summaryrefslogtreecommitdiff
path: root/jni/ruby/ext
diff options
context:
space:
mode:
authorJari Vetoniemi <jari.vetoniemi@indooratlas.com>2020-03-16 18:49:26 +0900
committerJari Vetoniemi <jari.vetoniemi@indooratlas.com>2020-03-30 00:39:06 +0900
commitfcbf63e62c627deae76c1b8cb8c0876c536ed811 (patch)
tree64cb17de3f41a2b6fef2368028fbd00349946994 /jni/ruby/ext
Fresh start
Diffstat (limited to 'jni/ruby/ext')
-rw-r--r--jni/ruby/ext/-test-/array/resize/Makefile267
-rw-r--r--jni/ruby/ext/-test-/array/resize/extconf.h3
-rw-r--r--jni/ruby/ext/-test-/array/resize/extconf.rb1
-rw-r--r--jni/ruby/ext/-test-/array/resize/resize.c14
-rw-r--r--jni/ruby/ext/-test-/bignum/Makefile371
-rw-r--r--jni/ruby/ext/-test-/bignum/big2str.c53
-rw-r--r--jni/ruby/ext/-test-/bignum/bigzero.c26
-rw-r--r--jni/ruby/ext/-test-/bignum/depend102
-rw-r--r--jni/ruby/ext/-test-/bignum/div.c35
-rw-r--r--jni/ruby/ext/-test-/bignum/extconf.h4
-rw-r--r--jni/ruby/ext/-test-/bignum/extconf.rb7
-rw-r--r--jni/ruby/ext/-test-/bignum/init.c11
-rw-r--r--jni/ruby/ext/-test-/bignum/intpack.c87
-rw-r--r--jni/ruby/ext/-test-/bignum/mul.c65
-rw-r--r--jni/ruby/ext/-test-/bignum/str2big.c38
-rw-r--r--jni/ruby/ext/-test-/bug-3571/Makefile267
-rw-r--r--jni/ruby/ext/-test-/bug-3571/bug.c23
-rw-r--r--jni/ruby/ext/-test-/bug-3571/extconf.h3
-rw-r--r--jni/ruby/ext/-test-/bug-3571/extconf.rb1
-rw-r--r--jni/ruby/ext/-test-/bug-3662/Makefile267
-rw-r--r--jni/ruby/ext/-test-/bug-3662/bug.c16
-rw-r--r--jni/ruby/ext/-test-/bug-3662/extconf.h3
-rw-r--r--jni/ruby/ext/-test-/bug-3662/extconf.rb1
-rw-r--r--jni/ruby/ext/-test-/bug-5832/Makefile267
-rw-r--r--jni/ruby/ext/-test-/bug-5832/bug.c14
-rw-r--r--jni/ruby/ext/-test-/bug-5832/extconf.h3
-rw-r--r--jni/ruby/ext/-test-/bug-5832/extconf.rb1
-rw-r--r--jni/ruby/ext/-test-/bug_reporter/Makefile267
-rw-r--r--jni/ruby/ext/-test-/bug_reporter/bug_reporter.c24
-rw-r--r--jni/ruby/ext/-test-/bug_reporter/extconf.h3
-rw-r--r--jni/ruby/ext/-test-/bug_reporter/extconf.rb1
-rw-r--r--jni/ruby/ext/-test-/class/Makefile267
-rw-r--r--jni/ruby/ext/-test-/class/class2name.c14
-rw-r--r--jni/ruby/ext/-test-/class/extconf.h4
-rw-r--r--jni/ruby/ext/-test-/class/extconf.rb7
-rw-r--r--jni/ruby/ext/-test-/class/init.c11
-rw-r--r--jni/ruby/ext/-test-/debug/Makefile301
-rw-r--r--jni/ruby/ext/-test-/debug/depend32
-rw-r--r--jni/ruby/ext/-test-/debug/extconf.h4
-rw-r--r--jni/ruby/ext/-test-/debug/extconf.rb6
-rw-r--r--jni/ruby/ext/-test-/debug/init.c11
-rw-r--r--jni/ruby/ext/-test-/debug/inspector.c32
-rw-r--r--jni/ruby/ext/-test-/debug/profile_frames.c43
-rw-r--r--jni/ruby/ext/-test-/exception/Makefile312
-rw-r--r--jni/ruby/ext/-test-/exception/dataerror.c31
-rw-r--r--jni/ruby/ext/-test-/exception/depend43
-rw-r--r--jni/ruby/ext/-test-/exception/enc_raise.c15
-rw-r--r--jni/ruby/ext/-test-/exception/ensured.c25
-rw-r--r--jni/ruby/ext/-test-/exception/extconf.h4
-rw-r--r--jni/ruby/ext/-test-/exception/extconf.rb6
-rw-r--r--jni/ruby/ext/-test-/exception/init.c11
-rw-r--r--jni/ruby/ext/-test-/fatal/Makefile267
-rw-r--r--jni/ruby/ext/-test-/fatal/extconf.h3
-rw-r--r--jni/ruby/ext/-test-/fatal/extconf.rb1
-rw-r--r--jni/ruby/ext/-test-/fatal/rb_fatal.c19
-rw-r--r--jni/ruby/ext/-test-/file/Makefile305
-rw-r--r--jni/ruby/ext/-test-/file/depend36
-rw-r--r--jni/ruby/ext/-test-/file/extconf.h11
-rw-r--r--jni/ruby/ext/-test-/file/extconf.rb21
-rw-r--r--jni/ruby/ext/-test-/file/fs.c74
-rw-r--r--jni/ruby/ext/-test-/file/init.c11
-rw-r--r--jni/ruby/ext/-test-/file/stat.c27
-rw-r--r--jni/ruby/ext/-test-/float/Makefile272
-rw-r--r--jni/ruby/ext/-test-/float/depend3
-rw-r--r--jni/ruby/ext/-test-/float/extconf.h4
-rw-r--r--jni/ruby/ext/-test-/float/extconf.rb7
-rw-r--r--jni/ruby/ext/-test-/float/init.c11
-rw-r--r--jni/ruby/ext/-test-/float/nextafter.c36
-rw-r--r--jni/ruby/ext/-test-/funcall/Makefile267
-rw-r--r--jni/ruby/ext/-test-/funcall/extconf.h3
-rw-r--r--jni/ruby/ext/-test-/funcall/extconf.rb2
-rw-r--r--jni/ruby/ext/-test-/funcall/passing_block.c30
-rw-r--r--jni/ruby/ext/-test-/hash/Makefile267
-rw-r--r--jni/ruby/ext/-test-/hash/delete.c16
-rw-r--r--jni/ruby/ext/-test-/hash/extconf.h4
-rw-r--r--jni/ruby/ext/-test-/hash/extconf.rb7
-rw-r--r--jni/ruby/ext/-test-/hash/init.c11
-rw-r--r--jni/ruby/ext/-test-/iseq_load/Makefile267
-rw-r--r--jni/ruby/ext/-test-/iseq_load/extconf.h3
-rw-r--r--jni/ruby/ext/-test-/iseq_load/extconf.rb1
-rw-r--r--jni/ruby/ext/-test-/iseq_load/iseq_load.c21
-rw-r--r--jni/ruby/ext/-test-/iter/Makefile267
-rw-r--r--jni/ruby/ext/-test-/iter/break.c25
-rw-r--r--jni/ruby/ext/-test-/iter/extconf.h4
-rw-r--r--jni/ruby/ext/-test-/iter/extconf.rb7
-rw-r--r--jni/ruby/ext/-test-/iter/init.c11
-rw-r--r--jni/ruby/ext/-test-/iter/yield.c16
-rw-r--r--jni/ruby/ext/-test-/load/dot.dot/Makefile267
-rw-r--r--jni/ruby/ext/-test-/load/dot.dot/dot.dot.c1
-rw-r--r--jni/ruby/ext/-test-/load/dot.dot/extconf.h3
-rw-r--r--jni/ruby/ext/-test-/load/dot.dot/extconf.rb1
-rw-r--r--jni/ruby/ext/-test-/marshal/compat/Makefile267
-rw-r--r--jni/ruby/ext/-test-/marshal/compat/extconf.h3
-rw-r--r--jni/ruby/ext/-test-/marshal/compat/extconf.rb1
-rw-r--r--jni/ruby/ext/-test-/marshal/compat/usrcompat.c32
-rw-r--r--jni/ruby/ext/-test-/marshal/usr/Makefile267
-rw-r--r--jni/ruby/ext/-test-/marshal/usr/extconf.h3
-rw-r--r--jni/ruby/ext/-test-/marshal/usr/extconf.rb1
-rw-r--r--jni/ruby/ext/-test-/marshal/usr/usrmarshal.c50
-rw-r--r--jni/ruby/ext/-test-/method/Makefile267
-rw-r--r--jni/ruby/ext/-test-/method/arity.c22
-rw-r--r--jni/ruby/ext/-test-/method/extconf.h4
-rw-r--r--jni/ruby/ext/-test-/method/extconf.rb6
-rw-r--r--jni/ruby/ext/-test-/method/init.c11
-rw-r--r--jni/ruby/ext/-test-/num2int/Makefile267
-rw-r--r--jni/ruby/ext/-test-/num2int/extconf.h3
-rw-r--r--jni/ruby/ext/-test-/num2int/extconf.rb1
-rw-r--r--jni/ruby/ext/-test-/num2int/num2int.c136
-rw-r--r--jni/ruby/ext/-test-/path_to_class/Makefile267
-rw-r--r--jni/ruby/ext/-test-/path_to_class/extconf.h4
-rw-r--r--jni/ruby/ext/-test-/path_to_class/extconf.rb6
-rw-r--r--jni/ruby/ext/-test-/path_to_class/path_to_class.c15
-rw-r--r--jni/ruby/ext/-test-/postponed_job/Makefile270
-rw-r--r--jni/ruby/ext/-test-/postponed_job/depend1
-rw-r--r--jni/ruby/ext/-test-/postponed_job/extconf.h3
-rw-r--r--jni/ruby/ext/-test-/postponed_job/extconf.rb1
-rw-r--r--jni/ruby/ext/-test-/postponed_job/postponed_job.c53
-rw-r--r--jni/ruby/ext/-test-/printf/Makefile272
-rw-r--r--jni/ruby/ext/-test-/printf/depend3
-rw-r--r--jni/ruby/ext/-test-/printf/extconf.h3
-rw-r--r--jni/ruby/ext/-test-/printf/extconf.rb1
-rw-r--r--jni/ruby/ext/-test-/printf/printf.c101
-rw-r--r--jni/ruby/ext/-test-/proc/Makefile267
-rw-r--r--jni/ruby/ext/-test-/proc/extconf.h4
-rw-r--r--jni/ruby/ext/-test-/proc/extconf.rb7
-rw-r--r--jni/ruby/ext/-test-/proc/init.c11
-rw-r--r--jni/ruby/ext/-test-/proc/receiver.c21
-rw-r--r--jni/ruby/ext/-test-/proc/super.c27
-rw-r--r--jni/ruby/ext/-test-/rational/Makefile289
-rw-r--r--jni/ruby/ext/-test-/rational/depend20
-rw-r--r--jni/ruby/ext/-test-/rational/extconf.h4
-rw-r--r--jni/ruby/ext/-test-/rational/extconf.rb7
-rw-r--r--jni/ruby/ext/-test-/rational/rat.c37
-rw-r--r--jni/ruby/ext/-test-/recursion/Makefile267
-rw-r--r--jni/ruby/ext/-test-/recursion/extconf.h3
-rw-r--r--jni/ruby/ext/-test-/recursion/extconf.rb2
-rw-r--r--jni/ruby/ext/-test-/recursion/recursion.c28
-rw-r--r--jni/ruby/ext/-test-/st/foreach/Makefile267
-rw-r--r--jni/ruby/ext/-test-/st/foreach/extconf.h3
-rw-r--r--jni/ruby/ext/-test-/st/foreach/extconf.rb1
-rw-r--r--jni/ruby/ext/-test-/st/foreach/foreach.c175
-rw-r--r--jni/ruby/ext/-test-/st/numhash/Makefile267
-rw-r--r--jni/ruby/ext/-test-/st/numhash/extconf.h3
-rw-r--r--jni/ruby/ext/-test-/st/numhash/extconf.rb1
-rw-r--r--jni/ruby/ext/-test-/st/numhash/numhash.c138
-rw-r--r--jni/ruby/ext/-test-/st/update/Makefile267
-rw-r--r--jni/ruby/ext/-test-/st/update/extconf.h3
-rw-r--r--jni/ruby/ext/-test-/st/update/extconf.rb1
-rw-r--r--jni/ruby/ext/-test-/st/update/update.c34
-rw-r--r--jni/ruby/ext/-test-/string/Makefile384
-rw-r--r--jni/ruby/ext/-test-/string/coderange.c47
-rw-r--r--jni/ruby/ext/-test-/string/cstr.c57
-rw-r--r--jni/ruby/ext/-test-/string/depend115
-rw-r--r--jni/ruby/ext/-test-/string/ellipsize.c13
-rw-r--r--jni/ruby/ext/-test-/string/enc_associate.c14
-rw-r--r--jni/ruby/ext/-test-/string/enc_str_buf_cat.c14
-rw-r--r--jni/ruby/ext/-test-/string/extconf.h4
-rw-r--r--jni/ruby/ext/-test-/string/extconf.rb7
-rw-r--r--jni/ruby/ext/-test-/string/init.c11
-rw-r--r--jni/ruby/ext/-test-/string/modify.c22
-rw-r--r--jni/ruby/ext/-test-/string/nofree.c13
-rw-r--r--jni/ruby/ext/-test-/string/normalize.c17
-rw-r--r--jni/ruby/ext/-test-/string/qsort.c61
-rw-r--r--jni/ruby/ext/-test-/string/set_len.c14
-rw-r--r--jni/ruby/ext/-test-/struct/Makefile267
-rw-r--r--jni/ruby/ext/-test-/struct/extconf.h4
-rw-r--r--jni/ruby/ext/-test-/struct/extconf.rb7
-rw-r--r--jni/ruby/ext/-test-/struct/init.c11
-rw-r--r--jni/ruby/ext/-test-/struct/member.c18
-rw-r--r--jni/ruby/ext/-test-/symbol/Makefile267
-rw-r--r--jni/ruby/ext/-test-/symbol/extconf.h4
-rw-r--r--jni/ruby/ext/-test-/symbol/extconf.rb7
-rw-r--r--jni/ruby/ext/-test-/symbol/init.c25
-rw-r--r--jni/ruby/ext/-test-/symbol/type.c78
-rw-r--r--jni/ruby/ext/-test-/tracepoint/Makefile291
-rw-r--r--jni/ruby/ext/-test-/tracepoint/depend22
-rw-r--r--jni/ruby/ext/-test-/tracepoint/extconf.h3
-rw-r--r--jni/ruby/ext/-test-/tracepoint/extconf.rb1
-rw-r--r--jni/ruby/ext/-test-/tracepoint/gc_hook.c80
-rw-r--r--jni/ruby/ext/-test-/tracepoint/tracepoint.c96
-rw-r--r--jni/ruby/ext/-test-/typeddata/Makefile267
-rw-r--r--jni/ruby/ext/-test-/typeddata/extconf.h3
-rw-r--r--jni/ruby/ext/-test-/typeddata/extconf.rb1
-rw-r--r--jni/ruby/ext/-test-/typeddata/typeddata.c20
-rw-r--r--jni/ruby/ext/-test-/wait_for_single_fd/Makefile283
-rw-r--r--jni/ruby/ext/-test-/wait_for_single_fd/depend14
-rw-r--r--jni/ruby/ext/-test-/wait_for_single_fd/extconf.h3
-rw-r--r--jni/ruby/ext/-test-/wait_for_single_fd/extconf.rb1
-rw-r--r--jni/ruby/ext/-test-/wait_for_single_fd/wait_for_single_fd.c30
-rw-r--r--jni/ruby/ext/-test-/win32/console/Makefile150
-rw-r--r--jni/ruby/ext/-test-/win32/console/attribute.c56
-rw-r--r--jni/ruby/ext/-test-/win32/console/depend1
-rw-r--r--jni/ruby/ext/-test-/win32/console/extconf.rb8
-rw-r--r--jni/ruby/ext/-test-/win32/console/init.c11
-rw-r--r--jni/ruby/ext/-test-/win32/dln/Makefile150
-rw-r--r--jni/ruby/ext/-test-/win32/dln/dlntest.c17
-rw-r--r--jni/ruby/ext/-test-/win32/dln/empty/Makefile150
-rw-r--r--jni/ruby/ext/-test-/win32/dln/empty/empty.c4
-rw-r--r--jni/ruby/ext/-test-/win32/dln/empty/extconf.rb3
-rw-r--r--jni/ruby/ext/-test-/win32/dln/extconf.rb37
-rw-r--r--jni/ruby/ext/-test-/win32/dln/libdlntest.c4
-rw-r--r--jni/ruby/ext/-test-/win32/dln/libdlntest.def2
-rw-r--r--jni/ruby/ext/-test-/win32/fd_setsize/Makefile150
-rw-r--r--jni/ruby/ext/-test-/win32/fd_setsize/depend1
-rw-r--r--jni/ruby/ext/-test-/win32/fd_setsize/extconf.rb3
-rw-r--r--jni/ruby/ext/-test-/win32/fd_setsize/fd_setsize.c55
-rw-r--r--jni/ruby/ext/.document103
-rw-r--r--jni/ruby/ext/Setup28
-rw-r--r--jni/ruby/ext/Setup.atheos29
-rw-r--r--jni/ruby/ext/Setup.emx31
-rw-r--r--jni/ruby/ext/Setup.nacl45
-rw-r--r--jni/ruby/ext/Setup.nt30
-rw-r--r--jni/ruby/ext/bigdecimal/Makefile313
-rw-r--r--jni/ruby/ext/bigdecimal/bigdecimal.c6266
-rw-r--r--jni/ruby/ext/bigdecimal/bigdecimal.gemspec31
-rw-r--r--jni/ruby/ext/bigdecimal/bigdecimal.h314
-rw-r--r--jni/ruby/ext/bigdecimal/depend13
-rw-r--r--jni/ruby/ext/bigdecimal/extconf.h5
-rw-r--r--jni/ruby/ext/bigdecimal/extconf.rb6
-rw-r--r--jni/ruby/ext/bigdecimal/lib/bigdecimal/jacobian.rb87
-rw-r--r--jni/ruby/ext/bigdecimal/lib/bigdecimal/ludcmp.rb88
-rw-r--r--jni/ruby/ext/bigdecimal/lib/bigdecimal/math.rb231
-rw-r--r--jni/ruby/ext/bigdecimal/lib/bigdecimal/newton.rb79
-rw-r--r--jni/ruby/ext/bigdecimal/lib/bigdecimal/util.rb127
-rw-r--r--jni/ruby/ext/bigdecimal/sample/linear.rb72
-rw-r--r--jni/ruby/ext/bigdecimal/sample/nlsolve.rb39
-rw-r--r--jni/ruby/ext/bigdecimal/sample/pi.rb20
-rw-r--r--jni/ruby/ext/continuation/Makefile267
-rw-r--r--jni/ruby/ext/continuation/continuation.c13
-rw-r--r--jni/ruby/ext/continuation/extconf.h3
-rw-r--r--jni/ruby/ext/continuation/extconf.rb3
-rw-r--r--jni/ruby/ext/coverage/Makefile310
-rw-r--r--jni/ruby/ext/coverage/coverage.c109
-rw-r--r--jni/ruby/ext/coverage/depend41
-rw-r--r--jni/ruby/ext/coverage/extconf.h3
-rw-r--r--jni/ruby/ext/coverage/extconf.rb4
-rw-r--r--jni/ruby/ext/date/Makefile333
-rw-r--r--jni/ruby/ext/date/date_core.c9573
-rw-r--r--jni/ruby/ext/date/date_parse.c3128
-rw-r--r--jni/ruby/ext/date/date_strftime.c633
-rw-r--r--jni/ruby/ext/date/date_strptime.c701
-rw-r--r--jni/ruby/ext/date/date_tmx.h56
-rw-r--r--jni/ruby/ext/date/depend53
-rw-r--r--jni/ruby/ext/date/extconf.h3
-rw-r--r--jni/ruby/ext/date/extconf.rb5
-rw-r--r--jni/ruby/ext/date/lib/date.rb60
-rw-r--r--jni/ruby/ext/dbm/Makefile150
-rw-r--r--jni/ruby/ext/dbm/dbm.c1159
-rw-r--r--jni/ruby/ext/dbm/extconf.rb289
-rw-r--r--jni/ruby/ext/digest/Makefile307
-rw-r--r--jni/ruby/ext/digest/bubblebabble/Makefile282
-rw-r--r--jni/ruby/ext/digest/bubblebabble/bubblebabble.c146
-rw-r--r--jni/ruby/ext/digest/bubblebabble/depend13
-rw-r--r--jni/ruby/ext/digest/bubblebabble/extconf.h4
-rw-r--r--jni/ruby/ext/digest/bubblebabble/extconf.rb6
-rw-r--r--jni/ruby/ext/digest/defs.h19
-rw-r--r--jni/ruby/ext/digest/depend13
-rw-r--r--jni/ruby/ext/digest/digest.c744
-rw-r--r--jni/ruby/ext/digest/digest.h32
-rw-r--r--jni/ruby/ext/digest/extconf.h3
-rw-r--r--jni/ruby/ext/digest/extconf.rb10
-rw-r--r--jni/ruby/ext/digest/lib/digest.rb108
-rw-r--r--jni/ruby/ext/digest/md5/Makefile287
-rw-r--r--jni/ruby/ext/digest/md5/depend18
-rw-r--r--jni/ruby/ext/digest/md5/extconf.h7
-rw-r--r--jni/ruby/ext/digest/md5/extconf.rb27
-rw-r--r--jni/ruby/ext/digest/md5/md5.c424
-rw-r--r--jni/ruby/ext/digest/md5/md5.h80
-rw-r--r--jni/ruby/ext/digest/md5/md5init.c45
-rw-r--r--jni/ruby/ext/digest/md5/md5ossl.c9
-rw-r--r--jni/ruby/ext/digest/md5/md5ossl.h13
-rw-r--r--jni/ruby/ext/digest/rmd160/Makefile297
-rw-r--r--jni/ruby/ext/digest/rmd160/depend28
-rw-r--r--jni/ruby/ext/digest/rmd160/extconf.h8
-rw-r--r--jni/ruby/ext/digest/rmd160/extconf.rb27
-rw-r--r--jni/ruby/ext/digest/rmd160/rmd160.c463
-rw-r--r--jni/ruby/ext/digest/rmd160/rmd160.h56
-rw-r--r--jni/ruby/ext/digest/rmd160/rmd160init.c45
-rw-r--r--jni/ruby/ext/digest/rmd160/rmd160ossl.c8
-rw-r--r--jni/ruby/ext/digest/rmd160/rmd160ossl.h19
-rw-r--r--jni/ruby/ext/digest/sha1/Makefile297
-rw-r--r--jni/ruby/ext/digest/sha1/depend28
-rw-r--r--jni/ruby/ext/digest/sha1/extconf.h7
-rw-r--r--jni/ruby/ext/digest/sha1/extconf.rb27
-rw-r--r--jni/ruby/ext/digest/sha1/sha1.c271
-rw-r--r--jni/ruby/ext/digest/sha1/sha1.h39
-rw-r--r--jni/ruby/ext/digest/sha1/sha1init.c45
-rw-r--r--jni/ruby/ext/digest/sha1/sha1ossl.c10
-rw-r--r--jni/ruby/ext/digest/sha1/sha1ossl.h20
-rw-r--r--jni/ruby/ext/digest/sha2/Makefile308
-rw-r--r--jni/ruby/ext/digest/sha2/depend28
-rw-r--r--jni/ruby/ext/digest/sha2/extconf.h13
-rw-r--r--jni/ruby/ext/digest/sha2/extconf.rb32
-rw-r--r--jni/ruby/ext/digest/sha2/lib/sha2.rb107
-rw-r--r--jni/ruby/ext/digest/sha2/sha2.c1081
-rw-r--r--jni/ruby/ext/digest/sha2/sha2.h225
-rw-r--r--jni/ruby/ext/digest/sha2/sha2init.c58
-rw-r--r--jni/ruby/ext/digest/sha2/sha2ossl.c13
-rw-r--r--jni/ruby/ext/digest/sha2/sha2ossl.h17
-rw-r--r--jni/ruby/ext/digest/test.sh30
-rw-r--r--jni/ruby/ext/etc/Makefile278
-rw-r--r--jni/ruby/ext/etc/constdefs.h1494
-rw-r--r--jni/ruby/ext/etc/depend9
-rw-r--r--jni/ruby/ext/etc/etc.c1199
-rw-r--r--jni/ruby/ext/etc/extconf.h18
-rw-r--r--jni/ruby/ext/etc/extconf.rb43
-rw-r--r--jni/ruby/ext/etc/mkconstants.rb331
-rwxr-xr-xjni/ruby/ext/extmk.rb774
-rw-r--r--jni/ruby/ext/fcntl/Makefile267
-rw-r--r--jni/ruby/ext/fcntl/extconf.h3
-rw-r--r--jni/ruby/ext/fcntl/extconf.rb2
-rw-r--r--jni/ruby/ext/fcntl/fcntl.c245
-rw-r--r--jni/ruby/ext/fiber/Makefile267
-rw-r--r--jni/ruby/ext/fiber/extconf.h3
-rw-r--r--jni/ruby/ext/fiber/extconf.rb3
-rw-r--r--jni/ruby/ext/fiber/fiber.c8
-rw-r--r--jni/ruby/ext/fiddle/Makefile381
-rw-r--r--jni/ruby/ext/fiddle/closure.c316
-rw-r--r--jni/ruby/ext/fiddle/closure.h8
-rw-r--r--jni/ruby/ext/fiddle/conversions.c141
-rw-r--r--jni/ruby/ext/fiddle/conversions.h44
-rw-r--r--jni/ruby/ext/fiddle/depend55
-rw-r--r--jni/ruby/ext/fiddle/extconf.h13
-rw-r--r--jni/ruby/ext/fiddle/extconf.rb168
-rw-r--r--jni/ruby/ext/fiddle/extlibs2
-rw-r--r--jni/ruby/ext/fiddle/fiddle.c454
-rw-r--r--jni/ruby/ext/fiddle/fiddle.h138
-rw-r--r--jni/ruby/ext/fiddle/function.c279
-rw-r--r--jni/ruby/ext/fiddle/function.h8
-rw-r--r--jni/ruby/ext/fiddle/handle.c479
-rw-r--r--jni/ruby/ext/fiddle/lib/fiddle.rb55
-rw-r--r--jni/ruby/ext/fiddle/lib/fiddle/closure.rb48
-rw-r--r--jni/ruby/ext/fiddle/lib/fiddle/cparser.rb176
-rw-r--r--jni/ruby/ext/fiddle/lib/fiddle/function.rb17
-rw-r--r--jni/ruby/ext/fiddle/lib/fiddle/import.rb314
-rw-r--r--jni/ruby/ext/fiddle/lib/fiddle/pack.rb128
-rw-r--r--jni/ruby/ext/fiddle/lib/fiddle/struct.rb243
-rw-r--r--jni/ruby/ext/fiddle/lib/fiddle/types.rb71
-rw-r--r--jni/ruby/ext/fiddle/lib/fiddle/value.rb112
-rw-r--r--jni/ruby/ext/fiddle/libffi-3.2.1/ChangeLog5505
-rw-r--r--jni/ruby/ext/fiddle/libffi-3.2.1/ChangeLog.libffi584
-rw-r--r--jni/ruby/ext/fiddle/libffi-3.2.1/ChangeLog.libffi-3.16000
-rw-r--r--jni/ruby/ext/fiddle/libffi-3.2.1/ChangeLog.libgcj40
-rw-r--r--jni/ruby/ext/fiddle/libffi-3.2.1/ChangeLog.v1764
-rw-r--r--jni/ruby/ext/fiddle/libffi-3.2.1/LICENSE21
-rw-r--r--jni/ruby/ext/fiddle/libffi-3.2.1/Makefile.am258
-rw-r--r--jni/ruby/ext/fiddle/libffi-3.2.1/Makefile.in2177
-rw-r--r--jni/ruby/ext/fiddle/libffi-3.2.1/README447
-rw-r--r--jni/ruby/ext/fiddle/libffi-3.2.1/acinclude.m492
-rw-r--r--jni/ruby/ext/fiddle/libffi-3.2.1/aclocal.m41961
-rwxr-xr-xjni/ruby/ext/fiddle/libffi-3.2.1/compile347
-rwxr-xr-xjni/ruby/ext/fiddle/libffi-3.2.1/config.guess1558
-rwxr-xr-xjni/ruby/ext/fiddle/libffi-3.2.1/config.sub1788
-rwxr-xr-xjni/ruby/ext/fiddle/libffi-3.2.1/configure21768
-rw-r--r--jni/ruby/ext/fiddle/libffi-3.2.1/configure.ac625
-rwxr-xr-xjni/ruby/ext/fiddle/libffi-3.2.1/depcomp791
-rw-r--r--jni/ruby/ext/fiddle/libffi-3.2.1/doc/libffi.info765
-rw-r--r--jni/ruby/ext/fiddle/libffi-3.2.1/doc/libffi.texi770
-rw-r--r--jni/ruby/ext/fiddle/libffi-3.2.1/doc/stamp-vti4
-rw-r--r--jni/ruby/ext/fiddle/libffi-3.2.1/doc/version.texi4
-rw-r--r--jni/ruby/ext/fiddle/libffi-3.2.1/fficonfig.h.in214
-rw-r--r--jni/ruby/ext/fiddle/libffi-3.2.1/generate-darwin-source-and-headers.py209
-rw-r--r--jni/ruby/ext/fiddle/libffi-3.2.1/include/Makefile.am9
-rw-r--r--jni/ruby/ext/fiddle/libffi-3.2.1/include/Makefile.in587
-rw-r--r--jni/ruby/ext/fiddle/libffi-3.2.1/include/ffi.h.in487
-rw-r--r--jni/ruby/ext/fiddle/libffi-3.2.1/include/ffi_common.h132
-rwxr-xr-xjni/ruby/ext/fiddle/libffi-3.2.1/install-sh527
-rw-r--r--jni/ruby/ext/fiddle/libffi-3.2.1/libffi.pc.in11
-rw-r--r--jni/ruby/ext/fiddle/libffi-3.2.1/libffi.xcodeproj/project.pbxproj637
-rwxr-xr-xjni/ruby/ext/fiddle/libffi-3.2.1/libtool-ldflags106
-rw-r--r--jni/ruby/ext/fiddle/libffi-3.2.1/libtool-version29
-rw-r--r--jni/ruby/ext/fiddle/libffi-3.2.1/ltmain.sh9655
-rw-r--r--jni/ruby/ext/fiddle/libffi-3.2.1/m4/asmcfi.m413
-rw-r--r--jni/ruby/ext/fiddle/libffi-3.2.1/m4/ax_append_flag.m469
-rw-r--r--jni/ruby/ext/fiddle/libffi-3.2.1/m4/ax_cc_maxopt.m4181
-rw-r--r--jni/ruby/ext/fiddle/libffi-3.2.1/m4/ax_cflags_warn_all.m4122
-rw-r--r--jni/ruby/ext/fiddle/libffi-3.2.1/m4/ax_check_compile_flag.m472
-rw-r--r--jni/ruby/ext/fiddle/libffi-3.2.1/m4/ax_compiler_vendor.m484
-rw-r--r--jni/ruby/ext/fiddle/libffi-3.2.1/m4/ax_configure_args.m470
-rw-r--r--jni/ruby/ext/fiddle/libffi-3.2.1/m4/ax_enable_builddir.m4301
-rw-r--r--jni/ruby/ext/fiddle/libffi-3.2.1/m4/ax_gcc_archflag.m4225
-rw-r--r--jni/ruby/ext/fiddle/libffi-3.2.1/m4/ax_gcc_x86_cpuid.m479
-rw-r--r--jni/ruby/ext/fiddle/libffi-3.2.1/m4/libtool.m47986
-rw-r--r--jni/ruby/ext/fiddle/libffi-3.2.1/m4/ltoptions.m4384
-rw-r--r--jni/ruby/ext/fiddle/libffi-3.2.1/m4/ltsugar.m4123
-rw-r--r--jni/ruby/ext/fiddle/libffi-3.2.1/m4/ltversion.m423
-rw-r--r--jni/ruby/ext/fiddle/libffi-3.2.1/m4/lt~obsolete.m498
-rw-r--r--jni/ruby/ext/fiddle/libffi-3.2.1/man/Makefile.am8
-rw-r--r--jni/ruby/ext/fiddle/libffi-3.2.1/man/Makefile.in541
-rw-r--r--jni/ruby/ext/fiddle/libffi-3.2.1/man/ffi.341
-rw-r--r--jni/ruby/ext/fiddle/libffi-3.2.1/man/ffi_call.3103
-rw-r--r--jni/ruby/ext/fiddle/libffi-3.2.1/man/ffi_prep_cif.368
-rw-r--r--jni/ruby/ext/fiddle/libffi-3.2.1/man/ffi_prep_cif_var.373
-rwxr-xr-xjni/ruby/ext/fiddle/libffi-3.2.1/mdate-sh224
-rwxr-xr-xjni/ruby/ext/fiddle/libffi-3.2.1/missing215
-rwxr-xr-xjni/ruby/ext/fiddle/libffi-3.2.1/msvcc.sh257
-rw-r--r--jni/ruby/ext/fiddle/libffi-3.2.1/src/aarch64/ffi.c1179
-rw-r--r--jni/ruby/ext/fiddle/libffi-3.2.1/src/aarch64/ffitarget.h63
-rw-r--r--jni/ruby/ext/fiddle/libffi-3.2.1/src/aarch64/sysv.S333
-rw-r--r--jni/ruby/ext/fiddle/libffi-3.2.1/src/alpha/ffi.c288
-rw-r--r--jni/ruby/ext/fiddle/libffi-3.2.1/src/alpha/ffitarget.h53
-rw-r--r--jni/ruby/ext/fiddle/libffi-3.2.1/src/alpha/osf.S387
-rw-r--r--jni/ruby/ext/fiddle/libffi-3.2.1/src/arc/arcompact.S135
-rw-r--r--jni/ruby/ext/fiddle/libffi-3.2.1/src/arc/ffi.c268
-rw-r--r--jni/ruby/ext/fiddle/libffi-3.2.1/src/arc/ffitarget.h53
-rw-r--r--jni/ruby/ext/fiddle/libffi-3.2.1/src/arm/ffi.c931
-rw-r--r--jni/ruby/ext/fiddle/libffi-3.2.1/src/arm/ffitarget.h71
-rwxr-xr-xjni/ruby/ext/fiddle/libffi-3.2.1/src/arm/gentramp.sh118
-rw-r--r--jni/ruby/ext/fiddle/libffi-3.2.1/src/arm/sysv.S491
-rw-r--r--jni/ruby/ext/fiddle/libffi-3.2.1/src/arm/trampoline.S4450
-rw-r--r--jni/ruby/ext/fiddle/libffi-3.2.1/src/avr32/ffi.c423
-rw-r--r--jni/ruby/ext/fiddle/libffi-3.2.1/src/avr32/ffitarget.h55
-rw-r--r--jni/ruby/ext/fiddle/libffi-3.2.1/src/avr32/sysv.S208
-rw-r--r--jni/ruby/ext/fiddle/libffi-3.2.1/src/bfin/ffi.c196
-rw-r--r--jni/ruby/ext/fiddle/libffi-3.2.1/src/bfin/ffitarget.h43
-rw-r--r--jni/ruby/ext/fiddle/libffi-3.2.1/src/bfin/sysv.S179
-rw-r--r--jni/ruby/ext/fiddle/libffi-3.2.1/src/closures.c688
-rw-r--r--jni/ruby/ext/fiddle/libffi-3.2.1/src/cris/ffi.c386
-rw-r--r--jni/ruby/ext/fiddle/libffi-3.2.1/src/cris/ffitarget.h56
-rw-r--r--jni/ruby/ext/fiddle/libffi-3.2.1/src/cris/sysv.S215
-rw-r--r--jni/ruby/ext/fiddle/libffi-3.2.1/src/debug.c64
-rw-r--r--jni/ruby/ext/fiddle/libffi-3.2.1/src/dlmalloc.c5161
-rw-r--r--jni/ruby/ext/fiddle/libffi-3.2.1/src/frv/eabi.S128
-rw-r--r--jni/ruby/ext/fiddle/libffi-3.2.1/src/frv/ffi.c292
-rw-r--r--jni/ruby/ext/fiddle/libffi-3.2.1/src/frv/ffitarget.h62
-rw-r--r--jni/ruby/ext/fiddle/libffi-3.2.1/src/ia64/ffi.c586
-rw-r--r--jni/ruby/ext/fiddle/libffi-3.2.1/src/ia64/ffitarget.h55
-rw-r--r--jni/ruby/ext/fiddle/libffi-3.2.1/src/ia64/ia64_flags.h40
-rw-r--r--jni/ruby/ext/fiddle/libffi-3.2.1/src/ia64/unix.S560
-rw-r--r--jni/ruby/ext/fiddle/libffi-3.2.1/src/java_raw_api.c374
-rw-r--r--jni/ruby/ext/fiddle/libffi-3.2.1/src/m32r/ffi.c232
-rw-r--r--jni/ruby/ext/fiddle/libffi-3.2.1/src/m32r/ffitarget.h53
-rw-r--r--jni/ruby/ext/fiddle/libffi-3.2.1/src/m32r/sysv.S121
-rw-r--r--jni/ruby/ext/fiddle/libffi-3.2.1/src/m68k/ffi.c362
-rw-r--r--jni/ruby/ext/fiddle/libffi-3.2.1/src/m68k/ffitarget.h54
-rw-r--r--jni/ruby/ext/fiddle/libffi-3.2.1/src/m68k/sysv.S330
-rw-r--r--jni/ruby/ext/fiddle/libffi-3.2.1/src/m88k/ffi.c400
-rw-r--r--jni/ruby/ext/fiddle/libffi-3.2.1/src/m88k/ffitarget.h49
-rw-r--r--jni/ruby/ext/fiddle/libffi-3.2.1/src/m88k/obsd.S209
-rw-r--r--jni/ruby/ext/fiddle/libffi-3.2.1/src/metag/ffi.c330
-rw-r--r--jni/ruby/ext/fiddle/libffi-3.2.1/src/metag/ffitarget.h53
-rw-r--r--jni/ruby/ext/fiddle/libffi-3.2.1/src/metag/sysv.S311
-rw-r--r--jni/ruby/ext/fiddle/libffi-3.2.1/src/microblaze/ffi.c321
-rw-r--r--jni/ruby/ext/fiddle/libffi-3.2.1/src/microblaze/ffitarget.h53
-rw-r--r--jni/ruby/ext/fiddle/libffi-3.2.1/src/microblaze/sysv.S302
-rw-r--r--jni/ruby/ext/fiddle/libffi-3.2.1/src/mips/ffi.c1050
-rw-r--r--jni/ruby/ext/fiddle/libffi-3.2.1/src/mips/ffitarget.h247
-rw-r--r--jni/ruby/ext/fiddle/libffi-3.2.1/src/mips/n32.S576
-rw-r--r--jni/ruby/ext/fiddle/libffi-3.2.1/src/mips/o32.S381
-rw-r--r--jni/ruby/ext/fiddle/libffi-3.2.1/src/moxie/eabi.S101
-rw-r--r--jni/ruby/ext/fiddle/libffi-3.2.1/src/moxie/ffi.c272
-rw-r--r--jni/ruby/ext/fiddle/libffi-3.2.1/src/moxie/ffitarget.h52
-rw-r--r--jni/ruby/ext/fiddle/libffi-3.2.1/src/nios2/ffi.c304
-rw-r--r--jni/ruby/ext/fiddle/libffi-3.2.1/src/nios2/ffitarget.h52
-rw-r--r--jni/ruby/ext/fiddle/libffi-3.2.1/src/nios2/sysv.S136
-rw-r--r--jni/ruby/ext/fiddle/libffi-3.2.1/src/or1k/ffi.c328
-rw-r--r--jni/ruby/ext/fiddle/libffi-3.2.1/src/or1k/ffitarget.h58
-rw-r--r--jni/ruby/ext/fiddle/libffi-3.2.1/src/or1k/sysv.S107
-rw-r--r--jni/ruby/ext/fiddle/libffi-3.2.1/src/pa/ffi.c719
-rw-r--r--jni/ruby/ext/fiddle/libffi-3.2.1/src/pa/ffitarget.h85
-rw-r--r--jni/ruby/ext/fiddle/libffi-3.2.1/src/pa/hpux32.S368
-rw-r--r--jni/ruby/ext/fiddle/libffi-3.2.1/src/pa/linux.S357
-rw-r--r--jni/ruby/ext/fiddle/libffi-3.2.1/src/powerpc/aix.S328
-rw-r--r--jni/ruby/ext/fiddle/libffi-3.2.1/src/powerpc/aix_closure.S447
-rw-r--r--jni/ruby/ext/fiddle/libffi-3.2.1/src/powerpc/asm.h125
-rw-r--r--jni/ruby/ext/fiddle/libffi-3.2.1/src/powerpc/darwin.S378
-rw-r--r--jni/ruby/ext/fiddle/libffi-3.2.1/src/powerpc/darwin_closure.S571
-rw-r--r--jni/ruby/ext/fiddle/libffi-3.2.1/src/powerpc/ffi.c141
-rw-r--r--jni/ruby/ext/fiddle/libffi-3.2.1/src/powerpc/ffi_darwin.c1359
-rw-r--r--jni/ruby/ext/fiddle/libffi-3.2.1/src/powerpc/ffi_linux64.c943
-rw-r--r--jni/ruby/ext/fiddle/libffi-3.2.1/src/powerpc/ffi_powerpc.h77
-rw-r--r--jni/ruby/ext/fiddle/libffi-3.2.1/src/powerpc/ffi_sysv.c931
-rw-r--r--jni/ruby/ext/fiddle/libffi-3.2.1/src/powerpc/ffitarget.h183
-rw-r--r--jni/ruby/ext/fiddle/libffi-3.2.1/src/powerpc/linux64.S261
-rw-r--r--jni/ruby/ext/fiddle/libffi-3.2.1/src/powerpc/linux64_closure.S392
-rw-r--r--jni/ruby/ext/fiddle/libffi-3.2.1/src/powerpc/ppc_closure.S384
-rw-r--r--jni/ruby/ext/fiddle/libffi-3.2.1/src/powerpc/sysv.S220
-rw-r--r--jni/ruby/ext/fiddle/libffi-3.2.1/src/prep_cif.c253
-rw-r--r--jni/ruby/ext/fiddle/libffi-3.2.1/src/raw_api.c267
-rw-r--r--jni/ruby/ext/fiddle/libffi-3.2.1/src/s390/ffi.c792
-rw-r--r--jni/ruby/ext/fiddle/libffi-3.2.1/src/s390/ffitarget.h69
-rw-r--r--jni/ruby/ext/fiddle/libffi-3.2.1/src/s390/sysv.S434
-rw-r--r--jni/ruby/ext/fiddle/libffi-3.2.1/src/sh/ffi.c717
-rw-r--r--jni/ruby/ext/fiddle/libffi-3.2.1/src/sh/ffitarget.h54
-rw-r--r--jni/ruby/ext/fiddle/libffi-3.2.1/src/sh/sysv.S850
-rw-r--r--jni/ruby/ext/fiddle/libffi-3.2.1/src/sh64/ffi.c469
-rw-r--r--jni/ruby/ext/fiddle/libffi-3.2.1/src/sh64/ffitarget.h58
-rw-r--r--jni/ruby/ext/fiddle/libffi-3.2.1/src/sh64/sysv.S539
-rw-r--r--jni/ruby/ext/fiddle/libffi-3.2.1/src/sparc/ffi.c681
-rw-r--r--jni/ruby/ext/fiddle/libffi-3.2.1/src/sparc/ffitarget.h73
-rw-r--r--jni/ruby/ext/fiddle/libffi-3.2.1/src/sparc/v8.S346
-rw-r--r--jni/ruby/ext/fiddle/libffi-3.2.1/src/sparc/v9.S307
-rw-r--r--jni/ruby/ext/fiddle/libffi-3.2.1/src/tile/ffi.c355
-rw-r--r--jni/ruby/ext/fiddle/libffi-3.2.1/src/tile/ffitarget.h65
-rw-r--r--jni/ruby/ext/fiddle/libffi-3.2.1/src/tile/tile.S360
-rw-r--r--jni/ruby/ext/fiddle/libffi-3.2.1/src/types.c106
-rw-r--r--jni/ruby/ext/fiddle/libffi-3.2.1/src/vax/elfbsd.S195
-rw-r--r--jni/ruby/ext/fiddle/libffi-3.2.1/src/vax/ffi.c276
-rw-r--r--jni/ruby/ext/fiddle/libffi-3.2.1/src/vax/ffitarget.h49
-rw-r--r--jni/ruby/ext/fiddle/libffi-3.2.1/src/x86/darwin.S444
-rw-r--r--jni/ruby/ext/fiddle/libffi-3.2.1/src/x86/darwin64.S416
-rw-r--r--jni/ruby/ext/fiddle/libffi-3.2.1/src/x86/ffi.c935
-rw-r--r--jni/ruby/ext/fiddle/libffi-3.2.1/src/x86/ffi64.c676
-rw-r--r--jni/ruby/ext/fiddle/libffi-3.2.1/src/x86/ffitarget.h152
-rw-r--r--jni/ruby/ext/fiddle/libffi-3.2.1/src/x86/freebsd.S463
-rw-r--r--jni/ruby/ext/fiddle/libffi-3.2.1/src/x86/sysv.S483
-rw-r--r--jni/ruby/ext/fiddle/libffi-3.2.1/src/x86/unix64.S432
-rw-r--r--jni/ruby/ext/fiddle/libffi-3.2.1/src/x86/win32.S1351
-rw-r--r--jni/ruby/ext/fiddle/libffi-3.2.1/src/x86/win64.S519
-rw-r--r--jni/ruby/ext/fiddle/libffi-3.2.1/src/xtensa/ffi.c298
-rw-r--r--jni/ruby/ext/fiddle/libffi-3.2.1/src/xtensa/ffitarget.h53
-rw-r--r--jni/ruby/ext/fiddle/libffi-3.2.1/src/xtensa/sysv.S253
-rw-r--r--jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/Makefile.am85
-rw-r--r--jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/Makefile.in590
-rw-r--r--jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/config/default.exp1
-rw-r--r--jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/lib/libffi.exp413
-rw-r--r--jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/lib/target-libpath.exp283
-rw-r--r--jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/lib/wrapper.exp45
-rw-r--r--jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/call.exp43
-rw-r--r--jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/closure_fn0.c89
-rw-r--r--jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/closure_fn1.c81
-rw-r--r--jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/closure_fn2.c81
-rw-r--r--jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/closure_fn3.c82
-rw-r--r--jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/closure_fn4.c89
-rw-r--r--jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/closure_fn5.c92
-rw-r--r--jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/closure_fn6.c90
-rw-r--r--jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/closure_loc_fn0.c95
-rw-r--r--jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/closure_simple.c55
-rw-r--r--jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/cls_12byte.c94
-rw-r--r--jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/cls_16byte.c95
-rw-r--r--jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/cls_18byte.c96
-rw-r--r--jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/cls_19byte.c102
-rw-r--r--jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/cls_1_1byte.c89
-rw-r--r--jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/cls_20byte.c91
-rw-r--r--jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/cls_20byte1.c93
-rw-r--r--jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/cls_24byte.c113
-rw-r--r--jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/cls_2byte.c90
-rw-r--r--jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/cls_3_1byte.c95
-rw-r--r--jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/cls_3byte1.c90
-rw-r--r--jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/cls_3byte2.c90
-rw-r--r--jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/cls_4_1byte.c98
-rw-r--r--jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/cls_4byte.c90
-rw-r--r--jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/cls_5_1_byte.c109
-rw-r--r--jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/cls_5byte.c98
-rw-r--r--jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/cls_64byte.c124
-rw-r--r--jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/cls_6_1_byte.c113
-rw-r--r--jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/cls_6byte.c99
-rw-r--r--jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/cls_7_1_byte.c117
-rw-r--r--jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/cls_7byte.c97
-rw-r--r--jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/cls_8byte.c88
-rw-r--r--jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/cls_9byte1.c90
-rw-r--r--jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/cls_9byte2.c91
-rw-r--r--jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/cls_align_double.c93
-rw-r--r--jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/cls_align_float.c91
-rw-r--r--jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/cls_align_longdouble.c92
-rw-r--r--jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/cls_align_longdouble_split.c134
-rw-r--r--jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/cls_align_longdouble_split2.c117
-rw-r--r--jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/cls_align_pointer.c95
-rw-r--r--jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/cls_align_sint16.c91
-rw-r--r--jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/cls_align_sint32.c91
-rw-r--r--jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/cls_align_sint64.c92
-rw-r--r--jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/cls_align_uint16.c91
-rw-r--r--jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/cls_align_uint32.c91
-rw-r--r--jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/cls_align_uint64.c93
-rw-r--r--jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/cls_dbls_struct.c66
-rw-r--r--jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/cls_double.c43
-rw-r--r--jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/cls_double_va.c61
-rw-r--r--jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/cls_float.c42
-rw-r--r--jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/cls_longdouble.c107
-rw-r--r--jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/cls_longdouble_va.c61
-rw-r--r--jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/cls_multi_schar.c74
-rw-r--r--jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/cls_multi_sshort.c74
-rw-r--r--jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/cls_multi_sshortchar.c86
-rw-r--r--jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/cls_multi_uchar.c91
-rw-r--r--jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/cls_multi_ushort.c74
-rw-r--r--jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/cls_multi_ushortchar.c86
-rw-r--r--jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/cls_pointer.c74
-rw-r--r--jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/cls_pointer_stack.c142
-rw-r--r--jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/cls_schar.c44
-rw-r--r--jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/cls_sint.c42
-rw-r--r--jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/cls_sshort.c42
-rw-r--r--jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/cls_struct_va1.c114
-rw-r--r--jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/cls_uchar.c42
-rw-r--r--jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/cls_uchar_va.c44
-rw-r--r--jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/cls_uint.c43
-rw-r--r--jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/cls_uint_va.c45
-rw-r--r--jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/cls_ulong_va.c45
-rw-r--r--jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/cls_ulonglong.c47
-rw-r--r--jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/cls_ushort.c43
-rw-r--r--jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/cls_ushort_va.c44
-rw-r--r--jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/err_bad_abi.c36
-rw-r--r--jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/err_bad_typedef.c26
-rw-r--r--jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/ffitest.h135
-rw-r--r--jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/float.c59
-rw-r--r--jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/float1.c58
-rw-r--r--jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/float2.c58
-rw-r--r--jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/float3.c72
-rw-r--r--jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/float4.c62
-rw-r--r--jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/float_va.c107
-rw-r--r--jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/huge_struct.c343
-rw-r--r--jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/many.c59
-rw-r--r--jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/many2.c57
-rw-r--r--jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/negint.c52
-rw-r--r--jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/nested_struct.c152
-rw-r--r--jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/nested_struct1.c161
-rw-r--r--jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/nested_struct10.c133
-rw-r--r--jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/nested_struct11.c121
-rw-r--r--jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/nested_struct2.c110
-rw-r--r--jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/nested_struct3.c111
-rw-r--r--jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/nested_struct4.c111
-rw-r--r--jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/nested_struct5.c112
-rw-r--r--jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/nested_struct6.c131
-rw-r--r--jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/nested_struct7.c111
-rw-r--r--jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/nested_struct8.c131
-rw-r--r--jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/nested_struct9.c131
-rw-r--r--jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/problem1.c90
-rw-r--r--jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/promotion.c59
-rw-r--r--jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/pyobjc-tc.c114
-rw-r--r--jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/return_dbl.c36
-rw-r--r--jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/return_dbl1.c43
-rw-r--r--jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/return_dbl2.c42
-rw-r--r--jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/return_fl.c35
-rw-r--r--jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/return_fl1.c36
-rw-r--r--jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/return_fl2.c49
-rw-r--r--jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/return_fl3.c42
-rw-r--r--jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/return_ldl.c34
-rw-r--r--jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/return_ll.c41
-rw-r--r--jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/return_ll1.c43
-rw-r--r--jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/return_sc.c36
-rw-r--r--jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/return_sl.c38
-rw-r--r--jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/return_uc.c38
-rw-r--r--jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/return_ul.c38
-rw-r--r--jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/stret_large.c145
-rw-r--r--jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/stret_large2.c148
-rw-r--r--jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/stret_medium.c124
-rw-r--r--jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/stret_medium2.c125
-rw-r--r--jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/strlen.c44
-rw-r--r--jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/strlen2.c49
-rw-r--r--jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/strlen3.c49
-rw-r--r--jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/strlen4.c55
-rw-r--r--jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/struct1.c67
-rw-r--r--jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/struct2.c67
-rw-r--r--jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/struct3.c60
-rw-r--r--jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/struct4.c64
-rw-r--r--jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/struct5.c66
-rw-r--r--jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/struct6.c64
-rw-r--r--jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/struct7.c74
-rw-r--r--jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/struct8.c81
-rw-r--r--jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/struct9.c68
-rw-r--r--jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/testclosure.c70
-rw-r--r--jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/uninitialized.c61
-rw-r--r--jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/unwindtest.cc117
-rw-r--r--jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/unwindtest_ffi_call.cc54
-rw-r--r--jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/va_1.c196
-rw-r--r--jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/va_struct1.c121
-rw-r--r--jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/va_struct2.c123
-rw-r--r--jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/va_struct3.c125
-rw-r--r--jni/ruby/ext/fiddle/libffi-3.2.1/texinfo.tex10079
-rw-r--r--jni/ruby/ext/fiddle/pointer.c721
-rwxr-xr-xjni/ruby/ext/fiddle/win32/fficonfig.h29
-rw-r--r--jni/ruby/ext/fiddle/win32/libffi-3.2.1-mswin.patch132
-rwxr-xr-xjni/ruby/ext/fiddle/win32/libffi-config.rb47
-rwxr-xr-xjni/ruby/ext/fiddle/win32/libffi.mk.tmpl96
-rw-r--r--jni/ruby/ext/gdbm/Makefile150
-rw-r--r--jni/ruby/ext/gdbm/README1
-rw-r--r--jni/ruby/ext/gdbm/extconf.rb18
-rw-r--r--jni/ruby/ext/gdbm/gdbm.c1306
-rw-r--r--jni/ruby/ext/io/console/Makefile284
-rw-r--r--jni/ruby/ext/io/console/console.c774
-rw-r--r--jni/ruby/ext/io/console/depend4
-rw-r--r--jni/ruby/ext/io/console/extconf.h6
-rw-r--r--jni/ruby/ext/io/console/extconf.rb21
-rw-r--r--jni/ruby/ext/io/console/io-console.gemspec21
-rw-r--r--jni/ruby/ext/io/console/lib/console/size.rb22
-rw-r--r--jni/ruby/ext/io/nonblock/Makefile273
-rw-r--r--jni/ruby/ext/io/nonblock/depend4
-rw-r--r--jni/ruby/ext/io/nonblock/extconf.h3
-rw-r--r--jni/ruby/ext/io/nonblock/extconf.rb8
-rw-r--r--jni/ruby/ext/io/nonblock/nonblock.c138
-rw-r--r--jni/ruby/ext/io/wait/Makefile273
-rw-r--r--jni/ruby/ext/io/wait/depend4
-rw-r--r--jni/ruby/ext/io/wait/extconf.h5
-rw-r--r--jni/ruby/ext/io/wait/extconf.rb18
-rw-r--r--jni/ruby/ext/io/wait/wait.c187
-rw-r--r--jni/ruby/ext/json/Makefile303
-rw-r--r--jni/ruby/ext/json/extconf.h3
-rw-r--r--jni/ruby/ext/json/extconf.rb3
-rw-r--r--jni/ruby/ext/json/fbuffer/fbuffer.h190
-rw-r--r--jni/ruby/ext/json/generator/Makefile290
-rw-r--r--jni/ruby/ext/json/generator/depend21
-rw-r--r--jni/ruby/ext/json/generator/extconf.h4
-rw-r--r--jni/ruby/ext/json/generator/extconf.rb4
-rw-r--r--jni/ruby/ext/json/generator/generator.c1458
-rw-r--r--jni/ruby/ext/json/generator/generator.h152
-rw-r--r--jni/ruby/ext/json/lib/json.rb62
-rw-r--r--jni/ruby/ext/json/lib/json/add/bigdecimal.rb28
-rw-r--r--jni/ruby/ext/json/lib/json/add/complex.rb22
-rw-r--r--jni/ruby/ext/json/lib/json/add/core.rb11
-rw-r--r--jni/ruby/ext/json/lib/json/add/date.rb34
-rw-r--r--jni/ruby/ext/json/lib/json/add/date_time.rb50
-rw-r--r--jni/ruby/ext/json/lib/json/add/exception.rb31
-rw-r--r--jni/ruby/ext/json/lib/json/add/ostruct.rb31
-rw-r--r--jni/ruby/ext/json/lib/json/add/range.rb29
-rw-r--r--jni/ruby/ext/json/lib/json/add/rational.rb22
-rw-r--r--jni/ruby/ext/json/lib/json/add/regexp.rb30
-rw-r--r--jni/ruby/ext/json/lib/json/add/struct.rb30
-rw-r--r--jni/ruby/ext/json/lib/json/add/symbol.rb25
-rw-r--r--jni/ruby/ext/json/lib/json/add/time.rb38
-rw-r--r--jni/ruby/ext/json/lib/json/common.rb484
-rw-r--r--jni/ruby/ext/json/lib/json/ext.rb21
-rw-r--r--jni/ruby/ext/json/lib/json/generic_object.rb70
-rw-r--r--jni/ruby/ext/json/lib/json/version.rb8
-rw-r--r--jni/ruby/ext/json/parser/Makefile289
-rw-r--r--jni/ruby/ext/json/parser/depend20
-rw-r--r--jni/ruby/ext/json/parser/extconf.h4
-rw-r--r--jni/ruby/ext/json/parser/extconf.rb5
-rw-r--r--jni/ruby/ext/json/parser/parser.c2235
-rw-r--r--jni/ruby/ext/json/parser/parser.h78
-rw-r--r--jni/ruby/ext/json/parser/parser.rl958
-rw-r--r--jni/ruby/ext/json/parser/prereq.mk10
-rw-r--r--jni/ruby/ext/mathn/complex/Makefile267
-rw-r--r--jni/ruby/ext/mathn/complex/complex.c7
-rw-r--r--jni/ruby/ext/mathn/complex/extconf.h3
-rw-r--r--jni/ruby/ext/mathn/complex/extconf.rb3
-rw-r--r--jni/ruby/ext/mathn/rational/Makefile267
-rw-r--r--jni/ruby/ext/mathn/rational/extconf.h3
-rw-r--r--jni/ruby/ext/mathn/rational/extconf.rb3
-rw-r--r--jni/ruby/ext/mathn/rational/rational.c7
-rw-r--r--jni/ruby/ext/nkf/Makefile302
-rw-r--r--jni/ruby/ext/nkf/depend22
-rw-r--r--jni/ruby/ext/nkf/extconf.h3
-rw-r--r--jni/ruby/ext/nkf/extconf.rb2
-rw-r--r--jni/ruby/ext/nkf/lib/kconv.rb282
-rw-r--r--jni/ruby/ext/nkf/nkf-utf8/config.h51
-rw-r--r--jni/ruby/ext/nkf/nkf-utf8/nkf.c7191
-rw-r--r--jni/ruby/ext/nkf/nkf-utf8/nkf.h189
-rw-r--r--jni/ruby/ext/nkf/nkf-utf8/utf8tbl.c14628
-rw-r--r--jni/ruby/ext/nkf/nkf-utf8/utf8tbl.h72
-rw-r--r--jni/ruby/ext/nkf/nkf.c507
-rw-r--r--jni/ruby/ext/objspace/Makefile335
-rw-r--r--jni/ruby/ext/objspace/depend66
-rw-r--r--jni/ruby/ext/objspace/extconf.h3
-rw-r--r--jni/ruby/ext/objspace/extconf.rb3
-rw-r--r--jni/ruby/ext/objspace/object_tracing.c492
-rw-r--r--jni/ruby/ext/objspace/objspace.c777
-rw-r--r--jni/ruby/ext/objspace/objspace.h20
-rw-r--r--jni/ruby/ext/objspace/objspace_dump.c434
-rw-r--r--jni/ruby/ext/openssl/Makefile1412
-rw-r--r--jni/ruby/ext/openssl/depend1091
-rw-r--r--jni/ruby/ext/openssl/deprecation.rb21
-rw-r--r--jni/ruby/ext/openssl/extconf.h71
-rw-r--r--jni/ruby/ext/openssl/extconf.rb160
-rw-r--r--jni/ruby/ext/openssl/lib/openssl.rb24
-rw-r--r--jni/ruby/ext/openssl/lib/openssl/bn.rb45
-rw-r--r--jni/ruby/ext/openssl/lib/openssl/buffering.rb457
-rw-r--r--jni/ruby/ext/openssl/lib/openssl/cipher.rb65
-rw-r--r--jni/ruby/ext/openssl/lib/openssl/config.rb472
-rw-r--r--jni/ruby/ext/openssl/lib/openssl/digest.rb88
-rw-r--r--jni/ruby/ext/openssl/lib/openssl/ssl.rb324
-rw-r--r--jni/ruby/ext/openssl/lib/openssl/x509.rb182
-rw-r--r--jni/ruby/ext/openssl/openssl_missing.c356
-rw-r--r--jni/ruby/ext/openssl/openssl_missing.h198
-rw-r--r--jni/ruby/ext/openssl/ossl.c1168
-rw-r--r--jni/ruby/ext/openssl/ossl.h247
-rw-r--r--jni/ruby/ext/openssl/ossl_asn1.c2000
-rw-r--r--jni/ruby/ext/openssl/ossl_asn1.h59
-rw-r--r--jni/ruby/ext/openssl/ossl_bio.c87
-rw-r--r--jni/ruby/ext/openssl/ossl_bio.h21
-rw-r--r--jni/ruby/ext/openssl/ossl_bn.c915
-rw-r--r--jni/ruby/ext/openssl/ossl_bn.h25
-rw-r--r--jni/ruby/ext/openssl/ossl_cipher.c1017
-rw-r--r--jni/ruby/ext/openssl/ossl_cipher.h22
-rw-r--r--jni/ruby/ext/openssl/ossl_config.c83
-rw-r--r--jni/ruby/ext/openssl/ossl_config.h22
-rw-r--r--jni/ruby/ext/openssl/ossl_digest.c452
-rw-r--r--jni/ruby/ext/openssl/ossl_digest.h22
-rw-r--r--jni/ruby/ext/openssl/ossl_engine.c598
-rw-r--r--jni/ruby/ext/openssl/ossl_engine.h20
-rw-r--r--jni/ruby/ext/openssl/ossl_hmac.c372
-rw-r--r--jni/ruby/ext/openssl/ossl_hmac.h19
-rw-r--r--jni/ruby/ext/openssl/ossl_ns_spki.c404
-rw-r--r--jni/ruby/ext/openssl/ossl_ns_spki.h21
-rw-r--r--jni/ruby/ext/openssl/ossl_ocsp.c1244
-rw-r--r--jni/ruby/ext/openssl/ossl_ocsp.h24
-rw-r--r--jni/ruby/ext/openssl/ossl_pkcs12.c226
-rw-r--r--jni/ruby/ext/openssl/ossl_pkcs12.h15
-rw-r--r--jni/ruby/ext/openssl/ossl_pkcs5.c189
-rw-r--r--jni/ruby/ext/openssl/ossl_pkcs5.h6
-rw-r--r--jni/ruby/ext/openssl/ossl_pkcs7.c1090
-rw-r--r--jni/ruby/ext/openssl/ossl_pkcs7.h22
-rw-r--r--jni/ruby/ext/openssl/ossl_pkey.c453
-rw-r--r--jni/ruby/ext/openssl/ossl_pkey.h152
-rw-r--r--jni/ruby/ext/openssl/ossl_pkey_dh.c666
-rw-r--r--jni/ruby/ext/openssl/ossl_pkey_dsa.c623
-rw-r--r--jni/ruby/ext/openssl/ossl_pkey_ec.c1703
-rw-r--r--jni/ruby/ext/openssl/ossl_pkey_rsa.c701
-rw-r--r--jni/ruby/ext/openssl/ossl_rand.c226
-rw-r--r--jni/ruby/ext/openssl/ossl_rand.h20
-rw-r--r--jni/ruby/ext/openssl/ossl_ssl.c2302
-rw-r--r--jni/ruby/ext/openssl/ossl_ssl.h42
-rw-r--r--jni/ruby/ext/openssl/ossl_ssl_session.c324
-rw-r--r--jni/ruby/ext/openssl/ossl_version.h16
-rw-r--r--jni/ruby/ext/openssl/ossl_x509.c104
-rw-r--r--jni/ruby/ext/openssl/ossl_x509.h114
-rw-r--r--jni/ruby/ext/openssl/ossl_x509attr.c289
-rw-r--r--jni/ruby/ext/openssl/ossl_x509cert.c860
-rw-r--r--jni/ruby/ext/openssl/ossl_x509crl.c551
-rw-r--r--jni/ruby/ext/openssl/ossl_x509ext.c493
-rw-r--r--jni/ruby/ext/openssl/ossl_x509name.c524
-rw-r--r--jni/ruby/ext/openssl/ossl_x509req.c482
-rw-r--r--jni/ruby/ext/openssl/ossl_x509revoked.c243
-rw-r--r--jni/ruby/ext/openssl/ossl_x509store.c702
-rw-r--r--jni/ruby/ext/openssl/ruby_missing.h28
-rw-r--r--jni/ruby/ext/pathname/Makefile283
-rw-r--r--jni/ruby/ext/pathname/depend3
-rw-r--r--jni/ruby/ext/pathname/extconf.h3
-rw-r--r--jni/ruby/ext/pathname/extconf.rb3
-rw-r--r--jni/ruby/ext/pathname/lib/pathname.rb579
-rw-r--r--jni/ruby/ext/pathname/pathname.c1463
-rw-r--r--jni/ruby/ext/psych/Makefile488
-rw-r--r--jni/ruby/ext/psych/depend3
-rw-r--r--jni/ruby/ext/psych/extconf.h14
-rw-r--r--jni/ruby/ext/psych/extconf.rb38
-rw-r--r--jni/ruby/ext/psych/lib/psych.rb498
-rw-r--r--jni/ruby/ext/psych/lib/psych/class_loader.rb101
-rw-r--r--jni/ruby/ext/psych/lib/psych/coder.rb94
-rw-r--r--jni/ruby/ext/psych/lib/psych/core_ext.rb35
-rw-r--r--jni/ruby/ext/psych/lib/psych/deprecated.rb85
-rw-r--r--jni/ruby/ext/psych/lib/psych/exception.rb13
-rw-r--r--jni/ruby/ext/psych/lib/psych/handler.rb249
-rw-r--r--jni/ruby/ext/psych/lib/psych/handlers/document_stream.rb22
-rw-r--r--jni/ruby/ext/psych/lib/psych/handlers/recorder.rb39
-rw-r--r--jni/ruby/ext/psych/lib/psych/json/ruby_events.rb19
-rw-r--r--jni/ruby/ext/psych/lib/psych/json/stream.rb16
-rw-r--r--jni/ruby/ext/psych/lib/psych/json/tree_builder.rb12
-rw-r--r--jni/ruby/ext/psych/lib/psych/json/yaml_events.rb29
-rw-r--r--jni/ruby/ext/psych/lib/psych/nodes.rb77
-rw-r--r--jni/ruby/ext/psych/lib/psych/nodes/alias.rb18
-rw-r--r--jni/ruby/ext/psych/lib/psych/nodes/document.rb60
-rw-r--r--jni/ruby/ext/psych/lib/psych/nodes/mapping.rb56
-rw-r--r--jni/ruby/ext/psych/lib/psych/nodes/node.rb55
-rw-r--r--jni/ruby/ext/psych/lib/psych/nodes/scalar.rb67
-rw-r--r--jni/ruby/ext/psych/lib/psych/nodes/sequence.rb81
-rw-r--r--jni/ruby/ext/psych/lib/psych/nodes/stream.rb37
-rw-r--r--jni/ruby/ext/psych/lib/psych/omap.rb4
-rw-r--r--jni/ruby/ext/psych/lib/psych/parser.rb51
-rw-r--r--jni/ruby/ext/psych/lib/psych/scalar_scanner.rb149
-rw-r--r--jni/ruby/ext/psych/lib/psych/set.rb4
-rw-r--r--jni/ruby/ext/psych/lib/psych/stream.rb37
-rw-r--r--jni/ruby/ext/psych/lib/psych/streaming.rb27
-rw-r--r--jni/ruby/ext/psych/lib/psych/syntax_error.rb21
-rw-r--r--jni/ruby/ext/psych/lib/psych/tree_builder.rb96
-rw-r--r--jni/ruby/ext/psych/lib/psych/visitors.rb6
-rw-r--r--jni/ruby/ext/psych/lib/psych/visitors/depth_first.rb26
-rw-r--r--jni/ruby/ext/psych/lib/psych/visitors/emitter.rb51
-rw-r--r--jni/ruby/ext/psych/lib/psych/visitors/json_tree.rb24
-rw-r--r--jni/ruby/ext/psych/lib/psych/visitors/to_ruby.rb389
-rw-r--r--jni/ruby/ext/psych/lib/psych/visitors/visitor.rb19
-rw-r--r--jni/ruby/ext/psych/lib/psych/visitors/yaml_tree.rb565
-rw-r--r--jni/ruby/ext/psych/lib/psych/y.rb9
-rw-r--r--jni/ruby/ext/psych/psych.c34
-rw-r--r--jni/ruby/ext/psych/psych.gemspec23
-rw-r--r--jni/ruby/ext/psych/psych.h20
-rw-r--r--jni/ruby/ext/psych/psych_emitter.c556
-rw-r--r--jni/ruby/ext/psych/psych_emitter.h8
-rw-r--r--jni/ruby/ext/psych/psych_parser.c597
-rw-r--r--jni/ruby/ext/psych/psych_parser.h6
-rw-r--r--jni/ruby/ext/psych/psych_to_ruby.c43
-rw-r--r--jni/ruby/ext/psych/psych_to_ruby.h8
-rw-r--r--jni/ruby/ext/psych/psych_yaml_tree.c24
-rw-r--r--jni/ruby/ext/psych/psych_yaml_tree.h8
-rw-r--r--jni/ruby/ext/psych/yaml/LICENSE19
-rw-r--r--jni/ruby/ext/psych/yaml/api.c1415
-rw-r--r--jni/ruby/ext/psych/yaml/config.h10
-rw-r--r--jni/ruby/ext/psych/yaml/dumper.c394
-rw-r--r--jni/ruby/ext/psych/yaml/emitter.c2329
-rw-r--r--jni/ruby/ext/psych/yaml/loader.c459
-rw-r--r--jni/ruby/ext/psych/yaml/parser.c1370
-rw-r--r--jni/ruby/ext/psych/yaml/reader.c469
-rw-r--r--jni/ruby/ext/psych/yaml/scanner.c3583
-rw-r--r--jni/ruby/ext/psych/yaml/writer.c141
-rw-r--r--jni/ruby/ext/psych/yaml/yaml.h1971
-rw-r--r--jni/ruby/ext/psych/yaml/yaml_private.h664
-rw-r--r--jni/ruby/ext/pty/Makefile297
-rw-r--r--jni/ruby/ext/pty/depend17
-rw-r--r--jni/ruby/ext/pty/extconf.h7
-rw-r--r--jni/ruby/ext/pty/extconf.rb19
-rw-r--r--jni/ruby/ext/pty/lib/expect.rb71
-rw-r--r--jni/ruby/ext/pty/pty.c758
-rw-r--r--jni/ruby/ext/racc/cparse/Makefile267
-rw-r--r--jni/ruby/ext/racc/cparse/README11
-rw-r--r--jni/ruby/ext/racc/cparse/cparse.c857
-rw-r--r--jni/ruby/ext/racc/cparse/extconf.h4
-rw-r--r--jni/ruby/ext/racc/cparse/extconf.rb5
-rw-r--r--jni/ruby/ext/rbconfig/sizeof/Makefile284
-rw-r--r--jni/ruby/ext/rbconfig/sizeof/depend15
-rw-r--r--jni/ruby/ext/rbconfig/sizeof/extconf.h3
-rw-r--r--jni/ruby/ext/rbconfig/sizeof/extconf.rb3
-rw-r--r--jni/ruby/ext/rbconfig/sizeof/sizes.c55
-rw-r--r--jni/ruby/ext/readline/Makefile150
-rw-r--r--jni/ruby/ext/readline/README10
-rw-r--r--jni/ruby/ext/readline/README.ja386
-rw-r--r--jni/ruby/ext/readline/depend17
-rw-r--r--jni/ruby/ext/readline/extconf.rb109
-rw-r--r--jni/ruby/ext/readline/readline.c1996
-rw-r--r--jni/ruby/ext/ripper/Makefile378
-rw-r--r--jni/ruby/ext/ripper/README30
-rw-r--r--jni/ruby/ext/ripper/depend75
-rw-r--r--jni/ruby/ext/ripper/eventids2.c305
-rw-r--r--jni/ruby/ext/ripper/extconf.h4
-rw-r--r--jni/ruby/ext/ripper/extconf.rb21
-rw-r--r--jni/ruby/ext/ripper/lib/ripper.rb73
-rw-r--r--jni/ruby/ext/ripper/lib/ripper/core.rb70
-rw-r--r--jni/ruby/ext/ripper/lib/ripper/filter.rb77
-rw-r--r--jni/ruby/ext/ripper/lib/ripper/lexer.rb186
-rw-r--r--jni/ruby/ext/ripper/lib/ripper/sexp.rb118
-rwxr-xr-xjni/ruby/ext/ripper/tools/generate-param-macros.rb14
-rwxr-xr-xjni/ruby/ext/ripper/tools/generate.rb161
-rwxr-xr-xjni/ruby/ext/ripper/tools/preproc.rb91
-rwxr-xr-xjni/ruby/ext/ripper/tools/strip.rb12
-rw-r--r--jni/ruby/ext/sdbm/Makefile288
-rw-r--r--jni/ruby/ext/sdbm/_sdbm.c952
-rw-r--r--jni/ruby/ext/sdbm/depend19
-rw-r--r--jni/ruby/ext/sdbm/extconf.h4
-rw-r--r--jni/ruby/ext/sdbm/extconf.rb4
-rw-r--r--jni/ruby/ext/sdbm/init.c1065
-rw-r--r--jni/ruby/ext/sdbm/sdbm.h86
-rw-r--r--jni/ruby/ext/socket/.document17
-rw-r--r--jni/ruby/ext/socket/Makefile571
-rw-r--r--jni/ruby/ext/socket/addrinfo.h189
-rw-r--r--jni/ruby/ext/socket/ancdata.c1842
-rw-r--r--jni/ruby/ext/socket/basicsocket.c767
-rw-r--r--jni/ruby/ext/socket/constants.c145
-rw-r--r--jni/ruby/ext/socket/constdefs.c6852
-rw-r--r--jni/ruby/ext/socket/constdefs.h2254
-rw-r--r--jni/ruby/ext/socket/depend295
-rw-r--r--jni/ruby/ext/socket/extconf.h127
-rw-r--r--jni/ruby/ext/socket/extconf.rb695
-rw-r--r--jni/ruby/ext/socket/getaddrinfo.c679
-rw-r--r--jni/ruby/ext/socket/getnameinfo.c261
-rw-r--r--jni/ruby/ext/socket/ifaddr.c459
-rw-r--r--jni/ruby/ext/socket/init.c615
-rw-r--r--jni/ruby/ext/socket/ipsocket.c338
-rw-r--r--jni/ruby/ext/socket/lib/socket.rb871
-rw-r--r--jni/ruby/ext/socket/mkconstants.rb804
-rw-r--r--jni/ruby/ext/socket/option.c1473
-rw-r--r--jni/ruby/ext/socket/raddrinfo.c2575
-rw-r--r--jni/ruby/ext/socket/rubysocket.h415
-rw-r--r--jni/ruby/ext/socket/socket.c2182
-rw-r--r--jni/ruby/ext/socket/sockport.h116
-rw-r--r--jni/ruby/ext/socket/sockssocket.c68
-rw-r--r--jni/ruby/ext/socket/tcpserver.c178
-rw-r--r--jni/ruby/ext/socket/tcpsocket.c82
-rw-r--r--jni/ruby/ext/socket/udpsocket.c266
-rw-r--r--jni/ruby/ext/socket/unixserver.c155
-rw-r--r--jni/ruby/ext/socket/unixsocket.c534
-rw-r--r--jni/ruby/ext/stringio/Makefile273
-rw-r--r--jni/ruby/ext/stringio/README18
-rw-r--r--jni/ruby/ext/stringio/depend4
-rw-r--r--jni/ruby/ext/stringio/extconf.h3
-rw-r--r--jni/ruby/ext/stringio/extconf.rb2
-rw-r--r--jni/ruby/ext/stringio/stringio.c1621
-rw-r--r--jni/ruby/ext/strscan/Makefile286
-rw-r--r--jni/ruby/ext/strscan/depend17
-rw-r--r--jni/ruby/ext/strscan/extconf.h3
-rw-r--r--jni/ruby/ext/strscan/extconf.rb3
-rw-r--r--jni/ruby/ext/strscan/strscan.c1402
-rw-r--r--jni/ruby/ext/syslog/Makefile292
-rw-r--r--jni/ruby/ext/syslog/depend12
-rw-r--r--jni/ruby/ext/syslog/extconf.h6
-rw-r--r--jni/ruby/ext/syslog/extconf.rb10
-rw-r--r--jni/ruby/ext/syslog/lib/syslog/logger.rb208
-rw-r--r--jni/ruby/ext/syslog/syslog.c592
-rw-r--r--jni/ruby/ext/syslog/syslog.txt124
-rw-r--r--jni/ruby/ext/thread/Makefile267
-rw-r--r--jni/ruby/ext/thread/extconf.h3
-rw-r--r--jni/ruby/ext/thread/extconf.rb3
-rw-r--r--jni/ruby/ext/thread/thread.c656
-rw-r--r--jni/ruby/ext/tk/ChangeLog.tkextlib949
-rw-r--r--jni/ruby/ext/tk/MANUAL_tcltklib.eng473
-rw-r--r--jni/ruby/ext/tk/MANUAL_tcltklib.ja584
-rw-r--r--jni/ruby/ext/tk/Makefile150
-rw-r--r--jni/ruby/ext/tk/README.1st19
-rw-r--r--jni/ruby/ext/tk/README.ActiveTcl62
-rw-r--r--jni/ruby/ext/tk/README.fork34
-rw-r--r--jni/ruby/ext/tk/README.macosx-aqua67
-rw-r--r--jni/ruby/ext/tk/README.tcltklib152
-rw-r--r--jni/ruby/ext/tk/config_list.in41
-rw-r--r--jni/ruby/ext/tk/depend2
-rw-r--r--jni/ruby/ext/tk/extconf.rb2094
-rw-r--r--jni/ruby/ext/tk/lib/README30
-rw-r--r--jni/ruby/ext/tk/lib/multi-tk.rb3754
-rw-r--r--jni/ruby/ext/tk/lib/remote-tk.rb530
-rw-r--r--jni/ruby/ext/tk/lib/tcltk.rb367
-rw-r--r--jni/ruby/ext/tk/lib/tk.rb5775
-rw-r--r--jni/ruby/ext/tk/lib/tk/after.rb6
-rw-r--r--jni/ruby/ext/tk/lib/tk/autoload.rb762
-rw-r--r--jni/ruby/ext/tk/lib/tk/bgerror.rb29
-rw-r--r--jni/ruby/ext/tk/lib/tk/bindtag.rb138
-rw-r--r--jni/ruby/ext/tk/lib/tk/busy.rb118
-rw-r--r--jni/ruby/ext/tk/lib/tk/button.rb31
-rw-r--r--jni/ruby/ext/tk/lib/tk/canvas.rb846
-rw-r--r--jni/ruby/ext/tk/lib/tk/canvastag.rb459
-rw-r--r--jni/ruby/ext/tk/lib/tk/checkbutton.rb32
-rw-r--r--jni/ruby/ext/tk/lib/tk/clipboard.rb75
-rw-r--r--jni/ruby/ext/tk/lib/tk/clock.rb71
-rw-r--r--jni/ruby/ext/tk/lib/tk/composite.rb484
-rw-r--r--jni/ruby/ext/tk/lib/tk/console.rb52
-rw-r--r--jni/ruby/ext/tk/lib/tk/dialog.rb326
-rw-r--r--jni/ruby/ext/tk/lib/tk/encodedstr.rb187
-rw-r--r--jni/ruby/ext/tk/lib/tk/entry.rb120
-rw-r--r--jni/ruby/ext/tk/lib/tk/event.rb562
-rw-r--r--jni/ruby/ext/tk/lib/tk/font.rb2351
-rw-r--r--jni/ruby/ext/tk/lib/tk/fontchooser.rb180
-rw-r--r--jni/ruby/ext/tk/lib/tk/frame.rb132
-rw-r--r--jni/ruby/ext/tk/lib/tk/grid.rb279
-rw-r--r--jni/ruby/ext/tk/lib/tk/image.rb395
-rw-r--r--jni/ruby/ext/tk/lib/tk/itemconfig.rb1222
-rw-r--r--jni/ruby/ext/tk/lib/tk/itemfont.rb327
-rw-r--r--jni/ruby/ext/tk/lib/tk/kinput.rb71
-rw-r--r--jni/ruby/ext/tk/lib/tk/label.rb22
-rw-r--r--jni/ruby/ext/tk/lib/tk/labelframe.rb31
-rw-r--r--jni/ruby/ext/tk/lib/tk/listbox.rb284
-rw-r--r--jni/ruby/ext/tk/lib/tk/macpkg.rb80
-rw-r--r--jni/ruby/ext/tk/lib/tk/menu.rb718
-rw-r--r--jni/ruby/ext/tk/lib/tk/menubar.rb137
-rw-r--r--jni/ruby/ext/tk/lib/tk/menuspec.rb456
-rw-r--r--jni/ruby/ext/tk/lib/tk/message.rb24
-rw-r--r--jni/ruby/ext/tk/lib/tk/mngfocus.rb33
-rw-r--r--jni/ruby/ext/tk/lib/tk/msgcat.rb299
-rw-r--r--jni/ruby/ext/tk/lib/tk/namespace.rb546
-rw-r--r--jni/ruby/ext/tk/lib/tk/optiondb.rb377
-rw-r--r--jni/ruby/ext/tk/lib/tk/optionobj.rb212
-rw-r--r--jni/ruby/ext/tk/lib/tk/pack.rb107
-rw-r--r--jni/ruby/ext/tk/lib/tk/package.rb143
-rw-r--r--jni/ruby/ext/tk/lib/tk/palette.rb55
-rw-r--r--jni/ruby/ext/tk/lib/tk/panedwindow.rb260
-rw-r--r--jni/ruby/ext/tk/lib/tk/place.rb128
-rw-r--r--jni/ruby/ext/tk/lib/tk/radiobutton.rb73
-rw-r--r--jni/ruby/ext/tk/lib/tk/root.rb95
-rw-r--r--jni/ruby/ext/tk/lib/tk/scale.rb112
-rw-r--r--jni/ruby/ext/tk/lib/tk/scrollable.rb82
-rw-r--r--jni/ruby/ext/tk/lib/tk/scrollbar.rb183
-rw-r--r--jni/ruby/ext/tk/lib/tk/scrollbox.rb39
-rw-r--r--jni/ruby/ext/tk/lib/tk/selection.rb86
-rw-r--r--jni/ruby/ext/tk/lib/tk/spinbox.rb144
-rw-r--r--jni/ruby/ext/tk/lib/tk/tagfont.rb43
-rw-r--r--jni/ruby/ext/tk/lib/tk/text.rb1604
-rw-r--r--jni/ruby/ext/tk/lib/tk/textimage.rb88
-rw-r--r--jni/ruby/ext/tk/lib/tk/textmark.rb204
-rw-r--r--jni/ruby/ext/tk/lib/tk/texttag.rb321
-rw-r--r--jni/ruby/ext/tk/lib/tk/textwindow.rb154
-rw-r--r--jni/ruby/ext/tk/lib/tk/timer.rb669
-rw-r--r--jni/ruby/ext/tk/lib/tk/tk_mac.rb158
-rw-r--r--jni/ruby/ext/tk/lib/tk/toplevel.rb264
-rw-r--r--jni/ruby/ext/tk/lib/tk/ttk_selector.rb98
-rw-r--r--jni/ruby/ext/tk/lib/tk/txtwin_abst.rb39
-rw-r--r--jni/ruby/ext/tk/lib/tk/validation.rb397
-rw-r--r--jni/ruby/ext/tk/lib/tk/variable.rb1799
-rw-r--r--jni/ruby/ext/tk/lib/tk/virtevent.rb139
-rw-r--r--jni/ruby/ext/tk/lib/tk/winfo.rb392
-rw-r--r--jni/ruby/ext/tk/lib/tk/winpkg.rb156
-rw-r--r--jni/ruby/ext/tk/lib/tk/wm.rb552
-rw-r--r--jni/ruby/ext/tk/lib/tk/xim.rb122
-rw-r--r--jni/ruby/ext/tk/lib/tkafter.rb4
-rw-r--r--jni/ruby/ext/tk/lib/tkbgerror.rb4
-rw-r--r--jni/ruby/ext/tk/lib/tkcanvas.rb4
-rw-r--r--jni/ruby/ext/tk/lib/tkclass.rb47
-rw-r--r--jni/ruby/ext/tk/lib/tkconsole.rb4
-rw-r--r--jni/ruby/ext/tk/lib/tkdialog.rb4
-rw-r--r--jni/ruby/ext/tk/lib/tkentry.rb4
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/ICONS.rb13
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/ICONS/icons.rb129
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/ICONS/setup.rb8
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/SUPPORT_STATUS193
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/blt.rb189
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/blt/barchart.rb79
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/blt/bitmap.rb112
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/blt/busy.rb83
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/blt/component.rb2218
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/blt/container.rb28
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/blt/cutbuffer.rb23
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/blt/dragdrop.rb269
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/blt/eps.rb32
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/blt/graph.rb67
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/blt/htext.rb112
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/blt/setup.rb8
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/blt/spline.rb23
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/blt/stripchart.rb74
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/blt/table.rb412
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/blt/tabnotebook.rb110
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/blt/tabset.rb504
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/blt/ted.rb68
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/blt/tile.rb25
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/blt/tile/button.rb16
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/blt/tile/checkbutton.rb17
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/blt/tile/frame.rb16
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/blt/tile/label.rb16
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/blt/tile/radiobutton.rb17
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/blt/tile/scrollbar.rb16
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/blt/tile/toplevel.rb16
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/blt/tree.rb1058
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/blt/treeview.rb1287
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/blt/unix_dnd.rb141
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/blt/vector.rb256
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/blt/watch.rb175
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/blt/win_printer.rb61
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/blt/winop.rb107
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/bwidget.rb153
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/bwidget/arrowbutton.rb21
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/bwidget/bitmap.rb21
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/bwidget/button.rb31
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/bwidget/buttonbox.rb90
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/bwidget/combobox.rb62
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/bwidget/dialog.rb194
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/bwidget/dragsite.rb31
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/bwidget/dropsite.rb39
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/bwidget/dynamichelp.rb63
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/bwidget/entry.rb43
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/bwidget/label.rb41
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/bwidget/labelentry.rb80
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/bwidget/labelframe.rb52
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/bwidget/listbox.rb361
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/bwidget/mainframe.rb132
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/bwidget/messagedlg.rb192
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/bwidget/notebook.rb166
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/bwidget/pagesmanager.rb73
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/bwidget/panedwindow.rb42
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/bwidget/panelframe.rb67
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/bwidget/passwddlg.rb44
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/bwidget/progressbar.rb20
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/bwidget/progressdlg.rb58
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/bwidget/scrollableframe.rb40
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/bwidget/scrolledwindow.rb48
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/bwidget/scrollview.rb25
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/bwidget/selectcolor.rb73
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/bwidget/selectfont.rb91
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/bwidget/separator.rb20
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/bwidget/setup.rb8
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/bwidget/spinbox.rb98
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/bwidget/statusbar.rb62
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/bwidget/titleframe.rb33
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/bwidget/tree.rb500
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/bwidget/widget.rb129
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/itcl.rb13
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/itcl/incr_tcl.rb178
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/itcl/setup.rb13
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/itk.rb13
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/itk/incr_tk.rb446
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/itk/setup.rb13
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/iwidgets.rb94
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/iwidgets/buttonbox.rb121
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/iwidgets/calendar.rb125
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/iwidgets/canvasprintbox.rb53
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/iwidgets/canvasprintdialog.rb38
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/iwidgets/checkbox.rb130
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/iwidgets/combobox.rb104
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/iwidgets/dateentry.rb20
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/iwidgets/datefield.rb58
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/iwidgets/dialog.rb20
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/iwidgets/dialogshell.rb121
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/iwidgets/disjointlistbox.rb50
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/iwidgets/entryfield.rb185
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/iwidgets/extbutton.rb40
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/iwidgets/extfileselectionbox.rb46
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/iwidgets/extfileselectiondialog.rb33
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/iwidgets/feedback.rb35
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/iwidgets/fileselectionbox.rb46
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/iwidgets/fileselectiondialog.rb33
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/iwidgets/finddialog.rb42
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/iwidgets/hierarchy.rb365
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/iwidgets/hyperhelp.rb50
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/iwidgets/labeledframe.rb39
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/iwidgets/labeledwidget.rb45
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/iwidgets/mainwindow.rb67
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/iwidgets/menubar.rb212
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/iwidgets/messagebox.rb93
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/iwidgets/messagedialog.rb20
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/iwidgets/notebook.rb175
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/iwidgets/optionmenu.rb92
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/iwidgets/panedwindow.rb134
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/iwidgets/promptdialog.rb131
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/iwidgets/pushbutton.rb35
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/iwidgets/radiobox.rb121
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/iwidgets/scopedobject.rb24
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/iwidgets/scrolledcanvas.rb353
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/iwidgets/scrolledframe.rb59
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/iwidgets/scrolledhtml.rb58
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/iwidgets/scrolledlistbox.rb207
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/iwidgets/scrolledtext.rb568
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/iwidgets/scrolledwidget.rb20
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/iwidgets/selectionbox.rb102
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/iwidgets/selectiondialog.rb92
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/iwidgets/setup.rb8
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/iwidgets/shell.rb38
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/iwidgets/spindate.rb48
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/iwidgets/spinint.rb30
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/iwidgets/spinner.rb169
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/iwidgets/spintime.rb48
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/iwidgets/tabnotebook.rb181
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/iwidgets/tabset.rb145
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/iwidgets/timeentry.rb25
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/iwidgets/timefield.rb58
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/iwidgets/toolbar.rb112
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/iwidgets/watch.rb56
-rwxr-xr-xjni/ruby/ext/tk/lib/tkextlib/pkg_checker.rb184
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/setup.rb8
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/tcllib.rb105
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/tcllib/README135
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/tcllib/autoscroll.rb158
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/tcllib/calendar.rb55
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/tcllib/canvas_sqmap.rb36
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/tcllib/canvas_zoom.rb21
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/tcllib/chatwidget.rb151
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/tcllib/crosshair.rb117
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/tcllib/ctext.rb160
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/tcllib/cursor.rb97
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/tcllib/dateentry.rb62
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/tcllib/datefield.rb57
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/tcllib/diagrams.rb224
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/tcllib/dialog.rb84
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/tcllib/getstring.rb134
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/tcllib/history.rb73
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/tcllib/ico.rb146
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/tcllib/ip_entry.rb75
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/tcllib/khim.rb68
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/tcllib/menuentry.rb47
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/tcllib/ntext.rb146
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/tcllib/panelframe.rb78
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/tcllib/plotchart.rb1404
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/tcllib/ruler.rb65
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/tcllib/screenruler.rb68
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/tcllib/scrolledwindow.rb57
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/tcllib/scrollwin.rb61
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/tcllib/setup.rb8
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/tcllib/statusbar.rb79
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/tcllib/style.rb61
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/tcllib/superframe.rb51
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/tcllib/swaplist.rb150
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/tcllib/tablelist.rb28
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/tcllib/tablelist_core.rb1072
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/tcllib/tablelist_tile.rb43
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/tcllib/tkpiechart.rb314
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/tcllib/toolbar.rb175
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/tcllib/tooltip.rb104
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/tcllib/validator.rb65
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/tcllib/widget.rb82
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/tclx.rb13
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/tclx/setup.rb8
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/tclx/tclx.rb74
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/tile.rb449
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/tile/dialog.rb102
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/tile/setup.rb8
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/tile/sizegrip.rb32
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/tile/style.rb336
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/tile/tbutton.rb34
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/tile/tcheckbutton.rb38
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/tile/tcombobox.rb55
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/tile/tentry.rb49
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/tile/tframe.rb34
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/tile/tlabel.rb34
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/tile/tlabelframe.rb38
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/tile/tmenubutton.rb38
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/tile/tnotebook.rb147
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/tile/tpaned.rb245
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/tile/tprogressbar.rb57
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/tile/tradiobutton.rb38
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/tile/treeview.rb1336
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/tile/tscale.rb56
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/tile/tscrollbar.rb63
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/tile/tseparator.rb34
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/tile/tspinbox.rb107
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/tile/tsquare.rb30
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/tkDND.rb18
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/tkDND/setup.rb8
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/tkDND/shape.rb125
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/tkDND/tkdnd.rb182
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/tkHTML.rb13
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/tkHTML/htmlwidget.rb453
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/tkHTML/setup.rb8
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/tkimg.rb36
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/tkimg/README26
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/tkimg/bmp.rb33
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/tkimg/dted.rb33
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/tkimg/gif.rb33
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/tkimg/ico.rb33
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/tkimg/jpeg.rb33
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/tkimg/pcx.rb33
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/tkimg/pixmap.rb44
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/tkimg/png.rb33
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/tkimg/ppm.rb33
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/tkimg/ps.rb33
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/tkimg/raw.rb33
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/tkimg/setup.rb8
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/tkimg/sgi.rb33
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/tkimg/sun.rb33
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/tkimg/tga.rb33
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/tkimg/tiff.rb33
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/tkimg/window.rb33
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/tkimg/xbm.rb33
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/tkimg/xpm.rb33
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/tktable.rb14
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/tktable/setup.rb8
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/tktable/tktable.rb966
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/tktrans.rb14
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/tktrans/setup.rb8
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/tktrans/tktrans.rb64
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/treectrl.rb13
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/treectrl/setup.rb8
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/treectrl/tktreectrl.rb2522
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/trofs.rb13
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/trofs/setup.rb8
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/trofs/trofs.rb51
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/version.rb6
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/vu.rb48
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/vu/bargraph.rb61
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/vu/charts.rb53
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/vu/dial.rb102
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/vu/pie.rb286
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/vu/setup.rb8
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/vu/spinbox.rb22
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/winico.rb14
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/winico/setup.rb8
-rw-r--r--jni/ruby/ext/tk/lib/tkextlib/winico/winico.rb224
-rw-r--r--jni/ruby/ext/tk/lib/tkfont.rb4
-rw-r--r--jni/ruby/ext/tk/lib/tkmacpkg.rb4
-rw-r--r--jni/ruby/ext/tk/lib/tkmenubar.rb4
-rw-r--r--jni/ruby/ext/tk/lib/tkmngfocus.rb4
-rw-r--r--jni/ruby/ext/tk/lib/tkpalette.rb4
-rw-r--r--jni/ruby/ext/tk/lib/tkscrollbox.rb4
-rw-r--r--jni/ruby/ext/tk/lib/tktext.rb4
-rw-r--r--jni/ruby/ext/tk/lib/tkvirtevent.rb4
-rw-r--r--jni/ruby/ext/tk/lib/tkwinpkg.rb4
-rw-r--r--jni/ruby/ext/tk/old-README.tcltklib.ja159
-rw-r--r--jni/ruby/ext/tk/old-extconf.rb440
-rw-r--r--jni/ruby/ext/tk/sample/24hr_clock.rb286
-rw-r--r--jni/ruby/ext/tk/sample/binding_sample.rb87
-rw-r--r--jni/ruby/ext/tk/sample/bindtag_sample.rb127
-rw-r--r--jni/ruby/ext/tk/sample/binstr_usage.rb45
-rw-r--r--jni/ruby/ext/tk/sample/btn_with_frame.rb20
-rw-r--r--jni/ruby/ext/tk/sample/cd_timer.rb81
-rw-r--r--jni/ruby/ext/tk/sample/cmd_res_test.rb17
-rw-r--r--jni/ruby/ext/tk/sample/cmd_resource5
-rw-r--r--jni/ruby/ext/tk/sample/demos-en/ChangeLog64
-rw-r--r--jni/ruby/ext/tk/sample/demos-en/ChangeLog.prev9
-rw-r--r--jni/ruby/ext/tk/sample/demos-en/README138
-rw-r--r--jni/ruby/ext/tk/sample/demos-en/README.1st18
-rw-r--r--jni/ruby/ext/tk/sample/demos-en/README.tkencoding29
-rw-r--r--jni/ruby/ext/tk/sample/demos-en/anilabel.rb174
-rw-r--r--jni/ruby/ext/tk/sample/demos-en/aniwave.rb118
-rw-r--r--jni/ruby/ext/tk/sample/demos-en/arrow.rb249
-rw-r--r--jni/ruby/ext/tk/sample/demos-en/bind.rb127
-rw-r--r--jni/ruby/ext/tk/sample/demos-en/bitmap.rb75
-rw-r--r--jni/ruby/ext/tk/sample/demos-en/browse163
-rw-r--r--jni/ruby/ext/tk/sample/demos-en/browse282
-rw-r--r--jni/ruby/ext/tk/sample/demos-en/button.rb84
-rw-r--r--jni/ruby/ext/tk/sample/demos-en/check.rb72
-rw-r--r--jni/ruby/ext/tk/sample/demos-en/check2.rb109
-rw-r--r--jni/ruby/ext/tk/sample/demos-en/clrpick.rb87
-rw-r--r--jni/ruby/ext/tk/sample/demos-en/colors.rb158
-rw-r--r--jni/ruby/ext/tk/sample/demos-en/combo.rb96
-rw-r--r--jni/ruby/ext/tk/sample/demos-en/cscroll.rb136
-rw-r--r--jni/ruby/ext/tk/sample/demos-en/ctext.rb207
-rw-r--r--jni/ruby/ext/tk/sample/demos-en/dialog1.rb38
-rw-r--r--jni/ruby/ext/tk/sample/demos-en/dialog2.rb41
-rw-r--r--jni/ruby/ext/tk/sample/demos-en/doc.org/README7
-rw-r--r--jni/ruby/ext/tk/sample/demos-en/doc.org/README.JP14
-rw-r--r--jni/ruby/ext/tk/sample/demos-en/doc.org/README.tk8046
-rw-r--r--jni/ruby/ext/tk/sample/demos-en/doc.org/license.terms39
-rw-r--r--jni/ruby/ext/tk/sample/demos-en/doc.org/license.terms.tk8039
-rw-r--r--jni/ruby/ext/tk/sample/demos-en/entry1.rb58
-rw-r--r--jni/ruby/ext/tk/sample/demos-en/entry2.rb93
-rw-r--r--jni/ruby/ext/tk/sample/demos-en/entry3.rb220
-rw-r--r--jni/ruby/ext/tk/sample/demos-en/filebox.rb102
-rw-r--r--jni/ruby/ext/tk/sample/demos-en/floor.rb1723
-rw-r--r--jni/ruby/ext/tk/sample/demos-en/floor2.rb1722
-rw-r--r--jni/ruby/ext/tk/sample/demos-en/form.rb64
-rw-r--r--jni/ruby/ext/tk/sample/demos-en/goldberg.rb2006
-rw-r--r--jni/ruby/ext/tk/sample/demos-en/hello14
-rw-r--r--jni/ruby/ext/tk/sample/demos-en/hscale.rb75
-rw-r--r--jni/ruby/ext/tk/sample/demos-en/icon.rb105
-rw-r--r--jni/ruby/ext/tk/sample/demos-en/image1.rb65
-rw-r--r--jni/ruby/ext/tk/sample/demos-en/image2.rb107
-rw-r--r--jni/ruby/ext/tk/sample/demos-en/image3.rb125
-rw-r--r--jni/ruby/ext/tk/sample/demos-en/items.rb381
-rw-r--r--jni/ruby/ext/tk/sample/demos-en/ixset333
-rw-r--r--jni/ruby/ext/tk/sample/demos-en/ixset2367
-rw-r--r--jni/ruby/ext/tk/sample/demos-en/knightstour.rb271
-rw-r--r--jni/ruby/ext/tk/sample/demos-en/label.rb72
-rw-r--r--jni/ruby/ext/tk/sample/demos-en/labelframe.rb95
-rw-r--r--jni/ruby/ext/tk/sample/demos-en/mclist.rb117
-rw-r--r--jni/ruby/ext/tk/sample/demos-en/menu.rb196
-rw-r--r--jni/ruby/ext/tk/sample/demos-en/menu84.rb215
-rw-r--r--jni/ruby/ext/tk/sample/demos-en/menubu.rb237
-rw-r--r--jni/ruby/ext/tk/sample/demos-en/msgbox.rb90
-rw-r--r--jni/ruby/ext/tk/sample/demos-en/msgbox2.rb91
-rw-r--r--jni/ruby/ext/tk/sample/demos-en/paned1.rb47
-rw-r--r--jni/ruby/ext/tk/sample/demos-en/paned2.rb94
-rw-r--r--jni/ruby/ext/tk/sample/demos-en/pendulum.rb240
-rw-r--r--jni/ruby/ext/tk/sample/demos-en/plot.rb124
-rw-r--r--jni/ruby/ext/tk/sample/demos-en/puzzle.rb134
-rw-r--r--jni/ruby/ext/tk/sample/demos-en/radio.rb86
-rw-r--r--jni/ruby/ext/tk/sample/demos-en/radio2.rb109
-rw-r--r--jni/ruby/ext/tk/sample/demos-en/radio3.rb117
-rw-r--r--jni/ruby/ext/tk/sample/demos-en/rmt268
-rw-r--r--jni/ruby/ext/tk/sample/demos-en/rolodex320
-rw-r--r--jni/ruby/ext/tk/sample/demos-en/ruler.rb205
-rw-r--r--jni/ruby/ext/tk/sample/demos-en/sayings.rb106
-rw-r--r--jni/ruby/ext/tk/sample/demos-en/search.rb187
-rw-r--r--jni/ruby/ext/tk/sample/demos-en/spin.rb65
-rw-r--r--jni/ruby/ext/tk/sample/demos-en/square81
-rw-r--r--jni/ruby/ext/tk/sample/demos-en/states.rb80
-rw-r--r--jni/ruby/ext/tk/sample/demos-en/style.rb231
-rw-r--r--jni/ruby/ext/tk/sample/demos-en/tcolor526
-rw-r--r--jni/ruby/ext/tk/sample/demos-en/text.rb128
-rw-r--r--jni/ruby/ext/tk/sample/demos-en/textpeer.rb76
-rw-r--r--jni/ruby/ext/tk/sample/demos-en/timer136
-rw-r--r--jni/ruby/ext/tk/sample/demos-en/tkencoding.rb42
-rw-r--r--jni/ruby/ext/tk/sample/demos-en/toolbar.rb130
-rw-r--r--jni/ruby/ext/tk/sample/demos-en/tree.rb119
-rw-r--r--jni/ruby/ext/tk/sample/demos-en/ttkbut.rb139
-rw-r--r--jni/ruby/ext/tk/sample/demos-en/ttkmenu.rb85
-rw-r--r--jni/ruby/ext/tk/sample/demos-en/ttknote.rb89
-rw-r--r--jni/ruby/ext/tk/sample/demos-en/ttkpane.rb213
-rw-r--r--jni/ruby/ext/tk/sample/demos-en/ttkprogress.rb66
-rw-r--r--jni/ruby/ext/tk/sample/demos-en/twind.rb291
-rw-r--r--jni/ruby/ext/tk/sample/demos-en/twind2.rb384
-rw-r--r--jni/ruby/ext/tk/sample/demos-en/unicodeout.rb114
-rw-r--r--jni/ruby/ext/tk/sample/demos-en/vscale.rb79
-rw-r--r--jni/ruby/ext/tk/sample/demos-en/widget1087
-rw-r--r--jni/ruby/ext/tk/sample/demos-jp/README54
-rw-r--r--jni/ruby/ext/tk/sample/demos-jp/README.1st20
-rw-r--r--jni/ruby/ext/tk/sample/demos-jp/anilabel.rb177
-rw-r--r--jni/ruby/ext/tk/sample/demos-jp/aniwave.rb120
-rw-r--r--jni/ruby/ext/tk/sample/demos-jp/arrow.rb247
-rw-r--r--jni/ruby/ext/tk/sample/demos-jp/bind.rb125
-rw-r--r--jni/ruby/ext/tk/sample/demos-jp/bitmap.rb74
-rw-r--r--jni/ruby/ext/tk/sample/demos-jp/browse163
-rw-r--r--jni/ruby/ext/tk/sample/demos-jp/browse282
-rw-r--r--jni/ruby/ext/tk/sample/demos-jp/button.rb83
-rw-r--r--jni/ruby/ext/tk/sample/demos-jp/check.rb70
-rw-r--r--jni/ruby/ext/tk/sample/demos-jp/check2.rb110
-rw-r--r--jni/ruby/ext/tk/sample/demos-jp/clrpick.rb84
-rw-r--r--jni/ruby/ext/tk/sample/demos-jp/colors.rb155
-rw-r--r--jni/ruby/ext/tk/sample/demos-jp/combo.rb98
-rw-r--r--jni/ruby/ext/tk/sample/demos-jp/cscroll.rb134
-rw-r--r--jni/ruby/ext/tk/sample/demos-jp/ctext.rb204
-rw-r--r--jni/ruby/ext/tk/sample/demos-jp/dialog1.rb39
-rw-r--r--jni/ruby/ext/tk/sample/demos-jp/dialog2.rb43
-rw-r--r--jni/ruby/ext/tk/sample/demos-jp/doc.org/README7
-rw-r--r--jni/ruby/ext/tk/sample/demos-jp/doc.org/README.JP14
-rw-r--r--jni/ruby/ext/tk/sample/demos-jp/doc.org/README.tk8046
-rw-r--r--jni/ruby/ext/tk/sample/demos-jp/doc.org/license.terms39
-rw-r--r--jni/ruby/ext/tk/sample/demos-jp/doc.org/license.terms.tk8039
-rw-r--r--jni/ruby/ext/tk/sample/demos-jp/entry1.rb60
-rw-r--r--jni/ruby/ext/tk/sample/demos-jp/entry2.rb91
-rw-r--r--jni/ruby/ext/tk/sample/demos-jp/entry3.rb225
-rw-r--r--jni/ruby/ext/tk/sample/demos-jp/filebox.rb102
-rw-r--r--jni/ruby/ext/tk/sample/demos-jp/floor.rb1721
-rw-r--r--jni/ruby/ext/tk/sample/demos-jp/floor2.rb1719
-rw-r--r--jni/ruby/ext/tk/sample/demos-jp/form.rb66
-rw-r--r--jni/ruby/ext/tk/sample/demos-jp/goldberg.rb2011
-rw-r--r--jni/ruby/ext/tk/sample/demos-jp/hello10
-rw-r--r--jni/ruby/ext/tk/sample/demos-jp/hscale.rb78
-rw-r--r--jni/ruby/ext/tk/sample/demos-jp/icon.rb103
-rw-r--r--jni/ruby/ext/tk/sample/demos-jp/image1.rb64
-rw-r--r--jni/ruby/ext/tk/sample/demos-jp/image2.rb106
-rw-r--r--jni/ruby/ext/tk/sample/demos-jp/image3.rb127
-rw-r--r--jni/ruby/ext/tk/sample/demos-jp/items.rb379
-rw-r--r--jni/ruby/ext/tk/sample/demos-jp/ixset333
-rw-r--r--jni/ruby/ext/tk/sample/demos-jp/ixset2369
-rw-r--r--jni/ruby/ext/tk/sample/demos-jp/knightstour.rb273
-rw-r--r--jni/ruby/ext/tk/sample/demos-jp/label.rb69
-rw-r--r--jni/ruby/ext/tk/sample/demos-jp/labelframe.rb102
-rw-r--r--jni/ruby/ext/tk/sample/demos-jp/mclist.rb121
-rw-r--r--jni/ruby/ext/tk/sample/demos-jp/menu.rb201
-rw-r--r--jni/ruby/ext/tk/sample/demos-jp/menu84.rb213
-rw-r--r--jni/ruby/ext/tk/sample/demos-jp/menu8x.rb233
-rw-r--r--jni/ruby/ext/tk/sample/demos-jp/menubu.rb238
-rw-r--r--jni/ruby/ext/tk/sample/demos-jp/msgbox.rb89
-rw-r--r--jni/ruby/ext/tk/sample/demos-jp/msgbox2.rb90
-rw-r--r--jni/ruby/ext/tk/sample/demos-jp/paned1.rb52
-rw-r--r--jni/ruby/ext/tk/sample/demos-jp/paned2.rb100
-rw-r--r--jni/ruby/ext/tk/sample/demos-jp/pendulum.rb242
-rw-r--r--jni/ruby/ext/tk/sample/demos-jp/plot.rb126
-rw-r--r--jni/ruby/ext/tk/sample/demos-jp/puzzle.rb131
-rw-r--r--jni/ruby/ext/tk/sample/demos-jp/radio.rb84
-rw-r--r--jni/ruby/ext/tk/sample/demos-jp/radio2.rb112
-rw-r--r--jni/ruby/ext/tk/sample/demos-jp/radio3.rb119
-rw-r--r--jni/ruby/ext/tk/sample/demos-jp/rmt268
-rw-r--r--jni/ruby/ext/tk/sample/demos-jp/rolodex320
-rw-r--r--jni/ruby/ext/tk/sample/demos-jp/rolodex-j300
-rw-r--r--jni/ruby/ext/tk/sample/demos-jp/ruler.rb203
-rw-r--r--jni/ruby/ext/tk/sample/demos-jp/sayings.rb103
-rw-r--r--jni/ruby/ext/tk/sample/demos-jp/search.rb184
-rw-r--r--jni/ruby/ext/tk/sample/demos-jp/spin.rb71
-rw-r--r--jni/ruby/ext/tk/sample/demos-jp/square81
-rw-r--r--jni/ruby/ext/tk/sample/demos-jp/states.rb74
-rw-r--r--jni/ruby/ext/tk/sample/demos-jp/style.rb270
-rw-r--r--jni/ruby/ext/tk/sample/demos-jp/tcolor534
-rw-r--r--jni/ruby/ext/tk/sample/demos-jp/text.rb120
-rw-r--r--jni/ruby/ext/tk/sample/demos-jp/textpeer.rb82
-rw-r--r--jni/ruby/ext/tk/sample/demos-jp/timer136
-rw-r--r--jni/ruby/ext/tk/sample/demos-jp/toolbar.rb136
-rw-r--r--jni/ruby/ext/tk/sample/demos-jp/tree.rb120
-rw-r--r--jni/ruby/ext/tk/sample/demos-jp/ttkbut.rb145
-rw-r--r--jni/ruby/ext/tk/sample/demos-jp/ttkmenu.rb91
-rw-r--r--jni/ruby/ext/tk/sample/demos-jp/ttknote.rb97
-rw-r--r--jni/ruby/ext/tk/sample/demos-jp/ttkpane.rb216
-rw-r--r--jni/ruby/ext/tk/sample/demos-jp/ttkprogress.rb71
-rw-r--r--jni/ruby/ext/tk/sample/demos-jp/twind.rb292
-rw-r--r--jni/ruby/ext/tk/sample/demos-jp/twind2.rb384
-rw-r--r--jni/ruby/ext/tk/sample/demos-jp/unicodeout.rb119
-rw-r--r--jni/ruby/ext/tk/sample/demos-jp/vscale.rb80
-rw-r--r--jni/ruby/ext/tk/sample/demos-jp/widget1122
-rw-r--r--jni/ruby/ext/tk/sample/editable_listbox.rb148
-rw-r--r--jni/ruby/ext/tk/sample/encstr_usage.rb30
-rw-r--r--jni/ruby/ext/tk/sample/figmemo_sample.rb456
-rw-r--r--jni/ruby/ext/tk/sample/images/earth.gifbin0 -> 51712 bytes
-rw-r--r--jni/ruby/ext/tk/sample/images/earthris.gifbin0 -> 6343 bytes
-rw-r--r--jni/ruby/ext/tk/sample/images/face.xbm173
-rw-r--r--jni/ruby/ext/tk/sample/images/flagdown.xbm27
-rw-r--r--jni/ruby/ext/tk/sample/images/flagup.xbm27
-rw-r--r--jni/ruby/ext/tk/sample/images/gray25.xbm6
-rw-r--r--jni/ruby/ext/tk/sample/images/grey.256
-rw-r--r--jni/ruby/ext/tk/sample/images/grey.56
-rw-r--r--jni/ruby/ext/tk/sample/images/letters.xbm27
-rw-r--r--jni/ruby/ext/tk/sample/images/noletter.xbm27
-rw-r--r--jni/ruby/ext/tk/sample/images/pattern.xbm6
-rw-r--r--jni/ruby/ext/tk/sample/images/tcllogo.gifbin0 -> 2341 bytes
-rw-r--r--jni/ruby/ext/tk/sample/images/teapot.ppm31
-rw-r--r--jni/ruby/ext/tk/sample/irbtk.rb30
-rw-r--r--jni/ruby/ext/tk/sample/irbtkw.rbw156
-rw-r--r--jni/ruby/ext/tk/sample/iso2022-kr.txt2
-rw-r--r--jni/ruby/ext/tk/sample/menubar1.rb51
-rw-r--r--jni/ruby/ext/tk/sample/menubar2.rb56
-rw-r--r--jni/ruby/ext/tk/sample/menubar3.rb72
-rw-r--r--jni/ruby/ext/tk/sample/msgs_rb/README3
-rw-r--r--jni/ruby/ext/tk/sample/msgs_rb/cs.msg84
-rw-r--r--jni/ruby/ext/tk/sample/msgs_rb/de.msg88
-rw-r--r--jni/ruby/ext/tk/sample/msgs_rb/el.msg98
-rw-r--r--jni/ruby/ext/tk/sample/msgs_rb/en.msg83
-rw-r--r--jni/ruby/ext/tk/sample/msgs_rb/en_gb.msg7
-rw-r--r--jni/ruby/ext/tk/sample/msgs_rb/eo.msg87
-rw-r--r--jni/ruby/ext/tk/sample/msgs_rb/es.msg84
-rw-r--r--jni/ruby/ext/tk/sample/msgs_rb/fr.msg84
-rw-r--r--jni/ruby/ext/tk/sample/msgs_rb/it.msg84
-rw-r--r--jni/ruby/ext/tk/sample/msgs_rb/ja.msg13
-rw-r--r--jni/ruby/ext/tk/sample/msgs_rb/nl.msg123
-rw-r--r--jni/ruby/ext/tk/sample/msgs_rb/pl.msg87
-rw-r--r--jni/ruby/ext/tk/sample/msgs_rb/ru.msg87
-rw-r--r--jni/ruby/ext/tk/sample/msgs_rb2/README5
-rw-r--r--jni/ruby/ext/tk/sample/msgs_rb2/de.msg88
-rw-r--r--jni/ruby/ext/tk/sample/msgs_rb2/ja.msg85
-rw-r--r--jni/ruby/ext/tk/sample/msgs_tk/README4
-rw-r--r--jni/ruby/ext/tk/sample/msgs_tk/cs.msg84
-rw-r--r--jni/ruby/ext/tk/sample/msgs_tk/de.msg88
-rw-r--r--jni/ruby/ext/tk/sample/msgs_tk/el.msg103
-rw-r--r--jni/ruby/ext/tk/sample/msgs_tk/en.msg83
-rw-r--r--jni/ruby/ext/tk/sample/msgs_tk/en_gb.msg7
-rw-r--r--jni/ruby/ext/tk/sample/msgs_tk/eo.msg87
-rw-r--r--jni/ruby/ext/tk/sample/msgs_tk/es.msg84
-rw-r--r--jni/ruby/ext/tk/sample/msgs_tk/fr.msg84
-rw-r--r--jni/ruby/ext/tk/sample/msgs_tk/it.msg84
-rw-r--r--jni/ruby/ext/tk/sample/msgs_tk/ja.msg13
-rw-r--r--jni/ruby/ext/tk/sample/msgs_tk/license.terms39
-rw-r--r--jni/ruby/ext/tk/sample/msgs_tk/nl.msg123
-rw-r--r--jni/ruby/ext/tk/sample/msgs_tk/pl.msg87
-rw-r--r--jni/ruby/ext/tk/sample/msgs_tk/ru.msg87
-rw-r--r--jni/ruby/ext/tk/sample/multi-ip_sample.rb103
-rw-r--r--jni/ruby/ext/tk/sample/multi-ip_sample2.rb29
-rw-r--r--jni/ruby/ext/tk/sample/optobj_sample.rb67
-rw-r--r--jni/ruby/ext/tk/sample/propagate.rb30
-rw-r--r--jni/ruby/ext/tk/sample/remote-ip_sample.rb33
-rw-r--r--jni/ruby/ext/tk/sample/remote-ip_sample2.rb56
-rw-r--r--jni/ruby/ext/tk/sample/resource.en13
-rw-r--r--jni/ruby/ext/tk/sample/resource.ja13
-rw-r--r--jni/ruby/ext/tk/sample/safe-tk.rb134
-rw-r--r--jni/ruby/ext/tk/sample/scrollframe.rb249
-rw-r--r--jni/ruby/ext/tk/sample/tcltklib/batsu.gifbin0 -> 538 bytes
-rw-r--r--jni/ruby/ext/tk/sample/tcltklib/lines0.tcl42
-rw-r--r--jni/ruby/ext/tk/sample/tcltklib/lines1.rb50
-rw-r--r--jni/ruby/ext/tk/sample/tcltklib/lines2.rb54
-rw-r--r--jni/ruby/ext/tk/sample/tcltklib/lines3.rb54
-rw-r--r--jni/ruby/ext/tk/sample/tcltklib/lines4.rb54
-rw-r--r--jni/ruby/ext/tk/sample/tcltklib/maru.gifbin0 -> 481 bytes
-rw-r--r--jni/ruby/ext/tk/sample/tcltklib/safeTk.rb22
-rw-r--r--jni/ruby/ext/tk/sample/tcltklib/sample0.rb39
-rw-r--r--jni/ruby/ext/tk/sample/tcltklib/sample1.rb634
-rw-r--r--jni/ruby/ext/tk/sample/tcltklib/sample2.rb451
-rw-r--r--jni/ruby/ext/tk/sample/tkalignbox.rb235
-rw-r--r--jni/ruby/ext/tk/sample/tkballoonhelp.rb220
-rw-r--r--jni/ruby/ext/tk/sample/tkbiff.rb155
-rw-r--r--jni/ruby/ext/tk/sample/tkbrowse.rb79
-rw-r--r--jni/ruby/ext/tk/sample/tkcombobox.rb497
-rw-r--r--jni/ruby/ext/tk/sample/tkdialog.rb61
-rw-r--r--jni/ruby/ext/tk/sample/tkextlib/ICONS/Orig_LICENSE.txt61
-rw-r--r--jni/ruby/ext/tk/sample/tkextlib/ICONS/tkIcons195
-rw-r--r--jni/ruby/ext/tk/sample/tkextlib/ICONS/tkIcons-sample.kde658
-rw-r--r--jni/ruby/ext/tk/sample/tkextlib/ICONS/tkIcons.kde195
-rw-r--r--jni/ruby/ext/tk/sample/tkextlib/ICONS/viewIcons.rb329
-rw-r--r--jni/ruby/ext/tk/sample/tkextlib/blt/barchart5.rb101
-rw-r--r--jni/ruby/ext/tk/sample/tkextlib/blt/calendar.rb117
-rw-r--r--jni/ruby/ext/tk/sample/tkextlib/blt/graph6.rb2222
-rw-r--r--jni/ruby/ext/tk/sample/tkextlib/blt/graph7.rb40
-rw-r--r--jni/ruby/ext/tk/sample/tkextlib/blt/graph7a.rb63
-rw-r--r--jni/ruby/ext/tk/sample/tkextlib/blt/graph7b.rb41
-rw-r--r--jni/ruby/ext/tk/sample/tkextlib/blt/graph7c.rb45
-rw-r--r--jni/ruby/ext/tk/sample/tkextlib/blt/images/buckskin.gifbin0 -> 7561 bytes
-rw-r--r--jni/ruby/ext/tk/sample/tkextlib/blt/images/chalk.gifbin0 -> 4378 bytes
-rw-r--r--jni/ruby/ext/tk/sample/tkextlib/blt/images/qv100.t.gifbin0 -> 2694 bytes
-rw-r--r--jni/ruby/ext/tk/sample/tkextlib/blt/images/rain.gifbin0 -> 3785 bytes
-rw-r--r--jni/ruby/ext/tk/sample/tkextlib/blt/images/sample.gifbin0 -> 186103 bytes
-rw-r--r--jni/ruby/ext/tk/sample/tkextlib/blt/pareto.rb90
-rw-r--r--jni/ruby/ext/tk/sample/tkextlib/blt/plot1.rb9
-rw-r--r--jni/ruby/ext/tk/sample/tkextlib/blt/plot1b.rb10
-rw-r--r--jni/ruby/ext/tk/sample/tkextlib/blt/readme.txt2
-rw-r--r--jni/ruby/ext/tk/sample/tkextlib/blt/scripts/stipples.rb156
-rw-r--r--jni/ruby/ext/tk/sample/tkextlib/blt/winop1.rb40
-rw-r--r--jni/ruby/ext/tk/sample/tkextlib/blt/winop2.rb28
-rw-r--r--jni/ruby/ext/tk/sample/tkextlib/bwidget/Orig_LICENSE.txt53
-rw-r--r--jni/ruby/ext/tk/sample/tkextlib/bwidget/basic.rb198
-rw-r--r--jni/ruby/ext/tk/sample/tkextlib/bwidget/bwidget.xbm46
-rw-r--r--jni/ruby/ext/tk/sample/tkextlib/bwidget/demo.rb243
-rw-r--r--jni/ruby/ext/tk/sample/tkextlib/bwidget/dnd.rb46
-rw-r--r--jni/ruby/ext/tk/sample/tkextlib/bwidget/manager.rb150
-rw-r--r--jni/ruby/ext/tk/sample/tkextlib/bwidget/select.rb82
-rw-r--r--jni/ruby/ext/tk/sample/tkextlib/bwidget/tmpldlg.rb221
-rw-r--r--jni/ruby/ext/tk/sample/tkextlib/bwidget/tree.rb289
-rw-r--r--jni/ruby/ext/tk/sample/tkextlib/bwidget/x1.xbm2258
-rw-r--r--jni/ruby/ext/tk/sample/tkextlib/iwidgets/catalog_demo/Orig_LICENSE.txt42
-rw-r--r--jni/ruby/ext/tk/sample/tkextlib/iwidgets/catalog_demo/images/box.xbm14
-rw-r--r--jni/ruby/ext/tk/sample/tkextlib/iwidgets/catalog_demo/images/clear.gifbin0 -> 279 bytes
-rw-r--r--jni/ruby/ext/tk/sample/tkextlib/iwidgets/catalog_demo/images/close.gifbin0 -> 249 bytes
-rw-r--r--jni/ruby/ext/tk/sample/tkextlib/iwidgets/catalog_demo/images/copy.gifbin0 -> 269 bytes
-rw-r--r--jni/ruby/ext/tk/sample/tkextlib/iwidgets/catalog_demo/images/cut.gifbin0 -> 179 bytes
-rw-r--r--jni/ruby/ext/tk/sample/tkextlib/iwidgets/catalog_demo/images/exit.gifbin0 -> 396 bytes
-rw-r--r--jni/ruby/ext/tk/sample/tkextlib/iwidgets/catalog_demo/images/find.gifbin0 -> 386 bytes
-rw-r--r--jni/ruby/ext/tk/sample/tkextlib/iwidgets/catalog_demo/images/help.gifbin0 -> 591 bytes
-rw-r--r--jni/ruby/ext/tk/sample/tkextlib/iwidgets/catalog_demo/images/line.xbm14
-rw-r--r--jni/ruby/ext/tk/sample/tkextlib/iwidgets/catalog_demo/images/mag.gifbin0 -> 183 bytes
-rw-r--r--jni/ruby/ext/tk/sample/tkextlib/iwidgets/catalog_demo/images/new.gifbin0 -> 212 bytes
-rw-r--r--jni/ruby/ext/tk/sample/tkextlib/iwidgets/catalog_demo/images/open.gifbin0 -> 258 bytes
-rw-r--r--jni/ruby/ext/tk/sample/tkextlib/iwidgets/catalog_demo/images/oval.xbm14
-rw-r--r--jni/ruby/ext/tk/sample/tkextlib/iwidgets/catalog_demo/images/paste.gifbin0 -> 376 bytes
-rw-r--r--jni/ruby/ext/tk/sample/tkextlib/iwidgets/catalog_demo/images/points.xbm14
-rw-r--r--jni/ruby/ext/tk/sample/tkextlib/iwidgets/catalog_demo/images/poly.gifbin0 -> 141 bytes
-rw-r--r--jni/ruby/ext/tk/sample/tkextlib/iwidgets/catalog_demo/images/print.gifbin0 -> 263 bytes
-rw-r--r--jni/ruby/ext/tk/sample/tkextlib/iwidgets/catalog_demo/images/ruler.gifbin0 -> 174 bytes
-rw-r--r--jni/ruby/ext/tk/sample/tkextlib/iwidgets/catalog_demo/images/save.gifbin0 -> 270 bytes
-rw-r--r--jni/ruby/ext/tk/sample/tkextlib/iwidgets/catalog_demo/images/select.gifbin0 -> 124 bytes
-rw-r--r--jni/ruby/ext/tk/sample/tkextlib/iwidgets/catalog_demo/images/text.xbm14
-rw-r--r--jni/ruby/ext/tk/sample/tkextlib/iwidgets/sample/buttonbox.rb22
-rw-r--r--jni/ruby/ext/tk/sample/tkextlib/iwidgets/sample/calendar.rb10
-rw-r--r--jni/ruby/ext/tk/sample/tkextlib/iwidgets/sample/canvasprintbox.rb8
-rw-r--r--jni/ruby/ext/tk/sample/tkextlib/iwidgets/sample/canvasprintdialog.rb8
-rw-r--r--jni/ruby/ext/tk/sample/tkextlib/iwidgets/sample/checkbox.rb12
-rw-r--r--jni/ruby/ext/tk/sample/tkextlib/iwidgets/sample/combobox.rb32
-rw-r--r--jni/ruby/ext/tk/sample/tkextlib/iwidgets/sample/dateentry.rb7
-rw-r--r--jni/ruby/ext/tk/sample/tkextlib/iwidgets/sample/datefield.rb8
-rw-r--r--jni/ruby/ext/tk/sample/tkextlib/iwidgets/sample/dialog.rb20
-rw-r--r--jni/ruby/ext/tk/sample/tkextlib/iwidgets/sample/dialogshell.rb14
-rw-r--r--jni/ruby/ext/tk/sample/tkextlib/iwidgets/sample/disjointlistbox.rb16
-rw-r--r--jni/ruby/ext/tk/sample/tkextlib/iwidgets/sample/entryfield-1.rb39
-rw-r--r--jni/ruby/ext/tk/sample/tkextlib/iwidgets/sample/entryfield-2.rb44
-rw-r--r--jni/ruby/ext/tk/sample/tkextlib/iwidgets/sample/entryfield-3.rb40
-rw-r--r--jni/ruby/ext/tk/sample/tkextlib/iwidgets/sample/extbutton.rb20
-rw-r--r--jni/ruby/ext/tk/sample/tkextlib/iwidgets/sample/extfileselectionbox.rb8
-rw-r--r--jni/ruby/ext/tk/sample/tkextlib/iwidgets/sample/extfileselectiondialog.rb29
-rw-r--r--jni/ruby/ext/tk/sample/tkextlib/iwidgets/sample/feedback.rb10
-rw-r--r--jni/ruby/ext/tk/sample/tkextlib/iwidgets/sample/fileselectionbox.rb8
-rw-r--r--jni/ruby/ext/tk/sample/tkextlib/iwidgets/sample/fileselectiondialog.rb28
-rw-r--r--jni/ruby/ext/tk/sample/tkextlib/iwidgets/sample/finddialog.rb15
-rw-r--r--jni/ruby/ext/tk/sample/tkextlib/iwidgets/sample/hierarchy.rb25
-rw-r--r--jni/ruby/ext/tk/sample/tkextlib/iwidgets/sample/hyperhelp.rb14
-rw-r--r--jni/ruby/ext/tk/sample/tkextlib/iwidgets/sample/labeledframe.rb14
-rw-r--r--jni/ruby/ext/tk/sample/tkextlib/iwidgets/sample/labeledwidget.rb13
-rw-r--r--jni/ruby/ext/tk/sample/tkextlib/iwidgets/sample/mainwindow.rb64
-rw-r--r--jni/ruby/ext/tk/sample/tkextlib/iwidgets/sample/menubar.rb124
-rw-r--r--jni/ruby/ext/tk/sample/tkextlib/iwidgets/sample/menubar2.rb44
-rw-r--r--jni/ruby/ext/tk/sample/tkextlib/iwidgets/sample/messagebox1.rb19
-rw-r--r--jni/ruby/ext/tk/sample/tkextlib/iwidgets/sample/messagebox2.rb19
-rw-r--r--jni/ruby/ext/tk/sample/tkextlib/iwidgets/sample/messagedialog.rb44
-rw-r--r--jni/ruby/ext/tk/sample/tkextlib/iwidgets/sample/notebook.rb30
-rw-r--r--jni/ruby/ext/tk/sample/tkextlib/iwidgets/sample/notebook2.rb30
-rw-r--r--jni/ruby/ext/tk/sample/tkextlib/iwidgets/sample/optionmenu.rb14
-rw-r--r--jni/ruby/ext/tk/sample/tkextlib/iwidgets/sample/panedwindow.rb22
-rw-r--r--jni/ruby/ext/tk/sample/tkextlib/iwidgets/sample/panedwindow2.rb22
-rw-r--r--jni/ruby/ext/tk/sample/tkextlib/iwidgets/sample/promptdialog.rb17
-rw-r--r--jni/ruby/ext/tk/sample/tkextlib/iwidgets/sample/pushbutton.rb9
-rw-r--r--jni/ruby/ext/tk/sample/tkextlib/iwidgets/sample/radiobox.rb13
-rw-r--r--jni/ruby/ext/tk/sample/tkextlib/iwidgets/sample/scrolledcanvas.rb13
-rw-r--r--jni/ruby/ext/tk/sample/tkextlib/iwidgets/sample/scrolledframe.rb18
-rw-r--r--jni/ruby/ext/tk/sample/tkextlib/iwidgets/sample/scrolledhtml.rb15
-rw-r--r--jni/ruby/ext/tk/sample/tkextlib/iwidgets/sample/scrolledlistbox.rb22
-rw-r--r--jni/ruby/ext/tk/sample/tkextlib/iwidgets/sample/scrolledtext.rb11
-rw-r--r--jni/ruby/ext/tk/sample/tkextlib/iwidgets/sample/selectionbox.rb19
-rw-r--r--jni/ruby/ext/tk/sample/tkextlib/iwidgets/sample/selectiondialog.rb12
-rw-r--r--jni/ruby/ext/tk/sample/tkextlib/iwidgets/sample/shell.rb17
-rw-r--r--jni/ruby/ext/tk/sample/tkextlib/iwidgets/sample/spindate.rb7
-rw-r--r--jni/ruby/ext/tk/sample/tkextlib/iwidgets/sample/spinint.rb10
-rw-r--r--jni/ruby/ext/tk/sample/tkextlib/iwidgets/sample/spinner.rb33
-rw-r--r--jni/ruby/ext/tk/sample/tkextlib/iwidgets/sample/spintime.rb7
-rw-r--r--jni/ruby/ext/tk/sample/tkextlib/iwidgets/sample/tabnotebook.rb26
-rw-r--r--jni/ruby/ext/tk/sample/tkextlib/iwidgets/sample/tabnotebook2.rb30
-rw-r--r--jni/ruby/ext/tk/sample/tkextlib/iwidgets/sample/tabset.rb34
-rw-r--r--jni/ruby/ext/tk/sample/tkextlib/iwidgets/sample/timeentry.rb7
-rw-r--r--jni/ruby/ext/tk/sample/tkextlib/iwidgets/sample/timefield.rb8
-rw-r--r--jni/ruby/ext/tk/sample/tkextlib/iwidgets/sample/toolbar.rb152
-rw-r--r--jni/ruby/ext/tk/sample/tkextlib/iwidgets/sample/watch.rb18
-rw-r--r--jni/ruby/ext/tk/sample/tkextlib/tcllib/Orig_LICENSE.txt46
-rw-r--r--jni/ruby/ext/tk/sample/tkextlib/tcllib/datefield.rb29
-rw-r--r--jni/ruby/ext/tk/sample/tkextlib/tcllib/plotdemos1.rb158
-rw-r--r--jni/ruby/ext/tk/sample/tkextlib/tcllib/plotdemos2.rb71
-rw-r--r--jni/ruby/ext/tk/sample/tkextlib/tcllib/plotdemos3.rb83
-rw-r--r--jni/ruby/ext/tk/sample/tkextlib/tcllib/xyplot.rb17
-rw-r--r--jni/ruby/ext/tk/sample/tkextlib/tile/Orig_LICENSE.txt30
-rw-r--r--jni/ruby/ext/tk/sample/tkextlib/tile/demo.rb983
-rw-r--r--jni/ruby/ext/tk/sample/tkextlib/tile/iconlib.tcl110
-rw-r--r--jni/ruby/ext/tk/sample/tkextlib/tile/readme.txt2
-rw-r--r--jni/ruby/ext/tk/sample/tkextlib/tile/repeater.tcl117
-rw-r--r--jni/ruby/ext/tk/sample/tkextlib/tile/themes/blue/blue.tcl149
-rw-r--r--jni/ruby/ext/tk/sample/tkextlib/tile/themes/blue/blue/arrowdown-h.gifbin0 -> 315 bytes
-rw-r--r--jni/ruby/ext/tk/sample/tkextlib/tile/themes/blue/blue/arrowdown-p.gifbin0 -> 312 bytes
-rw-r--r--jni/ruby/ext/tk/sample/tkextlib/tile/themes/blue/blue/arrowdown.gifbin0 -> 313 bytes
-rw-r--r--jni/ruby/ext/tk/sample/tkextlib/tile/themes/blue/blue/arrowleft-h.gifbin0 -> 329 bytes
-rw-r--r--jni/ruby/ext/tk/sample/tkextlib/tile/themes/blue/blue/arrowleft-p.gifbin0 -> 327 bytes
-rw-r--r--jni/ruby/ext/tk/sample/tkextlib/tile/themes/blue/blue/arrowleft.gifbin0 -> 323 bytes
-rw-r--r--jni/ruby/ext/tk/sample/tkextlib/tile/themes/blue/blue/arrowright-h.gifbin0 -> 330 bytes
-rw-r--r--jni/ruby/ext/tk/sample/tkextlib/tile/themes/blue/blue/arrowright-p.gifbin0 -> 327 bytes
-rw-r--r--jni/ruby/ext/tk/sample/tkextlib/tile/themes/blue/blue/arrowright.gifbin0 -> 324 bytes
-rw-r--r--jni/ruby/ext/tk/sample/tkextlib/tile/themes/blue/blue/arrowup-h.gifbin0 -> 309 bytes
-rw-r--r--jni/ruby/ext/tk/sample/tkextlib/tile/themes/blue/blue/arrowup-p.gifbin0 -> 313 bytes
-rw-r--r--jni/ruby/ext/tk/sample/tkextlib/tile/themes/blue/blue/arrowup.gifbin0 -> 314 bytes
-rw-r--r--jni/ruby/ext/tk/sample/tkextlib/tile/themes/blue/blue/button-h.gifbin0 -> 696 bytes
-rw-r--r--jni/ruby/ext/tk/sample/tkextlib/tile/themes/blue/blue/button-n.gifbin0 -> 770 bytes
-rw-r--r--jni/ruby/ext/tk/sample/tkextlib/tile/themes/blue/blue/button-n.xcfbin0 -> 1942 bytes
-rw-r--r--jni/ruby/ext/tk/sample/tkextlib/tile/themes/blue/blue/button-p.gifbin0 -> 769 bytes
-rw-r--r--jni/ruby/ext/tk/sample/tkextlib/tile/themes/blue/blue/check-hc.gifbin0 -> 254 bytes
-rw-r--r--jni/ruby/ext/tk/sample/tkextlib/tile/themes/blue/blue/check-hu.gifbin0 -> 234 bytes
-rw-r--r--jni/ruby/ext/tk/sample/tkextlib/tile/themes/blue/blue/check-nc.gifbin0 -> 249 bytes
-rw-r--r--jni/ruby/ext/tk/sample/tkextlib/tile/themes/blue/blue/check-nu.gifbin0 -> 229 bytes
-rw-r--r--jni/ruby/ext/tk/sample/tkextlib/tile/themes/blue/blue/radio-hc.gifbin0 -> 1098 bytes
-rw-r--r--jni/ruby/ext/tk/sample/tkextlib/tile/themes/blue/blue/radio-hu.gifbin0 -> 626 bytes
-rw-r--r--jni/ruby/ext/tk/sample/tkextlib/tile/themes/blue/blue/radio-nc.gifbin0 -> 389 bytes
-rw-r--r--jni/ruby/ext/tk/sample/tkextlib/tile/themes/blue/blue/radio-nu.gifbin0 -> 401 bytes
-rw-r--r--jni/ruby/ext/tk/sample/tkextlib/tile/themes/blue/blue/sb-thumb-p.gifbin0 -> 343 bytes
-rw-r--r--jni/ruby/ext/tk/sample/tkextlib/tile/themes/blue/blue/sb-thumb.gifbin0 -> 316 bytes
-rw-r--r--jni/ruby/ext/tk/sample/tkextlib/tile/themes/blue/blue/sb-vthumb-p.gifbin0 -> 333 bytes
-rw-r--r--jni/ruby/ext/tk/sample/tkextlib/tile/themes/blue/blue/sb-vthumb.gifbin0 -> 308 bytes
-rw-r--r--jni/ruby/ext/tk/sample/tkextlib/tile/themes/blue/blue/slider-p.gifbin0 -> 182 bytes
-rw-r--r--jni/ruby/ext/tk/sample/tkextlib/tile/themes/blue/blue/slider.gifbin0 -> 182 bytes
-rw-r--r--jni/ruby/ext/tk/sample/tkextlib/tile/themes/blue/blue/vslider-p.gifbin0 -> 183 bytes
-rw-r--r--jni/ruby/ext/tk/sample/tkextlib/tile/themes/blue/blue/vslider.gifbin0 -> 283 bytes
-rw-r--r--jni/ruby/ext/tk/sample/tkextlib/tile/themes/blue/pkgIndex.tcl6
-rw-r--r--jni/ruby/ext/tk/sample/tkextlib/tile/themes/keramik/keramik.tcl194
-rw-r--r--jni/ruby/ext/tk/sample/tkextlib/tile/themes/keramik/keramik/arrowdown-n.gifbin0 -> 273 bytes
-rw-r--r--jni/ruby/ext/tk/sample/tkextlib/tile/themes/keramik/keramik/arrowdown-p.gifbin0 -> 258 bytes
-rw-r--r--jni/ruby/ext/tk/sample/tkextlib/tile/themes/keramik/keramik/arrowleft-n.gifbin0 -> 292 bytes
-rw-r--r--jni/ruby/ext/tk/sample/tkextlib/tile/themes/keramik/keramik/arrowleft-p.gifbin0 -> 272 bytes
-rw-r--r--jni/ruby/ext/tk/sample/tkextlib/tile/themes/keramik/keramik/arrowright-n.gifbin0 -> 274 bytes
-rw-r--r--jni/ruby/ext/tk/sample/tkextlib/tile/themes/keramik/keramik/arrowright-p.gifbin0 -> 258 bytes
-rw-r--r--jni/ruby/ext/tk/sample/tkextlib/tile/themes/keramik/keramik/arrowup-n.gifbin0 -> 286 bytes
-rw-r--r--jni/ruby/ext/tk/sample/tkextlib/tile/themes/keramik/keramik/arrowup-p.gifbin0 -> 271 bytes
-rw-r--r--jni/ruby/ext/tk/sample/tkextlib/tile/themes/keramik/keramik/button-d.gifbin0 -> 1266 bytes
-rw-r--r--jni/ruby/ext/tk/sample/tkextlib/tile/themes/keramik/keramik/button-h.gifbin0 -> 896 bytes
-rw-r--r--jni/ruby/ext/tk/sample/tkextlib/tile/themes/keramik/keramik/button-n.gifbin0 -> 881 bytes
-rw-r--r--jni/ruby/ext/tk/sample/tkextlib/tile/themes/keramik/keramik/button-p.gifbin0 -> 625 bytes
-rw-r--r--jni/ruby/ext/tk/sample/tkextlib/tile/themes/keramik/keramik/button-s.gifbin0 -> 859 bytes
-rw-r--r--jni/ruby/ext/tk/sample/tkextlib/tile/themes/keramik/keramik/check-c.gifbin0 -> 434 bytes
-rw-r--r--jni/ruby/ext/tk/sample/tkextlib/tile/themes/keramik/keramik/check-u.gifbin0 -> 423 bytes
-rw-r--r--jni/ruby/ext/tk/sample/tkextlib/tile/themes/keramik/keramik/hsb-n.gifbin0 -> 401 bytes
-rw-r--r--jni/ruby/ext/tk/sample/tkextlib/tile/themes/keramik/keramik/hsb-p.gifbin0 -> 395 bytes
-rw-r--r--jni/ruby/ext/tk/sample/tkextlib/tile/themes/keramik/keramik/hslider-n.gifbin0 -> 592 bytes
-rw-r--r--jni/ruby/ext/tk/sample/tkextlib/tile/themes/keramik/keramik/mbut-a.gifbin0 -> 1116 bytes
-rw-r--r--jni/ruby/ext/tk/sample/tkextlib/tile/themes/keramik/keramik/mbut-arrow-n.gifbin0 -> 61 bytes
-rw-r--r--jni/ruby/ext/tk/sample/tkextlib/tile/themes/keramik/keramik/mbut-d.gifbin0 -> 1057 bytes
-rw-r--r--jni/ruby/ext/tk/sample/tkextlib/tile/themes/keramik/keramik/mbut-n.gifbin0 -> 1095 bytes
-rw-r--r--jni/ruby/ext/tk/sample/tkextlib/tile/themes/keramik/keramik/radio-c.gifbin0 -> 695 bytes
-rw-r--r--jni/ruby/ext/tk/sample/tkextlib/tile/themes/keramik/keramik/radio-u.gifbin0 -> 686 bytes
-rw-r--r--jni/ruby/ext/tk/sample/tkextlib/tile/themes/keramik/keramik/tab-n.gifbin0 -> 383 bytes
-rw-r--r--jni/ruby/ext/tk/sample/tkextlib/tile/themes/keramik/keramik/tab-p.gifbin0 -> 878 bytes
-rw-r--r--jni/ruby/ext/tk/sample/tkextlib/tile/themes/keramik/keramik/tbar-a.gifbin0 -> 907 bytes
-rw-r--r--jni/ruby/ext/tk/sample/tkextlib/tile/themes/keramik/keramik/tbar-n.gifbin0 -> 238 bytes
-rw-r--r--jni/ruby/ext/tk/sample/tkextlib/tile/themes/keramik/keramik/tbar-p.gifbin0 -> 927 bytes
-rw-r--r--jni/ruby/ext/tk/sample/tkextlib/tile/themes/keramik/keramik/vsb-n.gifbin0 -> 405 bytes
-rw-r--r--jni/ruby/ext/tk/sample/tkextlib/tile/themes/keramik/keramik/vsb-p.gifbin0 -> 399 bytes
-rw-r--r--jni/ruby/ext/tk/sample/tkextlib/tile/themes/keramik/keramik/vslider-n.gifbin0 -> 587 bytes
-rw-r--r--jni/ruby/ext/tk/sample/tkextlib/tile/themes/keramik/pkgIndex.tcl15
-rw-r--r--jni/ruby/ext/tk/sample/tkextlib/tile/themes/kroc.rb226
-rw-r--r--jni/ruby/ext/tk/sample/tkextlib/tile/themes/kroc/kroc.tcl163
-rw-r--r--jni/ruby/ext/tk/sample/tkextlib/tile/themes/kroc/kroc/button-h.gifbin0 -> 522 bytes
-rw-r--r--jni/ruby/ext/tk/sample/tkextlib/tile/themes/kroc/kroc/button-n.gifbin0 -> 554 bytes
-rw-r--r--jni/ruby/ext/tk/sample/tkextlib/tile/themes/kroc/kroc/button-p.gifbin0 -> 548 bytes
-rw-r--r--jni/ruby/ext/tk/sample/tkextlib/tile/themes/kroc/kroc/check-hc.gifbin0 -> 281 bytes
-rw-r--r--jni/ruby/ext/tk/sample/tkextlib/tile/themes/kroc/kroc/check-hu.gifbin0 -> 273 bytes
-rw-r--r--jni/ruby/ext/tk/sample/tkextlib/tile/themes/kroc/kroc/check-nc.gifbin0 -> 303 bytes
-rw-r--r--jni/ruby/ext/tk/sample/tkextlib/tile/themes/kroc/kroc/check-nu.gifbin0 -> 294 bytes
-rw-r--r--jni/ruby/ext/tk/sample/tkextlib/tile/themes/kroc/kroc/radio-hc.gifbin0 -> 652 bytes
-rw-r--r--jni/ruby/ext/tk/sample/tkextlib/tile/themes/kroc/kroc/radio-hu.gifbin0 -> 644 bytes
-rw-r--r--jni/ruby/ext/tk/sample/tkextlib/tile/themes/kroc/kroc/radio-nc.gifbin0 -> 632 bytes
-rw-r--r--jni/ruby/ext/tk/sample/tkextlib/tile/themes/kroc/kroc/radio-nu.gifbin0 -> 621 bytes
-rw-r--r--jni/ruby/ext/tk/sample/tkextlib/tile/themes/kroc/pkgIndex.tcl15
-rw-r--r--jni/ruby/ext/tk/sample/tkextlib/tile/themes/plastik/pkgIndex.tcl16
-rw-r--r--jni/ruby/ext/tk/sample/tkextlib/tile/themes/plastik/plastik.tcl125
-rw-r--r--jni/ruby/ext/tk/sample/tkextlib/tile/themes/plastik/plastik/arrowdown-n.gifbin0 -> 362 bytes
-rw-r--r--jni/ruby/ext/tk/sample/tkextlib/tile/themes/plastik/plastik/arrowdown-p.gifbin0 -> 250 bytes
-rw-r--r--jni/ruby/ext/tk/sample/tkextlib/tile/themes/plastik/plastik/arrowleft-n.gifbin0 -> 378 bytes
-rw-r--r--jni/ruby/ext/tk/sample/tkextlib/tile/themes/plastik/plastik/arrowleft-p.gifbin0 -> 267 bytes
-rw-r--r--jni/ruby/ext/tk/sample/tkextlib/tile/themes/plastik/plastik/arrowright-n.gifbin0 -> 379 bytes
-rw-r--r--jni/ruby/ext/tk/sample/tkextlib/tile/themes/plastik/plastik/arrowright-p.gifbin0 -> 266 bytes
-rw-r--r--jni/ruby/ext/tk/sample/tkextlib/tile/themes/plastik/plastik/arrowup-n.gifbin0 -> 363 bytes
-rw-r--r--jni/ruby/ext/tk/sample/tkextlib/tile/themes/plastik/plastik/arrowup-p.gifbin0 -> 251 bytes
-rw-r--r--jni/ruby/ext/tk/sample/tkextlib/tile/themes/plastik/plastik/button-h.gifbin0 -> 439 bytes
-rw-r--r--jni/ruby/ext/tk/sample/tkextlib/tile/themes/plastik/plastik/button-n.gifbin0 -> 443 bytes
-rw-r--r--jni/ruby/ext/tk/sample/tkextlib/tile/themes/plastik/plastik/button-p.gifbin0 -> 302 bytes
-rw-r--r--jni/ruby/ext/tk/sample/tkextlib/tile/themes/plastik/plastik/check-hc.gifbin0 -> 169 bytes
-rw-r--r--jni/ruby/ext/tk/sample/tkextlib/tile/themes/plastik/plastik/check-hu.gifbin0 -> 170 bytes
-rw-r--r--jni/ruby/ext/tk/sample/tkextlib/tile/themes/plastik/plastik/check-nc.gifbin0 -> 235 bytes
-rw-r--r--jni/ruby/ext/tk/sample/tkextlib/tile/themes/plastik/plastik/check-nu.gifbin0 -> 226 bytes
-rw-r--r--jni/ruby/ext/tk/sample/tkextlib/tile/themes/plastik/plastik/check-pc.gifbin0 -> 169 bytes
-rw-r--r--jni/ruby/ext/tk/sample/tkextlib/tile/themes/plastik/plastik/hsb-n.gifbin0 -> 269 bytes
-rw-r--r--jni/ruby/ext/tk/sample/tkextlib/tile/themes/plastik/plastik/hslider-n.gifbin0 -> 342 bytes
-rw-r--r--jni/ruby/ext/tk/sample/tkextlib/tile/themes/plastik/plastik/radio-hc.gifbin0 -> 178 bytes
-rw-r--r--jni/ruby/ext/tk/sample/tkextlib/tile/themes/plastik/plastik/radio-hu.gifbin0 -> 179 bytes
-rw-r--r--jni/ruby/ext/tk/sample/tkextlib/tile/themes/plastik/plastik/radio-nc.gifbin0 -> 236 bytes
-rw-r--r--jni/ruby/ext/tk/sample/tkextlib/tile/themes/plastik/plastik/radio-nu.gifbin0 -> 178 bytes
-rw-r--r--jni/ruby/ext/tk/sample/tkextlib/tile/themes/plastik/plastik/radio-pc.gifbin0 -> 178 bytes
-rw-r--r--jni/ruby/ext/tk/sample/tkextlib/tile/themes/plastik/plastik/vsb-n.gifbin0 -> 366 bytes
-rw-r--r--jni/ruby/ext/tk/sample/tkextlib/tile/themes/plastik/plastik/vslider-n.gifbin0 -> 336 bytes
-rw-r--r--jni/ruby/ext/tk/sample/tkextlib/tile/toolbutton.tcl152
-rw-r--r--jni/ruby/ext/tk/sample/tkextlib/tkHTML/Orig_COPYRIGHT.txt12
-rw-r--r--jni/ruby/ext/tk/sample/tkextlib/tkHTML/README12
-rw-r--r--jni/ruby/ext/tk/sample/tkextlib/tkHTML/hv.rb313
-rw-r--r--jni/ruby/ext/tk/sample/tkextlib/tkHTML/page1/image1bin0 -> 8995 bytes
-rw-r--r--jni/ruby/ext/tk/sample/tkextlib/tkHTML/page1/image10bin0 -> 3095 bytes
-rw-r--r--jni/ruby/ext/tk/sample/tkextlib/tkHTML/page1/image11bin0 -> 1425 bytes
-rw-r--r--jni/ruby/ext/tk/sample/tkextlib/tkHTML/page1/image12bin0 -> 2468 bytes
-rw-r--r--jni/ruby/ext/tk/sample/tkextlib/tkHTML/page1/image13bin0 -> 4073 bytes
-rw-r--r--jni/ruby/ext/tk/sample/tkextlib/tkHTML/page1/image14bin0 -> 53 bytes
-rw-r--r--jni/ruby/ext/tk/sample/tkextlib/tkHTML/page1/image2bin0 -> 42 bytes
-rw-r--r--jni/ruby/ext/tk/sample/tkextlib/tkHTML/page1/image3bin0 -> 3473 bytes
-rw-r--r--jni/ruby/ext/tk/sample/tkextlib/tkHTML/page1/image4bin0 -> 1988 bytes
-rw-r--r--jni/ruby/ext/tk/sample/tkextlib/tkHTML/page1/image5bin0 -> 973 bytes
-rw-r--r--jni/ruby/ext/tk/sample/tkextlib/tkHTML/page1/image6bin0 -> 2184 bytes
-rw-r--r--jni/ruby/ext/tk/sample/tkextlib/tkHTML/page1/image7bin0 -> 2022 bytes
-rw-r--r--jni/ruby/ext/tk/sample/tkextlib/tkHTML/page1/image8bin0 -> 1186 bytes
-rw-r--r--jni/ruby/ext/tk/sample/tkextlib/tkHTML/page1/image9bin0 -> 139 bytes
-rw-r--r--jni/ruby/ext/tk/sample/tkextlib/tkHTML/page1/index.html115
-rw-r--r--jni/ruby/ext/tk/sample/tkextlib/tkHTML/page2/image1bin0 -> 1966 bytes
-rw-r--r--jni/ruby/ext/tk/sample/tkextlib/tkHTML/page2/image10bin0 -> 255 bytes
-rw-r--r--jni/ruby/ext/tk/sample/tkextlib/tkHTML/page2/image11bin0 -> 590 bytes
-rw-r--r--jni/ruby/ext/tk/sample/tkextlib/tkHTML/page2/image12bin0 -> 254 bytes
-rw-r--r--jni/ruby/ext/tk/sample/tkextlib/tkHTML/page2/image13bin0 -> 493 bytes
-rw-r--r--jni/ruby/ext/tk/sample/tkextlib/tkHTML/page2/image14bin0 -> 195 bytes
-rw-r--r--jni/ruby/ext/tk/sample/tkextlib/tkHTML/page2/image15bin0 -> 68 bytes
-rw-r--r--jni/ruby/ext/tk/sample/tkextlib/tkHTML/page2/image16bin0 -> 157 bytes
-rw-r--r--jni/ruby/ext/tk/sample/tkextlib/tkHTML/page2/image17bin0 -> 81 bytes
-rw-r--r--jni/ruby/ext/tk/sample/tkextlib/tkHTML/page2/image18bin0 -> 545 bytes
-rw-r--r--jni/ruby/ext/tk/sample/tkextlib/tkHTML/page2/image19bin0 -> 53 bytes
-rw-r--r--jni/ruby/ext/tk/sample/tkextlib/tkHTML/page2/image2bin0 -> 49 bytes
-rw-r--r--jni/ruby/ext/tk/sample/tkextlib/tkHTML/page2/image20bin0 -> 533 bytes
-rw-r--r--jni/ruby/ext/tk/sample/tkextlib/tkHTML/page2/image21bin0 -> 564 bytes
-rw-r--r--jni/ruby/ext/tk/sample/tkextlib/tkHTML/page2/image22bin0 -> 81 bytes
-rw-r--r--jni/ruby/ext/tk/sample/tkextlib/tkHTML/page2/image23bin0 -> 539 bytes
-rw-r--r--jni/ruby/ext/tk/sample/tkextlib/tkHTML/page2/image24bin0 -> 151 bytes
-rw-r--r--jni/ruby/ext/tk/sample/tkextlib/tkHTML/page2/image25bin0 -> 453 bytes
-rw-r--r--jni/ruby/ext/tk/sample/tkextlib/tkHTML/page2/image26bin0 -> 520 bytes
-rw-r--r--jni/ruby/ext/tk/sample/tkextlib/tkHTML/page2/image27bin0 -> 565 bytes
-rw-r--r--jni/ruby/ext/tk/sample/tkextlib/tkHTML/page2/image28bin0 -> 416 bytes
-rw-r--r--jni/ruby/ext/tk/sample/tkextlib/tkHTML/page2/image29bin0 -> 121 bytes
-rw-r--r--jni/ruby/ext/tk/sample/tkextlib/tkHTML/page2/image3bin0 -> 10835 bytes
-rw-r--r--jni/ruby/ext/tk/sample/tkextlib/tkHTML/page2/image30bin0 -> 663 bytes
-rw-r--r--jni/ruby/ext/tk/sample/tkextlib/tkHTML/page2/image31bin0 -> 78 bytes
-rw-r--r--jni/ruby/ext/tk/sample/tkextlib/tkHTML/page2/image32bin0 -> 556 bytes
-rw-r--r--jni/ruby/ext/tk/sample/tkextlib/tkHTML/page2/image33bin0 -> 598 bytes
-rw-r--r--jni/ruby/ext/tk/sample/tkextlib/tkHTML/page2/image34bin0 -> 496 bytes
-rw-r--r--jni/ruby/ext/tk/sample/tkextlib/tkHTML/page2/image35bin0 -> 724 bytes
-rw-r--r--jni/ruby/ext/tk/sample/tkextlib/tkHTML/page2/image36bin0 -> 404 bytes
-rw-r--r--jni/ruby/ext/tk/sample/tkextlib/tkHTML/page2/image37bin0 -> 124 bytes
-rw-r--r--jni/ruby/ext/tk/sample/tkextlib/tkHTML/page2/image38bin0 -> 8330 bytes
-rw-r--r--jni/ruby/ext/tk/sample/tkextlib/tkHTML/page2/image39bin0 -> 369 bytes
-rw-r--r--jni/ruby/ext/tk/sample/tkextlib/tkHTML/page2/image4bin0 -> 268 bytes
-rw-r--r--jni/ruby/ext/tk/sample/tkextlib/tkHTML/page2/image5bin0 -> 492 bytes
-rw-r--r--jni/ruby/ext/tk/sample/tkextlib/tkHTML/page2/image6bin0 -> 246 bytes
-rw-r--r--jni/ruby/ext/tk/sample/tkextlib/tkHTML/page2/image7bin0 -> 551 bytes
-rw-r--r--jni/ruby/ext/tk/sample/tkextlib/tkHTML/page2/image8bin0 -> 497 bytes
-rw-r--r--jni/ruby/ext/tk/sample/tkextlib/tkHTML/page2/image9bin0 -> 492 bytes
-rw-r--r--jni/ruby/ext/tk/sample/tkextlib/tkHTML/page2/index.html433
-rw-r--r--jni/ruby/ext/tk/sample/tkextlib/tkHTML/page3/image1bin0 -> 113 bytes
-rw-r--r--jni/ruby/ext/tk/sample/tkextlib/tkHTML/page3/image10bin0 -> 5088 bytes
-rw-r--r--jni/ruby/ext/tk/sample/tkextlib/tkHTML/page3/image11bin0 -> 4485 bytes
-rw-r--r--jni/ruby/ext/tk/sample/tkextlib/tkHTML/page3/image12bin0 -> 3579 bytes
-rw-r--r--jni/ruby/ext/tk/sample/tkextlib/tkHTML/page3/image13bin0 -> 5119 bytes
-rw-r--r--jni/ruby/ext/tk/sample/tkextlib/tkHTML/page3/image14bin0 -> 3603 bytes
-rw-r--r--jni/ruby/ext/tk/sample/tkextlib/tkHTML/page3/image2bin0 -> 74 bytes
-rw-r--r--jni/ruby/ext/tk/sample/tkextlib/tkHTML/page3/image3bin0 -> 681 bytes
-rw-r--r--jni/ruby/ext/tk/sample/tkextlib/tkHTML/page3/image4bin0 -> 3056 bytes
-rw-r--r--jni/ruby/ext/tk/sample/tkextlib/tkHTML/page3/image5bin0 -> 2297 bytes
-rw-r--r--jni/ruby/ext/tk/sample/tkextlib/tkHTML/page3/image6bin0 -> 79 bytes
-rw-r--r--jni/ruby/ext/tk/sample/tkextlib/tkHTML/page3/image7bin0 -> 1613 bytes
-rw-r--r--jni/ruby/ext/tk/sample/tkextlib/tkHTML/page3/image8bin0 -> 864 bytes
-rw-r--r--jni/ruby/ext/tk/sample/tkextlib/tkHTML/page3/image9bin0 -> 2379 bytes
-rw-r--r--jni/ruby/ext/tk/sample/tkextlib/tkHTML/page3/index.html2787
-rw-r--r--jni/ruby/ext/tk/sample/tkextlib/tkHTML/page4/image1bin0 -> 42 bytes
-rw-r--r--jni/ruby/ext/tk/sample/tkextlib/tkHTML/page4/image2bin0 -> 14343 bytes
-rw-r--r--jni/ruby/ext/tk/sample/tkextlib/tkHTML/page4/image3bin0 -> 17750 bytes
-rw-r--r--jni/ruby/ext/tk/sample/tkextlib/tkHTML/page4/image4bin0 -> 61 bytes
-rw-r--r--jni/ruby/ext/tk/sample/tkextlib/tkHTML/page4/image5bin0 -> 201 bytes
-rw-r--r--jni/ruby/ext/tk/sample/tkextlib/tkHTML/page4/image6bin0 -> 214 bytes
-rw-r--r--jni/ruby/ext/tk/sample/tkextlib/tkHTML/page4/image7bin0 -> 149 bytes
-rw-r--r--jni/ruby/ext/tk/sample/tkextlib/tkHTML/page4/image8bin0 -> 203 bytes
-rw-r--r--jni/ruby/ext/tk/sample/tkextlib/tkHTML/page4/image9bin0 -> 1504 bytes
-rw-r--r--jni/ruby/ext/tk/sample/tkextlib/tkHTML/page4/index.html768
-rw-r--r--jni/ruby/ext/tk/sample/tkextlib/tkHTML/ss.rb436
-rw-r--r--jni/ruby/ext/tk/sample/tkextlib/tkimg/demo.rb1478
-rw-r--r--jni/ruby/ext/tk/sample/tkextlib/tkimg/license_terms_of_Img_extension41
-rw-r--r--jni/ruby/ext/tk/sample/tkextlib/tkimg/readme.txt3
-rw-r--r--jni/ruby/ext/tk/sample/tkextlib/tktable/Orig_LICENSE.txt52
-rw-r--r--jni/ruby/ext/tk/sample/tkextlib/tktable/basic.rb60
-rw-r--r--jni/ruby/ext/tk/sample/tkextlib/tktable/buttons.rb76
-rw-r--r--jni/ruby/ext/tk/sample/tkextlib/tktable/command.rb89
-rw-r--r--jni/ruby/ext/tk/sample/tkextlib/tktable/debug.rb101
-rw-r--r--jni/ruby/ext/tk/sample/tkextlib/tktable/dynarows.rb99
-rw-r--r--jni/ruby/ext/tk/sample/tkextlib/tktable/maxsize.rb67
-rw-r--r--jni/ruby/ext/tk/sample/tkextlib/tktable/spreadsheet.rb137
-rw-r--r--jni/ruby/ext/tk/sample/tkextlib/tktable/tcllogo.gifbin0 -> 2341 bytes
-rw-r--r--jni/ruby/ext/tk/sample/tkextlib/tktable/valid.rb88
-rw-r--r--jni/ruby/ext/tk/sample/tkextlib/treectrl/bitmaps.rb76
-rw-r--r--jni/ruby/ext/tk/sample/tkextlib/treectrl/demo.rb1305
-rw-r--r--jni/ruby/ext/tk/sample/tkextlib/treectrl/explorer.rb430
-rw-r--r--jni/ruby/ext/tk/sample/tkextlib/treectrl/help.rb404
-rw-r--r--jni/ruby/ext/tk/sample/tkextlib/treectrl/imovie.rb130
-rw-r--r--jni/ruby/ext/tk/sample/tkextlib/treectrl/layout.rb159
-rw-r--r--jni/ruby/ext/tk/sample/tkextlib/treectrl/mailwasher.rb269
-rw-r--r--jni/ruby/ext/tk/sample/tkextlib/treectrl/outlook-folders.rb124
-rw-r--r--jni/ruby/ext/tk/sample/tkextlib/treectrl/outlook-newgroup.rb448
-rw-r--r--jni/ruby/ext/tk/sample/tkextlib/treectrl/pics/big-dll.gifbin0 -> 437 bytes
-rw-r--r--jni/ruby/ext/tk/sample/tkextlib/treectrl/pics/big-exe.gifbin0 -> 368 bytes
-rw-r--r--jni/ruby/ext/tk/sample/tkextlib/treectrl/pics/big-file.gifbin0 -> 466 bytes
-rw-r--r--jni/ruby/ext/tk/sample/tkextlib/treectrl/pics/big-folder.gifbin0 -> 459 bytes
-rw-r--r--jni/ruby/ext/tk/sample/tkextlib/treectrl/pics/big-txt.gifbin0 -> 392 bytes
-rw-r--r--jni/ruby/ext/tk/sample/tkextlib/treectrl/pics/checked.gifbin0 -> 78 bytes
-rw-r--r--jni/ruby/ext/tk/sample/tkextlib/treectrl/pics/file.gifbin0 -> 279 bytes
-rw-r--r--jni/ruby/ext/tk/sample/tkextlib/treectrl/pics/folder-closed.gifbin0 -> 111 bytes
-rw-r--r--jni/ruby/ext/tk/sample/tkextlib/treectrl/pics/folder-open.gifbin0 -> 120 bytes
-rw-r--r--jni/ruby/ext/tk/sample/tkextlib/treectrl/pics/help-book-closed.gifbin0 -> 115 bytes
-rw-r--r--jni/ruby/ext/tk/sample/tkextlib/treectrl/pics/help-book-open.gifbin0 -> 128 bytes
-rw-r--r--jni/ruby/ext/tk/sample/tkextlib/treectrl/pics/help-page.gifbin0 -> 132 bytes
-rw-r--r--jni/ruby/ext/tk/sample/tkextlib/treectrl/pics/imovie-01.gifbin0 -> 5406 bytes
-rw-r--r--jni/ruby/ext/tk/sample/tkextlib/treectrl/pics/imovie-02.gifbin0 -> 5912 bytes
-rw-r--r--jni/ruby/ext/tk/sample/tkextlib/treectrl/pics/imovie-03.gifbin0 -> 4696 bytes
-rw-r--r--jni/ruby/ext/tk/sample/tkextlib/treectrl/pics/imovie-04.gifbin0 -> 5783 bytes
-rw-r--r--jni/ruby/ext/tk/sample/tkextlib/treectrl/pics/imovie-05.gifbin0 -> 3238 bytes
-rw-r--r--jni/ruby/ext/tk/sample/tkextlib/treectrl/pics/imovie-06.gifbin0 -> 3509 bytes
-rw-r--r--jni/ruby/ext/tk/sample/tkextlib/treectrl/pics/imovie-07.gifbin0 -> 2091 bytes
-rw-r--r--jni/ruby/ext/tk/sample/tkextlib/treectrl/pics/internet-check-off.gifbin0 -> 70 bytes
-rw-r--r--jni/ruby/ext/tk/sample/tkextlib/treectrl/pics/internet-check-on.gifbin0 -> 76 bytes
-rw-r--r--jni/ruby/ext/tk/sample/tkextlib/treectrl/pics/internet-print.gifbin0 -> 124 bytes
-rw-r--r--jni/ruby/ext/tk/sample/tkextlib/treectrl/pics/internet-radio-off.gifbin0 -> 68 bytes
-rw-r--r--jni/ruby/ext/tk/sample/tkextlib/treectrl/pics/internet-radio-on.gifbin0 -> 71 bytes
-rw-r--r--jni/ruby/ext/tk/sample/tkextlib/treectrl/pics/internet-search.gifbin0 -> 114 bytes
-rw-r--r--jni/ruby/ext/tk/sample/tkextlib/treectrl/pics/internet-security.gifbin0 -> 108 bytes
-rw-r--r--jni/ruby/ext/tk/sample/tkextlib/treectrl/pics/mac-collapse.gifbin0 -> 275 bytes
-rw-r--r--jni/ruby/ext/tk/sample/tkextlib/treectrl/pics/mac-expand.gifbin0 -> 277 bytes
-rw-r--r--jni/ruby/ext/tk/sample/tkextlib/treectrl/pics/outlook-arrow.gifbin0 -> 73 bytes
-rw-r--r--jni/ruby/ext/tk/sample/tkextlib/treectrl/pics/outlook-clip.gifbin0 -> 73 bytes
-rw-r--r--jni/ruby/ext/tk/sample/tkextlib/treectrl/pics/outlook-deleted.gifbin0 -> 138 bytes
-rw-r--r--jni/ruby/ext/tk/sample/tkextlib/treectrl/pics/outlook-draft.gifbin0 -> 134 bytes
-rw-r--r--jni/ruby/ext/tk/sample/tkextlib/treectrl/pics/outlook-folder.gifbin0 -> 133 bytes
-rw-r--r--jni/ruby/ext/tk/sample/tkextlib/treectrl/pics/outlook-group.gifbin0 -> 144 bytes
-rw-r--r--jni/ruby/ext/tk/sample/tkextlib/treectrl/pics/outlook-inbox.gifbin0 -> 133 bytes
-rw-r--r--jni/ruby/ext/tk/sample/tkextlib/treectrl/pics/outlook-local.gifbin0 -> 146 bytes
-rw-r--r--jni/ruby/ext/tk/sample/tkextlib/treectrl/pics/outlook-main.gifbin0 -> 174 bytes
-rw-r--r--jni/ruby/ext/tk/sample/tkextlib/treectrl/pics/outlook-outbox.gifbin0 -> 136 bytes
-rw-r--r--jni/ruby/ext/tk/sample/tkextlib/treectrl/pics/outlook-read-2.gifbin0 -> 343 bytes
-rw-r--r--jni/ruby/ext/tk/sample/tkextlib/treectrl/pics/outlook-read.gifbin0 -> 304 bytes
-rw-r--r--jni/ruby/ext/tk/sample/tkextlib/treectrl/pics/outlook-sent.gifbin0 -> 132 bytes
-rw-r--r--jni/ruby/ext/tk/sample/tkextlib/treectrl/pics/outlook-server.gifbin0 -> 163 bytes
-rw-r--r--jni/ruby/ext/tk/sample/tkextlib/treectrl/pics/outlook-unread.gifbin0 -> 303 bytes
-rw-r--r--jni/ruby/ext/tk/sample/tkextlib/treectrl/pics/outlook-watch.gifbin0 -> 98 bytes
-rw-r--r--jni/ruby/ext/tk/sample/tkextlib/treectrl/pics/sky.gifbin0 -> 6454 bytes
-rw-r--r--jni/ruby/ext/tk/sample/tkextlib/treectrl/pics/small-dll.gifbin0 -> 311 bytes
-rw-r--r--jni/ruby/ext/tk/sample/tkextlib/treectrl/pics/small-exe.gifbin0 -> 115 bytes
-rw-r--r--jni/ruby/ext/tk/sample/tkextlib/treectrl/pics/small-file.gifbin0 -> 338 bytes
-rw-r--r--jni/ruby/ext/tk/sample/tkextlib/treectrl/pics/small-folder.gifbin0 -> 307 bytes
-rw-r--r--jni/ruby/ext/tk/sample/tkextlib/treectrl/pics/small-txt.gifbin0 -> 302 bytes
-rw-r--r--jni/ruby/ext/tk/sample/tkextlib/treectrl/pics/unchecked.gifbin0 -> 72 bytes
-rw-r--r--jni/ruby/ext/tk/sample/tkextlib/treectrl/random.rb508
-rw-r--r--jni/ruby/ext/tk/sample/tkextlib/treectrl/readme.txt2
-rw-r--r--jni/ruby/ext/tk/sample/tkextlib/treectrl/www-options.rb303
-rw-r--r--jni/ruby/ext/tk/sample/tkextlib/vu/Orig_LICENSE.txt51
-rw-r--r--jni/ruby/ext/tk/sample/tkextlib/vu/README.txt50
-rw-r--r--jni/ruby/ext/tk/sample/tkextlib/vu/canvItems.rb90
-rw-r--r--jni/ruby/ext/tk/sample/tkextlib/vu/canvSticker.rb82
-rw-r--r--jni/ruby/ext/tk/sample/tkextlib/vu/canvSticker2.rb101
-rw-r--r--jni/ruby/ext/tk/sample/tkextlib/vu/dial_demo.rb113
-rw-r--r--jni/ruby/ext/tk/sample/tkextlib/vu/m128_000.xbm174
-rw-r--r--jni/ruby/ext/tk/sample/tkextlib/vu/oscilloscope.rb68
-rw-r--r--jni/ruby/ext/tk/sample/tkextlib/vu/pie.rb56
-rw-r--r--jni/ruby/ext/tk/sample/tkextlib/vu/vu_demo.rb67
-rw-r--r--jni/ruby/ext/tk/sample/tkfrom.rb132
-rw-r--r--jni/ruby/ext/tk/sample/tkhello.rb10
-rw-r--r--jni/ruby/ext/tk/sample/tkline.rb47
-rw-r--r--jni/ruby/ext/tk/sample/tkmenubutton.rb135
-rw-r--r--jni/ruby/ext/tk/sample/tkmsgcat-load_rb.rb102
-rw-r--r--jni/ruby/ext/tk/sample/tkmsgcat-load_rb2.rb102
-rw-r--r--jni/ruby/ext/tk/sample/tkmsgcat-load_tk.rb118
-rw-r--r--jni/ruby/ext/tk/sample/tkmulticolumnlist.rb743
-rw-r--r--jni/ruby/ext/tk/sample/tkmultilistbox.rb654
-rw-r--r--jni/ruby/ext/tk/sample/tkmultilistframe.rb940
-rw-r--r--jni/ruby/ext/tk/sample/tkoptdb-safeTk.rb73
-rw-r--r--jni/ruby/ext/tk/sample/tkoptdb.rb106
-rw-r--r--jni/ruby/ext/tk/sample/tkrttimer.rb77
-rw-r--r--jni/ruby/ext/tk/sample/tksleep_sample.rb29
-rw-r--r--jni/ruby/ext/tk/sample/tktextframe.rb281
-rw-r--r--jni/ruby/ext/tk/sample/tktextio.rb1060
-rw-r--r--jni/ruby/ext/tk/sample/tktimer.rb50
-rw-r--r--jni/ruby/ext/tk/sample/tktimer2.rb47
-rw-r--r--jni/ruby/ext/tk/sample/tktimer3.rb59
-rw-r--r--jni/ruby/ext/tk/sample/tktree.rb103
-rw-r--r--jni/ruby/ext/tk/sample/tktree.tcl305
-rw-r--r--jni/ruby/ext/tk/sample/ttk_wrapper.rb154
-rw-r--r--jni/ruby/ext/tk/stubs.c592
-rw-r--r--jni/ruby/ext/tk/stubs.h33
-rw-r--r--jni/ruby/ext/tk/tcltklib.c11130
-rw-r--r--jni/ruby/ext/tk/tkutil/Makefile150
-rw-r--r--jni/ruby/ext/tk/tkutil/depend1
-rw-r--r--jni/ruby/ext/tk/tkutil/extconf.rb11
-rw-r--r--jni/ruby/ext/tk/tkutil/tkutil.c1878
-rw-r--r--jni/ruby/ext/win32/Makefile150
-rw-r--r--jni/ruby/ext/win32/extconf.rb3
-rw-r--r--jni/ruby/ext/win32/lib/Win32API.rb37
-rw-r--r--jni/ruby/ext/win32/lib/win32/importer.rb8
-rw-r--r--jni/ruby/ext/win32/lib/win32/registry.rb909
-rw-r--r--jni/ruby/ext/win32/lib/win32/resolv.rb378
-rw-r--r--jni/ruby/ext/win32/lib/win32/sspi.rb330
-rw-r--r--jni/ruby/ext/win32ole/Makefile150
-rw-r--r--jni/ruby/ext/win32ole/depend12
-rw-r--r--jni/ruby/ext/win32ole/extconf.rb44
-rw-r--r--jni/ruby/ext/win32ole/lib/win32ole/property.rb16
-rw-r--r--jni/ruby/ext/win32ole/sample/excel1.rb36
-rw-r--r--jni/ruby/ext/win32ole/sample/excel2.rb30
-rw-r--r--jni/ruby/ext/win32ole/sample/excel3.rb20
-rw-r--r--jni/ruby/ext/win32ole/sample/ie.rb11
-rw-r--r--jni/ruby/ext/win32ole/sample/ieconst.rb32
-rw-r--r--jni/ruby/ext/win32ole/sample/ienavi.rb40
-rw-r--r--jni/ruby/ext/win32ole/sample/ienavi2.rb40
-rw-r--r--jni/ruby/ext/win32ole/sample/oledirs.rb23
-rw-r--r--jni/ruby/ext/win32ole/sample/olegen.rb347
-rw-r--r--jni/ruby/ext/win32ole/sample/xml.rb7306
-rw-r--r--jni/ruby/ext/win32ole/win32ole.c4073
-rw-r--r--jni/ruby/ext/win32ole/win32ole.h155
-rw-r--r--jni/ruby/ext/win32ole/win32ole_error.c83
-rw-r--r--jni/ruby/ext/win32ole/win32ole_error.h8
-rw-r--r--jni/ruby/ext/win32ole/win32ole_event.c1275
-rw-r--r--jni/ruby/ext/win32ole/win32ole_event.h6
-rw-r--r--jni/ruby/ext/win32ole/win32ole_method.c950
-rw-r--r--jni/ruby/ext/win32ole/win32ole_method.h16
-rw-r--r--jni/ruby/ext/win32ole/win32ole_param.c438
-rw-r--r--jni/ruby/ext/win32ole/win32ole_param.h8
-rw-r--r--jni/ruby/ext/win32ole/win32ole_record.c604
-rw-r--r--jni/ruby/ext/win32ole/win32ole_record.h10
-rw-r--r--jni/ruby/ext/win32ole/win32ole_type.c915
-rw-r--r--jni/ruby/ext/win32ole/win32ole_type.h8
-rw-r--r--jni/ruby/ext/win32ole/win32ole_typelib.c846
-rw-r--r--jni/ruby/ext/win32ole/win32ole_typelib.h11
-rw-r--r--jni/ruby/ext/win32ole/win32ole_variable.c380
-rw-r--r--jni/ruby/ext/win32ole/win32ole_variable.h8
-rw-r--r--jni/ruby/ext/win32ole/win32ole_variant.c734
-rw-r--r--jni/ruby/ext/win32ole/win32ole_variant.h9
-rw-r--r--jni/ruby/ext/win32ole/win32ole_variant_m.c149
-rw-r--r--jni/ruby/ext/win32ole/win32ole_variant_m.h7
-rw-r--r--jni/ruby/ext/zlib/Makefile274
-rw-r--r--jni/ruby/ext/zlib/depend5
-rw-r--r--jni/ruby/ext/zlib/extconf.h7
-rw-r--r--jni/ruby/ext/zlib/extconf.rb64
-rw-r--r--jni/ruby/ext/zlib/zlib.c4659
2078 files changed, 502231 insertions, 0 deletions
diff --git a/jni/ruby/ext/-test-/array/resize/Makefile b/jni/ruby/ext/-test-/array/resize/Makefile
new file mode 100644
index 0000000..c92f0ef
--- /dev/null
+++ b/jni/ruby/ext/-test-/array/resize/Makefile
@@ -0,0 +1,267 @@
+
+SHELL = /bin/sh
+
+# V=0 quiet, V=1 verbose. other values don't work.
+V = 0
+Q1 = $(V:1=)
+Q = $(Q1:0=@)
+ECHO1 = $(V:1=@:)
+ECHO = $(ECHO1:0=@echo)
+NULLCMD = :
+
+#### Start of system configuration section. ####
+top_srcdir = $(topdir)/.
+srcdir = $(top_srcdir)/ext/-test-/array/resize
+topdir = ../../../..
+hdrdir = $(top_srcdir)/include
+arch_hdrdir = $(extout)/include/$(arch)
+PATH_SEPARATOR = :
+VPATH = $(srcdir):$(arch_hdrdir)/ruby:$(hdrdir)/ruby
+RUBYLIB =
+RUBYOPT = -
+prefix = $(DESTDIR)/usr/local
+rubysitearchprefix = $(rubylibprefix)/$(sitearch)
+rubyarchprefix = $(rubylibprefix)/$(arch)
+rubylibprefix = $(libdir)/$(RUBY_BASE_NAME)
+exec_prefix = $(prefix)
+vendorarchhdrdir = $(vendorhdrdir)/$(sitearch)
+sitearchhdrdir = $(sitehdrdir)/$(sitearch)
+rubyarchhdrdir = $(rubyhdrdir)/$(arch)
+vendorhdrdir = $(rubyhdrdir)/vendor_ruby
+sitehdrdir = $(rubyhdrdir)/site_ruby
+rubyhdrdir = $(includedir)/$(RUBY_VERSION_NAME)
+vendorarchdir = $(vendorlibdir)/$(sitearch)
+vendorlibdir = $(vendordir)/$(ruby_version)
+vendordir = $(rubylibprefix)/vendor_ruby
+sitearchdir = $(sitelibdir)/$(sitearch)
+sitelibdir = $(sitedir)/$(ruby_version)
+sitedir = $(rubylibprefix)/site_ruby
+rubyarchdir = $(rubylibdir)/$(arch)
+rubylibdir = $(rubylibprefix)/$(ruby_version)
+sitearchincludedir = $(includedir)/$(sitearch)
+archincludedir = $(includedir)/$(arch)
+sitearchlibdir = $(libdir)/$(sitearch)
+archlibdir = $(libdir)/$(arch)
+ridir = $(datarootdir)/$(RI_BASE_NAME)
+mandir = $(datarootdir)/man
+localedir = $(datarootdir)/locale
+libdir = $(exec_prefix)/lib
+psdir = $(docdir)
+pdfdir = $(docdir)
+dvidir = $(docdir)
+htmldir = $(docdir)
+infodir = $(datarootdir)/info
+docdir = $(datarootdir)/doc/$(PACKAGE)
+oldincludedir = $(DESTDIR)/usr/include
+includedir = $(prefix)/include
+localstatedir = $(prefix)/var
+sharedstatedir = $(prefix)/com
+sysconfdir = $(prefix)/etc
+datadir = $(datarootdir)
+datarootdir = $(prefix)/share
+libexecdir = $(exec_prefix)/libexec
+sbindir = $(exec_prefix)/sbin
+bindir = $(exec_prefix)/bin
+archdir = $(rubyarchdir)
+
+
+CC = gcc
+CXX = g++
+LIBRUBY = $(LIBRUBY_SO)
+LIBRUBY_A = lib$(RUBY_SO_NAME)-static.a
+LIBRUBYARG_SHARED = -Wl,-R$(libdir) -L$(libdir) -l$(RUBY_SO_NAME)
+LIBRUBYARG_STATIC = -Wl,-R$(libdir) -L$(libdir) -l$(RUBY_SO_NAME)-static
+empty =
+OUTFLAG = -o $(empty)
+COUTFLAG = -o $(empty)
+
+RUBY_EXTCONF_H = extconf.h
+cflags = $(optflags) $(debugflags) $(warnflags)
+optflags = -O3 -fno-fast-math
+debugflags = -ggdb3
+warnflags = -Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wunused-variable -Wpointer-arith -Wwrite-strings -Wdeclaration-after-statement -Wimplicit-function-declaration -Wdeprecated-declarations -Wno-packed-bitfield-compat
+CCDLFLAGS = -fPIC
+CFLAGS = $(CCDLFLAGS) $(cflags) -fPIC $(ARCH_FLAG)
+INCFLAGS = -I. -I$(arch_hdrdir) -I$(hdrdir) -I$(srcdir)
+DEFS =
+CPPFLAGS = -DRUBY_EXTCONF_H=\"$(RUBY_EXTCONF_H)\" $(DEFS) $(cppflags)
+CXXFLAGS = $(CCDLFLAGS) $(cxxflags) $(ARCH_FLAG)
+ldflags = -L. -fstack-protector -rdynamic -Wl,-export-dynamic
+dldflags =
+ARCH_FLAG =
+DLDFLAGS = $(ldflags) $(dldflags) $(ARCH_FLAG)
+LDSHARED = $(CC) -shared
+LDSHAREDXX = $(CXX) -shared
+AR = ar
+EXEEXT =
+
+RUBY_INSTALL_NAME = $(RUBY_BASE_NAME)
+RUBY_SO_NAME = ruby
+RUBYW_INSTALL_NAME =
+RUBY_VERSION_NAME = $(RUBY_BASE_NAME)-$(ruby_version)
+RUBYW_BASE_NAME = rubyw
+RUBY_BASE_NAME = ruby
+
+arch = x86_64-linux
+sitearch = $(arch)
+ruby_version = 2.2.0
+ruby = $(topdir)/miniruby -I'$(topdir)' -I'$(top_srcdir)/lib' -I'$(extout)/$(arch)' -I'$(extout)/common'
+RUBY = $(ruby)
+ruby_headers = $(hdrdir)/ruby.h $(hdrdir)/ruby/ruby.h $(hdrdir)/ruby/defines.h $(hdrdir)/ruby/missing.h $(hdrdir)/ruby/intern.h $(hdrdir)/ruby/st.h $(hdrdir)/ruby/subst.h $(arch_hdrdir)/ruby/config.h $(RUBY_EXTCONF_H)
+
+RM = rm -f
+RM_RF = $(RUBY) -run -e rm -- -rf
+RMDIRS = rmdir --ignore-fail-on-non-empty -p
+MAKEDIRS = /bin/mkdir -p
+INSTALL = /usr/bin/install -c
+INSTALL_PROG = $(INSTALL) -m 0755
+INSTALL_DATA = $(INSTALL) -m 644
+COPY = cp
+TOUCH = exit >
+
+#### End of system configuration section. ####
+
+preload =
+
+libpath = . $(topdir)
+LIBPATH = -L. -L$(topdir)
+DEFFILE =
+
+CLEANFILES = mkmf.log
+DISTCLEANFILES =
+DISTCLEANDIRS =
+
+extout = $(topdir)/.ext
+extout_prefix = $(extout)$(target_prefix)/
+target_prefix = /-test-/array
+LOCAL_LIBS =
+LIBS = $(LIBRUBYARG_SHARED) -lpthread -lgmp -ldl -lcrypt -lm -lc
+ORIG_SRCS = resize.c
+SRCS = $(ORIG_SRCS)
+OBJS = resize.o
+HDRS = $(srcdir)/extconf.h
+TARGET = resize
+TARGET_NAME = resize
+TARGET_ENTRY = Init_$(TARGET_NAME)
+DLLIB = $(TARGET).so
+EXTSTATIC =
+STATIC_LIB = $(TARGET).a
+
+TIMESTAMP_DIR = $(extout)/.timestamp
+BINDIR = $(extout)/bin
+RUBYCOMMONDIR = $(extout)/common
+RUBYLIBDIR = $(RUBYCOMMONDIR)$(target_prefix)
+RUBYARCHDIR = $(extout)/$(arch)$(target_prefix)
+HDRDIR = $(extout)/include/ruby$(target_prefix)
+ARCHHDRDIR = $(extout)/include/$(arch)/ruby$(target_prefix)
+
+TARGET_SO = $(RUBYARCHDIR)/$(DLLIB)
+CLEANLIBS = $(RUBYARCHDIR)/$(TARGET).so
+CLEANOBJS = *.o *.bak
+
+all: install
+static: all
+.PHONY: all install static install-so install-rb
+.PHONY: clean clean-so clean-static clean-rb
+
+clean-static::
+clean-rb-default::
+clean-rb::
+clean-so::
+clean: clean-so clean-static clean-rb-default clean-rb
+ -$(Q)$(RM) $(CLEANLIBS) $(CLEANOBJS) $(CLEANFILES) .*.time
+
+distclean-rb-default::
+distclean-rb::
+distclean-so::
+distclean-static::
+distclean: clean distclean-so distclean-static distclean-rb-default distclean-rb
+ -$(Q)$(RM) Makefile $(RUBY_EXTCONF_H) conftest.* mkmf.log
+ -$(Q)$(RM) core ruby$(EXEEXT) *~ $(DISTCLEANFILES)
+ -$(Q)$(RMDIRS) $(DISTCLEANDIRS) 2> /dev/null || true
+
+realclean: distclean
+install: install-so install-rb
+
+install-so: $(RUBYARCHDIR)/$(DLLIB)
+clean-so::
+ -$(Q)$(RM) $(RUBYARCHDIR)/$(DLLIB)
+ -$(Q)$(RMDIRS) $(RUBYARCHDIR) 2> /dev/null || true
+clean-static::
+ -$(Q)$(RM) $(STATIC_LIB)
+install-rb: pre-install-rb install-rb-default
+install-rb-default: pre-install-rb-default
+pre-install-rb: Makefile
+pre-install-rb-default: Makefile
+pre-install-rb-default:
+ @$(NULLCMD)
+$(TIMESTAMP_DIR)/.RUBYARCHDIR.-.-test-.-.array.time:
+ $(Q) $(MAKEDIRS) $(@D) $(RUBYARCHDIR)
+ $(Q) $(TOUCH) $@
+
+site-install: site-install-so site-install-rb
+site-install-so: install-so
+site-install-rb: install-rb
+
+.SUFFIXES: .c .m .cc .mm .cxx .cpp .o .S
+
+.cc.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<
+
+.cc.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -S $<
+
+.mm.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<
+
+.mm.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -S $<
+
+.cxx.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<
+
+.cxx.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -S $<
+
+.cpp.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<
+
+.cpp.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -S $<
+
+.c.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -c $<
+
+.c.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -S $<
+
+.m.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -c $<
+
+.m.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -S $<
+
+$(RUBYARCHDIR)/$(DLLIB): $(OBJS) Makefile $(TIMESTAMP_DIR)/.RUBYARCHDIR.-.-test-.-.array.time
+ $(ECHO) linking shared-object -test-/array/$(DLLIB)
+ -$(Q)$(RM) $(@)
+ $(Q) $(LDSHARED) -o $@ $(OBJS) $(LIBPATH) $(DLDFLAGS) $(LOCAL_LIBS) $(LIBS)
+
+$(STATIC_LIB): $(OBJS)
+ -$(Q)$(RM) $(@)
+ $(ECHO) linking static-library $(@)
+ $(Q) $(AR) cru $@ $(OBJS)
+ -$(Q)ranlib $(@) 2> /dev/null || true
+
+$(OBJS): $(HDRS) $(ruby_headers)
diff --git a/jni/ruby/ext/-test-/array/resize/extconf.h b/jni/ruby/ext/-test-/array/resize/extconf.h
new file mode 100644
index 0000000..cda0cc8
--- /dev/null
+++ b/jni/ruby/ext/-test-/array/resize/extconf.h
@@ -0,0 +1,3 @@
+#ifndef EXTCONF_H
+#define EXTCONF_H
+#endif
diff --git a/jni/ruby/ext/-test-/array/resize/extconf.rb b/jni/ruby/ext/-test-/array/resize/extconf.rb
new file mode 100644
index 0000000..6500a87
--- /dev/null
+++ b/jni/ruby/ext/-test-/array/resize/extconf.rb
@@ -0,0 +1 @@
+create_makefile("-test-/array/resize")
diff --git a/jni/ruby/ext/-test-/array/resize/resize.c b/jni/ruby/ext/-test-/array/resize/resize.c
new file mode 100644
index 0000000..08bcee3
--- /dev/null
+++ b/jni/ruby/ext/-test-/array/resize/resize.c
@@ -0,0 +1,14 @@
+#include "ruby/ruby.h"
+
+static VALUE
+ary_resize(VALUE ary, VALUE len)
+{
+ rb_ary_resize(ary, NUM2LONG(len));
+ return ary;
+}
+
+void
+Init_resize(void)
+{
+ rb_define_method(rb_cArray, "__resize__", ary_resize, 1);
+}
diff --git a/jni/ruby/ext/-test-/bignum/Makefile b/jni/ruby/ext/-test-/bignum/Makefile
new file mode 100644
index 0000000..ba08424
--- /dev/null
+++ b/jni/ruby/ext/-test-/bignum/Makefile
@@ -0,0 +1,371 @@
+
+SHELL = /bin/sh
+
+# V=0 quiet, V=1 verbose. other values don't work.
+V = 0
+Q1 = $(V:1=)
+Q = $(Q1:0=@)
+ECHO1 = $(V:1=@:)
+ECHO = $(ECHO1:0=@echo)
+NULLCMD = :
+
+#### Start of system configuration section. ####
+top_srcdir = $(topdir)/.
+srcdir = $(top_srcdir)/ext/-test-/bignum
+topdir = ../../..
+hdrdir = $(top_srcdir)/include
+arch_hdrdir = $(extout)/include/$(arch)
+PATH_SEPARATOR = :
+VPATH = $(srcdir):$(arch_hdrdir)/ruby:$(hdrdir)/ruby
+RUBYLIB =
+RUBYOPT = -
+prefix = $(DESTDIR)/usr/local
+rubysitearchprefix = $(rubylibprefix)/$(sitearch)
+rubyarchprefix = $(rubylibprefix)/$(arch)
+rubylibprefix = $(libdir)/$(RUBY_BASE_NAME)
+exec_prefix = $(prefix)
+vendorarchhdrdir = $(vendorhdrdir)/$(sitearch)
+sitearchhdrdir = $(sitehdrdir)/$(sitearch)
+rubyarchhdrdir = $(rubyhdrdir)/$(arch)
+vendorhdrdir = $(rubyhdrdir)/vendor_ruby
+sitehdrdir = $(rubyhdrdir)/site_ruby
+rubyhdrdir = $(includedir)/$(RUBY_VERSION_NAME)
+vendorarchdir = $(vendorlibdir)/$(sitearch)
+vendorlibdir = $(vendordir)/$(ruby_version)
+vendordir = $(rubylibprefix)/vendor_ruby
+sitearchdir = $(sitelibdir)/$(sitearch)
+sitelibdir = $(sitedir)/$(ruby_version)
+sitedir = $(rubylibprefix)/site_ruby
+rubyarchdir = $(rubylibdir)/$(arch)
+rubylibdir = $(rubylibprefix)/$(ruby_version)
+sitearchincludedir = $(includedir)/$(sitearch)
+archincludedir = $(includedir)/$(arch)
+sitearchlibdir = $(libdir)/$(sitearch)
+archlibdir = $(libdir)/$(arch)
+ridir = $(datarootdir)/$(RI_BASE_NAME)
+mandir = $(datarootdir)/man
+localedir = $(datarootdir)/locale
+libdir = $(exec_prefix)/lib
+psdir = $(docdir)
+pdfdir = $(docdir)
+dvidir = $(docdir)
+htmldir = $(docdir)
+infodir = $(datarootdir)/info
+docdir = $(datarootdir)/doc/$(PACKAGE)
+oldincludedir = $(DESTDIR)/usr/include
+includedir = $(prefix)/include
+localstatedir = $(prefix)/var
+sharedstatedir = $(prefix)/com
+sysconfdir = $(prefix)/etc
+datadir = $(datarootdir)
+datarootdir = $(prefix)/share
+libexecdir = $(exec_prefix)/libexec
+sbindir = $(exec_prefix)/sbin
+bindir = $(exec_prefix)/bin
+archdir = $(rubyarchdir)
+
+
+CC = gcc
+CXX = g++
+LIBRUBY = $(LIBRUBY_SO)
+LIBRUBY_A = lib$(RUBY_SO_NAME)-static.a
+LIBRUBYARG_SHARED = -Wl,-R$(libdir) -L$(libdir) -l$(RUBY_SO_NAME)
+LIBRUBYARG_STATIC = -Wl,-R$(libdir) -L$(libdir) -l$(RUBY_SO_NAME)-static
+empty =
+OUTFLAG = -o $(empty)
+COUTFLAG = -o $(empty)
+
+RUBY_EXTCONF_H = extconf.h
+cflags = $(optflags) $(debugflags) $(warnflags)
+optflags = -O3 -fno-fast-math
+debugflags = -ggdb3
+warnflags = -Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wunused-variable -Wpointer-arith -Wwrite-strings -Wdeclaration-after-statement -Wimplicit-function-declaration -Wdeprecated-declarations -Wno-packed-bitfield-compat
+CCDLFLAGS = -fPIC
+CFLAGS = $(CCDLFLAGS) $(cflags) -fPIC $(ARCH_FLAG)
+INCFLAGS = -I. -I$(arch_hdrdir) -I$(hdrdir) -I$(srcdir) -I$(topdir) -I$(top_srcdir)
+DEFS =
+CPPFLAGS = -DRUBY_EXTCONF_H=\"$(RUBY_EXTCONF_H)\" $(DEFS) $(cppflags)
+CXXFLAGS = $(CCDLFLAGS) $(cxxflags) $(ARCH_FLAG)
+ldflags = -L. -fstack-protector -rdynamic -Wl,-export-dynamic
+dldflags =
+ARCH_FLAG =
+DLDFLAGS = $(ldflags) $(dldflags) $(ARCH_FLAG)
+LDSHARED = $(CC) -shared
+LDSHAREDXX = $(CXX) -shared
+AR = ar
+EXEEXT =
+
+RUBY_INSTALL_NAME = $(RUBY_BASE_NAME)
+RUBY_SO_NAME = ruby
+RUBYW_INSTALL_NAME =
+RUBY_VERSION_NAME = $(RUBY_BASE_NAME)-$(ruby_version)
+RUBYW_BASE_NAME = rubyw
+RUBY_BASE_NAME = ruby
+
+arch = x86_64-linux
+sitearch = $(arch)
+ruby_version = 2.2.0
+ruby = $(topdir)/miniruby -I'$(topdir)' -I'$(top_srcdir)/lib' -I'$(extout)/$(arch)' -I'$(extout)/common'
+RUBY = $(ruby)
+ruby_headers = $(hdrdir)/ruby.h $(hdrdir)/ruby/ruby.h $(hdrdir)/ruby/defines.h $(hdrdir)/ruby/missing.h $(hdrdir)/ruby/intern.h $(hdrdir)/ruby/st.h $(hdrdir)/ruby/subst.h $(arch_hdrdir)/ruby/config.h $(RUBY_EXTCONF_H)
+
+RM = rm -f
+RM_RF = $(RUBY) -run -e rm -- -rf
+RMDIRS = rmdir --ignore-fail-on-non-empty -p
+MAKEDIRS = /bin/mkdir -p
+INSTALL = /usr/bin/install -c
+INSTALL_PROG = $(INSTALL) -m 0755
+INSTALL_DATA = $(INSTALL) -m 644
+COPY = cp
+TOUCH = exit >
+
+#### End of system configuration section. ####
+
+preload =
+
+libpath = . $(topdir)
+LIBPATH = -L. -L$(topdir)
+DEFFILE =
+
+CLEANFILES = mkmf.log
+DISTCLEANFILES =
+DISTCLEANDIRS =
+
+extout = $(topdir)/.ext
+extout_prefix = $(extout)$(target_prefix)/
+target_prefix = /-test-
+LOCAL_LIBS =
+LIBS = $(LIBRUBYARG_SHARED) -lpthread -lgmp -ldl -lcrypt -lm -lc
+ORIG_SRCS = bigzero.c mul.c init.c str2big.c big2str.c div.c intpack.c
+SRCS = $(ORIG_SRCS)
+OBJS = bigzero.o mul.o init.o str2big.o big2str.o div.o intpack.o
+HDRS = $(srcdir)/extconf.h
+TARGET = bignum
+TARGET_NAME = bignum
+TARGET_ENTRY = Init_$(TARGET_NAME)
+DLLIB = $(TARGET).so
+EXTSTATIC =
+STATIC_LIB = $(TARGET).a
+
+TIMESTAMP_DIR = $(extout)/.timestamp
+BINDIR = $(extout)/bin
+RUBYCOMMONDIR = $(extout)/common
+RUBYLIBDIR = $(RUBYCOMMONDIR)$(target_prefix)
+RUBYARCHDIR = $(extout)/$(arch)$(target_prefix)
+HDRDIR = $(extout)/include/ruby$(target_prefix)
+ARCHHDRDIR = $(extout)/include/$(arch)/ruby$(target_prefix)
+
+TARGET_SO = $(RUBYARCHDIR)/$(DLLIB)
+CLEANLIBS = $(RUBYARCHDIR)/$(TARGET).so
+CLEANOBJS = *.o *.bak
+
+all: install
+static: all
+.PHONY: all install static install-so install-rb
+.PHONY: clean clean-so clean-static clean-rb
+
+clean-static::
+clean-rb-default::
+clean-rb::
+clean-so::
+clean: clean-so clean-static clean-rb-default clean-rb
+ -$(Q)$(RM) $(CLEANLIBS) $(CLEANOBJS) $(CLEANFILES) .*.time
+
+distclean-rb-default::
+distclean-rb::
+distclean-so::
+distclean-static::
+distclean: clean distclean-so distclean-static distclean-rb-default distclean-rb
+ -$(Q)$(RM) Makefile $(RUBY_EXTCONF_H) conftest.* mkmf.log
+ -$(Q)$(RM) core ruby$(EXEEXT) *~ $(DISTCLEANFILES)
+ -$(Q)$(RMDIRS) $(DISTCLEANDIRS) 2> /dev/null || true
+
+realclean: distclean
+install: install-so install-rb
+
+install-so: $(RUBYARCHDIR)/$(DLLIB)
+clean-so::
+ -$(Q)$(RM) $(RUBYARCHDIR)/$(DLLIB)
+ -$(Q)$(RMDIRS) $(RUBYARCHDIR) 2> /dev/null || true
+clean-static::
+ -$(Q)$(RM) $(STATIC_LIB)
+install-rb: pre-install-rb install-rb-default
+install-rb-default: pre-install-rb-default
+pre-install-rb: Makefile
+pre-install-rb-default: Makefile
+pre-install-rb-default:
+ @$(NULLCMD)
+$(TIMESTAMP_DIR)/.RUBYARCHDIR.-.-test-.time:
+ $(Q) $(MAKEDIRS) $(@D) $(RUBYARCHDIR)
+ $(Q) $(TOUCH) $@
+
+site-install: site-install-so site-install-rb
+site-install-so: install-so
+site-install-rb: install-rb
+
+.SUFFIXES: .c .m .cc .mm .cxx .cpp .o .S
+
+.cc.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<
+
+.cc.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -S $<
+
+.mm.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<
+
+.mm.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -S $<
+
+.cxx.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<
+
+.cxx.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -S $<
+
+.cpp.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<
+
+.cpp.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -S $<
+
+.c.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -c $<
+
+.c.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -S $<
+
+.m.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -c $<
+
+.m.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -S $<
+
+$(RUBYARCHDIR)/$(DLLIB): $(OBJS) Makefile $(TIMESTAMP_DIR)/.RUBYARCHDIR.-.-test-.time
+ $(ECHO) linking shared-object -test-/$(DLLIB)
+ -$(Q)$(RM) $(@)
+ $(Q) $(LDSHARED) -o $@ $(OBJS) $(LIBPATH) $(DLDFLAGS) $(LOCAL_LIBS) $(LIBS)
+
+$(STATIC_LIB): $(OBJS)
+ -$(Q)$(RM) $(@)
+ $(ECHO) linking static-library $(@)
+ $(Q) $(AR) cru $@ $(OBJS)
+ -$(Q)ranlib $(@) 2> /dev/null || true
+
+###
+$(OBJS): $(RUBY_EXTCONF_H)
+
+big2str.o: big2str.c
+div.o: div.c
+intpack.o: intpack.c
+mul.o: mul.c
+str2big.o: str2big.c
+
+# AUTOGENERATED DEPENDENCIES START
+big2str.o: $(RUBY_EXTCONF_H)
+big2str.o: $(arch_hdrdir)/ruby/config.h
+big2str.o: $(hdrdir)/ruby/defines.h
+big2str.o: $(hdrdir)/ruby/encoding.h
+big2str.o: $(hdrdir)/ruby/intern.h
+big2str.o: $(hdrdir)/ruby/io.h
+big2str.o: $(hdrdir)/ruby/missing.h
+big2str.o: $(hdrdir)/ruby/oniguruma.h
+big2str.o: $(hdrdir)/ruby/ruby.h
+big2str.o: $(hdrdir)/ruby/st.h
+big2str.o: $(hdrdir)/ruby/subst.h
+big2str.o: $(top_srcdir)/include/ruby.h
+big2str.o: $(top_srcdir)/internal.h
+big2str.o: big2str.c
+bigzero.o: $(RUBY_EXTCONF_H)
+bigzero.o: $(arch_hdrdir)/ruby/config.h
+bigzero.o: $(hdrdir)/ruby/defines.h
+bigzero.o: $(hdrdir)/ruby/encoding.h
+bigzero.o: $(hdrdir)/ruby/intern.h
+bigzero.o: $(hdrdir)/ruby/io.h
+bigzero.o: $(hdrdir)/ruby/missing.h
+bigzero.o: $(hdrdir)/ruby/oniguruma.h
+bigzero.o: $(hdrdir)/ruby/ruby.h
+bigzero.o: $(hdrdir)/ruby/st.h
+bigzero.o: $(hdrdir)/ruby/subst.h
+bigzero.o: $(top_srcdir)/include/ruby.h
+bigzero.o: $(top_srcdir)/internal.h
+bigzero.o: bigzero.c
+div.o: $(RUBY_EXTCONF_H)
+div.o: $(arch_hdrdir)/ruby/config.h
+div.o: $(hdrdir)/ruby/defines.h
+div.o: $(hdrdir)/ruby/encoding.h
+div.o: $(hdrdir)/ruby/intern.h
+div.o: $(hdrdir)/ruby/io.h
+div.o: $(hdrdir)/ruby/missing.h
+div.o: $(hdrdir)/ruby/oniguruma.h
+div.o: $(hdrdir)/ruby/ruby.h
+div.o: $(hdrdir)/ruby/st.h
+div.o: $(hdrdir)/ruby/subst.h
+div.o: $(top_srcdir)/include/ruby.h
+div.o: $(top_srcdir)/internal.h
+div.o: div.c
+init.o: $(RUBY_EXTCONF_H)
+init.o: $(arch_hdrdir)/ruby/config.h
+init.o: $(hdrdir)/ruby/defines.h
+init.o: $(hdrdir)/ruby/intern.h
+init.o: $(hdrdir)/ruby/missing.h
+init.o: $(hdrdir)/ruby/ruby.h
+init.o: $(hdrdir)/ruby/st.h
+init.o: $(hdrdir)/ruby/subst.h
+init.o: $(top_srcdir)/include/ruby.h
+init.o: init.c
+intpack.o: $(RUBY_EXTCONF_H)
+intpack.o: $(arch_hdrdir)/ruby/config.h
+intpack.o: $(hdrdir)/ruby/defines.h
+intpack.o: $(hdrdir)/ruby/encoding.h
+intpack.o: $(hdrdir)/ruby/intern.h
+intpack.o: $(hdrdir)/ruby/io.h
+intpack.o: $(hdrdir)/ruby/missing.h
+intpack.o: $(hdrdir)/ruby/oniguruma.h
+intpack.o: $(hdrdir)/ruby/ruby.h
+intpack.o: $(hdrdir)/ruby/st.h
+intpack.o: $(hdrdir)/ruby/subst.h
+intpack.o: $(top_srcdir)/include/ruby.h
+intpack.o: $(top_srcdir)/internal.h
+intpack.o: intpack.c
+mul.o: $(RUBY_EXTCONF_H)
+mul.o: $(arch_hdrdir)/ruby/config.h
+mul.o: $(hdrdir)/ruby/defines.h
+mul.o: $(hdrdir)/ruby/encoding.h
+mul.o: $(hdrdir)/ruby/intern.h
+mul.o: $(hdrdir)/ruby/io.h
+mul.o: $(hdrdir)/ruby/missing.h
+mul.o: $(hdrdir)/ruby/oniguruma.h
+mul.o: $(hdrdir)/ruby/ruby.h
+mul.o: $(hdrdir)/ruby/st.h
+mul.o: $(hdrdir)/ruby/subst.h
+mul.o: $(top_srcdir)/include/ruby.h
+mul.o: $(top_srcdir)/internal.h
+mul.o: mul.c
+str2big.o: $(RUBY_EXTCONF_H)
+str2big.o: $(arch_hdrdir)/ruby/config.h
+str2big.o: $(hdrdir)/ruby/defines.h
+str2big.o: $(hdrdir)/ruby/encoding.h
+str2big.o: $(hdrdir)/ruby/intern.h
+str2big.o: $(hdrdir)/ruby/io.h
+str2big.o: $(hdrdir)/ruby/missing.h
+str2big.o: $(hdrdir)/ruby/oniguruma.h
+str2big.o: $(hdrdir)/ruby/ruby.h
+str2big.o: $(hdrdir)/ruby/st.h
+str2big.o: $(hdrdir)/ruby/subst.h
+str2big.o: $(top_srcdir)/include/ruby.h
+str2big.o: $(top_srcdir)/internal.h
+str2big.o: str2big.c
+# AUTOGENERATED DEPENDENCIES END
diff --git a/jni/ruby/ext/-test-/bignum/big2str.c b/jni/ruby/ext/-test-/bignum/big2str.c
new file mode 100644
index 0000000..ec4bde2
--- /dev/null
+++ b/jni/ruby/ext/-test-/bignum/big2str.c
@@ -0,0 +1,53 @@
+#include "internal.h"
+
+static VALUE
+big(VALUE x)
+{
+ if (FIXNUM_P(x))
+ return rb_int2big(FIX2LONG(x));
+ if (RB_TYPE_P(x, T_BIGNUM))
+ return x;
+ rb_raise(rb_eTypeError, "can't convert %s to Bignum",
+ rb_obj_classname(x));
+}
+
+static VALUE
+big2str_generic(VALUE x, VALUE vbase)
+{
+ int base = NUM2INT(vbase);
+ if (base < 2 || 36 < base)
+ rb_raise(rb_eArgError, "invalid radix %d", base);
+ return rb_big2str_generic(big(x), base);
+}
+
+#define POW2_P(x) (((x)&((x)-1))==0)
+
+static VALUE
+big2str_poweroftwo(VALUE x, VALUE vbase)
+{
+ int base = NUM2INT(vbase);
+ if (base < 2 || 36 < base || !POW2_P(base))
+ rb_raise(rb_eArgError, "invalid radix %d", base);
+ return rb_big2str_poweroftwo(big(x), base);
+}
+
+#if defined(HAVE_LIBGMP) && defined(HAVE_GMP_H)
+static VALUE
+big2str_gmp(VALUE x, VALUE vbase)
+{
+ int base = NUM2INT(vbase);
+ if (base < 2 || 36 < base)
+ rb_raise(rb_eArgError, "invalid radix %d", base);
+ return rb_big2str_gmp(big(x), base);
+}
+#else
+#define big2str_gmp rb_f_notimplement
+#endif
+
+void
+Init_big2str(VALUE klass)
+{
+ rb_define_method(rb_cInteger, "big2str_generic", big2str_generic, 1);
+ rb_define_method(rb_cInteger, "big2str_poweroftwo", big2str_poweroftwo, 1);
+ rb_define_method(rb_cInteger, "big2str_gmp", big2str_gmp, 1);
+}
diff --git a/jni/ruby/ext/-test-/bignum/bigzero.c b/jni/ruby/ext/-test-/bignum/bigzero.c
new file mode 100644
index 0000000..35117db
--- /dev/null
+++ b/jni/ruby/ext/-test-/bignum/bigzero.c
@@ -0,0 +1,26 @@
+#include "internal.h"
+
+static VALUE
+bug_big_zero(VALUE self, VALUE length)
+{
+ long len = NUM2ULONG(length);
+ VALUE z = rb_big_new(len, 1);
+ MEMZERO(BIGNUM_DIGITS(z), BDIGIT, len);
+ return z;
+}
+
+static VALUE
+bug_big_negzero(VALUE self, VALUE length)
+{
+ long len = NUM2ULONG(length);
+ VALUE z = rb_big_new(len, 0);
+ MEMZERO(BIGNUM_DIGITS(z), BDIGIT, len);
+ return z;
+}
+
+void
+Init_bigzero(VALUE klass)
+{
+ rb_define_singleton_method(klass, "zero", bug_big_zero, 1);
+ rb_define_singleton_method(klass, "negzero", bug_big_negzero, 1);
+}
diff --git a/jni/ruby/ext/-test-/bignum/depend b/jni/ruby/ext/-test-/bignum/depend
new file mode 100644
index 0000000..26cb890
--- /dev/null
+++ b/jni/ruby/ext/-test-/bignum/depend
@@ -0,0 +1,102 @@
+big2str.o: big2str.c
+div.o: div.c
+intpack.o: intpack.c
+mul.o: mul.c
+str2big.o: str2big.c
+
+# AUTOGENERATED DEPENDENCIES START
+big2str.o: $(RUBY_EXTCONF_H)
+big2str.o: $(arch_hdrdir)/ruby/config.h
+big2str.o: $(hdrdir)/ruby/defines.h
+big2str.o: $(hdrdir)/ruby/encoding.h
+big2str.o: $(hdrdir)/ruby/intern.h
+big2str.o: $(hdrdir)/ruby/io.h
+big2str.o: $(hdrdir)/ruby/missing.h
+big2str.o: $(hdrdir)/ruby/oniguruma.h
+big2str.o: $(hdrdir)/ruby/ruby.h
+big2str.o: $(hdrdir)/ruby/st.h
+big2str.o: $(hdrdir)/ruby/subst.h
+big2str.o: $(top_srcdir)/include/ruby.h
+big2str.o: $(top_srcdir)/internal.h
+big2str.o: big2str.c
+bigzero.o: $(RUBY_EXTCONF_H)
+bigzero.o: $(arch_hdrdir)/ruby/config.h
+bigzero.o: $(hdrdir)/ruby/defines.h
+bigzero.o: $(hdrdir)/ruby/encoding.h
+bigzero.o: $(hdrdir)/ruby/intern.h
+bigzero.o: $(hdrdir)/ruby/io.h
+bigzero.o: $(hdrdir)/ruby/missing.h
+bigzero.o: $(hdrdir)/ruby/oniguruma.h
+bigzero.o: $(hdrdir)/ruby/ruby.h
+bigzero.o: $(hdrdir)/ruby/st.h
+bigzero.o: $(hdrdir)/ruby/subst.h
+bigzero.o: $(top_srcdir)/include/ruby.h
+bigzero.o: $(top_srcdir)/internal.h
+bigzero.o: bigzero.c
+div.o: $(RUBY_EXTCONF_H)
+div.o: $(arch_hdrdir)/ruby/config.h
+div.o: $(hdrdir)/ruby/defines.h
+div.o: $(hdrdir)/ruby/encoding.h
+div.o: $(hdrdir)/ruby/intern.h
+div.o: $(hdrdir)/ruby/io.h
+div.o: $(hdrdir)/ruby/missing.h
+div.o: $(hdrdir)/ruby/oniguruma.h
+div.o: $(hdrdir)/ruby/ruby.h
+div.o: $(hdrdir)/ruby/st.h
+div.o: $(hdrdir)/ruby/subst.h
+div.o: $(top_srcdir)/include/ruby.h
+div.o: $(top_srcdir)/internal.h
+div.o: div.c
+init.o: $(RUBY_EXTCONF_H)
+init.o: $(arch_hdrdir)/ruby/config.h
+init.o: $(hdrdir)/ruby/defines.h
+init.o: $(hdrdir)/ruby/intern.h
+init.o: $(hdrdir)/ruby/missing.h
+init.o: $(hdrdir)/ruby/ruby.h
+init.o: $(hdrdir)/ruby/st.h
+init.o: $(hdrdir)/ruby/subst.h
+init.o: $(top_srcdir)/include/ruby.h
+init.o: init.c
+intpack.o: $(RUBY_EXTCONF_H)
+intpack.o: $(arch_hdrdir)/ruby/config.h
+intpack.o: $(hdrdir)/ruby/defines.h
+intpack.o: $(hdrdir)/ruby/encoding.h
+intpack.o: $(hdrdir)/ruby/intern.h
+intpack.o: $(hdrdir)/ruby/io.h
+intpack.o: $(hdrdir)/ruby/missing.h
+intpack.o: $(hdrdir)/ruby/oniguruma.h
+intpack.o: $(hdrdir)/ruby/ruby.h
+intpack.o: $(hdrdir)/ruby/st.h
+intpack.o: $(hdrdir)/ruby/subst.h
+intpack.o: $(top_srcdir)/include/ruby.h
+intpack.o: $(top_srcdir)/internal.h
+intpack.o: intpack.c
+mul.o: $(RUBY_EXTCONF_H)
+mul.o: $(arch_hdrdir)/ruby/config.h
+mul.o: $(hdrdir)/ruby/defines.h
+mul.o: $(hdrdir)/ruby/encoding.h
+mul.o: $(hdrdir)/ruby/intern.h
+mul.o: $(hdrdir)/ruby/io.h
+mul.o: $(hdrdir)/ruby/missing.h
+mul.o: $(hdrdir)/ruby/oniguruma.h
+mul.o: $(hdrdir)/ruby/ruby.h
+mul.o: $(hdrdir)/ruby/st.h
+mul.o: $(hdrdir)/ruby/subst.h
+mul.o: $(top_srcdir)/include/ruby.h
+mul.o: $(top_srcdir)/internal.h
+mul.o: mul.c
+str2big.o: $(RUBY_EXTCONF_H)
+str2big.o: $(arch_hdrdir)/ruby/config.h
+str2big.o: $(hdrdir)/ruby/defines.h
+str2big.o: $(hdrdir)/ruby/encoding.h
+str2big.o: $(hdrdir)/ruby/intern.h
+str2big.o: $(hdrdir)/ruby/io.h
+str2big.o: $(hdrdir)/ruby/missing.h
+str2big.o: $(hdrdir)/ruby/oniguruma.h
+str2big.o: $(hdrdir)/ruby/ruby.h
+str2big.o: $(hdrdir)/ruby/st.h
+str2big.o: $(hdrdir)/ruby/subst.h
+str2big.o: $(top_srcdir)/include/ruby.h
+str2big.o: $(top_srcdir)/internal.h
+str2big.o: str2big.c
+# AUTOGENERATED DEPENDENCIES END
diff --git a/jni/ruby/ext/-test-/bignum/div.c b/jni/ruby/ext/-test-/bignum/div.c
new file mode 100644
index 0000000..a1db21d
--- /dev/null
+++ b/jni/ruby/ext/-test-/bignum/div.c
@@ -0,0 +1,35 @@
+#include "internal.h"
+
+static VALUE
+big(VALUE x)
+{
+ if (FIXNUM_P(x))
+ return rb_int2big(FIX2LONG(x));
+ if (RB_TYPE_P(x, T_BIGNUM))
+ return x;
+ rb_raise(rb_eTypeError, "can't convert %s to Bignum",
+ rb_obj_classname(x));
+}
+
+static VALUE
+divrem_normal(VALUE x, VALUE y)
+{
+ return rb_big_norm(rb_big_divrem_normal(big(x), big(y)));
+}
+
+#if defined(HAVE_LIBGMP) && defined(HAVE_GMP_H)
+static VALUE
+divrem_gmp(VALUE x, VALUE y)
+{
+ return rb_big_norm(rb_big_divrem_gmp(big(x), big(y)));
+}
+#else
+#define divrem_gmp rb_f_notimplement
+#endif
+
+void
+Init_div(VALUE klass)
+{
+ rb_define_method(rb_cInteger, "big_divrem_normal", divrem_normal, 1);
+ rb_define_method(rb_cInteger, "big_divrem_gmp", divrem_gmp, 1);
+}
diff --git a/jni/ruby/ext/-test-/bignum/extconf.h b/jni/ruby/ext/-test-/bignum/extconf.h
new file mode 100644
index 0000000..ada4a2f
--- /dev/null
+++ b/jni/ruby/ext/-test-/bignum/extconf.h
@@ -0,0 +1,4 @@
+#ifndef EXTCONF_H
+#define EXTCONF_H
+#define TEST_INIT_FUNCS(X) X(bigzero) X(mul) X(str2big) X(big2str) X(div) X(intpack)
+#endif
diff --git a/jni/ruby/ext/-test-/bignum/extconf.rb b/jni/ruby/ext/-test-/bignum/extconf.rb
new file mode 100644
index 0000000..e8c1feb
--- /dev/null
+++ b/jni/ruby/ext/-test-/bignum/extconf.rb
@@ -0,0 +1,7 @@
+$INCFLAGS << " -I$(topdir) -I$(top_srcdir)"
+$srcs = Dir[File.join($srcdir, "*.{#{SRC_EXT.join(%q{,})}}")]
+inits = $srcs.map {|s| File.basename(s, ".*")}
+inits.delete("init")
+inits.map! {|s|"X(#{s})"}
+$defs << "-DTEST_INIT_FUNCS(X)=\"#{inits.join(' ')}\""
+create_makefile("-test-/bignum")
diff --git a/jni/ruby/ext/-test-/bignum/init.c b/jni/ruby/ext/-test-/bignum/init.c
new file mode 100644
index 0000000..82a159b
--- /dev/null
+++ b/jni/ruby/ext/-test-/bignum/init.c
@@ -0,0 +1,11 @@
+#include "ruby.h"
+
+#define init(n) {void Init_##n(VALUE klass); Init_##n(klass);}
+
+void
+Init_bignum(void)
+{
+ VALUE mBug = rb_define_module("Bug");
+ VALUE klass = rb_define_class_under(mBug, "Bignum", rb_cString);
+ TEST_INIT_FUNCS(init);
+}
diff --git a/jni/ruby/ext/-test-/bignum/intpack.c b/jni/ruby/ext/-test-/bignum/intpack.c
new file mode 100644
index 0000000..2d19442
--- /dev/null
+++ b/jni/ruby/ext/-test-/bignum/intpack.c
@@ -0,0 +1,87 @@
+#include "internal.h"
+
+static VALUE
+rb_integer_pack_raw_m(VALUE val, VALUE buf, VALUE numwords_arg, VALUE wordsize_arg, VALUE nails, VALUE flags)
+{
+ int sign;
+ size_t numwords = 0;
+ size_t wordsize = NUM2SIZET(wordsize_arg);
+
+ StringValue(buf);
+ rb_str_modify(buf);
+ sign = rb_integer_pack(val,
+ RSTRING_PTR(buf), NUM2SIZET(numwords_arg),
+ NUM2SIZET(wordsize_arg), NUM2SIZET(nails), NUM2INT(flags));
+
+ return rb_ary_new_from_args(2, INT2NUM(sign), rb_str_new(RSTRING_PTR(buf), wordsize * numwords));
+}
+
+static VALUE
+rb_integer_pack_m(VALUE val, VALUE numwords_arg, VALUE wordsize_arg, VALUE nails, VALUE flags)
+{
+ int sign;
+ size_t numwords = NUM2SIZET(numwords_arg);
+ size_t wordsize = NUM2SIZET(wordsize_arg);
+ VALUE buf;
+
+ if (numwords != 0 && wordsize != 0 && LONG_MAX / wordsize < numwords)
+ rb_raise(rb_eArgError, "too big numwords * wordsize");
+ buf = rb_str_new(NULL, numwords * wordsize);
+ sign = rb_integer_pack(val,
+ RSTRING_PTR(buf), numwords,
+ wordsize, NUM2SIZET(nails), NUM2INT(flags));
+
+ return rb_assoc_new(INT2NUM(sign), buf);
+}
+
+static VALUE
+rb_integer_unpack_m(VALUE klass, VALUE buf, VALUE numwords, VALUE wordsize, VALUE nails, VALUE flags)
+{
+ StringValue(buf);
+
+ return rb_integer_unpack(RSTRING_PTR(buf),
+ NUM2SIZET(numwords), NUM2SIZET(wordsize),
+ NUM2SIZET(nails), NUM2INT(flags));
+}
+
+static VALUE
+rb_integer_test_numbits_2comp_without_sign(VALUE val)
+{
+ size_t size;
+ int neg = FIXNUM_P(val) ? FIX2LONG(val) < 0 : BIGNUM_NEGATIVE_P(val);
+ size = rb_absint_numwords(val, 1, NULL) - (neg && rb_absint_singlebit_p(val));
+ return SIZET2NUM(size);
+}
+
+static VALUE
+rb_integer_test_numbytes_2comp_with_sign(VALUE val)
+{
+ int neg = FIXNUM_P(val) ? FIX2LONG(val) < 0 : BIGNUM_NEGATIVE_P(val);
+ int nlz_bits;
+ size_t size = rb_absint_size(val, &nlz_bits);
+ if (nlz_bits == 0 && !(neg && rb_absint_singlebit_p(val)))
+ size++;
+ return SIZET2NUM(size);
+}
+
+void
+Init_intpack(VALUE klass)
+{
+ rb_define_method(rb_cInteger, "test_pack_raw", rb_integer_pack_raw_m, 5);
+ rb_define_method(rb_cInteger, "test_pack", rb_integer_pack_m, 4);
+ rb_define_singleton_method(rb_cInteger, "test_unpack", rb_integer_unpack_m, 5);
+ rb_define_const(rb_cInteger, "INTEGER_PACK_MSWORD_FIRST", INT2NUM(INTEGER_PACK_MSWORD_FIRST));
+ rb_define_const(rb_cInteger, "INTEGER_PACK_LSWORD_FIRST", INT2NUM(INTEGER_PACK_LSWORD_FIRST));
+ rb_define_const(rb_cInteger, "INTEGER_PACK_MSBYTE_FIRST", INT2NUM(INTEGER_PACK_MSBYTE_FIRST));
+ rb_define_const(rb_cInteger, "INTEGER_PACK_LSBYTE_FIRST", INT2NUM(INTEGER_PACK_LSBYTE_FIRST));
+ rb_define_const(rb_cInteger, "INTEGER_PACK_NATIVE_BYTE_ORDER", INT2NUM(INTEGER_PACK_NATIVE_BYTE_ORDER));
+ rb_define_const(rb_cInteger, "INTEGER_PACK_2COMP", INT2NUM(INTEGER_PACK_2COMP));
+ rb_define_const(rb_cInteger, "INTEGER_PACK_LITTLE_ENDIAN", INT2NUM(INTEGER_PACK_LITTLE_ENDIAN));
+ rb_define_const(rb_cInteger, "INTEGER_PACK_BIG_ENDIAN", INT2NUM(INTEGER_PACK_BIG_ENDIAN));
+ rb_define_const(rb_cInteger, "INTEGER_PACK_FORCE_BIGNUM", INT2NUM(INTEGER_PACK_FORCE_BIGNUM));
+ rb_define_const(rb_cInteger, "INTEGER_PACK_NEGATIVE", INT2NUM(INTEGER_PACK_NEGATIVE));
+ rb_define_const(rb_cInteger, "INTEGER_PACK_FORCE_GENERIC_IMPLEMENTATION", INT2NUM(INTEGER_PACK_FORCE_GENERIC_IMPLEMENTATION));
+
+ rb_define_method(rb_cInteger, "test_numbits_2comp_without_sign", rb_integer_test_numbits_2comp_without_sign, 0);
+ rb_define_method(rb_cInteger, "test_numbytes_2comp_with_sign", rb_integer_test_numbytes_2comp_with_sign, 0);
+}
diff --git a/jni/ruby/ext/-test-/bignum/mul.c b/jni/ruby/ext/-test-/bignum/mul.c
new file mode 100644
index 0000000..d34e98f
--- /dev/null
+++ b/jni/ruby/ext/-test-/bignum/mul.c
@@ -0,0 +1,65 @@
+#include "internal.h"
+
+static VALUE
+big(VALUE x)
+{
+ if (FIXNUM_P(x))
+ return rb_int2big(FIX2LONG(x));
+ if (RB_TYPE_P(x, T_BIGNUM))
+ return x;
+ rb_raise(rb_eTypeError, "can't convert %s to Bignum",
+ rb_obj_classname(x));
+}
+
+static VALUE
+mul_normal(VALUE x, VALUE y)
+{
+ return rb_big_norm(rb_big_mul_normal(big(x), big(y)));
+}
+
+static VALUE
+sq_fast(VALUE x)
+{
+ return rb_big_norm(rb_big_sq_fast(big(x)));
+}
+
+static VALUE
+mul_balance(VALUE x, VALUE y)
+{
+ return rb_big_norm(rb_big_mul_balance(big(x), big(y)));
+}
+
+static VALUE
+mul_karatsuba(VALUE x, VALUE y)
+{
+ return rb_big_norm(rb_big_mul_karatsuba(big(x), big(y)));
+}
+
+static VALUE
+mul_toom3(VALUE x, VALUE y)
+{
+ return rb_big_norm(rb_big_mul_toom3(big(x), big(y)));
+}
+
+#if defined(HAVE_LIBGMP) && defined(HAVE_GMP_H)
+static VALUE
+mul_gmp(VALUE x, VALUE y)
+{
+ return rb_big_norm(rb_big_mul_gmp(big(x), big(y)));
+}
+#else
+#define mul_gmp rb_f_notimplement
+#endif
+
+void
+Init_mul(VALUE klass)
+{
+ rb_define_const(rb_cBignum, "SIZEOF_BDIGIT", INT2NUM(SIZEOF_BDIGIT));
+ rb_define_const(rb_cBignum, "BITSPERDIG", INT2NUM(SIZEOF_BDIGIT * CHAR_BIT));
+ rb_define_method(rb_cInteger, "big_mul_normal", mul_normal, 1);
+ rb_define_method(rb_cInteger, "big_sq_fast", sq_fast, 0);
+ rb_define_method(rb_cInteger, "big_mul_balance", mul_balance, 1);
+ rb_define_method(rb_cInteger, "big_mul_karatsuba", mul_karatsuba, 1);
+ rb_define_method(rb_cInteger, "big_mul_toom3", mul_toom3, 1);
+ rb_define_method(rb_cInteger, "big_mul_gmp", mul_gmp, 1);
+}
diff --git a/jni/ruby/ext/-test-/bignum/str2big.c b/jni/ruby/ext/-test-/bignum/str2big.c
new file mode 100644
index 0000000..bc79ef0
--- /dev/null
+++ b/jni/ruby/ext/-test-/bignum/str2big.c
@@ -0,0 +1,38 @@
+#include "internal.h"
+
+static VALUE
+str2big_poweroftwo(VALUE str, VALUE vbase, VALUE badcheck)
+{
+ return rb_str2big_poweroftwo(str, NUM2INT(vbase), RTEST(badcheck));
+}
+
+static VALUE
+str2big_normal(VALUE str, VALUE vbase, VALUE badcheck)
+{
+ return rb_str2big_normal(str, NUM2INT(vbase), RTEST(badcheck));
+}
+
+static VALUE
+str2big_karatsuba(VALUE str, VALUE vbase, VALUE badcheck)
+{
+ return rb_str2big_karatsuba(str, NUM2INT(vbase), RTEST(badcheck));
+}
+
+#if defined(HAVE_LIBGMP) && defined(HAVE_GMP_H)
+static VALUE
+str2big_gmp(VALUE str, VALUE vbase, VALUE badcheck)
+{
+ return rb_str2big_gmp(str, NUM2INT(vbase), RTEST(badcheck));
+}
+#else
+#define str2big_gmp rb_f_notimplement
+#endif
+
+void
+Init_str2big(VALUE klass)
+{
+ rb_define_method(rb_cString, "str2big_poweroftwo", str2big_poweroftwo, 2);
+ rb_define_method(rb_cString, "str2big_normal", str2big_normal, 2);
+ rb_define_method(rb_cString, "str2big_karatsuba", str2big_karatsuba, 2);
+ rb_define_method(rb_cString, "str2big_gmp", str2big_gmp, 2);
+}
diff --git a/jni/ruby/ext/-test-/bug-3571/Makefile b/jni/ruby/ext/-test-/bug-3571/Makefile
new file mode 100644
index 0000000..3f6b584
--- /dev/null
+++ b/jni/ruby/ext/-test-/bug-3571/Makefile
@@ -0,0 +1,267 @@
+
+SHELL = /bin/sh
+
+# V=0 quiet, V=1 verbose. other values don't work.
+V = 0
+Q1 = $(V:1=)
+Q = $(Q1:0=@)
+ECHO1 = $(V:1=@:)
+ECHO = $(ECHO1:0=@echo)
+NULLCMD = :
+
+#### Start of system configuration section. ####
+top_srcdir = $(topdir)/.
+srcdir = $(top_srcdir)/ext/-test-/bug-3571
+topdir = ../../..
+hdrdir = $(top_srcdir)/include
+arch_hdrdir = $(extout)/include/$(arch)
+PATH_SEPARATOR = :
+VPATH = $(srcdir):$(arch_hdrdir)/ruby:$(hdrdir)/ruby
+RUBYLIB =
+RUBYOPT = -
+prefix = $(DESTDIR)/usr/local
+rubysitearchprefix = $(rubylibprefix)/$(sitearch)
+rubyarchprefix = $(rubylibprefix)/$(arch)
+rubylibprefix = $(libdir)/$(RUBY_BASE_NAME)
+exec_prefix = $(prefix)
+vendorarchhdrdir = $(vendorhdrdir)/$(sitearch)
+sitearchhdrdir = $(sitehdrdir)/$(sitearch)
+rubyarchhdrdir = $(rubyhdrdir)/$(arch)
+vendorhdrdir = $(rubyhdrdir)/vendor_ruby
+sitehdrdir = $(rubyhdrdir)/site_ruby
+rubyhdrdir = $(includedir)/$(RUBY_VERSION_NAME)
+vendorarchdir = $(vendorlibdir)/$(sitearch)
+vendorlibdir = $(vendordir)/$(ruby_version)
+vendordir = $(rubylibprefix)/vendor_ruby
+sitearchdir = $(sitelibdir)/$(sitearch)
+sitelibdir = $(sitedir)/$(ruby_version)
+sitedir = $(rubylibprefix)/site_ruby
+rubyarchdir = $(rubylibdir)/$(arch)
+rubylibdir = $(rubylibprefix)/$(ruby_version)
+sitearchincludedir = $(includedir)/$(sitearch)
+archincludedir = $(includedir)/$(arch)
+sitearchlibdir = $(libdir)/$(sitearch)
+archlibdir = $(libdir)/$(arch)
+ridir = $(datarootdir)/$(RI_BASE_NAME)
+mandir = $(datarootdir)/man
+localedir = $(datarootdir)/locale
+libdir = $(exec_prefix)/lib
+psdir = $(docdir)
+pdfdir = $(docdir)
+dvidir = $(docdir)
+htmldir = $(docdir)
+infodir = $(datarootdir)/info
+docdir = $(datarootdir)/doc/$(PACKAGE)
+oldincludedir = $(DESTDIR)/usr/include
+includedir = $(prefix)/include
+localstatedir = $(prefix)/var
+sharedstatedir = $(prefix)/com
+sysconfdir = $(prefix)/etc
+datadir = $(datarootdir)
+datarootdir = $(prefix)/share
+libexecdir = $(exec_prefix)/libexec
+sbindir = $(exec_prefix)/sbin
+bindir = $(exec_prefix)/bin
+archdir = $(rubyarchdir)
+
+
+CC = gcc
+CXX = g++
+LIBRUBY = $(LIBRUBY_SO)
+LIBRUBY_A = lib$(RUBY_SO_NAME)-static.a
+LIBRUBYARG_SHARED = -Wl,-R$(libdir) -L$(libdir) -l$(RUBY_SO_NAME)
+LIBRUBYARG_STATIC = -Wl,-R$(libdir) -L$(libdir) -l$(RUBY_SO_NAME)-static
+empty =
+OUTFLAG = -o $(empty)
+COUTFLAG = -o $(empty)
+
+RUBY_EXTCONF_H = extconf.h
+cflags = $(optflags) $(debugflags) $(warnflags)
+optflags = -O3 -fno-fast-math
+debugflags = -ggdb3
+warnflags = -Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wunused-variable -Wpointer-arith -Wwrite-strings -Wdeclaration-after-statement -Wimplicit-function-declaration -Wdeprecated-declarations -Wno-packed-bitfield-compat
+CCDLFLAGS = -fPIC
+CFLAGS = $(CCDLFLAGS) $(cflags) -fPIC $(ARCH_FLAG)
+INCFLAGS = -I. -I$(arch_hdrdir) -I$(hdrdir) -I$(srcdir)
+DEFS =
+CPPFLAGS = -DRUBY_EXTCONF_H=\"$(RUBY_EXTCONF_H)\" $(DEFS) $(cppflags)
+CXXFLAGS = $(CCDLFLAGS) $(cxxflags) $(ARCH_FLAG)
+ldflags = -L. -fstack-protector -rdynamic -Wl,-export-dynamic
+dldflags =
+ARCH_FLAG =
+DLDFLAGS = $(ldflags) $(dldflags) $(ARCH_FLAG)
+LDSHARED = $(CC) -shared
+LDSHAREDXX = $(CXX) -shared
+AR = ar
+EXEEXT =
+
+RUBY_INSTALL_NAME = $(RUBY_BASE_NAME)
+RUBY_SO_NAME = ruby
+RUBYW_INSTALL_NAME =
+RUBY_VERSION_NAME = $(RUBY_BASE_NAME)-$(ruby_version)
+RUBYW_BASE_NAME = rubyw
+RUBY_BASE_NAME = ruby
+
+arch = x86_64-linux
+sitearch = $(arch)
+ruby_version = 2.2.0
+ruby = $(topdir)/miniruby -I'$(topdir)' -I'$(top_srcdir)/lib' -I'$(extout)/$(arch)' -I'$(extout)/common'
+RUBY = $(ruby)
+ruby_headers = $(hdrdir)/ruby.h $(hdrdir)/ruby/ruby.h $(hdrdir)/ruby/defines.h $(hdrdir)/ruby/missing.h $(hdrdir)/ruby/intern.h $(hdrdir)/ruby/st.h $(hdrdir)/ruby/subst.h $(arch_hdrdir)/ruby/config.h $(RUBY_EXTCONF_H)
+
+RM = rm -f
+RM_RF = $(RUBY) -run -e rm -- -rf
+RMDIRS = rmdir --ignore-fail-on-non-empty -p
+MAKEDIRS = /bin/mkdir -p
+INSTALL = /usr/bin/install -c
+INSTALL_PROG = $(INSTALL) -m 0755
+INSTALL_DATA = $(INSTALL) -m 644
+COPY = cp
+TOUCH = exit >
+
+#### End of system configuration section. ####
+
+preload =
+
+libpath = . $(topdir)
+LIBPATH = -L. -L$(topdir)
+DEFFILE =
+
+CLEANFILES = mkmf.log
+DISTCLEANFILES =
+DISTCLEANDIRS =
+
+extout = $(topdir)/.ext
+extout_prefix = $(extout)$(target_prefix)/
+target_prefix = /-test-/bug-3571
+LOCAL_LIBS =
+LIBS = $(LIBRUBYARG_SHARED) -lpthread -lgmp -ldl -lcrypt -lm -lc
+ORIG_SRCS = bug.c
+SRCS = $(ORIG_SRCS)
+OBJS = bug.o
+HDRS = $(srcdir)/extconf.h
+TARGET = bug
+TARGET_NAME = bug
+TARGET_ENTRY = Init_$(TARGET_NAME)
+DLLIB = $(TARGET).so
+EXTSTATIC =
+STATIC_LIB = $(TARGET).a
+
+TIMESTAMP_DIR = $(extout)/.timestamp
+BINDIR = $(extout)/bin
+RUBYCOMMONDIR = $(extout)/common
+RUBYLIBDIR = $(RUBYCOMMONDIR)$(target_prefix)
+RUBYARCHDIR = $(extout)/$(arch)$(target_prefix)
+HDRDIR = $(extout)/include/ruby$(target_prefix)
+ARCHHDRDIR = $(extout)/include/$(arch)/ruby$(target_prefix)
+
+TARGET_SO = $(RUBYARCHDIR)/$(DLLIB)
+CLEANLIBS = $(RUBYARCHDIR)/$(TARGET).so
+CLEANOBJS = *.o *.bak
+
+all: install
+static: all
+.PHONY: all install static install-so install-rb
+.PHONY: clean clean-so clean-static clean-rb
+
+clean-static::
+clean-rb-default::
+clean-rb::
+clean-so::
+clean: clean-so clean-static clean-rb-default clean-rb
+ -$(Q)$(RM) $(CLEANLIBS) $(CLEANOBJS) $(CLEANFILES) .*.time
+
+distclean-rb-default::
+distclean-rb::
+distclean-so::
+distclean-static::
+distclean: clean distclean-so distclean-static distclean-rb-default distclean-rb
+ -$(Q)$(RM) Makefile $(RUBY_EXTCONF_H) conftest.* mkmf.log
+ -$(Q)$(RM) core ruby$(EXEEXT) *~ $(DISTCLEANFILES)
+ -$(Q)$(RMDIRS) $(DISTCLEANDIRS) 2> /dev/null || true
+
+realclean: distclean
+install: install-so install-rb
+
+install-so: $(RUBYARCHDIR)/$(DLLIB)
+clean-so::
+ -$(Q)$(RM) $(RUBYARCHDIR)/$(DLLIB)
+ -$(Q)$(RMDIRS) $(RUBYARCHDIR) 2> /dev/null || true
+clean-static::
+ -$(Q)$(RM) $(STATIC_LIB)
+install-rb: pre-install-rb install-rb-default
+install-rb-default: pre-install-rb-default
+pre-install-rb: Makefile
+pre-install-rb-default: Makefile
+pre-install-rb-default:
+ @$(NULLCMD)
+$(TIMESTAMP_DIR)/.RUBYARCHDIR.-.-test-.-.bug-3571.time:
+ $(Q) $(MAKEDIRS) $(@D) $(RUBYARCHDIR)
+ $(Q) $(TOUCH) $@
+
+site-install: site-install-so site-install-rb
+site-install-so: install-so
+site-install-rb: install-rb
+
+.SUFFIXES: .c .m .cc .mm .cxx .cpp .o .S
+
+.cc.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<
+
+.cc.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -S $<
+
+.mm.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<
+
+.mm.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -S $<
+
+.cxx.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<
+
+.cxx.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -S $<
+
+.cpp.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<
+
+.cpp.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -S $<
+
+.c.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -c $<
+
+.c.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -S $<
+
+.m.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -c $<
+
+.m.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -S $<
+
+$(RUBYARCHDIR)/$(DLLIB): $(OBJS) Makefile $(TIMESTAMP_DIR)/.RUBYARCHDIR.-.-test-.-.bug-3571.time
+ $(ECHO) linking shared-object -test-/bug-3571/$(DLLIB)
+ -$(Q)$(RM) $(@)
+ $(Q) $(LDSHARED) -o $@ $(OBJS) $(LIBPATH) $(DLDFLAGS) $(LOCAL_LIBS) $(LIBS)
+
+$(STATIC_LIB): $(OBJS)
+ -$(Q)$(RM) $(@)
+ $(ECHO) linking static-library $(@)
+ $(Q) $(AR) cru $@ $(OBJS)
+ -$(Q)ranlib $(@) 2> /dev/null || true
+
+$(OBJS): $(HDRS) $(ruby_headers)
diff --git a/jni/ruby/ext/-test-/bug-3571/bug.c b/jni/ruby/ext/-test-/bug-3571/bug.c
new file mode 100644
index 0000000..87a5df0
--- /dev/null
+++ b/jni/ruby/ext/-test-/bug-3571/bug.c
@@ -0,0 +1,23 @@
+#include <ruby.h>
+
+static VALUE
+bug_i(RB_BLOCK_CALL_FUNC_ARGLIST(i, arg))
+{
+ rb_notimplement();
+ return ID2SYM(rb_frame_this_func());
+}
+
+static VALUE
+bug_start(VALUE self, VALUE hash)
+{
+ VALUE ary = rb_ary_new3(1, Qnil);
+ rb_block_call(ary, rb_intern("map"), 0, 0, bug_i, self);
+ return ary;
+}
+
+void
+Init_bug(void)
+{
+ VALUE mBug = rb_define_module("Bug");
+ rb_define_module_function(mBug, "start", bug_start, 0);
+}
diff --git a/jni/ruby/ext/-test-/bug-3571/extconf.h b/jni/ruby/ext/-test-/bug-3571/extconf.h
new file mode 100644
index 0000000..cda0cc8
--- /dev/null
+++ b/jni/ruby/ext/-test-/bug-3571/extconf.h
@@ -0,0 +1,3 @@
+#ifndef EXTCONF_H
+#define EXTCONF_H
+#endif
diff --git a/jni/ruby/ext/-test-/bug-3571/extconf.rb b/jni/ruby/ext/-test-/bug-3571/extconf.rb
new file mode 100644
index 0000000..6390fce
--- /dev/null
+++ b/jni/ruby/ext/-test-/bug-3571/extconf.rb
@@ -0,0 +1 @@
+create_makefile("-test-/bug-3571/bug")
diff --git a/jni/ruby/ext/-test-/bug-3662/Makefile b/jni/ruby/ext/-test-/bug-3662/Makefile
new file mode 100644
index 0000000..916bb24
--- /dev/null
+++ b/jni/ruby/ext/-test-/bug-3662/Makefile
@@ -0,0 +1,267 @@
+
+SHELL = /bin/sh
+
+# V=0 quiet, V=1 verbose. other values don't work.
+V = 0
+Q1 = $(V:1=)
+Q = $(Q1:0=@)
+ECHO1 = $(V:1=@:)
+ECHO = $(ECHO1:0=@echo)
+NULLCMD = :
+
+#### Start of system configuration section. ####
+top_srcdir = $(topdir)/.
+srcdir = $(top_srcdir)/ext/-test-/bug-3662
+topdir = ../../..
+hdrdir = $(top_srcdir)/include
+arch_hdrdir = $(extout)/include/$(arch)
+PATH_SEPARATOR = :
+VPATH = $(srcdir):$(arch_hdrdir)/ruby:$(hdrdir)/ruby
+RUBYLIB =
+RUBYOPT = -
+prefix = $(DESTDIR)/usr/local
+rubysitearchprefix = $(rubylibprefix)/$(sitearch)
+rubyarchprefix = $(rubylibprefix)/$(arch)
+rubylibprefix = $(libdir)/$(RUBY_BASE_NAME)
+exec_prefix = $(prefix)
+vendorarchhdrdir = $(vendorhdrdir)/$(sitearch)
+sitearchhdrdir = $(sitehdrdir)/$(sitearch)
+rubyarchhdrdir = $(rubyhdrdir)/$(arch)
+vendorhdrdir = $(rubyhdrdir)/vendor_ruby
+sitehdrdir = $(rubyhdrdir)/site_ruby
+rubyhdrdir = $(includedir)/$(RUBY_VERSION_NAME)
+vendorarchdir = $(vendorlibdir)/$(sitearch)
+vendorlibdir = $(vendordir)/$(ruby_version)
+vendordir = $(rubylibprefix)/vendor_ruby
+sitearchdir = $(sitelibdir)/$(sitearch)
+sitelibdir = $(sitedir)/$(ruby_version)
+sitedir = $(rubylibprefix)/site_ruby
+rubyarchdir = $(rubylibdir)/$(arch)
+rubylibdir = $(rubylibprefix)/$(ruby_version)
+sitearchincludedir = $(includedir)/$(sitearch)
+archincludedir = $(includedir)/$(arch)
+sitearchlibdir = $(libdir)/$(sitearch)
+archlibdir = $(libdir)/$(arch)
+ridir = $(datarootdir)/$(RI_BASE_NAME)
+mandir = $(datarootdir)/man
+localedir = $(datarootdir)/locale
+libdir = $(exec_prefix)/lib
+psdir = $(docdir)
+pdfdir = $(docdir)
+dvidir = $(docdir)
+htmldir = $(docdir)
+infodir = $(datarootdir)/info
+docdir = $(datarootdir)/doc/$(PACKAGE)
+oldincludedir = $(DESTDIR)/usr/include
+includedir = $(prefix)/include
+localstatedir = $(prefix)/var
+sharedstatedir = $(prefix)/com
+sysconfdir = $(prefix)/etc
+datadir = $(datarootdir)
+datarootdir = $(prefix)/share
+libexecdir = $(exec_prefix)/libexec
+sbindir = $(exec_prefix)/sbin
+bindir = $(exec_prefix)/bin
+archdir = $(rubyarchdir)
+
+
+CC = gcc
+CXX = g++
+LIBRUBY = $(LIBRUBY_SO)
+LIBRUBY_A = lib$(RUBY_SO_NAME)-static.a
+LIBRUBYARG_SHARED = -Wl,-R$(libdir) -L$(libdir) -l$(RUBY_SO_NAME)
+LIBRUBYARG_STATIC = -Wl,-R$(libdir) -L$(libdir) -l$(RUBY_SO_NAME)-static
+empty =
+OUTFLAG = -o $(empty)
+COUTFLAG = -o $(empty)
+
+RUBY_EXTCONF_H = extconf.h
+cflags = $(optflags) $(debugflags) $(warnflags)
+optflags = -O3 -fno-fast-math
+debugflags = -ggdb3
+warnflags = -Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wunused-variable -Wpointer-arith -Wwrite-strings -Wdeclaration-after-statement -Wimplicit-function-declaration -Wdeprecated-declarations -Wno-packed-bitfield-compat
+CCDLFLAGS = -fPIC
+CFLAGS = $(CCDLFLAGS) $(cflags) -fPIC $(ARCH_FLAG)
+INCFLAGS = -I. -I$(arch_hdrdir) -I$(hdrdir) -I$(srcdir)
+DEFS =
+CPPFLAGS = -DRUBY_EXTCONF_H=\"$(RUBY_EXTCONF_H)\" $(DEFS) $(cppflags)
+CXXFLAGS = $(CCDLFLAGS) $(cxxflags) $(ARCH_FLAG)
+ldflags = -L. -fstack-protector -rdynamic -Wl,-export-dynamic
+dldflags =
+ARCH_FLAG =
+DLDFLAGS = $(ldflags) $(dldflags) $(ARCH_FLAG)
+LDSHARED = $(CC) -shared
+LDSHAREDXX = $(CXX) -shared
+AR = ar
+EXEEXT =
+
+RUBY_INSTALL_NAME = $(RUBY_BASE_NAME)
+RUBY_SO_NAME = ruby
+RUBYW_INSTALL_NAME =
+RUBY_VERSION_NAME = $(RUBY_BASE_NAME)-$(ruby_version)
+RUBYW_BASE_NAME = rubyw
+RUBY_BASE_NAME = ruby
+
+arch = x86_64-linux
+sitearch = $(arch)
+ruby_version = 2.2.0
+ruby = $(topdir)/miniruby -I'$(topdir)' -I'$(top_srcdir)/lib' -I'$(extout)/$(arch)' -I'$(extout)/common'
+RUBY = $(ruby)
+ruby_headers = $(hdrdir)/ruby.h $(hdrdir)/ruby/ruby.h $(hdrdir)/ruby/defines.h $(hdrdir)/ruby/missing.h $(hdrdir)/ruby/intern.h $(hdrdir)/ruby/st.h $(hdrdir)/ruby/subst.h $(arch_hdrdir)/ruby/config.h $(RUBY_EXTCONF_H)
+
+RM = rm -f
+RM_RF = $(RUBY) -run -e rm -- -rf
+RMDIRS = rmdir --ignore-fail-on-non-empty -p
+MAKEDIRS = /bin/mkdir -p
+INSTALL = /usr/bin/install -c
+INSTALL_PROG = $(INSTALL) -m 0755
+INSTALL_DATA = $(INSTALL) -m 644
+COPY = cp
+TOUCH = exit >
+
+#### End of system configuration section. ####
+
+preload =
+
+libpath = . $(topdir)
+LIBPATH = -L. -L$(topdir)
+DEFFILE =
+
+CLEANFILES = mkmf.log
+DISTCLEANFILES =
+DISTCLEANDIRS =
+
+extout = $(topdir)/.ext
+extout_prefix = $(extout)$(target_prefix)/
+target_prefix = /-test-/bug-3662
+LOCAL_LIBS =
+LIBS = $(LIBRUBYARG_SHARED) -lpthread -lgmp -ldl -lcrypt -lm -lc
+ORIG_SRCS = bug.c
+SRCS = $(ORIG_SRCS)
+OBJS = bug.o
+HDRS = $(srcdir)/extconf.h
+TARGET = bug
+TARGET_NAME = bug
+TARGET_ENTRY = Init_$(TARGET_NAME)
+DLLIB = $(TARGET).so
+EXTSTATIC =
+STATIC_LIB = $(TARGET).a
+
+TIMESTAMP_DIR = $(extout)/.timestamp
+BINDIR = $(extout)/bin
+RUBYCOMMONDIR = $(extout)/common
+RUBYLIBDIR = $(RUBYCOMMONDIR)$(target_prefix)
+RUBYARCHDIR = $(extout)/$(arch)$(target_prefix)
+HDRDIR = $(extout)/include/ruby$(target_prefix)
+ARCHHDRDIR = $(extout)/include/$(arch)/ruby$(target_prefix)
+
+TARGET_SO = $(RUBYARCHDIR)/$(DLLIB)
+CLEANLIBS = $(RUBYARCHDIR)/$(TARGET).so
+CLEANOBJS = *.o *.bak
+
+all: install
+static: all
+.PHONY: all install static install-so install-rb
+.PHONY: clean clean-so clean-static clean-rb
+
+clean-static::
+clean-rb-default::
+clean-rb::
+clean-so::
+clean: clean-so clean-static clean-rb-default clean-rb
+ -$(Q)$(RM) $(CLEANLIBS) $(CLEANOBJS) $(CLEANFILES) .*.time
+
+distclean-rb-default::
+distclean-rb::
+distclean-so::
+distclean-static::
+distclean: clean distclean-so distclean-static distclean-rb-default distclean-rb
+ -$(Q)$(RM) Makefile $(RUBY_EXTCONF_H) conftest.* mkmf.log
+ -$(Q)$(RM) core ruby$(EXEEXT) *~ $(DISTCLEANFILES)
+ -$(Q)$(RMDIRS) $(DISTCLEANDIRS) 2> /dev/null || true
+
+realclean: distclean
+install: install-so install-rb
+
+install-so: $(RUBYARCHDIR)/$(DLLIB)
+clean-so::
+ -$(Q)$(RM) $(RUBYARCHDIR)/$(DLLIB)
+ -$(Q)$(RMDIRS) $(RUBYARCHDIR) 2> /dev/null || true
+clean-static::
+ -$(Q)$(RM) $(STATIC_LIB)
+install-rb: pre-install-rb install-rb-default
+install-rb-default: pre-install-rb-default
+pre-install-rb: Makefile
+pre-install-rb-default: Makefile
+pre-install-rb-default:
+ @$(NULLCMD)
+$(TIMESTAMP_DIR)/.RUBYARCHDIR.-.-test-.-.bug-3662.time:
+ $(Q) $(MAKEDIRS) $(@D) $(RUBYARCHDIR)
+ $(Q) $(TOUCH) $@
+
+site-install: site-install-so site-install-rb
+site-install-so: install-so
+site-install-rb: install-rb
+
+.SUFFIXES: .c .m .cc .mm .cxx .cpp .o .S
+
+.cc.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<
+
+.cc.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -S $<
+
+.mm.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<
+
+.mm.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -S $<
+
+.cxx.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<
+
+.cxx.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -S $<
+
+.cpp.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<
+
+.cpp.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -S $<
+
+.c.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -c $<
+
+.c.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -S $<
+
+.m.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -c $<
+
+.m.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -S $<
+
+$(RUBYARCHDIR)/$(DLLIB): $(OBJS) Makefile $(TIMESTAMP_DIR)/.RUBYARCHDIR.-.-test-.-.bug-3662.time
+ $(ECHO) linking shared-object -test-/bug-3662/$(DLLIB)
+ -$(Q)$(RM) $(@)
+ $(Q) $(LDSHARED) -o $@ $(OBJS) $(LIBPATH) $(DLDFLAGS) $(LOCAL_LIBS) $(LIBS)
+
+$(STATIC_LIB): $(OBJS)
+ -$(Q)$(RM) $(@)
+ $(ECHO) linking static-library $(@)
+ $(Q) $(AR) cru $@ $(OBJS)
+ -$(Q)ranlib $(@) 2> /dev/null || true
+
+$(OBJS): $(HDRS) $(ruby_headers)
diff --git a/jni/ruby/ext/-test-/bug-3662/bug.c b/jni/ruby/ext/-test-/bug-3662/bug.c
new file mode 100644
index 0000000..9375dac
--- /dev/null
+++ b/jni/ruby/ext/-test-/bug-3662/bug.c
@@ -0,0 +1,16 @@
+#include <ruby.h>
+
+static VALUE
+bug_funcall(int argc, VALUE *argv, VALUE self)
+{
+ if (argc < 1) rb_raise(rb_eArgError, "not enough argument");
+ return rb_funcall2(self, rb_to_id(*argv), argc-1, argv+1);
+}
+
+void
+Init_bug(void)
+{
+ VALUE mBug = rb_define_module("Bug");
+ rb_define_module_function(mBug, "funcall", bug_funcall, -1);
+ rb_define_module_function(mBug, "notimplement", rb_f_notimplement, -1);
+}
diff --git a/jni/ruby/ext/-test-/bug-3662/extconf.h b/jni/ruby/ext/-test-/bug-3662/extconf.h
new file mode 100644
index 0000000..cda0cc8
--- /dev/null
+++ b/jni/ruby/ext/-test-/bug-3662/extconf.h
@@ -0,0 +1,3 @@
+#ifndef EXTCONF_H
+#define EXTCONF_H
+#endif
diff --git a/jni/ruby/ext/-test-/bug-3662/extconf.rb b/jni/ruby/ext/-test-/bug-3662/extconf.rb
new file mode 100644
index 0000000..7a1b730
--- /dev/null
+++ b/jni/ruby/ext/-test-/bug-3662/extconf.rb
@@ -0,0 +1 @@
+create_makefile("-test-/bug-3662/bug")
diff --git a/jni/ruby/ext/-test-/bug-5832/Makefile b/jni/ruby/ext/-test-/bug-5832/Makefile
new file mode 100644
index 0000000..4717a4a
--- /dev/null
+++ b/jni/ruby/ext/-test-/bug-5832/Makefile
@@ -0,0 +1,267 @@
+
+SHELL = /bin/sh
+
+# V=0 quiet, V=1 verbose. other values don't work.
+V = 0
+Q1 = $(V:1=)
+Q = $(Q1:0=@)
+ECHO1 = $(V:1=@:)
+ECHO = $(ECHO1:0=@echo)
+NULLCMD = :
+
+#### Start of system configuration section. ####
+top_srcdir = $(topdir)/.
+srcdir = $(top_srcdir)/ext/-test-/bug-5832
+topdir = ../../..
+hdrdir = $(top_srcdir)/include
+arch_hdrdir = $(extout)/include/$(arch)
+PATH_SEPARATOR = :
+VPATH = $(srcdir):$(arch_hdrdir)/ruby:$(hdrdir)/ruby
+RUBYLIB =
+RUBYOPT = -
+prefix = $(DESTDIR)/usr/local
+rubysitearchprefix = $(rubylibprefix)/$(sitearch)
+rubyarchprefix = $(rubylibprefix)/$(arch)
+rubylibprefix = $(libdir)/$(RUBY_BASE_NAME)
+exec_prefix = $(prefix)
+vendorarchhdrdir = $(vendorhdrdir)/$(sitearch)
+sitearchhdrdir = $(sitehdrdir)/$(sitearch)
+rubyarchhdrdir = $(rubyhdrdir)/$(arch)
+vendorhdrdir = $(rubyhdrdir)/vendor_ruby
+sitehdrdir = $(rubyhdrdir)/site_ruby
+rubyhdrdir = $(includedir)/$(RUBY_VERSION_NAME)
+vendorarchdir = $(vendorlibdir)/$(sitearch)
+vendorlibdir = $(vendordir)/$(ruby_version)
+vendordir = $(rubylibprefix)/vendor_ruby
+sitearchdir = $(sitelibdir)/$(sitearch)
+sitelibdir = $(sitedir)/$(ruby_version)
+sitedir = $(rubylibprefix)/site_ruby
+rubyarchdir = $(rubylibdir)/$(arch)
+rubylibdir = $(rubylibprefix)/$(ruby_version)
+sitearchincludedir = $(includedir)/$(sitearch)
+archincludedir = $(includedir)/$(arch)
+sitearchlibdir = $(libdir)/$(sitearch)
+archlibdir = $(libdir)/$(arch)
+ridir = $(datarootdir)/$(RI_BASE_NAME)
+mandir = $(datarootdir)/man
+localedir = $(datarootdir)/locale
+libdir = $(exec_prefix)/lib
+psdir = $(docdir)
+pdfdir = $(docdir)
+dvidir = $(docdir)
+htmldir = $(docdir)
+infodir = $(datarootdir)/info
+docdir = $(datarootdir)/doc/$(PACKAGE)
+oldincludedir = $(DESTDIR)/usr/include
+includedir = $(prefix)/include
+localstatedir = $(prefix)/var
+sharedstatedir = $(prefix)/com
+sysconfdir = $(prefix)/etc
+datadir = $(datarootdir)
+datarootdir = $(prefix)/share
+libexecdir = $(exec_prefix)/libexec
+sbindir = $(exec_prefix)/sbin
+bindir = $(exec_prefix)/bin
+archdir = $(rubyarchdir)
+
+
+CC = gcc
+CXX = g++
+LIBRUBY = $(LIBRUBY_SO)
+LIBRUBY_A = lib$(RUBY_SO_NAME)-static.a
+LIBRUBYARG_SHARED = -Wl,-R$(libdir) -L$(libdir) -l$(RUBY_SO_NAME)
+LIBRUBYARG_STATIC = -Wl,-R$(libdir) -L$(libdir) -l$(RUBY_SO_NAME)-static
+empty =
+OUTFLAG = -o $(empty)
+COUTFLAG = -o $(empty)
+
+RUBY_EXTCONF_H = extconf.h
+cflags = $(optflags) $(debugflags) $(warnflags)
+optflags = -O3 -fno-fast-math
+debugflags = -ggdb3
+warnflags = -Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wunused-variable -Wpointer-arith -Wwrite-strings -Wdeclaration-after-statement -Wimplicit-function-declaration -Wdeprecated-declarations -Wno-packed-bitfield-compat
+CCDLFLAGS = -fPIC
+CFLAGS = $(CCDLFLAGS) $(cflags) -fPIC $(ARCH_FLAG)
+INCFLAGS = -I. -I$(arch_hdrdir) -I$(hdrdir) -I$(srcdir)
+DEFS =
+CPPFLAGS = -DRUBY_EXTCONF_H=\"$(RUBY_EXTCONF_H)\" $(DEFS) $(cppflags)
+CXXFLAGS = $(CCDLFLAGS) $(cxxflags) $(ARCH_FLAG)
+ldflags = -L. -fstack-protector -rdynamic -Wl,-export-dynamic
+dldflags =
+ARCH_FLAG =
+DLDFLAGS = $(ldflags) $(dldflags) $(ARCH_FLAG)
+LDSHARED = $(CC) -shared
+LDSHAREDXX = $(CXX) -shared
+AR = ar
+EXEEXT =
+
+RUBY_INSTALL_NAME = $(RUBY_BASE_NAME)
+RUBY_SO_NAME = ruby
+RUBYW_INSTALL_NAME =
+RUBY_VERSION_NAME = $(RUBY_BASE_NAME)-$(ruby_version)
+RUBYW_BASE_NAME = rubyw
+RUBY_BASE_NAME = ruby
+
+arch = x86_64-linux
+sitearch = $(arch)
+ruby_version = 2.2.0
+ruby = $(topdir)/miniruby -I'$(topdir)' -I'$(top_srcdir)/lib' -I'$(extout)/$(arch)' -I'$(extout)/common'
+RUBY = $(ruby)
+ruby_headers = $(hdrdir)/ruby.h $(hdrdir)/ruby/ruby.h $(hdrdir)/ruby/defines.h $(hdrdir)/ruby/missing.h $(hdrdir)/ruby/intern.h $(hdrdir)/ruby/st.h $(hdrdir)/ruby/subst.h $(arch_hdrdir)/ruby/config.h $(RUBY_EXTCONF_H)
+
+RM = rm -f
+RM_RF = $(RUBY) -run -e rm -- -rf
+RMDIRS = rmdir --ignore-fail-on-non-empty -p
+MAKEDIRS = /bin/mkdir -p
+INSTALL = /usr/bin/install -c
+INSTALL_PROG = $(INSTALL) -m 0755
+INSTALL_DATA = $(INSTALL) -m 644
+COPY = cp
+TOUCH = exit >
+
+#### End of system configuration section. ####
+
+preload =
+
+libpath = . $(topdir)
+LIBPATH = -L. -L$(topdir)
+DEFFILE =
+
+CLEANFILES = mkmf.log
+DISTCLEANFILES =
+DISTCLEANDIRS =
+
+extout = $(topdir)/.ext
+extout_prefix = $(extout)$(target_prefix)/
+target_prefix = /-test-/bug-5832
+LOCAL_LIBS =
+LIBS = $(LIBRUBYARG_SHARED) -lpthread -lgmp -ldl -lcrypt -lm -lc
+ORIG_SRCS = bug.c
+SRCS = $(ORIG_SRCS)
+OBJS = bug.o
+HDRS = $(srcdir)/extconf.h
+TARGET = bug
+TARGET_NAME = bug
+TARGET_ENTRY = Init_$(TARGET_NAME)
+DLLIB = $(TARGET).so
+EXTSTATIC =
+STATIC_LIB = $(TARGET).a
+
+TIMESTAMP_DIR = $(extout)/.timestamp
+BINDIR = $(extout)/bin
+RUBYCOMMONDIR = $(extout)/common
+RUBYLIBDIR = $(RUBYCOMMONDIR)$(target_prefix)
+RUBYARCHDIR = $(extout)/$(arch)$(target_prefix)
+HDRDIR = $(extout)/include/ruby$(target_prefix)
+ARCHHDRDIR = $(extout)/include/$(arch)/ruby$(target_prefix)
+
+TARGET_SO = $(RUBYARCHDIR)/$(DLLIB)
+CLEANLIBS = $(RUBYARCHDIR)/$(TARGET).so
+CLEANOBJS = *.o *.bak
+
+all: install
+static: all
+.PHONY: all install static install-so install-rb
+.PHONY: clean clean-so clean-static clean-rb
+
+clean-static::
+clean-rb-default::
+clean-rb::
+clean-so::
+clean: clean-so clean-static clean-rb-default clean-rb
+ -$(Q)$(RM) $(CLEANLIBS) $(CLEANOBJS) $(CLEANFILES) .*.time
+
+distclean-rb-default::
+distclean-rb::
+distclean-so::
+distclean-static::
+distclean: clean distclean-so distclean-static distclean-rb-default distclean-rb
+ -$(Q)$(RM) Makefile $(RUBY_EXTCONF_H) conftest.* mkmf.log
+ -$(Q)$(RM) core ruby$(EXEEXT) *~ $(DISTCLEANFILES)
+ -$(Q)$(RMDIRS) $(DISTCLEANDIRS) 2> /dev/null || true
+
+realclean: distclean
+install: install-so install-rb
+
+install-so: $(RUBYARCHDIR)/$(DLLIB)
+clean-so::
+ -$(Q)$(RM) $(RUBYARCHDIR)/$(DLLIB)
+ -$(Q)$(RMDIRS) $(RUBYARCHDIR) 2> /dev/null || true
+clean-static::
+ -$(Q)$(RM) $(STATIC_LIB)
+install-rb: pre-install-rb install-rb-default
+install-rb-default: pre-install-rb-default
+pre-install-rb: Makefile
+pre-install-rb-default: Makefile
+pre-install-rb-default:
+ @$(NULLCMD)
+$(TIMESTAMP_DIR)/.RUBYARCHDIR.-.-test-.-.bug-5832.time:
+ $(Q) $(MAKEDIRS) $(@D) $(RUBYARCHDIR)
+ $(Q) $(TOUCH) $@
+
+site-install: site-install-so site-install-rb
+site-install-so: install-so
+site-install-rb: install-rb
+
+.SUFFIXES: .c .m .cc .mm .cxx .cpp .o .S
+
+.cc.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<
+
+.cc.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -S $<
+
+.mm.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<
+
+.mm.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -S $<
+
+.cxx.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<
+
+.cxx.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -S $<
+
+.cpp.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<
+
+.cpp.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -S $<
+
+.c.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -c $<
+
+.c.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -S $<
+
+.m.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -c $<
+
+.m.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -S $<
+
+$(RUBYARCHDIR)/$(DLLIB): $(OBJS) Makefile $(TIMESTAMP_DIR)/.RUBYARCHDIR.-.-test-.-.bug-5832.time
+ $(ECHO) linking shared-object -test-/bug-5832/$(DLLIB)
+ -$(Q)$(RM) $(@)
+ $(Q) $(LDSHARED) -o $@ $(OBJS) $(LIBPATH) $(DLDFLAGS) $(LOCAL_LIBS) $(LIBS)
+
+$(STATIC_LIB): $(OBJS)
+ -$(Q)$(RM) $(@)
+ $(ECHO) linking static-library $(@)
+ $(Q) $(AR) cru $@ $(OBJS)
+ -$(Q)ranlib $(@) 2> /dev/null || true
+
+$(OBJS): $(HDRS) $(ruby_headers)
diff --git a/jni/ruby/ext/-test-/bug-5832/bug.c b/jni/ruby/ext/-test-/bug-5832/bug.c
new file mode 100644
index 0000000..67be584
--- /dev/null
+++ b/jni/ruby/ext/-test-/bug-5832/bug.c
@@ -0,0 +1,14 @@
+#include <ruby.h>
+
+static VALUE
+bug_funcall_callback(VALUE self, VALUE obj)
+{
+ return rb_funcall(obj, rb_intern("callback"), 0);
+}
+
+void
+Init_bug(void)
+{
+ VALUE mBug = rb_define_module("Bug");
+ rb_define_module_function(mBug, "funcall_callback", bug_funcall_callback, 1);
+}
diff --git a/jni/ruby/ext/-test-/bug-5832/extconf.h b/jni/ruby/ext/-test-/bug-5832/extconf.h
new file mode 100644
index 0000000..cda0cc8
--- /dev/null
+++ b/jni/ruby/ext/-test-/bug-5832/extconf.h
@@ -0,0 +1,3 @@
+#ifndef EXTCONF_H
+#define EXTCONF_H
+#endif
diff --git a/jni/ruby/ext/-test-/bug-5832/extconf.rb b/jni/ruby/ext/-test-/bug-5832/extconf.rb
new file mode 100644
index 0000000..55a4b7d
--- /dev/null
+++ b/jni/ruby/ext/-test-/bug-5832/extconf.rb
@@ -0,0 +1 @@
+create_makefile("-test-/bug-5832/bug")
diff --git a/jni/ruby/ext/-test-/bug_reporter/Makefile b/jni/ruby/ext/-test-/bug_reporter/Makefile
new file mode 100644
index 0000000..91e159e
--- /dev/null
+++ b/jni/ruby/ext/-test-/bug_reporter/Makefile
@@ -0,0 +1,267 @@
+
+SHELL = /bin/sh
+
+# V=0 quiet, V=1 verbose. other values don't work.
+V = 0
+Q1 = $(V:1=)
+Q = $(Q1:0=@)
+ECHO1 = $(V:1=@:)
+ECHO = $(ECHO1:0=@echo)
+NULLCMD = :
+
+#### Start of system configuration section. ####
+top_srcdir = $(topdir)/.
+srcdir = $(top_srcdir)/ext/-test-/bug_reporter
+topdir = ../../..
+hdrdir = $(top_srcdir)/include
+arch_hdrdir = $(extout)/include/$(arch)
+PATH_SEPARATOR = :
+VPATH = $(srcdir):$(arch_hdrdir)/ruby:$(hdrdir)/ruby
+RUBYLIB =
+RUBYOPT = -
+prefix = $(DESTDIR)/usr/local
+rubysitearchprefix = $(rubylibprefix)/$(sitearch)
+rubyarchprefix = $(rubylibprefix)/$(arch)
+rubylibprefix = $(libdir)/$(RUBY_BASE_NAME)
+exec_prefix = $(prefix)
+vendorarchhdrdir = $(vendorhdrdir)/$(sitearch)
+sitearchhdrdir = $(sitehdrdir)/$(sitearch)
+rubyarchhdrdir = $(rubyhdrdir)/$(arch)
+vendorhdrdir = $(rubyhdrdir)/vendor_ruby
+sitehdrdir = $(rubyhdrdir)/site_ruby
+rubyhdrdir = $(includedir)/$(RUBY_VERSION_NAME)
+vendorarchdir = $(vendorlibdir)/$(sitearch)
+vendorlibdir = $(vendordir)/$(ruby_version)
+vendordir = $(rubylibprefix)/vendor_ruby
+sitearchdir = $(sitelibdir)/$(sitearch)
+sitelibdir = $(sitedir)/$(ruby_version)
+sitedir = $(rubylibprefix)/site_ruby
+rubyarchdir = $(rubylibdir)/$(arch)
+rubylibdir = $(rubylibprefix)/$(ruby_version)
+sitearchincludedir = $(includedir)/$(sitearch)
+archincludedir = $(includedir)/$(arch)
+sitearchlibdir = $(libdir)/$(sitearch)
+archlibdir = $(libdir)/$(arch)
+ridir = $(datarootdir)/$(RI_BASE_NAME)
+mandir = $(datarootdir)/man
+localedir = $(datarootdir)/locale
+libdir = $(exec_prefix)/lib
+psdir = $(docdir)
+pdfdir = $(docdir)
+dvidir = $(docdir)
+htmldir = $(docdir)
+infodir = $(datarootdir)/info
+docdir = $(datarootdir)/doc/$(PACKAGE)
+oldincludedir = $(DESTDIR)/usr/include
+includedir = $(prefix)/include
+localstatedir = $(prefix)/var
+sharedstatedir = $(prefix)/com
+sysconfdir = $(prefix)/etc
+datadir = $(datarootdir)
+datarootdir = $(prefix)/share
+libexecdir = $(exec_prefix)/libexec
+sbindir = $(exec_prefix)/sbin
+bindir = $(exec_prefix)/bin
+archdir = $(rubyarchdir)
+
+
+CC = gcc
+CXX = g++
+LIBRUBY = $(LIBRUBY_SO)
+LIBRUBY_A = lib$(RUBY_SO_NAME)-static.a
+LIBRUBYARG_SHARED = -Wl,-R$(libdir) -L$(libdir) -l$(RUBY_SO_NAME)
+LIBRUBYARG_STATIC = -Wl,-R$(libdir) -L$(libdir) -l$(RUBY_SO_NAME)-static
+empty =
+OUTFLAG = -o $(empty)
+COUTFLAG = -o $(empty)
+
+RUBY_EXTCONF_H = extconf.h
+cflags = $(optflags) $(debugflags) $(warnflags)
+optflags = -O3 -fno-fast-math
+debugflags = -ggdb3
+warnflags = -Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wunused-variable -Wpointer-arith -Wwrite-strings -Wdeclaration-after-statement -Wimplicit-function-declaration -Wdeprecated-declarations -Wno-packed-bitfield-compat
+CCDLFLAGS = -fPIC
+CFLAGS = $(CCDLFLAGS) $(cflags) -fPIC $(ARCH_FLAG)
+INCFLAGS = -I. -I$(arch_hdrdir) -I$(hdrdir) -I$(srcdir)
+DEFS =
+CPPFLAGS = -DRUBY_EXTCONF_H=\"$(RUBY_EXTCONF_H)\" $(DEFS) $(cppflags)
+CXXFLAGS = $(CCDLFLAGS) $(cxxflags) $(ARCH_FLAG)
+ldflags = -L. -fstack-protector -rdynamic -Wl,-export-dynamic
+dldflags =
+ARCH_FLAG =
+DLDFLAGS = $(ldflags) $(dldflags) $(ARCH_FLAG)
+LDSHARED = $(CC) -shared
+LDSHAREDXX = $(CXX) -shared
+AR = ar
+EXEEXT =
+
+RUBY_INSTALL_NAME = $(RUBY_BASE_NAME)
+RUBY_SO_NAME = ruby
+RUBYW_INSTALL_NAME =
+RUBY_VERSION_NAME = $(RUBY_BASE_NAME)-$(ruby_version)
+RUBYW_BASE_NAME = rubyw
+RUBY_BASE_NAME = ruby
+
+arch = x86_64-linux
+sitearch = $(arch)
+ruby_version = 2.2.0
+ruby = $(topdir)/miniruby -I'$(topdir)' -I'$(top_srcdir)/lib' -I'$(extout)/$(arch)' -I'$(extout)/common'
+RUBY = $(ruby)
+ruby_headers = $(hdrdir)/ruby.h $(hdrdir)/ruby/ruby.h $(hdrdir)/ruby/defines.h $(hdrdir)/ruby/missing.h $(hdrdir)/ruby/intern.h $(hdrdir)/ruby/st.h $(hdrdir)/ruby/subst.h $(arch_hdrdir)/ruby/config.h $(RUBY_EXTCONF_H)
+
+RM = rm -f
+RM_RF = $(RUBY) -run -e rm -- -rf
+RMDIRS = rmdir --ignore-fail-on-non-empty -p
+MAKEDIRS = /bin/mkdir -p
+INSTALL = /usr/bin/install -c
+INSTALL_PROG = $(INSTALL) -m 0755
+INSTALL_DATA = $(INSTALL) -m 644
+COPY = cp
+TOUCH = exit >
+
+#### End of system configuration section. ####
+
+preload =
+
+libpath = . $(topdir)
+LIBPATH = -L. -L$(topdir)
+DEFFILE =
+
+CLEANFILES = mkmf.log
+DISTCLEANFILES =
+DISTCLEANDIRS =
+
+extout = $(topdir)/.ext
+extout_prefix = $(extout)$(target_prefix)/
+target_prefix = /-test-/bug_reporter
+LOCAL_LIBS =
+LIBS = $(LIBRUBYARG_SHARED) -lpthread -lgmp -ldl -lcrypt -lm -lc
+ORIG_SRCS = bug_reporter.c
+SRCS = $(ORIG_SRCS)
+OBJS = bug_reporter.o
+HDRS = $(srcdir)/extconf.h
+TARGET = bug_reporter
+TARGET_NAME = bug_reporter
+TARGET_ENTRY = Init_$(TARGET_NAME)
+DLLIB = $(TARGET).so
+EXTSTATIC =
+STATIC_LIB = $(TARGET).a
+
+TIMESTAMP_DIR = $(extout)/.timestamp
+BINDIR = $(extout)/bin
+RUBYCOMMONDIR = $(extout)/common
+RUBYLIBDIR = $(RUBYCOMMONDIR)$(target_prefix)
+RUBYARCHDIR = $(extout)/$(arch)$(target_prefix)
+HDRDIR = $(extout)/include/ruby$(target_prefix)
+ARCHHDRDIR = $(extout)/include/$(arch)/ruby$(target_prefix)
+
+TARGET_SO = $(RUBYARCHDIR)/$(DLLIB)
+CLEANLIBS = $(RUBYARCHDIR)/$(TARGET).so
+CLEANOBJS = *.o *.bak
+
+all: install
+static: all
+.PHONY: all install static install-so install-rb
+.PHONY: clean clean-so clean-static clean-rb
+
+clean-static::
+clean-rb-default::
+clean-rb::
+clean-so::
+clean: clean-so clean-static clean-rb-default clean-rb
+ -$(Q)$(RM) $(CLEANLIBS) $(CLEANOBJS) $(CLEANFILES) .*.time
+
+distclean-rb-default::
+distclean-rb::
+distclean-so::
+distclean-static::
+distclean: clean distclean-so distclean-static distclean-rb-default distclean-rb
+ -$(Q)$(RM) Makefile $(RUBY_EXTCONF_H) conftest.* mkmf.log
+ -$(Q)$(RM) core ruby$(EXEEXT) *~ $(DISTCLEANFILES)
+ -$(Q)$(RMDIRS) $(DISTCLEANDIRS) 2> /dev/null || true
+
+realclean: distclean
+install: install-so install-rb
+
+install-so: $(RUBYARCHDIR)/$(DLLIB)
+clean-so::
+ -$(Q)$(RM) $(RUBYARCHDIR)/$(DLLIB)
+ -$(Q)$(RMDIRS) $(RUBYARCHDIR) 2> /dev/null || true
+clean-static::
+ -$(Q)$(RM) $(STATIC_LIB)
+install-rb: pre-install-rb install-rb-default
+install-rb-default: pre-install-rb-default
+pre-install-rb: Makefile
+pre-install-rb-default: Makefile
+pre-install-rb-default:
+ @$(NULLCMD)
+$(TIMESTAMP_DIR)/.RUBYARCHDIR.-.-test-.-.bug_reporter.time:
+ $(Q) $(MAKEDIRS) $(@D) $(RUBYARCHDIR)
+ $(Q) $(TOUCH) $@
+
+site-install: site-install-so site-install-rb
+site-install-so: install-so
+site-install-rb: install-rb
+
+.SUFFIXES: .c .m .cc .mm .cxx .cpp .o .S
+
+.cc.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<
+
+.cc.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -S $<
+
+.mm.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<
+
+.mm.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -S $<
+
+.cxx.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<
+
+.cxx.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -S $<
+
+.cpp.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<
+
+.cpp.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -S $<
+
+.c.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -c $<
+
+.c.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -S $<
+
+.m.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -c $<
+
+.m.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -S $<
+
+$(RUBYARCHDIR)/$(DLLIB): $(OBJS) Makefile $(TIMESTAMP_DIR)/.RUBYARCHDIR.-.-test-.-.bug_reporter.time
+ $(ECHO) linking shared-object -test-/bug_reporter/$(DLLIB)
+ -$(Q)$(RM) $(@)
+ $(Q) $(LDSHARED) -o $@ $(OBJS) $(LIBPATH) $(DLDFLAGS) $(LOCAL_LIBS) $(LIBS)
+
+$(STATIC_LIB): $(OBJS)
+ -$(Q)$(RM) $(@)
+ $(ECHO) linking static-library $(@)
+ $(Q) $(AR) cru $@ $(OBJS)
+ -$(Q)ranlib $(@) 2> /dev/null || true
+
+$(OBJS): $(HDRS) $(ruby_headers)
diff --git a/jni/ruby/ext/-test-/bug_reporter/bug_reporter.c b/jni/ruby/ext/-test-/bug_reporter/bug_reporter.c
new file mode 100644
index 0000000..e9ea9e3
--- /dev/null
+++ b/jni/ruby/ext/-test-/bug_reporter/bug_reporter.c
@@ -0,0 +1,24 @@
+#include <ruby.h>
+#include <stdio.h>
+
+int rb_bug_reporter_add(void (*func)(FILE *, void *), void *data);
+
+static void
+sample_bug_reporter(FILE *out, void *ptr)
+{
+ int n = (int)(uintptr_t)ptr;
+ fprintf(out, "Sample bug reporter: %d\n", n);
+}
+
+static VALUE
+register_sample_bug_reporter(VALUE self, VALUE obj)
+{
+ rb_bug_reporter_add(sample_bug_reporter, (void *)(uintptr_t)NUM2INT(obj));
+ return Qnil;
+}
+
+void
+Init_bug_reporter(void)
+{
+ rb_define_global_function("register_sample_bug_reporter", register_sample_bug_reporter, 1);
+}
diff --git a/jni/ruby/ext/-test-/bug_reporter/extconf.h b/jni/ruby/ext/-test-/bug_reporter/extconf.h
new file mode 100644
index 0000000..cda0cc8
--- /dev/null
+++ b/jni/ruby/ext/-test-/bug_reporter/extconf.h
@@ -0,0 +1,3 @@
+#ifndef EXTCONF_H
+#define EXTCONF_H
+#endif
diff --git a/jni/ruby/ext/-test-/bug_reporter/extconf.rb b/jni/ruby/ext/-test-/bug_reporter/extconf.rb
new file mode 100644
index 0000000..0fccd81
--- /dev/null
+++ b/jni/ruby/ext/-test-/bug_reporter/extconf.rb
@@ -0,0 +1 @@
+create_makefile("-test-/bug_reporter/bug_reporter")
diff --git a/jni/ruby/ext/-test-/class/Makefile b/jni/ruby/ext/-test-/class/Makefile
new file mode 100644
index 0000000..dc7268e
--- /dev/null
+++ b/jni/ruby/ext/-test-/class/Makefile
@@ -0,0 +1,267 @@
+
+SHELL = /bin/sh
+
+# V=0 quiet, V=1 verbose. other values don't work.
+V = 0
+Q1 = $(V:1=)
+Q = $(Q1:0=@)
+ECHO1 = $(V:1=@:)
+ECHO = $(ECHO1:0=@echo)
+NULLCMD = :
+
+#### Start of system configuration section. ####
+top_srcdir = $(topdir)/.
+srcdir = $(top_srcdir)/ext/-test-/class
+topdir = ../../..
+hdrdir = $(top_srcdir)/include
+arch_hdrdir = $(extout)/include/$(arch)
+PATH_SEPARATOR = :
+VPATH = $(srcdir):$(arch_hdrdir)/ruby:$(hdrdir)/ruby
+RUBYLIB =
+RUBYOPT = -
+prefix = $(DESTDIR)/usr/local
+rubysitearchprefix = $(rubylibprefix)/$(sitearch)
+rubyarchprefix = $(rubylibprefix)/$(arch)
+rubylibprefix = $(libdir)/$(RUBY_BASE_NAME)
+exec_prefix = $(prefix)
+vendorarchhdrdir = $(vendorhdrdir)/$(sitearch)
+sitearchhdrdir = $(sitehdrdir)/$(sitearch)
+rubyarchhdrdir = $(rubyhdrdir)/$(arch)
+vendorhdrdir = $(rubyhdrdir)/vendor_ruby
+sitehdrdir = $(rubyhdrdir)/site_ruby
+rubyhdrdir = $(includedir)/$(RUBY_VERSION_NAME)
+vendorarchdir = $(vendorlibdir)/$(sitearch)
+vendorlibdir = $(vendordir)/$(ruby_version)
+vendordir = $(rubylibprefix)/vendor_ruby
+sitearchdir = $(sitelibdir)/$(sitearch)
+sitelibdir = $(sitedir)/$(ruby_version)
+sitedir = $(rubylibprefix)/site_ruby
+rubyarchdir = $(rubylibdir)/$(arch)
+rubylibdir = $(rubylibprefix)/$(ruby_version)
+sitearchincludedir = $(includedir)/$(sitearch)
+archincludedir = $(includedir)/$(arch)
+sitearchlibdir = $(libdir)/$(sitearch)
+archlibdir = $(libdir)/$(arch)
+ridir = $(datarootdir)/$(RI_BASE_NAME)
+mandir = $(datarootdir)/man
+localedir = $(datarootdir)/locale
+libdir = $(exec_prefix)/lib
+psdir = $(docdir)
+pdfdir = $(docdir)
+dvidir = $(docdir)
+htmldir = $(docdir)
+infodir = $(datarootdir)/info
+docdir = $(datarootdir)/doc/$(PACKAGE)
+oldincludedir = $(DESTDIR)/usr/include
+includedir = $(prefix)/include
+localstatedir = $(prefix)/var
+sharedstatedir = $(prefix)/com
+sysconfdir = $(prefix)/etc
+datadir = $(datarootdir)
+datarootdir = $(prefix)/share
+libexecdir = $(exec_prefix)/libexec
+sbindir = $(exec_prefix)/sbin
+bindir = $(exec_prefix)/bin
+archdir = $(rubyarchdir)
+
+
+CC = gcc
+CXX = g++
+LIBRUBY = $(LIBRUBY_SO)
+LIBRUBY_A = lib$(RUBY_SO_NAME)-static.a
+LIBRUBYARG_SHARED = -Wl,-R$(libdir) -L$(libdir) -l$(RUBY_SO_NAME)
+LIBRUBYARG_STATIC = -Wl,-R$(libdir) -L$(libdir) -l$(RUBY_SO_NAME)-static
+empty =
+OUTFLAG = -o $(empty)
+COUTFLAG = -o $(empty)
+
+RUBY_EXTCONF_H = extconf.h
+cflags = $(optflags) $(debugflags) $(warnflags)
+optflags = -O3 -fno-fast-math
+debugflags = -ggdb3
+warnflags = -Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wunused-variable -Wpointer-arith -Wwrite-strings -Wdeclaration-after-statement -Wimplicit-function-declaration -Wdeprecated-declarations -Wno-packed-bitfield-compat
+CCDLFLAGS = -fPIC
+CFLAGS = $(CCDLFLAGS) $(cflags) -fPIC $(ARCH_FLAG)
+INCFLAGS = -I. -I$(arch_hdrdir) -I$(hdrdir) -I$(srcdir) -I$(topdir) -I$(top_srcdir)
+DEFS =
+CPPFLAGS = -DRUBY_EXTCONF_H=\"$(RUBY_EXTCONF_H)\" $(DEFS) $(cppflags)
+CXXFLAGS = $(CCDLFLAGS) $(cxxflags) $(ARCH_FLAG)
+ldflags = -L. -fstack-protector -rdynamic -Wl,-export-dynamic
+dldflags =
+ARCH_FLAG =
+DLDFLAGS = $(ldflags) $(dldflags) $(ARCH_FLAG)
+LDSHARED = $(CC) -shared
+LDSHAREDXX = $(CXX) -shared
+AR = ar
+EXEEXT =
+
+RUBY_INSTALL_NAME = $(RUBY_BASE_NAME)
+RUBY_SO_NAME = ruby
+RUBYW_INSTALL_NAME =
+RUBY_VERSION_NAME = $(RUBY_BASE_NAME)-$(ruby_version)
+RUBYW_BASE_NAME = rubyw
+RUBY_BASE_NAME = ruby
+
+arch = x86_64-linux
+sitearch = $(arch)
+ruby_version = 2.2.0
+ruby = $(topdir)/miniruby -I'$(topdir)' -I'$(top_srcdir)/lib' -I'$(extout)/$(arch)' -I'$(extout)/common'
+RUBY = $(ruby)
+ruby_headers = $(hdrdir)/ruby.h $(hdrdir)/ruby/ruby.h $(hdrdir)/ruby/defines.h $(hdrdir)/ruby/missing.h $(hdrdir)/ruby/intern.h $(hdrdir)/ruby/st.h $(hdrdir)/ruby/subst.h $(arch_hdrdir)/ruby/config.h $(RUBY_EXTCONF_H)
+
+RM = rm -f
+RM_RF = $(RUBY) -run -e rm -- -rf
+RMDIRS = rmdir --ignore-fail-on-non-empty -p
+MAKEDIRS = /bin/mkdir -p
+INSTALL = /usr/bin/install -c
+INSTALL_PROG = $(INSTALL) -m 0755
+INSTALL_DATA = $(INSTALL) -m 644
+COPY = cp
+TOUCH = exit >
+
+#### End of system configuration section. ####
+
+preload =
+
+libpath = . $(topdir)
+LIBPATH = -L. -L$(topdir)
+DEFFILE =
+
+CLEANFILES = mkmf.log
+DISTCLEANFILES =
+DISTCLEANDIRS =
+
+extout = $(topdir)/.ext
+extout_prefix = $(extout)$(target_prefix)/
+target_prefix = /-test-
+LOCAL_LIBS =
+LIBS = $(LIBRUBYARG_SHARED) -lpthread -lgmp -ldl -lcrypt -lm -lc
+ORIG_SRCS = init.c class2name.c
+SRCS = $(ORIG_SRCS)
+OBJS = init.o class2name.o
+HDRS = $(srcdir)/extconf.h
+TARGET = class
+TARGET_NAME = class
+TARGET_ENTRY = Init_$(TARGET_NAME)
+DLLIB = $(TARGET).so
+EXTSTATIC =
+STATIC_LIB = $(TARGET).a
+
+TIMESTAMP_DIR = $(extout)/.timestamp
+BINDIR = $(extout)/bin
+RUBYCOMMONDIR = $(extout)/common
+RUBYLIBDIR = $(RUBYCOMMONDIR)$(target_prefix)
+RUBYARCHDIR = $(extout)/$(arch)$(target_prefix)
+HDRDIR = $(extout)/include/ruby$(target_prefix)
+ARCHHDRDIR = $(extout)/include/$(arch)/ruby$(target_prefix)
+
+TARGET_SO = $(RUBYARCHDIR)/$(DLLIB)
+CLEANLIBS = $(RUBYARCHDIR)/$(TARGET).so
+CLEANOBJS = *.o *.bak
+
+all: install
+static: all
+.PHONY: all install static install-so install-rb
+.PHONY: clean clean-so clean-static clean-rb
+
+clean-static::
+clean-rb-default::
+clean-rb::
+clean-so::
+clean: clean-so clean-static clean-rb-default clean-rb
+ -$(Q)$(RM) $(CLEANLIBS) $(CLEANOBJS) $(CLEANFILES) .*.time
+
+distclean-rb-default::
+distclean-rb::
+distclean-so::
+distclean-static::
+distclean: clean distclean-so distclean-static distclean-rb-default distclean-rb
+ -$(Q)$(RM) Makefile $(RUBY_EXTCONF_H) conftest.* mkmf.log
+ -$(Q)$(RM) core ruby$(EXEEXT) *~ $(DISTCLEANFILES)
+ -$(Q)$(RMDIRS) $(DISTCLEANDIRS) 2> /dev/null || true
+
+realclean: distclean
+install: install-so install-rb
+
+install-so: $(RUBYARCHDIR)/$(DLLIB)
+clean-so::
+ -$(Q)$(RM) $(RUBYARCHDIR)/$(DLLIB)
+ -$(Q)$(RMDIRS) $(RUBYARCHDIR) 2> /dev/null || true
+clean-static::
+ -$(Q)$(RM) $(STATIC_LIB)
+install-rb: pre-install-rb install-rb-default
+install-rb-default: pre-install-rb-default
+pre-install-rb: Makefile
+pre-install-rb-default: Makefile
+pre-install-rb-default:
+ @$(NULLCMD)
+$(TIMESTAMP_DIR)/.RUBYARCHDIR.-.-test-.time:
+ $(Q) $(MAKEDIRS) $(@D) $(RUBYARCHDIR)
+ $(Q) $(TOUCH) $@
+
+site-install: site-install-so site-install-rb
+site-install-so: install-so
+site-install-rb: install-rb
+
+.SUFFIXES: .c .m .cc .mm .cxx .cpp .o .S
+
+.cc.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<
+
+.cc.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -S $<
+
+.mm.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<
+
+.mm.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -S $<
+
+.cxx.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<
+
+.cxx.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -S $<
+
+.cpp.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<
+
+.cpp.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -S $<
+
+.c.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -c $<
+
+.c.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -S $<
+
+.m.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -c $<
+
+.m.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -S $<
+
+$(RUBYARCHDIR)/$(DLLIB): $(OBJS) Makefile $(TIMESTAMP_DIR)/.RUBYARCHDIR.-.-test-.time
+ $(ECHO) linking shared-object -test-/$(DLLIB)
+ -$(Q)$(RM) $(@)
+ $(Q) $(LDSHARED) -o $@ $(OBJS) $(LIBPATH) $(DLDFLAGS) $(LOCAL_LIBS) $(LIBS)
+
+$(STATIC_LIB): $(OBJS)
+ -$(Q)$(RM) $(@)
+ $(ECHO) linking static-library $(@)
+ $(Q) $(AR) cru $@ $(OBJS)
+ -$(Q)ranlib $(@) 2> /dev/null || true
+
+$(OBJS): $(HDRS) $(ruby_headers)
diff --git a/jni/ruby/ext/-test-/class/class2name.c b/jni/ruby/ext/-test-/class/class2name.c
new file mode 100644
index 0000000..c48df6f
--- /dev/null
+++ b/jni/ruby/ext/-test-/class/class2name.c
@@ -0,0 +1,14 @@
+#include <ruby/ruby.h>
+
+static VALUE
+class2name(VALUE self, VALUE klass)
+{
+ const char *name = rb_class2name(klass);
+ return name ? rb_str_new_cstr(name) : Qnil;
+}
+
+void
+Init_class2name(VALUE klass)
+{
+ rb_define_singleton_method(klass, "class2name", class2name, 1);
+}
diff --git a/jni/ruby/ext/-test-/class/extconf.h b/jni/ruby/ext/-test-/class/extconf.h
new file mode 100644
index 0000000..a65666e
--- /dev/null
+++ b/jni/ruby/ext/-test-/class/extconf.h
@@ -0,0 +1,4 @@
+#ifndef EXTCONF_H
+#define EXTCONF_H
+#define TEST_INIT_FUNCS(X) X(class2name)
+#endif
diff --git a/jni/ruby/ext/-test-/class/extconf.rb b/jni/ruby/ext/-test-/class/extconf.rb
new file mode 100644
index 0000000..a07d660
--- /dev/null
+++ b/jni/ruby/ext/-test-/class/extconf.rb
@@ -0,0 +1,7 @@
+$INCFLAGS << " -I$(topdir) -I$(top_srcdir)"
+$srcs = Dir[File.join($srcdir, "*.{#{SRC_EXT.join(%q{,})}}")]
+inits = $srcs.map {|s| File.basename(s, ".*")}
+inits.delete("init")
+inits.map! {|s|"X(#{s})"}
+$defs << "-DTEST_INIT_FUNCS(X)=\"#{inits.join(' ')}\""
+create_makefile("-test-/class")
diff --git a/jni/ruby/ext/-test-/class/init.c b/jni/ruby/ext/-test-/class/init.c
new file mode 100644
index 0000000..ed715c1
--- /dev/null
+++ b/jni/ruby/ext/-test-/class/init.c
@@ -0,0 +1,11 @@
+#include "ruby.h"
+
+#define init(n) {void Init_##n(VALUE mod); Init_##n(mod);}
+
+void
+Init_class(void)
+{
+ VALUE mBug = rb_define_module("Bug");
+ VALUE mod = rb_define_module_under(mBug, "Class");
+ TEST_INIT_FUNCS(init);
+}
diff --git a/jni/ruby/ext/-test-/debug/Makefile b/jni/ruby/ext/-test-/debug/Makefile
new file mode 100644
index 0000000..b191503
--- /dev/null
+++ b/jni/ruby/ext/-test-/debug/Makefile
@@ -0,0 +1,301 @@
+
+SHELL = /bin/sh
+
+# V=0 quiet, V=1 verbose. other values don't work.
+V = 0
+Q1 = $(V:1=)
+Q = $(Q1:0=@)
+ECHO1 = $(V:1=@:)
+ECHO = $(ECHO1:0=@echo)
+NULLCMD = :
+
+#### Start of system configuration section. ####
+top_srcdir = $(topdir)/.
+srcdir = $(top_srcdir)/ext/-test-/debug
+topdir = ../../..
+hdrdir = $(top_srcdir)/include
+arch_hdrdir = $(extout)/include/$(arch)
+PATH_SEPARATOR = :
+VPATH = $(srcdir):$(arch_hdrdir)/ruby:$(hdrdir)/ruby
+RUBYLIB =
+RUBYOPT = -
+prefix = $(DESTDIR)/usr/local
+rubysitearchprefix = $(rubylibprefix)/$(sitearch)
+rubyarchprefix = $(rubylibprefix)/$(arch)
+rubylibprefix = $(libdir)/$(RUBY_BASE_NAME)
+exec_prefix = $(prefix)
+vendorarchhdrdir = $(vendorhdrdir)/$(sitearch)
+sitearchhdrdir = $(sitehdrdir)/$(sitearch)
+rubyarchhdrdir = $(rubyhdrdir)/$(arch)
+vendorhdrdir = $(rubyhdrdir)/vendor_ruby
+sitehdrdir = $(rubyhdrdir)/site_ruby
+rubyhdrdir = $(includedir)/$(RUBY_VERSION_NAME)
+vendorarchdir = $(vendorlibdir)/$(sitearch)
+vendorlibdir = $(vendordir)/$(ruby_version)
+vendordir = $(rubylibprefix)/vendor_ruby
+sitearchdir = $(sitelibdir)/$(sitearch)
+sitelibdir = $(sitedir)/$(ruby_version)
+sitedir = $(rubylibprefix)/site_ruby
+rubyarchdir = $(rubylibdir)/$(arch)
+rubylibdir = $(rubylibprefix)/$(ruby_version)
+sitearchincludedir = $(includedir)/$(sitearch)
+archincludedir = $(includedir)/$(arch)
+sitearchlibdir = $(libdir)/$(sitearch)
+archlibdir = $(libdir)/$(arch)
+ridir = $(datarootdir)/$(RI_BASE_NAME)
+mandir = $(datarootdir)/man
+localedir = $(datarootdir)/locale
+libdir = $(exec_prefix)/lib
+psdir = $(docdir)
+pdfdir = $(docdir)
+dvidir = $(docdir)
+htmldir = $(docdir)
+infodir = $(datarootdir)/info
+docdir = $(datarootdir)/doc/$(PACKAGE)
+oldincludedir = $(DESTDIR)/usr/include
+includedir = $(prefix)/include
+localstatedir = $(prefix)/var
+sharedstatedir = $(prefix)/com
+sysconfdir = $(prefix)/etc
+datadir = $(datarootdir)
+datarootdir = $(prefix)/share
+libexecdir = $(exec_prefix)/libexec
+sbindir = $(exec_prefix)/sbin
+bindir = $(exec_prefix)/bin
+archdir = $(rubyarchdir)
+
+
+CC = gcc
+CXX = g++
+LIBRUBY = $(LIBRUBY_SO)
+LIBRUBY_A = lib$(RUBY_SO_NAME)-static.a
+LIBRUBYARG_SHARED = -Wl,-R$(libdir) -L$(libdir) -l$(RUBY_SO_NAME)
+LIBRUBYARG_STATIC = -Wl,-R$(libdir) -L$(libdir) -l$(RUBY_SO_NAME)-static
+empty =
+OUTFLAG = -o $(empty)
+COUTFLAG = -o $(empty)
+
+RUBY_EXTCONF_H = extconf.h
+cflags = $(optflags) $(debugflags) $(warnflags)
+optflags = -O3 -fno-fast-math
+debugflags = -ggdb3
+warnflags = -Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wunused-variable -Wpointer-arith -Wwrite-strings -Wdeclaration-after-statement -Wimplicit-function-declaration -Wdeprecated-declarations -Wno-packed-bitfield-compat
+CCDLFLAGS = -fPIC
+CFLAGS = $(CCDLFLAGS) $(cflags) -fPIC $(ARCH_FLAG)
+INCFLAGS = -I. -I$(arch_hdrdir) -I$(hdrdir) -I$(srcdir)
+DEFS =
+CPPFLAGS = -DRUBY_EXTCONF_H=\"$(RUBY_EXTCONF_H)\" $(DEFS) $(cppflags)
+CXXFLAGS = $(CCDLFLAGS) $(cxxflags) $(ARCH_FLAG)
+ldflags = -L. -fstack-protector -rdynamic -Wl,-export-dynamic
+dldflags =
+ARCH_FLAG =
+DLDFLAGS = $(ldflags) $(dldflags) $(ARCH_FLAG)
+LDSHARED = $(CC) -shared
+LDSHAREDXX = $(CXX) -shared
+AR = ar
+EXEEXT =
+
+RUBY_INSTALL_NAME = $(RUBY_BASE_NAME)
+RUBY_SO_NAME = ruby
+RUBYW_INSTALL_NAME =
+RUBY_VERSION_NAME = $(RUBY_BASE_NAME)-$(ruby_version)
+RUBYW_BASE_NAME = rubyw
+RUBY_BASE_NAME = ruby
+
+arch = x86_64-linux
+sitearch = $(arch)
+ruby_version = 2.2.0
+ruby = $(topdir)/miniruby -I'$(topdir)' -I'$(top_srcdir)/lib' -I'$(extout)/$(arch)' -I'$(extout)/common'
+RUBY = $(ruby)
+ruby_headers = $(hdrdir)/ruby.h $(hdrdir)/ruby/ruby.h $(hdrdir)/ruby/defines.h $(hdrdir)/ruby/missing.h $(hdrdir)/ruby/intern.h $(hdrdir)/ruby/st.h $(hdrdir)/ruby/subst.h $(arch_hdrdir)/ruby/config.h $(RUBY_EXTCONF_H)
+
+RM = rm -f
+RM_RF = $(RUBY) -run -e rm -- -rf
+RMDIRS = rmdir --ignore-fail-on-non-empty -p
+MAKEDIRS = /bin/mkdir -p
+INSTALL = /usr/bin/install -c
+INSTALL_PROG = $(INSTALL) -m 0755
+INSTALL_DATA = $(INSTALL) -m 644
+COPY = cp
+TOUCH = exit >
+
+#### End of system configuration section. ####
+
+preload =
+
+libpath = . $(topdir)
+LIBPATH = -L. -L$(topdir)
+DEFFILE =
+
+CLEANFILES = mkmf.log
+DISTCLEANFILES =
+DISTCLEANDIRS =
+
+extout = $(topdir)/.ext
+extout_prefix = $(extout)$(target_prefix)/
+target_prefix = /-test-
+LOCAL_LIBS =
+LIBS = $(LIBRUBYARG_SHARED) -lpthread -lgmp -ldl -lcrypt -lm -lc
+ORIG_SRCS = inspector.c init.c profile_frames.c
+SRCS = $(ORIG_SRCS)
+OBJS = inspector.o init.o profile_frames.o
+HDRS = $(srcdir)/extconf.h
+TARGET = debug
+TARGET_NAME = debug
+TARGET_ENTRY = Init_$(TARGET_NAME)
+DLLIB = $(TARGET).so
+EXTSTATIC =
+STATIC_LIB = $(TARGET).a
+
+TIMESTAMP_DIR = $(extout)/.timestamp
+BINDIR = $(extout)/bin
+RUBYCOMMONDIR = $(extout)/common
+RUBYLIBDIR = $(RUBYCOMMONDIR)$(target_prefix)
+RUBYARCHDIR = $(extout)/$(arch)$(target_prefix)
+HDRDIR = $(extout)/include/ruby$(target_prefix)
+ARCHHDRDIR = $(extout)/include/$(arch)/ruby$(target_prefix)
+
+TARGET_SO = $(RUBYARCHDIR)/$(DLLIB)
+CLEANLIBS = $(RUBYARCHDIR)/$(TARGET).so
+CLEANOBJS = *.o *.bak
+
+all: install
+static: all
+.PHONY: all install static install-so install-rb
+.PHONY: clean clean-so clean-static clean-rb
+
+clean-static::
+clean-rb-default::
+clean-rb::
+clean-so::
+clean: clean-so clean-static clean-rb-default clean-rb
+ -$(Q)$(RM) $(CLEANLIBS) $(CLEANOBJS) $(CLEANFILES) .*.time
+
+distclean-rb-default::
+distclean-rb::
+distclean-so::
+distclean-static::
+distclean: clean distclean-so distclean-static distclean-rb-default distclean-rb
+ -$(Q)$(RM) Makefile $(RUBY_EXTCONF_H) conftest.* mkmf.log
+ -$(Q)$(RM) core ruby$(EXEEXT) *~ $(DISTCLEANFILES)
+ -$(Q)$(RMDIRS) $(DISTCLEANDIRS) 2> /dev/null || true
+
+realclean: distclean
+install: install-so install-rb
+
+install-so: $(RUBYARCHDIR)/$(DLLIB)
+clean-so::
+ -$(Q)$(RM) $(RUBYARCHDIR)/$(DLLIB)
+ -$(Q)$(RMDIRS) $(RUBYARCHDIR) 2> /dev/null || true
+clean-static::
+ -$(Q)$(RM) $(STATIC_LIB)
+install-rb: pre-install-rb install-rb-default
+install-rb-default: pre-install-rb-default
+pre-install-rb: Makefile
+pre-install-rb-default: Makefile
+pre-install-rb-default:
+ @$(NULLCMD)
+$(TIMESTAMP_DIR)/.RUBYARCHDIR.-.-test-.time:
+ $(Q) $(MAKEDIRS) $(@D) $(RUBYARCHDIR)
+ $(Q) $(TOUCH) $@
+
+site-install: site-install-so site-install-rb
+site-install-so: install-so
+site-install-rb: install-rb
+
+.SUFFIXES: .c .m .cc .mm .cxx .cpp .o .S
+
+.cc.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<
+
+.cc.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -S $<
+
+.mm.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<
+
+.mm.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -S $<
+
+.cxx.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<
+
+.cxx.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -S $<
+
+.cpp.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<
+
+.cpp.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -S $<
+
+.c.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -c $<
+
+.c.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -S $<
+
+.m.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -c $<
+
+.m.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -S $<
+
+$(RUBYARCHDIR)/$(DLLIB): $(OBJS) Makefile $(TIMESTAMP_DIR)/.RUBYARCHDIR.-.-test-.time
+ $(ECHO) linking shared-object -test-/$(DLLIB)
+ -$(Q)$(RM) $(@)
+ $(Q) $(LDSHARED) -o $@ $(OBJS) $(LIBPATH) $(DLDFLAGS) $(LOCAL_LIBS) $(LIBS)
+
+$(STATIC_LIB): $(OBJS)
+ -$(Q)$(RM) $(@)
+ $(ECHO) linking static-library $(@)
+ $(Q) $(AR) cru $@ $(OBJS)
+ -$(Q)ranlib $(@) 2> /dev/null || true
+
+###
+$(OBJS): $(RUBY_EXTCONF_H)
+
+# AUTOGENERATED DEPENDENCIES START
+init.o: $(RUBY_EXTCONF_H)
+init.o: $(arch_hdrdir)/ruby/config.h
+init.o: $(hdrdir)/ruby/defines.h
+init.o: $(hdrdir)/ruby/intern.h
+init.o: $(hdrdir)/ruby/missing.h
+init.o: $(hdrdir)/ruby/ruby.h
+init.o: $(hdrdir)/ruby/st.h
+init.o: $(hdrdir)/ruby/subst.h
+init.o: $(top_srcdir)/include/ruby.h
+init.o: init.c
+inspector.o: $(RUBY_EXTCONF_H)
+inspector.o: $(arch_hdrdir)/ruby/config.h
+inspector.o: $(hdrdir)/ruby/debug.h
+inspector.o: $(hdrdir)/ruby/defines.h
+inspector.o: $(hdrdir)/ruby/intern.h
+inspector.o: $(hdrdir)/ruby/missing.h
+inspector.o: $(hdrdir)/ruby/ruby.h
+inspector.o: $(hdrdir)/ruby/st.h
+inspector.o: $(hdrdir)/ruby/subst.h
+inspector.o: inspector.c
+profile_frames.o: $(RUBY_EXTCONF_H)
+profile_frames.o: $(arch_hdrdir)/ruby/config.h
+profile_frames.o: $(hdrdir)/ruby/debug.h
+profile_frames.o: $(hdrdir)/ruby/defines.h
+profile_frames.o: $(hdrdir)/ruby/intern.h
+profile_frames.o: $(hdrdir)/ruby/missing.h
+profile_frames.o: $(hdrdir)/ruby/ruby.h
+profile_frames.o: $(hdrdir)/ruby/st.h
+profile_frames.o: $(hdrdir)/ruby/subst.h
+profile_frames.o: profile_frames.c
+# AUTOGENERATED DEPENDENCIES END
diff --git a/jni/ruby/ext/-test-/debug/depend b/jni/ruby/ext/-test-/debug/depend
new file mode 100644
index 0000000..5178d85
--- /dev/null
+++ b/jni/ruby/ext/-test-/debug/depend
@@ -0,0 +1,32 @@
+# AUTOGENERATED DEPENDENCIES START
+init.o: $(RUBY_EXTCONF_H)
+init.o: $(arch_hdrdir)/ruby/config.h
+init.o: $(hdrdir)/ruby/defines.h
+init.o: $(hdrdir)/ruby/intern.h
+init.o: $(hdrdir)/ruby/missing.h
+init.o: $(hdrdir)/ruby/ruby.h
+init.o: $(hdrdir)/ruby/st.h
+init.o: $(hdrdir)/ruby/subst.h
+init.o: $(top_srcdir)/include/ruby.h
+init.o: init.c
+inspector.o: $(RUBY_EXTCONF_H)
+inspector.o: $(arch_hdrdir)/ruby/config.h
+inspector.o: $(hdrdir)/ruby/debug.h
+inspector.o: $(hdrdir)/ruby/defines.h
+inspector.o: $(hdrdir)/ruby/intern.h
+inspector.o: $(hdrdir)/ruby/missing.h
+inspector.o: $(hdrdir)/ruby/ruby.h
+inspector.o: $(hdrdir)/ruby/st.h
+inspector.o: $(hdrdir)/ruby/subst.h
+inspector.o: inspector.c
+profile_frames.o: $(RUBY_EXTCONF_H)
+profile_frames.o: $(arch_hdrdir)/ruby/config.h
+profile_frames.o: $(hdrdir)/ruby/debug.h
+profile_frames.o: $(hdrdir)/ruby/defines.h
+profile_frames.o: $(hdrdir)/ruby/intern.h
+profile_frames.o: $(hdrdir)/ruby/missing.h
+profile_frames.o: $(hdrdir)/ruby/ruby.h
+profile_frames.o: $(hdrdir)/ruby/st.h
+profile_frames.o: $(hdrdir)/ruby/subst.h
+profile_frames.o: profile_frames.c
+# AUTOGENERATED DEPENDENCIES END
diff --git a/jni/ruby/ext/-test-/debug/extconf.h b/jni/ruby/ext/-test-/debug/extconf.h
new file mode 100644
index 0000000..518a8d2
--- /dev/null
+++ b/jni/ruby/ext/-test-/debug/extconf.h
@@ -0,0 +1,4 @@
+#ifndef EXTCONF_H
+#define EXTCONF_H
+#define TEST_INIT_FUNCS(X) X(inspector) X(profile_frames)
+#endif
diff --git a/jni/ruby/ext/-test-/debug/extconf.rb b/jni/ruby/ext/-test-/debug/extconf.rb
new file mode 100644
index 0000000..8f7922e
--- /dev/null
+++ b/jni/ruby/ext/-test-/debug/extconf.rb
@@ -0,0 +1,6 @@
+$srcs = Dir[File.join($srcdir, "*.{#{SRC_EXT.join(%q{,})}}")]
+inits = $srcs.map {|s| File.basename(s, ".*")}
+inits.delete("init")
+inits.map! {|s|"X(#{s})"}
+$defs << "-DTEST_INIT_FUNCS(X)=\"#{inits.join(' ')}\""
+create_makefile("-test-/debug")
diff --git a/jni/ruby/ext/-test-/debug/init.c b/jni/ruby/ext/-test-/debug/init.c
new file mode 100644
index 0000000..fe3979c
--- /dev/null
+++ b/jni/ruby/ext/-test-/debug/init.c
@@ -0,0 +1,11 @@
+#include "ruby.h"
+
+#define init(n) {void Init_##n(VALUE klass); Init_##n(klass);}
+
+void
+Init_debug(void)
+{
+ VALUE mBug = rb_define_module("Bug");
+ VALUE klass = rb_define_module_under(mBug, "Debug");
+ TEST_INIT_FUNCS(init);
+}
diff --git a/jni/ruby/ext/-test-/debug/inspector.c b/jni/ruby/ext/-test-/debug/inspector.c
new file mode 100644
index 0000000..f0c58e5
--- /dev/null
+++ b/jni/ruby/ext/-test-/debug/inspector.c
@@ -0,0 +1,32 @@
+#include "ruby/ruby.h"
+#include "ruby/debug.h"
+
+static VALUE
+callback(const rb_debug_inspector_t *dbg_context, void *data)
+{
+ VALUE locs = rb_debug_inspector_backtrace_locations(dbg_context);
+ long i, len = RARRAY_LEN(locs);
+ VALUE binds = rb_ary_new();
+ for (i = 0; i < len; ++i) {
+ VALUE entry = rb_ary_new();
+ rb_ary_push(binds, entry);
+ rb_ary_push(entry, rb_debug_inspector_frame_self_get(dbg_context, i));
+ rb_ary_push(entry, rb_debug_inspector_frame_binding_get(dbg_context, i));
+ rb_ary_push(entry, rb_debug_inspector_frame_class_get(dbg_context, i));
+ rb_ary_push(entry, rb_debug_inspector_frame_iseq_get(dbg_context, i));
+ rb_ary_push(entry, rb_ary_entry(locs, i));
+ }
+ return binds;
+}
+
+static VALUE
+debug_inspector(VALUE self)
+{
+ return rb_debug_inspector_open(callback, NULL);
+}
+
+void
+Init_inspector(VALUE klass)
+{
+ rb_define_module_function(klass, "inspector", debug_inspector, 0);
+}
diff --git a/jni/ruby/ext/-test-/debug/profile_frames.c b/jni/ruby/ext/-test-/debug/profile_frames.c
new file mode 100644
index 0000000..1656ff7
--- /dev/null
+++ b/jni/ruby/ext/-test-/debug/profile_frames.c
@@ -0,0 +1,43 @@
+#include "ruby/ruby.h"
+#include "ruby/debug.h"
+
+#define MAX_BUF_SIZE 0x100
+
+static VALUE
+profile_frames(VALUE self, VALUE start_v, VALUE num_v)
+{
+ int i, collected_size;
+ int start = NUM2INT(start_v);
+ int buff_size = NUM2INT(num_v);
+ VALUE buff[MAX_BUF_SIZE];
+ int lines[MAX_BUF_SIZE];
+ VALUE result = rb_ary_new();
+
+ if (buff_size > MAX_BUF_SIZE) rb_raise(rb_eRuntimeError, "too long buff_size");
+
+ collected_size = rb_profile_frames(start, buff_size, buff, lines);
+
+ for (i=0; i<collected_size; i++) {
+ VALUE ary = rb_ary_new();
+ rb_ary_push(ary, rb_profile_frame_path(buff[i]));
+ rb_ary_push(ary, rb_profile_frame_absolute_path(buff[i]));
+ rb_ary_push(ary, rb_profile_frame_label(buff[i]));
+ rb_ary_push(ary, rb_profile_frame_base_label(buff[i]));
+ rb_ary_push(ary, rb_profile_frame_full_label(buff[i]));
+ rb_ary_push(ary, rb_profile_frame_first_lineno(buff[i]));
+ rb_ary_push(ary, rb_profile_frame_classpath(buff[i]));
+ rb_ary_push(ary, rb_profile_frame_singleton_method_p(buff[i]));
+ rb_ary_push(ary, rb_profile_frame_method_name(buff[i]));
+ rb_ary_push(ary, rb_profile_frame_qualified_method_name(buff[i]));
+
+ rb_ary_push(result, ary);
+ }
+
+ return result;
+}
+
+void
+Init_profile_frames(VALUE klass)
+{
+ rb_define_module_function(klass, "profile_frames", profile_frames, 2);
+}
diff --git a/jni/ruby/ext/-test-/exception/Makefile b/jni/ruby/ext/-test-/exception/Makefile
new file mode 100644
index 0000000..d91e7e5
--- /dev/null
+++ b/jni/ruby/ext/-test-/exception/Makefile
@@ -0,0 +1,312 @@
+
+SHELL = /bin/sh
+
+# V=0 quiet, V=1 verbose. other values don't work.
+V = 0
+Q1 = $(V:1=)
+Q = $(Q1:0=@)
+ECHO1 = $(V:1=@:)
+ECHO = $(ECHO1:0=@echo)
+NULLCMD = :
+
+#### Start of system configuration section. ####
+top_srcdir = $(topdir)/.
+srcdir = $(top_srcdir)/ext/-test-/exception
+topdir = ../../..
+hdrdir = $(top_srcdir)/include
+arch_hdrdir = $(extout)/include/$(arch)
+PATH_SEPARATOR = :
+VPATH = $(srcdir):$(arch_hdrdir)/ruby:$(hdrdir)/ruby
+RUBYLIB =
+RUBYOPT = -
+prefix = $(DESTDIR)/usr/local
+rubysitearchprefix = $(rubylibprefix)/$(sitearch)
+rubyarchprefix = $(rubylibprefix)/$(arch)
+rubylibprefix = $(libdir)/$(RUBY_BASE_NAME)
+exec_prefix = $(prefix)
+vendorarchhdrdir = $(vendorhdrdir)/$(sitearch)
+sitearchhdrdir = $(sitehdrdir)/$(sitearch)
+rubyarchhdrdir = $(rubyhdrdir)/$(arch)
+vendorhdrdir = $(rubyhdrdir)/vendor_ruby
+sitehdrdir = $(rubyhdrdir)/site_ruby
+rubyhdrdir = $(includedir)/$(RUBY_VERSION_NAME)
+vendorarchdir = $(vendorlibdir)/$(sitearch)
+vendorlibdir = $(vendordir)/$(ruby_version)
+vendordir = $(rubylibprefix)/vendor_ruby
+sitearchdir = $(sitelibdir)/$(sitearch)
+sitelibdir = $(sitedir)/$(ruby_version)
+sitedir = $(rubylibprefix)/site_ruby
+rubyarchdir = $(rubylibdir)/$(arch)
+rubylibdir = $(rubylibprefix)/$(ruby_version)
+sitearchincludedir = $(includedir)/$(sitearch)
+archincludedir = $(includedir)/$(arch)
+sitearchlibdir = $(libdir)/$(sitearch)
+archlibdir = $(libdir)/$(arch)
+ridir = $(datarootdir)/$(RI_BASE_NAME)
+mandir = $(datarootdir)/man
+localedir = $(datarootdir)/locale
+libdir = $(exec_prefix)/lib
+psdir = $(docdir)
+pdfdir = $(docdir)
+dvidir = $(docdir)
+htmldir = $(docdir)
+infodir = $(datarootdir)/info
+docdir = $(datarootdir)/doc/$(PACKAGE)
+oldincludedir = $(DESTDIR)/usr/include
+includedir = $(prefix)/include
+localstatedir = $(prefix)/var
+sharedstatedir = $(prefix)/com
+sysconfdir = $(prefix)/etc
+datadir = $(datarootdir)
+datarootdir = $(prefix)/share
+libexecdir = $(exec_prefix)/libexec
+sbindir = $(exec_prefix)/sbin
+bindir = $(exec_prefix)/bin
+archdir = $(rubyarchdir)
+
+
+CC = gcc
+CXX = g++
+LIBRUBY = $(LIBRUBY_SO)
+LIBRUBY_A = lib$(RUBY_SO_NAME)-static.a
+LIBRUBYARG_SHARED = -Wl,-R$(libdir) -L$(libdir) -l$(RUBY_SO_NAME)
+LIBRUBYARG_STATIC = -Wl,-R$(libdir) -L$(libdir) -l$(RUBY_SO_NAME)-static
+empty =
+OUTFLAG = -o $(empty)
+COUTFLAG = -o $(empty)
+
+RUBY_EXTCONF_H = extconf.h
+cflags = $(optflags) $(debugflags) $(warnflags)
+optflags = -O3 -fno-fast-math
+debugflags = -ggdb3
+warnflags = -Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wunused-variable -Wpointer-arith -Wwrite-strings -Wdeclaration-after-statement -Wimplicit-function-declaration -Wdeprecated-declarations -Wno-packed-bitfield-compat
+CCDLFLAGS = -fPIC
+CFLAGS = $(CCDLFLAGS) $(cflags) -fPIC $(ARCH_FLAG)
+INCFLAGS = -I. -I$(arch_hdrdir) -I$(hdrdir) -I$(srcdir)
+DEFS =
+CPPFLAGS = -DRUBY_EXTCONF_H=\"$(RUBY_EXTCONF_H)\" $(DEFS) $(cppflags)
+CXXFLAGS = $(CCDLFLAGS) $(cxxflags) $(ARCH_FLAG)
+ldflags = -L. -fstack-protector -rdynamic -Wl,-export-dynamic
+dldflags =
+ARCH_FLAG =
+DLDFLAGS = $(ldflags) $(dldflags) $(ARCH_FLAG)
+LDSHARED = $(CC) -shared
+LDSHAREDXX = $(CXX) -shared
+AR = ar
+EXEEXT =
+
+RUBY_INSTALL_NAME = $(RUBY_BASE_NAME)
+RUBY_SO_NAME = ruby
+RUBYW_INSTALL_NAME =
+RUBY_VERSION_NAME = $(RUBY_BASE_NAME)-$(ruby_version)
+RUBYW_BASE_NAME = rubyw
+RUBY_BASE_NAME = ruby
+
+arch = x86_64-linux
+sitearch = $(arch)
+ruby_version = 2.2.0
+ruby = $(topdir)/miniruby -I'$(topdir)' -I'$(top_srcdir)/lib' -I'$(extout)/$(arch)' -I'$(extout)/common'
+RUBY = $(ruby)
+ruby_headers = $(hdrdir)/ruby.h $(hdrdir)/ruby/ruby.h $(hdrdir)/ruby/defines.h $(hdrdir)/ruby/missing.h $(hdrdir)/ruby/intern.h $(hdrdir)/ruby/st.h $(hdrdir)/ruby/subst.h $(arch_hdrdir)/ruby/config.h $(RUBY_EXTCONF_H)
+
+RM = rm -f
+RM_RF = $(RUBY) -run -e rm -- -rf
+RMDIRS = rmdir --ignore-fail-on-non-empty -p
+MAKEDIRS = /bin/mkdir -p
+INSTALL = /usr/bin/install -c
+INSTALL_PROG = $(INSTALL) -m 0755
+INSTALL_DATA = $(INSTALL) -m 644
+COPY = cp
+TOUCH = exit >
+
+#### End of system configuration section. ####
+
+preload =
+
+libpath = . $(topdir)
+LIBPATH = -L. -L$(topdir)
+DEFFILE =
+
+CLEANFILES = mkmf.log
+DISTCLEANFILES =
+DISTCLEANDIRS =
+
+extout = $(topdir)/.ext
+extout_prefix = $(extout)$(target_prefix)/
+target_prefix = /-test-
+LOCAL_LIBS =
+LIBS = $(LIBRUBYARG_SHARED) -lpthread -lgmp -ldl -lcrypt -lm -lc
+ORIG_SRCS = enc_raise.c init.c dataerror.c ensured.c
+SRCS = $(ORIG_SRCS)
+OBJS = enc_raise.o init.o dataerror.o ensured.o
+HDRS = $(srcdir)/extconf.h
+TARGET = exception
+TARGET_NAME = exception
+TARGET_ENTRY = Init_$(TARGET_NAME)
+DLLIB = $(TARGET).so
+EXTSTATIC =
+STATIC_LIB = $(TARGET).a
+
+TIMESTAMP_DIR = $(extout)/.timestamp
+BINDIR = $(extout)/bin
+RUBYCOMMONDIR = $(extout)/common
+RUBYLIBDIR = $(RUBYCOMMONDIR)$(target_prefix)
+RUBYARCHDIR = $(extout)/$(arch)$(target_prefix)
+HDRDIR = $(extout)/include/ruby$(target_prefix)
+ARCHHDRDIR = $(extout)/include/$(arch)/ruby$(target_prefix)
+
+TARGET_SO = $(RUBYARCHDIR)/$(DLLIB)
+CLEANLIBS = $(RUBYARCHDIR)/$(TARGET).so
+CLEANOBJS = *.o *.bak
+
+all: install
+static: all
+.PHONY: all install static install-so install-rb
+.PHONY: clean clean-so clean-static clean-rb
+
+clean-static::
+clean-rb-default::
+clean-rb::
+clean-so::
+clean: clean-so clean-static clean-rb-default clean-rb
+ -$(Q)$(RM) $(CLEANLIBS) $(CLEANOBJS) $(CLEANFILES) .*.time
+
+distclean-rb-default::
+distclean-rb::
+distclean-so::
+distclean-static::
+distclean: clean distclean-so distclean-static distclean-rb-default distclean-rb
+ -$(Q)$(RM) Makefile $(RUBY_EXTCONF_H) conftest.* mkmf.log
+ -$(Q)$(RM) core ruby$(EXEEXT) *~ $(DISTCLEANFILES)
+ -$(Q)$(RMDIRS) $(DISTCLEANDIRS) 2> /dev/null || true
+
+realclean: distclean
+install: install-so install-rb
+
+install-so: $(RUBYARCHDIR)/$(DLLIB)
+clean-so::
+ -$(Q)$(RM) $(RUBYARCHDIR)/$(DLLIB)
+ -$(Q)$(RMDIRS) $(RUBYARCHDIR) 2> /dev/null || true
+clean-static::
+ -$(Q)$(RM) $(STATIC_LIB)
+install-rb: pre-install-rb install-rb-default
+install-rb-default: pre-install-rb-default
+pre-install-rb: Makefile
+pre-install-rb-default: Makefile
+pre-install-rb-default:
+ @$(NULLCMD)
+$(TIMESTAMP_DIR)/.RUBYARCHDIR.-.-test-.time:
+ $(Q) $(MAKEDIRS) $(@D) $(RUBYARCHDIR)
+ $(Q) $(TOUCH) $@
+
+site-install: site-install-so site-install-rb
+site-install-so: install-so
+site-install-rb: install-rb
+
+.SUFFIXES: .c .m .cc .mm .cxx .cpp .o .S
+
+.cc.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<
+
+.cc.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -S $<
+
+.mm.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<
+
+.mm.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -S $<
+
+.cxx.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<
+
+.cxx.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -S $<
+
+.cpp.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<
+
+.cpp.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -S $<
+
+.c.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -c $<
+
+.c.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -S $<
+
+.m.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -c $<
+
+.m.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -S $<
+
+$(RUBYARCHDIR)/$(DLLIB): $(OBJS) Makefile $(TIMESTAMP_DIR)/.RUBYARCHDIR.-.-test-.time
+ $(ECHO) linking shared-object -test-/$(DLLIB)
+ -$(Q)$(RM) $(@)
+ $(Q) $(LDSHARED) -o $@ $(OBJS) $(LIBPATH) $(DLDFLAGS) $(LOCAL_LIBS) $(LIBS)
+
+$(STATIC_LIB): $(OBJS)
+ -$(Q)$(RM) $(@)
+ $(ECHO) linking static-library $(@)
+ $(Q) $(AR) cru $@ $(OBJS)
+ -$(Q)ranlib $(@) 2> /dev/null || true
+
+###
+$(OBJS): $(RUBY_EXTCONF_H)
+
+# AUTOGENERATED DEPENDENCIES START
+dataerror.o: $(RUBY_EXTCONF_H)
+dataerror.o: $(arch_hdrdir)/ruby/config.h
+dataerror.o: $(hdrdir)/ruby/defines.h
+dataerror.o: $(hdrdir)/ruby/intern.h
+dataerror.o: $(hdrdir)/ruby/missing.h
+dataerror.o: $(hdrdir)/ruby/ruby.h
+dataerror.o: $(hdrdir)/ruby/st.h
+dataerror.o: $(hdrdir)/ruby/subst.h
+dataerror.o: dataerror.c
+enc_raise.o: $(RUBY_EXTCONF_H)
+enc_raise.o: $(arch_hdrdir)/ruby/config.h
+enc_raise.o: $(hdrdir)/ruby/defines.h
+enc_raise.o: $(hdrdir)/ruby/encoding.h
+enc_raise.o: $(hdrdir)/ruby/intern.h
+enc_raise.o: $(hdrdir)/ruby/missing.h
+enc_raise.o: $(hdrdir)/ruby/oniguruma.h
+enc_raise.o: $(hdrdir)/ruby/ruby.h
+enc_raise.o: $(hdrdir)/ruby/st.h
+enc_raise.o: $(hdrdir)/ruby/subst.h
+enc_raise.o: $(top_srcdir)/include/ruby.h
+enc_raise.o: enc_raise.c
+ensured.o: $(RUBY_EXTCONF_H)
+ensured.o: $(arch_hdrdir)/ruby/config.h
+ensured.o: $(hdrdir)/ruby/defines.h
+ensured.o: $(hdrdir)/ruby/intern.h
+ensured.o: $(hdrdir)/ruby/missing.h
+ensured.o: $(hdrdir)/ruby/ruby.h
+ensured.o: $(hdrdir)/ruby/st.h
+ensured.o: $(hdrdir)/ruby/subst.h
+ensured.o: $(top_srcdir)/include/ruby.h
+ensured.o: ensured.c
+init.o: $(RUBY_EXTCONF_H)
+init.o: $(arch_hdrdir)/ruby/config.h
+init.o: $(hdrdir)/ruby/defines.h
+init.o: $(hdrdir)/ruby/intern.h
+init.o: $(hdrdir)/ruby/missing.h
+init.o: $(hdrdir)/ruby/ruby.h
+init.o: $(hdrdir)/ruby/st.h
+init.o: $(hdrdir)/ruby/subst.h
+init.o: $(top_srcdir)/include/ruby.h
+init.o: init.c
+# AUTOGENERATED DEPENDENCIES END
diff --git a/jni/ruby/ext/-test-/exception/dataerror.c b/jni/ruby/ext/-test-/exception/dataerror.c
new file mode 100644
index 0000000..d8beba8
--- /dev/null
+++ b/jni/ruby/ext/-test-/exception/dataerror.c
@@ -0,0 +1,31 @@
+#include <ruby/ruby.h>
+
+static void
+dataerror_mark(void *ptr)
+{
+ rb_gc_mark((VALUE)ptr);
+}
+
+static void
+dataerror_free(void *ptr)
+{
+}
+
+static const rb_data_type_t dataerror_type = {
+ "Bug #9167",
+ {dataerror_mark, dataerror_free},
+};
+
+static VALUE
+dataerror_alloc(VALUE klass)
+{
+ VALUE n = rb_str_new_cstr("[Bug #9167] error");
+ return TypedData_Wrap_Struct(klass, &dataerror_type, (void *)n);
+}
+
+void
+Init_dataerror(VALUE klass)
+{
+ VALUE rb_eDataErr = rb_define_class_under(klass, "DataError", rb_eStandardError);
+ rb_define_alloc_func(rb_eDataErr, dataerror_alloc);
+}
diff --git a/jni/ruby/ext/-test-/exception/depend b/jni/ruby/ext/-test-/exception/depend
new file mode 100644
index 0000000..a89ecf7
--- /dev/null
+++ b/jni/ruby/ext/-test-/exception/depend
@@ -0,0 +1,43 @@
+# AUTOGENERATED DEPENDENCIES START
+dataerror.o: $(RUBY_EXTCONF_H)
+dataerror.o: $(arch_hdrdir)/ruby/config.h
+dataerror.o: $(hdrdir)/ruby/defines.h
+dataerror.o: $(hdrdir)/ruby/intern.h
+dataerror.o: $(hdrdir)/ruby/missing.h
+dataerror.o: $(hdrdir)/ruby/ruby.h
+dataerror.o: $(hdrdir)/ruby/st.h
+dataerror.o: $(hdrdir)/ruby/subst.h
+dataerror.o: dataerror.c
+enc_raise.o: $(RUBY_EXTCONF_H)
+enc_raise.o: $(arch_hdrdir)/ruby/config.h
+enc_raise.o: $(hdrdir)/ruby/defines.h
+enc_raise.o: $(hdrdir)/ruby/encoding.h
+enc_raise.o: $(hdrdir)/ruby/intern.h
+enc_raise.o: $(hdrdir)/ruby/missing.h
+enc_raise.o: $(hdrdir)/ruby/oniguruma.h
+enc_raise.o: $(hdrdir)/ruby/ruby.h
+enc_raise.o: $(hdrdir)/ruby/st.h
+enc_raise.o: $(hdrdir)/ruby/subst.h
+enc_raise.o: $(top_srcdir)/include/ruby.h
+enc_raise.o: enc_raise.c
+ensured.o: $(RUBY_EXTCONF_H)
+ensured.o: $(arch_hdrdir)/ruby/config.h
+ensured.o: $(hdrdir)/ruby/defines.h
+ensured.o: $(hdrdir)/ruby/intern.h
+ensured.o: $(hdrdir)/ruby/missing.h
+ensured.o: $(hdrdir)/ruby/ruby.h
+ensured.o: $(hdrdir)/ruby/st.h
+ensured.o: $(hdrdir)/ruby/subst.h
+ensured.o: $(top_srcdir)/include/ruby.h
+ensured.o: ensured.c
+init.o: $(RUBY_EXTCONF_H)
+init.o: $(arch_hdrdir)/ruby/config.h
+init.o: $(hdrdir)/ruby/defines.h
+init.o: $(hdrdir)/ruby/intern.h
+init.o: $(hdrdir)/ruby/missing.h
+init.o: $(hdrdir)/ruby/ruby.h
+init.o: $(hdrdir)/ruby/st.h
+init.o: $(hdrdir)/ruby/subst.h
+init.o: $(top_srcdir)/include/ruby.h
+init.o: init.c
+# AUTOGENERATED DEPENDENCIES END
diff --git a/jni/ruby/ext/-test-/exception/enc_raise.c b/jni/ruby/ext/-test-/exception/enc_raise.c
new file mode 100644
index 0000000..dc8a42c
--- /dev/null
+++ b/jni/ruby/ext/-test-/exception/enc_raise.c
@@ -0,0 +1,15 @@
+#include <ruby.h>
+#include <ruby/encoding.h>
+
+static VALUE
+enc_raise(VALUE exc, VALUE encoding, VALUE mesg)
+{
+ rb_enc_raise(rb_to_encoding(encoding), exc, "%s", StringValueCStr(mesg));
+ UNREACHABLE;
+}
+
+void
+Init_enc_raise(VALUE klass)
+{
+ rb_define_module_function(klass, "enc_raise", enc_raise, 2);
+}
diff --git a/jni/ruby/ext/-test-/exception/ensured.c b/jni/ruby/ext/-test-/exception/ensured.c
new file mode 100644
index 0000000..365e1f4
--- /dev/null
+++ b/jni/ruby/ext/-test-/exception/ensured.c
@@ -0,0 +1,25 @@
+#include <ruby.h>
+
+static VALUE
+begin(VALUE object)
+{
+ return rb_funcall(object, rb_intern("try_method"), 0);
+}
+
+static VALUE
+ensure(VALUE object)
+{
+ return rb_funcall(object, rb_intern("ensured_method"), 0);
+}
+
+static VALUE
+ensured(VALUE module, VALUE object)
+{
+ return rb_ensure(begin, object, ensure, object);
+}
+
+void
+Init_ensured(VALUE klass)
+{
+ rb_define_module_function(klass, "ensured", ensured, 1);
+}
diff --git a/jni/ruby/ext/-test-/exception/extconf.h b/jni/ruby/ext/-test-/exception/extconf.h
new file mode 100644
index 0000000..62372a6
--- /dev/null
+++ b/jni/ruby/ext/-test-/exception/extconf.h
@@ -0,0 +1,4 @@
+#ifndef EXTCONF_H
+#define EXTCONF_H
+#define TEST_INIT_FUNCS(X) X(enc_raise) X(dataerror) X(ensured)
+#endif
diff --git a/jni/ruby/ext/-test-/exception/extconf.rb b/jni/ruby/ext/-test-/exception/extconf.rb
new file mode 100644
index 0000000..0faf6d5
--- /dev/null
+++ b/jni/ruby/ext/-test-/exception/extconf.rb
@@ -0,0 +1,6 @@
+$srcs = Dir[File.join($srcdir, "*.{#{SRC_EXT.join(%q{,})}}")]
+inits = $srcs.map {|s| File.basename(s, ".*")}
+inits.delete("init")
+inits.map! {|s|"X(#{s})"}
+$defs << "-DTEST_INIT_FUNCS(X)=\"#{inits.join(' ')}\""
+create_makefile("-test-/exception")
diff --git a/jni/ruby/ext/-test-/exception/init.c b/jni/ruby/ext/-test-/exception/init.c
new file mode 100644
index 0000000..853bb68
--- /dev/null
+++ b/jni/ruby/ext/-test-/exception/init.c
@@ -0,0 +1,11 @@
+#include "ruby.h"
+
+#define init(n) {void Init_##n(VALUE klass); Init_##n(klass);}
+
+void
+Init_exception(void)
+{
+ VALUE mBug = rb_define_module("Bug");
+ VALUE klass = rb_define_class_under(mBug, "Exception", rb_eStandardError);
+ TEST_INIT_FUNCS(init);
+}
diff --git a/jni/ruby/ext/-test-/fatal/Makefile b/jni/ruby/ext/-test-/fatal/Makefile
new file mode 100644
index 0000000..da04e11
--- /dev/null
+++ b/jni/ruby/ext/-test-/fatal/Makefile
@@ -0,0 +1,267 @@
+
+SHELL = /bin/sh
+
+# V=0 quiet, V=1 verbose. other values don't work.
+V = 0
+Q1 = $(V:1=)
+Q = $(Q1:0=@)
+ECHO1 = $(V:1=@:)
+ECHO = $(ECHO1:0=@echo)
+NULLCMD = :
+
+#### Start of system configuration section. ####
+top_srcdir = $(topdir)/.
+srcdir = $(top_srcdir)/ext/-test-/fatal
+topdir = ../../..
+hdrdir = $(top_srcdir)/include
+arch_hdrdir = $(extout)/include/$(arch)
+PATH_SEPARATOR = :
+VPATH = $(srcdir):$(arch_hdrdir)/ruby:$(hdrdir)/ruby
+RUBYLIB =
+RUBYOPT = -
+prefix = $(DESTDIR)/usr/local
+rubysitearchprefix = $(rubylibprefix)/$(sitearch)
+rubyarchprefix = $(rubylibprefix)/$(arch)
+rubylibprefix = $(libdir)/$(RUBY_BASE_NAME)
+exec_prefix = $(prefix)
+vendorarchhdrdir = $(vendorhdrdir)/$(sitearch)
+sitearchhdrdir = $(sitehdrdir)/$(sitearch)
+rubyarchhdrdir = $(rubyhdrdir)/$(arch)
+vendorhdrdir = $(rubyhdrdir)/vendor_ruby
+sitehdrdir = $(rubyhdrdir)/site_ruby
+rubyhdrdir = $(includedir)/$(RUBY_VERSION_NAME)
+vendorarchdir = $(vendorlibdir)/$(sitearch)
+vendorlibdir = $(vendordir)/$(ruby_version)
+vendordir = $(rubylibprefix)/vendor_ruby
+sitearchdir = $(sitelibdir)/$(sitearch)
+sitelibdir = $(sitedir)/$(ruby_version)
+sitedir = $(rubylibprefix)/site_ruby
+rubyarchdir = $(rubylibdir)/$(arch)
+rubylibdir = $(rubylibprefix)/$(ruby_version)
+sitearchincludedir = $(includedir)/$(sitearch)
+archincludedir = $(includedir)/$(arch)
+sitearchlibdir = $(libdir)/$(sitearch)
+archlibdir = $(libdir)/$(arch)
+ridir = $(datarootdir)/$(RI_BASE_NAME)
+mandir = $(datarootdir)/man
+localedir = $(datarootdir)/locale
+libdir = $(exec_prefix)/lib
+psdir = $(docdir)
+pdfdir = $(docdir)
+dvidir = $(docdir)
+htmldir = $(docdir)
+infodir = $(datarootdir)/info
+docdir = $(datarootdir)/doc/$(PACKAGE)
+oldincludedir = $(DESTDIR)/usr/include
+includedir = $(prefix)/include
+localstatedir = $(prefix)/var
+sharedstatedir = $(prefix)/com
+sysconfdir = $(prefix)/etc
+datadir = $(datarootdir)
+datarootdir = $(prefix)/share
+libexecdir = $(exec_prefix)/libexec
+sbindir = $(exec_prefix)/sbin
+bindir = $(exec_prefix)/bin
+archdir = $(rubyarchdir)
+
+
+CC = gcc
+CXX = g++
+LIBRUBY = $(LIBRUBY_SO)
+LIBRUBY_A = lib$(RUBY_SO_NAME)-static.a
+LIBRUBYARG_SHARED = -Wl,-R$(libdir) -L$(libdir) -l$(RUBY_SO_NAME)
+LIBRUBYARG_STATIC = -Wl,-R$(libdir) -L$(libdir) -l$(RUBY_SO_NAME)-static
+empty =
+OUTFLAG = -o $(empty)
+COUTFLAG = -o $(empty)
+
+RUBY_EXTCONF_H = extconf.h
+cflags = $(optflags) $(debugflags) $(warnflags)
+optflags = -O3 -fno-fast-math
+debugflags = -ggdb3
+warnflags = -Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wunused-variable -Wpointer-arith -Wwrite-strings -Wdeclaration-after-statement -Wimplicit-function-declaration -Wdeprecated-declarations -Wno-packed-bitfield-compat
+CCDLFLAGS = -fPIC
+CFLAGS = $(CCDLFLAGS) $(cflags) -fPIC $(ARCH_FLAG)
+INCFLAGS = -I. -I$(arch_hdrdir) -I$(hdrdir) -I$(srcdir)
+DEFS =
+CPPFLAGS = -DRUBY_EXTCONF_H=\"$(RUBY_EXTCONF_H)\" $(DEFS) $(cppflags)
+CXXFLAGS = $(CCDLFLAGS) $(cxxflags) $(ARCH_FLAG)
+ldflags = -L. -fstack-protector -rdynamic -Wl,-export-dynamic
+dldflags =
+ARCH_FLAG =
+DLDFLAGS = $(ldflags) $(dldflags) $(ARCH_FLAG)
+LDSHARED = $(CC) -shared
+LDSHAREDXX = $(CXX) -shared
+AR = ar
+EXEEXT =
+
+RUBY_INSTALL_NAME = $(RUBY_BASE_NAME)
+RUBY_SO_NAME = ruby
+RUBYW_INSTALL_NAME =
+RUBY_VERSION_NAME = $(RUBY_BASE_NAME)-$(ruby_version)
+RUBYW_BASE_NAME = rubyw
+RUBY_BASE_NAME = ruby
+
+arch = x86_64-linux
+sitearch = $(arch)
+ruby_version = 2.2.0
+ruby = $(topdir)/miniruby -I'$(topdir)' -I'$(top_srcdir)/lib' -I'$(extout)/$(arch)' -I'$(extout)/common'
+RUBY = $(ruby)
+ruby_headers = $(hdrdir)/ruby.h $(hdrdir)/ruby/ruby.h $(hdrdir)/ruby/defines.h $(hdrdir)/ruby/missing.h $(hdrdir)/ruby/intern.h $(hdrdir)/ruby/st.h $(hdrdir)/ruby/subst.h $(arch_hdrdir)/ruby/config.h $(RUBY_EXTCONF_H)
+
+RM = rm -f
+RM_RF = $(RUBY) -run -e rm -- -rf
+RMDIRS = rmdir --ignore-fail-on-non-empty -p
+MAKEDIRS = /bin/mkdir -p
+INSTALL = /usr/bin/install -c
+INSTALL_PROG = $(INSTALL) -m 0755
+INSTALL_DATA = $(INSTALL) -m 644
+COPY = cp
+TOUCH = exit >
+
+#### End of system configuration section. ####
+
+preload =
+
+libpath = . $(topdir)
+LIBPATH = -L. -L$(topdir)
+DEFFILE =
+
+CLEANFILES = mkmf.log
+DISTCLEANFILES =
+DISTCLEANDIRS =
+
+extout = $(topdir)/.ext
+extout_prefix = $(extout)$(target_prefix)/
+target_prefix = /-test-/fatal
+LOCAL_LIBS =
+LIBS = $(LIBRUBYARG_SHARED) -lpthread -lgmp -ldl -lcrypt -lm -lc
+ORIG_SRCS = rb_fatal.c
+SRCS = $(ORIG_SRCS)
+OBJS = rb_fatal.o
+HDRS = $(srcdir)/extconf.h
+TARGET = rb_fatal
+TARGET_NAME = rb_fatal
+TARGET_ENTRY = Init_$(TARGET_NAME)
+DLLIB = $(TARGET).so
+EXTSTATIC =
+STATIC_LIB = $(TARGET).a
+
+TIMESTAMP_DIR = $(extout)/.timestamp
+BINDIR = $(extout)/bin
+RUBYCOMMONDIR = $(extout)/common
+RUBYLIBDIR = $(RUBYCOMMONDIR)$(target_prefix)
+RUBYARCHDIR = $(extout)/$(arch)$(target_prefix)
+HDRDIR = $(extout)/include/ruby$(target_prefix)
+ARCHHDRDIR = $(extout)/include/$(arch)/ruby$(target_prefix)
+
+TARGET_SO = $(RUBYARCHDIR)/$(DLLIB)
+CLEANLIBS = $(RUBYARCHDIR)/$(TARGET).so
+CLEANOBJS = *.o *.bak
+
+all: install
+static: all
+.PHONY: all install static install-so install-rb
+.PHONY: clean clean-so clean-static clean-rb
+
+clean-static::
+clean-rb-default::
+clean-rb::
+clean-so::
+clean: clean-so clean-static clean-rb-default clean-rb
+ -$(Q)$(RM) $(CLEANLIBS) $(CLEANOBJS) $(CLEANFILES) .*.time
+
+distclean-rb-default::
+distclean-rb::
+distclean-so::
+distclean-static::
+distclean: clean distclean-so distclean-static distclean-rb-default distclean-rb
+ -$(Q)$(RM) Makefile $(RUBY_EXTCONF_H) conftest.* mkmf.log
+ -$(Q)$(RM) core ruby$(EXEEXT) *~ $(DISTCLEANFILES)
+ -$(Q)$(RMDIRS) $(DISTCLEANDIRS) 2> /dev/null || true
+
+realclean: distclean
+install: install-so install-rb
+
+install-so: $(RUBYARCHDIR)/$(DLLIB)
+clean-so::
+ -$(Q)$(RM) $(RUBYARCHDIR)/$(DLLIB)
+ -$(Q)$(RMDIRS) $(RUBYARCHDIR) 2> /dev/null || true
+clean-static::
+ -$(Q)$(RM) $(STATIC_LIB)
+install-rb: pre-install-rb install-rb-default
+install-rb-default: pre-install-rb-default
+pre-install-rb: Makefile
+pre-install-rb-default: Makefile
+pre-install-rb-default:
+ @$(NULLCMD)
+$(TIMESTAMP_DIR)/.RUBYARCHDIR.-.-test-.-.fatal.time:
+ $(Q) $(MAKEDIRS) $(@D) $(RUBYARCHDIR)
+ $(Q) $(TOUCH) $@
+
+site-install: site-install-so site-install-rb
+site-install-so: install-so
+site-install-rb: install-rb
+
+.SUFFIXES: .c .m .cc .mm .cxx .cpp .o .S
+
+.cc.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<
+
+.cc.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -S $<
+
+.mm.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<
+
+.mm.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -S $<
+
+.cxx.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<
+
+.cxx.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -S $<
+
+.cpp.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<
+
+.cpp.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -S $<
+
+.c.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -c $<
+
+.c.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -S $<
+
+.m.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -c $<
+
+.m.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -S $<
+
+$(RUBYARCHDIR)/$(DLLIB): $(OBJS) Makefile $(TIMESTAMP_DIR)/.RUBYARCHDIR.-.-test-.-.fatal.time
+ $(ECHO) linking shared-object -test-/fatal/$(DLLIB)
+ -$(Q)$(RM) $(@)
+ $(Q) $(LDSHARED) -o $@ $(OBJS) $(LIBPATH) $(DLDFLAGS) $(LOCAL_LIBS) $(LIBS)
+
+$(STATIC_LIB): $(OBJS)
+ -$(Q)$(RM) $(@)
+ $(ECHO) linking static-library $(@)
+ $(Q) $(AR) cru $@ $(OBJS)
+ -$(Q)ranlib $(@) 2> /dev/null || true
+
+$(OBJS): $(HDRS) $(ruby_headers)
diff --git a/jni/ruby/ext/-test-/fatal/extconf.h b/jni/ruby/ext/-test-/fatal/extconf.h
new file mode 100644
index 0000000..cda0cc8
--- /dev/null
+++ b/jni/ruby/ext/-test-/fatal/extconf.h
@@ -0,0 +1,3 @@
+#ifndef EXTCONF_H
+#define EXTCONF_H
+#endif
diff --git a/jni/ruby/ext/-test-/fatal/extconf.rb b/jni/ruby/ext/-test-/fatal/extconf.rb
new file mode 100644
index 0000000..e0cfeb2
--- /dev/null
+++ b/jni/ruby/ext/-test-/fatal/extconf.rb
@@ -0,0 +1 @@
+create_makefile("-test-/fatal/rb_fatal")
diff --git a/jni/ruby/ext/-test-/fatal/rb_fatal.c b/jni/ruby/ext/-test-/fatal/rb_fatal.c
new file mode 100644
index 0000000..71aef46
--- /dev/null
+++ b/jni/ruby/ext/-test-/fatal/rb_fatal.c
@@ -0,0 +1,19 @@
+#include <ruby.h>
+
+static VALUE
+ruby_fatal(VALUE obj, VALUE msg)
+{
+ const char *cmsg = NULL;
+
+ (void)obj;
+
+ cmsg = RSTRING_PTR(msg);
+ rb_fatal("%s", cmsg);
+ return 0; /* never reached */
+}
+
+void
+Init_rb_fatal(void)
+{
+ rb_define_method(rb_mKernel, "rb_fatal", ruby_fatal, 1);
+}
diff --git a/jni/ruby/ext/-test-/file/Makefile b/jni/ruby/ext/-test-/file/Makefile
new file mode 100644
index 0000000..99ca123
--- /dev/null
+++ b/jni/ruby/ext/-test-/file/Makefile
@@ -0,0 +1,305 @@
+
+SHELL = /bin/sh
+
+# V=0 quiet, V=1 verbose. other values don't work.
+V = 0
+Q1 = $(V:1=)
+Q = $(Q1:0=@)
+ECHO1 = $(V:1=@:)
+ECHO = $(ECHO1:0=@echo)
+NULLCMD = :
+
+#### Start of system configuration section. ####
+top_srcdir = $(topdir)/.
+srcdir = $(top_srcdir)/ext/-test-/file
+topdir = ../../..
+hdrdir = $(top_srcdir)/include
+arch_hdrdir = $(extout)/include/$(arch)
+PATH_SEPARATOR = :
+VPATH = $(srcdir):$(arch_hdrdir)/ruby:$(hdrdir)/ruby
+RUBYLIB =
+RUBYOPT = -
+prefix = $(DESTDIR)/usr/local
+rubysitearchprefix = $(rubylibprefix)/$(sitearch)
+rubyarchprefix = $(rubylibprefix)/$(arch)
+rubylibprefix = $(libdir)/$(RUBY_BASE_NAME)
+exec_prefix = $(prefix)
+vendorarchhdrdir = $(vendorhdrdir)/$(sitearch)
+sitearchhdrdir = $(sitehdrdir)/$(sitearch)
+rubyarchhdrdir = $(rubyhdrdir)/$(arch)
+vendorhdrdir = $(rubyhdrdir)/vendor_ruby
+sitehdrdir = $(rubyhdrdir)/site_ruby
+rubyhdrdir = $(includedir)/$(RUBY_VERSION_NAME)
+vendorarchdir = $(vendorlibdir)/$(sitearch)
+vendorlibdir = $(vendordir)/$(ruby_version)
+vendordir = $(rubylibprefix)/vendor_ruby
+sitearchdir = $(sitelibdir)/$(sitearch)
+sitelibdir = $(sitedir)/$(ruby_version)
+sitedir = $(rubylibprefix)/site_ruby
+rubyarchdir = $(rubylibdir)/$(arch)
+rubylibdir = $(rubylibprefix)/$(ruby_version)
+sitearchincludedir = $(includedir)/$(sitearch)
+archincludedir = $(includedir)/$(arch)
+sitearchlibdir = $(libdir)/$(sitearch)
+archlibdir = $(libdir)/$(arch)
+ridir = $(datarootdir)/$(RI_BASE_NAME)
+mandir = $(datarootdir)/man
+localedir = $(datarootdir)/locale
+libdir = $(exec_prefix)/lib
+psdir = $(docdir)
+pdfdir = $(docdir)
+dvidir = $(docdir)
+htmldir = $(docdir)
+infodir = $(datarootdir)/info
+docdir = $(datarootdir)/doc/$(PACKAGE)
+oldincludedir = $(DESTDIR)/usr/include
+includedir = $(prefix)/include
+localstatedir = $(prefix)/var
+sharedstatedir = $(prefix)/com
+sysconfdir = $(prefix)/etc
+datadir = $(datarootdir)
+datarootdir = $(prefix)/share
+libexecdir = $(exec_prefix)/libexec
+sbindir = $(exec_prefix)/sbin
+bindir = $(exec_prefix)/bin
+archdir = $(rubyarchdir)
+
+
+CC = gcc
+CXX = g++
+LIBRUBY = $(LIBRUBY_SO)
+LIBRUBY_A = lib$(RUBY_SO_NAME)-static.a
+LIBRUBYARG_SHARED = -Wl,-R$(libdir) -L$(libdir) -l$(RUBY_SO_NAME)
+LIBRUBYARG_STATIC = -Wl,-R$(libdir) -L$(libdir) -l$(RUBY_SO_NAME)-static
+empty =
+OUTFLAG = -o $(empty)
+COUTFLAG = -o $(empty)
+
+RUBY_EXTCONF_H = extconf.h
+cflags = $(optflags) $(debugflags) $(warnflags)
+optflags = -O3 -fno-fast-math
+debugflags = -ggdb3
+warnflags = -Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wunused-variable -Wpointer-arith -Wwrite-strings -Wdeclaration-after-statement -Wimplicit-function-declaration -Wdeprecated-declarations -Wno-packed-bitfield-compat
+CCDLFLAGS = -fPIC
+CFLAGS = $(CCDLFLAGS) $(cflags) -fPIC $(ARCH_FLAG)
+INCFLAGS = -I. -I$(arch_hdrdir) -I$(hdrdir) -I$(srcdir) -I$(topdir) -I$(top_srcdir)
+DEFS =
+CPPFLAGS = -DRUBY_EXTCONF_H=\"$(RUBY_EXTCONF_H)\" $(DEFS) $(cppflags)
+CXXFLAGS = $(CCDLFLAGS) $(cxxflags) $(ARCH_FLAG)
+ldflags = -L. -fstack-protector -rdynamic -Wl,-export-dynamic
+dldflags =
+ARCH_FLAG =
+DLDFLAGS = $(ldflags) $(dldflags) $(ARCH_FLAG)
+LDSHARED = $(CC) -shared
+LDSHAREDXX = $(CXX) -shared
+AR = ar
+EXEEXT =
+
+RUBY_INSTALL_NAME = $(RUBY_BASE_NAME)
+RUBY_SO_NAME = ruby
+RUBYW_INSTALL_NAME =
+RUBY_VERSION_NAME = $(RUBY_BASE_NAME)-$(ruby_version)
+RUBYW_BASE_NAME = rubyw
+RUBY_BASE_NAME = ruby
+
+arch = x86_64-linux
+sitearch = $(arch)
+ruby_version = 2.2.0
+ruby = $(topdir)/miniruby -I'$(topdir)' -I'$(top_srcdir)/lib' -I'$(extout)/$(arch)' -I'$(extout)/common'
+RUBY = $(ruby)
+ruby_headers = $(hdrdir)/ruby.h $(hdrdir)/ruby/ruby.h $(hdrdir)/ruby/defines.h $(hdrdir)/ruby/missing.h $(hdrdir)/ruby/intern.h $(hdrdir)/ruby/st.h $(hdrdir)/ruby/subst.h $(arch_hdrdir)/ruby/config.h $(RUBY_EXTCONF_H)
+
+RM = rm -f
+RM_RF = $(RUBY) -run -e rm -- -rf
+RMDIRS = rmdir --ignore-fail-on-non-empty -p
+MAKEDIRS = /bin/mkdir -p
+INSTALL = /usr/bin/install -c
+INSTALL_PROG = $(INSTALL) -m 0755
+INSTALL_DATA = $(INSTALL) -m 644
+COPY = cp
+TOUCH = exit >
+
+#### End of system configuration section. ####
+
+preload =
+
+libpath = . $(topdir)
+LIBPATH = -L. -L$(topdir)
+DEFFILE =
+
+CLEANFILES = mkmf.log
+DISTCLEANFILES =
+DISTCLEANDIRS =
+
+extout = $(topdir)/.ext
+extout_prefix = $(extout)$(target_prefix)/
+target_prefix = /-test-
+LOCAL_LIBS =
+LIBS = $(LIBRUBYARG_SHARED) -lpthread -lgmp -ldl -lcrypt -lm -lc
+ORIG_SRCS = fs.c stat.c init.c
+SRCS = $(ORIG_SRCS)
+OBJS = fs.o stat.o init.o
+HDRS = $(srcdir)/extconf.h
+TARGET = file
+TARGET_NAME = file
+TARGET_ENTRY = Init_$(TARGET_NAME)
+DLLIB = $(TARGET).so
+EXTSTATIC =
+STATIC_LIB = $(TARGET).a
+
+TIMESTAMP_DIR = $(extout)/.timestamp
+BINDIR = $(extout)/bin
+RUBYCOMMONDIR = $(extout)/common
+RUBYLIBDIR = $(RUBYCOMMONDIR)$(target_prefix)
+RUBYARCHDIR = $(extout)/$(arch)$(target_prefix)
+HDRDIR = $(extout)/include/ruby$(target_prefix)
+ARCHHDRDIR = $(extout)/include/$(arch)/ruby$(target_prefix)
+
+TARGET_SO = $(RUBYARCHDIR)/$(DLLIB)
+CLEANLIBS = $(RUBYARCHDIR)/$(TARGET).so
+CLEANOBJS = *.o *.bak
+
+all: install
+static: all
+.PHONY: all install static install-so install-rb
+.PHONY: clean clean-so clean-static clean-rb
+
+clean-static::
+clean-rb-default::
+clean-rb::
+clean-so::
+clean: clean-so clean-static clean-rb-default clean-rb
+ -$(Q)$(RM) $(CLEANLIBS) $(CLEANOBJS) $(CLEANFILES) .*.time
+
+distclean-rb-default::
+distclean-rb::
+distclean-so::
+distclean-static::
+distclean: clean distclean-so distclean-static distclean-rb-default distclean-rb
+ -$(Q)$(RM) Makefile $(RUBY_EXTCONF_H) conftest.* mkmf.log
+ -$(Q)$(RM) core ruby$(EXEEXT) *~ $(DISTCLEANFILES)
+ -$(Q)$(RMDIRS) $(DISTCLEANDIRS) 2> /dev/null || true
+
+realclean: distclean
+install: install-so install-rb
+
+install-so: $(RUBYARCHDIR)/$(DLLIB)
+clean-so::
+ -$(Q)$(RM) $(RUBYARCHDIR)/$(DLLIB)
+ -$(Q)$(RMDIRS) $(RUBYARCHDIR) 2> /dev/null || true
+clean-static::
+ -$(Q)$(RM) $(STATIC_LIB)
+install-rb: pre-install-rb install-rb-default
+install-rb-default: pre-install-rb-default
+pre-install-rb: Makefile
+pre-install-rb-default: Makefile
+pre-install-rb-default:
+ @$(NULLCMD)
+$(TIMESTAMP_DIR)/.RUBYARCHDIR.-.-test-.time:
+ $(Q) $(MAKEDIRS) $(@D) $(RUBYARCHDIR)
+ $(Q) $(TOUCH) $@
+
+site-install: site-install-so site-install-rb
+site-install-so: install-so
+site-install-rb: install-rb
+
+.SUFFIXES: .c .m .cc .mm .cxx .cpp .o .S
+
+.cc.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<
+
+.cc.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -S $<
+
+.mm.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<
+
+.mm.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -S $<
+
+.cxx.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<
+
+.cxx.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -S $<
+
+.cpp.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<
+
+.cpp.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -S $<
+
+.c.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -c $<
+
+.c.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -S $<
+
+.m.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -c $<
+
+.m.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -S $<
+
+$(RUBYARCHDIR)/$(DLLIB): $(OBJS) Makefile $(TIMESTAMP_DIR)/.RUBYARCHDIR.-.-test-.time
+ $(ECHO) linking shared-object -test-/$(DLLIB)
+ -$(Q)$(RM) $(@)
+ $(Q) $(LDSHARED) -o $@ $(OBJS) $(LIBPATH) $(DLDFLAGS) $(LOCAL_LIBS) $(LIBS)
+
+$(STATIC_LIB): $(OBJS)
+ -$(Q)$(RM) $(@)
+ $(ECHO) linking static-library $(@)
+ $(Q) $(AR) cru $@ $(OBJS)
+ -$(Q)ranlib $(@) 2> /dev/null || true
+
+###
+$(OBJS): $(RUBY_EXTCONF_H)
+
+# AUTOGENERATED DEPENDENCIES START
+fs.o: $(RUBY_EXTCONF_H)
+fs.o: $(arch_hdrdir)/ruby/config.h
+fs.o: $(hdrdir)/ruby/defines.h
+fs.o: $(hdrdir)/ruby/encoding.h
+fs.o: $(hdrdir)/ruby/intern.h
+fs.o: $(hdrdir)/ruby/io.h
+fs.o: $(hdrdir)/ruby/missing.h
+fs.o: $(hdrdir)/ruby/oniguruma.h
+fs.o: $(hdrdir)/ruby/ruby.h
+fs.o: $(hdrdir)/ruby/st.h
+fs.o: $(hdrdir)/ruby/subst.h
+fs.o: fs.c
+init.o: $(RUBY_EXTCONF_H)
+init.o: $(arch_hdrdir)/ruby/config.h
+init.o: $(hdrdir)/ruby/defines.h
+init.o: $(hdrdir)/ruby/intern.h
+init.o: $(hdrdir)/ruby/missing.h
+init.o: $(hdrdir)/ruby/ruby.h
+init.o: $(hdrdir)/ruby/st.h
+init.o: $(hdrdir)/ruby/subst.h
+init.o: $(top_srcdir)/include/ruby.h
+init.o: init.c
+stat.o: $(RUBY_EXTCONF_H)
+stat.o: $(arch_hdrdir)/ruby/config.h
+stat.o: $(hdrdir)/ruby/defines.h
+stat.o: $(hdrdir)/ruby/encoding.h
+stat.o: $(hdrdir)/ruby/intern.h
+stat.o: $(hdrdir)/ruby/io.h
+stat.o: $(hdrdir)/ruby/missing.h
+stat.o: $(hdrdir)/ruby/oniguruma.h
+stat.o: $(hdrdir)/ruby/ruby.h
+stat.o: $(hdrdir)/ruby/st.h
+stat.o: $(hdrdir)/ruby/subst.h
+stat.o: stat.c
+# AUTOGENERATED DEPENDENCIES END
diff --git a/jni/ruby/ext/-test-/file/depend b/jni/ruby/ext/-test-/file/depend
new file mode 100644
index 0000000..a43b427
--- /dev/null
+++ b/jni/ruby/ext/-test-/file/depend
@@ -0,0 +1,36 @@
+# AUTOGENERATED DEPENDENCIES START
+fs.o: $(RUBY_EXTCONF_H)
+fs.o: $(arch_hdrdir)/ruby/config.h
+fs.o: $(hdrdir)/ruby/defines.h
+fs.o: $(hdrdir)/ruby/encoding.h
+fs.o: $(hdrdir)/ruby/intern.h
+fs.o: $(hdrdir)/ruby/io.h
+fs.o: $(hdrdir)/ruby/missing.h
+fs.o: $(hdrdir)/ruby/oniguruma.h
+fs.o: $(hdrdir)/ruby/ruby.h
+fs.o: $(hdrdir)/ruby/st.h
+fs.o: $(hdrdir)/ruby/subst.h
+fs.o: fs.c
+init.o: $(RUBY_EXTCONF_H)
+init.o: $(arch_hdrdir)/ruby/config.h
+init.o: $(hdrdir)/ruby/defines.h
+init.o: $(hdrdir)/ruby/intern.h
+init.o: $(hdrdir)/ruby/missing.h
+init.o: $(hdrdir)/ruby/ruby.h
+init.o: $(hdrdir)/ruby/st.h
+init.o: $(hdrdir)/ruby/subst.h
+init.o: $(top_srcdir)/include/ruby.h
+init.o: init.c
+stat.o: $(RUBY_EXTCONF_H)
+stat.o: $(arch_hdrdir)/ruby/config.h
+stat.o: $(hdrdir)/ruby/defines.h
+stat.o: $(hdrdir)/ruby/encoding.h
+stat.o: $(hdrdir)/ruby/intern.h
+stat.o: $(hdrdir)/ruby/io.h
+stat.o: $(hdrdir)/ruby/missing.h
+stat.o: $(hdrdir)/ruby/oniguruma.h
+stat.o: $(hdrdir)/ruby/ruby.h
+stat.o: $(hdrdir)/ruby/st.h
+stat.o: $(hdrdir)/ruby/subst.h
+stat.o: stat.c
+# AUTOGENERATED DEPENDENCIES END
diff --git a/jni/ruby/ext/-test-/file/extconf.h b/jni/ruby/ext/-test-/file/extconf.h
new file mode 100644
index 0000000..49c2892
--- /dev/null
+++ b/jni/ruby/ext/-test-/file/extconf.h
@@ -0,0 +1,11 @@
+#ifndef EXTCONF_H
+#define EXTCONF_H
+#define HAVE_SYS_PARAM_H 1
+#define HAVE_SYS_MOUNT_H 1
+#define HAVE_SYS_VFS_H 1
+#define HAVE_TYPE_STRUCT_STATFS 1
+#define HAVE_STRUCT_STATFS_F_TYPE 1
+#define HAVE_ST_F_TYPE 1
+#define HAVE_TYPE_STRUCT_STATVFS 1
+#define TEST_INIT_FUNCS(X) X(fs) X(stat)
+#endif
diff --git a/jni/ruby/ext/-test-/file/extconf.rb b/jni/ruby/ext/-test-/file/extconf.rb
new file mode 100644
index 0000000..be4a2fb
--- /dev/null
+++ b/jni/ruby/ext/-test-/file/extconf.rb
@@ -0,0 +1,21 @@
+$INCFLAGS << " -I$(topdir) -I$(top_srcdir)"
+
+headers = %w[sys/param.h sys/mount.h sys/vfs.h].select {|h| have_header(h)}
+if have_type("struct statfs", headers)
+ have_struct_member("struct statfs", "f_fstypename", headers)
+ have_struct_member("struct statfs", "f_type", headers)
+end
+
+headers = %w[sys/statvfs.h]
+if have_type("struct statvfs", headers)
+ have_struct_member("struct statvfs", "f_fstypename", headers)
+ have_struct_member("struct statvfs", "f_basetype", headers)
+ have_struct_member("struct statvfs", "f_type", headers)
+end
+
+$srcs = Dir[File.join($srcdir, "*.{#{SRC_EXT.join(%q{,})}}")]
+inits = $srcs.map {|s| File.basename(s, ".*")}
+inits.delete("init")
+inits.map! {|s|"X(#{s})"}
+$defs << "-DTEST_INIT_FUNCS(X)=\"#{inits.join(' ')}\""
+create_makefile("-test-/file")
diff --git a/jni/ruby/ext/-test-/file/fs.c b/jni/ruby/ext/-test-/file/fs.c
new file mode 100644
index 0000000..1ab067e
--- /dev/null
+++ b/jni/ruby/ext/-test-/file/fs.c
@@ -0,0 +1,74 @@
+#include "ruby/ruby.h"
+#include "ruby/io.h"
+
+#ifdef HAVE_SYS_MOUNT_H
+#include <sys/mount.h>
+#endif
+#ifdef HAVE_SYS_VFS_H
+#include <sys/vfs.h>
+#endif
+
+#if defined HAVE_STRUCT_STATFS_F_FSTYPENAME
+typedef struct statfs statfs_t;
+# define STATFS(f, s) statfs((f), (s))
+# define HAVE_STRUCT_STATFS_T_F_FSTYPENAME 1
+# if defined HAVE_STRUCT_STATFS_F_TYPE
+# define HAVE_STRUCT_STATFS_T_F_TYPE 1
+# endif
+#elif defined(HAVE_STRUCT_STATVFS_F_FSTYPENAME) /* NetBSD */
+typedef struct statvfs statfs_t;
+# define STATFS(f, s) statvfs((f), (s))
+# define HAVE_STRUCT_STATFS_T_F_FSTYPENAME 1
+# if defined HAVE_STRUCT_STATVFS_F_TYPE
+# define HAVE_STRUCT_STATFS_T_F_TYPE 1
+# endif
+#elif defined(HAVE_STRUCT_STATVFS_F_BASETYPE) /* AIX, HP-UX, Solaris */
+typedef struct statvfs statfs_t;
+# define STATFS(f, s) statvfs((f), (s))
+# define HAVE_STRUCT_STATFS_T_F_FSTYPENAME 1
+# define f_fstypename f_basetype
+# if defined HAVE_STRUCT_STATVFS_F_TYPE
+# define HAVE_STRUCT_STATFS_T_F_TYPE 1
+# endif
+#endif
+
+VALUE
+get_fsname(VALUE self, VALUE str)
+{
+#ifdef STATFS
+ statfs_t st;
+# define CSTR(s) rb_str_new_cstr(s)
+
+ FilePathValue(str);
+ str = rb_str_encode_ospath(str);
+ if (STATFS(StringValueCStr(str), &st) == -1) {
+ rb_sys_fail_str(str);
+ }
+# ifdef HAVE_STRUCT_STATFS_T_F_FSTYPENAME
+ if (st.f_fstypename[0])
+ return CSTR(st.f_fstypename);
+# endif
+# ifdef HAVE_STRUCT_STATFS_T_F_TYPE
+ switch (st.f_type) {
+ case 0x9123683E: /* BTRFS_SUPER_MAGIC */
+ return CSTR("btrfs");
+ case 0x7461636f: /* OCFS2_SUPER_MAGIC */
+ return CSTR("ocfs");
+ case 0xEF53: /* EXT2_SUPER_MAGIC EXT3_SUPER_MAGIC EXT4_SUPER_MAGIC */
+ return CSTR("ext4");
+ case 0x58465342: /* XFS_SUPER_MAGIC */
+ return CSTR("xfs");
+ case 0x01021994: /* TMPFS_MAGIC */
+ return CSTR("tmpfs");
+ }
+# endif
+#endif
+ return Qnil;
+}
+
+void
+Init_fs(VALUE module)
+{
+ VALUE fs = rb_define_module_under(module, "Fs");
+ rb_define_module_function(fs, "fsname", get_fsname, 1);
+}
diff --git a/jni/ruby/ext/-test-/file/init.c b/jni/ruby/ext/-test-/file/init.c
new file mode 100644
index 0000000..1117993
--- /dev/null
+++ b/jni/ruby/ext/-test-/file/init.c
@@ -0,0 +1,11 @@
+#include "ruby.h"
+
+#define init(n) {void Init_##n(VALUE klass); Init_##n(module);}
+
+void
+Init_file(void)
+{
+ VALUE mBug = rb_define_module("Bug");
+ VALUE module = rb_define_module_under(mBug, "File");
+ TEST_INIT_FUNCS(init);
+}
diff --git a/jni/ruby/ext/-test-/file/stat.c b/jni/ruby/ext/-test-/file/stat.c
new file mode 100644
index 0000000..fed5d38
--- /dev/null
+++ b/jni/ruby/ext/-test-/file/stat.c
@@ -0,0 +1,27 @@
+#include "ruby/ruby.h"
+#include "ruby/io.h"
+
+static VALUE
+stat_for_fd(VALUE self, VALUE fileno)
+{
+ struct stat st;
+ if (fstat(NUM2INT(fileno), &st)) rb_sys_fail(0);
+ return rb_stat_new(&st);
+}
+
+static VALUE
+stat_for_path(VALUE self, VALUE path)
+{
+ struct stat st;
+ FilePathValue(path);
+ if (stat(RSTRING_PTR(path), &st)) rb_sys_fail(0);
+ return rb_stat_new(&st);
+}
+
+void
+Init_stat(VALUE module)
+{
+ VALUE st = rb_define_module_under(module, "Stat");
+ rb_define_module_function(st, "for_fd", stat_for_fd, 1);
+ rb_define_module_function(st, "for_path", stat_for_path, 1);
+}
diff --git a/jni/ruby/ext/-test-/float/Makefile b/jni/ruby/ext/-test-/float/Makefile
new file mode 100644
index 0000000..c551dc3
--- /dev/null
+++ b/jni/ruby/ext/-test-/float/Makefile
@@ -0,0 +1,272 @@
+
+SHELL = /bin/sh
+
+# V=0 quiet, V=1 verbose. other values don't work.
+V = 0
+Q1 = $(V:1=)
+Q = $(Q1:0=@)
+ECHO1 = $(V:1=@:)
+ECHO = $(ECHO1:0=@echo)
+NULLCMD = :
+
+#### Start of system configuration section. ####
+top_srcdir = $(topdir)/.
+srcdir = $(top_srcdir)/ext/-test-/float
+topdir = ../../..
+hdrdir = $(top_srcdir)/include
+arch_hdrdir = $(extout)/include/$(arch)
+PATH_SEPARATOR = :
+VPATH = $(srcdir):$(arch_hdrdir)/ruby:$(hdrdir)/ruby
+RUBYLIB =
+RUBYOPT = -
+prefix = $(DESTDIR)/usr/local
+rubysitearchprefix = $(rubylibprefix)/$(sitearch)
+rubyarchprefix = $(rubylibprefix)/$(arch)
+rubylibprefix = $(libdir)/$(RUBY_BASE_NAME)
+exec_prefix = $(prefix)
+vendorarchhdrdir = $(vendorhdrdir)/$(sitearch)
+sitearchhdrdir = $(sitehdrdir)/$(sitearch)
+rubyarchhdrdir = $(rubyhdrdir)/$(arch)
+vendorhdrdir = $(rubyhdrdir)/vendor_ruby
+sitehdrdir = $(rubyhdrdir)/site_ruby
+rubyhdrdir = $(includedir)/$(RUBY_VERSION_NAME)
+vendorarchdir = $(vendorlibdir)/$(sitearch)
+vendorlibdir = $(vendordir)/$(ruby_version)
+vendordir = $(rubylibprefix)/vendor_ruby
+sitearchdir = $(sitelibdir)/$(sitearch)
+sitelibdir = $(sitedir)/$(ruby_version)
+sitedir = $(rubylibprefix)/site_ruby
+rubyarchdir = $(rubylibdir)/$(arch)
+rubylibdir = $(rubylibprefix)/$(ruby_version)
+sitearchincludedir = $(includedir)/$(sitearch)
+archincludedir = $(includedir)/$(arch)
+sitearchlibdir = $(libdir)/$(sitearch)
+archlibdir = $(libdir)/$(arch)
+ridir = $(datarootdir)/$(RI_BASE_NAME)
+mandir = $(datarootdir)/man
+localedir = $(datarootdir)/locale
+libdir = $(exec_prefix)/lib
+psdir = $(docdir)
+pdfdir = $(docdir)
+dvidir = $(docdir)
+htmldir = $(docdir)
+infodir = $(datarootdir)/info
+docdir = $(datarootdir)/doc/$(PACKAGE)
+oldincludedir = $(DESTDIR)/usr/include
+includedir = $(prefix)/include
+localstatedir = $(prefix)/var
+sharedstatedir = $(prefix)/com
+sysconfdir = $(prefix)/etc
+datadir = $(datarootdir)
+datarootdir = $(prefix)/share
+libexecdir = $(exec_prefix)/libexec
+sbindir = $(exec_prefix)/sbin
+bindir = $(exec_prefix)/bin
+archdir = $(rubyarchdir)
+
+
+CC = gcc
+CXX = g++
+LIBRUBY = $(LIBRUBY_SO)
+LIBRUBY_A = lib$(RUBY_SO_NAME)-static.a
+LIBRUBYARG_SHARED = -Wl,-R$(libdir) -L$(libdir) -l$(RUBY_SO_NAME)
+LIBRUBYARG_STATIC = -Wl,-R$(libdir) -L$(libdir) -l$(RUBY_SO_NAME)-static
+empty =
+OUTFLAG = -o $(empty)
+COUTFLAG = -o $(empty)
+
+RUBY_EXTCONF_H = extconf.h
+cflags = $(optflags) $(debugflags) $(warnflags)
+optflags = -O3 -fno-fast-math
+debugflags = -ggdb3
+warnflags = -Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wunused-variable -Wpointer-arith -Wwrite-strings -Wdeclaration-after-statement -Wimplicit-function-declaration -Wdeprecated-declarations -Wno-packed-bitfield-compat
+CCDLFLAGS = -fPIC
+CFLAGS = $(CCDLFLAGS) $(cflags) -fPIC $(ARCH_FLAG)
+INCFLAGS = -I. -I$(arch_hdrdir) -I$(hdrdir) -I$(srcdir) -I$(topdir) -I$(top_srcdir)
+DEFS =
+CPPFLAGS = -DRUBY_EXTCONF_H=\"$(RUBY_EXTCONF_H)\" $(DEFS) $(cppflags)
+CXXFLAGS = $(CCDLFLAGS) $(cxxflags) $(ARCH_FLAG)
+ldflags = -L. -fstack-protector -rdynamic -Wl,-export-dynamic
+dldflags =
+ARCH_FLAG =
+DLDFLAGS = $(ldflags) $(dldflags) $(ARCH_FLAG)
+LDSHARED = $(CC) -shared
+LDSHAREDXX = $(CXX) -shared
+AR = ar
+EXEEXT =
+
+RUBY_INSTALL_NAME = $(RUBY_BASE_NAME)
+RUBY_SO_NAME = ruby
+RUBYW_INSTALL_NAME =
+RUBY_VERSION_NAME = $(RUBY_BASE_NAME)-$(ruby_version)
+RUBYW_BASE_NAME = rubyw
+RUBY_BASE_NAME = ruby
+
+arch = x86_64-linux
+sitearch = $(arch)
+ruby_version = 2.2.0
+ruby = $(topdir)/miniruby -I'$(topdir)' -I'$(top_srcdir)/lib' -I'$(extout)/$(arch)' -I'$(extout)/common'
+RUBY = $(ruby)
+ruby_headers = $(hdrdir)/ruby.h $(hdrdir)/ruby/ruby.h $(hdrdir)/ruby/defines.h $(hdrdir)/ruby/missing.h $(hdrdir)/ruby/intern.h $(hdrdir)/ruby/st.h $(hdrdir)/ruby/subst.h $(arch_hdrdir)/ruby/config.h $(RUBY_EXTCONF_H)
+
+RM = rm -f
+RM_RF = $(RUBY) -run -e rm -- -rf
+RMDIRS = rmdir --ignore-fail-on-non-empty -p
+MAKEDIRS = /bin/mkdir -p
+INSTALL = /usr/bin/install -c
+INSTALL_PROG = $(INSTALL) -m 0755
+INSTALL_DATA = $(INSTALL) -m 644
+COPY = cp
+TOUCH = exit >
+
+#### End of system configuration section. ####
+
+preload =
+
+libpath = . $(topdir)
+LIBPATH = -L. -L$(topdir)
+DEFFILE =
+
+CLEANFILES = mkmf.log
+DISTCLEANFILES =
+DISTCLEANDIRS =
+
+extout = $(topdir)/.ext
+extout_prefix = $(extout)$(target_prefix)/
+target_prefix = /-test-
+LOCAL_LIBS =
+LIBS = $(LIBRUBYARG_SHARED) -lpthread -lgmp -ldl -lcrypt -lm -lc
+ORIG_SRCS = nextafter.c init.c
+SRCS = $(ORIG_SRCS)
+OBJS = nextafter.o init.o
+HDRS = $(srcdir)/extconf.h
+TARGET = float
+TARGET_NAME = float
+TARGET_ENTRY = Init_$(TARGET_NAME)
+DLLIB = $(TARGET).so
+EXTSTATIC =
+STATIC_LIB = $(TARGET).a
+
+TIMESTAMP_DIR = $(extout)/.timestamp
+BINDIR = $(extout)/bin
+RUBYCOMMONDIR = $(extout)/common
+RUBYLIBDIR = $(RUBYCOMMONDIR)$(target_prefix)
+RUBYARCHDIR = $(extout)/$(arch)$(target_prefix)
+HDRDIR = $(extout)/include/ruby$(target_prefix)
+ARCHHDRDIR = $(extout)/include/$(arch)/ruby$(target_prefix)
+
+TARGET_SO = $(RUBYARCHDIR)/$(DLLIB)
+CLEANLIBS = $(RUBYARCHDIR)/$(TARGET).so
+CLEANOBJS = *.o *.bak
+
+all: install
+static: all
+.PHONY: all install static install-so install-rb
+.PHONY: clean clean-so clean-static clean-rb
+
+clean-static::
+clean-rb-default::
+clean-rb::
+clean-so::
+clean: clean-so clean-static clean-rb-default clean-rb
+ -$(Q)$(RM) $(CLEANLIBS) $(CLEANOBJS) $(CLEANFILES) .*.time
+
+distclean-rb-default::
+distclean-rb::
+distclean-so::
+distclean-static::
+distclean: clean distclean-so distclean-static distclean-rb-default distclean-rb
+ -$(Q)$(RM) Makefile $(RUBY_EXTCONF_H) conftest.* mkmf.log
+ -$(Q)$(RM) core ruby$(EXEEXT) *~ $(DISTCLEANFILES)
+ -$(Q)$(RMDIRS) $(DISTCLEANDIRS) 2> /dev/null || true
+
+realclean: distclean
+install: install-so install-rb
+
+install-so: $(RUBYARCHDIR)/$(DLLIB)
+clean-so::
+ -$(Q)$(RM) $(RUBYARCHDIR)/$(DLLIB)
+ -$(Q)$(RMDIRS) $(RUBYARCHDIR) 2> /dev/null || true
+clean-static::
+ -$(Q)$(RM) $(STATIC_LIB)
+install-rb: pre-install-rb install-rb-default
+install-rb-default: pre-install-rb-default
+pre-install-rb: Makefile
+pre-install-rb-default: Makefile
+pre-install-rb-default:
+ @$(NULLCMD)
+$(TIMESTAMP_DIR)/.RUBYARCHDIR.-.-test-.time:
+ $(Q) $(MAKEDIRS) $(@D) $(RUBYARCHDIR)
+ $(Q) $(TOUCH) $@
+
+site-install: site-install-so site-install-rb
+site-install-so: install-so
+site-install-rb: install-rb
+
+.SUFFIXES: .c .m .cc .mm .cxx .cpp .o .S
+
+.cc.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<
+
+.cc.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -S $<
+
+.mm.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<
+
+.mm.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -S $<
+
+.cxx.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<
+
+.cxx.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -S $<
+
+.cpp.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<
+
+.cpp.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -S $<
+
+.c.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -c $<
+
+.c.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -S $<
+
+.m.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -c $<
+
+.m.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -S $<
+
+$(RUBYARCHDIR)/$(DLLIB): $(OBJS) Makefile $(TIMESTAMP_DIR)/.RUBYARCHDIR.-.-test-.time
+ $(ECHO) linking shared-object -test-/$(DLLIB)
+ -$(Q)$(RM) $(@)
+ $(Q) $(LDSHARED) -o $@ $(OBJS) $(LIBPATH) $(DLDFLAGS) $(LOCAL_LIBS) $(LIBS)
+
+$(STATIC_LIB): $(OBJS)
+ -$(Q)$(RM) $(@)
+ $(ECHO) linking static-library $(@)
+ $(Q) $(AR) cru $@ $(OBJS)
+ -$(Q)ranlib $(@) 2> /dev/null || true
+
+###
+$(OBJS): $(RUBY_EXTCONF_H)
+
+$(OBJS): $(HDRS) $(ruby_headers)
+
+nextafter.o: nextafter.c $(top_srcdir)/missing/nextafter.c
diff --git a/jni/ruby/ext/-test-/float/depend b/jni/ruby/ext/-test-/float/depend
new file mode 100644
index 0000000..dff1455
--- /dev/null
+++ b/jni/ruby/ext/-test-/float/depend
@@ -0,0 +1,3 @@
+$(OBJS): $(HDRS) $(ruby_headers)
+
+nextafter.o: nextafter.c $(top_srcdir)/missing/nextafter.c
diff --git a/jni/ruby/ext/-test-/float/extconf.h b/jni/ruby/ext/-test-/float/extconf.h
new file mode 100644
index 0000000..2e846d2
--- /dev/null
+++ b/jni/ruby/ext/-test-/float/extconf.h
@@ -0,0 +1,4 @@
+#ifndef EXTCONF_H
+#define EXTCONF_H
+#define TEST_INIT_FUNCS(X) X(nextafter)
+#endif
diff --git a/jni/ruby/ext/-test-/float/extconf.rb b/jni/ruby/ext/-test-/float/extconf.rb
new file mode 100644
index 0000000..0a9a299
--- /dev/null
+++ b/jni/ruby/ext/-test-/float/extconf.rb
@@ -0,0 +1,7 @@
+$INCFLAGS << " -I$(topdir) -I$(top_srcdir)"
+$srcs = Dir[File.join($srcdir, "*.{#{SRC_EXT.join(%q{,})}}")]
+inits = $srcs.map {|s| File.basename(s, ".*")}
+inits.delete("init")
+inits.map! {|s|"X(#{s})"}
+$defs << "-DTEST_INIT_FUNCS(X)=\"#{inits.join(' ')}\""
+create_makefile("-test-/float")
diff --git a/jni/ruby/ext/-test-/float/init.c b/jni/ruby/ext/-test-/float/init.c
new file mode 100644
index 0000000..d962108
--- /dev/null
+++ b/jni/ruby/ext/-test-/float/init.c
@@ -0,0 +1,11 @@
+#include "ruby.h"
+
+#define init(n) {void Init_##n(VALUE klass); Init_##n(klass);}
+
+void
+Init_float(void)
+{
+ VALUE mBug = rb_define_module("Bug");
+ VALUE klass = rb_define_class_under(mBug, "Float", rb_cObject);
+ TEST_INIT_FUNCS(init);
+}
diff --git a/jni/ruby/ext/-test-/float/nextafter.c b/jni/ruby/ext/-test-/float/nextafter.c
new file mode 100644
index 0000000..30fb71f
--- /dev/null
+++ b/jni/ruby/ext/-test-/float/nextafter.c
@@ -0,0 +1,36 @@
+#include "ruby.h"
+
+static VALUE
+system_nextafter_m(VALUE klass, VALUE vx, VALUE vy)
+{
+ double x, y, z;
+
+ x = NUM2DBL(vx);
+ y = NUM2DBL(vy);
+ z = nextafter(x, y);
+
+ return DBL2NUM(z);
+}
+
+#define nextafter missing_nextafter
+#include "../../../missing/nextafter.c"
+#undef nextafter
+
+static VALUE
+missing_nextafter_m(VALUE klass, VALUE vx, VALUE vy)
+{
+ double x, y, z;
+
+ x = NUM2DBL(vx);
+ y = NUM2DBL(vy);
+ z = missing_nextafter(x, y);
+
+ return DBL2NUM(z);
+}
+
+void
+Init_nextafter(VALUE klass)
+{
+ rb_define_singleton_method(klass, "system_nextafter", system_nextafter_m, 2);
+ rb_define_singleton_method(klass, "missing_nextafter", missing_nextafter_m, 2);
+}
diff --git a/jni/ruby/ext/-test-/funcall/Makefile b/jni/ruby/ext/-test-/funcall/Makefile
new file mode 100644
index 0000000..1ac3c82
--- /dev/null
+++ b/jni/ruby/ext/-test-/funcall/Makefile
@@ -0,0 +1,267 @@
+
+SHELL = /bin/sh
+
+# V=0 quiet, V=1 verbose. other values don't work.
+V = 0
+Q1 = $(V:1=)
+Q = $(Q1:0=@)
+ECHO1 = $(V:1=@:)
+ECHO = $(ECHO1:0=@echo)
+NULLCMD = :
+
+#### Start of system configuration section. ####
+top_srcdir = $(topdir)/.
+srcdir = $(top_srcdir)/ext/-test-/funcall
+topdir = ../../..
+hdrdir = $(top_srcdir)/include
+arch_hdrdir = $(extout)/include/$(arch)
+PATH_SEPARATOR = :
+VPATH = $(srcdir):$(arch_hdrdir)/ruby:$(hdrdir)/ruby
+RUBYLIB =
+RUBYOPT = -
+prefix = $(DESTDIR)/usr/local
+rubysitearchprefix = $(rubylibprefix)/$(sitearch)
+rubyarchprefix = $(rubylibprefix)/$(arch)
+rubylibprefix = $(libdir)/$(RUBY_BASE_NAME)
+exec_prefix = $(prefix)
+vendorarchhdrdir = $(vendorhdrdir)/$(sitearch)
+sitearchhdrdir = $(sitehdrdir)/$(sitearch)
+rubyarchhdrdir = $(rubyhdrdir)/$(arch)
+vendorhdrdir = $(rubyhdrdir)/vendor_ruby
+sitehdrdir = $(rubyhdrdir)/site_ruby
+rubyhdrdir = $(includedir)/$(RUBY_VERSION_NAME)
+vendorarchdir = $(vendorlibdir)/$(sitearch)
+vendorlibdir = $(vendordir)/$(ruby_version)
+vendordir = $(rubylibprefix)/vendor_ruby
+sitearchdir = $(sitelibdir)/$(sitearch)
+sitelibdir = $(sitedir)/$(ruby_version)
+sitedir = $(rubylibprefix)/site_ruby
+rubyarchdir = $(rubylibdir)/$(arch)
+rubylibdir = $(rubylibprefix)/$(ruby_version)
+sitearchincludedir = $(includedir)/$(sitearch)
+archincludedir = $(includedir)/$(arch)
+sitearchlibdir = $(libdir)/$(sitearch)
+archlibdir = $(libdir)/$(arch)
+ridir = $(datarootdir)/$(RI_BASE_NAME)
+mandir = $(datarootdir)/man
+localedir = $(datarootdir)/locale
+libdir = $(exec_prefix)/lib
+psdir = $(docdir)
+pdfdir = $(docdir)
+dvidir = $(docdir)
+htmldir = $(docdir)
+infodir = $(datarootdir)/info
+docdir = $(datarootdir)/doc/$(PACKAGE)
+oldincludedir = $(DESTDIR)/usr/include
+includedir = $(prefix)/include
+localstatedir = $(prefix)/var
+sharedstatedir = $(prefix)/com
+sysconfdir = $(prefix)/etc
+datadir = $(datarootdir)
+datarootdir = $(prefix)/share
+libexecdir = $(exec_prefix)/libexec
+sbindir = $(exec_prefix)/sbin
+bindir = $(exec_prefix)/bin
+archdir = $(rubyarchdir)
+
+
+CC = gcc
+CXX = g++
+LIBRUBY = $(LIBRUBY_SO)
+LIBRUBY_A = lib$(RUBY_SO_NAME)-static.a
+LIBRUBYARG_SHARED = -Wl,-R$(libdir) -L$(libdir) -l$(RUBY_SO_NAME)
+LIBRUBYARG_STATIC = -Wl,-R$(libdir) -L$(libdir) -l$(RUBY_SO_NAME)-static
+empty =
+OUTFLAG = -o $(empty)
+COUTFLAG = -o $(empty)
+
+RUBY_EXTCONF_H = extconf.h
+cflags = $(optflags) $(debugflags) $(warnflags)
+optflags = -O3 -fno-fast-math
+debugflags = -ggdb3
+warnflags = -Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wunused-variable -Wpointer-arith -Wwrite-strings -Wdeclaration-after-statement -Wimplicit-function-declaration -Wdeprecated-declarations -Wno-packed-bitfield-compat
+CCDLFLAGS = -fPIC
+CFLAGS = $(CCDLFLAGS) $(cflags) -fPIC $(ARCH_FLAG)
+INCFLAGS = -I. -I$(arch_hdrdir) -I$(hdrdir) -I$(srcdir)
+DEFS =
+CPPFLAGS = -DRUBY_EXTCONF_H=\"$(RUBY_EXTCONF_H)\" $(DEFS) $(cppflags)
+CXXFLAGS = $(CCDLFLAGS) $(cxxflags) $(ARCH_FLAG)
+ldflags = -L. -fstack-protector -rdynamic -Wl,-export-dynamic
+dldflags =
+ARCH_FLAG =
+DLDFLAGS = $(ldflags) $(dldflags) $(ARCH_FLAG)
+LDSHARED = $(CC) -shared
+LDSHAREDXX = $(CXX) -shared
+AR = ar
+EXEEXT =
+
+RUBY_INSTALL_NAME = $(RUBY_BASE_NAME)
+RUBY_SO_NAME = ruby
+RUBYW_INSTALL_NAME =
+RUBY_VERSION_NAME = $(RUBY_BASE_NAME)-$(ruby_version)
+RUBYW_BASE_NAME = rubyw
+RUBY_BASE_NAME = ruby
+
+arch = x86_64-linux
+sitearch = $(arch)
+ruby_version = 2.2.0
+ruby = $(topdir)/miniruby -I'$(topdir)' -I'$(top_srcdir)/lib' -I'$(extout)/$(arch)' -I'$(extout)/common'
+RUBY = $(ruby)
+ruby_headers = $(hdrdir)/ruby.h $(hdrdir)/ruby/ruby.h $(hdrdir)/ruby/defines.h $(hdrdir)/ruby/missing.h $(hdrdir)/ruby/intern.h $(hdrdir)/ruby/st.h $(hdrdir)/ruby/subst.h $(arch_hdrdir)/ruby/config.h $(RUBY_EXTCONF_H)
+
+RM = rm -f
+RM_RF = $(RUBY) -run -e rm -- -rf
+RMDIRS = rmdir --ignore-fail-on-non-empty -p
+MAKEDIRS = /bin/mkdir -p
+INSTALL = /usr/bin/install -c
+INSTALL_PROG = $(INSTALL) -m 0755
+INSTALL_DATA = $(INSTALL) -m 644
+COPY = cp
+TOUCH = exit >
+
+#### End of system configuration section. ####
+
+preload =
+
+libpath = . $(topdir)
+LIBPATH = -L. -L$(topdir)
+DEFFILE =
+
+CLEANFILES = mkmf.log
+DISTCLEANFILES =
+DISTCLEANDIRS =
+
+extout = $(topdir)/.ext
+extout_prefix = $(extout)$(target_prefix)/
+target_prefix = /-test-/funcall
+LOCAL_LIBS =
+LIBS = $(LIBRUBYARG_SHARED) -lpthread -lgmp -ldl -lcrypt -lm -lc
+ORIG_SRCS = passing_block.c
+SRCS = $(ORIG_SRCS)
+OBJS = passing_block.o
+HDRS = $(srcdir)/extconf.h
+TARGET = funcall
+TARGET_NAME = funcall
+TARGET_ENTRY = Init_$(TARGET_NAME)
+DLLIB = $(TARGET).so
+EXTSTATIC =
+STATIC_LIB = $(TARGET).a
+
+TIMESTAMP_DIR = $(extout)/.timestamp
+BINDIR = $(extout)/bin
+RUBYCOMMONDIR = $(extout)/common
+RUBYLIBDIR = $(RUBYCOMMONDIR)$(target_prefix)
+RUBYARCHDIR = $(extout)/$(arch)$(target_prefix)
+HDRDIR = $(extout)/include/ruby$(target_prefix)
+ARCHHDRDIR = $(extout)/include/$(arch)/ruby$(target_prefix)
+
+TARGET_SO = $(RUBYARCHDIR)/$(DLLIB)
+CLEANLIBS = $(RUBYARCHDIR)/$(TARGET).so
+CLEANOBJS = *.o *.bak
+
+all: install
+static: all
+.PHONY: all install static install-so install-rb
+.PHONY: clean clean-so clean-static clean-rb
+
+clean-static::
+clean-rb-default::
+clean-rb::
+clean-so::
+clean: clean-so clean-static clean-rb-default clean-rb
+ -$(Q)$(RM) $(CLEANLIBS) $(CLEANOBJS) $(CLEANFILES) .*.time
+
+distclean-rb-default::
+distclean-rb::
+distclean-so::
+distclean-static::
+distclean: clean distclean-so distclean-static distclean-rb-default distclean-rb
+ -$(Q)$(RM) Makefile $(RUBY_EXTCONF_H) conftest.* mkmf.log
+ -$(Q)$(RM) core ruby$(EXEEXT) *~ $(DISTCLEANFILES)
+ -$(Q)$(RMDIRS) $(DISTCLEANDIRS) 2> /dev/null || true
+
+realclean: distclean
+install: install-so install-rb
+
+install-so: $(RUBYARCHDIR)/$(DLLIB)
+clean-so::
+ -$(Q)$(RM) $(RUBYARCHDIR)/$(DLLIB)
+ -$(Q)$(RMDIRS) $(RUBYARCHDIR) 2> /dev/null || true
+clean-static::
+ -$(Q)$(RM) $(STATIC_LIB)
+install-rb: pre-install-rb install-rb-default
+install-rb-default: pre-install-rb-default
+pre-install-rb: Makefile
+pre-install-rb-default: Makefile
+pre-install-rb-default:
+ @$(NULLCMD)
+$(TIMESTAMP_DIR)/.RUBYARCHDIR.-.-test-.-.funcall.time:
+ $(Q) $(MAKEDIRS) $(@D) $(RUBYARCHDIR)
+ $(Q) $(TOUCH) $@
+
+site-install: site-install-so site-install-rb
+site-install-so: install-so
+site-install-rb: install-rb
+
+.SUFFIXES: .c .m .cc .mm .cxx .cpp .o .S
+
+.cc.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<
+
+.cc.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -S $<
+
+.mm.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<
+
+.mm.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -S $<
+
+.cxx.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<
+
+.cxx.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -S $<
+
+.cpp.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<
+
+.cpp.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -S $<
+
+.c.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -c $<
+
+.c.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -S $<
+
+.m.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -c $<
+
+.m.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -S $<
+
+$(RUBYARCHDIR)/$(DLLIB): $(OBJS) Makefile $(TIMESTAMP_DIR)/.RUBYARCHDIR.-.-test-.-.funcall.time
+ $(ECHO) linking shared-object -test-/funcall/$(DLLIB)
+ -$(Q)$(RM) $(@)
+ $(Q) $(LDSHARED) -o $@ $(OBJS) $(LIBPATH) $(DLDFLAGS) $(LOCAL_LIBS) $(LIBS)
+
+$(STATIC_LIB): $(OBJS)
+ -$(Q)$(RM) $(@)
+ $(ECHO) linking static-library $(@)
+ $(Q) $(AR) cru $@ $(OBJS)
+ -$(Q)ranlib $(@) 2> /dev/null || true
+
+$(OBJS): $(HDRS) $(ruby_headers)
diff --git a/jni/ruby/ext/-test-/funcall/extconf.h b/jni/ruby/ext/-test-/funcall/extconf.h
new file mode 100644
index 0000000..cda0cc8
--- /dev/null
+++ b/jni/ruby/ext/-test-/funcall/extconf.h
@@ -0,0 +1,3 @@
+#ifndef EXTCONF_H
+#define EXTCONF_H
+#endif
diff --git a/jni/ruby/ext/-test-/funcall/extconf.rb b/jni/ruby/ext/-test-/funcall/extconf.rb
new file mode 100644
index 0000000..8a9179a
--- /dev/null
+++ b/jni/ruby/ext/-test-/funcall/extconf.rb
@@ -0,0 +1,2 @@
+require 'mkmf'
+create_makefile("-test-/funcall/funcall")
diff --git a/jni/ruby/ext/-test-/funcall/passing_block.c b/jni/ruby/ext/-test-/funcall/passing_block.c
new file mode 100644
index 0000000..0200f80
--- /dev/null
+++ b/jni/ruby/ext/-test-/funcall/passing_block.c
@@ -0,0 +1,30 @@
+#include "ruby.h"
+
+VALUE rb_funcall_passing_block(VALUE, ID, int, const VALUE*);
+
+static VALUE
+with_funcall2(int argc, VALUE *argv, VALUE self)
+{
+ return rb_funcall2(self, rb_intern("target"), argc, argv);
+}
+
+static VALUE
+with_funcall_passing_block(int argc, VALUE *argv, VALUE self)
+{
+ return rb_funcall_passing_block(self, rb_intern("target"), argc, argv);
+}
+
+void
+Init_funcall(void)
+{
+ VALUE cRelay = rb_path2class("TestFuncall::Relay");
+
+ rb_define_singleton_method(cRelay,
+ "with_funcall2",
+ with_funcall2,
+ -1);
+ rb_define_singleton_method(cRelay,
+ "with_funcall_passing_block",
+ with_funcall_passing_block,
+ -1);
+}
diff --git a/jni/ruby/ext/-test-/hash/Makefile b/jni/ruby/ext/-test-/hash/Makefile
new file mode 100644
index 0000000..3526528
--- /dev/null
+++ b/jni/ruby/ext/-test-/hash/Makefile
@@ -0,0 +1,267 @@
+
+SHELL = /bin/sh
+
+# V=0 quiet, V=1 verbose. other values don't work.
+V = 0
+Q1 = $(V:1=)
+Q = $(Q1:0=@)
+ECHO1 = $(V:1=@:)
+ECHO = $(ECHO1:0=@echo)
+NULLCMD = :
+
+#### Start of system configuration section. ####
+top_srcdir = $(topdir)/.
+srcdir = $(top_srcdir)/ext/-test-/hash
+topdir = ../../..
+hdrdir = $(top_srcdir)/include
+arch_hdrdir = $(extout)/include/$(arch)
+PATH_SEPARATOR = :
+VPATH = $(srcdir):$(arch_hdrdir)/ruby:$(hdrdir)/ruby
+RUBYLIB =
+RUBYOPT = -
+prefix = $(DESTDIR)/usr/local
+rubysitearchprefix = $(rubylibprefix)/$(sitearch)
+rubyarchprefix = $(rubylibprefix)/$(arch)
+rubylibprefix = $(libdir)/$(RUBY_BASE_NAME)
+exec_prefix = $(prefix)
+vendorarchhdrdir = $(vendorhdrdir)/$(sitearch)
+sitearchhdrdir = $(sitehdrdir)/$(sitearch)
+rubyarchhdrdir = $(rubyhdrdir)/$(arch)
+vendorhdrdir = $(rubyhdrdir)/vendor_ruby
+sitehdrdir = $(rubyhdrdir)/site_ruby
+rubyhdrdir = $(includedir)/$(RUBY_VERSION_NAME)
+vendorarchdir = $(vendorlibdir)/$(sitearch)
+vendorlibdir = $(vendordir)/$(ruby_version)
+vendordir = $(rubylibprefix)/vendor_ruby
+sitearchdir = $(sitelibdir)/$(sitearch)
+sitelibdir = $(sitedir)/$(ruby_version)
+sitedir = $(rubylibprefix)/site_ruby
+rubyarchdir = $(rubylibdir)/$(arch)
+rubylibdir = $(rubylibprefix)/$(ruby_version)
+sitearchincludedir = $(includedir)/$(sitearch)
+archincludedir = $(includedir)/$(arch)
+sitearchlibdir = $(libdir)/$(sitearch)
+archlibdir = $(libdir)/$(arch)
+ridir = $(datarootdir)/$(RI_BASE_NAME)
+mandir = $(datarootdir)/man
+localedir = $(datarootdir)/locale
+libdir = $(exec_prefix)/lib
+psdir = $(docdir)
+pdfdir = $(docdir)
+dvidir = $(docdir)
+htmldir = $(docdir)
+infodir = $(datarootdir)/info
+docdir = $(datarootdir)/doc/$(PACKAGE)
+oldincludedir = $(DESTDIR)/usr/include
+includedir = $(prefix)/include
+localstatedir = $(prefix)/var
+sharedstatedir = $(prefix)/com
+sysconfdir = $(prefix)/etc
+datadir = $(datarootdir)
+datarootdir = $(prefix)/share
+libexecdir = $(exec_prefix)/libexec
+sbindir = $(exec_prefix)/sbin
+bindir = $(exec_prefix)/bin
+archdir = $(rubyarchdir)
+
+
+CC = gcc
+CXX = g++
+LIBRUBY = $(LIBRUBY_SO)
+LIBRUBY_A = lib$(RUBY_SO_NAME)-static.a
+LIBRUBYARG_SHARED = -Wl,-R$(libdir) -L$(libdir) -l$(RUBY_SO_NAME)
+LIBRUBYARG_STATIC = -Wl,-R$(libdir) -L$(libdir) -l$(RUBY_SO_NAME)-static
+empty =
+OUTFLAG = -o $(empty)
+COUTFLAG = -o $(empty)
+
+RUBY_EXTCONF_H = extconf.h
+cflags = $(optflags) $(debugflags) $(warnflags)
+optflags = -O3 -fno-fast-math
+debugflags = -ggdb3
+warnflags = -Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wunused-variable -Wpointer-arith -Wwrite-strings -Wdeclaration-after-statement -Wimplicit-function-declaration -Wdeprecated-declarations -Wno-packed-bitfield-compat
+CCDLFLAGS = -fPIC
+CFLAGS = $(CCDLFLAGS) $(cflags) -fPIC $(ARCH_FLAG)
+INCFLAGS = -I. -I$(arch_hdrdir) -I$(hdrdir) -I$(srcdir) -I$(topdir) -I$(top_srcdir)
+DEFS =
+CPPFLAGS = -DRUBY_EXTCONF_H=\"$(RUBY_EXTCONF_H)\" $(DEFS) $(cppflags)
+CXXFLAGS = $(CCDLFLAGS) $(cxxflags) $(ARCH_FLAG)
+ldflags = -L. -fstack-protector -rdynamic -Wl,-export-dynamic
+dldflags =
+ARCH_FLAG =
+DLDFLAGS = $(ldflags) $(dldflags) $(ARCH_FLAG)
+LDSHARED = $(CC) -shared
+LDSHAREDXX = $(CXX) -shared
+AR = ar
+EXEEXT =
+
+RUBY_INSTALL_NAME = $(RUBY_BASE_NAME)
+RUBY_SO_NAME = ruby
+RUBYW_INSTALL_NAME =
+RUBY_VERSION_NAME = $(RUBY_BASE_NAME)-$(ruby_version)
+RUBYW_BASE_NAME = rubyw
+RUBY_BASE_NAME = ruby
+
+arch = x86_64-linux
+sitearch = $(arch)
+ruby_version = 2.2.0
+ruby = $(topdir)/miniruby -I'$(topdir)' -I'$(top_srcdir)/lib' -I'$(extout)/$(arch)' -I'$(extout)/common'
+RUBY = $(ruby)
+ruby_headers = $(hdrdir)/ruby.h $(hdrdir)/ruby/ruby.h $(hdrdir)/ruby/defines.h $(hdrdir)/ruby/missing.h $(hdrdir)/ruby/intern.h $(hdrdir)/ruby/st.h $(hdrdir)/ruby/subst.h $(arch_hdrdir)/ruby/config.h $(RUBY_EXTCONF_H)
+
+RM = rm -f
+RM_RF = $(RUBY) -run -e rm -- -rf
+RMDIRS = rmdir --ignore-fail-on-non-empty -p
+MAKEDIRS = /bin/mkdir -p
+INSTALL = /usr/bin/install -c
+INSTALL_PROG = $(INSTALL) -m 0755
+INSTALL_DATA = $(INSTALL) -m 644
+COPY = cp
+TOUCH = exit >
+
+#### End of system configuration section. ####
+
+preload =
+
+libpath = . $(topdir)
+LIBPATH = -L. -L$(topdir)
+DEFFILE =
+
+CLEANFILES = mkmf.log
+DISTCLEANFILES =
+DISTCLEANDIRS =
+
+extout = $(topdir)/.ext
+extout_prefix = $(extout)$(target_prefix)/
+target_prefix = /-test-
+LOCAL_LIBS =
+LIBS = $(LIBRUBYARG_SHARED) -lpthread -lgmp -ldl -lcrypt -lm -lc
+ORIG_SRCS = init.c delete.c
+SRCS = $(ORIG_SRCS)
+OBJS = init.o delete.o
+HDRS = $(srcdir)/extconf.h
+TARGET = hash
+TARGET_NAME = hash
+TARGET_ENTRY = Init_$(TARGET_NAME)
+DLLIB = $(TARGET).so
+EXTSTATIC =
+STATIC_LIB = $(TARGET).a
+
+TIMESTAMP_DIR = $(extout)/.timestamp
+BINDIR = $(extout)/bin
+RUBYCOMMONDIR = $(extout)/common
+RUBYLIBDIR = $(RUBYCOMMONDIR)$(target_prefix)
+RUBYARCHDIR = $(extout)/$(arch)$(target_prefix)
+HDRDIR = $(extout)/include/ruby$(target_prefix)
+ARCHHDRDIR = $(extout)/include/$(arch)/ruby$(target_prefix)
+
+TARGET_SO = $(RUBYARCHDIR)/$(DLLIB)
+CLEANLIBS = $(RUBYARCHDIR)/$(TARGET).so
+CLEANOBJS = *.o *.bak
+
+all: install
+static: all
+.PHONY: all install static install-so install-rb
+.PHONY: clean clean-so clean-static clean-rb
+
+clean-static::
+clean-rb-default::
+clean-rb::
+clean-so::
+clean: clean-so clean-static clean-rb-default clean-rb
+ -$(Q)$(RM) $(CLEANLIBS) $(CLEANOBJS) $(CLEANFILES) .*.time
+
+distclean-rb-default::
+distclean-rb::
+distclean-so::
+distclean-static::
+distclean: clean distclean-so distclean-static distclean-rb-default distclean-rb
+ -$(Q)$(RM) Makefile $(RUBY_EXTCONF_H) conftest.* mkmf.log
+ -$(Q)$(RM) core ruby$(EXEEXT) *~ $(DISTCLEANFILES)
+ -$(Q)$(RMDIRS) $(DISTCLEANDIRS) 2> /dev/null || true
+
+realclean: distclean
+install: install-so install-rb
+
+install-so: $(RUBYARCHDIR)/$(DLLIB)
+clean-so::
+ -$(Q)$(RM) $(RUBYARCHDIR)/$(DLLIB)
+ -$(Q)$(RMDIRS) $(RUBYARCHDIR) 2> /dev/null || true
+clean-static::
+ -$(Q)$(RM) $(STATIC_LIB)
+install-rb: pre-install-rb install-rb-default
+install-rb-default: pre-install-rb-default
+pre-install-rb: Makefile
+pre-install-rb-default: Makefile
+pre-install-rb-default:
+ @$(NULLCMD)
+$(TIMESTAMP_DIR)/.RUBYARCHDIR.-.-test-.time:
+ $(Q) $(MAKEDIRS) $(@D) $(RUBYARCHDIR)
+ $(Q) $(TOUCH) $@
+
+site-install: site-install-so site-install-rb
+site-install-so: install-so
+site-install-rb: install-rb
+
+.SUFFIXES: .c .m .cc .mm .cxx .cpp .o .S
+
+.cc.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<
+
+.cc.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -S $<
+
+.mm.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<
+
+.mm.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -S $<
+
+.cxx.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<
+
+.cxx.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -S $<
+
+.cpp.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<
+
+.cpp.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -S $<
+
+.c.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -c $<
+
+.c.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -S $<
+
+.m.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -c $<
+
+.m.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -S $<
+
+$(RUBYARCHDIR)/$(DLLIB): $(OBJS) Makefile $(TIMESTAMP_DIR)/.RUBYARCHDIR.-.-test-.time
+ $(ECHO) linking shared-object -test-/$(DLLIB)
+ -$(Q)$(RM) $(@)
+ $(Q) $(LDSHARED) -o $@ $(OBJS) $(LIBPATH) $(DLDFLAGS) $(LOCAL_LIBS) $(LIBS)
+
+$(STATIC_LIB): $(OBJS)
+ -$(Q)$(RM) $(@)
+ $(ECHO) linking static-library $(@)
+ $(Q) $(AR) cru $@ $(OBJS)
+ -$(Q)ranlib $(@) 2> /dev/null || true
+
+$(OBJS): $(HDRS) $(ruby_headers)
diff --git a/jni/ruby/ext/-test-/hash/delete.c b/jni/ruby/ext/-test-/hash/delete.c
new file mode 100644
index 0000000..10d4aec
--- /dev/null
+++ b/jni/ruby/ext/-test-/hash/delete.c
@@ -0,0 +1,16 @@
+#include "ruby.h"
+
+extern VALUE rb_hash_delete_entry(VALUE hash, VALUE key);
+
+static VALUE
+hash_delete(VALUE hash, VALUE key)
+{
+ VALUE ret = rb_hash_delete_entry(hash, key);
+ return ret == Qundef ? Qnil : rb_ary_new_from_values(1, &ret);
+}
+
+void
+Init_delete(VALUE klass)
+{
+ rb_define_method(klass, "delete!", hash_delete, 1);
+}
diff --git a/jni/ruby/ext/-test-/hash/extconf.h b/jni/ruby/ext/-test-/hash/extconf.h
new file mode 100644
index 0000000..1a04600
--- /dev/null
+++ b/jni/ruby/ext/-test-/hash/extconf.h
@@ -0,0 +1,4 @@
+#ifndef EXTCONF_H
+#define EXTCONF_H
+#define TEST_INIT_FUNCS(X) X(delete)
+#endif
diff --git a/jni/ruby/ext/-test-/hash/extconf.rb b/jni/ruby/ext/-test-/hash/extconf.rb
new file mode 100644
index 0000000..9d4ef4f
--- /dev/null
+++ b/jni/ruby/ext/-test-/hash/extconf.rb
@@ -0,0 +1,7 @@
+$INCFLAGS << " -I$(topdir) -I$(top_srcdir)"
+$srcs = Dir[File.join($srcdir, "*.{#{SRC_EXT.join(%q{,})}}")]
+inits = $srcs.map {|s| File.basename(s, ".*")}
+inits.delete("init")
+inits.map! {|s|"X(#{s})"}
+$defs << "-DTEST_INIT_FUNCS(X)=\"#{inits.join(' ')}\""
+create_makefile("-test-/hash")
diff --git a/jni/ruby/ext/-test-/hash/init.c b/jni/ruby/ext/-test-/hash/init.c
new file mode 100644
index 0000000..9f6cbde
--- /dev/null
+++ b/jni/ruby/ext/-test-/hash/init.c
@@ -0,0 +1,11 @@
+#include "ruby.h"
+
+#define init(n) {void Init_##n(VALUE klass); Init_##n(klass);}
+
+void
+Init_hash(void)
+{
+ VALUE mBug = rb_define_module("Bug");
+ VALUE klass = rb_define_class_under(mBug, "Hash", rb_cHash);
+ TEST_INIT_FUNCS(init);
+}
diff --git a/jni/ruby/ext/-test-/iseq_load/Makefile b/jni/ruby/ext/-test-/iseq_load/Makefile
new file mode 100644
index 0000000..9588e01
--- /dev/null
+++ b/jni/ruby/ext/-test-/iseq_load/Makefile
@@ -0,0 +1,267 @@
+
+SHELL = /bin/sh
+
+# V=0 quiet, V=1 verbose. other values don't work.
+V = 0
+Q1 = $(V:1=)
+Q = $(Q1:0=@)
+ECHO1 = $(V:1=@:)
+ECHO = $(ECHO1:0=@echo)
+NULLCMD = :
+
+#### Start of system configuration section. ####
+top_srcdir = $(topdir)/.
+srcdir = $(top_srcdir)/ext/-test-/iseq_load
+topdir = ../../..
+hdrdir = $(top_srcdir)/include
+arch_hdrdir = $(extout)/include/$(arch)
+PATH_SEPARATOR = :
+VPATH = $(srcdir):$(arch_hdrdir)/ruby:$(hdrdir)/ruby
+RUBYLIB =
+RUBYOPT = -
+prefix = $(DESTDIR)/usr/local
+rubysitearchprefix = $(rubylibprefix)/$(sitearch)
+rubyarchprefix = $(rubylibprefix)/$(arch)
+rubylibprefix = $(libdir)/$(RUBY_BASE_NAME)
+exec_prefix = $(prefix)
+vendorarchhdrdir = $(vendorhdrdir)/$(sitearch)
+sitearchhdrdir = $(sitehdrdir)/$(sitearch)
+rubyarchhdrdir = $(rubyhdrdir)/$(arch)
+vendorhdrdir = $(rubyhdrdir)/vendor_ruby
+sitehdrdir = $(rubyhdrdir)/site_ruby
+rubyhdrdir = $(includedir)/$(RUBY_VERSION_NAME)
+vendorarchdir = $(vendorlibdir)/$(sitearch)
+vendorlibdir = $(vendordir)/$(ruby_version)
+vendordir = $(rubylibprefix)/vendor_ruby
+sitearchdir = $(sitelibdir)/$(sitearch)
+sitelibdir = $(sitedir)/$(ruby_version)
+sitedir = $(rubylibprefix)/site_ruby
+rubyarchdir = $(rubylibdir)/$(arch)
+rubylibdir = $(rubylibprefix)/$(ruby_version)
+sitearchincludedir = $(includedir)/$(sitearch)
+archincludedir = $(includedir)/$(arch)
+sitearchlibdir = $(libdir)/$(sitearch)
+archlibdir = $(libdir)/$(arch)
+ridir = $(datarootdir)/$(RI_BASE_NAME)
+mandir = $(datarootdir)/man
+localedir = $(datarootdir)/locale
+libdir = $(exec_prefix)/lib
+psdir = $(docdir)
+pdfdir = $(docdir)
+dvidir = $(docdir)
+htmldir = $(docdir)
+infodir = $(datarootdir)/info
+docdir = $(datarootdir)/doc/$(PACKAGE)
+oldincludedir = $(DESTDIR)/usr/include
+includedir = $(prefix)/include
+localstatedir = $(prefix)/var
+sharedstatedir = $(prefix)/com
+sysconfdir = $(prefix)/etc
+datadir = $(datarootdir)
+datarootdir = $(prefix)/share
+libexecdir = $(exec_prefix)/libexec
+sbindir = $(exec_prefix)/sbin
+bindir = $(exec_prefix)/bin
+archdir = $(rubyarchdir)
+
+
+CC = gcc
+CXX = g++
+LIBRUBY = $(LIBRUBY_SO)
+LIBRUBY_A = lib$(RUBY_SO_NAME)-static.a
+LIBRUBYARG_SHARED = -Wl,-R$(libdir) -L$(libdir) -l$(RUBY_SO_NAME)
+LIBRUBYARG_STATIC = -Wl,-R$(libdir) -L$(libdir) -l$(RUBY_SO_NAME)-static
+empty =
+OUTFLAG = -o $(empty)
+COUTFLAG = -o $(empty)
+
+RUBY_EXTCONF_H = extconf.h
+cflags = $(optflags) $(debugflags) $(warnflags)
+optflags = -O3 -fno-fast-math
+debugflags = -ggdb3
+warnflags = -Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wunused-variable -Wpointer-arith -Wwrite-strings -Wdeclaration-after-statement -Wimplicit-function-declaration -Wdeprecated-declarations -Wno-packed-bitfield-compat
+CCDLFLAGS = -fPIC
+CFLAGS = $(CCDLFLAGS) $(cflags) -fPIC $(ARCH_FLAG)
+INCFLAGS = -I. -I$(arch_hdrdir) -I$(hdrdir) -I$(srcdir)
+DEFS =
+CPPFLAGS = -DRUBY_EXTCONF_H=\"$(RUBY_EXTCONF_H)\" $(DEFS) $(cppflags)
+CXXFLAGS = $(CCDLFLAGS) $(cxxflags) $(ARCH_FLAG)
+ldflags = -L. -fstack-protector -rdynamic -Wl,-export-dynamic
+dldflags =
+ARCH_FLAG =
+DLDFLAGS = $(ldflags) $(dldflags) $(ARCH_FLAG)
+LDSHARED = $(CC) -shared
+LDSHAREDXX = $(CXX) -shared
+AR = ar
+EXEEXT =
+
+RUBY_INSTALL_NAME = $(RUBY_BASE_NAME)
+RUBY_SO_NAME = ruby
+RUBYW_INSTALL_NAME =
+RUBY_VERSION_NAME = $(RUBY_BASE_NAME)-$(ruby_version)
+RUBYW_BASE_NAME = rubyw
+RUBY_BASE_NAME = ruby
+
+arch = x86_64-linux
+sitearch = $(arch)
+ruby_version = 2.2.0
+ruby = $(topdir)/miniruby -I'$(topdir)' -I'$(top_srcdir)/lib' -I'$(extout)/$(arch)' -I'$(extout)/common'
+RUBY = $(ruby)
+ruby_headers = $(hdrdir)/ruby.h $(hdrdir)/ruby/ruby.h $(hdrdir)/ruby/defines.h $(hdrdir)/ruby/missing.h $(hdrdir)/ruby/intern.h $(hdrdir)/ruby/st.h $(hdrdir)/ruby/subst.h $(arch_hdrdir)/ruby/config.h $(RUBY_EXTCONF_H)
+
+RM = rm -f
+RM_RF = $(RUBY) -run -e rm -- -rf
+RMDIRS = rmdir --ignore-fail-on-non-empty -p
+MAKEDIRS = /bin/mkdir -p
+INSTALL = /usr/bin/install -c
+INSTALL_PROG = $(INSTALL) -m 0755
+INSTALL_DATA = $(INSTALL) -m 644
+COPY = cp
+TOUCH = exit >
+
+#### End of system configuration section. ####
+
+preload =
+
+libpath = . $(topdir)
+LIBPATH = -L. -L$(topdir)
+DEFFILE =
+
+CLEANFILES = mkmf.log
+DISTCLEANFILES =
+DISTCLEANDIRS =
+
+extout = $(topdir)/.ext
+extout_prefix = $(extout)$(target_prefix)/
+target_prefix = /-test-/iseq_load
+LOCAL_LIBS =
+LIBS = $(LIBRUBYARG_SHARED) -lpthread -lgmp -ldl -lcrypt -lm -lc
+ORIG_SRCS = iseq_load.c
+SRCS = $(ORIG_SRCS)
+OBJS = iseq_load.o
+HDRS = $(srcdir)/extconf.h
+TARGET = iseq_load
+TARGET_NAME = iseq_load
+TARGET_ENTRY = Init_$(TARGET_NAME)
+DLLIB = $(TARGET).so
+EXTSTATIC =
+STATIC_LIB = $(TARGET).a
+
+TIMESTAMP_DIR = $(extout)/.timestamp
+BINDIR = $(extout)/bin
+RUBYCOMMONDIR = $(extout)/common
+RUBYLIBDIR = $(RUBYCOMMONDIR)$(target_prefix)
+RUBYARCHDIR = $(extout)/$(arch)$(target_prefix)
+HDRDIR = $(extout)/include/ruby$(target_prefix)
+ARCHHDRDIR = $(extout)/include/$(arch)/ruby$(target_prefix)
+
+TARGET_SO = $(RUBYARCHDIR)/$(DLLIB)
+CLEANLIBS = $(RUBYARCHDIR)/$(TARGET).so
+CLEANOBJS = *.o *.bak
+
+all: install
+static: all
+.PHONY: all install static install-so install-rb
+.PHONY: clean clean-so clean-static clean-rb
+
+clean-static::
+clean-rb-default::
+clean-rb::
+clean-so::
+clean: clean-so clean-static clean-rb-default clean-rb
+ -$(Q)$(RM) $(CLEANLIBS) $(CLEANOBJS) $(CLEANFILES) .*.time
+
+distclean-rb-default::
+distclean-rb::
+distclean-so::
+distclean-static::
+distclean: clean distclean-so distclean-static distclean-rb-default distclean-rb
+ -$(Q)$(RM) Makefile $(RUBY_EXTCONF_H) conftest.* mkmf.log
+ -$(Q)$(RM) core ruby$(EXEEXT) *~ $(DISTCLEANFILES)
+ -$(Q)$(RMDIRS) $(DISTCLEANDIRS) 2> /dev/null || true
+
+realclean: distclean
+install: install-so install-rb
+
+install-so: $(RUBYARCHDIR)/$(DLLIB)
+clean-so::
+ -$(Q)$(RM) $(RUBYARCHDIR)/$(DLLIB)
+ -$(Q)$(RMDIRS) $(RUBYARCHDIR) 2> /dev/null || true
+clean-static::
+ -$(Q)$(RM) $(STATIC_LIB)
+install-rb: pre-install-rb install-rb-default
+install-rb-default: pre-install-rb-default
+pre-install-rb: Makefile
+pre-install-rb-default: Makefile
+pre-install-rb-default:
+ @$(NULLCMD)
+$(TIMESTAMP_DIR)/.RUBYARCHDIR.-.-test-.-.iseq_load.time:
+ $(Q) $(MAKEDIRS) $(@D) $(RUBYARCHDIR)
+ $(Q) $(TOUCH) $@
+
+site-install: site-install-so site-install-rb
+site-install-so: install-so
+site-install-rb: install-rb
+
+.SUFFIXES: .c .m .cc .mm .cxx .cpp .o .S
+
+.cc.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<
+
+.cc.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -S $<
+
+.mm.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<
+
+.mm.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -S $<
+
+.cxx.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<
+
+.cxx.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -S $<
+
+.cpp.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<
+
+.cpp.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -S $<
+
+.c.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -c $<
+
+.c.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -S $<
+
+.m.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -c $<
+
+.m.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -S $<
+
+$(RUBYARCHDIR)/$(DLLIB): $(OBJS) Makefile $(TIMESTAMP_DIR)/.RUBYARCHDIR.-.-test-.-.iseq_load.time
+ $(ECHO) linking shared-object -test-/iseq_load/$(DLLIB)
+ -$(Q)$(RM) $(@)
+ $(Q) $(LDSHARED) -o $@ $(OBJS) $(LIBPATH) $(DLDFLAGS) $(LOCAL_LIBS) $(LIBS)
+
+$(STATIC_LIB): $(OBJS)
+ -$(Q)$(RM) $(@)
+ $(ECHO) linking static-library $(@)
+ $(Q) $(AR) cru $@ $(OBJS)
+ -$(Q)ranlib $(@) 2> /dev/null || true
+
+$(OBJS): $(HDRS) $(ruby_headers)
diff --git a/jni/ruby/ext/-test-/iseq_load/extconf.h b/jni/ruby/ext/-test-/iseq_load/extconf.h
new file mode 100644
index 0000000..cda0cc8
--- /dev/null
+++ b/jni/ruby/ext/-test-/iseq_load/extconf.h
@@ -0,0 +1,3 @@
+#ifndef EXTCONF_H
+#define EXTCONF_H
+#endif
diff --git a/jni/ruby/ext/-test-/iseq_load/extconf.rb b/jni/ruby/ext/-test-/iseq_load/extconf.rb
new file mode 100644
index 0000000..860f30b
--- /dev/null
+++ b/jni/ruby/ext/-test-/iseq_load/extconf.rb
@@ -0,0 +1 @@
+create_makefile("-test-/iseq_load/iseq_load")
diff --git a/jni/ruby/ext/-test-/iseq_load/iseq_load.c b/jni/ruby/ext/-test-/iseq_load/iseq_load.c
new file mode 100644
index 0000000..b4b9a8a
--- /dev/null
+++ b/jni/ruby/ext/-test-/iseq_load/iseq_load.c
@@ -0,0 +1,21 @@
+#include <ruby.h>
+
+VALUE rb_iseq_load(VALUE data, VALUE parent, VALUE opt);
+
+static VALUE
+iseq_load(int argc, VALUE *argv, VALUE self)
+{
+ VALUE data, opt = Qnil;
+
+ rb_scan_args(argc, argv, "11", &data, &opt);
+
+ return rb_iseq_load(data, 0, opt);
+}
+
+void
+Init_iseq_load(void)
+{
+ VALUE rb_cISeq = rb_path2class("RubyVM::InstructionSequence");
+
+ rb_define_singleton_method(rb_cISeq, "iseq_load", iseq_load, -1);
+}
diff --git a/jni/ruby/ext/-test-/iter/Makefile b/jni/ruby/ext/-test-/iter/Makefile
new file mode 100644
index 0000000..3c65d4e
--- /dev/null
+++ b/jni/ruby/ext/-test-/iter/Makefile
@@ -0,0 +1,267 @@
+
+SHELL = /bin/sh
+
+# V=0 quiet, V=1 verbose. other values don't work.
+V = 0
+Q1 = $(V:1=)
+Q = $(Q1:0=@)
+ECHO1 = $(V:1=@:)
+ECHO = $(ECHO1:0=@echo)
+NULLCMD = :
+
+#### Start of system configuration section. ####
+top_srcdir = $(topdir)/.
+srcdir = $(top_srcdir)/ext/-test-/iter
+topdir = ../../..
+hdrdir = $(top_srcdir)/include
+arch_hdrdir = $(extout)/include/$(arch)
+PATH_SEPARATOR = :
+VPATH = $(srcdir):$(arch_hdrdir)/ruby:$(hdrdir)/ruby
+RUBYLIB =
+RUBYOPT = -
+prefix = $(DESTDIR)/usr/local
+rubysitearchprefix = $(rubylibprefix)/$(sitearch)
+rubyarchprefix = $(rubylibprefix)/$(arch)
+rubylibprefix = $(libdir)/$(RUBY_BASE_NAME)
+exec_prefix = $(prefix)
+vendorarchhdrdir = $(vendorhdrdir)/$(sitearch)
+sitearchhdrdir = $(sitehdrdir)/$(sitearch)
+rubyarchhdrdir = $(rubyhdrdir)/$(arch)
+vendorhdrdir = $(rubyhdrdir)/vendor_ruby
+sitehdrdir = $(rubyhdrdir)/site_ruby
+rubyhdrdir = $(includedir)/$(RUBY_VERSION_NAME)
+vendorarchdir = $(vendorlibdir)/$(sitearch)
+vendorlibdir = $(vendordir)/$(ruby_version)
+vendordir = $(rubylibprefix)/vendor_ruby
+sitearchdir = $(sitelibdir)/$(sitearch)
+sitelibdir = $(sitedir)/$(ruby_version)
+sitedir = $(rubylibprefix)/site_ruby
+rubyarchdir = $(rubylibdir)/$(arch)
+rubylibdir = $(rubylibprefix)/$(ruby_version)
+sitearchincludedir = $(includedir)/$(sitearch)
+archincludedir = $(includedir)/$(arch)
+sitearchlibdir = $(libdir)/$(sitearch)
+archlibdir = $(libdir)/$(arch)
+ridir = $(datarootdir)/$(RI_BASE_NAME)
+mandir = $(datarootdir)/man
+localedir = $(datarootdir)/locale
+libdir = $(exec_prefix)/lib
+psdir = $(docdir)
+pdfdir = $(docdir)
+dvidir = $(docdir)
+htmldir = $(docdir)
+infodir = $(datarootdir)/info
+docdir = $(datarootdir)/doc/$(PACKAGE)
+oldincludedir = $(DESTDIR)/usr/include
+includedir = $(prefix)/include
+localstatedir = $(prefix)/var
+sharedstatedir = $(prefix)/com
+sysconfdir = $(prefix)/etc
+datadir = $(datarootdir)
+datarootdir = $(prefix)/share
+libexecdir = $(exec_prefix)/libexec
+sbindir = $(exec_prefix)/sbin
+bindir = $(exec_prefix)/bin
+archdir = $(rubyarchdir)
+
+
+CC = gcc
+CXX = g++
+LIBRUBY = $(LIBRUBY_SO)
+LIBRUBY_A = lib$(RUBY_SO_NAME)-static.a
+LIBRUBYARG_SHARED = -Wl,-R$(libdir) -L$(libdir) -l$(RUBY_SO_NAME)
+LIBRUBYARG_STATIC = -Wl,-R$(libdir) -L$(libdir) -l$(RUBY_SO_NAME)-static
+empty =
+OUTFLAG = -o $(empty)
+COUTFLAG = -o $(empty)
+
+RUBY_EXTCONF_H = extconf.h
+cflags = $(optflags) $(debugflags) $(warnflags)
+optflags = -O3 -fno-fast-math
+debugflags = -ggdb3
+warnflags = -Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wunused-variable -Wpointer-arith -Wwrite-strings -Wdeclaration-after-statement -Wimplicit-function-declaration -Wdeprecated-declarations -Wno-packed-bitfield-compat
+CCDLFLAGS = -fPIC
+CFLAGS = $(CCDLFLAGS) $(cflags) -fPIC $(ARCH_FLAG)
+INCFLAGS = -I. -I$(arch_hdrdir) -I$(hdrdir) -I$(srcdir) -I$(topdir) -I$(top_srcdir)
+DEFS =
+CPPFLAGS = -DRUBY_EXTCONF_H=\"$(RUBY_EXTCONF_H)\" $(DEFS) $(cppflags)
+CXXFLAGS = $(CCDLFLAGS) $(cxxflags) $(ARCH_FLAG)
+ldflags = -L. -fstack-protector -rdynamic -Wl,-export-dynamic
+dldflags =
+ARCH_FLAG =
+DLDFLAGS = $(ldflags) $(dldflags) $(ARCH_FLAG)
+LDSHARED = $(CC) -shared
+LDSHAREDXX = $(CXX) -shared
+AR = ar
+EXEEXT =
+
+RUBY_INSTALL_NAME = $(RUBY_BASE_NAME)
+RUBY_SO_NAME = ruby
+RUBYW_INSTALL_NAME =
+RUBY_VERSION_NAME = $(RUBY_BASE_NAME)-$(ruby_version)
+RUBYW_BASE_NAME = rubyw
+RUBY_BASE_NAME = ruby
+
+arch = x86_64-linux
+sitearch = $(arch)
+ruby_version = 2.2.0
+ruby = $(topdir)/miniruby -I'$(topdir)' -I'$(top_srcdir)/lib' -I'$(extout)/$(arch)' -I'$(extout)/common'
+RUBY = $(ruby)
+ruby_headers = $(hdrdir)/ruby.h $(hdrdir)/ruby/ruby.h $(hdrdir)/ruby/defines.h $(hdrdir)/ruby/missing.h $(hdrdir)/ruby/intern.h $(hdrdir)/ruby/st.h $(hdrdir)/ruby/subst.h $(arch_hdrdir)/ruby/config.h $(RUBY_EXTCONF_H)
+
+RM = rm -f
+RM_RF = $(RUBY) -run -e rm -- -rf
+RMDIRS = rmdir --ignore-fail-on-non-empty -p
+MAKEDIRS = /bin/mkdir -p
+INSTALL = /usr/bin/install -c
+INSTALL_PROG = $(INSTALL) -m 0755
+INSTALL_DATA = $(INSTALL) -m 644
+COPY = cp
+TOUCH = exit >
+
+#### End of system configuration section. ####
+
+preload =
+
+libpath = . $(topdir)
+LIBPATH = -L. -L$(topdir)
+DEFFILE =
+
+CLEANFILES = mkmf.log
+DISTCLEANFILES =
+DISTCLEANDIRS =
+
+extout = $(topdir)/.ext
+extout_prefix = $(extout)$(target_prefix)/
+target_prefix = /-test-
+LOCAL_LIBS =
+LIBS = $(LIBRUBYARG_SHARED) -lpthread -lgmp -ldl -lcrypt -lm -lc
+ORIG_SRCS = yield.c init.c break.c
+SRCS = $(ORIG_SRCS)
+OBJS = yield.o init.o break.o
+HDRS = $(srcdir)/extconf.h
+TARGET = iter
+TARGET_NAME = iter
+TARGET_ENTRY = Init_$(TARGET_NAME)
+DLLIB = $(TARGET).so
+EXTSTATIC =
+STATIC_LIB = $(TARGET).a
+
+TIMESTAMP_DIR = $(extout)/.timestamp
+BINDIR = $(extout)/bin
+RUBYCOMMONDIR = $(extout)/common
+RUBYLIBDIR = $(RUBYCOMMONDIR)$(target_prefix)
+RUBYARCHDIR = $(extout)/$(arch)$(target_prefix)
+HDRDIR = $(extout)/include/ruby$(target_prefix)
+ARCHHDRDIR = $(extout)/include/$(arch)/ruby$(target_prefix)
+
+TARGET_SO = $(RUBYARCHDIR)/$(DLLIB)
+CLEANLIBS = $(RUBYARCHDIR)/$(TARGET).so
+CLEANOBJS = *.o *.bak
+
+all: install
+static: all
+.PHONY: all install static install-so install-rb
+.PHONY: clean clean-so clean-static clean-rb
+
+clean-static::
+clean-rb-default::
+clean-rb::
+clean-so::
+clean: clean-so clean-static clean-rb-default clean-rb
+ -$(Q)$(RM) $(CLEANLIBS) $(CLEANOBJS) $(CLEANFILES) .*.time
+
+distclean-rb-default::
+distclean-rb::
+distclean-so::
+distclean-static::
+distclean: clean distclean-so distclean-static distclean-rb-default distclean-rb
+ -$(Q)$(RM) Makefile $(RUBY_EXTCONF_H) conftest.* mkmf.log
+ -$(Q)$(RM) core ruby$(EXEEXT) *~ $(DISTCLEANFILES)
+ -$(Q)$(RMDIRS) $(DISTCLEANDIRS) 2> /dev/null || true
+
+realclean: distclean
+install: install-so install-rb
+
+install-so: $(RUBYARCHDIR)/$(DLLIB)
+clean-so::
+ -$(Q)$(RM) $(RUBYARCHDIR)/$(DLLIB)
+ -$(Q)$(RMDIRS) $(RUBYARCHDIR) 2> /dev/null || true
+clean-static::
+ -$(Q)$(RM) $(STATIC_LIB)
+install-rb: pre-install-rb install-rb-default
+install-rb-default: pre-install-rb-default
+pre-install-rb: Makefile
+pre-install-rb-default: Makefile
+pre-install-rb-default:
+ @$(NULLCMD)
+$(TIMESTAMP_DIR)/.RUBYARCHDIR.-.-test-.time:
+ $(Q) $(MAKEDIRS) $(@D) $(RUBYARCHDIR)
+ $(Q) $(TOUCH) $@
+
+site-install: site-install-so site-install-rb
+site-install-so: install-so
+site-install-rb: install-rb
+
+.SUFFIXES: .c .m .cc .mm .cxx .cpp .o .S
+
+.cc.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<
+
+.cc.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -S $<
+
+.mm.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<
+
+.mm.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -S $<
+
+.cxx.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<
+
+.cxx.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -S $<
+
+.cpp.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<
+
+.cpp.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -S $<
+
+.c.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -c $<
+
+.c.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -S $<
+
+.m.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -c $<
+
+.m.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -S $<
+
+$(RUBYARCHDIR)/$(DLLIB): $(OBJS) Makefile $(TIMESTAMP_DIR)/.RUBYARCHDIR.-.-test-.time
+ $(ECHO) linking shared-object -test-/$(DLLIB)
+ -$(Q)$(RM) $(@)
+ $(Q) $(LDSHARED) -o $@ $(OBJS) $(LIBPATH) $(DLDFLAGS) $(LOCAL_LIBS) $(LIBS)
+
+$(STATIC_LIB): $(OBJS)
+ -$(Q)$(RM) $(@)
+ $(ECHO) linking static-library $(@)
+ $(Q) $(AR) cru $@ $(OBJS)
+ -$(Q)ranlib $(@) 2> /dev/null || true
+
+$(OBJS): $(HDRS) $(ruby_headers)
diff --git a/jni/ruby/ext/-test-/iter/break.c b/jni/ruby/ext/-test-/iter/break.c
new file mode 100644
index 0000000..66ed26a
--- /dev/null
+++ b/jni/ruby/ext/-test-/iter/break.c
@@ -0,0 +1,25 @@
+#include <ruby.h>
+
+static VALUE
+iter_break(VALUE self)
+{
+ rb_iter_break();
+
+ UNREACHABLE;
+}
+
+static VALUE
+iter_break_value(VALUE self, VALUE val)
+{
+ rb_iter_break_value(val);
+
+ UNREACHABLE;
+}
+
+void
+Init_break(VALUE klass)
+{
+ VALUE breakable = rb_define_module_under(klass, "Breakable");
+ rb_define_module_function(breakable, "iter_break", iter_break, 0);
+ rb_define_module_function(breakable, "iter_break_value", iter_break_value, 1);
+}
diff --git a/jni/ruby/ext/-test-/iter/extconf.h b/jni/ruby/ext/-test-/iter/extconf.h
new file mode 100644
index 0000000..89e2ab5
--- /dev/null
+++ b/jni/ruby/ext/-test-/iter/extconf.h
@@ -0,0 +1,4 @@
+#ifndef EXTCONF_H
+#define EXTCONF_H
+#define TEST_INIT_FUNCS(X) X(yield) X(break)
+#endif
diff --git a/jni/ruby/ext/-test-/iter/extconf.rb b/jni/ruby/ext/-test-/iter/extconf.rb
new file mode 100644
index 0000000..0ba9969
--- /dev/null
+++ b/jni/ruby/ext/-test-/iter/extconf.rb
@@ -0,0 +1,7 @@
+$INCFLAGS << " -I$(topdir) -I$(top_srcdir)"
+$srcs = Dir[File.join($srcdir, "*.{#{SRC_EXT.join(%q{,})}}")]
+inits = $srcs.map {|s| File.basename(s, ".*")}
+inits.delete("init")
+inits.map! {|s|"X(#{s})"}
+$defs << "-DTEST_INIT_FUNCS(X)=\"#{inits.join(' ')}\""
+create_makefile("-test-/iter")
diff --git a/jni/ruby/ext/-test-/iter/init.c b/jni/ruby/ext/-test-/iter/init.c
new file mode 100644
index 0000000..a074ec4
--- /dev/null
+++ b/jni/ruby/ext/-test-/iter/init.c
@@ -0,0 +1,11 @@
+#include "ruby.h"
+
+#define init(n) {void Init_##n(VALUE klass); Init_##n(klass);}
+
+void
+Init_iter(void)
+{
+ VALUE mBug = rb_define_module("Bug");
+ VALUE klass = rb_define_module_under(mBug, "Iter");
+ TEST_INIT_FUNCS(init);
+}
diff --git a/jni/ruby/ext/-test-/iter/yield.c b/jni/ruby/ext/-test-/iter/yield.c
new file mode 100644
index 0000000..3cd408a
--- /dev/null
+++ b/jni/ruby/ext/-test-/iter/yield.c
@@ -0,0 +1,16 @@
+#include <ruby.h>
+
+static VALUE
+yield_block(int argc, VALUE *argv, VALUE self)
+{
+ rb_check_arity(argc, 1, UNLIMITED_ARGUMENTS);
+ return rb_block_call(self, rb_to_id(argv[0]), argc-1, argv+1, rb_yield_block, 0);
+}
+
+void
+Init_yield(VALUE klass)
+{
+ VALUE yield = rb_define_module_under(klass, "Yield");
+
+ rb_define_method(yield, "yield_block", yield_block, -1);
+}
diff --git a/jni/ruby/ext/-test-/load/dot.dot/Makefile b/jni/ruby/ext/-test-/load/dot.dot/Makefile
new file mode 100644
index 0000000..d9e2a49
--- /dev/null
+++ b/jni/ruby/ext/-test-/load/dot.dot/Makefile
@@ -0,0 +1,267 @@
+
+SHELL = /bin/sh
+
+# V=0 quiet, V=1 verbose. other values don't work.
+V = 0
+Q1 = $(V:1=)
+Q = $(Q1:0=@)
+ECHO1 = $(V:1=@:)
+ECHO = $(ECHO1:0=@echo)
+NULLCMD = :
+
+#### Start of system configuration section. ####
+top_srcdir = $(topdir)/.
+srcdir = $(top_srcdir)/ext/-test-/load/dot.dot
+topdir = ../../../..
+hdrdir = $(top_srcdir)/include
+arch_hdrdir = $(extout)/include/$(arch)
+PATH_SEPARATOR = :
+VPATH = $(srcdir):$(arch_hdrdir)/ruby:$(hdrdir)/ruby
+RUBYLIB =
+RUBYOPT = -
+prefix = $(DESTDIR)/usr/local
+rubysitearchprefix = $(rubylibprefix)/$(sitearch)
+rubyarchprefix = $(rubylibprefix)/$(arch)
+rubylibprefix = $(libdir)/$(RUBY_BASE_NAME)
+exec_prefix = $(prefix)
+vendorarchhdrdir = $(vendorhdrdir)/$(sitearch)
+sitearchhdrdir = $(sitehdrdir)/$(sitearch)
+rubyarchhdrdir = $(rubyhdrdir)/$(arch)
+vendorhdrdir = $(rubyhdrdir)/vendor_ruby
+sitehdrdir = $(rubyhdrdir)/site_ruby
+rubyhdrdir = $(includedir)/$(RUBY_VERSION_NAME)
+vendorarchdir = $(vendorlibdir)/$(sitearch)
+vendorlibdir = $(vendordir)/$(ruby_version)
+vendordir = $(rubylibprefix)/vendor_ruby
+sitearchdir = $(sitelibdir)/$(sitearch)
+sitelibdir = $(sitedir)/$(ruby_version)
+sitedir = $(rubylibprefix)/site_ruby
+rubyarchdir = $(rubylibdir)/$(arch)
+rubylibdir = $(rubylibprefix)/$(ruby_version)
+sitearchincludedir = $(includedir)/$(sitearch)
+archincludedir = $(includedir)/$(arch)
+sitearchlibdir = $(libdir)/$(sitearch)
+archlibdir = $(libdir)/$(arch)
+ridir = $(datarootdir)/$(RI_BASE_NAME)
+mandir = $(datarootdir)/man
+localedir = $(datarootdir)/locale
+libdir = $(exec_prefix)/lib
+psdir = $(docdir)
+pdfdir = $(docdir)
+dvidir = $(docdir)
+htmldir = $(docdir)
+infodir = $(datarootdir)/info
+docdir = $(datarootdir)/doc/$(PACKAGE)
+oldincludedir = $(DESTDIR)/usr/include
+includedir = $(prefix)/include
+localstatedir = $(prefix)/var
+sharedstatedir = $(prefix)/com
+sysconfdir = $(prefix)/etc
+datadir = $(datarootdir)
+datarootdir = $(prefix)/share
+libexecdir = $(exec_prefix)/libexec
+sbindir = $(exec_prefix)/sbin
+bindir = $(exec_prefix)/bin
+archdir = $(rubyarchdir)
+
+
+CC = gcc
+CXX = g++
+LIBRUBY = $(LIBRUBY_SO)
+LIBRUBY_A = lib$(RUBY_SO_NAME)-static.a
+LIBRUBYARG_SHARED = -Wl,-R$(libdir) -L$(libdir) -l$(RUBY_SO_NAME)
+LIBRUBYARG_STATIC = -Wl,-R$(libdir) -L$(libdir) -l$(RUBY_SO_NAME)-static
+empty =
+OUTFLAG = -o $(empty)
+COUTFLAG = -o $(empty)
+
+RUBY_EXTCONF_H = extconf.h
+cflags = $(optflags) $(debugflags) $(warnflags)
+optflags = -O3 -fno-fast-math
+debugflags = -ggdb3
+warnflags = -Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wunused-variable -Wpointer-arith -Wwrite-strings -Wdeclaration-after-statement -Wimplicit-function-declaration -Wdeprecated-declarations -Wno-packed-bitfield-compat
+CCDLFLAGS = -fPIC
+CFLAGS = $(CCDLFLAGS) $(cflags) -fPIC $(ARCH_FLAG)
+INCFLAGS = -I. -I$(arch_hdrdir) -I$(hdrdir) -I$(srcdir)
+DEFS =
+CPPFLAGS = -DRUBY_EXTCONF_H=\"$(RUBY_EXTCONF_H)\" $(DEFS) $(cppflags)
+CXXFLAGS = $(CCDLFLAGS) $(cxxflags) $(ARCH_FLAG)
+ldflags = -L. -fstack-protector -rdynamic -Wl,-export-dynamic
+dldflags =
+ARCH_FLAG =
+DLDFLAGS = $(ldflags) $(dldflags) $(ARCH_FLAG)
+LDSHARED = $(CC) -shared
+LDSHAREDXX = $(CXX) -shared
+AR = ar
+EXEEXT =
+
+RUBY_INSTALL_NAME = $(RUBY_BASE_NAME)
+RUBY_SO_NAME = ruby
+RUBYW_INSTALL_NAME =
+RUBY_VERSION_NAME = $(RUBY_BASE_NAME)-$(ruby_version)
+RUBYW_BASE_NAME = rubyw
+RUBY_BASE_NAME = ruby
+
+arch = x86_64-linux
+sitearch = $(arch)
+ruby_version = 2.2.0
+ruby = $(topdir)/miniruby -I'$(topdir)' -I'$(top_srcdir)/lib' -I'$(extout)/$(arch)' -I'$(extout)/common'
+RUBY = $(ruby)
+ruby_headers = $(hdrdir)/ruby.h $(hdrdir)/ruby/ruby.h $(hdrdir)/ruby/defines.h $(hdrdir)/ruby/missing.h $(hdrdir)/ruby/intern.h $(hdrdir)/ruby/st.h $(hdrdir)/ruby/subst.h $(arch_hdrdir)/ruby/config.h $(RUBY_EXTCONF_H)
+
+RM = rm -f
+RM_RF = $(RUBY) -run -e rm -- -rf
+RMDIRS = rmdir --ignore-fail-on-non-empty -p
+MAKEDIRS = /bin/mkdir -p
+INSTALL = /usr/bin/install -c
+INSTALL_PROG = $(INSTALL) -m 0755
+INSTALL_DATA = $(INSTALL) -m 644
+COPY = cp
+TOUCH = exit >
+
+#### End of system configuration section. ####
+
+preload =
+
+libpath = . $(topdir)
+LIBPATH = -L. -L$(topdir)
+DEFFILE =
+
+CLEANFILES = mkmf.log
+DISTCLEANFILES =
+DISTCLEANDIRS =
+
+extout = $(topdir)/.ext
+extout_prefix = $(extout)$(target_prefix)/
+target_prefix = /-test-/load/dot.dot
+LOCAL_LIBS =
+LIBS = $(LIBRUBYARG_SHARED) -lpthread -lgmp -ldl -lcrypt -lm -lc
+ORIG_SRCS = dot.dot.c
+SRCS = $(ORIG_SRCS)
+OBJS = dot.dot.o
+HDRS = $(srcdir)/extconf.h
+TARGET = dot.dot
+TARGET_NAME = dot
+TARGET_ENTRY = Init_$(TARGET_NAME)
+DLLIB = $(TARGET).so
+EXTSTATIC =
+STATIC_LIB = $(TARGET).a
+
+TIMESTAMP_DIR = $(extout)/.timestamp
+BINDIR = $(extout)/bin
+RUBYCOMMONDIR = $(extout)/common
+RUBYLIBDIR = $(RUBYCOMMONDIR)$(target_prefix)
+RUBYARCHDIR = $(extout)/$(arch)$(target_prefix)
+HDRDIR = $(extout)/include/ruby$(target_prefix)
+ARCHHDRDIR = $(extout)/include/$(arch)/ruby$(target_prefix)
+
+TARGET_SO = $(RUBYARCHDIR)/$(DLLIB)
+CLEANLIBS = $(RUBYARCHDIR)/$(TARGET).so
+CLEANOBJS = *.o *.bak
+
+all: install
+static: all
+.PHONY: all install static install-so install-rb
+.PHONY: clean clean-so clean-static clean-rb
+
+clean-static::
+clean-rb-default::
+clean-rb::
+clean-so::
+clean: clean-so clean-static clean-rb-default clean-rb
+ -$(Q)$(RM) $(CLEANLIBS) $(CLEANOBJS) $(CLEANFILES) .*.time
+
+distclean-rb-default::
+distclean-rb::
+distclean-so::
+distclean-static::
+distclean: clean distclean-so distclean-static distclean-rb-default distclean-rb
+ -$(Q)$(RM) Makefile $(RUBY_EXTCONF_H) conftest.* mkmf.log
+ -$(Q)$(RM) core ruby$(EXEEXT) *~ $(DISTCLEANFILES)
+ -$(Q)$(RMDIRS) $(DISTCLEANDIRS) 2> /dev/null || true
+
+realclean: distclean
+install: install-so install-rb
+
+install-so: $(RUBYARCHDIR)/$(DLLIB)
+clean-so::
+ -$(Q)$(RM) $(RUBYARCHDIR)/$(DLLIB)
+ -$(Q)$(RMDIRS) $(RUBYARCHDIR) 2> /dev/null || true
+clean-static::
+ -$(Q)$(RM) $(STATIC_LIB)
+install-rb: pre-install-rb install-rb-default
+install-rb-default: pre-install-rb-default
+pre-install-rb: Makefile
+pre-install-rb-default: Makefile
+pre-install-rb-default:
+ @$(NULLCMD)
+$(TIMESTAMP_DIR)/.RUBYARCHDIR.-.-test-.-.load.-.dot.dot.time:
+ $(Q) $(MAKEDIRS) $(@D) $(RUBYARCHDIR)
+ $(Q) $(TOUCH) $@
+
+site-install: site-install-so site-install-rb
+site-install-so: install-so
+site-install-rb: install-rb
+
+.SUFFIXES: .c .m .cc .mm .cxx .cpp .o .S
+
+.cc.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<
+
+.cc.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -S $<
+
+.mm.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<
+
+.mm.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -S $<
+
+.cxx.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<
+
+.cxx.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -S $<
+
+.cpp.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<
+
+.cpp.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -S $<
+
+.c.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -c $<
+
+.c.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -S $<
+
+.m.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -c $<
+
+.m.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -S $<
+
+$(RUBYARCHDIR)/$(DLLIB): $(OBJS) Makefile $(TIMESTAMP_DIR)/.RUBYARCHDIR.-.-test-.-.load.-.dot.dot.time
+ $(ECHO) linking shared-object -test-/load/dot.dot/$(DLLIB)
+ -$(Q)$(RM) $(@)
+ $(Q) $(LDSHARED) -o $@ $(OBJS) $(LIBPATH) $(DLDFLAGS) $(LOCAL_LIBS) $(LIBS)
+
+$(STATIC_LIB): $(OBJS)
+ -$(Q)$(RM) $(@)
+ $(ECHO) linking static-library $(@)
+ $(Q) $(AR) cru $@ $(OBJS)
+ -$(Q)ranlib $(@) 2> /dev/null || true
+
+$(OBJS): $(HDRS) $(ruby_headers)
diff --git a/jni/ruby/ext/-test-/load/dot.dot/dot.dot.c b/jni/ruby/ext/-test-/load/dot.dot/dot.dot.c
new file mode 100644
index 0000000..936d289
--- /dev/null
+++ b/jni/ruby/ext/-test-/load/dot.dot/dot.dot.c
@@ -0,0 +1 @@
+void Init_dot(void) {}
diff --git a/jni/ruby/ext/-test-/load/dot.dot/extconf.h b/jni/ruby/ext/-test-/load/dot.dot/extconf.h
new file mode 100644
index 0000000..cda0cc8
--- /dev/null
+++ b/jni/ruby/ext/-test-/load/dot.dot/extconf.h
@@ -0,0 +1,3 @@
+#ifndef EXTCONF_H
+#define EXTCONF_H
+#endif
diff --git a/jni/ruby/ext/-test-/load/dot.dot/extconf.rb b/jni/ruby/ext/-test-/load/dot.dot/extconf.rb
new file mode 100644
index 0000000..6287db6
--- /dev/null
+++ b/jni/ruby/ext/-test-/load/dot.dot/extconf.rb
@@ -0,0 +1 @@
+create_makefile("-test-/load/dot.dot/dot.dot")
diff --git a/jni/ruby/ext/-test-/marshal/compat/Makefile b/jni/ruby/ext/-test-/marshal/compat/Makefile
new file mode 100644
index 0000000..97b22f7
--- /dev/null
+++ b/jni/ruby/ext/-test-/marshal/compat/Makefile
@@ -0,0 +1,267 @@
+
+SHELL = /bin/sh
+
+# V=0 quiet, V=1 verbose. other values don't work.
+V = 0
+Q1 = $(V:1=)
+Q = $(Q1:0=@)
+ECHO1 = $(V:1=@:)
+ECHO = $(ECHO1:0=@echo)
+NULLCMD = :
+
+#### Start of system configuration section. ####
+top_srcdir = $(topdir)/.
+srcdir = $(top_srcdir)/ext/-test-/marshal/compat
+topdir = ../../../..
+hdrdir = $(top_srcdir)/include
+arch_hdrdir = $(extout)/include/$(arch)
+PATH_SEPARATOR = :
+VPATH = $(srcdir):$(arch_hdrdir)/ruby:$(hdrdir)/ruby
+RUBYLIB =
+RUBYOPT = -
+prefix = $(DESTDIR)/usr/local
+rubysitearchprefix = $(rubylibprefix)/$(sitearch)
+rubyarchprefix = $(rubylibprefix)/$(arch)
+rubylibprefix = $(libdir)/$(RUBY_BASE_NAME)
+exec_prefix = $(prefix)
+vendorarchhdrdir = $(vendorhdrdir)/$(sitearch)
+sitearchhdrdir = $(sitehdrdir)/$(sitearch)
+rubyarchhdrdir = $(rubyhdrdir)/$(arch)
+vendorhdrdir = $(rubyhdrdir)/vendor_ruby
+sitehdrdir = $(rubyhdrdir)/site_ruby
+rubyhdrdir = $(includedir)/$(RUBY_VERSION_NAME)
+vendorarchdir = $(vendorlibdir)/$(sitearch)
+vendorlibdir = $(vendordir)/$(ruby_version)
+vendordir = $(rubylibprefix)/vendor_ruby
+sitearchdir = $(sitelibdir)/$(sitearch)
+sitelibdir = $(sitedir)/$(ruby_version)
+sitedir = $(rubylibprefix)/site_ruby
+rubyarchdir = $(rubylibdir)/$(arch)
+rubylibdir = $(rubylibprefix)/$(ruby_version)
+sitearchincludedir = $(includedir)/$(sitearch)
+archincludedir = $(includedir)/$(arch)
+sitearchlibdir = $(libdir)/$(sitearch)
+archlibdir = $(libdir)/$(arch)
+ridir = $(datarootdir)/$(RI_BASE_NAME)
+mandir = $(datarootdir)/man
+localedir = $(datarootdir)/locale
+libdir = $(exec_prefix)/lib
+psdir = $(docdir)
+pdfdir = $(docdir)
+dvidir = $(docdir)
+htmldir = $(docdir)
+infodir = $(datarootdir)/info
+docdir = $(datarootdir)/doc/$(PACKAGE)
+oldincludedir = $(DESTDIR)/usr/include
+includedir = $(prefix)/include
+localstatedir = $(prefix)/var
+sharedstatedir = $(prefix)/com
+sysconfdir = $(prefix)/etc
+datadir = $(datarootdir)
+datarootdir = $(prefix)/share
+libexecdir = $(exec_prefix)/libexec
+sbindir = $(exec_prefix)/sbin
+bindir = $(exec_prefix)/bin
+archdir = $(rubyarchdir)
+
+
+CC = gcc
+CXX = g++
+LIBRUBY = $(LIBRUBY_SO)
+LIBRUBY_A = lib$(RUBY_SO_NAME)-static.a
+LIBRUBYARG_SHARED = -Wl,-R$(libdir) -L$(libdir) -l$(RUBY_SO_NAME)
+LIBRUBYARG_STATIC = -Wl,-R$(libdir) -L$(libdir) -l$(RUBY_SO_NAME)-static
+empty =
+OUTFLAG = -o $(empty)
+COUTFLAG = -o $(empty)
+
+RUBY_EXTCONF_H = extconf.h
+cflags = $(optflags) $(debugflags) $(warnflags)
+optflags = -O3 -fno-fast-math
+debugflags = -ggdb3
+warnflags = -Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wunused-variable -Wpointer-arith -Wwrite-strings -Wdeclaration-after-statement -Wimplicit-function-declaration -Wdeprecated-declarations -Wno-packed-bitfield-compat
+CCDLFLAGS = -fPIC
+CFLAGS = $(CCDLFLAGS) $(cflags) -fPIC $(ARCH_FLAG)
+INCFLAGS = -I. -I$(arch_hdrdir) -I$(hdrdir) -I$(srcdir)
+DEFS =
+CPPFLAGS = -DRUBY_EXTCONF_H=\"$(RUBY_EXTCONF_H)\" $(DEFS) $(cppflags)
+CXXFLAGS = $(CCDLFLAGS) $(cxxflags) $(ARCH_FLAG)
+ldflags = -L. -fstack-protector -rdynamic -Wl,-export-dynamic
+dldflags =
+ARCH_FLAG =
+DLDFLAGS = $(ldflags) $(dldflags) $(ARCH_FLAG)
+LDSHARED = $(CC) -shared
+LDSHAREDXX = $(CXX) -shared
+AR = ar
+EXEEXT =
+
+RUBY_INSTALL_NAME = $(RUBY_BASE_NAME)
+RUBY_SO_NAME = ruby
+RUBYW_INSTALL_NAME =
+RUBY_VERSION_NAME = $(RUBY_BASE_NAME)-$(ruby_version)
+RUBYW_BASE_NAME = rubyw
+RUBY_BASE_NAME = ruby
+
+arch = x86_64-linux
+sitearch = $(arch)
+ruby_version = 2.2.0
+ruby = $(topdir)/miniruby -I'$(topdir)' -I'$(top_srcdir)/lib' -I'$(extout)/$(arch)' -I'$(extout)/common'
+RUBY = $(ruby)
+ruby_headers = $(hdrdir)/ruby.h $(hdrdir)/ruby/ruby.h $(hdrdir)/ruby/defines.h $(hdrdir)/ruby/missing.h $(hdrdir)/ruby/intern.h $(hdrdir)/ruby/st.h $(hdrdir)/ruby/subst.h $(arch_hdrdir)/ruby/config.h $(RUBY_EXTCONF_H)
+
+RM = rm -f
+RM_RF = $(RUBY) -run -e rm -- -rf
+RMDIRS = rmdir --ignore-fail-on-non-empty -p
+MAKEDIRS = /bin/mkdir -p
+INSTALL = /usr/bin/install -c
+INSTALL_PROG = $(INSTALL) -m 0755
+INSTALL_DATA = $(INSTALL) -m 644
+COPY = cp
+TOUCH = exit >
+
+#### End of system configuration section. ####
+
+preload =
+
+libpath = . $(topdir)
+LIBPATH = -L. -L$(topdir)
+DEFFILE =
+
+CLEANFILES = mkmf.log
+DISTCLEANFILES =
+DISTCLEANDIRS =
+
+extout = $(topdir)/.ext
+extout_prefix = $(extout)$(target_prefix)/
+target_prefix = /-test-/marshal
+LOCAL_LIBS =
+LIBS = $(LIBRUBYARG_SHARED) -lpthread -lgmp -ldl -lcrypt -lm -lc
+ORIG_SRCS = usrcompat.c
+SRCS = $(ORIG_SRCS)
+OBJS = usrcompat.o
+HDRS = $(srcdir)/extconf.h
+TARGET = compat
+TARGET_NAME = compat
+TARGET_ENTRY = Init_$(TARGET_NAME)
+DLLIB = $(TARGET).so
+EXTSTATIC =
+STATIC_LIB = $(TARGET).a
+
+TIMESTAMP_DIR = $(extout)/.timestamp
+BINDIR = $(extout)/bin
+RUBYCOMMONDIR = $(extout)/common
+RUBYLIBDIR = $(RUBYCOMMONDIR)$(target_prefix)
+RUBYARCHDIR = $(extout)/$(arch)$(target_prefix)
+HDRDIR = $(extout)/include/ruby$(target_prefix)
+ARCHHDRDIR = $(extout)/include/$(arch)/ruby$(target_prefix)
+
+TARGET_SO = $(RUBYARCHDIR)/$(DLLIB)
+CLEANLIBS = $(RUBYARCHDIR)/$(TARGET).so
+CLEANOBJS = *.o *.bak
+
+all: install
+static: all
+.PHONY: all install static install-so install-rb
+.PHONY: clean clean-so clean-static clean-rb
+
+clean-static::
+clean-rb-default::
+clean-rb::
+clean-so::
+clean: clean-so clean-static clean-rb-default clean-rb
+ -$(Q)$(RM) $(CLEANLIBS) $(CLEANOBJS) $(CLEANFILES) .*.time
+
+distclean-rb-default::
+distclean-rb::
+distclean-so::
+distclean-static::
+distclean: clean distclean-so distclean-static distclean-rb-default distclean-rb
+ -$(Q)$(RM) Makefile $(RUBY_EXTCONF_H) conftest.* mkmf.log
+ -$(Q)$(RM) core ruby$(EXEEXT) *~ $(DISTCLEANFILES)
+ -$(Q)$(RMDIRS) $(DISTCLEANDIRS) 2> /dev/null || true
+
+realclean: distclean
+install: install-so install-rb
+
+install-so: $(RUBYARCHDIR)/$(DLLIB)
+clean-so::
+ -$(Q)$(RM) $(RUBYARCHDIR)/$(DLLIB)
+ -$(Q)$(RMDIRS) $(RUBYARCHDIR) 2> /dev/null || true
+clean-static::
+ -$(Q)$(RM) $(STATIC_LIB)
+install-rb: pre-install-rb install-rb-default
+install-rb-default: pre-install-rb-default
+pre-install-rb: Makefile
+pre-install-rb-default: Makefile
+pre-install-rb-default:
+ @$(NULLCMD)
+$(TIMESTAMP_DIR)/.RUBYARCHDIR.-.-test-.-.marshal.time:
+ $(Q) $(MAKEDIRS) $(@D) $(RUBYARCHDIR)
+ $(Q) $(TOUCH) $@
+
+site-install: site-install-so site-install-rb
+site-install-so: install-so
+site-install-rb: install-rb
+
+.SUFFIXES: .c .m .cc .mm .cxx .cpp .o .S
+
+.cc.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<
+
+.cc.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -S $<
+
+.mm.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<
+
+.mm.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -S $<
+
+.cxx.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<
+
+.cxx.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -S $<
+
+.cpp.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<
+
+.cpp.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -S $<
+
+.c.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -c $<
+
+.c.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -S $<
+
+.m.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -c $<
+
+.m.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -S $<
+
+$(RUBYARCHDIR)/$(DLLIB): $(OBJS) Makefile $(TIMESTAMP_DIR)/.RUBYARCHDIR.-.-test-.-.marshal.time
+ $(ECHO) linking shared-object -test-/marshal/$(DLLIB)
+ -$(Q)$(RM) $(@)
+ $(Q) $(LDSHARED) -o $@ $(OBJS) $(LIBPATH) $(DLDFLAGS) $(LOCAL_LIBS) $(LIBS)
+
+$(STATIC_LIB): $(OBJS)
+ -$(Q)$(RM) $(@)
+ $(ECHO) linking static-library $(@)
+ $(Q) $(AR) cru $@ $(OBJS)
+ -$(Q)ranlib $(@) 2> /dev/null || true
+
+$(OBJS): $(HDRS) $(ruby_headers)
diff --git a/jni/ruby/ext/-test-/marshal/compat/extconf.h b/jni/ruby/ext/-test-/marshal/compat/extconf.h
new file mode 100644
index 0000000..cda0cc8
--- /dev/null
+++ b/jni/ruby/ext/-test-/marshal/compat/extconf.h
@@ -0,0 +1,3 @@
+#ifndef EXTCONF_H
+#define EXTCONF_H
+#endif
diff --git a/jni/ruby/ext/-test-/marshal/compat/extconf.rb b/jni/ruby/ext/-test-/marshal/compat/extconf.rb
new file mode 100644
index 0000000..bb11ebf
--- /dev/null
+++ b/jni/ruby/ext/-test-/marshal/compat/extconf.rb
@@ -0,0 +1 @@
+create_makefile("-test-/marshal/compat")
diff --git a/jni/ruby/ext/-test-/marshal/compat/usrcompat.c b/jni/ruby/ext/-test-/marshal/compat/usrcompat.c
new file mode 100644
index 0000000..f812df5
--- /dev/null
+++ b/jni/ruby/ext/-test-/marshal/compat/usrcompat.c
@@ -0,0 +1,32 @@
+#include <ruby.h>
+
+static VALUE
+usr_dumper(VALUE self)
+{
+ return self;
+}
+
+static VALUE
+usr_loader(VALUE self, VALUE m)
+{
+ VALUE val = rb_ivar_get(m, rb_intern("@value"));
+ *(int *)DATA_PTR(self) = NUM2INT(val);
+ return self;
+}
+
+static VALUE
+compat_mload(VALUE self, VALUE data)
+{
+ rb_ivar_set(self, rb_intern("@value"), data);
+ return self;
+}
+
+void
+Init_compat(void)
+{
+ VALUE newclass = rb_path2class("Bug::Marshal::UsrMarshal");
+ VALUE oldclass = rb_define_class_under(newclass, "compat", rb_cObject);
+
+ rb_define_method(oldclass, "marshal_load", compat_mload, 1);
+ rb_marshal_define_compat(newclass, oldclass, usr_dumper, usr_loader);
+}
diff --git a/jni/ruby/ext/-test-/marshal/usr/Makefile b/jni/ruby/ext/-test-/marshal/usr/Makefile
new file mode 100644
index 0000000..e3b0150
--- /dev/null
+++ b/jni/ruby/ext/-test-/marshal/usr/Makefile
@@ -0,0 +1,267 @@
+
+SHELL = /bin/sh
+
+# V=0 quiet, V=1 verbose. other values don't work.
+V = 0
+Q1 = $(V:1=)
+Q = $(Q1:0=@)
+ECHO1 = $(V:1=@:)
+ECHO = $(ECHO1:0=@echo)
+NULLCMD = :
+
+#### Start of system configuration section. ####
+top_srcdir = $(topdir)/.
+srcdir = $(top_srcdir)/ext/-test-/marshal/usr
+topdir = ../../../..
+hdrdir = $(top_srcdir)/include
+arch_hdrdir = $(extout)/include/$(arch)
+PATH_SEPARATOR = :
+VPATH = $(srcdir):$(arch_hdrdir)/ruby:$(hdrdir)/ruby
+RUBYLIB =
+RUBYOPT = -
+prefix = $(DESTDIR)/usr/local
+rubysitearchprefix = $(rubylibprefix)/$(sitearch)
+rubyarchprefix = $(rubylibprefix)/$(arch)
+rubylibprefix = $(libdir)/$(RUBY_BASE_NAME)
+exec_prefix = $(prefix)
+vendorarchhdrdir = $(vendorhdrdir)/$(sitearch)
+sitearchhdrdir = $(sitehdrdir)/$(sitearch)
+rubyarchhdrdir = $(rubyhdrdir)/$(arch)
+vendorhdrdir = $(rubyhdrdir)/vendor_ruby
+sitehdrdir = $(rubyhdrdir)/site_ruby
+rubyhdrdir = $(includedir)/$(RUBY_VERSION_NAME)
+vendorarchdir = $(vendorlibdir)/$(sitearch)
+vendorlibdir = $(vendordir)/$(ruby_version)
+vendordir = $(rubylibprefix)/vendor_ruby
+sitearchdir = $(sitelibdir)/$(sitearch)
+sitelibdir = $(sitedir)/$(ruby_version)
+sitedir = $(rubylibprefix)/site_ruby
+rubyarchdir = $(rubylibdir)/$(arch)
+rubylibdir = $(rubylibprefix)/$(ruby_version)
+sitearchincludedir = $(includedir)/$(sitearch)
+archincludedir = $(includedir)/$(arch)
+sitearchlibdir = $(libdir)/$(sitearch)
+archlibdir = $(libdir)/$(arch)
+ridir = $(datarootdir)/$(RI_BASE_NAME)
+mandir = $(datarootdir)/man
+localedir = $(datarootdir)/locale
+libdir = $(exec_prefix)/lib
+psdir = $(docdir)
+pdfdir = $(docdir)
+dvidir = $(docdir)
+htmldir = $(docdir)
+infodir = $(datarootdir)/info
+docdir = $(datarootdir)/doc/$(PACKAGE)
+oldincludedir = $(DESTDIR)/usr/include
+includedir = $(prefix)/include
+localstatedir = $(prefix)/var
+sharedstatedir = $(prefix)/com
+sysconfdir = $(prefix)/etc
+datadir = $(datarootdir)
+datarootdir = $(prefix)/share
+libexecdir = $(exec_prefix)/libexec
+sbindir = $(exec_prefix)/sbin
+bindir = $(exec_prefix)/bin
+archdir = $(rubyarchdir)
+
+
+CC = gcc
+CXX = g++
+LIBRUBY = $(LIBRUBY_SO)
+LIBRUBY_A = lib$(RUBY_SO_NAME)-static.a
+LIBRUBYARG_SHARED = -Wl,-R$(libdir) -L$(libdir) -l$(RUBY_SO_NAME)
+LIBRUBYARG_STATIC = -Wl,-R$(libdir) -L$(libdir) -l$(RUBY_SO_NAME)-static
+empty =
+OUTFLAG = -o $(empty)
+COUTFLAG = -o $(empty)
+
+RUBY_EXTCONF_H = extconf.h
+cflags = $(optflags) $(debugflags) $(warnflags)
+optflags = -O3 -fno-fast-math
+debugflags = -ggdb3
+warnflags = -Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wunused-variable -Wpointer-arith -Wwrite-strings -Wdeclaration-after-statement -Wimplicit-function-declaration -Wdeprecated-declarations -Wno-packed-bitfield-compat
+CCDLFLAGS = -fPIC
+CFLAGS = $(CCDLFLAGS) $(cflags) -fPIC $(ARCH_FLAG)
+INCFLAGS = -I. -I$(arch_hdrdir) -I$(hdrdir) -I$(srcdir)
+DEFS =
+CPPFLAGS = -DRUBY_EXTCONF_H=\"$(RUBY_EXTCONF_H)\" $(DEFS) $(cppflags)
+CXXFLAGS = $(CCDLFLAGS) $(cxxflags) $(ARCH_FLAG)
+ldflags = -L. -fstack-protector -rdynamic -Wl,-export-dynamic
+dldflags =
+ARCH_FLAG =
+DLDFLAGS = $(ldflags) $(dldflags) $(ARCH_FLAG)
+LDSHARED = $(CC) -shared
+LDSHAREDXX = $(CXX) -shared
+AR = ar
+EXEEXT =
+
+RUBY_INSTALL_NAME = $(RUBY_BASE_NAME)
+RUBY_SO_NAME = ruby
+RUBYW_INSTALL_NAME =
+RUBY_VERSION_NAME = $(RUBY_BASE_NAME)-$(ruby_version)
+RUBYW_BASE_NAME = rubyw
+RUBY_BASE_NAME = ruby
+
+arch = x86_64-linux
+sitearch = $(arch)
+ruby_version = 2.2.0
+ruby = $(topdir)/miniruby -I'$(topdir)' -I'$(top_srcdir)/lib' -I'$(extout)/$(arch)' -I'$(extout)/common'
+RUBY = $(ruby)
+ruby_headers = $(hdrdir)/ruby.h $(hdrdir)/ruby/ruby.h $(hdrdir)/ruby/defines.h $(hdrdir)/ruby/missing.h $(hdrdir)/ruby/intern.h $(hdrdir)/ruby/st.h $(hdrdir)/ruby/subst.h $(arch_hdrdir)/ruby/config.h $(RUBY_EXTCONF_H)
+
+RM = rm -f
+RM_RF = $(RUBY) -run -e rm -- -rf
+RMDIRS = rmdir --ignore-fail-on-non-empty -p
+MAKEDIRS = /bin/mkdir -p
+INSTALL = /usr/bin/install -c
+INSTALL_PROG = $(INSTALL) -m 0755
+INSTALL_DATA = $(INSTALL) -m 644
+COPY = cp
+TOUCH = exit >
+
+#### End of system configuration section. ####
+
+preload =
+
+libpath = . $(topdir)
+LIBPATH = -L. -L$(topdir)
+DEFFILE =
+
+CLEANFILES = mkmf.log
+DISTCLEANFILES =
+DISTCLEANDIRS =
+
+extout = $(topdir)/.ext
+extout_prefix = $(extout)$(target_prefix)/
+target_prefix = /-test-/marshal
+LOCAL_LIBS =
+LIBS = $(LIBRUBYARG_SHARED) -lpthread -lgmp -ldl -lcrypt -lm -lc
+ORIG_SRCS = usrmarshal.c
+SRCS = $(ORIG_SRCS)
+OBJS = usrmarshal.o
+HDRS = $(srcdir)/extconf.h
+TARGET = usr
+TARGET_NAME = usr
+TARGET_ENTRY = Init_$(TARGET_NAME)
+DLLIB = $(TARGET).so
+EXTSTATIC =
+STATIC_LIB = $(TARGET).a
+
+TIMESTAMP_DIR = $(extout)/.timestamp
+BINDIR = $(extout)/bin
+RUBYCOMMONDIR = $(extout)/common
+RUBYLIBDIR = $(RUBYCOMMONDIR)$(target_prefix)
+RUBYARCHDIR = $(extout)/$(arch)$(target_prefix)
+HDRDIR = $(extout)/include/ruby$(target_prefix)
+ARCHHDRDIR = $(extout)/include/$(arch)/ruby$(target_prefix)
+
+TARGET_SO = $(RUBYARCHDIR)/$(DLLIB)
+CLEANLIBS = $(RUBYARCHDIR)/$(TARGET).so
+CLEANOBJS = *.o *.bak
+
+all: install
+static: all
+.PHONY: all install static install-so install-rb
+.PHONY: clean clean-so clean-static clean-rb
+
+clean-static::
+clean-rb-default::
+clean-rb::
+clean-so::
+clean: clean-so clean-static clean-rb-default clean-rb
+ -$(Q)$(RM) $(CLEANLIBS) $(CLEANOBJS) $(CLEANFILES) .*.time
+
+distclean-rb-default::
+distclean-rb::
+distclean-so::
+distclean-static::
+distclean: clean distclean-so distclean-static distclean-rb-default distclean-rb
+ -$(Q)$(RM) Makefile $(RUBY_EXTCONF_H) conftest.* mkmf.log
+ -$(Q)$(RM) core ruby$(EXEEXT) *~ $(DISTCLEANFILES)
+ -$(Q)$(RMDIRS) $(DISTCLEANDIRS) 2> /dev/null || true
+
+realclean: distclean
+install: install-so install-rb
+
+install-so: $(RUBYARCHDIR)/$(DLLIB)
+clean-so::
+ -$(Q)$(RM) $(RUBYARCHDIR)/$(DLLIB)
+ -$(Q)$(RMDIRS) $(RUBYARCHDIR) 2> /dev/null || true
+clean-static::
+ -$(Q)$(RM) $(STATIC_LIB)
+install-rb: pre-install-rb install-rb-default
+install-rb-default: pre-install-rb-default
+pre-install-rb: Makefile
+pre-install-rb-default: Makefile
+pre-install-rb-default:
+ @$(NULLCMD)
+$(TIMESTAMP_DIR)/.RUBYARCHDIR.-.-test-.-.marshal.time:
+ $(Q) $(MAKEDIRS) $(@D) $(RUBYARCHDIR)
+ $(Q) $(TOUCH) $@
+
+site-install: site-install-so site-install-rb
+site-install-so: install-so
+site-install-rb: install-rb
+
+.SUFFIXES: .c .m .cc .mm .cxx .cpp .o .S
+
+.cc.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<
+
+.cc.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -S $<
+
+.mm.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<
+
+.mm.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -S $<
+
+.cxx.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<
+
+.cxx.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -S $<
+
+.cpp.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<
+
+.cpp.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -S $<
+
+.c.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -c $<
+
+.c.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -S $<
+
+.m.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -c $<
+
+.m.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -S $<
+
+$(RUBYARCHDIR)/$(DLLIB): $(OBJS) Makefile $(TIMESTAMP_DIR)/.RUBYARCHDIR.-.-test-.-.marshal.time
+ $(ECHO) linking shared-object -test-/marshal/$(DLLIB)
+ -$(Q)$(RM) $(@)
+ $(Q) $(LDSHARED) -o $@ $(OBJS) $(LIBPATH) $(DLDFLAGS) $(LOCAL_LIBS) $(LIBS)
+
+$(STATIC_LIB): $(OBJS)
+ -$(Q)$(RM) $(@)
+ $(ECHO) linking static-library $(@)
+ $(Q) $(AR) cru $@ $(OBJS)
+ -$(Q)ranlib $(@) 2> /dev/null || true
+
+$(OBJS): $(HDRS) $(ruby_headers)
diff --git a/jni/ruby/ext/-test-/marshal/usr/extconf.h b/jni/ruby/ext/-test-/marshal/usr/extconf.h
new file mode 100644
index 0000000..cda0cc8
--- /dev/null
+++ b/jni/ruby/ext/-test-/marshal/usr/extconf.h
@@ -0,0 +1,3 @@
+#ifndef EXTCONF_H
+#define EXTCONF_H
+#endif
diff --git a/jni/ruby/ext/-test-/marshal/usr/extconf.rb b/jni/ruby/ext/-test-/marshal/usr/extconf.rb
new file mode 100644
index 0000000..c662b23
--- /dev/null
+++ b/jni/ruby/ext/-test-/marshal/usr/extconf.rb
@@ -0,0 +1 @@
+create_makefile("-test-/marshal/usr")
diff --git a/jni/ruby/ext/-test-/marshal/usr/usrmarshal.c b/jni/ruby/ext/-test-/marshal/usr/usrmarshal.c
new file mode 100644
index 0000000..0c9e079
--- /dev/null
+++ b/jni/ruby/ext/-test-/marshal/usr/usrmarshal.c
@@ -0,0 +1,50 @@
+#include <ruby.h>
+
+static size_t
+usr_size(const void *ptr)
+{
+ return sizeof(int);
+}
+
+static const rb_data_type_t usrmarshal_type = {
+ "UsrMarshal",
+ {0, RUBY_DEFAULT_FREE, usr_size,},
+ 0, 0,
+ RUBY_TYPED_FREE_IMMEDIATELY|RUBY_TYPED_WB_PROTECTED,
+};
+
+static VALUE
+usr_alloc(VALUE klass)
+{
+ int *p;
+ return TypedData_Make_Struct(klass, int, &usrmarshal_type, p);
+}
+
+static VALUE
+usr_init(VALUE self, VALUE val)
+{
+ int *ptr = Check_TypedStruct(self, &usrmarshal_type);
+ *ptr = NUM2INT(val);
+ return self;
+}
+
+static VALUE
+usr_value(VALUE self)
+{
+ int *ptr = Check_TypedStruct(self, &usrmarshal_type);
+ int val = *ptr;
+ return INT2NUM(val);
+}
+
+void
+Init_usr(void)
+{
+ VALUE mMarshal = rb_define_module_under(rb_define_module("Bug"), "Marshal");
+ VALUE newclass = rb_define_class_under(mMarshal, "UsrMarshal", rb_cObject);
+
+ rb_define_alloc_func(newclass, usr_alloc);
+ rb_define_method(newclass, "initialize", usr_init, 1);
+ rb_define_method(newclass, "value", usr_value, 0);
+ rb_define_method(newclass, "marshal_load", usr_init, 1);
+ rb_define_method(newclass, "marshal_dump", usr_value, 0);
+}
diff --git a/jni/ruby/ext/-test-/method/Makefile b/jni/ruby/ext/-test-/method/Makefile
new file mode 100644
index 0000000..7ab0152
--- /dev/null
+++ b/jni/ruby/ext/-test-/method/Makefile
@@ -0,0 +1,267 @@
+
+SHELL = /bin/sh
+
+# V=0 quiet, V=1 verbose. other values don't work.
+V = 0
+Q1 = $(V:1=)
+Q = $(Q1:0=@)
+ECHO1 = $(V:1=@:)
+ECHO = $(ECHO1:0=@echo)
+NULLCMD = :
+
+#### Start of system configuration section. ####
+top_srcdir = $(topdir)/.
+srcdir = $(top_srcdir)/ext/-test-/method
+topdir = ../../..
+hdrdir = $(top_srcdir)/include
+arch_hdrdir = $(extout)/include/$(arch)
+PATH_SEPARATOR = :
+VPATH = $(srcdir):$(arch_hdrdir)/ruby:$(hdrdir)/ruby
+RUBYLIB =
+RUBYOPT = -
+prefix = $(DESTDIR)/usr/local
+rubysitearchprefix = $(rubylibprefix)/$(sitearch)
+rubyarchprefix = $(rubylibprefix)/$(arch)
+rubylibprefix = $(libdir)/$(RUBY_BASE_NAME)
+exec_prefix = $(prefix)
+vendorarchhdrdir = $(vendorhdrdir)/$(sitearch)
+sitearchhdrdir = $(sitehdrdir)/$(sitearch)
+rubyarchhdrdir = $(rubyhdrdir)/$(arch)
+vendorhdrdir = $(rubyhdrdir)/vendor_ruby
+sitehdrdir = $(rubyhdrdir)/site_ruby
+rubyhdrdir = $(includedir)/$(RUBY_VERSION_NAME)
+vendorarchdir = $(vendorlibdir)/$(sitearch)
+vendorlibdir = $(vendordir)/$(ruby_version)
+vendordir = $(rubylibprefix)/vendor_ruby
+sitearchdir = $(sitelibdir)/$(sitearch)
+sitelibdir = $(sitedir)/$(ruby_version)
+sitedir = $(rubylibprefix)/site_ruby
+rubyarchdir = $(rubylibdir)/$(arch)
+rubylibdir = $(rubylibprefix)/$(ruby_version)
+sitearchincludedir = $(includedir)/$(sitearch)
+archincludedir = $(includedir)/$(arch)
+sitearchlibdir = $(libdir)/$(sitearch)
+archlibdir = $(libdir)/$(arch)
+ridir = $(datarootdir)/$(RI_BASE_NAME)
+mandir = $(datarootdir)/man
+localedir = $(datarootdir)/locale
+libdir = $(exec_prefix)/lib
+psdir = $(docdir)
+pdfdir = $(docdir)
+dvidir = $(docdir)
+htmldir = $(docdir)
+infodir = $(datarootdir)/info
+docdir = $(datarootdir)/doc/$(PACKAGE)
+oldincludedir = $(DESTDIR)/usr/include
+includedir = $(prefix)/include
+localstatedir = $(prefix)/var
+sharedstatedir = $(prefix)/com
+sysconfdir = $(prefix)/etc
+datadir = $(datarootdir)
+datarootdir = $(prefix)/share
+libexecdir = $(exec_prefix)/libexec
+sbindir = $(exec_prefix)/sbin
+bindir = $(exec_prefix)/bin
+archdir = $(rubyarchdir)
+
+
+CC = gcc
+CXX = g++
+LIBRUBY = $(LIBRUBY_SO)
+LIBRUBY_A = lib$(RUBY_SO_NAME)-static.a
+LIBRUBYARG_SHARED = -Wl,-R$(libdir) -L$(libdir) -l$(RUBY_SO_NAME)
+LIBRUBYARG_STATIC = -Wl,-R$(libdir) -L$(libdir) -l$(RUBY_SO_NAME)-static
+empty =
+OUTFLAG = -o $(empty)
+COUTFLAG = -o $(empty)
+
+RUBY_EXTCONF_H = extconf.h
+cflags = $(optflags) $(debugflags) $(warnflags)
+optflags = -O3 -fno-fast-math
+debugflags = -ggdb3
+warnflags = -Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wunused-variable -Wpointer-arith -Wwrite-strings -Wdeclaration-after-statement -Wimplicit-function-declaration -Wdeprecated-declarations -Wno-packed-bitfield-compat
+CCDLFLAGS = -fPIC
+CFLAGS = $(CCDLFLAGS) $(cflags) -fPIC $(ARCH_FLAG)
+INCFLAGS = -I. -I$(arch_hdrdir) -I$(hdrdir) -I$(srcdir)
+DEFS =
+CPPFLAGS = -DRUBY_EXTCONF_H=\"$(RUBY_EXTCONF_H)\" $(DEFS) $(cppflags)
+CXXFLAGS = $(CCDLFLAGS) $(cxxflags) $(ARCH_FLAG)
+ldflags = -L. -fstack-protector -rdynamic -Wl,-export-dynamic
+dldflags =
+ARCH_FLAG =
+DLDFLAGS = $(ldflags) $(dldflags) $(ARCH_FLAG)
+LDSHARED = $(CC) -shared
+LDSHAREDXX = $(CXX) -shared
+AR = ar
+EXEEXT =
+
+RUBY_INSTALL_NAME = $(RUBY_BASE_NAME)
+RUBY_SO_NAME = ruby
+RUBYW_INSTALL_NAME =
+RUBY_VERSION_NAME = $(RUBY_BASE_NAME)-$(ruby_version)
+RUBYW_BASE_NAME = rubyw
+RUBY_BASE_NAME = ruby
+
+arch = x86_64-linux
+sitearch = $(arch)
+ruby_version = 2.2.0
+ruby = $(topdir)/miniruby -I'$(topdir)' -I'$(top_srcdir)/lib' -I'$(extout)/$(arch)' -I'$(extout)/common'
+RUBY = $(ruby)
+ruby_headers = $(hdrdir)/ruby.h $(hdrdir)/ruby/ruby.h $(hdrdir)/ruby/defines.h $(hdrdir)/ruby/missing.h $(hdrdir)/ruby/intern.h $(hdrdir)/ruby/st.h $(hdrdir)/ruby/subst.h $(arch_hdrdir)/ruby/config.h $(RUBY_EXTCONF_H)
+
+RM = rm -f
+RM_RF = $(RUBY) -run -e rm -- -rf
+RMDIRS = rmdir --ignore-fail-on-non-empty -p
+MAKEDIRS = /bin/mkdir -p
+INSTALL = /usr/bin/install -c
+INSTALL_PROG = $(INSTALL) -m 0755
+INSTALL_DATA = $(INSTALL) -m 644
+COPY = cp
+TOUCH = exit >
+
+#### End of system configuration section. ####
+
+preload =
+
+libpath = . $(topdir)
+LIBPATH = -L. -L$(topdir)
+DEFFILE =
+
+CLEANFILES = mkmf.log
+DISTCLEANFILES =
+DISTCLEANDIRS =
+
+extout = $(topdir)/.ext
+extout_prefix = $(extout)$(target_prefix)/
+target_prefix = /-test-
+LOCAL_LIBS =
+LIBS = $(LIBRUBYARG_SHARED) -lpthread -lgmp -ldl -lcrypt -lm -lc
+ORIG_SRCS = arity.c init.c
+SRCS = $(ORIG_SRCS)
+OBJS = arity.o init.o
+HDRS = $(srcdir)/extconf.h
+TARGET = method
+TARGET_NAME = method
+TARGET_ENTRY = Init_$(TARGET_NAME)
+DLLIB = $(TARGET).so
+EXTSTATIC =
+STATIC_LIB = $(TARGET).a
+
+TIMESTAMP_DIR = $(extout)/.timestamp
+BINDIR = $(extout)/bin
+RUBYCOMMONDIR = $(extout)/common
+RUBYLIBDIR = $(RUBYCOMMONDIR)$(target_prefix)
+RUBYARCHDIR = $(extout)/$(arch)$(target_prefix)
+HDRDIR = $(extout)/include/ruby$(target_prefix)
+ARCHHDRDIR = $(extout)/include/$(arch)/ruby$(target_prefix)
+
+TARGET_SO = $(RUBYARCHDIR)/$(DLLIB)
+CLEANLIBS = $(RUBYARCHDIR)/$(TARGET).so
+CLEANOBJS = *.o *.bak
+
+all: install
+static: all
+.PHONY: all install static install-so install-rb
+.PHONY: clean clean-so clean-static clean-rb
+
+clean-static::
+clean-rb-default::
+clean-rb::
+clean-so::
+clean: clean-so clean-static clean-rb-default clean-rb
+ -$(Q)$(RM) $(CLEANLIBS) $(CLEANOBJS) $(CLEANFILES) .*.time
+
+distclean-rb-default::
+distclean-rb::
+distclean-so::
+distclean-static::
+distclean: clean distclean-so distclean-static distclean-rb-default distclean-rb
+ -$(Q)$(RM) Makefile $(RUBY_EXTCONF_H) conftest.* mkmf.log
+ -$(Q)$(RM) core ruby$(EXEEXT) *~ $(DISTCLEANFILES)
+ -$(Q)$(RMDIRS) $(DISTCLEANDIRS) 2> /dev/null || true
+
+realclean: distclean
+install: install-so install-rb
+
+install-so: $(RUBYARCHDIR)/$(DLLIB)
+clean-so::
+ -$(Q)$(RM) $(RUBYARCHDIR)/$(DLLIB)
+ -$(Q)$(RMDIRS) $(RUBYARCHDIR) 2> /dev/null || true
+clean-static::
+ -$(Q)$(RM) $(STATIC_LIB)
+install-rb: pre-install-rb install-rb-default
+install-rb-default: pre-install-rb-default
+pre-install-rb: Makefile
+pre-install-rb-default: Makefile
+pre-install-rb-default:
+ @$(NULLCMD)
+$(TIMESTAMP_DIR)/.RUBYARCHDIR.-.-test-.time:
+ $(Q) $(MAKEDIRS) $(@D) $(RUBYARCHDIR)
+ $(Q) $(TOUCH) $@
+
+site-install: site-install-so site-install-rb
+site-install-so: install-so
+site-install-rb: install-rb
+
+.SUFFIXES: .c .m .cc .mm .cxx .cpp .o .S
+
+.cc.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<
+
+.cc.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -S $<
+
+.mm.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<
+
+.mm.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -S $<
+
+.cxx.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<
+
+.cxx.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -S $<
+
+.cpp.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<
+
+.cpp.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -S $<
+
+.c.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -c $<
+
+.c.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -S $<
+
+.m.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -c $<
+
+.m.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -S $<
+
+$(RUBYARCHDIR)/$(DLLIB): $(OBJS) Makefile $(TIMESTAMP_DIR)/.RUBYARCHDIR.-.-test-.time
+ $(ECHO) linking shared-object -test-/$(DLLIB)
+ -$(Q)$(RM) $(@)
+ $(Q) $(LDSHARED) -o $@ $(OBJS) $(LIBPATH) $(DLDFLAGS) $(LOCAL_LIBS) $(LIBS)
+
+$(STATIC_LIB): $(OBJS)
+ -$(Q)$(RM) $(@)
+ $(ECHO) linking static-library $(@)
+ $(Q) $(AR) cru $@ $(OBJS)
+ -$(Q)ranlib $(@) 2> /dev/null || true
+
+$(OBJS): $(HDRS) $(ruby_headers)
diff --git a/jni/ruby/ext/-test-/method/arity.c b/jni/ruby/ext/-test-/method/arity.c
new file mode 100644
index 0000000..239b9f7
--- /dev/null
+++ b/jni/ruby/ext/-test-/method/arity.c
@@ -0,0 +1,22 @@
+#include "ruby.h"
+
+static VALUE
+obj_method_arity(VALUE self, VALUE obj, VALUE mid)
+{
+ int arity = rb_obj_method_arity(obj, rb_check_id(&mid));
+ return INT2FIX(arity);
+}
+
+static VALUE
+mod_method_arity(VALUE self, VALUE mod, VALUE mid)
+{
+ int arity = rb_mod_method_arity(mod, rb_check_id(&mid));
+ return INT2FIX(arity);
+}
+
+void
+Init_arity(VALUE mod)
+{
+ rb_define_module_function(mod, "obj_method_arity", obj_method_arity, 2);
+ rb_define_module_function(mod, "mod_method_arity", mod_method_arity, 2);
+}
diff --git a/jni/ruby/ext/-test-/method/extconf.h b/jni/ruby/ext/-test-/method/extconf.h
new file mode 100644
index 0000000..05f9c6e
--- /dev/null
+++ b/jni/ruby/ext/-test-/method/extconf.h
@@ -0,0 +1,4 @@
+#ifndef EXTCONF_H
+#define EXTCONF_H
+#define TEST_INIT_FUNCS(X) X(arity)
+#endif
diff --git a/jni/ruby/ext/-test-/method/extconf.rb b/jni/ruby/ext/-test-/method/extconf.rb
new file mode 100644
index 0000000..658b7af
--- /dev/null
+++ b/jni/ruby/ext/-test-/method/extconf.rb
@@ -0,0 +1,6 @@
+$srcs = Dir[File.join($srcdir, "*.{#{SRC_EXT.join(%q{,})}}")]
+inits = $srcs.map {|s| File.basename(s, ".*")}
+inits.delete("init")
+inits.map! {|s|"X(#{s})"}
+$defs << "-DTEST_INIT_FUNCS(X)=\"#{inits.join(' ')}\""
+create_makefile("-test-/method")
diff --git a/jni/ruby/ext/-test-/method/init.c b/jni/ruby/ext/-test-/method/init.c
new file mode 100644
index 0000000..cea2346
--- /dev/null
+++ b/jni/ruby/ext/-test-/method/init.c
@@ -0,0 +1,11 @@
+#include "ruby.h"
+
+#define init(n) {void Init_##n(VALUE klass); Init_##n(klass);}
+
+void
+Init_method(void)
+{
+ VALUE mBug = rb_define_module("Bug");
+ VALUE klass = rb_define_module_under(mBug, "Method");
+ TEST_INIT_FUNCS(init);
+}
diff --git a/jni/ruby/ext/-test-/num2int/Makefile b/jni/ruby/ext/-test-/num2int/Makefile
new file mode 100644
index 0000000..fbd92c6
--- /dev/null
+++ b/jni/ruby/ext/-test-/num2int/Makefile
@@ -0,0 +1,267 @@
+
+SHELL = /bin/sh
+
+# V=0 quiet, V=1 verbose. other values don't work.
+V = 0
+Q1 = $(V:1=)
+Q = $(Q1:0=@)
+ECHO1 = $(V:1=@:)
+ECHO = $(ECHO1:0=@echo)
+NULLCMD = :
+
+#### Start of system configuration section. ####
+top_srcdir = $(topdir)/.
+srcdir = $(top_srcdir)/ext/-test-/num2int
+topdir = ../../..
+hdrdir = $(top_srcdir)/include
+arch_hdrdir = $(extout)/include/$(arch)
+PATH_SEPARATOR = :
+VPATH = $(srcdir):$(arch_hdrdir)/ruby:$(hdrdir)/ruby
+RUBYLIB =
+RUBYOPT = -
+prefix = $(DESTDIR)/usr/local
+rubysitearchprefix = $(rubylibprefix)/$(sitearch)
+rubyarchprefix = $(rubylibprefix)/$(arch)
+rubylibprefix = $(libdir)/$(RUBY_BASE_NAME)
+exec_prefix = $(prefix)
+vendorarchhdrdir = $(vendorhdrdir)/$(sitearch)
+sitearchhdrdir = $(sitehdrdir)/$(sitearch)
+rubyarchhdrdir = $(rubyhdrdir)/$(arch)
+vendorhdrdir = $(rubyhdrdir)/vendor_ruby
+sitehdrdir = $(rubyhdrdir)/site_ruby
+rubyhdrdir = $(includedir)/$(RUBY_VERSION_NAME)
+vendorarchdir = $(vendorlibdir)/$(sitearch)
+vendorlibdir = $(vendordir)/$(ruby_version)
+vendordir = $(rubylibprefix)/vendor_ruby
+sitearchdir = $(sitelibdir)/$(sitearch)
+sitelibdir = $(sitedir)/$(ruby_version)
+sitedir = $(rubylibprefix)/site_ruby
+rubyarchdir = $(rubylibdir)/$(arch)
+rubylibdir = $(rubylibprefix)/$(ruby_version)
+sitearchincludedir = $(includedir)/$(sitearch)
+archincludedir = $(includedir)/$(arch)
+sitearchlibdir = $(libdir)/$(sitearch)
+archlibdir = $(libdir)/$(arch)
+ridir = $(datarootdir)/$(RI_BASE_NAME)
+mandir = $(datarootdir)/man
+localedir = $(datarootdir)/locale
+libdir = $(exec_prefix)/lib
+psdir = $(docdir)
+pdfdir = $(docdir)
+dvidir = $(docdir)
+htmldir = $(docdir)
+infodir = $(datarootdir)/info
+docdir = $(datarootdir)/doc/$(PACKAGE)
+oldincludedir = $(DESTDIR)/usr/include
+includedir = $(prefix)/include
+localstatedir = $(prefix)/var
+sharedstatedir = $(prefix)/com
+sysconfdir = $(prefix)/etc
+datadir = $(datarootdir)
+datarootdir = $(prefix)/share
+libexecdir = $(exec_prefix)/libexec
+sbindir = $(exec_prefix)/sbin
+bindir = $(exec_prefix)/bin
+archdir = $(rubyarchdir)
+
+
+CC = gcc
+CXX = g++
+LIBRUBY = $(LIBRUBY_SO)
+LIBRUBY_A = lib$(RUBY_SO_NAME)-static.a
+LIBRUBYARG_SHARED = -Wl,-R$(libdir) -L$(libdir) -l$(RUBY_SO_NAME)
+LIBRUBYARG_STATIC = -Wl,-R$(libdir) -L$(libdir) -l$(RUBY_SO_NAME)-static
+empty =
+OUTFLAG = -o $(empty)
+COUTFLAG = -o $(empty)
+
+RUBY_EXTCONF_H = extconf.h
+cflags = $(optflags) $(debugflags) $(warnflags)
+optflags = -O3 -fno-fast-math
+debugflags = -ggdb3
+warnflags = -Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wunused-variable -Wpointer-arith -Wwrite-strings -Wdeclaration-after-statement -Wimplicit-function-declaration -Wdeprecated-declarations -Wno-packed-bitfield-compat
+CCDLFLAGS = -fPIC
+CFLAGS = $(CCDLFLAGS) $(cflags) -fPIC $(ARCH_FLAG)
+INCFLAGS = -I. -I$(arch_hdrdir) -I$(hdrdir) -I$(srcdir)
+DEFS =
+CPPFLAGS = -DRUBY_EXTCONF_H=\"$(RUBY_EXTCONF_H)\" $(DEFS) $(cppflags)
+CXXFLAGS = $(CCDLFLAGS) $(cxxflags) $(ARCH_FLAG)
+ldflags = -L. -fstack-protector -rdynamic -Wl,-export-dynamic
+dldflags =
+ARCH_FLAG =
+DLDFLAGS = $(ldflags) $(dldflags) $(ARCH_FLAG)
+LDSHARED = $(CC) -shared
+LDSHAREDXX = $(CXX) -shared
+AR = ar
+EXEEXT =
+
+RUBY_INSTALL_NAME = $(RUBY_BASE_NAME)
+RUBY_SO_NAME = ruby
+RUBYW_INSTALL_NAME =
+RUBY_VERSION_NAME = $(RUBY_BASE_NAME)-$(ruby_version)
+RUBYW_BASE_NAME = rubyw
+RUBY_BASE_NAME = ruby
+
+arch = x86_64-linux
+sitearch = $(arch)
+ruby_version = 2.2.0
+ruby = $(topdir)/miniruby -I'$(topdir)' -I'$(top_srcdir)/lib' -I'$(extout)/$(arch)' -I'$(extout)/common'
+RUBY = $(ruby)
+ruby_headers = $(hdrdir)/ruby.h $(hdrdir)/ruby/ruby.h $(hdrdir)/ruby/defines.h $(hdrdir)/ruby/missing.h $(hdrdir)/ruby/intern.h $(hdrdir)/ruby/st.h $(hdrdir)/ruby/subst.h $(arch_hdrdir)/ruby/config.h $(RUBY_EXTCONF_H)
+
+RM = rm -f
+RM_RF = $(RUBY) -run -e rm -- -rf
+RMDIRS = rmdir --ignore-fail-on-non-empty -p
+MAKEDIRS = /bin/mkdir -p
+INSTALL = /usr/bin/install -c
+INSTALL_PROG = $(INSTALL) -m 0755
+INSTALL_DATA = $(INSTALL) -m 644
+COPY = cp
+TOUCH = exit >
+
+#### End of system configuration section. ####
+
+preload =
+
+libpath = . $(topdir)
+LIBPATH = -L. -L$(topdir)
+DEFFILE =
+
+CLEANFILES = mkmf.log
+DISTCLEANFILES =
+DISTCLEANDIRS =
+
+extout = $(topdir)/.ext
+extout_prefix = $(extout)$(target_prefix)/
+target_prefix = /-test-/num2int
+LOCAL_LIBS =
+LIBS = $(LIBRUBYARG_SHARED) -lpthread -lgmp -ldl -lcrypt -lm -lc
+ORIG_SRCS = num2int.c
+SRCS = $(ORIG_SRCS)
+OBJS = num2int.o
+HDRS = $(srcdir)/extconf.h
+TARGET = num2int
+TARGET_NAME = num2int
+TARGET_ENTRY = Init_$(TARGET_NAME)
+DLLIB = $(TARGET).so
+EXTSTATIC =
+STATIC_LIB = $(TARGET).a
+
+TIMESTAMP_DIR = $(extout)/.timestamp
+BINDIR = $(extout)/bin
+RUBYCOMMONDIR = $(extout)/common
+RUBYLIBDIR = $(RUBYCOMMONDIR)$(target_prefix)
+RUBYARCHDIR = $(extout)/$(arch)$(target_prefix)
+HDRDIR = $(extout)/include/ruby$(target_prefix)
+ARCHHDRDIR = $(extout)/include/$(arch)/ruby$(target_prefix)
+
+TARGET_SO = $(RUBYARCHDIR)/$(DLLIB)
+CLEANLIBS = $(RUBYARCHDIR)/$(TARGET).so
+CLEANOBJS = *.o *.bak
+
+all: install
+static: all
+.PHONY: all install static install-so install-rb
+.PHONY: clean clean-so clean-static clean-rb
+
+clean-static::
+clean-rb-default::
+clean-rb::
+clean-so::
+clean: clean-so clean-static clean-rb-default clean-rb
+ -$(Q)$(RM) $(CLEANLIBS) $(CLEANOBJS) $(CLEANFILES) .*.time
+
+distclean-rb-default::
+distclean-rb::
+distclean-so::
+distclean-static::
+distclean: clean distclean-so distclean-static distclean-rb-default distclean-rb
+ -$(Q)$(RM) Makefile $(RUBY_EXTCONF_H) conftest.* mkmf.log
+ -$(Q)$(RM) core ruby$(EXEEXT) *~ $(DISTCLEANFILES)
+ -$(Q)$(RMDIRS) $(DISTCLEANDIRS) 2> /dev/null || true
+
+realclean: distclean
+install: install-so install-rb
+
+install-so: $(RUBYARCHDIR)/$(DLLIB)
+clean-so::
+ -$(Q)$(RM) $(RUBYARCHDIR)/$(DLLIB)
+ -$(Q)$(RMDIRS) $(RUBYARCHDIR) 2> /dev/null || true
+clean-static::
+ -$(Q)$(RM) $(STATIC_LIB)
+install-rb: pre-install-rb install-rb-default
+install-rb-default: pre-install-rb-default
+pre-install-rb: Makefile
+pre-install-rb-default: Makefile
+pre-install-rb-default:
+ @$(NULLCMD)
+$(TIMESTAMP_DIR)/.RUBYARCHDIR.-.-test-.-.num2int.time:
+ $(Q) $(MAKEDIRS) $(@D) $(RUBYARCHDIR)
+ $(Q) $(TOUCH) $@
+
+site-install: site-install-so site-install-rb
+site-install-so: install-so
+site-install-rb: install-rb
+
+.SUFFIXES: .c .m .cc .mm .cxx .cpp .o .S
+
+.cc.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<
+
+.cc.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -S $<
+
+.mm.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<
+
+.mm.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -S $<
+
+.cxx.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<
+
+.cxx.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -S $<
+
+.cpp.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<
+
+.cpp.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -S $<
+
+.c.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -c $<
+
+.c.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -S $<
+
+.m.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -c $<
+
+.m.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -S $<
+
+$(RUBYARCHDIR)/$(DLLIB): $(OBJS) Makefile $(TIMESTAMP_DIR)/.RUBYARCHDIR.-.-test-.-.num2int.time
+ $(ECHO) linking shared-object -test-/num2int/$(DLLIB)
+ -$(Q)$(RM) $(@)
+ $(Q) $(LDSHARED) -o $@ $(OBJS) $(LIBPATH) $(DLDFLAGS) $(LOCAL_LIBS) $(LIBS)
+
+$(STATIC_LIB): $(OBJS)
+ -$(Q)$(RM) $(@)
+ $(ECHO) linking static-library $(@)
+ $(Q) $(AR) cru $@ $(OBJS)
+ -$(Q)ranlib $(@) 2> /dev/null || true
+
+$(OBJS): $(HDRS) $(ruby_headers)
diff --git a/jni/ruby/ext/-test-/num2int/extconf.h b/jni/ruby/ext/-test-/num2int/extconf.h
new file mode 100644
index 0000000..cda0cc8
--- /dev/null
+++ b/jni/ruby/ext/-test-/num2int/extconf.h
@@ -0,0 +1,3 @@
+#ifndef EXTCONF_H
+#define EXTCONF_H
+#endif
diff --git a/jni/ruby/ext/-test-/num2int/extconf.rb b/jni/ruby/ext/-test-/num2int/extconf.rb
new file mode 100644
index 0000000..2bc820e
--- /dev/null
+++ b/jni/ruby/ext/-test-/num2int/extconf.rb
@@ -0,0 +1 @@
+create_makefile("-test-/num2int/num2int")
diff --git a/jni/ruby/ext/-test-/num2int/num2int.c b/jni/ruby/ext/-test-/num2int/num2int.c
new file mode 100644
index 0000000..3aec3cc
--- /dev/null
+++ b/jni/ruby/ext/-test-/num2int/num2int.c
@@ -0,0 +1,136 @@
+#include <ruby.h>
+
+static VALUE
+test_num2short(VALUE obj, VALUE num)
+{
+ char buf[128];
+ sprintf(buf, "%d", NUM2SHORT(num));
+ return rb_str_new_cstr(buf);
+}
+
+static VALUE
+test_num2ushort(VALUE obj, VALUE num)
+{
+ char buf[128];
+ sprintf(buf, "%u", NUM2USHORT(num));
+ return rb_str_new_cstr(buf);
+}
+
+static VALUE
+test_num2int(VALUE obj, VALUE num)
+{
+ char buf[128];
+ sprintf(buf, "%d", NUM2INT(num));
+ return rb_str_new_cstr(buf);
+}
+
+static VALUE
+test_num2uint(VALUE obj, VALUE num)
+{
+ char buf[128];
+ sprintf(buf, "%u", NUM2UINT(num));
+ return rb_str_new_cstr(buf);
+}
+
+static VALUE
+test_num2long(VALUE obj, VALUE num)
+{
+ char buf[128];
+ sprintf(buf, "%ld", NUM2LONG(num));
+ return rb_str_new_cstr(buf);
+}
+
+static VALUE
+test_num2ulong(VALUE obj, VALUE num)
+{
+ char buf[128];
+ sprintf(buf, "%lu", NUM2ULONG(num));
+ return rb_str_new_cstr(buf);
+}
+
+#ifdef HAVE_LONG_LONG
+static VALUE
+test_num2ll(VALUE obj, VALUE num)
+{
+ char buf[128];
+ sprintf(buf, "%"PRI_LL_PREFIX"d", NUM2LL(num));
+ return rb_str_new_cstr(buf);
+}
+
+static VALUE
+test_num2ull(VALUE obj, VALUE num)
+{
+ char buf[128];
+ sprintf(buf, "%"PRI_LL_PREFIX"u", NUM2ULL(num));
+ return rb_str_new_cstr(buf);
+}
+#endif
+
+static VALUE
+test_fix2short(VALUE obj, VALUE num)
+{
+ char buf[128];
+ sprintf(buf, "%d", FIX2SHORT(num));
+ return rb_str_new_cstr(buf);
+}
+
+static VALUE
+test_fix2int(VALUE obj, VALUE num)
+{
+ char buf[128];
+ sprintf(buf, "%d", FIX2INT(num));
+ return rb_str_new_cstr(buf);
+}
+
+static VALUE
+test_fix2uint(VALUE obj, VALUE num)
+{
+ char buf[128];
+ sprintf(buf, "%u", FIX2UINT(num));
+ return rb_str_new_cstr(buf);
+}
+
+static VALUE
+test_fix2long(VALUE obj, VALUE num)
+{
+ char buf[128];
+ sprintf(buf, "%ld", FIX2LONG(num));
+ return rb_str_new_cstr(buf);
+}
+
+static VALUE
+test_fix2ulong(VALUE obj, VALUE num)
+{
+ char buf[128];
+ sprintf(buf, "%lu", FIX2ULONG(num));
+ return rb_str_new_cstr(buf);
+}
+
+void
+Init_num2int(void)
+{
+ VALUE mNum2int = rb_define_module("Num2int");
+
+ rb_define_module_function(mNum2int, "NUM2SHORT", test_num2short, 1);
+ rb_define_module_function(mNum2int, "NUM2USHORT", test_num2ushort, 1);
+
+ rb_define_module_function(mNum2int, "NUM2INT", test_num2int, 1);
+ rb_define_module_function(mNum2int, "NUM2UINT", test_num2uint, 1);
+
+ rb_define_module_function(mNum2int, "NUM2LONG", test_num2long, 1);
+ rb_define_module_function(mNum2int, "NUM2ULONG", test_num2ulong, 1);
+
+#ifdef HAVE_LONG_LONG
+ rb_define_module_function(mNum2int, "NUM2LL", test_num2ll, 1);
+ rb_define_module_function(mNum2int, "NUM2ULL", test_num2ull, 1);
+#endif
+
+ rb_define_module_function(mNum2int, "FIX2SHORT", test_fix2short, 1);
+
+ rb_define_module_function(mNum2int, "FIX2INT", test_fix2int, 1);
+ rb_define_module_function(mNum2int, "FIX2UINT", test_fix2uint, 1);
+
+ rb_define_module_function(mNum2int, "FIX2LONG", test_fix2long, 1);
+ rb_define_module_function(mNum2int, "FIX2ULONG", test_fix2ulong, 1);
+}
+
diff --git a/jni/ruby/ext/-test-/path_to_class/Makefile b/jni/ruby/ext/-test-/path_to_class/Makefile
new file mode 100644
index 0000000..a6dbf58
--- /dev/null
+++ b/jni/ruby/ext/-test-/path_to_class/Makefile
@@ -0,0 +1,267 @@
+
+SHELL = /bin/sh
+
+# V=0 quiet, V=1 verbose. other values don't work.
+V = 0
+Q1 = $(V:1=)
+Q = $(Q1:0=@)
+ECHO1 = $(V:1=@:)
+ECHO = $(ECHO1:0=@echo)
+NULLCMD = :
+
+#### Start of system configuration section. ####
+top_srcdir = $(topdir)/.
+srcdir = $(top_srcdir)/ext/-test-/path_to_class
+topdir = ../../..
+hdrdir = $(top_srcdir)/include
+arch_hdrdir = $(extout)/include/$(arch)
+PATH_SEPARATOR = :
+VPATH = $(srcdir):$(arch_hdrdir)/ruby:$(hdrdir)/ruby
+RUBYLIB =
+RUBYOPT = -
+prefix = $(DESTDIR)/usr/local
+rubysitearchprefix = $(rubylibprefix)/$(sitearch)
+rubyarchprefix = $(rubylibprefix)/$(arch)
+rubylibprefix = $(libdir)/$(RUBY_BASE_NAME)
+exec_prefix = $(prefix)
+vendorarchhdrdir = $(vendorhdrdir)/$(sitearch)
+sitearchhdrdir = $(sitehdrdir)/$(sitearch)
+rubyarchhdrdir = $(rubyhdrdir)/$(arch)
+vendorhdrdir = $(rubyhdrdir)/vendor_ruby
+sitehdrdir = $(rubyhdrdir)/site_ruby
+rubyhdrdir = $(includedir)/$(RUBY_VERSION_NAME)
+vendorarchdir = $(vendorlibdir)/$(sitearch)
+vendorlibdir = $(vendordir)/$(ruby_version)
+vendordir = $(rubylibprefix)/vendor_ruby
+sitearchdir = $(sitelibdir)/$(sitearch)
+sitelibdir = $(sitedir)/$(ruby_version)
+sitedir = $(rubylibprefix)/site_ruby
+rubyarchdir = $(rubylibdir)/$(arch)
+rubylibdir = $(rubylibprefix)/$(ruby_version)
+sitearchincludedir = $(includedir)/$(sitearch)
+archincludedir = $(includedir)/$(arch)
+sitearchlibdir = $(libdir)/$(sitearch)
+archlibdir = $(libdir)/$(arch)
+ridir = $(datarootdir)/$(RI_BASE_NAME)
+mandir = $(datarootdir)/man
+localedir = $(datarootdir)/locale
+libdir = $(exec_prefix)/lib
+psdir = $(docdir)
+pdfdir = $(docdir)
+dvidir = $(docdir)
+htmldir = $(docdir)
+infodir = $(datarootdir)/info
+docdir = $(datarootdir)/doc/$(PACKAGE)
+oldincludedir = $(DESTDIR)/usr/include
+includedir = $(prefix)/include
+localstatedir = $(prefix)/var
+sharedstatedir = $(prefix)/com
+sysconfdir = $(prefix)/etc
+datadir = $(datarootdir)
+datarootdir = $(prefix)/share
+libexecdir = $(exec_prefix)/libexec
+sbindir = $(exec_prefix)/sbin
+bindir = $(exec_prefix)/bin
+archdir = $(rubyarchdir)
+
+
+CC = gcc
+CXX = g++
+LIBRUBY = $(LIBRUBY_SO)
+LIBRUBY_A = lib$(RUBY_SO_NAME)-static.a
+LIBRUBYARG_SHARED = -Wl,-R$(libdir) -L$(libdir) -l$(RUBY_SO_NAME)
+LIBRUBYARG_STATIC = -Wl,-R$(libdir) -L$(libdir) -l$(RUBY_SO_NAME)-static
+empty =
+OUTFLAG = -o $(empty)
+COUTFLAG = -o $(empty)
+
+RUBY_EXTCONF_H = extconf.h
+cflags = $(optflags) $(debugflags) $(warnflags)
+optflags = -O3 -fno-fast-math
+debugflags = -ggdb3
+warnflags = -Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wunused-variable -Wpointer-arith -Wwrite-strings -Wdeclaration-after-statement -Wimplicit-function-declaration -Wdeprecated-declarations -Wno-packed-bitfield-compat
+CCDLFLAGS = -fPIC
+CFLAGS = $(CCDLFLAGS) $(cflags) -fPIC $(ARCH_FLAG)
+INCFLAGS = -I. -I$(arch_hdrdir) -I$(hdrdir) -I$(srcdir)
+DEFS =
+CPPFLAGS = -DRUBY_EXTCONF_H=\"$(RUBY_EXTCONF_H)\" $(DEFS) $(cppflags)
+CXXFLAGS = $(CCDLFLAGS) $(cxxflags) $(ARCH_FLAG)
+ldflags = -L. -fstack-protector -rdynamic -Wl,-export-dynamic
+dldflags =
+ARCH_FLAG =
+DLDFLAGS = $(ldflags) $(dldflags) $(ARCH_FLAG)
+LDSHARED = $(CC) -shared
+LDSHAREDXX = $(CXX) -shared
+AR = ar
+EXEEXT =
+
+RUBY_INSTALL_NAME = $(RUBY_BASE_NAME)
+RUBY_SO_NAME = ruby
+RUBYW_INSTALL_NAME =
+RUBY_VERSION_NAME = $(RUBY_BASE_NAME)-$(ruby_version)
+RUBYW_BASE_NAME = rubyw
+RUBY_BASE_NAME = ruby
+
+arch = x86_64-linux
+sitearch = $(arch)
+ruby_version = 2.2.0
+ruby = $(topdir)/miniruby -I'$(topdir)' -I'$(top_srcdir)/lib' -I'$(extout)/$(arch)' -I'$(extout)/common'
+RUBY = $(ruby)
+ruby_headers = $(hdrdir)/ruby.h $(hdrdir)/ruby/ruby.h $(hdrdir)/ruby/defines.h $(hdrdir)/ruby/missing.h $(hdrdir)/ruby/intern.h $(hdrdir)/ruby/st.h $(hdrdir)/ruby/subst.h $(arch_hdrdir)/ruby/config.h $(RUBY_EXTCONF_H)
+
+RM = rm -f
+RM_RF = $(RUBY) -run -e rm -- -rf
+RMDIRS = rmdir --ignore-fail-on-non-empty -p
+MAKEDIRS = /bin/mkdir -p
+INSTALL = /usr/bin/install -c
+INSTALL_PROG = $(INSTALL) -m 0755
+INSTALL_DATA = $(INSTALL) -m 644
+COPY = cp
+TOUCH = exit >
+
+#### End of system configuration section. ####
+
+preload =
+
+libpath = . $(topdir)
+LIBPATH = -L. -L$(topdir)
+DEFFILE =
+
+CLEANFILES = mkmf.log
+DISTCLEANFILES =
+DISTCLEANDIRS =
+
+extout = $(topdir)/.ext
+extout_prefix = $(extout)$(target_prefix)/
+target_prefix = /-test-/path_to_class
+LOCAL_LIBS =
+LIBS = $(LIBRUBYARG_SHARED) -lpthread -lgmp -ldl -lcrypt -lm -lc
+ORIG_SRCS = path_to_class.c
+SRCS = $(ORIG_SRCS)
+OBJS = path_to_class.o
+HDRS = $(srcdir)/extconf.h
+TARGET = path_to_class
+TARGET_NAME = path_to_class
+TARGET_ENTRY = Init_$(TARGET_NAME)
+DLLIB = $(TARGET).so
+EXTSTATIC =
+STATIC_LIB = $(TARGET).a
+
+TIMESTAMP_DIR = $(extout)/.timestamp
+BINDIR = $(extout)/bin
+RUBYCOMMONDIR = $(extout)/common
+RUBYLIBDIR = $(RUBYCOMMONDIR)$(target_prefix)
+RUBYARCHDIR = $(extout)/$(arch)$(target_prefix)
+HDRDIR = $(extout)/include/ruby$(target_prefix)
+ARCHHDRDIR = $(extout)/include/$(arch)/ruby$(target_prefix)
+
+TARGET_SO = $(RUBYARCHDIR)/$(DLLIB)
+CLEANLIBS = $(RUBYARCHDIR)/$(TARGET).so
+CLEANOBJS = *.o *.bak
+
+all: install
+static: all
+.PHONY: all install static install-so install-rb
+.PHONY: clean clean-so clean-static clean-rb
+
+clean-static::
+clean-rb-default::
+clean-rb::
+clean-so::
+clean: clean-so clean-static clean-rb-default clean-rb
+ -$(Q)$(RM) $(CLEANLIBS) $(CLEANOBJS) $(CLEANFILES) .*.time
+
+distclean-rb-default::
+distclean-rb::
+distclean-so::
+distclean-static::
+distclean: clean distclean-so distclean-static distclean-rb-default distclean-rb
+ -$(Q)$(RM) Makefile $(RUBY_EXTCONF_H) conftest.* mkmf.log
+ -$(Q)$(RM) core ruby$(EXEEXT) *~ $(DISTCLEANFILES)
+ -$(Q)$(RMDIRS) $(DISTCLEANDIRS) 2> /dev/null || true
+
+realclean: distclean
+install: install-so install-rb
+
+install-so: $(RUBYARCHDIR)/$(DLLIB)
+clean-so::
+ -$(Q)$(RM) $(RUBYARCHDIR)/$(DLLIB)
+ -$(Q)$(RMDIRS) $(RUBYARCHDIR) 2> /dev/null || true
+clean-static::
+ -$(Q)$(RM) $(STATIC_LIB)
+install-rb: pre-install-rb install-rb-default
+install-rb-default: pre-install-rb-default
+pre-install-rb: Makefile
+pre-install-rb-default: Makefile
+pre-install-rb-default:
+ @$(NULLCMD)
+$(TIMESTAMP_DIR)/.RUBYARCHDIR.-.-test-.-.path_to_class.time:
+ $(Q) $(MAKEDIRS) $(@D) $(RUBYARCHDIR)
+ $(Q) $(TOUCH) $@
+
+site-install: site-install-so site-install-rb
+site-install-so: install-so
+site-install-rb: install-rb
+
+.SUFFIXES: .c .m .cc .mm .cxx .cpp .o .S
+
+.cc.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<
+
+.cc.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -S $<
+
+.mm.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<
+
+.mm.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -S $<
+
+.cxx.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<
+
+.cxx.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -S $<
+
+.cpp.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<
+
+.cpp.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -S $<
+
+.c.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -c $<
+
+.c.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -S $<
+
+.m.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -c $<
+
+.m.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -S $<
+
+$(RUBYARCHDIR)/$(DLLIB): $(OBJS) Makefile $(TIMESTAMP_DIR)/.RUBYARCHDIR.-.-test-.-.path_to_class.time
+ $(ECHO) linking shared-object -test-/path_to_class/$(DLLIB)
+ -$(Q)$(RM) $(@)
+ $(Q) $(LDSHARED) -o $@ $(OBJS) $(LIBPATH) $(DLDFLAGS) $(LOCAL_LIBS) $(LIBS)
+
+$(STATIC_LIB): $(OBJS)
+ -$(Q)$(RM) $(@)
+ $(ECHO) linking static-library $(@)
+ $(Q) $(AR) cru $@ $(OBJS)
+ -$(Q)ranlib $(@) 2> /dev/null || true
+
+$(OBJS): $(HDRS) $(ruby_headers)
diff --git a/jni/ruby/ext/-test-/path_to_class/extconf.h b/jni/ruby/ext/-test-/path_to_class/extconf.h
new file mode 100644
index 0000000..821b496
--- /dev/null
+++ b/jni/ruby/ext/-test-/path_to_class/extconf.h
@@ -0,0 +1,4 @@
+#ifndef EXTCONF_H
+#define EXTCONF_H
+#define TEST_INIT_FUNCS(X) X(path_to_class)
+#endif
diff --git a/jni/ruby/ext/-test-/path_to_class/extconf.rb b/jni/ruby/ext/-test-/path_to_class/extconf.rb
new file mode 100644
index 0000000..e1072b1
--- /dev/null
+++ b/jni/ruby/ext/-test-/path_to_class/extconf.rb
@@ -0,0 +1,6 @@
+$srcs = Dir[File.join($srcdir, "*.{#{SRC_EXT.join(%q{,})}}")]
+inits = $srcs.map {|s| File.basename(s, ".*")}
+inits.delete("init")
+inits.map! {|s|"X(#{s})"}
+$defs << "-DTEST_INIT_FUNCS(X)=\"#{inits.join(' ')}\""
+create_makefile("-test-/path_to_class/path_to_class")
diff --git a/jni/ruby/ext/-test-/path_to_class/path_to_class.c b/jni/ruby/ext/-test-/path_to_class/path_to_class.c
new file mode 100644
index 0000000..c8c2831
--- /dev/null
+++ b/jni/ruby/ext/-test-/path_to_class/path_to_class.c
@@ -0,0 +1,15 @@
+#include "ruby.h"
+
+static VALUE
+path_to_class(VALUE klass, VALUE path)
+{
+ return rb_path_to_class(path);
+}
+
+void
+Init_path_to_class(void)
+{
+ VALUE klass = rb_path2class("Test_PathToClass");
+
+ rb_define_singleton_method(klass, "path_to_class", path_to_class, 1);
+}
diff --git a/jni/ruby/ext/-test-/postponed_job/Makefile b/jni/ruby/ext/-test-/postponed_job/Makefile
new file mode 100644
index 0000000..2c48136
--- /dev/null
+++ b/jni/ruby/ext/-test-/postponed_job/Makefile
@@ -0,0 +1,270 @@
+
+SHELL = /bin/sh
+
+# V=0 quiet, V=1 verbose. other values don't work.
+V = 0
+Q1 = $(V:1=)
+Q = $(Q1:0=@)
+ECHO1 = $(V:1=@:)
+ECHO = $(ECHO1:0=@echo)
+NULLCMD = :
+
+#### Start of system configuration section. ####
+top_srcdir = $(topdir)/.
+srcdir = $(top_srcdir)/ext/-test-/postponed_job
+topdir = ../../..
+hdrdir = $(top_srcdir)/include
+arch_hdrdir = $(extout)/include/$(arch)
+PATH_SEPARATOR = :
+VPATH = $(srcdir):$(arch_hdrdir)/ruby:$(hdrdir)/ruby
+RUBYLIB =
+RUBYOPT = -
+prefix = $(DESTDIR)/usr/local
+rubysitearchprefix = $(rubylibprefix)/$(sitearch)
+rubyarchprefix = $(rubylibprefix)/$(arch)
+rubylibprefix = $(libdir)/$(RUBY_BASE_NAME)
+exec_prefix = $(prefix)
+vendorarchhdrdir = $(vendorhdrdir)/$(sitearch)
+sitearchhdrdir = $(sitehdrdir)/$(sitearch)
+rubyarchhdrdir = $(rubyhdrdir)/$(arch)
+vendorhdrdir = $(rubyhdrdir)/vendor_ruby
+sitehdrdir = $(rubyhdrdir)/site_ruby
+rubyhdrdir = $(includedir)/$(RUBY_VERSION_NAME)
+vendorarchdir = $(vendorlibdir)/$(sitearch)
+vendorlibdir = $(vendordir)/$(ruby_version)
+vendordir = $(rubylibprefix)/vendor_ruby
+sitearchdir = $(sitelibdir)/$(sitearch)
+sitelibdir = $(sitedir)/$(ruby_version)
+sitedir = $(rubylibprefix)/site_ruby
+rubyarchdir = $(rubylibdir)/$(arch)
+rubylibdir = $(rubylibprefix)/$(ruby_version)
+sitearchincludedir = $(includedir)/$(sitearch)
+archincludedir = $(includedir)/$(arch)
+sitearchlibdir = $(libdir)/$(sitearch)
+archlibdir = $(libdir)/$(arch)
+ridir = $(datarootdir)/$(RI_BASE_NAME)
+mandir = $(datarootdir)/man
+localedir = $(datarootdir)/locale
+libdir = $(exec_prefix)/lib
+psdir = $(docdir)
+pdfdir = $(docdir)
+dvidir = $(docdir)
+htmldir = $(docdir)
+infodir = $(datarootdir)/info
+docdir = $(datarootdir)/doc/$(PACKAGE)
+oldincludedir = $(DESTDIR)/usr/include
+includedir = $(prefix)/include
+localstatedir = $(prefix)/var
+sharedstatedir = $(prefix)/com
+sysconfdir = $(prefix)/etc
+datadir = $(datarootdir)
+datarootdir = $(prefix)/share
+libexecdir = $(exec_prefix)/libexec
+sbindir = $(exec_prefix)/sbin
+bindir = $(exec_prefix)/bin
+archdir = $(rubyarchdir)
+
+
+CC = gcc
+CXX = g++
+LIBRUBY = $(LIBRUBY_SO)
+LIBRUBY_A = lib$(RUBY_SO_NAME)-static.a
+LIBRUBYARG_SHARED = -Wl,-R$(libdir) -L$(libdir) -l$(RUBY_SO_NAME)
+LIBRUBYARG_STATIC = -Wl,-R$(libdir) -L$(libdir) -l$(RUBY_SO_NAME)-static
+empty =
+OUTFLAG = -o $(empty)
+COUTFLAG = -o $(empty)
+
+RUBY_EXTCONF_H = extconf.h
+cflags = $(optflags) $(debugflags) $(warnflags)
+optflags = -O3 -fno-fast-math
+debugflags = -ggdb3
+warnflags = -Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wunused-variable -Wpointer-arith -Wwrite-strings -Wdeclaration-after-statement -Wimplicit-function-declaration -Wdeprecated-declarations -Wno-packed-bitfield-compat
+CCDLFLAGS = -fPIC
+CFLAGS = $(CCDLFLAGS) $(cflags) -fPIC $(ARCH_FLAG)
+INCFLAGS = -I. -I$(arch_hdrdir) -I$(hdrdir) -I$(srcdir)
+DEFS =
+CPPFLAGS = -DRUBY_EXTCONF_H=\"$(RUBY_EXTCONF_H)\" $(DEFS) $(cppflags)
+CXXFLAGS = $(CCDLFLAGS) $(cxxflags) $(ARCH_FLAG)
+ldflags = -L. -fstack-protector -rdynamic -Wl,-export-dynamic
+dldflags =
+ARCH_FLAG =
+DLDFLAGS = $(ldflags) $(dldflags) $(ARCH_FLAG)
+LDSHARED = $(CC) -shared
+LDSHAREDXX = $(CXX) -shared
+AR = ar
+EXEEXT =
+
+RUBY_INSTALL_NAME = $(RUBY_BASE_NAME)
+RUBY_SO_NAME = ruby
+RUBYW_INSTALL_NAME =
+RUBY_VERSION_NAME = $(RUBY_BASE_NAME)-$(ruby_version)
+RUBYW_BASE_NAME = rubyw
+RUBY_BASE_NAME = ruby
+
+arch = x86_64-linux
+sitearch = $(arch)
+ruby_version = 2.2.0
+ruby = $(topdir)/miniruby -I'$(topdir)' -I'$(top_srcdir)/lib' -I'$(extout)/$(arch)' -I'$(extout)/common'
+RUBY = $(ruby)
+ruby_headers = $(hdrdir)/ruby.h $(hdrdir)/ruby/ruby.h $(hdrdir)/ruby/defines.h $(hdrdir)/ruby/missing.h $(hdrdir)/ruby/intern.h $(hdrdir)/ruby/st.h $(hdrdir)/ruby/subst.h $(arch_hdrdir)/ruby/config.h $(RUBY_EXTCONF_H)
+
+RM = rm -f
+RM_RF = $(RUBY) -run -e rm -- -rf
+RMDIRS = rmdir --ignore-fail-on-non-empty -p
+MAKEDIRS = /bin/mkdir -p
+INSTALL = /usr/bin/install -c
+INSTALL_PROG = $(INSTALL) -m 0755
+INSTALL_DATA = $(INSTALL) -m 644
+COPY = cp
+TOUCH = exit >
+
+#### End of system configuration section. ####
+
+preload =
+
+libpath = . $(topdir)
+LIBPATH = -L. -L$(topdir)
+DEFFILE =
+
+CLEANFILES = mkmf.log
+DISTCLEANFILES =
+DISTCLEANDIRS =
+
+extout = $(topdir)/.ext
+extout_prefix = $(extout)$(target_prefix)/
+target_prefix = /-test-
+LOCAL_LIBS =
+LIBS = $(LIBRUBYARG_SHARED) -lpthread -lgmp -ldl -lcrypt -lm -lc
+ORIG_SRCS = postponed_job.c
+SRCS = $(ORIG_SRCS)
+OBJS = postponed_job.o
+HDRS = $(srcdir)/extconf.h
+TARGET = postponed_job
+TARGET_NAME = postponed_job
+TARGET_ENTRY = Init_$(TARGET_NAME)
+DLLIB = $(TARGET).so
+EXTSTATIC =
+STATIC_LIB = $(TARGET).a
+
+TIMESTAMP_DIR = $(extout)/.timestamp
+BINDIR = $(extout)/bin
+RUBYCOMMONDIR = $(extout)/common
+RUBYLIBDIR = $(RUBYCOMMONDIR)$(target_prefix)
+RUBYARCHDIR = $(extout)/$(arch)$(target_prefix)
+HDRDIR = $(extout)/include/ruby$(target_prefix)
+ARCHHDRDIR = $(extout)/include/$(arch)/ruby$(target_prefix)
+
+TARGET_SO = $(RUBYARCHDIR)/$(DLLIB)
+CLEANLIBS = $(RUBYARCHDIR)/$(TARGET).so
+CLEANOBJS = *.o *.bak
+
+all: install
+static: all
+.PHONY: all install static install-so install-rb
+.PHONY: clean clean-so clean-static clean-rb
+
+clean-static::
+clean-rb-default::
+clean-rb::
+clean-so::
+clean: clean-so clean-static clean-rb-default clean-rb
+ -$(Q)$(RM) $(CLEANLIBS) $(CLEANOBJS) $(CLEANFILES) .*.time
+
+distclean-rb-default::
+distclean-rb::
+distclean-so::
+distclean-static::
+distclean: clean distclean-so distclean-static distclean-rb-default distclean-rb
+ -$(Q)$(RM) Makefile $(RUBY_EXTCONF_H) conftest.* mkmf.log
+ -$(Q)$(RM) core ruby$(EXEEXT) *~ $(DISTCLEANFILES)
+ -$(Q)$(RMDIRS) $(DISTCLEANDIRS) 2> /dev/null || true
+
+realclean: distclean
+install: install-so install-rb
+
+install-so: $(RUBYARCHDIR)/$(DLLIB)
+clean-so::
+ -$(Q)$(RM) $(RUBYARCHDIR)/$(DLLIB)
+ -$(Q)$(RMDIRS) $(RUBYARCHDIR) 2> /dev/null || true
+clean-static::
+ -$(Q)$(RM) $(STATIC_LIB)
+install-rb: pre-install-rb install-rb-default
+install-rb-default: pre-install-rb-default
+pre-install-rb: Makefile
+pre-install-rb-default: Makefile
+pre-install-rb-default:
+ @$(NULLCMD)
+$(TIMESTAMP_DIR)/.RUBYARCHDIR.-.-test-.time:
+ $(Q) $(MAKEDIRS) $(@D) $(RUBYARCHDIR)
+ $(Q) $(TOUCH) $@
+
+site-install: site-install-so site-install-rb
+site-install-so: install-so
+site-install-rb: install-rb
+
+.SUFFIXES: .c .m .cc .mm .cxx .cpp .o .S
+
+.cc.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<
+
+.cc.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -S $<
+
+.mm.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<
+
+.mm.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -S $<
+
+.cxx.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<
+
+.cxx.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -S $<
+
+.cpp.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<
+
+.cpp.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -S $<
+
+.c.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -c $<
+
+.c.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -S $<
+
+.m.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -c $<
+
+.m.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -S $<
+
+$(RUBYARCHDIR)/$(DLLIB): $(OBJS) Makefile $(TIMESTAMP_DIR)/.RUBYARCHDIR.-.-test-.time
+ $(ECHO) linking shared-object -test-/$(DLLIB)
+ -$(Q)$(RM) $(@)
+ $(Q) $(LDSHARED) -o $@ $(OBJS) $(LIBPATH) $(DLDFLAGS) $(LOCAL_LIBS) $(LIBS)
+
+$(STATIC_LIB): $(OBJS)
+ -$(Q)$(RM) $(@)
+ $(ECHO) linking static-library $(@)
+ $(Q) $(AR) cru $@ $(OBJS)
+ -$(Q)ranlib $(@) 2> /dev/null || true
+
+###
+$(OBJS): $(RUBY_EXTCONF_H)
+
+postponed_job.o: $(HDRS) $(ruby_headers) $(hdrdir)/ruby/debug.h
diff --git a/jni/ruby/ext/-test-/postponed_job/depend b/jni/ruby/ext/-test-/postponed_job/depend
new file mode 100644
index 0000000..d672e53
--- /dev/null
+++ b/jni/ruby/ext/-test-/postponed_job/depend
@@ -0,0 +1 @@
+postponed_job.o: $(HDRS) $(ruby_headers) $(hdrdir)/ruby/debug.h
diff --git a/jni/ruby/ext/-test-/postponed_job/extconf.h b/jni/ruby/ext/-test-/postponed_job/extconf.h
new file mode 100644
index 0000000..cda0cc8
--- /dev/null
+++ b/jni/ruby/ext/-test-/postponed_job/extconf.h
@@ -0,0 +1,3 @@
+#ifndef EXTCONF_H
+#define EXTCONF_H
+#endif
diff --git a/jni/ruby/ext/-test-/postponed_job/extconf.rb b/jni/ruby/ext/-test-/postponed_job/extconf.rb
new file mode 100644
index 0000000..aa29b59
--- /dev/null
+++ b/jni/ruby/ext/-test-/postponed_job/extconf.rb
@@ -0,0 +1 @@
+create_makefile('-test-/postponed_job')
diff --git a/jni/ruby/ext/-test-/postponed_job/postponed_job.c b/jni/ruby/ext/-test-/postponed_job/postponed_job.c
new file mode 100644
index 0000000..157230e
--- /dev/null
+++ b/jni/ruby/ext/-test-/postponed_job/postponed_job.c
@@ -0,0 +1,53 @@
+#include "ruby.h"
+#include "ruby/debug.h"
+
+static void
+pjob_callback(void *data)
+{
+ VALUE ary = (VALUE)data;
+ Check_Type(ary, T_ARRAY);
+
+ rb_ary_replace(ary, rb_funcall(Qnil, rb_intern("caller"), 0));
+}
+
+static VALUE
+pjob_register(VALUE self, VALUE obj)
+{
+ rb_postponed_job_register(0, pjob_callback, (void *)obj);
+ return self;
+}
+
+static void
+pjob_one_callback(void *data)
+{
+ VALUE ary = (VALUE)data;
+ Check_Type(ary, T_ARRAY);
+
+ rb_ary_push(ary, INT2FIX(1));
+}
+
+static VALUE
+pjob_register_one(VALUE self, VALUE obj)
+{
+ rb_postponed_job_register_one(0, pjob_one_callback, (void *)obj);
+ rb_postponed_job_register_one(0, pjob_one_callback, (void *)obj);
+ rb_postponed_job_register_one(0, pjob_one_callback, (void *)obj);
+ return self;
+}
+
+static VALUE
+pjob_call_direct(VALUE self, VALUE obj)
+{
+ pjob_callback((void *)obj);
+ return self;
+}
+
+void
+Init_postponed_job(VALUE self)
+{
+ VALUE mBug = rb_define_module("Bug");
+ rb_define_module_function(mBug, "postponed_job_register", pjob_register, 1);
+ rb_define_module_function(mBug, "postponed_job_register_one", pjob_register_one, 1);
+ rb_define_module_function(mBug, "postponed_job_call_direct", pjob_call_direct, 1);
+}
+
diff --git a/jni/ruby/ext/-test-/printf/Makefile b/jni/ruby/ext/-test-/printf/Makefile
new file mode 100644
index 0000000..235145b
--- /dev/null
+++ b/jni/ruby/ext/-test-/printf/Makefile
@@ -0,0 +1,272 @@
+
+SHELL = /bin/sh
+
+# V=0 quiet, V=1 verbose. other values don't work.
+V = 0
+Q1 = $(V:1=)
+Q = $(Q1:0=@)
+ECHO1 = $(V:1=@:)
+ECHO = $(ECHO1:0=@echo)
+NULLCMD = :
+
+#### Start of system configuration section. ####
+top_srcdir = $(topdir)/.
+srcdir = $(top_srcdir)/ext/-test-/printf
+topdir = ../../..
+hdrdir = $(top_srcdir)/include
+arch_hdrdir = $(extout)/include/$(arch)
+PATH_SEPARATOR = :
+VPATH = $(srcdir):$(arch_hdrdir)/ruby:$(hdrdir)/ruby
+RUBYLIB =
+RUBYOPT = -
+prefix = $(DESTDIR)/usr/local
+rubysitearchprefix = $(rubylibprefix)/$(sitearch)
+rubyarchprefix = $(rubylibprefix)/$(arch)
+rubylibprefix = $(libdir)/$(RUBY_BASE_NAME)
+exec_prefix = $(prefix)
+vendorarchhdrdir = $(vendorhdrdir)/$(sitearch)
+sitearchhdrdir = $(sitehdrdir)/$(sitearch)
+rubyarchhdrdir = $(rubyhdrdir)/$(arch)
+vendorhdrdir = $(rubyhdrdir)/vendor_ruby
+sitehdrdir = $(rubyhdrdir)/site_ruby
+rubyhdrdir = $(includedir)/$(RUBY_VERSION_NAME)
+vendorarchdir = $(vendorlibdir)/$(sitearch)
+vendorlibdir = $(vendordir)/$(ruby_version)
+vendordir = $(rubylibprefix)/vendor_ruby
+sitearchdir = $(sitelibdir)/$(sitearch)
+sitelibdir = $(sitedir)/$(ruby_version)
+sitedir = $(rubylibprefix)/site_ruby
+rubyarchdir = $(rubylibdir)/$(arch)
+rubylibdir = $(rubylibprefix)/$(ruby_version)
+sitearchincludedir = $(includedir)/$(sitearch)
+archincludedir = $(includedir)/$(arch)
+sitearchlibdir = $(libdir)/$(sitearch)
+archlibdir = $(libdir)/$(arch)
+ridir = $(datarootdir)/$(RI_BASE_NAME)
+mandir = $(datarootdir)/man
+localedir = $(datarootdir)/locale
+libdir = $(exec_prefix)/lib
+psdir = $(docdir)
+pdfdir = $(docdir)
+dvidir = $(docdir)
+htmldir = $(docdir)
+infodir = $(datarootdir)/info
+docdir = $(datarootdir)/doc/$(PACKAGE)
+oldincludedir = $(DESTDIR)/usr/include
+includedir = $(prefix)/include
+localstatedir = $(prefix)/var
+sharedstatedir = $(prefix)/com
+sysconfdir = $(prefix)/etc
+datadir = $(datarootdir)
+datarootdir = $(prefix)/share
+libexecdir = $(exec_prefix)/libexec
+sbindir = $(exec_prefix)/sbin
+bindir = $(exec_prefix)/bin
+archdir = $(rubyarchdir)
+
+
+CC = gcc
+CXX = g++
+LIBRUBY = $(LIBRUBY_SO)
+LIBRUBY_A = lib$(RUBY_SO_NAME)-static.a
+LIBRUBYARG_SHARED = -Wl,-R$(libdir) -L$(libdir) -l$(RUBY_SO_NAME)
+LIBRUBYARG_STATIC = -Wl,-R$(libdir) -L$(libdir) -l$(RUBY_SO_NAME)-static
+empty =
+OUTFLAG = -o $(empty)
+COUTFLAG = -o $(empty)
+
+RUBY_EXTCONF_H = extconf.h
+cflags = $(optflags) $(debugflags) $(warnflags)
+optflags = -O3 -fno-fast-math
+debugflags = -ggdb3
+warnflags = -Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wunused-variable -Wpointer-arith -Wwrite-strings -Wdeclaration-after-statement -Wimplicit-function-declaration -Wdeprecated-declarations -Wno-packed-bitfield-compat
+CCDLFLAGS = -fPIC
+CFLAGS = $(CCDLFLAGS) $(cflags) -fPIC $(ARCH_FLAG)
+INCFLAGS = -I. -I$(arch_hdrdir) -I$(hdrdir) -I$(srcdir)
+DEFS =
+CPPFLAGS = -DRUBY_EXTCONF_H=\"$(RUBY_EXTCONF_H)\" $(DEFS) $(cppflags)
+CXXFLAGS = $(CCDLFLAGS) $(cxxflags) $(ARCH_FLAG)
+ldflags = -L. -fstack-protector -rdynamic -Wl,-export-dynamic
+dldflags =
+ARCH_FLAG =
+DLDFLAGS = $(ldflags) $(dldflags) $(ARCH_FLAG)
+LDSHARED = $(CC) -shared
+LDSHAREDXX = $(CXX) -shared
+AR = ar
+EXEEXT =
+
+RUBY_INSTALL_NAME = $(RUBY_BASE_NAME)
+RUBY_SO_NAME = ruby
+RUBYW_INSTALL_NAME =
+RUBY_VERSION_NAME = $(RUBY_BASE_NAME)-$(ruby_version)
+RUBYW_BASE_NAME = rubyw
+RUBY_BASE_NAME = ruby
+
+arch = x86_64-linux
+sitearch = $(arch)
+ruby_version = 2.2.0
+ruby = $(topdir)/miniruby -I'$(topdir)' -I'$(top_srcdir)/lib' -I'$(extout)/$(arch)' -I'$(extout)/common'
+RUBY = $(ruby)
+ruby_headers = $(hdrdir)/ruby.h $(hdrdir)/ruby/ruby.h $(hdrdir)/ruby/defines.h $(hdrdir)/ruby/missing.h $(hdrdir)/ruby/intern.h $(hdrdir)/ruby/st.h $(hdrdir)/ruby/subst.h $(arch_hdrdir)/ruby/config.h $(RUBY_EXTCONF_H)
+
+RM = rm -f
+RM_RF = $(RUBY) -run -e rm -- -rf
+RMDIRS = rmdir --ignore-fail-on-non-empty -p
+MAKEDIRS = /bin/mkdir -p
+INSTALL = /usr/bin/install -c
+INSTALL_PROG = $(INSTALL) -m 0755
+INSTALL_DATA = $(INSTALL) -m 644
+COPY = cp
+TOUCH = exit >
+
+#### End of system configuration section. ####
+
+preload =
+
+libpath = . $(topdir)
+LIBPATH = -L. -L$(topdir)
+DEFFILE =
+
+CLEANFILES = mkmf.log
+DISTCLEANFILES =
+DISTCLEANDIRS =
+
+extout = $(topdir)/.ext
+extout_prefix = $(extout)$(target_prefix)/
+target_prefix = /-test-
+LOCAL_LIBS =
+LIBS = $(LIBRUBYARG_SHARED) -lpthread -lgmp -ldl -lcrypt -lm -lc
+ORIG_SRCS = printf.c
+SRCS = $(ORIG_SRCS)
+OBJS = printf.o
+HDRS = $(srcdir)/extconf.h
+TARGET = printf
+TARGET_NAME = printf
+TARGET_ENTRY = Init_$(TARGET_NAME)
+DLLIB = $(TARGET).so
+EXTSTATIC =
+STATIC_LIB = $(TARGET).a
+
+TIMESTAMP_DIR = $(extout)/.timestamp
+BINDIR = $(extout)/bin
+RUBYCOMMONDIR = $(extout)/common
+RUBYLIBDIR = $(RUBYCOMMONDIR)$(target_prefix)
+RUBYARCHDIR = $(extout)/$(arch)$(target_prefix)
+HDRDIR = $(extout)/include/ruby$(target_prefix)
+ARCHHDRDIR = $(extout)/include/$(arch)/ruby$(target_prefix)
+
+TARGET_SO = $(RUBYARCHDIR)/$(DLLIB)
+CLEANLIBS = $(RUBYARCHDIR)/$(TARGET).so
+CLEANOBJS = *.o *.bak
+
+all: install
+static: all
+.PHONY: all install static install-so install-rb
+.PHONY: clean clean-so clean-static clean-rb
+
+clean-static::
+clean-rb-default::
+clean-rb::
+clean-so::
+clean: clean-so clean-static clean-rb-default clean-rb
+ -$(Q)$(RM) $(CLEANLIBS) $(CLEANOBJS) $(CLEANFILES) .*.time
+
+distclean-rb-default::
+distclean-rb::
+distclean-so::
+distclean-static::
+distclean: clean distclean-so distclean-static distclean-rb-default distclean-rb
+ -$(Q)$(RM) Makefile $(RUBY_EXTCONF_H) conftest.* mkmf.log
+ -$(Q)$(RM) core ruby$(EXEEXT) *~ $(DISTCLEANFILES)
+ -$(Q)$(RMDIRS) $(DISTCLEANDIRS) 2> /dev/null || true
+
+realclean: distclean
+install: install-so install-rb
+
+install-so: $(RUBYARCHDIR)/$(DLLIB)
+clean-so::
+ -$(Q)$(RM) $(RUBYARCHDIR)/$(DLLIB)
+ -$(Q)$(RMDIRS) $(RUBYARCHDIR) 2> /dev/null || true
+clean-static::
+ -$(Q)$(RM) $(STATIC_LIB)
+install-rb: pre-install-rb install-rb-default
+install-rb-default: pre-install-rb-default
+pre-install-rb: Makefile
+pre-install-rb-default: Makefile
+pre-install-rb-default:
+ @$(NULLCMD)
+$(TIMESTAMP_DIR)/.RUBYARCHDIR.-.-test-.time:
+ $(Q) $(MAKEDIRS) $(@D) $(RUBYARCHDIR)
+ $(Q) $(TOUCH) $@
+
+site-install: site-install-so site-install-rb
+site-install-so: install-so
+site-install-rb: install-rb
+
+.SUFFIXES: .c .m .cc .mm .cxx .cpp .o .S
+
+.cc.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<
+
+.cc.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -S $<
+
+.mm.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<
+
+.mm.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -S $<
+
+.cxx.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<
+
+.cxx.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -S $<
+
+.cpp.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<
+
+.cpp.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -S $<
+
+.c.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -c $<
+
+.c.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -S $<
+
+.m.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -c $<
+
+.m.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -S $<
+
+$(RUBYARCHDIR)/$(DLLIB): $(OBJS) Makefile $(TIMESTAMP_DIR)/.RUBYARCHDIR.-.-test-.time
+ $(ECHO) linking shared-object -test-/$(DLLIB)
+ -$(Q)$(RM) $(@)
+ $(Q) $(LDSHARED) -o $@ $(OBJS) $(LIBPATH) $(DLDFLAGS) $(LOCAL_LIBS) $(LIBS)
+
+$(STATIC_LIB): $(OBJS)
+ -$(Q)$(RM) $(@)
+ $(ECHO) linking static-library $(@)
+ $(Q) $(AR) cru $@ $(OBJS)
+ -$(Q)ranlib $(@) 2> /dev/null || true
+
+###
+$(OBJS): $(RUBY_EXTCONF_H)
+
+$(OBJS): $(HDRS) $(ruby_headers) \
+ $(hdrdir)/ruby/encoding.h \
+ $(hdrdir)/ruby/oniguruma.h
diff --git a/jni/ruby/ext/-test-/printf/depend b/jni/ruby/ext/-test-/printf/depend
new file mode 100644
index 0000000..79b6c53
--- /dev/null
+++ b/jni/ruby/ext/-test-/printf/depend
@@ -0,0 +1,3 @@
+$(OBJS): $(HDRS) $(ruby_headers) \
+ $(hdrdir)/ruby/encoding.h \
+ $(hdrdir)/ruby/oniguruma.h
diff --git a/jni/ruby/ext/-test-/printf/extconf.h b/jni/ruby/ext/-test-/printf/extconf.h
new file mode 100644
index 0000000..cda0cc8
--- /dev/null
+++ b/jni/ruby/ext/-test-/printf/extconf.h
@@ -0,0 +1,3 @@
+#ifndef EXTCONF_H
+#define EXTCONF_H
+#endif
diff --git a/jni/ruby/ext/-test-/printf/extconf.rb b/jni/ruby/ext/-test-/printf/extconf.rb
new file mode 100644
index 0000000..7b96da0
--- /dev/null
+++ b/jni/ruby/ext/-test-/printf/extconf.rb
@@ -0,0 +1 @@
+create_makefile("-test-/printf")
diff --git a/jni/ruby/ext/-test-/printf/printf.c b/jni/ruby/ext/-test-/printf/printf.c
new file mode 100644
index 0000000..666f559
--- /dev/null
+++ b/jni/ruby/ext/-test-/printf/printf.c
@@ -0,0 +1,101 @@
+#include <ruby.h>
+#include <ruby/encoding.h>
+
+static VALUE
+printf_test_s(VALUE self, VALUE obj)
+{
+ return rb_enc_sprintf(rb_usascii_encoding(), "<%"PRIsVALUE">", obj);
+}
+
+static VALUE
+printf_test_v(VALUE self, VALUE obj)
+{
+ return rb_enc_sprintf(rb_usascii_encoding(), "{%+"PRIsVALUE"}", obj);
+}
+
+static VALUE
+printf_test_q(VALUE self, VALUE obj)
+{
+ return rb_enc_sprintf(rb_usascii_encoding(), "[% "PRIsVALUE"]", obj);
+}
+
+static char *
+uint_to_str(char *p, char *e, unsigned int x)
+{
+ char *e0 = e;
+ if (e <= p) return p;
+ do {
+ *--e = x % 10 + '0';
+ } while ((x /= 10) != 0 && e > p);
+ memmove(p, e, e0 - e);
+ return p + (e0 - e);
+}
+
+static VALUE
+printf_test_call(int argc, VALUE *argv, VALUE self)
+{
+ VALUE opt, type, num, result;
+ char format[sizeof(int) * 6 + 8], *p = format, cnv;
+ int n = 0;
+ const char *s = 0;
+
+ rb_scan_args(argc, argv, "2:", &type, &num, &opt);
+ Check_Type(type, T_STRING);
+ if (RSTRING_LEN(type) != 1) rb_raise(rb_eArgError, "wrong length(%ld)", RSTRING_LEN(type));
+ switch (cnv = RSTRING_PTR(type)[0]) {
+ case 'd': case 'x': case 'o': case 'X':
+ n = NUM2INT(num);
+ break;
+ case 's':
+ s = StringValueCStr(num);
+ break;
+ default: rb_raise(rb_eArgError, "wrong conversion(%c)", cnv);
+ }
+ *p++ = '%';
+ if (!NIL_P(opt)) {
+ VALUE v;
+ Check_Type(opt, T_HASH);
+ if (RTEST(rb_hash_aref(opt, ID2SYM(rb_intern("space"))))) {
+ *p++ = ' ';
+ }
+ if (RTEST(rb_hash_aref(opt, ID2SYM(rb_intern("hash"))))) {
+ *p++ = '#';
+ }
+ if (RTEST(rb_hash_aref(opt, ID2SYM(rb_intern("plus"))))) {
+ *p++ = '+';
+ }
+ if (RTEST(rb_hash_aref(opt, ID2SYM(rb_intern("minus"))))) {
+ *p++ = '-';
+ }
+ if (RTEST(rb_hash_aref(opt, ID2SYM(rb_intern("zero"))))) {
+ *p++ = '0';
+ }
+ if (!NIL_P(v = rb_hash_aref(opt, ID2SYM(rb_intern("width"))))) {
+ p = uint_to_str(p, format + sizeof(format), NUM2UINT(v));
+ }
+ if (!NIL_P(v = rb_hash_aref(opt, ID2SYM(rb_intern("prec"))))) {
+ *p++ = '.';
+ if (FIXNUM_P(v))
+ p = uint_to_str(p, format + sizeof(format), NUM2UINT(v));
+ }
+ }
+ *p++ = cnv;
+ *p++ = '\0';
+ if (cnv == 's') {
+ result = rb_enc_sprintf(rb_usascii_encoding(), format, s);
+ }
+ else {
+ result = rb_enc_sprintf(rb_usascii_encoding(), format, n);
+ }
+ return rb_assoc_new(result, rb_usascii_str_new_cstr(format));
+}
+
+void
+Init_printf(void)
+{
+ VALUE m = rb_define_module_under(rb_define_module("Bug"), "Printf");
+ rb_define_singleton_method(m, "s", printf_test_s, 1);
+ rb_define_singleton_method(m, "v", printf_test_v, 1);
+ rb_define_singleton_method(m, "q", printf_test_q, 1);
+ rb_define_singleton_method(m, "call", printf_test_call, -1);
+}
diff --git a/jni/ruby/ext/-test-/proc/Makefile b/jni/ruby/ext/-test-/proc/Makefile
new file mode 100644
index 0000000..e2dd503
--- /dev/null
+++ b/jni/ruby/ext/-test-/proc/Makefile
@@ -0,0 +1,267 @@
+
+SHELL = /bin/sh
+
+# V=0 quiet, V=1 verbose. other values don't work.
+V = 0
+Q1 = $(V:1=)
+Q = $(Q1:0=@)
+ECHO1 = $(V:1=@:)
+ECHO = $(ECHO1:0=@echo)
+NULLCMD = :
+
+#### Start of system configuration section. ####
+top_srcdir = $(topdir)/.
+srcdir = $(top_srcdir)/ext/-test-/proc
+topdir = ../../..
+hdrdir = $(top_srcdir)/include
+arch_hdrdir = $(extout)/include/$(arch)
+PATH_SEPARATOR = :
+VPATH = $(srcdir):$(arch_hdrdir)/ruby:$(hdrdir)/ruby
+RUBYLIB =
+RUBYOPT = -
+prefix = $(DESTDIR)/usr/local
+rubysitearchprefix = $(rubylibprefix)/$(sitearch)
+rubyarchprefix = $(rubylibprefix)/$(arch)
+rubylibprefix = $(libdir)/$(RUBY_BASE_NAME)
+exec_prefix = $(prefix)
+vendorarchhdrdir = $(vendorhdrdir)/$(sitearch)
+sitearchhdrdir = $(sitehdrdir)/$(sitearch)
+rubyarchhdrdir = $(rubyhdrdir)/$(arch)
+vendorhdrdir = $(rubyhdrdir)/vendor_ruby
+sitehdrdir = $(rubyhdrdir)/site_ruby
+rubyhdrdir = $(includedir)/$(RUBY_VERSION_NAME)
+vendorarchdir = $(vendorlibdir)/$(sitearch)
+vendorlibdir = $(vendordir)/$(ruby_version)
+vendordir = $(rubylibprefix)/vendor_ruby
+sitearchdir = $(sitelibdir)/$(sitearch)
+sitelibdir = $(sitedir)/$(ruby_version)
+sitedir = $(rubylibprefix)/site_ruby
+rubyarchdir = $(rubylibdir)/$(arch)
+rubylibdir = $(rubylibprefix)/$(ruby_version)
+sitearchincludedir = $(includedir)/$(sitearch)
+archincludedir = $(includedir)/$(arch)
+sitearchlibdir = $(libdir)/$(sitearch)
+archlibdir = $(libdir)/$(arch)
+ridir = $(datarootdir)/$(RI_BASE_NAME)
+mandir = $(datarootdir)/man
+localedir = $(datarootdir)/locale
+libdir = $(exec_prefix)/lib
+psdir = $(docdir)
+pdfdir = $(docdir)
+dvidir = $(docdir)
+htmldir = $(docdir)
+infodir = $(datarootdir)/info
+docdir = $(datarootdir)/doc/$(PACKAGE)
+oldincludedir = $(DESTDIR)/usr/include
+includedir = $(prefix)/include
+localstatedir = $(prefix)/var
+sharedstatedir = $(prefix)/com
+sysconfdir = $(prefix)/etc
+datadir = $(datarootdir)
+datarootdir = $(prefix)/share
+libexecdir = $(exec_prefix)/libexec
+sbindir = $(exec_prefix)/sbin
+bindir = $(exec_prefix)/bin
+archdir = $(rubyarchdir)
+
+
+CC = gcc
+CXX = g++
+LIBRUBY = $(LIBRUBY_SO)
+LIBRUBY_A = lib$(RUBY_SO_NAME)-static.a
+LIBRUBYARG_SHARED = -Wl,-R$(libdir) -L$(libdir) -l$(RUBY_SO_NAME)
+LIBRUBYARG_STATIC = -Wl,-R$(libdir) -L$(libdir) -l$(RUBY_SO_NAME)-static
+empty =
+OUTFLAG = -o $(empty)
+COUTFLAG = -o $(empty)
+
+RUBY_EXTCONF_H = extconf.h
+cflags = $(optflags) $(debugflags) $(warnflags)
+optflags = -O3 -fno-fast-math
+debugflags = -ggdb3
+warnflags = -Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wunused-variable -Wpointer-arith -Wwrite-strings -Wdeclaration-after-statement -Wimplicit-function-declaration -Wdeprecated-declarations -Wno-packed-bitfield-compat
+CCDLFLAGS = -fPIC
+CFLAGS = $(CCDLFLAGS) $(cflags) -fPIC $(ARCH_FLAG)
+INCFLAGS = -I. -I$(arch_hdrdir) -I$(hdrdir) -I$(srcdir) -I$(topdir) -I$(top_srcdir)
+DEFS =
+CPPFLAGS = -DRUBY_EXTCONF_H=\"$(RUBY_EXTCONF_H)\" $(DEFS) $(cppflags)
+CXXFLAGS = $(CCDLFLAGS) $(cxxflags) $(ARCH_FLAG)
+ldflags = -L. -fstack-protector -rdynamic -Wl,-export-dynamic
+dldflags =
+ARCH_FLAG =
+DLDFLAGS = $(ldflags) $(dldflags) $(ARCH_FLAG)
+LDSHARED = $(CC) -shared
+LDSHAREDXX = $(CXX) -shared
+AR = ar
+EXEEXT =
+
+RUBY_INSTALL_NAME = $(RUBY_BASE_NAME)
+RUBY_SO_NAME = ruby
+RUBYW_INSTALL_NAME =
+RUBY_VERSION_NAME = $(RUBY_BASE_NAME)-$(ruby_version)
+RUBYW_BASE_NAME = rubyw
+RUBY_BASE_NAME = ruby
+
+arch = x86_64-linux
+sitearch = $(arch)
+ruby_version = 2.2.0
+ruby = $(topdir)/miniruby -I'$(topdir)' -I'$(top_srcdir)/lib' -I'$(extout)/$(arch)' -I'$(extout)/common'
+RUBY = $(ruby)
+ruby_headers = $(hdrdir)/ruby.h $(hdrdir)/ruby/ruby.h $(hdrdir)/ruby/defines.h $(hdrdir)/ruby/missing.h $(hdrdir)/ruby/intern.h $(hdrdir)/ruby/st.h $(hdrdir)/ruby/subst.h $(arch_hdrdir)/ruby/config.h $(RUBY_EXTCONF_H)
+
+RM = rm -f
+RM_RF = $(RUBY) -run -e rm -- -rf
+RMDIRS = rmdir --ignore-fail-on-non-empty -p
+MAKEDIRS = /bin/mkdir -p
+INSTALL = /usr/bin/install -c
+INSTALL_PROG = $(INSTALL) -m 0755
+INSTALL_DATA = $(INSTALL) -m 644
+COPY = cp
+TOUCH = exit >
+
+#### End of system configuration section. ####
+
+preload =
+
+libpath = . $(topdir)
+LIBPATH = -L. -L$(topdir)
+DEFFILE =
+
+CLEANFILES = mkmf.log
+DISTCLEANFILES =
+DISTCLEANDIRS =
+
+extout = $(topdir)/.ext
+extout_prefix = $(extout)$(target_prefix)/
+target_prefix = /-test-
+LOCAL_LIBS =
+LIBS = $(LIBRUBYARG_SHARED) -lpthread -lgmp -ldl -lcrypt -lm -lc
+ORIG_SRCS = receiver.c super.c init.c
+SRCS = $(ORIG_SRCS)
+OBJS = receiver.o super.o init.o
+HDRS = $(srcdir)/extconf.h
+TARGET = proc
+TARGET_NAME = proc
+TARGET_ENTRY = Init_$(TARGET_NAME)
+DLLIB = $(TARGET).so
+EXTSTATIC =
+STATIC_LIB = $(TARGET).a
+
+TIMESTAMP_DIR = $(extout)/.timestamp
+BINDIR = $(extout)/bin
+RUBYCOMMONDIR = $(extout)/common
+RUBYLIBDIR = $(RUBYCOMMONDIR)$(target_prefix)
+RUBYARCHDIR = $(extout)/$(arch)$(target_prefix)
+HDRDIR = $(extout)/include/ruby$(target_prefix)
+ARCHHDRDIR = $(extout)/include/$(arch)/ruby$(target_prefix)
+
+TARGET_SO = $(RUBYARCHDIR)/$(DLLIB)
+CLEANLIBS = $(RUBYARCHDIR)/$(TARGET).so
+CLEANOBJS = *.o *.bak
+
+all: install
+static: all
+.PHONY: all install static install-so install-rb
+.PHONY: clean clean-so clean-static clean-rb
+
+clean-static::
+clean-rb-default::
+clean-rb::
+clean-so::
+clean: clean-so clean-static clean-rb-default clean-rb
+ -$(Q)$(RM) $(CLEANLIBS) $(CLEANOBJS) $(CLEANFILES) .*.time
+
+distclean-rb-default::
+distclean-rb::
+distclean-so::
+distclean-static::
+distclean: clean distclean-so distclean-static distclean-rb-default distclean-rb
+ -$(Q)$(RM) Makefile $(RUBY_EXTCONF_H) conftest.* mkmf.log
+ -$(Q)$(RM) core ruby$(EXEEXT) *~ $(DISTCLEANFILES)
+ -$(Q)$(RMDIRS) $(DISTCLEANDIRS) 2> /dev/null || true
+
+realclean: distclean
+install: install-so install-rb
+
+install-so: $(RUBYARCHDIR)/$(DLLIB)
+clean-so::
+ -$(Q)$(RM) $(RUBYARCHDIR)/$(DLLIB)
+ -$(Q)$(RMDIRS) $(RUBYARCHDIR) 2> /dev/null || true
+clean-static::
+ -$(Q)$(RM) $(STATIC_LIB)
+install-rb: pre-install-rb install-rb-default
+install-rb-default: pre-install-rb-default
+pre-install-rb: Makefile
+pre-install-rb-default: Makefile
+pre-install-rb-default:
+ @$(NULLCMD)
+$(TIMESTAMP_DIR)/.RUBYARCHDIR.-.-test-.time:
+ $(Q) $(MAKEDIRS) $(@D) $(RUBYARCHDIR)
+ $(Q) $(TOUCH) $@
+
+site-install: site-install-so site-install-rb
+site-install-so: install-so
+site-install-rb: install-rb
+
+.SUFFIXES: .c .m .cc .mm .cxx .cpp .o .S
+
+.cc.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<
+
+.cc.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -S $<
+
+.mm.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<
+
+.mm.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -S $<
+
+.cxx.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<
+
+.cxx.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -S $<
+
+.cpp.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<
+
+.cpp.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -S $<
+
+.c.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -c $<
+
+.c.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -S $<
+
+.m.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -c $<
+
+.m.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -S $<
+
+$(RUBYARCHDIR)/$(DLLIB): $(OBJS) Makefile $(TIMESTAMP_DIR)/.RUBYARCHDIR.-.-test-.time
+ $(ECHO) linking shared-object -test-/$(DLLIB)
+ -$(Q)$(RM) $(@)
+ $(Q) $(LDSHARED) -o $@ $(OBJS) $(LIBPATH) $(DLDFLAGS) $(LOCAL_LIBS) $(LIBS)
+
+$(STATIC_LIB): $(OBJS)
+ -$(Q)$(RM) $(@)
+ $(ECHO) linking static-library $(@)
+ $(Q) $(AR) cru $@ $(OBJS)
+ -$(Q)ranlib $(@) 2> /dev/null || true
+
+$(OBJS): $(HDRS) $(ruby_headers)
diff --git a/jni/ruby/ext/-test-/proc/extconf.h b/jni/ruby/ext/-test-/proc/extconf.h
new file mode 100644
index 0000000..0daa29b
--- /dev/null
+++ b/jni/ruby/ext/-test-/proc/extconf.h
@@ -0,0 +1,4 @@
+#ifndef EXTCONF_H
+#define EXTCONF_H
+#define TEST_INIT_FUNCS(X) X(receiver) X(super)
+#endif
diff --git a/jni/ruby/ext/-test-/proc/extconf.rb b/jni/ruby/ext/-test-/proc/extconf.rb
new file mode 100644
index 0000000..40741d0
--- /dev/null
+++ b/jni/ruby/ext/-test-/proc/extconf.rb
@@ -0,0 +1,7 @@
+$INCFLAGS << " -I$(topdir) -I$(top_srcdir)"
+$srcs = Dir[File.join($srcdir, "*.{#{SRC_EXT.join(%q{,})}}")]
+inits = $srcs.map {|s| File.basename(s, ".*")}
+inits.delete("init")
+inits.map! {|s|"X(#{s})"}
+$defs << "-DTEST_INIT_FUNCS(X)=\"#{inits.join(' ')}\""
+create_makefile("-test-/proc")
diff --git a/jni/ruby/ext/-test-/proc/init.c b/jni/ruby/ext/-test-/proc/init.c
new file mode 100644
index 0000000..814c55d
--- /dev/null
+++ b/jni/ruby/ext/-test-/proc/init.c
@@ -0,0 +1,11 @@
+#include "ruby.h"
+
+#define init(n) {void Init_##n(VALUE klass); Init_##n(klass);}
+
+void
+Init_proc(void)
+{
+ VALUE mBug = rb_define_module("Bug");
+ VALUE klass = rb_define_module_under(mBug, "Proc");
+ TEST_INIT_FUNCS(init);
+}
diff --git a/jni/ruby/ext/-test-/proc/receiver.c b/jni/ruby/ext/-test-/proc/receiver.c
new file mode 100644
index 0000000..fe44a22
--- /dev/null
+++ b/jni/ruby/ext/-test-/proc/receiver.c
@@ -0,0 +1,21 @@
+#include "ruby.h"
+
+VALUE rb_current_receiver(void);
+
+static VALUE
+bug_proc_call_receiver(RB_BLOCK_CALL_FUNC_ARGLIST(yieldarg, procarg))
+{
+ return rb_current_receiver();
+}
+
+static VALUE
+bug_proc_make_call_receiver(VALUE self, VALUE procarg)
+{
+ return rb_proc_new(bug_proc_call_receiver, procarg);
+}
+
+void
+Init_receiver(VALUE klass)
+{
+ rb_define_singleton_method(klass, "make_call_receiver", bug_proc_make_call_receiver, 1);
+}
diff --git a/jni/ruby/ext/-test-/proc/super.c b/jni/ruby/ext/-test-/proc/super.c
new file mode 100644
index 0000000..dbe8af0
--- /dev/null
+++ b/jni/ruby/ext/-test-/proc/super.c
@@ -0,0 +1,27 @@
+#include "ruby.h"
+
+static VALUE
+bug_proc_call_super(RB_BLOCK_CALL_FUNC_ARGLIST(yieldarg, procarg))
+{
+ VALUE args[2];
+ VALUE ret;
+ args[0] = yieldarg;
+ args[1] = procarg;
+ ret = rb_call_super(2, args);
+ if (!NIL_P(blockarg)) {
+ ret = rb_proc_call(blockarg, ret);
+ }
+ return ret;
+}
+
+static VALUE
+bug_proc_make_call_super(VALUE self, VALUE procarg)
+{
+ return rb_proc_new(bug_proc_call_super, procarg);
+}
+
+void
+Init_super(VALUE klass)
+{
+ rb_define_singleton_method(klass, "make_call_super", bug_proc_make_call_super, 1);
+}
diff --git a/jni/ruby/ext/-test-/rational/Makefile b/jni/ruby/ext/-test-/rational/Makefile
new file mode 100644
index 0000000..32f790d
--- /dev/null
+++ b/jni/ruby/ext/-test-/rational/Makefile
@@ -0,0 +1,289 @@
+
+SHELL = /bin/sh
+
+# V=0 quiet, V=1 verbose. other values don't work.
+V = 0
+Q1 = $(V:1=)
+Q = $(Q1:0=@)
+ECHO1 = $(V:1=@:)
+ECHO = $(ECHO1:0=@echo)
+NULLCMD = :
+
+#### Start of system configuration section. ####
+top_srcdir = $(topdir)/.
+srcdir = $(top_srcdir)/ext/-test-/rational
+topdir = ../../..
+hdrdir = $(top_srcdir)/include
+arch_hdrdir = $(extout)/include/$(arch)
+PATH_SEPARATOR = :
+VPATH = $(srcdir):$(arch_hdrdir)/ruby:$(hdrdir)/ruby
+RUBYLIB =
+RUBYOPT = -
+prefix = $(DESTDIR)/usr/local
+rubysitearchprefix = $(rubylibprefix)/$(sitearch)
+rubyarchprefix = $(rubylibprefix)/$(arch)
+rubylibprefix = $(libdir)/$(RUBY_BASE_NAME)
+exec_prefix = $(prefix)
+vendorarchhdrdir = $(vendorhdrdir)/$(sitearch)
+sitearchhdrdir = $(sitehdrdir)/$(sitearch)
+rubyarchhdrdir = $(rubyhdrdir)/$(arch)
+vendorhdrdir = $(rubyhdrdir)/vendor_ruby
+sitehdrdir = $(rubyhdrdir)/site_ruby
+rubyhdrdir = $(includedir)/$(RUBY_VERSION_NAME)
+vendorarchdir = $(vendorlibdir)/$(sitearch)
+vendorlibdir = $(vendordir)/$(ruby_version)
+vendordir = $(rubylibprefix)/vendor_ruby
+sitearchdir = $(sitelibdir)/$(sitearch)
+sitelibdir = $(sitedir)/$(ruby_version)
+sitedir = $(rubylibprefix)/site_ruby
+rubyarchdir = $(rubylibdir)/$(arch)
+rubylibdir = $(rubylibprefix)/$(ruby_version)
+sitearchincludedir = $(includedir)/$(sitearch)
+archincludedir = $(includedir)/$(arch)
+sitearchlibdir = $(libdir)/$(sitearch)
+archlibdir = $(libdir)/$(arch)
+ridir = $(datarootdir)/$(RI_BASE_NAME)
+mandir = $(datarootdir)/man
+localedir = $(datarootdir)/locale
+libdir = $(exec_prefix)/lib
+psdir = $(docdir)
+pdfdir = $(docdir)
+dvidir = $(docdir)
+htmldir = $(docdir)
+infodir = $(datarootdir)/info
+docdir = $(datarootdir)/doc/$(PACKAGE)
+oldincludedir = $(DESTDIR)/usr/include
+includedir = $(prefix)/include
+localstatedir = $(prefix)/var
+sharedstatedir = $(prefix)/com
+sysconfdir = $(prefix)/etc
+datadir = $(datarootdir)
+datarootdir = $(prefix)/share
+libexecdir = $(exec_prefix)/libexec
+sbindir = $(exec_prefix)/sbin
+bindir = $(exec_prefix)/bin
+archdir = $(rubyarchdir)
+
+
+CC = gcc
+CXX = g++
+LIBRUBY = $(LIBRUBY_SO)
+LIBRUBY_A = lib$(RUBY_SO_NAME)-static.a
+LIBRUBYARG_SHARED = -Wl,-R$(libdir) -L$(libdir) -l$(RUBY_SO_NAME)
+LIBRUBYARG_STATIC = -Wl,-R$(libdir) -L$(libdir) -l$(RUBY_SO_NAME)-static
+empty =
+OUTFLAG = -o $(empty)
+COUTFLAG = -o $(empty)
+
+RUBY_EXTCONF_H = extconf.h
+cflags = $(optflags) $(debugflags) $(warnflags)
+optflags = -O3 -fno-fast-math
+debugflags = -ggdb3
+warnflags = -Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wunused-variable -Wpointer-arith -Wwrite-strings -Wdeclaration-after-statement -Wimplicit-function-declaration -Wdeprecated-declarations -Wno-packed-bitfield-compat
+CCDLFLAGS = -fPIC
+CFLAGS = $(CCDLFLAGS) $(cflags) -fPIC $(ARCH_FLAG)
+INCFLAGS = -I. -I$(arch_hdrdir) -I$(hdrdir) -I$(srcdir) -I$(topdir) -I$(top_srcdir)
+DEFS =
+CPPFLAGS = -DRUBY_EXTCONF_H=\"$(RUBY_EXTCONF_H)\" $(DEFS) $(cppflags)
+CXXFLAGS = $(CCDLFLAGS) $(cxxflags) $(ARCH_FLAG)
+ldflags = -L. -fstack-protector -rdynamic -Wl,-export-dynamic
+dldflags =
+ARCH_FLAG =
+DLDFLAGS = $(ldflags) $(dldflags) $(ARCH_FLAG)
+LDSHARED = $(CC) -shared
+LDSHAREDXX = $(CXX) -shared
+AR = ar
+EXEEXT =
+
+RUBY_INSTALL_NAME = $(RUBY_BASE_NAME)
+RUBY_SO_NAME = ruby
+RUBYW_INSTALL_NAME =
+RUBY_VERSION_NAME = $(RUBY_BASE_NAME)-$(ruby_version)
+RUBYW_BASE_NAME = rubyw
+RUBY_BASE_NAME = ruby
+
+arch = x86_64-linux
+sitearch = $(arch)
+ruby_version = 2.2.0
+ruby = $(topdir)/miniruby -I'$(topdir)' -I'$(top_srcdir)/lib' -I'$(extout)/$(arch)' -I'$(extout)/common'
+RUBY = $(ruby)
+ruby_headers = $(hdrdir)/ruby.h $(hdrdir)/ruby/ruby.h $(hdrdir)/ruby/defines.h $(hdrdir)/ruby/missing.h $(hdrdir)/ruby/intern.h $(hdrdir)/ruby/st.h $(hdrdir)/ruby/subst.h $(arch_hdrdir)/ruby/config.h $(RUBY_EXTCONF_H)
+
+RM = rm -f
+RM_RF = $(RUBY) -run -e rm -- -rf
+RMDIRS = rmdir --ignore-fail-on-non-empty -p
+MAKEDIRS = /bin/mkdir -p
+INSTALL = /usr/bin/install -c
+INSTALL_PROG = $(INSTALL) -m 0755
+INSTALL_DATA = $(INSTALL) -m 644
+COPY = cp
+TOUCH = exit >
+
+#### End of system configuration section. ####
+
+preload =
+
+libpath = . $(topdir)
+LIBPATH = -L. -L$(topdir)
+DEFFILE =
+
+CLEANFILES = mkmf.log
+DISTCLEANFILES =
+DISTCLEANDIRS =
+
+extout = $(topdir)/.ext
+extout_prefix = $(extout)$(target_prefix)/
+target_prefix = /-test-
+LOCAL_LIBS =
+LIBS = $(LIBRUBYARG_SHARED) -lpthread -lgmp -ldl -lcrypt -lm -lc
+ORIG_SRCS = rat.c
+SRCS = $(ORIG_SRCS)
+OBJS = rat.o
+HDRS = $(srcdir)/extconf.h
+TARGET = rational
+TARGET_NAME = rational
+TARGET_ENTRY = Init_$(TARGET_NAME)
+DLLIB = $(TARGET).so
+EXTSTATIC =
+STATIC_LIB = $(TARGET).a
+
+TIMESTAMP_DIR = $(extout)/.timestamp
+BINDIR = $(extout)/bin
+RUBYCOMMONDIR = $(extout)/common
+RUBYLIBDIR = $(RUBYCOMMONDIR)$(target_prefix)
+RUBYARCHDIR = $(extout)/$(arch)$(target_prefix)
+HDRDIR = $(extout)/include/ruby$(target_prefix)
+ARCHHDRDIR = $(extout)/include/$(arch)/ruby$(target_prefix)
+
+TARGET_SO = $(RUBYARCHDIR)/$(DLLIB)
+CLEANLIBS = $(RUBYARCHDIR)/$(TARGET).so
+CLEANOBJS = *.o *.bak
+
+all: install
+static: all
+.PHONY: all install static install-so install-rb
+.PHONY: clean clean-so clean-static clean-rb
+
+clean-static::
+clean-rb-default::
+clean-rb::
+clean-so::
+clean: clean-so clean-static clean-rb-default clean-rb
+ -$(Q)$(RM) $(CLEANLIBS) $(CLEANOBJS) $(CLEANFILES) .*.time
+
+distclean-rb-default::
+distclean-rb::
+distclean-so::
+distclean-static::
+distclean: clean distclean-so distclean-static distclean-rb-default distclean-rb
+ -$(Q)$(RM) Makefile $(RUBY_EXTCONF_H) conftest.* mkmf.log
+ -$(Q)$(RM) core ruby$(EXEEXT) *~ $(DISTCLEANFILES)
+ -$(Q)$(RMDIRS) $(DISTCLEANDIRS) 2> /dev/null || true
+
+realclean: distclean
+install: install-so install-rb
+
+install-so: $(RUBYARCHDIR)/$(DLLIB)
+clean-so::
+ -$(Q)$(RM) $(RUBYARCHDIR)/$(DLLIB)
+ -$(Q)$(RMDIRS) $(RUBYARCHDIR) 2> /dev/null || true
+clean-static::
+ -$(Q)$(RM) $(STATIC_LIB)
+install-rb: pre-install-rb install-rb-default
+install-rb-default: pre-install-rb-default
+pre-install-rb: Makefile
+pre-install-rb-default: Makefile
+pre-install-rb-default:
+ @$(NULLCMD)
+$(TIMESTAMP_DIR)/.RUBYARCHDIR.-.-test-.time:
+ $(Q) $(MAKEDIRS) $(@D) $(RUBYARCHDIR)
+ $(Q) $(TOUCH) $@
+
+site-install: site-install-so site-install-rb
+site-install-so: install-so
+site-install-rb: install-rb
+
+.SUFFIXES: .c .m .cc .mm .cxx .cpp .o .S
+
+.cc.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<
+
+.cc.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -S $<
+
+.mm.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<
+
+.mm.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -S $<
+
+.cxx.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<
+
+.cxx.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -S $<
+
+.cpp.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<
+
+.cpp.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -S $<
+
+.c.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -c $<
+
+.c.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -S $<
+
+.m.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -c $<
+
+.m.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -S $<
+
+$(RUBYARCHDIR)/$(DLLIB): $(OBJS) Makefile $(TIMESTAMP_DIR)/.RUBYARCHDIR.-.-test-.time
+ $(ECHO) linking shared-object -test-/$(DLLIB)
+ -$(Q)$(RM) $(@)
+ $(Q) $(LDSHARED) -o $@ $(OBJS) $(LIBPATH) $(DLDFLAGS) $(LOCAL_LIBS) $(LIBS)
+
+$(STATIC_LIB): $(OBJS)
+ -$(Q)$(RM) $(@)
+ $(ECHO) linking static-library $(@)
+ $(Q) $(AR) cru $@ $(OBJS)
+ -$(Q)ranlib $(@) 2> /dev/null || true
+
+###
+$(OBJS): $(RUBY_EXTCONF_H)
+
+$(OBJS): $(HDRS) $(ruby_headers)
+
+rat.o: rat.c $(top_srcdir)/internal.h
+
+# AUTOGENERATED DEPENDENCIES START
+rat.o: $(RUBY_EXTCONF_H)
+rat.o: $(arch_hdrdir)/ruby/config.h
+rat.o: $(hdrdir)/ruby/defines.h
+rat.o: $(hdrdir)/ruby/encoding.h
+rat.o: $(hdrdir)/ruby/intern.h
+rat.o: $(hdrdir)/ruby/io.h
+rat.o: $(hdrdir)/ruby/missing.h
+rat.o: $(hdrdir)/ruby/oniguruma.h
+rat.o: $(hdrdir)/ruby/ruby.h
+rat.o: $(hdrdir)/ruby/st.h
+rat.o: $(hdrdir)/ruby/subst.h
+rat.o: $(top_srcdir)/include/ruby.h
+rat.o: $(top_srcdir)/internal.h
+rat.o: rat.c
+# AUTOGENERATED DEPENDENCIES END
diff --git a/jni/ruby/ext/-test-/rational/depend b/jni/ruby/ext/-test-/rational/depend
new file mode 100644
index 0000000..bff4981
--- /dev/null
+++ b/jni/ruby/ext/-test-/rational/depend
@@ -0,0 +1,20 @@
+$(OBJS): $(HDRS) $(ruby_headers)
+
+rat.o: rat.c $(top_srcdir)/internal.h
+
+# AUTOGENERATED DEPENDENCIES START
+rat.o: $(RUBY_EXTCONF_H)
+rat.o: $(arch_hdrdir)/ruby/config.h
+rat.o: $(hdrdir)/ruby/defines.h
+rat.o: $(hdrdir)/ruby/encoding.h
+rat.o: $(hdrdir)/ruby/intern.h
+rat.o: $(hdrdir)/ruby/io.h
+rat.o: $(hdrdir)/ruby/missing.h
+rat.o: $(hdrdir)/ruby/oniguruma.h
+rat.o: $(hdrdir)/ruby/ruby.h
+rat.o: $(hdrdir)/ruby/st.h
+rat.o: $(hdrdir)/ruby/subst.h
+rat.o: $(top_srcdir)/include/ruby.h
+rat.o: $(top_srcdir)/internal.h
+rat.o: rat.c
+# AUTOGENERATED DEPENDENCIES END
diff --git a/jni/ruby/ext/-test-/rational/extconf.h b/jni/ruby/ext/-test-/rational/extconf.h
new file mode 100644
index 0000000..ebb36c5
--- /dev/null
+++ b/jni/ruby/ext/-test-/rational/extconf.h
@@ -0,0 +1,4 @@
+#ifndef EXTCONF_H
+#define EXTCONF_H
+#define TEST_INIT_FUNCS(X) X(rat)
+#endif
diff --git a/jni/ruby/ext/-test-/rational/extconf.rb b/jni/ruby/ext/-test-/rational/extconf.rb
new file mode 100644
index 0000000..bd658de
--- /dev/null
+++ b/jni/ruby/ext/-test-/rational/extconf.rb
@@ -0,0 +1,7 @@
+$INCFLAGS << " -I$(topdir) -I$(top_srcdir)"
+$srcs = Dir[File.join($srcdir, "*.{#{SRC_EXT.join(%q{,})}}")]
+inits = $srcs.map {|s| File.basename(s, ".*")}
+inits.delete("init")
+inits.map! {|s|"X(#{s})"}
+$defs << "-DTEST_INIT_FUNCS(X)=\"#{inits.join(' ')}\""
+create_makefile("-test-/rational")
diff --git a/jni/ruby/ext/-test-/rational/rat.c b/jni/ruby/ext/-test-/rational/rat.c
new file mode 100644
index 0000000..772546f
--- /dev/null
+++ b/jni/ruby/ext/-test-/rational/rat.c
@@ -0,0 +1,37 @@
+#include "internal.h"
+
+#if defined(HAVE_LIBGMP) && defined(HAVE_GMP_H)
+static VALUE
+big(VALUE x)
+{
+ if (FIXNUM_P(x))
+ return rb_int2big(FIX2LONG(x));
+ if (RB_TYPE_P(x, T_BIGNUM))
+ return x;
+ rb_raise(rb_eTypeError, "can't convert %s to Bignum",
+ rb_obj_classname(x));
+}
+#endif
+
+static VALUE
+gcd_normal(VALUE x, VALUE y)
+{
+ return rb_big_norm(rb_gcd_normal(rb_to_int(x), rb_to_int(y)));
+}
+
+#if defined(HAVE_LIBGMP) && defined(HAVE_GMP_H)
+static VALUE
+gcd_gmp(VALUE x, VALUE y)
+{
+ return rb_big_norm(rb_gcd_gmp(big(x), big(y)));
+}
+#else
+#define gcd_gmp rb_f_notimplement
+#endif
+
+void
+Init_rational(VALUE klass)
+{
+ rb_define_method(rb_cInteger, "gcd_normal", gcd_normal, 1);
+ rb_define_method(rb_cInteger, "gcd_gmp", gcd_gmp, 1);
+}
diff --git a/jni/ruby/ext/-test-/recursion/Makefile b/jni/ruby/ext/-test-/recursion/Makefile
new file mode 100644
index 0000000..3ce659e
--- /dev/null
+++ b/jni/ruby/ext/-test-/recursion/Makefile
@@ -0,0 +1,267 @@
+
+SHELL = /bin/sh
+
+# V=0 quiet, V=1 verbose. other values don't work.
+V = 0
+Q1 = $(V:1=)
+Q = $(Q1:0=@)
+ECHO1 = $(V:1=@:)
+ECHO = $(ECHO1:0=@echo)
+NULLCMD = :
+
+#### Start of system configuration section. ####
+top_srcdir = $(topdir)/.
+srcdir = $(top_srcdir)/ext/-test-/recursion
+topdir = ../../..
+hdrdir = $(top_srcdir)/include
+arch_hdrdir = $(extout)/include/$(arch)
+PATH_SEPARATOR = :
+VPATH = $(srcdir):$(arch_hdrdir)/ruby:$(hdrdir)/ruby
+RUBYLIB =
+RUBYOPT = -
+prefix = $(DESTDIR)/usr/local
+rubysitearchprefix = $(rubylibprefix)/$(sitearch)
+rubyarchprefix = $(rubylibprefix)/$(arch)
+rubylibprefix = $(libdir)/$(RUBY_BASE_NAME)
+exec_prefix = $(prefix)
+vendorarchhdrdir = $(vendorhdrdir)/$(sitearch)
+sitearchhdrdir = $(sitehdrdir)/$(sitearch)
+rubyarchhdrdir = $(rubyhdrdir)/$(arch)
+vendorhdrdir = $(rubyhdrdir)/vendor_ruby
+sitehdrdir = $(rubyhdrdir)/site_ruby
+rubyhdrdir = $(includedir)/$(RUBY_VERSION_NAME)
+vendorarchdir = $(vendorlibdir)/$(sitearch)
+vendorlibdir = $(vendordir)/$(ruby_version)
+vendordir = $(rubylibprefix)/vendor_ruby
+sitearchdir = $(sitelibdir)/$(sitearch)
+sitelibdir = $(sitedir)/$(ruby_version)
+sitedir = $(rubylibprefix)/site_ruby
+rubyarchdir = $(rubylibdir)/$(arch)
+rubylibdir = $(rubylibprefix)/$(ruby_version)
+sitearchincludedir = $(includedir)/$(sitearch)
+archincludedir = $(includedir)/$(arch)
+sitearchlibdir = $(libdir)/$(sitearch)
+archlibdir = $(libdir)/$(arch)
+ridir = $(datarootdir)/$(RI_BASE_NAME)
+mandir = $(datarootdir)/man
+localedir = $(datarootdir)/locale
+libdir = $(exec_prefix)/lib
+psdir = $(docdir)
+pdfdir = $(docdir)
+dvidir = $(docdir)
+htmldir = $(docdir)
+infodir = $(datarootdir)/info
+docdir = $(datarootdir)/doc/$(PACKAGE)
+oldincludedir = $(DESTDIR)/usr/include
+includedir = $(prefix)/include
+localstatedir = $(prefix)/var
+sharedstatedir = $(prefix)/com
+sysconfdir = $(prefix)/etc
+datadir = $(datarootdir)
+datarootdir = $(prefix)/share
+libexecdir = $(exec_prefix)/libexec
+sbindir = $(exec_prefix)/sbin
+bindir = $(exec_prefix)/bin
+archdir = $(rubyarchdir)
+
+
+CC = gcc
+CXX = g++
+LIBRUBY = $(LIBRUBY_SO)
+LIBRUBY_A = lib$(RUBY_SO_NAME)-static.a
+LIBRUBYARG_SHARED = -Wl,-R$(libdir) -L$(libdir) -l$(RUBY_SO_NAME)
+LIBRUBYARG_STATIC = -Wl,-R$(libdir) -L$(libdir) -l$(RUBY_SO_NAME)-static
+empty =
+OUTFLAG = -o $(empty)
+COUTFLAG = -o $(empty)
+
+RUBY_EXTCONF_H = extconf.h
+cflags = $(optflags) $(debugflags) $(warnflags)
+optflags = -O3 -fno-fast-math
+debugflags = -ggdb3
+warnflags = -Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wunused-variable -Wpointer-arith -Wwrite-strings -Wdeclaration-after-statement -Wimplicit-function-declaration -Wdeprecated-declarations -Wno-packed-bitfield-compat
+CCDLFLAGS = -fPIC
+CFLAGS = $(CCDLFLAGS) $(cflags) -fPIC $(ARCH_FLAG)
+INCFLAGS = -I. -I$(arch_hdrdir) -I$(hdrdir) -I$(srcdir)
+DEFS =
+CPPFLAGS = -DRUBY_EXTCONF_H=\"$(RUBY_EXTCONF_H)\" $(DEFS) $(cppflags)
+CXXFLAGS = $(CCDLFLAGS) $(cxxflags) $(ARCH_FLAG)
+ldflags = -L. -fstack-protector -rdynamic -Wl,-export-dynamic
+dldflags =
+ARCH_FLAG =
+DLDFLAGS = $(ldflags) $(dldflags) $(ARCH_FLAG)
+LDSHARED = $(CC) -shared
+LDSHAREDXX = $(CXX) -shared
+AR = ar
+EXEEXT =
+
+RUBY_INSTALL_NAME = $(RUBY_BASE_NAME)
+RUBY_SO_NAME = ruby
+RUBYW_INSTALL_NAME =
+RUBY_VERSION_NAME = $(RUBY_BASE_NAME)-$(ruby_version)
+RUBYW_BASE_NAME = rubyw
+RUBY_BASE_NAME = ruby
+
+arch = x86_64-linux
+sitearch = $(arch)
+ruby_version = 2.2.0
+ruby = $(topdir)/miniruby -I'$(topdir)' -I'$(top_srcdir)/lib' -I'$(extout)/$(arch)' -I'$(extout)/common'
+RUBY = $(ruby)
+ruby_headers = $(hdrdir)/ruby.h $(hdrdir)/ruby/ruby.h $(hdrdir)/ruby/defines.h $(hdrdir)/ruby/missing.h $(hdrdir)/ruby/intern.h $(hdrdir)/ruby/st.h $(hdrdir)/ruby/subst.h $(arch_hdrdir)/ruby/config.h $(RUBY_EXTCONF_H)
+
+RM = rm -f
+RM_RF = $(RUBY) -run -e rm -- -rf
+RMDIRS = rmdir --ignore-fail-on-non-empty -p
+MAKEDIRS = /bin/mkdir -p
+INSTALL = /usr/bin/install -c
+INSTALL_PROG = $(INSTALL) -m 0755
+INSTALL_DATA = $(INSTALL) -m 644
+COPY = cp
+TOUCH = exit >
+
+#### End of system configuration section. ####
+
+preload =
+
+libpath = . $(topdir)
+LIBPATH = -L. -L$(topdir)
+DEFFILE =
+
+CLEANFILES = mkmf.log
+DISTCLEANFILES =
+DISTCLEANDIRS =
+
+extout = $(topdir)/.ext
+extout_prefix = $(extout)$(target_prefix)/
+target_prefix = /-test-
+LOCAL_LIBS =
+LIBS = $(LIBRUBYARG_SHARED) -lpthread -lgmp -ldl -lcrypt -lm -lc
+ORIG_SRCS = recursion.c
+SRCS = $(ORIG_SRCS)
+OBJS = recursion.o
+HDRS = $(srcdir)/extconf.h
+TARGET = recursion
+TARGET_NAME = recursion
+TARGET_ENTRY = Init_$(TARGET_NAME)
+DLLIB = $(TARGET).so
+EXTSTATIC =
+STATIC_LIB = $(TARGET).a
+
+TIMESTAMP_DIR = $(extout)/.timestamp
+BINDIR = $(extout)/bin
+RUBYCOMMONDIR = $(extout)/common
+RUBYLIBDIR = $(RUBYCOMMONDIR)$(target_prefix)
+RUBYARCHDIR = $(extout)/$(arch)$(target_prefix)
+HDRDIR = $(extout)/include/ruby$(target_prefix)
+ARCHHDRDIR = $(extout)/include/$(arch)/ruby$(target_prefix)
+
+TARGET_SO = $(RUBYARCHDIR)/$(DLLIB)
+CLEANLIBS = $(RUBYARCHDIR)/$(TARGET).so
+CLEANOBJS = *.o *.bak
+
+all: install
+static: all
+.PHONY: all install static install-so install-rb
+.PHONY: clean clean-so clean-static clean-rb
+
+clean-static::
+clean-rb-default::
+clean-rb::
+clean-so::
+clean: clean-so clean-static clean-rb-default clean-rb
+ -$(Q)$(RM) $(CLEANLIBS) $(CLEANOBJS) $(CLEANFILES) .*.time
+
+distclean-rb-default::
+distclean-rb::
+distclean-so::
+distclean-static::
+distclean: clean distclean-so distclean-static distclean-rb-default distclean-rb
+ -$(Q)$(RM) Makefile $(RUBY_EXTCONF_H) conftest.* mkmf.log
+ -$(Q)$(RM) core ruby$(EXEEXT) *~ $(DISTCLEANFILES)
+ -$(Q)$(RMDIRS) $(DISTCLEANDIRS) 2> /dev/null || true
+
+realclean: distclean
+install: install-so install-rb
+
+install-so: $(RUBYARCHDIR)/$(DLLIB)
+clean-so::
+ -$(Q)$(RM) $(RUBYARCHDIR)/$(DLLIB)
+ -$(Q)$(RMDIRS) $(RUBYARCHDIR) 2> /dev/null || true
+clean-static::
+ -$(Q)$(RM) $(STATIC_LIB)
+install-rb: pre-install-rb install-rb-default
+install-rb-default: pre-install-rb-default
+pre-install-rb: Makefile
+pre-install-rb-default: Makefile
+pre-install-rb-default:
+ @$(NULLCMD)
+$(TIMESTAMP_DIR)/.RUBYARCHDIR.-.-test-.time:
+ $(Q) $(MAKEDIRS) $(@D) $(RUBYARCHDIR)
+ $(Q) $(TOUCH) $@
+
+site-install: site-install-so site-install-rb
+site-install-so: install-so
+site-install-rb: install-rb
+
+.SUFFIXES: .c .m .cc .mm .cxx .cpp .o .S
+
+.cc.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<
+
+.cc.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -S $<
+
+.mm.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<
+
+.mm.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -S $<
+
+.cxx.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<
+
+.cxx.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -S $<
+
+.cpp.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<
+
+.cpp.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -S $<
+
+.c.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -c $<
+
+.c.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -S $<
+
+.m.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -c $<
+
+.m.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -S $<
+
+$(RUBYARCHDIR)/$(DLLIB): $(OBJS) Makefile $(TIMESTAMP_DIR)/.RUBYARCHDIR.-.-test-.time
+ $(ECHO) linking shared-object -test-/$(DLLIB)
+ -$(Q)$(RM) $(@)
+ $(Q) $(LDSHARED) -o $@ $(OBJS) $(LIBPATH) $(DLDFLAGS) $(LOCAL_LIBS) $(LIBS)
+
+$(STATIC_LIB): $(OBJS)
+ -$(Q)$(RM) $(@)
+ $(ECHO) linking static-library $(@)
+ $(Q) $(AR) cru $@ $(OBJS)
+ -$(Q)ranlib $(@) 2> /dev/null || true
+
+$(OBJS): $(HDRS) $(ruby_headers)
diff --git a/jni/ruby/ext/-test-/recursion/extconf.h b/jni/ruby/ext/-test-/recursion/extconf.h
new file mode 100644
index 0000000..cda0cc8
--- /dev/null
+++ b/jni/ruby/ext/-test-/recursion/extconf.h
@@ -0,0 +1,3 @@
+#ifndef EXTCONF_H
+#define EXTCONF_H
+#endif
diff --git a/jni/ruby/ext/-test-/recursion/extconf.rb b/jni/ruby/ext/-test-/recursion/extconf.rb
new file mode 100644
index 0000000..92b2865
--- /dev/null
+++ b/jni/ruby/ext/-test-/recursion/extconf.rb
@@ -0,0 +1,2 @@
+require 'mkmf'
+create_makefile("-test-/recursion")
diff --git a/jni/ruby/ext/-test-/recursion/recursion.c b/jni/ruby/ext/-test-/recursion/recursion.c
new file mode 100644
index 0000000..13d41f0
--- /dev/null
+++ b/jni/ruby/ext/-test-/recursion/recursion.c
@@ -0,0 +1,28 @@
+#include <ruby.h>
+
+static VALUE
+recursive_i(VALUE obj, VALUE mid, int recur)
+{
+ if (recur) return Qnil;
+ return rb_funcallv(obj, rb_to_id(mid), 0, 0);
+}
+
+static VALUE
+exec_recursive(VALUE self, VALUE mid)
+{
+ return rb_exec_recursive(recursive_i, self, mid);
+}
+
+static VALUE
+exec_recursive_outer(VALUE self, VALUE mid)
+{
+ return rb_exec_recursive_outer(recursive_i, self, mid);
+}
+
+void
+Init_recursion(void)
+{
+ VALUE m = rb_define_module_under(rb_define_module("Bug"), "Recursive");
+ rb_define_method(m, "exec_recursive", exec_recursive, 1);
+ rb_define_method(m, "exec_recursive_outer", exec_recursive_outer, 1);
+}
diff --git a/jni/ruby/ext/-test-/st/foreach/Makefile b/jni/ruby/ext/-test-/st/foreach/Makefile
new file mode 100644
index 0000000..a5f621a
--- /dev/null
+++ b/jni/ruby/ext/-test-/st/foreach/Makefile
@@ -0,0 +1,267 @@
+
+SHELL = /bin/sh
+
+# V=0 quiet, V=1 verbose. other values don't work.
+V = 0
+Q1 = $(V:1=)
+Q = $(Q1:0=@)
+ECHO1 = $(V:1=@:)
+ECHO = $(ECHO1:0=@echo)
+NULLCMD = :
+
+#### Start of system configuration section. ####
+top_srcdir = $(topdir)/.
+srcdir = $(top_srcdir)/ext/-test-/st/foreach
+topdir = ../../../..
+hdrdir = $(top_srcdir)/include
+arch_hdrdir = $(extout)/include/$(arch)
+PATH_SEPARATOR = :
+VPATH = $(srcdir):$(arch_hdrdir)/ruby:$(hdrdir)/ruby
+RUBYLIB =
+RUBYOPT = -
+prefix = $(DESTDIR)/usr/local
+rubysitearchprefix = $(rubylibprefix)/$(sitearch)
+rubyarchprefix = $(rubylibprefix)/$(arch)
+rubylibprefix = $(libdir)/$(RUBY_BASE_NAME)
+exec_prefix = $(prefix)
+vendorarchhdrdir = $(vendorhdrdir)/$(sitearch)
+sitearchhdrdir = $(sitehdrdir)/$(sitearch)
+rubyarchhdrdir = $(rubyhdrdir)/$(arch)
+vendorhdrdir = $(rubyhdrdir)/vendor_ruby
+sitehdrdir = $(rubyhdrdir)/site_ruby
+rubyhdrdir = $(includedir)/$(RUBY_VERSION_NAME)
+vendorarchdir = $(vendorlibdir)/$(sitearch)
+vendorlibdir = $(vendordir)/$(ruby_version)
+vendordir = $(rubylibprefix)/vendor_ruby
+sitearchdir = $(sitelibdir)/$(sitearch)
+sitelibdir = $(sitedir)/$(ruby_version)
+sitedir = $(rubylibprefix)/site_ruby
+rubyarchdir = $(rubylibdir)/$(arch)
+rubylibdir = $(rubylibprefix)/$(ruby_version)
+sitearchincludedir = $(includedir)/$(sitearch)
+archincludedir = $(includedir)/$(arch)
+sitearchlibdir = $(libdir)/$(sitearch)
+archlibdir = $(libdir)/$(arch)
+ridir = $(datarootdir)/$(RI_BASE_NAME)
+mandir = $(datarootdir)/man
+localedir = $(datarootdir)/locale
+libdir = $(exec_prefix)/lib
+psdir = $(docdir)
+pdfdir = $(docdir)
+dvidir = $(docdir)
+htmldir = $(docdir)
+infodir = $(datarootdir)/info
+docdir = $(datarootdir)/doc/$(PACKAGE)
+oldincludedir = $(DESTDIR)/usr/include
+includedir = $(prefix)/include
+localstatedir = $(prefix)/var
+sharedstatedir = $(prefix)/com
+sysconfdir = $(prefix)/etc
+datadir = $(datarootdir)
+datarootdir = $(prefix)/share
+libexecdir = $(exec_prefix)/libexec
+sbindir = $(exec_prefix)/sbin
+bindir = $(exec_prefix)/bin
+archdir = $(rubyarchdir)
+
+
+CC = gcc
+CXX = g++
+LIBRUBY = $(LIBRUBY_SO)
+LIBRUBY_A = lib$(RUBY_SO_NAME)-static.a
+LIBRUBYARG_SHARED = -Wl,-R$(libdir) -L$(libdir) -l$(RUBY_SO_NAME)
+LIBRUBYARG_STATIC = -Wl,-R$(libdir) -L$(libdir) -l$(RUBY_SO_NAME)-static
+empty =
+OUTFLAG = -o $(empty)
+COUTFLAG = -o $(empty)
+
+RUBY_EXTCONF_H = extconf.h
+cflags = $(optflags) $(debugflags) $(warnflags)
+optflags = -O3 -fno-fast-math
+debugflags = -ggdb3
+warnflags = -Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wunused-variable -Wpointer-arith -Wwrite-strings -Wdeclaration-after-statement -Wimplicit-function-declaration -Wdeprecated-declarations -Wno-packed-bitfield-compat
+CCDLFLAGS = -fPIC
+CFLAGS = $(CCDLFLAGS) $(cflags) -fPIC $(ARCH_FLAG)
+INCFLAGS = -I. -I$(arch_hdrdir) -I$(hdrdir) -I$(srcdir)
+DEFS =
+CPPFLAGS = -DRUBY_EXTCONF_H=\"$(RUBY_EXTCONF_H)\" $(DEFS) $(cppflags)
+CXXFLAGS = $(CCDLFLAGS) $(cxxflags) $(ARCH_FLAG)
+ldflags = -L. -fstack-protector -rdynamic -Wl,-export-dynamic
+dldflags =
+ARCH_FLAG =
+DLDFLAGS = $(ldflags) $(dldflags) $(ARCH_FLAG)
+LDSHARED = $(CC) -shared
+LDSHAREDXX = $(CXX) -shared
+AR = ar
+EXEEXT =
+
+RUBY_INSTALL_NAME = $(RUBY_BASE_NAME)
+RUBY_SO_NAME = ruby
+RUBYW_INSTALL_NAME =
+RUBY_VERSION_NAME = $(RUBY_BASE_NAME)-$(ruby_version)
+RUBYW_BASE_NAME = rubyw
+RUBY_BASE_NAME = ruby
+
+arch = x86_64-linux
+sitearch = $(arch)
+ruby_version = 2.2.0
+ruby = $(topdir)/miniruby -I'$(topdir)' -I'$(top_srcdir)/lib' -I'$(extout)/$(arch)' -I'$(extout)/common'
+RUBY = $(ruby)
+ruby_headers = $(hdrdir)/ruby.h $(hdrdir)/ruby/ruby.h $(hdrdir)/ruby/defines.h $(hdrdir)/ruby/missing.h $(hdrdir)/ruby/intern.h $(hdrdir)/ruby/st.h $(hdrdir)/ruby/subst.h $(arch_hdrdir)/ruby/config.h $(RUBY_EXTCONF_H)
+
+RM = rm -f
+RM_RF = $(RUBY) -run -e rm -- -rf
+RMDIRS = rmdir --ignore-fail-on-non-empty -p
+MAKEDIRS = /bin/mkdir -p
+INSTALL = /usr/bin/install -c
+INSTALL_PROG = $(INSTALL) -m 0755
+INSTALL_DATA = $(INSTALL) -m 644
+COPY = cp
+TOUCH = exit >
+
+#### End of system configuration section. ####
+
+preload =
+
+libpath = . $(topdir)
+LIBPATH = -L. -L$(topdir)
+DEFFILE =
+
+CLEANFILES = mkmf.log
+DISTCLEANFILES =
+DISTCLEANDIRS =
+
+extout = $(topdir)/.ext
+extout_prefix = $(extout)$(target_prefix)/
+target_prefix = /-test-/st
+LOCAL_LIBS =
+LIBS = $(LIBRUBYARG_SHARED) -lpthread -lgmp -ldl -lcrypt -lm -lc
+ORIG_SRCS = foreach.c
+SRCS = $(ORIG_SRCS)
+OBJS = foreach.o
+HDRS = $(srcdir)/extconf.h
+TARGET = foreach
+TARGET_NAME = foreach
+TARGET_ENTRY = Init_$(TARGET_NAME)
+DLLIB = $(TARGET).so
+EXTSTATIC =
+STATIC_LIB = $(TARGET).a
+
+TIMESTAMP_DIR = $(extout)/.timestamp
+BINDIR = $(extout)/bin
+RUBYCOMMONDIR = $(extout)/common
+RUBYLIBDIR = $(RUBYCOMMONDIR)$(target_prefix)
+RUBYARCHDIR = $(extout)/$(arch)$(target_prefix)
+HDRDIR = $(extout)/include/ruby$(target_prefix)
+ARCHHDRDIR = $(extout)/include/$(arch)/ruby$(target_prefix)
+
+TARGET_SO = $(RUBYARCHDIR)/$(DLLIB)
+CLEANLIBS = $(RUBYARCHDIR)/$(TARGET).so
+CLEANOBJS = *.o *.bak
+
+all: install
+static: all
+.PHONY: all install static install-so install-rb
+.PHONY: clean clean-so clean-static clean-rb
+
+clean-static::
+clean-rb-default::
+clean-rb::
+clean-so::
+clean: clean-so clean-static clean-rb-default clean-rb
+ -$(Q)$(RM) $(CLEANLIBS) $(CLEANOBJS) $(CLEANFILES) .*.time
+
+distclean-rb-default::
+distclean-rb::
+distclean-so::
+distclean-static::
+distclean: clean distclean-so distclean-static distclean-rb-default distclean-rb
+ -$(Q)$(RM) Makefile $(RUBY_EXTCONF_H) conftest.* mkmf.log
+ -$(Q)$(RM) core ruby$(EXEEXT) *~ $(DISTCLEANFILES)
+ -$(Q)$(RMDIRS) $(DISTCLEANDIRS) 2> /dev/null || true
+
+realclean: distclean
+install: install-so install-rb
+
+install-so: $(RUBYARCHDIR)/$(DLLIB)
+clean-so::
+ -$(Q)$(RM) $(RUBYARCHDIR)/$(DLLIB)
+ -$(Q)$(RMDIRS) $(RUBYARCHDIR) 2> /dev/null || true
+clean-static::
+ -$(Q)$(RM) $(STATIC_LIB)
+install-rb: pre-install-rb install-rb-default
+install-rb-default: pre-install-rb-default
+pre-install-rb: Makefile
+pre-install-rb-default: Makefile
+pre-install-rb-default:
+ @$(NULLCMD)
+$(TIMESTAMP_DIR)/.RUBYARCHDIR.-.-test-.-.st.time:
+ $(Q) $(MAKEDIRS) $(@D) $(RUBYARCHDIR)
+ $(Q) $(TOUCH) $@
+
+site-install: site-install-so site-install-rb
+site-install-so: install-so
+site-install-rb: install-rb
+
+.SUFFIXES: .c .m .cc .mm .cxx .cpp .o .S
+
+.cc.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<
+
+.cc.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -S $<
+
+.mm.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<
+
+.mm.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -S $<
+
+.cxx.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<
+
+.cxx.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -S $<
+
+.cpp.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<
+
+.cpp.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -S $<
+
+.c.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -c $<
+
+.c.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -S $<
+
+.m.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -c $<
+
+.m.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -S $<
+
+$(RUBYARCHDIR)/$(DLLIB): $(OBJS) Makefile $(TIMESTAMP_DIR)/.RUBYARCHDIR.-.-test-.-.st.time
+ $(ECHO) linking shared-object -test-/st/$(DLLIB)
+ -$(Q)$(RM) $(@)
+ $(Q) $(LDSHARED) -o $@ $(OBJS) $(LIBPATH) $(DLDFLAGS) $(LOCAL_LIBS) $(LIBS)
+
+$(STATIC_LIB): $(OBJS)
+ -$(Q)$(RM) $(@)
+ $(ECHO) linking static-library $(@)
+ $(Q) $(AR) cru $@ $(OBJS)
+ -$(Q)ranlib $(@) 2> /dev/null || true
+
+$(OBJS): $(HDRS) $(ruby_headers)
diff --git a/jni/ruby/ext/-test-/st/foreach/extconf.h b/jni/ruby/ext/-test-/st/foreach/extconf.h
new file mode 100644
index 0000000..cda0cc8
--- /dev/null
+++ b/jni/ruby/ext/-test-/st/foreach/extconf.h
@@ -0,0 +1,3 @@
+#ifndef EXTCONF_H
+#define EXTCONF_H
+#endif
diff --git a/jni/ruby/ext/-test-/st/foreach/extconf.rb b/jni/ruby/ext/-test-/st/foreach/extconf.rb
new file mode 100644
index 0000000..969f386
--- /dev/null
+++ b/jni/ruby/ext/-test-/st/foreach/extconf.rb
@@ -0,0 +1 @@
+create_makefile("-test-/st/foreach")
diff --git a/jni/ruby/ext/-test-/st/foreach/foreach.c b/jni/ruby/ext/-test-/st/foreach/foreach.c
new file mode 100644
index 0000000..1e0fd51
--- /dev/null
+++ b/jni/ruby/ext/-test-/st/foreach/foreach.c
@@ -0,0 +1,175 @@
+#include <ruby.h>
+#include <ruby/st.h>
+
+static st_data_t expect_size = 32;
+struct checker {
+ st_table *tbl;
+ st_index_t nr;
+ VALUE test;
+};
+
+static void
+force_unpack_check(struct checker *c, st_data_t key, st_data_t val)
+{
+ if (c->nr == 0) {
+ st_data_t i;
+
+ if (!c->tbl->entries_packed) rb_bug("should be packed\n");
+
+ /* force unpacking during iteration: */
+ for (i = 1; i < expect_size; i++)
+ st_add_direct(c->tbl, i, i);
+
+ if (c->tbl->entries_packed) rb_bug("should be unpacked\n");
+ }
+
+ if (key != c->nr) {
+ rb_bug("unexpected key: %"PRIuVALUE" (expected %"PRIuVALUE")\n", (VALUE)key, (VALUE)c->nr);
+ }
+ if (val != c->nr) {
+ rb_bug("unexpected val: %"PRIuVALUE" (expected %"PRIuVALUE")\n", (VALUE)val, (VALUE)c->nr);
+ }
+
+ c->nr++;
+}
+
+static int
+unp_fec_i(st_data_t key, st_data_t val, st_data_t args, int error)
+{
+ struct checker *c = (struct checker *)args;
+
+ if (error) {
+ if (c->test == ID2SYM(rb_intern("delete2")))
+ return ST_STOP;
+
+ rb_bug("unexpected error");
+ }
+
+ force_unpack_check(c, key, val);
+
+ if (c->test == ID2SYM(rb_intern("check"))) {
+ return ST_CHECK;
+ }
+ if (c->test == ID2SYM(rb_intern("delete1"))) {
+ if (c->nr == 1) return ST_DELETE;
+ return ST_CHECK;
+ }
+ if (c->test == ID2SYM(rb_intern("delete2"))) {
+ if (c->nr == 1) {
+ st_data_t k = 0;
+ st_data_t v;
+
+ if (!st_delete(c->tbl, &k, &v)) {
+ rb_bug("failed to delete\n");
+ }
+ if (v != 0) {
+ rb_bug("unexpected value deleted: %"PRIuVALUE" (expected 0)", (VALUE)v);
+ }
+ }
+ return ST_CHECK;
+ }
+
+ rb_raise(rb_eArgError, "unexpected arg: %+"PRIsVALUE, c->test);
+}
+
+static VALUE
+unp_fec(VALUE self, VALUE test)
+{
+ st_table *tbl = st_init_numtable();
+ struct checker c;
+
+ c.tbl = tbl;
+ c.nr = 0;
+ c.test = test;
+
+ st_add_direct(tbl, 0, 0);
+
+ if (!tbl->entries_packed) rb_bug("should still be packed\n");
+
+ st_foreach_check(tbl, unp_fec_i, (st_data_t)&c, -1);
+
+ if (c.test == ID2SYM(rb_intern("delete2"))) {
+ if (c.nr != 1) {
+ rb_bug("mismatched iteration: %"PRIuVALUE" (expected 1)\n", (VALUE)c.nr);
+ }
+ }
+ else if (c.nr != expect_size) {
+ rb_bug("mismatched iteration: %"PRIuVALUE" (expected %"PRIuVALUE")\n",
+ (VALUE)c.nr, (VALUE)expect_size);
+ }
+
+ if (tbl->entries_packed) rb_bug("should be unpacked\n");
+
+ st_free_table(tbl);
+
+ return Qnil;
+}
+
+static int
+unp_fe_i(st_data_t key, st_data_t val, st_data_t args, int error)
+{
+ struct checker *c = (struct checker *)args;
+
+ force_unpack_check(c, key, val);
+ if (c->test == ID2SYM(rb_intern("unpacked"))) {
+ return ST_CONTINUE;
+ }
+ else if (c->test == ID2SYM(rb_intern("unpack_delete"))) {
+ if (c->nr == 1) {
+ st_data_t k = 0;
+ st_data_t v;
+
+ if (!st_delete(c->tbl, &k, &v)) {
+ rb_bug("failed to delete\n");
+ }
+ if (v != 0) {
+ rb_bug("unexpected value deleted: %"PRIuVALUE" (expected 0)", (VALUE)v);
+ }
+ return ST_CONTINUE;
+ }
+ rb_bug("should never get here\n");
+ }
+
+ rb_raise(rb_eArgError, "unexpected arg: %+"PRIsVALUE, c->test);
+}
+
+static VALUE
+unp_fe(VALUE self, VALUE test)
+{
+ st_table *tbl = st_init_numtable();
+ struct checker c;
+
+ c.tbl = tbl;
+ c.nr = 0;
+ c.test = test;
+
+ st_add_direct(tbl, 0, 0);
+
+ if (!tbl->entries_packed) rb_bug("should still be packed\n");
+
+ st_foreach(tbl, unp_fe_i, (st_data_t)&c);
+
+ if (c.test == ID2SYM(rb_intern("unpack_delete"))) {
+ if (c.nr != 1) {
+ rb_bug("mismatched iteration: %"PRIuVALUE" (expected 1)\n", (VALUE)c.nr);
+ }
+ }
+ else if (c.nr != expect_size) {
+ rb_bug("mismatched iteration: %"PRIuVALUE" (expected %"PRIuVALUE"o)\n",
+ (VALUE)c.nr, (VALUE)expect_size);
+ }
+
+ if (tbl->entries_packed) rb_bug("should be unpacked\n");
+
+ st_free_table(tbl);
+
+ return Qnil;
+}
+
+void
+Init_foreach(void)
+{
+ VALUE bug = rb_define_module("Bug");
+ rb_define_singleton_method(bug, "unp_st_foreach_check", unp_fec, 1);
+ rb_define_singleton_method(bug, "unp_st_foreach", unp_fe, 1);
+}
diff --git a/jni/ruby/ext/-test-/st/numhash/Makefile b/jni/ruby/ext/-test-/st/numhash/Makefile
new file mode 100644
index 0000000..a21990a
--- /dev/null
+++ b/jni/ruby/ext/-test-/st/numhash/Makefile
@@ -0,0 +1,267 @@
+
+SHELL = /bin/sh
+
+# V=0 quiet, V=1 verbose. other values don't work.
+V = 0
+Q1 = $(V:1=)
+Q = $(Q1:0=@)
+ECHO1 = $(V:1=@:)
+ECHO = $(ECHO1:0=@echo)
+NULLCMD = :
+
+#### Start of system configuration section. ####
+top_srcdir = $(topdir)/.
+srcdir = $(top_srcdir)/ext/-test-/st/numhash
+topdir = ../../../..
+hdrdir = $(top_srcdir)/include
+arch_hdrdir = $(extout)/include/$(arch)
+PATH_SEPARATOR = :
+VPATH = $(srcdir):$(arch_hdrdir)/ruby:$(hdrdir)/ruby
+RUBYLIB =
+RUBYOPT = -
+prefix = $(DESTDIR)/usr/local
+rubysitearchprefix = $(rubylibprefix)/$(sitearch)
+rubyarchprefix = $(rubylibprefix)/$(arch)
+rubylibprefix = $(libdir)/$(RUBY_BASE_NAME)
+exec_prefix = $(prefix)
+vendorarchhdrdir = $(vendorhdrdir)/$(sitearch)
+sitearchhdrdir = $(sitehdrdir)/$(sitearch)
+rubyarchhdrdir = $(rubyhdrdir)/$(arch)
+vendorhdrdir = $(rubyhdrdir)/vendor_ruby
+sitehdrdir = $(rubyhdrdir)/site_ruby
+rubyhdrdir = $(includedir)/$(RUBY_VERSION_NAME)
+vendorarchdir = $(vendorlibdir)/$(sitearch)
+vendorlibdir = $(vendordir)/$(ruby_version)
+vendordir = $(rubylibprefix)/vendor_ruby
+sitearchdir = $(sitelibdir)/$(sitearch)
+sitelibdir = $(sitedir)/$(ruby_version)
+sitedir = $(rubylibprefix)/site_ruby
+rubyarchdir = $(rubylibdir)/$(arch)
+rubylibdir = $(rubylibprefix)/$(ruby_version)
+sitearchincludedir = $(includedir)/$(sitearch)
+archincludedir = $(includedir)/$(arch)
+sitearchlibdir = $(libdir)/$(sitearch)
+archlibdir = $(libdir)/$(arch)
+ridir = $(datarootdir)/$(RI_BASE_NAME)
+mandir = $(datarootdir)/man
+localedir = $(datarootdir)/locale
+libdir = $(exec_prefix)/lib
+psdir = $(docdir)
+pdfdir = $(docdir)
+dvidir = $(docdir)
+htmldir = $(docdir)
+infodir = $(datarootdir)/info
+docdir = $(datarootdir)/doc/$(PACKAGE)
+oldincludedir = $(DESTDIR)/usr/include
+includedir = $(prefix)/include
+localstatedir = $(prefix)/var
+sharedstatedir = $(prefix)/com
+sysconfdir = $(prefix)/etc
+datadir = $(datarootdir)
+datarootdir = $(prefix)/share
+libexecdir = $(exec_prefix)/libexec
+sbindir = $(exec_prefix)/sbin
+bindir = $(exec_prefix)/bin
+archdir = $(rubyarchdir)
+
+
+CC = gcc
+CXX = g++
+LIBRUBY = $(LIBRUBY_SO)
+LIBRUBY_A = lib$(RUBY_SO_NAME)-static.a
+LIBRUBYARG_SHARED = -Wl,-R$(libdir) -L$(libdir) -l$(RUBY_SO_NAME)
+LIBRUBYARG_STATIC = -Wl,-R$(libdir) -L$(libdir) -l$(RUBY_SO_NAME)-static
+empty =
+OUTFLAG = -o $(empty)
+COUTFLAG = -o $(empty)
+
+RUBY_EXTCONF_H = extconf.h
+cflags = $(optflags) $(debugflags) $(warnflags)
+optflags = -O3 -fno-fast-math
+debugflags = -ggdb3
+warnflags = -Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wunused-variable -Wpointer-arith -Wwrite-strings -Wdeclaration-after-statement -Wimplicit-function-declaration -Wdeprecated-declarations -Wno-packed-bitfield-compat
+CCDLFLAGS = -fPIC
+CFLAGS = $(CCDLFLAGS) $(cflags) -fPIC $(ARCH_FLAG)
+INCFLAGS = -I. -I$(arch_hdrdir) -I$(hdrdir) -I$(srcdir)
+DEFS =
+CPPFLAGS = -DRUBY_EXTCONF_H=\"$(RUBY_EXTCONF_H)\" $(DEFS) $(cppflags)
+CXXFLAGS = $(CCDLFLAGS) $(cxxflags) $(ARCH_FLAG)
+ldflags = -L. -fstack-protector -rdynamic -Wl,-export-dynamic
+dldflags =
+ARCH_FLAG =
+DLDFLAGS = $(ldflags) $(dldflags) $(ARCH_FLAG)
+LDSHARED = $(CC) -shared
+LDSHAREDXX = $(CXX) -shared
+AR = ar
+EXEEXT =
+
+RUBY_INSTALL_NAME = $(RUBY_BASE_NAME)
+RUBY_SO_NAME = ruby
+RUBYW_INSTALL_NAME =
+RUBY_VERSION_NAME = $(RUBY_BASE_NAME)-$(ruby_version)
+RUBYW_BASE_NAME = rubyw
+RUBY_BASE_NAME = ruby
+
+arch = x86_64-linux
+sitearch = $(arch)
+ruby_version = 2.2.0
+ruby = $(topdir)/miniruby -I'$(topdir)' -I'$(top_srcdir)/lib' -I'$(extout)/$(arch)' -I'$(extout)/common'
+RUBY = $(ruby)
+ruby_headers = $(hdrdir)/ruby.h $(hdrdir)/ruby/ruby.h $(hdrdir)/ruby/defines.h $(hdrdir)/ruby/missing.h $(hdrdir)/ruby/intern.h $(hdrdir)/ruby/st.h $(hdrdir)/ruby/subst.h $(arch_hdrdir)/ruby/config.h $(RUBY_EXTCONF_H)
+
+RM = rm -f
+RM_RF = $(RUBY) -run -e rm -- -rf
+RMDIRS = rmdir --ignore-fail-on-non-empty -p
+MAKEDIRS = /bin/mkdir -p
+INSTALL = /usr/bin/install -c
+INSTALL_PROG = $(INSTALL) -m 0755
+INSTALL_DATA = $(INSTALL) -m 644
+COPY = cp
+TOUCH = exit >
+
+#### End of system configuration section. ####
+
+preload =
+
+libpath = . $(topdir)
+LIBPATH = -L. -L$(topdir)
+DEFFILE =
+
+CLEANFILES = mkmf.log
+DISTCLEANFILES =
+DISTCLEANDIRS =
+
+extout = $(topdir)/.ext
+extout_prefix = $(extout)$(target_prefix)/
+target_prefix = /-test-/st
+LOCAL_LIBS =
+LIBS = $(LIBRUBYARG_SHARED) -lpthread -lgmp -ldl -lcrypt -lm -lc
+ORIG_SRCS = numhash.c
+SRCS = $(ORIG_SRCS)
+OBJS = numhash.o
+HDRS = $(srcdir)/extconf.h
+TARGET = numhash
+TARGET_NAME = numhash
+TARGET_ENTRY = Init_$(TARGET_NAME)
+DLLIB = $(TARGET).so
+EXTSTATIC =
+STATIC_LIB = $(TARGET).a
+
+TIMESTAMP_DIR = $(extout)/.timestamp
+BINDIR = $(extout)/bin
+RUBYCOMMONDIR = $(extout)/common
+RUBYLIBDIR = $(RUBYCOMMONDIR)$(target_prefix)
+RUBYARCHDIR = $(extout)/$(arch)$(target_prefix)
+HDRDIR = $(extout)/include/ruby$(target_prefix)
+ARCHHDRDIR = $(extout)/include/$(arch)/ruby$(target_prefix)
+
+TARGET_SO = $(RUBYARCHDIR)/$(DLLIB)
+CLEANLIBS = $(RUBYARCHDIR)/$(TARGET).so
+CLEANOBJS = *.o *.bak
+
+all: install
+static: all
+.PHONY: all install static install-so install-rb
+.PHONY: clean clean-so clean-static clean-rb
+
+clean-static::
+clean-rb-default::
+clean-rb::
+clean-so::
+clean: clean-so clean-static clean-rb-default clean-rb
+ -$(Q)$(RM) $(CLEANLIBS) $(CLEANOBJS) $(CLEANFILES) .*.time
+
+distclean-rb-default::
+distclean-rb::
+distclean-so::
+distclean-static::
+distclean: clean distclean-so distclean-static distclean-rb-default distclean-rb
+ -$(Q)$(RM) Makefile $(RUBY_EXTCONF_H) conftest.* mkmf.log
+ -$(Q)$(RM) core ruby$(EXEEXT) *~ $(DISTCLEANFILES)
+ -$(Q)$(RMDIRS) $(DISTCLEANDIRS) 2> /dev/null || true
+
+realclean: distclean
+install: install-so install-rb
+
+install-so: $(RUBYARCHDIR)/$(DLLIB)
+clean-so::
+ -$(Q)$(RM) $(RUBYARCHDIR)/$(DLLIB)
+ -$(Q)$(RMDIRS) $(RUBYARCHDIR) 2> /dev/null || true
+clean-static::
+ -$(Q)$(RM) $(STATIC_LIB)
+install-rb: pre-install-rb install-rb-default
+install-rb-default: pre-install-rb-default
+pre-install-rb: Makefile
+pre-install-rb-default: Makefile
+pre-install-rb-default:
+ @$(NULLCMD)
+$(TIMESTAMP_DIR)/.RUBYARCHDIR.-.-test-.-.st.time:
+ $(Q) $(MAKEDIRS) $(@D) $(RUBYARCHDIR)
+ $(Q) $(TOUCH) $@
+
+site-install: site-install-so site-install-rb
+site-install-so: install-so
+site-install-rb: install-rb
+
+.SUFFIXES: .c .m .cc .mm .cxx .cpp .o .S
+
+.cc.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<
+
+.cc.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -S $<
+
+.mm.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<
+
+.mm.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -S $<
+
+.cxx.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<
+
+.cxx.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -S $<
+
+.cpp.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<
+
+.cpp.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -S $<
+
+.c.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -c $<
+
+.c.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -S $<
+
+.m.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -c $<
+
+.m.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -S $<
+
+$(RUBYARCHDIR)/$(DLLIB): $(OBJS) Makefile $(TIMESTAMP_DIR)/.RUBYARCHDIR.-.-test-.-.st.time
+ $(ECHO) linking shared-object -test-/st/$(DLLIB)
+ -$(Q)$(RM) $(@)
+ $(Q) $(LDSHARED) -o $@ $(OBJS) $(LIBPATH) $(DLDFLAGS) $(LOCAL_LIBS) $(LIBS)
+
+$(STATIC_LIB): $(OBJS)
+ -$(Q)$(RM) $(@)
+ $(ECHO) linking static-library $(@)
+ $(Q) $(AR) cru $@ $(OBJS)
+ -$(Q)ranlib $(@) 2> /dev/null || true
+
+$(OBJS): $(HDRS) $(ruby_headers)
diff --git a/jni/ruby/ext/-test-/st/numhash/extconf.h b/jni/ruby/ext/-test-/st/numhash/extconf.h
new file mode 100644
index 0000000..cda0cc8
--- /dev/null
+++ b/jni/ruby/ext/-test-/st/numhash/extconf.h
@@ -0,0 +1,3 @@
+#ifndef EXTCONF_H
+#define EXTCONF_H
+#endif
diff --git a/jni/ruby/ext/-test-/st/numhash/extconf.rb b/jni/ruby/ext/-test-/st/numhash/extconf.rb
new file mode 100644
index 0000000..867fd75
--- /dev/null
+++ b/jni/ruby/ext/-test-/st/numhash/extconf.rb
@@ -0,0 +1 @@
+create_makefile("-test-/st/numhash")
diff --git a/jni/ruby/ext/-test-/st/numhash/numhash.c b/jni/ruby/ext/-test-/st/numhash/numhash.c
new file mode 100644
index 0000000..e033886
--- /dev/null
+++ b/jni/ruby/ext/-test-/st/numhash/numhash.c
@@ -0,0 +1,138 @@
+#include <ruby.h>
+#include <ruby/st.h>
+
+static void
+numhash_free(void *ptr)
+{
+ if (ptr) st_free_table(ptr);
+}
+
+static size_t
+numhash_memsize(const void *ptr)
+{
+ return ptr ? st_memsize(ptr) : 0;
+}
+
+static const rb_data_type_t numhash_type = {
+ "numhash",
+ {0, numhash_free, numhash_memsize,},
+ 0, 0,
+ RUBY_TYPED_FREE_IMMEDIATELY|RUBY_TYPED_WB_PROTECTED,
+};
+
+static VALUE
+numhash_alloc(VALUE klass)
+{
+ return TypedData_Wrap_Struct(klass, &numhash_type, 0);
+}
+
+static VALUE
+numhash_init(VALUE self)
+{
+ st_table *tbl = (st_table *)Check_TypedStruct(self, &numhash_type);
+ if (tbl) st_free_table(tbl);
+ DATA_PTR(self) = st_init_numtable();
+ return self;
+}
+
+static VALUE
+numhash_aref(VALUE self, VALUE key)
+{
+ st_data_t data;
+ st_table *tbl = (st_table *)Check_TypedStruct(self, &numhash_type);
+ if (!SPECIAL_CONST_P(key)) rb_raise(rb_eArgError, "not a special const");
+ if (st_lookup(tbl, (st_data_t)key, &data))
+ return (VALUE)data;
+ return Qnil;
+}
+
+static VALUE
+numhash_aset(VALUE self, VALUE key, VALUE data)
+{
+ st_table *tbl = (st_table *)Check_TypedStruct(self, &numhash_type);
+ if (!SPECIAL_CONST_P(key)) rb_raise(rb_eArgError, "not a special const");
+ if (!SPECIAL_CONST_P(data)) rb_raise(rb_eArgError, "not a special const");
+ st_insert(tbl, (st_data_t)key, (st_data_t)data);
+ return self;
+}
+
+static int
+numhash_i(st_data_t key, st_data_t value, st_data_t arg)
+{
+ VALUE ret;
+ ret = rb_yield_values(3, (VALUE)key, (VALUE)value, (VALUE)arg);
+ if (ret == Qtrue) return ST_CHECK;
+ return ST_CONTINUE;
+}
+
+static VALUE
+numhash_each(VALUE self)
+{
+ st_table *table = (st_table *)Check_TypedStruct(self, &numhash_type);
+ st_data_t data = (st_data_t)self;
+ return st_foreach_check(table, numhash_i, data, data) ? Qtrue : Qfalse;
+}
+
+static int
+update_func(st_data_t *key, st_data_t *value, st_data_t arg, int existing)
+{
+ VALUE ret = rb_yield_values(existing ? 2 : 1, (VALUE)*key, (VALUE)*value);
+ switch (ret) {
+ case Qfalse:
+ return ST_STOP;
+ case Qnil:
+ return ST_DELETE;
+ default:
+ *value = ret;
+ return ST_CONTINUE;
+ }
+}
+
+static VALUE
+numhash_update(VALUE self, VALUE key)
+{
+ st_table *table = (st_table *)Check_TypedStruct(self, &numhash_type);
+ if (st_update(table, (st_data_t)key, update_func, 0))
+ return Qtrue;
+ else
+ return Qfalse;
+}
+
+#if SIZEOF_LONG == SIZEOF_VOIDP
+# define ST2NUM(x) ULONG2NUM(x)
+#elif SIZEOF_LONG_LONG == SIZEOF_VOIDP
+# define ST2NUM(x) ULL2NUM(x)
+#endif
+
+static VALUE
+numhash_size(VALUE self)
+{
+ st_table *table = (st_table *)Check_TypedStruct(self, &numhash_type);
+ return ST2NUM(table->num_entries);
+}
+
+static VALUE
+numhash_delete_safe(VALUE self, VALUE key)
+{
+ st_table *table = (st_table *)Check_TypedStruct(self, &numhash_type);
+ st_data_t val, k = (st_data_t)key;
+ if (st_delete_safe(table, &k, &val, (st_data_t)self)) {
+ return val;
+ }
+ return Qnil;
+}
+
+void
+Init_numhash(void)
+{
+ VALUE st = rb_define_class_under(rb_define_module("Bug"), "StNumHash", rb_cData);
+ rb_define_alloc_func(st, numhash_alloc);
+ rb_define_method(st, "initialize", numhash_init, 0);
+ rb_define_method(st, "[]", numhash_aref, 1);
+ rb_define_method(st, "[]=", numhash_aset, 2);
+ rb_define_method(st, "each", numhash_each, 0);
+ rb_define_method(st, "update", numhash_update, 1);
+ rb_define_method(st, "size", numhash_size, 0);
+ rb_define_method(st, "delete_safe", numhash_delete_safe, 1);
+}
+
diff --git a/jni/ruby/ext/-test-/st/update/Makefile b/jni/ruby/ext/-test-/st/update/Makefile
new file mode 100644
index 0000000..c421f32
--- /dev/null
+++ b/jni/ruby/ext/-test-/st/update/Makefile
@@ -0,0 +1,267 @@
+
+SHELL = /bin/sh
+
+# V=0 quiet, V=1 verbose. other values don't work.
+V = 0
+Q1 = $(V:1=)
+Q = $(Q1:0=@)
+ECHO1 = $(V:1=@:)
+ECHO = $(ECHO1:0=@echo)
+NULLCMD = :
+
+#### Start of system configuration section. ####
+top_srcdir = $(topdir)/.
+srcdir = $(top_srcdir)/ext/-test-/st/update
+topdir = ../../../..
+hdrdir = $(top_srcdir)/include
+arch_hdrdir = $(extout)/include/$(arch)
+PATH_SEPARATOR = :
+VPATH = $(srcdir):$(arch_hdrdir)/ruby:$(hdrdir)/ruby
+RUBYLIB =
+RUBYOPT = -
+prefix = $(DESTDIR)/usr/local
+rubysitearchprefix = $(rubylibprefix)/$(sitearch)
+rubyarchprefix = $(rubylibprefix)/$(arch)
+rubylibprefix = $(libdir)/$(RUBY_BASE_NAME)
+exec_prefix = $(prefix)
+vendorarchhdrdir = $(vendorhdrdir)/$(sitearch)
+sitearchhdrdir = $(sitehdrdir)/$(sitearch)
+rubyarchhdrdir = $(rubyhdrdir)/$(arch)
+vendorhdrdir = $(rubyhdrdir)/vendor_ruby
+sitehdrdir = $(rubyhdrdir)/site_ruby
+rubyhdrdir = $(includedir)/$(RUBY_VERSION_NAME)
+vendorarchdir = $(vendorlibdir)/$(sitearch)
+vendorlibdir = $(vendordir)/$(ruby_version)
+vendordir = $(rubylibprefix)/vendor_ruby
+sitearchdir = $(sitelibdir)/$(sitearch)
+sitelibdir = $(sitedir)/$(ruby_version)
+sitedir = $(rubylibprefix)/site_ruby
+rubyarchdir = $(rubylibdir)/$(arch)
+rubylibdir = $(rubylibprefix)/$(ruby_version)
+sitearchincludedir = $(includedir)/$(sitearch)
+archincludedir = $(includedir)/$(arch)
+sitearchlibdir = $(libdir)/$(sitearch)
+archlibdir = $(libdir)/$(arch)
+ridir = $(datarootdir)/$(RI_BASE_NAME)
+mandir = $(datarootdir)/man
+localedir = $(datarootdir)/locale
+libdir = $(exec_prefix)/lib
+psdir = $(docdir)
+pdfdir = $(docdir)
+dvidir = $(docdir)
+htmldir = $(docdir)
+infodir = $(datarootdir)/info
+docdir = $(datarootdir)/doc/$(PACKAGE)
+oldincludedir = $(DESTDIR)/usr/include
+includedir = $(prefix)/include
+localstatedir = $(prefix)/var
+sharedstatedir = $(prefix)/com
+sysconfdir = $(prefix)/etc
+datadir = $(datarootdir)
+datarootdir = $(prefix)/share
+libexecdir = $(exec_prefix)/libexec
+sbindir = $(exec_prefix)/sbin
+bindir = $(exec_prefix)/bin
+archdir = $(rubyarchdir)
+
+
+CC = gcc
+CXX = g++
+LIBRUBY = $(LIBRUBY_SO)
+LIBRUBY_A = lib$(RUBY_SO_NAME)-static.a
+LIBRUBYARG_SHARED = -Wl,-R$(libdir) -L$(libdir) -l$(RUBY_SO_NAME)
+LIBRUBYARG_STATIC = -Wl,-R$(libdir) -L$(libdir) -l$(RUBY_SO_NAME)-static
+empty =
+OUTFLAG = -o $(empty)
+COUTFLAG = -o $(empty)
+
+RUBY_EXTCONF_H = extconf.h
+cflags = $(optflags) $(debugflags) $(warnflags)
+optflags = -O3 -fno-fast-math
+debugflags = -ggdb3
+warnflags = -Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wunused-variable -Wpointer-arith -Wwrite-strings -Wdeclaration-after-statement -Wimplicit-function-declaration -Wdeprecated-declarations -Wno-packed-bitfield-compat
+CCDLFLAGS = -fPIC
+CFLAGS = $(CCDLFLAGS) $(cflags) -fPIC $(ARCH_FLAG)
+INCFLAGS = -I. -I$(arch_hdrdir) -I$(hdrdir) -I$(srcdir)
+DEFS =
+CPPFLAGS = -DRUBY_EXTCONF_H=\"$(RUBY_EXTCONF_H)\" $(DEFS) $(cppflags)
+CXXFLAGS = $(CCDLFLAGS) $(cxxflags) $(ARCH_FLAG)
+ldflags = -L. -fstack-protector -rdynamic -Wl,-export-dynamic
+dldflags =
+ARCH_FLAG =
+DLDFLAGS = $(ldflags) $(dldflags) $(ARCH_FLAG)
+LDSHARED = $(CC) -shared
+LDSHAREDXX = $(CXX) -shared
+AR = ar
+EXEEXT =
+
+RUBY_INSTALL_NAME = $(RUBY_BASE_NAME)
+RUBY_SO_NAME = ruby
+RUBYW_INSTALL_NAME =
+RUBY_VERSION_NAME = $(RUBY_BASE_NAME)-$(ruby_version)
+RUBYW_BASE_NAME = rubyw
+RUBY_BASE_NAME = ruby
+
+arch = x86_64-linux
+sitearch = $(arch)
+ruby_version = 2.2.0
+ruby = $(topdir)/miniruby -I'$(topdir)' -I'$(top_srcdir)/lib' -I'$(extout)/$(arch)' -I'$(extout)/common'
+RUBY = $(ruby)
+ruby_headers = $(hdrdir)/ruby.h $(hdrdir)/ruby/ruby.h $(hdrdir)/ruby/defines.h $(hdrdir)/ruby/missing.h $(hdrdir)/ruby/intern.h $(hdrdir)/ruby/st.h $(hdrdir)/ruby/subst.h $(arch_hdrdir)/ruby/config.h $(RUBY_EXTCONF_H)
+
+RM = rm -f
+RM_RF = $(RUBY) -run -e rm -- -rf
+RMDIRS = rmdir --ignore-fail-on-non-empty -p
+MAKEDIRS = /bin/mkdir -p
+INSTALL = /usr/bin/install -c
+INSTALL_PROG = $(INSTALL) -m 0755
+INSTALL_DATA = $(INSTALL) -m 644
+COPY = cp
+TOUCH = exit >
+
+#### End of system configuration section. ####
+
+preload =
+
+libpath = . $(topdir)
+LIBPATH = -L. -L$(topdir)
+DEFFILE =
+
+CLEANFILES = mkmf.log
+DISTCLEANFILES =
+DISTCLEANDIRS =
+
+extout = $(topdir)/.ext
+extout_prefix = $(extout)$(target_prefix)/
+target_prefix = /-test-/st
+LOCAL_LIBS =
+LIBS = $(LIBRUBYARG_SHARED) -lpthread -lgmp -ldl -lcrypt -lm -lc
+ORIG_SRCS = update.c
+SRCS = $(ORIG_SRCS)
+OBJS = update.o
+HDRS = $(srcdir)/extconf.h
+TARGET = update
+TARGET_NAME = update
+TARGET_ENTRY = Init_$(TARGET_NAME)
+DLLIB = $(TARGET).so
+EXTSTATIC =
+STATIC_LIB = $(TARGET).a
+
+TIMESTAMP_DIR = $(extout)/.timestamp
+BINDIR = $(extout)/bin
+RUBYCOMMONDIR = $(extout)/common
+RUBYLIBDIR = $(RUBYCOMMONDIR)$(target_prefix)
+RUBYARCHDIR = $(extout)/$(arch)$(target_prefix)
+HDRDIR = $(extout)/include/ruby$(target_prefix)
+ARCHHDRDIR = $(extout)/include/$(arch)/ruby$(target_prefix)
+
+TARGET_SO = $(RUBYARCHDIR)/$(DLLIB)
+CLEANLIBS = $(RUBYARCHDIR)/$(TARGET).so
+CLEANOBJS = *.o *.bak
+
+all: install
+static: all
+.PHONY: all install static install-so install-rb
+.PHONY: clean clean-so clean-static clean-rb
+
+clean-static::
+clean-rb-default::
+clean-rb::
+clean-so::
+clean: clean-so clean-static clean-rb-default clean-rb
+ -$(Q)$(RM) $(CLEANLIBS) $(CLEANOBJS) $(CLEANFILES) .*.time
+
+distclean-rb-default::
+distclean-rb::
+distclean-so::
+distclean-static::
+distclean: clean distclean-so distclean-static distclean-rb-default distclean-rb
+ -$(Q)$(RM) Makefile $(RUBY_EXTCONF_H) conftest.* mkmf.log
+ -$(Q)$(RM) core ruby$(EXEEXT) *~ $(DISTCLEANFILES)
+ -$(Q)$(RMDIRS) $(DISTCLEANDIRS) 2> /dev/null || true
+
+realclean: distclean
+install: install-so install-rb
+
+install-so: $(RUBYARCHDIR)/$(DLLIB)
+clean-so::
+ -$(Q)$(RM) $(RUBYARCHDIR)/$(DLLIB)
+ -$(Q)$(RMDIRS) $(RUBYARCHDIR) 2> /dev/null || true
+clean-static::
+ -$(Q)$(RM) $(STATIC_LIB)
+install-rb: pre-install-rb install-rb-default
+install-rb-default: pre-install-rb-default
+pre-install-rb: Makefile
+pre-install-rb-default: Makefile
+pre-install-rb-default:
+ @$(NULLCMD)
+$(TIMESTAMP_DIR)/.RUBYARCHDIR.-.-test-.-.st.time:
+ $(Q) $(MAKEDIRS) $(@D) $(RUBYARCHDIR)
+ $(Q) $(TOUCH) $@
+
+site-install: site-install-so site-install-rb
+site-install-so: install-so
+site-install-rb: install-rb
+
+.SUFFIXES: .c .m .cc .mm .cxx .cpp .o .S
+
+.cc.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<
+
+.cc.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -S $<
+
+.mm.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<
+
+.mm.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -S $<
+
+.cxx.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<
+
+.cxx.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -S $<
+
+.cpp.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<
+
+.cpp.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -S $<
+
+.c.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -c $<
+
+.c.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -S $<
+
+.m.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -c $<
+
+.m.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -S $<
+
+$(RUBYARCHDIR)/$(DLLIB): $(OBJS) Makefile $(TIMESTAMP_DIR)/.RUBYARCHDIR.-.-test-.-.st.time
+ $(ECHO) linking shared-object -test-/st/$(DLLIB)
+ -$(Q)$(RM) $(@)
+ $(Q) $(LDSHARED) -o $@ $(OBJS) $(LIBPATH) $(DLDFLAGS) $(LOCAL_LIBS) $(LIBS)
+
+$(STATIC_LIB): $(OBJS)
+ -$(Q)$(RM) $(@)
+ $(ECHO) linking static-library $(@)
+ $(Q) $(AR) cru $@ $(OBJS)
+ -$(Q)ranlib $(@) 2> /dev/null || true
+
+$(OBJS): $(HDRS) $(ruby_headers)
diff --git a/jni/ruby/ext/-test-/st/update/extconf.h b/jni/ruby/ext/-test-/st/update/extconf.h
new file mode 100644
index 0000000..cda0cc8
--- /dev/null
+++ b/jni/ruby/ext/-test-/st/update/extconf.h
@@ -0,0 +1,3 @@
+#ifndef EXTCONF_H
+#define EXTCONF_H
+#endif
diff --git a/jni/ruby/ext/-test-/st/update/extconf.rb b/jni/ruby/ext/-test-/st/update/extconf.rb
new file mode 100644
index 0000000..96dbae4
--- /dev/null
+++ b/jni/ruby/ext/-test-/st/update/extconf.rb
@@ -0,0 +1 @@
+create_makefile("-test-/st/update")
diff --git a/jni/ruby/ext/-test-/st/update/update.c b/jni/ruby/ext/-test-/st/update/update.c
new file mode 100644
index 0000000..979ad3e
--- /dev/null
+++ b/jni/ruby/ext/-test-/st/update/update.c
@@ -0,0 +1,34 @@
+#include <ruby.h>
+#include <ruby/st.h>
+
+static int
+update_func(st_data_t *key, st_data_t *value, st_data_t arg, int existing)
+{
+ VALUE ret = rb_yield_values(existing ? 2 : 1, (VALUE)*key, (VALUE)*value);
+ switch (ret) {
+ case Qfalse:
+ return ST_STOP;
+ case Qnil:
+ return ST_DELETE;
+ default:
+ *value = ret;
+ return ST_CONTINUE;
+ }
+}
+
+static VALUE
+test_st_update(VALUE self, VALUE key)
+{
+ if (st_update(RHASH_TBL(self), (st_data_t)key, update_func, 0))
+ return Qtrue;
+ else
+ return Qfalse;
+}
+
+void
+Init_update(void)
+{
+ VALUE st = rb_define_class_under(rb_define_module("Bug"), "StTable", rb_cHash);
+ rb_define_method(st, "st_update", test_st_update, 1);
+}
+
diff --git a/jni/ruby/ext/-test-/string/Makefile b/jni/ruby/ext/-test-/string/Makefile
new file mode 100644
index 0000000..353778b
--- /dev/null
+++ b/jni/ruby/ext/-test-/string/Makefile
@@ -0,0 +1,384 @@
+
+SHELL = /bin/sh
+
+# V=0 quiet, V=1 verbose. other values don't work.
+V = 0
+Q1 = $(V:1=)
+Q = $(Q1:0=@)
+ECHO1 = $(V:1=@:)
+ECHO = $(ECHO1:0=@echo)
+NULLCMD = :
+
+#### Start of system configuration section. ####
+top_srcdir = $(topdir)/.
+srcdir = $(top_srcdir)/ext/-test-/string
+topdir = ../../..
+hdrdir = $(top_srcdir)/include
+arch_hdrdir = $(extout)/include/$(arch)
+PATH_SEPARATOR = :
+VPATH = $(srcdir):$(arch_hdrdir)/ruby:$(hdrdir)/ruby
+RUBYLIB =
+RUBYOPT = -
+prefix = $(DESTDIR)/usr/local
+rubysitearchprefix = $(rubylibprefix)/$(sitearch)
+rubyarchprefix = $(rubylibprefix)/$(arch)
+rubylibprefix = $(libdir)/$(RUBY_BASE_NAME)
+exec_prefix = $(prefix)
+vendorarchhdrdir = $(vendorhdrdir)/$(sitearch)
+sitearchhdrdir = $(sitehdrdir)/$(sitearch)
+rubyarchhdrdir = $(rubyhdrdir)/$(arch)
+vendorhdrdir = $(rubyhdrdir)/vendor_ruby
+sitehdrdir = $(rubyhdrdir)/site_ruby
+rubyhdrdir = $(includedir)/$(RUBY_VERSION_NAME)
+vendorarchdir = $(vendorlibdir)/$(sitearch)
+vendorlibdir = $(vendordir)/$(ruby_version)
+vendordir = $(rubylibprefix)/vendor_ruby
+sitearchdir = $(sitelibdir)/$(sitearch)
+sitelibdir = $(sitedir)/$(ruby_version)
+sitedir = $(rubylibprefix)/site_ruby
+rubyarchdir = $(rubylibdir)/$(arch)
+rubylibdir = $(rubylibprefix)/$(ruby_version)
+sitearchincludedir = $(includedir)/$(sitearch)
+archincludedir = $(includedir)/$(arch)
+sitearchlibdir = $(libdir)/$(sitearch)
+archlibdir = $(libdir)/$(arch)
+ridir = $(datarootdir)/$(RI_BASE_NAME)
+mandir = $(datarootdir)/man
+localedir = $(datarootdir)/locale
+libdir = $(exec_prefix)/lib
+psdir = $(docdir)
+pdfdir = $(docdir)
+dvidir = $(docdir)
+htmldir = $(docdir)
+infodir = $(datarootdir)/info
+docdir = $(datarootdir)/doc/$(PACKAGE)
+oldincludedir = $(DESTDIR)/usr/include
+includedir = $(prefix)/include
+localstatedir = $(prefix)/var
+sharedstatedir = $(prefix)/com
+sysconfdir = $(prefix)/etc
+datadir = $(datarootdir)
+datarootdir = $(prefix)/share
+libexecdir = $(exec_prefix)/libexec
+sbindir = $(exec_prefix)/sbin
+bindir = $(exec_prefix)/bin
+archdir = $(rubyarchdir)
+
+
+CC = gcc
+CXX = g++
+LIBRUBY = $(LIBRUBY_SO)
+LIBRUBY_A = lib$(RUBY_SO_NAME)-static.a
+LIBRUBYARG_SHARED = -Wl,-R$(libdir) -L$(libdir) -l$(RUBY_SO_NAME)
+LIBRUBYARG_STATIC = -Wl,-R$(libdir) -L$(libdir) -l$(RUBY_SO_NAME)-static
+empty =
+OUTFLAG = -o $(empty)
+COUTFLAG = -o $(empty)
+
+RUBY_EXTCONF_H = extconf.h
+cflags = $(optflags) $(debugflags) $(warnflags)
+optflags = -O3 -fno-fast-math
+debugflags = -ggdb3
+warnflags = -Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wunused-variable -Wpointer-arith -Wwrite-strings -Wdeclaration-after-statement -Wimplicit-function-declaration -Wdeprecated-declarations -Wno-packed-bitfield-compat
+CCDLFLAGS = -fPIC
+CFLAGS = $(CCDLFLAGS) $(cflags) -fPIC $(ARCH_FLAG)
+INCFLAGS = -I. -I$(arch_hdrdir) -I$(hdrdir) -I$(srcdir) -I$(topdir) -I$(top_srcdir)
+DEFS =
+CPPFLAGS = -DRUBY_EXTCONF_H=\"$(RUBY_EXTCONF_H)\" $(DEFS) $(cppflags)
+CXXFLAGS = $(CCDLFLAGS) $(cxxflags) $(ARCH_FLAG)
+ldflags = -L. -fstack-protector -rdynamic -Wl,-export-dynamic
+dldflags =
+ARCH_FLAG =
+DLDFLAGS = $(ldflags) $(dldflags) $(ARCH_FLAG)
+LDSHARED = $(CC) -shared
+LDSHAREDXX = $(CXX) -shared
+AR = ar
+EXEEXT =
+
+RUBY_INSTALL_NAME = $(RUBY_BASE_NAME)
+RUBY_SO_NAME = ruby
+RUBYW_INSTALL_NAME =
+RUBY_VERSION_NAME = $(RUBY_BASE_NAME)-$(ruby_version)
+RUBYW_BASE_NAME = rubyw
+RUBY_BASE_NAME = ruby
+
+arch = x86_64-linux
+sitearch = $(arch)
+ruby_version = 2.2.0
+ruby = $(topdir)/miniruby -I'$(topdir)' -I'$(top_srcdir)/lib' -I'$(extout)/$(arch)' -I'$(extout)/common'
+RUBY = $(ruby)
+ruby_headers = $(hdrdir)/ruby.h $(hdrdir)/ruby/ruby.h $(hdrdir)/ruby/defines.h $(hdrdir)/ruby/missing.h $(hdrdir)/ruby/intern.h $(hdrdir)/ruby/st.h $(hdrdir)/ruby/subst.h $(arch_hdrdir)/ruby/config.h $(RUBY_EXTCONF_H)
+
+RM = rm -f
+RM_RF = $(RUBY) -run -e rm -- -rf
+RMDIRS = rmdir --ignore-fail-on-non-empty -p
+MAKEDIRS = /bin/mkdir -p
+INSTALL = /usr/bin/install -c
+INSTALL_PROG = $(INSTALL) -m 0755
+INSTALL_DATA = $(INSTALL) -m 644
+COPY = cp
+TOUCH = exit >
+
+#### End of system configuration section. ####
+
+preload =
+
+libpath = . $(topdir)
+LIBPATH = -L. -L$(topdir)
+DEFFILE =
+
+CLEANFILES = mkmf.log
+DISTCLEANFILES =
+DISTCLEANDIRS =
+
+extout = $(topdir)/.ext
+extout_prefix = $(extout)$(target_prefix)/
+target_prefix = /-test-/string
+LOCAL_LIBS =
+LIBS = $(LIBRUBYARG_SHARED) -lpthread -lgmp -ldl -lcrypt -lm -lc
+ORIG_SRCS = enc_associate.c qsort.c cstr.c init.c coderange.c normalize.c set_len.c nofree.c enc_str_buf_cat.c ellipsize.c modify.c
+SRCS = $(ORIG_SRCS)
+OBJS = enc_associate.o qsort.o cstr.o init.o coderange.o normalize.o set_len.o nofree.o enc_str_buf_cat.o ellipsize.o modify.o
+HDRS = $(srcdir)/extconf.h
+TARGET = string
+TARGET_NAME = string
+TARGET_ENTRY = Init_$(TARGET_NAME)
+DLLIB = $(TARGET).so
+EXTSTATIC =
+STATIC_LIB = $(TARGET).a
+
+TIMESTAMP_DIR = $(extout)/.timestamp
+BINDIR = $(extout)/bin
+RUBYCOMMONDIR = $(extout)/common
+RUBYLIBDIR = $(RUBYCOMMONDIR)$(target_prefix)
+RUBYARCHDIR = $(extout)/$(arch)$(target_prefix)
+HDRDIR = $(extout)/include/ruby$(target_prefix)
+ARCHHDRDIR = $(extout)/include/$(arch)/ruby$(target_prefix)
+
+TARGET_SO = $(RUBYARCHDIR)/$(DLLIB)
+CLEANLIBS = $(RUBYARCHDIR)/$(TARGET).so
+CLEANOBJS = *.o *.bak
+
+all: install
+static: all
+.PHONY: all install static install-so install-rb
+.PHONY: clean clean-so clean-static clean-rb
+
+clean-static::
+clean-rb-default::
+clean-rb::
+clean-so::
+clean: clean-so clean-static clean-rb-default clean-rb
+ -$(Q)$(RM) $(CLEANLIBS) $(CLEANOBJS) $(CLEANFILES) .*.time
+
+distclean-rb-default::
+distclean-rb::
+distclean-so::
+distclean-static::
+distclean: clean distclean-so distclean-static distclean-rb-default distclean-rb
+ -$(Q)$(RM) Makefile $(RUBY_EXTCONF_H) conftest.* mkmf.log
+ -$(Q)$(RM) core ruby$(EXEEXT) *~ $(DISTCLEANFILES)
+ -$(Q)$(RMDIRS) $(DISTCLEANDIRS) 2> /dev/null || true
+
+realclean: distclean
+install: install-so install-rb
+
+install-so: $(RUBYARCHDIR)/$(DLLIB)
+clean-so::
+ -$(Q)$(RM) $(RUBYARCHDIR)/$(DLLIB)
+ -$(Q)$(RMDIRS) $(RUBYARCHDIR) 2> /dev/null || true
+clean-static::
+ -$(Q)$(RM) $(STATIC_LIB)
+install-rb: pre-install-rb install-rb-default
+install-rb-default: pre-install-rb-default
+pre-install-rb: Makefile
+pre-install-rb-default: Makefile
+pre-install-rb-default:
+ @$(NULLCMD)
+$(TIMESTAMP_DIR)/.RUBYARCHDIR.-.-test-.-.string.time:
+ $(Q) $(MAKEDIRS) $(@D) $(RUBYARCHDIR)
+ $(Q) $(TOUCH) $@
+
+site-install: site-install-so site-install-rb
+site-install-so: install-so
+site-install-rb: install-rb
+
+.SUFFIXES: .c .m .cc .mm .cxx .cpp .o .S
+
+.cc.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<
+
+.cc.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -S $<
+
+.mm.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<
+
+.mm.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -S $<
+
+.cxx.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<
+
+.cxx.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -S $<
+
+.cpp.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<
+
+.cpp.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -S $<
+
+.c.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -c $<
+
+.c.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -S $<
+
+.m.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -c $<
+
+.m.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -S $<
+
+$(RUBYARCHDIR)/$(DLLIB): $(OBJS) Makefile $(TIMESTAMP_DIR)/.RUBYARCHDIR.-.-test-.-.string.time
+ $(ECHO) linking shared-object -test-/string/$(DLLIB)
+ -$(Q)$(RM) $(@)
+ $(Q) $(LDSHARED) -o $@ $(OBJS) $(LIBPATH) $(DLDFLAGS) $(LOCAL_LIBS) $(LIBS)
+
+$(STATIC_LIB): $(OBJS)
+ -$(Q)$(RM) $(@)
+ $(ECHO) linking static-library $(@)
+ $(Q) $(AR) cru $@ $(OBJS)
+ -$(Q)ranlib $(@) 2> /dev/null || true
+
+###
+$(OBJS): $(RUBY_EXTCONF_H)
+
+# AUTOGENERATED DEPENDENCIES START
+coderange.o: $(RUBY_EXTCONF_H)
+coderange.o: $(arch_hdrdir)/ruby/config.h
+coderange.o: $(hdrdir)/ruby/defines.h
+coderange.o: $(hdrdir)/ruby/encoding.h
+coderange.o: $(hdrdir)/ruby/intern.h
+coderange.o: $(hdrdir)/ruby/missing.h
+coderange.o: $(hdrdir)/ruby/oniguruma.h
+coderange.o: $(hdrdir)/ruby/ruby.h
+coderange.o: $(hdrdir)/ruby/st.h
+coderange.o: $(hdrdir)/ruby/subst.h
+coderange.o: coderange.c
+cstr.o: $(RUBY_EXTCONF_H)
+cstr.o: $(arch_hdrdir)/ruby/config.h
+cstr.o: $(hdrdir)/ruby/defines.h
+cstr.o: $(hdrdir)/ruby/encoding.h
+cstr.o: $(hdrdir)/ruby/intern.h
+cstr.o: $(hdrdir)/ruby/missing.h
+cstr.o: $(hdrdir)/ruby/oniguruma.h
+cstr.o: $(hdrdir)/ruby/ruby.h
+cstr.o: $(hdrdir)/ruby/st.h
+cstr.o: $(hdrdir)/ruby/subst.h
+cstr.o: $(top_srcdir)/include/ruby.h
+cstr.o: cstr.c
+ellipsize.o: $(RUBY_EXTCONF_H)
+ellipsize.o: $(arch_hdrdir)/ruby/config.h
+ellipsize.o: $(hdrdir)/ruby/defines.h
+ellipsize.o: $(hdrdir)/ruby/intern.h
+ellipsize.o: $(hdrdir)/ruby/missing.h
+ellipsize.o: $(hdrdir)/ruby/ruby.h
+ellipsize.o: $(hdrdir)/ruby/st.h
+ellipsize.o: $(hdrdir)/ruby/subst.h
+ellipsize.o: $(top_srcdir)/include/ruby.h
+ellipsize.o: ellipsize.c
+enc_associate.o: $(RUBY_EXTCONF_H)
+enc_associate.o: $(arch_hdrdir)/ruby/config.h
+enc_associate.o: $(hdrdir)/ruby/defines.h
+enc_associate.o: $(hdrdir)/ruby/encoding.h
+enc_associate.o: $(hdrdir)/ruby/intern.h
+enc_associate.o: $(hdrdir)/ruby/missing.h
+enc_associate.o: $(hdrdir)/ruby/oniguruma.h
+enc_associate.o: $(hdrdir)/ruby/ruby.h
+enc_associate.o: $(hdrdir)/ruby/st.h
+enc_associate.o: $(hdrdir)/ruby/subst.h
+enc_associate.o: $(top_srcdir)/include/ruby.h
+enc_associate.o: enc_associate.c
+enc_str_buf_cat.o: $(RUBY_EXTCONF_H)
+enc_str_buf_cat.o: $(arch_hdrdir)/ruby/config.h
+enc_str_buf_cat.o: $(hdrdir)/ruby/defines.h
+enc_str_buf_cat.o: $(hdrdir)/ruby/encoding.h
+enc_str_buf_cat.o: $(hdrdir)/ruby/intern.h
+enc_str_buf_cat.o: $(hdrdir)/ruby/missing.h
+enc_str_buf_cat.o: $(hdrdir)/ruby/oniguruma.h
+enc_str_buf_cat.o: $(hdrdir)/ruby/ruby.h
+enc_str_buf_cat.o: $(hdrdir)/ruby/st.h
+enc_str_buf_cat.o: $(hdrdir)/ruby/subst.h
+enc_str_buf_cat.o: enc_str_buf_cat.c
+init.o: $(RUBY_EXTCONF_H)
+init.o: $(arch_hdrdir)/ruby/config.h
+init.o: $(hdrdir)/ruby/defines.h
+init.o: $(hdrdir)/ruby/intern.h
+init.o: $(hdrdir)/ruby/missing.h
+init.o: $(hdrdir)/ruby/ruby.h
+init.o: $(hdrdir)/ruby/st.h
+init.o: $(hdrdir)/ruby/subst.h
+init.o: $(top_srcdir)/include/ruby.h
+init.o: init.c
+modify.o: $(RUBY_EXTCONF_H)
+modify.o: $(arch_hdrdir)/ruby/config.h
+modify.o: $(hdrdir)/ruby/defines.h
+modify.o: $(hdrdir)/ruby/intern.h
+modify.o: $(hdrdir)/ruby/missing.h
+modify.o: $(hdrdir)/ruby/ruby.h
+modify.o: $(hdrdir)/ruby/st.h
+modify.o: $(hdrdir)/ruby/subst.h
+modify.o: $(top_srcdir)/include/ruby.h
+modify.o: modify.c
+normalize.o: $(RUBY_EXTCONF_H)
+normalize.o: $(arch_hdrdir)/ruby/config.h
+normalize.o: $(hdrdir)/ruby/defines.h
+normalize.o: $(hdrdir)/ruby/encoding.h
+normalize.o: $(hdrdir)/ruby/intern.h
+normalize.o: $(hdrdir)/ruby/io.h
+normalize.o: $(hdrdir)/ruby/missing.h
+normalize.o: $(hdrdir)/ruby/oniguruma.h
+normalize.o: $(hdrdir)/ruby/ruby.h
+normalize.o: $(hdrdir)/ruby/st.h
+normalize.o: $(hdrdir)/ruby/subst.h
+normalize.o: $(top_srcdir)/include/ruby.h
+normalize.o: $(top_srcdir)/internal.h
+normalize.o: normalize.c
+qsort.o: $(RUBY_EXTCONF_H)
+qsort.o: $(arch_hdrdir)/ruby/config.h
+qsort.o: $(hdrdir)/ruby/defines.h
+qsort.o: $(hdrdir)/ruby/encoding.h
+qsort.o: $(hdrdir)/ruby/intern.h
+qsort.o: $(hdrdir)/ruby/missing.h
+qsort.o: $(hdrdir)/ruby/oniguruma.h
+qsort.o: $(hdrdir)/ruby/ruby.h
+qsort.o: $(hdrdir)/ruby/st.h
+qsort.o: $(hdrdir)/ruby/subst.h
+qsort.o: $(hdrdir)/ruby/util.h
+qsort.o: $(top_srcdir)/include/ruby.h
+qsort.o: qsort.c
+set_len.o: $(RUBY_EXTCONF_H)
+set_len.o: $(arch_hdrdir)/ruby/config.h
+set_len.o: $(hdrdir)/ruby/defines.h
+set_len.o: $(hdrdir)/ruby/intern.h
+set_len.o: $(hdrdir)/ruby/missing.h
+set_len.o: $(hdrdir)/ruby/ruby.h
+set_len.o: $(hdrdir)/ruby/st.h
+set_len.o: $(hdrdir)/ruby/subst.h
+set_len.o: $(top_srcdir)/include/ruby.h
+set_len.o: set_len.c
+# AUTOGENERATED DEPENDENCIES END
diff --git a/jni/ruby/ext/-test-/string/coderange.c b/jni/ruby/ext/-test-/string/coderange.c
new file mode 100644
index 0000000..b93172d
--- /dev/null
+++ b/jni/ruby/ext/-test-/string/coderange.c
@@ -0,0 +1,47 @@
+#include "ruby/ruby.h"
+#include "ruby/encoding.h"
+
+static VALUE sym_7bit, sym_valid, sym_unknown, sym_broken;
+
+static VALUE
+coderange_int2sym(int coderange)
+{
+ switch (coderange) {
+ case ENC_CODERANGE_7BIT:
+ return sym_7bit;
+ case ENC_CODERANGE_VALID:
+ return sym_valid;
+ case ENC_CODERANGE_UNKNOWN:
+ return sym_unknown;
+ case ENC_CODERANGE_BROKEN:
+ return sym_broken;
+ }
+ rb_bug("wrong condition of coderange");
+ UNREACHABLE;
+}
+
+/* return coderange without scan */
+static VALUE
+str_coderange(VALUE str)
+{
+ return coderange_int2sym(ENC_CODERANGE(str));
+}
+
+/* scan coderange and return the result */
+static VALUE
+str_coderange_scan(VALUE str)
+{
+ ENC_CODERANGE_SET(str, ENC_CODERANGE_UNKNOWN);
+ return coderange_int2sym(rb_enc_str_coderange(str));
+}
+
+void
+Init_coderange(VALUE klass)
+{
+ sym_7bit = ID2SYM(rb_intern("7bit"));
+ sym_valid = ID2SYM(rb_intern("valid"));
+ sym_unknown = ID2SYM(rb_intern("unknown"));
+ sym_broken = ID2SYM(rb_intern("broken"));
+ rb_define_method(klass, "coderange", str_coderange, 0);
+ rb_define_method(klass, "coderange_scan", str_coderange_scan, 0);
+}
diff --git a/jni/ruby/ext/-test-/string/cstr.c b/jni/ruby/ext/-test-/string/cstr.c
new file mode 100644
index 0000000..ba2e46b
--- /dev/null
+++ b/jni/ruby/ext/-test-/string/cstr.c
@@ -0,0 +1,57 @@
+#include "ruby.h"
+#include "ruby/encoding.h"
+
+static VALUE
+bug_str_cstr_term(VALUE str)
+{
+ long len;
+ char *s;
+ int c;
+ rb_encoding *enc;
+
+ rb_str_modify(str);
+ len = RSTRING_LEN(str);
+ RSTRING_PTR(str)[len] = 'x';
+ s = StringValueCStr(str);
+ rb_gc();
+ enc = rb_enc_get(str);
+ c = rb_enc_codepoint(&s[len], &s[len+rb_enc_mbminlen(enc)], enc);
+ return INT2NUM(c);
+}
+
+static VALUE
+bug_str_cstr_term_char(VALUE str)
+{
+ long len;
+ char *s;
+ int c;
+ rb_encoding *enc = rb_enc_get(str);
+
+ RSTRING_GETMEM(str, s, len);
+ s += len;
+ len = rb_enc_mbminlen(enc);
+ c = rb_enc_precise_mbclen(s, s + len, enc);
+ if (!MBCLEN_CHARFOUND_P(c)) {
+ c = (unsigned char)*s;
+ }
+ else {
+ c = rb_enc_mbc_to_codepoint(s, s + len, enc);
+ if (!c) return Qnil;
+ }
+ return rb_enc_uint_chr((unsigned int)c, enc);
+}
+
+static VALUE
+bug_str_s_cstr_term_char(VALUE self, VALUE str)
+{
+ Check_Type(str, T_STRING);
+ return bug_str_cstr_term_char(str);
+}
+
+void
+Init_cstr(VALUE klass)
+{
+ rb_define_method(klass, "cstr_term", bug_str_cstr_term, 0);
+ rb_define_method(klass, "cstr_term_char", bug_str_cstr_term_char, 0);
+ rb_define_singleton_method(klass, "cstr_term_char", bug_str_s_cstr_term_char, 1);
+}
diff --git a/jni/ruby/ext/-test-/string/depend b/jni/ruby/ext/-test-/string/depend
new file mode 100644
index 0000000..ef13e44
--- /dev/null
+++ b/jni/ruby/ext/-test-/string/depend
@@ -0,0 +1,115 @@
+# AUTOGENERATED DEPENDENCIES START
+coderange.o: $(RUBY_EXTCONF_H)
+coderange.o: $(arch_hdrdir)/ruby/config.h
+coderange.o: $(hdrdir)/ruby/defines.h
+coderange.o: $(hdrdir)/ruby/encoding.h
+coderange.o: $(hdrdir)/ruby/intern.h
+coderange.o: $(hdrdir)/ruby/missing.h
+coderange.o: $(hdrdir)/ruby/oniguruma.h
+coderange.o: $(hdrdir)/ruby/ruby.h
+coderange.o: $(hdrdir)/ruby/st.h
+coderange.o: $(hdrdir)/ruby/subst.h
+coderange.o: coderange.c
+cstr.o: $(RUBY_EXTCONF_H)
+cstr.o: $(arch_hdrdir)/ruby/config.h
+cstr.o: $(hdrdir)/ruby/defines.h
+cstr.o: $(hdrdir)/ruby/encoding.h
+cstr.o: $(hdrdir)/ruby/intern.h
+cstr.o: $(hdrdir)/ruby/missing.h
+cstr.o: $(hdrdir)/ruby/oniguruma.h
+cstr.o: $(hdrdir)/ruby/ruby.h
+cstr.o: $(hdrdir)/ruby/st.h
+cstr.o: $(hdrdir)/ruby/subst.h
+cstr.o: $(top_srcdir)/include/ruby.h
+cstr.o: cstr.c
+ellipsize.o: $(RUBY_EXTCONF_H)
+ellipsize.o: $(arch_hdrdir)/ruby/config.h
+ellipsize.o: $(hdrdir)/ruby/defines.h
+ellipsize.o: $(hdrdir)/ruby/intern.h
+ellipsize.o: $(hdrdir)/ruby/missing.h
+ellipsize.o: $(hdrdir)/ruby/ruby.h
+ellipsize.o: $(hdrdir)/ruby/st.h
+ellipsize.o: $(hdrdir)/ruby/subst.h
+ellipsize.o: $(top_srcdir)/include/ruby.h
+ellipsize.o: ellipsize.c
+enc_associate.o: $(RUBY_EXTCONF_H)
+enc_associate.o: $(arch_hdrdir)/ruby/config.h
+enc_associate.o: $(hdrdir)/ruby/defines.h
+enc_associate.o: $(hdrdir)/ruby/encoding.h
+enc_associate.o: $(hdrdir)/ruby/intern.h
+enc_associate.o: $(hdrdir)/ruby/missing.h
+enc_associate.o: $(hdrdir)/ruby/oniguruma.h
+enc_associate.o: $(hdrdir)/ruby/ruby.h
+enc_associate.o: $(hdrdir)/ruby/st.h
+enc_associate.o: $(hdrdir)/ruby/subst.h
+enc_associate.o: $(top_srcdir)/include/ruby.h
+enc_associate.o: enc_associate.c
+enc_str_buf_cat.o: $(RUBY_EXTCONF_H)
+enc_str_buf_cat.o: $(arch_hdrdir)/ruby/config.h
+enc_str_buf_cat.o: $(hdrdir)/ruby/defines.h
+enc_str_buf_cat.o: $(hdrdir)/ruby/encoding.h
+enc_str_buf_cat.o: $(hdrdir)/ruby/intern.h
+enc_str_buf_cat.o: $(hdrdir)/ruby/missing.h
+enc_str_buf_cat.o: $(hdrdir)/ruby/oniguruma.h
+enc_str_buf_cat.o: $(hdrdir)/ruby/ruby.h
+enc_str_buf_cat.o: $(hdrdir)/ruby/st.h
+enc_str_buf_cat.o: $(hdrdir)/ruby/subst.h
+enc_str_buf_cat.o: enc_str_buf_cat.c
+init.o: $(RUBY_EXTCONF_H)
+init.o: $(arch_hdrdir)/ruby/config.h
+init.o: $(hdrdir)/ruby/defines.h
+init.o: $(hdrdir)/ruby/intern.h
+init.o: $(hdrdir)/ruby/missing.h
+init.o: $(hdrdir)/ruby/ruby.h
+init.o: $(hdrdir)/ruby/st.h
+init.o: $(hdrdir)/ruby/subst.h
+init.o: $(top_srcdir)/include/ruby.h
+init.o: init.c
+modify.o: $(RUBY_EXTCONF_H)
+modify.o: $(arch_hdrdir)/ruby/config.h
+modify.o: $(hdrdir)/ruby/defines.h
+modify.o: $(hdrdir)/ruby/intern.h
+modify.o: $(hdrdir)/ruby/missing.h
+modify.o: $(hdrdir)/ruby/ruby.h
+modify.o: $(hdrdir)/ruby/st.h
+modify.o: $(hdrdir)/ruby/subst.h
+modify.o: $(top_srcdir)/include/ruby.h
+modify.o: modify.c
+normalize.o: $(RUBY_EXTCONF_H)
+normalize.o: $(arch_hdrdir)/ruby/config.h
+normalize.o: $(hdrdir)/ruby/defines.h
+normalize.o: $(hdrdir)/ruby/encoding.h
+normalize.o: $(hdrdir)/ruby/intern.h
+normalize.o: $(hdrdir)/ruby/io.h
+normalize.o: $(hdrdir)/ruby/missing.h
+normalize.o: $(hdrdir)/ruby/oniguruma.h
+normalize.o: $(hdrdir)/ruby/ruby.h
+normalize.o: $(hdrdir)/ruby/st.h
+normalize.o: $(hdrdir)/ruby/subst.h
+normalize.o: $(top_srcdir)/include/ruby.h
+normalize.o: $(top_srcdir)/internal.h
+normalize.o: normalize.c
+qsort.o: $(RUBY_EXTCONF_H)
+qsort.o: $(arch_hdrdir)/ruby/config.h
+qsort.o: $(hdrdir)/ruby/defines.h
+qsort.o: $(hdrdir)/ruby/encoding.h
+qsort.o: $(hdrdir)/ruby/intern.h
+qsort.o: $(hdrdir)/ruby/missing.h
+qsort.o: $(hdrdir)/ruby/oniguruma.h
+qsort.o: $(hdrdir)/ruby/ruby.h
+qsort.o: $(hdrdir)/ruby/st.h
+qsort.o: $(hdrdir)/ruby/subst.h
+qsort.o: $(hdrdir)/ruby/util.h
+qsort.o: $(top_srcdir)/include/ruby.h
+qsort.o: qsort.c
+set_len.o: $(RUBY_EXTCONF_H)
+set_len.o: $(arch_hdrdir)/ruby/config.h
+set_len.o: $(hdrdir)/ruby/defines.h
+set_len.o: $(hdrdir)/ruby/intern.h
+set_len.o: $(hdrdir)/ruby/missing.h
+set_len.o: $(hdrdir)/ruby/ruby.h
+set_len.o: $(hdrdir)/ruby/st.h
+set_len.o: $(hdrdir)/ruby/subst.h
+set_len.o: $(top_srcdir)/include/ruby.h
+set_len.o: set_len.c
+# AUTOGENERATED DEPENDENCIES END
diff --git a/jni/ruby/ext/-test-/string/ellipsize.c b/jni/ruby/ext/-test-/string/ellipsize.c
new file mode 100644
index 0000000..0451519
--- /dev/null
+++ b/jni/ruby/ext/-test-/string/ellipsize.c
@@ -0,0 +1,13 @@
+#include "ruby.h"
+
+static VALUE
+bug_str_ellipsize(VALUE str, VALUE len)
+{
+ return rb_str_ellipsize(str, NUM2LONG(len));
+}
+
+void
+Init_ellipsize(VALUE klass)
+{
+ rb_define_method(klass, "ellipsize", bug_str_ellipsize, 1);
+}
diff --git a/jni/ruby/ext/-test-/string/enc_associate.c b/jni/ruby/ext/-test-/string/enc_associate.c
new file mode 100644
index 0000000..d6614fb
--- /dev/null
+++ b/jni/ruby/ext/-test-/string/enc_associate.c
@@ -0,0 +1,14 @@
+#include "ruby.h"
+#include "ruby/encoding.h"
+
+VALUE
+bug_str_enc_associate(VALUE str, VALUE enc)
+{
+ return rb_enc_associate(str, rb_to_encoding(enc));
+}
+
+void
+Init_enc_associate(VALUE klass)
+{
+ rb_define_method(klass, "associate_encoding!", bug_str_enc_associate, 1);
+}
diff --git a/jni/ruby/ext/-test-/string/enc_str_buf_cat.c b/jni/ruby/ext/-test-/string/enc_str_buf_cat.c
new file mode 100644
index 0000000..5d583c6
--- /dev/null
+++ b/jni/ruby/ext/-test-/string/enc_str_buf_cat.c
@@ -0,0 +1,14 @@
+#include "ruby/ruby.h"
+#include "ruby/encoding.h"
+
+static VALUE
+enc_str_buf_cat(VALUE str, VALUE str2)
+{
+ return rb_enc_str_buf_cat(str, RSTRING_PTR(str2), RSTRING_LEN(str2), rb_enc_get(str2));
+}
+
+void
+Init_enc_str_buf_cat(VALUE klass)
+{
+ rb_define_method(klass, "enc_str_buf_cat", enc_str_buf_cat, 1);
+}
diff --git a/jni/ruby/ext/-test-/string/extconf.h b/jni/ruby/ext/-test-/string/extconf.h
new file mode 100644
index 0000000..48f039d
--- /dev/null
+++ b/jni/ruby/ext/-test-/string/extconf.h
@@ -0,0 +1,4 @@
+#ifndef EXTCONF_H
+#define EXTCONF_H
+#define TEST_INIT_FUNCS(X) X(enc_associate) X(qsort) X(cstr) X(coderange) X(normalize) X(set_len) X(nofree) X(enc_str_buf_cat) X(ellipsize) X(modify)
+#endif
diff --git a/jni/ruby/ext/-test-/string/extconf.rb b/jni/ruby/ext/-test-/string/extconf.rb
new file mode 100644
index 0000000..10d33cb
--- /dev/null
+++ b/jni/ruby/ext/-test-/string/extconf.rb
@@ -0,0 +1,7 @@
+$INCFLAGS << " -I$(topdir) -I$(top_srcdir)"
+$srcs = Dir[File.join($srcdir, "*.{#{SRC_EXT.join(%q{,})}}")]
+inits = $srcs.map {|s| File.basename(s, ".*")}
+inits.delete("init")
+inits.map! {|s|"X(#{s})"}
+$defs << "-DTEST_INIT_FUNCS(X)=\"#{inits.join(' ')}\""
+create_makefile("-test-/string/string")
diff --git a/jni/ruby/ext/-test-/string/init.c b/jni/ruby/ext/-test-/string/init.c
new file mode 100644
index 0000000..0b3e4a6
--- /dev/null
+++ b/jni/ruby/ext/-test-/string/init.c
@@ -0,0 +1,11 @@
+#include "ruby.h"
+
+#define init(n) {void Init_##n(VALUE klass); Init_##n(klass);}
+
+void
+Init_string(void)
+{
+ VALUE mBug = rb_define_module("Bug");
+ VALUE klass = rb_define_class_under(mBug, "String", rb_cString);
+ TEST_INIT_FUNCS(init);
+}
diff --git a/jni/ruby/ext/-test-/string/modify.c b/jni/ruby/ext/-test-/string/modify.c
new file mode 100644
index 0000000..ddd2efd
--- /dev/null
+++ b/jni/ruby/ext/-test-/string/modify.c
@@ -0,0 +1,22 @@
+#include "ruby.h"
+
+VALUE
+bug_str_modify(VALUE str)
+{
+ rb_str_modify(str);
+ return str;
+}
+
+VALUE
+bug_str_modify_expand(VALUE str, VALUE expand)
+{
+ rb_str_modify_expand(str, NUM2LONG(expand));
+ return str;
+}
+
+void
+Init_modify(VALUE klass)
+{
+ rb_define_method(klass, "modify!", bug_str_modify, 0);
+ rb_define_method(klass, "modify_expand!", bug_str_modify_expand, 1);
+}
diff --git a/jni/ruby/ext/-test-/string/nofree.c b/jni/ruby/ext/-test-/string/nofree.c
new file mode 100644
index 0000000..d3d8071
--- /dev/null
+++ b/jni/ruby/ext/-test-/string/nofree.c
@@ -0,0 +1,13 @@
+#include "ruby.h"
+
+VALUE
+bug_str_nofree(VALUE self)
+{
+ return rb_str_new_cstr("abcdef");
+}
+
+void
+Init_nofree(VALUE klass)
+{
+ rb_define_singleton_method(klass, "nofree", bug_str_nofree, 0);
+}
diff --git a/jni/ruby/ext/-test-/string/normalize.c b/jni/ruby/ext/-test-/string/normalize.c
new file mode 100644
index 0000000..2e16a46
--- /dev/null
+++ b/jni/ruby/ext/-test-/string/normalize.c
@@ -0,0 +1,17 @@
+#include "internal.h"
+
+#ifdef __APPLE__
+static VALUE
+normalize_ospath(VALUE str)
+{
+ return rb_str_normalize_ospath(RSTRING_PTR(str), RSTRING_LEN(str));
+}
+#else
+#define normalize_ospath rb_f_notimplement
+#endif
+
+void
+Init_normalize(VALUE klass)
+{
+ rb_define_method(klass, "normalize_ospath", normalize_ospath, 0);
+}
diff --git a/jni/ruby/ext/-test-/string/qsort.c b/jni/ruby/ext/-test-/string/qsort.c
new file mode 100644
index 0000000..0b34936
--- /dev/null
+++ b/jni/ruby/ext/-test-/string/qsort.c
@@ -0,0 +1,61 @@
+#include "ruby.h"
+#include "ruby/util.h"
+#include "ruby/encoding.h"
+
+struct sort_data {
+ rb_encoding *enc;
+ long elsize;
+};
+
+static int
+cmp_1(const void *ap, const void *bp, void *dummy)
+{
+ struct sort_data *d = dummy;
+ VALUE a = rb_enc_str_new(ap, d->elsize, d->enc);
+ VALUE b = rb_enc_str_new(bp, d->elsize, d->enc);
+ VALUE retval = rb_yield_values(2, a, b);
+ return rb_cmpint(retval, a, b);
+}
+
+static int
+cmp_2(const void *ap, const void *bp, void *dummy)
+{
+ int a = *(const unsigned char *)ap;
+ int b = *(const unsigned char *)bp;
+ return a - b;
+}
+
+static VALUE
+bug_str_qsort_bang(int argc, VALUE *argv, VALUE str)
+{
+ VALUE beg, len, size;
+ long l, b = 0, n, s = 1;
+ struct sort_data d;
+
+ rb_scan_args(argc, argv, "03", &beg, &len, &size);
+ l = RSTRING_LEN(str);
+ if (!NIL_P(beg) && (b = NUM2INT(beg)) < 0 && (b += l) < 0) {
+ rb_raise(rb_eArgError, "out of bounds");
+ }
+ if (!NIL_P(size) && (s = NUM2INT(size)) < 0) {
+ rb_raise(rb_eArgError, "negative size");
+ }
+ if (NIL_P(len) ||
+ (((n = NUM2INT(len)) < 0) ?
+ (rb_raise(rb_eArgError, "negative length"), 0) :
+ (b + n * s > l))) {
+ n = (l - b) / s;
+ }
+ rb_str_modify(str);
+ d.enc = rb_enc_get(str);
+ d.elsize = s;
+ ruby_qsort(RSTRING_PTR(str) + b, n, s,
+ rb_block_given_p() ? cmp_1 : cmp_2, &d);
+ return str;
+}
+
+void
+Init_qsort(VALUE klass)
+{
+ rb_define_method(klass, "qsort!", bug_str_qsort_bang, -1);
+}
diff --git a/jni/ruby/ext/-test-/string/set_len.c b/jni/ruby/ext/-test-/string/set_len.c
new file mode 100644
index 0000000..3c7d19d
--- /dev/null
+++ b/jni/ruby/ext/-test-/string/set_len.c
@@ -0,0 +1,14 @@
+#include "ruby.h"
+
+static VALUE
+bug_str_set_len(VALUE str, VALUE len)
+{
+ rb_str_set_len(str, NUM2LONG(len));
+ return str;
+}
+
+void
+Init_set_len(VALUE klass)
+{
+ rb_define_method(klass, "set_len", bug_str_set_len, 1);
+}
diff --git a/jni/ruby/ext/-test-/struct/Makefile b/jni/ruby/ext/-test-/struct/Makefile
new file mode 100644
index 0000000..60551e8
--- /dev/null
+++ b/jni/ruby/ext/-test-/struct/Makefile
@@ -0,0 +1,267 @@
+
+SHELL = /bin/sh
+
+# V=0 quiet, V=1 verbose. other values don't work.
+V = 0
+Q1 = $(V:1=)
+Q = $(Q1:0=@)
+ECHO1 = $(V:1=@:)
+ECHO = $(ECHO1:0=@echo)
+NULLCMD = :
+
+#### Start of system configuration section. ####
+top_srcdir = $(topdir)/.
+srcdir = $(top_srcdir)/ext/-test-/struct
+topdir = ../../..
+hdrdir = $(top_srcdir)/include
+arch_hdrdir = $(extout)/include/$(arch)
+PATH_SEPARATOR = :
+VPATH = $(srcdir):$(arch_hdrdir)/ruby:$(hdrdir)/ruby
+RUBYLIB =
+RUBYOPT = -
+prefix = $(DESTDIR)/usr/local
+rubysitearchprefix = $(rubylibprefix)/$(sitearch)
+rubyarchprefix = $(rubylibprefix)/$(arch)
+rubylibprefix = $(libdir)/$(RUBY_BASE_NAME)
+exec_prefix = $(prefix)
+vendorarchhdrdir = $(vendorhdrdir)/$(sitearch)
+sitearchhdrdir = $(sitehdrdir)/$(sitearch)
+rubyarchhdrdir = $(rubyhdrdir)/$(arch)
+vendorhdrdir = $(rubyhdrdir)/vendor_ruby
+sitehdrdir = $(rubyhdrdir)/site_ruby
+rubyhdrdir = $(includedir)/$(RUBY_VERSION_NAME)
+vendorarchdir = $(vendorlibdir)/$(sitearch)
+vendorlibdir = $(vendordir)/$(ruby_version)
+vendordir = $(rubylibprefix)/vendor_ruby
+sitearchdir = $(sitelibdir)/$(sitearch)
+sitelibdir = $(sitedir)/$(ruby_version)
+sitedir = $(rubylibprefix)/site_ruby
+rubyarchdir = $(rubylibdir)/$(arch)
+rubylibdir = $(rubylibprefix)/$(ruby_version)
+sitearchincludedir = $(includedir)/$(sitearch)
+archincludedir = $(includedir)/$(arch)
+sitearchlibdir = $(libdir)/$(sitearch)
+archlibdir = $(libdir)/$(arch)
+ridir = $(datarootdir)/$(RI_BASE_NAME)
+mandir = $(datarootdir)/man
+localedir = $(datarootdir)/locale
+libdir = $(exec_prefix)/lib
+psdir = $(docdir)
+pdfdir = $(docdir)
+dvidir = $(docdir)
+htmldir = $(docdir)
+infodir = $(datarootdir)/info
+docdir = $(datarootdir)/doc/$(PACKAGE)
+oldincludedir = $(DESTDIR)/usr/include
+includedir = $(prefix)/include
+localstatedir = $(prefix)/var
+sharedstatedir = $(prefix)/com
+sysconfdir = $(prefix)/etc
+datadir = $(datarootdir)
+datarootdir = $(prefix)/share
+libexecdir = $(exec_prefix)/libexec
+sbindir = $(exec_prefix)/sbin
+bindir = $(exec_prefix)/bin
+archdir = $(rubyarchdir)
+
+
+CC = gcc
+CXX = g++
+LIBRUBY = $(LIBRUBY_SO)
+LIBRUBY_A = lib$(RUBY_SO_NAME)-static.a
+LIBRUBYARG_SHARED = -Wl,-R$(libdir) -L$(libdir) -l$(RUBY_SO_NAME)
+LIBRUBYARG_STATIC = -Wl,-R$(libdir) -L$(libdir) -l$(RUBY_SO_NAME)-static
+empty =
+OUTFLAG = -o $(empty)
+COUTFLAG = -o $(empty)
+
+RUBY_EXTCONF_H = extconf.h
+cflags = $(optflags) $(debugflags) $(warnflags)
+optflags = -O3 -fno-fast-math
+debugflags = -ggdb3
+warnflags = -Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wunused-variable -Wpointer-arith -Wwrite-strings -Wdeclaration-after-statement -Wimplicit-function-declaration -Wdeprecated-declarations -Wno-packed-bitfield-compat
+CCDLFLAGS = -fPIC
+CFLAGS = $(CCDLFLAGS) $(cflags) -fPIC $(ARCH_FLAG)
+INCFLAGS = -I. -I$(arch_hdrdir) -I$(hdrdir) -I$(srcdir) -I$(topdir) -I$(top_srcdir)
+DEFS =
+CPPFLAGS = -DRUBY_EXTCONF_H=\"$(RUBY_EXTCONF_H)\" $(DEFS) $(cppflags)
+CXXFLAGS = $(CCDLFLAGS) $(cxxflags) $(ARCH_FLAG)
+ldflags = -L. -fstack-protector -rdynamic -Wl,-export-dynamic
+dldflags =
+ARCH_FLAG =
+DLDFLAGS = $(ldflags) $(dldflags) $(ARCH_FLAG)
+LDSHARED = $(CC) -shared
+LDSHAREDXX = $(CXX) -shared
+AR = ar
+EXEEXT =
+
+RUBY_INSTALL_NAME = $(RUBY_BASE_NAME)
+RUBY_SO_NAME = ruby
+RUBYW_INSTALL_NAME =
+RUBY_VERSION_NAME = $(RUBY_BASE_NAME)-$(ruby_version)
+RUBYW_BASE_NAME = rubyw
+RUBY_BASE_NAME = ruby
+
+arch = x86_64-linux
+sitearch = $(arch)
+ruby_version = 2.2.0
+ruby = $(topdir)/miniruby -I'$(topdir)' -I'$(top_srcdir)/lib' -I'$(extout)/$(arch)' -I'$(extout)/common'
+RUBY = $(ruby)
+ruby_headers = $(hdrdir)/ruby.h $(hdrdir)/ruby/ruby.h $(hdrdir)/ruby/defines.h $(hdrdir)/ruby/missing.h $(hdrdir)/ruby/intern.h $(hdrdir)/ruby/st.h $(hdrdir)/ruby/subst.h $(arch_hdrdir)/ruby/config.h $(RUBY_EXTCONF_H)
+
+RM = rm -f
+RM_RF = $(RUBY) -run -e rm -- -rf
+RMDIRS = rmdir --ignore-fail-on-non-empty -p
+MAKEDIRS = /bin/mkdir -p
+INSTALL = /usr/bin/install -c
+INSTALL_PROG = $(INSTALL) -m 0755
+INSTALL_DATA = $(INSTALL) -m 644
+COPY = cp
+TOUCH = exit >
+
+#### End of system configuration section. ####
+
+preload =
+
+libpath = . $(topdir)
+LIBPATH = -L. -L$(topdir)
+DEFFILE =
+
+CLEANFILES = mkmf.log
+DISTCLEANFILES =
+DISTCLEANDIRS =
+
+extout = $(topdir)/.ext
+extout_prefix = $(extout)$(target_prefix)/
+target_prefix = /-test-
+LOCAL_LIBS =
+LIBS = $(LIBRUBYARG_SHARED) -lpthread -lgmp -ldl -lcrypt -lm -lc
+ORIG_SRCS = init.c member.c
+SRCS = $(ORIG_SRCS)
+OBJS = init.o member.o
+HDRS = $(srcdir)/extconf.h
+TARGET = struct
+TARGET_NAME = struct
+TARGET_ENTRY = Init_$(TARGET_NAME)
+DLLIB = $(TARGET).so
+EXTSTATIC =
+STATIC_LIB = $(TARGET).a
+
+TIMESTAMP_DIR = $(extout)/.timestamp
+BINDIR = $(extout)/bin
+RUBYCOMMONDIR = $(extout)/common
+RUBYLIBDIR = $(RUBYCOMMONDIR)$(target_prefix)
+RUBYARCHDIR = $(extout)/$(arch)$(target_prefix)
+HDRDIR = $(extout)/include/ruby$(target_prefix)
+ARCHHDRDIR = $(extout)/include/$(arch)/ruby$(target_prefix)
+
+TARGET_SO = $(RUBYARCHDIR)/$(DLLIB)
+CLEANLIBS = $(RUBYARCHDIR)/$(TARGET).so
+CLEANOBJS = *.o *.bak
+
+all: install
+static: all
+.PHONY: all install static install-so install-rb
+.PHONY: clean clean-so clean-static clean-rb
+
+clean-static::
+clean-rb-default::
+clean-rb::
+clean-so::
+clean: clean-so clean-static clean-rb-default clean-rb
+ -$(Q)$(RM) $(CLEANLIBS) $(CLEANOBJS) $(CLEANFILES) .*.time
+
+distclean-rb-default::
+distclean-rb::
+distclean-so::
+distclean-static::
+distclean: clean distclean-so distclean-static distclean-rb-default distclean-rb
+ -$(Q)$(RM) Makefile $(RUBY_EXTCONF_H) conftest.* mkmf.log
+ -$(Q)$(RM) core ruby$(EXEEXT) *~ $(DISTCLEANFILES)
+ -$(Q)$(RMDIRS) $(DISTCLEANDIRS) 2> /dev/null || true
+
+realclean: distclean
+install: install-so install-rb
+
+install-so: $(RUBYARCHDIR)/$(DLLIB)
+clean-so::
+ -$(Q)$(RM) $(RUBYARCHDIR)/$(DLLIB)
+ -$(Q)$(RMDIRS) $(RUBYARCHDIR) 2> /dev/null || true
+clean-static::
+ -$(Q)$(RM) $(STATIC_LIB)
+install-rb: pre-install-rb install-rb-default
+install-rb-default: pre-install-rb-default
+pre-install-rb: Makefile
+pre-install-rb-default: Makefile
+pre-install-rb-default:
+ @$(NULLCMD)
+$(TIMESTAMP_DIR)/.RUBYARCHDIR.-.-test-.time:
+ $(Q) $(MAKEDIRS) $(@D) $(RUBYARCHDIR)
+ $(Q) $(TOUCH) $@
+
+site-install: site-install-so site-install-rb
+site-install-so: install-so
+site-install-rb: install-rb
+
+.SUFFIXES: .c .m .cc .mm .cxx .cpp .o .S
+
+.cc.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<
+
+.cc.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -S $<
+
+.mm.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<
+
+.mm.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -S $<
+
+.cxx.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<
+
+.cxx.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -S $<
+
+.cpp.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<
+
+.cpp.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -S $<
+
+.c.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -c $<
+
+.c.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -S $<
+
+.m.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -c $<
+
+.m.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -S $<
+
+$(RUBYARCHDIR)/$(DLLIB): $(OBJS) Makefile $(TIMESTAMP_DIR)/.RUBYARCHDIR.-.-test-.time
+ $(ECHO) linking shared-object -test-/$(DLLIB)
+ -$(Q)$(RM) $(@)
+ $(Q) $(LDSHARED) -o $@ $(OBJS) $(LIBPATH) $(DLDFLAGS) $(LOCAL_LIBS) $(LIBS)
+
+$(STATIC_LIB): $(OBJS)
+ -$(Q)$(RM) $(@)
+ $(ECHO) linking static-library $(@)
+ $(Q) $(AR) cru $@ $(OBJS)
+ -$(Q)ranlib $(@) 2> /dev/null || true
+
+$(OBJS): $(HDRS) $(ruby_headers)
diff --git a/jni/ruby/ext/-test-/struct/extconf.h b/jni/ruby/ext/-test-/struct/extconf.h
new file mode 100644
index 0000000..1258892
--- /dev/null
+++ b/jni/ruby/ext/-test-/struct/extconf.h
@@ -0,0 +1,4 @@
+#ifndef EXTCONF_H
+#define EXTCONF_H
+#define TEST_INIT_FUNCS(X) X(member)
+#endif
diff --git a/jni/ruby/ext/-test-/struct/extconf.rb b/jni/ruby/ext/-test-/struct/extconf.rb
new file mode 100644
index 0000000..0e4f955
--- /dev/null
+++ b/jni/ruby/ext/-test-/struct/extconf.rb
@@ -0,0 +1,7 @@
+$INCFLAGS << " -I$(topdir) -I$(top_srcdir)"
+$srcs = Dir[File.join($srcdir, "*.{#{SRC_EXT.join(%q{,})}}")]
+inits = $srcs.map {|s| File.basename(s, ".*")}
+inits.delete("init")
+inits.map! {|s|"X(#{s})"}
+$defs << "-DTEST_INIT_FUNCS(X)=\"#{inits.join(' ')}\""
+create_makefile("-test-/struct")
diff --git a/jni/ruby/ext/-test-/struct/init.c b/jni/ruby/ext/-test-/struct/init.c
new file mode 100644
index 0000000..459a939
--- /dev/null
+++ b/jni/ruby/ext/-test-/struct/init.c
@@ -0,0 +1,11 @@
+#include "ruby.h"
+
+#define init(n) {void Init_##n(VALUE klass); Init_##n(klass);}
+
+void
+Init_struct(void)
+{
+ VALUE mBug = rb_define_module("Bug");
+ VALUE klass = rb_define_class_under(mBug, "Struct", rb_cStruct);
+ TEST_INIT_FUNCS(init);
+}
diff --git a/jni/ruby/ext/-test-/struct/member.c b/jni/ruby/ext/-test-/struct/member.c
new file mode 100644
index 0000000..1d40403
--- /dev/null
+++ b/jni/ruby/ext/-test-/struct/member.c
@@ -0,0 +1,18 @@
+#include "ruby.h"
+
+static VALUE
+bug_struct_get(VALUE obj, VALUE name)
+{
+ ID id = rb_check_id(&name);
+
+ if (!id) {
+ rb_name_error_str(name, "`%"PRIsVALUE"' is not a struct member", name);
+ }
+ return rb_struct_getmember(obj, id);
+}
+
+void
+Init_member(VALUE klass)
+{
+ rb_define_method(klass, "get", bug_struct_get, 1);
+}
diff --git a/jni/ruby/ext/-test-/symbol/Makefile b/jni/ruby/ext/-test-/symbol/Makefile
new file mode 100644
index 0000000..23e3a92
--- /dev/null
+++ b/jni/ruby/ext/-test-/symbol/Makefile
@@ -0,0 +1,267 @@
+
+SHELL = /bin/sh
+
+# V=0 quiet, V=1 verbose. other values don't work.
+V = 0
+Q1 = $(V:1=)
+Q = $(Q1:0=@)
+ECHO1 = $(V:1=@:)
+ECHO = $(ECHO1:0=@echo)
+NULLCMD = :
+
+#### Start of system configuration section. ####
+top_srcdir = $(topdir)/.
+srcdir = $(top_srcdir)/ext/-test-/symbol
+topdir = ../../..
+hdrdir = $(top_srcdir)/include
+arch_hdrdir = $(extout)/include/$(arch)
+PATH_SEPARATOR = :
+VPATH = $(srcdir):$(arch_hdrdir)/ruby:$(hdrdir)/ruby
+RUBYLIB =
+RUBYOPT = -
+prefix = $(DESTDIR)/usr/local
+rubysitearchprefix = $(rubylibprefix)/$(sitearch)
+rubyarchprefix = $(rubylibprefix)/$(arch)
+rubylibprefix = $(libdir)/$(RUBY_BASE_NAME)
+exec_prefix = $(prefix)
+vendorarchhdrdir = $(vendorhdrdir)/$(sitearch)
+sitearchhdrdir = $(sitehdrdir)/$(sitearch)
+rubyarchhdrdir = $(rubyhdrdir)/$(arch)
+vendorhdrdir = $(rubyhdrdir)/vendor_ruby
+sitehdrdir = $(rubyhdrdir)/site_ruby
+rubyhdrdir = $(includedir)/$(RUBY_VERSION_NAME)
+vendorarchdir = $(vendorlibdir)/$(sitearch)
+vendorlibdir = $(vendordir)/$(ruby_version)
+vendordir = $(rubylibprefix)/vendor_ruby
+sitearchdir = $(sitelibdir)/$(sitearch)
+sitelibdir = $(sitedir)/$(ruby_version)
+sitedir = $(rubylibprefix)/site_ruby
+rubyarchdir = $(rubylibdir)/$(arch)
+rubylibdir = $(rubylibprefix)/$(ruby_version)
+sitearchincludedir = $(includedir)/$(sitearch)
+archincludedir = $(includedir)/$(arch)
+sitearchlibdir = $(libdir)/$(sitearch)
+archlibdir = $(libdir)/$(arch)
+ridir = $(datarootdir)/$(RI_BASE_NAME)
+mandir = $(datarootdir)/man
+localedir = $(datarootdir)/locale
+libdir = $(exec_prefix)/lib
+psdir = $(docdir)
+pdfdir = $(docdir)
+dvidir = $(docdir)
+htmldir = $(docdir)
+infodir = $(datarootdir)/info
+docdir = $(datarootdir)/doc/$(PACKAGE)
+oldincludedir = $(DESTDIR)/usr/include
+includedir = $(prefix)/include
+localstatedir = $(prefix)/var
+sharedstatedir = $(prefix)/com
+sysconfdir = $(prefix)/etc
+datadir = $(datarootdir)
+datarootdir = $(prefix)/share
+libexecdir = $(exec_prefix)/libexec
+sbindir = $(exec_prefix)/sbin
+bindir = $(exec_prefix)/bin
+archdir = $(rubyarchdir)
+
+
+CC = gcc
+CXX = g++
+LIBRUBY = $(LIBRUBY_SO)
+LIBRUBY_A = lib$(RUBY_SO_NAME)-static.a
+LIBRUBYARG_SHARED = -Wl,-R$(libdir) -L$(libdir) -l$(RUBY_SO_NAME)
+LIBRUBYARG_STATIC = -Wl,-R$(libdir) -L$(libdir) -l$(RUBY_SO_NAME)-static
+empty =
+OUTFLAG = -o $(empty)
+COUTFLAG = -o $(empty)
+
+RUBY_EXTCONF_H = extconf.h
+cflags = $(optflags) $(debugflags) $(warnflags)
+optflags = -O3 -fno-fast-math
+debugflags = -ggdb3
+warnflags = -Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wunused-variable -Wpointer-arith -Wwrite-strings -Wdeclaration-after-statement -Wimplicit-function-declaration -Wdeprecated-declarations -Wno-packed-bitfield-compat
+CCDLFLAGS = -fPIC
+CFLAGS = $(CCDLFLAGS) $(cflags) -fPIC $(ARCH_FLAG)
+INCFLAGS = -I. -I$(arch_hdrdir) -I$(hdrdir) -I$(srcdir)
+DEFS =
+CPPFLAGS = -DRUBY_EXTCONF_H=\"$(RUBY_EXTCONF_H)\" $(DEFS) $(cppflags)
+CXXFLAGS = $(CCDLFLAGS) $(cxxflags) $(ARCH_FLAG)
+ldflags = -L. -fstack-protector -rdynamic -Wl,-export-dynamic
+dldflags =
+ARCH_FLAG =
+DLDFLAGS = $(ldflags) $(dldflags) $(ARCH_FLAG)
+LDSHARED = $(CC) -shared
+LDSHAREDXX = $(CXX) -shared
+AR = ar
+EXEEXT =
+
+RUBY_INSTALL_NAME = $(RUBY_BASE_NAME)
+RUBY_SO_NAME = ruby
+RUBYW_INSTALL_NAME =
+RUBY_VERSION_NAME = $(RUBY_BASE_NAME)-$(ruby_version)
+RUBYW_BASE_NAME = rubyw
+RUBY_BASE_NAME = ruby
+
+arch = x86_64-linux
+sitearch = $(arch)
+ruby_version = 2.2.0
+ruby = $(topdir)/miniruby -I'$(topdir)' -I'$(top_srcdir)/lib' -I'$(extout)/$(arch)' -I'$(extout)/common'
+RUBY = $(ruby)
+ruby_headers = $(hdrdir)/ruby.h $(hdrdir)/ruby/ruby.h $(hdrdir)/ruby/defines.h $(hdrdir)/ruby/missing.h $(hdrdir)/ruby/intern.h $(hdrdir)/ruby/st.h $(hdrdir)/ruby/subst.h $(arch_hdrdir)/ruby/config.h $(RUBY_EXTCONF_H)
+
+RM = rm -f
+RM_RF = $(RUBY) -run -e rm -- -rf
+RMDIRS = rmdir --ignore-fail-on-non-empty -p
+MAKEDIRS = /bin/mkdir -p
+INSTALL = /usr/bin/install -c
+INSTALL_PROG = $(INSTALL) -m 0755
+INSTALL_DATA = $(INSTALL) -m 644
+COPY = cp
+TOUCH = exit >
+
+#### End of system configuration section. ####
+
+preload =
+
+libpath = . $(topdir)
+LIBPATH = -L. -L$(topdir)
+DEFFILE =
+
+CLEANFILES = mkmf.log
+DISTCLEANFILES =
+DISTCLEANDIRS =
+
+extout = $(topdir)/.ext
+extout_prefix = $(extout)$(target_prefix)/
+target_prefix = /-test-
+LOCAL_LIBS =
+LIBS = $(LIBRUBYARG_SHARED) -lpthread -lgmp -ldl -lcrypt -lm -lc
+ORIG_SRCS = type.c init.c
+SRCS = $(ORIG_SRCS)
+OBJS = type.o init.o
+HDRS = $(srcdir)/extconf.h
+TARGET = symbol
+TARGET_NAME = symbol
+TARGET_ENTRY = Init_$(TARGET_NAME)
+DLLIB = $(TARGET).so
+EXTSTATIC =
+STATIC_LIB = $(TARGET).a
+
+TIMESTAMP_DIR = $(extout)/.timestamp
+BINDIR = $(extout)/bin
+RUBYCOMMONDIR = $(extout)/common
+RUBYLIBDIR = $(RUBYCOMMONDIR)$(target_prefix)
+RUBYARCHDIR = $(extout)/$(arch)$(target_prefix)
+HDRDIR = $(extout)/include/ruby$(target_prefix)
+ARCHHDRDIR = $(extout)/include/$(arch)/ruby$(target_prefix)
+
+TARGET_SO = $(RUBYARCHDIR)/$(DLLIB)
+CLEANLIBS = $(RUBYARCHDIR)/$(TARGET).so
+CLEANOBJS = *.o *.bak
+
+all: install
+static: all
+.PHONY: all install static install-so install-rb
+.PHONY: clean clean-so clean-static clean-rb
+
+clean-static::
+clean-rb-default::
+clean-rb::
+clean-so::
+clean: clean-so clean-static clean-rb-default clean-rb
+ -$(Q)$(RM) $(CLEANLIBS) $(CLEANOBJS) $(CLEANFILES) .*.time
+
+distclean-rb-default::
+distclean-rb::
+distclean-so::
+distclean-static::
+distclean: clean distclean-so distclean-static distclean-rb-default distclean-rb
+ -$(Q)$(RM) Makefile $(RUBY_EXTCONF_H) conftest.* mkmf.log
+ -$(Q)$(RM) core ruby$(EXEEXT) *~ $(DISTCLEANFILES)
+ -$(Q)$(RMDIRS) $(DISTCLEANDIRS) 2> /dev/null || true
+
+realclean: distclean
+install: install-so install-rb
+
+install-so: $(RUBYARCHDIR)/$(DLLIB)
+clean-so::
+ -$(Q)$(RM) $(RUBYARCHDIR)/$(DLLIB)
+ -$(Q)$(RMDIRS) $(RUBYARCHDIR) 2> /dev/null || true
+clean-static::
+ -$(Q)$(RM) $(STATIC_LIB)
+install-rb: pre-install-rb install-rb-default
+install-rb-default: pre-install-rb-default
+pre-install-rb: Makefile
+pre-install-rb-default: Makefile
+pre-install-rb-default:
+ @$(NULLCMD)
+$(TIMESTAMP_DIR)/.RUBYARCHDIR.-.-test-.time:
+ $(Q) $(MAKEDIRS) $(@D) $(RUBYARCHDIR)
+ $(Q) $(TOUCH) $@
+
+site-install: site-install-so site-install-rb
+site-install-so: install-so
+site-install-rb: install-rb
+
+.SUFFIXES: .c .m .cc .mm .cxx .cpp .o .S
+
+.cc.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<
+
+.cc.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -S $<
+
+.mm.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<
+
+.mm.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -S $<
+
+.cxx.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<
+
+.cxx.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -S $<
+
+.cpp.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<
+
+.cpp.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -S $<
+
+.c.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -c $<
+
+.c.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -S $<
+
+.m.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -c $<
+
+.m.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -S $<
+
+$(RUBYARCHDIR)/$(DLLIB): $(OBJS) Makefile $(TIMESTAMP_DIR)/.RUBYARCHDIR.-.-test-.time
+ $(ECHO) linking shared-object -test-/$(DLLIB)
+ -$(Q)$(RM) $(@)
+ $(Q) $(LDSHARED) -o $@ $(OBJS) $(LIBPATH) $(DLDFLAGS) $(LOCAL_LIBS) $(LIBS)
+
+$(STATIC_LIB): $(OBJS)
+ -$(Q)$(RM) $(@)
+ $(ECHO) linking static-library $(@)
+ $(Q) $(AR) cru $@ $(OBJS)
+ -$(Q)ranlib $(@) 2> /dev/null || true
+
+$(OBJS): $(HDRS) $(ruby_headers)
diff --git a/jni/ruby/ext/-test-/symbol/extconf.h b/jni/ruby/ext/-test-/symbol/extconf.h
new file mode 100644
index 0000000..cb923dc
--- /dev/null
+++ b/jni/ruby/ext/-test-/symbol/extconf.h
@@ -0,0 +1,4 @@
+#ifndef EXTCONF_H
+#define EXTCONF_H
+#define TEST_INIT_FUNCS(X) X(type)
+#endif
diff --git a/jni/ruby/ext/-test-/symbol/extconf.rb b/jni/ruby/ext/-test-/symbol/extconf.rb
new file mode 100644
index 0000000..fc00ec9
--- /dev/null
+++ b/jni/ruby/ext/-test-/symbol/extconf.rb
@@ -0,0 +1,7 @@
+$srcs = Dir[File.join($srcdir, "*.{#{SRC_EXT.join(%q{,})}}")]
+inits = $srcs.map {|s| File.basename(s, ".*")}
+inits.delete("init")
+inits.map! {|s|"X(#{s})"}
+$defs << "-DTEST_INIT_FUNCS(X)=\"#{inits.join(' ')}\""
+have_func("rb_pin_dynamic_symbol")
+create_makefile("-test-/symbol")
diff --git a/jni/ruby/ext/-test-/symbol/init.c b/jni/ruby/ext/-test-/symbol/init.c
new file mode 100644
index 0000000..9e42e1a
--- /dev/null
+++ b/jni/ruby/ext/-test-/symbol/init.c
@@ -0,0 +1,25 @@
+#include "ruby.h"
+
+#define init(n) {void Init_##n(VALUE klass); Init_##n(klass);}
+
+static VALUE
+sym_find(VALUE dummy, VALUE sym)
+{
+ return rb_check_symbol(&sym);
+}
+
+static VALUE
+sym_pinneddown_p(VALUE dummy, VALUE sym)
+{
+ return rb_check_id(&sym) ? Qtrue : Qfalse;
+}
+
+void
+Init_symbol(void)
+{
+ VALUE mBug = rb_define_module("Bug");
+ VALUE klass = rb_define_class_under(mBug, "Symbol", rb_cSymbol);
+ rb_define_singleton_method(klass, "find", sym_find, 1);
+ rb_define_singleton_method(klass, "pinneddown?", sym_pinneddown_p, 1);
+ TEST_INIT_FUNCS(init);
+}
diff --git a/jni/ruby/ext/-test-/symbol/type.c b/jni/ruby/ext/-test-/symbol/type.c
new file mode 100644
index 0000000..e51e09e
--- /dev/null
+++ b/jni/ruby/ext/-test-/symbol/type.c
@@ -0,0 +1,78 @@
+#include "ruby.h"
+
+#ifdef HAVE_RB_IS_CONST_NAME
+# define get_symbol_type(type, t, name) do { \
+ ID id = rb_check_id(&name); \
+ t = (id ? rb_is_##type##_id(id) : rb_is_##type##_name(name)); \
+ } while (0)
+#else
+# define get_symbol_type(type, t, name) do { \
+ t = rb_is_##type##_id(rb_to_id(name)); \
+ } while (0)
+#endif
+
+#define define_symbol_type_p(type) \
+static VALUE \
+bug_sym_##type##_p(VALUE self, VALUE name) \
+{ \
+ int t; \
+ get_symbol_type(type, t, name); \
+ return (t ? Qtrue : Qfalse); \
+}
+
+#define declare_symbol_type_p(type) \
+ rb_define_singleton_method(klass, #type"?", bug_sym_##type##_p, 1);
+
+#define FOREACH_ID_TYPES(x) x(const) x(class) x(global) x(instance) x(attrset) x(local) x(junk)
+
+FOREACH_ID_TYPES(define_symbol_type_p)
+
+static VALUE
+bug_sym_attrset(VALUE self, VALUE name)
+{
+ ID id = rb_to_id(name);
+ id = rb_id_attrset(id);
+ return ID2SYM(id);
+}
+
+static VALUE
+bug_id2str(VALUE self, VALUE sym)
+{
+ return rb_sym2str(sym);
+}
+
+static VALUE
+bug_static_p(VALUE self, VALUE sym)
+{
+ return STATIC_SYM_P(sym) ? Qtrue : Qfalse;
+}
+
+static VALUE
+bug_dynamic_p(VALUE self, VALUE sym)
+{
+ return DYNAMIC_SYM_P(sym) ? Qtrue : Qfalse;
+}
+
+#ifdef HAVE_RB_PIN_DYNAMIC_SYMBOL
+ID rb_pin_dynamic_symbol(VALUE);
+
+static VALUE
+bug_pindown(VALUE self, VALUE sym)
+{
+ rb_pin_dynamic_symbol(sym);
+ return sym;
+}
+#endif
+
+void
+Init_type(VALUE klass)
+{
+ FOREACH_ID_TYPES(declare_symbol_type_p);
+ rb_define_singleton_method(klass, "attrset", bug_sym_attrset, 1);
+ rb_define_singleton_method(klass, "id2str", bug_id2str, 1);
+ rb_define_singleton_method(klass, "static?", bug_static_p, 1);
+ rb_define_singleton_method(klass, "dynamic?", bug_dynamic_p, 1);
+#ifdef HAVE_RB_PIN_DYNAMIC_SYMBOL
+ rb_define_singleton_method(klass, "pindown", bug_pindown, 1);
+#endif
+}
diff --git a/jni/ruby/ext/-test-/tracepoint/Makefile b/jni/ruby/ext/-test-/tracepoint/Makefile
new file mode 100644
index 0000000..fd1f367
--- /dev/null
+++ b/jni/ruby/ext/-test-/tracepoint/Makefile
@@ -0,0 +1,291 @@
+
+SHELL = /bin/sh
+
+# V=0 quiet, V=1 verbose. other values don't work.
+V = 0
+Q1 = $(V:1=)
+Q = $(Q1:0=@)
+ECHO1 = $(V:1=@:)
+ECHO = $(ECHO1:0=@echo)
+NULLCMD = :
+
+#### Start of system configuration section. ####
+top_srcdir = $(topdir)/.
+srcdir = $(top_srcdir)/ext/-test-/tracepoint
+topdir = ../../..
+hdrdir = $(top_srcdir)/include
+arch_hdrdir = $(extout)/include/$(arch)
+PATH_SEPARATOR = :
+VPATH = $(srcdir):$(arch_hdrdir)/ruby:$(hdrdir)/ruby
+RUBYLIB =
+RUBYOPT = -
+prefix = $(DESTDIR)/usr/local
+rubysitearchprefix = $(rubylibprefix)/$(sitearch)
+rubyarchprefix = $(rubylibprefix)/$(arch)
+rubylibprefix = $(libdir)/$(RUBY_BASE_NAME)
+exec_prefix = $(prefix)
+vendorarchhdrdir = $(vendorhdrdir)/$(sitearch)
+sitearchhdrdir = $(sitehdrdir)/$(sitearch)
+rubyarchhdrdir = $(rubyhdrdir)/$(arch)
+vendorhdrdir = $(rubyhdrdir)/vendor_ruby
+sitehdrdir = $(rubyhdrdir)/site_ruby
+rubyhdrdir = $(includedir)/$(RUBY_VERSION_NAME)
+vendorarchdir = $(vendorlibdir)/$(sitearch)
+vendorlibdir = $(vendordir)/$(ruby_version)
+vendordir = $(rubylibprefix)/vendor_ruby
+sitearchdir = $(sitelibdir)/$(sitearch)
+sitelibdir = $(sitedir)/$(ruby_version)
+sitedir = $(rubylibprefix)/site_ruby
+rubyarchdir = $(rubylibdir)/$(arch)
+rubylibdir = $(rubylibprefix)/$(ruby_version)
+sitearchincludedir = $(includedir)/$(sitearch)
+archincludedir = $(includedir)/$(arch)
+sitearchlibdir = $(libdir)/$(sitearch)
+archlibdir = $(libdir)/$(arch)
+ridir = $(datarootdir)/$(RI_BASE_NAME)
+mandir = $(datarootdir)/man
+localedir = $(datarootdir)/locale
+libdir = $(exec_prefix)/lib
+psdir = $(docdir)
+pdfdir = $(docdir)
+dvidir = $(docdir)
+htmldir = $(docdir)
+infodir = $(datarootdir)/info
+docdir = $(datarootdir)/doc/$(PACKAGE)
+oldincludedir = $(DESTDIR)/usr/include
+includedir = $(prefix)/include
+localstatedir = $(prefix)/var
+sharedstatedir = $(prefix)/com
+sysconfdir = $(prefix)/etc
+datadir = $(datarootdir)
+datarootdir = $(prefix)/share
+libexecdir = $(exec_prefix)/libexec
+sbindir = $(exec_prefix)/sbin
+bindir = $(exec_prefix)/bin
+archdir = $(rubyarchdir)
+
+
+CC = gcc
+CXX = g++
+LIBRUBY = $(LIBRUBY_SO)
+LIBRUBY_A = lib$(RUBY_SO_NAME)-static.a
+LIBRUBYARG_SHARED = -Wl,-R$(libdir) -L$(libdir) -l$(RUBY_SO_NAME)
+LIBRUBYARG_STATIC = -Wl,-R$(libdir) -L$(libdir) -l$(RUBY_SO_NAME)-static
+empty =
+OUTFLAG = -o $(empty)
+COUTFLAG = -o $(empty)
+
+RUBY_EXTCONF_H = extconf.h
+cflags = $(optflags) $(debugflags) $(warnflags)
+optflags = -O3 -fno-fast-math
+debugflags = -ggdb3
+warnflags = -Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wunused-variable -Wpointer-arith -Wwrite-strings -Wdeclaration-after-statement -Wimplicit-function-declaration -Wdeprecated-declarations -Wno-packed-bitfield-compat
+CCDLFLAGS = -fPIC
+CFLAGS = $(CCDLFLAGS) $(cflags) -fPIC $(ARCH_FLAG)
+INCFLAGS = -I. -I$(arch_hdrdir) -I$(hdrdir) -I$(srcdir)
+DEFS =
+CPPFLAGS = -DRUBY_EXTCONF_H=\"$(RUBY_EXTCONF_H)\" $(DEFS) $(cppflags)
+CXXFLAGS = $(CCDLFLAGS) $(cxxflags) $(ARCH_FLAG)
+ldflags = -L. -fstack-protector -rdynamic -Wl,-export-dynamic
+dldflags =
+ARCH_FLAG =
+DLDFLAGS = $(ldflags) $(dldflags) $(ARCH_FLAG)
+LDSHARED = $(CC) -shared
+LDSHAREDXX = $(CXX) -shared
+AR = ar
+EXEEXT =
+
+RUBY_INSTALL_NAME = $(RUBY_BASE_NAME)
+RUBY_SO_NAME = ruby
+RUBYW_INSTALL_NAME =
+RUBY_VERSION_NAME = $(RUBY_BASE_NAME)-$(ruby_version)
+RUBYW_BASE_NAME = rubyw
+RUBY_BASE_NAME = ruby
+
+arch = x86_64-linux
+sitearch = $(arch)
+ruby_version = 2.2.0
+ruby = $(topdir)/miniruby -I'$(topdir)' -I'$(top_srcdir)/lib' -I'$(extout)/$(arch)' -I'$(extout)/common'
+RUBY = $(ruby)
+ruby_headers = $(hdrdir)/ruby.h $(hdrdir)/ruby/ruby.h $(hdrdir)/ruby/defines.h $(hdrdir)/ruby/missing.h $(hdrdir)/ruby/intern.h $(hdrdir)/ruby/st.h $(hdrdir)/ruby/subst.h $(arch_hdrdir)/ruby/config.h $(RUBY_EXTCONF_H)
+
+RM = rm -f
+RM_RF = $(RUBY) -run -e rm -- -rf
+RMDIRS = rmdir --ignore-fail-on-non-empty -p
+MAKEDIRS = /bin/mkdir -p
+INSTALL = /usr/bin/install -c
+INSTALL_PROG = $(INSTALL) -m 0755
+INSTALL_DATA = $(INSTALL) -m 644
+COPY = cp
+TOUCH = exit >
+
+#### End of system configuration section. ####
+
+preload =
+
+libpath = . $(topdir)
+LIBPATH = -L. -L$(topdir)
+DEFFILE =
+
+CLEANFILES = mkmf.log
+DISTCLEANFILES =
+DISTCLEANDIRS =
+
+extout = $(topdir)/.ext
+extout_prefix = $(extout)$(target_prefix)/
+target_prefix = /-test-
+LOCAL_LIBS =
+LIBS = $(LIBRUBYARG_SHARED) -lpthread -lgmp -ldl -lcrypt -lm -lc
+ORIG_SRCS = gc_hook.c tracepoint.c
+SRCS = $(ORIG_SRCS)
+OBJS = gc_hook.o tracepoint.o
+HDRS = $(srcdir)/extconf.h
+TARGET = tracepoint
+TARGET_NAME = tracepoint
+TARGET_ENTRY = Init_$(TARGET_NAME)
+DLLIB = $(TARGET).so
+EXTSTATIC =
+STATIC_LIB = $(TARGET).a
+
+TIMESTAMP_DIR = $(extout)/.timestamp
+BINDIR = $(extout)/bin
+RUBYCOMMONDIR = $(extout)/common
+RUBYLIBDIR = $(RUBYCOMMONDIR)$(target_prefix)
+RUBYARCHDIR = $(extout)/$(arch)$(target_prefix)
+HDRDIR = $(extout)/include/ruby$(target_prefix)
+ARCHHDRDIR = $(extout)/include/$(arch)/ruby$(target_prefix)
+
+TARGET_SO = $(RUBYARCHDIR)/$(DLLIB)
+CLEANLIBS = $(RUBYARCHDIR)/$(TARGET).so
+CLEANOBJS = *.o *.bak
+
+all: install
+static: all
+.PHONY: all install static install-so install-rb
+.PHONY: clean clean-so clean-static clean-rb
+
+clean-static::
+clean-rb-default::
+clean-rb::
+clean-so::
+clean: clean-so clean-static clean-rb-default clean-rb
+ -$(Q)$(RM) $(CLEANLIBS) $(CLEANOBJS) $(CLEANFILES) .*.time
+
+distclean-rb-default::
+distclean-rb::
+distclean-so::
+distclean-static::
+distclean: clean distclean-so distclean-static distclean-rb-default distclean-rb
+ -$(Q)$(RM) Makefile $(RUBY_EXTCONF_H) conftest.* mkmf.log
+ -$(Q)$(RM) core ruby$(EXEEXT) *~ $(DISTCLEANFILES)
+ -$(Q)$(RMDIRS) $(DISTCLEANDIRS) 2> /dev/null || true
+
+realclean: distclean
+install: install-so install-rb
+
+install-so: $(RUBYARCHDIR)/$(DLLIB)
+clean-so::
+ -$(Q)$(RM) $(RUBYARCHDIR)/$(DLLIB)
+ -$(Q)$(RMDIRS) $(RUBYARCHDIR) 2> /dev/null || true
+clean-static::
+ -$(Q)$(RM) $(STATIC_LIB)
+install-rb: pre-install-rb install-rb-default
+install-rb-default: pre-install-rb-default
+pre-install-rb: Makefile
+pre-install-rb-default: Makefile
+pre-install-rb-default:
+ @$(NULLCMD)
+$(TIMESTAMP_DIR)/.RUBYARCHDIR.-.-test-.time:
+ $(Q) $(MAKEDIRS) $(@D) $(RUBYARCHDIR)
+ $(Q) $(TOUCH) $@
+
+site-install: site-install-so site-install-rb
+site-install-so: install-so
+site-install-rb: install-rb
+
+.SUFFIXES: .c .m .cc .mm .cxx .cpp .o .S
+
+.cc.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<
+
+.cc.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -S $<
+
+.mm.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<
+
+.mm.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -S $<
+
+.cxx.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<
+
+.cxx.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -S $<
+
+.cpp.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<
+
+.cpp.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -S $<
+
+.c.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -c $<
+
+.c.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -S $<
+
+.m.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -c $<
+
+.m.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -S $<
+
+$(RUBYARCHDIR)/$(DLLIB): $(OBJS) Makefile $(TIMESTAMP_DIR)/.RUBYARCHDIR.-.-test-.time
+ $(ECHO) linking shared-object -test-/$(DLLIB)
+ -$(Q)$(RM) $(@)
+ $(Q) $(LDSHARED) -o $@ $(OBJS) $(LIBPATH) $(DLDFLAGS) $(LOCAL_LIBS) $(LIBS)
+
+$(STATIC_LIB): $(OBJS)
+ -$(Q)$(RM) $(@)
+ $(ECHO) linking static-library $(@)
+ $(Q) $(AR) cru $@ $(OBJS)
+ -$(Q)ranlib $(@) 2> /dev/null || true
+
+###
+$(OBJS): $(RUBY_EXTCONF_H)
+
+# AUTOGENERATED DEPENDENCIES START
+gc_hook.o: $(RUBY_EXTCONF_H)
+gc_hook.o: $(arch_hdrdir)/ruby/config.h
+gc_hook.o: $(hdrdir)/ruby/debug.h
+gc_hook.o: $(hdrdir)/ruby/defines.h
+gc_hook.o: $(hdrdir)/ruby/intern.h
+gc_hook.o: $(hdrdir)/ruby/missing.h
+gc_hook.o: $(hdrdir)/ruby/ruby.h
+gc_hook.o: $(hdrdir)/ruby/st.h
+gc_hook.o: $(hdrdir)/ruby/subst.h
+gc_hook.o: gc_hook.c
+tracepoint.o: $(RUBY_EXTCONF_H)
+tracepoint.o: $(arch_hdrdir)/ruby/config.h
+tracepoint.o: $(hdrdir)/ruby/debug.h
+tracepoint.o: $(hdrdir)/ruby/defines.h
+tracepoint.o: $(hdrdir)/ruby/intern.h
+tracepoint.o: $(hdrdir)/ruby/missing.h
+tracepoint.o: $(hdrdir)/ruby/ruby.h
+tracepoint.o: $(hdrdir)/ruby/st.h
+tracepoint.o: $(hdrdir)/ruby/subst.h
+tracepoint.o: tracepoint.c
+# AUTOGENERATED DEPENDENCIES END
diff --git a/jni/ruby/ext/-test-/tracepoint/depend b/jni/ruby/ext/-test-/tracepoint/depend
new file mode 100644
index 0000000..741bad0
--- /dev/null
+++ b/jni/ruby/ext/-test-/tracepoint/depend
@@ -0,0 +1,22 @@
+# AUTOGENERATED DEPENDENCIES START
+gc_hook.o: $(RUBY_EXTCONF_H)
+gc_hook.o: $(arch_hdrdir)/ruby/config.h
+gc_hook.o: $(hdrdir)/ruby/debug.h
+gc_hook.o: $(hdrdir)/ruby/defines.h
+gc_hook.o: $(hdrdir)/ruby/intern.h
+gc_hook.o: $(hdrdir)/ruby/missing.h
+gc_hook.o: $(hdrdir)/ruby/ruby.h
+gc_hook.o: $(hdrdir)/ruby/st.h
+gc_hook.o: $(hdrdir)/ruby/subst.h
+gc_hook.o: gc_hook.c
+tracepoint.o: $(RUBY_EXTCONF_H)
+tracepoint.o: $(arch_hdrdir)/ruby/config.h
+tracepoint.o: $(hdrdir)/ruby/debug.h
+tracepoint.o: $(hdrdir)/ruby/defines.h
+tracepoint.o: $(hdrdir)/ruby/intern.h
+tracepoint.o: $(hdrdir)/ruby/missing.h
+tracepoint.o: $(hdrdir)/ruby/ruby.h
+tracepoint.o: $(hdrdir)/ruby/st.h
+tracepoint.o: $(hdrdir)/ruby/subst.h
+tracepoint.o: tracepoint.c
+# AUTOGENERATED DEPENDENCIES END
diff --git a/jni/ruby/ext/-test-/tracepoint/extconf.h b/jni/ruby/ext/-test-/tracepoint/extconf.h
new file mode 100644
index 0000000..cda0cc8
--- /dev/null
+++ b/jni/ruby/ext/-test-/tracepoint/extconf.h
@@ -0,0 +1,3 @@
+#ifndef EXTCONF_H
+#define EXTCONF_H
+#endif
diff --git a/jni/ruby/ext/-test-/tracepoint/extconf.rb b/jni/ruby/ext/-test-/tracepoint/extconf.rb
new file mode 100644
index 0000000..c0c2399
--- /dev/null
+++ b/jni/ruby/ext/-test-/tracepoint/extconf.rb
@@ -0,0 +1 @@
+create_makefile("-test-/tracepoint")
diff --git a/jni/ruby/ext/-test-/tracepoint/gc_hook.c b/jni/ruby/ext/-test-/tracepoint/gc_hook.c
new file mode 100644
index 0000000..6d8485e
--- /dev/null
+++ b/jni/ruby/ext/-test-/tracepoint/gc_hook.c
@@ -0,0 +1,80 @@
+#include "ruby/ruby.h"
+#include "ruby/debug.h"
+
+static int invoking; /* TODO: should not be global variable */
+
+static VALUE
+invoke_proc_ensure(void *dmy)
+{
+ invoking = 0;
+ return Qnil;
+}
+
+static VALUE
+invoke_proc_begin(VALUE proc)
+{
+ return rb_proc_call(proc, rb_ary_new());
+}
+
+static void
+invoke_proc(void *data)
+{
+ VALUE proc = (VALUE)data;
+ invoking += 1;
+ rb_ensure(invoke_proc_begin, proc, invoke_proc_ensure, 0);
+}
+
+static void
+gc_start_end_i(VALUE tpval, void *data)
+{
+ if (0) {
+ rb_trace_arg_t *tparg = rb_tracearg_from_tracepoint(tpval);
+ fprintf(stderr, "trace: %s\n", rb_tracearg_event_flag(tparg) == RUBY_INTERNAL_EVENT_GC_START ? "gc_start" : "gc_end");
+ }
+
+ if (invoking == 0) {
+ rb_postponed_job_register(0, invoke_proc, data);
+ }
+}
+
+static VALUE
+set_gc_hook(VALUE module, VALUE proc, rb_event_flag_t event, const char *tp_str, const char *proc_str)
+{
+ VALUE tpval;
+ ID tp_key = rb_intern(tp_str);
+ ID proc_key = rb_intern(proc_str);
+
+ /* disable previous keys */
+ if (rb_ivar_defined(module, tp_key) != 0 &&
+ RTEST(tpval = rb_ivar_get(module, tp_key))) {
+ rb_tracepoint_disable(tpval);
+ rb_ivar_set(module, tp_key, Qnil);
+ rb_ivar_set(module, proc_key, Qnil);
+ }
+
+ if (RTEST(proc)) {
+ if (!rb_obj_is_proc(proc)) {
+ rb_raise(rb_eTypeError, "trace_func needs to be Proc");
+ }
+
+ tpval = rb_tracepoint_new(0, event, gc_start_end_i, (void *)proc);
+ rb_ivar_set(module, tp_key, tpval);
+ rb_ivar_set(module, proc_key, proc); /* GC guard */
+ rb_tracepoint_enable(tpval);
+ }
+
+ return proc;
+}
+
+static VALUE
+set_after_gc_start(VALUE module, VALUE proc)
+{
+ return set_gc_hook(module, proc, RUBY_INTERNAL_EVENT_GC_START,
+ "__set_after_gc_start_tpval__", "__set_after_gc_start_proc__");
+}
+
+void
+Init_gc_hook(VALUE module)
+{
+ rb_define_module_function(module, "after_gc_start_hook=", set_after_gc_start, 1);
+}
diff --git a/jni/ruby/ext/-test-/tracepoint/tracepoint.c b/jni/ruby/ext/-test-/tracepoint/tracepoint.c
new file mode 100644
index 0000000..aa8c212
--- /dev/null
+++ b/jni/ruby/ext/-test-/tracepoint/tracepoint.c
@@ -0,0 +1,96 @@
+#include "ruby/ruby.h"
+#include "ruby/debug.h"
+
+struct tracepoint_track {
+ size_t newobj_count;
+ size_t free_count;
+ size_t gc_start_count;
+ size_t gc_end_mark_count;
+ size_t gc_end_sweep_count;
+ size_t objects_count;
+ VALUE objects[10];
+};
+
+#define objects_max (sizeof(((struct tracepoint_track *)NULL)->objects)/sizeof(VALUE))
+
+static void
+tracepoint_track_objspace_events_i(VALUE tpval, void *data)
+{
+ rb_trace_arg_t *tparg = rb_tracearg_from_tracepoint(tpval);
+ struct tracepoint_track *track = data;
+
+ switch (rb_tracearg_event_flag(tparg)) {
+ case RUBY_INTERNAL_EVENT_NEWOBJ:
+ {
+ VALUE obj = rb_tracearg_object(tparg);
+ if (track->objects_count < objects_max)
+ track->objects[track->objects_count++] = obj;
+ track->newobj_count++;
+ break;
+ }
+ case RUBY_INTERNAL_EVENT_FREEOBJ:
+ {
+ track->free_count++;
+ break;
+ }
+ case RUBY_INTERNAL_EVENT_GC_START:
+ {
+ track->gc_start_count++;
+ break;
+ }
+ case RUBY_INTERNAL_EVENT_GC_END_MARK:
+ {
+ track->gc_end_mark_count++;
+ break;
+ }
+ case RUBY_INTERNAL_EVENT_GC_END_SWEEP:
+ {
+ track->gc_end_sweep_count++;
+ break;
+ }
+ default:
+ rb_raise(rb_eRuntimeError, "unknown event");
+ }
+}
+
+static VALUE
+tracepoint_track_objspace_events(VALUE self)
+{
+ struct tracepoint_track track = {0, 0, 0, 0, 0,};
+ VALUE tpval = rb_tracepoint_new(0, RUBY_INTERNAL_EVENT_NEWOBJ | RUBY_INTERNAL_EVENT_FREEOBJ |
+ RUBY_INTERNAL_EVENT_GC_START | RUBY_INTERNAL_EVENT_GC_END_MARK |
+ RUBY_INTERNAL_EVENT_GC_END_SWEEP,
+ tracepoint_track_objspace_events_i, &track);
+ VALUE result = rb_ary_new();
+
+ rb_tracepoint_enable(tpval);
+ rb_ensure(rb_yield, Qundef, rb_tracepoint_disable, tpval);
+
+ rb_ary_push(result, SIZET2NUM(track.newobj_count));
+ rb_ary_push(result, SIZET2NUM(track.free_count));
+ rb_ary_push(result, SIZET2NUM(track.gc_start_count));
+ rb_ary_push(result, SIZET2NUM(track.gc_end_mark_count));
+ rb_ary_push(result, SIZET2NUM(track.gc_end_sweep_count));
+ rb_ary_cat(result, track.objects, track.objects_count);
+
+ return result;
+}
+
+static VALUE
+tracepoint_specify_normal_and_internal_events(VALUE self)
+{
+ VALUE tpval = rb_tracepoint_new(0, RUBY_INTERNAL_EVENT_NEWOBJ | RUBY_EVENT_CALL, 0, 0);
+ rb_tracepoint_enable(tpval);
+ return Qnil; /* should not be reached */
+}
+
+void Init_gc_hook(VALUE);
+
+void
+Init_tracepoint(void)
+{
+ VALUE mBug = rb_define_module("Bug");
+ Init_gc_hook(mBug);
+ rb_define_module_function(mBug, "tracepoint_track_objspace_events", tracepoint_track_objspace_events, 0);
+ rb_define_module_function(mBug, "tracepoint_specify_normal_and_internal_events", tracepoint_specify_normal_and_internal_events, 0);
+}
diff --git a/jni/ruby/ext/-test-/typeddata/Makefile b/jni/ruby/ext/-test-/typeddata/Makefile
new file mode 100644
index 0000000..9ce2421
--- /dev/null
+++ b/jni/ruby/ext/-test-/typeddata/Makefile
@@ -0,0 +1,267 @@
+
+SHELL = /bin/sh
+
+# V=0 quiet, V=1 verbose. other values don't work.
+V = 0
+Q1 = $(V:1=)
+Q = $(Q1:0=@)
+ECHO1 = $(V:1=@:)
+ECHO = $(ECHO1:0=@echo)
+NULLCMD = :
+
+#### Start of system configuration section. ####
+top_srcdir = $(topdir)/.
+srcdir = $(top_srcdir)/ext/-test-/typeddata
+topdir = ../../..
+hdrdir = $(top_srcdir)/include
+arch_hdrdir = $(extout)/include/$(arch)
+PATH_SEPARATOR = :
+VPATH = $(srcdir):$(arch_hdrdir)/ruby:$(hdrdir)/ruby
+RUBYLIB =
+RUBYOPT = -
+prefix = $(DESTDIR)/usr/local
+rubysitearchprefix = $(rubylibprefix)/$(sitearch)
+rubyarchprefix = $(rubylibprefix)/$(arch)
+rubylibprefix = $(libdir)/$(RUBY_BASE_NAME)
+exec_prefix = $(prefix)
+vendorarchhdrdir = $(vendorhdrdir)/$(sitearch)
+sitearchhdrdir = $(sitehdrdir)/$(sitearch)
+rubyarchhdrdir = $(rubyhdrdir)/$(arch)
+vendorhdrdir = $(rubyhdrdir)/vendor_ruby
+sitehdrdir = $(rubyhdrdir)/site_ruby
+rubyhdrdir = $(includedir)/$(RUBY_VERSION_NAME)
+vendorarchdir = $(vendorlibdir)/$(sitearch)
+vendorlibdir = $(vendordir)/$(ruby_version)
+vendordir = $(rubylibprefix)/vendor_ruby
+sitearchdir = $(sitelibdir)/$(sitearch)
+sitelibdir = $(sitedir)/$(ruby_version)
+sitedir = $(rubylibprefix)/site_ruby
+rubyarchdir = $(rubylibdir)/$(arch)
+rubylibdir = $(rubylibprefix)/$(ruby_version)
+sitearchincludedir = $(includedir)/$(sitearch)
+archincludedir = $(includedir)/$(arch)
+sitearchlibdir = $(libdir)/$(sitearch)
+archlibdir = $(libdir)/$(arch)
+ridir = $(datarootdir)/$(RI_BASE_NAME)
+mandir = $(datarootdir)/man
+localedir = $(datarootdir)/locale
+libdir = $(exec_prefix)/lib
+psdir = $(docdir)
+pdfdir = $(docdir)
+dvidir = $(docdir)
+htmldir = $(docdir)
+infodir = $(datarootdir)/info
+docdir = $(datarootdir)/doc/$(PACKAGE)
+oldincludedir = $(DESTDIR)/usr/include
+includedir = $(prefix)/include
+localstatedir = $(prefix)/var
+sharedstatedir = $(prefix)/com
+sysconfdir = $(prefix)/etc
+datadir = $(datarootdir)
+datarootdir = $(prefix)/share
+libexecdir = $(exec_prefix)/libexec
+sbindir = $(exec_prefix)/sbin
+bindir = $(exec_prefix)/bin
+archdir = $(rubyarchdir)
+
+
+CC = gcc
+CXX = g++
+LIBRUBY = $(LIBRUBY_SO)
+LIBRUBY_A = lib$(RUBY_SO_NAME)-static.a
+LIBRUBYARG_SHARED = -Wl,-R$(libdir) -L$(libdir) -l$(RUBY_SO_NAME)
+LIBRUBYARG_STATIC = -Wl,-R$(libdir) -L$(libdir) -l$(RUBY_SO_NAME)-static
+empty =
+OUTFLAG = -o $(empty)
+COUTFLAG = -o $(empty)
+
+RUBY_EXTCONF_H = extconf.h
+cflags = $(optflags) $(debugflags) $(warnflags)
+optflags = -O3 -fno-fast-math
+debugflags = -ggdb3
+warnflags = -Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wunused-variable -Wpointer-arith -Wwrite-strings -Wdeclaration-after-statement -Wimplicit-function-declaration -Wdeprecated-declarations -Wno-packed-bitfield-compat
+CCDLFLAGS = -fPIC
+CFLAGS = $(CCDLFLAGS) $(cflags) -fPIC $(ARCH_FLAG)
+INCFLAGS = -I. -I$(arch_hdrdir) -I$(hdrdir) -I$(srcdir)
+DEFS =
+CPPFLAGS = -DRUBY_EXTCONF_H=\"$(RUBY_EXTCONF_H)\" $(DEFS) $(cppflags)
+CXXFLAGS = $(CCDLFLAGS) $(cxxflags) $(ARCH_FLAG)
+ldflags = -L. -fstack-protector -rdynamic -Wl,-export-dynamic
+dldflags =
+ARCH_FLAG =
+DLDFLAGS = $(ldflags) $(dldflags) $(ARCH_FLAG)
+LDSHARED = $(CC) -shared
+LDSHAREDXX = $(CXX) -shared
+AR = ar
+EXEEXT =
+
+RUBY_INSTALL_NAME = $(RUBY_BASE_NAME)
+RUBY_SO_NAME = ruby
+RUBYW_INSTALL_NAME =
+RUBY_VERSION_NAME = $(RUBY_BASE_NAME)-$(ruby_version)
+RUBYW_BASE_NAME = rubyw
+RUBY_BASE_NAME = ruby
+
+arch = x86_64-linux
+sitearch = $(arch)
+ruby_version = 2.2.0
+ruby = $(topdir)/miniruby -I'$(topdir)' -I'$(top_srcdir)/lib' -I'$(extout)/$(arch)' -I'$(extout)/common'
+RUBY = $(ruby)
+ruby_headers = $(hdrdir)/ruby.h $(hdrdir)/ruby/ruby.h $(hdrdir)/ruby/defines.h $(hdrdir)/ruby/missing.h $(hdrdir)/ruby/intern.h $(hdrdir)/ruby/st.h $(hdrdir)/ruby/subst.h $(arch_hdrdir)/ruby/config.h $(RUBY_EXTCONF_H)
+
+RM = rm -f
+RM_RF = $(RUBY) -run -e rm -- -rf
+RMDIRS = rmdir --ignore-fail-on-non-empty -p
+MAKEDIRS = /bin/mkdir -p
+INSTALL = /usr/bin/install -c
+INSTALL_PROG = $(INSTALL) -m 0755
+INSTALL_DATA = $(INSTALL) -m 644
+COPY = cp
+TOUCH = exit >
+
+#### End of system configuration section. ####
+
+preload =
+
+libpath = . $(topdir)
+LIBPATH = -L. -L$(topdir)
+DEFFILE =
+
+CLEANFILES = mkmf.log
+DISTCLEANFILES =
+DISTCLEANDIRS =
+
+extout = $(topdir)/.ext
+extout_prefix = $(extout)$(target_prefix)/
+target_prefix = /-test-/typeddata
+LOCAL_LIBS =
+LIBS = $(LIBRUBYARG_SHARED) -lpthread -lgmp -ldl -lcrypt -lm -lc
+ORIG_SRCS = typeddata.c
+SRCS = $(ORIG_SRCS)
+OBJS = typeddata.o
+HDRS = $(srcdir)/extconf.h
+TARGET = typeddata
+TARGET_NAME = typeddata
+TARGET_ENTRY = Init_$(TARGET_NAME)
+DLLIB = $(TARGET).so
+EXTSTATIC =
+STATIC_LIB = $(TARGET).a
+
+TIMESTAMP_DIR = $(extout)/.timestamp
+BINDIR = $(extout)/bin
+RUBYCOMMONDIR = $(extout)/common
+RUBYLIBDIR = $(RUBYCOMMONDIR)$(target_prefix)
+RUBYARCHDIR = $(extout)/$(arch)$(target_prefix)
+HDRDIR = $(extout)/include/ruby$(target_prefix)
+ARCHHDRDIR = $(extout)/include/$(arch)/ruby$(target_prefix)
+
+TARGET_SO = $(RUBYARCHDIR)/$(DLLIB)
+CLEANLIBS = $(RUBYARCHDIR)/$(TARGET).so
+CLEANOBJS = *.o *.bak
+
+all: install
+static: all
+.PHONY: all install static install-so install-rb
+.PHONY: clean clean-so clean-static clean-rb
+
+clean-static::
+clean-rb-default::
+clean-rb::
+clean-so::
+clean: clean-so clean-static clean-rb-default clean-rb
+ -$(Q)$(RM) $(CLEANLIBS) $(CLEANOBJS) $(CLEANFILES) .*.time
+
+distclean-rb-default::
+distclean-rb::
+distclean-so::
+distclean-static::
+distclean: clean distclean-so distclean-static distclean-rb-default distclean-rb
+ -$(Q)$(RM) Makefile $(RUBY_EXTCONF_H) conftest.* mkmf.log
+ -$(Q)$(RM) core ruby$(EXEEXT) *~ $(DISTCLEANFILES)
+ -$(Q)$(RMDIRS) $(DISTCLEANDIRS) 2> /dev/null || true
+
+realclean: distclean
+install: install-so install-rb
+
+install-so: $(RUBYARCHDIR)/$(DLLIB)
+clean-so::
+ -$(Q)$(RM) $(RUBYARCHDIR)/$(DLLIB)
+ -$(Q)$(RMDIRS) $(RUBYARCHDIR) 2> /dev/null || true
+clean-static::
+ -$(Q)$(RM) $(STATIC_LIB)
+install-rb: pre-install-rb install-rb-default
+install-rb-default: pre-install-rb-default
+pre-install-rb: Makefile
+pre-install-rb-default: Makefile
+pre-install-rb-default:
+ @$(NULLCMD)
+$(TIMESTAMP_DIR)/.RUBYARCHDIR.-.-test-.-.typeddata.time:
+ $(Q) $(MAKEDIRS) $(@D) $(RUBYARCHDIR)
+ $(Q) $(TOUCH) $@
+
+site-install: site-install-so site-install-rb
+site-install-so: install-so
+site-install-rb: install-rb
+
+.SUFFIXES: .c .m .cc .mm .cxx .cpp .o .S
+
+.cc.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<
+
+.cc.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -S $<
+
+.mm.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<
+
+.mm.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -S $<
+
+.cxx.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<
+
+.cxx.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -S $<
+
+.cpp.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<
+
+.cpp.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -S $<
+
+.c.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -c $<
+
+.c.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -S $<
+
+.m.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -c $<
+
+.m.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -S $<
+
+$(RUBYARCHDIR)/$(DLLIB): $(OBJS) Makefile $(TIMESTAMP_DIR)/.RUBYARCHDIR.-.-test-.-.typeddata.time
+ $(ECHO) linking shared-object -test-/typeddata/$(DLLIB)
+ -$(Q)$(RM) $(@)
+ $(Q) $(LDSHARED) -o $@ $(OBJS) $(LIBPATH) $(DLDFLAGS) $(LOCAL_LIBS) $(LIBS)
+
+$(STATIC_LIB): $(OBJS)
+ -$(Q)$(RM) $(@)
+ $(ECHO) linking static-library $(@)
+ $(Q) $(AR) cru $@ $(OBJS)
+ -$(Q)ranlib $(@) 2> /dev/null || true
+
+$(OBJS): $(HDRS) $(ruby_headers)
diff --git a/jni/ruby/ext/-test-/typeddata/extconf.h b/jni/ruby/ext/-test-/typeddata/extconf.h
new file mode 100644
index 0000000..cda0cc8
--- /dev/null
+++ b/jni/ruby/ext/-test-/typeddata/extconf.h
@@ -0,0 +1,3 @@
+#ifndef EXTCONF_H
+#define EXTCONF_H
+#endif
diff --git a/jni/ruby/ext/-test-/typeddata/extconf.rb b/jni/ruby/ext/-test-/typeddata/extconf.rb
new file mode 100644
index 0000000..02e3e41
--- /dev/null
+++ b/jni/ruby/ext/-test-/typeddata/extconf.rb
@@ -0,0 +1 @@
+create_makefile("-test-/typeddata/typeddata")
diff --git a/jni/ruby/ext/-test-/typeddata/typeddata.c b/jni/ruby/ext/-test-/typeddata/typeddata.c
new file mode 100644
index 0000000..1c5d677
--- /dev/null
+++ b/jni/ruby/ext/-test-/typeddata/typeddata.c
@@ -0,0 +1,20 @@
+#include <ruby.h>
+
+static const rb_data_type_t test_data = {
+ "typed_data",
+};
+
+static VALUE
+test_check(VALUE self, VALUE obj)
+{
+ rb_check_typeddata(obj, &test_data);
+ return obj;
+}
+
+void
+Init_typeddata(void)
+{
+ VALUE mBug = rb_define_module("Bug");
+ VALUE klass = rb_define_class_under(mBug, "TypedData", rb_cData);
+ rb_define_singleton_method(klass, "check", test_check, 1);
+}
diff --git a/jni/ruby/ext/-test-/wait_for_single_fd/Makefile b/jni/ruby/ext/-test-/wait_for_single_fd/Makefile
new file mode 100644
index 0000000..000b78b
--- /dev/null
+++ b/jni/ruby/ext/-test-/wait_for_single_fd/Makefile
@@ -0,0 +1,283 @@
+
+SHELL = /bin/sh
+
+# V=0 quiet, V=1 verbose. other values don't work.
+V = 0
+Q1 = $(V:1=)
+Q = $(Q1:0=@)
+ECHO1 = $(V:1=@:)
+ECHO = $(ECHO1:0=@echo)
+NULLCMD = :
+
+#### Start of system configuration section. ####
+top_srcdir = $(topdir)/.
+srcdir = $(top_srcdir)/ext/-test-/wait_for_single_fd
+topdir = ../../..
+hdrdir = $(top_srcdir)/include
+arch_hdrdir = $(extout)/include/$(arch)
+PATH_SEPARATOR = :
+VPATH = $(srcdir):$(arch_hdrdir)/ruby:$(hdrdir)/ruby
+RUBYLIB =
+RUBYOPT = -
+prefix = $(DESTDIR)/usr/local
+rubysitearchprefix = $(rubylibprefix)/$(sitearch)
+rubyarchprefix = $(rubylibprefix)/$(arch)
+rubylibprefix = $(libdir)/$(RUBY_BASE_NAME)
+exec_prefix = $(prefix)
+vendorarchhdrdir = $(vendorhdrdir)/$(sitearch)
+sitearchhdrdir = $(sitehdrdir)/$(sitearch)
+rubyarchhdrdir = $(rubyhdrdir)/$(arch)
+vendorhdrdir = $(rubyhdrdir)/vendor_ruby
+sitehdrdir = $(rubyhdrdir)/site_ruby
+rubyhdrdir = $(includedir)/$(RUBY_VERSION_NAME)
+vendorarchdir = $(vendorlibdir)/$(sitearch)
+vendorlibdir = $(vendordir)/$(ruby_version)
+vendordir = $(rubylibprefix)/vendor_ruby
+sitearchdir = $(sitelibdir)/$(sitearch)
+sitelibdir = $(sitedir)/$(ruby_version)
+sitedir = $(rubylibprefix)/site_ruby
+rubyarchdir = $(rubylibdir)/$(arch)
+rubylibdir = $(rubylibprefix)/$(ruby_version)
+sitearchincludedir = $(includedir)/$(sitearch)
+archincludedir = $(includedir)/$(arch)
+sitearchlibdir = $(libdir)/$(sitearch)
+archlibdir = $(libdir)/$(arch)
+ridir = $(datarootdir)/$(RI_BASE_NAME)
+mandir = $(datarootdir)/man
+localedir = $(datarootdir)/locale
+libdir = $(exec_prefix)/lib
+psdir = $(docdir)
+pdfdir = $(docdir)
+dvidir = $(docdir)
+htmldir = $(docdir)
+infodir = $(datarootdir)/info
+docdir = $(datarootdir)/doc/$(PACKAGE)
+oldincludedir = $(DESTDIR)/usr/include
+includedir = $(prefix)/include
+localstatedir = $(prefix)/var
+sharedstatedir = $(prefix)/com
+sysconfdir = $(prefix)/etc
+datadir = $(datarootdir)
+datarootdir = $(prefix)/share
+libexecdir = $(exec_prefix)/libexec
+sbindir = $(exec_prefix)/sbin
+bindir = $(exec_prefix)/bin
+archdir = $(rubyarchdir)
+
+
+CC = gcc
+CXX = g++
+LIBRUBY = $(LIBRUBY_SO)
+LIBRUBY_A = lib$(RUBY_SO_NAME)-static.a
+LIBRUBYARG_SHARED = -Wl,-R$(libdir) -L$(libdir) -l$(RUBY_SO_NAME)
+LIBRUBYARG_STATIC = -Wl,-R$(libdir) -L$(libdir) -l$(RUBY_SO_NAME)-static
+empty =
+OUTFLAG = -o $(empty)
+COUTFLAG = -o $(empty)
+
+RUBY_EXTCONF_H = extconf.h
+cflags = $(optflags) $(debugflags) $(warnflags)
+optflags = -O3 -fno-fast-math
+debugflags = -ggdb3
+warnflags = -Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wunused-variable -Wpointer-arith -Wwrite-strings -Wdeclaration-after-statement -Wimplicit-function-declaration -Wdeprecated-declarations -Wno-packed-bitfield-compat
+CCDLFLAGS = -fPIC
+CFLAGS = $(CCDLFLAGS) $(cflags) -fPIC $(ARCH_FLAG)
+INCFLAGS = -I. -I$(arch_hdrdir) -I$(hdrdir) -I$(srcdir)
+DEFS =
+CPPFLAGS = -DRUBY_EXTCONF_H=\"$(RUBY_EXTCONF_H)\" $(DEFS) $(cppflags)
+CXXFLAGS = $(CCDLFLAGS) $(cxxflags) $(ARCH_FLAG)
+ldflags = -L. -fstack-protector -rdynamic -Wl,-export-dynamic
+dldflags =
+ARCH_FLAG =
+DLDFLAGS = $(ldflags) $(dldflags) $(ARCH_FLAG)
+LDSHARED = $(CC) -shared
+LDSHAREDXX = $(CXX) -shared
+AR = ar
+EXEEXT =
+
+RUBY_INSTALL_NAME = $(RUBY_BASE_NAME)
+RUBY_SO_NAME = ruby
+RUBYW_INSTALL_NAME =
+RUBY_VERSION_NAME = $(RUBY_BASE_NAME)-$(ruby_version)
+RUBYW_BASE_NAME = rubyw
+RUBY_BASE_NAME = ruby
+
+arch = x86_64-linux
+sitearch = $(arch)
+ruby_version = 2.2.0
+ruby = $(topdir)/miniruby -I'$(topdir)' -I'$(top_srcdir)/lib' -I'$(extout)/$(arch)' -I'$(extout)/common'
+RUBY = $(ruby)
+ruby_headers = $(hdrdir)/ruby.h $(hdrdir)/ruby/ruby.h $(hdrdir)/ruby/defines.h $(hdrdir)/ruby/missing.h $(hdrdir)/ruby/intern.h $(hdrdir)/ruby/st.h $(hdrdir)/ruby/subst.h $(arch_hdrdir)/ruby/config.h $(RUBY_EXTCONF_H)
+
+RM = rm -f
+RM_RF = $(RUBY) -run -e rm -- -rf
+RMDIRS = rmdir --ignore-fail-on-non-empty -p
+MAKEDIRS = /bin/mkdir -p
+INSTALL = /usr/bin/install -c
+INSTALL_PROG = $(INSTALL) -m 0755
+INSTALL_DATA = $(INSTALL) -m 644
+COPY = cp
+TOUCH = exit >
+
+#### End of system configuration section. ####
+
+preload =
+
+libpath = . $(topdir)
+LIBPATH = -L. -L$(topdir)
+DEFFILE =
+
+CLEANFILES = mkmf.log
+DISTCLEANFILES =
+DISTCLEANDIRS =
+
+extout = $(topdir)/.ext
+extout_prefix = $(extout)$(target_prefix)/
+target_prefix = /-test-/wait_for_single_fd
+LOCAL_LIBS =
+LIBS = $(LIBRUBYARG_SHARED) -lpthread -lgmp -ldl -lcrypt -lm -lc
+ORIG_SRCS = wait_for_single_fd.c
+SRCS = $(ORIG_SRCS)
+OBJS = wait_for_single_fd.o
+HDRS = $(srcdir)/extconf.h
+TARGET = wait_for_single_fd
+TARGET_NAME = wait_for_single_fd
+TARGET_ENTRY = Init_$(TARGET_NAME)
+DLLIB = $(TARGET).so
+EXTSTATIC =
+STATIC_LIB = $(TARGET).a
+
+TIMESTAMP_DIR = $(extout)/.timestamp
+BINDIR = $(extout)/bin
+RUBYCOMMONDIR = $(extout)/common
+RUBYLIBDIR = $(RUBYCOMMONDIR)$(target_prefix)
+RUBYARCHDIR = $(extout)/$(arch)$(target_prefix)
+HDRDIR = $(extout)/include/ruby$(target_prefix)
+ARCHHDRDIR = $(extout)/include/$(arch)/ruby$(target_prefix)
+
+TARGET_SO = $(RUBYARCHDIR)/$(DLLIB)
+CLEANLIBS = $(RUBYARCHDIR)/$(TARGET).so
+CLEANOBJS = *.o *.bak
+
+all: install
+static: all
+.PHONY: all install static install-so install-rb
+.PHONY: clean clean-so clean-static clean-rb
+
+clean-static::
+clean-rb-default::
+clean-rb::
+clean-so::
+clean: clean-so clean-static clean-rb-default clean-rb
+ -$(Q)$(RM) $(CLEANLIBS) $(CLEANOBJS) $(CLEANFILES) .*.time
+
+distclean-rb-default::
+distclean-rb::
+distclean-so::
+distclean-static::
+distclean: clean distclean-so distclean-static distclean-rb-default distclean-rb
+ -$(Q)$(RM) Makefile $(RUBY_EXTCONF_H) conftest.* mkmf.log
+ -$(Q)$(RM) core ruby$(EXEEXT) *~ $(DISTCLEANFILES)
+ -$(Q)$(RMDIRS) $(DISTCLEANDIRS) 2> /dev/null || true
+
+realclean: distclean
+install: install-so install-rb
+
+install-so: $(RUBYARCHDIR)/$(DLLIB)
+clean-so::
+ -$(Q)$(RM) $(RUBYARCHDIR)/$(DLLIB)
+ -$(Q)$(RMDIRS) $(RUBYARCHDIR) 2> /dev/null || true
+clean-static::
+ -$(Q)$(RM) $(STATIC_LIB)
+install-rb: pre-install-rb install-rb-default
+install-rb-default: pre-install-rb-default
+pre-install-rb: Makefile
+pre-install-rb-default: Makefile
+pre-install-rb-default:
+ @$(NULLCMD)
+$(TIMESTAMP_DIR)/.RUBYARCHDIR.-.-test-.-.wait_for_single_fd.time:
+ $(Q) $(MAKEDIRS) $(@D) $(RUBYARCHDIR)
+ $(Q) $(TOUCH) $@
+
+site-install: site-install-so site-install-rb
+site-install-so: install-so
+site-install-rb: install-rb
+
+.SUFFIXES: .c .m .cc .mm .cxx .cpp .o .S
+
+.cc.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<
+
+.cc.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -S $<
+
+.mm.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<
+
+.mm.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -S $<
+
+.cxx.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<
+
+.cxx.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -S $<
+
+.cpp.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<
+
+.cpp.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -S $<
+
+.c.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -c $<
+
+.c.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -S $<
+
+.m.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -c $<
+
+.m.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -S $<
+
+$(RUBYARCHDIR)/$(DLLIB): $(OBJS) Makefile $(TIMESTAMP_DIR)/.RUBYARCHDIR.-.-test-.-.wait_for_single_fd.time
+ $(ECHO) linking shared-object -test-/wait_for_single_fd/$(DLLIB)
+ -$(Q)$(RM) $(@)
+ $(Q) $(LDSHARED) -o $@ $(OBJS) $(LIBPATH) $(DLDFLAGS) $(LOCAL_LIBS) $(LIBS)
+
+$(STATIC_LIB): $(OBJS)
+ -$(Q)$(RM) $(@)
+ $(ECHO) linking static-library $(@)
+ $(Q) $(AR) cru $@ $(OBJS)
+ -$(Q)ranlib $(@) 2> /dev/null || true
+
+###
+$(OBJS): $(RUBY_EXTCONF_H)
+
+# AUTOGENERATED DEPENDENCIES START
+wait_for_single_fd.o: $(RUBY_EXTCONF_H)
+wait_for_single_fd.o: $(arch_hdrdir)/ruby/config.h
+wait_for_single_fd.o: $(hdrdir)/ruby/defines.h
+wait_for_single_fd.o: $(hdrdir)/ruby/encoding.h
+wait_for_single_fd.o: $(hdrdir)/ruby/intern.h
+wait_for_single_fd.o: $(hdrdir)/ruby/io.h
+wait_for_single_fd.o: $(hdrdir)/ruby/missing.h
+wait_for_single_fd.o: $(hdrdir)/ruby/oniguruma.h
+wait_for_single_fd.o: $(hdrdir)/ruby/ruby.h
+wait_for_single_fd.o: $(hdrdir)/ruby/st.h
+wait_for_single_fd.o: $(hdrdir)/ruby/subst.h
+wait_for_single_fd.o: wait_for_single_fd.c
+# AUTOGENERATED DEPENDENCIES END
diff --git a/jni/ruby/ext/-test-/wait_for_single_fd/depend b/jni/ruby/ext/-test-/wait_for_single_fd/depend
new file mode 100644
index 0000000..fddd410
--- /dev/null
+++ b/jni/ruby/ext/-test-/wait_for_single_fd/depend
@@ -0,0 +1,14 @@
+# AUTOGENERATED DEPENDENCIES START
+wait_for_single_fd.o: $(RUBY_EXTCONF_H)
+wait_for_single_fd.o: $(arch_hdrdir)/ruby/config.h
+wait_for_single_fd.o: $(hdrdir)/ruby/defines.h
+wait_for_single_fd.o: $(hdrdir)/ruby/encoding.h
+wait_for_single_fd.o: $(hdrdir)/ruby/intern.h
+wait_for_single_fd.o: $(hdrdir)/ruby/io.h
+wait_for_single_fd.o: $(hdrdir)/ruby/missing.h
+wait_for_single_fd.o: $(hdrdir)/ruby/oniguruma.h
+wait_for_single_fd.o: $(hdrdir)/ruby/ruby.h
+wait_for_single_fd.o: $(hdrdir)/ruby/st.h
+wait_for_single_fd.o: $(hdrdir)/ruby/subst.h
+wait_for_single_fd.o: wait_for_single_fd.c
+# AUTOGENERATED DEPENDENCIES END
diff --git a/jni/ruby/ext/-test-/wait_for_single_fd/extconf.h b/jni/ruby/ext/-test-/wait_for_single_fd/extconf.h
new file mode 100644
index 0000000..cda0cc8
--- /dev/null
+++ b/jni/ruby/ext/-test-/wait_for_single_fd/extconf.h
@@ -0,0 +1,3 @@
+#ifndef EXTCONF_H
+#define EXTCONF_H
+#endif
diff --git a/jni/ruby/ext/-test-/wait_for_single_fd/extconf.rb b/jni/ruby/ext/-test-/wait_for_single_fd/extconf.rb
new file mode 100644
index 0000000..1a28b23
--- /dev/null
+++ b/jni/ruby/ext/-test-/wait_for_single_fd/extconf.rb
@@ -0,0 +1 @@
+create_makefile("-test-/wait_for_single_fd/wait_for_single_fd")
diff --git a/jni/ruby/ext/-test-/wait_for_single_fd/wait_for_single_fd.c b/jni/ruby/ext/-test-/wait_for_single_fd/wait_for_single_fd.c
new file mode 100644
index 0000000..d406724
--- /dev/null
+++ b/jni/ruby/ext/-test-/wait_for_single_fd/wait_for_single_fd.c
@@ -0,0 +1,30 @@
+#include "ruby/ruby.h"
+#include "ruby/io.h"
+
+static VALUE
+wait_for_single_fd(VALUE ign, VALUE fd, VALUE events, VALUE timeout)
+{
+ struct timeval tv;
+ struct timeval *tvp = NULL;
+ int rc;
+
+ if (!NIL_P(timeout)) {
+ tv = rb_time_timeval(timeout);
+ tvp = &tv;
+ }
+
+ rc = rb_wait_for_single_fd(NUM2INT(fd), NUM2INT(events), tvp);
+ if (rc == -1)
+ rb_sys_fail("rb_wait_for_single_fd");
+ return INT2NUM(rc);
+}
+
+void
+Init_wait_for_single_fd(void)
+{
+ rb_define_const(rb_cObject, "RB_WAITFD_IN", INT2NUM(RB_WAITFD_IN));
+ rb_define_const(rb_cObject, "RB_WAITFD_OUT", INT2NUM(RB_WAITFD_OUT));
+ rb_define_const(rb_cObject, "RB_WAITFD_PRI", INT2NUM(RB_WAITFD_PRI));
+ rb_define_singleton_method(rb_cIO, "wait_for_single_fd",
+ wait_for_single_fd, 3);
+}
diff --git a/jni/ruby/ext/-test-/win32/console/Makefile b/jni/ruby/ext/-test-/win32/console/Makefile
new file mode 100644
index 0000000..2ec70d8
--- /dev/null
+++ b/jni/ruby/ext/-test-/win32/console/Makefile
@@ -0,0 +1,150 @@
+# ***DUMMY MAKEFILE***
+
+SHELL = /bin/sh
+
+# V=0 quiet, V=1 verbose. other values don't work.
+V = 0
+Q1 = $(V:1=)
+Q = $(Q1:0=@)
+ECHO1 = $(V:1=@:)
+ECHO = $(ECHO1:0=@echo)
+NULLCMD = :
+
+#### Start of system configuration section. ####
+top_srcdir = $(topdir)/.
+srcdir = $(top_srcdir)/ext/-test-/win32/console
+topdir = ../../../..
+hdrdir = $(top_srcdir)/include
+arch_hdrdir = $(extout)/include/$(arch)
+PATH_SEPARATOR = :
+VPATH = $(srcdir):$(arch_hdrdir)/ruby:$(hdrdir)/ruby
+RUBYLIB =
+RUBYOPT = -
+prefix = $(DESTDIR)/usr/local
+rubysitearchprefix = $(rubylibprefix)/$(sitearch)
+rubyarchprefix = $(rubylibprefix)/$(arch)
+rubylibprefix = $(libdir)/$(RUBY_BASE_NAME)
+exec_prefix = $(prefix)
+vendorarchhdrdir = $(vendorhdrdir)/$(sitearch)
+sitearchhdrdir = $(sitehdrdir)/$(sitearch)
+rubyarchhdrdir = $(rubyhdrdir)/$(arch)
+vendorhdrdir = $(rubyhdrdir)/vendor_ruby
+sitehdrdir = $(rubyhdrdir)/site_ruby
+rubyhdrdir = $(includedir)/$(RUBY_VERSION_NAME)
+vendorarchdir = $(vendorlibdir)/$(sitearch)
+vendorlibdir = $(vendordir)/$(ruby_version)
+vendordir = $(rubylibprefix)/vendor_ruby
+sitearchdir = $(sitelibdir)/$(sitearch)
+sitelibdir = $(sitedir)/$(ruby_version)
+sitedir = $(rubylibprefix)/site_ruby
+rubyarchdir = $(rubylibdir)/$(arch)
+rubylibdir = $(rubylibprefix)/$(ruby_version)
+sitearchincludedir = $(includedir)/$(sitearch)
+archincludedir = $(includedir)/$(arch)
+sitearchlibdir = $(libdir)/$(sitearch)
+archlibdir = $(libdir)/$(arch)
+ridir = $(datarootdir)/$(RI_BASE_NAME)
+mandir = $(datarootdir)/man
+localedir = $(datarootdir)/locale
+libdir = $(exec_prefix)/lib
+psdir = $(docdir)
+pdfdir = $(docdir)
+dvidir = $(docdir)
+htmldir = $(docdir)
+infodir = $(datarootdir)/info
+docdir = $(datarootdir)/doc/$(PACKAGE)
+oldincludedir = $(DESTDIR)/usr/include
+includedir = $(prefix)/include
+localstatedir = $(prefix)/var
+sharedstatedir = $(prefix)/com
+sysconfdir = $(prefix)/etc
+datadir = $(datarootdir)
+datarootdir = $(prefix)/share
+libexecdir = $(exec_prefix)/libexec
+sbindir = $(exec_prefix)/sbin
+bindir = $(exec_prefix)/bin
+archdir = $(rubyarchdir)
+
+
+CC = gcc
+CXX = g++
+LIBRUBY = $(LIBRUBY_SO)
+LIBRUBY_A = lib$(RUBY_SO_NAME)-static.a
+LIBRUBYARG_SHARED = -Wl,-R$(libdir) -L$(libdir) -l$(RUBY_SO_NAME)
+LIBRUBYARG_STATIC = -Wl,-R$(libdir) -L$(libdir) -l$(RUBY_SO_NAME)-static
+empty =
+OUTFLAG = -o $(empty)
+COUTFLAG = -o $(empty)
+
+RUBY_EXTCONF_H =
+cflags = $(optflags) $(debugflags) $(warnflags)
+optflags = -O3 -fno-fast-math
+debugflags = -ggdb3
+warnflags = -Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wunused-variable -Wpointer-arith -Wwrite-strings -Wdeclaration-after-statement -Wimplicit-function-declaration -Wdeprecated-declarations -Wno-packed-bitfield-compat
+CCDLFLAGS = -fPIC
+CFLAGS = $(CCDLFLAGS) $(cflags) -fPIC $(ARCH_FLAG)
+INCFLAGS = -I. -I$(arch_hdrdir) -I$(hdrdir) -I$(srcdir)
+DEFS =
+CPPFLAGS = $(DEFS) $(cppflags)
+CXXFLAGS = $(CCDLFLAGS) $(cxxflags) $(ARCH_FLAG)
+ldflags = -L. -fstack-protector -rdynamic -Wl,-export-dynamic
+dldflags =
+ARCH_FLAG =
+DLDFLAGS = $(ldflags) $(dldflags) $(ARCH_FLAG)
+LDSHARED = $(CC) -shared
+LDSHAREDXX = $(CXX) -shared
+AR = ar
+EXEEXT =
+
+RUBY_INSTALL_NAME = $(RUBY_BASE_NAME)
+RUBY_SO_NAME = ruby
+RUBYW_INSTALL_NAME =
+RUBY_VERSION_NAME = $(RUBY_BASE_NAME)-$(ruby_version)
+RUBYW_BASE_NAME = rubyw
+RUBY_BASE_NAME = ruby
+
+arch = x86_64-linux
+sitearch = $(arch)
+ruby_version = 2.2.0
+ruby = $(topdir)/miniruby -I'$(topdir)' -I'$(top_srcdir)/lib' -I'$(extout)/$(arch)' -I'$(extout)/common'
+RUBY = $(ruby)
+ruby_headers = $(hdrdir)/ruby.h $(hdrdir)/ruby/ruby.h $(hdrdir)/ruby/defines.h $(hdrdir)/ruby/missing.h $(hdrdir)/ruby/intern.h $(hdrdir)/ruby/st.h $(hdrdir)/ruby/subst.h $(arch_hdrdir)/ruby/config.h
+
+RM = rm -f
+RM_RF = $(RUBY) -run -e rm -- -rf
+RMDIRS = rmdir --ignore-fail-on-non-empty -p
+MAKEDIRS = /bin/mkdir -p
+INSTALL = /usr/bin/install -c
+INSTALL_PROG = $(INSTALL) -m 0755
+INSTALL_DATA = $(INSTALL) -m 644
+COPY = cp
+TOUCH = exit >
+
+#### End of system configuration section. ####
+
+preload =
+CLEANFILES = mkmf.log
+DISTCLEANFILES =
+
+all install static install-so install-rb: Makefile
+.PHONY: all install static install-so install-rb
+.PHONY: clean clean-so clean-static clean-rb
+
+
+clean-static::
+clean-rb-default::
+clean-rb::
+clean-so::
+clean: clean-so clean-static clean-rb-default clean-rb
+ -$(Q)$(RM) $(CLEANLIBS) $(CLEANOBJS) $(CLEANFILES) .*.time
+
+distclean-rb-default::
+distclean-rb::
+distclean-so::
+distclean-static::
+distclean: clean distclean-so distclean-static distclean-rb-default distclean-rb
+ -$(Q)$(RM) Makefile $(RUBY_EXTCONF_H) conftest.* mkmf.log
+ -$(Q)$(RM) core ruby$(EXEEXT) *~ $(DISTCLEANFILES)
+ -$(Q)$(RMDIRS) $(DISTCLEANDIRS) 2> /dev/null || true
+
+realclean: distclean
diff --git a/jni/ruby/ext/-test-/win32/console/attribute.c b/jni/ruby/ext/-test-/win32/console/attribute.c
new file mode 100644
index 0000000..a2c07fc
--- /dev/null
+++ b/jni/ruby/ext/-test-/win32/console/attribute.c
@@ -0,0 +1,56 @@
+#include <ruby.h>
+
+static VALUE rb_cConsoleScreenBufferInfo;
+
+static VALUE
+console_info(VALUE io)
+{
+ int fd = NUM2INT(rb_funcallv(io, rb_intern("fileno"), 0, 0));
+ HANDLE h = (HANDLE)rb_w32_get_osfhandle(fd);
+ CONSOLE_SCREEN_BUFFER_INFO csbi;
+
+ if (h == (HANDLE)-1) rb_raise(rb_eIOError, "invalid io");
+ if (!GetConsoleScreenBufferInfo(h, &csbi))
+ rb_syserr_fail(rb_w32_map_errno(GetLastError()), "not console");
+ return rb_struct_new(rb_cConsoleScreenBufferInfo,
+ INT2FIX(csbi.dwSize.X), INT2FIX(csbi.dwSize.Y),
+ INT2FIX(csbi.dwCursorPosition.X), INT2FIX(csbi.dwCursorPosition.Y),
+ INT2FIX(csbi.wAttributes));
+}
+
+static VALUE
+console_set_attribute(VALUE io, VALUE attr)
+{
+ int fd = NUM2INT(rb_funcallv(io, rb_intern("fileno"), 0, 0));
+ HANDLE h = (HANDLE)rb_w32_get_osfhandle(fd);
+
+ if (h == (HANDLE)-1) rb_raise(rb_eIOError, "invalid io");
+ SetConsoleTextAttribute(h, (WORD)NUM2INT(attr));
+ return Qnil;
+}
+
+#define FOREGROUND_MASK (FOREGROUND_BLUE | FOREGROUND_GREEN | FOREGROUND_RED | FOREGROUND_INTENSITY)
+#define BACKGROUND_MASK (BACKGROUND_BLUE | BACKGROUND_GREEN | BACKGROUND_RED | BACKGROUND_INTENSITY)
+
+void
+Init_attribute(VALUE m)
+{
+ rb_cConsoleScreenBufferInfo = rb_struct_define_under(m, "ConsoleScreenBufferInfo",
+ "size_x", "size_y",
+ "cur_x", "cur_y",
+ "attr", NULL);
+ rb_define_method(rb_cIO, "console_info", console_info, 0);
+ rb_define_method(rb_cIO, "console_attribute", console_set_attribute, 1);
+
+ rb_define_const(m, "FOREGROUND_MASK", INT2FIX(FOREGROUND_MASK));
+ rb_define_const(m, "FOREGROUND_BLUE", INT2FIX(FOREGROUND_BLUE));
+ rb_define_const(m, "FOREGROUND_GREEN", INT2FIX(FOREGROUND_GREEN));
+ rb_define_const(m, "FOREGROUND_RED", INT2FIX(FOREGROUND_RED));
+ rb_define_const(m, "FOREGROUND_INTENSITY", INT2FIX(FOREGROUND_INTENSITY));
+
+ rb_define_const(m, "BACKGROUND_MASK", INT2FIX(BACKGROUND_MASK));
+ rb_define_const(m, "BACKGROUND_BLUE", INT2FIX(BACKGROUND_BLUE));
+ rb_define_const(m, "BACKGROUND_GREEN", INT2FIX(BACKGROUND_GREEN));
+ rb_define_const(m, "BACKGROUND_RED", INT2FIX(BACKGROUND_RED));
+ rb_define_const(m, "BACKGROUND_INTENSITY", INT2FIX(BACKGROUND_INTENSITY));
+}
diff --git a/jni/ruby/ext/-test-/win32/console/depend b/jni/ruby/ext/-test-/win32/console/depend
new file mode 100644
index 0000000..f4f65ad
--- /dev/null
+++ b/jni/ruby/ext/-test-/win32/console/depend
@@ -0,0 +1 @@
+attribute.o: $(ruby_headers) $(hdrdir)/ruby/win32.h
diff --git a/jni/ruby/ext/-test-/win32/console/extconf.rb b/jni/ruby/ext/-test-/win32/console/extconf.rb
new file mode 100644
index 0000000..4de9fa7
--- /dev/null
+++ b/jni/ruby/ext/-test-/win32/console/extconf.rb
@@ -0,0 +1,8 @@
+if $mingw or $mswin
+ $srcs = Dir[File.join($srcdir, "*.{#{SRC_EXT.join(%q{,})}}")]
+ inits = $srcs.map {|s| File.basename(s, ".*")}
+ inits.delete("init")
+ inits.map! {|s|"X(#{s})"}
+ $defs << "-DTEST_INIT_FUNCS(X)=\"#{inits.join(' ')}\""
+ create_makefile("-test-/win32/console")
+end
diff --git a/jni/ruby/ext/-test-/win32/console/init.c b/jni/ruby/ext/-test-/win32/console/init.c
new file mode 100644
index 0000000..f2e0d1c
--- /dev/null
+++ b/jni/ruby/ext/-test-/win32/console/init.c
@@ -0,0 +1,11 @@
+#include "ruby.h"
+
+#define init(n) {void Init_##n(VALUE m); Init_##n(m);}
+
+void
+Init_console(void)
+{
+ VALUE mBug = rb_define_module("Bug");
+ VALUE m = rb_define_module_under(mBug, "Win32");
+ TEST_INIT_FUNCS(init);
+}
diff --git a/jni/ruby/ext/-test-/win32/dln/Makefile b/jni/ruby/ext/-test-/win32/dln/Makefile
new file mode 100644
index 0000000..9772e0e
--- /dev/null
+++ b/jni/ruby/ext/-test-/win32/dln/Makefile
@@ -0,0 +1,150 @@
+# ***DUMMY MAKEFILE***
+
+SHELL = /bin/sh
+
+# V=0 quiet, V=1 verbose. other values don't work.
+V = 0
+Q1 = $(V:1=)
+Q = $(Q1:0=@)
+ECHO1 = $(V:1=@:)
+ECHO = $(ECHO1:0=@echo)
+NULLCMD = :
+
+#### Start of system configuration section. ####
+top_srcdir = $(topdir)/.
+srcdir = $(top_srcdir)/ext/-test-/win32/dln
+topdir = ../../../..
+hdrdir = $(top_srcdir)/include
+arch_hdrdir = $(extout)/include/$(arch)
+PATH_SEPARATOR = :
+VPATH = $(srcdir):$(arch_hdrdir)/ruby:$(hdrdir)/ruby
+RUBYLIB =
+RUBYOPT = -
+prefix = $(DESTDIR)/usr/local
+rubysitearchprefix = $(rubylibprefix)/$(sitearch)
+rubyarchprefix = $(rubylibprefix)/$(arch)
+rubylibprefix = $(libdir)/$(RUBY_BASE_NAME)
+exec_prefix = $(prefix)
+vendorarchhdrdir = $(vendorhdrdir)/$(sitearch)
+sitearchhdrdir = $(sitehdrdir)/$(sitearch)
+rubyarchhdrdir = $(rubyhdrdir)/$(arch)
+vendorhdrdir = $(rubyhdrdir)/vendor_ruby
+sitehdrdir = $(rubyhdrdir)/site_ruby
+rubyhdrdir = $(includedir)/$(RUBY_VERSION_NAME)
+vendorarchdir = $(vendorlibdir)/$(sitearch)
+vendorlibdir = $(vendordir)/$(ruby_version)
+vendordir = $(rubylibprefix)/vendor_ruby
+sitearchdir = $(sitelibdir)/$(sitearch)
+sitelibdir = $(sitedir)/$(ruby_version)
+sitedir = $(rubylibprefix)/site_ruby
+rubyarchdir = $(rubylibdir)/$(arch)
+rubylibdir = $(rubylibprefix)/$(ruby_version)
+sitearchincludedir = $(includedir)/$(sitearch)
+archincludedir = $(includedir)/$(arch)
+sitearchlibdir = $(libdir)/$(sitearch)
+archlibdir = $(libdir)/$(arch)
+ridir = $(datarootdir)/$(RI_BASE_NAME)
+mandir = $(datarootdir)/man
+localedir = $(datarootdir)/locale
+libdir = $(exec_prefix)/lib
+psdir = $(docdir)
+pdfdir = $(docdir)
+dvidir = $(docdir)
+htmldir = $(docdir)
+infodir = $(datarootdir)/info
+docdir = $(datarootdir)/doc/$(PACKAGE)
+oldincludedir = $(DESTDIR)/usr/include
+includedir = $(prefix)/include
+localstatedir = $(prefix)/var
+sharedstatedir = $(prefix)/com
+sysconfdir = $(prefix)/etc
+datadir = $(datarootdir)
+datarootdir = $(prefix)/share
+libexecdir = $(exec_prefix)/libexec
+sbindir = $(exec_prefix)/sbin
+bindir = $(exec_prefix)/bin
+archdir = $(rubyarchdir)
+
+
+CC = gcc
+CXX = g++
+LIBRUBY = $(LIBRUBY_SO)
+LIBRUBY_A = lib$(RUBY_SO_NAME)-static.a
+LIBRUBYARG_SHARED = -Wl,-R$(libdir) -L$(libdir) -l$(RUBY_SO_NAME)
+LIBRUBYARG_STATIC = -Wl,-R$(libdir) -L$(libdir) -l$(RUBY_SO_NAME)-static
+empty =
+OUTFLAG = -o $(empty)
+COUTFLAG = -o $(empty)
+
+RUBY_EXTCONF_H =
+cflags = $(optflags) $(debugflags) $(warnflags)
+optflags = -O3 -fno-fast-math
+debugflags = -ggdb3
+warnflags = -Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wunused-variable -Wpointer-arith -Wwrite-strings -Wdeclaration-after-statement -Wimplicit-function-declaration -Wdeprecated-declarations -Wno-packed-bitfield-compat
+CCDLFLAGS = -fPIC
+CFLAGS = $(CCDLFLAGS) $(cflags) -fPIC $(ARCH_FLAG)
+INCFLAGS = -I. -I$(arch_hdrdir) -I$(hdrdir) -I$(srcdir)
+DEFS =
+CPPFLAGS = $(DEFS) $(cppflags)
+CXXFLAGS = $(CCDLFLAGS) $(cxxflags) $(ARCH_FLAG)
+ldflags = -L. -fstack-protector -rdynamic -Wl,-export-dynamic
+dldflags =
+ARCH_FLAG =
+DLDFLAGS = $(ldflags) $(dldflags) $(ARCH_FLAG)
+LDSHARED = $(CC) -shared
+LDSHAREDXX = $(CXX) -shared
+AR = ar
+EXEEXT =
+
+RUBY_INSTALL_NAME = $(RUBY_BASE_NAME)
+RUBY_SO_NAME = ruby
+RUBYW_INSTALL_NAME =
+RUBY_VERSION_NAME = $(RUBY_BASE_NAME)-$(ruby_version)
+RUBYW_BASE_NAME = rubyw
+RUBY_BASE_NAME = ruby
+
+arch = x86_64-linux
+sitearch = $(arch)
+ruby_version = 2.2.0
+ruby = $(topdir)/miniruby -I'$(topdir)' -I'$(top_srcdir)/lib' -I'$(extout)/$(arch)' -I'$(extout)/common'
+RUBY = $(ruby)
+ruby_headers = $(hdrdir)/ruby.h $(hdrdir)/ruby/ruby.h $(hdrdir)/ruby/defines.h $(hdrdir)/ruby/missing.h $(hdrdir)/ruby/intern.h $(hdrdir)/ruby/st.h $(hdrdir)/ruby/subst.h $(arch_hdrdir)/ruby/config.h
+
+RM = rm -f
+RM_RF = $(RUBY) -run -e rm -- -rf
+RMDIRS = rmdir --ignore-fail-on-non-empty -p
+MAKEDIRS = /bin/mkdir -p
+INSTALL = /usr/bin/install -c
+INSTALL_PROG = $(INSTALL) -m 0755
+INSTALL_DATA = $(INSTALL) -m 644
+COPY = cp
+TOUCH = exit >
+
+#### End of system configuration section. ####
+
+preload =
+CLEANFILES = mkmf.log
+DISTCLEANFILES =
+
+all install static install-so install-rb: Makefile
+.PHONY: all install static install-so install-rb
+.PHONY: clean clean-so clean-static clean-rb
+
+
+clean-static::
+clean-rb-default::
+clean-rb::
+clean-so::
+clean: clean-so clean-static clean-rb-default clean-rb
+ -$(Q)$(RM) $(CLEANLIBS) $(CLEANOBJS) $(CLEANFILES) .*.time
+
+distclean-rb-default::
+distclean-rb::
+distclean-so::
+distclean-static::
+distclean: clean distclean-so distclean-static distclean-rb-default distclean-rb
+ -$(Q)$(RM) Makefile $(RUBY_EXTCONF_H) conftest.* mkmf.log
+ -$(Q)$(RM) core ruby$(EXEEXT) *~ $(DISTCLEANFILES)
+ -$(Q)$(RMDIRS) $(DISTCLEANDIRS) 2> /dev/null || true
+
+realclean: distclean
diff --git a/jni/ruby/ext/-test-/win32/dln/dlntest.c b/jni/ruby/ext/-test-/win32/dln/dlntest.c
new file mode 100644
index 0000000..3e6037a
--- /dev/null
+++ b/jni/ruby/ext/-test-/win32/dln/dlntest.c
@@ -0,0 +1,17 @@
+#include <ruby.h>
+
+extern __declspec(dllimport) void dlntest_ordinal(void);
+
+static VALUE
+dln_dlntest(VALUE self)
+{
+ dlntest_ordinal();
+ return self;
+}
+
+void
+Init_dln(void)
+{
+ VALUE m = rb_define_module_under(rb_define_module("Bug"), "Win32");
+ rb_define_module_function(m, "dlntest", dln_dlntest, 0);
+}
diff --git a/jni/ruby/ext/-test-/win32/dln/empty/Makefile b/jni/ruby/ext/-test-/win32/dln/empty/Makefile
new file mode 100644
index 0000000..d781248
--- /dev/null
+++ b/jni/ruby/ext/-test-/win32/dln/empty/Makefile
@@ -0,0 +1,150 @@
+# ***DUMMY MAKEFILE***
+
+SHELL = /bin/sh
+
+# V=0 quiet, V=1 verbose. other values don't work.
+V = 0
+Q1 = $(V:1=)
+Q = $(Q1:0=@)
+ECHO1 = $(V:1=@:)
+ECHO = $(ECHO1:0=@echo)
+NULLCMD = :
+
+#### Start of system configuration section. ####
+top_srcdir = $(topdir)/.
+srcdir = ./ext
+topdir = /home/potato/Documents/android/mkxp/jni/ruby/ruby-2.2.3
+hdrdir = ../../../../.././include
+arch_hdrdir = $(extout)/include/$(arch)
+PATH_SEPARATOR = :
+VPATH = $(srcdir):$(arch_hdrdir)/ruby:$(hdrdir)/ruby
+RUBYLIB =
+RUBYOPT = -
+prefix = $(DESTDIR)/usr/local
+rubysitearchprefix = $(rubylibprefix)/$(sitearch)
+rubyarchprefix = $(rubylibprefix)/$(arch)
+rubylibprefix = $(libdir)/$(RUBY_BASE_NAME)
+exec_prefix = $(prefix)
+vendorarchhdrdir = $(vendorhdrdir)/$(sitearch)
+sitearchhdrdir = $(sitehdrdir)/$(sitearch)
+rubyarchhdrdir = $(rubyhdrdir)/$(arch)
+vendorhdrdir = $(rubyhdrdir)/vendor_ruby
+sitehdrdir = $(rubyhdrdir)/site_ruby
+rubyhdrdir = $(includedir)/$(RUBY_VERSION_NAME)
+vendorarchdir = $(vendorlibdir)/$(sitearch)
+vendorlibdir = $(vendordir)/$(ruby_version)
+vendordir = $(rubylibprefix)/vendor_ruby
+sitearchdir = $(sitelibdir)/$(sitearch)
+sitelibdir = $(sitedir)/$(ruby_version)
+sitedir = $(rubylibprefix)/site_ruby
+rubyarchdir = $(rubylibdir)/$(arch)
+rubylibdir = $(rubylibprefix)/$(ruby_version)
+sitearchincludedir = $(includedir)/$(sitearch)
+archincludedir = $(includedir)/$(arch)
+sitearchlibdir = $(libdir)/$(sitearch)
+archlibdir = $(libdir)/$(arch)
+ridir = $(datarootdir)/$(RI_BASE_NAME)
+mandir = $(datarootdir)/man
+localedir = $(datarootdir)/locale
+libdir = $(exec_prefix)/lib
+psdir = $(docdir)
+pdfdir = $(docdir)
+dvidir = $(docdir)
+htmldir = $(docdir)
+infodir = $(datarootdir)/info
+docdir = $(datarootdir)/doc/$(PACKAGE)
+oldincludedir = $(DESTDIR)/usr/include
+includedir = $(prefix)/include
+localstatedir = $(prefix)/var
+sharedstatedir = $(prefix)/com
+sysconfdir = $(prefix)/etc
+datadir = $(datarootdir)
+datarootdir = $(prefix)/share
+libexecdir = $(exec_prefix)/libexec
+sbindir = $(exec_prefix)/sbin
+bindir = $(exec_prefix)/bin
+archdir = $(rubyarchdir)
+
+
+CC = gcc
+CXX = g++
+LIBRUBY = $(LIBRUBY_SO)
+LIBRUBY_A = lib$(RUBY_SO_NAME)-static.a
+LIBRUBYARG_SHARED = -Wl,-R$(libdir) -L$(libdir) -l$(RUBY_SO_NAME)
+LIBRUBYARG_STATIC = -Wl,-R$(libdir) -L$(libdir) -l$(RUBY_SO_NAME)-static
+empty =
+OUTFLAG = -o $(empty)
+COUTFLAG = -o $(empty)
+
+RUBY_EXTCONF_H =
+cflags = $(optflags) $(debugflags) $(warnflags)
+optflags = -O3 -fno-fast-math
+debugflags = -ggdb3
+warnflags = -Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wunused-variable -Wpointer-arith -Wwrite-strings -Wdeclaration-after-statement -Wimplicit-function-declaration -Wdeprecated-declarations -Wno-packed-bitfield-compat
+CCDLFLAGS = -fPIC
+CFLAGS = $(CCDLFLAGS) $(cflags) -fPIC $(ARCH_FLAG)
+INCFLAGS = -I. -I$(arch_hdrdir) -I$(hdrdir) -I$(srcdir)
+DEFS =
+CPPFLAGS = $(DEFS) $(cppflags)
+CXXFLAGS = $(CCDLFLAGS) $(cxxflags) $(ARCH_FLAG)
+ldflags = -L. -fstack-protector -rdynamic -Wl,-export-dynamic
+dldflags =
+ARCH_FLAG =
+DLDFLAGS = $(ldflags) $(dldflags) $(ARCH_FLAG)
+LDSHARED = $(CC) -shared
+LDSHAREDXX = $(CXX) -shared
+AR = ar
+EXEEXT =
+
+RUBY_INSTALL_NAME = $(RUBY_BASE_NAME)
+RUBY_SO_NAME = ruby
+RUBYW_INSTALL_NAME =
+RUBY_VERSION_NAME = $(RUBY_BASE_NAME)-$(ruby_version)
+RUBYW_BASE_NAME = rubyw
+RUBY_BASE_NAME = ruby
+
+arch = x86_64-linux
+sitearch = $(arch)
+ruby_version = 2.2.0
+ruby = $(topdir)/miniruby -I'$(topdir)' -I'$(top_srcdir)/lib' -I'$(extout)/$(arch)' -I'$(extout)/common'
+RUBY = $(ruby)
+ruby_headers = $(hdrdir)/ruby.h $(hdrdir)/ruby/ruby.h $(hdrdir)/ruby/defines.h $(hdrdir)/ruby/missing.h $(hdrdir)/ruby/intern.h $(hdrdir)/ruby/st.h $(hdrdir)/ruby/subst.h $(arch_hdrdir)/ruby/config.h
+
+RM = rm -f
+RM_RF = $(RUBY) -run -e rm -- -rf
+RMDIRS = rmdir --ignore-fail-on-non-empty -p
+MAKEDIRS = /bin/mkdir -p
+INSTALL = /usr/bin/install -c
+INSTALL_PROG = $(INSTALL) -m 0755
+INSTALL_DATA = $(INSTALL) -m 644
+COPY = cp
+TOUCH = exit >
+
+#### End of system configuration section. ####
+
+preload =
+CLEANFILES = mkmf.log
+DISTCLEANFILES =
+
+all install static install-so install-rb: Makefile
+.PHONY: all install static install-so install-rb
+.PHONY: clean clean-so clean-static clean-rb
+
+
+clean-static::
+clean-rb-default::
+clean-rb::
+clean-so::
+clean: clean-so clean-static clean-rb-default clean-rb
+ -$(Q)$(RM) $(CLEANLIBS) $(CLEANOBJS) $(CLEANFILES) .*.time
+
+distclean-rb-default::
+distclean-rb::
+distclean-so::
+distclean-static::
+distclean: clean distclean-so distclean-static distclean-rb-default distclean-rb
+ -$(Q)$(RM) Makefile $(RUBY_EXTCONF_H) conftest.* mkmf.log
+ -$(Q)$(RM) core ruby$(EXEEXT) *~ $(DISTCLEANFILES)
+ -$(Q)$(RMDIRS) $(DISTCLEANDIRS) 2> /dev/null || true
+
+realclean: distclean
diff --git a/jni/ruby/ext/-test-/win32/dln/empty/empty.c b/jni/ruby/ext/-test-/win32/dln/empty/empty.c
new file mode 100644
index 0000000..c4f94f1
--- /dev/null
+++ b/jni/ruby/ext/-test-/win32/dln/empty/empty.c
@@ -0,0 +1,4 @@
+void
+Init_empty(void)
+{
+}
diff --git a/jni/ruby/ext/-test-/win32/dln/empty/extconf.rb b/jni/ruby/ext/-test-/win32/dln/empty/extconf.rb
new file mode 100644
index 0000000..a4efed9
--- /dev/null
+++ b/jni/ruby/ext/-test-/win32/dln/empty/extconf.rb
@@ -0,0 +1,3 @@
+if $mingw or $mswin
+ create_makefile("-test-/win32/dln/empty")
+end
diff --git a/jni/ruby/ext/-test-/win32/dln/extconf.rb b/jni/ruby/ext/-test-/win32/dln/extconf.rb
new file mode 100644
index 0000000..57cee23
--- /dev/null
+++ b/jni/ruby/ext/-test-/win32/dln/extconf.rb
@@ -0,0 +1,37 @@
+if $mingw or $mswin
+ $objs = ["dlntest.o"]
+ testdll = "$(topdir)/dlntest.dll"
+ $cleanfiles << testdll
+ $cleanfiles << "dlntest.#{$LIBEXT}"
+ config_string('cleanobjs') {|t| $cleanfiles.concat(t.gsub(/\$\*/, 'dlntest').split)}
+
+ create_makefile("-test-/win32/dln")
+ m = File.read("Makefile")
+ dlntestlib = "dlntest.#{$LIBEXT}"
+ m.sub!(/^OBJS =.*/) {"#{$&} #{dlntestlib}"}
+ FileUtils.rm_f(RbConfig.expand(testdll.dup))
+ open("Makefile", "wb") do |mf|
+ mf.puts m, "\n"
+ sodir = $extout ? "$(RUBYARCHDIR)/" : ''
+ mf.print "#{sodir}$(DLLIB): #{dlntestlib}"
+ mf.puts
+ mf.puts "#{dlntestlib}: $(topdir)/dlntest.dll"
+ mf.puts
+ if $mingw
+ mf.puts "$(topdir)/dlntest.dll: DEFFILE := $(srcdir)/libdlntest.def"
+ mf.puts "$(topdir)/dlntest.dll: DLDFLAGS += -Wl,--out-implib,#{dlntestlib}"
+ end
+ mf.puts depend_rules("$(topdir)/dlntest.dll: libdlntest.o libdlntest.def")
+ mf.puts "\t$(ECHO) linking shared-object $(@F)\n"
+ mf.print "\t-$(Q)$(RM) $@\n"
+ mf.print "\t-$(Q)$(MAKEDIRS) $(@D)\n" if $extout
+ link_so = LINK_SO.gsub(/^/, "\t$(Q) ")
+ link_so.sub!(/\$\(LOCAL_LIBS\)/, '')
+ link_so.gsub!(/-\$\(arch\)/, '')
+ link_so.gsub!(/:.so=/, ':.dll=')
+ link_so.sub!(/\$\(OBJS\)/, "libdlntest.#{$OBJEXT}")
+ link_so.sub!(/\$\(DEFFILE\)/, "$(srcdir)/libdlntest.def")
+ mf.puts link_so
+ mf.puts
+ end
+end
diff --git a/jni/ruby/ext/-test-/win32/dln/libdlntest.c b/jni/ruby/ext/-test-/win32/dln/libdlntest.c
new file mode 100644
index 0000000..5923b73
--- /dev/null
+++ b/jni/ruby/ext/-test-/win32/dln/libdlntest.c
@@ -0,0 +1,4 @@
+void
+dlntest_ordinal(void)
+{
+}
diff --git a/jni/ruby/ext/-test-/win32/dln/libdlntest.def b/jni/ruby/ext/-test-/win32/dln/libdlntest.def
new file mode 100644
index 0000000..85bc9c7
--- /dev/null
+++ b/jni/ruby/ext/-test-/win32/dln/libdlntest.def
@@ -0,0 +1,2 @@
+EXPORTS
+dlntest_ordinal @1 NONAME
diff --git a/jni/ruby/ext/-test-/win32/fd_setsize/Makefile b/jni/ruby/ext/-test-/win32/fd_setsize/Makefile
new file mode 100644
index 0000000..9792253
--- /dev/null
+++ b/jni/ruby/ext/-test-/win32/fd_setsize/Makefile
@@ -0,0 +1,150 @@
+# ***DUMMY MAKEFILE***
+
+SHELL = /bin/sh
+
+# V=0 quiet, V=1 verbose. other values don't work.
+V = 0
+Q1 = $(V:1=)
+Q = $(Q1:0=@)
+ECHO1 = $(V:1=@:)
+ECHO = $(ECHO1:0=@echo)
+NULLCMD = :
+
+#### Start of system configuration section. ####
+top_srcdir = $(topdir)/.
+srcdir = $(top_srcdir)/ext/-test-/win32/fd_setsize
+topdir = ../../../..
+hdrdir = $(top_srcdir)/include
+arch_hdrdir = $(extout)/include/$(arch)
+PATH_SEPARATOR = :
+VPATH = $(srcdir):$(arch_hdrdir)/ruby:$(hdrdir)/ruby
+RUBYLIB =
+RUBYOPT = -
+prefix = $(DESTDIR)/usr/local
+rubysitearchprefix = $(rubylibprefix)/$(sitearch)
+rubyarchprefix = $(rubylibprefix)/$(arch)
+rubylibprefix = $(libdir)/$(RUBY_BASE_NAME)
+exec_prefix = $(prefix)
+vendorarchhdrdir = $(vendorhdrdir)/$(sitearch)
+sitearchhdrdir = $(sitehdrdir)/$(sitearch)
+rubyarchhdrdir = $(rubyhdrdir)/$(arch)
+vendorhdrdir = $(rubyhdrdir)/vendor_ruby
+sitehdrdir = $(rubyhdrdir)/site_ruby
+rubyhdrdir = $(includedir)/$(RUBY_VERSION_NAME)
+vendorarchdir = $(vendorlibdir)/$(sitearch)
+vendorlibdir = $(vendordir)/$(ruby_version)
+vendordir = $(rubylibprefix)/vendor_ruby
+sitearchdir = $(sitelibdir)/$(sitearch)
+sitelibdir = $(sitedir)/$(ruby_version)
+sitedir = $(rubylibprefix)/site_ruby
+rubyarchdir = $(rubylibdir)/$(arch)
+rubylibdir = $(rubylibprefix)/$(ruby_version)
+sitearchincludedir = $(includedir)/$(sitearch)
+archincludedir = $(includedir)/$(arch)
+sitearchlibdir = $(libdir)/$(sitearch)
+archlibdir = $(libdir)/$(arch)
+ridir = $(datarootdir)/$(RI_BASE_NAME)
+mandir = $(datarootdir)/man
+localedir = $(datarootdir)/locale
+libdir = $(exec_prefix)/lib
+psdir = $(docdir)
+pdfdir = $(docdir)
+dvidir = $(docdir)
+htmldir = $(docdir)
+infodir = $(datarootdir)/info
+docdir = $(datarootdir)/doc/$(PACKAGE)
+oldincludedir = $(DESTDIR)/usr/include
+includedir = $(prefix)/include
+localstatedir = $(prefix)/var
+sharedstatedir = $(prefix)/com
+sysconfdir = $(prefix)/etc
+datadir = $(datarootdir)
+datarootdir = $(prefix)/share
+libexecdir = $(exec_prefix)/libexec
+sbindir = $(exec_prefix)/sbin
+bindir = $(exec_prefix)/bin
+archdir = $(rubyarchdir)
+
+
+CC = gcc
+CXX = g++
+LIBRUBY = $(LIBRUBY_SO)
+LIBRUBY_A = lib$(RUBY_SO_NAME)-static.a
+LIBRUBYARG_SHARED = -Wl,-R$(libdir) -L$(libdir) -l$(RUBY_SO_NAME)
+LIBRUBYARG_STATIC = -Wl,-R$(libdir) -L$(libdir) -l$(RUBY_SO_NAME)-static
+empty =
+OUTFLAG = -o $(empty)
+COUTFLAG = -o $(empty)
+
+RUBY_EXTCONF_H =
+cflags = $(optflags) $(debugflags) $(warnflags)
+optflags = -O3 -fno-fast-math
+debugflags = -ggdb3
+warnflags = -Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wunused-variable -Wpointer-arith -Wwrite-strings -Wdeclaration-after-statement -Wimplicit-function-declaration -Wdeprecated-declarations -Wno-packed-bitfield-compat
+CCDLFLAGS = -fPIC
+CFLAGS = $(CCDLFLAGS) $(cflags) -fPIC $(ARCH_FLAG)
+INCFLAGS = -I. -I$(arch_hdrdir) -I$(hdrdir) -I$(srcdir)
+DEFS =
+CPPFLAGS = $(DEFS) $(cppflags)
+CXXFLAGS = $(CCDLFLAGS) $(cxxflags) $(ARCH_FLAG)
+ldflags = -L. -fstack-protector -rdynamic -Wl,-export-dynamic
+dldflags =
+ARCH_FLAG =
+DLDFLAGS = $(ldflags) $(dldflags) $(ARCH_FLAG)
+LDSHARED = $(CC) -shared
+LDSHAREDXX = $(CXX) -shared
+AR = ar
+EXEEXT =
+
+RUBY_INSTALL_NAME = $(RUBY_BASE_NAME)
+RUBY_SO_NAME = ruby
+RUBYW_INSTALL_NAME =
+RUBY_VERSION_NAME = $(RUBY_BASE_NAME)-$(ruby_version)
+RUBYW_BASE_NAME = rubyw
+RUBY_BASE_NAME = ruby
+
+arch = x86_64-linux
+sitearch = $(arch)
+ruby_version = 2.2.0
+ruby = $(topdir)/miniruby -I'$(topdir)' -I'$(top_srcdir)/lib' -I'$(extout)/$(arch)' -I'$(extout)/common'
+RUBY = $(ruby)
+ruby_headers = $(hdrdir)/ruby.h $(hdrdir)/ruby/ruby.h $(hdrdir)/ruby/defines.h $(hdrdir)/ruby/missing.h $(hdrdir)/ruby/intern.h $(hdrdir)/ruby/st.h $(hdrdir)/ruby/subst.h $(arch_hdrdir)/ruby/config.h
+
+RM = rm -f
+RM_RF = $(RUBY) -run -e rm -- -rf
+RMDIRS = rmdir --ignore-fail-on-non-empty -p
+MAKEDIRS = /bin/mkdir -p
+INSTALL = /usr/bin/install -c
+INSTALL_PROG = $(INSTALL) -m 0755
+INSTALL_DATA = $(INSTALL) -m 644
+COPY = cp
+TOUCH = exit >
+
+#### End of system configuration section. ####
+
+preload =
+CLEANFILES = mkmf.log
+DISTCLEANFILES =
+
+all install static install-so install-rb: Makefile
+.PHONY: all install static install-so install-rb
+.PHONY: clean clean-so clean-static clean-rb
+
+
+clean-static::
+clean-rb-default::
+clean-rb::
+clean-so::
+clean: clean-so clean-static clean-rb-default clean-rb
+ -$(Q)$(RM) $(CLEANLIBS) $(CLEANOBJS) $(CLEANFILES) .*.time
+
+distclean-rb-default::
+distclean-rb::
+distclean-so::
+distclean-static::
+distclean: clean distclean-so distclean-static distclean-rb-default distclean-rb
+ -$(Q)$(RM) Makefile $(RUBY_EXTCONF_H) conftest.* mkmf.log
+ -$(Q)$(RM) core ruby$(EXEEXT) *~ $(DISTCLEANFILES)
+ -$(Q)$(RMDIRS) $(DISTCLEANDIRS) 2> /dev/null || true
+
+realclean: distclean
diff --git a/jni/ruby/ext/-test-/win32/fd_setsize/depend b/jni/ruby/ext/-test-/win32/fd_setsize/depend
new file mode 100644
index 0000000..7d40e8d
--- /dev/null
+++ b/jni/ruby/ext/-test-/win32/fd_setsize/depend
@@ -0,0 +1 @@
+fd_setsize.o: $(ruby_headers) $(hdrdir)/ruby/win32.h
diff --git a/jni/ruby/ext/-test-/win32/fd_setsize/extconf.rb b/jni/ruby/ext/-test-/win32/fd_setsize/extconf.rb
new file mode 100644
index 0000000..ed40f8b
--- /dev/null
+++ b/jni/ruby/ext/-test-/win32/fd_setsize/extconf.rb
@@ -0,0 +1,3 @@
+if $mingw or $mswin
+ create_makefile("-test-/win32/fd_setsize")
+end
diff --git a/jni/ruby/ext/-test-/win32/fd_setsize/fd_setsize.c b/jni/ruby/ext/-test-/win32/fd_setsize/fd_setsize.c
new file mode 100644
index 0000000..8da8b1e
--- /dev/null
+++ b/jni/ruby/ext/-test-/win32/fd_setsize/fd_setsize.c
@@ -0,0 +1,55 @@
+#undef FD_SETSIZE
+/* redefine smaller size then default 64 */
+#define FD_SETSIZE 32
+#include <ruby.h>
+
+static VALUE
+test_select(VALUE self)
+{
+ int sd = socket(AF_INET, SOCK_DGRAM, 0);
+ struct timeval zero;
+ fd_set read;
+ fd_set write;
+ fd_set error;
+
+ zero.tv_sec = 0;
+ zero.tv_usec = 0;
+
+ FD_ZERO(&read);
+ FD_ZERO(&write);
+ FD_ZERO(&error);
+
+ FD_SET(sd, &read);
+ FD_SET(sd, &write);
+ FD_SET(sd, &error);
+
+ select(sd+1, &read, &write, &error, &zero);
+
+ return Qtrue;
+}
+
+static VALUE
+test_fdset(VALUE self)
+{
+ int i;
+ fd_set set;
+
+ FD_ZERO(&set);
+
+ for (i = 0; i < FD_SETSIZE * 2; i++) {
+ int sd = socket(AF_INET, SOCK_DGRAM, 0);
+ FD_SET(sd, &set);
+ if (set.fd_count > FD_SETSIZE) {
+ return Qfalse;
+ }
+ }
+ return Qtrue;
+}
+
+void
+Init_fd_setsize(void)
+{
+ VALUE m = rb_define_module_under(rb_define_module("Bug"), "Win32");
+ rb_define_module_function(m, "test_select", test_select, 0);
+ rb_define_module_function(m, "test_fdset", test_fdset, 0);
+}
diff --git a/jni/ruby/ext/.document b/jni/ruby/ext/.document
new file mode 100644
index 0000000..2e6fc78
--- /dev/null
+++ b/jni/ruby/ext/.document
@@ -0,0 +1,103 @@
+# Add files to this as they become documented
+
+bigdecimal/bigdecimal.c
+bigdecimal/lib
+continuation/continuation.c
+coverage/coverage.c
+date/date_core.c
+dbm/dbm.c
+digest/bubblebabble/bubblebabble.c
+digest/digest.c
+digest/lib
+digest/md5/md5init.c
+digest/rmd160/rmd160init.c
+digest/sha1/sha1init.c
+digest/sha2/sha2init.c
+dl/cfunc.c
+dl/cptr.c
+dl/dl.c
+dl/handle.c
+dl/lib
+dl/win32/lib
+etc/etc.c
+fcntl/fcntl.c
+fiber/fiber.c
+fiddle/closure.c
+fiddle/conversions.c
+fiddle/fiddle.c
+fiddle/function.c
+fiddle/pointer.c
+fiddle/handle.c
+fiddle/lib
+fiddle/win32/lib
+gdbm/gdbm.c
+io/console/console.c
+io/nonblock/nonblock.c
+io/wait/lib
+io/wait/wait.c
+json/ext/generator/generator.c
+json/ext/parser/parser.c
+json/lib
+mathn/complex/complex.c
+mathn/rational/rational.c
+nkf/lib
+nkf/nkf.c
+objspace/objspace.c
+objspace/objspace_dump.c
+objspace/object_tracing.c
+openssl/lib
+openssl/ossl.c
+openssl/ossl_asn1.c
+openssl/ossl_bio.c
+openssl/ossl_bn.c
+openssl/ossl_cipher.c
+openssl/ossl_config.c
+openssl/ossl_digest.c
+openssl/ossl_engine.c
+openssl/ossl_hmac.c
+openssl/ossl_ns_spki.c
+openssl/ossl_ocsp.c
+openssl/ossl_pkcs12.c
+openssl/ossl_pkcs5.c
+openssl/ossl_pkcs7.c
+openssl/ossl_pkey.c
+openssl/ossl_pkey_dh.c
+openssl/ossl_pkey_dsa.c
+openssl/ossl_pkey_ec.c
+openssl/ossl_pkey_rsa.c
+openssl/ossl_rand.c
+openssl/ossl_ssl.c
+openssl/ossl_ssl_session.c
+openssl/ossl_x509.c
+openssl/ossl_x509attr.c
+openssl/ossl_x509cert.c
+openssl/ossl_x509crl.c
+openssl/ossl_x509ext.c
+openssl/ossl_x509name.c
+openssl/ossl_x509req.c
+openssl/ossl_x509revoked.c
+openssl/ossl_x509store.c
+pathname/lib
+pathname/pathname.c
+psych/emitter.c
+psych/lib
+psych/parser.c
+psych/psych.c
+psych/to_ruby.c
+psych/yaml_tree.c
+pty/lib
+pty/pty.c
+racc/cparse/cparse.c
+readline/readline.c
+ripper/lib
+ripper/ripper.c
+sdbm/init.c
+socket
+stringio/stringio.c
+strscan/strscan.c
+syslog/syslog.c
+syslog/lib
+thread/thread.c
+win32ole/lib
+win32ole/*.c
+zlib/zlib.c
diff --git a/jni/ruby/ext/Setup b/jni/ruby/ext/Setup
new file mode 100644
index 0000000..98ffffd
--- /dev/null
+++ b/jni/ruby/ext/Setup
@@ -0,0 +1,28 @@
+#option nodynamic
+
+#Win32API
+#bigdecimal
+#dbm
+#digest
+#digest/md5
+#digest/rmd160
+#digest/sha1
+#digest/sha2
+#etc
+#fcntl
+#gdbm
+#io/wait
+#nkf
+#openssl
+#pty
+#racc/cparse
+#readline
+#ripper
+#sdbm
+#socket
+#stringio
+#strscan
+#syslog
+#tk
+#win32ole
+#zlib
diff --git a/jni/ruby/ext/Setup.atheos b/jni/ruby/ext/Setup.atheos
new file mode 100644
index 0000000..41eecd1
--- /dev/null
+++ b/jni/ruby/ext/Setup.atheos
@@ -0,0 +1,29 @@
+option nodynamic
+
+#Win32API
+bigdecimal
+dbm
+digest
+digest/md5
+digest/rmd160
+digest/sha1
+digest/sha2
+enumerator
+etc
+fcntl
+gdbm
+io/wait
+nkf
+#openssl
+pty
+racc/parse
+readline
+ripper
+sdbm
+socket
+stringio
+strscan
+syslog
+#tk
+#win32ole
+zlib
diff --git a/jni/ruby/ext/Setup.emx b/jni/ruby/ext/Setup.emx
new file mode 100644
index 0000000..d976a18
--- /dev/null
+++ b/jni/ruby/ext/Setup.emx
@@ -0,0 +1,31 @@
+# OS/2 environment w/ Autoconf 2.1x for EMX
+option platform os2-emx
+option nodynamic
+
+#Win32API
+bigdecimal
+#dbm
+digest
+digest/md5
+digest/rmd160
+digest/sha1
+digest/sha2
+enumerator
+etc
+fcntl
+#gdbm
+#io/wait
+nkf
+#openssl
+#pty
+racc/cparse
+#readline
+#ripper
+#sdbm
+socket
+stringio
+strscan
+#syslog
+#tk
+#win32ole
+#zlib
diff --git a/jni/ruby/ext/Setup.nacl b/jni/ruby/ext/Setup.nacl
new file mode 100644
index 0000000..ce65ebc
--- /dev/null
+++ b/jni/ruby/ext/Setup.nacl
@@ -0,0 +1,45 @@
+# #option nodynamic
+#
+# #Win32API
+# bigdecimal
+# continuation
+# coverage
+# date
+# #dbm
+# digest/bubblebabble
+# digest
+# digest/md5
+# digest/rmd160
+# digest/sha1
+# digest/sha2
+# etc
+# fcntl
+# fiber
+# #fiddle
+# #gdbm
+# #iconv
+# io/console
+# io/nonblock
+# io/wait
+# #json
+# json/generator
+# json/parser
+# mathn/complex
+# mathn/rational
+# nkf
+# objspace
+# #openssl
+# pathname
+# #psych
+# #pty
+# racc/cparse
+# #readline
+# ripper
+# #sdbm
+# #socket
+# stringio
+# strscan
+# #syslog
+# #tk
+# #tk/tkutil
+# #zlib
diff --git a/jni/ruby/ext/Setup.nt b/jni/ruby/ext/Setup.nt
new file mode 100644
index 0000000..285b1ed
--- /dev/null
+++ b/jni/ruby/ext/Setup.nt
@@ -0,0 +1,30 @@
+#option platform cygwin|mingw|mswin
+#option nodynamic
+
+Win32API
+bigdecimal
+#dbm
+digest
+digest/md5
+digest/rmd160
+digest/sha1
+digest/sha2
+enumerator
+etc
+fcntl
+#gdbm
+#io/wait
+nkf
+#openssl
+#pty
+racc/cparse
+#readline
+#ripper
+sdbm
+socket
+stringio
+strscan
+#syslog
+#tk
+win32ole
+#zlib
diff --git a/jni/ruby/ext/bigdecimal/Makefile b/jni/ruby/ext/bigdecimal/Makefile
new file mode 100644
index 0000000..2da9ab2
--- /dev/null
+++ b/jni/ruby/ext/bigdecimal/Makefile
@@ -0,0 +1,313 @@
+
+SHELL = /bin/sh
+
+# V=0 quiet, V=1 verbose. other values don't work.
+V = 0
+Q1 = $(V:1=)
+Q = $(Q1:0=@)
+ECHO1 = $(V:1=@:)
+ECHO = $(ECHO1:0=@echo)
+NULLCMD = :
+
+#### Start of system configuration section. ####
+top_srcdir = $(topdir)/.
+srcdir = $(top_srcdir)/ext/bigdecimal
+topdir = ../..
+hdrdir = $(top_srcdir)/include
+arch_hdrdir = $(extout)/include/$(arch)
+PATH_SEPARATOR = :
+VPATH = $(srcdir):$(arch_hdrdir)/ruby:$(hdrdir)/ruby
+RUBYLIB =
+RUBYOPT = -
+prefix = $(DESTDIR)/usr/local
+rubysitearchprefix = $(rubylibprefix)/$(sitearch)
+rubyarchprefix = $(rubylibprefix)/$(arch)
+rubylibprefix = $(libdir)/$(RUBY_BASE_NAME)
+exec_prefix = $(prefix)
+vendorarchhdrdir = $(vendorhdrdir)/$(sitearch)
+sitearchhdrdir = $(sitehdrdir)/$(sitearch)
+rubyarchhdrdir = $(rubyhdrdir)/$(arch)
+vendorhdrdir = $(rubyhdrdir)/vendor_ruby
+sitehdrdir = $(rubyhdrdir)/site_ruby
+rubyhdrdir = $(includedir)/$(RUBY_VERSION_NAME)
+vendorarchdir = $(vendorlibdir)/$(sitearch)
+vendorlibdir = $(vendordir)/$(ruby_version)
+vendordir = $(rubylibprefix)/vendor_ruby
+sitearchdir = $(sitelibdir)/$(sitearch)
+sitelibdir = $(sitedir)/$(ruby_version)
+sitedir = $(rubylibprefix)/site_ruby
+rubyarchdir = $(rubylibdir)/$(arch)
+rubylibdir = $(rubylibprefix)/$(ruby_version)
+sitearchincludedir = $(includedir)/$(sitearch)
+archincludedir = $(includedir)/$(arch)
+sitearchlibdir = $(libdir)/$(sitearch)
+archlibdir = $(libdir)/$(arch)
+ridir = $(datarootdir)/$(RI_BASE_NAME)
+mandir = $(datarootdir)/man
+localedir = $(datarootdir)/locale
+libdir = $(exec_prefix)/lib
+psdir = $(docdir)
+pdfdir = $(docdir)
+dvidir = $(docdir)
+htmldir = $(docdir)
+infodir = $(datarootdir)/info
+docdir = $(datarootdir)/doc/$(PACKAGE)
+oldincludedir = $(DESTDIR)/usr/include
+includedir = $(prefix)/include
+localstatedir = $(prefix)/var
+sharedstatedir = $(prefix)/com
+sysconfdir = $(prefix)/etc
+datadir = $(datarootdir)
+datarootdir = $(prefix)/share
+libexecdir = $(exec_prefix)/libexec
+sbindir = $(exec_prefix)/sbin
+bindir = $(exec_prefix)/bin
+archdir = $(rubyarchdir)
+
+
+CC = gcc
+CXX = g++
+LIBRUBY = $(LIBRUBY_SO)
+LIBRUBY_A = lib$(RUBY_SO_NAME)-static.a
+LIBRUBYARG_SHARED = -Wl,-R$(libdir) -L$(libdir) -l$(RUBY_SO_NAME)
+LIBRUBYARG_STATIC = -Wl,-R$(libdir) -L$(libdir) -l$(RUBY_SO_NAME)-static
+empty =
+OUTFLAG = -o $(empty)
+COUTFLAG = -o $(empty)
+
+RUBY_EXTCONF_H = extconf.h
+cflags = $(optflags) $(debugflags) $(warnflags)
+optflags = -O3 -fno-fast-math
+debugflags = -ggdb3
+warnflags = -Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wunused-variable -Wpointer-arith -Wwrite-strings -Wdeclaration-after-statement -Wimplicit-function-declaration -Wdeprecated-declarations -Wno-packed-bitfield-compat
+CCDLFLAGS = -fPIC
+CFLAGS = $(CCDLFLAGS) $(cflags) -fPIC $(ARCH_FLAG)
+INCFLAGS = -I. -I$(arch_hdrdir) -I$(hdrdir) -I$(srcdir)
+DEFS =
+CPPFLAGS = -DRUBY_EXTCONF_H=\"$(RUBY_EXTCONF_H)\" $(DEFS) $(cppflags)
+CXXFLAGS = $(CCDLFLAGS) $(cxxflags) $(ARCH_FLAG)
+ldflags = -L. -fstack-protector -rdynamic -Wl,-export-dynamic
+dldflags =
+ARCH_FLAG =
+DLDFLAGS = $(ldflags) $(dldflags) $(ARCH_FLAG)
+LDSHARED = $(CC) -shared
+LDSHAREDXX = $(CXX) -shared
+AR = ar
+EXEEXT =
+
+RUBY_INSTALL_NAME = $(RUBY_BASE_NAME)
+RUBY_SO_NAME = ruby
+RUBYW_INSTALL_NAME =
+RUBY_VERSION_NAME = $(RUBY_BASE_NAME)-$(ruby_version)
+RUBYW_BASE_NAME = rubyw
+RUBY_BASE_NAME = ruby
+
+arch = x86_64-linux
+sitearch = $(arch)
+ruby_version = 2.2.0
+ruby = $(topdir)/miniruby -I'$(topdir)' -I'$(top_srcdir)/lib' -I'$(extout)/$(arch)' -I'$(extout)/common'
+RUBY = $(ruby)
+ruby_headers = $(hdrdir)/ruby.h $(hdrdir)/ruby/ruby.h $(hdrdir)/ruby/defines.h $(hdrdir)/ruby/missing.h $(hdrdir)/ruby/intern.h $(hdrdir)/ruby/st.h $(hdrdir)/ruby/subst.h $(arch_hdrdir)/ruby/config.h $(RUBY_EXTCONF_H)
+
+RM = rm -f
+RM_RF = $(RUBY) -run -e rm -- -rf
+RMDIRS = rmdir --ignore-fail-on-non-empty -p
+MAKEDIRS = /bin/mkdir -p
+INSTALL = /usr/bin/install -c
+INSTALL_PROG = $(INSTALL) -m 0755
+INSTALL_DATA = $(INSTALL) -m 644
+COPY = cp
+TOUCH = exit >
+
+#### End of system configuration section. ####
+
+preload =
+
+libpath = . $(topdir)
+LIBPATH = -L. -L$(topdir)
+DEFFILE =
+
+CLEANFILES = mkmf.log
+DISTCLEANFILES =
+DISTCLEANDIRS =
+
+extout = $(topdir)/.ext
+extout_prefix = $(extout)$(target_prefix)/
+target_prefix =
+LOCAL_LIBS =
+LIBS = $(LIBRUBYARG_SHARED) -lpthread -lgmp -ldl -lcrypt -lm -lc
+ORIG_SRCS = bigdecimal.c
+SRCS = $(ORIG_SRCS)
+OBJS = bigdecimal.o
+HDRS = $(srcdir)/extconf.h $(srcdir)/bigdecimal.h
+TARGET = bigdecimal
+TARGET_NAME = bigdecimal
+TARGET_ENTRY = Init_$(TARGET_NAME)
+DLLIB = $(TARGET).so
+EXTSTATIC =
+STATIC_LIB = $(TARGET).a
+
+TIMESTAMP_DIR = $(extout)/.timestamp
+BINDIR = $(extout)/bin
+RUBYCOMMONDIR = $(extout)/common
+RUBYLIBDIR = $(RUBYCOMMONDIR)$(target_prefix)
+RUBYARCHDIR = $(extout)/$(arch)$(target_prefix)
+HDRDIR = $(extout)/include/ruby$(target_prefix)
+ARCHHDRDIR = $(extout)/include/$(arch)/ruby$(target_prefix)
+
+TARGET_SO = $(RUBYARCHDIR)/$(DLLIB)
+CLEANLIBS = $(RUBYARCHDIR)/$(TARGET).so
+CLEANOBJS = *.o *.bak
+
+all: install
+static: all
+.PHONY: all install static install-so install-rb
+.PHONY: clean clean-so clean-static clean-rb
+
+clean-static::
+clean-rb-default::
+clean-rb::
+clean-so::
+clean: clean-so clean-static clean-rb-default clean-rb
+ -$(Q)$(RM) $(CLEANLIBS) $(CLEANOBJS) $(CLEANFILES) .*.time
+
+distclean-rb-default::
+distclean-rb::
+distclean-so::
+distclean-static::
+distclean: clean distclean-so distclean-static distclean-rb-default distclean-rb
+ -$(Q)$(RM) Makefile $(RUBY_EXTCONF_H) conftest.* mkmf.log
+ -$(Q)$(RM) core ruby$(EXEEXT) *~ $(DISTCLEANFILES)
+ -$(Q)$(RMDIRS) $(DISTCLEANDIRS) 2> /dev/null || true
+
+realclean: distclean
+install: install-so install-rb
+
+install-so: $(RUBYARCHDIR)/$(DLLIB)
+clean-so::
+ -$(Q)$(RM) $(RUBYARCHDIR)/$(DLLIB)
+ -$(Q)$(RMDIRS) $(RUBYARCHDIR) 2> /dev/null || true
+clean-static::
+ -$(Q)$(RM) $(STATIC_LIB)
+install-rb: pre-install-rb install-rb-default
+install-rb-default: pre-install-rb-default
+pre-install-rb: Makefile
+pre-install-rb-default: Makefile
+pre-install-rb-default: $(TIMESTAMP_DIR)/.RUBYLIBDIR.-.bigdecimal.time
+install-rb-default: $(RUBYLIBDIR)/bigdecimal/math.rb
+$(RUBYLIBDIR)/bigdecimal/math.rb: $(srcdir)/lib/bigdecimal/math.rb $(TIMESTAMP_DIR)/.RUBYLIBDIR.-.bigdecimal.time
+ $(Q) $(COPY) $(srcdir)/lib/bigdecimal/math.rb $(@D)
+clean-rb-default::
+ -$(Q)$(RM) $(RUBYLIBDIR)/bigdecimal/math.rb
+install-rb-default: $(RUBYLIBDIR)/bigdecimal/ludcmp.rb
+$(RUBYLIBDIR)/bigdecimal/ludcmp.rb: $(srcdir)/lib/bigdecimal/ludcmp.rb $(TIMESTAMP_DIR)/.RUBYLIBDIR.-.bigdecimal.time
+ $(Q) $(COPY) $(srcdir)/lib/bigdecimal/ludcmp.rb $(@D)
+clean-rb-default::
+ -$(Q)$(RM) $(RUBYLIBDIR)/bigdecimal/ludcmp.rb
+install-rb-default: $(RUBYLIBDIR)/bigdecimal/newton.rb
+$(RUBYLIBDIR)/bigdecimal/newton.rb: $(srcdir)/lib/bigdecimal/newton.rb $(TIMESTAMP_DIR)/.RUBYLIBDIR.-.bigdecimal.time
+ $(Q) $(COPY) $(srcdir)/lib/bigdecimal/newton.rb $(@D)
+clean-rb-default::
+ -$(Q)$(RM) $(RUBYLIBDIR)/bigdecimal/newton.rb
+install-rb-default: $(RUBYLIBDIR)/bigdecimal/util.rb
+$(RUBYLIBDIR)/bigdecimal/util.rb: $(srcdir)/lib/bigdecimal/util.rb $(TIMESTAMP_DIR)/.RUBYLIBDIR.-.bigdecimal.time
+ $(Q) $(COPY) $(srcdir)/lib/bigdecimal/util.rb $(@D)
+clean-rb-default::
+ -$(Q)$(RM) $(RUBYLIBDIR)/bigdecimal/util.rb
+install-rb-default: $(RUBYLIBDIR)/bigdecimal/jacobian.rb
+$(RUBYLIBDIR)/bigdecimal/jacobian.rb: $(srcdir)/lib/bigdecimal/jacobian.rb $(TIMESTAMP_DIR)/.RUBYLIBDIR.-.bigdecimal.time
+ $(Q) $(COPY) $(srcdir)/lib/bigdecimal/jacobian.rb $(@D)
+clean-rb-default::
+ -$(Q)$(RM) $(RUBYLIBDIR)/bigdecimal/jacobian.rb
+pre-install-rb-default:
+ $(ECHO) installing default bigdecimal libraries
+clean-rb-default::
+ -$(Q)$(RMDIRS) $(RUBYLIBDIR)/bigdecimal 2> /dev/null || true
+$(TIMESTAMP_DIR)/.RUBYARCHDIR.time:
+ $(Q) $(MAKEDIRS) $(@D) $(RUBYARCHDIR)
+ $(Q) $(TOUCH) $@
+$(TIMESTAMP_DIR)/.RUBYLIBDIR.-.bigdecimal.time:
+ $(Q) $(MAKEDIRS) $(@D) $(RUBYLIBDIR)/bigdecimal
+ $(Q) $(TOUCH) $@
+
+site-install: site-install-so site-install-rb
+site-install-so: install-so
+site-install-rb: install-rb
+
+.SUFFIXES: .c .m .cc .mm .cxx .cpp .o .S
+
+.cc.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<
+
+.cc.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -S $<
+
+.mm.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<
+
+.mm.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -S $<
+
+.cxx.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<
+
+.cxx.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -S $<
+
+.cpp.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<
+
+.cpp.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -S $<
+
+.c.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -c $<
+
+.c.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -S $<
+
+.m.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -c $<
+
+.m.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -S $<
+
+$(RUBYARCHDIR)/$(DLLIB): $(OBJS) Makefile $(TIMESTAMP_DIR)/.RUBYARCHDIR.time
+ $(ECHO) linking shared-object $(DLLIB)
+ -$(Q)$(RM) $(@)
+ $(Q) $(LDSHARED) -o $@ $(OBJS) $(LIBPATH) $(DLDFLAGS) $(LOCAL_LIBS) $(LIBS)
+
+$(STATIC_LIB): $(OBJS)
+ -$(Q)$(RM) $(@)
+ $(ECHO) linking static-library $(@)
+ $(Q) $(AR) cru $@ $(OBJS)
+ -$(Q)ranlib $(@) 2> /dev/null || true
+
+###
+$(OBJS): $(RUBY_EXTCONF_H)
+
+# AUTOGENERATED DEPENDENCIES START
+bigdecimal.o: $(RUBY_EXTCONF_H)
+bigdecimal.o: $(arch_hdrdir)/ruby/config.h
+bigdecimal.o: $(hdrdir)/ruby/defines.h
+bigdecimal.o: $(hdrdir)/ruby/intern.h
+bigdecimal.o: $(hdrdir)/ruby/missing.h
+bigdecimal.o: $(hdrdir)/ruby/st.h
+bigdecimal.o: $(hdrdir)/ruby/subst.h
+bigdecimal.o: $(hdrdir)/ruby/util.h
+bigdecimal.o: $(hdrdir)/ruby/ruby.h
+bigdecimal.o: bigdecimal.c
+bigdecimal.o: bigdecimal.h
+# AUTOGENERATED DEPENDENCIES END
diff --git a/jni/ruby/ext/bigdecimal/bigdecimal.c b/jni/ruby/ext/bigdecimal/bigdecimal.c
new file mode 100644
index 0000000..aabdbc6
--- /dev/null
+++ b/jni/ruby/ext/bigdecimal/bigdecimal.c
@@ -0,0 +1,6266 @@
+/*
+ *
+ * Ruby BigDecimal(Variable decimal precision) extension library.
+ *
+ * Copyright(C) 2002 by Shigeo Kobayashi(shigeo@tinyforest.gr.jp)
+ *
+ */
+
+/* #define BIGDECIMAL_DEBUG 1 */
+#ifdef BIGDECIMAL_DEBUG
+# define BIGDECIMAL_ENABLE_VPRINT 1
+#endif
+#include "bigdecimal.h"
+#include "ruby/util.h"
+
+#ifndef BIGDECIMAL_DEBUG
+# define NDEBUG
+#endif
+#include <assert.h>
+
+#include <ctype.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <errno.h>
+#include <math.h>
+#include "math.h"
+
+#ifdef HAVE_IEEEFP_H
+#include <ieeefp.h>
+#endif
+
+/* #define ENABLE_NUMERIC_STRING */
+
+#define MUL_OVERFLOW_SIGNED_INTEGER_P(a, b, min, max) ( \
+ (a) == 0 ? 0 : \
+ (a) == -1 ? (b) < -(max) : \
+ (a) > 0 ? \
+ ((b) > 0 ? (max) / (a) < (b) : (min) / (a) > (b)) : \
+ ((b) > 0 ? (min) / (a) < (b) : (max) / (a) > (b)))
+#define SIGNED_VALUE_MAX INTPTR_MAX
+#define SIGNED_VALUE_MIN INTPTR_MIN
+#define MUL_OVERFLOW_SIGNED_VALUE_P(a, b) MUL_OVERFLOW_SIGNED_INTEGER_P(a, b, SIGNED_VALUE_MIN, SIGNED_VALUE_MAX)
+
+VALUE rb_cBigDecimal;
+VALUE rb_mBigMath;
+
+static ID id_BigDecimal_exception_mode;
+static ID id_BigDecimal_rounding_mode;
+static ID id_BigDecimal_precision_limit;
+
+static ID id_up;
+static ID id_down;
+static ID id_truncate;
+static ID id_half_up;
+static ID id_default;
+static ID id_half_down;
+static ID id_half_even;
+static ID id_banker;
+static ID id_ceiling;
+static ID id_ceil;
+static ID id_floor;
+static ID id_to_r;
+static ID id_eq;
+
+/* MACRO's to guard objects from GC by keeping them in stack */
+#define ENTER(n) volatile VALUE RB_UNUSED_VAR(vStack[n]);int iStack=0
+#define PUSH(x) (vStack[iStack++] = (VALUE)(x))
+#define SAVE(p) PUSH((p)->obj)
+#define GUARD_OBJ(p,y) ((p)=(y), SAVE(p))
+
+#define BASE_FIG RMPD_COMPONENT_FIGURES
+#define BASE RMPD_BASE
+
+#define HALF_BASE (BASE/2)
+#define BASE1 (BASE/10)
+
+#ifndef DBLE_FIG
+#define DBLE_FIG (DBL_DIG+1) /* figure of double */
+#endif
+
+#ifndef RRATIONAL_ZERO_P
+# define RRATIONAL_ZERO_P(x) (FIXNUM_P(rb_rational_num(x)) && \
+ FIX2LONG(rb_rational_num(x)) == 0)
+#endif
+
+#ifndef RRATIONAL_NEGATIVE_P
+# define RRATIONAL_NEGATIVE_P(x) RTEST(rb_funcall((x), '<', 1, INT2FIX(0)))
+#endif
+
+#ifndef DECIMAL_SIZE_OF_BITS
+#define DECIMAL_SIZE_OF_BITS(n) (((n) * 3010 + 9998) / 9999)
+/* an approximation of ceil(n * log10(2)), upto 65536 at least */
+#endif
+
+#ifdef PRIsVALUE
+# define RB_OBJ_CLASSNAME(obj) rb_obj_class(obj)
+# define RB_OBJ_STRING(obj) (obj)
+#else
+# define PRIsVALUE "s"
+# define RB_OBJ_CLASSNAME(obj) rb_obj_classname(obj)
+# define RB_OBJ_STRING(obj) StringValueCStr(obj)
+#endif
+
+/*
+ * ================== Ruby Interface part ==========================
+ */
+#define DoSomeOne(x,y,f) rb_num_coerce_bin(x,y,f)
+
+/*
+ * Returns the BigDecimal version number.
+ */
+static VALUE
+BigDecimal_version(VALUE self)
+{
+ /*
+ * 1.0.0: Ruby 1.8.0
+ * 1.0.1: Ruby 1.8.1
+ * 1.1.0: Ruby 1.9.3
+ */
+ return rb_str_new2("1.1.0");
+}
+
+/*
+ * VP routines used in BigDecimal part
+ */
+static unsigned short VpGetException(void);
+static void VpSetException(unsigned short f);
+static void VpInternalRound(Real *c, size_t ixDigit, BDIGIT vPrev, BDIGIT v);
+static int VpLimitRound(Real *c, size_t ixDigit);
+static Real *VpCopy(Real *pv, Real const* const x);
+
+#ifdef BIGDECIMAL_ENABLE_VPRINT
+static int VPrint(FILE *fp,const char *cntl_chr,Real *a);
+#endif
+
+/*
+ * **** BigDecimal part ****
+ */
+
+static void
+BigDecimal_delete(void *pv)
+{
+ VpFree(pv);
+}
+
+static size_t
+BigDecimal_memsize(const void *ptr)
+{
+ const Real *pv = ptr;
+ return pv ? (sizeof(*pv) + pv->MaxPrec * sizeof(BDIGIT)) : 0;
+}
+
+static const rb_data_type_t BigDecimal_data_type = {
+ "BigDecimal",
+ { 0, BigDecimal_delete, BigDecimal_memsize, },
+#ifdef RUBY_TYPED_FREE_IMMEDIATELY
+ 0, 0, RUBY_TYPED_FREE_IMMEDIATELY
+#endif
+};
+
+static inline int
+is_kind_of_BigDecimal(VALUE const v)
+{
+ return rb_typeddata_is_kind_of(v, &BigDecimal_data_type);
+}
+
+static VALUE
+ToValue(Real *p)
+{
+ if (VpIsNaN(p)) {
+ VpException(VP_EXCEPTION_NaN, "Computation results to 'NaN'(Not a Number)", 0);
+ }
+ else if (VpIsPosInf(p)) {
+ VpException(VP_EXCEPTION_INFINITY, "Computation results to 'Infinity'", 0);
+ }
+ else if (VpIsNegInf(p)) {
+ VpException(VP_EXCEPTION_INFINITY, "Computation results to '-Infinity'", 0);
+ }
+ return p->obj;
+}
+
+NORETURN(static void cannot_be_coerced_into_BigDecimal(VALUE, VALUE));
+
+static void
+cannot_be_coerced_into_BigDecimal(VALUE exc_class, VALUE v)
+{
+ VALUE str;
+
+ if (rb_special_const_p(v)) {
+ str = rb_inspect(v);
+ }
+ else {
+ str = rb_class_name(rb_obj_class(v));
+ }
+
+ str = rb_str_cat2(rb_str_dup(str), " can't be coerced into BigDecimal");
+ rb_exc_raise(rb_exc_new3(exc_class, str));
+}
+
+static inline VALUE BigDecimal_div2(VALUE, VALUE, VALUE);
+
+static Real*
+GetVpValueWithPrec(VALUE v, long prec, int must)
+{
+ Real *pv;
+ VALUE num, bg;
+ char szD[128];
+ VALUE orig = Qundef;
+ double d;
+
+again:
+ switch(TYPE(v)) {
+ case T_FLOAT:
+ if (prec < 0) goto unable_to_coerce_without_prec;
+ if (prec > DBL_DIG+1) goto SomeOneMayDoIt;
+ d = RFLOAT_VALUE(v);
+ if (d != 0.0) {
+ v = rb_funcall(v, id_to_r, 0);
+ goto again;
+ }
+ if (1/d < 0.0) {
+ return VpCreateRbObject(prec, "-0");
+ }
+ return VpCreateRbObject(prec, "0");
+
+ case T_RATIONAL:
+ if (prec < 0) goto unable_to_coerce_without_prec;
+
+ if (orig == Qundef ? (orig = v, 1) : orig != v) {
+ num = rb_rational_num(v);
+ pv = GetVpValueWithPrec(num, -1, must);
+ if (pv == NULL) goto SomeOneMayDoIt;
+
+ v = BigDecimal_div2(ToValue(pv), rb_rational_den(v), LONG2NUM(prec));
+ goto again;
+ }
+
+ v = orig;
+ goto SomeOneMayDoIt;
+
+ case T_DATA:
+ if (is_kind_of_BigDecimal(v)) {
+ pv = DATA_PTR(v);
+ return pv;
+ }
+ else {
+ goto SomeOneMayDoIt;
+ }
+ break;
+
+ case T_FIXNUM:
+ sprintf(szD, "%ld", FIX2LONG(v));
+ return VpCreateRbObject(VpBaseFig() * 2 + 1, szD);
+
+#ifdef ENABLE_NUMERIC_STRING
+ case T_STRING:
+ SafeStringValue(v);
+ return VpCreateRbObject(strlen(RSTRING_PTR(v)) + VpBaseFig() + 1,
+ RSTRING_PTR(v));
+#endif /* ENABLE_NUMERIC_STRING */
+
+ case T_BIGNUM:
+ bg = rb_big2str(v, 10);
+ return VpCreateRbObject(strlen(RSTRING_PTR(bg)) + VpBaseFig() + 1,
+ RSTRING_PTR(bg));
+ default:
+ goto SomeOneMayDoIt;
+ }
+
+SomeOneMayDoIt:
+ if (must) {
+ cannot_be_coerced_into_BigDecimal(rb_eTypeError, v);
+ }
+ return NULL; /* NULL means to coerce */
+
+unable_to_coerce_without_prec:
+ if (must) {
+ rb_raise(rb_eArgError,
+ "%"PRIsVALUE" can't be coerced into BigDecimal without a precision",
+ RB_OBJ_CLASSNAME(v));
+ }
+ return NULL;
+}
+
+static Real*
+GetVpValue(VALUE v, int must)
+{
+ return GetVpValueWithPrec(v, -1, must);
+}
+
+/* call-seq:
+ * BigDecimal.double_fig
+ *
+ * The BigDecimal.double_fig class method returns the number of digits a
+ * Float number is allowed to have. The result depends upon the CPU and OS
+ * in use.
+ */
+static VALUE
+BigDecimal_double_fig(VALUE self)
+{
+ return INT2FIX(VpDblFig());
+}
+
+/* call-seq:
+ * precs
+ *
+ * Returns an Array of two Integer values.
+ *
+ * The first value is the current number of significant digits in the
+ * BigDecimal. The second value is the maximum number of significant digits
+ * for the BigDecimal.
+ */
+static VALUE
+BigDecimal_prec(VALUE self)
+{
+ ENTER(1);
+ Real *p;
+ VALUE obj;
+
+ GUARD_OBJ(p, GetVpValue(self, 1));
+ obj = rb_assoc_new(INT2NUM(p->Prec*VpBaseFig()),
+ INT2NUM(p->MaxPrec*VpBaseFig()));
+ return obj;
+}
+
+/*
+ * call-seq: hash
+ *
+ * Creates a hash for this BigDecimal.
+ *
+ * Two BigDecimals with equal sign,
+ * fractional part and exponent have the same hash.
+ */
+static VALUE
+BigDecimal_hash(VALUE self)
+{
+ ENTER(1);
+ Real *p;
+ st_index_t hash;
+
+ GUARD_OBJ(p, GetVpValue(self, 1));
+ hash = (st_index_t)p->sign;
+ /* hash!=2: the case for 0(1),NaN(0) or +-Infinity(3) is sign itself */
+ if(hash == 2 || hash == (st_index_t)-2) {
+ hash ^= rb_memhash(p->frac, sizeof(BDIGIT)*p->Prec);
+ hash += p->exponent;
+ }
+ return INT2FIX(hash);
+}
+
+/*
+ * call-seq: _dump
+ *
+ * Method used to provide marshalling support.
+ *
+ * inf = BigDecimal.new('Infinity')
+ * => #<BigDecimal:1e16fa8,'Infinity',9(9)>
+ * BigDecimal._load(inf._dump)
+ * => #<BigDecimal:1df8dc8,'Infinity',9(9)>
+ *
+ * See the Marshal module.
+ */
+static VALUE
+BigDecimal_dump(int argc, VALUE *argv, VALUE self)
+{
+ ENTER(5);
+ Real *vp;
+ char *psz;
+ VALUE dummy;
+ volatile VALUE dump;
+
+ rb_scan_args(argc, argv, "01", &dummy);
+ GUARD_OBJ(vp,GetVpValue(self, 1));
+ dump = rb_str_new(0, VpNumOfChars(vp, "E")+50);
+ psz = RSTRING_PTR(dump);
+ sprintf(psz, "%"PRIuSIZE":", VpMaxPrec(vp)*VpBaseFig());
+ VpToString(vp, psz+strlen(psz), 0, 0);
+ rb_str_resize(dump, strlen(psz));
+ return dump;
+}
+
+/*
+ * Internal method used to provide marshalling support. See the Marshal module.
+ */
+static VALUE
+BigDecimal_load(VALUE self, VALUE str)
+{
+ ENTER(2);
+ Real *pv;
+ unsigned char *pch;
+ unsigned char ch;
+ unsigned long m=0;
+
+ SafeStringValue(str);
+ pch = (unsigned char *)RSTRING_PTR(str);
+ /* First get max prec */
+ while((*pch) != (unsigned char)'\0' && (ch = *pch++) != (unsigned char)':') {
+ if(!ISDIGIT(ch)) {
+ rb_raise(rb_eTypeError, "load failed: invalid character in the marshaled string");
+ }
+ m = m*10 + (unsigned long)(ch-'0');
+ }
+ if (m > VpBaseFig()) m -= VpBaseFig();
+ GUARD_OBJ(pv, VpNewRbClass(m, (char *)pch, self));
+ m /= VpBaseFig();
+ if (m && pv->MaxPrec > m) {
+ pv->MaxPrec = m+1;
+ }
+ return ToValue(pv);
+}
+
+static unsigned short
+check_rounding_mode(VALUE const v)
+{
+ unsigned short sw;
+ ID id;
+ switch (TYPE(v)) {
+ case T_SYMBOL:
+ id = SYM2ID(v);
+ if (id == id_up)
+ return VP_ROUND_UP;
+ if (id == id_down || id == id_truncate)
+ return VP_ROUND_DOWN;
+ if (id == id_half_up || id == id_default)
+ return VP_ROUND_HALF_UP;
+ if (id == id_half_down)
+ return VP_ROUND_HALF_DOWN;
+ if (id == id_half_even || id == id_banker)
+ return VP_ROUND_HALF_EVEN;
+ if (id == id_ceiling || id == id_ceil)
+ return VP_ROUND_CEIL;
+ if (id == id_floor)
+ return VP_ROUND_FLOOR;
+ rb_raise(rb_eArgError, "invalid rounding mode");
+
+ default:
+ break;
+ }
+
+ Check_Type(v, T_FIXNUM);
+ sw = (unsigned short)FIX2UINT(v);
+ if (!VpIsRoundMode(sw)) {
+ rb_raise(rb_eArgError, "invalid rounding mode");
+ }
+ return sw;
+}
+
+/* call-seq:
+ * BigDecimal.mode(mode, value)
+ *
+ * Controls handling of arithmetic exceptions and rounding. If no value
+ * is supplied, the current value is returned.
+ *
+ * Six values of the mode parameter control the handling of arithmetic
+ * exceptions:
+ *
+ * BigDecimal::EXCEPTION_NaN
+ * BigDecimal::EXCEPTION_INFINITY
+ * BigDecimal::EXCEPTION_UNDERFLOW
+ * BigDecimal::EXCEPTION_OVERFLOW
+ * BigDecimal::EXCEPTION_ZERODIVIDE
+ * BigDecimal::EXCEPTION_ALL
+ *
+ * For each mode parameter above, if the value set is false, computation
+ * continues after an arithmetic exception of the appropriate type.
+ * When computation continues, results are as follows:
+ *
+ * EXCEPTION_NaN:: NaN
+ * EXCEPTION_INFINITY:: +Infinity or -Infinity
+ * EXCEPTION_UNDERFLOW:: 0
+ * EXCEPTION_OVERFLOW:: +Infinity or -Infinity
+ * EXCEPTION_ZERODIVIDE:: +Infinity or -Infinity
+ *
+ * One value of the mode parameter controls the rounding of numeric values:
+ * BigDecimal::ROUND_MODE. The values it can take are:
+ *
+ * ROUND_UP, :up:: round away from zero
+ * ROUND_DOWN, :down, :truncate:: round towards zero (truncate)
+ * ROUND_HALF_UP, :half_up, :default:: round towards the nearest neighbor, unless both neighbors are equidistant, in which case round away from zero. (default)
+ * ROUND_HALF_DOWN, :half_down:: round towards the nearest neighbor, unless both neighbors are equidistant, in which case round towards zero.
+ * ROUND_HALF_EVEN, :half_even, :banker:: round towards the nearest neighbor, unless both neighbors are equidistant, in which case round towards the even neighbor (Banker's rounding)
+ * ROUND_CEILING, :ceiling, :ceil:: round towards positive infinity (ceil)
+ * ROUND_FLOOR, :floor:: round towards negative infinity (floor)
+ *
+ */
+static VALUE
+BigDecimal_mode(int argc, VALUE *argv, VALUE self)
+{
+ VALUE which;
+ VALUE val;
+ unsigned long f,fo;
+
+ rb_scan_args(argc, argv, "11", &which, &val);
+ Check_Type(which, T_FIXNUM);
+ f = (unsigned long)FIX2INT(which);
+
+ if (f & VP_EXCEPTION_ALL) {
+ /* Exception mode setting */
+ fo = VpGetException();
+ if (val == Qnil) return INT2FIX(fo);
+ if (val != Qfalse && val!=Qtrue) {
+ rb_raise(rb_eArgError, "second argument must be true or false");
+ return Qnil; /* Not reached */
+ }
+ if (f & VP_EXCEPTION_INFINITY) {
+ VpSetException((unsigned short)((val == Qtrue) ? (fo | VP_EXCEPTION_INFINITY) :
+ (fo & (~VP_EXCEPTION_INFINITY))));
+ }
+ fo = VpGetException();
+ if (f & VP_EXCEPTION_NaN) {
+ VpSetException((unsigned short)((val == Qtrue) ? (fo | VP_EXCEPTION_NaN) :
+ (fo & (~VP_EXCEPTION_NaN))));
+ }
+ fo = VpGetException();
+ if (f & VP_EXCEPTION_UNDERFLOW) {
+ VpSetException((unsigned short)((val == Qtrue) ? (fo | VP_EXCEPTION_UNDERFLOW) :
+ (fo & (~VP_EXCEPTION_UNDERFLOW))));
+ }
+ fo = VpGetException();
+ if(f & VP_EXCEPTION_ZERODIVIDE) {
+ VpSetException((unsigned short)((val == Qtrue) ? (fo | VP_EXCEPTION_ZERODIVIDE) :
+ (fo & (~VP_EXCEPTION_ZERODIVIDE))));
+ }
+ fo = VpGetException();
+ return INT2FIX(fo);
+ }
+ if (VP_ROUND_MODE == f) {
+ /* Rounding mode setting */
+ unsigned short sw;
+ fo = VpGetRoundMode();
+ if (NIL_P(val)) return INT2FIX(fo);
+ sw = check_rounding_mode(val);
+ fo = VpSetRoundMode(sw);
+ return INT2FIX(fo);
+ }
+ rb_raise(rb_eTypeError, "first argument for BigDecimal#mode invalid");
+ return Qnil;
+}
+
+static size_t
+GetAddSubPrec(Real *a, Real *b)
+{
+ size_t mxs;
+ size_t mx = a->Prec;
+ SIGNED_VALUE d;
+
+ if (!VpIsDef(a) || !VpIsDef(b)) return (size_t)-1L;
+ if (mx < b->Prec) mx = b->Prec;
+ if (a->exponent != b->exponent) {
+ mxs = mx;
+ d = a->exponent - b->exponent;
+ if (d < 0) d = -d;
+ mx = mx + (size_t)d;
+ if (mx < mxs) {
+ return VpException(VP_EXCEPTION_INFINITY, "Exponent overflow", 0);
+ }
+ }
+ return mx;
+}
+
+static SIGNED_VALUE
+GetPositiveInt(VALUE v)
+{
+ SIGNED_VALUE n;
+ Check_Type(v, T_FIXNUM);
+ n = FIX2INT(v);
+ if (n < 0) {
+ rb_raise(rb_eArgError, "argument must be positive");
+ }
+ return n;
+}
+
+VP_EXPORT Real *
+VpNewRbClass(size_t mx, const char *str, VALUE klass)
+{
+ Real *pv = VpAlloc(mx,str);
+ pv->obj = TypedData_Wrap_Struct(klass, &BigDecimal_data_type, pv);
+ return pv;
+}
+
+VP_EXPORT Real *
+VpCreateRbObject(size_t mx, const char *str)
+{
+ Real *pv = VpAlloc(mx,str);
+ pv->obj = TypedData_Wrap_Struct(rb_cBigDecimal, &BigDecimal_data_type, pv);
+ return pv;
+}
+
+#define VpAllocReal(prec) (Real *)VpMemAlloc(offsetof(Real, frac) + (prec) * sizeof(BDIGIT))
+#define VpReallocReal(ptr, prec) (Real *)VpMemRealloc((ptr), offsetof(Real, frac) + (prec) * sizeof(BDIGIT))
+
+static Real *
+VpCopy(Real *pv, Real const* const x)
+{
+ assert(x != NULL);
+
+ pv = VpReallocReal(pv, x->MaxPrec);
+ pv->MaxPrec = x->MaxPrec;
+ pv->Prec = x->Prec;
+ pv->exponent = x->exponent;
+ pv->sign = x->sign;
+ pv->flag = x->flag;
+ MEMCPY(pv->frac, x->frac, BDIGIT, pv->MaxPrec);
+
+ return pv;
+}
+
+/* Returns True if the value is Not a Number */
+static VALUE
+BigDecimal_IsNaN(VALUE self)
+{
+ Real *p = GetVpValue(self, 1);
+ if (VpIsNaN(p)) return Qtrue;
+ return Qfalse;
+}
+
+/* Returns nil, -1, or +1 depending on whether the value is finite,
+ * -Infinity, or +Infinity.
+ */
+static VALUE
+BigDecimal_IsInfinite(VALUE self)
+{
+ Real *p = GetVpValue(self, 1);
+ if (VpIsPosInf(p)) return INT2FIX(1);
+ if (VpIsNegInf(p)) return INT2FIX(-1);
+ return Qnil;
+}
+
+/* Returns True if the value is finite (not NaN or infinite) */
+static VALUE
+BigDecimal_IsFinite(VALUE self)
+{
+ Real *p = GetVpValue(self, 1);
+ if (VpIsNaN(p)) return Qfalse;
+ if (VpIsInf(p)) return Qfalse;
+ return Qtrue;
+}
+
+static void
+BigDecimal_check_num(Real *p)
+{
+ if (VpIsNaN(p)) {
+ VpException(VP_EXCEPTION_NaN, "Computation results to 'NaN'(Not a Number)", 1);
+ }
+ else if (VpIsPosInf(p)) {
+ VpException(VP_EXCEPTION_INFINITY, "Computation results to 'Infinity'", 1);
+ }
+ else if (VpIsNegInf(p)) {
+ VpException(VP_EXCEPTION_INFINITY, "Computation results to '-Infinity'", 1);
+ }
+}
+
+static VALUE BigDecimal_split(VALUE self);
+
+/* Returns the value as an integer (Fixnum or Bignum).
+ *
+ * If the BigNumber is infinity or NaN, raises FloatDomainError.
+ */
+static VALUE
+BigDecimal_to_i(VALUE self)
+{
+ ENTER(5);
+ ssize_t e, nf;
+ Real *p;
+
+ GUARD_OBJ(p, GetVpValue(self, 1));
+ BigDecimal_check_num(p);
+
+ e = VpExponent10(p);
+ if (e <= 0) return INT2FIX(0);
+ nf = VpBaseFig();
+ if (e <= nf) {
+ return LONG2NUM((long)(VpGetSign(p) * (BDIGIT_DBL_SIGNED)p->frac[0]));
+ }
+ else {
+ VALUE a = BigDecimal_split(self);
+ VALUE digits = RARRAY_PTR(a)[1];
+ VALUE numerator = rb_funcall(digits, rb_intern("to_i"), 0);
+ VALUE ret;
+ ssize_t dpower = e - (ssize_t)RSTRING_LEN(digits);
+
+ if (VpGetSign(p) < 0) {
+ numerator = rb_funcall(numerator, '*', 1, INT2FIX(-1));
+ }
+ if (dpower < 0) {
+ ret = rb_funcall(numerator, rb_intern("div"), 1,
+ rb_funcall(INT2FIX(10), rb_intern("**"), 1,
+ INT2FIX(-dpower)));
+ }
+ else {
+ ret = rb_funcall(numerator, '*', 1,
+ rb_funcall(INT2FIX(10), rb_intern("**"), 1,
+ INT2FIX(dpower)));
+ }
+ if (RB_TYPE_P(ret, T_FLOAT)) {
+ rb_raise(rb_eFloatDomainError, "Infinity");
+ }
+ return ret;
+ }
+}
+
+/* Returns a new Float object having approximately the same value as the
+ * BigDecimal number. Normal accuracy limits and built-in errors of binary
+ * Float arithmetic apply.
+ */
+static VALUE
+BigDecimal_to_f(VALUE self)
+{
+ ENTER(1);
+ Real *p;
+ double d;
+ SIGNED_VALUE e;
+ char *buf;
+ volatile VALUE str;
+
+ GUARD_OBJ(p, GetVpValue(self, 1));
+ if (VpVtoD(&d, &e, p) != 1)
+ return rb_float_new(d);
+ if (e > (SIGNED_VALUE)(DBL_MAX_10_EXP+BASE_FIG))
+ goto overflow;
+ if (e < (SIGNED_VALUE)(DBL_MIN_10_EXP-BASE_FIG))
+ goto underflow;
+
+ str = rb_str_new(0, VpNumOfChars(p, "E"));
+ buf = RSTRING_PTR(str);
+ VpToString(p, buf, 0, 0);
+ errno = 0;
+ d = strtod(buf, 0);
+ if (errno == ERANGE) {
+ if (d == 0.0) goto underflow;
+ if (fabs(d) >= HUGE_VAL) goto overflow;
+ }
+ return rb_float_new(d);
+
+overflow:
+ VpException(VP_EXCEPTION_OVERFLOW, "BigDecimal to Float conversion", 0);
+ if (p->sign >= 0)
+ return rb_float_new(VpGetDoublePosInf());
+ else
+ return rb_float_new(VpGetDoubleNegInf());
+
+underflow:
+ VpException(VP_EXCEPTION_UNDERFLOW, "BigDecimal to Float conversion", 0);
+ if (p->sign >= 0)
+ return rb_float_new(0.0);
+ else
+ return rb_float_new(-0.0);
+}
+
+
+/* Converts a BigDecimal to a Rational.
+ */
+static VALUE
+BigDecimal_to_r(VALUE self)
+{
+ Real *p;
+ ssize_t sign, power, denomi_power;
+ VALUE a, digits, numerator;
+
+ p = GetVpValue(self, 1);
+ BigDecimal_check_num(p);
+
+ sign = VpGetSign(p);
+ power = VpExponent10(p);
+ a = BigDecimal_split(self);
+ digits = RARRAY_PTR(a)[1];
+ denomi_power = power - RSTRING_LEN(digits);
+ numerator = rb_funcall(digits, rb_intern("to_i"), 0);
+
+ if (sign < 0) {
+ numerator = rb_funcall(numerator, '*', 1, INT2FIX(-1));
+ }
+ if (denomi_power < 0) {
+ return rb_Rational(numerator,
+ rb_funcall(INT2FIX(10), rb_intern("**"), 1,
+ INT2FIX(-denomi_power)));
+ }
+ else {
+ return rb_Rational1(rb_funcall(numerator, '*', 1,
+ rb_funcall(INT2FIX(10), rb_intern("**"), 1,
+ INT2FIX(denomi_power))));
+ }
+}
+
+/* The coerce method provides support for Ruby type coercion. It is not
+ * enabled by default.
+ *
+ * This means that binary operations like + * / or - can often be performed
+ * on a BigDecimal and an object of another type, if the other object can
+ * be coerced into a BigDecimal value.
+ *
+ * e.g.
+ * a = BigDecimal.new("1.0")
+ * b = a / 2.0 -> 0.5
+ *
+ * Note that coercing a String to a BigDecimal is not supported by default;
+ * it requires a special compile-time option when building Ruby.
+ */
+static VALUE
+BigDecimal_coerce(VALUE self, VALUE other)
+{
+ ENTER(2);
+ VALUE obj;
+ Real *b;
+
+ if (RB_TYPE_P(other, T_FLOAT)) {
+ GUARD_OBJ(b, GetVpValueWithPrec(other, DBL_DIG+1, 1));
+ obj = rb_assoc_new(ToValue(b), self);
+ }
+ else {
+ if (RB_TYPE_P(other, T_RATIONAL)) {
+ Real* pv = DATA_PTR(self);
+ GUARD_OBJ(b, GetVpValueWithPrec(other, pv->Prec*VpBaseFig(), 1));
+ }
+ else {
+ GUARD_OBJ(b, GetVpValue(other, 1));
+ }
+ obj = rb_assoc_new(b->obj, self);
+ }
+
+ return obj;
+}
+
+/*
+ * call-seq: +@
+ *
+ * Return self.
+ *
+ * e.g.
+ * b = +a # b == a
+ */
+static VALUE
+BigDecimal_uplus(VALUE self)
+{
+ return self;
+}
+
+ /*
+ * Document-method: BigDecimal#add
+ * Document-method: BigDecimal#+
+ *
+ * call-seq:
+ * add(value, digits)
+ *
+ * Add the specified value.
+ *
+ * e.g.
+ * c = a.add(b,n)
+ * c = a + b
+ *
+ * digits:: If specified and less than the number of significant digits of the
+ * result, the result is rounded to that number of digits, according to
+ * BigDecimal.mode.
+ */
+static VALUE
+BigDecimal_add(VALUE self, VALUE r)
+{
+ ENTER(5);
+ Real *c, *a, *b;
+ size_t mx;
+
+ GUARD_OBJ(a, GetVpValue(self, 1));
+ if (RB_TYPE_P(r, T_FLOAT)) {
+ b = GetVpValueWithPrec(r, DBL_DIG+1, 1);
+ }
+ else if (RB_TYPE_P(r, T_RATIONAL)) {
+ b = GetVpValueWithPrec(r, a->Prec*VpBaseFig(), 1);
+ }
+ else {
+ b = GetVpValue(r, 0);
+ }
+
+ if (!b) return DoSomeOne(self,r,'+');
+ SAVE(b);
+
+ if (VpIsNaN(b)) return b->obj;
+ if (VpIsNaN(a)) return a->obj;
+
+ mx = GetAddSubPrec(a, b);
+ if (mx == (size_t)-1L) {
+ GUARD_OBJ(c,VpCreateRbObject(VpBaseFig() + 1, "0"));
+ VpAddSub(c, a, b, 1);
+ }
+ else {
+ GUARD_OBJ(c, VpCreateRbObject(mx * (VpBaseFig() + 1), "0"));
+ if(!mx) {
+ VpSetInf(c, VpGetSign(a));
+ }
+ else {
+ VpAddSub(c, a, b, 1);
+ }
+ }
+ return ToValue(c);
+}
+
+ /* call-seq:
+ * value - digits -> bigdecimal
+ *
+ * Subtract the specified value.
+ *
+ * e.g.
+ * c = a - b
+ *
+ * The precision of the result value depends on the type of +b+.
+ *
+ * If +b+ is a Float, the precision of the result is Float::DIG+1.
+ *
+ * If +b+ is a BigDecimal, the precision of the result is +b+'s precision of
+ * internal representation from platform. So, it's return value is platform
+ * dependent.
+ *
+ */
+static VALUE
+BigDecimal_sub(VALUE self, VALUE r)
+{
+ ENTER(5);
+ Real *c, *a, *b;
+ size_t mx;
+
+ GUARD_OBJ(a, GetVpValue(self,1));
+ if (RB_TYPE_P(r, T_FLOAT)) {
+ b = GetVpValueWithPrec(r, DBL_DIG+1, 1);
+ }
+ else if (RB_TYPE_P(r, T_RATIONAL)) {
+ b = GetVpValueWithPrec(r, a->Prec*VpBaseFig(), 1);
+ }
+ else {
+ b = GetVpValue(r,0);
+ }
+
+ if (!b) return DoSomeOne(self,r,'-');
+ SAVE(b);
+
+ if (VpIsNaN(b)) return b->obj;
+ if (VpIsNaN(a)) return a->obj;
+
+ mx = GetAddSubPrec(a,b);
+ if (mx == (size_t)-1L) {
+ GUARD_OBJ(c,VpCreateRbObject(VpBaseFig() + 1, "0"));
+ VpAddSub(c, a, b, -1);
+ }
+ else {
+ GUARD_OBJ(c,VpCreateRbObject(mx *(VpBaseFig() + 1), "0"));
+ if (!mx) {
+ VpSetInf(c,VpGetSign(a));
+ }
+ else {
+ VpAddSub(c, a, b, -1);
+ }
+ }
+ return ToValue(c);
+}
+
+static VALUE
+BigDecimalCmp(VALUE self, VALUE r,char op)
+{
+ ENTER(5);
+ SIGNED_VALUE e;
+ Real *a, *b=0;
+ GUARD_OBJ(a, GetVpValue(self, 1));
+ switch (TYPE(r)) {
+ case T_DATA:
+ if (!is_kind_of_BigDecimal(r)) break;
+ /* fall through */
+ case T_FIXNUM:
+ /* fall through */
+ case T_BIGNUM:
+ GUARD_OBJ(b, GetVpValue(r, 0));
+ break;
+
+ case T_FLOAT:
+ GUARD_OBJ(b, GetVpValueWithPrec(r, DBL_DIG+1, 0));
+ break;
+
+ case T_RATIONAL:
+ GUARD_OBJ(b, GetVpValueWithPrec(r, a->Prec*VpBaseFig(), 0));
+ break;
+
+ default:
+ break;
+ }
+ if (b == NULL) {
+ ID f = 0;
+
+ switch (op) {
+ case '*':
+ return rb_num_coerce_cmp(self, r, rb_intern("<=>"));
+
+ case '=':
+ return RTEST(rb_num_coerce_cmp(self, r, rb_intern("=="))) ? Qtrue : Qfalse;
+
+ case 'G':
+ f = rb_intern(">=");
+ break;
+
+ case 'L':
+ f = rb_intern("<=");
+ break;
+
+ case '>':
+ /* fall through */
+ case '<':
+ f = (ID)op;
+ break;
+
+ default:
+ break;
+ }
+ return rb_num_coerce_relop(self, r, f);
+ }
+ SAVE(b);
+ e = VpComp(a, b);
+ if (e == 999)
+ return (op == '*') ? Qnil : Qfalse;
+ switch (op) {
+ case '*':
+ return INT2FIX(e); /* any op */
+
+ case '=':
+ if (e == 0) return Qtrue;
+ return Qfalse;
+
+ case 'G':
+ if (e >= 0) return Qtrue;
+ return Qfalse;
+
+ case '>':
+ if (e > 0) return Qtrue;
+ return Qfalse;
+
+ case 'L':
+ if (e <= 0) return Qtrue;
+ return Qfalse;
+
+ case '<':
+ if (e < 0) return Qtrue;
+ return Qfalse;
+
+ default:
+ break;
+ }
+
+ rb_bug("Undefined operation in BigDecimalCmp()");
+
+ UNREACHABLE;
+}
+
+/* Returns True if the value is zero. */
+static VALUE
+BigDecimal_zero(VALUE self)
+{
+ Real *a = GetVpValue(self, 1);
+ return VpIsZero(a) ? Qtrue : Qfalse;
+}
+
+/* Returns self if the value is non-zero, nil otherwise. */
+static VALUE
+BigDecimal_nonzero(VALUE self)
+{
+ Real *a = GetVpValue(self, 1);
+ return VpIsZero(a) ? Qnil : self;
+}
+
+/* The comparison operator.
+ * a <=> b is 0 if a == b, 1 if a > b, -1 if a < b.
+ */
+static VALUE
+BigDecimal_comp(VALUE self, VALUE r)
+{
+ return BigDecimalCmp(self, r, '*');
+}
+
+/*
+ * Tests for value equality; returns true if the values are equal.
+ *
+ * The == and === operators and the eql? method have the same implementation
+ * for BigDecimal.
+ *
+ * Values may be coerced to perform the comparison:
+ *
+ * BigDecimal.new('1.0') == 1.0 -> true
+ */
+static VALUE
+BigDecimal_eq(VALUE self, VALUE r)
+{
+ return BigDecimalCmp(self, r, '=');
+}
+
+/* call-seq:
+ * a < b
+ *
+ * Returns true if a is less than b.
+ *
+ * Values may be coerced to perform the comparison (see ==, BigDecimal#coerce).
+ */
+static VALUE
+BigDecimal_lt(VALUE self, VALUE r)
+{
+ return BigDecimalCmp(self, r, '<');
+}
+
+/* call-seq:
+ * a <= b
+ *
+ * Returns true if a is less than or equal to b.
+ *
+ * Values may be coerced to perform the comparison (see ==, BigDecimal#coerce).
+ */
+static VALUE
+BigDecimal_le(VALUE self, VALUE r)
+{
+ return BigDecimalCmp(self, r, 'L');
+}
+
+/* call-seq:
+ * a > b
+ *
+ * Returns true if a is greater than b.
+ *
+ * Values may be coerced to perform the comparison (see ==, BigDecimal#coerce).
+ */
+static VALUE
+BigDecimal_gt(VALUE self, VALUE r)
+{
+ return BigDecimalCmp(self, r, '>');
+}
+
+/* call-seq:
+ * a >= b
+ *
+ * Returns true if a is greater than or equal to b.
+ *
+ * Values may be coerced to perform the comparison (see ==, BigDecimal#coerce)
+ */
+static VALUE
+BigDecimal_ge(VALUE self, VALUE r)
+{
+ return BigDecimalCmp(self, r, 'G');
+}
+
+/*
+ * call-seq: -@
+ *
+ * Return the negation of self.
+ *
+ * e.g.
+ * b = -a
+ * b == a * -1
+ */
+static VALUE
+BigDecimal_neg(VALUE self)
+{
+ ENTER(5);
+ Real *c, *a;
+ GUARD_OBJ(a, GetVpValue(self, 1));
+ GUARD_OBJ(c, VpCreateRbObject(a->Prec *(VpBaseFig() + 1), "0"));
+ VpAsgn(c, a, -1);
+ return ToValue(c);
+}
+
+ /*
+ * Document-method: BigDecimal#mult
+ *
+ * call-seq: mult(value, digits)
+ *
+ * Multiply by the specified value.
+ *
+ * e.g.
+ * c = a.mult(b,n)
+ * c = a * b
+ *
+ * digits:: If specified and less than the number of significant digits of the
+ * result, the result is rounded to that number of digits, according to
+ * BigDecimal.mode.
+ */
+static VALUE
+BigDecimal_mult(VALUE self, VALUE r)
+{
+ ENTER(5);
+ Real *c, *a, *b;
+ size_t mx;
+
+ GUARD_OBJ(a, GetVpValue(self, 1));
+ if (RB_TYPE_P(r, T_FLOAT)) {
+ b = GetVpValueWithPrec(r, DBL_DIG+1, 1);
+ }
+ else if (RB_TYPE_P(r, T_RATIONAL)) {
+ b = GetVpValueWithPrec(r, a->Prec*VpBaseFig(), 1);
+ }
+ else {
+ b = GetVpValue(r,0);
+ }
+
+ if (!b) return DoSomeOne(self, r, '*');
+ SAVE(b);
+
+ mx = a->Prec + b->Prec;
+ GUARD_OBJ(c, VpCreateRbObject(mx *(VpBaseFig() + 1), "0"));
+ VpMult(c, a, b);
+ return ToValue(c);
+}
+
+static VALUE
+BigDecimal_divide(Real **c, Real **res, Real **div, VALUE self, VALUE r)
+/* For c = self.div(r): with round operation */
+{
+ ENTER(5);
+ Real *a, *b;
+ size_t mx;
+
+ GUARD_OBJ(a, GetVpValue(self, 1));
+ if (RB_TYPE_P(r, T_FLOAT)) {
+ b = GetVpValueWithPrec(r, DBL_DIG+1, 1);
+ }
+ else if (RB_TYPE_P(r, T_RATIONAL)) {
+ b = GetVpValueWithPrec(r, a->Prec*VpBaseFig(), 1);
+ }
+ else {
+ b = GetVpValue(r, 0);
+ }
+
+ if (!b) return DoSomeOne(self, r, '/');
+ SAVE(b);
+
+ *div = b;
+ mx = a->Prec + vabs(a->exponent);
+ if (mx < b->Prec + vabs(b->exponent)) mx = b->Prec + vabs(b->exponent);
+ mx++; /* NOTE: An additional digit is needed for the compatibility to
+ the version 1.2.1 and the former. */
+ mx = (mx + 1) * VpBaseFig();
+ GUARD_OBJ((*c), VpCreateRbObject(mx, "#0"));
+ GUARD_OBJ((*res), VpCreateRbObject((mx+1) * 2 +(VpBaseFig() + 1), "#0"));
+ VpDivd(*c, *res, a, b);
+ return Qnil;
+}
+
+ /* call-seq:
+ * div(value, digits)
+ * quo(value)
+ *
+ * Divide by the specified value.
+ *
+ * e.g.
+ * c = a.div(b,n)
+ *
+ * digits:: If specified and less than the number of significant digits of the
+ * result, the result is rounded to that number of digits, according to
+ * BigDecimal.mode.
+ *
+ * If digits is 0, the result is the same as the / operator. If not, the
+ * result is an integer BigDecimal, by analogy with Float#div.
+ *
+ * The alias quo is provided since <code>div(value, 0)</code> is the same as
+ * computing the quotient; see BigDecimal#divmod.
+ */
+static VALUE
+BigDecimal_div(VALUE self, VALUE r)
+/* For c = self/r: with round operation */
+{
+ ENTER(5);
+ Real *c=NULL, *res=NULL, *div = NULL;
+ r = BigDecimal_divide(&c, &res, &div, self, r);
+ if (!NIL_P(r)) return r; /* coerced by other */
+ SAVE(c); SAVE(res); SAVE(div);
+ /* a/b = c + r/b */
+ /* c xxxxx
+ r 00000yyyyy ==> (y/b)*BASE >= HALF_BASE
+ */
+ /* Round */
+ if (VpHasVal(div)) { /* frac[0] must be zero for NaN,INF,Zero */
+ VpInternalRound(c, 0, c->frac[c->Prec-1], (BDIGIT)(VpBaseVal() * (BDIGIT_DBL)res->frac[0] / div->frac[0]));
+ }
+ return ToValue(c);
+}
+
+/*
+ * %: mod = a%b = a - (a.to_f/b).floor * b
+ * div = (a.to_f/b).floor
+ */
+static VALUE
+BigDecimal_DoDivmod(VALUE self, VALUE r, Real **div, Real **mod)
+{
+ ENTER(8);
+ Real *c=NULL, *d=NULL, *res=NULL;
+ Real *a, *b;
+ size_t mx;
+
+ GUARD_OBJ(a, GetVpValue(self, 1));
+ if (RB_TYPE_P(r, T_FLOAT)) {
+ b = GetVpValueWithPrec(r, DBL_DIG+1, 1);
+ }
+ else if (RB_TYPE_P(r, T_RATIONAL)) {
+ b = GetVpValueWithPrec(r, a->Prec*VpBaseFig(), 1);
+ }
+ else {
+ b = GetVpValue(r, 0);
+ }
+
+ if (!b) return Qfalse;
+ SAVE(b);
+
+ if (VpIsNaN(a) || VpIsNaN(b)) goto NaN;
+ if (VpIsInf(a) && VpIsInf(b)) goto NaN;
+ if (VpIsZero(b)) {
+ rb_raise(rb_eZeroDivError, "divided by 0");
+ }
+ if (VpIsInf(a)) {
+ GUARD_OBJ(d, VpCreateRbObject(1, "0"));
+ VpSetInf(d, (SIGNED_VALUE)(VpGetSign(a) == VpGetSign(b) ? 1 : -1));
+ GUARD_OBJ(c, VpCreateRbObject(1, "NaN"));
+ *div = d;
+ *mod = c;
+ return Qtrue;
+ }
+ if (VpIsInf(b)) {
+ GUARD_OBJ(d, VpCreateRbObject(1, "0"));
+ *div = d;
+ *mod = a;
+ return Qtrue;
+ }
+ if (VpIsZero(a)) {
+ GUARD_OBJ(c, VpCreateRbObject(1, "0"));
+ GUARD_OBJ(d, VpCreateRbObject(1, "0"));
+ *div = d;
+ *mod = c;
+ return Qtrue;
+ }
+
+ mx = a->Prec + vabs(a->exponent);
+ if (mx<b->Prec + vabs(b->exponent)) mx = b->Prec + vabs(b->exponent);
+ mx = (mx + 1) * VpBaseFig();
+ GUARD_OBJ(c, VpCreateRbObject(mx, "0"));
+ GUARD_OBJ(res, VpCreateRbObject((mx+1) * 2 +(VpBaseFig() + 1), "#0"));
+ VpDivd(c, res, a, b);
+ mx = c->Prec * (VpBaseFig() + 1);
+ GUARD_OBJ(d, VpCreateRbObject(mx, "0"));
+ VpActiveRound(d, c, VP_ROUND_DOWN, 0);
+ VpMult(res, d, b);
+ VpAddSub(c, a, res, -1);
+ if (!VpIsZero(c) && (VpGetSign(a) * VpGetSign(b) < 0)) {
+ VpAddSub(res, d, VpOne(), -1);
+ GUARD_OBJ(d, VpCreateRbObject(GetAddSubPrec(c, b)*(VpBaseFig() + 1), "0"));
+ VpAddSub(d, c, b, 1);
+ *div = res;
+ *mod = d;
+ } else {
+ *div = d;
+ *mod = c;
+ }
+ return Qtrue;
+
+NaN:
+ GUARD_OBJ(c, VpCreateRbObject(1, "NaN"));
+ GUARD_OBJ(d, VpCreateRbObject(1, "NaN"));
+ *div = d;
+ *mod = c;
+ return Qtrue;
+}
+
+/* call-seq:
+ * a % b
+ * a.modulo(b)
+ *
+ * Returns the modulus from dividing by b.
+ *
+ * See BigDecimal#divmod.
+ */
+static VALUE
+BigDecimal_mod(VALUE self, VALUE r) /* %: a%b = a - (a.to_f/b).floor * b */
+{
+ ENTER(3);
+ Real *div = NULL, *mod = NULL;
+
+ if (BigDecimal_DoDivmod(self, r, &div, &mod)) {
+ SAVE(div); SAVE(mod);
+ return ToValue(mod);
+ }
+ return DoSomeOne(self, r, '%');
+}
+
+static VALUE
+BigDecimal_divremain(VALUE self, VALUE r, Real **dv, Real **rv)
+{
+ ENTER(10);
+ size_t mx;
+ Real *a = NULL, *b = NULL, *c = NULL, *res = NULL, *d = NULL, *rr = NULL, *ff = NULL;
+ Real *f = NULL;
+
+ GUARD_OBJ(a, GetVpValue(self, 1));
+ if (RB_TYPE_P(r, T_FLOAT)) {
+ b = GetVpValueWithPrec(r, DBL_DIG+1, 1);
+ }
+ else if (RB_TYPE_P(r, T_RATIONAL)) {
+ b = GetVpValueWithPrec(r, a->Prec*VpBaseFig(), 1);
+ }
+ else {
+ b = GetVpValue(r, 0);
+ }
+
+ if (!b) return DoSomeOne(self, r, rb_intern("remainder"));
+ SAVE(b);
+
+ mx = (a->MaxPrec + b->MaxPrec) *VpBaseFig();
+ GUARD_OBJ(c, VpCreateRbObject(mx, "0"));
+ GUARD_OBJ(res, VpCreateRbObject((mx+1) * 2 + (VpBaseFig() + 1), "#0"));
+ GUARD_OBJ(rr, VpCreateRbObject((mx+1) * 2 + (VpBaseFig() + 1), "#0"));
+ GUARD_OBJ(ff, VpCreateRbObject((mx+1) * 2 + (VpBaseFig() + 1), "#0"));
+
+ VpDivd(c, res, a, b);
+
+ mx = c->Prec *(VpBaseFig() + 1);
+
+ GUARD_OBJ(d, VpCreateRbObject(mx, "0"));
+ GUARD_OBJ(f, VpCreateRbObject(mx, "0"));
+
+ VpActiveRound(d, c, VP_ROUND_DOWN, 0); /* 0: round off */
+
+ VpFrac(f, c);
+ VpMult(rr, f, b);
+ VpAddSub(ff, res, rr, 1);
+
+ *dv = d;
+ *rv = ff;
+ return Qnil;
+}
+
+/* Returns the remainder from dividing by the value.
+ *
+ * x.remainder(y) means x-y*(x/y).truncate
+ */
+static VALUE
+BigDecimal_remainder(VALUE self, VALUE r) /* remainder */
+{
+ VALUE f;
+ Real *d, *rv = 0;
+ f = BigDecimal_divremain(self, r, &d, &rv);
+ if (!NIL_P(f)) return f;
+ return ToValue(rv);
+}
+
+/* Divides by the specified value, and returns the quotient and modulus
+ * as BigDecimal numbers. The quotient is rounded towards negative infinity.
+ *
+ * For example:
+ *
+ * require 'bigdecimal'
+ *
+ * a = BigDecimal.new("42")
+ * b = BigDecimal.new("9")
+ *
+ * q,m = a.divmod(b)
+ *
+ * c = q * b + m
+ *
+ * a == c -> true
+ *
+ * The quotient q is (a/b).floor, and the modulus is the amount that must be
+ * added to q * b to get a.
+ */
+static VALUE
+BigDecimal_divmod(VALUE self, VALUE r)
+{
+ ENTER(5);
+ Real *div = NULL, *mod = NULL;
+
+ if (BigDecimal_DoDivmod(self, r, &div, &mod)) {
+ SAVE(div); SAVE(mod);
+ return rb_assoc_new(ToValue(div), ToValue(mod));
+ }
+ return DoSomeOne(self,r,rb_intern("divmod"));
+}
+
+/*
+ * See BigDecimal#quo
+ */
+static inline VALUE
+BigDecimal_div2(VALUE self, VALUE b, VALUE n)
+{
+ ENTER(5);
+ SIGNED_VALUE ix;
+
+ if (NIL_P(n)) { /* div in Float sense */
+ Real *div = NULL;
+ Real *mod;
+ if (BigDecimal_DoDivmod(self, b, &div, &mod)) {
+ return BigDecimal_to_i(ToValue(div));
+ }
+ return DoSomeOne(self, b, rb_intern("div"));
+ }
+
+ /* div in BigDecimal sense */
+ ix = GetPositiveInt(n);
+ if (ix == 0) {
+ return BigDecimal_div(self, b);
+ }
+ else {
+ Real *res = NULL;
+ Real *av = NULL, *bv = NULL, *cv = NULL;
+ size_t mx = ix + VpBaseFig()*2;
+ size_t pl = VpSetPrecLimit(0);
+
+ GUARD_OBJ(cv, VpCreateRbObject(mx, "0"));
+ GUARD_OBJ(av, GetVpValue(self, 1));
+ GUARD_OBJ(bv, GetVpValue(b, 1));
+ mx = av->Prec + bv->Prec + 2;
+ if (mx <= cv->MaxPrec) mx = cv->MaxPrec + 1;
+ GUARD_OBJ(res, VpCreateRbObject((mx * 2 + 2)*VpBaseFig(), "#0"));
+ VpDivd(cv, res, av, bv);
+ VpSetPrecLimit(pl);
+ VpLeftRound(cv, VpGetRoundMode(), ix);
+ return ToValue(cv);
+ }
+}
+
+static VALUE
+BigDecimal_div3(int argc, VALUE *argv, VALUE self)
+{
+ VALUE b,n;
+
+ rb_scan_args(argc, argv, "11", &b, &n);
+
+ return BigDecimal_div2(self, b, n);
+}
+
+static VALUE
+BigDecimal_add2(VALUE self, VALUE b, VALUE n)
+{
+ ENTER(2);
+ Real *cv;
+ SIGNED_VALUE mx = GetPositiveInt(n);
+ if (mx == 0) return BigDecimal_add(self, b);
+ else {
+ size_t pl = VpSetPrecLimit(0);
+ VALUE c = BigDecimal_add(self, b);
+ VpSetPrecLimit(pl);
+ GUARD_OBJ(cv, GetVpValue(c, 1));
+ VpLeftRound(cv, VpGetRoundMode(), mx);
+ return ToValue(cv);
+ }
+}
+
+/*
+ * sub(value, digits) -> bigdecimal
+ *
+ * Subtract the specified value.
+ *
+ * e.g.
+ * c = a.sub(b,n)
+ *
+ * digits:: If specified and less than the number of significant digits of the
+ * result, the result is rounded to that number of digits, according to
+ * BigDecimal.mode.
+ *
+ */
+static VALUE
+BigDecimal_sub2(VALUE self, VALUE b, VALUE n)
+{
+ ENTER(2);
+ Real *cv;
+ SIGNED_VALUE mx = GetPositiveInt(n);
+ if (mx == 0) return BigDecimal_sub(self, b);
+ else {
+ size_t pl = VpSetPrecLimit(0);
+ VALUE c = BigDecimal_sub(self, b);
+ VpSetPrecLimit(pl);
+ GUARD_OBJ(cv, GetVpValue(c, 1));
+ VpLeftRound(cv, VpGetRoundMode(), mx);
+ return ToValue(cv);
+ }
+}
+
+
+static VALUE
+BigDecimal_mult2(VALUE self, VALUE b, VALUE n)
+{
+ ENTER(2);
+ Real *cv;
+ SIGNED_VALUE mx = GetPositiveInt(n);
+ if (mx == 0) return BigDecimal_mult(self, b);
+ else {
+ size_t pl = VpSetPrecLimit(0);
+ VALUE c = BigDecimal_mult(self, b);
+ VpSetPrecLimit(pl);
+ GUARD_OBJ(cv, GetVpValue(c, 1));
+ VpLeftRound(cv, VpGetRoundMode(), mx);
+ return ToValue(cv);
+ }
+}
+
+/* Returns the absolute value.
+ *
+ * BigDecimal('5').abs -> 5
+ *
+ * BigDecimal('-3').abs -> 3
+ */
+static VALUE
+BigDecimal_abs(VALUE self)
+{
+ ENTER(5);
+ Real *c, *a;
+ size_t mx;
+
+ GUARD_OBJ(a, GetVpValue(self, 1));
+ mx = a->Prec *(VpBaseFig() + 1);
+ GUARD_OBJ(c, VpCreateRbObject(mx, "0"));
+ VpAsgn(c, a, 1);
+ VpChangeSign(c, 1);
+ return ToValue(c);
+}
+
+/* call-seq:
+ * sqrt(n)
+ *
+ * Returns the square root of the value.
+ *
+ * Result has at least n significant digits.
+ */
+static VALUE
+BigDecimal_sqrt(VALUE self, VALUE nFig)
+{
+ ENTER(5);
+ Real *c, *a;
+ size_t mx, n;
+
+ GUARD_OBJ(a, GetVpValue(self, 1));
+ mx = a->Prec * (VpBaseFig() + 1);
+
+ n = GetPositiveInt(nFig) + VpDblFig() + BASE_FIG;
+ if (mx <= n) mx = n;
+ GUARD_OBJ(c, VpCreateRbObject(mx, "0"));
+ VpSqrt(c, a);
+ return ToValue(c);
+}
+
+/* Return the integer part of the number.
+ */
+static VALUE
+BigDecimal_fix(VALUE self)
+{
+ ENTER(5);
+ Real *c, *a;
+ size_t mx;
+
+ GUARD_OBJ(a, GetVpValue(self, 1));
+ mx = a->Prec *(VpBaseFig() + 1);
+ GUARD_OBJ(c, VpCreateRbObject(mx, "0"));
+ VpActiveRound(c, a, VP_ROUND_DOWN, 0); /* 0: round off */
+ return ToValue(c);
+}
+
+/* call-seq:
+ * round(n, mode)
+ *
+ * Round to the nearest 1 (by default), returning the result as a BigDecimal.
+ *
+ * BigDecimal('3.14159').round #=> 3
+ * BigDecimal('8.7').round #=> 9
+ *
+ * If n is specified and positive, the fractional part of the result has no
+ * more than that many digits.
+ *
+ * If n is specified and negative, at least that many digits to the left of the
+ * decimal point will be 0 in the result.
+ *
+ * BigDecimal('3.14159').round(3) #=> 3.142
+ * BigDecimal('13345.234').round(-2) #=> 13300.0
+ *
+ * The value of the optional mode argument can be used to determine how
+ * rounding is performed; see BigDecimal.mode.
+ */
+static VALUE
+BigDecimal_round(int argc, VALUE *argv, VALUE self)
+{
+ ENTER(5);
+ Real *c, *a;
+ int iLoc = 0;
+ VALUE vLoc;
+ VALUE vRound;
+ size_t mx, pl;
+
+ unsigned short sw = VpGetRoundMode();
+
+ switch (rb_scan_args(argc, argv, "02", &vLoc, &vRound)) {
+ case 0:
+ iLoc = 0;
+ break;
+ case 1:
+ Check_Type(vLoc, T_FIXNUM);
+ iLoc = FIX2INT(vLoc);
+ break;
+ case 2:
+ Check_Type(vLoc, T_FIXNUM);
+ iLoc = FIX2INT(vLoc);
+ sw = check_rounding_mode(vRound);
+ break;
+ default:
+ break;
+ }
+
+ pl = VpSetPrecLimit(0);
+ GUARD_OBJ(a, GetVpValue(self, 1));
+ mx = a->Prec * (VpBaseFig() + 1);
+ GUARD_OBJ(c, VpCreateRbObject(mx, "0"));
+ VpSetPrecLimit(pl);
+ VpActiveRound(c, a, sw, iLoc);
+ if (argc == 0) {
+ return BigDecimal_to_i(ToValue(c));
+ }
+ return ToValue(c);
+}
+
+/* call-seq:
+ * truncate(n)
+ *
+ * Truncate to the nearest 1, returning the result as a BigDecimal.
+ *
+ * BigDecimal('3.14159').truncate #=> 3
+ * BigDecimal('8.7').truncate #=> 8
+ *
+ * If n is specified and positive, the fractional part of the result has no
+ * more than that many digits.
+ *
+ * If n is specified and negative, at least that many digits to the left of the
+ * decimal point will be 0 in the result.
+ *
+ * BigDecimal('3.14159').truncate(3) #=> 3.141
+ * BigDecimal('13345.234').truncate(-2) #=> 13300.0
+ */
+static VALUE
+BigDecimal_truncate(int argc, VALUE *argv, VALUE self)
+{
+ ENTER(5);
+ Real *c, *a;
+ int iLoc;
+ VALUE vLoc;
+ size_t mx, pl = VpSetPrecLimit(0);
+
+ if (rb_scan_args(argc, argv, "01", &vLoc) == 0) {
+ iLoc = 0;
+ }
+ else {
+ Check_Type(vLoc, T_FIXNUM);
+ iLoc = FIX2INT(vLoc);
+ }
+
+ GUARD_OBJ(a, GetVpValue(self, 1));
+ mx = a->Prec * (VpBaseFig() + 1);
+ GUARD_OBJ(c, VpCreateRbObject(mx, "0"));
+ VpSetPrecLimit(pl);
+ VpActiveRound(c, a, VP_ROUND_DOWN, iLoc); /* 0: truncate */
+ if (argc == 0) {
+ return BigDecimal_to_i(ToValue(c));
+ }
+ return ToValue(c);
+}
+
+/* Return the fractional part of the number.
+ */
+static VALUE
+BigDecimal_frac(VALUE self)
+{
+ ENTER(5);
+ Real *c, *a;
+ size_t mx;
+
+ GUARD_OBJ(a, GetVpValue(self, 1));
+ mx = a->Prec * (VpBaseFig() + 1);
+ GUARD_OBJ(c, VpCreateRbObject(mx, "0"));
+ VpFrac(c, a);
+ return ToValue(c);
+}
+
+/* call-seq:
+ * floor(n)
+ *
+ * Return the largest integer less than or equal to the value, as a BigDecimal.
+ *
+ * BigDecimal('3.14159').floor #=> 3
+ * BigDecimal('-9.1').floor #=> -10
+ *
+ * If n is specified and positive, the fractional part of the result has no
+ * more than that many digits.
+ *
+ * If n is specified and negative, at least that
+ * many digits to the left of the decimal point will be 0 in the result.
+ *
+ * BigDecimal('3.14159').floor(3) #=> 3.141
+ * BigDecimal('13345.234').floor(-2) #=> 13300.0
+ */
+static VALUE
+BigDecimal_floor(int argc, VALUE *argv, VALUE self)
+{
+ ENTER(5);
+ Real *c, *a;
+ int iLoc;
+ VALUE vLoc;
+ size_t mx, pl = VpSetPrecLimit(0);
+
+ if (rb_scan_args(argc, argv, "01", &vLoc)==0) {
+ iLoc = 0;
+ }
+ else {
+ Check_Type(vLoc, T_FIXNUM);
+ iLoc = FIX2INT(vLoc);
+ }
+
+ GUARD_OBJ(a, GetVpValue(self, 1));
+ mx = a->Prec * (VpBaseFig() + 1);
+ GUARD_OBJ(c, VpCreateRbObject(mx, "0"));
+ VpSetPrecLimit(pl);
+ VpActiveRound(c, a, VP_ROUND_FLOOR, iLoc);
+#ifdef BIGDECIMAL_DEBUG
+ VPrint(stderr, "floor: c=%\n", c);
+#endif
+ if (argc == 0) {
+ return BigDecimal_to_i(ToValue(c));
+ }
+ return ToValue(c);
+}
+
+/* call-seq:
+ * ceil(n)
+ *
+ * Return the smallest integer greater than or equal to the value, as a BigDecimal.
+ *
+ * BigDecimal('3.14159').ceil #=> 4
+ * BigDecimal('-9.1').ceil #=> -9
+ *
+ * If n is specified and positive, the fractional part of the result has no
+ * more than that many digits.
+ *
+ * If n is specified and negative, at least that
+ * many digits to the left of the decimal point will be 0 in the result.
+ *
+ * BigDecimal('3.14159').ceil(3) #=> 3.142
+ * BigDecimal('13345.234').ceil(-2) #=> 13400.0
+ */
+static VALUE
+BigDecimal_ceil(int argc, VALUE *argv, VALUE self)
+{
+ ENTER(5);
+ Real *c, *a;
+ int iLoc;
+ VALUE vLoc;
+ size_t mx, pl = VpSetPrecLimit(0);
+
+ if (rb_scan_args(argc, argv, "01", &vLoc) == 0) {
+ iLoc = 0;
+ } else {
+ Check_Type(vLoc, T_FIXNUM);
+ iLoc = FIX2INT(vLoc);
+ }
+
+ GUARD_OBJ(a, GetVpValue(self, 1));
+ mx = a->Prec * (VpBaseFig() + 1);
+ GUARD_OBJ(c, VpCreateRbObject(mx, "0"));
+ VpSetPrecLimit(pl);
+ VpActiveRound(c, a, VP_ROUND_CEIL, iLoc);
+ if (argc == 0) {
+ return BigDecimal_to_i(ToValue(c));
+ }
+ return ToValue(c);
+}
+
+/* call-seq:
+ * to_s(s)
+ *
+ * Converts the value to a string.
+ *
+ * The default format looks like 0.xxxxEnn.
+ *
+ * The optional parameter s consists of either an integer; or an optional '+'
+ * or ' ', followed by an optional number, followed by an optional 'E' or 'F'.
+ *
+ * If there is a '+' at the start of s, positive values are returned with
+ * a leading '+'.
+ *
+ * A space at the start of s returns positive values with a leading space.
+ *
+ * If s contains a number, a space is inserted after each group of that many
+ * fractional digits.
+ *
+ * If s ends with an 'E', engineering notation (0.xxxxEnn) is used.
+ *
+ * If s ends with an 'F', conventional floating point notation is used.
+ *
+ * Examples:
+ *
+ * BigDecimal.new('-123.45678901234567890').to_s('5F')
+ * #=> '-123.45678 90123 45678 9'
+ *
+ * BigDecimal.new('123.45678901234567890').to_s('+8F')
+ * #=> '+123.45678901 23456789'
+ *
+ * BigDecimal.new('123.45678901234567890').to_s(' F')
+ * #=> ' 123.4567890123456789'
+ */
+static VALUE
+BigDecimal_to_s(int argc, VALUE *argv, VALUE self)
+{
+ ENTER(5);
+ int fmt = 0; /* 0:E format */
+ int fPlus = 0; /* =0:default,=1: set ' ' before digits ,set '+' before digits. */
+ Real *vp;
+ volatile VALUE str;
+ char *psz;
+ char ch;
+ size_t nc, mc = 0;
+ VALUE f;
+
+ GUARD_OBJ(vp, GetVpValue(self, 1));
+
+ if (rb_scan_args(argc, argv, "01", &f) == 1) {
+ if (RB_TYPE_P(f, T_STRING)) {
+ SafeStringValue(f);
+ psz = RSTRING_PTR(f);
+ if (*psz == ' ') {
+ fPlus = 1;
+ psz++;
+ }
+ else if (*psz == '+') {
+ fPlus = 2;
+ psz++;
+ }
+ while ((ch = *psz++) != 0) {
+ if (ISSPACE(ch)) {
+ continue;
+ }
+ if (!ISDIGIT(ch)) {
+ if (ch == 'F' || ch == 'f') {
+ fmt = 1; /* F format */
+ }
+ break;
+ }
+ mc = mc*10 + ch - '0';
+ }
+ }
+ else {
+ mc = (size_t)GetPositiveInt(f);
+ }
+ }
+ if (fmt) {
+ nc = VpNumOfChars(vp, "F");
+ }
+ else {
+ nc = VpNumOfChars(vp, "E");
+ }
+ if (mc > 0) {
+ nc += (nc + mc - 1) / mc + 1;
+ }
+
+ str = rb_str_new(0, nc);
+ psz = RSTRING_PTR(str);
+
+ if (fmt) {
+ VpToFString(vp, psz, mc, fPlus);
+ }
+ else {
+ VpToString (vp, psz, mc, fPlus);
+ }
+ rb_str_resize(str, strlen(psz));
+ return str;
+}
+
+/* Splits a BigDecimal number into four parts, returned as an array of values.
+ *
+ * The first value represents the sign of the BigDecimal, and is -1 or 1, or 0
+ * if the BigDecimal is Not a Number.
+ *
+ * The second value is a string representing the significant digits of the
+ * BigDecimal, with no leading zeros.
+ *
+ * The third value is the base used for arithmetic (currently always 10) as an
+ * Integer.
+ *
+ * The fourth value is an Integer exponent.
+ *
+ * If the BigDecimal can be represented as 0.xxxxxx*10**n, then xxxxxx is the
+ * string of significant digits with no leading zeros, and n is the exponent.
+ *
+ * From these values, you can translate a BigDecimal to a float as follows:
+ *
+ * sign, significant_digits, base, exponent = a.split
+ * f = sign * "0.#{significant_digits}".to_f * (base ** exponent)
+ *
+ * (Note that the to_f method is provided as a more convenient way to translate
+ * a BigDecimal to a Float.)
+ */
+static VALUE
+BigDecimal_split(VALUE self)
+{
+ ENTER(5);
+ Real *vp;
+ VALUE obj,str;
+ ssize_t e, s;
+ char *psz1;
+
+ GUARD_OBJ(vp, GetVpValue(self, 1));
+ str = rb_str_new(0, VpNumOfChars(vp, "E"));
+ psz1 = RSTRING_PTR(str);
+ VpSzMantissa(vp, psz1);
+ s = 1;
+ if(psz1[0] == '-') {
+ size_t len = strlen(psz1 + 1);
+
+ memmove(psz1, psz1 + 1, len);
+ psz1[len] = '\0';
+ s = -1;
+ }
+ if (psz1[0] == 'N') s = 0; /* NaN */
+ e = VpExponent10(vp);
+ obj = rb_ary_new2(4);
+ rb_ary_push(obj, INT2FIX(s));
+ rb_ary_push(obj, str);
+ rb_str_resize(str, strlen(psz1));
+ rb_ary_push(obj, INT2FIX(10));
+ rb_ary_push(obj, INT2NUM(e));
+ return obj;
+}
+
+/* Returns the exponent of the BigDecimal number, as an Integer.
+ *
+ * If the number can be represented as 0.xxxxxx*10**n where xxxxxx is a string
+ * of digits with no leading zeros, then n is the exponent.
+ */
+static VALUE
+BigDecimal_exponent(VALUE self)
+{
+ ssize_t e = VpExponent10(GetVpValue(self, 1));
+ return INT2NUM(e);
+}
+
+/* Returns debugging information about the value as a string of comma-separated
+ * values in angle brackets with a leading #:
+ *
+ * BigDecimal.new("1234.5678").inspect ->
+ * "#<BigDecimal:b7ea1130,'0.12345678E4',8(12)>"
+ *
+ * The first part is the address, the second is the value as a string, and
+ * the final part ss(mm) is the current number of significant digits and the
+ * maximum number of significant digits, respectively.
+ */
+static VALUE
+BigDecimal_inspect(VALUE self)
+{
+ ENTER(5);
+ Real *vp;
+ volatile VALUE obj;
+ size_t nc;
+ char *psz, *tmp;
+
+ GUARD_OBJ(vp, GetVpValue(self, 1));
+ nc = VpNumOfChars(vp, "E");
+ nc += (nc + 9) / 10;
+
+ obj = rb_str_new(0, nc+256);
+ psz = RSTRING_PTR(obj);
+ sprintf(psz, "#<BigDecimal:%"PRIxVALUE",'", self);
+ tmp = psz + strlen(psz);
+ VpToString(vp, tmp, 10, 0);
+ tmp += strlen(tmp);
+ sprintf(tmp, "',%"PRIuSIZE"(%"PRIuSIZE")>", VpPrec(vp)*VpBaseFig(), VpMaxPrec(vp)*VpBaseFig());
+ rb_str_resize(obj, strlen(psz));
+ return obj;
+}
+
+static VALUE BigMath_s_exp(VALUE, VALUE, VALUE);
+static VALUE BigMath_s_log(VALUE, VALUE, VALUE);
+
+#define BigMath_exp(x, n) BigMath_s_exp(rb_mBigMath, (x), (n))
+#define BigMath_log(x, n) BigMath_s_log(rb_mBigMath, (x), (n))
+
+inline static int
+is_integer(VALUE x)
+{
+ return (RB_TYPE_P(x, T_FIXNUM) || RB_TYPE_P(x, T_BIGNUM));
+}
+
+inline static int
+is_negative(VALUE x)
+{
+ if (FIXNUM_P(x)) {
+ return FIX2LONG(x) < 0;
+ }
+ else if (RB_TYPE_P(x, T_BIGNUM)) {
+ return FIX2INT(rb_big_cmp(x, INT2FIX(0))) < 0;
+ }
+ else if (RB_TYPE_P(x, T_FLOAT)) {
+ return RFLOAT_VALUE(x) < 0.0;
+ }
+ return RTEST(rb_funcall(x, '<', 1, INT2FIX(0)));
+}
+
+#define is_positive(x) (!is_negative(x))
+
+inline static int
+is_zero(VALUE x)
+{
+ VALUE num;
+
+ switch (TYPE(x)) {
+ case T_FIXNUM:
+ return FIX2LONG(x) == 0;
+
+ case T_BIGNUM:
+ return Qfalse;
+
+ case T_RATIONAL:
+ num = rb_rational_num(x);
+ return FIXNUM_P(num) && FIX2LONG(num) == 0;
+
+ default:
+ break;
+ }
+
+ return RTEST(rb_funcall(x, id_eq, 1, INT2FIX(0)));
+}
+
+inline static int
+is_one(VALUE x)
+{
+ VALUE num, den;
+
+ switch (TYPE(x)) {
+ case T_FIXNUM:
+ return FIX2LONG(x) == 1;
+
+ case T_BIGNUM:
+ return Qfalse;
+
+ case T_RATIONAL:
+ num = rb_rational_num(x);
+ den = rb_rational_den(x);
+ return FIXNUM_P(den) && FIX2LONG(den) == 1 &&
+ FIXNUM_P(num) && FIX2LONG(num) == 1;
+
+ default:
+ break;
+ }
+
+ return RTEST(rb_funcall(x, id_eq, 1, INT2FIX(1)));
+}
+
+inline static int
+is_even(VALUE x)
+{
+ switch (TYPE(x)) {
+ case T_FIXNUM:
+ return (FIX2LONG(x) % 2) == 0;
+
+ case T_BIGNUM:
+ {
+ unsigned long l;
+ rb_big_pack(x, &l, 1);
+ return l % 2 == 0;
+ }
+
+ default:
+ break;
+ }
+
+ return 0;
+}
+
+static VALUE
+rmpd_power_by_big_decimal(Real const* x, Real const* exp, ssize_t const n)
+{
+ VALUE log_x, multiplied, y;
+ volatile VALUE obj = exp->obj;
+
+ if (VpIsZero(exp)) {
+ return ToValue(VpCreateRbObject(n, "1"));
+ }
+
+ log_x = BigMath_log(x->obj, SSIZET2NUM(n+1));
+ multiplied = BigDecimal_mult2(exp->obj, log_x, SSIZET2NUM(n+1));
+ y = BigMath_exp(multiplied, SSIZET2NUM(n));
+ RB_GC_GUARD(obj);
+
+ return y;
+}
+
+/* call-seq:
+ * power(n)
+ * power(n, prec)
+ *
+ * Returns the value raised to the power of n.
+ *
+ * Note that n must be an Integer.
+ *
+ * Also available as the operator **
+ */
+static VALUE
+BigDecimal_power(int argc, VALUE*argv, VALUE self)
+{
+ ENTER(5);
+ VALUE vexp, prec;
+ Real* exp = NULL;
+ Real *x, *y;
+ ssize_t mp, ma, n;
+ SIGNED_VALUE int_exp;
+ double d;
+
+ rb_scan_args(argc, argv, "11", &vexp, &prec);
+
+ GUARD_OBJ(x, GetVpValue(self, 1));
+ n = NIL_P(prec) ? (ssize_t)(x->Prec*VpBaseFig()) : NUM2SSIZET(prec);
+
+ if (VpIsNaN(x)) {
+ y = VpCreateRbObject(n, "0#");
+ RB_GC_GUARD(y->obj);
+ VpSetNaN(y);
+ return ToValue(y);
+ }
+
+ retry:
+ switch (TYPE(vexp)) {
+ case T_FIXNUM:
+ break;
+
+ case T_BIGNUM:
+ break;
+
+ case T_FLOAT:
+ d = RFLOAT_VALUE(vexp);
+ if (d == round(d)) {
+ if (FIXABLE(d)) {
+ vexp = LONG2FIX((long)d);
+ }
+ else {
+ vexp = rb_dbl2big(d);
+ }
+ goto retry;
+ }
+ exp = GetVpValueWithPrec(vexp, DBL_DIG+1, 1);
+ break;
+
+ case T_RATIONAL:
+ if (is_zero(rb_rational_num(vexp))) {
+ if (is_positive(vexp)) {
+ vexp = INT2FIX(0);
+ goto retry;
+ }
+ }
+ else if (is_one(rb_rational_den(vexp))) {
+ vexp = rb_rational_num(vexp);
+ goto retry;
+ }
+ exp = GetVpValueWithPrec(vexp, n, 1);
+ break;
+
+ case T_DATA:
+ if (is_kind_of_BigDecimal(vexp)) {
+ VALUE zero = INT2FIX(0);
+ VALUE rounded = BigDecimal_round(1, &zero, vexp);
+ if (RTEST(BigDecimal_eq(vexp, rounded))) {
+ vexp = BigDecimal_to_i(vexp);
+ goto retry;
+ }
+ exp = DATA_PTR(vexp);
+ break;
+ }
+ /* fall through */
+ default:
+ rb_raise(rb_eTypeError,
+ "wrong argument type %"PRIsVALUE" (expected scalar Numeric)",
+ RB_OBJ_CLASSNAME(vexp));
+ }
+
+ if (VpIsZero(x)) {
+ if (is_negative(vexp)) {
+ y = VpCreateRbObject(n, "#0");
+ RB_GC_GUARD(y->obj);
+ if (VpGetSign(x) < 0) {
+ if (is_integer(vexp)) {
+ if (is_even(vexp)) {
+ /* (-0) ** (-even_integer) -> Infinity */
+ VpSetPosInf(y);
+ }
+ else {
+ /* (-0) ** (-odd_integer) -> -Infinity */
+ VpSetNegInf(y);
+ }
+ }
+ else {
+ /* (-0) ** (-non_integer) -> Infinity */
+ VpSetPosInf(y);
+ }
+ }
+ else {
+ /* (+0) ** (-num) -> Infinity */
+ VpSetPosInf(y);
+ }
+ return ToValue(y);
+ }
+ else if (is_zero(vexp)) {
+ return ToValue(VpCreateRbObject(n, "1"));
+ }
+ else {
+ return ToValue(VpCreateRbObject(n, "0"));
+ }
+ }
+
+ if (is_zero(vexp)) {
+ return ToValue(VpCreateRbObject(n, "1"));
+ }
+ else if (is_one(vexp)) {
+ return self;
+ }
+
+ if (VpIsInf(x)) {
+ if (is_negative(vexp)) {
+ if (VpGetSign(x) < 0) {
+ if (is_integer(vexp)) {
+ if (is_even(vexp)) {
+ /* (-Infinity) ** (-even_integer) -> +0 */
+ return ToValue(VpCreateRbObject(n, "0"));
+ }
+ else {
+ /* (-Infinity) ** (-odd_integer) -> -0 */
+ return ToValue(VpCreateRbObject(n, "-0"));
+ }
+ }
+ else {
+ /* (-Infinity) ** (-non_integer) -> -0 */
+ return ToValue(VpCreateRbObject(n, "-0"));
+ }
+ }
+ else {
+ return ToValue(VpCreateRbObject(n, "0"));
+ }
+ }
+ else {
+ y = VpCreateRbObject(n, "0#");
+ if (VpGetSign(x) < 0) {
+ if (is_integer(vexp)) {
+ if (is_even(vexp)) {
+ VpSetPosInf(y);
+ }
+ else {
+ VpSetNegInf(y);
+ }
+ }
+ else {
+ /* TODO: support complex */
+ rb_raise(rb_eMathDomainError,
+ "a non-integral exponent for a negative base");
+ }
+ }
+ else {
+ VpSetPosInf(y);
+ }
+ return ToValue(y);
+ }
+ }
+
+ if (exp != NULL) {
+ return rmpd_power_by_big_decimal(x, exp, n);
+ }
+ else if (RB_TYPE_P(vexp, T_BIGNUM)) {
+ VALUE abs_value = BigDecimal_abs(self);
+ if (is_one(abs_value)) {
+ return ToValue(VpCreateRbObject(n, "1"));
+ }
+ else if (RTEST(rb_funcall(abs_value, '<', 1, INT2FIX(1)))) {
+ if (is_negative(vexp)) {
+ y = VpCreateRbObject(n, "0#");
+ if (is_even(vexp)) {
+ VpSetInf(y, VpGetSign(x));
+ }
+ else {
+ VpSetInf(y, -VpGetSign(x));
+ }
+ return ToValue(y);
+ }
+ else if (VpGetSign(x) < 0 && is_even(vexp)) {
+ return ToValue(VpCreateRbObject(n, "-0"));
+ }
+ else {
+ return ToValue(VpCreateRbObject(n, "0"));
+ }
+ }
+ else {
+ if (is_positive(vexp)) {
+ y = VpCreateRbObject(n, "0#");
+ if (is_even(vexp)) {
+ VpSetInf(y, VpGetSign(x));
+ }
+ else {
+ VpSetInf(y, -VpGetSign(x));
+ }
+ return ToValue(y);
+ }
+ else if (VpGetSign(x) < 0 && is_even(vexp)) {
+ return ToValue(VpCreateRbObject(n, "-0"));
+ }
+ else {
+ return ToValue(VpCreateRbObject(n, "0"));
+ }
+ }
+ }
+
+ int_exp = FIX2LONG(vexp);
+ ma = int_exp;
+ if (ma < 0) ma = -ma;
+ if (ma == 0) ma = 1;
+
+ if (VpIsDef(x)) {
+ mp = x->Prec * (VpBaseFig() + 1);
+ GUARD_OBJ(y, VpCreateRbObject(mp * (ma + 1), "0"));
+ }
+ else {
+ GUARD_OBJ(y, VpCreateRbObject(1, "0"));
+ }
+ VpPower(y, x, int_exp);
+ if (!NIL_P(prec) && VpIsDef(y)) {
+ VpMidRound(y, VpGetRoundMode(), n);
+ }
+ return ToValue(y);
+}
+
+/* call-seq:
+ * big_decimal ** exp -> big_decimal
+ *
+ * It is a synonym of BigDecimal#power(exp).
+ */
+static VALUE
+BigDecimal_power_op(VALUE self, VALUE exp)
+{
+ return BigDecimal_power(1, &exp, self);
+}
+
+static VALUE
+BigDecimal_s_allocate(VALUE klass)
+{
+ return VpNewRbClass(0, NULL, klass)->obj;
+}
+
+static Real *BigDecimal_new(int argc, VALUE *argv);
+
+/* call-seq:
+ * new(initial, digits)
+ *
+ * Create a new BigDecimal object.
+ *
+ * initial:: The initial value, as an Integer, a Float, a Rational,
+ * a BigDecimal, or a String.
+ *
+ * If it is a String, spaces are ignored and unrecognized characters
+ * terminate the value.
+ *
+ * digits:: The number of significant digits, as a Fixnum. If omitted or 0,
+ * the number of significant digits is determined from the initial
+ * value.
+ *
+ * The actual number of significant digits used in computation is usually
+ * larger than the specified number.
+ *
+ * ==== Exceptions
+ *
+ * TypeError:: If the +initial+ type is neither Fixnum, Bignum, Float,
+ * Rational, nor BigDecimal, this exception is raised.
+ *
+ * TypeError:: If the +digits+ is not a Fixnum, this exception is raised.
+ *
+ * ArgumentError:: If +initial+ is a Float, and the +digits+ is larger than
+ * Float::DIG + 1, this exception is raised.
+ *
+ * ArgumentError:: If the +initial+ is a Float or Rational, and the +digits+
+ * value is omitted, this exception is raised.
+ */
+static VALUE
+BigDecimal_initialize(int argc, VALUE *argv, VALUE self)
+{
+ ENTER(1);
+ Real *pv = rb_check_typeddata(self, &BigDecimal_data_type);
+ Real *x;
+
+ GUARD_OBJ(x, BigDecimal_new(argc, argv));
+ if (ToValue(x)) {
+ pv = VpCopy(pv, x);
+ }
+ else {
+ VpFree(pv);
+ pv = x;
+ }
+ DATA_PTR(self) = pv;
+ pv->obj = self;
+ return self;
+}
+
+/* :nodoc:
+ *
+ * private method to dup and clone the provided BigDecimal +other+
+ */
+static VALUE
+BigDecimal_initialize_copy(VALUE self, VALUE other)
+{
+ Real *pv = rb_check_typeddata(self, &BigDecimal_data_type);
+ Real *x = rb_check_typeddata(other, &BigDecimal_data_type);
+
+ if (self != other) {
+ DATA_PTR(self) = VpCopy(pv, x);
+ }
+ return self;
+}
+
+static Real *
+BigDecimal_new(int argc, VALUE *argv)
+{
+ size_t mf;
+ VALUE nFig;
+ VALUE iniValue;
+
+ if (rb_scan_args(argc, argv, "11", &iniValue, &nFig) == 1) {
+ mf = 0;
+ }
+ else {
+ mf = GetPositiveInt(nFig);
+ }
+
+ switch (TYPE(iniValue)) {
+ case T_DATA:
+ if (is_kind_of_BigDecimal(iniValue)) {
+ return DATA_PTR(iniValue);
+ }
+ break;
+
+ case T_FIXNUM:
+ /* fall through */
+ case T_BIGNUM:
+ return GetVpValue(iniValue, 1);
+
+ case T_FLOAT:
+ if (mf > DBL_DIG+1) {
+ rb_raise(rb_eArgError, "precision too large.");
+ }
+ /* fall through */
+ case T_RATIONAL:
+ if (NIL_P(nFig)) {
+ rb_raise(rb_eArgError,
+ "can't omit precision for a %"PRIsVALUE".",
+ RB_OBJ_CLASSNAME(iniValue));
+ }
+ return GetVpValueWithPrec(iniValue, mf, 1);
+
+ case T_STRING:
+ /* fall through */
+ default:
+ break;
+ }
+ StringValueCStr(iniValue);
+ return VpAlloc(mf, RSTRING_PTR(iniValue));
+}
+
+/* See also BigDecimal.new */
+static VALUE
+BigDecimal_global_new(int argc, VALUE *argv, VALUE self)
+{
+ ENTER(1);
+ Real *pv;
+
+ GUARD_OBJ(pv, BigDecimal_new(argc, argv));
+ if (ToValue(pv)) pv = VpCopy(NULL, pv);
+ pv->obj = TypedData_Wrap_Struct(rb_cBigDecimal, &BigDecimal_data_type, pv);
+ return pv->obj;
+}
+
+ /* call-seq:
+ * BigDecimal.limit(digits)
+ *
+ * Limit the number of significant digits in newly created BigDecimal
+ * numbers to the specified value. Rounding is performed as necessary,
+ * as specified by BigDecimal.mode.
+ *
+ * A limit of 0, the default, means no upper limit.
+ *
+ * The limit specified by this method takes less priority over any limit
+ * specified to instance methods such as ceil, floor, truncate, or round.
+ */
+static VALUE
+BigDecimal_limit(int argc, VALUE *argv, VALUE self)
+{
+ VALUE nFig;
+ VALUE nCur = INT2NUM(VpGetPrecLimit());
+
+ if (rb_scan_args(argc, argv, "01", &nFig) == 1) {
+ int nf;
+ if (NIL_P(nFig)) return nCur;
+ Check_Type(nFig, T_FIXNUM);
+ nf = FIX2INT(nFig);
+ if (nf < 0) {
+ rb_raise(rb_eArgError, "argument must be positive");
+ }
+ VpSetPrecLimit(nf);
+ }
+ return nCur;
+}
+
+/* Returns the sign of the value.
+ *
+ * Returns a positive value if > 0, a negative value if < 0, and a
+ * zero if == 0.
+ *
+ * The specific value returned indicates the type and sign of the BigDecimal,
+ * as follows:
+ *
+ * BigDecimal::SIGN_NaN:: value is Not a Number
+ * BigDecimal::SIGN_POSITIVE_ZERO:: value is +0
+ * BigDecimal::SIGN_NEGATIVE_ZERO:: value is -0
+ * BigDecimal::SIGN_POSITIVE_INFINITE:: value is +Infinity
+ * BigDecimal::SIGN_NEGATIVE_INFINITE:: value is -Infinity
+ * BigDecimal::SIGN_POSITIVE_FINITE:: value is positive
+ * BigDecimal::SIGN_NEGATIVE_FINITE:: value is negative
+ */
+static VALUE
+BigDecimal_sign(VALUE self)
+{ /* sign */
+ int s = GetVpValue(self, 1)->sign;
+ return INT2FIX(s);
+}
+
+/*
+ * call-seq: BigDecimal.save_exception_mode { ... }
+ *
+ * Execute the provided block, but preserve the exception mode
+ *
+ * BigDecimal.save_exception_mode do
+ * BigDecimal.mode(BigDecimal::EXCEPTION_OVERFLOW, false)
+ * BigDecimal.mode(BigDecimal::EXCEPTION_NaN, false)
+ *
+ * BigDecimal.new(BigDecimal('Infinity'))
+ * BigDecimal.new(BigDecimal('-Infinity'))
+ * BigDecimal(BigDecimal.new('NaN'))
+ * end
+ *
+ * For use with the BigDecimal::EXCEPTION_*
+ *
+ * See BigDecimal.mode
+ */
+static VALUE
+BigDecimal_save_exception_mode(VALUE self)
+{
+ unsigned short const exception_mode = VpGetException();
+ int state;
+ VALUE ret = rb_protect(rb_yield, Qnil, &state);
+ VpSetException(exception_mode);
+ if (state) rb_jump_tag(state);
+ return ret;
+}
+
+/*
+ * call-seq: BigDecimal.save_rounding_mode { ... }
+ *
+ * Execute the provided block, but preserve the rounding mode
+ *
+ * BigDecimal.save_rounding_mode do
+ * BigDecimal.mode(BigDecimal::ROUND_MODE, :up)
+ * puts BigDecimal.mode(BigDecimal::ROUND_MODE)
+ * end
+ *
+ * For use with the BigDecimal::ROUND_*
+ *
+ * See BigDecimal.mode
+ */
+static VALUE
+BigDecimal_save_rounding_mode(VALUE self)
+{
+ unsigned short const round_mode = VpGetRoundMode();
+ int state;
+ VALUE ret = rb_protect(rb_yield, Qnil, &state);
+ VpSetRoundMode(round_mode);
+ if (state) rb_jump_tag(state);
+ return ret;
+}
+
+/*
+ * call-seq: BigDecimal.save_limit { ... }
+ *
+ * Execute the provided block, but preserve the precision limit
+ *
+ * BigDecimal.limit(100)
+ * puts BigDecimal.limit
+ * BigDecimal.save_limit do
+ * BigDecimal.limit(200)
+ * puts BigDecimal.limit
+ * end
+ * puts BigDecimal.limit
+ *
+ */
+static VALUE
+BigDecimal_save_limit(VALUE self)
+{
+ size_t const limit = VpGetPrecLimit();
+ int state;
+ VALUE ret = rb_protect(rb_yield, Qnil, &state);
+ VpSetPrecLimit(limit);
+ if (state) rb_jump_tag(state);
+ return ret;
+}
+
+/* call-seq:
+ * BigMath.exp(decimal, numeric) -> BigDecimal
+ *
+ * Computes the value of e (the base of natural logarithms) raised to the
+ * power of +decimal+, to the specified number of digits of precision.
+ *
+ * If +decimal+ is infinity, returns Infinity.
+ *
+ * If +decimal+ is NaN, returns NaN.
+ */
+static VALUE
+BigMath_s_exp(VALUE klass, VALUE x, VALUE vprec)
+{
+ ssize_t prec, n, i;
+ Real* vx = NULL;
+ VALUE one, d, y;
+ int negative = 0;
+ int infinite = 0;
+ int nan = 0;
+ double flo;
+
+ prec = NUM2SSIZET(vprec);
+ if (prec <= 0) {
+ rb_raise(rb_eArgError, "Zero or negative precision for exp");
+ }
+
+ /* TODO: the following switch statement is almostly the same as one in the
+ * BigDecimalCmp function. */
+ switch (TYPE(x)) {
+ case T_DATA:
+ if (!is_kind_of_BigDecimal(x)) break;
+ vx = DATA_PTR(x);
+ negative = VpGetSign(vx) < 0;
+ infinite = VpIsPosInf(vx) || VpIsNegInf(vx);
+ nan = VpIsNaN(vx);
+ break;
+
+ case T_FIXNUM:
+ /* fall through */
+ case T_BIGNUM:
+ vx = GetVpValue(x, 0);
+ break;
+
+ case T_FLOAT:
+ flo = RFLOAT_VALUE(x);
+ negative = flo < 0;
+ infinite = isinf(flo);
+ nan = isnan(flo);
+ if (!infinite && !nan) {
+ vx = GetVpValueWithPrec(x, DBL_DIG+1, 0);
+ }
+ break;
+
+ case T_RATIONAL:
+ vx = GetVpValueWithPrec(x, prec, 0);
+ break;
+
+ default:
+ break;
+ }
+ if (infinite) {
+ if (negative) {
+ return ToValue(GetVpValueWithPrec(INT2FIX(0), prec, 1));
+ }
+ else {
+ Real* vy;
+ vy = VpCreateRbObject(prec, "#0");
+ VpSetInf(vy, VP_SIGN_POSITIVE_INFINITE);
+ RB_GC_GUARD(vy->obj);
+ return ToValue(vy);
+ }
+ }
+ else if (nan) {
+ Real* vy;
+ vy = VpCreateRbObject(prec, "#0");
+ VpSetNaN(vy);
+ RB_GC_GUARD(vy->obj);
+ return ToValue(vy);
+ }
+ else if (vx == NULL) {
+ cannot_be_coerced_into_BigDecimal(rb_eArgError, x);
+ }
+ x = vx->obj;
+
+ n = prec + rmpd_double_figures();
+ negative = VpGetSign(vx) < 0;
+ if (negative) {
+ VpSetSign(vx, 1);
+ }
+
+ one = ToValue(VpCreateRbObject(1, "1"));
+ y = one;
+ d = y;
+ i = 1;
+
+ while (!VpIsZero((Real*)DATA_PTR(d))) {
+ SIGNED_VALUE const ey = VpExponent10(DATA_PTR(y));
+ SIGNED_VALUE const ed = VpExponent10(DATA_PTR(d));
+ ssize_t m = n - vabs(ey - ed);
+
+ rb_thread_check_ints();
+
+ if (m <= 0) {
+ break;
+ }
+ else if ((size_t)m < rmpd_double_figures()) {
+ m = rmpd_double_figures();
+ }
+
+ d = BigDecimal_mult(d, x); /* d <- d * x */
+ d = BigDecimal_div2(d, SSIZET2NUM(i), SSIZET2NUM(m)); /* d <- d / i */
+ y = BigDecimal_add(y, d); /* y <- y + d */
+ ++i; /* i <- i + 1 */
+ }
+
+ if (negative) {
+ return BigDecimal_div2(one, y, vprec);
+ }
+ else {
+ vprec = SSIZET2NUM(prec - VpExponent10(DATA_PTR(y)));
+ return BigDecimal_round(1, &vprec, y);
+ }
+
+ RB_GC_GUARD(one);
+ RB_GC_GUARD(x);
+ RB_GC_GUARD(y);
+ RB_GC_GUARD(d);
+}
+
+/* call-seq:
+ * BigMath.log(decimal, numeric) -> BigDecimal
+ *
+ * Computes the natural logarithm of +decimal+ to the specified number of
+ * digits of precision, +numeric+.
+ *
+ * If +decimal+ is zero or negative, raises Math::DomainError.
+ *
+ * If +decimal+ is positive infinity, returns Infinity.
+ *
+ * If +decimal+ is NaN, returns NaN.
+ */
+static VALUE
+BigMath_s_log(VALUE klass, VALUE x, VALUE vprec)
+{
+ ssize_t prec, n, i;
+ SIGNED_VALUE expo;
+ Real* vx = NULL;
+ VALUE vn, one, two, w, x2, y, d;
+ int zero = 0;
+ int negative = 0;
+ int infinite = 0;
+ int nan = 0;
+ double flo;
+ long fix;
+
+ if (!is_integer(vprec)) {
+ rb_raise(rb_eArgError, "precision must be an Integer");
+ }
+
+ prec = NUM2SSIZET(vprec);
+ if (prec <= 0) {
+ rb_raise(rb_eArgError, "Zero or negative precision for exp");
+ }
+
+ /* TODO: the following switch statement is almostly the same as one in the
+ * BigDecimalCmp function. */
+ switch (TYPE(x)) {
+ case T_DATA:
+ if (!is_kind_of_BigDecimal(x)) break;
+ vx = DATA_PTR(x);
+ zero = VpIsZero(vx);
+ negative = VpGetSign(vx) < 0;
+ infinite = VpIsPosInf(vx) || VpIsNegInf(vx);
+ nan = VpIsNaN(vx);
+ break;
+
+ case T_FIXNUM:
+ fix = FIX2LONG(x);
+ zero = fix == 0;
+ negative = fix < 0;
+ goto get_vp_value;
+
+ case T_BIGNUM:
+ i = FIX2INT(rb_big_cmp(x, INT2FIX(0)));
+ zero = i == 0;
+ negative = i < 0;
+get_vp_value:
+ if (zero || negative) break;
+ vx = GetVpValue(x, 0);
+ break;
+
+ case T_FLOAT:
+ flo = RFLOAT_VALUE(x);
+ zero = flo == 0;
+ negative = flo < 0;
+ infinite = isinf(flo);
+ nan = isnan(flo);
+ if (!zero && !negative && !infinite && !nan) {
+ vx = GetVpValueWithPrec(x, DBL_DIG+1, 1);
+ }
+ break;
+
+ case T_RATIONAL:
+ zero = RRATIONAL_ZERO_P(x);
+ negative = RRATIONAL_NEGATIVE_P(x);
+ if (zero || negative) break;
+ vx = GetVpValueWithPrec(x, prec, 1);
+ break;
+
+ case T_COMPLEX:
+ rb_raise(rb_eMathDomainError,
+ "Complex argument for BigMath.log");
+
+ default:
+ break;
+ }
+ if (infinite && !negative) {
+ Real* vy;
+ vy = VpCreateRbObject(prec, "#0");
+ RB_GC_GUARD(vy->obj);
+ VpSetInf(vy, VP_SIGN_POSITIVE_INFINITE);
+ return ToValue(vy);
+ }
+ else if (nan) {
+ Real* vy;
+ vy = VpCreateRbObject(prec, "#0");
+ RB_GC_GUARD(vy->obj);
+ VpSetNaN(vy);
+ return ToValue(vy);
+ }
+ else if (zero || negative) {
+ rb_raise(rb_eMathDomainError,
+ "Zero or negative argument for log");
+ }
+ else if (vx == NULL) {
+ cannot_be_coerced_into_BigDecimal(rb_eArgError, x);
+ }
+ x = ToValue(vx);
+
+ RB_GC_GUARD(one) = ToValue(VpCreateRbObject(1, "1"));
+ RB_GC_GUARD(two) = ToValue(VpCreateRbObject(1, "2"));
+
+ n = prec + rmpd_double_figures();
+ RB_GC_GUARD(vn) = SSIZET2NUM(n);
+ expo = VpExponent10(vx);
+ if (expo < 0 || expo >= 3) {
+ char buf[DECIMAL_SIZE_OF_BITS(SIZEOF_VALUE * CHAR_BIT) + 4];
+ snprintf(buf, sizeof(buf), "1E%"PRIdVALUE, -expo);
+ x = BigDecimal_mult2(x, ToValue(VpCreateRbObject(1, buf)), vn);
+ }
+ else {
+ expo = 0;
+ }
+ w = BigDecimal_sub(x, one);
+ x = BigDecimal_div2(w, BigDecimal_add(x, one), vn);
+ RB_GC_GUARD(x2) = BigDecimal_mult2(x, x, vn);
+ RB_GC_GUARD(y) = x;
+ RB_GC_GUARD(d) = y;
+ i = 1;
+ while (!VpIsZero((Real*)DATA_PTR(d))) {
+ SIGNED_VALUE const ey = VpExponent10(DATA_PTR(y));
+ SIGNED_VALUE const ed = VpExponent10(DATA_PTR(d));
+ ssize_t m = n - vabs(ey - ed);
+ if (m <= 0) {
+ break;
+ }
+ else if ((size_t)m < rmpd_double_figures()) {
+ m = rmpd_double_figures();
+ }
+
+ x = BigDecimal_mult2(x2, x, vn);
+ i += 2;
+ d = BigDecimal_div2(x, SSIZET2NUM(i), SSIZET2NUM(m));
+ y = BigDecimal_add(y, d);
+ }
+
+ y = BigDecimal_mult(y, two);
+ if (expo != 0) {
+ VALUE log10, vexpo, dy;
+ log10 = BigMath_s_log(klass, INT2FIX(10), vprec);
+ vexpo = ToValue(GetVpValue(SSIZET2NUM(expo), 1));
+ dy = BigDecimal_mult(log10, vexpo);
+ y = BigDecimal_add(y, dy);
+ }
+
+ return y;
+}
+
+/* Document-class: BigDecimal
+ * BigDecimal provides arbitrary-precision floating point decimal arithmetic.
+ *
+ * == Introduction
+ *
+ * Ruby provides built-in support for arbitrary precision integer arithmetic.
+ *
+ * For example:
+ *
+ * 42**13 #=> 1265437718438866624512
+ *
+ * BigDecimal provides similar support for very large or very accurate floating
+ * point numbers.
+ *
+ * Decimal arithmetic is also useful for general calculation, because it
+ * provides the correct answers people expect--whereas normal binary floating
+ * point arithmetic often introduces subtle errors because of the conversion
+ * between base 10 and base 2.
+ *
+ * For example, try:
+ *
+ * sum = 0
+ * 10_000.times do
+ * sum = sum + 0.0001
+ * end
+ * print sum #=> 0.9999999999999062
+ *
+ * and contrast with the output from:
+ *
+ * require 'bigdecimal'
+ *
+ * sum = BigDecimal.new("0")
+ * 10_000.times do
+ * sum = sum + BigDecimal.new("0.0001")
+ * end
+ * print sum #=> 0.1E1
+ *
+ * Similarly:
+ *
+ * (BigDecimal.new("1.2") - BigDecimal("1.0")) == BigDecimal("0.2") #=> true
+ *
+ * (1.2 - 1.0) == 0.2 #=> false
+ *
+ * == Special features of accurate decimal arithmetic
+ *
+ * Because BigDecimal is more accurate than normal binary floating point
+ * arithmetic, it requires some special values.
+ *
+ * === Infinity
+ *
+ * BigDecimal sometimes needs to return infinity, for example if you divide
+ * a value by zero.
+ *
+ * BigDecimal.new("1.0") / BigDecimal.new("0.0") #=> Infinity
+ * BigDecimal.new("-1.0") / BigDecimal.new("0.0") #=> -Infinity
+ *
+ * You can represent infinite numbers to BigDecimal using the strings
+ * <code>'Infinity'</code>, <code>'+Infinity'</code> and
+ * <code>'-Infinity'</code> (case-sensitive)
+ *
+ * === Not a Number
+ *
+ * When a computation results in an undefined value, the special value +NaN+
+ * (for 'not a number') is returned.
+ *
+ * Example:
+ *
+ * BigDecimal.new("0.0") / BigDecimal.new("0.0") #=> NaN
+ *
+ * You can also create undefined values.
+ *
+ * NaN is never considered to be the same as any other value, even NaN itself:
+ *
+ * n = BigDecimal.new('NaN')
+ * n == 0.0 #=> false
+ * n == n #=> false
+ *
+ * === Positive and negative zero
+ *
+ * If a computation results in a value which is too small to be represented as
+ * a BigDecimal within the currently specified limits of precision, zero must
+ * be returned.
+ *
+ * If the value which is too small to be represented is negative, a BigDecimal
+ * value of negative zero is returned.
+ *
+ * BigDecimal.new("1.0") / BigDecimal.new("-Infinity") #=> -0.0
+ *
+ * If the value is positive, a value of positive zero is returned.
+ *
+ * BigDecimal.new("1.0") / BigDecimal.new("Infinity") #=> 0.0
+ *
+ * (See BigDecimal.mode for how to specify limits of precision.)
+ *
+ * Note that +-0.0+ and +0.0+ are considered to be the same for the purposes of
+ * comparison.
+ *
+ * Note also that in mathematics, there is no particular concept of negative
+ * or positive zero; true mathematical zero has no sign.
+ *
+ * == License
+ *
+ * Copyright (C) 2002 by Shigeo Kobayashi <shigeo@tinyforest.gr.jp>.
+ *
+ * You may distribute under the terms of either the GNU General Public
+ * License or the Artistic License, as specified in the README file
+ * of the BigDecimal distribution.
+ *
+ * Maintained by mrkn <mrkn@mrkn.jp> and ruby-core members.
+ *
+ * Documented by zzak <zachary@zacharyscott.net>, mathew <meta@pobox.com>, and
+ * many other contributors.
+ */
+void
+Init_bigdecimal(void)
+{
+ VALUE arg;
+
+ id_BigDecimal_exception_mode = rb_intern_const("BigDecimal.exception_mode");
+ id_BigDecimal_rounding_mode = rb_intern_const("BigDecimal.rounding_mode");
+ id_BigDecimal_precision_limit = rb_intern_const("BigDecimal.precision_limit");
+
+ /* Initialize VP routines */
+ VpInit(0UL);
+
+ /* Class and method registration */
+ rb_cBigDecimal = rb_define_class("BigDecimal", rb_cNumeric);
+ rb_define_alloc_func(rb_cBigDecimal, BigDecimal_s_allocate);
+
+ /* Global function */
+ rb_define_global_function("BigDecimal", BigDecimal_global_new, -1);
+
+ /* Class methods */
+ rb_define_singleton_method(rb_cBigDecimal, "mode", BigDecimal_mode, -1);
+ rb_define_singleton_method(rb_cBigDecimal, "limit", BigDecimal_limit, -1);
+ rb_define_singleton_method(rb_cBigDecimal, "double_fig", BigDecimal_double_fig, 0);
+ rb_define_singleton_method(rb_cBigDecimal, "_load", BigDecimal_load, 1);
+ rb_define_singleton_method(rb_cBigDecimal, "ver", BigDecimal_version, 0);
+
+ rb_define_singleton_method(rb_cBigDecimal, "save_exception_mode", BigDecimal_save_exception_mode, 0);
+ rb_define_singleton_method(rb_cBigDecimal, "save_rounding_mode", BigDecimal_save_rounding_mode, 0);
+ rb_define_singleton_method(rb_cBigDecimal, "save_limit", BigDecimal_save_limit, 0);
+
+ /* Constants definition */
+
+ /*
+ * Base value used in internal calculations. On a 32 bit system, BASE
+ * is 10000, indicating that calculation is done in groups of 4 digits.
+ * (If it were larger, BASE**2 wouldn't fit in 32 bits, so you couldn't
+ * guarantee that two groups could always be multiplied together without
+ * overflow.)
+ */
+ rb_define_const(rb_cBigDecimal, "BASE", INT2FIX((SIGNED_VALUE)VpBaseVal()));
+
+ /* Exceptions */
+
+ /*
+ * 0xff: Determines whether overflow, underflow or zero divide result in
+ * an exception being thrown. See BigDecimal.mode.
+ */
+ rb_define_const(rb_cBigDecimal, "EXCEPTION_ALL", INT2FIX(VP_EXCEPTION_ALL));
+
+ /*
+ * 0x02: Determines what happens when the result of a computation is not a
+ * number (NaN). See BigDecimal.mode.
+ */
+ rb_define_const(rb_cBigDecimal, "EXCEPTION_NaN", INT2FIX(VP_EXCEPTION_NaN));
+
+ /*
+ * 0x01: Determines what happens when the result of a computation is
+ * infinity. See BigDecimal.mode.
+ */
+ rb_define_const(rb_cBigDecimal, "EXCEPTION_INFINITY", INT2FIX(VP_EXCEPTION_INFINITY));
+
+ /*
+ * 0x04: Determines what happens when the result of a computation is an
+ * underflow (a result too small to be represented). See BigDecimal.mode.
+ */
+ rb_define_const(rb_cBigDecimal, "EXCEPTION_UNDERFLOW", INT2FIX(VP_EXCEPTION_UNDERFLOW));
+
+ /*
+ * 0x01: Determines what happens when the result of a computation is an
+ * overflow (a result too large to be represented). See BigDecimal.mode.
+ */
+ rb_define_const(rb_cBigDecimal, "EXCEPTION_OVERFLOW", INT2FIX(VP_EXCEPTION_OVERFLOW));
+
+ /*
+ * 0x01: Determines what happens when a division by zero is performed.
+ * See BigDecimal.mode.
+ */
+ rb_define_const(rb_cBigDecimal, "EXCEPTION_ZERODIVIDE", INT2FIX(VP_EXCEPTION_ZERODIVIDE));
+
+ /*
+ * 0x100: Determines what happens when a result must be rounded in order to
+ * fit in the appropriate number of significant digits. See
+ * BigDecimal.mode.
+ */
+ rb_define_const(rb_cBigDecimal, "ROUND_MODE", INT2FIX(VP_ROUND_MODE));
+
+ /* 1: Indicates that values should be rounded away from zero. See
+ * BigDecimal.mode.
+ */
+ rb_define_const(rb_cBigDecimal, "ROUND_UP", INT2FIX(VP_ROUND_UP));
+
+ /* 2: Indicates that values should be rounded towards zero. See
+ * BigDecimal.mode.
+ */
+ rb_define_const(rb_cBigDecimal, "ROUND_DOWN", INT2FIX(VP_ROUND_DOWN));
+
+ /* 3: Indicates that digits >= 5 should be rounded up, others rounded down.
+ * See BigDecimal.mode. */
+ rb_define_const(rb_cBigDecimal, "ROUND_HALF_UP", INT2FIX(VP_ROUND_HALF_UP));
+
+ /* 4: Indicates that digits >= 6 should be rounded up, others rounded down.
+ * See BigDecimal.mode.
+ */
+ rb_define_const(rb_cBigDecimal, "ROUND_HALF_DOWN", INT2FIX(VP_ROUND_HALF_DOWN));
+ /* 5: Round towards +Infinity. See BigDecimal.mode. */
+ rb_define_const(rb_cBigDecimal, "ROUND_CEILING", INT2FIX(VP_ROUND_CEIL));
+
+ /* 6: Round towards -Infinity. See BigDecimal.mode. */
+ rb_define_const(rb_cBigDecimal, "ROUND_FLOOR", INT2FIX(VP_ROUND_FLOOR));
+
+ /* 7: Round towards the even neighbor. See BigDecimal.mode. */
+ rb_define_const(rb_cBigDecimal, "ROUND_HALF_EVEN", INT2FIX(VP_ROUND_HALF_EVEN));
+
+ /* 0: Indicates that a value is not a number. See BigDecimal.sign. */
+ rb_define_const(rb_cBigDecimal, "SIGN_NaN", INT2FIX(VP_SIGN_NaN));
+
+ /* 1: Indicates that a value is +0. See BigDecimal.sign. */
+ rb_define_const(rb_cBigDecimal, "SIGN_POSITIVE_ZERO", INT2FIX(VP_SIGN_POSITIVE_ZERO));
+
+ /* -1: Indicates that a value is -0. See BigDecimal.sign. */
+ rb_define_const(rb_cBigDecimal, "SIGN_NEGATIVE_ZERO", INT2FIX(VP_SIGN_NEGATIVE_ZERO));
+
+ /* 2: Indicates that a value is positive and finite. See BigDecimal.sign. */
+ rb_define_const(rb_cBigDecimal, "SIGN_POSITIVE_FINITE", INT2FIX(VP_SIGN_POSITIVE_FINITE));
+
+ /* -2: Indicates that a value is negative and finite. See BigDecimal.sign. */
+ rb_define_const(rb_cBigDecimal, "SIGN_NEGATIVE_FINITE", INT2FIX(VP_SIGN_NEGATIVE_FINITE));
+
+ /* 3: Indicates that a value is positive and infinite. See BigDecimal.sign. */
+ rb_define_const(rb_cBigDecimal, "SIGN_POSITIVE_INFINITE", INT2FIX(VP_SIGN_POSITIVE_INFINITE));
+
+ /* -3: Indicates that a value is negative and infinite. See BigDecimal.sign. */
+ rb_define_const(rb_cBigDecimal, "SIGN_NEGATIVE_INFINITE", INT2FIX(VP_SIGN_NEGATIVE_INFINITE));
+
+ arg = rb_str_new2("+Infinity");
+ /* Positive infinity value. */
+ rb_define_const(rb_cBigDecimal, "INFINITY", BigDecimal_global_new(1, &arg, rb_cBigDecimal));
+ arg = rb_str_new2("NaN");
+ /* 'Not a Number' value. */
+ rb_define_const(rb_cBigDecimal, "NAN", BigDecimal_global_new(1, &arg, rb_cBigDecimal));
+
+
+ /* instance methods */
+ rb_define_method(rb_cBigDecimal, "initialize", BigDecimal_initialize, -1);
+ rb_define_method(rb_cBigDecimal, "initialize_copy", BigDecimal_initialize_copy, 1);
+ rb_define_method(rb_cBigDecimal, "precs", BigDecimal_prec, 0);
+
+ rb_define_method(rb_cBigDecimal, "add", BigDecimal_add2, 2);
+ rb_define_method(rb_cBigDecimal, "sub", BigDecimal_sub2, 2);
+ rb_define_method(rb_cBigDecimal, "mult", BigDecimal_mult2, 2);
+ rb_define_method(rb_cBigDecimal, "div", BigDecimal_div3, -1);
+ rb_define_method(rb_cBigDecimal, "hash", BigDecimal_hash, 0);
+ rb_define_method(rb_cBigDecimal, "to_s", BigDecimal_to_s, -1);
+ rb_define_method(rb_cBigDecimal, "to_i", BigDecimal_to_i, 0);
+ rb_define_method(rb_cBigDecimal, "to_int", BigDecimal_to_i, 0);
+ rb_define_method(rb_cBigDecimal, "to_r", BigDecimal_to_r, 0);
+ rb_define_method(rb_cBigDecimal, "split", BigDecimal_split, 0);
+ rb_define_method(rb_cBigDecimal, "+", BigDecimal_add, 1);
+ rb_define_method(rb_cBigDecimal, "-", BigDecimal_sub, 1);
+ rb_define_method(rb_cBigDecimal, "+@", BigDecimal_uplus, 0);
+ rb_define_method(rb_cBigDecimal, "-@", BigDecimal_neg, 0);
+ rb_define_method(rb_cBigDecimal, "*", BigDecimal_mult, 1);
+ rb_define_method(rb_cBigDecimal, "/", BigDecimal_div, 1);
+ rb_define_method(rb_cBigDecimal, "quo", BigDecimal_div, 1);
+ rb_define_method(rb_cBigDecimal, "%", BigDecimal_mod, 1);
+ rb_define_method(rb_cBigDecimal, "modulo", BigDecimal_mod, 1);
+ rb_define_method(rb_cBigDecimal, "remainder", BigDecimal_remainder, 1);
+ rb_define_method(rb_cBigDecimal, "divmod", BigDecimal_divmod, 1);
+ /* rb_define_method(rb_cBigDecimal, "dup", BigDecimal_dup, 0); */
+ rb_define_method(rb_cBigDecimal, "to_f", BigDecimal_to_f, 0);
+ rb_define_method(rb_cBigDecimal, "abs", BigDecimal_abs, 0);
+ rb_define_method(rb_cBigDecimal, "sqrt", BigDecimal_sqrt, 1);
+ rb_define_method(rb_cBigDecimal, "fix", BigDecimal_fix, 0);
+ rb_define_method(rb_cBigDecimal, "round", BigDecimal_round, -1);
+ rb_define_method(rb_cBigDecimal, "frac", BigDecimal_frac, 0);
+ rb_define_method(rb_cBigDecimal, "floor", BigDecimal_floor, -1);
+ rb_define_method(rb_cBigDecimal, "ceil", BigDecimal_ceil, -1);
+ rb_define_method(rb_cBigDecimal, "power", BigDecimal_power, -1);
+ rb_define_method(rb_cBigDecimal, "**", BigDecimal_power_op, 1);
+ rb_define_method(rb_cBigDecimal, "<=>", BigDecimal_comp, 1);
+ rb_define_method(rb_cBigDecimal, "==", BigDecimal_eq, 1);
+ rb_define_method(rb_cBigDecimal, "===", BigDecimal_eq, 1);
+ rb_define_method(rb_cBigDecimal, "eql?", BigDecimal_eq, 1);
+ rb_define_method(rb_cBigDecimal, "<", BigDecimal_lt, 1);
+ rb_define_method(rb_cBigDecimal, "<=", BigDecimal_le, 1);
+ rb_define_method(rb_cBigDecimal, ">", BigDecimal_gt, 1);
+ rb_define_method(rb_cBigDecimal, ">=", BigDecimal_ge, 1);
+ rb_define_method(rb_cBigDecimal, "zero?", BigDecimal_zero, 0);
+ rb_define_method(rb_cBigDecimal, "nonzero?", BigDecimal_nonzero, 0);
+ rb_define_method(rb_cBigDecimal, "coerce", BigDecimal_coerce, 1);
+ rb_define_method(rb_cBigDecimal, "inspect", BigDecimal_inspect, 0);
+ rb_define_method(rb_cBigDecimal, "exponent", BigDecimal_exponent, 0);
+ rb_define_method(rb_cBigDecimal, "sign", BigDecimal_sign, 0);
+ rb_define_method(rb_cBigDecimal, "nan?", BigDecimal_IsNaN, 0);
+ rb_define_method(rb_cBigDecimal, "infinite?", BigDecimal_IsInfinite, 0);
+ rb_define_method(rb_cBigDecimal, "finite?", BigDecimal_IsFinite, 0);
+ rb_define_method(rb_cBigDecimal, "truncate", BigDecimal_truncate, -1);
+ rb_define_method(rb_cBigDecimal, "_dump", BigDecimal_dump, -1);
+
+ rb_mBigMath = rb_define_module("BigMath");
+ rb_define_singleton_method(rb_mBigMath, "exp", BigMath_s_exp, 2);
+ rb_define_singleton_method(rb_mBigMath, "log", BigMath_s_log, 2);
+
+ id_up = rb_intern_const("up");
+ id_down = rb_intern_const("down");
+ id_truncate = rb_intern_const("truncate");
+ id_half_up = rb_intern_const("half_up");
+ id_default = rb_intern_const("default");
+ id_half_down = rb_intern_const("half_down");
+ id_half_even = rb_intern_const("half_even");
+ id_banker = rb_intern_const("banker");
+ id_ceiling = rb_intern_const("ceiling");
+ id_ceil = rb_intern_const("ceil");
+ id_floor = rb_intern_const("floor");
+ id_to_r = rb_intern_const("to_r");
+ id_eq = rb_intern_const("==");
+}
+
+/*
+ *
+ * ============================================================================
+ *
+ * vp_ routines begin from here.
+ *
+ * ============================================================================
+ *
+ */
+#ifdef BIGDECIMAL_DEBUG
+static int gfDebug = 1; /* Debug switch */
+#if 0
+static int gfCheckVal = 1; /* Value checking flag in VpNmlz() */
+#endif
+#endif /* BIGDECIMAL_DEBUG */
+
+static Real *VpConstOne; /* constant 1.0 */
+static Real *VpPt5; /* constant 0.5 */
+#define maxnr 100UL /* Maximum iterations for calculating sqrt. */
+ /* used in VpSqrt() */
+
+/* ETC */
+#define MemCmp(x,y,z) memcmp(x,y,z)
+#define StrCmp(x,y) strcmp(x,y)
+
+static int VpIsDefOP(Real *c,Real *a,Real *b,int sw);
+static int AddExponent(Real *a, SIGNED_VALUE n);
+static BDIGIT VpAddAbs(Real *a,Real *b,Real *c);
+static BDIGIT VpSubAbs(Real *a,Real *b,Real *c);
+static size_t VpSetPTR(Real *a, Real *b, Real *c, size_t *a_pos, size_t *b_pos, size_t *c_pos, BDIGIT *av, BDIGIT *bv);
+static int VpNmlz(Real *a);
+static void VpFormatSt(char *psz, size_t fFmt);
+static int VpRdup(Real *m, size_t ind_m);
+
+#ifdef BIGDECIMAL_DEBUG
+static int gnAlloc = 0; /* Memory allocation counter */
+#endif /* BIGDECIMAL_DEBUG */
+
+VP_EXPORT void *
+VpMemAlloc(size_t mb)
+{
+ void *p = xmalloc(mb);
+ if (!p) {
+ VpException(VP_EXCEPTION_MEMORY, "failed to allocate memory", 1);
+ }
+ memset(p, 0, mb);
+#ifdef BIGDECIMAL_DEBUG
+ gnAlloc++; /* Count allocation call */
+#endif /* BIGDECIMAL_DEBUG */
+ return p;
+}
+
+ VP_EXPORT void *
+VpMemRealloc(void *ptr, size_t mb)
+{
+ void *p = xrealloc(ptr, mb);
+ if (!p) {
+ VpException(VP_EXCEPTION_MEMORY, "failed to allocate memory", 1);
+ }
+ return p;
+}
+
+VP_EXPORT void
+VpFree(Real *pv)
+{
+ if (pv != NULL) {
+ xfree(pv);
+#ifdef BIGDECIMAL_DEBUG
+ gnAlloc--; /* Decrement allocation count */
+ if (gnAlloc == 0) {
+ printf(" *************** All memories allocated freed ****************");
+ getchar();
+ }
+ if (gnAlloc < 0) {
+ printf(" ??????????? Too many memory free calls(%d) ?????????????\n", gnAlloc);
+ getchar();
+ }
+#endif /* BIGDECIMAL_DEBUG */
+ }
+}
+
+/*
+ * EXCEPTION Handling.
+ */
+
+#define rmpd_set_thread_local_exception_mode(mode) \
+ rb_thread_local_aset( \
+ rb_thread_current(), \
+ id_BigDecimal_exception_mode, \
+ INT2FIX((int)(mode)) \
+ )
+
+static unsigned short
+VpGetException (void)
+{
+ VALUE const vmode = rb_thread_local_aref(
+ rb_thread_current(),
+ id_BigDecimal_exception_mode
+ );
+
+ if (NIL_P(vmode)) {
+ rmpd_set_thread_local_exception_mode(RMPD_EXCEPTION_MODE_DEFAULT);
+ return RMPD_EXCEPTION_MODE_DEFAULT;
+ }
+
+ return (unsigned short)FIX2UINT(vmode);
+}
+
+static void
+VpSetException(unsigned short f)
+{
+ rmpd_set_thread_local_exception_mode(f);
+}
+
+/*
+ * Precision limit.
+ */
+
+#define rmpd_set_thread_local_precision_limit(limit) \
+ rb_thread_local_aset( \
+ rb_thread_current(), \
+ id_BigDecimal_precision_limit, \
+ SIZET2NUM(limit) \
+ )
+#define RMPD_PRECISION_LIMIT_DEFAULT ((size_t)0)
+
+/* These 2 functions added at v1.1.7 */
+VP_EXPORT size_t
+VpGetPrecLimit(void)
+{
+ VALUE const vlimit = rb_thread_local_aref(
+ rb_thread_current(),
+ id_BigDecimal_precision_limit
+ );
+
+ if (NIL_P(vlimit)) {
+ rmpd_set_thread_local_precision_limit(RMPD_PRECISION_LIMIT_DEFAULT);
+ return RMPD_PRECISION_LIMIT_DEFAULT;
+ }
+
+ return NUM2SIZET(vlimit);
+}
+
+VP_EXPORT size_t
+VpSetPrecLimit(size_t n)
+{
+ size_t const s = VpGetPrecLimit();
+ rmpd_set_thread_local_precision_limit(n);
+ return s;
+}
+
+/*
+ * Rounding mode.
+ */
+
+#define rmpd_set_thread_local_rounding_mode(mode) \
+ rb_thread_local_aset( \
+ rb_thread_current(), \
+ id_BigDecimal_rounding_mode, \
+ INT2FIX((int)(mode)) \
+ )
+
+VP_EXPORT unsigned short
+VpGetRoundMode(void)
+{
+ VALUE const vmode = rb_thread_local_aref(
+ rb_thread_current(),
+ id_BigDecimal_rounding_mode
+ );
+
+ if (NIL_P(vmode)) {
+ rmpd_set_thread_local_rounding_mode(RMPD_ROUNDING_MODE_DEFAULT);
+ return RMPD_ROUNDING_MODE_DEFAULT;
+ }
+
+ return (unsigned short)FIX2INT(vmode);
+}
+
+VP_EXPORT int
+VpIsRoundMode(unsigned short n)
+{
+ switch (n) {
+ case VP_ROUND_UP:
+ case VP_ROUND_DOWN:
+ case VP_ROUND_HALF_UP:
+ case VP_ROUND_HALF_DOWN:
+ case VP_ROUND_CEIL:
+ case VP_ROUND_FLOOR:
+ case VP_ROUND_HALF_EVEN:
+ return 1;
+
+ default:
+ return 0;
+ }
+}
+
+VP_EXPORT unsigned short
+VpSetRoundMode(unsigned short n)
+{
+ if (VpIsRoundMode(n)) {
+ rmpd_set_thread_local_rounding_mode(n);
+ return n;
+ }
+
+ return VpGetRoundMode();
+}
+
+/*
+ * 0.0 & 1.0 generator
+ * These gZero_..... and gOne_..... can be any name
+ * referenced from nowhere except Zero() and One().
+ * gZero_..... and gOne_..... must have global scope
+ * (to let the compiler know they may be changed in outside
+ * (... but not actually..)).
+ */
+volatile const double gZero_ABCED9B1_CE73__00400511F31D = 0.0;
+volatile const double gOne_ABCED9B4_CE73__00400511F31D = 1.0;
+static double
+Zero(void)
+{
+ return gZero_ABCED9B1_CE73__00400511F31D;
+}
+
+static double
+One(void)
+{
+ return gOne_ABCED9B4_CE73__00400511F31D;
+}
+
+/*
+ ----------------------------------------------------------------
+ Value of sign in Real structure is reserved for future use.
+ short sign;
+ ==0 : NaN
+ 1 : Positive zero
+ -1 : Negative zero
+ 2 : Positive number
+ -2 : Negative number
+ 3 : Positive infinite number
+ -3 : Negative infinite number
+ ----------------------------------------------------------------
+*/
+
+VP_EXPORT double
+VpGetDoubleNaN(void) /* Returns the value of NaN */
+{
+ static double fNaN = 0.0;
+ if (fNaN == 0.0) fNaN = Zero()/Zero();
+ return fNaN;
+}
+
+VP_EXPORT double
+VpGetDoublePosInf(void) /* Returns the value of +Infinity */
+{
+ static double fInf = 0.0;
+ if (fInf == 0.0) fInf = One()/Zero();
+ return fInf;
+}
+
+VP_EXPORT double
+VpGetDoubleNegInf(void) /* Returns the value of -Infinity */
+{
+ static double fInf = 0.0;
+ if (fInf == 0.0) fInf = -(One()/Zero());
+ return fInf;
+}
+
+VP_EXPORT double
+VpGetDoubleNegZero(void) /* Returns the value of -0 */
+{
+ static double nzero = 1000.0;
+ if (nzero != 0.0) nzero = (One()/VpGetDoubleNegInf());
+ return nzero;
+}
+
+#if 0 /* unused */
+VP_EXPORT int
+VpIsNegDoubleZero(double v)
+{
+ double z = VpGetDoubleNegZero();
+ return MemCmp(&v,&z,sizeof(v))==0;
+}
+#endif
+
+VP_EXPORT int
+VpException(unsigned short f, const char *str,int always)
+{
+ unsigned short const exception_mode = VpGetException();
+
+ if (f == VP_EXCEPTION_OP || f == VP_EXCEPTION_MEMORY) always = 1;
+
+ if (always || (exception_mode & f)) {
+ switch(f) {
+ /* case VP_EXCEPTION_OVERFLOW: */
+ case VP_EXCEPTION_ZERODIVIDE:
+ case VP_EXCEPTION_INFINITY:
+ case VP_EXCEPTION_NaN:
+ case VP_EXCEPTION_UNDERFLOW:
+ case VP_EXCEPTION_OP:
+ rb_raise(rb_eFloatDomainError, "%s", str);
+ break;
+ case VP_EXCEPTION_MEMORY:
+ default:
+ rb_fatal("%s", str);
+ }
+ }
+ return 0; /* 0 Means VpException() raised no exception */
+}
+
+/* Throw exception or returns 0,when resulting c is Inf or NaN */
+/* sw=1:+ 2:- 3:* 4:/ */
+static int
+VpIsDefOP(Real *c,Real *a,Real *b,int sw)
+{
+ if (VpIsNaN(a) || VpIsNaN(b)) {
+ /* at least a or b is NaN */
+ VpSetNaN(c);
+ goto NaN;
+ }
+
+ if (VpIsInf(a)) {
+ if (VpIsInf(b)) {
+ switch(sw) {
+ case 1: /* + */
+ if (VpGetSign(a) == VpGetSign(b)) {
+ VpSetInf(c, VpGetSign(a));
+ goto Inf;
+ }
+ else {
+ VpSetNaN(c);
+ goto NaN;
+ }
+ case 2: /* - */
+ if (VpGetSign(a) != VpGetSign(b)) {
+ VpSetInf(c, VpGetSign(a));
+ goto Inf;
+ }
+ else {
+ VpSetNaN(c);
+ goto NaN;
+ }
+ break;
+ case 3: /* * */
+ VpSetInf(c, VpGetSign(a)*VpGetSign(b));
+ goto Inf;
+ break;
+ case 4: /* / */
+ VpSetNaN(c);
+ goto NaN;
+ }
+ VpSetNaN(c);
+ goto NaN;
+ }
+ /* Inf op Finite */
+ switch(sw) {
+ case 1: /* + */
+ case 2: /* - */
+ VpSetInf(c, VpGetSign(a));
+ break;
+ case 3: /* * */
+ if (VpIsZero(b)) {
+ VpSetNaN(c);
+ goto NaN;
+ }
+ VpSetInf(c, VpGetSign(a)*VpGetSign(b));
+ break;
+ case 4: /* / */
+ VpSetInf(c, VpGetSign(a)*VpGetSign(b));
+ }
+ goto Inf;
+ }
+
+ if (VpIsInf(b)) {
+ switch(sw) {
+ case 1: /* + */
+ VpSetInf(c, VpGetSign(b));
+ break;
+ case 2: /* - */
+ VpSetInf(c, -VpGetSign(b));
+ break;
+ case 3: /* * */
+ if (VpIsZero(a)) {
+ VpSetNaN(c);
+ goto NaN;
+ }
+ VpSetInf(c, VpGetSign(a)*VpGetSign(b));
+ break;
+ case 4: /* / */
+ VpSetZero(c, VpGetSign(a)*VpGetSign(b));
+ }
+ goto Inf;
+ }
+ return 1; /* Results OK */
+
+Inf:
+ return VpException(VP_EXCEPTION_INFINITY, "Computation results to 'Infinity'", 0);
+NaN:
+ return VpException(VP_EXCEPTION_NaN, "Computation results to 'NaN'", 0);
+}
+
+/*
+ ----------------------------------------------------------------
+*/
+
+/*
+ * returns number of chars needed to represent vp in specified format.
+ */
+VP_EXPORT size_t
+VpNumOfChars(Real *vp,const char *pszFmt)
+{
+ SIGNED_VALUE ex;
+ size_t nc;
+
+ if (vp == NULL) return BASE_FIG*2+6;
+ if (!VpIsDef(vp)) return 32; /* not sure,may be OK */
+
+ switch(*pszFmt) {
+ case 'F':
+ nc = BASE_FIG*(vp->Prec + 1)+2;
+ ex = vp->exponent;
+ if (ex < 0) {
+ nc += BASE_FIG*(size_t)(-ex);
+ }
+ else {
+ if ((size_t)ex > vp->Prec) {
+ nc += BASE_FIG*((size_t)ex - vp->Prec);
+ }
+ }
+ break;
+ case 'E':
+ /* fall through */
+ default:
+ nc = BASE_FIG*(vp->Prec + 2)+6; /* 3: sign + exponent chars */
+ }
+ return nc;
+}
+
+/*
+ * Initializer for Vp routines and constants used.
+ * [Input]
+ * BaseVal: Base value(assigned to BASE) for Vp calculation.
+ * It must be the form BaseVal=10**n.(n=1,2,3,...)
+ * If Base <= 0L,then the BASE will be calculated so
+ * that BASE is as large as possible satisfying the
+ * relation MaxVal <= BASE*(BASE+1). Where the value
+ * MaxVal is the largest value which can be represented
+ * by one BDIGIT word in the computer used.
+ *
+ * [Returns]
+ * 1+DBL_DIG ... OK
+ */
+VP_EXPORT size_t
+VpInit(BDIGIT BaseVal)
+{
+ /* Setup +/- Inf NaN -0 */
+ VpGetDoubleNaN();
+ VpGetDoublePosInf();
+ VpGetDoubleNegInf();
+ VpGetDoubleNegZero();
+
+ /* Allocates Vp constants. */
+ VpConstOne = VpAlloc(1UL, "1");
+ VpPt5 = VpAlloc(1UL, ".5");
+
+#ifdef BIGDECIMAL_DEBUG
+ gnAlloc = 0;
+#endif /* BIGDECIMAL_DEBUG */
+
+#ifdef BIGDECIMAL_DEBUG
+ if (gfDebug) {
+ printf("VpInit: BaseVal = %lu\n", BaseVal);
+ printf(" BASE = %lu\n", BASE);
+ printf(" HALF_BASE = %lu\n", HALF_BASE);
+ printf(" BASE1 = %lu\n", BASE1);
+ printf(" BASE_FIG = %u\n", BASE_FIG);
+ printf(" DBLE_FIG = %d\n", DBLE_FIG);
+ }
+#endif /* BIGDECIMAL_DEBUG */
+
+ return rmpd_double_figures();
+}
+
+VP_EXPORT Real *
+VpOne(void)
+{
+ return VpConstOne;
+}
+
+/* If exponent overflows,then raise exception or returns 0 */
+static int
+AddExponent(Real *a, SIGNED_VALUE n)
+{
+ SIGNED_VALUE e = a->exponent;
+ SIGNED_VALUE m = e+n;
+ SIGNED_VALUE eb, mb;
+ if (e > 0) {
+ if (n > 0) {
+ if (MUL_OVERFLOW_SIGNED_VALUE_P(m, (SIGNED_VALUE)BASE_FIG) ||
+ MUL_OVERFLOW_SIGNED_VALUE_P(e, (SIGNED_VALUE)BASE_FIG))
+ goto overflow;
+ mb = m*(SIGNED_VALUE)BASE_FIG;
+ eb = e*(SIGNED_VALUE)BASE_FIG;
+ if (mb < eb) goto overflow;
+ }
+ }
+ else if (n < 0) {
+ if (MUL_OVERFLOW_SIGNED_VALUE_P(m, (SIGNED_VALUE)BASE_FIG) ||
+ MUL_OVERFLOW_SIGNED_VALUE_P(e, (SIGNED_VALUE)BASE_FIG))
+ goto underflow;
+ mb = m*(SIGNED_VALUE)BASE_FIG;
+ eb = e*(SIGNED_VALUE)BASE_FIG;
+ if (mb > eb) goto underflow;
+ }
+ a->exponent = m;
+ return 1;
+
+/* Overflow/Underflow ==> Raise exception or returns 0 */
+underflow:
+ VpSetZero(a, VpGetSign(a));
+ return VpException(VP_EXCEPTION_UNDERFLOW, "Exponent underflow", 0);
+
+overflow:
+ VpSetInf(a, VpGetSign(a));
+ return VpException(VP_EXCEPTION_OVERFLOW, "Exponent overflow", 0);
+}
+
+/*
+ * Allocates variable.
+ * [Input]
+ * mx ... allocation unit, if zero then mx is determined by szVal.
+ * The mx is the number of effective digits can to be stored.
+ * szVal ... value assigned(char). If szVal==NULL,then zero is assumed.
+ * If szVal[0]=='#' then Max. Prec. will not be considered(1.1.7),
+ * full precision specified by szVal is allocated.
+ *
+ * [Returns]
+ * Pointer to the newly allocated variable, or
+ * NULL be returned if memory allocation is failed,or any error.
+ */
+VP_EXPORT Real *
+VpAlloc(size_t mx, const char *szVal)
+{
+ size_t i, ni, ipn, ipf, nf, ipe, ne, nalloc;
+ char v, *psz;
+ int sign=1;
+ Real *vp = NULL;
+ size_t mf = VpGetPrecLimit();
+ VALUE buf;
+
+ mx = (mx + BASE_FIG - 1) / BASE_FIG; /* Determine allocation unit. */
+ if (mx == 0) ++mx;
+
+ if (szVal) {
+ while (ISSPACE(*szVal)) szVal++;
+ if (*szVal != '#') {
+ if (mf) {
+ mf = (mf + BASE_FIG - 1) / BASE_FIG + 2; /* Needs 1 more for div */
+ if (mx > mf) {
+ mx = mf;
+ }
+ }
+ }
+ else {
+ ++szVal;
+ }
+ }
+ else {
+ /* necessary to be able to store */
+ /* at least mx digits. */
+ /* szVal==NULL ==> allocate zero value. */
+ vp = VpAllocReal(mx);
+ /* xmalloc() alway returns(or throw interruption) */
+ vp->MaxPrec = mx; /* set max precision */
+ VpSetZero(vp, 1); /* initialize vp to zero. */
+ return vp;
+ }
+
+ /* Skip all '_' after digit: 2006-6-30 */
+ ni = 0;
+ buf = rb_str_tmp_new(strlen(szVal) + 1);
+ psz = RSTRING_PTR(buf);
+ i = 0;
+ ipn = 0;
+ while ((psz[i] = szVal[ipn]) != 0) {
+ if (ISDIGIT(psz[i])) ++ni;
+ if (psz[i] == '_') {
+ if (ni > 0) {
+ ipn++;
+ continue;
+ }
+ psz[i] = 0;
+ break;
+ }
+ ++i;
+ ++ipn;
+ }
+ /* Skip trailing spaces */
+ while (--i > 0) {
+ if (ISSPACE(psz[i])) psz[i] = 0;
+ else break;
+ }
+ szVal = psz;
+
+ /* Check on Inf & NaN */
+ if (StrCmp(szVal, SZ_PINF) == 0 || StrCmp(szVal, SZ_INF) == 0 ) {
+ vp = VpAllocReal(1);
+ vp->MaxPrec = 1; /* set max precision */
+ VpSetPosInf(vp);
+ return vp;
+ }
+ if (StrCmp(szVal, SZ_NINF) == 0) {
+ vp = VpAllocReal(1);
+ vp->MaxPrec = 1; /* set max precision */
+ VpSetNegInf(vp);
+ return vp;
+ }
+ if (StrCmp(szVal, SZ_NaN) == 0) {
+ vp = VpAllocReal(1);
+ vp->MaxPrec = 1; /* set max precision */
+ VpSetNaN(vp);
+ return vp;
+ }
+
+ /* check on number szVal[] */
+ ipn = i = 0;
+ if (szVal[i] == '-') { sign=-1; ++i; }
+ else if (szVal[i] == '+') ++i;
+ /* Skip digits */
+ ni = 0; /* digits in mantissa */
+ while ((v = szVal[i]) != 0) {
+ if (!ISDIGIT(v)) break;
+ ++i;
+ ++ni;
+ }
+ nf = 0;
+ ipf = 0;
+ ipe = 0;
+ ne = 0;
+ if (v) {
+ /* other than digit nor \0 */
+ if (szVal[i] == '.') { /* xxx. */
+ ++i;
+ ipf = i;
+ while ((v = szVal[i]) != 0) { /* get fraction part. */
+ if (!ISDIGIT(v)) break;
+ ++i;
+ ++nf;
+ }
+ }
+ ipe = 0; /* Exponent */
+
+ switch (szVal[i]) {
+ case '\0':
+ break;
+ case 'e': case 'E':
+ case 'd': case 'D':
+ ++i;
+ ipe = i;
+ v = szVal[i];
+ if ((v == '-') || (v == '+')) ++i;
+ while ((v=szVal[i]) != 0) {
+ if (!ISDIGIT(v)) break;
+ ++i;
+ ++ne;
+ }
+ break;
+ default:
+ break;
+ }
+ }
+ nalloc = (ni + nf + BASE_FIG - 1) / BASE_FIG + 1; /* set effective allocation */
+ /* units for szVal[] */
+ if (mx == 0) mx = 1;
+ nalloc = Max(nalloc, mx);
+ mx = nalloc;
+ vp = VpAllocReal(mx);
+ /* xmalloc() alway returns(or throw interruption) */
+ vp->MaxPrec = mx; /* set max precision */
+ VpSetZero(vp, sign);
+ VpCtoV(vp, &szVal[ipn], ni, &szVal[ipf], nf, &szVal[ipe], ne);
+ rb_str_resize(buf, 0);
+ return vp;
+}
+
+/*
+ * Assignment(c=a).
+ * [Input]
+ * a ... RHSV
+ * isw ... switch for assignment.
+ * c = a when isw > 0
+ * c = -a when isw < 0
+ * if c->MaxPrec < a->Prec,then round operation
+ * will be performed.
+ * [Output]
+ * c ... LHSV
+ */
+VP_EXPORT size_t
+VpAsgn(Real *c, Real *a, int isw)
+{
+ size_t n;
+ if (VpIsNaN(a)) {
+ VpSetNaN(c);
+ return 0;
+ }
+ if (VpIsInf(a)) {
+ VpSetInf(c, isw * VpGetSign(a));
+ return 0;
+ }
+
+ /* check if the RHS is zero */
+ if (!VpIsZero(a)) {
+ c->exponent = a->exponent; /* store exponent */
+ VpSetSign(c, isw * VpGetSign(a)); /* set sign */
+ n = (a->Prec < c->MaxPrec) ? (a->Prec) : (c->MaxPrec);
+ c->Prec = n;
+ memcpy(c->frac, a->frac, n * sizeof(BDIGIT));
+ /* Needs round ? */
+ if (isw != 10) {
+ /* Not in ActiveRound */
+ if(c->Prec < a->Prec) {
+ VpInternalRound(c, n, (n>0) ? a->frac[n-1] : 0, a->frac[n]);
+ }
+ else {
+ VpLimitRound(c,0);
+ }
+ }
+ }
+ else {
+ /* The value of 'a' is zero. */
+ VpSetZero(c, isw * VpGetSign(a));
+ return 1;
+ }
+ return c->Prec * BASE_FIG;
+}
+
+/*
+ * c = a + b when operation = 1 or 2
+ * = a - b when operation = -1 or -2.
+ * Returns number of significant digits of c
+ */
+VP_EXPORT size_t
+VpAddSub(Real *c, Real *a, Real *b, int operation)
+{
+ short sw, isw;
+ Real *a_ptr, *b_ptr;
+ size_t n, na, nb, i;
+ BDIGIT mrv;
+
+#ifdef BIGDECIMAL_DEBUG
+ if (gfDebug) {
+ VPrint(stdout, "VpAddSub(enter) a=% \n", a);
+ VPrint(stdout, " b=% \n", b);
+ printf(" operation=%d\n", operation);
+ }
+#endif /* BIGDECIMAL_DEBUG */
+
+ if (!VpIsDefOP(c, a, b, (operation > 0) ? 1 : 2)) return 0; /* No significant digits */
+
+ /* check if a or b is zero */
+ if (VpIsZero(a)) {
+ /* a is zero,then assign b to c */
+ if (!VpIsZero(b)) {
+ VpAsgn(c, b, operation);
+ }
+ else {
+ /* Both a and b are zero. */
+ if (VpGetSign(a) < 0 && operation * VpGetSign(b) < 0) {
+ /* -0 -0 */
+ VpSetZero(c, -1);
+ }
+ else {
+ VpSetZero(c, 1);
+ }
+ return 1; /* 0: 1 significant digits */
+ }
+ return c->Prec * BASE_FIG;
+ }
+ if (VpIsZero(b)) {
+ /* b is zero,then assign a to c. */
+ VpAsgn(c, a, 1);
+ return c->Prec*BASE_FIG;
+ }
+
+ if (operation < 0) sw = -1;
+ else sw = 1;
+
+ /* compare absolute value. As a result,|a_ptr|>=|b_ptr| */
+ if (a->exponent > b->exponent) {
+ a_ptr = a;
+ b_ptr = b;
+ } /* |a|>|b| */
+ else if (a->exponent < b->exponent) {
+ a_ptr = b;
+ b_ptr = a;
+ } /* |a|<|b| */
+ else {
+ /* Exponent part of a and b is the same,then compare fraction */
+ /* part */
+ na = a->Prec;
+ nb = b->Prec;
+ n = Min(na, nb);
+ for (i=0; i < n; ++i) {
+ if (a->frac[i] > b->frac[i]) {
+ a_ptr = a;
+ b_ptr = b;
+ goto end_if;
+ }
+ else if (a->frac[i] < b->frac[i]) {
+ a_ptr = b;
+ b_ptr = a;
+ goto end_if;
+ }
+ }
+ if (na > nb) {
+ a_ptr = a;
+ b_ptr = b;
+ goto end_if;
+ }
+ else if (na < nb) {
+ a_ptr = b;
+ b_ptr = a;
+ goto end_if;
+ }
+ /* |a| == |b| */
+ if (VpGetSign(a) + sw *VpGetSign(b) == 0) {
+ VpSetZero(c, 1); /* abs(a)=abs(b) and operation = '-' */
+ return c->Prec * BASE_FIG;
+ }
+ a_ptr = a;
+ b_ptr = b;
+ }
+
+end_if:
+ isw = VpGetSign(a) + sw *VpGetSign(b);
+ /*
+ * isw = 0 ...( 1)+(-1),( 1)-( 1),(-1)+(1),(-1)-(-1)
+ * = 2 ...( 1)+( 1),( 1)-(-1)
+ * =-2 ...(-1)+(-1),(-1)-( 1)
+ * If isw==0, then c =(Sign a_ptr)(|a_ptr|-|b_ptr|)
+ * else c =(Sign ofisw)(|a_ptr|+|b_ptr|)
+ */
+ if (isw) { /* addition */
+ VpSetSign(c, 1);
+ mrv = VpAddAbs(a_ptr, b_ptr, c);
+ VpSetSign(c, isw / 2);
+ }
+ else { /* subtraction */
+ VpSetSign(c, 1);
+ mrv = VpSubAbs(a_ptr, b_ptr, c);
+ if (a_ptr == a) {
+ VpSetSign(c,VpGetSign(a));
+ }
+ else {
+ VpSetSign(c, VpGetSign(a_ptr) * sw);
+ }
+ }
+ VpInternalRound(c, 0, (c->Prec > 0) ? c->frac[c->Prec-1] : 0, mrv);
+
+#ifdef BIGDECIMAL_DEBUG
+ if (gfDebug) {
+ VPrint(stdout, "VpAddSub(result) c=% \n", c);
+ VPrint(stdout, " a=% \n", a);
+ VPrint(stdout, " b=% \n", b);
+ printf(" operation=%d\n", operation);
+ }
+#endif /* BIGDECIMAL_DEBUG */
+ return c->Prec * BASE_FIG;
+}
+
+/*
+ * Addition of two variable precisional variables
+ * a and b assuming abs(a)>abs(b).
+ * c = abs(a) + abs(b) ; where |a|>=|b|
+ */
+static BDIGIT
+VpAddAbs(Real *a, Real *b, Real *c)
+{
+ size_t word_shift;
+ size_t ap;
+ size_t bp;
+ size_t cp;
+ size_t a_pos;
+ size_t b_pos, b_pos_with_word_shift;
+ size_t c_pos;
+ BDIGIT av, bv, carry, mrv;
+
+#ifdef BIGDECIMAL_DEBUG
+ if (gfDebug) {
+ VPrint(stdout, "VpAddAbs called: a = %\n", a);
+ VPrint(stdout, " b = %\n", b);
+ }
+#endif /* BIGDECIMAL_DEBUG */
+
+ word_shift = VpSetPTR(a, b, c, &ap, &bp, &cp, &av, &bv);
+ a_pos = ap;
+ b_pos = bp;
+ c_pos = cp;
+
+ if (word_shift == (size_t)-1L) return 0; /* Overflow */
+ if (b_pos == (size_t)-1L) goto Assign_a;
+
+ mrv = av + bv; /* Most right val. Used for round. */
+
+ /* Just assign the last few digits of b to c because a has no */
+ /* corresponding digits to be added. */
+ if (b_pos > 0) {
+ while (b_pos > 0 && b_pos + word_shift > a_pos) {
+ c->frac[--c_pos] = b->frac[--b_pos];
+ }
+ }
+ if (b_pos == 0 && word_shift > a_pos) {
+ while (word_shift-- > a_pos) {
+ c->frac[--c_pos] = 0;
+ }
+ }
+
+ /* Just assign the last few digits of a to c because b has no */
+ /* corresponding digits to be added. */
+ b_pos_with_word_shift = b_pos + word_shift;
+ while (a_pos > b_pos_with_word_shift) {
+ c->frac[--c_pos] = a->frac[--a_pos];
+ }
+ carry = 0; /* set first carry be zero */
+
+ /* Now perform addition until every digits of b will be */
+ /* exhausted. */
+ while (b_pos > 0) {
+ c->frac[--c_pos] = a->frac[--a_pos] + b->frac[--b_pos] + carry;
+ if (c->frac[c_pos] >= BASE) {
+ c->frac[c_pos] -= BASE;
+ carry = 1;
+ }
+ else {
+ carry = 0;
+ }
+ }
+
+ /* Just assign the first few digits of a with considering */
+ /* the carry obtained so far because b has been exhausted. */
+ while (a_pos > 0) {
+ c->frac[--c_pos] = a->frac[--a_pos] + carry;
+ if (c->frac[c_pos] >= BASE) {
+ c->frac[c_pos] -= BASE;
+ carry = 1;
+ }
+ else {
+ carry = 0;
+ }
+ }
+ if (c_pos) c->frac[c_pos - 1] += carry;
+ goto Exit;
+
+Assign_a:
+ VpAsgn(c, a, 1);
+ mrv = 0;
+
+Exit:
+
+#ifdef BIGDECIMAL_DEBUG
+ if (gfDebug) {
+ VPrint(stdout, "VpAddAbs exit: c=% \n", c);
+ }
+#endif /* BIGDECIMAL_DEBUG */
+ return mrv;
+}
+
+/*
+ * c = abs(a) - abs(b)
+ */
+static BDIGIT
+VpSubAbs(Real *a, Real *b, Real *c)
+{
+ size_t word_shift;
+ size_t ap;
+ size_t bp;
+ size_t cp;
+ size_t a_pos;
+ size_t b_pos, b_pos_with_word_shift;
+ size_t c_pos;
+ BDIGIT av, bv, borrow, mrv;
+
+#ifdef BIGDECIMAL_DEBUG
+ if (gfDebug) {
+ VPrint(stdout, "VpSubAbs called: a = %\n", a);
+ VPrint(stdout, " b = %\n", b);
+ }
+#endif /* BIGDECIMAL_DEBUG */
+
+ word_shift = VpSetPTR(a, b, c, &ap, &bp, &cp, &av, &bv);
+ a_pos = ap;
+ b_pos = bp;
+ c_pos = cp;
+ if (word_shift == (size_t)-1L) return 0; /* Overflow */
+ if (b_pos == (size_t)-1L) goto Assign_a;
+
+ if (av >= bv) {
+ mrv = av - bv;
+ borrow = 0;
+ }
+ else {
+ mrv = 0;
+ borrow = 1;
+ }
+
+ /* Just assign the values which are the BASE subtracted by */
+ /* each of the last few digits of the b because the a has no */
+ /* corresponding digits to be subtracted. */
+ if (b_pos + word_shift > a_pos) {
+ while (b_pos > 0 && b_pos + word_shift > a_pos) {
+ c->frac[--c_pos] = BASE - b->frac[--b_pos] - borrow;
+ borrow = 1;
+ }
+ if (b_pos == 0) {
+ while (word_shift > a_pos) {
+ --word_shift;
+ c->frac[--c_pos] = BASE - borrow;
+ borrow = 1;
+ }
+ }
+ }
+ /* Just assign the last few digits of a to c because b has no */
+ /* corresponding digits to subtract. */
+
+ b_pos_with_word_shift = b_pos + word_shift;
+ while (a_pos > b_pos_with_word_shift) {
+ c->frac[--c_pos] = a->frac[--a_pos];
+ }
+
+ /* Now perform subtraction until every digits of b will be */
+ /* exhausted. */
+ while (b_pos > 0) {
+ --c_pos;
+ if (a->frac[--a_pos] < b->frac[--b_pos] + borrow) {
+ c->frac[c_pos] = BASE + a->frac[a_pos] - b->frac[b_pos] - borrow;
+ borrow = 1;
+ }
+ else {
+ c->frac[c_pos] = a->frac[a_pos] - b->frac[b_pos] - borrow;
+ borrow = 0;
+ }
+ }
+
+ /* Just assign the first few digits of a with considering */
+ /* the borrow obtained so far because b has been exhausted. */
+ while (a_pos > 0) {
+ --c_pos;
+ if (a->frac[--a_pos] < borrow) {
+ c->frac[c_pos] = BASE + a->frac[a_pos] - borrow;
+ borrow = 1;
+ }
+ else {
+ c->frac[c_pos] = a->frac[a_pos] - borrow;
+ borrow = 0;
+ }
+ }
+ if (c_pos) c->frac[c_pos - 1] -= borrow;
+ goto Exit;
+
+Assign_a:
+ VpAsgn(c, a, 1);
+ mrv = 0;
+
+Exit:
+#ifdef BIGDECIMAL_DEBUG
+ if (gfDebug) {
+ VPrint(stdout, "VpSubAbs exit: c=% \n", c);
+ }
+#endif /* BIGDECIMAL_DEBUG */
+ return mrv;
+}
+
+/*
+ * Note: If(av+bv)>= HALF_BASE,then 1 will be added to the least significant
+ * digit of c(In case of addition).
+ * ------------------------- figure of output -----------------------------------
+ * a = xxxxxxxxxxx
+ * b = xxxxxxxxxx
+ * c =xxxxxxxxxxxxxxx
+ * word_shift = | |
+ * right_word = | | (Total digits in RHSV)
+ * left_word = | | (Total digits in LHSV)
+ * a_pos = |
+ * b_pos = |
+ * c_pos = |
+ */
+static size_t
+VpSetPTR(Real *a, Real *b, Real *c, size_t *a_pos, size_t *b_pos, size_t *c_pos, BDIGIT *av, BDIGIT *bv)
+{
+ size_t left_word, right_word, word_shift;
+
+ size_t const round_limit = (VpGetPrecLimit() + BASE_FIG - 1) / BASE_FIG;
+
+ assert(a->exponent >= b->exponent);
+
+ c->frac[0] = 0;
+ *av = *bv = 0;
+
+ word_shift = (a->exponent - b->exponent);
+ left_word = b->Prec + word_shift;
+ right_word = Max(a->Prec, left_word);
+ left_word = c->MaxPrec - 1; /* -1 ... prepare for round up */
+
+ /*
+ * check if 'round' is needed.
+ */
+ if (right_word > left_word) { /* round ? */
+ /*---------------------------------
+ * Actual size of a = xxxxxxAxx
+ * Actual size of b = xxxBxxxxx
+ * Max. size of c = xxxxxx
+ * Round off = |-----|
+ * c_pos = |
+ * right_word = |
+ * a_pos = |
+ */
+ *c_pos = right_word = left_word + 1; /* Set resulting precision */
+ /* be equal to that of c */
+ if (a->Prec >= c->MaxPrec) {
+ /*
+ * a = xxxxxxAxxx
+ * c = xxxxxx
+ * a_pos = |
+ */
+ *a_pos = left_word;
+ if (*a_pos <= round_limit) {
+ *av = a->frac[*a_pos]; /* av is 'A' shown in above. */
+ }
+ }
+ else {
+ /*
+ * a = xxxxxxx
+ * c = xxxxxxxxxx
+ * a_pos = |
+ */
+ *a_pos = a->Prec;
+ }
+ if (b->Prec + word_shift >= c->MaxPrec) {
+ /*
+ * a = xxxxxxxxx
+ * b = xxxxxxxBxxx
+ * c = xxxxxxxxxxx
+ * b_pos = |
+ */
+ if (c->MaxPrec >= word_shift + 1) {
+ *b_pos = c->MaxPrec - word_shift - 1;
+ if (*b_pos + word_shift <= round_limit) {
+ *bv = b->frac[*b_pos];
+ }
+ }
+ else {
+ *b_pos = -1L;
+ }
+ }
+ else {
+ /*
+ * a = xxxxxxxxxxxxxxxx
+ * b = xxxxxx
+ * c = xxxxxxxxxxxxx
+ * b_pos = |
+ */
+ *b_pos = b->Prec;
+ }
+ }
+ else { /* The MaxPrec of c - 1 > The Prec of a + b */
+ /*
+ * a = xxxxxxx
+ * b = xxxxxx
+ * c = xxxxxxxxxxx
+ * c_pos = |
+ */
+ *b_pos = b->Prec;
+ *a_pos = a->Prec;
+ *c_pos = right_word + 1;
+ }
+ c->Prec = *c_pos;
+ c->exponent = a->exponent;
+ if (!AddExponent(c, 1)) return (size_t)-1L;
+ return word_shift;
+}
+
+/*
+ * Return number of significant digits
+ * c = a * b , Where a = a0a1a2 ... an
+ * b = b0b1b2 ... bm
+ * c = c0c1c2 ... cl
+ * a0 a1 ... an * bm
+ * a0 a1 ... an * bm-1
+ * . . .
+ * . . .
+ * a0 a1 .... an * b0
+ * +_____________________________
+ * c0 c1 c2 ...... cl
+ * nc <---|
+ * MaxAB |--------------------|
+ */
+VP_EXPORT size_t
+VpMult(Real *c, Real *a, Real *b)
+{
+ size_t MxIndA, MxIndB, MxIndAB, MxIndC;
+ size_t ind_c, i, ii, nc;
+ size_t ind_as, ind_ae, ind_bs;
+ BDIGIT carry;
+ BDIGIT_DBL s;
+ Real *w;
+
+#ifdef BIGDECIMAL_DEBUG
+ if (gfDebug) {
+ VPrint(stdout, "VpMult(Enter): a=% \n", a);
+ VPrint(stdout, " b=% \n", b);
+ }
+#endif /* BIGDECIMAL_DEBUG */
+
+ if (!VpIsDefOP(c, a, b, 3)) return 0; /* No significant digit */
+
+ if (VpIsZero(a) || VpIsZero(b)) {
+ /* at least a or b is zero */
+ VpSetZero(c, VpGetSign(a) * VpGetSign(b));
+ return 1; /* 0: 1 significant digit */
+ }
+
+ if (VpIsOne(a)) {
+ VpAsgn(c, b, VpGetSign(a));
+ goto Exit;
+ }
+ if (VpIsOne(b)) {
+ VpAsgn(c, a, VpGetSign(b));
+ goto Exit;
+ }
+ if (b->Prec > a->Prec) {
+ /* Adjust so that digits(a)>digits(b) */
+ w = a;
+ a = b;
+ b = w;
+ }
+ w = NULL;
+ MxIndA = a->Prec - 1;
+ MxIndB = b->Prec - 1;
+ MxIndC = c->MaxPrec - 1;
+ MxIndAB = a->Prec + b->Prec - 1;
+
+ if (MxIndC < MxIndAB) { /* The Max. prec. of c < Prec(a)+Prec(b) */
+ w = c;
+ c = VpAlloc((size_t)((MxIndAB + 1) * BASE_FIG), "#0");
+ MxIndC = MxIndAB;
+ }
+
+ /* set LHSV c info */
+
+ c->exponent = a->exponent; /* set exponent */
+ if (!AddExponent(c, b->exponent)) {
+ if (w) VpFree(c);
+ return 0;
+ }
+ VpSetSign(c, VpGetSign(a) * VpGetSign(b)); /* set sign */
+ carry = 0;
+ nc = ind_c = MxIndAB;
+ memset(c->frac, 0, (nc + 1) * sizeof(BDIGIT)); /* Initialize c */
+ c->Prec = nc + 1; /* set precision */
+ for (nc = 0; nc < MxIndAB; ++nc, --ind_c) {
+ if (nc < MxIndB) { /* The left triangle of the Fig. */
+ ind_as = MxIndA - nc;
+ ind_ae = MxIndA;
+ ind_bs = MxIndB;
+ }
+ else if (nc <= MxIndA) { /* The middle rectangular of the Fig. */
+ ind_as = MxIndA - nc;
+ ind_ae = MxIndA - (nc - MxIndB);
+ ind_bs = MxIndB;
+ }
+ else /* if (nc > MxIndA) */ { /* The right triangle of the Fig. */
+ ind_as = 0;
+ ind_ae = MxIndAB - nc - 1;
+ ind_bs = MxIndB - (nc - MxIndA);
+ }
+
+ for (i = ind_as; i <= ind_ae; ++i) {
+ s = (BDIGIT_DBL)a->frac[i] * b->frac[ind_bs--];
+ carry = (BDIGIT)(s / BASE);
+ s -= (BDIGIT_DBL)carry * BASE;
+ c->frac[ind_c] += (BDIGIT)s;
+ if (c->frac[ind_c] >= BASE) {
+ s = c->frac[ind_c] / BASE;
+ carry += (BDIGIT)s;
+ c->frac[ind_c] -= (BDIGIT)(s * BASE);
+ }
+ if (carry) {
+ ii = ind_c;
+ while (ii-- > 0) {
+ c->frac[ii] += carry;
+ if (c->frac[ii] >= BASE) {
+ carry = c->frac[ii] / BASE;
+ c->frac[ii] -= (carry * BASE);
+ }
+ else {
+ break;
+ }
+ }
+ }
+ }
+ }
+ if (w != NULL) { /* free work variable */
+ VpNmlz(c);
+ VpAsgn(w, c, 1);
+ VpFree(c);
+ c = w;
+ }
+ else {
+ VpLimitRound(c,0);
+ }
+
+Exit:
+#ifdef BIGDECIMAL_DEBUG
+ if (gfDebug) {
+ VPrint(stdout, "VpMult(c=a*b): c=% \n", c);
+ VPrint(stdout, " a=% \n", a);
+ VPrint(stdout, " b=% \n", b);
+ }
+#endif /*BIGDECIMAL_DEBUG */
+ return c->Prec*BASE_FIG;
+}
+
+/*
+ * c = a / b, remainder = r
+ */
+ VP_EXPORT size_t
+VpDivd(Real *c, Real *r, Real *a, Real *b)
+{
+ size_t word_a, word_b, word_c, word_r;
+ size_t i, n, ind_a, ind_b, ind_c, ind_r;
+ size_t nLoop;
+ BDIGIT_DBL q, b1, b1p1, b1b2, b1b2p1, r1r2;
+ BDIGIT borrow, borrow1, borrow2;
+ BDIGIT_DBL qb;
+
+#ifdef BIGDECIMAL_DEBUG
+ if (gfDebug) {
+ VPrint(stdout, " VpDivd(c=a/b) a=% \n", a);
+ VPrint(stdout, " b=% \n", b);
+ }
+#endif /*BIGDECIMAL_DEBUG */
+
+ VpSetNaN(r);
+ if (!VpIsDefOP(c, a, b, 4)) goto Exit;
+ if (VpIsZero(a) && VpIsZero(b)) {
+ VpSetNaN(c);
+ return VpException(VP_EXCEPTION_NaN, "(VpDivd) 0/0 not defined(NaN)", 0);
+ }
+ if (VpIsZero(b)) {
+ VpSetInf(c, VpGetSign(a) * VpGetSign(b));
+ return VpException(VP_EXCEPTION_ZERODIVIDE, "(VpDivd) Divide by zero", 0);
+ }
+ if (VpIsZero(a)) {
+ /* numerator a is zero */
+ VpSetZero(c, VpGetSign(a) * VpGetSign(b));
+ VpSetZero(r, VpGetSign(a) * VpGetSign(b));
+ goto Exit;
+ }
+ if (VpIsOne(b)) {
+ /* divide by one */
+ VpAsgn(c, a, VpGetSign(b));
+ VpSetZero(r, VpGetSign(a));
+ goto Exit;
+ }
+
+ word_a = a->Prec;
+ word_b = b->Prec;
+ word_c = c->MaxPrec;
+ word_r = r->MaxPrec;
+
+ ind_c = 0;
+ ind_r = 1;
+
+ if (word_a >= word_r) goto space_error;
+
+ r->frac[0] = 0;
+ while (ind_r <= word_a) {
+ r->frac[ind_r] = a->frac[ind_r - 1];
+ ++ind_r;
+ }
+
+ while (ind_r < word_r) r->frac[ind_r++] = 0;
+ while (ind_c < word_c) c->frac[ind_c++] = 0;
+
+ /* initial procedure */
+ b1 = b1p1 = b->frac[0];
+ if (b->Prec <= 1) {
+ b1b2p1 = b1b2 = b1p1 * BASE;
+ }
+ else {
+ b1p1 = b1 + 1;
+ b1b2p1 = b1b2 = b1 * BASE + b->frac[1];
+ if (b->Prec > 2) ++b1b2p1;
+ }
+
+ /* */
+ /* loop start */
+ ind_c = word_r - 1;
+ nLoop = Min(word_c,ind_c);
+ ind_c = 1;
+ while (ind_c < nLoop) {
+ if (r->frac[ind_c] == 0) {
+ ++ind_c;
+ continue;
+ }
+ r1r2 = (BDIGIT_DBL)r->frac[ind_c] * BASE + r->frac[ind_c + 1];
+ if (r1r2 == b1b2) {
+ /* The first two word digits is the same */
+ ind_b = 2;
+ ind_a = ind_c + 2;
+ while (ind_b < word_b) {
+ if (r->frac[ind_a] < b->frac[ind_b]) goto div_b1p1;
+ if (r->frac[ind_a] > b->frac[ind_b]) break;
+ ++ind_a;
+ ++ind_b;
+ }
+ /* The first few word digits of r and b is the same and */
+ /* the first different word digit of w is greater than that */
+ /* of b, so quotient is 1 and just subtract b from r. */
+ borrow = 0; /* quotient=1, then just r-b */
+ ind_b = b->Prec - 1;
+ ind_r = ind_c + ind_b;
+ if (ind_r >= word_r) goto space_error;
+ n = ind_b;
+ for (i = 0; i <= n; ++i) {
+ if (r->frac[ind_r] < b->frac[ind_b] + borrow) {
+ r->frac[ind_r] += (BASE - (b->frac[ind_b] + borrow));
+ borrow = 1;
+ }
+ else {
+ r->frac[ind_r] = r->frac[ind_r] - b->frac[ind_b] - borrow;
+ borrow = 0;
+ }
+ --ind_r;
+ --ind_b;
+ }
+ ++c->frac[ind_c];
+ goto carry;
+ }
+ /* The first two word digits is not the same, */
+ /* then compare magnitude, and divide actually. */
+ if (r1r2 >= b1b2p1) {
+ q = r1r2 / b1b2p1; /* q == (BDIGIT)q */
+ c->frac[ind_c] += (BDIGIT)q;
+ ind_r = b->Prec + ind_c - 1;
+ goto sub_mult;
+ }
+
+div_b1p1:
+ if (ind_c + 1 >= word_c) goto out_side;
+ q = r1r2 / b1p1; /* q == (BDIGIT)q */
+ c->frac[ind_c + 1] += (BDIGIT)q;
+ ind_r = b->Prec + ind_c;
+
+sub_mult:
+ borrow1 = borrow2 = 0;
+ ind_b = word_b - 1;
+ if (ind_r >= word_r) goto space_error;
+ n = ind_b;
+ for (i = 0; i <= n; ++i) {
+ /* now, perform r = r - q * b */
+ qb = q * b->frac[ind_b];
+ if (qb < BASE) borrow1 = 0;
+ else {
+ borrow1 = (BDIGIT)(qb / BASE);
+ qb -= (BDIGIT_DBL)borrow1 * BASE; /* get qb < BASE */
+ }
+ if(r->frac[ind_r] < qb) {
+ r->frac[ind_r] += (BDIGIT)(BASE - qb);
+ borrow2 = borrow2 + borrow1 + 1;
+ }
+ else {
+ r->frac[ind_r] -= (BDIGIT)qb;
+ borrow2 += borrow1;
+ }
+ if (borrow2) {
+ if(r->frac[ind_r - 1] < borrow2) {
+ r->frac[ind_r - 1] += (BASE - borrow2);
+ borrow2 = 1;
+ }
+ else {
+ r->frac[ind_r - 1] -= borrow2;
+ borrow2 = 0;
+ }
+ }
+ --ind_r;
+ --ind_b;
+ }
+
+ r->frac[ind_r] -= borrow2;
+carry:
+ ind_r = ind_c;
+ while (c->frac[ind_r] >= BASE) {
+ c->frac[ind_r] -= BASE;
+ --ind_r;
+ ++c->frac[ind_r];
+ }
+ }
+ /* End of operation, now final arrangement */
+out_side:
+ c->Prec = word_c;
+ c->exponent = a->exponent;
+ if (!AddExponent(c, 2)) return 0;
+ if (!AddExponent(c, -(b->exponent))) return 0;
+
+ VpSetSign(c, VpGetSign(a) * VpGetSign(b));
+ VpNmlz(c); /* normalize c */
+ r->Prec = word_r;
+ r->exponent = a->exponent;
+ if (!AddExponent(r, 1)) return 0;
+ VpSetSign(r, VpGetSign(a));
+ VpNmlz(r); /* normalize r(remainder) */
+ goto Exit;
+
+space_error:
+#ifdef BIGDECIMAL_DEBUG
+ if (gfDebug) {
+ printf(" word_a=%lu\n", word_a);
+ printf(" word_b=%lu\n", word_b);
+ printf(" word_c=%lu\n", word_c);
+ printf(" word_r=%lu\n", word_r);
+ printf(" ind_r =%lu\n", ind_r);
+ }
+#endif /* BIGDECIMAL_DEBUG */
+ rb_bug("ERROR(VpDivd): space for remainder too small.");
+
+Exit:
+#ifdef BIGDECIMAL_DEBUG
+ if (gfDebug) {
+ VPrint(stdout, " VpDivd(c=a/b), c=% \n", c);
+ VPrint(stdout, " r=% \n", r);
+ }
+#endif /* BIGDECIMAL_DEBUG */
+ return c->Prec * BASE_FIG;
+}
+
+/*
+ * Input a = 00000xxxxxxxx En(5 preceding zeros)
+ * Output a = xxxxxxxx En-5
+ */
+static int
+VpNmlz(Real *a)
+{
+ size_t ind_a, i;
+
+ if (!VpIsDef(a)) goto NoVal;
+ if (VpIsZero(a)) goto NoVal;
+
+ ind_a = a->Prec;
+ while (ind_a--) {
+ if (a->frac[ind_a]) {
+ a->Prec = ind_a + 1;
+ i = 0;
+ while (a->frac[i] == 0) ++i; /* skip the first few zeros */
+ if (i) {
+ a->Prec -= i;
+ if (!AddExponent(a, -(SIGNED_VALUE)i)) return 0;
+ memmove(&a->frac[0], &a->frac[i], a->Prec*sizeof(BDIGIT));
+ }
+ return 1;
+ }
+ }
+ /* a is zero(no non-zero digit) */
+ VpSetZero(a, VpGetSign(a));
+ return 0;
+
+NoVal:
+ a->frac[0] = 0;
+ a->Prec = 1;
+ return 0;
+}
+
+/*
+ * VpComp = 0 ... if a=b,
+ * Pos ... a>b,
+ * Neg ... a<b.
+ * 999 ... result undefined(NaN)
+ */
+VP_EXPORT int
+VpComp(Real *a, Real *b)
+{
+ int val;
+ size_t mx, ind;
+ int e;
+ val = 0;
+ if (VpIsNaN(a) || VpIsNaN(b)) return 999;
+ if (!VpIsDef(a)) {
+ if (!VpIsDef(b)) e = a->sign - b->sign;
+ else e = a->sign;
+
+ if (e > 0) return 1;
+ else if (e < 0) return -1;
+ else return 0;
+ }
+ if (!VpIsDef(b)) {
+ e = -b->sign;
+ if (e > 0) return 1;
+ else return -1;
+ }
+ /* Zero check */
+ if (VpIsZero(a)) {
+ if (VpIsZero(b)) return 0; /* both zero */
+ val = -VpGetSign(b);
+ goto Exit;
+ }
+ if (VpIsZero(b)) {
+ val = VpGetSign(a);
+ goto Exit;
+ }
+
+ /* compare sign */
+ if (VpGetSign(a) > VpGetSign(b)) {
+ val = 1; /* a>b */
+ goto Exit;
+ }
+ if (VpGetSign(a) < VpGetSign(b)) {
+ val = -1; /* a<b */
+ goto Exit;
+ }
+
+ /* a and b have same sign, && sign!=0,then compare exponent */
+ if (a->exponent > b->exponent) {
+ val = VpGetSign(a);
+ goto Exit;
+ }
+ if (a->exponent < b->exponent) {
+ val = -VpGetSign(b);
+ goto Exit;
+ }
+
+ /* a and b have same exponent, then compare significand. */
+ mx = (a->Prec < b->Prec) ? a->Prec : b->Prec;
+ ind = 0;
+ while (ind < mx) {
+ if (a->frac[ind] > b->frac[ind]) {
+ val = VpGetSign(a);
+ goto Exit;
+ }
+ if (a->frac[ind] < b->frac[ind]) {
+ val = -VpGetSign(b);
+ goto Exit;
+ }
+ ++ind;
+ }
+ if (a->Prec > b->Prec) {
+ val = VpGetSign(a);
+ }
+ else if (a->Prec < b->Prec) {
+ val = -VpGetSign(b);
+ }
+
+Exit:
+ if (val > 1) val = 1;
+ else if (val < -1) val = -1;
+
+#ifdef BIGDECIMAL_DEBUG
+ if (gfDebug) {
+ VPrint(stdout, " VpComp a=%\n", a);
+ VPrint(stdout, " b=%\n", b);
+ printf(" ans=%d\n", val);
+ }
+#endif /* BIGDECIMAL_DEBUG */
+ return (int)val;
+}
+
+/*
+ * cntl_chr ... ASCIIZ Character, print control characters
+ * Available control codes:
+ * % ... VP variable. To print '%', use '%%'.
+ * \n ... new line
+ * \b ... backspace
+ * ... tab
+ * Note: % must must not appear more than once
+ * a ... VP variable to be printed
+ */
+#ifdef BIGDECIMAL_ENABLE_VPRINT
+static int
+VPrint(FILE *fp, const char *cntl_chr, Real *a)
+{
+ size_t i, j, nc, nd, ZeroSup, sep = 10;
+ BDIGIT m, e, nn;
+
+ /* Check if NaN & Inf. */
+ if (VpIsNaN(a)) {
+ fprintf(fp, SZ_NaN);
+ return 8;
+ }
+ if (VpIsPosInf(a)) {
+ fprintf(fp, SZ_INF);
+ return 8;
+ }
+ if (VpIsNegInf(a)) {
+ fprintf(fp, SZ_NINF);
+ return 9;
+ }
+ if (VpIsZero(a)) {
+ fprintf(fp, "0.0");
+ return 3;
+ }
+
+ j = 0;
+ nd = nc = 0; /* nd : number of digits in fraction part(every 10 digits, */
+ /* nd<=10). */
+ /* nc : number of characters printed */
+ ZeroSup = 1; /* Flag not to print the leading zeros as 0.00xxxxEnn */
+ while (*(cntl_chr + j)) {
+ if (*(cntl_chr + j) == '%' && *(cntl_chr + j + 1) != '%') {
+ nc = 0;
+ if (!VpIsZero(a)) {
+ if (VpGetSign(a) < 0) {
+ fprintf(fp, "-");
+ ++nc;
+ }
+ nc += fprintf(fp, "0.");
+ switch (*(cntl_chr + j + 1)) {
+ default:
+ break;
+
+ case '0': case 'z':
+ ZeroSup = 0;
+ ++j;
+ sep = cntl_chr[j] == 'z' ? RMPD_COMPONENT_FIGURES : 10;
+ break;
+ }
+ for (i = 0; i < a->Prec; ++i) {
+ m = BASE1;
+ e = a->frac[i];
+ while (m) {
+ nn = e / m;
+ if (!ZeroSup || nn) {
+ nc += fprintf(fp, "%lu", (unsigned long)nn); /* The leading zero(s) */
+ /* as 0.00xx will not */
+ /* be printed. */
+ ++nd;
+ ZeroSup = 0; /* Set to print succeeding zeros */
+ }
+ if (nd >= sep) { /* print ' ' after every 10 digits */
+ nd = 0;
+ nc += fprintf(fp, " ");
+ }
+ e = e - nn * m;
+ m /= 10;
+ }
+ }
+ nc += fprintf(fp, "E%"PRIdSIZE, VpExponent10(a));
+ nc += fprintf(fp, " (%"PRIdVALUE", %lu, %lu)", a->exponent, a->Prec, a->MaxPrec);
+ }
+ else {
+ nc += fprintf(fp, "0.0");
+ }
+ }
+ else {
+ ++nc;
+ if (*(cntl_chr + j) == '\\') {
+ switch (*(cntl_chr + j + 1)) {
+ case 'n':
+ fprintf(fp, "\n");
+ ++j;
+ break;
+ case 't':
+ fprintf(fp, "\t");
+ ++j;
+ break;
+ case 'b':
+ fprintf(fp, "\n");
+ ++j;
+ break;
+ default:
+ fprintf(fp, "%c", *(cntl_chr + j));
+ break;
+ }
+ }
+ else {
+ fprintf(fp, "%c", *(cntl_chr + j));
+ if (*(cntl_chr + j) == '%') ++j;
+ }
+ }
+ j++;
+ }
+
+ return (int)nc;
+}
+#endif
+
+static void
+VpFormatSt(char *psz, size_t fFmt)
+{
+ size_t ie, i, nf = 0;
+ char ch;
+
+ if (fFmt == 0) return;
+
+ ie = strlen(psz);
+ for (i = 0; i < ie; ++i) {
+ ch = psz[i];
+ if (!ch) break;
+ if (ISSPACE(ch) || ch=='-' || ch=='+') continue;
+ if (ch == '.') { nf = 0; continue; }
+ if (ch == 'E') break;
+
+ if (++nf > fFmt) {
+ memmove(psz + i + 1, psz + i, ie - i + 1);
+ ++ie;
+ nf = 0;
+ psz[i] = ' ';
+ }
+ }
+}
+
+VP_EXPORT ssize_t
+VpExponent10(Real *a)
+{
+ ssize_t ex;
+ size_t n;
+
+ if (!VpHasVal(a)) return 0;
+
+ ex = a->exponent * (ssize_t)BASE_FIG;
+ n = BASE1;
+ while ((a->frac[0] / n) == 0) {
+ --ex;
+ n /= 10;
+ }
+ return ex;
+}
+
+VP_EXPORT void
+VpSzMantissa(Real *a,char *psz)
+{
+ size_t i, n, ZeroSup;
+ BDIGIT_DBL m, e, nn;
+
+ if (VpIsNaN(a)) {
+ sprintf(psz, SZ_NaN);
+ return;
+ }
+ if (VpIsPosInf(a)) {
+ sprintf(psz, SZ_INF);
+ return;
+ }
+ if (VpIsNegInf(a)) {
+ sprintf(psz, SZ_NINF);
+ return;
+ }
+
+ ZeroSup = 1; /* Flag not to print the leading zeros as 0.00xxxxEnn */
+ if (!VpIsZero(a)) {
+ if (VpGetSign(a) < 0) *psz++ = '-';
+ n = a->Prec;
+ for (i = 0; i < n; ++i) {
+ m = BASE1;
+ e = a->frac[i];
+ while (m) {
+ nn = e / m;
+ if (!ZeroSup || nn) {
+ sprintf(psz, "%lu", (unsigned long)nn); /* The leading zero(s) */
+ psz += strlen(psz);
+ /* as 0.00xx will be ignored. */
+ ZeroSup = 0; /* Set to print succeeding zeros */
+ }
+ e = e - nn * m;
+ m /= 10;
+ }
+ }
+ *psz = 0;
+ while (psz[-1] == '0') *(--psz) = 0;
+ }
+ else {
+ if (VpIsPosZero(a)) sprintf(psz, "0");
+ else sprintf(psz, "-0");
+ }
+}
+
+VP_EXPORT int
+VpToSpecialString(Real *a,char *psz,int fPlus)
+ /* fPlus =0:default, =1: set ' ' before digits , =2: set '+' before digits. */
+{
+ if (VpIsNaN(a)) {
+ sprintf(psz,SZ_NaN);
+ return 1;
+ }
+
+ if (VpIsPosInf(a)) {
+ if (fPlus == 1) {
+ *psz++ = ' ';
+ }
+ else if (fPlus == 2) {
+ *psz++ = '+';
+ }
+ sprintf(psz, SZ_INF);
+ return 1;
+ }
+ if (VpIsNegInf(a)) {
+ sprintf(psz, SZ_NINF);
+ return 1;
+ }
+ if (VpIsZero(a)) {
+ if (VpIsPosZero(a)) {
+ if (fPlus == 1) sprintf(psz, " 0.0");
+ else if (fPlus == 2) sprintf(psz, "+0.0");
+ else sprintf(psz, "0.0");
+ }
+ else sprintf(psz, "-0.0");
+ return 1;
+ }
+ return 0;
+}
+
+VP_EXPORT void
+VpToString(Real *a, char *psz, size_t fFmt, int fPlus)
+/* fPlus =0:default, =1: set ' ' before digits , =2:set '+' before digits. */
+{
+ size_t i, n, ZeroSup;
+ BDIGIT shift, m, e, nn;
+ char *pszSav = psz;
+ ssize_t ex;
+
+ if (VpToSpecialString(a, psz, fPlus)) return;
+
+ ZeroSup = 1; /* Flag not to print the leading zeros as 0.00xxxxEnn */
+
+ if (VpGetSign(a) < 0) *psz++ = '-';
+ else if (fPlus == 1) *psz++ = ' ';
+ else if (fPlus == 2) *psz++ = '+';
+
+ *psz++ = '0';
+ *psz++ = '.';
+ n = a->Prec;
+ for (i = 0; i < n; ++i) {
+ m = BASE1;
+ e = a->frac[i];
+ while (m) {
+ nn = e / m;
+ if (!ZeroSup || nn) {
+ sprintf(psz, "%lu", (unsigned long)nn); /* The reading zero(s) */
+ psz += strlen(psz);
+ /* as 0.00xx will be ignored. */
+ ZeroSup = 0; /* Set to print succeeding zeros */
+ }
+ e = e - nn * m;
+ m /= 10;
+ }
+ }
+ ex = a->exponent * (ssize_t)BASE_FIG;
+ shift = BASE1;
+ while (a->frac[0] / shift == 0) {
+ --ex;
+ shift /= 10;
+ }
+ while (psz[-1] == '0') {
+ *(--psz) = 0;
+ }
+ sprintf(psz, "E%"PRIdSIZE, ex);
+ if (fFmt) VpFormatSt(pszSav, fFmt);
+}
+
+VP_EXPORT void
+VpToFString(Real *a, char *psz, size_t fFmt, int fPlus)
+/* fPlus =0:default,=1: set ' ' before digits ,set '+' before digits. */
+{
+ size_t i, n;
+ BDIGIT m, e, nn;
+ char *pszSav = psz;
+ ssize_t ex;
+
+ if (VpToSpecialString(a, psz, fPlus)) return;
+
+ if (VpGetSign(a) < 0) *psz++ = '-';
+ else if (fPlus == 1) *psz++ = ' ';
+ else if (fPlus == 2) *psz++ = '+';
+
+ n = a->Prec;
+ ex = a->exponent;
+ if (ex <= 0) {
+ *psz++ = '0';*psz++ = '.';
+ while (ex < 0) {
+ for (i=0; i < BASE_FIG; ++i) *psz++ = '0';
+ ++ex;
+ }
+ ex = -1;
+ }
+
+ for (i = 0; i < n; ++i) {
+ --ex;
+ if (i == 0 && ex >= 0) {
+ sprintf(psz, "%lu", (unsigned long)a->frac[i]);
+ psz += strlen(psz);
+ }
+ else {
+ m = BASE1;
+ e = a->frac[i];
+ while (m) {
+ nn = e / m;
+ *psz++ = (char)(nn + '0');
+ e = e - nn * m;
+ m /= 10;
+ }
+ }
+ if (ex == 0) *psz++ = '.';
+ }
+ while (--ex>=0) {
+ m = BASE;
+ while (m /= 10) *psz++ = '0';
+ if (ex == 0) *psz++ = '.';
+ }
+ *psz = 0;
+ while (psz[-1] == '0') *(--psz) = 0;
+ if (psz[-1] == '.') sprintf(psz, "0");
+ if (fFmt) VpFormatSt(pszSav, fFmt);
+}
+
+/*
+ * [Output]
+ * a[] ... variable to be assigned the value.
+ * [Input]
+ * int_chr[] ... integer part(may include '+/-').
+ * ni ... number of characters in int_chr[],not including '+/-'.
+ * frac[] ... fraction part.
+ * nf ... number of characters in frac[].
+ * exp_chr[] ... exponent part(including '+/-').
+ * ne ... number of characters in exp_chr[],not including '+/-'.
+ */
+VP_EXPORT int
+VpCtoV(Real *a, const char *int_chr, size_t ni, const char *frac, size_t nf, const char *exp_chr, size_t ne)
+{
+ size_t i, j, ind_a, ma, mi, me;
+ SIGNED_VALUE e, es, eb, ef;
+ int sign, signe, exponent_overflow;
+
+ /* get exponent part */
+ e = 0;
+ ma = a->MaxPrec;
+ mi = ni;
+ me = ne;
+ signe = 1;
+ exponent_overflow = 0;
+ memset(a->frac, 0, ma * sizeof(BDIGIT));
+ if (ne > 0) {
+ i = 0;
+ if (exp_chr[0] == '-') {
+ signe = -1;
+ ++i;
+ ++me;
+ }
+ else if (exp_chr[0] == '+') {
+ ++i;
+ ++me;
+ }
+ while (i < me) {
+ if (MUL_OVERFLOW_SIGNED_VALUE_P(e, (SIGNED_VALUE)BASE_FIG)) {
+ es = e;
+ goto exp_overflow;
+ }
+ es = e * (SIGNED_VALUE)BASE_FIG;
+ if (MUL_OVERFLOW_SIGNED_VALUE_P(e, 10) ||
+ SIGNED_VALUE_MAX - (exp_chr[i] - '0') < e * 10)
+ goto exp_overflow;
+ e = e * 10 + exp_chr[i] - '0';
+ if (MUL_OVERFLOW_SIGNED_VALUE_P(e, (SIGNED_VALUE)BASE_FIG))
+ goto exp_overflow;
+ if (es > (SIGNED_VALUE)(e * BASE_FIG)) {
+ exp_overflow:
+ exponent_overflow = 1;
+ e = es; /* keep sign */
+ break;
+ }
+ ++i;
+ }
+ }
+
+ /* get integer part */
+ i = 0;
+ sign = 1;
+ if (1 /*ni >= 0*/) {
+ if (int_chr[0] == '-') {
+ sign = -1;
+ ++i;
+ ++mi;
+ }
+ else if (int_chr[0] == '+') {
+ ++i;
+ ++mi;
+ }
+ }
+
+ e = signe * e; /* e: The value of exponent part. */
+ e = e + ni; /* set actual exponent size. */
+
+ if (e > 0) signe = 1;
+ else signe = -1;
+
+ /* Adjust the exponent so that it is the multiple of BASE_FIG. */
+ j = 0;
+ ef = 1;
+ while (ef) {
+ if (e >= 0) eb = e;
+ else eb = -e;
+ ef = eb / (SIGNED_VALUE)BASE_FIG;
+ ef = eb - ef * (SIGNED_VALUE)BASE_FIG;
+ if (ef) {
+ ++j; /* Means to add one more preceding zero */
+ ++e;
+ }
+ }
+
+ eb = e / (SIGNED_VALUE)BASE_FIG;
+
+ if (exponent_overflow) {
+ int zero = 1;
+ for ( ; i < mi && zero; i++) zero = int_chr[i] == '0';
+ for (i = 0; i < nf && zero; i++) zero = frac[i] == '0';
+ if (!zero && signe > 0) {
+ VpSetInf(a, sign);
+ VpException(VP_EXCEPTION_INFINITY, "exponent overflow",0);
+ }
+ else VpSetZero(a, sign);
+ return 1;
+ }
+
+ ind_a = 0;
+ while (i < mi) {
+ a->frac[ind_a] = 0;
+ while (j < BASE_FIG && i < mi) {
+ a->frac[ind_a] = a->frac[ind_a] * 10 + int_chr[i] - '0';
+ ++j;
+ ++i;
+ }
+ if (i < mi) {
+ ++ind_a;
+ if (ind_a >= ma) goto over_flow;
+ j = 0;
+ }
+ }
+
+ /* get fraction part */
+
+ i = 0;
+ while (i < nf) {
+ while (j < BASE_FIG && i < nf) {
+ a->frac[ind_a] = a->frac[ind_a] * 10 + frac[i] - '0';
+ ++j;
+ ++i;
+ }
+ if (i < nf) {
+ ++ind_a;
+ if (ind_a >= ma) goto over_flow;
+ j = 0;
+ }
+ }
+ goto Final;
+
+over_flow:
+ rb_warn("Conversion from String to BigDecimal overflow (last few digits discarded).");
+
+Final:
+ if (ind_a >= ma) ind_a = ma - 1;
+ while (j < BASE_FIG) {
+ a->frac[ind_a] = a->frac[ind_a] * 10;
+ ++j;
+ }
+ a->Prec = ind_a + 1;
+ a->exponent = eb;
+ VpSetSign(a, sign);
+ VpNmlz(a);
+ return 1;
+}
+
+/*
+ * [Input]
+ * *m ... Real
+ * [Output]
+ * *d ... fraction part of m(d = 0.xxxxxxx). where # of 'x's is fig.
+ * *e ... exponent of m.
+ * DBLE_FIG ... Number of digits in a double variable.
+ *
+ * m -> d*10**e, 0<d<BASE
+ * [Returns]
+ * 0 ... Zero
+ * 1 ... Normal
+ * 2 ... Infinity
+ * -1 ... NaN
+ */
+VP_EXPORT int
+VpVtoD(double *d, SIGNED_VALUE *e, Real *m)
+{
+ size_t ind_m, mm, fig;
+ double div;
+ int f = 1;
+
+ if (VpIsNaN(m)) {
+ *d = VpGetDoubleNaN();
+ *e = 0;
+ f = -1; /* NaN */
+ goto Exit;
+ }
+ else if (VpIsPosZero(m)) {
+ *d = 0.0;
+ *e = 0;
+ f = 0;
+ goto Exit;
+ }
+ else if (VpIsNegZero(m)) {
+ *d = VpGetDoubleNegZero();
+ *e = 0;
+ f = 0;
+ goto Exit;
+ }
+ else if (VpIsPosInf(m)) {
+ *d = VpGetDoublePosInf();
+ *e = 0;
+ f = 2;
+ goto Exit;
+ }
+ else if (VpIsNegInf(m)) {
+ *d = VpGetDoubleNegInf();
+ *e = 0;
+ f = 2;
+ goto Exit;
+ }
+ /* Normal number */
+ fig = (DBLE_FIG + BASE_FIG - 1) / BASE_FIG;
+ ind_m = 0;
+ mm = Min(fig, m->Prec);
+ *d = 0.0;
+ div = 1.;
+ while (ind_m < mm) {
+ div /= (double)BASE;
+ *d = *d + (double)m->frac[ind_m++] * div;
+ }
+ *e = m->exponent * (SIGNED_VALUE)BASE_FIG;
+ *d *= VpGetSign(m);
+
+Exit:
+#ifdef BIGDECIMAL_DEBUG
+ if (gfDebug) {
+ VPrint(stdout, " VpVtoD: m=%\n", m);
+ printf(" d=%e * 10 **%ld\n", *d, *e);
+ printf(" DBLE_FIG = %d\n", DBLE_FIG);
+ }
+#endif /*BIGDECIMAL_DEBUG */
+ return f;
+}
+
+/*
+ * m <- d
+ */
+VP_EXPORT void
+VpDtoV(Real *m, double d)
+{
+ size_t ind_m, mm;
+ SIGNED_VALUE ne;
+ BDIGIT i;
+ double val, val2;
+
+ if (isnan(d)) {
+ VpSetNaN(m);
+ goto Exit;
+ }
+ if (isinf(d)) {
+ if (d > 0.0) VpSetPosInf(m);
+ else VpSetNegInf(m);
+ goto Exit;
+ }
+
+ if (d == 0.0) {
+ VpSetZero(m, 1);
+ goto Exit;
+ }
+ val = (d > 0.) ? d : -d;
+ ne = 0;
+ if (val >= 1.0) {
+ while (val >= 1.0) {
+ val /= (double)BASE;
+ ++ne;
+ }
+ }
+ else {
+ val2 = 1.0 / (double)BASE;
+ while (val < val2) {
+ val *= (double)BASE;
+ --ne;
+ }
+ }
+ /* Now val = 0.xxxxx*BASE**ne */
+
+ mm = m->MaxPrec;
+ memset(m->frac, 0, mm * sizeof(BDIGIT));
+ for (ind_m = 0; val > 0.0 && ind_m < mm; ind_m++) {
+ val *= (double)BASE;
+ i = (BDIGIT)val;
+ val -= (double)i;
+ m->frac[ind_m] = i;
+ }
+ if (ind_m >= mm) ind_m = mm - 1;
+ VpSetSign(m, (d > 0.0) ? 1 : -1);
+ m->Prec = ind_m + 1;
+ m->exponent = ne;
+
+ VpInternalRound(m, 0, (m->Prec > 0) ? m->frac[m->Prec-1] : 0,
+ (BDIGIT)(val*(double)BASE));
+
+Exit:
+#ifdef BIGDECIMAL_DEBUG
+ if (gfDebug) {
+ printf("VpDtoV d=%30.30e\n", d);
+ VPrint(stdout, " m=%\n", m);
+ }
+#endif /* BIGDECIMAL_DEBUG */
+ return;
+}
+
+/*
+ * m <- ival
+ */
+#if 0 /* unused */
+VP_EXPORT void
+VpItoV(Real *m, SIGNED_VALUE ival)
+{
+ size_t mm, ind_m;
+ size_t val, v1, v2, v;
+ int isign;
+ SIGNED_VALUE ne;
+
+ if (ival == 0) {
+ VpSetZero(m, 1);
+ goto Exit;
+ }
+ isign = 1;
+ val = ival;
+ if (ival < 0) {
+ isign = -1;
+ val =(size_t)(-ival);
+ }
+ ne = 0;
+ ind_m = 0;
+ mm = m->MaxPrec;
+ while (ind_m < mm) {
+ m->frac[ind_m] = 0;
+ ++ind_m;
+ }
+ ind_m = 0;
+ while (val > 0) {
+ if (val) {
+ v1 = val;
+ v2 = 1;
+ while (v1 >= BASE) {
+ v1 /= BASE;
+ v2 *= BASE;
+ }
+ val = val - v2 * v1;
+ v = v1;
+ }
+ else {
+ v = 0;
+ }
+ m->frac[ind_m] = v;
+ ++ind_m;
+ ++ne;
+ }
+ m->Prec = ind_m - 1;
+ m->exponent = ne;
+ VpSetSign(m, isign);
+ VpNmlz(m);
+
+Exit:
+#ifdef BIGDECIMAL_DEBUG
+ if (gfDebug) {
+ printf(" VpItoV i=%d\n", ival);
+ VPrint(stdout, " m=%\n", m);
+ }
+#endif /* BIGDECIMAL_DEBUG */
+ return;
+}
+#endif
+
+/*
+ * y = SQRT(x), y*y - x =>0
+ */
+VP_EXPORT int
+VpSqrt(Real *y, Real *x)
+{
+ Real *f = NULL;
+ Real *r = NULL;
+ size_t y_prec;
+ SIGNED_VALUE n, e;
+ SIGNED_VALUE prec;
+ ssize_t nr;
+ double val;
+
+ /* Zero, NaN or Infinity ? */
+ if (!VpHasVal(x)) {
+ if (VpIsZero(x) || VpGetSign(x) > 0) {
+ VpAsgn(y,x,1);
+ goto Exit;
+ }
+ VpSetNaN(y);
+ return VpException(VP_EXCEPTION_OP, "(VpSqrt) SQRT(NaN or negative value)", 0);
+ goto Exit;
+ }
+
+ /* Negative ? */
+ if (VpGetSign(x) < 0) {
+ VpSetNaN(y);
+ return VpException(VP_EXCEPTION_OP, "(VpSqrt) SQRT(negative value)", 0);
+ }
+
+ /* One ? */
+ if (VpIsOne(x)) {
+ VpSetOne(y);
+ goto Exit;
+ }
+
+ n = (SIGNED_VALUE)y->MaxPrec;
+ if (x->MaxPrec > (size_t)n) n = (ssize_t)x->MaxPrec;
+
+ /* allocate temporally variables */
+ f = VpAlloc(y->MaxPrec * (BASE_FIG + 2), "#1");
+ r = VpAlloc((n + n) * (BASE_FIG + 2), "#1");
+
+ nr = 0;
+ y_prec = y->MaxPrec;
+
+ prec = x->exponent - (ssize_t)y_prec;
+ if (x->exponent > 0)
+ ++prec;
+ else
+ --prec;
+
+ VpVtoD(&val, &e, x); /* val <- x */
+ e /= (SIGNED_VALUE)BASE_FIG;
+ n = e / 2;
+ if (e - n * 2 != 0) {
+ val /= BASE;
+ n = (e + 1) / 2;
+ }
+ VpDtoV(y, sqrt(val)); /* y <- sqrt(val) */
+ y->exponent += n;
+ n = (SIGNED_VALUE)((DBLE_FIG + BASE_FIG - 1) / BASE_FIG);
+ y->MaxPrec = Min((size_t)n , y_prec);
+ f->MaxPrec = y->MaxPrec + 1;
+ n = (SIGNED_VALUE)(y_prec * BASE_FIG);
+ if (n < (SIGNED_VALUE)maxnr) n = (SIGNED_VALUE)maxnr;
+ do {
+ y->MaxPrec *= 2;
+ if (y->MaxPrec > y_prec) y->MaxPrec = y_prec;
+ f->MaxPrec = y->MaxPrec;
+ VpDivd(f, r, x, y); /* f = x/y */
+ VpAddSub(r, f, y, -1); /* r = f - y */
+ VpMult(f, VpPt5, r); /* f = 0.5*r */
+ if (VpIsZero(f)) goto converge;
+ VpAddSub(r, f, y, 1); /* r = y + f */
+ VpAsgn(y, r, 1); /* y = r */
+ } while (++nr < n);
+
+#ifdef BIGDECIMAL_DEBUG
+ if (gfDebug) {
+ printf("ERROR(VpSqrt): did not converge within %ld iterations.\n", nr);
+ }
+#endif /* BIGDECIMAL_DEBUG */
+ y->MaxPrec = y_prec;
+
+converge:
+ VpChangeSign(y, 1);
+#ifdef BIGDECIMAL_DEBUG
+ if (gfDebug) {
+ VpMult(r, y, y);
+ VpAddSub(f, x, r, -1);
+ printf("VpSqrt: iterations = %"PRIdSIZE"\n", nr);
+ VPrint(stdout, " y =% \n", y);
+ VPrint(stdout, " x =% \n", x);
+ VPrint(stdout, " x-y*y = % \n", f);
+ }
+#endif /* BIGDECIMAL_DEBUG */
+ y->MaxPrec = y_prec;
+
+Exit:
+ VpFree(f);
+ VpFree(r);
+ return 1;
+}
+
+/*
+ *
+ * nf: digit position for operation.
+ *
+ */
+VP_EXPORT int
+VpMidRound(Real *y, unsigned short f, ssize_t nf)
+/*
+ * Round relatively from the decimal point.
+ * f: rounding mode
+ * nf: digit location to round from the decimal point.
+ */
+{
+ /* fracf: any positive digit under rounding position? */
+ /* fracf_1further: any positive digits under one further than the rounding position? */
+ /* exptoadd: number of digits needed to compensate negative nf */
+ int fracf, fracf_1further;
+ ssize_t n,i,ix,ioffset, exptoadd;
+ BDIGIT v, shifter;
+ BDIGIT div;
+
+ nf += y->exponent * (ssize_t)BASE_FIG;
+ exptoadd=0;
+ if (nf < 0) {
+ /* rounding position too left(large). */
+ if (f != VP_ROUND_CEIL && f != VP_ROUND_FLOOR) {
+ VpSetZero(y, VpGetSign(y)); /* truncate everything */
+ return 0;
+ }
+ exptoadd = -nf;
+ nf = 0;
+ }
+
+ ix = nf / (ssize_t)BASE_FIG;
+ if ((size_t)ix >= y->Prec) return 0; /* rounding position too right(small). */
+ v = y->frac[ix];
+
+ ioffset = nf - ix*(ssize_t)BASE_FIG;
+ n = (ssize_t)BASE_FIG - ioffset - 1;
+ for (shifter = 1, i = 0; i < n; ++i) shifter *= 10;
+
+ /* so the representation used (in y->frac) is an array of BDIGIT, where
+ each BDIGIT contains a value between 0 and BASE-1, consisting of BASE_FIG
+ decimal places.
+
+ (that numbers of decimal places are typed as ssize_t is somewhat confusing)
+
+ nf is now position (in decimal places) of the digit from the start of
+ the array.
+
+ ix is the position (in BDIGITS) of the BDIGIT containing the decimal digit,
+ from the start of the array.
+
+ v is the value of this BDIGIT
+
+ ioffset is the number of extra decimal places along of this decimal digit
+ within v.
+
+ n is the number of decimal digits remaining within v after this decimal digit
+ shifter is 10**n,
+
+ v % shifter are the remaining digits within v
+ v % (shifter * 10) are the digit together with the remaining digits within v
+ v / shifter are the digit's predecessors together with the digit
+ div = v / shifter / 10 is just the digit's precessors
+ (v / shifter) - div*10 is just the digit, which is what v ends up being reassigned to.
+ */
+
+ fracf = (v % (shifter * 10) > 0);
+ fracf_1further = ((v % shifter) > 0);
+
+ v /= shifter;
+ div = v / 10;
+ v = v - div*10;
+ /* now v is just the digit required.
+ now fracf is whether the digit or any of the remaining digits within v are non-zero
+ now fracf_1further is whether any of the remaining digits within v are non-zero
+ */
+
+ /* now check all the remaining BDIGITS for zero-ness a whole BDIGIT at a time.
+ if we spot any non-zeroness, that means that we found a positive digit under
+ rounding position, and we also found a positive digit under one further than
+ the rounding position, so both searches (to see if any such non-zero digit exists)
+ can stop */
+
+ for (i = ix + 1; (size_t)i < y->Prec; i++) {
+ if (y->frac[i] % BASE) {
+ fracf = fracf_1further = 1;
+ break;
+ }
+ }
+
+ /* now fracf = does any positive digit exist under the rounding position?
+ now fracf_1further = does any positive digit exist under one further than the
+ rounding position?
+ now v = the first digit under the rounding position */
+
+ /* drop digits after pointed digit */
+ memset(y->frac + ix + 1, 0, (y->Prec - (ix + 1)) * sizeof(BDIGIT));
+
+ switch (f) {
+ case VP_ROUND_DOWN: /* Truncate */
+ break;
+ case VP_ROUND_UP: /* Roundup */
+ if (fracf) ++div;
+ break;
+ case VP_ROUND_HALF_UP:
+ if (v>=5) ++div;
+ break;
+ case VP_ROUND_HALF_DOWN:
+ if (v > 5 || (v == 5 && fracf_1further)) ++div;
+ break;
+ case VP_ROUND_CEIL:
+ if (fracf && (VpGetSign(y) > 0)) ++div;
+ break;
+ case VP_ROUND_FLOOR:
+ if (fracf && (VpGetSign(y) < 0)) ++div;
+ break;
+ case VP_ROUND_HALF_EVEN: /* Banker's rounding */
+ if (v > 5) ++div;
+ else if (v == 5) {
+ if (fracf_1further) {
+ ++div;
+ }
+ else {
+ if (ioffset == 0) {
+ /* v is the first decimal digit of its BDIGIT;
+ need to grab the previous BDIGIT if present
+ to check for evenness of the previous decimal
+ digit (which is same as that of the BDIGIT since
+ base 10 has a factor of 2) */
+ if (ix && (y->frac[ix-1] % 2)) ++div;
+ }
+ else {
+ if (div % 2) ++div;
+ }
+ }
+ }
+ break;
+ }
+ for (i = 0; i <= n; ++i) div *= 10;
+ if (div >= BASE) {
+ if (ix) {
+ y->frac[ix] = 0;
+ VpRdup(y, ix);
+ }
+ else {
+ short s = VpGetSign(y);
+ SIGNED_VALUE e = y->exponent;
+ VpSetOne(y);
+ VpSetSign(y, s);
+ y->exponent = e + 1;
+ }
+ }
+ else {
+ y->frac[ix] = div;
+ VpNmlz(y);
+ }
+ if (exptoadd > 0) {
+ y->exponent += (SIGNED_VALUE)(exptoadd / BASE_FIG);
+ exptoadd %= (ssize_t)BASE_FIG;
+ for (i = 0; i < exptoadd; i++) {
+ y->frac[0] *= 10;
+ if (y->frac[0] >= BASE) {
+ y->frac[0] /= BASE;
+ y->exponent++;
+ }
+ }
+ }
+ return 1;
+}
+
+VP_EXPORT int
+VpLeftRound(Real *y, unsigned short f, ssize_t nf)
+/*
+ * Round from the left hand side of the digits.
+ */
+{
+ BDIGIT v;
+ if (!VpHasVal(y)) return 0; /* Unable to round */
+ v = y->frac[0];
+ nf -= VpExponent(y) * (ssize_t)BASE_FIG;
+ while ((v /= 10) != 0) nf--;
+ nf += (ssize_t)BASE_FIG-1;
+ return VpMidRound(y, f, nf);
+}
+
+VP_EXPORT int
+VpActiveRound(Real *y, Real *x, unsigned short f, ssize_t nf)
+{
+ /* First,assign whole value in truncation mode */
+ if (VpAsgn(y, x, 10) <= 1) return 0; /* Zero,NaN,or Infinity */
+ return VpMidRound(y, f, nf);
+}
+
+static int
+VpLimitRound(Real *c, size_t ixDigit)
+{
+ size_t ix = VpGetPrecLimit();
+ if (!VpNmlz(c)) return -1;
+ if (!ix) return 0;
+ if (!ixDigit) ixDigit = c->Prec-1;
+ if ((ix + BASE_FIG - 1) / BASE_FIG > ixDigit + 1) return 0;
+ return VpLeftRound(c, VpGetRoundMode(), (ssize_t)ix);
+}
+
+/* If I understand correctly, this is only ever used to round off the final decimal
+ digit of precision */
+static void
+VpInternalRound(Real *c, size_t ixDigit, BDIGIT vPrev, BDIGIT v)
+{
+ int f = 0;
+
+ unsigned short const rounding_mode = VpGetRoundMode();
+
+ if (VpLimitRound(c, ixDigit)) return;
+ if (!v) return;
+
+ v /= BASE1;
+ switch (rounding_mode) {
+ case VP_ROUND_DOWN:
+ break;
+ case VP_ROUND_UP:
+ if (v) f = 1;
+ break;
+ case VP_ROUND_HALF_UP:
+ if (v >= 5) f = 1;
+ break;
+ case VP_ROUND_HALF_DOWN:
+ /* this is ok - because this is the last digit of precision,
+ the case where v == 5 and some further digits are nonzero
+ will never occur */
+ if (v >= 6) f = 1;
+ break;
+ case VP_ROUND_CEIL:
+ if (v && (VpGetSign(c) > 0)) f = 1;
+ break;
+ case VP_ROUND_FLOOR:
+ if (v && (VpGetSign(c) < 0)) f = 1;
+ break;
+ case VP_ROUND_HALF_EVEN: /* Banker's rounding */
+ /* as per VP_ROUND_HALF_DOWN, because this is the last digit of precision,
+ there is no case to worry about where v == 5 and some further digits are nonzero */
+ if (v > 5) f = 1;
+ else if (v == 5 && vPrev % 2) f = 1;
+ break;
+ }
+ if (f) {
+ VpRdup(c, ixDigit);
+ VpNmlz(c);
+ }
+}
+
+/*
+ * Rounds up m(plus one to final digit of m).
+ */
+static int
+VpRdup(Real *m, size_t ind_m)
+{
+ BDIGIT carry;
+
+ if (!ind_m) ind_m = m->Prec;
+
+ carry = 1;
+ while (carry > 0 && ind_m--) {
+ m->frac[ind_m] += carry;
+ if (m->frac[ind_m] >= BASE) m->frac[ind_m] -= BASE;
+ else carry = 0;
+ }
+ if (carry > 0) { /* Overflow,count exponent and set fraction part be 1 */
+ if (!AddExponent(m, 1)) return 0;
+ m->Prec = m->frac[0] = 1;
+ }
+ else {
+ VpNmlz(m);
+ }
+ return 1;
+}
+
+/*
+ * y = x - fix(x)
+ */
+VP_EXPORT void
+VpFrac(Real *y, Real *x)
+{
+ size_t my, ind_y, ind_x;
+
+ if (!VpHasVal(x)) {
+ VpAsgn(y, x, 1);
+ goto Exit;
+ }
+
+ if (x->exponent > 0 && (size_t)x->exponent >= x->Prec) {
+ VpSetZero(y, VpGetSign(x));
+ goto Exit;
+ }
+ else if (x->exponent <= 0) {
+ VpAsgn(y, x, 1);
+ goto Exit;
+ }
+
+ /* satisfy: x->exponent > 0 */
+
+ y->Prec = x->Prec - (size_t)x->exponent;
+ y->Prec = Min(y->Prec, y->MaxPrec);
+ y->exponent = 0;
+ VpSetSign(y, VpGetSign(x));
+ ind_y = 0;
+ my = y->Prec;
+ ind_x = x->exponent;
+ while (ind_y < my) {
+ y->frac[ind_y] = x->frac[ind_x];
+ ++ind_y;
+ ++ind_x;
+ }
+ VpNmlz(y);
+
+Exit:
+#ifdef BIGDECIMAL_DEBUG
+ if (gfDebug) {
+ VPrint(stdout, "VpFrac y=%\n", y);
+ VPrint(stdout, " x=%\n", x);
+ }
+#endif /* BIGDECIMAL_DEBUG */
+ return;
+}
+
+/*
+ * y = x ** n
+ */
+VP_EXPORT int
+VpPower(Real *y, Real *x, SIGNED_VALUE n)
+{
+ size_t s, ss;
+ ssize_t sign;
+ Real *w1 = NULL;
+ Real *w2 = NULL;
+
+ if (VpIsZero(x)) {
+ if (n == 0) {
+ VpSetOne(y);
+ goto Exit;
+ }
+ sign = VpGetSign(x);
+ if (n < 0) {
+ n = -n;
+ if (sign < 0) sign = (n % 2) ? -1 : 1;
+ VpSetInf(y, sign);
+ }
+ else {
+ if (sign < 0) sign = (n % 2) ? -1 : 1;
+ VpSetZero(y,sign);
+ }
+ goto Exit;
+ }
+ if (VpIsNaN(x)) {
+ VpSetNaN(y);
+ goto Exit;
+ }
+ if (VpIsInf(x)) {
+ if (n == 0) {
+ VpSetOne(y);
+ goto Exit;
+ }
+ if (n > 0) {
+ VpSetInf(y, (n % 2 == 0 || VpIsPosInf(x)) ? 1 : -1);
+ goto Exit;
+ }
+ VpSetZero(y, (n % 2 == 0 || VpIsPosInf(x)) ? 1 : -1);
+ goto Exit;
+ }
+
+ if (x->exponent == 1 && x->Prec == 1 && x->frac[0] == 1) {
+ /* abs(x) = 1 */
+ VpSetOne(y);
+ if (VpGetSign(x) > 0) goto Exit;
+ if ((n % 2) == 0) goto Exit;
+ VpSetSign(y, -1);
+ goto Exit;
+ }
+
+ if (n > 0) sign = 1;
+ else if (n < 0) {
+ sign = -1;
+ n = -n;
+ }
+ else {
+ VpSetOne(y);
+ goto Exit;
+ }
+
+ /* Allocate working variables */
+
+ w1 = VpAlloc((y->MaxPrec + 2) * BASE_FIG, "#0");
+ w2 = VpAlloc((w1->MaxPrec * 2 + 1) * BASE_FIG, "#0");
+ /* calculation start */
+
+ VpAsgn(y, x, 1);
+ --n;
+ while (n > 0) {
+ VpAsgn(w1, x, 1);
+ s = 1;
+ while (ss = s, (s += s) <= (size_t)n) {
+ VpMult(w2, w1, w1);
+ VpAsgn(w1, w2, 1);
+ }
+ n -= (SIGNED_VALUE)ss;
+ VpMult(w2, y, w1);
+ VpAsgn(y, w2, 1);
+ }
+ if (sign < 0) {
+ VpDivd(w1, w2, VpConstOne, y);
+ VpAsgn(y, w1, 1);
+ }
+
+Exit:
+#ifdef BIGDECIMAL_DEBUG
+ if (gfDebug) {
+ VPrint(stdout, "VpPower y=%\n", y);
+ VPrint(stdout, "VpPower x=%\n", x);
+ printf(" n=%d\n", n);
+ }
+#endif /* BIGDECIMAL_DEBUG */
+ VpFree(w2);
+ VpFree(w1);
+ return 1;
+}
+
+#ifdef BIGDECIMAL_DEBUG
+int
+VpVarCheck(Real * v)
+/*
+ * Checks the validity of the Real variable v.
+ * [Input]
+ * v ... Real *, variable to be checked.
+ * [Returns]
+ * 0 ... correct v.
+ * other ... error
+ */
+{
+ size_t i;
+
+ if (v->MaxPrec == 0) {
+ printf("ERROR(VpVarCheck): Illegal Max. Precision(=%"PRIuSIZE")\n",
+ v->MaxPrec);
+ return 1;
+ }
+ if (v->Prec == 0 || v->Prec > v->MaxPrec) {
+ printf("ERROR(VpVarCheck): Illegal Precision(=%"PRIuSIZE")\n", v->Prec);
+ printf(" Max. Prec.=%"PRIuSIZE"\n", v->MaxPrec);
+ return 2;
+ }
+ for (i = 0; i < v->Prec; ++i) {
+ if (v->frac[i] >= BASE) {
+ printf("ERROR(VpVarCheck): Illegal fraction\n");
+ printf(" Frac[%"PRIuSIZE"]=%lu\n", i, v->frac[i]);
+ printf(" Prec. =%"PRIuSIZE"\n", v->Prec);
+ printf(" Exp. =%"PRIdVALUE"\n", v->exponent);
+ printf(" BASE =%lu\n", BASE);
+ return 3;
+ }
+ }
+ return 0;
+}
+#endif /* BIGDECIMAL_DEBUG */
diff --git a/jni/ruby/ext/bigdecimal/bigdecimal.gemspec b/jni/ruby/ext/bigdecimal/bigdecimal.gemspec
new file mode 100644
index 0000000..e695e42
--- /dev/null
+++ b/jni/ruby/ext/bigdecimal/bigdecimal.gemspec
@@ -0,0 +1,31 @@
+# -*- ruby -*-
+_VERSION = "1.2.6"
+date = %w$Date:: 2015-07-01 04:17:07 +0900#$[1]
+
+Gem::Specification.new do |s|
+ s.name = "bigdecimal"
+ s.version = _VERSION
+ s.date = date
+ s.license = 'ruby'
+ s.summary = "Arbitrary-precision decimal floating-point number library."
+ s.homepage = "http://www.ruby-lang.org"
+ s.email = "mrkn@mrkn.jp"
+ s.description = "This library provides arbitrary-precision decimal floating-point number class."
+ s.authors = ["Kenta Murata", "Zachary Scott", "Shigeo Kobayashi"]
+ s.require_path = %[lib]
+ s.files = %w[
+ bigdecimal.gemspec
+ bigdecimal.c
+ bigdecimal.h
+ depend extconf.rb
+ lib/bigdecimal/jacobian.rb
+ lib/bigdecimal/ludcmp.rb
+ lib/bigdecimal/math.rb
+ lib/bigdecimal/newton.rb
+ lib/bigdecimal/util.rb
+ sample/linear.rb
+ sample/nlsolve.rb
+ sample/pi.rb
+ ]
+ s.extensions = %w[extconf.rb]
+end
diff --git a/jni/ruby/ext/bigdecimal/bigdecimal.h b/jni/ruby/ext/bigdecimal/bigdecimal.h
new file mode 100644
index 0000000..e8adea6
--- /dev/null
+++ b/jni/ruby/ext/bigdecimal/bigdecimal.h
@@ -0,0 +1,314 @@
+/*
+ *
+ * Ruby BigDecimal(Variable decimal precision) extension library.
+ *
+ * Copyright(C) 2002 by Shigeo Kobayashi(shigeo@tinyforest.gr.jp)
+ *
+ */
+
+#ifndef RUBY_BIG_DECIMAL_H
+#define RUBY_BIG_DECIMAL_H 1
+
+#include "ruby/ruby.h"
+#include <float.h>
+
+#ifndef RB_UNUSED_VAR
+# ifdef __GNUC__
+# define RB_UNUSED_VAR(x) x __attribute__ ((unused))
+# else
+# define RB_UNUSED_VAR(x) x
+# endif
+#endif
+
+#ifndef UNREACHABLE
+# define UNREACHABLE /* unreachable */
+#endif
+
+#undef BDIGIT
+#undef SIZEOF_BDIGITS
+#undef BDIGIT_DBL
+#undef BDIGIT_DBL_SIGNED
+#undef PRI_BDIGIT_PREFIX
+#undef PRI_BDIGIT_DBL_PREFIX
+
+#ifdef HAVE_INT64_T
+# define BDIGIT uint32_t
+# define BDIGIT_DBL uint64_t
+# define BDIGIT_DBL_SIGNED int64_t
+# define SIZEOF_BDIGITS 4
+#else
+# define BDIGIT uint16_t
+# define BDIGIT_DBL uint32_t
+# define BDIGIT_DBL_SIGNED int32_t
+# define SIZEOF_BDIGITS 2
+#endif
+
+#if defined(__cplusplus)
+extern "C" {
+#if 0
+} /* satisfy cc-mode */
+#endif
+#endif
+
+#ifndef HAVE_LABS
+static inline long
+labs(long const x)
+{
+ if (x < 0) return -x;
+ return x;
+}
+#endif
+
+#ifndef HAVE_LLABS
+static inline LONG_LONG
+llabs(LONG_LONG const x)
+{
+ if (x < 0) return -x;
+ return x;
+}
+#endif
+
+#ifdef vabs
+# undef vabs
+#endif
+#if SIZEOF_VALUE <= SIZEOF_INT
+# define vabs abs
+#elif SIZEOF_VALUE <= SIZEOF_LONG
+# define vabs labs
+#elif SIZEOF_VALUE <= SIZEOF_LONG_LONG
+# define vabs llabs
+#endif
+
+extern VALUE rb_cBigDecimal;
+
+#if 0 || SIZEOF_BDIGITS >= 16
+# define RMPD_COMPONENT_FIGURES 38
+# define RMPD_BASE ((BDIGIT)100000000000000000000000000000000000000U)
+#elif SIZEOF_BDIGITS >= 8
+# define RMPD_COMPONENT_FIGURES 19
+# define RMPD_BASE ((BDIGIT)10000000000000000000U)
+#elif SIZEOF_BDIGITS >= 4
+# define RMPD_COMPONENT_FIGURES 9
+# define RMPD_BASE ((BDIGIT)1000000000U)
+#elif SIZEOF_BDIGITS >= 2
+# define RMPD_COMPONENT_FIGURES 4
+# define RMPD_BASE ((BDIGIT)10000U)
+#else
+# define RMPD_COMPONENT_FIGURES 2
+# define RMPD_BASE ((BDIGIT)100U)
+#endif
+
+
+/*
+ * NaN & Infinity
+ */
+#define SZ_NaN "NaN"
+#define SZ_INF "Infinity"
+#define SZ_PINF "+Infinity"
+#define SZ_NINF "-Infinity"
+
+/*
+ * #define VP_EXPORT other than static to let VP_ routines
+ * be called from outside of this module.
+ */
+#define VP_EXPORT static
+
+/* Exception codes */
+#define VP_EXCEPTION_ALL ((unsigned short)0x00FF)
+#define VP_EXCEPTION_INFINITY ((unsigned short)0x0001)
+#define VP_EXCEPTION_NaN ((unsigned short)0x0002)
+#define VP_EXCEPTION_UNDERFLOW ((unsigned short)0x0004)
+#define VP_EXCEPTION_OVERFLOW ((unsigned short)0x0001) /* 0x0008) */
+#define VP_EXCEPTION_ZERODIVIDE ((unsigned short)0x0010)
+
+/* Following 2 exceptions can't controlled by user */
+#define VP_EXCEPTION_OP ((unsigned short)0x0020)
+#define VP_EXCEPTION_MEMORY ((unsigned short)0x0040)
+
+#define RMPD_EXCEPTION_MODE_DEFAULT 0U
+
+/* Computation mode */
+#define VP_ROUND_MODE ((unsigned short)0x0100)
+#define VP_ROUND_UP 1
+#define VP_ROUND_DOWN 2
+#define VP_ROUND_HALF_UP 3
+#define VP_ROUND_HALF_DOWN 4
+#define VP_ROUND_CEIL 5
+#define VP_ROUND_FLOOR 6
+#define VP_ROUND_HALF_EVEN 7
+
+#define RMPD_ROUNDING_MODE_DEFAULT VP_ROUND_HALF_UP
+
+#define VP_SIGN_NaN 0 /* NaN */
+#define VP_SIGN_POSITIVE_ZERO 1 /* Positive zero */
+#define VP_SIGN_NEGATIVE_ZERO -1 /* Negative zero */
+#define VP_SIGN_POSITIVE_FINITE 2 /* Positive finite number */
+#define VP_SIGN_NEGATIVE_FINITE -2 /* Negative finite number */
+#define VP_SIGN_POSITIVE_INFINITE 3 /* Positive infinite number */
+#define VP_SIGN_NEGATIVE_INFINITE -3 /* Negative infinite number */
+
+#ifdef __GNUC__
+#define FLEXIBLE_ARRAY_SIZE 0
+#else
+#define FLEXIBLE_ARRAY_SIZE 1
+#endif
+
+/*
+ * VP representation
+ * r = 0.xxxxxxxxx *BASE**exponent
+ */
+typedef struct {
+ VALUE obj; /* Back pointer(VALUE) for Ruby object. */
+ size_t MaxPrec; /* Maximum precision size */
+ /* This is the actual size of pfrac[] */
+ /*(frac[0] to frac[MaxPrec] are available). */
+ size_t Prec; /* Current precision size. */
+ /* This indicates how much the. */
+ /* the array frac[] is actually used. */
+ SIGNED_VALUE exponent; /* Exponent part. */
+ short sign; /* Attributes of the value. */
+ /*
+ * ==0 : NaN
+ * 1 : Positive zero
+ * -1 : Negative zero
+ * 2 : Positive number
+ * -2 : Negative number
+ * 3 : Positive infinite number
+ * -3 : Negative infinite number
+ */
+ short flag; /* Not used in vp_routines,space for user. */
+ BDIGIT frac[FLEXIBLE_ARRAY_SIZE]; /* Array of fraction part. */
+} Real;
+
+/*
+ * ------------------
+ * EXPORTables.
+ * ------------------
+ */
+
+VP_EXPORT Real *
+VpNewRbClass(size_t mx, char const *str, VALUE klass);
+
+VP_EXPORT Real *VpCreateRbObject(size_t mx,const char *str);
+
+static inline BDIGIT
+rmpd_base_value(void) { return RMPD_BASE; }
+static inline size_t
+rmpd_component_figures(void) { return RMPD_COMPONENT_FIGURES; }
+static inline size_t
+rmpd_double_figures(void) { return 1+DBL_DIG; }
+
+#define VpBaseFig() rmpd_component_figures()
+#define VpDblFig() rmpd_double_figures()
+#define VpBaseVal() rmpd_base_value()
+
+/* Zero,Inf,NaN (isinf(),isnan() used to check) */
+VP_EXPORT double VpGetDoubleNaN(void);
+VP_EXPORT double VpGetDoublePosInf(void);
+VP_EXPORT double VpGetDoubleNegInf(void);
+VP_EXPORT double VpGetDoubleNegZero(void);
+
+/* These 2 functions added at v1.1.7 */
+VP_EXPORT size_t VpGetPrecLimit(void);
+VP_EXPORT size_t VpSetPrecLimit(size_t n);
+
+/* Round mode */
+VP_EXPORT int VpIsRoundMode(unsigned short n);
+VP_EXPORT unsigned short VpGetRoundMode(void);
+VP_EXPORT unsigned short VpSetRoundMode(unsigned short n);
+
+VP_EXPORT int VpException(unsigned short f,const char *str,int always);
+#if 0 /* unused */
+VP_EXPORT int VpIsNegDoubleZero(double v);
+#endif
+VP_EXPORT size_t VpNumOfChars(Real *vp,const char *pszFmt);
+VP_EXPORT size_t VpInit(BDIGIT BaseVal);
+VP_EXPORT void *VpMemAlloc(size_t mb);
+VP_EXPORT void *VpMemRealloc(void *ptr, size_t mb);
+VP_EXPORT void VpFree(Real *pv);
+VP_EXPORT Real *VpAlloc(size_t mx, const char *szVal);
+VP_EXPORT size_t VpAsgn(Real *c, Real *a, int isw);
+VP_EXPORT size_t VpAddSub(Real *c,Real *a,Real *b,int operation);
+VP_EXPORT size_t VpMult(Real *c,Real *a,Real *b);
+VP_EXPORT size_t VpDivd(Real *c,Real *r,Real *a,Real *b);
+VP_EXPORT int VpComp(Real *a,Real *b);
+VP_EXPORT ssize_t VpExponent10(Real *a);
+VP_EXPORT void VpSzMantissa(Real *a,char *psz);
+VP_EXPORT int VpToSpecialString(Real *a,char *psz,int fPlus);
+VP_EXPORT void VpToString(Real *a, char *psz, size_t fFmt, int fPlus);
+VP_EXPORT void VpToFString(Real *a, char *psz, size_t fFmt, int fPlus);
+VP_EXPORT int VpCtoV(Real *a, const char *int_chr, size_t ni, const char *frac, size_t nf, const char *exp_chr, size_t ne);
+VP_EXPORT int VpVtoD(double *d, SIGNED_VALUE *e, Real *m);
+VP_EXPORT void VpDtoV(Real *m,double d);
+#if 0 /* unused */
+VP_EXPORT void VpItoV(Real *m,S_INT ival);
+#endif
+VP_EXPORT int VpSqrt(Real *y,Real *x);
+VP_EXPORT int VpActiveRound(Real *y, Real *x, unsigned short f, ssize_t il);
+VP_EXPORT int VpMidRound(Real *y, unsigned short f, ssize_t nf);
+VP_EXPORT int VpLeftRound(Real *y, unsigned short f, ssize_t nf);
+VP_EXPORT void VpFrac(Real *y, Real *x);
+VP_EXPORT int VpPower(Real *y, Real *x, SIGNED_VALUE n);
+
+/* VP constants */
+VP_EXPORT Real *VpOne(void);
+
+/*
+ * ------------------
+ * MACRO definitions.
+ * ------------------
+ */
+#define Abs(a) (((a)>= 0)?(a):(-(a)))
+#define Max(a, b) (((a)>(b))?(a):(b))
+#define Min(a, b) (((a)>(b))?(b):(a))
+
+#define VpMaxPrec(a) ((a)->MaxPrec)
+#define VpPrec(a) ((a)->Prec)
+#define VpGetFlag(a) ((a)->flag)
+
+/* Sign */
+
+/* VpGetSign(a) returns 1,-1 if a>0,a<0 respectively */
+#define VpGetSign(a) (((a)->sign>0)?1:(-1))
+/* Change sign of a to a>0,a<0 if s = 1,-1 respectively */
+#define VpChangeSign(a,s) {if((s)>0) (a)->sign=(short)Abs((ssize_t)(a)->sign);else (a)->sign=-(short)Abs((ssize_t)(a)->sign);}
+/* Sets sign of a to a>0,a<0 if s = 1,-1 respectively */
+#define VpSetSign(a,s) {if((s)>0) (a)->sign=(short)VP_SIGN_POSITIVE_FINITE;else (a)->sign=(short)VP_SIGN_NEGATIVE_FINITE;}
+
+/* 1 */
+#define VpSetOne(a) {(a)->Prec=(a)->exponent=(a)->frac[0]=1;(a)->sign=VP_SIGN_POSITIVE_FINITE;}
+
+/* ZEROs */
+#define VpIsPosZero(a) ((a)->sign==VP_SIGN_POSITIVE_ZERO)
+#define VpIsNegZero(a) ((a)->sign==VP_SIGN_NEGATIVE_ZERO)
+#define VpIsZero(a) (VpIsPosZero(a) || VpIsNegZero(a))
+#define VpSetPosZero(a) ((a)->frac[0]=0,(a)->Prec=1,(a)->sign=VP_SIGN_POSITIVE_ZERO)
+#define VpSetNegZero(a) ((a)->frac[0]=0,(a)->Prec=1,(a)->sign=VP_SIGN_NEGATIVE_ZERO)
+#define VpSetZero(a,s) (void)(((s)>0)?VpSetPosZero(a):VpSetNegZero(a))
+
+/* NaN */
+#define VpIsNaN(a) ((a)->sign==VP_SIGN_NaN)
+#define VpSetNaN(a) ((a)->frac[0]=0,(a)->Prec=1,(a)->sign=VP_SIGN_NaN)
+
+/* Infinity */
+#define VpIsPosInf(a) ((a)->sign==VP_SIGN_POSITIVE_INFINITE)
+#define VpIsNegInf(a) ((a)->sign==VP_SIGN_NEGATIVE_INFINITE)
+#define VpIsInf(a) (VpIsPosInf(a) || VpIsNegInf(a))
+#define VpIsDef(a) ( !(VpIsNaN(a)||VpIsInf(a)) )
+#define VpSetPosInf(a) ((a)->frac[0]=0,(a)->Prec=1,(a)->sign=VP_SIGN_POSITIVE_INFINITE)
+#define VpSetNegInf(a) ((a)->frac[0]=0,(a)->Prec=1,(a)->sign=VP_SIGN_NEGATIVE_INFINITE)
+#define VpSetInf(a,s) (void)(((s)>0)?VpSetPosInf(a):VpSetNegInf(a))
+#define VpHasVal(a) (a->frac[0])
+#define VpIsOne(a) ((a->Prec==1)&&(a->frac[0]==1)&&(a->exponent==1))
+#define VpExponent(a) (a->exponent)
+#ifdef BIGDECIMAL_DEBUG
+int VpVarCheck(Real * v);
+#endif /* BIGDECIMAL_DEBUG */
+
+#if defined(__cplusplus)
+#if 0
+{ /* satisfy cc-mode */
+#endif
+} /* extern "C" { */
+#endif
+#endif /* RUBY_BIG_DECIMAL_H */
diff --git a/jni/ruby/ext/bigdecimal/depend b/jni/ruby/ext/bigdecimal/depend
new file mode 100644
index 0000000..d9c6600
--- /dev/null
+++ b/jni/ruby/ext/bigdecimal/depend
@@ -0,0 +1,13 @@
+# AUTOGENERATED DEPENDENCIES START
+bigdecimal.o: $(RUBY_EXTCONF_H)
+bigdecimal.o: $(arch_hdrdir)/ruby/config.h
+bigdecimal.o: $(hdrdir)/ruby/defines.h
+bigdecimal.o: $(hdrdir)/ruby/intern.h
+bigdecimal.o: $(hdrdir)/ruby/missing.h
+bigdecimal.o: $(hdrdir)/ruby/st.h
+bigdecimal.o: $(hdrdir)/ruby/subst.h
+bigdecimal.o: $(hdrdir)/ruby/util.h
+bigdecimal.o: $(hdrdir)/ruby/ruby.h
+bigdecimal.o: bigdecimal.c
+bigdecimal.o: bigdecimal.h
+# AUTOGENERATED DEPENDENCIES END
diff --git a/jni/ruby/ext/bigdecimal/extconf.h b/jni/ruby/ext/bigdecimal/extconf.h
new file mode 100644
index 0000000..8e66d3b
--- /dev/null
+++ b/jni/ruby/ext/bigdecimal/extconf.h
@@ -0,0 +1,5 @@
+#ifndef EXTCONF_H
+#define EXTCONF_H
+#define HAVE_LABS 1
+#define HAVE_LLABS 1
+#endif
diff --git a/jni/ruby/ext/bigdecimal/extconf.rb b/jni/ruby/ext/bigdecimal/extconf.rb
new file mode 100644
index 0000000..d6be3e5
--- /dev/null
+++ b/jni/ruby/ext/bigdecimal/extconf.rb
@@ -0,0 +1,6 @@
+require 'mkmf'
+
+have_func("labs", "stdlib.h")
+have_func("llabs", "stdlib.h")
+
+create_makefile('bigdecimal')
diff --git a/jni/ruby/ext/bigdecimal/lib/bigdecimal/jacobian.rb b/jni/ruby/ext/bigdecimal/lib/bigdecimal/jacobian.rb
new file mode 100644
index 0000000..d56caab
--- /dev/null
+++ b/jni/ruby/ext/bigdecimal/lib/bigdecimal/jacobian.rb
@@ -0,0 +1,87 @@
+#
+# require 'bigdecimal/jacobian'
+#
+# Provides methods to compute the Jacobian matrix of a set of equations at a
+# point x. In the methods below:
+#
+# f is an Object which is used to compute the Jacobian matrix of the equations.
+# It must provide the following methods:
+#
+# f.values(x):: returns the values of all functions at x
+#
+# f.zero:: returns 0.0
+# f.one:: returns 1.0
+# f.two:: returns 2.0
+# f.ten:: returns 10.0
+#
+# f.eps:: returns the convergence criterion (epsilon value) used to determine whether two values are considered equal. If |a-b| < epsilon, the two values are considered equal.
+#
+# x is the point at which to compute the Jacobian.
+#
+# fx is f.values(x).
+#
+module Jacobian
+ module_function
+
+ # Determines the equality of two numbers by comparing to zero, or using the epsilon value
+ def isEqual(a,b,zero=0.0,e=1.0e-8)
+ aa = a.abs
+ bb = b.abs
+ if aa == zero && bb == zero then
+ true
+ else
+ if ((a-b)/(aa+bb)).abs < e then
+ true
+ else
+ false
+ end
+ end
+ end
+
+
+ # Computes the derivative of f[i] at x[i].
+ # fx is the value of f at x.
+ def dfdxi(f,fx,x,i)
+ nRetry = 0
+ n = x.size
+ xSave = x[i]
+ ok = 0
+ ratio = f.ten*f.ten*f.ten
+ dx = x[i].abs/ratio
+ dx = fx[i].abs/ratio if isEqual(dx,f.zero,f.zero,f.eps)
+ dx = f.one/f.ten if isEqual(dx,f.zero,f.zero,f.eps)
+ until ok>0 do
+ deriv = []
+ nRetry += 1
+ if nRetry > 100
+ raise "Singular Jacobian matrix. No change at x[" + i.to_s + "]"
+ end
+ dx = dx*f.two
+ x[i] += dx
+ fxNew = f.values(x)
+ for j in 0...n do
+ if !isEqual(fxNew[j],fx[j],f.zero,f.eps) then
+ ok += 1
+ deriv <<= (fxNew[j]-fx[j])/dx
+ else
+ deriv <<= f.zero
+ end
+ end
+ x[i] = xSave
+ end
+ deriv
+ end
+
+ # Computes the Jacobian of f at x. fx is the value of f at x.
+ def jacobian(f,fx,x)
+ n = x.size
+ dfdx = Array.new(n*n)
+ for i in 0...n do
+ df = dfdxi(f,fx,x,i)
+ for j in 0...n do
+ dfdx[j*n+i] = df[j]
+ end
+ end
+ dfdx
+ end
+end
diff --git a/jni/ruby/ext/bigdecimal/lib/bigdecimal/ludcmp.rb b/jni/ruby/ext/bigdecimal/lib/bigdecimal/ludcmp.rb
new file mode 100644
index 0000000..6cbe29b
--- /dev/null
+++ b/jni/ruby/ext/bigdecimal/lib/bigdecimal/ludcmp.rb
@@ -0,0 +1,88 @@
+require 'bigdecimal'
+
+#
+# Solves a*x = b for x, using LU decomposition.
+#
+module LUSolve
+ module_function
+
+ # Performs LU decomposition of the n by n matrix a.
+ def ludecomp(a,n,zero=0,one=1)
+ prec = BigDecimal.limit(nil)
+ ps = []
+ scales = []
+ for i in 0...n do # pick up largest(abs. val.) element in each row.
+ ps <<= i
+ nrmrow = zero
+ ixn = i*n
+ for j in 0...n do
+ biggst = a[ixn+j].abs
+ nrmrow = biggst if biggst>nrmrow
+ end
+ if nrmrow>zero then
+ scales <<= one.div(nrmrow,prec)
+ else
+ raise "Singular matrix"
+ end
+ end
+ n1 = n - 1
+ for k in 0...n1 do # Gaussian elimination with partial pivoting.
+ biggst = zero;
+ for i in k...n do
+ size = a[ps[i]*n+k].abs*scales[ps[i]]
+ if size>biggst then
+ biggst = size
+ pividx = i
+ end
+ end
+ raise "Singular matrix" if biggst<=zero
+ if pividx!=k then
+ j = ps[k]
+ ps[k] = ps[pividx]
+ ps[pividx] = j
+ end
+ pivot = a[ps[k]*n+k]
+ for i in (k+1)...n do
+ psin = ps[i]*n
+ a[psin+k] = mult = a[psin+k].div(pivot,prec)
+ if mult!=zero then
+ pskn = ps[k]*n
+ for j in (k+1)...n do
+ a[psin+j] -= mult.mult(a[pskn+j],prec)
+ end
+ end
+ end
+ end
+ raise "Singular matrix" if a[ps[n1]*n+n1] == zero
+ ps
+ end
+
+ # Solves a*x = b for x, using LU decomposition.
+ #
+ # a is a matrix, b is a constant vector, x is the solution vector.
+ #
+ # ps is the pivot, a vector which indicates the permutation of rows performed
+ # during LU decomposition.
+ def lusolve(a,b,ps,zero=0.0)
+ prec = BigDecimal.limit(nil)
+ n = ps.size
+ x = []
+ for i in 0...n do
+ dot = zero
+ psin = ps[i]*n
+ for j in 0...i do
+ dot = a[psin+j].mult(x[j],prec) + dot
+ end
+ x <<= b[ps[i]] - dot
+ end
+ (n-1).downto(0) do |i|
+ dot = zero
+ psin = ps[i]*n
+ for j in (i+1)...n do
+ dot = a[psin+j].mult(x[j],prec) + dot
+ end
+ x[i] = (x[i]-dot).div(a[psin+i],prec)
+ end
+ x
+ end
+end
diff --git a/jni/ruby/ext/bigdecimal/lib/bigdecimal/math.rb b/jni/ruby/ext/bigdecimal/lib/bigdecimal/math.rb
new file mode 100644
index 0000000..4a4fcc2
--- /dev/null
+++ b/jni/ruby/ext/bigdecimal/lib/bigdecimal/math.rb
@@ -0,0 +1,231 @@
+require 'bigdecimal'
+
+#
+#--
+# Contents:
+# sqrt(x, prec)
+# sin (x, prec)
+# cos (x, prec)
+# atan(x, prec) Note: |x|<1, x=0.9999 may not converge.
+# PI (prec)
+# E (prec) == exp(1.0,prec)
+#
+# where:
+# x ... BigDecimal number to be computed.
+# |x| must be small enough to get convergence.
+# prec ... Number of digits to be obtained.
+#++
+#
+# Provides mathematical functions.
+#
+# Example:
+#
+# require "bigdecimal/math"
+#
+# include BigMath
+#
+# a = BigDecimal((PI(100)/2).to_s)
+# puts sin(a,100) # => 0.10000000000000000000......E1
+#
+module BigMath
+ module_function
+
+ # call-seq:
+ # sqrt(decimal, numeric) -> BigDecimal
+ #
+ # Computes the square root of +decimal+ to the specified number of digits of
+ # precision, +numeric+.
+ #
+ # BigMath.sqrt(BigDecimal.new('2'), 16).to_s
+ # #=> "0.1414213562373095048801688724E1"
+ #
+ def sqrt(x, prec)
+ x.sqrt(prec)
+ end
+
+ # call-seq:
+ # sin(decimal, numeric) -> BigDecimal
+ #
+ # Computes the sine of +decimal+ to the specified number of digits of
+ # precision, +numeric+.
+ #
+ # If +decimal+ is Infinity or NaN, returns NaN.
+ #
+ # BigMath.sin(BigMath.PI(5)/4, 5).to_s
+ # #=> "0.70710678118654752440082036563292800375E0"
+ #
+ def sin(x, prec)
+ raise ArgumentError, "Zero or negative precision for sin" if prec <= 0
+ return BigDecimal("NaN") if x.infinite? || x.nan?
+ n = prec + BigDecimal.double_fig
+ one = BigDecimal("1")
+ two = BigDecimal("2")
+ x = -x if neg = x < 0
+ if x > (twopi = two * BigMath.PI(prec))
+ if x > 30
+ x %= twopi
+ else
+ x -= twopi while x > twopi
+ end
+ end
+ x1 = x
+ x2 = x.mult(x,n)
+ sign = 1
+ y = x
+ d = y
+ i = one
+ z = one
+ while d.nonzero? && ((m = n - (y.exponent - d.exponent).abs) > 0)
+ m = BigDecimal.double_fig if m < BigDecimal.double_fig
+ sign = -sign
+ x1 = x2.mult(x1,n)
+ i += two
+ z *= (i-one) * i
+ d = sign * x1.div(z,m)
+ y += d
+ end
+ neg ? -y : y
+ end
+
+ # call-seq:
+ # cos(decimal, numeric) -> BigDecimal
+ #
+ # Computes the cosine of +decimal+ to the specified number of digits of
+ # precision, +numeric+.
+ #
+ # If +decimal+ is Infinity or NaN, returns NaN.
+ #
+ # BigMath.cos(BigMath.PI(4), 16).to_s
+ # #=> "-0.999999999999999999999999999999856613163740061349E0"
+ #
+ def cos(x, prec)
+ raise ArgumentError, "Zero or negative precision for cos" if prec <= 0
+ return BigDecimal("NaN") if x.infinite? || x.nan?
+ n = prec + BigDecimal.double_fig
+ one = BigDecimal("1")
+ two = BigDecimal("2")
+ x = -x if x < 0
+ if x > (twopi = two * BigMath.PI(prec))
+ if x > 30
+ x %= twopi
+ else
+ x -= twopi while x > twopi
+ end
+ end
+ x1 = one
+ x2 = x.mult(x,n)
+ sign = 1
+ y = one
+ d = y
+ i = BigDecimal("0")
+ z = one
+ while d.nonzero? && ((m = n - (y.exponent - d.exponent).abs) > 0)
+ m = BigDecimal.double_fig if m < BigDecimal.double_fig
+ sign = -sign
+ x1 = x2.mult(x1,n)
+ i += two
+ z *= (i-one) * i
+ d = sign * x1.div(z,m)
+ y += d
+ end
+ y
+ end
+
+ # call-seq:
+ # atan(decimal, numeric) -> BigDecimal
+ #
+ # Computes the arctangent of +decimal+ to the specified number of digits of
+ # precision, +numeric+.
+ #
+ # If +decimal+ is NaN, returns NaN.
+ #
+ # BigMath.atan(BigDecimal.new('-1'), 16).to_s
+ # #=> "-0.785398163397448309615660845819878471907514682065E0"
+ #
+ def atan(x, prec)
+ raise ArgumentError, "Zero or negative precision for atan" if prec <= 0
+ return BigDecimal("NaN") if x.nan?
+ pi = PI(prec)
+ x = -x if neg = x < 0
+ return pi.div(neg ? -2 : 2, prec) if x.infinite?
+ return pi / (neg ? -4 : 4) if x.round(prec) == 1
+ x = BigDecimal("1").div(x, prec) if inv = x > 1
+ x = (-1 + sqrt(1 + x**2, prec))/x if dbl = x > 0.5
+ n = prec + BigDecimal.double_fig
+ y = x
+ d = y
+ t = x
+ r = BigDecimal("3")
+ x2 = x.mult(x,n)
+ while d.nonzero? && ((m = n - (y.exponent - d.exponent).abs) > 0)
+ m = BigDecimal.double_fig if m < BigDecimal.double_fig
+ t = -t.mult(x2,n)
+ d = t.div(r,m)
+ y += d
+ r += 2
+ end
+ y *= 2 if dbl
+ y = pi / 2 - y if inv
+ y = -y if neg
+ y
+ end
+
+ # call-seq:
+ # PI(numeric) -> BigDecimal
+ #
+ # Computes the value of pi to the specified number of digits of precision,
+ # +numeric+.
+ #
+ # BigMath.PI(10).to_s
+ # #=> "0.3141592653589793238462643388813853786957412E1"
+ #
+ def PI(prec)
+ raise ArgumentError, "Zero or negative precision for PI" if prec <= 0
+ n = prec + BigDecimal.double_fig
+ zero = BigDecimal("0")
+ one = BigDecimal("1")
+ two = BigDecimal("2")
+
+ m25 = BigDecimal("-0.04")
+ m57121 = BigDecimal("-57121")
+
+ pi = zero
+
+ d = one
+ k = one
+ t = BigDecimal("-80")
+ while d.nonzero? && ((m = n - (pi.exponent - d.exponent).abs) > 0)
+ m = BigDecimal.double_fig if m < BigDecimal.double_fig
+ t = t*m25
+ d = t.div(k,m)
+ k = k+two
+ pi = pi + d
+ end
+
+ d = one
+ k = one
+ t = BigDecimal("956")
+ while d.nonzero? && ((m = n - (pi.exponent - d.exponent).abs) > 0)
+ m = BigDecimal.double_fig if m < BigDecimal.double_fig
+ t = t.div(m57121,n)
+ d = t.div(k,m)
+ pi = pi + d
+ k = k+two
+ end
+ pi
+ end
+
+ # call-seq:
+ # E(numeric) -> BigDecimal
+ #
+ # Computes e (the base of natural logarithms) to the specified number of
+ # digits of precision, +numeric+.
+ #
+ # BigMath.E(10).to_s
+ # #=> "0.271828182845904523536028752390026306410273E1"
+ #
+ def E(prec)
+ raise ArgumentError, "Zero or negative precision for E" if prec <= 0
+ BigMath.exp(1, prec)
+ end
+end
diff --git a/jni/ruby/ext/bigdecimal/lib/bigdecimal/newton.rb b/jni/ruby/ext/bigdecimal/lib/bigdecimal/newton.rb
new file mode 100644
index 0000000..db1a5ad
--- /dev/null
+++ b/jni/ruby/ext/bigdecimal/lib/bigdecimal/newton.rb
@@ -0,0 +1,79 @@
+require "bigdecimal/ludcmp"
+require "bigdecimal/jacobian"
+
+#
+# newton.rb
+#
+# Solves the nonlinear algebraic equation system f = 0 by Newton's method.
+# This program is not dependent on BigDecimal.
+#
+# To call:
+# n = nlsolve(f,x)
+# where n is the number of iterations required,
+# x is the initial value vector
+# f is an Object which is used to compute the values of the equations to be solved.
+# It must provide the following methods:
+#
+# f.values(x):: returns the values of all functions at x
+#
+# f.zero:: returns 0.0
+# f.one:: returns 1.0
+# f.two:: returns 2.0
+# f.ten:: returns 10.0
+#
+# f.eps:: returns the convergence criterion (epsilon value) used to determine whether two values are considered equal. If |a-b| < epsilon, the two values are considered equal.
+#
+# On exit, x is the solution vector.
+#
+module Newton
+ include LUSolve
+ include Jacobian
+ module_function
+
+ def norm(fv,zero=0.0) # :nodoc:
+ s = zero
+ n = fv.size
+ for i in 0...n do
+ s += fv[i]*fv[i]
+ end
+ s
+ end
+
+ # See also Newton
+ def nlsolve(f,x)
+ nRetry = 0
+ n = x.size
+
+ f0 = f.values(x)
+ zero = f.zero
+ one = f.one
+ two = f.two
+ p5 = one/two
+ d = norm(f0,zero)
+ minfact = f.ten*f.ten*f.ten
+ minfact = one/minfact
+ e = f.eps
+ while d >= e do
+ nRetry += 1
+ # Not yet converged. => Compute Jacobian matrix
+ dfdx = jacobian(f,f0,x)
+ # Solve dfdx*dx = -f0 to estimate dx
+ dx = lusolve(dfdx,f0,ludecomp(dfdx,n,zero,one),zero)
+ fact = two
+ xs = x.dup
+ begin
+ fact *= p5
+ if fact < minfact then
+ raise "Failed to reduce function values."
+ end
+ for i in 0...n do
+ x[i] = xs[i] - dx[i]*fact
+ end
+ f0 = f.values(x)
+ dn = norm(f0,zero)
+ end while(dn>=d)
+ d = dn
+ end
+ nRetry
+ end
+end
diff --git a/jni/ruby/ext/bigdecimal/lib/bigdecimal/util.rb b/jni/ruby/ext/bigdecimal/lib/bigdecimal/util.rb
new file mode 100644
index 0000000..82c82c8
--- /dev/null
+++ b/jni/ruby/ext/bigdecimal/lib/bigdecimal/util.rb
@@ -0,0 +1,127 @@
+# BigDecimal extends the native Integer class to provide the #to_d method.
+#
+# When you require the BigDecimal library in your application, this methodwill
+# be available on Integer objects.
+class Integer < Numeric
+ # call-seq:
+ # int.to_d -> bigdecimal
+ #
+ # Convert +int+ to a BigDecimal and return it.
+ #
+ # require 'bigdecimal'
+ # require 'bigdecimal/util'
+ #
+ # 42.to_d
+ # # => #<BigDecimal:1008ef070,'0.42E2',9(36)>
+ #
+ def to_d
+ BigDecimal(self)
+ end
+end
+
+# BigDecimal extends the native Float class to provide the #to_d method.
+#
+# When you require BigDecimal in your application, this method will be
+# available on Float objects.
+class Float < Numeric
+ # call-seq:
+ # flt.to_d -> bigdecimal
+ #
+ # Convert +flt+ to a BigDecimal and return it.
+ #
+ # require 'bigdecimal'
+ # require 'bigdecimal/util'
+ #
+ # 0.5.to_d
+ # # => #<BigDecimal:1dc69e0,'0.5E0',9(18)>
+ #
+ def to_d(precision=nil)
+ BigDecimal(self, precision || Float::DIG)
+ end
+end
+
+# BigDecimal extends the native String class to provide the #to_d method.
+#
+# When you require BigDecimal in your application, this method will be
+# available on String objects.
+class String
+ # call-seq:
+ # string.to_d -> bigdecimal
+ #
+ # Convert +string+ to a BigDecimal and return it.
+ #
+ # require 'bigdecimal'
+ # require 'bigdecimal/util'
+ #
+ # "0.5".to_d
+ # # => #<BigDecimal:1dc69e0,'0.5E0',9(18)>
+ #
+ def to_d
+ BigDecimal(self)
+ end
+end
+
+# BigDecimal extends the native Numeric class to provide the #to_digits and
+# #to_d methods.
+#
+# When you require BigDecimal in your application, this method will be
+# available on BigDecimal objects.
+class BigDecimal < Numeric
+ # call-seq:
+ # a.to_digits -> string
+ #
+ # Converts a BigDecimal to a String of the form "nnnnnn.mmm".
+ # This method is deprecated; use BigDecimal#to_s("F") instead.
+ #
+ # require 'bigdecimal'
+ # require 'bigdecimal/util'
+ #
+ # d = BigDecimal.new("3.14")
+ # d.to_digits
+ # # => "3.14"
+ def to_digits
+ if self.nan? || self.infinite? || self.zero?
+ self.to_s
+ else
+ i = self.to_i.to_s
+ _,f,_,z = self.frac.split
+ i + "." + ("0"*(-z)) + f
+ end
+ end
+
+ # call-seq:
+ # a.to_d -> bigdecimal
+ #
+ # Returns self.
+ def to_d
+ self
+ end
+end
+
+# BigDecimal extends the native Rational class to provide the #to_d method.
+#
+# When you require BigDecimal in your application, this method will be
+# available on Rational objects.
+class Rational < Numeric
+ # call-seq:
+ # r.to_d(precision) -> bigdecimal
+ #
+ # Converts a Rational to a BigDecimal.
+ #
+ # The required +precision+ parameter is used to determine the amount of
+ # significant digits for the result. See BigDecimal#div for more information,
+ # as it is used along with the #denominator and the +precision+ for
+ # parameters.
+ #
+ # r = (22/7.0).to_r
+ # # => (7077085128725065/2251799813685248)
+ # r.to_d(3)
+ # # => #<BigDecimal:1a44d08,'0.314E1',18(36)>
+ def to_d(precision)
+ if precision <= 0
+ raise ArgumentError, "negative precision"
+ end
+ num = self.numerator
+ BigDecimal(num).div(self.denominator, precision)
+ end
+end
diff --git a/jni/ruby/ext/bigdecimal/sample/linear.rb b/jni/ruby/ext/bigdecimal/sample/linear.rb
new file mode 100644
index 0000000..a33255f
--- /dev/null
+++ b/jni/ruby/ext/bigdecimal/sample/linear.rb
@@ -0,0 +1,72 @@
+#!/usr/local/bin/ruby
+
+#
+# linear.rb
+#
+# Solves linear equation system(A*x = b) by LU decomposition method.
+# where A is a coefficient matrix,x is an answer vector,b is a constant vector.
+#
+# USAGE:
+# ruby linear.rb [input file solved]
+#
+
+# :stopdoc:
+require "bigdecimal"
+require "bigdecimal/ludcmp"
+
+#
+# NOTE:
+# Change following BigDecimal.limit() if needed.
+BigDecimal.limit(100)
+#
+
+include LUSolve
+def rd_order(na)
+ printf("Number of equations ?") if(na <= 0)
+ n = ARGF.gets().to_i
+end
+
+na = ARGV.size
+zero = BigDecimal.new("0.0")
+one = BigDecimal.new("1.0")
+
+while (n=rd_order(na))>0
+ a = []
+ as= []
+ b = []
+ if na <= 0
+ # Read data from console.
+ printf("\nEnter coefficient matrix element A[i,j]\n");
+ for i in 0...n do
+ for j in 0...n do
+ printf("A[%d,%d]? ",i,j); s = ARGF.gets
+ a << BigDecimal.new(s);
+ as << BigDecimal.new(s);
+ end
+ printf("Contatant vector element b[%d] ? ",i); b << BigDecimal.new(ARGF.gets);
+ end
+ else
+ # Read data from specified file.
+ printf("Coefficient matrix and constant vector.\n");
+ for i in 0...n do
+ s = ARGF.gets
+ printf("%d) %s",i,s)
+ s = s.split
+ for j in 0...n do
+ a << BigDecimal.new(s[j]);
+ as << BigDecimal.new(s[j]);
+ end
+ b << BigDecimal.new(s[n]);
+ end
+ end
+ x = lusolve(a,b,ludecomp(a,n,zero,one),zero)
+ printf("Answer(x[i] & (A*x-b)[i]) follows\n")
+ for i in 0...n do
+ printf("x[%d]=%s ",i,x[i].to_s)
+ s = zero
+ for j in 0...n do
+ s = s + as[i*n+j]*x[j]
+ end
+ printf(" & %s\n",(s-b[i]).to_s)
+ end
+end
diff --git a/jni/ruby/ext/bigdecimal/sample/nlsolve.rb b/jni/ruby/ext/bigdecimal/sample/nlsolve.rb
new file mode 100644
index 0000000..7fa921c
--- /dev/null
+++ b/jni/ruby/ext/bigdecimal/sample/nlsolve.rb
@@ -0,0 +1,39 @@
+#!/usr/local/bin/ruby
+
+#
+# nlsolve.rb
+# An example for solving nonlinear algebraic equation system.
+#
+
+require "bigdecimal"
+require "bigdecimal/newton"
+include Newton
+
+class Function # :nodoc: all
+ def initialize()
+ @zero = BigDecimal.new("0.0")
+ @one = BigDecimal.new("1.0")
+ @two = BigDecimal.new("2.0")
+ @ten = BigDecimal.new("10.0")
+ @eps = BigDecimal.new("1.0e-16")
+ end
+ def zero;@zero;end
+ def one ;@one ;end
+ def two ;@two ;end
+ def ten ;@ten ;end
+ def eps ;@eps ;end
+ def values(x) # <= defines functions solved
+ f = []
+ f1 = x[0]*x[0] + x[1]*x[1] - @two # f1 = x**2 + y**2 - 2 => 0
+ f2 = x[0] - x[1] # f2 = x - y => 0
+ f <<= f1
+ f <<= f2
+ f
+ end
+end
+
+f = BigDecimal.limit(100)
+f = Function.new
+x = [f.zero,f.zero] # Initial values
+n = nlsolve(f,x)
+p x
diff --git a/jni/ruby/ext/bigdecimal/sample/pi.rb b/jni/ruby/ext/bigdecimal/sample/pi.rb
new file mode 100644
index 0000000..2f7dd27
--- /dev/null
+++ b/jni/ruby/ext/bigdecimal/sample/pi.rb
@@ -0,0 +1,20 @@
+#!/usr/local/bin/ruby
+
+#
+# pi.rb
+#
+# Calculates 3.1415.... (the number of times that a circle's diameter
+# will fit around the circle) using J. Machin's formula.
+#
+
+require "bigdecimal"
+require "bigdecimal/math.rb"
+
+include BigMath
+
+if ARGV.size == 1
+ print "PI("+ARGV[0]+"):\n"
+ p PI(ARGV[0].to_i)
+else
+ print "TRY: ruby pi.rb 1000 \n"
+end
diff --git a/jni/ruby/ext/continuation/Makefile b/jni/ruby/ext/continuation/Makefile
new file mode 100644
index 0000000..17e4d19
--- /dev/null
+++ b/jni/ruby/ext/continuation/Makefile
@@ -0,0 +1,267 @@
+
+SHELL = /bin/sh
+
+# V=0 quiet, V=1 verbose. other values don't work.
+V = 0
+Q1 = $(V:1=)
+Q = $(Q1:0=@)
+ECHO1 = $(V:1=@:)
+ECHO = $(ECHO1:0=@echo)
+NULLCMD = :
+
+#### Start of system configuration section. ####
+top_srcdir = $(topdir)/.
+srcdir = $(top_srcdir)/ext/continuation
+topdir = ../..
+hdrdir = $(top_srcdir)/include
+arch_hdrdir = $(extout)/include/$(arch)
+PATH_SEPARATOR = :
+VPATH = $(srcdir):$(arch_hdrdir)/ruby:$(hdrdir)/ruby
+RUBYLIB =
+RUBYOPT = -
+prefix = $(DESTDIR)/usr/local
+rubysitearchprefix = $(rubylibprefix)/$(sitearch)
+rubyarchprefix = $(rubylibprefix)/$(arch)
+rubylibprefix = $(libdir)/$(RUBY_BASE_NAME)
+exec_prefix = $(prefix)
+vendorarchhdrdir = $(vendorhdrdir)/$(sitearch)
+sitearchhdrdir = $(sitehdrdir)/$(sitearch)
+rubyarchhdrdir = $(rubyhdrdir)/$(arch)
+vendorhdrdir = $(rubyhdrdir)/vendor_ruby
+sitehdrdir = $(rubyhdrdir)/site_ruby
+rubyhdrdir = $(includedir)/$(RUBY_VERSION_NAME)
+vendorarchdir = $(vendorlibdir)/$(sitearch)
+vendorlibdir = $(vendordir)/$(ruby_version)
+vendordir = $(rubylibprefix)/vendor_ruby
+sitearchdir = $(sitelibdir)/$(sitearch)
+sitelibdir = $(sitedir)/$(ruby_version)
+sitedir = $(rubylibprefix)/site_ruby
+rubyarchdir = $(rubylibdir)/$(arch)
+rubylibdir = $(rubylibprefix)/$(ruby_version)
+sitearchincludedir = $(includedir)/$(sitearch)
+archincludedir = $(includedir)/$(arch)
+sitearchlibdir = $(libdir)/$(sitearch)
+archlibdir = $(libdir)/$(arch)
+ridir = $(datarootdir)/$(RI_BASE_NAME)
+mandir = $(datarootdir)/man
+localedir = $(datarootdir)/locale
+libdir = $(exec_prefix)/lib
+psdir = $(docdir)
+pdfdir = $(docdir)
+dvidir = $(docdir)
+htmldir = $(docdir)
+infodir = $(datarootdir)/info
+docdir = $(datarootdir)/doc/$(PACKAGE)
+oldincludedir = $(DESTDIR)/usr/include
+includedir = $(prefix)/include
+localstatedir = $(prefix)/var
+sharedstatedir = $(prefix)/com
+sysconfdir = $(prefix)/etc
+datadir = $(datarootdir)
+datarootdir = $(prefix)/share
+libexecdir = $(exec_prefix)/libexec
+sbindir = $(exec_prefix)/sbin
+bindir = $(exec_prefix)/bin
+archdir = $(rubyarchdir)
+
+
+CC = gcc
+CXX = g++
+LIBRUBY = $(LIBRUBY_SO)
+LIBRUBY_A = lib$(RUBY_SO_NAME)-static.a
+LIBRUBYARG_SHARED = -Wl,-R$(libdir) -L$(libdir) -l$(RUBY_SO_NAME)
+LIBRUBYARG_STATIC = -Wl,-R$(libdir) -L$(libdir) -l$(RUBY_SO_NAME)-static
+empty =
+OUTFLAG = -o $(empty)
+COUTFLAG = -o $(empty)
+
+RUBY_EXTCONF_H = extconf.h
+cflags = $(optflags) $(debugflags) $(warnflags)
+optflags = -O3 -fno-fast-math
+debugflags = -ggdb3
+warnflags = -Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wunused-variable -Wpointer-arith -Wwrite-strings -Wdeclaration-after-statement -Wimplicit-function-declaration -Wdeprecated-declarations -Wno-packed-bitfield-compat
+CCDLFLAGS = -fPIC
+CFLAGS = $(CCDLFLAGS) $(cflags) -fPIC $(ARCH_FLAG)
+INCFLAGS = -I. -I$(arch_hdrdir) -I$(hdrdir) -I$(srcdir)
+DEFS =
+CPPFLAGS = -DRUBY_EXTCONF_H=\"$(RUBY_EXTCONF_H)\" $(DEFS) $(cppflags)
+CXXFLAGS = $(CCDLFLAGS) $(cxxflags) $(ARCH_FLAG)
+ldflags = -L. -fstack-protector -rdynamic -Wl,-export-dynamic
+dldflags =
+ARCH_FLAG =
+DLDFLAGS = $(ldflags) $(dldflags) $(ARCH_FLAG)
+LDSHARED = $(CC) -shared
+LDSHAREDXX = $(CXX) -shared
+AR = ar
+EXEEXT =
+
+RUBY_INSTALL_NAME = $(RUBY_BASE_NAME)
+RUBY_SO_NAME = ruby
+RUBYW_INSTALL_NAME =
+RUBY_VERSION_NAME = $(RUBY_BASE_NAME)-$(ruby_version)
+RUBYW_BASE_NAME = rubyw
+RUBY_BASE_NAME = ruby
+
+arch = x86_64-linux
+sitearch = $(arch)
+ruby_version = 2.2.0
+ruby = $(topdir)/miniruby -I'$(topdir)' -I'$(top_srcdir)/lib' -I'$(extout)/$(arch)' -I'$(extout)/common'
+RUBY = $(ruby)
+ruby_headers = $(hdrdir)/ruby.h $(hdrdir)/ruby/ruby.h $(hdrdir)/ruby/defines.h $(hdrdir)/ruby/missing.h $(hdrdir)/ruby/intern.h $(hdrdir)/ruby/st.h $(hdrdir)/ruby/subst.h $(arch_hdrdir)/ruby/config.h $(RUBY_EXTCONF_H)
+
+RM = rm -f
+RM_RF = $(RUBY) -run -e rm -- -rf
+RMDIRS = rmdir --ignore-fail-on-non-empty -p
+MAKEDIRS = /bin/mkdir -p
+INSTALL = /usr/bin/install -c
+INSTALL_PROG = $(INSTALL) -m 0755
+INSTALL_DATA = $(INSTALL) -m 644
+COPY = cp
+TOUCH = exit >
+
+#### End of system configuration section. ####
+
+preload =
+
+libpath = . $(topdir)
+LIBPATH = -L. -L$(topdir)
+DEFFILE =
+
+CLEANFILES = mkmf.log
+DISTCLEANFILES =
+DISTCLEANDIRS =
+
+extout = $(topdir)/.ext
+extout_prefix = $(extout)$(target_prefix)/
+target_prefix =
+LOCAL_LIBS =
+LIBS = $(LIBRUBYARG_SHARED) -lpthread -lgmp -ldl -lcrypt -lm -lc
+ORIG_SRCS = continuation.c
+SRCS = $(ORIG_SRCS)
+OBJS = continuation.o
+HDRS = $(srcdir)/extconf.h
+TARGET = continuation
+TARGET_NAME = continuation
+TARGET_ENTRY = Init_$(TARGET_NAME)
+DLLIB = $(TARGET).so
+EXTSTATIC =
+STATIC_LIB = $(TARGET).a
+
+TIMESTAMP_DIR = $(extout)/.timestamp
+BINDIR = $(extout)/bin
+RUBYCOMMONDIR = $(extout)/common
+RUBYLIBDIR = $(RUBYCOMMONDIR)$(target_prefix)
+RUBYARCHDIR = $(extout)/$(arch)$(target_prefix)
+HDRDIR = $(extout)/include/ruby$(target_prefix)
+ARCHHDRDIR = $(extout)/include/$(arch)/ruby$(target_prefix)
+
+TARGET_SO = $(RUBYARCHDIR)/$(DLLIB)
+CLEANLIBS = $(RUBYARCHDIR)/$(TARGET).so
+CLEANOBJS = *.o *.bak
+
+all: install
+static: all
+.PHONY: all install static install-so install-rb
+.PHONY: clean clean-so clean-static clean-rb
+
+clean-static::
+clean-rb-default::
+clean-rb::
+clean-so::
+clean: clean-so clean-static clean-rb-default clean-rb
+ -$(Q)$(RM) $(CLEANLIBS) $(CLEANOBJS) $(CLEANFILES) .*.time
+
+distclean-rb-default::
+distclean-rb::
+distclean-so::
+distclean-static::
+distclean: clean distclean-so distclean-static distclean-rb-default distclean-rb
+ -$(Q)$(RM) Makefile $(RUBY_EXTCONF_H) conftest.* mkmf.log
+ -$(Q)$(RM) core ruby$(EXEEXT) *~ $(DISTCLEANFILES)
+ -$(Q)$(RMDIRS) $(DISTCLEANDIRS) 2> /dev/null || true
+
+realclean: distclean
+install: install-so install-rb
+
+install-so: $(RUBYARCHDIR)/$(DLLIB)
+clean-so::
+ -$(Q)$(RM) $(RUBYARCHDIR)/$(DLLIB)
+ -$(Q)$(RMDIRS) $(RUBYARCHDIR) 2> /dev/null || true
+clean-static::
+ -$(Q)$(RM) $(STATIC_LIB)
+install-rb: pre-install-rb install-rb-default
+install-rb-default: pre-install-rb-default
+pre-install-rb: Makefile
+pre-install-rb-default: Makefile
+pre-install-rb-default:
+ @$(NULLCMD)
+$(TIMESTAMP_DIR)/.RUBYARCHDIR.time:
+ $(Q) $(MAKEDIRS) $(@D) $(RUBYARCHDIR)
+ $(Q) $(TOUCH) $@
+
+site-install: site-install-so site-install-rb
+site-install-so: install-so
+site-install-rb: install-rb
+
+.SUFFIXES: .c .m .cc .mm .cxx .cpp .o .S
+
+.cc.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<
+
+.cc.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -S $<
+
+.mm.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<
+
+.mm.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -S $<
+
+.cxx.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<
+
+.cxx.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -S $<
+
+.cpp.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<
+
+.cpp.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -S $<
+
+.c.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -c $<
+
+.c.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -S $<
+
+.m.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -c $<
+
+.m.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -S $<
+
+$(RUBYARCHDIR)/$(DLLIB): $(OBJS) Makefile $(TIMESTAMP_DIR)/.RUBYARCHDIR.time
+ $(ECHO) linking shared-object $(DLLIB)
+ -$(Q)$(RM) $(@)
+ $(Q) $(LDSHARED) -o $@ $(OBJS) $(LIBPATH) $(DLDFLAGS) $(LOCAL_LIBS) $(LIBS)
+
+$(STATIC_LIB): $(OBJS)
+ -$(Q)$(RM) $(@)
+ $(ECHO) linking static-library $(@)
+ $(Q) $(AR) cru $@ $(OBJS)
+ -$(Q)ranlib $(@) 2> /dev/null || true
+
+$(OBJS): $(HDRS) $(ruby_headers)
diff --git a/jni/ruby/ext/continuation/continuation.c b/jni/ruby/ext/continuation/continuation.c
new file mode 100644
index 0000000..c678371
--- /dev/null
+++ b/jni/ruby/ext/continuation/continuation.c
@@ -0,0 +1,13 @@
+
+#include "ruby/ruby.h"
+
+void ruby_Init_Continuation_body(void);
+
+void
+Init_continuation(void)
+{
+#ifndef RUBY_EXPORT
+ rb_warn("callcc is obsolete; use Fiber instead");
+#endif
+ ruby_Init_Continuation_body();
+}
diff --git a/jni/ruby/ext/continuation/extconf.h b/jni/ruby/ext/continuation/extconf.h
new file mode 100644
index 0000000..cda0cc8
--- /dev/null
+++ b/jni/ruby/ext/continuation/extconf.h
@@ -0,0 +1,3 @@
+#ifndef EXTCONF_H
+#define EXTCONF_H
+#endif
diff --git a/jni/ruby/ext/continuation/extconf.rb b/jni/ruby/ext/continuation/extconf.rb
new file mode 100644
index 0000000..17e2d05
--- /dev/null
+++ b/jni/ruby/ext/continuation/extconf.rb
@@ -0,0 +1,3 @@
+require 'mkmf'
+create_makefile('continuation')
+
diff --git a/jni/ruby/ext/coverage/Makefile b/jni/ruby/ext/coverage/Makefile
new file mode 100644
index 0000000..6df0023
--- /dev/null
+++ b/jni/ruby/ext/coverage/Makefile
@@ -0,0 +1,310 @@
+
+SHELL = /bin/sh
+
+# V=0 quiet, V=1 verbose. other values don't work.
+V = 0
+Q1 = $(V:1=)
+Q = $(Q1:0=@)
+ECHO1 = $(V:1=@:)
+ECHO = $(ECHO1:0=@echo)
+NULLCMD = :
+
+#### Start of system configuration section. ####
+top_srcdir = $(topdir)/.
+srcdir = $(top_srcdir)/ext/coverage
+topdir = ../..
+hdrdir = $(top_srcdir)/include
+arch_hdrdir = $(extout)/include/$(arch)
+PATH_SEPARATOR = :
+VPATH = $(srcdir):$(arch_hdrdir)/ruby:$(hdrdir)/ruby:$(topdir):$(top_srcdir)
+RUBYLIB =
+RUBYOPT = -
+prefix = $(DESTDIR)/usr/local
+rubysitearchprefix = $(rubylibprefix)/$(sitearch)
+rubyarchprefix = $(rubylibprefix)/$(arch)
+rubylibprefix = $(libdir)/$(RUBY_BASE_NAME)
+exec_prefix = $(prefix)
+vendorarchhdrdir = $(vendorhdrdir)/$(sitearch)
+sitearchhdrdir = $(sitehdrdir)/$(sitearch)
+rubyarchhdrdir = $(rubyhdrdir)/$(arch)
+vendorhdrdir = $(rubyhdrdir)/vendor_ruby
+sitehdrdir = $(rubyhdrdir)/site_ruby
+rubyhdrdir = $(includedir)/$(RUBY_VERSION_NAME)
+vendorarchdir = $(vendorlibdir)/$(sitearch)
+vendorlibdir = $(vendordir)/$(ruby_version)
+vendordir = $(rubylibprefix)/vendor_ruby
+sitearchdir = $(sitelibdir)/$(sitearch)
+sitelibdir = $(sitedir)/$(ruby_version)
+sitedir = $(rubylibprefix)/site_ruby
+rubyarchdir = $(rubylibdir)/$(arch)
+rubylibdir = $(rubylibprefix)/$(ruby_version)
+sitearchincludedir = $(includedir)/$(sitearch)
+archincludedir = $(includedir)/$(arch)
+sitearchlibdir = $(libdir)/$(sitearch)
+archlibdir = $(libdir)/$(arch)
+ridir = $(datarootdir)/$(RI_BASE_NAME)
+mandir = $(datarootdir)/man
+localedir = $(datarootdir)/locale
+libdir = $(exec_prefix)/lib
+psdir = $(docdir)
+pdfdir = $(docdir)
+dvidir = $(docdir)
+htmldir = $(docdir)
+infodir = $(datarootdir)/info
+docdir = $(datarootdir)/doc/$(PACKAGE)
+oldincludedir = $(DESTDIR)/usr/include
+includedir = $(prefix)/include
+localstatedir = $(prefix)/var
+sharedstatedir = $(prefix)/com
+sysconfdir = $(prefix)/etc
+datadir = $(datarootdir)
+datarootdir = $(prefix)/share
+libexecdir = $(exec_prefix)/libexec
+sbindir = $(exec_prefix)/sbin
+bindir = $(exec_prefix)/bin
+archdir = $(rubyarchdir)
+
+
+CC = gcc
+CXX = g++
+LIBRUBY = $(LIBRUBY_SO)
+LIBRUBY_A = lib$(RUBY_SO_NAME)-static.a
+LIBRUBYARG_SHARED = -Wl,-R$(libdir) -L$(libdir) -l$(RUBY_SO_NAME)
+LIBRUBYARG_STATIC = -Wl,-R$(libdir) -L$(libdir) -l$(RUBY_SO_NAME)-static
+empty =
+OUTFLAG = -o $(empty)
+COUTFLAG = -o $(empty)
+
+RUBY_EXTCONF_H = extconf.h
+cflags = $(optflags) $(debugflags) $(warnflags)
+optflags = -O3 -fno-fast-math
+debugflags = -ggdb3
+warnflags = -Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wunused-variable -Wpointer-arith -Wwrite-strings -Wdeclaration-after-statement -Wimplicit-function-declaration -Wdeprecated-declarations -Wno-packed-bitfield-compat
+CCDLFLAGS = -fPIC
+CFLAGS = $(CCDLFLAGS) $(cflags) -fPIC $(ARCH_FLAG)
+INCFLAGS = -I. -I$(arch_hdrdir) -I$(hdrdir) -I$(srcdir) -I$(topdir) -I$(top_srcdir)
+DEFS =
+CPPFLAGS = -DRUBY_EXTCONF_H=\"$(RUBY_EXTCONF_H)\" $(DEFS) $(cppflags)
+CXXFLAGS = $(CCDLFLAGS) $(cxxflags) $(ARCH_FLAG)
+ldflags = -L. -fstack-protector -rdynamic -Wl,-export-dynamic
+dldflags =
+ARCH_FLAG =
+DLDFLAGS = $(ldflags) $(dldflags) $(ARCH_FLAG)
+LDSHARED = $(CC) -shared
+LDSHAREDXX = $(CXX) -shared
+AR = ar
+EXEEXT =
+
+RUBY_INSTALL_NAME = $(RUBY_BASE_NAME)
+RUBY_SO_NAME = ruby
+RUBYW_INSTALL_NAME =
+RUBY_VERSION_NAME = $(RUBY_BASE_NAME)-$(ruby_version)
+RUBYW_BASE_NAME = rubyw
+RUBY_BASE_NAME = ruby
+
+arch = x86_64-linux
+sitearch = $(arch)
+ruby_version = 2.2.0
+ruby = $(topdir)/miniruby -I'$(topdir)' -I'$(top_srcdir)/lib' -I'$(extout)/$(arch)' -I'$(extout)/common'
+RUBY = $(ruby)
+ruby_headers = $(hdrdir)/ruby.h $(hdrdir)/ruby/ruby.h $(hdrdir)/ruby/defines.h $(hdrdir)/ruby/missing.h $(hdrdir)/ruby/intern.h $(hdrdir)/ruby/st.h $(hdrdir)/ruby/subst.h $(arch_hdrdir)/ruby/config.h $(RUBY_EXTCONF_H)
+
+RM = rm -f
+RM_RF = $(RUBY) -run -e rm -- -rf
+RMDIRS = rmdir --ignore-fail-on-non-empty -p
+MAKEDIRS = /bin/mkdir -p
+INSTALL = /usr/bin/install -c
+INSTALL_PROG = $(INSTALL) -m 0755
+INSTALL_DATA = $(INSTALL) -m 644
+COPY = cp
+TOUCH = exit >
+
+#### End of system configuration section. ####
+
+preload =
+
+libpath = . $(topdir)
+LIBPATH = -L. -L$(topdir)
+DEFFILE =
+
+CLEANFILES = mkmf.log
+DISTCLEANFILES =
+DISTCLEANDIRS =
+
+extout = $(topdir)/.ext
+extout_prefix = $(extout)$(target_prefix)/
+target_prefix =
+LOCAL_LIBS =
+LIBS = $(LIBRUBYARG_SHARED) -lpthread -lgmp -ldl -lcrypt -lm -lc
+ORIG_SRCS = coverage.c
+SRCS = $(ORIG_SRCS)
+OBJS = coverage.o
+HDRS = $(srcdir)/extconf.h
+TARGET = coverage
+TARGET_NAME = coverage
+TARGET_ENTRY = Init_$(TARGET_NAME)
+DLLIB = $(TARGET).so
+EXTSTATIC =
+STATIC_LIB = $(TARGET).a
+
+TIMESTAMP_DIR = $(extout)/.timestamp
+BINDIR = $(extout)/bin
+RUBYCOMMONDIR = $(extout)/common
+RUBYLIBDIR = $(RUBYCOMMONDIR)$(target_prefix)
+RUBYARCHDIR = $(extout)/$(arch)$(target_prefix)
+HDRDIR = $(extout)/include/ruby$(target_prefix)
+ARCHHDRDIR = $(extout)/include/$(arch)/ruby$(target_prefix)
+
+TARGET_SO = $(RUBYARCHDIR)/$(DLLIB)
+CLEANLIBS = $(RUBYARCHDIR)/$(TARGET).so
+CLEANOBJS = *.o *.bak
+
+all: install
+static: all
+.PHONY: all install static install-so install-rb
+.PHONY: clean clean-so clean-static clean-rb
+
+clean-static::
+clean-rb-default::
+clean-rb::
+clean-so::
+clean: clean-so clean-static clean-rb-default clean-rb
+ -$(Q)$(RM) $(CLEANLIBS) $(CLEANOBJS) $(CLEANFILES) .*.time
+
+distclean-rb-default::
+distclean-rb::
+distclean-so::
+distclean-static::
+distclean: clean distclean-so distclean-static distclean-rb-default distclean-rb
+ -$(Q)$(RM) Makefile $(RUBY_EXTCONF_H) conftest.* mkmf.log
+ -$(Q)$(RM) core ruby$(EXEEXT) *~ $(DISTCLEANFILES)
+ -$(Q)$(RMDIRS) $(DISTCLEANDIRS) 2> /dev/null || true
+
+realclean: distclean
+install: install-so install-rb
+
+install-so: $(RUBYARCHDIR)/$(DLLIB)
+clean-so::
+ -$(Q)$(RM) $(RUBYARCHDIR)/$(DLLIB)
+ -$(Q)$(RMDIRS) $(RUBYARCHDIR) 2> /dev/null || true
+clean-static::
+ -$(Q)$(RM) $(STATIC_LIB)
+install-rb: pre-install-rb install-rb-default
+install-rb-default: pre-install-rb-default
+pre-install-rb: Makefile
+pre-install-rb-default: Makefile
+pre-install-rb-default:
+ @$(NULLCMD)
+$(TIMESTAMP_DIR)/.RUBYARCHDIR.time:
+ $(Q) $(MAKEDIRS) $(@D) $(RUBYARCHDIR)
+ $(Q) $(TOUCH) $@
+
+site-install: site-install-so site-install-rb
+site-install-so: install-so
+site-install-rb: install-rb
+
+.SUFFIXES: .c .m .cc .mm .cxx .cpp .o .S
+
+.cc.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<
+
+.cc.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -S $<
+
+.mm.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<
+
+.mm.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -S $<
+
+.cxx.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<
+
+.cxx.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -S $<
+
+.cpp.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<
+
+.cpp.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -S $<
+
+.c.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -c $<
+
+.c.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -S $<
+
+.m.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -c $<
+
+.m.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -S $<
+
+$(RUBYARCHDIR)/$(DLLIB): $(OBJS) Makefile $(TIMESTAMP_DIR)/.RUBYARCHDIR.time
+ $(ECHO) linking shared-object $(DLLIB)
+ -$(Q)$(RM) $(@)
+ $(Q) $(LDSHARED) -o $@ $(OBJS) $(LIBPATH) $(DLDFLAGS) $(LOCAL_LIBS) $(LIBS)
+
+$(STATIC_LIB): $(OBJS)
+ -$(Q)$(RM) $(@)
+ $(ECHO) linking static-library $(@)
+ $(Q) $(AR) cru $@ $(OBJS)
+ -$(Q)ranlib $(@) 2> /dev/null || true
+
+###
+$(OBJS): $(RUBY_EXTCONF_H)
+
+$(OBJS): $(HDRS) $(ruby_headers) \
+ $(top_srcdir)/vm_core.h \
+ $(top_srcdir)/node.h \
+ $(top_srcdir)/vm_debug.h \
+ $(top_srcdir)/vm_opts.h \
+ id.h \
+ $(top_srcdir)/method.h \
+ $(top_srcdir)/ruby_atomic.h \
+ $(top_srcdir)/thread_pthread.h \
+ $(top_srcdir)/internal.h \
+ $(top_srcdir)/include/ruby/thread_native.h
+
+# AUTOGENERATED DEPENDENCIES START
+coverage.o: $(RUBY_EXTCONF_H)
+coverage.o: $(arch_hdrdir)/ruby/config.h
+coverage.o: $(hdrdir)/ruby/defines.h
+coverage.o: $(hdrdir)/ruby/encoding.h
+coverage.o: $(hdrdir)/ruby/intern.h
+coverage.o: $(hdrdir)/ruby/io.h
+coverage.o: $(hdrdir)/ruby/missing.h
+coverage.o: $(hdrdir)/ruby/oniguruma.h
+coverage.o: $(hdrdir)/ruby/ruby.h
+coverage.o: $(hdrdir)/ruby/st.h
+coverage.o: $(hdrdir)/ruby/subst.h
+coverage.o: $(hdrdir)/ruby/thread_native.h
+coverage.o: $(top_srcdir)/ccan/check_type/check_type.h
+coverage.o: $(top_srcdir)/ccan/container_of/container_of.h
+coverage.o: $(top_srcdir)/ccan/list/list.h
+coverage.o: $(top_srcdir)/ccan/str/str.h
+coverage.o: $(top_srcdir)/include/ruby.h
+coverage.o: $(top_srcdir)/internal.h
+coverage.o: $(top_srcdir)/method.h
+coverage.o: $(top_srcdir)/node.h
+coverage.o: $(top_srcdir)/ruby_atomic.h
+coverage.o: $(top_srcdir)/thread_pthread.h
+coverage.o: $(top_srcdir)/vm_core.h
+coverage.o: $(top_srcdir)/vm_debug.h
+coverage.o: $(top_srcdir)/vm_opts.h
+coverage.o: coverage.c
+coverage.o: id.h
+# AUTOGENERATED DEPENDENCIES END
diff --git a/jni/ruby/ext/coverage/coverage.c b/jni/ruby/ext/coverage/coverage.c
new file mode 100644
index 0000000..93cb2a5
--- /dev/null
+++ b/jni/ruby/ext/coverage/coverage.c
@@ -0,0 +1,109 @@
+/************************************************
+
+ coverage.c -
+
+ $Author: $
+
+ Copyright (c) 2008 Yusuke Endoh
+
+************************************************/
+
+#include "ruby.h"
+#include "vm_core.h"
+
+static VALUE rb_coverages = Qundef;
+
+/*
+ * call-seq:
+ * Coverage.start => nil
+ *
+ * Enables coverage measurement.
+ */
+static VALUE
+rb_coverage_start(VALUE klass)
+{
+ if (!RTEST(rb_get_coverages())) {
+ if (rb_coverages == Qundef) {
+ rb_coverages = rb_hash_new();
+ rb_obj_hide(rb_coverages);
+ }
+ rb_set_coverages(rb_coverages);
+ }
+ return Qnil;
+}
+
+static int
+coverage_result_i(st_data_t key, st_data_t val, st_data_t h)
+{
+ VALUE path = (VALUE)key;
+ VALUE coverage = (VALUE)val;
+ VALUE coverages = (VALUE)h;
+ coverage = rb_ary_dup(coverage);
+ rb_ary_clear((VALUE)val);
+ rb_ary_freeze(coverage);
+ rb_hash_aset(coverages, path, coverage);
+ return ST_CONTINUE;
+}
+
+/*
+ * call-seq:
+ * Coverage.result => hash
+ *
+ * Returns a hash that contains filename as key and coverage array as value
+ * and disables coverage measurement.
+ */
+static VALUE
+rb_coverage_result(VALUE klass)
+{
+ VALUE coverages = rb_get_coverages();
+ VALUE ncoverages = rb_hash_new();
+ if (!RTEST(coverages)) {
+ rb_raise(rb_eRuntimeError, "coverage measurement is not enabled");
+ }
+ st_foreach(RHASH_TBL(coverages), coverage_result_i, ncoverages);
+ rb_hash_freeze(ncoverages);
+ rb_reset_coverages();
+ return ncoverages;
+}
+
+/* Coverage provides coverage measurement feature for Ruby.
+ * This feature is experimental, so these APIs may be changed in future.
+ *
+ * = Usage
+ *
+ * 1. require "coverage.so"
+ * 2. do Coverage.start
+ * 3. require or load Ruby source file
+ * 4. Coverage.result will return a hash that contains filename as key and
+ * coverage array as value. A coverage array gives, for each line, the
+ * number of line execution by the interpreter. A +nil+ value means
+ * coverage is disabled for this line (lines like +else+ and +end+).
+ *
+ * = Example
+ *
+ * [foo.rb]
+ * s = 0
+ * 10.times do |x|
+ * s += x
+ * end
+ *
+ * if s == 45
+ * p :ok
+ * else
+ * p :ng
+ * end
+ * [EOF]
+ *
+ * require "coverage.so"
+ * Coverage.start
+ * require "foo.rb"
+ * p Coverage.result #=> {"foo.rb"=>[1, 1, 10, nil, nil, 1, 1, nil, 0, nil]}
+ */
+void
+Init_coverage(void)
+{
+ VALUE rb_mCoverage = rb_define_module("Coverage");
+ rb_define_module_function(rb_mCoverage, "start", rb_coverage_start, 0);
+ rb_define_module_function(rb_mCoverage, "result", rb_coverage_result, 0);
+ rb_gc_register_address(&rb_coverages);
+}
diff --git a/jni/ruby/ext/coverage/depend b/jni/ruby/ext/coverage/depend
new file mode 100644
index 0000000..04eaf10
--- /dev/null
+++ b/jni/ruby/ext/coverage/depend
@@ -0,0 +1,41 @@
+$(OBJS): $(HDRS) $(ruby_headers) \
+ $(top_srcdir)/vm_core.h \
+ $(top_srcdir)/node.h \
+ $(top_srcdir)/vm_debug.h \
+ $(top_srcdir)/vm_opts.h \
+ {$(VPATH)}id.h \
+ $(top_srcdir)/method.h \
+ $(top_srcdir)/ruby_atomic.h \
+ $(top_srcdir)/thread_pthread.h \
+ $(top_srcdir)/internal.h \
+ $(top_srcdir)/include/ruby/thread_native.h
+
+# AUTOGENERATED DEPENDENCIES START
+coverage.o: $(RUBY_EXTCONF_H)
+coverage.o: $(arch_hdrdir)/ruby/config.h
+coverage.o: $(hdrdir)/ruby/defines.h
+coverage.o: $(hdrdir)/ruby/encoding.h
+coverage.o: $(hdrdir)/ruby/intern.h
+coverage.o: $(hdrdir)/ruby/io.h
+coverage.o: $(hdrdir)/ruby/missing.h
+coverage.o: $(hdrdir)/ruby/oniguruma.h
+coverage.o: $(hdrdir)/ruby/ruby.h
+coverage.o: $(hdrdir)/ruby/st.h
+coverage.o: $(hdrdir)/ruby/subst.h
+coverage.o: $(hdrdir)/ruby/thread_native.h
+coverage.o: $(top_srcdir)/ccan/check_type/check_type.h
+coverage.o: $(top_srcdir)/ccan/container_of/container_of.h
+coverage.o: $(top_srcdir)/ccan/list/list.h
+coverage.o: $(top_srcdir)/ccan/str/str.h
+coverage.o: $(top_srcdir)/include/ruby.h
+coverage.o: $(top_srcdir)/internal.h
+coverage.o: $(top_srcdir)/method.h
+coverage.o: $(top_srcdir)/node.h
+coverage.o: $(top_srcdir)/ruby_atomic.h
+coverage.o: $(top_srcdir)/thread_pthread.h
+coverage.o: $(top_srcdir)/vm_core.h
+coverage.o: $(top_srcdir)/vm_debug.h
+coverage.o: $(top_srcdir)/vm_opts.h
+coverage.o: coverage.c
+coverage.o: {$(VPATH)}id.h
+# AUTOGENERATED DEPENDENCIES END
diff --git a/jni/ruby/ext/coverage/extconf.h b/jni/ruby/ext/coverage/extconf.h
new file mode 100644
index 0000000..cda0cc8
--- /dev/null
+++ b/jni/ruby/ext/coverage/extconf.h
@@ -0,0 +1,3 @@
+#ifndef EXTCONF_H
+#define EXTCONF_H
+#endif
diff --git a/jni/ruby/ext/coverage/extconf.rb b/jni/ruby/ext/coverage/extconf.rb
new file mode 100644
index 0000000..769f85b
--- /dev/null
+++ b/jni/ruby/ext/coverage/extconf.rb
@@ -0,0 +1,4 @@
+require 'mkmf'
+$VPATH << '$(topdir)' << '$(top_srcdir)'
+$INCFLAGS << " -I$(topdir) -I$(top_srcdir)"
+create_makefile('coverage')
diff --git a/jni/ruby/ext/date/Makefile b/jni/ruby/ext/date/Makefile
new file mode 100644
index 0000000..066cc6a
--- /dev/null
+++ b/jni/ruby/ext/date/Makefile
@@ -0,0 +1,333 @@
+
+SHELL = /bin/sh
+
+# V=0 quiet, V=1 verbose. other values don't work.
+V = 0
+Q1 = $(V:1=)
+Q = $(Q1:0=@)
+ECHO1 = $(V:1=@:)
+ECHO = $(ECHO1:0=@echo)
+NULLCMD = :
+
+#### Start of system configuration section. ####
+top_srcdir = $(topdir)/.
+srcdir = $(top_srcdir)/ext/date
+topdir = ../..
+hdrdir = $(top_srcdir)/include
+arch_hdrdir = $(extout)/include/$(arch)
+PATH_SEPARATOR = :
+VPATH = $(srcdir):$(arch_hdrdir)/ruby:$(hdrdir)/ruby
+RUBYLIB =
+RUBYOPT = -
+prefix = $(DESTDIR)/usr/local
+rubysitearchprefix = $(rubylibprefix)/$(sitearch)
+rubyarchprefix = $(rubylibprefix)/$(arch)
+rubylibprefix = $(libdir)/$(RUBY_BASE_NAME)
+exec_prefix = $(prefix)
+vendorarchhdrdir = $(vendorhdrdir)/$(sitearch)
+sitearchhdrdir = $(sitehdrdir)/$(sitearch)
+rubyarchhdrdir = $(rubyhdrdir)/$(arch)
+vendorhdrdir = $(rubyhdrdir)/vendor_ruby
+sitehdrdir = $(rubyhdrdir)/site_ruby
+rubyhdrdir = $(includedir)/$(RUBY_VERSION_NAME)
+vendorarchdir = $(vendorlibdir)/$(sitearch)
+vendorlibdir = $(vendordir)/$(ruby_version)
+vendordir = $(rubylibprefix)/vendor_ruby
+sitearchdir = $(sitelibdir)/$(sitearch)
+sitelibdir = $(sitedir)/$(ruby_version)
+sitedir = $(rubylibprefix)/site_ruby
+rubyarchdir = $(rubylibdir)/$(arch)
+rubylibdir = $(rubylibprefix)/$(ruby_version)
+sitearchincludedir = $(includedir)/$(sitearch)
+archincludedir = $(includedir)/$(arch)
+sitearchlibdir = $(libdir)/$(sitearch)
+archlibdir = $(libdir)/$(arch)
+ridir = $(datarootdir)/$(RI_BASE_NAME)
+mandir = $(datarootdir)/man
+localedir = $(datarootdir)/locale
+libdir = $(exec_prefix)/lib
+psdir = $(docdir)
+pdfdir = $(docdir)
+dvidir = $(docdir)
+htmldir = $(docdir)
+infodir = $(datarootdir)/info
+docdir = $(datarootdir)/doc/$(PACKAGE)
+oldincludedir = $(DESTDIR)/usr/include
+includedir = $(prefix)/include
+localstatedir = $(prefix)/var
+sharedstatedir = $(prefix)/com
+sysconfdir = $(prefix)/etc
+datadir = $(datarootdir)
+datarootdir = $(prefix)/share
+libexecdir = $(exec_prefix)/libexec
+sbindir = $(exec_prefix)/sbin
+bindir = $(exec_prefix)/bin
+archdir = $(rubyarchdir)
+
+
+CC = gcc
+CXX = g++
+LIBRUBY = $(LIBRUBY_SO)
+LIBRUBY_A = lib$(RUBY_SO_NAME)-static.a
+LIBRUBYARG_SHARED = -Wl,-R$(libdir) -L$(libdir) -l$(RUBY_SO_NAME)
+LIBRUBYARG_STATIC = -Wl,-R$(libdir) -L$(libdir) -l$(RUBY_SO_NAME)-static
+empty =
+OUTFLAG = -o $(empty)
+COUTFLAG = -o $(empty)
+
+RUBY_EXTCONF_H = extconf.h
+cflags = $(optflags) $(debugflags) $(warnflags)
+optflags = -O3 -fno-fast-math
+debugflags = -ggdb3
+warnflags = -Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wunused-variable -Wpointer-arith -Wwrite-strings -Wdeclaration-after-statement -Wimplicit-function-declaration -Wdeprecated-declarations -Wno-packed-bitfield-compat
+CCDLFLAGS = -fPIC
+CFLAGS = $(CCDLFLAGS) $(cflags) -fPIC -std=iso9899:1999 $(ARCH_FLAG)
+INCFLAGS = -I. -I$(arch_hdrdir) -I$(hdrdir) -I$(srcdir)
+DEFS =
+CPPFLAGS = -DRUBY_EXTCONF_H=\"$(RUBY_EXTCONF_H)\" $(DEFS) $(cppflags)
+CXXFLAGS = $(CCDLFLAGS) $(cxxflags) $(ARCH_FLAG)
+ldflags = -L. -fstack-protector -rdynamic -Wl,-export-dynamic
+dldflags =
+ARCH_FLAG =
+DLDFLAGS = $(ldflags) $(dldflags) $(ARCH_FLAG)
+LDSHARED = $(CC) -shared
+LDSHAREDXX = $(CXX) -shared
+AR = ar
+EXEEXT =
+
+RUBY_INSTALL_NAME = $(RUBY_BASE_NAME)
+RUBY_SO_NAME = ruby
+RUBYW_INSTALL_NAME =
+RUBY_VERSION_NAME = $(RUBY_BASE_NAME)-$(ruby_version)
+RUBYW_BASE_NAME = rubyw
+RUBY_BASE_NAME = ruby
+
+arch = x86_64-linux
+sitearch = $(arch)
+ruby_version = 2.2.0
+ruby = $(topdir)/miniruby -I'$(topdir)' -I'$(top_srcdir)/lib' -I'$(extout)/$(arch)' -I'$(extout)/common'
+RUBY = $(ruby)
+ruby_headers = $(hdrdir)/ruby.h $(hdrdir)/ruby/ruby.h $(hdrdir)/ruby/defines.h $(hdrdir)/ruby/missing.h $(hdrdir)/ruby/intern.h $(hdrdir)/ruby/st.h $(hdrdir)/ruby/subst.h $(arch_hdrdir)/ruby/config.h $(RUBY_EXTCONF_H)
+
+RM = rm -f
+RM_RF = $(RUBY) -run -e rm -- -rf
+RMDIRS = rmdir --ignore-fail-on-non-empty -p
+MAKEDIRS = /bin/mkdir -p
+INSTALL = /usr/bin/install -c
+INSTALL_PROG = $(INSTALL) -m 0755
+INSTALL_DATA = $(INSTALL) -m 644
+COPY = cp
+TOUCH = exit >
+
+#### End of system configuration section. ####
+
+preload =
+
+libpath = . $(topdir)
+LIBPATH = -L. -L$(topdir)
+DEFFILE =
+
+CLEANFILES = mkmf.log
+DISTCLEANFILES =
+DISTCLEANDIRS =
+
+extout = $(topdir)/.ext
+extout_prefix = $(extout)$(target_prefix)/
+target_prefix =
+LOCAL_LIBS =
+LIBS = $(LIBRUBYARG_SHARED) -lpthread -lgmp -ldl -lcrypt -lm -lc
+ORIG_SRCS = date_parse.c date_core.c date_strftime.c date_strptime.c
+SRCS = $(ORIG_SRCS)
+OBJS = date_parse.o date_core.o date_strftime.o date_strptime.o
+HDRS = $(srcdir)/extconf.h $(srcdir)/date_tmx.h
+TARGET = date_core
+TARGET_NAME = date_core
+TARGET_ENTRY = Init_$(TARGET_NAME)
+DLLIB = $(TARGET).so
+EXTSTATIC =
+STATIC_LIB = $(TARGET).a
+
+TIMESTAMP_DIR = $(extout)/.timestamp
+BINDIR = $(extout)/bin
+RUBYCOMMONDIR = $(extout)/common
+RUBYLIBDIR = $(RUBYCOMMONDIR)$(target_prefix)
+RUBYARCHDIR = $(extout)/$(arch)$(target_prefix)
+HDRDIR = $(extout)/include/ruby$(target_prefix)
+ARCHHDRDIR = $(extout)/include/$(arch)/ruby$(target_prefix)
+
+TARGET_SO = $(RUBYARCHDIR)/$(DLLIB)
+CLEANLIBS = $(RUBYARCHDIR)/$(TARGET).so
+CLEANOBJS = *.o *.bak
+
+all: install
+static: all
+.PHONY: all install static install-so install-rb
+.PHONY: clean clean-so clean-static clean-rb
+
+clean-static::
+clean-rb-default::
+clean-rb::
+clean-so::
+clean: clean-so clean-static clean-rb-default clean-rb
+ -$(Q)$(RM) $(CLEANLIBS) $(CLEANOBJS) $(CLEANFILES) .*.time
+
+distclean-rb-default::
+distclean-rb::
+distclean-so::
+distclean-static::
+distclean: clean distclean-so distclean-static distclean-rb-default distclean-rb
+ -$(Q)$(RM) Makefile $(RUBY_EXTCONF_H) conftest.* mkmf.log
+ -$(Q)$(RM) core ruby$(EXEEXT) *~ $(DISTCLEANFILES)
+ -$(Q)$(RMDIRS) $(DISTCLEANDIRS) 2> /dev/null || true
+
+realclean: distclean
+install: install-so install-rb
+
+install-so: $(RUBYARCHDIR)/$(DLLIB)
+clean-so::
+ -$(Q)$(RM) $(RUBYARCHDIR)/$(DLLIB)
+ -$(Q)$(RMDIRS) $(RUBYARCHDIR) 2> /dev/null || true
+clean-static::
+ -$(Q)$(RM) $(STATIC_LIB)
+install-rb: pre-install-rb install-rb-default
+install-rb-default: pre-install-rb-default
+pre-install-rb: Makefile
+pre-install-rb-default: Makefile
+pre-install-rb-default: $(TIMESTAMP_DIR)/.RUBYLIBDIR.time
+install-rb-default: $(RUBYLIBDIR)/date.rb
+$(RUBYLIBDIR)/date.rb: $(srcdir)/lib/date.rb $(TIMESTAMP_DIR)/.RUBYLIBDIR.time
+ $(Q) $(COPY) $(srcdir)/lib/date.rb $(@D)
+clean-rb-default::
+ -$(Q)$(RM) $(RUBYLIBDIR)/date.rb
+pre-install-rb-default:
+ $(ECHO) installing default date_core libraries
+clean-rb-default::
+ -$(Q)$(RMDIRS) $(RUBYLIBDIR) 2> /dev/null || true
+$(TIMESTAMP_DIR)/.RUBYARCHDIR.time:
+ $(Q) $(MAKEDIRS) $(@D) $(RUBYARCHDIR)
+ $(Q) $(TOUCH) $@
+$(TIMESTAMP_DIR)/.RUBYLIBDIR.time:
+ $(Q) $(MAKEDIRS) $(@D) $(RUBYLIBDIR)
+ $(Q) $(TOUCH) $@
+
+site-install: site-install-so site-install-rb
+site-install-so: install-so
+site-install-rb: install-rb
+
+.SUFFIXES: .c .m .cc .mm .cxx .cpp .o .S
+
+.cc.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<
+
+.cc.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -S $<
+
+.mm.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<
+
+.mm.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -S $<
+
+.cxx.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<
+
+.cxx.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -S $<
+
+.cpp.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<
+
+.cpp.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -S $<
+
+.c.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -c $<
+
+.c.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -S $<
+
+.m.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -c $<
+
+.m.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -S $<
+
+$(RUBYARCHDIR)/$(DLLIB): $(OBJS) Makefile $(TIMESTAMP_DIR)/.RUBYARCHDIR.time
+ $(ECHO) linking shared-object $(DLLIB)
+ -$(Q)$(RM) $(@)
+ $(Q) $(LDSHARED) -o $@ $(OBJS) $(LIBPATH) $(DLDFLAGS) $(LOCAL_LIBS) $(LIBS)
+
+$(STATIC_LIB): $(OBJS)
+ -$(Q)$(RM) $(@)
+ $(ECHO) linking static-library $(@)
+ $(Q) $(AR) cru $@ $(OBJS)
+ -$(Q)ranlib $(@) 2> /dev/null || true
+
+###
+$(OBJS): $(RUBY_EXTCONF_H)
+
+# AUTOGENERATED DEPENDENCIES START
+date_core.o: $(RUBY_EXTCONF_H)
+date_core.o: $(arch_hdrdir)/ruby/config.h
+date_core.o: $(hdrdir)/ruby/defines.h
+date_core.o: $(hdrdir)/ruby/encoding.h
+date_core.o: $(hdrdir)/ruby/intern.h
+date_core.o: $(hdrdir)/ruby/missing.h
+date_core.o: $(hdrdir)/ruby/oniguruma.h
+date_core.o: $(hdrdir)/ruby/ruby.h
+date_core.o: $(hdrdir)/ruby/st.h
+date_core.o: $(hdrdir)/ruby/subst.h
+date_core.o: $(top_srcdir)/include/ruby.h
+date_core.o: date_core.c
+date_core.o: date_tmx.h
+date_parse.o: $(RUBY_EXTCONF_H)
+date_parse.o: $(arch_hdrdir)/ruby/config.h
+date_parse.o: $(hdrdir)/ruby/defines.h
+date_parse.o: $(hdrdir)/ruby/encoding.h
+date_parse.o: $(hdrdir)/ruby/intern.h
+date_parse.o: $(hdrdir)/ruby/missing.h
+date_parse.o: $(hdrdir)/ruby/oniguruma.h
+date_parse.o: $(hdrdir)/ruby/re.h
+date_parse.o: $(hdrdir)/ruby/regex.h
+date_parse.o: $(hdrdir)/ruby/ruby.h
+date_parse.o: $(hdrdir)/ruby/st.h
+date_parse.o: $(hdrdir)/ruby/subst.h
+date_parse.o: $(top_srcdir)/include/ruby.h
+date_parse.o: date_parse.c
+date_strftime.o: $(RUBY_EXTCONF_H)
+date_strftime.o: $(arch_hdrdir)/ruby/config.h
+date_strftime.o: $(hdrdir)/ruby/defines.h
+date_strftime.o: $(hdrdir)/ruby/intern.h
+date_strftime.o: $(hdrdir)/ruby/missing.h
+date_strftime.o: $(hdrdir)/ruby/ruby.h
+date_strftime.o: $(hdrdir)/ruby/st.h
+date_strftime.o: $(hdrdir)/ruby/subst.h
+date_strftime.o: date_strftime.c
+date_strftime.o: date_tmx.h
+date_strptime.o: $(RUBY_EXTCONF_H)
+date_strptime.o: $(arch_hdrdir)/ruby/config.h
+date_strptime.o: $(hdrdir)/ruby/defines.h
+date_strptime.o: $(hdrdir)/ruby/encoding.h
+date_strptime.o: $(hdrdir)/ruby/intern.h
+date_strptime.o: $(hdrdir)/ruby/missing.h
+date_strptime.o: $(hdrdir)/ruby/oniguruma.h
+date_strptime.o: $(hdrdir)/ruby/re.h
+date_strptime.o: $(hdrdir)/ruby/regex.h
+date_strptime.o: $(hdrdir)/ruby/ruby.h
+date_strptime.o: $(hdrdir)/ruby/st.h
+date_strptime.o: $(hdrdir)/ruby/subst.h
+date_strptime.o: $(top_srcdir)/include/ruby.h
+date_strptime.o: date_strptime.c
+# AUTOGENERATED DEPENDENCIES END
diff --git a/jni/ruby/ext/date/date_core.c b/jni/ruby/ext/date/date_core.c
new file mode 100644
index 0000000..07b65a7
--- /dev/null
+++ b/jni/ruby/ext/date/date_core.c
@@ -0,0 +1,9573 @@
+/*
+ date_core.c: Coded by Tadayoshi Funaba 2010-2014
+*/
+
+#include "ruby.h"
+#include "ruby/encoding.h"
+#include <math.h>
+#include <time.h>
+#if defined(HAVE_SYS_TIME_H)
+#include <sys/time.h>
+#endif
+
+#define NDEBUG
+#include <assert.h>
+
+#ifdef RUBY_EXTCONF_H
+#include RUBY_EXTCONF_H
+#endif
+
+#define USE_PACK
+
+static ID id_cmp, id_le_p, id_ge_p, id_eqeq_p;
+static VALUE cDate, cDateTime;
+static VALUE half_days_in_day, day_in_nanoseconds;
+static double positive_inf, negative_inf;
+
+#define f_boolcast(x) ((x) ? Qtrue : Qfalse)
+
+#define f_abs(x) rb_funcall(x, rb_intern("abs"), 0)
+#define f_negate(x) rb_funcall(x, rb_intern("-@"), 0)
+#define f_add(x,y) rb_funcall(x, '+', 1, y)
+#define f_sub(x,y) rb_funcall(x, '-', 1, y)
+#define f_mul(x,y) rb_funcall(x, '*', 1, y)
+#define f_div(x,y) rb_funcall(x, '/', 1, y)
+#define f_quo(x,y) rb_funcall(x, rb_intern("quo"), 1, y)
+#define f_idiv(x,y) rb_funcall(x, rb_intern("div"), 1, y)
+#define f_mod(x,y) rb_funcall(x, '%', 1, y)
+#define f_remainder(x,y) rb_funcall(x, rb_intern("remainder"), 1, y)
+#define f_expt(x,y) rb_funcall(x, rb_intern("**"), 1, y)
+#define f_floor(x) rb_funcall(x, rb_intern("floor"), 0)
+#define f_ceil(x) rb_funcall(x, rb_intern("ceil"), 0)
+#define f_truncate(x) rb_funcall(x, rb_intern("truncate"), 0)
+#define f_round(x) rb_funcall(x, rb_intern("round"), 0)
+
+#define f_to_i(x) rb_funcall(x, rb_intern("to_i"), 0)
+#define f_to_r(x) rb_funcall(x, rb_intern("to_r"), 0)
+#define f_to_s(x) rb_funcall(x, rb_intern("to_s"), 0)
+#define f_inspect(x) rb_funcall(x, rb_intern("inspect"), 0)
+
+#define f_add3(x,y,z) f_add(f_add(x, y), z)
+#define f_sub3(x,y,z) f_sub(f_sub(x, y), z)
+
+inline static VALUE
+f_cmp(VALUE x, VALUE y)
+{
+ if (FIXNUM_P(x) && FIXNUM_P(y)) {
+ long c = FIX2LONG(x) - FIX2LONG(y);
+ if (c > 0)
+ c = 1;
+ else if (c < 0)
+ c = -1;
+ return INT2FIX(c);
+ }
+ return rb_funcall(x, id_cmp, 1, y);
+}
+
+inline static VALUE
+f_lt_p(VALUE x, VALUE y)
+{
+ if (FIXNUM_P(x) && FIXNUM_P(y))
+ return f_boolcast(FIX2LONG(x) < FIX2LONG(y));
+ return rb_funcall(x, '<', 1, y);
+}
+
+inline static VALUE
+f_gt_p(VALUE x, VALUE y)
+{
+ if (FIXNUM_P(x) && FIXNUM_P(y))
+ return f_boolcast(FIX2LONG(x) > FIX2LONG(y));
+ return rb_funcall(x, '>', 1, y);
+}
+
+inline static VALUE
+f_le_p(VALUE x, VALUE y)
+{
+ if (FIXNUM_P(x) && FIXNUM_P(y))
+ return f_boolcast(FIX2LONG(x) <= FIX2LONG(y));
+ return rb_funcall(x, id_le_p, 1, y);
+}
+
+inline static VALUE
+f_ge_p(VALUE x, VALUE y)
+{
+ if (FIXNUM_P(x) && FIXNUM_P(y))
+ return f_boolcast(FIX2LONG(x) >= FIX2LONG(y));
+ return rb_funcall(x, rb_intern(">="), 1, y);
+}
+
+inline static VALUE
+f_eqeq_p(VALUE x, VALUE y)
+{
+ if (FIXNUM_P(x) && FIXNUM_P(y))
+ return f_boolcast(FIX2LONG(x) == FIX2LONG(y));
+ return rb_funcall(x, rb_intern("=="), 1, y);
+}
+
+inline static VALUE
+f_zero_p(VALUE x)
+{
+ switch (TYPE(x)) {
+ case T_FIXNUM:
+ return f_boolcast(FIX2LONG(x) == 0);
+ case T_BIGNUM:
+ return Qfalse;
+ case T_RATIONAL:
+ {
+ VALUE num = rb_rational_num(x);
+ return f_boolcast(FIXNUM_P(num) && FIX2LONG(num) == 0);
+ }
+ }
+ return rb_funcall(x, id_eqeq_p, 1, INT2FIX(0));
+}
+
+#define f_nonzero_p(x) (!f_zero_p(x))
+
+inline static VALUE
+f_negative_p(VALUE x)
+{
+ if (FIXNUM_P(x))
+ return f_boolcast(FIX2LONG(x) < 0);
+ return rb_funcall(x, '<', 1, INT2FIX(0));
+}
+
+#define f_positive_p(x) (!f_negative_p(x))
+
+#define f_ajd(x) rb_funcall(x, rb_intern("ajd"), 0)
+#define f_jd(x) rb_funcall(x, rb_intern("jd"), 0)
+#define f_year(x) rb_funcall(x, rb_intern("year"), 0)
+#define f_mon(x) rb_funcall(x, rb_intern("mon"), 0)
+#define f_mday(x) rb_funcall(x, rb_intern("mday"), 0)
+#define f_wday(x) rb_funcall(x, rb_intern("wday"), 0)
+#define f_hour(x) rb_funcall(x, rb_intern("hour"), 0)
+#define f_min(x) rb_funcall(x, rb_intern("min"), 0)
+#define f_sec(x) rb_funcall(x, rb_intern("sec"), 0)
+
+/* copied from time.c */
+#define NDIV(x,y) (-(-((x)+1)/(y))-1)
+#define NMOD(x,y) ((y)-(-((x)+1)%(y))-1)
+#define DIV(n,d) ((n)<0 ? NDIV((n),(d)) : (n)/(d))
+#define MOD(n,d) ((n)<0 ? NMOD((n),(d)) : (n)%(d))
+
+#define HAVE_JD (1 << 0)
+#define HAVE_DF (1 << 1)
+#define HAVE_CIVIL (1 << 2)
+#define HAVE_TIME (1 << 3)
+#define COMPLEX_DAT (1 << 7)
+
+#define have_jd_p(x) ((x)->flags & HAVE_JD)
+#define have_df_p(x) ((x)->flags & HAVE_DF)
+#define have_civil_p(x) ((x)->flags & HAVE_CIVIL)
+#define have_time_p(x) ((x)->flags & HAVE_TIME)
+#define complex_dat_p(x) ((x)->flags & COMPLEX_DAT)
+#define simple_dat_p(x) (!complex_dat_p(x))
+
+#define ITALY 2299161 /* 1582-10-15 */
+#define ENGLAND 2361222 /* 1752-09-14 */
+#define JULIAN positive_inf
+#define GREGORIAN negative_inf
+#define DEFAULT_SG ITALY
+
+#define UNIX_EPOCH_IN_CJD INT2FIX(2440588) /* 1970-01-01 */
+
+#define MINUTE_IN_SECONDS 60
+#define HOUR_IN_SECONDS 3600
+#define DAY_IN_SECONDS 86400
+#define SECOND_IN_MILLISECONDS 1000
+#define SECOND_IN_NANOSECONDS 1000000000
+
+#define JC_PERIOD0 1461 /* 365.25 * 4 */
+#define GC_PERIOD0 146097 /* 365.2425 * 400 */
+#define CM_PERIOD0 71149239 /* (lcm 7 1461 146097) */
+#define CM_PERIOD (0xfffffff / CM_PERIOD0 * CM_PERIOD0)
+#define CM_PERIOD_JCY (CM_PERIOD / JC_PERIOD0 * 4)
+#define CM_PERIOD_GCY (CM_PERIOD / GC_PERIOD0 * 400)
+
+#define REFORM_BEGIN_YEAR 1582
+#define REFORM_END_YEAR 1930
+#define REFORM_BEGIN_JD 2298874 /* ns 1582-01-01 */
+#define REFORM_END_JD 2426355 /* os 1930-12-31 */
+
+#ifdef USE_PACK
+#define SEC_WIDTH 6
+#define MIN_WIDTH 6
+#define HOUR_WIDTH 5
+#define MDAY_WIDTH 5
+#define MON_WIDTH 4
+
+#define SEC_SHIFT 0
+#define MIN_SHIFT SEC_WIDTH
+#define HOUR_SHIFT (MIN_WIDTH + SEC_WIDTH)
+#define MDAY_SHIFT (HOUR_WIDTH + MIN_WIDTH + SEC_WIDTH)
+#define MON_SHIFT (MDAY_WIDTH + HOUR_WIDTH + MIN_WIDTH + SEC_WIDTH)
+
+#define PK_MASK(x) ((1 << (x)) - 1)
+
+#define EX_SEC(x) (((x) >> SEC_SHIFT) & PK_MASK(SEC_WIDTH))
+#define EX_MIN(x) (((x) >> MIN_SHIFT) & PK_MASK(MIN_WIDTH))
+#define EX_HOUR(x) (((x) >> HOUR_SHIFT) & PK_MASK(HOUR_WIDTH))
+#define EX_MDAY(x) (((x) >> MDAY_SHIFT) & PK_MASK(MDAY_WIDTH))
+#define EX_MON(x) (((x) >> MON_SHIFT) & PK_MASK(MON_WIDTH))
+
+#define PACK5(m,d,h,min,s) \
+ (((m) << MON_SHIFT) | ((d) << MDAY_SHIFT) |\
+ ((h) << HOUR_SHIFT) | ((min) << MIN_SHIFT) | ((s) << SEC_SHIFT))
+
+#define PACK2(m,d) \
+ (((m) << MON_SHIFT) | ((d) << MDAY_SHIFT))
+#endif
+
+#ifdef HAVE_FLOAT_H
+#include <float.h>
+#endif
+
+#if defined(FLT_RADIX) && defined(FLT_MANT_DIG) && FLT_RADIX == 2 && FLT_MANT_DIG > 22
+#define date_sg_t float
+#else
+#define date_sg_t double
+#endif
+
+/* A set of nth, jd, df and sf denote ajd + 1/2. Each ajd begin at
+ * noon of GMT (assume equal to UTC). However, this begins at
+ * midnight.
+ */
+
+struct SimpleDateData
+{
+ unsigned flags;
+ VALUE nth; /* not always canonicalized */
+ int jd; /* as utc */
+ /* df is zero */
+ /* sf is zero */
+ /* of is zero */
+ date_sg_t sg; /* 2298874..2426355 or -/+oo -- at most 22 bits */
+ /* decoded as utc=local */
+ int year; /* truncated */
+#ifndef USE_PACK
+ int mon;
+ int mday;
+ /* hour is zero */
+ /* min is zero */
+ /* sec is zero */
+#else
+ /* packed civil */
+ unsigned pc;
+#endif
+};
+
+struct ComplexDateData
+{
+ unsigned flags;
+ VALUE nth; /* not always canonicalized */
+ int jd; /* as utc */
+ int df; /* as utc, in secs */
+ VALUE sf; /* in nano secs */
+ int of; /* in secs */
+ date_sg_t sg; /* 2298874..2426355 or -/+oo -- at most 22 bits */
+ /* decoded as local */
+ int year; /* truncated */
+#ifndef USE_PACK
+ int mon;
+ int mday;
+ int hour;
+ int min;
+ int sec;
+#else
+ /* packed civil */
+ unsigned pc;
+#endif
+};
+
+union DateData {
+ unsigned flags;
+ struct SimpleDateData s;
+ struct ComplexDateData c;
+};
+
+#define get_d1(x)\
+ union DateData *dat;\
+ TypedData_Get_Struct(x, union DateData, &d_lite_type, dat);
+
+#define get_d1a(x)\
+ union DateData *adat;\
+ TypedData_Get_Struct(x, union DateData, &d_lite_type, adat);
+
+#define get_d1b(x)\
+ union DateData *bdat;\
+ TypedData_Get_Struct(x, union DateData, &d_lite_type, bdat);
+
+#define get_d2(x,y)\
+ union DateData *adat, *bdat;\
+ TypedData_Get_Struct(x, union DateData, &d_lite_type, adat);\
+ TypedData_Get_Struct(y, union DateData, &d_lite_type, bdat);
+
+inline static VALUE
+canon(VALUE x)
+{
+ if (RB_TYPE_P(x, T_RATIONAL)) {
+ VALUE den = rb_rational_den(x);
+ if (FIXNUM_P(den) && FIX2LONG(den) == 1)
+ return rb_rational_num(x);
+ }
+ return x;
+}
+
+#ifndef USE_PACK
+#define set_to_simple(obj, x, _nth, _jd ,_sg, _year, _mon, _mday, _flags) \
+{\
+ RB_OBJ_WRITE((obj), &(x)->nth, canon(_nth)); \
+ (x)->jd = _jd;\
+ (x)->sg = (date_sg_t)(_sg);\
+ (x)->year = _year;\
+ (x)->mon = _mon;\
+ (x)->mday = _mday;\
+ (x)->flags = _flags;\
+}
+#else
+#define set_to_simple(obj, x, _nth, _jd ,_sg, _year, _mon, _mday, _flags) \
+{\
+ RB_OBJ_WRITE((obj), &(x)->nth, canon(_nth)); \
+ (x)->jd = _jd;\
+ (x)->sg = (date_sg_t)(_sg);\
+ (x)->year = _year;\
+ (x)->pc = PACK2(_mon, _mday);\
+ (x)->flags = _flags;\
+}
+#endif
+
+#ifndef USE_PACK
+#define set_to_complex(obj, x, _nth, _jd ,_df, _sf, _of, _sg,\
+_year, _mon, _mday, _hour, _min, _sec, _flags) \
+{\
+ RB_OBJ_WRITE((obj), &(x)->nth, canon(_nth));\
+ (x)->jd = _jd;\
+ (x)->df = _df;\
+ RB_OBJ_WRITE((obj), &(x)->sf, canon(_sf));\
+ (x)->of = _of;\
+ (x)->sg = (date_sg_t)(_sg);\
+ (x)->year = _year;\
+ (x)->mon = _mon;\
+ (x)->mday = _mday;\
+ (x)->hour = _hour;\
+ (x)->min = _min;\
+ (x)->sec = _sec;\
+ (x)->flags = _flags;\
+}
+#else
+#define set_to_complex(obj, x, _nth, _jd ,_df, _sf, _of, _sg,\
+_year, _mon, _mday, _hour, _min, _sec, _flags) \
+{\
+ RB_OBJ_WRITE((obj), &(x)->nth, canon(_nth));\
+ (x)->jd = _jd;\
+ (x)->df = _df;\
+ RB_OBJ_WRITE((obj), &(x)->sf, canon(_sf));\
+ (x)->of = _of;\
+ (x)->sg = (date_sg_t)(_sg);\
+ (x)->year = _year;\
+ (x)->pc = PACK5(_mon, _mday, _hour, _min, _sec);\
+ (x)->flags = _flags;\
+}
+#endif
+
+#ifndef USE_PACK
+#define copy_simple_to_complex(obj, x, y) \
+{\
+ RB_OBJ_WRITE((obj), &(x)->nth, (y)->nth);\
+ (x)->jd = (y)->jd;\
+ (x)->df = 0;\
+ (x)->sf = INT2FIX(0);\
+ (x)->of = 0;\
+ (x)->sg = (date_sg_t)((y)->sg);\
+ (x)->year = (y)->year;\
+ (x)->mon = (y)->mon;\
+ (x)->mday = (y)->mday;\
+ (x)->hour = 0;\
+ (x)->min = 0;\
+ (x)->sec = 0;\
+ (x)->flags = (y)->flags;\
+}
+#else
+#define copy_simple_to_complex(obj, x, y) \
+{\
+ RB_OBJ_WRITE((obj), &(x)->nth, (y)->nth);\
+ (x)->jd = (y)->jd;\
+ (x)->df = 0;\
+ RB_OBJ_WRITE((obj), &(x)->sf, INT2FIX(0));\
+ (x)->of = 0;\
+ (x)->sg = (date_sg_t)((y)->sg);\
+ (x)->year = (y)->year;\
+ (x)->pc = PACK5(EX_MON((y)->pc), EX_MDAY((y)->pc), 0, 0, 0);\
+ (x)->flags = (y)->flags;\
+}
+#endif
+
+#ifndef USE_PACK
+#define copy_complex_to_simple(obj, x, y) \
+{\
+ RB_OBJ_WRITE((obj), &(x)->nth, (y)->nth);\
+ (x)->jd = (y)->jd;\
+ (x)->sg = (date_sg_t)((y)->sg);\
+ (x)->year = (y)->year;\
+ (x)->mon = (y)->mon;\
+ (x)->mday = (y)->mday;\
+ (x)->flags = (y)->flags;\
+}
+#else
+#define copy_complex_to_simple(obj, x, y) \
+{\
+ RB_OBJ_WRITE((obj), &(x)->nth, (y)->nth);\
+ (x)->jd = (y)->jd;\
+ (x)->sg = (date_sg_t)((y)->sg);\
+ (x)->year = (y)->year;\
+ (x)->pc = PACK2(EX_MON((y)->pc), EX_MDAY((y)->pc));\
+ (x)->flags = (y)->flags;\
+}
+#endif
+
+/* base */
+
+static int c_valid_civil_p(int, int, int, double,
+ int *, int *, int *, int *);
+
+static int
+c_find_fdoy(int y, double sg, int *rjd, int *ns)
+{
+ int d, rm, rd;
+
+ for (d = 1; d < 31; d++)
+ if (c_valid_civil_p(y, 1, d, sg, &rm, &rd, rjd, ns))
+ return 1;
+ return 0;
+}
+
+static int
+c_find_ldoy(int y, double sg, int *rjd, int *ns)
+{
+ int i, rm, rd;
+
+ for (i = 0; i < 30; i++)
+ if (c_valid_civil_p(y, 12, 31 - i, sg, &rm, &rd, rjd, ns))
+ return 1;
+ return 0;
+}
+
+#ifndef NDEBUG
+static int
+c_find_fdom(int y, int m, double sg, int *rjd, int *ns)
+{
+ int d, rm, rd;
+
+ for (d = 1; d < 31; d++)
+ if (c_valid_civil_p(y, m, d, sg, &rm, &rd, rjd, ns))
+ return 1;
+ return 0;
+}
+#endif
+
+static int
+c_find_ldom(int y, int m, double sg, int *rjd, int *ns)
+{
+ int i, rm, rd;
+
+ for (i = 0; i < 30; i++)
+ if (c_valid_civil_p(y, m, 31 - i, sg, &rm, &rd, rjd, ns))
+ return 1;
+ return 0;
+}
+
+static void
+c_civil_to_jd(int y, int m, int d, double sg, int *rjd, int *ns)
+{
+ double a, b, jd;
+
+ if (m <= 2) {
+ y -= 1;
+ m += 12;
+ }
+ a = floor(y / 100.0);
+ b = 2 - a + floor(a / 4.0);
+ jd = floor(365.25 * (y + 4716)) +
+ floor(30.6001 * (m + 1)) +
+ d + b - 1524;
+ if (jd < sg) {
+ jd -= b;
+ *ns = 0;
+ }
+ else
+ *ns = 1;
+
+ *rjd = (int)jd;
+}
+
+static void
+c_jd_to_civil(int jd, double sg, int *ry, int *rm, int *rdom)
+{
+ double x, a, b, c, d, e, y, m, dom;
+
+ if (jd < sg)
+ a = jd;
+ else {
+ x = floor((jd - 1867216.25) / 36524.25);
+ a = jd + 1 + x - floor(x / 4.0);
+ }
+ b = a + 1524;
+ c = floor((b - 122.1) / 365.25);
+ d = floor(365.25 * c);
+ e = floor((b - d) / 30.6001);
+ dom = b - d - floor(30.6001 * e);
+ if (e <= 13) {
+ m = e - 1;
+ y = c - 4716;
+ }
+ else {
+ m = e - 13;
+ y = c - 4715;
+ }
+
+ *ry = (int)y;
+ *rm = (int)m;
+ *rdom = (int)dom;
+}
+
+static void
+c_ordinal_to_jd(int y, int d, double sg, int *rjd, int *ns)
+{
+ int ns2;
+
+ c_find_fdoy(y, sg, rjd, &ns2);
+ *rjd += d - 1;
+ *ns = (*rjd < sg) ? 0 : 1;
+}
+
+static void
+c_jd_to_ordinal(int jd, double sg, int *ry, int *rd)
+{
+ int rm2, rd2, rjd, ns;
+
+ c_jd_to_civil(jd, sg, ry, &rm2, &rd2);
+ c_find_fdoy(*ry, sg, &rjd, &ns);
+ *rd = (jd - rjd) + 1;
+}
+
+static void
+c_commercial_to_jd(int y, int w, int d, double sg, int *rjd, int *ns)
+{
+ int rjd2, ns2;
+
+ c_find_fdoy(y, sg, &rjd2, &ns2);
+ rjd2 += 3;
+ *rjd =
+ (rjd2 - MOD((rjd2 - 1) + 1, 7)) +
+ 7 * (w - 1) +
+ (d - 1);
+ *ns = (*rjd < sg) ? 0 : 1;
+}
+
+static void
+c_jd_to_commercial(int jd, double sg, int *ry, int *rw, int *rd)
+{
+ int ry2, rm2, rd2, a, rjd2, ns2;
+
+ c_jd_to_civil(jd - 3, sg, &ry2, &rm2, &rd2);
+ a = ry2;
+ c_commercial_to_jd(a + 1, 1, 1, sg, &rjd2, &ns2);
+ if (jd >= rjd2)
+ *ry = a + 1;
+ else {
+ c_commercial_to_jd(a, 1, 1, sg, &rjd2, &ns2);
+ *ry = a;
+ }
+ *rw = 1 + DIV(jd - rjd2, 7);
+ *rd = MOD(jd + 1, 7);
+ if (*rd == 0)
+ *rd = 7;
+}
+
+static void
+c_weeknum_to_jd(int y, int w, int d, int f, double sg, int *rjd, int *ns)
+{
+ int rjd2, ns2;
+
+ c_find_fdoy(y, sg, &rjd2, &ns2);
+ rjd2 += 6;
+ *rjd = (rjd2 - MOD(((rjd2 - f) + 1), 7) - 7) + 7 * w + d;
+ *ns = (*rjd < sg) ? 0 : 1;
+}
+
+static void
+c_jd_to_weeknum(int jd, int f, double sg, int *ry, int *rw, int *rd)
+{
+ int rm, rd2, rjd, ns, j;
+
+ c_jd_to_civil(jd, sg, ry, &rm, &rd2);
+ c_find_fdoy(*ry, sg, &rjd, &ns);
+ rjd += 6;
+ j = jd - (rjd - MOD((rjd - f) + 1, 7)) + 7;
+ *rw = (int)DIV(j, 7);
+ *rd = (int)MOD(j, 7);
+}
+
+#ifndef NDEBUG
+static void
+c_nth_kday_to_jd(int y, int m, int n, int k, double sg, int *rjd, int *ns)
+{
+ int rjd2, ns2;
+
+ if (n > 0) {
+ c_find_fdom(y, m, sg, &rjd2, &ns2);
+ rjd2 -= 1;
+ }
+ else {
+ c_find_ldom(y, m, sg, &rjd2, &ns2);
+ rjd2 += 7;
+ }
+ *rjd = (rjd2 - MOD((rjd2 - k) + 1, 7)) + 7 * n;
+ *ns = (*rjd < sg) ? 0 : 1;
+}
+#endif
+
+inline static int
+c_jd_to_wday(int jd)
+{
+ return MOD(jd + 1, 7);
+}
+
+#ifndef NDEBUG
+static void
+c_jd_to_nth_kday(int jd, double sg, int *ry, int *rm, int *rn, int *rk)
+{
+ int rd, rjd, ns2;
+
+ c_jd_to_civil(jd, sg, ry, rm, &rd);
+ c_find_fdom(*ry, *rm, sg, &rjd, &ns2);
+ *rn = DIV(jd - rjd, 7) + 1;
+ *rk = c_jd_to_wday(jd);
+}
+#endif
+
+static int
+c_valid_ordinal_p(int y, int d, double sg,
+ int *rd, int *rjd, int *ns)
+{
+ int ry2, rd2;
+
+ if (d < 0) {
+ int rjd2, ns2;
+
+ if (!c_find_ldoy(y, sg, &rjd2, &ns2))
+ return 0;
+ c_jd_to_ordinal(rjd2 + d + 1, sg, &ry2, &rd2);
+ if (ry2 != y)
+ return 0;
+ d = rd2;
+ }
+ c_ordinal_to_jd(y, d, sg, rjd, ns);
+ c_jd_to_ordinal(*rjd, sg, &ry2, &rd2);
+ if (ry2 != y || rd2 != d)
+ return 0;
+ return 1;
+}
+
+static const int monthtab[2][13] = {
+ { 0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 },
+ { 0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }
+};
+
+inline static int
+c_julian_leap_p(int y)
+{
+ return MOD(y, 4) == 0;
+}
+
+inline static int
+c_gregorian_leap_p(int y)
+{
+ return (MOD(y, 4) == 0 && y % 100 != 0) || MOD(y, 400) == 0;
+}
+
+static int
+c_julian_last_day_of_month(int y, int m)
+{
+ assert(m >= 1 && m <= 12);
+ return monthtab[c_julian_leap_p(y) ? 1 : 0][m];
+}
+
+static int
+c_gregorian_last_day_of_month(int y, int m)
+{
+ assert(m >= 1 && m <= 12);
+ return monthtab[c_gregorian_leap_p(y) ? 1 : 0][m];
+}
+
+static int
+c_valid_julian_p(int y, int m, int d, int *rm, int *rd)
+{
+ int last;
+
+ if (m < 0)
+ m += 13;
+ if (m < 1 || m > 12)
+ return 0;
+ last = c_julian_last_day_of_month(y, m);
+ if (d < 0)
+ d = last + d + 1;
+ if (d < 1 || d > last)
+ return 0;
+ *rm = m;
+ *rd = d;
+ return 1;
+}
+
+static int
+c_valid_gregorian_p(int y, int m, int d, int *rm, int *rd)
+{
+ int last;
+
+ if (m < 0)
+ m += 13;
+ if (m < 1 || m > 12)
+ return 0;
+ last = c_gregorian_last_day_of_month(y, m);
+ if (d < 0)
+ d = last + d + 1;
+ if (d < 1 || d > last)
+ return 0;
+ *rm = m;
+ *rd = d;
+ return 1;
+}
+
+static int
+c_valid_civil_p(int y, int m, int d, double sg,
+ int *rm, int *rd, int *rjd, int *ns)
+{
+ int ry;
+
+ if (m < 0)
+ m += 13;
+ if (d < 0) {
+ if (!c_find_ldom(y, m, sg, rjd, ns))
+ return 0;
+ c_jd_to_civil(*rjd + d + 1, sg, &ry, rm, rd);
+ if (ry != y || *rm != m)
+ return 0;
+ d = *rd;
+ }
+ c_civil_to_jd(y, m, d, sg, rjd, ns);
+ c_jd_to_civil(*rjd, sg, &ry, rm, rd);
+ if (ry != y || *rm != m || *rd != d)
+ return 0;
+ return 1;
+}
+
+static int
+c_valid_commercial_p(int y, int w, int d, double sg,
+ int *rw, int *rd, int *rjd, int *ns)
+{
+ int ns2, ry2, rw2, rd2;
+
+ if (d < 0)
+ d += 8;
+ if (w < 0) {
+ int rjd2;
+
+ c_commercial_to_jd(y + 1, 1, 1, sg, &rjd2, &ns2);
+ c_jd_to_commercial(rjd2 + w * 7, sg, &ry2, &rw2, &rd2);
+ if (ry2 != y)
+ return 0;
+ w = rw2;
+ }
+ c_commercial_to_jd(y, w, d, sg, rjd, ns);
+ c_jd_to_commercial(*rjd, sg, &ry2, rw, rd);
+ if (y != ry2 || w != *rw || d != *rd)
+ return 0;
+ return 1;
+}
+
+static int
+c_valid_weeknum_p(int y, int w, int d, int f, double sg,
+ int *rw, int *rd, int *rjd, int *ns)
+{
+ int ns2, ry2, rw2, rd2;
+
+ if (d < 0)
+ d += 7;
+ if (w < 0) {
+ int rjd2;
+
+ c_weeknum_to_jd(y + 1, 1, f, f, sg, &rjd2, &ns2);
+ c_jd_to_weeknum(rjd2 + w * 7, f, sg, &ry2, &rw2, &rd2);
+ if (ry2 != y)
+ return 0;
+ w = rw2;
+ }
+ c_weeknum_to_jd(y, w, d, f, sg, rjd, ns);
+ c_jd_to_weeknum(*rjd, f, sg, &ry2, rw, rd);
+ if (y != ry2 || w != *rw || d != *rd)
+ return 0;
+ return 1;
+}
+
+#ifndef NDEBUG
+static int
+c_valid_nth_kday_p(int y, int m, int n, int k, double sg,
+ int *rm, int *rn, int *rk, int *rjd, int *ns)
+{
+ int ns2, ry2, rm2, rn2, rk2;
+
+ if (k < 0)
+ k += 7;
+ if (n < 0) {
+ int t, ny, nm, rjd2;
+
+ t = y * 12 + m;
+ ny = DIV(t, 12);
+ nm = MOD(t, 12) + 1;
+
+ c_nth_kday_to_jd(ny, nm, 1, k, sg, &rjd2, &ns2);
+ c_jd_to_nth_kday(rjd2 + n * 7, sg, &ry2, &rm2, &rn2, &rk2);
+ if (ry2 != y || rm2 != m)
+ return 0;
+ n = rn2;
+ }
+ c_nth_kday_to_jd(y, m, n, k, sg, rjd, ns);
+ c_jd_to_nth_kday(*rjd, sg, &ry2, rm, rn, rk);
+ if (y != ry2 || m != *rm || n != *rn || k != *rk)
+ return 0;
+ return 1;
+}
+#endif
+
+static int
+c_valid_time_p(int h, int min, int s, int *rh, int *rmin, int *rs)
+{
+ if (h < 0)
+ h += 24;
+ if (min < 0)
+ min += 60;
+ if (s < 0)
+ s += 60;
+ *rh = h;
+ *rmin = min;
+ *rs = s;
+ return !(h < 0 || h > 24 ||
+ min < 0 || min > 59 ||
+ s < 0 || s > 59 ||
+ (h == 24 && (min > 0 || s > 0)));
+}
+
+inline static int
+c_valid_start_p(double sg)
+{
+ if (isnan(sg))
+ return 0;
+ if (isinf(sg))
+ return 1;
+ if (sg < REFORM_BEGIN_JD || sg > REFORM_END_JD)
+ return 0;
+ return 1;
+}
+
+inline static int
+df_local_to_utc(int df, int of)
+{
+ df -= of;
+ if (df < 0)
+ df += DAY_IN_SECONDS;
+ else if (df >= DAY_IN_SECONDS)
+ df -= DAY_IN_SECONDS;
+ return df;
+}
+
+inline static int
+df_utc_to_local(int df, int of)
+{
+ df += of;
+ if (df < 0)
+ df += DAY_IN_SECONDS;
+ else if (df >= DAY_IN_SECONDS)
+ df -= DAY_IN_SECONDS;
+ return df;
+}
+
+inline static int
+jd_local_to_utc(int jd, int df, int of)
+{
+ df -= of;
+ if (df < 0)
+ jd -= 1;
+ else if (df >= DAY_IN_SECONDS)
+ jd += 1;
+ return jd;
+}
+
+inline static int
+jd_utc_to_local(int jd, int df, int of)
+{
+ df += of;
+ if (df < 0)
+ jd -= 1;
+ else if (df >= DAY_IN_SECONDS)
+ jd += 1;
+ return jd;
+}
+
+inline static int
+time_to_df(int h, int min, int s)
+{
+ return h * HOUR_IN_SECONDS + min * MINUTE_IN_SECONDS + s;
+}
+
+inline static void
+df_to_time(int df, int *h, int *min, int *s)
+{
+ *h = df / HOUR_IN_SECONDS;
+ df %= HOUR_IN_SECONDS;
+ *min = df / MINUTE_IN_SECONDS;
+ *s = df % MINUTE_IN_SECONDS;
+}
+
+static VALUE
+sec_to_day(VALUE s)
+{
+ if (FIXNUM_P(s))
+ return rb_rational_new2(s, INT2FIX(DAY_IN_SECONDS));
+ return f_quo(s, INT2FIX(DAY_IN_SECONDS));
+}
+
+inline static VALUE
+isec_to_day(int s)
+{
+ return sec_to_day(INT2FIX(s));
+}
+
+static VALUE
+ns_to_day(VALUE n)
+{
+ if (FIXNUM_P(n))
+ return rb_rational_new2(n, day_in_nanoseconds);
+ return f_quo(n, day_in_nanoseconds);
+}
+
+#ifndef NDEBUG
+static VALUE
+ms_to_sec(VALUE m)
+{
+ if (FIXNUM_P(m))
+ return rb_rational_new2(m, INT2FIX(SECOND_IN_MILLISECONDS));
+ return f_quo(m, INT2FIX(SECOND_IN_MILLISECONDS));
+}
+#endif
+
+static VALUE
+ns_to_sec(VALUE n)
+{
+ if (FIXNUM_P(n))
+ return rb_rational_new2(n, INT2FIX(SECOND_IN_NANOSECONDS));
+ return f_quo(n, INT2FIX(SECOND_IN_NANOSECONDS));
+}
+
+#ifndef NDEBUG
+inline static VALUE
+ins_to_day(int n)
+{
+ return ns_to_day(INT2FIX(n));
+}
+#endif
+
+static int
+safe_mul_p(VALUE x, long m)
+{
+ long ix;
+
+ if (!FIXNUM_P(x))
+ return 0;
+ ix = FIX2LONG(x);
+ if (ix < 0) {
+ if (ix <= (FIXNUM_MIN / m))
+ return 0;
+ }
+ else {
+ if (ix >= (FIXNUM_MAX / m))
+ return 0;
+ }
+ return 1;
+}
+
+static VALUE
+day_to_sec(VALUE d)
+{
+ if (safe_mul_p(d, DAY_IN_SECONDS))
+ return LONG2FIX(FIX2LONG(d) * DAY_IN_SECONDS);
+ return f_mul(d, INT2FIX(DAY_IN_SECONDS));
+}
+
+#ifndef NDEBUG
+static VALUE
+day_to_ns(VALUE d)
+{
+ return f_mul(d, day_in_nanoseconds);
+}
+#endif
+
+static VALUE
+sec_to_ms(VALUE s)
+{
+ if (safe_mul_p(s, SECOND_IN_MILLISECONDS))
+ return LONG2FIX(FIX2LONG(s) * SECOND_IN_MILLISECONDS);
+ return f_mul(s, INT2FIX(SECOND_IN_MILLISECONDS));
+}
+
+static VALUE
+sec_to_ns(VALUE s)
+{
+ if (safe_mul_p(s, SECOND_IN_NANOSECONDS))
+ return LONG2FIX(FIX2LONG(s) * SECOND_IN_NANOSECONDS);
+ return f_mul(s, INT2FIX(SECOND_IN_NANOSECONDS));
+}
+
+#ifndef NDEBUG
+static VALUE
+isec_to_ns(int s)
+{
+ return sec_to_ns(INT2FIX(s));
+}
+#endif
+
+static VALUE
+div_day(VALUE d, VALUE *f)
+{
+ if (f)
+ *f = f_mod(d, INT2FIX(1));
+ return f_floor(d);
+}
+
+static VALUE
+div_df(VALUE d, VALUE *f)
+{
+ VALUE s = day_to_sec(d);
+
+ if (f)
+ *f = f_mod(s, INT2FIX(1));
+ return f_floor(s);
+}
+
+#ifndef NDEBUG
+static VALUE
+div_sf(VALUE s, VALUE *f)
+{
+ VALUE n = sec_to_ns(s);
+
+ if (f)
+ *f = f_mod(n, INT2FIX(1));
+ return f_floor(n);
+}
+#endif
+
+static void
+decode_day(VALUE d, VALUE *jd, VALUE *df, VALUE *sf)
+{
+ VALUE f;
+
+ *jd = div_day(d, &f);
+ *df = div_df(f, &f);
+ *sf = sec_to_ns(f);
+}
+
+inline static double
+s_virtual_sg(union DateData *x)
+{
+ if (isinf(x->s.sg))
+ return x->s.sg;
+ if (f_zero_p(x->s.nth))
+ return x->s.sg;
+ else if (f_negative_p(x->s.nth))
+ return positive_inf;
+ return negative_inf;
+}
+
+inline static double
+c_virtual_sg(union DateData *x)
+{
+ if (isinf(x->c.sg))
+ return x->c.sg;
+ if (f_zero_p(x->c.nth))
+ return x->c.sg;
+ else if (f_negative_p(x->c.nth))
+ return positive_inf;
+ return negative_inf;
+}
+
+inline static double
+m_virtual_sg(union DateData *x)
+{
+ if (simple_dat_p(x))
+ return s_virtual_sg(x);
+ else
+ return c_virtual_sg(x);
+}
+
+#define canonicalize_jd(_nth, _jd) \
+{\
+ if (_jd < 0) {\
+ _nth = f_sub(_nth, INT2FIX(1));\
+ _jd += CM_PERIOD;\
+ }\
+ if (_jd >= CM_PERIOD) {\
+ _nth = f_add(_nth, INT2FIX(1));\
+ _jd -= CM_PERIOD;\
+ }\
+}
+
+inline static void
+canonicalize_s_jd(VALUE obj, union DateData *x)
+{
+ int j = x->s.jd;
+ VALUE nth = x->s.nth;
+ assert(have_jd_p(x));
+ canonicalize_jd(nth, x->s.jd);
+ RB_OBJ_WRITE(obj, &x->s.nth, nth);
+ if (x->s.jd != j)
+ x->flags &= ~HAVE_CIVIL;
+}
+
+inline static void
+get_s_jd(union DateData *x)
+{
+ assert(simple_dat_p(x));
+ if (!have_jd_p(x)) {
+ int jd, ns;
+
+ assert(have_civil_p(x));
+#ifndef USE_PACK
+ c_civil_to_jd(x->s.year, x->s.mon, x->s.mday,
+ s_virtual_sg(x), &jd, &ns);
+#else
+ c_civil_to_jd(x->s.year, EX_MON(x->s.pc), EX_MDAY(x->s.pc),
+ s_virtual_sg(x), &jd, &ns);
+#endif
+ x->s.jd = jd;
+ x->s.flags |= HAVE_JD;
+ }
+}
+
+inline static void
+get_s_civil(union DateData *x)
+{
+ assert(simple_dat_p(x));
+ if (!have_civil_p(x)) {
+ int y, m, d;
+
+ assert(have_jd_p(x));
+ c_jd_to_civil(x->s.jd, s_virtual_sg(x), &y, &m, &d);
+ x->s.year = y;
+#ifndef USE_PACK
+ x->s.mon = m;
+ x->s.mday = d;
+#else
+ x->s.pc = PACK2(m, d);
+#endif
+ x->s.flags |= HAVE_CIVIL;
+ }
+}
+
+inline static void
+get_c_df(union DateData *x)
+{
+ assert(complex_dat_p(x));
+ if (!have_df_p(x)) {
+ assert(have_time_p(x));
+#ifndef USE_PACK
+ x->c.df = df_local_to_utc(time_to_df(x->c.hour, x->c.min, x->c.sec),
+ x->c.of);
+#else
+ x->c.df = df_local_to_utc(time_to_df(EX_HOUR(x->c.pc),
+ EX_MIN(x->c.pc),
+ EX_SEC(x->c.pc)),
+ x->c.of);
+#endif
+ x->c.flags |= HAVE_DF;
+ }
+}
+
+inline static void
+get_c_time(union DateData *x)
+{
+ assert(complex_dat_p(x));
+ if (!have_time_p(x)) {
+#ifndef USE_PACK
+ int r;
+ assert(have_df_p(x));
+ r = df_utc_to_local(x->c.df, x->c.of);
+ df_to_time(r, &x->c.hour, &x->c.min, &x->c.sec);
+ x->c.flags |= HAVE_TIME;
+#else
+ int r, m, d, h, min, s;
+
+ assert(have_df_p(x));
+ m = EX_MON(x->c.pc);
+ d = EX_MDAY(x->c.pc);
+ r = df_utc_to_local(x->c.df, x->c.of);
+ df_to_time(r, &h, &min, &s);
+ x->c.pc = PACK5(m, d, h, min, s);
+ x->c.flags |= HAVE_TIME;
+#endif
+ }
+}
+
+inline static void
+canonicalize_c_jd(VALUE obj, union DateData *x)
+{
+ int j = x->c.jd;
+ VALUE nth = x->c.nth;
+ assert(have_jd_p(x));
+ canonicalize_jd(nth, x->c.jd);
+ RB_OBJ_WRITE(obj, &x->c.nth, nth);
+ if (x->c.jd != j)
+ x->flags &= ~HAVE_CIVIL;
+}
+
+inline static void
+get_c_jd(union DateData *x)
+{
+ assert(complex_dat_p(x));
+ if (!have_jd_p(x)) {
+ int jd, ns;
+
+ assert(have_civil_p(x));
+#ifndef USE_PACK
+ c_civil_to_jd(x->c.year, x->c.mon, x->c.mday,
+ c_virtual_sg(x), &jd, &ns);
+#else
+ c_civil_to_jd(x->c.year, EX_MON(x->c.pc), EX_MDAY(x->c.pc),
+ c_virtual_sg(x), &jd, &ns);
+#endif
+
+ get_c_time(x);
+#ifndef USE_PACK
+ x->c.jd = jd_local_to_utc(jd,
+ time_to_df(x->c.hour, x->c.min, x->c.sec),
+ x->c.of);
+#else
+ x->c.jd = jd_local_to_utc(jd,
+ time_to_df(EX_HOUR(x->c.pc),
+ EX_MIN(x->c.pc),
+ EX_SEC(x->c.pc)),
+ x->c.of);
+#endif
+ x->c.flags |= HAVE_JD;
+ }
+}
+
+inline static void
+get_c_civil(union DateData *x)
+{
+ assert(complex_dat_p(x));
+ if (!have_civil_p(x)) {
+#ifndef USE_PACK
+ int jd, y, m, d;
+#else
+ int jd, y, m, d, h, min, s;
+#endif
+
+ assert(have_jd_p(x));
+ get_c_df(x);
+ jd = jd_utc_to_local(x->c.jd, x->c.df, x->c.of);
+ c_jd_to_civil(jd, c_virtual_sg(x), &y, &m, &d);
+ x->c.year = y;
+#ifndef USE_PACK
+ x->c.mon = m;
+ x->c.mday = d;
+#else
+ h = EX_HOUR(x->c.pc);
+ min = EX_MIN(x->c.pc);
+ s = EX_SEC(x->c.pc);
+ x->c.pc = PACK5(m, d, h, min, s);
+#endif
+ x->c.flags |= HAVE_CIVIL;
+ }
+}
+
+inline static int
+local_jd(union DateData *x)
+{
+ assert(complex_dat_p(x));
+ assert(have_jd_p(x));
+ assert(have_df_p(x));
+ return jd_utc_to_local(x->c.jd, x->c.df, x->c.of);
+}
+
+inline static int
+local_df(union DateData *x)
+{
+ assert(complex_dat_p(x));
+ assert(have_df_p(x));
+ return df_utc_to_local(x->c.df, x->c.of);
+}
+
+static void
+decode_year(VALUE y, double style,
+ VALUE *nth, int *ry)
+{
+ int period;
+ VALUE t;
+
+ period = (style < 0) ?
+ CM_PERIOD_GCY :
+ CM_PERIOD_JCY;
+ if (FIXNUM_P(y)) {
+ long iy, it, inth;
+
+ iy = FIX2LONG(y);
+ if (iy >= (FIXNUM_MAX - 4712))
+ goto big;
+ it = iy + 4712; /* shift */
+ inth = DIV(it, ((long)period));
+ *nth = LONG2FIX(inth);
+ if (inth)
+ it = MOD(it, ((long)period));
+ *ry = (int)it - 4712; /* unshift */
+ return;
+ }
+ big:
+ t = f_add(y, INT2FIX(4712)); /* shift */
+ *nth = f_idiv(t, INT2FIX(period));
+ if (f_nonzero_p(*nth))
+ t = f_mod(t, INT2FIX(period));
+ *ry = FIX2INT(t) - 4712; /* unshift */
+}
+
+static void
+encode_year(VALUE nth, int y, double style,
+ VALUE *ry)
+{
+ int period;
+ VALUE t;
+
+ period = (style < 0) ?
+ CM_PERIOD_GCY :
+ CM_PERIOD_JCY;
+ if (f_zero_p(nth))
+ *ry = INT2FIX(y);
+ else {
+ t = f_mul(INT2FIX(period), nth);
+ t = f_add(t, INT2FIX(y));
+ *ry = t;
+ }
+}
+
+static void
+decode_jd(VALUE jd, VALUE *nth, int *rjd)
+{
+ assert(FIXNUM_P(jd) || RB_TYPE_P(jd, T_BIGNUM));
+ *nth = f_idiv(jd, INT2FIX(CM_PERIOD));
+ if (f_zero_p(*nth)) {
+ assert(FIXNUM_P(jd));
+ *rjd = FIX2INT(jd);
+ return;
+ }
+ *rjd = FIX2INT(f_mod(jd, INT2FIX(CM_PERIOD)));
+}
+
+static void
+encode_jd(VALUE nth, int jd, VALUE *rjd)
+{
+ if (f_zero_p(nth)) {
+ *rjd = INT2FIX(jd);
+ return;
+ }
+ *rjd = f_add(f_mul(INT2FIX(CM_PERIOD), nth), INT2FIX(jd));
+}
+
+inline static double
+guess_style(VALUE y, double sg) /* -/+oo or zero */
+{
+ double style = 0;
+
+ if (isinf(sg))
+ style = sg;
+ else if (!FIXNUM_P(y))
+ style = f_positive_p(y) ? negative_inf : positive_inf;
+ else {
+ long iy = FIX2LONG(y);
+
+ assert(FIXNUM_P(y));
+ if (iy < REFORM_BEGIN_YEAR)
+ style = positive_inf;
+ else if (iy > REFORM_END_YEAR)
+ style = negative_inf;
+ }
+ return style;
+}
+
+inline static void
+m_canonicalize_jd(VALUE obj, union DateData *x)
+{
+ if (simple_dat_p(x)) {
+ get_s_jd(x);
+ canonicalize_s_jd(obj, x);
+ }
+ else {
+ get_c_jd(x);
+ canonicalize_c_jd(obj, x);
+ }
+}
+
+inline static VALUE
+m_nth(union DateData *x)
+{
+ if (simple_dat_p(x))
+ return x->s.nth;
+ else {
+ get_c_civil(x);
+ return x->c.nth;
+ }
+}
+
+inline static int
+m_jd(union DateData *x)
+{
+ if (simple_dat_p(x)) {
+ get_s_jd(x);
+ return x->s.jd;
+ }
+ else {
+ get_c_jd(x);
+ return x->c.jd;
+ }
+}
+
+static VALUE
+m_real_jd(union DateData *x)
+{
+ VALUE nth, rjd;
+ int jd;
+
+ nth = m_nth(x);
+ jd = m_jd(x);
+
+ encode_jd(nth, jd, &rjd);
+ return rjd;
+}
+
+static int
+m_local_jd(union DateData *x)
+{
+ if (simple_dat_p(x)) {
+ get_s_jd(x);
+ return x->s.jd;
+ }
+ else {
+ get_c_jd(x);
+ get_c_df(x);
+ return local_jd(x);
+ }
+}
+
+static VALUE
+m_real_local_jd(union DateData *x)
+{
+ VALUE nth, rjd;
+ int jd;
+
+ nth = m_nth(x);
+ jd = m_local_jd(x);
+
+ encode_jd(nth, jd, &rjd);
+ return rjd;
+}
+
+inline static int
+m_df(union DateData *x)
+{
+ if (simple_dat_p(x))
+ return 0;
+ else {
+ get_c_df(x);
+ return x->c.df;
+ }
+}
+
+#ifndef NDEBUG
+static VALUE
+m_df_in_day(union DateData *x)
+{
+ return isec_to_day(m_df(x));
+}
+#endif
+
+static int
+m_local_df(union DateData *x)
+{
+ if (simple_dat_p(x))
+ return 0;
+ else {
+ get_c_df(x);
+ return local_df(x);
+ }
+}
+
+#ifndef NDEBUG
+static VALUE
+m_local_df_in_day(union DateData *x)
+{
+ return isec_to_day(m_local_df(x));
+}
+#endif
+
+inline static VALUE
+m_sf(union DateData *x)
+{
+ if (simple_dat_p(x))
+ return INT2FIX(0);
+ else
+ return x->c.sf;
+}
+
+#ifndef NDEBUG
+static VALUE
+m_sf_in_day(union DateData *x)
+{
+ return ns_to_day(m_sf(x));
+}
+#endif
+
+static VALUE
+m_sf_in_sec(union DateData *x)
+{
+ return ns_to_sec(m_sf(x));
+}
+
+static VALUE
+m_fr(union DateData *x)
+{
+ if (simple_dat_p(x))
+ return INT2FIX(0);
+ else {
+ int df;
+ VALUE sf, fr;
+
+ df = m_local_df(x);
+ sf = m_sf(x);
+ fr = isec_to_day(df);
+ if (f_nonzero_p(sf))
+ fr = f_add(fr, ns_to_day(sf));
+ return fr;
+ }
+}
+
+#define HALF_DAYS_IN_SECONDS (DAY_IN_SECONDS / 2)
+
+static VALUE
+m_ajd(union DateData *x)
+{
+ VALUE r, sf;
+ int df;
+
+ if (simple_dat_p(x)) {
+ r = m_real_jd(x);
+ if (FIXNUM_P(r) && FIX2LONG(r) <= (FIXNUM_MAX / 2)) {
+ long ir = FIX2LONG(r);
+ ir = ir * 2 - 1;
+ return rb_rational_new2(LONG2FIX(ir), INT2FIX(2));
+ }
+ else
+ return rb_rational_new2(f_sub(f_mul(r,
+ INT2FIX(2)),
+ INT2FIX(1)),
+ INT2FIX(2));
+ }
+
+ r = m_real_jd(x);
+ df = m_df(x);
+ df -= HALF_DAYS_IN_SECONDS;
+ if (df)
+ r = f_add(r, isec_to_day(df));
+ sf = m_sf(x);
+ if (f_nonzero_p(sf))
+ r = f_add(r, ns_to_day(sf));
+
+ return r;
+}
+
+static VALUE
+m_amjd(union DateData *x)
+{
+ VALUE r, sf;
+ int df;
+
+ r = m_real_jd(x);
+ if (FIXNUM_P(r) && FIX2LONG(r) >= (FIXNUM_MIN + 2400001)) {
+ long ir = FIX2LONG(r);
+ ir -= 2400001;
+ r = rb_rational_new1(LONG2FIX(ir));
+ }
+ else
+ r = rb_rational_new1(f_sub(m_real_jd(x),
+ INT2FIX(2400001)));
+
+ if (simple_dat_p(x))
+ return r;
+
+ df = m_df(x);
+ if (df)
+ r = f_add(r, isec_to_day(df));
+ sf = m_sf(x);
+ if (f_nonzero_p(sf))
+ r = f_add(r, ns_to_day(sf));
+
+ return r;
+}
+
+inline static int
+m_of(union DateData *x)
+{
+ if (simple_dat_p(x))
+ return 0;
+ else {
+ get_c_jd(x);
+ return x->c.of;
+ }
+}
+
+static VALUE
+m_of_in_day(union DateData *x)
+{
+ return isec_to_day(m_of(x));
+}
+
+inline static double
+m_sg(union DateData *x)
+{
+ if (simple_dat_p(x))
+ return x->s.sg;
+ else {
+ get_c_jd(x);
+ return x->c.sg;
+ }
+}
+
+static int
+m_julian_p(union DateData *x)
+{
+ int jd;
+ double sg;
+
+ if (simple_dat_p(x)) {
+ get_s_jd(x);
+ jd = x->s.jd;
+ sg = s_virtual_sg(x);
+ }
+ else {
+ get_c_jd(x);
+ jd = x->c.jd;
+ sg = c_virtual_sg(x);
+ }
+ if (isinf(sg))
+ return sg == positive_inf;
+ return jd < sg;
+}
+
+inline static int
+m_gregorian_p(union DateData *x)
+{
+ return !m_julian_p(x);
+}
+
+inline static int
+m_proleptic_julian_p(union DateData *x)
+{
+ double sg;
+
+ sg = m_sg(x);
+ if (isinf(sg) && sg > 0)
+ return 1;
+ return 0;
+}
+
+inline static int
+m_proleptic_gregorian_p(union DateData *x)
+{
+ double sg;
+
+ sg = m_sg(x);
+ if (isinf(sg) && sg < 0)
+ return 1;
+ return 0;
+}
+
+inline static int
+m_year(union DateData *x)
+{
+ if (simple_dat_p(x)) {
+ get_s_civil(x);
+ return x->s.year;
+ }
+ else {
+ get_c_civil(x);
+ return x->c.year;
+ }
+}
+
+static VALUE
+m_real_year(union DateData *x)
+{
+ VALUE nth, ry;
+ int year;
+
+ nth = m_nth(x);
+ year = m_year(x);
+
+ if (f_zero_p(nth))
+ return INT2FIX(year);
+
+ encode_year(nth, year,
+ m_gregorian_p(x) ? -1 : +1,
+ &ry);
+ return ry;
+}
+
+inline static int
+m_mon(union DateData *x)
+{
+ if (simple_dat_p(x)) {
+ get_s_civil(x);
+#ifndef USE_PACK
+ return x->s.mon;
+#else
+ return EX_MON(x->s.pc);
+#endif
+ }
+ else {
+ get_c_civil(x);
+#ifndef USE_PACK
+ return x->c.mon;
+#else
+ return EX_MON(x->c.pc);
+#endif
+ }
+}
+
+inline static int
+m_mday(union DateData *x)
+{
+ if (simple_dat_p(x)) {
+ get_s_civil(x);
+#ifndef USE_PACK
+ return x->s.mday;
+#else
+ return EX_MDAY(x->s.pc);
+#endif
+ }
+ else {
+ get_c_civil(x);
+#ifndef USE_PACK
+ return x->c.mday;
+#else
+ return EX_MDAY(x->c.pc);
+#endif
+ }
+}
+
+static const int yeartab[2][13] = {
+ { 0, 0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334 },
+ { 0, 0, 31, 60, 91, 121, 152, 182, 213, 244, 274, 305, 335 }
+};
+
+static int
+c_julian_to_yday(int y, int m, int d)
+{
+ assert(m >= 1 && m <= 12);
+ return yeartab[c_julian_leap_p(y) ? 1 : 0][m] + d;
+}
+
+static int
+c_gregorian_to_yday(int y, int m, int d)
+{
+ assert(m >= 1 && m <= 12);
+ return yeartab[c_gregorian_leap_p(y) ? 1 : 0][m] + d;
+}
+
+static int
+m_yday(union DateData *x)
+{
+ int jd, ry, rd;
+ double sg;
+
+ jd = m_local_jd(x);
+ sg = m_virtual_sg(x); /* !=m_sg() */
+
+ if (m_proleptic_gregorian_p(x) ||
+ (jd - sg) > 366)
+ return c_gregorian_to_yday(m_year(x), m_mon(x), m_mday(x));
+ if (m_proleptic_julian_p(x))
+ return c_julian_to_yday(m_year(x), m_mon(x), m_mday(x));
+ c_jd_to_ordinal(jd, sg, &ry, &rd);
+ return rd;
+}
+
+static int
+m_wday(union DateData *x)
+{
+ return c_jd_to_wday(m_local_jd(x));
+}
+
+static int
+m_cwyear(union DateData *x)
+{
+ int ry, rw, rd;
+
+ c_jd_to_commercial(m_local_jd(x), m_virtual_sg(x), /* !=m_sg() */
+ &ry, &rw, &rd);
+ return ry;
+}
+
+static VALUE
+m_real_cwyear(union DateData *x)
+{
+ VALUE nth, ry;
+ int year;
+
+ nth = m_nth(x);
+ year = m_cwyear(x);
+
+ if (f_zero_p(nth))
+ return INT2FIX(year);
+
+ encode_year(nth, year,
+ m_gregorian_p(x) ? -1 : +1,
+ &ry);
+ return ry;
+}
+
+static int
+m_cweek(union DateData *x)
+{
+ int ry, rw, rd;
+
+ c_jd_to_commercial(m_local_jd(x), m_virtual_sg(x), /* !=m_sg() */
+ &ry, &rw, &rd);
+ return rw;
+}
+
+static int
+m_cwday(union DateData *x)
+{
+ int w;
+
+ w = m_wday(x);
+ if (w == 0)
+ w = 7;
+ return w;
+}
+
+static int
+m_wnumx(union DateData *x, int f)
+{
+ int ry, rw, rd;
+
+ c_jd_to_weeknum(m_local_jd(x), f, m_virtual_sg(x), /* !=m_sg() */
+ &ry, &rw, &rd);
+ return rw;
+}
+
+static int
+m_wnum0(union DateData *x)
+{
+ return m_wnumx(x, 0);
+}
+
+static int
+m_wnum1(union DateData *x)
+{
+ return m_wnumx(x, 1);
+}
+
+inline static int
+m_hour(union DateData *x)
+{
+ if (simple_dat_p(x))
+ return 0;
+ else {
+ get_c_time(x);
+#ifndef USE_PACK
+ return x->c.hour;
+#else
+ return EX_HOUR(x->c.pc);
+#endif
+ }
+}
+
+inline static int
+m_min(union DateData *x)
+{
+ if (simple_dat_p(x))
+ return 0;
+ else {
+ get_c_time(x);
+#ifndef USE_PACK
+ return x->c.min;
+#else
+ return EX_MIN(x->c.pc);
+#endif
+ }
+}
+
+inline static int
+m_sec(union DateData *x)
+{
+ if (simple_dat_p(x))
+ return 0;
+ else {
+ get_c_time(x);
+#ifndef USE_PACK
+ return x->c.sec;
+#else
+ return EX_SEC(x->c.pc);
+#endif
+ }
+}
+
+#define decode_offset(of,s,h,m)\
+{\
+ int a;\
+ s = (of < 0) ? '-' : '+';\
+ a = (of < 0) ? -of : of;\
+ h = a / HOUR_IN_SECONDS;\
+ m = a % HOUR_IN_SECONDS / MINUTE_IN_SECONDS;\
+}
+
+static VALUE
+of2str(int of)
+{
+ int s, h, m;
+
+ decode_offset(of, s, h, m);
+ return rb_enc_sprintf(rb_usascii_encoding(), "%c%02d:%02d", s, h, m);
+}
+
+static VALUE
+m_zone(union DateData *x)
+{
+ if (simple_dat_p(x))
+ return rb_usascii_str_new2("+00:00");
+ return of2str(m_of(x));
+}
+
+inline static VALUE
+f_kind_of_p(VALUE x, VALUE c)
+{
+ return rb_obj_is_kind_of(x, c);
+}
+
+inline static VALUE
+k_date_p(VALUE x)
+{
+ return f_kind_of_p(x, cDate);
+}
+
+inline static VALUE
+k_numeric_p(VALUE x)
+{
+ return f_kind_of_p(x, rb_cNumeric);
+}
+
+inline static VALUE
+k_rational_p(VALUE x)
+{
+ return f_kind_of_p(x, rb_cRational);
+}
+
+#ifndef NDEBUG
+static void
+civil_to_jd(VALUE y, int m, int d, double sg,
+ VALUE *nth, int *ry,
+ int *rjd,
+ int *ns)
+{
+ double style = guess_style(y, sg);
+
+ if (style == 0) {
+ int jd;
+
+ c_civil_to_jd(FIX2INT(y), m, d, sg, &jd, ns);
+ decode_jd(INT2FIX(jd), nth, rjd);
+ if (f_zero_p(*nth))
+ *ry = FIX2INT(y);
+ else {
+ VALUE nth2;
+ decode_year(y, *ns ? -1 : +1, &nth2, ry);
+ }
+ }
+ else {
+ decode_year(y, style, nth, ry);
+ c_civil_to_jd(*ry, m, d, style, rjd, ns);
+ }
+}
+
+static void
+jd_to_civil(VALUE jd, double sg,
+ VALUE *nth, int *rjd,
+ int *ry, int *rm, int *rd)
+{
+ decode_jd(jd, nth, rjd);
+ c_jd_to_civil(*rjd, sg, ry, rm, rd);
+}
+
+static void
+ordinal_to_jd(VALUE y, int d, double sg,
+ VALUE *nth, int *ry,
+ int *rjd,
+ int *ns)
+{
+ double style = guess_style(y, sg);
+
+ if (style == 0) {
+ int jd;
+
+ c_ordinal_to_jd(FIX2INT(y), d, sg, &jd, ns);
+ decode_jd(INT2FIX(jd), nth, rjd);
+ if (f_zero_p(*nth))
+ *ry = FIX2INT(y);
+ else {
+ VALUE nth2;
+ decode_year(y, *ns ? -1 : +1, &nth2, ry);
+ }
+ }
+ else {
+ decode_year(y, style, nth, ry);
+ c_ordinal_to_jd(*ry, d, style, rjd, ns);
+ }
+}
+
+static void
+jd_to_ordinal(VALUE jd, double sg,
+ VALUE *nth, int *rjd,
+ int *ry, int *rd)
+{
+ decode_jd(jd, nth, rjd);
+ c_jd_to_ordinal(*rjd, sg, ry, rd);
+}
+
+static void
+commercial_to_jd(VALUE y, int w, int d, double sg,
+ VALUE *nth, int *ry,
+ int *rjd,
+ int *ns)
+{
+ double style = guess_style(y, sg);
+
+ if (style == 0) {
+ int jd;
+
+ c_commercial_to_jd(FIX2INT(y), w, d, sg, &jd, ns);
+ decode_jd(INT2FIX(jd), nth, rjd);
+ if (f_zero_p(*nth))
+ *ry = FIX2INT(y);
+ else {
+ VALUE nth2;
+ decode_year(y, *ns ? -1 : +1, &nth2, ry);
+ }
+ }
+ else {
+ decode_year(y, style, nth, ry);
+ c_commercial_to_jd(*ry, w, d, style, rjd, ns);
+ }
+}
+
+static void
+jd_to_commercial(VALUE jd, double sg,
+ VALUE *nth, int *rjd,
+ int *ry, int *rw, int *rd)
+{
+ decode_jd(jd, nth, rjd);
+ c_jd_to_commercial(*rjd, sg, ry, rw, rd);
+}
+
+static void
+weeknum_to_jd(VALUE y, int w, int d, int f, double sg,
+ VALUE *nth, int *ry,
+ int *rjd,
+ int *ns)
+{
+ double style = guess_style(y, sg);
+
+ if (style == 0) {
+ int jd;
+
+ c_weeknum_to_jd(FIX2INT(y), w, d, f, sg, &jd, ns);
+ decode_jd(INT2FIX(jd), nth, rjd);
+ if (f_zero_p(*nth))
+ *ry = FIX2INT(y);
+ else {
+ VALUE nth2;
+ decode_year(y, *ns ? -1 : +1, &nth2, ry);
+ }
+ }
+ else {
+ decode_year(y, style, nth, ry);
+ c_weeknum_to_jd(*ry, w, d, f, style, rjd, ns);
+ }
+}
+
+static void
+jd_to_weeknum(VALUE jd, int f, double sg,
+ VALUE *nth, int *rjd,
+ int *ry, int *rw, int *rd)
+{
+ decode_jd(jd, nth, rjd);
+ c_jd_to_weeknum(*rjd, f, sg, ry, rw, rd);
+}
+
+static void
+nth_kday_to_jd(VALUE y, int m, int n, int k, double sg,
+ VALUE *nth, int *ry,
+ int *rjd,
+ int *ns)
+{
+ double style = guess_style(y, sg);
+
+ if (style == 0) {
+ int jd;
+
+ c_nth_kday_to_jd(FIX2INT(y), m, n, k, sg, &jd, ns);
+ decode_jd(INT2FIX(jd), nth, rjd);
+ if (f_zero_p(*nth))
+ *ry = FIX2INT(y);
+ else {
+ VALUE nth2;
+ decode_year(y, *ns ? -1 : +1, &nth2, ry);
+ }
+ }
+ else {
+ decode_year(y, style, nth, ry);
+ c_nth_kday_to_jd(*ry, m, n, k, style, rjd, ns);
+ }
+}
+
+static void
+jd_to_nth_kday(VALUE jd, double sg,
+ VALUE *nth, int *rjd,
+ int *ry, int *rm, int *rn, int *rk)
+{
+ decode_jd(jd, nth, rjd);
+ c_jd_to_nth_kday(*rjd, sg, ry, rm, rn, rk);
+}
+#endif
+
+static int
+valid_ordinal_p(VALUE y, int d, double sg,
+ VALUE *nth, int *ry,
+ int *rd, int *rjd,
+ int *ns)
+{
+ double style = guess_style(y, sg);
+ int r;
+
+ if (style == 0) {
+ int jd;
+
+ r = c_valid_ordinal_p(FIX2INT(y), d, sg, rd, &jd, ns);
+ if (!r)
+ return 0;
+ decode_jd(INT2FIX(jd), nth, rjd);
+ if (f_zero_p(*nth))
+ *ry = FIX2INT(y);
+ else {
+ VALUE nth2;
+ decode_year(y, *ns ? -1 : +1, &nth2, ry);
+ }
+ }
+ else {
+ decode_year(y, style, nth, ry);
+ r = c_valid_ordinal_p(*ry, d, style, rd, rjd, ns);
+ }
+ return r;
+}
+
+static int
+valid_gregorian_p(VALUE y, int m, int d,
+ VALUE *nth, int *ry,
+ int *rm, int *rd)
+{
+ decode_year(y, -1, nth, ry);
+ return c_valid_gregorian_p(*ry, m, d, rm, rd);
+}
+
+static int
+valid_civil_p(VALUE y, int m, int d, double sg,
+ VALUE *nth, int *ry,
+ int *rm, int *rd, int *rjd,
+ int *ns)
+{
+ double style = guess_style(y, sg);
+ int r;
+
+ if (style == 0) {
+ int jd;
+
+ r = c_valid_civil_p(FIX2INT(y), m, d, sg, rm, rd, &jd, ns);
+ if (!r)
+ return 0;
+ decode_jd(INT2FIX(jd), nth, rjd);
+ if (f_zero_p(*nth))
+ *ry = FIX2INT(y);
+ else {
+ VALUE nth2;
+ decode_year(y, *ns ? -1 : +1, &nth2, ry);
+ }
+ }
+ else {
+ decode_year(y, style, nth, ry);
+ if (style < 0)
+ r = c_valid_gregorian_p(*ry, m, d, rm, rd);
+ else
+ r = c_valid_julian_p(*ry, m, d, rm, rd);
+ if (!r)
+ return 0;
+ c_civil_to_jd(*ry, *rm, *rd, style, rjd, ns);
+ }
+ return r;
+}
+
+static int
+valid_commercial_p(VALUE y, int w, int d, double sg,
+ VALUE *nth, int *ry,
+ int *rw, int *rd, int *rjd,
+ int *ns)
+{
+ double style = guess_style(y, sg);
+ int r;
+
+ if (style == 0) {
+ int jd;
+
+ r = c_valid_commercial_p(FIX2INT(y), w, d, sg, rw, rd, &jd, ns);
+ if (!r)
+ return 0;
+ decode_jd(INT2FIX(jd), nth, rjd);
+ if (f_zero_p(*nth))
+ *ry = FIX2INT(y);
+ else {
+ VALUE nth2;
+ decode_year(y, *ns ? -1 : +1, &nth2, ry);
+ }
+ }
+ else {
+ decode_year(y, style, nth, ry);
+ r = c_valid_commercial_p(*ry, w, d, style, rw, rd, rjd, ns);
+ }
+ return r;
+}
+
+static int
+valid_weeknum_p(VALUE y, int w, int d, int f, double sg,
+ VALUE *nth, int *ry,
+ int *rw, int *rd, int *rjd,
+ int *ns)
+{
+ double style = guess_style(y, sg);
+ int r;
+
+ if (style == 0) {
+ int jd;
+
+ r = c_valid_weeknum_p(FIX2INT(y), w, d, f, sg, rw, rd, &jd, ns);
+ if (!r)
+ return 0;
+ decode_jd(INT2FIX(jd), nth, rjd);
+ if (f_zero_p(*nth))
+ *ry = FIX2INT(y);
+ else {
+ VALUE nth2;
+ decode_year(y, *ns ? -1 : +1, &nth2, ry);
+ }
+ }
+ else {
+ decode_year(y, style, nth, ry);
+ r = c_valid_weeknum_p(*ry, w, d, f, style, rw, rd, rjd, ns);
+ }
+ return r;
+}
+
+#ifndef NDEBUG
+static int
+valid_nth_kday_p(VALUE y, int m, int n, int k, double sg,
+ VALUE *nth, int *ry,
+ int *rm, int *rn, int *rk, int *rjd,
+ int *ns)
+{
+ double style = guess_style(y, sg);
+ int r;
+
+ if (style == 0) {
+ int jd;
+
+ r = c_valid_nth_kday_p(FIX2INT(y), m, n, k, sg, rm, rn, rk, &jd, ns);
+ if (!r)
+ return 0;
+ decode_jd(INT2FIX(jd), nth, rjd);
+ if (f_zero_p(*nth))
+ *ry = FIX2INT(y);
+ else {
+ VALUE nth2;
+ decode_year(y, *ns ? -1 : +1, &nth2, ry);
+ }
+ }
+ else {
+ decode_year(y, style, nth, ry);
+ r = c_valid_nth_kday_p(*ry, m, n, k, style, rm, rn, rk, rjd, ns);
+ }
+ return r;
+}
+#endif
+
+VALUE date_zone_to_diff(VALUE);
+
+static int
+offset_to_sec(VALUE vof, int *rof)
+{
+ switch (TYPE(vof)) {
+ case T_FIXNUM:
+ {
+ long n;
+
+ n = FIX2LONG(vof);
+ if (n != -1 && n != 0 && n != 1)
+ return 0;
+ *rof = (int)n * DAY_IN_SECONDS;
+ return 1;
+ }
+ case T_FLOAT:
+ {
+ double n;
+
+ n = RFLOAT_VALUE(vof) * DAY_IN_SECONDS;
+ if (n < -DAY_IN_SECONDS || n > DAY_IN_SECONDS)
+ return 0;
+ *rof = (int)round(n);
+ if (*rof != n)
+ rb_warning("fraction of offset is ignored");
+ return 1;
+ }
+ default:
+ if (!k_numeric_p(vof))
+ rb_raise(rb_eTypeError, "expected numeric");
+ vof = f_to_r(vof);
+#ifdef CANONICALIZATION_FOR_MATHN
+ if (!k_rational_p(vof))
+ return offset_to_sec(vof, rof);
+#endif
+ /* fall through */
+ case T_RATIONAL:
+ {
+ VALUE vs, vn, vd;
+ long n;
+
+ vs = day_to_sec(vof);
+
+#ifdef CANONICALIZATION_FOR_MATHN
+ if (!k_rational_p(vs)) {
+ if (!FIXNUM_P(vs))
+ return 0;
+ n = FIX2LONG(vs);
+ if (n < -DAY_IN_SECONDS || n > DAY_IN_SECONDS)
+ return 0;
+ *rof = (int)n;
+ return 1;
+ }
+#endif
+ vn = rb_rational_num(vs);
+ vd = rb_rational_den(vs);
+
+ if (FIXNUM_P(vn) && FIXNUM_P(vd) && (FIX2LONG(vd) == 1))
+ n = FIX2LONG(vn);
+ else {
+ vn = f_round(vs);
+ if (!f_eqeq_p(vn, vs))
+ rb_warning("fraction of offset is ignored");
+ if (!FIXNUM_P(vn))
+ return 0;
+ n = FIX2LONG(vn);
+ if (n < -DAY_IN_SECONDS || n > DAY_IN_SECONDS)
+ return 0;
+ }
+ *rof = (int)n;
+ return 1;
+ }
+ case T_STRING:
+ {
+ VALUE vs = date_zone_to_diff(vof);
+ long n;
+
+ if (!FIXNUM_P(vs))
+ return 0;
+ n = FIX2LONG(vs);
+ if (n < -DAY_IN_SECONDS || n > DAY_IN_SECONDS)
+ return 0;
+ *rof = (int)n;
+ return 1;
+ }
+ }
+ return 0;
+}
+
+/* date */
+
+#define valid_sg(sg) \
+{\
+ if (!c_valid_start_p(sg)) {\
+ sg = 0;\
+ rb_warning("invalid start is ignored");\
+ }\
+}
+
+static VALUE
+valid_jd_sub(int argc, VALUE *argv, VALUE klass, int need_jd)
+{
+ double sg = NUM2DBL(argv[1]);
+ valid_sg(sg);
+ return argv[0];
+}
+
+#ifndef NDEBUG
+static VALUE
+date_s__valid_jd_p(int argc, VALUE *argv, VALUE klass)
+{
+ VALUE vjd, vsg;
+ VALUE argv2[2];
+
+ rb_scan_args(argc, argv, "11", &vjd, &vsg);
+
+ argv2[0] = vjd;
+ if (argc < 2)
+ argv2[1] = DBL2NUM(GREGORIAN);
+ else
+ argv2[1] = vsg;
+
+ return valid_jd_sub(2, argv2, klass, 1);
+}
+#endif
+
+/*
+ * call-seq:
+ * Date.valid_jd?(jd[, start=Date::ITALY]) -> bool
+ *
+ * Just returns true. It's nonsense, but is for symmetry.
+ *
+ * Date.valid_jd?(2451944) #=> true
+ *
+ * See also jd.
+ */
+static VALUE
+date_s_valid_jd_p(int argc, VALUE *argv, VALUE klass)
+{
+ VALUE vjd, vsg;
+ VALUE argv2[2];
+
+ rb_scan_args(argc, argv, "11", &vjd, &vsg);
+
+ argv2[0] = vjd;
+ if (argc < 2)
+ argv2[1] = INT2FIX(DEFAULT_SG);
+ else
+ argv2[1] = vsg;
+
+ if (NIL_P(valid_jd_sub(2, argv2, klass, 0)))
+ return Qfalse;
+ return Qtrue;
+}
+
+static VALUE
+valid_civil_sub(int argc, VALUE *argv, VALUE klass, int need_jd)
+{
+ VALUE nth, y;
+ int m, d, ry, rm, rd;
+ double sg;
+
+ y = argv[0];
+ m = NUM2INT(argv[1]);
+ d = NUM2INT(argv[2]);
+ sg = NUM2DBL(argv[3]);
+
+ valid_sg(sg);
+
+ if (!need_jd && (guess_style(y, sg) < 0)) {
+ if (!valid_gregorian_p(y, m, d,
+ &nth, &ry,
+ &rm, &rd))
+ return Qnil;
+ return INT2FIX(0); /* dummy */
+ }
+ else {
+ int rjd, ns;
+ VALUE rjd2;
+
+ if (!valid_civil_p(y, m, d, sg,
+ &nth, &ry,
+ &rm, &rd, &rjd,
+ &ns))
+ return Qnil;
+ if (!need_jd)
+ return INT2FIX(0); /* dummy */
+ encode_jd(nth, rjd, &rjd2);
+ return rjd2;
+ }
+}
+
+#ifndef NDEBUG
+static VALUE
+date_s__valid_civil_p(int argc, VALUE *argv, VALUE klass)
+{
+ VALUE vy, vm, vd, vsg;
+ VALUE argv2[4];
+
+ rb_scan_args(argc, argv, "31", &vy, &vm, &vd, &vsg);
+
+ argv2[0] = vy;
+ argv2[1] = vm;
+ argv2[2] = vd;
+ if (argc < 4)
+ argv2[3] = DBL2NUM(GREGORIAN);
+ else
+ argv2[3] = vsg;
+
+ return valid_civil_sub(4, argv2, klass, 1);
+}
+#endif
+
+/*
+ * call-seq:
+ * Date.valid_civil?(year, month, mday[, start=Date::ITALY]) -> bool
+ * Date.valid_date?(year, month, mday[, start=Date::ITALY]) -> bool
+ *
+ * Returns true if the given calendar date is valid, and false if not.
+ *
+ * Date.valid_date?(2001,2,3) #=> true
+ * Date.valid_date?(2001,2,29) #=> false
+ *
+ * See also jd and civil.
+ */
+static VALUE
+date_s_valid_civil_p(int argc, VALUE *argv, VALUE klass)
+{
+ VALUE vy, vm, vd, vsg;
+ VALUE argv2[4];
+
+ rb_scan_args(argc, argv, "31", &vy, &vm, &vd, &vsg);
+
+ argv2[0] = vy;
+ argv2[1] = vm;
+ argv2[2] = vd;
+ if (argc < 4)
+ argv2[3] = INT2FIX(DEFAULT_SG);
+ else
+ argv2[3] = vsg;
+
+ if (NIL_P(valid_civil_sub(4, argv2, klass, 0)))
+ return Qfalse;
+ return Qtrue;
+}
+
+static VALUE
+valid_ordinal_sub(int argc, VALUE *argv, VALUE klass, int need_jd)
+{
+ VALUE nth, y;
+ int d, ry, rd;
+ double sg;
+
+ y = argv[0];
+ d = NUM2INT(argv[1]);
+ sg = NUM2DBL(argv[2]);
+
+ valid_sg(sg);
+
+ {
+ int rjd, ns;
+ VALUE rjd2;
+
+ if (!valid_ordinal_p(y, d, sg,
+ &nth, &ry,
+ &rd, &rjd,
+ &ns))
+ return Qnil;
+ if (!need_jd)
+ return INT2FIX(0); /* dummy */
+ encode_jd(nth, rjd, &rjd2);
+ return rjd2;
+ }
+}
+
+#ifndef NDEBUG
+static VALUE
+date_s__valid_ordinal_p(int argc, VALUE *argv, VALUE klass)
+{
+ VALUE vy, vd, vsg;
+ VALUE argv2[3];
+
+ rb_scan_args(argc, argv, "21", &vy, &vd, &vsg);
+
+ argv2[0] = vy;
+ argv2[1] = vd;
+ if (argc < 3)
+ argv2[2] = DBL2NUM(GREGORIAN);
+ else
+ argv2[2] = vsg;
+
+ return valid_ordinal_sub(3, argv2, klass, 1);
+}
+#endif
+
+/*
+ * call-seq:
+ * Date.valid_ordinal?(year, yday[, start=Date::ITALY]) -> bool
+ *
+ * Returns true if the given ordinal date is valid, and false if not.
+ *
+ * Date.valid_ordinal?(2001,34) #=> true
+ * Date.valid_ordinal?(2001,366) #=> false
+ *
+ * See also jd and ordinal.
+ */
+static VALUE
+date_s_valid_ordinal_p(int argc, VALUE *argv, VALUE klass)
+{
+ VALUE vy, vd, vsg;
+ VALUE argv2[3];
+
+ rb_scan_args(argc, argv, "21", &vy, &vd, &vsg);
+
+ argv2[0] = vy;
+ argv2[1] = vd;
+ if (argc < 3)
+ argv2[2] = INT2FIX(DEFAULT_SG);
+ else
+ argv2[2] = vsg;
+
+ if (NIL_P(valid_ordinal_sub(3, argv2, klass, 0)))
+ return Qfalse;
+ return Qtrue;
+}
+
+static VALUE
+valid_commercial_sub(int argc, VALUE *argv, VALUE klass, int need_jd)
+{
+ VALUE nth, y;
+ int w, d, ry, rw, rd;
+ double sg;
+
+ y = argv[0];
+ w = NUM2INT(argv[1]);
+ d = NUM2INT(argv[2]);
+ sg = NUM2DBL(argv[3]);
+
+ valid_sg(sg);
+
+ {
+ int rjd, ns;
+ VALUE rjd2;
+
+ if (!valid_commercial_p(y, w, d, sg,
+ &nth, &ry,
+ &rw, &rd, &rjd,
+ &ns))
+ return Qnil;
+ if (!need_jd)
+ return INT2FIX(0); /* dummy */
+ encode_jd(nth, rjd, &rjd2);
+ return rjd2;
+ }
+}
+
+#ifndef NDEBUG
+static VALUE
+date_s__valid_commercial_p(int argc, VALUE *argv, VALUE klass)
+{
+ VALUE vy, vw, vd, vsg;
+ VALUE argv2[4];
+
+ rb_scan_args(argc, argv, "31", &vy, &vw, &vd, &vsg);
+
+ argv2[0] = vy;
+ argv2[1] = vw;
+ argv2[2] = vd;
+ if (argc < 4)
+ argv2[3] = DBL2NUM(GREGORIAN);
+ else
+ argv2[3] = vsg;
+
+ return valid_commercial_sub(4, argv2, klass, 1);
+}
+#endif
+
+/*
+ * call-seq:
+ * Date.valid_commercial?(cwyear, cweek, cwday[, start=Date::ITALY]) -> bool
+ *
+ * Returns true if the given week date is valid, and false if not.
+ *
+ * Date.valid_commercial?(2001,5,6) #=> true
+ * Date.valid_commercial?(2001,5,8) #=> false
+ *
+ * See also jd and commercial.
+ */
+static VALUE
+date_s_valid_commercial_p(int argc, VALUE *argv, VALUE klass)
+{
+ VALUE vy, vw, vd, vsg;
+ VALUE argv2[4];
+
+ rb_scan_args(argc, argv, "31", &vy, &vw, &vd, &vsg);
+
+ argv2[0] = vy;
+ argv2[1] = vw;
+ argv2[2] = vd;
+ if (argc < 4)
+ argv2[3] = INT2FIX(DEFAULT_SG);
+ else
+ argv2[3] = vsg;
+
+ if (NIL_P(valid_commercial_sub(4, argv2, klass, 0)))
+ return Qfalse;
+ return Qtrue;
+}
+
+#ifndef NDEBUG
+static VALUE
+valid_weeknum_sub(int argc, VALUE *argv, VALUE klass, int need_jd)
+{
+ VALUE nth, y;
+ int w, d, f, ry, rw, rd;
+ double sg;
+
+ y = argv[0];
+ w = NUM2INT(argv[1]);
+ d = NUM2INT(argv[2]);
+ f = NUM2INT(argv[3]);
+ sg = NUM2DBL(argv[4]);
+
+ valid_sg(sg);
+
+ {
+ int rjd, ns;
+ VALUE rjd2;
+
+ if (!valid_weeknum_p(y, w, d, f, sg,
+ &nth, &ry,
+ &rw, &rd, &rjd,
+ &ns))
+ return Qnil;
+ if (!need_jd)
+ return INT2FIX(0); /* dummy */
+ encode_jd(nth, rjd, &rjd2);
+ return rjd2;
+ }
+}
+
+static VALUE
+date_s__valid_weeknum_p(int argc, VALUE *argv, VALUE klass)
+{
+ VALUE vy, vw, vd, vf, vsg;
+ VALUE argv2[5];
+
+ rb_scan_args(argc, argv, "41", &vy, &vw, &vd, &vf, &vsg);
+
+ argv2[0] = vy;
+ argv2[1] = vw;
+ argv2[2] = vd;
+ argv2[3] = vf;
+ if (argc < 5)
+ argv2[4] = DBL2NUM(GREGORIAN);
+ else
+ argv2[4] = vsg;
+
+ return valid_weeknum_sub(5, argv2, klass, 1);
+}
+
+static VALUE
+date_s_valid_weeknum_p(int argc, VALUE *argv, VALUE klass)
+{
+ VALUE vy, vw, vd, vf, vsg;
+ VALUE argv2[5];
+
+ rb_scan_args(argc, argv, "41", &vy, &vw, &vd, &vf, &vsg);
+
+ argv2[0] = vy;
+ argv2[1] = vw;
+ argv2[2] = vd;
+ argv2[3] = vf;
+ if (argc < 5)
+ argv2[4] = INT2FIX(DEFAULT_SG);
+ else
+ argv2[4] = vsg;
+
+ if (NIL_P(valid_weeknum_sub(5, argv2, klass, 0)))
+ return Qfalse;
+ return Qtrue;
+}
+
+static VALUE
+valid_nth_kday_sub(int argc, VALUE *argv, VALUE klass, int need_jd)
+{
+ VALUE nth, y;
+ int m, n, k, ry, rm, rn, rk;
+ double sg;
+
+ y = argv[0];
+ m = NUM2INT(argv[1]);
+ n = NUM2INT(argv[2]);
+ k = NUM2INT(argv[3]);
+ sg = NUM2DBL(argv[4]);
+
+ {
+ int rjd, ns;
+ VALUE rjd2;
+
+ if (!valid_nth_kday_p(y, m, n, k, sg,
+ &nth, &ry,
+ &rm, &rn, &rk, &rjd,
+ &ns))
+ return Qnil;
+ if (!need_jd)
+ return INT2FIX(0); /* dummy */
+ encode_jd(nth, rjd, &rjd2);
+ return rjd2;
+ }
+}
+
+static VALUE
+date_s__valid_nth_kday_p(int argc, VALUE *argv, VALUE klass)
+{
+ VALUE vy, vm, vn, vk, vsg;
+ VALUE argv2[5];
+
+ rb_scan_args(argc, argv, "41", &vy, &vm, &vn, &vk, &vsg);
+
+ argv2[0] = vy;
+ argv2[1] = vm;
+ argv2[2] = vn;
+ argv2[3] = vk;
+ if (argc < 5)
+ argv2[4] = DBL2NUM(GREGORIAN);
+ else
+ argv2[4] = vsg;
+
+ return valid_nth_kday_sub(5, argv2, klass, 1);
+}
+
+static VALUE
+date_s_valid_nth_kday_p(int argc, VALUE *argv, VALUE klass)
+{
+ VALUE vy, vm, vn, vk, vsg;
+ VALUE argv2[5];
+
+ rb_scan_args(argc, argv, "41", &vy, &vm, &vn, &vk, &vsg);
+
+ argv2[0] = vy;
+ argv2[1] = vm;
+ argv2[2] = vn;
+ argv2[3] = vk;
+ if (argc < 5)
+ argv2[4] = INT2FIX(DEFAULT_SG);
+ else
+ argv2[4] = vsg;
+
+ if (NIL_P(valid_nth_kday_sub(5, argv2, klass, 0)))
+ return Qfalse;
+ return Qtrue;
+}
+
+static VALUE
+date_s_zone_to_diff(VALUE klass, VALUE str)
+{
+ return date_zone_to_diff(str);
+}
+#endif
+
+/*
+ * call-seq:
+ * Date.julian_leap?(year) -> bool
+ *
+ * Returns true if the given year is a leap year of the proleptic
+ * Julian calendar.
+ *
+ * Date.julian_leap?(1900) #=> true
+ * Date.julian_leap?(1901) #=> false
+ */
+static VALUE
+date_s_julian_leap_p(VALUE klass, VALUE y)
+{
+ VALUE nth;
+ int ry;
+
+ decode_year(y, +1, &nth, &ry);
+ return f_boolcast(c_julian_leap_p(ry));
+}
+
+/*
+ * call-seq:
+ * Date.gregorian_leap?(year) -> bool
+ * Date.leap?(year) -> bool
+ *
+ * Returns true if the given year is a leap year of the proleptic
+ * Gregorian calendar.
+ *
+ * Date.gregorian_leap?(1900) #=> false
+ * Date.gregorian_leap?(2000) #=> true
+ */
+static VALUE
+date_s_gregorian_leap_p(VALUE klass, VALUE y)
+{
+ VALUE nth;
+ int ry;
+
+ decode_year(y, -1, &nth, &ry);
+ return f_boolcast(c_gregorian_leap_p(ry));
+}
+
+static void
+d_lite_gc_mark(void *ptr)
+{
+ union DateData *dat = ptr;
+ if (simple_dat_p(dat))
+ rb_gc_mark(dat->s.nth);
+ else {
+ rb_gc_mark(dat->c.nth);
+ rb_gc_mark(dat->c.sf);
+ }
+}
+
+static size_t
+d_lite_memsize(const void *ptr)
+{
+ const union DateData *dat = ptr;
+ return complex_dat_p(dat) ? sizeof(struct ComplexDateData) : sizeof(struct SimpleDateData);
+}
+
+static const rb_data_type_t d_lite_type = {
+ "Date",
+ {d_lite_gc_mark, RUBY_TYPED_DEFAULT_FREE, d_lite_memsize,},
+ 0, 0,
+ RUBY_TYPED_FREE_IMMEDIATELY|RUBY_TYPED_WB_PROTECTED,
+};
+
+inline static VALUE
+d_simple_new_internal(VALUE klass,
+ VALUE nth, int jd,
+ double sg,
+ int y, int m, int d,
+ unsigned flags)
+{
+ struct SimpleDateData *dat;
+ VALUE obj;
+
+ obj = TypedData_Make_Struct(klass, struct SimpleDateData,
+ &d_lite_type, dat);
+ set_to_simple(obj, dat, nth, jd, sg, y, m, d, flags & ~COMPLEX_DAT);
+
+ assert(have_jd_p(dat) || have_civil_p(dat));
+
+ return obj;
+}
+
+inline static VALUE
+d_complex_new_internal(VALUE klass,
+ VALUE nth, int jd,
+ int df, VALUE sf,
+ int of, double sg,
+ int y, int m, int d,
+ int h, int min, int s,
+ unsigned flags)
+{
+ struct ComplexDateData *dat;
+ VALUE obj;
+
+ obj = TypedData_Make_Struct(klass, struct ComplexDateData,
+ &d_lite_type, dat);
+ set_to_complex(obj, dat, nth, jd, df, sf, of, sg,
+ y, m, d, h, min, s, flags | COMPLEX_DAT);
+
+ assert(have_jd_p(dat) || have_civil_p(dat));
+ assert(have_df_p(dat) || have_time_p(dat));
+
+ return obj;
+}
+
+static VALUE
+d_lite_s_alloc_simple(VALUE klass)
+{
+ return d_simple_new_internal(klass,
+ INT2FIX(0), 0,
+ DEFAULT_SG,
+ 0, 0, 0,
+ HAVE_JD);
+}
+
+static VALUE
+d_lite_s_alloc_complex(VALUE klass)
+{
+ return d_complex_new_internal(klass,
+ INT2FIX(0), 0,
+ 0, INT2FIX(0),
+ 0, DEFAULT_SG,
+ 0, 0, 0,
+ 0, 0, 0,
+ HAVE_JD | HAVE_DF);
+}
+
+static VALUE
+d_lite_s_alloc(VALUE klass)
+{
+ return d_lite_s_alloc_complex(klass);
+}
+
+static void
+old_to_new(VALUE ajd, VALUE of, VALUE sg,
+ VALUE *rnth, int *rjd, int *rdf, VALUE *rsf,
+ int *rof, double *rsg)
+{
+ VALUE jd, df, sf, of2, t;
+
+ decode_day(f_add(ajd, half_days_in_day),
+ &jd, &df, &sf);
+ t = day_to_sec(of);
+ of2 = f_round(t);
+
+ if (!f_eqeq_p(of2, t))
+ rb_warning("fraction of offset is ignored");
+
+ decode_jd(jd, rnth, rjd);
+
+ *rdf = NUM2INT(df);
+ *rsf = sf;
+ *rof = NUM2INT(of2);
+ *rsg = NUM2DBL(sg);
+
+ if (*rdf < 0 || *rdf >= DAY_IN_SECONDS)
+ rb_raise(rb_eArgError, "invalid day fraction");
+
+ if (f_lt_p(*rsf, INT2FIX(0)) ||
+ f_ge_p(*rsf, INT2FIX(SECOND_IN_NANOSECONDS)))
+
+ if (*rof < -DAY_IN_SECONDS || *rof > DAY_IN_SECONDS) {
+ *rof = 0;
+ rb_warning("invalid offset is ignored");
+ }
+
+ if (!c_valid_start_p(*rsg)) {
+ *rsg = DEFAULT_SG;
+ rb_warning("invalid start is ignored");
+ }
+}
+
+#ifndef NDEBUG
+static VALUE
+date_s_new_bang(int argc, VALUE *argv, VALUE klass)
+{
+ VALUE ajd, of, sg, nth, sf;
+ int jd, df, rof;
+ double rsg;
+
+ rb_scan_args(argc, argv, "03", &ajd, &of, &sg);
+
+ switch (argc) {
+ case 0:
+ ajd = INT2FIX(0);
+ case 1:
+ of = INT2FIX(0);
+ case 2:
+ sg = INT2FIX(DEFAULT_SG);
+ }
+
+ old_to_new(ajd, of, sg,
+ &nth, &jd, &df, &sf, &rof, &rsg);
+
+ if (!df && f_zero_p(sf) && !rof)
+ return d_simple_new_internal(klass,
+ nth, jd,
+ rsg,
+ 0, 0, 0,
+ HAVE_JD);
+ else
+ return d_complex_new_internal(klass,
+ nth, jd,
+ df, sf,
+ rof, rsg,
+ 0, 0, 0,
+ 0, 0, 0,
+ HAVE_JD | HAVE_DF);
+}
+#endif
+
+inline static int
+wholenum_p(VALUE x)
+{
+ if (FIXNUM_P(x))
+ return 1;
+ switch (TYPE(x)) {
+ case T_BIGNUM:
+ return 1;
+ case T_FLOAT:
+ {
+ double d = RFLOAT_VALUE(x);
+ return round(d) == d;
+ }
+ break;
+ case T_RATIONAL:
+ {
+ VALUE den = rb_rational_den(x);
+ return FIXNUM_P(den) && FIX2LONG(den) == 1;
+ }
+ break;
+ }
+ return 0;
+}
+
+inline static VALUE
+to_integer(VALUE x)
+{
+ if (FIXNUM_P(x) || RB_TYPE_P(x, T_BIGNUM))
+ return x;
+ return f_to_i(x);
+}
+
+inline static VALUE
+d_trunc(VALUE d, VALUE *fr)
+{
+ VALUE rd;
+
+ if (wholenum_p(d)) {
+ rd = to_integer(d);
+ *fr = INT2FIX(0);
+ }
+ else {
+ rd = f_idiv(d, INT2FIX(1));
+ *fr = f_mod(d, INT2FIX(1));
+ }
+ return rd;
+}
+
+#define jd_trunc d_trunc
+#define k_trunc d_trunc
+
+inline static VALUE
+h_trunc(VALUE h, VALUE *fr)
+{
+ VALUE rh;
+
+ if (wholenum_p(h)) {
+ rh = to_integer(h);
+ *fr = INT2FIX(0);
+ }
+ else {
+ rh = f_idiv(h, INT2FIX(1));
+ *fr = f_mod(h, INT2FIX(1));
+ *fr = f_quo(*fr, INT2FIX(24));
+ }
+ return rh;
+}
+
+inline static VALUE
+min_trunc(VALUE min, VALUE *fr)
+{
+ VALUE rmin;
+
+ if (wholenum_p(min)) {
+ rmin = to_integer(min);
+ *fr = INT2FIX(0);
+ }
+ else {
+ rmin = f_idiv(min, INT2FIX(1));
+ *fr = f_mod(min, INT2FIX(1));
+ *fr = f_quo(*fr, INT2FIX(1440));
+ }
+ return rmin;
+}
+
+inline static VALUE
+s_trunc(VALUE s, VALUE *fr)
+{
+ VALUE rs;
+
+ if (wholenum_p(s)) {
+ rs = to_integer(s);
+ *fr = INT2FIX(0);
+ }
+ else {
+ rs = f_idiv(s, INT2FIX(1));
+ *fr = f_mod(s, INT2FIX(1));
+ *fr = f_quo(*fr, INT2FIX(86400));
+ }
+ return rs;
+}
+
+#define num2num_with_frac(s,n) \
+{\
+ s = s##_trunc(v##s, &fr);\
+ if (f_nonzero_p(fr)) {\
+ if (argc > n)\
+ rb_raise(rb_eArgError, "invalid fraction");\
+ fr2 = fr;\
+ }\
+}
+
+#define num2int_with_frac(s,n) \
+{\
+ s = NUM2INT(s##_trunc(v##s, &fr));\
+ if (f_nonzero_p(fr)) {\
+ if (argc > n)\
+ rb_raise(rb_eArgError, "invalid fraction");\
+ fr2 = fr;\
+ }\
+}
+
+#define canon24oc() \
+{\
+ if (rh == 24) {\
+ rh = 0;\
+ fr2 = f_add(fr2, INT2FIX(1));\
+ }\
+}
+
+#define add_frac() \
+{\
+ if (f_nonzero_p(fr2))\
+ ret = d_lite_plus(ret, fr2);\
+}
+
+#define val2sg(vsg,dsg) \
+{\
+ dsg = NUM2DBL(vsg);\
+ if (!c_valid_start_p(dsg)) {\
+ dsg = DEFAULT_SG;\
+ rb_warning("invalid start is ignored");\
+ }\
+}
+
+static VALUE d_lite_plus(VALUE, VALUE);
+
+/*
+ * call-seq:
+ * Date.jd([jd=0[, start=Date::ITALY]]) -> date
+ *
+ * Creates a date object denoting the given chronological Julian day
+ * number.
+ *
+ * Date.jd(2451944) #=> #<Date: 2001-02-03 ...>
+ * Date.jd(2451945) #=> #<Date: 2001-02-04 ...>
+ * Date.jd(0) #=> #<Date: -4712-01-01 ...>
+ *
+ * See also new.
+ */
+static VALUE
+date_s_jd(int argc, VALUE *argv, VALUE klass)
+{
+ VALUE vjd, vsg, jd, fr, fr2, ret;
+ double sg;
+
+ rb_scan_args(argc, argv, "02", &vjd, &vsg);
+
+ jd = INT2FIX(0);
+ fr2 = INT2FIX(0);
+ sg = DEFAULT_SG;
+
+ switch (argc) {
+ case 2:
+ val2sg(vsg, sg);
+ case 1:
+ num2num_with_frac(jd, positive_inf);
+ }
+
+ {
+ VALUE nth;
+ int rjd;
+
+ decode_jd(jd, &nth, &rjd);
+ ret = d_simple_new_internal(klass,
+ nth, rjd,
+ sg,
+ 0, 0, 0,
+ HAVE_JD);
+ }
+ add_frac();
+ return ret;
+}
+
+/*
+ * call-seq:
+ * Date.ordinal([year=-4712[, yday=1[, start=Date::ITALY]]]) -> date
+ *
+ * Creates a date object denoting the given ordinal date.
+ *
+ * The day of year should be a negative or a positive number (as a
+ * relative day from the end of year when negative). It should not be
+ * zero.
+ *
+ * Date.ordinal(2001) #=> #<Date: 2001-01-01 ...>
+ * Date.ordinal(2001,34) #=> #<Date: 2001-02-03 ...>
+ * Date.ordinal(2001,-1) #=> #<Date: 2001-12-31 ...>
+ *
+ * See also jd and new.
+ */
+static VALUE
+date_s_ordinal(int argc, VALUE *argv, VALUE klass)
+{
+ VALUE vy, vd, vsg, y, fr, fr2, ret;
+ int d;
+ double sg;
+
+ rb_scan_args(argc, argv, "03", &vy, &vd, &vsg);
+
+ y = INT2FIX(-4712);
+ d = 1;
+ fr2 = INT2FIX(0);
+ sg = DEFAULT_SG;
+
+ switch (argc) {
+ case 3:
+ val2sg(vsg, sg);
+ case 2:
+ num2int_with_frac(d, positive_inf);
+ case 1:
+ y = vy;
+ }
+
+ {
+ VALUE nth;
+ int ry, rd, rjd, ns;
+
+ if (!valid_ordinal_p(y, d, sg,
+ &nth, &ry,
+ &rd, &rjd,
+ &ns))
+ rb_raise(rb_eArgError, "invalid date");
+
+ ret = d_simple_new_internal(klass,
+ nth, rjd,
+ sg,
+ 0, 0, 0,
+ HAVE_JD);
+ }
+ add_frac();
+ return ret;
+}
+
+/*
+ * call-seq:
+ * Date.civil([year=-4712[, month=1[, mday=1[, start=Date::ITALY]]]]) -> date
+ * Date.new([year=-4712[, month=1[, mday=1[, start=Date::ITALY]]]]) -> date
+ *
+ * Creates a date object denoting the given calendar date.
+ *
+ * In this class, BCE years are counted astronomically. Thus, the
+ * year before the year 1 is the year zero, and the year preceding the
+ * year zero is the year -1. The month and the day of month should be
+ * a negative or a positive number (as a relative month/day from the
+ * end of year/month when negative). They should not be zero.
+ *
+ * The last argument should be a Julian day number which denotes the
+ * day of calendar reform. Date::ITALY (2299161=1582-10-15),
+ * Date::ENGLAND (2361222=1752-09-14), Date::GREGORIAN (the proleptic
+ * Gregorian calendar) and Date::JULIAN (the proleptic Julian
+ * calendar) can be specified as a day of calendar reform.
+ *
+ * Date.new(2001) #=> #<Date: 2001-01-01 ...>
+ * Date.new(2001,2,3) #=> #<Date: 2001-02-03 ...>
+ * Date.new(2001,2,-1) #=> #<Date: 2001-02-28 ...>
+ *
+ * See also jd.
+ */
+static VALUE
+date_s_civil(int argc, VALUE *argv, VALUE klass)
+{
+ VALUE vy, vm, vd, vsg, y, fr, fr2, ret;
+ int m, d;
+ double sg;
+
+ rb_scan_args(argc, argv, "04", &vy, &vm, &vd, &vsg);
+
+ y = INT2FIX(-4712);
+ m = 1;
+ d = 1;
+ fr2 = INT2FIX(0);
+ sg = DEFAULT_SG;
+
+ switch (argc) {
+ case 4:
+ val2sg(vsg, sg);
+ case 3:
+ num2int_with_frac(d, positive_inf);
+ case 2:
+ m = NUM2INT(vm);
+ case 1:
+ y = vy;
+ }
+
+ if (guess_style(y, sg) < 0) {
+ VALUE nth;
+ int ry, rm, rd;
+
+ if (!valid_gregorian_p(y, m, d,
+ &nth, &ry,
+ &rm, &rd))
+ rb_raise(rb_eArgError, "invalid date");
+
+ ret = d_simple_new_internal(klass,
+ nth, 0,
+ sg,
+ ry, rm, rd,
+ HAVE_CIVIL);
+ }
+ else {
+ VALUE nth;
+ int ry, rm, rd, rjd, ns;
+
+ if (!valid_civil_p(y, m, d, sg,
+ &nth, &ry,
+ &rm, &rd, &rjd,
+ &ns))
+ rb_raise(rb_eArgError, "invalid date");
+
+ ret = d_simple_new_internal(klass,
+ nth, rjd,
+ sg,
+ ry, rm, rd,
+ HAVE_JD | HAVE_CIVIL);
+ }
+ add_frac();
+ return ret;
+}
+
+/*
+ * call-seq:
+ * Date.commercial([cwyear=-4712[, cweek=1[, cwday=1[, start=Date::ITALY]]]]) -> date
+ *
+ * Creates a date object denoting the given week date.
+ *
+ * The week and the day of week should be a negative or a positive
+ * number (as a relative week/day from the end of year/week when
+ * negative). They should not be zero.
+ *
+ * Date.commercial(2001) #=> #<Date: 2001-01-01 ...>
+ * Date.commercial(2002) #=> #<Date: 2001-12-31 ...>
+ * Date.commercial(2001,5,6) #=> #<Date: 2001-02-03 ...>
+ *
+ * See also jd and new.
+ */
+static VALUE
+date_s_commercial(int argc, VALUE *argv, VALUE klass)
+{
+ VALUE vy, vw, vd, vsg, y, fr, fr2, ret;
+ int w, d;
+ double sg;
+
+ rb_scan_args(argc, argv, "04", &vy, &vw, &vd, &vsg);
+
+ y = INT2FIX(-4712);
+ w = 1;
+ d = 1;
+ fr2 = INT2FIX(0);
+ sg = DEFAULT_SG;
+
+ switch (argc) {
+ case 4:
+ val2sg(vsg, sg);
+ case 3:
+ num2int_with_frac(d, positive_inf);
+ case 2:
+ w = NUM2INT(vw);
+ case 1:
+ y = vy;
+ }
+
+ {
+ VALUE nth;
+ int ry, rw, rd, rjd, ns;
+
+ if (!valid_commercial_p(y, w, d, sg,
+ &nth, &ry,
+ &rw, &rd, &rjd,
+ &ns))
+ rb_raise(rb_eArgError, "invalid date");
+
+ ret = d_simple_new_internal(klass,
+ nth, rjd,
+ sg,
+ 0, 0, 0,
+ HAVE_JD);
+ }
+ add_frac();
+ return ret;
+}
+
+#ifndef NDEBUG
+static VALUE
+date_s_weeknum(int argc, VALUE *argv, VALUE klass)
+{
+ VALUE vy, vw, vd, vf, vsg, y, fr, fr2, ret;
+ int w, d, f;
+ double sg;
+
+ rb_scan_args(argc, argv, "05", &vy, &vw, &vd, &vf, &vsg);
+
+ y = INT2FIX(-4712);
+ w = 0;
+ d = 1;
+ f = 0;
+ fr2 = INT2FIX(0);
+ sg = DEFAULT_SG;
+
+ switch (argc) {
+ case 5:
+ val2sg(vsg, sg);
+ case 4:
+ f = NUM2INT(vf);
+ case 3:
+ num2int_with_frac(d, positive_inf);
+ case 2:
+ w = NUM2INT(vw);
+ case 1:
+ y = vy;
+ }
+
+ {
+ VALUE nth;
+ int ry, rw, rd, rjd, ns;
+
+ if (!valid_weeknum_p(y, w, d, f, sg,
+ &nth, &ry,
+ &rw, &rd, &rjd,
+ &ns))
+ rb_raise(rb_eArgError, "invalid date");
+
+ ret = d_simple_new_internal(klass,
+ nth, rjd,
+ sg,
+ 0, 0, 0,
+ HAVE_JD);
+ }
+ add_frac();
+ return ret;
+}
+
+static VALUE
+date_s_nth_kday(int argc, VALUE *argv, VALUE klass)
+{
+ VALUE vy, vm, vn, vk, vsg, y, fr, fr2, ret;
+ int m, n, k;
+ double sg;
+
+ rb_scan_args(argc, argv, "05", &vy, &vm, &vn, &vk, &vsg);
+
+ y = INT2FIX(-4712);
+ m = 1;
+ n = 1;
+ k = 1;
+ fr2 = INT2FIX(0);
+ sg = DEFAULT_SG;
+
+ switch (argc) {
+ case 5:
+ val2sg(vsg, sg);
+ case 4:
+ num2int_with_frac(k, positive_inf);
+ case 3:
+ n = NUM2INT(vn);
+ case 2:
+ m = NUM2INT(vm);
+ case 1:
+ y = vy;
+ }
+
+ {
+ VALUE nth;
+ int ry, rm, rn, rk, rjd, ns;
+
+ if (!valid_nth_kday_p(y, m, n, k, sg,
+ &nth, &ry,
+ &rm, &rn, &rk, &rjd,
+ &ns))
+ rb_raise(rb_eArgError, "invalid date");
+
+ ret = d_simple_new_internal(klass,
+ nth, rjd,
+ sg,
+ 0, 0, 0,
+ HAVE_JD);
+ }
+ add_frac();
+ return ret;
+}
+#endif
+
+#if !defined(HAVE_GMTIME_R)
+static struct tm*
+gmtime_r(const time_t *t, struct tm *tm)
+{
+ auto struct tm *tmp = gmtime(t);
+ if (tmp)
+ *tm = *tmp;
+ return tmp;
+}
+
+static struct tm*
+localtime_r(const time_t *t, struct tm *tm)
+{
+ auto struct tm *tmp = localtime(t);
+ if (tmp)
+ *tm = *tmp;
+ return tmp;
+}
+#endif
+
+static void set_sg(union DateData *, double);
+
+/*
+ * call-seq:
+ * Date.today([start=Date::ITALY]) -> date
+ *
+ * Date.today #=> #<Date: 2011-06-11 ..>
+ *
+ * Creates a date object denoting the present day.
+ */
+static VALUE
+date_s_today(int argc, VALUE *argv, VALUE klass)
+{
+ VALUE vsg, nth, ret;
+ double sg;
+ time_t t;
+ struct tm tm;
+ int y, ry, m, d;
+
+ rb_scan_args(argc, argv, "01", &vsg);
+
+ if (argc < 1)
+ sg = DEFAULT_SG;
+ else
+ val2sg(vsg, sg);
+
+ if (time(&t) == -1)
+ rb_sys_fail("time");
+ tzset();
+ if (!localtime_r(&t, &tm))
+ rb_sys_fail("localtime");
+
+ y = tm.tm_year + 1900;
+ m = tm.tm_mon + 1;
+ d = tm.tm_mday;
+
+ decode_year(INT2FIX(y), -1, &nth, &ry);
+
+ ret = d_simple_new_internal(klass,
+ nth, 0,
+ GREGORIAN,
+ ry, m, d,
+ HAVE_CIVIL);
+ {
+ get_d1(ret);
+ set_sg(dat, sg);
+ }
+ return ret;
+}
+
+#define set_hash0(k,v) rb_hash_aset(hash, k, v)
+#define ref_hash0(k) rb_hash_aref(hash, k)
+#define del_hash0(k) rb_hash_delete(hash, k)
+
+#define set_hash(k,v) rb_hash_aset(hash, ID2SYM(rb_intern(k)), v)
+#define ref_hash(k) rb_hash_aref(hash, ID2SYM(rb_intern(k)))
+#define del_hash(k) rb_hash_delete(hash, ID2SYM(rb_intern(k)))
+
+static VALUE
+rt_rewrite_frags(VALUE hash)
+{
+ VALUE seconds;
+
+ seconds = ref_hash("seconds");
+ if (!NIL_P(seconds)) {
+ VALUE offset, d, h, min, s, fr;
+
+ offset = ref_hash("offset");
+ if (!NIL_P(offset))
+ seconds = f_add(seconds, offset);
+
+ d = f_idiv(seconds, INT2FIX(DAY_IN_SECONDS));
+ fr = f_mod(seconds, INT2FIX(DAY_IN_SECONDS));
+
+ h = f_idiv(fr, INT2FIX(HOUR_IN_SECONDS));
+ fr = f_mod(fr, INT2FIX(HOUR_IN_SECONDS));
+
+ min = f_idiv(fr, INT2FIX(MINUTE_IN_SECONDS));
+ fr = f_mod(fr, INT2FIX(MINUTE_IN_SECONDS));
+
+ s = f_idiv(fr, INT2FIX(1));
+ fr = f_mod(fr, INT2FIX(1));
+
+ set_hash("jd", f_add(UNIX_EPOCH_IN_CJD, d));
+ set_hash("hour", h);
+ set_hash("min", min);
+ set_hash("sec", s);
+ set_hash("sec_fraction", fr);
+ del_hash("seconds");
+ }
+ return hash;
+}
+
+#define sym(x) ID2SYM(rb_intern(x))
+
+static VALUE d_lite_year(VALUE);
+static VALUE d_lite_wday(VALUE);
+static VALUE d_lite_jd(VALUE);
+
+static VALUE
+rt_complete_frags(VALUE klass, VALUE hash)
+{
+ static VALUE tab = Qnil;
+ int g, e;
+ VALUE k, a, d;
+
+ if (NIL_P(tab)) {
+ tab = rb_ary_new3(11,
+ rb_ary_new3(2,
+ sym("time"),
+ rb_ary_new3(3,
+ sym("hour"),
+ sym("min"),
+ sym("sec"))),
+ rb_ary_new3(2,
+ Qnil,
+ rb_ary_new3(1,
+ sym("jd"))),
+ rb_ary_new3(2,
+ sym("ordinal"),
+ rb_ary_new3(5,
+ sym("year"),
+ sym("yday"),
+ sym("hour"),
+ sym("min"),
+ sym("sec"))),
+ rb_ary_new3(2,
+ sym("civil"),
+ rb_ary_new3(6,
+ sym("year"),
+ sym("mon"),
+ sym("mday"),
+ sym("hour"),
+ sym("min"),
+ sym("sec"))),
+ rb_ary_new3(2,
+ sym("commercial"),
+ rb_ary_new3(6,
+ sym("cwyear"),
+ sym("cweek"),
+ sym("cwday"),
+ sym("hour"),
+ sym("min"),
+ sym("sec"))),
+ rb_ary_new3(2,
+ sym("wday"),
+ rb_ary_new3(4,
+ sym("wday"),
+ sym("hour"),
+ sym("min"),
+ sym("sec"))),
+ rb_ary_new3(2,
+ sym("wnum0"),
+ rb_ary_new3(6,
+ sym("year"),
+ sym("wnum0"),
+ sym("wday"),
+ sym("hour"),
+ sym("min"),
+ sym("sec"))),
+ rb_ary_new3(2,
+ sym("wnum1"),
+ rb_ary_new3(6,
+ sym("year"),
+ sym("wnum1"),
+ sym("wday"),
+ sym("hour"),
+ sym("min"),
+ sym("sec"))),
+ rb_ary_new3(2,
+ Qnil,
+ rb_ary_new3(6,
+ sym("cwyear"),
+ sym("cweek"),
+ sym("wday"),
+ sym("hour"),
+ sym("min"),
+ sym("sec"))),
+ rb_ary_new3(2,
+ Qnil,
+ rb_ary_new3(6,
+ sym("year"),
+ sym("wnum0"),
+ sym("cwday"),
+ sym("hour"),
+ sym("min"),
+ sym("sec"))),
+ rb_ary_new3(2,
+ Qnil,
+ rb_ary_new3(6,
+ sym("year"),
+ sym("wnum1"),
+ sym("cwday"),
+ sym("hour"),
+ sym("min"),
+ sym("sec"))));
+ rb_gc_register_mark_object(tab);
+ }
+
+ {
+ int i, eno = 0, idx = 0;
+
+ for (i = 0; i < RARRAY_LENINT(tab); i++) {
+ VALUE x, a;
+
+ x = RARRAY_PTR(tab)[i];
+ a = RARRAY_PTR(x)[1];
+
+ {
+ int j, n = 0;
+
+ for (j = 0; j < RARRAY_LENINT(a); j++)
+ if (!NIL_P(ref_hash0(RARRAY_PTR(a)[j])))
+ n++;
+ if (n > eno) {
+ eno = n;
+ idx = i;
+ }
+ }
+ }
+ if (eno == 0)
+ g = 0;
+ else {
+ g = 1;
+ k = RARRAY_PTR(RARRAY_PTR(tab)[idx])[0];
+ a = RARRAY_PTR(RARRAY_PTR(tab)[idx])[1];
+ e = eno;
+ }
+ }
+
+ d = Qnil;
+
+ if (g && !NIL_P(k) && (RARRAY_LENINT(a) - e)) {
+ if (k == sym("ordinal")) {
+ if (NIL_P(ref_hash("year"))) {
+ if (NIL_P(d))
+ d = date_s_today(0, (VALUE *)0, cDate);
+ set_hash("year", d_lite_year(d));
+ }
+ if (NIL_P(ref_hash("yday")))
+ set_hash("yday", INT2FIX(1));
+ }
+ else if (k == sym("civil")) {
+ int i;
+
+ for (i = 0; i < RARRAY_LENINT(a); i++) {
+ VALUE e = RARRAY_PTR(a)[i];
+
+ if (!NIL_P(ref_hash0(e)))
+ break;
+ if (NIL_P(d))
+ d = date_s_today(0, (VALUE *)0, cDate);
+ set_hash0(e, rb_funcall(d, SYM2ID(e), 0));
+ }
+ if (NIL_P(ref_hash("mon")))
+ set_hash("mon", INT2FIX(1));
+ if (NIL_P(ref_hash("mday")))
+ set_hash("mday", INT2FIX(1));
+ }
+ else if (k == sym("commercial")) {
+ int i;
+
+ for (i = 0; i < RARRAY_LENINT(a); i++) {
+ VALUE e = RARRAY_PTR(a)[i];
+
+ if (!NIL_P(ref_hash0(e)))
+ break;
+ if (NIL_P(d))
+ d = date_s_today(0, (VALUE *)0, cDate);
+ set_hash0(e, rb_funcall(d, SYM2ID(e), 0));
+ }
+ if (NIL_P(ref_hash("cweek")))
+ set_hash("cweek", INT2FIX(1));
+ if (NIL_P(ref_hash("cwday")))
+ set_hash("cwday", INT2FIX(1));
+ }
+ else if (k == sym("wday")) {
+ if (NIL_P(d))
+ d = date_s_today(0, (VALUE *)0, cDate);
+ set_hash("jd", d_lite_jd(f_add(f_sub(d,
+ d_lite_wday(d)),
+ ref_hash("wday"))));
+ }
+ else if (k == sym("wnum0")) {
+ int i;
+
+ for (i = 0; i < RARRAY_LENINT(a); i++) {
+ VALUE e = RARRAY_PTR(a)[i];
+
+ if (!NIL_P(ref_hash0(e)))
+ break;
+ if (NIL_P(d))
+ d = date_s_today(0, (VALUE *)0, cDate);
+ set_hash0(e, rb_funcall(d, SYM2ID(e), 0));
+ }
+ if (NIL_P(ref_hash("wnum0")))
+ set_hash("wnum0", INT2FIX(0));
+ if (NIL_P(ref_hash("wday")))
+ set_hash("wday", INT2FIX(0));
+ }
+ else if (k == sym("wnum1")) {
+ int i;
+
+ for (i = 0; i < RARRAY_LENINT(a); i++) {
+ VALUE e = RARRAY_PTR(a)[i];
+
+ if (!NIL_P(ref_hash0(e)))
+ break;
+ if (NIL_P(d))
+ d = date_s_today(0, (VALUE *)0, cDate);
+ set_hash0(e, rb_funcall(d, SYM2ID(e), 0));
+ }
+ if (NIL_P(ref_hash("wnum1")))
+ set_hash("wnum1", INT2FIX(0));
+ if (NIL_P(ref_hash("wday")))
+ set_hash("wday", INT2FIX(1));
+ }
+ }
+
+ if (g && k == sym("time")) {
+ if (f_le_p(klass, cDateTime)) {
+ if (NIL_P(d))
+ d = date_s_today(0, (VALUE *)0, cDate);
+ if (NIL_P(ref_hash("jd")))
+ set_hash("jd", d_lite_jd(d));
+ }
+ }
+
+ if (NIL_P(ref_hash("hour")))
+ set_hash("hour", INT2FIX(0));
+ if (NIL_P(ref_hash("min")))
+ set_hash("min", INT2FIX(0));
+ if (NIL_P(ref_hash("sec")))
+ set_hash("sec", INT2FIX(0));
+ else if (f_gt_p(ref_hash("sec"), INT2FIX(59)))
+ set_hash("sec", INT2FIX(59));
+
+ return hash;
+}
+
+static VALUE
+rt__valid_jd_p(VALUE jd, VALUE sg)
+{
+ return jd;
+}
+
+static VALUE
+rt__valid_ordinal_p(VALUE y, VALUE d, VALUE sg)
+{
+ VALUE nth, rjd2;
+ int ry, rd, rjd, ns;
+
+ if (!valid_ordinal_p(y, NUM2INT(d), NUM2DBL(sg),
+ &nth, &ry,
+ &rd, &rjd,
+ &ns))
+ return Qnil;
+ encode_jd(nth, rjd, &rjd2);
+ return rjd2;
+}
+
+static VALUE
+rt__valid_civil_p(VALUE y, VALUE m, VALUE d, VALUE sg)
+{
+ VALUE nth, rjd2;
+ int ry, rm, rd, rjd, ns;
+
+ if (!valid_civil_p(y, NUM2INT(m), NUM2INT(d), NUM2DBL(sg),
+ &nth, &ry,
+ &rm, &rd, &rjd,
+ &ns))
+ return Qnil;
+ encode_jd(nth, rjd, &rjd2);
+ return rjd2;
+}
+
+static VALUE
+rt__valid_commercial_p(VALUE y, VALUE w, VALUE d, VALUE sg)
+{
+ VALUE nth, rjd2;
+ int ry, rw, rd, rjd, ns;
+
+ if (!valid_commercial_p(y, NUM2INT(w), NUM2INT(d), NUM2DBL(sg),
+ &nth, &ry,
+ &rw, &rd, &rjd,
+ &ns))
+ return Qnil;
+ encode_jd(nth, rjd, &rjd2);
+ return rjd2;
+}
+
+static VALUE
+rt__valid_weeknum_p(VALUE y, VALUE w, VALUE d, VALUE f, VALUE sg)
+{
+ VALUE nth, rjd2;
+ int ry, rw, rd, rjd, ns;
+
+ if (!valid_weeknum_p(y, NUM2INT(w), NUM2INT(d), NUM2INT(f), NUM2DBL(sg),
+ &nth, &ry,
+ &rw, &rd, &rjd,
+ &ns))
+ return Qnil;
+ encode_jd(nth, rjd, &rjd2);
+ return rjd2;
+}
+
+static VALUE
+rt__valid_date_frags_p(VALUE hash, VALUE sg)
+{
+ {
+ VALUE vjd;
+
+ if (!NIL_P(vjd = ref_hash("jd"))) {
+ VALUE jd = rt__valid_jd_p(vjd, sg);
+ if (!NIL_P(jd))
+ return jd;
+ }
+ }
+
+ {
+ VALUE year, yday;
+
+ if (!NIL_P(yday = ref_hash("yday")) &&
+ !NIL_P(year = ref_hash("year"))) {
+ VALUE jd = rt__valid_ordinal_p(year, yday, sg);
+ if (!NIL_P(jd))
+ return jd;
+ }
+ }
+
+ {
+ VALUE year, mon, mday;
+
+ if (!NIL_P(mday = ref_hash("mday")) &&
+ !NIL_P(mon = ref_hash("mon")) &&
+ !NIL_P(year = ref_hash("year"))) {
+ VALUE jd = rt__valid_civil_p(year, mon, mday, sg);
+ if (!NIL_P(jd))
+ return jd;
+ }
+ }
+
+ {
+ VALUE year, week, wday;
+
+ wday = ref_hash("cwday");
+ if (NIL_P(wday)) {
+ wday = ref_hash("wday");
+ if (!NIL_P(wday))
+ if (f_zero_p(wday))
+ wday = INT2FIX(7);
+ }
+
+ if (!NIL_P(wday) &&
+ !NIL_P(week = ref_hash("cweek")) &&
+ !NIL_P(year = ref_hash("cwyear"))) {
+ VALUE jd = rt__valid_commercial_p(year, week, wday, sg);
+ if (!NIL_P(jd))
+ return jd;
+ }
+ }
+
+ {
+ VALUE year, week, wday;
+
+ wday = ref_hash("wday");
+ if (NIL_P(wday)) {
+ wday = ref_hash("cwday");
+ if (!NIL_P(wday))
+ if (f_eqeq_p(wday, INT2FIX(7)))
+ wday = INT2FIX(0);
+ }
+
+ if (!NIL_P(wday) &&
+ !NIL_P(week = ref_hash("wnum0")) &&
+ !NIL_P(year = ref_hash("year"))) {
+ VALUE jd = rt__valid_weeknum_p(year, week, wday, INT2FIX(0), sg);
+ if (!NIL_P(jd))
+ return jd;
+ }
+ }
+
+ {
+ VALUE year, week, wday;
+
+ wday = ref_hash("wday");
+ if (NIL_P(wday))
+ wday = ref_hash("cwday");
+ if (!NIL_P(wday))
+ wday = f_mod(f_sub(wday, INT2FIX(1)),
+ INT2FIX(7));
+
+ if (!NIL_P(wday) &&
+ !NIL_P(week = ref_hash("wnum1")) &&
+ !NIL_P(year = ref_hash("year"))) {
+ VALUE jd = rt__valid_weeknum_p(year, week, wday, INT2FIX(1), sg);
+ if (!NIL_P(jd))
+ return jd;
+ }
+ }
+ return Qnil;
+}
+
+static VALUE
+d_new_by_frags(VALUE klass, VALUE hash, VALUE sg)
+{
+ VALUE jd;
+
+ if (!c_valid_start_p(NUM2DBL(sg))) {
+ sg = INT2FIX(DEFAULT_SG);
+ rb_warning("invalid start is ignored");
+ }
+
+ if (NIL_P(hash))
+ rb_raise(rb_eArgError, "invalid date");
+
+ if (NIL_P(ref_hash("jd")) &&
+ NIL_P(ref_hash("yday")) &&
+ !NIL_P(ref_hash("year")) &&
+ !NIL_P(ref_hash("mon")) &&
+ !NIL_P(ref_hash("mday")))
+ jd = rt__valid_civil_p(ref_hash("year"),
+ ref_hash("mon"),
+ ref_hash("mday"), sg);
+ else {
+ hash = rt_rewrite_frags(hash);
+ hash = rt_complete_frags(klass, hash);
+ jd = rt__valid_date_frags_p(hash, sg);
+ }
+
+ if (NIL_P(jd))
+ rb_raise(rb_eArgError, "invalid date");
+ {
+ VALUE nth;
+ int rjd;
+
+ decode_jd(jd, &nth, &rjd);
+ return d_simple_new_internal(klass,
+ nth, rjd,
+ NUM2DBL(sg),
+ 0, 0, 0,
+ HAVE_JD);
+ }
+}
+
+VALUE date__strptime(const char *str, size_t slen,
+ const char *fmt, size_t flen, VALUE hash);
+
+static VALUE
+date_s__strptime_internal(int argc, VALUE *argv, VALUE klass,
+ const char *default_fmt)
+{
+ VALUE vstr, vfmt, hash;
+ const char *str, *fmt;
+ size_t slen, flen;
+
+ rb_scan_args(argc, argv, "11", &vstr, &vfmt);
+
+ StringValue(vstr);
+ if (!rb_enc_str_asciicompat_p(vstr))
+ rb_raise(rb_eArgError,
+ "string should have ASCII compatible encoding");
+ str = RSTRING_PTR(vstr);
+ slen = RSTRING_LEN(vstr);
+ if (argc < 2) {
+ fmt = default_fmt;
+ flen = strlen(default_fmt);
+ }
+ else {
+ StringValue(vfmt);
+ if (!rb_enc_str_asciicompat_p(vfmt))
+ rb_raise(rb_eArgError,
+ "format should have ASCII compatible encoding");
+ fmt = RSTRING_PTR(vfmt);
+ flen = RSTRING_LEN(vfmt);
+ }
+ hash = rb_hash_new();
+ if (NIL_P(date__strptime(str, slen, fmt, flen, hash)))
+ return Qnil;
+
+ {
+ VALUE zone = ref_hash("zone");
+ VALUE left = ref_hash("leftover");
+
+ if (!NIL_P(zone)) {
+ rb_enc_copy(zone, vstr);
+ OBJ_INFECT(zone, vstr);
+ set_hash("zone", zone);
+ }
+ if (!NIL_P(left)) {
+ rb_enc_copy(left, vstr);
+ OBJ_INFECT(left, vstr);
+ set_hash("leftover", left);
+ }
+ }
+
+ return hash;
+}
+
+/*
+ * call-seq:
+ * Date._strptime(string[, format='%F']) -> hash
+ *
+ * Parses the given representation of date and time with the given
+ * template, and returns a hash of parsed elements. _strptime does
+ * not support specification of flags and width unlike strftime.
+ *
+ * Date._strptime('2001-02-03', '%Y-%m-%d')
+ * #=> {:year=>2001, :mon=>2, :mday=>3}
+ *
+ * See also strptime(3) and strftime.
+ */
+static VALUE
+date_s__strptime(int argc, VALUE *argv, VALUE klass)
+{
+ return date_s__strptime_internal(argc, argv, klass, "%F");
+}
+
+/*
+ * call-seq:
+ * Date.strptime([string='-4712-01-01'[, format='%F'[, start=ITALY]]]) -> date
+ *
+ * Parses the given representation of date and time with the given
+ * template, and creates a date object. strptime does not support
+ * specification of flags and width unlike strftime.
+ *
+ * Date.strptime('2001-02-03', '%Y-%m-%d') #=> #<Date: 2001-02-03 ...>
+ * Date.strptime('03-02-2001', '%d-%m-%Y') #=> #<Date: 2001-02-03 ...>
+ * Date.strptime('2001-034', '%Y-%j') #=> #<Date: 2001-02-03 ...>
+ * Date.strptime('2001-W05-6', '%G-W%V-%u') #=> #<Date: 2001-02-03 ...>
+ * Date.strptime('2001 04 6', '%Y %U %w') #=> #<Date: 2001-02-03 ...>
+ * Date.strptime('2001 05 6', '%Y %W %u') #=> #<Date: 2001-02-03 ...>
+ * Date.strptime('sat3feb01', '%a%d%b%y') #=> #<Date: 2001-02-03 ...>
+ *
+ * See also strptime(3) and strftime.
+ */
+static VALUE
+date_s_strptime(int argc, VALUE *argv, VALUE klass)
+{
+ VALUE str, fmt, sg;
+
+ rb_scan_args(argc, argv, "03", &str, &fmt, &sg);
+
+ switch (argc) {
+ case 0:
+ str = rb_str_new2("-4712-01-01");
+ case 1:
+ fmt = rb_str_new2("%F");
+ case 2:
+ sg = INT2FIX(DEFAULT_SG);
+ }
+
+ {
+ VALUE argv2[2], hash;
+
+ argv2[0] = str;
+ argv2[1] = fmt;
+ hash = date_s__strptime(2, argv2, klass);
+ return d_new_by_frags(klass, hash, sg);
+ }
+}
+
+VALUE date__parse(VALUE str, VALUE comp);
+
+static VALUE
+date_s__parse_internal(int argc, VALUE *argv, VALUE klass)
+{
+ VALUE vstr, vcomp, hash;
+
+ rb_scan_args(argc, argv, "11", &vstr, &vcomp);
+ StringValue(vstr);
+ if (!rb_enc_str_asciicompat_p(vstr))
+ rb_raise(rb_eArgError,
+ "string should have ASCII compatible encoding");
+ if (argc < 2)
+ vcomp = Qtrue;
+
+ hash = date__parse(vstr, vcomp);
+
+ {
+ VALUE zone = ref_hash("zone");
+
+ if (!NIL_P(zone)) {
+ rb_enc_copy(zone, vstr);
+ OBJ_INFECT(zone, vstr);
+ set_hash("zone", zone);
+ }
+ }
+
+ return hash;
+}
+
+/*
+ * call-seq:
+ * Date._parse(string[, comp=true]) -> hash
+ *
+ * Parses the given representation of date and time, and returns a
+ * hash of parsed elements. This method does not function as a
+ * validator.
+ *
+ * If the optional second argument is true and the detected year is in
+ * the range "00" to "99", considers the year a 2-digit form and makes
+ * it full.
+ *
+ * Date._parse('2001-02-03') #=> {:year=>2001, :mon=>2, :mday=>3}
+ */
+static VALUE
+date_s__parse(int argc, VALUE *argv, VALUE klass)
+{
+ return date_s__parse_internal(argc, argv, klass);
+}
+
+/*
+ * call-seq:
+ * Date.parse(string='-4712-01-01'[, comp=true[, start=ITALY]]) -> date
+ *
+ * Parses the given representation of date and time, and creates a
+ * date object. This method does not function as a validator.
+ *
+ * If the optional second argument is true and the detected year is in
+ * the range "00" to "99", considers the year a 2-digit form and makes
+ * it full.
+ *
+ * Date.parse('2001-02-03') #=> #<Date: 2001-02-03 ...>
+ * Date.parse('20010203') #=> #<Date: 2001-02-03 ...>
+ * Date.parse('3rd Feb 2001') #=> #<Date: 2001-02-03 ...>
+ */
+static VALUE
+date_s_parse(int argc, VALUE *argv, VALUE klass)
+{
+ VALUE str, comp, sg;
+
+ rb_scan_args(argc, argv, "03", &str, &comp, &sg);
+
+ switch (argc) {
+ case 0:
+ str = rb_str_new2("-4712-01-01");
+ case 1:
+ comp = Qtrue;
+ case 2:
+ sg = INT2FIX(DEFAULT_SG);
+ }
+
+ {
+ VALUE argv2[2], hash;
+
+ argv2[0] = str;
+ argv2[1] = comp;
+ hash = date_s__parse(2, argv2, klass);
+ return d_new_by_frags(klass, hash, sg);
+ }
+}
+
+VALUE date__iso8601(VALUE);
+VALUE date__rfc3339(VALUE);
+VALUE date__xmlschema(VALUE);
+VALUE date__rfc2822(VALUE);
+VALUE date__httpdate(VALUE);
+VALUE date__jisx0301(VALUE);
+
+/*
+ * call-seq:
+ * Date._iso8601(string) -> hash
+ *
+ * Returns a hash of parsed elements.
+ */
+static VALUE
+date_s__iso8601(VALUE klass, VALUE str)
+{
+ return date__iso8601(str);
+}
+
+/*
+ * call-seq:
+ * Date.iso8601(string='-4712-01-01'[, start=ITALY]) -> date
+ *
+ * Creates a new Date object by parsing from a string according to
+ * some typical ISO 8601 formats.
+ *
+ * Date.iso8601('2001-02-03') #=> #<Date: 2001-02-03 ...>
+ * Date.iso8601('20010203') #=> #<Date: 2001-02-03 ...>
+ * Date.iso8601('2001-W05-6') #=> #<Date: 2001-02-03 ...>
+ */
+static VALUE
+date_s_iso8601(int argc, VALUE *argv, VALUE klass)
+{
+ VALUE str, sg;
+
+ rb_scan_args(argc, argv, "02", &str, &sg);
+
+ switch (argc) {
+ case 0:
+ str = rb_str_new2("-4712-01-01");
+ case 1:
+ sg = INT2FIX(DEFAULT_SG);
+ }
+
+ {
+ VALUE hash = date_s__iso8601(klass, str);
+ return d_new_by_frags(klass, hash, sg);
+ }
+}
+
+/*
+ * call-seq:
+ * Date._rfc3339(string) -> hash
+ *
+ * Returns a hash of parsed elements.
+ */
+static VALUE
+date_s__rfc3339(VALUE klass, VALUE str)
+{
+ return date__rfc3339(str);
+}
+
+/*
+ * call-seq:
+ * Date.rfc3339(string='-4712-01-01T00:00:00+00:00'[, start=ITALY]) -> date
+ *
+ * Creates a new Date object by parsing from a string according to
+ * some typical RFC 3339 formats.
+ *
+ * Date.rfc3339('2001-02-03T04:05:06+07:00') #=> #<Date: 2001-02-03 ...>
+ */
+static VALUE
+date_s_rfc3339(int argc, VALUE *argv, VALUE klass)
+{
+ VALUE str, sg;
+
+ rb_scan_args(argc, argv, "02", &str, &sg);
+
+ switch (argc) {
+ case 0:
+ str = rb_str_new2("-4712-01-01T00:00:00+00:00");
+ case 1:
+ sg = INT2FIX(DEFAULT_SG);
+ }
+
+ {
+ VALUE hash = date_s__rfc3339(klass, str);
+ return d_new_by_frags(klass, hash, sg);
+ }
+}
+
+/*
+ * call-seq:
+ * Date._xmlschema(string) -> hash
+ *
+ * Returns a hash of parsed elements.
+ */
+static VALUE
+date_s__xmlschema(VALUE klass, VALUE str)
+{
+ return date__xmlschema(str);
+}
+
+/*
+ * call-seq:
+ * Date.xmlschema(string='-4712-01-01'[, start=ITALY]) -> date
+ *
+ * Creates a new Date object by parsing from a string according to
+ * some typical XML Schema formats.
+ *
+ * Date.xmlschema('2001-02-03') #=> #<Date: 2001-02-03 ...>
+ */
+static VALUE
+date_s_xmlschema(int argc, VALUE *argv, VALUE klass)
+{
+ VALUE str, sg;
+
+ rb_scan_args(argc, argv, "02", &str, &sg);
+
+ switch (argc) {
+ case 0:
+ str = rb_str_new2("-4712-01-01");
+ case 1:
+ sg = INT2FIX(DEFAULT_SG);
+ }
+
+ {
+ VALUE hash = date_s__xmlschema(klass, str);
+ return d_new_by_frags(klass, hash, sg);
+ }
+}
+
+/*
+ * call-seq:
+ * Date._rfc2822(string) -> hash
+ * Date._rfc822(string) -> hash
+ *
+ * Returns a hash of parsed elements.
+ */
+static VALUE
+date_s__rfc2822(VALUE klass, VALUE str)
+{
+ return date__rfc2822(str);
+}
+
+/*
+ * call-seq:
+ * Date.rfc2822(string='Mon, 1 Jan -4712 00:00:00 +0000'[, start=ITALY]) -> date
+ * Date.rfc822(string='Mon, 1 Jan -4712 00:00:00 +0000'[, start=ITALY]) -> date
+ *
+ * Creates a new Date object by parsing from a string according to
+ * some typical RFC 2822 formats.
+ *
+ * Date.rfc2822('Sat, 3 Feb 2001 00:00:00 +0000')
+ * #=> #<Date: 2001-02-03 ...>
+ */
+static VALUE
+date_s_rfc2822(int argc, VALUE *argv, VALUE klass)
+{
+ VALUE str, sg;
+
+ rb_scan_args(argc, argv, "02", &str, &sg);
+
+ switch (argc) {
+ case 0:
+ str = rb_str_new2("Mon, 1 Jan -4712 00:00:00 +0000");
+ case 1:
+ sg = INT2FIX(DEFAULT_SG);
+ }
+
+ {
+ VALUE hash = date_s__rfc2822(klass, str);
+ return d_new_by_frags(klass, hash, sg);
+ }
+}
+
+/*
+ * call-seq:
+ * Date._httpdate(string) -> hash
+ *
+ * Returns a hash of parsed elements.
+ */
+static VALUE
+date_s__httpdate(VALUE klass, VALUE str)
+{
+ return date__httpdate(str);
+}
+
+/*
+ * call-seq:
+ * Date.httpdate(string='Mon, 01 Jan -4712 00:00:00 GMT'[, start=ITALY]) -> date
+ *
+ * Creates a new Date object by parsing from a string according to
+ * some RFC 2616 format.
+ *
+ * Date.httpdate('Sat, 03 Feb 2001 00:00:00 GMT')
+ * #=> #<Date: 2001-02-03 ...>
+ */
+static VALUE
+date_s_httpdate(int argc, VALUE *argv, VALUE klass)
+{
+ VALUE str, sg;
+
+ rb_scan_args(argc, argv, "02", &str, &sg);
+
+ switch (argc) {
+ case 0:
+ str = rb_str_new2("Mon, 01 Jan -4712 00:00:00 GMT");
+ case 1:
+ sg = INT2FIX(DEFAULT_SG);
+ }
+
+ {
+ VALUE hash = date_s__httpdate(klass, str);
+ return d_new_by_frags(klass, hash, sg);
+ }
+}
+
+/*
+ * call-seq:
+ * Date._jisx0301(string) -> hash
+ *
+ * Returns a hash of parsed elements.
+ */
+static VALUE
+date_s__jisx0301(VALUE klass, VALUE str)
+{
+ return date__jisx0301(str);
+}
+
+/*
+ * call-seq:
+ * Date.jisx0301(string='-4712-01-01'[, start=ITALY]) -> date
+ *
+ * Creates a new Date object by parsing from a string according to
+ * some typical JIS X 0301 formats.
+ *
+ * Date.jisx0301('H13.02.03') #=> #<Date: 2001-02-03 ...>
+ */
+static VALUE
+date_s_jisx0301(int argc, VALUE *argv, VALUE klass)
+{
+ VALUE str, sg;
+
+ rb_scan_args(argc, argv, "02", &str, &sg);
+
+ switch (argc) {
+ case 0:
+ str = rb_str_new2("-4712-01-01");
+ case 1:
+ sg = INT2FIX(DEFAULT_SG);
+ }
+
+ {
+ VALUE hash = date_s__jisx0301(klass, str);
+ return d_new_by_frags(klass, hash, sg);
+ }
+}
+
+static VALUE
+dup_obj(VALUE self)
+{
+ get_d1a(self);
+
+ if (simple_dat_p(adat)) {
+ VALUE new = d_lite_s_alloc_simple(rb_obj_class(self));
+ {
+ get_d1b(new);
+ bdat->s = adat->s;
+ RB_OBJ_WRITTEN(new, Qundef, bdat->s.nth);
+ return new;
+ }
+ }
+ else {
+ VALUE new = d_lite_s_alloc_complex(rb_obj_class(self));
+ {
+ get_d1b(new);
+ bdat->c = adat->c;
+ RB_OBJ_WRITTEN(new, Qundef, bdat->c.nth);
+ RB_OBJ_WRITTEN(new, Qundef, bdat->c.sf);
+ return new;
+ }
+ }
+}
+
+static VALUE
+dup_obj_as_complex(VALUE self)
+{
+ get_d1a(self);
+
+ if (simple_dat_p(adat)) {
+ VALUE new = d_lite_s_alloc_complex(rb_obj_class(self));
+ {
+ get_d1b(new);
+ copy_simple_to_complex(new, &bdat->c, &adat->s);
+ bdat->c.flags |= HAVE_DF | COMPLEX_DAT;
+ return new;
+ }
+ }
+ else {
+ VALUE new = d_lite_s_alloc_complex(rb_obj_class(self));
+ {
+ get_d1b(new);
+ bdat->c = adat->c;
+ RB_OBJ_WRITTEN(new, Qundef, bdat->c.nth);
+ RB_OBJ_WRITTEN(new, Qundef, bdat->c.sf);
+ return new;
+ }
+ }
+}
+
+#define val2off(vof,iof) \
+{\
+ if (!offset_to_sec(vof, &iof)) {\
+ iof = 0;\
+ rb_warning("invalid offset is ignored");\
+ }\
+}
+
+#ifndef NDEBUG
+static VALUE
+d_lite_initialize(int argc, VALUE *argv, VALUE self)
+{
+ VALUE jd, vjd, vdf, sf, vsf, vof, vsg;
+ int df, of;
+ double sg;
+
+ rb_check_frozen(self);
+ rb_check_trusted(self);
+
+ rb_scan_args(argc, argv, "05", &vjd, &vdf, &vsf, &vof, &vsg);
+
+ jd = INT2FIX(0);
+ df = 0;
+ sf = INT2FIX(0);
+ of = 0;
+ sg = DEFAULT_SG;
+
+ switch (argc) {
+ case 5:
+ val2sg(vsg, sg);
+ case 4:
+ val2off(vof, of);
+ case 3:
+ sf = vsf;
+ if (f_lt_p(sf, INT2FIX(0)) ||
+ f_ge_p(sf, INT2FIX(SECOND_IN_NANOSECONDS)))
+ rb_raise(rb_eArgError, "invalid second fraction");
+ case 2:
+ df = NUM2INT(vdf);
+ if (df < 0 || df >= DAY_IN_SECONDS)
+ rb_raise(rb_eArgError, "invalid day fraction");
+ case 1:
+ jd = vjd;
+ }
+
+ {
+ VALUE nth;
+ int rjd;
+
+ get_d1(self);
+
+ decode_jd(jd, &nth, &rjd);
+ if (!df && f_zero_p(sf) && !of) {
+ set_to_simple(self, &dat->s, nth, rjd, sg, 0, 0, 0, HAVE_JD);
+ }
+ else {
+ if (!complex_dat_p(dat))
+ rb_raise(rb_eArgError,
+ "cannot load complex into simple");
+
+ set_to_complex(&dat->c, nth, rjd, df, sf, of, sg,
+ 0, 0, 0, 0, 0, 0, HAVE_JD | HAVE_DF | COMPLEX_DAT);
+ }
+ }
+ return self;
+}
+#endif
+
+/* :nodoc: */
+static VALUE
+d_lite_initialize_copy(VALUE copy, VALUE date)
+{
+ rb_check_frozen(copy);
+ rb_check_trusted(copy);
+
+ if (copy == date)
+ return copy;
+ {
+ get_d2(copy, date);
+ if (simple_dat_p(bdat)) {
+ adat->s = bdat->s;
+ adat->s.flags &= ~COMPLEX_DAT;
+ }
+ else {
+ if (!complex_dat_p(adat))
+ rb_raise(rb_eArgError,
+ "cannot load complex into simple");
+
+ adat->c = bdat->c;
+ adat->c.flags |= COMPLEX_DAT;
+ }
+ }
+ return copy;
+}
+
+#ifndef NDEBUG
+static VALUE
+d_lite_fill(VALUE self)
+{
+ get_d1(self);
+
+ if (simple_dat_p(dat)) {
+ get_s_jd(dat);
+ get_s_civil(dat);
+ }
+ else {
+ get_c_jd(dat);
+ get_c_civil(dat);
+ get_c_df(dat);
+ get_c_time(dat);
+ }
+ return self;
+}
+#endif
+
+/*
+ * call-seq:
+ * d.ajd -> rational
+ *
+ * Returns the astronomical Julian day number. This is a fractional
+ * number, which is not adjusted by the offset.
+ *
+ * DateTime.new(2001,2,3,4,5,6,'+7').ajd #=> (11769328217/4800)
+ * DateTime.new(2001,2,2,14,5,6,'-7').ajd #=> (11769328217/4800)
+ */
+static VALUE
+d_lite_ajd(VALUE self)
+{
+ get_d1(self);
+ return m_ajd(dat);
+}
+
+/*
+ * call-seq:
+ * d.amjd -> rational
+ *
+ * Returns the astronomical modified Julian day number. This is
+ * a fractional number, which is not adjusted by the offset.
+ *
+ * DateTime.new(2001,2,3,4,5,6,'+7').amjd #=> (249325817/4800)
+ * DateTime.new(2001,2,2,14,5,6,'-7').amjd #=> (249325817/4800)
+ */
+static VALUE
+d_lite_amjd(VALUE self)
+{
+ get_d1(self);
+ return m_amjd(dat);
+}
+
+/*
+ * call-seq:
+ * d.jd -> integer
+ *
+ * Returns the Julian day number. This is a whole number, which is
+ * adjusted by the offset as the local time.
+ *
+ * DateTime.new(2001,2,3,4,5,6,'+7').jd #=> 2451944
+ * DateTime.new(2001,2,3,4,5,6,'-7').jd #=> 2451944
+ */
+static VALUE
+d_lite_jd(VALUE self)
+{
+ get_d1(self);
+ return m_real_local_jd(dat);
+}
+
+/*
+ * call-seq:
+ * d.mjd -> integer
+ *
+ * Returns the modified Julian day number. This is a whole number,
+ * which is adjusted by the offset as the local time.
+ *
+ * DateTime.new(2001,2,3,4,5,6,'+7').mjd #=> 51943
+ * DateTime.new(2001,2,3,4,5,6,'-7').mjd #=> 51943
+ */
+static VALUE
+d_lite_mjd(VALUE self)
+{
+ get_d1(self);
+ return f_sub(m_real_local_jd(dat), INT2FIX(2400001));
+}
+
+/*
+ * call-seq:
+ * d.ld -> integer
+ *
+ * Returns the Lilian day number. This is a whole number, which is
+ * adjusted by the offset as the local time.
+ *
+ * Date.new(2001,2,3).ld #=> 152784
+ */
+static VALUE
+d_lite_ld(VALUE self)
+{
+ get_d1(self);
+ return f_sub(m_real_local_jd(dat), INT2FIX(2299160));
+}
+
+/*
+ * call-seq:
+ * d.year -> integer
+ *
+ * Returns the year.
+ *
+ * Date.new(2001,2,3).year #=> 2001
+ * (Date.new(1,1,1) - 1).year #=> 0
+ */
+static VALUE
+d_lite_year(VALUE self)
+{
+ get_d1(self);
+ return m_real_year(dat);
+}
+
+/*
+ * call-seq:
+ * d.yday -> fixnum
+ *
+ * Returns the day of the year (1-366).
+ *
+ * Date.new(2001,2,3).yday #=> 34
+ */
+static VALUE
+d_lite_yday(VALUE self)
+{
+ get_d1(self);
+ return INT2FIX(m_yday(dat));
+}
+
+/*
+ * call-seq:
+ * d.mon -> fixnum
+ * d.month -> fixnum
+ *
+ * Returns the month (1-12).
+ *
+ * Date.new(2001,2,3).mon #=> 2
+ */
+static VALUE
+d_lite_mon(VALUE self)
+{
+ get_d1(self);
+ return INT2FIX(m_mon(dat));
+}
+
+/*
+ * call-seq:
+ * d.mday -> fixnum
+ * d.day -> fixnum
+ *
+ * Returns the day of the month (1-31).
+ *
+ * Date.new(2001,2,3).mday #=> 3
+ */
+static VALUE
+d_lite_mday(VALUE self)
+{
+ get_d1(self);
+ return INT2FIX(m_mday(dat));
+}
+
+/*
+ * call-seq:
+ * d.day_fraction -> rational
+ *
+ * Returns the fractional part of the day.
+ *
+ * DateTime.new(2001,2,3,12).day_fraction #=> (1/2)
+ */
+static VALUE
+d_lite_day_fraction(VALUE self)
+{
+ get_d1(self);
+ if (simple_dat_p(dat))
+ return INT2FIX(0);
+ return m_fr(dat);
+}
+
+/*
+ * call-seq:
+ * d.cwyear -> integer
+ *
+ * Returns the calendar week based year.
+ *
+ * Date.new(2001,2,3).cwyear #=> 2001
+ * Date.new(2000,1,1).cwyear #=> 1999
+ */
+static VALUE
+d_lite_cwyear(VALUE self)
+{
+ get_d1(self);
+ return m_real_cwyear(dat);
+}
+
+/*
+ * call-seq:
+ * d.cweek -> fixnum
+ *
+ * Returns the calendar week number (1-53).
+ *
+ * Date.new(2001,2,3).cweek #=> 5
+ */
+static VALUE
+d_lite_cweek(VALUE self)
+{
+ get_d1(self);
+ return INT2FIX(m_cweek(dat));
+}
+
+/*
+ * call-seq:
+ * d.cwday -> fixnum
+ *
+ * Returns the day of calendar week (1-7, Monday is 1).
+ *
+ * Date.new(2001,2,3).cwday #=> 6
+ */
+static VALUE
+d_lite_cwday(VALUE self)
+{
+ get_d1(self);
+ return INT2FIX(m_cwday(dat));
+}
+
+#ifndef NDEBUG
+static VALUE
+d_lite_wnum0(VALUE self)
+{
+ get_d1(self);
+ return INT2FIX(m_wnum0(dat));
+}
+
+static VALUE
+d_lite_wnum1(VALUE self)
+{
+ get_d1(self);
+ return INT2FIX(m_wnum1(dat));
+}
+#endif
+
+/*
+ * call-seq:
+ * d.wday -> fixnum
+ *
+ * Returns the day of week (0-6, Sunday is zero).
+ *
+ * Date.new(2001,2,3).wday #=> 6
+ */
+static VALUE
+d_lite_wday(VALUE self)
+{
+ get_d1(self);
+ return INT2FIX(m_wday(dat));
+}
+
+/*
+ * call-seq:
+ * d.sunday? -> bool
+ *
+ * Returns true if the date is Sunday.
+ */
+static VALUE
+d_lite_sunday_p(VALUE self)
+{
+ get_d1(self);
+ return f_boolcast(m_wday(dat) == 0);
+}
+
+/*
+ * call-seq:
+ * d.monday? -> bool
+ *
+ * Returns true if the date is Monday.
+ */
+static VALUE
+d_lite_monday_p(VALUE self)
+{
+ get_d1(self);
+ return f_boolcast(m_wday(dat) == 1);
+}
+
+/*
+ * call-seq:
+ * d.tuesday? -> bool
+ *
+ * Returns true if the date is Tuesday.
+ */
+static VALUE
+d_lite_tuesday_p(VALUE self)
+{
+ get_d1(self);
+ return f_boolcast(m_wday(dat) == 2);
+}
+
+/*
+ * call-seq:
+ * d.wednesday? -> bool
+ *
+ * Returns true if the date is Wednesday.
+ */
+static VALUE
+d_lite_wednesday_p(VALUE self)
+{
+ get_d1(self);
+ return f_boolcast(m_wday(dat) == 3);
+}
+
+/*
+ * call-seq:
+ * d.thursday? -> bool
+ *
+ * Returns true if the date is Thursday.
+ */
+static VALUE
+d_lite_thursday_p(VALUE self)
+{
+ get_d1(self);
+ return f_boolcast(m_wday(dat) == 4);
+}
+
+/*
+ * call-seq:
+ * d.friday? -> bool
+ *
+ * Returns true if the date is Friday.
+ */
+static VALUE
+d_lite_friday_p(VALUE self)
+{
+ get_d1(self);
+ return f_boolcast(m_wday(dat) == 5);
+}
+
+/*
+ * call-seq:
+ * d.saturday? -> bool
+ *
+ * Returns true if the date is Saturday.
+ */
+static VALUE
+d_lite_saturday_p(VALUE self)
+{
+ get_d1(self);
+ return f_boolcast(m_wday(dat) == 6);
+}
+
+#ifndef NDEBUG
+static VALUE
+d_lite_nth_kday_p(VALUE self, VALUE n, VALUE k)
+{
+ int rjd, ns;
+
+ get_d1(self);
+
+ if (NUM2INT(k) != m_wday(dat))
+ return Qfalse;
+
+ c_nth_kday_to_jd(m_year(dat), m_mon(dat),
+ NUM2INT(n), NUM2INT(k), m_virtual_sg(dat), /* !=m_sg() */
+ &rjd, &ns);
+ if (m_local_jd(dat) != rjd)
+ return Qfalse;
+ return Qtrue;
+}
+#endif
+
+/*
+ * call-seq:
+ * d.hour -> fixnum
+ *
+ * Returns the hour (0-23).
+ *
+ * DateTime.new(2001,2,3,4,5,6).hour #=> 4
+ */
+static VALUE
+d_lite_hour(VALUE self)
+{
+ get_d1(self);
+ return INT2FIX(m_hour(dat));
+}
+
+/*
+ * call-seq:
+ * d.min -> fixnum
+ * d.minute -> fixnum
+ *
+ * Returns the minute (0-59).
+ *
+ * DateTime.new(2001,2,3,4,5,6).min #=> 5
+ */
+static VALUE
+d_lite_min(VALUE self)
+{
+ get_d1(self);
+ return INT2FIX(m_min(dat));
+}
+
+/*
+ * call-seq:
+ * d.sec -> fixnum
+ * d.second -> fixnum
+ *
+ * Returns the second (0-59).
+ *
+ * DateTime.new(2001,2,3,4,5,6).sec #=> 6
+ */
+static VALUE
+d_lite_sec(VALUE self)
+{
+ get_d1(self);
+ return INT2FIX(m_sec(dat));
+}
+
+/*
+ * call-seq:
+ * d.sec_fraction -> rational
+ * d.second_fraction -> rational
+ *
+ * Returns the fractional part of the second.
+ *
+ * DateTime.new(2001,2,3,4,5,6.5).sec_fraction #=> (1/2)
+ */
+static VALUE
+d_lite_sec_fraction(VALUE self)
+{
+ get_d1(self);
+ return m_sf_in_sec(dat);
+}
+
+/*
+ * call-seq:
+ * d.offset -> rational
+ *
+ * Returns the offset.
+ *
+ * DateTime.parse('04pm+0730').offset #=> (5/16)
+ */
+static VALUE
+d_lite_offset(VALUE self)
+{
+ get_d1(self);
+ return m_of_in_day(dat);
+}
+
+/*
+ * call-seq:
+ * d.zone -> string
+ *
+ * Returns the timezone.
+ *
+ * DateTime.parse('04pm+0730').zone #=> "+07:30"
+ */
+static VALUE
+d_lite_zone(VALUE self)
+{
+ get_d1(self);
+ return m_zone(dat);
+}
+
+/*
+ * call-seq:
+ * d.julian? -> bool
+ *
+ * Retruns true if the date is before the day of calendar reform.
+ *
+ * Date.new(1582,10,15).julian? #=> false
+ * (Date.new(1582,10,15) - 1).julian? #=> true
+ */
+static VALUE
+d_lite_julian_p(VALUE self)
+{
+ get_d1(self);
+ return f_boolcast(m_julian_p(dat));
+}
+
+/*
+ * call-seq:
+ * d.gregorian? -> bool
+ *
+ * Retunrs true if the date is on or after the day of calendar reform.
+ *
+ * Date.new(1582,10,15).gregorian? #=> true
+ * (Date.new(1582,10,15) - 1).gregorian? #=> false
+ */
+static VALUE
+d_lite_gregorian_p(VALUE self)
+{
+ get_d1(self);
+ return f_boolcast(m_gregorian_p(dat));
+}
+
+/*
+ * call-seq:
+ * d.leap? -> bool
+ *
+ * Returns true if the year is a leap year.
+ *
+ * Date.new(2000).leap? #=> true
+ * Date.new(2001).leap? #=> false
+ */
+static VALUE
+d_lite_leap_p(VALUE self)
+{
+ int rjd, ns, ry, rm, rd;
+
+ get_d1(self);
+ if (m_gregorian_p(dat))
+ return f_boolcast(c_gregorian_leap_p(m_year(dat)));
+
+ c_civil_to_jd(m_year(dat), 3, 1, m_virtual_sg(dat),
+ &rjd, &ns);
+ c_jd_to_civil(rjd - 1, m_virtual_sg(dat), &ry, &rm, &rd);
+ return f_boolcast(rd == 29);
+}
+
+/*
+ * call-seq:
+ * d.start -> float
+ *
+ * Returns the Julian day number denoting the day of calendar reform.
+ *
+ * Date.new(2001,2,3).start #=> 2299161.0
+ * Date.new(2001,2,3,Date::GREGORIAN).start #=> -Infinity
+ */
+static VALUE
+d_lite_start(VALUE self)
+{
+ get_d1(self);
+ return DBL2NUM(m_sg(dat));
+}
+
+static void
+clear_civil(union DateData *x)
+{
+ if (simple_dat_p(x)) {
+ x->s.year = 0;
+#ifndef USE_PACK
+ x->s.mon = 0;
+ x->s.mday = 0;
+#else
+ x->s.pc = 0;
+#endif
+ x->s.flags &= ~HAVE_CIVIL;
+ }
+ else {
+ x->c.year = 0;
+#ifndef USE_PACK
+ x->c.mon = 0;
+ x->c.mday = 0;
+ x->c.hour = 0;
+ x->c.min = 0;
+ x->c.sec = 0;
+#else
+ x->c.pc = 0;
+#endif
+ x->c.flags &= ~(HAVE_CIVIL | HAVE_TIME);
+ }
+}
+
+static void
+set_sg(union DateData *x, double sg)
+{
+ if (simple_dat_p(x)) {
+ get_s_jd(x);
+ clear_civil(x);
+ x->s.sg = (date_sg_t)sg;
+ } else {
+ get_c_jd(x);
+ get_c_df(x);
+ clear_civil(x);
+ x->c.sg = (date_sg_t)sg;
+ }
+}
+
+static VALUE
+dup_obj_with_new_start(VALUE obj, double sg)
+{
+ volatile VALUE dup = dup_obj(obj);
+ {
+ get_d1(dup);
+ set_sg(dat, sg);
+ }
+ return dup;
+}
+
+/*
+ * call-seq:
+ * d.new_start([start=Date::ITALY]) -> date
+ *
+ * Duplicates self and resets its the day of calendar reform.
+ *
+ * d = Date.new(1582,10,15)
+ * d.new_start(Date::JULIAN) #=> #<Date: 1582-10-05 ...>
+ */
+static VALUE
+d_lite_new_start(int argc, VALUE *argv, VALUE self)
+{
+ VALUE vsg;
+ double sg;
+
+ rb_scan_args(argc, argv, "01", &vsg);
+
+ sg = DEFAULT_SG;
+ if (argc >= 1)
+ val2sg(vsg, sg);
+
+ return dup_obj_with_new_start(self, sg);
+}
+
+/*
+ * call-seq:
+ * d.italy -> date
+ *
+ * This method is equivalent to new_start(Date::ITALY).
+ */
+static VALUE
+d_lite_italy(VALUE self)
+{
+ return dup_obj_with_new_start(self, ITALY);
+}
+
+/*
+ * call-seq:
+ * d.england -> date
+ *
+ * This method is equivalent to new_start(Date::ENGLAND).
+ */
+static VALUE
+d_lite_england(VALUE self)
+{
+ return dup_obj_with_new_start(self, ENGLAND);
+}
+
+/*
+ * call-seq:
+ * d.julian -> date
+ *
+ * This method is equivalent to new_start(Date::JULIAN).
+ */
+static VALUE
+d_lite_julian(VALUE self)
+{
+ return dup_obj_with_new_start(self, JULIAN);
+}
+
+/*
+ * call-seq:
+ * d.gregorian -> date
+ *
+ * This method is equivalent to new_start(Date::GREGORIAN).
+ */
+static VALUE
+d_lite_gregorian(VALUE self)
+{
+ return dup_obj_with_new_start(self, GREGORIAN);
+}
+
+static void
+set_of(union DateData *x, int of)
+{
+ assert(complex_dat_p(x));
+ get_c_jd(x);
+ get_c_df(x);
+ clear_civil(x);
+ x->c.of = of;
+}
+
+static VALUE
+dup_obj_with_new_offset(VALUE obj, int of)
+{
+ volatile VALUE dup = dup_obj_as_complex(obj);
+ {
+ get_d1(dup);
+ set_of(dat, of);
+ }
+ return dup;
+}
+
+/*
+ * call-seq:
+ * d.new_offset([offset=0]) -> date
+ *
+ * Duplicates self and resets its offset.
+ *
+ * d = DateTime.new(2001,2,3,4,5,6,'-02:00')
+ * #=> #<DateTime: 2001-02-03T04:05:06-02:00 ...>
+ * d.new_offset('+09:00') #=> #<DateTime: 2001-02-03T15:05:06+09:00 ...>
+ */
+static VALUE
+d_lite_new_offset(int argc, VALUE *argv, VALUE self)
+{
+ VALUE vof;
+ int rof;
+
+ rb_scan_args(argc, argv, "01", &vof);
+
+ rof = 0;
+ if (argc >= 1)
+ val2off(vof, rof);
+
+ return dup_obj_with_new_offset(self, rof);
+}
+
+/*
+ * call-seq:
+ * d + other -> date
+ *
+ * Returns a date object pointing other days after self. The other
+ * should be a numeric value. If the other is flonum, assumes its
+ * precision is at most nanosecond.
+ *
+ * Date.new(2001,2,3) + 1 #=> #<Date: 2001-02-04 ...>
+ * DateTime.new(2001,2,3) + Rational(1,2)
+ * #=> #<DateTime: 2001-02-03T12:00:00+00:00 ...>
+ * DateTime.new(2001,2,3) + Rational(-1,2)
+ * #=> #<DateTime: 2001-02-02T12:00:00+00:00 ...>
+ * DateTime.jd(0,12) + DateTime.new(2001,2,3).ajd
+ * #=> #<DateTime: 2001-02-03T00:00:00+00:00 ...>
+ */
+static VALUE
+d_lite_plus(VALUE self, VALUE other)
+{
+ get_d1(self);
+
+ switch (TYPE(other)) {
+ case T_FIXNUM:
+ {
+ VALUE nth;
+ long t;
+ int jd;
+
+ nth = m_nth(dat);
+ t = FIX2LONG(other);
+ if (DIV(t, CM_PERIOD)) {
+ nth = f_add(nth, INT2FIX(DIV(t, CM_PERIOD)));
+ t = MOD(t, CM_PERIOD);
+ }
+
+ if (!t)
+ jd = m_jd(dat);
+ else {
+ jd = m_jd(dat) + (int)t;
+ canonicalize_jd(nth, jd);
+ }
+
+ if (simple_dat_p(dat))
+ return d_simple_new_internal(rb_obj_class(self),
+ nth, jd,
+ dat->s.sg,
+ 0, 0, 0,
+ (dat->s.flags | HAVE_JD) &
+ ~HAVE_CIVIL);
+ else
+ return d_complex_new_internal(rb_obj_class(self),
+ nth, jd,
+ dat->c.df, dat->c.sf,
+ dat->c.of, dat->c.sg,
+ 0, 0, 0,
+#ifndef USE_PACK
+ dat->c.hour,
+ dat->c.min,
+ dat->c.sec,
+#else
+ EX_HOUR(dat->c.pc),
+ EX_MIN(dat->c.pc),
+ EX_SEC(dat->c.pc),
+#endif
+ (dat->c.flags | HAVE_JD) &
+ ~HAVE_CIVIL);
+ }
+ break;
+ case T_BIGNUM:
+ {
+ VALUE nth;
+ int jd, s;
+
+ if (f_positive_p(other))
+ s = +1;
+ else {
+ s = -1;
+ other = f_negate(other);
+ }
+
+ nth = f_idiv(other, INT2FIX(CM_PERIOD));
+ jd = FIX2INT(f_mod(other, INT2FIX(CM_PERIOD)));
+
+ if (s < 0) {
+ nth = f_negate(nth);
+ jd = -jd;
+ }
+
+ if (!jd)
+ jd = m_jd(dat);
+ else {
+ jd = m_jd(dat) + jd;
+ canonicalize_jd(nth, jd);
+ }
+
+ if (f_zero_p(nth))
+ nth = m_nth(dat);
+ else
+ nth = f_add(m_nth(dat), nth);
+
+ if (simple_dat_p(dat))
+ return d_simple_new_internal(rb_obj_class(self),
+ nth, jd,
+ dat->s.sg,
+ 0, 0, 0,
+ (dat->s.flags | HAVE_JD) &
+ ~HAVE_CIVIL);
+ else
+ return d_complex_new_internal(rb_obj_class(self),
+ nth, jd,
+ dat->c.df, dat->c.sf,
+ dat->c.of, dat->c.sg,
+ 0, 0, 0,
+#ifndef USE_PACK
+ dat->c.hour,
+ dat->c.min,
+ dat->c.sec,
+#else
+ EX_HOUR(dat->c.pc),
+ EX_MIN(dat->c.pc),
+ EX_SEC(dat->c.pc),
+#endif
+ (dat->c.flags | HAVE_JD) &
+ ~HAVE_CIVIL);
+ }
+ break;
+ case T_FLOAT:
+ {
+ double jd, o, tmp;
+ int s, df;
+ VALUE nth, sf;
+
+ o = RFLOAT_VALUE(other);
+
+ if (o > 0)
+ s = +1;
+ else {
+ s = -1;
+ o = -o;
+ }
+
+ o = modf(o, &tmp);
+
+ if (!floor(tmp / CM_PERIOD)) {
+ nth = INT2FIX(0);
+ jd = (int)tmp;
+ }
+ else {
+ double i, f;
+
+ f = modf(tmp / CM_PERIOD, &i);
+ nth = f_floor(DBL2NUM(i));
+ jd = (int)(f * CM_PERIOD);
+ }
+
+ o *= DAY_IN_SECONDS;
+ o = modf(o, &tmp);
+ df = (int)tmp;
+ o *= SECOND_IN_NANOSECONDS;
+ sf = INT2FIX((int)round(o));
+
+ if (s < 0) {
+ jd = -jd;
+ df = -df;
+ sf = f_negate(sf);
+ }
+
+ if (f_zero_p(sf))
+ sf = m_sf(dat);
+ else {
+ sf = f_add(m_sf(dat), sf);
+ if (f_lt_p(sf, INT2FIX(0))) {
+ df -= 1;
+ sf = f_add(sf, INT2FIX(SECOND_IN_NANOSECONDS));
+ }
+ else if (f_ge_p(sf, INT2FIX(SECOND_IN_NANOSECONDS))) {
+ df += 1;
+ sf = f_sub(sf, INT2FIX(SECOND_IN_NANOSECONDS));
+ }
+ }
+
+ if (!df)
+ df = m_df(dat);
+ else {
+ df = m_df(dat) + df;
+ if (df < 0) {
+ jd -= 1;
+ df += DAY_IN_SECONDS;
+ }
+ else if (df >= DAY_IN_SECONDS) {
+ jd += 1;
+ df -= DAY_IN_SECONDS;
+ }
+ }
+
+ if (!jd)
+ jd = m_jd(dat);
+ else {
+ jd = m_jd(dat) + jd;
+ canonicalize_jd(nth, jd);
+ }
+
+ if (f_zero_p(nth))
+ nth = m_nth(dat);
+ else
+ nth = f_add(m_nth(dat), nth);
+
+ if (!df && f_zero_p(sf) && !m_of(dat))
+ return d_simple_new_internal(rb_obj_class(self),
+ nth, (int)jd,
+ m_sg(dat),
+ 0, 0, 0,
+ (dat->s.flags | HAVE_JD) &
+ ~(HAVE_CIVIL | HAVE_TIME |
+ COMPLEX_DAT));
+ else
+ return d_complex_new_internal(rb_obj_class(self),
+ nth, (int)jd,
+ df, sf,
+ m_of(dat), m_sg(dat),
+ 0, 0, 0,
+ 0, 0, 0,
+ (dat->c.flags |
+ HAVE_JD | HAVE_DF) &
+ ~(HAVE_CIVIL | HAVE_TIME));
+ }
+ break;
+ default:
+ if (!k_numeric_p(other))
+ rb_raise(rb_eTypeError, "expected numeric");
+ other = f_to_r(other);
+#ifdef CANONICALIZATION_FOR_MATHN
+ if (!k_rational_p(other))
+ return d_lite_plus(self, other);
+#endif
+ /* fall through */
+ case T_RATIONAL:
+ {
+ VALUE nth, sf, t;
+ int jd, df, s;
+
+ if (wholenum_p(other))
+ return d_lite_plus(self, rb_rational_num(other));
+
+ if (f_positive_p(other))
+ s = +1;
+ else {
+ s = -1;
+ other = f_negate(other);
+ }
+
+ nth = f_idiv(other, INT2FIX(CM_PERIOD));
+ t = f_mod(other, INT2FIX(CM_PERIOD));
+
+ jd = FIX2INT(f_idiv(t, INT2FIX(1)));
+ t = f_mod(t, INT2FIX(1));
+
+ t = f_mul(t, INT2FIX(DAY_IN_SECONDS));
+ df = FIX2INT(f_idiv(t, INT2FIX(1)));
+ t = f_mod(t, INT2FIX(1));
+
+ sf = f_mul(t, INT2FIX(SECOND_IN_NANOSECONDS));
+
+ if (s < 0) {
+ nth = f_negate(nth);
+ jd = -jd;
+ df = -df;
+ sf = f_negate(sf);
+ }
+
+ if (f_zero_p(sf))
+ sf = m_sf(dat);
+ else {
+ sf = f_add(m_sf(dat), sf);
+ if (f_lt_p(sf, INT2FIX(0))) {
+ df -= 1;
+ sf = f_add(sf, INT2FIX(SECOND_IN_NANOSECONDS));
+ }
+ else if (f_ge_p(sf, INT2FIX(SECOND_IN_NANOSECONDS))) {
+ df += 1;
+ sf = f_sub(sf, INT2FIX(SECOND_IN_NANOSECONDS));
+ }
+ }
+
+ if (!df)
+ df = m_df(dat);
+ else {
+ df = m_df(dat) + df;
+ if (df < 0) {
+ jd -= 1;
+ df += DAY_IN_SECONDS;
+ }
+ else if (df >= DAY_IN_SECONDS) {
+ jd += 1;
+ df -= DAY_IN_SECONDS;
+ }
+ }
+
+ if (!jd)
+ jd = m_jd(dat);
+ else {
+ jd = m_jd(dat) + jd;
+ canonicalize_jd(nth, jd);
+ }
+
+ if (f_zero_p(nth))
+ nth = m_nth(dat);
+ else
+ nth = f_add(m_nth(dat), nth);
+
+ if (!df && f_zero_p(sf) && !m_of(dat))
+ return d_simple_new_internal(rb_obj_class(self),
+ nth, jd,
+ m_sg(dat),
+ 0, 0, 0,
+ (dat->s.flags | HAVE_JD) &
+ ~(HAVE_CIVIL | HAVE_TIME |
+ COMPLEX_DAT));
+ else
+ return d_complex_new_internal(rb_obj_class(self),
+ nth, jd,
+ df, sf,
+ m_of(dat), m_sg(dat),
+ 0, 0, 0,
+ 0, 0, 0,
+ (dat->c.flags |
+ HAVE_JD | HAVE_DF) &
+ ~(HAVE_CIVIL | HAVE_TIME));
+ }
+ break;
+ }
+}
+
+static VALUE
+minus_dd(VALUE self, VALUE other)
+{
+ get_d2(self, other);
+
+ {
+ int d, df;
+ VALUE n, sf, r;
+
+ n = f_sub(m_nth(adat), m_nth(bdat));
+ d = m_jd(adat) - m_jd(bdat);
+ df = m_df(adat) - m_df(bdat);
+ sf = f_sub(m_sf(adat), m_sf(bdat));
+ canonicalize_jd(n, d);
+
+ if (df < 0) {
+ d -= 1;
+ df += DAY_IN_SECONDS;
+ }
+ else if (df >= DAY_IN_SECONDS) {
+ d += 1;
+ df -= DAY_IN_SECONDS;
+ }
+
+ if (f_lt_p(sf, INT2FIX(0))) {
+ df -= 1;
+ sf = f_add(sf, INT2FIX(SECOND_IN_NANOSECONDS));
+ }
+ else if (f_ge_p(sf, INT2FIX(SECOND_IN_NANOSECONDS))) {
+ df += 1;
+ sf = f_sub(sf, INT2FIX(SECOND_IN_NANOSECONDS));
+ }
+
+ if (f_zero_p(n))
+ r = INT2FIX(0);
+ else
+ r = f_mul(n, INT2FIX(CM_PERIOD));
+
+ if (d)
+ r = f_add(r, rb_rational_new1(INT2FIX(d)));
+ if (df)
+ r = f_add(r, isec_to_day(df));
+ if (f_nonzero_p(sf))
+ r = f_add(r, ns_to_day(sf));
+
+ if (RB_TYPE_P(r, T_RATIONAL))
+ return r;
+ return rb_rational_new1(r);
+ }
+}
+
+/*
+ * call-seq:
+ * d - other -> date or rational
+ *
+ * Returns the difference between the two dates if the other is a date
+ * object. If the other is a numeric value, returns a date object
+ * pointing other days before self. If the other is flonum, assumes
+ * its precision is at most nanosecond.
+ *
+ * Date.new(2001,2,3) - 1 #=> #<Date: 2001-02-02 ...>
+ * DateTime.new(2001,2,3) - Rational(1,2)
+ * #=> #<DateTime: 2001-02-02T12:00:00+00:00 ...>
+ * Date.new(2001,2,3) - Date.new(2001)
+ * #=> (33/1)
+ * DateTime.new(2001,2,3) - DateTime.new(2001,2,2,12)
+ * #=> (1/2)
+ */
+static VALUE
+d_lite_minus(VALUE self, VALUE other)
+{
+ if (k_date_p(other))
+ return minus_dd(self, other);
+
+ switch (TYPE(other)) {
+ case T_FIXNUM:
+ return d_lite_plus(self, LONG2NUM(-FIX2LONG(other)));
+ case T_FLOAT:
+ return d_lite_plus(self, DBL2NUM(-RFLOAT_VALUE(other)));
+ default:
+ if (!k_numeric_p(other))
+ rb_raise(rb_eTypeError, "expected numeric");
+ /* fall through */
+ case T_BIGNUM:
+ case T_RATIONAL:
+ return d_lite_plus(self, f_negate(other));
+ }
+}
+
+/*
+ * call-seq:
+ * d.next_day([n=1]) -> date
+ *
+ * This method is equivalent to d + n.
+ */
+static VALUE
+d_lite_next_day(int argc, VALUE *argv, VALUE self)
+{
+ VALUE n;
+
+ rb_scan_args(argc, argv, "01", &n);
+ if (argc < 1)
+ n = INT2FIX(1);
+ return d_lite_plus(self, n);
+}
+
+/*
+ * call-seq:
+ * d.prev_day([n=1]) -> date
+ *
+ * This method is equivalent to d - n.
+ */
+static VALUE
+d_lite_prev_day(int argc, VALUE *argv, VALUE self)
+{
+ VALUE n;
+
+ rb_scan_args(argc, argv, "01", &n);
+ if (argc < 1)
+ n = INT2FIX(1);
+ return d_lite_minus(self, n);
+}
+
+/*
+ * call-seq:
+ * d.succ -> date
+ * d.next -> date
+ *
+ * Returns a date object denoting the following day.
+ */
+static VALUE
+d_lite_next(VALUE self)
+{
+ return d_lite_next_day(0, (VALUE *)NULL, self);
+}
+
+/*
+ * call-seq:
+ * d >> n -> date
+ *
+ * Returns a date object pointing n months after self. The n should
+ * be a numeric value.
+ *
+ * Date.new(2001,2,3) >> 1 #=> #<Date: 2001-03-03 ...>
+ * Date.new(2001,1,31) >> 1 #=> #<Date: 2001-02-28 ...>
+ * Date.new(2001,2,3) >> -2 #=> #<Date: 2000-12-03 ...>
+ */
+static VALUE
+d_lite_rshift(VALUE self, VALUE other)
+{
+ VALUE t, y, nth, rjd2;
+ int m, d, rjd;
+ double sg;
+
+ get_d1(self);
+ t = f_add3(f_mul(m_real_year(dat), INT2FIX(12)),
+ INT2FIX(m_mon(dat) - 1),
+ other);
+ if (FIXNUM_P(t)) {
+ long it = FIX2LONG(t);
+ y = LONG2NUM(DIV(it, 12));
+ it = MOD(it, 12);
+ m = (int)it + 1;
+ }
+ else {
+ y = f_idiv(t, INT2FIX(12));
+ t = f_mod(t, INT2FIX(12));
+ m = FIX2INT(t) + 1;
+ }
+ d = m_mday(dat);
+ sg = m_sg(dat);
+
+ while (1) {
+ int ry, rm, rd, ns;
+
+ if (valid_civil_p(y, m, d, sg,
+ &nth, &ry,
+ &rm, &rd, &rjd, &ns))
+ break;
+ if (--d < 1)
+ rb_raise(rb_eArgError, "invalid date");
+ }
+ encode_jd(nth, rjd, &rjd2);
+ return d_lite_plus(self, f_sub(rjd2, m_real_local_jd(dat)));
+}
+
+/*
+ * call-seq:
+ * d << n -> date
+ *
+ * Returns a date object pointing n months before self. The n should
+ * be a numeric value.
+ *
+ * Date.new(2001,2,3) << 1 #=> #<Date: 2001-01-03 ...>
+ * Date.new(2001,1,31) << 11 #=> #<Date: 2000-02-29 ...>
+ * Date.new(2001,2,3) << -1 #=> #<Date: 2001-03-03 ...>
+ */
+static VALUE
+d_lite_lshift(VALUE self, VALUE other)
+{
+ return d_lite_rshift(self, f_negate(other));
+}
+
+/*
+ * call-seq:
+ * d.next_month([n=1]) -> date
+ *
+ * This method is equivalent to d >> n
+ */
+static VALUE
+d_lite_next_month(int argc, VALUE *argv, VALUE self)
+{
+ VALUE n;
+
+ rb_scan_args(argc, argv, "01", &n);
+ if (argc < 1)
+ n = INT2FIX(1);
+ return d_lite_rshift(self, n);
+}
+
+/*
+ * call-seq:
+ * d.prev_month([n=1]) -> date
+ *
+ * This method is equivalent to d << n
+ */
+static VALUE
+d_lite_prev_month(int argc, VALUE *argv, VALUE self)
+{
+ VALUE n;
+
+ rb_scan_args(argc, argv, "01", &n);
+ if (argc < 1)
+ n = INT2FIX(1);
+ return d_lite_lshift(self, n);
+}
+
+/*
+ * call-seq:
+ * d.next_year([n=1]) -> date
+ *
+ * This method is equivalent to d >> (n * 12)
+ */
+static VALUE
+d_lite_next_year(int argc, VALUE *argv, VALUE self)
+{
+ VALUE n;
+
+ rb_scan_args(argc, argv, "01", &n);
+ if (argc < 1)
+ n = INT2FIX(1);
+ return d_lite_rshift(self, f_mul(n, INT2FIX(12)));
+}
+
+/*
+ * call-seq:
+ * d.prev_year([n=1]) -> date
+ *
+ * This method is equivalent to d << (n * 12)
+ */
+static VALUE
+d_lite_prev_year(int argc, VALUE *argv, VALUE self)
+{
+ VALUE n;
+
+ rb_scan_args(argc, argv, "01", &n);
+ if (argc < 1)
+ n = INT2FIX(1);
+ return d_lite_lshift(self, f_mul(n, INT2FIX(12)));
+}
+
+static VALUE d_lite_cmp(VALUE, VALUE);
+
+/*
+ * call-seq:
+ * d.step(limit[, step=1]) -> enumerator
+ * d.step(limit[, step=1]){|date| ...} -> self
+ *
+ * Iterates evaluation of the given block, which takes a date object.
+ * The limit should be a date object.
+ *
+ * Date.new(2001).step(Date.new(2001,-1,-1)).select{|d| d.sunday?}.size
+ * #=> 52
+ */
+static VALUE
+d_lite_step(int argc, VALUE *argv, VALUE self)
+{
+ VALUE limit, step, date;
+
+ rb_scan_args(argc, argv, "11", &limit, &step);
+
+ if (argc < 2)
+ step = INT2FIX(1);
+
+#if 0
+ if (f_zero_p(step))
+ rb_raise(rb_eArgError, "step can't be 0");
+#endif
+
+ RETURN_ENUMERATOR(self, argc, argv);
+
+ date = self;
+ switch (FIX2INT(f_cmp(step, INT2FIX(0)))) {
+ case -1:
+ while (FIX2INT(d_lite_cmp(date, limit)) >= 0) {
+ rb_yield(date);
+ date = d_lite_plus(date, step);
+ }
+ break;
+ case 0:
+ while (1)
+ rb_yield(date);
+ break;
+ case 1:
+ while (FIX2INT(d_lite_cmp(date, limit)) <= 0) {
+ rb_yield(date);
+ date = d_lite_plus(date, step);
+ }
+ break;
+ default:
+ abort();
+ }
+ return self;
+}
+
+/*
+ * call-seq:
+ * d.upto(max) -> enumerator
+ * d.upto(max){|date| ...} -> self
+ *
+ * This method is equivalent to step(max, 1){|date| ...}.
+ */
+static VALUE
+d_lite_upto(VALUE self, VALUE max)
+{
+ VALUE date;
+
+ RETURN_ENUMERATOR(self, 1, &max);
+
+ date = self;
+ while (FIX2INT(d_lite_cmp(date, max)) <= 0) {
+ rb_yield(date);
+ date = d_lite_plus(date, INT2FIX(1));
+ }
+ return self;
+}
+
+/*
+ * call-seq:
+ * d.downto(min) -> enumerator
+ * d.downto(min){|date| ...} -> self
+ *
+ * This method is equivalent to step(min, -1){|date| ...}.
+ */
+static VALUE
+d_lite_downto(VALUE self, VALUE min)
+{
+ VALUE date;
+
+ RETURN_ENUMERATOR(self, 1, &min);
+
+ date = self;
+ while (FIX2INT(d_lite_cmp(date, min)) >= 0) {
+ rb_yield(date);
+ date = d_lite_plus(date, INT2FIX(-1));
+ }
+ return self;
+}
+
+static VALUE
+cmp_gen(VALUE self, VALUE other)
+{
+ get_d1(self);
+
+ if (k_numeric_p(other))
+ return f_cmp(m_ajd(dat), other);
+ else if (k_date_p(other))
+ return f_cmp(m_ajd(dat), f_ajd(other));
+ return rb_num_coerce_cmp(self, other, rb_intern("<=>"));
+}
+
+static VALUE
+cmp_dd(VALUE self, VALUE other)
+{
+ get_d2(self, other);
+
+ {
+ VALUE a_nth, b_nth,
+ a_sf, b_sf;
+ int a_jd, b_jd,
+ a_df, b_df;
+
+ m_canonicalize_jd(self, adat);
+ m_canonicalize_jd(other, bdat);
+ a_nth = m_nth(adat);
+ b_nth = m_nth(bdat);
+ if (f_eqeq_p(a_nth, b_nth)) {
+ a_jd = m_jd(adat);
+ b_jd = m_jd(bdat);
+ if (a_jd == b_jd) {
+ a_df = m_df(adat);
+ b_df = m_df(bdat);
+ if (a_df == b_df) {
+ a_sf = m_sf(adat);
+ b_sf = m_sf(bdat);
+ if (f_eqeq_p(a_sf, b_sf)) {
+ return INT2FIX(0);
+ }
+ else if (f_lt_p(a_sf, b_sf)) {
+ return INT2FIX(-1);
+ }
+ else {
+ return INT2FIX(1);
+ }
+ }
+ else if (a_df < b_df) {
+ return INT2FIX(-1);
+ }
+ else {
+ return INT2FIX(1);
+ }
+ }
+ else if (a_jd < b_jd) {
+ return INT2FIX(-1);
+ }
+ else {
+ return INT2FIX(1);
+ }
+ }
+ else if (f_lt_p(a_nth, b_nth)) {
+ return INT2FIX(-1);
+ }
+ else {
+ return INT2FIX(1);
+ }
+ }
+}
+
+/*
+ * call-seq:
+ * d <=> other -> -1, 0, +1 or nil
+ *
+ * Compares the two dates and returns -1, zero, 1 or nil. The other
+ * should be a date object or a numeric value as an astronomical
+ * Julian day number.
+ *
+ * Date.new(2001,2,3) <=> Date.new(2001,2,4) #=> -1
+ * Date.new(2001,2,3) <=> Date.new(2001,2,3) #=> 0
+ * Date.new(2001,2,3) <=> Date.new(2001,2,2) #=> 1
+ * Date.new(2001,2,3) <=> Object.new #=> nil
+ * Date.new(2001,2,3) <=> Rational(4903887,2)#=> 0
+ *
+ * See also Comparable.
+ */
+static VALUE
+d_lite_cmp(VALUE self, VALUE other)
+{
+ if (!k_date_p(other))
+ return cmp_gen(self, other);
+
+ {
+ get_d2(self, other);
+
+ if (!(simple_dat_p(adat) && simple_dat_p(bdat) &&
+ m_gregorian_p(adat) == m_gregorian_p(bdat)))
+ return cmp_dd(self, other);
+
+ {
+ VALUE a_nth, b_nth;
+ int a_jd, b_jd;
+
+ m_canonicalize_jd(self, adat);
+ m_canonicalize_jd(other, bdat);
+ a_nth = m_nth(adat);
+ b_nth = m_nth(bdat);
+ if (f_eqeq_p(a_nth, b_nth)) {
+ a_jd = m_jd(adat);
+ b_jd = m_jd(bdat);
+ if (a_jd == b_jd) {
+ return INT2FIX(0);
+ }
+ else if (a_jd < b_jd) {
+ return INT2FIX(-1);
+ }
+ else {
+ return INT2FIX(1);
+ }
+ }
+ else if (f_lt_p(a_nth, b_nth)) {
+ return INT2FIX(-1);
+ }
+ else {
+ return INT2FIX(1);
+ }
+ }
+ }
+}
+
+static VALUE
+equal_gen(VALUE self, VALUE other)
+{
+ get_d1(self);
+
+ if (k_numeric_p(other))
+ return f_eqeq_p(m_real_local_jd(dat), other);
+ else if (k_date_p(other))
+ return f_eqeq_p(m_real_local_jd(dat), f_jd(other));
+ return rb_num_coerce_cmp(self, other, rb_intern("=="));
+}
+
+/*
+ * call-seq:
+ * d === other -> bool
+ *
+ * Returns true if they are the same day.
+ *
+ * Date.new(2001,2,3) === Date.new(2001,2,3)
+ * #=> true
+ * Date.new(2001,2,3) === Date.new(2001,2,4)
+ * #=> false
+ * DateTime.new(2001,2,3) === DateTime.new(2001,2,3,12)
+ * #=> true
+ * DateTime.new(2001,2,3) === DateTime.new(2001,2,3,0,0,0,'+24:00')
+ * #=> true
+ * DateTime.new(2001,2,3) === DateTime.new(2001,2,4,0,0,0,'+24:00')
+ * #=> false
+ */
+static VALUE
+d_lite_equal(VALUE self, VALUE other)
+{
+ if (!k_date_p(other))
+ return equal_gen(self, other);
+
+ {
+ get_d2(self, other);
+
+ if (!(m_gregorian_p(adat) == m_gregorian_p(bdat)))
+ return equal_gen(self, other);
+
+ {
+ VALUE a_nth, b_nth;
+ int a_jd, b_jd;
+
+ m_canonicalize_jd(self, adat);
+ m_canonicalize_jd(other, bdat);
+ a_nth = m_nth(adat);
+ b_nth = m_nth(bdat);
+ a_jd = m_local_jd(adat);
+ b_jd = m_local_jd(bdat);
+ if (f_eqeq_p(a_nth, b_nth) &&
+ a_jd == b_jd)
+ return Qtrue;
+ return Qfalse;
+ }
+ }
+}
+
+/* :nodoc: */
+static VALUE
+d_lite_eql_p(VALUE self, VALUE other)
+{
+ if (!k_date_p(other))
+ return Qfalse;
+ return f_zero_p(d_lite_cmp(self, other));
+}
+
+/* :nodoc: */
+static VALUE
+d_lite_hash(VALUE self)
+{
+ st_index_t v, h[4];
+
+ get_d1(self);
+ h[0] = m_nth(dat);
+ h[1] = m_jd(dat);
+ h[2] = m_df(dat);
+ h[3] = m_sf(dat);
+ v = rb_memhash(h, sizeof(h));
+ return LONG2FIX(v);
+}
+
+#include "date_tmx.h"
+static void set_tmx(VALUE, struct tmx *);
+static VALUE strftimev(const char *, VALUE,
+ void (*)(VALUE, struct tmx *));
+
+/*
+ * call-seq:
+ * d.to_s -> string
+ *
+ * Returns a string in an ISO 8601 format (This method doesn't use the
+ * expanded representations).
+ *
+ * Date.new(2001,2,3).to_s #=> "2001-02-03"
+ */
+static VALUE
+d_lite_to_s(VALUE self)
+{
+ return strftimev("%Y-%m-%d", self, set_tmx);
+}
+
+#ifndef NDEBUG
+static VALUE
+mk_inspect_flags(union DateData *x)
+{
+ return rb_enc_sprintf(rb_usascii_encoding(),
+ "%c%c%c%c%c",
+ (x->flags & COMPLEX_DAT) ? 'C' : 'S',
+ (x->flags & HAVE_JD) ? 'j' : '-',
+ (x->flags & HAVE_DF) ? 'd' : '-',
+ (x->flags & HAVE_CIVIL) ? 'c' : '-',
+ (x->flags & HAVE_TIME) ? 't' : '-');
+}
+
+static VALUE
+mk_inspect_raw(union DateData *x, const char *klass)
+{
+ if (simple_dat_p(x)) {
+ VALUE nth, flags;
+
+ RB_GC_GUARD(nth) = f_inspect(x->s.nth);
+ RB_GC_GUARD(flags) = mk_inspect_flags(x);
+
+ return rb_enc_sprintf(rb_usascii_encoding(),
+ "#<%s: "
+ "(%sth,%dj),+0s,%.0fj; "
+ "%dy%dm%dd; %s>",
+ klass ? klass : "?",
+ RSTRING_PTR(nth), x->s.jd, x->s.sg,
+#ifndef USE_PACK
+ x->s.year, x->s.mon, x->s.mday,
+#else
+ x->s.year,
+ EX_MON(x->s.pc), EX_MDAY(x->s.pc),
+#endif
+ RSTRING_PTR(flags));
+ }
+ else {
+ VALUE nth, sf, flags;
+
+ RB_GC_GUARD(nth) = f_inspect(x->c.nth);
+ RB_GC_GUARD(sf) = f_inspect(x->c.sf);
+ RB_GC_GUARD(flags) = mk_inspect_flags(x);
+
+ return rb_enc_sprintf(rb_usascii_encoding(),
+ "#<%s: "
+ "(%sth,%dj,%ds,%sn),%+ds,%.0fj; "
+ "%dy%dm%dd %dh%dm%ds; %s>",
+ klass ? klass : "?",
+ RSTRING_PTR(nth), x->c.jd, x->c.df,
+ RSTRING_PTR(sf),
+ x->c.of, x->c.sg,
+#ifndef USE_PACK
+ x->c.year, x->c.mon, x->c.mday,
+ x->c.hour, x->c.min, x->c.sec,
+#else
+ x->c.year,
+ EX_MON(x->c.pc), EX_MDAY(x->c.pc),
+ EX_HOUR(x->c.pc), EX_MIN(x->c.pc),
+ EX_SEC(x->c.pc),
+#endif
+ RSTRING_PTR(flags));
+ }
+}
+
+static VALUE
+d_lite_inspect_raw(VALUE self)
+{
+ get_d1(self);
+ return mk_inspect_raw(dat, rb_obj_classname(self));
+}
+#endif
+
+static VALUE
+mk_inspect(union DateData *x, const char *klass, const char *to_s)
+{
+ VALUE jd, sf;
+
+ RB_GC_GUARD(jd) = f_inspect(m_real_jd(x));
+ RB_GC_GUARD(sf) = f_inspect(m_sf(x));
+
+ return rb_enc_sprintf(rb_usascii_encoding(),
+ "#<%s: %s ((%sj,%ds,%sn),%+ds,%.0fj)>",
+ klass ? klass : "?",
+ to_s ? to_s : "?",
+ RSTRING_PTR(jd), m_df(x), RSTRING_PTR(sf),
+ m_of(x), m_sg(x));
+}
+
+/*
+ * call-seq:
+ * d.inspect -> string
+ *
+ * Returns the value as a string for inspection.
+ *
+ * Date.new(2001,2,3).inspect
+ * #=> "#<Date: 2001-02-03 ((2451944j,0s,0n),+0s,2299161j)>"
+ * DateTime.new(2001,2,3,4,5,6,'-7').inspect
+ * #=> "#<DateTime: 2001-02-03T04:05:06-07:00 ((2451944j,39906s,0n),-25200s,2299161j)>"
+ */
+static VALUE
+d_lite_inspect(VALUE self)
+{
+ get_d1(self);
+ {
+ VALUE to_s;
+
+ RB_GC_GUARD(to_s) = f_to_s(self);
+ return mk_inspect(dat, rb_obj_classname(self), RSTRING_PTR(to_s));
+ }
+}
+
+#include <errno.h>
+#include "date_tmx.h"
+
+size_t date_strftime(char *s, size_t maxsize, const char *format,
+ const struct tmx *tmx);
+
+#define SMALLBUF 100
+static size_t
+date_strftime_alloc(char **buf, const char *format,
+ struct tmx *tmx)
+{
+ size_t size, len, flen;
+
+ (*buf)[0] = '\0';
+ flen = strlen(format);
+ if (flen == 0) {
+ return 0;
+ }
+ errno = 0;
+ len = date_strftime(*buf, SMALLBUF, format, tmx);
+ if (len != 0 || (**buf == '\0' && errno != ERANGE)) return len;
+ for (size=1024; ; size*=2) {
+ *buf = xmalloc(size);
+ (*buf)[0] = '\0';
+ len = date_strftime(*buf, size, format, tmx);
+ /*
+ * buflen can be zero EITHER because there's not enough
+ * room in the string, or because the control command
+ * goes to the empty string. Make a reasonable guess that
+ * if the buffer is 1024 times bigger than the length of the
+ * format string, it's not failing for lack of room.
+ */
+ if (len > 0) break;
+ xfree(*buf);
+ if (size >= 1024 * flen) {
+ rb_sys_fail(format);
+ break;
+ }
+ }
+ return len;
+}
+
+static VALUE
+tmx_m_secs(union DateData *x)
+{
+ VALUE s;
+ int df;
+
+ s = day_to_sec(f_sub(m_real_jd(x),
+ UNIX_EPOCH_IN_CJD));
+ if (simple_dat_p(x))
+ return s;
+ df = m_df(x);
+ if (df)
+ s = f_add(s, INT2FIX(df));
+ return s;
+}
+
+#define MILLISECOND_IN_NANOSECONDS 1000000
+
+static VALUE
+tmx_m_msecs(union DateData *x)
+{
+ VALUE s, sf;
+
+ s = sec_to_ms(tmx_m_secs(x));
+ if (simple_dat_p(x))
+ return s;
+ sf = m_sf(x);
+ if (f_nonzero_p(sf))
+ s = f_add(s, f_div(sf, INT2FIX(MILLISECOND_IN_NANOSECONDS)));
+ return s;
+}
+
+static int
+tmx_m_of(union DateData *x)
+{
+ return m_of(x);
+}
+
+static char *
+tmx_m_zone(union DateData *x)
+{
+ return RSTRING_PTR(m_zone(x));
+}
+
+static struct tmx_funcs tmx_funcs = {
+ (VALUE (*)(void *))m_real_year,
+ (int (*)(void *))m_yday,
+ (int (*)(void *))m_mon,
+ (int (*)(void *))m_mday,
+ (VALUE (*)(void *))m_real_cwyear,
+ (int (*)(void *))m_cweek,
+ (int (*)(void *))m_cwday,
+ (int (*)(void *))m_wnum0,
+ (int (*)(void *))m_wnum1,
+ (int (*)(void *))m_wday,
+ (int (*)(void *))m_hour,
+ (int (*)(void *))m_min,
+ (int (*)(void *))m_sec,
+ (VALUE (*)(void *))m_sf_in_sec,
+ (VALUE (*)(void *))tmx_m_secs,
+ (VALUE (*)(void *))tmx_m_msecs,
+ (int (*)(void *))tmx_m_of,
+ (char *(*)(void *))tmx_m_zone
+};
+
+static void
+set_tmx(VALUE self, struct tmx *tmx)
+{
+ get_d1(self);
+ tmx->dat = (void *)dat;
+ tmx->funcs = &tmx_funcs;
+}
+
+static VALUE
+date_strftime_internal(int argc, VALUE *argv, VALUE self,
+ const char *default_fmt,
+ void (*func)(VALUE, struct tmx *))
+{
+ VALUE vfmt;
+ const char *fmt;
+ long len;
+ char buffer[SMALLBUF], *buf = buffer;
+ struct tmx tmx;
+ VALUE str;
+
+ rb_scan_args(argc, argv, "01", &vfmt);
+
+ if (argc < 1)
+ vfmt = rb_usascii_str_new2(default_fmt);
+ else {
+ StringValue(vfmt);
+ if (!rb_enc_str_asciicompat_p(vfmt)) {
+ rb_raise(rb_eArgError,
+ "format should have ASCII compatible encoding");
+ }
+ }
+ fmt = RSTRING_PTR(vfmt);
+ len = RSTRING_LEN(vfmt);
+ (*func)(self, &tmx);
+ if (memchr(fmt, '\0', len)) {
+ /* Ruby string may contain \0's. */
+ const char *p = fmt, *pe = fmt + len;
+
+ str = rb_str_new(0, 0);
+ while (p < pe) {
+ len = date_strftime_alloc(&buf, p, &tmx);
+ rb_str_cat(str, buf, len);
+ p += strlen(p);
+ if (buf != buffer) {
+ xfree(buf);
+ buf = buffer;
+ }
+ for (fmt = p; p < pe && !*p; ++p);
+ if (p > fmt) rb_str_cat(str, fmt, p - fmt);
+ }
+ rb_enc_copy(str, vfmt);
+ OBJ_INFECT(str, vfmt);
+ return str;
+ }
+ else
+ len = date_strftime_alloc(&buf, fmt, &tmx);
+
+ str = rb_str_new(buf, len);
+ if (buf != buffer) xfree(buf);
+ rb_enc_copy(str, vfmt);
+ OBJ_INFECT(str, vfmt);
+ return str;
+}
+
+/*
+ * call-seq:
+ * d.strftime([format='%F']) -> string
+ *
+ * Formats date according to the directives in the given format
+ * string.
+ * The directives begins with a percent (%) character.
+ * Any text not listed as a directive will be passed through to the
+ * output string.
+ *
+ * The directive consists of a percent (%) character,
+ * zero or more flags, optional minimum field width,
+ * optional modifier and a conversion specifier
+ * as follows.
+ *
+ * %<flags><width><modifier><conversion>
+ *
+ * Flags:
+ * - don't pad a numerical output.
+ * _ use spaces for padding.
+ * 0 use zeros for padding.
+ * ^ upcase the result string.
+ * # change case.
+ *
+ * The minimum field width specifies the minimum width.
+ *
+ * The modifiers are "E", "O", ":", "::" and ":::".
+ * "E" and "O" are ignored. No effect to result currently.
+ *
+ * Format directives:
+ *
+ * Date (Year, Month, Day):
+ * %Y - Year with century (can be negative, 4 digits at least)
+ * -0001, 0000, 1995, 2009, 14292, etc.
+ * %C - year / 100 (round down. 20 in 2009)
+ * %y - year % 100 (00..99)
+ *
+ * %m - Month of the year, zero-padded (01..12)
+ * %_m blank-padded ( 1..12)
+ * %-m no-padded (1..12)
+ * %B - The full month name (``January'')
+ * %^B uppercased (``JANUARY'')
+ * %b - The abbreviated month name (``Jan'')
+ * %^b uppercased (``JAN'')
+ * %h - Equivalent to %b
+ *
+ * %d - Day of the month, zero-padded (01..31)
+ * %-d no-padded (1..31)
+ * %e - Day of the month, blank-padded ( 1..31)
+ *
+ * %j - Day of the year (001..366)
+ *
+ * Time (Hour, Minute, Second, Subsecond):
+ * %H - Hour of the day, 24-hour clock, zero-padded (00..23)
+ * %k - Hour of the day, 24-hour clock, blank-padded ( 0..23)
+ * %I - Hour of the day, 12-hour clock, zero-padded (01..12)
+ * %l - Hour of the day, 12-hour clock, blank-padded ( 1..12)
+ * %P - Meridian indicator, lowercase (``am'' or ``pm'')
+ * %p - Meridian indicator, uppercase (``AM'' or ``PM'')
+ *
+ * %M - Minute of the hour (00..59)
+ *
+ * %S - Second of the minute (00..59)
+ *
+ * %L - Millisecond of the second (000..999)
+ * %N - Fractional seconds digits, default is 9 digits (nanosecond)
+ * %3N millisecond (3 digits) %15N femtosecond (15 digits)
+ * %6N microsecond (6 digits) %18N attosecond (18 digits)
+ * %9N nanosecond (9 digits) %21N zeptosecond (21 digits)
+ * %12N picosecond (12 digits) %24N yoctosecond (24 digits)
+ *
+ * Time zone:
+ * %z - Time zone as hour and minute offset from UTC (e.g. +0900)
+ * %:z - hour and minute offset from UTC with a colon (e.g. +09:00)
+ * %::z - hour, minute and second offset from UTC (e.g. +09:00:00)
+ * %:::z - hour, minute and second offset from UTC
+ * (e.g. +09, +09:30, +09:30:30)
+ * %Z - Time zone abbreviation name or something similar information.
+ *
+ * Weekday:
+ * %A - The full weekday name (``Sunday'')
+ * %^A uppercased (``SUNDAY'')
+ * %a - The abbreviated name (``Sun'')
+ * %^a uppercased (``SUN'')
+ * %u - Day of the week (Monday is 1, 1..7)
+ * %w - Day of the week (Sunday is 0, 0..6)
+ *
+ * ISO 8601 week-based year and week number:
+ * The week 1 of YYYY starts with a Monday and includes YYYY-01-04.
+ * The days in the year before the first week are in the last week of
+ * the previous year.
+ * %G - The week-based year
+ * %g - The last 2 digits of the week-based year (00..99)
+ * %V - Week number of the week-based year (01..53)
+ *
+ * Week number:
+ * The week 1 of YYYY starts with a Sunday or Monday (according to %U
+ * or %W). The days in the year before the first week are in week 0.
+ * %U - Week number of the year. The week starts with Sunday. (00..53)
+ * %W - Week number of the year. The week starts with Monday. (00..53)
+ *
+ * Seconds since the Unix Epoch:
+ * %s - Number of seconds since 1970-01-01 00:00:00 UTC.
+ * %Q - Number of milliseconds since 1970-01-01 00:00:00 UTC.
+ *
+ * Literal string:
+ * %n - Newline character (\n)
+ * %t - Tab character (\t)
+ * %% - Literal ``%'' character
+ *
+ * Combination:
+ * %c - date and time (%a %b %e %T %Y)
+ * %D - Date (%m/%d/%y)
+ * %F - The ISO 8601 date format (%Y-%m-%d)
+ * %v - VMS date (%e-%b-%Y)
+ * %x - Same as %D
+ * %X - Same as %T
+ * %r - 12-hour time (%I:%M:%S %p)
+ * %R - 24-hour time (%H:%M)
+ * %T - 24-hour time (%H:%M:%S)
+ * %+ - date(1) (%a %b %e %H:%M:%S %Z %Y)
+ *
+ * This method is similar to strftime() function defined in ISO C and POSIX.
+ * Several directives (%a, %A, %b, %B, %c, %p, %r, %x, %X, %E*, %O* and %Z)
+ * are locale dependent in the function.
+ * However this method is locale independent.
+ * So, the result may differ even if a same format string is used in other
+ * systems such as C.
+ * It is good practice to avoid %x and %X because there are corresponding
+ * locale independent representations, %D and %T.
+ *
+ * Examples:
+ *
+ * d = DateTime.new(2007,11,19,8,37,48,"-06:00")
+ * #=> #<DateTime: 2007-11-19T08:37:48-0600 ...>
+ * d.strftime("Printed on %m/%d/%Y") #=> "Printed on 11/19/2007"
+ * d.strftime("at %I:%M%p") #=> "at 08:37AM"
+ *
+ * Various ISO 8601 formats:
+ * %Y%m%d => 20071119 Calendar date (basic)
+ * %F => 2007-11-19 Calendar date (extended)
+ * %Y-%m => 2007-11 Calendar date, reduced accuracy, specific month
+ * %Y => 2007 Calendar date, reduced accuracy, specific year
+ * %C => 20 Calendar date, reduced accuracy, specific century
+ * %Y%j => 2007323 Ordinal date (basic)
+ * %Y-%j => 2007-323 Ordinal date (extended)
+ * %GW%V%u => 2007W471 Week date (basic)
+ * %G-W%V-%u => 2007-W47-1 Week date (extended)
+ * %GW%V => 2007W47 Week date, reduced accuracy, specific week (basic)
+ * %G-W%V => 2007-W47 Week date, reduced accuracy, specific week (extended)
+ * %H%M%S => 083748 Local time (basic)
+ * %T => 08:37:48 Local time (extended)
+ * %H%M => 0837 Local time, reduced accuracy, specific minute (basic)
+ * %H:%M => 08:37 Local time, reduced accuracy, specific minute (extended)
+ * %H => 08 Local time, reduced accuracy, specific hour
+ * %H%M%S,%L => 083748,000 Local time with decimal fraction, comma as decimal sign (basic)
+ * %T,%L => 08:37:48,000 Local time with decimal fraction, comma as decimal sign (extended)
+ * %H%M%S.%L => 083748.000 Local time with decimal fraction, full stop as decimal sign (basic)
+ * %T.%L => 08:37:48.000 Local time with decimal fraction, full stop as decimal sign (extended)
+ * %H%M%S%z => 083748-0600 Local time and the difference from UTC (basic)
+ * %T%:z => 08:37:48-06:00 Local time and the difference from UTC (extended)
+ * %Y%m%dT%H%M%S%z => 20071119T083748-0600 Date and time of day for calendar date (basic)
+ * %FT%T%:z => 2007-11-19T08:37:48-06:00 Date and time of day for calendar date (extended)
+ * %Y%jT%H%M%S%z => 2007323T083748-0600 Date and time of day for ordinal date (basic)
+ * %Y-%jT%T%:z => 2007-323T08:37:48-06:00 Date and time of day for ordinal date (extended)
+ * %GW%V%uT%H%M%S%z => 2007W471T083748-0600 Date and time of day for week date (basic)
+ * %G-W%V-%uT%T%:z => 2007-W47-1T08:37:48-06:00 Date and time of day for week date (extended)
+ * %Y%m%dT%H%M => 20071119T0837 Calendar date and local time (basic)
+ * %FT%R => 2007-11-19T08:37 Calendar date and local time (extended)
+ * %Y%jT%H%MZ => 2007323T0837Z Ordinal date and UTC of day (basic)
+ * %Y-%jT%RZ => 2007-323T08:37Z Ordinal date and UTC of day (extended)
+ * %GW%V%uT%H%M%z => 2007W471T0837-0600 Week date and local time and difference from UTC (basic)
+ * %G-W%V-%uT%R%:z => 2007-W47-1T08:37-06:00 Week date and local time and difference from UTC (extended)
+ *
+ * See also strftime(3) and strptime.
+ */
+static VALUE
+d_lite_strftime(int argc, VALUE *argv, VALUE self)
+{
+ return date_strftime_internal(argc, argv, self,
+ "%Y-%m-%d", set_tmx);
+}
+
+static VALUE
+strftimev(const char *fmt, VALUE self,
+ void (*func)(VALUE, struct tmx *))
+{
+ char buffer[SMALLBUF], *buf = buffer;
+ struct tmx tmx;
+ long len;
+ VALUE str;
+
+ (*func)(self, &tmx);
+ len = date_strftime_alloc(&buf, fmt, &tmx);
+ str = rb_usascii_str_new(buf, len);
+ if (buf != buffer) xfree(buf);
+ return str;
+}
+
+/*
+ * call-seq:
+ * d.asctime -> string
+ * d.ctime -> string
+ *
+ * Returns a string in asctime(3) format (but without "\n\0" at the
+ * end). This method is equivalent to strftime('%c').
+ *
+ * See also asctime(3) or ctime(3).
+ */
+static VALUE
+d_lite_asctime(VALUE self)
+{
+ return strftimev("%a %b %e %H:%M:%S %Y", self, set_tmx);
+}
+
+/*
+ * call-seq:
+ * d.iso8601 -> string
+ * d.xmlschema -> string
+ *
+ * This method is equivalent to strftime('%F').
+ */
+static VALUE
+d_lite_iso8601(VALUE self)
+{
+ return strftimev("%Y-%m-%d", self, set_tmx);
+}
+
+/*
+ * call-seq:
+ * d.rfc3339 -> string
+ *
+ * This method is equivalent to strftime('%FT%T%:z').
+ */
+static VALUE
+d_lite_rfc3339(VALUE self)
+{
+ return strftimev("%Y-%m-%dT%H:%M:%S%:z", self, set_tmx);
+}
+
+/*
+ * call-seq:
+ * d.rfc2822 -> string
+ * d.rfc822 -> string
+ *
+ * This method is equivalent to strftime('%a, %-d %b %Y %T %z').
+ */
+static VALUE
+d_lite_rfc2822(VALUE self)
+{
+ return strftimev("%a, %-d %b %Y %T %z", self, set_tmx);
+}
+
+/*
+ * call-seq:
+ * d.httpdate -> string
+ *
+ * This method is equivalent to strftime('%a, %d %b %Y %T GMT').
+ * See also RFC 2616.
+ */
+static VALUE
+d_lite_httpdate(VALUE self)
+{
+ volatile VALUE dup = dup_obj_with_new_offset(self, 0);
+ return strftimev("%a, %d %b %Y %T GMT", dup, set_tmx);
+}
+
+static VALUE
+jisx0301_date(VALUE jd, VALUE y)
+{
+ VALUE a[2];
+
+ if (f_lt_p(jd, INT2FIX(2405160)))
+ return rb_usascii_str_new2("%Y-%m-%d");
+ if (f_lt_p(jd, INT2FIX(2419614))) {
+ a[0] = rb_usascii_str_new2("M%02d" ".%%m.%%d");
+ a[1] = f_sub(y, INT2FIX(1867));
+ }
+ else if (f_lt_p(jd, INT2FIX(2424875))) {
+ a[0] = rb_usascii_str_new2("T%02d" ".%%m.%%d");
+ a[1] = f_sub(y, INT2FIX(1911));
+ }
+ else if (f_lt_p(jd, INT2FIX(2447535))) {
+ a[0] = rb_usascii_str_new2("S%02d" ".%%m.%%d");
+ a[1] = f_sub(y, INT2FIX(1925));
+ }
+ else {
+ a[0] = rb_usascii_str_new2("H%02d" ".%%m.%%d");
+ a[1] = f_sub(y, INT2FIX(1988));
+ }
+ return rb_f_sprintf(2, a);
+}
+
+/*
+ * call-seq:
+ * d.jisx0301 -> string
+ *
+ * Returns a string in a JIS X 0301 format.
+ *
+ * Date.new(2001,2,3).jisx0301 #=> "H13.02.03"
+ */
+static VALUE
+d_lite_jisx0301(VALUE self)
+{
+ VALUE s;
+
+ get_d1(self);
+ s = jisx0301_date(m_real_local_jd(dat),
+ m_real_year(dat));
+ return strftimev(RSTRING_PTR(s), self, set_tmx);
+}
+
+#ifndef NDEBUG
+static VALUE
+d_lite_marshal_dump_old(VALUE self)
+{
+ VALUE a;
+
+ get_d1(self);
+
+ a = rb_ary_new3(3,
+ m_ajd(dat),
+ m_of_in_day(dat),
+ DBL2NUM(m_sg(dat)));
+
+ if (FL_TEST(self, FL_EXIVAR)) {
+ rb_copy_generic_ivar(a, self);
+ FL_SET(a, FL_EXIVAR);
+ }
+
+ return a;
+}
+#endif
+
+/* :nodoc: */
+static VALUE
+d_lite_marshal_dump(VALUE self)
+{
+ VALUE a;
+
+ get_d1(self);
+
+ a = rb_ary_new3(6,
+ m_nth(dat),
+ INT2FIX(m_jd(dat)),
+ INT2FIX(m_df(dat)),
+ m_sf(dat),
+ INT2FIX(m_of(dat)),
+ DBL2NUM(m_sg(dat)));
+
+ if (FL_TEST(self, FL_EXIVAR)) {
+ rb_copy_generic_ivar(a, self);
+ FL_SET(a, FL_EXIVAR);
+ }
+
+ return a;
+}
+
+/* :nodoc: */
+static VALUE
+d_lite_marshal_load(VALUE self, VALUE a)
+{
+ get_d1(self);
+
+ rb_check_frozen(self);
+ rb_check_trusted(self);
+
+ if (!RB_TYPE_P(a, T_ARRAY))
+ rb_raise(rb_eTypeError, "expected an array");
+
+ switch (RARRAY_LEN(a)) {
+ case 2: /* 1.6.x */
+ case 3: /* 1.8.x, 1.9.2 */
+ {
+ VALUE ajd, of, sg, nth, sf;
+ int jd, df, rof;
+ double rsg;
+
+
+ if (RARRAY_LEN(a) == 2) {
+ ajd = f_sub(RARRAY_PTR(a)[0], half_days_in_day);
+ of = INT2FIX(0);
+ sg = RARRAY_PTR(a)[1];
+ if (!k_numeric_p(sg))
+ sg = DBL2NUM(RTEST(sg) ? GREGORIAN : JULIAN);
+ }
+ else {
+ ajd = RARRAY_PTR(a)[0];
+ of = RARRAY_PTR(a)[1];
+ sg = RARRAY_PTR(a)[2];
+ }
+
+ old_to_new(ajd, of, sg,
+ &nth, &jd, &df, &sf, &rof, &rsg);
+
+ if (!df && f_zero_p(sf) && !rof) {
+ set_to_simple(self, &dat->s, nth, jd, rsg, 0, 0, 0, HAVE_JD);
+ } else {
+ if (!complex_dat_p(dat))
+ rb_raise(rb_eArgError,
+ "cannot load complex into simple");
+
+ set_to_complex(self, &dat->c, nth, jd, df, sf, rof, rsg,
+ 0, 0, 0, 0, 0, 0,
+ HAVE_JD | HAVE_DF | COMPLEX_DAT);
+ }
+ }
+ break;
+ case 6:
+ {
+ VALUE nth, sf;
+ int jd, df, of;
+ double sg;
+
+ nth = RARRAY_PTR(a)[0];
+ jd = NUM2INT(RARRAY_PTR(a)[1]);
+ df = NUM2INT(RARRAY_PTR(a)[2]);
+ sf = RARRAY_PTR(a)[3];
+ of = NUM2INT(RARRAY_PTR(a)[4]);
+ sg = NUM2DBL(RARRAY_PTR(a)[5]);
+ if (!df && f_zero_p(sf) && !of) {
+ set_to_simple(self, &dat->s, nth, jd, sg, 0, 0, 0, HAVE_JD);
+ } else {
+ if (!complex_dat_p(dat))
+ rb_raise(rb_eArgError,
+ "cannot load complex into simple");
+
+ set_to_complex(self, &dat->c, nth, jd, df, sf, of, sg,
+ 0, 0, 0, 0, 0, 0,
+ HAVE_JD | HAVE_DF | COMPLEX_DAT);
+ }
+ }
+ break;
+ default:
+ rb_raise(rb_eTypeError, "invalid size");
+ break;
+ }
+
+ if (FL_TEST(a, FL_EXIVAR)) {
+ rb_copy_generic_ivar(self, a);
+ FL_SET(self, FL_EXIVAR);
+ }
+
+ return self;
+}
+
+/* :nodoc: */
+static VALUE
+date_s__load(VALUE klass, VALUE s)
+{
+ VALUE a, obj;
+
+ a = rb_marshal_load(s);
+ obj = d_lite_s_alloc(klass);
+ return d_lite_marshal_load(obj, a);
+}
+
+/* datetime */
+
+/*
+ * call-seq:
+ * DateTime.jd([jd=0[, hour=0[, minute=0[, second=0[, offset=0[, start=Date::ITALY]]]]]]) -> datetime
+ *
+ * Creates a datetime object denoting the given chronological Julian
+ * day number.
+ *
+ * DateTime.jd(2451944) #=> #<DateTime: 2001-02-03T00:00:00+00:00 ...>
+ * DateTime.jd(2451945) #=> #<DateTime: 2001-02-04T00:00:00+00:00 ...>
+ * DateTime.jd(Rational('0.5'))
+ * #=> #<DateTime: -4712-01-01T12:00:00+00:00 ...>
+ */
+static VALUE
+datetime_s_jd(int argc, VALUE *argv, VALUE klass)
+{
+ VALUE vjd, vh, vmin, vs, vof, vsg, jd, fr, fr2, ret;
+ int h, min, s, rof;
+ double sg;
+
+ rb_scan_args(argc, argv, "06", &vjd, &vh, &vmin, &vs, &vof, &vsg);
+
+ jd = INT2FIX(0);
+
+ h = min = s = 0;
+ fr2 = INT2FIX(0);
+ rof = 0;
+ sg = DEFAULT_SG;
+
+ switch (argc) {
+ case 6:
+ val2sg(vsg, sg);
+ case 5:
+ val2off(vof, rof);
+ case 4:
+ num2int_with_frac(s, positive_inf);
+ case 3:
+ num2int_with_frac(min, 3);
+ case 2:
+ num2int_with_frac(h, 2);
+ case 1:
+ num2num_with_frac(jd, 1);
+ }
+
+ {
+ VALUE nth;
+ int rh, rmin, rs, rjd, rjd2;
+
+ if (!c_valid_time_p(h, min, s, &rh, &rmin, &rs))
+ rb_raise(rb_eArgError, "invalid date");
+ canon24oc();
+
+ decode_jd(jd, &nth, &rjd);
+ rjd2 = jd_local_to_utc(rjd,
+ time_to_df(rh, rmin, rs),
+ rof);
+
+ ret = d_complex_new_internal(klass,
+ nth, rjd2,
+ 0, INT2FIX(0),
+ rof, sg,
+ 0, 0, 0,
+ rh, rmin, rs,
+ HAVE_JD | HAVE_TIME);
+ }
+ add_frac();
+ return ret;
+}
+
+/*
+ * call-seq:
+ * DateTime.ordinal([year=-4712[, yday=1[, hour=0[, minute=0[, second=0[, offset=0[, start=Date::ITALY]]]]]]]) -> datetime
+ *
+ * Creates a date-time object denoting the given ordinal date.
+ *
+ * DateTime.ordinal(2001,34) #=> #<DateTime: 2001-02-03T00:00:00+00:00 ...>
+ * DateTime.ordinal(2001,34,4,5,6,'+7')
+ * #=> #<DateTime: 2001-02-03T04:05:06+07:00 ...>
+ * DateTime.ordinal(2001,-332,-20,-55,-54,'+7')
+ * #=> #<DateTime: 2001-02-03T04:05:06+07:00 ...>
+ */
+static VALUE
+datetime_s_ordinal(int argc, VALUE *argv, VALUE klass)
+{
+ VALUE vy, vd, vh, vmin, vs, vof, vsg, y, fr, fr2, ret;
+ int d, h, min, s, rof;
+ double sg;
+
+ rb_scan_args(argc, argv, "07", &vy, &vd, &vh, &vmin, &vs, &vof, &vsg);
+
+ y = INT2FIX(-4712);
+ d = 1;
+
+ h = min = s = 0;
+ fr2 = INT2FIX(0);
+ rof = 0;
+ sg = DEFAULT_SG;
+
+ switch (argc) {
+ case 7:
+ val2sg(vsg, sg);
+ case 6:
+ val2off(vof, rof);
+ case 5:
+ num2int_with_frac(s, positive_inf);
+ case 4:
+ num2int_with_frac(min, 4);
+ case 3:
+ num2int_with_frac(h, 3);
+ case 2:
+ num2int_with_frac(d, 2);
+ case 1:
+ y = vy;
+ }
+
+ {
+ VALUE nth;
+ int ry, rd, rh, rmin, rs, rjd, rjd2, ns;
+
+ if (!valid_ordinal_p(y, d, sg,
+ &nth, &ry,
+ &rd, &rjd,
+ &ns))
+ rb_raise(rb_eArgError, "invalid date");
+ if (!c_valid_time_p(h, min, s, &rh, &rmin, &rs))
+ rb_raise(rb_eArgError, "invalid date");
+ canon24oc();
+
+ rjd2 = jd_local_to_utc(rjd,
+ time_to_df(rh, rmin, rs),
+ rof);
+
+ ret = d_complex_new_internal(klass,
+ nth, rjd2,
+ 0, INT2FIX(0),
+ rof, sg,
+ 0, 0, 0,
+ rh, rmin, rs,
+ HAVE_JD | HAVE_TIME);
+ }
+ add_frac();
+ return ret;
+}
+
+/*
+ * call-seq:
+ * DateTime.civil([year=-4712[, month=1[, mday=1[, hour=0[, minute=0[, second=0[, offset=0[, start=Date::ITALY]]]]]]]]) -> datetime
+ * DateTime.new([year=-4712[, month=1[, mday=1[, hour=0[, minute=0[, second=0[, offset=0[, start=Date::ITALY]]]]]]]]) -> datetime
+ *
+ * Creates a date-time object denoting the given calendar date.
+ *
+ * DateTime.new(2001,2,3) #=> #<DateTime: 2001-02-03T00:00:00+00:00 ...>
+ * DateTime.new(2001,2,3,4,5,6,'+7')
+ * #=> #<DateTime: 2001-02-03T04:05:06+07:00 ...>
+ * DateTime.new(2001,-11,-26,-20,-55,-54,'+7')
+ * #=> #<DateTime: 2001-02-03T04:05:06+07:00 ...>
+ */
+static VALUE
+datetime_s_civil(int argc, VALUE *argv, VALUE klass)
+{
+ VALUE vy, vm, vd, vh, vmin, vs, vof, vsg, y, fr, fr2, ret;
+ int m, d, h, min, s, rof;
+ double sg;
+
+ rb_scan_args(argc, argv, "08", &vy, &vm, &vd, &vh, &vmin, &vs, &vof, &vsg);
+
+ y = INT2FIX(-4712);
+ m = 1;
+ d = 1;
+
+ h = min = s = 0;
+ fr2 = INT2FIX(0);
+ rof = 0;
+ sg = DEFAULT_SG;
+
+ switch (argc) {
+ case 8:
+ val2sg(vsg, sg);
+ case 7:
+ val2off(vof, rof);
+ case 6:
+ num2int_with_frac(s, positive_inf);
+ case 5:
+ num2int_with_frac(min, 5);
+ case 4:
+ num2int_with_frac(h, 4);
+ case 3:
+ num2int_with_frac(d, 3);
+ case 2:
+ m = NUM2INT(vm);
+ case 1:
+ y = vy;
+ }
+
+ if (guess_style(y, sg) < 0) {
+ VALUE nth;
+ int ry, rm, rd, rh, rmin, rs;
+
+ if (!valid_gregorian_p(y, m, d,
+ &nth, &ry,
+ &rm, &rd))
+ rb_raise(rb_eArgError, "invalid date");
+ if (!c_valid_time_p(h, min, s, &rh, &rmin, &rs))
+ rb_raise(rb_eArgError, "invalid date");
+ canon24oc();
+
+ ret = d_complex_new_internal(klass,
+ nth, 0,
+ 0, INT2FIX(0),
+ rof, sg,
+ ry, rm, rd,
+ rh, rmin, rs,
+ HAVE_CIVIL | HAVE_TIME);
+ }
+ else {
+ VALUE nth;
+ int ry, rm, rd, rh, rmin, rs, rjd, rjd2, ns;
+
+ if (!valid_civil_p(y, m, d, sg,
+ &nth, &ry,
+ &rm, &rd, &rjd,
+ &ns))
+ rb_raise(rb_eArgError, "invalid date");
+ if (!c_valid_time_p(h, min, s, &rh, &rmin, &rs))
+ rb_raise(rb_eArgError, "invalid date");
+ canon24oc();
+
+ rjd2 = jd_local_to_utc(rjd,
+ time_to_df(rh, rmin, rs),
+ rof);
+
+ ret = d_complex_new_internal(klass,
+ nth, rjd2,
+ 0, INT2FIX(0),
+ rof, sg,
+ ry, rm, rd,
+ rh, rmin, rs,
+ HAVE_JD | HAVE_CIVIL | HAVE_TIME);
+ }
+ add_frac();
+ return ret;
+}
+
+/*
+ * call-seq:
+ * DateTime.commercial([cwyear=-4712[, cweek=1[, cwday=1[, hour=0[, minute=0[, second=0[, offset=0[, start=Date::ITALY]]]]]]]]) -> datetime
+ *
+ * Creates a date-time object denoting the given week date.
+ *
+ * DateTime.commercial(2001) #=> #<DateTime: 2001-01-01T00:00:00+00:00 ...>
+ * DateTime.commercial(2002) #=> #<DateTime: 2001-12-31T00:00:00+00:00 ...>
+ * DateTime.commercial(2001,5,6,4,5,6,'+7')
+ * #=> #<DateTime: 2001-02-03T04:05:06+07:00 ...>
+ */
+static VALUE
+datetime_s_commercial(int argc, VALUE *argv, VALUE klass)
+{
+ VALUE vy, vw, vd, vh, vmin, vs, vof, vsg, y, fr, fr2, ret;
+ int w, d, h, min, s, rof;
+ double sg;
+
+ rb_scan_args(argc, argv, "08", &vy, &vw, &vd, &vh, &vmin, &vs, &vof, &vsg);
+
+ y = INT2FIX(-4712);
+ w = 1;
+ d = 1;
+
+ h = min = s = 0;
+ fr2 = INT2FIX(0);
+ rof = 0;
+ sg = DEFAULT_SG;
+
+ switch (argc) {
+ case 8:
+ val2sg(vsg, sg);
+ case 7:
+ val2off(vof, rof);
+ case 6:
+ num2int_with_frac(s, positive_inf);
+ case 5:
+ num2int_with_frac(min, 5);
+ case 4:
+ num2int_with_frac(h, 4);
+ case 3:
+ num2int_with_frac(d, 3);
+ case 2:
+ w = NUM2INT(vw);
+ case 1:
+ y = vy;
+ }
+
+ {
+ VALUE nth;
+ int ry, rw, rd, rh, rmin, rs, rjd, rjd2, ns;
+
+ if (!valid_commercial_p(y, w, d, sg,
+ &nth, &ry,
+ &rw, &rd, &rjd,
+ &ns))
+ rb_raise(rb_eArgError, "invalid date");
+ if (!c_valid_time_p(h, min, s, &rh, &rmin, &rs))
+ rb_raise(rb_eArgError, "invalid date");
+ canon24oc();
+
+ rjd2 = jd_local_to_utc(rjd,
+ time_to_df(rh, rmin, rs),
+ rof);
+
+ ret = d_complex_new_internal(klass,
+ nth, rjd2,
+ 0, INT2FIX(0),
+ rof, sg,
+ 0, 0, 0,
+ rh, rmin, rs,
+ HAVE_JD | HAVE_TIME);
+ }
+ add_frac();
+ return ret;
+}
+
+#ifndef NDEBUG
+static VALUE
+datetime_s_weeknum(int argc, VALUE *argv, VALUE klass)
+{
+ VALUE vy, vw, vd, vf, vh, vmin, vs, vof, vsg, y, fr, fr2, ret;
+ int w, d, f, h, min, s, rof;
+ double sg;
+
+ rb_scan_args(argc, argv, "09", &vy, &vw, &vd, &vf,
+ &vh, &vmin, &vs, &vof, &vsg);
+
+ y = INT2FIX(-4712);
+ w = 0;
+ d = 1;
+ f = 0;
+
+ h = min = s = 0;
+ fr2 = INT2FIX(0);
+ rof = 0;
+ sg = DEFAULT_SG;
+
+ switch (argc) {
+ case 9:
+ val2sg(vsg, sg);
+ case 8:
+ val2off(vof, rof);
+ case 7:
+ num2int_with_frac(s, positive_inf);
+ case 6:
+ num2int_with_frac(min, 6);
+ case 5:
+ num2int_with_frac(h, 5);
+ case 4:
+ f = NUM2INT(vf);
+ case 3:
+ num2int_with_frac(d, 4);
+ case 2:
+ w = NUM2INT(vw);
+ case 1:
+ y = vy;
+ }
+
+ {
+ VALUE nth;
+ int ry, rw, rd, rh, rmin, rs, rjd, rjd2, ns;
+
+ if (!valid_weeknum_p(y, w, d, f, sg,
+ &nth, &ry,
+ &rw, &rd, &rjd,
+ &ns))
+ rb_raise(rb_eArgError, "invalid date");
+ if (!c_valid_time_p(h, min, s, &rh, &rmin, &rs))
+ rb_raise(rb_eArgError, "invalid date");
+ canon24oc();
+
+ rjd2 = jd_local_to_utc(rjd,
+ time_to_df(rh, rmin, rs),
+ rof);
+ ret = d_complex_new_internal(klass,
+ nth, rjd2,
+ 0, INT2FIX(0),
+ rof, sg,
+ 0, 0, 0,
+ rh, rmin, rs,
+ HAVE_JD | HAVE_TIME);
+ }
+ add_frac();
+ return ret;
+}
+
+static VALUE
+datetime_s_nth_kday(int argc, VALUE *argv, VALUE klass)
+{
+ VALUE vy, vm, vn, vk, vh, vmin, vs, vof, vsg, y, fr, fr2, ret;
+ int m, n, k, h, min, s, rof;
+ double sg;
+
+ rb_scan_args(argc, argv, "09", &vy, &vm, &vn, &vk,
+ &vh, &vmin, &vs, &vof, &vsg);
+
+ y = INT2FIX(-4712);
+ m = 1;
+ n = 1;
+ k = 1;
+
+ h = min = s = 0;
+ fr2 = INT2FIX(0);
+ rof = 0;
+ sg = DEFAULT_SG;
+
+ switch (argc) {
+ case 9:
+ val2sg(vsg, sg);
+ case 8:
+ val2off(vof, rof);
+ case 7:
+ num2int_with_frac(s, positive_inf);
+ case 6:
+ num2int_with_frac(min, 6);
+ case 5:
+ num2int_with_frac(h, 5);
+ case 4:
+ num2int_with_frac(k, 4);
+ case 3:
+ n = NUM2INT(vn);
+ case 2:
+ m = NUM2INT(vm);
+ case 1:
+ y = vy;
+ }
+
+ {
+ VALUE nth;
+ int ry, rm, rn, rk, rh, rmin, rs, rjd, rjd2, ns;
+
+ if (!valid_nth_kday_p(y, m, n, k, sg,
+ &nth, &ry,
+ &rm, &rn, &rk, &rjd,
+ &ns))
+ rb_raise(rb_eArgError, "invalid date");
+ if (!c_valid_time_p(h, min, s, &rh, &rmin, &rs))
+ rb_raise(rb_eArgError, "invalid date");
+ canon24oc();
+
+ rjd2 = jd_local_to_utc(rjd,
+ time_to_df(rh, rmin, rs),
+ rof);
+ ret = d_complex_new_internal(klass,
+ nth, rjd2,
+ 0, INT2FIX(0),
+ rof, sg,
+ 0, 0, 0,
+ rh, rmin, rs,
+ HAVE_JD | HAVE_TIME);
+ }
+ add_frac();
+ return ret;
+}
+#endif
+
+/*
+ * call-seq:
+ * DateTime.now([start=Date::ITALY]) -> datetime
+ *
+ * Creates a date-time object denoting the present time.
+ *
+ * DateTime.now #=> #<DateTime: 2011-06-11T21:20:44+09:00 ...>
+ */
+static VALUE
+datetime_s_now(int argc, VALUE *argv, VALUE klass)
+{
+ VALUE vsg, nth, ret;
+ double sg;
+#ifdef HAVE_CLOCK_GETTIME
+ struct timespec ts;
+#else
+ struct timeval tv;
+#endif
+ time_t sec;
+ struct tm tm;
+ long sf, of;
+ int y, ry, m, d, h, min, s;
+
+ rb_scan_args(argc, argv, "01", &vsg);
+
+ if (argc < 1)
+ sg = DEFAULT_SG;
+ else
+ sg = NUM2DBL(vsg);
+
+#ifdef HAVE_CLOCK_GETTIME
+ if (clock_gettime(CLOCK_REALTIME, &ts) == -1)
+ rb_sys_fail("clock_gettime");
+ sec = ts.tv_sec;
+#else
+ if (gettimeofday(&tv, NULL) == -1)
+ rb_sys_fail("gettimeofday");
+ sec = tv.tv_sec;
+#endif
+ tzset();
+ if (!localtime_r(&sec, &tm))
+ rb_sys_fail("localtime");
+
+ y = tm.tm_year + 1900;
+ m = tm.tm_mon + 1;
+ d = tm.tm_mday;
+ h = tm.tm_hour;
+ min = tm.tm_min;
+ s = tm.tm_sec;
+ if (s == 60)
+ s = 59;
+#ifdef HAVE_STRUCT_TM_TM_GMTOFF
+ of = tm.tm_gmtoff;
+#elif defined(HAVE_VAR_TIMEZONE)
+#ifdef HAVE_VAR_ALTZONE
+ of = (long)-((tm.tm_isdst > 0) ? altzone : timezone);
+#else
+ of = (long)-timezone;
+ if (tm.tm_isdst) {
+ time_t sec2;
+
+ tm.tm_isdst = 0;
+ sec2 = mktime(&tm);
+ of += (long)difftime(sec2, sec);
+ }
+#endif
+#elif defined(HAVE_TIMEGM)
+ {
+ time_t sec2;
+
+ sec2 = timegm(&tm);
+ of = (long)difftime(sec2, sec);
+ }
+#else
+ {
+ struct tm tm2;
+ time_t sec2;
+
+ if (!gmtime_r(&sec, &tm2))
+ rb_sys_fail("gmtime");
+ tm2.tm_isdst = tm.tm_isdst;
+ sec2 = mktime(&tm2);
+ of = (long)difftime(sec, sec2);
+ }
+#endif
+#ifdef HAVE_CLOCK_GETTIME
+ sf = ts.tv_nsec;
+#else
+ sf = tv.tv_usec * 1000;
+#endif
+
+ if (of < -DAY_IN_SECONDS || of > DAY_IN_SECONDS) {
+ of = 0;
+ rb_warning("invalid offset is ignored");
+ }
+
+ decode_year(INT2FIX(y), -1, &nth, &ry);
+
+ ret = d_complex_new_internal(klass,
+ nth, 0,
+ 0, LONG2NUM(sf),
+ (int)of, GREGORIAN,
+ ry, m, d,
+ h, min, s,
+ HAVE_CIVIL | HAVE_TIME);
+ {
+ get_d1(ret);
+ set_sg(dat, sg);
+ }
+ return ret;
+}
+
+static VALUE
+dt_new_by_frags(VALUE klass, VALUE hash, VALUE sg)
+{
+ VALUE jd, sf, t;
+ int df, of;
+
+ if (!c_valid_start_p(NUM2DBL(sg))) {
+ sg = INT2FIX(DEFAULT_SG);
+ rb_warning("invalid start is ignored");
+ }
+
+ if (NIL_P(hash))
+ rb_raise(rb_eArgError, "invalid date");
+
+ if (NIL_P(ref_hash("jd")) &&
+ NIL_P(ref_hash("yday")) &&
+ !NIL_P(ref_hash("year")) &&
+ !NIL_P(ref_hash("mon")) &&
+ !NIL_P(ref_hash("mday"))) {
+ jd = rt__valid_civil_p(ref_hash("year"),
+ ref_hash("mon"),
+ ref_hash("mday"), sg);
+
+ if (NIL_P(ref_hash("hour")))
+ set_hash("hour", INT2FIX(0));
+ if (NIL_P(ref_hash("min")))
+ set_hash("min", INT2FIX(0));
+ if (NIL_P(ref_hash("sec")))
+ set_hash("sec", INT2FIX(0));
+ else if (f_eqeq_p(ref_hash("sec"), INT2FIX(60)))
+ set_hash("sec", INT2FIX(59));
+ }
+ else {
+ hash = rt_rewrite_frags(hash);
+ hash = rt_complete_frags(klass, hash);
+ jd = rt__valid_date_frags_p(hash, sg);
+ }
+
+ if (NIL_P(jd))
+ rb_raise(rb_eArgError, "invalid date");
+
+ {
+ int rh, rmin, rs;
+
+ if (!c_valid_time_p(NUM2INT(ref_hash("hour")),
+ NUM2INT(ref_hash("min")),
+ NUM2INT(ref_hash("sec")),
+ &rh, &rmin, &rs))
+ rb_raise(rb_eArgError, "invalid date");
+
+ df = time_to_df(rh, rmin, rs);
+ }
+
+ t = ref_hash("sec_fraction");
+ if (NIL_P(t))
+ sf = INT2FIX(0);
+ else
+ sf = sec_to_ns(t);
+
+ t = ref_hash("offset");
+ if (NIL_P(t))
+ of = 0;
+ else {
+ of = NUM2INT(t);
+ if (of < -DAY_IN_SECONDS || of > DAY_IN_SECONDS) {
+ of = 0;
+ rb_warning("invalid offset is ignored");
+ }
+ }
+ {
+ VALUE nth;
+ int rjd, rjd2;
+
+ decode_jd(jd, &nth, &rjd);
+ rjd2 = jd_local_to_utc(rjd, df, of);
+ df = df_local_to_utc(df, of);
+
+ return d_complex_new_internal(klass,
+ nth, rjd2,
+ df, sf,
+ of, NUM2DBL(sg),
+ 0, 0, 0,
+ 0, 0, 0,
+ HAVE_JD | HAVE_DF);
+ }
+}
+
+/*
+ * call-seq:
+ * DateTime._strptime(string[, format='%FT%T%z']) -> hash
+ *
+ * Parses the given representation of date and time with the given
+ * template, and returns a hash of parsed elements. _strptime does
+ * not support specification of flags and width unlike strftime.
+ *
+ * See also strptime(3) and strftime.
+ */
+static VALUE
+datetime_s__strptime(int argc, VALUE *argv, VALUE klass)
+{
+ return date_s__strptime_internal(argc, argv, klass, "%FT%T%z");
+}
+
+/*
+ * call-seq:
+ * DateTime.strptime([string='-4712-01-01T00:00:00+00:00'[, format='%FT%T%z'[ ,start=ITALY]]]) -> datetime
+ *
+ * Parses the given representation of date and time with the given
+ * template, and creates a date object. strptime does not support
+ * specification of flags and width unlike strftime.
+ *
+ * DateTime.strptime('2001-02-03T04:05:06+07:00', '%Y-%m-%dT%H:%M:%S%z')
+ * #=> #<DateTime: 2001-02-03T04:05:06+07:00 ...>
+ * DateTime.strptime('03-02-2001 04:05:06 PM', '%d-%m-%Y %I:%M:%S %p')
+ * #=> #<DateTime: 2001-02-03T16:05:06+00:00 ...>
+ * DateTime.strptime('2001-W05-6T04:05:06+07:00', '%G-W%V-%uT%H:%M:%S%z')
+ * #=> #<DateTime: 2001-02-03T04:05:06+07:00 ...>
+ * DateTime.strptime('2001 04 6 04 05 06 +7', '%Y %U %w %H %M %S %z')
+ * #=> #<DateTime: 2001-02-03T04:05:06+07:00 ...>
+ * DateTime.strptime('2001 05 6 04 05 06 +7', '%Y %W %u %H %M %S %z')
+ * #=> #<DateTime: 2001-02-03T04:05:06+07:00 ...>
+ * DateTime.strptime('-1', '%s')
+ * #=> #<DateTime: 1969-12-31T23:59:59+00:00 ...>
+ * DateTime.strptime('-1000', '%Q')
+ * #=> #<DateTime: 1969-12-31T23:59:59+00:00 ...>
+ * DateTime.strptime('sat3feb014pm+7', '%a%d%b%y%H%p%z')
+ * #=> #<DateTime: 2001-02-03T16:00:00+07:00 ...>
+ *
+ * See also strptime(3) and strftime.
+ */
+static VALUE
+datetime_s_strptime(int argc, VALUE *argv, VALUE klass)
+{
+ VALUE str, fmt, sg;
+
+ rb_scan_args(argc, argv, "03", &str, &fmt, &sg);
+
+ switch (argc) {
+ case 0:
+ str = rb_str_new2("-4712-01-01T00:00:00+00:00");
+ case 1:
+ fmt = rb_str_new2("%FT%T%z");
+ case 2:
+ sg = INT2FIX(DEFAULT_SG);
+ }
+
+ {
+ VALUE argv2[2], hash;
+
+ argv2[0] = str;
+ argv2[1] = fmt;
+ hash = date_s__strptime(2, argv2, klass);
+ return dt_new_by_frags(klass, hash, sg);
+ }
+}
+
+/*
+ * call-seq:
+ * DateTime.parse(string='-4712-01-01T00:00:00+00:00'[, comp=true[, start=ITALY]]) -> datetime
+ *
+ * Parses the given representation of date and time, and creates a
+ * date object. This method does not function as a validator.
+ *
+ * If the optional second argument is true and the detected year is in
+ * the range "00" to "99", makes it full.
+ *
+ * DateTime.parse('2001-02-03T04:05:06+07:00')
+ * #=> #<DateTime: 2001-02-03T04:05:06+07:00 ...>
+ * DateTime.parse('20010203T040506+0700')
+ * #=> #<DateTime: 2001-02-03T04:05:06+07:00 ...>
+ * DateTime.parse('3rd Feb 2001 04:05:06 PM')
+ * #=> #<DateTime: 2001-02-03T16:05:06+00:00 ...>
+ */
+static VALUE
+datetime_s_parse(int argc, VALUE *argv, VALUE klass)
+{
+ VALUE str, comp, sg;
+
+ rb_scan_args(argc, argv, "03", &str, &comp, &sg);
+
+ switch (argc) {
+ case 0:
+ str = rb_str_new2("-4712-01-01T00:00:00+00:00");
+ case 1:
+ comp = Qtrue;
+ case 2:
+ sg = INT2FIX(DEFAULT_SG);
+ }
+
+ {
+ VALUE argv2[2], hash;
+
+ argv2[0] = str;
+ argv2[1] = comp;
+ hash = date_s__parse(2, argv2, klass);
+ return dt_new_by_frags(klass, hash, sg);
+ }
+}
+
+/*
+ * call-seq:
+ * DateTime.iso8601(string='-4712-01-01T00:00:00+00:00'[, start=ITALY]) -> datetime
+ *
+ * Creates a new Date object by parsing from a string according to
+ * some typical ISO 8601 formats.
+ *
+ * DateTime.iso8601('2001-02-03T04:05:06+07:00')
+ * #=> #<DateTime: 2001-02-03T04:05:06+07:00 ...>
+ * DateTime.iso8601('20010203T040506+0700')
+ * #=> #<DateTime: 2001-02-03T04:05:06+07:00 ...>
+ * DateTime.iso8601('2001-W05-6T04:05:06+07:00')
+ * #=> #<DateTime: 2001-02-03T04:05:06+07:00 ...>
+ */
+static VALUE
+datetime_s_iso8601(int argc, VALUE *argv, VALUE klass)
+{
+ VALUE str, sg;
+
+ rb_scan_args(argc, argv, "02", &str, &sg);
+
+ switch (argc) {
+ case 0:
+ str = rb_str_new2("-4712-01-01T00:00:00+00:00");
+ case 1:
+ sg = INT2FIX(DEFAULT_SG);
+ }
+
+ {
+ VALUE hash = date_s__iso8601(klass, str);
+ return dt_new_by_frags(klass, hash, sg);
+ }
+}
+
+/*
+ * call-seq:
+ * DateTime.rfc3339(string='-4712-01-01T00:00:00+00:00'[, start=ITALY]) -> datetime
+ *
+ * Creates a new Date object by parsing from a string according to
+ * some typical RFC 3339 formats.
+ *
+ * DateTime.rfc3339('2001-02-03T04:05:06+07:00')
+ * #=> #<DateTime: 2001-02-03T04:05:06+07:00 ...>
+ */
+static VALUE
+datetime_s_rfc3339(int argc, VALUE *argv, VALUE klass)
+{
+ VALUE str, sg;
+
+ rb_scan_args(argc, argv, "02", &str, &sg);
+
+ switch (argc) {
+ case 0:
+ str = rb_str_new2("-4712-01-01T00:00:00+00:00");
+ case 1:
+ sg = INT2FIX(DEFAULT_SG);
+ }
+
+ {
+ VALUE hash = date_s__rfc3339(klass, str);
+ return dt_new_by_frags(klass, hash, sg);
+ }
+}
+
+/*
+ * call-seq:
+ * DateTime.xmlschema(string='-4712-01-01T00:00:00+00:00'[, start=ITALY]) -> datetime
+ *
+ * Creates a new Date object by parsing from a string according to
+ * some typical XML Schema formats.
+ *
+ * DateTime.xmlschema('2001-02-03T04:05:06+07:00')
+ * #=> #<DateTime: 2001-02-03T04:05:06+07:00 ...>
+ */
+static VALUE
+datetime_s_xmlschema(int argc, VALUE *argv, VALUE klass)
+{
+ VALUE str, sg;
+
+ rb_scan_args(argc, argv, "02", &str, &sg);
+
+ switch (argc) {
+ case 0:
+ str = rb_str_new2("-4712-01-01T00:00:00+00:00");
+ case 1:
+ sg = INT2FIX(DEFAULT_SG);
+ }
+
+ {
+ VALUE hash = date_s__xmlschema(klass, str);
+ return dt_new_by_frags(klass, hash, sg);
+ }
+}
+
+/*
+ * call-seq:
+ * DateTime.rfc2822(string='Mon, 1 Jan -4712 00:00:00 +0000'[, start=ITALY]) -> datetime
+ * DateTime.rfc822(string='Mon, 1 Jan -4712 00:00:00 +0000'[, start=ITALY]) -> datetime
+ *
+ * Creates a new Date object by parsing from a string according to
+ * some typical RFC 2822 formats.
+ *
+ * DateTime.rfc2822('Sat, 3 Feb 2001 04:05:06 +0700')
+ * #=> #<DateTime: 2001-02-03T04:05:06+07:00 ...>
+ */
+static VALUE
+datetime_s_rfc2822(int argc, VALUE *argv, VALUE klass)
+{
+ VALUE str, sg;
+
+ rb_scan_args(argc, argv, "02", &str, &sg);
+
+ switch (argc) {
+ case 0:
+ str = rb_str_new2("Mon, 1 Jan -4712 00:00:00 +0000");
+ case 1:
+ sg = INT2FIX(DEFAULT_SG);
+ }
+
+ {
+ VALUE hash = date_s__rfc2822(klass, str);
+ return dt_new_by_frags(klass, hash, sg);
+ }
+}
+
+/*
+ * call-seq:
+ * DateTime.httpdate(string='Mon, 01 Jan -4712 00:00:00 GMT'[, start=ITALY]) -> datetime
+ *
+ * Creates a new Date object by parsing from a string according to
+ * some RFC 2616 format.
+ *
+ * DateTime.httpdate('Sat, 03 Feb 2001 04:05:06 GMT')
+ * #=> #<DateTime: 2001-02-03T04:05:06+00:00 ...>
+ */
+static VALUE
+datetime_s_httpdate(int argc, VALUE *argv, VALUE klass)
+{
+ VALUE str, sg;
+
+ rb_scan_args(argc, argv, "02", &str, &sg);
+
+ switch (argc) {
+ case 0:
+ str = rb_str_new2("Mon, 01 Jan -4712 00:00:00 GMT");
+ case 1:
+ sg = INT2FIX(DEFAULT_SG);
+ }
+
+ {
+ VALUE hash = date_s__httpdate(klass, str);
+ return dt_new_by_frags(klass, hash, sg);
+ }
+}
+
+/*
+ * call-seq:
+ * DateTime.jisx0301(string='-4712-01-01T00:00:00+00:00'[, start=ITALY]) -> datetime
+ *
+ * Creates a new Date object by parsing from a string according to
+ * some typical JIS X 0301 formats.
+ *
+ * DateTime.jisx0301('H13.02.03T04:05:06+07:00')
+ * #=> #<DateTime: 2001-02-03T04:05:06+07:00 ...>
+ */
+static VALUE
+datetime_s_jisx0301(int argc, VALUE *argv, VALUE klass)
+{
+ VALUE str, sg;
+
+ rb_scan_args(argc, argv, "02", &str, &sg);
+
+ switch (argc) {
+ case 0:
+ str = rb_str_new2("-4712-01-01T00:00:00+00:00");
+ case 1:
+ sg = INT2FIX(DEFAULT_SG);
+ }
+
+ {
+ VALUE hash = date_s__jisx0301(klass, str);
+ return dt_new_by_frags(klass, hash, sg);
+ }
+}
+
+/*
+ * call-seq:
+ * dt.to_s -> string
+ *
+ * Returns a string in an ISO 8601 format (This method doesn't use the
+ * expanded representations).
+ *
+ * DateTime.new(2001,2,3,4,5,6,'-7').to_s
+ * #=> "2001-02-03T04:05:06-07:00"
+ */
+static VALUE
+dt_lite_to_s(VALUE self)
+{
+ return strftimev("%Y-%m-%dT%H:%M:%S%:z", self, set_tmx);
+}
+
+/*
+ * call-seq:
+ * dt.strftime([format='%FT%T%:z']) -> string
+ *
+ * Formats date according to the directives in the given format
+ * string.
+ * The directives begins with a percent (%) character.
+ * Any text not listed as a directive will be passed through to the
+ * output string.
+ *
+ * The directive consists of a percent (%) character,
+ * zero or more flags, optional minimum field width,
+ * optional modifier and a conversion specifier
+ * as follows.
+ *
+ * %<flags><width><modifier><conversion>
+ *
+ * Flags:
+ * - don't pad a numerical output.
+ * _ use spaces for padding.
+ * 0 use zeros for padding.
+ * ^ upcase the result string.
+ * # change case.
+ * : use colons for %z.
+ *
+ * The minimum field width specifies the minimum width.
+ *
+ * The modifier is "E" and "O".
+ * They are ignored.
+ *
+ * Format directives:
+ *
+ * Date (Year, Month, Day):
+ * %Y - Year with century (can be negative, 4 digits at least)
+ * -0001, 0000, 1995, 2009, 14292, etc.
+ * %C - year / 100 (round down. 20 in 2009)
+ * %y - year % 100 (00..99)
+ *
+ * %m - Month of the year, zero-padded (01..12)
+ * %_m blank-padded ( 1..12)
+ * %-m no-padded (1..12)
+ * %B - The full month name (``January'')
+ * %^B uppercased (``JANUARY'')
+ * %b - The abbreviated month name (``Jan'')
+ * %^b uppercased (``JAN'')
+ * %h - Equivalent to %b
+ *
+ * %d - Day of the month, zero-padded (01..31)
+ * %-d no-padded (1..31)
+ * %e - Day of the month, blank-padded ( 1..31)
+ *
+ * %j - Day of the year (001..366)
+ *
+ * Time (Hour, Minute, Second, Subsecond):
+ * %H - Hour of the day, 24-hour clock, zero-padded (00..23)
+ * %k - Hour of the day, 24-hour clock, blank-padded ( 0..23)
+ * %I - Hour of the day, 12-hour clock, zero-padded (01..12)
+ * %l - Hour of the day, 12-hour clock, blank-padded ( 1..12)
+ * %P - Meridian indicator, lowercase (``am'' or ``pm'')
+ * %p - Meridian indicator, uppercase (``AM'' or ``PM'')
+ *
+ * %M - Minute of the hour (00..59)
+ *
+ * %S - Second of the minute (00..59)
+ *
+ * %L - Millisecond of the second (000..999)
+ * %N - Fractional seconds digits, default is 9 digits (nanosecond)
+ * %3N millisecond (3 digits) %15N femtosecond (15 digits)
+ * %6N microsecond (6 digits) %18N attosecond (18 digits)
+ * %9N nanosecond (9 digits) %21N zeptosecond (21 digits)
+ * %12N picosecond (12 digits) %24N yoctosecond (24 digits)
+ *
+ * Time zone:
+ * %z - Time zone as hour and minute offset from UTC (e.g. +0900)
+ * %:z - hour and minute offset from UTC with a colon (e.g. +09:00)
+ * %::z - hour, minute and second offset from UTC (e.g. +09:00:00)
+ * %:::z - hour, minute and second offset from UTC
+ * (e.g. +09, +09:30, +09:30:30)
+ * %Z - Time zone abbreviation name or something similar information.
+ *
+ * Weekday:
+ * %A - The full weekday name (``Sunday'')
+ * %^A uppercased (``SUNDAY'')
+ * %a - The abbreviated name (``Sun'')
+ * %^a uppercased (``SUN'')
+ * %u - Day of the week (Monday is 1, 1..7)
+ * %w - Day of the week (Sunday is 0, 0..6)
+ *
+ * ISO 8601 week-based year and week number:
+ * The week 1 of YYYY starts with a Monday and includes YYYY-01-04.
+ * The days in the year before the first week are in the last week of
+ * the previous year.
+ * %G - The week-based year
+ * %g - The last 2 digits of the week-based year (00..99)
+ * %V - Week number of the week-based year (01..53)
+ *
+ * Week number:
+ * The week 1 of YYYY starts with a Sunday or Monday (according to %U
+ * or %W). The days in the year before the first week are in week 0.
+ * %U - Week number of the year. The week starts with Sunday. (00..53)
+ * %W - Week number of the year. The week starts with Monday. (00..53)
+ *
+ * Seconds since the Unix Epoch:
+ * %s - Number of seconds since 1970-01-01 00:00:00 UTC.
+ * %Q - Number of milliseconds since 1970-01-01 00:00:00 UTC.
+ *
+ * Literal string:
+ * %n - Newline character (\n)
+ * %t - Tab character (\t)
+ * %% - Literal ``%'' character
+ *
+ * Combination:
+ * %c - date and time (%a %b %e %T %Y)
+ * %D - Date (%m/%d/%y)
+ * %F - The ISO 8601 date format (%Y-%m-%d)
+ * %v - VMS date (%e-%b-%Y)
+ * %x - Same as %D
+ * %X - Same as %T
+ * %r - 12-hour time (%I:%M:%S %p)
+ * %R - 24-hour time (%H:%M)
+ * %T - 24-hour time (%H:%M:%S)
+ * %+ - date(1) (%a %b %e %H:%M:%S %Z %Y)
+ *
+ * This method is similar to strftime() function defined in ISO C and POSIX.
+ * Several directives (%a, %A, %b, %B, %c, %p, %r, %x, %X, %E*, %O* and %Z)
+ * are locale dependent in the function.
+ * However this method is locale independent.
+ * So, the result may differ even if a same format string is used in other
+ * systems such as C.
+ * It is good practice to avoid %x and %X because there are corresponding
+ * locale independent representations, %D and %T.
+ *
+ * Examples:
+ *
+ * d = DateTime.new(2007,11,19,8,37,48,"-06:00")
+ * #=> #<DateTime: 2007-11-19T08:37:48-0600 ...>
+ * d.strftime("Printed on %m/%d/%Y") #=> "Printed on 11/19/2007"
+ * d.strftime("at %I:%M%p") #=> "at 08:37AM"
+ *
+ * Various ISO 8601 formats:
+ * %Y%m%d => 20071119 Calendar date (basic)
+ * %F => 2007-11-19 Calendar date (extended)
+ * %Y-%m => 2007-11 Calendar date, reduced accuracy, specific month
+ * %Y => 2007 Calendar date, reduced accuracy, specific year
+ * %C => 20 Calendar date, reduced accuracy, specific century
+ * %Y%j => 2007323 Ordinal date (basic)
+ * %Y-%j => 2007-323 Ordinal date (extended)
+ * %GW%V%u => 2007W471 Week date (basic)
+ * %G-W%V-%u => 2007-W47-1 Week date (extended)
+ * %GW%V => 2007W47 Week date, reduced accuracy, specific week (basic)
+ * %G-W%V => 2007-W47 Week date, reduced accuracy, specific week (extended)
+ * %H%M%S => 083748 Local time (basic)
+ * %T => 08:37:48 Local time (extended)
+ * %H%M => 0837 Local time, reduced accuracy, specific minute (basic)
+ * %H:%M => 08:37 Local time, reduced accuracy, specific minute (extended)
+ * %H => 08 Local time, reduced accuracy, specific hour
+ * %H%M%S,%L => 083748,000 Local time with decimal fraction, comma as decimal sign (basic)
+ * %T,%L => 08:37:48,000 Local time with decimal fraction, comma as decimal sign (extended)
+ * %H%M%S.%L => 083748.000 Local time with decimal fraction, full stop as decimal sign (basic)
+ * %T.%L => 08:37:48.000 Local time with decimal fraction, full stop as decimal sign (extended)
+ * %H%M%S%z => 083748-0600 Local time and the difference from UTC (basic)
+ * %T%:z => 08:37:48-06:00 Local time and the difference from UTC (extended)
+ * %Y%m%dT%H%M%S%z => 20071119T083748-0600 Date and time of day for calendar date (basic)
+ * %FT%T%:z => 2007-11-19T08:37:48-06:00 Date and time of day for calendar date (extended)
+ * %Y%jT%H%M%S%z => 2007323T083748-0600 Date and time of day for ordinal date (basic)
+ * %Y-%jT%T%:z => 2007-323T08:37:48-06:00 Date and time of day for ordinal date (extended)
+ * %GW%V%uT%H%M%S%z => 2007W471T083748-0600 Date and time of day for week date (basic)
+ * %G-W%V-%uT%T%:z => 2007-W47-1T08:37:48-06:00 Date and time of day for week date (extended)
+ * %Y%m%dT%H%M => 20071119T0837 Calendar date and local time (basic)
+ * %FT%R => 2007-11-19T08:37 Calendar date and local time (extended)
+ * %Y%jT%H%MZ => 2007323T0837Z Ordinal date and UTC of day (basic)
+ * %Y-%jT%RZ => 2007-323T08:37Z Ordinal date and UTC of day (extended)
+ * %GW%V%uT%H%M%z => 2007W471T0837-0600 Week date and local time and difference from UTC (basic)
+ * %G-W%V-%uT%R%:z => 2007-W47-1T08:37-06:00 Week date and local time and difference from UTC (extended)
+ *
+ * See also strftime(3) and strptime.
+ */
+static VALUE
+dt_lite_strftime(int argc, VALUE *argv, VALUE self)
+{
+ return date_strftime_internal(argc, argv, self,
+ "%Y-%m-%dT%H:%M:%S%:z", set_tmx);
+}
+
+static VALUE
+iso8601_timediv(VALUE self, VALUE n)
+{
+ VALUE fmt;
+
+ n = to_integer(n);
+ fmt = rb_usascii_str_new2("T%H:%M:%S");
+ if (f_gt_p(n, INT2FIX(0))) {
+ VALUE argv[3];
+
+ get_d1(self);
+
+ argv[0] = rb_usascii_str_new2(".%0*d");
+ argv[1] = n;
+ argv[2] = f_round(f_quo(m_sf_in_sec(dat),
+ f_quo(INT2FIX(1),
+ f_expt(INT2FIX(10), n))));
+ rb_str_append(fmt, rb_f_sprintf(3, argv));
+ }
+ rb_str_append(fmt, rb_usascii_str_new2("%:z"));
+ return strftimev(RSTRING_PTR(fmt), self, set_tmx);
+}
+
+/*
+ * call-seq:
+ * dt.iso8601([n=0]) -> string
+ * dt.xmlschema([n=0]) -> string
+ *
+ * This method is equivalent to strftime('%FT%T'). The optional
+ * argument n is length of fractional seconds.
+ *
+ * DateTime.parse('2001-02-03T04:05:06.123456789+07:00').iso8601(9)
+ * #=> "2001-02-03T04:05:06.123456789+07:00"
+ */
+static VALUE
+dt_lite_iso8601(int argc, VALUE *argv, VALUE self)
+{
+ VALUE n;
+
+ rb_scan_args(argc, argv, "01", &n);
+
+ if (argc < 1)
+ n = INT2FIX(0);
+
+ return f_add(strftimev("%Y-%m-%d", self, set_tmx),
+ iso8601_timediv(self, n));
+}
+
+/*
+ * call-seq:
+ * dt.rfc3339([n=0]) -> string
+ *
+ * This method is equivalent to strftime('%FT%T'). The optional
+ * argument n is length of fractional seconds.
+ *
+ * DateTime.parse('2001-02-03T04:05:06.123456789+07:00').rfc3339(9)
+ * #=> "2001-02-03T04:05:06.123456789+07:00"
+ */
+static VALUE
+dt_lite_rfc3339(int argc, VALUE *argv, VALUE self)
+{
+ return dt_lite_iso8601(argc, argv, self);
+}
+
+/*
+ * call-seq:
+ * dt.jisx0301([n=0]) -> string
+ *
+ * Returns a string in a JIS X 0301 format. The optional argument n
+ * is length of fractional seconds.
+ *
+ * DateTime.parse('2001-02-03T04:05:06.123456789+07:00').jisx0301(9)
+ * #=> "H13.02.03T04:05:06.123456789+07:00"
+ */
+static VALUE
+dt_lite_jisx0301(int argc, VALUE *argv, VALUE self)
+{
+ VALUE n, s;
+
+ rb_scan_args(argc, argv, "01", &n);
+
+ if (argc < 1)
+ n = INT2FIX(0);
+
+ {
+ get_d1(self);
+ s = jisx0301_date(m_real_local_jd(dat),
+ m_real_year(dat));
+ return rb_str_append(strftimev(RSTRING_PTR(s), self, set_tmx),
+ iso8601_timediv(self, n));
+ }
+}
+
+/* conversions */
+
+#define f_getlocal(x) rb_funcall(x, rb_intern("getlocal"), 0)
+#define f_subsec(x) rb_funcall(x, rb_intern("subsec"), 0)
+#define f_utc_offset(x) rb_funcall(x, rb_intern("utc_offset"), 0)
+#define f_local3(x,y,m,d) rb_funcall(x, rb_intern("local"), 3, y, m, d)
+#define f_utc6(x,y,m,d,h,min,s) rb_funcall(x, rb_intern("utc"), 6,\
+ y, m, d, h, min, s)
+
+/*
+ * call-seq:
+ * t.to_time -> time
+ *
+ * Returns a copy of self as local mode.
+ */
+static VALUE
+time_to_time(VALUE self)
+{
+ return f_getlocal(self);
+}
+
+/*
+ * call-seq:
+ * t.to_date -> date
+ *
+ * Returns a Date object which denotes self.
+ */
+static VALUE
+time_to_date(VALUE self)
+{
+ VALUE y, nth, ret;
+ int ry, m, d;
+
+ y = f_year(self);
+ m = FIX2INT(f_mon(self));
+ d = FIX2INT(f_mday(self));
+
+ decode_year(y, -1, &nth, &ry);
+
+ ret = d_simple_new_internal(cDate,
+ nth, 0,
+ GREGORIAN,
+ ry, m, d,
+ HAVE_CIVIL);
+ {
+ get_d1(ret);
+ set_sg(dat, DEFAULT_SG);
+ }
+ return ret;
+}
+
+/*
+ * call-seq:
+ * t.to_datetime -> datetime
+ *
+ * Returns a DateTime object which denotes self.
+ */
+static VALUE
+time_to_datetime(VALUE self)
+{
+ VALUE y, sf, nth, ret;
+ int ry, m, d, h, min, s, of;
+
+ y = f_year(self);
+ m = FIX2INT(f_mon(self));
+ d = FIX2INT(f_mday(self));
+
+ h = FIX2INT(f_hour(self));
+ min = FIX2INT(f_min(self));
+ s = FIX2INT(f_sec(self));
+ if (s == 60)
+ s = 59;
+
+ sf = sec_to_ns(f_subsec(self));
+ of = FIX2INT(f_utc_offset(self));
+
+ decode_year(y, -1, &nth, &ry);
+
+ ret = d_complex_new_internal(cDateTime,
+ nth, 0,
+ 0, sf,
+ of, DEFAULT_SG,
+ ry, m, d,
+ h, min, s,
+ HAVE_CIVIL | HAVE_TIME);
+ {
+ get_d1(ret);
+ set_sg(dat, DEFAULT_SG);
+ }
+ return ret;
+}
+
+/*
+ * call-seq:
+ * d.to_time -> time
+ *
+ * Returns a Time object which denotes self.
+ */
+static VALUE
+date_to_time(VALUE self)
+{
+ get_d1(self);
+
+ return f_local3(rb_cTime,
+ m_real_year(dat),
+ INT2FIX(m_mon(dat)),
+ INT2FIX(m_mday(dat)));
+}
+
+/*
+ * call-seq:
+ * d.to_date -> self
+ *
+ * Returns self;
+ */
+static VALUE
+date_to_date(VALUE self)
+{
+ return self;
+}
+
+/*
+ * call-seq:
+ * d.to_datetime -> datetime
+ *
+ * Returns a DateTime object which denotes self.
+ */
+static VALUE
+date_to_datetime(VALUE self)
+{
+ get_d1a(self);
+
+ if (simple_dat_p(adat)) {
+ VALUE new = d_lite_s_alloc_simple(cDateTime);
+ {
+ get_d1b(new);
+ bdat->s = adat->s;
+ return new;
+ }
+ }
+ else {
+ VALUE new = d_lite_s_alloc_complex(cDateTime);
+ {
+ get_d1b(new);
+ bdat->c = adat->c;
+ bdat->c.df = 0;
+ RB_OBJ_WRITE(new, &bdat->c.sf, INT2FIX(0));
+#ifndef USE_PACK
+ bdat->c.hour = 0;
+ bdat->c.min = 0;
+ bdat->c.sec = 0;
+#else
+ bdat->c.pc = PACK5(EX_MON(adat->c.pc), EX_MDAY(adat->c.pc),
+ 0, 0, 0);
+ bdat->c.flags |= HAVE_DF | HAVE_TIME;
+#endif
+ return new;
+ }
+ }
+}
+
+/*
+ * call-seq:
+ * dt.to_time -> time
+ *
+ * Returns a Time object which denotes self.
+ */
+static VALUE
+datetime_to_time(VALUE self)
+{
+ volatile VALUE dup = dup_obj_with_new_offset(self, 0);
+ {
+ VALUE t;
+
+ get_d1(dup);
+
+ t = f_utc6(rb_cTime,
+ m_real_year(dat),
+ INT2FIX(m_mon(dat)),
+ INT2FIX(m_mday(dat)),
+ INT2FIX(m_hour(dat)),
+ INT2FIX(m_min(dat)),
+ f_add(INT2FIX(m_sec(dat)),
+ m_sf_in_sec(dat)));
+ return f_getlocal(t);
+ }
+}
+
+/*
+ * call-seq:
+ * dt.to_date -> date
+ *
+ * Returns a Date object which denotes self.
+ */
+static VALUE
+datetime_to_date(VALUE self)
+{
+ get_d1a(self);
+
+ if (simple_dat_p(adat)) {
+ VALUE new = d_lite_s_alloc_simple(cDate);
+ {
+ get_d1b(new);
+ bdat->s = adat->s;
+ bdat->s.jd = m_local_jd(adat);
+ return new;
+ }
+ }
+ else {
+ VALUE new = d_lite_s_alloc_simple(cDate);
+ {
+ get_d1b(new);
+ copy_complex_to_simple(new, &bdat->s, &adat->c)
+ bdat->s.jd = m_local_jd(adat);
+ bdat->s.flags &= ~(HAVE_DF | HAVE_TIME | COMPLEX_DAT);
+ return new;
+ }
+ }
+}
+
+/*
+ * call-seq:
+ * dt.to_datetime -> self
+ *
+ * Returns self.
+ */
+static VALUE
+datetime_to_datetime(VALUE self)
+{
+ return self;
+}
+
+#ifndef NDEBUG
+/* tests */
+
+#define MIN_YEAR -4713
+#define MAX_YEAR 1000000
+#define MIN_JD -327
+#define MAX_JD 366963925
+
+static int
+test_civil(int from, int to, double sg)
+{
+ int j;
+
+ fprintf(stderr, "test_civil: %d...%d (%d) - %.0f\n",
+ from, to, to - from, sg);
+ for (j = from; j <= to; j++) {
+ int y, m, d, rj, ns;
+
+ c_jd_to_civil(j, sg, &y, &m, &d);
+ c_civil_to_jd(y, m, d, sg, &rj, &ns);
+ if (j != rj) {
+ fprintf(stderr, "%d != %d\n", j, rj);
+ return 0;
+ }
+ }
+ return 1;
+}
+
+static VALUE
+date_s_test_civil(VALUE klass)
+{
+ if (!test_civil(MIN_JD, MIN_JD + 366, GREGORIAN))
+ return Qfalse;
+ if (!test_civil(2305814, 2598007, GREGORIAN))
+ return Qfalse;
+ if (!test_civil(MAX_JD - 366, MAX_JD, GREGORIAN))
+ return Qfalse;
+
+ if (!test_civil(MIN_JD, MIN_JD + 366, ITALY))
+ return Qfalse;
+ if (!test_civil(2305814, 2598007, ITALY))
+ return Qfalse;
+ if (!test_civil(MAX_JD - 366, MAX_JD, ITALY))
+ return Qfalse;
+
+ return Qtrue;
+}
+
+static int
+test_ordinal(int from, int to, double sg)
+{
+ int j;
+
+ fprintf(stderr, "test_ordinal: %d...%d (%d) - %.0f\n",
+ from, to, to - from, sg);
+ for (j = from; j <= to; j++) {
+ int y, d, rj, ns;
+
+ c_jd_to_ordinal(j, sg, &y, &d);
+ c_ordinal_to_jd(y, d, sg, &rj, &ns);
+ if (j != rj) {
+ fprintf(stderr, "%d != %d\n", j, rj);
+ return 0;
+ }
+ }
+ return 1;
+}
+
+static VALUE
+date_s_test_ordinal(VALUE klass)
+{
+ if (!test_ordinal(MIN_JD, MIN_JD + 366, GREGORIAN))
+ return Qfalse;
+ if (!test_ordinal(2305814, 2598007, GREGORIAN))
+ return Qfalse;
+ if (!test_ordinal(MAX_JD - 366, MAX_JD, GREGORIAN))
+ return Qfalse;
+
+ if (!test_ordinal(MIN_JD, MIN_JD + 366, ITALY))
+ return Qfalse;
+ if (!test_ordinal(2305814, 2598007, ITALY))
+ return Qfalse;
+ if (!test_ordinal(MAX_JD - 366, MAX_JD, ITALY))
+ return Qfalse;
+
+ return Qtrue;
+}
+
+static int
+test_commercial(int from, int to, double sg)
+{
+ int j;
+
+ fprintf(stderr, "test_commercial: %d...%d (%d) - %.0f\n",
+ from, to, to - from, sg);
+ for (j = from; j <= to; j++) {
+ int y, w, d, rj, ns;
+
+ c_jd_to_commercial(j, sg, &y, &w, &d);
+ c_commercial_to_jd(y, w, d, sg, &rj, &ns);
+ if (j != rj) {
+ fprintf(stderr, "%d != %d\n", j, rj);
+ return 0;
+ }
+ }
+ return 1;
+}
+
+static VALUE
+date_s_test_commercial(VALUE klass)
+{
+ if (!test_commercial(MIN_JD, MIN_JD + 366, GREGORIAN))
+ return Qfalse;
+ if (!test_commercial(2305814, 2598007, GREGORIAN))
+ return Qfalse;
+ if (!test_commercial(MAX_JD - 366, MAX_JD, GREGORIAN))
+ return Qfalse;
+
+ if (!test_commercial(MIN_JD, MIN_JD + 366, ITALY))
+ return Qfalse;
+ if (!test_commercial(2305814, 2598007, ITALY))
+ return Qfalse;
+ if (!test_commercial(MAX_JD - 366, MAX_JD, ITALY))
+ return Qfalse;
+
+ return Qtrue;
+}
+
+static int
+test_weeknum(int from, int to, int f, double sg)
+{
+ int j;
+
+ fprintf(stderr, "test_weeknum: %d...%d (%d) - %.0f\n",
+ from, to, to - from, sg);
+ for (j = from; j <= to; j++) {
+ int y, w, d, rj, ns;
+
+ c_jd_to_weeknum(j, f, sg, &y, &w, &d);
+ c_weeknum_to_jd(y, w, d, f, sg, &rj, &ns);
+ if (j != rj) {
+ fprintf(stderr, "%d != %d\n", j, rj);
+ return 0;
+ }
+ }
+ return 1;
+}
+
+static VALUE
+date_s_test_weeknum(VALUE klass)
+{
+ int f;
+
+ for (f = 0; f <= 1; f++) {
+ if (!test_weeknum(MIN_JD, MIN_JD + 366, f, GREGORIAN))
+ return Qfalse;
+ if (!test_weeknum(2305814, 2598007, f, GREGORIAN))
+ return Qfalse;
+ if (!test_weeknum(MAX_JD - 366, MAX_JD, f, GREGORIAN))
+ return Qfalse;
+
+ if (!test_weeknum(MIN_JD, MIN_JD + 366, f, ITALY))
+ return Qfalse;
+ if (!test_weeknum(2305814, 2598007, f, ITALY))
+ return Qfalse;
+ if (!test_weeknum(MAX_JD - 366, MAX_JD, f, ITALY))
+ return Qfalse;
+ }
+
+ return Qtrue;
+}
+
+static int
+test_nth_kday(int from, int to, double sg)
+{
+ int j;
+
+ fprintf(stderr, "test_nth_kday: %d...%d (%d) - %.0f\n",
+ from, to, to - from, sg);
+ for (j = from; j <= to; j++) {
+ int y, m, n, k, rj, ns;
+
+ c_jd_to_nth_kday(j, sg, &y, &m, &n, &k);
+ c_nth_kday_to_jd(y, m, n, k, sg, &rj, &ns);
+ if (j != rj) {
+ fprintf(stderr, "%d != %d\n", j, rj);
+ return 0;
+ }
+ }
+ return 1;
+}
+
+static VALUE
+date_s_test_nth_kday(VALUE klass)
+{
+ if (!test_nth_kday(MIN_JD, MIN_JD + 366, GREGORIAN))
+ return Qfalse;
+ if (!test_nth_kday(2305814, 2598007, GREGORIAN))
+ return Qfalse;
+ if (!test_nth_kday(MAX_JD - 366, MAX_JD, GREGORIAN))
+ return Qfalse;
+
+ if (!test_nth_kday(MIN_JD, MIN_JD + 366, ITALY))
+ return Qfalse;
+ if (!test_nth_kday(2305814, 2598007, ITALY))
+ return Qfalse;
+ if (!test_nth_kday(MAX_JD - 366, MAX_JD, ITALY))
+ return Qfalse;
+
+ return Qtrue;
+}
+
+static int
+test_unit_v2v(VALUE i,
+ VALUE (* conv1)(VALUE),
+ VALUE (* conv2)(VALUE))
+{
+ VALUE c, o;
+ c = (*conv1)(i);
+ o = (*conv2)(c);
+ return f_eqeq_p(o, i);
+}
+
+static int
+test_unit_v2v_iter2(VALUE (* conv1)(VALUE),
+ VALUE (* conv2)(VALUE))
+{
+ if (!test_unit_v2v(INT2FIX(0), conv1, conv2))
+ return 0;
+ if (!test_unit_v2v(INT2FIX(1), conv1, conv2))
+ return 0;
+ if (!test_unit_v2v(INT2FIX(2), conv1, conv2))
+ return 0;
+ if (!test_unit_v2v(INT2FIX(3), conv1, conv2))
+ return 0;
+ if (!test_unit_v2v(INT2FIX(11), conv1, conv2))
+ return 0;
+ if (!test_unit_v2v(INT2FIX(65535), conv1, conv2))
+ return 0;
+ if (!test_unit_v2v(INT2FIX(1073741823), conv1, conv2))
+ return 0;
+ if (!test_unit_v2v(INT2NUM(1073741824), conv1, conv2))
+ return 0;
+ if (!test_unit_v2v(rb_rational_new2(INT2FIX(0), INT2FIX(1)), conv1, conv2))
+ return 0;
+ if (!test_unit_v2v(rb_rational_new2(INT2FIX(1), INT2FIX(1)), conv1, conv2))
+ return 0;
+ if (!test_unit_v2v(rb_rational_new2(INT2FIX(1), INT2FIX(2)), conv1, conv2))
+ return 0;
+ if (!test_unit_v2v(rb_rational_new2(INT2FIX(2), INT2FIX(3)), conv1, conv2))
+ return 0;
+ return 1;
+}
+
+static int
+test_unit_v2v_iter(VALUE (* conv1)(VALUE),
+ VALUE (* conv2)(VALUE))
+{
+ if (!test_unit_v2v_iter2(conv1, conv2))
+ return 0;
+ if (!test_unit_v2v_iter2(conv2, conv1))
+ return 0;
+ return 1;
+}
+
+static VALUE
+date_s_test_unit_conv(VALUE klass)
+{
+ if (!test_unit_v2v_iter(sec_to_day, day_to_sec))
+ return Qfalse;
+ if (!test_unit_v2v_iter(ms_to_sec, sec_to_ms))
+ return Qfalse;
+ if (!test_unit_v2v_iter(ns_to_day, day_to_ns))
+ return Qfalse;
+ if (!test_unit_v2v_iter(ns_to_sec, sec_to_ns))
+ return Qfalse;
+ return Qtrue;
+}
+
+static VALUE
+date_s_test_all(VALUE klass)
+{
+ if (date_s_test_civil(klass) == Qfalse)
+ return Qfalse;
+ if (date_s_test_ordinal(klass) == Qfalse)
+ return Qfalse;
+ if (date_s_test_commercial(klass) == Qfalse)
+ return Qfalse;
+ if (date_s_test_weeknum(klass) == Qfalse)
+ return Qfalse;
+ if (date_s_test_nth_kday(klass) == Qfalse)
+ return Qfalse;
+ if (date_s_test_unit_conv(klass) == Qfalse)
+ return Qfalse;
+ return Qtrue;
+}
+#endif
+
+static const char *monthnames[] = {
+ NULL,
+ "January", "February", "March",
+ "April", "May", "June",
+ "July", "August", "September",
+ "October", "November", "December"
+};
+
+static const char *abbr_monthnames[] = {
+ NULL,
+ "Jan", "Feb", "Mar", "Apr",
+ "May", "Jun", "Jul", "Aug",
+ "Sep", "Oct", "Nov", "Dec"
+};
+
+static const char *daynames[] = {
+ "Sunday", "Monday", "Tuesday", "Wednesday",
+ "Thursday", "Friday", "Saturday"
+};
+
+static const char *abbr_daynames[] = {
+ "Sun", "Mon", "Tue", "Wed",
+ "Thu", "Fri", "Sat"
+};
+
+static VALUE
+mk_ary_of_str(long len, const char *a[])
+{
+ VALUE o;
+ long i;
+
+ o = rb_ary_new2(len);
+ for (i = 0; i < len; i++) {
+ VALUE e;
+
+ if (!a[i])
+ e = Qnil;
+ else {
+ e = rb_usascii_str_new2(a[i]);
+ rb_obj_freeze(e);
+ }
+ rb_ary_push(o, e);
+ }
+ rb_obj_freeze(o);
+ return o;
+}
+
+void
+Init_date_core(void)
+{
+#undef rb_intern
+#define rb_intern(str) rb_intern_const(str)
+
+ assert(fprintf(stderr, "assert() is now active\n"));
+
+ id_cmp = rb_intern("<=>");
+ id_le_p = rb_intern("<=");
+ id_ge_p = rb_intern(">=");
+ id_eqeq_p = rb_intern("==");
+
+ half_days_in_day = rb_rational_new2(INT2FIX(1), INT2FIX(2));
+
+#if (LONG_MAX / DAY_IN_SECONDS) > SECOND_IN_NANOSECONDS
+ day_in_nanoseconds = LONG2NUM((long)DAY_IN_SECONDS *
+ SECOND_IN_NANOSECONDS);
+#elif defined HAVE_LONG_LONG
+ day_in_nanoseconds = LL2NUM((LONG_LONG)DAY_IN_SECONDS *
+ SECOND_IN_NANOSECONDS);
+#else
+ day_in_nanoseconds = f_mul(INT2FIX(DAY_IN_SECONDS),
+ INT2FIX(SECOND_IN_NANOSECONDS));
+#endif
+
+ rb_gc_register_mark_object(half_days_in_day);
+ rb_gc_register_mark_object(day_in_nanoseconds);
+
+ positive_inf = +INFINITY;
+ negative_inf = -INFINITY;
+
+ /*
+ * date and datetime class - Tadayoshi Funaba 1998-2011
+ *
+ * 'date' provides two classes Date and DateTime.
+ *
+ * == Terms and definitions
+ *
+ * Some terms and definitions are based on ISO 8601 and JIS X 0301.
+ *
+ * === calendar date
+ *
+ * The calendar date is a particular day of a calendar year,
+ * identified by its ordinal number within a calendar month within
+ * that year.
+ *
+ * In those classes, this is so-called "civil".
+ *
+ * === ordinal date
+ *
+ * The ordinal date is a particular day of a calendar year identified
+ * by its ordinal number within the year.
+ *
+ * In those classes, this is so-called "ordinal".
+ *
+ * === week date
+ *
+ * The week date is a date identified by calendar week and day numbers.
+ *
+ * The calendar week is a seven day period within a calendar year,
+ * starting on a Monday and identified by its ordinal number within
+ * the year; the first calendar week of the year is the one that
+ * includes the first Thursday of that year. In the Gregorian
+ * calendar, this is equivalent to the week which includes January 4.
+ *
+ * In those classes, this so-called "commercial".
+ *
+ * === julian day number
+ *
+ * The Julian day number is in elapsed days since noon (Greenwich mean
+ * time) on January 1, 4713 BCE (in the Julian calendar).
+ *
+ * In this document, the astronomical Julian day number is same as the
+ * original Julian day number. And the chronological Julian day
+ * number is a variation of the Julian day number. Its days begin at
+ * midnight on local time.
+ *
+ * In this document, when the term "Julian day number" simply appears,
+ * it just refers to "chronological Julian day number", not the
+ * original.
+ *
+ * In those classes, those are so-called "ajd" and "jd".
+ *
+ * === modified julian day number
+ *
+ * The modified Julian day number is in elapsed days since midnight
+ * (Coordinated universal time) on November 17, 1858 CE (in the
+ * Gregorian calendar).
+ *
+ * In this document, the astronomical modified Julian day number is
+ * same as the original modified Julian day number. And the
+ * chronological modified Julian day number is a variation of the
+ * modified Julian day number. Its days begin at midnight on local
+ * time.
+ *
+ * In this document, when the term "modified Julian day number" simply
+ * appears, it just refers to "chronological modified Julian day
+ * number", not the original.
+ *
+ * In those classes, this is so-called "mjd".
+ *
+ * == Date
+ *
+ * A subclass of Object that includes Comparable module and easily handles
+ * date.
+ *
+ * Date object is created with Date::new, Date::jd, Date::ordinal,
+ * Date::commercial, Date::parse, Date::strptime, Date::today,
+ * Time#to_date or etc.
+ *
+ * require 'date'
+ *
+ * Date.new(2001,2,3)
+ * #=> #<Date: 2001-02-03 ...>
+ * Date.jd(2451944)
+ * #=> #<Date: 2001-02-03 ...>
+ * Date.ordinal(2001,34)
+ * #=> #<Date: 2001-02-03 ...>
+ * Date.commercial(2001,5,6)
+ * #=> #<Date: 2001-02-03 ...>
+ * Date.parse('2001-02-03')
+ * #=> #<Date: 2001-02-03 ...>
+ * Date.strptime('03-02-2001', '%d-%m-%Y')
+ * #=> #<Date: 2001-02-03 ...>
+ * Time.new(2001,2,3).to_date
+ * #=> #<Date: 2001-02-03 ...>
+ *
+ * All date objects are immutable; hence cannot modify themselves.
+ *
+ * The concept of this date object can be represented as a tuple
+ * of the day count, the offset and the day of calendar reform.
+ *
+ * The day count denotes the absolute position of a temporal
+ * dimension. The offset is relative adjustment, which determines
+ * decoded local time with the day count. The day of calendar
+ * reform denotes the start day of the new style. The old style
+ * of the West is the Julian calendar which was adopted by
+ * Caesar. The new style is the Gregorian calendar, which is the
+ * current civil calendar of many countries.
+ *
+ * The day count is virtually the astronomical Julian day number.
+ * The offset in this class is usually zero, and cannot be
+ * specified directly.
+ *
+ * An optional argument the day of calendar reform (start) as a
+ * Julian day number, which should be 2298874 to 2426355 or -/+oo.
+ * The default value is Date::ITALY (2299161=1582-10-15). See
+ * also sample/cal.rb.
+ *
+ * $ ruby sample/cal.rb -c it 10 1582
+ * October 1582
+ * S M Tu W Th F S
+ * 1 2 3 4 15 16
+ * 17 18 19 20 21 22 23
+ * 24 25 26 27 28 29 30
+ * 31
+ *
+ * $ ruby sample/cal.rb -c gb 9 1752
+ * September 1752
+ * S M Tu W Th F S
+ * 1 2 14 15 16
+ * 17 18 19 20 21 22 23
+ * 24 25 26 27 28 29 30
+ *
+ * Date object has various methods. See each reference.
+ *
+ * d = Date.parse('3rd Feb 2001')
+ * #=> #<Date: 2001-02-03 ...>
+ * d.year #=> 2001
+ * d.mon #=> 2
+ * d.mday #=> 3
+ * d.wday #=> 6
+ * d += 1 #=> #<Date: 2001-02-04 ...>
+ * d.strftime('%a %d %b %Y') #=> "Sun 04 Feb 2001"
+ *
+ *
+ * == DateTime
+ *
+ * A subclass of Date that easily handles date, hour, minute, second and
+ * offset.
+ *
+ * DateTime does not consider any leap seconds, does not track
+ * any summer time rules.
+ *
+ * DateTime object is created with DateTime::new, DateTime::jd,
+ * DateTime::ordinal, DateTime::commercial, DateTime::parse,
+ * DateTime::strptime, DateTime::now, Time#to_datetime or etc.
+ *
+ * require 'date'
+ *
+ * DateTime.new(2001,2,3,4,5,6)
+ * #=> #<DateTime: 2001-02-03T04:05:06+00:00 ...>
+ *
+ * The last element of day, hour, minute or second can be
+ * fractional number. The fractional number's precision is assumed
+ * at most nanosecond.
+ *
+ * DateTime.new(2001,2,3.5)
+ * #=> #<DateTime: 2001-02-03T12:00:00+00:00 ...>
+ *
+ * An optional argument the offset indicates the difference
+ * between the local time and UTC. For example, Rational(3,24)
+ * represents ahead of 3 hours of UTC, Rational(-5,24) represents
+ * behind of 5 hours of UTC. The offset should be -1 to +1, and
+ * its precision is assumed at most second. The default value is
+ * zero(equals to UTC).
+ *
+ * DateTime.new(2001,2,3,4,5,6,Rational(3,24))
+ * #=> #<DateTime: 2001-02-03T04:05:06+03:00 ...>
+ *
+ * also accepts string form.
+ *
+ * DateTime.new(2001,2,3,4,5,6,'+03:00')
+ * #=> #<DateTime: 2001-02-03T04:05:06+03:00 ...>
+ *
+ * An optional argument the day of calendar reform (start) denotes
+ * a Julian day number, which should be 2298874 to 2426355 or
+ * -/+oo. The default value is Date::ITALY (2299161=1582-10-15).
+ *
+ * DateTime object has various methods. See each reference.
+ *
+ * d = DateTime.parse('3rd Feb 2001 04:05:06+03:30')
+ * #=> #<DateTime: 2001-02-03T04:05:06+03:30 ...>
+ * d.hour #=> 4
+ * d.min #=> 5
+ * d.sec #=> 6
+ * d.offset #=> (7/48)
+ * d.zone #=> "+03:30"
+ * d += Rational('1.5')
+ * #=> #<DateTime: 2001-02-04%16:05:06+03:30 ...>
+ * d = d.new_offset('+09:00')
+ * #=> #<DateTime: 2001-02-04%21:35:06+09:00 ...>
+ * d.strftime('%I:%M:%S %p')
+ * #=> "09:35:06 PM"
+ * d > DateTime.new(1999)
+ * #=> true
+ */
+ cDate = rb_define_class("Date", rb_cObject);
+
+ rb_include_module(cDate, rb_mComparable);
+
+ /* An array of strings of full month names in English. The first
+ * element is nil.
+ */
+ rb_define_const(cDate, "MONTHNAMES", mk_ary_of_str(13, monthnames));
+
+ /* An array of strings of abbreviated month names in English. The
+ * first element is nil.
+ */
+ rb_define_const(cDate, "ABBR_MONTHNAMES",
+ mk_ary_of_str(13, abbr_monthnames));
+
+ /* An array of strings of the full names of days of the week in English.
+ * The first is "Sunday".
+ */
+ rb_define_const(cDate, "DAYNAMES", mk_ary_of_str(7, daynames));
+
+ /* An array of strings of abbreviated day names in English. The
+ * first is "Sun".
+ */
+ rb_define_const(cDate, "ABBR_DAYNAMES", mk_ary_of_str(7, abbr_daynames));
+
+ /* The Julian day number of the day of calendar reform for Italy
+ * and some catholic countries.
+ */
+ rb_define_const(cDate, "ITALY", INT2FIX(ITALY));
+
+ /* The Julian day number of the day of calendar reform for England
+ * and her colonies.
+ */
+ rb_define_const(cDate, "ENGLAND", INT2FIX(ENGLAND));
+
+ /* The Julian day number of the day of calendar reform for the
+ * proleptic Julian calendar
+ */
+ rb_define_const(cDate, "JULIAN", DBL2NUM(JULIAN));
+
+ /* The Julian day number of the day of calendar reform for the
+ * proleptic Gregorian calendar
+ */
+ rb_define_const(cDate, "GREGORIAN", DBL2NUM(GREGORIAN));
+
+ rb_define_alloc_func(cDate, d_lite_s_alloc);
+
+#ifndef NDEBUG
+#define de_define_private_method rb_define_private_method
+ de_define_private_method(CLASS_OF(cDate), "_valid_jd?",
+ date_s__valid_jd_p, -1);
+ de_define_private_method(CLASS_OF(cDate), "_valid_ordinal?",
+ date_s__valid_ordinal_p, -1);
+ de_define_private_method(CLASS_OF(cDate), "_valid_civil?",
+ date_s__valid_civil_p, -1);
+ de_define_private_method(CLASS_OF(cDate), "_valid_date?",
+ date_s__valid_civil_p, -1);
+ de_define_private_method(CLASS_OF(cDate), "_valid_commercial?",
+ date_s__valid_commercial_p, -1);
+ de_define_private_method(CLASS_OF(cDate), "_valid_weeknum?",
+ date_s__valid_weeknum_p, -1);
+ de_define_private_method(CLASS_OF(cDate), "_valid_nth_kday?",
+ date_s__valid_nth_kday_p, -1);
+#endif
+
+ rb_define_singleton_method(cDate, "valid_jd?", date_s_valid_jd_p, -1);
+ rb_define_singleton_method(cDate, "valid_ordinal?",
+ date_s_valid_ordinal_p, -1);
+ rb_define_singleton_method(cDate, "valid_civil?", date_s_valid_civil_p, -1);
+ rb_define_singleton_method(cDate, "valid_date?", date_s_valid_civil_p, -1);
+ rb_define_singleton_method(cDate, "valid_commercial?",
+ date_s_valid_commercial_p, -1);
+
+#ifndef NDEBUG
+ de_define_private_method(CLASS_OF(cDate), "valid_weeknum?",
+ date_s_valid_weeknum_p, -1);
+ de_define_private_method(CLASS_OF(cDate), "valid_nth_kday?",
+ date_s_valid_nth_kday_p, -1);
+ de_define_private_method(CLASS_OF(cDate), "zone_to_diff",
+ date_s_zone_to_diff, 1);
+#endif
+
+ rb_define_singleton_method(cDate, "julian_leap?", date_s_julian_leap_p, 1);
+ rb_define_singleton_method(cDate, "gregorian_leap?",
+ date_s_gregorian_leap_p, 1);
+ rb_define_singleton_method(cDate, "leap?",
+ date_s_gregorian_leap_p, 1);
+
+#ifndef NDEBUG
+#define de_define_singleton_method rb_define_singleton_method
+#define de_define_alias rb_define_alias
+ de_define_singleton_method(cDate, "new!", date_s_new_bang, -1);
+ de_define_alias(rb_singleton_class(cDate), "new_l!", "new");
+#endif
+
+ rb_define_singleton_method(cDate, "jd", date_s_jd, -1);
+ rb_define_singleton_method(cDate, "ordinal", date_s_ordinal, -1);
+ rb_define_singleton_method(cDate, "civil", date_s_civil, -1);
+ rb_define_singleton_method(cDate, "new", date_s_civil, -1);
+ rb_define_singleton_method(cDate, "commercial", date_s_commercial, -1);
+
+#ifndef NDEBUG
+ de_define_singleton_method(cDate, "weeknum", date_s_weeknum, -1);
+ de_define_singleton_method(cDate, "nth_kday", date_s_nth_kday, -1);
+#endif
+
+ rb_define_singleton_method(cDate, "today", date_s_today, -1);
+ rb_define_singleton_method(cDate, "_strptime", date_s__strptime, -1);
+ rb_define_singleton_method(cDate, "strptime", date_s_strptime, -1);
+ rb_define_singleton_method(cDate, "_parse", date_s__parse, -1);
+ rb_define_singleton_method(cDate, "parse", date_s_parse, -1);
+ rb_define_singleton_method(cDate, "_iso8601", date_s__iso8601, 1);
+ rb_define_singleton_method(cDate, "iso8601", date_s_iso8601, -1);
+ rb_define_singleton_method(cDate, "_rfc3339", date_s__rfc3339, 1);
+ rb_define_singleton_method(cDate, "rfc3339", date_s_rfc3339, -1);
+ rb_define_singleton_method(cDate, "_xmlschema", date_s__xmlschema, 1);
+ rb_define_singleton_method(cDate, "xmlschema", date_s_xmlschema, -1);
+ rb_define_singleton_method(cDate, "_rfc2822", date_s__rfc2822, 1);
+ rb_define_singleton_method(cDate, "_rfc822", date_s__rfc2822, 1);
+ rb_define_singleton_method(cDate, "rfc2822", date_s_rfc2822, -1);
+ rb_define_singleton_method(cDate, "rfc822", date_s_rfc2822, -1);
+ rb_define_singleton_method(cDate, "_httpdate", date_s__httpdate, 1);
+ rb_define_singleton_method(cDate, "httpdate", date_s_httpdate, -1);
+ rb_define_singleton_method(cDate, "_jisx0301", date_s__jisx0301, 1);
+ rb_define_singleton_method(cDate, "jisx0301", date_s_jisx0301, -1);
+
+#ifndef NDEBUG
+#define de_define_method rb_define_method
+ de_define_method(cDate, "initialize", d_lite_initialize, -1);
+#endif
+ rb_define_method(cDate, "initialize_copy", d_lite_initialize_copy, 1);
+
+#ifndef NDEBUG
+ de_define_method(cDate, "fill", d_lite_fill, 0);
+#endif
+
+ rb_define_method(cDate, "ajd", d_lite_ajd, 0);
+ rb_define_method(cDate, "amjd", d_lite_amjd, 0);
+ rb_define_method(cDate, "jd", d_lite_jd, 0);
+ rb_define_method(cDate, "mjd", d_lite_mjd, 0);
+ rb_define_method(cDate, "ld", d_lite_ld, 0);
+
+ rb_define_method(cDate, "year", d_lite_year, 0);
+ rb_define_method(cDate, "yday", d_lite_yday, 0);
+ rb_define_method(cDate, "mon", d_lite_mon, 0);
+ rb_define_method(cDate, "month", d_lite_mon, 0);
+ rb_define_method(cDate, "mday", d_lite_mday, 0);
+ rb_define_method(cDate, "day", d_lite_mday, 0);
+ rb_define_method(cDate, "day_fraction", d_lite_day_fraction, 0);
+
+ rb_define_method(cDate, "cwyear", d_lite_cwyear, 0);
+ rb_define_method(cDate, "cweek", d_lite_cweek, 0);
+ rb_define_method(cDate, "cwday", d_lite_cwday, 0);
+
+#ifndef NDEBUG
+ de_define_private_method(cDate, "wnum0", d_lite_wnum0, 0);
+ de_define_private_method(cDate, "wnum1", d_lite_wnum1, 0);
+#endif
+
+ rb_define_method(cDate, "wday", d_lite_wday, 0);
+
+ rb_define_method(cDate, "sunday?", d_lite_sunday_p, 0);
+ rb_define_method(cDate, "monday?", d_lite_monday_p, 0);
+ rb_define_method(cDate, "tuesday?", d_lite_tuesday_p, 0);
+ rb_define_method(cDate, "wednesday?", d_lite_wednesday_p, 0);
+ rb_define_method(cDate, "thursday?", d_lite_thursday_p, 0);
+ rb_define_method(cDate, "friday?", d_lite_friday_p, 0);
+ rb_define_method(cDate, "saturday?", d_lite_saturday_p, 0);
+
+#ifndef NDEBUG
+ de_define_method(cDate, "nth_kday?", d_lite_nth_kday_p, 2);
+#endif
+
+ rb_define_private_method(cDate, "hour", d_lite_hour, 0);
+ rb_define_private_method(cDate, "min", d_lite_min, 0);
+ rb_define_private_method(cDate, "minute", d_lite_min, 0);
+ rb_define_private_method(cDate, "sec", d_lite_sec, 0);
+ rb_define_private_method(cDate, "second", d_lite_sec, 0);
+ rb_define_private_method(cDate, "sec_fraction", d_lite_sec_fraction, 0);
+ rb_define_private_method(cDate, "second_fraction", d_lite_sec_fraction, 0);
+ rb_define_private_method(cDate, "offset", d_lite_offset, 0);
+ rb_define_private_method(cDate, "zone", d_lite_zone, 0);
+
+ rb_define_method(cDate, "julian?", d_lite_julian_p, 0);
+ rb_define_method(cDate, "gregorian?", d_lite_gregorian_p, 0);
+ rb_define_method(cDate, "leap?", d_lite_leap_p, 0);
+
+ rb_define_method(cDate, "start", d_lite_start, 0);
+ rb_define_method(cDate, "new_start", d_lite_new_start, -1);
+ rb_define_method(cDate, "italy", d_lite_italy, 0);
+ rb_define_method(cDate, "england", d_lite_england, 0);
+ rb_define_method(cDate, "julian", d_lite_julian, 0);
+ rb_define_method(cDate, "gregorian", d_lite_gregorian, 0);
+
+ rb_define_private_method(cDate, "new_offset", d_lite_new_offset, -1);
+
+ rb_define_method(cDate, "+", d_lite_plus, 1);
+ rb_define_method(cDate, "-", d_lite_minus, 1);
+
+ rb_define_method(cDate, "next_day", d_lite_next_day, -1);
+ rb_define_method(cDate, "prev_day", d_lite_prev_day, -1);
+ rb_define_method(cDate, "next", d_lite_next, 0);
+ rb_define_method(cDate, "succ", d_lite_next, 0);
+
+ rb_define_method(cDate, ">>", d_lite_rshift, 1);
+ rb_define_method(cDate, "<<", d_lite_lshift, 1);
+
+ rb_define_method(cDate, "next_month", d_lite_next_month, -1);
+ rb_define_method(cDate, "prev_month", d_lite_prev_month, -1);
+ rb_define_method(cDate, "next_year", d_lite_next_year, -1);
+ rb_define_method(cDate, "prev_year", d_lite_prev_year, -1);
+
+ rb_define_method(cDate, "step", d_lite_step, -1);
+ rb_define_method(cDate, "upto", d_lite_upto, 1);
+ rb_define_method(cDate, "downto", d_lite_downto, 1);
+
+ rb_define_method(cDate, "<=>", d_lite_cmp, 1);
+ rb_define_method(cDate, "===", d_lite_equal, 1);
+ rb_define_method(cDate, "eql?", d_lite_eql_p, 1);
+ rb_define_method(cDate, "hash", d_lite_hash, 0);
+
+ rb_define_method(cDate, "to_s", d_lite_to_s, 0);
+#ifndef NDEBUG
+ de_define_method(cDate, "inspect_raw", d_lite_inspect_raw, 0);
+#endif
+ rb_define_method(cDate, "inspect", d_lite_inspect, 0);
+
+ rb_define_method(cDate, "strftime", d_lite_strftime, -1);
+
+ rb_define_method(cDate, "asctime", d_lite_asctime, 0);
+ rb_define_method(cDate, "ctime", d_lite_asctime, 0);
+ rb_define_method(cDate, "iso8601", d_lite_iso8601, 0);
+ rb_define_method(cDate, "xmlschema", d_lite_iso8601, 0);
+ rb_define_method(cDate, "rfc3339", d_lite_rfc3339, 0);
+ rb_define_method(cDate, "rfc2822", d_lite_rfc2822, 0);
+ rb_define_method(cDate, "rfc822", d_lite_rfc2822, 0);
+ rb_define_method(cDate, "httpdate", d_lite_httpdate, 0);
+ rb_define_method(cDate, "jisx0301", d_lite_jisx0301, 0);
+
+#ifndef NDEBUG
+ de_define_method(cDate, "marshal_dump_old", d_lite_marshal_dump_old, 0);
+#endif
+ rb_define_method(cDate, "marshal_dump", d_lite_marshal_dump, 0);
+ rb_define_method(cDate, "marshal_load", d_lite_marshal_load, 1);
+ rb_define_singleton_method(cDate, "_load", date_s__load, 1);
+
+ /* datetime */
+
+ cDateTime = rb_define_class("DateTime", cDate);
+
+ rb_define_singleton_method(cDateTime, "jd", datetime_s_jd, -1);
+ rb_define_singleton_method(cDateTime, "ordinal", datetime_s_ordinal, -1);
+ rb_define_singleton_method(cDateTime, "civil", datetime_s_civil, -1);
+ rb_define_singleton_method(cDateTime, "new", datetime_s_civil, -1);
+ rb_define_singleton_method(cDateTime, "commercial",
+ datetime_s_commercial, -1);
+
+#ifndef NDEBUG
+ de_define_singleton_method(cDateTime, "weeknum",
+ datetime_s_weeknum, -1);
+ de_define_singleton_method(cDateTime, "nth_kday",
+ datetime_s_nth_kday, -1);
+#endif
+
+ rb_undef_method(CLASS_OF(cDateTime), "today");
+
+ rb_define_singleton_method(cDateTime, "now", datetime_s_now, -1);
+ rb_define_singleton_method(cDateTime, "_strptime",
+ datetime_s__strptime, -1);
+ rb_define_singleton_method(cDateTime, "strptime",
+ datetime_s_strptime, -1);
+ rb_define_singleton_method(cDateTime, "parse",
+ datetime_s_parse, -1);
+ rb_define_singleton_method(cDateTime, "iso8601",
+ datetime_s_iso8601, -1);
+ rb_define_singleton_method(cDateTime, "rfc3339",
+ datetime_s_rfc3339, -1);
+ rb_define_singleton_method(cDateTime, "xmlschema",
+ datetime_s_xmlschema, -1);
+ rb_define_singleton_method(cDateTime, "rfc2822",
+ datetime_s_rfc2822, -1);
+ rb_define_singleton_method(cDateTime, "rfc822",
+ datetime_s_rfc2822, -1);
+ rb_define_singleton_method(cDateTime, "httpdate",
+ datetime_s_httpdate, -1);
+ rb_define_singleton_method(cDateTime, "jisx0301",
+ datetime_s_jisx0301, -1);
+
+#define f_public(m,s) rb_funcall(m, rb_intern("public"), 1,\
+ ID2SYM(rb_intern(s)))
+
+ f_public(cDateTime, "hour");
+ f_public(cDateTime, "min");
+ f_public(cDateTime, "minute");
+ f_public(cDateTime, "sec");
+ f_public(cDateTime, "second");
+ f_public(cDateTime, "sec_fraction");
+ f_public(cDateTime, "second_fraction");
+ f_public(cDateTime, "offset");
+ f_public(cDateTime, "zone");
+ f_public(cDateTime, "new_offset");
+
+ rb_define_method(cDateTime, "to_s", dt_lite_to_s, 0);
+
+ rb_define_method(cDateTime, "strftime", dt_lite_strftime, -1);
+
+ rb_define_method(cDateTime, "iso8601", dt_lite_iso8601, -1);
+ rb_define_method(cDateTime, "xmlschema", dt_lite_iso8601, -1);
+ rb_define_method(cDateTime, "rfc3339", dt_lite_rfc3339, -1);
+ rb_define_method(cDateTime, "jisx0301", dt_lite_jisx0301, -1);
+
+ /* conversions */
+
+ rb_define_method(rb_cTime, "to_time", time_to_time, 0);
+ rb_define_method(rb_cTime, "to_date", time_to_date, 0);
+ rb_define_method(rb_cTime, "to_datetime", time_to_datetime, 0);
+
+ rb_define_method(cDate, "to_time", date_to_time, 0);
+ rb_define_method(cDate, "to_date", date_to_date, 0);
+ rb_define_method(cDate, "to_datetime", date_to_datetime, 0);
+
+ rb_define_method(cDateTime, "to_time", datetime_to_time, 0);
+ rb_define_method(cDateTime, "to_date", datetime_to_date, 0);
+ rb_define_method(cDateTime, "to_datetime", datetime_to_datetime, 0);
+
+#ifndef NDEBUG
+ /* tests */
+
+ de_define_singleton_method(cDate, "test_civil", date_s_test_civil, 0);
+ de_define_singleton_method(cDate, "test_ordinal", date_s_test_ordinal, 0);
+ de_define_singleton_method(cDate, "test_commercial",
+ date_s_test_commercial, 0);
+ de_define_singleton_method(cDate, "test_weeknum", date_s_test_weeknum, 0);
+ de_define_singleton_method(cDate, "test_nth_kday", date_s_test_nth_kday, 0);
+ de_define_singleton_method(cDate, "test_unit_conv",
+ date_s_test_unit_conv, 0);
+ de_define_singleton_method(cDate, "test_all", date_s_test_all, 0);
+#endif
+}
+
+/*
+Local variables:
+c-file-style: "ruby"
+End:
+*/
diff --git a/jni/ruby/ext/date/date_parse.c b/jni/ruby/ext/date/date_parse.c
new file mode 100644
index 0000000..239e264
--- /dev/null
+++ b/jni/ruby/ext/date/date_parse.c
@@ -0,0 +1,3128 @@
+/*
+ date_parse.c: Coded by Tadayoshi Funaba 2011,2012
+*/
+
+#include "ruby.h"
+#include "ruby/encoding.h"
+#include "ruby/re.h"
+#include <ctype.h>
+
+/* #define TIGHT_PARSER */
+
+#define sizeof_array(o) (sizeof o / sizeof o[0])
+
+#define f_negate(x) rb_funcall(x, rb_intern("-@"), 0)
+#define f_add(x,y) rb_funcall(x, '+', 1, y)
+#define f_sub(x,y) rb_funcall(x, '-', 1, y)
+#define f_mul(x,y) rb_funcall(x, '*', 1, y)
+#define f_div(x,y) rb_funcall(x, '/', 1, y)
+#define f_idiv(x,y) rb_funcall(x, rb_intern("div"), 1, y)
+#define f_mod(x,y) rb_funcall(x, '%', 1, y)
+#define f_expt(x,y) rb_funcall(x, rb_intern("**"), 1, y)
+
+#define f_lt_p(x,y) rb_funcall(x, '<', 1, y)
+#define f_gt_p(x,y) rb_funcall(x, '>', 1, y)
+#define f_le_p(x,y) rb_funcall(x, rb_intern("<="), 1, y)
+#define f_ge_p(x,y) rb_funcall(x, rb_intern(">="), 1, y)
+
+#define f_to_s(x) rb_funcall(x, rb_intern("to_s"), 0)
+
+#define f_match(r,s) rb_funcall(r, rb_intern("match"), 1, s)
+#define f_aref(o,i) rb_funcall(o, rb_intern("[]"), 1, i)
+#define f_aref2(o,i,j) rb_funcall(o, rb_intern("[]"), 2, i, j)
+#define f_begin(o,i) rb_funcall(o, rb_intern("begin"), 1, i)
+#define f_end(o,i) rb_funcall(o, rb_intern("end"), 1, i)
+#define f_aset(o,i,v) rb_funcall(o, rb_intern("[]="), 2, i, v)
+#define f_aset2(o,i,j,v) rb_funcall(o, rb_intern("[]="), 3, i, j, v)
+#define f_sub_bang(s,r,x) rb_funcall(s, rb_intern("sub!"), 2, r, x)
+#define f_gsub_bang(s,r,x) rb_funcall(s, rb_intern("gsub!"), 2, r, x)
+
+#define set_hash(k,v) rb_hash_aset(hash, ID2SYM(rb_intern(k)), v)
+#define ref_hash(k) rb_hash_aref(hash, ID2SYM(rb_intern(k)))
+#define del_hash(k) rb_hash_delete(hash, ID2SYM(rb_intern(k)))
+
+#define cstr2num(s) rb_cstr_to_inum(s, 10, 0)
+#define str2num(s) rb_str_to_inum(s, 10, 0)
+
+static const char *abbr_days[] = {
+ "sun", "mon", "tue", "wed",
+ "thu", "fri", "sat"
+};
+
+static const char *abbr_months[] = {
+ "jan", "feb", "mar", "apr", "may", "jun",
+ "jul", "aug", "sep", "oct", "nov", "dec"
+};
+
+#define issign(c) ((c) == '-' || (c) == '+')
+#define asp_string() rb_str_new(" ", 1)
+#ifdef TIGHT_PARSER
+#define asuba_string() rb_str_new("\001", 1)
+#define asubb_string() rb_str_new("\002", 1)
+#define asubw_string() rb_str_new("\027", 1)
+#define asubt_string() rb_str_new("\024", 1)
+#endif
+
+#define DECDIGIT "0123456789"
+
+static void
+s3e(VALUE hash, VALUE y, VALUE m, VALUE d, int bc)
+{
+ VALUE c = Qnil;
+
+ if (!RB_TYPE_P(m, T_STRING))
+ m = f_to_s(m);
+
+ if (!NIL_P(y) && !NIL_P(m) && NIL_P(d)) {
+ VALUE oy = y;
+ VALUE om = m;
+ VALUE od = d;
+
+ y = od;
+ m = oy;
+ d = om;
+ }
+
+ if (NIL_P(y)) {
+ if (!NIL_P(d) && RSTRING_LEN(d) > 2) {
+ y = d;
+ d = Qnil;
+ }
+ if (!NIL_P(d) && *RSTRING_PTR(d) == '\'') {
+ y = d;
+ d = Qnil;
+ }
+ }
+
+ if (!NIL_P(y)) {
+ const char *s, *bp, *ep;
+ size_t l;
+
+ s = RSTRING_PTR(y);
+ while (!issign((unsigned char)*s) && !isdigit((unsigned char)*s))
+ s++;
+ bp = s;
+ if (issign((unsigned char)*s))
+ s++;
+ l = strspn(s, DECDIGIT);
+ ep = s + l;
+ if (*ep) {
+ y = d;
+ d = rb_str_new(bp, ep - bp);
+ }
+ }
+
+ if (!NIL_P(m)) {
+ const char *s;
+
+ s = RSTRING_PTR(m);
+ if (*s == '\'' || RSTRING_LEN(m) > 2) {
+ /* us -> be */
+ VALUE oy = y;
+ VALUE om = m;
+ VALUE od = d;
+
+ y = om;
+ m = od;
+ d = oy;
+ }
+ }
+
+ if (!NIL_P(d)) {
+ const char *s;
+
+ s = RSTRING_PTR(d);
+ if (*s == '\'' || RSTRING_LEN(d) > 2) {
+ VALUE oy = y;
+ VALUE od = d;
+
+ y = od;
+ d = oy;
+ }
+ }
+
+ if (!NIL_P(y)) {
+ const char *s, *bp, *ep;
+ int sign = 0;
+ size_t l;
+ VALUE iy;
+
+ s = RSTRING_PTR(y);
+ while (!issign((unsigned char)*s) && !isdigit((unsigned char)*s))
+ s++;
+ bp = s;
+ if (issign(*s)) {
+ s++;
+ sign = 1;
+ }
+ if (sign)
+ c = Qfalse;
+ l = strspn(s, DECDIGIT);
+ ep = s + l;
+ if (l > 2)
+ c = Qfalse;
+ {
+ char *buf;
+
+ buf = ALLOCA_N(char, ep - bp + 1);
+ memcpy(buf, bp, ep - bp);
+ buf[ep - bp] = '\0';
+ iy = cstr2num(buf);
+ }
+ set_hash("year", iy);
+ }
+
+ if (bc)
+ set_hash("_bc", Qtrue);
+
+ if (!NIL_P(m)) {
+ const char *s, *bp, *ep;
+ size_t l;
+ VALUE im;
+
+ s = RSTRING_PTR(m);
+ while (!isdigit((unsigned char)*s))
+ s++;
+ bp = s;
+ l = strspn(s, DECDIGIT);
+ ep = s + l;
+ {
+ char *buf;
+
+ buf = ALLOCA_N(char, ep - bp + 1);
+ memcpy(buf, bp, ep - bp);
+ buf[ep - bp] = '\0';
+ im = cstr2num(buf);
+ }
+ set_hash("mon", im);
+ }
+
+ if (!NIL_P(d)) {
+ const char *s, *bp, *ep;
+ size_t l;
+ VALUE id;
+
+ s = RSTRING_PTR(d);
+ while (!isdigit((unsigned char)*s))
+ s++;
+ bp = s;
+ l = strspn(s, DECDIGIT);
+ ep = s + l;
+ {
+ char *buf;
+
+ buf = ALLOCA_N(char, ep - bp + 1);
+ memcpy(buf, bp, ep - bp);
+ buf[ep - bp] = '\0';
+ id = cstr2num(buf);
+ }
+ set_hash("mday", id);
+ }
+
+ if (!NIL_P(c))
+ set_hash("_comp", c);
+}
+
+#define DAYS "sunday|monday|tuesday|wednesday|thursday|friday|saturday"
+#define MONTHS "january|february|march|april|may|june|july|august|september|october|november|december"
+#define ABBR_DAYS "sun|mon|tue|wed|thu|fri|sat"
+#define ABBR_MONTHS "jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec"
+
+#ifdef TIGHT_PARSER
+#define VALID_DAYS "(?:" DAYS ")" "|(?:tues|wednes|thurs|thur|" ABBR_DAYS ")\\.?"
+#define VALID_MONTHS "(?:" MONTHS ")" "|(?:sept|" ABBR_MONTHS ")\\.?"
+#define DOTLESS_VALID_MONTHS "(?:" MONTHS ")" "|(?:sept|" ABBR_MONTHS ")"
+#define BOS "\\A\\s*"
+#define FPA "\\001"
+#define FPB "\\002"
+#define FPW "\\027"
+#define FPT "\\024"
+#define FPW_COM "\\s*(?:" FPW "\\s*,?)?\\s*"
+#define FPT_COM "\\s*(?:" FPT "\\s*,?)?\\s*"
+#define COM_FPW "\\s*(?:,?\\s*" FPW ")?\\s*"
+#define COM_FPT "\\s*(?:,?\\s*(?:@|\\b[aA][tT]\\b)?\\s*" FPT ")?\\s*"
+#define TEE_FPT "\\s*(?:[tT]?" FPT ")?"
+#define EOS "\\s*\\z"
+#endif
+
+static VALUE
+regcomp(const char *source, long len, int opt)
+{
+ VALUE pat;
+
+ pat = rb_reg_new(source, len, opt);
+ rb_gc_register_mark_object(pat);
+ return pat;
+}
+
+#define REGCOMP(pat,opt) \
+{ \
+ if (NIL_P(pat)) \
+ pat = regcomp(pat##_source, sizeof pat##_source - 1, opt); \
+}
+
+#define REGCOMP_0(pat) REGCOMP(pat, 0)
+#define REGCOMP_I(pat) REGCOMP(pat, ONIG_OPTION_IGNORECASE)
+
+#define MATCH(s,p,c) \
+{ \
+ return match(s, p, hash, c); \
+}
+
+static int
+match(VALUE str, VALUE pat, VALUE hash, int (*cb)(VALUE, VALUE))
+{
+ VALUE m;
+
+ m = f_match(pat, str);
+
+ if (NIL_P(m))
+ return 0;
+
+ (*cb)(m, hash);
+
+ return 1;
+}
+
+static int
+subx(VALUE str, VALUE rep, VALUE pat, VALUE hash, int (*cb)(VALUE, VALUE))
+{
+ VALUE m;
+
+ m = f_match(pat, str);
+
+ if (NIL_P(m))
+ return 0;
+
+ {
+ VALUE be, en;
+
+ be = f_begin(m, INT2FIX(0));
+ en = f_end(m, INT2FIX(0));
+ f_aset2(str, be, LONG2NUM(NUM2LONG(en) - NUM2LONG(be)), rep);
+ (*cb)(m, hash);
+ }
+
+ return 1;
+}
+
+#define SUBS(s,p,c) \
+{ \
+ return subx(s, asp_string(), p, hash, c); \
+}
+
+#ifdef TIGHT_PARSER
+#define SUBA(s,p,c) \
+{ \
+ return subx(s, asuba_string(), p, hash, c); \
+}
+
+#define SUBB(s,p,c) \
+{ \
+ return subx(s, asubb_string(), p, hash, c); \
+}
+
+#define SUBW(s,p,c) \
+{ \
+ return subx(s, asubw_string(), p, hash, c); \
+}
+
+#define SUBT(s,p,c) \
+{ \
+ return subx(s, asubt_string(), p, hash, c); \
+}
+#endif
+
+struct zone {
+ const char *name;
+ int offset;
+};
+
+static struct zone zones_source[] = {
+ {"ut", 0*3600}, {"gmt", 0*3600}, {"est", -5*3600}, {"edt", -4*3600},
+ {"cst", -6*3600}, {"cdt", -5*3600}, {"mst", -7*3600}, {"mdt", -6*3600},
+ {"pst", -8*3600}, {"pdt", -7*3600},
+ {"a", 1*3600}, {"b", 2*3600}, {"c", 3*3600}, {"d", 4*3600},
+ {"e", 5*3600}, {"f", 6*3600}, {"g", 7*3600}, {"h", 8*3600},
+ {"i", 9*3600}, {"k", 10*3600}, {"l", 11*3600}, {"m", 12*3600},
+ {"n", -1*3600}, {"o", -2*3600}, {"p", -3*3600}, {"q", -4*3600},
+ {"r", -5*3600}, {"s", -6*3600}, {"t", -7*3600}, {"u", -8*3600},
+ {"v", -9*3600}, {"w", -10*3600}, {"x", -11*3600}, {"y", -12*3600},
+ {"z", 0*3600},
+
+ {"utc", 0*3600}, {"wet", 0*3600},
+ {"at", -2*3600}, {"brst",-2*3600}, {"ndt", -(2*3600+1800)},
+ {"art", -3*3600}, {"adt", -3*3600}, {"brt", -3*3600}, {"clst",-3*3600},
+ {"nst", -(3*3600+1800)},
+ {"ast", -4*3600}, {"clt", -4*3600},
+ {"akdt",-8*3600}, {"ydt", -8*3600},
+ {"akst",-9*3600}, {"hadt",-9*3600}, {"hdt", -9*3600}, {"yst", -9*3600},
+ {"ahst",-10*3600},{"cat",-10*3600}, {"hast",-10*3600},{"hst",-10*3600},
+ {"nt", -11*3600},
+ {"idlw",-12*3600},
+ {"bst", 1*3600}, {"cet", 1*3600}, {"fwt", 1*3600}, {"met", 1*3600},
+ {"mewt", 1*3600}, {"mez", 1*3600}, {"swt", 1*3600}, {"wat", 1*3600},
+ {"west", 1*3600},
+ {"cest", 2*3600}, {"eet", 2*3600}, {"fst", 2*3600}, {"mest", 2*3600},
+ {"mesz", 2*3600}, {"sast", 2*3600}, {"sst", 2*3600},
+ {"bt", 3*3600}, {"eat", 3*3600}, {"eest", 3*3600}, {"msk", 3*3600},
+ {"msd", 4*3600}, {"zp4", 4*3600},
+ {"zp5", 5*3600}, {"ist", (5*3600+1800)},
+ {"zp6", 6*3600},
+ {"wast", 7*3600},
+ {"cct", 8*3600}, {"sgt", 8*3600}, {"wadt", 8*3600},
+ {"jst", 9*3600}, {"kst", 9*3600},
+ {"east",10*3600}, {"gst", 10*3600},
+ {"eadt",11*3600},
+ {"idle",12*3600}, {"nzst",12*3600}, {"nzt", 12*3600},
+ {"nzdt",13*3600},
+
+ {"afghanistan", 16200}, {"alaskan", -32400},
+ {"arab", 10800}, {"arabian", 14400},
+ {"arabic", 10800}, {"atlantic", -14400},
+ {"aus central", 34200}, {"aus eastern", 36000},
+ {"azores", -3600}, {"canada central", -21600},
+ {"cape verde", -3600}, {"caucasus", 14400},
+ {"cen. australia", 34200}, {"central america", -21600},
+ {"central asia", 21600}, {"central europe", 3600},
+ {"central european", 3600}, {"central pacific", 39600},
+ {"central", -21600}, {"china", 28800},
+ {"dateline", -43200}, {"e. africa", 10800},
+ {"e. australia", 36000}, {"e. europe", 7200},
+ {"e. south america", -10800}, {"eastern", -18000},
+ {"egypt", 7200}, {"ekaterinburg", 18000},
+ {"fiji", 43200}, {"fle", 7200},
+ {"greenland", -10800}, {"greenwich", 0},
+ {"gtb", 7200}, {"hawaiian", -36000},
+ {"india", 19800}, {"iran", 12600},
+ {"jerusalem", 7200}, {"korea", 32400},
+ {"mexico", -21600}, {"mid-atlantic", -7200},
+ {"mountain", -25200}, {"myanmar", 23400},
+ {"n. central asia", 21600}, {"nepal", 20700},
+ {"new zealand", 43200}, {"newfoundland", -12600},
+ {"north asia east", 28800}, {"north asia", 25200},
+ {"pacific sa", -14400}, {"pacific", -28800},
+ {"romance", 3600}, {"russian", 10800},
+ {"sa eastern", -10800}, {"sa pacific", -18000},
+ {"sa western", -14400}, {"samoa", -39600},
+ {"se asia", 25200}, {"malay peninsula", 28800},
+ {"south africa", 7200}, {"sri lanka", 21600},
+ {"taipei", 28800}, {"tasmania", 36000},
+ {"tokyo", 32400}, {"tonga", 46800},
+ {"us eastern", -18000}, {"us mountain", -25200},
+ {"vladivostok", 36000}, {"w. australia", 28800},
+ {"w. central africa", 3600}, {"w. europe", 3600},
+ {"west asia", 18000}, {"west pacific", 36000},
+ {"yakutsk", 32400}
+};
+
+VALUE
+date_zone_to_diff(VALUE str)
+{
+ VALUE offset = Qnil;
+
+ long l, i;
+ char *s, *dest, *d;
+ int sp = 1;
+
+ l = RSTRING_LEN(str);
+ s = RSTRING_PTR(str);
+
+ dest = d = ALLOCA_N(char, l + 1);
+
+ for (i = 0; i < l; i++) {
+ if (isspace((unsigned char)s[i]) || s[i] == '\0') {
+ if (!sp)
+ *d++ = ' ';
+ sp = 1;
+ }
+ else {
+ if (isalpha((unsigned char)s[i]))
+ *d++ = tolower((unsigned char)s[i]);
+ else
+ *d++ = s[i];
+ sp = 0;
+ }
+ }
+ if (d > dest) {
+ if (*(d - 1) == ' ')
+ --d;
+ *d = '\0';
+ }
+ str = rb_str_new2(dest);
+ {
+#define STD " standard time"
+#define DST " daylight time"
+ char *ss, *ds;
+ long sl, dl;
+ int dst = 0;
+
+ sl = RSTRING_LEN(str) - (sizeof STD - 1);
+ ss = RSTRING_PTR(str) + sl;
+ dl = RSTRING_LEN(str) - (sizeof DST - 1);
+ ds = RSTRING_PTR(str) + dl;
+
+ if (sl >= 0 && strcmp(ss, STD) == 0) {
+ str = rb_str_new(RSTRING_PTR(str), sl);
+ }
+ else if (dl >= 0 && strcmp(ds, DST) == 0) {
+ str = rb_str_new(RSTRING_PTR(str), dl);
+ dst = 1;
+ }
+#undef STD
+#undef DST
+ else {
+#define DST " dst"
+ char *ds;
+ long dl;
+
+ dl = RSTRING_LEN(str) - (sizeof DST - 1);
+ ds = RSTRING_PTR(str) + dl;
+
+ if (dl >= 0 && strcmp(ds, DST) == 0) {
+ str = rb_str_new(RSTRING_PTR(str), dl);
+ dst = 1;
+ }
+#undef DST
+ }
+ {
+ static VALUE zones = Qnil;
+
+ if (NIL_P(zones)) {
+ int i;
+
+ zones = rb_hash_new();
+ rb_gc_register_mark_object(zones);
+ for (i = 0; i < (int)sizeof_array(zones_source); i++) {
+ VALUE name = rb_str_new2(zones_source[i].name);
+ VALUE offset = INT2FIX(zones_source[i].offset);
+ rb_hash_aset(zones, name, offset);
+ }
+ }
+
+ offset = f_aref(zones, str);
+ if (!NIL_P(offset)) {
+ if (dst)
+ offset = f_add(offset, INT2FIX(3600));
+ goto ok;
+ }
+ }
+ {
+ char *s, *p;
+ VALUE sign;
+ VALUE hour = Qnil, min = Qnil, sec = Qnil;
+ VALUE str_orig;
+
+ s = RSTRING_PTR(str);
+ str_orig = str;
+
+ if (strncmp(s, "gmt", 3) == 0 ||
+ strncmp(s, "utc", 3) == 0)
+ s += 3;
+ if (issign(*s)) {
+ sign = rb_str_new(s, 1);
+ s++;
+
+ str = rb_str_new2(s);
+
+ if (p = strchr(s, ':')) {
+ hour = rb_str_new(s, p - s);
+ s = ++p;
+ if (p = strchr(s, ':')) {
+ min = rb_str_new(s, p - s);
+ s = ++p;
+ if (p = strchr(s, ':')) {
+ sec = rb_str_new(s, p - s);
+ }
+ else
+ sec = rb_str_new2(s);
+ }
+ else
+ min = rb_str_new2(s);
+ RB_GC_GUARD(str_orig);
+ goto num;
+ }
+ if (strpbrk(RSTRING_PTR(str), ",.")) {
+ char *a, *b;
+
+ a = ALLOCA_N(char, RSTRING_LEN(str) + 1);
+ strcpy(a, RSTRING_PTR(str));
+ b = strpbrk(a, ",.");
+ *b = '\0';
+ b++;
+
+ hour = cstr2num(a);
+ min = f_mul(rb_rational_new2
+ (cstr2num(b),
+ f_expt(INT2FIX(10),
+ LONG2NUM((long)strlen(b)))),
+ INT2FIX(60));
+ goto num;
+ }
+ {
+ const char *cs = RSTRING_PTR(str);
+ long cl = RSTRING_LEN(str);
+
+ if (cl % 2) {
+ if (cl >= 1)
+ hour = rb_str_new(&cs[0], 1);
+ if (cl >= 3)
+ min = rb_str_new(&cs[1], 2);
+ if (cl >= 5)
+ sec = rb_str_new(&cs[3], 2);
+ }
+ else {
+ if (cl >= 2)
+ hour = rb_str_new(&cs[0], 2);
+ if (cl >= 4)
+ min = rb_str_new(&cs[2], 2);
+ if (cl >= 6)
+ sec = rb_str_new(&cs[4], 2);
+ }
+ goto num;
+ }
+ num:
+ if (NIL_P(hour))
+ offset = INT2FIX(0);
+ else {
+ if (RB_TYPE_P(hour, T_STRING))
+ hour = str2num(hour);
+ offset = f_mul(hour, INT2FIX(3600));
+ }
+ if (!NIL_P(min)) {
+ if (RB_TYPE_P(min, T_STRING))
+ min = str2num(min);
+ offset = f_add(offset, f_mul(min, INT2FIX(60)));
+ }
+ if (!NIL_P(sec))
+ offset = f_add(offset, str2num(sec));
+ if (!NIL_P(sign) &&
+ RSTRING_LEN(sign) == 1 &&
+ *RSTRING_PTR(sign) == '-')
+ offset = f_negate(offset);
+ }
+ }
+ }
+ RB_GC_GUARD(str);
+ ok:
+ return offset;
+}
+
+static int
+day_num(VALUE s)
+{
+ int i;
+
+ for (i = 0; i < (int)sizeof_array(abbr_days); i++)
+ if (strncasecmp(abbr_days[i], RSTRING_PTR(s), 3) == 0)
+ break;
+ return i;
+}
+
+static int
+mon_num(VALUE s)
+{
+ int i;
+
+ for (i = 0; i < (int)sizeof_array(abbr_months); i++)
+ if (strncasecmp(abbr_months[i], RSTRING_PTR(s), 3) == 0)
+ break;
+ return i + 1;
+}
+
+static int
+parse_day_cb(VALUE m, VALUE hash)
+{
+ VALUE s;
+
+ s = rb_reg_nth_match(1, m);
+ set_hash("wday", INT2FIX(day_num(s)));
+ return 1;
+}
+
+static int
+parse_day(VALUE str, VALUE hash)
+{
+ static const char pat_source[] =
+#ifndef TIGHT_PARSER
+ "\\b(" ABBR_DAYS ")[^-/\\d\\s]*"
+#else
+ "(" VALID_DAYS ")"
+#endif
+ ;
+ static VALUE pat = Qnil;
+
+ REGCOMP_I(pat);
+#ifndef TIGHT_PARSER
+ SUBS(str, pat, parse_day_cb);
+#else
+ SUBW(str, pat, parse_day_cb);
+#endif
+}
+
+static int
+parse_time2_cb(VALUE m, VALUE hash)
+{
+ VALUE h, min, s, f, p;
+
+ h = rb_reg_nth_match(1, m);
+ h = str2num(h);
+
+ min = rb_reg_nth_match(2, m);
+ if (!NIL_P(min))
+ min = str2num(min);
+
+ s = rb_reg_nth_match(3, m);
+ if (!NIL_P(s))
+ s = str2num(s);
+
+ f = rb_reg_nth_match(4, m);
+
+ if (!NIL_P(f))
+ f = rb_rational_new2(str2num(f),
+ f_expt(INT2FIX(10), LONG2NUM(RSTRING_LEN(f))));
+
+ p = rb_reg_nth_match(5, m);
+
+ if (!NIL_P(p)) {
+ int ih = NUM2INT(h);
+ ih %= 12;
+ if (*RSTRING_PTR(p) == 'P' || *RSTRING_PTR(p) == 'p')
+ ih += 12;
+ h = INT2FIX(ih);
+ }
+
+ set_hash("hour", h);
+ if (!NIL_P(min))
+ set_hash("min", min);
+ if (!NIL_P(s))
+ set_hash("sec", s);
+ if (!NIL_P(f))
+ set_hash("sec_fraction", f);
+
+ return 1;
+}
+
+static int
+parse_time_cb(VALUE m, VALUE hash)
+{
+ static const char pat_source[] =
+ "\\A(\\d+)h?"
+ "(?:\\s*:?\\s*(\\d+)m?"
+ "(?:"
+ "\\s*:?\\s*(\\d+)(?:[,.](\\d+))?s?"
+ ")?"
+ ")?"
+ "(?:\\s*([ap])(?:m\\b|\\.m\\.))?";
+ static VALUE pat = Qnil;
+ VALUE s1, s2;
+
+ s1 = rb_reg_nth_match(1, m);
+ s2 = rb_reg_nth_match(2, m);
+
+ if (!NIL_P(s2))
+ set_hash("zone", s2);
+
+ REGCOMP_I(pat);
+
+ {
+ VALUE m = f_match(pat, s1);
+
+ if (NIL_P(m))
+ return 0;
+ parse_time2_cb(m, hash);
+ }
+
+ return 1;
+}
+
+static int
+parse_time(VALUE str, VALUE hash)
+{
+ static const char pat_source[] =
+ "("
+ "(?:"
+ "\\d+\\s*:\\s*\\d+"
+ "(?:"
+#ifndef TIGHT_PARSER
+ "\\s*:\\s*\\d+(?:[,.]\\d*)?"
+#else
+ "\\s*:\\s*\\d+(?:[,.]\\d+)?"
+#endif
+ ")?"
+ "|"
+ "\\d+\\s*h(?:\\s*\\d+m?(?:\\s*\\d+s?)?)?"
+ ")"
+ "(?:"
+ "\\s*"
+ "[ap](?:m\\b|\\.m\\.)"
+ ")?"
+ "|"
+ "\\d+\\s*[ap](?:m\\b|\\.m\\.)"
+ ")"
+ "(?:"
+ "\\s*"
+ "("
+ "(?:gmt|utc?)?[-+]\\d+(?:[,.:]\\d+(?::\\d+)?)?"
+ "|"
+ "(?-i:[[:alpha:].\\s]+)(?:standard|daylight)\\stime\\b"
+ "|"
+ "(?-i:[[:alpha:]]+)(?:\\sdst)?\\b"
+ ")"
+ ")?";
+ static VALUE pat = Qnil;
+
+ REGCOMP_I(pat);
+#ifndef TIGHT_PARSER
+ SUBS(str, pat, parse_time_cb);
+#else
+ SUBT(str, pat, parse_time_cb);
+#endif
+}
+
+#ifdef TIGHT_PARSER
+static int
+parse_era1_cb(VALUE m, VALUE hash)
+{
+ return 1;
+}
+
+static int
+parse_era1(VALUE str, VALUE hash)
+{
+ static const char pat_source[] =
+ "(a(?:d|\\.d\\.))";
+ static VALUE pat = Qnil;
+
+ REGCOMP_I(pat);
+ SUBA(str, pat, parse_era1_cb);
+}
+
+static int
+parse_era2_cb(VALUE m, VALUE hash)
+{
+ VALUE b;
+
+ b = rb_reg_nth_match(1, m);
+ if (*RSTRING_PTR(b) == 'B' ||
+ *RSTRING_PTR(b) == 'b')
+ set_hash("_bc", Qtrue);
+ return 1;
+}
+
+static int
+parse_era2(VALUE str, VALUE hash)
+{
+ static const char pat_source[] =
+ "(c(?:e|\\.e\\.)|b(?:ce|\\.c\\.e\\.)|b(?:c|\\.c\\.))";
+ static VALUE pat = Qnil;
+
+ REGCOMP_I(pat);
+ SUBB(str, pat, parse_era2_cb);
+}
+
+static int
+parse_era(VALUE str, VALUE hash)
+{
+ if (parse_era1(str, hash)) /* pre */
+ goto ok;
+ if (parse_era2(str, hash)) /* post */
+ goto ok;
+ return 0;
+ ok:
+ return 1;
+}
+#endif
+
+#ifdef TIGHT_PARSER
+static int
+check_year_width(VALUE y)
+{
+ char *s;
+ size_t l;
+
+ s = RSTRING_PTR(y);
+ l = strcspn(s, DECDIGIT);
+ s += l;
+ l = strspn(s, DECDIGIT);
+ if (l != 2)
+ return 0;
+ return 1;
+}
+
+static int
+check_apost(VALUE a, VALUE b, VALUE c)
+{
+ int f = 0;
+
+ if (!NIL_P(a) && *RSTRING_PTR(a) == '\'') {
+ if (!check_year_width(a))
+ return 0;
+ f++;
+ }
+ if (!NIL_P(b) && *RSTRING_PTR(b) == '\'') {
+ if (!check_year_width(b))
+ return 0;
+ if (!NIL_P(c))
+ return 0;
+ f++;
+ }
+ if (!NIL_P(c) && *RSTRING_PTR(c) == '\'') {
+ if (!check_year_width(c))
+ return 0;
+ f++;
+ }
+ if (f > 1)
+ return 0;
+ return 1;
+}
+#endif
+
+static int
+parse_eu_cb(VALUE m, VALUE hash)
+{
+#ifndef TIGHT_PARSER
+ VALUE y, mon, d, b;
+
+ d = rb_reg_nth_match(1, m);
+ mon = rb_reg_nth_match(2, m);
+ b = rb_reg_nth_match(3, m);
+ y = rb_reg_nth_match(4, m);
+
+ mon = INT2FIX(mon_num(mon));
+
+ s3e(hash, y, mon, d, !NIL_P(b) &&
+ (*RSTRING_PTR(b) == 'B' ||
+ *RSTRING_PTR(b) == 'b'));
+#else
+ VALUE y, mon, d;
+
+ d = rb_reg_nth_match(1, m);
+ mon = rb_reg_nth_match(2, m);
+ y = rb_reg_nth_match(3, m);
+
+ if (!check_apost(d, mon, y))
+ return 0;
+
+ mon = INT2FIX(mon_num(mon));
+
+ s3e(hash, y, mon, d, 0);
+#endif
+ return 1;
+}
+
+static int
+parse_eu(VALUE str, VALUE hash)
+{
+ static const char pat_source[] =
+#ifdef TIGHT_PARSER
+ BOS
+ FPW_COM FPT_COM
+#endif
+#ifndef TIGHT_PARSER
+ "('?\\d+)[^-\\d\\s]*"
+#else
+ "(\\d+)(?:(?:st|nd|rd|th)\\b)?"
+#endif
+ "\\s*"
+#ifndef TIGHT_PARSER
+ "(" ABBR_MONTHS ")[^-\\d\\s']*"
+#else
+ "(" VALID_MONTHS ")"
+#endif
+ "(?:"
+ "\\s*"
+#ifndef TIGHT_PARSER
+ "(c(?:e|\\.e\\.)|b(?:ce|\\.c\\.e\\.)|a(?:d|\\.d\\.)|b(?:c|\\.c\\.))?"
+ "\\s*"
+ "('?-?\\d+(?:(?:st|nd|rd|th)\\b)?)"
+#else
+ "(?:" FPA ")?"
+ "\\s*"
+ "([-']?\\d+)"
+ "\\s*"
+ "(?:" FPA "|" FPB ")?"
+#endif
+ ")?"
+#ifdef TIGHT_PARSER
+ COM_FPT COM_FPW
+ EOS
+#endif
+ ;
+ static VALUE pat = Qnil;
+
+ REGCOMP_I(pat);
+ SUBS(str, pat, parse_eu_cb);
+}
+
+static int
+parse_us_cb(VALUE m, VALUE hash)
+{
+#ifndef TIGHT_PARSER
+ VALUE y, mon, d, b;
+
+ mon = rb_reg_nth_match(1, m);
+ d = rb_reg_nth_match(2, m);
+
+ b = rb_reg_nth_match(3, m);
+ y = rb_reg_nth_match(4, m);
+
+ mon = INT2FIX(mon_num(mon));
+
+ s3e(hash, y, mon, d, !NIL_P(b) &&
+ (*RSTRING_PTR(b) == 'B' ||
+ *RSTRING_PTR(b) == 'b'));
+#else
+ VALUE y, mon, d;
+
+ mon = rb_reg_nth_match(1, m);
+ d = rb_reg_nth_match(2, m);
+ y = rb_reg_nth_match(3, m);
+
+ if (!check_apost(mon, d, y))
+ return 0;
+
+ mon = INT2FIX(mon_num(mon));
+
+ s3e(hash, y, mon, d, 0);
+#endif
+ return 1;
+}
+
+static int
+parse_us(VALUE str, VALUE hash)
+{
+ static const char pat_source[] =
+#ifdef TIGHT_PARSER
+ BOS
+ FPW_COM FPT_COM
+#endif
+#ifndef TIGHT_PARSER
+ "\\b(" ABBR_MONTHS ")[^-\\d\\s']*"
+#else
+ "\\b(" VALID_MONTHS ")"
+#endif
+ "\\s*"
+#ifndef TIGHT_PARSER
+ "('?\\d+)[^-\\d\\s']*"
+#else
+ "('?\\d+)(?:(?:st|nd|rd|th)\\b)?"
+ COM_FPT
+#endif
+ "(?:"
+ "\\s*,?"
+ "\\s*"
+#ifndef TIGHT_PARSER
+ "(c(?:e|\\.e\\.)|b(?:ce|\\.c\\.e\\.)|a(?:d|\\.d\\.)|b(?:c|\\.c\\.))?"
+ "\\s*"
+ "('?-?\\d+)"
+#else
+ "(?:" FPA ")?"
+ "\\s*"
+ "([-']?\\d+)"
+ "\\s*"
+ "(?:" FPA "|" FPB ")?"
+#endif
+ ")?"
+#ifdef TIGHT_PARSER
+ COM_FPT COM_FPW
+ EOS
+#endif
+ ;
+ static VALUE pat = Qnil;
+
+ REGCOMP_I(pat);
+ SUBS(str, pat, parse_us_cb);
+}
+
+static int
+parse_iso_cb(VALUE m, VALUE hash)
+{
+ VALUE y, mon, d;
+
+ y = rb_reg_nth_match(1, m);
+ mon = rb_reg_nth_match(2, m);
+ d = rb_reg_nth_match(3, m);
+
+#ifdef TIGHT_PARSER
+ if (!check_apost(y, mon, d))
+ return 0;
+#endif
+
+ s3e(hash, y, mon, d, 0);
+ return 1;
+}
+
+static int
+parse_iso(VALUE str, VALUE hash)
+{
+ static const char pat_source[] =
+#ifndef TIGHT_PARSER
+ "('?[-+]?\\d+)-(\\d+)-('?-?\\d+)"
+#else
+ BOS
+ FPW_COM FPT_COM
+ "([-+']?\\d+)-(\\d+)-([-']?\\d+)"
+ TEE_FPT COM_FPW
+ EOS
+#endif
+ ;
+ static VALUE pat = Qnil;
+
+ REGCOMP_0(pat);
+ SUBS(str, pat, parse_iso_cb);
+}
+
+static int
+parse_iso21_cb(VALUE m, VALUE hash)
+{
+ VALUE y, w, d;
+
+ y = rb_reg_nth_match(1, m);
+ w = rb_reg_nth_match(2, m);
+ d = rb_reg_nth_match(3, m);
+
+ if (!NIL_P(y))
+ set_hash("cwyear", str2num(y));
+ set_hash("cweek", str2num(w));
+ if (!NIL_P(d))
+ set_hash("cwday", str2num(d));
+
+ return 1;
+}
+
+static int
+parse_iso21(VALUE str, VALUE hash)
+{
+ static const char pat_source[] =
+#ifndef TIGHT_PARSER
+ "\\b(\\d{2}|\\d{4})?-?w(\\d{2})(?:-?(\\d))?\\b"
+#else
+ BOS
+ FPW_COM FPT_COM
+ "(\\d{2}|\\d{4})?-?w(\\d{2})(?:-?(\\d))?"
+ TEE_FPT COM_FPW
+ EOS
+#endif
+ ;
+ static VALUE pat = Qnil;
+
+ REGCOMP_I(pat);
+ SUBS(str, pat, parse_iso21_cb);
+}
+
+static int
+parse_iso22_cb(VALUE m, VALUE hash)
+{
+ VALUE d;
+
+ d = rb_reg_nth_match(1, m);
+ set_hash("cwday", str2num(d));
+ return 1;
+}
+
+static int
+parse_iso22(VALUE str, VALUE hash)
+{
+ static const char pat_source[] =
+#ifndef TIGHT_PARSER
+ "-w-(\\d)\\b"
+#else
+ BOS
+ FPW_COM FPT_COM
+ "-w-(\\d)"
+ TEE_FPT COM_FPW
+ EOS
+#endif
+ ;
+ static VALUE pat = Qnil;
+
+ REGCOMP_I(pat);
+ SUBS(str, pat, parse_iso22_cb);
+}
+
+static int
+parse_iso23_cb(VALUE m, VALUE hash)
+{
+ VALUE mon, d;
+
+ mon = rb_reg_nth_match(1, m);
+ d = rb_reg_nth_match(2, m);
+
+ if (!NIL_P(mon))
+ set_hash("mon", str2num(mon));
+ set_hash("mday", str2num(d));
+
+ return 1;
+}
+
+static int
+parse_iso23(VALUE str, VALUE hash)
+{
+ static const char pat_source[] =
+#ifndef TIGHT_PARSER
+ "--(\\d{2})?-(\\d{2})\\b"
+#else
+ BOS
+ FPW_COM FPT_COM
+ "--(\\d{2})?-(\\d{2})"
+ TEE_FPT COM_FPW
+ EOS
+#endif
+ ;
+ static VALUE pat = Qnil;
+
+ REGCOMP_0(pat);
+ SUBS(str, pat, parse_iso23_cb);
+}
+
+static int
+parse_iso24_cb(VALUE m, VALUE hash)
+{
+ VALUE mon, d;
+
+ mon = rb_reg_nth_match(1, m);
+ d = rb_reg_nth_match(2, m);
+
+ set_hash("mon", str2num(mon));
+ if (!NIL_P(d))
+ set_hash("mday", str2num(d));
+
+ return 1;
+}
+
+static int
+parse_iso24(VALUE str, VALUE hash)
+{
+ static const char pat_source[] =
+#ifndef TIGHT_PARSER
+ "--(\\d{2})(\\d{2})?\\b"
+#else
+ BOS
+ FPW_COM FPT_COM
+ "--(\\d{2})(\\d{2})?"
+ TEE_FPT COM_FPW
+ EOS
+#endif
+ ;
+ static VALUE pat = Qnil;
+
+ REGCOMP_0(pat);
+ SUBS(str, pat, parse_iso24_cb);
+}
+
+static int
+parse_iso25_cb(VALUE m, VALUE hash)
+{
+ VALUE y, d;
+
+ y = rb_reg_nth_match(1, m);
+ d = rb_reg_nth_match(2, m);
+
+ set_hash("year", str2num(y));
+ set_hash("yday", str2num(d));
+
+ return 1;
+}
+
+static int
+parse_iso25(VALUE str, VALUE hash)
+{
+ static const char pat0_source[] =
+#ifndef TIGHT_PARSER
+ "[,.](\\d{2}|\\d{4})-\\d{3}\\b"
+#else
+ BOS
+ FPW_COM FPT_COM
+ "[,.](\\d{2}|\\d{4})-\\d{3}"
+ TEE_FPT COM_FPW
+ EOS
+#endif
+ ;
+ static VALUE pat0 = Qnil;
+ static const char pat_source[] =
+#ifndef TIGHT_PARSER
+ "\\b(\\d{2}|\\d{4})-(\\d{3})\\b"
+#else
+ BOS
+ FPW_COM FPT_COM
+ "(\\d{2}|\\d{4})-(\\d{3})"
+ TEE_FPT COM_FPW
+ EOS
+#endif
+ ;
+ static VALUE pat = Qnil;
+
+ REGCOMP_0(pat0);
+ REGCOMP_0(pat);
+
+ if (!NIL_P(f_match(pat0, str)))
+ return 0;
+ SUBS(str, pat, parse_iso25_cb);
+}
+
+static int
+parse_iso26_cb(VALUE m, VALUE hash)
+{
+ VALUE d;
+
+ d = rb_reg_nth_match(1, m);
+ set_hash("yday", str2num(d));
+
+ return 1;
+}
+static int
+parse_iso26(VALUE str, VALUE hash)
+{
+ static const char pat0_source[] =
+#ifndef TIGHT_PARSER
+ "\\d-\\d{3}\\b"
+#else
+ BOS
+ FPW_COM FPT_COM
+ "\\d-\\d{3}"
+ TEE_FPT COM_FPW
+ EOS
+#endif
+ ;
+ static VALUE pat0 = Qnil;
+ static const char pat_source[] =
+#ifndef TIGHT_PARSER
+ "\\b-(\\d{3})\\b"
+#else
+ BOS
+ FPW_COM FPT_COM
+ "-(\\d{3})"
+ TEE_FPT COM_FPW
+ EOS
+#endif
+ ;
+ static VALUE pat = Qnil;
+
+ REGCOMP_0(pat0);
+ REGCOMP_0(pat);
+
+ if (!NIL_P(f_match(pat0, str)))
+ return 0;
+ SUBS(str, pat, parse_iso26_cb);
+}
+
+static int
+parse_iso2(VALUE str, VALUE hash)
+{
+ if (parse_iso21(str, hash))
+ goto ok;
+ if (parse_iso22(str, hash))
+ goto ok;
+ if (parse_iso23(str, hash))
+ goto ok;
+ if (parse_iso24(str, hash))
+ goto ok;
+ if (parse_iso25(str, hash))
+ goto ok;
+ if (parse_iso26(str, hash))
+ goto ok;
+ return 0;
+
+ ok:
+ return 1;
+}
+
+static int
+gengo(int c)
+{
+ int e;
+
+ switch (c) {
+ case 'M': case 'm': e = 1867; break;
+ case 'T': case 't': e = 1911; break;
+ case 'S': case 's': e = 1925; break;
+ case 'H': case 'h': e = 1988; break;
+ default: e = 0; break;
+ }
+ return e;
+}
+
+static int
+parse_jis_cb(VALUE m, VALUE hash)
+{
+ VALUE e, y, mon, d;
+ int ep;
+
+ e = rb_reg_nth_match(1, m);
+ y = rb_reg_nth_match(2, m);
+ mon = rb_reg_nth_match(3, m);
+ d = rb_reg_nth_match(4, m);
+
+ ep = gengo(*RSTRING_PTR(e));
+
+ set_hash("year", f_add(str2num(y), INT2FIX(ep)));
+ set_hash("mon", str2num(mon));
+ set_hash("mday", str2num(d));
+
+ return 1;
+}
+
+static int
+parse_jis(VALUE str, VALUE hash)
+{
+ static const char pat_source[] =
+#ifndef TIGHT_PARSER
+ "\\b([mtsh])(\\d+)\\.(\\d+)\\.(\\d+)"
+#else
+ BOS
+ FPW_COM FPT_COM
+ "([mtsh])(\\d+)\\.(\\d+)\\.(\\d+)"
+ TEE_FPT COM_FPW
+ EOS
+#endif
+ ;
+ static VALUE pat = Qnil;
+
+ REGCOMP_I(pat);
+ SUBS(str, pat, parse_jis_cb);
+}
+
+static int
+parse_vms11_cb(VALUE m, VALUE hash)
+{
+ VALUE y, mon, d;
+
+ d = rb_reg_nth_match(1, m);
+ mon = rb_reg_nth_match(2, m);
+ y = rb_reg_nth_match(3, m);
+
+#ifdef TIGHT_PARSER
+ if (!check_apost(d, mon, y))
+ return 0;
+#endif
+
+ mon = INT2FIX(mon_num(mon));
+
+ s3e(hash, y, mon, d, 0);
+ return 1;
+}
+
+static int
+parse_vms11(VALUE str, VALUE hash)
+{
+ static const char pat_source[] =
+#ifndef TIGHT_PARSER
+ "('?-?\\d+)-(" ABBR_MONTHS ")[^-/.]*"
+ "-('?-?\\d+)"
+#else
+ BOS
+ FPW_COM FPT_COM
+ "([-']?\\d+)-(" DOTLESS_VALID_MONTHS ")"
+ "-([-']?\\d+)"
+ COM_FPT COM_FPW
+ EOS
+#endif
+ ;
+ static VALUE pat = Qnil;
+
+ REGCOMP_I(pat);
+ SUBS(str, pat, parse_vms11_cb);
+}
+
+static int
+parse_vms12_cb(VALUE m, VALUE hash)
+{
+ VALUE y, mon, d;
+
+ mon = rb_reg_nth_match(1, m);
+ d = rb_reg_nth_match(2, m);
+ y = rb_reg_nth_match(3, m);
+
+#ifdef TIGHT_PARSER
+ if (!check_apost(mon, d, y))
+ return 0;
+#endif
+
+ mon = INT2FIX(mon_num(mon));
+
+ s3e(hash, y, mon, d, 0);
+ return 1;
+}
+
+static int
+parse_vms12(VALUE str, VALUE hash)
+{
+ static const char pat_source[] =
+#ifndef TIGHT_PARSER
+ "\\b(" ABBR_MONTHS ")[^-/.]*"
+ "-('?-?\\d+)(?:-('?-?\\d+))?"
+#else
+ BOS
+ FPW_COM FPT_COM
+ "(" DOTLESS_VALID_MONTHS ")"
+ "-([-']?\\d+)(?:-([-']?\\d+))?"
+ COM_FPT COM_FPW
+ EOS
+#endif
+ ;
+ static VALUE pat = Qnil;
+
+ REGCOMP_I(pat);
+ SUBS(str, pat, parse_vms12_cb);
+}
+
+static int
+parse_vms(VALUE str, VALUE hash)
+{
+ if (parse_vms11(str, hash))
+ goto ok;
+ if (parse_vms12(str, hash))
+ goto ok;
+ return 0;
+
+ ok:
+ return 1;
+}
+
+static int
+parse_sla_cb(VALUE m, VALUE hash)
+{
+ VALUE y, mon, d;
+
+ y = rb_reg_nth_match(1, m);
+ mon = rb_reg_nth_match(2, m);
+ d = rb_reg_nth_match(3, m);
+
+#ifdef TIGHT_PARSER
+ if (!check_apost(y, mon, d))
+ return 0;
+#endif
+
+ s3e(hash, y, mon, d, 0);
+ return 1;
+}
+
+static int
+parse_sla(VALUE str, VALUE hash)
+{
+ static const char pat_source[] =
+#ifndef TIGHT_PARSER
+ "('?-?\\d+)/\\s*('?\\d+)(?:\\D\\s*('?-?\\d+))?"
+#else
+ BOS
+ FPW_COM FPT_COM
+ "([-']?\\d+)/\\s*('?\\d+)(?:(?:[-/]|\\s+)\\s*([-']?\\d+))?"
+ COM_FPT COM_FPW
+ EOS
+#endif
+ ;
+ static VALUE pat = Qnil;
+
+ REGCOMP_I(pat);
+ SUBS(str, pat, parse_sla_cb);
+}
+
+#ifdef TIGHT_PARSER
+static int
+parse_sla2_cb(VALUE m, VALUE hash)
+{
+ VALUE y, mon, d;
+
+ d = rb_reg_nth_match(1, m);
+ mon = rb_reg_nth_match(2, m);
+ y = rb_reg_nth_match(3, m);
+
+ if (!check_apost(d, mon, y))
+ return 0;
+
+ mon = INT2FIX(mon_num(mon));
+
+ s3e(hash, y, mon, d, 0);
+ return 1;
+}
+
+static int
+parse_sla2(VALUE str, VALUE hash)
+{
+ static const char pat_source[] =
+ BOS
+ FPW_COM FPT_COM
+ "([-']?\\d+)/\\s*(" DOTLESS_VALID_MONTHS ")(?:(?:[-/]|\\s+)\\s*([-']?\\d+))?"
+ COM_FPT COM_FPW
+ EOS
+ ;
+ static VALUE pat = Qnil;
+
+ REGCOMP_I(pat);
+ SUBS(str, pat, parse_sla2_cb);
+}
+
+static int
+parse_sla3_cb(VALUE m, VALUE hash)
+{
+ VALUE y, mon, d;
+
+ mon = rb_reg_nth_match(1, m);
+ d = rb_reg_nth_match(2, m);
+ y = rb_reg_nth_match(3, m);
+
+ if (!check_apost(mon, d, y))
+ return 0;
+
+ mon = INT2FIX(mon_num(mon));
+
+ s3e(hash, y, mon, d, 0);
+ return 1;
+}
+
+static int
+parse_sla3(VALUE str, VALUE hash)
+{
+ static const char pat_source[] =
+ BOS
+ FPW_COM FPT_COM
+ "(" DOTLESS_VALID_MONTHS ")/\\s*([-']?\\d+)(?:(?:[-/]|\\s+)\\s*([-']?\\d+))?"
+ COM_FPT COM_FPW
+ EOS
+ ;
+ static VALUE pat = Qnil;
+
+ REGCOMP_I(pat);
+ SUBS(str, pat, parse_sla3_cb);
+}
+#endif
+
+static int
+parse_dot_cb(VALUE m, VALUE hash)
+{
+ VALUE y, mon, d;
+
+ y = rb_reg_nth_match(1, m);
+ mon = rb_reg_nth_match(2, m);
+ d = rb_reg_nth_match(3, m);
+
+#ifdef TIGHT_PARSER
+ if (!check_apost(y, mon, d))
+ return 0;
+#endif
+
+ s3e(hash, y, mon, d, 0);
+ return 1;
+}
+
+static int
+parse_dot(VALUE str, VALUE hash)
+{
+ static const char pat_source[] =
+#ifndef TIGHT_PARSER
+ "('?-?\\d+)\\.\\s*('?\\d+)\\.\\s*('?-?\\d+)"
+#else
+ BOS
+ FPW_COM FPT_COM
+ "([-']?\\d+)\\.\\s*(\\d+)\\.\\s*([-']?\\d+)"
+ COM_FPT COM_FPW
+ EOS
+#endif
+ ;
+ static VALUE pat = Qnil;
+
+ REGCOMP_I(pat);
+ SUBS(str, pat, parse_dot_cb);
+}
+
+#ifdef TIGHT_PARSER
+static int
+parse_dot2_cb(VALUE m, VALUE hash)
+{
+ VALUE y, mon, d;
+
+ d = rb_reg_nth_match(1, m);
+ mon = rb_reg_nth_match(2, m);
+ y = rb_reg_nth_match(3, m);
+
+ if (!check_apost(d, mon, y))
+ return 0;
+
+ mon = INT2FIX(mon_num(mon));
+
+ s3e(hash, y, mon, d, 0);
+ return 1;
+}
+
+static int
+parse_dot2(VALUE str, VALUE hash)
+{
+ static const char pat_source[] =
+ BOS
+ FPW_COM FPT_COM
+ "([-']?\\d+)\\.\\s*(" DOTLESS_VALID_MONTHS ")(?:(?:[./])\\s*([-']?\\d+))?"
+ COM_FPT COM_FPW
+ EOS
+ ;
+ static VALUE pat = Qnil;
+
+ REGCOMP_I(pat);
+ SUBS(str, pat, parse_dot2_cb);
+}
+
+static int
+parse_dot3_cb(VALUE m, VALUE hash)
+{
+ VALUE y, mon, d;
+
+ mon = rb_reg_nth_match(1, m);
+ d = rb_reg_nth_match(2, m);
+ y = rb_reg_nth_match(3, m);
+
+ if (!check_apost(mon, d, y))
+ return 0;
+
+ mon = INT2FIX(mon_num(mon));
+
+ s3e(hash, y, mon, d, 0);
+ return 1;
+}
+
+static int
+parse_dot3(VALUE str, VALUE hash)
+{
+ static const char pat_source[] =
+ BOS
+ FPW_COM FPT_COM
+ "(" DOTLESS_VALID_MONTHS ")\\.\\s*([-']?\\d+)(?:(?:[./])\\s*([-']?\\d+))?"
+ COM_FPT COM_FPW
+ EOS
+ ;
+ static VALUE pat = Qnil;
+
+ REGCOMP_I(pat);
+ SUBS(str, pat, parse_dot3_cb);
+}
+#endif
+
+static int
+parse_year_cb(VALUE m, VALUE hash)
+{
+ VALUE y;
+
+ y = rb_reg_nth_match(1, m);
+ set_hash("year", str2num(y));
+ return 1;
+}
+
+static int
+parse_year(VALUE str, VALUE hash)
+{
+ static const char pat_source[] =
+#ifndef TIGHT_PARSER
+ "'(\\d+)\\b"
+#else
+ BOS
+ FPW_COM FPT_COM
+ "'(\\d+)"
+ COM_FPT COM_FPW
+ EOS
+#endif
+ ;
+ static VALUE pat = Qnil;
+
+ REGCOMP_0(pat);
+ SUBS(str, pat, parse_year_cb);
+}
+
+static int
+parse_mon_cb(VALUE m, VALUE hash)
+{
+ VALUE mon;
+
+ mon = rb_reg_nth_match(1, m);
+ set_hash("mon", INT2FIX(mon_num(mon)));
+ return 1;
+}
+
+static int
+parse_mon(VALUE str, VALUE hash)
+{
+ static const char pat_source[] =
+#ifndef TIGHT_PARSER
+ "\\b(" ABBR_MONTHS ")\\S*"
+#else
+ BOS
+ FPW_COM FPT_COM
+ "(" VALID_MONTHS ")"
+ COM_FPT COM_FPW
+ EOS
+#endif
+ ;
+ static VALUE pat = Qnil;
+
+ REGCOMP_I(pat);
+ SUBS(str, pat, parse_mon_cb);
+}
+
+static int
+parse_mday_cb(VALUE m, VALUE hash)
+{
+ VALUE d;
+
+ d = rb_reg_nth_match(1, m);
+ set_hash("mday", str2num(d));
+ return 1;
+}
+
+static int
+parse_mday(VALUE str, VALUE hash)
+{
+ static const char pat_source[] =
+#ifndef TIGHT_PARSER
+ "(\\d+)(st|nd|rd|th)\\b"
+#else
+ BOS
+ FPW_COM FPT_COM
+ "(\\d+)(st|nd|rd|th)"
+ COM_FPT COM_FPW
+ EOS
+#endif
+ ;
+ static VALUE pat = Qnil;
+
+ REGCOMP_I(pat);
+ SUBS(str, pat, parse_mday_cb);
+}
+
+static int
+n2i(const char *s, long f, long w)
+{
+ long e, i;
+ int v;
+
+ e = f + w;
+ v = 0;
+ for (i = f; i < e; i++) {
+ v *= 10;
+ v += s[i] - '0';
+ }
+ return v;
+}
+
+static int
+parse_ddd_cb(VALUE m, VALUE hash)
+{
+ VALUE s1, s2, s3, s4, s5;
+ const char *cs2, *cs3, *cs5;
+ long l2, l3, l4, l5;
+
+ s1 = rb_reg_nth_match(1, m);
+ s2 = rb_reg_nth_match(2, m);
+ s3 = rb_reg_nth_match(3, m);
+ s4 = rb_reg_nth_match(4, m);
+ s5 = rb_reg_nth_match(5, m);
+
+ cs2 = RSTRING_PTR(s2);
+ l2 = RSTRING_LEN(s2);
+
+ switch (l2) {
+ case 2:
+ if (NIL_P(s3) && !NIL_P(s4))
+ set_hash("sec", INT2FIX(n2i(cs2, l2-2, 2)));
+ else
+ set_hash("mday", INT2FIX(n2i(cs2, 0, 2)));
+ break;
+ case 4:
+ if (NIL_P(s3) && !NIL_P(s4)) {
+ set_hash("sec", INT2FIX(n2i(cs2, l2-2, 2)));
+ set_hash("min", INT2FIX(n2i(cs2, l2-4, 2)));
+ }
+ else {
+ set_hash("mon", INT2FIX(n2i(cs2, 0, 2)));
+ set_hash("mday", INT2FIX(n2i(cs2, 2, 2)));
+ }
+ break;
+ case 6:
+ if (NIL_P(s3) && !NIL_P(s4)) {
+ set_hash("sec", INT2FIX(n2i(cs2, l2-2, 2)));
+ set_hash("min", INT2FIX(n2i(cs2, l2-4, 2)));
+ set_hash("hour", INT2FIX(n2i(cs2, l2-6, 2)));
+ }
+ else {
+ int y = n2i(cs2, 0, 2);
+ if (!NIL_P(s1) && *RSTRING_PTR(s1) == '-')
+ y = -y;
+ set_hash("year", INT2FIX(y));
+ set_hash("mon", INT2FIX(n2i(cs2, 2, 2)));
+ set_hash("mday", INT2FIX(n2i(cs2, 4, 2)));
+ }
+ break;
+ case 8:
+ case 10:
+ case 12:
+ case 14:
+ if (NIL_P(s3) && !NIL_P(s4)) {
+ set_hash("sec", INT2FIX(n2i(cs2, l2-2, 2)));
+ set_hash("min", INT2FIX(n2i(cs2, l2-4, 2)));
+ set_hash("hour", INT2FIX(n2i(cs2, l2-6, 2)));
+ set_hash("mday", INT2FIX(n2i(cs2, l2-8, 2)));
+ if (l2 >= 10)
+ set_hash("mon", INT2FIX(n2i(cs2, l2-10, 2)));
+ if (l2 == 12) {
+ int y = n2i(cs2, l2-12, 2);
+ if (!NIL_P(s1) && *RSTRING_PTR(s1) == '-')
+ y = -y;
+ set_hash("year", INT2FIX(y));
+ }
+ if (l2 == 14) {
+ int y = n2i(cs2, l2-14, 4);
+ if (!NIL_P(s1) && *RSTRING_PTR(s1) == '-')
+ y = -y;
+ set_hash("year", INT2FIX(y));
+ set_hash("_comp", Qfalse);
+ }
+ }
+ else {
+ int y = n2i(cs2, 0, 4);
+ if (!NIL_P(s1) && *RSTRING_PTR(s1) == '-')
+ y = -y;
+ set_hash("year", INT2FIX(y));
+ set_hash("mon", INT2FIX(n2i(cs2, 4, 2)));
+ set_hash("mday", INT2FIX(n2i(cs2, 6, 2)));
+ if (l2 >= 10)
+ set_hash("hour", INT2FIX(n2i(cs2, 8, 2)));
+ if (l2 >= 12)
+ set_hash("min", INT2FIX(n2i(cs2, 10, 2)));
+ if (l2 >= 14)
+ set_hash("sec", INT2FIX(n2i(cs2, 12, 2)));
+ set_hash("_comp", Qfalse);
+ }
+ break;
+ case 3:
+ if (NIL_P(s3) && !NIL_P(s4)) {
+ set_hash("sec", INT2FIX(n2i(cs2, l2-2, 2)));
+ set_hash("min", INT2FIX(n2i(cs2, l2-3, 1)));
+ }
+ else
+ set_hash("yday", INT2FIX(n2i(cs2, 0, 3)));
+ break;
+ case 5:
+ if (NIL_P(s3) && !NIL_P(s4)) {
+ set_hash("sec", INT2FIX(n2i(cs2, l2-2, 2)));
+ set_hash("min", INT2FIX(n2i(cs2, l2-4, 2)));
+ set_hash("hour", INT2FIX(n2i(cs2, l2-5, 1)));
+ }
+ else {
+ int y = n2i(cs2, 0, 2);
+ if (!NIL_P(s1) && *RSTRING_PTR(s1) == '-')
+ y = -y;
+ set_hash("year", INT2FIX(y));
+ set_hash("yday", INT2FIX(n2i(cs2, 2, 3)));
+ }
+ break;
+ case 7:
+ if (NIL_P(s3) && !NIL_P(s4)) {
+ set_hash("sec", INT2FIX(n2i(cs2, l2-2, 2)));
+ set_hash("min", INT2FIX(n2i(cs2, l2-4, 2)));
+ set_hash("hour", INT2FIX(n2i(cs2, l2-6, 2)));
+ set_hash("mday", INT2FIX(n2i(cs2, l2-7, 1)));
+ }
+ else {
+ int y = n2i(cs2, 0, 4);
+ if (!NIL_P(s1) && *RSTRING_PTR(s1) == '-')
+ y = -y;
+ set_hash("year", INT2FIX(y));
+ set_hash("yday", INT2FIX(n2i(cs2, 4, 3)));
+ }
+ break;
+ }
+ RB_GC_GUARD(s2);
+ if (!NIL_P(s3)) {
+ cs3 = RSTRING_PTR(s3);
+ l3 = RSTRING_LEN(s3);
+
+ if (!NIL_P(s4)) {
+ switch (l3) {
+ case 2:
+ case 4:
+ case 6:
+ set_hash("sec", INT2FIX(n2i(cs3, l3-2, 2)));
+ if (l3 >= 4)
+ set_hash("min", INT2FIX(n2i(cs3, l3-4, 2)));
+ if (l3 >= 6)
+ set_hash("hour", INT2FIX(n2i(cs3, l3-6, 2)));
+ break;
+ }
+ }
+ else {
+ switch (l3) {
+ case 2:
+ case 4:
+ case 6:
+ set_hash("hour", INT2FIX(n2i(cs3, 0, 2)));
+ if (l3 >= 4)
+ set_hash("min", INT2FIX(n2i(cs3, 2, 2)));
+ if (l3 >= 6)
+ set_hash("sec", INT2FIX(n2i(cs3, 4, 2)));
+ break;
+ }
+ }
+ RB_GC_GUARD(s3);
+ }
+ if (!NIL_P(s4)) {
+ l4 = RSTRING_LEN(s4);
+
+ set_hash("sec_fraction",
+ rb_rational_new2(str2num(s4),
+ f_expt(INT2FIX(10), LONG2NUM(l4))));
+ }
+ if (!NIL_P(s5)) {
+ cs5 = RSTRING_PTR(s5);
+ l5 = RSTRING_LEN(s5);
+
+ set_hash("zone", s5);
+
+ if (*cs5 == '[') {
+ char *buf = ALLOCA_N(char, l5 + 1);
+ char *s1, *s2, *s3;
+ VALUE zone;
+
+ memcpy(buf, cs5, l5);
+ buf[l5 - 1] = '\0';
+
+ s1 = buf + 1;
+ s2 = strchr(buf, ':');
+ if (s2) {
+ *s2 = '\0';
+ s2++;
+ }
+ if (s2)
+ s3 = s2;
+ else
+ s3 = s1;
+ zone = rb_str_new2(s3);
+ set_hash("zone", zone);
+ if (isdigit((unsigned char)*s1))
+ *--s1 = '+';
+ set_hash("offset", date_zone_to_diff(rb_str_new2(s1)));
+ }
+ RB_GC_GUARD(s5);
+ }
+
+ return 1;
+}
+
+static int
+parse_ddd(VALUE str, VALUE hash)
+{
+ static const char pat_source[] =
+#ifdef TIGHT_PARSER
+ BOS
+#endif
+ "([-+]?)(\\d{2,14})"
+ "(?:"
+ "\\s*"
+ "t?"
+ "\\s*"
+ "(\\d{2,6})?(?:[,.](\\d*))?"
+ ")?"
+ "(?:"
+ "\\s*"
+ "("
+ "z\\b"
+ "|"
+ "[-+]\\d{1,4}\\b"
+ "|"
+ "\\[[-+]?\\d[^\\]]*\\]"
+ ")"
+ ")?"
+#ifdef TIGHT_PARSER
+ EOS
+#endif
+ ;
+ static VALUE pat = Qnil;
+
+ REGCOMP_I(pat);
+ SUBS(str, pat, parse_ddd_cb);
+}
+
+#ifndef TIGHT_PARSER
+static int
+parse_bc_cb(VALUE m, VALUE hash)
+{
+ set_hash("_bc", Qtrue);
+ return 1;
+}
+
+static int
+parse_bc(VALUE str, VALUE hash)
+{
+ static const char pat_source[] =
+ "\\b(bc\\b|bce\\b|b\\.c\\.|b\\.c\\.e\\.)";
+ static VALUE pat = Qnil;
+
+ REGCOMP_I(pat);
+ SUBS(str, pat, parse_bc_cb);
+}
+
+static int
+parse_frag_cb(VALUE m, VALUE hash)
+{
+ VALUE s, n;
+
+ s = rb_reg_nth_match(1, m);
+
+ if (!NIL_P(ref_hash("hour")) && NIL_P(ref_hash("mday"))) {
+ n = str2num(s);
+ if (f_ge_p(n, INT2FIX(1)) &&
+ f_le_p(n, INT2FIX(31)))
+ set_hash("mday", n);
+ }
+ if (!NIL_P(ref_hash("mday")) && NIL_P(ref_hash("hour"))) {
+ n = str2num(s);
+ if (f_ge_p(n, INT2FIX(0)) &&
+ f_le_p(n, INT2FIX(24)))
+ set_hash("hour", n);
+ }
+
+ return 1;
+}
+
+static int
+parse_frag(VALUE str, VALUE hash)
+{
+ static const char pat_source[] = "\\A\\s*(\\d{1,2})\\s*\\z";
+ static VALUE pat = Qnil;
+
+ REGCOMP_I(pat);
+ SUBS(str, pat, parse_frag_cb);
+}
+#endif
+
+#ifdef TIGHT_PARSER
+static int
+parse_dummy_cb(VALUE m, VALUE hash)
+{
+ return 1;
+}
+
+static int
+parse_wday_only(VALUE str, VALUE hash)
+{
+ static const char pat_source[] = "\\A\\s*" FPW "\\s*\\z";
+ static VALUE pat = Qnil;
+
+ REGCOMP_0(pat);
+ SUBS(str, pat, parse_dummy_cb);
+}
+
+static int
+parse_time_only(VALUE str, VALUE hash)
+{
+ static const char pat_source[] = "\\A\\s*" FPT "\\s*\\z";
+ static VALUE pat = Qnil;
+
+ REGCOMP_0(pat);
+ SUBS(str, pat, parse_dummy_cb);
+}
+
+static int
+parse_wday_and_time(VALUE str, VALUE hash)
+{
+ static const char pat_source[] = "\\A\\s*(" FPW "\\s+" FPT "|" FPT "\\s+" FPW ")\\s*\\z";
+ static VALUE pat = Qnil;
+
+ REGCOMP_0(pat);
+ SUBS(str, pat, parse_dummy_cb);
+}
+
+static unsigned
+have_invalid_char_p(VALUE s)
+{
+ long i;
+
+ for (i = 0; i < RSTRING_LEN(s); i++)
+ if (iscntrl((unsigned char)RSTRING_PTR(s)[i]) &&
+ !isspace((unsigned char)RSTRING_PTR(s)[i]))
+ return 1;
+ return 0;
+}
+#endif
+
+#define HAVE_ALPHA (1<<0)
+#define HAVE_DIGIT (1<<1)
+#define HAVE_DASH (1<<2)
+#define HAVE_DOT (1<<3)
+#define HAVE_SLASH (1<<4)
+
+static unsigned
+check_class(VALUE s)
+{
+ unsigned flags;
+ long i;
+
+ flags = 0;
+ for (i = 0; i < RSTRING_LEN(s); i++) {
+ if (isalpha((unsigned char)RSTRING_PTR(s)[i]))
+ flags |= HAVE_ALPHA;
+ if (isdigit((unsigned char)RSTRING_PTR(s)[i]))
+ flags |= HAVE_DIGIT;
+ if (RSTRING_PTR(s)[i] == '-')
+ flags |= HAVE_DASH;
+ if (RSTRING_PTR(s)[i] == '.')
+ flags |= HAVE_DOT;
+ if (RSTRING_PTR(s)[i] == '/')
+ flags |= HAVE_SLASH;
+ }
+ return flags;
+}
+
+#define HAVE_ELEM_P(x) ((check_class(str) & (x)) == (x))
+
+#ifdef TIGHT_PARSER
+#define PARSER_ERROR return rb_hash_new()
+#endif
+
+VALUE
+date__parse(VALUE str, VALUE comp)
+{
+ VALUE backref, hash;
+
+#ifdef TIGHT_PARSER
+ if (have_invalid_char_p(str))
+ PARSER_ERROR;
+#endif
+
+ backref = rb_backref_get();
+ rb_match_busy(backref);
+
+ {
+ static const char pat_source[] =
+#ifndef TIGHT_PARSER
+ "[^-+',./:@[:alnum:]\\[\\]]+"
+#else
+ "[^[:graph:]]+"
+#endif
+ ;
+ static VALUE pat = Qnil;
+
+ REGCOMP_0(pat);
+ str = rb_str_dup(str);
+ f_gsub_bang(str, pat, asp_string());
+ }
+
+ hash = rb_hash_new();
+ set_hash("_comp", comp);
+
+ if (HAVE_ELEM_P(HAVE_ALPHA))
+ parse_day(str, hash);
+ if (HAVE_ELEM_P(HAVE_DIGIT))
+ parse_time(str, hash);
+
+#ifdef TIGHT_PARSER
+ if (HAVE_ELEM_P(HAVE_ALPHA))
+ parse_era(str, hash);
+#endif
+
+ if (HAVE_ELEM_P(HAVE_ALPHA|HAVE_DIGIT)) {
+ if (parse_eu(str, hash))
+ goto ok;
+ if (parse_us(str, hash))
+ goto ok;
+ }
+ if (HAVE_ELEM_P(HAVE_DIGIT|HAVE_DASH))
+ if (parse_iso(str, hash))
+ goto ok;
+ if (HAVE_ELEM_P(HAVE_DIGIT|HAVE_DOT))
+ if (parse_jis(str, hash))
+ goto ok;
+ if (HAVE_ELEM_P(HAVE_ALPHA|HAVE_DIGIT|HAVE_DASH))
+ if (parse_vms(str, hash))
+ goto ok;
+ if (HAVE_ELEM_P(HAVE_DIGIT|HAVE_SLASH))
+ if (parse_sla(str, hash))
+ goto ok;
+#ifdef TIGHT_PARSER
+ if (HAVE_ELEM_P(HAVE_ALPHA|HAVE_DIGIT|HAVE_SLASH)) {
+ if (parse_sla2(str, hash))
+ goto ok;
+ if (parse_sla3(str, hash))
+ goto ok;
+ }
+#endif
+ if (HAVE_ELEM_P(HAVE_DIGIT|HAVE_DOT))
+ if (parse_dot(str, hash))
+ goto ok;
+#ifdef TIGHT_PARSER
+ if (HAVE_ELEM_P(HAVE_ALPHA|HAVE_DIGIT|HAVE_DOT)) {
+ if (parse_dot2(str, hash))
+ goto ok;
+ if (parse_dot3(str, hash))
+ goto ok;
+ }
+#endif
+ if (HAVE_ELEM_P(HAVE_DIGIT))
+ if (parse_iso2(str, hash))
+ goto ok;
+ if (HAVE_ELEM_P(HAVE_DIGIT))
+ if (parse_year(str, hash))
+ goto ok;
+ if (HAVE_ELEM_P(HAVE_ALPHA))
+ if (parse_mon(str, hash))
+ goto ok;
+ if (HAVE_ELEM_P(HAVE_DIGIT))
+ if (parse_mday(str, hash))
+ goto ok;
+ if (HAVE_ELEM_P(HAVE_DIGIT))
+ if (parse_ddd(str, hash))
+ goto ok;
+
+#ifdef TIGHT_PARSER
+ if (parse_wday_only(str, hash))
+ goto ok;
+ if (parse_time_only(str, hash))
+ goto ok;
+ if (parse_wday_and_time(str, hash))
+ goto ok;
+
+ PARSER_ERROR; /* not found */
+#endif
+
+ ok:
+#ifndef TIGHT_PARSER
+ if (HAVE_ELEM_P(HAVE_ALPHA))
+ parse_bc(str, hash);
+ if (HAVE_ELEM_P(HAVE_DIGIT))
+ parse_frag(str, hash);
+#endif
+
+ {
+ if (RTEST(ref_hash("_bc"))) {
+ VALUE y;
+
+ y = ref_hash("cwyear");
+ if (!NIL_P(y)) {
+ y = f_add(f_negate(y), INT2FIX(1));
+ set_hash("cwyear", y);
+ }
+ y = ref_hash("year");
+ if (!NIL_P(y)) {
+ y = f_add(f_negate(y), INT2FIX(1));
+ set_hash("year", y);
+ }
+ }
+
+ if (RTEST(ref_hash("_comp"))) {
+ VALUE y;
+
+ y = ref_hash("cwyear");
+ if (!NIL_P(y))
+ if (f_ge_p(y, INT2FIX(0)) && f_le_p(y, INT2FIX(99))) {
+ if (f_ge_p(y, INT2FIX(69)))
+ set_hash("cwyear", f_add(y, INT2FIX(1900)));
+ else
+ set_hash("cwyear", f_add(y, INT2FIX(2000)));
+ }
+ y = ref_hash("year");
+ if (!NIL_P(y))
+ if (f_ge_p(y, INT2FIX(0)) && f_le_p(y, INT2FIX(99))) {
+ if (f_ge_p(y, INT2FIX(69)))
+ set_hash("year", f_add(y, INT2FIX(1900)));
+ else
+ set_hash("year", f_add(y, INT2FIX(2000)));
+ }
+ }
+
+ }
+
+ del_hash("_bc");
+ del_hash("_comp");
+
+ {
+ VALUE zone = ref_hash("zone");
+ if (!NIL_P(zone) && NIL_P(ref_hash("offset")))
+ set_hash("offset", date_zone_to_diff(zone));
+ }
+
+ rb_backref_set(backref);
+
+ return hash;
+}
+
+static VALUE
+comp_year69(VALUE y)
+{
+ if (f_ge_p(y, INT2FIX(69)))
+ return f_add(y, INT2FIX(1900));
+ return f_add(y, INT2FIX(2000));
+}
+
+static VALUE
+comp_year50(VALUE y)
+{
+ if (f_ge_p(y, INT2FIX(50)))
+ return f_add(y, INT2FIX(1900));
+ return f_add(y, INT2FIX(2000));
+}
+
+static VALUE
+sec_fraction(VALUE f)
+{
+ return rb_rational_new2(str2num(f),
+ f_expt(INT2FIX(10),
+ LONG2NUM(RSTRING_LEN(f))));
+}
+
+#define SNUM 14
+
+static int
+iso8601_ext_datetime_cb(VALUE m, VALUE hash)
+{
+ VALUE s[SNUM + 1], y;
+
+ {
+ int i;
+ s[0] = Qnil;
+ for (i = 1; i <= SNUM; i++)
+ s[i] = rb_reg_nth_match(i, m);
+ }
+
+ if (!NIL_P(s[3])) {
+ set_hash("mday", str2num(s[3]));
+ if (strcmp(RSTRING_PTR(s[1]), "-") != 0) {
+ y = str2num(s[1]);
+ if (RSTRING_LEN(s[1]) < 4)
+ y = comp_year69(y);
+ set_hash("year", y);
+ }
+ if (NIL_P(s[2])) {
+ if (strcmp(RSTRING_PTR(s[1]), "-") != 0)
+ return 0;
+ }
+ else
+ set_hash("mon", str2num(s[2]));
+ }
+ else if (!NIL_P(s[5])) {
+ set_hash("yday", str2num(s[5]));
+ if (!NIL_P(s[4])) {
+ y = str2num(s[4]);
+ if (RSTRING_LEN(s[4]) < 4)
+ y = comp_year69(y);
+ set_hash("year", y);
+ }
+ }
+ else if (!NIL_P(s[8])) {
+ set_hash("cweek", str2num(s[7]));
+ set_hash("cwday", str2num(s[8]));
+ if (!NIL_P(s[6])) {
+ y = str2num(s[6]);
+ if (RSTRING_LEN(s[6]) < 4)
+ y = comp_year69(y);
+ set_hash("cwyear", y);
+ }
+ }
+ else if (!NIL_P(s[9])) {
+ set_hash("cwday", str2num(s[9]));
+ }
+ if (!NIL_P(s[10])) {
+ set_hash("hour", str2num(s[10]));
+ set_hash("min", str2num(s[11]));
+ if (!NIL_P(s[12]))
+ set_hash("sec", str2num(s[12]));
+ }
+ if (!NIL_P(s[13])) {
+ set_hash("sec_fraction", sec_fraction(s[13]));
+ }
+ if (!NIL_P(s[14])) {
+ set_hash("zone", s[14]);
+ set_hash("offset", date_zone_to_diff(s[14]));
+ }
+
+ return 1;
+}
+
+static int
+iso8601_ext_datetime(VALUE str, VALUE hash)
+{
+ static const char pat_source[] =
+ "\\A\\s*(?:([-+]?\\d{2,}|-)-(\\d{2})?-(\\d{2})|"
+ "([-+]?\\d{2,})?-(\\d{3})|"
+ "(\\d{4}|\\d{2})?-w(\\d{2})-(\\d)|"
+ "-w-(\\d))"
+ "(?:t"
+ "(\\d{2}):(\\d{2})(?::(\\d{2})(?:[,.](\\d+))?)?"
+ "(z|[-+]\\d{2}(?::?\\d{2})?)?)?\\s*\\z";
+ static VALUE pat = Qnil;
+
+ REGCOMP_I(pat);
+ MATCH(str, pat, iso8601_ext_datetime_cb);
+}
+
+#undef SNUM
+#define SNUM 17
+
+static int
+iso8601_bas_datetime_cb(VALUE m, VALUE hash)
+{
+ VALUE s[SNUM + 1], y;
+
+ {
+ int i;
+ s[0] = Qnil;
+ for (i = 1; i <= SNUM; i++)
+ s[i] = rb_reg_nth_match(i, m);
+ }
+
+ if (!NIL_P(s[3])) {
+ set_hash("mday", str2num(s[3]));
+ if (strcmp(RSTRING_PTR(s[1]), "--") != 0) {
+ y = str2num(s[1]);
+ if (RSTRING_LEN(s[1]) < 4)
+ y = comp_year69(y);
+ set_hash("year", y);
+ }
+ if (*RSTRING_PTR(s[2]) == '-') {
+ if (strcmp(RSTRING_PTR(s[1]), "--") != 0)
+ return 0;
+ }
+ else
+ set_hash("mon", str2num(s[2]));
+ }
+ else if (!NIL_P(s[5])) {
+ set_hash("yday", str2num(s[5]));
+ y = str2num(s[4]);
+ if (RSTRING_LEN(s[4]) < 4)
+ y = comp_year69(y);
+ set_hash("year", y);
+ }
+ else if (!NIL_P(s[6])) {
+ set_hash("yday", str2num(s[6]));
+ }
+ else if (!NIL_P(s[9])) {
+ set_hash("cweek", str2num(s[8]));
+ set_hash("cwday", str2num(s[9]));
+ y = str2num(s[7]);
+ if (RSTRING_LEN(s[7]) < 4)
+ y = comp_year69(y);
+ set_hash("cwyear", y);
+ }
+ else if (!NIL_P(s[11])) {
+ set_hash("cweek", str2num(s[10]));
+ set_hash("cwday", str2num(s[11]));
+ }
+ else if (!NIL_P(s[12])) {
+ set_hash("cwday", str2num(s[12]));
+ }
+ if (!NIL_P(s[13])) {
+ set_hash("hour", str2num(s[13]));
+ set_hash("min", str2num(s[14]));
+ if (!NIL_P(s[15]))
+ set_hash("sec", str2num(s[15]));
+ }
+ if (!NIL_P(s[16])) {
+ set_hash("sec_fraction", sec_fraction(s[16]));
+ }
+ if (!NIL_P(s[17])) {
+ set_hash("zone", s[17]);
+ set_hash("offset", date_zone_to_diff(s[17]));
+ }
+
+ return 1;
+}
+
+static int
+iso8601_bas_datetime(VALUE str, VALUE hash)
+{
+ static const char pat_source[] =
+ "\\A\\s*(?:([-+]?(?:\\d{4}|\\d{2})|--)(\\d{2}|-)(\\d{2})|"
+ "([-+]?(?:\\d{4}|\\d{2}))(\\d{3})|"
+ "-(\\d{3})|"
+ "(\\d{4}|\\d{2})w(\\d{2})(\\d)|"
+ "-w(\\d{2})(\\d)|"
+ "-w-(\\d))"
+ "(?:t?"
+ "(\\d{2})(\\d{2})(?:(\\d{2})(?:[,.](\\d+))?)?"
+ "(z|[-+]\\d{2}(?:\\d{2})?)?)?\\s*\\z";
+ static VALUE pat = Qnil;
+
+ REGCOMP_I(pat);
+ MATCH(str, pat, iso8601_bas_datetime_cb);
+}
+
+#undef SNUM
+#define SNUM 5
+
+static int
+iso8601_ext_time_cb(VALUE m, VALUE hash)
+{
+ VALUE s[SNUM + 1];
+
+ {
+ int i;
+ s[0] = Qnil;
+ for (i = 1; i <= SNUM; i++)
+ s[i] = rb_reg_nth_match(i, m);
+ }
+
+ set_hash("hour", str2num(s[1]));
+ set_hash("min", str2num(s[2]));
+ if (!NIL_P(s[3]))
+ set_hash("sec", str2num(s[3]));
+ if (!NIL_P(s[4]))
+ set_hash("sec_fraction", sec_fraction(s[4]));
+ if (!NIL_P(s[5])) {
+ set_hash("zone", s[5]);
+ set_hash("offset", date_zone_to_diff(s[5]));
+ }
+
+ return 1;
+}
+
+#define iso8601_bas_time_cb iso8601_ext_time_cb
+
+static int
+iso8601_ext_time(VALUE str, VALUE hash)
+{
+ static const char pat_source[] =
+ "\\A\\s*(\\d{2}):(\\d{2})(?::(\\d{2})(?:[,.](\\d+))?"
+ "(z|[-+]\\d{2}(:?\\d{2})?)?)?\\s*\\z";
+ static VALUE pat = Qnil;
+
+ REGCOMP_I(pat);
+ MATCH(str, pat, iso8601_ext_time_cb);
+}
+
+static int
+iso8601_bas_time(VALUE str, VALUE hash)
+{
+ static const char pat_source[] =
+ "\\A\\s*(\\d{2})(\\d{2})(?:(\\d{2})(?:[,.](\\d+))?"
+ "(z|[-+]\\d{2}(\\d{2})?)?)?\\s*\\z";
+ static VALUE pat = Qnil;
+
+ REGCOMP_I(pat);
+ MATCH(str, pat, iso8601_bas_time_cb);
+}
+
+VALUE
+date__iso8601(VALUE str)
+{
+ VALUE backref, hash;
+
+ backref = rb_backref_get();
+ rb_match_busy(backref);
+
+ hash = rb_hash_new();
+
+ if (iso8601_ext_datetime(str, hash))
+ goto ok;
+ if (iso8601_bas_datetime(str, hash))
+ goto ok;
+ if (iso8601_ext_time(str, hash))
+ goto ok;
+ if (iso8601_bas_time(str, hash))
+ goto ok;
+
+ ok:
+ rb_backref_set(backref);
+
+ return hash;
+}
+
+#undef SNUM
+#define SNUM 8
+
+static int
+rfc3339_cb(VALUE m, VALUE hash)
+{
+ VALUE s[SNUM + 1];
+
+ {
+ int i;
+ s[0] = Qnil;
+ for (i = 1; i <= SNUM; i++)
+ s[i] = rb_reg_nth_match(i, m);
+ }
+
+ set_hash("year", str2num(s[1]));
+ set_hash("mon", str2num(s[2]));
+ set_hash("mday", str2num(s[3]));
+ set_hash("hour", str2num(s[4]));
+ set_hash("min", str2num(s[5]));
+ set_hash("sec", str2num(s[6]));
+ set_hash("zone", s[8]);
+ set_hash("offset", date_zone_to_diff(s[8]));
+ if (!NIL_P(s[7]))
+ set_hash("sec_fraction", sec_fraction(s[7]));
+
+ return 1;
+}
+
+static int
+rfc3339(VALUE str, VALUE hash)
+{
+ static const char pat_source[] =
+ "\\A\\s*(-?\\d{4})-(\\d{2})-(\\d{2})"
+ "(?:t|\\s)"
+ "(\\d{2}):(\\d{2}):(\\d{2})(?:\\.(\\d+))?"
+ "(z|[-+]\\d{2}:\\d{2})\\s*\\z";
+ static VALUE pat = Qnil;
+
+ REGCOMP_I(pat);
+ MATCH(str, pat, rfc3339_cb);
+}
+
+VALUE
+date__rfc3339(VALUE str)
+{
+ VALUE backref, hash;
+
+ backref = rb_backref_get();
+ rb_match_busy(backref);
+
+ hash = rb_hash_new();
+ rfc3339(str, hash);
+ rb_backref_set(backref);
+ return hash;
+}
+
+#undef SNUM
+#define SNUM 8
+
+static int
+xmlschema_datetime_cb(VALUE m, VALUE hash)
+{
+ VALUE s[SNUM + 1];
+
+ {
+ int i;
+ s[0] = Qnil;
+ for (i = 1; i <= SNUM; i++)
+ s[i] = rb_reg_nth_match(i, m);
+ }
+
+ set_hash("year", str2num(s[1]));
+ if (!NIL_P(s[2]))
+ set_hash("mon", str2num(s[2]));
+ if (!NIL_P(s[3]))
+ set_hash("mday", str2num(s[3]));
+ if (!NIL_P(s[4]))
+ set_hash("hour", str2num(s[4]));
+ if (!NIL_P(s[5]))
+ set_hash("min", str2num(s[5]));
+ if (!NIL_P(s[6]))
+ set_hash("sec", str2num(s[6]));
+ if (!NIL_P(s[7]))
+ set_hash("sec_fraction", sec_fraction(s[7]));
+ if (!NIL_P(s[8])) {
+ set_hash("zone", s[8]);
+ set_hash("offset", date_zone_to_diff(s[8]));
+ }
+
+ return 1;
+}
+
+static int
+xmlschema_datetime(VALUE str, VALUE hash)
+{
+ static const char pat_source[] =
+ "\\A\\s*(-?\\d{4,})(?:-(\\d{2})(?:-(\\d{2}))?)?"
+ "(?:t"
+ "(\\d{2}):(\\d{2}):(\\d{2})(?:\\.(\\d+))?)?"
+ "(z|[-+]\\d{2}:\\d{2})?\\s*\\z";
+ static VALUE pat = Qnil;
+
+ REGCOMP_I(pat);
+ MATCH(str, pat, xmlschema_datetime_cb);
+}
+
+#undef SNUM
+#define SNUM 5
+
+static int
+xmlschema_time_cb(VALUE m, VALUE hash)
+{
+ VALUE s[SNUM + 1];
+
+ {
+ int i;
+ s[0] = Qnil;
+ for (i = 1; i <= SNUM; i++)
+ s[i] = rb_reg_nth_match(i, m);
+ }
+
+ set_hash("hour", str2num(s[1]));
+ set_hash("min", str2num(s[2]));
+ if (!NIL_P(s[3]))
+ set_hash("sec", str2num(s[3]));
+ if (!NIL_P(s[4]))
+ set_hash("sec_fraction", sec_fraction(s[4]));
+ if (!NIL_P(s[5])) {
+ set_hash("zone", s[5]);
+ set_hash("offset", date_zone_to_diff(s[5]));
+ }
+
+ return 1;
+}
+
+static int
+xmlschema_time(VALUE str, VALUE hash)
+{
+ static const char pat_source[] =
+ "\\A\\s*(\\d{2}):(\\d{2}):(\\d{2})(?:\\.(\\d+))?"
+ "(z|[-+]\\d{2}:\\d{2})?\\s*\\z";
+ static VALUE pat = Qnil;
+
+ REGCOMP_I(pat);
+ MATCH(str, pat, xmlschema_time_cb);
+}
+
+#undef SNUM
+#define SNUM 4
+
+static int
+xmlschema_trunc_cb(VALUE m, VALUE hash)
+{
+ VALUE s[SNUM + 1];
+
+ {
+ int i;
+ s[0] = Qnil;
+ for (i = 1; i <= SNUM; i++)
+ s[i] = rb_reg_nth_match(i, m);
+ }
+
+ if (!NIL_P(s[1]))
+ set_hash("mon", str2num(s[1]));
+ if (!NIL_P(s[2]))
+ set_hash("mday", str2num(s[2]));
+ if (!NIL_P(s[3]))
+ set_hash("mday", str2num(s[3]));
+ if (!NIL_P(s[4])) {
+ set_hash("zone", s[4]);
+ set_hash("offset", date_zone_to_diff(s[4]));
+ }
+
+ return 1;
+}
+
+static int
+xmlschema_trunc(VALUE str, VALUE hash)
+{
+ static const char pat_source[] =
+ "\\A\\s*(?:--(\\d{2})(?:-(\\d{2}))?|---(\\d{2}))"
+ "(z|[-+]\\d{2}:\\d{2})?\\s*\\z";
+ static VALUE pat = Qnil;
+
+ REGCOMP_I(pat);
+ MATCH(str, pat, xmlschema_trunc_cb);
+}
+
+VALUE
+date__xmlschema(VALUE str)
+{
+ VALUE backref, hash;
+
+ backref = rb_backref_get();
+ rb_match_busy(backref);
+
+ hash = rb_hash_new();
+
+ if (xmlschema_datetime(str, hash))
+ goto ok;
+ if (xmlschema_time(str, hash))
+ goto ok;
+ if (xmlschema_trunc(str, hash))
+ goto ok;
+
+ ok:
+ rb_backref_set(backref);
+
+ return hash;
+}
+
+#undef SNUM
+#define SNUM 8
+
+static int
+rfc2822_cb(VALUE m, VALUE hash)
+{
+ VALUE s[SNUM + 1], y;
+
+ {
+ int i;
+ s[0] = Qnil;
+ for (i = 1; i <= SNUM; i++)
+ s[i] = rb_reg_nth_match(i, m);
+ }
+
+ if (!NIL_P(s[1])) {
+ set_hash("wday", INT2FIX(day_num(s[1])));
+ }
+ set_hash("mday", str2num(s[2]));
+ set_hash("mon", INT2FIX(mon_num(s[3])));
+ y = str2num(s[4]);
+ if (RSTRING_LEN(s[4]) < 4)
+ y = comp_year50(y);
+ set_hash("year", y);
+ set_hash("hour", str2num(s[5]));
+ set_hash("min", str2num(s[6]));
+ if (!NIL_P(s[7]))
+ set_hash("sec", str2num(s[7]));
+ set_hash("zone", s[8]);
+ set_hash("offset", date_zone_to_diff(s[8]));
+
+ return 1;
+}
+
+static int
+rfc2822(VALUE str, VALUE hash)
+{
+ static const char pat_source[] =
+ "\\A\\s*(?:(" ABBR_DAYS ")\\s*,\\s+)?"
+ "(\\d{1,2})\\s+"
+ "(" ABBR_MONTHS ")\\s+"
+ "(-?\\d{2,})\\s+"
+ "(\\d{2}):(\\d{2})(?::(\\d{2}))?\\s*"
+ "([-+]\\d{4}|ut|gmt|e[sd]t|c[sd]t|m[sd]t|p[sd]t|[a-ik-z])\\s*\\z";
+ static VALUE pat = Qnil;
+
+ REGCOMP_I(pat);
+ MATCH(str, pat, rfc2822_cb);
+}
+
+VALUE
+date__rfc2822(VALUE str)
+{
+ VALUE backref, hash;
+
+ backref = rb_backref_get();
+ rb_match_busy(backref);
+
+ hash = rb_hash_new();
+ rfc2822(str, hash);
+ rb_backref_set(backref);
+ return hash;
+}
+
+#undef SNUM
+#define SNUM 8
+
+static int
+httpdate_type1_cb(VALUE m, VALUE hash)
+{
+ VALUE s[SNUM + 1];
+
+ {
+ int i;
+ s[0] = Qnil;
+ for (i = 1; i <= SNUM; i++)
+ s[i] = rb_reg_nth_match(i, m);
+ }
+
+ set_hash("wday", INT2FIX(day_num(s[1])));
+ set_hash("mday", str2num(s[2]));
+ set_hash("mon", INT2FIX(mon_num(s[3])));
+ set_hash("year", str2num(s[4]));
+ set_hash("hour", str2num(s[5]));
+ set_hash("min", str2num(s[6]));
+ set_hash("sec", str2num(s[7]));
+ set_hash("zone", s[8]);
+ set_hash("offset", INT2FIX(0));
+
+ return 1;
+}
+
+static int
+httpdate_type1(VALUE str, VALUE hash)
+{
+ static const char pat_source[] =
+ "\\A\\s*(" ABBR_DAYS ")\\s*,\\s+"
+ "(\\d{2})\\s+"
+ "(" ABBR_MONTHS ")\\s+"
+ "(-?\\d{4})\\s+"
+ "(\\d{2}):(\\d{2}):(\\d{2})\\s+"
+ "(gmt)\\s*\\z";
+ static VALUE pat = Qnil;
+
+ REGCOMP_I(pat);
+ MATCH(str, pat, httpdate_type1_cb);
+}
+
+#undef SNUM
+#define SNUM 8
+
+static int
+httpdate_type2_cb(VALUE m, VALUE hash)
+{
+ VALUE s[SNUM + 1], y;
+
+ {
+ int i;
+ s[0] = Qnil;
+ for (i = 1; i <= SNUM; i++)
+ s[i] = rb_reg_nth_match(i, m);
+ }
+
+ set_hash("wday", INT2FIX(day_num(s[1])));
+ set_hash("mday", str2num(s[2]));
+ set_hash("mon", INT2FIX(mon_num(s[3])));
+ y = str2num(s[4]);
+ if (f_ge_p(y, INT2FIX(0)) && f_le_p(y, INT2FIX(99)))
+ y = comp_year69(y);
+ set_hash("year", y);
+ set_hash("hour", str2num(s[5]));
+ set_hash("min", str2num(s[6]));
+ set_hash("sec", str2num(s[7]));
+ set_hash("zone", s[8]);
+ set_hash("offset", INT2FIX(0));
+
+ return 1;
+}
+
+static int
+httpdate_type2(VALUE str, VALUE hash)
+{
+ static const char pat_source[] =
+ "\\A\\s*(" DAYS ")\\s*,\\s+"
+ "(\\d{2})\\s*-\\s*"
+ "(" ABBR_MONTHS ")\\s*-\\s*"
+ "(\\d{2})\\s+"
+ "(\\d{2}):(\\d{2}):(\\d{2})\\s+"
+ "(gmt)\\s*\\z";
+ static VALUE pat = Qnil;
+
+ REGCOMP_I(pat);
+ MATCH(str, pat, httpdate_type2_cb);
+}
+
+#undef SNUM
+#define SNUM 7
+
+static int
+httpdate_type3_cb(VALUE m, VALUE hash)
+{
+ VALUE s[SNUM + 1];
+
+ {
+ int i;
+ s[0] = Qnil;
+ for (i = 1; i <= SNUM; i++)
+ s[i] = rb_reg_nth_match(i, m);
+ }
+
+ set_hash("wday", INT2FIX(day_num(s[1])));
+ set_hash("mon", INT2FIX(mon_num(s[2])));
+ set_hash("mday", str2num(s[3]));
+ set_hash("hour", str2num(s[4]));
+ set_hash("min", str2num(s[5]));
+ set_hash("sec", str2num(s[6]));
+ set_hash("year", str2num(s[7]));
+
+ return 1;
+}
+
+static int
+httpdate_type3(VALUE str, VALUE hash)
+{
+ static const char pat_source[] =
+ "\\A\\s*(" ABBR_DAYS ")\\s+"
+ "(" ABBR_MONTHS ")\\s+"
+ "(\\d{1,2})\\s+"
+ "(\\d{2}):(\\d{2}):(\\d{2})\\s+"
+ "(\\d{4})\\s*\\z";
+ static VALUE pat = Qnil;
+
+ REGCOMP_I(pat);
+ MATCH(str, pat, httpdate_type3_cb);
+}
+
+VALUE
+date__httpdate(VALUE str)
+{
+ VALUE backref, hash;
+
+ backref = rb_backref_get();
+ rb_match_busy(backref);
+
+ hash = rb_hash_new();
+
+ if (httpdate_type1(str, hash))
+ goto ok;
+ if (httpdate_type2(str, hash))
+ goto ok;
+ if (httpdate_type3(str, hash))
+ goto ok;
+
+ ok:
+ rb_backref_set(backref);
+
+ return hash;
+}
+
+#undef SNUM
+#define SNUM 9
+
+static int
+jisx0301_cb(VALUE m, VALUE hash)
+{
+ VALUE s[SNUM + 1];
+ int ep;
+
+ {
+ int i;
+ s[0] = Qnil;
+ for (i = 1; i <= SNUM; i++)
+ s[i] = rb_reg_nth_match(i, m);
+ }
+
+ ep = gengo(NIL_P(s[1]) ? 'h' : *RSTRING_PTR(s[1]));
+ set_hash("year", f_add(str2num(s[2]), INT2FIX(ep)));
+ set_hash("mon", str2num(s[3]));
+ set_hash("mday", str2num(s[4]));
+ if (!NIL_P(s[5])) {
+ set_hash("hour", str2num(s[5]));
+ if (!NIL_P(s[6]))
+ set_hash("min", str2num(s[6]));
+ if (!NIL_P(s[7]))
+ set_hash("sec", str2num(s[7]));
+ }
+ if (!NIL_P(s[8]))
+ set_hash("sec_fraction", sec_fraction(s[8]));
+ if (!NIL_P(s[9])) {
+ set_hash("zone", s[9]);
+ set_hash("offset", date_zone_to_diff(s[9]));
+ }
+
+ return 1;
+}
+
+static int
+jisx0301(VALUE str, VALUE hash)
+{
+ static const char pat_source[] =
+ "\\A\\s*([mtsh])?(\\d{2})\\.(\\d{2})\\.(\\d{2})"
+ "(?:t"
+ "(?:(\\d{2}):(\\d{2})(?::(\\d{2})(?:[,.](\\d*))?)?"
+ "(z|[-+]\\d{2}(?::?\\d{2})?)?)?)?\\s*\\z";
+ static VALUE pat = Qnil;
+
+ REGCOMP_I(pat);
+ MATCH(str, pat, jisx0301_cb);
+}
+
+VALUE
+date__jisx0301(VALUE str)
+{
+ VALUE backref, hash;
+
+ backref = rb_backref_get();
+ rb_match_busy(backref);
+
+ hash = rb_hash_new();
+ if (jisx0301(str, hash))
+ goto ok;
+ hash = date__iso8601(str);
+
+ ok:
+ rb_backref_set(backref);
+ return hash;
+}
+
+/*
+Local variables:
+c-file-style: "ruby"
+End:
+*/
diff --git a/jni/ruby/ext/date/date_strftime.c b/jni/ruby/ext/date/date_strftime.c
new file mode 100644
index 0000000..20931a3
--- /dev/null
+++ b/jni/ruby/ext/date/date_strftime.c
@@ -0,0 +1,633 @@
+/*
+ date_strftime.c: based on a public-domain implementation of ANSI C
+ library routine strftime, which is originally written by Arnold
+ Robbins.
+ */
+
+#include "ruby/ruby.h"
+#include "date_tmx.h"
+
+#include <stdlib.h>
+#include <string.h>
+#include <ctype.h>
+#include <errno.h>
+
+#if defined(HAVE_SYS_TIME_H)
+#include <sys/time.h>
+#endif
+
+#undef strchr /* avoid AIX weirdness */
+
+#define range(low, item, hi) (item)
+
+#define add(x,y) (rb_funcall((x), '+', 1, (y)))
+#define sub(x,y) (rb_funcall((x), '-', 1, (y)))
+#define mul(x,y) (rb_funcall((x), '*', 1, (y)))
+#define quo(x,y) (rb_funcall((x), rb_intern("quo"), 1, (y)))
+#define div(x,y) (rb_funcall((x), rb_intern("div"), 1, (y)))
+#define mod(x,y) (rb_funcall((x), '%', 1, (y)))
+
+static void
+upcase(char *s, size_t i)
+{
+ do {
+ if (ISLOWER(*s))
+ *s = TOUPPER(*s);
+ } while (s++, --i);
+}
+
+static void
+downcase(char *s, size_t i)
+{
+ do {
+ if (ISUPPER(*s))
+ *s = TOLOWER(*s);
+ } while (s++, --i);
+}
+
+/* strftime --- produce formatted time */
+
+static size_t
+date_strftime_with_tmx(char *s, size_t maxsize, const char *format,
+ const struct tmx *tmx)
+{
+ char *endp = s + maxsize;
+ char *start = s;
+ const char *sp, *tp;
+ auto char tbuf[100];
+ ptrdiff_t i;
+ int v, w;
+ size_t colons;
+ int precision, flags;
+ char padding;
+ /* LOCALE_[OE] and COLONS are actually modifiers, not flags */
+ enum {LEFT, CHCASE, LOWER, UPPER, LOCALE_O, LOCALE_E, COLONS};
+#define BIT_OF(n) (1U<<(n))
+
+ /* various tables for locale C */
+ static const char days_l[][10] = {
+ "Sunday", "Monday", "Tuesday", "Wednesday",
+ "Thursday", "Friday", "Saturday",
+ };
+ static const char months_l[][10] = {
+ "January", "February", "March", "April",
+ "May", "June", "July", "August", "September",
+ "October", "November", "December",
+ };
+ static const char ampm[][3] = { "AM", "PM", };
+
+ if (s == NULL || format == NULL || tmx == NULL || maxsize == 0)
+ return 0;
+
+ /* quick check if we even need to bother */
+ if (strchr(format, '%') == NULL && strlen(format) + 1 >= maxsize) {
+ err:
+ errno = ERANGE;
+ return 0;
+ }
+
+ for (; *format && s < endp - 1; format++) {
+#define FLAG_FOUND() do { \
+ if (precision > 0 || flags & (BIT_OF(LOCALE_E) | BIT_OF(LOCALE_O) | BIT_OF(COLONS))) \
+ goto unknown; \
+ } while (0)
+#define NEEDS(n) do if (s >= endp || (n) >= endp - s - 1) goto err; while (0)
+#define FILL_PADDING(i) do { \
+ if (!(flags & BIT_OF(LEFT)) && precision > (i)) { \
+ NEEDS(precision); \
+ memset(s, padding ? padding : ' ', precision - (i)); \
+ s += precision - (i); \
+ } \
+ else { \
+ NEEDS(i); \
+ } \
+ } while (0);
+#define FMT(def_pad, def_prec, fmt, val) \
+ do { \
+ int l; \
+ if (precision <= 0) precision = (def_prec); \
+ if (flags & BIT_OF(LEFT)) precision = 1; \
+ l = snprintf(s, endp - s, \
+ ((padding == '0' || (!padding && (def_pad) == '0')) ? \
+ "%0*"fmt : "%*"fmt), \
+ precision, (val)); \
+ if (l < 0) goto err; \
+ s += l; \
+ } while (0)
+#define STRFTIME(fmt) \
+ do { \
+ i = date_strftime_with_tmx(s, endp - s, (fmt), tmx); \
+ if (!i) return 0; \
+ if (flags & BIT_OF(UPPER)) \
+ upcase(s, i); \
+ if (!(flags & BIT_OF(LEFT)) && precision > i) { \
+ if (start + maxsize < s + precision) { \
+ errno = ERANGE; \
+ return 0; \
+ } \
+ memmove(s + precision - i, s, i); \
+ memset(s, padding ? padding : ' ', precision - i); \
+ s += precision; \
+ } \
+ else s += i; \
+ } while (0)
+#define FMTV(def_pad, def_prec, fmt, val) \
+ do { \
+ VALUE tmp = (val); \
+ if (FIXNUM_P(tmp)) { \
+ FMT((def_pad), (def_prec), "l"fmt, FIX2LONG(tmp)); \
+ } \
+ else { \
+ VALUE args[2], result; \
+ size_t l; \
+ if (precision <= 0) precision = (def_prec); \
+ if (flags & BIT_OF(LEFT)) precision = 1; \
+ args[0] = INT2FIX(precision); \
+ args[1] = (val); \
+ if (padding == '0' || (!padding && (def_pad) == '0')) \
+ result = rb_str_format(2, args, rb_str_new2("%0*"fmt)); \
+ else \
+ result = rb_str_format(2, args, rb_str_new2("%*"fmt)); \
+ l = strlcpy(s, StringValueCStr(result), endp - s); \
+ if ((size_t)(endp - s) <= l) \
+ goto err; \
+ s += l; \
+ } \
+ } while (0)
+
+ if (*format != '%') {
+ *s++ = *format;
+ continue;
+ }
+ tp = tbuf;
+ sp = format;
+ precision = -1;
+ flags = 0;
+ padding = 0;
+ colons = 0;
+ again:
+ switch (*++format) {
+ case '\0':
+ format--;
+ goto unknown;
+
+ case 'A': /* full weekday name */
+ case 'a': /* abbreviated weekday name */
+ if (flags & BIT_OF(CHCASE)) {
+ flags &= ~(BIT_OF(LOWER) | BIT_OF(CHCASE));
+ flags |= BIT_OF(UPPER);
+ }
+ {
+ int wday = tmx_wday;
+ if (wday < 0 || wday > 6)
+ i = 1, tp = "?";
+ else {
+ if (*format == 'A')
+ i = strlen(tp = days_l[wday]);
+ else
+ i = 3, tp = days_l[wday];
+ }
+ }
+ break;
+
+ case 'B': /* full month name */
+ case 'b': /* abbreviated month name */
+ case 'h': /* same as %b */
+ if (flags & BIT_OF(CHCASE)) {
+ flags &= ~(BIT_OF(LOWER) | BIT_OF(CHCASE));
+ flags |= BIT_OF(UPPER);
+ }
+ {
+ int mon = tmx_mon;
+ if (mon < 1 || mon > 12)
+ i = 1, tp = "?";
+ else {
+ if (*format == 'B')
+ i = strlen(tp = months_l[mon - 1]);
+ else
+ i = 3, tp = months_l[mon - 1];
+ }
+ }
+ break;
+
+ case 'C': /* century (year/100) */
+ FMTV('0', 2, "d", div(tmx_year, INT2FIX(100)));
+ continue;
+
+ case 'c': /* appropriate date and time representation */
+ STRFTIME("%a %b %e %H:%M:%S %Y");
+ continue;
+
+ case 'D':
+ STRFTIME("%m/%d/%y");
+ continue;
+
+ case 'd': /* day of the month, 01 - 31 */
+ case 'e': /* day of month, blank padded */
+ v = range(1, tmx_mday, 31);
+ FMT((*format == 'd') ? '0' : ' ', 2, "d", v);
+ continue;
+
+ case 'F':
+ STRFTIME("%Y-%m-%d");
+ continue;
+
+ case 'G': /* year of ISO week with century */
+ case 'Y': /* year with century */
+ {
+ VALUE year = (*format == 'G') ? tmx_cwyear : tmx_year;
+ if (FIXNUM_P(year)) {
+ long y = FIX2LONG(year);
+ FMT('0', 0 <= y ? 4 : 5, "ld", y);
+ }
+ else {
+ FMTV('0', 4, "d", year);
+ }
+ }
+ continue;
+
+ case 'g': /* year of ISO week without a century */
+ case 'y': /* year without a century */
+ v = NUM2INT(mod((*format == 'g') ? tmx_cwyear : tmx_year, INT2FIX(100)));
+ FMT('0', 2, "d", v);
+ continue;
+
+ case 'H': /* hour, 24-hour clock, 00 - 23 */
+ case 'k': /* hour, 24-hour clock, blank pad */
+ v = range(0, tmx_hour, 23);
+ FMT((*format == 'H') ? '0' : ' ', 2, "d", v);
+ continue;
+
+ case 'I': /* hour, 12-hour clock, 01 - 12 */
+ case 'l': /* hour, 12-hour clock, 1 - 12, blank pad */
+ v = range(0, tmx_hour, 23);
+ if (v == 0)
+ v = 12;
+ else if (v > 12)
+ v -= 12;
+ FMT((*format == 'I') ? '0' : ' ', 2, "d", v);
+ continue;
+
+ case 'j': /* day of the year, 001 - 366 */
+ v = range(1, tmx_yday, 366);
+ FMT('0', 3, "d", v);
+ continue;
+
+ case 'L': /* millisecond */
+ case 'N': /* nanosecond */
+ if (*format == 'L')
+ w = 3;
+ else
+ w = 9;
+ if (precision <= 0)
+ precision = w;
+ NEEDS(precision);
+
+ {
+ VALUE subsec = tmx_sec_fraction;
+ int ww;
+ long n;
+
+ ww = precision;
+ while (9 <= ww) {
+ subsec = mul(subsec, INT2FIX(1000000000));
+ ww -= 9;
+ }
+ n = 1;
+ for (; 0 < ww; ww--)
+ n *= 10;
+ if (n != 1)
+ subsec = mul(subsec, INT2FIX(n));
+ subsec = div(subsec, INT2FIX(1));
+
+ if (FIXNUM_P(subsec)) {
+ (void)snprintf(s, endp - s, "%0*ld",
+ precision, FIX2LONG(subsec));
+ s += precision;
+ }
+ else {
+ VALUE args[2], result;
+ args[0] = INT2FIX(precision);
+ args[1] = subsec;
+ result = rb_str_format(2, args, rb_str_new2("%0*d"));
+ (void)strlcpy(s, StringValueCStr(result), endp - s);
+ s += precision;
+ }
+ }
+ continue;
+
+ case 'M': /* minute, 00 - 59 */
+ v = range(0, tmx_min, 59);
+ FMT('0', 2, "d", v);
+ continue;
+
+ case 'm': /* month, 01 - 12 */
+ v = range(1, tmx_mon, 12);
+ FMT('0', 2, "d", v);
+ continue;
+
+ case 'n': /* same as \n */
+ FILL_PADDING(1);
+ *s++ = '\n';
+ continue;
+
+ case 't': /* same as \t */
+ FILL_PADDING(1);
+ *s++ = '\t';
+ continue;
+
+ case 'P': /* am or pm based on 12-hour clock */
+ case 'p': /* AM or PM based on 12-hour clock */
+ if ((*format == 'p' && (flags & BIT_OF(CHCASE))) ||
+ (*format == 'P' && !(flags & (BIT_OF(CHCASE) | BIT_OF(UPPER))))) {
+ flags &= ~(BIT_OF(UPPER) | BIT_OF(CHCASE));
+ flags |= BIT_OF(LOWER);
+ }
+ v = range(0, tmx_hour, 23);
+ if (v < 12)
+ tp = ampm[0];
+ else
+ tp = ampm[1];
+ i = 2;
+ break;
+
+ case 'Q': /* milliseconds since Unix epoch */
+ FMTV('0', 1, "d", tmx_msecs);
+ continue;
+
+ case 'R':
+ STRFTIME("%H:%M");
+ continue;
+
+ case 'r':
+ STRFTIME("%I:%M:%S %p");
+ continue;
+
+ case 'S': /* second, 00 - 59 */
+ v = range(0, tmx_sec, 59);
+ FMT('0', 2, "d", v);
+ continue;
+
+ case 's': /* seconds since Unix epoch */
+ FMTV('0', 1, "d", tmx_secs);
+ continue;
+
+ case 'T':
+ STRFTIME("%H:%M:%S");
+ continue;
+
+ case 'U': /* week of year, Sunday is first day of week */
+ case 'W': /* week of year, Monday is first day of week */
+ v = range(0, (*format == 'U') ? tmx_wnum0 : tmx_wnum1, 53);
+ FMT('0', 2, "d", v);
+ continue;
+
+ case 'u': /* weekday, Monday == 1, 1 - 7 */
+ v = range(1, tmx_cwday, 7);
+ FMT('0', 1, "d", v);
+ continue;
+
+ case 'V': /* week of year according ISO 8601 */
+ v = range(1, tmx_cweek, 53);
+ FMT('0', 2, "d", v);
+ continue;
+
+ case 'v':
+ STRFTIME("%e-%b-%Y");
+ continue;
+
+ case 'w': /* weekday, Sunday == 0, 0 - 6 */
+ v = range(0, tmx_wday, 6);
+ FMT('0', 1, "d", v);
+ continue;
+
+ case 'X': /* appropriate time representation */
+ STRFTIME("%H:%M:%S");
+ continue;
+
+ case 'x': /* appropriate date representation */
+ STRFTIME("%m/%d/%y");
+ continue;
+
+ case 'Z': /* time zone name or abbreviation */
+ if (flags & BIT_OF(CHCASE)) {
+ flags &= ~(BIT_OF(UPPER) | BIT_OF(CHCASE));
+ flags |= BIT_OF(LOWER);
+ }
+ {
+ char *zone = tmx_zone;
+ if (zone == NULL)
+ tp = "";
+ else
+ tp = zone;
+ i = strlen(tp);
+ }
+ break;
+
+ case 'z': /* offset from UTC */
+ {
+ long off, aoff;
+ int hl, hw;
+
+ off = tmx_offset;
+ aoff = off;
+ if (aoff < 0)
+ aoff = -off;
+
+ if ((aoff / 3600) < 10)
+ hl = 1;
+ else
+ hl = 2;
+ hw = 2;
+ if (flags & BIT_OF(LEFT) && hl == 1)
+ hw = 1;
+
+ switch (colons) {
+ case 0: /* %z -> +hhmm */
+ precision = precision <= (3 + hw) ? hw : precision - 3;
+ NEEDS(precision + 3);
+ break;
+
+ case 1: /* %:z -> +hh:mm */
+ precision = precision <= (4 + hw) ? hw : precision - 4;
+ NEEDS(precision + 4);
+ break;
+
+ case 2: /* %::z -> +hh:mm:ss */
+ precision = precision <= (7 + hw) ? hw : precision - 7;
+ NEEDS(precision + 7);
+ break;
+
+ case 3: /* %:::z -> +hh[:mm[:ss]] */
+ {
+ if (aoff % 3600 == 0) {
+ precision = precision <= (1 + hw) ?
+ hw : precision - 1;
+ NEEDS(precision + 3);
+ }
+ else if (aoff % 60 == 0) {
+ precision = precision <= (4 + hw) ?
+ hw : precision - 4;
+ NEEDS(precision + 4);
+ }
+ else {
+ precision = precision <= (7 + hw) ?
+ hw : precision - 7;
+ NEEDS(precision + 7);
+ }
+ }
+ break;
+
+ default:
+ format--;
+ goto unknown;
+ }
+ if (padding == ' ' && precision > hl) {
+ i = snprintf(s, endp - s, "%*s", precision - hl, "");
+ precision = hl;
+ if (i < 0) goto err;
+ s += i;
+ }
+ if (off < 0) {
+ off = -off;
+ *s++ = '-';
+ } else {
+ *s++ = '+';
+ }
+ i = snprintf(s, endp - s, "%.*ld", precision, off / 3600);
+ if (i < 0) goto err;
+ s += i;
+ off = off % 3600;
+ if (colons == 3 && off == 0)
+ continue;
+ if (1 <= colons)
+ *s++ = ':';
+ i = snprintf(s, endp - s, "%02d", (int)(off / 60));
+ if (i < 0) goto err;
+ s += i;
+ off = off % 60;
+ if (colons == 3 && off == 0)
+ continue;
+ if (2 <= colons) {
+ *s++ = ':';
+ i = snprintf(s, endp - s, "%02d", (int)off);
+ if (i < 0) goto err;
+ s += i;
+ }
+ }
+ continue;
+
+ case '+':
+ STRFTIME("%a %b %e %H:%M:%S %Z %Y");
+ continue;
+
+ case 'E':
+ /* POSIX locale extensions, ignored for now */
+ flags |= BIT_OF(LOCALE_E);
+ if (*(format + 1) && strchr("cCxXyY", *(format + 1)))
+ goto again;
+ goto unknown;
+ case 'O':
+ /* POSIX locale extensions, ignored for now */
+ flags |= BIT_OF(LOCALE_O);
+ if (*(format + 1) && strchr("deHkIlmMSuUVwWy", *(format + 1)))
+ goto again;
+ goto unknown;
+
+ case ':':
+ flags |= BIT_OF(COLONS);
+ {
+ size_t l = strspn(format, ":");
+ format += l;
+ if (*format == 'z') {
+ colons = l;
+ format--;
+ goto again;
+ }
+ format -= l;
+ }
+ goto unknown;
+
+ case '_':
+ FLAG_FOUND();
+ padding = ' ';
+ goto again;
+
+ case '-':
+ FLAG_FOUND();
+ flags |= BIT_OF(LEFT);
+ goto again;
+
+ case '^':
+ FLAG_FOUND();
+ flags |= BIT_OF(UPPER);
+ goto again;
+
+ case '#':
+ FLAG_FOUND();
+ flags |= BIT_OF(CHCASE);
+ goto again;
+
+ case '0':
+ FLAG_FOUND();
+ padding = '0';
+ case '1': case '2': case '3': case '4':
+ case '5': case '6': case '7': case '8': case '9':
+ {
+ char *e;
+ precision = (int)strtoul(format, &e, 10);
+ format = e - 1;
+ goto again;
+ }
+
+ case '%':
+ FILL_PADDING(1);
+ *s++ = '%';
+ continue;
+
+ default:
+ unknown:
+ i = format - sp + 1;
+ tp = sp;
+ precision = -1;
+ flags = 0;
+ padding = 0;
+ colons = 0;
+ break;
+ }
+ if (i) {
+ FILL_PADDING(i);
+ memcpy(s, tp, i);
+ switch (flags & (BIT_OF(UPPER) | BIT_OF(LOWER))) {
+ case BIT_OF(UPPER):
+ upcase(s, i);
+ break;
+ case BIT_OF(LOWER):
+ downcase(s, i);
+ break;
+ }
+ s += i;
+ }
+ }
+ if (s >= endp) {
+ goto err;
+ }
+ if (*format == '\0') {
+ *s = '\0';
+ return (s - start);
+ }
+ return 0;
+}
+
+size_t
+date_strftime(char *s, size_t maxsize, const char *format,
+ const struct tmx *tmx)
+{
+ return date_strftime_with_tmx(s, maxsize, format, tmx);
+}
+
+/*
+Local variables:
+c-file-style: "ruby"
+End:
+*/
diff --git a/jni/ruby/ext/date/date_strptime.c b/jni/ruby/ext/date/date_strptime.c
new file mode 100644
index 0000000..e318af1
--- /dev/null
+++ b/jni/ruby/ext/date/date_strptime.c
@@ -0,0 +1,701 @@
+/*
+ date_strptime.c: Coded by Tadayoshi Funaba 2011,2012
+*/
+
+#include "ruby.h"
+#include "ruby/encoding.h"
+#include "ruby/re.h"
+#include <ctype.h>
+
+static const char *day_names[] = {
+ "Sunday", "Monday", "Tuesday", "Wednesday",
+ "Thursday", "Friday", "Saturday",
+ "Sun", "Mon", "Tue", "Wed",
+ "Thu", "Fri", "Sat"
+};
+
+static const char *month_names[] = {
+ "January", "February", "March", "April",
+ "May", "June", "July", "August", "September",
+ "October", "November", "December",
+ "Jan", "Feb", "Mar", "Apr", "May", "Jun",
+ "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"
+};
+
+static const char *merid_names[] = {
+ "am", "pm",
+ "a.m.", "p.m."
+};
+
+static const char *extz_pats[] = {
+ ":z",
+ "::z",
+ ":::z"
+};
+
+#define sizeof_array(o) (sizeof o / sizeof o[0])
+
+#define f_negate(x) rb_funcall(x, rb_intern("-@"), 0)
+#define f_add(x,y) rb_funcall(x, '+', 1, y)
+#define f_sub(x,y) rb_funcall(x, '-', 1, y)
+#define f_mul(x,y) rb_funcall(x, '*', 1, y)
+#define f_div(x,y) rb_funcall(x, '/', 1, y)
+#define f_idiv(x,y) rb_funcall(x, rb_intern("div"), 1, y)
+#define f_mod(x,y) rb_funcall(x, '%', 1, y)
+#define f_expt(x,y) rb_funcall(x, rb_intern("**"), 1, y)
+
+#define f_lt_p(x,y) rb_funcall(x, '<', 1, y)
+#define f_gt_p(x,y) rb_funcall(x, '>', 1, y)
+#define f_le_p(x,y) rb_funcall(x, rb_intern("<="), 1, y)
+#define f_ge_p(x,y) rb_funcall(x, rb_intern(">="), 1, y)
+
+#define f_match(r,s) rb_funcall(r, rb_intern("match"), 1, s)
+#define f_aref(o,i) rb_funcall(o, rb_intern("[]"), 1, i)
+#define f_end(o,i) rb_funcall(o, rb_intern("end"), 1, i)
+
+#define issign(c) ((c) == '-' || (c) == '+')
+
+static int
+num_pattern_p(const char *s)
+{
+ if (isdigit((unsigned char)*s))
+ return 1;
+ if (*s == '%') {
+ s++;
+ if (*s == 'E' || *s == 'O')
+ s++;
+ if (*s &&
+ (strchr("CDdeFGgHIjkLlMmNQRrSsTUuVvWwXxYy", *s) ||
+ isdigit((unsigned char)*s)))
+ return 1;
+ }
+ return 0;
+}
+
+#define NUM_PATTERN_P() num_pattern_p(&fmt[fi + 1])
+
+static long
+read_digits(const char *s, VALUE *n, size_t width)
+{
+ size_t l;
+
+ l = strspn(s, "0123456789");
+
+ if (l == 0)
+ return 0;
+
+ if (width < l)
+ l = width;
+
+ if ((4 * l * sizeof(char)) <= (sizeof(long)*CHAR_BIT)) {
+ const char *os = s;
+ long v;
+
+ v = 0;
+ while ((size_t)(s - os) < l) {
+ v *= 10;
+ v += *s - '0';
+ s++;
+ }
+ if (os == s)
+ return 0;
+ *n = LONG2NUM(v);
+ return l;
+ }
+ else {
+ char *s2 = ALLOCA_N(char, l + 1);
+ memcpy(s2, s, l);
+ s2[l] = '\0';
+ *n = rb_cstr_to_inum(s2, 10, 0);
+ return l;
+ }
+}
+
+#define set_hash(k,v) rb_hash_aset(hash, ID2SYM(rb_intern(k)), v)
+#define ref_hash(k) rb_hash_aref(hash, ID2SYM(rb_intern(k)))
+#define del_hash(k) rb_hash_delete(hash, ID2SYM(rb_intern(k)))
+
+#define fail() \
+{ \
+ set_hash("_fail", Qtrue); \
+ return 0; \
+}
+
+#define fail_p() (!NIL_P(ref_hash("_fail")))
+
+#define READ_DIGITS(n,w) \
+{ \
+ size_t l; \
+ l = read_digits(&str[si], &n, w); \
+ if (l == 0) \
+ fail(); \
+ si += l; \
+}
+
+#define READ_DIGITS_MAX(n) READ_DIGITS(n, LONG_MAX)
+
+static int
+valid_range_p(VALUE v, int a, int b)
+{
+ if (FIXNUM_P(v)) {
+ int vi = FIX2INT(v);
+ return !(vi < a || vi > b);
+ }
+ return !(f_lt_p(v, INT2NUM(a)) || f_gt_p(v, INT2NUM(b)));
+}
+
+#define recur(fmt) \
+{ \
+ size_t l; \
+ l = date__strptime_internal(&str[si], slen - si, \
+ fmt, sizeof fmt - 1, hash); \
+ if (fail_p()) \
+ return 0; \
+ si += l; \
+}
+
+VALUE date_zone_to_diff(VALUE);
+
+static size_t
+date__strptime_internal(const char *str, size_t slen,
+ const char *fmt, size_t flen, VALUE hash)
+{
+ size_t si, fi;
+ int c;
+
+ si = fi = 0;
+
+ while (fi < flen) {
+
+ switch (fmt[fi]) {
+ case '%':
+
+ again:
+ fi++;
+ c = fmt[fi];
+
+ switch (c) {
+ case 'E':
+ if (fmt[fi + 1] && strchr("cCxXyY", fmt[fi + 1]))
+ goto again;
+ fi--;
+ goto ordinal;
+ case 'O':
+ if (fmt[fi + 1] && strchr("deHImMSuUVwWy", fmt[fi + 1]))
+ goto again;
+ fi--;
+ goto ordinal;
+ case ':':
+ {
+ int i;
+
+ for (i = 0; i < (int)sizeof_array(extz_pats); i++)
+ if (strncmp(extz_pats[i], &fmt[fi],
+ strlen(extz_pats[i])) == 0) {
+ fi += i;
+ goto again;
+ }
+ fail();
+ }
+
+ case 'A':
+ case 'a':
+ {
+ int i;
+
+ for (i = 0; i < (int)sizeof_array(day_names); i++) {
+ size_t l = strlen(day_names[i]);
+ if (strncasecmp(day_names[i], &str[si], l) == 0) {
+ si += l;
+ set_hash("wday", INT2FIX(i % 7));
+ goto matched;
+ }
+ }
+ fail();
+ }
+ case 'B':
+ case 'b':
+ case 'h':
+ {
+ int i;
+
+ for (i = 0; i < (int)sizeof_array(month_names); i++) {
+ size_t l = strlen(month_names[i]);
+ if (strncasecmp(month_names[i], &str[si], l) == 0) {
+ si += l;
+ set_hash("mon", INT2FIX((i % 12) + 1));
+ goto matched;
+ }
+ }
+ fail();
+ }
+
+ case 'C':
+ {
+ VALUE n;
+
+ if (NUM_PATTERN_P())
+ READ_DIGITS(n, 2)
+ else
+ READ_DIGITS_MAX(n)
+ set_hash("_cent", n);
+ goto matched;
+ }
+
+ case 'c':
+ recur("%a %b %e %H:%M:%S %Y");
+ goto matched;
+
+ case 'D':
+ recur("%m/%d/%y");
+ goto matched;
+
+ case 'd':
+ case 'e':
+ {
+ VALUE n;
+
+ if (str[si] == ' ') {
+ si++;
+ READ_DIGITS(n, 1);
+ } else {
+ READ_DIGITS(n, 2);
+ }
+ if (!valid_range_p(n, 1, 31))
+ fail();
+ set_hash("mday", n);
+ goto matched;
+ }
+
+ case 'F':
+ recur("%Y-%m-%d");
+ goto matched;
+
+ case 'G':
+ {
+ VALUE n;
+
+ if (NUM_PATTERN_P())
+ READ_DIGITS(n, 4)
+ else
+ READ_DIGITS_MAX(n)
+ set_hash("cwyear", n);
+ goto matched;
+ }
+
+ case 'g':
+ {
+ VALUE n;
+
+ READ_DIGITS(n, 2);
+ if (!valid_range_p(n, 0, 99))
+ fail();
+ set_hash("cwyear",n);
+ if (NIL_P(ref_hash("_cent")))
+ set_hash("_cent",
+ INT2FIX(f_ge_p(n, INT2FIX(69)) ? 19 : 20));
+ goto matched;
+ }
+
+ case 'H':
+ case 'k':
+ {
+ VALUE n;
+
+ if (str[si] == ' ') {
+ si++;
+ READ_DIGITS(n, 1);
+ } else {
+ READ_DIGITS(n, 2);
+ }
+ if (!valid_range_p(n, 0, 24))
+ fail();
+ set_hash("hour", n);
+ goto matched;
+ }
+
+ case 'I':
+ case 'l':
+ {
+ VALUE n;
+
+ if (str[si] == ' ') {
+ si++;
+ READ_DIGITS(n, 1);
+ } else {
+ READ_DIGITS(n, 2);
+ }
+ if (!valid_range_p(n, 1, 12))
+ fail();
+ set_hash("hour", n);
+ goto matched;
+ }
+
+ case 'j':
+ {
+ VALUE n;
+
+ READ_DIGITS(n, 3);
+ if (!valid_range_p(n, 1, 366))
+ fail();
+ set_hash("yday", n);
+ goto matched;
+ }
+
+ case 'L':
+ case 'N':
+ {
+ VALUE n;
+ int sign = 1;
+ size_t osi;
+
+ if (issign(str[si])) {
+ if (str[si] == '-')
+ sign = -1;
+ si++;
+ }
+ osi = si;
+ if (NUM_PATTERN_P())
+ READ_DIGITS(n, c == 'L' ? 3 : 9)
+ else
+ READ_DIGITS_MAX(n)
+ if (sign == -1)
+ n = f_negate(n);
+ set_hash("sec_fraction",
+ rb_rational_new2(n,
+ f_expt(INT2FIX(10),
+ ULONG2NUM(si - osi))));
+ goto matched;
+ }
+
+ case 'M':
+ {
+ VALUE n;
+
+ READ_DIGITS(n, 2);
+ if (!valid_range_p(n, 0, 59))
+ fail();
+ set_hash("min", n);
+ goto matched;
+ }
+
+ case 'm':
+ {
+ VALUE n;
+
+ READ_DIGITS(n, 2);
+ if (!valid_range_p(n, 1, 12))
+ fail();
+ set_hash("mon", n);
+ goto matched;
+ }
+
+ case 'n':
+ case 't':
+ recur(" ");
+ goto matched;
+
+ case 'P':
+ case 'p':
+ {
+ int i;
+
+ for (i = 0; i < 4; i++) {
+ size_t l = strlen(merid_names[i]);
+ if (strncasecmp(merid_names[i], &str[si], l) == 0) {
+ si += l;
+ set_hash("_merid", INT2FIX((i % 2) == 0 ? 0 : 12));
+ goto matched;
+ }
+ }
+ fail();
+ }
+
+ case 'Q':
+ {
+ VALUE n;
+ int sign = 1;
+
+ if (str[si] == '-') {
+ sign = -1;
+ si++;
+ }
+ READ_DIGITS_MAX(n);
+ if (sign == -1)
+ n = f_negate(n);
+ set_hash("seconds",
+ rb_rational_new2(n,
+ f_expt(INT2FIX(10),
+ INT2FIX(3))));
+ goto matched;
+ }
+
+ case 'R':
+ recur("%H:%M");
+ goto matched;
+
+ case 'r':
+ recur("%I:%M:%S %p");
+ goto matched;
+
+ case 'S':
+ {
+ VALUE n;
+
+ READ_DIGITS(n, 2);
+ if (!valid_range_p(n, 0, 60))
+ fail();
+ set_hash("sec", n);
+ goto matched;
+ }
+
+ case 's':
+ {
+ VALUE n;
+ int sign = 1;
+
+ if (str[si] == '-') {
+ sign = -1;
+ si++;
+ }
+ READ_DIGITS_MAX(n);
+ if (sign == -1)
+ n = f_negate(n);
+ set_hash("seconds", n);
+ goto matched;
+ }
+
+ case 'T':
+ recur("%H:%M:%S");
+ goto matched;
+
+ case 'U':
+ case 'W':
+ {
+ VALUE n;
+
+ READ_DIGITS(n, 2);
+ if (!valid_range_p(n, 0, 53))
+ fail();
+ set_hash(c == 'U' ? "wnum0" : "wnum1", n);
+ goto matched;
+ }
+
+ case 'u':
+ {
+ VALUE n;
+
+ READ_DIGITS(n, 1);
+ if (!valid_range_p(n, 1, 7))
+ fail();
+ set_hash("cwday", n);
+ goto matched;
+ }
+
+ case 'V':
+ {
+ VALUE n;
+
+ READ_DIGITS(n, 2);
+ if (!valid_range_p(n, 1, 53))
+ fail();
+ set_hash("cweek", n);
+ goto matched;
+ }
+
+ case 'v':
+ recur("%e-%b-%Y");
+ goto matched;
+
+ case 'w':
+ {
+ VALUE n;
+
+ READ_DIGITS(n, 1);
+ if (!valid_range_p(n, 0, 6))
+ fail();
+ set_hash("wday", n);
+ goto matched;
+ }
+
+ case 'X':
+ recur("%H:%M:%S");
+ goto matched;
+
+ case 'x':
+ recur("%m/%d/%y");
+ goto matched;
+
+ case 'Y':
+ {
+ VALUE n;
+ int sign = 1;
+
+ if (issign(str[si])) {
+ if (str[si] == '-')
+ sign = -1;
+ si++;
+ }
+ if (NUM_PATTERN_P())
+ READ_DIGITS(n, 4)
+ else
+ READ_DIGITS_MAX(n)
+ if (sign == -1)
+ n = f_negate(n);
+ set_hash("year", n);
+ goto matched;
+ }
+
+ case 'y':
+ {
+ VALUE n;
+ int sign = 1;
+
+ READ_DIGITS(n, 2);
+ if (!valid_range_p(n, 0, 99))
+ fail();
+ if (sign == -1)
+ n = f_negate(n);
+ set_hash("year", n);
+ if (NIL_P(ref_hash("_cent")))
+ set_hash("_cent",
+ INT2FIX(f_ge_p(n, INT2FIX(69)) ? 19 : 20));
+ goto matched;
+ }
+
+ case 'Z':
+ case 'z':
+ {
+ static const char pat_source[] =
+ "\\A("
+ "(?:gmt|utc?)?[-+]\\d+(?:[,.:]\\d+(?::\\d+)?)?"
+ "|(?-i:[[:alpha:].\\s]+)(?:standard|daylight)\\s+time\\b"
+ "|(?-i:[[:alpha:]]+)(?:\\s+dst)?\\b"
+ ")";
+ static VALUE pat = Qnil;
+ VALUE m, b;
+
+ if (NIL_P(pat)) {
+ pat = rb_reg_new(pat_source, sizeof pat_source - 1,
+ ONIG_OPTION_IGNORECASE);
+ rb_gc_register_mark_object(pat);
+ }
+
+ b = rb_backref_get();
+ rb_match_busy(b);
+ m = f_match(pat, rb_usascii_str_new2(&str[si]));
+
+ if (!NIL_P(m)) {
+ VALUE s, l, o;
+
+ s = rb_reg_nth_match(1, m);
+ l = f_end(m, INT2FIX(0));
+ o = date_zone_to_diff(s);
+ si += NUM2LONG(l);
+ set_hash("zone", s);
+ set_hash("offset", o);
+ rb_backref_set(b);
+ goto matched;
+ }
+ rb_backref_set(b);
+ fail();
+ }
+
+ case '%':
+ if (str[si] != '%')
+ fail();
+ si++;
+ goto matched;
+
+ case '+':
+ recur("%a %b %e %H:%M:%S %Z %Y");
+ goto matched;
+
+ default:
+ if (str[si] != '%')
+ fail();
+ si++;
+ if (fi < flen)
+ if (str[si] != fmt[fi])
+ fail();
+ si++;
+ goto matched;
+ }
+ case ' ':
+ case '\t':
+ case '\n':
+ case '\v':
+ case '\f':
+ case '\r':
+ while (isspace((unsigned char)str[si]))
+ si++;
+ fi++;
+ break;
+ default:
+ ordinal:
+ if (str[si] != fmt[fi])
+ fail();
+ si++;
+ fi++;
+ break;
+ matched:
+ fi++;
+ break;
+ }
+ }
+
+ return si;
+}
+
+VALUE
+date__strptime(const char *str, size_t slen,
+ const char *fmt, size_t flen, VALUE hash)
+{
+ size_t si;
+ VALUE cent, merid;
+
+ si = date__strptime_internal(str, slen, fmt, flen, hash);
+
+ if (slen > si) {
+ VALUE s;
+
+ s = rb_usascii_str_new(&str[si], slen - si);
+ set_hash("leftover", s);
+ }
+
+ if (fail_p())
+ return Qnil;
+
+ cent = ref_hash("_cent");
+ if (!NIL_P(cent)) {
+ VALUE year;
+
+ year = ref_hash("cwyear");
+ if (!NIL_P(year))
+ set_hash("cwyear", f_add(year, f_mul(cent, INT2FIX(100))));
+ year = ref_hash("year");
+ if (!NIL_P(year))
+ set_hash("year", f_add(year, f_mul(cent, INT2FIX(100))));
+ del_hash("_cent");
+ }
+
+ merid = ref_hash("_merid");
+ if (!NIL_P(merid)) {
+ VALUE hour;
+
+ hour = ref_hash("hour");
+ if (!NIL_P(hour)) {
+ hour = f_mod(hour, INT2FIX(12));
+ set_hash("hour", f_add(hour, merid));
+ }
+ del_hash("_merid");
+ }
+
+ return hash;
+}
+
+/*
+Local variables:
+c-file-style: "ruby"
+End:
+*/
diff --git a/jni/ruby/ext/date/date_tmx.h b/jni/ruby/ext/date/date_tmx.h
new file mode 100644
index 0000000..ed06501
--- /dev/null
+++ b/jni/ruby/ext/date/date_tmx.h
@@ -0,0 +1,56 @@
+#ifndef DATE_TMX_H
+#define DATE_TMX_H
+
+struct tmx_funcs {
+ VALUE (*year)(void *dat);
+ int (*yday)(void *dat);
+ int (*mon)(void *dat);
+ int (*mday)(void *dat);
+ VALUE (*cwyear)(void *dat);
+ int (*cweek)(void *dat);
+ int (*cwday)(void *dat);
+ int (*wnum0)(void *dat);
+ int (*wnum1)(void *dat);
+ int (*wday)(void *dat);
+ int (*hour)(void *dat);
+ int (*min)(void *dat);
+ int (*sec)(void *dat);
+ VALUE (*sec_fraction)(void *dat);
+ VALUE (*secs)(void *dat);
+ VALUE (*msecs)(void *dat);
+ int (*offset)(void *dat);
+ char *(*zone)(void *dat);
+};
+struct tmx {
+ void *dat;
+ struct tmx_funcs *funcs;
+};
+
+#define tmx_attr(x) (tmx->funcs->x)(tmx->dat)
+
+#define tmx_year tmx_attr(year)
+#define tmx_yday tmx_attr(yday)
+#define tmx_mon tmx_attr(mon)
+#define tmx_mday tmx_attr(mday)
+#define tmx_cwyear tmx_attr(cwyear)
+#define tmx_cweek tmx_attr(cweek)
+#define tmx_cwday tmx_attr(cwday)
+#define tmx_wnum0 tmx_attr(wnum0)
+#define tmx_wnum1 tmx_attr(wnum1)
+#define tmx_wday tmx_attr(wday)
+#define tmx_hour tmx_attr(hour)
+#define tmx_min tmx_attr(min)
+#define tmx_sec tmx_attr(sec)
+#define tmx_sec_fraction tmx_attr(sec_fraction)
+#define tmx_secs tmx_attr(secs)
+#define tmx_msecs tmx_attr(msecs)
+#define tmx_offset tmx_attr(offset)
+#define tmx_zone tmx_attr(zone)
+
+#endif
+
+/*
+Local variables:
+c-file-style: "ruby"
+End:
+*/
diff --git a/jni/ruby/ext/date/depend b/jni/ruby/ext/date/depend
new file mode 100644
index 0000000..a5444e3
--- /dev/null
+++ b/jni/ruby/ext/date/depend
@@ -0,0 +1,53 @@
+# AUTOGENERATED DEPENDENCIES START
+date_core.o: $(RUBY_EXTCONF_H)
+date_core.o: $(arch_hdrdir)/ruby/config.h
+date_core.o: $(hdrdir)/ruby/defines.h
+date_core.o: $(hdrdir)/ruby/encoding.h
+date_core.o: $(hdrdir)/ruby/intern.h
+date_core.o: $(hdrdir)/ruby/missing.h
+date_core.o: $(hdrdir)/ruby/oniguruma.h
+date_core.o: $(hdrdir)/ruby/ruby.h
+date_core.o: $(hdrdir)/ruby/st.h
+date_core.o: $(hdrdir)/ruby/subst.h
+date_core.o: $(top_srcdir)/include/ruby.h
+date_core.o: date_core.c
+date_core.o: date_tmx.h
+date_parse.o: $(RUBY_EXTCONF_H)
+date_parse.o: $(arch_hdrdir)/ruby/config.h
+date_parse.o: $(hdrdir)/ruby/defines.h
+date_parse.o: $(hdrdir)/ruby/encoding.h
+date_parse.o: $(hdrdir)/ruby/intern.h
+date_parse.o: $(hdrdir)/ruby/missing.h
+date_parse.o: $(hdrdir)/ruby/oniguruma.h
+date_parse.o: $(hdrdir)/ruby/re.h
+date_parse.o: $(hdrdir)/ruby/regex.h
+date_parse.o: $(hdrdir)/ruby/ruby.h
+date_parse.o: $(hdrdir)/ruby/st.h
+date_parse.o: $(hdrdir)/ruby/subst.h
+date_parse.o: $(top_srcdir)/include/ruby.h
+date_parse.o: date_parse.c
+date_strftime.o: $(RUBY_EXTCONF_H)
+date_strftime.o: $(arch_hdrdir)/ruby/config.h
+date_strftime.o: $(hdrdir)/ruby/defines.h
+date_strftime.o: $(hdrdir)/ruby/intern.h
+date_strftime.o: $(hdrdir)/ruby/missing.h
+date_strftime.o: $(hdrdir)/ruby/ruby.h
+date_strftime.o: $(hdrdir)/ruby/st.h
+date_strftime.o: $(hdrdir)/ruby/subst.h
+date_strftime.o: date_strftime.c
+date_strftime.o: date_tmx.h
+date_strptime.o: $(RUBY_EXTCONF_H)
+date_strptime.o: $(arch_hdrdir)/ruby/config.h
+date_strptime.o: $(hdrdir)/ruby/defines.h
+date_strptime.o: $(hdrdir)/ruby/encoding.h
+date_strptime.o: $(hdrdir)/ruby/intern.h
+date_strptime.o: $(hdrdir)/ruby/missing.h
+date_strptime.o: $(hdrdir)/ruby/oniguruma.h
+date_strptime.o: $(hdrdir)/ruby/re.h
+date_strptime.o: $(hdrdir)/ruby/regex.h
+date_strptime.o: $(hdrdir)/ruby/ruby.h
+date_strptime.o: $(hdrdir)/ruby/st.h
+date_strptime.o: $(hdrdir)/ruby/subst.h
+date_strptime.o: $(top_srcdir)/include/ruby.h
+date_strptime.o: date_strptime.c
+# AUTOGENERATED DEPENDENCIES END
diff --git a/jni/ruby/ext/date/extconf.h b/jni/ruby/ext/date/extconf.h
new file mode 100644
index 0000000..cda0cc8
--- /dev/null
+++ b/jni/ruby/ext/date/extconf.h
@@ -0,0 +1,3 @@
+#ifndef EXTCONF_H
+#define EXTCONF_H
+#endif
diff --git a/jni/ruby/ext/date/extconf.rb b/jni/ruby/ext/date/extconf.rb
new file mode 100644
index 0000000..6f479ea
--- /dev/null
+++ b/jni/ruby/ext/date/extconf.rb
@@ -0,0 +1,5 @@
+require 'mkmf'
+if try_cflags("-std=iso9899:1999")
+ $CFLAGS += " " << "-std=iso9899:1999"
+end
+create_makefile('date_core')
diff --git a/jni/ruby/ext/date/lib/date.rb b/jni/ruby/ext/date/lib/date.rb
new file mode 100644
index 0000000..4268661
--- /dev/null
+++ b/jni/ruby/ext/date/lib/date.rb
@@ -0,0 +1,60 @@
+# date.rb: Written by Tadayoshi Funaba 1998-2011
+
+require 'date_core'
+
+class Date
+
+ class Infinity < Numeric # :nodoc:
+
+ include Comparable
+
+ def initialize(d=1) @d = d <=> 0 end
+
+ def d() @d end
+
+ protected :d
+
+ def zero? () false end
+ def finite? () false end
+ def infinite? () d.nonzero? end
+ def nan? () d.zero? end
+
+ def abs() self.class.new end
+
+ def -@ () self.class.new(-d) end
+ def +@ () self.class.new(+d) end
+
+ def <=> (other)
+ case other
+ when Infinity; return d <=> other.d
+ when Numeric; return d
+ else
+ begin
+ l, r = other.coerce(self)
+ return l <=> r
+ rescue NoMethodError
+ end
+ end
+ nil
+ end
+
+ def coerce(other)
+ case other
+ when Numeric; return -d, d
+ else
+ super
+ end
+ end
+
+ def to_f
+ return 0 if @d == 0
+ if @d > 0
+ Float::INFINITY
+ else
+ -Float::INFINITY
+ end
+ end
+
+ end
+
+end
diff --git a/jni/ruby/ext/dbm/Makefile b/jni/ruby/ext/dbm/Makefile
new file mode 100644
index 0000000..dc3421d
--- /dev/null
+++ b/jni/ruby/ext/dbm/Makefile
@@ -0,0 +1,150 @@
+# ***DUMMY MAKEFILE***
+
+SHELL = /bin/sh
+
+# V=0 quiet, V=1 verbose. other values don't work.
+V = 0
+Q1 = $(V:1=)
+Q = $(Q1:0=@)
+ECHO1 = $(V:1=@:)
+ECHO = $(ECHO1:0=@echo)
+NULLCMD = :
+
+#### Start of system configuration section. ####
+top_srcdir = $(topdir)/.
+srcdir = $(top_srcdir)/ext/dbm
+topdir = ../..
+hdrdir = $(top_srcdir)/include
+arch_hdrdir = $(extout)/include/$(arch)
+PATH_SEPARATOR = :
+VPATH = $(srcdir):$(arch_hdrdir)/ruby:$(hdrdir)/ruby
+RUBYLIB =
+RUBYOPT = -
+prefix = $(DESTDIR)/usr/local
+rubysitearchprefix = $(rubylibprefix)/$(sitearch)
+rubyarchprefix = $(rubylibprefix)/$(arch)
+rubylibprefix = $(libdir)/$(RUBY_BASE_NAME)
+exec_prefix = $(prefix)
+vendorarchhdrdir = $(vendorhdrdir)/$(sitearch)
+sitearchhdrdir = $(sitehdrdir)/$(sitearch)
+rubyarchhdrdir = $(rubyhdrdir)/$(arch)
+vendorhdrdir = $(rubyhdrdir)/vendor_ruby
+sitehdrdir = $(rubyhdrdir)/site_ruby
+rubyhdrdir = $(includedir)/$(RUBY_VERSION_NAME)
+vendorarchdir = $(vendorlibdir)/$(sitearch)
+vendorlibdir = $(vendordir)/$(ruby_version)
+vendordir = $(rubylibprefix)/vendor_ruby
+sitearchdir = $(sitelibdir)/$(sitearch)
+sitelibdir = $(sitedir)/$(ruby_version)
+sitedir = $(rubylibprefix)/site_ruby
+rubyarchdir = $(rubylibdir)/$(arch)
+rubylibdir = $(rubylibprefix)/$(ruby_version)
+sitearchincludedir = $(includedir)/$(sitearch)
+archincludedir = $(includedir)/$(arch)
+sitearchlibdir = $(libdir)/$(sitearch)
+archlibdir = $(libdir)/$(arch)
+ridir = $(datarootdir)/$(RI_BASE_NAME)
+mandir = $(datarootdir)/man
+localedir = $(datarootdir)/locale
+libdir = $(exec_prefix)/lib
+psdir = $(docdir)
+pdfdir = $(docdir)
+dvidir = $(docdir)
+htmldir = $(docdir)
+infodir = $(datarootdir)/info
+docdir = $(datarootdir)/doc/$(PACKAGE)
+oldincludedir = $(DESTDIR)/usr/include
+includedir = $(prefix)/include
+localstatedir = $(prefix)/var
+sharedstatedir = $(prefix)/com
+sysconfdir = $(prefix)/etc
+datadir = $(datarootdir)
+datarootdir = $(prefix)/share
+libexecdir = $(exec_prefix)/libexec
+sbindir = $(exec_prefix)/sbin
+bindir = $(exec_prefix)/bin
+archdir = $(rubyarchdir)
+
+
+CC = gcc
+CXX = g++
+LIBRUBY = $(LIBRUBY_SO)
+LIBRUBY_A = lib$(RUBY_SO_NAME)-static.a
+LIBRUBYARG_SHARED = -Wl,-R$(libdir) -L$(libdir) -l$(RUBY_SO_NAME)
+LIBRUBYARG_STATIC = -Wl,-R$(libdir) -L$(libdir) -l$(RUBY_SO_NAME)-static
+empty =
+OUTFLAG = -o $(empty)
+COUTFLAG = -o $(empty)
+
+RUBY_EXTCONF_H =
+cflags = $(optflags) $(debugflags) $(warnflags)
+optflags = -O3 -fno-fast-math
+debugflags = -ggdb3
+warnflags = -Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wunused-variable -Wpointer-arith -Wwrite-strings -Wdeclaration-after-statement -Wimplicit-function-declaration -Wdeprecated-declarations -Wno-packed-bitfield-compat
+CCDLFLAGS = -fPIC
+CFLAGS = $(CCDLFLAGS) $(cflags) -fPIC $(ARCH_FLAG)
+INCFLAGS = -I. -I$(arch_hdrdir) -I$(hdrdir) -I$(srcdir)
+DEFS =
+CPPFLAGS = $(DEFS) $(cppflags)
+CXXFLAGS = $(CCDLFLAGS) $(cxxflags) $(ARCH_FLAG)
+ldflags = -L. -fstack-protector -rdynamic -Wl,-export-dynamic
+dldflags =
+ARCH_FLAG =
+DLDFLAGS = $(ldflags) $(dldflags) $(ARCH_FLAG)
+LDSHARED = $(CC) -shared
+LDSHAREDXX = $(CXX) -shared
+AR = ar
+EXEEXT =
+
+RUBY_INSTALL_NAME = $(RUBY_BASE_NAME)
+RUBY_SO_NAME = ruby
+RUBYW_INSTALL_NAME =
+RUBY_VERSION_NAME = $(RUBY_BASE_NAME)-$(ruby_version)
+RUBYW_BASE_NAME = rubyw
+RUBY_BASE_NAME = ruby
+
+arch = x86_64-linux
+sitearch = $(arch)
+ruby_version = 2.2.0
+ruby = $(topdir)/miniruby -I'$(topdir)' -I'$(top_srcdir)/lib' -I'$(extout)/$(arch)' -I'$(extout)/common'
+RUBY = $(ruby)
+ruby_headers = $(hdrdir)/ruby.h $(hdrdir)/ruby/ruby.h $(hdrdir)/ruby/defines.h $(hdrdir)/ruby/missing.h $(hdrdir)/ruby/intern.h $(hdrdir)/ruby/st.h $(hdrdir)/ruby/subst.h $(arch_hdrdir)/ruby/config.h
+
+RM = rm -f
+RM_RF = $(RUBY) -run -e rm -- -rf
+RMDIRS = rmdir --ignore-fail-on-non-empty -p
+MAKEDIRS = /bin/mkdir -p
+INSTALL = /usr/bin/install -c
+INSTALL_PROG = $(INSTALL) -m 0755
+INSTALL_DATA = $(INSTALL) -m 644
+COPY = cp
+TOUCH = exit >
+
+#### End of system configuration section. ####
+
+preload =
+CLEANFILES = mkmf.log
+DISTCLEANFILES =
+
+all install static install-so install-rb: Makefile
+.PHONY: all install static install-so install-rb
+.PHONY: clean clean-so clean-static clean-rb
+
+
+clean-static::
+clean-rb-default::
+clean-rb::
+clean-so::
+clean: clean-so clean-static clean-rb-default clean-rb
+ -$(Q)$(RM) $(CLEANLIBS) $(CLEANOBJS) $(CLEANFILES) .*.time
+
+distclean-rb-default::
+distclean-rb::
+distclean-so::
+distclean-static::
+distclean: clean distclean-so distclean-static distclean-rb-default distclean-rb
+ -$(Q)$(RM) Makefile $(RUBY_EXTCONF_H) conftest.* mkmf.log
+ -$(Q)$(RM) core ruby$(EXEEXT) *~ $(DISTCLEANFILES)
+ -$(Q)$(RMDIRS) $(DISTCLEANDIRS) 2> /dev/null || true
+
+realclean: distclean
diff --git a/jni/ruby/ext/dbm/dbm.c b/jni/ruby/ext/dbm/dbm.c
new file mode 100644
index 0000000..41648b4
--- /dev/null
+++ b/jni/ruby/ext/dbm/dbm.c
@@ -0,0 +1,1159 @@
+/************************************************
+
+ dbm.c -
+
+ $Author: nobu $
+ created at: Mon Jan 24 15:59:52 JST 1994
+
+ Copyright (C) 1995-2001 Yukihiro Matsumoto
+
+************************************************/
+
+#include "ruby.h"
+
+#ifdef HAVE_CDEFS_H
+# include <cdefs.h>
+#endif
+#ifdef HAVE_SYS_CDEFS_H
+# include <sys/cdefs.h>
+#endif
+#include DBM_HDR
+#include <fcntl.h>
+#include <errno.h>
+
+#define DSIZE_TYPE TYPEOF_DATUM_DSIZE
+#if SIZEOF_DATUM_DSIZE > SIZEOF_INT
+# define RSTRING_DSIZE(s) RSTRING_LEN(s)
+# define TOO_LONG(n) 0
+#else
+# define RSTRING_DSIZE(s) RSTRING_LENINT(s)
+# define TOO_LONG(n) ((long)(+(DSIZE_TYPE)(n)) != (n))
+#endif
+
+static VALUE rb_cDBM, rb_eDBMError;
+
+#define RUBY_DBM_RW_BIT 0x20000000
+
+struct dbmdata {
+ long di_size;
+ DBM *di_dbm;
+};
+
+static void
+closed_dbm(void)
+{
+ rb_raise(rb_eDBMError, "closed DBM file");
+}
+
+#define GetDBM(obj, dbmp) do {\
+ TypedData_Get_Struct((obj), struct dbmdata, &dbm_type, (dbmp));\
+ if ((dbmp) == 0) closed_dbm();\
+ if ((dbmp)->di_dbm == 0) closed_dbm();\
+} while (0)
+
+#define GetDBM2(obj, dbmp, dbm) do {\
+ GetDBM((obj), (dbmp));\
+ (dbm) = (dbmp)->di_dbm;\
+} while (0)
+
+static void
+free_dbm(void *ptr)
+{
+ struct dbmdata *dbmp = ptr;
+ if (dbmp) {
+ if (dbmp->di_dbm) dbm_close(dbmp->di_dbm);
+ xfree(dbmp);
+ }
+}
+
+static size_t
+memsize_dbm(const void *ptr)
+{
+ size_t size = 0;
+ const struct dbmdata *dbmp = ptr;
+ if (dbmp) {
+ size += sizeof(*dbmp);
+ if (dbmp->di_dbm) size += DBM_SIZEOF_DBM;
+ }
+ return size;
+}
+
+static const rb_data_type_t dbm_type = {
+ "dbm",
+ {0, free_dbm, memsize_dbm,},
+ 0, 0,
+ RUBY_TYPED_FREE_IMMEDIATELY,
+};
+
+/*
+ * call-seq:
+ * dbm.close
+ *
+ * Closes the database.
+ */
+static VALUE
+fdbm_close(VALUE obj)
+{
+ struct dbmdata *dbmp;
+
+ GetDBM(obj, dbmp);
+ dbm_close(dbmp->di_dbm);
+ dbmp->di_dbm = 0;
+
+ return Qnil;
+}
+
+/*
+ * call-seq:
+ * dbm.closed? -> true or false
+ *
+ * Returns true if the database is closed, false otherwise.
+ */
+static VALUE
+fdbm_closed(VALUE obj)
+{
+ struct dbmdata *dbmp;
+
+ TypedData_Get_Struct(obj, struct dbmdata, &dbm_type, dbmp);
+ if (dbmp == 0)
+ return Qtrue;
+ if (dbmp->di_dbm == 0)
+ return Qtrue;
+
+ return Qfalse;
+}
+
+static VALUE
+fdbm_alloc(VALUE klass)
+{
+ return TypedData_Wrap_Struct(klass, &dbm_type, 0);
+}
+
+/*
+ * call-seq:
+ * DBM.new(filename[, mode[, flags]]) -> dbm
+ *
+ * Open a dbm database with the specified name, which can include a directory
+ * path. Any file extensions needed will be supplied automatically by the dbm
+ * library. For example, Berkeley DB appends '.db', and GNU gdbm uses two
+ * physical files with extensions '.dir' and '.pag'.
+ *
+ * The mode should be an integer, as for Unix chmod.
+ *
+ * Flags should be one of READER, WRITER, WRCREAT or NEWDB.
+ */
+static VALUE
+fdbm_initialize(int argc, VALUE *argv, VALUE obj)
+{
+ volatile VALUE file;
+ VALUE vmode, vflags;
+ DBM *dbm;
+ struct dbmdata *dbmp;
+ int mode, flags = 0;
+
+ if (rb_scan_args(argc, argv, "12", &file, &vmode, &vflags) == 1) {
+ mode = 0666; /* default value */
+ }
+ else if (NIL_P(vmode)) {
+ mode = -1; /* return nil if DB not exist */
+ }
+ else {
+ mode = NUM2INT(vmode);
+ }
+
+ if (!NIL_P(vflags))
+ flags = NUM2INT(vflags);
+
+ FilePathValue(file);
+
+ /*
+ * Note:
+ * gdbm 1.10 works with O_CLOEXEC. gdbm 1.9.1 silently ignore it.
+ */
+#ifndef O_CLOEXEC
+# define O_CLOEXEC 0
+#endif
+
+ if (flags & RUBY_DBM_RW_BIT) {
+ flags &= ~RUBY_DBM_RW_BIT;
+ dbm = dbm_open(RSTRING_PTR(file), flags|O_CLOEXEC, mode);
+ }
+ else {
+ dbm = 0;
+ if (mode >= 0) {
+ dbm = dbm_open(RSTRING_PTR(file), O_RDWR|O_CREAT|O_CLOEXEC, mode);
+ }
+ if (!dbm) {
+ dbm = dbm_open(RSTRING_PTR(file), O_RDWR|O_CLOEXEC, 0);
+ }
+ if (!dbm) {
+ dbm = dbm_open(RSTRING_PTR(file), O_RDONLY|O_CLOEXEC, 0);
+ }
+ }
+
+ if (dbm) {
+ /*
+ * History of dbm_pagfno() and dbm_dirfno() in ndbm and its compatibles.
+ * (dbm_pagfno() and dbm_dirfno() is not standardized.)
+ *
+ * 1986: 4.3BSD provides ndbm.
+ * It provides dbm_pagfno() and dbm_dirfno() as macros.
+ * 1991: gdbm-1.5 provides them as functions.
+ * They returns a same descriptor.
+ * (Earlier releases may have the functions too.)
+ * 1991: Net/2 provides Berkeley DB.
+ * It doesn't provide dbm_pagfno() and dbm_dirfno().
+ * 1992: 4.4BSD Alpha provides Berkeley DB with dbm_dirfno() as a function.
+ * dbm_pagfno() is a macro as DBM_PAGFNO_NOT_AVAILABLE.
+ * 1997: Berkeley DB 2.0 is released by Sleepycat Software, Inc.
+ * It defines dbm_pagfno() and dbm_dirfno() as macros.
+ * 2011: gdbm-1.9 creates a separate dir file.
+ * dbm_pagfno() and dbm_dirfno() returns different descriptors.
+ */
+#if defined(HAVE_DBM_PAGFNO)
+ rb_fd_fix_cloexec(dbm_pagfno(dbm));
+#endif
+#if defined(HAVE_DBM_DIRFNO)
+ rb_fd_fix_cloexec(dbm_dirfno(dbm));
+#endif
+
+#if defined(RUBYDBM_DB_HEADER) && defined(HAVE_TYPE_DBC)
+ /* Disable Berkeley DB error messages such as:
+ * DB->put: attempt to modify a read-only database */
+ ((DBC*)dbm)->dbp->set_errfile(((DBC*)dbm)->dbp, NULL);
+#endif
+ }
+
+ if (!dbm) {
+ if (mode == -1) return Qnil;
+ rb_sys_fail_str(file);
+ }
+
+ dbmp = ALLOC(struct dbmdata);
+ DATA_PTR(obj) = dbmp;
+ dbmp->di_dbm = dbm;
+ dbmp->di_size = -1;
+
+ return obj;
+}
+
+/*
+ * call-seq:
+ * DBM.open(filename[, mode[, flags]]) -> dbm
+ * DBM.open(filename[, mode[, flags]]) {|dbm| block}
+ *
+ * Open a dbm database and yields it if a block is given. See also
+ * <code>DBM.new</code>.
+ */
+static VALUE
+fdbm_s_open(int argc, VALUE *argv, VALUE klass)
+{
+ VALUE obj = fdbm_alloc(klass);
+
+ if (NIL_P(fdbm_initialize(argc, argv, obj))) {
+ return Qnil;
+ }
+
+ if (rb_block_given_p()) {
+ return rb_ensure(rb_yield, obj, fdbm_close, obj);
+ }
+
+ return obj;
+}
+
+static VALUE
+fdbm_fetch(VALUE obj, VALUE keystr, VALUE ifnone)
+{
+ datum key, value;
+ struct dbmdata *dbmp;
+ DBM *dbm;
+ long len;
+
+ ExportStringValue(keystr);
+ len = RSTRING_LEN(keystr);
+ if (TOO_LONG(len)) goto not_found;
+ key.dptr = RSTRING_PTR(keystr);
+ key.dsize = (DSIZE_TYPE)len;
+
+ GetDBM2(obj, dbmp, dbm);
+ value = dbm_fetch(dbm, key);
+ if (value.dptr == 0) {
+ not_found:
+ if (NIL_P(ifnone) && rb_block_given_p()) {
+ keystr = rb_str_dup(keystr);
+ OBJ_TAINT(keystr);
+ return rb_yield(keystr);
+ }
+ return ifnone;
+ }
+ return rb_tainted_str_new(value.dptr, value.dsize);
+}
+
+/*
+ * call-seq:
+ * dbm[key] -> string value or nil
+ *
+ * Return a value from the database by locating the key string
+ * provided. If the key is not found, returns nil.
+ */
+static VALUE
+fdbm_aref(VALUE obj, VALUE keystr)
+{
+ return fdbm_fetch(obj, keystr, Qnil);
+}
+
+/*
+ * call-seq:
+ * dbm.fetch(key[, ifnone]) -> value
+ *
+ * Return a value from the database by locating the key string
+ * provided. If the key is not found, returns +ifnone+. If +ifnone+
+ * is not given, raises IndexError.
+ */
+static VALUE
+fdbm_fetch_m(int argc, VALUE *argv, VALUE obj)
+{
+ VALUE keystr, valstr, ifnone;
+
+ rb_scan_args(argc, argv, "11", &keystr, &ifnone);
+ valstr = fdbm_fetch(obj, keystr, ifnone);
+ if (argc == 1 && !rb_block_given_p() && NIL_P(valstr))
+ rb_raise(rb_eIndexError, "key not found");
+
+ return valstr;
+}
+
+/*
+ * call-seq:
+ * dbm.key(value) -> string
+ *
+ * Returns the key for the specified value.
+ */
+static VALUE
+fdbm_key(VALUE obj, VALUE valstr)
+{
+ datum key, val;
+ struct dbmdata *dbmp;
+ DBM *dbm;
+ long len;
+
+ ExportStringValue(valstr);
+ len = RSTRING_LEN(valstr);
+ if (TOO_LONG(len)) return Qnil;
+ val.dptr = RSTRING_PTR(valstr);
+ val.dsize = (DSIZE_TYPE)len;
+
+ GetDBM2(obj, dbmp, dbm);
+ for (key = dbm_firstkey(dbm); key.dptr; key = dbm_nextkey(dbm)) {
+ val = dbm_fetch(dbm, key);
+ if ((long)val.dsize == RSTRING_LEN(valstr) &&
+ memcmp(val.dptr, RSTRING_PTR(valstr), val.dsize) == 0) {
+ return rb_tainted_str_new(key.dptr, key.dsize);
+ }
+ }
+ return Qnil;
+}
+
+/* :nodoc: */
+static VALUE
+fdbm_index(VALUE hash, VALUE value)
+{
+ rb_warn("DBM#index is deprecated; use DBM#key");
+ return fdbm_key(hash, value);
+}
+
+/*
+ * call-seq:
+ * dbm.select {|key, value| block} -> array
+ *
+ * Returns a new array consisting of the [key, value] pairs for which the code
+ * block returns true.
+ */
+static VALUE
+fdbm_select(VALUE obj)
+{
+ VALUE new = rb_ary_new();
+ datum key, val;
+ DBM *dbm;
+ struct dbmdata *dbmp;
+
+ GetDBM2(obj, dbmp, dbm);
+ for (key = dbm_firstkey(dbm); key.dptr; key = dbm_nextkey(dbm)) {
+ VALUE assoc, v;
+ val = dbm_fetch(dbm, key);
+ assoc = rb_assoc_new(rb_tainted_str_new(key.dptr, key.dsize),
+ rb_tainted_str_new(val.dptr, val.dsize));
+ v = rb_yield(assoc);
+ if (RTEST(v)) {
+ rb_ary_push(new, assoc);
+ }
+ GetDBM2(obj, dbmp, dbm);
+ }
+
+ return new;
+}
+
+/*
+ * call-seq:
+ * dbm.values_at(key, ...) -> Array
+ *
+ * Returns an array containing the values associated with the given keys.
+ */
+static VALUE
+fdbm_values_at(int argc, VALUE *argv, VALUE obj)
+{
+ VALUE new = rb_ary_new2(argc);
+ int i;
+
+ for (i=0; i<argc; i++) {
+ rb_ary_push(new, fdbm_fetch(obj, argv[i], Qnil));
+ }
+
+ return new;
+}
+
+static void
+fdbm_modify(VALUE obj)
+{
+ if (OBJ_FROZEN(obj)) rb_error_frozen("DBM");
+}
+
+/*
+ * call-seq:
+ * dbm.delete(key)
+ *
+ * Deletes an entry from the database.
+ */
+static VALUE
+fdbm_delete(VALUE obj, VALUE keystr)
+{
+ datum key, value;
+ struct dbmdata *dbmp;
+ DBM *dbm;
+ VALUE valstr;
+ long len;
+
+ fdbm_modify(obj);
+ ExportStringValue(keystr);
+ len = RSTRING_LEN(keystr);
+ if (TOO_LONG(len)) goto not_found;
+ key.dptr = RSTRING_PTR(keystr);
+ key.dsize = (DSIZE_TYPE)len;
+
+ GetDBM2(obj, dbmp, dbm);
+
+ value = dbm_fetch(dbm, key);
+ if (value.dptr == 0) {
+ not_found:
+ if (rb_block_given_p()) return rb_yield(keystr);
+ return Qnil;
+ }
+
+ /* need to save value before dbm_delete() */
+ valstr = rb_tainted_str_new(value.dptr, value.dsize);
+
+ if (dbm_delete(dbm, key)) {
+ dbmp->di_size = -1;
+ rb_raise(rb_eDBMError, "dbm_delete failed");
+ }
+ else if (dbmp->di_size >= 0) {
+ dbmp->di_size--;
+ }
+ return valstr;
+}
+
+/*
+ * call-seq:
+ * dbm.shift() -> [key, value]
+ *
+ * Removes a [key, value] pair from the database, and returns it.
+ * If the database is empty, returns nil.
+ * The order in which values are removed/returned is not guaranteed.
+ */
+static VALUE
+fdbm_shift(VALUE obj)
+{
+ datum key, val;
+ struct dbmdata *dbmp;
+ DBM *dbm;
+ VALUE keystr, valstr;
+
+ fdbm_modify(obj);
+ GetDBM2(obj, dbmp, dbm);
+ dbmp->di_size = -1;
+
+ key = dbm_firstkey(dbm);
+ if (!key.dptr) return Qnil;
+ val = dbm_fetch(dbm, key);
+ keystr = rb_tainted_str_new(key.dptr, key.dsize);
+ valstr = rb_tainted_str_new(val.dptr, val.dsize);
+ dbm_delete(dbm, key);
+
+ return rb_assoc_new(keystr, valstr);
+}
+
+/*
+ * call-seq:
+ * dbm.reject! {|key, value| block} -> self
+ * dbm.delete_if {|key, value| block} -> self
+ *
+ * Deletes all entries for which the code block returns true.
+ * Returns self.
+ */
+static VALUE
+fdbm_delete_if(VALUE obj)
+{
+ datum key, val;
+ struct dbmdata *dbmp;
+ DBM *dbm;
+ VALUE keystr, valstr;
+ VALUE ret, ary = rb_ary_tmp_new(0);
+ int i, status = 0;
+ long n;
+
+ fdbm_modify(obj);
+ GetDBM2(obj, dbmp, dbm);
+ n = dbmp->di_size;
+ dbmp->di_size = -1;
+
+ for (key = dbm_firstkey(dbm); key.dptr; key = dbm_nextkey(dbm)) {
+ val = dbm_fetch(dbm, key);
+ keystr = rb_tainted_str_new(key.dptr, key.dsize);
+ OBJ_FREEZE(keystr);
+ valstr = rb_tainted_str_new(val.dptr, val.dsize);
+ ret = rb_protect(rb_yield, rb_assoc_new(rb_str_dup(keystr), valstr), &status);
+ if (status != 0) break;
+ if (RTEST(ret)) rb_ary_push(ary, keystr);
+ GetDBM2(obj, dbmp, dbm);
+ }
+
+ for (i = 0; i < RARRAY_LEN(ary); i++) {
+ keystr = RARRAY_PTR(ary)[i];
+ key.dptr = RSTRING_PTR(keystr);
+ key.dsize = (DSIZE_TYPE)RSTRING_LEN(keystr);
+ if (dbm_delete(dbm, key)) {
+ rb_raise(rb_eDBMError, "dbm_delete failed");
+ }
+ }
+ if (status) rb_jump_tag(status);
+ if (n > 0) dbmp->di_size = n - RARRAY_LEN(ary);
+ rb_ary_clear(ary);
+
+ return obj;
+}
+
+/*
+ * call-seq:
+ * dbm.clear
+ *
+ * Deletes all data from the database.
+ */
+static VALUE
+fdbm_clear(VALUE obj)
+{
+ datum key;
+ struct dbmdata *dbmp;
+ DBM *dbm;
+
+ fdbm_modify(obj);
+ GetDBM2(obj, dbmp, dbm);
+ dbmp->di_size = -1;
+ while (key = dbm_firstkey(dbm), key.dptr) {
+ if (dbm_delete(dbm, key)) {
+ rb_raise(rb_eDBMError, "dbm_delete failed");
+ }
+ }
+ dbmp->di_size = 0;
+
+ return obj;
+}
+
+/*
+ * call-seq:
+ * dbm.invert -> hash
+ *
+ * Returns a Hash (not a DBM database) created by using each value in the
+ * database as a key, with the corresponding key as its value.
+ */
+static VALUE
+fdbm_invert(VALUE obj)
+{
+ datum key, val;
+ struct dbmdata *dbmp;
+ DBM *dbm;
+ VALUE keystr, valstr;
+ VALUE hash = rb_hash_new();
+
+ GetDBM2(obj, dbmp, dbm);
+ for (key = dbm_firstkey(dbm); key.dptr; key = dbm_nextkey(dbm)) {
+ val = dbm_fetch(dbm, key);
+ keystr = rb_tainted_str_new(key.dptr, key.dsize);
+ valstr = rb_tainted_str_new(val.dptr, val.dsize);
+ rb_hash_aset(hash, valstr, keystr);
+ }
+ return hash;
+}
+
+static VALUE fdbm_store(VALUE,VALUE,VALUE);
+
+static VALUE
+update_i(RB_BLOCK_CALL_FUNC_ARGLIST(pair, dbm))
+{
+ Check_Type(pair, T_ARRAY);
+ if (RARRAY_LEN(pair) < 2) {
+ rb_raise(rb_eArgError, "pair must be [key, value]");
+ }
+ fdbm_store(dbm, RARRAY_PTR(pair)[0], RARRAY_PTR(pair)[1]);
+ return Qnil;
+}
+
+/*
+ * call-seq:
+ * dbm.update(obj)
+ *
+ * Updates the database with multiple values from the specified object.
+ * Takes any object which implements the each_pair method, including
+ * Hash and DBM objects.
+ */
+static VALUE
+fdbm_update(VALUE obj, VALUE other)
+{
+ rb_block_call(other, rb_intern("each_pair"), 0, 0, update_i, obj);
+ return obj;
+}
+
+/*
+ * call-seq:
+ * dbm.replace(obj)
+ *
+ * Replaces the contents of the database with the contents of the specified
+ * object. Takes any object which implements the each_pair method, including
+ * Hash and DBM objects.
+ */
+static VALUE
+fdbm_replace(VALUE obj, VALUE other)
+{
+ fdbm_clear(obj);
+ rb_block_call(other, rb_intern("each_pair"), 0, 0, update_i, obj);
+ return obj;
+}
+
+/*
+ * call-seq:
+ * dbm.store(key, value) -> value
+ * dbm[key] = value
+ *
+ * Stores the specified string value in the database, indexed via the
+ * string key provided.
+ */
+static VALUE
+fdbm_store(VALUE obj, VALUE keystr, VALUE valstr)
+{
+ datum key, val;
+ struct dbmdata *dbmp;
+ DBM *dbm;
+
+ fdbm_modify(obj);
+ keystr = rb_obj_as_string(keystr);
+ valstr = rb_obj_as_string(valstr);
+
+ key.dptr = RSTRING_PTR(keystr);
+ key.dsize = RSTRING_DSIZE(keystr);
+
+ val.dptr = RSTRING_PTR(valstr);
+ val.dsize = RSTRING_DSIZE(valstr);
+
+ GetDBM2(obj, dbmp, dbm);
+ dbmp->di_size = -1;
+ if (dbm_store(dbm, key, val, DBM_REPLACE)) {
+ dbm_clearerr(dbm);
+ if (errno == EPERM) rb_sys_fail(0);
+ rb_raise(rb_eDBMError, "dbm_store failed");
+ }
+
+ return valstr;
+}
+
+/*
+ * call-seq:
+ * dbm.length -> integer
+ * dbm.size -> integer
+ *
+ * Returns the number of entries in the database.
+ */
+static VALUE
+fdbm_length(VALUE obj)
+{
+ datum key;
+ struct dbmdata *dbmp;
+ DBM *dbm;
+ int i = 0;
+
+ GetDBM2(obj, dbmp, dbm);
+ if (dbmp->di_size > 0) return INT2FIX(dbmp->di_size);
+
+ for (key = dbm_firstkey(dbm); key.dptr; key = dbm_nextkey(dbm)) {
+ i++;
+ }
+ dbmp->di_size = i;
+
+ return INT2FIX(i);
+}
+
+/*
+ * call-seq:
+ * dbm.empty?
+ *
+ * Returns true if the database is empty, false otherwise.
+ */
+static VALUE
+fdbm_empty_p(VALUE obj)
+{
+ datum key;
+ struct dbmdata *dbmp;
+ DBM *dbm;
+
+ GetDBM2(obj, dbmp, dbm);
+ if (dbmp->di_size < 0) {
+ dbm = dbmp->di_dbm;
+
+ for (key = dbm_firstkey(dbm); key.dptr; key = dbm_nextkey(dbm)) {
+ return Qfalse;
+ }
+ }
+ else {
+ if (dbmp->di_size)
+ return Qfalse;
+ }
+ return Qtrue;
+}
+
+/*
+ * call-seq:
+ * dbm.each_value {|value| block} -> self
+ *
+ * Calls the block once for each value string in the database. Returns self.
+ */
+static VALUE
+fdbm_each_value(VALUE obj)
+{
+ datum key, val;
+ struct dbmdata *dbmp;
+ DBM *dbm;
+
+ RETURN_ENUMERATOR(obj, 0, 0);
+
+ GetDBM2(obj, dbmp, dbm);
+ for (key = dbm_firstkey(dbm); key.dptr; key = dbm_nextkey(dbm)) {
+ val = dbm_fetch(dbm, key);
+ rb_yield(rb_tainted_str_new(val.dptr, val.dsize));
+ GetDBM2(obj, dbmp, dbm);
+ }
+ return obj;
+}
+
+/*
+ * call-seq:
+ * dbm.each_key {|key| block} -> self
+ *
+ * Calls the block once for each key string in the database. Returns self.
+ */
+static VALUE
+fdbm_each_key(VALUE obj)
+{
+ datum key;
+ struct dbmdata *dbmp;
+ DBM *dbm;
+
+ RETURN_ENUMERATOR(obj, 0, 0);
+
+ GetDBM2(obj, dbmp, dbm);
+ for (key = dbm_firstkey(dbm); key.dptr; key = dbm_nextkey(dbm)) {
+ rb_yield(rb_tainted_str_new(key.dptr, key.dsize));
+ GetDBM2(obj, dbmp, dbm);
+ }
+ return obj;
+}
+
+/*
+ * call-seq:
+ * dbm.each_pair {|key,value| block} -> self
+ *
+ * Calls the block once for each [key, value] pair in the database.
+ * Returns self.
+ */
+static VALUE
+fdbm_each_pair(VALUE obj)
+{
+ datum key, val;
+ DBM *dbm;
+ struct dbmdata *dbmp;
+ VALUE keystr, valstr;
+
+ RETURN_ENUMERATOR(obj, 0, 0);
+
+ GetDBM2(obj, dbmp, dbm);
+
+ for (key = dbm_firstkey(dbm); key.dptr; key = dbm_nextkey(dbm)) {
+ val = dbm_fetch(dbm, key);
+ keystr = rb_tainted_str_new(key.dptr, key.dsize);
+ valstr = rb_tainted_str_new(val.dptr, val.dsize);
+ rb_yield(rb_assoc_new(keystr, valstr));
+ GetDBM2(obj, dbmp, dbm);
+ }
+
+ return obj;
+}
+
+/*
+ * call-seq:
+ * dbm.keys -> array
+ *
+ * Returns an array of all the string keys in the database.
+ */
+static VALUE
+fdbm_keys(VALUE obj)
+{
+ datum key;
+ struct dbmdata *dbmp;
+ DBM *dbm;
+ VALUE ary;
+
+ GetDBM2(obj, dbmp, dbm);
+
+ ary = rb_ary_new();
+ for (key = dbm_firstkey(dbm); key.dptr; key = dbm_nextkey(dbm)) {
+ rb_ary_push(ary, rb_tainted_str_new(key.dptr, key.dsize));
+ }
+
+ return ary;
+}
+
+/*
+ * call-seq:
+ * dbm.values -> array
+ *
+ * Returns an array of all the string values in the database.
+ */
+static VALUE
+fdbm_values(VALUE obj)
+{
+ datum key, val;
+ struct dbmdata *dbmp;
+ DBM *dbm;
+ VALUE ary;
+
+ GetDBM2(obj, dbmp, dbm);
+ ary = rb_ary_new();
+ for (key = dbm_firstkey(dbm); key.dptr; key = dbm_nextkey(dbm)) {
+ val = dbm_fetch(dbm, key);
+ rb_ary_push(ary, rb_tainted_str_new(val.dptr, val.dsize));
+ }
+
+ return ary;
+}
+
+/*
+ * call-seq:
+ * dbm.include?(key) -> boolean
+ * dbm.has_key?(key) -> boolean
+ * dbm.member?(key) -> boolean
+ * dbm.key?(key) -> boolean
+ *
+ * Returns true if the database contains the specified key, false otherwise.
+ */
+static VALUE
+fdbm_has_key(VALUE obj, VALUE keystr)
+{
+ datum key, val;
+ struct dbmdata *dbmp;
+ DBM *dbm;
+ long len;
+
+ ExportStringValue(keystr);
+ len = RSTRING_LEN(keystr);
+ if (TOO_LONG(len)) return Qfalse;
+ key.dptr = RSTRING_PTR(keystr);
+ key.dsize = (DSIZE_TYPE)len;
+
+ GetDBM2(obj, dbmp, dbm);
+ val = dbm_fetch(dbm, key);
+ if (val.dptr) return Qtrue;
+ return Qfalse;
+}
+
+/*
+ * call-seq:
+ * dbm.has_value?(value) -> boolean
+ * dbm.value?(value) -> boolean
+ *
+ * Returns true if the database contains the specified string value, false
+ * otherwise.
+ */
+static VALUE
+fdbm_has_value(VALUE obj, VALUE valstr)
+{
+ datum key, val;
+ struct dbmdata *dbmp;
+ DBM *dbm;
+ long len;
+
+ ExportStringValue(valstr);
+ len = RSTRING_LEN(valstr);
+ if (TOO_LONG(len)) return Qfalse;
+ val.dptr = RSTRING_PTR(valstr);
+ val.dsize = (DSIZE_TYPE)len;
+
+ GetDBM2(obj, dbmp, dbm);
+ for (key = dbm_firstkey(dbm); key.dptr; key = dbm_nextkey(dbm)) {
+ val = dbm_fetch(dbm, key);
+ if ((DSIZE_TYPE)val.dsize == (DSIZE_TYPE)RSTRING_LEN(valstr) &&
+ memcmp(val.dptr, RSTRING_PTR(valstr), val.dsize) == 0)
+ return Qtrue;
+ }
+ return Qfalse;
+}
+
+/*
+ * call-seq:
+ * dbm.to_a -> array
+ *
+ * Converts the contents of the database to an array of [key, value] arrays,
+ * and returns it.
+ */
+static VALUE
+fdbm_to_a(VALUE obj)
+{
+ datum key, val;
+ struct dbmdata *dbmp;
+ DBM *dbm;
+ VALUE ary;
+
+ GetDBM2(obj, dbmp, dbm);
+ ary = rb_ary_new();
+ for (key = dbm_firstkey(dbm); key.dptr; key = dbm_nextkey(dbm)) {
+ val = dbm_fetch(dbm, key);
+ rb_ary_push(ary, rb_assoc_new(rb_tainted_str_new(key.dptr, key.dsize),
+ rb_tainted_str_new(val.dptr, val.dsize)));
+ }
+
+ return ary;
+}
+
+/*
+ * call-seq:
+ * dbm.to_hash -> hash
+ *
+ * Converts the contents of the database to an in-memory Hash object, and
+ * returns it.
+ */
+static VALUE
+fdbm_to_hash(VALUE obj)
+{
+ datum key, val;
+ struct dbmdata *dbmp;
+ DBM *dbm;
+ VALUE hash;
+
+ GetDBM2(obj, dbmp, dbm);
+ hash = rb_hash_new();
+ for (key = dbm_firstkey(dbm); key.dptr; key = dbm_nextkey(dbm)) {
+ val = dbm_fetch(dbm, key);
+ rb_hash_aset(hash, rb_tainted_str_new(key.dptr, key.dsize),
+ rb_tainted_str_new(val.dptr, val.dsize));
+ }
+
+ return hash;
+}
+
+/*
+ * call-seq:
+ * dbm.reject {|key,value| block} -> Hash
+ *
+ * Converts the contents of the database to an in-memory Hash, then calls
+ * Hash#reject with the specified code block, returning a new Hash.
+ */
+static VALUE
+fdbm_reject(VALUE obj)
+{
+ return rb_hash_delete_if(fdbm_to_hash(obj));
+}
+
+/*
+ * == Introduction
+ *
+ * The DBM class provides a wrapper to a Unix-style
+ * {dbm}[http://en.wikipedia.org/wiki/Dbm] or Database Manager library.
+ *
+ * Dbm databases do not have tables or columns; they are simple key-value
+ * data stores, like a Ruby Hash except not resident in RAM. Keys and values
+ * must be strings.
+ *
+ * The exact library used depends on how Ruby was compiled. It could be any
+ * of the following:
+ *
+ * - The original ndbm library is released in 4.3BSD.
+ * It is based on dbm library in Unix Version 7 but has different API to
+ * support multiple databases in a process.
+ * - {Berkeley DB}[http://en.wikipedia.org/wiki/Berkeley_DB] versions
+ * 1 thru 5, also known as BDB and Sleepycat DB, now owned by Oracle
+ * Corporation.
+ * - Berkeley DB 1.x, still found in 4.4BSD derivatives (FreeBSD, OpenBSD, etc).
+ * - {gdbm}[http://www.gnu.org/software/gdbm/], the GNU implementation of dbm.
+ * - {qdbm}[http://fallabs.com/qdbm/index.html], another open source
+ * reimplementation of dbm.
+ *
+ * All of these dbm implementations have their own Ruby interfaces
+ * available, which provide richer (but varying) APIs.
+ *
+ * == Cautions
+ *
+ * Before you decide to use DBM, there are some issues you should consider:
+ *
+ * - Each implementation of dbm has its own file format. Generally, dbm
+ * libraries will not read each other's files. This makes dbm files
+ * a bad choice for data exchange.
+ *
+ * - Even running the same OS and the same dbm implementation, the database
+ * file format may depend on the CPU architecture. For example, files may
+ * not be portable between PowerPC and 386, or between 32 and 64 bit Linux.
+ *
+ * - Different versions of Berkeley DB use different file formats. A change to
+ * the OS may therefore break DBM access to existing files.
+ *
+ * - Data size limits vary between implementations. Original Berkeley DB was
+ * limited to 2GB of data. Dbm libraries also sometimes limit the total
+ * size of a key/value pair, and the total size of all the keys that hash
+ * to the same value. These limits can be as little as 512 bytes. That said,
+ * gdbm and recent versions of Berkeley DB do away with these limits.
+ *
+ * Given the above cautions, DBM is not a good choice for long term storage of
+ * important data. It is probably best used as a fast and easy alternative
+ * to a Hash for processing large amounts of data.
+ *
+ * == Example
+ *
+ * require 'dbm'
+ * db = DBM.open('rfcs', 666, DBM::WRCREAT)
+ * db['822'] = 'Standard for the Format of ARPA Internet Text Messages'
+ * db['1123'] = 'Requirements for Internet Hosts - Application and Support'
+ * db['3068'] = 'An Anycast Prefix for 6to4 Relay Routers'
+ * puts db['822']
+ */
+void
+Init_dbm(void)
+{
+ rb_cDBM = rb_define_class("DBM", rb_cObject);
+ /* Document-class: DBMError
+ * Exception class used to return errors from the dbm library.
+ */
+ rb_eDBMError = rb_define_class("DBMError", rb_eStandardError);
+ rb_include_module(rb_cDBM, rb_mEnumerable);
+
+ rb_define_alloc_func(rb_cDBM, fdbm_alloc);
+ rb_define_singleton_method(rb_cDBM, "open", fdbm_s_open, -1);
+
+ rb_define_method(rb_cDBM, "initialize", fdbm_initialize, -1);
+ rb_define_method(rb_cDBM, "close", fdbm_close, 0);
+ rb_define_method(rb_cDBM, "closed?", fdbm_closed, 0);
+ rb_define_method(rb_cDBM, "[]", fdbm_aref, 1);
+ rb_define_method(rb_cDBM, "fetch", fdbm_fetch_m, -1);
+ rb_define_method(rb_cDBM, "[]=", fdbm_store, 2);
+ rb_define_method(rb_cDBM, "store", fdbm_store, 2);
+ rb_define_method(rb_cDBM, "index", fdbm_index, 1);
+ rb_define_method(rb_cDBM, "key", fdbm_key, 1);
+ rb_define_method(rb_cDBM, "select", fdbm_select, 0);
+ rb_define_method(rb_cDBM, "values_at", fdbm_values_at, -1);
+ rb_define_method(rb_cDBM, "length", fdbm_length, 0);
+ rb_define_method(rb_cDBM, "size", fdbm_length, 0);
+ rb_define_method(rb_cDBM, "empty?", fdbm_empty_p, 0);
+ rb_define_method(rb_cDBM, "each", fdbm_each_pair, 0);
+ rb_define_method(rb_cDBM, "each_value", fdbm_each_value, 0);
+ rb_define_method(rb_cDBM, "each_key", fdbm_each_key, 0);
+ rb_define_method(rb_cDBM, "each_pair", fdbm_each_pair, 0);
+ rb_define_method(rb_cDBM, "keys", fdbm_keys, 0);
+ rb_define_method(rb_cDBM, "values", fdbm_values, 0);
+ rb_define_method(rb_cDBM, "shift", fdbm_shift, 0);
+ rb_define_method(rb_cDBM, "delete", fdbm_delete, 1);
+ rb_define_method(rb_cDBM, "delete_if", fdbm_delete_if, 0);
+ rb_define_method(rb_cDBM, "reject!", fdbm_delete_if, 0);
+ rb_define_method(rb_cDBM, "reject", fdbm_reject, 0);
+ rb_define_method(rb_cDBM, "clear", fdbm_clear, 0);
+ rb_define_method(rb_cDBM, "invert", fdbm_invert, 0);
+ rb_define_method(rb_cDBM, "update", fdbm_update, 1);
+ rb_define_method(rb_cDBM, "replace", fdbm_replace, 1);
+
+ rb_define_method(rb_cDBM, "include?", fdbm_has_key, 1);
+ rb_define_method(rb_cDBM, "has_key?", fdbm_has_key, 1);
+ rb_define_method(rb_cDBM, "member?", fdbm_has_key, 1);
+ rb_define_method(rb_cDBM, "has_value?", fdbm_has_value, 1);
+ rb_define_method(rb_cDBM, "key?", fdbm_has_key, 1);
+ rb_define_method(rb_cDBM, "value?", fdbm_has_value, 1);
+
+ rb_define_method(rb_cDBM, "to_a", fdbm_to_a, 0);
+ rb_define_method(rb_cDBM, "to_hash", fdbm_to_hash, 0);
+
+ /* Indicates that dbm_open() should open the database in read-only mode */
+ rb_define_const(rb_cDBM, "READER", INT2FIX(O_RDONLY|RUBY_DBM_RW_BIT));
+
+ /* Indicates that dbm_open() should open the database in read/write mode */
+ rb_define_const(rb_cDBM, "WRITER", INT2FIX(O_RDWR|RUBY_DBM_RW_BIT));
+
+ /* Indicates that dbm_open() should open the database in read/write mode,
+ * and create it if it does not already exist
+ */
+ rb_define_const(rb_cDBM, "WRCREAT", INT2FIX(O_RDWR|O_CREAT|RUBY_DBM_RW_BIT));
+
+ /* Indicates that dbm_open() should open the database in read/write mode,
+ * create it if it does not already exist, and delete all contents if it
+ * does already exist.
+ */
+ rb_define_const(rb_cDBM, "NEWDB", INT2FIX(O_RDWR|O_CREAT|O_TRUNC|RUBY_DBM_RW_BIT));
+
+ {
+ VALUE version;
+#if defined(_DBM_IOERR)
+ version = rb_str_new2("ndbm (4.3BSD)");
+#elif defined(RUBYDBM_GDBM_HEADER)
+# if defined(HAVE_DECLARED_LIBVAR_GDBM_VERSION)
+ /* since gdbm 1.9 */
+ version = rb_str_new2(gdbm_version);
+# elif defined(HAVE_UNDECLARED_LIBVAR_GDBM_VERSION)
+ /* ndbm.h doesn't declare gdbm_version until gdbm 1.8.3.
+ * See extconf.rb for more information. */
+ RUBY_EXTERN char *gdbm_version;
+ version = rb_str_new2(gdbm_version);
+# else
+ version = rb_str_new2("GDBM (unknown)");
+# endif
+#elif defined(RUBYDBM_DB_HEADER)
+# if defined(HAVE_DB_VERSION)
+ /* The version of the dbm library, if using Berkeley DB */
+ version = rb_str_new2(db_version(NULL, NULL, NULL));
+# else
+ version = rb_str_new2("Berkeley DB (unknown)");
+# endif
+#elif defined(_RELIC_H)
+# if defined(HAVE_DPVERSION)
+ version = rb_sprintf("QDBM %s", dpversion);
+# else
+ version = rb_str_new2("QDBM (unknown)");
+# endif
+#else
+ version = rb_str_new2("ndbm (unknown)");
+#endif
+ /*
+ * Identifies ndbm library version.
+ *
+ * Examples:
+ *
+ * - "ndbm (4.3BSD)"
+ * - "Berkeley DB 4.8.30: (April 9, 2010)"
+ * - "Berkeley DB (unknown)" (4.4BSD, maybe)
+ * - "GDBM version 1.8.3. 10/15/2002 (built Jul 1 2011 12:32:45)"
+ * - "QDBM 1.8.78"
+ *
+ */
+ rb_define_const(rb_cDBM, "VERSION", version);
+ }
+}
diff --git a/jni/ruby/ext/dbm/extconf.rb b/jni/ruby/ext/dbm/extconf.rb
new file mode 100644
index 0000000..2c8caa3
--- /dev/null
+++ b/jni/ruby/ext/dbm/extconf.rb
@@ -0,0 +1,289 @@
+# configure option:
+# --with-dbm-type=COMMA-SEPARATED-NDBM-TYPES
+#
+# ndbm type:
+# libc ndbm compatible library in libc.
+# db Berkeley DB (libdb)
+# db2 Berkeley DB (libdb2)
+# db1 Berkeley DB (libdb1)
+# db5 Berkeley DB (libdb5)
+# db4 Berkeley DB (libdb4)
+# db3 Berkeley DB (libdb3)
+# gdbm_compat GDBM since 1.8.1 (libgdbm_compat)
+# gdbm GDBM until 1.8.0 (libgdbm)
+# qdbm QDBM (libqdbm)
+# ndbm Some legacy OS may have libndbm.
+
+# :stopdoc:
+require 'mkmf'
+
+dir_config("dbm")
+
+if dblib = with_config("dbm-type", nil)
+ dblib = dblib.split(/[ ,]+/)
+else
+ dblib = %w(libc db db2 db1 db5 db4 db3 gdbm_compat gdbm qdbm)
+end
+
+headers = {
+ "libc" => ["ndbm.h"], # 4.3BSD original ndbm, Berkeley DB 1 in 4.4BSD libc.
+ "db" => ["db.h"],
+ "db1" => ["db1/ndbm.h", "db1.h", "ndbm.h"],
+ "db2" => ["db2/db.h", "db2.h", "db.h"],
+ "db3" => ["db3/db.h", "db3.h", "db.h"],
+ "db4" => ["db4/db.h", "db4.h", "db.h"],
+ "db5" => ["db5/db.h", "db5.h", "db.h"],
+ "gdbm_compat" => ["gdbm-ndbm.h", "gdbm/ndbm.h", "ndbm.h"], # GDBM since 1.8.1
+ "gdbm" => ["gdbm-ndbm.h", "gdbm/ndbm.h", "ndbm.h"], # GDBM until 1.8.0
+ "qdbm" => ["qdbm/relic.h", "relic.h"],
+}
+
+class << headers
+ attr_accessor :found
+ attr_accessor :defs
+end
+headers.found = []
+headers.defs = nil
+
+def headers.db_check(db, hdr)
+ old_libs = $libs.dup
+ old_defs = $defs.dup
+ result = db_check2(db, hdr)
+ if !result
+ $libs = old_libs
+ $defs = old_defs
+ end
+ result
+end
+
+def have_declared_libvar(var, headers = nil, opt = "", &b)
+ checking_for checking_message([*var].compact.join(' '), headers, opt) do
+ try_declared_libvar(var, headers, opt, &b)
+ end
+end
+
+def try_declared_libvar(var, headers = nil, opt = "", &b)
+ if try_link(<<"SRC", opt, &b)
+#{cpp_include(headers)}
+/*top*/
+int main(int argc, char *argv[]) {
+ void *conftest_var = &#{var};
+ return 0;
+}
+SRC
+ $defs.push(format("-DHAVE_DECLARED_LIBVAR_%s", var.tr_cpp))
+ true
+ else
+ false
+ end
+end
+
+def have_undeclared_libvar(var, headers = nil, opt = "", &b)
+ checking_for checking_message([*var].compact.join(' '), headers, opt) do
+ try_undeclared_libvar(var, headers, opt, &b)
+ end
+end
+
+def try_undeclared_libvar(var, headers = nil, opt = "", &b)
+ var, type = *var
+ if try_link(<<"SRC", opt, &b)
+#{cpp_include(headers)}
+/*top*/
+int main(int argc, char *argv[]) {
+ typedef #{type || 'int'} conftest_type;
+ extern conftest_type #{var};
+ conftest_type *conftest_var = &#{var};
+ return 0;
+}
+SRC
+ $defs.push(format("-DHAVE_UNDECLARED_LIBVAR_%s", var.tr_cpp))
+ true
+ else
+ false
+ end
+end
+
+def have_empty_macro_dbm_clearerr(headers = nil, opt = "", &b)
+ checking_for checking_message('empty macro of dbm_clearerr(foobarbaz)',
+ headers, opt) do
+ try_toplevel('dbm_clearerr(foobarbaz)', headers, opt, &b)
+ end
+end
+
+def try_toplevel(src, headers = nil, opt = "", &b)
+ if try_compile(<<"SRC", opt, &b)
+#{cpp_include(headers)}
+/*top*/
+#{src}
+SRC
+ true
+ else
+ false
+ end
+end
+
+
+def headers.db_check2(db, hdr)
+ $defs.push(%{-DRUBYDBM_DBM_HEADER='"#{hdr}"'})
+ $defs.push(%{-DRUBYDBM_DBM_TYPE='"#{db}"'})
+
+ hsearch = nil
+
+ case db
+ when /^db[2-5]?$/
+ hsearch = "-DDB_DBM_HSEARCH"
+ when "gdbm_compat"
+ have_library("gdbm") or return false
+ end
+
+ if !have_type("DBM", hdr, hsearch)
+ return false
+ end
+
+ # 'libc' means ndbm is provided by libc.
+ # 4.3BSD original ndbm is contained in libc.
+ # 4.4BSD (and its derivatives such as NetBSD) contains Berkeley DB 1 in libc.
+ if !(db == 'libc' ? have_func('dbm_open("", 0, 0)', hdr, hsearch) :
+ have_library(db, 'dbm_open("", 0, 0)', hdr, hsearch))
+ return false
+ end
+
+ # Skip a mismatch of Berkeley DB's ndbm.h and old GDBM library.
+ #
+ # dbm_clearerr() should be available for any ndbm implementation.
+ # It is available since the original (4.3BSD) ndbm and standardized by POSIX.
+ #
+ # However "can't resolve symbol 'dbm_clearerr'" problem may be caused by
+ # header/library mismatch: Berkeley DB ndbm.h and GDBM library until 1.8.3.
+ # GDBM (until 1.8.3) provides dbm_clearerr() as a empty macro in the header
+ # and the library don't provide dbm_clearerr().
+ # Berkeley DB provides dbm_clearerr() as a usual function.
+ # So Berkeley DB header with GDBM library causes the problem.
+ #
+ if !have_func('dbm_clearerr((DBM *)0)', hdr, hsearch)
+ return false
+ end
+
+ # Berkeley DB's ndbm.h (since 1.85 at least) defines DBM_SUFFIX.
+ # Note that _DB_H_ is not defined on Mac OS X because
+ # it uses Berkeley DB 1 but ndbm.h doesn't include db.h.
+ have_db_header = have_macro('DBM_SUFFIX', hdr, hsearch)
+
+ # Old GDBM's ndbm.h, until 1.8.3, defines dbm_clearerr as a macro which
+ # expands to no tokens.
+ have_gdbm_header1 = have_empty_macro_dbm_clearerr(hdr, hsearch)
+
+ # Recent GDBM's ndbm.h, since 1.9, includes gdbm.h and it defines _GDBM_H_.
+ # ndbm compatibility layer of GDBM is provided by libgdbm (until 1.8.0)
+ # and libgdbm_compat (since 1.8.1).
+ have_gdbm_header2 = have_macro('_GDBM_H_', hdr, hsearch)
+
+ # 4.3BSD's ndbm.h defines _DBM_IOERR.
+ # The original ndbm is provided by libc in 4.3BSD.
+ have_ndbm_header = have_macro('_DBM_IOERR', hdr, hsearch)
+
+ # GDBM provides ndbm functions in libgdbm_compat since GDBM 1.8.1.
+ # GDBM's ndbm.h defines _GDBM_H_ since GDBM 1.9.
+ # If _GDBM_H_ is defined, 'gdbm_compat' is required and reject 'gdbm'.
+ if have_gdbm_header2 && db == 'gdbm'
+ return false
+ end
+
+ if have_db_header
+ $defs.push('-DRUBYDBM_DB_HEADER')
+ end
+
+ have_gdbm_header = have_gdbm_header1 | have_gdbm_header2
+ if have_gdbm_header
+ $defs.push('-DRUBYDBM_GDBM_HEADER')
+ end
+
+ # ndbm.h is provided by the original (4.3BSD) ndbm,
+ # Berkeley DB 1 in libc of 4.4BSD and
+ # ndbm compatibility layer of GDBM.
+ # So, try to check header/library mismatch.
+ #
+ # Several (possibly historical) distributions provides libndbm.
+ # It may be Berkeley DB, GDBM or 4.3BSD ndbm.
+ # So mismatch check is not performed for that.
+ # Note that libndbm is searched only when --with-dbm-type=ndbm is
+ # given for configure.
+ #
+ if hdr == 'ndbm.h' && db != 'libc' && db != 'ndbm'
+ if /\Adb\d?\z/ !~ db && have_db_header
+ return false
+ end
+
+ if /\Agdbm/ !~ db && have_gdbm_header
+ return false
+ end
+
+ if have_ndbm_header
+ return false
+ end
+ end
+
+ # Berkeley DB
+ have_func('db_version((int *)0, (int *)0, (int *)0)', hdr, hsearch)
+
+ # GDBM
+ have_gdbm_version = have_declared_libvar("gdbm_version", hdr, hsearch)
+ # gdbm_version is available since very old version (GDBM 1.5 at least).
+ # However it is not declared by ndbm.h until GDBM 1.8.3.
+ # We can't include both ndbm.h and gdbm.h because they both define datum type.
+ # ndbm.h includes gdbm.h and gdbm_version is declared since GDBM 1.9.
+ have_gdbm_version |= have_undeclared_libvar(["gdbm_version", "char *"], hdr, hsearch)
+
+ # QDBM
+ have_var("dpversion", hdr, hsearch)
+
+ # detect mismatch between GDBM header and other library.
+ # If GDBM header is included, GDBM library should be linked.
+ if have_gdbm_header && !have_gdbm_version
+ return false
+ end
+
+ # DBC type is required to disable error messages by Berkeley DB 2 or later.
+ if have_db_header
+ have_type("DBC", hdr, hsearch)
+ end
+
+ if hsearch
+ $defs << hsearch
+ @defs = hsearch
+ end
+ $defs << '-DDBM_HDR="<'+hdr+'>"'
+ @found << hdr
+
+ puts "header: #{hdr}"
+ puts "library: #{db}"
+
+ true
+end
+
+if dblib.any? {|db| headers.fetch(db, ["ndbm.h"]).any? {|hdr| headers.db_check(db, hdr) } }
+ have_header("cdefs.h")
+ have_header("sys/cdefs.h")
+ have_func("dbm_pagfno((DBM *)0)", headers.found, headers.defs)
+ have_func("dbm_dirfno((DBM *)0)", headers.found, headers.defs)
+ convertible_int("datum.dsize", headers.found, headers.defs)
+ checking_for("sizeof(DBM) is available") {
+ if try_compile(<<SRC)
+#ifdef HAVE_CDEFS_H
+# include <cdefs.h>
+#endif
+#ifdef HAVE_SYS_CDEFS_H
+# include <sys/cdefs.h>
+#endif
+#include DBM_HDR
+
+const int sizeof_DBM = (int)sizeof(DBM);
+SRC
+ $defs << '-DDBM_SIZEOF_DBM=sizeof(DBM)'
+ else
+ $defs << '-DDBM_SIZEOF_DBM=0'
+ end
+ }
+ create_makefile("dbm")
+end
+# :startdoc:
diff --git a/jni/ruby/ext/digest/Makefile b/jni/ruby/ext/digest/Makefile
new file mode 100644
index 0000000..0949ea6
--- /dev/null
+++ b/jni/ruby/ext/digest/Makefile
@@ -0,0 +1,307 @@
+
+SHELL = /bin/sh
+
+# V=0 quiet, V=1 verbose. other values don't work.
+V = 0
+Q1 = $(V:1=)
+Q = $(Q1:0=@)
+ECHO1 = $(V:1=@:)
+ECHO = $(ECHO1:0=@echo)
+NULLCMD = :
+
+#### Start of system configuration section. ####
+top_srcdir = $(topdir)/.
+srcdir = $(top_srcdir)/ext/digest
+topdir = ../..
+hdrdir = $(top_srcdir)/include
+arch_hdrdir = $(extout)/include/$(arch)
+PATH_SEPARATOR = :
+VPATH = $(srcdir):$(arch_hdrdir)/ruby:$(hdrdir)/ruby
+RUBYLIB =
+RUBYOPT = -
+prefix = $(DESTDIR)/usr/local
+rubysitearchprefix = $(rubylibprefix)/$(sitearch)
+rubyarchprefix = $(rubylibprefix)/$(arch)
+rubylibprefix = $(libdir)/$(RUBY_BASE_NAME)
+exec_prefix = $(prefix)
+vendorarchhdrdir = $(vendorhdrdir)/$(sitearch)
+sitearchhdrdir = $(sitehdrdir)/$(sitearch)
+rubyarchhdrdir = $(rubyhdrdir)/$(arch)
+vendorhdrdir = $(rubyhdrdir)/vendor_ruby
+sitehdrdir = $(rubyhdrdir)/site_ruby
+rubyhdrdir = $(includedir)/$(RUBY_VERSION_NAME)
+vendorarchdir = $(vendorlibdir)/$(sitearch)
+vendorlibdir = $(vendordir)/$(ruby_version)
+vendordir = $(rubylibprefix)/vendor_ruby
+sitearchdir = $(sitelibdir)/$(sitearch)
+sitelibdir = $(sitedir)/$(ruby_version)
+sitedir = $(rubylibprefix)/site_ruby
+rubyarchdir = $(rubylibdir)/$(arch)
+rubylibdir = $(rubylibprefix)/$(ruby_version)
+sitearchincludedir = $(includedir)/$(sitearch)
+archincludedir = $(includedir)/$(arch)
+sitearchlibdir = $(libdir)/$(sitearch)
+archlibdir = $(libdir)/$(arch)
+ridir = $(datarootdir)/$(RI_BASE_NAME)
+mandir = $(datarootdir)/man
+localedir = $(datarootdir)/locale
+libdir = $(exec_prefix)/lib
+psdir = $(docdir)
+pdfdir = $(docdir)
+dvidir = $(docdir)
+htmldir = $(docdir)
+infodir = $(datarootdir)/info
+docdir = $(datarootdir)/doc/$(PACKAGE)
+oldincludedir = $(DESTDIR)/usr/include
+includedir = $(prefix)/include
+localstatedir = $(prefix)/var
+sharedstatedir = $(prefix)/com
+sysconfdir = $(prefix)/etc
+datadir = $(datarootdir)
+datarootdir = $(prefix)/share
+libexecdir = $(exec_prefix)/libexec
+sbindir = $(exec_prefix)/sbin
+bindir = $(exec_prefix)/bin
+archdir = $(rubyarchdir)
+
+
+CC = gcc
+CXX = g++
+LIBRUBY = $(LIBRUBY_SO)
+LIBRUBY_A = lib$(RUBY_SO_NAME)-static.a
+LIBRUBYARG_SHARED = -Wl,-R$(libdir) -L$(libdir) -l$(RUBY_SO_NAME)
+LIBRUBYARG_STATIC = -Wl,-R$(libdir) -L$(libdir) -l$(RUBY_SO_NAME)-static
+empty =
+OUTFLAG = -o $(empty)
+COUTFLAG = -o $(empty)
+
+RUBY_EXTCONF_H = extconf.h
+cflags = $(optflags) $(debugflags) $(warnflags)
+optflags = -O3 -fno-fast-math
+debugflags = -ggdb3
+warnflags = -Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wunused-variable -Wpointer-arith -Wwrite-strings -Wdeclaration-after-statement -Wimplicit-function-declaration -Wdeprecated-declarations -Wno-packed-bitfield-compat
+CCDLFLAGS = -fPIC
+CFLAGS = $(CCDLFLAGS) $(cflags) -fPIC $(ARCH_FLAG)
+INCFLAGS = -I. -I$(arch_hdrdir) -I$(hdrdir) -I$(srcdir)
+DEFS =
+CPPFLAGS = -DRUBY_EXTCONF_H=\"$(RUBY_EXTCONF_H)\" $(DEFS) $(cppflags)
+CXXFLAGS = $(CCDLFLAGS) $(cxxflags) $(ARCH_FLAG)
+ldflags = -L. -fstack-protector -rdynamic -Wl,-export-dynamic
+dldflags =
+ARCH_FLAG =
+DLDFLAGS = $(ldflags) $(dldflags) $(ARCH_FLAG)
+LDSHARED = $(CC) -shared
+LDSHAREDXX = $(CXX) -shared
+AR = ar
+EXEEXT =
+
+RUBY_INSTALL_NAME = $(RUBY_BASE_NAME)
+RUBY_SO_NAME = ruby
+RUBYW_INSTALL_NAME =
+RUBY_VERSION_NAME = $(RUBY_BASE_NAME)-$(ruby_version)
+RUBYW_BASE_NAME = rubyw
+RUBY_BASE_NAME = ruby
+
+arch = x86_64-linux
+sitearch = $(arch)
+ruby_version = 2.2.0
+ruby = $(topdir)/miniruby -I'$(topdir)' -I'$(top_srcdir)/lib' -I'$(extout)/$(arch)' -I'$(extout)/common'
+RUBY = $(ruby)
+ruby_headers = $(hdrdir)/ruby.h $(hdrdir)/ruby/ruby.h $(hdrdir)/ruby/defines.h $(hdrdir)/ruby/missing.h $(hdrdir)/ruby/intern.h $(hdrdir)/ruby/st.h $(hdrdir)/ruby/subst.h $(arch_hdrdir)/ruby/config.h $(RUBY_EXTCONF_H)
+
+RM = rm -f
+RM_RF = $(RUBY) -run -e rm -- -rf
+RMDIRS = rmdir --ignore-fail-on-non-empty -p
+MAKEDIRS = /bin/mkdir -p
+INSTALL = /usr/bin/install -c
+INSTALL_PROG = $(INSTALL) -m 0755
+INSTALL_DATA = $(INSTALL) -m 644
+COPY = cp
+TOUCH = exit >
+
+#### End of system configuration section. ####
+
+preload =
+
+libpath = . $(topdir)
+LIBPATH = -L. -L$(topdir)
+DEFFILE =
+
+CLEANFILES = mkmf.log $(HDRDIR)/digest.h
+DISTCLEANFILES =
+DISTCLEANDIRS = $(HDRDIR)
+
+extout = $(topdir)/.ext
+extout_prefix = $(extout)$(target_prefix)/
+target_prefix =
+LOCAL_LIBS =
+LIBS = $(LIBRUBYARG_SHARED) -lpthread -lgmp -ldl -lcrypt -lm -lc
+ORIG_SRCS = digest.c
+SRCS = $(ORIG_SRCS)
+OBJS = digest.o
+HDRS = $(srcdir)/defs.h $(srcdir)/extconf.h $(srcdir)/digest.h
+TARGET = digest
+TARGET_NAME = digest
+TARGET_ENTRY = Init_$(TARGET_NAME)
+DLLIB = $(TARGET).so
+EXTSTATIC =
+STATIC_LIB = $(TARGET).a
+
+TIMESTAMP_DIR = $(extout)/.timestamp
+BINDIR = $(extout)/bin
+RUBYCOMMONDIR = $(extout)/common
+RUBYLIBDIR = $(RUBYCOMMONDIR)$(target_prefix)
+RUBYARCHDIR = $(extout)/$(arch)$(target_prefix)
+HDRDIR = $(extout)/include/ruby$(target_prefix)
+ARCHHDRDIR = $(extout)/include/$(arch)/ruby$(target_prefix)
+
+TARGET_SO = $(RUBYARCHDIR)/$(DLLIB)
+CLEANLIBS = $(RUBYARCHDIR)/$(TARGET).so
+CLEANOBJS = *.o *.bak
+
+all: install
+static: all
+.PHONY: all install static install-so install-rb
+.PHONY: clean clean-so clean-static clean-rb
+
+clean-static::
+clean-rb-default::
+clean-rb::
+clean-so::
+clean: clean-so clean-static clean-rb-default clean-rb
+ -$(Q)$(RM) $(CLEANLIBS) $(CLEANOBJS) $(CLEANFILES) .*.time
+
+distclean-rb-default::
+distclean-rb::
+distclean-so::
+distclean-static::
+distclean: clean distclean-so distclean-static distclean-rb-default distclean-rb
+ -$(Q)$(RM) Makefile $(RUBY_EXTCONF_H) conftest.* mkmf.log
+ -$(Q)$(RM) core ruby$(EXEEXT) *~ $(DISTCLEANFILES)
+ -$(Q)$(RMDIRS) $(DISTCLEANDIRS) 2> /dev/null || true
+
+realclean: distclean
+install: install-so install-rb
+
+install-so: $(RUBYARCHDIR)/$(DLLIB)
+clean-so::
+ -$(Q)$(RM) $(RUBYARCHDIR)/$(DLLIB)
+ -$(Q)$(RMDIRS) $(RUBYARCHDIR) 2> /dev/null || true
+clean-static::
+ -$(Q)$(RM) $(STATIC_LIB)
+install-rb: pre-install-rb install-rb-default
+install-rb-default: pre-install-rb-default
+pre-install-rb: Makefile
+pre-install-rb-default: Makefile
+pre-install-rb-default: $(TIMESTAMP_DIR)/.RUBYLIBDIR.time
+install-rb-default: $(RUBYLIBDIR)/digest.rb
+$(RUBYLIBDIR)/digest.rb: $(srcdir)/lib/digest.rb $(TIMESTAMP_DIR)/.RUBYLIBDIR.time
+ $(Q) $(COPY) $(srcdir)/lib/digest.rb $(@D)
+clean-rb-default::
+ -$(Q)$(RM) $(RUBYLIBDIR)/digest.rb
+pre-install-rb-default:
+ $(ECHO) installing default digest libraries
+clean-rb-default::
+ -$(Q)$(RMDIRS) $(RUBYLIBDIR) 2> /dev/null || true
+pre-install-rb: $(TIMESTAMP_DIR)/.HDRDIR.time
+install-rb: $(HDRDIR)/digest.h
+$(HDRDIR)/digest.h: $(srcdir)/digest.h $(TIMESTAMP_DIR)/.HDRDIR.time
+ $(Q) $(COPY) $(srcdir)/digest.h $(@D)
+clean-rb::
+ -$(Q)$(RM) $(HDRDIR)/digest.h
+pre-install-rb:
+ $(ECHO) installing digest libraries
+clean-rb::
+ -$(Q)$(RMDIRS) $(RUBYLIBDIR) 2> /dev/null || true
+ -$(Q)$(RMDIRS) $(HDRDIR) 2> /dev/null || true
+$(TIMESTAMP_DIR)/.RUBYARCHDIR.time:
+ $(Q) $(MAKEDIRS) $(@D) $(RUBYARCHDIR)
+ $(Q) $(TOUCH) $@
+$(TIMESTAMP_DIR)/.RUBYLIBDIR.time:
+ $(Q) $(MAKEDIRS) $(@D) $(RUBYLIBDIR)
+ $(Q) $(TOUCH) $@
+$(TIMESTAMP_DIR)/.HDRDIR.time:
+ $(Q) $(MAKEDIRS) $(@D) $(HDRDIR)
+ $(Q) $(TOUCH) $@
+
+site-install: site-install-so site-install-rb
+site-install-so: install-so
+site-install-rb: install-rb
+
+.SUFFIXES: .c .m .cc .mm .cxx .cpp .o .S
+
+.cc.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<
+
+.cc.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -S $<
+
+.mm.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<
+
+.mm.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -S $<
+
+.cxx.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<
+
+.cxx.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -S $<
+
+.cpp.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<
+
+.cpp.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -S $<
+
+.c.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -c $<
+
+.c.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -S $<
+
+.m.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -c $<
+
+.m.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -S $<
+
+$(RUBYARCHDIR)/$(DLLIB): $(OBJS) Makefile $(TIMESTAMP_DIR)/.RUBYARCHDIR.time
+ $(ECHO) linking shared-object $(DLLIB)
+ -$(Q)$(RM) $(@)
+ $(Q) $(LDSHARED) -o $@ $(OBJS) $(LIBPATH) $(DLDFLAGS) $(LOCAL_LIBS) $(LIBS)
+
+$(STATIC_LIB): $(OBJS)
+ -$(Q)$(RM) $(@)
+ $(ECHO) linking static-library $(@)
+ $(Q) $(AR) cru $@ $(OBJS)
+ -$(Q)ranlib $(@) 2> /dev/null || true
+
+###
+$(OBJS): $(RUBY_EXTCONF_H)
+
+# AUTOGENERATED DEPENDENCIES START
+digest.o: $(RUBY_EXTCONF_H)
+digest.o: $(arch_hdrdir)/ruby/config.h
+digest.o: $(hdrdir)/ruby/defines.h
+digest.o: $(hdrdir)/ruby/intern.h
+digest.o: $(hdrdir)/ruby/missing.h
+digest.o: $(hdrdir)/ruby/ruby.h
+digest.o: $(hdrdir)/ruby/st.h
+digest.o: $(hdrdir)/ruby/subst.h
+digest.o: $(top_srcdir)/include/ruby.h
+digest.o: digest.c
+digest.o: digest.h
+# AUTOGENERATED DEPENDENCIES END
diff --git a/jni/ruby/ext/digest/bubblebabble/Makefile b/jni/ruby/ext/digest/bubblebabble/Makefile
new file mode 100644
index 0000000..2db0c16
--- /dev/null
+++ b/jni/ruby/ext/digest/bubblebabble/Makefile
@@ -0,0 +1,282 @@
+
+SHELL = /bin/sh
+
+# V=0 quiet, V=1 verbose. other values don't work.
+V = 0
+Q1 = $(V:1=)
+Q = $(Q1:0=@)
+ECHO1 = $(V:1=@:)
+ECHO = $(ECHO1:0=@echo)
+NULLCMD = :
+
+#### Start of system configuration section. ####
+top_srcdir = $(topdir)/.
+srcdir = $(top_srcdir)/ext/digest/bubblebabble
+topdir = ../../..
+hdrdir = $(top_srcdir)/include
+arch_hdrdir = $(extout)/include/$(arch)
+PATH_SEPARATOR = :
+VPATH = $(srcdir):$(arch_hdrdir)/ruby:$(hdrdir)/ruby
+RUBYLIB =
+RUBYOPT = -
+prefix = $(DESTDIR)/usr/local
+rubysitearchprefix = $(rubylibprefix)/$(sitearch)
+rubyarchprefix = $(rubylibprefix)/$(arch)
+rubylibprefix = $(libdir)/$(RUBY_BASE_NAME)
+exec_prefix = $(prefix)
+vendorarchhdrdir = $(vendorhdrdir)/$(sitearch)
+sitearchhdrdir = $(sitehdrdir)/$(sitearch)
+rubyarchhdrdir = $(rubyhdrdir)/$(arch)
+vendorhdrdir = $(rubyhdrdir)/vendor_ruby
+sitehdrdir = $(rubyhdrdir)/site_ruby
+rubyhdrdir = $(includedir)/$(RUBY_VERSION_NAME)
+vendorarchdir = $(vendorlibdir)/$(sitearch)
+vendorlibdir = $(vendordir)/$(ruby_version)
+vendordir = $(rubylibprefix)/vendor_ruby
+sitearchdir = $(sitelibdir)/$(sitearch)
+sitelibdir = $(sitedir)/$(ruby_version)
+sitedir = $(rubylibprefix)/site_ruby
+rubyarchdir = $(rubylibdir)/$(arch)
+rubylibdir = $(rubylibprefix)/$(ruby_version)
+sitearchincludedir = $(includedir)/$(sitearch)
+archincludedir = $(includedir)/$(arch)
+sitearchlibdir = $(libdir)/$(sitearch)
+archlibdir = $(libdir)/$(arch)
+ridir = $(datarootdir)/$(RI_BASE_NAME)
+mandir = $(datarootdir)/man
+localedir = $(datarootdir)/locale
+libdir = $(exec_prefix)/lib
+psdir = $(docdir)
+pdfdir = $(docdir)
+dvidir = $(docdir)
+htmldir = $(docdir)
+infodir = $(datarootdir)/info
+docdir = $(datarootdir)/doc/$(PACKAGE)
+oldincludedir = $(DESTDIR)/usr/include
+includedir = $(prefix)/include
+localstatedir = $(prefix)/var
+sharedstatedir = $(prefix)/com
+sysconfdir = $(prefix)/etc
+datadir = $(datarootdir)
+datarootdir = $(prefix)/share
+libexecdir = $(exec_prefix)/libexec
+sbindir = $(exec_prefix)/sbin
+bindir = $(exec_prefix)/bin
+archdir = $(rubyarchdir)
+
+
+CC = gcc
+CXX = g++
+LIBRUBY = $(LIBRUBY_SO)
+LIBRUBY_A = lib$(RUBY_SO_NAME)-static.a
+LIBRUBYARG_SHARED = -Wl,-R$(libdir) -L$(libdir) -l$(RUBY_SO_NAME)
+LIBRUBYARG_STATIC = -Wl,-R$(libdir) -L$(libdir) -l$(RUBY_SO_NAME)-static
+empty =
+OUTFLAG = -o $(empty)
+COUTFLAG = -o $(empty)
+
+RUBY_EXTCONF_H = extconf.h
+cflags = $(optflags) $(debugflags) $(warnflags)
+optflags = -O3 -fno-fast-math
+debugflags = -ggdb3
+warnflags = -Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wunused-variable -Wpointer-arith -Wwrite-strings -Wdeclaration-after-statement -Wimplicit-function-declaration -Wdeprecated-declarations -Wno-packed-bitfield-compat
+CCDLFLAGS = -fPIC
+CFLAGS = $(CCDLFLAGS) $(cflags) -fPIC $(ARCH_FLAG)
+INCFLAGS = -I. -I$(arch_hdrdir) -I$(hdrdir) -I$(srcdir) -I$(srcdir)/..
+DEFS =
+CPPFLAGS = -DRUBY_EXTCONF_H=\"$(RUBY_EXTCONF_H)\" $(DEFS) $(cppflags)
+CXXFLAGS = $(CCDLFLAGS) $(cxxflags) $(ARCH_FLAG)
+ldflags = -L. -fstack-protector -rdynamic -Wl,-export-dynamic
+dldflags =
+ARCH_FLAG =
+DLDFLAGS = $(ldflags) $(dldflags) $(ARCH_FLAG)
+LDSHARED = $(CC) -shared
+LDSHAREDXX = $(CXX) -shared
+AR = ar
+EXEEXT =
+
+RUBY_INSTALL_NAME = $(RUBY_BASE_NAME)
+RUBY_SO_NAME = ruby
+RUBYW_INSTALL_NAME =
+RUBY_VERSION_NAME = $(RUBY_BASE_NAME)-$(ruby_version)
+RUBYW_BASE_NAME = rubyw
+RUBY_BASE_NAME = ruby
+
+arch = x86_64-linux
+sitearch = $(arch)
+ruby_version = 2.2.0
+ruby = $(topdir)/miniruby -I'$(topdir)' -I'$(top_srcdir)/lib' -I'$(extout)/$(arch)' -I'$(extout)/common'
+RUBY = $(ruby)
+ruby_headers = $(hdrdir)/ruby.h $(hdrdir)/ruby/ruby.h $(hdrdir)/ruby/defines.h $(hdrdir)/ruby/missing.h $(hdrdir)/ruby/intern.h $(hdrdir)/ruby/st.h $(hdrdir)/ruby/subst.h $(arch_hdrdir)/ruby/config.h $(RUBY_EXTCONF_H)
+
+RM = rm -f
+RM_RF = $(RUBY) -run -e rm -- -rf
+RMDIRS = rmdir --ignore-fail-on-non-empty -p
+MAKEDIRS = /bin/mkdir -p
+INSTALL = /usr/bin/install -c
+INSTALL_PROG = $(INSTALL) -m 0755
+INSTALL_DATA = $(INSTALL) -m 644
+COPY = cp
+TOUCH = exit >
+
+#### End of system configuration section. ####
+
+preload =
+
+libpath = . $(topdir)
+LIBPATH = -L. -L$(topdir)
+DEFFILE =
+
+CLEANFILES = mkmf.log
+DISTCLEANFILES =
+DISTCLEANDIRS =
+
+extout = $(topdir)/.ext
+extout_prefix = $(extout)$(target_prefix)/
+target_prefix = /digest
+LOCAL_LIBS =
+LIBS = $(LIBRUBYARG_SHARED) -lpthread -lgmp -ldl -lcrypt -lm -lc
+ORIG_SRCS = bubblebabble.c
+SRCS = $(ORIG_SRCS)
+OBJS = bubblebabble.o
+HDRS = $(srcdir)/extconf.h
+TARGET = bubblebabble
+TARGET_NAME = bubblebabble
+TARGET_ENTRY = Init_$(TARGET_NAME)
+DLLIB = $(TARGET).so
+EXTSTATIC =
+STATIC_LIB = $(TARGET).a
+
+TIMESTAMP_DIR = $(extout)/.timestamp
+BINDIR = $(extout)/bin
+RUBYCOMMONDIR = $(extout)/common
+RUBYLIBDIR = $(RUBYCOMMONDIR)$(target_prefix)
+RUBYARCHDIR = $(extout)/$(arch)$(target_prefix)
+HDRDIR = $(extout)/include/ruby$(target_prefix)
+ARCHHDRDIR = $(extout)/include/$(arch)/ruby$(target_prefix)
+
+TARGET_SO = $(RUBYARCHDIR)/$(DLLIB)
+CLEANLIBS = $(RUBYARCHDIR)/$(TARGET).so
+CLEANOBJS = *.o *.bak
+
+all: install
+static: all
+.PHONY: all install static install-so install-rb
+.PHONY: clean clean-so clean-static clean-rb
+
+clean-static::
+clean-rb-default::
+clean-rb::
+clean-so::
+clean: clean-so clean-static clean-rb-default clean-rb
+ -$(Q)$(RM) $(CLEANLIBS) $(CLEANOBJS) $(CLEANFILES) .*.time
+
+distclean-rb-default::
+distclean-rb::
+distclean-so::
+distclean-static::
+distclean: clean distclean-so distclean-static distclean-rb-default distclean-rb
+ -$(Q)$(RM) Makefile $(RUBY_EXTCONF_H) conftest.* mkmf.log
+ -$(Q)$(RM) core ruby$(EXEEXT) *~ $(DISTCLEANFILES)
+ -$(Q)$(RMDIRS) $(DISTCLEANDIRS) 2> /dev/null || true
+
+realclean: distclean
+install: install-so install-rb
+
+install-so: $(RUBYARCHDIR)/$(DLLIB)
+clean-so::
+ -$(Q)$(RM) $(RUBYARCHDIR)/$(DLLIB)
+ -$(Q)$(RMDIRS) $(RUBYARCHDIR) 2> /dev/null || true
+clean-static::
+ -$(Q)$(RM) $(STATIC_LIB)
+install-rb: pre-install-rb install-rb-default
+install-rb-default: pre-install-rb-default
+pre-install-rb: Makefile
+pre-install-rb-default: Makefile
+pre-install-rb-default:
+ @$(NULLCMD)
+$(TIMESTAMP_DIR)/.RUBYARCHDIR.-.digest.time:
+ $(Q) $(MAKEDIRS) $(@D) $(RUBYARCHDIR)
+ $(Q) $(TOUCH) $@
+
+site-install: site-install-so site-install-rb
+site-install-so: install-so
+site-install-rb: install-rb
+
+.SUFFIXES: .c .m .cc .mm .cxx .cpp .o .S
+
+.cc.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<
+
+.cc.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -S $<
+
+.mm.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<
+
+.mm.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -S $<
+
+.cxx.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<
+
+.cxx.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -S $<
+
+.cpp.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<
+
+.cpp.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -S $<
+
+.c.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -c $<
+
+.c.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -S $<
+
+.m.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -c $<
+
+.m.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -S $<
+
+$(RUBYARCHDIR)/$(DLLIB): $(OBJS) Makefile $(TIMESTAMP_DIR)/.RUBYARCHDIR.-.digest.time
+ $(ECHO) linking shared-object digest/$(DLLIB)
+ -$(Q)$(RM) $(@)
+ $(Q) $(LDSHARED) -o $@ $(OBJS) $(LIBPATH) $(DLDFLAGS) $(LOCAL_LIBS) $(LIBS)
+
+$(STATIC_LIB): $(OBJS)
+ -$(Q)$(RM) $(@)
+ $(ECHO) linking static-library $(@)
+ $(Q) $(AR) cru $@ $(OBJS)
+ -$(Q)ranlib $(@) 2> /dev/null || true
+
+###
+$(OBJS): $(RUBY_EXTCONF_H)
+
+# AUTOGENERATED DEPENDENCIES START
+bubblebabble.o: $(RUBY_EXTCONF_H)
+bubblebabble.o: $(arch_hdrdir)/ruby/config.h
+bubblebabble.o: $(hdrdir)/ruby/defines.h
+bubblebabble.o: $(hdrdir)/ruby/intern.h
+bubblebabble.o: $(hdrdir)/ruby/missing.h
+bubblebabble.o: $(hdrdir)/ruby/ruby.h
+bubblebabble.o: $(hdrdir)/ruby/st.h
+bubblebabble.o: $(hdrdir)/ruby/subst.h
+bubblebabble.o: $(top_srcdir)/ext/digest/digest.h
+bubblebabble.o: $(top_srcdir)/include/ruby.h
+bubblebabble.o: bubblebabble.c
+# AUTOGENERATED DEPENDENCIES END
diff --git a/jni/ruby/ext/digest/bubblebabble/bubblebabble.c b/jni/ruby/ext/digest/bubblebabble/bubblebabble.c
new file mode 100644
index 0000000..231f92f
--- /dev/null
+++ b/jni/ruby/ext/digest/bubblebabble/bubblebabble.c
@@ -0,0 +1,146 @@
+/************************************************
+
+ bubblebabble.c - BubbleBabble encoding support
+
+ $Author: zzak $
+ created at: Fri Oct 13 18:31:42 JST 2006
+
+ Copyright (C) 2006 Akinori MUSHA
+
+ $Id: bubblebabble.c 43754 2013-11-21 07:53:39Z zzak $
+
+************************************************/
+
+#include "ruby.h"
+#include "digest.h"
+
+static ID id_digest;
+
+static VALUE
+bubblebabble_str_new(VALUE str_digest)
+{
+ char *digest;
+ size_t digest_len;
+ VALUE str;
+ char *p;
+ size_t i, j, seed = 1;
+ static const char vowels[] = {
+ 'a', 'e', 'i', 'o', 'u', 'y'
+ };
+ static const char consonants[] = {
+ 'b', 'c', 'd', 'f', 'g', 'h', 'k', 'l', 'm', 'n',
+ 'p', 'r', 's', 't', 'v', 'z', 'x'
+ };
+
+ StringValue(str_digest);
+ digest = RSTRING_PTR(str_digest);
+ digest_len = RSTRING_LEN(str_digest);
+
+ if ((LONG_MAX - 2) / 3 < (digest_len | 1)) {
+ rb_raise(rb_eRuntimeError, "digest string too long");
+ }
+
+ str = rb_str_new(0, (digest_len | 1) * 3 + 2);
+ p = RSTRING_PTR(str);
+
+ i = j = 0;
+ p[j++] = 'x';
+
+ for (;;) {
+ unsigned char byte1, byte2;
+
+ if (i >= digest_len) {
+ p[j++] = vowels[seed % 6];
+ p[j++] = consonants[16];
+ p[j++] = vowels[seed / 6];
+ break;
+ }
+
+ byte1 = digest[i++];
+ p[j++] = vowels[(((byte1 >> 6) & 3) + seed) % 6];
+ p[j++] = consonants[(byte1 >> 2) & 15];
+ p[j++] = vowels[((byte1 & 3) + (seed / 6)) % 6];
+
+ if (i >= digest_len) {
+ break;
+ }
+
+ byte2 = digest[i++];
+ p[j++] = consonants[(byte2 >> 4) & 15];
+ p[j++] = '-';
+ p[j++] = consonants[byte2 & 15];
+
+ seed = (seed * 5 + byte1 * 7 + byte2) % 36;
+ }
+
+ p[j] = 'x';
+
+ return str;
+}
+
+/* Document-method: Digest::bubblebabble
+ *
+ * call-seq:
+ * Digest.bubblebabble(string) -> bubblebabble_string
+ *
+ * Returns a BubbleBabble encoded version of a given _string_.
+ */
+static VALUE
+rb_digest_s_bubblebabble(VALUE klass, VALUE str)
+{
+ return bubblebabble_str_new(str);
+}
+
+/* Document-method: Digest::Class::bubblebabble
+ *
+ * call-seq:
+ * Digest::Class.bubblebabble(string, ...) -> hash_string
+ *
+ * Returns the BubbleBabble encoded hash value of a given _string_.
+ */
+static VALUE
+rb_digest_class_s_bubblebabble(int argc, VALUE *argv, VALUE klass)
+{
+ return bubblebabble_str_new(rb_funcall2(klass, id_digest, argc, argv));
+}
+
+/* Document-method: Digest::Instance#bubblebabble
+ *
+ * call-seq:
+ * digest_obj.bubblebabble -> hash_string
+ *
+ * Returns the resulting hash value in a Bubblebabble encoded form.
+ */
+static VALUE
+rb_digest_instance_bubblebabble(VALUE self)
+{
+ return bubblebabble_str_new(rb_funcall(self, id_digest, 0));
+}
+
+/*
+ * This module adds some methods to Digest classes to perform
+ * BubbleBabble encoding.
+ */
+void
+Init_bubblebabble(void)
+{
+ VALUE rb_mDigest, rb_mDigest_Instance, rb_cDigest_Class;
+
+ rb_require("digest");
+
+ rb_mDigest = rb_path2class("Digest");
+ rb_mDigest_Instance = rb_path2class("Digest::Instance");
+ rb_cDigest_Class = rb_path2class("Digest::Class");
+
+#if 0
+ rb_mDigest = rb_define_module("Digest");
+ rb_mDigest_Instance = rb_define_module_under(rb_mDigest, "Instance");
+ rb_cDigest_Class = rb_define_class_under(rb_mDigest, "Class", rb_cObject);
+#endif
+
+ rb_define_module_function(rb_mDigest, "bubblebabble", rb_digest_s_bubblebabble, 1);
+ rb_define_singleton_method(rb_cDigest_Class, "bubblebabble", rb_digest_class_s_bubblebabble, -1);
+ rb_define_method(rb_mDigest_Instance, "bubblebabble", rb_digest_instance_bubblebabble, 0);
+
+ id_digest = rb_intern("digest");
+}
diff --git a/jni/ruby/ext/digest/bubblebabble/depend b/jni/ruby/ext/digest/bubblebabble/depend
new file mode 100644
index 0000000..59c6d0c
--- /dev/null
+++ b/jni/ruby/ext/digest/bubblebabble/depend
@@ -0,0 +1,13 @@
+# AUTOGENERATED DEPENDENCIES START
+bubblebabble.o: $(RUBY_EXTCONF_H)
+bubblebabble.o: $(arch_hdrdir)/ruby/config.h
+bubblebabble.o: $(hdrdir)/ruby/defines.h
+bubblebabble.o: $(hdrdir)/ruby/intern.h
+bubblebabble.o: $(hdrdir)/ruby/missing.h
+bubblebabble.o: $(hdrdir)/ruby/ruby.h
+bubblebabble.o: $(hdrdir)/ruby/st.h
+bubblebabble.o: $(hdrdir)/ruby/subst.h
+bubblebabble.o: $(top_srcdir)/ext/digest/digest.h
+bubblebabble.o: $(top_srcdir)/include/ruby.h
+bubblebabble.o: bubblebabble.c
+# AUTOGENERATED DEPENDENCIES END
diff --git a/jni/ruby/ext/digest/bubblebabble/extconf.h b/jni/ruby/ext/digest/bubblebabble/extconf.h
new file mode 100644
index 0000000..aa1cef4
--- /dev/null
+++ b/jni/ruby/ext/digest/bubblebabble/extconf.h
@@ -0,0 +1,4 @@
+#ifndef EXTCONF_H
+#define EXTCONF_H
+#define HAVE_CONFIG_H 1
+#endif
diff --git a/jni/ruby/ext/digest/bubblebabble/extconf.rb b/jni/ruby/ext/digest/bubblebabble/extconf.rb
new file mode 100644
index 0000000..53cb839
--- /dev/null
+++ b/jni/ruby/ext/digest/bubblebabble/extconf.rb
@@ -0,0 +1,6 @@
+require 'mkmf'
+
+$defs << "-DHAVE_CONFIG_H"
+$INCFLAGS << " -I$(srcdir)/.."
+
+create_makefile('digest/bubblebabble')
diff --git a/jni/ruby/ext/digest/defs.h b/jni/ruby/ext/digest/defs.h
new file mode 100644
index 0000000..ed9cb02
--- /dev/null
+++ b/jni/ruby/ext/digest/defs.h
@@ -0,0 +1,19 @@
+/* -*- C -*-
+ * $Id: defs.h 25189 2009-10-02 12:04:37Z akr $
+ */
+
+#ifndef DEFS_H
+#define DEFS_H
+
+#include "ruby.h"
+#include <sys/types.h>
+
+#if defined(HAVE_SYS_CDEFS_H)
+# include <sys/cdefs.h>
+#endif
+#if !defined(__BEGIN_DECLS)
+# define __BEGIN_DECLS
+# define __END_DECLS
+#endif
+
+#endif /* DEFS_H */
diff --git a/jni/ruby/ext/digest/depend b/jni/ruby/ext/digest/depend
new file mode 100644
index 0000000..dbc2bba
--- /dev/null
+++ b/jni/ruby/ext/digest/depend
@@ -0,0 +1,13 @@
+# AUTOGENERATED DEPENDENCIES START
+digest.o: $(RUBY_EXTCONF_H)
+digest.o: $(arch_hdrdir)/ruby/config.h
+digest.o: $(hdrdir)/ruby/defines.h
+digest.o: $(hdrdir)/ruby/intern.h
+digest.o: $(hdrdir)/ruby/missing.h
+digest.o: $(hdrdir)/ruby/ruby.h
+digest.o: $(hdrdir)/ruby/st.h
+digest.o: $(hdrdir)/ruby/subst.h
+digest.o: $(top_srcdir)/include/ruby.h
+digest.o: digest.c
+digest.o: digest.h
+# AUTOGENERATED DEPENDENCIES END
diff --git a/jni/ruby/ext/digest/digest.c b/jni/ruby/ext/digest/digest.c
new file mode 100644
index 0000000..37eb0af
--- /dev/null
+++ b/jni/ruby/ext/digest/digest.c
@@ -0,0 +1,744 @@
+/************************************************
+
+ digest.c -
+
+ $Author: nobu $
+ created at: Fri May 25 08:57:27 JST 2001
+
+ Copyright (C) 1995-2001 Yukihiro Matsumoto
+ Copyright (C) 2001-2006 Akinori MUSHA
+
+ $RoughId: digest.c,v 1.16 2001/07/13 15:38:27 knu Exp $
+ $Id: digest.c 48662 2014-12-01 06:38:04Z nobu $
+
+************************************************/
+
+#include "digest.h"
+
+static VALUE rb_mDigest;
+static VALUE rb_mDigest_Instance;
+static VALUE rb_cDigest_Class;
+static VALUE rb_cDigest_Base;
+
+static ID id_reset, id_update, id_finish, id_digest, id_hexdigest, id_digest_length;
+static ID id_metadata;
+
+RUBY_EXTERN void Init_digest_base(void);
+
+/*
+ * Document-module: Digest
+ *
+ * This module provides a framework for message digest libraries.
+ *
+ * You may want to look at OpenSSL::Digest as it supports more algorithms.
+ *
+ * A cryptographic hash function is a procedure that takes data and returns a
+ * fixed bit string: the hash value, also known as _digest_. Hash functions
+ * are also called one-way functions, it is easy to compute a digest from
+ * a message, but it is infeasible to generate a message from a digest.
+ *
+ * == Examples
+ *
+ * require 'digest'
+ *
+ * # Compute a complete digest
+ * Digest::SHA256.digest 'message' #=> "\xABS\n\x13\xE4Y..."
+ *
+ * sha256 = Digest::SHA256.new
+ * sha256.digest 'message' #=> "\xABS\n\x13\xE4Y..."
+ *
+ * # Other encoding formats
+ * Digest::SHA256.hexdigest 'message' #=> "ab530a13e459..."
+ * Digest::SHA256.base64digest 'message' #=> "q1MKE+RZFJgr..."
+ *
+ * # Compute digest by chunks
+ * md5 = Digest::MD5.new
+ * md5.update 'message1'
+ * md5 << 'message2' # << is an alias for update
+ *
+ * md5.hexdigest #=> "94af09c09bb9..."
+ *
+ * # Compute digest for a file
+ * sha256 = Digest::SHA256.file 'testfile'
+ * sha256.hexdigest
+ *
+ * Additionally digests can be encoded in "bubble babble" format as a sequence
+ * of consonants and vowels which is more recognizable and comparable than a
+ * hexadecimal digest.
+ *
+ * require 'digest/bubblebabble'
+ *
+ * Digest::SHA256.bubblebabble 'message' #=> "xopoh-fedac-fenyh-..."
+ *
+ * See the bubble babble specification at
+ * http://web.mit.edu/kenta/www/one/bubblebabble/spec/jrtrjwzi/draft-huima-01.txt.
+ *
+ * == Digest algorithms
+ *
+ * Different digest algorithms (or hash functions) are available:
+ *
+ * HMAC::
+ * See FIPS PUB 198 The Keyed-Hash Message Authentication Code (HMAC).
+ * RIPEMD-160::
+ * As Digest::RMD160.
+ * See http://homes.esat.kuleuven.be/~bosselae/ripemd160.html.
+ * SHA1::
+ * See FIPS 180 Secure Hash Standard.
+ * SHA2 family::
+ * See FIPS 180 Secure Hash Standard which defines the following algorithms:
+ * * SHA512
+ * * SHA384
+ * * SHA256
+ *
+ * The latest versions of the FIPS publications can be found here:
+ * http://csrc.nist.gov/publications/PubsFIPS.html.
+ */
+
+static VALUE
+hexencode_str_new(VALUE str_digest)
+{
+ char *digest;
+ size_t digest_len;
+ size_t i;
+ VALUE str;
+ char *p;
+ static const char hex[] = {
+ '0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
+ 'a', 'b', 'c', 'd', 'e', 'f'
+ };
+
+ StringValue(str_digest);
+ digest = RSTRING_PTR(str_digest);
+ digest_len = RSTRING_LEN(str_digest);
+
+ if (LONG_MAX / 2 < digest_len) {
+ rb_raise(rb_eRuntimeError, "digest string too long");
+ }
+
+ str = rb_usascii_str_new(0, digest_len * 2);
+
+ for (i = 0, p = RSTRING_PTR(str); i < digest_len; i++) {
+ unsigned char byte = digest[i];
+
+ p[i + i] = hex[byte >> 4];
+ p[i + i + 1] = hex[byte & 0x0f];
+ }
+
+ return str;
+}
+
+/*
+ * call-seq:
+ * Digest.hexencode(string) -> hexencoded_string
+ *
+ * Generates a hex-encoded version of a given _string_.
+ */
+static VALUE
+rb_digest_s_hexencode(VALUE klass, VALUE str)
+{
+ return hexencode_str_new(str);
+}
+
+NORETURN(static void rb_digest_instance_method_unimpl(VALUE self, const char *method));
+
+/*
+ * Document-module: Digest::Instance
+ *
+ * This module provides instance methods for a digest implementation
+ * object to calculate message digest values.
+ */
+
+static void
+rb_digest_instance_method_unimpl(VALUE self, const char *method)
+{
+ rb_raise(rb_eRuntimeError, "%s does not implement %s()",
+ rb_obj_classname(self), method);
+}
+
+/*
+ * call-seq:
+ * digest_obj.update(string) -> digest_obj
+ * digest_obj << string -> digest_obj
+ *
+ * Updates the digest using a given _string_ and returns self.
+ *
+ * The update() method and the left-shift operator are overridden by
+ * each implementation subclass. (One should be an alias for the
+ * other)
+ */
+static VALUE
+rb_digest_instance_update(VALUE self, VALUE str)
+{
+ rb_digest_instance_method_unimpl(self, "update");
+
+ UNREACHABLE;
+}
+
+/*
+ * call-seq:
+ * digest_obj.instance_eval { finish } -> digest_obj
+ *
+ * Finishes the digest and returns the resulting hash value.
+ *
+ * This method is overridden by each implementation subclass and often
+ * made private, because some of those subclasses may leave internal
+ * data uninitialized. Do not call this method from outside. Use
+ * #digest!() instead, which ensures that internal data be reset for
+ * security reasons.
+ */
+static VALUE
+rb_digest_instance_finish(VALUE self)
+{
+ rb_digest_instance_method_unimpl(self, "finish");
+
+ UNREACHABLE;
+}
+
+/*
+ * call-seq:
+ * digest_obj.reset -> digest_obj
+ *
+ * Resets the digest to the initial state and returns self.
+ *
+ * This method is overridden by each implementation subclass.
+ */
+static VALUE
+rb_digest_instance_reset(VALUE self)
+{
+ rb_digest_instance_method_unimpl(self, "reset");
+
+ UNREACHABLE;
+}
+
+/*
+ * call-seq:
+ * digest_obj.new -> another_digest_obj
+ *
+ * Returns a new, initialized copy of the digest object. Equivalent
+ * to digest_obj.clone().reset().
+ */
+static VALUE
+rb_digest_instance_new(VALUE self)
+{
+ VALUE clone = rb_obj_clone(self);
+ rb_funcall(clone, id_reset, 0);
+ return clone;
+}
+
+/*
+ * call-seq:
+ * digest_obj.digest -> string
+ * digest_obj.digest(string) -> string
+ *
+ * If none is given, returns the resulting hash value of the digest,
+ * keeping the digest's state.
+ *
+ * If a _string_ is given, returns the hash value for the given
+ * _string_, resetting the digest to the initial state before and
+ * after the process.
+ */
+static VALUE
+rb_digest_instance_digest(int argc, VALUE *argv, VALUE self)
+{
+ VALUE str, value;
+
+ if (rb_scan_args(argc, argv, "01", &str) > 0) {
+ rb_funcall(self, id_reset, 0);
+ rb_funcall(self, id_update, 1, str);
+ value = rb_funcall(self, id_finish, 0);
+ rb_funcall(self, id_reset, 0);
+ } else {
+ value = rb_funcall(rb_obj_clone(self), id_finish, 0);
+ }
+
+ return value;
+}
+
+/*
+ * call-seq:
+ * digest_obj.digest! -> string
+ *
+ * Returns the resulting hash value and resets the digest to the
+ * initial state.
+ */
+static VALUE
+rb_digest_instance_digest_bang(VALUE self)
+{
+ VALUE value = rb_funcall(self, id_finish, 0);
+ rb_funcall(self, id_reset, 0);
+
+ return value;
+}
+
+/*
+ * call-seq:
+ * digest_obj.hexdigest -> string
+ * digest_obj.hexdigest(string) -> string
+ *
+ * If none is given, returns the resulting hash value of the digest in
+ * a hex-encoded form, keeping the digest's state.
+ *
+ * If a _string_ is given, returns the hash value for the given
+ * _string_ in a hex-encoded form, resetting the digest to the initial
+ * state before and after the process.
+ */
+static VALUE
+rb_digest_instance_hexdigest(int argc, VALUE *argv, VALUE self)
+{
+ VALUE str, value;
+
+ if (rb_scan_args(argc, argv, "01", &str) > 0) {
+ rb_funcall(self, id_reset, 0);
+ rb_funcall(self, id_update, 1, str);
+ value = rb_funcall(self, id_finish, 0);
+ rb_funcall(self, id_reset, 0);
+ } else {
+ value = rb_funcall(rb_obj_clone(self), id_finish, 0);
+ }
+
+ return hexencode_str_new(value);
+}
+
+/*
+ * call-seq:
+ * digest_obj.hexdigest! -> string
+ *
+ * Returns the resulting hash value in a hex-encoded form and resets
+ * the digest to the initial state.
+ */
+static VALUE
+rb_digest_instance_hexdigest_bang(VALUE self)
+{
+ VALUE value = rb_funcall(self, id_finish, 0);
+ rb_funcall(self, id_reset, 0);
+
+ return hexencode_str_new(value);
+}
+
+/*
+ * call-seq:
+ * digest_obj.to_s -> string
+ *
+ * Returns digest_obj.hexdigest().
+ */
+static VALUE
+rb_digest_instance_to_s(VALUE self)
+{
+ return rb_funcall(self, id_hexdigest, 0);
+}
+
+/*
+ * call-seq:
+ * digest_obj.inspect -> string
+ *
+ * Creates a printable version of the digest object.
+ */
+static VALUE
+rb_digest_instance_inspect(VALUE self)
+{
+ VALUE str;
+ size_t digest_len = 32; /* about this size at least */
+ const char *cname;
+
+ cname = rb_obj_classname(self);
+
+ /* #<Digest::ClassName: xxxxx...xxxx> */
+ str = rb_str_buf_new(2 + strlen(cname) + 2 + digest_len * 2 + 1);
+ rb_str_buf_cat2(str, "#<");
+ rb_str_buf_cat2(str, cname);
+ rb_str_buf_cat2(str, ": ");
+ rb_str_buf_append(str, rb_digest_instance_hexdigest(0, 0, self));
+ rb_str_buf_cat2(str, ">");
+ return str;
+}
+
+/*
+ * call-seq:
+ * digest_obj == another_digest_obj -> boolean
+ * digest_obj == string -> boolean
+ *
+ * If a string is given, checks whether it is equal to the hex-encoded
+ * hash value of the digest object. If another digest instance is
+ * given, checks whether they have the same hash value. Otherwise
+ * returns false.
+ */
+static VALUE
+rb_digest_instance_equal(VALUE self, VALUE other)
+{
+ VALUE str1, str2;
+
+ if (rb_obj_is_kind_of(other, rb_mDigest_Instance) == Qtrue) {
+ str1 = rb_digest_instance_digest(0, 0, self);
+ str2 = rb_digest_instance_digest(0, 0, other);
+ } else {
+ str1 = rb_digest_instance_to_s(self);
+ str2 = rb_check_string_type(other);
+ if (NIL_P(str2)) return Qfalse;
+ }
+
+ /* never blindly assume that subclass methods return strings */
+ StringValue(str1);
+ StringValue(str2);
+
+ if (RSTRING_LEN(str1) == RSTRING_LEN(str2) &&
+ rb_str_cmp(str1, str2) == 0) {
+ return Qtrue;
+ }
+ return Qfalse;
+}
+
+/*
+ * call-seq:
+ * digest_obj.digest_length -> integer
+ *
+ * Returns the length of the hash value of the digest.
+ *
+ * This method should be overridden by each implementation subclass.
+ * If not, digest_obj.digest().length() is returned.
+ */
+static VALUE
+rb_digest_instance_digest_length(VALUE self)
+{
+ /* subclasses really should redefine this method */
+ VALUE digest = rb_digest_instance_digest(0, 0, self);
+
+ /* never blindly assume that #digest() returns a string */
+ StringValue(digest);
+ return INT2NUM(RSTRING_LEN(digest));
+}
+
+/*
+ * call-seq:
+ * digest_obj.length -> integer
+ * digest_obj.size -> integer
+ *
+ * Returns digest_obj.digest_length().
+ */
+static VALUE
+rb_digest_instance_length(VALUE self)
+{
+ return rb_funcall(self, id_digest_length, 0);
+}
+
+/*
+ * call-seq:
+ * digest_obj.block_length -> integer
+ *
+ * Returns the block length of the digest.
+ *
+ * This method is overridden by each implementation subclass.
+ */
+static VALUE
+rb_digest_instance_block_length(VALUE self)
+{
+ rb_digest_instance_method_unimpl(self, "block_length");
+
+ UNREACHABLE;
+}
+
+/*
+ * Document-class: Digest::Class
+ *
+ * This module stands as a base class for digest implementation
+ * classes.
+ */
+
+/*
+ * call-seq:
+ * Digest::Class.digest(string, *parameters) -> hash_string
+ *
+ * Returns the hash value of a given _string_. This is equivalent to
+ * Digest::Class.new(*parameters).digest(string), where extra
+ * _parameters_, if any, are passed through to the constructor and the
+ * _string_ is passed to #digest().
+ */
+static VALUE
+rb_digest_class_s_digest(int argc, VALUE *argv, VALUE klass)
+{
+ VALUE str;
+ volatile VALUE obj;
+
+ if (argc < 1) {
+ rb_raise(rb_eArgError, "no data given");
+ }
+
+ str = *argv++;
+ argc--;
+
+ StringValue(str);
+
+ obj = rb_obj_alloc(klass);
+ rb_obj_call_init(obj, argc, argv);
+
+ return rb_funcall(obj, id_digest, 1, str);
+}
+
+/*
+ * call-seq:
+ * Digest::Class.hexdigest(string[, ...]) -> hash_string
+ *
+ * Returns the hex-encoded hash value of a given _string_. This is
+ * almost equivalent to
+ * Digest.hexencode(Digest::Class.new(*parameters).digest(string)).
+ */
+static VALUE
+rb_digest_class_s_hexdigest(int argc, VALUE *argv, VALUE klass)
+{
+ return hexencode_str_new(rb_funcall2(klass, id_digest, argc, argv));
+}
+
+/* :nodoc: */
+static VALUE
+rb_digest_class_init(VALUE self)
+{
+ return self;
+}
+
+/*
+ * Document-class: Digest::Base
+ *
+ * This abstract class provides a common interface to message digest
+ * implementation classes written in C.
+ */
+
+static rb_digest_metadata_t *
+get_digest_base_metadata(VALUE klass)
+{
+ VALUE p;
+ VALUE obj;
+ rb_digest_metadata_t *algo;
+
+ for (p = klass; !NIL_P(p); p = rb_class_superclass(p)) {
+ if (rb_ivar_defined(p, id_metadata)) {
+ obj = rb_ivar_get(p, id_metadata);
+ break;
+ }
+ }
+
+ if (NIL_P(p))
+ rb_raise(rb_eRuntimeError, "Digest::Base cannot be directly inherited in Ruby");
+
+#undef RUBY_UNTYPED_DATA_WARNING
+#define RUBY_UNTYPED_DATA_WARNING 0
+ Data_Get_Struct(obj, rb_digest_metadata_t, algo);
+
+ switch (algo->api_version) {
+ case 3:
+ break;
+
+ /*
+ * put conversion here if possible when API is updated
+ */
+
+ default:
+ rb_raise(rb_eRuntimeError, "Incompatible digest API version");
+ }
+
+ return algo;
+}
+
+static const rb_data_type_t digest_type = {
+ "digest",
+ {0, RUBY_TYPED_DEFAULT_FREE, 0,},
+ 0, 0,
+ (RUBY_TYPED_FREE_IMMEDIATELY|RUBY_TYPED_WB_PROTECTED),
+};
+
+static inline void
+algo_init(const rb_digest_metadata_t *algo, void *pctx)
+{
+ if (algo->init_func(pctx) != 1) {
+ rb_raise(rb_eRuntimeError, "Digest initialization failed.");
+ }
+}
+
+static VALUE
+rb_digest_base_alloc(VALUE klass)
+{
+ rb_digest_metadata_t *algo;
+ VALUE obj;
+ void *pctx;
+
+ if (klass == rb_cDigest_Base) {
+ rb_raise(rb_eNotImpError, "Digest::Base is an abstract class");
+ }
+
+ algo = get_digest_base_metadata(klass);
+
+ pctx = xmalloc(algo->ctx_size);
+ algo_init(algo, pctx);
+
+ obj = TypedData_Wrap_Struct(klass, &digest_type, pctx);
+
+ return obj;
+}
+
+/* :nodoc: */
+static VALUE
+rb_digest_base_copy(VALUE copy, VALUE obj)
+{
+ rb_digest_metadata_t *algo;
+ void *pctx1, *pctx2;
+
+ if (copy == obj) return copy;
+
+ rb_check_frozen(copy);
+
+ algo = get_digest_base_metadata(rb_obj_class(copy));
+ if (algo != get_digest_base_metadata(rb_obj_class(obj)))
+ rb_raise(rb_eTypeError, "different algorithms");
+
+ TypedData_Get_Struct(obj, void, &digest_type, pctx1);
+ TypedData_Get_Struct(copy, void, &digest_type, pctx2);
+ memcpy(pctx2, pctx1, algo->ctx_size);
+
+ return copy;
+}
+
+/* :nodoc: */
+static VALUE
+rb_digest_base_reset(VALUE self)
+{
+ rb_digest_metadata_t *algo;
+ void *pctx;
+
+ algo = get_digest_base_metadata(rb_obj_class(self));
+
+ TypedData_Get_Struct(self, void, &digest_type, pctx);
+
+ algo_init(algo, pctx);
+
+ return self;
+}
+
+/* :nodoc: */
+static VALUE
+rb_digest_base_update(VALUE self, VALUE str)
+{
+ rb_digest_metadata_t *algo;
+ void *pctx;
+
+ algo = get_digest_base_metadata(rb_obj_class(self));
+
+ TypedData_Get_Struct(self, void, &digest_type, pctx);
+
+ StringValue(str);
+ algo->update_func(pctx, (unsigned char *)RSTRING_PTR(str), RSTRING_LEN(str));
+
+ return self;
+}
+
+/* :nodoc: */
+static VALUE
+rb_digest_base_finish(VALUE self)
+{
+ rb_digest_metadata_t *algo;
+ void *pctx;
+ VALUE str;
+
+ algo = get_digest_base_metadata(rb_obj_class(self));
+
+ TypedData_Get_Struct(self, void, &digest_type, pctx);
+
+ str = rb_str_new(0, algo->digest_len);
+ algo->finish_func(pctx, (unsigned char *)RSTRING_PTR(str));
+
+ /* avoid potential coredump caused by use of a finished context */
+ algo_init(algo, pctx);
+
+ return str;
+}
+
+/* :nodoc: */
+static VALUE
+rb_digest_base_digest_length(VALUE self)
+{
+ rb_digest_metadata_t *algo;
+
+ algo = get_digest_base_metadata(rb_obj_class(self));
+
+ return INT2NUM(algo->digest_len);
+}
+
+/* :nodoc: */
+static VALUE
+rb_digest_base_block_length(VALUE self)
+{
+ rb_digest_metadata_t *algo;
+
+ algo = get_digest_base_metadata(rb_obj_class(self));
+
+ return INT2NUM(algo->block_len);
+}
+
+void
+Init_digest(void)
+{
+ id_reset = rb_intern("reset");
+ id_update = rb_intern("update");
+ id_finish = rb_intern("finish");
+ id_digest = rb_intern("digest");
+ id_hexdigest = rb_intern("hexdigest");
+ id_digest_length = rb_intern("digest_length");
+
+ /*
+ * module Digest
+ */
+ rb_mDigest = rb_define_module("Digest");
+
+ /* module functions */
+ rb_define_module_function(rb_mDigest, "hexencode", rb_digest_s_hexencode, 1);
+
+ /*
+ * module Digest::Instance
+ */
+ rb_mDigest_Instance = rb_define_module_under(rb_mDigest, "Instance");
+
+ /* instance methods that should be overridden */
+ rb_define_method(rb_mDigest_Instance, "update", rb_digest_instance_update, 1);
+ rb_define_method(rb_mDigest_Instance, "<<", rb_digest_instance_update, 1);
+ rb_define_private_method(rb_mDigest_Instance, "finish", rb_digest_instance_finish, 0);
+ rb_define_method(rb_mDigest_Instance, "reset", rb_digest_instance_reset, 0);
+ rb_define_method(rb_mDigest_Instance, "digest_length", rb_digest_instance_digest_length, 0);
+ rb_define_method(rb_mDigest_Instance, "block_length", rb_digest_instance_block_length, 0);
+
+ /* instance methods that may be overridden */
+ rb_define_method(rb_mDigest_Instance, "==", rb_digest_instance_equal, 1);
+ rb_define_method(rb_mDigest_Instance, "inspect", rb_digest_instance_inspect, 0);
+
+ /* instance methods that need not usually be overridden */
+ rb_define_method(rb_mDigest_Instance, "new", rb_digest_instance_new, 0);
+ rb_define_method(rb_mDigest_Instance, "digest", rb_digest_instance_digest, -1);
+ rb_define_method(rb_mDigest_Instance, "digest!", rb_digest_instance_digest_bang, 0);
+ rb_define_method(rb_mDigest_Instance, "hexdigest", rb_digest_instance_hexdigest, -1);
+ rb_define_method(rb_mDigest_Instance, "hexdigest!", rb_digest_instance_hexdigest_bang, 0);
+ rb_define_method(rb_mDigest_Instance, "to_s", rb_digest_instance_to_s, 0);
+ rb_define_method(rb_mDigest_Instance, "length", rb_digest_instance_length, 0);
+ rb_define_method(rb_mDigest_Instance, "size", rb_digest_instance_length, 0);
+
+ /*
+ * class Digest::Class
+ */
+ rb_cDigest_Class = rb_define_class_under(rb_mDigest, "Class", rb_cObject);
+ rb_define_method(rb_cDigest_Class, "initialize", rb_digest_class_init, 0);
+ rb_include_module(rb_cDigest_Class, rb_mDigest_Instance);
+
+ /* class methods */
+ rb_define_singleton_method(rb_cDigest_Class, "digest", rb_digest_class_s_digest, -1);
+ rb_define_singleton_method(rb_cDigest_Class, "hexdigest", rb_digest_class_s_hexdigest, -1);
+
+ id_metadata = rb_intern("metadata");
+
+ /* class Digest::Base < Digest::Class */
+ rb_cDigest_Base = rb_define_class_under(rb_mDigest, "Base", rb_cDigest_Class);
+
+ rb_define_alloc_func(rb_cDigest_Base, rb_digest_base_alloc);
+
+ rb_define_method(rb_cDigest_Base, "initialize_copy", rb_digest_base_copy, 1);
+ rb_define_method(rb_cDigest_Base, "reset", rb_digest_base_reset, 0);
+ rb_define_method(rb_cDigest_Base, "update", rb_digest_base_update, 1);
+ rb_define_method(rb_cDigest_Base, "<<", rb_digest_base_update, 1);
+ rb_define_private_method(rb_cDigest_Base, "finish", rb_digest_base_finish, 0);
+ rb_define_method(rb_cDigest_Base, "digest_length", rb_digest_base_digest_length, 0);
+ rb_define_method(rb_cDigest_Base, "block_length", rb_digest_base_block_length, 0);
+}
diff --git a/jni/ruby/ext/digest/digest.h b/jni/ruby/ext/digest/digest.h
new file mode 100644
index 0000000..528ce13
--- /dev/null
+++ b/jni/ruby/ext/digest/digest.h
@@ -0,0 +1,32 @@
+/************************************************
+
+ digest.h - header file for ruby digest modules
+
+ $Author: nobu $
+ created at: Fri May 25 08:54:56 JST 2001
+
+
+ Copyright (C) 2001-2006 Akinori MUSHA
+
+ $RoughId: digest.h,v 1.3 2001/07/13 15:38:27 knu Exp $
+ $Id: digest.h 46826 2014-07-15 14:58:53Z nobu $
+
+************************************************/
+
+#include "ruby.h"
+
+#define RUBY_DIGEST_API_VERSION 3
+
+typedef int (*rb_digest_hash_init_func_t)(void *);
+typedef void (*rb_digest_hash_update_func_t)(void *, unsigned char *, size_t);
+typedef int (*rb_digest_hash_finish_func_t)(void *, unsigned char *);
+
+typedef struct {
+ int api_version;
+ size_t digest_len;
+ size_t block_len;
+ size_t ctx_size;
+ rb_digest_hash_init_func_t init_func;
+ rb_digest_hash_update_func_t update_func;
+ rb_digest_hash_finish_func_t finish_func;
+} rb_digest_metadata_t;
diff --git a/jni/ruby/ext/digest/extconf.h b/jni/ruby/ext/digest/extconf.h
new file mode 100644
index 0000000..cda0cc8
--- /dev/null
+++ b/jni/ruby/ext/digest/extconf.h
@@ -0,0 +1,3 @@
+#ifndef EXTCONF_H
+#define EXTCONF_H
+#endif
diff --git a/jni/ruby/ext/digest/extconf.rb b/jni/ruby/ext/digest/extconf.rb
new file mode 100644
index 0000000..b94e54b
--- /dev/null
+++ b/jni/ruby/ext/digest/extconf.rb
@@ -0,0 +1,10 @@
+# $RoughId: extconf.rb,v 1.6 2001/07/13 15:38:27 knu Exp $
+# $Id: extconf.rb 25189 2009-10-02 12:04:37Z akr $
+
+require "mkmf"
+
+$INSTALLFILES = {
+ "digest.h" => "$(HDRDIR)"
+}
+
+create_makefile("digest")
diff --git a/jni/ruby/ext/digest/lib/digest.rb b/jni/ruby/ext/digest/lib/digest.rb
new file mode 100644
index 0000000..ef43c46
--- /dev/null
+++ b/jni/ruby/ext/digest/lib/digest.rb
@@ -0,0 +1,108 @@
+require 'digest.so'
+
+module Digest
+ # A mutex for Digest().
+ REQUIRE_MUTEX = Mutex.new
+
+ def self.const_missing(name) # :nodoc:
+ case name
+ when :SHA256, :SHA384, :SHA512
+ lib = 'digest/sha2.so'
+ else
+ lib = File.join('digest', name.to_s.downcase)
+ end
+
+ begin
+ require lib
+ rescue LoadError
+ raise LoadError, "library not found for class Digest::#{name} -- #{lib}", caller(1)
+ end
+ unless Digest.const_defined?(name)
+ raise NameError, "uninitialized constant Digest::#{name}", caller(1)
+ end
+ Digest.const_get(name)
+ end
+
+ class ::Digest::Class
+ # Creates a digest object and reads a given file, _name_.
+ # Optional arguments are passed to the constructor of the digest
+ # class.
+ #
+ # p Digest::SHA256.file("X11R6.8.2-src.tar.bz2").hexdigest
+ # # => "f02e3c85572dc9ad7cb77c2a638e3be24cc1b5bea9fdbb0b0299c9668475c534"
+ def self.file(name, *args)
+ new(*args).file(name)
+ end
+
+ # Returns the base64 encoded hash value of a given _string_. The
+ # return value is properly padded with '=' and contains no line
+ # feeds.
+ def self.base64digest(str, *args)
+ [digest(str, *args)].pack('m0')
+ end
+ end
+
+ module Instance
+ # Updates the digest with the contents of a given file _name_ and
+ # returns self.
+ def file(name)
+ File.open(name, "rb") {|f|
+ buf = ""
+ while f.read(16384, buf)
+ update buf
+ end
+ }
+ self
+ end
+
+ # If none is given, returns the resulting hash value of the digest
+ # in a base64 encoded form, keeping the digest's state.
+ #
+ # If a +string+ is given, returns the hash value for the given
+ # +string+ in a base64 encoded form, resetting the digest to the
+ # initial state before and after the process.
+ #
+ # In either case, the return value is properly padded with '=' and
+ # contains no line feeds.
+ def base64digest(str = nil)
+ [str ? digest(str) : digest].pack('m0')
+ end
+
+ # Returns the resulting hash value and resets the digest to the
+ # initial state.
+ def base64digest!
+ [digest!].pack('m0')
+ end
+ end
+end
+
+# call-seq:
+# Digest(name) -> digest_subclass
+#
+# Returns a Digest subclass by +name+ in a thread-safe manner even
+# when on-demand loading is involved.
+#
+# require 'digest'
+#
+# Digest("MD5")
+# # => Digest::MD5
+#
+# Digest(:SHA256)
+# # => Digest::SHA256
+#
+# Digest(:Foo)
+# # => LoadError: library not found for class Digest::Foo -- digest/foo
+def Digest(name)
+ const = name.to_sym
+ Digest::REQUIRE_MUTEX.synchronize {
+ # Ignore autoload's because it is void when we have #const_missing
+ Digest.const_missing(const)
+ }
+rescue LoadError
+ # Constants do not necessarily rely on digest/*.
+ if Digest.const_defined?(const)
+ Digest.const_get(const)
+ else
+ raise
+ end
+end
diff --git a/jni/ruby/ext/digest/md5/Makefile b/jni/ruby/ext/digest/md5/Makefile
new file mode 100644
index 0000000..a85512a
--- /dev/null
+++ b/jni/ruby/ext/digest/md5/Makefile
@@ -0,0 +1,287 @@
+
+SHELL = /bin/sh
+
+# V=0 quiet, V=1 verbose. other values don't work.
+V = 0
+Q1 = $(V:1=)
+Q = $(Q1:0=@)
+ECHO1 = $(V:1=@:)
+ECHO = $(ECHO1:0=@echo)
+NULLCMD = :
+
+#### Start of system configuration section. ####
+top_srcdir = $(topdir)/.
+srcdir = $(top_srcdir)/ext/digest/md5
+topdir = ../../..
+hdrdir = $(top_srcdir)/include
+arch_hdrdir = $(extout)/include/$(arch)
+PATH_SEPARATOR = :
+VPATH = $(srcdir):$(arch_hdrdir)/ruby:$(hdrdir)/ruby
+RUBYLIB =
+RUBYOPT = -
+prefix = $(DESTDIR)/usr/local
+rubysitearchprefix = $(rubylibprefix)/$(sitearch)
+rubyarchprefix = $(rubylibprefix)/$(arch)
+rubylibprefix = $(libdir)/$(RUBY_BASE_NAME)
+exec_prefix = $(prefix)
+vendorarchhdrdir = $(vendorhdrdir)/$(sitearch)
+sitearchhdrdir = $(sitehdrdir)/$(sitearch)
+rubyarchhdrdir = $(rubyhdrdir)/$(arch)
+vendorhdrdir = $(rubyhdrdir)/vendor_ruby
+sitehdrdir = $(rubyhdrdir)/site_ruby
+rubyhdrdir = $(includedir)/$(RUBY_VERSION_NAME)
+vendorarchdir = $(vendorlibdir)/$(sitearch)
+vendorlibdir = $(vendordir)/$(ruby_version)
+vendordir = $(rubylibprefix)/vendor_ruby
+sitearchdir = $(sitelibdir)/$(sitearch)
+sitelibdir = $(sitedir)/$(ruby_version)
+sitedir = $(rubylibprefix)/site_ruby
+rubyarchdir = $(rubylibdir)/$(arch)
+rubylibdir = $(rubylibprefix)/$(ruby_version)
+sitearchincludedir = $(includedir)/$(sitearch)
+archincludedir = $(includedir)/$(arch)
+sitearchlibdir = $(libdir)/$(sitearch)
+archlibdir = $(libdir)/$(arch)
+ridir = $(datarootdir)/$(RI_BASE_NAME)
+mandir = $(datarootdir)/man
+localedir = $(datarootdir)/locale
+libdir = $(exec_prefix)/lib
+psdir = $(docdir)
+pdfdir = $(docdir)
+dvidir = $(docdir)
+htmldir = $(docdir)
+infodir = $(datarootdir)/info
+docdir = $(datarootdir)/doc/$(PACKAGE)
+oldincludedir = $(DESTDIR)/usr/include
+includedir = $(prefix)/include
+localstatedir = $(prefix)/var
+sharedstatedir = $(prefix)/com
+sysconfdir = $(prefix)/etc
+datadir = $(datarootdir)
+datarootdir = $(prefix)/share
+libexecdir = $(exec_prefix)/libexec
+sbindir = $(exec_prefix)/sbin
+bindir = $(exec_prefix)/bin
+archdir = $(rubyarchdir)
+
+
+CC = gcc
+CXX = g++
+LIBRUBY = $(LIBRUBY_SO)
+LIBRUBY_A = lib$(RUBY_SO_NAME)-static.a
+LIBRUBYARG_SHARED = -Wl,-R$(libdir) -L$(libdir) -l$(RUBY_SO_NAME)
+LIBRUBYARG_STATIC = -Wl,-R$(libdir) -L$(libdir) -l$(RUBY_SO_NAME)-static
+empty =
+OUTFLAG = -o $(empty)
+COUTFLAG = -o $(empty)
+
+RUBY_EXTCONF_H = extconf.h
+cflags = $(optflags) $(debugflags) $(warnflags)
+optflags = -O3 -fno-fast-math
+debugflags = -ggdb3
+warnflags = -Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wunused-variable -Wpointer-arith -Wwrite-strings -Wdeclaration-after-statement -Wimplicit-function-declaration -Wdeprecated-declarations -Wno-packed-bitfield-compat -Werror=deprecated-declarations
+CCDLFLAGS = -fPIC
+CFLAGS = $(CCDLFLAGS) $(cflags) -fPIC $(ARCH_FLAG)
+INCFLAGS = -I. -I$(arch_hdrdir) -I$(hdrdir) -I$(srcdir) -I$(srcdir)/..
+DEFS =
+CPPFLAGS = -DRUBY_EXTCONF_H=\"$(RUBY_EXTCONF_H)\" $(DEFS) $(cppflags)
+CXXFLAGS = $(CCDLFLAGS) $(cxxflags) $(ARCH_FLAG)
+ldflags = -L. -fstack-protector -rdynamic -Wl,-export-dynamic
+dldflags =
+ARCH_FLAG =
+DLDFLAGS = $(ldflags) $(dldflags) $(ARCH_FLAG)
+LDSHARED = $(CC) -shared
+LDSHAREDXX = $(CXX) -shared
+AR = ar
+EXEEXT =
+
+RUBY_INSTALL_NAME = $(RUBY_BASE_NAME)
+RUBY_SO_NAME = ruby
+RUBYW_INSTALL_NAME =
+RUBY_VERSION_NAME = $(RUBY_BASE_NAME)-$(ruby_version)
+RUBYW_BASE_NAME = rubyw
+RUBY_BASE_NAME = ruby
+
+arch = x86_64-linux
+sitearch = $(arch)
+ruby_version = 2.2.0
+ruby = $(topdir)/miniruby -I'$(topdir)' -I'$(top_srcdir)/lib' -I'$(extout)/$(arch)' -I'$(extout)/common'
+RUBY = $(ruby)
+ruby_headers = $(hdrdir)/ruby.h $(hdrdir)/ruby/ruby.h $(hdrdir)/ruby/defines.h $(hdrdir)/ruby/missing.h $(hdrdir)/ruby/intern.h $(hdrdir)/ruby/st.h $(hdrdir)/ruby/subst.h $(arch_hdrdir)/ruby/config.h $(RUBY_EXTCONF_H)
+
+RM = rm -f
+RM_RF = $(RUBY) -run -e rm -- -rf
+RMDIRS = rmdir --ignore-fail-on-non-empty -p
+MAKEDIRS = /bin/mkdir -p
+INSTALL = /usr/bin/install -c
+INSTALL_PROG = $(INSTALL) -m 0755
+INSTALL_DATA = $(INSTALL) -m 644
+COPY = cp
+TOUCH = exit >
+
+#### End of system configuration section. ####
+
+preload = digest
+
+libpath = . $(topdir)
+LIBPATH = -L. -L$(topdir)
+DEFFILE =
+
+CLEANFILES = mkmf.log
+DISTCLEANFILES =
+DISTCLEANDIRS =
+
+extout = $(topdir)/.ext
+extout_prefix = $(extout)$(target_prefix)/
+target_prefix = /digest
+LOCAL_LIBS =
+LIBS = $(LIBRUBYARG_SHARED) -lcrypto -lssl -lcrypto -lpthread -lgmp -ldl -lcrypt -lm -lc
+ORIG_SRCS = md5ossl.c md5init.c md5.c
+SRCS = $(ORIG_SRCS) md5init.c md5ossl.c
+OBJS = md5init.o md5ossl.o
+HDRS = $(srcdir)/md5.h $(srcdir)/extconf.h $(srcdir)/md5ossl.h
+TARGET = md5
+TARGET_NAME = md5
+TARGET_ENTRY = Init_$(TARGET_NAME)
+DLLIB = $(TARGET).so
+EXTSTATIC =
+STATIC_LIB = $(TARGET).a
+
+TIMESTAMP_DIR = $(extout)/.timestamp
+BINDIR = $(extout)/bin
+RUBYCOMMONDIR = $(extout)/common
+RUBYLIBDIR = $(RUBYCOMMONDIR)$(target_prefix)
+RUBYARCHDIR = $(extout)/$(arch)$(target_prefix)
+HDRDIR = $(extout)/include/ruby$(target_prefix)
+ARCHHDRDIR = $(extout)/include/$(arch)/ruby$(target_prefix)
+
+TARGET_SO = $(RUBYARCHDIR)/$(DLLIB)
+CLEANLIBS = $(RUBYARCHDIR)/$(TARGET).so
+CLEANOBJS = *.o *.bak
+
+all: install
+static: all
+.PHONY: all install static install-so install-rb
+.PHONY: clean clean-so clean-static clean-rb
+
+clean-static::
+clean-rb-default::
+clean-rb::
+clean-so::
+clean: clean-so clean-static clean-rb-default clean-rb
+ -$(Q)$(RM) $(CLEANLIBS) $(CLEANOBJS) $(CLEANFILES) .*.time
+
+distclean-rb-default::
+distclean-rb::
+distclean-so::
+distclean-static::
+distclean: clean distclean-so distclean-static distclean-rb-default distclean-rb
+ -$(Q)$(RM) Makefile $(RUBY_EXTCONF_H) conftest.* mkmf.log
+ -$(Q)$(RM) core ruby$(EXEEXT) *~ $(DISTCLEANFILES)
+ -$(Q)$(RMDIRS) $(DISTCLEANDIRS) 2> /dev/null || true
+
+realclean: distclean
+install: install-so install-rb
+
+install-so: $(RUBYARCHDIR)/$(DLLIB)
+clean-so::
+ -$(Q)$(RM) $(RUBYARCHDIR)/$(DLLIB)
+ -$(Q)$(RMDIRS) $(RUBYARCHDIR) 2> /dev/null || true
+clean-static::
+ -$(Q)$(RM) $(STATIC_LIB)
+install-rb: pre-install-rb install-rb-default
+install-rb-default: pre-install-rb-default
+pre-install-rb: Makefile
+pre-install-rb-default: Makefile
+pre-install-rb-default:
+ @$(NULLCMD)
+$(TIMESTAMP_DIR)/.RUBYARCHDIR.-.digest.time:
+ $(Q) $(MAKEDIRS) $(@D) $(RUBYARCHDIR)
+ $(Q) $(TOUCH) $@
+
+site-install: site-install-so site-install-rb
+site-install-so: install-so
+site-install-rb: install-rb
+
+.SUFFIXES: .c .m .cc .mm .cxx .cpp .o .S
+
+.cc.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<
+
+.cc.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -S $<
+
+.mm.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<
+
+.mm.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -S $<
+
+.cxx.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<
+
+.cxx.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -S $<
+
+.cpp.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<
+
+.cpp.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -S $<
+
+.c.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -c $<
+
+.c.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -S $<
+
+.m.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -c $<
+
+.m.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -S $<
+
+$(RUBYARCHDIR)/$(DLLIB): $(OBJS) Makefile $(TIMESTAMP_DIR)/.RUBYARCHDIR.-.digest.time
+ $(ECHO) linking shared-object digest/$(DLLIB)
+ -$(Q)$(RM) $(@)
+ $(Q) $(LDSHARED) -o $@ $(OBJS) $(LIBPATH) $(DLDFLAGS) $(LOCAL_LIBS) $(LIBS)
+
+$(STATIC_LIB): $(OBJS)
+ -$(Q)$(RM) $(@)
+ $(ECHO) linking static-library $(@)
+ $(Q) $(AR) cru $@ $(OBJS)
+ -$(Q)ranlib $(@) 2> /dev/null || true
+
+###
+$(OBJS): $(RUBY_EXTCONF_H)
+
+md5.o: md5.c md5.h $(srcdir)/../defs.h
+
+# AUTOGENERATED DEPENDENCIES START
+md5init.o: $(RUBY_EXTCONF_H)
+md5init.o: $(arch_hdrdir)/ruby/config.h
+md5init.o: $(hdrdir)/ruby/defines.h
+md5init.o: $(hdrdir)/ruby/intern.h
+md5init.o: $(hdrdir)/ruby/missing.h
+md5init.o: $(hdrdir)/ruby/ruby.h
+md5init.o: $(hdrdir)/ruby/st.h
+md5init.o: $(hdrdir)/ruby/subst.h
+md5init.o: $(top_srcdir)/ext/digest/digest.h
+md5init.o: $(top_srcdir)/include/ruby.h
+md5init.o: md5init.c
+md5init.o: md5ossl.h
+md5ossl.o: md5ossl.c
+md5ossl.o: md5ossl.h
+# AUTOGENERATED DEPENDENCIES END
diff --git a/jni/ruby/ext/digest/md5/depend b/jni/ruby/ext/digest/md5/depend
new file mode 100644
index 0000000..288c30a
--- /dev/null
+++ b/jni/ruby/ext/digest/md5/depend
@@ -0,0 +1,18 @@
+md5.o: md5.c md5.h $(srcdir)/../defs.h
+
+# AUTOGENERATED DEPENDENCIES START
+md5init.o: $(RUBY_EXTCONF_H)
+md5init.o: $(arch_hdrdir)/ruby/config.h
+md5init.o: $(hdrdir)/ruby/defines.h
+md5init.o: $(hdrdir)/ruby/intern.h
+md5init.o: $(hdrdir)/ruby/missing.h
+md5init.o: $(hdrdir)/ruby/ruby.h
+md5init.o: $(hdrdir)/ruby/st.h
+md5init.o: $(hdrdir)/ruby/subst.h
+md5init.o: $(top_srcdir)/ext/digest/digest.h
+md5init.o: $(top_srcdir)/include/ruby.h
+md5init.o: md5init.c
+md5init.o: md5ossl.h
+md5ossl.o: md5ossl.c
+md5ossl.o: md5ossl.h
+# AUTOGENERATED DEPENDENCIES END
diff --git a/jni/ruby/ext/digest/md5/extconf.h b/jni/ruby/ext/digest/md5/extconf.h
new file mode 100644
index 0000000..930d061
--- /dev/null
+++ b/jni/ruby/ext/digest/md5/extconf.h
@@ -0,0 +1,7 @@
+#ifndef EXTCONF_H
+#define EXTCONF_H
+#define HAVE_CONFIG_H 1
+#define HAVE_MD5_TRANSFORM 1
+#define HAVE_OPENSSL_MD5_H 1
+#define HAVE_SYS_CDEFS_H 1
+#endif
diff --git a/jni/ruby/ext/digest/md5/extconf.rb b/jni/ruby/ext/digest/md5/extconf.rb
new file mode 100644
index 0000000..ed4a8f5
--- /dev/null
+++ b/jni/ruby/ext/digest/md5/extconf.rb
@@ -0,0 +1,27 @@
+# -*- coding: us-ascii -*-
+# $RoughId: extconf.rb,v 1.3 2001/08/14 19:54:51 knu Exp $
+# $Id: extconf.rb 47802 2014-10-05 02:03:55Z nobu $
+
+require "mkmf"
+
+$defs << "-DHAVE_CONFIG_H"
+$INCFLAGS << " -I$(srcdir)/.."
+
+$objs = [ "md5init.#{$OBJEXT}" ]
+
+if !with_config("bundled-md5") &&
+ (dir_config("openssl")
+ pkg_config("openssl")
+ require File.expand_path('../../../openssl/deprecation', __FILE__)
+ have_library("crypto")) &&
+ OpenSSL.check_func("MD5_Transform", "openssl/md5.h")
+ $objs << "md5ossl.#{$OBJEXT}"
+else
+ $objs << "md5.#{$OBJEXT}"
+end
+
+have_header("sys/cdefs.h")
+
+$preload = %w[digest]
+
+create_makefile("digest/md5")
diff --git a/jni/ruby/ext/digest/md5/md5.c b/jni/ruby/ext/digest/md5/md5.c
new file mode 100644
index 0000000..2cd842b
--- /dev/null
+++ b/jni/ruby/ext/digest/md5/md5.c
@@ -0,0 +1,424 @@
+/*
+ Copyright (C) 1999, 2000 Aladdin Enterprises. All rights reserved.
+
+ This software is provided 'as-is', without any express or implied
+ warranty. In no event will the authors be held liable for any damages
+ arising from the use of this software.
+
+ Permission is granted to anyone to use this software for any purpose,
+ including commercial applications, and to alter it and redistribute it
+ freely, subject to the following restrictions:
+
+ 1. The origin of this software must not be misrepresented; you must not
+ claim that you wrote the original software. If you use this software
+ in a product, an acknowledgment in the product documentation would be
+ appreciated but is not required.
+ 2. Altered source versions must be plainly marked as such, and must not be
+ misrepresented as being the original software.
+ 3. This notice may not be removed or altered from any source distribution.
+
+ L. Peter Deutsch
+ ghost@aladdin.com
+
+ */
+
+/*
+ Independent implementation of MD5 (RFC 1321).
+
+ This code implements the MD5 Algorithm defined in RFC 1321.
+ It is derived directly from the text of the RFC and not from the
+ reference implementation.
+
+ The original and principal author of md5.c is L. Peter Deutsch
+ <ghost@aladdin.com>. Other authors are noted in the change history
+ that follows (in reverse chronological order):
+
+ 2000-07-03 lpd Patched to eliminate warnings about "constant is
+ unsigned in ANSI C, signed in traditional";
+ made test program self-checking.
+ 1999-11-04 lpd Edited comments slightly for automatic TOC extraction.
+ 1999-10-18 lpd Fixed typo in header comment (ansi2knr rather than md5).
+ 1999-05-03 lpd Original version.
+ */
+
+/*
+ This code was modified for use in Ruby.
+
+ - Akinori MUSHA <knu@idaemons.org>
+ */
+
+/*$OrigId: md5c.c,v 1.2 2001/03/26 08:57:14 matz Exp $ */
+/*$RoughId: md5.c,v 1.2 2001/07/13 19:48:41 knu Exp $ */
+/*$Id: md5.c 47744 2014-09-30 05:25:32Z nobu $ */
+
+#include "md5.h"
+
+#ifdef TEST
+/*
+ * Compile with -DTEST to create a self-contained executable test program.
+ * The test program should print out the same values as given in section
+ * A.5 of RFC 1321, reproduced below.
+ */
+#include <string.h>
+int
+main(void)
+{
+ static const char *const test[7*2] = {
+ "", "d41d8cd98f00b204e9800998ecf8427e",
+ "a", "0cc175b9c0f1b6a831c399e269772661",
+ "abc", "900150983cd24fb0d6963f7d28e17f72",
+ "message digest", "f96b697d7cb7938d525a2f31aaf161d0",
+ "abcdefghijklmnopqrstuvwxyz", "c3fcd3d76192e4007dfb496cca67e13b",
+ "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",
+ "d174ab98d277d9f5a5611c2c9f419d9f",
+ "12345678901234567890123456789012345678901234567890123456789012345678901234567890", "57edf4a22be3c955ac49da2e2107b67a"
+ };
+ int i;
+
+ for (i = 0; i < 7*2; i += 2) {
+ MD5_CTX state;
+ uint8_t digest[16];
+ char hex_output[16*2 + 1];
+ int di;
+
+ MD5_Init(&state);
+ MD5_Update(&state, (const uint8_t *)test[i], strlen(test[i]));
+ MD5_Final(digest, &state);
+ printf("MD5 (\"%s\") = ", test[i]);
+ for (di = 0; di < 16; ++di)
+ sprintf(hex_output + di * 2, "%02x", digest[di]);
+ puts(hex_output);
+ if (strcmp(hex_output, test[i + 1]))
+ printf("**** ERROR, should be: %s\n", test[i + 1]);
+ }
+ return 0;
+}
+#endif /* TEST */
+
+
+/*
+ * For reference, here is the program that computed the T values.
+ */
+#ifdef COMPUTE_T_VALUES
+#include <math.h>
+int
+main(void)
+{
+ int i;
+ for (i = 1; i <= 64; ++i) {
+ unsigned long v = (unsigned long)(4294967296.0 * fabs(sin((double)i)));
+
+ /*
+ * The following nonsense is only to avoid compiler warnings about
+ * "integer constant is unsigned in ANSI C, signed with -traditional".
+ */
+ if (v >> 31) {
+ printf("#define T%d /* 0x%08lx */ (T_MASK ^ 0x%08lx)\n", i,
+ v, (unsigned long)(unsigned int)(~v));
+ } else {
+ printf("#define T%d 0x%08lx\n", i, v);
+ }
+ }
+ return 0;
+}
+#endif /* COMPUTE_T_VALUES */
+/*
+ * End of T computation program.
+ */
+#ifdef T_MASK
+#undef T_MASK
+#endif
+#define T_MASK ((uint32_t)~0)
+#define T1 /* 0xd76aa478 */ (T_MASK ^ 0x28955b87)
+#define T2 /* 0xe8c7b756 */ (T_MASK ^ 0x173848a9)
+#define T3 0x242070db
+#define T4 /* 0xc1bdceee */ (T_MASK ^ 0x3e423111)
+#define T5 /* 0xf57c0faf */ (T_MASK ^ 0x0a83f050)
+#define T6 0x4787c62a
+#define T7 /* 0xa8304613 */ (T_MASK ^ 0x57cfb9ec)
+#define T8 /* 0xfd469501 */ (T_MASK ^ 0x02b96afe)
+#define T9 0x698098d8
+#define T10 /* 0x8b44f7af */ (T_MASK ^ 0x74bb0850)
+#define T11 /* 0xffff5bb1 */ (T_MASK ^ 0x0000a44e)
+#define T12 /* 0x895cd7be */ (T_MASK ^ 0x76a32841)
+#define T13 0x6b901122
+#define T14 /* 0xfd987193 */ (T_MASK ^ 0x02678e6c)
+#define T15 /* 0xa679438e */ (T_MASK ^ 0x5986bc71)
+#define T16 0x49b40821
+#define T17 /* 0xf61e2562 */ (T_MASK ^ 0x09e1da9d)
+#define T18 /* 0xc040b340 */ (T_MASK ^ 0x3fbf4cbf)
+#define T19 0x265e5a51
+#define T20 /* 0xe9b6c7aa */ (T_MASK ^ 0x16493855)
+#define T21 /* 0xd62f105d */ (T_MASK ^ 0x29d0efa2)
+#define T22 0x02441453
+#define T23 /* 0xd8a1e681 */ (T_MASK ^ 0x275e197e)
+#define T24 /* 0xe7d3fbc8 */ (T_MASK ^ 0x182c0437)
+#define T25 0x21e1cde6
+#define T26 /* 0xc33707d6 */ (T_MASK ^ 0x3cc8f829)
+#define T27 /* 0xf4d50d87 */ (T_MASK ^ 0x0b2af278)
+#define T28 0x455a14ed
+#define T29 /* 0xa9e3e905 */ (T_MASK ^ 0x561c16fa)
+#define T30 /* 0xfcefa3f8 */ (T_MASK ^ 0x03105c07)
+#define T31 0x676f02d9
+#define T32 /* 0x8d2a4c8a */ (T_MASK ^ 0x72d5b375)
+#define T33 /* 0xfffa3942 */ (T_MASK ^ 0x0005c6bd)
+#define T34 /* 0x8771f681 */ (T_MASK ^ 0x788e097e)
+#define T35 0x6d9d6122
+#define T36 /* 0xfde5380c */ (T_MASK ^ 0x021ac7f3)
+#define T37 /* 0xa4beea44 */ (T_MASK ^ 0x5b4115bb)
+#define T38 0x4bdecfa9
+#define T39 /* 0xf6bb4b60 */ (T_MASK ^ 0x0944b49f)
+#define T40 /* 0xbebfbc70 */ (T_MASK ^ 0x4140438f)
+#define T41 0x289b7ec6
+#define T42 /* 0xeaa127fa */ (T_MASK ^ 0x155ed805)
+#define T43 /* 0xd4ef3085 */ (T_MASK ^ 0x2b10cf7a)
+#define T44 0x04881d05
+#define T45 /* 0xd9d4d039 */ (T_MASK ^ 0x262b2fc6)
+#define T46 /* 0xe6db99e5 */ (T_MASK ^ 0x1924661a)
+#define T47 0x1fa27cf8
+#define T48 /* 0xc4ac5665 */ (T_MASK ^ 0x3b53a99a)
+#define T49 /* 0xf4292244 */ (T_MASK ^ 0x0bd6ddbb)
+#define T50 0x432aff97
+#define T51 /* 0xab9423a7 */ (T_MASK ^ 0x546bdc58)
+#define T52 /* 0xfc93a039 */ (T_MASK ^ 0x036c5fc6)
+#define T53 0x655b59c3
+#define T54 /* 0x8f0ccc92 */ (T_MASK ^ 0x70f3336d)
+#define T55 /* 0xffeff47d */ (T_MASK ^ 0x00100b82)
+#define T56 /* 0x85845dd1 */ (T_MASK ^ 0x7a7ba22e)
+#define T57 0x6fa87e4f
+#define T58 /* 0xfe2ce6e0 */ (T_MASK ^ 0x01d3191f)
+#define T59 /* 0xa3014314 */ (T_MASK ^ 0x5cfebceb)
+#define T60 0x4e0811a1
+#define T61 /* 0xf7537e82 */ (T_MASK ^ 0x08ac817d)
+#define T62 /* 0xbd3af235 */ (T_MASK ^ 0x42c50dca)
+#define T63 0x2ad7d2bb
+#define T64 /* 0xeb86d391 */ (T_MASK ^ 0x14792c6e)
+
+
+static void
+md5_process(MD5_CTX *pms, const uint8_t *data /*[64]*/)
+{
+ uint32_t
+ a = pms->state[0], b = pms->state[1],
+ c = pms->state[2], d = pms->state[3];
+ uint32_t t;
+
+#ifdef WORDS_BIGENDIAN
+
+ /*
+ * On big-endian machines, we must arrange the bytes in the right
+ * order. (This also works on machines of unknown byte order.)
+ */
+ uint32_t X[16];
+ const uint8_t *xp = data;
+ int i;
+
+ for (i = 0; i < 16; ++i, xp += 4)
+ X[i] = xp[0] + (xp[1] << 8) + (xp[2] << 16) + (xp[3] << 24);
+
+#else
+
+ /*
+ * On little-endian machines, we can process properly aligned data
+ * without copying it.
+ */
+ uint32_t xbuf[16];
+ const uint32_t *X;
+
+ if (!((data - (const uint8_t *)0) & 3)) {
+ /* data are properly aligned */
+ X = (const uint32_t *)data;
+ } else {
+ /* not aligned */
+ memcpy(xbuf, data, 64);
+ X = xbuf;
+ }
+#endif
+
+#define ROTATE_LEFT(x, n) (((x) << (n)) | ((x) >> (32 - (n))))
+
+ /* Round 1. */
+ /* Let [abcd k s i] denote the operation
+ a = b + ((a + F(b,c,d) + X[k] + T[i]) <<< s). */
+#define F(x, y, z) (((x) & (y)) | (~(x) & (z)))
+#define SET(a, b, c, d, k, s, Ti)\
+ t = a + F(b,c,d) + X[k] + Ti;\
+ a = ROTATE_LEFT(t, s) + b
+ /* Do the following 16 operations. */
+ SET(a, b, c, d, 0, 7, T1);
+ SET(d, a, b, c, 1, 12, T2);
+ SET(c, d, a, b, 2, 17, T3);
+ SET(b, c, d, a, 3, 22, T4);
+ SET(a, b, c, d, 4, 7, T5);
+ SET(d, a, b, c, 5, 12, T6);
+ SET(c, d, a, b, 6, 17, T7);
+ SET(b, c, d, a, 7, 22, T8);
+ SET(a, b, c, d, 8, 7, T9);
+ SET(d, a, b, c, 9, 12, T10);
+ SET(c, d, a, b, 10, 17, T11);
+ SET(b, c, d, a, 11, 22, T12);
+ SET(a, b, c, d, 12, 7, T13);
+ SET(d, a, b, c, 13, 12, T14);
+ SET(c, d, a, b, 14, 17, T15);
+ SET(b, c, d, a, 15, 22, T16);
+#undef SET
+
+ /* Round 2. */
+ /* Let [abcd k s i] denote the operation
+ a = b + ((a + G(b,c,d) + X[k] + T[i]) <<< s). */
+#define G(x, y, z) (((x) & (z)) | ((y) & ~(z)))
+#define SET(a, b, c, d, k, s, Ti)\
+ t = a + G(b,c,d) + X[k] + Ti;\
+ a = ROTATE_LEFT(t, s) + b
+ /* Do the following 16 operations. */
+ SET(a, b, c, d, 1, 5, T17);
+ SET(d, a, b, c, 6, 9, T18);
+ SET(c, d, a, b, 11, 14, T19);
+ SET(b, c, d, a, 0, 20, T20);
+ SET(a, b, c, d, 5, 5, T21);
+ SET(d, a, b, c, 10, 9, T22);
+ SET(c, d, a, b, 15, 14, T23);
+ SET(b, c, d, a, 4, 20, T24);
+ SET(a, b, c, d, 9, 5, T25);
+ SET(d, a, b, c, 14, 9, T26);
+ SET(c, d, a, b, 3, 14, T27);
+ SET(b, c, d, a, 8, 20, T28);
+ SET(a, b, c, d, 13, 5, T29);
+ SET(d, a, b, c, 2, 9, T30);
+ SET(c, d, a, b, 7, 14, T31);
+ SET(b, c, d, a, 12, 20, T32);
+#undef SET
+
+ /* Round 3. */
+ /* Let [abcd k s t] denote the operation
+ a = b + ((a + H(b,c,d) + X[k] + T[i]) <<< s). */
+#define H(x, y, z) ((x) ^ (y) ^ (z))
+#define SET(a, b, c, d, k, s, Ti)\
+ t = a + H(b,c,d) + X[k] + Ti;\
+ a = ROTATE_LEFT(t, s) + b
+ /* Do the following 16 operations. */
+ SET(a, b, c, d, 5, 4, T33);
+ SET(d, a, b, c, 8, 11, T34);
+ SET(c, d, a, b, 11, 16, T35);
+ SET(b, c, d, a, 14, 23, T36);
+ SET(a, b, c, d, 1, 4, T37);
+ SET(d, a, b, c, 4, 11, T38);
+ SET(c, d, a, b, 7, 16, T39);
+ SET(b, c, d, a, 10, 23, T40);
+ SET(a, b, c, d, 13, 4, T41);
+ SET(d, a, b, c, 0, 11, T42);
+ SET(c, d, a, b, 3, 16, T43);
+ SET(b, c, d, a, 6, 23, T44);
+ SET(a, b, c, d, 9, 4, T45);
+ SET(d, a, b, c, 12, 11, T46);
+ SET(c, d, a, b, 15, 16, T47);
+ SET(b, c, d, a, 2, 23, T48);
+#undef SET
+
+ /* Round 4. */
+ /* Let [abcd k s t] denote the operation
+ a = b + ((a + I(b,c,d) + X[k] + T[i]) <<< s). */
+#define I(x, y, z) ((y) ^ ((x) | ~(z)))
+#define SET(a, b, c, d, k, s, Ti)\
+ t = a + I(b,c,d) + X[k] + Ti;\
+ a = ROTATE_LEFT(t, s) + b
+ /* Do the following 16 operations. */
+ SET(a, b, c, d, 0, 6, T49);
+ SET(d, a, b, c, 7, 10, T50);
+ SET(c, d, a, b, 14, 15, T51);
+ SET(b, c, d, a, 5, 21, T52);
+ SET(a, b, c, d, 12, 6, T53);
+ SET(d, a, b, c, 3, 10, T54);
+ SET(c, d, a, b, 10, 15, T55);
+ SET(b, c, d, a, 1, 21, T56);
+ SET(a, b, c, d, 8, 6, T57);
+ SET(d, a, b, c, 15, 10, T58);
+ SET(c, d, a, b, 6, 15, T59);
+ SET(b, c, d, a, 13, 21, T60);
+ SET(a, b, c, d, 4, 6, T61);
+ SET(d, a, b, c, 11, 10, T62);
+ SET(c, d, a, b, 2, 15, T63);
+ SET(b, c, d, a, 9, 21, T64);
+#undef SET
+
+ /* Then perform the following additions. (That is increment each
+ of the four registers by the value it had before this block
+ was started.) */
+ pms->state[0] += a;
+ pms->state[1] += b;
+ pms->state[2] += c;
+ pms->state[3] += d;
+}
+
+int
+MD5_Init(MD5_CTX *pms)
+{
+ pms->count[0] = pms->count[1] = 0;
+ pms->state[0] = 0x67452301;
+ pms->state[1] = /*0xefcdab89*/ T_MASK ^ 0x10325476;
+ pms->state[2] = /*0x98badcfe*/ T_MASK ^ 0x67452301;
+ pms->state[3] = 0x10325476;
+ return 1;
+}
+
+void
+MD5_Update(MD5_CTX *pms, const uint8_t *data, size_t nbytes)
+{
+ const uint8_t *p = data;
+ size_t left = nbytes;
+ size_t offset = (pms->count[0] >> 3) & 63;
+ uint32_t nbits = (uint32_t)(nbytes << 3);
+
+ if (nbytes == 0)
+ return;
+
+ /* Update the message length. */
+ pms->count[1] += nbytes >> 29;
+ pms->count[0] += nbits;
+ if (pms->count[0] < nbits)
+ pms->count[1]++;
+
+ /* Process an initial partial block. */
+ if (offset) {
+ size_t copy = (offset + nbytes > 64 ? 64 - offset : nbytes);
+
+ memcpy(pms->buffer + offset, p, copy);
+ if (offset + copy < 64)
+ return;
+ p += copy;
+ left -= copy;
+ md5_process(pms, pms->buffer);
+ }
+
+ /* Process full blocks. */
+ for (; left >= 64; p += 64, left -= 64)
+ md5_process(pms, p);
+
+ /* Process a final partial block. */
+ if (left)
+ memcpy(pms->buffer, p, left);
+}
+
+int
+MD5_Finish(MD5_CTX *pms, uint8_t *digest)
+{
+ static const uint8_t pad[64] = {
+ 0x80, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
+ };
+ uint8_t data[8];
+ size_t i;
+
+ /* Save the length before padding. */
+ for (i = 0; i < 8; ++i)
+ data[i] = (uint8_t)(pms->count[i >> 2] >> ((i & 3) << 3));
+ /* Pad to 56 bytes mod 64. */
+ MD5_Update(pms, pad, ((55 - (pms->count[0] >> 3)) & 63) + 1);
+ /* Append the length. */
+ MD5_Update(pms, data, 8);
+ for (i = 0; i < 16; ++i)
+ digest[i] = (uint8_t)(pms->state[i >> 2] >> ((i & 3) << 3));
+ return 1;
+}
diff --git a/jni/ruby/ext/digest/md5/md5.h b/jni/ruby/ext/digest/md5/md5.h
new file mode 100644
index 0000000..25850fc
--- /dev/null
+++ b/jni/ruby/ext/digest/md5/md5.h
@@ -0,0 +1,80 @@
+/*
+ Copyright (C) 1999 Aladdin Enterprises. All rights reserved.
+
+ This software is provided 'as-is', without any express or implied
+ warranty. In no event will the authors be held liable for any damages
+ arising from the use of this software.
+
+ Permission is granted to anyone to use this software for any purpose,
+ including commercial applications, and to alter it and redistribute it
+ freely, subject to the following restrictions:
+
+ 1. The origin of this software must not be misrepresented; you must not
+ claim that you wrote the original software. If you use this software
+ in a product, an acknowledgment in the product documentation would be
+ appreciated but is not required.
+ 2. Altered source versions must be plainly marked as such, and must not be
+ misrepresented as being the original software.
+ 3. This notice may not be removed or altered from any source distribution.
+
+ L. Peter Deutsch
+ ghost@aladdin.com
+
+ */
+/*
+ Independent implementation of MD5 (RFC 1321).
+
+ This code implements the MD5 Algorithm defined in RFC 1321.
+ It is derived directly from the text of the RFC and not from the
+ reference implementation.
+
+ The original and principal author of md5.h is L. Peter Deutsch
+ <ghost@aladdin.com>. Other authors are noted in the change history
+ that follows (in reverse chronological order):
+
+ 1999-11-04 lpd Edited comments slightly for automatic TOC extraction.
+ 1999-10-18 lpd Fixed typo in header comment (ansi2knr rather than md5);
+ added conditionalization for C++ compilation from Martin
+ Purschke <purschke@bnl.gov>.
+ 1999-05-03 lpd Original version.
+ */
+
+/* $OrigId: md5.h,v 1.2 2001/03/26 08:57:14 matz Exp $ */
+/* $RoughId: md5.h,v 1.3 2002/02/24 08:14:31 knu Exp $ */
+/* $Id: md5.h 46827 2014-07-15 14:59:20Z nobu $ */
+
+#ifndef MD5_INCLUDED
+# define MD5_INCLUDED
+
+#include "defs.h"
+
+/*
+ * This code has some adaptations for the Ghostscript environment, but it
+ * will compile and run correctly in any environment with 8-bit chars and
+ * 32-bit ints. Specifically, it assumes that if the following are
+ * defined, they have the same meaning as in Ghostscript: P1, P2, P3.
+ */
+
+/* Define the state of the MD5 Algorithm. */
+typedef struct md5_state_s {
+ uint32_t count[2]; /* message length in bits, lsw first */
+ uint32_t state[4]; /* digest buffer */
+ uint8_t buffer[64]; /* accumulate block */
+} MD5_CTX;
+
+#ifdef RUBY
+/* avoid name clash */
+#define MD5_Init rb_Digest_MD5_Init
+#define MD5_Update rb_Digest_MD5_Update
+#define MD5_Finish rb_Digest_MD5_Finish
+#endif
+
+int MD5_Init _((MD5_CTX *pms));
+void MD5_Update _((MD5_CTX *pms, const uint8_t *data, size_t nbytes));
+int MD5_Finish _((MD5_CTX *pms, uint8_t *digest));
+
+#define MD5_BLOCK_LENGTH 64
+#define MD5_DIGEST_LENGTH 16
+#define MD5_DIGEST_STRING_LENGTH (MD5_DIGEST_LENGTH * 2 + 1)
+
+#endif /* MD5_INCLUDED */
diff --git a/jni/ruby/ext/digest/md5/md5init.c b/jni/ruby/ext/digest/md5/md5init.c
new file mode 100644
index 0000000..f31a223
--- /dev/null
+++ b/jni/ruby/ext/digest/md5/md5init.c
@@ -0,0 +1,45 @@
+/* $RoughId: md5init.c,v 1.2 2001/07/13 19:49:10 knu Exp $ */
+/* $Id: md5init.c 47745 2014-09-30 08:29:02Z nobu $ */
+
+#include "digest.h"
+#if defined(HAVE_OPENSSL_MD5_H)
+#include "md5ossl.h"
+#else
+#include "md5.h"
+#endif
+
+static const rb_digest_metadata_t md5 = {
+ RUBY_DIGEST_API_VERSION,
+ MD5_DIGEST_LENGTH,
+ MD5_BLOCK_LENGTH,
+ sizeof(MD5_CTX),
+ (rb_digest_hash_init_func_t)MD5_Init,
+ (rb_digest_hash_update_func_t)MD5_Update,
+ (rb_digest_hash_finish_func_t)MD5_Finish,
+};
+
+/*
+ * A class for calculating message digests using the MD5
+ * Message-Digest Algorithm by RSA Data Security, Inc., described in
+ * RFC1321.
+ */
+void
+Init_md5(void)
+{
+ VALUE mDigest, cDigest_Base, cDigest_MD5;
+
+ rb_require("digest");
+
+#if 0
+ mDigest = rb_define_module("Digest"); /* let rdoc know */
+#endif
+ mDigest = rb_path2class("Digest");
+ cDigest_Base = rb_path2class("Digest::Base");
+
+ cDigest_MD5 = rb_define_class_under(mDigest, "MD5", cDigest_Base);
+
+#undef RUBY_UNTYPED_DATA_WARNING
+#define RUBY_UNTYPED_DATA_WARNING 0
+ rb_ivar_set(cDigest_MD5, rb_intern("metadata"),
+ Data_Wrap_Struct(0, 0, 0, (void *)&md5));
+}
diff --git a/jni/ruby/ext/digest/md5/md5ossl.c b/jni/ruby/ext/digest/md5/md5ossl.c
new file mode 100644
index 0000000..f08241e
--- /dev/null
+++ b/jni/ruby/ext/digest/md5/md5ossl.c
@@ -0,0 +1,9 @@
+/* $Id: md5ossl.c 46829 2014-07-15 15:43:03Z nobu $ */
+
+#include "md5ossl.h"
+
+void
+MD5_Finish(MD5_CTX *pctx, unsigned char *digest)
+{
+ MD5_Final(digest, pctx);
+}
diff --git a/jni/ruby/ext/digest/md5/md5ossl.h b/jni/ruby/ext/digest/md5/md5ossl.h
new file mode 100644
index 0000000..7523038
--- /dev/null
+++ b/jni/ruby/ext/digest/md5/md5ossl.h
@@ -0,0 +1,13 @@
+/* $Id: md5ossl.h 46829 2014-07-15 15:43:03Z nobu $ */
+
+#ifndef MD5OSSL_H_INCLUDED
+#define MD5OSSL_H_INCLUDED
+
+#include <stddef.h>
+#include <openssl/md5.h>
+
+#define MD5_BLOCK_LENGTH MD5_CBLOCK
+
+void MD5_Finish(MD5_CTX *pctx, unsigned char *digest);
+
+#endif
diff --git a/jni/ruby/ext/digest/rmd160/Makefile b/jni/ruby/ext/digest/rmd160/Makefile
new file mode 100644
index 0000000..86c5ef2
--- /dev/null
+++ b/jni/ruby/ext/digest/rmd160/Makefile
@@ -0,0 +1,297 @@
+
+SHELL = /bin/sh
+
+# V=0 quiet, V=1 verbose. other values don't work.
+V = 0
+Q1 = $(V:1=)
+Q = $(Q1:0=@)
+ECHO1 = $(V:1=@:)
+ECHO = $(ECHO1:0=@echo)
+NULLCMD = :
+
+#### Start of system configuration section. ####
+top_srcdir = $(topdir)/.
+srcdir = $(top_srcdir)/ext/digest/rmd160
+topdir = ../../..
+hdrdir = $(top_srcdir)/include
+arch_hdrdir = $(extout)/include/$(arch)
+PATH_SEPARATOR = :
+VPATH = $(srcdir):$(arch_hdrdir)/ruby:$(hdrdir)/ruby
+RUBYLIB =
+RUBYOPT = -
+prefix = $(DESTDIR)/usr/local
+rubysitearchprefix = $(rubylibprefix)/$(sitearch)
+rubyarchprefix = $(rubylibprefix)/$(arch)
+rubylibprefix = $(libdir)/$(RUBY_BASE_NAME)
+exec_prefix = $(prefix)
+vendorarchhdrdir = $(vendorhdrdir)/$(sitearch)
+sitearchhdrdir = $(sitehdrdir)/$(sitearch)
+rubyarchhdrdir = $(rubyhdrdir)/$(arch)
+vendorhdrdir = $(rubyhdrdir)/vendor_ruby
+sitehdrdir = $(rubyhdrdir)/site_ruby
+rubyhdrdir = $(includedir)/$(RUBY_VERSION_NAME)
+vendorarchdir = $(vendorlibdir)/$(sitearch)
+vendorlibdir = $(vendordir)/$(ruby_version)
+vendordir = $(rubylibprefix)/vendor_ruby
+sitearchdir = $(sitelibdir)/$(sitearch)
+sitelibdir = $(sitedir)/$(ruby_version)
+sitedir = $(rubylibprefix)/site_ruby
+rubyarchdir = $(rubylibdir)/$(arch)
+rubylibdir = $(rubylibprefix)/$(ruby_version)
+sitearchincludedir = $(includedir)/$(sitearch)
+archincludedir = $(includedir)/$(arch)
+sitearchlibdir = $(libdir)/$(sitearch)
+archlibdir = $(libdir)/$(arch)
+ridir = $(datarootdir)/$(RI_BASE_NAME)
+mandir = $(datarootdir)/man
+localedir = $(datarootdir)/locale
+libdir = $(exec_prefix)/lib
+psdir = $(docdir)
+pdfdir = $(docdir)
+dvidir = $(docdir)
+htmldir = $(docdir)
+infodir = $(datarootdir)/info
+docdir = $(datarootdir)/doc/$(PACKAGE)
+oldincludedir = $(DESTDIR)/usr/include
+includedir = $(prefix)/include
+localstatedir = $(prefix)/var
+sharedstatedir = $(prefix)/com
+sysconfdir = $(prefix)/etc
+datadir = $(datarootdir)
+datarootdir = $(prefix)/share
+libexecdir = $(exec_prefix)/libexec
+sbindir = $(exec_prefix)/sbin
+bindir = $(exec_prefix)/bin
+archdir = $(rubyarchdir)
+
+
+CC = gcc
+CXX = g++
+LIBRUBY = $(LIBRUBY_SO)
+LIBRUBY_A = lib$(RUBY_SO_NAME)-static.a
+LIBRUBYARG_SHARED = -Wl,-R$(libdir) -L$(libdir) -l$(RUBY_SO_NAME)
+LIBRUBYARG_STATIC = -Wl,-R$(libdir) -L$(libdir) -l$(RUBY_SO_NAME)-static
+empty =
+OUTFLAG = -o $(empty)
+COUTFLAG = -o $(empty)
+
+RUBY_EXTCONF_H = extconf.h
+cflags = $(optflags) $(debugflags) $(warnflags)
+optflags = -O3 -fno-fast-math
+debugflags = -ggdb3
+warnflags = -Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wunused-variable -Wpointer-arith -Wwrite-strings -Wdeclaration-after-statement -Wimplicit-function-declaration -Wdeprecated-declarations -Wno-packed-bitfield-compat
+CCDLFLAGS = -fPIC
+CFLAGS = $(CCDLFLAGS) $(cflags) -fPIC $(ARCH_FLAG)
+INCFLAGS = -I. -I$(arch_hdrdir) -I$(hdrdir) -I$(srcdir) -I$(srcdir)/..
+DEFS =
+CPPFLAGS = -DRUBY_EXTCONF_H=\"$(RUBY_EXTCONF_H)\" $(DEFS) $(cppflags)
+CXXFLAGS = $(CCDLFLAGS) $(cxxflags) $(ARCH_FLAG)
+ldflags = -L. -fstack-protector -rdynamic -Wl,-export-dynamic
+dldflags =
+ARCH_FLAG =
+DLDFLAGS = $(ldflags) $(dldflags) $(ARCH_FLAG)
+LDSHARED = $(CC) -shared
+LDSHAREDXX = $(CXX) -shared
+AR = ar
+EXEEXT =
+
+RUBY_INSTALL_NAME = $(RUBY_BASE_NAME)
+RUBY_SO_NAME = ruby
+RUBYW_INSTALL_NAME =
+RUBY_VERSION_NAME = $(RUBY_BASE_NAME)-$(ruby_version)
+RUBYW_BASE_NAME = rubyw
+RUBY_BASE_NAME = ruby
+
+arch = x86_64-linux
+sitearch = $(arch)
+ruby_version = 2.2.0
+ruby = $(topdir)/miniruby -I'$(topdir)' -I'$(top_srcdir)/lib' -I'$(extout)/$(arch)' -I'$(extout)/common'
+RUBY = $(ruby)
+ruby_headers = $(hdrdir)/ruby.h $(hdrdir)/ruby/ruby.h $(hdrdir)/ruby/defines.h $(hdrdir)/ruby/missing.h $(hdrdir)/ruby/intern.h $(hdrdir)/ruby/st.h $(hdrdir)/ruby/subst.h $(arch_hdrdir)/ruby/config.h $(RUBY_EXTCONF_H)
+
+RM = rm -f
+RM_RF = $(RUBY) -run -e rm -- -rf
+RMDIRS = rmdir --ignore-fail-on-non-empty -p
+MAKEDIRS = /bin/mkdir -p
+INSTALL = /usr/bin/install -c
+INSTALL_PROG = $(INSTALL) -m 0755
+INSTALL_DATA = $(INSTALL) -m 644
+COPY = cp
+TOUCH = exit >
+
+#### End of system configuration section. ####
+
+preload = digest
+
+libpath = . $(topdir)
+LIBPATH = -L. -L$(topdir)
+DEFFILE =
+
+CLEANFILES = mkmf.log
+DISTCLEANFILES =
+DISTCLEANDIRS =
+
+extout = $(topdir)/.ext
+extout_prefix = $(extout)$(target_prefix)/
+target_prefix = /digest
+LOCAL_LIBS =
+LIBS = $(LIBRUBYARG_SHARED) -lcrypto -lssl -lcrypto -lpthread -lgmp -ldl -lcrypt -lm -lc
+ORIG_SRCS = rmd160init.c rmd160.c rmd160ossl.c
+SRCS = $(ORIG_SRCS) rmd160init.c rmd160ossl.c
+OBJS = rmd160init.o rmd160ossl.o
+HDRS = $(srcdir)/rmd160.h $(srcdir)/rmd160ossl.h $(srcdir)/extconf.h
+TARGET = rmd160
+TARGET_NAME = rmd160
+TARGET_ENTRY = Init_$(TARGET_NAME)
+DLLIB = $(TARGET).so
+EXTSTATIC =
+STATIC_LIB = $(TARGET).a
+
+TIMESTAMP_DIR = $(extout)/.timestamp
+BINDIR = $(extout)/bin
+RUBYCOMMONDIR = $(extout)/common
+RUBYLIBDIR = $(RUBYCOMMONDIR)$(target_prefix)
+RUBYARCHDIR = $(extout)/$(arch)$(target_prefix)
+HDRDIR = $(extout)/include/ruby$(target_prefix)
+ARCHHDRDIR = $(extout)/include/$(arch)/ruby$(target_prefix)
+
+TARGET_SO = $(RUBYARCHDIR)/$(DLLIB)
+CLEANLIBS = $(RUBYARCHDIR)/$(TARGET).so
+CLEANOBJS = *.o *.bak
+
+all: install
+static: all
+.PHONY: all install static install-so install-rb
+.PHONY: clean clean-so clean-static clean-rb
+
+clean-static::
+clean-rb-default::
+clean-rb::
+clean-so::
+clean: clean-so clean-static clean-rb-default clean-rb
+ -$(Q)$(RM) $(CLEANLIBS) $(CLEANOBJS) $(CLEANFILES) .*.time
+
+distclean-rb-default::
+distclean-rb::
+distclean-so::
+distclean-static::
+distclean: clean distclean-so distclean-static distclean-rb-default distclean-rb
+ -$(Q)$(RM) Makefile $(RUBY_EXTCONF_H) conftest.* mkmf.log
+ -$(Q)$(RM) core ruby$(EXEEXT) *~ $(DISTCLEANFILES)
+ -$(Q)$(RMDIRS) $(DISTCLEANDIRS) 2> /dev/null || true
+
+realclean: distclean
+install: install-so install-rb
+
+install-so: $(RUBYARCHDIR)/$(DLLIB)
+clean-so::
+ -$(Q)$(RM) $(RUBYARCHDIR)/$(DLLIB)
+ -$(Q)$(RMDIRS) $(RUBYARCHDIR) 2> /dev/null || true
+clean-static::
+ -$(Q)$(RM) $(STATIC_LIB)
+install-rb: pre-install-rb install-rb-default
+install-rb-default: pre-install-rb-default
+pre-install-rb: Makefile
+pre-install-rb-default: Makefile
+pre-install-rb-default:
+ @$(NULLCMD)
+$(TIMESTAMP_DIR)/.RUBYARCHDIR.-.digest.time:
+ $(Q) $(MAKEDIRS) $(@D) $(RUBYARCHDIR)
+ $(Q) $(TOUCH) $@
+
+site-install: site-install-so site-install-rb
+site-install-so: install-so
+site-install-rb: install-rb
+
+.SUFFIXES: .c .m .cc .mm .cxx .cpp .o .S
+
+.cc.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<
+
+.cc.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -S $<
+
+.mm.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<
+
+.mm.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -S $<
+
+.cxx.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<
+
+.cxx.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -S $<
+
+.cpp.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<
+
+.cpp.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -S $<
+
+.c.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -c $<
+
+.c.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -S $<
+
+.m.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -c $<
+
+.m.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -S $<
+
+$(RUBYARCHDIR)/$(DLLIB): $(OBJS) Makefile $(TIMESTAMP_DIR)/.RUBYARCHDIR.-.digest.time
+ $(ECHO) linking shared-object digest/$(DLLIB)
+ -$(Q)$(RM) $(@)
+ $(Q) $(LDSHARED) -o $@ $(OBJS) $(LIBPATH) $(DLDFLAGS) $(LOCAL_LIBS) $(LIBS)
+
+$(STATIC_LIB): $(OBJS)
+ -$(Q)$(RM) $(@)
+ $(ECHO) linking static-library $(@)
+ $(Q) $(AR) cru $@ $(OBJS)
+ -$(Q)ranlib $(@) 2> /dev/null || true
+
+###
+$(OBJS): $(RUBY_EXTCONF_H)
+
+rmd160.o: rmd160.c rmd160.h $(srcdir)/../defs.h $(HDRS) $(ruby_headers)
+
+# AUTOGENERATED DEPENDENCIES START
+rmd160init.o: $(RUBY_EXTCONF_H)
+rmd160init.o: $(arch_hdrdir)/ruby/config.h
+rmd160init.o: $(hdrdir)/ruby/defines.h
+rmd160init.o: $(hdrdir)/ruby/intern.h
+rmd160init.o: $(hdrdir)/ruby/missing.h
+rmd160init.o: $(hdrdir)/ruby/ruby.h
+rmd160init.o: $(hdrdir)/ruby/st.h
+rmd160init.o: $(hdrdir)/ruby/subst.h
+rmd160init.o: $(top_srcdir)/ext/digest/digest.h
+rmd160init.o: $(top_srcdir)/include/ruby.h
+rmd160init.o: rmd160init.c
+rmd160init.o: rmd160ossl.h
+rmd160ossl.o: $(RUBY_EXTCONF_H)
+rmd160ossl.o: $(arch_hdrdir)/ruby/config.h
+rmd160ossl.o: $(hdrdir)/ruby/defines.h
+rmd160ossl.o: $(hdrdir)/ruby/intern.h
+rmd160ossl.o: $(hdrdir)/ruby/missing.h
+rmd160ossl.o: $(hdrdir)/ruby/ruby.h
+rmd160ossl.o: $(hdrdir)/ruby/st.h
+rmd160ossl.o: $(hdrdir)/ruby/subst.h
+rmd160ossl.o: $(top_srcdir)/ext/digest/defs.h
+rmd160ossl.o: $(top_srcdir)/include/ruby.h
+rmd160ossl.o: rmd160ossl.c
+rmd160ossl.o: rmd160ossl.h
+# AUTOGENERATED DEPENDENCIES END
diff --git a/jni/ruby/ext/digest/rmd160/depend b/jni/ruby/ext/digest/rmd160/depend
new file mode 100644
index 0000000..49cf2af
--- /dev/null
+++ b/jni/ruby/ext/digest/rmd160/depend
@@ -0,0 +1,28 @@
+rmd160.o: rmd160.c rmd160.h $(srcdir)/../defs.h $(HDRS) $(ruby_headers)
+
+# AUTOGENERATED DEPENDENCIES START
+rmd160init.o: $(RUBY_EXTCONF_H)
+rmd160init.o: $(arch_hdrdir)/ruby/config.h
+rmd160init.o: $(hdrdir)/ruby/defines.h
+rmd160init.o: $(hdrdir)/ruby/intern.h
+rmd160init.o: $(hdrdir)/ruby/missing.h
+rmd160init.o: $(hdrdir)/ruby/ruby.h
+rmd160init.o: $(hdrdir)/ruby/st.h
+rmd160init.o: $(hdrdir)/ruby/subst.h
+rmd160init.o: $(top_srcdir)/ext/digest/digest.h
+rmd160init.o: $(top_srcdir)/include/ruby.h
+rmd160init.o: rmd160init.c
+rmd160init.o: rmd160ossl.h
+rmd160ossl.o: $(RUBY_EXTCONF_H)
+rmd160ossl.o: $(arch_hdrdir)/ruby/config.h
+rmd160ossl.o: $(hdrdir)/ruby/defines.h
+rmd160ossl.o: $(hdrdir)/ruby/intern.h
+rmd160ossl.o: $(hdrdir)/ruby/missing.h
+rmd160ossl.o: $(hdrdir)/ruby/ruby.h
+rmd160ossl.o: $(hdrdir)/ruby/st.h
+rmd160ossl.o: $(hdrdir)/ruby/subst.h
+rmd160ossl.o: $(top_srcdir)/ext/digest/defs.h
+rmd160ossl.o: $(top_srcdir)/include/ruby.h
+rmd160ossl.o: rmd160ossl.c
+rmd160ossl.o: rmd160ossl.h
+# AUTOGENERATED DEPENDENCIES END
diff --git a/jni/ruby/ext/digest/rmd160/extconf.h b/jni/ruby/ext/digest/rmd160/extconf.h
new file mode 100644
index 0000000..bcacaee
--- /dev/null
+++ b/jni/ruby/ext/digest/rmd160/extconf.h
@@ -0,0 +1,8 @@
+#ifndef EXTCONF_H
+#define EXTCONF_H
+#define NDEBUG 1
+#define HAVE_CONFIG_H 1
+#define HAVE_RIPEMD160_TRANSFORM 1
+#define HAVE_OPENSSL_RIPEMD_H 1
+#define HAVE_SYS_CDEFS_H 1
+#endif
diff --git a/jni/ruby/ext/digest/rmd160/extconf.rb b/jni/ruby/ext/digest/rmd160/extconf.rb
new file mode 100644
index 0000000..6b870e9
--- /dev/null
+++ b/jni/ruby/ext/digest/rmd160/extconf.rb
@@ -0,0 +1,27 @@
+# -*- coding: us-ascii -*-
+# $RoughId: extconf.rb,v 1.3 2001/08/14 19:54:51 knu Exp $
+# $Id: extconf.rb 47802 2014-10-05 02:03:55Z nobu $
+
+require "mkmf"
+
+$defs << "-DNDEBUG" << "-DHAVE_CONFIG_H"
+$INCFLAGS << " -I$(srcdir)/.."
+
+$objs = [ "rmd160init.#{$OBJEXT}" ]
+
+if !with_config("bundled-rmd160") &&
+ (dir_config("openssl")
+ pkg_config("openssl")
+ require File.expand_path('../../../openssl/deprecation', __FILE__)
+ have_library("crypto")) &&
+ OpenSSL.check_func("RIPEMD160_Transform", "openssl/ripemd.h")
+ $objs << "rmd160ossl.#{$OBJEXT}"
+else
+ $objs << "rmd160.#{$OBJEXT}"
+end
+
+have_header("sys/cdefs.h")
+
+$preload = %w[digest]
+
+create_makefile("digest/rmd160")
diff --git a/jni/ruby/ext/digest/rmd160/rmd160.c b/jni/ruby/ext/digest/rmd160/rmd160.c
new file mode 100644
index 0000000..0b834f3
--- /dev/null
+++ b/jni/ruby/ext/digest/rmd160/rmd160.c
@@ -0,0 +1,463 @@
+/* $NetBSD: rmd160.c,v 1.1.1.1 2001/03/06 11:21:05 agc Exp $ */
+/* $RoughId: rmd160.c,v 1.2 2001/07/13 19:49:10 knu Exp $ */
+/* $Id: rmd160.c 46827 2014-07-15 14:59:20Z nobu $ */
+
+/********************************************************************\
+ *
+ * FILE: rmd160.c
+ *
+ * CONTENTS: A sample C-implementation of the RIPEMD-160
+ * hash-function.
+ * TARGET: any computer with an ANSI C compiler
+ *
+ * AUTHOR: Antoon Bosselaers, ESAT-COSIC
+ * (Arranged for libc by Todd C. Miller)
+ * DATE: 1 March 1996
+ * VERSION: 1.0
+ *
+ * Copyright (c) Katholieke Universiteit Leuven
+ * 1996, All Rights Reserved
+ *
+\********************************************************************/
+
+#include "rmd160.h"
+
+#ifndef lint
+/* __RCSID("$NetBSD: rmd160.c,v 1.1.1.1 2001/03/06 11:21:05 agc Exp $"); */
+#endif /* not lint */
+
+/* header files */
+
+#ifdef HAVE_SYS_ENDIAN_H_
+#include <sys/endian.h>
+#endif
+
+#ifdef HAVE_MACHINE_ENDIAN_H_
+#include <machine/endian.h>
+#endif
+
+/* #include "namespace.h" */
+
+#include <assert.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#ifndef _DIAGASSERT
+#define _DIAGASSERT(cond) assert(cond)
+#endif
+
+
+/********************************************************************/
+
+/* macro definitions */
+
+/* collect four bytes into one word: */
+#define BYTES_TO_DWORD(strptr) \
+ (((uint32_t) *((strptr)+3) << 24) | \
+ ((uint32_t) *((strptr)+2) << 16) | \
+ ((uint32_t) *((strptr)+1) << 8) | \
+ ((uint32_t) *(strptr)))
+
+/* ROL(x, n) cyclically rotates x over n bits to the left */
+/* x must be of an unsigned 32 bits type and 0 <= n < 32. */
+#define ROL(x, n) (((x) << (n)) | ((x) >> (32-(n))))
+
+/* the three basic functions F(), G() and H() */
+#define F(x, y, z) ((x) ^ (y) ^ (z))
+#define G(x, y, z) (((x) & (y)) | (~(x) & (z)))
+#define H(x, y, z) (((x) | ~(y)) ^ (z))
+#define I(x, y, z) (((x) & (z)) | ((y) & ~(z)))
+#define J(x, y, z) ((x) ^ ((y) | ~(z)))
+
+/* the eight basic operations FF() through III() */
+#define FF(a, b, c, d, e, x, s) { \
+ (a) += F((b), (c), (d)) + (x); \
+ (a) = ROL((a), (s)) + (e); \
+ (c) = ROL((c), 10); \
+}
+#define GG(a, b, c, d, e, x, s) { \
+ (a) += G((b), (c), (d)) + (x) + 0x5a827999U; \
+ (a) = ROL((a), (s)) + (e); \
+ (c) = ROL((c), 10); \
+}
+#define HH(a, b, c, d, e, x, s) { \
+ (a) += H((b), (c), (d)) + (x) + 0x6ed9eba1U; \
+ (a) = ROL((a), (s)) + (e); \
+ (c) = ROL((c), 10); \
+}
+#define II(a, b, c, d, e, x, s) { \
+ (a) += I((b), (c), (d)) + (x) + 0x8f1bbcdcU; \
+ (a) = ROL((a), (s)) + (e); \
+ (c) = ROL((c), 10); \
+}
+#define JJ(a, b, c, d, e, x, s) { \
+ (a) += J((b), (c), (d)) + (x) + 0xa953fd4eU; \
+ (a) = ROL((a), (s)) + (e); \
+ (c) = ROL((c), 10); \
+}
+#define FFF(a, b, c, d, e, x, s) { \
+ (a) += F((b), (c), (d)) + (x); \
+ (a) = ROL((a), (s)) + (e); \
+ (c) = ROL((c), 10); \
+}
+#define GGG(a, b, c, d, e, x, s) { \
+ (a) += G((b), (c), (d)) + (x) + 0x7a6d76e9U; \
+ (a) = ROL((a), (s)) + (e); \
+ (c) = ROL((c), 10); \
+}
+#define HHH(a, b, c, d, e, x, s) { \
+ (a) += H((b), (c), (d)) + (x) + 0x6d703ef3U; \
+ (a) = ROL((a), (s)) + (e); \
+ (c) = ROL((c), 10); \
+}
+#define III(a, b, c, d, e, x, s) { \
+ (a) += I((b), (c), (d)) + (x) + 0x5c4dd124U; \
+ (a) = ROL((a), (s)) + (e); \
+ (c) = ROL((c), 10); \
+}
+#define JJJ(a, b, c, d, e, x, s) { \
+ (a) += J((b), (c), (d)) + (x) + 0x50a28be6U; \
+ (a) = ROL((a), (s)) + (e); \
+ (c) = ROL((c), 10); \
+}
+
+/********************************************************************/
+
+int
+RMD160_Init(RMD160_CTX *context)
+{
+
+ _DIAGASSERT(context != NULL);
+
+ /* ripemd-160 initialization constants */
+ context->state[0] = 0x67452301U;
+ context->state[1] = 0xefcdab89U;
+ context->state[2] = 0x98badcfeU;
+ context->state[3] = 0x10325476U;
+ context->state[4] = 0xc3d2e1f0U;
+ context->length[0] = context->length[1] = 0;
+ context->buflen = 0;
+ return 1;
+}
+
+/********************************************************************/
+
+void
+RMD160_Transform(uint32_t state[5], const uint32_t block[16])
+{
+ uint32_t aa, bb, cc, dd, ee;
+ uint32_t aaa, bbb, ccc, ddd, eee;
+
+ _DIAGASSERT(state != NULL);
+ _DIAGASSERT(block != NULL);
+
+ aa = aaa = state[0];
+ bb = bbb = state[1];
+ cc = ccc = state[2];
+ dd = ddd = state[3];
+ ee = eee = state[4];
+
+ /* round 1 */
+ FF(aa, bb, cc, dd, ee, block[ 0], 11);
+ FF(ee, aa, bb, cc, dd, block[ 1], 14);
+ FF(dd, ee, aa, bb, cc, block[ 2], 15);
+ FF(cc, dd, ee, aa, bb, block[ 3], 12);
+ FF(bb, cc, dd, ee, aa, block[ 4], 5);
+ FF(aa, bb, cc, dd, ee, block[ 5], 8);
+ FF(ee, aa, bb, cc, dd, block[ 6], 7);
+ FF(dd, ee, aa, bb, cc, block[ 7], 9);
+ FF(cc, dd, ee, aa, bb, block[ 8], 11);
+ FF(bb, cc, dd, ee, aa, block[ 9], 13);
+ FF(aa, bb, cc, dd, ee, block[10], 14);
+ FF(ee, aa, bb, cc, dd, block[11], 15);
+ FF(dd, ee, aa, bb, cc, block[12], 6);
+ FF(cc, dd, ee, aa, bb, block[13], 7);
+ FF(bb, cc, dd, ee, aa, block[14], 9);
+ FF(aa, bb, cc, dd, ee, block[15], 8);
+
+ /* round 2 */
+ GG(ee, aa, bb, cc, dd, block[ 7], 7);
+ GG(dd, ee, aa, bb, cc, block[ 4], 6);
+ GG(cc, dd, ee, aa, bb, block[13], 8);
+ GG(bb, cc, dd, ee, aa, block[ 1], 13);
+ GG(aa, bb, cc, dd, ee, block[10], 11);
+ GG(ee, aa, bb, cc, dd, block[ 6], 9);
+ GG(dd, ee, aa, bb, cc, block[15], 7);
+ GG(cc, dd, ee, aa, bb, block[ 3], 15);
+ GG(bb, cc, dd, ee, aa, block[12], 7);
+ GG(aa, bb, cc, dd, ee, block[ 0], 12);
+ GG(ee, aa, bb, cc, dd, block[ 9], 15);
+ GG(dd, ee, aa, bb, cc, block[ 5], 9);
+ GG(cc, dd, ee, aa, bb, block[ 2], 11);
+ GG(bb, cc, dd, ee, aa, block[14], 7);
+ GG(aa, bb, cc, dd, ee, block[11], 13);
+ GG(ee, aa, bb, cc, dd, block[ 8], 12);
+
+ /* round 3 */
+ HH(dd, ee, aa, bb, cc, block[ 3], 11);
+ HH(cc, dd, ee, aa, bb, block[10], 13);
+ HH(bb, cc, dd, ee, aa, block[14], 6);
+ HH(aa, bb, cc, dd, ee, block[ 4], 7);
+ HH(ee, aa, bb, cc, dd, block[ 9], 14);
+ HH(dd, ee, aa, bb, cc, block[15], 9);
+ HH(cc, dd, ee, aa, bb, block[ 8], 13);
+ HH(bb, cc, dd, ee, aa, block[ 1], 15);
+ HH(aa, bb, cc, dd, ee, block[ 2], 14);
+ HH(ee, aa, bb, cc, dd, block[ 7], 8);
+ HH(dd, ee, aa, bb, cc, block[ 0], 13);
+ HH(cc, dd, ee, aa, bb, block[ 6], 6);
+ HH(bb, cc, dd, ee, aa, block[13], 5);
+ HH(aa, bb, cc, dd, ee, block[11], 12);
+ HH(ee, aa, bb, cc, dd, block[ 5], 7);
+ HH(dd, ee, aa, bb, cc, block[12], 5);
+
+ /* round 4 */
+ II(cc, dd, ee, aa, bb, block[ 1], 11);
+ II(bb, cc, dd, ee, aa, block[ 9], 12);
+ II(aa, bb, cc, dd, ee, block[11], 14);
+ II(ee, aa, bb, cc, dd, block[10], 15);
+ II(dd, ee, aa, bb, cc, block[ 0], 14);
+ II(cc, dd, ee, aa, bb, block[ 8], 15);
+ II(bb, cc, dd, ee, aa, block[12], 9);
+ II(aa, bb, cc, dd, ee, block[ 4], 8);
+ II(ee, aa, bb, cc, dd, block[13], 9);
+ II(dd, ee, aa, bb, cc, block[ 3], 14);
+ II(cc, dd, ee, aa, bb, block[ 7], 5);
+ II(bb, cc, dd, ee, aa, block[15], 6);
+ II(aa, bb, cc, dd, ee, block[14], 8);
+ II(ee, aa, bb, cc, dd, block[ 5], 6);
+ II(dd, ee, aa, bb, cc, block[ 6], 5);
+ II(cc, dd, ee, aa, bb, block[ 2], 12);
+
+ /* round 5 */
+ JJ(bb, cc, dd, ee, aa, block[ 4], 9);
+ JJ(aa, bb, cc, dd, ee, block[ 0], 15);
+ JJ(ee, aa, bb, cc, dd, block[ 5], 5);
+ JJ(dd, ee, aa, bb, cc, block[ 9], 11);
+ JJ(cc, dd, ee, aa, bb, block[ 7], 6);
+ JJ(bb, cc, dd, ee, aa, block[12], 8);
+ JJ(aa, bb, cc, dd, ee, block[ 2], 13);
+ JJ(ee, aa, bb, cc, dd, block[10], 12);
+ JJ(dd, ee, aa, bb, cc, block[14], 5);
+ JJ(cc, dd, ee, aa, bb, block[ 1], 12);
+ JJ(bb, cc, dd, ee, aa, block[ 3], 13);
+ JJ(aa, bb, cc, dd, ee, block[ 8], 14);
+ JJ(ee, aa, bb, cc, dd, block[11], 11);
+ JJ(dd, ee, aa, bb, cc, block[ 6], 8);
+ JJ(cc, dd, ee, aa, bb, block[15], 5);
+ JJ(bb, cc, dd, ee, aa, block[13], 6);
+
+ /* parallel round 1 */
+ JJJ(aaa, bbb, ccc, ddd, eee, block[ 5], 8);
+ JJJ(eee, aaa, bbb, ccc, ddd, block[14], 9);
+ JJJ(ddd, eee, aaa, bbb, ccc, block[ 7], 9);
+ JJJ(ccc, ddd, eee, aaa, bbb, block[ 0], 11);
+ JJJ(bbb, ccc, ddd, eee, aaa, block[ 9], 13);
+ JJJ(aaa, bbb, ccc, ddd, eee, block[ 2], 15);
+ JJJ(eee, aaa, bbb, ccc, ddd, block[11], 15);
+ JJJ(ddd, eee, aaa, bbb, ccc, block[ 4], 5);
+ JJJ(ccc, ddd, eee, aaa, bbb, block[13], 7);
+ JJJ(bbb, ccc, ddd, eee, aaa, block[ 6], 7);
+ JJJ(aaa, bbb, ccc, ddd, eee, block[15], 8);
+ JJJ(eee, aaa, bbb, ccc, ddd, block[ 8], 11);
+ JJJ(ddd, eee, aaa, bbb, ccc, block[ 1], 14);
+ JJJ(ccc, ddd, eee, aaa, bbb, block[10], 14);
+ JJJ(bbb, ccc, ddd, eee, aaa, block[ 3], 12);
+ JJJ(aaa, bbb, ccc, ddd, eee, block[12], 6);
+
+ /* parallel round 2 */
+ III(eee, aaa, bbb, ccc, ddd, block[ 6], 9);
+ III(ddd, eee, aaa, bbb, ccc, block[11], 13);
+ III(ccc, ddd, eee, aaa, bbb, block[ 3], 15);
+ III(bbb, ccc, ddd, eee, aaa, block[ 7], 7);
+ III(aaa, bbb, ccc, ddd, eee, block[ 0], 12);
+ III(eee, aaa, bbb, ccc, ddd, block[13], 8);
+ III(ddd, eee, aaa, bbb, ccc, block[ 5], 9);
+ III(ccc, ddd, eee, aaa, bbb, block[10], 11);
+ III(bbb, ccc, ddd, eee, aaa, block[14], 7);
+ III(aaa, bbb, ccc, ddd, eee, block[15], 7);
+ III(eee, aaa, bbb, ccc, ddd, block[ 8], 12);
+ III(ddd, eee, aaa, bbb, ccc, block[12], 7);
+ III(ccc, ddd, eee, aaa, bbb, block[ 4], 6);
+ III(bbb, ccc, ddd, eee, aaa, block[ 9], 15);
+ III(aaa, bbb, ccc, ddd, eee, block[ 1], 13);
+ III(eee, aaa, bbb, ccc, ddd, block[ 2], 11);
+
+ /* parallel round 3 */
+ HHH(ddd, eee, aaa, bbb, ccc, block[15], 9);
+ HHH(ccc, ddd, eee, aaa, bbb, block[ 5], 7);
+ HHH(bbb, ccc, ddd, eee, aaa, block[ 1], 15);
+ HHH(aaa, bbb, ccc, ddd, eee, block[ 3], 11);
+ HHH(eee, aaa, bbb, ccc, ddd, block[ 7], 8);
+ HHH(ddd, eee, aaa, bbb, ccc, block[14], 6);
+ HHH(ccc, ddd, eee, aaa, bbb, block[ 6], 6);
+ HHH(bbb, ccc, ddd, eee, aaa, block[ 9], 14);
+ HHH(aaa, bbb, ccc, ddd, eee, block[11], 12);
+ HHH(eee, aaa, bbb, ccc, ddd, block[ 8], 13);
+ HHH(ddd, eee, aaa, bbb, ccc, block[12], 5);
+ HHH(ccc, ddd, eee, aaa, bbb, block[ 2], 14);
+ HHH(bbb, ccc, ddd, eee, aaa, block[10], 13);
+ HHH(aaa, bbb, ccc, ddd, eee, block[ 0], 13);
+ HHH(eee, aaa, bbb, ccc, ddd, block[ 4], 7);
+ HHH(ddd, eee, aaa, bbb, ccc, block[13], 5);
+
+ /* parallel round 4 */
+ GGG(ccc, ddd, eee, aaa, bbb, block[ 8], 15);
+ GGG(bbb, ccc, ddd, eee, aaa, block[ 6], 5);
+ GGG(aaa, bbb, ccc, ddd, eee, block[ 4], 8);
+ GGG(eee, aaa, bbb, ccc, ddd, block[ 1], 11);
+ GGG(ddd, eee, aaa, bbb, ccc, block[ 3], 14);
+ GGG(ccc, ddd, eee, aaa, bbb, block[11], 14);
+ GGG(bbb, ccc, ddd, eee, aaa, block[15], 6);
+ GGG(aaa, bbb, ccc, ddd, eee, block[ 0], 14);
+ GGG(eee, aaa, bbb, ccc, ddd, block[ 5], 6);
+ GGG(ddd, eee, aaa, bbb, ccc, block[12], 9);
+ GGG(ccc, ddd, eee, aaa, bbb, block[ 2], 12);
+ GGG(bbb, ccc, ddd, eee, aaa, block[13], 9);
+ GGG(aaa, bbb, ccc, ddd, eee, block[ 9], 12);
+ GGG(eee, aaa, bbb, ccc, ddd, block[ 7], 5);
+ GGG(ddd, eee, aaa, bbb, ccc, block[10], 15);
+ GGG(ccc, ddd, eee, aaa, bbb, block[14], 8);
+
+ /* parallel round 5 */
+ FFF(bbb, ccc, ddd, eee, aaa, block[12] , 8);
+ FFF(aaa, bbb, ccc, ddd, eee, block[15] , 5);
+ FFF(eee, aaa, bbb, ccc, ddd, block[10] , 12);
+ FFF(ddd, eee, aaa, bbb, ccc, block[ 4] , 9);
+ FFF(ccc, ddd, eee, aaa, bbb, block[ 1] , 12);
+ FFF(bbb, ccc, ddd, eee, aaa, block[ 5] , 5);
+ FFF(aaa, bbb, ccc, ddd, eee, block[ 8] , 14);
+ FFF(eee, aaa, bbb, ccc, ddd, block[ 7] , 6);
+ FFF(ddd, eee, aaa, bbb, ccc, block[ 6] , 8);
+ FFF(ccc, ddd, eee, aaa, bbb, block[ 2] , 13);
+ FFF(bbb, ccc, ddd, eee, aaa, block[13] , 6);
+ FFF(aaa, bbb, ccc, ddd, eee, block[14] , 5);
+ FFF(eee, aaa, bbb, ccc, ddd, block[ 0] , 15);
+ FFF(ddd, eee, aaa, bbb, ccc, block[ 3] , 13);
+ FFF(ccc, ddd, eee, aaa, bbb, block[ 9] , 11);
+ FFF(bbb, ccc, ddd, eee, aaa, block[11] , 11);
+
+ /* combine results */
+ ddd += cc + state[1]; /* final result for state[0] */
+ state[1] = state[2] + dd + eee;
+ state[2] = state[3] + ee + aaa;
+ state[3] = state[4] + aa + bbb;
+ state[4] = state[0] + bb + ccc;
+ state[0] = ddd;
+}
+
+/********************************************************************/
+
+void
+RMD160_Update(RMD160_CTX *context, const uint8_t *data, size_t nbytes)
+{
+ uint32_t X[16];
+ uint32_t ofs = 0;
+ uint32_t i;
+#ifdef WORDS_BIGENDIAN
+ uint32_t j;
+#endif
+
+ _DIAGASSERT(context != NULL);
+ _DIAGASSERT(data != NULL);
+
+ /* update length[] */
+#if SIZEOF_SIZE_T * CHAR_BIT > 32
+ context->length[1] += (uint32_t)((context->length[0] + nbytes) >> 32);
+#else
+ if (context->length[0] + nbytes < context->length[0])
+ context->length[1]++; /* overflow to msb of length */
+#endif
+ context->length[0] += (uint32_t)nbytes;
+
+ (void)memset(X, 0, sizeof(X));
+
+ if ( context->buflen + nbytes < 64 )
+ {
+ (void)memcpy(context->bbuffer + context->buflen, data, nbytes);
+ context->buflen += (uint32_t)nbytes;
+ }
+ else
+ {
+ /* process first block */
+ ofs = 64 - context->buflen;
+ (void)memcpy(context->bbuffer + context->buflen, data, ofs);
+#ifndef WORDS_BIGENDIAN
+ (void)memcpy(X, context->bbuffer, sizeof(X));
+#else
+ for (j=0; j < 16; j++)
+ X[j] = BYTES_TO_DWORD(context->bbuffer + (4 * j));
+#endif
+ RMD160_Transform(context->state, X);
+ nbytes -= ofs;
+
+ /* process remaining complete blocks */
+ for (i = 0; i < (nbytes >> 6); i++) {
+#ifndef WORDS_BIGENDIAN
+ (void)memcpy(X, data + (64 * i) + ofs, sizeof(X));
+#else
+ for (j=0; j < 16; j++)
+ X[j] = BYTES_TO_DWORD(data + (64 * i) + (4 * j) + ofs);
+#endif
+ RMD160_Transform(context->state, X);
+ }
+
+ /*
+ * Put last bytes from data into context's buffer
+ */
+ context->buflen = (uint32_t)nbytes & 63;
+ memcpy(context->bbuffer, data + (64 * i) + ofs, context->buflen);
+ }
+}
+
+/********************************************************************/
+
+int
+RMD160_Finish(RMD160_CTX *context, uint8_t digest[20])
+{
+ uint32_t i;
+ uint32_t X[16];
+#ifdef WORDS_BIGENDIAN
+ uint32_t j;
+#endif
+
+ _DIAGASSERT(digest != NULL);
+ _DIAGASSERT(context != NULL);
+
+ /* append the bit m_n == 1 */
+ context->bbuffer[context->buflen] = (uint8_t)'\200';
+
+ (void)memset(context->bbuffer + context->buflen + 1, 0,
+ 63 - context->buflen);
+#ifndef WORDS_BIGENDIAN
+ (void)memcpy(X, context->bbuffer, sizeof(X));
+#else
+ for (j=0; j < 16; j++)
+ X[j] = BYTES_TO_DWORD(context->bbuffer + (4 * j));
+#endif
+ if ((context->buflen) > 55) {
+ /* length goes to next block */
+ RMD160_Transform(context->state, X);
+ (void)memset(X, 0, sizeof(X));
+ }
+
+ /* append length in bits */
+ X[14] = context->length[0] << 3;
+ X[15] = (context->length[0] >> 29) |
+ (context->length[1] << 3);
+ RMD160_Transform(context->state, X);
+
+ if (digest != NULL) {
+ for (i = 0; i < 20; i += 4) {
+ /* extracts the 8 least significant bits. */
+ digest[i] = context->state[i>>2];
+ digest[i + 1] = (context->state[i>>2] >> 8);
+ digest[i + 2] = (context->state[i>>2] >> 16);
+ digest[i + 3] = (context->state[i>>2] >> 24);
+ }
+ }
+ return 1;
+}
+
+/************************ end of file rmd160.c **********************/
diff --git a/jni/ruby/ext/digest/rmd160/rmd160.h b/jni/ruby/ext/digest/rmd160/rmd160.h
new file mode 100644
index 0000000..9a2135f
--- /dev/null
+++ b/jni/ruby/ext/digest/rmd160/rmd160.h
@@ -0,0 +1,56 @@
+/* $NetBSD: rmd160.h,v 1.2 2000/07/07 10:47:06 ad Exp $ */
+/* $RoughId: rmd160.h,v 1.3 2002/02/24 08:14:31 knu Exp $ */
+/* $Id: rmd160.h 46827 2014-07-15 14:59:20Z nobu $ */
+
+/********************************************************************\
+ *
+ * FILE: rmd160.h
+ *
+ * CONTENTS: Header file for a sample C-implementation of the
+ * RIPEMD-160 hash-function.
+ * TARGET: any computer with an ANSI C compiler
+ *
+ * AUTHOR: Antoon Bosselaers, ESAT-COSIC
+ * DATE: 1 March 1996
+ * VERSION: 1.0
+ *
+ * Copyright (c) Katholieke Universiteit Leuven
+ * 1996, All Rights Reserved
+ *
+\********************************************************************/
+
+/*
+ * from OpenBSD: rmd160.h,v 1.4 1999/08/16 09:59:04 millert Exp
+ */
+
+#ifndef _RMD160_H_
+#define _RMD160_H_
+
+#include "defs.h"
+
+typedef struct {
+ uint32_t state[5]; /* state (ABCDE) */
+ uint32_t length[2]; /* number of bits */
+ uint8_t bbuffer[64]; /* overflow buffer */
+ uint32_t buflen; /* number of chars in bbuffer */
+} RMD160_CTX;
+
+#ifdef RUBY
+#define RMD160_Init rb_Digest_RMD160_Init
+#define RMD160_Transform rb_Digest_RMD160_Transform
+#define RMD160_Update rb_Digest_RMD160_Update
+#define RMD160_Finish rb_Digest_RMD160_Finish
+#endif
+
+__BEGIN_DECLS
+int RMD160_Init _((RMD160_CTX *));
+void RMD160_Transform _((uint32_t[5], const uint32_t[16]));
+void RMD160_Update _((RMD160_CTX *, const uint8_t *, size_t));
+int RMD160_Finish _((RMD160_CTX *, uint8_t[20]));
+__END_DECLS
+
+#define RMD160_BLOCK_LENGTH 64
+#define RMD160_DIGEST_LENGTH 20
+#define RMD160_DIGEST_STRING_LENGTH (RMD160_DIGEST_LENGTH * 2 + 1)
+
+#endif /* !_RMD160_H_ */
diff --git a/jni/ruby/ext/digest/rmd160/rmd160init.c b/jni/ruby/ext/digest/rmd160/rmd160init.c
new file mode 100644
index 0000000..05978ec
--- /dev/null
+++ b/jni/ruby/ext/digest/rmd160/rmd160init.c
@@ -0,0 +1,45 @@
+/* $RoughId: rmd160init.c,v 1.3 2001/07/13 20:00:43 knu Exp $ */
+/* $Id: rmd160init.c 47745 2014-09-30 08:29:02Z nobu $ */
+
+#include "digest.h"
+#if defined(HAVE_OPENSSL_RIPEMD_H)
+#include "rmd160ossl.h"
+#else
+#include "rmd160.h"
+#endif
+
+static const rb_digest_metadata_t rmd160 = {
+ RUBY_DIGEST_API_VERSION,
+ RMD160_DIGEST_LENGTH,
+ RMD160_BLOCK_LENGTH,
+ sizeof(RMD160_CTX),
+ (rb_digest_hash_init_func_t)RMD160_Init,
+ (rb_digest_hash_update_func_t)RMD160_Update,
+ (rb_digest_hash_finish_func_t)RMD160_Finish,
+};
+
+/*
+ * A class for calculating message digests using RIPEMD-160
+ * cryptographic hash function, designed by Hans Dobbertin, Antoon
+ * Bosselaers, and Bart Preneel.
+ */
+void
+Init_rmd160(void)
+{
+ VALUE mDigest, cDigest_Base, cDigest_RMD160;
+
+ rb_require("digest");
+
+#if 0
+ mDigest = rb_define_module("Digest"); /* let rdoc know */
+#endif
+ mDigest = rb_path2class("Digest");
+ cDigest_Base = rb_path2class("Digest::Base");
+
+ cDigest_RMD160 = rb_define_class_under(mDigest, "RMD160", cDigest_Base);
+
+#undef RUBY_UNTYPED_DATA_WARNING
+#define RUBY_UNTYPED_DATA_WARNING 0
+ rb_ivar_set(cDigest_RMD160, rb_intern("metadata"),
+ Data_Wrap_Struct(0, 0, 0, (void *)&rmd160));
+}
diff --git a/jni/ruby/ext/digest/rmd160/rmd160ossl.c b/jni/ruby/ext/digest/rmd160/rmd160ossl.c
new file mode 100644
index 0000000..9f97274
--- /dev/null
+++ b/jni/ruby/ext/digest/rmd160/rmd160ossl.c
@@ -0,0 +1,8 @@
+/* $Id: rmd160ossl.c 25189 2009-10-02 12:04:37Z akr $ */
+
+#include "defs.h"
+#include "rmd160ossl.h"
+
+void RMD160_Finish(RMD160_CTX *ctx, char *buf) {
+ RIPEMD160_Final((unsigned char *)buf, ctx);
+}
diff --git a/jni/ruby/ext/digest/rmd160/rmd160ossl.h b/jni/ruby/ext/digest/rmd160/rmd160ossl.h
new file mode 100644
index 0000000..c7b1fd4
--- /dev/null
+++ b/jni/ruby/ext/digest/rmd160/rmd160ossl.h
@@ -0,0 +1,19 @@
+/* $Id: rmd160ossl.h 25189 2009-10-02 12:04:37Z akr $ */
+
+#ifndef RMD160OSSL_H_INCLUDED
+#define RMD160OSSL_H_INCLUDED
+
+#include <stddef.h>
+#include <openssl/ripemd.h>
+
+#define RMD160_CTX RIPEMD160_CTX
+
+#define RMD160_Init RIPEMD160_Init
+#define RMD160_Update RIPEMD160_Update
+
+#define RMD160_BLOCK_LENGTH RIPEMD160_CBLOCK
+#define RMD160_DIGEST_LENGTH RIPEMD160_DIGEST_LENGTH
+
+void RMD160_Finish(RMD160_CTX *ctx, char *buf);
+
+#endif
diff --git a/jni/ruby/ext/digest/sha1/Makefile b/jni/ruby/ext/digest/sha1/Makefile
new file mode 100644
index 0000000..cc81aa2
--- /dev/null
+++ b/jni/ruby/ext/digest/sha1/Makefile
@@ -0,0 +1,297 @@
+
+SHELL = /bin/sh
+
+# V=0 quiet, V=1 verbose. other values don't work.
+V = 0
+Q1 = $(V:1=)
+Q = $(Q1:0=@)
+ECHO1 = $(V:1=@:)
+ECHO = $(ECHO1:0=@echo)
+NULLCMD = :
+
+#### Start of system configuration section. ####
+top_srcdir = $(topdir)/.
+srcdir = $(top_srcdir)/ext/digest/sha1
+topdir = ../../..
+hdrdir = $(top_srcdir)/include
+arch_hdrdir = $(extout)/include/$(arch)
+PATH_SEPARATOR = :
+VPATH = $(srcdir):$(arch_hdrdir)/ruby:$(hdrdir)/ruby
+RUBYLIB =
+RUBYOPT = -
+prefix = $(DESTDIR)/usr/local
+rubysitearchprefix = $(rubylibprefix)/$(sitearch)
+rubyarchprefix = $(rubylibprefix)/$(arch)
+rubylibprefix = $(libdir)/$(RUBY_BASE_NAME)
+exec_prefix = $(prefix)
+vendorarchhdrdir = $(vendorhdrdir)/$(sitearch)
+sitearchhdrdir = $(sitehdrdir)/$(sitearch)
+rubyarchhdrdir = $(rubyhdrdir)/$(arch)
+vendorhdrdir = $(rubyhdrdir)/vendor_ruby
+sitehdrdir = $(rubyhdrdir)/site_ruby
+rubyhdrdir = $(includedir)/$(RUBY_VERSION_NAME)
+vendorarchdir = $(vendorlibdir)/$(sitearch)
+vendorlibdir = $(vendordir)/$(ruby_version)
+vendordir = $(rubylibprefix)/vendor_ruby
+sitearchdir = $(sitelibdir)/$(sitearch)
+sitelibdir = $(sitedir)/$(ruby_version)
+sitedir = $(rubylibprefix)/site_ruby
+rubyarchdir = $(rubylibdir)/$(arch)
+rubylibdir = $(rubylibprefix)/$(ruby_version)
+sitearchincludedir = $(includedir)/$(sitearch)
+archincludedir = $(includedir)/$(arch)
+sitearchlibdir = $(libdir)/$(sitearch)
+archlibdir = $(libdir)/$(arch)
+ridir = $(datarootdir)/$(RI_BASE_NAME)
+mandir = $(datarootdir)/man
+localedir = $(datarootdir)/locale
+libdir = $(exec_prefix)/lib
+psdir = $(docdir)
+pdfdir = $(docdir)
+dvidir = $(docdir)
+htmldir = $(docdir)
+infodir = $(datarootdir)/info
+docdir = $(datarootdir)/doc/$(PACKAGE)
+oldincludedir = $(DESTDIR)/usr/include
+includedir = $(prefix)/include
+localstatedir = $(prefix)/var
+sharedstatedir = $(prefix)/com
+sysconfdir = $(prefix)/etc
+datadir = $(datarootdir)
+datarootdir = $(prefix)/share
+libexecdir = $(exec_prefix)/libexec
+sbindir = $(exec_prefix)/sbin
+bindir = $(exec_prefix)/bin
+archdir = $(rubyarchdir)
+
+
+CC = gcc
+CXX = g++
+LIBRUBY = $(LIBRUBY_SO)
+LIBRUBY_A = lib$(RUBY_SO_NAME)-static.a
+LIBRUBYARG_SHARED = -Wl,-R$(libdir) -L$(libdir) -l$(RUBY_SO_NAME)
+LIBRUBYARG_STATIC = -Wl,-R$(libdir) -L$(libdir) -l$(RUBY_SO_NAME)-static
+empty =
+OUTFLAG = -o $(empty)
+COUTFLAG = -o $(empty)
+
+RUBY_EXTCONF_H = extconf.h
+cflags = $(optflags) $(debugflags) $(warnflags)
+optflags = -O3 -fno-fast-math
+debugflags = -ggdb3
+warnflags = -Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wunused-variable -Wpointer-arith -Wwrite-strings -Wdeclaration-after-statement -Wimplicit-function-declaration -Wdeprecated-declarations -Wno-packed-bitfield-compat
+CCDLFLAGS = -fPIC
+CFLAGS = $(CCDLFLAGS) $(cflags) -fPIC $(ARCH_FLAG)
+INCFLAGS = -I. -I$(arch_hdrdir) -I$(hdrdir) -I$(srcdir) -I$(srcdir)/..
+DEFS =
+CPPFLAGS = -DRUBY_EXTCONF_H=\"$(RUBY_EXTCONF_H)\" $(DEFS) $(cppflags)
+CXXFLAGS = $(CCDLFLAGS) $(cxxflags) $(ARCH_FLAG)
+ldflags = -L. -fstack-protector -rdynamic -Wl,-export-dynamic
+dldflags =
+ARCH_FLAG =
+DLDFLAGS = $(ldflags) $(dldflags) $(ARCH_FLAG)
+LDSHARED = $(CC) -shared
+LDSHAREDXX = $(CXX) -shared
+AR = ar
+EXEEXT =
+
+RUBY_INSTALL_NAME = $(RUBY_BASE_NAME)
+RUBY_SO_NAME = ruby
+RUBYW_INSTALL_NAME =
+RUBY_VERSION_NAME = $(RUBY_BASE_NAME)-$(ruby_version)
+RUBYW_BASE_NAME = rubyw
+RUBY_BASE_NAME = ruby
+
+arch = x86_64-linux
+sitearch = $(arch)
+ruby_version = 2.2.0
+ruby = $(topdir)/miniruby -I'$(topdir)' -I'$(top_srcdir)/lib' -I'$(extout)/$(arch)' -I'$(extout)/common'
+RUBY = $(ruby)
+ruby_headers = $(hdrdir)/ruby.h $(hdrdir)/ruby/ruby.h $(hdrdir)/ruby/defines.h $(hdrdir)/ruby/missing.h $(hdrdir)/ruby/intern.h $(hdrdir)/ruby/st.h $(hdrdir)/ruby/subst.h $(arch_hdrdir)/ruby/config.h $(RUBY_EXTCONF_H)
+
+RM = rm -f
+RM_RF = $(RUBY) -run -e rm -- -rf
+RMDIRS = rmdir --ignore-fail-on-non-empty -p
+MAKEDIRS = /bin/mkdir -p
+INSTALL = /usr/bin/install -c
+INSTALL_PROG = $(INSTALL) -m 0755
+INSTALL_DATA = $(INSTALL) -m 644
+COPY = cp
+TOUCH = exit >
+
+#### End of system configuration section. ####
+
+preload = digest
+
+libpath = . $(topdir)
+LIBPATH = -L. -L$(topdir)
+DEFFILE =
+
+CLEANFILES = mkmf.log
+DISTCLEANFILES =
+DISTCLEANDIRS =
+
+extout = $(topdir)/.ext
+extout_prefix = $(extout)$(target_prefix)/
+target_prefix = /digest
+LOCAL_LIBS =
+LIBS = $(LIBRUBYARG_SHARED) -lcrypto -lssl -lcrypto -lpthread -lgmp -ldl -lcrypt -lm -lc
+ORIG_SRCS = sha1ossl.c sha1init.c sha1.c
+SRCS = $(ORIG_SRCS) sha1init.c sha1ossl.c
+OBJS = sha1init.o sha1ossl.o
+HDRS = $(srcdir)/extconf.h $(srcdir)/sha1.h $(srcdir)/sha1ossl.h
+TARGET = sha1
+TARGET_NAME = sha1
+TARGET_ENTRY = Init_$(TARGET_NAME)
+DLLIB = $(TARGET).so
+EXTSTATIC =
+STATIC_LIB = $(TARGET).a
+
+TIMESTAMP_DIR = $(extout)/.timestamp
+BINDIR = $(extout)/bin
+RUBYCOMMONDIR = $(extout)/common
+RUBYLIBDIR = $(RUBYCOMMONDIR)$(target_prefix)
+RUBYARCHDIR = $(extout)/$(arch)$(target_prefix)
+HDRDIR = $(extout)/include/ruby$(target_prefix)
+ARCHHDRDIR = $(extout)/include/$(arch)/ruby$(target_prefix)
+
+TARGET_SO = $(RUBYARCHDIR)/$(DLLIB)
+CLEANLIBS = $(RUBYARCHDIR)/$(TARGET).so
+CLEANOBJS = *.o *.bak
+
+all: install
+static: all
+.PHONY: all install static install-so install-rb
+.PHONY: clean clean-so clean-static clean-rb
+
+clean-static::
+clean-rb-default::
+clean-rb::
+clean-so::
+clean: clean-so clean-static clean-rb-default clean-rb
+ -$(Q)$(RM) $(CLEANLIBS) $(CLEANOBJS) $(CLEANFILES) .*.time
+
+distclean-rb-default::
+distclean-rb::
+distclean-so::
+distclean-static::
+distclean: clean distclean-so distclean-static distclean-rb-default distclean-rb
+ -$(Q)$(RM) Makefile $(RUBY_EXTCONF_H) conftest.* mkmf.log
+ -$(Q)$(RM) core ruby$(EXEEXT) *~ $(DISTCLEANFILES)
+ -$(Q)$(RMDIRS) $(DISTCLEANDIRS) 2> /dev/null || true
+
+realclean: distclean
+install: install-so install-rb
+
+install-so: $(RUBYARCHDIR)/$(DLLIB)
+clean-so::
+ -$(Q)$(RM) $(RUBYARCHDIR)/$(DLLIB)
+ -$(Q)$(RMDIRS) $(RUBYARCHDIR) 2> /dev/null || true
+clean-static::
+ -$(Q)$(RM) $(STATIC_LIB)
+install-rb: pre-install-rb install-rb-default
+install-rb-default: pre-install-rb-default
+pre-install-rb: Makefile
+pre-install-rb-default: Makefile
+pre-install-rb-default:
+ @$(NULLCMD)
+$(TIMESTAMP_DIR)/.RUBYARCHDIR.-.digest.time:
+ $(Q) $(MAKEDIRS) $(@D) $(RUBYARCHDIR)
+ $(Q) $(TOUCH) $@
+
+site-install: site-install-so site-install-rb
+site-install-so: install-so
+site-install-rb: install-rb
+
+.SUFFIXES: .c .m .cc .mm .cxx .cpp .o .S
+
+.cc.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<
+
+.cc.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -S $<
+
+.mm.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<
+
+.mm.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -S $<
+
+.cxx.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<
+
+.cxx.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -S $<
+
+.cpp.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<
+
+.cpp.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -S $<
+
+.c.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -c $<
+
+.c.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -S $<
+
+.m.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -c $<
+
+.m.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -S $<
+
+$(RUBYARCHDIR)/$(DLLIB): $(OBJS) Makefile $(TIMESTAMP_DIR)/.RUBYARCHDIR.-.digest.time
+ $(ECHO) linking shared-object digest/$(DLLIB)
+ -$(Q)$(RM) $(@)
+ $(Q) $(LDSHARED) -o $@ $(OBJS) $(LIBPATH) $(DLDFLAGS) $(LOCAL_LIBS) $(LIBS)
+
+$(STATIC_LIB): $(OBJS)
+ -$(Q)$(RM) $(@)
+ $(ECHO) linking static-library $(@)
+ $(Q) $(AR) cru $@ $(OBJS)
+ -$(Q)ranlib $(@) 2> /dev/null || true
+
+###
+$(OBJS): $(RUBY_EXTCONF_H)
+
+sha1.o: sha1.c sha1.h $(srcdir)/../defs.h
+
+# AUTOGENERATED DEPENDENCIES START
+sha1init.o: $(RUBY_EXTCONF_H)
+sha1init.o: $(arch_hdrdir)/ruby/config.h
+sha1init.o: $(hdrdir)/ruby/defines.h
+sha1init.o: $(hdrdir)/ruby/intern.h
+sha1init.o: $(hdrdir)/ruby/missing.h
+sha1init.o: $(hdrdir)/ruby/ruby.h
+sha1init.o: $(hdrdir)/ruby/st.h
+sha1init.o: $(hdrdir)/ruby/subst.h
+sha1init.o: $(top_srcdir)/ext/digest/digest.h
+sha1init.o: $(top_srcdir)/include/ruby.h
+sha1init.o: sha1init.c
+sha1init.o: sha1ossl.h
+sha1ossl.o: $(RUBY_EXTCONF_H)
+sha1ossl.o: $(arch_hdrdir)/ruby/config.h
+sha1ossl.o: $(hdrdir)/ruby/defines.h
+sha1ossl.o: $(hdrdir)/ruby/intern.h
+sha1ossl.o: $(hdrdir)/ruby/missing.h
+sha1ossl.o: $(hdrdir)/ruby/ruby.h
+sha1ossl.o: $(hdrdir)/ruby/st.h
+sha1ossl.o: $(hdrdir)/ruby/subst.h
+sha1ossl.o: $(top_srcdir)/ext/digest/defs.h
+sha1ossl.o: $(top_srcdir)/include/ruby.h
+sha1ossl.o: sha1ossl.c
+sha1ossl.o: sha1ossl.h
+# AUTOGENERATED DEPENDENCIES END
diff --git a/jni/ruby/ext/digest/sha1/depend b/jni/ruby/ext/digest/sha1/depend
new file mode 100644
index 0000000..2ce73c4
--- /dev/null
+++ b/jni/ruby/ext/digest/sha1/depend
@@ -0,0 +1,28 @@
+sha1.o: sha1.c sha1.h $(srcdir)/../defs.h
+
+# AUTOGENERATED DEPENDENCIES START
+sha1init.o: $(RUBY_EXTCONF_H)
+sha1init.o: $(arch_hdrdir)/ruby/config.h
+sha1init.o: $(hdrdir)/ruby/defines.h
+sha1init.o: $(hdrdir)/ruby/intern.h
+sha1init.o: $(hdrdir)/ruby/missing.h
+sha1init.o: $(hdrdir)/ruby/ruby.h
+sha1init.o: $(hdrdir)/ruby/st.h
+sha1init.o: $(hdrdir)/ruby/subst.h
+sha1init.o: $(top_srcdir)/ext/digest/digest.h
+sha1init.o: $(top_srcdir)/include/ruby.h
+sha1init.o: sha1init.c
+sha1init.o: sha1ossl.h
+sha1ossl.o: $(RUBY_EXTCONF_H)
+sha1ossl.o: $(arch_hdrdir)/ruby/config.h
+sha1ossl.o: $(hdrdir)/ruby/defines.h
+sha1ossl.o: $(hdrdir)/ruby/intern.h
+sha1ossl.o: $(hdrdir)/ruby/missing.h
+sha1ossl.o: $(hdrdir)/ruby/ruby.h
+sha1ossl.o: $(hdrdir)/ruby/st.h
+sha1ossl.o: $(hdrdir)/ruby/subst.h
+sha1ossl.o: $(top_srcdir)/ext/digest/defs.h
+sha1ossl.o: $(top_srcdir)/include/ruby.h
+sha1ossl.o: sha1ossl.c
+sha1ossl.o: sha1ossl.h
+# AUTOGENERATED DEPENDENCIES END
diff --git a/jni/ruby/ext/digest/sha1/extconf.h b/jni/ruby/ext/digest/sha1/extconf.h
new file mode 100644
index 0000000..808ca65
--- /dev/null
+++ b/jni/ruby/ext/digest/sha1/extconf.h
@@ -0,0 +1,7 @@
+#ifndef EXTCONF_H
+#define EXTCONF_H
+#define HAVE_CONFIG_H 1
+#define HAVE_SHA1_TRANSFORM 1
+#define HAVE_OPENSSL_SHA_H 1
+#define HAVE_SYS_CDEFS_H 1
+#endif
diff --git a/jni/ruby/ext/digest/sha1/extconf.rb b/jni/ruby/ext/digest/sha1/extconf.rb
new file mode 100644
index 0000000..13c448b
--- /dev/null
+++ b/jni/ruby/ext/digest/sha1/extconf.rb
@@ -0,0 +1,27 @@
+# -*- coding: us-ascii -*-
+# $RoughId: extconf.rb,v 1.3 2001/08/14 19:54:51 knu Exp $
+# $Id: extconf.rb 47802 2014-10-05 02:03:55Z nobu $
+
+require "mkmf"
+
+$defs << "-DHAVE_CONFIG_H"
+$INCFLAGS << " -I$(srcdir)/.."
+
+$objs = [ "sha1init.#{$OBJEXT}" ]
+
+if !with_config("bundled-sha1") &&
+ (dir_config("openssl")
+ pkg_config("openssl")
+ require File.expand_path('../../../openssl/deprecation', __FILE__)
+ have_library("crypto")) &&
+ OpenSSL.check_func("SHA1_Transform", "openssl/sha.h")
+ $objs << "sha1ossl.#{$OBJEXT}"
+else
+ $objs << "sha1.#{$OBJEXT}"
+end
+
+have_header("sys/cdefs.h")
+
+$preload = %w[digest]
+
+create_makefile("digest/sha1")
diff --git a/jni/ruby/ext/digest/sha1/sha1.c b/jni/ruby/ext/digest/sha1/sha1.c
new file mode 100644
index 0000000..e9740ed
--- /dev/null
+++ b/jni/ruby/ext/digest/sha1/sha1.c
@@ -0,0 +1,271 @@
+/* $NetBSD: sha1.c,v 1.2 2001/03/22 09:51:48 agc Exp $ */
+/* $OpenBSD: sha1.c,v 1.9 1997/07/23 21:12:32 kstailey Exp $ */
+/* $RoughId: sha1.c,v 1.2 2001/07/13 19:49:10 knu Exp $ */
+/* $Id: sha1.c 46827 2014-07-15 14:59:20Z nobu $ */
+
+/*
+ * SHA-1 in C
+ * By Steve Reid <steve@edmweb.com>
+ * 100% Public Domain
+ *
+ * Test Vectors (from FIPS PUB 180-1)
+ * "abc"
+ * A9993E36 4706816A BA3E2571 7850C26C 9CD0D89D
+ * "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq"
+ * 84983E44 1C3BD26E BAAE4AA1 F95129E5 E54670F1
+ * A million repetitions of "a"
+ * 34AA973C D4C4DAA4 F61EEB2B DBAD2731 6534016F
+ */
+
+#include "sha1.h"
+
+#define SHA1HANDSOFF /* Copies data before messing with it. */
+
+#if defined(_KERNEL) || defined(_STANDALONE)
+#include <sys/param.h>
+#include <sys/systm.h>
+#define _DIAGASSERT(x) (void)0
+#else
+/* #include "namespace.h" */
+#include <assert.h>
+#include <string.h>
+#endif
+
+#ifndef _DIAGASSERT
+#define _DIAGASSERT(cond) assert(cond)
+#endif
+
+/*
+ * XXX Kludge until there is resolution regarding mem*() functions
+ * XXX in the kernel.
+ */
+#if defined(_KERNEL) || defined(_STANDALONE)
+#define memcpy(s, d, l) bcopy((d), (s), (l))
+#endif
+
+#define rol(value, bits) (((value) << (bits)) | ((value) >> (32 - (bits))))
+
+/*
+ * blk0() and blk() perform the initial expand.
+ * I got the idea of expanding during the round function from SSLeay
+ */
+#ifndef WORDS_BIGENDIAN
+# define blk0(i) (block->l[i] = (rol(block->l[i],24)&0xFF00FF00) \
+ |(rol(block->l[i],8)&0x00FF00FF))
+#else
+# define blk0(i) block->l[i]
+#endif
+#define blk(i) (block->l[i&15] = rol(block->l[(i+13)&15]^block->l[(i+8)&15] \
+ ^block->l[(i+2)&15]^block->l[i&15],1))
+
+/*
+ * (R0+R1), R2, R3, R4 are the different operations (rounds) used in SHA1
+ */
+#define R0(v,w,x,y,z,i) z+=((w&(x^y))^y)+blk0(i)+0x5A827999+rol(v,5);w=rol(w,30);
+#define R1(v,w,x,y,z,i) z+=((w&(x^y))^y)+blk(i)+0x5A827999+rol(v,5);w=rol(w,30);
+#define R2(v,w,x,y,z,i) z+=(w^x^y)+blk(i)+0x6ED9EBA1+rol(v,5);w=rol(w,30);
+#define R3(v,w,x,y,z,i) z+=(((w|x)&y)|(w&x))+blk(i)+0x8F1BBCDC+rol(v,5);w=rol(w,30);
+#define R4(v,w,x,y,z,i) z+=(w^x^y)+blk(i)+0xCA62C1D6+rol(v,5);w=rol(w,30);
+
+
+typedef union {
+ uint8_t c[64];
+ uint32_t l[16];
+} CHAR64LONG16;
+
+#ifdef __sparc_v9__
+void do_R01(uint32_t *a, uint32_t *b, uint32_t *c, uint32_t *d, uint32_t *e, CHAR64LONG16 *);
+void do_R2(uint32_t *a, uint32_t *b, uint32_t *c, uint32_t *d, uint32_t *e, CHAR64LONG16 *);
+void do_R3(uint32_t *a, uint32_t *b, uint32_t *c, uint32_t *d, uint32_t *e, CHAR64LONG16 *);
+void do_R4(uint32_t *a, uint32_t *b, uint32_t *c, uint32_t *d, uint32_t *e, CHAR64LONG16 *);
+
+#define nR0(v,w,x,y,z,i) R0(*v,*w,*x,*y,*z,i)
+#define nR1(v,w,x,y,z,i) R1(*v,*w,*x,*y,*z,i)
+#define nR2(v,w,x,y,z,i) R2(*v,*w,*x,*y,*z,i)
+#define nR3(v,w,x,y,z,i) R3(*v,*w,*x,*y,*z,i)
+#define nR4(v,w,x,y,z,i) R4(*v,*w,*x,*y,*z,i)
+
+void
+do_R01(uint32_t *a, uint32_t *b, uint32_t *c, uint32_t *d, uint32_t *e, CHAR64LONG16 *block)
+{
+ nR0(a,b,c,d,e, 0); nR0(e,a,b,c,d, 1); nR0(d,e,a,b,c, 2); nR0(c,d,e,a,b, 3);
+ nR0(b,c,d,e,a, 4); nR0(a,b,c,d,e, 5); nR0(e,a,b,c,d, 6); nR0(d,e,a,b,c, 7);
+ nR0(c,d,e,a,b, 8); nR0(b,c,d,e,a, 9); nR0(a,b,c,d,e,10); nR0(e,a,b,c,d,11);
+ nR0(d,e,a,b,c,12); nR0(c,d,e,a,b,13); nR0(b,c,d,e,a,14); nR0(a,b,c,d,e,15);
+ nR1(e,a,b,c,d,16); nR1(d,e,a,b,c,17); nR1(c,d,e,a,b,18); nR1(b,c,d,e,a,19);
+}
+
+void
+do_R2(uint32_t *a, uint32_t *b, uint32_t *c, uint32_t *d, uint32_t *e, CHAR64LONG16 *block)
+{
+ nR2(a,b,c,d,e,20); nR2(e,a,b,c,d,21); nR2(d,e,a,b,c,22); nR2(c,d,e,a,b,23);
+ nR2(b,c,d,e,a,24); nR2(a,b,c,d,e,25); nR2(e,a,b,c,d,26); nR2(d,e,a,b,c,27);
+ nR2(c,d,e,a,b,28); nR2(b,c,d,e,a,29); nR2(a,b,c,d,e,30); nR2(e,a,b,c,d,31);
+ nR2(d,e,a,b,c,32); nR2(c,d,e,a,b,33); nR2(b,c,d,e,a,34); nR2(a,b,c,d,e,35);
+ nR2(e,a,b,c,d,36); nR2(d,e,a,b,c,37); nR2(c,d,e,a,b,38); nR2(b,c,d,e,a,39);
+}
+
+void
+do_R3(uint32_t *a, uint32_t *b, uint32_t *c, uint32_t *d, uint32_t *e, CHAR64LONG16 *block)
+{
+ nR3(a,b,c,d,e,40); nR3(e,a,b,c,d,41); nR3(d,e,a,b,c,42); nR3(c,d,e,a,b,43);
+ nR3(b,c,d,e,a,44); nR3(a,b,c,d,e,45); nR3(e,a,b,c,d,46); nR3(d,e,a,b,c,47);
+ nR3(c,d,e,a,b,48); nR3(b,c,d,e,a,49); nR3(a,b,c,d,e,50); nR3(e,a,b,c,d,51);
+ nR3(d,e,a,b,c,52); nR3(c,d,e,a,b,53); nR3(b,c,d,e,a,54); nR3(a,b,c,d,e,55);
+ nR3(e,a,b,c,d,56); nR3(d,e,a,b,c,57); nR3(c,d,e,a,b,58); nR3(b,c,d,e,a,59);
+}
+
+void
+do_R4(uint32_t *a, uint32_t *b, uint32_t *c, uint32_t *d, uint32_t *e, CHAR64LONG16 *block)
+{
+ nR4(a,b,c,d,e,60); nR4(e,a,b,c,d,61); nR4(d,e,a,b,c,62); nR4(c,d,e,a,b,63);
+ nR4(b,c,d,e,a,64); nR4(a,b,c,d,e,65); nR4(e,a,b,c,d,66); nR4(d,e,a,b,c,67);
+ nR4(c,d,e,a,b,68); nR4(b,c,d,e,a,69); nR4(a,b,c,d,e,70); nR4(e,a,b,c,d,71);
+ nR4(d,e,a,b,c,72); nR4(c,d,e,a,b,73); nR4(b,c,d,e,a,74); nR4(a,b,c,d,e,75);
+ nR4(e,a,b,c,d,76); nR4(d,e,a,b,c,77); nR4(c,d,e,a,b,78); nR4(b,c,d,e,a,79);
+}
+#endif
+
+/*
+ * Hash a single 512-bit block. This is the core of the algorithm.
+ */
+void SHA1_Transform(uint32_t state[5], const uint8_t buffer[64])
+{
+ uint32_t a, b, c, d, e;
+ CHAR64LONG16 *block;
+
+#ifdef SHA1HANDSOFF
+ CHAR64LONG16 workspace;
+#endif
+
+ _DIAGASSERT(buffer != 0);
+ _DIAGASSERT(state != 0);
+
+#ifdef SHA1HANDSOFF
+ block = &workspace;
+ (void)memcpy(block, buffer, 64);
+#else
+ block = (CHAR64LONG16 *)(void *)buffer;
+#endif
+
+ /* Copy context->state[] to working vars */
+ a = state[0];
+ b = state[1];
+ c = state[2];
+ d = state[3];
+ e = state[4];
+
+#ifdef __sparc_v9__
+ do_R01(&a, &b, &c, &d, &e, block);
+ do_R2(&a, &b, &c, &d, &e, block);
+ do_R3(&a, &b, &c, &d, &e, block);
+ do_R4(&a, &b, &c, &d, &e, block);
+#else
+ /* 4 rounds of 20 operations each. Loop unrolled. */
+ R0(a,b,c,d,e, 0); R0(e,a,b,c,d, 1); R0(d,e,a,b,c, 2); R0(c,d,e,a,b, 3);
+ R0(b,c,d,e,a, 4); R0(a,b,c,d,e, 5); R0(e,a,b,c,d, 6); R0(d,e,a,b,c, 7);
+ R0(c,d,e,a,b, 8); R0(b,c,d,e,a, 9); R0(a,b,c,d,e,10); R0(e,a,b,c,d,11);
+ R0(d,e,a,b,c,12); R0(c,d,e,a,b,13); R0(b,c,d,e,a,14); R0(a,b,c,d,e,15);
+ R1(e,a,b,c,d,16); R1(d,e,a,b,c,17); R1(c,d,e,a,b,18); R1(b,c,d,e,a,19);
+ R2(a,b,c,d,e,20); R2(e,a,b,c,d,21); R2(d,e,a,b,c,22); R2(c,d,e,a,b,23);
+ R2(b,c,d,e,a,24); R2(a,b,c,d,e,25); R2(e,a,b,c,d,26); R2(d,e,a,b,c,27);
+ R2(c,d,e,a,b,28); R2(b,c,d,e,a,29); R2(a,b,c,d,e,30); R2(e,a,b,c,d,31);
+ R2(d,e,a,b,c,32); R2(c,d,e,a,b,33); R2(b,c,d,e,a,34); R2(a,b,c,d,e,35);
+ R2(e,a,b,c,d,36); R2(d,e,a,b,c,37); R2(c,d,e,a,b,38); R2(b,c,d,e,a,39);
+ R3(a,b,c,d,e,40); R3(e,a,b,c,d,41); R3(d,e,a,b,c,42); R3(c,d,e,a,b,43);
+ R3(b,c,d,e,a,44); R3(a,b,c,d,e,45); R3(e,a,b,c,d,46); R3(d,e,a,b,c,47);
+ R3(c,d,e,a,b,48); R3(b,c,d,e,a,49); R3(a,b,c,d,e,50); R3(e,a,b,c,d,51);
+ R3(d,e,a,b,c,52); R3(c,d,e,a,b,53); R3(b,c,d,e,a,54); R3(a,b,c,d,e,55);
+ R3(e,a,b,c,d,56); R3(d,e,a,b,c,57); R3(c,d,e,a,b,58); R3(b,c,d,e,a,59);
+ R4(a,b,c,d,e,60); R4(e,a,b,c,d,61); R4(d,e,a,b,c,62); R4(c,d,e,a,b,63);
+ R4(b,c,d,e,a,64); R4(a,b,c,d,e,65); R4(e,a,b,c,d,66); R4(d,e,a,b,c,67);
+ R4(c,d,e,a,b,68); R4(b,c,d,e,a,69); R4(a,b,c,d,e,70); R4(e,a,b,c,d,71);
+ R4(d,e,a,b,c,72); R4(c,d,e,a,b,73); R4(b,c,d,e,a,74); R4(a,b,c,d,e,75);
+ R4(e,a,b,c,d,76); R4(d,e,a,b,c,77); R4(c,d,e,a,b,78); R4(b,c,d,e,a,79);
+#endif
+
+ /* Add the working vars back into context.state[] */
+ state[0] += a;
+ state[1] += b;
+ state[2] += c;
+ state[3] += d;
+ state[4] += e;
+
+ /* Wipe variables */
+ a = b = c = d = e = 0;
+}
+
+
+/*
+ * SHA1_Init - Initialize new context
+ */
+int SHA1_Init(SHA1_CTX *context)
+{
+
+ _DIAGASSERT(context != 0);
+
+ /* SHA1 initialization constants */
+ context->state[0] = 0x67452301;
+ context->state[1] = 0xEFCDAB89;
+ context->state[2] = 0x98BADCFE;
+ context->state[3] = 0x10325476;
+ context->state[4] = 0xC3D2E1F0;
+ context->count[0] = context->count[1] = 0;
+ return 1;
+}
+
+
+/*
+ * Run your data through this.
+ */
+void SHA1_Update(SHA1_CTX *context, const uint8_t *data, size_t len)
+{
+ uint32_t i, j;
+
+ _DIAGASSERT(context != 0);
+ _DIAGASSERT(data != 0);
+
+ j = context->count[0];
+ if ((context->count[0] += len << 3) < j)
+ context->count[1] += (len>>29)+1;
+ j = (j >> 3) & 63;
+ if ((j + len) > 63) {
+ (void)memcpy(&context->buffer[j], data, (i = 64-j));
+ SHA1_Transform(context->state, context->buffer);
+ for ( ; i + 63 < len; i += 64)
+ SHA1_Transform(context->state, &data[i]);
+ j = 0;
+ } else {
+ i = 0;
+ }
+ (void)memcpy(&context->buffer[j], &data[i], len - i);
+}
+
+
+/*
+ * Add padding and return the message digest.
+ */
+int SHA1_Finish(SHA1_CTX* context, uint8_t digest[20])
+{
+ size_t i;
+ uint8_t finalcount[8];
+
+ _DIAGASSERT(digest != 0);
+ _DIAGASSERT(context != 0);
+
+ for (i = 0; i < 8; i++) {
+ finalcount[i] = (uint8_t)((context->count[(i >= 4 ? 0 : 1)]
+ >> ((3-(i & 3)) * 8) ) & 255); /* Endian independent */
+ }
+ SHA1_Update(context, (const uint8_t *)"\200", 1);
+ while ((context->count[0] & 504) != 448)
+ SHA1_Update(context, (const uint8_t *)"\0", 1);
+ SHA1_Update(context, finalcount, 8); /* Should cause a SHA1_Transform() */
+
+ if (digest) {
+ for (i = 0; i < 20; i++)
+ digest[i] = (uint8_t)
+ ((context->state[i>>2] >> ((3-(i & 3)) * 8) ) & 255);
+ }
+ return 1;
+}
diff --git a/jni/ruby/ext/digest/sha1/sha1.h b/jni/ruby/ext/digest/sha1/sha1.h
new file mode 100644
index 0000000..d175eda
--- /dev/null
+++ b/jni/ruby/ext/digest/sha1/sha1.h
@@ -0,0 +1,39 @@
+/* $NetBSD: sha1.h,v 1.2 1998/05/29 22:55:44 thorpej Exp $ */
+/* $RoughId: sha1.h,v 1.3 2002/02/24 08:14:32 knu Exp $ */
+/* $Id: sha1.h 46827 2014-07-15 14:59:20Z nobu $ */
+
+/*
+ * SHA-1 in C
+ * By Steve Reid <steve@edmweb.com>
+ * 100% Public Domain
+ */
+
+#ifndef _SYS_SHA1_H_
+#define _SYS_SHA1_H_
+
+#include "defs.h"
+
+typedef struct {
+ uint32_t state[5];
+ uint32_t count[2];
+ uint8_t buffer[64];
+} SHA1_CTX;
+
+#ifdef RUBY
+/* avoid name clash */
+#define SHA1_Transform rb_Digest_SHA1_Transform
+#define SHA1_Init rb_Digest_SHA1_Init
+#define SHA1_Update rb_Digest_SHA1_Update
+#define SHA1_Finish rb_Digest_SHA1_Finish
+#endif
+
+void SHA1_Transform _((uint32_t state[5], const uint8_t buffer[64]));
+int SHA1_Init _((SHA1_CTX *context));
+void SHA1_Update _((SHA1_CTX *context, const uint8_t *data, size_t len));
+int SHA1_Finish _((SHA1_CTX *context, uint8_t digest[20]));
+
+#define SHA1_BLOCK_LENGTH 64
+#define SHA1_DIGEST_LENGTH 20
+#define SHA1_DIGEST_STRING_LENGTH (SHA1_DIGEST_LENGTH * 2 + 1)
+
+#endif /* _SYS_SHA1_H_ */
diff --git a/jni/ruby/ext/digest/sha1/sha1init.c b/jni/ruby/ext/digest/sha1/sha1init.c
new file mode 100644
index 0000000..f3769ce
--- /dev/null
+++ b/jni/ruby/ext/digest/sha1/sha1init.c
@@ -0,0 +1,45 @@
+/* $RoughId: sha1init.c,v 1.2 2001/07/13 19:49:10 knu Exp $ */
+/* $Id: sha1init.c 47745 2014-09-30 08:29:02Z nobu $ */
+
+#include "digest.h"
+#if defined(HAVE_OPENSSL_SHA_H)
+#include "sha1ossl.h"
+#else
+#include "sha1.h"
+#endif
+
+static const rb_digest_metadata_t sha1 = {
+ RUBY_DIGEST_API_VERSION,
+ SHA1_DIGEST_LENGTH,
+ SHA1_BLOCK_LENGTH,
+ sizeof(SHA1_CTX),
+ (rb_digest_hash_init_func_t)SHA1_Init,
+ (rb_digest_hash_update_func_t)SHA1_Update,
+ (rb_digest_hash_finish_func_t)SHA1_Finish,
+};
+
+/*
+ * A class for calculating message digests using the SHA-1 Secure Hash
+ * Algorithm by NIST (the US' National Institute of Standards and
+ * Technology), described in FIPS PUB 180-1.
+ */
+void
+Init_sha1(void)
+{
+ VALUE mDigest, cDigest_Base, cDigest_SHA1;
+
+ rb_require("digest");
+
+#if 0
+ mDigest = rb_define_module("Digest"); /* let rdoc know */
+#endif
+ mDigest = rb_path2class("Digest");
+ cDigest_Base = rb_path2class("Digest::Base");
+
+ cDigest_SHA1 = rb_define_class_under(mDigest, "SHA1", cDigest_Base);
+
+#undef RUBY_UNTYPED_DATA_WARNING
+#define RUBY_UNTYPED_DATA_WARNING 0
+ rb_ivar_set(cDigest_SHA1, rb_intern("metadata"),
+ Data_Wrap_Struct(0, 0, 0, (void *)&sha1));
+}
diff --git a/jni/ruby/ext/digest/sha1/sha1ossl.c b/jni/ruby/ext/digest/sha1/sha1ossl.c
new file mode 100644
index 0000000..70391bb
--- /dev/null
+++ b/jni/ruby/ext/digest/sha1/sha1ossl.c
@@ -0,0 +1,10 @@
+/* $Id: sha1ossl.c 25189 2009-10-02 12:04:37Z akr $ */
+
+#include "defs.h"
+#include "sha1ossl.h"
+
+void
+SHA1_Finish(SHA1_CTX *ctx, char *buf)
+{
+ SHA1_Final((unsigned char *)buf, ctx);
+}
diff --git a/jni/ruby/ext/digest/sha1/sha1ossl.h b/jni/ruby/ext/digest/sha1/sha1ossl.h
new file mode 100644
index 0000000..5cd1660
--- /dev/null
+++ b/jni/ruby/ext/digest/sha1/sha1ossl.h
@@ -0,0 +1,20 @@
+/* $Id: sha1ossl.h 25189 2009-10-02 12:04:37Z akr $ */
+
+#ifndef SHA1OSSL_H_INCLUDED
+#define SHA1OSSL_H_INCLUDED
+
+#include <stddef.h>
+#include <openssl/sha.h>
+
+#define SHA1_CTX SHA_CTX
+
+#ifdef SHA_BLOCK_LENGTH
+#define SHA1_BLOCK_LENGTH SHA_BLOCK_LENGTH
+#else
+#define SHA1_BLOCK_LENGTH SHA_CBLOCK
+#endif
+#define SHA1_DIGEST_LENGTH SHA_DIGEST_LENGTH
+
+void SHA1_Finish(SHA1_CTX *ctx, char *buf);
+
+#endif
diff --git a/jni/ruby/ext/digest/sha2/Makefile b/jni/ruby/ext/digest/sha2/Makefile
new file mode 100644
index 0000000..0a9fb9f
--- /dev/null
+++ b/jni/ruby/ext/digest/sha2/Makefile
@@ -0,0 +1,308 @@
+
+SHELL = /bin/sh
+
+# V=0 quiet, V=1 verbose. other values don't work.
+V = 0
+Q1 = $(V:1=)
+Q = $(Q1:0=@)
+ECHO1 = $(V:1=@:)
+ECHO = $(ECHO1:0=@echo)
+NULLCMD = :
+
+#### Start of system configuration section. ####
+top_srcdir = $(topdir)/.
+srcdir = $(top_srcdir)/ext/digest/sha2
+topdir = ../../..
+hdrdir = $(top_srcdir)/include
+arch_hdrdir = $(extout)/include/$(arch)
+PATH_SEPARATOR = :
+VPATH = $(srcdir):$(arch_hdrdir)/ruby:$(hdrdir)/ruby
+RUBYLIB =
+RUBYOPT = -
+prefix = $(DESTDIR)/usr/local
+rubysitearchprefix = $(rubylibprefix)/$(sitearch)
+rubyarchprefix = $(rubylibprefix)/$(arch)
+rubylibprefix = $(libdir)/$(RUBY_BASE_NAME)
+exec_prefix = $(prefix)
+vendorarchhdrdir = $(vendorhdrdir)/$(sitearch)
+sitearchhdrdir = $(sitehdrdir)/$(sitearch)
+rubyarchhdrdir = $(rubyhdrdir)/$(arch)
+vendorhdrdir = $(rubyhdrdir)/vendor_ruby
+sitehdrdir = $(rubyhdrdir)/site_ruby
+rubyhdrdir = $(includedir)/$(RUBY_VERSION_NAME)
+vendorarchdir = $(vendorlibdir)/$(sitearch)
+vendorlibdir = $(vendordir)/$(ruby_version)
+vendordir = $(rubylibprefix)/vendor_ruby
+sitearchdir = $(sitelibdir)/$(sitearch)
+sitelibdir = $(sitedir)/$(ruby_version)
+sitedir = $(rubylibprefix)/site_ruby
+rubyarchdir = $(rubylibdir)/$(arch)
+rubylibdir = $(rubylibprefix)/$(ruby_version)
+sitearchincludedir = $(includedir)/$(sitearch)
+archincludedir = $(includedir)/$(arch)
+sitearchlibdir = $(libdir)/$(sitearch)
+archlibdir = $(libdir)/$(arch)
+ridir = $(datarootdir)/$(RI_BASE_NAME)
+mandir = $(datarootdir)/man
+localedir = $(datarootdir)/locale
+libdir = $(exec_prefix)/lib
+psdir = $(docdir)
+pdfdir = $(docdir)
+dvidir = $(docdir)
+htmldir = $(docdir)
+infodir = $(datarootdir)/info
+docdir = $(datarootdir)/doc/$(PACKAGE)
+oldincludedir = $(DESTDIR)/usr/include
+includedir = $(prefix)/include
+localstatedir = $(prefix)/var
+sharedstatedir = $(prefix)/com
+sysconfdir = $(prefix)/etc
+datadir = $(datarootdir)
+datarootdir = $(prefix)/share
+libexecdir = $(exec_prefix)/libexec
+sbindir = $(exec_prefix)/sbin
+bindir = $(exec_prefix)/bin
+archdir = $(rubyarchdir)
+
+
+CC = gcc
+CXX = g++
+LIBRUBY = $(LIBRUBY_SO)
+LIBRUBY_A = lib$(RUBY_SO_NAME)-static.a
+LIBRUBYARG_SHARED = -Wl,-R$(libdir) -L$(libdir) -l$(RUBY_SO_NAME)
+LIBRUBYARG_STATIC = -Wl,-R$(libdir) -L$(libdir) -l$(RUBY_SO_NAME)-static
+empty =
+OUTFLAG = -o $(empty)
+COUTFLAG = -o $(empty)
+
+RUBY_EXTCONF_H = extconf.h
+cflags = $(optflags) $(debugflags) $(warnflags)
+optflags = -O3 -fno-fast-math
+debugflags = -ggdb3
+warnflags = -Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wunused-variable -Wpointer-arith -Wwrite-strings -Wdeclaration-after-statement -Wimplicit-function-declaration -Wdeprecated-declarations -Wno-packed-bitfield-compat
+CCDLFLAGS = -fPIC
+CFLAGS = $(CCDLFLAGS) $(cflags) -fPIC $(ARCH_FLAG)
+INCFLAGS = -I. -I$(arch_hdrdir) -I$(hdrdir) -I$(srcdir) -I$(srcdir)/..
+DEFS =
+CPPFLAGS = -DRUBY_EXTCONF_H=\"$(RUBY_EXTCONF_H)\" $(DEFS) $(cppflags)
+CXXFLAGS = $(CCDLFLAGS) $(cxxflags) $(ARCH_FLAG)
+ldflags = -L. -fstack-protector -rdynamic -Wl,-export-dynamic
+dldflags =
+ARCH_FLAG =
+DLDFLAGS = $(ldflags) $(dldflags) $(ARCH_FLAG)
+LDSHARED = $(CC) -shared
+LDSHAREDXX = $(CXX) -shared
+AR = ar
+EXEEXT =
+
+RUBY_INSTALL_NAME = $(RUBY_BASE_NAME)
+RUBY_SO_NAME = ruby
+RUBYW_INSTALL_NAME =
+RUBY_VERSION_NAME = $(RUBY_BASE_NAME)-$(ruby_version)
+RUBYW_BASE_NAME = rubyw
+RUBY_BASE_NAME = ruby
+
+arch = x86_64-linux
+sitearch = $(arch)
+ruby_version = 2.2.0
+ruby = $(topdir)/miniruby -I'$(topdir)' -I'$(top_srcdir)/lib' -I'$(extout)/$(arch)' -I'$(extout)/common'
+RUBY = $(ruby)
+ruby_headers = $(hdrdir)/ruby.h $(hdrdir)/ruby/ruby.h $(hdrdir)/ruby/defines.h $(hdrdir)/ruby/missing.h $(hdrdir)/ruby/intern.h $(hdrdir)/ruby/st.h $(hdrdir)/ruby/subst.h $(arch_hdrdir)/ruby/config.h $(RUBY_EXTCONF_H)
+
+RM = rm -f
+RM_RF = $(RUBY) -run -e rm -- -rf
+RMDIRS = rmdir --ignore-fail-on-non-empty -p
+MAKEDIRS = /bin/mkdir -p
+INSTALL = /usr/bin/install -c
+INSTALL_PROG = $(INSTALL) -m 0755
+INSTALL_DATA = $(INSTALL) -m 644
+COPY = cp
+TOUCH = exit >
+
+#### End of system configuration section. ####
+
+preload = digest
+
+libpath = . $(topdir)
+LIBPATH = -L. -L$(topdir)
+DEFFILE =
+
+CLEANFILES = mkmf.log
+DISTCLEANFILES =
+DISTCLEANDIRS =
+
+extout = $(topdir)/.ext
+extout_prefix = $(extout)$(target_prefix)/
+target_prefix = /digest
+LOCAL_LIBS =
+LIBS = $(LIBRUBYARG_SHARED) -lcrypto -lssl -lcrypto -lpthread -lgmp -ldl -lcrypt -lm -lc
+ORIG_SRCS = sha2.c sha2ossl.c sha2init.c
+SRCS = $(ORIG_SRCS) sha2init.c sha2ossl.c
+OBJS = sha2init.o sha2ossl.o
+HDRS = $(srcdir)/sha2ossl.h $(srcdir)/sha2.h $(srcdir)/extconf.h
+TARGET = sha2
+TARGET_NAME = sha2
+TARGET_ENTRY = Init_$(TARGET_NAME)
+DLLIB = $(TARGET).so
+EXTSTATIC =
+STATIC_LIB = $(TARGET).a
+
+TIMESTAMP_DIR = $(extout)/.timestamp
+BINDIR = $(extout)/bin
+RUBYCOMMONDIR = $(extout)/common
+RUBYLIBDIR = $(RUBYCOMMONDIR)$(target_prefix)
+RUBYARCHDIR = $(extout)/$(arch)$(target_prefix)
+HDRDIR = $(extout)/include/ruby$(target_prefix)
+ARCHHDRDIR = $(extout)/include/$(arch)/ruby$(target_prefix)
+
+TARGET_SO = $(RUBYARCHDIR)/$(DLLIB)
+CLEANLIBS = $(RUBYARCHDIR)/$(TARGET).so
+CLEANOBJS = *.o *.bak
+
+all: install
+static: all
+.PHONY: all install static install-so install-rb
+.PHONY: clean clean-so clean-static clean-rb
+
+clean-static::
+clean-rb-default::
+clean-rb::
+clean-so::
+clean: clean-so clean-static clean-rb-default clean-rb
+ -$(Q)$(RM) $(CLEANLIBS) $(CLEANOBJS) $(CLEANFILES) .*.time
+
+distclean-rb-default::
+distclean-rb::
+distclean-so::
+distclean-static::
+distclean: clean distclean-so distclean-static distclean-rb-default distclean-rb
+ -$(Q)$(RM) Makefile $(RUBY_EXTCONF_H) conftest.* mkmf.log
+ -$(Q)$(RM) core ruby$(EXEEXT) *~ $(DISTCLEANFILES)
+ -$(Q)$(RMDIRS) $(DISTCLEANDIRS) 2> /dev/null || true
+
+realclean: distclean
+install: install-so install-rb
+
+install-so: $(RUBYARCHDIR)/$(DLLIB)
+clean-so::
+ -$(Q)$(RM) $(RUBYARCHDIR)/$(DLLIB)
+ -$(Q)$(RMDIRS) $(RUBYARCHDIR) 2> /dev/null || true
+clean-static::
+ -$(Q)$(RM) $(STATIC_LIB)
+install-rb: pre-install-rb install-rb-default
+install-rb-default: pre-install-rb-default
+pre-install-rb: Makefile
+pre-install-rb-default: Makefile
+pre-install-rb-default: $(TIMESTAMP_DIR)/.RUBYLIBDIR.-.digest.time
+install-rb-default: $(RUBYLIBDIR)/sha2.rb
+$(RUBYLIBDIR)/sha2.rb: $(srcdir)/lib/sha2.rb $(TIMESTAMP_DIR)/.RUBYLIBDIR.-.digest.time
+ $(Q) $(COPY) $(srcdir)/lib/sha2.rb $(@D)
+clean-rb-default::
+ -$(Q)$(RM) $(RUBYLIBDIR)/sha2.rb
+pre-install-rb-default:
+ $(ECHO) installing default sha2 libraries
+clean-rb-default::
+ -$(Q)$(RMDIRS) $(RUBYLIBDIR) 2> /dev/null || true
+$(TIMESTAMP_DIR)/.RUBYARCHDIR.-.digest.time:
+ $(Q) $(MAKEDIRS) $(@D) $(RUBYARCHDIR)
+ $(Q) $(TOUCH) $@
+$(TIMESTAMP_DIR)/.RUBYLIBDIR.-.digest.time:
+ $(Q) $(MAKEDIRS) $(@D) $(RUBYLIBDIR)
+ $(Q) $(TOUCH) $@
+
+site-install: site-install-so site-install-rb
+site-install-so: install-so
+site-install-rb: install-rb
+
+.SUFFIXES: .c .m .cc .mm .cxx .cpp .o .S
+
+.cc.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<
+
+.cc.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -S $<
+
+.mm.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<
+
+.mm.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -S $<
+
+.cxx.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<
+
+.cxx.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -S $<
+
+.cpp.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<
+
+.cpp.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -S $<
+
+.c.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -c $<
+
+.c.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -S $<
+
+.m.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -c $<
+
+.m.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -S $<
+
+$(RUBYARCHDIR)/$(DLLIB): $(OBJS) Makefile $(TIMESTAMP_DIR)/.RUBYARCHDIR.-.digest.time
+ $(ECHO) linking shared-object digest/$(DLLIB)
+ -$(Q)$(RM) $(@)
+ $(Q) $(LDSHARED) -o $@ $(OBJS) $(LIBPATH) $(DLDFLAGS) $(LOCAL_LIBS) $(LIBS)
+
+$(STATIC_LIB): $(OBJS)
+ -$(Q)$(RM) $(@)
+ $(ECHO) linking static-library $(@)
+ $(Q) $(AR) cru $@ $(OBJS)
+ -$(Q)ranlib $(@) 2> /dev/null || true
+
+###
+$(OBJS): $(RUBY_EXTCONF_H)
+
+sha2.o: sha2.c sha2.h $(srcdir)/../defs.h $(HDRS) $(ruby_headers)
+
+# AUTOGENERATED DEPENDENCIES START
+sha2init.o: $(RUBY_EXTCONF_H)
+sha2init.o: $(arch_hdrdir)/ruby/config.h
+sha2init.o: $(hdrdir)/ruby/defines.h
+sha2init.o: $(hdrdir)/ruby/intern.h
+sha2init.o: $(hdrdir)/ruby/missing.h
+sha2init.o: $(hdrdir)/ruby/ruby.h
+sha2init.o: $(hdrdir)/ruby/st.h
+sha2init.o: $(hdrdir)/ruby/subst.h
+sha2init.o: $(top_srcdir)/ext/digest/digest.h
+sha2init.o: $(top_srcdir)/include/ruby.h
+sha2init.o: sha2init.c
+sha2init.o: sha2ossl.h
+sha2ossl.o: $(RUBY_EXTCONF_H)
+sha2ossl.o: $(arch_hdrdir)/ruby/config.h
+sha2ossl.o: $(hdrdir)/ruby/defines.h
+sha2ossl.o: $(hdrdir)/ruby/intern.h
+sha2ossl.o: $(hdrdir)/ruby/missing.h
+sha2ossl.o: $(hdrdir)/ruby/ruby.h
+sha2ossl.o: $(hdrdir)/ruby/st.h
+sha2ossl.o: $(hdrdir)/ruby/subst.h
+sha2ossl.o: $(top_srcdir)/ext/digest/defs.h
+sha2ossl.o: $(top_srcdir)/include/ruby.h
+sha2ossl.o: sha2ossl.c
+sha2ossl.o: sha2ossl.h
+# AUTOGENERATED DEPENDENCIES END
diff --git a/jni/ruby/ext/digest/sha2/depend b/jni/ruby/ext/digest/sha2/depend
new file mode 100644
index 0000000..3a47a76
--- /dev/null
+++ b/jni/ruby/ext/digest/sha2/depend
@@ -0,0 +1,28 @@
+sha2.o: sha2.c sha2.h $(srcdir)/../defs.h $(HDRS) $(ruby_headers)
+
+# AUTOGENERATED DEPENDENCIES START
+sha2init.o: $(RUBY_EXTCONF_H)
+sha2init.o: $(arch_hdrdir)/ruby/config.h
+sha2init.o: $(hdrdir)/ruby/defines.h
+sha2init.o: $(hdrdir)/ruby/intern.h
+sha2init.o: $(hdrdir)/ruby/missing.h
+sha2init.o: $(hdrdir)/ruby/ruby.h
+sha2init.o: $(hdrdir)/ruby/st.h
+sha2init.o: $(hdrdir)/ruby/subst.h
+sha2init.o: $(top_srcdir)/ext/digest/digest.h
+sha2init.o: $(top_srcdir)/include/ruby.h
+sha2init.o: sha2init.c
+sha2init.o: sha2ossl.h
+sha2ossl.o: $(RUBY_EXTCONF_H)
+sha2ossl.o: $(arch_hdrdir)/ruby/config.h
+sha2ossl.o: $(hdrdir)/ruby/defines.h
+sha2ossl.o: $(hdrdir)/ruby/intern.h
+sha2ossl.o: $(hdrdir)/ruby/missing.h
+sha2ossl.o: $(hdrdir)/ruby/ruby.h
+sha2ossl.o: $(hdrdir)/ruby/st.h
+sha2ossl.o: $(hdrdir)/ruby/subst.h
+sha2ossl.o: $(top_srcdir)/ext/digest/defs.h
+sha2ossl.o: $(top_srcdir)/include/ruby.h
+sha2ossl.o: sha2ossl.c
+sha2ossl.o: sha2ossl.h
+# AUTOGENERATED DEPENDENCIES END
diff --git a/jni/ruby/ext/digest/sha2/extconf.h b/jni/ruby/ext/digest/sha2/extconf.h
new file mode 100644
index 0000000..0891867
--- /dev/null
+++ b/jni/ruby/ext/digest/sha2/extconf.h
@@ -0,0 +1,13 @@
+#ifndef EXTCONF_H
+#define EXTCONF_H
+#define HAVE_CONFIG_H 1
+#define HAVE_SHA256_TRANSFORM 1
+#define HAVE_OPENSSL_SHA_H 1
+#define HAVE_SHA512_TRANSFORM 1
+#define HAVE_OPENSSL_SHA_H 1
+#define HAVE_TYPE_SHA256_CTX 1
+#define HAVE_TYPE_SHA512_CTX 1
+#define SHA2_USE_OPENSSL 1
+#define HAVE_SYS_CDEFS_H 1
+#define HAVE_TYPE_UINT64_T 1
+#endif
diff --git a/jni/ruby/ext/digest/sha2/extconf.rb b/jni/ruby/ext/digest/sha2/extconf.rb
new file mode 100644
index 0000000..64ce4b6
--- /dev/null
+++ b/jni/ruby/ext/digest/sha2/extconf.rb
@@ -0,0 +1,32 @@
+# -*- coding: us-ascii -*-
+# $RoughId: extconf.rb,v 1.4 2001/08/14 19:54:51 knu Exp $
+# $Id: extconf.rb 47802 2014-10-05 02:03:55Z nobu $
+
+require "mkmf"
+
+$defs << "-DHAVE_CONFIG_H"
+$INCFLAGS << " -I$(srcdir)/.."
+
+$objs = [ "sha2init.#{$OBJEXT}" ]
+
+if !with_config("bundled-sha2") &&
+ (dir_config("openssl")
+ pkg_config("openssl")
+ require File.expand_path('../../../openssl/deprecation', __FILE__)
+ have_library("crypto")) &&
+ %w[SHA256 SHA512].all? {|d| OpenSSL.check_func("#{d}_Transform", "openssl/sha.h")} &&
+ %w[SHA256 SHA512].all? {|d| have_type("#{d}_CTX", "openssl/sha.h")}
+ $objs << "sha2ossl.#{$OBJEXT}"
+ $defs << "-DSHA2_USE_OPENSSL"
+else
+ have_type("u_int8_t")
+ $objs << "sha2.#{$OBJEXT}"
+end
+
+have_header("sys/cdefs.h")
+
+$preload = %w[digest]
+
+if have_type("uint64_t", "defs.h", $defs.join(' '))
+ create_makefile("digest/sha2")
+end
diff --git a/jni/ruby/ext/digest/sha2/lib/sha2.rb b/jni/ruby/ext/digest/sha2/lib/sha2.rb
new file mode 100644
index 0000000..fffc1f4
--- /dev/null
+++ b/jni/ruby/ext/digest/sha2/lib/sha2.rb
@@ -0,0 +1,107 @@
+#--
+# sha2.rb - defines Digest::SHA2 class which wraps up the SHA256,
+# SHA384, and SHA512 classes.
+#++
+# Copyright (c) 2006 Akinori MUSHA <knu@iDaemons.org>
+#
+# All rights reserved. You can redistribute and/or modify it under the same
+# terms as Ruby.
+#
+# $Id: sha2.rb 35293 2012-04-10 22:41:04Z drbrain $
+
+require 'digest'
+require 'digest/sha2.so'
+
+module Digest
+ #
+ # A meta digest provider class for SHA256, SHA384 and SHA512.
+ #
+ class SHA2 < Digest::Class
+ # call-seq:
+ # Digest::SHA2.new(bitlen = 256) -> digest_obj
+ #
+ # Creates a new SHA2 hash object with a given bit length.
+ #
+ # Valid bit lengths are 256, 384 and 512.
+ def initialize(bitlen = 256)
+ case bitlen
+ when 256
+ @sha2 = Digest::SHA256.new
+ when 384
+ @sha2 = Digest::SHA384.new
+ when 512
+ @sha2 = Digest::SHA512.new
+ else
+ raise ArgumentError, "unsupported bit length: %s" % bitlen.inspect
+ end
+ @bitlen = bitlen
+ end
+
+ # call-seq:
+ # digest_obj.reset -> digest_obj
+ #
+ # Resets the digest to the initial state and returns self.
+ def reset
+ @sha2.reset
+ self
+ end
+
+ # call-seq:
+ # digest_obj.update(string) -> digest_obj
+ # digest_obj << string -> digest_obj
+ #
+ # Updates the digest using a given _string_ and returns self.
+ def update(str)
+ @sha2.update(str)
+ self
+ end
+ alias << update
+
+ def finish # :nodoc:
+ @sha2.digest!
+ end
+ private :finish
+
+
+ # call-seq:
+ # digest_obj.block_length -> Integer
+ #
+ # Returns the block length of the digest in bytes.
+ #
+ # Digest::SHA256.new.block_length * 8
+ # # => 512
+ # Digest::SHA384.new.block_length * 8
+ # # => 1024
+ # Digest::SHA512.new.block_length * 8
+ # # => 1024
+ def block_length
+ @sha2.block_length
+ end
+
+ # call-seq:
+ # digest_obj.digest_length -> Integer
+ #
+ # Returns the length of the hash value of the digest in bytes.
+ #
+ # Digest::SHA256.new.digest_length * 8
+ # # => 256
+ # Digest::SHA384.new.digest_length * 8
+ # # => 384
+ # Digest::SHA512.new.digest_length * 8
+ # # => 512
+ #
+ # For example, digests produced by Digest::SHA256 will always be 32 bytes
+ # (256 bits) in size.
+ def digest_length
+ @sha2.digest_length
+ end
+
+ def initialize_copy(other) # :nodoc:
+ @sha2 = other.instance_eval { @sha2.clone }
+ end
+
+ def inspect # :nodoc:
+ "#<%s:%d %s>" % [self.class.name, @bitlen, hexdigest]
+ end
+ end
+end
diff --git a/jni/ruby/ext/digest/sha2/sha2.c b/jni/ruby/ext/digest/sha2/sha2.c
new file mode 100644
index 0000000..8673801
--- /dev/null
+++ b/jni/ruby/ext/digest/sha2/sha2.c
@@ -0,0 +1,1081 @@
+/*
+ * FILE: sha2.c
+ * AUTHOR: Aaron D. Gifford - http://www.aarongifford.com/
+ *
+ * Copyright (c) 2000-2001, Aaron D. Gifford
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the copyright holder nor the names of contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTOR(S) ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTOR(S) BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * $OrigId: sha2.c,v 1.1 2001/11/08 00:01:51 adg Exp adg $
+ * $RoughId: sha2.c,v 1.3 2002/02/26 22:03:36 knu Exp $
+ * $Id: sha2.c 46827 2014-07-15 14:59:20Z nobu $
+ */
+
+#include "defs.h"
+#include <string.h> /* memcpy()/memset() or bcopy()/bzero() */
+#include <assert.h> /* assert() */
+#include "sha2.h"
+
+/*
+ * ASSERT NOTE:
+ * Some sanity checking code is included using assert(). On my FreeBSD
+ * system, this additional code can be removed by compiling with NDEBUG
+ * defined. Check your own systems manpage on assert() to see how to
+ * compile WITHOUT the sanity checking code on your system.
+ *
+ * UNROLLED TRANSFORM LOOP NOTE:
+ * You can define SHA2_UNROLL_TRANSFORM to use the unrolled transform
+ * loop version for the hash transform rounds (defined using macros
+ * later in this file). Either define on the command line, for example:
+ *
+ * cc -DSHA2_UNROLL_TRANSFORM -o sha2 sha2.c sha2prog.c
+ *
+ * or define below:
+ *
+ * #define SHA2_UNROLL_TRANSFORM
+ *
+ */
+
+
+/*** SHA-256/384/512 Machine Architecture Definitions *****************/
+/*
+ * BYTE_ORDER NOTE:
+ *
+ * Please make sure that your system defines BYTE_ORDER. If your
+ * architecture is little-endian, make sure it also defines
+ * LITTLE_ENDIAN and that the two (BYTE_ORDER and LITTLE_ENDIAN) are
+ * equivilent.
+ *
+ * If your system does not define the above, then you can do so by
+ * hand like this:
+ *
+ * #define LITTLE_ENDIAN 1234
+ * #define BIG_ENDIAN 4321
+ *
+ * And for little-endian machines, add:
+ *
+ * #define BYTE_ORDER LITTLE_ENDIAN
+ *
+ * Or for big-endian machines:
+ *
+ * #define BYTE_ORDER BIG_ENDIAN
+ *
+ * The FreeBSD machine this was written on defines BYTE_ORDER
+ * appropriately by including <sys/types.h> (which in turn includes
+ * <machine/endian.h> where the appropriate definitions are actually
+ * made).
+ */
+#if !defined(BYTE_ORDER) || (BYTE_ORDER != LITTLE_ENDIAN && BYTE_ORDER != BIG_ENDIAN)
+#error Define BYTE_ORDER to be equal to either LITTLE_ENDIAN or BIG_ENDIAN
+#endif
+
+/*
+ * Define the followingsha2_* types to types of the correct length on
+ * the native archtecture. Most BSD systems and Linux define u_intXX_t
+ * types. Machines with very recent ANSI C headers, can use the
+ * uintXX_t definintions from inttypes.h by defining SHA2_USE_INTTYPES_H
+ * during compile or in the sha.h header file.
+ *
+ * Machines that support neither u_intXX_t nor inttypes.h's uintXX_t
+ * will need to define these three typedefs below (and the appropriate
+ * ones in sha.h too) by hand according to their system architecture.
+ *
+ * Thank you, Jun-ichiro itojun Hagino, for suggesting using u_intXX_t
+ * types and pointing out recent ANSI C support for uintXX_t in inttypes.h.
+ */
+#ifdef SHA2_USE_INTTYPES_H
+
+typedef uint8_t sha2_byte; /* Exactly 1 byte */
+typedef uint32_t sha2_word32; /* Exactly 4 bytes */
+typedef uint64_t sha2_word64; /* Exactly 8 bytes */
+
+#else /* SHA2_USE_INTTYPES_H */
+
+typedef u_int8_t sha2_byte; /* Exactly 1 byte */
+typedef u_int32_t sha2_word32; /* Exactly 4 bytes */
+typedef u_int64_t sha2_word64; /* Exactly 8 bytes */
+
+#endif /* SHA2_USE_INTTYPES_H */
+
+
+/*** SHA-256/384/512 Various Length Definitions ***********************/
+/* NOTE: Most of these are in sha2.h */
+#define SHA256_SHORT_BLOCK_LENGTH (SHA256_BLOCK_LENGTH - 8)
+#define SHA384_SHORT_BLOCK_LENGTH (SHA384_BLOCK_LENGTH - 16)
+#define SHA512_SHORT_BLOCK_LENGTH (SHA512_BLOCK_LENGTH - 16)
+
+
+#if (defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L)) || defined(__GNUC__) || defined(_HPUX_SOURCE) || defined(__IBMC__)
+#define ULL(number) number##ULL
+#else
+#define ULL(number) (uint64_t)(number)
+#endif
+/*** ENDIAN REVERSAL MACROS *******************************************/
+#if BYTE_ORDER == LITTLE_ENDIAN
+#define REVERSE32(w,x) { \
+ sha2_word32 tmp = (w); \
+ tmp = (tmp >> 16) | (tmp << 16); \
+ (x) = ((tmp & (sha2_word32)0xff00ff00UL) >> 8) | ((tmp & (sha2_word32)0x00ff00ffUL) << 8); \
+}
+#define REVERSE64(w,x) { \
+ sha2_word64 tmp = (w); \
+ tmp = (tmp >> 32) | (tmp << 32); \
+ tmp = ((tmp & ULL(0xff00ff00ff00ff00)) >> 8) | \
+ ((tmp & ULL(0x00ff00ff00ff00ff)) << 8); \
+ (x) = ((tmp & ULL(0xffff0000ffff0000)) >> 16) | \
+ ((tmp & ULL(0x0000ffff0000ffff)) << 16); \
+}
+#endif /* BYTE_ORDER == LITTLE_ENDIAN */
+
+/*
+ * Macro for incrementally adding the unsigned 64-bit integer n to the
+ * unsigned 128-bit integer (represented using a two-element array of
+ * 64-bit words):
+ */
+#define ADDINC128(w,n) { \
+ (w)[0] += (sha2_word64)(n); \
+ if ((w)[0] < (n)) { \
+ (w)[1]++; \
+ } \
+}
+
+/*
+ * Macros for copying blocks of memory and for zeroing out ranges
+ * of memory. Using these macros makes it easy to switch from
+ * using memset()/memcpy() and using bzero()/bcopy().
+ *
+ * Please define either SHA2_USE_MEMSET_MEMCPY or define
+ * SHA2_USE_BZERO_BCOPY depending on which function set you
+ * choose to use:
+ */
+#if !defined(SHA2_USE_MEMSET_MEMCPY) && !defined(SHA2_USE_BZERO_BCOPY)
+/* Default to memset()/memcpy() if no option is specified */
+#define SHA2_USE_MEMSET_MEMCPY 1
+#endif
+#if defined(SHA2_USE_MEMSET_MEMCPY) && defined(SHA2_USE_BZERO_BCOPY)
+/* Abort with an error if BOTH options are defined */
+#error Define either SHA2_USE_MEMSET_MEMCPY or SHA2_USE_BZERO_BCOPY, not both!
+#endif
+
+#ifdef SHA2_USE_MEMSET_MEMCPY
+#define MEMSET_BZERO(p,l) memset((p), 0, (l))
+#define MEMCPY_BCOPY(d,s,l) memcpy((d), (s), (l))
+#endif
+#ifdef SHA2_USE_BZERO_BCOPY
+#define MEMSET_BZERO(p,l) bzero((p), (l))
+#define MEMCPY_BCOPY(d,s,l) bcopy((s), (d), (l))
+#endif
+
+
+/*** THE SIX LOGICAL FUNCTIONS ****************************************/
+/*
+ * Bit shifting and rotation (used by the six SHA-XYZ logical functions:
+ *
+ * NOTE: The naming of R and S appears backwards here (R is a SHIFT and
+ * S is a ROTATION) because the SHA-256/384/512 description document
+ * (see http://csrc.nist.gov/cryptval/shs/sha256-384-512.pdf) uses this
+ * same "backwards" definition.
+ */
+/* Shift-right (used in SHA-256, SHA-384, and SHA-512): */
+#define R(b,x) ((x) >> (b))
+/* 32-bit Rotate-right (used in SHA-256): */
+#define S32(b,x) (((x) >> (b)) | ((x) << (32 - (b))))
+/* 64-bit Rotate-right (used in SHA-384 and SHA-512): */
+#define S64(b,x) (((x) >> (b)) | ((x) << (64 - (b))))
+
+/* Two of six logical functions used in SHA-256, SHA-384, and SHA-512: */
+#define Ch(x,y,z) (((x) & (y)) ^ ((~(x)) & (z)))
+#define Maj(x,y,z) (((x) & (y)) ^ ((x) & (z)) ^ ((y) & (z)))
+
+/* Four of six logical functions used in SHA-256: */
+#define Sigma0_256(x) (S32(2, (x)) ^ S32(13, (x)) ^ S32(22, (x)))
+#define Sigma1_256(x) (S32(6, (x)) ^ S32(11, (x)) ^ S32(25, (x)))
+#define sigma0_256(x) (S32(7, (x)) ^ S32(18, (x)) ^ R(3 , (x)))
+#define sigma1_256(x) (S32(17, (x)) ^ S32(19, (x)) ^ R(10, (x)))
+
+/* Four of six logical functions used in SHA-384 and SHA-512: */
+#define Sigma0_512(x) (S64(28, (x)) ^ S64(34, (x)) ^ S64(39, (x)))
+#define Sigma1_512(x) (S64(14, (x)) ^ S64(18, (x)) ^ S64(41, (x)))
+#define sigma0_512(x) (S64( 1, (x)) ^ S64( 8, (x)) ^ R( 7, (x)))
+#define sigma1_512(x) (S64(19, (x)) ^ S64(61, (x)) ^ R( 6, (x)))
+
+/*** INTERNAL FUNCTION PROTOTYPES *************************************/
+/* NOTE: These should not be accessed directly from outside this
+ * library -- they are intended for private internal visibility/use
+ * only.
+ */
+void SHA512_Last(SHA512_CTX*);
+void SHA256_Transform(SHA256_CTX*, const sha2_word32*);
+void SHA512_Transform(SHA512_CTX*, const sha2_word64*);
+
+
+/*** SHA-XYZ INITIAL HASH VALUES AND CONSTANTS ************************/
+/* Hash constant words K for SHA-256: */
+static const sha2_word32 K256[64] = {
+ 0x428a2f98UL, 0x71374491UL, 0xb5c0fbcfUL, 0xe9b5dba5UL,
+ 0x3956c25bUL, 0x59f111f1UL, 0x923f82a4UL, 0xab1c5ed5UL,
+ 0xd807aa98UL, 0x12835b01UL, 0x243185beUL, 0x550c7dc3UL,
+ 0x72be5d74UL, 0x80deb1feUL, 0x9bdc06a7UL, 0xc19bf174UL,
+ 0xe49b69c1UL, 0xefbe4786UL, 0x0fc19dc6UL, 0x240ca1ccUL,
+ 0x2de92c6fUL, 0x4a7484aaUL, 0x5cb0a9dcUL, 0x76f988daUL,
+ 0x983e5152UL, 0xa831c66dUL, 0xb00327c8UL, 0xbf597fc7UL,
+ 0xc6e00bf3UL, 0xd5a79147UL, 0x06ca6351UL, 0x14292967UL,
+ 0x27b70a85UL, 0x2e1b2138UL, 0x4d2c6dfcUL, 0x53380d13UL,
+ 0x650a7354UL, 0x766a0abbUL, 0x81c2c92eUL, 0x92722c85UL,
+ 0xa2bfe8a1UL, 0xa81a664bUL, 0xc24b8b70UL, 0xc76c51a3UL,
+ 0xd192e819UL, 0xd6990624UL, 0xf40e3585UL, 0x106aa070UL,
+ 0x19a4c116UL, 0x1e376c08UL, 0x2748774cUL, 0x34b0bcb5UL,
+ 0x391c0cb3UL, 0x4ed8aa4aUL, 0x5b9cca4fUL, 0x682e6ff3UL,
+ 0x748f82eeUL, 0x78a5636fUL, 0x84c87814UL, 0x8cc70208UL,
+ 0x90befffaUL, 0xa4506cebUL, 0xbef9a3f7UL, 0xc67178f2UL
+};
+
+/* Initial hash value H for SHA-256: */
+static const sha2_word32 sha256_initial_hash_value[8] = {
+ 0x6a09e667UL,
+ 0xbb67ae85UL,
+ 0x3c6ef372UL,
+ 0xa54ff53aUL,
+ 0x510e527fUL,
+ 0x9b05688cUL,
+ 0x1f83d9abUL,
+ 0x5be0cd19UL
+};
+
+/* Hash constant words K for SHA-384 and SHA-512: */
+static const sha2_word64 K512[80] = {
+ ULL(0x428a2f98d728ae22), ULL(0x7137449123ef65cd),
+ ULL(0xb5c0fbcfec4d3b2f), ULL(0xe9b5dba58189dbbc),
+ ULL(0x3956c25bf348b538), ULL(0x59f111f1b605d019),
+ ULL(0x923f82a4af194f9b), ULL(0xab1c5ed5da6d8118),
+ ULL(0xd807aa98a3030242), ULL(0x12835b0145706fbe),
+ ULL(0x243185be4ee4b28c), ULL(0x550c7dc3d5ffb4e2),
+ ULL(0x72be5d74f27b896f), ULL(0x80deb1fe3b1696b1),
+ ULL(0x9bdc06a725c71235), ULL(0xc19bf174cf692694),
+ ULL(0xe49b69c19ef14ad2), ULL(0xefbe4786384f25e3),
+ ULL(0x0fc19dc68b8cd5b5), ULL(0x240ca1cc77ac9c65),
+ ULL(0x2de92c6f592b0275), ULL(0x4a7484aa6ea6e483),
+ ULL(0x5cb0a9dcbd41fbd4), ULL(0x76f988da831153b5),
+ ULL(0x983e5152ee66dfab), ULL(0xa831c66d2db43210),
+ ULL(0xb00327c898fb213f), ULL(0xbf597fc7beef0ee4),
+ ULL(0xc6e00bf33da88fc2), ULL(0xd5a79147930aa725),
+ ULL(0x06ca6351e003826f), ULL(0x142929670a0e6e70),
+ ULL(0x27b70a8546d22ffc), ULL(0x2e1b21385c26c926),
+ ULL(0x4d2c6dfc5ac42aed), ULL(0x53380d139d95b3df),
+ ULL(0x650a73548baf63de), ULL(0x766a0abb3c77b2a8),
+ ULL(0x81c2c92e47edaee6), ULL(0x92722c851482353b),
+ ULL(0xa2bfe8a14cf10364), ULL(0xa81a664bbc423001),
+ ULL(0xc24b8b70d0f89791), ULL(0xc76c51a30654be30),
+ ULL(0xd192e819d6ef5218), ULL(0xd69906245565a910),
+ ULL(0xf40e35855771202a), ULL(0x106aa07032bbd1b8),
+ ULL(0x19a4c116b8d2d0c8), ULL(0x1e376c085141ab53),
+ ULL(0x2748774cdf8eeb99), ULL(0x34b0bcb5e19b48a8),
+ ULL(0x391c0cb3c5c95a63), ULL(0x4ed8aa4ae3418acb),
+ ULL(0x5b9cca4f7763e373), ULL(0x682e6ff3d6b2b8a3),
+ ULL(0x748f82ee5defb2fc), ULL(0x78a5636f43172f60),
+ ULL(0x84c87814a1f0ab72), ULL(0x8cc702081a6439ec),
+ ULL(0x90befffa23631e28), ULL(0xa4506cebde82bde9),
+ ULL(0xbef9a3f7b2c67915), ULL(0xc67178f2e372532b),
+ ULL(0xca273eceea26619c), ULL(0xd186b8c721c0c207),
+ ULL(0xeada7dd6cde0eb1e), ULL(0xf57d4f7fee6ed178),
+ ULL(0x06f067aa72176fba), ULL(0x0a637dc5a2c898a6),
+ ULL(0x113f9804bef90dae), ULL(0x1b710b35131c471b),
+ ULL(0x28db77f523047d84), ULL(0x32caab7b40c72493),
+ ULL(0x3c9ebe0a15c9bebc), ULL(0x431d67c49c100d4c),
+ ULL(0x4cc5d4becb3e42b6), ULL(0x597f299cfc657e2a),
+ ULL(0x5fcb6fab3ad6faec), ULL(0x6c44198c4a475817)
+};
+
+/* Initial hash value H for SHA-384 */
+static const sha2_word64 sha384_initial_hash_value[8] = {
+ ULL(0xcbbb9d5dc1059ed8),
+ ULL(0x629a292a367cd507),
+ ULL(0x9159015a3070dd17),
+ ULL(0x152fecd8f70e5939),
+ ULL(0x67332667ffc00b31),
+ ULL(0x8eb44a8768581511),
+ ULL(0xdb0c2e0d64f98fa7),
+ ULL(0x47b5481dbefa4fa4)
+};
+
+/* Initial hash value H for SHA-512 */
+static const sha2_word64 sha512_initial_hash_value[8] = {
+ ULL(0x6a09e667f3bcc908),
+ ULL(0xbb67ae8584caa73b),
+ ULL(0x3c6ef372fe94f82b),
+ ULL(0xa54ff53a5f1d36f1),
+ ULL(0x510e527fade682d1),
+ ULL(0x9b05688c2b3e6c1f),
+ ULL(0x1f83d9abfb41bd6b),
+ ULL(0x5be0cd19137e2179)
+};
+
+/*
+ * Constant used by SHA256/384/512_End() functions for converting the
+ * digest to a readable hexadecimal character string:
+ */
+static const char *sha2_hex_digits = "0123456789abcdef";
+
+
+/*** SHA-256: *********************************************************/
+int SHA256_Init(SHA256_CTX* context) {
+ if (context == (SHA256_CTX*)0) {
+ return 0;
+ }
+ MEMCPY_BCOPY(context->state, sha256_initial_hash_value, SHA256_DIGEST_LENGTH);
+ MEMSET_BZERO(context->buffer, SHA256_BLOCK_LENGTH);
+ context->bitcount = 0;
+ return 1;
+}
+
+#ifdef SHA2_UNROLL_TRANSFORM
+
+/* Unrolled SHA-256 round macros: */
+
+#if BYTE_ORDER == LITTLE_ENDIAN
+
+#define ROUND256_0_TO_15(a,b,c,d,e,f,g,h) \
+ REVERSE32(*data++, W256[j]); \
+ T1 = (h) + Sigma1_256(e) + Ch((e), (f), (g)) + \
+ K256[j] + W256[j]; \
+ (d) += T1; \
+ (h) = T1 + Sigma0_256(a) + Maj((a), (b), (c)); \
+ j++
+
+
+#else /* BYTE_ORDER == LITTLE_ENDIAN */
+
+#define ROUND256_0_TO_15(a,b,c,d,e,f,g,h) \
+ T1 = (h) + Sigma1_256(e) + Ch((e), (f), (g)) + \
+ K256[j] + (W256[j] = *data++); \
+ (d) += T1; \
+ (h) = T1 + Sigma0_256(a) + Maj((a), (b), (c)); \
+ j++
+
+#endif /* BYTE_ORDER == LITTLE_ENDIAN */
+
+#define ROUND256(a,b,c,d,e,f,g,h) \
+ s0 = W256[(j+1)&0x0f]; \
+ s0 = sigma0_256(s0); \
+ s1 = W256[(j+14)&0x0f]; \
+ s1 = sigma1_256(s1); \
+ T1 = (h) + Sigma1_256(e) + Ch((e), (f), (g)) + K256[j] + \
+ (W256[j&0x0f] += s1 + W256[(j+9)&0x0f] + s0); \
+ (d) += T1; \
+ (h) = T1 + Sigma0_256(a) + Maj((a), (b), (c)); \
+ j++
+
+void SHA256_Transform(SHA256_CTX* context, const sha2_word32* data) {
+ sha2_word32 a, b, c, d, e, f, g, h, s0, s1;
+ sha2_word32 T1, *W256;
+ int j;
+
+ W256 = (sha2_word32*)context->buffer;
+
+ /* Initialize registers with the prev. intermediate value */
+ a = context->state[0];
+ b = context->state[1];
+ c = context->state[2];
+ d = context->state[3];
+ e = context->state[4];
+ f = context->state[5];
+ g = context->state[6];
+ h = context->state[7];
+
+ j = 0;
+ do {
+ /* Rounds 0 to 15 (unrolled): */
+ ROUND256_0_TO_15(a,b,c,d,e,f,g,h);
+ ROUND256_0_TO_15(h,a,b,c,d,e,f,g);
+ ROUND256_0_TO_15(g,h,a,b,c,d,e,f);
+ ROUND256_0_TO_15(f,g,h,a,b,c,d,e);
+ ROUND256_0_TO_15(e,f,g,h,a,b,c,d);
+ ROUND256_0_TO_15(d,e,f,g,h,a,b,c);
+ ROUND256_0_TO_15(c,d,e,f,g,h,a,b);
+ ROUND256_0_TO_15(b,c,d,e,f,g,h,a);
+ } while (j < 16);
+
+ /* Now for the remaining rounds to 64: */
+ do {
+ ROUND256(a,b,c,d,e,f,g,h);
+ ROUND256(h,a,b,c,d,e,f,g);
+ ROUND256(g,h,a,b,c,d,e,f);
+ ROUND256(f,g,h,a,b,c,d,e);
+ ROUND256(e,f,g,h,a,b,c,d);
+ ROUND256(d,e,f,g,h,a,b,c);
+ ROUND256(c,d,e,f,g,h,a,b);
+ ROUND256(b,c,d,e,f,g,h,a);
+ } while (j < 64);
+
+ /* Compute the current intermediate hash value */
+ context->state[0] += a;
+ context->state[1] += b;
+ context->state[2] += c;
+ context->state[3] += d;
+ context->state[4] += e;
+ context->state[5] += f;
+ context->state[6] += g;
+ context->state[7] += h;
+
+ /* Clean up */
+ a = b = c = d = e = f = g = h = T1 = 0;
+}
+
+#else /* SHA2_UNROLL_TRANSFORM */
+
+void SHA256_Transform(SHA256_CTX* context, const sha2_word32* data) {
+ sha2_word32 a, b, c, d, e, f, g, h, s0, s1;
+ sha2_word32 T1, T2, *W256;
+ int j;
+
+ W256 = (sha2_word32*)context->buffer;
+
+ /* Initialize registers with the prev. intermediate value */
+ a = context->state[0];
+ b = context->state[1];
+ c = context->state[2];
+ d = context->state[3];
+ e = context->state[4];
+ f = context->state[5];
+ g = context->state[6];
+ h = context->state[7];
+
+ j = 0;
+ do {
+#if BYTE_ORDER == LITTLE_ENDIAN
+ /* Copy data while converting to host byte order */
+ REVERSE32(*data++,W256[j]);
+ /* Apply the SHA-256 compression function to update a..h */
+ T1 = h + Sigma1_256(e) + Ch(e, f, g) + K256[j] + W256[j];
+#else /* BYTE_ORDER == LITTLE_ENDIAN */
+ /* Apply the SHA-256 compression function to update a..h with copy */
+ T1 = h + Sigma1_256(e) + Ch(e, f, g) + K256[j] + (W256[j] = *data++);
+#endif /* BYTE_ORDER == LITTLE_ENDIAN */
+ T2 = Sigma0_256(a) + Maj(a, b, c);
+ h = g;
+ g = f;
+ f = e;
+ e = d + T1;
+ d = c;
+ c = b;
+ b = a;
+ a = T1 + T2;
+
+ j++;
+ } while (j < 16);
+
+ do {
+ /* Part of the message block expansion: */
+ s0 = W256[(j+1)&0x0f];
+ s0 = sigma0_256(s0);
+ s1 = W256[(j+14)&0x0f];
+ s1 = sigma1_256(s1);
+
+ /* Apply the SHA-256 compression function to update a..h */
+ T1 = h + Sigma1_256(e) + Ch(e, f, g) + K256[j] +
+ (W256[j&0x0f] += s1 + W256[(j+9)&0x0f] + s0);
+ T2 = Sigma0_256(a) + Maj(a, b, c);
+ h = g;
+ g = f;
+ f = e;
+ e = d + T1;
+ d = c;
+ c = b;
+ b = a;
+ a = T1 + T2;
+
+ j++;
+ } while (j < 64);
+
+ /* Compute the current intermediate hash value */
+ context->state[0] += a;
+ context->state[1] += b;
+ context->state[2] += c;
+ context->state[3] += d;
+ context->state[4] += e;
+ context->state[5] += f;
+ context->state[6] += g;
+ context->state[7] += h;
+
+ /* Clean up */
+ a = b = c = d = e = f = g = h = T1 = T2 = 0;
+}
+
+#endif /* SHA2_UNROLL_TRANSFORM */
+
+void SHA256_Update(SHA256_CTX* context, const sha2_byte *data, size_t len) {
+ unsigned int freespace, usedspace;
+
+ if (len == 0) {
+ /* Calling with no data is valid - we do nothing */
+ return;
+ }
+
+ /* Sanity check: */
+ assert(context != (SHA256_CTX*)0 && data != (sha2_byte*)0);
+
+ usedspace = (unsigned int)((context->bitcount >> 3) % SHA256_BLOCK_LENGTH);
+ if (usedspace > 0) {
+ /* Calculate how much free space is available in the buffer */
+ freespace = SHA256_BLOCK_LENGTH - usedspace;
+
+ if (len >= freespace) {
+ /* Fill the buffer completely and process it */
+ MEMCPY_BCOPY(&context->buffer[usedspace], data, freespace);
+ context->bitcount += freespace << 3;
+ len -= freespace;
+ data += freespace;
+ SHA256_Transform(context, (sha2_word32*)context->buffer);
+ } else {
+ /* The buffer is not yet full */
+ MEMCPY_BCOPY(&context->buffer[usedspace], data, len);
+ context->bitcount += len << 3;
+ /* Clean up: */
+ usedspace = freespace = 0;
+ return;
+ }
+ }
+ while (len >= SHA256_BLOCK_LENGTH) {
+ /* Process as many complete blocks as we can */
+ MEMCPY_BCOPY(context->buffer, data, SHA256_BLOCK_LENGTH);
+ SHA256_Transform(context, (sha2_word32*)context->buffer);
+ context->bitcount += SHA256_BLOCK_LENGTH << 3;
+ len -= SHA256_BLOCK_LENGTH;
+ data += SHA256_BLOCK_LENGTH;
+ }
+ if (len > 0) {
+ /* There's left-overs, so save 'em */
+ MEMCPY_BCOPY(context->buffer, data, len);
+ context->bitcount += len << 3;
+ }
+ /* Clean up: */
+ usedspace = freespace = 0;
+}
+
+int SHA256_Final(sha2_byte digest[], SHA256_CTX* context) {
+ sha2_word32 *d = (sha2_word32*)digest;
+ unsigned int usedspace;
+
+ /* Sanity check: */
+ assert(context != (SHA256_CTX*)0);
+
+ /* If no digest buffer is passed, we don't bother doing this: */
+ if (digest != (sha2_byte*)0) {
+ usedspace = (unsigned int)((context->bitcount >> 3) % SHA256_BLOCK_LENGTH);
+#if BYTE_ORDER == LITTLE_ENDIAN
+ /* Convert FROM host byte order */
+ REVERSE64(context->bitcount,context->bitcount);
+#endif
+ if (usedspace > 0) {
+ /* Begin padding with a 1 bit: */
+ context->buffer[usedspace++] = 0x80;
+
+ if (usedspace <= SHA256_SHORT_BLOCK_LENGTH) {
+ /* Set-up for the last transform: */
+ MEMSET_BZERO(&context->buffer[usedspace], SHA256_SHORT_BLOCK_LENGTH - usedspace);
+ } else {
+ if (usedspace < SHA256_BLOCK_LENGTH) {
+ MEMSET_BZERO(&context->buffer[usedspace], SHA256_BLOCK_LENGTH - usedspace);
+ }
+ /* Do second-to-last transform: */
+ SHA256_Transform(context, (sha2_word32*)context->buffer);
+
+ /* And set-up for the last transform: */
+ MEMSET_BZERO(context->buffer, SHA256_SHORT_BLOCK_LENGTH);
+ }
+ } else {
+ /* Set-up for the last transform: */
+ MEMSET_BZERO(context->buffer, SHA256_SHORT_BLOCK_LENGTH);
+
+ /* Begin padding with a 1 bit: */
+ *context->buffer = 0x80;
+ }
+ /* Set the bit count: */
+ MEMCPY_BCOPY(&context->buffer[SHA256_SHORT_BLOCK_LENGTH], &context->bitcount,
+ sizeof(sha2_word64));
+
+ /* Final transform: */
+ SHA256_Transform(context, (sha2_word32*)context->buffer);
+
+#if BYTE_ORDER == LITTLE_ENDIAN
+ {
+ /* Convert TO host byte order */
+ int j;
+ for (j = 0; j < 8; j++) {
+ REVERSE32(context->state[j],context->state[j]);
+ *d++ = context->state[j];
+ }
+ }
+#else
+ MEMCPY_BCOPY(d, context->state, SHA256_DIGEST_LENGTH);
+#endif
+ }
+
+ /* Clean up state data: */
+ MEMSET_BZERO(context, sizeof(*context));
+ usedspace = 0;
+ return 1;
+}
+
+char *SHA256_End(SHA256_CTX* context, char buffer[]) {
+ sha2_byte digest[SHA256_DIGEST_LENGTH], *d = digest;
+ int i;
+
+ /* Sanity check: */
+ assert(context != (SHA256_CTX*)0);
+
+ if (buffer != (char*)0) {
+ SHA256_Final(digest, context);
+ for (i = 0; i < SHA256_DIGEST_LENGTH; i++) {
+ *buffer++ = sha2_hex_digits[(*d & 0xf0) >> 4];
+ *buffer++ = sha2_hex_digits[*d & 0x0f];
+ d++;
+ }
+ *buffer = (char)0;
+ } else {
+ MEMSET_BZERO(context, sizeof(*context));
+ }
+ MEMSET_BZERO(digest, SHA256_DIGEST_LENGTH);
+ return buffer;
+}
+
+char* SHA256_Data(const sha2_byte* data, size_t len, char digest[SHA256_DIGEST_STRING_LENGTH]) {
+ SHA256_CTX context;
+
+ SHA256_Init(&context);
+ SHA256_Update(&context, data, len);
+ return SHA256_End(&context, digest);
+}
+
+
+/*** SHA-512: *********************************************************/
+int SHA512_Init(SHA512_CTX* context) {
+ if (context == (SHA512_CTX*)0) {
+ return 0;
+ }
+ MEMCPY_BCOPY(context->state, sha512_initial_hash_value, SHA512_DIGEST_LENGTH);
+ MEMSET_BZERO(context->buffer, SHA512_BLOCK_LENGTH);
+ context->bitcount[0] = context->bitcount[1] = 0;
+ return 1;
+}
+
+#ifdef SHA2_UNROLL_TRANSFORM
+
+/* Unrolled SHA-512 round macros: */
+#if BYTE_ORDER == LITTLE_ENDIAN
+
+#define ROUND512_0_TO_15(a,b,c,d,e,f,g,h) \
+ REVERSE64(*data++, W512[j]); \
+ T1 = (h) + Sigma1_512(e) + Ch((e), (f), (g)) + \
+ K512[j] + W512[j]; \
+ (d) += T1, \
+ (h) = T1 + Sigma0_512(a) + Maj((a), (b), (c)), \
+ j++
+
+
+#else /* BYTE_ORDER == LITTLE_ENDIAN */
+
+#define ROUND512_0_TO_15(a,b,c,d,e,f,g,h) \
+ T1 = (h) + Sigma1_512(e) + Ch((e), (f), (g)) + \
+ K512[j] + (W512[j] = *data++); \
+ (d) += T1; \
+ (h) = T1 + Sigma0_512(a) + Maj((a), (b), (c)); \
+ j++
+
+#endif /* BYTE_ORDER == LITTLE_ENDIAN */
+
+#define ROUND512(a,b,c,d,e,f,g,h) \
+ s0 = W512[(j+1)&0x0f]; \
+ s0 = sigma0_512(s0); \
+ s1 = W512[(j+14)&0x0f]; \
+ s1 = sigma1_512(s1); \
+ T1 = (h) + Sigma1_512(e) + Ch((e), (f), (g)) + K512[j] + \
+ (W512[j&0x0f] += s1 + W512[(j+9)&0x0f] + s0); \
+ (d) += T1; \
+ (h) = T1 + Sigma0_512(a) + Maj((a), (b), (c)); \
+ j++
+
+void SHA512_Transform(SHA512_CTX* context, const sha2_word64* data) {
+ sha2_word64 a, b, c, d, e, f, g, h, s0, s1;
+ sha2_word64 T1, *W512 = (sha2_word64*)context->buffer;
+ int j;
+
+ /* Initialize registers with the prev. intermediate value */
+ a = context->state[0];
+ b = context->state[1];
+ c = context->state[2];
+ d = context->state[3];
+ e = context->state[4];
+ f = context->state[5];
+ g = context->state[6];
+ h = context->state[7];
+
+ j = 0;
+ do {
+ ROUND512_0_TO_15(a,b,c,d,e,f,g,h);
+ ROUND512_0_TO_15(h,a,b,c,d,e,f,g);
+ ROUND512_0_TO_15(g,h,a,b,c,d,e,f);
+ ROUND512_0_TO_15(f,g,h,a,b,c,d,e);
+ ROUND512_0_TO_15(e,f,g,h,a,b,c,d);
+ ROUND512_0_TO_15(d,e,f,g,h,a,b,c);
+ ROUND512_0_TO_15(c,d,e,f,g,h,a,b);
+ ROUND512_0_TO_15(b,c,d,e,f,g,h,a);
+ } while (j < 16);
+
+ /* Now for the remaining rounds up to 79: */
+ do {
+ ROUND512(a,b,c,d,e,f,g,h);
+ ROUND512(h,a,b,c,d,e,f,g);
+ ROUND512(g,h,a,b,c,d,e,f);
+ ROUND512(f,g,h,a,b,c,d,e);
+ ROUND512(e,f,g,h,a,b,c,d);
+ ROUND512(d,e,f,g,h,a,b,c);
+ ROUND512(c,d,e,f,g,h,a,b);
+ ROUND512(b,c,d,e,f,g,h,a);
+ } while (j < 80);
+
+ /* Compute the current intermediate hash value */
+ context->state[0] += a;
+ context->state[1] += b;
+ context->state[2] += c;
+ context->state[3] += d;
+ context->state[4] += e;
+ context->state[5] += f;
+ context->state[6] += g;
+ context->state[7] += h;
+
+ /* Clean up */
+ a = b = c = d = e = f = g = h = T1 = 0;
+}
+
+#else /* SHA2_UNROLL_TRANSFORM */
+
+void SHA512_Transform(SHA512_CTX* context, const sha2_word64* data) {
+ sha2_word64 a, b, c, d, e, f, g, h, s0, s1;
+ sha2_word64 T1, T2, *W512 = (sha2_word64*)context->buffer;
+ int j;
+
+ /* Initialize registers with the prev. intermediate value */
+ a = context->state[0];
+ b = context->state[1];
+ c = context->state[2];
+ d = context->state[3];
+ e = context->state[4];
+ f = context->state[5];
+ g = context->state[6];
+ h = context->state[7];
+
+ j = 0;
+ do {
+#if BYTE_ORDER == LITTLE_ENDIAN
+ /* Convert TO host byte order */
+ REVERSE64(*data++, W512[j]);
+ /* Apply the SHA-512 compression function to update a..h */
+ T1 = h + Sigma1_512(e) + Ch(e, f, g) + K512[j] + W512[j];
+#else /* BYTE_ORDER == LITTLE_ENDIAN */
+ /* Apply the SHA-512 compression function to update a..h with copy */
+ T1 = h + Sigma1_512(e) + Ch(e, f, g) + K512[j] + (W512[j] = *data++);
+#endif /* BYTE_ORDER == LITTLE_ENDIAN */
+ T2 = Sigma0_512(a) + Maj(a, b, c);
+ h = g;
+ g = f;
+ f = e;
+ e = d + T1;
+ d = c;
+ c = b;
+ b = a;
+ a = T1 + T2;
+
+ j++;
+ } while (j < 16);
+
+ do {
+ /* Part of the message block expansion: */
+ s0 = W512[(j+1)&0x0f];
+ s0 = sigma0_512(s0);
+ s1 = W512[(j+14)&0x0f];
+ s1 = sigma1_512(s1);
+
+ /* Apply the SHA-512 compression function to update a..h */
+ T1 = h + Sigma1_512(e) + Ch(e, f, g) + K512[j] +
+ (W512[j&0x0f] += s1 + W512[(j+9)&0x0f] + s0);
+ T2 = Sigma0_512(a) + Maj(a, b, c);
+ h = g;
+ g = f;
+ f = e;
+ e = d + T1;
+ d = c;
+ c = b;
+ b = a;
+ a = T1 + T2;
+
+ j++;
+ } while (j < 80);
+
+ /* Compute the current intermediate hash value */
+ context->state[0] += a;
+ context->state[1] += b;
+ context->state[2] += c;
+ context->state[3] += d;
+ context->state[4] += e;
+ context->state[5] += f;
+ context->state[6] += g;
+ context->state[7] += h;
+
+ /* Clean up */
+ a = b = c = d = e = f = g = h = T1 = T2 = 0;
+}
+
+#endif /* SHA2_UNROLL_TRANSFORM */
+
+void SHA512_Update(SHA512_CTX* context, const sha2_byte *data, size_t len) {
+ unsigned int freespace, usedspace;
+
+ if (len == 0) {
+ /* Calling with no data is valid - we do nothing */
+ return;
+ }
+
+ /* Sanity check: */
+ assert(context != (SHA512_CTX*)0 && data != (sha2_byte*)0);
+
+ usedspace = (unsigned int)((context->bitcount[0] >> 3) % SHA512_BLOCK_LENGTH);
+ if (usedspace > 0) {
+ /* Calculate how much free space is available in the buffer */
+ freespace = SHA512_BLOCK_LENGTH - usedspace;
+
+ if (len >= freespace) {
+ /* Fill the buffer completely and process it */
+ MEMCPY_BCOPY(&context->buffer[usedspace], data, freespace);
+ ADDINC128(context->bitcount, freespace << 3);
+ len -= freespace;
+ data += freespace;
+ SHA512_Transform(context, (sha2_word64*)context->buffer);
+ } else {
+ /* The buffer is not yet full */
+ MEMCPY_BCOPY(&context->buffer[usedspace], data, len);
+ ADDINC128(context->bitcount, len << 3);
+ /* Clean up: */
+ usedspace = freespace = 0;
+ return;
+ }
+ }
+ while (len >= SHA512_BLOCK_LENGTH) {
+ /* Process as many complete blocks as we can */
+ MEMCPY_BCOPY(context->buffer, data, SHA512_BLOCK_LENGTH);
+ SHA512_Transform(context, (sha2_word64*)context->buffer);
+ ADDINC128(context->bitcount, SHA512_BLOCK_LENGTH << 3);
+ len -= SHA512_BLOCK_LENGTH;
+ data += SHA512_BLOCK_LENGTH;
+ }
+ if (len > 0) {
+ /* There's left-overs, so save 'em */
+ MEMCPY_BCOPY(context->buffer, data, len);
+ ADDINC128(context->bitcount, len << 3);
+ }
+ /* Clean up: */
+ usedspace = freespace = 0;
+}
+
+void SHA512_Last(SHA512_CTX* context) {
+ unsigned int usedspace;
+
+ usedspace = (unsigned int)((context->bitcount[0] >> 3) % SHA512_BLOCK_LENGTH);
+#if BYTE_ORDER == LITTLE_ENDIAN
+ /* Convert FROM host byte order */
+ REVERSE64(context->bitcount[0],context->bitcount[0]);
+ REVERSE64(context->bitcount[1],context->bitcount[1]);
+#endif
+ if (usedspace > 0) {
+ /* Begin padding with a 1 bit: */
+ context->buffer[usedspace++] = 0x80;
+
+ if (usedspace <= SHA512_SHORT_BLOCK_LENGTH) {
+ /* Set-up for the last transform: */
+ MEMSET_BZERO(&context->buffer[usedspace], SHA512_SHORT_BLOCK_LENGTH - usedspace);
+ } else {
+ if (usedspace < SHA512_BLOCK_LENGTH) {
+ MEMSET_BZERO(&context->buffer[usedspace], SHA512_BLOCK_LENGTH - usedspace);
+ }
+ /* Do second-to-last transform: */
+ SHA512_Transform(context, (sha2_word64*)context->buffer);
+
+ /* And set-up for the last transform: */
+ MEMSET_BZERO(context->buffer, SHA512_BLOCK_LENGTH - 2);
+ }
+ } else {
+ /* Prepare for final transform: */
+ MEMSET_BZERO(context->buffer, SHA512_SHORT_BLOCK_LENGTH);
+
+ /* Begin padding with a 1 bit: */
+ *context->buffer = 0x80;
+ }
+ /* Store the length of input data (in bits): */
+ MEMCPY_BCOPY(&context->buffer[SHA512_SHORT_BLOCK_LENGTH], &context->bitcount[1],
+ sizeof(sha2_word64));
+ MEMCPY_BCOPY(&context->buffer[SHA512_SHORT_BLOCK_LENGTH+8], &context->bitcount[0],
+ sizeof(sha2_word64));
+
+ /* Final transform: */
+ SHA512_Transform(context, (sha2_word64*)context->buffer);
+}
+
+int SHA512_Final(sha2_byte digest[], SHA512_CTX* context) {
+ sha2_word64 *d = (sha2_word64*)digest;
+
+ /* Sanity check: */
+ assert(context != (SHA512_CTX*)0);
+
+ /* If no digest buffer is passed, we don't bother doing this: */
+ if (digest != (sha2_byte*)0) {
+ SHA512_Last(context);
+
+ /* Save the hash data for output: */
+#if BYTE_ORDER == LITTLE_ENDIAN
+ {
+ /* Convert TO host byte order */
+ int j;
+ for (j = 0; j < 8; j++) {
+ REVERSE64(context->state[j],context->state[j]);
+ *d++ = context->state[j];
+ }
+ }
+#else
+ MEMCPY_BCOPY(d, context->state, SHA512_DIGEST_LENGTH);
+#endif
+ }
+
+ /* Zero out state data */
+ MEMSET_BZERO(context, sizeof(*context));
+ return 1;
+}
+
+char *SHA512_End(SHA512_CTX* context, char buffer[]) {
+ sha2_byte digest[SHA512_DIGEST_LENGTH], *d = digest;
+ int i;
+
+ /* Sanity check: */
+ assert(context != (SHA512_CTX*)0);
+
+ if (buffer != (char*)0) {
+ SHA512_Final(digest, context);
+ for (i = 0; i < SHA512_DIGEST_LENGTH; i++) {
+ *buffer++ = sha2_hex_digits[(*d & 0xf0) >> 4];
+ *buffer++ = sha2_hex_digits[*d & 0x0f];
+ d++;
+ }
+ *buffer = (char)0;
+ } else {
+ MEMSET_BZERO(context, sizeof(*context));
+ }
+ MEMSET_BZERO(digest, SHA512_DIGEST_LENGTH);
+ return buffer;
+}
+
+char* SHA512_Data(const sha2_byte* data, size_t len, char digest[SHA512_DIGEST_STRING_LENGTH]) {
+ SHA512_CTX context;
+
+ SHA512_Init(&context);
+ SHA512_Update(&context, data, len);
+ return SHA512_End(&context, digest);
+}
+
+
+/*** SHA-384: *********************************************************/
+int SHA384_Init(SHA384_CTX* context) {
+ if (context == (SHA384_CTX*)0) {
+ return 0;
+ }
+ MEMCPY_BCOPY(context->state, sha384_initial_hash_value, SHA512_DIGEST_LENGTH);
+ MEMSET_BZERO(context->buffer, SHA384_BLOCK_LENGTH);
+ context->bitcount[0] = context->bitcount[1] = 0;
+ return 1;
+}
+
+void SHA384_Update(SHA384_CTX* context, const sha2_byte* data, size_t len) {
+ SHA512_Update((SHA512_CTX*)context, data, len);
+}
+
+int SHA384_Final(sha2_byte digest[], SHA384_CTX* context) {
+ sha2_word64 *d = (sha2_word64*)digest;
+
+ /* Sanity check: */
+ assert(context != (SHA384_CTX*)0);
+
+ /* If no digest buffer is passed, we don't bother doing this: */
+ if (digest != (sha2_byte*)0) {
+ SHA512_Last((SHA512_CTX*)context);
+
+ /* Save the hash data for output: */
+#if BYTE_ORDER == LITTLE_ENDIAN
+ {
+ /* Convert TO host byte order */
+ int j;
+ for (j = 0; j < 6; j++) {
+ REVERSE64(context->state[j],context->state[j]);
+ *d++ = context->state[j];
+ }
+ }
+#else
+ MEMCPY_BCOPY(d, context->state, SHA384_DIGEST_LENGTH);
+#endif
+ }
+
+ /* Zero out state data */
+ MEMSET_BZERO(context, sizeof(*context));
+ return 1;
+}
+
+char *SHA384_End(SHA384_CTX* context, char buffer[]) {
+ sha2_byte digest[SHA384_DIGEST_LENGTH], *d = digest;
+ int i;
+
+ /* Sanity check: */
+ assert(context != (SHA384_CTX*)0);
+
+ if (buffer != (char*)0) {
+ SHA384_Final(digest, context);
+ for (i = 0; i < SHA384_DIGEST_LENGTH; i++) {
+ *buffer++ = sha2_hex_digits[(*d & 0xf0) >> 4];
+ *buffer++ = sha2_hex_digits[*d & 0x0f];
+ d++;
+ }
+ *buffer = (char)0;
+ } else {
+ MEMSET_BZERO(context, sizeof(*context));
+ }
+ MEMSET_BZERO(digest, SHA384_DIGEST_LENGTH);
+ return buffer;
+}
+
+char* SHA384_Data(const sha2_byte* data, size_t len, char digest[SHA384_DIGEST_STRING_LENGTH]) {
+ SHA384_CTX context;
+
+ SHA384_Init(&context);
+ SHA384_Update(&context, data, len);
+ return SHA384_End(&context, digest);
+}
+
diff --git a/jni/ruby/ext/digest/sha2/sha2.h b/jni/ruby/ext/digest/sha2/sha2.h
new file mode 100644
index 0000000..8d1734e
--- /dev/null
+++ b/jni/ruby/ext/digest/sha2/sha2.h
@@ -0,0 +1,225 @@
+/*
+ * FILE: sha2.h
+ * AUTHOR: Aaron D. Gifford - http://www.aarongifford.com/
+ *
+ * Copyright (c) 2000-2001, Aaron D. Gifford
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the copyright holder nor the names of contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTOR(S) ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTOR(S) BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * $OrigId: sha2.h,v 1.1 2001/11/08 00:02:01 adg Exp adg $
+ * $RoughId: sha2.h,v 1.3 2002/02/24 08:14:32 knu Exp $
+ * $Id: sha2.h 46827 2014-07-15 14:59:20Z nobu $
+ */
+
+#ifndef __SHA2_H__
+#define __SHA2_H__
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
+/*
+ * Import u_intXX_t size_t type definitions from system headers. You
+ * may need to change this, or define these things yourself in this
+ * file.
+ */
+#include <sys/types.h>
+
+#ifdef RUBY
+# ifdef HAVE_PROTOTYPES
+# undef NOPROTO
+# else
+# define NOPROTO
+# endif /* HAVE_PROTOTYPES */
+# ifndef BYTE_ORDER
+# define LITTLE_ENDIAN 1234
+# define BIG_ENDIAN 4321
+# ifdef WORDS_BIGENDIAN
+# define BYTE_ORDER BIG_ENDIAN
+# else
+# define BYTE_ORDER LITTLE_ENDIAN
+# endif
+# endif /* BYTE_ORDER */
+# define SHA2_USE_INTTYPES_H
+#else /* RUBY */
+#ifdef SHA2_USE_INTTYPES_H
+
+#include <inttypes.h>
+
+#endif /* SHA2_USE_INTTYPES_H */
+#endif /* RUBY */
+
+
+/*** SHA-256/384/512 Various Length Definitions ***********************/
+#define SHA256_BLOCK_LENGTH 64
+#define SHA256_DIGEST_LENGTH 32
+#define SHA256_DIGEST_STRING_LENGTH (SHA256_DIGEST_LENGTH * 2 + 1)
+#define SHA384_BLOCK_LENGTH 128
+#define SHA384_DIGEST_LENGTH 48
+#define SHA384_DIGEST_STRING_LENGTH (SHA384_DIGEST_LENGTH * 2 + 1)
+#define SHA512_BLOCK_LENGTH 128
+#define SHA512_DIGEST_LENGTH 64
+#define SHA512_DIGEST_STRING_LENGTH (SHA512_DIGEST_LENGTH * 2 + 1)
+
+
+/*** SHA-256/384/512 Context Structures *******************************/
+/* NOTE: If your architecture does not define either u_intXX_t types or
+ * uintXX_t (from inttypes.h), you may need to define things by hand
+ * for your system:
+ */
+#ifndef SHA2_USE_INTTYPES_H
+# ifdef HAVE_U_INT8_T
+typedef u_int8_t uint8_t; /* 1-byte (8-bits) */
+typedef u_int32_t uint32_t; /* 4-bytes (32-bits) */
+typedef u_int64_t uint64_t; /* 8-bytes (64-bits) */
+# else
+typedef unsigned char uint8_t; /* 1-byte (8-bits) */
+typedef unsigned int uint32_t; /* 4-bytes (32-bits) */
+typedef unsigned long long uint64_t; /* 8-bytes (64-bits) */
+# endif
+#endif
+
+/*
+ * Most BSD systems already define u_intXX_t types, as does Linux.
+ * Some systems, however, like Compaq's Tru64 Unix instead can use
+ * uintXX_t types defined by very recent ANSI C standards and included
+ * in the file:
+ *
+ * #include <inttypes.h>
+ *
+ * If you choose to use <inttypes.h> then please define:
+ *
+ * #define SHA2_USE_INTTYPES_H
+ *
+ * Or on the command line during compile:
+ *
+ * cc -DSHA2_USE_INTTYPES_H ...
+ */
+typedef struct _SHA256_CTX {
+ uint32_t state[8];
+ uint64_t bitcount;
+ uint8_t buffer[SHA256_BLOCK_LENGTH];
+} SHA256_CTX;
+typedef struct _SHA512_CTX {
+ uint64_t state[8];
+ uint64_t bitcount[2];
+ uint8_t buffer[SHA512_BLOCK_LENGTH];
+} SHA512_CTX;
+
+typedef SHA512_CTX SHA384_CTX;
+
+
+/*** SHA-256/384/512 Function Prototypes ******************************/
+#ifdef RUBY
+#define SHA256_Init rb_Digest_SHA256_Init
+#define SHA256_Update rb_Digest_SHA256_Update
+#define SHA256_Finish rb_Digest_SHA256_Finish
+#define SHA256_Data rb_Digest_SHA256_Data
+#define SHA256_End rb_Digest_SHA256_End
+#define SHA256_Last rb_Digest_SHA256_Last
+#define SHA256_Transform rb_Digest_SHA256_Transform
+#define SHA256_Final(d, c) SHA256_Finish(c, d)
+
+#define SHA384_Init rb_Digest_SHA384_Init
+#define SHA384_Update rb_Digest_SHA384_Update
+#define SHA384_Finish rb_Digest_SHA384_Finish
+#define SHA384_Data rb_Digest_SHA384_Data
+#define SHA384_End rb_Digest_SHA384_End
+#define SHA384_Last rb_Digest_SHA384_Last
+#define SHA384_Transform rb_Digest_SHA384_Transform
+#define SHA384_Final(d, c) SHA384_Finish(c, d)
+
+#define SHA512_Init rb_Digest_SHA512_Init
+#define SHA512_Update rb_Digest_SHA512_Update
+#define SHA512_Finish rb_Digest_SHA512_Finish
+#define SHA512_Data rb_Digest_SHA512_Data
+#define SHA512_End rb_Digest_SHA512_End
+#define SHA512_Last rb_Digest_SHA512_Last
+#define SHA512_Transform rb_Digest_SHA512_Transform
+#define SHA512_Final(d, c) SHA512_Finish(c, d)
+#endif /* RUBY */
+
+#ifndef NOPROTO
+
+int SHA256_Init(SHA256_CTX *);
+void SHA256_Update(SHA256_CTX*, const uint8_t*, size_t);
+int SHA256_Final(uint8_t[SHA256_DIGEST_LENGTH], SHA256_CTX*);
+char* SHA256_End(SHA256_CTX*, char[SHA256_DIGEST_STRING_LENGTH]);
+char* SHA256_Data(const uint8_t*, size_t, char[SHA256_DIGEST_STRING_LENGTH]);
+
+int SHA384_Init(SHA384_CTX*);
+void SHA384_Update(SHA384_CTX*, const uint8_t*, size_t);
+int SHA384_Final(uint8_t[SHA384_DIGEST_LENGTH], SHA384_CTX*);
+char* SHA384_End(SHA384_CTX*, char[SHA384_DIGEST_STRING_LENGTH]);
+char* SHA384_Data(const uint8_t*, size_t, char[SHA384_DIGEST_STRING_LENGTH]);
+
+int SHA512_Init(SHA512_CTX*);
+void SHA512_Update(SHA512_CTX*, const uint8_t*, size_t);
+int SHA512_Final(uint8_t[SHA512_DIGEST_LENGTH], SHA512_CTX*);
+char* SHA512_End(SHA512_CTX*, char[SHA512_DIGEST_STRING_LENGTH]);
+char* SHA512_Data(const uint8_t*, size_t, char[SHA512_DIGEST_STRING_LENGTH]);
+
+#else /* NOPROTO */
+
+int SHA256_Init();
+void SHA256_Update();
+#ifdef RUBY
+int SHA256_Finish();
+#else
+int SHA256_Final();
+#endif /* RUBY */
+char* SHA256_End();
+char* SHA256_Data();
+
+int SHA384_Init();
+void SHA384_Update();
+#ifdef RUBY
+int SHA384_Finish();
+#else
+int SHA384_Final();
+#endif /* RUBY */
+char* SHA384_End();
+char* SHA384_Data();
+
+int SHA512_Init();
+void SHA512_Update();
+#ifdef RUBY
+int SHA512_Finish();
+#else
+int SHA512_Final();
+#endif /* RUBY */
+char* SHA512_End();
+char* SHA512_Data();
+
+#endif /* NOPROTO */
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+#endif /* __SHA2_H__ */
+
diff --git a/jni/ruby/ext/digest/sha2/sha2init.c b/jni/ruby/ext/digest/sha2/sha2init.c
new file mode 100644
index 0000000..a48a967
--- /dev/null
+++ b/jni/ruby/ext/digest/sha2/sha2init.c
@@ -0,0 +1,58 @@
+/* $RoughId: sha2init.c,v 1.3 2001/07/13 20:00:43 knu Exp $ */
+/* $Id: sha2init.c 47745 2014-09-30 08:29:02Z nobu $ */
+
+#include "digest.h"
+#if defined(SHA2_USE_OPENSSL)
+#include "sha2ossl.h"
+#else
+#include "sha2.h"
+#endif
+
+#define FOREACH_BITLEN(func) func(256) func(384) func(512)
+
+#define DEFINE_ALGO_METADATA(bitlen) \
+static const rb_digest_metadata_t sha##bitlen = { \
+ RUBY_DIGEST_API_VERSION, \
+ SHA##bitlen##_DIGEST_LENGTH, \
+ SHA##bitlen##_BLOCK_LENGTH, \
+ sizeof(SHA##bitlen##_CTX), \
+ (rb_digest_hash_init_func_t)SHA##bitlen##_Init, \
+ (rb_digest_hash_update_func_t)SHA##bitlen##_Update, \
+ (rb_digest_hash_finish_func_t)SHA##bitlen##_Finish, \
+};
+
+FOREACH_BITLEN(DEFINE_ALGO_METADATA)
+
+/*
+ * Classes for calculating message digests using the SHA-256/384/512
+ * Secure Hash Algorithm(s) by NIST (the US' National Institute of
+ * Standards and Technology), described in FIPS PUB 180-2.
+ */
+void
+Init_sha2(void)
+{
+ VALUE mDigest, cDigest_Base;
+ ID id_metadata;
+
+#define DECLARE_ALGO_CLASS(bitlen) \
+ VALUE cDigest_SHA##bitlen;
+
+ FOREACH_BITLEN(DECLARE_ALGO_CLASS)
+
+ rb_require("digest");
+
+ id_metadata = rb_intern("metadata");
+
+ mDigest = rb_path2class("Digest");
+ cDigest_Base = rb_path2class("Digest::Base");
+
+#define DEFINE_ALGO_CLASS(bitlen) \
+ cDigest_SHA##bitlen = rb_define_class_under(mDigest, "SHA" #bitlen, cDigest_Base); \
+\
+ rb_ivar_set(cDigest_SHA##bitlen, id_metadata, \
+ Data_Wrap_Struct(0, 0, 0, (void *)&sha##bitlen));
+
+#undef RUBY_UNTYPED_DATA_WARNING
+#define RUBY_UNTYPED_DATA_WARNING 0
+ FOREACH_BITLEN(DEFINE_ALGO_CLASS)
+}
diff --git a/jni/ruby/ext/digest/sha2/sha2ossl.c b/jni/ruby/ext/digest/sha2/sha2ossl.c
new file mode 100644
index 0000000..34353be
--- /dev/null
+++ b/jni/ruby/ext/digest/sha2/sha2ossl.c
@@ -0,0 +1,13 @@
+#include "defs.h"
+#include "sha2ossl.h"
+
+#define SHA_Finish(bit) \
+ void SHA##bit##_Finish(SHA##bit##_CTX *ctx, char *buf) \
+ { SHA##bit##_Final((unsigned char *)buf, ctx);}
+#ifndef __DragonFly__
+#define SHA384_Final SHA512_Final
+#endif
+
+SHA_Finish(256)
+SHA_Finish(384)
+SHA_Finish(512)
diff --git a/jni/ruby/ext/digest/sha2/sha2ossl.h b/jni/ruby/ext/digest/sha2/sha2ossl.h
new file mode 100644
index 0000000..4229d14
--- /dev/null
+++ b/jni/ruby/ext/digest/sha2/sha2ossl.h
@@ -0,0 +1,17 @@
+#ifndef SHA2OSSL_H_INCLUDED
+#define SHA2OSSL_H_INCLUDED
+
+#include <stddef.h>
+#include <openssl/sha.h>
+
+#define SHA256_BLOCK_LENGTH SHA256_CBLOCK
+#define SHA384_BLOCK_LENGTH SHA512_CBLOCK
+#define SHA512_BLOCK_LENGTH SHA512_CBLOCK
+
+typedef SHA512_CTX SHA384_CTX;
+
+void SHA256_Finish(SHA256_CTX *ctx, char *buf);
+void SHA384_Finish(SHA384_CTX *ctx, char *buf);
+void SHA512_Finish(SHA512_CTX *ctx, char *buf);
+
+#endif
diff --git a/jni/ruby/ext/digest/test.sh b/jni/ruby/ext/digest/test.sh
new file mode 100644
index 0000000..03b5078
--- /dev/null
+++ b/jni/ruby/ext/digest/test.sh
@@ -0,0 +1,30 @@
+#!/bin/sh
+#
+# $RoughId: test.sh,v 1.5 2001/07/13 15:38:27 knu Exp $
+# $Id: test.sh 25189 2009-10-02 12:04:37Z akr $
+
+RUBY=${RUBY:=ruby}
+MAKE=${MAKE:=make}
+CFLAGS=${CFLAGS:=-Wall}
+
+${RUBY} extconf.rb --with-cflags="${CFLAGS}"
+${MAKE} clean
+${MAKE}
+
+for algo in md5 rmd160 sha1 sha2; do
+ args=--with-cflags="${CFLAGS}"
+
+ if [ $WITH_BUNDLED_ENGINES ]; then
+ args="$args --with-bundled-$algo"
+ fi
+
+ (cd $algo &&
+ ${RUBY} extconf.rb $args;
+ ${MAKE} clean;
+ ${MAKE})
+ ln -sf ../../$algo/$algo.so lib/digest/
+done
+
+${RUBY} -I. -I./lib ../../test/digest/test_digest.rb
+
+rm lib/digest/*.so
diff --git a/jni/ruby/ext/etc/Makefile b/jni/ruby/ext/etc/Makefile
new file mode 100644
index 0000000..da47e67
--- /dev/null
+++ b/jni/ruby/ext/etc/Makefile
@@ -0,0 +1,278 @@
+
+SHELL = /bin/sh
+
+# V=0 quiet, V=1 verbose. other values don't work.
+V = 0
+Q1 = $(V:1=)
+Q = $(Q1:0=@)
+ECHO1 = $(V:1=@:)
+ECHO = $(ECHO1:0=@echo)
+NULLCMD = :
+
+#### Start of system configuration section. ####
+top_srcdir = $(topdir)/.
+srcdir = $(top_srcdir)/ext/etc
+topdir = ../..
+hdrdir = $(top_srcdir)/include
+arch_hdrdir = $(extout)/include/$(arch)
+PATH_SEPARATOR = :
+VPATH = $(srcdir):$(arch_hdrdir)/ruby:$(hdrdir)/ruby
+RUBYLIB =
+RUBYOPT = -
+prefix = $(DESTDIR)/usr/local
+rubysitearchprefix = $(rubylibprefix)/$(sitearch)
+rubyarchprefix = $(rubylibprefix)/$(arch)
+rubylibprefix = $(libdir)/$(RUBY_BASE_NAME)
+exec_prefix = $(prefix)
+vendorarchhdrdir = $(vendorhdrdir)/$(sitearch)
+sitearchhdrdir = $(sitehdrdir)/$(sitearch)
+rubyarchhdrdir = $(rubyhdrdir)/$(arch)
+vendorhdrdir = $(rubyhdrdir)/vendor_ruby
+sitehdrdir = $(rubyhdrdir)/site_ruby
+rubyhdrdir = $(includedir)/$(RUBY_VERSION_NAME)
+vendorarchdir = $(vendorlibdir)/$(sitearch)
+vendorlibdir = $(vendordir)/$(ruby_version)
+vendordir = $(rubylibprefix)/vendor_ruby
+sitearchdir = $(sitelibdir)/$(sitearch)
+sitelibdir = $(sitedir)/$(ruby_version)
+sitedir = $(rubylibprefix)/site_ruby
+rubyarchdir = $(rubylibdir)/$(arch)
+rubylibdir = $(rubylibprefix)/$(ruby_version)
+sitearchincludedir = $(includedir)/$(sitearch)
+archincludedir = $(includedir)/$(arch)
+sitearchlibdir = $(libdir)/$(sitearch)
+archlibdir = $(libdir)/$(arch)
+ridir = $(datarootdir)/$(RI_BASE_NAME)
+mandir = $(datarootdir)/man
+localedir = $(datarootdir)/locale
+libdir = $(exec_prefix)/lib
+psdir = $(docdir)
+pdfdir = $(docdir)
+dvidir = $(docdir)
+htmldir = $(docdir)
+infodir = $(datarootdir)/info
+docdir = $(datarootdir)/doc/$(PACKAGE)
+oldincludedir = $(DESTDIR)/usr/include
+includedir = $(prefix)/include
+localstatedir = $(prefix)/var
+sharedstatedir = $(prefix)/com
+sysconfdir = $(prefix)/etc
+datadir = $(datarootdir)
+datarootdir = $(prefix)/share
+libexecdir = $(exec_prefix)/libexec
+sbindir = $(exec_prefix)/sbin
+bindir = $(exec_prefix)/bin
+archdir = $(rubyarchdir)
+
+
+CC = gcc
+CXX = g++
+LIBRUBY = $(LIBRUBY_SO)
+LIBRUBY_A = lib$(RUBY_SO_NAME)-static.a
+LIBRUBYARG_SHARED = -Wl,-R$(libdir) -L$(libdir) -l$(RUBY_SO_NAME)
+LIBRUBYARG_STATIC = -Wl,-R$(libdir) -L$(libdir) -l$(RUBY_SO_NAME)-static
+empty =
+OUTFLAG = -o $(empty)
+COUTFLAG = -o $(empty)
+
+RUBY_EXTCONF_H = extconf.h
+cflags = $(optflags) $(debugflags) $(warnflags)
+optflags = -O3 -fno-fast-math
+debugflags = -ggdb3
+warnflags = -Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wunused-variable -Wpointer-arith -Wwrite-strings -Wdeclaration-after-statement -Wimplicit-function-declaration -Wdeprecated-declarations -Wno-packed-bitfield-compat
+CCDLFLAGS = -fPIC
+CFLAGS = $(CCDLFLAGS) $(cflags) -fPIC $(ARCH_FLAG)
+INCFLAGS = -I. -I$(arch_hdrdir) -I$(hdrdir) -I$(srcdir)
+DEFS =
+CPPFLAGS = -DRUBY_EXTCONF_H=\"$(RUBY_EXTCONF_H)\" $(DEFS) $(cppflags)
+CXXFLAGS = $(CCDLFLAGS) $(cxxflags) $(ARCH_FLAG)
+ldflags = -L. -fstack-protector -rdynamic -Wl,-export-dynamic
+dldflags =
+ARCH_FLAG =
+DLDFLAGS = $(ldflags) $(dldflags) $(ARCH_FLAG)
+LDSHARED = $(CC) -shared
+LDSHAREDXX = $(CXX) -shared
+AR = ar
+EXEEXT =
+
+RUBY_INSTALL_NAME = $(RUBY_BASE_NAME)
+RUBY_SO_NAME = ruby
+RUBYW_INSTALL_NAME =
+RUBY_VERSION_NAME = $(RUBY_BASE_NAME)-$(ruby_version)
+RUBYW_BASE_NAME = rubyw
+RUBY_BASE_NAME = ruby
+
+arch = x86_64-linux
+sitearch = $(arch)
+ruby_version = 2.2.0
+ruby = $(topdir)/miniruby -I'$(topdir)' -I'$(top_srcdir)/lib' -I'$(extout)/$(arch)' -I'$(extout)/common'
+RUBY = $(ruby)
+ruby_headers = $(hdrdir)/ruby.h $(hdrdir)/ruby/ruby.h $(hdrdir)/ruby/defines.h $(hdrdir)/ruby/missing.h $(hdrdir)/ruby/intern.h $(hdrdir)/ruby/st.h $(hdrdir)/ruby/subst.h $(arch_hdrdir)/ruby/config.h $(RUBY_EXTCONF_H)
+
+RM = rm -f
+RM_RF = $(RUBY) -run -e rm -- -rf
+RMDIRS = rmdir --ignore-fail-on-non-empty -p
+MAKEDIRS = /bin/mkdir -p
+INSTALL = /usr/bin/install -c
+INSTALL_PROG = $(INSTALL) -m 0755
+INSTALL_DATA = $(INSTALL) -m 644
+COPY = cp
+TOUCH = exit >
+
+#### End of system configuration section. ####
+
+preload =
+
+libpath = . $(topdir)
+LIBPATH = -L. -L$(topdir)
+DEFFILE =
+
+CLEANFILES = mkmf.log
+DISTCLEANFILES = constdefs.h
+DISTCLEANDIRS =
+
+extout = $(topdir)/.ext
+extout_prefix = $(extout)$(target_prefix)/
+target_prefix =
+LOCAL_LIBS =
+LIBS = $(LIBRUBYARG_SHARED) -lpthread -lgmp -ldl -lcrypt -lm -lc
+ORIG_SRCS = etc.c
+SRCS = $(ORIG_SRCS)
+OBJS = etc.o
+HDRS = $(srcdir)/extconf.h $(srcdir)/constdefs.h
+TARGET = etc
+TARGET_NAME = etc
+TARGET_ENTRY = Init_$(TARGET_NAME)
+DLLIB = $(TARGET).so
+EXTSTATIC =
+STATIC_LIB = $(TARGET).a
+
+TIMESTAMP_DIR = $(extout)/.timestamp
+BINDIR = $(extout)/bin
+RUBYCOMMONDIR = $(extout)/common
+RUBYLIBDIR = $(RUBYCOMMONDIR)$(target_prefix)
+RUBYARCHDIR = $(extout)/$(arch)$(target_prefix)
+HDRDIR = $(extout)/include/ruby$(target_prefix)
+ARCHHDRDIR = $(extout)/include/$(arch)/ruby$(target_prefix)
+
+TARGET_SO = $(RUBYARCHDIR)/$(DLLIB)
+CLEANLIBS = $(RUBYARCHDIR)/$(TARGET).so
+CLEANOBJS = *.o *.bak
+
+all: install
+static: all
+.PHONY: all install static install-so install-rb
+.PHONY: clean clean-so clean-static clean-rb
+
+clean-static::
+clean-rb-default::
+clean-rb::
+clean-so::
+clean: clean-so clean-static clean-rb-default clean-rb
+ -$(Q)$(RM) $(CLEANLIBS) $(CLEANOBJS) $(CLEANFILES) .*.time
+
+distclean-rb-default::
+distclean-rb::
+distclean-so::
+distclean-static::
+distclean: clean distclean-so distclean-static distclean-rb-default distclean-rb
+ -$(Q)$(RM) Makefile $(RUBY_EXTCONF_H) conftest.* mkmf.log
+ -$(Q)$(RM) core ruby$(EXEEXT) *~ $(DISTCLEANFILES)
+ -$(Q)$(RMDIRS) $(DISTCLEANDIRS) 2> /dev/null || true
+
+realclean: distclean
+install: install-so install-rb
+
+install-so: $(RUBYARCHDIR)/$(DLLIB)
+clean-so::
+ -$(Q)$(RM) $(RUBYARCHDIR)/$(DLLIB)
+ -$(Q)$(RMDIRS) $(RUBYARCHDIR) 2> /dev/null || true
+clean-static::
+ -$(Q)$(RM) $(STATIC_LIB)
+install-rb: pre-install-rb install-rb-default
+install-rb-default: pre-install-rb-default
+pre-install-rb: Makefile
+pre-install-rb-default: Makefile
+pre-install-rb-default:
+ @$(NULLCMD)
+$(TIMESTAMP_DIR)/.RUBYARCHDIR.time:
+ $(Q) $(MAKEDIRS) $(@D) $(RUBYARCHDIR)
+ $(Q) $(TOUCH) $@
+
+site-install: site-install-so site-install-rb
+site-install-so: install-so
+site-install-rb: install-rb
+
+.SUFFIXES: .c .m .cc .mm .cxx .cpp .o .S
+
+.cc.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<
+
+.cc.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -S $<
+
+.mm.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<
+
+.mm.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -S $<
+
+.cxx.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<
+
+.cxx.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -S $<
+
+.cpp.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<
+
+.cpp.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -S $<
+
+.c.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -c $<
+
+.c.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -S $<
+
+.m.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -c $<
+
+.m.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -S $<
+
+$(RUBYARCHDIR)/$(DLLIB): $(OBJS) Makefile $(TIMESTAMP_DIR)/.RUBYARCHDIR.time
+ $(ECHO) linking shared-object $(DLLIB)
+ -$(Q)$(RM) $(@)
+ $(Q) $(LDSHARED) -o $@ $(OBJS) $(LIBPATH) $(DLDFLAGS) $(LOCAL_LIBS) $(LIBS)
+
+$(STATIC_LIB): $(OBJS)
+ -$(Q)$(RM) $(@)
+ $(ECHO) linking static-library $(@)
+ $(Q) $(AR) cru $@ $(OBJS)
+ -$(Q)ranlib $(@) 2> /dev/null || true
+
+###
+$(OBJS): $(RUBY_EXTCONF_H)
+
+etc.o : etc.c constdefs.h $(HDRS) $(ruby_headers) \
+ $(hdrdir)/ruby/io.h \
+ $(hdrdir)/ruby/encoding.h \
+ $(hdrdir)/ruby/oniguruma.h
+
+constdefs.h : $(srcdir)/mkconstants.rb
+ @echo "generating constant definitions"
+ @$(RUBY) $(srcdir)/mkconstants.rb -o constdefs.h
+
diff --git a/jni/ruby/ext/etc/constdefs.h b/jni/ruby/ext/etc/constdefs.h
new file mode 100644
index 0000000..1098b52
--- /dev/null
+++ b/jni/ruby/ext/etc/constdefs.h
@@ -0,0 +1,1494 @@
+/* autogenerated file */
+
+#if !defined(_SC_AIO_LISTIO_MAX)
+# if defined(HAVE_CONST__SC_AIO_LISTIO_MAX)
+# define _SC_AIO_LISTIO_MAX _SC_AIO_LISTIO_MAX
+# endif
+#endif
+#if !defined(_SC_AIO_MAX)
+# if defined(HAVE_CONST__SC_AIO_MAX)
+# define _SC_AIO_MAX _SC_AIO_MAX
+# endif
+#endif
+#if !defined(_SC_AIO_PRIO_DELTA_MAX)
+# if defined(HAVE_CONST__SC_AIO_PRIO_DELTA_MAX)
+# define _SC_AIO_PRIO_DELTA_MAX _SC_AIO_PRIO_DELTA_MAX
+# endif
+#endif
+#if !defined(_SC_ARG_MAX)
+# if defined(HAVE_CONST__SC_ARG_MAX)
+# define _SC_ARG_MAX _SC_ARG_MAX
+# endif
+#endif
+#if !defined(_SC_ATEXIT_MAX)
+# if defined(HAVE_CONST__SC_ATEXIT_MAX)
+# define _SC_ATEXIT_MAX _SC_ATEXIT_MAX
+# endif
+#endif
+#if !defined(_SC_BC_BASE_MAX)
+# if defined(HAVE_CONST__SC_BC_BASE_MAX)
+# define _SC_BC_BASE_MAX _SC_BC_BASE_MAX
+# endif
+#endif
+#if !defined(_SC_BC_DIM_MAX)
+# if defined(HAVE_CONST__SC_BC_DIM_MAX)
+# define _SC_BC_DIM_MAX _SC_BC_DIM_MAX
+# endif
+#endif
+#if !defined(_SC_BC_SCALE_MAX)
+# if defined(HAVE_CONST__SC_BC_SCALE_MAX)
+# define _SC_BC_SCALE_MAX _SC_BC_SCALE_MAX
+# endif
+#endif
+#if !defined(_SC_BC_STRING_MAX)
+# if defined(HAVE_CONST__SC_BC_STRING_MAX)
+# define _SC_BC_STRING_MAX _SC_BC_STRING_MAX
+# endif
+#endif
+#if !defined(_SC_CHILD_MAX)
+# if defined(HAVE_CONST__SC_CHILD_MAX)
+# define _SC_CHILD_MAX _SC_CHILD_MAX
+# endif
+#endif
+#if !defined(_SC_CLK_TCK)
+# if defined(HAVE_CONST__SC_CLK_TCK)
+# define _SC_CLK_TCK _SC_CLK_TCK
+# endif
+#endif
+#if !defined(_SC_COLL_WEIGHTS_MAX)
+# if defined(HAVE_CONST__SC_COLL_WEIGHTS_MAX)
+# define _SC_COLL_WEIGHTS_MAX _SC_COLL_WEIGHTS_MAX
+# endif
+#endif
+#if !defined(_SC_DELAYTIMER_MAX)
+# if defined(HAVE_CONST__SC_DELAYTIMER_MAX)
+# define _SC_DELAYTIMER_MAX _SC_DELAYTIMER_MAX
+# endif
+#endif
+#if !defined(_SC_EXPR_NEST_MAX)
+# if defined(HAVE_CONST__SC_EXPR_NEST_MAX)
+# define _SC_EXPR_NEST_MAX _SC_EXPR_NEST_MAX
+# endif
+#endif
+#if !defined(_SC_HOST_NAME_MAX)
+# if defined(HAVE_CONST__SC_HOST_NAME_MAX)
+# define _SC_HOST_NAME_MAX _SC_HOST_NAME_MAX
+# endif
+#endif
+#if !defined(_SC_IOV_MAX)
+# if defined(HAVE_CONST__SC_IOV_MAX)
+# define _SC_IOV_MAX _SC_IOV_MAX
+# endif
+#endif
+#if !defined(_SC_LINE_MAX)
+# if defined(HAVE_CONST__SC_LINE_MAX)
+# define _SC_LINE_MAX _SC_LINE_MAX
+# endif
+#endif
+#if !defined(_SC_LOGIN_NAME_MAX)
+# if defined(HAVE_CONST__SC_LOGIN_NAME_MAX)
+# define _SC_LOGIN_NAME_MAX _SC_LOGIN_NAME_MAX
+# endif
+#endif
+#if !defined(_SC_NGROUPS_MAX)
+# if defined(HAVE_CONST__SC_NGROUPS_MAX)
+# define _SC_NGROUPS_MAX _SC_NGROUPS_MAX
+# endif
+#endif
+#if !defined(_SC_GETGR_R_SIZE_MAX)
+# if defined(HAVE_CONST__SC_GETGR_R_SIZE_MAX)
+# define _SC_GETGR_R_SIZE_MAX _SC_GETGR_R_SIZE_MAX
+# endif
+#endif
+#if !defined(_SC_GETPW_R_SIZE_MAX)
+# if defined(HAVE_CONST__SC_GETPW_R_SIZE_MAX)
+# define _SC_GETPW_R_SIZE_MAX _SC_GETPW_R_SIZE_MAX
+# endif
+#endif
+#if !defined(_SC_MQ_OPEN_MAX)
+# if defined(HAVE_CONST__SC_MQ_OPEN_MAX)
+# define _SC_MQ_OPEN_MAX _SC_MQ_OPEN_MAX
+# endif
+#endif
+#if !defined(_SC_MQ_PRIO_MAX)
+# if defined(HAVE_CONST__SC_MQ_PRIO_MAX)
+# define _SC_MQ_PRIO_MAX _SC_MQ_PRIO_MAX
+# endif
+#endif
+#if !defined(_SC_OPEN_MAX)
+# if defined(HAVE_CONST__SC_OPEN_MAX)
+# define _SC_OPEN_MAX _SC_OPEN_MAX
+# endif
+#endif
+#if !defined(_SC_ADVISORY_INFO)
+# if defined(HAVE_CONST__SC_ADVISORY_INFO)
+# define _SC_ADVISORY_INFO _SC_ADVISORY_INFO
+# endif
+#endif
+#if !defined(_SC_BARRIERS)
+# if defined(HAVE_CONST__SC_BARRIERS)
+# define _SC_BARRIERS _SC_BARRIERS
+# endif
+#endif
+#if !defined(_SC_ASYNCHRONOUS_IO)
+# if defined(HAVE_CONST__SC_ASYNCHRONOUS_IO)
+# define _SC_ASYNCHRONOUS_IO _SC_ASYNCHRONOUS_IO
+# endif
+#endif
+#if !defined(_SC_CLOCK_SELECTION)
+# if defined(HAVE_CONST__SC_CLOCK_SELECTION)
+# define _SC_CLOCK_SELECTION _SC_CLOCK_SELECTION
+# endif
+#endif
+#if !defined(_SC_CPUTIME)
+# if defined(HAVE_CONST__SC_CPUTIME)
+# define _SC_CPUTIME _SC_CPUTIME
+# endif
+#endif
+#if !defined(_SC_FSYNC)
+# if defined(HAVE_CONST__SC_FSYNC)
+# define _SC_FSYNC _SC_FSYNC
+# endif
+#endif
+#if !defined(_SC_IPV6)
+# if defined(HAVE_CONST__SC_IPV6)
+# define _SC_IPV6 _SC_IPV6
+# endif
+#endif
+#if !defined(_SC_JOB_CONTROL)
+# if defined(HAVE_CONST__SC_JOB_CONTROL)
+# define _SC_JOB_CONTROL _SC_JOB_CONTROL
+# endif
+#endif
+#if !defined(_SC_MAPPED_FILES)
+# if defined(HAVE_CONST__SC_MAPPED_FILES)
+# define _SC_MAPPED_FILES _SC_MAPPED_FILES
+# endif
+#endif
+#if !defined(_SC_MEMLOCK)
+# if defined(HAVE_CONST__SC_MEMLOCK)
+# define _SC_MEMLOCK _SC_MEMLOCK
+# endif
+#endif
+#if !defined(_SC_MEMLOCK_RANGE)
+# if defined(HAVE_CONST__SC_MEMLOCK_RANGE)
+# define _SC_MEMLOCK_RANGE _SC_MEMLOCK_RANGE
+# endif
+#endif
+#if !defined(_SC_MEMORY_PROTECTION)
+# if defined(HAVE_CONST__SC_MEMORY_PROTECTION)
+# define _SC_MEMORY_PROTECTION _SC_MEMORY_PROTECTION
+# endif
+#endif
+#if !defined(_SC_MESSAGE_PASSING)
+# if defined(HAVE_CONST__SC_MESSAGE_PASSING)
+# define _SC_MESSAGE_PASSING _SC_MESSAGE_PASSING
+# endif
+#endif
+#if !defined(_SC_MONOTONIC_CLOCK)
+# if defined(HAVE_CONST__SC_MONOTONIC_CLOCK)
+# define _SC_MONOTONIC_CLOCK _SC_MONOTONIC_CLOCK
+# endif
+#endif
+#if !defined(_SC_PRIORITIZED_IO)
+# if defined(HAVE_CONST__SC_PRIORITIZED_IO)
+# define _SC_PRIORITIZED_IO _SC_PRIORITIZED_IO
+# endif
+#endif
+#if !defined(_SC_PRIORITY_SCHEDULING)
+# if defined(HAVE_CONST__SC_PRIORITY_SCHEDULING)
+# define _SC_PRIORITY_SCHEDULING _SC_PRIORITY_SCHEDULING
+# endif
+#endif
+#if !defined(_SC_RAW_SOCKETS)
+# if defined(HAVE_CONST__SC_RAW_SOCKETS)
+# define _SC_RAW_SOCKETS _SC_RAW_SOCKETS
+# endif
+#endif
+#if !defined(_SC_READER_WRITER_LOCKS)
+# if defined(HAVE_CONST__SC_READER_WRITER_LOCKS)
+# define _SC_READER_WRITER_LOCKS _SC_READER_WRITER_LOCKS
+# endif
+#endif
+#if !defined(_SC_REALTIME_SIGNALS)
+# if defined(HAVE_CONST__SC_REALTIME_SIGNALS)
+# define _SC_REALTIME_SIGNALS _SC_REALTIME_SIGNALS
+# endif
+#endif
+#if !defined(_SC_REGEXP)
+# if defined(HAVE_CONST__SC_REGEXP)
+# define _SC_REGEXP _SC_REGEXP
+# endif
+#endif
+#if !defined(_SC_SAVED_IDS)
+# if defined(HAVE_CONST__SC_SAVED_IDS)
+# define _SC_SAVED_IDS _SC_SAVED_IDS
+# endif
+#endif
+#if !defined(_SC_SEMAPHORES)
+# if defined(HAVE_CONST__SC_SEMAPHORES)
+# define _SC_SEMAPHORES _SC_SEMAPHORES
+# endif
+#endif
+#if !defined(_SC_SHARED_MEMORY_OBJECTS)
+# if defined(HAVE_CONST__SC_SHARED_MEMORY_OBJECTS)
+# define _SC_SHARED_MEMORY_OBJECTS _SC_SHARED_MEMORY_OBJECTS
+# endif
+#endif
+#if !defined(_SC_SHELL)
+# if defined(HAVE_CONST__SC_SHELL)
+# define _SC_SHELL _SC_SHELL
+# endif
+#endif
+#if !defined(_SC_SPAWN)
+# if defined(HAVE_CONST__SC_SPAWN)
+# define _SC_SPAWN _SC_SPAWN
+# endif
+#endif
+#if !defined(_SC_SPIN_LOCKS)
+# if defined(HAVE_CONST__SC_SPIN_LOCKS)
+# define _SC_SPIN_LOCKS _SC_SPIN_LOCKS
+# endif
+#endif
+#if !defined(_SC_SPORADIC_SERVER)
+# if defined(HAVE_CONST__SC_SPORADIC_SERVER)
+# define _SC_SPORADIC_SERVER _SC_SPORADIC_SERVER
+# endif
+#endif
+#if !defined(_SC_SS_REPL_MAX)
+# if defined(HAVE_CONST__SC_SS_REPL_MAX)
+# define _SC_SS_REPL_MAX _SC_SS_REPL_MAX
+# endif
+#endif
+#if !defined(_SC_SYNCHRONIZED_IO)
+# if defined(HAVE_CONST__SC_SYNCHRONIZED_IO)
+# define _SC_SYNCHRONIZED_IO _SC_SYNCHRONIZED_IO
+# endif
+#endif
+#if !defined(_SC_THREAD_ATTR_STACKADDR)
+# if defined(HAVE_CONST__SC_THREAD_ATTR_STACKADDR)
+# define _SC_THREAD_ATTR_STACKADDR _SC_THREAD_ATTR_STACKADDR
+# endif
+#endif
+#if !defined(_SC_THREAD_ATTR_STACKSIZE)
+# if defined(HAVE_CONST__SC_THREAD_ATTR_STACKSIZE)
+# define _SC_THREAD_ATTR_STACKSIZE _SC_THREAD_ATTR_STACKSIZE
+# endif
+#endif
+#if !defined(_SC_THREAD_CPUTIME)
+# if defined(HAVE_CONST__SC_THREAD_CPUTIME)
+# define _SC_THREAD_CPUTIME _SC_THREAD_CPUTIME
+# endif
+#endif
+#if !defined(_SC_THREAD_PRIO_INHERIT)
+# if defined(HAVE_CONST__SC_THREAD_PRIO_INHERIT)
+# define _SC_THREAD_PRIO_INHERIT _SC_THREAD_PRIO_INHERIT
+# endif
+#endif
+#if !defined(_SC_THREAD_PRIO_PROTECT)
+# if defined(HAVE_CONST__SC_THREAD_PRIO_PROTECT)
+# define _SC_THREAD_PRIO_PROTECT _SC_THREAD_PRIO_PROTECT
+# endif
+#endif
+#if !defined(_SC_THREAD_PRIORITY_SCHEDULING)
+# if defined(HAVE_CONST__SC_THREAD_PRIORITY_SCHEDULING)
+# define _SC_THREAD_PRIORITY_SCHEDULING _SC_THREAD_PRIORITY_SCHEDULING
+# endif
+#endif
+#if !defined(_SC_THREAD_PROCESS_SHARED)
+# if defined(HAVE_CONST__SC_THREAD_PROCESS_SHARED)
+# define _SC_THREAD_PROCESS_SHARED _SC_THREAD_PROCESS_SHARED
+# endif
+#endif
+#if !defined(_SC_THREAD_ROBUST_PRIO_INHERIT)
+# if defined(HAVE_CONST__SC_THREAD_ROBUST_PRIO_INHERIT)
+# define _SC_THREAD_ROBUST_PRIO_INHERIT _SC_THREAD_ROBUST_PRIO_INHERIT
+# endif
+#endif
+#if !defined(_SC_THREAD_ROBUST_PRIO_PROTECT)
+# if defined(HAVE_CONST__SC_THREAD_ROBUST_PRIO_PROTECT)
+# define _SC_THREAD_ROBUST_PRIO_PROTECT _SC_THREAD_ROBUST_PRIO_PROTECT
+# endif
+#endif
+#if !defined(_SC_THREAD_SAFE_FUNCTIONS)
+# if defined(HAVE_CONST__SC_THREAD_SAFE_FUNCTIONS)
+# define _SC_THREAD_SAFE_FUNCTIONS _SC_THREAD_SAFE_FUNCTIONS
+# endif
+#endif
+#if !defined(_SC_THREAD_SPORADIC_SERVER)
+# if defined(HAVE_CONST__SC_THREAD_SPORADIC_SERVER)
+# define _SC_THREAD_SPORADIC_SERVER _SC_THREAD_SPORADIC_SERVER
+# endif
+#endif
+#if !defined(_SC_THREADS)
+# if defined(HAVE_CONST__SC_THREADS)
+# define _SC_THREADS _SC_THREADS
+# endif
+#endif
+#if !defined(_SC_TIMEOUTS)
+# if defined(HAVE_CONST__SC_TIMEOUTS)
+# define _SC_TIMEOUTS _SC_TIMEOUTS
+# endif
+#endif
+#if !defined(_SC_TIMERS)
+# if defined(HAVE_CONST__SC_TIMERS)
+# define _SC_TIMERS _SC_TIMERS
+# endif
+#endif
+#if !defined(_SC_TRACE)
+# if defined(HAVE_CONST__SC_TRACE)
+# define _SC_TRACE _SC_TRACE
+# endif
+#endif
+#if !defined(_SC_TRACE_EVENT_FILTER)
+# if defined(HAVE_CONST__SC_TRACE_EVENT_FILTER)
+# define _SC_TRACE_EVENT_FILTER _SC_TRACE_EVENT_FILTER
+# endif
+#endif
+#if !defined(_SC_TRACE_EVENT_NAME_MAX)
+# if defined(HAVE_CONST__SC_TRACE_EVENT_NAME_MAX)
+# define _SC_TRACE_EVENT_NAME_MAX _SC_TRACE_EVENT_NAME_MAX
+# endif
+#endif
+#if !defined(_SC_TRACE_INHERIT)
+# if defined(HAVE_CONST__SC_TRACE_INHERIT)
+# define _SC_TRACE_INHERIT _SC_TRACE_INHERIT
+# endif
+#endif
+#if !defined(_SC_TRACE_LOG)
+# if defined(HAVE_CONST__SC_TRACE_LOG)
+# define _SC_TRACE_LOG _SC_TRACE_LOG
+# endif
+#endif
+#if !defined(_SC_TRACE_NAME_MAX)
+# if defined(HAVE_CONST__SC_TRACE_NAME_MAX)
+# define _SC_TRACE_NAME_MAX _SC_TRACE_NAME_MAX
+# endif
+#endif
+#if !defined(_SC_TRACE_SYS_MAX)
+# if defined(HAVE_CONST__SC_TRACE_SYS_MAX)
+# define _SC_TRACE_SYS_MAX _SC_TRACE_SYS_MAX
+# endif
+#endif
+#if !defined(_SC_TRACE_USER_EVENT_MAX)
+# if defined(HAVE_CONST__SC_TRACE_USER_EVENT_MAX)
+# define _SC_TRACE_USER_EVENT_MAX _SC_TRACE_USER_EVENT_MAX
+# endif
+#endif
+#if !defined(_SC_TYPED_MEMORY_OBJECTS)
+# if defined(HAVE_CONST__SC_TYPED_MEMORY_OBJECTS)
+# define _SC_TYPED_MEMORY_OBJECTS _SC_TYPED_MEMORY_OBJECTS
+# endif
+#endif
+#if !defined(_SC_VERSION)
+# if defined(HAVE_CONST__SC_VERSION)
+# define _SC_VERSION _SC_VERSION
+# endif
+#endif
+#if !defined(_SC_V7_ILP32_OFF32)
+# if defined(HAVE_CONST__SC_V7_ILP32_OFF32)
+# define _SC_V7_ILP32_OFF32 _SC_V7_ILP32_OFF32
+# endif
+#endif
+#if !defined(_SC_V7_ILP32_OFFBIG)
+# if defined(HAVE_CONST__SC_V7_ILP32_OFFBIG)
+# define _SC_V7_ILP32_OFFBIG _SC_V7_ILP32_OFFBIG
+# endif
+#endif
+#if !defined(_SC_V7_LP64_OFF64)
+# if defined(HAVE_CONST__SC_V7_LP64_OFF64)
+# define _SC_V7_LP64_OFF64 _SC_V7_LP64_OFF64
+# endif
+#endif
+#if !defined(_SC_V7_LPBIG_OFFBIG)
+# if defined(HAVE_CONST__SC_V7_LPBIG_OFFBIG)
+# define _SC_V7_LPBIG_OFFBIG _SC_V7_LPBIG_OFFBIG
+# endif
+#endif
+#if !defined(_SC_V6_ILP32_OFF32)
+# if defined(HAVE_CONST__SC_V6_ILP32_OFF32)
+# define _SC_V6_ILP32_OFF32 _SC_V6_ILP32_OFF32
+# endif
+#endif
+#if !defined(_SC_V6_ILP32_OFFBIG)
+# if defined(HAVE_CONST__SC_V6_ILP32_OFFBIG)
+# define _SC_V6_ILP32_OFFBIG _SC_V6_ILP32_OFFBIG
+# endif
+#endif
+#if !defined(_SC_V6_LP64_OFF64)
+# if defined(HAVE_CONST__SC_V6_LP64_OFF64)
+# define _SC_V6_LP64_OFF64 _SC_V6_LP64_OFF64
+# endif
+#endif
+#if !defined(_SC_V6_LPBIG_OFFBIG)
+# if defined(HAVE_CONST__SC_V6_LPBIG_OFFBIG)
+# define _SC_V6_LPBIG_OFFBIG _SC_V6_LPBIG_OFFBIG
+# endif
+#endif
+#if !defined(_SC_2_C_BIND)
+# if defined(HAVE_CONST__SC_2_C_BIND)
+# define _SC_2_C_BIND _SC_2_C_BIND
+# endif
+#endif
+#if !defined(_SC_2_C_DEV)
+# if defined(HAVE_CONST__SC_2_C_DEV)
+# define _SC_2_C_DEV _SC_2_C_DEV
+# endif
+#endif
+#if !defined(_SC_2_CHAR_TERM)
+# if defined(HAVE_CONST__SC_2_CHAR_TERM)
+# define _SC_2_CHAR_TERM _SC_2_CHAR_TERM
+# endif
+#endif
+#if !defined(_SC_2_FORT_DEV)
+# if defined(HAVE_CONST__SC_2_FORT_DEV)
+# define _SC_2_FORT_DEV _SC_2_FORT_DEV
+# endif
+#endif
+#if !defined(_SC_2_FORT_RUN)
+# if defined(HAVE_CONST__SC_2_FORT_RUN)
+# define _SC_2_FORT_RUN _SC_2_FORT_RUN
+# endif
+#endif
+#if !defined(_SC_2_LOCALEDEF)
+# if defined(HAVE_CONST__SC_2_LOCALEDEF)
+# define _SC_2_LOCALEDEF _SC_2_LOCALEDEF
+# endif
+#endif
+#if !defined(_SC_2_PBS)
+# if defined(HAVE_CONST__SC_2_PBS)
+# define _SC_2_PBS _SC_2_PBS
+# endif
+#endif
+#if !defined(_SC_2_PBS_ACCOUNTING)
+# if defined(HAVE_CONST__SC_2_PBS_ACCOUNTING)
+# define _SC_2_PBS_ACCOUNTING _SC_2_PBS_ACCOUNTING
+# endif
+#endif
+#if !defined(_SC_2_PBS_CHECKPOINT)
+# if defined(HAVE_CONST__SC_2_PBS_CHECKPOINT)
+# define _SC_2_PBS_CHECKPOINT _SC_2_PBS_CHECKPOINT
+# endif
+#endif
+#if !defined(_SC_2_PBS_LOCATE)
+# if defined(HAVE_CONST__SC_2_PBS_LOCATE)
+# define _SC_2_PBS_LOCATE _SC_2_PBS_LOCATE
+# endif
+#endif
+#if !defined(_SC_2_PBS_MESSAGE)
+# if defined(HAVE_CONST__SC_2_PBS_MESSAGE)
+# define _SC_2_PBS_MESSAGE _SC_2_PBS_MESSAGE
+# endif
+#endif
+#if !defined(_SC_2_PBS_TRACK)
+# if defined(HAVE_CONST__SC_2_PBS_TRACK)
+# define _SC_2_PBS_TRACK _SC_2_PBS_TRACK
+# endif
+#endif
+#if !defined(_SC_2_SW_DEV)
+# if defined(HAVE_CONST__SC_2_SW_DEV)
+# define _SC_2_SW_DEV _SC_2_SW_DEV
+# endif
+#endif
+#if !defined(_SC_2_UPE)
+# if defined(HAVE_CONST__SC_2_UPE)
+# define _SC_2_UPE _SC_2_UPE
+# endif
+#endif
+#if !defined(_SC_2_VERSION)
+# if defined(HAVE_CONST__SC_2_VERSION)
+# define _SC_2_VERSION _SC_2_VERSION
+# endif
+#endif
+#if !defined(_SC_PAGE_SIZE)
+# if defined(HAVE_CONST__SC_PAGE_SIZE)
+# define _SC_PAGE_SIZE _SC_PAGE_SIZE
+# endif
+#endif
+#if !defined(_SC_PAGESIZE)
+# if defined(HAVE_CONST__SC_PAGESIZE)
+# define _SC_PAGESIZE _SC_PAGESIZE
+# endif
+#endif
+#if !defined(_SC_THREAD_DESTRUCTOR_ITERATIONS)
+# if defined(HAVE_CONST__SC_THREAD_DESTRUCTOR_ITERATIONS)
+# define _SC_THREAD_DESTRUCTOR_ITERATIONS _SC_THREAD_DESTRUCTOR_ITERATIONS
+# endif
+#endif
+#if !defined(_SC_THREAD_KEYS_MAX)
+# if defined(HAVE_CONST__SC_THREAD_KEYS_MAX)
+# define _SC_THREAD_KEYS_MAX _SC_THREAD_KEYS_MAX
+# endif
+#endif
+#if !defined(_SC_THREAD_STACK_MIN)
+# if defined(HAVE_CONST__SC_THREAD_STACK_MIN)
+# define _SC_THREAD_STACK_MIN _SC_THREAD_STACK_MIN
+# endif
+#endif
+#if !defined(_SC_THREAD_THREADS_MAX)
+# if defined(HAVE_CONST__SC_THREAD_THREADS_MAX)
+# define _SC_THREAD_THREADS_MAX _SC_THREAD_THREADS_MAX
+# endif
+#endif
+#if !defined(_SC_RE_DUP_MAX)
+# if defined(HAVE_CONST__SC_RE_DUP_MAX)
+# define _SC_RE_DUP_MAX _SC_RE_DUP_MAX
+# endif
+#endif
+#if !defined(_SC_RTSIG_MAX)
+# if defined(HAVE_CONST__SC_RTSIG_MAX)
+# define _SC_RTSIG_MAX _SC_RTSIG_MAX
+# endif
+#endif
+#if !defined(_SC_SEM_NSEMS_MAX)
+# if defined(HAVE_CONST__SC_SEM_NSEMS_MAX)
+# define _SC_SEM_NSEMS_MAX _SC_SEM_NSEMS_MAX
+# endif
+#endif
+#if !defined(_SC_SEM_VALUE_MAX)
+# if defined(HAVE_CONST__SC_SEM_VALUE_MAX)
+# define _SC_SEM_VALUE_MAX _SC_SEM_VALUE_MAX
+# endif
+#endif
+#if !defined(_SC_SIGQUEUE_MAX)
+# if defined(HAVE_CONST__SC_SIGQUEUE_MAX)
+# define _SC_SIGQUEUE_MAX _SC_SIGQUEUE_MAX
+# endif
+#endif
+#if !defined(_SC_STREAM_MAX)
+# if defined(HAVE_CONST__SC_STREAM_MAX)
+# define _SC_STREAM_MAX _SC_STREAM_MAX
+# endif
+#endif
+#if !defined(_SC_SYMLOOP_MAX)
+# if defined(HAVE_CONST__SC_SYMLOOP_MAX)
+# define _SC_SYMLOOP_MAX _SC_SYMLOOP_MAX
+# endif
+#endif
+#if !defined(_SC_TIMER_MAX)
+# if defined(HAVE_CONST__SC_TIMER_MAX)
+# define _SC_TIMER_MAX _SC_TIMER_MAX
+# endif
+#endif
+#if !defined(_SC_TTY_NAME_MAX)
+# if defined(HAVE_CONST__SC_TTY_NAME_MAX)
+# define _SC_TTY_NAME_MAX _SC_TTY_NAME_MAX
+# endif
+#endif
+#if !defined(_SC_TZNAME_MAX)
+# if defined(HAVE_CONST__SC_TZNAME_MAX)
+# define _SC_TZNAME_MAX _SC_TZNAME_MAX
+# endif
+#endif
+#if !defined(_SC_XOPEN_CRYPT)
+# if defined(HAVE_CONST__SC_XOPEN_CRYPT)
+# define _SC_XOPEN_CRYPT _SC_XOPEN_CRYPT
+# endif
+#endif
+#if !defined(_SC_XOPEN_ENH_I18N)
+# if defined(HAVE_CONST__SC_XOPEN_ENH_I18N)
+# define _SC_XOPEN_ENH_I18N _SC_XOPEN_ENH_I18N
+# endif
+#endif
+#if !defined(_SC_XOPEN_REALTIME)
+# if defined(HAVE_CONST__SC_XOPEN_REALTIME)
+# define _SC_XOPEN_REALTIME _SC_XOPEN_REALTIME
+# endif
+#endif
+#if !defined(_SC_XOPEN_REALTIME_THREADS)
+# if defined(HAVE_CONST__SC_XOPEN_REALTIME_THREADS)
+# define _SC_XOPEN_REALTIME_THREADS _SC_XOPEN_REALTIME_THREADS
+# endif
+#endif
+#if !defined(_SC_XOPEN_SHM)
+# if defined(HAVE_CONST__SC_XOPEN_SHM)
+# define _SC_XOPEN_SHM _SC_XOPEN_SHM
+# endif
+#endif
+#if !defined(_SC_XOPEN_STREAMS)
+# if defined(HAVE_CONST__SC_XOPEN_STREAMS)
+# define _SC_XOPEN_STREAMS _SC_XOPEN_STREAMS
+# endif
+#endif
+#if !defined(_SC_XOPEN_UNIX)
+# if defined(HAVE_CONST__SC_XOPEN_UNIX)
+# define _SC_XOPEN_UNIX _SC_XOPEN_UNIX
+# endif
+#endif
+#if !defined(_SC_XOPEN_UUCP)
+# if defined(HAVE_CONST__SC_XOPEN_UUCP)
+# define _SC_XOPEN_UUCP _SC_XOPEN_UUCP
+# endif
+#endif
+#if !defined(_SC_XOPEN_VERSION)
+# if defined(HAVE_CONST__SC_XOPEN_VERSION)
+# define _SC_XOPEN_VERSION _SC_XOPEN_VERSION
+# endif
+#endif
+#if !defined(_SC_PHYS_PAGES)
+# if defined(HAVE_CONST__SC_PHYS_PAGES)
+# define _SC_PHYS_PAGES _SC_PHYS_PAGES
+# endif
+#endif
+#if !defined(_SC_AVPHYS_PAGES)
+# if defined(HAVE_CONST__SC_AVPHYS_PAGES)
+# define _SC_AVPHYS_PAGES _SC_AVPHYS_PAGES
+# endif
+#endif
+#if !defined(_SC_NPROCESSORS_CONF)
+# if defined(HAVE_CONST__SC_NPROCESSORS_CONF)
+# define _SC_NPROCESSORS_CONF _SC_NPROCESSORS_CONF
+# endif
+#endif
+#if !defined(_SC_NPROCESSORS_ONLN)
+# if defined(HAVE_CONST__SC_NPROCESSORS_ONLN)
+# define _SC_NPROCESSORS_ONLN _SC_NPROCESSORS_ONLN
+# endif
+#endif
+#if !defined(_SC_CPUSET_SIZE)
+# if defined(HAVE_CONST__SC_CPUSET_SIZE)
+# define _SC_CPUSET_SIZE _SC_CPUSET_SIZE
+# endif
+#endif
+#if !defined(_CS_PATH)
+# if defined(HAVE_CONST__CS_PATH)
+# define _CS_PATH _CS_PATH
+# endif
+#endif
+#if !defined(_CS_POSIX_V7_ILP32_OFF32_CFLAGS)
+# if defined(HAVE_CONST__CS_POSIX_V7_ILP32_OFF32_CFLAGS)
+# define _CS_POSIX_V7_ILP32_OFF32_CFLAGS _CS_POSIX_V7_ILP32_OFF32_CFLAGS
+# endif
+#endif
+#if !defined(_CS_POSIX_V7_ILP32_OFF32_LDFLAGS)
+# if defined(HAVE_CONST__CS_POSIX_V7_ILP32_OFF32_LDFLAGS)
+# define _CS_POSIX_V7_ILP32_OFF32_LDFLAGS _CS_POSIX_V7_ILP32_OFF32_LDFLAGS
+# endif
+#endif
+#if !defined(_CS_POSIX_V7_ILP32_OFF32_LIBS)
+# if defined(HAVE_CONST__CS_POSIX_V7_ILP32_OFF32_LIBS)
+# define _CS_POSIX_V7_ILP32_OFF32_LIBS _CS_POSIX_V7_ILP32_OFF32_LIBS
+# endif
+#endif
+#if !defined(_CS_POSIX_V7_ILP32_OFFBIG_CFLAGS)
+# if defined(HAVE_CONST__CS_POSIX_V7_ILP32_OFFBIG_CFLAGS)
+# define _CS_POSIX_V7_ILP32_OFFBIG_CFLAGS _CS_POSIX_V7_ILP32_OFFBIG_CFLAGS
+# endif
+#endif
+#if !defined(_CS_POSIX_V7_ILP32_OFFBIG_LDFLAGS)
+# if defined(HAVE_CONST__CS_POSIX_V7_ILP32_OFFBIG_LDFLAGS)
+# define _CS_POSIX_V7_ILP32_OFFBIG_LDFLAGS _CS_POSIX_V7_ILP32_OFFBIG_LDFLAGS
+# endif
+#endif
+#if !defined(_CS_POSIX_V7_ILP32_OFFBIG_LIBS)
+# if defined(HAVE_CONST__CS_POSIX_V7_ILP32_OFFBIG_LIBS)
+# define _CS_POSIX_V7_ILP32_OFFBIG_LIBS _CS_POSIX_V7_ILP32_OFFBIG_LIBS
+# endif
+#endif
+#if !defined(_CS_POSIX_V7_LP64_OFF64_CFLAGS)
+# if defined(HAVE_CONST__CS_POSIX_V7_LP64_OFF64_CFLAGS)
+# define _CS_POSIX_V7_LP64_OFF64_CFLAGS _CS_POSIX_V7_LP64_OFF64_CFLAGS
+# endif
+#endif
+#if !defined(_CS_POSIX_V7_LP64_OFF64_LDFLAGS)
+# if defined(HAVE_CONST__CS_POSIX_V7_LP64_OFF64_LDFLAGS)
+# define _CS_POSIX_V7_LP64_OFF64_LDFLAGS _CS_POSIX_V7_LP64_OFF64_LDFLAGS
+# endif
+#endif
+#if !defined(_CS_POSIX_V7_LP64_OFF64_LIBS)
+# if defined(HAVE_CONST__CS_POSIX_V7_LP64_OFF64_LIBS)
+# define _CS_POSIX_V7_LP64_OFF64_LIBS _CS_POSIX_V7_LP64_OFF64_LIBS
+# endif
+#endif
+#if !defined(_CS_POSIX_V7_LPBIG_OFFBIG_CFLAGS)
+# if defined(HAVE_CONST__CS_POSIX_V7_LPBIG_OFFBIG_CFLAGS)
+# define _CS_POSIX_V7_LPBIG_OFFBIG_CFLAGS _CS_POSIX_V7_LPBIG_OFFBIG_CFLAGS
+# endif
+#endif
+#if !defined(_CS_POSIX_V7_LPBIG_OFFBIG_LDFLAGS)
+# if defined(HAVE_CONST__CS_POSIX_V7_LPBIG_OFFBIG_LDFLAGS)
+# define _CS_POSIX_V7_LPBIG_OFFBIG_LDFLAGS _CS_POSIX_V7_LPBIG_OFFBIG_LDFLAGS
+# endif
+#endif
+#if !defined(_CS_POSIX_V7_LPBIG_OFFBIG_LIBS)
+# if defined(HAVE_CONST__CS_POSIX_V7_LPBIG_OFFBIG_LIBS)
+# define _CS_POSIX_V7_LPBIG_OFFBIG_LIBS _CS_POSIX_V7_LPBIG_OFFBIG_LIBS
+# endif
+#endif
+#if !defined(_CS_POSIX_V7_THREADS_CFLAGS)
+# if defined(HAVE_CONST__CS_POSIX_V7_THREADS_CFLAGS)
+# define _CS_POSIX_V7_THREADS_CFLAGS _CS_POSIX_V7_THREADS_CFLAGS
+# endif
+#endif
+#if !defined(_CS_POSIX_V7_THREADS_LDFLAGS)
+# if defined(HAVE_CONST__CS_POSIX_V7_THREADS_LDFLAGS)
+# define _CS_POSIX_V7_THREADS_LDFLAGS _CS_POSIX_V7_THREADS_LDFLAGS
+# endif
+#endif
+#if !defined(_CS_POSIX_V7_WIDTH_RESTRICTED_ENVS)
+# if defined(HAVE_CONST__CS_POSIX_V7_WIDTH_RESTRICTED_ENVS)
+# define _CS_POSIX_V7_WIDTH_RESTRICTED_ENVS _CS_POSIX_V7_WIDTH_RESTRICTED_ENVS
+# endif
+#endif
+#if !defined(_CS_V7_ENV)
+# if defined(HAVE_CONST__CS_V7_ENV)
+# define _CS_V7_ENV _CS_V7_ENV
+# endif
+#endif
+#if !defined(_CS_POSIX_V6_ILP32_OFF32_CFLAGS)
+# if defined(HAVE_CONST__CS_POSIX_V6_ILP32_OFF32_CFLAGS)
+# define _CS_POSIX_V6_ILP32_OFF32_CFLAGS _CS_POSIX_V6_ILP32_OFF32_CFLAGS
+# endif
+#endif
+#if !defined(_CS_POSIX_V6_ILP32_OFF32_LDFLAGS)
+# if defined(HAVE_CONST__CS_POSIX_V6_ILP32_OFF32_LDFLAGS)
+# define _CS_POSIX_V6_ILP32_OFF32_LDFLAGS _CS_POSIX_V6_ILP32_OFF32_LDFLAGS
+# endif
+#endif
+#if !defined(_CS_POSIX_V6_ILP32_OFF32_LIBS)
+# if defined(HAVE_CONST__CS_POSIX_V6_ILP32_OFF32_LIBS)
+# define _CS_POSIX_V6_ILP32_OFF32_LIBS _CS_POSIX_V6_ILP32_OFF32_LIBS
+# endif
+#endif
+#if !defined(_CS_POSIX_V6_ILP32_OFFBIG_CFLAGS)
+# if defined(HAVE_CONST__CS_POSIX_V6_ILP32_OFFBIG_CFLAGS)
+# define _CS_POSIX_V6_ILP32_OFFBIG_CFLAGS _CS_POSIX_V6_ILP32_OFFBIG_CFLAGS
+# endif
+#endif
+#if !defined(_CS_POSIX_V6_ILP32_OFFBIG_LDFLAGS)
+# if defined(HAVE_CONST__CS_POSIX_V6_ILP32_OFFBIG_LDFLAGS)
+# define _CS_POSIX_V6_ILP32_OFFBIG_LDFLAGS _CS_POSIX_V6_ILP32_OFFBIG_LDFLAGS
+# endif
+#endif
+#if !defined(_CS_POSIX_V6_ILP32_OFFBIG_LIBS)
+# if defined(HAVE_CONST__CS_POSIX_V6_ILP32_OFFBIG_LIBS)
+# define _CS_POSIX_V6_ILP32_OFFBIG_LIBS _CS_POSIX_V6_ILP32_OFFBIG_LIBS
+# endif
+#endif
+#if !defined(_CS_POSIX_V6_LP64_OFF64_CFLAGS)
+# if defined(HAVE_CONST__CS_POSIX_V6_LP64_OFF64_CFLAGS)
+# define _CS_POSIX_V6_LP64_OFF64_CFLAGS _CS_POSIX_V6_LP64_OFF64_CFLAGS
+# endif
+#endif
+#if !defined(_CS_POSIX_V6_LP64_OFF64_LDFLAGS)
+# if defined(HAVE_CONST__CS_POSIX_V6_LP64_OFF64_LDFLAGS)
+# define _CS_POSIX_V6_LP64_OFF64_LDFLAGS _CS_POSIX_V6_LP64_OFF64_LDFLAGS
+# endif
+#endif
+#if !defined(_CS_POSIX_V6_LP64_OFF64_LIBS)
+# if defined(HAVE_CONST__CS_POSIX_V6_LP64_OFF64_LIBS)
+# define _CS_POSIX_V6_LP64_OFF64_LIBS _CS_POSIX_V6_LP64_OFF64_LIBS
+# endif
+#endif
+#if !defined(_CS_POSIX_V6_LPBIG_OFFBIG_CFLAGS)
+# if defined(HAVE_CONST__CS_POSIX_V6_LPBIG_OFFBIG_CFLAGS)
+# define _CS_POSIX_V6_LPBIG_OFFBIG_CFLAGS _CS_POSIX_V6_LPBIG_OFFBIG_CFLAGS
+# endif
+#endif
+#if !defined(_CS_POSIX_V6_LPBIG_OFFBIG_LDFLAGS)
+# if defined(HAVE_CONST__CS_POSIX_V6_LPBIG_OFFBIG_LDFLAGS)
+# define _CS_POSIX_V6_LPBIG_OFFBIG_LDFLAGS _CS_POSIX_V6_LPBIG_OFFBIG_LDFLAGS
+# endif
+#endif
+#if !defined(_CS_POSIX_V6_LPBIG_OFFBIG_LIBS)
+# if defined(HAVE_CONST__CS_POSIX_V6_LPBIG_OFFBIG_LIBS)
+# define _CS_POSIX_V6_LPBIG_OFFBIG_LIBS _CS_POSIX_V6_LPBIG_OFFBIG_LIBS
+# endif
+#endif
+#if !defined(_CS_POSIX_V6_WIDTH_RESTRICTED_ENVS)
+# if defined(HAVE_CONST__CS_POSIX_V6_WIDTH_RESTRICTED_ENVS)
+# define _CS_POSIX_V6_WIDTH_RESTRICTED_ENVS _CS_POSIX_V6_WIDTH_RESTRICTED_ENVS
+# endif
+#endif
+#if !defined(_CS_V6_ENV)
+# if defined(HAVE_CONST__CS_V6_ENV)
+# define _CS_V6_ENV _CS_V6_ENV
+# endif
+#endif
+#if !defined(_CS_GNU_LIBC_VERSION)
+# if defined(HAVE_CONST__CS_GNU_LIBC_VERSION)
+# define _CS_GNU_LIBC_VERSION _CS_GNU_LIBC_VERSION
+# endif
+#endif
+#if !defined(_CS_GNU_LIBPTHREAD_VERSION)
+# if defined(HAVE_CONST__CS_GNU_LIBPTHREAD_VERSION)
+# define _CS_GNU_LIBPTHREAD_VERSION _CS_GNU_LIBPTHREAD_VERSION
+# endif
+#endif
+#if !defined(_PC_FILESIZEBITS)
+# if defined(HAVE_CONST__PC_FILESIZEBITS)
+# define _PC_FILESIZEBITS _PC_FILESIZEBITS
+# endif
+#endif
+#if !defined(_PC_LINK_MAX)
+# if defined(HAVE_CONST__PC_LINK_MAX)
+# define _PC_LINK_MAX _PC_LINK_MAX
+# endif
+#endif
+#if !defined(_PC_MAX_CANON)
+# if defined(HAVE_CONST__PC_MAX_CANON)
+# define _PC_MAX_CANON _PC_MAX_CANON
+# endif
+#endif
+#if !defined(_PC_MAX_INPUT)
+# if defined(HAVE_CONST__PC_MAX_INPUT)
+# define _PC_MAX_INPUT _PC_MAX_INPUT
+# endif
+#endif
+#if !defined(_PC_NAME_MAX)
+# if defined(HAVE_CONST__PC_NAME_MAX)
+# define _PC_NAME_MAX _PC_NAME_MAX
+# endif
+#endif
+#if !defined(_PC_PATH_MAX)
+# if defined(HAVE_CONST__PC_PATH_MAX)
+# define _PC_PATH_MAX _PC_PATH_MAX
+# endif
+#endif
+#if !defined(_PC_PIPE_BUF)
+# if defined(HAVE_CONST__PC_PIPE_BUF)
+# define _PC_PIPE_BUF _PC_PIPE_BUF
+# endif
+#endif
+#if !defined(_PC_2_SYMLINKS)
+# if defined(HAVE_CONST__PC_2_SYMLINKS)
+# define _PC_2_SYMLINKS _PC_2_SYMLINKS
+# endif
+#endif
+#if !defined(_PC_ALLOC_SIZE_MIN)
+# if defined(HAVE_CONST__PC_ALLOC_SIZE_MIN)
+# define _PC_ALLOC_SIZE_MIN _PC_ALLOC_SIZE_MIN
+# endif
+#endif
+#if !defined(_PC_REC_INCR_XFER_SIZE)
+# if defined(HAVE_CONST__PC_REC_INCR_XFER_SIZE)
+# define _PC_REC_INCR_XFER_SIZE _PC_REC_INCR_XFER_SIZE
+# endif
+#endif
+#if !defined(_PC_REC_MAX_XFER_SIZE)
+# if defined(HAVE_CONST__PC_REC_MAX_XFER_SIZE)
+# define _PC_REC_MAX_XFER_SIZE _PC_REC_MAX_XFER_SIZE
+# endif
+#endif
+#if !defined(_PC_REC_MIN_XFER_SIZE)
+# if defined(HAVE_CONST__PC_REC_MIN_XFER_SIZE)
+# define _PC_REC_MIN_XFER_SIZE _PC_REC_MIN_XFER_SIZE
+# endif
+#endif
+#if !defined(_PC_REC_XFER_ALIGN)
+# if defined(HAVE_CONST__PC_REC_XFER_ALIGN)
+# define _PC_REC_XFER_ALIGN _PC_REC_XFER_ALIGN
+# endif
+#endif
+#if !defined(_PC_SYMLINK_MAX)
+# if defined(HAVE_CONST__PC_SYMLINK_MAX)
+# define _PC_SYMLINK_MAX _PC_SYMLINK_MAX
+# endif
+#endif
+#if !defined(_PC_CHOWN_RESTRICTED)
+# if defined(HAVE_CONST__PC_CHOWN_RESTRICTED)
+# define _PC_CHOWN_RESTRICTED _PC_CHOWN_RESTRICTED
+# endif
+#endif
+#if !defined(_PC_NO_TRUNC)
+# if defined(HAVE_CONST__PC_NO_TRUNC)
+# define _PC_NO_TRUNC _PC_NO_TRUNC
+# endif
+#endif
+#if !defined(_PC_VDISABLE)
+# if defined(HAVE_CONST__PC_VDISABLE)
+# define _PC_VDISABLE _PC_VDISABLE
+# endif
+#endif
+#if !defined(_PC_ASYNC_IO)
+# if defined(HAVE_CONST__PC_ASYNC_IO)
+# define _PC_ASYNC_IO _PC_ASYNC_IO
+# endif
+#endif
+#if !defined(_PC_PRIO_IO)
+# if defined(HAVE_CONST__PC_PRIO_IO)
+# define _PC_PRIO_IO _PC_PRIO_IO
+# endif
+#endif
+#if !defined(_PC_SYNC_IO)
+# if defined(HAVE_CONST__PC_SYNC_IO)
+# define _PC_SYNC_IO _PC_SYNC_IO
+# endif
+#endif
+#if !defined(_PC_TIMESTAMP_RESOLUTION)
+# if defined(HAVE_CONST__PC_TIMESTAMP_RESOLUTION)
+# define _PC_TIMESTAMP_RESOLUTION _PC_TIMESTAMP_RESOLUTION
+# endif
+#endif
+
+/* autogenerated file */
+
+#ifdef HAVE_LONG_LONG
+#define INTEGER2NUM(n) \
+ (FIXNUM_MAX < (n) ? ULL2NUM(n) : \
+ FIXNUM_MIN > (LONG_LONG)(n) ? LL2NUM(n) : \
+ LONG2FIX(n))
+#else
+#define INTEGER2NUM(n) \
+ (FIXNUM_MAX < (n) ? ULONG2NUM(n) : \
+ FIXNUM_MIN > (long)(n) ? LONG2NUM(n) : \
+ LONG2FIX(n))
+#endif
+
+static void
+init_constants(VALUE mod)
+{
+#if defined(_SC_AIO_LISTIO_MAX)
+ rb_define_const(mod, "SC_AIO_LISTIO_MAX", INTEGER2NUM(_SC_AIO_LISTIO_MAX));
+#endif
+#if defined(_SC_AIO_MAX)
+ rb_define_const(mod, "SC_AIO_MAX", INTEGER2NUM(_SC_AIO_MAX));
+#endif
+#if defined(_SC_AIO_PRIO_DELTA_MAX)
+ rb_define_const(mod, "SC_AIO_PRIO_DELTA_MAX", INTEGER2NUM(_SC_AIO_PRIO_DELTA_MAX));
+#endif
+#if defined(_SC_ARG_MAX)
+ rb_define_const(mod, "SC_ARG_MAX", INTEGER2NUM(_SC_ARG_MAX));
+#endif
+#if defined(_SC_ATEXIT_MAX)
+ rb_define_const(mod, "SC_ATEXIT_MAX", INTEGER2NUM(_SC_ATEXIT_MAX));
+#endif
+#if defined(_SC_BC_BASE_MAX)
+ rb_define_const(mod, "SC_BC_BASE_MAX", INTEGER2NUM(_SC_BC_BASE_MAX));
+#endif
+#if defined(_SC_BC_DIM_MAX)
+ rb_define_const(mod, "SC_BC_DIM_MAX", INTEGER2NUM(_SC_BC_DIM_MAX));
+#endif
+#if defined(_SC_BC_SCALE_MAX)
+ rb_define_const(mod, "SC_BC_SCALE_MAX", INTEGER2NUM(_SC_BC_SCALE_MAX));
+#endif
+#if defined(_SC_BC_STRING_MAX)
+ rb_define_const(mod, "SC_BC_STRING_MAX", INTEGER2NUM(_SC_BC_STRING_MAX));
+#endif
+#if defined(_SC_CHILD_MAX)
+ rb_define_const(mod, "SC_CHILD_MAX", INTEGER2NUM(_SC_CHILD_MAX));
+#endif
+#if defined(_SC_CLK_TCK)
+ rb_define_const(mod, "SC_CLK_TCK", INTEGER2NUM(_SC_CLK_TCK));
+#endif
+#if defined(_SC_COLL_WEIGHTS_MAX)
+ rb_define_const(mod, "SC_COLL_WEIGHTS_MAX", INTEGER2NUM(_SC_COLL_WEIGHTS_MAX));
+#endif
+#if defined(_SC_DELAYTIMER_MAX)
+ rb_define_const(mod, "SC_DELAYTIMER_MAX", INTEGER2NUM(_SC_DELAYTIMER_MAX));
+#endif
+#if defined(_SC_EXPR_NEST_MAX)
+ rb_define_const(mod, "SC_EXPR_NEST_MAX", INTEGER2NUM(_SC_EXPR_NEST_MAX));
+#endif
+#if defined(_SC_HOST_NAME_MAX)
+ rb_define_const(mod, "SC_HOST_NAME_MAX", INTEGER2NUM(_SC_HOST_NAME_MAX));
+#endif
+#if defined(_SC_IOV_MAX)
+ rb_define_const(mod, "SC_IOV_MAX", INTEGER2NUM(_SC_IOV_MAX));
+#endif
+#if defined(_SC_LINE_MAX)
+ rb_define_const(mod, "SC_LINE_MAX", INTEGER2NUM(_SC_LINE_MAX));
+#endif
+#if defined(_SC_LOGIN_NAME_MAX)
+ rb_define_const(mod, "SC_LOGIN_NAME_MAX", INTEGER2NUM(_SC_LOGIN_NAME_MAX));
+#endif
+#if defined(_SC_NGROUPS_MAX)
+ rb_define_const(mod, "SC_NGROUPS_MAX", INTEGER2NUM(_SC_NGROUPS_MAX));
+#endif
+#if defined(_SC_GETGR_R_SIZE_MAX)
+ rb_define_const(mod, "SC_GETGR_R_SIZE_MAX", INTEGER2NUM(_SC_GETGR_R_SIZE_MAX));
+#endif
+#if defined(_SC_GETPW_R_SIZE_MAX)
+ rb_define_const(mod, "SC_GETPW_R_SIZE_MAX", INTEGER2NUM(_SC_GETPW_R_SIZE_MAX));
+#endif
+#if defined(_SC_MQ_OPEN_MAX)
+ rb_define_const(mod, "SC_MQ_OPEN_MAX", INTEGER2NUM(_SC_MQ_OPEN_MAX));
+#endif
+#if defined(_SC_MQ_PRIO_MAX)
+ rb_define_const(mod, "SC_MQ_PRIO_MAX", INTEGER2NUM(_SC_MQ_PRIO_MAX));
+#endif
+#if defined(_SC_OPEN_MAX)
+ rb_define_const(mod, "SC_OPEN_MAX", INTEGER2NUM(_SC_OPEN_MAX));
+#endif
+#if defined(_SC_ADVISORY_INFO)
+ rb_define_const(mod, "SC_ADVISORY_INFO", INTEGER2NUM(_SC_ADVISORY_INFO));
+#endif
+#if defined(_SC_BARRIERS)
+ rb_define_const(mod, "SC_BARRIERS", INTEGER2NUM(_SC_BARRIERS));
+#endif
+#if defined(_SC_ASYNCHRONOUS_IO)
+ rb_define_const(mod, "SC_ASYNCHRONOUS_IO", INTEGER2NUM(_SC_ASYNCHRONOUS_IO));
+#endif
+#if defined(_SC_CLOCK_SELECTION)
+ rb_define_const(mod, "SC_CLOCK_SELECTION", INTEGER2NUM(_SC_CLOCK_SELECTION));
+#endif
+#if defined(_SC_CPUTIME)
+ rb_define_const(mod, "SC_CPUTIME", INTEGER2NUM(_SC_CPUTIME));
+#endif
+#if defined(_SC_FSYNC)
+ rb_define_const(mod, "SC_FSYNC", INTEGER2NUM(_SC_FSYNC));
+#endif
+#if defined(_SC_IPV6)
+ rb_define_const(mod, "SC_IPV6", INTEGER2NUM(_SC_IPV6));
+#endif
+#if defined(_SC_JOB_CONTROL)
+ rb_define_const(mod, "SC_JOB_CONTROL", INTEGER2NUM(_SC_JOB_CONTROL));
+#endif
+#if defined(_SC_MAPPED_FILES)
+ rb_define_const(mod, "SC_MAPPED_FILES", INTEGER2NUM(_SC_MAPPED_FILES));
+#endif
+#if defined(_SC_MEMLOCK)
+ rb_define_const(mod, "SC_MEMLOCK", INTEGER2NUM(_SC_MEMLOCK));
+#endif
+#if defined(_SC_MEMLOCK_RANGE)
+ rb_define_const(mod, "SC_MEMLOCK_RANGE", INTEGER2NUM(_SC_MEMLOCK_RANGE));
+#endif
+#if defined(_SC_MEMORY_PROTECTION)
+ rb_define_const(mod, "SC_MEMORY_PROTECTION", INTEGER2NUM(_SC_MEMORY_PROTECTION));
+#endif
+#if defined(_SC_MESSAGE_PASSING)
+ rb_define_const(mod, "SC_MESSAGE_PASSING", INTEGER2NUM(_SC_MESSAGE_PASSING));
+#endif
+#if defined(_SC_MONOTONIC_CLOCK)
+ rb_define_const(mod, "SC_MONOTONIC_CLOCK", INTEGER2NUM(_SC_MONOTONIC_CLOCK));
+#endif
+#if defined(_SC_PRIORITIZED_IO)
+ rb_define_const(mod, "SC_PRIORITIZED_IO", INTEGER2NUM(_SC_PRIORITIZED_IO));
+#endif
+#if defined(_SC_PRIORITY_SCHEDULING)
+ rb_define_const(mod, "SC_PRIORITY_SCHEDULING", INTEGER2NUM(_SC_PRIORITY_SCHEDULING));
+#endif
+#if defined(_SC_RAW_SOCKETS)
+ rb_define_const(mod, "SC_RAW_SOCKETS", INTEGER2NUM(_SC_RAW_SOCKETS));
+#endif
+#if defined(_SC_READER_WRITER_LOCKS)
+ rb_define_const(mod, "SC_READER_WRITER_LOCKS", INTEGER2NUM(_SC_READER_WRITER_LOCKS));
+#endif
+#if defined(_SC_REALTIME_SIGNALS)
+ rb_define_const(mod, "SC_REALTIME_SIGNALS", INTEGER2NUM(_SC_REALTIME_SIGNALS));
+#endif
+#if defined(_SC_REGEXP)
+ rb_define_const(mod, "SC_REGEXP", INTEGER2NUM(_SC_REGEXP));
+#endif
+#if defined(_SC_SAVED_IDS)
+ rb_define_const(mod, "SC_SAVED_IDS", INTEGER2NUM(_SC_SAVED_IDS));
+#endif
+#if defined(_SC_SEMAPHORES)
+ rb_define_const(mod, "SC_SEMAPHORES", INTEGER2NUM(_SC_SEMAPHORES));
+#endif
+#if defined(_SC_SHARED_MEMORY_OBJECTS)
+ rb_define_const(mod, "SC_SHARED_MEMORY_OBJECTS", INTEGER2NUM(_SC_SHARED_MEMORY_OBJECTS));
+#endif
+#if defined(_SC_SHELL)
+ rb_define_const(mod, "SC_SHELL", INTEGER2NUM(_SC_SHELL));
+#endif
+#if defined(_SC_SPAWN)
+ rb_define_const(mod, "SC_SPAWN", INTEGER2NUM(_SC_SPAWN));
+#endif
+#if defined(_SC_SPIN_LOCKS)
+ rb_define_const(mod, "SC_SPIN_LOCKS", INTEGER2NUM(_SC_SPIN_LOCKS));
+#endif
+#if defined(_SC_SPORADIC_SERVER)
+ rb_define_const(mod, "SC_SPORADIC_SERVER", INTEGER2NUM(_SC_SPORADIC_SERVER));
+#endif
+#if defined(_SC_SS_REPL_MAX)
+ rb_define_const(mod, "SC_SS_REPL_MAX", INTEGER2NUM(_SC_SS_REPL_MAX));
+#endif
+#if defined(_SC_SYNCHRONIZED_IO)
+ rb_define_const(mod, "SC_SYNCHRONIZED_IO", INTEGER2NUM(_SC_SYNCHRONIZED_IO));
+#endif
+#if defined(_SC_THREAD_ATTR_STACKADDR)
+ rb_define_const(mod, "SC_THREAD_ATTR_STACKADDR", INTEGER2NUM(_SC_THREAD_ATTR_STACKADDR));
+#endif
+#if defined(_SC_THREAD_ATTR_STACKSIZE)
+ rb_define_const(mod, "SC_THREAD_ATTR_STACKSIZE", INTEGER2NUM(_SC_THREAD_ATTR_STACKSIZE));
+#endif
+#if defined(_SC_THREAD_CPUTIME)
+ rb_define_const(mod, "SC_THREAD_CPUTIME", INTEGER2NUM(_SC_THREAD_CPUTIME));
+#endif
+#if defined(_SC_THREAD_PRIO_INHERIT)
+ rb_define_const(mod, "SC_THREAD_PRIO_INHERIT", INTEGER2NUM(_SC_THREAD_PRIO_INHERIT));
+#endif
+#if defined(_SC_THREAD_PRIO_PROTECT)
+ rb_define_const(mod, "SC_THREAD_PRIO_PROTECT", INTEGER2NUM(_SC_THREAD_PRIO_PROTECT));
+#endif
+#if defined(_SC_THREAD_PRIORITY_SCHEDULING)
+ rb_define_const(mod, "SC_THREAD_PRIORITY_SCHEDULING", INTEGER2NUM(_SC_THREAD_PRIORITY_SCHEDULING));
+#endif
+#if defined(_SC_THREAD_PROCESS_SHARED)
+ rb_define_const(mod, "SC_THREAD_PROCESS_SHARED", INTEGER2NUM(_SC_THREAD_PROCESS_SHARED));
+#endif
+#if defined(_SC_THREAD_ROBUST_PRIO_INHERIT)
+ rb_define_const(mod, "SC_THREAD_ROBUST_PRIO_INHERIT", INTEGER2NUM(_SC_THREAD_ROBUST_PRIO_INHERIT));
+#endif
+#if defined(_SC_THREAD_ROBUST_PRIO_PROTECT)
+ rb_define_const(mod, "SC_THREAD_ROBUST_PRIO_PROTECT", INTEGER2NUM(_SC_THREAD_ROBUST_PRIO_PROTECT));
+#endif
+#if defined(_SC_THREAD_SAFE_FUNCTIONS)
+ rb_define_const(mod, "SC_THREAD_SAFE_FUNCTIONS", INTEGER2NUM(_SC_THREAD_SAFE_FUNCTIONS));
+#endif
+#if defined(_SC_THREAD_SPORADIC_SERVER)
+ rb_define_const(mod, "SC_THREAD_SPORADIC_SERVER", INTEGER2NUM(_SC_THREAD_SPORADIC_SERVER));
+#endif
+#if defined(_SC_THREADS)
+ rb_define_const(mod, "SC_THREADS", INTEGER2NUM(_SC_THREADS));
+#endif
+#if defined(_SC_TIMEOUTS)
+ rb_define_const(mod, "SC_TIMEOUTS", INTEGER2NUM(_SC_TIMEOUTS));
+#endif
+#if defined(_SC_TIMERS)
+ rb_define_const(mod, "SC_TIMERS", INTEGER2NUM(_SC_TIMERS));
+#endif
+#if defined(_SC_TRACE)
+ rb_define_const(mod, "SC_TRACE", INTEGER2NUM(_SC_TRACE));
+#endif
+#if defined(_SC_TRACE_EVENT_FILTER)
+ rb_define_const(mod, "SC_TRACE_EVENT_FILTER", INTEGER2NUM(_SC_TRACE_EVENT_FILTER));
+#endif
+#if defined(_SC_TRACE_EVENT_NAME_MAX)
+ rb_define_const(mod, "SC_TRACE_EVENT_NAME_MAX", INTEGER2NUM(_SC_TRACE_EVENT_NAME_MAX));
+#endif
+#if defined(_SC_TRACE_INHERIT)
+ rb_define_const(mod, "SC_TRACE_INHERIT", INTEGER2NUM(_SC_TRACE_INHERIT));
+#endif
+#if defined(_SC_TRACE_LOG)
+ rb_define_const(mod, "SC_TRACE_LOG", INTEGER2NUM(_SC_TRACE_LOG));
+#endif
+#if defined(_SC_TRACE_NAME_MAX)
+ rb_define_const(mod, "SC_TRACE_NAME_MAX", INTEGER2NUM(_SC_TRACE_NAME_MAX));
+#endif
+#if defined(_SC_TRACE_SYS_MAX)
+ rb_define_const(mod, "SC_TRACE_SYS_MAX", INTEGER2NUM(_SC_TRACE_SYS_MAX));
+#endif
+#if defined(_SC_TRACE_USER_EVENT_MAX)
+ rb_define_const(mod, "SC_TRACE_USER_EVENT_MAX", INTEGER2NUM(_SC_TRACE_USER_EVENT_MAX));
+#endif
+#if defined(_SC_TYPED_MEMORY_OBJECTS)
+ rb_define_const(mod, "SC_TYPED_MEMORY_OBJECTS", INTEGER2NUM(_SC_TYPED_MEMORY_OBJECTS));
+#endif
+#if defined(_SC_VERSION)
+ rb_define_const(mod, "SC_VERSION", INTEGER2NUM(_SC_VERSION));
+#endif
+#if defined(_SC_V7_ILP32_OFF32)
+ rb_define_const(mod, "SC_V7_ILP32_OFF32", INTEGER2NUM(_SC_V7_ILP32_OFF32));
+#endif
+#if defined(_SC_V7_ILP32_OFFBIG)
+ rb_define_const(mod, "SC_V7_ILP32_OFFBIG", INTEGER2NUM(_SC_V7_ILP32_OFFBIG));
+#endif
+#if defined(_SC_V7_LP64_OFF64)
+ rb_define_const(mod, "SC_V7_LP64_OFF64", INTEGER2NUM(_SC_V7_LP64_OFF64));
+#endif
+#if defined(_SC_V7_LPBIG_OFFBIG)
+ rb_define_const(mod, "SC_V7_LPBIG_OFFBIG", INTEGER2NUM(_SC_V7_LPBIG_OFFBIG));
+#endif
+#if defined(_SC_V6_ILP32_OFF32)
+ rb_define_const(mod, "SC_V6_ILP32_OFF32", INTEGER2NUM(_SC_V6_ILP32_OFF32));
+#endif
+#if defined(_SC_V6_ILP32_OFFBIG)
+ rb_define_const(mod, "SC_V6_ILP32_OFFBIG", INTEGER2NUM(_SC_V6_ILP32_OFFBIG));
+#endif
+#if defined(_SC_V6_LP64_OFF64)
+ rb_define_const(mod, "SC_V6_LP64_OFF64", INTEGER2NUM(_SC_V6_LP64_OFF64));
+#endif
+#if defined(_SC_V6_LPBIG_OFFBIG)
+ rb_define_const(mod, "SC_V6_LPBIG_OFFBIG", INTEGER2NUM(_SC_V6_LPBIG_OFFBIG));
+#endif
+#if defined(_SC_2_C_BIND)
+ rb_define_const(mod, "SC_2_C_BIND", INTEGER2NUM(_SC_2_C_BIND));
+#endif
+#if defined(_SC_2_C_DEV)
+ rb_define_const(mod, "SC_2_C_DEV", INTEGER2NUM(_SC_2_C_DEV));
+#endif
+#if defined(_SC_2_CHAR_TERM)
+ rb_define_const(mod, "SC_2_CHAR_TERM", INTEGER2NUM(_SC_2_CHAR_TERM));
+#endif
+#if defined(_SC_2_FORT_DEV)
+ rb_define_const(mod, "SC_2_FORT_DEV", INTEGER2NUM(_SC_2_FORT_DEV));
+#endif
+#if defined(_SC_2_FORT_RUN)
+ rb_define_const(mod, "SC_2_FORT_RUN", INTEGER2NUM(_SC_2_FORT_RUN));
+#endif
+#if defined(_SC_2_LOCALEDEF)
+ rb_define_const(mod, "SC_2_LOCALEDEF", INTEGER2NUM(_SC_2_LOCALEDEF));
+#endif
+#if defined(_SC_2_PBS)
+ rb_define_const(mod, "SC_2_PBS", INTEGER2NUM(_SC_2_PBS));
+#endif
+#if defined(_SC_2_PBS_ACCOUNTING)
+ rb_define_const(mod, "SC_2_PBS_ACCOUNTING", INTEGER2NUM(_SC_2_PBS_ACCOUNTING));
+#endif
+#if defined(_SC_2_PBS_CHECKPOINT)
+ rb_define_const(mod, "SC_2_PBS_CHECKPOINT", INTEGER2NUM(_SC_2_PBS_CHECKPOINT));
+#endif
+#if defined(_SC_2_PBS_LOCATE)
+ rb_define_const(mod, "SC_2_PBS_LOCATE", INTEGER2NUM(_SC_2_PBS_LOCATE));
+#endif
+#if defined(_SC_2_PBS_MESSAGE)
+ rb_define_const(mod, "SC_2_PBS_MESSAGE", INTEGER2NUM(_SC_2_PBS_MESSAGE));
+#endif
+#if defined(_SC_2_PBS_TRACK)
+ rb_define_const(mod, "SC_2_PBS_TRACK", INTEGER2NUM(_SC_2_PBS_TRACK));
+#endif
+#if defined(_SC_2_SW_DEV)
+ rb_define_const(mod, "SC_2_SW_DEV", INTEGER2NUM(_SC_2_SW_DEV));
+#endif
+#if defined(_SC_2_UPE)
+ rb_define_const(mod, "SC_2_UPE", INTEGER2NUM(_SC_2_UPE));
+#endif
+#if defined(_SC_2_VERSION)
+ rb_define_const(mod, "SC_2_VERSION", INTEGER2NUM(_SC_2_VERSION));
+#endif
+#if defined(_SC_PAGE_SIZE)
+ rb_define_const(mod, "SC_PAGE_SIZE", INTEGER2NUM(_SC_PAGE_SIZE));
+#endif
+#if defined(_SC_PAGESIZE)
+ rb_define_const(mod, "SC_PAGESIZE", INTEGER2NUM(_SC_PAGESIZE));
+#endif
+#if defined(_SC_THREAD_DESTRUCTOR_ITERATIONS)
+ rb_define_const(mod, "SC_THREAD_DESTRUCTOR_ITERATIONS", INTEGER2NUM(_SC_THREAD_DESTRUCTOR_ITERATIONS));
+#endif
+#if defined(_SC_THREAD_KEYS_MAX)
+ rb_define_const(mod, "SC_THREAD_KEYS_MAX", INTEGER2NUM(_SC_THREAD_KEYS_MAX));
+#endif
+#if defined(_SC_THREAD_STACK_MIN)
+ rb_define_const(mod, "SC_THREAD_STACK_MIN", INTEGER2NUM(_SC_THREAD_STACK_MIN));
+#endif
+#if defined(_SC_THREAD_THREADS_MAX)
+ rb_define_const(mod, "SC_THREAD_THREADS_MAX", INTEGER2NUM(_SC_THREAD_THREADS_MAX));
+#endif
+#if defined(_SC_RE_DUP_MAX)
+ rb_define_const(mod, "SC_RE_DUP_MAX", INTEGER2NUM(_SC_RE_DUP_MAX));
+#endif
+#if defined(_SC_RTSIG_MAX)
+ rb_define_const(mod, "SC_RTSIG_MAX", INTEGER2NUM(_SC_RTSIG_MAX));
+#endif
+#if defined(_SC_SEM_NSEMS_MAX)
+ rb_define_const(mod, "SC_SEM_NSEMS_MAX", INTEGER2NUM(_SC_SEM_NSEMS_MAX));
+#endif
+#if defined(_SC_SEM_VALUE_MAX)
+ rb_define_const(mod, "SC_SEM_VALUE_MAX", INTEGER2NUM(_SC_SEM_VALUE_MAX));
+#endif
+#if defined(_SC_SIGQUEUE_MAX)
+ rb_define_const(mod, "SC_SIGQUEUE_MAX", INTEGER2NUM(_SC_SIGQUEUE_MAX));
+#endif
+#if defined(_SC_STREAM_MAX)
+ rb_define_const(mod, "SC_STREAM_MAX", INTEGER2NUM(_SC_STREAM_MAX));
+#endif
+#if defined(_SC_SYMLOOP_MAX)
+ rb_define_const(mod, "SC_SYMLOOP_MAX", INTEGER2NUM(_SC_SYMLOOP_MAX));
+#endif
+#if defined(_SC_TIMER_MAX)
+ rb_define_const(mod, "SC_TIMER_MAX", INTEGER2NUM(_SC_TIMER_MAX));
+#endif
+#if defined(_SC_TTY_NAME_MAX)
+ rb_define_const(mod, "SC_TTY_NAME_MAX", INTEGER2NUM(_SC_TTY_NAME_MAX));
+#endif
+#if defined(_SC_TZNAME_MAX)
+ rb_define_const(mod, "SC_TZNAME_MAX", INTEGER2NUM(_SC_TZNAME_MAX));
+#endif
+#if defined(_SC_XOPEN_CRYPT)
+ rb_define_const(mod, "SC_XOPEN_CRYPT", INTEGER2NUM(_SC_XOPEN_CRYPT));
+#endif
+#if defined(_SC_XOPEN_ENH_I18N)
+ rb_define_const(mod, "SC_XOPEN_ENH_I18N", INTEGER2NUM(_SC_XOPEN_ENH_I18N));
+#endif
+#if defined(_SC_XOPEN_REALTIME)
+ rb_define_const(mod, "SC_XOPEN_REALTIME", INTEGER2NUM(_SC_XOPEN_REALTIME));
+#endif
+#if defined(_SC_XOPEN_REALTIME_THREADS)
+ rb_define_const(mod, "SC_XOPEN_REALTIME_THREADS", INTEGER2NUM(_SC_XOPEN_REALTIME_THREADS));
+#endif
+#if defined(_SC_XOPEN_SHM)
+ rb_define_const(mod, "SC_XOPEN_SHM", INTEGER2NUM(_SC_XOPEN_SHM));
+#endif
+#if defined(_SC_XOPEN_STREAMS)
+ rb_define_const(mod, "SC_XOPEN_STREAMS", INTEGER2NUM(_SC_XOPEN_STREAMS));
+#endif
+#if defined(_SC_XOPEN_UNIX)
+ rb_define_const(mod, "SC_XOPEN_UNIX", INTEGER2NUM(_SC_XOPEN_UNIX));
+#endif
+#if defined(_SC_XOPEN_UUCP)
+ rb_define_const(mod, "SC_XOPEN_UUCP", INTEGER2NUM(_SC_XOPEN_UUCP));
+#endif
+#if defined(_SC_XOPEN_VERSION)
+ rb_define_const(mod, "SC_XOPEN_VERSION", INTEGER2NUM(_SC_XOPEN_VERSION));
+#endif
+#if defined(_SC_PHYS_PAGES)
+ rb_define_const(mod, "SC_PHYS_PAGES", INTEGER2NUM(_SC_PHYS_PAGES));
+#endif
+#if defined(_SC_AVPHYS_PAGES)
+ rb_define_const(mod, "SC_AVPHYS_PAGES", INTEGER2NUM(_SC_AVPHYS_PAGES));
+#endif
+#if defined(_SC_NPROCESSORS_CONF)
+ rb_define_const(mod, "SC_NPROCESSORS_CONF", INTEGER2NUM(_SC_NPROCESSORS_CONF));
+#endif
+#if defined(_SC_NPROCESSORS_ONLN)
+ rb_define_const(mod, "SC_NPROCESSORS_ONLN", INTEGER2NUM(_SC_NPROCESSORS_ONLN));
+#endif
+#if defined(_SC_CPUSET_SIZE)
+ rb_define_const(mod, "SC_CPUSET_SIZE", INTEGER2NUM(_SC_CPUSET_SIZE));
+#endif
+#if defined(_CS_PATH)
+ rb_define_const(mod, "CS_PATH", INTEGER2NUM(_CS_PATH));
+#endif
+#if defined(_CS_POSIX_V7_ILP32_OFF32_CFLAGS)
+ rb_define_const(mod, "CS_POSIX_V7_ILP32_OFF32_CFLAGS", INTEGER2NUM(_CS_POSIX_V7_ILP32_OFF32_CFLAGS));
+#endif
+#if defined(_CS_POSIX_V7_ILP32_OFF32_LDFLAGS)
+ rb_define_const(mod, "CS_POSIX_V7_ILP32_OFF32_LDFLAGS", INTEGER2NUM(_CS_POSIX_V7_ILP32_OFF32_LDFLAGS));
+#endif
+#if defined(_CS_POSIX_V7_ILP32_OFF32_LIBS)
+ rb_define_const(mod, "CS_POSIX_V7_ILP32_OFF32_LIBS", INTEGER2NUM(_CS_POSIX_V7_ILP32_OFF32_LIBS));
+#endif
+#if defined(_CS_POSIX_V7_ILP32_OFFBIG_CFLAGS)
+ rb_define_const(mod, "CS_POSIX_V7_ILP32_OFFBIG_CFLAGS", INTEGER2NUM(_CS_POSIX_V7_ILP32_OFFBIG_CFLAGS));
+#endif
+#if defined(_CS_POSIX_V7_ILP32_OFFBIG_LDFLAGS)
+ rb_define_const(mod, "CS_POSIX_V7_ILP32_OFFBIG_LDFLAGS", INTEGER2NUM(_CS_POSIX_V7_ILP32_OFFBIG_LDFLAGS));
+#endif
+#if defined(_CS_POSIX_V7_ILP32_OFFBIG_LIBS)
+ rb_define_const(mod, "CS_POSIX_V7_ILP32_OFFBIG_LIBS", INTEGER2NUM(_CS_POSIX_V7_ILP32_OFFBIG_LIBS));
+#endif
+#if defined(_CS_POSIX_V7_LP64_OFF64_CFLAGS)
+ rb_define_const(mod, "CS_POSIX_V7_LP64_OFF64_CFLAGS", INTEGER2NUM(_CS_POSIX_V7_LP64_OFF64_CFLAGS));
+#endif
+#if defined(_CS_POSIX_V7_LP64_OFF64_LDFLAGS)
+ rb_define_const(mod, "CS_POSIX_V7_LP64_OFF64_LDFLAGS", INTEGER2NUM(_CS_POSIX_V7_LP64_OFF64_LDFLAGS));
+#endif
+#if defined(_CS_POSIX_V7_LP64_OFF64_LIBS)
+ rb_define_const(mod, "CS_POSIX_V7_LP64_OFF64_LIBS", INTEGER2NUM(_CS_POSIX_V7_LP64_OFF64_LIBS));
+#endif
+#if defined(_CS_POSIX_V7_LPBIG_OFFBIG_CFLAGS)
+ rb_define_const(mod, "CS_POSIX_V7_LPBIG_OFFBIG_CFLAGS", INTEGER2NUM(_CS_POSIX_V7_LPBIG_OFFBIG_CFLAGS));
+#endif
+#if defined(_CS_POSIX_V7_LPBIG_OFFBIG_LDFLAGS)
+ rb_define_const(mod, "CS_POSIX_V7_LPBIG_OFFBIG_LDFLAGS", INTEGER2NUM(_CS_POSIX_V7_LPBIG_OFFBIG_LDFLAGS));
+#endif
+#if defined(_CS_POSIX_V7_LPBIG_OFFBIG_LIBS)
+ rb_define_const(mod, "CS_POSIX_V7_LPBIG_OFFBIG_LIBS", INTEGER2NUM(_CS_POSIX_V7_LPBIG_OFFBIG_LIBS));
+#endif
+#if defined(_CS_POSIX_V7_THREADS_CFLAGS)
+ rb_define_const(mod, "CS_POSIX_V7_THREADS_CFLAGS", INTEGER2NUM(_CS_POSIX_V7_THREADS_CFLAGS));
+#endif
+#if defined(_CS_POSIX_V7_THREADS_LDFLAGS)
+ rb_define_const(mod, "CS_POSIX_V7_THREADS_LDFLAGS", INTEGER2NUM(_CS_POSIX_V7_THREADS_LDFLAGS));
+#endif
+#if defined(_CS_POSIX_V7_WIDTH_RESTRICTED_ENVS)
+ rb_define_const(mod, "CS_POSIX_V7_WIDTH_RESTRICTED_ENVS", INTEGER2NUM(_CS_POSIX_V7_WIDTH_RESTRICTED_ENVS));
+#endif
+#if defined(_CS_V7_ENV)
+ rb_define_const(mod, "CS_V7_ENV", INTEGER2NUM(_CS_V7_ENV));
+#endif
+#if defined(_CS_POSIX_V6_ILP32_OFF32_CFLAGS)
+ rb_define_const(mod, "CS_POSIX_V6_ILP32_OFF32_CFLAGS", INTEGER2NUM(_CS_POSIX_V6_ILP32_OFF32_CFLAGS));
+#endif
+#if defined(_CS_POSIX_V6_ILP32_OFF32_LDFLAGS)
+ rb_define_const(mod, "CS_POSIX_V6_ILP32_OFF32_LDFLAGS", INTEGER2NUM(_CS_POSIX_V6_ILP32_OFF32_LDFLAGS));
+#endif
+#if defined(_CS_POSIX_V6_ILP32_OFF32_LIBS)
+ rb_define_const(mod, "CS_POSIX_V6_ILP32_OFF32_LIBS", INTEGER2NUM(_CS_POSIX_V6_ILP32_OFF32_LIBS));
+#endif
+#if defined(_CS_POSIX_V6_ILP32_OFFBIG_CFLAGS)
+ rb_define_const(mod, "CS_POSIX_V6_ILP32_OFFBIG_CFLAGS", INTEGER2NUM(_CS_POSIX_V6_ILP32_OFFBIG_CFLAGS));
+#endif
+#if defined(_CS_POSIX_V6_ILP32_OFFBIG_LDFLAGS)
+ rb_define_const(mod, "CS_POSIX_V6_ILP32_OFFBIG_LDFLAGS", INTEGER2NUM(_CS_POSIX_V6_ILP32_OFFBIG_LDFLAGS));
+#endif
+#if defined(_CS_POSIX_V6_ILP32_OFFBIG_LIBS)
+ rb_define_const(mod, "CS_POSIX_V6_ILP32_OFFBIG_LIBS", INTEGER2NUM(_CS_POSIX_V6_ILP32_OFFBIG_LIBS));
+#endif
+#if defined(_CS_POSIX_V6_LP64_OFF64_CFLAGS)
+ rb_define_const(mod, "CS_POSIX_V6_LP64_OFF64_CFLAGS", INTEGER2NUM(_CS_POSIX_V6_LP64_OFF64_CFLAGS));
+#endif
+#if defined(_CS_POSIX_V6_LP64_OFF64_LDFLAGS)
+ rb_define_const(mod, "CS_POSIX_V6_LP64_OFF64_LDFLAGS", INTEGER2NUM(_CS_POSIX_V6_LP64_OFF64_LDFLAGS));
+#endif
+#if defined(_CS_POSIX_V6_LP64_OFF64_LIBS)
+ rb_define_const(mod, "CS_POSIX_V6_LP64_OFF64_LIBS", INTEGER2NUM(_CS_POSIX_V6_LP64_OFF64_LIBS));
+#endif
+#if defined(_CS_POSIX_V6_LPBIG_OFFBIG_CFLAGS)
+ rb_define_const(mod, "CS_POSIX_V6_LPBIG_OFFBIG_CFLAGS", INTEGER2NUM(_CS_POSIX_V6_LPBIG_OFFBIG_CFLAGS));
+#endif
+#if defined(_CS_POSIX_V6_LPBIG_OFFBIG_LDFLAGS)
+ rb_define_const(mod, "CS_POSIX_V6_LPBIG_OFFBIG_LDFLAGS", INTEGER2NUM(_CS_POSIX_V6_LPBIG_OFFBIG_LDFLAGS));
+#endif
+#if defined(_CS_POSIX_V6_LPBIG_OFFBIG_LIBS)
+ rb_define_const(mod, "CS_POSIX_V6_LPBIG_OFFBIG_LIBS", INTEGER2NUM(_CS_POSIX_V6_LPBIG_OFFBIG_LIBS));
+#endif
+#if defined(_CS_POSIX_V6_WIDTH_RESTRICTED_ENVS)
+ rb_define_const(mod, "CS_POSIX_V6_WIDTH_RESTRICTED_ENVS", INTEGER2NUM(_CS_POSIX_V6_WIDTH_RESTRICTED_ENVS));
+#endif
+#if defined(_CS_V6_ENV)
+ rb_define_const(mod, "CS_V6_ENV", INTEGER2NUM(_CS_V6_ENV));
+#endif
+#if defined(_CS_GNU_LIBC_VERSION)
+ rb_define_const(mod, "CS_GNU_LIBC_VERSION", INTEGER2NUM(_CS_GNU_LIBC_VERSION));
+#endif
+#if defined(_CS_GNU_LIBPTHREAD_VERSION)
+ rb_define_const(mod, "CS_GNU_LIBPTHREAD_VERSION", INTEGER2NUM(_CS_GNU_LIBPTHREAD_VERSION));
+#endif
+#if defined(_PC_FILESIZEBITS)
+ rb_define_const(mod, "PC_FILESIZEBITS", INTEGER2NUM(_PC_FILESIZEBITS));
+#endif
+#if defined(_PC_LINK_MAX)
+ rb_define_const(mod, "PC_LINK_MAX", INTEGER2NUM(_PC_LINK_MAX));
+#endif
+#if defined(_PC_MAX_CANON)
+ rb_define_const(mod, "PC_MAX_CANON", INTEGER2NUM(_PC_MAX_CANON));
+#endif
+#if defined(_PC_MAX_INPUT)
+ rb_define_const(mod, "PC_MAX_INPUT", INTEGER2NUM(_PC_MAX_INPUT));
+#endif
+#if defined(_PC_NAME_MAX)
+ rb_define_const(mod, "PC_NAME_MAX", INTEGER2NUM(_PC_NAME_MAX));
+#endif
+#if defined(_PC_PATH_MAX)
+ rb_define_const(mod, "PC_PATH_MAX", INTEGER2NUM(_PC_PATH_MAX));
+#endif
+#if defined(_PC_PIPE_BUF)
+ rb_define_const(mod, "PC_PIPE_BUF", INTEGER2NUM(_PC_PIPE_BUF));
+#endif
+#if defined(_PC_2_SYMLINKS)
+ rb_define_const(mod, "PC_2_SYMLINKS", INTEGER2NUM(_PC_2_SYMLINKS));
+#endif
+#if defined(_PC_ALLOC_SIZE_MIN)
+ rb_define_const(mod, "PC_ALLOC_SIZE_MIN", INTEGER2NUM(_PC_ALLOC_SIZE_MIN));
+#endif
+#if defined(_PC_REC_INCR_XFER_SIZE)
+ rb_define_const(mod, "PC_REC_INCR_XFER_SIZE", INTEGER2NUM(_PC_REC_INCR_XFER_SIZE));
+#endif
+#if defined(_PC_REC_MAX_XFER_SIZE)
+ rb_define_const(mod, "PC_REC_MAX_XFER_SIZE", INTEGER2NUM(_PC_REC_MAX_XFER_SIZE));
+#endif
+#if defined(_PC_REC_MIN_XFER_SIZE)
+ rb_define_const(mod, "PC_REC_MIN_XFER_SIZE", INTEGER2NUM(_PC_REC_MIN_XFER_SIZE));
+#endif
+#if defined(_PC_REC_XFER_ALIGN)
+ rb_define_const(mod, "PC_REC_XFER_ALIGN", INTEGER2NUM(_PC_REC_XFER_ALIGN));
+#endif
+#if defined(_PC_SYMLINK_MAX)
+ rb_define_const(mod, "PC_SYMLINK_MAX", INTEGER2NUM(_PC_SYMLINK_MAX));
+#endif
+#if defined(_PC_CHOWN_RESTRICTED)
+ rb_define_const(mod, "PC_CHOWN_RESTRICTED", INTEGER2NUM(_PC_CHOWN_RESTRICTED));
+#endif
+#if defined(_PC_NO_TRUNC)
+ rb_define_const(mod, "PC_NO_TRUNC", INTEGER2NUM(_PC_NO_TRUNC));
+#endif
+#if defined(_PC_VDISABLE)
+ rb_define_const(mod, "PC_VDISABLE", INTEGER2NUM(_PC_VDISABLE));
+#endif
+#if defined(_PC_ASYNC_IO)
+ rb_define_const(mod, "PC_ASYNC_IO", INTEGER2NUM(_PC_ASYNC_IO));
+#endif
+#if defined(_PC_PRIO_IO)
+ rb_define_const(mod, "PC_PRIO_IO", INTEGER2NUM(_PC_PRIO_IO));
+#endif
+#if defined(_PC_SYNC_IO)
+ rb_define_const(mod, "PC_SYNC_IO", INTEGER2NUM(_PC_SYNC_IO));
+#endif
+#if defined(_PC_TIMESTAMP_RESOLUTION)
+ rb_define_const(mod, "PC_TIMESTAMP_RESOLUTION", INTEGER2NUM(_PC_TIMESTAMP_RESOLUTION));
+#endif
+
+}
diff --git a/jni/ruby/ext/etc/depend b/jni/ruby/ext/etc/depend
new file mode 100644
index 0000000..a73a184
--- /dev/null
+++ b/jni/ruby/ext/etc/depend
@@ -0,0 +1,9 @@
+etc.o : etc.c constdefs.h $(HDRS) $(ruby_headers) \
+ $(hdrdir)/ruby/io.h \
+ $(hdrdir)/ruby/encoding.h \
+ $(hdrdir)/ruby/oniguruma.h
+
+constdefs.h : $(srcdir)/mkconstants.rb
+ @echo "generating constant definitions"
+ @$(RUBY) $(srcdir)/mkconstants.rb -o constdefs.h
+
diff --git a/jni/ruby/ext/etc/etc.c b/jni/ruby/ext/etc/etc.c
new file mode 100644
index 0000000..e25b586
--- /dev/null
+++ b/jni/ruby/ext/etc/etc.c
@@ -0,0 +1,1199 @@
+/************************************************
+
+ etc.c -
+
+ $Author: nobu $
+ created at: Tue Mar 22 18:39:19 JST 1994
+
+************************************************/
+
+#include "ruby.h"
+#include "ruby/encoding.h"
+#include "ruby/io.h"
+
+#include <sys/types.h>
+#ifdef HAVE_UNISTD_H
+#include <unistd.h>
+#endif
+
+#ifdef HAVE_GETPWENT
+#include <pwd.h>
+#endif
+
+#ifdef HAVE_GETGRENT
+#include <grp.h>
+#endif
+
+#include <errno.h>
+
+#ifdef HAVE_SYS_UTSNAME_H
+#include <sys/utsname.h>
+#endif
+
+#ifdef HAVE_SCHED_GETAFFINITY
+#include <sched.h>
+#endif
+
+static VALUE sPasswd;
+#ifdef HAVE_GETGRENT
+static VALUE sGroup;
+#endif
+
+#ifdef _WIN32
+#include <shlobj.h>
+#ifndef CSIDL_COMMON_APPDATA
+#define CSIDL_COMMON_APPDATA 35
+#endif
+#define HAVE_UNAME 1
+#endif
+
+#ifndef _WIN32
+char *getenv();
+#endif
+char *getlogin();
+
+#include "constdefs.h"
+
+/* call-seq:
+ * getlogin -> String
+ *
+ * Returns the short user name of the currently logged in user.
+ * Unfortunately, it is often rather easy to fool ::getlogin.
+ *
+ * Avoid ::getlogin for security-related purposes.
+ *
+ * If ::getlogin fails, try ::getpwuid.
+ *
+ * See the unix manpage for <code>getpwuid(3)</code> for more detail.
+ *
+ * e.g.
+ * Etc.getlogin -> 'guest'
+ */
+static VALUE
+etc_getlogin(VALUE obj)
+{
+ char *login;
+
+#ifdef HAVE_GETLOGIN
+ login = getlogin();
+ if (!login) login = getenv("USER");
+#else
+ login = getenv("USER");
+#endif
+
+ if (login) {
+#ifdef _WIN32
+ rb_encoding *extenc = rb_utf8_encoding();
+#else
+ rb_encoding *extenc = rb_locale_encoding();
+#endif
+ return rb_external_str_new_with_enc(login, strlen(login), extenc);
+ }
+
+ return Qnil;
+}
+
+#if defined(HAVE_GETPWENT) || defined(HAVE_GETGRENT)
+static VALUE
+safe_setup_str(const char *str)
+{
+ if (str == 0) str = "";
+ return rb_tainted_str_new2(str);
+}
+
+static VALUE
+safe_setup_locale_str(const char *str)
+{
+ if (str == 0) str = "";
+ return rb_locale_str_new_cstr(str);
+}
+
+static VALUE
+safe_setup_filesystem_str(const char *str)
+{
+ if (str == 0) str = "";
+ return rb_filesystem_str_new_cstr(str);
+}
+#endif
+
+#ifdef HAVE_GETPWENT
+static VALUE
+setup_passwd(struct passwd *pwd)
+{
+ if (pwd == 0) rb_sys_fail("/etc/passwd");
+ return rb_struct_new(sPasswd,
+ safe_setup_locale_str(pwd->pw_name),
+#ifdef HAVE_STRUCT_PASSWD_PW_PASSWD
+ safe_setup_str(pwd->pw_passwd),
+#endif
+ UIDT2NUM(pwd->pw_uid),
+ GIDT2NUM(pwd->pw_gid),
+#ifdef HAVE_STRUCT_PASSWD_PW_GECOS
+ safe_setup_locale_str(pwd->pw_gecos),
+#endif
+ safe_setup_filesystem_str(pwd->pw_dir),
+ safe_setup_filesystem_str(pwd->pw_shell),
+#ifdef HAVE_STRUCT_PASSWD_PW_CHANGE
+ INT2NUM(pwd->pw_change),
+#endif
+#ifdef HAVE_STRUCT_PASSWD_PW_QUOTA
+ INT2NUM(pwd->pw_quota),
+#endif
+#ifdef HAVE_STRUCT_PASSWD_PW_AGE
+ PW_AGE2VAL(pwd->pw_age),
+#endif
+#ifdef HAVE_STRUCT_PASSWD_PW_CLASS
+ safe_setup_locale_str(pwd->pw_class),
+#endif
+#ifdef HAVE_STRUCT_PASSWD_PW_COMMENT
+ safe_setup_locale_str(pwd->pw_comment),
+#endif
+#ifdef HAVE_STRUCT_PASSWD_PW_EXPIRE
+ INT2NUM(pwd->pw_expire),
+#endif
+ 0 /*dummy*/
+ );
+}
+#endif
+
+/* call-seq:
+ * getpwuid(uid) -> Passwd
+ *
+ * Returns the /etc/passwd information for the user with the given integer +uid+.
+ *
+ * The information is returned as a Passwd struct.
+ *
+ * If +uid+ is omitted, the value from <code>Passwd[:uid]</code> is returned
+ * instead.
+ *
+ * See the unix manpage for <code>getpwuid(3)</code> for more detail.
+ *
+ * === Example:
+ *
+ * Etc.getpwuid(0)
+ * #=> #<struct Etc::Passwd name="root", passwd="x", uid=0, gid=0, gecos="root",dir="/root", shell="/bin/bash">
+ */
+static VALUE
+etc_getpwuid(int argc, VALUE *argv, VALUE obj)
+{
+#if defined(HAVE_GETPWENT)
+ VALUE id;
+ rb_uid_t uid;
+ struct passwd *pwd;
+
+ if (rb_scan_args(argc, argv, "01", &id) == 1) {
+ uid = NUM2UIDT(id);
+ }
+ else {
+ uid = getuid();
+ }
+ pwd = getpwuid(uid);
+ if (pwd == 0) rb_raise(rb_eArgError, "can't find user for %d", (int)uid);
+ return setup_passwd(pwd);
+#else
+ return Qnil;
+#endif
+}
+
+/* call-seq:
+ * getpwnam(name) -> Passwd
+ *
+ * Returns the /etc/passwd information for the user with specified login
+ * +name+.
+ *
+ * The information is returned as a Passwd struct.
+ *
+ * See the unix manpage for <code>getpwnam(3)</code> for more detail.
+ *
+ * === Example:
+ *
+ * Etc.getpwnam('root')
+ * #=> #<struct Etc::Passwd name="root", passwd="x", uid=0, gid=0, gecos="root",dir="/root", shell="/bin/bash">
+ */
+static VALUE
+etc_getpwnam(VALUE obj, VALUE nam)
+{
+#ifdef HAVE_GETPWENT
+ struct passwd *pwd;
+
+ SafeStringValue(nam);
+ pwd = getpwnam(RSTRING_PTR(nam));
+ if (pwd == 0) rb_raise(rb_eArgError, "can't find user for %"PRIsVALUE, nam);
+ return setup_passwd(pwd);
+#else
+ return Qnil;
+#endif
+}
+
+#ifdef HAVE_GETPWENT
+static int passwd_blocking = 0;
+static VALUE
+passwd_ensure(void)
+{
+ endpwent();
+ passwd_blocking = (int)Qfalse;
+ return Qnil;
+}
+
+static VALUE
+passwd_iterate(void)
+{
+ struct passwd *pw;
+
+ setpwent();
+ while (pw = getpwent()) {
+ rb_yield(setup_passwd(pw));
+ }
+ return Qnil;
+}
+
+static void
+each_passwd(void)
+{
+ if (passwd_blocking) {
+ rb_raise(rb_eRuntimeError, "parallel passwd iteration");
+ }
+ passwd_blocking = (int)Qtrue;
+ rb_ensure(passwd_iterate, 0, passwd_ensure, 0);
+}
+#endif
+
+/* call-seq:
+ * Etc.passwd { |struct| block } -> Passwd
+ * Etc.passwd -> Passwd
+ *
+ * Provides a convenient Ruby iterator which executes a block for each entry
+ * in the /etc/passwd file.
+ *
+ * The code block is passed an Passwd struct.
+ *
+ * See ::getpwent above for details.
+ *
+ * Example:
+ *
+ * require 'etc'
+ *
+ * Etc.passwd {|u|
+ * puts u.name + " = " + u.gecos
+ * }
+ *
+ */
+static VALUE
+etc_passwd(VALUE obj)
+{
+#ifdef HAVE_GETPWENT
+ struct passwd *pw;
+
+ if (rb_block_given_p()) {
+ each_passwd();
+ }
+ else if (pw = getpwent()) {
+ return setup_passwd(pw);
+ }
+#endif
+ return Qnil;
+}
+
+/* call-seq:
+ * Etc::Passwd.each { |struct| block } -> Passwd
+ * Etc::Passwd.each -> Enumerator
+ *
+ * Iterates for each entry in the /etc/passwd file if a block is given.
+ *
+ * If no block is given, returns the Enumerator.
+ *
+ * The code block is passed an Passwd struct.
+ *
+ * See ::getpwent above for details.
+ *
+ * Example:
+ *
+ * require 'etc'
+ *
+ * Etc::Passwd.each {|u|
+ * puts u.name + " = " + u.gecos
+ * }
+ *
+ * Etc::Passwd.collect {|u| u.gecos}
+ * Etc::Passwd.collect {|u| u.gecos}
+ *
+ */
+static VALUE
+etc_each_passwd(VALUE obj)
+{
+#ifdef HAVE_GETPWENT
+ RETURN_ENUMERATOR(obj, 0, 0);
+ each_passwd();
+#endif
+ return obj;
+}
+
+/* Resets the process of reading the /etc/passwd file, so that the next call
+ * to ::getpwent will return the first entry again.
+ */
+static VALUE
+etc_setpwent(VALUE obj)
+{
+#ifdef HAVE_GETPWENT
+ setpwent();
+#endif
+ return Qnil;
+}
+
+/* Ends the process of scanning through the /etc/passwd file begun with
+ * ::getpwent, and closes the file.
+ */
+static VALUE
+etc_endpwent(VALUE obj)
+{
+#ifdef HAVE_GETPWENT
+ endpwent();
+#endif
+ return Qnil;
+}
+
+/* Returns an entry from the /etc/passwd file.
+ *
+ * The first time it is called it opens the file and returns the first entry;
+ * each successive call returns the next entry, or +nil+ if the end of the file
+ * has been reached.
+ *
+ * To close the file when processing is complete, call ::endpwent.
+ *
+ * Each entry is returned as a Passwd struct.
+ *
+ */
+static VALUE
+etc_getpwent(VALUE obj)
+{
+#ifdef HAVE_GETPWENT
+ struct passwd *pw;
+
+ if (pw = getpwent()) {
+ return setup_passwd(pw);
+ }
+#endif
+ return Qnil;
+}
+
+#ifdef HAVE_GETGRENT
+static VALUE
+setup_group(struct group *grp)
+{
+ VALUE mem;
+ char **tbl;
+
+ mem = rb_ary_new();
+ tbl = grp->gr_mem;
+ while (*tbl) {
+ rb_ary_push(mem, safe_setup_locale_str(*tbl));
+ tbl++;
+ }
+ return rb_struct_new(sGroup,
+ safe_setup_locale_str(grp->gr_name),
+#ifdef HAVE_STRUCT_GROUP_GR_PASSWD
+ safe_setup_str(grp->gr_passwd),
+#endif
+ GIDT2NUM(grp->gr_gid),
+ mem);
+}
+#endif
+
+/* call-seq:
+ * getgrgid(group_id) -> Group
+ *
+ * Returns information about the group with specified integer +group_id+,
+ * as found in /etc/group.
+ *
+ * The information is returned as a Group struct.
+ *
+ * See the unix manpage for <code>getgrgid(3)</code> for more detail.
+ *
+ * === Example:
+ *
+ * Etc.getgrgid(100)
+ * #=> #<struct Etc::Group name="users", passwd="x", gid=100, mem=["meta", "root"]>
+ *
+ */
+static VALUE
+etc_getgrgid(int argc, VALUE *argv, VALUE obj)
+{
+#ifdef HAVE_GETGRENT
+ VALUE id;
+ gid_t gid;
+ struct group *grp;
+
+ if (rb_scan_args(argc, argv, "01", &id) == 1) {
+ gid = NUM2GIDT(id);
+ }
+ else {
+ gid = getgid();
+ }
+ grp = getgrgid(gid);
+ if (grp == 0) rb_raise(rb_eArgError, "can't find group for %d", (int)gid);
+ return setup_group(grp);
+#else
+ return Qnil;
+#endif
+}
+
+/* call-seq:
+ * getgrnam(name) -> Group
+ *
+ * Returns information about the group with specified +name+, as found in
+ * /etc/group.
+ *
+ * The information is returned as a Group struct.
+ *
+ * See the unix manpage for <code>getgrnam(3)</code> for more detail.
+ *
+ * === Example:
+ *
+ * Etc.getgrnam('users')
+ * #=> #<struct Etc::Group name="users", passwd="x", gid=100, mem=["meta", "root"]>
+ *
+ */
+static VALUE
+etc_getgrnam(VALUE obj, VALUE nam)
+{
+#ifdef HAVE_GETGRENT
+ struct group *grp;
+
+ SafeStringValue(nam);
+ grp = getgrnam(RSTRING_PTR(nam));
+ if (grp == 0) rb_raise(rb_eArgError, "can't find group for %"PRIsVALUE, nam);
+ return setup_group(grp);
+#else
+ return Qnil;
+#endif
+}
+
+#ifdef HAVE_GETGRENT
+static int group_blocking = 0;
+static VALUE
+group_ensure(void)
+{
+ endgrent();
+ group_blocking = (int)Qfalse;
+ return Qnil;
+}
+
+
+static VALUE
+group_iterate(void)
+{
+ struct group *pw;
+
+ setgrent();
+ while (pw = getgrent()) {
+ rb_yield(setup_group(pw));
+ }
+ return Qnil;
+}
+
+static void
+each_group(void)
+{
+ if (group_blocking) {
+ rb_raise(rb_eRuntimeError, "parallel group iteration");
+ }
+ group_blocking = (int)Qtrue;
+ rb_ensure(group_iterate, 0, group_ensure, 0);
+}
+#endif
+
+/* Provides a convenient Ruby iterator which executes a block for each entry
+ * in the /etc/group file.
+ *
+ * The code block is passed an Group struct.
+ *
+ * See ::getgrent above for details.
+ *
+ * Example:
+ *
+ * require 'etc'
+ *
+ * Etc.group {|g|
+ * puts g.name + ": " + g.mem.join(', ')
+ * }
+ *
+ */
+static VALUE
+etc_group(VALUE obj)
+{
+#ifdef HAVE_GETGRENT
+ struct group *grp;
+
+ if (rb_block_given_p()) {
+ each_group();
+ }
+ else if (grp = getgrent()) {
+ return setup_group(grp);
+ }
+#endif
+ return Qnil;
+}
+
+#ifdef HAVE_GETGRENT
+/* call-seq:
+ * Etc::Group.each { |group| block } -> obj
+ * Etc::Group.each -> Enumerator
+ *
+ * Iterates for each entry in the /etc/group file if a block is given.
+ *
+ * If no block is given, returns the Enumerator.
+ *
+ * The code block is passed a Group struct.
+ *
+ * Example:
+ *
+ * require 'etc'
+ *
+ * Etc::Group.each {|g|
+ * puts g.name + ": " + g.mem.join(', ')
+ * }
+ *
+ * Etc::Group.collect {|g| g.name}
+ * Etc::Group.select {|g| !g.mem.empty?}
+ *
+ */
+static VALUE
+etc_each_group(VALUE obj)
+{
+ RETURN_ENUMERATOR(obj, 0, 0);
+ each_group();
+ return obj;
+}
+#endif
+
+/* Resets the process of reading the /etc/group file, so that the next call
+ * to ::getgrent will return the first entry again.
+ */
+static VALUE
+etc_setgrent(VALUE obj)
+{
+#ifdef HAVE_GETGRENT
+ setgrent();
+#endif
+ return Qnil;
+}
+
+/* Ends the process of scanning through the /etc/group file begun by
+ * ::getgrent, and closes the file.
+ */
+static VALUE
+etc_endgrent(VALUE obj)
+{
+#ifdef HAVE_GETGRENT
+ endgrent();
+#endif
+ return Qnil;
+}
+
+/* Returns an entry from the /etc/group file.
+ *
+ * The first time it is called it opens the file and returns the first entry;
+ * each successive call returns the next entry, or +nil+ if the end of the file
+ * has been reached.
+ *
+ * To close the file when processing is complete, call ::endgrent.
+ *
+ * Each entry is returned as a Group struct
+ */
+static VALUE
+etc_getgrent(VALUE obj)
+{
+#ifdef HAVE_GETGRENT
+ struct group *gr;
+
+ if (gr = getgrent()) {
+ return setup_group(gr);
+ }
+#endif
+ return Qnil;
+}
+
+#define numberof(array) (sizeof(array) / sizeof(*(array)))
+
+#ifdef _WIN32
+VALUE rb_w32_special_folder(int type);
+UINT rb_w32_system_tmpdir(WCHAR *path, UINT len);
+VALUE rb_w32_conv_from_wchar(const WCHAR *wstr, rb_encoding *enc);
+#endif
+
+/*
+ * Returns system configuration directory.
+ *
+ * This is typically "/etc", but is modified by the prefix used when Ruby was
+ * compiled. For example, if Ruby is built and installed in /usr/local, returns
+ * "/usr/local/etc".
+ */
+static VALUE
+etc_sysconfdir(VALUE obj)
+{
+#ifdef _WIN32
+ return rb_w32_special_folder(CSIDL_COMMON_APPDATA);
+#else
+ return rb_filesystem_str_new_cstr(SYSCONFDIR);
+#endif
+}
+
+/*
+ * Returns system temporary directory; typically "/tmp".
+ */
+static VALUE
+etc_systmpdir(void)
+{
+ VALUE tmpdir;
+#ifdef _WIN32
+ WCHAR path[_MAX_PATH];
+ UINT len = rb_w32_system_tmpdir(path, numberof(path));
+ if (!len) return Qnil;
+ tmpdir = rb_w32_conv_from_wchar(path, rb_filesystem_encoding());
+#else
+ const char default_tmp[] = "/tmp";
+ const char *tmpstr = default_tmp;
+ size_t tmplen = strlen(default_tmp);
+# if defined _CS_DARWIN_USER_TEMP_DIR
+ #ifndef MAXPATHLEN
+ #define MAXPATHLEN 1024
+ #endif
+ char path[MAXPATHLEN];
+ size_t len;
+ len = confstr(_CS_DARWIN_USER_TEMP_DIR, path, sizeof(path));
+ if (len > 0) {
+ tmpstr = path;
+ tmplen = len - 1;
+ }
+# endif
+ tmpdir = rb_filesystem_str_new(tmpstr, tmplen);
+#endif
+ FL_UNSET(tmpdir, FL_TAINT);
+ return tmpdir;
+}
+
+#ifdef HAVE_UNAME
+/*
+ * Returns the system information obtained by uname system call.
+ *
+ * The return value is a hash which has 5 keys at least:
+ * :sysname, :nodename, :release, :version, :machine
+ *
+ * Example:
+ *
+ * require 'etc'
+ * require 'pp'
+ *
+ * pp Etc.uname
+ * #=> {:sysname=>"Linux",
+ * # :nodename=>"boron",
+ * # :release=>"2.6.18-6-xen-686",
+ * # :version=>"#1 SMP Thu Nov 5 19:54:42 UTC 2009",
+ * # :machine=>"i686"}
+ *
+ */
+static VALUE
+etc_uname(VALUE obj)
+{
+#ifdef _WIN32
+ OSVERSIONINFOW v;
+ SYSTEM_INFO s;
+ const char *sysname, *mach;
+ VALUE result, release, version;
+ VALUE vbuf, nodename = Qnil;
+ DWORD len = 0;
+ WCHAR *buf;
+
+ v.dwOSVersionInfoSize = sizeof(v);
+ if (!GetVersionExW(&v))
+ rb_sys_fail("GetVersionEx");
+
+ result = rb_hash_new();
+ switch (v.dwPlatformId) {
+ case VER_PLATFORM_WIN32s:
+ sysname = "Win32s";
+ break;
+ case VER_PLATFORM_WIN32_NT:
+ sysname = "Windows_NT";
+ break;
+ case VER_PLATFORM_WIN32_WINDOWS:
+ default:
+ sysname = "Windows";
+ break;
+ }
+ rb_hash_aset(result, ID2SYM(rb_intern("sysname")), rb_str_new_cstr(sysname));
+ release = rb_sprintf("%lu.%lu.%lu", v.dwMajorVersion, v.dwMinorVersion, v.dwBuildNumber);
+ rb_hash_aset(result, ID2SYM(rb_intern("release")), release);
+ version = rb_sprintf("%s Version %"PRIsVALUE": %"PRIsVALUE, sysname, release,
+ rb_w32_conv_from_wchar(v.szCSDVersion, rb_utf8_encoding()));
+ rb_hash_aset(result, ID2SYM(rb_intern("version")), version);
+
+# if defined _MSC_VER && _MSC_VER < 1300
+# define GET_COMPUTER_NAME(ptr, plen) GetComputerNameW(ptr, plen)
+# else
+# define GET_COMPUTER_NAME(ptr, plen) GetComputerNameExW(ComputerNameDnsFullyQualified, ptr, plen)
+# endif
+ GET_COMPUTER_NAME(NULL, &len);
+ buf = ALLOCV_N(WCHAR, vbuf, len);
+ if (GET_COMPUTER_NAME(buf, &len)) {
+ nodename = rb_w32_conv_from_wchar(buf, rb_utf8_encoding());
+ }
+ ALLOCV_END(vbuf);
+ if (NIL_P(nodename)) nodename = rb_str_new(0, 0);
+ rb_hash_aset(result, ID2SYM(rb_intern("nodename")), nodename);
+
+# ifndef PROCESSOR_ARCHITECTURE_AMD64
+# define PROCESSOR_ARCHITECTURE_AMD64 9
+# endif
+# ifndef PROCESSOR_ARCHITECTURE_IA64
+# define PROCESSOR_ARCHITECTURE_IA64 6
+# endif
+# ifndef PROCESSOR_ARCHITECTURE_INTEL
+# define PROCESSOR_ARCHITECTURE_INTEL 0
+# endif
+ GetSystemInfo(&s);
+ switch (s.wProcessorArchitecture) {
+ case PROCESSOR_ARCHITECTURE_AMD64:
+ mach = "x64";
+ break;
+ case PROCESSOR_ARCHITECTURE_ARM:
+ mach = "ARM";
+ break;
+ case PROCESSOR_ARCHITECTURE_IA64:
+ mach = "IA64";
+ break;
+ case PROCESSOR_ARCHITECTURE_INTEL:
+ mach = "x86";
+ break;
+ default:
+ mach = "unknown";
+ break;
+ }
+
+ rb_hash_aset(result, ID2SYM(rb_intern("machine")), rb_str_new_cstr(mach));
+#else
+ struct utsname u;
+ int ret;
+ VALUE result;
+
+ ret = uname(&u);
+ if (ret == -1)
+ rb_sys_fail("uname");
+
+ result = rb_hash_new();
+ rb_hash_aset(result, ID2SYM(rb_intern("sysname")), rb_str_new_cstr(u.sysname));
+ rb_hash_aset(result, ID2SYM(rb_intern("nodename")), rb_str_new_cstr(u.nodename));
+ rb_hash_aset(result, ID2SYM(rb_intern("release")), rb_str_new_cstr(u.release));
+ rb_hash_aset(result, ID2SYM(rb_intern("version")), rb_str_new_cstr(u.version));
+ rb_hash_aset(result, ID2SYM(rb_intern("machine")), rb_str_new_cstr(u.machine));
+#endif
+
+ return result;
+}
+#else
+#define etc_uname rb_f_notimplement
+#endif
+
+#ifdef HAVE_SYSCONF
+/*
+ * Returns system configuration variable using sysconf().
+ *
+ * _name_ should be a constant under <code>Etc</code> which begins with <code>SC_</code>.
+ *
+ * The return value is an integer or nil.
+ * nil means indefinite limit. (sysconf() returns -1 but errno is not set.)
+ *
+ * Etc.sysconf(Etc::SC_ARG_MAX) #=> 2097152
+ * Etc.sysconf(Etc::SC_LOGIN_NAME_MAX) #=> 256
+ *
+ */
+static VALUE
+etc_sysconf(VALUE obj, VALUE arg)
+{
+ int name;
+ long ret;
+
+ name = NUM2INT(arg);
+
+ errno = 0;
+ ret = sysconf(name);
+ if (ret == -1) {
+ if (errno == 0) /* no limit */
+ return Qnil;
+ rb_sys_fail("sysconf");
+ }
+ return LONG2NUM(ret);
+}
+#else
+#define etc_sysconf rb_f_notimplement
+#endif
+
+#ifdef HAVE_CONFSTR
+/*
+ * Returns system configuration variable using confstr().
+ *
+ * _name_ should be a constant under <code>Etc</code> which begins with <code>CS_</code>.
+ *
+ * The return value is a string or nil.
+ * nil means no configuration-defined value. (confstr() returns 0 but errno is not set.)
+ *
+ * Etc.confstr(Etc::CS_PATH) #=> "/bin:/usr/bin"
+ *
+ * # GNU/Linux
+ * Etc.confstr(Etc::CS_GNU_LIBC_VERSION) #=> "glibc 2.18"
+ * Etc.confstr(Etc::CS_GNU_LIBPTHREAD_VERSION) #=> "NPTL 2.18"
+ *
+ */
+static VALUE
+etc_confstr(VALUE obj, VALUE arg)
+{
+ int name;
+ char localbuf[128], *buf = localbuf;
+ size_t bufsize = sizeof(localbuf), ret;
+ VALUE tmp;
+
+ name = NUM2INT(arg);
+
+ errno = 0;
+ ret = confstr(name, buf, bufsize);
+ if (bufsize < ret) {
+ bufsize = ret;
+ buf = ALLOCV_N(char, tmp, bufsize);
+ errno = 0;
+ ret = confstr(name, buf, bufsize);
+ }
+ if (bufsize < ret)
+ rb_bug("required buffer size for confstr() changed dynamically.");
+ if (ret == 0) {
+ if (errno == 0) /* no configuration-defined value */
+ return Qnil;
+ rb_sys_fail("confstr");
+ }
+ return rb_str_new_cstr(buf);
+}
+#else
+#define etc_confstr rb_f_notimplement
+#endif
+
+#ifdef HAVE_FPATHCONF
+/*
+ * Returns pathname configuration variable using fpathconf().
+ *
+ * _name_ should be a constant under <code>Etc</code> which begins with <code>PC_</code>.
+ *
+ * The return value is an integer or nil.
+ * nil means indefinite limit. (fpathconf() returns -1 but errno is not set.)
+ *
+ * require 'etc'
+ * IO.pipe {|r, w|
+ * p w.pathconf(Etc::PC_PIPE_BUF) #=> 4096
+ * }
+ *
+ */
+static VALUE
+io_pathconf(VALUE io, VALUE arg)
+{
+ int name;
+ long ret;
+ rb_io_t *fptr;
+
+ name = NUM2INT(arg);
+
+ GetOpenFile(io, fptr);
+
+ errno = 0;
+ ret = fpathconf(fptr->fd, name);
+ if (ret == -1) {
+ if (errno == 0) /* no limit */
+ return Qnil;
+ rb_sys_fail("fpathconf");
+ }
+ return LONG2NUM(ret);
+}
+#else
+#define io_pathconf rb_f_notimplement
+#endif
+
+#if (defined(HAVE_SYSCONF) && defined(_SC_NPROCESSORS_ONLN)) || defined(_WIN32)
+
+#if defined(HAVE_SCHED_GETAFFINITY) && defined(CPU_ALLOC)
+static int
+etc_nprocessors_affin(void)
+{
+ cpu_set_t *cpuset;
+ size_t size;
+ int ret;
+ int n;
+
+ /*
+ * XXX:
+ * man page says CPU_ALLOC takes number of cpus. But it is not accurate
+ * explanation. sched_getaffinity() returns EINVAL if cpuset bitmap is
+ * smaller than kernel internal bitmap.
+ * That said, sched_getaffinity() can fail when a kernel have sparse bitmap
+ * even if cpuset bitmap is larger than number of cpus.
+ * The precious way is to use /sys/devices/system/cpu/online. But there are
+ * two problems,
+ * - Costly calculation
+ * It is a minor issue, but possibly kill a benefit of a parallel processing.
+ * - No guarantee to exist /sys/devices/system/cpu/online
+ * This is an issue especially when using Linux containers.
+ * So, we use hardcode number for a workaround. Current linux kernel
+ * (Linux 3.17) support 8192 cpus at maximum. Then 16384 must be enough.
+ */
+ for (n=64; n <= 16384; n *= 2) {
+ size = CPU_ALLOC_SIZE(n);
+ if (size >= 1024) {
+ cpuset = xcalloc(1, size);
+ if (!cpuset)
+ return -1;
+ } else {
+ cpuset = alloca(size);
+ CPU_ZERO_S(size, cpuset);
+ }
+
+ ret = sched_getaffinity(0, size, cpuset);
+ if (ret == 0) {
+ /* On success, count number of cpus. */
+ ret = CPU_COUNT_S(size, cpuset);
+ }
+
+ if (size >= 1024) {
+ xfree(cpuset);
+ }
+ if (ret > 0) {
+ return ret;
+ }
+ }
+
+ return ret;
+}
+#endif
+
+/*
+ * Returns the number of online processors.
+ *
+ * The result is intended as the number of processes to
+ * use all available processors.
+ *
+ * This method is implemented using:
+ * - sched_getaffinity(): Linux
+ * - sysconf(_SC_NPROCESSORS_ONLN): GNU/Linux, NetBSD, FreeBSD, OpenBSD, DragonFly BSD, OpenIndiana, Mac OS X, AIX
+ *
+ * Example:
+ *
+ * require 'etc'
+ * p Etc.nprocessors #=> 4
+ *
+ * The result might be smaller number than physical cpus especially when ruby
+ * process is bound to specific cpus. This is intended for getting better
+ * parallel processing.
+ *
+ * Example: (Linux)
+ *
+ * linux$ taskset 0x3 ./ruby -retc -e "p Etc.nprocessors" #=> 2
+ *
+ */
+static VALUE
+etc_nprocessors(VALUE obj)
+{
+ long ret;
+
+#if !defined(_WIN32)
+
+#if defined(HAVE_SCHED_GETAFFINITY) && defined(CPU_ALLOC)
+ int ncpus;
+
+ ncpus = etc_nprocessors_affin();
+ if (ncpus != -1) {
+ return INT2NUM(ncpus);
+ }
+ /* fallback to _SC_NPROCESSORS_ONLN */
+#endif
+
+ errno = 0;
+ ret = sysconf(_SC_NPROCESSORS_ONLN);
+ if (ret == -1) {
+ rb_sys_fail("sysconf(_SC_NPROCESSORS_ONLN)");
+ }
+#else
+ SYSTEM_INFO si;
+ GetSystemInfo(&si);
+ ret = (long)si.dwNumberOfProcessors;
+#endif
+ return LONG2NUM(ret);
+}
+#else
+#define etc_nprocessors rb_f_notimplement
+#endif
+
+/*
+ * The Etc module provides access to information typically stored in
+ * files in the /etc directory on Unix systems.
+ *
+ * The information accessible consists of the information found in the
+ * /etc/passwd and /etc/group files, plus information about the system's
+ * temporary directory (/tmp) and configuration directory (/etc).
+ *
+ * The Etc module provides a more reliable way to access information about
+ * the logged in user than environment variables such as +$USER+.
+ *
+ * == Example:
+ *
+ * require 'etc'
+ *
+ * login = Etc.getlogin
+ * info = Etc.getpwnam(login)
+ * username = info.gecos.split(/,/).first
+ * puts "Hello #{username}, I see your login name is #{login}"
+ *
+ * Note that the methods provided by this module are not always secure.
+ * It should be used for informational purposes, and not for security.
+ *
+ * All operations defined in this module are class methods, so that you can
+ * include the Etc module into your class.
+ */
+void
+Init_etc(void)
+{
+ VALUE mEtc;
+
+ mEtc = rb_define_module("Etc");
+ init_constants(mEtc);
+
+ rb_define_module_function(mEtc, "getlogin", etc_getlogin, 0);
+
+ rb_define_module_function(mEtc, "getpwuid", etc_getpwuid, -1);
+ rb_define_module_function(mEtc, "getpwnam", etc_getpwnam, 1);
+ rb_define_module_function(mEtc, "setpwent", etc_setpwent, 0);
+ rb_define_module_function(mEtc, "endpwent", etc_endpwent, 0);
+ rb_define_module_function(mEtc, "getpwent", etc_getpwent, 0);
+ rb_define_module_function(mEtc, "passwd", etc_passwd, 0);
+
+ rb_define_module_function(mEtc, "getgrgid", etc_getgrgid, -1);
+ rb_define_module_function(mEtc, "getgrnam", etc_getgrnam, 1);
+ rb_define_module_function(mEtc, "group", etc_group, 0);
+ rb_define_module_function(mEtc, "setgrent", etc_setgrent, 0);
+ rb_define_module_function(mEtc, "endgrent", etc_endgrent, 0);
+ rb_define_module_function(mEtc, "getgrent", etc_getgrent, 0);
+ rb_define_module_function(mEtc, "sysconfdir", etc_sysconfdir, 0);
+ rb_define_module_function(mEtc, "systmpdir", etc_systmpdir, 0);
+ rb_define_module_function(mEtc, "uname", etc_uname, 0);
+ rb_define_module_function(mEtc, "sysconf", etc_sysconf, 1);
+ rb_define_module_function(mEtc, "confstr", etc_confstr, 1);
+ rb_define_method(rb_cIO, "pathconf", io_pathconf, 1);
+ rb_define_module_function(mEtc, "nprocessors", etc_nprocessors, 0);
+
+ sPasswd = rb_struct_define_under(mEtc, "Passwd",
+ "name",
+#ifdef HAVE_STRUCT_PASSWD_PW_PASSWD
+ "passwd",
+#endif
+ "uid",
+ "gid",
+#ifdef HAVE_STRUCT_PASSWD_PW_GECOS
+ "gecos",
+#endif
+ "dir",
+ "shell",
+#ifdef HAVE_STRUCT_PASSWD_PW_CHANGE
+ "change",
+#endif
+#ifdef HAVE_STRUCT_PASSWD_PW_QUOTA
+ "quota",
+#endif
+#ifdef HAVE_STRUCT_PASSWD_PW_AGE
+ "age",
+#endif
+#ifdef HAVE_STRUCT_PASSWD_PW_CLASS
+ "uclass",
+#endif
+#ifdef HAVE_STRUCT_PASSWD_PW_COMMENT
+ "comment",
+#endif
+#ifdef HAVE_STRUCT_PASSWD_PW_EXPIRE
+ "expire",
+#endif
+ NULL);
+#if 0
+ /* Define-const: Passwd
+ *
+ * Passwd is a Struct that contains the following members:
+ *
+ * name::
+ * contains the short login name of the user as a String.
+ * passwd::
+ * contains the encrypted password of the user as a String.
+ * an 'x' is returned if shadow passwords are in use. An '*' is returned
+ * if the user cannot log in using a password.
+ * uid::
+ * contains the integer user ID (uid) of the user.
+ * gid::
+ * contains the integer group ID (gid) of the user's primary group.
+ * dir::
+ * contains the path to the home directory of the user as a String.
+ * shell::
+ * contains the path to the login shell of the user as a String.
+ *
+ * === The following members below are optional, and must be compiled with special flags:
+ *
+ * gecos::
+ * contains a longer String description of the user, such as
+ * a full name. Some Unix systems provide structured information in the
+ * gecos field, but this is system-dependent.
+ * must be compiled with +HAVE_STRUCT_PASSWD_PW_GECOS+
+ * change::
+ * password change time(integer) must be compiled with +HAVE_STRUCT_PASSWD_PW_CHANGE+
+ * quota::
+ * quota value(integer) must be compiled with +HAVE_STRUCT_PASSWD_PW_QUOTA+
+ * age::
+ * password age(integer) must be compiled with +HAVE_STRUCT_PASSWD_PW_AGE+
+ * class::
+ * user access class(string) must be compiled with +HAVE_STRUCT_PASSWD_PW_CLASS+
+ * comment::
+ * comment(string) must be compiled with +HAVE_STRUCT_PASSWD_PW_COMMENT+
+ * expire::
+ * account expiration time(integer) must be compiled with +HAVE_STRUCT_PASSWD_PW_EXPIRE+
+ */
+ rb_define_const(mEtc, "Passwd", sPasswd);
+#endif
+ rb_define_const(rb_cStruct, "Passwd", sPasswd); /* deprecated name */
+ rb_extend_object(sPasswd, rb_mEnumerable);
+ rb_define_singleton_method(sPasswd, "each", etc_each_passwd, 0);
+
+#ifdef HAVE_GETGRENT
+ sGroup = rb_struct_define_under(mEtc, "Group", "name",
+#ifdef HAVE_STRUCT_GROUP_GR_PASSWD
+ "passwd",
+#endif
+ "gid", "mem", NULL);
+
+#if 0
+ /* Define-const: Group
+ *
+ * Group is a Struct that is only available when compiled with +HAVE_GETGRENT+.
+ *
+ * The struct contains the following members:
+ *
+ * name::
+ * contains the name of the group as a String.
+ * passwd::
+ * contains the encrypted password as a String. An 'x' is
+ * returned if password access to the group is not available; an empty
+ * string is returned if no password is needed to obtain membership of
+ * the group.
+ *
+ * Must be compiled with +HAVE_STRUCT_GROUP_GR_PASSWD+.
+ * gid::
+ * contains the group's numeric ID as an integer.
+ * mem::
+ * is an Array of Strings containing the short login names of the
+ * members of the group.
+ */
+ rb_define_const(mEtc, "Group", sGroup);
+#endif
+ rb_define_const(rb_cStruct, "Group", sGroup); /* deprecated name */
+ rb_extend_object(sGroup, rb_mEnumerable);
+ rb_define_singleton_method(sGroup, "each", etc_each_group, 0);
+#endif
+}
diff --git a/jni/ruby/ext/etc/extconf.h b/jni/ruby/ext/etc/extconf.h
new file mode 100644
index 0000000..bf054fa
--- /dev/null
+++ b/jni/ruby/ext/etc/extconf.h
@@ -0,0 +1,18 @@
+#ifndef EXTCONF_H
+#define EXTCONF_H
+#define HAVE_SYS_UTSNAME_H 1
+#define HAVE_UNAME 1
+#define HAVE_GETLOGIN 1
+#define HAVE_GETPWENT 1
+#define HAVE_GETGRENT 1
+#define SYSCONFDIR "/usr/local/etc"
+#define HAVE_SYSCONF 1
+#define HAVE_CONFSTR 1
+#define HAVE_FPATHCONF 1
+#define HAVE_STRUCT_PASSWD_PW_GECOS 1
+#define HAVE_ST_PW_GECOS 1
+#define HAVE_STRUCT_PASSWD_PW_PASSWD 1
+#define HAVE_ST_PW_PASSWD 1
+#define HAVE_STRUCT_GROUP_GR_PASSWD 1
+#define HAVE_ST_GR_PASSWD 1
+#endif
diff --git a/jni/ruby/ext/etc/extconf.rb b/jni/ruby/ext/etc/extconf.rb
new file mode 100644
index 0000000..c6b41a4
--- /dev/null
+++ b/jni/ruby/ext/etc/extconf.rb
@@ -0,0 +1,43 @@
+require 'mkmf'
+
+headers = []
+%w[sys/utsname.h].each {|h|
+ if have_header(h, headers)
+ headers << h
+ end
+}
+have_library("sun", "getpwnam") # NIS (== YP) interface for IRIX 4
+have_func("uname((struct utsname *)NULL)", headers)
+have_func("getlogin")
+have_func("getpwent")
+have_func("getgrent")
+sysconfdir = RbConfig.expand(RbConfig::CONFIG["sysconfdir"].dup, "prefix"=>"", "DESTDIR"=>"")
+$defs.push("-DSYSCONFDIR=#{Shellwords.escape(sysconfdir.dump)}")
+
+have_func("sysconf")
+have_func("confstr")
+have_func("fpathconf")
+
+have_struct_member('struct passwd', 'pw_gecos', 'pwd.h')
+have_struct_member('struct passwd', 'pw_change', 'pwd.h')
+have_struct_member('struct passwd', 'pw_quota', 'pwd.h')
+if have_struct_member('struct passwd', 'pw_age', 'pwd.h')
+ case what_type?('struct passwd', 'pw_age', 'pwd.h')
+ when "string"
+ f = "safe_setup_str"
+ when "long long"
+ f = "LL2NUM"
+ else
+ f = "INT2NUM"
+ end
+ $defs.push("-DPW_AGE2VAL="+f)
+end
+have_struct_member('struct passwd', 'pw_class', 'pwd.h')
+have_struct_member('struct passwd', 'pw_comment', 'pwd.h') unless /cygwin/ === RUBY_PLATFORM
+have_struct_member('struct passwd', 'pw_expire', 'pwd.h')
+have_struct_member('struct passwd', 'pw_passwd', 'pwd.h')
+have_struct_member('struct group', 'gr_passwd', 'grp.h')
+
+$distcleanfiles << "constdefs.h"
+
+create_makefile("etc")
diff --git a/jni/ruby/ext/etc/mkconstants.rb b/jni/ruby/ext/etc/mkconstants.rb
new file mode 100644
index 0000000..c9fddfd
--- /dev/null
+++ b/jni/ruby/ext/etc/mkconstants.rb
@@ -0,0 +1,331 @@
+require 'optparse'
+require 'erb'
+
+C_ESC = {
+ "\\" => "\\\\",
+ '"' => '\"',
+ "\n" => '\n',
+}
+
+0x00.upto(0x1f) {|ch| C_ESC[[ch].pack("C")] ||= "\\%03o" % ch }
+0x7f.upto(0xff) {|ch| C_ESC[[ch].pack("C")] = "\\%03o" % ch }
+C_ESC_PAT = Regexp.union(*C_ESC.keys)
+
+def c_str(str)
+ '"' + str.gsub(C_ESC_PAT) {|s| C_ESC[s]} + '"'
+end
+
+opt = OptionParser.new
+
+opt.def_option('-h', 'help') {
+ puts opt
+ exit 0
+}
+
+opt_o = nil
+opt.def_option('-o FILE', 'specify output file') {|filename|
+ opt_o = filename
+}
+
+opt_H = nil
+opt.def_option('-H FILE', 'specify output header file') {|filename|
+ opt_H = filename
+}
+
+opt.parse!
+
+h = {}
+COMMENTS = {}
+
+DATA.each_line {|s|
+ next if /\A\s*(\#|\z)/ =~ s
+ name, default_value, comment = s.chomp.split(/\s+/, 3)
+
+ default_value = nil if default_value == 'nil'
+
+ if h.has_key? name
+ warn "#{$.}: warning: duplicate name: #{name}"
+ next
+ end
+ h[name] = default_value
+ COMMENTS[name] = comment if comment
+}
+DEFS = h.to_a
+
+def each_const
+ DEFS.each {|name, default_value|
+ yield name, default_value
+ }
+end
+
+def each_name(pat)
+ DEFS.each {|name, default_value|
+ next if pat !~ name
+ yield name
+ }
+end
+
+ERB.new(<<'EOS', nil, '%').def_method(Object, "gen_const_decls")
+% each_const {|name, default_value|
+#if !defined(<%=name%>)
+# if defined(HAVE_CONST_<%=name.upcase%>)
+# define <%=name%> <%=name%>
+%if default_value
+# else
+# define <%=name%> <%=default_value%>
+%end
+# endif
+#endif
+% }
+EOS
+
+ERB.new(<<'EOS', nil, '%').def_method(Object, "gen_const_defs")
+% each_const {|name, default_value|
+#if defined(<%=name%>)
+% if comment = COMMENTS[name]
+ /* <%=comment%> */
+% end
+ rb_define_const(mod, <%=c_str name.sub(/\A_*/, '')%>, INTEGER2NUM(<%=name%>));
+#endif
+% }
+EOS
+
+header_result = ERB.new(<<'EOS', nil, '%').result(binding)
+/* autogenerated file */
+
+<%= gen_const_decls %>
+EOS
+
+result = ERB.new(<<'EOS', nil, '%').result(binding)
+/* autogenerated file */
+
+#ifdef HAVE_LONG_LONG
+#define INTEGER2NUM(n) \
+ (FIXNUM_MAX < (n) ? ULL2NUM(n) : \
+ FIXNUM_MIN > (LONG_LONG)(n) ? LL2NUM(n) : \
+ LONG2FIX(n))
+#else
+#define INTEGER2NUM(n) \
+ (FIXNUM_MAX < (n) ? ULONG2NUM(n) : \
+ FIXNUM_MIN > (long)(n) ? LONG2NUM(n) : \
+ LONG2FIX(n))
+#endif
+
+static void
+init_constants(VALUE mod)
+{
+<%= gen_const_defs %>
+}
+EOS
+
+if opt_H
+ File.open(opt_H, 'w') {|f|
+ f << header_result
+ }
+else
+ result = header_result + result
+end
+
+if opt_o
+ File.open(opt_o, 'w') {|f|
+ f << result
+ }
+else
+ $stdout << result
+end
+
+__END__
+# SUSv4
+_SC_AIO_LISTIO_MAX
+_SC_AIO_MAX
+_SC_AIO_PRIO_DELTA_MAX
+_SC_ARG_MAX
+_SC_ATEXIT_MAX
+_SC_BC_BASE_MAX
+_SC_BC_DIM_MAX
+_SC_BC_SCALE_MAX
+_SC_BC_STRING_MAX
+_SC_CHILD_MAX
+_SC_CLK_TCK
+_SC_COLL_WEIGHTS_MAX
+_SC_DELAYTIMER_MAX
+_SC_EXPR_NEST_MAX
+_SC_HOST_NAME_MAX
+_SC_IOV_MAX
+_SC_LINE_MAX
+_SC_LOGIN_NAME_MAX
+_SC_NGROUPS_MAX
+_SC_GETGR_R_SIZE_MAX
+_SC_GETPW_R_SIZE_MAX
+_SC_MQ_OPEN_MAX
+_SC_MQ_PRIO_MAX
+_SC_OPEN_MAX
+_SC_ADVISORY_INFO
+_SC_BARRIERS
+_SC_ASYNCHRONOUS_IO
+_SC_CLOCK_SELECTION
+_SC_CPUTIME
+_SC_FSYNC
+_SC_IPV6
+_SC_JOB_CONTROL
+_SC_MAPPED_FILES
+_SC_MEMLOCK
+_SC_MEMLOCK_RANGE
+_SC_MEMORY_PROTECTION
+_SC_MESSAGE_PASSING
+_SC_MONOTONIC_CLOCK
+_SC_PRIORITIZED_IO
+_SC_PRIORITY_SCHEDULING
+_SC_RAW_SOCKETS
+_SC_READER_WRITER_LOCKS
+_SC_REALTIME_SIGNALS
+_SC_REGEXP
+_SC_SAVED_IDS
+_SC_SEMAPHORES
+_SC_SHARED_MEMORY_OBJECTS
+_SC_SHELL
+_SC_SPAWN
+_SC_SPIN_LOCKS
+_SC_SPORADIC_SERVER
+_SC_SS_REPL_MAX
+_SC_SYNCHRONIZED_IO
+_SC_THREAD_ATTR_STACKADDR
+_SC_THREAD_ATTR_STACKSIZE
+_SC_THREAD_CPUTIME
+_SC_THREAD_PRIO_INHERIT
+_SC_THREAD_PRIO_PROTECT
+_SC_THREAD_PRIORITY_SCHEDULING
+_SC_THREAD_PROCESS_SHARED
+_SC_THREAD_ROBUST_PRIO_INHERIT
+_SC_THREAD_ROBUST_PRIO_PROTECT
+_SC_THREAD_SAFE_FUNCTIONS
+_SC_THREAD_SPORADIC_SERVER
+_SC_THREADS
+_SC_TIMEOUTS
+_SC_TIMERS
+_SC_TRACE
+_SC_TRACE_EVENT_FILTER
+_SC_TRACE_EVENT_NAME_MAX
+_SC_TRACE_INHERIT
+_SC_TRACE_LOG
+_SC_TRACE_NAME_MAX
+_SC_TRACE_SYS_MAX
+_SC_TRACE_USER_EVENT_MAX
+_SC_TYPED_MEMORY_OBJECTS
+_SC_VERSION
+_SC_V7_ILP32_OFF32
+_SC_V7_ILP32_OFFBIG
+_SC_V7_LP64_OFF64
+_SC_V7_LPBIG_OFFBIG
+_SC_V6_ILP32_OFF32
+_SC_V6_ILP32_OFFBIG
+_SC_V6_LP64_OFF64
+_SC_V6_LPBIG_OFFBIG
+_SC_2_C_BIND
+_SC_2_C_DEV
+_SC_2_CHAR_TERM
+_SC_2_FORT_DEV
+_SC_2_FORT_RUN
+_SC_2_LOCALEDEF
+_SC_2_PBS
+_SC_2_PBS_ACCOUNTING
+_SC_2_PBS_CHECKPOINT
+_SC_2_PBS_LOCATE
+_SC_2_PBS_MESSAGE
+_SC_2_PBS_TRACK
+_SC_2_SW_DEV
+_SC_2_UPE
+_SC_2_VERSION
+_SC_PAGE_SIZE
+_SC_PAGESIZE
+_SC_THREAD_DESTRUCTOR_ITERATIONS
+_SC_THREAD_KEYS_MAX
+_SC_THREAD_STACK_MIN
+_SC_THREAD_THREADS_MAX
+_SC_RE_DUP_MAX
+_SC_RTSIG_MAX
+_SC_SEM_NSEMS_MAX
+_SC_SEM_VALUE_MAX
+_SC_SIGQUEUE_MAX
+_SC_STREAM_MAX
+_SC_SYMLOOP_MAX
+_SC_TIMER_MAX
+_SC_TTY_NAME_MAX
+_SC_TZNAME_MAX
+_SC_XOPEN_CRYPT
+_SC_XOPEN_ENH_I18N
+_SC_XOPEN_REALTIME
+_SC_XOPEN_REALTIME_THREADS
+_SC_XOPEN_SHM
+_SC_XOPEN_STREAMS
+_SC_XOPEN_UNIX
+_SC_XOPEN_UUCP
+_SC_XOPEN_VERSION
+
+# non-standard
+_SC_PHYS_PAGES
+_SC_AVPHYS_PAGES
+_SC_NPROCESSORS_CONF
+_SC_NPROCESSORS_ONLN
+_SC_CPUSET_SIZE
+
+# SUSv4
+_CS_PATH
+_CS_POSIX_V7_ILP32_OFF32_CFLAGS
+_CS_POSIX_V7_ILP32_OFF32_LDFLAGS
+_CS_POSIX_V7_ILP32_OFF32_LIBS
+_CS_POSIX_V7_ILP32_OFFBIG_CFLAGS
+_CS_POSIX_V7_ILP32_OFFBIG_LDFLAGS
+_CS_POSIX_V7_ILP32_OFFBIG_LIBS
+_CS_POSIX_V7_LP64_OFF64_CFLAGS
+_CS_POSIX_V7_LP64_OFF64_LDFLAGS
+_CS_POSIX_V7_LP64_OFF64_LIBS
+_CS_POSIX_V7_LPBIG_OFFBIG_CFLAGS
+_CS_POSIX_V7_LPBIG_OFFBIG_LDFLAGS
+_CS_POSIX_V7_LPBIG_OFFBIG_LIBS
+_CS_POSIX_V7_THREADS_CFLAGS
+_CS_POSIX_V7_THREADS_LDFLAGS
+_CS_POSIX_V7_WIDTH_RESTRICTED_ENVS
+_CS_V7_ENV
+_CS_POSIX_V6_ILP32_OFF32_CFLAGS
+_CS_POSIX_V6_ILP32_OFF32_LDFLAGS
+_CS_POSIX_V6_ILP32_OFF32_LIBS
+_CS_POSIX_V6_ILP32_OFFBIG_CFLAGS
+_CS_POSIX_V6_ILP32_OFFBIG_LDFLAGS
+_CS_POSIX_V6_ILP32_OFFBIG_LIBS
+_CS_POSIX_V6_LP64_OFF64_CFLAGS
+_CS_POSIX_V6_LP64_OFF64_LDFLAGS
+_CS_POSIX_V6_LP64_OFF64_LIBS
+_CS_POSIX_V6_LPBIG_OFFBIG_CFLAGS
+_CS_POSIX_V6_LPBIG_OFFBIG_LDFLAGS
+_CS_POSIX_V6_LPBIG_OFFBIG_LIBS
+_CS_POSIX_V6_WIDTH_RESTRICTED_ENVS
+_CS_V6_ENV
+
+# non-standard
+_CS_GNU_LIBC_VERSION
+_CS_GNU_LIBPTHREAD_VERSION
+
+# SUSv4
+_PC_FILESIZEBITS
+_PC_LINK_MAX
+_PC_MAX_CANON
+_PC_MAX_INPUT
+_PC_NAME_MAX
+_PC_PATH_MAX
+_PC_PIPE_BUF
+_PC_2_SYMLINKS
+_PC_ALLOC_SIZE_MIN
+_PC_REC_INCR_XFER_SIZE
+_PC_REC_MAX_XFER_SIZE
+_PC_REC_MIN_XFER_SIZE
+_PC_REC_XFER_ALIGN
+_PC_SYMLINK_MAX
+_PC_CHOWN_RESTRICTED
+_PC_NO_TRUNC
+_PC_VDISABLE
+_PC_ASYNC_IO
+_PC_PRIO_IO
+_PC_SYNC_IO
+_PC_TIMESTAMP_RESOLUTION
+
diff --git a/jni/ruby/ext/extmk.rb b/jni/ruby/ext/extmk.rb
new file mode 100755
index 0000000..850461a
--- /dev/null
+++ b/jni/ruby/ext/extmk.rb
@@ -0,0 +1,774 @@
+#! /usr/local/bin/ruby
+# -*- mode: ruby; coding: us-ascii -*-
+
+# :stopdoc:
+$extension = nil
+$extstatic = nil
+$force_static = nil
+$install = nil
+$destdir = nil
+$dryrun = false
+$clean = nil
+$nodynamic = nil
+$extinit = nil
+$extobjs = []
+$extflags = ""
+$extlibs = nil
+$extpath = nil
+$ignore = nil
+$message = nil
+$command_output = nil
+$configure_only = false
+
+$progname = $0
+alias $PROGRAM_NAME $0
+alias $0 $progname
+
+$extlist = []
+$compiled = {}
+
+DUMMY_SIGNATURE = "***DUMMY MAKEFILE***"
+
+srcdir = File.dirname(File.dirname(__FILE__))
+unless defined?(CROSS_COMPILING) and CROSS_COMPILING
+ $:.replace([File.expand_path("lib", srcdir), Dir.pwd])
+end
+$:.unshift(srcdir)
+require 'rbconfig'
+
+$topdir = "."
+$top_srcdir = srcdir
+
+$" << "mkmf.rb"
+load File.expand_path("lib/mkmf.rb", srcdir)
+require 'optparse/shellwords'
+
+if defined?(File::NULL)
+ @null = File::NULL
+elsif !File.chardev?(@null = "/dev/null")
+ @null = "nul"
+end
+
+def sysquote(x)
+ @quote ||= /os2/ =~ (CROSS_COMPILING || RUBY_PLATFORM)
+ @quote ? x.quote : x
+end
+
+def verbose?
+ $mflags.defined?("V") == "1"
+end
+
+def system(*args)
+ if verbose?
+ if args.size == 1
+ puts args
+ else
+ puts Shellwords.join(args)
+ end
+ end
+ super
+end
+
+def atomic_write_open(filename)
+ filename_new = filename + ".new.#$$"
+ open(filename_new, "wb") do |f|
+ yield f
+ end
+ if File.binread(filename_new) != (File.binread(filename) rescue nil)
+ File.rename(filename_new, filename)
+ else
+ File.unlink(filename_new)
+ end
+end
+
+def extract_makefile(makefile, keep = true)
+ m = File.read(makefile)
+ if !(target = m[/^TARGET[ \t]*=[ \t]*(\S*)/, 1])
+ return keep
+ end
+ installrb = {}
+ m.scan(/^install-rb-default:.*[ \t](\S+)(?:[ \t].*)?\n\1:[ \t]*(\S+)/) {installrb[$2] = $1}
+ oldrb = installrb.keys.sort
+ newrb = install_rb(nil, "").collect {|d, *f| f}.flatten.sort
+ if target_prefix = m[/^target_prefix[ \t]*=[ \t]*\/(.*)/, 1]
+ target = "#{target_prefix}/#{target}"
+ end
+ unless oldrb == newrb
+ if $extout
+ newrb.each {|f| installrb.delete(f)}
+ unless installrb.empty?
+ config = CONFIG.dup
+ install_dirs(target_prefix).each {|var, val| config[var] = val}
+ FileUtils.rm_f(installrb.values.collect {|f| RbConfig.expand(f, config)},
+ :verbose => verbose?)
+ end
+ end
+ return false
+ end
+ srcs = Dir[File.join($srcdir, "*.{#{SRC_EXT.join(%q{,})}}")].map {|fn| File.basename(fn)}.sort
+ if !srcs.empty?
+ old_srcs = m[/^ORIG_SRCS[ \t]*=[ \t](.*)/, 1] or return false
+ old_srcs.split.sort == srcs or return false
+ end
+ $target = target
+ $extconf_h = m[/^RUBY_EXTCONF_H[ \t]*=[ \t]*(\S+)/, 1]
+ if $static.nil?
+ $static ||= m[/^EXTSTATIC[ \t]*=[ \t]*(\S+)/, 1] || false
+ /^STATIC_LIB[ \t]*=[ \t]*\S+/ =~ m or $static = false
+ end
+ $preload = Shellwords.shellwords(m[/^preload[ \t]*=[ \t]*(.*)/, 1] || "")
+ if dldflags = m[/^dldflags[ \t]*=[ \t]*(.*)/, 1] and !$DLDFLAGS.include?(dldflags)
+ $DLDFLAGS += " " + dldflags
+ end
+ if s = m[/^LIBS[ \t]*=[ \t]*(.*)/, 1]
+ s.sub!(/^#{Regexp.quote($LIBRUBYARG)} */, "")
+ s.sub!(/ *#{Regexp.quote($LIBS)}$/, "")
+ $libs = s
+ end
+ $objs = (m[/^OBJS[ \t]*=[ \t](.*)/, 1] || "").split
+ $srcs = (m[/^SRCS[ \t]*=[ \t](.*)/, 1] || "").split
+ $distcleanfiles = (m[/^DISTCLEANFILES[ \t]*=[ \t](.*)/, 1] || "").split
+ $LOCAL_LIBS = m[/^LOCAL_LIBS[ \t]*=[ \t]*(.*)/, 1] || ""
+ $LIBPATH = Shellwords.shellwords(m[/^libpath[ \t]*=[ \t]*(.*)/, 1] || "") - %w[$(libdir) $(topdir)]
+ true
+end
+
+def extmake(target)
+ unless $configure_only || verbose?
+ print "#{$message} #{target}\n"
+ $stdout.flush
+ end
+
+ FileUtils.mkpath target unless File.directory?(target)
+ begin
+ # don't build if parent library isn't build
+ parent = true
+ d = target
+ until (d = File.dirname(d)) == '.'
+ if File.exist?("#{$top_srcdir}/ext/#{d}/extconf.rb")
+ parent = (/^all:\s*install/ =~ IO.read("#{d}/Makefile") rescue false)
+ break
+ end
+ end
+
+ dir = Dir.pwd
+ FileUtils.mkpath target unless File.directory?(target)
+ Dir.chdir target
+ top_srcdir = $top_srcdir
+ topdir = $topdir
+ hdrdir = $hdrdir
+ prefix = "../" * (target.count("/")+1)
+ $top_srcdir = relative_from(top_srcdir, prefix)
+ $hdrdir = relative_from(hdrdir, prefix)
+ $topdir = prefix + $topdir
+ $target = target
+ $mdir = target
+ $srcdir = File.join($top_srcdir, "ext", $mdir)
+ $preload = nil
+ $objs = []
+ $srcs = []
+ $compiled[target] = false
+ makefile = "./Makefile"
+ static = $static
+ $static = nil if noinstall = File.fnmatch?("-*", target)
+ ok = parent && File.exist?(makefile)
+ if parent && !$ignore
+ rbconfig0 = RbConfig::CONFIG
+ mkconfig0 = CONFIG
+ rbconfig = {
+ "hdrdir" => $hdrdir,
+ "srcdir" => $srcdir,
+ "topdir" => $topdir,
+ }
+ mkconfig = {
+ "hdrdir" => ($hdrdir == top_srcdir) ? top_srcdir : "$(top_srcdir)/include",
+ "srcdir" => "$(top_srcdir)/ext/#{$mdir}",
+ "topdir" => $topdir,
+ }
+ rbconfig0.each_pair {|key, val| rbconfig[key] ||= val.dup}
+ mkconfig0.each_pair {|key, val| mkconfig[key] ||= val.dup}
+ RbConfig.module_eval {
+ remove_const(:CONFIG)
+ const_set(:CONFIG, rbconfig)
+ remove_const(:MAKEFILE_CONFIG)
+ const_set(:MAKEFILE_CONFIG, mkconfig)
+ }
+ MakeMakefile.class_eval {
+ remove_const(:CONFIG)
+ const_set(:CONFIG, mkconfig)
+ }
+ begin
+ $extconf_h = nil
+ ok &&= extract_makefile(makefile)
+ old_objs = $objs
+ old_cleanfiles = $distcleanfiles
+ conf = ["#{$srcdir}/makefile.rb", "#{$srcdir}/extconf.rb"].find {|f| File.exist?(f)}
+ if (!ok || ($extconf_h && !File.exist?($extconf_h)) ||
+ !(t = modified?(makefile, MTIMES)) ||
+ [conf, "#{$srcdir}/depend"].any? {|f| modified?(f, [t])})
+ then
+ ok = false
+ if $configure_only
+ if verbose?
+ print "#{conf}\n" if conf
+ else
+ print "#{$message} #{target}\n"
+ end
+ $stdout.flush
+ end
+ init_mkmf
+ Logging::logfile 'mkmf.log'
+ rm_f makefile
+ if conf
+ Logging.open do
+ unless verbose?
+ $stderr.reopen($stdout.reopen(@null))
+ end
+ load $0 = conf
+ end
+ else
+ create_makefile(target)
+ end
+ $defs << "-DRUBY_EXPORT" if $static
+ ok = File.exist?(makefile)
+ end
+ rescue SystemExit
+ # ignore
+ rescue => error
+ ok = false
+ ensure
+ rm_f "conftest*"
+ $0 = $PROGRAM_NAME
+ end
+ end
+ ok &&= File.open(makefile){|f| s = f.gets and !s[DUMMY_SIGNATURE]}
+ ok = yield(ok) if block_given?
+ if ok
+ open(makefile, "r+b") do |f|
+ s = f.read.sub!(/^(static:)\s(?!all\b).*/, '\1 all') or break
+ f.rewind
+ f.print(s)
+ f.truncate(f.pos)
+ end unless $static
+ else
+ atomic_write_open(makefile) do |f|
+ f.puts "# " + DUMMY_SIGNATURE
+ f.print(*dummy_makefile(CONFIG["srcdir"]))
+ end
+
+ mess = "Failed to configure #{target}. It will not be installed.\n"
+ if error
+ mess = "#{error}\n#{mess}"
+ end
+
+ Logging::message(mess) if Logging.log_opened?
+ print(mess)
+ $stdout.flush
+ return true
+ end
+ args = sysquote($mflags)
+ unless $destdir.to_s.empty? or $mflags.defined?("DESTDIR")
+ args += [sysquote("DESTDIR=" + relative_from($destdir, "../"+prefix))]
+ end
+ if $static and ok and !$objs.empty? and !noinstall
+ args += ["static"] unless $clean
+ $extlist.push [$static, target, $target, $preload]
+ end
+ FileUtils.rm_f(old_cleanfiles - $distcleanfiles)
+ FileUtils.rm_f(old_objs - $objs)
+ unless $configure_only or system($make, *args)
+ $ignore or $continue or return false
+ end
+ $compiled[target] = true
+ if $clean
+ FileUtils.rm_f("mkmf.log")
+ if $clean != true
+ FileUtils.rm_f([makefile, $extconf_h || "extconf.h"])
+ end
+ end
+ if $static
+ $extflags ||= ""
+ $extlibs ||= []
+ $extpath ||= []
+ unless $mswin
+ $extflags = split_libs($extflags, $DLDFLAGS, $LDFLAGS).uniq.join(" ")
+ end
+ $extlibs = merge_libs($extlibs, split_libs($libs, $LOCAL_LIBS).map {|lib| lib.sub(/\A\.\//, "ext/#{target}/")})
+ $extpath |= $LIBPATH
+ end
+ ensure
+ Logging::log_close
+ if rbconfig0
+ RbConfig.module_eval {
+ remove_const(:CONFIG)
+ const_set(:CONFIG, rbconfig0)
+ remove_const(:MAKEFILE_CONFIG)
+ const_set(:MAKEFILE_CONFIG, mkconfig0)
+ }
+ end
+ if mkconfig0
+ MakeMakefile.class_eval {
+ remove_const(:CONFIG)
+ const_set(:CONFIG, mkconfig0)
+ }
+ end
+ $top_srcdir = top_srcdir
+ $topdir = topdir
+ $hdrdir = hdrdir
+ $static = static
+ Dir.chdir dir
+ end
+ begin
+ Dir.rmdir target
+ target = File.dirname(target)
+ rescue SystemCallError
+ break
+ end while true
+ true
+end
+
+def compiled?(target)
+ $compiled[target]
+end
+
+def parse_args()
+ $mflags = []
+ $makeflags = [] # for make command to build ruby, so quoted
+
+ $optparser ||= OptionParser.new do |opts|
+ opts.on('-n') {$dryrun = true}
+ opts.on('--[no-]extension [EXTS]', Array) do |v|
+ $extension = (v == false ? [] : v)
+ end
+ opts.on('--[no-]extstatic [STATIC]', Array) do |v|
+ if ($extstatic = v) == false
+ $extstatic = []
+ elsif v
+ $force_static = true if $extstatic.delete("static")
+ $extstatic = nil if $extstatic.empty?
+ end
+ end
+ opts.on('--dest-dir=DIR') do |v|
+ $destdir = v
+ end
+ opts.on('--extout=DIR') do |v|
+ $extout = (v unless v.empty?)
+ end
+ opts.on('--make=MAKE') do |v|
+ $make = v || 'make'
+ end
+ opts.on('--make-flags=FLAGS', '--mflags', Shellwords) do |v|
+ v.grep(/\A([-\w]+)=(.*)/) {$configure_args["--#{$1}"] = $2}
+ if arg = v.first
+ arg.insert(0, '-') if /\A[^-][^=]*\Z/ =~ arg
+ end
+ $makeflags.concat(v.reject {|arg2| /\AMINIRUBY=/ =~ arg2}.quote)
+ $mflags.concat(v)
+ end
+ opts.on('--message [MESSAGE]', String) do |v|
+ $message = v
+ end
+ opts.on('--command-output=FILE', String) do |v|
+ $command_output = v
+ end
+ opts.on('--gnumake=yes|no', true) do |v|
+ $gnumake = v
+ end
+ end
+ begin
+ $optparser.parse!(ARGV)
+ rescue OptionParser::InvalidOption => e
+ retry if /^--/ =~ e.args[0]
+ $optparser.warn(e)
+ abort $optparser.to_s
+ end
+
+ $destdir ||= ''
+
+ $make, *rest = Shellwords.shellwords($make)
+ $mflags.unshift(*rest) unless rest.empty?
+
+ def $mflags.set?(flag)
+ grep(/\A-(?!-).*#{flag.chr}/i) { return true }
+ false
+ end
+ def $mflags.defined?(var)
+ grep(/\A#{var}=(.*)/) {return $1}
+ false
+ end
+
+ if $mflags.set?(?n)
+ $dryrun = true
+ else
+ $mflags.unshift '-n' if $dryrun
+ end
+
+ $continue = $mflags.set?(?k)
+ if $extout
+ $extout = '$(topdir)/'+$extout
+ RbConfig::CONFIG["extout"] = CONFIG["extout"] = $extout
+ $extout_prefix = $extout ? "$(extout)$(target_prefix)/" : ""
+ $mflags << "extout=#$extout" << "extout_prefix=#$extout_prefix"
+ end
+end
+
+parse_args()
+
+if target = ARGV.shift and /^[a-z-]+$/ =~ target
+ $mflags.push(target)
+ case target
+ when /^(dist|real)?(clean)$/
+ target = $2
+ $ignore ||= true
+ $clean = $1 ? $1[0] : true
+ when /^install\b/
+ $install = true
+ $ignore ||= true
+ $mflags.unshift("INSTALL_PROG=install -c -p -m 0755",
+ "INSTALL_DATA=install -c -p -m 0644",
+ "MAKEDIRS=mkdir -p") if $dryrun
+ when /configure/
+ $configure_only = true
+ end
+end
+unless $message
+ if target
+ $message = target.sub(/^(\w+?)e?\b/, '\1ing').tr('-', ' ')
+ else
+ $message = "compiling"
+ end
+end
+
+EXEEXT = CONFIG['EXEEXT']
+if CROSS_COMPILING
+ $ruby = $mflags.defined?("MINIRUBY") || CONFIG['MINIRUBY']
+elsif sep = config_string('BUILD_FILE_SEPARATOR')
+ $ruby = "$(topdir:/=#{sep})#{sep}miniruby" + EXEEXT
+else
+ $ruby = '$(topdir)/miniruby' + EXEEXT
+end
+$ruby << " -I'$(topdir)'"
+unless CROSS_COMPILING
+ $ruby << " -I'$(top_srcdir)/lib'"
+ $ruby << " -I'$(extout)/$(arch)' -I'$(extout)/common'" if $extout
+ ENV["RUBYLIB"] = "-"
+end
+$mflags << "ruby=#$ruby"
+
+MTIMES = [__FILE__, 'rbconfig.rb', srcdir+'/lib/mkmf.rb'].collect {|f| File.mtime(f)}
+
+# get static-link modules
+$static_ext = {}
+if $extstatic
+ $extstatic.each do |t|
+ target = t
+ target = target.downcase if File::FNM_SYSCASE.nonzero?
+ $static_ext[target] = $static_ext.size
+ end
+end
+for dir in ["ext", File::join($top_srcdir, "ext")]
+ setup = File::join(dir, CONFIG['setup'])
+ if File.file? setup
+ f = open(setup)
+ while line = f.gets()
+ line.chomp!
+ line.sub!(/#.*$/, '')
+ next if /^\s*$/ =~ line
+ target, opt = line.split(nil, 3)
+ if target == 'option'
+ case opt
+ when 'nodynamic'
+ $nodynamic = true
+ end
+ next
+ end
+ target = target.downcase if File::FNM_SYSCASE.nonzero?
+ $static_ext[target] = $static_ext.size
+ end
+ MTIMES << f.mtime
+ $setup = setup
+ f.close
+ break
+ end
+end unless $extstatic
+
+ext_prefix = "#{$top_srcdir}/ext"
+exts = $static_ext.sort_by {|t, i| i}.collect {|t, i| t}
+withes, withouts = %w[--with --without].collect {|w|
+ if !(w = %w[-extensions -ext].collect {|o|arg_config(w+o)}).any?
+ nil
+ elsif (w = w.grep(String)).empty?
+ proc {true}
+ else
+ proc {|c1| w.collect {|o| o.split(/,/)}.flatten.any?(&c1)}
+ end
+}
+if withes
+ withouts ||= proc {true}
+else
+ withes = proc {false}
+ withouts ||= withes
+end
+cond = proc {|ext, *|
+ cond1 = proc {|n| File.fnmatch(n, ext)}
+ withes.call(cond1) or !withouts.call(cond1)
+}
+($extension || %w[*]).each do |e|
+ e = e.sub(/\A(?:\.\/)+/, '')
+ exts |= Dir.glob("#{ext_prefix}/#{e}/**/extconf.rb").collect {|d|
+ d = File.dirname(d)
+ d.slice!(0, ext_prefix.length + 1)
+ d
+ }.find_all {|ext|
+ with_config(ext, &cond)
+ }.sort
+ if $LIBRUBYARG_SHARED.empty? and CONFIG["EXTSTATIC"] == "static"
+ exts.delete_if {|d| File.fnmatch?("-*", d)}
+ end
+end
+
+if $extout
+ extout = RbConfig.expand("#{$extout}", RbConfig::CONFIG.merge("topdir"=>$topdir))
+ unless $ignore
+ FileUtils.mkpath(extout)
+ end
+end
+
+dir = Dir.pwd
+FileUtils::makedirs('ext')
+Dir::chdir('ext')
+
+hdrdir = $hdrdir
+$hdrdir = ($top_srcdir = relative_from(srcdir, $topdir = "..")) + "/include"
+exts.each do |d|
+ $static = $force_static ? true : $static_ext[d]
+
+ if $ignore or !$nodynamic or $static
+ extmake(d) or abort
+ end
+end
+
+$top_srcdir = srcdir
+$topdir = "."
+$hdrdir = hdrdir
+
+extinit = Struct.new(:c, :o) {
+ def initialize(src)
+ super("#{src}.c", "#{src}.#{$OBJEXT}")
+ end
+}.new("extinit")
+if $ignore
+ FileUtils.rm_f(extinit.to_a) if $clean
+ Dir.chdir ".."
+ if $clean
+ Dir.rmdir('ext') rescue nil
+ if $extout
+ FileUtils.rm_rf([extout+"/common", extout+"/include/ruby", extout+"/rdoc"])
+ FileUtils.rm_rf(extout+"/"+CONFIG["arch"])
+ if $clean != true
+ FileUtils.rm_rf(extout+"/include/"+CONFIG["arch"])
+ FileUtils.rm_f($mflags.defined?("INSTALLED_LIST")||ENV["INSTALLED_LIST"]||".installed.list")
+ Dir.rmdir(extout+"/include") rescue nil
+ Dir.rmdir(extout) rescue nil
+ end
+ end
+ end
+ exit
+end
+
+$extinit ||= ""
+$extobjs ||= []
+$extpath ||= []
+$extflags ||= ""
+$extlibs ||= []
+unless $extlist.empty?
+ $extinit << "\n" unless $extinit.empty?
+ list = $extlist.dup
+ built = []
+ while e = list.shift
+ _, target, feature, required = e
+ if required and !(required -= built).empty?
+ l = list.size
+ if (while l > 0; break true if required.include?(list[l-=1][1]) end)
+ list.insert(l + 1, e)
+ end
+ next
+ end
+ base = File.basename(feature)
+ $extinit << " init(Init_#{base}, \"#{feature}.so\");\n"
+ $extobjs << format("ext/%s/%s.%s", target, base, $LIBEXT)
+ built << target
+ end
+
+ src = %{\
+#include "ruby/ruby.h"
+
+#define init(func, name) { \\
+ extern void func(void); \\
+ ruby_init_ext(name, func); \\
+}
+
+void ruby_init_ext(const char *name, void (*init)(void));
+
+void Init_ext(void)\n{\n#$extinit}
+}
+ if !modified?(extinit.c, MTIMES) || IO.read(extinit.c) != src
+ open(extinit.c, "w") {|fe| fe.print src}
+ end
+
+ if RUBY_PLATFORM =~ /beos/
+ $extflags.delete("-L/usr/local/lib")
+ end
+ $extpath.delete("$(topdir)")
+ $extflags = libpathflag($extpath) << " " << $extflags.strip
+ conf = [
+ ['LIBRUBY_SO_UPDATE', '$(LIBRUBY_EXTS)'],
+ ['SETUP', $setup],
+ ['EXTLIBS', $extlibs.join(' ')], ['EXTLDFLAGS', $extflags]
+ ].map {|n, v|
+ "#{n}=#{v}" if v and !(v = v.strip).empty?
+ }.compact
+ puts(*conf)
+ $stdout.flush
+ $mflags.concat(conf)
+ $makeflags.concat(conf)
+else
+ FileUtils.rm_f(extinit.to_a)
+end
+rubies = []
+%w[RUBY RUBYW STATIC_RUBY].each {|n|
+ r = n
+ if r = arg_config("--"+r.downcase) || config_string(r+"_INSTALL_NAME")
+ rubies << RbConfig.expand(r+=EXEEXT)
+ $mflags << "#{n}=#{r}"
+ end
+}
+
+Dir.chdir ".."
+unless $destdir.to_s.empty?
+ $mflags.defined?("DESTDIR") or $mflags << "DESTDIR=#{$destdir}"
+end
+$makeflags.uniq!
+
+if $nmake == ?b
+ unless (vars = $mflags.grep(/\A\w+=/n)).empty?
+ open(mkf = "libruby.mk", "wb") do |tmf|
+ tmf.puts("!include Makefile")
+ tmf.puts
+ tmf.puts(*vars.map {|v| v.sub(/\=/, " = ")})
+ tmf.puts("PRE_LIBRUBY_UPDATE = del #{mkf}")
+ end
+ $mflags.unshift("-f#{mkf}")
+ vars.each {|flag| flag.sub!(/\A/, "-D")}
+ end
+end
+$mflags.unshift("topdir=#$topdir")
+ENV.delete("RUBYOPT")
+if $configure_only and $command_output
+ exts.map! {|d| "ext/#{d}/."}
+ atomic_write_open($command_output) do |mf|
+ mf.puts "V = 0"
+ mf.puts "Q1 = $(V:1=)"
+ mf.puts "Q = $(Q1:0=@)"
+ mf.puts "ECHO1 = $(V:1=@:)"
+ mf.puts "ECHO = $(ECHO1:0=@echo)"
+ mf.puts "MFLAGS = -$(MAKEFLAGS)" if $nmake
+ mf.puts
+
+ def mf.macro(name, values, max = 70)
+ print name, " ="
+ w = w0 = name.size + 2
+ h = " \\\n" + "\t" * (w / 8) + " " * (w % 8)
+ values.each do |s|
+ if s.size + w > max
+ print h
+ w = w0
+ end
+ print " ", s
+ w += s.size + 1
+ end
+ puts
+ end
+
+ mf.macro "extensions", exts
+ mf.macro "EXTOBJS", $extlist.empty? ? ["dmyext.#{$OBJEXT}"] : ["ext/extinit.#{$OBJEXT}", *$extobjs]
+ mf.macro "EXTLIBS", $extlibs
+ mf.macro "EXTLDFLAGS", $extflags.split
+ submakeopts = []
+ if enable_config("shared", $enable_shared)
+ submakeopts << 'DLDOBJS="$(EXTOBJS) $(ENCOBJS)"'
+ submakeopts << 'EXTOBJS='
+ submakeopts << 'EXTSOLIBS="$(EXTLIBS)"'
+ submakeopts << 'LIBRUBY_SO_UPDATE=$(LIBRUBY_EXTS)'
+ else
+ submakeopts << 'EXTOBJS="$(EXTOBJS) $(ENCOBJS)"'
+ submakeopts << 'EXTLIBS="$(EXTLIBS)"'
+ end
+ submakeopts << 'EXTLDFLAGS="$(EXTLDFLAGS)"'
+ submakeopts << 'UPDATE_LIBRARIES="$(UPDATE_LIBRARIES)"'
+ mf.macro "SUBMAKEOPTS", submakeopts
+ mf.puts
+ targets = %w[all install static install-so install-rb clean distclean realclean]
+ targets.each do |tgt|
+ mf.puts "#{tgt}: $(extensions:/.=/#{tgt})"
+ end
+ mf.puts
+ mf.puts "clean:\n\t-$(Q)$(RM) ext/extinit.#{$OBJEXT}"
+ mf.puts "distclean:\n\t-$(Q)$(RM) ext/extinit.c"
+ mf.puts
+ mf.puts "#{rubies.join(' ')}: $(extensions:/.=/#{$force_static ? 'static' : 'all'})"
+ submake = "$(Q)$(MAKE) $(MFLAGS) $(SUBMAKEOPTS)"
+ mf.puts "all static: $(EXTOBJS)\n\t#{submake} #{rubies.join(' ')}\n"
+ $extobjs.each do |tgt|
+ mf.puts "#{tgt}: #{File.dirname(tgt)}/static"
+ end
+ mf.puts "#{rubies.join(' ')}: $(EXTOBJS)"
+ rubies.each do |tgt|
+ mf.puts "#{tgt}:\n\t#{submake} $@"
+ end
+ mf.puts "ext/extinit.#{$OBJEXT}:\n\t$(Q)$(MAKE) $(MFLAGS) V=$(V) $@" if $static
+ mf.puts
+ if $gnumake == "yes"
+ submake = "$(MAKE) -C $(@D)"
+ else
+ submake = "cd $(@D) && "
+ config_string("exec") {|str| submake << str << " "}
+ submake << "$(MAKE)"
+ end
+ targets.each do |tgt|
+ exts.each do |d|
+ mf.puts "#{d[0..-2]}#{tgt}:\n\t$(Q)#{submake} $(MFLAGS) V=$(V) $(@F)"
+ end
+ end
+ end
+elsif $command_output
+ message = "making #{rubies.join(', ')}"
+ message = "echo #{message}"
+ $mflags.concat(rubies)
+ $makeflags.concat(rubies)
+ cmd = $makeflags.map {|ss|ss.sub(/.*[$(){};\s].*/, %q['\&'])}.join(' ')
+ open($command_output, 'wb') do |ff|
+ case $command_output
+ when /\.sh\z/
+ ff.puts message, "rm -f \"$0\"; exec \"$@\" #{cmd}"
+ when /\.bat\z/
+ ["@echo off", message, "%* #{cmd}", "del %0 & exit %ERRORLEVEL%"].each do |ss|
+ ff.print ss, "\r\n"
+ end
+ else
+ ff.puts cmd
+ end
+ ff.chmod(0755)
+ end
+elsif !$configure_only
+ message = "making #{rubies.join(', ')}"
+ puts message
+ $stdout.flush
+ $mflags.concat(rubies)
+ system($make, *sysquote($mflags)) or exit($?.exitstatus)
+end
+# :startdoc:
+
+#Local variables:
+# mode: ruby
+#end:
diff --git a/jni/ruby/ext/fcntl/Makefile b/jni/ruby/ext/fcntl/Makefile
new file mode 100644
index 0000000..d018090
--- /dev/null
+++ b/jni/ruby/ext/fcntl/Makefile
@@ -0,0 +1,267 @@
+
+SHELL = /bin/sh
+
+# V=0 quiet, V=1 verbose. other values don't work.
+V = 0
+Q1 = $(V:1=)
+Q = $(Q1:0=@)
+ECHO1 = $(V:1=@:)
+ECHO = $(ECHO1:0=@echo)
+NULLCMD = :
+
+#### Start of system configuration section. ####
+top_srcdir = $(topdir)/.
+srcdir = $(top_srcdir)/ext/fcntl
+topdir = ../..
+hdrdir = $(top_srcdir)/include
+arch_hdrdir = $(extout)/include/$(arch)
+PATH_SEPARATOR = :
+VPATH = $(srcdir):$(arch_hdrdir)/ruby:$(hdrdir)/ruby
+RUBYLIB =
+RUBYOPT = -
+prefix = $(DESTDIR)/usr/local
+rubysitearchprefix = $(rubylibprefix)/$(sitearch)
+rubyarchprefix = $(rubylibprefix)/$(arch)
+rubylibprefix = $(libdir)/$(RUBY_BASE_NAME)
+exec_prefix = $(prefix)
+vendorarchhdrdir = $(vendorhdrdir)/$(sitearch)
+sitearchhdrdir = $(sitehdrdir)/$(sitearch)
+rubyarchhdrdir = $(rubyhdrdir)/$(arch)
+vendorhdrdir = $(rubyhdrdir)/vendor_ruby
+sitehdrdir = $(rubyhdrdir)/site_ruby
+rubyhdrdir = $(includedir)/$(RUBY_VERSION_NAME)
+vendorarchdir = $(vendorlibdir)/$(sitearch)
+vendorlibdir = $(vendordir)/$(ruby_version)
+vendordir = $(rubylibprefix)/vendor_ruby
+sitearchdir = $(sitelibdir)/$(sitearch)
+sitelibdir = $(sitedir)/$(ruby_version)
+sitedir = $(rubylibprefix)/site_ruby
+rubyarchdir = $(rubylibdir)/$(arch)
+rubylibdir = $(rubylibprefix)/$(ruby_version)
+sitearchincludedir = $(includedir)/$(sitearch)
+archincludedir = $(includedir)/$(arch)
+sitearchlibdir = $(libdir)/$(sitearch)
+archlibdir = $(libdir)/$(arch)
+ridir = $(datarootdir)/$(RI_BASE_NAME)
+mandir = $(datarootdir)/man
+localedir = $(datarootdir)/locale
+libdir = $(exec_prefix)/lib
+psdir = $(docdir)
+pdfdir = $(docdir)
+dvidir = $(docdir)
+htmldir = $(docdir)
+infodir = $(datarootdir)/info
+docdir = $(datarootdir)/doc/$(PACKAGE)
+oldincludedir = $(DESTDIR)/usr/include
+includedir = $(prefix)/include
+localstatedir = $(prefix)/var
+sharedstatedir = $(prefix)/com
+sysconfdir = $(prefix)/etc
+datadir = $(datarootdir)
+datarootdir = $(prefix)/share
+libexecdir = $(exec_prefix)/libexec
+sbindir = $(exec_prefix)/sbin
+bindir = $(exec_prefix)/bin
+archdir = $(rubyarchdir)
+
+
+CC = gcc
+CXX = g++
+LIBRUBY = $(LIBRUBY_SO)
+LIBRUBY_A = lib$(RUBY_SO_NAME)-static.a
+LIBRUBYARG_SHARED = -Wl,-R$(libdir) -L$(libdir) -l$(RUBY_SO_NAME)
+LIBRUBYARG_STATIC = -Wl,-R$(libdir) -L$(libdir) -l$(RUBY_SO_NAME)-static
+empty =
+OUTFLAG = -o $(empty)
+COUTFLAG = -o $(empty)
+
+RUBY_EXTCONF_H = extconf.h
+cflags = $(optflags) $(debugflags) $(warnflags)
+optflags = -O3 -fno-fast-math
+debugflags = -ggdb3
+warnflags = -Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wunused-variable -Wpointer-arith -Wwrite-strings -Wdeclaration-after-statement -Wimplicit-function-declaration -Wdeprecated-declarations -Wno-packed-bitfield-compat
+CCDLFLAGS = -fPIC
+CFLAGS = $(CCDLFLAGS) $(cflags) -fPIC $(ARCH_FLAG)
+INCFLAGS = -I. -I$(arch_hdrdir) -I$(hdrdir) -I$(srcdir)
+DEFS =
+CPPFLAGS = -DRUBY_EXTCONF_H=\"$(RUBY_EXTCONF_H)\" $(DEFS) $(cppflags)
+CXXFLAGS = $(CCDLFLAGS) $(cxxflags) $(ARCH_FLAG)
+ldflags = -L. -fstack-protector -rdynamic -Wl,-export-dynamic
+dldflags =
+ARCH_FLAG =
+DLDFLAGS = $(ldflags) $(dldflags) $(ARCH_FLAG)
+LDSHARED = $(CC) -shared
+LDSHAREDXX = $(CXX) -shared
+AR = ar
+EXEEXT =
+
+RUBY_INSTALL_NAME = $(RUBY_BASE_NAME)
+RUBY_SO_NAME = ruby
+RUBYW_INSTALL_NAME =
+RUBY_VERSION_NAME = $(RUBY_BASE_NAME)-$(ruby_version)
+RUBYW_BASE_NAME = rubyw
+RUBY_BASE_NAME = ruby
+
+arch = x86_64-linux
+sitearch = $(arch)
+ruby_version = 2.2.0
+ruby = $(topdir)/miniruby -I'$(topdir)' -I'$(top_srcdir)/lib' -I'$(extout)/$(arch)' -I'$(extout)/common'
+RUBY = $(ruby)
+ruby_headers = $(hdrdir)/ruby.h $(hdrdir)/ruby/ruby.h $(hdrdir)/ruby/defines.h $(hdrdir)/ruby/missing.h $(hdrdir)/ruby/intern.h $(hdrdir)/ruby/st.h $(hdrdir)/ruby/subst.h $(arch_hdrdir)/ruby/config.h $(RUBY_EXTCONF_H)
+
+RM = rm -f
+RM_RF = $(RUBY) -run -e rm -- -rf
+RMDIRS = rmdir --ignore-fail-on-non-empty -p
+MAKEDIRS = /bin/mkdir -p
+INSTALL = /usr/bin/install -c
+INSTALL_PROG = $(INSTALL) -m 0755
+INSTALL_DATA = $(INSTALL) -m 644
+COPY = cp
+TOUCH = exit >
+
+#### End of system configuration section. ####
+
+preload =
+
+libpath = . $(topdir)
+LIBPATH = -L. -L$(topdir)
+DEFFILE =
+
+CLEANFILES = mkmf.log
+DISTCLEANFILES =
+DISTCLEANDIRS =
+
+extout = $(topdir)/.ext
+extout_prefix = $(extout)$(target_prefix)/
+target_prefix =
+LOCAL_LIBS =
+LIBS = $(LIBRUBYARG_SHARED) -lpthread -lgmp -ldl -lcrypt -lm -lc
+ORIG_SRCS = fcntl.c
+SRCS = $(ORIG_SRCS)
+OBJS = fcntl.o
+HDRS = $(srcdir)/extconf.h
+TARGET = fcntl
+TARGET_NAME = fcntl
+TARGET_ENTRY = Init_$(TARGET_NAME)
+DLLIB = $(TARGET).so
+EXTSTATIC =
+STATIC_LIB = $(TARGET).a
+
+TIMESTAMP_DIR = $(extout)/.timestamp
+BINDIR = $(extout)/bin
+RUBYCOMMONDIR = $(extout)/common
+RUBYLIBDIR = $(RUBYCOMMONDIR)$(target_prefix)
+RUBYARCHDIR = $(extout)/$(arch)$(target_prefix)
+HDRDIR = $(extout)/include/ruby$(target_prefix)
+ARCHHDRDIR = $(extout)/include/$(arch)/ruby$(target_prefix)
+
+TARGET_SO = $(RUBYARCHDIR)/$(DLLIB)
+CLEANLIBS = $(RUBYARCHDIR)/$(TARGET).so
+CLEANOBJS = *.o *.bak
+
+all: install
+static: all
+.PHONY: all install static install-so install-rb
+.PHONY: clean clean-so clean-static clean-rb
+
+clean-static::
+clean-rb-default::
+clean-rb::
+clean-so::
+clean: clean-so clean-static clean-rb-default clean-rb
+ -$(Q)$(RM) $(CLEANLIBS) $(CLEANOBJS) $(CLEANFILES) .*.time
+
+distclean-rb-default::
+distclean-rb::
+distclean-so::
+distclean-static::
+distclean: clean distclean-so distclean-static distclean-rb-default distclean-rb
+ -$(Q)$(RM) Makefile $(RUBY_EXTCONF_H) conftest.* mkmf.log
+ -$(Q)$(RM) core ruby$(EXEEXT) *~ $(DISTCLEANFILES)
+ -$(Q)$(RMDIRS) $(DISTCLEANDIRS) 2> /dev/null || true
+
+realclean: distclean
+install: install-so install-rb
+
+install-so: $(RUBYARCHDIR)/$(DLLIB)
+clean-so::
+ -$(Q)$(RM) $(RUBYARCHDIR)/$(DLLIB)
+ -$(Q)$(RMDIRS) $(RUBYARCHDIR) 2> /dev/null || true
+clean-static::
+ -$(Q)$(RM) $(STATIC_LIB)
+install-rb: pre-install-rb install-rb-default
+install-rb-default: pre-install-rb-default
+pre-install-rb: Makefile
+pre-install-rb-default: Makefile
+pre-install-rb-default:
+ @$(NULLCMD)
+$(TIMESTAMP_DIR)/.RUBYARCHDIR.time:
+ $(Q) $(MAKEDIRS) $(@D) $(RUBYARCHDIR)
+ $(Q) $(TOUCH) $@
+
+site-install: site-install-so site-install-rb
+site-install-so: install-so
+site-install-rb: install-rb
+
+.SUFFIXES: .c .m .cc .mm .cxx .cpp .o .S
+
+.cc.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<
+
+.cc.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -S $<
+
+.mm.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<
+
+.mm.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -S $<
+
+.cxx.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<
+
+.cxx.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -S $<
+
+.cpp.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<
+
+.cpp.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -S $<
+
+.c.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -c $<
+
+.c.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -S $<
+
+.m.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -c $<
+
+.m.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -S $<
+
+$(RUBYARCHDIR)/$(DLLIB): $(OBJS) Makefile $(TIMESTAMP_DIR)/.RUBYARCHDIR.time
+ $(ECHO) linking shared-object $(DLLIB)
+ -$(Q)$(RM) $(@)
+ $(Q) $(LDSHARED) -o $@ $(OBJS) $(LIBPATH) $(DLDFLAGS) $(LOCAL_LIBS) $(LIBS)
+
+$(STATIC_LIB): $(OBJS)
+ -$(Q)$(RM) $(@)
+ $(ECHO) linking static-library $(@)
+ $(Q) $(AR) cru $@ $(OBJS)
+ -$(Q)ranlib $(@) 2> /dev/null || true
+
+$(OBJS): $(HDRS) $(ruby_headers)
diff --git a/jni/ruby/ext/fcntl/extconf.h b/jni/ruby/ext/fcntl/extconf.h
new file mode 100644
index 0000000..cda0cc8
--- /dev/null
+++ b/jni/ruby/ext/fcntl/extconf.h
@@ -0,0 +1,3 @@
+#ifndef EXTCONF_H
+#define EXTCONF_H
+#endif
diff --git a/jni/ruby/ext/fcntl/extconf.rb b/jni/ruby/ext/fcntl/extconf.rb
new file mode 100644
index 0000000..8b717d4
--- /dev/null
+++ b/jni/ruby/ext/fcntl/extconf.rb
@@ -0,0 +1,2 @@
+require 'mkmf'
+create_makefile('fcntl')
diff --git a/jni/ruby/ext/fcntl/fcntl.c b/jni/ruby/ext/fcntl/fcntl.c
new file mode 100644
index 0000000..6503c78
--- /dev/null
+++ b/jni/ruby/ext/fcntl/fcntl.c
@@ -0,0 +1,245 @@
+/************************************************
+
+ fcntl.c -
+
+ $Author: nobu $
+ created at: Mon Apr 7 18:53:05 JST 1997
+
+ Copyright (C) 1997-2001 Yukihiro Matsumoto
+
+************************************************/
+
+/************************************************
+= NAME
+
+fcntl - load the C fcntl.h defines
+
+= DESCRIPTION
+
+This module is just a translation of the C <fcntl.h> file.
+
+= NOTE
+
+Only #define symbols get translated; you must still correctly
+pack up your own arguments to pass as args for locking functions, etc.
+
+************************************************/
+
+#include "ruby.h"
+#include <fcntl.h>
+
+/* Fcntl loads the constants defined in the system's <fcntl.h> C header
+ * file, and used with both the fcntl(2) and open(2) POSIX system calls.
+ *
+ * To perform a fcntl(2) operation, use IO::fcntl.
+ *
+ * To perform an open(2) operation, use IO::sysopen.
+ *
+ * The set of operations and constants available depends upon specific
+ * operating system. Some values listed below may not be supported on your
+ * system.
+ *
+ * See your fcntl(2) man page for complete details.
+ *
+ * Open /tmp/tempfile as a write-only file that is created if it doesn't
+ * exist:
+ *
+ * require 'fcntl'
+ *
+ * fd = IO.sysopen('/tmp/tempfile',
+ * Fcntl::O_WRONLY | Fcntl::O_EXCL | Fcntl::O_CREAT)
+ * f = IO.open(fd)
+ * f.syswrite("TEMP DATA")
+ * f.close
+ *
+ * Get the flags on file +s+:
+ *
+ * m = s.fcntl(Fcntl::F_GETFL, 0)
+ *
+ * Set the non-blocking flag on +f+ in addition to the existing flags in +m+.
+ *
+ * f.fcntl(Fcntl::F_SETFL, Fcntl::O_NONBLOCK|m)
+ *
+ */
+void
+Init_fcntl(void)
+{
+ VALUE mFcntl = rb_define_module("Fcntl");
+#ifdef F_DUPFD
+ /* Document-const: F_DUPFD
+ *
+ * Duplicate a file descriptor to the mimimum unused file descriptor
+ * greater than or equal to the argument.
+ *
+ * The close-on-exec flag of the duplicated file descriptor is set.
+ * (Ruby uses F_DUPFD_CLOEXEC internally if available to avoid race
+ * condition. F_SETFD is used if F_DUPFD_CLOEXEC is not available.)
+ */
+ rb_define_const(mFcntl, "F_DUPFD", INT2NUM(F_DUPFD));
+#endif
+#ifdef F_GETFD
+ /* Document-const: F_GETFD
+ *
+ * Read the close-on-exec flag of a file descriptor.
+ */
+ rb_define_const(mFcntl, "F_GETFD", INT2NUM(F_GETFD));
+#endif
+#ifdef F_GETLK
+ /* Document-const: F_GETLK
+ *
+ * Determine whether a given region of a file is locked. This uses one of
+ * the F_*LK flags.
+ */
+ rb_define_const(mFcntl, "F_GETLK", INT2NUM(F_GETLK));
+#endif
+#ifdef F_SETFD
+ /* Document-const: F_SETFD
+ *
+ * Set the close-on-exec flag of a file descriptor.
+ */
+ rb_define_const(mFcntl, "F_SETFD", INT2NUM(F_SETFD));
+#endif
+#ifdef F_GETFL
+ /* Document-const: F_GETFL
+ *
+ * Get the file descriptor flags. This will be one or more of the O_*
+ * flags.
+ */
+ rb_define_const(mFcntl, "F_GETFL", INT2NUM(F_GETFL));
+#endif
+#ifdef F_SETFL
+ /* Document-const: F_SETFL
+ *
+ * Set the file descriptor flags. This will be one or more of the O_*
+ * flags.
+ */
+ rb_define_const(mFcntl, "F_SETFL", INT2NUM(F_SETFL));
+#endif
+#ifdef F_SETLK
+ /* Document-const: F_SETLK
+ *
+ * Acquire a lock on a region of a file. This uses one of the F_*LCK
+ * flags.
+ */
+ rb_define_const(mFcntl, "F_SETLK", INT2NUM(F_SETLK));
+#endif
+#ifdef F_SETLKW
+ /* Document-const: F_SETLKW
+ *
+ * Acquire a lock on a region of a file, waiting if necessary. This uses
+ * one of the F_*LCK flags
+ */
+ rb_define_const(mFcntl, "F_SETLKW", INT2NUM(F_SETLKW));
+#endif
+#ifdef FD_CLOEXEC
+ /* Document-const: FD_CLOEXEC
+ *
+ * the value of the close-on-exec flag.
+ */
+ rb_define_const(mFcntl, "FD_CLOEXEC", INT2NUM(FD_CLOEXEC));
+#endif
+#ifdef F_RDLCK
+ /* Document-const: F_RDLCK
+ *
+ * Read lock for a region of a file
+ */
+ rb_define_const(mFcntl, "F_RDLCK", INT2NUM(F_RDLCK));
+#endif
+#ifdef F_UNLCK
+ /* Document-const: F_UNLCK
+ *
+ * Remove lock for a region of a file
+ */
+ rb_define_const(mFcntl, "F_UNLCK", INT2NUM(F_UNLCK));
+#endif
+#ifdef F_WRLCK
+ /* Document-const: F_WRLCK
+ *
+ * Write lock for a region of a file
+ */
+ rb_define_const(mFcntl, "F_WRLCK", INT2NUM(F_WRLCK));
+#endif
+#ifdef O_CREAT
+ /* Document-const: O_CREAT
+ *
+ * Create the file if it doesn't exist
+ */
+ rb_define_const(mFcntl, "O_CREAT", INT2NUM(O_CREAT));
+#endif
+#ifdef O_EXCL
+ /* Document-const: O_EXCL
+ *
+ * Used with O_CREAT, fail if the file exists
+ */
+ rb_define_const(mFcntl, "O_EXCL", INT2NUM(O_EXCL));
+#endif
+#ifdef O_NOCTTY
+ /* Document-const: O_NOCTTY
+ *
+ * Open TTY without it becoming the controlling TTY
+ */
+ rb_define_const(mFcntl, "O_NOCTTY", INT2NUM(O_NOCTTY));
+#endif
+#ifdef O_TRUNC
+ /* Document-const: O_TRUNC
+ *
+ * Truncate the file on open
+ */
+ rb_define_const(mFcntl, "O_TRUNC", INT2NUM(O_TRUNC));
+#endif
+#ifdef O_APPEND
+ /* Document-const: O_APPEND
+ *
+ * Open the file in append mode
+ */
+ rb_define_const(mFcntl, "O_APPEND", INT2NUM(O_APPEND));
+#endif
+#ifdef O_NONBLOCK
+ /* Document-const: O_NONBLOCK
+ *
+ * Open the file in non-blocking mode
+ */
+ rb_define_const(mFcntl, "O_NONBLOCK", INT2NUM(O_NONBLOCK));
+#endif
+#ifdef O_NDELAY
+ /* Document-const: O_NDELAY
+ *
+ * Open the file in non-blocking mode
+ */
+ rb_define_const(mFcntl, "O_NDELAY", INT2NUM(O_NDELAY));
+#endif
+#ifdef O_RDONLY
+ /* Document-const: O_RDONLY
+ *
+ * Open the file in read-only mode
+ */
+ rb_define_const(mFcntl, "O_RDONLY", INT2NUM(O_RDONLY));
+#endif
+#ifdef O_RDWR
+ /* Document-const: O_RDWR
+ *
+ * Open the file in read-write mode
+ */
+ rb_define_const(mFcntl, "O_RDWR", INT2NUM(O_RDWR));
+#endif
+#ifdef O_WRONLY
+ /* Document-const: O_WRONLY
+ *
+ * Open the file in write-only mode.
+ */
+ rb_define_const(mFcntl, "O_WRONLY", INT2NUM(O_WRONLY));
+#endif
+#ifdef O_ACCMODE
+ /* Document-const: O_ACCMODE
+ *
+ * Mask to extract the read/write flags
+ */
+ rb_define_const(mFcntl, "O_ACCMODE", INT2FIX(O_ACCMODE));
+#else
+ /* Document-const: O_ACCMODE
+ *
+ * Mask to extract the read/write flags
+ */
+ rb_define_const(mFcntl, "O_ACCMODE", INT2FIX(O_RDONLY | O_WRONLY | O_RDWR));
+#endif
+}
diff --git a/jni/ruby/ext/fiber/Makefile b/jni/ruby/ext/fiber/Makefile
new file mode 100644
index 0000000..a728c2d
--- /dev/null
+++ b/jni/ruby/ext/fiber/Makefile
@@ -0,0 +1,267 @@
+
+SHELL = /bin/sh
+
+# V=0 quiet, V=1 verbose. other values don't work.
+V = 0
+Q1 = $(V:1=)
+Q = $(Q1:0=@)
+ECHO1 = $(V:1=@:)
+ECHO = $(ECHO1:0=@echo)
+NULLCMD = :
+
+#### Start of system configuration section. ####
+top_srcdir = $(topdir)/.
+srcdir = $(top_srcdir)/ext/fiber
+topdir = ../..
+hdrdir = $(top_srcdir)/include
+arch_hdrdir = $(extout)/include/$(arch)
+PATH_SEPARATOR = :
+VPATH = $(srcdir):$(arch_hdrdir)/ruby:$(hdrdir)/ruby
+RUBYLIB =
+RUBYOPT = -
+prefix = $(DESTDIR)/usr/local
+rubysitearchprefix = $(rubylibprefix)/$(sitearch)
+rubyarchprefix = $(rubylibprefix)/$(arch)
+rubylibprefix = $(libdir)/$(RUBY_BASE_NAME)
+exec_prefix = $(prefix)
+vendorarchhdrdir = $(vendorhdrdir)/$(sitearch)
+sitearchhdrdir = $(sitehdrdir)/$(sitearch)
+rubyarchhdrdir = $(rubyhdrdir)/$(arch)
+vendorhdrdir = $(rubyhdrdir)/vendor_ruby
+sitehdrdir = $(rubyhdrdir)/site_ruby
+rubyhdrdir = $(includedir)/$(RUBY_VERSION_NAME)
+vendorarchdir = $(vendorlibdir)/$(sitearch)
+vendorlibdir = $(vendordir)/$(ruby_version)
+vendordir = $(rubylibprefix)/vendor_ruby
+sitearchdir = $(sitelibdir)/$(sitearch)
+sitelibdir = $(sitedir)/$(ruby_version)
+sitedir = $(rubylibprefix)/site_ruby
+rubyarchdir = $(rubylibdir)/$(arch)
+rubylibdir = $(rubylibprefix)/$(ruby_version)
+sitearchincludedir = $(includedir)/$(sitearch)
+archincludedir = $(includedir)/$(arch)
+sitearchlibdir = $(libdir)/$(sitearch)
+archlibdir = $(libdir)/$(arch)
+ridir = $(datarootdir)/$(RI_BASE_NAME)
+mandir = $(datarootdir)/man
+localedir = $(datarootdir)/locale
+libdir = $(exec_prefix)/lib
+psdir = $(docdir)
+pdfdir = $(docdir)
+dvidir = $(docdir)
+htmldir = $(docdir)
+infodir = $(datarootdir)/info
+docdir = $(datarootdir)/doc/$(PACKAGE)
+oldincludedir = $(DESTDIR)/usr/include
+includedir = $(prefix)/include
+localstatedir = $(prefix)/var
+sharedstatedir = $(prefix)/com
+sysconfdir = $(prefix)/etc
+datadir = $(datarootdir)
+datarootdir = $(prefix)/share
+libexecdir = $(exec_prefix)/libexec
+sbindir = $(exec_prefix)/sbin
+bindir = $(exec_prefix)/bin
+archdir = $(rubyarchdir)
+
+
+CC = gcc
+CXX = g++
+LIBRUBY = $(LIBRUBY_SO)
+LIBRUBY_A = lib$(RUBY_SO_NAME)-static.a
+LIBRUBYARG_SHARED = -Wl,-R$(libdir) -L$(libdir) -l$(RUBY_SO_NAME)
+LIBRUBYARG_STATIC = -Wl,-R$(libdir) -L$(libdir) -l$(RUBY_SO_NAME)-static
+empty =
+OUTFLAG = -o $(empty)
+COUTFLAG = -o $(empty)
+
+RUBY_EXTCONF_H = extconf.h
+cflags = $(optflags) $(debugflags) $(warnflags)
+optflags = -O3 -fno-fast-math
+debugflags = -ggdb3
+warnflags = -Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wunused-variable -Wpointer-arith -Wwrite-strings -Wdeclaration-after-statement -Wimplicit-function-declaration -Wdeprecated-declarations -Wno-packed-bitfield-compat
+CCDLFLAGS = -fPIC
+CFLAGS = $(CCDLFLAGS) $(cflags) -fPIC $(ARCH_FLAG)
+INCFLAGS = -I. -I$(arch_hdrdir) -I$(hdrdir) -I$(srcdir)
+DEFS =
+CPPFLAGS = -DRUBY_EXTCONF_H=\"$(RUBY_EXTCONF_H)\" $(DEFS) $(cppflags)
+CXXFLAGS = $(CCDLFLAGS) $(cxxflags) $(ARCH_FLAG)
+ldflags = -L. -fstack-protector -rdynamic -Wl,-export-dynamic
+dldflags =
+ARCH_FLAG =
+DLDFLAGS = $(ldflags) $(dldflags) $(ARCH_FLAG)
+LDSHARED = $(CC) -shared
+LDSHAREDXX = $(CXX) -shared
+AR = ar
+EXEEXT =
+
+RUBY_INSTALL_NAME = $(RUBY_BASE_NAME)
+RUBY_SO_NAME = ruby
+RUBYW_INSTALL_NAME =
+RUBY_VERSION_NAME = $(RUBY_BASE_NAME)-$(ruby_version)
+RUBYW_BASE_NAME = rubyw
+RUBY_BASE_NAME = ruby
+
+arch = x86_64-linux
+sitearch = $(arch)
+ruby_version = 2.2.0
+ruby = $(topdir)/miniruby -I'$(topdir)' -I'$(top_srcdir)/lib' -I'$(extout)/$(arch)' -I'$(extout)/common'
+RUBY = $(ruby)
+ruby_headers = $(hdrdir)/ruby.h $(hdrdir)/ruby/ruby.h $(hdrdir)/ruby/defines.h $(hdrdir)/ruby/missing.h $(hdrdir)/ruby/intern.h $(hdrdir)/ruby/st.h $(hdrdir)/ruby/subst.h $(arch_hdrdir)/ruby/config.h $(RUBY_EXTCONF_H)
+
+RM = rm -f
+RM_RF = $(RUBY) -run -e rm -- -rf
+RMDIRS = rmdir --ignore-fail-on-non-empty -p
+MAKEDIRS = /bin/mkdir -p
+INSTALL = /usr/bin/install -c
+INSTALL_PROG = $(INSTALL) -m 0755
+INSTALL_DATA = $(INSTALL) -m 644
+COPY = cp
+TOUCH = exit >
+
+#### End of system configuration section. ####
+
+preload =
+
+libpath = . $(topdir)
+LIBPATH = -L. -L$(topdir)
+DEFFILE =
+
+CLEANFILES = mkmf.log
+DISTCLEANFILES =
+DISTCLEANDIRS =
+
+extout = $(topdir)/.ext
+extout_prefix = $(extout)$(target_prefix)/
+target_prefix =
+LOCAL_LIBS =
+LIBS = $(LIBRUBYARG_SHARED) -lpthread -lgmp -ldl -lcrypt -lm -lc
+ORIG_SRCS = fiber.c
+SRCS = $(ORIG_SRCS)
+OBJS = fiber.o
+HDRS = $(srcdir)/extconf.h
+TARGET = fiber
+TARGET_NAME = fiber
+TARGET_ENTRY = Init_$(TARGET_NAME)
+DLLIB = $(TARGET).so
+EXTSTATIC =
+STATIC_LIB = $(TARGET).a
+
+TIMESTAMP_DIR = $(extout)/.timestamp
+BINDIR = $(extout)/bin
+RUBYCOMMONDIR = $(extout)/common
+RUBYLIBDIR = $(RUBYCOMMONDIR)$(target_prefix)
+RUBYARCHDIR = $(extout)/$(arch)$(target_prefix)
+HDRDIR = $(extout)/include/ruby$(target_prefix)
+ARCHHDRDIR = $(extout)/include/$(arch)/ruby$(target_prefix)
+
+TARGET_SO = $(RUBYARCHDIR)/$(DLLIB)
+CLEANLIBS = $(RUBYARCHDIR)/$(TARGET).so
+CLEANOBJS = *.o *.bak
+
+all: install
+static: all
+.PHONY: all install static install-so install-rb
+.PHONY: clean clean-so clean-static clean-rb
+
+clean-static::
+clean-rb-default::
+clean-rb::
+clean-so::
+clean: clean-so clean-static clean-rb-default clean-rb
+ -$(Q)$(RM) $(CLEANLIBS) $(CLEANOBJS) $(CLEANFILES) .*.time
+
+distclean-rb-default::
+distclean-rb::
+distclean-so::
+distclean-static::
+distclean: clean distclean-so distclean-static distclean-rb-default distclean-rb
+ -$(Q)$(RM) Makefile $(RUBY_EXTCONF_H) conftest.* mkmf.log
+ -$(Q)$(RM) core ruby$(EXEEXT) *~ $(DISTCLEANFILES)
+ -$(Q)$(RMDIRS) $(DISTCLEANDIRS) 2> /dev/null || true
+
+realclean: distclean
+install: install-so install-rb
+
+install-so: $(RUBYARCHDIR)/$(DLLIB)
+clean-so::
+ -$(Q)$(RM) $(RUBYARCHDIR)/$(DLLIB)
+ -$(Q)$(RMDIRS) $(RUBYARCHDIR) 2> /dev/null || true
+clean-static::
+ -$(Q)$(RM) $(STATIC_LIB)
+install-rb: pre-install-rb install-rb-default
+install-rb-default: pre-install-rb-default
+pre-install-rb: Makefile
+pre-install-rb-default: Makefile
+pre-install-rb-default:
+ @$(NULLCMD)
+$(TIMESTAMP_DIR)/.RUBYARCHDIR.time:
+ $(Q) $(MAKEDIRS) $(@D) $(RUBYARCHDIR)
+ $(Q) $(TOUCH) $@
+
+site-install: site-install-so site-install-rb
+site-install-so: install-so
+site-install-rb: install-rb
+
+.SUFFIXES: .c .m .cc .mm .cxx .cpp .o .S
+
+.cc.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<
+
+.cc.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -S $<
+
+.mm.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<
+
+.mm.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -S $<
+
+.cxx.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<
+
+.cxx.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -S $<
+
+.cpp.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<
+
+.cpp.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -S $<
+
+.c.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -c $<
+
+.c.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -S $<
+
+.m.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -c $<
+
+.m.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -S $<
+
+$(RUBYARCHDIR)/$(DLLIB): $(OBJS) Makefile $(TIMESTAMP_DIR)/.RUBYARCHDIR.time
+ $(ECHO) linking shared-object $(DLLIB)
+ -$(Q)$(RM) $(@)
+ $(Q) $(LDSHARED) -o $@ $(OBJS) $(LIBPATH) $(DLDFLAGS) $(LOCAL_LIBS) $(LIBS)
+
+$(STATIC_LIB): $(OBJS)
+ -$(Q)$(RM) $(@)
+ $(ECHO) linking static-library $(@)
+ $(Q) $(AR) cru $@ $(OBJS)
+ -$(Q)ranlib $(@) 2> /dev/null || true
+
+$(OBJS): $(HDRS) $(ruby_headers)
diff --git a/jni/ruby/ext/fiber/extconf.h b/jni/ruby/ext/fiber/extconf.h
new file mode 100644
index 0000000..cda0cc8
--- /dev/null
+++ b/jni/ruby/ext/fiber/extconf.h
@@ -0,0 +1,3 @@
+#ifndef EXTCONF_H
+#define EXTCONF_H
+#endif
diff --git a/jni/ruby/ext/fiber/extconf.rb b/jni/ruby/ext/fiber/extconf.rb
new file mode 100644
index 0000000..904ab94
--- /dev/null
+++ b/jni/ruby/ext/fiber/extconf.rb
@@ -0,0 +1,3 @@
+require 'mkmf'
+create_makefile('fiber')
+
diff --git a/jni/ruby/ext/fiber/fiber.c b/jni/ruby/ext/fiber/fiber.c
new file mode 100644
index 0000000..12fcaad
--- /dev/null
+++ b/jni/ruby/ext/fiber/fiber.c
@@ -0,0 +1,8 @@
+
+void ruby_Init_Fiber_as_Coroutine(void);
+
+void
+Init_fiber(void)
+{
+ ruby_Init_Fiber_as_Coroutine();
+}
diff --git a/jni/ruby/ext/fiddle/Makefile b/jni/ruby/ext/fiddle/Makefile
new file mode 100644
index 0000000..89c998d
--- /dev/null
+++ b/jni/ruby/ext/fiddle/Makefile
@@ -0,0 +1,381 @@
+
+SHELL = /bin/sh
+
+# V=0 quiet, V=1 verbose. other values don't work.
+V = 0
+Q1 = $(V:1=)
+Q = $(Q1:0=@)
+ECHO1 = $(V:1=@:)
+ECHO = $(ECHO1:0=@echo)
+NULLCMD = :
+
+#### Start of system configuration section. ####
+top_srcdir = $(topdir)/.
+srcdir = $(top_srcdir)/ext/fiddle
+topdir = ../..
+hdrdir = $(top_srcdir)/include
+arch_hdrdir = $(extout)/include/$(arch)
+PATH_SEPARATOR = :
+VPATH = $(srcdir):$(arch_hdrdir)/ruby:$(hdrdir)/ruby
+RUBYLIB =
+RUBYOPT = -
+prefix = $(DESTDIR)/usr/local
+rubysitearchprefix = $(rubylibprefix)/$(sitearch)
+rubyarchprefix = $(rubylibprefix)/$(arch)
+rubylibprefix = $(libdir)/$(RUBY_BASE_NAME)
+exec_prefix = $(prefix)
+vendorarchhdrdir = $(vendorhdrdir)/$(sitearch)
+sitearchhdrdir = $(sitehdrdir)/$(sitearch)
+rubyarchhdrdir = $(rubyhdrdir)/$(arch)
+vendorhdrdir = $(rubyhdrdir)/vendor_ruby
+sitehdrdir = $(rubyhdrdir)/site_ruby
+rubyhdrdir = $(includedir)/$(RUBY_VERSION_NAME)
+vendorarchdir = $(vendorlibdir)/$(sitearch)
+vendorlibdir = $(vendordir)/$(ruby_version)
+vendordir = $(rubylibprefix)/vendor_ruby
+sitearchdir = $(sitelibdir)/$(sitearch)
+sitelibdir = $(sitedir)/$(ruby_version)
+sitedir = $(rubylibprefix)/site_ruby
+rubyarchdir = $(rubylibdir)/$(arch)
+rubylibdir = $(rubylibprefix)/$(ruby_version)
+sitearchincludedir = $(includedir)/$(sitearch)
+archincludedir = $(includedir)/$(arch)
+sitearchlibdir = $(libdir)/$(sitearch)
+archlibdir = $(libdir)/$(arch)
+ridir = $(datarootdir)/$(RI_BASE_NAME)
+mandir = $(datarootdir)/man
+localedir = $(datarootdir)/locale
+libdir = $(exec_prefix)/lib
+psdir = $(docdir)
+pdfdir = $(docdir)
+dvidir = $(docdir)
+htmldir = $(docdir)
+infodir = $(datarootdir)/info
+docdir = $(datarootdir)/doc/$(PACKAGE)
+oldincludedir = $(DESTDIR)/usr/include
+includedir = $(prefix)/include
+localstatedir = $(prefix)/var
+sharedstatedir = $(prefix)/com
+sysconfdir = $(prefix)/etc
+datadir = $(datarootdir)
+datarootdir = $(prefix)/share
+libexecdir = $(exec_prefix)/libexec
+sbindir = $(exec_prefix)/sbin
+bindir = $(exec_prefix)/bin
+archdir = $(rubyarchdir)
+
+
+CC = gcc
+CXX = g++
+LIBRUBY = $(LIBRUBY_SO)
+LIBRUBY_A = lib$(RUBY_SO_NAME)-static.a
+LIBRUBYARG_SHARED = -Wl,-R$(libdir) -L$(libdir) -l$(RUBY_SO_NAME)
+LIBRUBYARG_STATIC = -Wl,-R$(libdir) -L$(libdir) -l$(RUBY_SO_NAME)-static
+empty =
+OUTFLAG = -o $(empty)
+COUTFLAG = -o $(empty)
+
+RUBY_EXTCONF_H = extconf.h
+cflags = $(optflags) $(debugflags) $(warnflags)
+optflags = -O3 -fno-fast-math
+debugflags = -ggdb3
+warnflags = -Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wunused-variable -Wpointer-arith -Wwrite-strings -Wdeclaration-after-statement -Wimplicit-function-declaration -Wdeprecated-declarations -Wno-packed-bitfield-compat
+CCDLFLAGS = -fPIC
+CFLAGS = $(CCDLFLAGS) $(cflags) -fPIC $(ARCH_FLAG)
+INCFLAGS = -I. -I$(arch_hdrdir) -I$(hdrdir) -I$(srcdir)
+DEFS =
+CPPFLAGS = -DRUBY_EXTCONF_H=\"$(RUBY_EXTCONF_H)\" $(DEFS) $(cppflags)
+CXXFLAGS = $(CCDLFLAGS) $(cxxflags) $(ARCH_FLAG)
+ldflags = -L. -fstack-protector -rdynamic -Wl,-export-dynamic
+dldflags =
+ARCH_FLAG =
+DLDFLAGS = $(ldflags) $(dldflags) $(ARCH_FLAG)
+LDSHARED = $(CC) -shared
+LDSHAREDXX = $(CXX) -shared
+AR = ar
+EXEEXT =
+
+RUBY_INSTALL_NAME = $(RUBY_BASE_NAME)
+RUBY_SO_NAME = ruby
+RUBYW_INSTALL_NAME =
+RUBY_VERSION_NAME = $(RUBY_BASE_NAME)-$(ruby_version)
+RUBYW_BASE_NAME = rubyw
+RUBY_BASE_NAME = ruby
+
+arch = x86_64-linux
+sitearch = $(arch)
+ruby_version = 2.2.0
+ruby = $(topdir)/miniruby -I'$(topdir)' -I'$(top_srcdir)/lib' -I'$(extout)/$(arch)' -I'$(extout)/common'
+RUBY = $(ruby)
+ruby_headers = $(hdrdir)/ruby.h $(hdrdir)/ruby/ruby.h $(hdrdir)/ruby/defines.h $(hdrdir)/ruby/missing.h $(hdrdir)/ruby/intern.h $(hdrdir)/ruby/st.h $(hdrdir)/ruby/subst.h $(arch_hdrdir)/ruby/config.h $(RUBY_EXTCONF_H)
+
+RM = rm -f
+RM_RF = $(RUBY) -run -e rm -- -rf
+RMDIRS = rmdir --ignore-fail-on-non-empty -p
+MAKEDIRS = /bin/mkdir -p
+INSTALL = /usr/bin/install -c
+INSTALL_PROG = $(INSTALL) -m 0755
+INSTALL_DATA = $(INSTALL) -m 644
+COPY = cp
+TOUCH = exit >
+
+#### End of system configuration section. ####
+
+preload =
+LIBFFI_CLEAN = none
+
+libpath = . $(topdir)
+LIBPATH = -L. -L$(topdir)
+DEFFILE =
+
+CLEANFILES = mkmf.log
+DISTCLEANFILES =
+DISTCLEANDIRS =
+
+extout = $(topdir)/.ext
+extout_prefix = $(extout)$(target_prefix)/
+target_prefix =
+LOCAL_LIBS =
+LIBS = $(LIBRUBYARG_SHARED) -ldl -lffi -lffi -lpthread -lgmp -ldl -lcrypt -lm -lc
+ORIG_SRCS = function.c handle.c fiddle.c conversions.c closure.c pointer.c
+SRCS = $(ORIG_SRCS)
+OBJS = function.o handle.o fiddle.o conversions.o closure.o pointer.o
+HDRS = $(srcdir)/function.h $(srcdir)/extconf.h $(srcdir)/closure.h $(srcdir)/conversions.h $(srcdir)/fiddle.h
+TARGET = fiddle
+TARGET_NAME = fiddle
+TARGET_ENTRY = Init_$(TARGET_NAME)
+DLLIB = $(TARGET).so
+EXTSTATIC =
+STATIC_LIB = $(TARGET).a
+
+TIMESTAMP_DIR = $(extout)/.timestamp
+BINDIR = $(extout)/bin
+RUBYCOMMONDIR = $(extout)/common
+RUBYLIBDIR = $(RUBYCOMMONDIR)$(target_prefix)
+RUBYARCHDIR = $(extout)/$(arch)$(target_prefix)
+HDRDIR = $(extout)/include/ruby$(target_prefix)
+ARCHHDRDIR = $(extout)/include/$(arch)/ruby$(target_prefix)
+
+TARGET_SO = $(RUBYARCHDIR)/$(DLLIB)
+CLEANLIBS = $(RUBYARCHDIR)/$(TARGET).so
+CLEANOBJS = *.o *.bak
+
+all: install
+static: all
+.PHONY: all install static install-so install-rb
+.PHONY: clean clean-so clean-static clean-rb
+
+clean-static::
+clean-rb-default::
+clean-rb::
+clean-so::
+clean: clean-so clean-static clean-rb-default clean-rb
+ -$(Q)$(RM) $(CLEANLIBS) $(CLEANOBJS) $(CLEANFILES) .*.time
+
+distclean-rb-default::
+distclean-rb::
+distclean-so::
+distclean-static::
+distclean: clean distclean-so distclean-static distclean-rb-default distclean-rb
+ -$(Q)$(RM) Makefile $(RUBY_EXTCONF_H) conftest.* mkmf.log
+ -$(Q)$(RM) core ruby$(EXEEXT) *~ $(DISTCLEANFILES)
+ -$(Q)$(RMDIRS) $(DISTCLEANDIRS) 2> /dev/null || true
+
+realclean: distclean
+install: install-so install-rb
+
+install-so: $(RUBYARCHDIR)/$(DLLIB)
+clean-so::
+ -$(Q)$(RM) $(RUBYARCHDIR)/$(DLLIB)
+ -$(Q)$(RMDIRS) $(RUBYARCHDIR) 2> /dev/null || true
+clean-static::
+ -$(Q)$(RM) $(STATIC_LIB)
+install-rb: pre-install-rb install-rb-default
+install-rb-default: pre-install-rb-default
+pre-install-rb: Makefile
+pre-install-rb-default: Makefile
+pre-install-rb-default: $(TIMESTAMP_DIR)/.RUBYLIBDIR.-.fiddle.time
+install-rb-default: $(RUBYLIBDIR)/fiddle/types.rb
+$(RUBYLIBDIR)/fiddle/types.rb: $(srcdir)/lib/fiddle/types.rb $(TIMESTAMP_DIR)/.RUBYLIBDIR.-.fiddle.time
+ $(Q) $(COPY) $(srcdir)/lib/fiddle/types.rb $(@D)
+clean-rb-default::
+ -$(Q)$(RM) $(RUBYLIBDIR)/fiddle/types.rb
+install-rb-default: $(RUBYLIBDIR)/fiddle/cparser.rb
+$(RUBYLIBDIR)/fiddle/cparser.rb: $(srcdir)/lib/fiddle/cparser.rb $(TIMESTAMP_DIR)/.RUBYLIBDIR.-.fiddle.time
+ $(Q) $(COPY) $(srcdir)/lib/fiddle/cparser.rb $(@D)
+clean-rb-default::
+ -$(Q)$(RM) $(RUBYLIBDIR)/fiddle/cparser.rb
+install-rb-default: $(RUBYLIBDIR)/fiddle/closure.rb
+$(RUBYLIBDIR)/fiddle/closure.rb: $(srcdir)/lib/fiddle/closure.rb $(TIMESTAMP_DIR)/.RUBYLIBDIR.-.fiddle.time
+ $(Q) $(COPY) $(srcdir)/lib/fiddle/closure.rb $(@D)
+clean-rb-default::
+ -$(Q)$(RM) $(RUBYLIBDIR)/fiddle/closure.rb
+install-rb-default: $(RUBYLIBDIR)/fiddle/function.rb
+$(RUBYLIBDIR)/fiddle/function.rb: $(srcdir)/lib/fiddle/function.rb $(TIMESTAMP_DIR)/.RUBYLIBDIR.-.fiddle.time
+ $(Q) $(COPY) $(srcdir)/lib/fiddle/function.rb $(@D)
+clean-rb-default::
+ -$(Q)$(RM) $(RUBYLIBDIR)/fiddle/function.rb
+install-rb-default: $(RUBYLIBDIR)/fiddle/struct.rb
+$(RUBYLIBDIR)/fiddle/struct.rb: $(srcdir)/lib/fiddle/struct.rb $(TIMESTAMP_DIR)/.RUBYLIBDIR.-.fiddle.time
+ $(Q) $(COPY) $(srcdir)/lib/fiddle/struct.rb $(@D)
+clean-rb-default::
+ -$(Q)$(RM) $(RUBYLIBDIR)/fiddle/struct.rb
+install-rb-default: $(RUBYLIBDIR)/fiddle/import.rb
+$(RUBYLIBDIR)/fiddle/import.rb: $(srcdir)/lib/fiddle/import.rb $(TIMESTAMP_DIR)/.RUBYLIBDIR.-.fiddle.time
+ $(Q) $(COPY) $(srcdir)/lib/fiddle/import.rb $(@D)
+clean-rb-default::
+ -$(Q)$(RM) $(RUBYLIBDIR)/fiddle/import.rb
+install-rb-default: $(RUBYLIBDIR)/fiddle/value.rb
+$(RUBYLIBDIR)/fiddle/value.rb: $(srcdir)/lib/fiddle/value.rb $(TIMESTAMP_DIR)/.RUBYLIBDIR.-.fiddle.time
+ $(Q) $(COPY) $(srcdir)/lib/fiddle/value.rb $(@D)
+clean-rb-default::
+ -$(Q)$(RM) $(RUBYLIBDIR)/fiddle/value.rb
+install-rb-default: $(RUBYLIBDIR)/fiddle/pack.rb
+$(RUBYLIBDIR)/fiddle/pack.rb: $(srcdir)/lib/fiddle/pack.rb $(TIMESTAMP_DIR)/.RUBYLIBDIR.-.fiddle.time
+ $(Q) $(COPY) $(srcdir)/lib/fiddle/pack.rb $(@D)
+clean-rb-default::
+ -$(Q)$(RM) $(RUBYLIBDIR)/fiddle/pack.rb
+pre-install-rb-default: $(TIMESTAMP_DIR)/.RUBYLIBDIR.time
+install-rb-default: $(RUBYLIBDIR)/fiddle.rb
+$(RUBYLIBDIR)/fiddle.rb: $(srcdir)/lib/fiddle.rb $(TIMESTAMP_DIR)/.RUBYLIBDIR.time
+ $(Q) $(COPY) $(srcdir)/lib/fiddle.rb $(@D)
+clean-rb-default::
+ -$(Q)$(RM) $(RUBYLIBDIR)/fiddle.rb
+pre-install-rb-default:
+ $(ECHO) installing default fiddle libraries
+clean-rb-default::
+ -$(Q)$(RMDIRS) $(RUBYLIBDIR)/fiddle 2> /dev/null || true
+ -$(Q)$(RMDIRS) $(RUBYLIBDIR) 2> /dev/null || true
+$(TIMESTAMP_DIR)/.RUBYARCHDIR.time:
+ $(Q) $(MAKEDIRS) $(@D) $(RUBYARCHDIR)
+ $(Q) $(TOUCH) $@
+$(TIMESTAMP_DIR)/.RUBYLIBDIR.-.fiddle.time:
+ $(Q) $(MAKEDIRS) $(@D) $(RUBYLIBDIR)/fiddle
+ $(Q) $(TOUCH) $@
+$(TIMESTAMP_DIR)/.RUBYLIBDIR.time:
+ $(Q) $(MAKEDIRS) $(@D) $(RUBYLIBDIR)
+ $(Q) $(TOUCH) $@
+
+site-install: site-install-so site-install-rb
+site-install-so: install-so
+site-install-rb: install-rb
+
+.SUFFIXES: .c .m .cc .mm .cxx .cpp .o .S
+
+.cc.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<
+
+.cc.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -S $<
+
+.mm.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<
+
+.mm.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -S $<
+
+.cxx.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<
+
+.cxx.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -S $<
+
+.cpp.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<
+
+.cpp.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -S $<
+
+.c.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -c $<
+
+.c.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -S $<
+
+.m.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -c $<
+
+.m.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -S $<
+
+$(RUBYARCHDIR)/$(DLLIB): $(OBJS) Makefile $(TIMESTAMP_DIR)/.RUBYARCHDIR.time
+ $(ECHO) linking shared-object $(DLLIB)
+ -$(Q)$(RM) $(@)
+ $(Q) $(LDSHARED) -o $@ $(OBJS) $(LIBPATH) $(DLDFLAGS) $(LOCAL_LIBS) $(LIBS)
+
+$(STATIC_LIB): $(OBJS)
+ -$(Q)$(RM) $(@)
+ $(ECHO) linking static-library $(@)
+ $(Q) $(AR) cru $@ $(OBJS)
+ -$(Q)ranlib $(@) 2> /dev/null || true
+
+###
+$(OBJS): $(RUBY_EXTCONF_H)
+
+PWD =
+
+CONFIGURE_LIBFFI = \
+ $(LIBFFI_CONFIGURE) --disable-shared \
+ --host=$(LIBFFI_ARCH) --enable-builddir=$(arch) \
+ CC="$(CC)" CFLAGS="$(LIBFFI_CFLAGS)" \
+ LD="$(LD)" LDFLAGS="$(LIBFFI_LDFLAGS)"
+
+$(OBJS): $(HDRS) $(ruby_headers) \
+ $(hdrdir)/ruby/io.h \
+ $(hdrdir)/ruby/encoding.h \
+ $(hdrdir)/ruby/oniguruma.h
+
+$(STATIC_LIB) $(RUBYARCHDIR)/$(DLLIB) $(DLLIB): $(LIBFFI_A)
+
+$(OBJS): $(FFI_H)
+
+.PHONY: .FORCE hdr
+
+.FORCE:
+
+hdr: $(FFI_H)
+
+configure-libffi build-libffi: .FORCE
+configure-libffi \
+$(LIBFFI_DIR)/include/ffi.h \
+$(LIBFFI_DIR)/include/ffitarget.h \
+$(LIBFFI_DIR)/fficonfig.h \
+$(LIBFFI_DIR)/Makefile:
+ $(Q) $(MAKEDIRS) $(LIBFFI_DIR)
+ $(Q) $(CONFIGURE_LIBFFI)
+
+build-libffi: $(LIBFFI_A)
+build-libffi $(LIBFFI_A):
+ $(Q) $(SUBMAKE_LIBFFI)
+
+clean-libffi:
+ $(Q) $(SUBMAKE_LIBFFI) clean
+
+distclean-libffi:
+ $(Q) $(SUBMAKE_LIBFFI) distclean
+ $(Q) $(RM) $(LIBFFI_DIR)/local.exp
+ $(Q) $(RUBY) -rfileutils -e "FileUtils.rmdir(Dir.glob(ARGV[0]+'/**/'), :parents=>true)" $(LIBFFI_DIR)
+
+realclean-libffi:
+ $(Q) $(RMALL) $(LIBFFI_DIR)
+
+.PHONY clean-libffi distclean-libffi realclean-libffi: .FORCE
+.PHONY clean-none distclean-none realclean-none: .FORCE
+
+clean: clean-$(LIBFFI_CLEAN)
+distclean: distclean-$(LIBFFI_CLEAN)
+realclean: realclean-$(LIBFFI_CLEAN)
+
+.PHONY configure: configure-libffi
diff --git a/jni/ruby/ext/fiddle/closure.c b/jni/ruby/ext/fiddle/closure.c
new file mode 100644
index 0000000..d857bfe
--- /dev/null
+++ b/jni/ruby/ext/fiddle/closure.c
@@ -0,0 +1,316 @@
+#include <fiddle.h>
+
+VALUE cFiddleClosure;
+
+typedef struct {
+ void * code;
+ ffi_closure *pcl;
+ ffi_cif cif;
+ int argc;
+ ffi_type **argv;
+} fiddle_closure;
+
+#if defined(USE_FFI_CLOSURE_ALLOC)
+#elif defined(__OpenBSD__) || defined(__APPLE__) || defined(__linux__)
+# define USE_FFI_CLOSURE_ALLOC 0
+#elif defined(RUBY_LIBFFI_MODVERSION) && RUBY_LIBFFI_MODVERSION < 3000005 && \
+ (defined(__i386__) || defined(__x86_64__) || defined(_M_IX86) || defined(_M_AMD64))
+# define USE_FFI_CLOSURE_ALLOC 0
+#else
+# define USE_FFI_CLOSURE_ALLOC 1
+#endif
+
+static void
+dealloc(void * ptr)
+{
+ fiddle_closure * cls = (fiddle_closure *)ptr;
+#if USE_FFI_CLOSURE_ALLOC
+ ffi_closure_free(cls->pcl);
+#else
+ munmap(cls->pcl, sizeof(*cls->pcl));
+#endif
+ if (cls->argv) xfree(cls->argv);
+ xfree(cls);
+}
+
+static size_t
+closure_memsize(const void * ptr)
+{
+ fiddle_closure * cls = (fiddle_closure *)ptr;
+ size_t size = 0;
+
+ if (ptr) {
+ size += sizeof(*cls);
+#if !defined(FFI_NO_RAW_API) || !FFI_NO_RAW_API
+ size += ffi_raw_size(&cls->cif);
+#endif
+ size += sizeof(*cls->argv);
+ size += sizeof(ffi_closure);
+ }
+ return size;
+}
+
+const rb_data_type_t closure_data_type = {
+ "fiddle/closure",
+ {0, dealloc, closure_memsize,},
+};
+
+void
+callback(ffi_cif *cif, void *resp, void **args, void *ctx)
+{
+ VALUE self = (VALUE)ctx;
+ VALUE rbargs = rb_iv_get(self, "@args");
+ VALUE ctype = rb_iv_get(self, "@ctype");
+ int argc = RARRAY_LENINT(rbargs);
+ VALUE params = rb_ary_tmp_new(argc);
+ VALUE ret;
+ VALUE cPointer;
+ int i, type;
+
+ cPointer = rb_const_get(mFiddle, rb_intern("Pointer"));
+
+ for (i = 0; i < argc; i++) {
+ type = NUM2INT(RARRAY_PTR(rbargs)[i]);
+ switch (type) {
+ case TYPE_VOID:
+ argc = 0;
+ break;
+ case TYPE_INT:
+ rb_ary_push(params, INT2NUM(*(int *)args[i]));
+ break;
+ case -TYPE_INT:
+ rb_ary_push(params, UINT2NUM(*(unsigned int *)args[i]));
+ break;
+ case TYPE_VOIDP:
+ rb_ary_push(params,
+ rb_funcall(cPointer, rb_intern("[]"), 1,
+ PTR2NUM(*(void **)args[i])));
+ break;
+ case TYPE_LONG:
+ rb_ary_push(params, LONG2NUM(*(long *)args[i]));
+ break;
+ case -TYPE_LONG:
+ rb_ary_push(params, ULONG2NUM(*(unsigned long *)args[i]));
+ break;
+ case TYPE_CHAR:
+ rb_ary_push(params, INT2NUM(*(signed char *)args[i]));
+ break;
+ case -TYPE_CHAR:
+ rb_ary_push(params, UINT2NUM(*(unsigned char *)args[i]));
+ break;
+ case TYPE_SHORT:
+ rb_ary_push(params, INT2NUM(*(signed short *)args[i]));
+ break;
+ case -TYPE_SHORT:
+ rb_ary_push(params, UINT2NUM(*(unsigned short *)args[i]));
+ break;
+ case TYPE_DOUBLE:
+ rb_ary_push(params, rb_float_new(*(double *)args[i]));
+ break;
+ case TYPE_FLOAT:
+ rb_ary_push(params, rb_float_new(*(float *)args[i]));
+ break;
+#if HAVE_LONG_LONG
+ case TYPE_LONG_LONG:
+ rb_ary_push(params, LL2NUM(*(LONG_LONG *)args[i]));
+ break;
+ case -TYPE_LONG_LONG:
+ rb_ary_push(params, ULL2NUM(*(unsigned LONG_LONG *)args[i]));
+ break;
+#endif
+ default:
+ rb_raise(rb_eRuntimeError, "closure args: %d", type);
+ }
+ }
+
+ ret = rb_funcall2(self, rb_intern("call"), argc, RARRAY_PTR(params));
+ RB_GC_GUARD(params);
+
+ type = NUM2INT(ctype);
+ switch (type) {
+ case TYPE_VOID:
+ break;
+ case TYPE_LONG:
+ *(long *)resp = NUM2LONG(ret);
+ break;
+ case -TYPE_LONG:
+ *(unsigned long *)resp = NUM2ULONG(ret);
+ break;
+ case TYPE_CHAR:
+ case TYPE_SHORT:
+ case TYPE_INT:
+ *(ffi_sarg *)resp = NUM2INT(ret);
+ break;
+ case -TYPE_CHAR:
+ case -TYPE_SHORT:
+ case -TYPE_INT:
+ *(ffi_arg *)resp = NUM2UINT(ret);
+ break;
+ case TYPE_VOIDP:
+ *(void **)resp = NUM2PTR(ret);
+ break;
+ case TYPE_DOUBLE:
+ *(double *)resp = NUM2DBL(ret);
+ break;
+ case TYPE_FLOAT:
+ *(float *)resp = (float)NUM2DBL(ret);
+ break;
+#if HAVE_LONG_LONG
+ case TYPE_LONG_LONG:
+ *(LONG_LONG *)resp = NUM2LL(ret);
+ break;
+ case -TYPE_LONG_LONG:
+ *(unsigned LONG_LONG *)resp = NUM2ULL(ret);
+ break;
+#endif
+ default:
+ rb_raise(rb_eRuntimeError, "closure retval: %d", type);
+ }
+}
+
+static VALUE
+allocate(VALUE klass)
+{
+ fiddle_closure * closure;
+
+ VALUE i = TypedData_Make_Struct(klass, fiddle_closure,
+ &closure_data_type, closure);
+
+#if USE_FFI_CLOSURE_ALLOC
+ closure->pcl = ffi_closure_alloc(sizeof(ffi_closure), &closure->code);
+#else
+ closure->pcl = mmap(NULL, sizeof(ffi_closure), PROT_READ | PROT_WRITE,
+ MAP_ANON | MAP_PRIVATE, -1, 0);
+#endif
+
+ return i;
+}
+
+static VALUE
+initialize(int rbargc, VALUE argv[], VALUE self)
+{
+ VALUE ret;
+ VALUE args;
+ VALUE abi;
+ fiddle_closure * cl;
+ ffi_cif * cif;
+ ffi_closure *pcl;
+ ffi_status result;
+ int i, argc;
+
+ if (2 == rb_scan_args(rbargc, argv, "21", &ret, &args, &abi))
+ abi = INT2NUM(FFI_DEFAULT_ABI);
+
+ Check_Type(args, T_ARRAY);
+
+ argc = RARRAY_LENINT(args);
+
+ TypedData_Get_Struct(self, fiddle_closure, &closure_data_type, cl);
+
+ cl->argv = (ffi_type **)xcalloc(argc + 1, sizeof(ffi_type *));
+
+ for (i = 0; i < argc; i++) {
+ int type = NUM2INT(RARRAY_PTR(args)[i]);
+ cl->argv[i] = INT2FFI_TYPE(type);
+ }
+ cl->argv[argc] = NULL;
+
+ rb_iv_set(self, "@ctype", ret);
+ rb_iv_set(self, "@args", args);
+
+ cif = &cl->cif;
+ pcl = cl->pcl;
+
+ result = ffi_prep_cif(cif, NUM2INT(abi), argc,
+ INT2FFI_TYPE(NUM2INT(ret)),
+ cl->argv);
+
+ if (FFI_OK != result)
+ rb_raise(rb_eRuntimeError, "error prepping CIF %d", result);
+
+#if USE_FFI_CLOSURE_ALLOC
+ result = ffi_prep_closure_loc(pcl, cif, callback,
+ (void *)self, cl->code);
+#else
+ result = ffi_prep_closure(pcl, cif, callback, (void *)self);
+ cl->code = (void *)pcl;
+ i = mprotect(pcl, sizeof(*pcl), PROT_READ | PROT_EXEC);
+ if (i) {
+ rb_sys_fail("mprotect");
+ }
+#endif
+
+ if (FFI_OK != result)
+ rb_raise(rb_eRuntimeError, "error prepping closure %d", result);
+
+ return self;
+}
+
+static VALUE
+to_i(VALUE self)
+{
+ fiddle_closure * cl;
+ void *code;
+
+ TypedData_Get_Struct(self, fiddle_closure, &closure_data_type, cl);
+
+ code = cl->code;
+
+ return PTR2NUM(code);
+}
+
+void
+Init_fiddle_closure(void)
+{
+#if 0
+ mFiddle = rb_define_module("Fiddle"); /* let rdoc know about mFiddle */
+#endif
+
+ /*
+ * Document-class: Fiddle::Closure
+ *
+ * == Description
+ *
+ * An FFI closure wrapper, for handling callbacks.
+ *
+ * == Example
+ *
+ * closure = Class.new(Fiddle::Closure) {
+ * def call
+ * 10
+ * end
+ * }.new(Fiddle::TYPE_INT, [])
+ * #=> #<#<Class:0x0000000150d308>:0x0000000150d240>
+ * func = Fiddle::Function.new(closure, [], Fiddle::TYPE_INT)
+ * #=> #<Fiddle::Function:0x00000001516e58>
+ * func.call
+ * #=> 10
+ */
+ cFiddleClosure = rb_define_class_under(mFiddle, "Closure", rb_cObject);
+
+ rb_define_alloc_func(cFiddleClosure, allocate);
+
+ /*
+ * Document-method: new
+ *
+ * call-seq: new(ret, args, abi = Fiddle::DEFAULT)
+ *
+ * Construct a new Closure object.
+ *
+ * * +ret+ is the C type to be returned
+ * * +args+ is an Array of arguments, passed to the callback function
+ * * +abi+ is the abi of the closure
+ *
+ * If there is an error in preparing the ffi_cif or ffi_prep_closure,
+ * then a RuntimeError will be raised.
+ */
+ rb_define_method(cFiddleClosure, "initialize", initialize, -1);
+
+ /*
+ * Document-method: to_i
+ *
+ * Returns the memory address for this closure
+ */
+ rb_define_method(cFiddleClosure, "to_i", to_i, 0);
+}
+/* vim: set noet sw=4 sts=4 */
diff --git a/jni/ruby/ext/fiddle/closure.h b/jni/ruby/ext/fiddle/closure.h
new file mode 100644
index 0000000..d0a8be6
--- /dev/null
+++ b/jni/ruby/ext/fiddle/closure.h
@@ -0,0 +1,8 @@
+#ifndef FIDDLE_CLOSURE_H
+#define FIDDLE_CLOSURE_H
+
+#include <fiddle.h>
+
+void Init_fiddle_closure(void);
+
+#endif
diff --git a/jni/ruby/ext/fiddle/conversions.c b/jni/ruby/ext/fiddle/conversions.c
new file mode 100644
index 0000000..d40ddc1
--- /dev/null
+++ b/jni/ruby/ext/fiddle/conversions.c
@@ -0,0 +1,141 @@
+#include <fiddle.h>
+
+ffi_type *
+int_to_ffi_type(int type)
+{
+ int signed_p = 1;
+
+ if (type < 0) {
+ type = -1 * type;
+ signed_p = 0;
+ }
+
+#define rb_ffi_type_of(t) (signed_p ? &ffi_type_s##t : &ffi_type_u##t)
+
+ switch (type) {
+ case TYPE_VOID:
+ return &ffi_type_void;
+ case TYPE_VOIDP:
+ return &ffi_type_pointer;
+ case TYPE_CHAR:
+ return rb_ffi_type_of(char);
+ case TYPE_SHORT:
+ return rb_ffi_type_of(short);
+ case TYPE_INT:
+ return rb_ffi_type_of(int);
+ case TYPE_LONG:
+ return rb_ffi_type_of(long);
+#if HAVE_LONG_LONG
+ case TYPE_LONG_LONG:
+ return rb_ffi_type_of(long_long);
+#endif
+ case TYPE_FLOAT:
+ return &ffi_type_float;
+ case TYPE_DOUBLE:
+ return &ffi_type_double;
+ default:
+ rb_raise(rb_eRuntimeError, "unknown type %d", type);
+ }
+ return &ffi_type_pointer;
+}
+
+void
+value_to_generic(int type, VALUE src, fiddle_generic * dst)
+{
+ switch (type) {
+ case TYPE_VOID:
+ break;
+ case TYPE_VOIDP:
+ dst->pointer = NUM2PTR(rb_Integer(src));
+ break;
+ case TYPE_CHAR:
+ dst->schar = (signed char)NUM2INT(src);
+ break;
+ case -TYPE_CHAR:
+ dst->uchar = (unsigned char)NUM2UINT(src);
+ break;
+ case TYPE_SHORT:
+ dst->sshort = (unsigned short)NUM2INT(src);
+ break;
+ case -TYPE_SHORT:
+ dst->sshort = (signed short)NUM2UINT(src);
+ break;
+ case TYPE_INT:
+ dst->sint = NUM2INT(src);
+ break;
+ case -TYPE_INT:
+ dst->uint = NUM2UINT(src);
+ break;
+ case TYPE_LONG:
+ dst->slong = NUM2LONG(src);
+ break;
+ case -TYPE_LONG:
+ dst->ulong = NUM2ULONG(src);
+ break;
+#if HAVE_LONG_LONG
+ case TYPE_LONG_LONG:
+ dst->slong_long = NUM2LL(src);
+ break;
+ case -TYPE_LONG_LONG:
+ dst->ulong_long = NUM2ULL(src);
+ break;
+#endif
+ case TYPE_FLOAT:
+ dst->ffloat = (float)NUM2DBL(src);
+ break;
+ case TYPE_DOUBLE:
+ dst->ddouble = NUM2DBL(src);
+ break;
+ default:
+ rb_raise(rb_eRuntimeError, "unknown type %d", type);
+ }
+}
+
+VALUE
+generic_to_value(VALUE rettype, fiddle_generic retval)
+{
+ int type = NUM2INT(rettype);
+ VALUE cPointer;
+
+ cPointer = rb_const_get(mFiddle, rb_intern("Pointer"));
+
+ switch (type) {
+ case TYPE_VOID:
+ return Qnil;
+ case TYPE_VOIDP:
+ return rb_funcall(cPointer, rb_intern("[]"), 1,
+ PTR2NUM((void *)retval.pointer));
+ case TYPE_CHAR:
+ return INT2NUM((signed char)retval.fffi_sarg);
+ case -TYPE_CHAR:
+ return INT2NUM((unsigned char)retval.fffi_arg);
+ case TYPE_SHORT:
+ return INT2NUM((signed short)retval.fffi_sarg);
+ case -TYPE_SHORT:
+ return INT2NUM((unsigned short)retval.fffi_arg);
+ case TYPE_INT:
+ return INT2NUM((signed int)retval.fffi_sarg);
+ case -TYPE_INT:
+ return UINT2NUM((unsigned int)retval.fffi_arg);
+ case TYPE_LONG:
+ return LONG2NUM(retval.slong);
+ case -TYPE_LONG:
+ return ULONG2NUM(retval.ulong);
+#if HAVE_LONG_LONG
+ case TYPE_LONG_LONG:
+ return LL2NUM(retval.slong_long);
+ case -TYPE_LONG_LONG:
+ return ULL2NUM(retval.ulong_long);
+#endif
+ case TYPE_FLOAT:
+ return rb_float_new(retval.ffloat);
+ case TYPE_DOUBLE:
+ return rb_float_new(retval.ddouble);
+ default:
+ rb_raise(rb_eRuntimeError, "unknown type %d", type);
+ }
+
+ UNREACHABLE;
+}
+
+/* vim: set noet sw=4 sts=4 */
diff --git a/jni/ruby/ext/fiddle/conversions.h b/jni/ruby/ext/fiddle/conversions.h
new file mode 100644
index 0000000..d0a08d6
--- /dev/null
+++ b/jni/ruby/ext/fiddle/conversions.h
@@ -0,0 +1,44 @@
+#ifndef FIDDLE_CONVERSIONS_H
+#define FIDDLE_CONVERSIONS_H
+
+#include <fiddle.h>
+
+typedef union
+{
+ ffi_arg fffi_arg; /* rvalue smaller than unsigned long */
+ ffi_sarg fffi_sarg; /* rvalue smaller than signed long */
+ unsigned char uchar; /* ffi_type_uchar */
+ signed char schar; /* ffi_type_schar */
+ unsigned short ushort; /* ffi_type_sshort */
+ signed short sshort; /* ffi_type_ushort */
+ unsigned int uint; /* ffi_type_uint */
+ signed int sint; /* ffi_type_sint */
+ unsigned long ulong; /* ffi_type_ulong */
+ signed long slong; /* ffi_type_slong */
+ float ffloat; /* ffi_type_float */
+ double ddouble; /* ffi_type_double */
+#if HAVE_LONG_LONG
+ unsigned LONG_LONG ulong_long; /* ffi_type_ulong_long */
+ signed LONG_LONG slong_long; /* ffi_type_ulong_long */
+#endif
+ void * pointer; /* ffi_type_pointer */
+} fiddle_generic;
+
+ffi_type * int_to_ffi_type(int type);
+void value_to_generic(int type, VALUE src, fiddle_generic * dst);
+VALUE generic_to_value(VALUE rettype, fiddle_generic retval);
+
+#define VALUE2GENERIC(_type, _src, _dst) value_to_generic((_type), (_src), (_dst))
+#define INT2FFI_TYPE(_type) int_to_ffi_type(_type)
+#define GENERIC2VALUE(_type, _retval) generic_to_value((_type), (_retval))
+
+#if SIZEOF_VOIDP == SIZEOF_LONG
+# define PTR2NUM(x) (ULONG2NUM((unsigned long)(x)))
+# define NUM2PTR(x) ((void*)(NUM2ULONG(x)))
+#else
+/* # error --->> Ruby/DL2 requires sizeof(void*) == sizeof(long) to be compiled. <<--- */
+# define PTR2NUM(x) (ULL2NUM((unsigned long long)(x)))
+# define NUM2PTR(x) ((void*)(NUM2ULL(x)))
+#endif
+
+#endif
diff --git a/jni/ruby/ext/fiddle/depend b/jni/ruby/ext/fiddle/depend
new file mode 100644
index 0000000..47ba44e
--- /dev/null
+++ b/jni/ruby/ext/fiddle/depend
@@ -0,0 +1,55 @@
+PWD =
+
+CONFIGURE_LIBFFI = \
+ $(LIBFFI_CONFIGURE) --disable-shared \
+ --host=$(LIBFFI_ARCH) --enable-builddir=$(arch) \
+ CC="$(CC)" CFLAGS="$(LIBFFI_CFLAGS)" \
+ LD="$(LD)" LDFLAGS="$(LIBFFI_LDFLAGS)"
+
+$(OBJS): $(HDRS) $(ruby_headers) \
+ $(hdrdir)/ruby/io.h \
+ $(hdrdir)/ruby/encoding.h \
+ $(hdrdir)/ruby/oniguruma.h
+
+$(STATIC_LIB) $(RUBYARCHDIR)/$(DLLIB) $(DLLIB): $(LIBFFI_A)
+
+$(OBJS): $(FFI_H)
+
+.PHONY: .FORCE hdr
+
+.FORCE:
+
+hdr: $(FFI_H)
+
+configure-libffi build-libffi: .FORCE
+configure-libffi \
+$(LIBFFI_DIR)/include/ffi.h \
+$(LIBFFI_DIR)/include/ffitarget.h \
+$(LIBFFI_DIR)/fficonfig.h \
+$(LIBFFI_DIR)/Makefile:
+ $(Q) $(MAKEDIRS) $(LIBFFI_DIR)
+ $(Q) $(CONFIGURE_LIBFFI)
+
+build-libffi: $(LIBFFI_A)
+build-libffi $(LIBFFI_A):
+ $(Q) $(SUBMAKE_LIBFFI)
+
+clean-libffi:
+ $(Q) $(SUBMAKE_LIBFFI) clean
+
+distclean-libffi:
+ $(Q) $(SUBMAKE_LIBFFI) distclean
+ $(Q) $(RM) $(LIBFFI_DIR)/local.exp
+ $(Q) $(RUBY) -rfileutils -e "FileUtils.rmdir(Dir.glob(ARGV[0]+'/**/'), :parents=>true)" $(LIBFFI_DIR)
+
+realclean-libffi:
+ $(Q) $(RMALL) $(LIBFFI_DIR)
+
+.PHONY clean-libffi distclean-libffi realclean-libffi: .FORCE
+.PHONY clean-none distclean-none realclean-none: .FORCE
+
+clean: clean-$(LIBFFI_CLEAN)
+distclean: distclean-$(LIBFFI_CLEAN)
+realclean: realclean-$(LIBFFI_CLEAN)
+
+.PHONY configure: configure-libffi
diff --git a/jni/ruby/ext/fiddle/extconf.h b/jni/ruby/ext/fiddle/extconf.h
new file mode 100644
index 0000000..8d7e7f0
--- /dev/null
+++ b/jni/ruby/ext/fiddle/extconf.h
@@ -0,0 +1,13 @@
+#ifndef EXTCONF_H
+#define EXTCONF_H
+#define HAVE_FFI_H 1
+#define RUBY_LIBFFI_MODVERSION 3001000
+#define HAVE_SYS_MMAN_H 1
+#define HAVE_DLFCN_H 1
+#define HAVE_DLOPEN 1
+#define HAVE_DLCLOSE 1
+#define HAVE_DLSYM 1
+#define HAVE_DLERROR 1
+#define HAVE_CONST_FFI_STDCALL 1
+#define SIGNEDNESS_OF_SIZE_T +1
+#endif
diff --git a/jni/ruby/ext/fiddle/extconf.rb b/jni/ruby/ext/fiddle/extconf.rb
new file mode 100644
index 0000000..5688086
--- /dev/null
+++ b/jni/ruby/ext/fiddle/extconf.rb
@@ -0,0 +1,168 @@
+require 'mkmf'
+
+# :stopdoc:
+
+if ! enable_config('bundled-libffi', false)
+ dir_config 'libffi'
+
+ pkg_config("libffi") and
+ ver = pkg_config("libffi", "modversion")
+
+ if have_header(ffi_header = 'ffi.h')
+ true
+ elsif have_header(ffi_header = 'ffi/ffi.h')
+ $defs.push(format('-DUSE_HEADER_HACKS'))
+ true
+ end and (have_library('ffi') || have_library('libffi'))
+end or
+begin
+ ver = Dir.glob("#{$srcdir}/libffi-*/")
+ .map {|n| File.basename(n)}
+ .max_by {|n| n.scan(/\d+/).map(&:to_i)}
+ unless ver
+ raise "missing libffi. Please install libffi."
+ end
+
+ srcdir = "#{$srcdir}/#{ver}"
+ ffi_header = 'ffi.h'
+ libffi = Struct.new(*%I[dir srcdir builddir include lib a cflags ldflags opt arch]).new
+ libffi.dir = ver
+ if $srcdir == "."
+ libffi.builddir = "#{ver}/#{RUBY_PLATFORM}"
+ libffi.srcdir = "."
+ else
+ libffi.builddir = libffi.dir
+ libffi.srcdir = relative_from(srcdir, "..")
+ end
+ libffi.include = "#{libffi.builddir}/include"
+ libffi.lib = "#{libffi.builddir}/.libs"
+ libffi.a = "#{libffi.lib}/libffi_convenience.#{$LIBEXT}"
+ nowarn = CONFIG.merge("warnflags"=>"")
+ libffi.cflags = RbConfig.expand("$(CFLAGS)", nowarn)
+ ver = ver[/libffi-(.*)/, 1]
+
+ FileUtils.mkdir_p(libffi.dir)
+ libffi.opt = CONFIG['configure_args'][/'(-C)'/, 1]
+ libffi.ldflags = RbConfig.expand("$(LDFLAGS) #{libpathflag([relative_from($topdir, "..")])} #{$LIBRUBYARG}")
+ libffi.arch = RbConfig::CONFIG['host']
+ if $mswin
+ $defs << "-DFFI_BUILDING"
+ libffi_config = "#{relative_from($srcdir, '..')}/win32/libffi-config.rb"
+ config = CONFIG.merge("top_srcdir" => $top_srcdir)
+ args = $ruby.gsub(/:\/=\\/, '')
+ args.gsub!(/\)\\/, ')/')
+ args = args.shellsplit
+ args.map! {|s| RbConfig.expand(s, config)}
+ args << '-C' << libffi.dir << libffi_config
+ opts = {}
+ else
+ args = %W[sh #{libffi.srcdir}/configure ]
+ opts = {chdir: libffi.dir}
+ end
+ cc = RbConfig::CONFIG['CC']
+ cxx = RbConfig::CONFIG['CXX']
+ ld = RbConfig::CONFIG['LD']
+ args.concat %W[
+ --srcdir=#{libffi.srcdir}
+ --host=#{libffi.arch}
+ --enable-builddir=#{RUBY_PLATFORM}
+ ]
+ args << ($enable_shared || !$static ? '--enable-shared' : '--enable-static')
+ args << libffi.opt if libffi.opt
+ args.concat %W[
+ CC=#{cc} CFLAGS=#{libffi.cflags}
+ CXX=#{cxx} CXXFLAGS=#{RbConfig.expand("$(CXXFLAGS)", nowarn)}
+ LD=#{ld} LDFLAGS=#{libffi.ldflags}
+ ]
+
+ FileUtils.rm_f("#{libffi.include}/ffitarget.h")
+ Logging::open do
+ Logging.message("%p in %p\n", args, opts)
+ system(*args, **opts) or
+ raise "failed to configure libffi. Please install libffi."
+ end
+ if $mswin && File.file?("#{libffi.include}/ffitarget.h")
+ FileUtils.rm_f("#{libffi.include}/ffitarget.h")
+ end
+ unless File.file?("#{libffi.include}/ffitarget.h")
+ FileUtils.cp("#{srcdir}/src/x86/ffitarget.h", libffi.include, preserve: true)
+ end
+ $INCFLAGS << " -I" << libffi.include
+end
+
+if ver
+ ver = ver.gsub(/-rc\d+/, '') # If ver contains rc version, just ignored.
+ ver = (ver.split('.') + [0,0])[0,3]
+ $defs.push(%{-DRUBY_LIBFFI_MODVERSION=#{ '%d%03d%03d' % ver }})
+end
+
+have_header 'sys/mman.h'
+
+if have_header "dlfcn.h"
+ have_library "dl"
+
+ %w{ dlopen dlclose dlsym }.each do |func|
+ abort "missing function #{func}" unless have_func(func)
+ end
+
+ have_func "dlerror"
+elsif have_header "windows.h"
+ %w{ LoadLibrary FreeLibrary GetProcAddress }.each do |func|
+ abort "missing function #{func}" unless have_func(func)
+ end
+end
+
+have_const('FFI_STDCALL', ffi_header)
+
+config = File.read(RbConfig.expand(File.join($arch_hdrdir, "ruby/config.h")))
+types = {"SIZE_T"=>"SSIZE_T", "PTRDIFF_T"=>nil, "INTPTR_T"=>nil}
+types.each do |type, signed|
+ if /^\#define\s+SIZEOF_#{type}\s+(SIZEOF_(.+)|\d+)/ =~ config
+ if size = $2 and size != 'VOIDP'
+ size = types.fetch(size) {size}
+ $defs << format("-DTYPE_%s=TYPE_%s", signed||type, size)
+ end
+ if signed
+ check_signedness(type.downcase, "stddef.h")
+ end
+ end
+end
+
+if libffi
+ $LOCAL_LIBS.prepend("./#{libffi.a} ").strip!
+end
+create_makefile 'fiddle' do |conf|
+ if !libffi
+ next conf << "LIBFFI_CLEAN = none\n"
+ elsif $gnumake && !$nmake
+ submake = "$(MAKE) -C $(LIBFFI_DIR)\n"
+ else
+ submake = "cd $(LIBFFI_DIR) && \\\n\t\t" << "#{config_string("exec")} $(MAKE)".strip
+ end
+ if $nmake
+ cmd = "$(RUBY) -C $(LIBFFI_DIR) #{libffi_config} --srcdir=$(LIBFFI_SRCDIR)"
+ else
+ cmd = "cd $(LIBFFI_DIR) && #$exec $(LIBFFI_SRCDIR)/configure #{libffi.opt}"
+ end
+ sep = "/"
+ seprpl = config_string('BUILD_FILE_SEPARATOR') {|s| sep = s; ":/=#{s}" if s != "/"} || ""
+ conf << <<-MK.gsub(/^ +| +$/, '')
+ PWD =
+ LIBFFI_CONFIGURE = #{cmd}
+ LIBFFI_ARCH = #{libffi.arch}
+ LIBFFI_SRCDIR = #{libffi.srcdir}
+ LIBFFI_DIR = #{libffi.dir}
+ LIBFFI_A = #{libffi.a}
+ LIBFFI_CFLAGS = #{libffi.cflags}
+ LIBFFI_LDFLAGS = #{libffi.ldflags}
+ FFI_H = $(LIBFFI_DIR)/include/ffi.h
+ SUBMAKE_LIBFFI = #{submake}
+ LIBFFI_CLEAN = libffi
+ MK
+end
+
+if libffi
+ $LIBPATH.pop
+end
+
+# :startdoc:
diff --git a/jni/ruby/ext/fiddle/extlibs b/jni/ruby/ext/fiddle/extlibs
new file mode 100644
index 0000000..7d5fda5
--- /dev/null
+++ b/jni/ruby/ext/fiddle/extlibs
@@ -0,0 +1,2 @@
+ftp://sourceware.org/pub/libffi/libffi-3.2.1.tar.gz md5:83b89587607e3eb65c70d361f13bab43
+ win32/libffi-3.2.1-mswin.patch -p0
diff --git a/jni/ruby/ext/fiddle/fiddle.c b/jni/ruby/ext/fiddle/fiddle.c
new file mode 100644
index 0000000..9f3d153
--- /dev/null
+++ b/jni/ruby/ext/fiddle/fiddle.c
@@ -0,0 +1,454 @@
+#include <fiddle.h>
+
+VALUE mFiddle;
+VALUE rb_eFiddleError;
+
+#ifndef TYPE_SSIZE_T
+# if SIZEOF_SIZE_T == SIZEOF_INT
+# define TYPE_SSIZE_T TYPE_INT
+# elif SIZEOF_SIZE_T == SIZEOF_LONG
+# define TYPE_SSIZE_T TYPE_LONG
+# elif defined HAVE_LONG_LONG && SIZEOF_SIZE_T == SIZEOF_LONG_LONG
+# define TYPE_SSIZE_T TYPE_LONG_LONG
+# endif
+#endif
+#define TYPE_SIZE_T (-1*SIGNEDNESS_OF_SIZE_T*TYPE_SSIZE_T)
+
+#ifndef TYPE_PTRDIFF_T
+# if SIZEOF_PTRDIFF_T == SIZEOF_INT
+# define TYPE_PTRDIFF_T TYPE_INT
+# elif SIZEOF_PTRDIFF_T == SIZEOF_LONG
+# define TYPE_PTRDIFF_T TYPE_LONG
+# elif defined HAVE_LONG_LONG && SIZEOF_PTRDIFF_T == SIZEOF_LONG_LONG
+# define TYPE_PTRDIFF_T TYPE_LONG_LONG
+# endif
+#endif
+
+#ifndef TYPE_INTPTR_T
+# if SIZEOF_INTPTR_T == SIZEOF_INT
+# define TYPE_INTPTR_T TYPE_INT
+# elif SIZEOF_INTPTR_T == SIZEOF_LONG
+# define TYPE_INTPTR_T TYPE_LONG
+# elif defined HAVE_LONG_LONG && SIZEOF_INTPTR_T == SIZEOF_LONG_LONG
+# define TYPE_INTPTR_T TYPE_LONG_LONG
+# endif
+#endif
+#define TYPE_UINTPTR_T (-TYPE_INTPTR_T)
+
+void Init_fiddle_pointer(void);
+
+/*
+ * call-seq: Fiddle.malloc(size)
+ *
+ * Allocate +size+ bytes of memory and return the integer memory address
+ * for the allocated memory.
+ */
+static VALUE
+rb_fiddle_malloc(VALUE self, VALUE size)
+{
+ void *ptr;
+
+ ptr = (void*)ruby_xmalloc(NUM2SIZET(size));
+ return PTR2NUM(ptr);
+}
+
+/*
+ * call-seq: Fiddle.realloc(addr, size)
+ *
+ * Change the size of the memory allocated at the memory location +addr+ to
+ * +size+ bytes. Returns the memory address of the reallocated memory, which
+ * may be different than the address passed in.
+ */
+static VALUE
+rb_fiddle_realloc(VALUE self, VALUE addr, VALUE size)
+{
+ void *ptr = NUM2PTR(addr);
+
+ ptr = (void*)ruby_xrealloc(ptr, NUM2SIZET(size));
+ return PTR2NUM(ptr);
+}
+
+/*
+ * call-seq: Fiddle.free(addr)
+ *
+ * Free the memory at address +addr+
+ */
+VALUE
+rb_fiddle_free(VALUE self, VALUE addr)
+{
+ void *ptr = NUM2PTR(addr);
+
+ ruby_xfree(ptr);
+ return Qnil;
+}
+
+/*
+ * call-seq: Fiddle.dlunwrap(addr)
+ *
+ * Returns the hexadecimal representation of a memory pointer address +addr+
+ *
+ * Example:
+ *
+ * lib = Fiddle.dlopen('/lib64/libc-2.15.so')
+ * => #<Fiddle::Handle:0x00000001342460>
+ *
+ * lib['strcpy'].to_s(16)
+ * => "7f59de6dd240"
+ *
+ * Fiddle.dlunwrap(Fiddle.dlwrap(lib['strcpy'].to_s(16)))
+ * => "7f59de6dd240"
+ */
+VALUE
+rb_fiddle_ptr2value(VALUE self, VALUE addr)
+{
+ return (VALUE)NUM2PTR(addr);
+}
+
+/*
+ * call-seq: Fiddle.dlwrap(val)
+ *
+ * Returns a memory pointer of a function's hexadecimal address location +val+
+ *
+ * Example:
+ *
+ * lib = Fiddle.dlopen('/lib64/libc-2.15.so')
+ * => #<Fiddle::Handle:0x00000001342460>
+ *
+ * Fiddle.dlwrap(lib['strcpy'].to_s(16))
+ * => 25522520
+ */
+static VALUE
+rb_fiddle_value2ptr(VALUE self, VALUE val)
+{
+ return PTR2NUM((void*)val);
+}
+
+void Init_fiddle_handle(void);
+
+void
+Init_fiddle(void)
+{
+ /*
+ * Document-module: Fiddle
+ *
+ * A libffi wrapper for Ruby.
+ *
+ * == Description
+ *
+ * Fiddle is an extension to translate a foreign function interface (FFI)
+ * with ruby.
+ *
+ * It wraps {libffi}[http://sourceware.org/libffi/], a popular C library
+ * which provides a portable interface that allows code written in one
+ * language to call code written in another language.
+ *
+ * == Example
+ *
+ * Here we will use Fiddle::Function to wrap {floor(3) from
+ * libm}[http://linux.die.net/man/3/floor]
+ *
+ * require 'fiddle'
+ *
+ * libm = Fiddle.dlopen('/lib/libm.so.6')
+ *
+ * floor = Fiddle::Function.new(
+ * libm['floor'],
+ * [Fiddle::TYPE_DOUBLE],
+ * Fiddle::TYPE_DOUBLE
+ * )
+ *
+ * puts floor.call(3.14159) #=> 3.0
+ *
+ *
+ */
+ mFiddle = rb_define_module("Fiddle");
+
+ /*
+ * Document-class: Fiddle::DLError
+ *
+ * standard dynamic load exception
+ */
+ rb_eFiddleError = rb_define_class_under(mFiddle, "DLError", rb_eStandardError);
+
+ /* Document-const: TYPE_VOID
+ *
+ * C type - void
+ */
+ rb_define_const(mFiddle, "TYPE_VOID", INT2NUM(TYPE_VOID));
+
+ /* Document-const: TYPE_VOIDP
+ *
+ * C type - void*
+ */
+ rb_define_const(mFiddle, "TYPE_VOIDP", INT2NUM(TYPE_VOIDP));
+
+ /* Document-const: TYPE_CHAR
+ *
+ * C type - char
+ */
+ rb_define_const(mFiddle, "TYPE_CHAR", INT2NUM(TYPE_CHAR));
+
+ /* Document-const: TYPE_SHORT
+ *
+ * C type - short
+ */
+ rb_define_const(mFiddle, "TYPE_SHORT", INT2NUM(TYPE_SHORT));
+
+ /* Document-const: TYPE_INT
+ *
+ * C type - int
+ */
+ rb_define_const(mFiddle, "TYPE_INT", INT2NUM(TYPE_INT));
+
+ /* Document-const: TYPE_LONG
+ *
+ * C type - long
+ */
+ rb_define_const(mFiddle, "TYPE_LONG", INT2NUM(TYPE_LONG));
+
+#if HAVE_LONG_LONG
+ /* Document-const: TYPE_LONG_LONG
+ *
+ * C type - long long
+ */
+ rb_define_const(mFiddle, "TYPE_LONG_LONG", INT2NUM(TYPE_LONG_LONG));
+#endif
+
+ /* Document-const: TYPE_FLOAT
+ *
+ * C type - float
+ */
+ rb_define_const(mFiddle, "TYPE_FLOAT", INT2NUM(TYPE_FLOAT));
+
+ /* Document-const: TYPE_DOUBLE
+ *
+ * C type - double
+ */
+ rb_define_const(mFiddle, "TYPE_DOUBLE", INT2NUM(TYPE_DOUBLE));
+
+ /* Document-const: TYPE_SIZE_T
+ *
+ * C type - size_t
+ */
+ rb_define_const(mFiddle, "TYPE_SIZE_T", INT2NUM(TYPE_SIZE_T));
+
+ /* Document-const: TYPE_SSIZE_T
+ *
+ * C type - ssize_t
+ */
+ rb_define_const(mFiddle, "TYPE_SSIZE_T", INT2NUM(TYPE_SSIZE_T));
+
+ /* Document-const: TYPE_PTRDIFF_T
+ *
+ * C type - ptrdiff_t
+ */
+ rb_define_const(mFiddle, "TYPE_PTRDIFF_T", INT2NUM(TYPE_PTRDIFF_T));
+
+ /* Document-const: TYPE_INTPTR_T
+ *
+ * C type - intptr_t
+ */
+ rb_define_const(mFiddle, "TYPE_INTPTR_T", INT2NUM(TYPE_INTPTR_T));
+
+ /* Document-const: TYPE_UINTPTR_T
+ *
+ * C type - uintptr_t
+ */
+ rb_define_const(mFiddle, "TYPE_UINTPTR_T", INT2NUM(TYPE_UINTPTR_T));
+
+ /* Document-const: ALIGN_VOIDP
+ *
+ * The alignment size of a void*
+ */
+ rb_define_const(mFiddle, "ALIGN_VOIDP", INT2NUM(ALIGN_VOIDP));
+
+ /* Document-const: ALIGN_CHAR
+ *
+ * The alignment size of a char
+ */
+ rb_define_const(mFiddle, "ALIGN_CHAR", INT2NUM(ALIGN_CHAR));
+
+ /* Document-const: ALIGN_SHORT
+ *
+ * The alignment size of a short
+ */
+ rb_define_const(mFiddle, "ALIGN_SHORT", INT2NUM(ALIGN_SHORT));
+
+ /* Document-const: ALIGN_INT
+ *
+ * The alignment size of an int
+ */
+ rb_define_const(mFiddle, "ALIGN_INT", INT2NUM(ALIGN_INT));
+
+ /* Document-const: ALIGN_LONG
+ *
+ * The alignment size of a long
+ */
+ rb_define_const(mFiddle, "ALIGN_LONG", INT2NUM(ALIGN_LONG));
+
+#if HAVE_LONG_LONG
+ /* Document-const: ALIGN_LONG_LONG
+ *
+ * The alignment size of a long long
+ */
+ rb_define_const(mFiddle, "ALIGN_LONG_LONG", INT2NUM(ALIGN_LONG_LONG));
+#endif
+
+ /* Document-const: ALIGN_FLOAT
+ *
+ * The alignment size of a float
+ */
+ rb_define_const(mFiddle, "ALIGN_FLOAT", INT2NUM(ALIGN_FLOAT));
+
+ /* Document-const: ALIGN_DOUBLE
+ *
+ * The alignment size of a double
+ */
+ rb_define_const(mFiddle, "ALIGN_DOUBLE",INT2NUM(ALIGN_DOUBLE));
+
+ /* Document-const: ALIGN_SIZE_T
+ *
+ * The alignment size of a size_t
+ */
+ rb_define_const(mFiddle, "ALIGN_SIZE_T", INT2NUM(ALIGN_OF(size_t)));
+
+ /* Document-const: ALIGN_SSIZE_T
+ *
+ * The alignment size of a ssize_t
+ */
+ rb_define_const(mFiddle, "ALIGN_SSIZE_T", INT2NUM(ALIGN_OF(size_t))); /* same as size_t */
+
+ /* Document-const: ALIGN_PTRDIFF_T
+ *
+ * The alignment size of a ptrdiff_t
+ */
+ rb_define_const(mFiddle, "ALIGN_PTRDIFF_T", INT2NUM(ALIGN_OF(ptrdiff_t)));
+
+ /* Document-const: ALIGN_INTPTR_T
+ *
+ * The alignment size of a intptr_t
+ */
+ rb_define_const(mFiddle, "ALIGN_INTPTR_T", INT2NUM(ALIGN_OF(intptr_t)));
+
+ /* Document-const: ALIGN_UINTPTR_T
+ *
+ * The alignment size of a uintptr_t
+ */
+ rb_define_const(mFiddle, "ALIGN_UINTPTR_T", INT2NUM(ALIGN_OF(uintptr_t)));
+
+ /* Document-const: WINDOWS
+ *
+ * Returns a boolean regarding whether the host is WIN32
+ */
+#if defined(_WIN32)
+ rb_define_const(mFiddle, "WINDOWS", Qtrue);
+#else
+ rb_define_const(mFiddle, "WINDOWS", Qfalse);
+#endif
+
+ /* Document-const: SIZEOF_VOIDP
+ *
+ * size of a void*
+ */
+ rb_define_const(mFiddle, "SIZEOF_VOIDP", INT2NUM(sizeof(void*)));
+
+ /* Document-const: SIZEOF_CHAR
+ *
+ * size of a char
+ */
+ rb_define_const(mFiddle, "SIZEOF_CHAR", INT2NUM(sizeof(char)));
+
+ /* Document-const: SIZEOF_SHORT
+ *
+ * size of a short
+ */
+ rb_define_const(mFiddle, "SIZEOF_SHORT", INT2NUM(sizeof(short)));
+
+ /* Document-const: SIZEOF_INT
+ *
+ * size of an int
+ */
+ rb_define_const(mFiddle, "SIZEOF_INT", INT2NUM(sizeof(int)));
+
+ /* Document-const: SIZEOF_LONG
+ *
+ * size of a long
+ */
+ rb_define_const(mFiddle, "SIZEOF_LONG", INT2NUM(sizeof(long)));
+
+#if HAVE_LONG_LONG
+ /* Document-const: SIZEOF_LONG_LONG
+ *
+ * size of a long long
+ */
+ rb_define_const(mFiddle, "SIZEOF_LONG_LONG", INT2NUM(sizeof(LONG_LONG)));
+#endif
+
+ /* Document-const: SIZEOF_FLOAT
+ *
+ * size of a float
+ */
+ rb_define_const(mFiddle, "SIZEOF_FLOAT", INT2NUM(sizeof(float)));
+
+ /* Document-const: SIZEOF_DOUBLE
+ *
+ * size of a double
+ */
+ rb_define_const(mFiddle, "SIZEOF_DOUBLE",INT2NUM(sizeof(double)));
+
+ /* Document-const: SIZEOF_SIZE_T
+ *
+ * size of a size_t
+ */
+ rb_define_const(mFiddle, "SIZEOF_SIZE_T", INT2NUM(sizeof(size_t)));
+
+ /* Document-const: SIZEOF_SSIZE_T
+ *
+ * size of a ssize_t
+ */
+ rb_define_const(mFiddle, "SIZEOF_SSIZE_T", INT2NUM(sizeof(size_t))); /* same as size_t */
+
+ /* Document-const: SIZEOF_PTRDIFF_T
+ *
+ * size of a ptrdiff_t
+ */
+ rb_define_const(mFiddle, "SIZEOF_PTRDIFF_T", INT2NUM(sizeof(ptrdiff_t)));
+
+ /* Document-const: SIZEOF_INTPTR_T
+ *
+ * size of a intptr_t
+ */
+ rb_define_const(mFiddle, "SIZEOF_INTPTR_T", INT2NUM(sizeof(intptr_t)));
+
+ /* Document-const: SIZEOF_UINTPTR_T
+ *
+ * size of a uintptr_t
+ */
+ rb_define_const(mFiddle, "SIZEOF_UINTPTR_T", INT2NUM(sizeof(uintptr_t)));
+
+ /* Document-const: RUBY_FREE
+ *
+ * Address of the ruby_xfree() function
+ */
+ rb_define_const(mFiddle, "RUBY_FREE", PTR2NUM(ruby_xfree));
+
+ /* Document-const: BUILD_RUBY_PLATFORM
+ *
+ * Platform built against (i.e. "x86_64-linux", etc.)
+ *
+ * See also RUBY_PLATFORM
+ */
+ rb_define_const(mFiddle, "BUILD_RUBY_PLATFORM", rb_str_new2(RUBY_PLATFORM));
+
+ rb_define_module_function(mFiddle, "dlwrap", rb_fiddle_value2ptr, 1);
+ rb_define_module_function(mFiddle, "dlunwrap", rb_fiddle_ptr2value, 1);
+ rb_define_module_function(mFiddle, "malloc", rb_fiddle_malloc, 1);
+ rb_define_module_function(mFiddle, "realloc", rb_fiddle_realloc, 2);
+ rb_define_module_function(mFiddle, "free", rb_fiddle_free, 1);
+
+ Init_fiddle_function();
+ Init_fiddle_closure();
+ Init_fiddle_handle();
+ Init_fiddle_pointer();
+}
+/* vim: set noet sws=4 sw=4: */
diff --git a/jni/ruby/ext/fiddle/fiddle.h b/jni/ruby/ext/fiddle/fiddle.h
new file mode 100644
index 0000000..d2583c1
--- /dev/null
+++ b/jni/ruby/ext/fiddle/fiddle.h
@@ -0,0 +1,138 @@
+#ifndef FIDDLE_H
+#define FIDDLE_H
+
+#include <ruby.h>
+#include <errno.h>
+
+#if defined(_WIN32)
+#include <windows.h>
+#endif
+
+#ifdef HAVE_SYS_MMAN_H
+#include <sys/mman.h>
+#endif
+
+#if defined(HAVE_DLFCN_H)
+# include <dlfcn.h>
+# /* some stranger systems may not define all of these */
+#ifndef RTLD_LAZY
+#define RTLD_LAZY 0
+#endif
+#ifndef RTLD_GLOBAL
+#define RTLD_GLOBAL 0
+#endif
+#ifndef RTLD_NOW
+#define RTLD_NOW 0
+#endif
+#else
+# if defined(_WIN32)
+# include <windows.h>
+# define dlopen(name,flag) ((void*)LoadLibrary(name))
+# define dlerror() strerror(rb_w32_map_errno(GetLastError()))
+# define dlsym(handle,name) ((void*)GetProcAddress((handle),(name)))
+# define RTLD_LAZY -1
+# define RTLD_NOW -1
+# define RTLD_GLOBAL -1
+# endif
+#endif
+
+#ifdef USE_HEADER_HACKS
+#include <ffi/ffi.h>
+#else
+#include <ffi.h>
+#endif
+
+#undef ffi_type_uchar
+#undef ffi_type_schar
+#undef ffi_type_ushort
+#undef ffi_type_sshort
+#undef ffi_type_uint
+#undef ffi_type_sint
+#undef ffi_type_ulong
+#undef ffi_type_slong
+
+#if CHAR_BIT == 8
+# define ffi_type_uchar ffi_type_uint8
+# define ffi_type_schar ffi_type_sint8
+#else
+# error "CHAR_BIT not supported"
+#endif
+
+# if SIZEOF_SHORT == 2
+# define ffi_type_ushort ffi_type_uint16
+# define ffi_type_sshort ffi_type_sint16
+# elif SIZEOF_SHORT == 4
+# define ffi_type_ushort ffi_type_uint32
+# define ffi_type_sshort ffi_type_sint32
+# else
+# error "short size not supported"
+# endif
+
+# if SIZEOF_INT == 2
+# define ffi_type_uint ffi_type_uint16
+# define ffi_type_sint ffi_type_sint16
+# elif SIZEOF_INT == 4
+# define ffi_type_uint ffi_type_uint32
+# define ffi_type_sint ffi_type_sint32
+# elif SIZEOF_INT == 8
+# define ffi_type_uint ffi_type_uint64
+# define ffi_type_sint ffi_type_sint64
+# else
+# error "int size not supported"
+# endif
+
+# if SIZEOF_LONG == 4
+# define ffi_type_ulong ffi_type_uint32
+# define ffi_type_slong ffi_type_sint32
+# elif SIZEOF_LONG == 8
+# define ffi_type_ulong ffi_type_uint64
+# define ffi_type_slong ffi_type_sint64
+# else
+# error "long size not supported"
+# endif
+
+#if HAVE_LONG_LONG
+# if SIZEOF_LONG_LONG == 8
+# define ffi_type_slong_long ffi_type_sint64
+# define ffi_type_ulong_long ffi_type_uint64
+# else
+# error "long long size not supported"
+# endif
+#endif
+
+#include <closure.h>
+#include <conversions.h>
+#include <function.h>
+
+#define TYPE_VOID 0
+#define TYPE_VOIDP 1
+#define TYPE_CHAR 2
+#define TYPE_SHORT 3
+#define TYPE_INT 4
+#define TYPE_LONG 5
+#if HAVE_LONG_LONG
+#define TYPE_LONG_LONG 6
+#endif
+#define TYPE_FLOAT 7
+#define TYPE_DOUBLE 8
+
+#define ALIGN_OF(type) offsetof(struct {char align_c; type align_x;}, align_x)
+
+#define ALIGN_VOIDP ALIGN_OF(void*)
+#define ALIGN_SHORT ALIGN_OF(short)
+#define ALIGN_CHAR ALIGN_OF(char)
+#define ALIGN_INT ALIGN_OF(int)
+#define ALIGN_LONG ALIGN_OF(long)
+#if HAVE_LONG_LONG
+#define ALIGN_LONG_LONG ALIGN_OF(LONG_LONG)
+#endif
+#define ALIGN_FLOAT ALIGN_OF(float)
+#define ALIGN_DOUBLE ALIGN_OF(double)
+
+extern VALUE mFiddle;
+extern VALUE rb_eFiddleError;
+
+VALUE rb_fiddle_new_function(VALUE address, VALUE arg_types, VALUE ret_type);
+
+#endif
+/* vim: set noet sws=4 sw=4: */
diff --git a/jni/ruby/ext/fiddle/function.c b/jni/ruby/ext/fiddle/function.c
new file mode 100644
index 0000000..e0da8b6
--- /dev/null
+++ b/jni/ruby/ext/fiddle/function.c
@@ -0,0 +1,279 @@
+#include <fiddle.h>
+
+#ifdef PRIsVALUE
+# define RB_OBJ_CLASSNAME(obj) rb_obj_class(obj)
+# define RB_OBJ_STRING(obj) (obj)
+#else
+# define PRIsVALUE "s"
+# define RB_OBJ_CLASSNAME(obj) rb_obj_classname(obj)
+# define RB_OBJ_STRING(obj) StringValueCStr(obj)
+#endif
+
+VALUE cFiddleFunction;
+
+#define MAX_ARGS (SIZE_MAX / (sizeof(void *) + sizeof(fiddle_generic)) - 1)
+
+#define Check_Max_Args(name, len) \
+ if ((size_t)(len) < MAX_ARGS) { \
+ /* OK */ \
+ } \
+ else { \
+ rb_raise(rb_eTypeError, \
+ name" is so large that it can cause integer overflow (%d)", \
+ (len)); \
+ }
+
+static void
+deallocate(void *p)
+{
+ ffi_cif *ptr = p;
+ if (ptr->arg_types) xfree(ptr->arg_types);
+ xfree(ptr);
+}
+
+static size_t
+function_memsize(const void *p)
+{
+ /* const */ffi_cif *ptr = (ffi_cif *)p;
+ size_t size = 0;
+
+ if (ptr) {
+ size += sizeof(*ptr);
+#if !defined(FFI_NO_RAW_API) || !FFI_NO_RAW_API
+ size += ffi_raw_size(ptr);
+#endif
+ }
+ return size;
+}
+
+const rb_data_type_t function_data_type = {
+ "fiddle/function",
+ {0, deallocate, function_memsize,},
+};
+
+static VALUE
+allocate(VALUE klass)
+{
+ ffi_cif * cif;
+
+ return TypedData_Make_Struct(klass, ffi_cif, &function_data_type, cif);
+}
+
+VALUE
+rb_fiddle_new_function(VALUE address, VALUE arg_types, VALUE ret_type)
+{
+ VALUE argv[3];
+
+ argv[0] = address;
+ argv[1] = arg_types;
+ argv[2] = ret_type;
+
+ return rb_class_new_instance(3, argv, cFiddleFunction);
+}
+
+static int
+parse_keyword_arg_i(VALUE key, VALUE value, VALUE self)
+{
+ if (key == ID2SYM(rb_intern("name"))) {
+ rb_iv_set(self, "@name", value);
+ } else {
+ rb_raise(rb_eArgError, "unknown keyword: %"PRIsVALUE,
+ RB_OBJ_STRING(key));
+ }
+ return ST_CONTINUE;
+}
+
+static VALUE
+initialize(int argc, VALUE argv[], VALUE self)
+{
+ ffi_cif * cif;
+ ffi_type **arg_types;
+ ffi_status result;
+ VALUE ptr, args, ret_type, abi, kwds;
+ int i;
+
+ rb_scan_args(argc, argv, "31:", &ptr, &args, &ret_type, &abi, &kwds);
+ if(NIL_P(abi)) abi = INT2NUM(FFI_DEFAULT_ABI);
+
+ Check_Type(args, T_ARRAY);
+ Check_Max_Args("args", RARRAY_LENINT(args));
+
+ rb_iv_set(self, "@ptr", ptr);
+ rb_iv_set(self, "@args", args);
+ rb_iv_set(self, "@return_type", ret_type);
+ rb_iv_set(self, "@abi", abi);
+
+ if (!NIL_P(kwds)) rb_hash_foreach(kwds, parse_keyword_arg_i, self);
+
+ TypedData_Get_Struct(self, ffi_cif, &function_data_type, cif);
+
+ arg_types = xcalloc(RARRAY_LEN(args) + 1, sizeof(ffi_type *));
+
+ for (i = 0; i < RARRAY_LEN(args); i++) {
+ int type = NUM2INT(RARRAY_PTR(args)[i]);
+ arg_types[i] = INT2FFI_TYPE(type);
+ }
+ arg_types[RARRAY_LEN(args)] = NULL;
+
+ result = ffi_prep_cif (
+ cif,
+ NUM2INT(abi),
+ RARRAY_LENINT(args),
+ INT2FFI_TYPE(NUM2INT(ret_type)),
+ arg_types);
+
+ if (result)
+ rb_raise(rb_eRuntimeError, "error creating CIF %d", result);
+
+ return self;
+}
+
+static VALUE
+function_call(int argc, VALUE argv[], VALUE self)
+{
+ ffi_cif * cif;
+ fiddle_generic retval;
+ fiddle_generic *generic_args;
+ void **values;
+ VALUE cfunc, types, cPointer;
+ int i;
+ VALUE alloc_buffer = 0;
+
+ cfunc = rb_iv_get(self, "@ptr");
+ types = rb_iv_get(self, "@args");
+ cPointer = rb_const_get(mFiddle, rb_intern("Pointer"));
+
+ Check_Max_Args("number of arguments", argc);
+ if(argc != RARRAY_LENINT(types)) {
+ rb_raise(rb_eArgError, "wrong number of arguments (%d for %d)",
+ argc, RARRAY_LENINT(types));
+ }
+
+ TypedData_Get_Struct(self, ffi_cif, &function_data_type, cif);
+
+ if (rb_safe_level() >= 1) {
+ for (i = 0; i < argc; i++) {
+ VALUE src = argv[i];
+ if (OBJ_TAINTED(src)) {
+ rb_raise(rb_eSecurityError, "tainted parameter not allowed");
+ }
+ }
+ }
+
+ generic_args = ALLOCV(alloc_buffer,
+ (size_t)(argc + 1) * sizeof(void *) + (size_t)argc * sizeof(fiddle_generic));
+ values = (void **)((char *)generic_args + (size_t)argc * sizeof(fiddle_generic));
+
+ for (i = 0; i < argc; i++) {
+ VALUE type = RARRAY_PTR(types)[i];
+ VALUE src = argv[i];
+
+ if(NUM2INT(type) == TYPE_VOIDP) {
+ if(NIL_P(src)) {
+ src = INT2FIX(0);
+ } else if(cPointer != CLASS_OF(src)) {
+ src = rb_funcall(cPointer, rb_intern("[]"), 1, src);
+ }
+ src = rb_Integer(src);
+ }
+
+ VALUE2GENERIC(NUM2INT(type), src, &generic_args[i]);
+ values[i] = (void *)&generic_args[i];
+ }
+ values[argc] = NULL;
+
+ ffi_call(cif, NUM2PTR(rb_Integer(cfunc)), &retval, values);
+
+ rb_funcall(mFiddle, rb_intern("last_error="), 1, INT2NUM(errno));
+#if defined(_WIN32)
+ rb_funcall(mFiddle, rb_intern("win32_last_error="), 1, INT2NUM(errno));
+#endif
+
+ ALLOCV_END(alloc_buffer);
+
+ return GENERIC2VALUE(rb_iv_get(self, "@return_type"), retval);
+}
+
+void
+Init_fiddle_function(void)
+{
+ /*
+ * Document-class: Fiddle::Function
+ *
+ * == Description
+ *
+ * A representation of a C function
+ *
+ * == Examples
+ *
+ * === 'strcpy'
+ *
+ * @libc = Fiddle.dlopen "/lib/libc.so.6"
+ * #=> #<Fiddle::Handle:0x00000001d7a8d8>
+ * f = Fiddle::Function.new(
+ * @libc['strcpy'],
+ * [Fiddle::TYPE_VOIDP, Fiddle::TYPE_VOIDP],
+ * Fiddle::TYPE_VOIDP)
+ * #=> #<Fiddle::Function:0x00000001d8ee00>
+ * buff = "000"
+ * #=> "000"
+ * str = f.call(buff, "123")
+ * #=> #<Fiddle::Pointer:0x00000001d0c380 ptr=0x000000018a21b8 size=0 free=0x00000000000000>
+ * str.to_s
+ * => "123"
+ *
+ * === ABI check
+ *
+ * @libc = Fiddle.dlopen "/lib/libc.so.6"
+ * #=> #<Fiddle::Handle:0x00000001d7a8d8>
+ * f = Fiddle::Function.new(@libc['strcpy'], [TYPE_VOIDP, TYPE_VOIDP], TYPE_VOIDP)
+ * #=> #<Fiddle::Function:0x00000001d8ee00>
+ * f.abi == Fiddle::Function::DEFAULT
+ * #=> true
+ */
+ cFiddleFunction = rb_define_class_under(mFiddle, "Function", rb_cObject);
+
+ /*
+ * Document-const: DEFAULT
+ *
+ * Default ABI
+ *
+ */
+ rb_define_const(cFiddleFunction, "DEFAULT", INT2NUM(FFI_DEFAULT_ABI));
+
+#ifdef HAVE_CONST_FFI_STDCALL
+ /*
+ * Document-const: STDCALL
+ *
+ * FFI implementation of WIN32 stdcall convention
+ *
+ */
+ rb_define_const(cFiddleFunction, "STDCALL", INT2NUM(FFI_STDCALL));
+#endif
+
+ rb_define_alloc_func(cFiddleFunction, allocate);
+
+ /*
+ * Document-method: call
+ *
+ * Calls the constructed Function, with +args+
+ *
+ * For an example see Fiddle::Function
+ *
+ */
+ rb_define_method(cFiddleFunction, "call", function_call, -1);
+
+ /*
+ * Document-method: new
+ * call-seq: new(ptr, args, ret_type, abi = DEFAULT)
+ *
+ * Constructs a Function object.
+ * * +ptr+ is a referenced function, of a Fiddle::Handle
+ * * +args+ is an Array of arguments, passed to the +ptr+ function
+ * * +ret_type+ is the return type of the function
+ * * +abi+ is the ABI of the function
+ *
+ */
+ rb_define_method(cFiddleFunction, "initialize", initialize, -1);
+}
+/* vim: set noet sws=4 sw=4: */
diff --git a/jni/ruby/ext/fiddle/function.h b/jni/ruby/ext/fiddle/function.h
new file mode 100644
index 0000000..829e592
--- /dev/null
+++ b/jni/ruby/ext/fiddle/function.h
@@ -0,0 +1,8 @@
+#ifndef FIDDLE_FUNCTION_H
+#define FIDDLE_FUNCTION_H
+
+#include <fiddle.h>
+
+void Init_fiddle_function(void);
+
+#endif
diff --git a/jni/ruby/ext/fiddle/handle.c b/jni/ruby/ext/fiddle/handle.c
new file mode 100644
index 0000000..4cfeeda
--- /dev/null
+++ b/jni/ruby/ext/fiddle/handle.c
@@ -0,0 +1,479 @@
+#include <ruby.h>
+#include <fiddle.h>
+
+VALUE rb_cHandle;
+
+struct dl_handle {
+ void *ptr;
+ int open;
+ int enable_close;
+};
+
+#ifdef _WIN32
+# ifndef _WIN32_WCE
+static void *
+w32_coredll(void)
+{
+ MEMORY_BASIC_INFORMATION m;
+ memset(&m, 0, sizeof(m));
+ if( !VirtualQuery(_errno, &m, sizeof(m)) ) return NULL;
+ return m.AllocationBase;
+}
+# endif
+
+static int
+w32_dlclose(void *ptr)
+{
+# ifndef _WIN32_WCE
+ if( ptr == w32_coredll() ) return 0;
+# endif
+ if( FreeLibrary((HMODULE)ptr) ) return 0;
+ return errno = rb_w32_map_errno(GetLastError());
+}
+#define dlclose(ptr) w32_dlclose(ptr)
+#endif
+
+static void
+fiddle_handle_free(void *ptr)
+{
+ struct dl_handle *fiddle_handle = ptr;
+ if( fiddle_handle->ptr && fiddle_handle->open && fiddle_handle->enable_close ){
+ dlclose(fiddle_handle->ptr);
+ }
+ xfree(ptr);
+}
+
+static size_t
+fiddle_handle_memsize(const void *ptr)
+{
+ return ptr ? sizeof(struct dl_handle) : 0;
+}
+
+static const rb_data_type_t fiddle_handle_data_type = {
+ "fiddle/handle",
+ {0, fiddle_handle_free, fiddle_handle_memsize,},
+};
+
+/*
+ * call-seq: close
+ *
+ * Close this handle.
+ *
+ * Calling close more than once will raise a Fiddle::DLError exception.
+ */
+static VALUE
+rb_fiddle_handle_close(VALUE self)
+{
+ struct dl_handle *fiddle_handle;
+
+ TypedData_Get_Struct(self, struct dl_handle, &fiddle_handle_data_type, fiddle_handle);
+ if(fiddle_handle->open) {
+ int ret = dlclose(fiddle_handle->ptr);
+ fiddle_handle->open = 0;
+
+ /* Check dlclose for successful return value */
+ if(ret) {
+#if defined(HAVE_DLERROR)
+ rb_raise(rb_eFiddleError, "%s", dlerror());
+#else
+ rb_raise(rb_eFiddleError, "could not close handle");
+#endif
+ }
+ return INT2NUM(ret);
+ }
+ rb_raise(rb_eFiddleError, "dlclose() called too many times");
+
+ UNREACHABLE;
+}
+
+static VALUE
+rb_fiddle_handle_s_allocate(VALUE klass)
+{
+ VALUE obj;
+ struct dl_handle *fiddle_handle;
+
+ obj = TypedData_Make_Struct(rb_cHandle, struct dl_handle, &fiddle_handle_data_type, fiddle_handle);
+ fiddle_handle->ptr = 0;
+ fiddle_handle->open = 0;
+ fiddle_handle->enable_close = 0;
+
+ return obj;
+}
+
+static VALUE
+predefined_fiddle_handle(void *handle)
+{
+ VALUE obj = rb_fiddle_handle_s_allocate(rb_cHandle);
+ struct dl_handle *fiddle_handle = DATA_PTR(obj);
+
+ fiddle_handle->ptr = handle;
+ fiddle_handle->open = 1;
+ OBJ_FREEZE(obj);
+ return obj;
+}
+
+/*
+ * call-seq:
+ * new(library = nil, flags = Fiddle::RTLD_LAZY | Fiddle::RTLD_GLOBAL)
+ *
+ * Create a new handler that opens +library+ with +flags+.
+ *
+ * If no +library+ is specified or +nil+ is given, DEFAULT is used, which is
+ * the equivalent to RTLD_DEFAULT. See <code>man 3 dlopen</code> for more.
+ *
+ * lib = Fiddle::Handle.new
+ *
+ * The default is dependent on OS, and provide a handle for all libraries
+ * already loaded. For example, in most cases you can use this to access +libc+
+ * functions, or ruby functions like +rb_str_new+.
+ */
+static VALUE
+rb_fiddle_handle_initialize(int argc, VALUE argv[], VALUE self)
+{
+ void *ptr;
+ struct dl_handle *fiddle_handle;
+ VALUE lib, flag;
+ char *clib;
+ int cflag;
+ const char *err;
+
+ switch( rb_scan_args(argc, argv, "02", &lib, &flag) ){
+ case 0:
+ clib = NULL;
+ cflag = RTLD_LAZY | RTLD_GLOBAL;
+ break;
+ case 1:
+ clib = NIL_P(lib) ? NULL : StringValuePtr(lib);
+ cflag = RTLD_LAZY | RTLD_GLOBAL;
+ break;
+ case 2:
+ clib = NIL_P(lib) ? NULL : StringValuePtr(lib);
+ cflag = NUM2INT(flag);
+ break;
+ default:
+ rb_bug("rb_fiddle_handle_new");
+ }
+
+ rb_secure(2);
+
+#if defined(_WIN32)
+ if( !clib ){
+ HANDLE rb_libruby_handle(void);
+ ptr = rb_libruby_handle();
+ }
+ else if( STRCASECMP(clib, "libc") == 0
+# ifdef RUBY_COREDLL
+ || STRCASECMP(clib, RUBY_COREDLL) == 0
+ || STRCASECMP(clib, RUBY_COREDLL".dll") == 0
+# endif
+ ){
+# ifdef _WIN32_WCE
+ ptr = dlopen("coredll.dll", cflag);
+# else
+ (void)cflag;
+ ptr = w32_coredll();
+# endif
+ }
+ else
+#endif
+ ptr = dlopen(clib, cflag);
+#if defined(HAVE_DLERROR)
+ if( !ptr && (err = dlerror()) ){
+ rb_raise(rb_eFiddleError, "%s", err);
+ }
+#else
+ if( !ptr ){
+ err = dlerror();
+ rb_raise(rb_eFiddleError, "%s", err);
+ }
+#endif
+ TypedData_Get_Struct(self, struct dl_handle, &fiddle_handle_data_type, fiddle_handle);
+ if( fiddle_handle->ptr && fiddle_handle->open && fiddle_handle->enable_close ){
+ dlclose(fiddle_handle->ptr);
+ }
+ fiddle_handle->ptr = ptr;
+ fiddle_handle->open = 1;
+ fiddle_handle->enable_close = 0;
+
+ if( rb_block_given_p() ){
+ rb_ensure(rb_yield, self, rb_fiddle_handle_close, self);
+ }
+
+ return Qnil;
+}
+
+/*
+ * call-seq: enable_close
+ *
+ * Enable a call to dlclose() when this handle is garbage collected.
+ */
+static VALUE
+rb_fiddle_handle_enable_close(VALUE self)
+{
+ struct dl_handle *fiddle_handle;
+
+ TypedData_Get_Struct(self, struct dl_handle, &fiddle_handle_data_type, fiddle_handle);
+ fiddle_handle->enable_close = 1;
+ return Qnil;
+}
+
+/*
+ * call-seq: disable_close
+ *
+ * Disable a call to dlclose() when this handle is garbage collected.
+ */
+static VALUE
+rb_fiddle_handle_disable_close(VALUE self)
+{
+ struct dl_handle *fiddle_handle;
+
+ TypedData_Get_Struct(self, struct dl_handle, &fiddle_handle_data_type, fiddle_handle);
+ fiddle_handle->enable_close = 0;
+ return Qnil;
+}
+
+/*
+ * call-seq: close_enabled?
+ *
+ * Returns +true+ if dlclose() will be called when this handle is garbage collected.
+ *
+ * See man(3) dlclose() for more info.
+ */
+static VALUE
+rb_fiddle_handle_close_enabled_p(VALUE self)
+{
+ struct dl_handle *fiddle_handle;
+
+ TypedData_Get_Struct(self, struct dl_handle, &fiddle_handle_data_type, fiddle_handle);
+
+ if(fiddle_handle->enable_close) return Qtrue;
+ return Qfalse;
+}
+
+/*
+ * call-seq: to_i
+ *
+ * Returns the memory address for this handle.
+ */
+static VALUE
+rb_fiddle_handle_to_i(VALUE self)
+{
+ struct dl_handle *fiddle_handle;
+
+ TypedData_Get_Struct(self, struct dl_handle, &fiddle_handle_data_type, fiddle_handle);
+ return PTR2NUM(fiddle_handle);
+}
+
+static VALUE fiddle_handle_sym(void *handle, const char *symbol);
+
+/*
+ * Document-method: sym
+ *
+ * call-seq: sym(name)
+ *
+ * Get the address as an Integer for the function named +name+.
+ */
+static VALUE
+rb_fiddle_handle_sym(VALUE self, VALUE sym)
+{
+ struct dl_handle *fiddle_handle;
+
+ TypedData_Get_Struct(self, struct dl_handle, &fiddle_handle_data_type, fiddle_handle);
+ if( ! fiddle_handle->open ){
+ rb_raise(rb_eFiddleError, "closed handle");
+ }
+
+ return fiddle_handle_sym(fiddle_handle->ptr, StringValueCStr(sym));
+}
+
+#ifndef RTLD_NEXT
+#define RTLD_NEXT NULL
+#endif
+#ifndef RTLD_DEFAULT
+#define RTLD_DEFAULT NULL
+#endif
+
+/*
+ * Document-method: sym
+ *
+ * call-seq: sym(name)
+ *
+ * Get the address as an Integer for the function named +name+. The function
+ * is searched via dlsym on RTLD_NEXT.
+ *
+ * See man(3) dlsym() for more info.
+ */
+static VALUE
+rb_fiddle_handle_s_sym(VALUE self, VALUE sym)
+{
+ return fiddle_handle_sym(RTLD_NEXT, StringValueCStr(sym));
+}
+
+static VALUE
+fiddle_handle_sym(void *handle, const char *name)
+{
+#if defined(HAVE_DLERROR)
+ const char *err;
+# define CHECK_DLERROR if ((err = dlerror()) != 0) { func = 0; }
+#else
+# define CHECK_DLERROR
+#endif
+ void (*func)();
+
+ rb_secure(2);
+#ifdef HAVE_DLERROR
+ dlerror();
+#endif
+ func = (void (*)())(VALUE)dlsym(handle, name);
+ CHECK_DLERROR;
+#if defined(FUNC_STDCALL)
+ if( !func ){
+ int i;
+ int len = (int)strlen(name);
+ char *name_n;
+#if defined(__CYGWIN__) || defined(_WIN32) || defined(__MINGW32__)
+ {
+ char *name_a = (char*)xmalloc(len+2);
+ strcpy(name_a, name);
+ name_n = name_a;
+ name_a[len] = 'A';
+ name_a[len+1] = '\0';
+ func = dlsym(handle, name_a);
+ CHECK_DLERROR;
+ if( func ) goto found;
+ name_n = xrealloc(name_a, len+6);
+ }
+#else
+ name_n = (char*)xmalloc(len+6);
+#endif
+ memcpy(name_n, name, len);
+ name_n[len++] = '@';
+ for( i = 0; i < 256; i += 4 ){
+ sprintf(name_n + len, "%d", i);
+ func = dlsym(handle, name_n);
+ CHECK_DLERROR;
+ if( func ) break;
+ }
+ if( func ) goto found;
+ name_n[len-1] = 'A';
+ name_n[len++] = '@';
+ for( i = 0; i < 256; i += 4 ){
+ sprintf(name_n + len, "%d", i);
+ func = dlsym(handle, name_n);
+ CHECK_DLERROR;
+ if( func ) break;
+ }
+ found:
+ xfree(name_n);
+ }
+#endif
+ if( !func ){
+ rb_raise(rb_eFiddleError, "unknown symbol \"%s\"", name);
+ }
+
+ return PTR2NUM(func);
+}
+
+void
+Init_fiddle_handle(void)
+{
+ /*
+ * Document-class: Fiddle::Handle
+ *
+ * The Fiddle::Handle is the manner to access the dynamic library
+ *
+ * == Example
+ *
+ * === Setup
+ *
+ * libc_so = "/lib64/libc.so.6"
+ * => "/lib64/libc.so.6"
+ * @handle = Fiddle::Handle.new(libc_so)
+ * => #<Fiddle::Handle:0x00000000d69ef8>
+ *
+ * === Setup, with flags
+ *
+ * libc_so = "/lib64/libc.so.6"
+ * => "/lib64/libc.so.6"
+ * @handle = Fiddle::Handle.new(libc_so, Fiddle::RTLD_LAZY | Fiddle::RTLD_GLOBAL)
+ * => #<Fiddle::Handle:0x00000000d69ef8>
+ *
+ * See RTLD_LAZY and RTLD_GLOBAL
+ *
+ * === Addresses to symbols
+ *
+ * strcpy_addr = @handle['strcpy']
+ * => 140062278451968
+ *
+ * or
+ *
+ * strcpy_addr = @handle.sym('strcpy')
+ * => 140062278451968
+ *
+ */
+ rb_cHandle = rb_define_class_under(mFiddle, "Handle", rb_cObject);
+ rb_define_alloc_func(rb_cHandle, rb_fiddle_handle_s_allocate);
+ rb_define_singleton_method(rb_cHandle, "sym", rb_fiddle_handle_s_sym, 1);
+ rb_define_singleton_method(rb_cHandle, "[]", rb_fiddle_handle_s_sym, 1);
+
+ /* Document-const: NEXT
+ *
+ * A predefined pseudo-handle of RTLD_NEXT
+ *
+ * Which will find the next occurrence of a function in the search order
+ * after the current library.
+ */
+ rb_define_const(rb_cHandle, "NEXT", predefined_fiddle_handle(RTLD_NEXT));
+
+ /* Document-const: DEFAULT
+ *
+ * A predefined pseudo-handle of RTLD_DEFAULT
+ *
+ * Which will find the first occurrence of the desired symbol using the
+ * default library search order
+ */
+ rb_define_const(rb_cHandle, "DEFAULT", predefined_fiddle_handle(RTLD_DEFAULT));
+
+ /* Document-const: RTLD_GLOBAL
+ *
+ * rtld Fiddle::Handle flag.
+ *
+ * The symbols defined by this library will be made available for symbol
+ * resolution of subsequently loaded libraries.
+ */
+ rb_define_const(rb_cHandle, "RTLD_GLOBAL", INT2NUM(RTLD_GLOBAL));
+
+ /* Document-const: RTLD_LAZY
+ *
+ * rtld Fiddle::Handle flag.
+ *
+ * Perform lazy binding. Only resolve symbols as the code that references
+ * them is executed. If the symbol is never referenced, then it is never
+ * resolved. (Lazy binding is only performed for function references;
+ * references to variables are always immediately bound when the library
+ * is loaded.)
+ */
+ rb_define_const(rb_cHandle, "RTLD_LAZY", INT2NUM(RTLD_LAZY));
+
+ /* Document-const: RTLD_NOW
+ *
+ * rtld Fiddle::Handle flag.
+ *
+ * If this value is specified or the environment variable LD_BIND_NOW is
+ * set to a nonempty string, all undefined symbols in the library are
+ * resolved before Fiddle.dlopen returns. If this cannot be done an error
+ * is returned.
+ */
+ rb_define_const(rb_cHandle, "RTLD_NOW", INT2NUM(RTLD_NOW));
+
+ rb_define_method(rb_cHandle, "initialize", rb_fiddle_handle_initialize, -1);
+ rb_define_method(rb_cHandle, "to_i", rb_fiddle_handle_to_i, 0);
+ rb_define_method(rb_cHandle, "close", rb_fiddle_handle_close, 0);
+ rb_define_method(rb_cHandle, "sym", rb_fiddle_handle_sym, 1);
+ rb_define_method(rb_cHandle, "[]", rb_fiddle_handle_sym, 1);
+ rb_define_method(rb_cHandle, "disable_close", rb_fiddle_handle_disable_close, 0);
+ rb_define_method(rb_cHandle, "enable_close", rb_fiddle_handle_enable_close, 0);
+ rb_define_method(rb_cHandle, "close_enabled?", rb_fiddle_handle_close_enabled_p, 0);
+}
+
+/* vim: set noet sws=4 sw=4: */
diff --git a/jni/ruby/ext/fiddle/lib/fiddle.rb b/jni/ruby/ext/fiddle/lib/fiddle.rb
new file mode 100644
index 0000000..ae6e299
--- /dev/null
+++ b/jni/ruby/ext/fiddle/lib/fiddle.rb
@@ -0,0 +1,55 @@
+require 'fiddle.so'
+require 'fiddle/function'
+require 'fiddle/closure'
+
+module Fiddle
+ if WINDOWS
+ # Returns the last win32 +Error+ of the current executing +Thread+ or nil
+ # if none
+ def self.win32_last_error
+ Thread.current[:__FIDDLE_WIN32_LAST_ERROR__]
+ end
+
+ # Sets the last win32 +Error+ of the current executing +Thread+ to +error+
+ def self.win32_last_error= error
+ Thread.current[:__FIDDLE_WIN32_LAST_ERROR__] = error
+ end
+ end
+
+ # Returns the last +Error+ of the current executing +Thread+ or nil if none
+ def self.last_error
+ Thread.current[:__FIDDLE_LAST_ERROR__]
+ end
+
+ # Sets the last +Error+ of the current executing +Thread+ to +error+
+ def self.last_error= error
+ Thread.current[:__DL2_LAST_ERROR__] = error
+ Thread.current[:__FIDDLE_LAST_ERROR__] = error
+ end
+
+ # call-seq: dlopen(library) => Fiddle::Handle
+ #
+ # Creates a new handler that opens +library+, and returns an instance of
+ # Fiddle::Handle.
+ #
+ # If +nil+ is given for the +library+, Fiddle::Handle::DEFAULT is used, which
+ # is the equivalent to RTLD_DEFAULT. See <code>man 3 dlopen</code> for more.
+ #
+ # lib = Fiddle.dlopen(nil)
+ #
+ # The default is dependent on OS, and provide a handle for all libraries
+ # already loaded. For example, in most cases you can use this to access
+ # +libc+ functions, or ruby functions like +rb_str_new+.
+ #
+ # See Fiddle::Handle.new for more.
+ def dlopen library
+ Fiddle::Handle.new library
+ end
+ module_function :dlopen
+
+ # Add constants for backwards compat
+
+ RTLD_GLOBAL = Handle::RTLD_GLOBAL # :nodoc:
+ RTLD_LAZY = Handle::RTLD_LAZY # :nodoc:
+ RTLD_NOW = Handle::RTLD_NOW # :nodoc:
+end
diff --git a/jni/ruby/ext/fiddle/lib/fiddle/closure.rb b/jni/ruby/ext/fiddle/lib/fiddle/closure.rb
new file mode 100644
index 0000000..beb90ec
--- /dev/null
+++ b/jni/ruby/ext/fiddle/lib/fiddle/closure.rb
@@ -0,0 +1,48 @@
+module Fiddle
+ class Closure
+
+ # the C type of the return of the FFI closure
+ attr_reader :ctype
+
+ # arguments of the FFI closure
+ attr_reader :args
+
+ # Extends Fiddle::Closure to allow for building the closure in a block
+ class BlockCaller < Fiddle::Closure
+
+ # == Description
+ #
+ # Construct a new BlockCaller object.
+ #
+ # * +ctype+ is the C type to be returned
+ # * +args+ are passed the callback
+ # * +abi+ is the abi of the closure
+ #
+ # If there is an error in preparing the +ffi_cif+ or +ffi_prep_closure+,
+ # then a RuntimeError will be raised.
+ #
+ # == Example
+ #
+ # include Fiddle
+ #
+ # cb = Closure::BlockCaller.new(TYPE_INT, [TYPE_INT]) do |one|
+ # one
+ # end
+ #
+ # func = Function.new(cb, [TYPE_INT], TYPE_INT)
+ #
+ def initialize ctype, args, abi = Fiddle::Function::DEFAULT, &block
+ super(ctype, args, abi)
+ @block = block
+ end
+
+ # Calls the constructed BlockCaller, with +args+
+ #
+ # For an example see Fiddle::Closure::BlockCaller.new
+ #
+ def call *args
+ @block.call(*args)
+ end
+ end
+ end
+end
diff --git a/jni/ruby/ext/fiddle/lib/fiddle/cparser.rb b/jni/ruby/ext/fiddle/lib/fiddle/cparser.rb
new file mode 100644
index 0000000..43fb184
--- /dev/null
+++ b/jni/ruby/ext/fiddle/lib/fiddle/cparser.rb
@@ -0,0 +1,176 @@
+module Fiddle
+ # A mixin that provides methods for parsing C struct and prototype signatures.
+ #
+ # == Example
+ # require 'fiddle/import'
+ #
+ # include Fiddle::CParser
+ # #=> Object
+ #
+ # parse_ctype('int increment(int)')
+ # #=> ["increment", Fiddle::TYPE_INT, [Fiddle::TYPE_INT]]
+ #
+ module CParser
+ # Parses a C struct's members
+ #
+ # Example:
+ #
+ # include Fiddle::CParser
+ # #=> Object
+ #
+ # parse_struct_signature(['int i', 'char c'])
+ # #=> [[Fiddle::TYPE_INT, Fiddle::TYPE_CHAR], ["i", "c"]]
+ #
+ def parse_struct_signature(signature, tymap=nil)
+ if( signature.is_a?(String) )
+ signature = signature.split(/\s*,\s*/)
+ end
+ mems = []
+ tys = []
+ signature.each{|msig|
+ tks = msig.split(/\s+(\*)?/)
+ ty = tks[0..-2].join(" ")
+ member = tks[-1]
+
+ case ty
+ when /\[(\d+)\]/
+ n = $1.to_i
+ ty.gsub!(/\s*\[\d+\]/,"")
+ ty = [ty, n]
+ when /\[\]/
+ ty.gsub!(/\s*\[\]/, "*")
+ end
+
+ case member
+ when /\[(\d+)\]/
+ ty = [ty, $1.to_i]
+ member.gsub!(/\s*\[\d+\]/,"")
+ when /\[\]/
+ ty = ty + "*"
+ member.gsub!(/\s*\[\]/, "")
+ end
+
+ mems.push(member)
+ tys.push(parse_ctype(ty,tymap))
+ }
+ return tys, mems
+ end
+
+ # Parses a C prototype signature
+ #
+ # If Hash +tymap+ is provided, the return value and the arguments from the
+ # +signature+ are expected to be keys, and the value will be the C type to
+ # be looked up.
+ #
+ # Example:
+ #
+ # include Fiddle::CParser
+ # #=> Object
+ #
+ # parse_signature('double sum(double, double)')
+ # #=> ["sum", Fiddle::TYPE_DOUBLE, [Fiddle::TYPE_DOUBLE, Fiddle::TYPE_DOUBLE]]
+ #
+ def parse_signature(signature, tymap=nil)
+ tymap ||= {}
+ signature = signature.gsub(/\s+/, " ").strip
+ case signature
+ when /^([\w@\*\s]+)\(([\w\*\s\,\[\]]*)\)$/
+ ret = $1
+ (args = $2).strip!
+ ret = ret.split(/\s+/)
+ args = args.split(/\s*,\s*/)
+ func = ret.pop
+ if( func =~ /^\*/ )
+ func.gsub!(/^\*+/,"")
+ ret.push("*")
+ end
+ ret = ret.join(" ")
+ return [func, parse_ctype(ret, tymap), args.collect{|arg| parse_ctype(arg, tymap)}]
+ else
+ raise(RuntimeError,"can't parse the function prototype: #{signature}")
+ end
+ end
+
+ # Given a String of C type +ty+, returns the corresponding Fiddle constant.
+ #
+ # +ty+ can also accept an Array of C type Strings, and will be returned in
+ # a corresponding Array.
+ #
+ # If Hash +tymap+ is provided, +ty+ is expected to be the key, and the
+ # value will be the C type to be looked up.
+ #
+ # Example:
+ #
+ # include Fiddle::CParser
+ # #=> Object
+ #
+ # parse_ctype('int')
+ # #=> Fiddle::TYPE_INT
+ #
+ # parse_ctype('double')
+ # #=> Fiddle::TYPE_DOUBLE
+ #
+ # parse_ctype('unsigned char')
+ # #=> -Fiddle::TYPE_CHAR
+ #
+ def parse_ctype(ty, tymap=nil)
+ tymap ||= {}
+ case ty
+ when Array
+ return [parse_ctype(ty[0], tymap), ty[1]]
+ when "void"
+ return TYPE_VOID
+ when "char"
+ return TYPE_CHAR
+ when "unsigned char"
+ return -TYPE_CHAR
+ when "short"
+ return TYPE_SHORT
+ when "unsigned short"
+ return -TYPE_SHORT
+ when "int"
+ return TYPE_INT
+ when "unsigned int", 'uint'
+ return -TYPE_INT
+ when "long"
+ return TYPE_LONG
+ when "unsigned long"
+ return -TYPE_LONG
+ when "long long"
+ if( defined?(TYPE_LONG_LONG) )
+ return TYPE_LONG_LONG
+ else
+ raise(RuntimeError, "unsupported type: #{ty}")
+ end
+ when "unsigned long long"
+ if( defined?(TYPE_LONG_LONG) )
+ return -TYPE_LONG_LONG
+ else
+ raise(RuntimeError, "unsupported type: #{ty}")
+ end
+ when "float"
+ return TYPE_FLOAT
+ when "double"
+ return TYPE_DOUBLE
+ when "size_t"
+ return TYPE_SIZE_T
+ when "ssize_t"
+ return TYPE_SSIZE_T
+ when "ptrdiff_t"
+ return TYPE_PTRDIFF_T
+ when "intptr_t"
+ return TYPE_INTPTR_T
+ when "uintptr_t"
+ return TYPE_UINTPTR_T
+ when /\*/, /\[\s*\]/
+ return TYPE_VOIDP
+ else
+ if( tymap[ty] )
+ return parse_ctype(tymap[ty], tymap)
+ else
+ raise(DLError, "unknown type: #{ty}")
+ end
+ end
+ end
+ end
+end
diff --git a/jni/ruby/ext/fiddle/lib/fiddle/function.rb b/jni/ruby/ext/fiddle/lib/fiddle/function.rb
new file mode 100644
index 0000000..ab7496e
--- /dev/null
+++ b/jni/ruby/ext/fiddle/lib/fiddle/function.rb
@@ -0,0 +1,17 @@
+module Fiddle
+ class Function
+ # The ABI of the Function.
+ attr_reader :abi
+
+ # The address of this function
+ attr_reader :ptr
+
+ # The name of this function
+ attr_reader :name
+
+ # The integer memory location of this function
+ def to_i
+ ptr.to_i
+ end
+ end
+end
diff --git a/jni/ruby/ext/fiddle/lib/fiddle/import.rb b/jni/ruby/ext/fiddle/lib/fiddle/import.rb
new file mode 100644
index 0000000..34f5d7f
--- /dev/null
+++ b/jni/ruby/ext/fiddle/lib/fiddle/import.rb
@@ -0,0 +1,314 @@
+require 'fiddle'
+require 'fiddle/struct'
+require 'fiddle/cparser'
+
+module Fiddle
+
+ # Used internally by Fiddle::Importer
+ class CompositeHandler
+ # Create a new handler with the open +handlers+
+ #
+ # Used internally by Fiddle::Importer.dlload
+ def initialize(handlers)
+ @handlers = handlers
+ end
+
+ # Array of the currently loaded libraries.
+ def handlers()
+ @handlers
+ end
+
+ # Returns the address as an Integer from any handlers with the function
+ # named +symbol+.
+ #
+ # Raises a DLError if the handle is closed.
+ def sym(symbol)
+ @handlers.each{|handle|
+ if( handle )
+ begin
+ addr = handle.sym(symbol)
+ return addr
+ rescue DLError
+ end
+ end
+ }
+ return nil
+ end
+
+ # See Fiddle::CompositeHandler.sym
+ def [](symbol)
+ sym(symbol)
+ end
+ end
+
+ # A DSL that provides the means to dynamically load libraries and build
+ # modules around them including calling extern functions within the C
+ # library that has been loaded.
+ #
+ # == Example
+ #
+ # require 'fiddle'
+ # require 'fiddle/import'
+ #
+ # module LibSum
+ # extend Fiddle::Importer
+ # dlload './libsum.so'
+ # extern 'double sum(double*, int)'
+ # extern 'double split(double)'
+ # end
+ #
+ module Importer
+ include Fiddle
+ include CParser
+ extend Importer
+
+ # Creates an array of handlers for the given +libs+, can be an instance of
+ # Fiddle::Handle, Fiddle::Importer, or will create a new instance of
+ # Fiddle::Handle using Fiddle.dlopen
+ #
+ # Raises a DLError if the library cannot be loaded.
+ #
+ # See Fiddle.dlopen
+ def dlload(*libs)
+ handles = libs.collect{|lib|
+ case lib
+ when nil
+ nil
+ when Handle
+ lib
+ when Importer
+ lib.handlers
+ else
+ begin
+ Fiddle.dlopen(lib)
+ rescue DLError
+ raise(DLError, "can't load #{lib}")
+ end
+ end
+ }.flatten()
+ @handler = CompositeHandler.new(handles)
+ @func_map = {}
+ @type_alias = {}
+ end
+
+ # Sets the type alias for +alias_type+ as +orig_type+
+ def typealias(alias_type, orig_type)
+ @type_alias[alias_type] = orig_type
+ end
+
+ # Returns the sizeof +ty+, using Fiddle::Importer.parse_ctype to determine
+ # the C type and the appropriate Fiddle constant.
+ def sizeof(ty)
+ case ty
+ when String
+ ty = parse_ctype(ty, @type_alias).abs()
+ case ty
+ when TYPE_CHAR
+ return SIZEOF_CHAR
+ when TYPE_SHORT
+ return SIZEOF_SHORT
+ when TYPE_INT
+ return SIZEOF_INT
+ when TYPE_LONG
+ return SIZEOF_LONG
+ when TYPE_LONG_LONG
+ return SIZEOF_LONG_LONG
+ when TYPE_FLOAT
+ return SIZEOF_FLOAT
+ when TYPE_DOUBLE
+ return SIZEOF_DOUBLE
+ when TYPE_VOIDP
+ return SIZEOF_VOIDP
+ else
+ raise(DLError, "unknown type: #{ty}")
+ end
+ when Class
+ if( ty.instance_methods().include?(:to_ptr) )
+ return ty.size()
+ end
+ end
+ return Pointer[ty].size()
+ end
+
+ def parse_bind_options(opts)
+ h = {}
+ while( opt = opts.shift() )
+ case opt
+ when :stdcall, :cdecl
+ h[:call_type] = opt
+ when :carried, :temp, :temporal, :bind
+ h[:callback_type] = opt
+ h[:carrier] = opts.shift()
+ else
+ h[opt] = true
+ end
+ end
+ h
+ end
+ private :parse_bind_options
+
+ # :stopdoc:
+ CALL_TYPE_TO_ABI = Hash.new { |h, k|
+ raise RuntimeError, "unsupported call type: #{k}"
+ }.merge({ :stdcall => (Function::STDCALL rescue Function::DEFAULT),
+ :cdecl => Function::DEFAULT,
+ nil => Function::DEFAULT
+ }).freeze
+ private_constant :CALL_TYPE_TO_ABI
+ # :startdoc:
+
+ # Creates a global method from the given C +signature+.
+ def extern(signature, *opts)
+ symname, ctype, argtype = parse_signature(signature, @type_alias)
+ opt = parse_bind_options(opts)
+ f = import_function(symname, ctype, argtype, opt[:call_type])
+ name = symname.gsub(/@.+/,'')
+ @func_map[name] = f
+ # define_method(name){|*args,&block| f.call(*args,&block)}
+ begin
+ /^(.+?):(\d+)/ =~ caller.first
+ file, line = $1, $2.to_i
+ rescue
+ file, line = __FILE__, __LINE__+3
+ end
+ module_eval(<<-EOS, file, line)
+ def #{name}(*args, &block)
+ @func_map['#{name}'].call(*args,&block)
+ end
+ EOS
+ module_function(name)
+ f
+ end
+
+ # Creates a global method from the given C +signature+ using the given
+ # +opts+ as bind parameters with the given block.
+ def bind(signature, *opts, &blk)
+ name, ctype, argtype = parse_signature(signature, @type_alias)
+ h = parse_bind_options(opts)
+ case h[:callback_type]
+ when :bind, nil
+ f = bind_function(name, ctype, argtype, h[:call_type], &blk)
+ else
+ raise(RuntimeError, "unknown callback type: #{h[:callback_type]}")
+ end
+ @func_map[name] = f
+ #define_method(name){|*args,&block| f.call(*args,&block)}
+ begin
+ /^(.+?):(\d+)/ =~ caller.first
+ file, line = $1, $2.to_i
+ rescue
+ file, line = __FILE__, __LINE__+3
+ end
+ module_eval(<<-EOS, file, line)
+ def #{name}(*args,&block)
+ @func_map['#{name}'].call(*args,&block)
+ end
+ EOS
+ module_function(name)
+ f
+ end
+
+ # Creates a class to wrap the C struct described by +signature+.
+ #
+ # MyStruct = struct ['int i', 'char c']
+ def struct(signature)
+ tys, mems = parse_struct_signature(signature, @type_alias)
+ Fiddle::CStructBuilder.create(CStruct, tys, mems)
+ end
+
+ # Creates a class to wrap the C union described by +signature+.
+ #
+ # MyUnion = union ['int i', 'char c']
+ def union(signature)
+ tys, mems = parse_struct_signature(signature, @type_alias)
+ Fiddle::CStructBuilder.create(CUnion, tys, mems)
+ end
+
+ # Returns the function mapped to +name+, that was created by either
+ # Fiddle::Importer.extern or Fiddle::Importer.bind
+ def [](name)
+ @func_map[name]
+ end
+
+ # Creates a class to wrap the C struct with the value +ty+
+ #
+ # See also Fiddle::Importer.struct
+ def create_value(ty, val=nil)
+ s = struct([ty + " value"])
+ ptr = s.malloc()
+ if( val )
+ ptr.value = val
+ end
+ return ptr
+ end
+ alias value create_value
+
+ # Returns a new instance of the C struct with the value +ty+ at the +addr+
+ # address.
+ def import_value(ty, addr)
+ s = struct([ty + " value"])
+ ptr = s.new(addr)
+ return ptr
+ end
+
+
+ # The Fiddle::CompositeHandler instance
+ #
+ # Will raise an error if no handlers are open.
+ def handler
+ @handler or raise "call dlload before importing symbols and functions"
+ end
+
+ # Returns a new Fiddle::Pointer instance at the memory address of the given
+ # +name+ symbol.
+ #
+ # Raises a DLError if the +name+ doesn't exist.
+ #
+ # See Fiddle::CompositeHandler.sym and Fiddle::Handle.sym
+ def import_symbol(name)
+ addr = handler.sym(name)
+ if( !addr )
+ raise(DLError, "cannot find the symbol: #{name}")
+ end
+ Pointer.new(addr)
+ end
+
+ # Returns a new Fiddle::Function instance at the memory address of the given
+ # +name+ function.
+ #
+ # Raises a DLError if the +name+ doesn't exist.
+ #
+ # * +argtype+ is an Array of arguments, passed to the +name+ function.
+ # * +ctype+ is the return type of the function
+ # * +call_type+ is the ABI of the function
+ #
+ # See also Fiddle:Function.new
+ #
+ # See Fiddle::CompositeHandler.sym and Fiddle::Handler.sym
+ def import_function(name, ctype, argtype, call_type = nil)
+ addr = handler.sym(name)
+ if( !addr )
+ raise(DLError, "cannot find the function: #{name}()")
+ end
+ Function.new(addr, argtype, ctype, CALL_TYPE_TO_ABI[call_type],
+ name: name)
+ end
+
+ # Returns a new closure wrapper for the +name+ function.
+ #
+ # * +ctype+ is the return type of the function
+ # * +argtype+ is an Array of arguments, passed to the callback function
+ # * +call_type+ is the abi of the closure
+ # * +block+ is passed to the callback
+ #
+ # See Fiddle::Closure
+ def bind_function(name, ctype, argtype, call_type = nil, &block)
+ abi = CALL_TYPE_TO_ABI[call_type]
+ closure = Class.new(Fiddle::Closure) {
+ define_method(:call, block)
+ }.new(ctype, argtype, abi)
+
+ Function.new(closure, argtype, ctype, abi, name: name)
+ end
+ end
+end
diff --git a/jni/ruby/ext/fiddle/lib/fiddle/pack.rb b/jni/ruby/ext/fiddle/lib/fiddle/pack.rb
new file mode 100644
index 0000000..e4e9542
--- /dev/null
+++ b/jni/ruby/ext/fiddle/lib/fiddle/pack.rb
@@ -0,0 +1,128 @@
+require 'fiddle'
+
+module Fiddle
+ module PackInfo # :nodoc: all
+ ALIGN_MAP = {
+ TYPE_VOIDP => ALIGN_VOIDP,
+ TYPE_CHAR => ALIGN_CHAR,
+ TYPE_SHORT => ALIGN_SHORT,
+ TYPE_INT => ALIGN_INT,
+ TYPE_LONG => ALIGN_LONG,
+ TYPE_FLOAT => ALIGN_FLOAT,
+ TYPE_DOUBLE => ALIGN_DOUBLE,
+ -TYPE_CHAR => ALIGN_CHAR,
+ -TYPE_SHORT => ALIGN_SHORT,
+ -TYPE_INT => ALIGN_INT,
+ -TYPE_LONG => ALIGN_LONG,
+ }
+
+ PACK_MAP = {
+ TYPE_VOIDP => ((SIZEOF_VOIDP == SIZEOF_LONG_LONG) ? "q" : "l!"),
+ TYPE_CHAR => "c",
+ TYPE_SHORT => "s!",
+ TYPE_INT => "i!",
+ TYPE_LONG => "l!",
+ TYPE_FLOAT => "f",
+ TYPE_DOUBLE => "d",
+ -TYPE_CHAR => "c",
+ -TYPE_SHORT => "s!",
+ -TYPE_INT => "i!",
+ -TYPE_LONG => "l!",
+ }
+
+ SIZE_MAP = {
+ TYPE_VOIDP => SIZEOF_VOIDP,
+ TYPE_CHAR => SIZEOF_CHAR,
+ TYPE_SHORT => SIZEOF_SHORT,
+ TYPE_INT => SIZEOF_INT,
+ TYPE_LONG => SIZEOF_LONG,
+ TYPE_FLOAT => SIZEOF_FLOAT,
+ TYPE_DOUBLE => SIZEOF_DOUBLE,
+ -TYPE_CHAR => SIZEOF_CHAR,
+ -TYPE_SHORT => SIZEOF_SHORT,
+ -TYPE_INT => SIZEOF_INT,
+ -TYPE_LONG => SIZEOF_LONG,
+ }
+ if defined?(TYPE_LONG_LONG)
+ ALIGN_MAP[TYPE_LONG_LONG] = ALIGN_MAP[-TYPE_LONG_LONG] = ALIGN_LONG_LONG
+ PACK_MAP[TYPE_LONG_LONG] = PACK_MAP[-TYPE_LONG_LONG] = "q"
+ SIZE_MAP[TYPE_LONG_LONG] = SIZE_MAP[-TYPE_LONG_LONG] = SIZEOF_LONG_LONG
+ end
+
+ def align(addr, align)
+ d = addr % align
+ if( d == 0 )
+ addr
+ else
+ addr + (align - d)
+ end
+ end
+ module_function :align
+ end
+
+ class Packer # :nodoc: all
+ include PackInfo
+
+ def self.[](*types)
+ new(types)
+ end
+
+ def initialize(types)
+ parse_types(types)
+ end
+
+ def size()
+ @size
+ end
+
+ def pack(ary)
+ case SIZEOF_VOIDP
+ when SIZEOF_LONG
+ ary.pack(@template)
+ when SIZEOF_LONG_LONG
+ ary.pack(@template)
+ else
+ raise(RuntimeError, "sizeof(void*)?")
+ end
+ end
+
+ def unpack(ary)
+ case SIZEOF_VOIDP
+ when SIZEOF_LONG
+ ary.join().unpack(@template)
+ when SIZEOF_LONG_LONG
+ ary.join().unpack(@template)
+ else
+ raise(RuntimeError, "sizeof(void*)?")
+ end
+ end
+
+ private
+
+ def parse_types(types)
+ @template = ""
+ addr = 0
+ types.each{|t|
+ orig_addr = addr
+ if( t.is_a?(Array) )
+ addr = align(orig_addr, ALIGN_MAP[TYPE_VOIDP])
+ else
+ addr = align(orig_addr, ALIGN_MAP[t])
+ end
+ d = addr - orig_addr
+ if( d > 0 )
+ @template << "x#{d}"
+ end
+ if( t.is_a?(Array) )
+ @template << (PACK_MAP[t[0]] * t[1])
+ addr += (SIZE_MAP[t[0]] * t[1])
+ else
+ @template << PACK_MAP[t]
+ addr += SIZE_MAP[t]
+ end
+ }
+ addr = align(addr, ALIGN_MAP[TYPE_VOIDP])
+ @size = addr
+ end
+ end
+end
diff --git a/jni/ruby/ext/fiddle/lib/fiddle/struct.rb b/jni/ruby/ext/fiddle/lib/fiddle/struct.rb
new file mode 100644
index 0000000..695a4d2
--- /dev/null
+++ b/jni/ruby/ext/fiddle/lib/fiddle/struct.rb
@@ -0,0 +1,243 @@
+require 'fiddle'
+require 'fiddle/value'
+require 'fiddle/pack'
+
+module Fiddle
+ # C struct shell
+ class CStruct
+ # accessor to Fiddle::CStructEntity
+ def CStruct.entity_class
+ CStructEntity
+ end
+ end
+
+ # C union shell
+ class CUnion
+ # accessor to Fiddle::CUnionEntity
+ def CUnion.entity_class
+ CUnionEntity
+ end
+ end
+
+ # Used to construct C classes (CUnion, CStruct, etc)
+ #
+ # Fiddle::Importer#struct and Fiddle::Importer#union wrap this functionality in an
+ # easy-to-use manner.
+ module CStructBuilder
+ # Construct a new class given a C:
+ # * class +klass+ (CUnion, CStruct, or other that provide an
+ # #entity_class)
+ # * +types+ (Fiddle::TYPE_INT, Fiddle::TYPE_SIZE_T, etc., see the C types
+ # constants)
+ # * corresponding +members+
+ #
+ # Fiddle::Importer#struct and Fiddle::Importer#union wrap this functionality in an
+ # easy-to-use manner.
+ #
+ # Example:
+ #
+ # require 'fiddle/struct'
+ # require 'fiddle/cparser'
+ #
+ # include Fiddle::CParser
+ #
+ # types, members = parse_struct_signature(['int i','char c'])
+ #
+ # MyStruct = Fiddle::CStructBuilder.create(Fiddle::CUnion, types, members)
+ #
+ # obj = MyStruct.allocate
+ #
+ def create(klass, types, members)
+ new_class = Class.new(klass){
+ define_method(:initialize){|addr|
+ @entity = klass.entity_class.new(addr, types)
+ @entity.assign_names(members)
+ }
+ define_method(:to_ptr){ @entity }
+ define_method(:to_i){ @entity.to_i }
+ members.each{|name|
+ define_method(name){ @entity[name] }
+ define_method(name + "="){|val| @entity[name] = val }
+ }
+ }
+ size = klass.entity_class.size(types)
+ new_class.module_eval(<<-EOS, __FILE__, __LINE__+1)
+ def new_class.size()
+ #{size}
+ end
+ def new_class.malloc()
+ addr = Fiddle.malloc(#{size})
+ new(addr)
+ end
+ EOS
+ return new_class
+ end
+ module_function :create
+ end
+
+ # A C struct wrapper
+ class CStructEntity < Fiddle::Pointer
+ include PackInfo
+ include ValueUtil
+
+ # Allocates a C struct with the +types+ provided.
+ #
+ # When the instance is garbage collected, the C function +func+ is called.
+ def CStructEntity.malloc(types, func = nil)
+ addr = Fiddle.malloc(CStructEntity.size(types))
+ CStructEntity.new(addr, types, func)
+ end
+
+ # Returns the offset for the packed sizes for the given +types+.
+ #
+ # Fiddle::CStructEntity.size(
+ # [ Fiddle::TYPE_DOUBLE,
+ # Fiddle::TYPE_INT,
+ # Fiddle::TYPE_CHAR,
+ # Fiddle::TYPE_VOIDP ]) #=> 24
+ def CStructEntity.size(types)
+ offset = 0
+
+ max_align = types.map { |type, count = 1|
+ last_offset = offset
+
+ align = PackInfo::ALIGN_MAP[type]
+ offset = PackInfo.align(last_offset, align) +
+ (PackInfo::SIZE_MAP[type] * count)
+
+ align
+ }.max
+
+ PackInfo.align(offset, max_align)
+ end
+
+ # Wraps the C pointer +addr+ as a C struct with the given +types+.
+ #
+ # When the instance is garbage collected, the C function +func+ is called.
+ #
+ # See also Fiddle::Pointer.new
+ def initialize(addr, types, func = nil)
+ set_ctypes(types)
+ super(addr, @size, func)
+ end
+
+ # Set the names of the +members+ in this C struct
+ def assign_names(members)
+ @members = members
+ end
+
+ # Calculates the offsets and sizes for the given +types+ in the struct.
+ def set_ctypes(types)
+ @ctypes = types
+ @offset = []
+ offset = 0
+
+ max_align = types.map { |type, count = 1|
+ orig_offset = offset
+ align = ALIGN_MAP[type]
+ offset = PackInfo.align(orig_offset, align)
+
+ @offset << offset
+
+ offset += (SIZE_MAP[type] * count)
+
+ align
+ }.max
+
+ @size = PackInfo.align(offset, max_align)
+ end
+
+ # Fetch struct member +name+
+ def [](name)
+ idx = @members.index(name)
+ if( idx.nil? )
+ raise(ArgumentError, "no such member: #{name}")
+ end
+ ty = @ctypes[idx]
+ if( ty.is_a?(Array) )
+ r = super(@offset[idx], SIZE_MAP[ty[0]] * ty[1])
+ else
+ r = super(@offset[idx], SIZE_MAP[ty.abs])
+ end
+ packer = Packer.new([ty])
+ val = packer.unpack([r])
+ case ty
+ when Array
+ case ty[0]
+ when TYPE_VOIDP
+ val = val.collect{|v| Pointer.new(v)}
+ end
+ when TYPE_VOIDP
+ val = Pointer.new(val[0])
+ else
+ val = val[0]
+ end
+ if( ty.is_a?(Integer) && (ty < 0) )
+ return unsigned_value(val, ty)
+ elsif( ty.is_a?(Array) && (ty[0] < 0) )
+ return val.collect{|v| unsigned_value(v,ty[0])}
+ else
+ return val
+ end
+ end
+
+ # Set struct member +name+, to value +val+
+ def []=(name, val)
+ idx = @members.index(name)
+ if( idx.nil? )
+ raise(ArgumentError, "no such member: #{name}")
+ end
+ ty = @ctypes[idx]
+ packer = Packer.new([ty])
+ val = wrap_arg(val, ty, [])
+ buff = packer.pack([val].flatten())
+ super(@offset[idx], buff.size, buff)
+ if( ty.is_a?(Integer) && (ty < 0) )
+ return unsigned_value(val, ty)
+ elsif( ty.is_a?(Array) && (ty[0] < 0) )
+ return val.collect{|v| unsigned_value(v,ty[0])}
+ else
+ return val
+ end
+ end
+
+ def to_s() # :nodoc:
+ super(@size)
+ end
+ end
+
+ # A C union wrapper
+ class CUnionEntity < CStructEntity
+ include PackInfo
+
+ # Allocates a C union the +types+ provided.
+ #
+ # When the instance is garbage collected, the C function +func+ is called.
+ def CUnionEntity.malloc(types, func=nil)
+ addr = Fiddle.malloc(CUnionEntity.size(types))
+ CUnionEntity.new(addr, types, func)
+ end
+
+ # Returns the size needed for the union with the given +types+.
+ #
+ # Fiddle::CUnionEntity.size(
+ # [ Fiddle::TYPE_DOUBLE,
+ # Fiddle::TYPE_INT,
+ # Fiddle::TYPE_CHAR,
+ # Fiddle::TYPE_VOIDP ]) #=> 8
+ def CUnionEntity.size(types)
+ types.map { |type, count = 1|
+ PackInfo::SIZE_MAP[type] * count
+ }.max
+ end
+
+ # Calculate the necessary offset and for each union member with the given
+ # +types+
+ def set_ctypes(types)
+ @ctypes = types
+ @offset = Array.new(types.length, 0)
+ @size = self.class.size types
+ end
+ end
+end
+
diff --git a/jni/ruby/ext/fiddle/lib/fiddle/types.rb b/jni/ruby/ext/fiddle/lib/fiddle/types.rb
new file mode 100644
index 0000000..02c1d25
--- /dev/null
+++ b/jni/ruby/ext/fiddle/lib/fiddle/types.rb
@@ -0,0 +1,71 @@
+module Fiddle
+ # Adds Windows type aliases to the including class for use with
+ # Fiddle::Importer.
+ #
+ # The aliases added are:
+ # * ATOM
+ # * BOOL
+ # * BYTE
+ # * DWORD
+ # * DWORD32
+ # * DWORD64
+ # * HANDLE
+ # * HDC
+ # * HINSTANCE
+ # * HWND
+ # * LPCSTR
+ # * LPSTR
+ # * PBYTE
+ # * PDWORD
+ # * PHANDLE
+ # * PVOID
+ # * PWORD
+ # * UCHAR
+ # * UINT
+ # * ULONG
+ # * WORD
+ module Win32Types
+ def included(m) # :nodoc:
+ m.module_eval{
+ typealias "DWORD", "unsigned long"
+ typealias "PDWORD", "unsigned long *"
+ typealias "DWORD32", "unsigned long"
+ typealias "DWORD64", "unsigned long long"
+ typealias "WORD", "unsigned short"
+ typealias "PWORD", "unsigned short *"
+ typealias "BOOL", "int"
+ typealias "ATOM", "int"
+ typealias "BYTE", "unsigned char"
+ typealias "PBYTE", "unsigned char *"
+ typealias "UINT", "unsigned int"
+ typealias "ULONG", "unsigned long"
+ typealias "UCHAR", "unsigned char"
+ typealias "HANDLE", "uintptr_t"
+ typealias "PHANDLE", "void*"
+ typealias "PVOID", "void*"
+ typealias "LPCSTR", "char*"
+ typealias "LPSTR", "char*"
+ typealias "HINSTANCE", "unsigned int"
+ typealias "HDC", "unsigned int"
+ typealias "HWND", "unsigned int"
+ }
+ end
+ module_function :included
+ end
+
+ # Adds basic type aliases to the including class for use with Fiddle::Importer.
+ #
+ # The aliases added are +uint+ and +u_int+ (<tt>unsigned int</tt>) and
+ # +ulong+ and +u_long+ (<tt>unsigned long</tt>)
+ module BasicTypes
+ def included(m) # :nodoc:
+ m.module_eval{
+ typealias "uint", "unsigned int"
+ typealias "u_int", "unsigned int"
+ typealias "ulong", "unsigned long"
+ typealias "u_long", "unsigned long"
+ }
+ end
+ module_function :included
+ end
+end
diff --git a/jni/ruby/ext/fiddle/lib/fiddle/value.rb b/jni/ruby/ext/fiddle/lib/fiddle/value.rb
new file mode 100644
index 0000000..8d71e47
--- /dev/null
+++ b/jni/ruby/ext/fiddle/lib/fiddle/value.rb
@@ -0,0 +1,112 @@
+require 'fiddle'
+
+module Fiddle
+ module ValueUtil #:nodoc: all
+ def unsigned_value(val, ty)
+ case ty.abs
+ when TYPE_CHAR
+ [val].pack("c").unpack("C")[0]
+ when TYPE_SHORT
+ [val].pack("s!").unpack("S!")[0]
+ when TYPE_INT
+ [val].pack("i!").unpack("I!")[0]
+ when TYPE_LONG
+ [val].pack("l!").unpack("L!")[0]
+ when TYPE_LONG_LONG
+ [val].pack("q").unpack("Q")[0]
+ else
+ val
+ end
+ end
+
+ def signed_value(val, ty)
+ case ty.abs
+ when TYPE_CHAR
+ [val].pack("C").unpack("c")[0]
+ when TYPE_SHORT
+ [val].pack("S!").unpack("s!")[0]
+ when TYPE_INT
+ [val].pack("I!").unpack("i!")[0]
+ when TYPE_LONG
+ [val].pack("L!").unpack("l!")[0]
+ when TYPE_LONG_LONG
+ [val].pack("Q").unpack("q")[0]
+ else
+ val
+ end
+ end
+
+ def wrap_args(args, tys, funcs, &block)
+ result = []
+ tys ||= []
+ args.each_with_index{|arg, idx|
+ result.push(wrap_arg(arg, tys[idx], funcs, &block))
+ }
+ result
+ end
+
+ def wrap_arg(arg, ty, funcs = [], &block)
+ funcs ||= []
+ case arg
+ when nil
+ return 0
+ when Pointer
+ return arg.to_i
+ when IO
+ case ty
+ when TYPE_VOIDP
+ return Pointer[arg].to_i
+ else
+ return arg.to_i
+ end
+ when Function
+ if( block )
+ arg.bind_at_call(&block)
+ funcs.push(arg)
+ elsif !arg.bound?
+ raise(RuntimeError, "block must be given.")
+ end
+ return arg.to_i
+ when String
+ if( ty.is_a?(Array) )
+ return arg.unpack('C*')
+ else
+ case SIZEOF_VOIDP
+ when SIZEOF_LONG
+ return [arg].pack("p").unpack("l!")[0]
+ when SIZEOF_LONG_LONG
+ return [arg].pack("p").unpack("q")[0]
+ else
+ raise(RuntimeError, "sizeof(void*)?")
+ end
+ end
+ when Float, Integer
+ return arg
+ when Array
+ if( ty.is_a?(Array) ) # used only by struct
+ case ty[0]
+ when TYPE_VOIDP
+ return arg.collect{|v| Integer(v)}
+ when TYPE_CHAR
+ if( arg.is_a?(String) )
+ return val.unpack('C*')
+ end
+ end
+ return arg
+ else
+ return arg
+ end
+ else
+ if( arg.respond_to?(:to_ptr) )
+ return arg.to_ptr.to_i
+ else
+ begin
+ return Integer(arg)
+ rescue
+ raise(ArgumentError, "unknown argument type: #{arg.class}")
+ end
+ end
+ end
+ end
+ end
+end
diff --git a/jni/ruby/ext/fiddle/libffi-3.2.1/ChangeLog b/jni/ruby/ext/fiddle/libffi-3.2.1/ChangeLog
new file mode 100644
index 0000000..68990e3
--- /dev/null
+++ b/jni/ruby/ext/fiddle/libffi-3.2.1/ChangeLog
@@ -0,0 +1,5505 @@
+commit 20562ac0427c3578250d04c6e34fb0127d4551cf
+Author: Anthony Green <green@moxielogic.com>
+Date: Wed Nov 12 07:00:59 2014 -0500
+
+ Fix for AArch64. Release as 3.2.1.
+
+commit a0bdc5250cd36f1d2578358e33299fd2408091ac
+Author: Anthony Green <green@moxielogic.com>
+Date: Tue Nov 11 09:43:01 2014 -0500
+
+ Fix typo
+
+commit 67c0c0705318d2e567fd48e680d63dca3619a235
+Author: Anthony Green <green@moxielogic.com>
+Date: Tue Nov 11 07:30:49 2014 -0500
+
+ Final 3.2 changes
+
+commit ee826b933bbdeb68ee81876ffb508c3908eed371
+Author: Anthony Green <green@moxielogic.com>
+Date: Tue Nov 11 07:29:26 2014 -0500
+
+ Final 3.2 changes
+
+commit c81a705d53be97899d314953987936213244b1ba
+Author: Anthony Green <green@moxielogic.com>
+Date: Tue Nov 4 13:29:58 2014 -0500
+
+ Mention OpenRISC
+
+commit 6a17ad540d7ddb7a812687f4380bd0ef2d2865bb
+Merge: 990eb9d 0f316ab
+Author: Anthony Green <green@moxielogic.com>
+Date: Sun Sep 28 00:54:00 2014 -0400
+
+ Merge pull request #134 from s-macke/openrisc
+
+ Add OpenRISC support
+
+commit 990eb9d4c244324771a7d878a168bb8eba1850c0
+Author: Anthony Green <green@moxielogic.com>
+Date: Sun Sep 28 00:50:29 2014 -0400
+
+ Only run the complex type tests on supported platforms.
+
+commit 0f316ab7c11b8315a838a6ae4645d36ff2c46f4c
+Author: Sebastian Macke <sebastian@macke.de>
+Date: Sat Sep 27 00:19:15 2014 +0000
+
+ Add OpenRISC support
+
+ This patch adds support for the OpenRISC architecture.
+ (http://opencores.org/or1k/Main_Page)
+
+ This patch has been tested under Linux with QEMU-user emulation support.
+ - 32 Bit
+ - big endian
+ - delayed instructions
+ This is the only available configuration under Linux.
+
+ The description of the ABI can be found on the official website.
+
+ Is passes the testsuite except of the unwindtest_ffi_call.cc
+ testcase, which seems to be a problem of gcc and not libffi.
+ Some testcases of the gcc testsuite still fail.
+
+ Signed-off-by: Sebastian Macke <sebastian@macke.de>
+
+commit 6695983d2f0857caab220862de12f3f94a55bcf6
+Author: Anthony Green <green@moxielogic.com>
+Date: Sat Sep 20 07:44:37 2014 -0400
+
+ Add complex type support. Mostly broken right now
+
+commit fbbf48fbdf9b1491af0aefc00523a1b5d8bb9349
+Author: Anthony Green <green@moxielogic.com>
+Date: Sat Sep 20 07:43:51 2014 -0400
+
+ Compile tests with -Wno-psabi when using GCC
+
+commit ae8d2554c5f192be54dadc9f99a1449b4df1b222
+Author: Anthony Green <green@moxielogic.com>
+Date: Sat Sep 20 07:08:37 2014 -0400
+
+ Update version to 3.2
+
+commit b2ca59d39d2192021316561ea9dda3d35d8d35d9
+Author: Anthony Green <green@moxielogic.com>
+Date: Sat Sep 20 07:08:05 2014 -0400
+
+ More README updates for 3.2
+
+commit f920a01ad8eafc79daaf331499ef9a97696c46a7
+Author: Anthony Green <green@moxielogic.com>
+Date: Sat Sep 20 06:54:06 2014 -0400
+
+ Update release notes.
+
+commit bfcbf329c5e4bebdb32134d4e53260e17e4e66cc
+Author: Bernd Edlinger <bernd.edlinger@hotmail.de>
+Date: Sat Sep 20 06:51:45 2014 -0400
+
+ 2014-05-11 Bernd Edlinger <bernd.edlinger@hotmail.de>
+
+ Fix current cygwin-64 build problems.
+ * src/java_raw_api.c: Remove if !defined(FFI_NO_RAW_API).
+ * src/x86/ffi.c: Add if defined(__CYGWIN__).
+ * src/x86/win64.S (ffi_closure_win64, ffi_call_win64): Added
+ handling for FFI_TYPE_UINT64, FFI_TYPE_POINTER and FFI_TYPE_INT.
+ Added SEH information. Fixed formatting.
+
+commit 32cb2ce81db9457c6bd43a2587d7fa23a2edb9b1
+Author: Jakub Jelinek <jakub@redhat.com>
+Date: Sat Sep 20 06:39:55 2014 -0400
+
+ 2014-09-10 Jakub Jelinek <jakub@redhat.com>
+
+ * src/powerpc/linux64.S: Emit .note.GNU-stack even when
+ POWERPC64 is not defined.
+ * src/powerpc/linux64_closure.S: Likewise. Also test _CALL_ELF == 2.
+
+commit aaf3101ba81af8f488502881648e3f687721671e
+Author: Matthias Klose <doko@ubuntu.com>
+Date: Sat Sep 20 06:37:04 2014 -0400
+
+ Fix -Werror=declaration-after-statement problem
+
+commit 6e8a4460833594d5af1b4539178025da0077df19
+Author: Dominik Vogt <vogt@linux.vnet.ibm.com>
+Date: Sat Sep 20 06:21:19 2014 -0400
+
+ 2014-07-22 Dominik Vogt <vogt@linux.vnet.ibm.com>
+
+ * src/types.c (FFI_TYPEDEF, FFI_NONCONST_TYPEDEF): Merge the macros by
+ adding another argument that controls whether the result is const or not
+ (FFI_LDBL_CONST): Temporary macro to reduce ifdef confusion
+ * src/prep_cif.c (ffi_prep_cif_core): Replace list of systems with new
+ macro FFI_TARGET_SPECIFIC_STACK_SPACE_ALLOCATION
+ * src/pa/ffitarget.h (FFI_TARGET_SPECIFIC_STACK_SPACE_ALLOCATION):
+ Define.
+ * src/s390/ffitarget.h (FFI_TARGET_SPECIFIC_STACK_SPACE_ALLOCATION):
+ Define.
+ * src/x86/ffitarget.h (FFI_TARGET_SPECIFIC_STACK_SPACE_ALLOCATION):
+ Define.
+
+ 2014-07-22 Dominik Vogt <vogt@linux.vnet.ibm.com>
+
+ * doc/libffi.texi (Primitive Types): Document ffi_type_complex_float,
+ ffi_type_complex_double and ffi_type_complex_longdouble
+ (Complex Types): New subsection.
+ (Complex Type Example): Ditto.
+ * testsuite/libffi.call/cls_align_complex_double.c: New
+ FFI_TYPE_COMPLEX test.
+ * testsuite/libffi.call/cls_align_complex_float.c: Ditto.
+ * testsuite/libffi.call/cls_align_complex_longdouble.c: Ditto.
+ * testsuite/libffi.call/cls_complex_double.c: Ditto.
+ * testsuite/libffi.call/cls_complex_float.c: Ditto.
+ * testsuite/libffi.call/cls_complex_longdouble.c: Ditto.
+ * testsuite/libffi.call/cls_complex_struct_double.c: Ditto.
+ * testsuite/libffi.call/cls_complex_struct_float.c: Ditto.
+ * testsuite/libffi.call/cls_complex_struct_longdouble.c: Ditto.
+ * testsuite/libffi.call/cls_complex_va_double.c: Ditto.
+ * testsuite/libffi.call/cls_complex_va_float.c: Ditto.
+ * testsuite/libffi.call/cls_complex_va_longdouble.c: Ditto.
+ * testsuite/libffi.call/complex_double.c: Ditto.
+ * testsuite/libffi.call/complex_defs_double.c: Ditto.
+ * testsuite/libffi.call/complex_float.c: Ditto.
+ * testsuite/libffi.call/complex_defs_float.c: Ditto.
+ * testsuite/libffi.call/complex_longdouble.c: Ditto.
+ * testsuite/libffi.call/complex_defs_longdouble.c: Ditto.
+ * testsuite/libffi.call/complex_int.c: Ditto.
+ * testsuite/libffi.call/many_complex_double.c: Ditto.
+ * testsuite/libffi.call/many_complex_float.c: Ditto.
+ * testsuite/libffi.call/many_complex_longdouble.c: Ditto.
+ * testsuite/libffi.call/return_complex1_double.c: Ditto.
+ * testsuite/libffi.call/return_complex1_float.c: Ditto.
+ * testsuite/libffi.call/return_complex1_longdouble.c: Ditto.
+ * testsuite/libffi.call/return_complex2_double.c: Ditto.
+ * testsuite/libffi.call/return_complex2_float.c: Ditto.
+ * testsuite/libffi.call/return_complex2_longdouble.c: Ditto.
+ * testsuite/libffi.call/return_complex_double.c: Ditto.
+ * testsuite/libffi.call/return_complex_float.c: Ditto.
+ * testsuite/libffi.call/return_complex_longdouble.c: Ditto.
+ * src/raw_api.c (ffi_raw_to_ptrarray): Handle FFI_TYPE_COMPLEX
+ (ffi_ptrarray_to_raw): Ditto.
+ * src/prep_cif.c (ffi_prep_cif_core): Abort if FFI_TYPE_COMPLEX is not
+ implemented in libffi for the target.
+ * src/java_raw_api.c (ffi_java_raw_size): FFI_TYPE_COMPLEX not supported
+ yet (abort).
+ (ffi_java_raw_to_ptrarray): Ditto.
+ (ffi_java_rvalue_to_raw): Ditto.
+ (ffi_java_raw_to_rvalue): Ditto.
+ * src/debug.c (ffi_type_test): Add debug tests for complex types.
+ * include/ffi.h.in (FFI_TYPE_COMPLEX): Add new FFI_TYPE_COMPLEX.
+ (FFI_TYPE_LAST): Bump.
+ (ffi_type_complex_float): Add new ffi_type_....
+ (ffi_type_complex_double): Ditto.
+ (ffi_type_complex_longdouble): Ditto.
+
+ 2014-07-22 Dominik Vogt <vogt@linux.vnet.ibm.com>
+
+ * src/s390/ffitarget.h (FFI_TARGET_HAS_COMPLEX_TYPE): Define to provide
+ FFI_TYPE_COMPLEX support.
+ * src/s390/ffi.c (ffi_check_struct_type): Implement FFI_TYPE_COMPLEX
+ (ffi_prep_args): Ditto.
+ (ffi_prep_cif_machdep): Ditto.
+ (ffi_closure_helper_SYSV): Ditto.
+
+commit 4c5c4088aa3e4d8103ff9ca441937da64fdd849a
+Merge: 862f53d 5d6340e
+Author: Anthony Green <green@moxielogic.com>
+Date: Thu Sep 18 19:10:54 2014 -0400
+
+ Merge pull request #132 from nielsAD/master
+
+ Pascal and Register calling convention support on x86
+
+commit 862f53de04ff898a128be7eec592bae60930d6df
+Merge: 5df3840 aebf2c3
+Author: Anthony Green <green@moxielogic.com>
+Date: Thu Sep 18 19:06:08 2014 -0400
+
+ Merge pull request #130 from frida/fix/darwin-aarch64-float-alignment
+
+ Fix alignment of FFI_TYPE_FLOAT for Apple's ARM64 ABI
+
+commit 5df384077f3633ec8cf2e08f9199e5a44994dbad
+Merge: 7b7a528 0f4e09d
+Author: Anthony Green <green@moxielogic.com>
+Date: Thu Sep 18 19:05:35 2014 -0400
+
+ Merge pull request #129 from frida/fix/darwin-aarch64-cif-prep
+
+ Fix non-variadic CIF initialization for Apple/ARM64
+
+commit 7b7a5284de7a99edfcee5ac362dbf76251698e1e
+Merge: 4cd5e84 6172a99
+Author: Anthony Green <green@moxielogic.com>
+Date: Thu Sep 18 18:28:05 2014 -0400
+
+ Merge pull request #124 from knuesel/master
+
+ Fix issue with builddir when calling configure with absolute path
+
+commit 4cd5e840122e22636b5838943372c4ed74618e35
+Merge: 1cee07b 08853e3
+Author: Anthony Green <green@moxielogic.com>
+Date: Thu Sep 18 18:27:15 2014 -0400
+
+ Merge pull request #123 from ehsan/clang-cl
+
+ Add support for building with clang-cl
+
+commit 5d6340ef2cf81432da79ac8b0b1b1218ab391438
+Author: nielsAD <niels.a.d@gmail.com>
+Date: Mon Aug 25 17:29:44 2014 +0200
+
+ Determine whether register arguments (THISCALL/FASTCALL/REGISTER) are really passed via register to closures. Use stack if not.
+
+commit 6e346487b879b4b056a847268e381ae6efec4c21
+Author: nielsAD <niels.a.d@gmail.com>
+Date: Mon Aug 25 12:23:29 2014 +0200
+
+ Fixed THISCALL/FASTCALL closures and added basic support for PASCAL/REGISTER closures.
+
+commit 098dca6b31e42dd0256ed7d966729e31961f1461
+Author: nielsAD <niels.a.d@gmail.com>
+Date: Sat Aug 23 00:18:47 2014 +0200
+
+ Support for calling functions with PASCAL and REGISTER calling conventions on x86 Windows/Linux.
+ Also changed indentation to be more consistent throughout the (adjusted) files.
+
+commit 08853e32fb6b750cda664ee6d3290d340429dd4d
+Author: Ehsan Akhgari <ehsan@mozilla.com>
+Date: Thu Jul 31 20:33:33 2014 -0400
+
+ Enable forcing the usage of the static CRT in libffi's msvc wrapper
+
+ This is required for AddressSanitizer builds with clang-cl.
+
+commit aebf2c3023b5ff056a708dc34169f7b549b2ec4f
+Author: Ole André Vadla Ravnås <ole.andre.ravnas@tillitech.com>
+Date: Fri Jul 25 21:40:50 2014 +0200
+
+ Fix alignment of FFI_TYPE_FLOAT for Apple's ARM64 ABI
+
+commit 0f4e09d27dc175ce3e95d070b794351663c7220e
+Author: Ole André Vadla Ravnås <ole.andre.ravnas@tillitech.com>
+Date: Sat Jul 26 00:11:06 2014 +0200
+
+ Fix non-variadic CIF initialization for Apple/ARM64
+
+ Turns out `aarch64_nfixedargs` wasn't initialized in the non-variadic
+ case, resulting in undefined behavior when allocating arguments.
+
+commit 6172a995e14bdbc6150aa02a361f710626a5c293
+Author: Jeremie Knuesel <jeremie.knusel@sensefly.com>
+Date: Wed Jun 25 12:28:17 2014 +0200
+
+ Fix issue with builddir when calling configure with absolute path
+
+commit fb25cd08ed5a87640b02f0feeb10a09b37cfddbe
+Author: Ehsan Akhgari <ehsan@mozilla.com>
+Date: Wed Jun 11 12:07:24 2014 -0400
+
+ Add support for building with clang-cl
+
+commit 1cee07be4712411baa5eb8af22698bc8443a6d6e
+Author: Anthony Green <green@moxielogic.com>
+Date: Thu Jun 12 06:30:59 2014 -0400
+
+ Remove compiler warning
+
+commit ad0d1d239afc7ad09203847793dcc020856d1035
+Author: Samuli Suominen <ssuominen@gentoo.org>
+Date: Thu Jun 12 06:30:21 2014 -0400
+
+ Fix paths in libffi.pc.in
+
+commit df31a85103b0cc232bbc340d7e782a3853c7fad5
+Merge: 69289c1 360aa8c
+Author: Anthony Green <green@moxielogic.com>
+Date: Fri Jun 6 08:24:35 2014 -0400
+
+ Merge pull request #122 from rvandermeulen/1014976
+
+ Don't make --enable-debug imply using the debug CRT in libffi
+
+commit 360aa8ca1ead2fdaefa7b1c6f01ad001d8abae7e
+Author: Mike Hommey <mh+mozilla@glandium.org>
+Date: Mon Jun 2 09:21:10 2014 -0400
+
+ Bug 1014976 - Don't make --enable-debug imply using the debug CRT in libffi.
+
+commit 69289c10b0acb4b52c8b5df4cf738193c618db40
+Author: Anthony Green <green@moxielogic.com>
+Date: Sat May 31 08:54:08 2014 -0400
+
+ Prepare for libffi 3.1.1
+
+commit 978c9540154d320525488db1b7049277122f736d
+Author: Samuli Suominen <ssuominen@gentoo.org>
+Date: Sat May 31 08:53:10 2014 -0400
+
+ Add missing GNU stack markings in win32.S
+
+commit cbc5a3c0200aa6c2cf8d6798d69a21501557c83f
+Author: Ryan Hill <rhill@gentoo.org>
+Date: Sat May 31 08:26:34 2014 -0400
+
+ Fix typo
+
+commit 9d8e3018ac3d0d338373bff7eefa9f006746f4ec
+Author: Anthony Green <green@moxielogic.com>
+Date: Sat May 24 23:28:42 2014 -0400
+
+ Update current version.
+
+commit 18d56cca5a4ee95ad48b129100adf26231518ed0
+Author: Anthony Green <green@moxielogic.com>
+Date: Mon May 19 18:05:33 2014 -0400
+
+ Increment libtool version number
+
+commit 629f1029c47e522e4331988f02f32c203a070e28
+Merge: 0403f33 c1166d4
+Author: Anthony Green <green@moxielogic.com>
+Date: Mon May 19 18:04:28 2014 -0400
+
+ Merge pull request #120 from l0kod/tmpfile
+
+ Create temporary file with O_TMPFILE and O_CLOEXEC when available
+
+commit c1166d4f653bf6d17ad8c265cf5e8da84e2e76dc
+Author: Mickaël Salaün <mic@digikod.net>
+Date: Mon May 12 19:44:08 2014 +0200
+
+ closures: Check for mkostemp(3)
+
+commit 8daeed9570af72eb135c8ded460d2888f05b2e68
+Author: Mickaël Salaün <mic@digikod.net>
+Date: Sun May 11 22:54:58 2014 +0200
+
+ closures: Create temporary file with O_TMPFILE and O_CLOEXEC when available
+
+ The open_temp_exec_file_dir function can create a temporary file without
+ file system accessible link. If the O_TMPFILE flag is not defined (old
+ Linux kernel or libc) the behavior is unchanged.
+
+ The open_temp_exec_file_name function now need a new argument "flags"
+ (like O_CLOEXEC) used for temporary file creation.
+
+ The O_TMPFILE flag allow temporary file creation without race condition.
+ This feature/fix prevent another process to access the (future)
+ executable file from the file system.
+
+ The O_CLOEXEC flag automatically close the temporary file for any
+ execve. This avoid transmitting (executable) file descriptor to a child
+ process.
+
+commit 0403f332b1f478696c30d3d8a0e2f6eef24aaf88
+Author: Anthony Green <green@moxielogic.com>
+Date: Mon May 19 09:41:32 2014 -0400
+
+ Update date. Annoucing 3.1 today.
+
+commit 94ac0c168ee7b115409121d88b25a4979446c8da
+Author: Anthony Green <green@moxielogic.com>
+Date: Mon May 19 09:37:21 2014 -0400
+
+ Increment libtool library revision number
+
+commit 57465744b6e1295d7202de5a7734df589518f1c8
+Author: Anthony Green <green@moxielogic.com>
+Date: Sun May 11 10:30:22 2014 -0400
+
+ Update to version 3.1
+
+commit 0c2251a42df5108b6d9ebe5fe1cf83d0bcdf660e
+Author: Anthony Green <green@moxielogic.com>
+Date: Sun May 11 10:22:30 2014 -0400
+
+ Support versions of git older than 1.8.5
+
+commit 70c303cb88e23aaee91c87c56b108c50ab4f3c2f
+Author: Anthony Green <green@moxielogic.com>
+Date: Sun May 11 09:56:40 2014 -0400
+
+ Fix testsuite for GCC 4.9.0
+
+commit 52b3457093ed19b2a7c5fcf243c4014c90ce6225
+Author: Magnus Granberg <zorry@gentoo.org>
+Date: Sun May 11 09:55:28 2014 -0400
+
+ Check /proc/self/status for PaX status.
+
+commit 7ba4c5d72aa440a4b21fb57e999e67c5957761da
+Author: Dominik Vogt <dominik.vogt@gmx.de>
+Date: Sun May 11 09:52:47 2014 -0400
+
+ Use to get correct dir
+
+commit 31e0d4ecff6dc2a6c75a066ee099b52a43f6ba27
+Merge: 1c0e9a7 99909eb
+Author: Anthony Green <green@moxielogic.com>
+Date: Wed Apr 23 19:24:47 2014 -0400
+
+ Merge pull request #119 from joshtriplett/fastcall-fastball
+
+ src/x86/win32.S: Define ffi_closure_FASTCALL in the MASM section, too
+
+commit 99909eb6184b62408d88b6b4e7ab38e84e6d0bf3
+Author: Josh Triplett <josh@joshtriplett.org>
+Date: Tue Apr 22 21:17:52 2014 -0700
+
+ src/x86/win32.S: Define ffi_closure_FASTCALL in the MASM section, too
+
+commit 1c0e9a7297ced15413c2d2d5d35f6c650c4b46c9
+Merge: 93a24f2 d369522
+Author: Anthony Green <green@moxielogic.com>
+Date: Mon Apr 21 12:41:56 2014 -0400
+
+ Merge pull request #101 from joshtriplett/fastcall-closures
+
+ Support closures for fastcall
+
+commit d36952273d4fafbda91ecc205fc0824f7cc65e70
+Author: Josh Triplett <josh@joshtriplett.org>
+Date: Sun Apr 20 12:03:25 2014 -0700
+
+ Support fastcall closures
+
+ libffi on 32-bit x86 now supports closures for all supported ABIs.
+ Thus, rewrite the last remaining duplicated-by-ABI test (closure_stdcall
+ and closure_thiscall) to use the generic ABI_NUM/ABI_ATTR mechanism.
+
+commit 93a24f216bcdd1018b976d697179c6d49004015a
+Merge: dd11a04 2349fec
+Author: Anthony Green <green@moxielogic.com>
+Date: Sat Apr 12 19:38:07 2014 -0400
+
+ Merge pull request #80 from ueno/devel
+
+ Fix typo in doc
+
+commit dd11a04061cb49ce1d702545693c24eb1267d648
+Merge: 8fa2812 03ca880
+Author: Anthony Green <green@moxielogic.com>
+Date: Sat Apr 12 19:37:21 2014 -0400
+
+ Merge pull request #86 from joshtriplett/testsuite-CC-CXX
+
+ testsuite ignores CC parameter supplied to configure or make
+
+commit 8fa2812355e685a42abf9a62fbc674d616b2edee
+Merge: 8a58e6b 419503f
+Author: Anthony Green <green@moxielogic.com>
+Date: Sat Apr 12 19:32:08 2014 -0400
+
+ Merge pull request #116 from frida/fix/darwin-aarch64-variadic
+
+ Fix handling of variadic calls on Darwin/AArch64
+
+commit 8a58e6b7805b736def197b8baf8e465a2a3f6913
+Merge: 30b77c5 a539f7f
+Author: Anthony Green <green@moxielogic.com>
+Date: Sat Apr 12 19:30:18 2014 -0400
+
+ Merge pull request #115 from frida/fix/darwin-aarch64-alignment
+
+ Fix alignment of AArch64 assembler functions
+
+commit 30b77c56f95c63ecd83399aafdbad7b07330f2fd
+Merge: dc33cb3 3e2b84d
+Author: Anthony Green <green@moxielogic.com>
+Date: Sat Apr 12 19:29:13 2014 -0400
+
+ Merge pull request #117 from frida/fix/windows-regression
+
+ Fix Windows regression
+
+commit 3e2b84d295531720917bf46afc532fc6d877e3ec
+Author: Ole André Vadla Ravnås <ole.andre.ravnas@tillitech.com>
+Date: Sat Apr 12 01:04:04 2014 +0200
+
+ Fix Windows regression
+
+ Introduced by b5fed601948237037513a9b7f967c8fc6c9ff1f6.
+
+commit 419503f409c321fe31ff59d963ef34bb913420d0
+Author: Ole André Vadla Ravnås <ole.andre.ravnas@tillitech.com>
+Date: Sun Apr 6 20:54:13 2014 +0200
+
+ Fix handling of variadic calls on Darwin/AArch64
+
+commit a539f7ffd6783aa11353d13265520e453c565fb4
+Author: Ole André Vadla Ravnås <ole.andre.ravnas@tillitech.com>
+Date: Sun Apr 6 20:53:02 2014 +0200
+
+ Fix alignment of AArch64 assembler functions
+
+commit dc33cb3c998da521a960385c1269c3aef552f69f
+Merge: c860a99 b5fed60
+Author: Anthony Green <green@moxielogic.com>
+Date: Sat Apr 5 23:41:22 2014 -0400
+
+ Merge pull request #114 from joshtriplett/bounce-on-a-tiny-trampoline
+
+ Fix ABI on 32-bit non-Windows x86: go back to trampoline size 10
+
+commit b5fed601948237037513a9b7f967c8fc6c9ff1f6
+Author: Josh Triplett <josh@joshtriplett.org>
+Date: Sat Apr 5 17:33:42 2014 -0700
+
+ Fix ABI on 32-bit non-Windows x86: go back to trampoline size 10
+
+ The trampoline size is part of the ABI, so it cannot change. Move the
+ logic from the stdcall and thiscall trampolines to the functions they
+ call, to reduce them both to 10 bytes.
+
+ This drops the previously added support for raw THISCALL closures on
+ non-Windows. (Non-raw THISCALL closures still work.)
+
+commit 03ca880081b22efab09ba72268270f83017d3d7b
+Author: Josh Triplett <josh@joshtriplett.org>
+Date: Thu Mar 27 08:44:34 2014 -0700
+
+ README: Note the testsuite changes to respect $CC and $CXX
+
+commit d74df8c5d8c6722ecb908da98c86cc8e2c755b84
+Author: Josh Triplett <josh@joshtriplett.org>
+Date: Thu Mar 27 00:44:12 2014 -0700
+
+ README: Update Windows example to set both CC and CXX
+
+commit 7d698125b1f05173f3656a89755a2eb58813b002
+Author: Josh Triplett <josh@joshtriplett.org>
+Date: Wed Mar 26 23:17:56 2014 -0700
+
+ Use the proper C++ compiler to run C++ tests
+
+ Running the C compiler with -shared-libgcc -lstdc++ does not work on
+ non-GCC compilers.
+
+commit fa5e88f170cb37c7b2b9bb015c8c5b854ffd8a3e
+Author: Josh Triplett <josh@joshtriplett.org>
+Date: Wed Mar 26 23:53:57 2014 -0700
+
+ .travis.yml: Make the build command more readable by splitting at &&
+
+ "script" can contain multiple commands to run in sequence.
+
+commit 0c3824702d3d59d37f8c177d646303f546187683
+Author: Josh Triplett <josh@joshtriplett.org>
+Date: Wed Mar 26 14:51:32 2014 -0700
+
+ Always set CC_FOR_TARGET for dejagnu, to make the testsuite respect $CC
+
+ This fixes cross-compilation and compilation with CC="gcc -m32".
+
+commit 9946a92af31b30cb7760150d1f8ca6c11b01aeea
+Author: Josh Triplett <josh@joshtriplett.org>
+Date: Wed Mar 26 20:18:58 2014 -0700
+
+ Stop looking for expect and runtest above top_builddir
+
+ Users wishing to test hand-compiled versions of expect and runtest can
+ easily enough put them in their path or set EXPECT and RUNTEST
+ themselves.
+
+commit acb202325215058639234efb7af1f04c1c8a1f44
+Author: Josh Triplett <josh@joshtriplett.org>
+Date: Wed Mar 26 20:18:41 2014 -0700
+
+ Stop setting an empty AM_RUNTESTFLAGS
+
+commit c860a992fef5d7cd7bb0975b1632d17a9fafe007
+Author: Anthony Green <green@moxielogic.com>
+Date: Tue Mar 25 17:02:51 2014 -0400
+
+ Upgrade version to 3.1-rc1
+
+commit 9837073e6203048a162a226798c5d252600219ed
+Author: Anthony Green <green@moxielogic.com>
+Date: Tue Mar 25 16:24:14 2014 -0400
+
+ Update copyright date and clean up README notes.
+
+commit 18d3baa9f597b026675baa1b4e5a5eeef7577a08
+Merge: afee537 f0c8a31
+Author: Anthony Green <green@moxielogic.com>
+Date: Tue Mar 25 16:12:53 2014 -0400
+
+ Merge pull request #108 from joshtriplett/freebsd
+
+ [3.1 blocker] Fix FreeBSD support
+
+commit afee53738a995e23bd2f89fd0f7b30b380566106
+Merge: 7d24785 b2d610e
+Author: Anthony Green <green@moxielogic.com>
+Date: Tue Mar 25 16:12:35 2014 -0400
+
+ Merge pull request #106 from joshtriplett/darwin-award
+
+ [3.1 blocker] Update OS X build system to include win32.S on 32-bit
+
+commit 7d2478568ed9f03cbf57627f449a2d2cf4d1571c
+Merge: beab5f3 56be47f
+Author: Anthony Green <green@moxielogic.com>
+Date: Tue Mar 25 16:12:17 2014 -0400
+
+ Merge pull request #110 from joshtriplett/w64
+
+ Fix 64-bit Windows support
+
+commit beab5f334d9ec5b8b91d1cc727d1029b40358e7e
+Merge: 28fb197 ef5890e
+Author: Anthony Green <green@moxielogic.com>
+Date: Tue Mar 25 16:07:47 2014 -0400
+
+ Merge pull request #105 from joshtriplett/win32-relocations
+
+ [3.1 blocker] win32.S needs to handle relocations/GOT
+
+commit f0c8a31577172104049283f0a80c723084a5bd77
+Author: Josh Triplett <josh@joshtriplett.org>
+Date: Mon Mar 24 22:14:26 2014 -0700
+
+ Compile win32.S on FreeBSD
+
+commit b2d610e028b5ce48d1ad7e5d0debc9c321d891b2
+Author: Josh Triplett <josh@joshtriplett.org>
+Date: Fri Mar 21 11:10:13 2014 -0700
+
+ Compile win32.S on 32-bit Darwin as well
+
+commit be50b87a490e794362cb4a27ada2fbaab202adb8
+Author: Josh Triplett <josh@joshtriplett.org>
+Date: Mon Mar 24 21:44:13 2014 -0700
+
+ Always use configure to detect whether global symbols need underscores
+
+ 64-bit Windows already used this check; make it universal, and use it in
+ place of an ifdef on X86_WIN32, to handle non-Windows platforms that use
+ the underscore, such as Darwin.
+
+commit 56be47f87629e31afbcb0774aa65735f539ee972
+Author: Josh Triplett <josh@joshtriplett.org>
+Date: Mon Mar 24 21:24:53 2014 -0700
+
+ Fix a warning on 64-bit Windows
+
+ When sizeof(size_t) != sizeof(unsigned), adding a size_t to cif->bytes
+ produces a "possible loss of data" warning. However, the size_t in
+ question refers to the size of a single parameter. Use a cast to avoid
+ the warning.
+
+commit 48a8eda74aad8a21b6f26df5df08fe64c043d208
+Author: Josh Triplett <josh@joshtriplett.org>
+Date: Mon Mar 24 21:21:12 2014 -0700
+
+ Avoid referencing undefined ABIs on 64-bit Windows builds
+
+ 64-bit Windows does not have FFI_STDCALL, FFI_THISCALL, or FFI_FASTCALL.
+
+commit f0f4138f90345d7d67dfa6783a7e1c7cc30d3c6f
+Author: Josh Triplett <josh@joshtriplett.org>
+Date: Sat Mar 22 10:00:53 2014 -0700
+
+ win32.S: Add handling for position-independent code on Darwin
+
+ Newer versions of Darwin generate the necessary stub functions
+ automatically and just need a call instruction, but accomodating older
+ versions as well requires adding the stub.
+
+commit ef5890ebafb7cd2fbf9acf161edb55fe1382871c
+Author: Josh Triplett <josh@joshtriplett.org>
+Date: Fri Mar 21 11:01:39 2014 -0700
+
+ win32.S: Use shifting for multiplication rather than repeated addition
+
+ The jump table code added a register to itself twice to multiply by 4;
+ shift the register left by 2 instead.
+
+commit 4fca48901e7e4f53bf490ed22607b2d2d8f4bfcc
+Author: Josh Triplett <josh@joshtriplett.org>
+Date: Fri Mar 21 11:00:41 2014 -0700
+
+ win32.S: Make the jump tables position-independent
+
+ Now that non-Windows platforms include win32.S, it needs to support
+ building as position-independent code. This fixes build failures on
+ target platforms that do not allow text relocations.
+
+commit 2087dcf736274286f76c69d3988fb6d7cc4fd0f5
+Author: Josh Triplett <josh@joshtriplett.org>
+Date: Fri Mar 21 10:57:06 2014 -0700
+
+ win32.S: Make calls to ffi_closure_SYSV_inner position-independent
+
+ Now that non-Windows platforms include win32.S, it needs to support
+ building as position-independent code. This fixes one source of build
+ failures on target platforms that do not allow text relocations.
+
+commit 28fb197079cf1d11da4eef7c8c243ab05590c528
+Merge: c697472 c3dd0a1
+Author: Anthony Green <green@moxielogic.com>
+Date: Tue Mar 18 12:19:36 2014 -0400
+
+ Merge pull request #107 from rvandermeulen/msvcc
+
+ Various compatibility fixes and improvements to msvcc.sh.
+
+commit c3dd0a1a0245fc174361a70876e88ae24285f861
+Author: Ryan VanderMeulen <ryanvm@gmail.com>
+Date: Tue Mar 18 12:09:45 2014 -0400
+
+ Various compatibility fixes and improvements to msvcc.sh.
+
+ * Don't try to mix incompatible optimization flags in debug builds.
+ * Workaround ax_cc_maxopt.m4 not supporting MSVC and change -O3 to -O2.
+ * Fix MSVC warning by properly passing linker flags to compiler.
+ * Make msvcc.sh return 1 if invalid command line options are used rather than silently eating them.
+ * Add more comments.
+
+commit c697472fccfbb5b87b007c053cda9ef014b346b9
+Merge: 83fd2bc e48918e
+Author: Anthony Green <green@moxielogic.com>
+Date: Mon Mar 17 00:32:42 2014 -0400
+
+ Merge pull request #102 from joshtriplett/test-generic
+
+ Add ABIs to the test matrix; unify many bits of the testsuite
+
+commit e48918ecf876bc85d040fc50a232059c566553a8
+Author: Josh Triplett <josh@joshtriplett.org>
+Date: Sun Mar 16 20:29:27 2014 -0700
+
+ testsuite: Add ABIs to the test matrix; unify tests across ABIs
+
+ This eliminates all the *_win32.c tests in favor of the tests they were
+ branched from, and expands test coverage to run many more tests on
+ stdcall, thiscall, and fastcall.
+
+ This same mechanism also supports testing any other target that has
+ multiple ABIs.
+
+commit 4d4d368e5a55d9443c4c53b1b70d58ab6d8c941c
+Author: Josh Triplett <josh@joshtriplett.org>
+Date: Sun Mar 16 17:02:05 2014 -0700
+
+ testsuite: Replace ffitestcxx.h with ffitest.h
+
+ ffitest.h contains a superset of the functionality of ffitestcxx.h;
+ make the C++ tests include ffitest.h instead, and remove ffitestcxx.h.
+
+commit 3f97cf3413c46caf2a79f32ac9cda4620972c2d7
+Author: Josh Triplett <josh@joshtriplett.org>
+Date: Sun Mar 16 16:53:42 2014 -0700
+
+ testsuite: Unify the C and C++ testsuites
+
+ These two testsuites differ only in the source file glob and a couple of
+ additional compiler options; unify the remaining bits.
+
+commit 0d9cce8edb937bbe771a6cdd25f671edf06d2128
+Author: Josh Triplett <josh@joshtriplett.org>
+Date: Sun Mar 16 16:22:58 2014 -0700
+
+ testsuite: ffitest.h: Parenthesize the CHECK macro
+
+commit 5695ec1444c5323e48fe4314f8c8f027625e67df
+Author: Josh Triplett <josh@joshtriplett.org>
+Date: Sun Mar 16 16:04:58 2014 -0700
+
+ testsuite: Factor out a function to run a matrix of tests
+
+ This commons up code from libffi.call/call.exp and
+ libffi.special/special.exp, unifies the optimization option matrix
+ between the two, and makes it easier to add more axes to the matrix
+ in the future.
+
+commit dfdb02cc869855d3b68571e5f7aa77ae8c9d254a
+Author: Josh Triplett <josh@joshtriplett.org>
+Date: Sun Mar 16 15:26:26 2014 -0700
+
+ testsuite: Introduce a __THISCALL__ compiler-specific macro
+
+commit 83fd2bce0456224483435d4b764063f4513fd464
+Merge: 3658a07 06ff924
+Author: Anthony Green <green@moxielogic.com>
+Date: Sun Mar 16 22:03:29 2014 -0400
+
+ Merge pull request #99 from joshtriplett/gitignore
+
+ .gitignore: Ignore more generated files
+
+commit 3658a0700a50d37a2fdba04fd9d79ad2f706d9f5
+Merge: d948d0a 46c5d3c
+Author: Anthony Green <green@moxielogic.com>
+Date: Sun Mar 16 21:37:42 2014 -0400
+
+ Merge pull request #100 from rvandermeulen/bug-756740
+
+ Change double quotes in Makefile.am to single quotes.
+
+commit 46c5d3c30fdc2b43c076ad955078d7c5f1e75b37
+Author: Ryan VanderMeulen <ryanvm@gmail.com>
+Date: Sun Mar 16 21:16:08 2014 -0400
+
+ Change double quotes in Makefile.am to single quotes.
+
+ This was originally done in PR #84, except the change was made to Makefile.in instead of Makefile.am and was therefore reverted the next time the files were regenerated.
+
+commit 06ff924215a2f9739efa2c059dc595bc4ec1c851
+Author: Josh Triplett <josh@joshtriplett.org>
+Date: Sun Mar 16 16:19:46 2014 -0700
+
+ .gitignore: Ignore more generated files
+
+ The build process generates doc/libffi.info and fficonfig.h.in, so add
+ them to .gitignore.
+
+commit bad8948346e9b8813023a0cc78a3b6eb8d9c14c6
+Author: Josh Triplett <josh@joshtriplett.org>
+Date: Sun Mar 16 15:16:18 2014 -0700
+
+ testsuite: Introduce a __STDCALL__ compiler-specific macro
+
+ Several tests want to use stdcall, which differs in syntax by compiler,
+ so introduce a macro for it in ffitest.h.
+
+commit 98a793fa36a4ab3ba24d059cb80a2891cdb940e1
+Author: Josh Triplett <josh@joshtriplett.org>
+Date: Sun Mar 16 15:20:36 2014 -0700
+
+ testsuite: Common up the ifdef blocks for compiler-specific macros
+
+commit d948d0a729c934b0224749338a3ba0a2c8f51c45
+Merge: b61b472 a86bd31
+Author: Anthony Green <green@moxielogic.com>
+Date: Sun Mar 16 10:53:48 2014 -0400
+
+ Merge pull request #98 from joshtriplett/unconfigure.host
+
+ Merge configure.host into configure.ac
+
+commit a86bd318e2424d879d784ee7b29d6536d7a17c18
+Author: Josh Triplett <josh@joshtriplett.org>
+Date: Sun Mar 16 06:58:59 2014 -0700
+
+ Merge configure.host into configure.ac
+
+ configure.host only has a single entry, and shows no signs of needing
+ more added.
+
+commit b61b472bd0647006d6685238721002017f1d119c
+Author: Anthony Green <green@moxielogic.com>
+Date: Sun Mar 16 09:45:55 2014 -0400
+
+ Update version to 3.1-rc0. Clean up README.
+
+commit 7a64e7dbba54e6e9f69954adfb943be1856ff928
+Merge: 11a5c5c eef2e02
+Author: Anthony Green <green@moxielogic.com>
+Date: Sun Mar 16 09:39:08 2014 -0400
+
+ Merge pull request #97 from joshtriplett/remove-more-generated-files
+
+ Remove more generated files
+
+commit 11a5c5c39f5861011f6c5ddf795da3a32b5f0082
+Merge: 9a62a21 1c68c07
+Author: Anthony Green <green@moxielogic.com>
+Date: Sun Mar 16 09:38:47 2014 -0400
+
+ Merge pull request #96 from joshtriplett/sawing-changelogs
+
+ Generate ChangeLog from git in make dist; remove it from version control
+
+commit eef2e02a13d7d1c8145d47a64467f654406a3548
+Author: Josh Triplett <josh@joshtriplett.org>
+Date: Sun Mar 16 06:26:03 2014 -0700
+
+ doc: Remove autogenerated info file and stamp
+
+commit 9fb403d3c5d9643e0f561cab6d4a07b1e54907ff
+Author: Josh Triplett <josh@joshtriplett.org>
+Date: Sun Mar 16 06:25:52 2014 -0700
+
+ fficonfig.h.in: Remove, configure generates it
+
+commit 1c68c07217fda78a779778c1480fedef7a58d5b4
+Author: Josh Triplett <josh@joshtriplett.org>
+Date: Sun Mar 16 06:11:58 2014 -0700
+
+ Generate ChangeLog from git in make dist
+
+ Archive the existing ChangeLog to ChangeLog.libffi-3.1
+
+commit c65ed55e655711e008282edbdd82ce95d008b4f6
+Author: Josh Triplett <josh@joshtriplett.org>
+Date: Sun Mar 16 05:52:00 2014 -0700
+
+ ChangeLog.v1: Fix typo in explanatory header.
+
+commit 9a62a21f5c3a8e1da463229f3170c8ab3031d920
+Author: Anthony Green <green@moxielogic.com>
+Date: Sun Mar 16 09:03:57 2014 -0400
+
+ Add missing ChangeLog entry. Clean up some entries.
+
+commit 9bc704c58cb7a049d867837e3a11e2e31886ec66
+Merge: 694447a e892e58
+Author: Anthony Green <green@moxielogic.com>
+Date: Sun Mar 16 08:41:00 2014 -0400
+
+ Merge pull request #95 from joshtriplett/news
+
+ README: Update news for 3.0.14
+
+commit e892e581d1838a06c18c7ecd50ebd79915cff92b
+Author: Josh Triplett <josh@joshtriplett.org>
+Date: Sun Mar 16 05:38:24 2014 -0700
+
+ README: Update news for 3.0.14
+
+commit 694447aa29deadd571efb4e9a26ee3f68ede1493
+Merge: fdc87f3 45a6c21
+Author: Anthony Green <green@moxielogic.com>
+Date: Sun Mar 16 08:32:05 2014 -0400
+
+ Merge pull request #93 from joshtriplett/travis-dist
+
+ Make Travis check "make dist"
+
+commit 45a6c21efa944b520842e631dc54919b04884744
+Author: Josh Triplett <josh@joshtriplett.org>
+Date: Sun Mar 16 05:29:08 2014 -0700
+
+ .travis.yml: Test "make dist" too.
+
+commit fdc87f3b2ea37b58a4a9ae6c35083f544909fe3c
+Merge: 7412b83 e1911f7
+Author: Anthony Green <green@moxielogic.com>
+Date: Sun Mar 16 08:05:51 2014 -0400
+
+ Merge pull request #85 from joshtriplett/stdcall
+
+ stdcall support on Linux
+
+commit e1911f78df113ca58738b66089a070d4cf747de7
+Author: Josh Triplett <josh@joshtriplett.org>
+Date: Sun Mar 16 03:25:53 2014 -0700
+
+ Add support for stdcall, thiscall, and fastcall on non-Windows x86-32
+
+ Linux supports the stdcall calling convention, either via functions
+ explicitly declared with the stdcall attribute, or via code compiled
+ with -mrtd which effectively makes stdcall the default.
+
+ This introduces FFI_STDCALL, FFI_THISCALL, and FFI_FASTCALL on
+ non-Windows x86-32 platforms, as non-default calling conventions.
+
+commit 7412b838d543aae4fa925862bd5702d3dacbc29a
+Merge: c0cc5fd 9531d05
+Author: Anthony Green <green@moxielogic.com>
+Date: Sun Mar 16 07:58:16 2014 -0400
+
+ Merge pull request #90 from joshtriplett/win32-unifdef
+
+ prep_cif.c: Remove unnecessary ifdef for X86_WIN32
+
+commit c0cc5fdaa237b67e86f22d2f6e13f3b42d9aae33
+Merge: 98b5296 b3a5da0
+Author: Anthony Green <green@moxielogic.com>
+Date: Sun Mar 16 07:57:59 2014 -0400
+
+ Merge pull request #89 from joshtriplett/travis32
+
+ .travis.yml: Test on both 32-bit and 64-bit
+
+commit 9531d05f64c2a674e0197158ffad68d69f177bd0
+Author: Josh Triplett <josh@joshtriplett.org>
+Date: Sun Mar 16 01:50:02 2014 -0700
+
+ prep_cif.c: Remove unnecessary ifdef for X86_WIN32
+
+ ffi_prep_cif_core had a special case for X86_WIN32, checking for
+ FFI_THISCALL in addition to the FFI_FIRST_ABI-to-FFI_LAST_ABI range
+ before returning FFI_BAD_ABI. However, on X86_WIN32, FFI_THISCALL
+ already falls in that range, making the special case unnecessary.
+ Remove it.
+
+commit b3a5da068abd2f2983d9e67adbf41b0e0f34e37f
+Author: Josh Triplett <josh@joshtriplett.org>
+Date: Sat Mar 15 23:27:56 2014 -0700
+
+ .travis.yml: Test on both 32-bit and 64-bit
+
+commit 98b52960485a261399f081915f36063de3854a5f
+Merge: 134ce4c f6dd184
+Author: Anthony Green <green@moxielogic.com>
+Date: Sun Mar 16 07:51:33 2014 -0400
+
+ Merge pull request #94 from joshtriplett/esp-extra-stackery-perception
+
+ ChangeLog: Document testsuite changes to remove fragile stack pointer checks
+
+commit f6dd1845434dd53e22129becdfa092c082df307c
+Author: Josh Triplett <josh@joshtriplett.org>
+Date: Sun Mar 16 04:49:36 2014 -0700
+
+ ChangeLog: Document testsuite changes to remove fragile stack pointer checks
+
+commit 134ce4c0266bf994f07518fc534de53f1d3c8de8
+Merge: 2680e9e 9c27932
+Author: Anthony Green <green@moxielogic.com>
+Date: Sun Mar 16 07:47:17 2014 -0400
+
+ Merge pull request #91 from joshtriplett/esp-extra-stackery-perception
+
+ testsuite: Remove fragile stack pointer checks
+
+commit 9c279328ee12fc869adff63ca81f1230977bd42b
+Author: Josh Triplett <josh@joshtriplett.org>
+Date: Sun Mar 16 02:31:19 2014 -0700
+
+ testsuite: Remove fragile stack pointer checks
+
+ testsuite/libffi.call/closure_stdcall.c and
+ testsuite/libffi.call/closure_thiscall.c include inline assembly to save
+ the stack pointer before and after the call, and compare the values.
+ However, compilers can and do leave the stack in different states for
+ these two pieces of inline assembly, such as by saving a temporary value
+ on the stack across the call; observed with gcc -Os, and verified as
+ spurious through careful inspection of disassembly.
+
+commit 2680e9ea9b4c87ea8042a61e551bd667493d4bd3
+Merge: 071eab3 82f8cb2
+Author: Anthony Green <green@moxielogic.com>
+Date: Sun Mar 16 07:44:08 2014 -0400
+
+ Merge pull request #88 from joshtriplett/such-precision-many-fail-wow
+
+ testsuite/libffi.call/many.c: Avoid spurious failure due to excess precision
+
+commit 82f8cb24a1d976db35ae31a4b86cec8926da327d
+Author: Josh Triplett <josh@joshtriplett.org>
+Date: Sun Mar 16 04:27:32 2014 -0700
+
+ ChangeLog: Document many.c and many_win32.c changes to avoid spurious failures
+
+commit 88d562a8b5912e99306063fe3bc289bab6ca6ebe
+Author: Josh Triplett <josh@joshtriplett.org>
+Date: Sat Mar 15 22:08:19 2014 -0700
+
+ testsuite/libffi.call/many_win32.c: Avoid spurious failure due to excess precision
+
+ The test case testsuite/libffi.call/many_win32.c can spuriously fail due
+ to excess floating-point precision. Instrumenting it with some printf
+ calls shows differences well above FLT_EPSILON. (Note when
+ instrumenting it that multiple computations of the difference, such as
+ one in a print and another in the conditional, may produce different
+ results.)
+
+ Rather than complicating the test suite with architecture-specific flags
+ to avoid excess precision, just simplify the floating-point computation
+ to avoid a dependency on potential excess precision.
+
+commit c00a49ecd165b2d06c1c9b249d212dc843fa116f
+Author: Josh Triplett <josh@joshtriplett.org>
+Date: Sat Mar 15 22:08:19 2014 -0700
+
+ testsuite/libffi.call/many.c: Avoid spurious failure due to excess precision
+
+ The test case testsuite/libffi.call/many.c can spuriously fail due to
+ excess floating-point precision. Instrumenting it with some printf
+ calls shows differences well above FLT_EPSILON. (Note when
+ instrumenting it that multiple computations of the difference, such as
+ one in a print and another in the conditional, may produce different
+ results.)
+
+ Rather than complicating the test suite with architecture-specific flags
+ to avoid excess precision, just simplify the floating-point computation
+ to avoid a dependency on potential excess precision.
+
+commit 071eab32a7f9fbbef46c0d8f37d9985bc9cceb37
+Merge: 2228c7a 2f44952
+Author: Anthony Green <green@moxielogic.com>
+Date: Sun Mar 16 07:36:52 2014 -0400
+
+ Merge pull request #92 from joshtriplett/autogen
+
+ Re-add libtool-ldflags
+
+commit 2f44952c95765c1486fad66f57235f8d459a9748
+Author: Josh Triplett <josh@joshtriplett.org>
+Date: Sun Mar 16 04:35:12 2014 -0700
+
+ Re-add libtool-ldflags
+
+commit 2228c7ab190f3c529b9018495467b841fa21cba2
+Merge: 76d19d0 35634db
+Author: Anthony Green <green@moxielogic.com>
+Date: Sun Mar 16 07:25:18 2014 -0400
+
+ Merge pull request #87 from joshtriplett/autogen
+
+ Remove autogenerated files from the repository
+
+commit 35634dbceaac0a1544f7385addc01d21ef1ef6a8
+Author: Josh Triplett <josh@joshtriplett.org>
+Date: Sat Mar 15 18:11:16 2014 -0700
+
+ Remove autogenerated files from the repository
+
+ Add an autogen.sh to regenerate them.
+
+commit 76d19d004e36e99d261ee78261e2f52cea5e4ab1
+Merge: c86d9b6 a1a6f71
+Author: Anthony Green <green@moxielogic.com>
+Date: Fri Mar 14 16:54:31 2014 -0400
+
+ Ensure the linker supports @unwind sections in libffi.
+
+commit c86d9b6cc6e16ee262844a33b40441374400758c
+Merge: 4efb7db f8cdf11
+Author: Anthony Green <green@moxielogic.com>
+Date: Fri Mar 14 16:51:20 2014 -0400
+
+ Fix merge
+
+commit 4efb7dbfd9427c478a948cd0d464210123db8de8
+Merge: 634a475 18eb81d
+Author: Anthony Green <green@moxielogic.com>
+Date: Fri Mar 14 16:47:57 2014 -0400
+
+ Merge pull request #81 from rvandermeulen/bug-756740
+
+ Allow building for mipsel with Android NDK r8.
+
+commit a1a6f71bfe4199293043b2e4cfb4c8d3cb1112f9
+Author: Ryan VanderMeulen <ryanvm@gmail.com>
+Date: Mon Mar 10 15:12:47 2014 -0400
+
+ Remove stray hunk that shouldn't have been included in this patch.
+
+commit f8cdf11467181f2a9a6b7e748167569aa58e3a81
+Author: Ryan VanderMeulen <ryanvm@gmail.com>
+Date: Mon Mar 10 15:04:58 2014 -0400
+
+ Replace double quotes with single quotes in Makefile.in to improve compatibility between some versions of MSYS and gmake. From Mozilla bug 943728.
+ https://bugzilla.mozilla.org/show_bug.cgi?id=943728
+
+commit dfa3738732e1bc3a7f4130395ae4bab55fcebb99
+Author: Ryan VanderMeulen <ryanvm@gmail.com>
+Date: Mon Mar 10 14:53:48 2014 -0400
+
+ Ensure the linker supports @unwind sections in libffi. From Mozilla bug 756740.
+ https://bugzilla.mozilla.org/show_bug.cgi?id=778414
+
+ Also tracked as issue #42.
+ https://github.com/atgreen/libffi/issues/42
+
+commit 18eb81d032f29d645d0498ba92bddfd651f009ae
+Author: Ryan VanderMeulen <ryanvm@gmail.com>
+Date: Mon Mar 10 14:43:37 2014 -0400
+
+ Allow building for mipsel with Android NDK r8. From Mozilla bug 756740.
+ https://bugzilla.mozilla.org/show_bug.cgi?id=756740
+
+commit 2349fec9a818fb52fd2f294bcbc7b3156cd113de
+Author: Daiki Ueno <ueno@gnu.org>
+Date: Wed Mar 5 17:53:02 2014 +0900
+
+ Fix typo in doc
+
+commit 634a475eaf1bee31c09f7d519e31c13b64cd24df
+Author: Anthony Green <green@moxielogic.com>
+Date: Sat Mar 1 18:37:29 2014 -0500
+
+ Update Makefile for new darwin scripts
+
+commit c7b67e874bb89859f9a07d1cf9606052b6c0dcc1
+Author: Anthony Green <green@moxielogic.com>
+Date: Sat Mar 1 18:34:18 2014 -0500
+
+ Add README note
+
+commit a04e30ba3dc303133d459c1ac273ceefe4d49b32
+Author: Anthony Green <green@moxielogic.com>
+Date: Fri Feb 28 17:20:59 2014 -0500
+
+ Add missing -DFFI_DEBUG flag
+
+commit 934dc1b5c8d6a9e727bedc72342831eb7d62c35f
+Merge: 11d7aa9 67fbef3
+Author: Anthony Green <green@moxielogic.com>
+Date: Fri Feb 28 01:10:17 2014 -0500
+
+ Merge branch 'master' of github.com:/atgreen/libffi
+
+commit 11d7aa9d7a4bbe642944edc0f07cf96db9b270b6
+Merge: b40aeda 3b44d41
+Author: Anthony Green <green@moxielogic.com>
+Date: Fri Feb 28 01:06:48 2014 -0500
+
+ Merge pull request #46 from makotokato/android-clang
+
+ Fix build failure when using clang for Android
+
+commit 67fbef3b56ff0ef88f9b1a7fe48cb77222fa6cec
+Merge: b40aeda 3b44d41
+Author: Anthony Green <green@moxielogic.com>
+Date: Fri Feb 28 01:06:48 2014 -0500
+
+ Merge pull request #46 from makotokato/android-clang
+
+ Fix build failure when using clang for Android
+
+commit b40aeda31a74d95a37c723b6243aabac466e67c4
+Merge: 20698ab 53ceaf1
+Author: Anthony Green <green@moxielogic.com>
+Date: Fri Feb 28 01:01:29 2014 -0500
+
+ Merge branch 'master' of github.com:/atgreen/libffi
+
+commit 53ceaf14c5eeb16ba09745f0ca87cca367d41a90
+Merge: 860fe66 cc9b518
+Author: Anthony Green <green@moxielogic.com>
+Date: Fri Feb 28 01:01:02 2014 -0500
+
+ Merge pull request #40 from wojdyr/master
+
+ Correct the -L flag in libffi.pc.in
+
+commit 20698abc6a00092fd7fd3e434a3a29dc0f048f1e
+Merge: 64bd069 1a0b01e
+Author: Anthony Green <green@moxielogic.com>
+Date: Fri Feb 28 00:56:27 2014 -0500
+
+ Merge pull request #66 from ppizarro/master
+
+ BlackFin fixes - Fatal error when calling a function defined in a shared library from within the function called by FFI
+
+commit 860fe6646f5ae603e99a8d1d722ddddba8b75769
+Merge: 64bd069 1a0b01e
+Author: Anthony Green <green@moxielogic.com>
+Date: Fri Feb 28 00:56:27 2014 -0500
+
+ Merge pull request #66 from ppizarro/master
+
+ BlackFin fixes - Fatal error when calling a function defined in a shared library from within the function called by FFI
+
+commit 64bd06990a7accf72271516a2110b86cdccd8df4
+Author: Anthony Green <green@moxielogic.com>
+Date: Fri Feb 28 00:52:56 2014 -0500
+
+ Add ChangeLog entry for Josh's change
+
+commit edf29c5169b06fcfc241445e152e325bc3c50e0e
+Merge: 33c9954 3998d26
+Author: Anthony Green <green@moxielogic.com>
+Date: Fri Feb 28 00:50:25 2014 -0500
+
+ Merge pull request #75 from joshtriplett/longdouble
+
+ Fix build error on x86 without distinct long double
+
+commit 33c9954f2eec539011a0f93270aaf013318837ae
+Author: Anthony Green <green@moxielogic.com>
+Date: Fri Feb 28 00:38:41 2014 -0500
+
+ Rebuilt with new libtool
+
+commit 926b6989fbd08488b9105943293353d45ac527e0
+Merge: 5a88c85 cc82051
+Author: Anthony Green <green@moxielogic.com>
+Date: Fri Feb 28 00:26:57 2014 -0500
+
+ Merge branch 'master' of github.com:/atgreen/libffi
+
+ Conflicts:
+ ChangeLog
+
+commit 5a88c85fde304052bed1581ed0b6452ac2c68838
+Author: Anthony Green <green@moxielogic.com>
+Date: Fri Feb 28 00:23:04 2014 -0500
+
+ Fix spelling errors
+
+commit cc82051c7e80cea772c4b72da026eb7e68d598fc
+Author: Anthony Green <green@moxielogic.com>
+Date: Fri Feb 28 00:23:04 2014 -0500
+
+ Fix spelling errors
+
+commit 001aaf4b1b56349596bb6f6b5c1613dcbbd84ea8
+Author: Anthony Green <green@moxielogic.com>
+Date: Fri Feb 28 00:20:17 2014 -0500
+
+ When no VFP arguments are present the IP register is used
+ uninitialized. Initialize it to the value of FP.
+
+ This fixes a number of testsuite failures when configured for
+ armv7l-unknown-linux-gnueabihf
+
+commit 49f7729c3ce697c12408c42ccb29cdf4eb66bb85
+Author: Anthony Green <green@moxielogic.com>
+Date: Fri Feb 28 00:17:16 2014 -0500
+
+ aarch64 fix
+
+commit 447483d51c6aa9df7116f346a73fc1cf795f4c2b
+Merge: 51377bd b4df9cf
+Author: Anthony Green <green@moxielogic.com>
+Date: Thu Feb 27 15:42:41 2014 -0500
+
+ Fix ChangeLog merge
+
+commit 3998d2604b5c0d45a098ff3119a9fd9710ef429d
+Author: Josh Triplett <josh@joshtriplett.org>
+Date: Mon Feb 17 11:20:33 2014 -0800
+
+ Fix build error on x86 without distinct long double
+
+ src/x86/ffi64.c: In function 'classify_argument':
+ src/x86/ffi64.c:205:5: error: duplicate case value
+ case FFI_TYPE_LONGDOUBLE:
+ ^
+ src/x86/ffi64.c:202:5: error: previously used here
+ case FFI_TYPE_DOUBLE:
+ ^
+
+commit 51377bda9aed0b2c1309c818460cab9d9ab3d46e
+Merge: f08da54 40927bd
+Author: Anthony Green <green@moxielogic.com>
+Date: Sat Feb 15 08:06:29 2014 -0500
+
+ Merge pull request #72 from heiher/devel
+
+ MIPS N32: Fix call floating point va function
+
+commit f08da5465463e60a28f5e921f23ebf2ba984c148
+Merge: 3dc3f32 fa5f25c
+Author: Anthony Green <green@moxielogic.com>
+Date: Sat Feb 15 08:06:11 2014 -0500
+
+ Merge pull request #68 from zeldin/master
+
+ Linux/ppc64: Remove assumption on contents of r11 in closure
+
+commit 40927bd3e1e7c6007025ba10854fd8a0664e47df
+Author: Heiher <r@hev.cc>
+Date: Tue Jan 21 23:18:27 2014 +0800
+
+ Fix call floating point va function
+
+ I'm not sure floating-point arguments in GPR or FPR before calling
+ variable number arguments function. so, load all arguments to GPR and
+ FPR.
+
+commit b4df9cf9cc4a9a9401a53fd6bea1f3c2c283b97b
+Author: Zachary Waldowski <zach@waldowski.me>
+Date: Wed Feb 5 14:22:52 2014 -0500
+
+ AArch64: Fix void fall-through case when assertions are enabled
+
+commit f466aad0d91a117e42571d1d6fb434fa0433c930
+Author: Zachary Waldowski <zach@waldowski.me>
+Date: Tue Jan 21 16:38:31 2014 -0500
+
+ AArch64: Fix missing semicolons when assertions are enabled
+
+commit 7ea677733bd98917241852b8901a6b7580728895
+Author: Anthony Green <green@moxielogic.com>
+Date: Sat Nov 30 20:58:31 2013 -0500
+
+ Remove build-ios from Makefile
+
+ Conflicts:
+ ChangeLog
+
+commit 6ae046cc59c12b2cd40158d6bcb96f4a59886159
+Author: Anthony Green <green@moxielogic.com>
+Date: Sat Nov 30 21:06:51 2013 -0500
+
+ Mention Aarch64 on iOS
+
+commit bfc06b3fdb32abe90ce0749aedfec649df85a7ef
+Author: Zachary Waldowski <zach@waldowski.me>
+Date: Mon Dec 30 17:36:39 2013 -0500
+
+ Update ChangeLog
+
+commit 0a0f12ce1f7be81006b08a3c81a636926d283a9b
+Author: Zachary Waldowski <zach@waldowski.me>
+Date: Thu Jan 9 13:50:17 2014 -0500
+
+ AArch64: Remove duplicitous element_count call.
+
+ This inhibits an analyzer warning by Clang.
+
+commit 4330fdcd92e67c816288d64ab230237065768206
+Author: Zachary Waldowski <zach@waldowski.me>
+Date: Thu Jan 9 13:53:30 2014 -0500
+
+ Darwin/aarch64: Respect iOS ABI re: stack argument alignment
+
+commit 0a333d6c3973935d4fe02aae76b10e39d3c88e07
+Author: Zachary Waldowski <zach@waldowski.me>
+Date: Thu Jan 9 14:03:29 2014 -0500
+
+ Darwin/aarch64: Fix size_t assumptions
+
+commit 2c18e3c76aad1b426617db05a4384e7c3a920176
+Author: Zachary Waldowski <zach@waldowski.me>
+Date: Mon Dec 30 16:14:02 2013 -0500
+
+ Darwin/aarch64: Fix "shadows declaration" warnings
+
+commit 1b8a8e20e344f3c55495ab6eb46bd14e843d4b3e
+Author: Zachary Waldowski <zach@waldowski.me>
+Date: Thu Jan 9 13:55:21 2014 -0500
+
+ Darwin/aarch64: Use Clang cache invalidation builtin
+
+commit 6030cdcae776f8fb5876a53168f7d1e75d28a242
+Author: Zachary Waldowski <zach@waldowski.me>
+Date: Mon Dec 30 15:45:51 2013 -0500
+
+ Darwin/aarch64: Account for long double being equal to double
+
+commit 5658b0892683d2e24e4d5842978c184a7ad33858
+Author: Zachary Waldowski <zach@waldowski.me>
+Date: Mon Dec 30 16:33:47 2013 -0500
+
+ Darwin/aarch64: Use CNAME, restrict .size like ARM
+
+commit 07175780802acec5dc49fdedd6d20a62409a6707
+Author: Zachary Waldowski <zach@waldowski.me>
+Date: Mon Dec 30 17:48:22 2013 -0500
+
+ Darwin/aarch64: Fix invalid reference in assembly
+
+commit 9da28b44277fea3aeb827c35dd63d609d2524a8b
+Author: Zachary Waldowski <zach@waldowski.me>
+Date: Mon Dec 30 16:23:21 2013 -0500
+
+ Darwin/x86_64: Fix 64-bit type shortening warnings
+
+commit 821d398f08bd1d540a5b235507812ffeee49b580
+Author: Zachary Waldowski <zach@waldowski.me>
+Date: Thu Jan 9 13:15:06 2014 -0500
+
+ Darwin: Merge build scripts, redo project, incl. arm64
+
+commit 6eff9ff9e72463b9783be2514f944b6f05692054
+Author: Zachary Waldowski <zach@waldowski.me>
+Date: Mon Dec 30 17:48:10 2013 -0500
+
+ Darwin/iOS: Improve unified syntax use for LLVM
+
+commit ba0ea99c82aadd5957386a031e3122011bd36d52
+Author: Zachary Waldowski <zach@waldowski.me>
+Date: Mon Dec 30 15:27:44 2013 -0500
+
+ Fix dlmalloc warnings due to set_segment_flags, sizeof(size_t)
+
+commit 994be3a5c1d0d17b19103396103e128517fd62f9
+Author: Zachary Waldowski <zach@waldowski.me>
+Date: Mon Dec 30 15:27:14 2013 -0500
+
+ Darwin/iOS: Fix mis-typing of vfp_reg_free
+
+commit a8e0a835ab1f62d03ad6391760e3e8b7732d24f8
+Author: Zachary Waldowski <zach@waldowski.me>
+Date: Mon Dec 30 15:26:20 2013 -0500
+
+ Darwin/ARM: Assert on NULL dereference
+
+ This inhibits an analyzer warning by Clang on all platforms.
+
+commit 13675341581c489ed9df8ba390c8e08a732decb2
+Author: Zachary Waldowski <zach@waldowski.me>
+Date: Thu Jan 9 13:42:08 2014 -0500
+
+ Darwin/i386: Inhibit Clang previous prototype warnings
+
+commit 66469c381e2e2cc96e7d409266dea0ffe177eeca
+Author: Zachary Waldowski <zach@waldowski.me>
+Date: Thu Jan 9 13:41:45 2014 -0500
+
+ Darwin/ARM: Inhibit Clang previous prototype warnings
+
+commit 5bfe62a00d2d659eec9f19b39802b6e69844fc27
+Author: Zachary Waldowski <zach@waldowski.me>
+Date: Thu Jan 9 13:41:27 2014 -0500
+
+ Darwin/AArch64: Inhibit Clang previous prototype warnings
+
+commit fa5f25c20f76a6ef5e950a7ccbce826672c8a620
+Author: Marcus Comstedt <marcus@mc.pp.se>
+Date: Sat Jan 4 19:00:08 2014 +0100
+
+ Linux/ppc64: Remove assumption on contents of r11 in closure
+
+commit 1a0b01e171e9c750437cef2f18917f5a6e32c498
+Author: Paulo Pizarro <paulo.pizarro@gmail.com>
+Date: Thu Jan 2 16:17:59 2014 -0200
+
+ When the function called by the ffi called a function defined in a shared library generate a fatal error
+ The correction was to take into consideration the GOT.
+
+commit 3dc3f32c35db5ab995a835225f6815369735ceb7
+Author: Anthony Green <green@moxielogic.com>
+Date: Thu Dec 5 16:23:25 2013 -0500
+
+ Undo iOS ARM64 changes.
+
+commit 356b2cbc304bfe5bdc28b8d1c68d1ff084e9ec37
+Merge: 484a758 07345a3
+Author: Anthony Green <green@moxielogic.com>
+Date: Sat Nov 30 22:38:13 2013 -0500
+
+ Merge branch 'master' of github.com:/atgreen/libffi
+
+commit 484a7584260e2fbb399ce90083046834271bf9ff
+Author: Anthony Green <green@moxielogic.com>
+Date: Sat Nov 30 21:06:51 2013 -0500
+
+ Mention Aarch64 on iOS
+
+commit 07345a30ec0a2fa45a7c363d301f57723690cfa0
+Author: Anthony Green <green@moxielogic.com>
+Date: Sat Nov 30 21:06:51 2013 -0500
+
+ Mention Aarch64 on iOS
+
+commit d4b931c1b872378c35f12ddbb9a6d55e7f17c65e
+Author: Anthony Green <green@moxielogic.com>
+Date: Sat Nov 30 20:58:31 2013 -0500
+
+ Remove build-ios from Makefile
+
+commit dfbf236d70fc1ec68e6ff193584a154353508e2f
+Merge: 852ac3b bb9740e
+Author: Anthony Green <green@moxielogic.com>
+Date: Sat Nov 30 20:54:54 2013 -0500
+
+ Merge branch 'master' of github.com:/atgreen/libffi
+ Add ChangeLog entry.
+
+commit bb9740e545205f93a525c77aa6d1cbf4ca9371f3
+Merge: ac75368 4d701e0
+Author: Anthony Green <green@moxielogic.com>
+Date: Sat Nov 30 17:54:39 2013 -0800
+
+ Merge pull request #60 from zwaldowski/ios-redo
+
+ Mac/iOS support, including aarch64 port
+
+commit 4d701e03faa475a5eb3b54b90046114a1e27b813
+Author: Zachary Waldowski <zwaldowski@gmail.com>
+Date: Sat Nov 30 13:25:27 2013 -0500
+
+ Darwin: Properly export headers from Xcode project
+
+commit 022f12eb9ad2264e838fa5fb453733f5177888f4
+Author: Zachary Waldowski <zwaldowski@gmail.com>
+Date: Sat Nov 30 12:21:38 2013 -0500
+
+ Darwin: Freshen gen scripts, remove old build-ios.sh
+
+commit e820fe2025d7ad3df7584407946dfaad2af69599
+Author: Zachary Waldowski <zwaldowski@gmail.com>
+Date: Sat Nov 30 12:03:51 2013 -0500
+
+ Darwin/iOS: Include x86_64+aarch64 pieces in library
+
+commit 0278284e470ec91db7cdc15ac3dcd64683305848
+Author: Zachary Waldowski <zwaldowski@gmail.com>
+Date: Sat Nov 30 03:03:37 2013 -0500
+
+ Darwin/aarch64: size_t assumptions
+
+commit 9775446b6441c91cd9059215c106aa3bcf949767
+Author: Zachary Waldowski <zwaldowski@gmail.com>
+Date: Sat Nov 30 02:39:34 2013 -0500
+
+ Darwin/aarch64: Fix “shadows declaration†warnings
+
+commit 4260badc37705d3618e774dfe61184ac709881c1
+Author: Zachary Waldowski <zwaldowski@gmail.com>
+Date: Sat Nov 30 02:08:14 2013 -0500
+
+ Darwin/aarch64: Use Clang cache invalidation builtin
+
+commit 9fa7998d5f9250908cbf12a671479852ebadf9d1
+Author: Zachary Waldowski <zwaldowski@gmail.com>
+Date: Sat Nov 30 02:07:48 2013 -0500
+
+ Darwin/aarch64: Inhibit Xcode warning
+
+commit 0e832048a93830575b0976406444e134e649a4f7
+Author: Zachary Waldowski <zwaldowski@gmail.com>
+Date: Sat Nov 30 02:07:34 2013 -0500
+
+ Darwin/aarch64: double == long double
+
+commit 602dc22d76931092610234cf063f9f1b8dbc1a51
+Author: Zachary Waldowski <zwaldowski@gmail.com>
+Date: Sat Nov 30 02:06:00 2013 -0500
+
+ Darwin/iOS prep script: try and compile for arm64
+
+commit b513dfe79de4725e8a717325a9e3b5b9f69f63dc
+Author: Zachary Waldowski <zwaldowski@gmail.com>
+Date: Sat Nov 30 02:05:22 2013 -0500
+
+ Darwin/aarch64: Restrict .size to ELF like arm32.
+
+commit bc978099bf2812de755c076b67ef9c2547607572
+Author: Zachary Waldowski <zwaldowski@gmail.com>
+Date: Sat Nov 30 02:04:57 2013 -0500
+
+ Darwin/aarch64: Potentially(?) fix compile error
+
+commit d6bb9314467c6e0683156559d23ca341c43fa3c8
+Author: Zachary Waldowski <zwaldowski@gmail.com>
+Date: Sat Nov 30 02:04:22 2013 -0500
+
+ Darwin/aarch64: Use CNAME refs
+
+commit 33c46ce5680eea28d3437c8771ec1d137e226b45
+Author: Zachary Waldowski <zwaldowski@gmail.com>
+Date: Sat Nov 30 04:13:42 2013 -0500
+
+ Darwin/Mac: Fix 64/32 shortening warnings
+
+commit 0612081e6c161d9d820742f995975d35da2adbc2
+Author: Zachary Waldowski <zwaldowski@gmail.com>
+Date: Sat Nov 30 03:03:00 2013 -0500
+
+ Darwin: Misc size_t warnings
+
+commit 6a6247d179ec3859311c2d8775841b884f309f66
+Author: Zachary Waldowski <zwaldowski@gmail.com>
+Date: Sat Nov 30 02:55:48 2013 -0500
+
+ Darwin: Fix dlmalloc warnings due to sizeof(size_t)
+
+commit 4d60d9e1e32de6166ffd63bbe9ce54cf961c78fc
+Author: Zachary Waldowski <zwaldowski@gmail.com>
+Date: Sat Nov 30 04:09:30 2013 -0500
+
+ Darwin: Rebuild Xcode project
+
+commit cb719a5c1c2eb391d6a5f5e02484ba4aa990a51b
+Author: Zachary Waldowski <zwaldowski@gmail.com>
+Date: Sat Nov 30 04:09:18 2013 -0500
+
+ Darwin/iOS: Fix LLVM 3.3 warning re: memcpy.
+
+commit 21bde92c9abb378f9c456a9d95e6f9b99ef8c920
+Author: Zachary Waldowski <zwaldowski@gmail.com>
+Date: Sat Nov 30 03:43:42 2013 -0500
+
+ Darwin: Clean up, modernize generator scripts
+
+commit fd54eab74cef7891e4acaaafb71e783142ecb69e
+Author: Zachary Waldowski <zwaldowski@gmail.com>
+Date: Sat Nov 30 03:38:02 2013 -0500
+
+ Darwin/Mac: Also exclude OS X generated source
+
+commit 953b6f14c655141f9e7d82550a312c3eeb961091
+Author: Zachary Waldowski <zwaldowski@gmail.com>
+Date: Tue Apr 24 11:16:20 2012 -0400
+
+ Darwin/iOS: More unified syntax support w/ Clang.
+
+ Signed-off-by: Zachary Waldowski <zwaldowski@gmail.com>
+
+commit c713a55379481c339877f2e0003d97cb8d9ed80e
+Author: Zachary Waldowski <zwaldowski@gmail.com>
+Date: Tue Apr 24 10:25:29 2012 -0400
+
+ Darwin/iOS: Simplify RETLDM arguments for LLVM 3.1
+
+ Signed-off-by: Zachary Waldowski <zwaldowski@gmail.com>
+
+commit 16ba1b80028db5cb71cf86e5f79f5e48317f83c8
+Author: Zachary Waldowski <zwaldowski@gmail.com>
+Date: Wed Apr 11 23:26:04 2012 -0400
+
+ Darwin: Silence Clang warnings.
+
+commit 852ac3bd302d6ed97b1ef65f4cbed69c258a48df
+Merge: ab79d6e ac75368
+Author: Anthony Green <green@moxielogic.com>
+Date: Thu Nov 21 21:25:44 2013 -0500
+
+ Merge branch 'master' of github.com:/atgreen/libffi
+
+ Conflicts:
+ ChangeLog
+
+commit ab79d6e21992dd86139ba07530ff888833b78a04
+Author: Alan Modra <amodra@gmail.com>
+Date: Thu Nov 21 06:12:35 2013 -0500
+
+ This separates the 32-bit sysv/linux/bsd code from the 64-bit linux
+ code, and makes it possible to link code compiled with different
+ options to those used to compile libffi. For example, a
+ -mlong-double-128 libffi can be used with -mlong-double-64 code.
+
+ Using the return value area as a place to pass parameters wasn't such
+ a good idea, causing a failure of cls_ulonglong.c. I didn't see this
+ when running the mainline gcc libffi testsuite because that version of
+ the test is inferior to the upstreamm libffi test.
+
+ Using NUM_FPR_ARG_REGISTERS rather than NUM_FPR_ARG_REGISTERS64 meant
+ that a parameter save area could be allocated before it was strictly
+ necessary. Wrong but harmless. Found when splitting apart ffi.c
+ into 32-bit and 64-bit support.
+
+commit ac7536889334d4be50709006d7e23536364d7891
+Author: Alan Modra <amodra@gmail.com>
+Date: Thu Nov 21 06:12:35 2013 -0500
+
+ This separates the 32-bit sysv/linux/bsd code from the 64-bit linux
+ code, and makes it possible to link code compiled with different
+ options to those used to compile libffi. For example, a
+ -mlong-double-128 libffi can be used with -mlong-double-64 code.
+
+ Using the return value area as a place to pass parameters wasn't such
+ a good idea, causing a failure of cls_ulonglong.c. I didn't see this
+ when running the mainline gcc libffi testsuite because that version of
+ the test is inferior to the upstreamm libffi test.
+
+ Using NUM_FPR_ARG_REGISTERS rather than NUM_FPR_ARG_REGISTERS64 meant
+ that a parameter save area could be allocated before it was strictly
+ necessary. Wrong but harmless. Found when splitting apart ffi.c
+ into 32-bit and 64-bit support.
+
+commit 69df91cfb4fa6bcb644350a80bff970f27478a6a
+Merge: 2f45082 aa1f62c
+Author: Anthony Green <green@moxielogic.com>
+Date: Mon Nov 18 06:34:04 2013 -0800
+
+ Merge pull request #59 from iains/powerpc-darwin-unwind-fix
+
+ Fix PowerPC Darwin FDE encodings to use pcrel correctly. Modernise the picbase labels.
+
+commit aa1f62c0a093c30325dff1d4d2b6b4b22eb96929
+Author: Iain Sandoe <iain@codesourcery.com>
+Date: Mon Nov 18 13:11:56 2013 +0000
+
+ Fix PowerPC Darwin FDE encodings to use pcrel correctly. Modernise the picbase labels.
+
+commit 2f450822a8698ba88441c56d152c7dc8924b127f
+Author: Anthony Green <green@moxielogic.com>
+Date: Mon Nov 18 06:52:29 2013 -0500
+
+ Clean up code to appease modern GCC compiler.
+
+commit 16d56c51aded374730920a4acde76ff3d2860ae1
+Author: Alan Modra <amodra@gmail.com>
+Date: Mon Nov 18 06:36:03 2013 -0500
+
+ An #endif in the wrong place would cause compile failure on powerpcle.
+ Using bl instead of b doesn't cause runtime failures as you might think,
+ but does mess the processor branch prediction.
+
+commit 34f878a5ef28663f6b1d7fd26fb099429ea1579e
+Merge: 83f65b6 1fd0457
+Author: Anthony Green <green@moxielogic.com>
+Date: Sat Nov 16 06:57:54 2013 -0500
+
+ Merge branch 'master' of github.com:/atgreen/libffi
+
+ Conflicts:
+ ChangeLog
+ src/powerpc/ffi.c
+
+commit 83f65b63d9764a9cc7688fc5cda5ee2bd23faf54
+Author: Alan Modra <amodra@gmail.com>
+Date: Sat Nov 16 06:53:50 2013 -0500
+
+ Finally, this adds _CALL_ELF == 2 support. ELFv1 objects can't be
+ linked with ELFv2 objects, so this is one case where preprocessor
+ tests in ffi.c are fine. Also, there is no need to define a new
+ FFI_ELFv2 or somesuch value in enum ffi_abi. FFI_LINUX64 will happily
+ serve both ABIs.
+
+commit 1fd045784cac874b5d76b7fa931f67209a8280d3
+Author: Alan Modra <amodra@gmail.com>
+Date: Sat Nov 16 06:53:50 2013 -0500
+
+ Finally, this adds _CALL_ELF == 2 support. ELFv1 objects can't be
+ linked with ELFv2 objects, so this is one case where preprocessor
+ tests in ffi.c are fine. Also, there is no need to define a new
+ FFI_ELFv2 or somesuch value in enum ffi_abi. FFI_LINUX64 will happily
+ serve both ABIs.
+
+commit 362851379a49ce07d3e36e82c4e5c7b6cc16a352
+Author: Alan Modra <amodra@gmail.com>
+Date: Sat Nov 16 06:52:43 2013 -0500
+
+ Andreas' 2013-02-08 change reverted some breakage for struct return
+ values from 2011-11-12, but in so doing reintroduced string
+ instructions to sysv.S that are not supported on all powerpc variants.
+ This patch properly copies the bounce buffer to destination in C code
+ rather than in asm.
+
+ I have tested this on powerpc64-linux, powerpc-linux and
+ powerpc-freebsd. Well, the last on powerpc-linux by lying to
+ configure with
+
+ CC="gcc -m32 -msvr4-struct-return -mlong-double-64" \
+ CXX="g++ -m32 -msvr4-struct-return -mlong-double-64" \
+ /src/libffi-current/configure --build=powerpc-freebsd
+
+ and then
+
+ make && make CC="gcc -m32" CXX="g++ -m32" \
+ RUNTESTFLAGS=--target_board=unix/-m32/-msvr4-struct-return/-mlong-double-64\
+ check
+
+commit 1c06515d927d9de1582438d4eb5953890e79c5c7
+Author: Alan Modra <amodra@gmail.com>
+Date: Sat Nov 16 06:41:36 2013 -0500
+
+ The powerpc64 ABIs align structs passed by value, a fact ignored by
+ gcc for quite some time. Since gcc now does the correct alignment,
+ libffi needs to follow suit. This ought to be made selectable via
+ a new abi value, and the #ifdefs removed from ffi.c along with many
+ other #ifdefs present there and in assembly. I'll do that with a
+ followup patch sometime.
+
+ This is a revised version of
+ https://sourceware.org/ml/libffi-discuss/2013/msg00162.html
+
+commit a97cf1fae575d8bfd5259c5c422025ad43911326
+Author: Alan Modra <amodra@gmail.com>
+Date: Sat Nov 16 06:40:13 2013 -0500
+
+ This patch prepares for ELFv2, where sizes of these areas change. It
+ also makes some minor changes to improve code efficiency.
+
+commit 164283f4ac5972ce2ab5e015cc2ab1014c23276c
+Author: Alan Modra <amodra@gmail.com>
+Date: Sat Nov 16 06:38:55 2013 -0500
+
+ The powerpc64 support opted to pass floating point values both in the
+ fpr area and the parameter save area, necessary when the backend
+ doesn't know if a function argument corresponds to the ellipsis
+ arguments of a variadic function. This patch adds powerpc support for
+ variadic functions, and changes the code to only pass fp in the ABI
+ mandated area. ELFv2 needs this change since the parameter save area
+ may not exist there.
+
+ This also fixes two faulty tests that used a non-variadic function
+ cast to call a variadic function, and spuriously reasoned that this is
+ somehow necessary for static functions..
+
+commit 31257b3189f81a199bc2902c22bc5f2d7c54ccde
+Author: Andrew Haley <aph@redhat.com>
+Date: Sat Nov 16 06:35:51 2013 -0500
+
+ Fix sample closure code
+
+commit db0ace3a38496af73eae3df02ef353736d16909f
+Author: Andrew Haley <aph@redhat.com>
+Date: Sat Nov 16 06:29:25 2013 -0500
+
+ Fix broken test cases
+
+commit de10f5039ed7a53382ddcc95c368d03e535edb98
+Merge: 58c2577 f3657da
+Author: Anthony Green <green@moxielogic.com>
+Date: Thu Nov 14 10:56:29 2013 -0500
+
+ Merge branch 'master' of https://github.com/bivab/libffi
+
+ Conflicts:
+ ChangeLog
+
+commit f3657da278dd63afcdd8762894a9bdaea8ef028a
+Author: David Schneider <david.schneider@bivab.de>
+Date: Thu Nov 14 13:02:16 2013 +0100
+
+ update Changelog
+
+commit 58c2577a3ff80e7416ef0434769e2af23365719c
+Author: Alan Modra <amodra@gmail.com>
+Date: Wed Nov 13 16:55:36 2013 -0500
+
+ This enshrines the current testsuite practice of using ffi_arg for
+ returned values. It would be reasonable and logical to use the actual
+ return argument type as passed to ffi_prep_cif, but this would mean
+ changing a large number of tests that use ffi_arg and all backends
+ that write results to an ffi_arg.
+
+commit 8af42f9944f7ed72c81ae360aac6a84dc11f89dc
+Author: Anthony Green <green@moxielogic.com>
+Date: Wed Nov 13 16:40:28 2013 -0500
+
+ Respect HAVE_ALLOCA_H
+
+commit cdf405d574f479b782454516366bd4f4b9b3415e
+Author: David Schneider <david.schneider@bivab.de>
+Date: Wed Nov 13 15:50:21 2013 +0100
+
+ add a testcase for the double/float issue on ARMHF
+
+commit 77f823e31ffb557a466b24f7fba845fbf7831798
+Author: David Schneider <david.schneider@bivab.de>
+Date: Wed Nov 13 14:26:57 2013 +0100
+
+ stop trying to assing vfp regs once we are done with the registers
+
+commit 37067ec5036f2a6ed7a4799f83f8f53160460344
+Author: David Schneider <david.schneider@bivab.de>
+Date: Tue Nov 12 19:49:01 2013 +0100
+
+ mark all vfp registers as used when done.
+
+ To avoid assigning registers the would fit, once arguments have been on
+ the stack, we mark all registers as used once we do not find a free
+ register for the first time.
+
+commit 2f5b7ce545473a7f6e41193edc29407cbebe82d5
+Author: Anthony Green <green@moxielogic.com>
+Date: Sat Nov 9 06:16:32 2013 -0500
+
+ UltraSPARC IIi fix. Update README and build configury.
+
+commit becd754434173032f426d22ffcbfe24f55b3c137
+Author: Mark Kettenis <kettenis@gnu.org>
+Date: Wed Nov 6 06:43:49 2013 -0500
+
+ Align the stack pointer to 16-bytes.
+
+commit 05c31093409f7b3e6d795fac21d2c954313d8162
+Author: Konstantin Belousov <kib@freebsd.org>
+Date: Wed Nov 6 06:40:58 2013 -0500
+
+ Mark executable as not requiring executable stack.
+
+commit cf6bf9818e8394cfcdb07a40c6a5e2ee6b01d333
+Author: Anthony Green <green@moxielogic.com>
+Date: Sat Nov 2 17:23:59 2013 -0400
+
+ Fix up docs
+
+commit 02177176854d16fc0f1a5958aa34da2f306630ee
+Merge: c242217 c265b4c
+Author: Anthony Green <green@moxielogic.com>
+Date: Sat Nov 2 17:11:22 2013 -0400
+
+ Merge branch 'master' of github.com:/atgreen/libffi
+
+commit c2422174b3edc0de0b148dfd6b67087bb881c4a6
+Merge: f4b843f d918d47
+Author: Anthony Green <green@moxielogic.com>
+Date: Sat Nov 2 14:08:23 2013 -0700
+
+ Merge pull request #45 from foss-for-synopsys-dwc-arc-processors/arc_support
+
+ arc: Fix build error
+
+commit c265b4cacb9130f042699a85de9c7242b3f49cc3
+Merge: f4b843f d918d47
+Author: Anthony Green <green@moxielogic.com>
+Date: Sat Nov 2 14:08:23 2013 -0700
+
+ Merge pull request #45 from foss-for-synopsys-dwc-arc-processors/arc_support
+
+ arc: Fix build error
+
+commit f4b843f83710ac378c48abd87fe66bb519d30d2e
+Author: Anthony Green <green@moxielogic.com>
+Date: Sat Nov 2 17:01:15 2013 -0400
+
+ Don't align stack for win32
+
+commit f3cd39345713db8e414cf642b6cb65a4cfe6018c
+Merge: 666f3e7 6aa1590
+Author: Anthony Green <green@moxielogic.com>
+Date: Sat Nov 2 13:17:57 2013 -0700
+
+ Merge pull request #51 from vbudovski/for_upstream
+
+ Don't use 16 byte aligned stack for WIN32
+
+commit 666f3e71b56d92c49fcd2d7f349b8f8ebca0f8a3
+Author: Anthony Green <green@moxielogic.com>
+Date: Sat Oct 26 09:12:42 2013 -0400
+
+ Add more credits to README. Tidy up.
+
+commit 73ada14e756bad97fad0e6915a821a3c7e079f81
+Author: Anthony Green <green@moxielogic.com>
+Date: Sat Oct 26 09:09:45 2013 -0400
+
+ Update README
+
+commit d3372c54ce7117e80d389ba875dc5b6b2213c71e
+Author: Mark H Weaver <mhw@netris.org>
+Date: Sat Oct 26 08:30:06 2013 -0400
+
+ Fix N32 ABI issue for MIPS.
+
+commit d6716aba8118eb0513885cfe557bedebb7016e8b
+Author: Anthony Green <green@moxielogic.com>
+Date: Tue Oct 15 15:42:49 2013 -0400
+
+ Update travis-ci build dependencies to include texinfo
+
+commit 16b93a211bcfbe4bd0efdcf94de225a71aa0ee02
+Author: Sandra Loosemore <sandra@codesourcery.com>
+Date: Tue Oct 15 15:33:59 2013 -0400
+
+ Add nios2 port.
+
+commit 2f5626ce02fce8267ab48ceb6d7d0ed7d672a75e
+Author: Sandra Loosemore <sandra@codesourcery.com>
+Date: Tue Oct 15 15:32:16 2013 -0400
+
+ Fix testsuite bug
+
+commit f64e4a865557e440774436b4c2b2fd7374290e97
+Author: Marcus Shawcroft <marcus.shawcroft@arm.com>
+Date: Tue Oct 15 15:20:14 2013 -0400
+
+ Fix many.c testcase for Aarch64
+
+commit 128cd1d2f358f26d9fa75a27cf2b30356f5dd903
+Author: Anthony Green <green@moxielogic.com>
+Date: Tue Oct 8 06:45:51 2013 -0400
+
+ Fix spelling errors
+
+commit ff06269d707cafbfef2a88afb07a79c9d1480c5f
+Author: Anthony Green <green@moxielogic.com>
+Date: Tue Oct 8 06:32:18 2013 -0400
+
+ Update README for M88K and VAX
+
+commit d2fcbcdfbea750d1f6a9f493e2e6c4d5ffa71b34
+Author: Anthony Green <green@moxielogic.com>
+Date: Tue Oct 8 06:27:46 2013 -0400
+
+ Add m88k and VAX support. Update some configury bits.
+
+commit 6aa15900accc0a648cdebf11ec11d11697ebfffd
+Author: Vitaly Budovski <vbudovski@gmail.com>
+Date: Thu Sep 5 12:05:06 2013 +1000
+
+ Don't use 16 byte aligned stack for WIN32
+
+ This fixes a crash when accessing __stdcall functions in Python ctypes.
+
+commit 3b44d41156149af8da2a58825fefdfa23274ae7a
+Author: Makoto Kato <m_kato@ga2.so-net.ne.jp>
+Date: Wed Jul 10 15:34:53 2013 +0900
+
+ Fix build failure when using clang for Android
+
+ clang for Android generates __gnu_linux__ define, but gcc for Android doesn't. So we should add check it for Android
+
+commit d918d47809c174d62283306b282749f8db93661f
+Author: Mischa Jonker <mjonker@synopsys.com>
+Date: Mon Jul 8 15:51:36 2013 +0200
+
+ arc: Fix build error
+
+ One part of the patch for ARC support was missing in the upstreamed
+ version.
+
+ Signed-off-by: Mischa Jonker <mjonker@synopsys.com>
+
+commit d3d099b40c122550279789200263346f120f6909
+Author: Anthony Green <green@moxielogic.com>
+Date: Tue Jul 2 16:11:38 2013 -0400
+
+ little-endian ppc64 support
+
+commit 0f8690a84c874ec09a090c8c6adfb93c594acac6
+Author: Anthony Green <green@moxielogic.com>
+Date: Tue Jul 2 15:54:40 2013 -0400
+
+ Rebuild for ARC additions
+
+commit f88118b345f27c46f5445d6e4832c498ff9a6d85
+Author: Anthony Green <green@moxielogic.com>
+Date: Tue Jul 2 15:51:27 2013 -0400
+
+ Revert "Merge pull request #36 from abergmeier/emscripten_fix"
+
+ This reverts commit 6a4d901dde7b3f87984c563505717cde3113d16e, reversing
+ changes made to b50a13b9c07ec09af4b9697e482acdad571e6961.
+
+commit 6a4d901dde7b3f87984c563505717cde3113d16e
+Merge: b50a13b 587002c
+Author: Anthony Green <green@moxielogic.com>
+Date: Tue Jul 2 12:12:34 2013 -0700
+
+ Merge pull request #36 from abergmeier/emscripten_fix
+
+ Fixes for building with Emscripten
+
+commit b50a13b9c07ec09af4b9697e482acdad571e6961
+Merge: 767f1f9 b082e15
+Author: Anthony Green <green@moxielogic.com>
+Date: Tue Jul 2 12:10:26 2013 -0700
+
+ Merge pull request #44 from foss-for-synopsys-dwc-arc-processors/arc_support
+
+ Add ARC support
+
+commit 767f1f96e5282da44d7340e6815e9820a3f78e39
+Merge: c3c40e0 b8a91d8
+Author: Anthony Green <green@moxielogic.com>
+Date: Tue Jul 2 12:08:04 2013 -0700
+
+ Merge pull request #43 from JensTimmerman/__m128
+
+ added include for xmmintrin.h
+
+commit b8a91d81be77d479327fdb6bdd9fdae6d18e6e63
+Author: Jens Timmerman <jens.timmerman@ugent.be>
+Date: Tue Jul 2 10:57:37 2013 +0200
+
+ added include for xmmintrin.h
+
+commit b082e15091961373c03d10ed0251f619ebb6ed76
+Author: Mischa Jonker <mjonker@synopsys.com>
+Date: Mon Jun 10 16:19:33 2013 +0200
+
+ Add ARC support
+
+ This adds support for the ARC architecture to libffi. DesignWare ARC
+ is a family of processors from Synopsys, Inc.
+
+ This patch has been tested on a little-endian system and passes
+ the testsuite.
+
+ Signed-off-by: Mischa Jonker <mjonker@synopsys.com>
+
+commit cc9b518687e46b0d1acafdd4bc3f3b281c25a3d9
+Author: Marcin Wojdyr <wojdyr@gmail.com>
+Date: Tue May 14 15:01:23 2013 +0200
+
+ Update libffi.pc.in
+
+ use -L${toolexeclibdir} instead of -L${libdir}
+ to be consistent with Makefile.am
+
+commit 587002c092cffe6e7a8d7028f246c241d03b738c
+Author: Andreas Bergmeier <andreas.bergmeier@gmx.net>
+Date: Fri Apr 19 17:12:24 2013 +0200
+
+ Enable disabling of libtool on platforms where it does not work (e.g. LLVM).
+ Build libraries normally then.
+
+commit c3c40e0290377d7cf948b072eedd8317c4bf215e
+Merge: ede96e4 4750e3c
+Author: Anthony Green <green@moxielogic.com>
+Date: Sat Mar 30 05:24:14 2013 -0700
+
+ Merge pull request #34 from davidsch/armhf
+
+ Fix ARM hard-float support for large numbers of VFP arguments
+
+commit 4750e3c662fd9569cb3e2d28f539685fd1ca8caf
+Author: David Schneider <david.schneider@bivab.de>
+Date: Thu Mar 28 16:56:36 2013 +0100
+
+ update changelog
+
+commit 9708e7cf09f1bf815f4d6485eb1f180fabb35804
+Author: David Schneider <david.schneider@bivab.de>
+Date: Wed Mar 27 19:31:04 2013 +0100
+
+ folow the ARM hard-float ABI in ffi_prep_incoming_args_VFP
+
+commit b41120981e5e49ca2da10b94b154775f50da5f36
+Author: David Schneider <david.schneider@bivab.de>
+Date: Wed Mar 27 16:38:35 2013 +0100
+
+ create separated versions of ffi_prep_incoming_args_* for SYSV and VFP ABIs.
+
+ The different versions will be called depending on the value of cif->abi
+
+commit dd26f1f39c54861c5b91931f0f37a72942c2a072
+Author: David Schneider <david.schneider@bivab.de>
+Date: Thu Mar 28 15:39:01 2013 +0100
+
+ add a failing test for closures on ARM hardfloat
+
+commit 3c1608613ab3c2184222b98c5482cddedd6b559b
+Author: David Schneider <david.schneider@bivab.de>
+Date: Tue Mar 26 19:24:47 2013 +0100
+
+ extend ffi_prepare_args for FFI_VFP (hard-float ABI), fixing an issue with passing VFP arguments in VFP registers and the stack, while at the same time not using all core registers.
+
+commit 0f2ff2d4c92719be8936179f9ab674f4d1a3fd14
+Author: David Schneider <david.schneider@bivab.de>
+Date: Tue Mar 26 19:22:02 2013 +0100
+
+ separate ARM ffi_prepare_args in a version implementing the simple SYSV calling convention and one for the hard-float calling convention
+
+commit 3a352b8a8252400a83de22c7c424bf1887b4a2ef
+Author: David Schneider <david.schneider@bivab.de>
+Date: Tue Mar 26 14:24:04 2013 +0100
+
+ move the hardfloat specific argument copying code to the helper function
+
+commit 5df6b7944a4225b6eb329f3886be64e04e966f29
+Author: David Schneider <david.schneider@bivab.de>
+Date: Tue Mar 26 14:02:21 2013 +0100
+
+ extract setting of arguments to be passed to a helper function
+
+commit 7d1048c471bb4b1f9d67a9e9f8e95f9a1d2e6d45
+Author: David Schneider <david.schneider@bivab.de>
+Date: Tue Mar 26 11:33:33 2013 +0100
+
+ extract code to align the argument storage pointer to a helper function
+
+commit b9f013788f0f384c423ad963475aaacb55598135
+Author: David Schneider <david.schneider@bivab.de>
+Date: Mon Mar 25 13:27:36 2013 +0100
+
+ add a testcase, that on ARM hardfloat needs more than the 8 VFP argument registers to pass arguments to a call
+
+commit 2fbdb0f231cafdb77b025d3cd8afe90cda99b3ba
+Author: David Schneider <david.schneider@bivab.de>
+Date: Mon Mar 25 13:26:02 2013 +0100
+
+ use the absolute value to check the test result against an epsilon
+
+commit ede96e4eb660bbf3e0fe048135efa8106f48af5d
+Merge: f22ab3c 9e34992
+Author: Anthony Green <green@moxielogic.com>
+Date: Sun Mar 17 18:38:21 2013 -0400
+
+ Merge branch 'master' of github.com:/atgreen/libffi
+
+commit f22ab3c6877cbdd07f058b68816b0086b1cb0e1e
+Merge: 12b1886 d08124b
+Author: Anthony Green <green@moxielogic.com>
+Date: Sun Mar 17 18:34:54 2013 -0400
+
+ Merge branch 'master' of github.com:/atgreen/libffi
+
+commit 9e34992a5ea2fda1dba5875bf96dc91a7230f51f
+Merge: 12b1886 d08124b
+Author: Anthony Green <green@moxielogic.com>
+Date: Sun Mar 17 18:34:54 2013 -0400
+
+ Merge branch 'master' of github.com:/atgreen/libffi
+
+commit 12b1886d7b1f8aa264b1d348bfa47a0e14712df4
+Author: Anthony Green <green@moxielogic.com>
+Date: Sun Mar 17 18:32:12 2013 -0400
+
+ cygwin fix & updates for 3.0.13
+
+commit d08124bedf2c6d61874fe215404783aeb9f6f1ac
+Author: Anthony Green <green@moxielogic.com>
+Date: Sun Mar 17 18:32:12 2013 -0400
+
+ cygwin fix & updates for 3.0.13
+
+commit cb32c812d04d1dfa72002cc04924e7e4fef89e02
+Author: Anthony Green <green@moxielogic.com>
+Date: Sun Mar 17 09:27:55 2013 -0400
+
+ Fix lib install dir
+
+commit efd7866a361a6f636bae8400d26c6811e56ca207
+Author: Anthony Green <green@moxielogic.com>
+Date: Sat Mar 16 08:35:57 2013 -0400
+
+ 2.0.13rc1
+
+commit ff647ad4dff2f07dd153f295a1f70b1d906cd6ca
+Merge: 4acf005 d9dd417
+Author: Anthony Green <green@moxielogic.com>
+Date: Sat Mar 16 08:20:40 2013 -0400
+
+ Merge branch 'master' of github.com:/atgreen/libffi
+
+ Conflicts:
+ ChangeLog
+
+commit 4acf0056f55c757490dae6c29a65b0321327ea8a
+Author: Anthony Green <green@moxielogic.com>
+Date: Sat Mar 16 08:18:45 2013 -0400
+
+ Build fix for soft-float power targets
+
+commit 675c9839224e4268187f1ec6f512127f9db555d0
+Author: Anthony Green <green@moxielogic.com>
+Date: Sat Mar 16 08:12:38 2013 -0400
+
+ Documentation fix
+
+commit 8a286f570ccd41db81f74ea7f248da62241d898a
+Author: Anthony Green <green@moxielogic.com>
+Date: Sat Mar 16 08:01:19 2013 -0400
+
+ Fix for m68000 systems
+
+commit d9dd417b09566af55b7b3000bb53ccaf2e1d6c92
+Author: Anthony Green <green@moxielogic.com>
+Date: Sat Mar 16 08:01:19 2013 -0400
+
+ Fix for m68000 systems
+
+commit 215763d012a944d95406b394d6013b80d220e870
+Author: Anthony Green <green@moxielogic.com>
+Date: Sat Mar 16 07:57:35 2013 -0400
+
+ Update configury.
+
+commit 9180d8f39c9b6afe17b78277c2711a5d9948e824
+Merge: 2fb527a 7e1b326
+Author: Anthony Green <green@moxielogic.com>
+Date: Sat Mar 16 07:46:55 2013 -0400
+
+ Merge branch 'master' of github.com:/atgreen/libffi
+
+commit 2fb527a017a4943e176a489ff103231b86464b59
+Author: Anthony Green <green@moxielogic.com>
+Date: Sat Mar 16 07:46:38 2013 -0400
+
+ Add Meta processor support
+
+commit 211a9ebf4d1a9801e15e103566aed2b8c42790be
+Merge: f308faf ee18766
+Author: Anthony Green <green@moxielogic.com>
+Date: Sat Mar 16 04:24:40 2013 -0700
+
+ Merge pull request #32 from alex/patch-1
+
+ Fix for a crasher due to misaligned stack on x86-32.
+
+commit 7e1b32649efd24814e86172e196f390566f9e970
+Merge: f308faf ee18766
+Author: Anthony Green <green@moxielogic.com>
+Date: Sat Mar 16 04:24:40 2013 -0700
+
+ Merge pull request #32 from alex/patch-1
+
+ Fix for a crasher due to misaligned stack on x86-32.
+
+commit ee18766b169811426c14b011fbb46d81e344f926
+Author: Alex Gaynor <alex.gaynor@gmail.com>
+Date: Thu Mar 14 15:00:33 2013 -0700
+
+ Fix for a crasher due to misaligned stack on x86-32.
+
+ Full information on reproduction (using Python's ctypes available here: http://bugs.python.org/issue17423)
+
+commit f308faf1eabaf8dc24966ab17fbf94368f46b9c7
+Author: Anthony Green <green@moxielogic.com>
+Date: Mon Feb 11 14:25:13 2013 -0500
+
+ Add moxie support. Release 3.0.12.
+
+commit 4ea22e54e3b143fe05c413f6dddd236af6bcbfb2
+Author: Anthony Green <green@moxielogic.com>
+Date: Sun Feb 10 08:48:38 2013 -0500
+
+ Update README
+
+commit 10e77227b6ae85f46f28590bfb09ca3608554358
+Author: Anthony Green <green@moxielogic.com>
+Date: Sun Feb 10 08:47:26 2013 -0500
+
+ mend
+
+commit a9521411a53d58f2bf88199242200ceb0d4dae3a
+Author: Anthony Green <green@moxielogic.com>
+Date: Sat Feb 9 06:54:40 2013 -0500
+
+ sparc v8 and testsuite fixes
+
+commit 70b11b47eea93bf43627588d494d0b3b0d062481
+Author: Anthony Green <green@moxielogic.com>
+Date: Fri Feb 8 16:12:19 2013 -0500
+
+ Fix small struct passing on ppc
+
+commit 63ba1fa79f7c4ce42de848debe233aab31aecb51
+Author: Anthony Green <green@moxielogic.com>
+Date: Fri Feb 8 15:18:19 2013 -0500
+
+ Remove xfail for arm*-*-*.
+
+commit 24fbca4c1d57d4ea628c0a8ba643684daf54a37e
+Author: Anthony Green <green@moxielogic.com>
+Date: Fri Feb 8 14:19:56 2013 -0500
+
+ Fix typo
+
+commit b0fa11cb0a94ce6baca058eab9b10e40475e71d6
+Author: Anthony Green <green@moxielogic.com>
+Date: Fri Feb 8 14:17:13 2013 -0500
+
+ More man page cleanup
+
+commit 8bd15d139a58a6e46dc90a1cb2d89f59f32f06c7
+Author: Anthony Green <green@moxielogic.com>
+Date: Fri Feb 8 13:56:37 2013 -0500
+
+ Fix many.c testcase for ppc
+
+commit 7aab825cf198be85490d3cd80e778d415d85ad9b
+Author: Anthony Green <green@moxielogic.com>
+Date: Fri Feb 8 13:26:21 2013 -0500
+
+ Add missing files to dist
+
+commit cb03ea8f4eb08024e44abe4392edc77b89fbfbad
+Author: Anthony Green <green@moxielogic.com>
+Date: Fri Feb 8 12:25:18 2013 -0500
+
+ sparc v9 fixes for sun tools
+
+commit 35ee8d44f31dd3d3b88083c837dc351593e13cc2
+Author: Anthony Green <green@moxielogic.com>
+Date: Fri Feb 8 07:12:41 2013 -0500
+
+ Fix microblaze big-endian struct issue
+
+commit 9db7e1a958fc484ba149efe027008b9a170395fb
+Author: Anthony Green <green@moxielogic.com>
+Date: Thu Feb 7 21:06:08 2013 -0500
+
+ Fix botched sparc patch. Update version.
+
+commit ce0138e61455f268af326e26908b9680ec2c4bea
+Author: Anthony Green <green@moxielogic.com>
+Date: Thu Feb 7 18:04:01 2013 -0500
+
+ Update bug report address. rc2.
+
+commit fd07c9e40451e0ec1d0475cd54a83d45ccaea2c0
+Author: Anthony Green <green@moxielogic.com>
+Date: Thu Feb 7 18:00:36 2013 -0500
+
+ Add cache flushing routine for sun compiler on sparc solaris 2.8
+
+commit ed6ae9501b2bab45daf93b4935eb0c977635b763
+Author: Anthony Green <green@moxielogic.com>
+Date: Thu Feb 7 16:43:36 2013 -0500
+
+ Add libtool-ldflags. Define toolexeclibdir for non-GCC builds.
+
+commit ffef2e046aaec853be356f0b8770a335185ea9cf
+Author: Anthony Green <green@moxielogic.com>
+Date: Thu Feb 7 15:47:01 2013 -0500
+
+ x32 and libtool fixes
+
+commit 95eecebb2858dc6f1495a61072ff36d0a8127144
+Author: Anthony Green <green@moxielogic.com>
+Date: Thu Feb 7 15:32:46 2013 -0500
+
+ Remove a.out cruft from dist
+
+commit 176aa9d2e23d9cd57d6f250692d910b408f9a651
+Author: Anthony Green <green@moxielogic.com>
+Date: Thu Feb 7 15:29:22 2013 -0500
+
+ Fix GCC usage test and update README
+
+commit f3a4f3fdde89b04d66983a42a25d09161c5d4d54
+Author: Anthony Green <green@moxielogic.com>
+Date: Thu Feb 7 09:57:20 2013 -0500
+
+ Fixes for AIX xlc compiler.
+
+commit 522f8fef49848927482bc63c94afaea5b84e5ec1
+Author: Anthony Green <green@moxielogic.com>
+Date: Wed Feb 6 20:31:31 2013 -0500
+
+ Fix man page. Clean out junk.
+
+commit c4dfa259eb4e8e6f4c397868d7fee80aa0bb6a12
+Author: Anthony Green <green@moxielogic.com>
+Date: Wed Feb 6 17:43:24 2013 -0500
+
+ Bump soversion
+
+commit f62bd63fe6123cadedb8b2b2c72eb549c40fbce9
+Author: Anthony Green <green@moxielogic.com>
+Date: Wed Feb 6 17:38:32 2013 -0500
+
+ Release candidate 1
+
+commit f7cd61e9e68a4a51147df04d75bfe5b91b9d9286
+Author: Anthony Green <green@moxielogic.com>
+Date: Wed Feb 6 17:38:04 2013 -0500
+
+ Fix pkgconfig install bits
+
+commit 6a790129427121f7db2d876e7218a3104e6d2741
+Author: Anthony Green <green@moxielogic.com>
+Date: Wed Feb 6 17:37:15 2013 -0500
+
+ Work around LLVM ABI problem on x86-64
+
+commit 370112938e705128fd5dd4017fc1a1210bd0271a
+Merge: bada2e3 bcc0c28
+Author: Anthony Green <green@moxielogic.com>
+Date: Sun Jan 27 05:09:04 2013 -0800
+
+ Merge pull request #28 from jralls/master
+
+ Reorder x86_64 checks
+
+commit bcc0c28001b6d427d5cd8037d2e3c892babc6b4c
+Author: John Ralls <jralls@ceridwen.us>
+Date: Sat Jan 26 15:21:14 2013 -0800
+
+ Reorder x86_64 tests
+
+ So that darwin and cygwin/mingw are tested before the generic check --
+ which allows them to actually be set.
+
+commit bada2e326d9a9acf3ae40cfa4f5d7a9ba97b2ea8
+Author: Anthony Green <green@moxielogic.com>
+Date: Mon Jan 21 08:02:07 2013 -0500
+
+ Update README
+
+commit 655bb8f3690feba8e840a5f1854b1d78ed08f692
+Merge: 1035ffb 840f975
+Author: Anthony Green <green@moxielogic.com>
+Date: Mon Jan 21 08:01:24 2013 -0500
+
+ Merge branch 'master' of github.com:/atgreen/libffi
+
+commit 1035ffb2f468e1a1c401d58cff7e7abb69838e68
+Merge: aeb8719 4086024
+Author: Anthony Green <green@moxielogic.com>
+Date: Mon Jan 21 07:55:53 2013 -0500
+
+ Update README
+
+commit 840f975866052fdd91b2c224d56e01ae5900b60d
+Merge: aeb8719 4086024
+Author: Anthony Green <green@moxielogic.com>
+Date: Mon Jan 21 07:55:53 2013 -0500
+
+ Merge branch 'master' of github.com:/atgreen/libffi
+
+commit aeb8719a34756969970603fca4568530d56708af
+Author: Anthony Green <green@moxielogic.com>
+Date: Mon Jan 21 07:37:30 2013 -0500
+
+ New microblaze support
+
+commit 40860245a4fd91a1b88adc9171ec993c549e45d5
+Author: Anthony Green <green@moxielogic.com>
+Date: Mon Jan 21 07:37:30 2013 -0500
+
+ New microblaze support
+
+commit 20cae32b152b43679ae65a85db9a1c6bb8a143dd
+Author: Anthony Green <green@moxielogic.com>
+Date: Mon Jan 21 07:07:38 2013 -0500
+
+ Xtensa support
+
+commit 9742f91782faef4a15941508a22c408fb7d1d227
+Author: Anthony Green <green@moxielogic.com>
+Date: Mon Jan 21 07:03:41 2013 -0500
+
+ Mention IBM XL compiler support on AIX.
+
+commit f03eab08248f122ce3b623a18df9e19fae1b6e98
+Author: Anthony Green <green@moxielogic.com>
+Date: Fri Jan 11 17:14:11 2013 -0500
+
+ Remove obsolete inline test functions
+
+commit 05fbe1faedc7b2580d5f14010d00e9e3cee73951
+Author: Anthony Green <green@moxielogic.com>
+Date: Fri Jan 11 16:54:40 2013 -0500
+
+ xlc compiler support
+
+commit 0b4986a7889ed1864674192228f1162c1b5770a8
+Author: Anthony Green <green@moxielogic.com>
+Date: Fri Jan 11 11:19:52 2013 -0500
+
+ [travis] install dejagnu with sudo
+
+commit 3c337eef51ab9a4993fc875bfa26289dd6a08881
+Author: Anthony Green <green@moxielogic.com>
+Date: Fri Jan 11 11:18:14 2013 -0500
+
+ [travis] install dejagnu
+
+commit 90720962ce1baf9fc35d1bde1738102bcd5bd5ed
+Author: Anthony Green <green@moxielogic.com>
+Date: Fri Jan 11 10:57:30 2013 -0500
+
+ Add first travis config file
+
+commit bff052d9cd5be41ba9e47c76114054af487d3c30
+Author: Anthony Green <green@moxielogic.com>
+Date: Fri Jan 11 10:24:32 2013 -0500
+
+ 32-bit x86 fix and more
+
+commit cd41aeab6176f839167955c016ecc19f65f75df3
+Author: Anthony Green <green@moxielogic.com>
+Date: Thu Jan 10 17:25:45 2013 -0500
+
+ Add compiler column to table
+
+commit 8bf987d4df7c4d21435b9211f6cc86abf5904b42
+Author: Anthony Green <green@moxielogic.com>
+Date: Thu Jan 10 17:24:51 2013 -0500
+
+ Fix for sunpro compiler on Solaris
+
+commit 3ee74fd6dc8ccd32b608bbff73526838fc34f70b
+Author: Anthony Green <green@moxielogic.com>
+Date: Thu Jan 10 17:15:03 2013 -0500
+
+ Update documentation version.
+
+commit 13e2d7b92557a9511a0414df82bf2df3edc55cba
+Author: Anthony Green <green@moxielogic.com>
+Date: Thu Jan 10 10:52:02 2013 -0500
+
+ Handle both 32 and 64-bit x86 builds regardless of target triple
+
+commit 5141543000fc86a3d49a907a2313713ee79e504d
+Author: Anthony Green <green@moxielogic.com>
+Date: Thu Jan 10 07:35:53 2013 -0500
+
+ Don't run EH tests with non-GNU compiler
+
+commit 56ba8d86f47937a0afb81a2b9e77c9d235d9db45
+Author: Anthony Green <green@moxielogic.com>
+Date: Thu Jan 10 07:25:10 2013 -0500
+
+ Don't use warning checking macro with sun compiler
+
+commit 6a028caec1b2c7904feb4c4f9cb7e1125e1d1b60
+Author: Anthony Green <green@moxielogic.com>
+Date: Thu Jan 10 01:19:43 2013 -0500
+
+ Don't use GCCisms to define types when
+ + building with the SUNPRO compiler.
+
+commit 2d9b3939751b3ef9739049509d353ade10b32a8f
+Author: Anthony Green <green@moxielogic.com>
+Date: Wed Jan 9 21:14:54 2013 -0500
+
+ Fix for closures with sunpro compiler
+
+commit 8308984e479e3274a36e98e8272b5adbb6b774c2
+Author: Anthony Green <green@moxielogic.com>
+Date: Tue Jan 8 15:14:21 2013 -0500
+
+ Make sure we're running dejagnu tests with the right compiler.
+
+commit f26c7ca67147450db2fe25ea932944e6cf145d5c
+Author: Anthony Green <green@moxielogic.com>
+Date: Tue Jan 8 14:47:05 2013 -0500
+
+ Make compiler options in dejagnu runs compiler specific
+
+commit 74c776e21907fc2e59257c021f23077f8b7966cb
+Author: Anthony Green <green@moxielogic.com>
+Date: Tue Jan 8 12:25:54 2013 -0500
+
+ Switch x86 Solaris to X86 from X86_64
+
+commit 8962c8c8d06803e310bac0ffc8e84ea15daeff3f
+Author: Anthony Green <green@moxielogic.com>
+Date: Tue Jan 8 12:22:24 2013 -0500
+
+ Fix read-only eh_frame test
+
+commit 35ddb69c2b49746d940e919ca226ecc1be94f14a
+Author: Anthony Green <green@moxielogic.com>
+Date: Tue Jan 8 07:53:37 2013 -0500
+
+ Only emit DWARF unwind info when building with GCC
+
+commit f7879bc3f3a8d0bbfcc38771732c160a58ba9cd8
+Author: Anthony Green <green@moxielogic.com>
+Date: Tue Jan 8 07:30:28 2013 -0500
+
+ Testsuite fix for Solaris vendor compiler
+
+commit 67cea90fc0897021466fd102671019d30db474cd
+Author: Anthony Green <green@moxielogic.com>
+Date: Mon Jan 7 06:30:24 2013 -0500
+
+ mend
+
+commit 0de3277b18cf54be3b81d509b9be9b47d9bc1e82
+Author: Thorsten Glaser <tg@mirbsd.de>
+Date: Mon Dec 3 00:02:31 2012 +0000
+
+ Testsuite fixes (was Re: [PATCH] Fix libffi on m68k-linux-gnu, completely)
+
+ Dixi quod…
+
+ >although I believe some 3.0.11 checks to be broken:
+
+ And indeed, with a few minor changes on top of git master,
+ I still get a full run of PASS plus one XPASS on amd64-linux!
+
+ With the other patches (from this message’s parent) and
+ these applied, I get a full PASS on m68k-linux as well.
+
+ So, please git am these three diffs ☺
+
+ bye,
+ //mirabilos
+ --
+ FWIW, I'm quite impressed with mksh interactively. I thought it was much
+ *much* more bare bones. But it turns out it beats the living hell out of
+ ksh93 in that respect. I'd even consider it for my daily use if I hadn't
+ wasted half my life on my zsh setup. :-) -- Frank Terbeck in #!/bin/mksh
+ From 5cb15a3bad1f0fb360520dd48bfc938c821cdcca Mon Sep 17 00:00:00 2001
+ From: Thorsten Glaser <tg@mirbsd.org>
+ Date: Sun, 2 Dec 2012 23:20:56 +0000
+ Subject: [PATCH 1/2] Fix tests writing to a closure retval via pointer casts
+
+ As explained in <Pine.BSM.4.64L.1212022014490.23442@herc.mirbsd.org>
+ all other tests that do the same cast to an ffi_arg pointer instead.
+
+ PASS on amd64-linux (Xen domU) and m68k-linux (ARAnyM)
+
+ Signed-off-by: Thorsten Glaser <tg@mirbsd.org>
+
+commit 8f4772f383abd71cfa141c8a70ba11c1aa4ebe2c
+Author: Anthony Green <green@moxielogic.com>
+Date: Mon Jan 7 06:14:53 2013 -0500
+
+ m68k fixes for signed 8 and 16-bit calls.
+
+commit ea7f8440d58afbebb181e295ff564fdf3d6590a0
+Author: Anthony Green <green@moxielogic.com>
+Date: Fri Jan 4 09:09:32 2013 -0500
+
+ remove gcc-ism
+
+commit f06c0f10377ac04eeba5e632dbe5c62c629df4e6
+Author: Anthony Green <green@moxielogic.com>
+Date: Wed Jan 2 09:39:17 2013 -0500
+
+ Add missing ChangeLog entry and generated files.
+
+commit 1f8675d4c101d19d67ca0a55ff2ba973349558ad
+Merge: 335f419 f6b58d2
+Author: Anthony Green <green@moxielogic.com>
+Date: Wed Jan 2 06:34:38 2013 -0800
+
+ Merge pull request #26 from rofl0r/master
+
+ fix build error on ppc when long double == double
+
+commit 335f419a86090cda9f215d149572f9481c3ad034
+Merge: 53236d5 6d6f711
+Author: Anthony Green <green@moxielogic.com>
+Date: Wed Jan 2 06:30:03 2013 -0800
+
+ Merge pull request #23 from rurban/master
+
+ cygwin/mingw shared libs need libtool LDFLAGS = -no-undefined
+
+commit 53236d5061034cc0a7f4647fc1bd05ba1aeb3d2a
+Author: Anthony Green <green@moxielogic.com>
+Date: Wed Jan 2 09:24:55 2013 -0500
+
+ Regenerate files
+
+commit 72222ca3fbe560e13c8dc89ca441b28b7cc74daf
+Author: Anthony Green <green@moxielogic.com>
+Date: Wed Jan 2 09:06:38 2013 -0500
+
+ Update texinfo.tex
+
+commit 1e326c95431fc9896422fa36659f3e833852579c
+Author: Anthony Green <green@moxielogic.com>
+Date: Wed Jan 2 09:05:02 2013 -0500
+
+ Update config.guess and config.sub
+
+commit cb6671f5b8a9596ff968c6b6c304f70adf71b368
+Author: Anthony Green <green@moxielogic.com>
+Date: Wed Jan 2 08:56:07 2013 -0500
+
+ Missing .gitignore changes for xcode support
+
+commit ebbe77966855395a2a47ed2c09a38f93eb0481cf
+Author: Anthony Green <green@moxielogic.com>
+Date: Wed Jan 2 08:54:05 2013 -0500
+
+ missed x32 libtool patch.
+
+commit 4394096da0aca0dd422b479a043c18b4f05c5770
+Author: Anthony Green <green@moxielogic.com>
+Date: Wed Jan 2 08:51:35 2013 -0500
+
+ missed trampoline_table patch. Move to GCC.
+
+commit ed7a59c3ff7c84bd95c374a5aff21599f705e6dc
+Author: Anthony Green <green@moxielogic.com>
+Date: Wed Jan 2 08:48:01 2013 -0500
+
+ Windows symbol export fix. Move to GCC.
+
+commit ccee09a4ff843b11c7d8b6819776f57d187305c7
+Author: Anthony Green <green@moxielogic.com>
+Date: Wed Jan 2 08:41:55 2013 -0500
+
+ +2012-03-21 Peter Rosin <peda@lysator.liu.se>
+ +
+ + * testsuite/lib/target-libpath.exp [*-*-cygwin*, *-*-mingw*]
+ + (set_ld_library_path_env_vars): Add the library search dir to PATH
+ + (and save PATH for later).
+ + (restore_ld_library_path_env_vars): Restore PATH.
+
+commit 089dbce7cc0889eb26444d89ae062c73c69f26f0
+Author: Anthony Green <green@moxielogic.com>
+Date: Wed Jan 2 08:37:35 2013 -0500
+
+ med
+
+commit 980a334c42b4b0eff32e55929ec6727d1326b05d
+Author: Anthony Green <green@moxielogic.com>
+Date: Wed Jan 2 07:36:42 2013 -0500
+
+ Test GCC update
+
+commit 8bad679ade5000e57cdc9cacde22e8b99840930f
+Author: Anthony Green <green@moxielogic.com>
+Date: Wed Jan 2 08:28:35 2013 -0500
+
+ New stand-alone patch
+
+commit 981c32ee115e9f0d6546a74592875e138222a9d1
+Author: Anthony Green <green@moxielogic.com>
+Date: Wed Jan 2 07:34:03 2013 -0500
+
+ Merge with GCC. Eliminate quilt bits.
+
+commit 61a054929517fb80c437ba71c91f3e20cfff581a
+Author: Anthony Green <green@moxielogic.com>
+Date: Wed Nov 28 06:07:41 2012 -0500
+
+ Refresh config.guess and config.sub
+
+commit f6b58d2bdc0a24ce94dedce59802f091979df265
+Author: rofl0r <retnyg@gmx.net>
+Date: Thu Nov 22 16:26:21 2012 +0100
+
+ fix build on ppc when long double == double
+
+commit 69da33a0761aeac73f9e9646269da61c906d6020
+Author: Anthony Green <green@moxielogic.com>
+Date: Mon Nov 12 15:25:47 2012 -0500
+
+ Pull in config.sub for aarch64 support and more
+
+commit f680b598b7bdde325ac9349e8c35151c228bf2df
+Author: Anthony Green <green@moxielogic.com>
+Date: Tue Nov 6 16:00:40 2012 -0500
+
+ Add missing aarch64 configury bits
+
+commit dfadfb19853c57c8623c436d0ef2bdafab24b433
+Author: Anthony Green <green@moxielogic.com>
+Date: Wed Oct 31 06:46:41 2012 -0400
+
+ Rebase for ppc64 fix
+
+commit e944b8c7eb1e2eeb9c0f3b9742b4d7f476860ce1
+Author: Anthony Green <green@moxielogic.com>
+Date: Tue Oct 30 14:06:09 2012 -0400
+
+ Add PaX work-around
+
+commit 9ccd51be1fdeb99f8b4f42f905166c2abbba8ac0
+Merge: f342996 fa5d747
+Author: Anthony Green <green@moxielogic.com>
+Date: Tue Oct 30 13:37:37 2012 -0400
+
+ Fix commit conflicts
+
+commit f342996cb50eb23b868afcff5ac0cdbb6b505d63
+Author: Anthony Green <green@moxielogic.com>
+Date: Tue Oct 30 07:42:27 2012 -0400
+
+ Darwin12 fix
+
+commit 58e8b66f70cef2e3c9b0e5a707b45d634cbbf5d9
+Author: Anthony Green <green@moxielogic.com>
+Date: Tue Oct 30 07:07:19 2012 -0400
+
+ AArch64 port
+
+commit fa5d747905472571fd472c07d4726017624f66b3
+Author: Anthony Green <green@moxielogic.com>
+Date: Tue Oct 30 07:07:19 2012 -0400
+
+ AArch64 port
+
+commit 6993a6686f43f2313b18142c1e96189a27db2aa3
+Author: Anthony Green <green@moxielogic.com>
+Date: Tue Oct 30 06:59:32 2012 -0400
+
+ Fix autoconf macros
+
+commit 70084e70ddb13b29dd05c751b1904de206bbe790
+Author: Anthony Green <green@moxielogic.com>
+Date: Fri Oct 12 23:55:06 2012 -0400
+
+ Update Tile* port info
+
+commit 9c00a3f6742d61404b31268cc773e7130ff43331
+Author: Anthony Green <green@moxielogic.com>
+Date: Fri Oct 12 16:46:06 2012 -0400
+
+ TILE-Gx/TILEPro support
+
+commit 048d2f41c3a6664b4b64bf21e804686662da4160
+Author: Anthony Green <green@moxielogic.com>
+Date: Thu Oct 11 10:55:25 2012 -0400
+
+ Rebase
+
+commit 6d6f71108064f5069edd7bf771059d3b82640135
+Author: Reini Urban <rurban@cpanel.net>
+Date: Sat Jul 7 12:42:00 2012 -0500
+
+ cygwin/mingw shared libs need libtool LDFLAGS = -no-undefined
+
+ otherwise only static libs are created.
+
+commit d330f19292da8f39a78a9e2b0ba08df8094e3bc5
+Author: Nicolas Lelong <rotoglup>
+Date: Sat May 5 09:37:02 2012 -0400
+
+ iOS build fixes.
+
+commit 09b23cfc1d6d15361eee18818851fd3cacb26559
+Author: Anthony Green <green@moxielogic.com>
+Date: Fri Apr 27 08:29:48 2012 -0400
+
+ Update README with Blackfin/uClinux support
+
+commit 213ed15c70e72d666154c08e2b41dae3f61f20d3
+Author: Anthony Green <green@moxielogic.com>
+Date: Fri Apr 27 01:34:15 2012 -0400
+
+ Add blackfin supprt from Alexandre Keunecke.
+
+commit ff3d76fd427382ce7d2b2ed54acdd0bce470ca4f
+Author: Anthony Green <green@moxielogic.com>
+Date: Wed Apr 11 23:16:48 2012 -0400
+
+ 3.0.11
+
+commit 7e0a412c4fd9cbe77b467a9bf86f56aea62632c3
+Author: Anthony Green <green@moxielogic.com>
+Date: Wed Apr 11 22:47:44 2012 -0400
+
+ Update files to ship
+
+commit 39e6a5860416f7bad992149817e1da1ba7c460d4
+Author: Zachary Waldowski <zwaldowski@gmail.com>
+Date: Wed Apr 11 22:39:46 2012 -0400
+
+ More mac/ios build improvements
+
+commit 853cc722a16f8d1254573ef3bb73c7b8f3d8a110
+Author: Anthony Green <green@moxielogic.com>
+Date: Tue Apr 10 06:33:33 2012 -0400
+
+ Fix typo for darwin targets
+
+commit 3f5023068cda07a3dd6dacbaa875a5b5fc96d4bb
+Author: Anthony Green <green@moxielogic.com>
+Date: Fri Apr 6 20:34:51 2012 -0400
+
+ mend
+
+commit ebb8e8945681ce0af7a5c47a980287e8ece84b84
+Author: Mike Lewis <mikelikespie@gmail.com>
+Date: Fri Apr 6 20:02:08 2012 -0400
+
+ Build iOS library with xcode
+
+commit a098b44f4c592c2192fcdef4fad6108eb3f4301c
+Author: Anthony Green <green@moxielogic.com>
+Date: Fri Apr 6 17:04:35 2012 -0400
+
+ Reapply missing testsuite changes for arm
+
+commit 10d1e51393f08c14045db85843208f44f9f1e9ba
+Author: Anthony Green <green@moxielogic.com>
+Date: Fri Apr 6 11:57:14 2012 -0400
+
+ Update to rc4. Upgrade autoconf version.
+
+commit 9bcc884276dc0a807b2605e510b11b1740dd9aa2
+Author: Anthony Green <green@moxielogic.com>
+Date: Fri Apr 6 11:53:07 2012 -0400
+
+ Fix Linux/x32 reference in README
+
+commit a044a56b1cd2a0924f5ec0d6b5a5089d14fcd1a1
+Author: Anthony Green <green@moxielogic.com>
+Date: Fri Apr 6 10:39:10 2012 -0400
+
+ Linux/x32 libtool fix
+
+commit 59bb61a36661b972e8443531d3b7bc736e131a4b
+Author: Anthony Green <green@moxielogic.com>
+Date: Fri Apr 6 08:26:14 2012 -0400
+
+ Update libtool version, README, tests dists
+
+commit f2981454cbe25cf9411b710f46c5f5552003a123
+Author: Anthony Green <green@moxielogic.com>
+Date: Thu Apr 5 15:45:19 2012 -0400
+
+ Revert debug code changes
+
+commit 39dccddb606f6fdb8dcb177d416e884041da6e30
+Author: Zachary Waldowski <zwaldowski@gmail.com>
+Date: Thu Apr 5 12:32:41 2012 -0400
+
+ Fix building with Clang for Darwin (OS X 10.6+ and iOS
+ 4.0+)
+
+commit 3afaa9a34a81a305227ae8cf4f12b9d0484d055e
+Author: Peter Rosin <peda@lysator.liu.se>
+Date: Tue Apr 3 07:40:31 2012 -0400
+
+ Fix return_uc.c test case on windows.
+
+commit 65f40c35a2873d8328359ec4512bd0736dbe32c7
+Author: Anthony Green <green@moxielogic.com>
+Date: Tue Apr 3 07:35:59 2012 -0400
+
+ Repair ppc build regression.
+
+commit 0a1ab12a8d15caa894116a82249551f23ef65612
+Author: Peter Rosin <peda@lysator.liu.se>
+Date: Fri Mar 30 08:14:08 2012 -0400
+
+ Various MSVC-related changes.
+
+commit e1539266e6c6dde3c99832323586f33f977d1dc0
+Author: Anthony Green <green@moxielogic.com>
+Date: Fri Mar 30 00:40:18 2012 -0400
+
+ ARM VFP fix for old toolchains
+
+commit 7c5e60b5f47d725036a72162f136272bc407e3a1
+Author: Anthony Green <green@moxielogic.com>
+Date: Thu Mar 29 08:48:22 2012 -0400
+
+ Rebase on fixed GCC sources
+
+commit e72ed5eeaa9cfb0fdc86f6b3422734177b659f96
+Author: Anthony Green <green@moxielogic.com>
+Date: Wed Mar 21 09:52:28 2012 -0400
+
+ Fix vararg float test
+
+commit bd78c9c3311244dd5f877c915b0dff91621dd253
+Author: Anthony Green <green@moxielogic.com>
+Date: Wed Mar 21 08:09:30 2012 -0400
+
+ More cygwin fixes
+
+commit 84d3253f86dad6b4f261231935675d35fd964b05
+Author: Anthony Green <green@moxielogic.com>
+Date: Mon Mar 19 23:07:35 2012 -0400
+
+ Rebase post GCC merge
+
+commit 964c5b93f80dcaacf73056b7d15a4d2b4b7a217c
+Author: Anthony Green <green@moxielogic.com>
+Date: Sat Mar 3 14:46:20 2012 -0500
+
+ abi check fixes and Linux/x32 support
+
+commit 6c194233a5f6f1d274669afc5924a9e1f69d4876
+Author: Anthony Green <green@moxielogic.com>
+Date: Sat Mar 3 14:17:54 2012 -0500
+
+ Add -no-undefined for both 32- and 64-bit x86
+ windows-like hosts.
+
+commit 8360bf1cd0aba8db5582266da70467de7e89a57a
+Author: Anthony Green <green@moxielogic.com>
+Date: Thu Feb 23 07:01:13 2012 -0500
+
+ Ensure that users don't include ffitarget.h directly
+
+commit d578b89619cf3d2baff027b203619dc307fc12e3
+Author: Anthony Green <green@moxielogic.com>
+Date: Wed Feb 15 00:18:18 2012 -0500
+
+ Fix ABI check regression
+
+commit dee20f8e45c486f5018f31e09bb362992aa498c3
+Author: Anthony Green <green@moxielogic.com>
+Date: Fri Feb 10 13:06:46 2012 -0500
+
+ Rebased from gcc
+
+commit 4130e1972d001143e5e9f3c6b65f2a6f9524169e
+Author: Anthony Green <green@moxielogic.com>
+Date: Fri Feb 3 13:18:27 2012 -0600
+
+ Refresh autoconf-archive m4 scripts
+
+commit 1ff9c604bb214b5a305064af1049577ef783730a
+Author: Anthony Green <green@moxielogic.com>
+Date: Wed Feb 1 16:34:30 2012 -0600
+
+ Rebase from GCC
+
+commit 211060eb8f714af0e935430efa6bb45e8e3ffc5d
+Author: Anthony Green <green@moxielogic.com>
+Date: Mon Jan 23 14:24:01 2012 -0500
+
+ Alpha fix
+
+commit 78d9c638ba0de6edfbc603fd65d19c6562663248
+Author: Anthony Green <green@moxielogic.com>
+Date: Mon Jan 23 14:17:24 2012 -0500
+
+ mend
+
+commit afaf3381604bd81803d8a5f3bf4d462299f1aac3
+Author: Anthony Green <green@moxielogic.com>
+Date: Mon Jan 23 14:17:13 2012 -0500
+
+ mend
+
+commit 9e9c4aeb77de5608d602109f22100c1c0c79faad
+Author: Anthony Green <green@moxielogic.com>
+Date: Mon Jan 23 14:11:23 2012 -0500
+
+ Add Amiga support
+
+commit 8efc0b1f4027d5a3cbf205e55d422d94e60f3226
+Author: Anthony Green <green@moxielogic.com>
+Date: Mon Jan 23 13:47:38 2012 -0500
+
+ Unlikely fixes
+
+commit 1df51398ae183dc208ba4599ee867278b04d13d3
+Author: Anthony Green <green@moxielogic.com>
+Date: Mon Jan 23 13:43:59 2012 -0500
+
+ mend
+
+commit cd2277cc796b96b149cd284ae85326529fe7fb9c
+Author: Anthony Green <green@moxielogic.com>
+Date: Mon Jan 23 13:43:38 2012 -0500
+
+ mend
+
+commit 164e6fe04b189746c8bd5810c6e3e919770bb9d4
+Author: Anthony Green <green@moxielogic.com>
+Date: Mon Jan 23 12:41:06 2012 -0500
+
+ m68k fixes
+
+commit c365ee7577bef00cb3c2c0b5224147aea04138d8
+Author: Anthony Green <green@moxielogic.com>
+Date: Mon Jan 23 11:13:18 2012 -0500
+
+ Refresh
+
+commit f22c38bbd93bcc0c04bf26c3e414556b3177c385
+Author: Anthony Green <green@moxielogic.com>
+Date: Fri Nov 18 15:13:41 2011 -0500
+
+ Update variadic patch
+
+commit 03e9ee321a3c208f88d2432587ce40b2bb2430ba
+Author: Anthony Green <green@moxielogic.com>
+Date: Fri Nov 18 15:13:00 2011 -0500
+
+ Fix cls_double_va.c and update docs
+
+commit 95f31151ec792809cfb80d385350f9f56d95aa25
+Author: Anthony Green <green@moxielogic.com>
+Date: Sat Nov 12 23:46:05 2011 -0500
+
+ Rerun automake
+
+commit 198ed1ef85cf18342627f8d44bc3f12c9975a49d
+Author: Anthony Green <green@moxielogic.com>
+Date: Sat Nov 12 23:45:20 2011 -0500
+
+ Update version number
+
+commit 4f17e1f142e805b13959ba2594ee735eae439f4e
+Author: Anthony Green <green@moxielogic.com>
+Date: Sat Nov 12 17:22:24 2011 -0500
+
+ Fix last patch
+
+commit ff9454da44859716a5bd4eaa344499288c79694f
+Author: Anthony Green <green@moxielogic.com>
+Date: Sat Nov 12 17:18:51 2011 -0500
+
+ Add David Gilbert's variadic function call support
+
+commit ea14ae85e8f54ff046b7fb8a9cfe349475272044
+Author: Anthony Green <green@moxielogic.com>
+Date: Sat Nov 12 16:36:59 2011 -0500
+
+ clean up
+
+commit 52891f8a93f9b8de801cca4cf05639422dc9773e
+Author: Anthony Green <green@moxielogic.com>
+Date: Sat Nov 12 16:35:55 2011 -0500
+
+ Add powerpc soft float support
+
+commit c8f1bde8e2566c5a87474b4d08aa934d6d28ee75
+Author: Anthony Green <green@moxielogic.com>
+Date: Sat Nov 12 16:21:02 2011 -0500
+
+ Remove junk file
+
+commit 6a6e7f862f3cc677e19131587caa619e7f9c7ffd
+Author: Anthony Green <green@moxielogic.com>
+Date: Sat Nov 12 16:20:42 2011 -0500
+
+ Fix kfreebsd
+
+commit d52fbed05ccbdee9ed8b9c911cbb4f85b0ff0f2a
+Author: Anthony Green <green@moxielogic.com>
+Date: Sat Nov 12 16:13:41 2011 -0500
+
+ Add missing ChangeLog entry
+
+commit 322052ce65c4fdac85bedc24726fd0e0094ba521
+Author: Anthony Green <green@moxielogic.com>
+Date: Sat Nov 12 16:11:49 2011 -0500
+
+ Fix arm wince alignment issue
+
+commit af18df2bc2f52df81e7b5c619bd86db8489dc873
+Author: Anthony Green <green@moxielogic.com>
+Date: Sat Nov 12 15:52:08 2011 -0500
+
+ Remove use of ppc string instructions
+
+commit 236c9391321f83ad40daf03f40c35c9ebc1da6b3
+Author: Anthony Green <green@moxielogic.com>
+Date: Sat Nov 12 07:37:40 2011 -0500
+
+ Fix darwin11 build problem
+
+commit c411f140f305ebb00d33c92b7cb2742bcd241b6a
+Author: Anthony Green <green@moxielogic.com>
+Date: Sat Nov 12 07:32:36 2011 -0500
+
+ Fix ax_enable_builddir macro on BSD systems
+
+commit 3d56106b07735abef6ae9f032e94f560a0ed2f30
+Author: Anthony Green <green@moxielogic.com>
+Date: Sat Nov 12 07:20:24 2011 -0500
+
+ Rebase
+
+commit 8c01954c50bf8ef2e00a3db166060a1b8f83a20d
+Author: Anthony Green <green@moxielogic.com>
+Date: Tue Sep 6 14:26:32 2011 -0400
+
+ Build assembly files with debug info
+
+commit fed646a2078969f4ce89c29107f1e72e03f4a977
+Author: Anthony Green <green@moxielogic.com>
+Date: Tue Sep 6 09:50:20 2011 -0400
+
+ Regenerate configury with missing m4 macros
+
+commit d76441cf71216f8f1e62e7ec852a7f4e21371ec8
+Author: Anthony Green <green@moxielogic.com>
+Date: Wed Aug 24 10:14:23 2011 -0400
+
+ Update list of supported OpenBSD systems
+
+commit ee6696fdf4768ba6dd037fb6dd99435afa13816e
+Author: Anthony Green <green@moxielogic.com>
+Date: Tue Aug 23 12:30:29 2011 -0400
+
+ 3.0.11-rc1. soname bump.
+
+commit c6265c36a91eab8175d0e72db84d8225418f2379
+Author: Anthony Green <green@moxielogic.com>
+Date: Tue Aug 23 10:31:33 2011 -0400
+
+ Version 3.0.10
+
+commit cc5e41bf32d18a14dbdd653d52eacdbdc934c392
+Author: Anthony Green <green@moxielogic.com>
+Date: Mon Aug 22 16:34:24 2011 -0400
+
+ Fix use of autoconf macros
+
+commit 049d8386ff52399e69a530b55b9feedc8a2589d2
+Author: Anthony Green <green@moxielogic.com>
+Date: Mon Aug 22 14:50:10 2011 -0400
+
+ Many new patches
+
+commit 3b7efa4e74f0dcebf70b447391987aedd3473306
+Author: Anthony Green <green@moxielogic.com>
+Date: Mon Aug 15 13:25:13 2011 -0400
+
+ Revert remove-debug-code patch temporarily (for ARM Fedora release)
+
+commit d992ac54a2a9e7e064ffebcb91e05e7cb86185c7
+Author: Anthony Green <green@gmachine.(none)>
+Date: Fri Jul 29 17:32:53 2011 -0400
+
+ Refresh from GCC
+
+commit 2d3fb36420e09304220ee6c0652bae5eccdb965d
+Author: Anthony Green <green@moxielogic.com>
+Date: Wed Mar 30 16:54:42 2011 -0400
+
+ Fix darwin EH
+
+commit 30ff28e1d8cd9ed5319f1fbe9c7cccacc8161fb3
+Author: Anthony Green <green@moxielogic.com>
+Date: Mon Feb 28 15:36:23 2011 -0500
+
+ Fix permissions
+
+commit 09f8f310f4f53a24289682d3d28f4399d7bafc3b
+Author: Anthony Green <green@moxielogic.com>
+Date: Mon Feb 28 15:36:07 2011 -0500
+
+ More AIX fixes. rc9.
+
+commit 53d7b165642c220aa5166ba350b490802f359b54
+Merge: 18dd85d 3000dc2
+Author: Anthony Green <green@moxielogic.com>
+Date: Mon Feb 28 15:23:31 2011 -0500
+
+ Merge branch 'master' of https://github.com/landonf/libffi-ios
+
+commit 18dd85d6cb9f3f3eea2a3b70eb4e150045905c55
+Author: Anthony Green <green@moxielogic.com>
+Date: Fri Feb 25 16:23:04 2011 -0500
+
+ rc8. fix last patch.
+
+commit 74ee6ea8b42e60d44a3ae8938b1e42a38c1e66b4
+Author: Anthony Green <green@moxielogic.com>
+Date: Fri Feb 25 15:52:14 2011 -0500
+
+ rc7. More AIX fixes.
+
+commit 2541679dbd3db0014890f42192dbf8008ab923fa
+Author: Anthony Green <green@moxielogic.com>
+Date: Fri Feb 25 15:09:13 2011 -0500
+
+ Fix ppc32 bug
+
+commit cbb062cc35c518004f1ab45c847f8ec4f66069ad
+Author: Anthony Green <green@moxielogic.com>
+Date: Thu Feb 17 20:39:21 2011 -0500
+
+ Another non-GCC configury fix
+
+commit 8cf8878425e9971866fa6b27a3e4914729ad3960
+Author: Anthony Green <green@moxielogic.com>
+Date: Tue Feb 15 15:19:49 2011 -0500
+
+ Fix ax_cc_maxopt.m4
+
+commit 24b72070c0937f9000744c77a636f07e04786b6a
+Author: Anthony Green <green@moxielogic.com>
+Date: Mon Feb 14 15:30:57 2011 -0500
+
+ Fix warning and msvcc patches
+
+commit d72c49e556a8c516e97f6722d1be2f1209c21207
+Author: Anthony Green <green@moxielogic.com>
+Date: Sun Feb 13 11:41:05 2011 -0500
+
+ Add missing msvcc.sh
+
+commit 3000dc237f6017a7445d8404097a4f46b73fdd29
+Merge: 55e4a5a 1fbf9dc
+Author: Landon Fuller <landonf@bikemonkey.org>
+Date: Sun Feb 13 08:55:53 2011 -0500
+
+ Merge remote branch 'upstream/master'
+
+commit 1fbf9dc44feea564e84ad7406d17c5d5906ce0e0
+Author: Anthony Green <green@moxielogic.com>
+Date: Sun Feb 13 08:06:39 2011 -0500
+
+ Fix bad_abi test. rc5.
+
+commit 90af15ef5c1614b76370c4d13954586fabf9e8e3
+Author: Anthony Green <green@moxielogic.com>
+Date: Sat Feb 12 12:29:36 2011 -0500
+
+ iOS fixes
+
+commit 55e4a5aa1568558a04aa40f16fc022e459af53e3
+Author: Landon Fuller <landonf@bikemonkey.org>
+Date: Sat Feb 12 12:13:46 2011 -0500
+
+ Add support for building a full armv6/armv7/i386 universal iOS library
+
+commit a0c80f279b8733d001cb5e5c5a3289ecb7a6e56a
+Author: Landon Fuller <landonf@bikemonkey.org>
+Date: Sat Feb 12 11:43:49 2011 -0500
+
+ Update my e-mail address.
+
+commit 8195e0e11df7a53fa474caa9375f73ca1136ed66
+Author: Landon Fuller <landonf@bikemonkey.org>
+Date: Sat Feb 12 11:27:00 2011 -0500
+
+ Fix symbol prefixes on Darwin.
+
+commit 56b3f8cef0f28cefaa0f40fe0cf7c524adef131d
+Author: Landon Fuller <landonf@bikemonkey.org>
+Date: Sat Feb 12 11:14:54 2011 -0500
+
+ Modify the ffi_closure structures to hold table/table entry pointers instead of a code buffer.
+
+ This re-integrates commit da2773e02ab26cc11a7f.
+
+commit 28a00f61ff3f64c4eb2269ce2aea3d493274469e
+Author: Landon Fuller <landonf@bikemonkey.org>
+Date: Sat Feb 12 11:01:48 2011 -0500
+
+ Apple assembler support; fixed most gas/ELF-isms.
+
+commit 7f2ea33a80bfced5e48ed7292f3b8f057d54ff8f
+Author: Landon Fuller <landonf@bikemonkey.org>
+Date: Sat Feb 12 10:39:18 2011 -0500
+
+ Replace RETLDM macro.
+
+ The macro is incompatible with Apple's assembler; switch to
+ a simple inline version.
+
+commit 92ff23e77fa586455b427b71f49e1d9502470e6e
+Author: Landon Fuller <landonf@bikemonkey.org>
+Date: Sat Feb 12 10:24:49 2011 -0500
+
+ Switch to the current iOS 4.2 SDK.
+
+commit 58fb8ca2dfb89ad70284bb9678d3d4dbb658c8a7
+Merge: cc3fbd9 71c792f
+Author: Landon Fuller <landonf@bikemonkey.org>
+Date: Sat Feb 12 10:23:19 2011 -0500
+
+ Merge remote branch 'upstream/master'
+
+commit cc3fbd975ce9366d4c40a6ff6c108f664867bd7c
+Merge: e449a43 f6ab3ed
+Author: Landon Fuller <landonf@bikemonkey.org>
+Date: Sat Feb 12 10:21:02 2011 -0500
+
+ Merge branch 'master' of github.com:landonf/libffi-ios
+
+commit e449a43bbe12f8119399928db1ae26adc71dde14
+Author: Landon Fuller <landonf@bikemonkey.org>
+Date: Sat Feb 12 10:20:42 2011 -0500
+
+ Allow specification of the minimum supported iOS version.
+
+commit 71c792f51bcf3e2f334e5ea1fb1a8b667cb3aedb
+Author: Anthony Green <green@moxielogic.com>
+Date: Sat Feb 12 09:33:11 2011 -0500
+
+ rc4
+
+commit 7c7c9f327299331022f6000603a35f2310dfe308
+Author: Anthony Green <green@moxielogic.com>
+Date: Sat Feb 12 09:29:29 2011 -0500
+
+ ungccify parts of the build
+
+commit ed62e48b95a0fa60b685f647cb73c9e190eec35c
+Author: Anthony Green <green@moxielogic.com>
+Date: Fri Feb 11 12:23:58 2011 -0500
+
+ Fix permissions
+
+commit 17d9e9e68ddb1b915a0b9751713033861b598575
+Author: Anthony Green <green@moxielogic.com>
+Date: Fri Feb 11 12:23:20 2011 -0500
+
+ Use newer autotools. Only build debug.c when --enable-debug.
+
+commit 6972a4ffda75761eaab7dfbe0fb1516b255e8e0c
+Author: Anthony Green <green@moxielogic.com>
+Date: Fri Feb 11 07:32:51 2011 -0500
+
+ Fix xlc build on AIX
+
+commit 1833aa0fb9831eb0725b63e35886c0f6d35df480
+Author: Anthony Green <green@moxielogic.com>
+Date: Fri Feb 11 07:11:04 2011 -0500
+
+ sparc ABI test fix.
+
+commit f1fb139b4e283fffdcf205a903943d5e9d2bb2a2
+Author: Anthony Green <green@moxielogic.com>
+Date: Wed Feb 9 18:30:02 2011 -0500
+
+ Fix tests
+
+commit 5cb470331d181c84d5d621e88868327a324a5898
+Author: Anthony Green <green@moxielogic.com>
+Date: Wed Feb 9 15:23:06 2011 -0500
+
+ Fix permissions
+
+commit 269deef6dbbb426695919d3398357fada3bb288c
+Author: Anthony Green <green@moxielogic.com>
+Date: Wed Feb 9 15:22:23 2011 -0500
+
+ rc3
+
+commit 42695e72504f647444b8e8e9b90bd24f1e3220e1
+Author: Anthony Green <green@moxielogic.com>
+Date: Wed Feb 9 15:12:35 2011 -0500
+
+ Fix IRIX support
+
+commit a6e56b97f62a3feeb3301c24a2e4cae55e546021
+Author: Anthony Green <green@moxielogic.com>
+Date: Wed Feb 9 15:00:42 2011 -0500
+
+ Add powerpc64-*-darwin* support
+
+commit 747d6c32d4abb07c10c3a1f93579c3929aaa2487
+Author: Anthony Green <green@moxielogic.com>
+Date: Wed Feb 9 14:56:23 2011 -0500
+
+ Add Interix support
+
+commit eab6e41cde382aa07de6c011d514a14c0d62eb47
+Author: Anthony Green <green@moxielogic.com>
+Date: Wed Feb 9 10:15:02 2011 -0500
+
+ Remove README.markdown form libffi-ios
+
+commit 69dbe845f4ee3e6ce8999f17a1e4f2179ef7da89
+Author: Anthony Green <green@moxielogic.com>
+Date: Wed Feb 9 07:38:43 2011 -0500
+
+ Fix xfails
+
+commit f498318c07b95137fe259d86bdbe15347588b84a
+Author: Anthony Green <green@moxielogic.com>
+Date: Wed Feb 9 06:26:46 2011 -0500
+
+ Update README for iOS again
+
+commit 630b9c0ac43c7edcbfd892e23c09fb26724f4ac0
+Author: Anthony Green <green@moxielogic.com>
+Date: Wed Feb 9 06:24:23 2011 -0500
+
+ Update to rc2
+
+commit 0cad4386fa4c9ea5f8ca88b16247db4e5c8fea90
+Author: Anthony Green <green@moxielogic.com>
+Date: Wed Feb 9 06:11:46 2011 -0500
+
+ Add ChangeLog entry. Fix copyright headers.
+
+commit 09cb76f2645bd2c151846e9249d8ea707ba01e8c
+Author: Anthony Green <green@moxielogic.com>
+Date: Tue Feb 8 20:39:51 2011 -0500
+
+ Add missing change
+
+commit 2e3a48ccdd54340983c46a29a0b41985e3e789ac
+Author: Anthony Green <green@moxielogic.com>
+Date: Tue Feb 8 20:37:26 2011 -0500
+
+ Fix make dist
+
+commit 5e4814d9928e236a2a4afe84d6e1d4fdaa473206
+Author: Anthony Green <green@moxielogic.com>
+Date: Tue Feb 8 19:46:28 2011 -0500
+
+ fix permissions
+
+commit 5c0cc6f1536aa1738795a97303810a823c7fa2cb
+Author: Anthony Green <green@moxielogic.com>
+Date: Tue Feb 8 19:45:59 2011 -0500
+
+ 3.0.10rc1
+
+commit 857fe3de46d2286afa2fe772920ecf4aefa1688f
+Author: Anthony Green <green@moxielogic.com>
+Date: Tue Feb 8 19:39:20 2011 -0500
+
+ Clean ups
+
+commit e2214f8adb5577c247452e2cc9f4cbe304d7ca9f
+Author: Anthony Green <green@moxielogic.com>
+Date: Tue Feb 8 19:22:56 2011 -0500
+
+ Update README
+
+commit 1106229a5721a659da5c231ec0e8211119615394
+Merge: bc9d0be f6ab3ed
+Author: Anthony Green <green@moxielogic.com>
+Date: Tue Feb 8 19:20:09 2011 -0500
+
+ Add iOS support
+
+commit bc9d0be2958ce475757f34dd2c878948aa77a39f
+Author: Anthony Green <green@moxielogic.com>
+Date: Tue Feb 8 17:04:26 2011 -0500
+
+ 3.0.10rc0 changes
+
+commit 3b836249feae6d08d3e6887486e4b9961ddafa09
+Author: Anthony Green <green@moxielogic.com>
+Date: Tue Feb 8 14:28:59 2011 -0500
+
+ Rebase from GCC
+
+commit a26e3940619faeba6de54824c9540c90b1aab513
+Author: Anthony Green <green@moxielogic.com>
+Date: Tue Feb 8 13:56:12 2011 -0500
+
+ copyright updates patch
+
+commit b8099539f00e224107594101e9760b6dc081a056
+Author: Anthony Green <green@moxielogic.com>
+Date: Tue Feb 8 13:50:43 2011 -0500
+
+ Fix msvcc.sh botch
+
+commit dc411e8f99113a34656bfd2d3ae51259972488cc
+Author: Anthony Green <green@moxielogic.com>
+Date: Tue Feb 8 10:49:29 2011 -0500
+
+ Fix HP-UX build
+
+commit 404585d1348e30ac58203bbd876d9131e5aed874
+Author: Anthony Green <green@moxielogic.com>
+Date: Tue Feb 8 10:44:36 2011 -0500
+
+ Fix sparc v8 aggregate type returns for sun's compiler
+
+commit 19ce713188e193e4522740d24c20170411883d2d
+Author: Anthony Green <green@moxielogic.com>
+Date: Tue Feb 8 10:34:23 2011 -0500
+
+ grammar fix
+
+commit 89284fe55f1a8ad3bddbea796ee00d0e3ba411ce
+Author: Anthony Green <green@moxielogic.com>
+Date: Tue Feb 8 10:19:19 2011 -0500
+
+ Fix AIX build with IBM XLC
+
+commit ba022c338af97cb18d9f8ed5a607fd483a61c09c
+Author: Anthony Green <green@moxielogic.com>
+Date: Tue Feb 8 10:12:48 2011 -0500
+
+ fix win64-underscore patch
+
+commit 097e5f3924ee92a3ba6cd72f787da8a3eb14fea3
+Author: Anthony Green <green@moxielogic.com>
+Date: Tue Feb 8 10:11:00 2011 -0500
+
+ x86 pcrel test part 2
+
+commit ed2c518d960b91d444be74e5a55779a9c4602f3b
+Author: Anthony Green <green@moxielogic.com>
+Date: Tue Feb 8 10:10:07 2011 -0500
+
+ x86 pcrel test
+
+commit 0e5843995f46900ef212531281e08b224464f413
+Author: Anthony Green <green@moxielogic.com>
+Date: Tue Feb 8 07:52:40 2011 -0500
+
+ Refresh from GCC
+
+commit 5b9cd52784339a42e417174a55e310e214d435f9
+Author: Anthony Green <green@moxielogic.com>
+Date: Mon Nov 22 15:19:57 2010 -0500
+
+ win64-underscore patch
+
+commit 2db72615b50eb5c0f29725c02c740a2f0d7fc7d9
+Author: Anthony Green <green@moxielogic.com>
+Date: Sun Nov 21 10:50:56 2010 -0500
+
+ Rebase
+
+commit f6ab3edc23dc8fc7c47a31c896044150c23f04b5
+Author: Landon Fuller <landonf@plausible.coop>
+Date: Wed Oct 27 19:34:51 2010 -0400
+
+ Include the license header in the generated output.
+
+commit cef619462887fa0f360e3ee702d1e04f112b5b38
+Author: Landon Fuller <landonf@bikemonkey.org>
+Date: Wed Oct 27 13:59:30 2010 -0400
+
+ Add missing copyright/license header.
+
+commit 53f387b203413c9aa6e31f49dbb70d37d816330b
+Author: Landon Fuller <landonf@bikemonkey.org>
+Date: Sun Sep 19 19:57:17 2010 -0700
+
+ Minor README fix.
+
+commit 4fbcb5b5fbce11f4b168060e00639db33c85b75b
+Author: Landon Fuller <landonf@bikemonkey.org>
+Date: Sun Sep 19 19:50:37 2010 -0700
+
+ Minor README fix.
+
+commit 8e7652ef6acab5db7a29f786686a54f05cdbdc7d
+Author: Landon Fuller <landonf@bikemonkey.org>
+Date: Sun Sep 19 19:49:39 2010 -0700
+
+ Add a libffi-ios-specific github README.
+
+commit 83038cf24aa1a92b62b91ffee1dcc25d79243484
+Author: Landon Fuller <landonf@bikemonkey.org>
+Date: Sun Sep 19 14:36:45 2010 -0700
+
+ Implement FFI_EXEC_TRAMPOLINE_TABLE allocator for iOS/ARM.
+
+ This provides working closure support on iOS/ARM devices where
+ PROT_WRITE|PROT_EXEC is not permitted. The code passes basic
+ smoke tests, but requires further review.
+
+commit b00ff3e98fdde622cef617030e14d5356dff988f
+Author: Landon Fuller <landonf@bikemonkey.org>
+Date: Sun Sep 19 14:22:26 2010 -0700
+
+ Rename the generated symbol
+
+commit da2773e02ab26cc11a7fe87e985599f35cdf0649
+Author: Landon Fuller <landonf@bikemonkey.org>
+Date: Sun Sep 19 14:21:37 2010 -0700
+
+ Modify the ffi_closure structures to hold table/table entry pointers instead of a code buffer.
+
+commit 01d71b7bed41844f80cb9feef20dcc5ece5ba2d0
+Author: Landon Fuller <landonf@bikemonkey.org>
+Date: Sun Sep 19 14:21:14 2010 -0700
+
+ Regenerated the autoconf script
+
+commit 19afda0069c42e51c81dca7b10a5cf884b4cdce0
+Author: Landon Fuller <landonf@bikemonkey.org>
+Date: Sun Sep 19 14:20:52 2010 -0700
+
+ Enable AC_SUBST for FFI_EXEC_TRAMPOLINE_TABLE
+
+commit 9e1196444e78aef20028c18891f44ebe39a815fd
+Author: Landon Fuller <landonf@bikemonkey.org>
+Date: Sun Sep 19 10:43:06 2010 -0700
+
+ Add a hard-coded FFI_EXEC_TRAMPOLINE_TABLE arm implementation.
+
+ This implements support for re-mapping a shared table of executable
+ trampolines directly in front of a writable configuration page, working
+ around PROT_WRITE restrictions for sandboxed applications on Apple's
+ iOS.
+
+ This implementation is for testing purposes; a proper allocator is still
+ necessary, and ARM-specific code needs to be moved out of
+ src/closures.c.
+
+commit f38364b399184e682fc3e785084bd497827bc5af
+Author: Landon Fuller <landonf@bikemonkey.org>
+Date: Sun Sep 19 10:42:36 2010 -0700
+
+ Fix symbol prefix for ffi_closure_SYSV_inner on Darwin.
+
+commit 36849e7716b77aa25e4175d1f4be1b93dbf47aac
+Author: Landon Fuller <landonf@bikemonkey.org>
+Date: Sun Sep 19 09:35:04 2010 -0700
+
+ Whitespace/comment fixes.
+
+commit b764162526854686e579a48b6ac5981f4eb886a3
+Author: Landon Fuller <landonf@bikemonkey.org>
+Date: Sun Sep 19 09:04:34 2010 -0700
+
+ Fix the script name (build-iphone.sh -> build-ios.sh)
+
+commit a3d9aa85013341451ea97766485b7a11852d32b2
+Author: Landon Fuller <landonf@bikemonkey.org>
+Date: Sun Sep 19 09:03:52 2010 -0700
+
+ Update the autogenerated autoconf/automake files.
+
+commit c71480eaf839f26bbdfcd8965f65ac4d8defddc0
+Author: Landon Fuller <landonf@bikemonkey.org>
+Date: Sun Sep 19 09:02:05 2010 -0700
+
+ Update automake/autoconf to conditionally build src/arm/trampoline.S if FFI_EXEC_TRAMPOLINE_TABLE is enabled.
+
+commit 9af9291b73bc5e27ecd949bec8157f20426d65b8
+Author: Landon Fuller <landonf@bikemonkey.org>
+Date: Sun Sep 19 08:52:33 2010 -0700
+
+ Add the trampoline table generated by gentramp.sh
+
+commit 68ce0c383ece84f69945d1c8c3fed03f7f9cb5d6
+Author: Landon Fuller <landonf@bikemonkey.org>
+Date: Sun Sep 19 08:38:19 2010 -0700
+
+ Add a shell script that generates the ARM trampoline page.
+
+ This generates a page of 340 trampolines, aligned within one page. The
+ trampolines use pc-relative addressing to reference config data
+ (context, jump address) from a page placed directly prior to the
+ trampoline page. This can be used on systems -- such as iOS -- that do not
+ support writable, executable memory by remapping the executable page
+ containing the trampolines directly above a newly allocated writable
+ config page.
+
+commit 75af086be8830a8eafe9b1ebda199d788bcb0c62
+Author: Landon Fuller <landonf@bikemonkey.org>
+Date: Sat Sep 18 18:12:19 2010 -0700
+
+ Update autoconf files
+
+commit 1ac92cca9b02ef8d6a769f0de1adccd5c9630355
+Author: Landon Fuller <landonf@bikemonkey.org>
+Date: Sat Sep 18 18:08:14 2010 -0700
+
+ Add autoconf check for W^X platforms that require a trampoline table.
+
+ This adds the FFI_EXEC_TRAMPOLINE_TABLE. The flag is enabled for
+ arm-apple-darwin, where PROT_EXEC on writable (or formerly writable) pages is
+ not permitted for sandboxed binaries.
+
+commit be72fbab29b7190c702d8e1ac3d149855e95879d
+Author: Landon Fuller <landonf@bikemonkey.org>
+Date: Sat Sep 18 18:02:25 2010 -0700
+
+ Use the correct host triple for arm/darwin
+
+commit 70150bdf4509269965c72f2032bf74f285767afe
+Author: Landon Fuller <landonf@bikemonkey.org>
+Date: Sat Sep 18 16:38:03 2010 -0700
+
+ Add missing UNWIND entry; disables .pad on non-EABI targets.
+
+commit 6b452bafaec498df975ba8ac4c99de174e5f74f7
+Author: Landon Fuller <landonf@bikemonkey.org>
+Date: Sat Sep 18 16:21:32 2010 -0700
+
+ Apple assembler support; fixed most gas/ELF-isms.
+
+commit 8ddac835b6f8b54ede764d0ea977dee4c82e2d67
+Author: Landon Fuller <landonf@bikemonkey.org>
+Date: Sat Sep 18 15:38:06 2010 -0700
+
+ Fix placement of the __APPLE__ macro.
+
+commit 69043d02936bb0579ac59b4ee1ed8dec38c38db7
+Author: Landon Fuller <landonf@bikemonkey.org>
+Date: Sat Sep 18 15:32:08 2010 -0700
+
+ Work-around libffi's FP ABI detection.
+
+ On iOS, we must use the AAPCS floating point return value calling
+ conventions. libffi's ARM implementation will only use these conventions
+ if __SOFTFP__ is defined, which is not the case when GCC's
+ -mfloat-abi defaults to 'softfp' instead of 'soft'. To work around this
+ we manually define __SOFTFP__ for Apple platforms in the ARM-specific
+ sysv.S.
+
+ See also:
+ http://developer.apple.com/library/ios/#documentation/Xcode/Conceptual/iPhoneOSABIReference/Introduction/Introduction.html
+ http://infocenter.arm.com/help/topic/com.arm.doc.ihi0042d/IHI0042D_aapcs.pdf
+
+commit a82e6c354ea805114642a6e440abd0832cb1d23f
+Author: Landon Fuller <landonf@bikemonkey.org>
+Date: Sat Sep 18 14:44:24 2010 -0700
+
+ Add a stub iOS build script to drive autoconf
+
+commit 84e8de6e9fc19388f6f1102c013b7d0d52940ecc
+Author: Anthony Green <green@moxielogic.com>
+Date: Fri Aug 6 01:35:12 2010 -0400
+
+ Restore execute permissions
+
+commit 3aeecc9eb1a6feba6549849cdd335c926415a4fc
+Author: Anthony Green <green@moxielogic.com>
+Date: Thu Aug 5 15:19:00 2010 -0400
+
+ Fix win64-struct-args patch
+
+commit 00d0b59cd13f89ab8b44bd894eb7f0a131fcb472
+Author: Anthony Green <green@moxielogic.com>
+Date: Thu Aug 5 14:56:53 2010 -0400
+
+ Fix debug build for windows
+
+commit bda487e87064f27965155459a62dc52a744778d0
+Author: Anthony Green <green@moxielogic.com>
+Date: Thu Aug 5 09:02:41 2010 -0400
+
+ Don't use -safeseh with ml64
+
+commit c1d28ba8d5029795af313ffeb81c97efc6d4c847
+Author: Anthony Green <green@moxielogic.com>
+Date: Thu Aug 5 08:48:16 2010 -0400
+
+ stdcall-x86-closure-fix
+
+commit 5feacad4a56c85b3f23a267a30b2cf424cd59548
+Author: Anthony Green <green@moxielogic.com>
+Date: Thu Aug 5 08:30:04 2010 -0400
+
+ define generic symbols carefully
+
+commit 10ea848900bc3018ac213cef52b44cacbe5cbebc
+Author: Anthony Green <green@moxielogic.com>
+Date: Thu Aug 5 08:24:27 2010 -0400
+
+ don't copy win64 struct args
+
+commit d14178be4c49c3ada44a9fe9efe11d444372ddab
+Author: Anthony Green <green@moxielogic.com>
+Date: Fri Jul 23 09:14:00 2010 -0400
+
+ FFI_LAST_ABI fix
+
+commit 3f5b1375ab1e2b8e3d593e21b27097a4a50f9b83
+Author: Anthony Green <green@moxielogic.com>
+Date: Mon Jul 12 14:39:18 2010 -0400
+
+ rebase
+
+commit eaf444eabc4c78703c0f98ac0197b1619c1b1bef
+Author: Anthony Green <green@moxielogic.com>
+Date: Sat Jul 10 08:59:09 2010 -0400
+
+ Fix selinux test
+
+commit 630974152247f100ece4d44f10c3721bb4599fbf
+Author: Anthony Green <green@gmachine.(none)>
+Date: Wed May 5 20:14:56 2010 -0400
+
+ Micharl Kohler's spelling fixes
+
+commit 9dc9a293f3d4589fcaf02dd4288c8cebaefa508e
+Author: Anthony Green <green@gmachine.(none)>
+Date: Tue Apr 13 10:33:52 2010 -0400
+
+ Rebase to latest GCC sources
+
+commit f2c2a4fce9b3eca9f39b4f3545118bc256da4a73
+Author: Anthony Green <green@gmachine.(none)>
+Date: Tue Apr 13 10:19:28 2010 -0400
+
+ Remove warnings and add OS/2 support
+
+commit c0b69e57d529e33d18b658cc5572a21e3663247c
+Author: Anthony Green <green@gmachine.(none)>
+Date: Tue Mar 30 08:30:22 2010 -0400
+
+ Dan Witte's windows build fixes.
+
+commit 59a259f4d348f593b45f452309f4d020a28051c4
+Author: Anthony Green <green@gmachine.(none)>
+Date: Mon Mar 15 05:57:51 2010 -0400
+
+ Remove junk file
+
+commit 3de1eb36d37a66829e606421939874d0d60d816d
+Author: Anthony Green <green@gmachine.(none)>
+Date: Mon Mar 15 05:57:24 2010 -0400
+
+ fix-comments patch
+
+commit c3813b6d7f8a777700f4c5862190c0db148d4de8
+Author: Anthony Green <green@gmachine.(none)>
+Date: Tue Jan 26 16:48:56 2010 -0500
+
+ Rebuild Makefiles with automake 1.11.1 for CVE-2009-4029.
+
+commit 8d27f68baa365bf883b6053c5f6bc819646d5434
+Author: Anthony Green <green@gmachine.(none)>
+Date: Fri Jan 15 11:35:37 2010 -0500
+
+ Mention recent changes in README
+
+commit ff3cd68b8cf2d9a28cad7aa9beff46236eacec8c
+Author: Anthony Green <green@gmachine.(none)>
+Date: Fri Jan 15 11:27:24 2010 -0500
+
+ Add msvc.sh wrapper
+
+commit cadeba6cb53414a1253582f1719c286665de7b6c
+Author: Anthony Green <green@gmachine.(none)>
+Date: Fri Jan 15 10:46:51 2010 -0500
+
+ Microsoft Visual C port
+
+commit 0739e7dc00db766eb64f502ec4137b817638c9a1
+Author: Anthony Green <green@gmachine.(none)>
+Date: Fri Jan 15 09:48:33 2010 -0500
+
+ Add x86 Sun Studio compiler support
+
+commit edfdfd2e85b8d01d2455934f1d7f4d7eb2f3cf1c
+Author: Anthony Green <green@gmachine.(none)>
+Date: Wed Jan 13 02:56:19 2010 -0500
+
+ Add closure example doc
+
+commit 7b7a42f221cf171e8d09df34cac6dc1fd8458cc3
+Author: Anthony Green <green@gmachine.(none)>
+Date: Tue Jan 12 09:14:14 2010 -0500
+
+ Rebase from GCC
+
+commit 4b18d1f73dc7733137869e4ab5725cb90c1c8fde
+Author: Anthony Green <green@gmachine.(none)>
+Date: Fri Jan 1 10:24:27 2010 -0500
+
+ Add x86-64 MingW to README
+
+commit c3042afaf3f84abbbe9c91bf9bc9896b0d9eb003
+Author: Anthony Green <green@gmachine.(none)>
+Date: Fri Jan 1 08:08:02 2010 -0500
+
+ Reset quilt patches post 3.0.9 merge with GCC
+
+commit b0304e9679bdfec6ac45a57b5c96542697249418
+Author: Anthony Green <green@gmachine.(none)>
+Date: Thu Dec 31 11:32:40 2009 -0500
+
+ Update version
+
+commit 2e7e03d014d9c9bf40e97ce75cba089ad052fa6b
+Author: Anthony Green <green@gmachine.(none)>
+Date: Thu Dec 31 07:43:22 2009 -0500
+
+ Final updates before 3.0.9
+
+commit aea706c52825c8eee677ffa7fdbdd3aed1725492
+Author: Anthony Green <green@gmachine.(none)>
+Date: Tue Dec 29 10:09:31 2009 -0500
+
+ really 3.0.9rc12
+
+commit 0cfe60e9d13f132b88995cfee41f2156344f6fa2
+Author: Anthony Green <green@gmachine.(none)>
+Date: Tue Dec 29 10:06:04 2009 -0500
+
+ 3.0.9rc12
+
+commit 14e2e92e8645804b6940b3e96c98e9f7f384a6b2
+Author: Anthony Green <green@gmachine.(none)>
+Date: Sun Dec 27 21:03:33 2009 -0500
+
+ 3.0.9rc11
+
+commit 884402787bf8eaf7ec207085037cf8ace2f660ec
+Author: Anthony Green <green@gmachine.(none)>
+Date: Sat Dec 26 12:57:23 2009 -0500
+
+ HPUX support and avr32 test fixes.
+
+commit 01c78756aff22efb1f122f8e93e068d7bf2185c7
+Author: Anthony Green <green@gmachine.(none)>
+Date: Sat Dec 26 10:05:18 2009 -0500
+
+ 3.0.9rc9
+
+commit 70868464651320268d79c6894db5a50fdc11032a
+Author: Anthony Green <green@gmachine.(none)>
+Date: Sat Dec 26 09:58:03 2009 -0500
+
+ Remove xfails for mips and arm
+
+commit 838d4ad920ec85cf5ca3b511221d67f6d9a99024
+Author: Anthony Green <green@gmachine.(none)>
+Date: Sat Dec 26 09:57:27 2009 -0500
+
+ Remove a bunch of xfails.
+
+commit 7e37eaaf772f48906e69618c773b0a36c3927de9
+Author: Anthony Green <green@gmachine.(none)>
+Date: Sat Dec 26 07:46:50 2009 -0500
+
+ Fix huge_struct for solaris
+
+commit 07cc7a37194bc34064ebed7f2724333a798411c8
+Author: Anthony Green <green@gmachine.(none)>
+Date: Sat Dec 26 07:23:04 2009 -0500
+
+ 3.0.9rc8
+
+commit 2b9be16ffabc81326128bc1bbdddff8ddc5d13d3
+Author: Anthony Green <green@gmachine.(none)>
+Date: Sat Dec 26 07:04:45 2009 -0500
+
+ 3.0.9rc8
+
+commit 9458d88f676e9a21ab8993a54e16754b11687419
+Author: Anthony Green <green@gmachine.(none)>
+Date: Sat Dec 26 07:02:27 2009 -0500
+
+ Rebase from GCC
+
+commit 6a3412417593f068a04dc6163f4269cb295ad5ca
+Author: Anthony Green <green@gmachine.(none)>
+Date: Sat Dec 26 06:51:33 2009 -0500
+
+ Add Andreas Schwab's powerpc fix
+
+commit 39c8792ece1043f41f4c395a2ce71f4cf0ff4674
+Author: Anthony Green <green@gmachine.(none)>
+Date: Fri Dec 25 21:52:28 2009 -0500
+
+ 3.0.9rc7
+
+commit 1d04af52e3e24db69f742064694c22f8df5cc70e
+Author: Anthony Green <green@gmachine.(none)>
+Date: Fri Dec 25 09:50:36 2009 -0500
+
+ Updated some mips XFAILs
+
+commit 26e9509c9b7929bc4fcf697071699051a652b1fd
+Author: Anthony Green <green@gmachine.(none)>
+Date: Fri Dec 25 02:19:23 2009 -0500
+
+ Clean up ChangeLog.libffi for older patches.
+
+commit 9c157d3215e4393777f83eb6fa801df6528f40d7
+Author: Anthony Green <green@gmachine.(none)>
+Date: Fri Dec 25 02:15:40 2009 -0500
+
+ Clean up undefine_AC_ARG_VAR_PRECIOUS patch.
+
+commit d22de05b0bfc480766bc1240615ce2830eee71b8
+Author: Anthony Green <green@gmachine.(none)>
+Date: Fri Dec 25 02:04:23 2009 -0500
+
+ Fix patches
+
+commit 1fe3dc7c20dc4dbd8fed0d19c8618027d44ed971
+Author: Anthony Green <green@gmachine.(none)>
+Date: Fri Dec 25 01:39:00 2009 -0500
+
+ Add windows support patch.
+
+commit f7c0bc613a88f7dbc2d18b345c10fa438833c170
+Author: Anthony Green <green@gmachine.(none)>
+Date: Fri Dec 25 01:22:11 2009 -0500
+
+ 3.0.9rc6
+
+commit c7fa2da8260258c11ab1dc7ac06fb611a2c1b50f
+Author: Anthony Green <green@gmachine.(none)>
+Date: Thu Dec 24 07:22:44 2009 -0500
+
+ 3.0.9rc6
+
+commit da11bece0fde66fc0268db3a01207dda857e25d2
+Author: Anthony Green <green@gmachine.(none)>
+Date: Thu Dec 24 05:34:46 2009 -0500
+
+ Release 3.0.9rc5
+
+commit e3399b11edeab546b066bfc18574f3edb905d0dc
+Author: Anthony Green <green@gmachine.(none)>
+Date: Thu Dec 24 01:09:32 2009 -0500
+
+ Update README
+
+commit 115ab36fceee69740a01ce49bc27e1908cc237b1
+Author: Anthony Green <green@gmachine.(none)>
+Date: Thu Dec 24 00:22:00 2009 -0500
+
+ Update missing changes for 3.0.9r4.
+
+commit f8c7a245bf5a80bd7e730ec03fcad17c8dcfcb07
+Author: Anthony Green <green@gmachine.(none)>
+Date: Wed Dec 23 23:46:22 2009 -0500
+
+ Switch to quilt. Rebase to latest GCC.
+
+commit ce806772f02387b9a74f6496a263a368bccd5d59
+Merge: cd98813 dcc1f6b
+Author: Anthony Green <green@moxielogic.com>
+Date: Mon Oct 5 00:41:35 2009 -0400
+
+ Merge branch 'master' of git@github.com:atgreen/libffi
+
+commit dcc1f6b4f1ffd2713bf68b791a13f85d455c8b1b
+Author: Anthony Green <green@moxielogic.com>
+Date: Mon Oct 5 00:29:33 2009 -0400
+
+ More clean up.
+
+commit 2829f5941a223b9d851d8ab6318318e6197d7e01
+Author: Anthony Green <green@moxielogic.com>
+Date: Mon Oct 5 00:28:03 2009 -0400
+
+ Clean up
+
+commit cd98813de517ea64041637e3e78d27a001d6d3b4
+Author: Anthony Green <green@moxielogic.com>
+Date: Mon Oct 5 00:25:29 2009 -0400
+
+ From Jens Rehsack. Fix for 64-bit AIX.
+
+commit e4a91de766acc47f6c50f13cc11719a65e23ecba
+Author: Anthony Green <green@moxielogic.com>
+Date: Mon Oct 5 00:16:17 2009 -0400
+
+ From Abdulaziz Ghuloum. Adds special case for Snow Leopard.
+
+commit 3425a763bcdaadb8b430226f427ec833afdcc96a
+Author: Anthony Green <green@moxielogic.com>
+Date: Sun Oct 4 23:57:29 2009 -0400
+
+ Fix detection of free/openbsd. From Alexis Ballier.
+
+commit 2340e7a777902de61499d47823ad8d5e0eeb6203
+Author: Anthony Green <green@moxielogic.com>
+Date: Sun Oct 4 23:53:17 2009 -0400
+
+ AVR support
+
+commit 5cbe2058c128e848446ae79fe15ee54260a90559
+Author: Anthony Green <green@moxielogic.com>
+Date: Sun Oct 4 23:53:11 2009 -0400
+
+ Initial stand-alone patch.
+
+commit c6dddbd02bad9654ed58cdb0feb360934d105dec
+Author: Anthony Green <green@moxielogic.com>
+Date: Sun Oct 4 08:11:33 2009 -0400
+
+ Initial commit
+
+commit 5ffc0c37486fb1538bccc0ca7acc807d4f1af932
+Author: Anthony Green <green@moxielogic.com>
+Date: Sun Oct 4 07:58:22 2009 -0400
+
+ Update version to 3.0.9rc1. Add more useful things to .gitignore.
+
+commit bd29f83ee9f6fa6b65adee9d3f57834f364d9887
+Author: Anthony Green <green@moxielogic.com>
+Date: Tue Sep 29 12:07:26 2009 -0400
+
+ Add .gitignore
+
+commit 9474f853f83e3f0167c1b306177321bfcc93e56d
+Author: Anthony Green <green@moxielogic.com>
+Date: Tue Sep 29 11:13:02 2009 -0400
+
+ Remove old CVSROOT files.
+
+commit 0c25275ec24bfe2c2c25a000465f0950ef9dd51b
+Author: twall <twall>
+Date: Wed Aug 19 12:57:34 2009 +0000
+
+ Apply Dave Korn's cygwin/GCC changes
+
+commit 39228c27ed3f677a95b46380a8d31602b5777e1a
+Author: aph <aph>
+Date: Tue Jun 16 18:00:47 2009 +0000
+
+ 2009-06-16 Wim Lewis <wiml@hhhh.org>
+
+ * src/powerpc/ffi.c: Avoid clobbering cr3 and cr4, which are
+ supposed to be callee-saved.
+ * src/powerpc/sysv.S (small_struct_return_value): Fix overrun of
+ return buffer for odd-size structs.
+
+commit 5e93cc704d127c2c8ae7f5d2cef621145d43e777
+Author: aph <aph>
+Date: Tue Jun 16 17:41:47 2009 +0000
+
+ 2009-06-16 Andreas Tobler <a.tobler@schweiz.org>
+
+ PR libffi/40444
+ * testsuite/lib/libffi-dg.exp (libffi_target_compile): Add
+ allow_stack_execute for Darwin.
+
+commit b509af8959dc371b92392c623522ea6f4946a71d
+Author: aph <aph>
+Date: Tue Jun 16 16:17:52 2009 +0000
+
+ 2009-06-16 Andrew Haley <aph@redhat.com>
+
+ * configure.ac (TARGETDIR): Add missing blank lines.
+ * configure: Regenerate.
+
+commit d57e96dc56ee76fbbb9b59d73aeaa92354db5ecb
+Author: aph <aph>
+Date: Tue Jun 16 09:59:02 2009 +0000
+
+ 2009-06-16 Andrew Haley <aph@redhat.com>
+
+ * testsuite/libffi.call/cls_align_sint64.c,
+ testsuite/libffi.call/cls_align_uint64.c,
+ testsuite/libffi.call/cls_longdouble_va.c,
+ testsuite/libffi.call/cls_ulonglong.c,
+ testsuite/libffi.call/return_ll1.c,
+ testsuite/libffi.call/stret_medium2.c: Fix printf format
+ specifiers.
+ * testsuite/libffi.call/huge_struct.c: Ad x86 XFAILs.
+ * testsuite/libffi.call/float2.c: Fix dg-excess-errors.
+ * testsuite/libffi.call/ffitest.h,
+ testsuite/libffi.special/ffitestcxx.h (PRIdLL, PRIuLL): Define.
+
+commit b01d6d1982c9e020507029bfd5a58a8c60d111fa
+Author: aph <aph>
+Date: Tue Jun 16 09:44:54 2009 +0000
+
+ 2009-06-16 Andrew Haley <aph@redhat.com>
+
+ * testsuite/libffi.call/err_bad_typedef.c: xfail everywhere.
+ * testsuite/libffi.call/err_bad_abi.c: Likewise.
+
+commit 35b6ded138591900a88055a8a8ac1fadc29a76d6
+Author: aph <aph>
+Date: Fri Jun 12 15:29:20 2009 +0000
+
+ 2009-06-11 Kaz Kojima <kkojima@gcc.gnu.org>
+
+ * testsuite/libffi.call/cls_longdouble_va.c: Add xfail sh*-*-linux-*.
+ * testsuite/libffi.call/err_bad_abi.c: Add xfail sh*-*-*.
+ * testsuite/libffi.call/err_bad_typedef.c: Likewise.
+
+commit acc46605f2d95d67d69398e7644610f10a157ce3
+Author: aph <aph>
+Date: Fri Jun 12 14:21:28 2009 +0000
+
+ 2009-06-12 Andrew Haley <aph@redhat.com>
+
+ * ChangeLog.libffi: testsuite/libffi.call/cls_align_sint64.c,
+ testsuite/libffi.call/cls_align_uint64.c,
+ testsuite/libffi.call/cls_ulonglong.c,
+ testsuite/libffi.call/return_ll1.c,
+ testsuite/libffi.call/stret_medium2.c: Fix printf format
+ specifiers.
+ testsuite/libffi.special/unwindtest.cc: include stdint.h.
+
+commit 16d1996ed0797bd7c11aca2b0fe7e7748751aaf6
+Author: twall <twall>
+Date: Thu Jun 11 14:27:42 2009 +0000
+
+ update changelog
+
+commit 92a515c33efe91be3cb0258f01c63aff208489c7
+Author: twall <twall>
+Date: Thu Jun 11 14:27:28 2009 +0000
+
+ use ffi_closure_alloc instead of stack-based closure
+
+commit e4363160ba9e50167f9ca0a7399d537a1d2cd0ce
+Author: twall <twall>
+Date: Thu Jun 11 14:26:23 2009 +0000
+
+ remove unused extern
+
+commit 1dc2781d2ba38f5f000ff70069d617fb21e1d2af
+Author: twall <twall>
+Date: Thu Jun 11 11:36:16 2009 +0000
+
+ remove not-yet-applied changelog entries
+
+commit bb27735fe689dac97ec0dc847ed8d3d519620109
+Author: twall <twall>
+Date: Wed Jun 10 10:42:36 2009 +0000
+
+ add win64 support
+
+commit b2a54c100c74854a409820817d54617fdda39eb8
+Author: aph <aph>
+Date: Mon Jun 8 16:50:49 2009 +0000
+
+ 2009-06-08 Andrew Haley <aph@redhat.com>
+
+ * testsuite/libffi.call/err_bad_abi.c: Add xfails.
+ * testsuite/libffi.call/cls_longdouble_va.c: Add xfails.
+ * testsuite/libffi.call/cls_dbls_struct.c: Add xfail x86_64-*-linux-*.
+ * testsuite/libffi.call/err_bad_typedef.c: Add xfails.
+
+ * testsuite/libffi.call/stret_medium2.c: Add __UNUSED__ to args.
+ * testsuite/libffi.call/stret_medium.c: Likewise.
+ * testsuite/libffi.call/stret_large2.c: Likewise.
+ * testsuite/libffi.call/stret_large.c: Likewise.
+
+commit 25723e7141f73d3736d7244b980c89d97db852b6
+Author: aph <aph>
+Date: Fri Jun 5 13:03:40 2009 +0000
+
+ 2009-06-05 Andrew Haley <aph@redhat.com>
+
+ * src/x86/win32.S (_ffi_closure_STDCALL): Import from gcc.
+
+commit 70758199c7cd41f411987360ccb302b497a56dc9
+Author: aph <aph>
+Date: Thu Jun 4 16:29:58 2009 +0000
+
+ 2009-06-04 Andrew Haley <aph@redhat.com>
+
+ * src/powerpc/ffitarget.h: Fix misapplied merge from gcc.
+
+commit e8bb12563f9aa23ddf36fa6a5b92b16b5c3e1a7f
+Author: aph <aph>
+Date: Thu Jun 4 14:59:18 2009 +0000
+
+ 2009-06-04 Andrew Haley <aph@redhat.com>
+
+ * src/mips/o32.S,
+ src/mips/n32.S: Fix licence formatting.
+
+commit d66a8e32c3671479e3ce0f6819673e5932ba6b7f
+Author: aph <aph>
+Date: Thu Jun 4 14:43:40 2009 +0000
+
+ 2009-06-04 Andrew Haley <aph@redhat.com>
+
+ * src/x86/darwin.S: Fix licence formatting.
+ src/x86/win32.S: Likewise.
+ src/sh64/sysv.S: Likewise.
+ src/sh/sysv.S: Likewise.
+
+commit 7c3b7fd6b5db746b5b09a718f3044f811372f941
+Author: aph <aph>
+Date: Thu Jun 4 14:39:20 2009 +0000
+
+ 2009-06-04 Andrew Haley <aph@redhat.com>
+
+ * src/sh64/ffi.c: Remove lint directives. Was missing from merge
+ of Andreas Tobler's patch from 2006-04-22.
+
+commit 1a2f93a8b362db13638afd9fcb3f2650180bfa17
+Author: aph <aph>
+Date: Thu Jun 4 10:45:51 2009 +0000
+
+ 2009-06-04 Andrew Haley <aph@redhat.com>
+
+ * src/sh/ffi.c: Apply missing hunk from Alexandre Oliva's patch of
+ 2007-03-07.
+
+commit 944c95cf7aaaaf7c5fa368cda4673dd38f45020e
+Author: aph <aph>
+Date: Wed Jun 3 17:42:56 2009 +0000
+
+ 2009-05-22 Dave Korn <dave.korn.cygwin@gmail.com>
+
+ * src/x86/win32.S (_ffi_closure_STDCALL): New function.
+ (.eh_frame): Add FDE for it.
+
+ 2009-05-22 Dave Korn <dave.korn.cygwin@gmail.com>
+
+ * configure.ac: Also check if assembler supports pc-relative
+ relocs on X86_WIN32 targets.
+ * configure: Regenerate.
+ * src/x86/win32.S (ffi_prep_args): Declare extern, not global.
+ (_ffi_call_SYSV): Add missing function type symbol .def and
+ add EH markup labels.
+ (_ffi_call_STDCALL): Likewise.
+ (_ffi_closure_SYSV): Likewise.
+ (_ffi_closure_raw_SYSV): Likewise.
+ (.eh_frame): Add hand-crafted EH data.
+
+ 2008-11-21 Eric Botcazou <ebotcazou@adacore.com>
+
+ * src/sparc/ffi.c (ffi_prep_cif_machdep): Add support for
+ signed/unsigned int8/16 return values.
+ * src/sparc/v8.S (ffi_call_v8): Likewise.
+ (ffi_closure_v8): Likewise.
+
+ 2008-03-26 Kaz Kojima <kkojima@gcc.gnu.org>
+
+ * src/sh/sysv.S: Add .note.GNU-stack on Linux.
+ * src/sh64/sysv.S: Likewise.
+
+ 2008-03-26 Daniel Jacobowitz <dan@debian.org>
+
+ * src/arm/sysv.S: Fix ARM comment marker.
+
+commit 00fa972430bb1535a4b34bf029ebcad500027b0c
+Author: twall <twall>
+Date: Sat Dec 27 16:59:05 2008 +0000
+
+ properly glob-match
+
+commit f5179e6794ac35af26fe86e468b8508a7a570c55
+Author: twall <twall>
+Date: Fri Dec 26 19:06:28 2008 +0000
+
+ Mark XFAIL on longdouble tests for x86_64/mingw
+
+commit 80e2b5a749208c8a18f994ec5bee84594d051cc8
+Author: twall <twall>
+Date: Mon Dec 22 15:21:15 2008 +0000
+
+ clean up tests for win64 use
+
+commit 7063d9996f742576095c7b0eb5016c0f9a670aec
+Author: green <green>
+Date: Fri Dec 19 16:13:46 2008 +0000
+
+ Version 3.0.8 with x86-solaris support
+
+commit bdfeb13f0df0a63b19d62597517237b54d92228b
+Author: green <green>
+Date: Fri Dec 19 15:47:44 2008 +0000
+
+ Bump to 3.0.7
+
+commit 69205de17d6ac4c11d4ba92d6a5b40a0c5f246b2
+Author: green <green>
+Date: Thu Jul 24 18:03:48 2008 +0000
+
+ Many test fixes (failures due to excessive compiler warnings).
+
+commit 260d513fea00b3613fe957a44a157fe72c4ca29e
+Author: green <green>
+Date: Thu Jul 17 13:13:52 2008 +0000
+
+ Version 3.0.6. sh/sh64 fixes.
+
+commit 3704031875feabb74e3655ed03cff4c2b3c76ac6
+Author: green <green>
+Date: Thu Apr 3 18:57:57 2008 +0000
+
+ Rev 3.0.5.
+
+commit 8406f5f48f7f58a1c982a93a95d521cf82b3241f
+Author: green <green>
+Date: Thu Apr 3 18:57:34 2008 +0000
+
+ 3.0.5
+
+commit 23a9e73212b62f9684cedb0ce70e92c59cfdaffa
+Author: green <green>
+Date: Wed Mar 5 00:07:02 2008 +0000
+
+ 2008-03-04 Anthony Green <green@redhat.com>
+ Blake Chaffin
+ hos@tamanegi.org
+
+ * testsuite/libffi.call/cls_align_longdouble_split2.c
+ testsuite/libffi.call/cls_align_longdouble_split.c
+ testsuite/libffi.call/cls_dbls_struct.c
+ testsuite/libffi.call/cls_double_va.c
+ testsuite/libffi.call/cls_longdouble.c
+ testsuite/libffi.call/cls_longdouble_va.c
+ testsuite/libffi.call/cls_pointer.c
+ testsuite/libffi.call/cls_pointer_stack.c
+ testsuite/libffi.call/err_bad_abi.c
+ testsuite/libffi.call/err_bad_typedef.c
+ testsuite/libffi.call/huge_struct.c
+ testsuite/libffi.call/stret_large2.c
+ testsuite/libffi.call/stret_large.c
+ testsuite/libffi.call/stret_medium2.c
+ testsuite/libffi.call/stret_medium.c: New tests from Apple.
+
+commit 429e37d3ad653e52e75bf725c883ab79e859f89a
+Author: green <green>
+Date: Thu Feb 28 04:50:19 2008 +0000
+
+ clicky
+
+commit 51e79c428348c033314f54bcb30f7e388c59e347
+Author: green <green>
+Date: Thu Feb 28 04:47:35 2008 +0000
+
+ getclicky
+
+commit affcab04e280efeace45a72c4dc6152c0e4f1b7f
+Author: green <green>
+Date: Tue Feb 26 19:01:53 2008 +0000
+
+ 2008-02-26 Jakub Jelinek <jakub@redhat.com>
+ Anthony Green <green@redhat.com>
+
+ * src/alpha/osf.S: Add .note.GNU-stack on Linux.
+ * src/s390/sysv.S: Likewise.
+ * src/powerpc/linux64.S: Likewise.
+ * src/powerpc/linux64_closure.S: Likewise.
+ * src/powerpc/ppc_closure.S: Likewise.
+ * src/powerpc/sysv.S: Likewise.
+ * src/x86/unix64.S: Likewise.
+ * src/x86/sysv.S: Likewise.
+ * src/sparc/v8.S: Likewise.
+ * src/sparc/v9.S: Likewise.
+ * src/m68k/sysv.S: Likewise.
+ * src/ia64/unix.S: Likewise.
+ * src/arm/sysv.S: Likewise.
+
+commit 59689d5522c159a3ac967adb6b891cf5f22c890f
+Author: green <green>
+Date: Tue Feb 26 17:40:51 2008 +0000
+
+ 2008-02-26 Anthony Green <green@redhat.com>
+ Thomas Heller <theller@ctypes.org>
+
+ * src/x86/ffi.c (ffi_closure_SYSV_inner): Change C++ comment to C
+ comment.
+
+commit b13c84cf4668828ff8429ba4a2f94cd1eb574ae0
+Author: green <green>
+Date: Tue Feb 26 17:38:15 2008 +0000
+
+ 2008-02-26 Anthony Green <green@redhat.org>
+ Thomas Heller <theller@ctypes.org>
+
+ * include/ffi.h.in: Change void (*)() to void (*)(void).
+
+commit 265289f679ffd24a88ae1aa2cef0e4aa14703cd8
+Author: green <green>
+Date: Tue Feb 26 17:34:36 2008 +0000
+
+ 2008-02-26 Anthony Green <green@spindazzle.org>
+
+ * src/alpha/ffi.c: Change void (*)() to void (*)(void).
+ src/alpha/osf.S, src/arm/ffi.c, src/frv/ffi.c, src/ia64/ffi.c,
+ src/ia64/unix.S, src/java_raw_api.c, src/m32r/ffi.c,
+ src/mips/ffi.c, src/pa/ffi.c, src/pa/hpux32.S, src/pa/linux.S,
+ src/powerpc/ffi.c, src/powerpc/ffi_darwin.c, src/raw_api.c,
+ src/s390/ffi.c, src/sh/ffi.c, src/sh64/ffi.c, src/sparc/ffi.c,
+ src/x86/ffi.c, src/x86/unix64.S, src/x86/darwin64.S,> src/x86/ffi64.c: Ditto.
+
+commit fb5036cd6d0f909918e90f7d2d9fd80d46682d5d
+Author: green <green>
+Date: Sun Feb 24 17:25:25 2008 +0000
+
+ fix date
+
+commit 40bec108e7d0181e6c9928aa7a33187bcc0f3d6f
+Author: green <green>
+Date: Sun Feb 24 17:25:02 2008 +0000
+
+ New release
+
+commit b922048fa82ea109a4af269ee47bbc2a586bbac2
+Author: green <green>
+Date: Sun Feb 24 17:24:00 2008 +0000
+
+ 2008-02-24 Anthony Green <green@spindazzle.org>
+
+ * configure.ac: Accept openbsd*, not just openbsd.
+ Bump version to 3.0.4.
+ * configure, doc/stamp-vti, doc/version.texi: Rebuilt.
+ * libtool-version: Increment revision.
+ * README: Update for new release.
+
+commit affca4b92d06e5554784c7e9b233029ef83f7d8a
+Author: green <green>
+Date: Fri Feb 22 21:53:29 2008 +0000
+
+ sync readme with web page.
+
+commit 3e53d8752ea74859b4c64fbbf935e62a937c4d78
+Author: green <green>
+Date: Fri Feb 22 21:52:38 2008 +0000
+
+ New release
+
+commit 4d92f6c8e78fe084be65f3e8b58b859901ba796d
+Author: green <green>
+Date: Fri Feb 22 21:49:46 2008 +0000
+
+ 2008-02-22 Anthony Green <green@redhat.com>
+
+ * configure.ac: Bump version to 3.0.3.
+ * configure, doc/stamp-vti, doc/version.texi: Rebuilt.
+ * libtool-version: Increment revision.
+ * README: Update for new release. Clean up test docs.
+
+commit 0e185fa11a01f816824ba2687ed3715ab6219bef
+Author: green <green>
+Date: Fri Feb 22 21:43:18 2008 +0000
+
+ Update configure script.
+
+commit f73986bd211cfbbaa593d1309504d0dc68626191
+Author: green <green>
+Date: Fri Feb 22 21:40:53 2008 +0000
+
+ 2008-02-22 Bjoern Koenig <bkoenig@alpha-tierchen.de>
+ Andreas Tobler <a.tobler@schweiz.org>
+
+ * configure.ac: Add amd64-*-freebsd* target.
+ * configure: Regenerate.
+
+commit 0208f68fe5de30c33e7f70ebc281635917013f5a
+Author: green <green>
+Date: Fri Feb 22 21:15:44 2008 +0000
+
+ 2008-02-22 Thomas Heller <theller@ctypes.org>
+
+ * configure.ac: Add x86 OpenBSD support.
+ * configure: Rebuilt.
+
+commit 01adb0e638a86cf0d5e668ed8e08be9b0cd2505f
+Author: green <green>
+Date: Thu Feb 21 16:17:26 2008 +0000
+
+ Fix README.
+
+commit 1edd4563225981a14f7d4fb9919b1ed88e38082f
+Author: green <green>
+Date: Thu Feb 21 13:39:01 2008 +0000
+
+ 3.0.2
+
+commit c9b542800864e2204db6e83f3843a17813ba6165
+Author: green <green>
+Date: Thu Feb 21 13:36:43 2008 +0000
+
+ add missing file
+
+commit d5fa5633d5c8d3c212a2267cfa38fba4091baa2c
+Author: green <green>
+Date: Thu Feb 21 13:36:19 2008 +0000
+
+ 2008-02-21 Anthony Green <green@redhat.com>
+
+ * configure.ac: Bump version to 3.0.2.
+ * configure, doc/stamp-vti, doc/version.texi: Rebuilt.
+ * libtool-version: Increment revision.
+ * README: Update for new release.
+
+ 2008-02-21 Björn König <bkoenig@alpha-tierchen.de>
+
+ * src/x86/freebsd.S: New file.
+ * configure.ac: Add x86 FreeBSD support.
+ * Makefile.am: Ditto.
+
+commit ac35bfc6fcadd8880c1efce36724820f9074b318
+Author: green <green>
+Date: Sat Feb 16 01:03:56 2008 +0000
+
+ Updated
+
+commit f7942975fee7b0162647dd79e2652615b737e98e
+Author: green <green>
+Date: Sat Feb 16 01:02:00 2008 +0000
+
+ 2008-02-15 Anthony Green <green@redhat.com>
+
+ * configure.ac: Bump version to 3.0.1.
+ * configure, doc/stamp-vti, doc/version.texi: Rebuilt.
+ * libtool-version: Increment revision.
+ * README: Update for new release.
+
+ 2008-02-15 David Daney <ddaney@avtrex.com>
+
+ * src/mips/ffi.c: Remove extra '>' from include directive.
+ (ffi_prep_closure_loc): Use clear_location instead of tramp.
+
+commit 59aa6bb1bfc86a610ac1a8b123443efd75854dd1
+Author: green <green>
+Date: Fri Feb 15 20:52:26 2008 +0000
+
+ Add more platforms.
+
+commit 45a45ab99074448be0ae1a8d2ade50d28b60f8de
+Author: green <green>
+Date: Fri Feb 15 19:16:36 2008 +0000
+
+ 3.0 notes
+
+commit 4db74cbea888c9f1251b85baf00d99b83d3b994d
+Author: green <green>
+Date: Fri Feb 15 19:10:26 2008 +0000
+
+ Update
+
+commit c3e1101ffabf44d8a2ee46e03ba9ab582050a825
+Author: green <green>
+Date: Fri Feb 15 18:43:40 2008 +0000
+
+ 2008-02-15 Anthony Green <green@redhat.com>
+
+ * configure.ac: Bump version to 3.0.0,
+ * configure, doc/stamp-vti, doc/version.texi: Rebuilt.
+
+ 2008-02-15 David Daney <ddaney@avtrex.com>
+
+ * src/mips/ffi.c (USE__BUILTIN___CLEAR_CACHE):
+ Define (conditionally), and use it to include cachectl.h.
+ (ffi_prep_closure_loc): Fix cache flushing.
+ * src/mips/ffitarget.h (_ABIN32, _ABI64, _ABIO32): Define.
+
+commit 7e0cc12e9233ad285db41ce8dbdda61ed2a7fb06
+Author: green <green>
+Date: Fri Feb 15 15:51:03 2008 +0000
+
+ New release
+
+commit 2d7dc885ec40d53866f29984d595511942c8b686
+Author: green <green>
+Date: Fri Feb 15 15:30:26 2008 +0000
+
+ * man/ffi_call.3, man/ffi_prep_cif.3, man/ffi.3:
+ Update dates and remove all references to ffi_prep_closure.
+ * configure.ac: Bump version to 2.99.9.
+ * configure, doc/stamp-vti, doc/version.texi: Rebuilt.
+
+commit a0525f03eeaaed33b1eac80e0c016455cee3615d
+Author: green <green>
+Date: Fri Feb 15 15:14:30 2008 +0000
+
+ New release.
+
+commit 2b30dfb3146ee26ad956d00ee05eb835ca1a95b4
+Author: green <green>
+Date: Fri Feb 15 15:12:43 2008 +0000
+
+ * man/ffi_prep_closure.3: Delete.
+ * man/Makefile.am (EXTRA_DIST): Remove ffi_prep_closure.3.
+ (man_MANS): Ditto.
+ * man/Makefile.in: Rebuilt.
+ * configure.ac: Bump version to 2.99.8.
+ * configure, doc/stamp-vti, doc/version.texi: Rebuilt.
+
+commit bf41e64840ebcb6cc31a6f028253c1fde82705d8
+Author: green <green>
+Date: Fri Feb 15 01:56:50 2008 +0000
+
+ Update.
+
+commit 4d39ddee677bbb61d621893b91e11eac5e7c4af7
+Author: green <green>
+Date: Fri Feb 15 01:24:06 2008 +0000
+
+ * configure.ac: Bump version to 2.99.7.
+ * configure, doc/stamp-vti, doc/version.texi: Rebuilt.
+ * include/ffi.h.in LICENSE src/debug.c src/closures.c
+ src/ffitest.c src/s390/sysv.S src/s390/ffitarget.h
+ src/types.c src/m68k/ffitarget.h src/raw_api.c src/frv/ffi.c
+ src/frv/ffitarget.h src/sh/ffi.c src/sh/sysv.S
+ src/sh/ffitarget.h src/powerpc/ffitarget.h src/pa/ffi.c
+ src/pa/ffitarget.h src/pa/linux.S src/java_raw_api.c
+ src/cris/ffitarget.h src/x86/ffi.c src/x86/sysv.S
+ src/x86/unix64.S src/x86/win32.S src/x86/ffitarget.h
+ src/x86/ffi64.c src/x86/darwin.S src/ia64/ffi.c
+ src/ia64/ffitarget.h src/ia64/ia64_flags.h src/ia64/unix.S
+ src/sparc/ffi.c src/sparc/v9.S src/sparc/ffitarget.h
+ src/sparc/v8.S src/alpha/ffi.c src/alpha/ffitarget.h
+ src/alpha/osf.S src/sh64/ffi.c src/sh64/sysv.S
+ src/sh64/ffitarget.h src/mips/ffi.c src/mips/ffitarget.h
+ src/mips/n32.S src/mips/o32.S src/arm/ffi.c src/arm/sysv.S
+ src/arm/ffitarget.h src/prep_cif.c: Update license text.
+
+commit d58b032b41a12bd3d72148da6822ab59dd698ff9
+Author: green <green>
+Date: Fri Feb 15 00:59:25 2008 +0000
+
+ New release
+
+commit 91e5478df6d5ac63efbb10f025807b4606afab56
+Author: green <green>
+Date: Fri Feb 15 00:50:30 2008 +0000
+
+ Update supported platforms. Bump version.
+
+commit bd0768f877c8f7fd0d36af2191b203d4d057b1ce
+Author: green <green>
+Date: Fri Feb 15 00:45:33 2008 +0000
+
+ * configure.ac: Bump version to 2.99.5.
+ * configure: Rebuilt.
+ * Makefile.am (EXTRA_DIST): Add darwin64.S
+ * Makefile.in: Rebuilt.
+ * testsuite/lib/libffi-dg.exp: Remove libstdc++ bits from GCC tree.
+ * LICENSE: Update WARRANTY.
+
+commit 49d345f767bd2cfee951bceaab6a1a07986cf293
+Author: green <green>
+Date: Thu Feb 14 23:43:27 2008 +0000
+
+ update license reference
+
+commit 12ac48fc79b515db7c9accd9fcaa87b0dcefccdb
+Author: green <green>
+Date: Thu Feb 14 23:42:08 2008 +0000
+
+ Update WARRANTY
+
+commit 6b91c41da87e78552f2990dfc504a0a3349f340b
+Author: green <green>
+Date: Thu Feb 14 23:38:27 2008 +0000
+
+ fix tarball reference
+
+commit 2b59579e3533334bee4788e076b4e520c2ab518c
+Author: green <green>
+Date: Thu Feb 14 23:35:58 2008 +0000
+
+ First update in 5 years!
+
+commit 6cbdf3f3a3777a93382a2d508ddef1c353ff0955
+Author: green <green>
+Date: Thu Feb 14 22:44:06 2008 +0000
+
+ Fix .pc file bug and bump version
+
+commit 1d1dc81104b209df3cfef0840735c59efae2f655
+Author: green <green>
+Date: Thu Feb 14 22:03:37 2008 +0000
+
+ Add man files and info file. Update README. Tag as 2.99.3.
+
+commit f045a2367f793fa8b01534cf2e25bcc46afc8fa1
+Author: tromey <tromey>
+Date: Thu Feb 14 20:46:57 2008 +0000
+
+ Move entry from ChangeLog to ChangeLog.libffi
+
+commit 6257f07d1a9efd27fa83639cfba281f5d3188731
+Author: tromey <tromey>
+Date: Thu Feb 14 20:33:17 2008 +0000
+
+ * aclocal.m4, Makefile.in, configure, fficonfig.h.in: Rebuilt.
+ * mdate-sh, texinfo.tex: New files.
+ * Makefile.am (info_TEXINFOS): New variable.
+ * doc/libffi.texi: New file.
+ * doc/version.texi: Likewise.
+
+commit 4232af563c5509c3760a33e3684a2b958be755e1
+Author: green <green>
+Date: Thu Feb 14 16:19:21 2008 +0000
+
+ * Makefile.am (AM_CFLAGS): Don't compile with -D.
+ (lib_LTLIBRARIES): Define.
+ (toolexeclib_LIBRARIES): Undefine.
+ * Makefile.in: Rebuilt.
+ * configure.ac: Reset version to 2.99.1.
+ * configure.in: Rebuilt.
+
+commit 961543615c31f092b578a4b4cda914db64f9d0fa
+Author: green <green>
+Date: Thu Feb 14 15:57:40 2008 +0000
+
+ Fix typo.
+
+commit aeb0abab87222f637fbf352d4effd3b76b52ed26
+Author: green <green>
+Date: Thu Feb 14 15:54:27 2008 +0000
+
+ * libffi.pc.in: Usse @PACKAGE_NAME@ and @PACKAGE_VERSION@.
+ * configure.ac: Reset version to 2.99.1.
+ * configure.in: Rebuilt.
+ * Makefile.am (EXTRA_DIST): Add ChangeLog.libffi.
+ * Makefile.in: Rebuilt.
+ * LICENSE: Update copyright notice.
+
+commit 77fe243556433eae119d8bd7469bfccdd5bd8a1a
+Author: green <green>
+Date: Thu Feb 14 15:37:00 2008 +0000
+
+ Fix make dist again
+
+commit d4970cf4529459bf0f0e43c602cac396786c6802
+Author: green <green>
+Date: Thu Feb 14 15:18:56 2008 +0000
+
+ Fix make dist
+
+commit f0b1462f2d3024922ad71421bd5c4311fcb16da5
+Author: green <green>
+Date: Thu Feb 14 15:01:41 2008 +0000
+
+ Use pkgconfig. Increment libtool CURRENT version.
+
+commit 27e52f33baa069012a5adb2a3807f9ca1f2165ab
+Author: green <green>
+Date: Sun Feb 3 13:59:48 2008 +0000
+
+ Fix header installs when using DESTDIR.
+
+commit fadab28eb6e33fb6dcdd7b9323e147142216d548
+Author: twall <twall>
+Date: Sun Feb 3 12:32:22 2008 +0000
+
+ update changelog
+
+commit b5e44c8dfa92c87b99762c303cf5574a16db8f27
+Author: twall <twall>
+Date: Sun Feb 3 01:12:32 2008 +0000
+
+ offset from code base address, not data base address
+
+commit f359848d1a995c0e44566d815f218729dc996e22
+Author: green <green>
+Date: Fri Feb 1 21:29:43 2008 +0000
+
+ Fix header installs.
+
+commit c30df49e157c7bfc8e19e3f8a72b9464fe225e54
+Author: green <green>
+Date: Fri Feb 1 21:13:55 2008 +0000
+
+ Revert my broken changes to twall's patch.
+
+commit 675561bb9aa0732c76698df10dd3007b5d0ec759
+Author: green <green>
+Date: Thu Jan 31 13:44:25 2008 +0000
+
+ Fix make dist .
+
+commit abc0bbf3813dc43e23d4c23e6fe794dbf287639b
+Author: green <green>
+Date: Thu Jan 31 11:58:57 2008 +0000
+
+ Add Tim Wall's x86 windows patch.
+
+commit e332366d15a31198735b593ec8f7fc0558d783b8
+Author: green <green>
+Date: Wed Jan 30 13:21:02 2008 +0000
+
+ Add HJ's -fomit-frame-pointer struct return fix
+
+commit d4204240392af5b7750a08671b08e9c22dff5e93
+Author: green <green>
+Date: Wed Jan 30 12:42:34 2008 +0000
+
+ Clean up for new automake.
+
+commit f4932dd020df574637c9fb3fc1bb18e5a8f304cc
+Author: green <green>
+Date: Wed Jan 30 12:40:25 2008 +0000
+
+ Fixes to run testsuite
+
+commit 085520ddc8db6a916bfc416b871fcb2d00074d40
+Author: green <green>
+Date: Tue Jan 29 15:16:43 2008 +0000
+
+ New files from gcc tree.
+
+commit 77175b3f7234e4875a4ef554ed1fe9fdc4133794
+Author: green <green>
+Date: Tue Jan 29 15:15:20 2008 +0000
+
+ Latest gcc svn sources
+
+commit 2544e45a0b2b634053df02da3a2ed9680eeed2a1
+Author: green <green>
+Date: Tue Jan 29 14:28:13 2008 +0000
+
+ Install ffitarget.h in $prefix/include.
+
+commit 6002211b1cc4daeb587d054b4f83968bda2c981e
+Author: green <green>
+Date: Tue Jan 29 12:30:10 2008 +0000
+
+ Add new files.
+
+commit ccabd2b16be883cd03e5f0cd88ccfdd6ca39239d
+Author: green <green>
+Date: Tue Jan 29 12:28:15 2008 +0000
+
+ Merge from gcc
+
+commit e680ecfbfca1da8d1823e48bc89b8375e66e128b
+Author: tromey <tromey>
+Date: Sun Dec 24 23:12:15 2006 +0000
+
+ Pulled in libffi from gcc trunk.
+ Fixed build and install for standalone use.
+
+commit e7ba08965942ce872fdbc69f70f9848cc3d0bad6
+Author: root <root>
+Date: Sun Jun 4 23:22:24 2006 +0000
+
+ sourcware.org
+
+commit 0cd4aa24e21aaa964dfbdebc25ec5c8188049375
+Author: root <root>
+Date: Sun May 30 01:51:57 2004 +0000
+
+ Add LockDir
+
+commit 5826120fbd940d26cca76ed2522187505581e1ed
+Author: green <green>
+Date: Tue Nov 4 06:09:08 2003 +0000
+
+ Add link to Gianni's web site.
+
+commit 220aa4b27db42d7ffaac5056000d5179f00d5ea3
+Author: jsm <jsm>
+Date: Tue Jan 21 08:07:42 2003 +0000
+
+ Newer, better, increased from before! (list of acceptable anon usernames)
+
+commit 1c3adc892cc1403dc4d3d7003a2385899836612e
+Author: green <green>
+Date: Fri Dec 6 01:28:03 2002 +0000
+
+ Fixed Cygnus references.
+
+commit 4af66bb62fab9a8e318af3bf01e5486596a0c8d4
+Author: green <green>
+Date: Sun Oct 21 19:18:42 2001 +0000
+
+ Testsuite fixes.
+
+commit 5435965f9015ce40584c98d3816c3d05e7de1d21
+Author: green <green>
+Date: Mon Apr 23 00:32:03 2001 +0000
+
+ * include/ffi_common.h: Delete, after moving contents to...
+ * include/ffi_private.h: Subsume contents of ffi_common.h.
+ * include/Makefile.am (noinst_HEADERS): Remove ffi_common.h.
+ * include/Makefile.in: Rebuilt.
+ * arm/ffi.c, m68k/ffi.c, mips/ffi.c, powerpc/ffi.c, s390/ffi.c,
+ ia64/ffi.c: Include ffi_private.h, not ffi_common.h.
+ * alpha/ffi.c, sparc/ffi.c, x86/ffi.c: Don't include ffi_common.h.
+ * types.c, raw_api.c, java_raw_api.c, prep_cif.c: Don't include
+ ffi_common.h.
+ * debug.c: Include ffi_private.h instead of ffi_common.h.
+
+ * mips/ffi.c (calc_n32_struct_flags): Make static.
+ (FIX_ARGP): Remove call to debugging routine ffi_stop_here.
+
+ * mips/n32.S: Include ffi_private.h.
+ * mips/o32.S: Include ffi_private.h.
+
+commit 6fdb7de0fe3b7385e1fd78812ae69d9b3069d994
+Author: green <green>
+Date: Sun Apr 22 19:38:34 2001 +0000
+
+ * README: Update some comments.
+
+ * Makefile.am (SUBDIRS): Add include so ffi.h gets installed.
+ * Makefile.in: Rebuilt.
+
+ * include/ffi.h: Change ALPHA to __alpha__ and SPARC to __sparc__.
+ * types.c: Ditto.
+ * prep_cif.c (ffi_prep_cif): Ditto.
+
+ * alpha/ffi.c, alpha/osf.S, sparc/ffi.c, sparc/v8.S, sparc/v9.S:
+ Include ffi_private.h.
+
+ * include/ffi_private.h (FFI_TYPE_LAST): Define.
+
+commit bc7144b01b9707ef35f1a2e3e6996e005e82953a
+Author: green <green>
+Date: Sun Apr 22 18:28:36 2001 +0000
+
+ Moved files from old home
+
+commit e57279831e20368c1aa1d2b35462b8629be73959
+Author: green <green>
+Date: Sun Apr 22 18:23:47 2001 +0000
+
+ These are dead.
+
+commit 7247436b5fe71767b29dc02b4da0fe18b08082e6
+Author: green <green>
+Date: Sun Apr 22 18:22:43 2001 +0000
+
+ All these files live somewhere else now.
+
+commit a8b0d40ff908e275028f676870c31d0d70274a98
+Author: green <green>
+Date: Sun Apr 22 18:17:14 2001 +0000
+
+ Many changes. Not quite there yet.
+
+commit f893d2273355710a290a26faebf5f12c3a34d0e3
+Author: green <green>
+Date: Sun Apr 22 18:13:22 2001 +0000
+
+ Moved m68k files
+
+commit 688ddfeced89cbb9d37b53005e1f7f2b9c78a8d7
+Author: green <green>
+Date: Sun Apr 22 18:12:33 2001 +0000
+
+ New, target indepentent, header
+
+commit f9e40776d488d5ecf43b3ae21444a1a2f6eca528
+Author: green <green>
+Date: Sun Apr 22 18:11:57 2001 +0000
+
+ Many changes.
+
+commit 8c1d2eb47f6bc314c431b75c85c107e8e43c4a76
+Author: green <green>
+Date: Sun Apr 22 18:10:47 2001 +0000
+
+ Many changes
+
+commit 1359dfc6582680a158b3caa3efb7a368da4aa12d
+Author: green <green>
+Date: Sun Apr 22 18:10:20 2001 +0000
+
+ Moved ia64 files
+
+commit 6e2de5eee316a4579869aff50c7c5f6f478582d8
+Author: green <green>
+Date: Sun Apr 22 18:08:11 2001 +0000
+
+ Moved arm files
+
+commit 8807355af34cba8ffe87aee51152dfccec2771fa
+Author: green <green>
+Date: Mon Apr 9 00:58:38 2001 +0000
+
+ Many many updates. Merge from gcc and then some.
+
+commit f7e9f91adec4ff1c2e7a13b3de81d2c5a3f55e7e
+Author: green <green>
+Date: Mon Apr 17 03:32:37 2000 +0000
+
+ Mnay fixes.
+
+commit c4860de618f4956283f5c8230a2544e403dfe390
+Author: green <green>
+Date: Mon Apr 17 03:18:46 2000 +0000
+
+ Merge from libgcj. Merged patches from net. See ChangeLog for details.
+
+commit c578b58314990c3853429297c38ba14015fec5fa
+Author: jsm <jsm>
+Date: Sat Oct 9 20:18:16 1999 +0000
+
+ 1999-10-09 Jason Molenda (jsm@bugshack.cygnus.com)
+
+ * CVSROOT/auto_checkout, CVSROOT/commit_prep, CVSROOT/log_accum:
+ Deleted; generic versions now used for all repositories.
+
+ * CVSROOT/commitinfo, CVSROOT/loginfo: Change pathnames to
+ generic versions.
+
+ * CVSROOT/checkoutlist: Don't try to check out the removed
+ files any longer.
+
+commit acdb20051207fed7652dd9f122f65de5458c474c
+Author: jsm <jsm>
+Date: Sat Oct 9 20:18:15 1999 +0000
+
+ 1999-10-09 Jason Molenda (jsm@bugshack.cygnus.com)
+
+ * CVSROOT/auto_checkout, CVSROOT/commit_prep, CVSROOT/log_accum:
+ Deleted; generic versions now used for all repositories.
+
+ * CVSROOT/commitinfo, CVSROOT/loginfo: Change pathnames to
+ generic versions.
+
+ * CVSROOT/checkoutlist: Don't try to check out the removed
+ files any longer.
+
+commit e75be655ceedf7ab24c4e99d75eec9efeb979bc7
+Author: green <green>
+Date: Sun Aug 8 13:16:41 1999 +0000
+
+ New configury
+
+commit d6669a0dd5b266005325bbf6d5a8ff34574d809e
+Author: green <green>
+Date: Sun Aug 8 13:05:12 1999 +0000
+
+ * include/ffi.h.in: Try to work around messy header problem
+ with PACKAGE and VERSION.
+
+ * configure: Rebuilt.
+ * configure.in: Change version to 2.00-beta.
+
+ * fficonfig.h.in: Rebuilt.
+ * acconfig.h (FFI_NO_STRUCTS, FFI_NO_RAW_API): Define.
+
+ * src/x86/ffi.c (ffi_raw_call): Rename.
+
+commit 4819d52b007934a40d6d29a75ee30e857c4a93ae
+Author: green <green>
+Date: Wed Aug 4 18:02:34 1999 +0000
+
+ New file for Kresten's closure work
+
+commit 2dbf801eb427cbf5021a9e1e512b5fc523524700
+Author: green <green>
+Date: Wed Aug 4 18:00:05 1999 +0000
+
+ Kresten's closure work. Initial checkin.
+
+commit d170961701b0f2bf7e824d7caba2ebe10002ed84
+Author: green <green>
+Date: Thu Jul 8 14:36:52 1999 +0000
+
+ * configure.in: Add x86 and powerpc BeOS configurations.
+ From Makoto Kato <m_kato@ga2.so-net.ne.jp>.
+
+commit c7747d976924ec6f2229cbcfbbdb98d364e10de9
+Author: jsm <jsm>
+Date: Wed May 12 23:32:16 1999 +0000
+
+ 1999-05-12 Jason Molenda (jsm@bugshack.cygnus.com)
+ * index.html: Add links to libffi* mail list archives.
+
+commit dd2aa9a8de22e26df3bbc85d068358641f6202f7
+Author: green <green>
+Date: Thu May 6 05:34:36 1999 +0000
+
+ * configure.in: Add warning about this being beta code.
+ Remove src/Makefile.am from the picture.
+ * configure: Rebuilt.
+ * Makefile.am: Move logic from src/Makefile.am. Add changes
+ to support libffi as a target library.
+ * Makefile.in: Rebuilt.
+ * aclocal.m4, config.guess, config.sub, ltconfig, ltmain.sh:
+ Upgraded to new autoconf, automake, libtool.
+ * README: Tweaks.
+ * LICENSE: Update copyright date.
+ * src/Makefile.am, src/Makefile.in: Removed.
+
+commit 4e9452abed58a3058ccdb446f96a29d50dda1f34
+Author: green <green>
+Date: Wed May 5 22:06:13 1999 +0000
+
+ Updated to new automake, libtool, autoconf - nothing works :-)
+
+commit 6d3b2bddaf4967fba8b8656c01bfc77ec0f2800c
+Author: jsm <jsm>
+Date: Mon Apr 26 15:55:28 1999 +0000
+
+ 1999-04-26 Jason Molenda (jsm@bugshack.cygnus.com)
+ * index.html: Missed a reference to libffi-discuss@cygnus.com. Fixed.
+
+commit ebc6a9c28af831d3d187af8ff17319f0f309bd98
+Author: jsm <jsm>
+Date: Mon Apr 26 15:53:29 1999 +0000
+
+ 1999-04-26 Jason Molenda (jsm@bugshack.cygnus.com)
+ * index.html: Change links to ftp directory to point to sourceware
+ directory.
+ Change mailing list subscription forms to point to sourceware lists.
+
+commit 78ffc52a8b257061348c576ccb6fbbf8b48b0fff
+Author: jsm <jsm>
+Date: Sun Apr 18 01:33:21 1999 +0000
+
+ Standard sourceware setup.
+
+commit b4d77e827d7ebef7e57ebcd71e71c15c62f1e0a8
+Author: jsm <jsm>
+Date: Mon Nov 30 11:11:25 1998 +0000
+
+ Small typeo. (I wouldn't bother except that it made the sentence hard
+ for me to parse on a casual read.)
+
+commit bfb73f08fdc987e37070c5fb0b196fbd28872888
+Author: jsm <jsm>
+Date: Mon Nov 30 10:44:55 1998 +0000
+
+ A few cleanups. Most notably, point to the correct subscribe cgi-bin
+ script.
+
+commit af8b7f037ccee3b7939ee226a1a2bbc2f057b35c
+Author: green <green>
+Date: Mon Nov 30 06:20:05 1998 +0000
+
+ * index.html: Reformatted and updated to reflect hosting on
+ sourceware.cygnus.com (new mailing lists, etc).
+
+commit 334f0b060942aff8d26badaf7dde7830450dc5da
+Author: green <green>
+Date: Sun Nov 29 16:56:12 1998 +0000
+
+ initial snapshot of documentation
+
+commit 3ab5cb4a1dcc7ecd7e773c97582b0099976c4753
+Author: green <green>
+Date: Sun Nov 29 16:56:10 1998 +0000
+
+ Initial revision
+
+commit d2a9eb5a8b7cbc8b769809cad59c82b975c178e2
+Merge: d3782ec bc75c54
+Author: green <green>
+Date: Sun Nov 29 16:48:16 1998 +0000
+
+ This commit was generated by cvs2svn to compensate for changes in r7, which
+ included commits to RCS files with non-trunk default branches.
+
+commit bc75c54bd311658005b065f1bf201b204c81cbca
+Author: green <green>
+Date: Sun Nov 29 16:48:16 1998 +0000
+
+ Import of v1 code.
+
+commit d3782ec8160c644421dcea17b605fec6e328f14e
+Author: jsm <jsm>
+Date: Fri Nov 20 20:18:00 1998 +0000
+
+ Send commit messages to mailing lists.
+
+commit 8d8d3843c484c2bb70d8375b2b799f75eb03f709
+Author: jsm <jsm>
+Date: Thu Oct 1 22:08:36 1998 +0000
+
+ initial checkin
+
+commit 49634f3bf221cc1939abafc788f7e4e31293fe73
+Author: jsm <jsm>
+Date: Thu Oct 1 22:08:35 1998 +0000
+
+ Add standard setup.
+
+commit c64a84c7693f8cd400fb94bba3c9bcfd9ad1fc36
+Author: jsm <jsm>
+Date: Thu Oct 1 22:08:34 1998 +0000
+
+ Add readers and standard modules file.
+
+commit 9813273b07fd082da573b3b6bfb8d23809b59eea
+Author: jsm <jsm>
+Date: Thu Oct 1 22:08:33 1998 +0000
+
+ initial checkin
diff --git a/jni/ruby/ext/fiddle/libffi-3.2.1/ChangeLog.libffi b/jni/ruby/ext/fiddle/libffi-3.2.1/ChangeLog.libffi
new file mode 100644
index 0000000..49ba8da
--- /dev/null
+++ b/jni/ruby/ext/fiddle/libffi-3.2.1/ChangeLog.libffi
@@ -0,0 +1,584 @@
+2011-02-08 Andreas Tobler <andreast@fgznet.ch>
+
+ * testsuite/lib/libffi.exp: Tweak for stand-alone mode.
+
+2009-12-25 Samuli Suominen <ssuominen@gentoo.org>
+
+ * configure.ac: Undefine _AC_ARG_VAR_PRECIOUS for autoconf 2.64.
+ * configure: Rebuilt.
+ * fficonfig.h.in: Rebuilt.
+
+2009-06-16 Andrew Haley <aph@redhat.com>
+
+ * testsuite/libffi.call/cls_align_sint64.c,
+ testsuite/libffi.call/cls_align_uint64.c,
+ testsuite/libffi.call/cls_longdouble_va.c,
+ testsuite/libffi.call/cls_ulonglong.c,
+ testsuite/libffi.call/return_ll1.c,
+ testsuite/libffi.call/stret_medium2.c: Fix printf format
+ specifiers.
+ * testsuite/libffi.call/huge_struct.c: Ad x86 XFAILs.
+ * testsuite/libffi.call/float2.c: Fix dg-excess-errors.
+ * testsuite/libffi.call/ffitest.h,
+ testsuite/libffi.special/ffitestcxx.h (PRIdLL, PRIuLL): Define.
+
+2009-06-12 Andrew Haley <aph@redhat.com>
+
+ * testsuite/libffi.call/cls_align_sint64.c,
+ testsuite/libffi.call/cls_align_uint64.c,
+ testsuite/libffi.call/cls_ulonglong.c,
+ testsuite/libffi.call/return_ll1.c,
+ testsuite/libffi.call/stret_medium2.c: Fix printf format
+ specifiers.
+ testsuite/libffi.special/unwindtest.cc: include stdint.h.
+
+2009-06-11 Timothy Wall <twall@users.sf.net>
+
+ * Makefile.am,
+ configure.ac,
+ include/ffi.h.in,
+ include/ffi_common.h,
+ src/closures.c,
+ src/dlmalloc.c,
+ src/x86/ffi.c,
+ src/x86/ffitarget.h,
+ src/x86/win64.S (new),
+ README: Added win64 support (mingw or MSVC)
+ * Makefile.in,
+ include/Makefile.in,
+ man/Makefile.in,
+ testsuite/Makefile.in,
+ configure,
+ aclocal.m4: Regenerated
+ * ltcf-c.sh: properly escape cygwin/w32 path
+ * man/ffi_call.3: Clarify size requirements for return value.
+ * src/x86/ffi64.c: Fix filename in comment.
+ * src/x86/win32.S: Remove unused extern.
+
+ * testsuite/libffi.call/closure_fn0.c,
+ testsuite/libffi.call/closure_fn1.c,
+ testsuite/libffi.call/closure_fn2.c,
+ testsuite/libffi.call/closure_fn3.c,
+ testsuite/libffi.call/closure_fn4.c,
+ testsuite/libffi.call/closure_fn5.c,
+ testsuite/libffi.call/closure_fn6.c,
+ testsuite/libffi.call/closure_stdcall.c,
+ testsuite/libffi.call/cls_12byte.c,
+ testsuite/libffi.call/cls_16byte.c,
+ testsuite/libffi.call/cls_18byte.c,
+ testsuite/libffi.call/cls_19byte.c,
+ testsuite/libffi.call/cls_1_1byte.c,
+ testsuite/libffi.call/cls_20byte.c,
+ testsuite/libffi.call/cls_20byte1.c,
+ testsuite/libffi.call/cls_24byte.c,
+ testsuite/libffi.call/cls_2byte.c,
+ testsuite/libffi.call/cls_3_1byte.c,
+ testsuite/libffi.call/cls_3byte1.c,
+ testsuite/libffi.call/cls_3byte2.c,
+ testsuite/libffi.call/cls_4_1byte.c,
+ testsuite/libffi.call/cls_4byte.c,
+ testsuite/libffi.call/cls_5_1_byte.c,
+ testsuite/libffi.call/cls_5byte.c,
+ testsuite/libffi.call/cls_64byte.c,
+ testsuite/libffi.call/cls_6_1_byte.c,
+ testsuite/libffi.call/cls_6byte.c,
+ testsuite/libffi.call/cls_7_1_byte.c,
+ testsuite/libffi.call/cls_7byte.c,
+ testsuite/libffi.call/cls_8byte.c,
+ testsuite/libffi.call/cls_9byte1.c,
+ testsuite/libffi.call/cls_9byte2.c,
+ testsuite/libffi.call/cls_align_double.c,
+ testsuite/libffi.call/cls_align_float.c,
+ testsuite/libffi.call/cls_align_longdouble.c,
+ testsuite/libffi.call/cls_align_longdouble_split.c,
+ testsuite/libffi.call/cls_align_longdouble_split2.c,
+ testsuite/libffi.call/cls_align_pointer.c,
+ testsuite/libffi.call/cls_align_sint16.c,
+ testsuite/libffi.call/cls_align_sint32.c,
+ testsuite/libffi.call/cls_align_sint64.c,
+ testsuite/libffi.call/cls_align_uint16.c,
+ testsuite/libffi.call/cls_align_uint32.c,
+ testsuite/libffi.call/cls_align_uint64.c,
+ testsuite/libffi.call/cls_dbls_struct.c,
+ testsuite/libffi.call/cls_double.c,
+ testsuite/libffi.call/cls_double_va.c,
+ testsuite/libffi.call/cls_float.c,
+ testsuite/libffi.call/cls_longdouble.c,
+ testsuite/libffi.call/cls_longdouble_va.c,
+ testsuite/libffi.call/cls_multi_schar.c,
+ testsuite/libffi.call/cls_multi_sshort.c,
+ testsuite/libffi.call/cls_multi_sshortchar.c,
+ testsuite/libffi.call/cls_multi_uchar.c,
+ testsuite/libffi.call/cls_multi_ushort.c,
+ testsuite/libffi.call/cls_multi_ushortchar.c,
+ testsuite/libffi.call/cls_pointer.c,
+ testsuite/libffi.call/cls_pointer_stack.c,
+ testsuite/libffi.call/cls_schar.c,
+ testsuite/libffi.call/cls_sint.c,
+ testsuite/libffi.call/cls_sshort.c,
+ testsuite/libffi.call/cls_uchar.c,
+ testsuite/libffi.call/cls_uint.c,
+ testsuite/libffi.call/cls_ulonglong.c,
+ testsuite/libffi.call/cls_ushort.c,
+ testsuite/libffi.call/err_bad_abi.c,
+ testsuite/libffi.call/err_bad_typedef.c,
+ testsuite/libffi.call/float2.c,
+ testsuite/libffi.call/huge_struct.c,
+ testsuite/libffi.call/nested_struct.c,
+ testsuite/libffi.call/nested_struct1.c,
+ testsuite/libffi.call/nested_struct10.c,
+ testsuite/libffi.call/nested_struct2.c,
+ testsuite/libffi.call/nested_struct3.c,
+ testsuite/libffi.call/nested_struct4.c,
+ testsuite/libffi.call/nested_struct5.c,
+ testsuite/libffi.call/nested_struct6.c,
+ testsuite/libffi.call/nested_struct7.c,
+ testsuite/libffi.call/nested_struct8.c,
+ testsuite/libffi.call/nested_struct9.c,
+ testsuite/libffi.call/problem1.c,
+ testsuite/libffi.call/return_ldl.c,
+ testsuite/libffi.call/return_ll1.c,
+ testsuite/libffi.call/stret_large.c,
+ testsuite/libffi.call/stret_large2.c,
+ testsuite/libffi.call/stret_medium.c,
+ testsuite/libffi.call/stret_medium2.c,
+ testsuite/libffi.special/unwindtest.cc: use ffi_closure_alloc instead
+ of checking for MMAP. Use intptr_t instead of long casts.
+
+2009-06-04 Andrew Haley <aph@redhat.com>
+
+ * src/powerpc/ffitarget.h: Fix misapplied merge from gcc.
+
+2009-06-04 Andrew Haley <aph@redhat.com>
+
+ * src/mips/o32.S,
+ src/mips/n32.S: Fix licence formatting.
+
+2009-06-04 Andrew Haley <aph@redhat.com>
+
+ * src/x86/darwin.S: Fix licence formatting.
+ src/x86/win32.S: Likewise.
+ src/sh64/sysv.S: Likewise.
+ src/sh/sysv.S: Likewise.
+
+2009-06-04 Andrew Haley <aph@redhat.com>
+
+ * src/sh64/ffi.c: Remove lint directives. Was missing from merge
+ of Andreas Tobler's patch from 2006-04-22.
+
+2009-06-04 Andrew Haley <aph@redhat.com>
+
+ * src/sh/ffi.c: Apply missing hunk from Alexandre Oliva's patch of
+ 2007-03-07.
+
+2008-12-26 Timothy Wall <twall@users.sf.net>
+
+ * testsuite/libffi.call/cls_longdouble.c,
+ testsuite/libffi.call/cls_longdouble_va.c,
+ testsuite/libffi.call/cls_align_longdouble.c,
+ testsuite/libffi.call/cls_align_longdouble_split.c,
+ testsuite/libffi.call/cls_align_longdouble_split2.c: mark expected
+ failures on x86_64 cygwin/mingw.
+
+2008-12-22 Timothy Wall <twall@users.sf.net>
+
+ * testsuite/libffi.call/closure_fn0.c,
+ testsuite/libffi.call/closure_fn1.c,
+ testsuite/libffi.call/closure_fn2.c,
+ testsuite/libffi.call/closure_fn3.c,
+ testsuite/libffi.call/closure_fn4.c,
+ testsuite/libffi.call/closure_fn5.c,
+ testsuite/libffi.call/closure_fn6.c,
+ testsuite/libffi.call/closure_loc_fn0.c,
+ testsuite/libffi.call/closure_stdcall.c,
+ testsuite/libffi.call/cls_align_pointer.c,
+ testsuite/libffi.call/cls_pointer.c,
+ testsuite/libffi.call/cls_pointer_stack.c: use portable cast from
+ pointer to integer (intptr_t).
+ * testsuite/libffi.call/cls_longdouble.c: disable for win64.
+
+2008-12-19 Anthony Green <green@redhat.com>
+
+ * configure.ac: Bump version to 3.0.8.
+ * configure, doc/stamp-vti, doc/version.texi: Rebuilt.
+ * libtool-version: Increment revision.
+ * README: Update for new release.
+
+2008-11-11 Anthony Green <green@redhat.com>
+
+ * configure.ac: Bump version to 3.0.7.
+ * configure, doc/stamp-vti, doc/version.texi: Rebuilt.
+ * libtool-version: Increment revision.
+ * README: Update for new release.
+
+2008-08-25 Andreas Tobler <a.tobler@schweiz.org>
+
+ * src/powerpc/ffitarget.h (ffi_abi): Add FFI_LINUX and
+ FFI_LINUX_SOFT_FLOAT to the POWERPC_FREEBSD enum.
+ Add note about flag bits used for FFI_SYSV_TYPE_SMALL_STRUCT.
+ Adjust copyright notice.
+ * src/powerpc/ffi.c: Add two new flags to indicate if we have one
+ register or two register to use for FFI_SYSV structs.
+ (ffi_prep_cif_machdep): Pass the right register flag introduced above.
+ (ffi_closure_helper_SYSV): Fix the return type for
+ FFI_SYSV_TYPE_SMALL_STRUCT. Comment.
+ Adjust copyright notice.
+
+2008-07-24 Anthony Green <green@redhat.com>
+
+ * testsuite/libffi.call/cls_dbls_struct.c,
+ testsuite/libffi.call/cls_double_va.c,
+ testsuite/libffi.call/cls_longdouble.c,
+ testsuite/libffi.call/cls_longdouble_va.c,
+ testsuite/libffi.call/cls_pointer.c,
+ testsuite/libffi.call/cls_pointer_stack.c,
+ testsuite/libffi.call/err_bad_abi.c: Clean up failures from
+ compiler warnings.
+
+2008-07-17 Anthony Green <green@redhat.com>
+
+ * configure.ac: Bump version to 3.0.6.
+ * configure, doc/stamp-vti, doc/version.texi: Rebuilt.
+ * libtool-version: Increment revision. Add documentation.
+ * README: Update for new release.
+
+2008-07-16 Kaz Kojima <kkojima@gcc.gnu.org>
+
+ * src/sh/ffi.c (ffi_prep_closure_loc): Turn INSN into an unsigned
+ int.
+
+2008-07-16 Kaz Kojima <kkojima@gcc.gnu.org>
+
+ * src/sh/sysv.S: Add .note.GNU-stack on Linux.
+ * src/sh64/sysv.S: Likewise.
+
+2008-04-03 Anthony Green <green@redhat.com>
+
+ * libffi.pc.in (Libs): Add -L${libdir}.
+ * configure.ac: Bump version to 3.0.5.
+ * configure, doc/stamp-vti, doc/version.texi: Rebuilt.
+ * libtool-version: Increment revision.
+ * README: Update for new release.
+
+2008-04-03 Anthony Green <green@redhat.com>
+ Xerces Ranby <xerxes@zafena.se>
+
+ * include/ffi.h.in: Wrap definition of target architecture to
+ protect from double definitions.
+
+2008-03-22 Moriyoshi Koizumi <moriyoshi@gmail.com>
+
+ * src/x86/ffi.c (ffi_prep_closure_loc): Fix for bug revealed in
+ closure_loc_fn0.c.
+ * testsuite/libffi.call/closure_loc_fn0.c (closure_loc_test_fn0):
+ New test.
+
+2008-03-04 Anthony Green <green@redhat.com>
+ Blake Chaffin
+ hos@tamanegi.org
+
+ * testsuite/libffi.call/cls_align_longdouble_split2.c
+ testsuite/libffi.call/cls_align_longdouble_split.c
+ testsuite/libffi.call/cls_dbls_struct.c
+ testsuite/libffi.call/cls_double_va.c
+ testsuite/libffi.call/cls_longdouble.c
+ testsuite/libffi.call/cls_longdouble_va.c
+ testsuite/libffi.call/cls_pointer.c
+ testsuite/libffi.call/cls_pointer_stack.c
+ testsuite/libffi.call/err_bad_abi.c
+ testsuite/libffi.call/err_bad_typedef.c
+ testsuite/libffi.call/huge_struct.c
+ testsuite/libffi.call/stret_large2.c
+ testsuite/libffi.call/stret_large.c
+ testsuite/libffi.call/stret_medium2.c
+ testsuite/libffi.call/stret_medium.c: New tests from Apple.
+
+2008-02-26 Jakub Jelinek <jakub@redhat.com>
+ Anthony Green <green@redhat.com>
+
+ * src/alpha/osf.S: Add .note.GNU-stack on Linux.
+ * src/s390/sysv.S: Likewise.
+ * src/powerpc/linux64.S: Likewise.
+ * src/powerpc/linux64_closure.S: Likewise.
+ * src/powerpc/ppc_closure.S: Likewise.
+ * src/powerpc/sysv.S: Likewise.
+ * src/x86/unix64.S: Likewise.
+ * src/x86/sysv.S: Likewise.
+ * src/sparc/v8.S: Likewise.
+ * src/sparc/v9.S: Likewise.
+ * src/m68k/sysv.S: Likewise.
+ * src/ia64/unix.S: Likewise.
+ * src/arm/sysv.S: Likewise.
+
+2008-02-26 Anthony Green <green@redhat.com>
+ Thomas Heller <theller@ctypes.org>
+
+ * src/x86/ffi.c (ffi_closure_SYSV_inner): Change C++ comment to C
+ comment.
+
+2008-02-26 Anthony Green <green@redhat.org>
+ Thomas Heller <theller@ctypes.org>
+
+ * include/ffi.h.in: Change void (*)() to void (*)(void).
+
+2008-02-26 Anthony Green <green@redhat.org>
+ Thomas Heller <theller@ctypes.org>
+
+ * src/alpha/ffi.c: Change void (*)() to void (*)(void).
+ src/alpha/osf.S, src/arm/ffi.c, src/frv/ffi.c, src/ia64/ffi.c,
+ src/ia64/unix.S, src/java_raw_api.c, src/m32r/ffi.c,
+ src/mips/ffi.c, src/pa/ffi.c, src/pa/hpux32.S, src/pa/linux.S,
+ src/powerpc/ffi.c, src/powerpc/ffi_darwin.c, src/raw_api.c,
+ src/s390/ffi.c, src/sh/ffi.c, src/sh64/ffi.c, src/sparc/ffi.c,
+ src/x86/ffi.c, src/x86/unix64.S, src/x86/darwin64.S,
+ src/x86/ffi64.c: Ditto.
+
+2008-02-24 Anthony Green <green@redhat.org>
+
+ * configure.ac: Accept openbsd*, not just openbsd.
+ Bump version to 3.0.4.
+ * configure, doc/stamp-vti, doc/version.texi: Rebuilt.
+ * libtool-version: Increment revision.
+ * README: Update for new release.
+
+2008-02-22 Anthony Green <green@redhat.com>
+
+ * README: Clean up list of tested platforms.
+
+2008-02-22 Anthony Green <green@redhat.com>
+
+ * configure.ac: Bump version to 3.0.3.
+ * configure, doc/stamp-vti, doc/version.texi: Rebuilt.
+ * libtool-version: Increment revision.
+ * README: Update for new release. Clean up test docs.
+
+2008-02-22 Bjoern Koenig <bkoenig@alpha-tierchen.de>
+ Andreas Tobler <a.tobler@schweiz.org>
+
+ * configure.ac: Add amd64-*-freebsd* target.
+ * configure: Regenerate.
+
+2008-02-22 Thomas Heller <theller@ctypes.org>
+
+ * configure.ac: Add x86 OpenBSD support.
+ * configure: Rebuilt.
+
+2008-02-21 Thomas Heller <theller@ctypes.org>
+
+ * README: Change "make test" to "make check".
+
+2008-02-21 Anthony Green <green@redhat.com>
+
+ * configure.ac: Bump version to 3.0.2.
+ * configure, doc/stamp-vti, doc/version.texi: Rebuilt.
+ * libtool-version: Increment revision.
+ * README: Update for new release.
+
+2008-02-21 Björn König <bkoenig@alpha-tierchen.de>
+
+ * src/x86/freebsd.S: New file.
+ * configure.ac: Add x86 FreeBSD support.
+ * Makefile.am: Ditto.
+
+2008-02-15 Anthony Green <green@redhat.com>
+
+ * configure.ac: Bump version to 3.0.1.
+ * configure, doc/stamp-vti, doc/version.texi: Rebuilt.
+ * libtool-version: Increment revision.
+ * README: Update for new release.
+
+2008-02-15 David Daney <ddaney@avtrex.com>
+
+ * src/mips/ffi.c: Remove extra '>' from include directive.
+ (ffi_prep_closure_loc): Use clear_location instead of tramp.
+
+2008-02-15 Anthony Green <green@redhat.com>
+
+ * configure.ac: Bump version to 3.0.0.
+ * configure, doc/stamp-vti, doc/version.texi: Rebuilt.
+
+2008-02-15 David Daney <ddaney@avtrex.com>
+
+ * src/mips/ffi.c (USE__BUILTIN___CLEAR_CACHE):
+ Define (conditionally), and use it to include cachectl.h.
+ (ffi_prep_closure_loc): Fix cache flushing.
+ * src/mips/ffitarget.h (_ABIN32, _ABI64, _ABIO32): Define.
+
+2008-02-15 Anthony Green <green@redhat.com>
+
+ * man/ffi_call.3, man/ffi_prep_cif.3, man/ffi.3:
+ Update dates and remove all references to ffi_prep_closure.
+ * configure.ac: Bump version to 2.99.9.
+ * configure, doc/stamp-vti, doc/version.texi: Rebuilt.
+
+2008-02-15 Anthony Green <green@redhat.com>
+
+ * man/ffi_prep_closure.3: Delete.
+ * man/Makefile.am (EXTRA_DIST): Remove ffi_prep_closure.3.
+ (man_MANS): Ditto.
+ * man/Makefile.in: Rebuilt.
+ * configure.ac: Bump version to 2.99.8.
+ * configure, doc/stamp-vti, doc/version.texi: Rebuilt.
+
+2008-02-14 Anthony Green <green@redhat.com>
+
+ * configure.ac: Bump version to 2.99.7.
+ * configure, doc/stamp-vti, doc/version.texi: Rebuilt.
+ * include/ffi.h.in LICENSE src/debug.c src/closures.c
+ src/ffitest.c src/s390/sysv.S src/s390/ffitarget.h
+ src/types.c src/m68k/ffitarget.h src/raw_api.c src/frv/ffi.c
+ src/frv/ffitarget.h src/sh/ffi.c src/sh/sysv.S
+ src/sh/ffitarget.h src/powerpc/ffitarget.h src/pa/ffi.c
+ src/pa/ffitarget.h src/pa/linux.S src/java_raw_api.c
+ src/cris/ffitarget.h src/x86/ffi.c src/x86/sysv.S
+ src/x86/unix64.S src/x86/win32.S src/x86/ffitarget.h
+ src/x86/ffi64.c src/x86/darwin.S src/ia64/ffi.c
+ src/ia64/ffitarget.h src/ia64/ia64_flags.h src/ia64/unix.S
+ src/sparc/ffi.c src/sparc/v9.S src/sparc/ffitarget.h
+ src/sparc/v8.S src/alpha/ffi.c src/alpha/ffitarget.h
+ src/alpha/osf.S src/sh64/ffi.c src/sh64/sysv.S
+ src/sh64/ffitarget.h src/mips/ffi.c src/mips/ffitarget.h
+ src/mips/n32.S src/mips/o32.S src/arm/ffi.c src/arm/sysv.S
+ src/arm/ffitarget.h src/prep_cif.c: Update license text.
+
+2008-02-14 Anthony Green <green@redhat.com>
+
+ * README: Update tested platforms.
+ * configure.ac: Bump version to 2.99.6.
+ * configure: Rebuilt.
+
+2008-02-14 Anthony Green <green@redhat.com>
+
+ * configure.ac: Bump version to 2.99.5.
+ * configure: Rebuilt.
+ * Makefile.am (EXTRA_DIST): Add darwin64.S
+ * Makefile.in: Rebuilt.
+ * testsuite/lib/libffi-dg.exp: Remove libstdc++ bits from GCC tree.
+ * LICENSE: Update WARRANTY.
+
+2008-02-14 Anthony Green <green@redhat.com>
+
+ * libffi.pc.in (libdir): Fix libdir definition.
+ * configure.ac: Bump version to 2.99.4.
+ * configure: Rebuilt.
+
+2008-02-14 Anthony Green <green@redhat.com>
+
+ * README: Update.
+ * libffi.info: New file.
+ * doc/stamp-vti: New file.
+ * configure.ac: Bump version to 2.99.3.
+ * configure: Rebuilt.
+
+2008-02-14 Anthony Green <green@redhat.com>
+
+ * Makefile.am (SUBDIRS): Add man dir.
+ * Makefile.in: Rebuilt.
+ * configure.ac: Create Makefile.
+ * configure: Rebuilt.
+ * man/ffi_call.3 man/ffi_prep_cif.3 man/ffi_prep_closure.3
+ man/Makefile.am man/Makefile.in: New files.
+
+2008-02-14 Tom Tromey <tromey@redhat.com>
+
+ * aclocal.m4, Makefile.in, configure, fficonfig.h.in: Rebuilt.
+ * mdate-sh, texinfo.tex: New files.
+ * Makefile.am (info_TEXINFOS): New variable.
+ * doc/libffi.texi: New file.
+ * doc/version.texi: Likewise.
+
+2008-02-14 Anthony Green <green@redhat.com>
+
+ * Makefile.am (AM_CFLAGS): Don't compile with -D$(TARGET).
+ (lib_LTLIBRARIES): Define.
+ (toolexeclib_LIBRARIES): Undefine.
+ * Makefile.in: Rebuilt.
+ * configure.ac: Reset version to 2.99.1.
+ * configure.in: Rebuilt.
+
+2008-02-14 Anthony Green <green@redhat.com>
+
+ * libffi.pc.in: Use @PACKAGE_NAME@ and @PACKAGE_VERSION@.
+ * configure.ac: Reset version to 2.99.1.
+ * configure.in: Rebuilt.
+ * Makefile.am (EXTRA_DIST): Add ChangeLog.libffi.
+ * Makefile.in: Rebuilt.
+ * LICENSE: Update copyright notice.
+
+2008-02-14 Anthony Green <green@redhat.com>
+
+ * include/Makefile.am (nodist_includes_HEADERS): Define. Don't
+ distribute ffitarget.h or ffi.h from the build include dir.
+ * Makefile.in: Rebuilt.
+
+2008-02-14 Anthony Green <green@redhat.com>
+
+ * include/Makefile.am (includesdir): Install headers under libdir.
+ (pkgconfigdir): Define. Install libffi.pc.
+ * include/Makefile.in: Rebuilt.
+ * libffi.pc.in: Create.
+ * libtool-version: Increment CURRENT
+ * configure.ac: Add libffi.pc.in
+ * configure: Rebuilt.
+
+2008-02-03 Anthony Green <green@redhat.com>
+
+ * include/Makefile.am (includesdir): Fix header install with
+ DESTDIR.
+ * include/Makefile.in: Rebuilt.
+
+2008-02-03 Timothy Wall <twall@users.sf.net>
+
+ * src/x86/ffi.c (FFI_INIT_TRAMPOLINE_STDCALL): Calculate jump return
+ offset based on code pointer, not data pointer.
+
+2008-02-01 Anthony Green <green@redhat.com>
+
+ * include/Makefile.am: Fix header installs.
+ * Makefile.am: Ditto.
+ * include/Makefile.in: Rebuilt.
+ * Makefile.in: Ditto.
+
+2008-02-01 Anthony Green <green@redhat.com>
+
+ * src/x86/ffi.c (FFI_INIT_TRAMPOLINE_STDCALL,
+ FFI_INIT_TRAMPOLINE): Revert my broken changes to twall's last
+ patch.
+
+2008-01-31 Anthony Green <green@redhat.com>
+
+ * Makefile.am (EXTRA_DIST): Add missing files.
+ * testsuite/Makefile.am: Ditto.
+ * Makefile.in, testsuite/Makefile.in: Rebuilt.
+
+2008-01-31 Timothy Wall <twall@users.sf.net>
+
+ * testsuite/libffi.call/closure_stdcall.c: Add test for stdcall
+ closures.
+ * src/x86/ffitarget.h: Increase size of trampoline for stdcall
+ closures.
+ * src/x86/win32.S: Add assembly for stdcall closure.
+ * src/x86/ffi.c: Initialize stdcall closure trampoline.
+
+2008-01-30 H.J. Lu <hongjiu.lu@intel.com>
+
+ PR libffi/34612
+ * src/x86/sysv.S (ffi_closure_SYSV): Pop 4 byte from stack when
+ returning struct.
+
+ * testsuite/libffi.call/call.exp: Add "-O2 -fomit-frame-pointer"
+ tests.
+
+2008-01-30 Anthony Green <green@redhat.com>
+
+ * Makefile.am, include/Makefile.am: Move headers to
+ libffi_la_SOURCES for new automake.
+ * Makefile.in, include/Makefile.in: Rebuilt.
+
+ * testsuite/lib/wrapper.exp: Copied from gcc tree to allow for
+ execution outside of gcc tree.
+ * testsuite/lib/target-libpath.exp: Ditto.
+
+ * testsuite/lib/libffi-dg.exp: Many changes to allow for execution
+ outside of gcc tree.
+
diff --git a/jni/ruby/ext/fiddle/libffi-3.2.1/ChangeLog.libffi-3.1 b/jni/ruby/ext/fiddle/libffi-3.2.1/ChangeLog.libffi-3.1
new file mode 100644
index 0000000..8f7f50d
--- /dev/null
+++ b/jni/ruby/ext/fiddle/libffi-3.2.1/ChangeLog.libffi-3.1
@@ -0,0 +1,6000 @@
+2014-03-16 Josh Triplett <josh@joshtriplett.org>
+
+ * ChangeLog: Archive to ChangeLog.libffi-3.1 and delete. Future
+ changelogs will come from git, with autogenerated snapshots shipped in
+ distributed tarballs.
+
+2014-03-16 Josh Triplett <josh@joshtriplett.org>
+
+ Add support for stdcall, thiscall, and fastcall on non-Windows
+ x86-32.
+
+ Linux supports the stdcall calling convention, either via
+ functions explicitly declared with the stdcall attribute, or via
+ code compiled with -mrtd which effectively makes stdcall the
+ default.
+
+ This introduces FFI_STDCALL, FFI_THISCALL, and FFI_FASTCALL on
+ non-Windows x86-32 platforms, as non-default calling conventions.
+
+ * Makefile.am: Compile in src/x86/win32.S on non-Windows x86-32.
+ * src/x86/ffitarget.h: Add FFI_STDCALL, FFI_THISCALL, and
+ FFI_FASTCALL on non-Windows x86-32. Increase trampoline size to
+ accomodate these calling conventions, and unify some ifdeffery.
+ * src/x86/ffi.c: Add support for FFI_STDCALL, FFI_THISCALL, and
+ FFI_FASTCALL on non-Windows x86-32 platforms; update ifdeffery.
+ * src/x86/win32.S: Support compiling on non-Windows x86-32
+ platforms. On those platforms, avoid redefining the SYSV symbols
+ already provided by src/x86/sysv.S.
+ * testsuite/libffi.call/closure_stdcall.c: Run on non-Windows.
+ #define __stdcall if needed.
+ * testsuite/libffi.call/closure_thiscall.c: Run on non-Windows.
+ #define __fastcall if needed.
+ * testsuite/libffi.call/fastthis1_win32.c: Run on non-Windows.
+ * testsuite/libffi.call/fastthis2_win32.c: Ditto.
+ * testsuite/libffi.call/fastthis3_win32.c: Ditto.
+ * testsuite/libffi.call/many2_win32.c: Ditto.
+ * testsuite/libffi.call/many_win32.c: Ditto.
+ * testsuite/libffi.call/strlen2_win32.c: Ditto.
+ * testsuite/libffi.call/strlen_win32.c: Ditto.
+ * testsuite/libffi.call/struct1_win32.c: Ditto.
+ * testsuite/libffi.call/struct2_win32.c: Ditto.
+
+2014-03-16 Josh Triplett <josh@joshtriplett.org>
+
+ * prep_cif.c: Remove unnecessary ifdef for X86_WIN32.
+ ffi_prep_cif_core had a special case for X86_WIN32, checking for
+ FFI_THISCALL in addition to the FFI_FIRST_ABI-to-FFI_LAST_ABI
+ range before returning FFI_BAD_ABI. However, on X86_WIN32,
+ FFI_THISCALL already falls in that range, making the special case
+ unnecessary. Remove it.
+
+2014-03-16 Josh Triplett <josh@joshtriplett.org>
+
+ * testsuite/libffi.call/closure_stdcall.c,
+ testsuite/libffi.call/closure_thiscall.c: Remove fragile stack
+ pointer checks. These files included inline assembly to save the
+ stack pointer before and after the call, and compare the values.
+ However, compilers can and do leave the stack in different states
+ for these two pieces of inline assembly, such as by saving a
+ temporary value on the stack across the call; observed with gcc
+ -Os, and verified as spurious through careful inspection of
+ disassembly.
+
+2014-03-16 Josh Triplett <josh@joshtriplett.org>
+
+ * testsuite/libffi.call/many.c: Avoid spurious failure due to
+ excess floating-point precision.
+ * testsuite/libffi.call/many_win32.c: Ditto.
+
+2014-03-16 Josh Triplett <josh@joshtriplett.org>
+
+ * libtool-ldflags: Re-add.
+
+2014-03-16 Josh Triplett <josh@joshtriplett.org>
+
+ * Makefile.in, aclocal.m4, compile, config.guess, config.sub,
+ configure, depcomp, include/Makefile.in, install-sh,
+ libtool-ldflags, ltmain.sh, m4/libtool.m4, m4/ltoptions.m4,
+ m4/ltsugar.m4, m4/ltversion.m4, m4/lt~obsolete.m4,
+ man/Makefile.in, mdate-sh, missing, testsuite/Makefile.in: Delete
+ autogenerated files from version control.
+ * .gitignore: Add autogenerated files.
+ * autogen.sh: New script to generate the autogenerated files.
+ * README: Document requirement to run autogen.sh when building
+ directly from version control.
+ * .travis.yml: Run autogen.sh
+
+2014-03-14 Anthony Green <green@moxielogic.com>
+
+ * configure, Makefile.in: Rebuilt.
+
+2014-03-10 Mike Hommey <mh+mozilla@glandium.org>
+
+ * configure.ac: Allow building for mipsel with Android NDK r8.
+ * Makefile.am (AM_MAKEFLAGS): Replace double quotes with single
+ quotes.
+
+2014-03-10 Landry Breuil <landry@openbsd.org>
+
+ * configure.ac: Ensure the linker supports @unwind sections in libffi.
+
+2014-03-01 Anthony Green <green@moxielogic.com>
+
+ * Makefile.am (EXTRA_DIST): Replace old scripts with
+ generate-darwin-source-and-headers.py.
+ * Makefile.in: Rebuilt.
+
+2014-02-28 Anthony Green <green@moxielogic.com>
+
+ * Makefile.am (AM_CFLAGS): Reintroduce missing -DFFI_DEBUG for
+ --enable-debug builds.
+ * Makefile.in: Rebuilt.
+
+2014-02-28 Makoto Kato <m_kato@ga2.so-net.ne.jp>
+
+ * src/closures.c: Fix build failure when using clang for Android.
+
+2014-02-28 Marcin Wojdyr <wojdyr@gmail.com>
+
+ * libffi.pc.in (toolexeclibdir): use -L${toolexeclibdir} instead
+ of -L${libdir}.
+
+2014-02-28 Paulo Pizarro <paulo.pizarro@gmail.com>
+
+ * src/bfin/sysv.S: Calling functions in shared libraries requires
+ considering the GOT.
+
+2014-02-28 Josh Triplett <josh@joshtriplett.org>
+
+ * src/x86/ffi64.c (classify_argument): Handle case where
+ FFI_TYPE_LONGDOUBLE == FFI_TYPE_DOUBLE.
+
+2014-02-28 Anthony Green <green@moxielogic.com>
+
+ * ltmain.sh: Generate with libtool-2.4.2.418.
+ * m4/libtool.m4, m4/ltoptions.m4, m4/ltversion.m4: Ditto.
+ * configure: Rebuilt.
+
+2014-02-28 Dominik Vogt <vogt@linux.vnet.ibm.com>
+
+ * configure.ac (AC_ARG_ENABLE struct): Fix typo in help
+ message.
+ (AC_ARG_ENABLE raw_api): Ditto.
+ * configure, fficonfig.h.in: Rebuilt.
+
+2014-02-28 Will Newton <will.newton@linaro.org>
+
+ * src/arm/sysv.S: Initialize IP register with FP.
+
+2014-02-28 Yufeng Zhang <yufeng.zhang@arm.com>
+
+ * src/aarch64/sysv.S (ffi_closure_SYSV): Use x29 as the
+ main CFA reg; update cfi_rel_offset.
+
+2014-02-15 Marcus Comstedt <marcus@mc.pp.se>
+
+ * src/powerpc/ffi_linux64.c, src/powerpc/linux64_closure.S: Remove
+ assumption on contents of r11 in closure.
+
+2014-02-09 Heiher <r@hev.cc>
+
+ * src/mips/n32.S: Fix call floating point va function.
+
+2014-01-21 Zachary Waldowski <zach@waldowski.me>
+
+ * src/aarch64/ffi.c: Fix missing semicolons on assertions under
+ debug mode.
+
+2013-12-30 Zachary Waldowski <zach@waldowski.me>
+
+ * .gitignore: Exclude darwin_* generated source and build_* trees.
+ * src/aarch64/ffi.c, src/arm/ffi.c, src/x86/ffi.c: Inhibit Clang
+ previous prototype warnings.
+ * src/arm/ffi.c: Prevent NULL dereference, fix short type warning
+ * src/dlmalloc.c: Fix warnings from set_segment_flags return type,
+ and the native use of size_t for malloc on platforms
+ * src/arm/sysv.S: Use unified syntax. Clang clean-ups for
+ ARM_FUNC_START.
+ * generate-osx-source-and-headers.py: Remove.
+ * build-ios.sh: Remove.
+ * libffi.xcodeproj/project.pbxproj: Rebuild targets. Include
+ x86_64+aarch64 pieces in library. Export headers properly.
+ * src/x86/ffi64.c: More Clang warning clean-ups.
+ * src/closures.c (open_temp_exec_file_dir): Use size_t.
+ * src/prep_cif.c (ffi_prep_cif_core): Cast ALIGN result.
+ * src/aarch64/sysv.S: Use CNAME for global symbols. Only use
+ .size for ELF targets.
+ * src/aarch64/ffi.c: Clean up for double == long double. Clean up
+ from Clang warnings. Use Clang cache invalidation builtin. Use
+ size_t in place of unsigned in many places. Accommodate for
+ differences in Apple AArch64 ABI.
+
+2013-12-02 Daniel Rodríguez Troitiño <drodrigueztroitino@yahoo.es>
+
+ * generate-darwin-source-and-headers.py: Clean up, modernize,
+ merged version of previous scripts.
+
+2013-11-21 Anthony Green <green@moxielogic.com>
+
+ * configure, Makefile.in, include/Makefile.in, include/ffi.h.in,
+ man/Makefile.in, testsuite/Makefile.in, fficonfig.h.in: Rebuilt.
+
+2013-11-21 Alan Modra <amodra@gmail.com>
+
+ * Makefile.am (EXTRA_DIST): Add new src/powerpc files.
+ (nodist_libffi_la_SOURCES <POWERPC, POWERPC_FREEBSD>): Likewise.
+ * configure.ac (HAVE_LONG_DOUBLE_VARIANT): Define for powerpc.
+ * include/ffi.h.in (ffi_prep_types): Declare.
+ * src/prep_cif.c (ffi_prep_cif_core): Call ffi_prep_types.
+ * src/types.c (FFI_NONCONST_TYPEDEF): Define and use for
+ HAVE_LONG_DOUBLE_VARIANT.
+ * src/powerpc/ffi_powerpc.h: New file.
+ * src/powerpc/ffi.c: Split into..
+ * src/powerpc/ffi_sysv.c: ..new file, and..
+ * src/powerpc/ffi_linux64.c: ..new file, rewriting parts.
+ * src/powerpc/ffitarget.h (enum ffi_abi): Rewrite powerpc ABI
+ selection as bits controlling features.
+ * src/powerpc/linux64.S: For consistency, use POWERPC64 rather
+ than __powerpc64__.
+ * src/powerpc/linux64_closure.S: Likewise.
+ * src/powerpc/ppc_closure.S: Likewise. Move .note.FNU-stack
+ inside guard.
+ * src/powerpc/sysv.S: Likewise.
+ * configure: Regenerate.
+ * fficonfig.h.in: Regenerate.
+ * Makefile.in: Regenerate.
+
+2013-11-20 Alan Modra <amodra@gmail.com>
+
+ * src/powerpc/ffi.c (ffi_prep_cif_machdep_core): Use
+ NUM_FPR_ARG_REGISTERS64 and NUM_GPR_ARG_REGISTERS64 not their
+ 32-bit versions for 64-bit code.
+ * src/powerpc/linux64_closure.S: Don't use the return value area
+ as a parameter save area on ELFv2.
+
+2013-11-18 Iain Sandoe <iain@codesourcery.com>
+
+ * src/powerpc/darwin.S (EH): Correct use of pcrel FDE encoding.
+ * src/powerpc/darwin_closure.S (EH): Likewise. Modernise picbase
+ labels.
+
+2013-11-18 Anthony Green <green@moxielogic.com>
+
+ * src/arm/ffi.c (ffi_call): Hoist declaration of temp to top of
+ function.
+ * src/arm/ffi.c (ffi_closure_inner): Moderize function declaration
+ to appease compiler.
+ Thanks for Gregory P. Smith <greg@krypto.org>.
+
+2013-11-18 Anthony Green <green@moxielogic.com>
+
+ * README (tested): Mention PowerPC ELFv2.
+
+2013-11-16 Alan Modra <amodra@gmail.com>
+
+ * src/powerpc/ppc_closure.S: Move errant #endif to where it belongs.
+ Don't bl .Luint128.
+
+2013-11-16 Alan Modra <amodra@gmail.com>
+
+ * src/powerpc/ffi.c (ffi_prep_cif_machdep_core): Use #if _CALL_ELF
+ test to select parameter save sizing for ELFv2 vs. ELFv1.
+ * src/powerpc/ffitarget.h (FFI_V2_TYPE_FLOAT_HOMOG,
+ FFI_V2_TYPE_DOUBLE_HOMOG, FFI_V2_TYPE_SMALL_STRUCT): Define.
+ (FFI_TRAMPOLINE_SIZE): Define variant for ELFv2.
+ * src/powerpc/ffi.c (FLAG_ARG_NEEDS_PSAVE): Define.
+ (discover_homogeneous_aggregate): New function.
+ (ffi_prep_args64): Adjust start of param save area for ELFv2.
+ Handle homogenous floating point struct parms.
+ (ffi_prep_cif_machdep_core): Adjust space calculation for ELFv2.
+ Handle ELFv2 return values. Set FLAG_ARG_NEEDS_PSAVE. Handle
+ homogenous floating point structs.
+ (ffi_call): Increase size of smst_buffer for ELFv2. Handle ELFv2.
+ (flush_icache): Compile for ELFv2.
+ (ffi_prep_closure_loc): Set up ELFv2 trampoline.
+ (ffi_closure_helper_LINUX64): Don't return all structs directly
+ to caller. Handle homogenous floating point structs. Handle
+ ELFv2 struct return values.
+ * src/powerpc/linux64.S (ffi_call_LINUX64): Set up r2 for
+ ELFv2. Adjust toc save location. Call function pointer using
+ r12. Handle FLAG_RETURNS_SMST. Don't predict branches.
+ * src/powerpc/linux64_closure.S (ffi_closure_LINUX64): Set up r2
+ for ELFv2. Define ELFv2 versions of STACKFRAME, PARMSAVE, and
+ RETVAL. Handle possibly missing parameter save area. Handle
+ ELFv2 return values.
+ (.note.GNU-stack): Move inside outer #ifdef.
+
+2013-11-16 Alan Modra <amodra@gmail.com>
+
+ * src/powerpc/ffi.c (ffi_prep_cif_machdep): Revert 2013-02-08
+ change. Do not consume an int arg when returning a small struct
+ for FFI_SYSV ABI.
+ (ffi_call): Only use bounce buffer when FLAG_RETURNS_SMST.
+ Properly copy bounce buffer to destination.
+ * src/powerpc/sysv.S: Revert 2013-02-08 change.
+ * src/powerpc/ppc_closure.S: Remove stray '+'.
+
+2013-11-16 Alan Modra <amodra@gmail.com>
+
+ * src/powerpc/ffi.c (ffi_prep_args64): Align struct parameters
+ according to __STRUCT_PARM_ALIGN__.
+ (ffi_prep_cif_machdep_core): Likewise.
+ (ffi_closure_helper_LINUX64): Likewise.
+
+2013-11-16 Alan Modra <amodra@gmail.com>
+
+ * src/powerpc/linux64.S (ffi_call_LINUX64): Tweak restore of r28.
+ (.note.GNU-stack): Move inside outer #ifdef.
+ * src/powerpc/linux64_closure.S (STACKFRAME, PARMSAVE,
+ RETVAL): Define and use throughout.
+ (ffi_closure_LINUX64): Save fprs before buying stack.
+ (.note.GNU-stack): Move inside outer #ifdef.
+
+2013-11-16 Alan Modra <amodra@gmail.com>
+
+ * src/powerpc/ffitarget.h (FFI_TARGET_SPECIFIC_VARIADIC): Define.
+ (FFI_EXTRA_CIF_FIELDS): Define.
+ * src/powerpc/ffi.c (ffi_prep_args64): Save fprs as per the
+ ABI, not to both fpr and param save area.
+ (ffi_prep_cif_machdep_core): Renamed from ffi_prep_cif_machdep.
+ Keep initial flags. Formatting. Remove dead FFI_LINUX_SOFT_FLOAT
+ code.
+ (ffi_prep_cif_machdep, ffi_prep_cif_machdep_var): New functions.
+ (ffi_closure_helper_LINUX64): Pass floating point as per ABI,
+ not to both fpr and parameter save areas.
+
+ * libffi/testsuite/libffi.call/cls_double_va.c (main): Correct
+ function cast and don't call ffi_prep_cif.
+ * libffi/testsuite/libffi.call/cls_longdouble_va.c (main): Likewise.
+
+2013-11-15 Andrew Haley <aph@redhat.com>
+
+ * doc/libffi.texi (Closure Example): Fix the sample code.
+ * doc/libffi.info, doc/stamp-vti, doc/version.texi: Rebuilt.
+
+2013-11-15 Andrew Haley <aph@redhat.com>
+
+ * testsuite/libffi.call/va_struct1.c (main): Fix broken test.
+ * testsuite/libffi.call/cls_uint_va.c (cls_ret_T_fn): Likewise
+ * testsuite/libffi.call/cls_struct_va1.c (test_fn): Likewise.
+ * testsuite/libffi.call/va_1.c (main): Likewise.
+
+2013-11-14 David Schneider <david.schneider@bivab.de>
+
+ * src/arm/ffi.c: Fix register allocation for mixed float and
+ doubles.
+ * testsuite/libffi.call/cls_many_mixed_float_double.c: Testcase
+ for many mixed float and double arguments.
+
+2013-11-13 Alan Modra <amodra@gmail.com>
+
+ * doc/libffi.texi (Simple Example): Correct example code.
+ * doc/libffi.info, doc/stamp-vti, doc/version.texi: Rebuilt.
+
+2013-11-13 Anthony Green <green@moxielogic.com>
+
+ * include/ffi_common.h: Respect HAVE_ALLOCA_H for GNU compiler
+ based build. (Thanks to tmr111116 on github)
+
+2013-11-09 Anthony Green <green@moxielogic.com>
+
+ * m4/libtool.m4: Refresh.
+ * configure, Makefile.in: Rebuilt.
+ * README: Add more notes about next release.
+
+2013-11-09 Shigeharu TAKENO <shige@iee.niit.ac.jp>
+
+ * m4/ax_gcc_archflag.m4 (ax_gcc_arch): Don't recognize
+ UltraSPARC-IIi as ultrasparc3.
+
+2013-11-06 Mark Kettenis <kettenis@gnu.org>
+
+ * src/x86/freebsd.S (ffi_call_SYSV): Align the stack pointer to
+ 16-bytes.
+
+2013-11-06 Konstantin Belousov <kib@freebsd.org>
+
+ * src/x86/freebsd.S (ffi_closure_raw_SYSV): Mark the assembler
+ source as not requiring executable stack.
+
+2013-11-02 Anthony Green <green@moxielogic.com>
+
+ * doc/libffi.texi (The Basics): Clarify return value buffer size
+ requirements. Also, NULL result buffer pointers are no longer
+ supported.
+ * doc/libffi.info: Rebuilt.
+
+2013-11-02 Mischa Jonker <mjonker@synopsys.com>
+
+ * Makefile.am (nodist_libffi_la_SOURCES): Fix build error.
+ * Makefile.in: Rebuilt.
+
+2013-11-02 David Schneider <david.schneider@bivab.de>
+
+ * src/arm/ffi.c: more robust argument handling for closures on arm hardfloat
+ * testsuite/libffi.call/many_mixed.c: New file.
+ * testsuite/libffi.call/cls_many_mixed_args.c: More tests.
+
+2013-11-02 Vitaly Budovski
+
+ * src/x86/ffi.c (ffi_prep_cif_machdep): Don't align stack for win32.
+
+2013-10-23 Mark H Weaver <mhw@netris.org>
+
+ * src/mips/ffi.c: Fix handling of uint32_t arguments on the
+ MIPS N32 ABI.
+
+2013-10-13 Sandra Loosemore <sandra@codesourcery.com>
+
+ * README: Add Nios II to table of supported platforms.
+ * Makefile.am (EXTRA_DIST): Add nios2 files.
+ (nodist_libffi_la_SOURCES): Likewise.
+ * Makefile.in: Regenerated.
+ * configure.ac (nios2*-linux*): New host.
+ (NIOS2): Add AM_CONDITIONAL.
+ * configure: Regenerated.
+ * src/nios2/ffi.c: New.
+ * src/nios2/ffitarget.h: New.
+ * src/nios2/sysv.S: New.
+ * src/prep_cif.c (initialize_aggregate): Handle extra structure
+ alignment via FFI_AGGREGATE_ALIGNMENT.
+ (ffi_prep_cif_core): Conditionalize structure return for NIOS2.
+
+2013-10-10 Sandra Loosemore <sandra@codesourcery.com>
+
+ * testsuite/libffi.call/cls_many_mixed_args.c (cls_ret_double_fn):
+ Fix uninitialized variable.
+
+2013-10-11 Marcus Shawcroft <marcus.shawcroft@arm.com>
+
+ * testsuite/libffi.call/many.c (many): Replace * with +.
+
+2013-10-08 Ondřej Bílka <neleai@seznam.cz>
+
+ * src/aarch64/ffi.c, src/aarch64/sysv.S, src/arm/ffi.c,
+ src/arm/gentramp.sh, src/bfin/sysv.S, src/closures.c,
+ src/dlmalloc.c, src/ia64/ffi.c, src/microblaze/ffi.c,
+ src/microblaze/sysv.S, src/powerpc/darwin_closure.S,
+ src/powerpc/ffi.c, src/powerpc/ffi_darwin.c, src/sh/ffi.c,
+ src/tile/tile.S, testsuite/libffi.call/nested_struct11.c: Fix
+ spelling errors.
+
+2013-10-08 Anthony Green <green@moxielogic.com>
+
+ * aclocal.m4, compile, config.guess, config.sub, depcomp,
+ install-sh, mdate-sh, missing, texinfo.tex: Update from upstream.
+ * configure.ac: Update version to 3.0.14-rc0.
+ * Makefile.in, configure, Makefile.in, include/Makefile.in,
+ man/Makefile.in, testsuite/Makefile.in: Rebuilt.
+ * README: Mention M88K and VAX.
+
+2013-07-15 Miod Vallat <miod@openbsd.org>
+
+ * Makefile.am,
+ configure.ac,
+ src/m88k/ffi.c,
+ src/m88k/ffitarget.h,
+ src/m88k/obsd.S,
+ src/vax/elfbsd.S,
+ src/vax/ffi.c,
+ src/vax/ffitarget.h: Add m88k and vax support.
+
+2013-06-24 Alan Modra <amodra@gmail.com>
+
+ * src/powerpc/ffi.c (ffi_prep_args_SYSV): Move var declaration
+ before statements.
+ (ffi_prep_args64): Support little-endian.
+ (ffi_closure_helper_SYSV, ffi_closure_helper_LINUX64): Likewise.
+ * src/powerpc/linux64_closure.S (ffi_closure_LINUX64): Likewise.
+ * src/powerpc/ppc_closure.S (ffi_closure_SYSV): Likewise.
+
+2013-06-12 Mischa Jonker <mjonker@synopsys.com>
+
+ * configure.ac: Add support for ARC.
+ * Makefile.am: Likewise.
+ * README: Add ARC details.
+ * src/arc/arcompact.S: New.
+ * src/arc/ffi.c: Likewise.
+ * src/arc/ffitarget.h: Likewise.
+
+2013-03-28 David Schneider <david.schneider@bivab.de>
+
+ * src/arm/ffi.c: Fix support for ARM hard-float calling convention.
+ * src/arm/sysv.S: call different methods for SYSV and VFP ABIs.
+ * testsuite/libffi.call/cls_many_mixed_args.c: testcase for a closure with
+ mixed arguments, many doubles.
+ * testsuite/libffi.call/many_double.c: testcase for calling a function using
+ more than 8 doubles.
+ * testcase/libffi.call/many.c: use absolute value to check result against an
+ epsilon
+
+2013-03-17 Anthony Green <green@moxielogic.com>
+
+ * README: Update for 3.0.13.
+ * configure.ac: Ditto.
+ * configure: Rebuilt.
+ * doc/*: Update version.
+
+2013-03-17 Dave Korn <dave.korn.cygwin@gmail.com>
+
+ * src/closures.c (is_emutramp_enabled
+ [!FFI_MMAP_EXEC_EMUTRAMP_PAX]): Move default definition outside
+ enclosing #if scope.
+
+2013-03-17 Anthony Green <green@moxielogic.com>
+
+ * configure.ac: Only modify toolexecdir in certain cases.
+ * configure: Rebuilt.
+
+2013-03-16 Gilles Talis <gilles.talis@gmail.com>
+
+ * src/powerpc/ffi.c (ffi_prep_args_SYSV): Don't use
+ fparg_count,etc on __NO_FPRS__ targets.
+
+2013-03-16 Alan Hourihane <alanh@fairlite.co.uk>
+
+ * src/m68k/sysv.S (epilogue): Don't use extb instruction on
+ m680000 machines.
+
+2013-03-16 Alex Gaynor <alex.gaynor@gmail.com>
+
+ * src/x86/ffi.c (ffi_prep_cif_machdep): Always align stack.
+
+2013-03-13 Markos Chandras <markos.chandras@imgtec.com>
+
+ * configure.ac: Add support for Imagination Technologies Meta.
+ * Makefile.am: Likewise.
+ * README: Add Imagination Technologies Meta details.
+ * src/metag/ffi.c: New.
+ * src/metag/ffitarget.h: Likewise.
+ * src/metag/sysv.S: Likewise.
+
+2013-02-24 Andreas Schwab <schwab@linux-m68k.org>
+
+ * doc/libffi.texi (Structures): Fix missing category argument of
+ @deftp.
+
+2013-02-11 Anthony Green <green@moxielogic.com>
+
+ * configure.ac: Update release number to 3.0.12.
+ * configure: Rebuilt.
+ * README: Update release info.
+
+2013-02-10 Anthony Green <green@moxielogic.com>
+
+ * README: Add Moxie.
+ * src/moxie/ffi.c: Created.
+ * src/moxie/eabi.S: Created.
+ * src/moxie/ffitarget.h: Created.
+ * Makefile.am (nodist_libffi_la_SOURCES): Add Moxie.
+ * Makefile.in: Rebuilt.
+ * configure.ac: Add Moxie.
+ * configure: Rebuilt.
+ * testsuite/libffi.call/huge_struct.c: Disable format string
+ warnings for moxie*-*-elf tests.
+
+2013-02-10 Anthony Green <green@moxielogic.com>
+
+ * Makefile.am (LTLDFLAGS): Fix reference.
+ * Makefile.in: Rebuilt.
+
+2013-02-10 Anthony Green <green@moxielogic.com>
+
+ * README: Update supported platforms. Update test results link.
+
+2013-02-09 Anthony Green <green@moxielogic.com>
+
+ * testsuite/libffi.call/negint.c: Remove forced -O2.
+ * testsuite/libffi.call/many2.c (foo): Remove GCCism.
+ * testsuite/libffi.call/ffitest.h: Add default PRIuPTR definition.
+
+ * src/sparc/v8.S (ffi_closure_v8): Import ancient ulonglong
+ closure return type fix developed by Martin v. Löwis for cpython
+ fork.
+
+2013-02-08 Andreas Tobler <andreast@fgznet.ch>
+
+ * src/powerpc/ffi.c (ffi_prep_cif_machdep): Fix small struct
+ support.
+ * src/powerpc/sysv.S: Ditto.
+
+2013-02-08 Anthony Green <green@moxielogic.com>
+
+ * testsuite/libffi.call/cls_longdouble.c: Remove xfail for
+ arm*-*-*.
+
+2013-02-08 Anthony Green <green@moxielogic.com>
+
+ * src/sparc/ffi.c (ffi_prep_closure_loc): Fix cache flushing for GCC.
+
+2013-02-08 Matthias Klose <doko@ubuntu.com>
+
+ * man/ffi_prep_cif.3: Clean up for debian linter.
+
+2013-02-08 Peter Bergner <bergner@vnet.ibm.com>
+
+ * src/powerpc/ffi.c (ffi_prep_args_SYSV): Account for FP args pushed
+ on the stack.
+
+2013-02-08 Anthony Green <green@moxielogic.com>
+
+ * Makefile.am (EXTRA_DIST): Add missing files.
+ * testsuite/Makefile.am (EXTRA_DIST): Ditto.
+ * Makefile.in: Rebuilt.
+
+2013-02-08 Anthony Green <green@moxielogic.com>
+
+ * configure.ac: Move sparc asm config checks to within functions
+ for compatibility with sun tools.
+ * configure: Rebuilt.
+ * src/sparc/ffi.c (ffi_prep_closure_loc): Flush cache on v9
+ systems.
+ * src/sparc/v8.S (ffi_flush_icache): Implement a sparc v9 cache
+ flusher.
+
+2013-02-08 Nathan Rossi <nathan.rossi@xilinx.com>
+
+ * src/microblaze/ffi.c (ffi_closure_call_SYSV): Fix handling of
+ small big-endian structures.
+ (ffi_prep_args): Ditto.
+
+2013-02-07 Anthony Green <green@moxielogic.com>
+
+ * src/sparc/v8.S (ffi_call_v8): Fix typo from last patch
+ (effectively hiding ffi_call_v8).
+
+2013-02-07 Anthony Green <green@moxielogic.com>
+
+ * configure.ac: Update bug reporting address.
+ * configure.in: Rebuild.
+
+ * src/sparc/v8.S (ffi_flush_icache): Out-of-line cache flusher for
+ Sun compiler.
+ * src/sparc/ffi.c (ffi_call): Remove warning.
+ Call ffi_flush_icache for non-GCC builds.
+ (ffi_prep_closure_loc): Use ffi_flush_icache.
+
+ * Makefile.am (EXTRA_DIST): Add libtool-ldflags.
+ * Makefile.in: Rebuilt.
+ * libtool-ldflags: New file.
+
+2013-02-07 Daniel Schepler <dschepler@gmail.com>
+
+ * configure.ac: Correctly identify x32 systems as 64-bit.
+ * m4/libtool.m4: Remove libtool expr error.
+ * aclocal.m4, configure: Rebuilt.
+
+2013-02-07 Anthony Green <green@moxielogic.com>
+
+ * configure.ac: Fix GCC usage test.
+ * configure: Rebuilt.
+ * README: Mention LLVM/GCC x86_64 issue.
+ * testsuite/Makefile.in: Rebuilt.
+
+2013-02-07 Anthony Green <green@moxielogic.com>
+
+ * testsuite/libffi.call/cls_double_va.c (main): Replace // style
+ comments with /* */ for xlc compiler.
+ * testsuite/libffi.call/stret_large.c (main): Ditto.
+ * testsuite/libffi.call/stret_large2.c (main): Ditto.
+ * testsuite/libffi.call/nested_struct1.c (main): Ditto.
+ * testsuite/libffi.call/huge_struct.c (main): Ditto.
+ * testsuite/libffi.call/float_va.c (main): Ditto.
+ * testsuite/libffi.call/cls_struct_va1.c (main): Ditto.
+ * testsuite/libffi.call/cls_pointer_stack.c (main): Ditto.
+ * testsuite/libffi.call/cls_pointer.c (main): Ditto.
+ * testsuite/libffi.call/cls_longdouble_va.c (main): Ditto.
+
+2013-02-06 Anthony Green <green@moxielogic.com>
+
+ * man/ffi_prep_cif.3: Clean up for debian lintian checker.
+
+2013-02-06 Anthony Green <green@moxielogic.com>
+
+ * Makefile.am (pkgconfigdir): Add missing pkgconfig install bits.
+ * Makefile.in: Rebuild.
+
+2013-02-02 Mark H Weaver <mhw@netris.org>
+
+ * src/x86/ffi64.c (ffi_call): Sign-extend integer arguments passed
+ via general purpose registers.
+
+2013-01-21 Nathan Rossi <nathan.rossi@xilinx.com>
+
+ * README: Add MicroBlaze details.
+ * Makefile.am: Add MicroBlaze support.
+ * configure.ac: Likewise.
+ * src/microblaze/ffi.c: New.
+ * src/microblaze/ffitarget.h: Likewise.
+ * src/microblaze/sysv.S: Likewise.
+
+2013-01-21 Nathan Rossi <nathan.rossi@xilinx.com>
+ * testsuite/libffi.call/return_uc.c: Fixed issue.
+
+2013-01-21 Chris Zankel <chris@zankel.net>
+
+ * README: Add Xtensa support.
+ * Makefile.am: Likewise.
+ * configure.ac: Likewise.
+ * Makefile.in Regenerate.
+ * configure: Likewise.
+ * src/prep_cif.c: Handle Xtensa.
+ * src/xtensa: New directory.
+ * src/xtensa/ffi.c: New file.
+ * src/xtensa/ffitarget.h: Ditto.
+ * src/xtensa/sysv.S: Ditto.
+
+2013-01-11 Anthony Green <green@moxielogic.com>
+
+ * src/powerpc/ffi_darwin.c (ffi_prep_args): Replace // style
+ comments with /* */ for xlc compiler.
+ * src/powerpc/aix.S (ffi_call_AIX): Ditto.
+ * testsuite/libffi.call/ffitest.h (allocate_mmap): Delete
+ deprecated inline function.
+ * testsuite/libffi.special/ffitestcxx.h: Ditto.
+ * README: Add update for AIX support.
+
+2013-01-11 Anthony Green <green@moxielogic.com>
+
+ * configure.ac: Robustify pc relative reloc check.
+ * m4/ax_cc_maxopt.m4: Don't -malign-double. This is an ABI
+ changing option for 32-bit x86.
+ * aclocal.m4, configure: Rebuilt.
+ * README: Update supported target list.
+
+2013-01-10 Anthony Green <green@moxielogic.com>
+
+ * README (tested): Add Compiler column to table.
+
+2013-01-10 Anthony Green <green@moxielogic.com>
+
+ * src/x86/ffi64.c (struct register_args): Make sse array and array
+ of unions for sunpro compiler compatibility.
+
+2013-01-10 Anthony Green <green@moxielogic.com>
+
+ * configure.ac: Test target platform size_t size. Handle both 32
+ and 64-bit builds for x86_64-* and i?86-* targets (allowing for
+ CFLAG option to change default settings).
+ * configure, aclocal.m4: Rebuilt.
+
+2013-01-10 Anthony Green <green@moxielogic.com>
+
+ * testsuite/libffi.special/special.exp: Only run exception
+ handling tests when using GNU compiler.
+
+ * m4/ax_compiler_vendor.m4: New file.
+ * configure.ac: Test for compiler vendor and don't use
+ AX_CFLAGS_WARN_ALL with the sun compiler.
+ * aclocal.m4, configure: Rebuilt.
+
+2013-01-10 Anthony Green <green@moxielogic.com>
+
+ * include/ffi_common.h: Don't use GCCisms to define types when
+ building with the SUNPRO compiler.
+
+2013-01-10 Anthony Green <green@moxielogic.com>
+
+ * configure.ac: Put local.exp in the right place.
+ * configure: Rebuilt.
+
+ * src/x86/ffi.c: Update comment about regparm function attributes.
+ * src/x86/sysv.S (ffi_closure_SYSV): The SUNPRO compiler requires
+ that all function arguments be passed on the stack (no regparm
+ support).
+
+2013-01-08 Anthony Green <green@moxielogic.com>
+
+ * configure.ac: Generate local.exp. This sets CC_FOR_TARGET
+ when we are using the vendor compiler.
+ * testsuite/Makefile.am (EXTRA_DEJAGNU_SITE_CONFIG): Point to
+ ../local.exp.
+ * configure, testsuite/Makefile.in: Rebuilt.
+
+ * testsuite/libffi.call/call.exp: Run tests with different
+ options, depending on whether or not we are using gcc or the
+ vendor compiler.
+ * testsuite/lib/libffi.exp (libffi-init): Set using_gcc based on
+ whether or not we are building/testing with gcc.
+
+2013-01-08 Anthony Green <green@moxielogic.com>
+
+ * configure.ac: Switch x86 solaris target to X86 by default.
+ * configure: Rebuilt.
+
+2013-01-08 Anthony Green <green@moxielogic.com>
+
+ * configure.ac: Fix test for read-only eh_frame.
+ * configure: Rebuilt.
+
+2013-01-08 Anthony Green <green@moxielogic.com>
+
+ * src/x86/sysv.S, src/x86/unix64.S: Only emit DWARF unwind info
+ when building with the GNU toolchain.
+ * testsuite/libffi.call/ffitest.h (CHECK): Fix for Solaris vendor
+ compiler.
+
+2013-01-07 Thorsten Glaser <tg@mirbsd.org>
+
+ * testsuite/libffi.call/cls_uchar_va.c,
+ testsuite/libffi.call/cls_ushort_va.c,
+ testsuite/libffi.call/va_1.c: Testsuite fixes.
+
+2013-01-07 Thorsten Glaser <tg@mirbsd.org>
+
+ * src/m68k/ffi.c (CIF_FLAGS_SINT8, CIF_FLAGS_SINT16): Define.
+ (ffi_prep_cif_machdep): Fix 8-bit and 16-bit signed calls.
+ * src/m68k/sysv.S (ffi_call_SYSV, ffi_closure_SYSV): Ditto.
+
+2013-01-04 Anthony Green <green@moxielogic.com>
+
+ * Makefile.am (AM_CFLAGS): Don't automatically add -fexceptions
+ and -Wall. This is set in the configure script after testing for
+ GCC.
+ * Makefile.in: Rebuilt.
+
+2013-01-02 rofl0r <https://github.com/rofl0r>
+
+ * src/powerpc/ffi.c (ffi_prep_cif_machdep): Fix build error on ppc
+ when long double == double.
+
+2013-01-02 Reini Urban <rurban@x-ray.at>
+
+ * Makefile.am (libffi_la_LDFLAGS): Add -no-undefined to LDFLAGS
+ (required for shared libs on cygwin/mingw).
+ * Makefile.in: Rebuilt.
+
+2012-10-31 Alan Modra <amodra@gmail.co>
+
+ * src/powerpc/linux64_closure.S: Add new ABI support.
+ * src/powerpc/linux64.S: Likewise.
+
+2012-10-30 Magnus Granberg <zorry@gentoo.org>
+ Pavel Labushev <pavel.labushev@runbox.ru>
+
+ * configure.ac: New options pax_emutramp
+ * configure, fficonfig.h.in: Regenerated
+ * src/closures.c: New function emutramp_enabled_check() and
+ checks.
+
+2012-10-30 Frederick Cheung <frederick.cheung@gmail.com>
+
+ * configure.ac: Enable FFI_MAP_EXEC_WRIT for Darwin 12 (mountain
+ lion) and future version.
+ * configure: Rebuild.
+
+2012-10-30 James Greenhalgh <james.greenhalgh at arm.com>
+ Marcus Shawcroft <marcus.shawcroft at arm.com>
+
+ * README: Add details of aarch64 port.
+ * src/aarch64/ffi.c: New.
+ * src/aarch64/ffitarget.h: Likewise.
+ * src/aarch64/sysv.S: Likewise.
+ * Makefile.am: Support aarch64.
+ * configure.ac: Support aarch64.
+ * Makefile.in, configure: Rebuilt.
+
+2012-10-30 James Greenhalgh <james.greenhalgh at arm.com>
+ Marcus Shawcroft <marcus.shawcroft at arm.com>
+
+ * testsuite/lib/libffi.exp: Add support for aarch64.
+ * testsuite/libffi.call/cls_struct_va1.c: New.
+ * testsuite/libffi.call/cls_uchar_va.c: Likewise.
+ * testsuite/libffi.call/cls_uint_va.c: Likewise.
+ * testsuite/libffi.call/cls_ulong_va.c: Likewise.
+ * testsuite/libffi.call/cls_ushort_va.c: Likewise.
+ * testsuite/libffi.call/nested_struct11.c: Likewise.
+ * testsuite/libffi.call/uninitialized.c: Likewise.
+ * testsuite/libffi.call/va_1.c: Likewise.
+ * testsuite/libffi.call/va_struct1.c: Likewise.
+ * testsuite/libffi.call/va_struct2.c: Likewise.
+ * testsuite/libffi.call/va_struct3.c: Likewise.
+
+2012-10-12 Walter Lee <walt@tilera.com>
+
+ * Makefile.am: Add TILE-Gx/TILEPro support.
+ * configure.ac: Likewise.
+ * Makefile.in: Regenerate.
+ * configure: Likewise.
+ * src/prep_cif.c (ffi_prep_cif_core): Handle TILE-Gx/TILEPro.
+ * src/tile: New directory.
+ * src/tile/ffi.c: New file.
+ * src/tile/ffitarget.h: Ditto.
+ * src/tile/tile.S: Ditto.
+
+2012-10-12 Matthias Klose <doko@ubuntu.com>
+
+ * generate-osx-source-and-headers.py: Normalize whitespace.
+
+2012-09-14 David Edelsohn <dje.gcc@gmail.com>
+
+ * configure: Regenerated.
+
+2012-08-26 Andrew Pinski <apinski@cavium.com>
+
+ PR libffi/53014
+ * src/mips/ffi.c (ffi_prep_closure_loc): Allow n32 with soft-float and n64 with
+ soft-float.
+
+2012-08-08 Uros Bizjak <ubizjak@gmail.com>
+
+ * src/s390/ffi.c (ffi_prep_closure_loc): Don't ASSERT ABI test,
+ just return FFI_BAD_ABI when things are wrong.
+
+2012-07-18 H.J. Lu <hongjiu.lu@intel.com>
+
+ PR libffi/53982
+ PR libffi/53973
+ * src/x86/ffitarget.h: Check __ILP32__ instead of __LP64__ for x32.
+ (FFI_SIZEOF_JAVA_RAW): Defined to 4 for x32.
+
+2012-05-16 H.J. Lu <hongjiu.lu@intel.com>
+
+ * configure: Regenerated.
+
+2012-05-05 Nicolas Lelong
+
+ * libffi.xcodeproj/project.pbxproj: Fixes.
+ * README: Update for iOS builds.
+
+2012-04-23 Alexandre Keunecke I. de Mendonca <alexandre.keunecke@gmail.com>
+
+ * configure.ac: Add Blackfin/sysv support
+ * Makefile.am: Add Blackfin/sysv support
+ * src/bfin/ffi.c: Add Blackfin/sysv support
+ * src/bfin/ffitarget.h: Add Blackfin/sysv support
+
+2012-04-11 Anthony Green <green@moxielogic.com>
+
+ * Makefile.am (EXTRA_DIST): Add new script.
+ * Makefile.in: Rebuilt.
+
+2012-04-11 Zachary Waldowski <zwaldowski@gmail.com>
+
+ * generate-ios-source-and-headers.py,
+ libffi.xcodeproj/project.pbxproj: Support a Mac static library via
+ Xcode. Set iOS compatibility to 4.0. Move iOS trampoline
+ generation into an Xcode "run script" phase. Include both as
+ Xcode build scripts. Don't always regenerate config files.
+
+2012-04-10 Anthony Green <green@moxielogic.com>
+
+ * src/powerpc/ffi_darwin.c (ffi_prep_args): Add missing semicolon.
+
+2012-04-06 Anthony Green <green@moxielogic.com>
+
+ * Makefile.am (EXTRA_DIST): Add new iOS/xcode files.
+ * Makefile.in: Rebuilt.
+
+2012-04-06 Mike Lewis <mikelikespie@gmail.com>
+
+ * generate-ios-source-and-headers.py: New file.
+ * libffi.xcodeproj/project.pbxproj: New file.
+ * README: Update instructions on building iOS binary.
+ * build-ios.sh: Delete.
+
+2012-04-06 Anthony Green <green@moxielogic.com>
+
+ * src/x86/ffi64.c (UINT128): Define differently for Intel and GNU
+ compilers, then use it.
+
+2012-04-06 H.J. Lu <hongjiu.lu@intel.com>
+
+ * m4/libtool.m4 (_LT_ENABLE_LOCK): Support x32.
+
+2012-04-06 Anthony Green <green@moxielogic.com>
+
+ * testsuite/Makefile.am (EXTRA_DIST): Add missing test cases.
+ * testsuite/Makefile.in: Rebuilt.
+
+2012-04-05 Zachary Waldowski <zwaldowski@gmail.com>
+
+ * include/ffi.h.in: Add missing trampoline table fields.
+ * src/arm/sysv.S: Fix ENTRY definition, and wrap symbol references
+ in CNAME.
+ * src/x86/ffi.c: Wrap Windows specific code in ifdefs.
+
+2012-04-02 Peter Bergner <bergner@vnet.ibm.com>
+
+ * src/powerpc/ffi.c (ffi_prep_args_SYSV): Declare double_tmp.
+ Silence casting pointer to integer of different size warning.
+ Delete goto to previously deleted label.
+ (ffi_call): Silence possibly undefined warning.
+ (ffi_closure_helper_SYSV): Declare variable type.
+
+2012-04-02 Peter Rosin <peda@lysator.liu.se>
+
+ * src/x86/win32.S (ffi_call_win32): Sign/zero extend the return
+ value in the Intel version as is already done for the AT&T version.
+ (ffi_closure_SYSV): Likewise.
+ (ffi_closure_raw_SYSV): Likewise.
+ (ffi_closure_STDCALL): Likewise.
+
+2012-03-29 Peter Rosin <peda@lysator.liu.se>
+
+ * src/x86/win32.S (ffi_closure_raw_THISCALL): Unify the frame
+ generation, fix the ENDP label and remove the surplus third arg
+ from the 'lea' insn.
+
+2012-03-29 Peter Rosin <peda@lysator.liu.se>
+
+ * src/x86/win32.S (ffi_closure_raw_SYSV): Make the 'stubraw' label
+ visible outside the PROC, so that ffi_closure_raw_THISCALL can see
+ it. Also instruct the assembler to add a frame to the function.
+
+2012-03-23 Peter Rosin <peda@lysator.liu.se>
+
+ * Makefile.am (AM_CPPFLAGS): Add -DFFI_BUILDING.
+ * Makefile.in: Rebuilt.
+ * include/ffi.h.in [MSVC]: Add __declspec(dllimport) decorations
+ to all data exports, when compiling libffi clients using MSVC.
+
+2012-03-29 Peter Rosin <peda@lysator.liu.se>
+
+ * src/x86/ffitarget.h (ffi_abi): Add new ABI FFI_MS_CDECL and
+ make it the default for MSVC.
+ (FFI_TYPE_MS_STRUCT): New structure return convention.
+ * src/x86/ffi.c (ffi_prep_cif_machdep): Tweak the structure
+ return convention for FFI_MS_CDECL to be FFI_TYPE_MS_STRUCT
+ instead of an ordinary FFI_TYPE_STRUCT.
+ (ffi_prep_args): Treat FFI_TYPE_MS_STRUCT as FFI_TYPE_STRUCT.
+ (ffi_call): Likewise.
+ (ffi_prep_incoming_args_SYSV): Likewise.
+ (ffi_raw_call): Likewise.
+ (ffi_prep_closure_loc): Treat FFI_MS_CDECL as FFI_SYSV.
+ * src/x86/win32.S (ffi_closure_SYSV): For FFI_TYPE_MS_STRUCT,
+ return a pointer to the result structure in eax and don't pop
+ that pointer from the stack, the caller takes care of it.
+ (ffi_call_win32): Treat FFI_TYPE_MS_STRUCT as FFI_TYPE_STRUCT.
+ (ffi_closure_raw_SYSV): Likewise.
+
+2012-03-22 Peter Rosin <peda@lysator.liu.se>
+
+ * testsuite/libffi.call/closure_stdcall.c [MSVC]: Add inline
+ assembly version with Intel syntax.
+ * testsuite/libffi.call/closure_thiscall.c [MSVC]: Likewise.
+
+2012-03-23 Peter Rosin <peda@lysator.liu.se>
+
+ * testsuite/libffi.call/ffitest.h: Provide abstration of
+ __attribute__((fastcall)) in the form of a __FASTCALL__
+ define. Define it to __fastcall for MSVC.
+ * testsuite/libffi.call/fastthis1_win32.c: Use the above.
+ * testsuite/libffi.call/fastthis2_win32.c: Likewise.
+ * testsuite/libffi.call/fastthis3_win32.c: Likewise.
+ * testsuite/libffi.call/strlen2_win32.c: Likewise.
+ * testsuite/libffi.call/struct1_win32.c: Likewise.
+ * testsuite/libffi.call/struct2_win32.c: Likewise.
+
+2012-03-22 Peter Rosin <peda@lysator.liu.se>
+
+ * src/x86/win32.S [MSVC] (ffi_closure_THISCALL): Remove the manual
+ frame on function entry, MASM adds one automatically.
+
+2012-03-22 Peter Rosin <peda@lysator.liu.se>
+
+ * testsuite/libffi.call/ffitest.h [MSVC]: Add kludge for missing
+ bits in the MSVC headers.
+
+2012-03-22 Peter Rosin <peda@lysator.liu.se>
+
+ * testsuite/libffi.call/cls_12byte.c: Adjust to the C89 style
+ with no declarations after statements.
+ * testsuite/libffi.call/cls_16byte.c: Likewise.
+ * testsuite/libffi.call/cls_18byte.c: Likewise.
+ * testsuite/libffi.call/cls_19byte.c: Likewise.
+ * testsuite/libffi.call/cls_1_1byte.c: Likewise.
+ * testsuite/libffi.call/cls_20byte.c: Likewise.
+ * testsuite/libffi.call/cls_20byte1.c: Likewise.
+ * testsuite/libffi.call/cls_24byte.c: Likewise.
+ * testsuite/libffi.call/cls_2byte.c: Likewise.
+ * testsuite/libffi.call/cls_3_1byte.c: Likewise.
+ * testsuite/libffi.call/cls_3byte1.c: Likewise.
+ * testsuite/libffi.call/cls_3byte2.c: Likewise.
+ * testsuite/libffi.call/cls_4_1byte.c: Likewise.
+ * testsuite/libffi.call/cls_4byte.c: Likewise.
+ * testsuite/libffi.call/cls_5_1_byte.c: Likewise.
+ * testsuite/libffi.call/cls_5byte.c: Likewise.
+ * testsuite/libffi.call/cls_64byte.c: Likewise.
+ * testsuite/libffi.call/cls_6_1_byte.c: Likewise.
+ * testsuite/libffi.call/cls_6byte.c: Likewise.
+ * testsuite/libffi.call/cls_7_1_byte.c: Likewise.
+ * testsuite/libffi.call/cls_7byte.c: Likewise.
+ * testsuite/libffi.call/cls_8byte.c: Likewise.
+ * testsuite/libffi.call/cls_9byte1.c: Likewise.
+ * testsuite/libffi.call/cls_9byte2.c: Likewise.
+ * testsuite/libffi.call/cls_align_double.c: Likewise.
+ * testsuite/libffi.call/cls_align_float.c: Likewise.
+ * testsuite/libffi.call/cls_align_longdouble.c: Likewise.
+ * testsuite/libffi.call/cls_align_longdouble_split.c: Likewise.
+ * testsuite/libffi.call/cls_align_longdouble_split2.c: Likewise.
+ * testsuite/libffi.call/cls_align_pointer.c: Likewise.
+ * testsuite/libffi.call/cls_align_sint16.c: Likewise.
+ * testsuite/libffi.call/cls_align_sint32.c: Likewise.
+ * testsuite/libffi.call/cls_align_sint64.c: Likewise.
+ * testsuite/libffi.call/cls_align_uint16.c: Likewise.
+ * testsuite/libffi.call/cls_align_uint32.c: Likewise.
+ * testsuite/libffi.call/cls_align_uint64.c: Likewise.
+ * testsuite/libffi.call/cls_dbls_struct.c: Likewise.
+ * testsuite/libffi.call/cls_pointer_stack.c: Likewise.
+ * testsuite/libffi.call/err_bad_typedef.c: Likewise.
+ * testsuite/libffi.call/huge_struct.c: Likewise.
+ * testsuite/libffi.call/nested_struct.c: Likewise.
+ * testsuite/libffi.call/nested_struct1.c: Likewise.
+ * testsuite/libffi.call/nested_struct10.c: Likewise.
+ * testsuite/libffi.call/nested_struct2.c: Likewise.
+ * testsuite/libffi.call/nested_struct3.c: Likewise.
+ * testsuite/libffi.call/nested_struct4.c: Likewise.
+ * testsuite/libffi.call/nested_struct5.c: Likewise.
+ * testsuite/libffi.call/nested_struct6.c: Likewise.
+ * testsuite/libffi.call/nested_struct7.c: Likewise.
+ * testsuite/libffi.call/nested_struct8.c: Likewise.
+ * testsuite/libffi.call/nested_struct9.c: Likewise.
+ * testsuite/libffi.call/stret_large.c: Likewise.
+ * testsuite/libffi.call/stret_large2.c: Likewise.
+ * testsuite/libffi.call/stret_medium.c: Likewise.
+ * testsuite/libffi.call/stret_medium2.c: Likewise.
+ * testsuite/libffi.call/struct1.c: Likewise.
+ * testsuite/libffi.call/struct1_win32.c: Likewise.
+ * testsuite/libffi.call/struct2.c: Likewise.
+ * testsuite/libffi.call/struct2_win32.c: Likewise.
+ * testsuite/libffi.call/struct3.c: Likewise.
+ * testsuite/libffi.call/struct4.c: Likewise.
+ * testsuite/libffi.call/struct5.c: Likewise.
+ * testsuite/libffi.call/struct6.c: Likewise.
+ * testsuite/libffi.call/struct7.c: Likewise.
+ * testsuite/libffi.call/struct8.c: Likewise.
+ * testsuite/libffi.call/struct9.c: Likewise.
+ * testsuite/libffi.call/testclosure.c: Likewise.
+
+2012-03-21 Peter Rosin <peda@lysator.liu.se>
+
+ * testsuite/libffi.call/float_va.c (float_va_fn): Use %f when
+ printing doubles (%lf is for long doubles).
+ (main): Likewise.
+
+2012-03-21 Peter Rosin <peda@lysator.liu.se>
+
+ * testsuite/lib/target-libpath.exp [*-*-cygwin*, *-*-mingw*]
+ (set_ld_library_path_env_vars): Add the library search dir to PATH
+ (and save PATH for later).
+ (restore_ld_library_path_env_vars): Restore PATH.
+
+2012-03-21 Peter Rosin <peda@lysator.liu.se>
+
+ * testsuite/lib/target-libpath.exp [*-*-cygwin*, *-*-mingw*]
+ (set_ld_library_path_env_vars): Add the library search dir to PATH
+ (and save PATH for later).
+ (restore_ld_library_path_env_vars): Restore PATH.
+
+2012-03-20 Peter Rosin <peda@lysator.liu.se>
+
+ * testsuite/libffi.call/strlen2_win32.c (main): Remove bug.
+ * src/x86/win32.S [MSVC] (ffi_closure_SYSV): Make the 'stub' label
+ visible outside the PROC, so that ffi_closure_THISCALL can see it.
+
+2012-03-20 Peter Rosin <peda@lysator.liu.se>
+
+ * testsuite/libffi.call/strlen2_win32.c (main): Remove bug.
+ * src/x86/win32.S [MSVC] (ffi_closure_SYSV): Make the 'stub' label
+ visible outside the PROC, so that ffi_closure_THISCALL can see it.
+
+2012-03-19 Alan Hourihane <alanh@fairlite.co.uk>
+
+ * src/m68k/ffi.c: Add MINT support.
+ * src/m68k/sysv.S: Ditto.
+
+2012-03-06 Chung-Lin Tang <cltang@codesourcery.com>
+
+ * src/arm/ffi.c (ffi_call): Add __ARM_EABI__ guard around call to
+ ffi_call_VFP().
+ (ffi_prep_closure_loc): Add __ARM_EABI__ guard around use of
+ ffi_closure_VFP.
+ * src/arm/sysv.S: Add __ARM_EABI__ guard around VFP code.
+
+2012-03-19 chennam <csit@axway.com>
+
+ * src/powerpc/ffi_darwin.c (ffi_prep_closure_loc): Fix AIX closure
+ support.
+
+2012-03-13 Kaz Kojima <kkojima@gcc.gnu.org>
+
+ * src/sh/ffi.c (ffi_prep_closure_loc): Don't ASSERT ABI test,
+ just return FFI_BAD_ABI when things are wrong.
+ * src/sh64/ffi.c (ffi_prep_closure_loc): Ditto.
+
+2012-03-09 David Edelsohn <dje.gcc@gmail.com>
+
+ * src/powerpc/aix_closure.S (ffi_closure_ASM): Adjust for Darwin64
+ change to return value of ffi_closure_helper_DARWIN and load type
+ from return type.
+
+2012-03-03 H.J. Lu <hongjiu.lu@intel.com>
+
+ * src/x86/ffi64.c (ffi_call): Cast the return value to unsigned
+ long.
+ (ffi_prep_closure_loc): Cast to 64bit address in trampoline.
+ (ffi_closure_unix64_inner): Cast return pointer to unsigned long
+ first.
+
+ * src/x86/ffitarget.h (FFI_SIZEOF_ARG): Defined to 8 for x32.
+ (ffi_arg): Set to unsigned long long for x32.
+ (ffi_sarg): Set to long long for x32.
+
+2012-03-03 H.J. Lu <hongjiu.lu@intel.com>
+
+ * src/prep_cif.c (ffi_prep_cif_core): Properly check bad ABI.
+
+2012-03-03 Andoni Morales Alastruey <ylatuya@gmail.com>
+
+ * configure.ac: Add -no-undefined for both 32- and 64-bit x86
+ windows-like hosts.
+ * configure: Rebuilt.
+
+2012-02-27 Mikael Pettersson <mikpe@it.uu.se>
+
+ PR libffi/52223
+ * Makefile.am (FLAGS_TO_PASS): Define.
+ * Makefile.in: Regenerate.
+
+2012-02-23 Anthony Green <green@moxielogic.com>
+
+ * src/*/ffitarget.h: Ensure that users never include ffitarget.h
+ directly.
+
+2012-02-23 Kai Tietz <ktietz@redhat.com>
+
+ PR libffi/52221
+ * src/x86/ffi.c (ffi_closure_raw_THISCALL): New
+ prototype.
+ (ffi_prep_raw_closure_loc): Use ffi_closure_raw_THISCALL for
+ thiscall-convention.
+ (ffi_raw_call): Use ffi_prep_args_raw.
+ * src/x86/win32.S (ffi_closure_raw_THISCALL): Add
+ implementation for stub.
+
+2012-02-10 Kai Tietz <ktietz@redhat.com>
+
+ * configure.ac (AM_LTLDFLAGS): Add -no-undefine for x64
+ windows target.
+ * configure: Regenerated.
+
+2012-02-08 Kai Tietz <ktietz@redhat.com>
+
+ * src/prep_cif.c (ffi_prep_cif): Allow for X86_WIN32
+ also FFI_THISCALL.
+ * src/x86/ffi.c (ffi_closure_THISCALL): Add prototype.
+ (FFI_INIT_TRAMPOLINE_THISCALL): New trampoline code.
+ (ffi_prep_closure_loc): Add FFI_THISCALL support.
+ * src/x86/ffitarget.h (FFI_TRAMPOLINE_SIZE): Adjust size.
+ * src/x86/win32.S (ffi_closure_THISCALL): New closure code
+ for thiscall-calling convention.
+ * testsuite/libffi.call/closure_thiscall.c: New test.
+
+2012-01-28 Kai Tietz <ktietz@redhat.com>
+
+ * src/libffi/src/x86/ffi.c (ffi_call_win32): Add new
+ argument to prototype for specify calling-convention.
+ (ffi_call): Add support for stdcall/thiscall convention.
+ (ffi_prep_args): Likewise.
+ (ffi_raw_call): Likewise.
+ * src/x86/ffitarget.h (ffi_abi): Add FFI_THISCALL and
+ FFI_FASTCALL.
+ * src/x86/win32.S (_ffi_call_win32): Add support for
+ fastcall/thiscall calling-convention calls.
+ * testsuite/libffi.call/fastthis1_win32.c: New test.
+ * testsuite/libffi.call/fastthis2_win32.c: New test.
+ * testsuite/libffi.call/fastthis3_win32.c: New test.
+ * testsuite/libffi.call/strlen2_win32.c: New test.
+ * testsuite/libffi.call/many2_win32.c: New test.
+ * testsuite/libffi.call/struct1_win32.c: New test.
+ * testsuite/libffi.call/struct2_win32.c: New test.
+
+2012-01-23 Uros Bizjak <ubizjak@gmail.com>
+
+ * src/alpha/ffi.c (ffi_prep_closure_loc): Check for bad ABI.
+
+2012-01-23 Anthony Green <green@moxielogic.com>
+ Chris Young <cdyoung@ntlworld.com>
+
+ * configure.ac: Add Amiga support.
+ * configure: Rebuilt.
+
+2012-01-23 Dmitry Nadezhin <dmitry.nadezhin@gmail.com>
+
+ * include/ffi_common.h (LIKELY, UNLIKELY): Fix definitions.
+
+2012-01-23 Andreas Schwab <schwab@linux-m68k.org>
+
+ * src/m68k/sysv.S (ffi_call_SYSV): Properly test for plain
+ mc68000. Test for __HAVE_68881__ in addition to __MC68881__.
+
+2012-01-19 Jakub Jelinek <jakub@redhat.com>
+
+ PR rtl-optimization/48496
+ * src/ia64/ffi.c (ffi_call): Fix up aliasing violations.
+
+2012-01-09 Rainer Orth <ro@CeBiTec.Uni-Bielefeld.DE>
+
+ * configure.ac (i?86-*-*): Set TARGET to X86_64.
+ * configure: Regenerate.
+
+2011-12-07 Andrew Pinski <apinski@cavium.com>
+
+ PR libffi/50051
+ * src/mips/n32.S: Add ".set mips4".
+
+2011-11-21 Andreas Tobler <andreast@fgznet.ch>
+
+ * configure: Regenerate.
+
+2011-11-12 David Gilbert <david.gilbert@linaro.org>
+
+ * doc/libffi.texi, include/ffi.h.in, include/ffi_common.h,
+ man/Makefile.am, man/ffi.3, man/ffi_prep_cif.3,
+ man/ffi_prep_cif_var.3, src/arm/ffi.c, src/arm/ffitarget.h,
+ src/cris/ffi.c, src/prep_cif.c,
+ testsuite/libffi.call/cls_double_va.c,
+ testsuite/libffi.call/cls_longdouble_va.c,
+ testsuite/libffi.call/float_va.c: Many changes to support variadic
+ function calls.
+
+2011-11-12 Kyle Moffett <Kyle.D.Moffett@boeing.com>
+
+ * src/powerpc/ffi.c, src/powerpc/ffitarget.h,
+ src/powerpc/ppc_closure.S, src/powerpc/sysv.S: Many changes for
+ softfloat powerpc variants.
+
+2011-11-12 Petr Salinger <Petr.Salinger@seznam.cz>
+
+ * configure.ac (FFI_EXEC_TRAMPOLINE_TABLE): Fix kfreebsd support.
+ * configure: Rebuilt.
+
+2011-11-12 Timothy Wall <twall@users.sf.net>
+
+ * src/arm/ffi.c (ffi_prep_args, ffi_prep_incoming_args_SYSV): Max
+ alignment of 4 for wince on ARM.
+
+2011-11-12 Kyle Moffett <Kyle.D.Moffett@boeing.com>
+ Anthony Green <green@moxielogic.com>
+
+ * src/ppc/sysv.S, src/ppc/ffi.c: Remove use of ppc string
+ instructions (not available on some cores, like the PPC440).
+
+2011-11-12 Kimura Wataru <kimuraw@i.nifty.jp>
+
+ * m4/ax_enable_builddir: Change from string comparison to numeric
+ comparison for wc output.
+ * configure.ac: Enable FFI_MMAP_EXEC_WRIT for darwin11 aka Mac OS
+ X 10.7.
+ * configure: Rebuilt.
+
+2011-11-12 Anthony Green <green@moxielogic.com>
+
+ * Makefile.am (AM_CCASFLAGS): Add -g option to build assembly
+ files with debug info.
+ * Makefile.in: Rebuilt.
+
+2011-11-12 Jasper Lievisse Adriaanse <jasper@openbsd.org>
+
+ * README: Update list of supported OpenBSD systems.
+
+2011-11-12 Anthony Green <green@moxielogic.com>
+
+ * libtool-version: Update.
+ * Makefile.am (nodist_libffi_la_SOURCES): Add src/debug.c if
+ FFI_DEBUG.
+ (libffi_la_SOURCES): Remove src/debug.c
+ (EXTRA_DIST): Add src/debug.c
+ * Makefile.in: Rebuilt.
+ * README: Update for 3.0.11.
+
+2011-11-10 Richard Henderson <rth@redhat.com>
+
+ * configure.ac (GCC_AS_CFI_PSEUDO_OP): Use it instead of inline check.
+ * configure, aclocal.m4: Rebuild.
+
+2011-09-04 Iain Sandoe <iains@gcc.gnu.org>
+
+ PR libffi/49594
+ * src/powerpc/darwin_closure.S (stubs): Make the stub binding
+ helper reference track the architecture pointer size.
+
+2011-08-25 Andrew Haley <aph@redhat.com>
+
+ * src/arm/ffi.c (FFI_INIT_TRAMPOLINE): Remove hard-coded assembly
+ instructions.
+ * src/arm/sysv.S (ffi_arm_trampoline): Put them here instead.
+
+2011-07-11 Andrew Haley <aph@redhat.com>
+
+ * src/arm/ffi.c (FFI_INIT_TRAMPOLINE): Clear icache.
+
+2011-06-29 Rainer Orth <ro@CeBiTec.Uni-Bielefeld.DE>
+
+ * testsuite/libffi.call/cls_double_va.c: Move PR number to comment.
+ * testsuite/libffi.call/cls_longdouble_va.c: Likewise.
+
+2011-06-29 Rainer Orth <ro@CeBiTec.Uni-Bielefeld.DE>
+
+ PR libffi/46660
+ * testsuite/libffi.call/cls_double_va.c: xfail dg-output on
+ mips-sgi-irix6*.
+ * testsuite/libffi.call/cls_longdouble_va.c: Likewise.
+
+2011-06-14 Rainer Orth <ro@CeBiTec.Uni-Bielefeld.DE>
+
+ * testsuite/libffi.call/huge_struct.c (test_large_fn): Use PRIu8,
+ PRId8 instead of %hhu, %hhd.
+ * testsuite/libffi.call/ffitest.h [__alpha__ && __osf__] (PRId8,
+ PRIu8): Define.
+ [__sgi__] (PRId8, PRIu8): Define.
+
+2011-04-29 Rainer Orth <ro@CeBiTec.Uni-Bielefeld.DE>
+
+ * src/alpha/osf.S (UA_SI, FDE_ENCODING, FDE_ENCODE, FDE_ARANGE):
+ Define.
+ Use them to handle ELF vs. ECOFF differences.
+ [__osf__] (_GLOBAL__F_ffi_call_osf): Define.
+
+2011-03-30 Timothy Wall <twall@users.sf.net>
+
+ * src/powerpc/darwin.S: Fix unknown FDE encoding.
+ * src/powerpc/darwin_closure.S: ditto.
+
+2011-02-25 Anthony Green <green@moxielogic.com>
+
+ * src/powerpc/ffi.c (ffi_prep_closure_loc): Allow for more
+ 32-bit ABIs.
+
+2011-02-15 Anthony Green <green@moxielogic.com>
+
+ * m4/ax_cc_maxopt.m4: Don't -malign-double or use -ffast-math.
+ * configure: Rebuilt.
+
+2011-02-13 Ralf Wildenhues <Ralf.Wildenhues@gmx.de>
+
+ * configure: Regenerate.
+
+2011-02-13 Anthony Green <green@moxielogic.com>
+
+ * include/ffi_common.h (UNLIKELY, LIKELY): Define.
+ * src/x86/ffi64.c (UNLIKELY, LIKELY): Remove definition.
+ * src/prep_cif.c (UNLIKELY, LIKELY): Remove definition.
+
+ * src/prep_cif.c (initialize_aggregate): Convert assertion into
+ FFI_BAD_TYPEDEF return. Initialize arg size and alignment to 0.
+
+ * src/pa/ffi.c (ffi_prep_closure_loc): Don't ASSERT ABI test,
+ just return FFI_BAD_ABI when things are wrong.
+ * src/arm/ffi.c (ffi_prep_closure_loc): Ditto.
+ * src/powerpc/ffi.c (ffi_prep_closure_loc): Ditto.
+ * src/mips/ffi.c (ffi_prep_closure_loc): Ditto.
+ * src/ia64/ffi.c (ffi_prep_closure_loc): Ditto.
+ * src/avr32/ffi.c (ffi_prep_closure_loc): Ditto.
+
+2011-02-11 Anthony Green <green@moxielogic.com>
+
+ * src/sparc/ffi.c (ffi_prep_closure_loc): Don't ASSERT ABI test,
+ just return FFI_BAD_ABI when things are wrong.
+
+2012-02-11 Eric Botcazou <ebotcazou@adacore.com>
+
+ * src/sparc/v9.S (STACKFRAME): Bump to 176.
+
+2011-02-09 Stuart Shelton <srcshelton@gmail.com>
+
+ http://bugs.gentoo.org/show_bug.cgi?id=286911
+ * src/mips/ffitarget.h: Clean up error messages.
+ * src/java_raw_api.c (ffi_java_translate_args): Cast raw arg to
+ ffi_raw*.
+ * include/ffi.h.in: Add pragma for SGI compiler.
+
+2011-02-09 Anthony Green <green@moxielogic.com>
+
+ * configure.ac: Add powerpc64-*-darwin* support.
+
+2011-02-09 Anthony Green <green@moxielogic.com>
+
+ * README: Mention Interix.
+
+2011-02-09 Jonathan Callen <abcd@gentoo.org>
+
+ * configure.ac: Add Interix to win32/cygwin/mingw case.
+ * configure: Ditto.
+ * src/closures.c: Treat Interix like Cygwin, instead of as a
+ generic win32.
+
+2011-02-09 Anthony Green <green@moxielogic.com>
+
+ * testsuite/libffi.call/err_bad_typedef.c: Remove xfail.
+ * testsuite/libffi.call/err_bad_abi.c: Remove xfail.
+ * src/x86/ffi64.c (UNLIKELY, LIKELY): Define.
+ (ffi_prep_closure_loc): Check for bad ABI.
+ * src/prep_cif.c (UNLIKELY, LIKELY): Define.
+ (initialize_aggregate): Check for bad types.
+
+2011-02-09 Landon Fuller <landonf@plausible.coop>
+
+ * Makefile.am (EXTRA_DIST): Add build-ios.sh, src/arm/gentramp.sh,
+ src/arm/trampoline.S.
+ (nodist_libffi_la_SOURCES): Add src/arc/trampoline.S.
+ * configure.ac (FFI_EXEC_TRAMPOLINE_TABLE): Define.
+ * src/arm/ffi.c (ffi_trampoline_table)
+ (ffi_closure_trampoline_table_page, ffi_trampoline_table_entry)
+ (FFI_TRAMPOLINE_CODELOC_CONFIG, FFI_TRAMPOLINE_CONFIG_PAGE_OFFSET)
+ (FFI_TRAMPOLINE_COUNT, ffi_trampoline_lock, ffi_trampoline_tables)
+ (ffi_trampoline_table_alloc, ffi_closure_alloc, ffi_closure_free):
+ Define for FFI_EXEC_TRAMPOLINE_TABLE case (iOS).
+ (ffi_prep_closure_loc): Handl FFI_EXEC_TRAMPOLINE_TABLE case
+ separately.
+ * src/arm/sysv.S: Handle Apple iOS host.
+ * src/closures.c: Handle FFI_EXEC_TRAMPOLINE_TABLE case.
+ * build-ios.sh: New file.
+ * fficonfig.h.in, configure, Makefile.in: Rebuilt.
+ * README: Mention ARM iOS.
+
+2011-02-08 Oren Held <orenhe@il.ibm.com>
+
+ * src/dlmalloc.c (_STRUCT_MALLINFO): Define in order to avoid
+ redefinition of mallinfo on HP-UX.
+
+2011-02-08 Ginn Chen <ginn.chen@oracle.com>
+
+ * src/sparc/ffi.c (ffi_call): Make compatible with Solaris Studio
+ aggregate return ABI. Flush cache.
+ (ffi_prep_closure_loc): Flush cache.
+
+2011-02-11 Anthony Green <green@moxielogic.com>
+
+ From Tom Honermann <tom.honermann@oracle.com>:
+ * src/powerpc/aix.S (ffi_call_AIX): Support for xlc toolchain on
+ AIX. Declare .ffi_prep_args. Insert nops after branch
+ instructions so that the AIX linker can insert TOC reload
+ instructions.
+ * src/powerpc/aix_closure.S: Declare .ffi_closure_helper_DARWIN.
+
+2011-02-08 Ed <ed@kdtc.net>
+
+ * src/powerpc/asm.h: Fix grammar nit in comment.
+
+2011-02-08 Uli Link <ul.mcamafia@linkitup.de>
+
+ * include/ffi.h.in (FFI_64_BIT_MAX): Define and use.
+
+2011-02-09 Rainer Orth <ro@CeBiTec.Uni-Bielefeld.DE>
+
+ PR libffi/46661
+ * testsuite/libffi.call/cls_pointer.c (main): Cast void * to
+ uintptr_t first.
+ * testsuite/libffi.call/cls_pointer_stack.c (main): Likewise.
+
+2011-02-08 Rafael Avila de Espindola <respindola@mozilla.com>
+
+ * configure.ac: Fix x86 test for pc related relocs.
+ * configure: Rebuilt.
+
+2011-02-07 Joel Sherrill <joel.sherrill@oarcorp.com>
+
+ * libffi/src/m68k/ffi.c: Add RTEMS support for cache flushing.
+ Handle case when CPU variant does not have long double support.
+ * libffi/src/m68k/sysv.S: Add support for mc68000, Coldfire,
+ and cores with soft floating point.
+
+2011-02-07 Joel Sherrill <joel.sherrill@oarcorp.com>
+
+ * configure.ac: Add mips*-*-rtems* support.
+ * configure: Regenerate.
+ * src/mips/ffitarget.h: Ensure needed constants are available
+ for targets which do not have sgidefs.h.
+
+2011-01-26 Dave Korn <dave.korn.cygwin@gmail.com>
+
+ PR target/40125
+ * configure.ac (AM_LTLDFLAGS): Add -bindir option for windows DLLs.
+ * configure: Regenerate.
+
+2010-12-18 Iain Sandoe <iains@gcc.gnu.org>
+
+ PR libffi/29152
+ PR libffi/42378
+ * src/powerpc/darwin_closure.S: Provide Darwin64 implementation,
+ update comments.
+ * src/powerpc/ffitarget.h (POWERPC_DARWIN64): New,
+ (FFI_TRAMPOLINE_SIZE): Update for Darwin64.
+ * src/powerpc/darwin.S: Provide Darwin64 implementation,
+ update comments.
+ * src/powerpc/ffi_darwin.c: Likewise.
+
+2010-12-06 Rainer Orth <ro@CeBiTec.Uni-Bielefeld.DE>
+
+ * configure.ac (libffi_cv_as_ascii_pseudo_op): Use double
+ backslashes.
+ (libffi_cv_as_string_pseudo_op): Likewise.
+ * configure: Regenerate.
+
+2010-12-03 Chung-Lin Tang <cltang@codesourcery.com>
+
+ * src/arm/sysv.S (ffi_closure_SYSV): Add UNWIND to .pad directive.
+ (ffi_closure_VFP): Same.
+ (ffi_call_VFP): Move down to before ffi_closure_VFP. Add '.fpu vfp'
+ directive.
+
+2010-12-01 Rainer Orth <ro@CeBiTec.Uni-Bielefeld.DE>
+
+ * testsuite/libffi.call/ffitest.h [__sgi] (PRId64, PRIu64): Define.
+ (PRIuPTR): Define.
+
+2010-11-29 Richard Henderson <rth@redhat.com>
+ Rainer Orth <ro@CeBiTec.Uni-Bielefeld.DE>
+
+ * src/x86/sysv.S (FDE_ENCODING, FDE_ENCODE): Define.
+ (.eh_frame): Use FDE_ENCODING.
+ (.LASFDE1, .LASFDE2, LASFDE3): Simplify with FDE_ENCODE.
+
+2010-11-22 Jacek Caban <jacek@codeweavers.com>
+
+ * configure.ac: Check for symbol underscores on mingw-w64.
+ * configure: Rebuilt.
+ * src/x86/win64.S: Correctly access extern symbols in respect to
+ underscores.
+
+2010-11-15 Rainer Orth <ro@CeBiTec.Uni-Bielefeld.DE>
+
+ * testsuite/lib/libffi-dg.exp: Rename ...
+ * testsuite/lib/libffi.exp: ... to this.
+ * libffi/testsuite/libffi.call/call.exp: Don't load libffi-dg.exp.
+ * libffi/testsuite/libffi.special/special.exp: Likewise.
+
+2010-10-28 Chung-Lin Tang <cltang@codesourcery.com>
+
+ * src/arm/ffi.c (ffi_prep_args): Add VFP register argument handling
+ code, new parameter, and return value. Update comments.
+ (ffi_prep_cif_machdep): Add case for VFP struct return values. Add
+ call to layout_vfp_args().
+ (ffi_call_SYSV): Update declaration.
+ (ffi_call_VFP): New declaration.
+ (ffi_call): Add VFP struct return conditions. Call ffi_call_VFP()
+ when ABI is FFI_VFP.
+ (ffi_closure_VFP): New declaration.
+ (ffi_closure_SYSV_inner): Add new vfp_args parameter, update call to
+ ffi_prep_incoming_args_SYSV().
+ (ffi_prep_incoming_args_SYSV): Update parameters. Add VFP argument
+ case handling.
+ (ffi_prep_closure_loc): Pass ffi_closure_VFP to trampoline
+ construction under VFP hard-float.
+ (rec_vfp_type_p): New function.
+ (vfp_type_p): Same.
+ (place_vfp_arg): Same.
+ (layout_vfp_args): Same.
+ * src/arm/ffitarget.h (ffi_abi): Add FFI_VFP. Define FFI_DEFAULT_ABI
+ based on __ARM_PCS_VFP.
+ (FFI_EXTRA_CIF_FIELDS): Define for adding VFP hard-float specific
+ fields.
+ (FFI_TYPE_STRUCT_VFP_FLOAT): Define internally used type code.
+ (FFI_TYPE_STRUCT_VFP_DOUBLE): Same.
+ * src/arm/sysv.S (ffi_call_SYSV): Change call of ffi_prep_args() to
+ direct call. Move function pointer load upwards.
+ (ffi_call_VFP): New function.
+ (ffi_closure_VFP): Same.
+
+ * testsuite/lib/libffi-dg.exp (check-flags): New function.
+ (dg-skip-if): New function.
+ * testsuite/libffi.call/cls_double_va.c: Skip if target is arm*-*-*
+ and compiler options include -mfloat-abi=hard.
+ * testsuite/libffi.call/cls_longdouble_va.c: Same.
+
+2010-10-01 Jakub Jelinek <jakub@redhat.com>
+
+ PR libffi/45677
+ * src/x86/ffi64.c (ffi_prep_cif_machdep): Ensure cif->bytes is
+ a multiple of 8.
+ * testsuite/libffi.call/many2.c: New test.
+
+2010-08-20 Mark Wielaard <mjw@redhat.com>
+
+ * src/closures.c (open_temp_exec_file_mnt): Check if getmntent_r
+ returns NULL.
+
+2010-08-09 Andreas Tobler <andreast@fgznet.ch>
+
+ * configure.ac: Add target powerpc64-*-freebsd*.
+ * configure: Regenerate.
+ * testsuite/libffi.call/cls_align_longdouble_split.c: Pass
+ -mlong-double-128 only to linux targets.
+ * testsuite/libffi.call/cls_align_longdouble_split2.c: Likewise.
+ * testsuite/libffi.call/cls_longdouble.c: Likewise.
+ * testsuite/libffi.call/huge_struct.c: Likewise.
+
+2010-08-05 Dan Witte <dwitte@mozilla.com>
+
+ * Makefile.am: Pass FFI_DEBUG define to msvcc.sh for linking to the
+ debug CRT when --enable-debug is given.
+ * configure.ac: Define it.
+ * msvcc.sh: Translate -g and -DFFI_DEBUG appropriately.
+
+2010-08-04 Dan Witte <dwitte@mozilla.com>
+
+ * src/x86/ffitarget.h: Add X86_ANY define for all x86/x86_64
+ platforms.
+ * src/x86/ffi.c: Remove redundant ifdef checks.
+ * src/prep_cif.c: Push stack space computation into src/x86/ffi.c
+ for X86_ANY so return value space doesn't get added twice.
+
+2010-08-03 Neil Rashbrooke <neil@parkwaycc.co.uk>
+
+ * msvcc.sh: Don't pass -safeseh to ml64 because behavior is buggy.
+
+2010-07-22 Dan Witte <dwitte@mozilla.com>
+
+ * src/*/ffitarget.h: Make FFI_LAST_ABI one past the last valid ABI.
+ * src/prep_cif.c: Fix ABI assertion.
+ * src/cris/ffi.c: Ditto.
+
+2010-07-10 Evan Phoenix <evan@fallingsnow.net>
+
+ * src/closures.c (selinux_enabled_check): Fix strncmp usage bug.
+
+2010-07-07 Dan Horák <dan@danny.cz>
+
+ * include/ffi.h.in: Protect #define with #ifndef.
+ * src/powerpc/ffitarget.h: Ditto.
+ * src/s390/ffitarget.h: Ditto.
+ * src/sparc/ffitarget.h: Ditto.
+
+2010-07-07 Neil Roberts <neil@linux.intel.com>
+
+ * src/x86/sysv.S (ffi_call_SYSV): Align the stack pointer to
+ 16-bytes.
+
+2010-07-02 Jakub Jelinek <jakub@redhat.com>
+
+ * Makefile.am (AM_MAKEFLAGS): Pass also mandir to submakes.
+ * Makefile.in: Regenerated.
+
+2010-05-19 Rainer Orth <ro@CeBiTec.Uni-Bielefeld.DE>
+
+ * configure.ac (libffi_cv_as_x86_pcrel): Check for illegal in as
+ output, too.
+ (libffi_cv_as_ascii_pseudo_op): Check for .ascii.
+ (libffi_cv_as_string_pseudo_op): Check for .string.
+ * configure: Regenerate.
+ * fficonfig.h.in: Regenerate.
+ * src/x86/sysv.S (.eh_frame): Use .ascii, .string or error.
+
+2010-05-11 Dan Witte <dwitte@mozilla.com>
+
+ * doc/libffi.tex: Document previous change.
+
+2010-05-11 Makoto Kato <m_kato@ga2.so-net.ne.jp>
+
+ * src/x86/ffi.c (ffi_call): Don't copy structs passed by value.
+
+2010-05-05 Michael Kohler <michaelkohler@live.com>
+
+ * src/dlmalloc.c (dlfree): Fix spelling.
+ * src/ia64/ffi.c (ffi_prep_cif_machdep): Ditto.
+ * configure.ac: Ditto.
+ * configure: Rebuilt.
+
+2010-04-13 Dan Witte <dwitte@mozilla.com>
+
+ * msvcc.sh: Build with -W3 instead of -Wall.
+ * src/powerpc/ffi_darwin.c: Remove build warnings.
+ * src/x86/ffi.c: Ditto.
+ * src/x86/ffitarget.h: Ditto.
+
+2010-04-12 Dan Witte <dwitte@mozilla.com>
+ Walter Meinl <wuno@lsvw.de>
+
+ * configure.ac: Add OS/2 support.
+ * configure: Rebuilt.
+ * src/closures.c: Ditto.
+ * src/dlmalloc.c: Ditto.
+ * src/x86/win32.S: Ditto.
+
+2010-04-07 Jakub Jelinek <jakub@redhat.com>
+
+ * testsuite/libffi.call/err_bad_abi.c: Remove unused args variable.
+
+2010-04-02 Ralf Wildenhues <Ralf.Wildenhues@gmx.de>
+
+ * Makefile.in: Regenerate.
+ * aclocal.m4: Regenerate.
+ * include/Makefile.in: Regenerate.
+ * man/Makefile.in: Regenerate.
+ * testsuite/Makefile.in: Regenerate.
+
+2010-03-30 Dan Witte <dwitte@mozilla.com>
+
+ * msvcc.sh: Disable build warnings.
+ * README (tested): Clarify windows build procedure.
+
+2010-03-15 Rainer Orth <ro@CeBiTec.Uni-Bielefeld.DE>
+
+ * configure.ac (libffi_cv_as_x86_64_unwind_section_type): New test.
+ * configure: Regenerate.
+ * fficonfig.h.in: Regenerate.
+ * libffi/src/x86/unix64.S (.eh_frame)
+ [HAVE_AS_X86_64_UNWIND_SECTION_TYPE]: Use @unwind section type.
+
+2010-03-14 Matthias Klose <doko@ubuntu.com>
+
+ * src/x86/ffi64.c: Fix typo in comment.
+ * src/x86/ffi.c: Use /* ... */ comment style.
+
+2010-02-24 Rainer Orth <ro@CeBiTec.Uni-Bielefeld.DE>
+
+ * doc/libffi.texi (The Closure API): Fix typo.
+ * doc/libffi.info: Remove.
+
+2010-02-15 Matthias Klose <doko@ubuntu.com>
+
+ * src/arm/sysv.S (__ARM_ARCH__): Define for processor
+ __ARM_ARCH_7EM__.
+
+2010-01-15 Anthony Green <green@redhat.com>
+
+ * README: Add notes on building with Microsoft Visual C++.
+
+2010-01-15 Daniel Witte <dwitte@mozilla.com>
+
+ * msvcc.sh: New file.
+
+ * src/x86/win32.S: Port assembly routines to MSVC and #ifdef.
+ * src/x86/ffi.c: Tweak function declaration and remove excess
+ parens.
+ * include/ffi.h.in: Add __declspec(align(8)) to typedef struct
+ ffi_closure.
+
+ * src/x86/ffi.c: Merge ffi_call_SYSV and ffi_call_STDCALL into new
+ function ffi_call_win32 on X86_WIN32.
+ * src/x86/win32.S (ffi_call_SYSV): Rename to ffi_call_win32.
+ (ffi_call_STDCALL): Remove.
+
+ * src/prep_cif.c (ffi_prep_cif): Move stack space allocation code
+ to ffi_prep_cif_machdep for x86.
+ * src/x86/ffi.c (ffi_prep_cif_machdep): To here.
+
+2010-01-15 Oliver Kiddle <okiddle@yahoo.co.uk>
+
+ * src/x86/ffitarget.h (ffi_abi): Check for __i386 and __amd64 for
+ Sun Studio compiler compatibility.
+
+2010-01-12 Conrad Irwin <conrad.irwin@gmail.com>
+
+ * doc/libffi.texi: Add closure example.
+
+2010-01-07 Rainer Orth <ro@CeBiTec.Uni-Bielefeld.DE>
+
+ PR libffi/40701
+ * testsuite/libffi.call/ffitest.h [__alpha__ && __osf__] (PRIdLL,
+ PRIuLL, PRId64, PRIu64, PRIuPTR): Define.
+ * testsuite/libffi.call/cls_align_sint64.c: Add -Wno-format on
+ alpha*-dec-osf*.
+ * testsuite/libffi.call/cls_align_uint64.c: Likewise.
+ * testsuite/libffi.call/cls_ulonglong.c: Likewise.
+ * testsuite/libffi.call/return_ll1.c: Likewise.
+ * testsuite/libffi.call/stret_medium2.c: Likewise.
+ * testsuite/libffi.special/ffitestcxx.h (allocate_mmap): Cast
+ MAP_FAILED to char *.
+
+2010-01-06 Rainer Orth <ro@CeBiTec.Uni-Bielefeld.DE>
+
+ * src/mips/n32.S: Use .abicalls and .eh_frame with __GNUC__.
+
+2009-12-31 Anthony Green <green@redhat.com>
+
+ * README: Update for libffi 3.0.9.
+
+2009-12-27 Matthias Klose <doko@ubuntu.com>
+
+ * configure.ac (HAVE_LONG_DOUBLE): Define for mips when
+ appropriate.
+ * configure: Rebuilt.
+
+2009-12-26 Anthony Green <green@redhat.com>
+
+ * testsuite/libffi.call/cls_longdouble_va.c: Mark as xfail for
+ avr32*-*-*.
+ * testsuite/libffi.call/cls_double_va.c: Ditto.
+
+2009-12-26 Andreas Tobler <a.tobler@schweiz.org>
+
+ * testsuite/libffi.call/ffitest.h: Conditionally include stdint.h
+ and inttypes.h.
+ * testsuite/libffi.special/unwindtest.cc: Ditto.
+
+2009-12-26 Andreas Tobler <a.tobler@schweiz.org>
+
+ * configure.ac: Add amd64-*-openbsd*.
+ * configure: Rebuilt.
+ * testsuite/lib/libffi-dg.exp (libffi_target_compile): Link
+ openbsd programs with -lpthread.
+
+2009-12-26 Anthony Green <green@redhat.com>
+
+ * testsuite/libffi.call/cls_double_va.c,
+ testsuite/libffi.call/cls_longdouble.c,
+ testsuite/libffi.call/cls_longdouble_va.c,
+ testsuite/libffi.call/cls_pointer.c,
+ testsuite/libffi.call/cls_pointer_stack.c: Remove xfail for
+ mips*-*-* and arm*-*-*.
+ * testsuite/libffi.call/cls_align_longdouble_split.c,
+ testsuite/libffi.call/cls_align_longdouble_split2.c,
+ testsuite/libffi.call/stret_medium2.c,
+ testsuite/libffi.call/stret_medium.c,
+ testsuite/libffi.call/stret_large.c,
+ testsuite/libffi.call/stret_large2.c: Remove xfail for arm*-*-*.
+
+2009-12-31 Kay Tietz <ktietz70@googlemail.com>
+
+ * testsuite/libffi.call/ffitest.h,
+ testsuite/libffi.special/ffitestcxx.h (PRIdLL, PRuLL): Fix
+ definitions.
+
+2009-12-31 Carlo Bramini <carlo.bramix@libero.it>
+
+ * configure.ac (AM_LTLDFLAGS): Define for windows hosts.
+ * Makefile.am (libffi_la_LDFLAGS): Add AM_LTLDFLAGS.
+ * configure: Rebuilt.
+ * Makefile.in: Rebuilt.
+
+2009-12-31 Anthony Green <green@redhat.com>
+ Blake Chaffin.
+
+ * testsuite/libffi.call/huge_struct.c: New test case from Blake
+ Chaffin @ Apple.
+
+2009-12-28 David Edelsohn <edelsohn@gnu.org>
+
+ * src/powerpc/ffi_darwin.c (ffi_prep_args): Copy abi and nargs to
+ local variables.
+ (aix_adjust_aggregate_sizes): New function.
+ (ffi_prep_cif_machdep): Call it.
+
+2009-12-26 Andreas Tobler <a.tobler@schweiz.org>
+
+ * configure.ac: Define FFI_MMAP_EXEC_WRIT for the given targets.
+ * configure: Regenerate.
+ * fficonfig.h.in: Likewise.
+ * src/closures.c: Remove the FFI_MMAP_EXEC_WRIT definition for
+ Solaris/x86.
+
+2009-12-26 Andreas Schwab <schwab@linux-m68k.org>
+
+ * src/powerpc/ffi.c (ffi_prep_args_SYSV): Advance intarg_count
+ when a float arguments is passed in memory.
+ (ffi_closure_helper_SYSV): Mark general registers as used up when
+ a 64bit or soft-float long double argument is passed in memory.
+
+2009-12-25 Matthias Klose <doko@ubuntu.com>
+
+ * man/ffi_call.3: Fix #include in examples.
+ * doc/libffi.texi: Add dircategory.
+
+2009-12-25 Frank Everdij <f.p.x.everdij@tudelft.nl>
+
+ * include/ffi.h.in: Placed '__GNUC__' ifdef around
+ '__attribute__((aligned(8)))' in ffi_closure, fixes compile for
+ IRIX MIPSPro c99.
+ * include/ffi_common.h: Added '__sgi' define to non
+ '__attribute__((__mode__()))' integer typedefs.
+ * src/mips/ffi.c (ffi_call, ffi_closure_mips_inner_O32,
+ ffi_closure_mips_inner_N32): Added 'defined(_MIPSEB)' to BE check.
+ (ffi_closure_mips_inner_O32, ffi_closure_mips_inner_N32): Added
+ FFI_LONGDOUBLE support and alignment(N32 only).
+ * src/mips/ffitarget.h: Corrected '#include <sgidefs.h>' for IRIX and
+ fixed non '__attribute__((__mode__()))' integer typedefs.
+ * src/mips/n32.S: Put '#ifdef linux' around '.abicalls' and '.eh_frame'
+ since they are Linux/GNU Assembler specific.
+
+2009-12-25 Bradley Smith <brad@brad-smith.co.uk>
+
+ * configure.ac, Makefile.am, src/avr32/ffi.c,
+ src/avr32/ffitarget.h,
+ src/avr32/sysv.S: Add AVR32 port.
+ * configure, Makefile.in: Rebuilt.
+
+2009-12-21 Andreas Tobler <a.tobler@schweiz.org>
+
+ * configure.ac: Make i?86 build on FreeBSD and OpenBSD.
+ * configure: Regenerate.
+
+2009-12-15 John David Anglin <dave.anglin@nrc-cnrc.gc.ca>
+
+ * testsuite/libffi.call/ffitest.h: Define PRIuPTR on PA HP-UX.
+
+2009-12-13 John David Anglin <dave.anglin@nrc-cnrc.gc.ca>
+
+ * src/pa/ffi.c (ffi_closure_inner_pa32): Handle FFI_TYPE_LONGDOUBLE
+ type on HP-UX.
+
+2012-02-13 Kai Tietz <ktietz@redhat.com>
+
+ PR libffi/52221
+ * src/x86/ffi.c (ffi_prep_raw_closure_loc): Add thiscall
+ support for X86_WIN32.
+ (FFI_INIT_TRAMPOLINE_THISCALL): Fix displacement.
+
+2009-12-11 Eric Botcazou <ebotcazou@adacore.com>
+
+ * src/sparc/ffi.c (ffi_closure_sparc_inner_v9): Properly align 'long
+ double' arguments.
+
+2009-12-11 Eric Botcazou <ebotcazou@adacore.com>
+
+ * testsuite/libffi.call/ffitest.h: Define PRIuPTR on Solaris < 10.
+
+2009-12-10 Rainer Orth <ro@CeBiTec.Uni-Bielefeld.DE>
+
+ PR libffi/40700
+ * src/closures.c [X86_64 && __sun__ && __svr4__]
+ (FFI_MMAP_EXEC_WRIT): Define.
+
+2009-12-08 David Daney <ddaney@caviumnetworks.com>
+
+ * testsuite/libffi.call/stret_medium.c: Remove xfail for mips*-*-*
+ * testsuite/libffi.call/cls_align_longdouble_split2.c: Same.
+ * testsuite/libffi.call/stret_large.c: Same.
+ * testsuite/libffi.call/cls_align_longdouble_split.c: Same.
+ * testsuite/libffi.call/stret_large2.c: Same.
+ * testsuite/libffi.call/stret_medium2.c: Same.
+
+2009-12-07 David Edelsohn <edelsohn@gnu.org>
+
+ * src/powerpc/aix_closure.S (libffi_closure_ASM): Fix tablejump
+ typo.
+
+2009-12-05 David Edelsohn <edelsohn@gnu.org>
+
+ * src/powerpc/aix.S: Update AIX32 code to be consistent with AIX64
+ code.
+ * src/powerpc/aix_closure.S: Same.
+
+2009-12-05 Ralf Wildenhues <Ralf.Wildenhues@gmx.de>
+
+ * Makefile.in: Regenerate.
+ * configure: Regenerate.
+ * include/Makefile.in: Regenerate.
+ * man/Makefile.in: Regenerate.
+ * testsuite/Makefile.in: Regenerate.
+
+2009-12-04 David Edelsohn <edelsohn@gnu.org>
+
+ * src/powerpc/aix_closure.S: Reorganize 64-bit code to match
+ linux64_closure.S.
+
+2009-12-04 Uros Bizjak <ubizjak@gmail.com>
+
+ PR libffi/41908
+ * src/x86/ffi64.c (classify_argument): Update from
+ gcc/config/i386/i386.c.
+ (ffi_closure_unix64_inner): Do not use the address of two consecutive
+ SSE registers directly.
+ * testsuite/libffi.call/cls_dbls_struct.c (main): Remove xfail
+ for x86_64 linux targets.
+
+2009-12-04 David Edelsohn <edelsohn@gnu.org>
+
+ * src/powerpc/ffi_darwin.c (ffi_closure_helper_DARWIN): Increment
+ pfr for long double split between fpr13 and stack.
+
+2009-12-03 David Edelsohn <edelsohn@gnu.org>
+
+ * src/powerpc/ffi_darwin.c (ffi_prep_args): Increment next_arg and
+ fparg_count twice for long double.
+
+2009-12-03 David Edelsohn <edelsohn@gnu.org>
+
+ PR libffi/42243
+ * src/powerpc/ffi_darwin.c (ffi_prep_args): Remove extra parentheses.
+
+2009-12-03 Uros Bizjak <ubizjak@gmail.com>
+
+ * testsuite/libffi.call/cls_longdouble_va.c (main): Fix format string.
+ Remove xfails for x86 linux targets.
+
+2009-12-02 David Edelsohn <edelsohn@gnu.org>
+
+ * src/powerpc/ffi_darwin.c (ffi_prep_args): Fix typo in INT64
+ case.
+
+2009-12-01 David Edelsohn <edelsohn@gnu.org>
+
+ * src/powerpc/aix.S (ffi_call_AIX): Convert to more standard
+ register usage. Call ffi_prep_args directly. Add long double
+ return value support.
+ * src/powerpc/ffi_darwin.c (ffi_prep_args): Double arg increment
+ applies to FFI_TYPE_DOUBLE. Correct fpr_base increment typo.
+ Separate FFI_TYPE_SINT32 and FFI_TYPE_UINT32 cases.
+ (ffi_prep_cif_machdep): Only 16 byte stack alignment in 64 bit
+ mode.
+ (ffi_closure_helper_DARWIN): Remove nf and ng counters. Move temp
+ into case.
+ * src/powerpc/aix_closure.S: Maintain 16 byte stack alignment.
+ Allocate result area between params and FPRs.
+
+2009-11-30 David Edelsohn <edelsohn@gnu.org>
+
+ PR target/35484
+ * src/powerpc/ffitarget.h (POWERPC64): Define for PPC64 Linux and
+ AIX64.
+ * src/powerpc/aix.S: Implement AIX64 version.
+ * src/powerpc/aix_closure.S: Implement AIX64 version.
+ (ffi_closure_ASM): Use extsb, lha and displament addresses.
+ * src/powerpc/ffi_darwin.c (ffi_prep_args): Implement AIX64
+ support.
+ (ffi_prep_cif_machdep): Same.
+ (ffi_call): Same.
+ (ffi_closure_helper_DARWIN): Same.
+
+2009-11-02 Andreas Tobler <a.tobler@schweiz.org>
+
+ PR libffi/41908
+ * testsuite/libffi.call/testclosure.c: New test.
+
+2009-09-28 Kai Tietz <kai.tietz@onevision.com>
+
+ * src/x86/win64.S (_ffi_call_win64 stack): Remove for gnu
+ assembly version use of ___chkstk.
+
+2009-09-23 Matthias Klose <doko@ubuntu.com>
+
+ PR libffi/40242, PR libffi/41443
+ * src/arm/sysv.S (__ARM_ARCH__): Define for processors
+ __ARM_ARCH_6T2__, __ARM_ARCH_6M__, __ARM_ARCH_7__,
+ __ARM_ARCH_7A__, __ARM_ARCH_7R__, __ARM_ARCH_7M__.
+ Change the conditionals to __SOFTFP__ || __ARM_EABI__
+ for -mfloat-abi=softfp to work.
+
+2009-09-17 Loren J. Rittle <ljrittle@acm.org>
+
+ PR testsuite/32843 (strikes again)
+ * src/x86/ffi.c (ffi_prep_cif_machdep): Add X86_FREEBSD to
+ enable proper extension on char and short.
+
+2009-09-15 David Daney <ddaney@caviumnetworks.com>
+
+ * src/java_raw_api.c (ffi_java_raw_to_rvalue): Remove special
+ handling for FFI_TYPE_POINTER.
+ * src/mips/ffitarget.h (FFI_TYPE_STRUCT_D_SOFT,
+ FFI_TYPE_STRUCT_F_SOFT, FFI_TYPE_STRUCT_DD_SOFT,
+ FFI_TYPE_STRUCT_FF_SOFT, FFI_TYPE_STRUCT_FD_SOFT,
+ FFI_TYPE_STRUCT_DF_SOFT, FFI_TYPE_STRUCT_SOFT): New defines.
+ (FFI_N32_SOFT_FLOAT, FFI_N64_SOFT_FLOAT): New ffi_abi enumerations.
+ (enum ffi_abi): Set FFI_DEFAULT_ABI for soft-float.
+ * src/mips/n32.S (ffi_call_N32): Add handling for soft-float
+ structure and pointer returns.
+ (ffi_closure_N32): Add handling for pointer returns.
+ * src/mips/ffi.c (ffi_prep_args, calc_n32_struct_flags,
+ calc_n32_return_struct_flags): Handle soft-float.
+ (ffi_prep_cif_machdep): Handle soft-float, fix pointer handling.
+ (ffi_call_N32): Declare proper argument types.
+ (ffi_call, copy_struct_N32, ffi_closure_mips_inner_N32): Handle
+ soft-float.
+
+2009-08-24 Ralf Wildenhues <Ralf.Wildenhues@gmx.de>
+
+ * configure.ac (AC_PREREQ): Bump to 2.64.
+
+2009-08-22 Ralf Wildenhues <Ralf.Wildenhues@gmx.de>
+
+ * Makefile.am (install-html, install-pdf): Remove.
+ * Makefile.in: Regenerate.
+
+ * Makefile.in: Regenerate.
+ * aclocal.m4: Regenerate.
+ * configure: Regenerate.
+ * fficonfig.h.in: Regenerate.
+ * include/Makefile.in: Regenerate.
+ * man/Makefile.in: Regenerate.
+ * testsuite/Makefile.in: Regenerate.
+
+2011-08-22 Jasper Lievisse Adriaanse <jasper@openbsd.org>
+
+ * configure.ac: Add OpenBSD/hppa and OpenBSD/powerpc support.
+ * configure: Rebuilt.
+
+2009-07-30 Ralf Wildenhues <Ralf.Wildenhues@gmx.de>
+
+ * configure.ac (_AC_ARG_VAR_PRECIOUS): Use m4_rename_force.
+
+2009-07-24 Dave Korn <dave.korn.cygwin@gmail.com>
+
+ PR libffi/40807
+ * src/x86/ffi.c (ffi_prep_cif_machdep): Also use sign/zero-extending
+ return types for X86_WIN32.
+ * src/x86/win32.S (_ffi_call_SYSV): Handle omitted return types.
+ (_ffi_call_STDCALL, _ffi_closure_SYSV, _ffi_closure_raw_SYSV,
+ _ffi_closure_STDCALL): Likewise.
+
+ * src/closures.c (is_selinux_enabled): Define to const 0 for Cygwin.
+ (dlmmap, dlmunmap): Also use these functions on Cygwin.
+
+2009-07-11 Richard Sandiford <rdsandiford@googlemail.com>
+
+ PR testsuite/40699
+ PR testsuite/40707
+ PR testsuite/40709
+ * testsuite/lib/libffi-dg.exp: Revert 2009-07-02, 2009-07-01 and
+ 2009-06-30 commits.
+
+2009-07-01 Richard Sandiford <r.sandiford@uk.ibm.com>
+
+ * testsuite/lib/libffi-dg.exp (libffi-init): Set ld_library_path
+ to "" before adding paths. (This reinstates an assignment that
+ was removed by my 2009-06-30 commit, but changes the initial
+ value from "." to "".)
+
+2009-07-01 H.J. Lu <hongjiu.lu@intel.com>
+
+ PR testsuite/40601
+ * testsuite/lib/libffi-dg.exp (libffi-init): Properly set
+ gccdir. Adjust ld_library_path for gcc only if gccdir isn't
+ empty.
+
+2009-06-30 Richard Sandiford <r.sandiford@uk.ibm.com>
+
+ * testsuite/lib/libffi-dg.exp (libffi-init): Don't add "."
+ to ld_library_path. Use add_path. Add just find_libgcc_s
+ to ld_library_path, not every libgcc multilib directory.
+
+2009-06-16 Wim Lewis <wiml@hhhh.org>
+
+ * src/powerpc/ffi.c: Avoid clobbering cr3 and cr4, which are
+ supposed to be callee-saved.
+ * src/powerpc/sysv.S (small_struct_return_value): Fix overrun of
+ return buffer for odd-size structs.
+
+2009-06-16 Andreas Tobler <a.tobler@schweiz.org>
+
+ PR libffi/40444
+ * testsuite/lib/libffi-dg.exp (libffi_target_compile): Add
+ allow_stack_execute for Darwin.
+
+2009-06-16 Andrew Haley <aph@redhat.com>
+
+ * configure.ac (TARGETDIR): Add missing blank lines.
+ * configure: Regenerate.
+
+2009-06-16 Andrew Haley <aph@redhat.com>
+
+ * testsuite/libffi.call/cls_align_sint64.c,
+ testsuite/libffi.call/cls_align_uint64.c,
+ testsuite/libffi.call/cls_longdouble_va.c,
+ testsuite/libffi.call/cls_ulonglong.c,
+ testsuite/libffi.call/return_ll1.c,
+ testsuite/libffi.call/stret_medium2.c: Fix printf format
+ specifiers.
+ * testsuite/libffi.call/ffitest.h,
+ testsuite/libffi.special/ffitestcxx.h (PRIdLL, PRIuLL): Define.
+
+2009-06-15 Andrew Haley <aph@redhat.com>
+
+ * testsuite/libffi.call/err_bad_typedef.c: xfail everywhere.
+ * testsuite/libffi.call/err_bad_abi.c: Likewise.
+
+2009-06-12 Andrew Haley <aph@redhat.com>
+
+ * Makefile.am: Remove info_TEXINFOS.
+
+2009-06-12 Andrew Haley <aph@redhat.com>
+
+ * ChangeLog.libffi: testsuite/libffi.call/cls_align_sint64.c,
+ testsuite/libffi.call/cls_align_uint64.c,
+ testsuite/libffi.call/cls_ulonglong.c,
+ testsuite/libffi.call/return_ll1.c,
+ testsuite/libffi.call/stret_medium2.c: Fix printf format
+ specifiers.
+ testsuite/libffi.special/unwindtest.cc: include stdint.h.
+
+2009-06-11 Timothy Wall <twall@users.sf.net>
+
+ * Makefile.am,
+ configure.ac,
+ include/ffi.h.in,
+ include/ffi_common.h,
+ src/closures.c,
+ src/dlmalloc.c,
+ src/x86/ffi.c,
+ src/x86/ffitarget.h,
+ src/x86/win64.S (new),
+ README: Added win64 support (mingw or MSVC)
+ * Makefile.in,
+ include/Makefile.in,
+ man/Makefile.in,
+ testsuite/Makefile.in,
+ configure,
+ aclocal.m4: Regenerated
+ * ltcf-c.sh: properly escape cygwin/w32 path
+ * man/ffi_call.3: Clarify size requirements for return value.
+ * src/x86/ffi64.c: Fix filename in comment.
+ * src/x86/win32.S: Remove unused extern.
+
+ * testsuite/libffi.call/closure_fn0.c,
+ testsuite/libffi.call/closure_fn1.c,
+ testsuite/libffi.call/closure_fn2.c,
+ testsuite/libffi.call/closure_fn3.c,
+ testsuite/libffi.call/closure_fn4.c,
+ testsuite/libffi.call/closure_fn5.c,
+ testsuite/libffi.call/closure_fn6.c,
+ testsuite/libffi.call/closure_stdcall.c,
+ testsuite/libffi.call/cls_12byte.c,
+ testsuite/libffi.call/cls_16byte.c,
+ testsuite/libffi.call/cls_18byte.c,
+ testsuite/libffi.call/cls_19byte.c,
+ testsuite/libffi.call/cls_1_1byte.c,
+ testsuite/libffi.call/cls_20byte.c,
+ testsuite/libffi.call/cls_20byte1.c,
+ testsuite/libffi.call/cls_24byte.c,
+ testsuite/libffi.call/cls_2byte.c,
+ testsuite/libffi.call/cls_3_1byte.c,
+ testsuite/libffi.call/cls_3byte1.c,
+ testsuite/libffi.call/cls_3byte2.c,
+ testsuite/libffi.call/cls_4_1byte.c,
+ testsuite/libffi.call/cls_4byte.c,
+ testsuite/libffi.call/cls_5_1_byte.c,
+ testsuite/libffi.call/cls_5byte.c,
+ testsuite/libffi.call/cls_64byte.c,
+ testsuite/libffi.call/cls_6_1_byte.c,
+ testsuite/libffi.call/cls_6byte.c,
+ testsuite/libffi.call/cls_7_1_byte.c,
+ testsuite/libffi.call/cls_7byte.c,
+ testsuite/libffi.call/cls_8byte.c,
+ testsuite/libffi.call/cls_9byte1.c,
+ testsuite/libffi.call/cls_9byte2.c,
+ testsuite/libffi.call/cls_align_double.c,
+ testsuite/libffi.call/cls_align_float.c,
+ testsuite/libffi.call/cls_align_longdouble.c,
+ testsuite/libffi.call/cls_align_longdouble_split.c,
+ testsuite/libffi.call/cls_align_longdouble_split2.c,
+ testsuite/libffi.call/cls_align_pointer.c,
+ testsuite/libffi.call/cls_align_sint16.c,
+ testsuite/libffi.call/cls_align_sint32.c,
+ testsuite/libffi.call/cls_align_sint64.c,
+ testsuite/libffi.call/cls_align_uint16.c,
+ testsuite/libffi.call/cls_align_uint32.c,
+ testsuite/libffi.call/cls_align_uint64.c,
+ testsuite/libffi.call/cls_dbls_struct.c,
+ testsuite/libffi.call/cls_double.c,
+ testsuite/libffi.call/cls_double_va.c,
+ testsuite/libffi.call/cls_float.c,
+ testsuite/libffi.call/cls_longdouble.c,
+ testsuite/libffi.call/cls_longdouble_va.c,
+ testsuite/libffi.call/cls_multi_schar.c,
+ testsuite/libffi.call/cls_multi_sshort.c,
+ testsuite/libffi.call/cls_multi_sshortchar.c,
+ testsuite/libffi.call/cls_multi_uchar.c,
+ testsuite/libffi.call/cls_multi_ushort.c,
+ testsuite/libffi.call/cls_multi_ushortchar.c,
+ testsuite/libffi.call/cls_pointer.c,
+ testsuite/libffi.call/cls_pointer_stack.c,
+ testsuite/libffi.call/cls_schar.c,
+ testsuite/libffi.call/cls_sint.c,
+ testsuite/libffi.call/cls_sshort.c,
+ testsuite/libffi.call/cls_uchar.c,
+ testsuite/libffi.call/cls_uint.c,
+ testsuite/libffi.call/cls_ulonglong.c,
+ testsuite/libffi.call/cls_ushort.c,
+ testsuite/libffi.call/err_bad_abi.c,
+ testsuite/libffi.call/err_bad_typedef.c,
+ testsuite/libffi.call/float2.c,
+ testsuite/libffi.call/huge_struct.c,
+ testsuite/libffi.call/nested_struct.c,
+ testsuite/libffi.call/nested_struct1.c,
+ testsuite/libffi.call/nested_struct10.c,
+ testsuite/libffi.call/nested_struct2.c,
+ testsuite/libffi.call/nested_struct3.c,
+ testsuite/libffi.call/nested_struct4.c,
+ testsuite/libffi.call/nested_struct5.c,
+ testsuite/libffi.call/nested_struct6.c,
+ testsuite/libffi.call/nested_struct7.c,
+ testsuite/libffi.call/nested_struct8.c,
+ testsuite/libffi.call/nested_struct9.c,
+ testsuite/libffi.call/problem1.c,
+ testsuite/libffi.call/return_ldl.c,
+ testsuite/libffi.call/return_ll1.c,
+ testsuite/libffi.call/stret_large.c,
+ testsuite/libffi.call/stret_large2.c,
+ testsuite/libffi.call/stret_medium.c,
+ testsuite/libffi.call/stret_medium2.c,
+ testsuite/libffi.special/unwindtest.cc: use ffi_closure_alloc instead
+ of checking for MMAP. Use intptr_t instead of long casts.
+
+2009-06-11 Kaz Kojima <kkojima@gcc.gnu.org>
+
+ * testsuite/libffi.call/cls_longdouble_va.c: Add xfail sh*-*-linux-*.
+ * testsuite/libffi.call/err_bad_abi.c: Add xfail sh*-*-*.
+ * testsuite/libffi.call/err_bad_typedef.c: Likewise.
+
+2009-06-09 Andrew Haley <aph@redhat.com>
+
+ * src/x86/freebsd.S: Add missing file.
+
+2009-06-08 Andrew Haley <aph@redhat.com>
+
+ Import from libffi 3.0.8:
+
+ * doc/libffi.texi: New file.
+ * doc/libffi.info: Likewise.
+ * doc/stamp-vti: Likewise.
+ * man/Makefile.am: New file.
+ * man/ffi_call.3: New file.
+
+ * Makefile.am (EXTRA_DIST): Add src/x86/darwin64.S,
+ src/dlmalloc.c.
+ (nodist_libffi_la_SOURCES): Add X86_FREEBSD.
+
+ * configure.ac: Bump version to 3.0.8.
+ parisc*-*-linux*: Add.
+ i386-*-freebsd* | i386-*-openbsd*: Add.
+ powerpc-*-beos*: Add.
+ AM_CONDITIONAL X86_FREEBSD: Add.
+ AC_CONFIG_FILES: Add man/Makefile.
+
+ * include/ffi.h.in (FFI_FN): Change void (*)() to void (*)(void).
+
+2009-06-08 Andrew Haley <aph@redhat.com>
+
+ * README: Import from libffi 3.0.8.
+
+2009-06-08 Andrew Haley <aph@redhat.com>
+
+ * testsuite/libffi.call/err_bad_abi.c: Add xfails.
+ * testsuite/libffi.call/cls_longdouble_va.c: Add xfails.
+ * testsuite/libffi.call/cls_dbls_struct.c: Add xfail x86_64-*-linux-*.
+ * testsuite/libffi.call/err_bad_typedef.c: Add xfails.
+
+ * testsuite/libffi.call/stret_medium2.c: Add __UNUSED__ to args.
+ * testsuite/libffi.call/stret_medium.c: Likewise.
+ * testsuite/libffi.call/stret_large2.c: Likewise.
+ * testsuite/libffi.call/stret_large.c: Likewise.
+
+2008-12-26 Timothy Wall <twall@users.sf.net>
+
+ * testsuite/libffi.call/cls_longdouble.c,
+ testsuite/libffi.call/cls_longdouble_va.c,
+ testsuite/libffi.call/cls_align_longdouble.c,
+ testsuite/libffi.call/cls_align_longdouble_split.c,
+ testsuite/libffi.call/cls_align_longdouble_split2.c: mark expected
+ failures on x86_64 cygwin/mingw.
+
+2008-12-22 Timothy Wall <twall@users.sf.net>
+
+ * testsuite/libffi.call/closure_fn0.c,
+ testsuite/libffi.call/closure_fn1.c,
+ testsuite/libffi.call/closure_fn2.c,
+ testsuite/libffi.call/closure_fn3.c,
+ testsuite/libffi.call/closure_fn4.c,
+ testsuite/libffi.call/closure_fn5.c,
+ testsuite/libffi.call/closure_fn6.c,
+ testsuite/libffi.call/closure_loc_fn0.c,
+ testsuite/libffi.call/closure_stdcall.c,
+ testsuite/libffi.call/cls_align_pointer.c,
+ testsuite/libffi.call/cls_pointer.c,
+ testsuite/libffi.call/cls_pointer_stack.c: use portable cast from
+ pointer to integer (intptr_t).
+ * testsuite/libffi.call/cls_longdouble.c: disable for win64.
+
+2008-07-24 Anthony Green <green@redhat.com>
+
+ * testsuite/libffi.call/cls_dbls_struct.c,
+ testsuite/libffi.call/cls_double_va.c,
+ testsuite/libffi.call/cls_longdouble.c,
+ testsuite/libffi.call/cls_longdouble_va.c,
+ testsuite/libffi.call/cls_pointer.c,
+ testsuite/libffi.call/cls_pointer_stack.c,
+ testsuite/libffi.call/err_bad_abi.c: Clean up failures from
+ compiler warnings.
+
+2008-03-04 Anthony Green <green@redhat.com>
+ Blake Chaffin
+ hos@tamanegi.org
+
+ * testsuite/libffi.call/cls_align_longdouble_split2.c
+ testsuite/libffi.call/cls_align_longdouble_split.c
+ testsuite/libffi.call/cls_dbls_struct.c
+ testsuite/libffi.call/cls_double_va.c
+ testsuite/libffi.call/cls_longdouble.c
+ testsuite/libffi.call/cls_longdouble_va.c
+ testsuite/libffi.call/cls_pointer.c
+ testsuite/libffi.call/cls_pointer_stack.c
+ testsuite/libffi.call/err_bad_abi.c
+ testsuite/libffi.call/err_bad_typedef.c
+ testsuite/libffi.call/stret_large2.c
+ testsuite/libffi.call/stret_large.c
+ testsuite/libffi.call/stret_medium2.c
+ testsuite/libffi.call/stret_medium.c: New tests from Apple.
+
+2009-06-05 Andrew Haley <aph@redhat.com>
+
+ * src/x86/ffitarget.h, src/x86/ffi.c: Merge stdcall changes from
+ libffi.
+
+2009-06-04 Andrew Haley <aph@redhat.com>
+
+ * src/x86/ffitarget.h, src/x86/win32.S, src/x86/ffi.c: Back out
+ stdcall changes.
+
+2008-02-26 Anthony Green <green@redhat.com>
+ Thomas Heller <theller@ctypes.org>
+
+ * src/x86/ffi.c (ffi_closure_SYSV_inner): Change C++ comment to C
+ comment.
+
+2008-02-03 Timothy Wall <twall@users.sf.net>
+
+ * src/x86/ffi.c (FFI_INIT_TRAMPOLINE_STDCALL): Calculate jump return
+ offset based on code pointer, not data pointer.
+
+2008-01-31 Timothy Wall <twall@users.sf.net>
+
+ * testsuite/libffi.call/closure_stdcall.c: Add test for stdcall
+ closures.
+ * src/x86/ffitarget.h: Increase size of trampoline for stdcall
+ closures.
+ * src/x86/win32.S: Add assembly for stdcall closure.
+ * src/x86/ffi.c: Initialize stdcall closure trampoline.
+
+2009-06-04 Andrew Haley <aph@redhat.com>
+
+ * include/ffi.h.in: Change void (*)() to void (*)(void).
+ * src/x86/ffi.c: Likewise.
+
+2009-06-04 Andrew Haley <aph@redhat.com>
+
+ * src/powerpc/ppc_closure.S: Insert licence header.
+ * src/powerpc/linux64_closure.S: Likewise.
+ * src/m68k/sysv.S: Likewise.
+
+ * src/sh64/ffi.c: Change void (*)() to void (*)(void).
+ * src/powerpc/ffi.c: Likewise.
+ * src/powerpc/ffi_darwin.c: Likewise.
+ * src/m32r/ffi.c: Likewise.
+ * src/sh64/ffi.c: Likewise.
+ * src/x86/ffi64.c: Likewise.
+ * src/alpha/ffi.c: Likewise.
+ * src/alpha/osf.S: Likewise.
+ * src/frv/ffi.c: Likewise.
+ * src/s390/ffi.c: Likewise.
+ * src/pa/ffi.c: Likewise.
+ * src/pa/hpux32.S: Likewise.
+ * src/ia64/unix.S: Likewise.
+ * src/ia64/ffi.c: Likewise.
+ * src/sparc/ffi.c: Likewise.
+ * src/mips/ffi.c: Likewise.
+ * src/sh/ffi.c: Likewise.
+
+2008-02-15 David Daney <ddaney@avtrex.com>
+
+ * src/mips/ffi.c (USE__BUILTIN___CLEAR_CACHE):
+ Define (conditionally), and use it to include cachectl.h.
+ (ffi_prep_closure_loc): Fix cache flushing.
+ * src/mips/ffitarget.h (_ABIN32, _ABI64, _ABIO32): Define.
+
+2009-06-04 Andrew Haley <aph@redhat.com>
+
+ include/ffi.h.in,
+ src/arm/ffitarget.h,
+ src/arm/ffi.c,
+ src/arm/sysv.S,
+ src/powerpc/ffitarget.h,
+ src/closures.c,
+ src/sh64/ffitarget.h,
+ src/sh64/ffi.c,
+ src/sh64/sysv.S,
+ src/types.c,
+ src/x86/ffi64.c,
+ src/x86/ffitarget.h,
+ src/x86/win32.S,
+ src/x86/darwin.S,
+ src/x86/ffi.c,
+ src/x86/sysv.S,
+ src/x86/unix64.S,
+ src/alpha/ffitarget.h,
+ src/alpha/ffi.c,
+ src/alpha/osf.S,
+ src/m68k/ffitarget.h,
+ src/frv/ffitarget.h,
+ src/frv/ffi.c,
+ src/s390/ffitarget.h,
+ src/s390/sysv.S,
+ src/cris/ffitarget.h,
+ src/pa/linux.S,
+ src/pa/ffitarget.h,
+ src/pa/ffi.c,
+ src/raw_api.c,
+ src/ia64/ffitarget.h,
+ src/ia64/unix.S,
+ src/ia64/ffi.c,
+ src/ia64/ia64_flags.h,
+ src/java_raw_api.c,
+ src/debug.c,
+ src/sparc/v9.S,
+ src/sparc/ffitarget.h,
+ src/sparc/ffi.c,
+ src/sparc/v8.S,
+ src/mips/ffitarget.h,
+ src/mips/n32.S,
+ src/mips/o32.S,
+ src/mips/ffi.c,
+ src/prep_cif.c,
+ src/sh/ffitarget.h,
+ src/sh/ffi.c,
+ src/sh/sysv.S: Update license text.
+
+2009-05-22 Dave Korn <dave.korn.cygwin@gmail.com>
+
+ * src/x86/win32.S (_ffi_closure_STDCALL): New function.
+ (.eh_frame): Add FDE for it.
+
+2009-05-22 Dave Korn <dave.korn.cygwin@gmail.com>
+
+ * configure.ac: Also check if assembler supports pc-relative
+ relocs on X86_WIN32 targets.
+ * configure: Regenerate.
+ * src/x86/win32.S (ffi_prep_args): Declare extern, not global.
+ (_ffi_call_SYSV): Add missing function type symbol .def and
+ add EH markup labels.
+ (_ffi_call_STDCALL): Likewise.
+ (_ffi_closure_SYSV): Likewise.
+ (_ffi_closure_raw_SYSV): Likewise.
+ (.eh_frame): Add hand-crafted EH data.
+
+2009-04-09 Jakub Jelinek <jakub@redhat.com>
+
+ * testsuite/lib/libffi-dg.exp: Change copyright header to refer to
+ version 3 of the GNU General Public License and to point readers
+ at the COPYING3 file and the FSF's license web page.
+ * testsuite/libffi.call/call.exp: Likewise.
+ * testsuite/libffi.special/special.exp: Likewise.
+
+2009-03-01 Ralf Wildenhues <Ralf.Wildenhues@gmx.de>
+
+ * configure: Regenerate.
+
+2008-12-18 Rainer Orth <ro@TechFak.Uni-Bielefeld.DE>
+
+ PR libffi/26048
+ * configure.ac (HAVE_AS_X86_PCREL): New test.
+ * configure: Regenerate.
+ * fficonfig.h.in: Regenerate.
+ * src/x86/sysv.S [!FFI_NO_RAW_API]: Precalculate
+ RAW_CLOSURE_CIF_OFFSET, RAW_CLOSURE_FUN_OFFSET,
+ RAW_CLOSURE_USER_DATA_OFFSET for the Solaris 10/x86 assembler.
+ (.eh_frame): Only use SYMBOL-. iff HAVE_AS_X86_PCREL.
+ * src/x86/unix64.S (.Lstore_table): Move to .text section.
+ (.Lload_table): Likewise.
+ (.eh_frame): Only use SYMBOL-. iff HAVE_AS_X86_PCREL.
+
+2008-12-18 Ralf Wildenhues <Ralf.Wildenhues@gmx.de>
+
+ * configure: Regenerate.
+
+2008-11-21 Eric Botcazou <ebotcazou@adacore.com>
+
+ * src/sparc/ffi.c (ffi_prep_cif_machdep): Add support for
+ signed/unsigned int8/16 return values.
+ * src/sparc/v8.S (ffi_call_v8): Likewise.
+ (ffi_closure_v8): Likewise.
+
+2008-09-26 Peter O'Gorman <pogma@thewrittenword.com>
+ Steve Ellcey <sje@cup.hp.com>
+
+ * configure: Regenerate for new libtool.
+ * Makefile.in: Ditto.
+ * include/Makefile.in: Ditto.
+ * aclocal.m4: Ditto.
+
+2008-08-25 Andreas Tobler <a.tobler@schweiz.org>
+
+ * src/powerpc/ffitarget.h (ffi_abi): Add FFI_LINUX and
+ FFI_LINUX_SOFT_FLOAT to the POWERPC_FREEBSD enum.
+ Add note about flag bits used for FFI_SYSV_TYPE_SMALL_STRUCT.
+ Adjust copyright notice.
+ * src/powerpc/ffi.c: Add two new flags to indicate if we have one
+ register or two register to use for FFI_SYSV structs.
+ (ffi_prep_cif_machdep): Pass the right register flag introduced above.
+ (ffi_closure_helper_SYSV): Fix the return type for
+ FFI_SYSV_TYPE_SMALL_STRUCT. Comment.
+ Adjust copyright notice.
+
+2008-07-16 Kaz Kojima <kkojima@gcc.gnu.org>
+
+ * src/sh/ffi.c (ffi_prep_closure_loc): Turn INSN into an unsigned
+ int.
+
+2008-06-17 Ralf Wildenhues <Ralf.Wildenhues@gmx.de>
+
+ * configure: Regenerate.
+ * include/Makefile.in: Regenerate.
+ * testsuite/Makefile.in: Regenerate.
+
+2008-06-07 Joseph Myers <joseph@codesourcery.com>
+
+ * configure.ac (parisc*-*-linux*, powerpc-*-sysv*,
+ powerpc-*-beos*): Remove.
+ * configure: Regenerate.
+
+2008-05-09 Julian Brown <julian@codesourcery.com>
+
+ * Makefile.am (LTLDFLAGS): New.
+ (libffi_la_LDFLAGS): Use above.
+ * Makefile.in: Regenerate.
+
+2008-04-18 Paolo Bonzini <bonzini@gnu.org>
+
+ PR bootstrap/35457
+ * aclocal.m4: Regenerate.
+ * configure: Regenerate.
+
+2008-03-26 Kaz Kojima <kkojima@gcc.gnu.org>
+
+ * src/sh/sysv.S: Add .note.GNU-stack on Linux.
+ * src/sh64/sysv.S: Likewise.
+
+2008-03-26 Daniel Jacobowitz <dan@debian.org>
+
+ * src/arm/sysv.S: Fix ARM comment marker.
+
+2008-03-26 Jakub Jelinek <jakub@redhat.com>
+
+ * src/alpha/osf.S: Add .note.GNU-stack on Linux.
+ * src/s390/sysv.S: Likewise.
+ * src/powerpc/ppc_closure.S: Likewise.
+ * src/powerpc/sysv.S: Likewise.
+ * src/x86/unix64.S: Likewise.
+ * src/x86/sysv.S: Likewise.
+ * src/sparc/v8.S: Likewise.
+ * src/sparc/v9.S: Likewise.
+ * src/m68k/sysv.S: Likewise.
+ * src/arm/sysv.S: Likewise.
+
+2008-03-16 Ralf Wildenhues <Ralf.Wildenhues@gmx.de>
+
+ * aclocal.m4: Regenerate.
+ * configure: Likewise.
+ * Makefile.in: Likewise.
+ * include/Makefile.in: Likewise.
+ * testsuite/Makefile.in: Likewise.
+
+2008-02-12 Bjoern Koenig <bkoenig@alpha-tierchen.de>
+ Andreas Tobler <a.tobler@schweiz.org>
+
+ * configure.ac: Add amd64-*-freebsd* target.
+ * configure: Regenerate.
+
+2008-01-30 H.J. Lu <hongjiu.lu@intel.com>
+
+ PR libffi/34612
+ * src/x86/sysv.S (ffi_closure_SYSV): Pop 4 byte from stack when
+ returning struct.
+
+ * testsuite/libffi.call/call.exp: Add "-O2 -fomit-frame-pointer"
+ tests.
+
+2008-01-24 David Edelsohn <edelsohn@gnu.org>
+
+ * configure: Regenerate.
+
+2008-01-06 Andreas Tobler <a.tobler@schweiz.org>
+
+ * src/x86/ffi.c (ffi_prep_cif_machdep): Fix thinko.
+
+2008-01-05 Andreas Tobler <a.tobler@schweiz.org>
+
+ PR testsuite/32843
+ * src/x86/ffi.c (ffi_prep_cif_machdep): Add code for
+ signed/unsigned int8/16 for X86_DARWIN.
+ Updated copyright info.
+ Handle one and two byte structs with special cif->flags.
+ * src/x86/ffitarget.h: Add special types for one and two byte structs.
+ Updated copyright info.
+ * src/x86/darwin.S (ffi_call_SYSV): Rewrite to use a jump table like
+ sysv.S
+ Remove code to pop args from the stack after call.
+ Special-case signed/unsigned for int8/16, one and two byte structs.
+ (ffi_closure_raw_SYSV): Handle FFI_TYPE_UINT8,
+ FFI_TYPE_SINT8, FFI_TYPE_UINT16, FFI_TYPE_SINT16, FFI_TYPE_UINT32,
+ FFI_TYPE_SINT32.
+ Updated copyright info.
+
+2007-12-08 David Daney <ddaney@avtrex.com>
+
+ * src/mips/n32.S (ffi_call_N32): Replace dadd with ADDU, dsub with
+ SUBU, add with ADDU and use smaller code sequences.
+
+2007-12-07 David Daney <ddaney@avtrex.com>
+
+ * src/mips/ffi.c (ffi_prep_cif_machdep): Handle long double return
+ type.
+
+2007-12-06 David Daney <ddaney@avtrex.com>
+
+ * include/ffi.h.in (FFI_SIZEOF_JAVA_RAW): Define if not already
+ defined.
+ (ffi_java_raw): New typedef.
+ (ffi_java_raw_call, ffi_java_ptrarray_to_raw,
+ ffi_java_raw_to_ptrarray): Change parameter types from ffi_raw to
+ ffi_java_raw.
+ (ffi_java_raw_closure) : Same.
+ (ffi_prep_java_raw_closure, ffi_prep_java_raw_closure_loc): Change
+ parameter types.
+ * src/java_raw_api.c (ffi_java_raw_size): Replace FFI_SIZEOF_ARG with
+ FFI_SIZEOF_JAVA_RAW.
+ (ffi_java_raw_to_ptrarray): Change type of raw to ffi_java_raw.
+ Replace FFI_SIZEOF_ARG with FFI_SIZEOF_JAVA_RAW. Use
+ sizeof(ffi_java_raw) for alignment calculations.
+ (ffi_java_ptrarray_to_raw): Same.
+ (ffi_java_rvalue_to_raw): Add special handling for FFI_TYPE_POINTER
+ if FFI_SIZEOF_JAVA_RAW == 4.
+ (ffi_java_raw_to_rvalue): Same.
+ (ffi_java_raw_call): Change type of raw to ffi_java_raw.
+ (ffi_java_translate_args): Same.
+ (ffi_prep_java_raw_closure_loc, ffi_prep_java_raw_closure): Change
+ parameter types.
+ * src/mips/ffitarget.h (FFI_SIZEOF_JAVA_RAW): Define for N32 ABI.
+
+2007-12-06 David Daney <ddaney@avtrex.com>
+
+ * src/mips/n32.S (ffi_closure_N32): Use 64-bit add instruction on
+ pointer values.
+
+2007-12-01 Andreas Tobler <a.tobler@schweiz.org>
+
+ PR libffi/31937
+ * src/powerpc/ffitarget.h: Introduce new ABI FFI_LINUX_SOFT_FLOAT.
+ Add local FFI_TYPE_UINT128 to handle soft-float long-double-128.
+ * src/powerpc/ffi.c: Distinguish between __NO_FPRS__ and not and
+ set the NUM_FPR_ARG_REGISTERS according to.
+ Add support for potential soft-float support under hard-float
+ architecture.
+ (ffi_prep_args_SYSV): Set NUM_FPR_ARG_REGISTERS to 0 in case of
+ FFI_LINUX_SOFT_FLOAT, handle float, doubles and long-doubles according
+ to the FFI_LINUX_SOFT_FLOAT ABI.
+ (ffi_prep_cif_machdep): Likewise.
+ (ffi_closure_helper_SYSV): Likewise.
+ * src/powerpc/ppc_closure.S: Make sure not to store float/double
+ on archs where __NO_FPRS__ is true.
+ Add FFI_TYPE_UINT128 support.
+ * src/powerpc/sysv.S: Add support for soft-float long-double-128.
+ Adjust copyright notice.
+
+2007-11-25 Andreas Tobler <a.tobler@schweiz.org>
+
+ * src/closures.c: Move defintion of MAYBE_UNUSED from here to ...
+ * include/ffi_common.h: ... here.
+ Update copyright.
+
+2007-11-17 Andreas Tobler <a.tobler@schweiz.org>
+
+ * src/powerpc/sysv.S: Load correct cr to compare if we have long double.
+ * src/powerpc/linux64.S: Likewise.
+ * src/powerpc/ffi.c: Add a comment to show which part goes into cr6.
+ * testsuite/libffi.call/return_ldl.c: New test.
+
+2007-09-04 <aph@redhat.com>
+
+ * src/arm/sysv.S (UNWIND): New.
+ (Whole file): Conditionally compile unwinder directives.
+ * src/arm/sysv.S: Add unwinder directives.
+
+ * src/arm/ffi.c (ffi_prep_args): Align structs by at least 4 bytes.
+ Only treat r0 as a struct address if we're actually returning a
+ struct by address.
+ Only copy the bytes that are actually within a struct.
+ (ffi_prep_cif_machdep): A Composite Type not larger than 4 bytes
+ is returned in r0, not passed by address.
+ (ffi_call): Allocate a word-sized temporary for the case where
+ a composite is returned in r0.
+ (ffi_prep_incoming_args_SYSV): Align as necessary.
+
+2007-08-05 Steven Newbury <s_j_newbury@yahoo.co.uk>
+
+ * src/arm/ffi.c (FFI_INIT_TRAMPOLINE): Use __clear_cache instead of
+ directly using the sys_cacheflush syscall.
+
+2007-07-27 Andrew Haley <aph@redhat.com>
+
+ * src/arm/sysv.S (ffi_closure_SYSV): Add soft-float.
+
+2007-09-03 Maciej W. Rozycki <macro@linux-mips.org>
+
+ * Makefile.am: Unify MIPS_IRIX and MIPS_LINUX into MIPS.
+ * configure.ac: Likewise.
+ * Makefile.in: Regenerate.
+ * include/Makefile.in: Likewise.
+ * testsuite/Makefile.in: Likewise.
+ * configure: Likewise.
+
+2007-08-24 David Daney <ddaney@avtrex.com>
+
+ * testsuite/libffi.call/return_sl.c: New test.
+
+2007-08-10 David Daney <ddaney@avtrex.com>
+
+ * testsuite/libffi.call/cls_multi_ushort.c,
+ testsuite/libffi.call/cls_align_uint16.c,
+ testsuite/libffi.call/nested_struct1.c,
+ testsuite/libffi.call/nested_struct3.c,
+ testsuite/libffi.call/cls_7_1_byte.c,
+ testsuite/libffi.call/nested_struct5.c,
+ testsuite/libffi.call/cls_double.c,
+ testsuite/libffi.call/nested_struct7.c,
+ testsuite/libffi.call/cls_sint.c,
+ testsuite/libffi.call/nested_struct9.c,
+ testsuite/libffi.call/cls_20byte1.c,
+ testsuite/libffi.call/cls_multi_sshortchar.c,
+ testsuite/libffi.call/cls_align_sint64.c,
+ testsuite/libffi.call/cls_3byte2.c,
+ testsuite/libffi.call/cls_multi_schar.c,
+ testsuite/libffi.call/cls_multi_uchar.c,
+ testsuite/libffi.call/cls_19byte.c,
+ testsuite/libffi.call/cls_9byte1.c,
+ testsuite/libffi.call/cls_align_float.c,
+ testsuite/libffi.call/closure_fn1.c,
+ testsuite/libffi.call/problem1.c,
+ testsuite/libffi.call/closure_fn3.c,
+ testsuite/libffi.call/cls_sshort.c,
+ testsuite/libffi.call/closure_fn5.c,
+ testsuite/libffi.call/cls_align_double.c,
+ testsuite/libffi.call/nested_struct.c,
+ testsuite/libffi.call/cls_2byte.c,
+ testsuite/libffi.call/nested_struct10.c,
+ testsuite/libffi.call/cls_4byte.c,
+ testsuite/libffi.call/cls_6byte.c,
+ testsuite/libffi.call/cls_8byte.c,
+ testsuite/libffi.call/cls_multi_sshort.c,
+ testsuite/libffi.call/cls_align_sint16.c,
+ testsuite/libffi.call/cls_align_uint32.c,
+ testsuite/libffi.call/cls_20byte.c,
+ testsuite/libffi.call/cls_float.c,
+ testsuite/libffi.call/nested_struct2.c,
+ testsuite/libffi.call/cls_5_1_byte.c,
+ testsuite/libffi.call/nested_struct4.c,
+ testsuite/libffi.call/cls_24byte.c,
+ testsuite/libffi.call/nested_struct6.c,
+ testsuite/libffi.call/cls_64byte.c,
+ testsuite/libffi.call/nested_struct8.c,
+ testsuite/libffi.call/cls_uint.c,
+ testsuite/libffi.call/cls_multi_ushortchar.c,
+ testsuite/libffi.call/cls_schar.c,
+ testsuite/libffi.call/cls_uchar.c,
+ testsuite/libffi.call/cls_align_uint64.c,
+ testsuite/libffi.call/cls_ulonglong.c,
+ testsuite/libffi.call/cls_align_longdouble.c,
+ testsuite/libffi.call/cls_1_1byte.c,
+ testsuite/libffi.call/cls_12byte.c,
+ testsuite/libffi.call/cls_3_1byte.c,
+ testsuite/libffi.call/cls_3byte1.c,
+ testsuite/libffi.call/cls_4_1byte.c,
+ testsuite/libffi.call/cls_6_1_byte.c,
+ testsuite/libffi.call/cls_16byte.c,
+ testsuite/libffi.call/cls_18byte.c,
+ testsuite/libffi.call/closure_fn0.c,
+ testsuite/libffi.call/cls_9byte2.c,
+ testsuite/libffi.call/closure_fn2.c,
+ testsuite/libffi.call/closure_fn4.c,
+ testsuite/libffi.call/cls_ushort.c,
+ testsuite/libffi.call/closure_fn6.c,
+ testsuite/libffi.call/cls_5byte.c,
+ testsuite/libffi.call/cls_align_pointer.c,
+ testsuite/libffi.call/cls_7byte.c,
+ testsuite/libffi.call/cls_align_sint32.c,
+ testsuite/libffi.special/unwindtest_ffi_call.cc,
+ testsuite/libffi.special/unwindtest.cc: Remove xfail for mips64*-*-*.
+
+2007-08-10 David Daney <ddaney@avtrex.com>
+
+ PR libffi/28313
+ * configure.ac: Don't treat mips64 as a special case.
+ * Makefile.am (nodist_libffi_la_SOURCES): Add n32.S.
+ * configure: Regenerate
+ * Makefile.in: Ditto.
+ * fficonfig.h.in: Ditto.
+ * src/mips/ffitarget.h (REG_L, REG_S, SUBU, ADDU, SRL, LI): Indent.
+ (LA, EH_FRAME_ALIGN, FDE_ADDR_BYTES): New preprocessor macros.
+ (FFI_DEFAULT_ABI): Set for n64 case.
+ (FFI_CLOSURES, FFI_TRAMPOLINE_SIZE): Define for n32 and n64 cases.
+ * src/mips/n32.S (ffi_call_N32): Add debug macros and labels for FDE.
+ (ffi_closure_N32): New function.
+ (.eh_frame): New section
+ * src/mips/o32.S: Clean up comments.
+ (ffi_closure_O32): Pass ffi_closure parameter in $12.
+ * src/mips/ffi.c: Use FFI_MIPS_N32 instead of
+ _MIPS_SIM == _ABIN32 throughout.
+ (FFI_MIPS_STOP_HERE): New, use in place of
+ ffi_stop_here.
+ (ffi_prep_args): Use unsigned long to hold pointer values. Rewrite
+ to support n32/n64 ABIs.
+ (calc_n32_struct_flags): Rewrite.
+ (calc_n32_return_struct_flags): Remove unused variable. Reverse
+ position of flag bits.
+ (ffi_prep_cif_machdep): Rewrite n32 portion.
+ (ffi_call): Enable for n64. Add special handling for small structure
+ return values.
+ (ffi_prep_closure_loc): Add n32 and n64 support.
+ (ffi_closure_mips_inner_O32): Add cast to silence warning.
+ (copy_struct_N32, ffi_closure_mips_inner_N32): New functions.
+
+2007-08-08 David Daney <ddaney@avtrex.com>
+
+ * testsuite/libffi.call/ffitest.h (ffi_type_mylong): Remove definition.
+ * testsuite/libffi.call/cls_align_uint16.c (main): Use correct type
+ specifiers.
+ * testsuite/libffi.call/nested_struct1.c (main): Ditto.
+ * testsuite/libffi.call/cls_sint.c (main): Ditto.
+ * testsuite/libffi.call/nested_struct9.c (main): Ditto.
+ * testsuite/libffi.call/cls_20byte1.c (main): Ditto.
+ * testsuite/libffi.call/cls_9byte1.c (main): Ditto.
+ * testsuite/libffi.call/closure_fn1.c (main): Ditto.
+ * testsuite/libffi.call/closure_fn3.c (main): Ditto.
+ * testsuite/libffi.call/return_dbl2.c (main): Ditto.
+ * testsuite/libffi.call/cls_sshort.c (main): Ditto.
+ * testsuite/libffi.call/return_fl3.c (main): Ditto.
+ * testsuite/libffi.call/closure_fn5.c (main): Ditto.
+ * testsuite/libffi.call/nested_struct.c (main): Ditto.
+ * testsuite/libffi.call/nested_struct10.c (main): Ditto.
+ * testsuite/libffi.call/return_ll1.c (main): Ditto.
+ * testsuite/libffi.call/cls_8byte.c (main): Ditto.
+ * testsuite/libffi.call/cls_align_uint32.c (main): Ditto.
+ * testsuite/libffi.call/cls_align_sint16.c (main): Ditto.
+ * testsuite/libffi.call/cls_20byte.c (main): Ditto.
+ * testsuite/libffi.call/nested_struct2.c (main): Ditto.
+ * testsuite/libffi.call/cls_24byte.c (main): Ditto.
+ * testsuite/libffi.call/nested_struct6.c (main): Ditto.
+ * testsuite/libffi.call/cls_uint.c (main): Ditto.
+ * testsuite/libffi.call/cls_12byte.c (main): Ditto.
+ * testsuite/libffi.call/cls_16byte.c (main): Ditto.
+ * testsuite/libffi.call/closure_fn0.c (main): Ditto.
+ * testsuite/libffi.call/cls_9byte2.c (main): Ditto.
+ * testsuite/libffi.call/closure_fn2.c (main): Ditto.
+ * testsuite/libffi.call/return_dbl1.c (main): Ditto.
+ * testsuite/libffi.call/closure_fn4.c (main): Ditto.
+ * testsuite/libffi.call/closure_fn6.c (main): Ditto.
+ * testsuite/libffi.call/cls_align_sint32.c (main): Ditto.
+
+2007-08-07 Andrew Haley <aph@redhat.com>
+
+ * src/x86/sysv.S (ffi_closure_raw_SYSV): Fix typo in previous
+ checkin.
+
+2007-08-06 Andrew Haley <aph@redhat.com>
+
+ PR testsuite/32843
+ * src/x86/sysv.S (ffi_closure_raw_SYSV): Handle FFI_TYPE_UINT8,
+ FFI_TYPE_SINT8, FFI_TYPE_UINT16, FFI_TYPE_SINT16, FFI_TYPE_UINT32,
+ FFI_TYPE_SINT32.
+
+2007-08-02 David Daney <ddaney@avtrex.com>
+
+ * testsuite/libffi.call/return_ul.c (main): Define return type as
+ ffi_arg. Use proper printf conversion specifier.
+
+2007-07-30 Andrew Haley <aph@redhat.com>
+
+ PR testsuite/32843
+ * src/x86/ffi.c (ffi_prep_cif_machdep): in x86 case, add code for
+ signed/unsigned int8/16.
+ * src/x86/sysv.S (ffi_call_SYSV): Rewrite to:
+ Use a jump table.
+ Remove code to pop args from the stack after call.
+ Special-case signed/unsigned int8/16.
+ * testsuite/libffi.call/return_sc.c (main): Revert.
+
+2007-07-26 Richard Guenther <rguenther@suse.de>
+
+ PR testsuite/32843
+ * testsuite/libffi.call/return_sc.c (main): Verify call
+ result as signed char, not ffi_arg.
+
+2007-07-16 Rainer Orth <ro@TechFak.Uni-Bielefeld.DE>
+
+ * configure.ac (i?86-*-solaris2.1[0-9]): Set TARGET to X86_64.
+ * configure: Regenerate.
+
+2007-07-11 David Daney <ddaney@avtrex.com>
+
+ * src/mips/ffi.c: Don't include sys/cachectl.h.
+ (ffi_prep_closure_loc): Use __builtin___clear_cache() instead of
+ cacheflush().
+
+2007-05-18 Aurelien Jarno <aurelien@aurel32.net>
+
+ * src/arm/ffi.c (ffi_prep_closure_loc): Renamed and ajusted
+ from (ffi_prep_closure): ... this.
+ (FFI_INIT_TRAMPOLINE): Adjust.
+
+2005-12-31 Phil Blundell <pb@reciva.com>
+
+ * src/arm/ffi.c (ffi_prep_incoming_args_SYSV,
+ ffi_closure_SYSV_inner, ffi_prep_closure): New, add closure support.
+ * src/arm/sysv.S(ffi_closure_SYSV): Likewise.
+ * src/arm/ffitarget.h (FFI_TRAMPOLINE_SIZE): Likewise.
+ (FFI_CLOSURES): Enable closure support.
+
+2007-07-03 Andrew Haley <aph@hedges.billgatliff.com>
+
+ * testsuite/libffi.call/cls_multi_ushort.c,
+ testsuite/libffi.call/cls_align_uint16.c,
+ testsuite/libffi.call/nested_struct1.c,
+ testsuite/libffi.call/nested_struct3.c,
+ testsuite/libffi.call/cls_7_1_byte.c,
+ testsuite/libffi.call/cls_double.c,
+ testsuite/libffi.call/nested_struct5.c,
+ testsuite/libffi.call/nested_struct7.c,
+ testsuite/libffi.call/cls_sint.c,
+ testsuite/libffi.call/nested_struct9.c,
+ testsuite/libffi.call/cls_20byte1.c,
+ testsuite/libffi.call/cls_multi_sshortchar.c,
+ testsuite/libffi.call/cls_align_sint64.c,
+ testsuite/libffi.call/cls_3byte2.c,
+ testsuite/libffi.call/cls_multi_schar.c,
+ testsuite/libffi.call/cls_multi_uchar.c,
+ testsuite/libffi.call/cls_19byte.c,
+ testsuite/libffi.call/cls_9byte1.c,
+ testsuite/libffi.call/cls_align_float.c,
+ testsuite/libffi.call/closure_fn1.c,
+ testsuite/libffi.call/problem1.c,
+ testsuite/libffi.call/closure_fn3.c,
+ testsuite/libffi.call/cls_sshort.c,
+ testsuite/libffi.call/closure_fn5.c,
+ testsuite/libffi.call/cls_align_double.c,
+ testsuite/libffi.call/cls_2byte.c,
+ testsuite/libffi.call/nested_struct.c,
+ testsuite/libffi.call/nested_struct10.c,
+ testsuite/libffi.call/cls_4byte.c,
+ testsuite/libffi.call/cls_6byte.c,
+ testsuite/libffi.call/cls_8byte.c,
+ testsuite/libffi.call/cls_multi_sshort.c,
+ testsuite/libffi.call/cls_align_uint32.c,
+ testsuite/libffi.call/cls_align_sint16.c,
+ testsuite/libffi.call/cls_float.c,
+ testsuite/libffi.call/cls_20byte.c,
+ testsuite/libffi.call/cls_5_1_byte.c,
+ testsuite/libffi.call/nested_struct2.c,
+ testsuite/libffi.call/cls_24byte.c,
+ testsuite/libffi.call/nested_struct4.c,
+ testsuite/libffi.call/nested_struct6.c,
+ testsuite/libffi.call/cls_64byte.c,
+ testsuite/libffi.call/nested_struct8.c,
+ testsuite/libffi.call/cls_uint.c,
+ testsuite/libffi.call/cls_multi_ushortchar.c,
+ testsuite/libffi.call/cls_schar.c,
+ testsuite/libffi.call/cls_uchar.c,
+ testsuite/libffi.call/cls_align_uint64.c,
+ testsuite/libffi.call/cls_ulonglong.c,
+ testsuite/libffi.call/cls_align_longdouble.c,
+ testsuite/libffi.call/cls_1_1byte.c,
+ testsuite/libffi.call/cls_12byte.c,
+ testsuite/libffi.call/cls_3_1byte.c,
+ testsuite/libffi.call/cls_3byte1.c,
+ testsuite/libffi.call/cls_4_1byte.c,
+ testsuite/libffi.call/cls_6_1_byte.c,
+ testsuite/libffi.call/cls_16byte.c,
+ testsuite/libffi.call/cls_18byte.c,
+ testsuite/libffi.call/closure_fn0.c,
+ testsuite/libffi.call/cls_9byte2.c,
+ testsuite/libffi.call/closure_fn2.c,
+ testsuite/libffi.call/closure_fn4.c,
+ testsuite/libffi.call/cls_ushort.c,
+ testsuite/libffi.call/closure_fn6.c,
+ testsuite/libffi.call/cls_5byte.c,
+ testsuite/libffi.call/cls_align_pointer.c,
+ testsuite/libffi.call/cls_7byte.c,
+ testsuite/libffi.call/cls_align_sint32.c,
+ testsuite/libffi.special/unwindtest_ffi_call.cc,
+ testsuite/libffi.special/unwindtest.cc: Enable for ARM.
+
+2007-07-05 H.J. Lu <hongjiu.lu@intel.com>
+
+ * aclocal.m4: Regenerated.
+
+2007-06-02 Paolo Bonzini <bonzini@gnu.org>
+
+ * configure: Regenerate.
+
+2007-05-23 Steve Ellcey <sje@cup.hp.com>
+
+ * Makefile.in: Regenerate.
+ * configure: Regenerate.
+ * aclocal.m4: Regenerate.
+ * include/Makefile.in: Regenerate.
+ * testsuite/Makefile.in: Regenerate.
+
+2007-05-10 Roman Zippel <zippel@linux-m68k.org>
+
+ * src/m68k/ffi.c (ffi_prep_incoming_args_SYSV,
+ ffi_closure_SYSV_inner,ffi_prep_closure): New, add closure support.
+ * src/m68k/sysv.S(ffi_closure_SYSV,ffi_closure_struct_SYSV): Likewise.
+ * src/m68k/ffitarget.h (FFI_TRAMPOLINE_SIZE): Likewise.
+ (FFI_CLOSURES): Enable closure support.
+
+2007-05-10 Roman Zippel <zippel@linux-m68k.org>
+
+ * configure.ac (HAVE_AS_CFI_PSEUDO_OP): New test.
+ * configure: Regenerate.
+ * fficonfig.h.in: Regenerate.
+ * src/m68k/sysv.S (CFI_STARTPROC,CFI_ENDPROC,
+ CFI_OFFSET,CFI_DEF_CFA): New macros.
+ (ffi_call_SYSV): Add callframe annotation.
+
+2007-05-10 Roman Zippel <zippel@linux-m68k.org>
+
+ * src/m68k/ffi.c (ffi_prep_args,ffi_prep_cif_machdep): Fix
+ numerous test suite failures.
+ * src/m68k/sysv.S (ffi_call_SYSV): Likewise.
+
+2007-04-11 Paolo Bonzini <bonzini@gnu.org>
+
+ * Makefile.am (EXTRA_DIST): Bring up to date.
+ * Makefile.in: Regenerate.
+ * src/frv/eabi.S: Remove RCS keyword.
+
+2007-04-06 Richard Henderson <rth@redhat.com>
+
+ * configure.ac: Tidy target case.
+ (HAVE_LONG_DOUBLE): Allow the target to override.
+ * configure: Regenerate.
+ * include/ffi.h.in: Don't define ffi_type_foo if
+ LIBFFI_HIDE_BASIC_TYPES is defined.
+ (ffi_type_longdouble): If not HAVE_LONG_DOUBLE, define
+ to ffi_type_double.
+ * types.c (LIBFFI_HIDE_BASIC_TYPES): Define.
+ (FFI_TYPEDEF, ffi_type_void): Mark the data const.
+ (ffi_type_longdouble): Special case for Alpha. Don't define
+ if long double == double.
+
+ * src/alpha/ffi.c (FFI_TYPE_LONGDOUBLE): Assert unique value.
+ (ffi_prep_cif_machdep): Handle it as the 128-bit type.
+ (ffi_call, ffi_closure_osf_inner): Likewise.
+ (ffi_closure_osf_inner): Likewise. Mark hidden.
+ (ffi_call_osf, ffi_closure_osf): Mark hidden.
+ * src/alpha/ffitarget.h (FFI_LAST_ABI): Tidy definition.
+ * src/alpha/osf.S (ffi_call_osf, ffi_closure_osf): Mark hidden.
+ (load_table): Handle 128-bit long double.
+
+ * testsuite/libffi.call/float4.c: Add -mieee for alpha.
+
+2007-04-06 Tom Tromey <tromey@redhat.com>
+
+ PR libffi/31491:
+ * README: Fixed bug in example.
+
+2007-04-03 Jakub Jelinek <jakub@redhat.com>
+
+ * src/closures.c: Include sys/statfs.h.
+ (_GNU_SOURCE): Define on Linux.
+ (FFI_MMAP_EXEC_SELINUX): Define.
+ (selinux_enabled): New variable.
+ (selinux_enabled_check): New function.
+ (is_selinux_enabled): Define.
+ (dlmmap): Use it.
+
+2007-03-24 Uros Bizjak <ubizjak@gmail.com>
+
+ * testsuite/libffi.call/return_fl2.c (return_fl): Mark as static.
+ Use 'volatile float sum' to create sum of floats to avoid false
+ negative due to excess precision on ix86 targets.
+ (main): Ditto.
+
+2007-03-08 Alexandre Oliva <aoliva@redhat.com>
+
+ * src/powerpc/ffi.c (flush_icache): Fix left-over from previous
+ patch.
+ (ffi_prep_closure_loc): Remove unneeded casts. Add needed ones.
+
+2007-03-07 Alexandre Oliva <aoliva@redhat.com>
+
+ * include/ffi.h.in (ffi_closure_alloc, ffi_closure_free): New.
+ (ffi_prep_closure_loc): New.
+ (ffi_prep_raw_closure_loc): New.
+ (ffi_prep_java_raw_closure_loc): New.
+ * src/closures.c: New file.
+ * src/dlmalloc.c [FFI_MMAP_EXEC_WRIT] (struct malloc_segment):
+ Replace sflags with exec_offset.
+ [FFI_MMAP_EXEC_WRIT] (mmap_exec_offset, add_segment_exec_offset,
+ sub_segment_exec_offset): New macros.
+ (get_segment_flags, set_segment_flags, check_segment_merge): New
+ macros.
+ (is_mmapped_segment, is_extern_segment): Use get_segment_flags.
+ (add_segment, sys_alloc, create_mspace, create_mspace_with_base,
+ destroy_mspace): Use new macros.
+ (sys_alloc): Silence warning.
+ * Makefile.am (libffi_la_SOURCES): Add src/closures.c.
+ * Makefile.in: Rebuilt.
+ * src/prep_cif [FFI_CLOSURES] (ffi_prep_closure): Implement in
+ terms of ffi_prep_closure_loc.
+ * src/raw_api.c (ffi_prep_raw_closure_loc): Renamed and adjusted
+ from...
+ (ffi_prep_raw_closure): ... this. Re-implement in terms of the
+ renamed version.
+ * src/java_raw_api (ffi_prep_java_raw_closure_loc): Renamed and
+ adjusted from...
+ (ffi_prep_java_raw_closure): ... this. Re-implement in terms of
+ the renamed version.
+ * src/alpha/ffi.c (ffi_prep_closure_loc): Renamed from
+ (ffi_prep_closure): ... this.
+ * src/pa/ffi.c: Likewise.
+ * src/cris/ffi.c: Likewise. Adjust.
+ * src/frv/ffi.c: Likewise.
+ * src/ia64/ffi.c: Likewise.
+ * src/mips/ffi.c: Likewise.
+ * src/powerpc/ffi_darwin.c: Likewise.
+ * src/s390/ffi.c: Likewise.
+ * src/sh/ffi.c: Likewise.
+ * src/sh64/ffi.c: Likewise.
+ * src/sparc/ffi.c: Likewise.
+ * src/x86/ffi64.c: Likewise.
+ * src/x86/ffi.c: Likewise.
+ (FFI_INIT_TRAMPOLINE): Adjust.
+ (ffi_prep_raw_closure_loc): Renamed and adjusted from...
+ (ffi_prep_raw_closure): ... this.
+ * src/powerpc/ffi.c (ffi_prep_closure_loc): Renamed from
+ (ffi_prep_closure): ... this.
+ (flush_icache): Adjust.
+
+2007-03-07 Alexandre Oliva <aoliva@redhat.com>
+
+ * src/dlmalloc.c: New file, imported version 2.8.3 of Doug
+ Lea's malloc.
+
+2007-03-01 Brooks Moses <brooks.moses@codesourcery.com>
+
+ * Makefile.am: Add dummy install-pdf target.
+ * Makefile.in: Regenerate
+
+2007-02-13 Andreas Krebbel <krebbel1@de.ibm.com>
+
+ * src/s390/ffi.c (ffi_prep_args, ffi_prep_cif_machdep,
+ ffi_closure_helper_SYSV): Add long double handling.
+
+2007-02-02 Jakub Jelinek <jakub@redhat.com>
+
+ * src/powerpc/linux64.S (ffi_call_LINUX64): Move restore of r2
+ immediately after bctrl instruction.
+
+2007-01-18 Alexandre Oliva <aoliva@redhat.com>
+
+ * Makefile.am (all-recursive, install-recursive,
+ mostlyclean-recursive, clean-recursive, distclean-recursive,
+ maintainer-clean-recursive): Add missing targets.
+ * Makefile.in: Rebuilt.
+
+2006-12-14 Andreas Tobler <a.tobler@schweiz.org>
+
+ * configure.ac: Add TARGET for x86_64-*-darwin*.
+ * Makefile.am (nodist_libffi_la_SOURCES): Add rules for 64-bit sources
+ for X86_DARWIN.
+ * src/x86/ffitarget.h: Set trampoline size for x86_64-*-darwin*.
+ * src/x86/darwin64.S: New file for x86_64-*-darwin* support.
+ * configure: Regenerate.
+ * Makefile.in: Regenerate.
+ * include/Makefile.in: Regenerate.
+ * testsuite/Makefile.in: Regenerate.
+ * testsuite/libffi.special/unwindtest_ffi_call.cc: New test case for
+ ffi_call only.
+
+2006-12-13 Andreas Tobler <a.tobler@schweiz.org>
+
+ * aclocal.m4: Regenerate with aclocal -I .. as written in the
+ Makefile.am.
+
+2006-10-31 Geoffrey Keating <geoffk@apple.com>
+
+ * src/powerpc/ffi_darwin.c (darwin_adjust_aggregate_sizes): New.
+ (ffi_prep_cif_machdep): Call darwin_adjust_aggregate_sizes for
+ Darwin.
+ * testsuite/libffi.call/nested_struct4.c: Remove Darwin XFAIL.
+ * testsuite/libffi.call/nested_struct6.c: Remove Darwin XFAIL.
+
+2006-10-10 Paolo Bonzini <bonzini@gnu.org>
+ Sandro Tolaini <tolaini@libero.it>
+
+ * configure.ac [i*86-*-darwin*]: Set X86_DARWIN symbol and
+ conditional.
+ * configure: Regenerated.
+ * Makefile.am (nodist_libffi_la_SOURCES) [X86_DARWIN]: New case.
+ (EXTRA_DIST): Add src/x86/darwin.S.
+ * Makefile.in: Regenerated.
+ * include/Makefile.in: Regenerated.
+ * testsuite/Makefile.in: Regenerated.
+
+ * src/x86/ffi.c (ffi_prep_cif_machdep) [X86_DARWIN]: Treat like
+ X86_WIN32, and additionally align stack to 16 bytes.
+ * src/x86/darwin.S: New, based on sysv.S.
+ * src/prep_cif.c (ffi_prep_cif) [X86_DARWIN]: Align > 8-byte structs.
+
+2006-09-12 David Daney <ddaney@avtrex.com>
+
+ PR libffi/23935
+ * include/Makefile.am: Install both ffi.h and ffitarget.h in
+ $(libdir)/gcc/$(target_alias)/$(gcc_version)/include.
+ * aclocal.m4: Regenerated for automake 1.9.6.
+ * Makefile.in: Regenerated.
+ * include/Makefile.in: Regenerated.
+ * testsuite/Makefile.in: Regenerated.
+
+2006-08-17 Andreas Tobler <a.tobler@schweiz.ch>
+
+ * include/ffi_common.h (struct): Revert accidental commit.
+
+2006-08-15 Andreas Tobler <a.tobler@schweiz.ch>
+
+ * include/ffi_common.h: Remove lint directives.
+ * include/ffi.h.in: Likewise.
+
+2006-07-25 Torsten Schoenfeld <kaffeetisch@gmx.de>
+
+ * include/ffi.h.in (ffi_type_ulong, ffi_type_slong): Define correctly
+ for 32-bit architectures.
+ * testsuite/libffi.call/return_ul.c: New test case.
+
+2006-07-19 David Daney <ddaney@avtrex.com>
+
+ * testsuite/libffi.call/closure_fn6.c: Remove xfail for mips,
+ xfail remains for mips64.
+
+2006-05-23 Carlos O'Donell <carlos@codesourcery.com>
+
+ * Makefile.am: Add install-html target. Add install-html to .PHONY
+ * Makefile.in: Regenerate.
+ * aclocal.m4: Regenerate.
+ * include/Makefile.in: Regenerate.
+ * testsuite/Makefile.in: Regenerate.
+
+2006-05-18 John David Anglin <dave.anglin@nrc-cnrc.gc.ca>
+
+ * pa/ffi.c (ffi_prep_args_pa32): Load floating point arguments from
+ stack slot.
+
+2006-04-22 Andreas Tobler <a.tobler@schweiz.ch>
+
+ * README: Remove notice about 'Crazy Comments'.
+ * src/debug.c: Remove lint directives. Cleanup white spaces.
+ * src/java_raw_api.c: Likewise.
+ * src/prep_cif.c: Likewise.
+ * src/raw_api.c: Likewise.
+ * src/ffitest.c: Delete. No longer needed, all test cases migrated
+ to the testsuite.
+ * src/arm/ffi.c: Remove lint directives.
+ * src/m32r/ffi.c: Likewise.
+ * src/pa/ffi.c: Likewise.
+ * src/powerpc/ffi.c: Likewise.
+ * src/powerpc/ffi_darwin.c: Likewise.
+ * src/sh/ffi.c: Likewise.
+ * src/sh64/ffi.c: Likewise.
+ * src/x86/ffi.c: Likewise.
+ * testsuite/libffi.call/float2.c: Likewise.
+ * testsuite/libffi.call/promotion.c: Likewise.
+ * testsuite/libffi.call/struct1.c: Likewise.
+
+2006-04-13 Andreas Tobler <a.tobler@schweiz.ch>
+
+ * src/pa/hpux32.S: Correct unwind offset calculation for
+ ffi_closure_pa32.
+ * src/pa/linux.S: Likewise.
+
+2006-04-12 James E Wilson <wilson@specifix.com>
+
+ PR libgcj/26483
+ * src/ia64/ffi.c (stf_spill, ldf_fill): Rewrite as macros.
+ (hfa_type_load): Call stf_spill.
+ (hfa_type_store): Call ldf_fill.
+ (ffi_call): Adjust calls to above routines. Add local temps for
+ macro result.
+
+2006-04-10 Matthias Klose <doko@debian.org>
+
+ * testsuite/lib/libffi-dg.exp (libffi-init): Recognize multilib
+ directory names containing underscores.
+
+2006-04-07 James E Wilson <wilson@specifix.com>
+
+ * testsuite/libffi.call/float4.c: New testcase.
+
+2006-04-05 John David Anglin <dave.anglin@nrc-cnrc.gc.ca>
+ Andreas Tobler <a.tobler@schweiz.ch>
+
+ * Makefile.am: Add PA_HPUX port.
+ * Makefile.in: Regenerate.
+ * include/Makefile.in: Likewise.
+ * testsuite/Makefile.in: Likewise.
+ * configure.ac: Add PA_HPUX rules.
+ * configure: Regenerate.
+ * src/pa/ffitarget.h: Rename linux target to PA_LINUX.
+ Add PA_HPUX and PA64_HPUX.
+ Rename FFI_LINUX ABI to FFI_PA32 ABI.
+ (FFI_TRAMPOLINE_SIZE): Define for 32-bit HP-UX targets.
+ (FFI_TYPE_SMALL_STRUCT2): Define.
+ (FFI_TYPE_SMALL_STRUCT4): Likewise.
+ (FFI_TYPE_SMALL_STRUCT8): Likewise.
+ (FFI_TYPE_SMALL_STRUCT3): Redefine.
+ (FFI_TYPE_SMALL_STRUCT5): Likewise.
+ (FFI_TYPE_SMALL_STRUCT6): Likewise.
+ (FFI_TYPE_SMALL_STRUCT7): Likewise.
+ * src/pa/ffi.c (ROUND_DOWN): Delete.
+ (fldw, fstw, fldd, fstd): Use '__asm__'.
+ (ffi_struct_type): Add support for FFI_TYPE_SMALL_STRUCT2,
+ FFI_TYPE_SMALL_STRUCT4 and FFI_TYPE_SMALL_STRUCT8.
+ (ffi_prep_args_LINUX): Rename to ffi_prep_args_pa32. Update comment.
+ Simplify incrementing of stack slot variable. Change type of local
+ 'n' to unsigned int.
+ (ffi_size_stack_LINUX): Rename to ffi_size_stack_pa32. Handle long
+ double on PA_HPUX.
+ (ffi_prep_cif_machdep): Likewise.
+ (ffi_call): Likewise.
+ (ffi_closure_inner_LINUX): Rename to ffi_closure_inner_pa32. Change
+ return type to ffi_status. Simplify incrementing of stack slot
+ variable. Only copy floating point argument registers when PA_LINUX
+ is true. Reformat debug statement.
+ Add support for FFI_TYPE_SMALL_STRUCT2, FFI_TYPE_SMALL_STRUCT4 and
+ FFI_TYPE_SMALL_STRUCT8.
+ (ffi_closure_LINUX): Rename to ffi_closure_pa32. Add 'extern' to
+ declaration.
+ (ffi_prep_closure): Make linux trampoline conditional on PA_LINUX.
+ Add nops to cache flush. Add trampoline for PA_HPUX.
+ * src/pa/hpux32.S: New file.
+ * src/pa/linux.S (ffi_call_LINUX): Rename to ffi_call_pa32. Rename
+ ffi_prep_args_LINUX to ffi_prep_args_pa32.
+ Localize labels. Add support for 2, 4 and 8-byte small structs. Handle
+ unaligned destinations in 3, 5, 6 and 7-byte small structs. Order
+ argument type checks so that common argument types appear first.
+ (ffi_closure_LINUX): Rename to ffi_closure_pa32. Rename
+ ffi_closure_inner_LINUX to ffi_closure_inner_pa32.
+
+2006-03-24 Alan Modra <amodra@bigpond.net.au>
+
+ * src/powerpc/ffitarget.h (enum ffi_abi): Add FFI_LINUX. Default
+ for 32-bit using IBM extended double format. Fix FFI_LAST_ABI.
+ * src/powerpc/ffi.c (ffi_prep_args_SYSV): Handle linux variant of
+ FFI_TYPE_LONGDOUBLE.
+ (ffi_prep_args64): Assert using IBM extended double.
+ (ffi_prep_cif_machdep): Don't munge FFI_TYPE_LONGDOUBLE type.
+ Handle FFI_LINUX FFI_TYPE_LONGDOUBLE return and args.
+ (ffi_call): Handle FFI_LINUX.
+ (ffi_closure_helper_SYSV): Non FFI_LINUX long double return needs
+ gpr3 return pointer as for struct return. Handle FFI_LINUX
+ FFI_TYPE_LONGDOUBLE return and args. Don't increment "nf"
+ unnecessarily.
+ * src/powerpc/ppc_closure.S (ffi_closure_SYSV): Load both f1 and f2
+ for FFI_TYPE_LONGDOUBLE. Move epilogue insns into case table.
+ Don't use r6 as pointer to results, instead use sp offset. Don't
+ make a special call to load lr with case table address, instead
+ use offset from previous call.
+ * src/powerpc/sysv.S (ffi_call_SYSV): Save long double return.
+ * src/powerpc/linux64.S (ffi_call_LINUX64): Simplify long double
+ return.
+
+2006-03-15 Kaz Kojima <kkojima@gcc.gnu.org>
+
+ * src/sh64/ffi.c (ffi_prep_cif_machdep): Handle float arguments
+ passed with FP registers correctly.
+ (ffi_closure_helper_SYSV): Likewise.
+ * src/sh64/sysv.S: Likewise.
+
+2006-03-01 Andreas Tobler <a.tobler@schweiz.ch>
+
+ * testsuite/libffi.special/unwindtest.cc (closure_test_fn): Mark cif,
+ args and userdata unused.
+ (closure_test_fn1): Mark cif and userdata unused.
+ (main): Remove unused res.
+
+2006-02-28 Andreas Tobler <a.tobler@schweiz.ch>
+
+ * testsuite/libffi.call/call.exp: Adjust FSF address. Add test runs for
+ -O2, -O3, -Os and the warning flags -W -Wall.
+ * testsuite/libffi.special/special.exp: Likewise.
+ * testsuite/libffi.call/ffitest.h: Add an __UNUSED__ macro to mark
+ unused parameter unused for gcc or else do nothing.
+ * testsuite/libffi.special/ffitestcxx.h: Likewise.
+ * testsuite/libffi.call/cls_12byte.c (cls_struct_12byte_gn): Mark cif
+ and userdata unused.
+ * testsuite/libffi.call/cls_16byte.c (cls_struct_16byte_gn): Likewise.
+ * testsuite/libffi.call/cls_18byte.c (cls_struct_18byte_gn): Likewise.
+ * testsuite/libffi.call/cls_19byte.c (cls_struct_19byte_gn): Likewise.
+ * testsuite/libffi.call/cls_1_1byte.c (cls_struct_1_1byte_gn): Likewise.
+ * testsuite/libffi.call/cls_20byte.c (cls_struct_20byte_gn): Likewise.
+ * testsuite/libffi.call/cls_20byte1.c (cls_struct_20byte_gn): Likewise.
+ * testsuite/libffi.call/cls_24byte.c (cls_struct_24byte_gn): Likewise.
+ * testsuite/libffi.call/cls_2byte.c (cls_struct_2byte_gn): Likewise.
+ * testsuite/libffi.call/cls_3_1byte.c (cls_struct_3_1byte_gn): Likewise.
+ * testsuite/libffi.call/cls_3byte1.c (cls_struct_3byte_gn): Likewise.
+ * testsuite/libffi.call/cls_3byte2.c (cls_struct_3byte_gn1): Likewise.
+ * testsuite/libffi.call/cls_4_1byte.c (cls_struct_4_1byte_gn): Likewise.
+ * testsuite/libffi.call/cls_4byte.c (cls_struct_4byte_gn): Likewise.
+ * testsuite/libffi.call/cls_5_1_byte.c (cls_struct_5byte_gn): Likewise.
+ * testsuite/libffi.call/cls_5byte.c (cls_struct_5byte_gn): Likewise.
+ * testsuite/libffi.call/cls_64byte.c (cls_struct_64byte_gn): Likewise.
+ * testsuite/libffi.call/cls_6_1_byte.c (cls_struct_6byte_gn): Likewise.
+ * testsuite/libffi.call/cls_6byte.c (cls_struct_6byte_gn): Likewise.
+ * testsuite/libffi.call/cls_7_1_byte.c (cls_struct_7byte_gn): Likewise.
+ * testsuite/libffi.call/cls_7byte.c (cls_struct_7byte_gn): Likewise.
+ * testsuite/libffi.call/cls_8byte.c (cls_struct_8byte_gn): Likewise.
+ * testsuite/libffi.call/cls_9byte1.c (cls_struct_9byte_gn): Likewise.
+ * testsuite/libffi.call/cls_9byte2.c (cls_struct_9byte_gn): Likewise.
+ * testsuite/libffi.call/cls_align_double.c (cls_struct_align_gn):
+ Likewise.
+ * testsuite/libffi.call/cls_align_float.c (cls_struct_align_gn):
+ Likewise.
+ * testsuite/libffi.call/cls_align_longdouble.c (cls_struct_align_gn):
+ Likewise.
+ * testsuite/libffi.call/cls_align_pointer.c (cls_struct_align_fn): Cast
+ void* to avoid compiler warning.
+ (main): Likewise.
+ (cls_struct_align_gn): Mark cif and userdata unused.
+ * testsuite/libffi.call/cls_align_sint16.c (cls_struct_align_gn):
+ Likewise.
+ * testsuite/libffi.call/cls_align_sint32.c (cls_struct_align_gn):
+ Likewise.
+ * testsuite/libffi.call/cls_align_sint64.c (cls_struct_align_gn):
+ Likewise.
+ * testsuite/libffi.call/cls_align_uint16.c (cls_struct_align_gn):
+ Likewise.
+ * testsuite/libffi.call/cls_align_uint32.c (cls_struct_align_gn):
+ Likewise.
+ * testsuite/libffi.call/cls_double.c (cls_ret_double_fn): Likewise.
+ * testsuite/libffi.call/cls_float.c (cls_ret_float_fn): Likewise.
+ * testsuite/libffi.call/cls_multi_schar.c (test_func_gn): Mark cif and
+ data unused.
+ (main): Cast res_call to silence gcc.
+ * testsuite/libffi.call/cls_multi_sshort.c (test_func_gn): Mark cif and
+ data unused.
+ (main): Cast res_call to silence gcc.
+ * testsuite/libffi.call/cls_multi_sshortchar.c (test_func_gn): Mark cif
+ and data unused.
+ (main): Cast res_call to silence gcc.
+ * testsuite/libffi.call/cls_multi_uchar.c (test_func_gn): Mark cif and
+ data unused.
+ (main): Cast res_call to silence gcc.
+ * testsuite/libffi.call/cls_multi_ushort.c (test_func_gn): Mark cif and
+ data unused.
+ (main): Cast res_call to silence gcc.
+ * testsuite/libffi.call/cls_multi_ushortchar.c (test_func_gn): Mark cif
+ and data unused.
+ (main): Cast res_call to silence gcc.
+ * testsuite/libffi.call/cls_schar.c (cls_ret_schar_fn): Mark cif and
+ userdata unused.
+ (cls_ret_schar_fn): Cast printf parameter to silence gcc.
+ * testsuite/libffi.call/cls_sint.c (cls_ret_sint_fn): Mark cif and
+ userdata unused.
+ (cls_ret_sint_fn): Cast printf parameter to silence gcc.
+ * testsuite/libffi.call/cls_sshort.c (cls_ret_sshort_fn): Mark cif and
+ userdata unused.
+ (cls_ret_sshort_fn): Cast printf parameter to silence gcc.
+ * testsuite/libffi.call/cls_uchar.c (cls_ret_uchar_fn): Mark cif and
+ userdata unused.
+ (cls_ret_uchar_fn): Cast printf parameter to silence gcc.
+ * testsuite/libffi.call/cls_uint.c (cls_ret_uint_fn): Mark cif and
+ userdata unused.
+ (cls_ret_uint_fn): Cast printf parameter to silence gcc.
+ * testsuite/libffi.call/cls_ulonglong.c (cls_ret_ulonglong_fn): Mark cif
+ and userdata unused.
+ * testsuite/libffi.call/cls_ushort.c (cls_ret_ushort_fn): Mark cif and
+ userdata unused.
+ (cls_ret_ushort_fn): Cast printf parameter to silence gcc.
+ * testsuite/libffi.call/float.c (floating): Remove unused parameter e.
+ * testsuite/libffi.call/float1.c (main): Remove unused variable i.
+ Cleanup white spaces.
+ * testsuite/libffi.call/negint.c (checking): Remove unused variable i.
+ * testsuite/libffi.call/nested_struct.c (cls_struct_combined_gn): Mark
+ cif and userdata unused.
+ * testsuite/libffi.call/nested_struct1.c (cls_struct_combined_gn):
+ Likewise.
+ * testsuite/libffi.call/nested_struct10.c (B_gn): Likewise.
+ * testsuite/libffi.call/nested_struct2.c (B_fn): Adjust printf
+ formatters to silence gcc.
+ (B_gn): Mark cif and userdata unused.
+ * testsuite/libffi.call/nested_struct3.c (B_gn): Mark cif and userdata
+ unused.
+ * testsuite/libffi.call/nested_struct4.c: Mention related PR.
+ (B_gn): Mark cif and userdata unused.
+ * testsuite/libffi.call/nested_struct5.c (B_gn): Mark cif and userdata
+ unused.
+ * testsuite/libffi.call/nested_struct6.c: Mention related PR.
+ (B_gn): Mark cif and userdata unused.
+ * testsuite/libffi.call/nested_struct7.c (B_gn): Mark cif and userdata
+ unused.
+ * testsuite/libffi.call/nested_struct8.c (B_gn): Likewise.
+ * testsuite/libffi.call/nested_struct9.c (B_gn): Likewise.
+ * testsuite/libffi.call/problem1.c (stub): Likewise.
+ * testsuite/libffi.call/pyobjc-tc.c (main): Cast the result to silence
+ gcc.
+ * testsuite/libffi.call/return_fl2.c (return_fl): Add the note mentioned
+ in the last commit for this test case in the test case itself.
+ * testsuite/libffi.call/closure_fn0.c (closure_test_fn0): Mark cif as
+ unused.
+ * testsuite/libffi.call/closure_fn1.c (closure_test_fn1): Likewise.
+ * testsuite/libffi.call/closure_fn2.c (closure_test_fn2): Likewise.
+ * testsuite/libffi.call/closure_fn3.c (closure_test_fn3): Likewise.
+ * testsuite/libffi.call/closure_fn4.c (closure_test_fn0): Likewise.
+ * testsuite/libffi.call/closure_fn5.c (closure_test_fn5): Likewise.
+ * testsuite/libffi.call/closure_fn6.c (closure_test_fn0): Likewise.
+
+2006-02-22 Kaz Kojima <kkojima@gcc.gnu.org>
+
+ * src/sh/sysv.S: Fix register numbers in the FDE for
+ ffi_closure_SYSV.
+
+2006-02-20 Andreas Tobler <a.tobler@schweiz.ch>
+
+ * testsuite/libffi.call/return_fl2.c (return_fl): Remove static
+ declaration to avoid a false negative on ix86. See PR323.
+
+2006-02-18 Kaz Kojima <kkojima@gcc.gnu.org>
+
+ * src/sh/ffi.c (ffi_closure_helper_SYSV): Remove unused variable
+ and cast integer to void * if needed. Update the pointer to
+ the FP register saved area correctly.
+
+2006-02-17 Andreas Tobler <a.tobler@schweiz.ch>
+
+ * testsuite/libffi.call/nested_struct6.c: XFAIL this test until PR25630
+ is fixed.
+ * testsuite/libffi.call/nested_struct4.c: Likewise.
+
+2006-02-16 Andreas Tobler <a.tobler@schweiz.ch>
+
+ * testsuite/libffi.call/return_dbl.c: New test case.
+ * testsuite/libffi.call/return_dbl1.c: Likewise.
+ * testsuite/libffi.call/return_dbl2.c: Likewise.
+ * testsuite/libffi.call/return_fl.c: Likewise.
+ * testsuite/libffi.call/return_fl1.c: Likewise.
+ * testsuite/libffi.call/return_fl2.c: Likewise.
+ * testsuite/libffi.call/return_fl3.c: Likewise.
+ * testsuite/libffi.call/closure_fn6.c: Likewise.
+
+ * testsuite/libffi.call/nested_struct2.c: Remove ffi_type_mylong
+ definition.
+ * testsuite/libffi.call/ffitest.h: Add ffi_type_mylong definition
+ here to be used by other test cases too.
+
+ * testsuite/libffi.call/nested_struct10.c: New test case.
+ * testsuite/libffi.call/nested_struct9.c: Likewise.
+ * testsuite/libffi.call/nested_struct8.c: Likewise.
+ * testsuite/libffi.call/nested_struct7.c: Likewise.
+ * testsuite/libffi.call/nested_struct6.c: Likewise.
+ * testsuite/libffi.call/nested_struct5.c: Likewise.
+ * testsuite/libffi.call/nested_struct4.c: Likewise.
+
+2006-01-21 Andreas Tobler <a.tobler@schweiz.ch>
+
+ * configure.ac: Enable libffi for sparc64-*-freebsd*.
+ * configure: Rebuilt.
+
+2006-01-18 Jakub Jelinek <jakub@redhat.com>
+
+ * src/powerpc/sysv.S (smst_two_register): Don't call __ashldi3,
+ instead do the shifting inline.
+ * src/powerpc/ppc_closure.S (ffi_closure_SYSV): Don't compute %r5
+ shift count unconditionally. Simplify load sequences for 1, 2, 3, 4
+ and 8 byte structs, for the remaining struct sizes don't call
+ __lshrdi3, instead do the shifting inline.
+
+2005-12-07 Thiemo Seufer <ths@networkno.de>
+
+ * src/mips/ffitarget.h: Remove obsolete sgidefs.h include. Add
+ missing parentheses.
+ * src/mips/o32.S (ffi_call_O32): Code formatting. Define
+ and use A3_OFF, FP_OFF, RA_OFF. Micro-optimizations.
+ (ffi_closure_O32): Likewise, but with newly defined A3_OFF2,
+ A2_OFF2, A1_OFF2, A0_OFF2, RA_OFF2, FP_OFF2, S0_OFF2, GP_OFF2,
+ V1_OFF2, V0_OFF2, FA_1_1_OFF2, FA_1_0_OFF2, FA_0_1_OFF2,
+ FA_0_0_OFF2.
+ * src/mips/ffi.c (ffi_prep_args): Code formatting. Fix
+ endianness bugs.
+ (ffi_prep_closure): Improve trampoline instruction scheduling.
+ (ffi_closure_mips_inner_O32): Fix endianness bugs.
+
+2005-12-03 Alan Modra <amodra@bigpond.net.au>
+
+ * src/powerpc/ffi.c: Formatting.
+ (ffi_prep_args_SYSV): Avoid possible aliasing problems by using unions.
+ (ffi_prep_args64): Likewise.
+
+2005-09-30 Geoffrey Keating <geoffk@apple.com>
+
+ * testsuite/lib/libffi-dg.exp (libffi_target_compile): For
+ darwin, use -shared-libgcc not -lgcc_s, and explain why.
+
+2005-09-26 Tom Tromey <tromey@redhat.com>
+
+ * testsuite/libffi.call/float1.c (value_type): New typedef.
+ (CANARY): New define.
+ (main): Check for result buffer overflow.
+ * src/powerpc/linux64.S: Handle linux64 long double returns.
+ * src/powerpc/ffi.c (FLAG_RETURNS_128BITS): New constant.
+ (ffi_prep_cif_machdep): Handle linux64 long double returns.
+
+2005-08-25 Alan Modra <amodra@bigpond.net.au>
+
+ PR target/23404
+ * src/powerpc/ffi.c (ffi_prep_args_SYSV): Correct placement of stack
+ homed fp args.
+ (ffi_status ffi_prep_cif_machdep): Correct stack sizing for same.
+
+2005-08-11 Jakub Jelinek <jakub@redhat.com>
+
+ * configure.ac (HAVE_HIDDEN_VISIBILITY_ATTRIBUTE): New test.
+ (AH_BOTTOM): Add FFI_HIDDEN definition.
+ * configure: Rebuilt.
+ * fficonfig.h.in: Rebuilt.
+ * src/powerpc/ffi.c (hidden): Remove.
+ (ffi_closure_LINUX64, ffi_prep_args64, ffi_call_LINUX64,
+ ffi_closure_helper_LINUX64): Use FFI_HIDDEN instead of hidden.
+ * src/powerpc/linux64_closure.S (ffi_closure_LINUX64,
+ .ffi_closure_LINUX64): Use FFI_HIDDEN instead of .hidden.
+ * src/x86/ffi.c (ffi_closure_SYSV, ffi_closure_raw_SYSV): Remove,
+ add FFI_HIDDEN to its prototype.
+ (ffi_closure_SYSV_inner): New.
+ * src/x86/sysv.S (ffi_closure_SYSV, ffi_closure_raw_SYSV): New.
+ * src/x86/win32.S (ffi_closure_SYSV, ffi_closure_raw_SYSV): New.
+
+2005-08-10 Alfred M. Szmidt <ams@gnu.org>
+
+ PR libffi/21819:
+ * configure: Rebuilt.
+ * configure.ac: Handle i*86-*-gnu*.
+
+2005-08-09 Jakub Jelinek <jakub@redhat.com>
+
+ * src/powerpc/ppc_closure.S (ffi_closure_SYSV): Use
+ DW_CFA_offset_extended_sf rather than
+ DW_CFA_GNU_negative_offset_extended.
+ * src/powerpc/sysv.S (ffi_call_SYSV): Likewise.
+
+2005-07-22 SUGIOKA Toshinobu <sugioka@itonet.co.jp>
+
+ * src/sh/sysv.S (ffi_call_SYSV): Stop argument popping correctly
+ on sh3.
+ (ffi_closure_SYSV): Change the stack layout for sh3 struct argument.
+ * src/sh/ffi.c (ffi_prep_args): Fix sh3 argument copy, when it is
+ partially on register.
+ (ffi_closure_helper_SYSV): Likewise.
+ (ffi_prep_cif_machdep): Don't set too many cif->flags.
+
+2005-07-20 Kaz Kojima <kkojima@gcc.gnu.org>
+
+ * src/sh/ffi.c (ffi_call): Handle small structures correctly.
+ Remove empty line.
+ * src/sh64/ffi.c (simple_type): Remove.
+ (return_type): Handle small structures correctly.
+ (ffi_prep_args): Likewise.
+ (ffi_call): Likewise.
+ (ffi_closure_helper_SYSV): Likewise.
+ * src/sh64/sysv.S (ffi_call_SYSV): Handle 1, 2 and 4-byte return.
+ Emit position independent code if PIC and remove wrong datalabel
+ prefixes from EH data.
+
+2005-07-19 Andreas Tobler <a.tobler@schweiz.ch>
+
+ * Makefile.am (nodist_libffi_la_SOURCES): Add POWERPC_FREEBSD.
+ * Makefile.in: Regenerate.
+ * include/Makefile.in: Likewise.
+ * testsuite/Makefile.in: Likewise.
+ * configure.ac: Add POWERPC_FREEBSD rules.
+ * configure: Regenerate.
+ * src/powerpc/ffitarget.h: Add POWERPC_FREEBSD rules.
+ (FFI_SYSV_TYPE_SMALL_STRUCT): Define.
+ * src/powerpc/ffi.c: Add flags to handle small structure returns
+ in ffi_call_SYSV.
+ (ffi_prep_cif_machdep): Handle small structures for SYSV 4 ABI.
+ Aka FFI_SYSV.
+ (ffi_closure_helper_SYSV): Likewise.
+ * src/powerpc/ppc_closure.S: Add return types for small structures.
+ * src/powerpc/sysv.S: Add bits to handle small structures for
+ final SYSV 4 ABI.
+
+2005-07-10 Andreas Tobler <a.tobler@schweiz.ch>
+
+ * testsuite/libffi.call/cls_5_1_byte.c: New test file.
+ * testsuite/libffi.call/cls_6_1_byte.c: Likewise.
+ * testsuite/libffi.call/cls_7_1_byte.c: Likewise.
+
+2005-07-05 Randolph Chung <tausq@debian.org>
+
+ * src/pa/ffi.c (ffi_struct_type): Rename FFI_TYPE_SMALL_STRUCT1
+ as FFI_TYPE_SMALL_STRUCT3. Break out handling for 5-7 byte
+ structures. Kill compilation warnings.
+ (ffi_closure_inner_LINUX): Print return values as hex in debug
+ message. Rename FFI_TYPE_SMALL_STRUCT1 as FFI_TYPE_SMALL_STRUCT3.
+ Properly handle 5-7 byte structure returns.
+ * src/pa/ffitarget.h (FFI_TYPE_SMALL_STRUCT1)
+ (FFI_TYPE_SMALL_STRUCT2): Remove.
+ (FFI_TYPE_SMALL_STRUCT3, FFI_TYPE_SMALL_STRUCT5)
+ (FFI_TYPE_SMALL_STRUCT6, FFI_TYPE_SMALL_STRUCT7): Define.
+ * src/pa/linux.S: Mark source file as using PA1.1 assembly.
+ (checksmst1, checksmst2): Remove.
+ (checksmst3): Optimize handling of 3-byte struct returns.
+ (checksmst567): Properly handle 5-7 byte struct returns.
+
+2005-06-15 Rainer Orth <ro@TechFak.Uni-Bielefeld.DE>
+
+ PR libgcj/21943
+ * src/mips/n32.S: Enforce PIC code.
+ * src/mips/o32.S: Likewise.
+
+2005-06-15 Rainer Orth <ro@TechFak.Uni-Bielefeld.DE>
+
+ * configure.ac: Treat i*86-*-solaris2.10 and up as X86_64.
+ * configure: Regenerate.
+
+2005-06-01 Alan Modra <amodra@bigpond.net.au>
+
+ * src/powerpc/ppc_closure.S (ffi_closure_SYSV): Don't use JUMPTARGET
+ to call ffi_closure_helper_SYSV. Append @local instead.
+ * src/powerpc/sysv.S (ffi_call_SYSV): Likewise for ffi_prep_args_SYSV.
+
+2005-05-17 Kelley Cook <kcook@gcc.gnu.org>
+
+ * configure.ac: Use AC_C_BIGENDIAN instead of AC_C_BIGENDIAN_CROSS.
+ Use AC_CHECK_SIZEOF instead of AC_COMPILE_CHECK_SIZEOF.
+ * Makefile.am (ACLOCAL_AMFLAGS): Remove -I ../config.
+ * aclocal.m4, configure, fficonfig.h.in, Makefile.in,
+ include/Makefile.in, testsuite/Makefile.in: Regenerate.
+
+2005-05-09 Mike Stump <mrs@apple.com>
+
+ * configure: Regenerate.
+
+2005-05-08 Richard Henderson <rth@redhat.com>
+
+ PR libffi/21285
+ * src/alpha/osf.S: Update unwind into to match code.
+
+2005-05-04 Andreas Degert <ad@papyrus-gmbh.de>
+ Richard Henderson <rth@redhat.com>
+
+ * src/x86/ffi64.c (ffi_prep_cif_machdep): Save sse-used flag in
+ bit 11 of flags.
+ (ffi_call): Mask return type field. Pass ssecount to ffi_call_unix64.
+ (ffi_prep_closure): Set carry bit if sse-used flag set.
+ * src/x86/unix64.S (ffi_call_unix64): Add ssecount argument.
+ Only load sse registers if ssecount non-zero.
+ (ffi_closure_unix64): Only save sse registers if carry set on entry.
+
+2005-04-29 Ralf Corsepius <ralf.corsepius@rtems.org>
+
+ * configure.ac: Add i*86-*-rtems*, sparc*-*-rtems*,
+ powerpc-*rtems*, arm*-*-rtems*, sh-*-rtems*.
+ * configure: Regenerate.
+
+2005-04-20 Hans-Peter Nilsson <hp@axis.com>
+
+ * testsuite/lib/libffi-dg.exp (libffi-dg-test-1): In regsub use,
+ have Tcl8.3-compatible intermediate variable.
+
+2005-04-18 Simon Posnjak <simon.posnjak@siol.net>
+ Hans-Peter Nilsson <hp@axis.com>
+
+ * Makefile.am: Add CRIS support.
+ * configure.ac: Likewise.
+ * Makefile.in, configure, testsuite/Makefile.in,
+ include/Makefile.in: Regenerate.
+ * src/cris: New directory.
+ * src/cris/ffi.c, src/cris/sysv.S, src/cris/ffitarget.h: New files.
+ * src/prep_cif.c (ffi_prep_cif): Wrap in #ifndef __CRIS__.
+
+ * testsuite/lib/libffi-dg.exp (libffi-dg-test-1): Replace \n with
+ \r?\n in output tests.
+
+2005-04-12 Mike Stump <mrs@apple.com>
+
+ * configure: Regenerate.
+
+2005-03-30 Hans Boehm <Hans.Boehm@hp.com>
+
+ * src/ia64/ffitarget.h (ffi_arg): Use long long instead of DI.
+
+2005-03-30 Steve Ellcey <sje@cup.hp.com>
+
+ * src/ia64/ffitarget.h (ffi_arg) ADD DI attribute.
+ (ffi_sarg) Ditto.
+ * src/ia64/unix.S (ffi_closure_unix): Extend gp
+ to 64 bits in ILP32 mode.
+ Load 64 bits even for short data.
+
+2005-03-23 Mike Stump <mrs@apple.com>
+
+ * src/powerpc/darwin.S: Update for -m64 multilib.
+ * src/powerpc/darwin_closure.S: Likewise.
+
+2005-03-21 Zack Weinberg <zack@codesourcery.com>
+
+ * configure.ac: Do not invoke TL_AC_GCC_VERSION.
+ Do not set tool_include_dir.
+ * aclocal.m4, configure, Makefile.in, testsuite/Makefile.in:
+ Regenerate.
+ * include/Makefile.am: Set gcc_version and toollibffidir.
+ * include/Makefile.in: Regenerate.
+
+2005-02-22 Andrew Haley <aph@redhat.com>
+
+ * src/powerpc/ffi.c (ffi_prep_cif_machdep): Bump alignment to
+ odd-numbered register pairs for 64-bit integer types.
+
+2005-02-23 Andreas Tobler <a.tobler@schweiz.ch>
+
+ PR libffi/20104
+ * testsuite/libffi.call/return_ll1.c: New test case.
+
+2005-02-11 Janis Johnson <janis187@us.ibm.com>
+
+ * testsuite/libffi.call/cls_align_longdouble.c: Remove dg-options.
+ * testsuite/libffi.call/float.c: Ditto.
+ * testsuite/libffi.call/float2.c: Ditto.
+ * testsuite/libffi.call/float3.c: Ditto.
+
+2005-02-08 Andreas Tobler <a.tobler@schweiz.ch>
+
+ * src/frv/ffitarget.h: Remove PPC stuff which does not belong to frv.
+
+2005-01-12 Eric Botcazou <ebotcazou@libertysurf.fr>
+
+ * testsuite/libffi.special/special.exp (cxx_options): Add
+ -shared-libgcc.
+
+2004-12-31 Richard Henderson <rth@redhat.com>
+
+ * src/types.c (FFI_AGGREGATE_TYPEDEF): Remove.
+ (FFI_TYPEDEF): Rename from FFI_INTEGRAL_TYPEDEF. Replace size and
+ offset parameters with a type parameter; deduce size and structure
+ alignment. Update all users.
+
+2004-12-31 Richard Henderson <rth@redhat.com>
+
+ * src/types.c (FFI_TYPE_POINTER): Define with sizeof.
+ (FFI_TYPE_LONGDOUBLE): Fix for ia64.
+ * src/ia64/ffitarget.h (struct ffi_ia64_trampoline_struct): Move
+ into ffi_prep_closure.
+ * src/ia64/ia64_flags.h, src/ia64/ffi.c, src/ia64/unix.S: Rewrite
+ from scratch.
+
+2004-12-27 Richard Henderson <rth@redhat.com>
+
+ * src/x86/unix64.S: Fix typo in unwind info.
+
+2004-12-25 Richard Henderson <rth@redhat.com>
+
+ * src/x86/ffi64.c (struct register_args): Rename from stackLayout.
+ (enum x86_64_reg_class): Add X86_64_COMPLEX_X87_CLASS.
+ (merge_classes): Check for it.
+ (SSE_CLASS_P): New.
+ (classify_argument): Pass byte_offset by value; perform all updates
+ inside struct case.
+ (examine_argument): Add classes argument; handle
+ X86_64_COMPLEX_X87_CLASS.
+ (ffi_prep_args): Merge into ...
+ (ffi_call): ... here. Share stack frame with ffi_call_unix64.
+ (ffi_prep_cif_machdep): Setup cif->flags for proper structure return.
+ (ffi_fill_return_value): Remove.
+ (ffi_prep_closure): Remove dead assert.
+ (ffi_closure_unix64_inner): Rename from ffi_closure_UNIX64_inner.
+ Rewrite to use struct register_args instead of va_list. Create
+ flags for handling structure returns.
+ * src/x86/unix64.S: Remove dead strings.
+ (ffi_call_unix64): Rename from ffi_call_UNIX64. Rewrite to share
+ stack frame with ffi_call. Handle structure returns properly.
+ (float2sse, floatfloat2sse, double2sse): Remove.
+ (sse2float, sse2double, sse2floatfloat): Remove.
+ (ffi_closure_unix64): Rename from ffi_closure_UNIX64. Rewrite
+ to handle structure returns properly.
+
+2004-12-08 David Edelsohn <edelsohn@gnu.org>
+
+ * Makefile.am (AM_MAKEFLAGS): Remove duplicate LIBCFLAGS and
+ PICFLAG.
+ * Makefile.in: Regenerated.
+
+2004-12-02 Richard Sandiford <rsandifo@redhat.com>
+
+ * configure.ac: Use TL_AC_GCC_VERSION to set gcc_version.
+ * configure, aclocal.m4, Makefile.in: Regenerate.
+ * include/Makefile.in, testsuite/Makefile.in: Regenerate.
+
+2004-11-29 Kelley Cook <kcook@gcc.gnu.org>
+
+ * configure: Regenerate for libtool change.
+
+2004-11-25 Kelley Cook <kcook@gcc.gnu.org>
+
+ * configure: Regenerate for libtool reversion.
+
+2004-11-24 Kelley Cook <kcook@gcc.gnu.org>
+
+ * configure: Regenerate for libtool change.
+
+2004-11-23 John David Anglin <dave.anglin@nrc-cnrc.gc.ca>
+
+ * testsuite/lib/libffi-dg.exp: Use new procs in target-libpath.exp.
+
+2004-11-23 Richard Sandiford <rsandifo@redhat.com>
+
+ * src/mips/o32.S (ffi_call_O32, ffi_closure_O32): Use jalr instead
+ of jal. Use an absolute encoding for the frame information.
+
+2004-11-23 Kelley Cook <kcook@gcc.gnu.org>
+
+ * Makefile.am: Remove no-dependencies. Add ACLOCAL_AMFLAGS.
+ * acinclude.m4: Delete logic for sincludes.
+ * aclocal.m4, Makefile.in, configure: Regenerate.
+ * include/Makefile: Likewise.
+ * testsuite/Makefile: Likewise.
+
+2004-11-22 Eric Botcazou <ebotcazou@libertysurf.fr>
+
+ * src/sparc/ffi.c (ffi_prep_closure): Align doubles and 64-bit integers
+ on a 8-byte boundary.
+ * src/sparc/v8.S (ffi_closure_v8): Reserve frame space for arguments.
+
+2004-10-27 Richard Earnshaw <rearnsha@arm.com>
+
+ * src/arm/ffi.c (ffi_prep_cif_machdep): Handle functions that return
+ long long values. Round stack allocation to a multiple of 8 bytes
+ for ATPCS compatibility.
+ * src/arm/sysv.S (ffi_call_SYSV): Rework to avoid use of APCS register
+ names. Handle returning long long types. Add Thumb and interworking
+ support. Improve soft-float code.
+
+2004-10-27 Richard Earnshaw <rearnsha@arm.com>
+
+ * testsuite/lib/libffi-db.exp (load_gcc_lib): New function.
+ (libffi_exit): New function.
+ (libffi_init): Build the testglue wrapper if needed.
+
+2004-10-25 Eric Botcazou <ebotcazou@libertysurf.fr>
+
+ PR other/18138
+ * testsuite/lib/libffi-dg.exp: Accept more than one multilib libgcc.
+
+2004-10-25 Kazuhiro Inaoka <inaoka.kazuhiro@renesas.com>
+
+ * src/m32r/libffitarget.h (FFI_CLOSURES): Set to 0.
+
+2004-10-20 Kaz Kojima <kkojima@gcc.gnu.org>
+
+ * src/sh/sysv.S (ffi_call_SYSV): Don't align for double data.
+ * testsuite/libffi.call/float3.c: New test case.
+
+2004-10-18 Kaz Kojima <kkojima@gcc.gnu.org>
+
+ * src/sh/ffi.c (ffi_prep_closure): Set T bit in trampoline for
+ the function returning a structure pointed with R2.
+ * src/sh/sysv.S (ffi_closure_SYSV): Use R2 as the pointer to
+ the structure return value if T bit set. Emit position
+ independent code and EH data if PIC.
+
+2004-10-13 Kazuhiro Inaoka <inaoka.kazuhiro@renesas.com>
+
+ * Makefile.am: Add m32r support.
+ * configure.ac: Likewise.
+ * Makefile.in: Regenerate.
+ * confiugre: Regenerate.
+ * src/types.c: Add m32r port to FFI_INTERNAL_TYPEDEF
+ (uint64, sint64, double, longdouble)
+ * src/m32r: New directory.
+ * src/m32r/ffi.c: New file.
+ * src/m32r/sysv.S: Likewise.
+ * src/m32r/ffitarget.h: Likewise.
+
+2004-10-02 Kaz Kojima <kkojima@gcc.gnu.org>
+
+ * testsuite/libffi.call/negint.c: New test case.
+
+2004-09-14 H.J. Lu <hongjiu.lu@intel.com>
+
+ PR libgcj/17465
+ * testsuite/lib/libffi-dg.exp: Don't use global ld_library_path.
+ Set up LD_LIBRARY_PATH, SHLIB_PATH, LD_LIBRARYN32_PATH,
+ LD_LIBRARY64_PATH, LD_LIBRARY_PATH_32, LD_LIBRARY_PATH_64 and
+ DYLD_LIBRARY_PATH.
+
+2004-09-05 Andreas Tobler <a.tobler@schweiz.ch>
+
+ * testsuite/libffi.call/many_win32.c: Remove whitespaces.
+ * testsuite/libffi.call/promotion.c: Likewise.
+ * testsuite/libffi.call/return_ll.c: Remove unused var. Cleanup
+ whitespaces.
+ * testsuite/libffi.call/return_sc.c: Likewise.
+ * testsuite/libffi.call/return_uc.c: Likewise.
+
+2004-09-05 Andreas Tobler <a.tobler@schweiz.ch>
+
+ * src/powerpc/darwin.S: Fix comments and identation.
+ * src/powerpc/darwin_closure.S: Likewise.
+
+2004-09-02 Andreas Tobler <a.tobler@schweiz.ch>
+
+ * src/powerpc/ffi_darwin.c: Add flag for longdouble return values.
+ (ffi_prep_args): Handle longdouble arguments.
+ (ffi_prep_cif_machdep): Set flags for longdouble. Calculate space for
+ longdouble.
+ (ffi_closure_helper_DARWIN): Add closure handling for longdouble.
+ * src/powerpc/darwin.S (_ffi_call_DARWIN): Add handling of longdouble
+ values.
+ * src/powerpc/darwin_closure.S (_ffi_closure_ASM): Likewise.
+ * src/types.c: Defined longdouble size and alignment for darwin.
+
+2004-09-02 Andreas Tobler <a.tobler@schweiz.ch>
+
+ * src/powerpc/aix.S: Remove whitespaces.
+ * src/powerpc/aix_closure.S: Likewise.
+ * src/powerpc/asm.h: Likewise.
+ * src/powerpc/ffi.c: Likewise.
+ * src/powerpc/ffitarget.h: Likewise.
+ * src/powerpc/linux64.S: Likewise.
+ * src/powerpc/linux64_closure.S: Likewise.
+ * src/powerpc/ppc_closure.S: Likewise.
+ * src/powerpc/sysv.S: Likewise.
+
+2004-08-30 Anthony Green <green@redhat.com>
+
+ * Makefile.am: Add frv support.
+ * Makefile.in, testsuite/Makefile.in: Rebuilt.
+ * configure.ac: Read configure.host.
+ * configure.in: Read configure.host.
+ * configure.host: New file. frv-elf needs libgloss.
+ * include/ffi.h.in: Force ffi_closure to have a nice big (8)
+ alignment. This is needed to frv and shouldn't harm the others.
+ * include/ffi_common.h (ALIGN_DOWN): New macro.
+ * src/frv/ffi.c, src/frv/ffitarget.h, src/frv/eabi.S: New files.
+
+2004-08-24 David Daney <daney@avtrex.com>
+
+ * testsuite/libffi.call/closure_fn0.c: Xfail mips64* instead of mips*.
+ * testsuite/libffi.call/closure_fn1.c: Likewise.
+ * testsuite/libffi.call/closure_fn2.c Likewise.
+ * testsuite/libffi.call/closure_fn3.c: Likewise.
+ * testsuite/libffi.call/closure_fn4.c: Likewise.
+ * testsuite/libffi.call/closure_fn5.c: Likewise.
+ * testsuite/libffi.call/cls_18byte.c: Likewise.
+ * testsuite/libffi.call/cls_19byte.c: Likewise.
+ * testsuite/libffi.call/cls_1_1byte.c: Likewise.
+ * testsuite/libffi.call/cls_20byte.c: Likewise.
+ * testsuite/libffi.call/cls_20byte1.c: Likewise.
+ * testsuite/libffi.call/cls_24byte.c: Likewise.
+ * testsuite/libffi.call/cls_2byte.c: Likewise.
+ * testsuite/libffi.call/cls_3_1byte.c: Likewise.
+ * testsuite/libffi.call/cls_3byte1.c: Likewise.
+ * testsuite/libffi.call/cls_3byte2.c: Likewise.
+ * testsuite/libffi.call/cls_4_1byte.c: Likewise.
+ * testsuite/libffi.call/cls_4byte.c: Likewise.
+ * testsuite/libffi.call/cls_64byte.c: Likewise.
+ * testsuite/libffi.call/cls_6byte.c: Likewise.
+ * testsuite/libffi.call/cls_7byte.c: Likewise.
+ * testsuite/libffi.call/cls_8byte.c: Likewise.
+ * testsuite/libffi.call/cls_9byte1.c: Likewise.
+ * testsuite/libffi.call/cls_9byte2.c: Likewise.
+ * testsuite/libffi.call/cls_align_double.c: Likewise.
+ * testsuite/libffi.call/cls_align_float.c: Likewise.
+ * testsuite/libffi.call/cls_align_longdouble.c: Likewise.
+ * testsuite/libffi.call/cls_align_pointer.c: Likewise.
+ * testsuite/libffi.call/cls_align_sint16.c: Likewise.
+ * testsuite/libffi.call/cls_align_sint32.c: Likewise.
+ * testsuite/libffi.call/cls_align_sint64.c: Likewise.
+ * testsuite/libffi.call/cls_align_uint16.c: Likewise.
+ * testsuite/libffi.call/cls_align_uint32.c: Likewise.
+ * testsuite/libffi.call/cls_align_uint64.c: Likewise.
+ * testsuite/libffi.call/cls_double.c: Likewise.
+ * testsuite/libffi.call/cls_float.c: Likewise.
+ * testsuite/libffi.call/cls_multi_schar.c: Likewise.
+ * testsuite/libffi.call/cls_multi_sshort.c: Likewise.
+ * testsuite/libffi.call/cls_multi_sshortchar.c: Likewise.
+ * testsuite/libffi.call/cls_multi_uchar.c: Likewise.
+ * testsuite/libffi.call/cls_multi_ushort.c: Likewise.
+ * testsuite/libffi.call/cls_multi_ushortchar.c: Likewise.
+ * testsuite/libffi.call/cls_schar.c: Likewise.
+ * testsuite/libffi.call/cls_sint.c: Likewise.
+ * testsuite/libffi.call/cls_sshort.c: Likewise.
+ * testsuite/libffi.call/cls_uchar.c: Likewise.
+ * testsuite/libffi.call/cls_uint.c: Likewise.
+ * testsuite/libffi.call/cls_ulonglong.c: Likewise.
+ * testsuite/libffi.call/cls_ushort.c: Likewise.
+ * testsuite/libffi.call/nested_struct.c: Likewise.
+ * testsuite/libffi.call/nested_struct1.c: Likewise.
+ * testsuite/libffi.call/nested_struct2.c: Likewise.
+ * testsuite/libffi.call/nested_struct3.c: Likewise.
+ * testsuite/libffi.call/problem1.c: Likewise.
+ * testsuite/libffi.special/unwindtest.cc: Likewise.
+ * testsuite/libffi.call/cls_12byte.c: Likewise and set return value
+ to zero.
+ * testsuite/libffi.call/cls_16byte.c: Likewise.
+ * testsuite/libffi.call/cls_5byte.c: Likewise.
+
+2004-08-23 David Daney <daney@avtrex.com>
+
+ PR libgcj/13141
+ * src/mips/ffitarget.h (FFI_O32_SOFT_FLOAT): New ABI.
+ * src/mips/ffi.c (ffi_prep_args): Fix alignment calculation.
+ (ffi_prep_cif_machdep): Handle FFI_O32_SOFT_FLOAT floating point
+ parameters and return types.
+ (ffi_call): Handle FFI_O32_SOFT_FLOAT ABI.
+ (ffi_prep_closure): Ditto.
+ (ffi_closure_mips_inner_O32): Handle FFI_O32_SOFT_FLOAT ABI, fix
+ alignment calculations.
+ * src/mips/o32.S (ffi_closure_O32): Don't use floating point
+ instructions if FFI_O32_SOFT_FLOAT, make stack frame ABI compliant.
+
+2004-08-14 Casey Marshall <csm@gnu.org>
+
+ * src/mips/ffi.c (ffi_pref_cif_machdep): set `cif->flags' to
+ contain `FFI_TYPE_UINT64' as return type for any 64-bit
+ integer (O32 ABI only).
+ (ffi_prep_closure): new function.
+ (ffi_closure_mips_inner_O32): new function.
+ * src/mips/ffitarget.h: Define `FFI_CLOSURES' and
+ `FFI_TRAMPOLINE_SIZE' appropriately if the ABI is o32.
+ * src/mips/o32.S (ffi_call_O32): add labels for .eh_frame. Return
+ 64 bit integers correctly.
+ (ffi_closure_O32): new function.
+ Added DWARF-2 unwind info for both functions.
+
+2004-08-10 Andrew Haley <aph@redhat.com>
+
+ * src/x86/ffi64.c (ffi_prep_args ): 8-align all stack arguments.
+
+2004-08-01 Robert Millan <robertmh@gnu.org>
+
+ * configure.ac: Detect knetbsd-gnu and kfreebsd-gnu.
+ * configure: Regenerate.
+
+2004-07-30 Maciej W. Rozycki <macro@linux-mips.org>
+
+ * acinclude.m4 (AC_FUNC_MMAP_BLACKLIST): Check for <sys/mman.h>
+ and mmap() explicitly instead of relying on preset autoconf cache
+ variables.
+ * aclocal.m4: Regenerate.
+ * configure: Regenerate.
+
+2004-07-11 Ulrich Weigand <uweigand@de.ibm.com>
+
+ * src/s390/ffi.c (ffi_prep_args): Fix C aliasing violation.
+ (ffi_check_float_struct): Remove unused prototype.
+
+2004-06-30 Geoffrey Keating <geoffk@apple.com>
+
+ * src/powerpc/ffi_darwin.c (flush_icache): ';' is a comment
+ character on Darwin, use '\n\t' instead.
+
+2004-06-26 Matthias Klose <doko@debian.org>
+
+ * libtool-version: Fix typo in revision/age.
+
+2004-06-17 Matthias Klose <doko@debian.org>
+
+ * libtool-version: New.
+ * Makefile.am (libffi_la_LDFLAGS): Use -version-info for soname.
+ * Makefile.in: Regenerate.
+
+2004-06-15 Paolo Bonzini <bonzini@gnu.org>
+
+ * Makefile.am: Remove useless multilib rules.
+ * Makefile.in: Regenerate.
+ * aclocal.m4: Regenerate with automake 1.8.5.
+ * configure.ac: Remove useless multilib configury.
+ * configure: Regenerate.
+
+2004-06-15 Paolo Bonzini <bonzini@gnu.org>
+
+ * .cvsignore: New file.
+
+2004-06-10 Jakub Jelinek <jakub@redhat.com>
+
+ * src/ia64/unix.S (ffi_call_unix): Insert group barrier break
+ fp_done.
+ (ffi_closure_UNIX): Fix f14/f15 adjustment if FLOAT_SZ is ever
+ changed from 8.
+
+2004-06-06 Sean McNeil <sean@mcneil.com>
+
+ * configure.ac: Add x86_64-*-freebsd* support.
+ * configure: Regenerate.
+
+2004-04-26 Joe Buck <jbuck@welsh-buck.org>
+
+ Bug 15093
+ * configure.ac: Test for existence of mmap and sys/mman.h before
+ checking blacklist. Fix suggested by Jim Wilson.
+ * configure: Regenerate.
+
+2004-04-26 Matt Austern <austern@apple.com>
+
+ * src/powerpc/darwin.S: Go through a non-lazy pointer for initial
+ FDE location.
+ * src/powerpc/darwin_closure.S: Likewise.
+
+2004-04-24 Andreas Tobler <a.tobler@schweiz.ch>
+
+ * testsuite/libffi.call/cls_multi_schar.c (main): Fix initialization
+ error. Reported by Thomas Heller <theller@python.net>.
+ * testsuite/libffi.call/cls_multi_sshort.c (main): Likewise.
+ * testsuite/libffi.call/cls_multi_ushort.c (main): Likewise.
+
+2004-03-20 Matthias Klose <doko@debian.org>
+
+ * src/pa/linux.S: Fix typo.
+
+2004-03-19 Matthias Klose <doko@debian.org>
+
+ * Makefile.am: Update.
+ * Makefile.in: Regenerate.
+ * src/pa/ffi.h.in: Remove.
+ * src/pa/ffitarget.h: New file.
+
+2004-02-10 Randolph Chung <tausq@debian.org>
+
+ * Makefile.am: Add PA support.
+ * Makefile.in: Regenerate.
+ * include/Makefile.in: Regenerate.
+ * configure.ac: Add PA target.
+ * configure: Regenerate.
+ * src/pa/ffi.c: New file.
+ * src/pa/ffi.h.in: Add PA support.
+ * src/pa/linux.S: New file.
+ * prep_cif.c: Add PA support.
+
+2004-03-16 Hosaka Yuji <hos@tamanegi.org>
+
+ * src/types.c: Fix alignment size of X86_WIN32 case int64 and
+ double.
+ * src/x86/ffi.c (ffi_prep_args): Replace ecif->cif->rtype->type
+ with ecif->cif->flags.
+ (ffi_call, ffi_prep_incoming_args_SYSV): Replace cif->rtype->type
+ with cif->flags.
+ (ffi_prep_cif_machdep): Add X86_WIN32 struct case.
+ (ffi_closure_SYSV): Add 1 or 2-bytes struct case for X86_WIN32.
+ * src/x86/win32.S (retstruct1b, retstruct2b, sc_retstruct1b,
+ sc_retstruct2b): Add for 1 or 2-bytes struct case.
+
+2004-03-15 Kelley Cook <kcook@gcc.gnu.org>
+
+ * configure.in: Rename file to ...
+ * configure.ac: ... this.
+ * fficonfig.h.in: Regenerate.
+ * Makefile.in: Regenerate.
+ * include/Makefile.in: Regenerate.
+ * testsuite/Makefile.in: Regenerate.
+
+2004-03-12 Matt Austern <austern@apple.com>
+
+ * src/powerpc/darwin.S: Fix EH information so it corresponds to
+ changes in EH format resulting from addition of linkonce support.
+ * src/powerpc/darwin_closure.S: Likewise.
+
+2004-03-11 Andreas Tobler <a.tobler@schweiz.ch>
+ Paolo Bonzini <bonzini@gnu.org>
+
+ * Makefile.am (AUTOMAKE_OPTIONS): Set them.
+ Remove VPATH. Remove rules for object files. Remove multilib support.
+ (AM_CCASFLAGS): Add.
+ * configure.in (AC_CONFIG_HEADERS): Relace AM_CONFIG_HEADER.
+ (AC_PREREQ): Bump version to 2.59.
+ (AC_INIT): Fill with version info and bug address.
+ (ORIGINAL_LD_FOR_MULTILIBS): Remove.
+ (AM_ENABLE_MULTILIB): Use this instead of AC_ARG_ENABLE.
+ De-precious CC so that the right flags are passed down to multilibs.
+ (AC_MSG_ERROR): Replace obsolete macro AC_ERROR.
+ (AC_CONFIG_FILES): Replace obsolete macro AC_LINK_FILES.
+ (AC_OUTPUT): Reorganize the output with AC_CONFIG_COMMANDS.
+ * configure: Rebuilt.
+ * aclocal.m4: Likewise.
+ * Makefile.in, include/Makefile.in, testsuite/Makefile.in: Likewise.
+ * fficonfig.h.in: Likewise.
+
+2004-03-11 Andreas Schwab <schwab@suse.de>
+
+ * src/ia64/ffi.c (ffi_prep_incoming_args_UNIX): Get floating point
+ arguments from fp registers only for the first 8 parameter slots.
+ Don't convert a float parameter when passed in memory.
+
+2004-03-09 Hans-Peter Nilsson <hp@axis.com>
+
+ * configure: Regenerate for config/accross.m4 correction.
+
+2004-02-25 Matt Kraai <kraai@alumni.cmu.edu>
+
+ * src/powerpc/ffi.c (ffi_prep_args_SYSV): Change
+ ecif->cif->bytes to bytes.
+ (ffi_prep_cif_machdep): Add braces around nested if statement.
+
+2004-02-09 Alan Modra <amodra@bigpond.net.au>
+
+ * src/types.c (pointer): POWERPC64 has 8 byte pointers.
+
+ * src/powerpc/ffi.c (ffi_prep_args64): Correct long double handling.
+ (ffi_closure_helper_LINUX64): Fix typo.
+ * testsuite/libffi.call/cls_align_longdouble.c: Pass -mlong-double-128
+ for powerpc64-*-*.
+ * testsuite/libffi.call/float.c: Likewise.
+ * testsuite/libffi.call/float2.c: Likewise.
+
+2004-02-08 Alan Modra <amodra@bigpond.net.au>
+
+ * src/powerpc/ffi.c (ffi_prep_cif_machdep <FFI_LINUX64>): Correct
+ long double function return and long double arg handling.
+ (ffi_closure_helper_LINUX64): Formatting. Delete unused "ng" var.
+ Use "end_pfr" instead of "nf". Correct long double handling.
+ Localise "temp".
+ * src/powerpc/linux64.S (ffi_call_LINUX64): Save f2 long double
+ return value.
+ * src/powerpc/linux64_closure.S (ffi_closure_LINUX64): Allocate
+ space for long double return value. Adjust stack frame and offsets.
+ Load f2 long double return.
+
+2004-02-07 Alan Modra <amodra@bigpond.net.au>
+
+ * src/types.c: Use 16 byte long double for POWERPC64.
+
+2004-01-25 Eric Botcazou <ebotcazou@libertysurf.fr>
+
+ * src/sparc/ffi.c (ffi_prep_args_v9): Shift the parameter array
+ when the structure return address is passed in %o0.
+ (ffi_V9_return_struct): Rename into ffi_v9_layout_struct.
+ (ffi_v9_layout_struct): Align the field following a nested structure
+ on a word boundary. Use memmove instead of memcpy.
+ (ffi_call): Update call to ffi_V9_return_struct.
+ (ffi_prep_closure): Define 'ctx' only for V8.
+ (ffi_closure_sparc_inner): Clone into ffi_closure_sparc_inner_v8
+ and ffi_closure_sparc_inner_v9.
+ (ffi_closure_sparc_inner_v8): Return long doubles by reference.
+ Always skip the structure return address. For structures and long
+ doubles, copy the argument directly.
+ (ffi_closure_sparc_inner_v9): Skip the structure return address only
+ if required. Shift the maximum floating-point slot accordingly. For
+ big structures, copy the argument directly; otherwise, left-justify the
+ argument and call ffi_v9_layout_struct to lay out the structure on
+ the stack.
+ * src/sparc/v8.S: Undef STACKFRAME before defining it.
+ (ffi_closure_v8): Pass the structure return address. Update call to
+ ffi_closure_sparc_inner_v8. Short-circuit FFI_TYPE_INT handling.
+ Skip the 'unimp' insn when returning long doubles and structures.
+ * src/sparc/v9.S: Undef STACKFRAME before defining it.
+ (ffi_closure_v9): Increase the frame size by 2 words. Short-circuit
+ FFI_TYPE_INT handling. Load structures both in integers and
+ floating-point registers on return.
+ * README: Update status of the SPARC port.
+
+2004-01-24 Andreas Tobler <a.tobler@schweiz.ch>
+
+ * testsuite/libffi.call/pyobjc-tc.c (main): Treat result value
+ as of type ffi_arg.
+ * testsuite/libffi.call/struct3.c (main): Fix CHECK.
+
+2004-01-22 Ulrich Weigand <uweigand@de.ibm.com>
+
+ * testsuite/libffi.call/cls_uint.c (cls_ret_uint_fn): Treat result
+ value as of type ffi_arg, not unsigned int.
+
+2004-01-21 Michael Ritzert <ritzert@t-online.de>
+
+ * ffi64.c (ffi_prep_args): Cast the RHS of an assignment instead
+ of the LHS.
+
+2004-01-12 Andreas Tobler <a.tobler@schweiz.ch>
+
+ * testsuite/lib/libffi-dg.exp: Set LD_LIBRARY_PATH_32 for
+ Solaris.
+
+2004-01-08 Rainer Orth <ro@TechFak.Uni-Bielefeld.DE>
+
+ * testsuite/libffi.call/ffitest.h (allocate_mmap): Cast MAP_FAILED
+ to void *.
+
+2003-12-10 Richard Henderson <rth@redhat.com>
+
+ * testsuite/libffi.call/cls_align_pointer.c: Cast pointers to
+ size_t instead of int.
+
+2003-12-04 Hosaka Yuji <hos@tamanegi.org>
+
+ * testsuite/libffi.call/many_win32.c: Include <float.h>.
+ * testsuite/libffi.call/many_win32.c (main): Replace variable
+ int i with unsigned long ul.
+
+ * testsuite/libffi.call/cls_align_uint64.c: New test case.
+ * testsuite/libffi.call/cls_align_sint64.c: Likewise.
+ * testsuite/libffi.call/cls_align_uint32.c: Likewise.
+ * testsuite/libffi.call/cls_align_sint32.c: Likewise.
+ * testsuite/libffi.call/cls_align_uint16.c: Likewise.
+ * testsuite/libffi.call/cls_align_sint16.c: Likewise.
+ * testsuite/libffi.call/cls_align_float.c: Likewise.
+ * testsuite/libffi.call/cls_align_double.c: Likewise.
+ * testsuite/libffi.call/cls_align_longdouble.c: Likewise.
+ * testsuite/libffi.call/cls_align_pointer.c: Likewise.
+
+2003-12-02 Hosaka Yuji <hos@tamanegi.org>
+
+ PR other/13221
+ * src/x86/ffi.c (ffi_prep_args, ffi_prep_incoming_args_SYSV):
+ Align arguments to 32 bits.
+
+2003-12-01 Andreas Tobler <a.tobler@schweiz.ch>
+
+ PR other/13221
+ * testsuite/libffi.call/cls_multi_sshort.c: New test case.
+ * testsuite/libffi.call/cls_multi_sshortchar.c: Likewise.
+ * testsuite/libffi.call/cls_multi_uchar.c: Likewise.
+ * testsuite/libffi.call/cls_multi_schar.c: Likewise.
+ * testsuite/libffi.call/cls_multi_ushortchar.c: Likewise.
+ * testsuite/libffi.call/cls_multi_ushort.c: Likewise.
+
+ * testsuite/libffi.special/unwindtest.cc: Cosmetics.
+
+2003-11-26 Kaveh R. Ghazi <ghazi@caip.rutgers.edu>
+
+ * testsuite/libffi.call/ffitest.h: Include <fcntl.h>.
+ * testsuite/libffi.special/ffitestcxx.h: Likewise.
+
+2003-11-22 Andreas Tobler <a.tobler@schweiz.ch>
+
+ * Makefile.in: Rebuilt.
+ * configure: Likewise.
+ * testsuite/libffi.special/unwindtest.cc: Convert the mmap to
+ the right type.
+
+2003-11-21 Andreas Jaeger <aj@suse.de>
+ Andreas Tobler <a.tobler@schweiz.ch>
+
+ * acinclude.m4: Add AC_FUNC_MMAP_BLACKLIST.
+ * configure.in: Call AC_FUNC_MMAP_BLACKLIST.
+ * Makefile.in: Rebuilt.
+ * aclocal.m4: Likewise.
+ * configure: Likewise.
+ * fficonfig.h.in: Likewise.
+ * testsuite/lib/libffi-dg.exp: Add include dir.
+ * testsuite/libffi.call/ffitest.h: Add MMAP definitions.
+ * testsuite/libffi.special/ffitestcxx.h: Likewise.
+ * testsuite/libffi.call/closure_fn0.c: Use MMAP functionality
+ for ffi_closure if available.
+ * testsuite/libffi.call/closure_fn1.c: Likewise.
+ * testsuite/libffi.call/closure_fn2.c: Likewise.
+ * testsuite/libffi.call/closure_fn3.c: Likewise.
+ * testsuite/libffi.call/closure_fn4.c: Likewise.
+ * testsuite/libffi.call/closure_fn5.c: Likewise.
+ * testsuite/libffi.call/cls_12byte.c: Likewise.
+ * testsuite/libffi.call/cls_16byte.c: Likewise.
+ * testsuite/libffi.call/cls_18byte.c: Likewise.
+ * testsuite/libffi.call/cls_19byte.c: Likewise.
+ * testsuite/libffi.call/cls_1_1byte.c: Likewise.
+ * testsuite/libffi.call/cls_20byte.c: Likewise.
+ * testsuite/libffi.call/cls_20byte1.c: Likewise.
+ * testsuite/libffi.call/cls_24byte.c: Likewise.
+ * testsuite/libffi.call/cls_2byte.c: Likewise.
+ * testsuite/libffi.call/cls_3_1byte.c: Likewise.
+ * testsuite/libffi.call/cls_3byte1.c: Likewise.
+ * testsuite/libffi.call/cls_3byte2.c: Likewise.
+ * testsuite/libffi.call/cls_4_1byte.c: Likewise.
+ * testsuite/libffi.call/cls_4byte.c: Likewise.
+ * testsuite/libffi.call/cls_5byte.c: Likewise.
+ * testsuite/libffi.call/cls_64byte.c: Likewise.
+ * testsuite/libffi.call/cls_6byte.c: Likewise.
+ * testsuite/libffi.call/cls_7byte.c: Likewise.
+ * testsuite/libffi.call/cls_8byte.c: Likewise.
+ * testsuite/libffi.call/cls_9byte1.c: Likewise.
+ * testsuite/libffi.call/cls_9byte2.c: Likewise.
+ * testsuite/libffi.call/cls_double.c: Likewise.
+ * testsuite/libffi.call/cls_float.c: Likewise.
+ * testsuite/libffi.call/cls_schar.c: Likewise.
+ * testsuite/libffi.call/cls_sint.c: Likewise.
+ * testsuite/libffi.call/cls_sshort.c: Likewise.
+ * testsuite/libffi.call/cls_uchar.c: Likewise.
+ * testsuite/libffi.call/cls_uint.c: Likewise.
+ * testsuite/libffi.call/cls_ulonglong.c: Likewise.
+ * testsuite/libffi.call/cls_ushort.c: Likewise.
+ * testsuite/libffi.call/nested_struct.c: Likewise.
+ * testsuite/libffi.call/nested_struct1.c: Likewise.
+ * testsuite/libffi.call/nested_struct2.c: Likewise.
+ * testsuite/libffi.call/nested_struct3.c: Likewise.
+ * testsuite/libffi.call/problem1.c: Likewise.
+ * testsuite/libffi.special/unwindtest.cc: Likewise.
+
+2003-11-20 Andreas Tobler <a.tobler@schweiz.ch>
+
+ * testsuite/lib/libffi-dg.exp: Make the -lgcc_s conditional.
+
+2003-11-19 Andreas Tobler <a.tobler@schweiz.ch>
+
+ * testsuite/lib/libffi-dg.exp: Add DYLD_LIBRARY_PATH for darwin.
+ Add -lgcc_s to additional flags.
+
+2003-11-12 Andreas Tobler <a.tobler@schweiz.ch>
+
+ * configure.in, include/Makefile.am: PR libgcj/11147, install
+ the ffitarget.h header file in a gcc versioned and target
+ dependent place.
+ * configure: Regenerated.
+ * Makefile.in, include/Makefile.in: Likewise.
+ * testsuite/Makefile.in: Likewise.
+
+2003-11-09 Andreas Tobler <a.tobler@schweiz.ch>
+
+ * testsuite/libffi.call/closure_fn0.c: Print result and check
+ with dg-output to make debugging easier.
+ * testsuite/libffi.call/closure_fn1.c: Likewise.
+ * testsuite/libffi.call/closure_fn2.c: Likewise.
+ * testsuite/libffi.call/closure_fn3.c: Likewise.
+ * testsuite/libffi.call/closure_fn4.c: Likewise.
+ * testsuite/libffi.call/closure_fn5.c: Likewise.
+ * testsuite/libffi.call/cls_12byte.c: Likewise.
+ * testsuite/libffi.call/cls_16byte.c: Likewise.
+ * testsuite/libffi.call/cls_18byte.c: Likewise.
+ * testsuite/libffi.call/cls_19byte.c: Likewise.
+ * testsuite/libffi.call/cls_1_1byte.c: Likewise.
+ * testsuite/libffi.call/cls_20byte.c: Likewise.
+ * testsuite/libffi.call/cls_20byte1.c: Likewise.
+ * testsuite/libffi.call/cls_24byte.c: Likewise.
+ * testsuite/libffi.call/cls_2byte.c: Likewise.
+ * testsuite/libffi.call/cls_3_1byte.c: Likewise.
+ * testsuite/libffi.call/cls_3byte1.c: Likewise.
+ * testsuite/libffi.call/cls_3byte2.c: Likewise.
+ * testsuite/libffi.call/cls_4_1byte.c: Likewise.
+ * testsuite/libffi.call/cls_4byte.c: Likewise.
+ * testsuite/libffi.call/cls_5byte.c: Likewise.
+ * testsuite/libffi.call/cls_64byte.c: Likewise.
+ * testsuite/libffi.call/cls_6byte.c: Likewise.
+ * testsuite/libffi.call/cls_7byte.c: Likewise.
+ * testsuite/libffi.call/cls_8byte.c: Likewise.
+ * testsuite/libffi.call/cls_9byte1.c: Likewise.
+ * testsuite/libffi.call/cls_9byte2.c: Likewise.
+ * testsuite/libffi.call/cls_double.c: Likewise.
+ * testsuite/libffi.call/cls_float.c: Likewise.
+ * testsuite/libffi.call/cls_schar.c: Likewise.
+ * testsuite/libffi.call/cls_sint.c: Likewise.
+ * testsuite/libffi.call/cls_sshort.c: Likewise.
+ * testsuite/libffi.call/cls_uchar.c: Likewise.
+ * testsuite/libffi.call/cls_uint.c: Likewise.
+ * testsuite/libffi.call/cls_ulonglong.c: Likewise.
+ * testsuite/libffi.call/cls_ushort.c: Likewise.
+ * testsuite/libffi.call/problem1.c: Likewise.
+
+ * testsuite/libffi.special/unwindtest.cc: Make ffi_closure
+ static.
+
+2003-11-08 Andreas Tobler <a.tobler@schweiz.ch>
+
+ * testsuite/libffi.call/cls_9byte2.c: New test case.
+ * testsuite/libffi.call/cls_9byte1.c: Likewise.
+ * testsuite/libffi.call/cls_64byte.c: Likewise.
+ * testsuite/libffi.call/cls_20byte1.c: Likewise.
+ * testsuite/libffi.call/cls_19byte.c: Likewise.
+ * testsuite/libffi.call/cls_18byte.c: Likewise.
+ * testsuite/libffi.call/closure_fn4.c: Likewise.
+ * testsuite/libffi.call/closure_fn5.c: Likewise.
+ * testsuite/libffi.call/cls_schar.c: Likewise.
+ * testsuite/libffi.call/cls_sint.c: Likewise.
+ * testsuite/libffi.call/cls_sshort.c: Likewise.
+ * testsuite/libffi.call/nested_struct2.c: Likewise.
+ * testsuite/libffi.call/nested_struct3.c: Likewise.
+
+2003-11-08 Andreas Tobler <a.tobler@schweiz.ch>
+
+ * testsuite/libffi.call/cls_double.c: Do a check on the result.
+ * testsuite/libffi.call/cls_uchar.c: Likewise.
+ * testsuite/libffi.call/cls_uint.c: Likewise.
+ * testsuite/libffi.call/cls_ulonglong.c: Likewise.
+ * testsuite/libffi.call/cls_ushort.c: Likewise.
+ * testsuite/libffi.call/return_sc.c: Cleanup whitespaces.
+
+2003-11-06 Andreas Tobler <a.tobler@schweiz.ch>
+
+ * src/prep_cif.c (ffi_prep_cif): Move the validity check after
+ the initialization.
+
+2003-10-23 Andreas Tobler <a.tobler@schweiz.ch>
+
+ * src/java_raw_api.c (ffi_java_ptrarray_to_raw): Replace
+ FFI_ASSERT(FALSE) with FFI_ASSERT(0).
+
+2003-10-22 David Daney <ddaney@avtrex.com>
+
+ * src/mips/ffitarget.h: Replace undefined UINT32 and friends with
+ __attribute__((__mode__(__SI__))) and friends.
+
+2003-10-22 Andreas Schwab <schwab@suse.de>
+
+ * src/ia64/ffi.c: Replace FALSE/TRUE with false/true.
+
+2003-10-21 Andreas Tobler <a.tobler@schweiz.ch>
+
+ * configure.in: AC_LINK_FILES(ffitarget.h).
+ * configure: Regenerate.
+ * Makefile.in: Likewise.
+ * include/Makefile.in: Likewise.
+ * testsuite/Makefile.in: Likewise.
+ * fficonfig.h.in: Likewise.
+
+2003-10-21 Paolo Bonzini <bonzini@gnu.org>
+ Richard Henderson <rth@redhat.com>
+
+ Avoid that ffi.h includes fficonfig.h.
+
+ * Makefile.am (EXTRA_DIST): Include ffitarget.h files
+ (TARGET_SRC_MIPS_GCC): Renamed to TARGET_SRC_MIPS_IRIX.
+ (TARGET_SRC_MIPS_SGI): Removed.
+ (MIPS_GCC): Renamed to TARGET_SRC_MIPS_IRIX.
+ (MIPS_SGI): Removed.
+ (CLEANFILES): Removed.
+ (mostlyclean-am, clean-am, mostlyclean-sub, clean-sub): New
+ targets.
+ * acconfig.h: Removed.
+ * configure.in: Compute sizeofs only for double and long double.
+ Use them to define and subst HAVE_LONG_DOUBLE. Include comments
+ into AC_DEFINE instead of using acconfig.h. Create
+ include/ffitarget.h instead of include/fficonfig.h. Rename
+ MIPS_GCC to MIPS_IRIX, drop MIPS_SGI since we are in gcc's tree.
+ AC_DEFINE EH_FRAME_FLAGS.
+ * include/Makefile.am (DISTCLEANFILES): New automake macro.
+ (hack_DATA): Add ffitarget.h.
+ * include/ffi.h.in: Remove all system specific definitions.
+ Declare raw API even if it is not installed, why bother?
+ Use limits.h instead of SIZEOF_* to define ffi_type_*. Do
+ not define EH_FRAME_FLAGS, it is in fficonfig.h now. Include
+ ffitarget.h instead of fficonfig.h. Remove ALIGN macro.
+ (UINT_ARG, INT_ARG): Removed, use ffi_arg and ffi_sarg instead.
+ * include/ffi_common.h (bool): Do not define.
+ (ffi_assert): Accept failed assertion.
+ (ffi_type_test): Return void and accept file/line.
+ (FFI_ASSERT): Pass stringized failed assertion.
+ (FFI_ASSERT_AT): New macro.
+ (FFI_ASSERT_VALID_TYPE): New macro.
+ (UINT8, SINT8, UINT16, SINT16, UINT32, SINT32,
+ UINT64, SINT64): Define here with gcc's __attribute__ macro
+ instead of in ffi.h
+ (FLOAT32, ALIGN): Define here instead of in ffi.h
+ * include/ffi-mips.h: Removed. Its content moved to
+ src/mips/ffitarget.h after separating assembly and C sections.
+ * src/alpha/ffi.c, src/alpha/ffi.c, src/java_raw_api.c
+ src/prep_cif.c, src/raw_api.c, src/ia64/ffi.c,
+ src/mips/ffi.c, src/mips/n32.S, src/mips/o32.S,
+ src/mips/ffitarget.h, src/sparc/ffi.c, src/x86/ffi64.c:
+ SIZEOF_ARG -> FFI_SIZEOF_ARG.
+ * src/ia64/ffi.c: Include stdbool.h (provided by GCC 2.95+).
+ * src/debug.c (ffi_assert): Accept stringized failed assertion.
+ (ffi_type_test): Rewritten.
+ * src/prep-cif.c (initialize_aggregate, ffi_prep_cif): Call
+ FFI_ASSERT_VALID_TYPE.
+ * src/alpha/ffitarget.h, src/arm/ffitarget.h,
+ src/ia64/ffitarget.h, src/m68k/ffitarget.h,
+ src/mips/ffitarget.h, src/powerpc/ffitarget.h,
+ src/s390/ffitarget.h, src/sh/ffitarget.h,
+ src/sh64/ffitarget.h, src/sparc/ffitarget.h,
+ src/x86/ffitarget.h: New files.
+ * src/alpha/osf.S, src/arm/sysv.S, src/ia64/unix.S,
+ src/m68k/sysv.S, src/mips/n32.S, src/mips/o32.S,
+ src/powerpc/aix.S, src/powerpc/darwin.S,
+ src/powerpc/ffi_darwin.c, src/powerpc/linux64.S,
+ src/powerpc/linux64_closure.S, src/powerpc/ppc_closure.S,
+ src/powerpc/sysv.S, src/s390/sysv.S, src/sh/sysv.S,
+ src/sh64/sysv.S, src/sparc/v8.S, src/sparc/v9.S,
+ src/x86/sysv.S, src/x86/unix64.S, src/x86/win32.S:
+ include fficonfig.h
+
+2003-10-20 Rainer Orth <ro@TechFak.Uni-Bielefeld.DE>
+
+ * src/mips/ffi.c: Use _ABIN32, _ABIO32 instead of external
+ _MIPS_SIM_NABI32, _MIPS_SIM_ABI32.
+
+2003-10-19 Andreas Tobler <a.tobler@schweiz.ch>
+
+ * src/powerpc/ffi_darwin.c (ffi_prep_args): Declare bytes again.
+ Used when FFI_DEBUG = 1.
+
+2003-10-14 Alan Modra <amodra@bigpond.net.au>
+
+ * src/types.c (double, longdouble): Default POWERPC64 to 8 byte size
+ and align.
+
+2003-10-06 Rainer Orth <ro@TechFak.Uni-Bielefeld.DE>
+
+ * include/ffi_mips.h: Define FFI_MIPS_N32 for N32/N64 ABIs,
+ FFI_MIPS_O32 for O32 ABI.
+
+2003-10-01 Andreas Tobler <a.tobler@schweiz.ch>
+
+ * testsuite/lib/libffi-dg.exp: Set LD_LIBRARY_PATH_64 for
+ SPARC64. Cleanup whitespaces.
+
+2003-09-19 Andreas Tobler <a.tobler@schweiz.ch>
+
+ * testsuite/libffi.call/closure_fn0.c: Xfail mips, arm,
+ strongarm, xscale. Cleanup whitespaces.
+ * testsuite/libffi.call/closure_fn1.c: Likewise.
+ * testsuite/libffi.call/closure_fn2.c: Likewise.
+ * testsuite/libffi.call/closure_fn3.c: Likewise.
+ * testsuite/libffi.call/cls_12byte.c: Likewise.
+ * testsuite/libffi.call/cls_16byte.c: Likewise.
+ * testsuite/libffi.call/cls_1_1byte.c: Likewise.
+ * testsuite/libffi.call/cls_20byte.c: Likewise.
+ * testsuite/libffi.call/cls_24byte.c: Likewise.
+ * testsuite/libffi.call/cls_2byte.c: Likewise.
+ * testsuite/libffi.call/cls_3_1byte.c: Likewise.
+ * testsuite/libffi.call/cls_3byte1.c: Likewise.
+ * testsuite/libffi.call/cls_3byte2.c: Likewise.
+ * testsuite/libffi.call/cls_4_1byte.c: Likewise.
+ * testsuite/libffi.call/cls_4byte.c: Likewise.
+ * testsuite/libffi.call/cls_5byte.c: Likewise.
+ * testsuite/libffi.call/cls_6byte.c: Likewise.
+ * testsuite/libffi.call/cls_7byte.c: Likewise.
+ * testsuite/libffi.call/cls_8byte.c: Likewise.
+ * testsuite/libffi.call/cls_double.c: Likewise.
+ * testsuite/libffi.call/cls_float.c: Likewise.
+ * testsuite/libffi.call/cls_uchar.c: Likewise.
+ * testsuite/libffi.call/cls_uint.c: Likewise.
+ * testsuite/libffi.call/cls_ulonglong.c: Likewise.
+ * testsuite/libffi.call/cls_ushort.c: Likewise.
+ * testsuite/libffi.call/nested_struct.c: Likewise.
+ * testsuite/libffi.call/nested_struct1.c: Likewise.
+ * testsuite/libffi.call/problem1.c: Likewise.
+ * testsuite/libffi.special/unwindtest.cc: Likewise.
+ * testsuite/libffi.call/pyobjc-tc.c: Cleanup whitespaces.
+
+2003-09-18 David Edelsohn <edelsohn@gnu.org>
+
+ * src/powerpc/aix.S: Cleanup whitespaces.
+ * src/powerpc/aix_closure.S: Likewise.
+
+2003-09-18 Andreas Tobler <a.tobler@schweiz.ch>
+
+ * src/powerpc/darwin.S: Cleanup whitespaces, comment formatting.
+ * src/powerpc/darwin_closure.S: Likewise.
+ * src/powerpc/ffi_darwin.c: Likewise.
+
+2003-09-18 Andreas Tobler <a.tobler@schweiz.ch>
+ David Edelsohn <edelsohn@gnu.org>
+
+ * src/types.c (double): Add AIX and Darwin to the right TYPEDEF.
+ * src/powerpc/aix_closure.S: Remove the pointer to the outgoing
+ parameter stack.
+ * src/powerpc/darwin_closure.S: Likewise.
+ * src/powerpc/ffi_darwin.c (ffi_prep_args): Handle structures
+ according to the Darwin/AIX ABI.
+ (ffi_prep_cif_machdep): Likewise.
+ (ffi_closure_helper_DARWIN): Likewise.
+ Remove the outgoing parameter stack logic. Simplify the evaluation
+ of the different CASE types.
+ (ffi_prep_clousure): Avoid the casts on lvalues. Change the branch
+ statement in the trampoline code.
+
+2003-09-18 Kaz Kojima <kkojima@gcc.gnu.org>
+
+ * src/sh/ffi.c (ffi_prep_args): Take account into the alignement
+ for the register size.
+ (ffi_closure_helper_SYSV): Handle the structure return value
+ address correctly.
+ (ffi_closure_helper_SYSV): Return the appropriate type when
+ the registers are used for the structure return value.
+ * src/sh/sysv.S (ffi_closure_SYSV): Fix the stack layout for
+ the 64-bit return value. Update copyright years.
+
+2003-09-17 Rainer Orth <ro@TechFak.Uni-Bielefeld.DE>
+
+ * testsuite/lib/libffi-dg.exp (libffi_target_compile): Search in
+ srcdir for ffi_mips.h.
+
+2003-09-12 Alan Modra <amodra@bigpond.net.au>
+
+ * src/prep_cif.c (initialize_aggregate): Include tail padding in
+ structure size.
+ * src/powerpc/linux64_closure.S (ffi_closure_LINUX64): Correct
+ placement of float result.
+ * testsuite/libffi.special/unwindtest.cc (closure_test_fn1): Correct
+ cast of "resp" for big-endian 64 bit machines.
+
+2003-09-11 Alan Modra <amodra@bigpond.net.au>
+
+ * src/types.c (double, longdouble): Merge identical SH and ARM
+ typedefs, and add POWERPC64.
+ * src/powerpc/ffi.c (ffi_prep_args64): Correct next_arg calc for
+ struct split over gpr and rest.
+ (ffi_prep_cif_machdep): Correct intarg_count for structures.
+ * src/powerpc/linux64.S (ffi_call_LINUX64): Fix gpr offsets.
+
+2003-09-09 Andreas Tobler <a.tobler@schweiz.ch>
+
+ * src/powerpc/ffi.c (ffi_closure_helper_SYSV) Handle struct
+ passing correctly.
+
+2003-09-09 Alan Modra <amodra@bigpond.net.au>
+
+ * configure: Regenerate.
+
+2003-09-04 Andreas Tobler <a.tobler@schweiz.ch>
+
+ * Makefile.am: Remove build rules for ffitest.
+ * Makefile.in: Rebuilt.
+
+2003-09-04 Andreas Tobler <a.tobler@schweiz.ch>
+
+ * src/java_raw_api.c: Include <stdlib.h> to fix compiler warning
+ about implicit declaration of abort().
+
+2003-09-04 Andreas Tobler <a.tobler@schweiz.ch>
+
+ * Makefile.am: Add dejagnu test framework. Fixes PR other/11411.
+ * Makefile.in: Rebuilt.
+ * configure.in: Add dejagnu test framework.
+ * configure: Rebuilt.
+
+ * testsuite/Makefile.am: New file.
+ * testsuite/Makefile.in: Built
+ * testsuite/lib/libffi-dg.exp: New file.
+ * testsuite/config/default.exp: Likewise.
+ * testsuite/libffi.call/call.exp: Likewise.
+ * testsuite/libffi.call/ffitest.h: Likewise.
+ * testsuite/libffi.call/closure_fn0.c: Likewise.
+ * testsuite/libffi.call/closure_fn1.c: Likewise.
+ * testsuite/libffi.call/closure_fn2.c: Likewise.
+ * testsuite/libffi.call/closure_fn3.c: Likewise.
+ * testsuite/libffi.call/cls_1_1byte.c: Likewise.
+ * testsuite/libffi.call/cls_3_1byte.c: Likewise.
+ * testsuite/libffi.call/cls_4_1byte.c: Likewise.
+ * testsuite/libffi.call/cls_2byte.c: Likewise.
+ * testsuite/libffi.call/cls_3byte1.c: Likewise.
+ * testsuite/libffi.call/cls_3byte2.c: Likewise.
+ * testsuite/libffi.call/cls_4byte.c: Likewise.
+ * testsuite/libffi.call/cls_5byte.c: Likewise.
+ * testsuite/libffi.call/cls_6byte.c: Likewise.
+ * testsuite/libffi.call/cls_7byte.c: Likewise.
+ * testsuite/libffi.call/cls_8byte.c: Likewise.
+ * testsuite/libffi.call/cls_12byte.c: Likewise.
+ * testsuite/libffi.call/cls_16byte.c: Likewise.
+ * testsuite/libffi.call/cls_20byte.c: Likewise.
+ * testsuite/libffi.call/cls_24byte.c: Likewise.
+ * testsuite/libffi.call/cls_double.c: Likewise.
+ * testsuite/libffi.call/cls_float.c: Likewise.
+ * testsuite/libffi.call/cls_uchar.c: Likewise.
+ * testsuite/libffi.call/cls_uint.c: Likewise.
+ * testsuite/libffi.call/cls_ulonglong.c: Likewise.
+ * testsuite/libffi.call/cls_ushort.c: Likewise.
+ * testsuite/libffi.call/float.c: Likewise.
+ * testsuite/libffi.call/float1.c: Likewise.
+ * testsuite/libffi.call/float2.c: Likewise.
+ * testsuite/libffi.call/many.c: Likewise.
+ * testsuite/libffi.call/many_win32.c: Likewise.
+ * testsuite/libffi.call/nested_struct.c: Likewise.
+ * testsuite/libffi.call/nested_struct1.c: Likewise.
+ * testsuite/libffi.call/pyobjc-tc.c: Likewise.
+ * testsuite/libffi.call/problem1.c: Likewise.
+ * testsuite/libffi.call/promotion.c: Likewise.
+ * testsuite/libffi.call/return_ll.c: Likewise.
+ * testsuite/libffi.call/return_sc.c: Likewise.
+ * testsuite/libffi.call/return_uc.c: Likewise.
+ * testsuite/libffi.call/strlen.c: Likewise.
+ * testsuite/libffi.call/strlen_win32.c: Likewise.
+ * testsuite/libffi.call/struct1.c: Likewise.
+ * testsuite/libffi.call/struct2.c: Likewise.
+ * testsuite/libffi.call/struct3.c: Likewise.
+ * testsuite/libffi.call/struct4.c: Likewise.
+ * testsuite/libffi.call/struct5.c: Likewise.
+ * testsuite/libffi.call/struct6.c: Likewise.
+ * testsuite/libffi.call/struct7.c: Likewise.
+ * testsuite/libffi.call/struct8.c: Likewise.
+ * testsuite/libffi.call/struct9.c: Likewise.
+ * testsuite/libffi.special/special.exp: New file.
+ * testsuite/libffi.special/ffitestcxx.h: Likewise.
+ * testsuite/libffi.special/unwindtest.cc: Likewise.
+
+
+2003-08-13 Kaz Kojima <kkojima@gcc.gnu.org>
+
+ * src/sh/ffi.c (OFS_INT16): Set 0 for little endian case. Update
+ copyright years.
+
+2003-08-02 Alan Modra <amodra@bigpond.net.au>
+
+ * src/powerpc/ffi.c (ffi_prep_args64): Modify for changed gcc
+ structure passing.
+ (ffi_closure_helper_LINUX64): Likewise.
+ * src/powerpc/linux64.S: Remove code writing to parm save area.
+ * src/powerpc/linux64_closure.S (ffi_closure_LINUX64): Use return
+ address in lr from ffi_closure_helper_LINUX64 call to calculate
+ table address. Optimize function tail.
+
+2003-07-28 Andreas Tobler <a.tobler@schweiz.ch>
+
+ * src/sparc/ffi.c: Handle all floating point registers.
+ * src/sparc/v9.S: Likewise. Fixes second part of PR target/11410.
+
+2003-07-11 Gerald Pfeifer <pfeifer@dbai.tuwien.ac.at>
+
+ * README: Note that libffi is not part of GCC. Update the project
+ URL and status.
+
+2003-06-19 Franz Sirl <Franz.Sirl-kernel@lauterbach.com>
+
+ * src/powerpc/ppc_closure.S: Include ffi.h.
+
+2003-06-13 Rainer Orth <ro@TechFak.Uni-Bielefeld.DE>
+
+ * src/x86/sysv.S: Avoid gas-only .uleb128/.sleb128 directives.
+ Use C style comments.
+
+2003-06-13 Kaz Kojima <kkojima@rr.iij4u.or.jp>
+
+ * Makefile.am: Add SHmedia support. Fix a typo of SH support.
+ * Makefile.in: Regenerate.
+ * configure.in (sh64-*-linux*, sh5*-*-linux*): Add target.
+ * configure: Regenerate.
+ * include/ffi.h.in: Add SHmedia support.
+ * src/sh64/ffi.c: New file.
+ * src/sh64/sysv.S: New file.
+
+2003-05-16 Jakub Jelinek <jakub@redhat.com>
+
+ * configure.in (HAVE_RO_EH_FRAME): Check whether .eh_frame section
+ should be read-only.
+ * configure: Rebuilt.
+ * fficonfig.h.in: Rebuilt.
+ * include/ffi.h.in (EH_FRAME_FLAGS): Define.
+ * src/alpha/osf.S: Use EH_FRAME_FLAGS.
+ * src/powerpc/linux64.S: Likewise.
+ * src/powerpc/linux64_closure.S: Likewise. Include ffi.h.
+ * src/powerpc/sysv.S: Use EH_FRAME_FLAGS. Use pcrel encoding
+ if -fpic/-fPIC/-mrelocatable.
+ * src/powerpc/powerpc_closure.S: Likewise.
+ * src/sparc/v8.S: If HAVE_RO_EH_FRAME is defined, don't include
+ #write in .eh_frame flags.
+ * src/sparc/v9.S: Likewise.
+ * src/x86/unix64.S: Use EH_FRAME_FLAGS.
+ * src/x86/sysv.S: Likewise. Use pcrel encoding if -fpic/-fPIC.
+ * src/s390/sysv.S: Use EH_FRAME_FLAGS. Include ffi.h.
+
+2003-05-07 Jeff Sturm <jsturm@one-point.com>
+
+ Fixes PR bootstrap/10656
+ * configure.in (HAVE_AS_REGISTER_PSEUDO_OP): Test assembler
+ support for .register pseudo-op.
+ * src/sparc/v8.S: Use it.
+ * fficonfig.h.in: Rebuilt.
+ * configure: Rebuilt.
+
+2003-04-18 Jakub Jelinek <jakub@redhat.com>
+
+ * include/ffi.h.in (POWERPC64): Define if 64-bit.
+ (enum ffi_abi): Add FFI_LINUX64 on POWERPC.
+ Make it the default on POWERPC64.
+ (FFI_TRAMPOLINE_SIZE): Define to 24 on POWERPC64.
+ * configure.in: Change powerpc-*-linux* into powerpc*-*-linux*.
+ * configure: Rebuilt.
+ * src/powerpc/ffi.c (hidden): Define.
+ (ffi_prep_args_SYSV): Renamed from
+ ffi_prep_args. Cast pointers to unsigned long to shut up warnings.
+ (NUM_GPR_ARG_REGISTERS64, NUM_FPR_ARG_REGISTERS64,
+ ASM_NEEDS_REGISTERS64): New.
+ (ffi_prep_args64): New function.
+ (ffi_prep_cif_machdep): Handle FFI_LINUX64 ABI.
+ (ffi_call): Likewise.
+ (ffi_prep_closure): Likewise.
+ (flush_icache): Surround by #ifndef POWERPC64.
+ (ffi_dblfl): New union type.
+ (ffi_closure_helper_SYSV): Use it to avoid aliasing problems.
+ (ffi_closure_helper_LINUX64): New function.
+ * src/powerpc/ppc_closure.S: Surround whole file by #ifndef
+ __powerpc64__.
+ * src/powerpc/sysv.S: Likewise.
+ (ffi_call_SYSV): Rename ffi_prep_args to ffi_prep_args_SYSV.
+ * src/powerpc/linux64.S: New file.
+ * src/powerpc/linux64_closure.S: New file.
+ * Makefile.am (EXTRA_DIST): Add src/powerpc/linux64.S and
+ src/powerpc/linux64_closure.S.
+ (TARGET_SRC_POWERPC): Likewise.
+
+ * src/ffitest.c (closure_test_fn, closure_test_fn1, closure_test_fn2,
+ closure_test_fn3): Fix result printing on big-endian 64-bit
+ machines.
+ (main): Print tst2_arg instead of uninitialized tst2_result.
+
+ * src/ffitest.c (main): Hide what closure pointer really points to
+ from the compiler.
+
+2003-04-16 Richard Earnshaw <rearnsha@arm.com>
+
+ * configure.in (arm-*-netbsdelf*): Add configuration.
+ (configure): Regenerated.
+
+2003-04-04 Loren J. Rittle <ljrittle@acm.org>
+
+ * include/Makefile.in: Regenerate.
+
+2003-03-21 Zdenek Dvorak <rakdver@atrey.karlin.mff.cuni.cz>
+
+ * libffi/include/ffi.h.in: Define X86 instead of X86_64 in 32
+ bit mode.
+ * libffi/src/x86/ffi.c (ffi_closure_SYSV, ffi_closure_raw_SYSV):
+ Receive closure pointer through parameter, read args using
+ __builtin_dwarf_cfa.
+ (FFI_INIT_TRAMPOLINE): Send closure reference through eax.
+
+2003-03-12 Andreas Schwab <schwab@suse.de>
+
+ * configure.in: Avoid trailing /. in toolexeclibdir.
+ * configure: Rebuilt.
+
+2003-03-03 Andreas Tobler <a.tobler@schweiz.ch>
+
+ * src/powerpc/darwin_closure.S: Recode to fit dynamic libraries.
+
+2003-02-06 Andreas Tobler <a.tobler@schweiz.ch>
+
+ * libffi/src/powerpc/darwin_closure.S:
+ Fix alignement bug, allocate 8 bytes for the result.
+ * libffi/src/powerpc/aix_closure.S:
+ Likewise.
+ * libffi/src/powerpc/ffi_darwin.c:
+ Update stackframe description for aix/darwin_closure.S.
+
+2003-02-06 Jakub Jelinek <jakub@redhat.com>
+
+ * src/s390/ffi.c (ffi_closure_helper_SYSV): Add hidden visibility
+ attribute.
+
+2003-01-31 Christian Cornelssen <ccorn@cs.tu-berlin.de>,
+ Andreas Schwab <schwab@suse.de>
+
+ * configure.in: Adjust command to source config-ml.in to account
+ for changes to the libffi_basedir definition.
+ (libffi_basedir): Remove ${srcdir} from value and include trailing
+ slash if nonempty.
+
+ * configure: Regenerate.
+
+2003-01-29 Franz Sirl <Franz.Sirl-kernel@lauterbach.com>
+
+ * src/powerpc/ppc_closure.S: Recode to fit shared libs.
+
+2003-01-28 Andrew Haley <aph@redhat.com>
+
+ * include/ffi.h.in: Enable FFI_CLOSURES for x86_64.
+ * src/x86/ffi64.c (ffi_prep_closure): New.
+ (ffi_closure_UNIX64_inner): New.
+ * src/x86/unix64.S (ffi_closure_UNIX64): New.
+
+2003-01-27 Alexandre Oliva <aoliva@redhat.com>
+
+ * configure.in (toolexecdir, toolexeclibdir): Set and AC_SUBST.
+ Remove USE_LIBDIR conditional.
+ * Makefile.am (toolexecdir, toolexeclibdir): Don't override.
+ * Makefile.in, configure: Rebuilt.
+
+2003-01027 David Edelsohn <edelsohn@gnu.org>
+
+ * Makefile.am (TARGET_SRC_POWERPC_AIX): Fix typo.
+ * Makefile.in: Regenerate.
+
+2003-01-22 Andrew Haley <aph@redhat.com>
+
+ * src/powerpc/darwin.S (_ffi_call_AIX): Add Augmentation size to
+ unwind info.
+
+2003-01-21 Andreas Tobler <a.tobler@schweiz.ch>
+
+ * src/powerpc/darwin.S: Add unwind info.
+ * src/powerpc/darwin_closure.S: Likewise.
+
+2003-01-14 Andrew Haley <aph@redhat.com>
+
+ * src/x86/ffi64.c (ffi_prep_args): Check for void retval.
+ (ffi_prep_cif_machdep): Likewise.
+ * src/x86/unix64.S: Add unwind info.
+
+2003-01-14 Andreas Jaeger <aj@suse.de>
+
+ * src/ffitest.c (main): Only use ffi_closures if those are
+ supported.
+
+2003-01-13 Andreas Tobler <a.tobler@schweiz.ch>
+
+ * libffi/src/ffitest.c
+ add closure testcases
+
+2003-01-13 Kevin B. Hendricks <khendricks@ivey.uwo.ca>
+
+ * libffi/src/powerpc/ffi.c
+ fix alignment bug for float (4 byte aligned iso 8 byte)
+
+2003-01-09 Geoffrey Keating <geoffk@apple.com>
+
+ * src/powerpc/ffi_darwin.c: Remove RCS version string.
+ * src/powerpc/darwin.S: Remove RCS version string.
+
+2003-01-03 Jeff Sturm <jsturm@one-point.com>
+
+ * include/ffi.h.in: Add closure defines for SPARC, SPARC64.
+ * src/ffitest.c (main): Use static storage for closure.
+ * src/sparc/ffi.c (ffi_prep_closure, ffi_closure_sparc_inner): New.
+ * src/sparc/v8.S (ffi_closure_v8): New.
+ * src/sparc/v9.S (ffi_closure_v9): New.
+
+2002-11-10 Ranjit Mathew <rmathew@hotmail.com>
+
+ * include/ffi.h.in: Added FFI_STDCALL ffi_type
+ enumeration for X86_WIN32.
+ * src/x86/win32.S: Added ffi_call_STDCALL function
+ definition.
+ * src/x86/ffi.c (ffi_call/ffi_raw_call): Added
+ switch cases for recognising FFI_STDCALL and
+ calling ffi_call_STDCALL if target is X86_WIN32.
+ * src/ffitest.c (my_stdcall_strlen/stdcall_many):
+ stdcall versions of the "my_strlen" and "many"
+ test functions (for X86_WIN32).
+ Added test cases to test stdcall invocation using
+ these functions.
+
+2002-12-02 Kaz Kojima <kkojima@gcc.gnu.org>
+
+ * src/sh/sysv.S: Add DWARF2 unwind info.
+
+2002-11-27 Ulrich Weigand <uweigand@de.ibm.com>
+
+ * src/s390/sysv.S (.eh_frame section): Make section read-only.
+
+2002-11-26 Jim Wilson <wilson@redhat.com>
+
+ * src/types.c (FFI_TYPE_POINTER): Has size 8 on IA64.
+
+2002-11-23 H.J. Lu <hjl@gnu.org>
+
+ * acinclude.m4: Add dummy AM_PROG_LIBTOOL.
+ Include ../config/accross.m4.
+ * aclocal.m4; Rebuild.
+ * configure: Likewise.
+
+2002-11-15 Ulrich Weigand <uweigand@de.ibm.com>
+
+ * src/s390/sysv.S (.eh_frame section): Adapt to pcrel FDE encoding.
+
+2002-11-11 DJ Delorie <dj@redhat.com>
+
+ * configure.in: Look for common files in the right place.
+
+2002-10-08 Ulrich Weigand <uweigand@de.ibm.com>
+
+ * src/java_raw_api.c (ffi_java_raw_to_ptrarray): Interpret
+ raw data as _Jv_word values, not ffi_raw.
+ (ffi_java_ptrarray_to_raw): Likewise.
+ (ffi_java_rvalue_to_raw): New function.
+ (ffi_java_raw_call): Call it.
+ (ffi_java_raw_to_rvalue): New function.
+ (ffi_java_translate_args): Call it.
+ * src/ffitest.c (closure_test_fn): Interpret return value
+ as ffi_arg, not int.
+ * src/s390/ffi.c (ffi_prep_cif_machdep): Add missing
+ FFI_TYPE_POINTER case.
+ (ffi_closure_helper_SYSV): Likewise. Also, assume return
+ values extended to word size.
+
+2002-10-02 Andreas Jaeger <aj@suse.de>
+
+ * src/x86/ffi64.c (ffi_prep_cif_machdep): Remove debug output.
+
+2002-10-01 Bo Thorsen <bo@smetana.suse.de>
+
+ * include/ffi.h.in: Fix i386 win32 compilation.
+
+2002-09-30 Ulrich Weigand <uweigand@de.ibm.com>
+
+ * configure.in: Add s390x-*-linux-* target.
+ * configure: Regenerate.
+ * include/ffi.h.in: Define S390X for s390x targets.
+ (FFI_CLOSURES): Define for s390/s390x.
+ (FFI_TRAMPOLINE_SIZE): Likewise.
+ (FFI_NATIVE_RAW_API): Likewise.
+ * src/prep_cif.c (ffi_prep_cif): Do not compute stack space for s390.
+ * src/types.c (FFI_TYPE_POINTER): Use 8-byte pointers on s390x.
+ * src/s390/ffi.c: Major rework of existing code. Add support for
+ s390x targets. Add closure support.
+ * src/s390/sysv.S: Likewise.
+
+2002-09-29 Richard Earnshaw <rearnsha@arm.com>
+
+ * src/arm/sysv.S: Fix typo.
+
+2002-09-28 Richard Earnshaw <rearnsha@arm.com>
+
+ * src/arm/sysv.S: If we don't have machine/asm.h and the pre-processor
+ has defined __USER_LABEL_PREFIX__, then use it in CNAME.
+ (ffi_call_SYSV): Handle soft-float.
+
+2002-09-27 Bo Thorsen <bo@suse.de>
+
+ * include/ffi.h.in: Fix multilib x86-64 support.
+
+2002-09-22 Kaveh R. Ghazi <ghazi@caip.rutgers.edu>
+
+ * Makefile.am (all-multi): Fix multilib parallel build.
+
+2002-07-19 Kaz Kojima <kkojima@gcc.gnu.org>
+
+ * configure.in (sh[34]*-*-linux*): Add brackets.
+ * configure: Regenerate.
+
+2002-07-18 Kaz Kojima <kkojima@gcc.gnu.org>
+
+ * Makefile.am: Add SH support.
+ * Makefile.in: Regenerate.
+ * configure.in (sh-*-linux*, sh[34]*-*-linux*): Add target.
+ * configure: Regenerate.
+ * include/ffi.h.in: Add SH support.
+ * src/sh/ffi.c: New file.
+ * src/sh/sysv.S: New file.
+ * src/types.c: Add SH support.
+
+2002-07-16 Bo Thorsen <bo@suse.de>
+
+ * src/x86/ffi64.c: New file that adds x86-64 support.
+ * src/x86/unix64.S: New file that handles argument setup for
+ x86-64.
+ * src/x86/sysv.S: Don't use this on x86-64.
+ * src/x86/ffi.c: Don't use this on x86-64.
+ Remove unused vars.
+ * src/prep_cif.c (ffi_prep_cif): Don't do stack size calculation
+ for x86-64.
+ * src/ffitest.c (struct6): New test that tests a special case in
+ the x86-64 ABI.
+ (struct7): Likewise.
+ (struct8): Likewise.
+ (struct9): Likewise.
+ (closure_test_fn): Silence warning about this when it's not used.
+ (main): Add the new tests.
+ (main): Fix a couple of wrong casts and silence some compiler warnings.
+ * include/ffi.h.in: Add x86-64 ABI definition.
+ * fficonfig.h.in: Regenerate.
+ * Makefile.am: Add x86-64 support.
+ * configure.in: Likewise.
+ * Makefile.in: Regenerate.
+ * configure: Likewise.
+
+2002-06-24 Bo Thorsen <bo@suse.de>
+
+ * src/types.c: Merge settings for similar architectures.
+ Add x86-64 sizes and alignments.
+
+2002-06-23 Bo Thorsen <bo@suse.de>
+
+ * src/arm/ffi.c (ffi_prep_args): Remove unused vars.
+ * src/sparc/ffi.c (ffi_prep_args_v8): Likewise.
+ * src/mips/ffi.c (ffi_prep_args): Likewise.
+ * src/m68k/ffi.c (ffi_prep_args): Likewise.
+
+2002-07-18 H.J. Lu (hjl@gnu.org)
+
+ * Makefile.am (TARGET_SRC_MIPS_LINUX): New.
+ (libffi_la_SOURCES): Support MIPS_LINUX.
+ (libffi_convenience_la_SOURCES): Likewise.
+ * Makefile.in: Regenerated.
+
+ * configure.in (mips64*-*): Skip.
+ (mips*-*-linux*): New.
+ * configure: Regenerated.
+
+ * src/mips/ffi.c: Include <sgidefs.h>.
+
+2002-06-06 Ulrich Weigand <uweigand@de.ibm.com>
+
+ * src/s390/sysv.S: Save/restore %r6. Add DWARF-2 unwind info.
+
+2002-05-27 Roger Sayle <roger@eyesopen.com>
+
+ * src/x86/ffi.c (ffi_prep_args): Remove reference to avn.
+
+2002-05-27 Bo Thorsen <bo@suse.de>
+
+ * src/x86/ffi.c (ffi_prep_args): Remove unused variable and
+ fix formatting.
+
+2002-05-13 Andreas Tobler <a.tobler@schweiz.ch>
+
+ * src/powerpc/ffi_darwin.c (ffi_prep_closure): Declare fd at
+ beginning of function (for older apple cc).
+
+2002-05-08 Alexandre Oliva <aoliva@redhat.com>
+
+ * configure.in (ORIGINAL_LD_FOR_MULTILIBS): Preserve LD at
+ script entry, and set LD to it when configuring multilibs.
+ * configure: Rebuilt.
+
+2002-05-05 Jason Thorpe <thorpej@wasabisystems.com>
+
+ * configure.in (sparc64-*-netbsd*): Add target.
+ (sparc-*-netbsdelf*): Likewise.
+ * configure: Regenerate.
+
+2002-04-28 David S. Miller <davem@redhat.com>
+
+ * configure.in, configure: Fix SPARC test in previous change.
+
+2002-04-29 Gerhard Tonn <GerhardTonn@swol.de>
+
+ * Makefile.am: Add Linux for S/390 support.
+ * Makefile.in: Regenerate.
+ * configure.in: Add Linux for S/390 support.
+ * configure: Regenerate.
+ * include/ffi.h.in: Add Linux for S/390 support.
+ * src/s390/ffi.c: New file from libffi CVS tree.
+ * src/s390/sysv.S: New file from libffi CVS tree.
+
+2002-04-28 Jakub Jelinek <jakub@redhat.com>
+
+ * configure.in (HAVE_AS_SPARC_UA_PCREL): Check for working
+ %r_disp32().
+ * src/sparc/v8.S: Use it.
+ * src/sparc/v9.S: Likewise.
+ * fficonfig.h.in: Rebuilt.
+ * configure: Rebuilt.
+
+2002-04-08 Hans Boehm <Hans_Boehm@hp.com>
+
+ * src/java_raw_api.c (ffi_java_raw_size): Handle FFI_TYPE_DOUBLE
+ correctly.
+ * src/ia64/unix.S: Add unwind information. Fix comments.
+ Save sp in a way that's compatible with unwind info.
+ (ffi_call_unix): Correctly restore sp in all cases.
+ * src/ia64/ffi.c: Add, fix comments.
+
+2002-04-08 Jakub Jelinek <jakub@redhat.com>
+
+ * src/sparc/v8.S: Make .eh_frame dependent on target word size.
+
+2002-04-06 Jason Thorpe <thorpej@wasabisystems.com>
+
+ * configure.in (alpha*-*-netbsd*): Add target.
+ * configure: Regenerate.
+
+2002-04-04 Jeff Sturm <jsturm@one-point.com>
+
+ * src/sparc/v8.S: Add unwind info.
+ * src/sparc/v9.S: Likewise.
+
+2002-03-30 Krister Walfridsson <cato@df.lth.se>
+
+ * configure.in: Enable i*86-*-netbsdelf*.
+ * configure: Rebuilt.
+
+2002-03-29 David Billinghurst <David.Billinghurst@riotinto.com>
+
+ PR other/2620
+ * src/mips/n32.s: Delete
+ * src/mips/o32.s: Delete
+
+2002-03-21 Loren J. Rittle <ljrittle@acm.org>
+
+ * configure.in: Enable alpha*-*-freebsd*.
+ * configure: Rebuilt.
+
+2002-03-17 Bryce McKinlay <bryce@waitaki.otago.ac.nz>
+
+ * Makefile.am: libfficonvenience -> libffi_convenience.
+ * Makefile.in: Rebuilt.
+
+ * Makefile.am: Define ffitest_OBJECTS.
+ * Makefile.in: Rebuilt.
+
+2002-03-07 Andreas Tobler <toa@pop.agri.ch>
+ David Edelsohn <edelsohn@gnu.org>
+
+ * Makefile.am (EXTRA_DIST): Add Darwin and AIX closure files.
+ (TARGET_SRC_POWERPC_AIX): Add aix_closure.S.
+ (TARGET_SRC_POWERPC_DARWIN): Add darwin_closure.S.
+ * Makefile.in: Regenerate.
+ * include/ffi.h.in: Add AIX and Darwin closure definitions.
+ * src/powerpc/ffi_darwin.c (ffi_prep_closure): New function.
+ (flush_icache, flush_range): New functions.
+ (ffi_closure_helper_DARWIN): New function.
+ * src/powerpc/aix_closure.S: New file.
+ * src/powerpc/darwin_closure.S: New file.
+
+2002-02-24 Jeff Sturm <jsturm@one-point.com>
+
+ * include/ffi.h.in: Add typedef for ffi_arg.
+ * src/ffitest.c (main): Declare rint with ffi_arg.
+
+2002-02-21 Andreas Tobler <toa@pop.agri.ch>
+
+ * src/powerpc/ffi_darwin.c (ffi_prep_args): Skip appropriate
+ number of GPRs for floating-point arguments.
+
+2002-01-31 Anthony Green <green@redhat.com>
+
+ * configure: Rebuilt.
+ * configure.in: Replace CHECK_SIZEOF and endian tests with
+ cross-compiler friendly macros.
+ * aclocal.m4 (AC_COMPILE_CHECK_SIZEOF, AC_C_BIGENDIAN_CROSS): New
+ macros.
+
+2002-01-18 David Edelsohn <edelsohn@gnu.org>
+
+ * src/powerpc/darwin.S (_ffi_call_AIX): New.
+ * src/powerpc/aix.S (ffi_call_DARWIN): New.
+
+2002-01-17 David Edelsohn <edelsohn@gnu.org>
+
+ * Makefile.am (EXTRA_DIST): Add Darwin and AIX files.
+ (TARGET_SRC_POWERPC_AIX): New.
+ (POWERPC_AIX): New stanza.
+ * Makefile.in: Regenerate.
+ * configure.in: Add AIX case.
+ * configure: Regenerate.
+ * include/ffi.h.in (ffi_abi): Add FFI_AIX.
+ * src/powerpc/ffi_darwin.c (ffi_status): Use "long" to scale frame
+ size. Fix "long double" support.
+ (ffi_call): Add FFI_AIX case.
+ * src/powerpc/aix.S: New.
+
+2001-10-09 John Hornkvist <john@toastedmarshmallow.com>
+
+ Implement Darwin PowerPC ABI.
+ * configure.in: Handle powerpc-*-darwin*.
+ * Makefile.am: Set source files for POWERPC_DARWIN.
+ * configure: Rebuilt.
+ * Makefile.in: Rebuilt.
+ * include/ffi.h.in: Define FFI_DARWIN and FFI_DEFAULT_ABI for
+ POWERPC_DARWIN.
+ * src/powerpc/darwin.S: New file.
+ * src/powerpc/ffi_darwin.c: New file.
+
+2001-10-07 Joseph S. Myers <jsm28@cam.ac.uk>
+
+ * src/x86/ffi.c: Fix spelling error of "separate" as "seperate".
+
+2001-07-16 Rainer Orth <ro@TechFak.Uni-Bielefeld.DE>
+
+ * src/x86/sysv.S: Avoid gas-only .balign directive.
+ Use C style comments.
+
+2001-07-16 Rainer Orth <ro@TechFak.Uni-Bielefeld.DE>
+
+ * src/alpha/ffi.c (ffi_prep_closure): Avoid gas-only mnemonic.
+ Fixes PR bootstrap/3563.
+
+2001-06-26 Rainer Orth <ro@TechFak.Uni-Bielefeld.DE>
+
+ * src/alpha/osf.S (ffi_closure_osf): Use .rdata for ECOFF.
+
+2001-06-25 Rainer Orth <ro@TechFak.Uni-Bielefeld.DE>
+
+ * configure.in: Recognize sparc*-sun-* host.
+ * configure: Regenerate.
+
+2001-06-06 Andrew Haley <aph@redhat.com>
+
+ * src/alpha/osf.S (__FRAME_BEGIN__): Conditionalize for ELF.
+
+2001-06-03 Andrew Haley <aph@redhat.com>
+
+ * src/alpha/osf.S: Add unwind info.
+ * src/powerpc/sysv.S: Add unwind info.
+ * src/powerpc/ppc_closure.S: Likewise.
+
+2000-05-31 Jeff Sturm <jsturm@one-point.com>
+
+ * configure.in: Fix AC_ARG_ENABLE usage.
+ * configure: Rebuilt.
+
+2001-05-06 Bryce McKinlay <bryce@waitaki.otago.ac.nz>
+
+ * configure.in: Remove warning about beta code.
+ * configure: Rebuilt.
+
+2001-04-25 Hans Boehm <Hans_Boehm@hp.com>
+
+ * src/ia64/unix.S: Restore stack pointer when returning from
+ ffi_closure_UNIX.
+ * src/ia64/ffi.c: Fix typo in comment.
+
+2001-04-18 Jim Wilson <wilson@redhat.com>
+
+ * src/ia64/unix.S: Delete unnecessary increment and decrement of loc2
+ to eliminate RAW DV.
+
+2001-04-12 Bryce McKinlay <bryce@albatross.co.nz>
+
+ * Makefile.am: Make a libtool convenience library.
+ * Makefile.in: Rebuilt.
+
+2001-03-29 Bryce McKinlay <bryce@albatross.co.nz>
+
+ * configure.in: Use different syntax for subdirectory creation.
+ * configure: Rebuilt.
+
+2001-03-27 Jon Beniston <jon@beniston.com>
+
+ * configure.in: Added X86_WIN32 target (Win32, CygWin, MingW).
+ * configure: Rebuilt.
+ * Makefile.am: Added X86_WIN32 target support.
+ * Makefile.in: Rebuilt.
+
+ * include/ffi.h.in: Added X86_WIN32 target support.
+
+ * src/ffitest.c: Doesn't run structure tests for X86_WIN32 targets.
+ * src/types.c: Added X86_WIN32 target support.
+
+ * src/x86/win32.S: New file. Based on sysv.S, but with EH
+ stuff removed and made to work with CygWin's gas.
+
+2001-03-26 Bryce McKinlay <bryce@albatross.co.nz>
+
+ * configure.in: Make target subdirectory in build dir.
+ * Makefile.am: Override suffix based rules to specify correct output
+ subdirectory.
+ * Makefile.in: Rebuilt.
+ * configure: Rebuilt.
+
+2001-03-23 Kevin B Hendricks <khendricks@ivey.uwo.ca>
+
+ * src/powerpc/ppc_closure.S: New file.
+ * src/powerpc/ffi.c (ffi_prep_args): Fixed ABI compatibility bug
+ involving long long and register pairs.
+ (ffi_prep_closure): New function.
+ (flush_icache): Likewise.
+ (ffi_closure_helper_SYSV): Likewise.
+ * include/ffi.h.in (FFI_CLOSURES): Define on PPC.
+ (FFI_TRAMPOLINE_SIZE): Likewise.
+ (FFI_NATIVE_RAW_API): Likewise.
+ * Makefile.in: Rebuilt.
+ * Makefile.am (EXTRA_DIST): Added src/powerpc/ppc_closure.S.
+ (TARGET_SRC_POWERPC): Likewise.
+
+2001-03-19 Tom Tromey <tromey@redhat.com>
+
+ * Makefile.in: Rebuilt.
+ * Makefile.am (ffitest_LDFLAGS): New macro.
+
+2001-03-02 Nick Clifton <nickc@redhat.com>
+
+ * include/ffi.h.in: Remove RCS ident string.
+ * include/ffi_mips.h: Remove RCS ident string.
+ * src/debug.c: Remove RCS ident string.
+ * src/ffitest.c: Remove RCS ident string.
+ * src/prep_cif.c: Remove RCS ident string.
+ * src/types.c: Remove RCS ident string.
+ * src/alpha/ffi.c: Remove RCS ident string.
+ * src/alpha/osf.S: Remove RCS ident string.
+ * src/arm/ffi.c: Remove RCS ident string.
+ * src/arm/sysv.S: Remove RCS ident string.
+ * src/mips/ffi.c: Remove RCS ident string.
+ * src/mips/n32.S: Remove RCS ident string.
+ * src/mips/o32.S: Remove RCS ident string.
+ * src/sparc/ffi.c: Remove RCS ident string.
+ * src/sparc/v8.S: Remove RCS ident string.
+ * src/sparc/v9.S: Remove RCS ident string.
+ * src/x86/ffi.c: Remove RCS ident string.
+ * src/x86/sysv.S: Remove RCS ident string.
+
+2001-02-08 Joseph S. Myers <jsm28@cam.ac.uk>
+
+ * include/ffi.h.in: Change sourceware.cygnus.com references to
+ gcc.gnu.org.
+
+2000-12-09 Richard Henderson <rth@redhat.com>
+
+ * src/alpha/ffi.c (ffi_call): Simplify struct return test.
+ (ffi_closure_osf_inner): Index rather than increment avalue
+ and arg_types. Give ffi_closure_osf the raw return value type.
+ * src/alpha/osf.S (ffi_closure_osf): Handle return value type
+ promotion.
+
+2000-12-07 Richard Henderson <rth@redhat.com>
+
+ * src/raw_api.c (ffi_translate_args): Fix typo.
+ (ffi_prep_closure): Likewise.
+
+ * include/ffi.h.in [ALPHA]: Define FFI_CLOSURES and
+ FFI_TRAMPOLINE_SIZE.
+ * src/alpha/ffi.c (ffi_prep_cif_machdep): Adjust minimal
+ cif->bytes for new ffi_call_osf implementation.
+ (ffi_prep_args): Absorb into ...
+ (ffi_call): ... here. Do all stack allocation here and
+ avoid a callback function.
+ (ffi_prep_closure, ffi_closure_osf_inner): New.
+ * src/alpha/osf.S (ffi_call_osf): Reimplement with no callback.
+ (ffi_closure_osf): New.
+
+2000-09-10 Alexandre Oliva <aoliva@redhat.com>
+
+ * config.guess, config.sub, install-sh: Removed.
+ * ltconfig, ltmain.sh, missing, mkinstalldirs: Likewise.
+ * Makefile.in: Rebuilt.
+
+ * acinclude.m4: Include libtool macros from the top level.
+ * aclocal.m4, configure: Rebuilt.
+
+2000-08-22 Alexandre Oliva <aoliva@redhat.com>
+
+ * configure.in [i*86-*-freebsd*] (TARGET, TARGETDIR): Set.
+ * configure: Rebuilt.
+
+2000-05-11 Scott Bambrough <scottb@netwinder.org>
+
+ * libffi/src/arm/sysv.S (ffi_call_SYSV): Doubles are not saved to
+ memory correctly. Use conditional instructions, not branches where
+ possible.
+
+2000-05-04 Tom Tromey <tromey@cygnus.com>
+
+ * configure: Rebuilt.
+ * configure.in: Match `arm*-*-linux-*'.
+ From Chris Dornan <cdornan@arm.com>.
+
+2000-04-28 Jakub Jelinek <jakub@redhat.com>
+
+ * Makefile.am (SUBDIRS): Define.
+ (AM_MAKEFLAGS): Likewise.
+ (Multilib support.): Add section.
+ * Makefile.in: Rebuilt.
+ * ltconfig (extra_compiler_flags, extra_compiler_flags_value):
+ New variables. Set for gcc using -print-multi-lib. Export them
+ to libtool.
+ (sparc64-*-linux-gnu*): Use libsuff 64 for search paths.
+ * ltmain.sh (B|b|V): Don't throw away gcc's -B, -b and -V options
+ for -shared links.
+ (extra_compiler_flags_value, extra_compiler_flags): Check these
+ for extra compiler options which need to be passed down in
+ compiler_flags.
+
+2000-04-16 Anthony Green <green@redhat.com>
+
+ * configure: Rebuilt.
+ * configure.in: Change i*86-pc-linux* to i*86-*-linux*.
+
+2000-04-14 Jakub Jelinek <jakub@redhat.com>
+
+ * include/ffi.h.in (SPARC64): Define for 64bit SPARC builds.
+ Set SPARC FFI_DEFAULT_ABI based on SPARC64 define.
+ * src/sparc/ffi.c (ffi_prep_args_v8): Renamed from ffi_prep_args.
+ Replace all void * sizeofs with sizeof(int).
+ Only compare type with FFI_TYPE_LONGDOUBLE if LONGDOUBLE is
+ different than DOUBLE.
+ Remove FFI_TYPE_SINT32 and FFI_TYPE_UINT32 cases (handled elsewhere).
+ (ffi_prep_args_v9): New function.
+ (ffi_prep_cif_machdep): Handle V9 ABI and long long on V8.
+ (ffi_V9_return_struct): New function.
+ (ffi_call): Handle FFI_V9 ABI from 64bit code and FFI_V8 ABI from
+ 32bit code (not yet cross-arch calls).
+ * src/sparc/v8.S: Add struct return delay nop.
+ Handle long long.
+ * src/sparc/v9.S: New file.
+ * src/prep_cif.c (ffi_prep_cif): Return structure pointer
+ is used on sparc64 only for structures larger than 32 bytes.
+ Pass by reference for structures is done for structure arguments
+ larger than 16 bytes.
+ * src/ffitest.c (main): Use 64bit rint on sparc64.
+ Run long long tests on sparc.
+ * src/types.c (FFI_TYPE_POINTER): Pointer is 64bit on alpha and
+ sparc64.
+ (FFI_TYPE_LONGDOUBLE): long double is 128 bit aligned to 128 bits
+ on sparc64.
+ * configure.in (sparc-*-linux*): New supported target.
+ (sparc64-*-linux*): Likewise.
+ * configure: Rebuilt.
+ * Makefile.am: Add v9.S to SPARC files.
+ * Makefile.in: Likewise.
+ (LINK): Surround $(CCLD) into double quotes, so that multilib
+ compiles work correctly.
+
+2000-04-04 Alexandre Petit-Bianco <apbianco@cygnus.com>
+
+ * configure: Rebuilt.
+ * configure.in: (i*86-*-solaris*): New libffi target. Patch
+ proposed by Bryce McKinlay.
+
+2000-03-20 Tom Tromey <tromey@cygnus.com>
+
+ * Makefile.in: Hand edit for java_raw_api.lo.
+
+2000-03-08 Bryce McKinlay <bryce@albatross.co.nz>
+
+ * config.guess, config.sub: Update from the gcc tree.
+ Fix for PR libgcj/168.
+
+2000-03-03 Tom Tromey <tromey@cygnus.com>
+
+ * Makefile.in: Fixed ia64 by hand.
+
+ * configure: Rebuilt.
+ * configure.in (--enable-multilib): New option.
+ (libffi_basedir): New subst.
+ (AC_OUTPUT): Added multilib code.
+
+2000-03-02 Tom Tromey <tromey@cygnus.com>
+
+ * Makefile.in: Rebuilt.
+ * Makefile.am (TARGET_SRC_IA64): Use `ia64', not `alpha', as
+ directory name.
+
+2000-02-25 Hans Boehm <boehm@acm.org>
+
+ * src/ia64/ffi.c, src/ia64/ia64_flags.h, src/ia64/unix.S: New
+ files.
+ * src/raw_api.c (ffi_translate_args): Fixed typo in argument
+ list.
+ (ffi_prep_raw_closure): Use ffi_translate_args, not
+ ffi_closure_translate.
+ * src/java_raw_api.c: New file.
+ * src/ffitest.c (closure_test_fn): New function.
+ (main): Define `rint' as long long on IA64. Added new test when
+ FFI_CLOSURES is defined.
+ * include/ffi.h.in (ALIGN): Use size_t, not unsigned.
+ (ffi_abi): Recognize IA64.
+ (ffi_raw): Added `flt' field.
+ Added "Java raw API" code.
+ * configure.in: Recognize ia64.
+ * Makefile.am (TARGET_SRC_IA64): New macro.
+ (libffi_la_common_SOURCES): Added java_raw_api.c.
+ (libffi_la_SOURCES): Define in IA64 case.
+
+2000-01-04 Tom Tromey <tromey@cygnus.com>
+
+ * Makefile.in: Rebuilt with newer automake.
+
+1999-12-31 Tom Tromey <tromey@cygnus.com>
+
+ * Makefile.am (INCLUDES): Added -I$(top_srcdir)/src.
+
+1999-09-01 Tom Tromey <tromey@cygnus.com>
+
+ * include/ffi.h.in: Removed PACKAGE and VERSION defines and
+ undefs.
+ * fficonfig.h.in: Rebuilt.
+ * configure: Rebuilt.
+ * configure.in: Pass 3rd argument to AM_INIT_AUTOMAKE.
+ Use AM_PROG_LIBTOOL (automake 1.4 compatibility).
+ * acconfig.h: Don't #undef PACKAGE or VERSION.
+
+1999-08-09 Anthony Green <green@cygnus.com>
+
+ * include/ffi.h.in: Try to work around messy header problem
+ with PACKAGE and VERSION.
+
+ * configure: Rebuilt.
+ * configure.in: Change version to 2.00-beta.
+
+ * fficonfig.h.in: Rebuilt.
+ * acconfig.h (FFI_NO_STRUCTS, FFI_NO_RAW_API): Define.
+
+ * src/x86/ffi.c (ffi_raw_call): Rename.
+
+1999-08-02 Kresten Krab Thorup <krab@dominiq.is.s.u-tokyo.ac.jp>
+
+ * src/x86/ffi.c (ffi_closure_SYSV): New function.
+ (ffi_prep_incoming_args_SYSV): Ditto.
+ (ffi_prep_closure): Ditto.
+ (ffi_closure_raw_SYSV): Ditto.
+ (ffi_prep_raw_closure): More ditto.
+ (ffi_call_raw): Final ditto.
+
+ * include/ffi.h.in: Add definitions for closure and raw API.
+
+ * src/x86/ffi.c (ffi_prep_cif_machdep): Added case for
+ FFI_TYPE_UINT64.
+
+ * Makefile.am (libffi_la_common_SOURCES): Added raw_api.c
+
+ * src/raw_api.c: New file.
+
+ * include/ffi.h.in (ffi_raw): New type.
+ (UINT_ARG, SINT_ARG): New defines.
+ (ffi_closure, ffi_raw_closure): New types.
+ (ffi_prep_closure, ffi_prep_raw_closure): New declarations.
+
+ * configure.in: Add check for endianness and sizeof void*.
+
+ * src/x86/sysv.S (ffi_call_SYSV): Call fixup routine via argument,
+ instead of directly.
+
+ * configure: Rebuilt.
+
+Thu Jul 8 14:28:42 1999 Anthony Green <green@cygnus.com>
+
+ * configure.in: Add x86 and powerpc BeOS configurations.
+ From Makoto Kato <m_kato@ga2.so-net.ne.jp>.
+
+1999-05-09 Anthony Green <green@cygnus.com>
+
+ * configure.in: Add warning about this being beta code.
+ Remove src/Makefile.am from the picture.
+ * configure: Rebuilt.
+
+ * Makefile.am: Move logic from src/Makefile.am. Add changes
+ to support libffi as a target library.
+ * Makefile.in: Rebuilt.
+
+ * aclocal.m4, config.guess, config.sub, ltconfig, ltmain.sh:
+ Upgraded to new autoconf, automake, libtool.
+
+ * README: Tweaks.
+
+ * LICENSE: Update copyright date.
+
+ * src/Makefile.am, src/Makefile.in: Removed.
+
+1998-11-29 Anthony Green <green@cygnus.com>
+
+ * include/ChangeLog: Removed.
+ * src/ChangeLog: Removed.
+ * src/mips/ChangeLog: Removed.
+ * src/sparc/ChangeLog: Remboved.
+ * src/x86/ChangeLog: Removed.
+
+ * ChangeLog.v1: Created.
diff --git a/jni/ruby/ext/fiddle/libffi-3.2.1/ChangeLog.libgcj b/jni/ruby/ext/fiddle/libffi-3.2.1/ChangeLog.libgcj
new file mode 100644
index 0000000..ea5d02f
--- /dev/null
+++ b/jni/ruby/ext/fiddle/libffi-3.2.1/ChangeLog.libgcj
@@ -0,0 +1,40 @@
+2004-01-14 Kelley Cook <kcook@gcc.gnu.org>
+
+ * configure.in: Add in AC_PREREQ(2.13)
+
+2003-02-20 Alexandre Oliva <aoliva@redhat.com>
+
+ * configure.in: Propagate ORIGINAL_LD_FOR_MULTILIBS to
+ config.status.
+ * configure: Rebuilt.
+
+2002-01-27 Alexandre Oliva <aoliva@redhat.com>
+
+ * configure.in (toolexecdir, toolexeclibdir): Set and AC_SUBST.
+ Remove USE_LIBDIR conditional.
+ * Makefile.am (toolexecdir, toolexeclibdir): Don't override.
+ * Makefile.in, configure: Rebuilt.
+
+Mon Aug 9 18:33:38 1999 Rainer Orth <ro@TechFak.Uni-Bielefeld.DE>
+
+ * include/Makefile.in: Rebuilt.
+ * Makefile.in: Rebuilt
+ * Makefile.am (toolexeclibdir): Add $(MULTISUBDIR) even for native
+ builds.
+ Use USE_LIBDIR.
+
+ * configure: Rebuilt.
+ * configure.in (USE_LIBDIR): Define for native builds.
+ Use lowercase in configure --help explanations.
+
+1999-08-08 Anthony Green <green@cygnus.com>
+
+ * include/ffi.h.in (FFI_FN): Remove `...'.
+
+1999-08-08 Anthony Green <green@cygnus.com>
+
+ * Makefile.in: Rebuilt.
+ * Makefile.am (AM_CFLAGS): Compile with -fexceptions.
+
+ * src/x86/sysv.S: Add exception handling metadata.
+
diff --git a/jni/ruby/ext/fiddle/libffi-3.2.1/ChangeLog.v1 b/jni/ruby/ext/fiddle/libffi-3.2.1/ChangeLog.v1
new file mode 100644
index 0000000..af3a377
--- /dev/null
+++ b/jni/ruby/ext/fiddle/libffi-3.2.1/ChangeLog.v1
@@ -0,0 +1,764 @@
+The libffi version 1 ChangeLog archive.
+
+Version 1 of libffi had per-directory ChangeLogs. Current and future
+versions have a single ChangeLog file in the root directory. The
+version 1 ChangeLogs have all been concatenated into this file for
+future reference only.
+
+--- libffi ----------------------------------------------------------------
+
+Mon Oct 5 02:17:50 1998 Anthony Green <green@cygnus.com>
+
+ * configure.in: Boosted rev.
+ * configure, Makefile.in, aclocal.m4: Rebuilt.
+ * README: Boosted rev and updated release notes.
+
+Mon Oct 5 01:03:03 1998 Anthony Green <green@cygnus.com>
+
+ * configure.in: Boosted rev.
+ * configure, Makefile.in, aclocal.m4: Rebuilt.
+ * README: Boosted rev and updated release notes.
+
+1998-07-25 Andreas Schwab <schwab@issan.informatik.uni-dortmund.de>
+
+ * m68k/ffi.c (ffi_prep_cif_machdep): Use bitmask for cif->flags.
+ Correctly handle small structures.
+ (ffi_prep_args): Also handle small structures.
+ (ffi_call): Pass size of return type to ffi_call_SYSV.
+ * m68k/sysv.S: Adjust for above changes. Correctly align small
+ structures in the return value.
+
+ * types.c (uint64, sint64) [M68K]: Change alignment to 4.
+
+Fri Apr 17 17:26:58 1998 Anthony Green <green@hoser.cygnus.com>
+
+ * configure.in: Boosted rev.
+ * configure,Makefile.in,aclocal.m4: Rebuilt.
+ * README: Boosted rev and added release notes.
+
+Sun Feb 22 00:50:41 1998 Geoff Keating <geoffk@ozemail.com.au>
+
+ * configure.in: Add PowerPC config bits.
+
+1998-02-14 Andreas Schwab <schwab@issan.informatik.uni-dortmund.de>
+
+ * configure.in: Add m68k config bits. Change AC_CANONICAL_SYSTEM
+ to AC_CANONICAL_HOST, this is not a compiler. Use $host instead
+ of $target. Remove AC_CHECK_SIZEOF(char), we already know the
+ result. Fix argument of AC_ARG_ENABLE.
+ * configure, fficonfig.h.in: Rebuilt.
+
+Tue Feb 10 20:53:40 1998 Richard Henderson <rth@cygnus.com>
+
+ * configure.in: Add Alpha config bits.
+
+Tue May 13 13:39:20 1997 Anthony Green <green@hoser.cygnus.com>
+
+ * README: Updated dates and reworded Irix comments.
+
+ * configure.in: Removed AC_PROG_RANLIB.
+
+ * Makefile.in, aclocal.m4, config.guess, config.sub, configure,
+ ltmain.sh, */Makefile.in: libtoolized again and rebuilt with
+ automake and autoconf.
+
+Sat May 10 18:44:50 1997 Tom Tromey <tromey@cygnus.com>
+
+ * configure, aclocal.m4: Rebuilt.
+ * configure.in: Don't compute EXTRADIST; now handled in
+ src/Makefile.in. Removed macros implied by AM_INIT_AUTOMAKE.
+ Don't run AM_MAINTAINER_MODE.
+
+Thu May 8 14:34:05 1997 Anthony Green <green@hoser.cygnus.com>
+
+ * missing, ltmain.sh, ltconfig.sh: Created. These are new files
+ required by automake and libtool.
+
+ * README: Boosted rev to 1.14. Added notes.
+
+ * acconfig.h: Moved PACKAGE and VERSION for new automake.
+
+ * configure.in: Changes for libtool.
+
+ * Makefile.am (check): make test now make check. Uses libtool now.
+
+ * Makefile.in, configure.in, aclocal.h, fficonfig.h.in: Rebuilt.
+
+Thu May 1 16:27:07 1997 Anthony Green <green@hoser.cygnus.com>
+
+ * missing: Added file required by new automake.
+
+Tue Nov 26 14:10:42 1996 Anthony Green <green@csk3.cygnus.com>
+
+ * acconfig.h: Added USING_PURIFY flag. This is defined when
+ --enable-purify-safety was used at configure time.
+
+ * configure.in (allsources): Added --enable-purify-safety switch.
+ (VERSION): Boosted rev to 1.13.
+ * configure: Rebuilt.
+
+Fri Nov 22 06:46:12 1996 Anthony Green <green@rtl.cygnus.com>
+
+ * configure.in (VERSION): Boosted rev to 1.12.
+ Removed special CFLAGS hack for gcc.
+ * configure: Rebuilt.
+
+ * README: Boosted rev to 1.12. Added notes.
+
+ * Many files: Cygnus Support changed to Cygnus Solutions.
+
+Wed Oct 30 11:15:25 1996 Anthony Green <green@rtl.cygnus.com>
+
+ * configure.in (VERSION): Boosted rev to 1.11.
+ * configure: Rebuilt.
+
+ * README: Boosted rev to 1.11. Added notes about GNU make.
+
+Tue Oct 29 12:25:12 1996 Anthony Green <green@rtl.cygnus.com>
+
+ * configure.in: Fixed -Wall trick.
+ (VERSION): Boosted rev.
+ * configure: Rebuilt
+
+ * acconfig.h: Needed for --enable-debug configure switch.
+
+ * README: Boosted rev to 1.09. Added more notes on building
+ libffi, and LCLint.
+
+ * configure.in: Added --enable-debug switch. Boosted rev to
+ 1.09.
+ * configure: Rebuilt
+
+Tue Oct 15 13:11:28 1996 Anthony Green <green@hoser.cygnus.com>
+
+ * configure.in (VERSION): Boosted rev to 1.08
+ * configure: Rebuilt.
+
+ * README: Added n32 bug fix notes.
+
+ * Makefile.am: Added "make lint" production.
+ * Makefile.in: Rebuilt.
+
+Mon Oct 14 10:54:46 1996 Anthony Green <green@rtl.cygnus.com>
+
+ * README: Added web page reference.
+
+ * configure.in, README: Boosted rev to 1.05
+ * configure: Rebuilt.
+
+ * README: Fixed n32 sample code.
+
+Fri Oct 11 17:09:28 1996 Anthony Green <green@rtl.cygnus.com>
+
+ * README: Added sparc notes.
+
+ * configure.in, README: Boosted rev to 1.04.
+ * configure: Rebuilt.
+
+Thu Oct 10 10:31:03 1996 Anthony Green <green@rtl.cygnus.com>
+
+ * configure.in, README: Boosted rev to 1.03.
+ * configure: Rebuilt.
+
+ * README: Added struct notes.
+
+ * Makefile.am (EXTRA_DIST): Added LICENSE to distribution.
+ * Makefile.in: Rebuilt.
+
+ * README: Removed Linux section. No special notes now
+ because aggregates arg/return types work.
+
+Wed Oct 9 16:16:42 1996 Anthony Green <green@rtl.cygnus.com>
+
+ * README, configure.in (VERSION): Boosted rev to 1.02
+ * configure: Rebuilt.
+
+Tue Oct 8 11:56:33 1996 Anthony Green <green@rtl.cygnus.com>
+
+ * README (NOTE): Added n32 notes.
+
+ * Makefile.am: Added test production.
+ * Makefile: Rebuilt
+
+ * README: spell checked!
+
+ * configure.in (VERSION): Boosted rev to 1.01
+ * configure: Rebuilt.
+
+Mon Oct 7 15:50:22 1996 Anthony Green <green@rtl.cygnus.com>
+
+ * configure.in: Added nasty bit to support SGI tools.
+ * configure: Rebuilt.
+
+ * README: Added SGI notes. Added note about automake bug.
+
+Mon Oct 7 11:00:28 1996 Anthony Green <green@hoser.cygnus.com>
+
+ * README: Rewrote intro, and fixed examples.
+
+Fri Oct 4 10:19:55 1996 Anthony Green <green@hoser.cygnus.com>
+
+ * configure.in: -D$TARGET is no longer used as a compiler switch.
+ It is now inserted into ffi.h at configure time.
+ * configure: Rebuilt.
+
+ * FFI_ABI and FFI_STATUS are now ffi_abi and ffi_status.
+
+Thu Oct 3 13:47:34 1996 Anthony Green <green@hoser.cygnus.com>
+
+ * README, LICENSE: Created. Wrote some docs.
+
+ * configure.in: Don't barf on i586-unknown-linuxaout.
+ Added EXTRADIST code for "make dist".
+ * configure: Rebuilt.
+
+ * */Makefile.in: Rebuilt with patched automake.
+
+Tue Oct 1 17:12:25 1996 Anthony Green <green@rtl.cygnus.com>
+
+ * Makefile.am, aclocal.m4, config.guess, config.sub,
+ configure.in, fficonfig.h.in, install-sh, mkinstalldirs,
+ stamp-h.in: Created
+ * Makefile.in, configure: Generated
+
+--- libffi/include --------------------------------------------------------
+
+Tue Feb 24 13:09:36 1998 Anthony Green <green@gerbil.cygnus.com>
+
+ * ffi_mips.h: Updated FFI_TYPE_STRUCT_* values based on
+ ffi.h.in changes. This is a work-around for SGI's "simple"
+ assembler.
+
+Sun Feb 22 00:51:55 1998 Geoff Keating <geoffk@ozemail.com.au>
+
+ * ffi.h.in: PowerPC support.
+
+1998-02-14 Andreas Schwab <schwab@issan.informatik.uni-dortmund.de>
+
+ * ffi.h.in: Add m68k support.
+ (FFI_TYPE_LONGDOUBLE): Make it a separate value.
+
+Tue Feb 10 20:55:16 1998 Richard Henderson <rth@cygnus.com>
+
+ * ffi.h.in (SIZEOF_ARG): Use a pointer type by default.
+
+ * ffi.h.in: Alpha support.
+
+Fri Nov 22 06:48:45 1996 Anthony Green <green@rtl.cygnus.com>
+
+ * ffi.h.in, ffi_common.h: Cygnus Support -> Cygnus Solutions.
+
+Wed Nov 20 22:31:01 1996 Anthony Green <green@hoser.cygnus.com>
+
+ * ffi.h.in: Added ffi_type_void definition.
+
+Tue Oct 29 12:22:40 1996 Anthony Green <green@rtl.cygnus.com>
+
+ * Makefile.am (hack_DATA): Always install ffi_mips.h.
+
+ * ffi.h.in: Removed FFI_DEBUG. It's now in the correct
+ place (acconfig.h).
+ Added #include <stddef.h> for size_t definition.
+
+Tue Oct 15 17:23:35 1996 Anthony Green <green@hoser.cygnus.com>
+
+ * ffi.h.in, ffi_common.h, ffi_mips.h: More clean up.
+ Commented out #define of FFI_DEBUG.
+
+Tue Oct 15 13:01:06 1996 Anthony Green <green@rtl.cygnus.com>
+
+ * ffi_common.h: Added bool definition.
+
+ * ffi.h.in, ffi_common.h: Clean up based on LCLint output.
+ Added funny /*@...@*/ comments to annotate source.
+
+Mon Oct 14 12:29:23 1996 Anthony Green <green@rtl.cygnus.com>
+
+ * ffi.h.in: Interface changes based on feedback from Jim
+ Blandy.
+
+Fri Oct 11 16:49:35 1996 Anthony Green <green@rtl.cygnus.com>
+
+ * ffi.h.in: Small change for sparc support.
+
+Thu Oct 10 14:53:37 1996 Anthony Green <green@rtl.cygnus.com>
+
+ * ffi_mips.h: Added FFI_TYPE_STRUCT_* definitions for
+ special structure return types.
+
+Wed Oct 9 13:55:57 1996 Anthony Green <green@rtl.cygnus.com>
+
+ * ffi.h.in: Added SIZEOF_ARG definition for X86
+
+Tue Oct 8 11:40:36 1996 Anthony Green <green@rtl.cygnus.com>
+
+ * ffi.h.in (FFI_FN): Added macro for eliminating compiler warnings.
+ Use it to case your function pointers to the proper type.
+
+ * ffi_mips.h (SIZEOF_ARG): Added magic to fix type promotion bug.
+
+ * Makefile.am (EXTRA_DIST): Added ffi_mips.h to EXTRA_DIST.
+ * Makefile: Rebuilt.
+
+ * ffi_mips.h: Created. Moved all common mips definitions here.
+
+Mon Oct 7 10:58:12 1996 Anthony Green <green@hoser.cygnus.com>
+
+ * ffi.h.in: The SGI assember is very picky about parens. Redefined
+ some macros to avoid problems.
+
+ * ffi.h.in: Added FFI_DEFAULT_ABI definitions. Also added
+ externs for pointer, and 64bit integral ffi_types.
+
+Fri Oct 4 09:51:37 1996 Anthony Green <green@hoser.cygnus.com>
+
+ * ffi.h.in: Added FFI_ABI member to ffi_cif and changed
+ function prototypes accordingly.
+ Added #define @TARGET@. Now programs including ffi.h don't
+ have to specify this themselves.
+
+Thu Oct 3 15:36:44 1996 Anthony Green <green@hoser.cygnus.com>
+
+ * ffi.h.in: Changed ffi_prep_cif's values from void* to void**
+
+ * Makefile.am (EXTRA_DIST): Added EXTRA_DIST for "make dist"
+ to work.
+ * Makefile.in: Regenerated.
+
+Wed Oct 2 10:16:59 1996 Anthony Green <green@hoser.cygnus.com>
+
+ * Makefile.am: Created
+ * Makefile.in: Generated
+
+ * ffi_common.h: Added rcsid comment
+
+Tue Oct 1 17:13:51 1996 Anthony Green <green@rtl.cygnus.com>
+
+ * ffi.h.in, ffi_common.h: Created
+
+--- libffi/src ------------------------------------------------------------
+
+Mon Oct 5 02:17:50 1998 Anthony Green <green@cygnus.com>
+
+ * arm/ffi.c, arm/sysv.S: Created.
+
+ * Makefile.am: Added arm files.
+ * Makefile.in: Rebuilt.
+
+Mon Oct 5 01:41:38 1998 Anthony Green <green@rtl.cygnus.com>
+
+ * Makefile.am (libffi_la_LDFLAGS): Incremented revision.
+
+Sun Oct 4 16:27:17 1998 Anthony Green <green@cygnus.com>
+
+ * alpha/osf.S (ffi_call_osf): Patch for DU assembler.
+
+ * ffitest.c (main): long long and long double return values work
+ for x86.
+
+Fri Apr 17 11:50:58 1998 Anthony Green <green@hoser.cygnus.com>
+
+ * Makefile.in: Rebuilt.
+
+ * ffitest.c (main): Floating point tests not executed for systems
+ with broken lond double (SunOS 4 w/ GCC).
+
+ * types.c: Fixed x86 alignment info for long long types.
+
+Thu Apr 16 07:15:28 1998 Anthony Green <green@ada.cygnus.com>
+
+ * ffitest.c: Added more notes about GCC bugs under Irix 6.
+
+Wed Apr 15 08:42:22 1998 Anthony Green <green@hoser.cygnus.com>
+
+ * ffitest.c (struct5): New test function.
+ (main): New test with struct5.
+
+Thu Mar 5 10:48:11 1998 Anthony Green <green@tootie.to.cygnus.com>
+
+ * prep_cif.c (initialize_aggregate): Fix assertion for
+ nested structures.
+
+Tue Feb 24 16:33:41 1998 Anthony Green <green@hoser.cygnus.com>
+
+ * prep_cif.c (ffi_prep_cif): Added long double support for sparc.
+
+Sun Feb 22 00:52:18 1998 Geoff Keating <geoffk@ozemail.com.au>
+
+ * powerpc/asm.h: New file.
+ * powerpc/ffi.c: New file.
+ * powerpc/sysv.S: New file.
+ * Makefile.am: PowerPC port.
+ * ffitest.c (main): Allow all tests to run even in presence of gcc
+ bug on PowerPC.
+
+1998-02-17 Anthony Green <green@hoser.cygnus.com>
+
+ * mips/ffi.c: Fixed comment typo.
+
+ * x86/ffi.c (ffi_prep_cif_machdep), x86/sysv.S (retfloat):
+ Fixed x86 long double return handling.
+
+ * types.c: Fixed x86 long double alignment info.
+
+1998-02-14 Andreas Schwab <schwab@issan.informatik.uni-dortmund.de>
+
+ * types.c: Add m68k support.
+
+ * ffitest.c (floating): Add long double parameter.
+ (return_ll, ldblit): New functions to test long long and long
+ double return value.
+ (main): Fix type error in assignment of ts[1-4]_type.elements.
+ Add tests for long long and long double arguments and return
+ values.
+
+ * prep_cif.c (ffi_prep_cif) [M68K]: Don't allocate argument for
+ struct value pointer.
+
+ * m68k/ffi.c, m68k/sysv.S: New files.
+ * Makefile.am: Add bits for m68k port. Add kludge to work around
+ automake deficiency.
+ (test): Don't require "." in $PATH.
+ * Makefile.in: Rebuilt.
+
+Wed Feb 11 07:36:50 1998 Anthony Green <green@hoser.cygnus.com>
+
+ * Makefile.in: Rebuilt.
+
+Tue Feb 10 20:56:00 1998 Richard Henderson <rth@cygnus.com>
+
+ * alpha/ffi.c, alpha/osf.S: New files.
+ * Makefile.am: Alpha port.
+
+Tue Nov 18 14:12:07 1997 Anthony Green <green@hoser.cygnus.com>
+
+ * mips/ffi.c (ffi_prep_cif_machdep): Initialize rstruct_flag
+ for n32.
+
+Tue Jun 3 17:18:20 1997 Anthony Green <green@hoser.cygnus.com>
+
+ * ffitest.c (main): Added hack to get structure tests working
+ correctly.
+
+Sat May 10 19:06:42 1997 Tom Tromey <tromey@cygnus.com>
+
+ * Makefile.in: Rebuilt.
+ * Makefile.am (EXTRA_DIST): Explicitly list all distributable
+ files in subdirs.
+ (VERSION, CC): Removed.
+
+Thu May 8 17:19:01 1997 Anthony Green <green@hoser.cygnus.com>
+
+ * Makefile.am: Many changes for new automake and libtool.
+ * Makefile.in: Rebuilt.
+
+Fri Nov 22 06:57:56 1996 Anthony Green <green@rtl.cygnus.com>
+
+ * ffitest.c (main): Fixed test case for non mips machines.
+
+Wed Nov 20 22:31:59 1996 Anthony Green <green@hoser.cygnus.com>
+
+ * types.c: Added ffi_type_void declaration.
+
+Tue Oct 29 13:07:19 1996 Anthony Green <green@rtl.cygnus.com>
+
+ * ffitest.c (main): Fixed character constants.
+ (main): Emit warning for structure test 3 failure on Sun.
+
+ * Makefile.am (VPATH): Fixed VPATH def'n so automake won't
+ strip it out.
+ Moved distdir hack from libffi to automake.
+ (ffitest): Added missing -c for $(COMPILE) (change in automake).
+ * Makefile.in: Rebuilt.
+
+Tue Oct 15 13:08:20 1996 Anthony Green <green@hoser.cygnus.com>
+
+ * Makefile.am: Added "make lint" production.
+ * Makefile.in: Rebuilt.
+
+ * prep_cif.c (STACK_ARG_SIZE): Improved STACK_ARG_SIZE macro.
+ Clean up based on LCLint output. Added funny /*@...@*/ comments to
+ annotate source.
+
+ * ffitest.c, debug.c: Cleaned up code.
+
+Mon Oct 14 12:26:56 1996 Anthony Green <green@rtl.cygnus.com>
+
+ * ffitest.c: Changes based on interface changes.
+
+ * prep_cif.c (ffi_prep_cif): Cleaned up interface based on
+ feedback from Jim Blandy.
+
+Fri Oct 11 15:53:18 1996 Anthony Green <green@rtl.cygnus.com>
+
+ * ffitest.c: Reordered tests while porting to sparc.
+ Made changes to handle lame structure passing for sparc.
+ Removed calls to fflush().
+
+ * prep_cif.c (ffi_prep_cif): Added special case for sparc
+ aggregate type arguments.
+
+Thu Oct 10 09:56:51 1996 Anthony Green <green@rtl.cygnus.com>
+
+ * ffitest.c (main): Added structure passing/returning tests.
+
+ * prep_cif.c (ffi_prep_cif): Perform proper initialization
+ of structure return types if needed.
+ (initialize_aggregate): Bug fix
+
+Wed Oct 9 16:04:20 1996 Anthony Green <green@rtl.cygnus.com>
+
+ * types.c: Added special definitions for x86 (double doesn't
+ need double word alignment).
+
+ * ffitest.c: Added many tests
+
+Tue Oct 8 09:19:22 1996 Anthony Green <green@rtl.cygnus.com>
+
+ * prep_cif.c (ffi_prep_cif): Fixed assertion.
+
+ * debug.c (ffi_assert): Must return a non void now.
+
+ * Makefile.am: Added test production.
+ * Makefile: Rebuilt.
+
+ * ffitest.c (main): Created.
+
+ * types.c: Created. Stripped common code out of */ffi.c.
+
+ * prep_cif.c: Added missing stdlib.h include.
+
+ * debug.c (ffi_type_test): Used "a" to eliminate compiler
+ warnings in non-debug builds. Included ffi_common.h.
+
+Mon Oct 7 15:36:42 1996 Anthony Green <green@rtl.cygnus.com>
+
+ * Makefile.am: Added a rule for .s -> .o
+ This is required by the SGI compiler.
+ * Makefile: Rebuilt.
+
+Fri Oct 4 09:51:08 1996 Anthony Green <green@hoser.cygnus.com>
+
+ * prep_cif.c (initialize_aggregate): Moved abi specification
+ to ffi_prep_cif().
+
+Thu Oct 3 15:37:37 1996 Anthony Green <green@hoser.cygnus.com>
+
+ * prep_cif.c (ffi_prep_cif): Changed values from void* to void**.
+ (initialize_aggregate): Fixed aggregate type initialization.
+
+ * Makefile.am (EXTRA_DIST): Added support code for "make dist".
+ * Makefile.in: Regenerated.
+
+Wed Oct 2 11:41:57 1996 Anthony Green <green@hoser.cygnus.com>
+
+ * debug.c, prep_cif: Created.
+
+ * Makefile.am: Added debug.o and prep_cif.o to OBJ.
+ * Makefile.in: Regenerated.
+
+ * Makefile.am (INCLUDES): Added missing -I../include
+ * Makefile.in: Regenerated.
+
+Tue Oct 1 17:11:51 1996 Anthony Green <green@rtl.cygnus.com>
+
+ * error.c, Makefile.am: Created.
+ * Makefile.in: Generated.
+
+--- libffi/src/x86 --------------------------------------------------------
+
+Sun Oct 4 16:27:17 1998 Anthony Green <green@cygnus.com>
+
+ * sysv.S (retlongdouble): Fixed long long return value support.
+ * ffi.c (ffi_prep_cif_machdep): Ditto.
+
+Wed May 13 04:30:33 1998 Anthony Green <green@raft.ppp.tsoft.net>
+
+ * ffi.c (ffi_prep_cif_machdep): Fixed long double return value
+ support.
+
+Wed Apr 15 08:43:20 1998 Anthony Green <green@hoser.cygnus.com>
+
+ * ffi.c (ffi_prep_args): small struct support was missing.
+
+Thu May 8 16:53:58 1997 Anthony Green <green@hoser.cygnus.com>
+
+ * objects.mak: Removed.
+
+Mon Dec 2 15:12:58 1996 Tom Tromey <tromey@cygnus.com>
+
+ * sysv.S: Use .balign, for a.out Linux boxes.
+
+Tue Oct 15 13:06:50 1996 Anthony Green <green@hoser.cygnus.com>
+
+ * ffi.c: Clean up based on LCLint output.
+ Added funny /*@...@*/ comments to annotate source.
+
+Fri Oct 11 16:43:38 1996 Anthony Green <green@rtl.cygnus.com>
+
+ * ffi.c (ffi_call): Added assertion for bad ABIs.
+
+Wed Oct 9 13:57:27 1996 Anthony Green <green@rtl.cygnus.com>
+
+ * sysv.S (retdouble): Fixed double return problems.
+
+ * ffi.c (ffi_call): Corrected fn arg definition.
+ (ffi_prep_cif_machdep): Fixed double return problems
+
+Tue Oct 8 12:12:49 1996 Anthony Green <green@rtl.cygnus.com>
+
+ * ffi.c: Moved ffi_type definitions to types.c.
+ (ffi_prep_args): Fixed type promotion bug.
+
+Mon Oct 7 15:53:06 1996 Anthony Green <green@rtl.cygnus.com>
+
+ * ffi.c (FFI_*_TYPEDEF): Removed redundant ';'
+
+Fri Oct 4 09:54:53 1996 Anthony Green <green@hoser.cygnus.com>
+
+ * ffi.c (ffi_call): Removed FFI_ABI arg, and swapped
+ remaining args.
+
+Wed Oct 2 10:07:05 1996 Anthony Green <green@hoser.cygnus.com>
+
+ * ffi.c, sysv.S, objects.mak: Created.
+ (ffi_prep_cif): cif->rvalue no longer initialized to NULL.
+ (ffi_prep_cif_machdep): Moved machine independent cif processing
+ to src/prep_cif.c. Introduced ffi_prep_cif_machdep().
+
+--- libffi/src/mips -------------------------------------------------------
+
+Tue Feb 17 17:18:07 1998 Anthony Green <green@hoser.cygnus.com>
+
+ * o32.S: Fixed typo in comment.
+
+ * ffi.c (ffi_prep_cif_machdep): Fixed argument processing.
+
+Thu May 8 16:53:58 1997 Anthony Green <green@hoser.cygnus.com>
+
+ * o32.s, n32.s: Wrappers for SGI tool support.
+
+ * objects.mak: Removed.
+
+Tue Oct 29 14:37:45 1996 Anthony Green <green@rtl.cygnus.com>
+
+ * ffi.c (ffi_prep_args): Changed int z to size_t z.
+
+Tue Oct 15 13:17:25 1996 Anthony Green <green@hoser.cygnus.com>
+
+ * n32.S: Fixed bad stack munging.
+
+ * ffi.c: Moved prototypes for ffi_call_?32() to here from
+ ffi_mips.h because extended_cif is not defined in ffi_mips.h.
+
+Mon Oct 14 12:42:02 1996 Anthony Green <green@rtl.cygnus.com>
+
+ * ffi.c: Interface changes based on feedback from Jim Blandy.
+
+Thu Oct 10 11:22:16 1996 Anthony Green <green@rtl.cygnus.com>
+
+ * n32.S, ffi.c: Lots of changes to support passing and
+ returning structures with the n32 calling convention.
+
+ * n32.S: Fixed fn pointer bug.
+
+ * ffi.c (ffi_prep_cif_machdep): Fix for o32 structure
+ return values.
+ (ffi_prep_args): Fixed n32 structure passing when structures
+ partially fit in registers.
+
+Wed Oct 9 13:49:25 1996 Anthony Green <green@rtl.cygnus.com>
+
+ * objects.mak: Added n32.o.
+
+ * n32.S: Created.
+
+ * ffi.c (ffi_prep_args): Added magic to support proper
+ n32 processing.
+
+Tue Oct 8 10:37:35 1996 Anthony Green <green@rtl.cygnus.com>
+
+ * ffi.c: Moved ffi_type definitions to types.c.
+ (ffi_prep_args): Fixed type promotion bug.
+
+ * o32.S: This code is only built for o32 compiles.
+ A lot of the #define cruft has moved to ffi_mips.h.
+
+ * ffi.c (ffi_prep_cif_machdep): Fixed arg flags. Second arg
+ is only processed if the first is either a float or double.
+
+Mon Oct 7 15:33:59 1996 Anthony Green <green@rtl.cygnus.com>
+
+ * o32.S: Modified to compile under each of o32, n32 and n64.
+
+ * ffi.c (FFI_*_TYPEDEF): Removed redundant ';'
+
+Fri Oct 4 09:53:25 1996 Anthony Green <green@hoser.cygnus.com>
+
+ * ffi.c (ffi_call): Removed FFI_ABI arg, and swapped
+ remaining args.
+
+Wed Oct 2 17:41:22 1996 Anthony Green <green@rtl.cygnus.com>
+
+ * o32.S: Removed crufty definitions.
+
+Wed Oct 2 12:53:42 1996 Anthony Green <green@hoser.cygnus.com>
+
+ * ffi.c (ffi_prep_cif): cif->rvalue no longer initialized to NULL.
+ (ffi_prep_cif_machdep): Moved all machine independent cif processing
+ to src/prep_cif.c. Introduced ffi_prep_cif_machdep. Return types
+ of FFI_TYPE_STRUCT are no different than FFI_TYPE_INT.
+
+Tue Oct 1 17:11:02 1996 Anthony Green <green@rtl.cygnus.com>
+
+ * ffi.c, o32.S, object.mak: Created
+
+--- libffi/src/sparc ------------------------------------------------------
+
+Tue Feb 24 16:33:18 1998 Anthony Green <green@hoser.cygnus.com>
+
+ * ffi.c (ffi_prep_args): Added long double support.
+
+Thu May 8 16:53:58 1997 Anthony Green <green@hoser.cygnus.com>
+
+ * objects.mak: Removed.
+
+Thu May 1 16:07:56 1997 Anthony Green <green@hoser.cygnus.com>
+
+ * v8.S: Fixed minor portability problem reported by
+ Russ McManus <mcmanr@eq.gs.com>.
+
+Tue Nov 26 14:12:43 1996 Anthony Green <green@csk3.cygnus.com>
+
+ * v8.S: Used STACKFRAME define elsewhere.
+
+ * ffi.c (ffi_prep_args): Zero out space when USING_PURIFY
+ is set.
+ (ffi_prep_cif_machdep): Allocate the correct stack frame
+ space for functions with < 6 args.
+
+Tue Oct 29 15:08:55 1996 Anthony Green <green@rtl.cygnus.com>
+
+ * ffi.c (ffi_prep_args): int z is now size_t z.
+
+Mon Oct 14 13:31:24 1996 Anthony Green <green@rtl.cygnus.com>
+
+ * v8.S (ffi_call_V8): Gordon rewrites this again. It looks
+ great now.
+
+ * ffi.c (ffi_call): The comment about hijacked registers
+ is no longer valid after gordoni hacked v8.S.
+
+ * v8.S (ffi_call_V8): Rewrote with gordoni. Much simpler.
+
+ * v8.S, ffi.c: ffi_call() had changed to accept more than
+ two args, so v8.S had to change (because it hijacks incoming
+ arg registers).
+
+ * ffi.c: Interface changes based on feedback from Jim Blandy.
+
+Thu Oct 10 17:48:16 1996 Anthony Green <green@rtl.cygnus.com>
+
+ * ffi.c, v8.S, objects.mak: Created.
+
+
diff --git a/jni/ruby/ext/fiddle/libffi-3.2.1/LICENSE b/jni/ruby/ext/fiddle/libffi-3.2.1/LICENSE
new file mode 100644
index 0000000..a66fab4
--- /dev/null
+++ b/jni/ruby/ext/fiddle/libffi-3.2.1/LICENSE
@@ -0,0 +1,21 @@
+libffi - Copyright (c) 1996-2014 Anthony Green, Red Hat, Inc and others.
+See source files for details.
+
+Permission is hereby granted, free of charge, to any person obtaining
+a copy of this software and associated documentation files (the
+``Software''), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sublicense, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice shall be
+included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
diff --git a/jni/ruby/ext/fiddle/libffi-3.2.1/Makefile.am b/jni/ruby/ext/fiddle/libffi-3.2.1/Makefile.am
new file mode 100644
index 0000000..0e40451
--- /dev/null
+++ b/jni/ruby/ext/fiddle/libffi-3.2.1/Makefile.am
@@ -0,0 +1,258 @@
+## Process this with automake to create Makefile.in
+
+AUTOMAKE_OPTIONS = foreign subdir-objects
+
+ACLOCAL_AMFLAGS = -I m4
+
+SUBDIRS = include testsuite man
+
+EXTRA_DIST = LICENSE ChangeLog.v1 ChangeLog.libgcj \
+ src/aarch64/ffi.c src/aarch64/ffitarget.h src/aarch64/sysv.S \
+ src/alpha/ffi.c src/alpha/osf.S \
+ src/alpha/ffitarget.h src/arc/ffi.c src/arc/arcompact.S \
+ src/arc/ffitarget.h src/arm/ffi.c src/arm/sysv.S \
+ src/arm/ffitarget.h src/avr32/ffi.c src/avr32/sysv.S \
+ src/avr32/ffitarget.h src/cris/ffi.c src/cris/sysv.S \
+ src/cris/ffitarget.h src/ia64/ffi.c src/ia64/ffitarget.h \
+ src/ia64/ia64_flags.h src/ia64/unix.S src/mips/ffi.c \
+ src/mips/n32.S src/mips/o32.S src/metag/ffi.c \
+ src/metag/ffitarget.h src/metag/sysv.S src/moxie/ffi.c \
+ src/moxie/ffitarget.h src/moxie/eabi.S src/mips/ffitarget.h \
+ src/m32r/ffi.c src/m32r/sysv.S src/m32r/ffitarget.h \
+ src/m68k/ffi.c src/m68k/sysv.S src/m68k/ffitarget.h \
+ src/m88k/ffi.c src/m88k/obsd.S src/m88k/ffitarget.h \
+ src/microblaze/ffi.c src/microblaze/sysv.S \
+ src/microblaze/ffitarget.h \
+ src/nios2/ffi.c src/nios2/ffitarget.h src/nios2/sysv.S \
+ src/or1k/ffi.c src/or1k/ffitarget.h src/or1k/sysv.S \
+ src/powerpc/ffi.c src/powerpc/ffi_powerpc.h \
+ src/powerpc/ffi_sysv.c src/powerpc/ffi_linux64.c \
+ src/powerpc/sysv.S src/powerpc/linux64.S \
+ src/powerpc/linux64_closure.S src/powerpc/ppc_closure.S \
+ src/powerpc/asm.h src/powerpc/aix.S src/powerpc/darwin.S \
+ src/powerpc/aix_closure.S src/powerpc/darwin_closure.S \
+ src/powerpc/ffi_darwin.c src/powerpc/ffitarget.h \
+ src/s390/ffi.c src/s390/sysv.S src/s390/ffitarget.h \
+ src/sh/ffi.c src/sh/sysv.S src/sh/ffitarget.h src/sh64/ffi.c \
+ src/sh64/sysv.S src/sh64/ffitarget.h src/sparc/v8.S \
+ src/sparc/v9.S src/sparc/ffitarget.h src/sparc/ffi.c \
+ src/x86/darwin64.S src/x86/ffi.c src/x86/sysv.S \
+ src/x86/win32.S src/x86/darwin.S src/x86/win64.S \
+ src/x86/freebsd.S src/x86/ffi64.c src/x86/unix64.S \
+ src/x86/ffitarget.h src/pa/ffitarget.h src/pa/ffi.c \
+ src/pa/linux.S src/pa/hpux32.S src/frv/ffi.c src/bfin/ffi.c \
+ src/bfin/ffitarget.h src/bfin/sysv.S src/frv/eabi.S \
+ src/frv/ffitarget.h src/dlmalloc.c src/tile/ffi.c \
+ src/tile/ffitarget.h src/tile/tile.S libtool-version \
+ src/vax/ffi.c src/vax/ffitarget.h src/vax/elfbsd.S \
+ src/xtensa/ffitarget.h src/xtensa/ffi.c src/xtensa/sysv.S \
+ ChangeLog.libffi m4/libtool.m4 m4/lt~obsolete.m4 \
+ m4/ltoptions.m4 m4/ltsugar.m4 m4/ltversion.m4 \
+ m4/ltversion.m4 src/arm/gentramp.sh src/debug.c msvcc.sh \
+ generate-darwin-source-and-headers.py \
+ libffi.xcodeproj/project.pbxproj src/arm/trampoline.S \
+ libtool-ldflags ChangeLog.libffi-3.1
+
+info_TEXINFOS = doc/libffi.texi
+
+## ################################################################
+
+##
+## This section is for make and multilib madness.
+##
+
+# Work around what appears to be a GNU make bug handling MAKEFLAGS
+# values defined in terms of make variables, as is the case for CC and
+# friends when we are called from the top level Makefile.
+AM_MAKEFLAGS = \
+ 'AR_FLAGS=$(AR_FLAGS)' \
+ 'CC_FOR_BUILD=$(CC_FOR_BUILD)' \
+ 'CFLAGS=$(CFLAGS)' \
+ 'CXXFLAGS=$(CXXFLAGS)' \
+ 'CFLAGS_FOR_BUILD=$(CFLAGS_FOR_BUILD)' \
+ 'CFLAGS_FOR_TARGET=$(CFLAGS_FOR_TARGET)' \
+ 'INSTALL=$(INSTALL)' \
+ 'INSTALL_DATA=$(INSTALL_DATA)' \
+ 'INSTALL_PROGRAM=$(INSTALL_PROGRAM)' \
+ 'INSTALL_SCRIPT=$(INSTALL_SCRIPT)' \
+ 'JC1FLAGS=$(JC1FLAGS)' \
+ 'LDFLAGS=$(LDFLAGS)' \
+ 'LIBCFLAGS=$(LIBCFLAGS)' \
+ 'LIBCFLAGS_FOR_TARGET=$(LIBCFLAGS_FOR_TARGET)' \
+ 'MAKE=$(MAKE)' \
+ 'MAKEINFO=$(MAKEINFO) $(MAKEINFOFLAGS)' \
+ 'PICFLAG=$(PICFLAG)' \
+ 'PICFLAG_FOR_TARGET=$(PICFLAG_FOR_TARGET)' \
+ 'RUNTESTFLAGS=$(RUNTESTFLAGS)' \
+ 'SHELL=$(SHELL)' \
+ 'exec_prefix=$(exec_prefix)' \
+ 'infodir=$(infodir)' \
+ 'libdir=$(libdir)' \
+ 'mandir=$(mandir)' \
+ 'prefix=$(prefix)' \
+ 'AR=$(AR)' \
+ 'AS=$(AS)' \
+ 'CC=$(CC)' \
+ 'CXX=$(CXX)' \
+ 'LD=$(LD)' \
+ 'NM=$(NM)' \
+ 'RANLIB=$(RANLIB)' \
+ 'DESTDIR=$(DESTDIR)'
+
+# Subdir rules rely on $(FLAGS_TO_PASS)
+FLAGS_TO_PASS = $(AM_MAKEFLAGS)
+
+MAKEOVERRIDES=
+
+toolexeclib_LTLIBRARIES = libffi.la
+noinst_LTLIBRARIES = libffi_convenience.la
+
+libffi_la_SOURCES = src/prep_cif.c src/types.c \
+ src/raw_api.c src/java_raw_api.c src/closures.c
+
+pkgconfigdir = $(libdir)/pkgconfig
+pkgconfig_DATA = libffi.pc
+
+nodist_libffi_la_SOURCES =
+
+if FFI_DEBUG
+nodist_libffi_la_SOURCES += src/debug.c
+endif
+
+if MIPS
+nodist_libffi_la_SOURCES += src/mips/ffi.c src/mips/o32.S src/mips/n32.S
+endif
+if BFIN
+nodist_libffi_la_SOURCES += src/bfin/ffi.c src/bfin/sysv.S
+endif
+if X86
+nodist_libffi_la_SOURCES += src/x86/ffi.c src/x86/sysv.S src/x86/win32.S
+endif
+if X86_FREEBSD
+nodist_libffi_la_SOURCES += src/x86/ffi.c src/x86/freebsd.S src/x86/win32.S
+endif
+if X86_WIN32
+nodist_libffi_la_SOURCES += src/x86/ffi.c src/x86/win32.S
+endif
+if X86_WIN64
+nodist_libffi_la_SOURCES += src/x86/ffi.c src/x86/win64.S
+endif
+if X86_DARWIN
+nodist_libffi_la_SOURCES += src/x86/ffi.c src/x86/darwin.S src/x86/ffi64.c src/x86/darwin64.S
+if X86_DARWIN32
+nodist_libffi_la_SOURCES += src/x86/win32.S
+endif
+endif
+if SPARC
+nodist_libffi_la_SOURCES += src/sparc/ffi.c src/sparc/v8.S src/sparc/v9.S
+endif
+if ALPHA
+nodist_libffi_la_SOURCES += src/alpha/ffi.c src/alpha/osf.S
+endif
+if IA64
+nodist_libffi_la_SOURCES += src/ia64/ffi.c src/ia64/unix.S
+endif
+if M32R
+nodist_libffi_la_SOURCES += src/m32r/sysv.S src/m32r/ffi.c
+endif
+if M68K
+nodist_libffi_la_SOURCES += src/m68k/ffi.c src/m68k/sysv.S
+endif
+if M88K
+nodist_libffi_la_SOURCES += src/m88k/ffi.c src/m88k/obsd.S
+endif
+if MOXIE
+nodist_libffi_la_SOURCES += src/moxie/ffi.c src/moxie/eabi.S
+endif
+if MICROBLAZE
+nodist_libffi_la_SOURCES += src/microblaze/ffi.c src/microblaze/sysv.S
+endif
+if NIOS2
+nodist_libffi_la_SOURCES += src/nios2/sysv.S src/nios2/ffi.c
+endif
+if OR1K
+nodist_libffi_la_SOURCES += src/or1k/sysv.S src/or1k/ffi.c
+endif
+if POWERPC
+nodist_libffi_la_SOURCES += src/powerpc/ffi.c src/powerpc/ffi_sysv.c src/powerpc/ffi_linux64.c src/powerpc/sysv.S src/powerpc/ppc_closure.S src/powerpc/linux64.S src/powerpc/linux64_closure.S
+endif
+if POWERPC_AIX
+nodist_libffi_la_SOURCES += src/powerpc/ffi_darwin.c src/powerpc/aix.S src/powerpc/aix_closure.S
+endif
+if POWERPC_DARWIN
+nodist_libffi_la_SOURCES += src/powerpc/ffi_darwin.c src/powerpc/darwin.S src/powerpc/darwin_closure.S
+endif
+if POWERPC_FREEBSD
+nodist_libffi_la_SOURCES += src/powerpc/ffi.c src/powerpc/ffi_sysv.c src/powerpc/sysv.S src/powerpc/ppc_closure.S
+endif
+if AARCH64
+nodist_libffi_la_SOURCES += src/aarch64/sysv.S src/aarch64/ffi.c
+endif
+if ARC
+nodist_libffi_la_SOURCES += src/arc/arcompact.S src/arc/ffi.c
+endif
+if ARM
+nodist_libffi_la_SOURCES += src/arm/sysv.S src/arm/ffi.c
+if FFI_EXEC_TRAMPOLINE_TABLE
+nodist_libffi_la_SOURCES += src/arm/trampoline.S
+endif
+endif
+if AVR32
+nodist_libffi_la_SOURCES += src/avr32/sysv.S src/avr32/ffi.c
+endif
+if LIBFFI_CRIS
+nodist_libffi_la_SOURCES += src/cris/sysv.S src/cris/ffi.c
+endif
+if FRV
+nodist_libffi_la_SOURCES += src/frv/eabi.S src/frv/ffi.c
+endif
+if S390
+nodist_libffi_la_SOURCES += src/s390/sysv.S src/s390/ffi.c
+endif
+if X86_64
+nodist_libffi_la_SOURCES += src/x86/ffi64.c src/x86/unix64.S src/x86/ffi.c src/x86/sysv.S
+endif
+if SH
+nodist_libffi_la_SOURCES += src/sh/sysv.S src/sh/ffi.c
+endif
+if SH64
+nodist_libffi_la_SOURCES += src/sh64/sysv.S src/sh64/ffi.c
+endif
+if PA_LINUX
+nodist_libffi_la_SOURCES += src/pa/linux.S src/pa/ffi.c
+endif
+if PA_HPUX
+nodist_libffi_la_SOURCES += src/pa/hpux32.S src/pa/ffi.c
+endif
+if TILE
+nodist_libffi_la_SOURCES += src/tile/tile.S src/tile/ffi.c
+endif
+if XTENSA
+nodist_libffi_la_SOURCES += src/xtensa/sysv.S src/xtensa/ffi.c
+endif
+if METAG
+nodist_libffi_la_SOURCES += src/metag/sysv.S src/metag/ffi.c
+endif
+if VAX
+nodist_libffi_la_SOURCES += src/vax/elfbsd.S src/vax/ffi.c
+endif
+
+libffi_convenience_la_SOURCES = $(libffi_la_SOURCES)
+nodist_libffi_convenience_la_SOURCES = $(nodist_libffi_la_SOURCES)
+
+LTLDFLAGS = $(shell $(SHELL) $(top_srcdir)/libtool-ldflags $(LDFLAGS))
+
+AM_CFLAGS =
+if FFI_DEBUG
+# Build debug. Define FFI_DEBUG on the commandline so that, when building with
+# MSVC, it can link against the debug CRT.
+AM_CFLAGS += -DFFI_DEBUG
+endif
+
+libffi_la_LDFLAGS = -no-undefined -version-info `grep -v '^\#' $(srcdir)/libtool-version` $(LTLDFLAGS) $(AM_LTLDFLAGS)
+
+AM_CPPFLAGS = -I. -I$(top_srcdir)/include -Iinclude -I$(top_srcdir)/src
+AM_CCASFLAGS = $(AM_CPPFLAGS)
+
+dist-hook:
+ if [ -d $(top_srcdir)/.git ] ; then (cd $(top_srcdir); git log --no-decorate) ; else echo 'See git log for history.' ; fi > $(distdir)/ChangeLog
diff --git a/jni/ruby/ext/fiddle/libffi-3.2.1/Makefile.in b/jni/ruby/ext/fiddle/libffi-3.2.1/Makefile.in
new file mode 100644
index 0000000..dcc5f47
--- /dev/null
+++ b/jni/ruby/ext/fiddle/libffi-3.2.1/Makefile.in
@@ -0,0 +1,2177 @@
+# Makefile.in generated by automake 1.13.4 from Makefile.am.
+# @configure_input@
+
+# Copyright (C) 1994-2013 Free Software Foundation, Inc.
+
+# This Makefile.in is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
+# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE.
+
+@SET_MAKE@
+
+
+VPATH = @srcdir@
+am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)'
+am__make_running_with_option = \
+ case $${target_option-} in \
+ ?) ;; \
+ *) echo "am__make_running_with_option: internal error: invalid" \
+ "target option '$${target_option-}' specified" >&2; \
+ exit 1;; \
+ esac; \
+ has_opt=no; \
+ sane_makeflags=$$MAKEFLAGS; \
+ if $(am__is_gnu_make); then \
+ sane_makeflags=$$MFLAGS; \
+ else \
+ case $$MAKEFLAGS in \
+ *\\[\ \ ]*) \
+ bs=\\; \
+ sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \
+ | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \
+ esac; \
+ fi; \
+ skip_next=no; \
+ strip_trailopt () \
+ { \
+ flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \
+ }; \
+ for flg in $$sane_makeflags; do \
+ test $$skip_next = yes && { skip_next=no; continue; }; \
+ case $$flg in \
+ *=*|--*) continue;; \
+ -*I) strip_trailopt 'I'; skip_next=yes;; \
+ -*I?*) strip_trailopt 'I';; \
+ -*O) strip_trailopt 'O'; skip_next=yes;; \
+ -*O?*) strip_trailopt 'O';; \
+ -*l) strip_trailopt 'l'; skip_next=yes;; \
+ -*l?*) strip_trailopt 'l';; \
+ -[dEDm]) skip_next=yes;; \
+ -[JT]) skip_next=yes;; \
+ esac; \
+ case $$flg in \
+ *$$target_option*) has_opt=yes; break;; \
+ esac; \
+ done; \
+ test $$has_opt = yes
+am__make_dryrun = (target_option=n; $(am__make_running_with_option))
+am__make_keepgoing = (target_option=k; $(am__make_running_with_option))
+pkgdatadir = $(datadir)/@PACKAGE@
+pkgincludedir = $(includedir)/@PACKAGE@
+pkglibdir = $(libdir)/@PACKAGE@
+pkglibexecdir = $(libexecdir)/@PACKAGE@
+am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
+install_sh_DATA = $(install_sh) -c -m 644
+install_sh_PROGRAM = $(install_sh) -c
+install_sh_SCRIPT = $(install_sh) -c
+INSTALL_HEADER = $(INSTALL_DATA)
+transform = $(program_transform_name)
+NORMAL_INSTALL = :
+PRE_INSTALL = :
+POST_INSTALL = :
+NORMAL_UNINSTALL = :
+PRE_UNINSTALL = :
+POST_UNINSTALL = :
+build_triplet = @build@
+host_triplet = @host@
+target_triplet = @target@
+@FFI_DEBUG_TRUE@am__append_1 = src/debug.c
+@MIPS_TRUE@am__append_2 = src/mips/ffi.c src/mips/o32.S src/mips/n32.S
+@BFIN_TRUE@am__append_3 = src/bfin/ffi.c src/bfin/sysv.S
+@X86_TRUE@am__append_4 = src/x86/ffi.c src/x86/sysv.S src/x86/win32.S
+@X86_FREEBSD_TRUE@am__append_5 = src/x86/ffi.c src/x86/freebsd.S src/x86/win32.S
+@X86_WIN32_TRUE@am__append_6 = src/x86/ffi.c src/x86/win32.S
+@X86_WIN64_TRUE@am__append_7 = src/x86/ffi.c src/x86/win64.S
+@X86_DARWIN_TRUE@am__append_8 = src/x86/ffi.c src/x86/darwin.S src/x86/ffi64.c src/x86/darwin64.S
+@X86_DARWIN32_TRUE@@X86_DARWIN_TRUE@am__append_9 = src/x86/win32.S
+@SPARC_TRUE@am__append_10 = src/sparc/ffi.c src/sparc/v8.S src/sparc/v9.S
+@ALPHA_TRUE@am__append_11 = src/alpha/ffi.c src/alpha/osf.S
+@IA64_TRUE@am__append_12 = src/ia64/ffi.c src/ia64/unix.S
+@M32R_TRUE@am__append_13 = src/m32r/sysv.S src/m32r/ffi.c
+@M68K_TRUE@am__append_14 = src/m68k/ffi.c src/m68k/sysv.S
+@M88K_TRUE@am__append_15 = src/m88k/ffi.c src/m88k/obsd.S
+@MOXIE_TRUE@am__append_16 = src/moxie/ffi.c src/moxie/eabi.S
+@MICROBLAZE_TRUE@am__append_17 = src/microblaze/ffi.c src/microblaze/sysv.S
+@NIOS2_TRUE@am__append_18 = src/nios2/sysv.S src/nios2/ffi.c
+@OR1K_TRUE@am__append_19 = src/or1k/sysv.S src/or1k/ffi.c
+@POWERPC_TRUE@am__append_20 = src/powerpc/ffi.c src/powerpc/ffi_sysv.c src/powerpc/ffi_linux64.c src/powerpc/sysv.S src/powerpc/ppc_closure.S src/powerpc/linux64.S src/powerpc/linux64_closure.S
+@POWERPC_AIX_TRUE@am__append_21 = src/powerpc/ffi_darwin.c src/powerpc/aix.S src/powerpc/aix_closure.S
+@POWERPC_DARWIN_TRUE@am__append_22 = src/powerpc/ffi_darwin.c src/powerpc/darwin.S src/powerpc/darwin_closure.S
+@POWERPC_FREEBSD_TRUE@am__append_23 = src/powerpc/ffi.c src/powerpc/ffi_sysv.c src/powerpc/sysv.S src/powerpc/ppc_closure.S
+@AARCH64_TRUE@am__append_24 = src/aarch64/sysv.S src/aarch64/ffi.c
+@ARC_TRUE@am__append_25 = src/arc/arcompact.S src/arc/ffi.c
+@ARM_TRUE@am__append_26 = src/arm/sysv.S src/arm/ffi.c
+@ARM_TRUE@@FFI_EXEC_TRAMPOLINE_TABLE_TRUE@am__append_27 = src/arm/trampoline.S
+@AVR32_TRUE@am__append_28 = src/avr32/sysv.S src/avr32/ffi.c
+@LIBFFI_CRIS_TRUE@am__append_29 = src/cris/sysv.S src/cris/ffi.c
+@FRV_TRUE@am__append_30 = src/frv/eabi.S src/frv/ffi.c
+@S390_TRUE@am__append_31 = src/s390/sysv.S src/s390/ffi.c
+@X86_64_TRUE@am__append_32 = src/x86/ffi64.c src/x86/unix64.S src/x86/ffi.c src/x86/sysv.S
+@SH_TRUE@am__append_33 = src/sh/sysv.S src/sh/ffi.c
+@SH64_TRUE@am__append_34 = src/sh64/sysv.S src/sh64/ffi.c
+@PA_LINUX_TRUE@am__append_35 = src/pa/linux.S src/pa/ffi.c
+@PA_HPUX_TRUE@am__append_36 = src/pa/hpux32.S src/pa/ffi.c
+@TILE_TRUE@am__append_37 = src/tile/tile.S src/tile/ffi.c
+@XTENSA_TRUE@am__append_38 = src/xtensa/sysv.S src/xtensa/ffi.c
+@METAG_TRUE@am__append_39 = src/metag/sysv.S src/metag/ffi.c
+@VAX_TRUE@am__append_40 = src/vax/elfbsd.S src/vax/ffi.c
+# Build debug. Define FFI_DEBUG on the commandline so that, when building with
+# MSVC, it can link against the debug CRT.
+@FFI_DEBUG_TRUE@am__append_41 = -DFFI_DEBUG
+subdir = .
+DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am \
+ $(top_srcdir)/configure $(am__configure_deps) \
+ $(srcdir)/fficonfig.h.in $(srcdir)/libffi.pc.in depcomp \
+ mdate-sh $(srcdir)/doc/version.texi $(srcdir)/doc/stamp-vti \
+ texinfo.tex README compile config.guess config.sub install-sh \
+ missing ltmain.sh
+ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
+am__aclocal_m4_deps = $(top_srcdir)/m4/asmcfi.m4 \
+ $(top_srcdir)/m4/ax_append_flag.m4 \
+ $(top_srcdir)/m4/ax_cc_maxopt.m4 \
+ $(top_srcdir)/m4/ax_cflags_warn_all.m4 \
+ $(top_srcdir)/m4/ax_check_compile_flag.m4 \
+ $(top_srcdir)/m4/ax_compiler_vendor.m4 \
+ $(top_srcdir)/m4/ax_configure_args.m4 \
+ $(top_srcdir)/m4/ax_enable_builddir.m4 \
+ $(top_srcdir)/m4/ax_gcc_archflag.m4 \
+ $(top_srcdir)/m4/ax_gcc_x86_cpuid.m4 \
+ $(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \
+ $(top_srcdir)/m4/ltsugar.m4 $(top_srcdir)/m4/ltversion.m4 \
+ $(top_srcdir)/m4/lt~obsolete.m4 $(top_srcdir)/acinclude.m4 \
+ $(top_srcdir)/configure.ac
+am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
+ $(ACLOCAL_M4)
+am__CONFIG_DISTCLEAN_FILES = config.status config.cache config.log \
+ configure.lineno config.status.lineno
+mkinstalldirs = $(install_sh) -d
+CONFIG_HEADER = fficonfig.h
+CONFIG_CLEAN_FILES = libffi.pc
+CONFIG_CLEAN_VPATH_FILES =
+am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`;
+am__vpath_adj = case $$p in \
+ $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \
+ *) f=$$p;; \
+ esac;
+am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`;
+am__install_max = 40
+am__nobase_strip_setup = \
+ srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'`
+am__nobase_strip = \
+ for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||"
+am__nobase_list = $(am__nobase_strip_setup); \
+ for p in $$list; do echo "$$p $$p"; done | \
+ sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \
+ $(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \
+ if (++n[$$2] == $(am__install_max)) \
+ { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \
+ END { for (dir in files) print dir, files[dir] }'
+am__base_list = \
+ sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \
+ sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g'
+am__uninstall_files_from_dir = { \
+ test -z "$$files" \
+ || { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \
+ || { echo " ( cd '$$dir' && rm -f" $$files ")"; \
+ $(am__cd) "$$dir" && rm -f $$files; }; \
+ }
+am__installdirs = "$(DESTDIR)$(toolexeclibdir)" "$(DESTDIR)$(infodir)" \
+ "$(DESTDIR)$(pkgconfigdir)"
+LTLIBRARIES = $(noinst_LTLIBRARIES) $(toolexeclib_LTLIBRARIES)
+libffi_la_LIBADD =
+am__dirstamp = $(am__leading_dot)dirstamp
+am_libffi_la_OBJECTS = src/prep_cif.lo src/types.lo src/raw_api.lo \
+ src/java_raw_api.lo src/closures.lo
+@FFI_DEBUG_TRUE@am__objects_1 = src/debug.lo
+@MIPS_TRUE@am__objects_2 = src/mips/ffi.lo src/mips/o32.lo \
+@MIPS_TRUE@ src/mips/n32.lo
+@BFIN_TRUE@am__objects_3 = src/bfin/ffi.lo src/bfin/sysv.lo
+@X86_TRUE@am__objects_4 = src/x86/ffi.lo src/x86/sysv.lo \
+@X86_TRUE@ src/x86/win32.lo
+@X86_FREEBSD_TRUE@am__objects_5 = src/x86/ffi.lo src/x86/freebsd.lo \
+@X86_FREEBSD_TRUE@ src/x86/win32.lo
+@X86_WIN32_TRUE@am__objects_6 = src/x86/ffi.lo src/x86/win32.lo
+@X86_WIN64_TRUE@am__objects_7 = src/x86/ffi.lo src/x86/win64.lo
+@X86_DARWIN_TRUE@am__objects_8 = src/x86/ffi.lo src/x86/darwin.lo \
+@X86_DARWIN_TRUE@ src/x86/ffi64.lo src/x86/darwin64.lo
+@X86_DARWIN32_TRUE@@X86_DARWIN_TRUE@am__objects_9 = src/x86/win32.lo
+@SPARC_TRUE@am__objects_10 = src/sparc/ffi.lo src/sparc/v8.lo \
+@SPARC_TRUE@ src/sparc/v9.lo
+@ALPHA_TRUE@am__objects_11 = src/alpha/ffi.lo src/alpha/osf.lo
+@IA64_TRUE@am__objects_12 = src/ia64/ffi.lo src/ia64/unix.lo
+@M32R_TRUE@am__objects_13 = src/m32r/sysv.lo src/m32r/ffi.lo
+@M68K_TRUE@am__objects_14 = src/m68k/ffi.lo src/m68k/sysv.lo
+@M88K_TRUE@am__objects_15 = src/m88k/ffi.lo src/m88k/obsd.lo
+@MOXIE_TRUE@am__objects_16 = src/moxie/ffi.lo src/moxie/eabi.lo
+@MICROBLAZE_TRUE@am__objects_17 = src/microblaze/ffi.lo \
+@MICROBLAZE_TRUE@ src/microblaze/sysv.lo
+@NIOS2_TRUE@am__objects_18 = src/nios2/sysv.lo src/nios2/ffi.lo
+@OR1K_TRUE@am__objects_19 = src/or1k/sysv.lo src/or1k/ffi.lo
+@POWERPC_TRUE@am__objects_20 = src/powerpc/ffi.lo \
+@POWERPC_TRUE@ src/powerpc/ffi_sysv.lo \
+@POWERPC_TRUE@ src/powerpc/ffi_linux64.lo src/powerpc/sysv.lo \
+@POWERPC_TRUE@ src/powerpc/ppc_closure.lo \
+@POWERPC_TRUE@ src/powerpc/linux64.lo \
+@POWERPC_TRUE@ src/powerpc/linux64_closure.lo
+@POWERPC_AIX_TRUE@am__objects_21 = src/powerpc/ffi_darwin.lo \
+@POWERPC_AIX_TRUE@ src/powerpc/aix.lo \
+@POWERPC_AIX_TRUE@ src/powerpc/aix_closure.lo
+@POWERPC_DARWIN_TRUE@am__objects_22 = src/powerpc/ffi_darwin.lo \
+@POWERPC_DARWIN_TRUE@ src/powerpc/darwin.lo \
+@POWERPC_DARWIN_TRUE@ src/powerpc/darwin_closure.lo
+@POWERPC_FREEBSD_TRUE@am__objects_23 = src/powerpc/ffi.lo \
+@POWERPC_FREEBSD_TRUE@ src/powerpc/ffi_sysv.lo \
+@POWERPC_FREEBSD_TRUE@ src/powerpc/sysv.lo \
+@POWERPC_FREEBSD_TRUE@ src/powerpc/ppc_closure.lo
+@AARCH64_TRUE@am__objects_24 = src/aarch64/sysv.lo src/aarch64/ffi.lo
+@ARC_TRUE@am__objects_25 = src/arc/arcompact.lo src/arc/ffi.lo
+@ARM_TRUE@am__objects_26 = src/arm/sysv.lo src/arm/ffi.lo
+@ARM_TRUE@@FFI_EXEC_TRAMPOLINE_TABLE_TRUE@am__objects_27 = src/arm/trampoline.lo
+@AVR32_TRUE@am__objects_28 = src/avr32/sysv.lo src/avr32/ffi.lo
+@LIBFFI_CRIS_TRUE@am__objects_29 = src/cris/sysv.lo src/cris/ffi.lo
+@FRV_TRUE@am__objects_30 = src/frv/eabi.lo src/frv/ffi.lo
+@S390_TRUE@am__objects_31 = src/s390/sysv.lo src/s390/ffi.lo
+@X86_64_TRUE@am__objects_32 = src/x86/ffi64.lo src/x86/unix64.lo \
+@X86_64_TRUE@ src/x86/ffi.lo src/x86/sysv.lo
+@SH_TRUE@am__objects_33 = src/sh/sysv.lo src/sh/ffi.lo
+@SH64_TRUE@am__objects_34 = src/sh64/sysv.lo src/sh64/ffi.lo
+@PA_LINUX_TRUE@am__objects_35 = src/pa/linux.lo src/pa/ffi.lo
+@PA_HPUX_TRUE@am__objects_36 = src/pa/hpux32.lo src/pa/ffi.lo
+@TILE_TRUE@am__objects_37 = src/tile/tile.lo src/tile/ffi.lo
+@XTENSA_TRUE@am__objects_38 = src/xtensa/sysv.lo src/xtensa/ffi.lo
+@METAG_TRUE@am__objects_39 = src/metag/sysv.lo src/metag/ffi.lo
+@VAX_TRUE@am__objects_40 = src/vax/elfbsd.lo src/vax/ffi.lo
+nodist_libffi_la_OBJECTS = $(am__objects_1) $(am__objects_2) \
+ $(am__objects_3) $(am__objects_4) $(am__objects_5) \
+ $(am__objects_6) $(am__objects_7) $(am__objects_8) \
+ $(am__objects_9) $(am__objects_10) $(am__objects_11) \
+ $(am__objects_12) $(am__objects_13) $(am__objects_14) \
+ $(am__objects_15) $(am__objects_16) $(am__objects_17) \
+ $(am__objects_18) $(am__objects_19) $(am__objects_20) \
+ $(am__objects_21) $(am__objects_22) $(am__objects_23) \
+ $(am__objects_24) $(am__objects_25) $(am__objects_26) \
+ $(am__objects_27) $(am__objects_28) $(am__objects_29) \
+ $(am__objects_30) $(am__objects_31) $(am__objects_32) \
+ $(am__objects_33) $(am__objects_34) $(am__objects_35) \
+ $(am__objects_36) $(am__objects_37) $(am__objects_38) \
+ $(am__objects_39) $(am__objects_40)
+libffi_la_OBJECTS = $(am_libffi_la_OBJECTS) \
+ $(nodist_libffi_la_OBJECTS)
+AM_V_lt = $(am__v_lt_@AM_V@)
+am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@)
+am__v_lt_0 = --silent
+am__v_lt_1 =
+libffi_la_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
+ $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
+ $(libffi_la_LDFLAGS) $(LDFLAGS) -o $@
+libffi_convenience_la_LIBADD =
+am__objects_41 = src/prep_cif.lo src/types.lo src/raw_api.lo \
+ src/java_raw_api.lo src/closures.lo
+am_libffi_convenience_la_OBJECTS = $(am__objects_41)
+am__objects_42 = $(am__objects_1) $(am__objects_2) $(am__objects_3) \
+ $(am__objects_4) $(am__objects_5) $(am__objects_6) \
+ $(am__objects_7) $(am__objects_8) $(am__objects_9) \
+ $(am__objects_10) $(am__objects_11) $(am__objects_12) \
+ $(am__objects_13) $(am__objects_14) $(am__objects_15) \
+ $(am__objects_16) $(am__objects_17) $(am__objects_18) \
+ $(am__objects_19) $(am__objects_20) $(am__objects_21) \
+ $(am__objects_22) $(am__objects_23) $(am__objects_24) \
+ $(am__objects_25) $(am__objects_26) $(am__objects_27) \
+ $(am__objects_28) $(am__objects_29) $(am__objects_30) \
+ $(am__objects_31) $(am__objects_32) $(am__objects_33) \
+ $(am__objects_34) $(am__objects_35) $(am__objects_36) \
+ $(am__objects_37) $(am__objects_38) $(am__objects_39) \
+ $(am__objects_40)
+nodist_libffi_convenience_la_OBJECTS = $(am__objects_42)
+libffi_convenience_la_OBJECTS = $(am_libffi_convenience_la_OBJECTS) \
+ $(nodist_libffi_convenience_la_OBJECTS)
+AM_V_P = $(am__v_P_@AM_V@)
+am__v_P_ = $(am__v_P_@AM_DEFAULT_V@)
+am__v_P_0 = false
+am__v_P_1 = :
+AM_V_GEN = $(am__v_GEN_@AM_V@)
+am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@)
+am__v_GEN_0 = @echo " GEN " $@;
+am__v_GEN_1 =
+AM_V_at = $(am__v_at_@AM_V@)
+am__v_at_ = $(am__v_at_@AM_DEFAULT_V@)
+am__v_at_0 = @
+am__v_at_1 =
+DEFAULT_INCLUDES = -I.@am__isrc@
+depcomp = $(SHELL) $(top_srcdir)/depcomp
+am__depfiles_maybe = depfiles
+am__mv = mv -f
+CPPASCOMPILE = $(CCAS) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \
+ $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CCASFLAGS) $(CCASFLAGS)
+LTCPPASCOMPILE = $(LIBTOOL) $(AM_V_lt) $(AM_LIBTOOLFLAGS) \
+ $(LIBTOOLFLAGS) --mode=compile $(CCAS) $(DEFS) \
+ $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \
+ $(AM_CCASFLAGS) $(CCASFLAGS)
+AM_V_CPPAS = $(am__v_CPPAS_@AM_V@)
+am__v_CPPAS_ = $(am__v_CPPAS_@AM_DEFAULT_V@)
+am__v_CPPAS_0 = @echo " CPPAS " $@;
+am__v_CPPAS_1 =
+COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
+ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
+LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
+ $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \
+ $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \
+ $(AM_CFLAGS) $(CFLAGS)
+AM_V_CC = $(am__v_CC_@AM_V@)
+am__v_CC_ = $(am__v_CC_@AM_DEFAULT_V@)
+am__v_CC_0 = @echo " CC " $@;
+am__v_CC_1 =
+CCLD = $(CC)
+LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
+ $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
+ $(AM_LDFLAGS) $(LDFLAGS) -o $@
+AM_V_CCLD = $(am__v_CCLD_@AM_V@)
+am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@)
+am__v_CCLD_0 = @echo " CCLD " $@;
+am__v_CCLD_1 =
+SOURCES = $(libffi_la_SOURCES) $(nodist_libffi_la_SOURCES) \
+ $(libffi_convenience_la_SOURCES) \
+ $(nodist_libffi_convenience_la_SOURCES)
+DIST_SOURCES = $(libffi_la_SOURCES) $(libffi_convenience_la_SOURCES)
+AM_V_DVIPS = $(am__v_DVIPS_@AM_V@)
+am__v_DVIPS_ = $(am__v_DVIPS_@AM_DEFAULT_V@)
+am__v_DVIPS_0 = @echo " DVIPS " $@;
+am__v_DVIPS_1 =
+AM_V_MAKEINFO = $(am__v_MAKEINFO_@AM_V@)
+am__v_MAKEINFO_ = $(am__v_MAKEINFO_@AM_DEFAULT_V@)
+am__v_MAKEINFO_0 = @echo " MAKEINFO" $@;
+am__v_MAKEINFO_1 =
+AM_V_INFOHTML = $(am__v_INFOHTML_@AM_V@)
+am__v_INFOHTML_ = $(am__v_INFOHTML_@AM_DEFAULT_V@)
+am__v_INFOHTML_0 = @echo " INFOHTML" $@;
+am__v_INFOHTML_1 =
+AM_V_TEXI2DVI = $(am__v_TEXI2DVI_@AM_V@)
+am__v_TEXI2DVI_ = $(am__v_TEXI2DVI_@AM_DEFAULT_V@)
+am__v_TEXI2DVI_0 = @echo " TEXI2DVI" $@;
+am__v_TEXI2DVI_1 =
+AM_V_TEXI2PDF = $(am__v_TEXI2PDF_@AM_V@)
+am__v_TEXI2PDF_ = $(am__v_TEXI2PDF_@AM_DEFAULT_V@)
+am__v_TEXI2PDF_0 = @echo " TEXI2PDF" $@;
+am__v_TEXI2PDF_1 =
+AM_V_texinfo = $(am__v_texinfo_@AM_V@)
+am__v_texinfo_ = $(am__v_texinfo_@AM_DEFAULT_V@)
+am__v_texinfo_0 = -q
+am__v_texinfo_1 =
+AM_V_texidevnull = $(am__v_texidevnull_@AM_V@)
+am__v_texidevnull_ = $(am__v_texidevnull_@AM_DEFAULT_V@)
+am__v_texidevnull_0 = > /dev/null
+am__v_texidevnull_1 =
+INFO_DEPS = $(srcdir)/doc/libffi.info
+am__TEXINFO_TEX_DIR = $(srcdir)
+DVIS = doc/libffi.dvi
+PDFS = doc/libffi.pdf
+PSS = doc/libffi.ps
+HTMLS = doc/libffi.html
+TEXINFOS = doc/libffi.texi
+TEXI2DVI = texi2dvi
+TEXI2PDF = $(TEXI2DVI) --pdf --batch
+MAKEINFOHTML = $(MAKEINFO) --html
+AM_MAKEINFOHTMLFLAGS = $(AM_MAKEINFOFLAGS)
+DVIPS = dvips
+RECURSIVE_TARGETS = all-recursive check-recursive cscopelist-recursive \
+ ctags-recursive dvi-recursive html-recursive info-recursive \
+ install-data-recursive install-dvi-recursive \
+ install-exec-recursive install-html-recursive \
+ install-info-recursive install-pdf-recursive \
+ install-ps-recursive install-recursive installcheck-recursive \
+ installdirs-recursive pdf-recursive ps-recursive \
+ tags-recursive uninstall-recursive
+am__can_run_installinfo = \
+ case $$AM_UPDATE_INFO_DIR in \
+ n|no|NO) false;; \
+ *) (install-info --version) >/dev/null 2>&1;; \
+ esac
+DATA = $(pkgconfig_DATA)
+RECURSIVE_CLEAN_TARGETS = mostlyclean-recursive clean-recursive \
+ distclean-recursive maintainer-clean-recursive
+am__recursive_targets = \
+ $(RECURSIVE_TARGETS) \
+ $(RECURSIVE_CLEAN_TARGETS) \
+ $(am__extra_recursive_targets)
+AM_RECURSIVE_TARGETS = $(am__recursive_targets:-recursive=) TAGS CTAGS \
+ cscope distdir dist dist-all distcheck
+am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) \
+ $(LISP)fficonfig.h.in
+# Read a list of newline-separated strings from the standard input,
+# and print each of them once, without duplicates. Input order is
+# *not* preserved.
+am__uniquify_input = $(AWK) '\
+ BEGIN { nonempty = 0; } \
+ { items[$$0] = 1; nonempty = 1; } \
+ END { if (nonempty) { for (i in items) print i; }; } \
+'
+# Make sure the list of sources is unique. This is necessary because,
+# e.g., the same source file might be shared among _SOURCES variables
+# for different programs/libraries.
+am__define_uniq_tagged_files = \
+ list='$(am__tagged_files)'; \
+ unique=`for i in $$list; do \
+ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+ done | $(am__uniquify_input)`
+ETAGS = etags
+CTAGS = ctags
+CSCOPE = cscope
+DIST_SUBDIRS = $(SUBDIRS)
+DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
+distdir = $(PACKAGE)-$(VERSION)
+top_distdir = $(distdir)
+am__remove_distdir = \
+ if test -d "$(distdir)"; then \
+ find "$(distdir)" -type d ! -perm -200 -exec chmod u+w {} ';' \
+ && rm -rf "$(distdir)" \
+ || { sleep 5 && rm -rf "$(distdir)"; }; \
+ else :; fi
+am__post_remove_distdir = $(am__remove_distdir)
+am__relativize = \
+ dir0=`pwd`; \
+ sed_first='s,^\([^/]*\)/.*$$,\1,'; \
+ sed_rest='s,^[^/]*/*,,'; \
+ sed_last='s,^.*/\([^/]*\)$$,\1,'; \
+ sed_butlast='s,/*[^/]*$$,,'; \
+ while test -n "$$dir1"; do \
+ first=`echo "$$dir1" | sed -e "$$sed_first"`; \
+ if test "$$first" != "."; then \
+ if test "$$first" = ".."; then \
+ dir2=`echo "$$dir0" | sed -e "$$sed_last"`/"$$dir2"; \
+ dir0=`echo "$$dir0" | sed -e "$$sed_butlast"`; \
+ else \
+ first2=`echo "$$dir2" | sed -e "$$sed_first"`; \
+ if test "$$first2" = "$$first"; then \
+ dir2=`echo "$$dir2" | sed -e "$$sed_rest"`; \
+ else \
+ dir2="../$$dir2"; \
+ fi; \
+ dir0="$$dir0"/"$$first"; \
+ fi; \
+ fi; \
+ dir1=`echo "$$dir1" | sed -e "$$sed_rest"`; \
+ done; \
+ reldir="$$dir2"
+DIST_ARCHIVES = $(distdir).tar.gz
+GZIP_ENV = --best
+DIST_TARGETS = dist-gzip
+distuninstallcheck_listfiles = find . -type f -print
+am__distuninstallcheck_listfiles = $(distuninstallcheck_listfiles) \
+ | sed 's|^\./|$(prefix)/|' | grep -v '$(infodir)/dir$$'
+distcleancheck_listfiles = find . -type f -print
+ACLOCAL = @ACLOCAL@
+ALLOCA = @ALLOCA@
+AMTAR = @AMTAR@
+AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@
+AM_LTLDFLAGS = @AM_LTLDFLAGS@
+AM_RUNTESTFLAGS = @AM_RUNTESTFLAGS@
+AR = @AR@
+AUTOCONF = @AUTOCONF@
+AUTOHEADER = @AUTOHEADER@
+AUTOMAKE = @AUTOMAKE@
+AWK = @AWK@
+CC = @CC@
+CCAS = @CCAS@
+CCASDEPMODE = @CCASDEPMODE@
+CCASFLAGS = @CCASFLAGS@
+CCDEPMODE = @CCDEPMODE@
+CFLAGS = @CFLAGS@
+CPP = @CPP@
+CPPFLAGS = @CPPFLAGS@
+CXX = @CXX@
+CXXCPP = @CXXCPP@
+CXXDEPMODE = @CXXDEPMODE@
+CXXFLAGS = @CXXFLAGS@
+CYGPATH_W = @CYGPATH_W@
+DEFS = @DEFS@
+DEPDIR = @DEPDIR@
+DLLTOOL = @DLLTOOL@
+DSYMUTIL = @DSYMUTIL@
+DUMPBIN = @DUMPBIN@
+ECHO_C = @ECHO_C@
+ECHO_N = @ECHO_N@
+ECHO_T = @ECHO_T@
+EGREP = @EGREP@
+EXEEXT = @EXEEXT@
+FFI_EXEC_TRAMPOLINE_TABLE = @FFI_EXEC_TRAMPOLINE_TABLE@
+FGREP = @FGREP@
+GREP = @GREP@
+HAVE_LONG_DOUBLE = @HAVE_LONG_DOUBLE@
+HAVE_LONG_DOUBLE_VARIANT = @HAVE_LONG_DOUBLE_VARIANT@
+INSTALL = @INSTALL@
+INSTALL_DATA = @INSTALL_DATA@
+INSTALL_PROGRAM = @INSTALL_PROGRAM@
+INSTALL_SCRIPT = @INSTALL_SCRIPT@
+INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
+LD = @LD@
+LDFLAGS = @LDFLAGS@
+LIBOBJS = @LIBOBJS@
+LIBS = @LIBS@
+LIBTOOL = @LIBTOOL@
+LIPO = @LIPO@
+LN_S = @LN_S@
+LTLIBOBJS = @LTLIBOBJS@
+MAINT = @MAINT@
+MAKEINFO = @MAKEINFO@
+MANIFEST_TOOL = @MANIFEST_TOOL@
+MKDIR_P = @MKDIR_P@
+NM = @NM@
+NMEDIT = @NMEDIT@
+OBJDUMP = @OBJDUMP@
+OBJEXT = @OBJEXT@
+OTOOL = @OTOOL@
+OTOOL64 = @OTOOL64@
+PACKAGE = @PACKAGE@
+PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
+PACKAGE_NAME = @PACKAGE_NAME@
+PACKAGE_STRING = @PACKAGE_STRING@
+PACKAGE_TARNAME = @PACKAGE_TARNAME@
+PACKAGE_URL = @PACKAGE_URL@
+PACKAGE_VERSION = @PACKAGE_VERSION@
+PATH_SEPARATOR = @PATH_SEPARATOR@
+PRTDIAG = @PRTDIAG@
+RANLIB = @RANLIB@
+SED = @SED@
+SET_MAKE = @SET_MAKE@
+SHELL = @SHELL@
+STRIP = @STRIP@
+TARGET = @TARGET@
+TARGETDIR = @TARGETDIR@
+VERSION = @VERSION@
+abs_builddir = @abs_builddir@
+abs_srcdir = @abs_srcdir@
+abs_top_builddir = @abs_top_builddir@
+abs_top_srcdir = @abs_top_srcdir@
+ac_ct_AR = @ac_ct_AR@
+ac_ct_CC = @ac_ct_CC@
+ac_ct_CXX = @ac_ct_CXX@
+ac_ct_DUMPBIN = @ac_ct_DUMPBIN@
+am__include = @am__include@
+am__leading_dot = @am__leading_dot@
+am__quote = @am__quote@
+am__tar = @am__tar@
+am__untar = @am__untar@
+ax_enable_builddir_sed = @ax_enable_builddir_sed@
+bindir = @bindir@
+build = @build@
+build_alias = @build_alias@
+build_cpu = @build_cpu@
+build_os = @build_os@
+build_vendor = @build_vendor@
+builddir = @builddir@
+datadir = @datadir@
+datarootdir = @datarootdir@
+docdir = @docdir@
+dvidir = @dvidir@
+exec_prefix = @exec_prefix@
+host = @host@
+host_alias = @host_alias@
+host_cpu = @host_cpu@
+host_os = @host_os@
+host_vendor = @host_vendor@
+htmldir = @htmldir@
+includedir = @includedir@
+infodir = @infodir@
+install_sh = @install_sh@
+libdir = @libdir@
+libexecdir = @libexecdir@
+localedir = @localedir@
+localstatedir = @localstatedir@
+mandir = @mandir@
+mkdir_p = @mkdir_p@
+oldincludedir = @oldincludedir@
+pdfdir = @pdfdir@
+prefix = @prefix@
+program_transform_name = @program_transform_name@
+psdir = @psdir@
+sbindir = @sbindir@
+sharedstatedir = @sharedstatedir@
+srcdir = @srcdir@
+sys_symbol_underscore = @sys_symbol_underscore@
+sysconfdir = @sysconfdir@
+target = @target@
+target_alias = @target_alias@
+target_cpu = @target_cpu@
+target_os = @target_os@
+target_vendor = @target_vendor@
+toolexecdir = @toolexecdir@
+toolexeclibdir = @toolexeclibdir@
+top_build_prefix = @top_build_prefix@
+top_builddir = @top_builddir@
+top_srcdir = @top_srcdir@
+AUTOMAKE_OPTIONS = foreign subdir-objects
+ACLOCAL_AMFLAGS = -I m4
+SUBDIRS = include testsuite man
+EXTRA_DIST = LICENSE ChangeLog.v1 ChangeLog.libgcj \
+ src/aarch64/ffi.c src/aarch64/ffitarget.h src/aarch64/sysv.S \
+ src/alpha/ffi.c src/alpha/osf.S \
+ src/alpha/ffitarget.h src/arc/ffi.c src/arc/arcompact.S \
+ src/arc/ffitarget.h src/arm/ffi.c src/arm/sysv.S \
+ src/arm/ffitarget.h src/avr32/ffi.c src/avr32/sysv.S \
+ src/avr32/ffitarget.h src/cris/ffi.c src/cris/sysv.S \
+ src/cris/ffitarget.h src/ia64/ffi.c src/ia64/ffitarget.h \
+ src/ia64/ia64_flags.h src/ia64/unix.S src/mips/ffi.c \
+ src/mips/n32.S src/mips/o32.S src/metag/ffi.c \
+ src/metag/ffitarget.h src/metag/sysv.S src/moxie/ffi.c \
+ src/moxie/ffitarget.h src/moxie/eabi.S src/mips/ffitarget.h \
+ src/m32r/ffi.c src/m32r/sysv.S src/m32r/ffitarget.h \
+ src/m68k/ffi.c src/m68k/sysv.S src/m68k/ffitarget.h \
+ src/m88k/ffi.c src/m88k/obsd.S src/m88k/ffitarget.h \
+ src/microblaze/ffi.c src/microblaze/sysv.S \
+ src/microblaze/ffitarget.h \
+ src/nios2/ffi.c src/nios2/ffitarget.h src/nios2/sysv.S \
+ src/or1k/ffi.c src/or1k/ffitarget.h src/or1k/sysv.S \
+ src/powerpc/ffi.c src/powerpc/ffi_powerpc.h \
+ src/powerpc/ffi_sysv.c src/powerpc/ffi_linux64.c \
+ src/powerpc/sysv.S src/powerpc/linux64.S \
+ src/powerpc/linux64_closure.S src/powerpc/ppc_closure.S \
+ src/powerpc/asm.h src/powerpc/aix.S src/powerpc/darwin.S \
+ src/powerpc/aix_closure.S src/powerpc/darwin_closure.S \
+ src/powerpc/ffi_darwin.c src/powerpc/ffitarget.h \
+ src/s390/ffi.c src/s390/sysv.S src/s390/ffitarget.h \
+ src/sh/ffi.c src/sh/sysv.S src/sh/ffitarget.h src/sh64/ffi.c \
+ src/sh64/sysv.S src/sh64/ffitarget.h src/sparc/v8.S \
+ src/sparc/v9.S src/sparc/ffitarget.h src/sparc/ffi.c \
+ src/x86/darwin64.S src/x86/ffi.c src/x86/sysv.S \
+ src/x86/win32.S src/x86/darwin.S src/x86/win64.S \
+ src/x86/freebsd.S src/x86/ffi64.c src/x86/unix64.S \
+ src/x86/ffitarget.h src/pa/ffitarget.h src/pa/ffi.c \
+ src/pa/linux.S src/pa/hpux32.S src/frv/ffi.c src/bfin/ffi.c \
+ src/bfin/ffitarget.h src/bfin/sysv.S src/frv/eabi.S \
+ src/frv/ffitarget.h src/dlmalloc.c src/tile/ffi.c \
+ src/tile/ffitarget.h src/tile/tile.S libtool-version \
+ src/vax/ffi.c src/vax/ffitarget.h src/vax/elfbsd.S \
+ src/xtensa/ffitarget.h src/xtensa/ffi.c src/xtensa/sysv.S \
+ ChangeLog.libffi m4/libtool.m4 m4/lt~obsolete.m4 \
+ m4/ltoptions.m4 m4/ltsugar.m4 m4/ltversion.m4 \
+ m4/ltversion.m4 src/arm/gentramp.sh src/debug.c msvcc.sh \
+ generate-darwin-source-and-headers.py \
+ libffi.xcodeproj/project.pbxproj src/arm/trampoline.S \
+ libtool-ldflags ChangeLog.libffi-3.1
+
+info_TEXINFOS = doc/libffi.texi
+
+# Work around what appears to be a GNU make bug handling MAKEFLAGS
+# values defined in terms of make variables, as is the case for CC and
+# friends when we are called from the top level Makefile.
+AM_MAKEFLAGS = \
+ 'AR_FLAGS=$(AR_FLAGS)' \
+ 'CC_FOR_BUILD=$(CC_FOR_BUILD)' \
+ 'CFLAGS=$(CFLAGS)' \
+ 'CXXFLAGS=$(CXXFLAGS)' \
+ 'CFLAGS_FOR_BUILD=$(CFLAGS_FOR_BUILD)' \
+ 'CFLAGS_FOR_TARGET=$(CFLAGS_FOR_TARGET)' \
+ 'INSTALL=$(INSTALL)' \
+ 'INSTALL_DATA=$(INSTALL_DATA)' \
+ 'INSTALL_PROGRAM=$(INSTALL_PROGRAM)' \
+ 'INSTALL_SCRIPT=$(INSTALL_SCRIPT)' \
+ 'JC1FLAGS=$(JC1FLAGS)' \
+ 'LDFLAGS=$(LDFLAGS)' \
+ 'LIBCFLAGS=$(LIBCFLAGS)' \
+ 'LIBCFLAGS_FOR_TARGET=$(LIBCFLAGS_FOR_TARGET)' \
+ 'MAKE=$(MAKE)' \
+ 'MAKEINFO=$(MAKEINFO) $(MAKEINFOFLAGS)' \
+ 'PICFLAG=$(PICFLAG)' \
+ 'PICFLAG_FOR_TARGET=$(PICFLAG_FOR_TARGET)' \
+ 'RUNTESTFLAGS=$(RUNTESTFLAGS)' \
+ 'SHELL=$(SHELL)' \
+ 'exec_prefix=$(exec_prefix)' \
+ 'infodir=$(infodir)' \
+ 'libdir=$(libdir)' \
+ 'mandir=$(mandir)' \
+ 'prefix=$(prefix)' \
+ 'AR=$(AR)' \
+ 'AS=$(AS)' \
+ 'CC=$(CC)' \
+ 'CXX=$(CXX)' \
+ 'LD=$(LD)' \
+ 'NM=$(NM)' \
+ 'RANLIB=$(RANLIB)' \
+ 'DESTDIR=$(DESTDIR)'
+
+
+# Subdir rules rely on $(FLAGS_TO_PASS)
+FLAGS_TO_PASS = $(AM_MAKEFLAGS)
+MAKEOVERRIDES =
+toolexeclib_LTLIBRARIES = libffi.la
+noinst_LTLIBRARIES = libffi_convenience.la
+libffi_la_SOURCES = src/prep_cif.c src/types.c \
+ src/raw_api.c src/java_raw_api.c src/closures.c
+
+pkgconfigdir = $(libdir)/pkgconfig
+pkgconfig_DATA = libffi.pc
+nodist_libffi_la_SOURCES = $(am__append_1) $(am__append_2) \
+ $(am__append_3) $(am__append_4) $(am__append_5) \
+ $(am__append_6) $(am__append_7) $(am__append_8) \
+ $(am__append_9) $(am__append_10) $(am__append_11) \
+ $(am__append_12) $(am__append_13) $(am__append_14) \
+ $(am__append_15) $(am__append_16) $(am__append_17) \
+ $(am__append_18) $(am__append_19) $(am__append_20) \
+ $(am__append_21) $(am__append_22) $(am__append_23) \
+ $(am__append_24) $(am__append_25) $(am__append_26) \
+ $(am__append_27) $(am__append_28) $(am__append_29) \
+ $(am__append_30) $(am__append_31) $(am__append_32) \
+ $(am__append_33) $(am__append_34) $(am__append_35) \
+ $(am__append_36) $(am__append_37) $(am__append_38) \
+ $(am__append_39) $(am__append_40)
+libffi_convenience_la_SOURCES = $(libffi_la_SOURCES)
+nodist_libffi_convenience_la_SOURCES = $(nodist_libffi_la_SOURCES)
+LTLDFLAGS = $(shell $(SHELL) $(top_srcdir)/libtool-ldflags $(LDFLAGS))
+AM_CFLAGS = $(am__append_41)
+libffi_la_LDFLAGS = -no-undefined -version-info `grep -v '^\#' $(srcdir)/libtool-version` $(LTLDFLAGS) $(AM_LTLDFLAGS)
+AM_CPPFLAGS = -I. -I$(top_srcdir)/include -Iinclude -I$(top_srcdir)/src
+AM_CCASFLAGS = $(AM_CPPFLAGS)
+all: fficonfig.h
+ $(MAKE) $(AM_MAKEFLAGS) all-recursive
+
+.SUFFIXES:
+.SUFFIXES: .S .c .dvi .lo .o .obj .ps
+am--refresh: Makefile
+ @:
+$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps)
+ @for dep in $?; do \
+ case '$(am__configure_deps)' in \
+ *$$dep*) \
+ echo ' cd $(srcdir) && $(AUTOMAKE) --foreign'; \
+ $(am__cd) $(srcdir) && $(AUTOMAKE) --foreign \
+ && exit 0; \
+ exit 1;; \
+ esac; \
+ done; \
+ echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign Makefile'; \
+ $(am__cd) $(top_srcdir) && \
+ $(AUTOMAKE) --foreign Makefile
+.PRECIOUS: Makefile
+Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
+ @case '$?' in \
+ *config.status*) \
+ echo ' $(SHELL) ./config.status'; \
+ $(SHELL) ./config.status;; \
+ *) \
+ echo ' cd $(top_builddir) && $(SHELL) ./config.status $@ $(am__depfiles_maybe)'; \
+ cd $(top_builddir) && $(SHELL) ./config.status $@ $(am__depfiles_maybe);; \
+ esac;
+
+$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
+ $(SHELL) ./config.status --recheck
+
+$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps)
+ $(am__cd) $(srcdir) && $(AUTOCONF)
+$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps)
+ $(am__cd) $(srcdir) && $(ACLOCAL) $(ACLOCAL_AMFLAGS)
+$(am__aclocal_m4_deps):
+
+fficonfig.h: stamp-h1
+ @if test ! -f $@; then rm -f stamp-h1; else :; fi
+ @if test ! -f $@; then $(MAKE) $(AM_MAKEFLAGS) stamp-h1; else :; fi
+
+stamp-h1: $(srcdir)/fficonfig.h.in $(top_builddir)/config.status
+ @rm -f stamp-h1
+ cd $(top_builddir) && $(SHELL) ./config.status fficonfig.h
+$(srcdir)/fficonfig.h.in: @MAINTAINER_MODE_TRUE@ $(am__configure_deps)
+ ($(am__cd) $(top_srcdir) && $(AUTOHEADER))
+ rm -f stamp-h1
+ touch $@
+
+distclean-hdr:
+ -rm -f fficonfig.h stamp-h1
+libffi.pc: $(top_builddir)/config.status $(srcdir)/libffi.pc.in
+ cd $(top_builddir) && $(SHELL) ./config.status $@
+
+clean-noinstLTLIBRARIES:
+ -test -z "$(noinst_LTLIBRARIES)" || rm -f $(noinst_LTLIBRARIES)
+ @list='$(noinst_LTLIBRARIES)'; \
+ locs=`for p in $$list; do echo $$p; done | \
+ sed 's|^[^/]*$$|.|; s|/[^/]*$$||; s|$$|/so_locations|' | \
+ sort -u`; \
+ test -z "$$locs" || { \
+ echo rm -f $${locs}; \
+ rm -f $${locs}; \
+ }
+
+install-toolexeclibLTLIBRARIES: $(toolexeclib_LTLIBRARIES)
+ @$(NORMAL_INSTALL)
+ @list='$(toolexeclib_LTLIBRARIES)'; test -n "$(toolexeclibdir)" || list=; \
+ list2=; for p in $$list; do \
+ if test -f $$p; then \
+ list2="$$list2 $$p"; \
+ else :; fi; \
+ done; \
+ test -z "$$list2" || { \
+ echo " $(MKDIR_P) '$(DESTDIR)$(toolexeclibdir)'"; \
+ $(MKDIR_P) "$(DESTDIR)$(toolexeclibdir)" || exit 1; \
+ echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 '$(DESTDIR)$(toolexeclibdir)'"; \
+ $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 "$(DESTDIR)$(toolexeclibdir)"; \
+ }
+
+uninstall-toolexeclibLTLIBRARIES:
+ @$(NORMAL_UNINSTALL)
+ @list='$(toolexeclib_LTLIBRARIES)'; test -n "$(toolexeclibdir)" || list=; \
+ for p in $$list; do \
+ $(am__strip_dir) \
+ echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f '$(DESTDIR)$(toolexeclibdir)/$$f'"; \
+ $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f "$(DESTDIR)$(toolexeclibdir)/$$f"; \
+ done
+
+clean-toolexeclibLTLIBRARIES:
+ -test -z "$(toolexeclib_LTLIBRARIES)" || rm -f $(toolexeclib_LTLIBRARIES)
+ @list='$(toolexeclib_LTLIBRARIES)'; \
+ locs=`for p in $$list; do echo $$p; done | \
+ sed 's|^[^/]*$$|.|; s|/[^/]*$$||; s|$$|/so_locations|' | \
+ sort -u`; \
+ test -z "$$locs" || { \
+ echo rm -f $${locs}; \
+ rm -f $${locs}; \
+ }
+src/$(am__dirstamp):
+ @$(MKDIR_P) src
+ @: > src/$(am__dirstamp)
+src/$(DEPDIR)/$(am__dirstamp):
+ @$(MKDIR_P) src/$(DEPDIR)
+ @: > src/$(DEPDIR)/$(am__dirstamp)
+src/prep_cif.lo: src/$(am__dirstamp) src/$(DEPDIR)/$(am__dirstamp)
+src/types.lo: src/$(am__dirstamp) src/$(DEPDIR)/$(am__dirstamp)
+src/raw_api.lo: src/$(am__dirstamp) src/$(DEPDIR)/$(am__dirstamp)
+src/java_raw_api.lo: src/$(am__dirstamp) src/$(DEPDIR)/$(am__dirstamp)
+src/closures.lo: src/$(am__dirstamp) src/$(DEPDIR)/$(am__dirstamp)
+src/debug.lo: src/$(am__dirstamp) src/$(DEPDIR)/$(am__dirstamp)
+src/mips/$(am__dirstamp):
+ @$(MKDIR_P) src/mips
+ @: > src/mips/$(am__dirstamp)
+src/mips/$(DEPDIR)/$(am__dirstamp):
+ @$(MKDIR_P) src/mips/$(DEPDIR)
+ @: > src/mips/$(DEPDIR)/$(am__dirstamp)
+src/mips/ffi.lo: src/mips/$(am__dirstamp) \
+ src/mips/$(DEPDIR)/$(am__dirstamp)
+src/mips/o32.lo: src/mips/$(am__dirstamp) \
+ src/mips/$(DEPDIR)/$(am__dirstamp)
+src/mips/n32.lo: src/mips/$(am__dirstamp) \
+ src/mips/$(DEPDIR)/$(am__dirstamp)
+src/bfin/$(am__dirstamp):
+ @$(MKDIR_P) src/bfin
+ @: > src/bfin/$(am__dirstamp)
+src/bfin/$(DEPDIR)/$(am__dirstamp):
+ @$(MKDIR_P) src/bfin/$(DEPDIR)
+ @: > src/bfin/$(DEPDIR)/$(am__dirstamp)
+src/bfin/ffi.lo: src/bfin/$(am__dirstamp) \
+ src/bfin/$(DEPDIR)/$(am__dirstamp)
+src/bfin/sysv.lo: src/bfin/$(am__dirstamp) \
+ src/bfin/$(DEPDIR)/$(am__dirstamp)
+src/x86/$(am__dirstamp):
+ @$(MKDIR_P) src/x86
+ @: > src/x86/$(am__dirstamp)
+src/x86/$(DEPDIR)/$(am__dirstamp):
+ @$(MKDIR_P) src/x86/$(DEPDIR)
+ @: > src/x86/$(DEPDIR)/$(am__dirstamp)
+src/x86/ffi.lo: src/x86/$(am__dirstamp) \
+ src/x86/$(DEPDIR)/$(am__dirstamp)
+src/x86/sysv.lo: src/x86/$(am__dirstamp) \
+ src/x86/$(DEPDIR)/$(am__dirstamp)
+src/x86/win32.lo: src/x86/$(am__dirstamp) \
+ src/x86/$(DEPDIR)/$(am__dirstamp)
+src/x86/freebsd.lo: src/x86/$(am__dirstamp) \
+ src/x86/$(DEPDIR)/$(am__dirstamp)
+src/x86/win64.lo: src/x86/$(am__dirstamp) \
+ src/x86/$(DEPDIR)/$(am__dirstamp)
+src/x86/darwin.lo: src/x86/$(am__dirstamp) \
+ src/x86/$(DEPDIR)/$(am__dirstamp)
+src/x86/ffi64.lo: src/x86/$(am__dirstamp) \
+ src/x86/$(DEPDIR)/$(am__dirstamp)
+src/x86/darwin64.lo: src/x86/$(am__dirstamp) \
+ src/x86/$(DEPDIR)/$(am__dirstamp)
+src/sparc/$(am__dirstamp):
+ @$(MKDIR_P) src/sparc
+ @: > src/sparc/$(am__dirstamp)
+src/sparc/$(DEPDIR)/$(am__dirstamp):
+ @$(MKDIR_P) src/sparc/$(DEPDIR)
+ @: > src/sparc/$(DEPDIR)/$(am__dirstamp)
+src/sparc/ffi.lo: src/sparc/$(am__dirstamp) \
+ src/sparc/$(DEPDIR)/$(am__dirstamp)
+src/sparc/v8.lo: src/sparc/$(am__dirstamp) \
+ src/sparc/$(DEPDIR)/$(am__dirstamp)
+src/sparc/v9.lo: src/sparc/$(am__dirstamp) \
+ src/sparc/$(DEPDIR)/$(am__dirstamp)
+src/alpha/$(am__dirstamp):
+ @$(MKDIR_P) src/alpha
+ @: > src/alpha/$(am__dirstamp)
+src/alpha/$(DEPDIR)/$(am__dirstamp):
+ @$(MKDIR_P) src/alpha/$(DEPDIR)
+ @: > src/alpha/$(DEPDIR)/$(am__dirstamp)
+src/alpha/ffi.lo: src/alpha/$(am__dirstamp) \
+ src/alpha/$(DEPDIR)/$(am__dirstamp)
+src/alpha/osf.lo: src/alpha/$(am__dirstamp) \
+ src/alpha/$(DEPDIR)/$(am__dirstamp)
+src/ia64/$(am__dirstamp):
+ @$(MKDIR_P) src/ia64
+ @: > src/ia64/$(am__dirstamp)
+src/ia64/$(DEPDIR)/$(am__dirstamp):
+ @$(MKDIR_P) src/ia64/$(DEPDIR)
+ @: > src/ia64/$(DEPDIR)/$(am__dirstamp)
+src/ia64/ffi.lo: src/ia64/$(am__dirstamp) \
+ src/ia64/$(DEPDIR)/$(am__dirstamp)
+src/ia64/unix.lo: src/ia64/$(am__dirstamp) \
+ src/ia64/$(DEPDIR)/$(am__dirstamp)
+src/m32r/$(am__dirstamp):
+ @$(MKDIR_P) src/m32r
+ @: > src/m32r/$(am__dirstamp)
+src/m32r/$(DEPDIR)/$(am__dirstamp):
+ @$(MKDIR_P) src/m32r/$(DEPDIR)
+ @: > src/m32r/$(DEPDIR)/$(am__dirstamp)
+src/m32r/sysv.lo: src/m32r/$(am__dirstamp) \
+ src/m32r/$(DEPDIR)/$(am__dirstamp)
+src/m32r/ffi.lo: src/m32r/$(am__dirstamp) \
+ src/m32r/$(DEPDIR)/$(am__dirstamp)
+src/m68k/$(am__dirstamp):
+ @$(MKDIR_P) src/m68k
+ @: > src/m68k/$(am__dirstamp)
+src/m68k/$(DEPDIR)/$(am__dirstamp):
+ @$(MKDIR_P) src/m68k/$(DEPDIR)
+ @: > src/m68k/$(DEPDIR)/$(am__dirstamp)
+src/m68k/ffi.lo: src/m68k/$(am__dirstamp) \
+ src/m68k/$(DEPDIR)/$(am__dirstamp)
+src/m68k/sysv.lo: src/m68k/$(am__dirstamp) \
+ src/m68k/$(DEPDIR)/$(am__dirstamp)
+src/m88k/$(am__dirstamp):
+ @$(MKDIR_P) src/m88k
+ @: > src/m88k/$(am__dirstamp)
+src/m88k/$(DEPDIR)/$(am__dirstamp):
+ @$(MKDIR_P) src/m88k/$(DEPDIR)
+ @: > src/m88k/$(DEPDIR)/$(am__dirstamp)
+src/m88k/ffi.lo: src/m88k/$(am__dirstamp) \
+ src/m88k/$(DEPDIR)/$(am__dirstamp)
+src/m88k/obsd.lo: src/m88k/$(am__dirstamp) \
+ src/m88k/$(DEPDIR)/$(am__dirstamp)
+src/moxie/$(am__dirstamp):
+ @$(MKDIR_P) src/moxie
+ @: > src/moxie/$(am__dirstamp)
+src/moxie/$(DEPDIR)/$(am__dirstamp):
+ @$(MKDIR_P) src/moxie/$(DEPDIR)
+ @: > src/moxie/$(DEPDIR)/$(am__dirstamp)
+src/moxie/ffi.lo: src/moxie/$(am__dirstamp) \
+ src/moxie/$(DEPDIR)/$(am__dirstamp)
+src/moxie/eabi.lo: src/moxie/$(am__dirstamp) \
+ src/moxie/$(DEPDIR)/$(am__dirstamp)
+src/microblaze/$(am__dirstamp):
+ @$(MKDIR_P) src/microblaze
+ @: > src/microblaze/$(am__dirstamp)
+src/microblaze/$(DEPDIR)/$(am__dirstamp):
+ @$(MKDIR_P) src/microblaze/$(DEPDIR)
+ @: > src/microblaze/$(DEPDIR)/$(am__dirstamp)
+src/microblaze/ffi.lo: src/microblaze/$(am__dirstamp) \
+ src/microblaze/$(DEPDIR)/$(am__dirstamp)
+src/microblaze/sysv.lo: src/microblaze/$(am__dirstamp) \
+ src/microblaze/$(DEPDIR)/$(am__dirstamp)
+src/nios2/$(am__dirstamp):
+ @$(MKDIR_P) src/nios2
+ @: > src/nios2/$(am__dirstamp)
+src/nios2/$(DEPDIR)/$(am__dirstamp):
+ @$(MKDIR_P) src/nios2/$(DEPDIR)
+ @: > src/nios2/$(DEPDIR)/$(am__dirstamp)
+src/nios2/sysv.lo: src/nios2/$(am__dirstamp) \
+ src/nios2/$(DEPDIR)/$(am__dirstamp)
+src/nios2/ffi.lo: src/nios2/$(am__dirstamp) \
+ src/nios2/$(DEPDIR)/$(am__dirstamp)
+src/or1k/$(am__dirstamp):
+ @$(MKDIR_P) src/or1k
+ @: > src/or1k/$(am__dirstamp)
+src/or1k/$(DEPDIR)/$(am__dirstamp):
+ @$(MKDIR_P) src/or1k/$(DEPDIR)
+ @: > src/or1k/$(DEPDIR)/$(am__dirstamp)
+src/or1k/sysv.lo: src/or1k/$(am__dirstamp) \
+ src/or1k/$(DEPDIR)/$(am__dirstamp)
+src/or1k/ffi.lo: src/or1k/$(am__dirstamp) \
+ src/or1k/$(DEPDIR)/$(am__dirstamp)
+src/powerpc/$(am__dirstamp):
+ @$(MKDIR_P) src/powerpc
+ @: > src/powerpc/$(am__dirstamp)
+src/powerpc/$(DEPDIR)/$(am__dirstamp):
+ @$(MKDIR_P) src/powerpc/$(DEPDIR)
+ @: > src/powerpc/$(DEPDIR)/$(am__dirstamp)
+src/powerpc/ffi.lo: src/powerpc/$(am__dirstamp) \
+ src/powerpc/$(DEPDIR)/$(am__dirstamp)
+src/powerpc/ffi_sysv.lo: src/powerpc/$(am__dirstamp) \
+ src/powerpc/$(DEPDIR)/$(am__dirstamp)
+src/powerpc/ffi_linux64.lo: src/powerpc/$(am__dirstamp) \
+ src/powerpc/$(DEPDIR)/$(am__dirstamp)
+src/powerpc/sysv.lo: src/powerpc/$(am__dirstamp) \
+ src/powerpc/$(DEPDIR)/$(am__dirstamp)
+src/powerpc/ppc_closure.lo: src/powerpc/$(am__dirstamp) \
+ src/powerpc/$(DEPDIR)/$(am__dirstamp)
+src/powerpc/linux64.lo: src/powerpc/$(am__dirstamp) \
+ src/powerpc/$(DEPDIR)/$(am__dirstamp)
+src/powerpc/linux64_closure.lo: src/powerpc/$(am__dirstamp) \
+ src/powerpc/$(DEPDIR)/$(am__dirstamp)
+src/powerpc/ffi_darwin.lo: src/powerpc/$(am__dirstamp) \
+ src/powerpc/$(DEPDIR)/$(am__dirstamp)
+src/powerpc/aix.lo: src/powerpc/$(am__dirstamp) \
+ src/powerpc/$(DEPDIR)/$(am__dirstamp)
+src/powerpc/aix_closure.lo: src/powerpc/$(am__dirstamp) \
+ src/powerpc/$(DEPDIR)/$(am__dirstamp)
+src/powerpc/darwin.lo: src/powerpc/$(am__dirstamp) \
+ src/powerpc/$(DEPDIR)/$(am__dirstamp)
+src/powerpc/darwin_closure.lo: src/powerpc/$(am__dirstamp) \
+ src/powerpc/$(DEPDIR)/$(am__dirstamp)
+src/aarch64/$(am__dirstamp):
+ @$(MKDIR_P) src/aarch64
+ @: > src/aarch64/$(am__dirstamp)
+src/aarch64/$(DEPDIR)/$(am__dirstamp):
+ @$(MKDIR_P) src/aarch64/$(DEPDIR)
+ @: > src/aarch64/$(DEPDIR)/$(am__dirstamp)
+src/aarch64/sysv.lo: src/aarch64/$(am__dirstamp) \
+ src/aarch64/$(DEPDIR)/$(am__dirstamp)
+src/aarch64/ffi.lo: src/aarch64/$(am__dirstamp) \
+ src/aarch64/$(DEPDIR)/$(am__dirstamp)
+src/arc/$(am__dirstamp):
+ @$(MKDIR_P) src/arc
+ @: > src/arc/$(am__dirstamp)
+src/arc/$(DEPDIR)/$(am__dirstamp):
+ @$(MKDIR_P) src/arc/$(DEPDIR)
+ @: > src/arc/$(DEPDIR)/$(am__dirstamp)
+src/arc/arcompact.lo: src/arc/$(am__dirstamp) \
+ src/arc/$(DEPDIR)/$(am__dirstamp)
+src/arc/ffi.lo: src/arc/$(am__dirstamp) \
+ src/arc/$(DEPDIR)/$(am__dirstamp)
+src/arm/$(am__dirstamp):
+ @$(MKDIR_P) src/arm
+ @: > src/arm/$(am__dirstamp)
+src/arm/$(DEPDIR)/$(am__dirstamp):
+ @$(MKDIR_P) src/arm/$(DEPDIR)
+ @: > src/arm/$(DEPDIR)/$(am__dirstamp)
+src/arm/sysv.lo: src/arm/$(am__dirstamp) \
+ src/arm/$(DEPDIR)/$(am__dirstamp)
+src/arm/ffi.lo: src/arm/$(am__dirstamp) \
+ src/arm/$(DEPDIR)/$(am__dirstamp)
+src/arm/trampoline.lo: src/arm/$(am__dirstamp) \
+ src/arm/$(DEPDIR)/$(am__dirstamp)
+src/avr32/$(am__dirstamp):
+ @$(MKDIR_P) src/avr32
+ @: > src/avr32/$(am__dirstamp)
+src/avr32/$(DEPDIR)/$(am__dirstamp):
+ @$(MKDIR_P) src/avr32/$(DEPDIR)
+ @: > src/avr32/$(DEPDIR)/$(am__dirstamp)
+src/avr32/sysv.lo: src/avr32/$(am__dirstamp) \
+ src/avr32/$(DEPDIR)/$(am__dirstamp)
+src/avr32/ffi.lo: src/avr32/$(am__dirstamp) \
+ src/avr32/$(DEPDIR)/$(am__dirstamp)
+src/cris/$(am__dirstamp):
+ @$(MKDIR_P) src/cris
+ @: > src/cris/$(am__dirstamp)
+src/cris/$(DEPDIR)/$(am__dirstamp):
+ @$(MKDIR_P) src/cris/$(DEPDIR)
+ @: > src/cris/$(DEPDIR)/$(am__dirstamp)
+src/cris/sysv.lo: src/cris/$(am__dirstamp) \
+ src/cris/$(DEPDIR)/$(am__dirstamp)
+src/cris/ffi.lo: src/cris/$(am__dirstamp) \
+ src/cris/$(DEPDIR)/$(am__dirstamp)
+src/frv/$(am__dirstamp):
+ @$(MKDIR_P) src/frv
+ @: > src/frv/$(am__dirstamp)
+src/frv/$(DEPDIR)/$(am__dirstamp):
+ @$(MKDIR_P) src/frv/$(DEPDIR)
+ @: > src/frv/$(DEPDIR)/$(am__dirstamp)
+src/frv/eabi.lo: src/frv/$(am__dirstamp) \
+ src/frv/$(DEPDIR)/$(am__dirstamp)
+src/frv/ffi.lo: src/frv/$(am__dirstamp) \
+ src/frv/$(DEPDIR)/$(am__dirstamp)
+src/s390/$(am__dirstamp):
+ @$(MKDIR_P) src/s390
+ @: > src/s390/$(am__dirstamp)
+src/s390/$(DEPDIR)/$(am__dirstamp):
+ @$(MKDIR_P) src/s390/$(DEPDIR)
+ @: > src/s390/$(DEPDIR)/$(am__dirstamp)
+src/s390/sysv.lo: src/s390/$(am__dirstamp) \
+ src/s390/$(DEPDIR)/$(am__dirstamp)
+src/s390/ffi.lo: src/s390/$(am__dirstamp) \
+ src/s390/$(DEPDIR)/$(am__dirstamp)
+src/x86/unix64.lo: src/x86/$(am__dirstamp) \
+ src/x86/$(DEPDIR)/$(am__dirstamp)
+src/sh/$(am__dirstamp):
+ @$(MKDIR_P) src/sh
+ @: > src/sh/$(am__dirstamp)
+src/sh/$(DEPDIR)/$(am__dirstamp):
+ @$(MKDIR_P) src/sh/$(DEPDIR)
+ @: > src/sh/$(DEPDIR)/$(am__dirstamp)
+src/sh/sysv.lo: src/sh/$(am__dirstamp) \
+ src/sh/$(DEPDIR)/$(am__dirstamp)
+src/sh/ffi.lo: src/sh/$(am__dirstamp) src/sh/$(DEPDIR)/$(am__dirstamp)
+src/sh64/$(am__dirstamp):
+ @$(MKDIR_P) src/sh64
+ @: > src/sh64/$(am__dirstamp)
+src/sh64/$(DEPDIR)/$(am__dirstamp):
+ @$(MKDIR_P) src/sh64/$(DEPDIR)
+ @: > src/sh64/$(DEPDIR)/$(am__dirstamp)
+src/sh64/sysv.lo: src/sh64/$(am__dirstamp) \
+ src/sh64/$(DEPDIR)/$(am__dirstamp)
+src/sh64/ffi.lo: src/sh64/$(am__dirstamp) \
+ src/sh64/$(DEPDIR)/$(am__dirstamp)
+src/pa/$(am__dirstamp):
+ @$(MKDIR_P) src/pa
+ @: > src/pa/$(am__dirstamp)
+src/pa/$(DEPDIR)/$(am__dirstamp):
+ @$(MKDIR_P) src/pa/$(DEPDIR)
+ @: > src/pa/$(DEPDIR)/$(am__dirstamp)
+src/pa/linux.lo: src/pa/$(am__dirstamp) \
+ src/pa/$(DEPDIR)/$(am__dirstamp)
+src/pa/ffi.lo: src/pa/$(am__dirstamp) src/pa/$(DEPDIR)/$(am__dirstamp)
+src/pa/hpux32.lo: src/pa/$(am__dirstamp) \
+ src/pa/$(DEPDIR)/$(am__dirstamp)
+src/tile/$(am__dirstamp):
+ @$(MKDIR_P) src/tile
+ @: > src/tile/$(am__dirstamp)
+src/tile/$(DEPDIR)/$(am__dirstamp):
+ @$(MKDIR_P) src/tile/$(DEPDIR)
+ @: > src/tile/$(DEPDIR)/$(am__dirstamp)
+src/tile/tile.lo: src/tile/$(am__dirstamp) \
+ src/tile/$(DEPDIR)/$(am__dirstamp)
+src/tile/ffi.lo: src/tile/$(am__dirstamp) \
+ src/tile/$(DEPDIR)/$(am__dirstamp)
+src/xtensa/$(am__dirstamp):
+ @$(MKDIR_P) src/xtensa
+ @: > src/xtensa/$(am__dirstamp)
+src/xtensa/$(DEPDIR)/$(am__dirstamp):
+ @$(MKDIR_P) src/xtensa/$(DEPDIR)
+ @: > src/xtensa/$(DEPDIR)/$(am__dirstamp)
+src/xtensa/sysv.lo: src/xtensa/$(am__dirstamp) \
+ src/xtensa/$(DEPDIR)/$(am__dirstamp)
+src/xtensa/ffi.lo: src/xtensa/$(am__dirstamp) \
+ src/xtensa/$(DEPDIR)/$(am__dirstamp)
+src/metag/$(am__dirstamp):
+ @$(MKDIR_P) src/metag
+ @: > src/metag/$(am__dirstamp)
+src/metag/$(DEPDIR)/$(am__dirstamp):
+ @$(MKDIR_P) src/metag/$(DEPDIR)
+ @: > src/metag/$(DEPDIR)/$(am__dirstamp)
+src/metag/sysv.lo: src/metag/$(am__dirstamp) \
+ src/metag/$(DEPDIR)/$(am__dirstamp)
+src/metag/ffi.lo: src/metag/$(am__dirstamp) \
+ src/metag/$(DEPDIR)/$(am__dirstamp)
+src/vax/$(am__dirstamp):
+ @$(MKDIR_P) src/vax
+ @: > src/vax/$(am__dirstamp)
+src/vax/$(DEPDIR)/$(am__dirstamp):
+ @$(MKDIR_P) src/vax/$(DEPDIR)
+ @: > src/vax/$(DEPDIR)/$(am__dirstamp)
+src/vax/elfbsd.lo: src/vax/$(am__dirstamp) \
+ src/vax/$(DEPDIR)/$(am__dirstamp)
+src/vax/ffi.lo: src/vax/$(am__dirstamp) \
+ src/vax/$(DEPDIR)/$(am__dirstamp)
+
+libffi.la: $(libffi_la_OBJECTS) $(libffi_la_DEPENDENCIES) $(EXTRA_libffi_la_DEPENDENCIES)
+ $(AM_V_CCLD)$(libffi_la_LINK) -rpath $(toolexeclibdir) $(libffi_la_OBJECTS) $(libffi_la_LIBADD) $(LIBS)
+
+libffi_convenience.la: $(libffi_convenience_la_OBJECTS) $(libffi_convenience_la_DEPENDENCIES) $(EXTRA_libffi_convenience_la_DEPENDENCIES)
+ $(AM_V_CCLD)$(LINK) $(libffi_convenience_la_OBJECTS) $(libffi_convenience_la_LIBADD) $(LIBS)
+
+mostlyclean-compile:
+ -rm -f *.$(OBJEXT)
+ -rm -f src/*.$(OBJEXT)
+ -rm -f src/*.lo
+ -rm -f src/aarch64/*.$(OBJEXT)
+ -rm -f src/aarch64/*.lo
+ -rm -f src/alpha/*.$(OBJEXT)
+ -rm -f src/alpha/*.lo
+ -rm -f src/arc/*.$(OBJEXT)
+ -rm -f src/arc/*.lo
+ -rm -f src/arm/*.$(OBJEXT)
+ -rm -f src/arm/*.lo
+ -rm -f src/avr32/*.$(OBJEXT)
+ -rm -f src/avr32/*.lo
+ -rm -f src/bfin/*.$(OBJEXT)
+ -rm -f src/bfin/*.lo
+ -rm -f src/cris/*.$(OBJEXT)
+ -rm -f src/cris/*.lo
+ -rm -f src/frv/*.$(OBJEXT)
+ -rm -f src/frv/*.lo
+ -rm -f src/ia64/*.$(OBJEXT)
+ -rm -f src/ia64/*.lo
+ -rm -f src/m32r/*.$(OBJEXT)
+ -rm -f src/m32r/*.lo
+ -rm -f src/m68k/*.$(OBJEXT)
+ -rm -f src/m68k/*.lo
+ -rm -f src/m88k/*.$(OBJEXT)
+ -rm -f src/m88k/*.lo
+ -rm -f src/metag/*.$(OBJEXT)
+ -rm -f src/metag/*.lo
+ -rm -f src/microblaze/*.$(OBJEXT)
+ -rm -f src/microblaze/*.lo
+ -rm -f src/mips/*.$(OBJEXT)
+ -rm -f src/mips/*.lo
+ -rm -f src/moxie/*.$(OBJEXT)
+ -rm -f src/moxie/*.lo
+ -rm -f src/nios2/*.$(OBJEXT)
+ -rm -f src/nios2/*.lo
+ -rm -f src/or1k/*.$(OBJEXT)
+ -rm -f src/or1k/*.lo
+ -rm -f src/pa/*.$(OBJEXT)
+ -rm -f src/pa/*.lo
+ -rm -f src/powerpc/*.$(OBJEXT)
+ -rm -f src/powerpc/*.lo
+ -rm -f src/s390/*.$(OBJEXT)
+ -rm -f src/s390/*.lo
+ -rm -f src/sh/*.$(OBJEXT)
+ -rm -f src/sh/*.lo
+ -rm -f src/sh64/*.$(OBJEXT)
+ -rm -f src/sh64/*.lo
+ -rm -f src/sparc/*.$(OBJEXT)
+ -rm -f src/sparc/*.lo
+ -rm -f src/tile/*.$(OBJEXT)
+ -rm -f src/tile/*.lo
+ -rm -f src/vax/*.$(OBJEXT)
+ -rm -f src/vax/*.lo
+ -rm -f src/x86/*.$(OBJEXT)
+ -rm -f src/x86/*.lo
+ -rm -f src/xtensa/*.$(OBJEXT)
+ -rm -f src/xtensa/*.lo
+
+distclean-compile:
+ -rm -f *.tab.c
+
+@AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/closures.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/debug.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/java_raw_api.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/prep_cif.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/raw_api.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/types.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@src/aarch64/$(DEPDIR)/ffi.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@src/aarch64/$(DEPDIR)/sysv.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@src/alpha/$(DEPDIR)/ffi.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@src/alpha/$(DEPDIR)/osf.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@src/arc/$(DEPDIR)/arcompact.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@src/arc/$(DEPDIR)/ffi.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@src/arm/$(DEPDIR)/ffi.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@src/arm/$(DEPDIR)/sysv.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@src/arm/$(DEPDIR)/trampoline.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@src/avr32/$(DEPDIR)/ffi.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@src/avr32/$(DEPDIR)/sysv.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@src/bfin/$(DEPDIR)/ffi.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@src/bfin/$(DEPDIR)/sysv.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@src/cris/$(DEPDIR)/ffi.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@src/cris/$(DEPDIR)/sysv.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@src/frv/$(DEPDIR)/eabi.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@src/frv/$(DEPDIR)/ffi.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@src/ia64/$(DEPDIR)/ffi.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@src/ia64/$(DEPDIR)/unix.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@src/m32r/$(DEPDIR)/ffi.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@src/m32r/$(DEPDIR)/sysv.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@src/m68k/$(DEPDIR)/ffi.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@src/m68k/$(DEPDIR)/sysv.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@src/m88k/$(DEPDIR)/ffi.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@src/m88k/$(DEPDIR)/obsd.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@src/metag/$(DEPDIR)/ffi.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@src/metag/$(DEPDIR)/sysv.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@src/microblaze/$(DEPDIR)/ffi.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@src/microblaze/$(DEPDIR)/sysv.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@src/mips/$(DEPDIR)/ffi.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@src/mips/$(DEPDIR)/n32.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@src/mips/$(DEPDIR)/o32.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@src/moxie/$(DEPDIR)/eabi.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@src/moxie/$(DEPDIR)/ffi.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@src/nios2/$(DEPDIR)/ffi.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@src/nios2/$(DEPDIR)/sysv.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@src/or1k/$(DEPDIR)/ffi.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@src/or1k/$(DEPDIR)/sysv.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@src/pa/$(DEPDIR)/ffi.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@src/pa/$(DEPDIR)/hpux32.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@src/pa/$(DEPDIR)/linux.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@src/powerpc/$(DEPDIR)/aix.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@src/powerpc/$(DEPDIR)/aix_closure.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@src/powerpc/$(DEPDIR)/darwin.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@src/powerpc/$(DEPDIR)/darwin_closure.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@src/powerpc/$(DEPDIR)/ffi.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@src/powerpc/$(DEPDIR)/ffi_darwin.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@src/powerpc/$(DEPDIR)/ffi_linux64.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@src/powerpc/$(DEPDIR)/ffi_sysv.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@src/powerpc/$(DEPDIR)/linux64.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@src/powerpc/$(DEPDIR)/linux64_closure.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@src/powerpc/$(DEPDIR)/ppc_closure.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@src/powerpc/$(DEPDIR)/sysv.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@src/s390/$(DEPDIR)/ffi.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@src/s390/$(DEPDIR)/sysv.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@src/sh/$(DEPDIR)/ffi.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@src/sh/$(DEPDIR)/sysv.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@src/sh64/$(DEPDIR)/ffi.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@src/sh64/$(DEPDIR)/sysv.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@src/sparc/$(DEPDIR)/ffi.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@src/sparc/$(DEPDIR)/v8.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@src/sparc/$(DEPDIR)/v9.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@src/tile/$(DEPDIR)/ffi.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@src/tile/$(DEPDIR)/tile.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@src/vax/$(DEPDIR)/elfbsd.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@src/vax/$(DEPDIR)/ffi.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@src/x86/$(DEPDIR)/darwin.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@src/x86/$(DEPDIR)/darwin64.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@src/x86/$(DEPDIR)/ffi.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@src/x86/$(DEPDIR)/ffi64.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@src/x86/$(DEPDIR)/freebsd.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@src/x86/$(DEPDIR)/sysv.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@src/x86/$(DEPDIR)/unix64.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@src/x86/$(DEPDIR)/win32.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@src/x86/$(DEPDIR)/win64.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@src/xtensa/$(DEPDIR)/ffi.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@src/xtensa/$(DEPDIR)/sysv.Plo@am__quote@
+
+.S.o:
+@am__fastdepCCAS_TRUE@ $(AM_V_CPPAS)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.o$$||'`;\
+@am__fastdepCCAS_TRUE@ $(CPPASCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\
+@am__fastdepCCAS_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po
+@AMDEP_TRUE@@am__fastdepCCAS_FALSE@ $(AM_V_CPPAS)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCCAS_FALSE@ DEPDIR=$(DEPDIR) $(CCASDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCCAS_FALSE@ $(AM_V_CPPAS@am__nodep@)$(CPPASCOMPILE) -c -o $@ $<
+
+.S.obj:
+@am__fastdepCCAS_TRUE@ $(AM_V_CPPAS)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.obj$$||'`;\
+@am__fastdepCCAS_TRUE@ $(CPPASCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ `$(CYGPATH_W) '$<'` &&\
+@am__fastdepCCAS_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po
+@AMDEP_TRUE@@am__fastdepCCAS_FALSE@ $(AM_V_CPPAS)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCCAS_FALSE@ DEPDIR=$(DEPDIR) $(CCASDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCCAS_FALSE@ $(AM_V_CPPAS@am__nodep@)$(CPPASCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'`
+
+.S.lo:
+@am__fastdepCCAS_TRUE@ $(AM_V_CPPAS)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.lo$$||'`;\
+@am__fastdepCCAS_TRUE@ $(LTCPPASCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\
+@am__fastdepCCAS_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Plo
+@AMDEP_TRUE@@am__fastdepCCAS_FALSE@ $(AM_V_CPPAS)source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCCAS_FALSE@ DEPDIR=$(DEPDIR) $(CCASDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCCAS_FALSE@ $(AM_V_CPPAS@am__nodep@)$(LTCPPASCOMPILE) -c -o $@ $<
+
+.c.o:
+@am__fastdepCC_TRUE@ $(AM_V_CC)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.o$$||'`;\
+@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\
+@am__fastdepCC_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ $<
+
+.c.obj:
+@am__fastdepCC_TRUE@ $(AM_V_CC)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.obj$$||'`;\
+@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ `$(CYGPATH_W) '$<'` &&\
+@am__fastdepCC_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ `$(CYGPATH_W) '$<'`
+
+.c.lo:
+@am__fastdepCC_TRUE@ $(AM_V_CC)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.lo$$||'`;\
+@am__fastdepCC_TRUE@ $(LTCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\
+@am__fastdepCC_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LTCOMPILE) -c -o $@ $<
+
+mostlyclean-libtool:
+ -rm -f *.lo
+
+clean-libtool:
+ -rm -rf .libs _libs
+ -rm -rf src/.libs src/_libs
+ -rm -rf src/aarch64/.libs src/aarch64/_libs
+ -rm -rf src/alpha/.libs src/alpha/_libs
+ -rm -rf src/arc/.libs src/arc/_libs
+ -rm -rf src/arm/.libs src/arm/_libs
+ -rm -rf src/avr32/.libs src/avr32/_libs
+ -rm -rf src/bfin/.libs src/bfin/_libs
+ -rm -rf src/cris/.libs src/cris/_libs
+ -rm -rf src/frv/.libs src/frv/_libs
+ -rm -rf src/ia64/.libs src/ia64/_libs
+ -rm -rf src/m32r/.libs src/m32r/_libs
+ -rm -rf src/m68k/.libs src/m68k/_libs
+ -rm -rf src/m88k/.libs src/m88k/_libs
+ -rm -rf src/metag/.libs src/metag/_libs
+ -rm -rf src/microblaze/.libs src/microblaze/_libs
+ -rm -rf src/mips/.libs src/mips/_libs
+ -rm -rf src/moxie/.libs src/moxie/_libs
+ -rm -rf src/nios2/.libs src/nios2/_libs
+ -rm -rf src/or1k/.libs src/or1k/_libs
+ -rm -rf src/pa/.libs src/pa/_libs
+ -rm -rf src/powerpc/.libs src/powerpc/_libs
+ -rm -rf src/s390/.libs src/s390/_libs
+ -rm -rf src/sh/.libs src/sh/_libs
+ -rm -rf src/sh64/.libs src/sh64/_libs
+ -rm -rf src/sparc/.libs src/sparc/_libs
+ -rm -rf src/tile/.libs src/tile/_libs
+ -rm -rf src/vax/.libs src/vax/_libs
+ -rm -rf src/x86/.libs src/x86/_libs
+ -rm -rf src/xtensa/.libs src/xtensa/_libs
+
+distclean-libtool:
+ -rm -f libtool config.lt
+doc/$(am__dirstamp):
+ @$(MKDIR_P) doc
+ @: > doc/$(am__dirstamp)
+
+$(srcdir)/doc/libffi.info: doc/libffi.texi $(srcdir)/doc/version.texi
+ $(AM_V_MAKEINFO)restore=: && backupdir="$(am__leading_dot)am$$$$" && \
+ am__cwd=`pwd` && $(am__cd) $(srcdir) && \
+ rm -rf $$backupdir && mkdir $$backupdir && \
+ if ($(MAKEINFO) --version) >/dev/null 2>&1; then \
+ for f in $@ $@-[0-9] $@-[0-9][0-9] $(@:.info=).i[0-9] $(@:.info=).i[0-9][0-9]; do \
+ if test -f $$f; then mv $$f $$backupdir; restore=mv; else :; fi; \
+ done; \
+ else :; fi && \
+ cd "$$am__cwd"; \
+ if $(MAKEINFO) $(AM_MAKEINFOFLAGS) $(MAKEINFOFLAGS) -I doc -I $(srcdir)/doc \
+ -o $@ $(srcdir)/doc/libffi.texi; \
+ then \
+ rc=0; \
+ $(am__cd) $(srcdir); \
+ else \
+ rc=$$?; \
+ $(am__cd) $(srcdir) && \
+ $$restore $$backupdir/* `echo "./$@" | sed 's|[^/]*$$||'`; \
+ fi; \
+ rm -rf $$backupdir; exit $$rc
+
+doc/libffi.dvi: doc/libffi.texi $(srcdir)/doc/version.texi doc/$(am__dirstamp)
+ $(AM_V_TEXI2DVI)TEXINPUTS="$(am__TEXINFO_TEX_DIR)$(PATH_SEPARATOR)$$TEXINPUTS" \
+ MAKEINFO='$(MAKEINFO) $(AM_MAKEINFOFLAGS) $(MAKEINFOFLAGS) -I doc -I $(srcdir)/doc' \
+ $(TEXI2DVI) $(AM_V_texinfo) --build-dir=$(@:.dvi=.t2d) -o $@ $(AM_V_texidevnull) \
+ `test -f 'doc/libffi.texi' || echo '$(srcdir)/'`doc/libffi.texi
+
+doc/libffi.pdf: doc/libffi.texi $(srcdir)/doc/version.texi doc/$(am__dirstamp)
+ $(AM_V_TEXI2PDF)TEXINPUTS="$(am__TEXINFO_TEX_DIR)$(PATH_SEPARATOR)$$TEXINPUTS" \
+ MAKEINFO='$(MAKEINFO) $(AM_MAKEINFOFLAGS) $(MAKEINFOFLAGS) -I doc -I $(srcdir)/doc' \
+ $(TEXI2PDF) $(AM_V_texinfo) --build-dir=$(@:.pdf=.t2p) -o $@ $(AM_V_texidevnull) \
+ `test -f 'doc/libffi.texi' || echo '$(srcdir)/'`doc/libffi.texi
+
+doc/libffi.html: doc/libffi.texi $(srcdir)/doc/version.texi doc/$(am__dirstamp)
+ $(AM_V_MAKEINFO)rm -rf $(@:.html=.htp)
+ $(AM_V_at)if $(MAKEINFOHTML) $(AM_MAKEINFOHTMLFLAGS) $(MAKEINFOFLAGS) -I doc -I $(srcdir)/doc \
+ -o $(@:.html=.htp) `test -f 'doc/libffi.texi' || echo '$(srcdir)/'`doc/libffi.texi; \
+ then \
+ rm -rf $@; \
+ if test ! -d $(@:.html=.htp) && test -d $(@:.html=); then \
+ mv $(@:.html=) $@; else mv $(@:.html=.htp) $@; fi; \
+ else \
+ if test ! -d $(@:.html=.htp) && test -d $(@:.html=); then \
+ rm -rf $(@:.html=); else rm -Rf $(@:.html=.htp) $@; fi; \
+ exit 1; \
+ fi
+$(srcdir)/doc/version.texi: @MAINTAINER_MODE_TRUE@ $(srcdir)/doc/stamp-vti
+$(srcdir)/doc/stamp-vti: doc/libffi.texi $(top_srcdir)/configure
+ test -f doc/$(am__dirstamp) || $(MAKE) $(AM_MAKEFLAGS) doc/$(am__dirstamp)
+ @(dir=.; test -f ./doc/libffi.texi || dir=$(srcdir); \
+ set `$(SHELL) $(srcdir)/mdate-sh $$dir/doc/libffi.texi`; \
+ echo "@set UPDATED $$1 $$2 $$3"; \
+ echo "@set UPDATED-MONTH $$2 $$3"; \
+ echo "@set EDITION $(VERSION)"; \
+ echo "@set VERSION $(VERSION)") > vti.tmp
+ @cmp -s vti.tmp $(srcdir)/doc/version.texi \
+ || (echo "Updating $(srcdir)/doc/version.texi"; \
+ cp vti.tmp $(srcdir)/doc/version.texi)
+ -@rm -f vti.tmp
+ @cp $(srcdir)/doc/version.texi $@
+
+mostlyclean-vti:
+ -rm -f vti.tmp
+
+maintainer-clean-vti:
+@MAINTAINER_MODE_TRUE@ -rm -f $(srcdir)/doc/stamp-vti $(srcdir)/doc/version.texi
+.dvi.ps:
+ $(AM_V_DVIPS)TEXINPUTS="$(am__TEXINFO_TEX_DIR)$(PATH_SEPARATOR)$$TEXINPUTS" \
+ $(DVIPS) $(AM_V_texinfo) -o $@ $<
+
+uninstall-dvi-am:
+ @$(NORMAL_UNINSTALL)
+ @list='$(DVIS)'; test -n "$(dvidir)" || list=; \
+ for p in $$list; do \
+ $(am__strip_dir) \
+ echo " rm -f '$(DESTDIR)$(dvidir)/$$f'"; \
+ rm -f "$(DESTDIR)$(dvidir)/$$f"; \
+ done
+
+uninstall-html-am:
+ @$(NORMAL_UNINSTALL)
+ @list='$(HTMLS)'; test -n "$(htmldir)" || list=; \
+ for p in $$list; do \
+ $(am__strip_dir) \
+ echo " rm -rf '$(DESTDIR)$(htmldir)/$$f'"; \
+ rm -rf "$(DESTDIR)$(htmldir)/$$f"; \
+ done
+
+uninstall-info-am:
+ @$(PRE_UNINSTALL)
+ @if test -d '$(DESTDIR)$(infodir)' && $(am__can_run_installinfo); then \
+ list='$(INFO_DEPS)'; \
+ for file in $$list; do \
+ relfile=`echo "$$file" | sed 's|^.*/||'`; \
+ echo " install-info --info-dir='$(DESTDIR)$(infodir)' --remove '$(DESTDIR)$(infodir)/$$relfile'"; \
+ if install-info --info-dir="$(DESTDIR)$(infodir)" --remove "$(DESTDIR)$(infodir)/$$relfile"; \
+ then :; else test ! -f "$(DESTDIR)$(infodir)/$$relfile" || exit 1; fi; \
+ done; \
+ else :; fi
+ @$(NORMAL_UNINSTALL)
+ @list='$(INFO_DEPS)'; \
+ for file in $$list; do \
+ relfile=`echo "$$file" | sed 's|^.*/||'`; \
+ relfile_i=`echo "$$relfile" | sed 's|\.info$$||;s|$$|.i|'`; \
+ (if test -d "$(DESTDIR)$(infodir)" && cd "$(DESTDIR)$(infodir)"; then \
+ echo " cd '$(DESTDIR)$(infodir)' && rm -f $$relfile $$relfile-[0-9] $$relfile-[0-9][0-9] $$relfile_i[0-9] $$relfile_i[0-9][0-9]"; \
+ rm -f $$relfile $$relfile-[0-9] $$relfile-[0-9][0-9] $$relfile_i[0-9] $$relfile_i[0-9][0-9]; \
+ else :; fi); \
+ done
+
+uninstall-pdf-am:
+ @$(NORMAL_UNINSTALL)
+ @list='$(PDFS)'; test -n "$(pdfdir)" || list=; \
+ for p in $$list; do \
+ $(am__strip_dir) \
+ echo " rm -f '$(DESTDIR)$(pdfdir)/$$f'"; \
+ rm -f "$(DESTDIR)$(pdfdir)/$$f"; \
+ done
+
+uninstall-ps-am:
+ @$(NORMAL_UNINSTALL)
+ @list='$(PSS)'; test -n "$(psdir)" || list=; \
+ for p in $$list; do \
+ $(am__strip_dir) \
+ echo " rm -f '$(DESTDIR)$(psdir)/$$f'"; \
+ rm -f "$(DESTDIR)$(psdir)/$$f"; \
+ done
+
+dist-info: $(INFO_DEPS)
+ @srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; \
+ list='$(INFO_DEPS)'; \
+ for base in $$list; do \
+ case $$base in \
+ $(srcdir)/*) base=`echo "$$base" | sed "s|^$$srcdirstrip/||"`;; \
+ esac; \
+ if test -f $$base; then d=.; else d=$(srcdir); fi; \
+ base_i=`echo "$$base" | sed 's|\.info$$||;s|$$|.i|'`; \
+ for file in $$d/$$base $$d/$$base-[0-9] $$d/$$base-[0-9][0-9] $$d/$$base_i[0-9] $$d/$$base_i[0-9][0-9]; do \
+ if test -f $$file; then \
+ relfile=`expr "$$file" : "$$d/\(.*\)"`; \
+ test -f "$(distdir)/$$relfile" || \
+ cp -p $$file "$(distdir)/$$relfile"; \
+ else :; fi; \
+ done; \
+ done
+
+mostlyclean-aminfo:
+ -rm -rf doc/libffi.t2d doc/libffi.t2p
+
+clean-aminfo:
+ -test -z "doc/libffi.dvi doc/libffi.pdf doc/libffi.ps doc/libffi.html" \
+ || rm -rf doc/libffi.dvi doc/libffi.pdf doc/libffi.ps doc/libffi.html
+
+maintainer-clean-aminfo:
+ @list='$(INFO_DEPS)'; for i in $$list; do \
+ i_i=`echo "$$i" | sed 's|\.info$$||;s|$$|.i|'`; \
+ echo " rm -f $$i $$i-[0-9] $$i-[0-9][0-9] $$i_i[0-9] $$i_i[0-9][0-9]"; \
+ rm -f $$i $$i-[0-9] $$i-[0-9][0-9] $$i_i[0-9] $$i_i[0-9][0-9]; \
+ done
+install-pkgconfigDATA: $(pkgconfig_DATA)
+ @$(NORMAL_INSTALL)
+ @list='$(pkgconfig_DATA)'; test -n "$(pkgconfigdir)" || list=; \
+ if test -n "$$list"; then \
+ echo " $(MKDIR_P) '$(DESTDIR)$(pkgconfigdir)'"; \
+ $(MKDIR_P) "$(DESTDIR)$(pkgconfigdir)" || exit 1; \
+ fi; \
+ for p in $$list; do \
+ if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \
+ echo "$$d$$p"; \
+ done | $(am__base_list) | \
+ while read files; do \
+ echo " $(INSTALL_DATA) $$files '$(DESTDIR)$(pkgconfigdir)'"; \
+ $(INSTALL_DATA) $$files "$(DESTDIR)$(pkgconfigdir)" || exit $$?; \
+ done
+
+uninstall-pkgconfigDATA:
+ @$(NORMAL_UNINSTALL)
+ @list='$(pkgconfig_DATA)'; test -n "$(pkgconfigdir)" || list=; \
+ files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \
+ dir='$(DESTDIR)$(pkgconfigdir)'; $(am__uninstall_files_from_dir)
+
+# This directory's subdirectories are mostly independent; you can cd
+# into them and run 'make' without going through this Makefile.
+# To change the values of 'make' variables: instead of editing Makefiles,
+# (1) if the variable is set in 'config.status', edit 'config.status'
+# (which will cause the Makefiles to be regenerated when you run 'make');
+# (2) otherwise, pass the desired values on the 'make' command line.
+$(am__recursive_targets):
+ @fail=; \
+ if $(am__make_keepgoing); then \
+ failcom='fail=yes'; \
+ else \
+ failcom='exit 1'; \
+ fi; \
+ dot_seen=no; \
+ target=`echo $@ | sed s/-recursive//`; \
+ case "$@" in \
+ distclean-* | maintainer-clean-*) list='$(DIST_SUBDIRS)' ;; \
+ *) list='$(SUBDIRS)' ;; \
+ esac; \
+ for subdir in $$list; do \
+ echo "Making $$target in $$subdir"; \
+ if test "$$subdir" = "."; then \
+ dot_seen=yes; \
+ local_target="$$target-am"; \
+ else \
+ local_target="$$target"; \
+ fi; \
+ ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \
+ || eval $$failcom; \
+ done; \
+ if test "$$dot_seen" = "no"; then \
+ $(MAKE) $(AM_MAKEFLAGS) "$$target-am" || exit 1; \
+ fi; test -z "$$fail"
+
+ID: $(am__tagged_files)
+ $(am__define_uniq_tagged_files); mkid -fID $$unique
+tags: tags-recursive
+TAGS: tags
+
+tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files)
+ set x; \
+ here=`pwd`; \
+ if ($(ETAGS) --etags-include --version) >/dev/null 2>&1; then \
+ include_option=--etags-include; \
+ empty_fix=.; \
+ else \
+ include_option=--include; \
+ empty_fix=; \
+ fi; \
+ list='$(SUBDIRS)'; for subdir in $$list; do \
+ if test "$$subdir" = .; then :; else \
+ test ! -f $$subdir/TAGS || \
+ set "$$@" "$$include_option=$$here/$$subdir/TAGS"; \
+ fi; \
+ done; \
+ $(am__define_uniq_tagged_files); \
+ shift; \
+ if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \
+ test -n "$$unique" || unique=$$empty_fix; \
+ if test $$# -gt 0; then \
+ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+ "$$@" $$unique; \
+ else \
+ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+ $$unique; \
+ fi; \
+ fi
+ctags: ctags-recursive
+
+CTAGS: ctags
+ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files)
+ $(am__define_uniq_tagged_files); \
+ test -z "$(CTAGS_ARGS)$$unique" \
+ || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
+ $$unique
+
+GTAGS:
+ here=`$(am__cd) $(top_builddir) && pwd` \
+ && $(am__cd) $(top_srcdir) \
+ && gtags -i $(GTAGS_ARGS) "$$here"
+cscope: cscope.files
+ test ! -s cscope.files \
+ || $(CSCOPE) -b -q $(AM_CSCOPEFLAGS) $(CSCOPEFLAGS) -i cscope.files $(CSCOPE_ARGS)
+clean-cscope:
+ -rm -f cscope.files
+cscope.files: clean-cscope cscopelist
+cscopelist: cscopelist-recursive
+
+cscopelist-am: $(am__tagged_files)
+ list='$(am__tagged_files)'; \
+ case "$(srcdir)" in \
+ [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \
+ *) sdir=$(subdir)/$(srcdir) ;; \
+ esac; \
+ for i in $$list; do \
+ if test -f "$$i"; then \
+ echo "$(subdir)/$$i"; \
+ else \
+ echo "$$sdir/$$i"; \
+ fi; \
+ done >> $(top_builddir)/cscope.files
+
+distclean-tags:
+ -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
+ -rm -f cscope.out cscope.in.out cscope.po.out cscope.files
+
+distdir: $(DISTFILES)
+ $(am__remove_distdir)
+ test -d "$(distdir)" || mkdir "$(distdir)"
+ @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+ list='$(DISTFILES)'; \
+ dist_files=`for file in $$list; do echo $$file; done | \
+ sed -e "s|^$$srcdirstrip/||;t" \
+ -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
+ case $$dist_files in \
+ */*) $(MKDIR_P) `echo "$$dist_files" | \
+ sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
+ sort -u` ;; \
+ esac; \
+ for file in $$dist_files; do \
+ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
+ if test -d $$d/$$file; then \
+ dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
+ if test -d "$(distdir)/$$file"; then \
+ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
+ fi; \
+ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
+ cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \
+ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
+ fi; \
+ cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \
+ else \
+ test -f "$(distdir)/$$file" \
+ || cp -p $$d/$$file "$(distdir)/$$file" \
+ || exit 1; \
+ fi; \
+ done
+ @list='$(DIST_SUBDIRS)'; for subdir in $$list; do \
+ if test "$$subdir" = .; then :; else \
+ $(am__make_dryrun) \
+ || test -d "$(distdir)/$$subdir" \
+ || $(MKDIR_P) "$(distdir)/$$subdir" \
+ || exit 1; \
+ dir1=$$subdir; dir2="$(distdir)/$$subdir"; \
+ $(am__relativize); \
+ new_distdir=$$reldir; \
+ dir1=$$subdir; dir2="$(top_distdir)"; \
+ $(am__relativize); \
+ new_top_distdir=$$reldir; \
+ echo " (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) top_distdir="$$new_top_distdir" distdir="$$new_distdir" \\"; \
+ echo " am__remove_distdir=: am__skip_length_check=: am__skip_mode_fix=: distdir)"; \
+ ($(am__cd) $$subdir && \
+ $(MAKE) $(AM_MAKEFLAGS) \
+ top_distdir="$$new_top_distdir" \
+ distdir="$$new_distdir" \
+ am__remove_distdir=: \
+ am__skip_length_check=: \
+ am__skip_mode_fix=: \
+ distdir) \
+ || exit 1; \
+ fi; \
+ done
+ $(MAKE) $(AM_MAKEFLAGS) \
+ top_distdir="$(top_distdir)" distdir="$(distdir)" \
+ dist-info dist-hook
+ -test -n "$(am__skip_mode_fix)" \
+ || find "$(distdir)" -type d ! -perm -755 \
+ -exec chmod u+rwx,go+rx {} \; -o \
+ ! -type d ! -perm -444 -links 1 -exec chmod a+r {} \; -o \
+ ! -type d ! -perm -400 -exec chmod a+r {} \; -o \
+ ! -type d ! -perm -444 -exec $(install_sh) -c -m a+r {} {} \; \
+ || chmod -R a+r "$(distdir)"
+dist-gzip: distdir
+ tardir=$(distdir) && $(am__tar) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).tar.gz
+ $(am__post_remove_distdir)
+
+dist-bzip2: distdir
+ tardir=$(distdir) && $(am__tar) | BZIP2=$${BZIP2--9} bzip2 -c >$(distdir).tar.bz2
+ $(am__post_remove_distdir)
+
+dist-lzip: distdir
+ tardir=$(distdir) && $(am__tar) | lzip -c $${LZIP_OPT--9} >$(distdir).tar.lz
+ $(am__post_remove_distdir)
+
+dist-xz: distdir
+ tardir=$(distdir) && $(am__tar) | XZ_OPT=$${XZ_OPT--e} xz -c >$(distdir).tar.xz
+ $(am__post_remove_distdir)
+
+dist-tarZ: distdir
+ tardir=$(distdir) && $(am__tar) | compress -c >$(distdir).tar.Z
+ $(am__post_remove_distdir)
+
+dist-shar: distdir
+ shar $(distdir) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).shar.gz
+ $(am__post_remove_distdir)
+
+dist-zip: distdir
+ -rm -f $(distdir).zip
+ zip -rq $(distdir).zip $(distdir)
+ $(am__post_remove_distdir)
+
+dist dist-all:
+ $(MAKE) $(AM_MAKEFLAGS) $(DIST_TARGETS) am__post_remove_distdir='@:'
+ $(am__post_remove_distdir)
+
+# This target untars the dist file and tries a VPATH configuration. Then
+# it guarantees that the distribution is self-contained by making another
+# tarfile.
+distcheck: dist
+ case '$(DIST_ARCHIVES)' in \
+ *.tar.gz*) \
+ GZIP=$(GZIP_ENV) gzip -dc $(distdir).tar.gz | $(am__untar) ;;\
+ *.tar.bz2*) \
+ bzip2 -dc $(distdir).tar.bz2 | $(am__untar) ;;\
+ *.tar.lz*) \
+ lzip -dc $(distdir).tar.lz | $(am__untar) ;;\
+ *.tar.xz*) \
+ xz -dc $(distdir).tar.xz | $(am__untar) ;;\
+ *.tar.Z*) \
+ uncompress -c $(distdir).tar.Z | $(am__untar) ;;\
+ *.shar.gz*) \
+ GZIP=$(GZIP_ENV) gzip -dc $(distdir).shar.gz | unshar ;;\
+ *.zip*) \
+ unzip $(distdir).zip ;;\
+ esac
+ chmod -R a-w $(distdir)
+ chmod u+w $(distdir)
+ mkdir $(distdir)/_build $(distdir)/_inst
+ chmod a-w $(distdir)
+ test -d $(distdir)/_build || exit 0; \
+ dc_install_base=`$(am__cd) $(distdir)/_inst && pwd | sed -e 's,^[^:\\/]:[\\/],/,'` \
+ && dc_destdir="$${TMPDIR-/tmp}/am-dc-$$$$/" \
+ && am__cwd=`pwd` \
+ && $(am__cd) $(distdir)/_build \
+ && ../configure --srcdir=.. --prefix="$$dc_install_base" \
+ $(AM_DISTCHECK_CONFIGURE_FLAGS) \
+ $(DISTCHECK_CONFIGURE_FLAGS) \
+ && $(MAKE) $(AM_MAKEFLAGS) \
+ && $(MAKE) $(AM_MAKEFLAGS) dvi \
+ && $(MAKE) $(AM_MAKEFLAGS) check \
+ && $(MAKE) $(AM_MAKEFLAGS) install \
+ && $(MAKE) $(AM_MAKEFLAGS) installcheck \
+ && $(MAKE) $(AM_MAKEFLAGS) uninstall \
+ && $(MAKE) $(AM_MAKEFLAGS) distuninstallcheck_dir="$$dc_install_base" \
+ distuninstallcheck \
+ && chmod -R a-w "$$dc_install_base" \
+ && ({ \
+ (cd ../.. && umask 077 && mkdir "$$dc_destdir") \
+ && $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" install \
+ && $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" uninstall \
+ && $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" \
+ distuninstallcheck_dir="$$dc_destdir" distuninstallcheck; \
+ } || { rm -rf "$$dc_destdir"; exit 1; }) \
+ && rm -rf "$$dc_destdir" \
+ && $(MAKE) $(AM_MAKEFLAGS) dist \
+ && rm -rf $(DIST_ARCHIVES) \
+ && $(MAKE) $(AM_MAKEFLAGS) distcleancheck \
+ && cd "$$am__cwd" \
+ || exit 1
+ $(am__post_remove_distdir)
+ @(echo "$(distdir) archives ready for distribution: "; \
+ list='$(DIST_ARCHIVES)'; for i in $$list; do echo $$i; done) | \
+ sed -e 1h -e 1s/./=/g -e 1p -e 1x -e '$$p' -e '$$x'
+distuninstallcheck:
+ @test -n '$(distuninstallcheck_dir)' || { \
+ echo 'ERROR: trying to run $@ with an empty' \
+ '$$(distuninstallcheck_dir)' >&2; \
+ exit 1; \
+ }; \
+ $(am__cd) '$(distuninstallcheck_dir)' || { \
+ echo 'ERROR: cannot chdir into $(distuninstallcheck_dir)' >&2; \
+ exit 1; \
+ }; \
+ test `$(am__distuninstallcheck_listfiles) | wc -l` -eq 0 \
+ || { echo "ERROR: files left after uninstall:" ; \
+ if test -n "$(DESTDIR)"; then \
+ echo " (check DESTDIR support)"; \
+ fi ; \
+ $(distuninstallcheck_listfiles) ; \
+ exit 1; } >&2
+distcleancheck: distclean
+ @if test '$(srcdir)' = . ; then \
+ echo "ERROR: distcleancheck can only run from a VPATH build" ; \
+ exit 1 ; \
+ fi
+ @test `$(distcleancheck_listfiles) | wc -l` -eq 0 \
+ || { echo "ERROR: files left in build directory after distclean:" ; \
+ $(distcleancheck_listfiles) ; \
+ exit 1; } >&2
+check-am: all-am
+check: check-recursive
+all-am: Makefile $(INFO_DEPS) $(LTLIBRARIES) $(DATA) fficonfig.h
+installdirs: installdirs-recursive
+installdirs-am:
+ for dir in "$(DESTDIR)$(toolexeclibdir)" "$(DESTDIR)$(infodir)" "$(DESTDIR)$(pkgconfigdir)"; do \
+ test -z "$$dir" || $(MKDIR_P) "$$dir"; \
+ done
+install: install-recursive
+install-exec: install-exec-recursive
+install-data: install-data-recursive
+uninstall: uninstall-recursive
+
+install-am: all-am
+ @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
+
+installcheck: installcheck-recursive
+install-strip:
+ if test -z '$(STRIP)'; then \
+ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
+ install; \
+ else \
+ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
+ "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \
+ fi
+mostlyclean-generic:
+
+clean-generic:
+
+distclean-generic:
+ -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
+ -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES)
+ -rm -f doc/$(am__dirstamp)
+ -rm -f src/$(DEPDIR)/$(am__dirstamp)
+ -rm -f src/$(am__dirstamp)
+ -rm -f src/aarch64/$(DEPDIR)/$(am__dirstamp)
+ -rm -f src/aarch64/$(am__dirstamp)
+ -rm -f src/alpha/$(DEPDIR)/$(am__dirstamp)
+ -rm -f src/alpha/$(am__dirstamp)
+ -rm -f src/arc/$(DEPDIR)/$(am__dirstamp)
+ -rm -f src/arc/$(am__dirstamp)
+ -rm -f src/arm/$(DEPDIR)/$(am__dirstamp)
+ -rm -f src/arm/$(am__dirstamp)
+ -rm -f src/avr32/$(DEPDIR)/$(am__dirstamp)
+ -rm -f src/avr32/$(am__dirstamp)
+ -rm -f src/bfin/$(DEPDIR)/$(am__dirstamp)
+ -rm -f src/bfin/$(am__dirstamp)
+ -rm -f src/cris/$(DEPDIR)/$(am__dirstamp)
+ -rm -f src/cris/$(am__dirstamp)
+ -rm -f src/frv/$(DEPDIR)/$(am__dirstamp)
+ -rm -f src/frv/$(am__dirstamp)
+ -rm -f src/ia64/$(DEPDIR)/$(am__dirstamp)
+ -rm -f src/ia64/$(am__dirstamp)
+ -rm -f src/m32r/$(DEPDIR)/$(am__dirstamp)
+ -rm -f src/m32r/$(am__dirstamp)
+ -rm -f src/m68k/$(DEPDIR)/$(am__dirstamp)
+ -rm -f src/m68k/$(am__dirstamp)
+ -rm -f src/m88k/$(DEPDIR)/$(am__dirstamp)
+ -rm -f src/m88k/$(am__dirstamp)
+ -rm -f src/metag/$(DEPDIR)/$(am__dirstamp)
+ -rm -f src/metag/$(am__dirstamp)
+ -rm -f src/microblaze/$(DEPDIR)/$(am__dirstamp)
+ -rm -f src/microblaze/$(am__dirstamp)
+ -rm -f src/mips/$(DEPDIR)/$(am__dirstamp)
+ -rm -f src/mips/$(am__dirstamp)
+ -rm -f src/moxie/$(DEPDIR)/$(am__dirstamp)
+ -rm -f src/moxie/$(am__dirstamp)
+ -rm -f src/nios2/$(DEPDIR)/$(am__dirstamp)
+ -rm -f src/nios2/$(am__dirstamp)
+ -rm -f src/or1k/$(DEPDIR)/$(am__dirstamp)
+ -rm -f src/or1k/$(am__dirstamp)
+ -rm -f src/pa/$(DEPDIR)/$(am__dirstamp)
+ -rm -f src/pa/$(am__dirstamp)
+ -rm -f src/powerpc/$(DEPDIR)/$(am__dirstamp)
+ -rm -f src/powerpc/$(am__dirstamp)
+ -rm -f src/s390/$(DEPDIR)/$(am__dirstamp)
+ -rm -f src/s390/$(am__dirstamp)
+ -rm -f src/sh/$(DEPDIR)/$(am__dirstamp)
+ -rm -f src/sh/$(am__dirstamp)
+ -rm -f src/sh64/$(DEPDIR)/$(am__dirstamp)
+ -rm -f src/sh64/$(am__dirstamp)
+ -rm -f src/sparc/$(DEPDIR)/$(am__dirstamp)
+ -rm -f src/sparc/$(am__dirstamp)
+ -rm -f src/tile/$(DEPDIR)/$(am__dirstamp)
+ -rm -f src/tile/$(am__dirstamp)
+ -rm -f src/vax/$(DEPDIR)/$(am__dirstamp)
+ -rm -f src/vax/$(am__dirstamp)
+ -rm -f src/x86/$(DEPDIR)/$(am__dirstamp)
+ -rm -f src/x86/$(am__dirstamp)
+ -rm -f src/xtensa/$(DEPDIR)/$(am__dirstamp)
+ -rm -f src/xtensa/$(am__dirstamp)
+
+maintainer-clean-generic:
+ @echo "This command is intended for maintainers to use"
+ @echo "it deletes files that may require special tools to rebuild."
+clean: clean-recursive
+
+clean-am: clean-aminfo clean-generic clean-libtool \
+ clean-noinstLTLIBRARIES clean-toolexeclibLTLIBRARIES \
+ mostlyclean-am
+
+distclean: distclean-recursive
+ -rm -f $(am__CONFIG_DISTCLEAN_FILES)
+ -rm -rf src/$(DEPDIR) src/aarch64/$(DEPDIR) src/alpha/$(DEPDIR) src/arc/$(DEPDIR) src/arm/$(DEPDIR) src/avr32/$(DEPDIR) src/bfin/$(DEPDIR) src/cris/$(DEPDIR) src/frv/$(DEPDIR) src/ia64/$(DEPDIR) src/m32r/$(DEPDIR) src/m68k/$(DEPDIR) src/m88k/$(DEPDIR) src/metag/$(DEPDIR) src/microblaze/$(DEPDIR) src/mips/$(DEPDIR) src/moxie/$(DEPDIR) src/nios2/$(DEPDIR) src/or1k/$(DEPDIR) src/pa/$(DEPDIR) src/powerpc/$(DEPDIR) src/s390/$(DEPDIR) src/sh/$(DEPDIR) src/sh64/$(DEPDIR) src/sparc/$(DEPDIR) src/tile/$(DEPDIR) src/vax/$(DEPDIR) src/x86/$(DEPDIR) src/xtensa/$(DEPDIR)
+ -rm -f Makefile
+distclean-am: clean-am distclean-compile distclean-generic \
+ distclean-hdr distclean-libtool distclean-tags
+
+dvi: dvi-recursive
+
+dvi-am: $(DVIS)
+
+html: html-recursive
+
+html-am: $(HTMLS)
+
+info: info-recursive
+
+info-am: $(INFO_DEPS)
+
+install-data-am: install-info-am install-pkgconfigDATA
+
+install-dvi: install-dvi-recursive
+
+install-dvi-am: $(DVIS)
+ @$(NORMAL_INSTALL)
+ @list='$(DVIS)'; test -n "$(dvidir)" || list=; \
+ if test -n "$$list"; then \
+ echo " $(MKDIR_P) '$(DESTDIR)$(dvidir)'"; \
+ $(MKDIR_P) "$(DESTDIR)$(dvidir)" || exit 1; \
+ fi; \
+ for p in $$list; do \
+ if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \
+ echo "$$d$$p"; \
+ done | $(am__base_list) | \
+ while read files; do \
+ echo " $(INSTALL_DATA) $$files '$(DESTDIR)$(dvidir)'"; \
+ $(INSTALL_DATA) $$files "$(DESTDIR)$(dvidir)" || exit $$?; \
+ done
+install-exec-am: install-toolexeclibLTLIBRARIES
+
+install-html: install-html-recursive
+
+install-html-am: $(HTMLS)
+ @$(NORMAL_INSTALL)
+ @list='$(HTMLS)'; list2=; test -n "$(htmldir)" || list=; \
+ if test -n "$$list"; then \
+ echo " $(MKDIR_P) '$(DESTDIR)$(htmldir)'"; \
+ $(MKDIR_P) "$(DESTDIR)$(htmldir)" || exit 1; \
+ fi; \
+ for p in $$list; do \
+ if test -f "$$p" || test -d "$$p"; then d=; else d="$(srcdir)/"; fi; \
+ $(am__strip_dir) \
+ d2=$$d$$p; \
+ if test -d "$$d2"; then \
+ echo " $(MKDIR_P) '$(DESTDIR)$(htmldir)/$$f'"; \
+ $(MKDIR_P) "$(DESTDIR)$(htmldir)/$$f" || exit 1; \
+ echo " $(INSTALL_DATA) '$$d2'/* '$(DESTDIR)$(htmldir)/$$f'"; \
+ $(INSTALL_DATA) "$$d2"/* "$(DESTDIR)$(htmldir)/$$f" || exit $$?; \
+ else \
+ list2="$$list2 $$d2"; \
+ fi; \
+ done; \
+ test -z "$$list2" || { echo "$$list2" | $(am__base_list) | \
+ while read files; do \
+ echo " $(INSTALL_DATA) $$files '$(DESTDIR)$(htmldir)'"; \
+ $(INSTALL_DATA) $$files "$(DESTDIR)$(htmldir)" || exit $$?; \
+ done; }
+install-info: install-info-recursive
+
+install-info-am: $(INFO_DEPS)
+ @$(NORMAL_INSTALL)
+ @srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; \
+ list='$(INFO_DEPS)'; test -n "$(infodir)" || list=; \
+ if test -n "$$list"; then \
+ echo " $(MKDIR_P) '$(DESTDIR)$(infodir)'"; \
+ $(MKDIR_P) "$(DESTDIR)$(infodir)" || exit 1; \
+ fi; \
+ for file in $$list; do \
+ case $$file in \
+ $(srcdir)/*) file=`echo "$$file" | sed "s|^$$srcdirstrip/||"`;; \
+ esac; \
+ if test -f $$file; then d=.; else d=$(srcdir); fi; \
+ file_i=`echo "$$file" | sed 's|\.info$$||;s|$$|.i|'`; \
+ for ifile in $$d/$$file $$d/$$file-[0-9] $$d/$$file-[0-9][0-9] \
+ $$d/$$file_i[0-9] $$d/$$file_i[0-9][0-9] ; do \
+ if test -f $$ifile; then \
+ echo "$$ifile"; \
+ else : ; fi; \
+ done; \
+ done | $(am__base_list) | \
+ while read files; do \
+ echo " $(INSTALL_DATA) $$files '$(DESTDIR)$(infodir)'"; \
+ $(INSTALL_DATA) $$files "$(DESTDIR)$(infodir)" || exit $$?; done
+ @$(POST_INSTALL)
+ @if $(am__can_run_installinfo); then \
+ list='$(INFO_DEPS)'; test -n "$(infodir)" || list=; \
+ for file in $$list; do \
+ relfile=`echo "$$file" | sed 's|^.*/||'`; \
+ echo " install-info --info-dir='$(DESTDIR)$(infodir)' '$(DESTDIR)$(infodir)/$$relfile'";\
+ install-info --info-dir="$(DESTDIR)$(infodir)" "$(DESTDIR)$(infodir)/$$relfile" || :;\
+ done; \
+ else : ; fi
+install-man:
+
+install-pdf: install-pdf-recursive
+
+install-pdf-am: $(PDFS)
+ @$(NORMAL_INSTALL)
+ @list='$(PDFS)'; test -n "$(pdfdir)" || list=; \
+ if test -n "$$list"; then \
+ echo " $(MKDIR_P) '$(DESTDIR)$(pdfdir)'"; \
+ $(MKDIR_P) "$(DESTDIR)$(pdfdir)" || exit 1; \
+ fi; \
+ for p in $$list; do \
+ if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \
+ echo "$$d$$p"; \
+ done | $(am__base_list) | \
+ while read files; do \
+ echo " $(INSTALL_DATA) $$files '$(DESTDIR)$(pdfdir)'"; \
+ $(INSTALL_DATA) $$files "$(DESTDIR)$(pdfdir)" || exit $$?; done
+install-ps: install-ps-recursive
+
+install-ps-am: $(PSS)
+ @$(NORMAL_INSTALL)
+ @list='$(PSS)'; test -n "$(psdir)" || list=; \
+ if test -n "$$list"; then \
+ echo " $(MKDIR_P) '$(DESTDIR)$(psdir)'"; \
+ $(MKDIR_P) "$(DESTDIR)$(psdir)" || exit 1; \
+ fi; \
+ for p in $$list; do \
+ if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \
+ echo "$$d$$p"; \
+ done | $(am__base_list) | \
+ while read files; do \
+ echo " $(INSTALL_DATA) $$files '$(DESTDIR)$(psdir)'"; \
+ $(INSTALL_DATA) $$files "$(DESTDIR)$(psdir)" || exit $$?; done
+installcheck-am:
+
+maintainer-clean: maintainer-clean-recursive
+ -rm -f $(am__CONFIG_DISTCLEAN_FILES)
+ -rm -rf $(top_srcdir)/autom4te.cache
+ -rm -rf src/$(DEPDIR) src/aarch64/$(DEPDIR) src/alpha/$(DEPDIR) src/arc/$(DEPDIR) src/arm/$(DEPDIR) src/avr32/$(DEPDIR) src/bfin/$(DEPDIR) src/cris/$(DEPDIR) src/frv/$(DEPDIR) src/ia64/$(DEPDIR) src/m32r/$(DEPDIR) src/m68k/$(DEPDIR) src/m88k/$(DEPDIR) src/metag/$(DEPDIR) src/microblaze/$(DEPDIR) src/mips/$(DEPDIR) src/moxie/$(DEPDIR) src/nios2/$(DEPDIR) src/or1k/$(DEPDIR) src/pa/$(DEPDIR) src/powerpc/$(DEPDIR) src/s390/$(DEPDIR) src/sh/$(DEPDIR) src/sh64/$(DEPDIR) src/sparc/$(DEPDIR) src/tile/$(DEPDIR) src/vax/$(DEPDIR) src/x86/$(DEPDIR) src/xtensa/$(DEPDIR)
+ -rm -f Makefile
+maintainer-clean-am: distclean-am maintainer-clean-aminfo \
+ maintainer-clean-generic maintainer-clean-vti
+
+mostlyclean: mostlyclean-recursive
+
+mostlyclean-am: mostlyclean-aminfo mostlyclean-compile \
+ mostlyclean-generic mostlyclean-libtool mostlyclean-vti
+
+pdf: pdf-recursive
+
+pdf-am: $(PDFS)
+
+ps: ps-recursive
+
+ps-am: $(PSS)
+
+uninstall-am: uninstall-dvi-am uninstall-html-am uninstall-info-am \
+ uninstall-pdf-am uninstall-pkgconfigDATA uninstall-ps-am \
+ uninstall-toolexeclibLTLIBRARIES
+
+.MAKE: $(am__recursive_targets) all install-am install-strip
+
+.PHONY: $(am__recursive_targets) CTAGS GTAGS TAGS all all-am \
+ am--refresh check check-am clean clean-aminfo clean-cscope \
+ clean-generic clean-libtool clean-noinstLTLIBRARIES \
+ clean-toolexeclibLTLIBRARIES cscope cscopelist-am ctags \
+ ctags-am dist dist-all dist-bzip2 dist-gzip dist-hook \
+ dist-info dist-lzip dist-shar dist-tarZ dist-xz dist-zip \
+ distcheck distclean distclean-compile distclean-generic \
+ distclean-hdr distclean-libtool distclean-tags distcleancheck \
+ distdir distuninstallcheck dvi dvi-am html html-am info \
+ info-am install install-am install-data install-data-am \
+ install-dvi install-dvi-am install-exec install-exec-am \
+ install-html install-html-am install-info install-info-am \
+ install-man install-pdf install-pdf-am install-pkgconfigDATA \
+ install-ps install-ps-am install-strip \
+ install-toolexeclibLTLIBRARIES installcheck installcheck-am \
+ installdirs installdirs-am maintainer-clean \
+ maintainer-clean-aminfo maintainer-clean-generic \
+ maintainer-clean-vti mostlyclean mostlyclean-aminfo \
+ mostlyclean-compile mostlyclean-generic mostlyclean-libtool \
+ mostlyclean-vti pdf pdf-am ps ps-am tags tags-am uninstall \
+ uninstall-am uninstall-dvi-am uninstall-html-am \
+ uninstall-info-am uninstall-pdf-am uninstall-pkgconfigDATA \
+ uninstall-ps-am uninstall-toolexeclibLTLIBRARIES
+
+
+dist-hook:
+ if [ -d $(top_srcdir)/.git ] ; then (cd $(top_srcdir); git log --no-decorate) ; else echo 'See git log for history.' ; fi > $(distdir)/ChangeLog
+
+# Tell versions [3.59,3.63) of GNU make to not export all variables.
+# Otherwise a system limit (for SysV at least) may be exceeded.
+.NOEXPORT:
diff --git a/jni/ruby/ext/fiddle/libffi-3.2.1/README b/jni/ruby/ext/fiddle/libffi-3.2.1/README
new file mode 100644
index 0000000..5acc19d
--- /dev/null
+++ b/jni/ruby/ext/fiddle/libffi-3.2.1/README
@@ -0,0 +1,447 @@
+Status
+======
+
+libffi-3.2.1 was released on November 12, 2014. Check the libffi web
+page for updates: <URL:http://sourceware.org/libffi/>.
+
+
+What is libffi?
+===============
+
+Compilers for high level languages generate code that follow certain
+conventions. These conventions are necessary, in part, for separate
+compilation to work. One such convention is the "calling
+convention". The "calling convention" is essentially a set of
+assumptions made by the compiler about where function arguments will
+be found on entry to a function. A "calling convention" also specifies
+where the return value for a function is found.
+
+Some programs may not know at the time of compilation what arguments
+are to be passed to a function. For instance, an interpreter may be
+told at run-time about the number and types of arguments used to call
+a given function. Libffi can be used in such programs to provide a
+bridge from the interpreter program to compiled code.
+
+The libffi library provides a portable, high level programming
+interface to various calling conventions. This allows a programmer to
+call any function specified by a call interface description at run
+time.
+
+FFI stands for Foreign Function Interface. A foreign function
+interface is the popular name for the interface that allows code
+written in one language to call code written in another language. The
+libffi library really only provides the lowest, machine dependent
+layer of a fully featured foreign function interface. A layer must
+exist above libffi that handles type conversions for values passed
+between the two languages.
+
+
+Supported Platforms
+===================
+
+Libffi has been ported to many different platforms.
+For specific configuration details and testing status, please
+refer to the wiki page here:
+
+ http://www.moxielogic.org/wiki/index.php?title=Libffi_3.2
+
+At the time of release, the following basic configurations have been
+tested:
+
+|-----------------+------------------+-------------------------|
+| Architecture | Operating System | Compiler |
+|-----------------+------------------+-------------------------|
+| AArch64 (ARM64) | iOS | Clang |
+| AArch64 | Linux | GCC |
+| Alpha | Linux | GCC |
+| Alpha | Tru64 | GCC |
+| ARC | Linux | GCC |
+| ARM | Linux | GCC |
+| ARM | iOS | GCC |
+| AVR32 | Linux | GCC |
+| Blackfin | uClinux | GCC |
+| HPPA | HPUX | GCC |
+| IA-64 | Linux | GCC |
+| M68K | FreeMiNT | GCC |
+| M68K | Linux | GCC |
+| M68K | RTEMS | GCC |
+| M88K | OpenBSD/mvme88k | GCC |
+| Meta | Linux | GCC |
+| MicroBlaze | Linux | GCC |
+| MIPS | IRIX | GCC |
+| MIPS | Linux | GCC |
+| MIPS | RTEMS | GCC |
+| MIPS64 | Linux | GCC |
+| Moxie | Bare metal | GCC |
+| Nios II | Linux | GCC |
+| OpenRISC | Linux | GCC |
+| PowerPC 32-bit | AIX | IBM XL C |
+| PowerPC 64-bit | AIX | IBM XL C |
+| PowerPC | AMIGA | GCC |
+| PowerPC | Linux | GCC |
+| PowerPC | Mac OSX | GCC |
+| PowerPC | FreeBSD | GCC |
+| PowerPC 64-bit | FreeBSD | GCC |
+| PowerPC 64-bit | Linux ELFv1 | GCC |
+| PowerPC 64-bit | Linux ELFv2 | GCC |
+| S390 | Linux | GCC |
+| S390X | Linux | GCC |
+| SPARC | Linux | GCC |
+| SPARC | Solaris | GCC |
+| SPARC | Solaris | Oracle Solaris Studio C |
+| SPARC64 | Linux | GCC |
+| SPARC64 | FreeBSD | GCC |
+| SPARC64 | Solaris | Oracle Solaris Studio C |
+| TILE-Gx/TILEPro | Linux | GCC |
+| VAX | OpenBSD/vax | GCC |
+| X86 | FreeBSD | GCC |
+| X86 | GNU HURD | GCC |
+| X86 | Interix | GCC |
+| X86 | kFreeBSD | GCC |
+| X86 | Linux | GCC |
+| X86 | Mac OSX | GCC |
+| X86 | OpenBSD | GCC |
+| X86 | OS/2 | GCC |
+| X86 | Solaris | GCC |
+| X86 | Solaris | Oracle Solaris Studio C |
+| X86 | Windows/Cygwin | GCC |
+| X86 | Windows/MingW | GCC |
+| X86-64 | FreeBSD | GCC |
+| X86-64 | Linux | GCC |
+| X86-64 | Linux/x32 | GCC |
+| X86-64 | OpenBSD | GCC |
+| X86-64 | Solaris | Oracle Solaris Studio C |
+| X86-64 | Windows/Cygwin | GCC |
+| X86-64 | Windows/MingW | GCC |
+| Xtensa | Linux | GCC |
+|-----------------+------------------+-------------------------|
+
+Please send additional platform test results to
+libffi-discuss@sourceware.org and feel free to update the wiki page
+above.
+
+Installing libffi
+=================
+
+First you must configure the distribution for your particular
+system. Go to the directory you wish to build libffi in and run the
+"configure" program found in the root directory of the libffi source
+distribution.
+
+If you're building libffi directly from version control, configure won't
+exist yet; run ./autogen.sh first.
+
+You may want to tell configure where to install the libffi library and
+header files. To do that, use the --prefix configure switch. Libffi
+will install under /usr/local by default.
+
+If you want to enable extra run-time debugging checks use the the
+--enable-debug configure switch. This is useful when your program dies
+mysteriously while using libffi.
+
+Another useful configure switch is --enable-purify-safety. Using this
+will add some extra code which will suppress certain warnings when you
+are using Purify with libffi. Only use this switch when using
+Purify, as it will slow down the library.
+
+It's also possible to build libffi on Windows platforms with
+Microsoft's Visual C++ compiler. In this case, use the msvcc.sh
+wrapper script during configuration like so:
+
+path/to/configure CC=path/to/msvcc.sh CXX=path/to/msvcc.sh LD=link CPP="cl -nologo -EP"
+
+For 64-bit Windows builds, use CC="path/to/msvcc.sh -m64" and
+CXX="path/to/msvcc.sh -m64". You may also need to specify --build
+appropriately.
+
+It is also possible to build libffi on Windows platforms with the LLVM
+project's clang-cl compiler, like below:
+
+path/to/configure CC="path/to/msvcc.sh -clang-cl" CXX="path/to/msvcc.sh -clang-cl" LD=link CPP="clang-cl -EP"
+
+When building with MSVC under a MingW environment, you may need to
+remove the line in configure that sets 'fix_srcfile_path' to a 'cygpath'
+command. ('cygpath' is not present in MingW, and is not required when
+using MingW-style paths.)
+
+For iOS builds, the 'libffi.xcodeproj' Xcode project is available.
+
+Configure has many other options. Use "configure --help" to see them all.
+
+Once configure has finished, type "make". Note that you must be using
+GNU make. You can ftp GNU make from ftp.gnu.org:/pub/gnu/make .
+
+To ensure that libffi is working as advertised, type "make check".
+This will require that you have DejaGNU installed.
+
+To install the library and header files, type "make install".
+
+
+History
+=======
+
+See the git log for details at http://github.com/atgreen/libffi.
+
+3.2.1 Nov-12-14
+ Build fix for non-iOS AArch64 targets.
+
+3.2 Nov-11-14
+ Add C99 Complex Type support (currently only supported on
+ s390).
+ Add support for PASCAL and REGISTER calling conventions on x86
+ Windows/Linux.
+ Add OpenRISC and Cygwin-64 support.
+ Bug fixes.
+
+3.1 May-19-14
+ Add AArch64 (ARM64) iOS support.
+ Add Nios II support.
+ Add m88k and DEC VAX support.
+ Add support for stdcall, thiscall, and fastcall on non-Windows
+ 32-bit x86 targets such as Linux.
+ Various Android, MIPS N32, x86, FreeBSD and UltraSPARC IIi
+ fixes.
+ Make the testsuite more robust: eliminate several spurious
+ failures, and respect the $CC and $CXX environment variables.
+ Archive off the manually maintained ChangeLog in favor of git
+ log.
+
+3.0.13 Mar-17-13
+ Add Meta support.
+ Add missing Moxie bits.
+ Fix stack alignment bug on 32-bit x86.
+ Build fix for m68000 targets.
+ Build fix for soft-float Power targets.
+ Fix the install dir location for some platforms when building
+ with GCC (OS X, Solaris).
+ Fix Cygwin regression.
+
+3.0.12 Feb-11-13
+ Add Moxie support.
+ Add AArch64 support.
+ Add Blackfin support.
+ Add TILE-Gx/TILEPro support.
+ Add MicroBlaze support.
+ Add Xtensa support.
+ Add support for PaX enabled kernels with MPROTECT.
+ Add support for native vendor compilers on
+ Solaris and AIX.
+ Work around LLVM/GCC interoperability issue on x86_64.
+
+3.0.11 Apr-11-12
+ Lots of build fixes.
+ Add support for variadic functions (ffi_prep_cif_var).
+ Add Linux/x32 support.
+ Add thiscall, fastcall and MSVC cdecl support on Windows.
+ Add Amiga and newer MacOS support.
+ Add m68k FreeMiNT support.
+ Integration with iOS' xcode build tools.
+ Fix Octeon and MC68881 support.
+ Fix code pessimizations.
+
+3.0.10 Aug-23-11
+ Add support for Apple's iOS.
+ Add support for ARM VFP ABI.
+ Add RTEMS support for MIPS and M68K.
+ Fix instruction cache clearing problems on
+ ARM and SPARC.
+ Fix the N64 build on mips-sgi-irix6.5.
+ Enable builds with Microsoft's compiler.
+ Enable x86 builds with Oracle's Solaris compiler.
+ Fix support for calling code compiled with Oracle's Sparc
+ Solaris compiler.
+ Testsuite fixes for Tru64 Unix.
+ Additional platform support.
+
+3.0.9 Dec-31-09
+ Add AVR32 and win64 ports. Add ARM softfp support.
+ Many fixes for AIX, Solaris, HP-UX, *BSD.
+ Several PowerPC and x86-64 bug fixes.
+ Build DLL for windows.
+
+3.0.8 Dec-19-08
+ Add *BSD, BeOS, and PA-Linux support.
+
+3.0.7 Nov-11-08
+ Fix for ppc FreeBSD.
+ (thanks to Andreas Tobler)
+
+3.0.6 Jul-17-08
+ Fix for closures on sh.
+ Mark the sh/sh64 stack as non-executable.
+ (both thanks to Kaz Kojima)
+
+3.0.5 Apr-3-08
+ Fix libffi.pc file.
+ Fix #define ARM for IcedTea users.
+ Fix x86 closure bug.
+
+3.0.4 Feb-24-08
+ Fix x86 OpenBSD configury.
+
+3.0.3 Feb-22-08
+ Enable x86 OpenBSD thanks to Thomas Heller, and
+ x86-64 FreeBSD thanks to Björn König and Andreas Tobler.
+ Clean up test instruction in README.
+
+3.0.2 Feb-21-08
+ Improved x86 FreeBSD support.
+ Thanks to Björn König.
+
+3.0.1 Feb-15-08
+ Fix instruction cache flushing bug on MIPS.
+ Thanks to David Daney.
+
+3.0.0 Feb-15-08
+ Many changes, mostly thanks to the GCC project.
+ Cygnus Solutions is now Red Hat.
+
+ [10 years go by...]
+
+1.20 Oct-5-98
+ Raffaele Sena produces ARM port.
+
+1.19 Oct-5-98
+ Fixed x86 long double and long long return support.
+ m68k bug fixes from Andreas Schwab.
+ Patch for DU assembler compatibility for the Alpha from Richard
+ Henderson.
+
+1.18 Apr-17-98
+ Bug fixes and MIPS configuration changes.
+
+1.17 Feb-24-98
+ Bug fixes and m68k port from Andreas Schwab. PowerPC port from
+ Geoffrey Keating. Various bug x86, Sparc and MIPS bug fixes.
+
+1.16 Feb-11-98
+ Richard Henderson produces Alpha port.
+
+1.15 Dec-4-97
+ Fixed an n32 ABI bug. New libtool, auto* support.
+
+1.14 May-13-97
+ libtool is now used to generate shared and static libraries.
+ Fixed a minor portability problem reported by Russ McManus
+ <mcmanr@eq.gs.com>.
+
+1.13 Dec-2-96
+ Added --enable-purify-safety to keep Purify from complaining
+ about certain low level code.
+ Sparc fix for calling functions with < 6 args.
+ Linux x86 a.out fix.
+
+1.12 Nov-22-96
+ Added missing ffi_type_void, needed for supporting void return
+ types. Fixed test case for non MIPS machines. Cygnus Support
+ is now Cygnus Solutions.
+
+1.11 Oct-30-96
+ Added notes about GNU make.
+
+1.10 Oct-29-96
+ Added configuration fix for non GNU compilers.
+
+1.09 Oct-29-96
+ Added --enable-debug configure switch. Clean-ups based on LCLint
+ feedback. ffi_mips.h is always installed. Many configuration
+ fixes. Fixed ffitest.c for sparc builds.
+
+1.08 Oct-15-96
+ Fixed n32 problem. Many clean-ups.
+
+1.07 Oct-14-96
+ Gordon Irlam rewrites v8.S again. Bug fixes.
+
+1.06 Oct-14-96
+ Gordon Irlam improved the sparc port.
+
+1.05 Oct-14-96
+ Interface changes based on feedback.
+
+1.04 Oct-11-96
+ Sparc port complete (modulo struct passing bug).
+
+1.03 Oct-10-96
+ Passing struct args, and returning struct values works for
+ all architectures/calling conventions. Expanded tests.
+
+1.02 Oct-9-96
+ Added SGI n32 support. Fixed bugs in both o32 and Linux support.
+ Added "make test".
+
+1.01 Oct-8-96
+ Fixed float passing bug in mips version. Restructured some
+ of the code. Builds cleanly with SGI tools.
+
+1.00 Oct-7-96
+ First release. No public announcement.
+
+
+Authors & Credits
+=================
+
+libffi was originally written by Anthony Green <green@moxielogic.com>.
+
+The developers of the GNU Compiler Collection project have made
+innumerable valuable contributions. See the ChangeLog file for
+details.
+
+Some of the ideas behind libffi were inspired by Gianni Mariani's free
+gencall library for Silicon Graphics machines.
+
+The closure mechanism was designed and implemented by Kresten Krab
+Thorup.
+
+Major processor architecture ports were contributed by the following
+developers:
+
+aarch64 Marcus Shawcroft, James Greenhalgh
+alpha Richard Henderson
+arm Raffaele Sena
+blackfin Alexandre Keunecke I. de Mendonca
+cris Simon Posnjak, Hans-Peter Nilsson
+frv Anthony Green
+ia64 Hans Boehm
+m32r Kazuhiro Inaoka
+m68k Andreas Schwab
+m88k Miod Vallat
+microblaze Nathan Rossi
+mips Anthony Green, Casey Marshall
+mips64 David Daney
+moxie Anthony Green
+nios ii Sandra Loosemore
+openrisc Sebastian Macke
+pa Randolph Chung, Dave Anglin, Andreas Tobler
+powerpc Geoffrey Keating, Andreas Tobler,
+ David Edelsohn, John Hornkvist
+powerpc64 Jakub Jelinek
+s390 Gerhard Tonn, Ulrich Weigand
+sh Kaz Kojima
+sh64 Kaz Kojima
+sparc Anthony Green, Gordon Irlam
+tile-gx/tilepro Walter Lee
+vax Miod Vallat
+x86 Anthony Green, Jon Beniston
+x86-64 Bo Thorsen
+xtensa Chris Zankel
+
+Jesper Skov and Andrew Haley both did more than their fair share of
+stepping through the code and tracking down bugs.
+
+Thanks also to Tom Tromey for bug fixes, documentation and
+configuration help.
+
+Thanks to Jim Blandy, who provided some useful feedback on the libffi
+interface.
+
+Andreas Tobler has done a tremendous amount of work on the testsuite.
+
+Alex Oliva solved the executable page problem for SElinux.
+
+The list above is almost certainly incomplete and inaccurate. I'm
+happy to make corrections or additions upon request.
+
+If you have a problem, or have found a bug, please send a note to the
+author at green@moxielogic.com, or the project mailing list at
+libffi-discuss@sourceware.org.
diff --git a/jni/ruby/ext/fiddle/libffi-3.2.1/acinclude.m4 b/jni/ruby/ext/fiddle/libffi-3.2.1/acinclude.m4
new file mode 100644
index 0000000..3e8f8ba
--- /dev/null
+++ b/jni/ruby/ext/fiddle/libffi-3.2.1/acinclude.m4
@@ -0,0 +1,92 @@
+# mmap(2) blacklisting. Some platforms provide the mmap library routine
+# but don't support all of the features we need from it.
+AC_DEFUN([AC_FUNC_MMAP_BLACKLIST],
+[
+AC_CHECK_HEADER([sys/mman.h],
+ [libffi_header_sys_mman_h=yes], [libffi_header_sys_mman_h=no])
+AC_CHECK_FUNC([mmap], [libffi_func_mmap=yes], [libffi_func_mmap=no])
+if test "$libffi_header_sys_mman_h" != yes \
+ || test "$libffi_func_mmap" != yes; then
+ ac_cv_func_mmap_file=no
+ ac_cv_func_mmap_dev_zero=no
+ ac_cv_func_mmap_anon=no
+else
+ AC_CACHE_CHECK([whether read-only mmap of a plain file works],
+ ac_cv_func_mmap_file,
+ [# Add a system to this blacklist if
+ # mmap(0, stat_size, PROT_READ, MAP_PRIVATE, fd, 0) doesn't return a
+ # memory area containing the same data that you'd get if you applied
+ # read() to the same fd. The only system known to have a problem here
+ # is VMS, where text files have record structure.
+ case "$host_os" in
+ vms* | ultrix*)
+ ac_cv_func_mmap_file=no ;;
+ *)
+ ac_cv_func_mmap_file=yes;;
+ esac])
+ AC_CACHE_CHECK([whether mmap from /dev/zero works],
+ ac_cv_func_mmap_dev_zero,
+ [# Add a system to this blacklist if it has mmap() but /dev/zero
+ # does not exist, or if mmapping /dev/zero does not give anonymous
+ # zeroed pages with both the following properties:
+ # 1. If you map N consecutive pages in with one call, and then
+ # unmap any subset of those pages, the pages that were not
+ # explicitly unmapped remain accessible.
+ # 2. If you map two adjacent blocks of memory and then unmap them
+ # both at once, they must both go away.
+ # Systems known to be in this category are Windows (all variants),
+ # VMS, and Darwin.
+ case "$host_os" in
+ vms* | cygwin* | pe | mingw* | darwin* | ultrix* | hpux10* | hpux11.00)
+ ac_cv_func_mmap_dev_zero=no ;;
+ *)
+ ac_cv_func_mmap_dev_zero=yes;;
+ esac])
+
+ # Unlike /dev/zero, the MAP_ANON(YMOUS) defines can be probed for.
+ AC_CACHE_CHECK([for MAP_ANON(YMOUS)], ac_cv_decl_map_anon,
+ [AC_TRY_COMPILE(
+[#include <sys/types.h>
+#include <sys/mman.h>
+#include <unistd.h>
+
+#ifndef MAP_ANONYMOUS
+#define MAP_ANONYMOUS MAP_ANON
+#endif
+],
+[int n = MAP_ANONYMOUS;],
+ ac_cv_decl_map_anon=yes,
+ ac_cv_decl_map_anon=no)])
+
+ if test $ac_cv_decl_map_anon = no; then
+ ac_cv_func_mmap_anon=no
+ else
+ AC_CACHE_CHECK([whether mmap with MAP_ANON(YMOUS) works],
+ ac_cv_func_mmap_anon,
+ [# Add a system to this blacklist if it has mmap() and MAP_ANON or
+ # MAP_ANONYMOUS, but using mmap(..., MAP_PRIVATE|MAP_ANONYMOUS, -1, 0)
+ # doesn't give anonymous zeroed pages with the same properties listed
+ # above for use of /dev/zero.
+ # Systems known to be in this category are Windows, VMS, and SCO Unix.
+ case "$host_os" in
+ vms* | cygwin* | pe | mingw* | sco* | udk* )
+ ac_cv_func_mmap_anon=no ;;
+ *)
+ ac_cv_func_mmap_anon=yes;;
+ esac])
+ fi
+fi
+
+if test $ac_cv_func_mmap_file = yes; then
+ AC_DEFINE(HAVE_MMAP_FILE, 1,
+ [Define if read-only mmap of a plain file works.])
+fi
+if test $ac_cv_func_mmap_dev_zero = yes; then
+ AC_DEFINE(HAVE_MMAP_DEV_ZERO, 1,
+ [Define if mmap of /dev/zero works.])
+fi
+if test $ac_cv_func_mmap_anon = yes; then
+ AC_DEFINE(HAVE_MMAP_ANON, 1,
+ [Define if mmap with MAP_ANON(YMOUS) works.])
+fi
+])
diff --git a/jni/ruby/ext/fiddle/libffi-3.2.1/aclocal.m4 b/jni/ruby/ext/fiddle/libffi-3.2.1/aclocal.m4
new file mode 100644
index 0000000..6292fba
--- /dev/null
+++ b/jni/ruby/ext/fiddle/libffi-3.2.1/aclocal.m4
@@ -0,0 +1,1961 @@
+# generated automatically by aclocal 1.13.4 -*- Autoconf -*-
+
+# Copyright (C) 1996-2013 Free Software Foundation, Inc.
+
+# This file is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
+# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE.
+
+m4_ifndef([AC_CONFIG_MACRO_DIRS], [m4_defun([_AM_CONFIG_MACRO_DIRS], [])m4_defun([AC_CONFIG_MACRO_DIRS], [_AM_CONFIG_MACRO_DIRS($@)])])
+m4_ifndef([AC_AUTOCONF_VERSION],
+ [m4_copy([m4_PACKAGE_VERSION], [AC_AUTOCONF_VERSION])])dnl
+m4_if(m4_defn([AC_AUTOCONF_VERSION]), [2.69],,
+[m4_warning([this file was generated for autoconf 2.69.
+You have another version of autoconf. It may work, but is not guaranteed to.
+If you have problems, you may need to regenerate the build system entirely.
+To do so, use the procedure documented by the package, typically 'autoreconf'.])])
+
+# ltdl.m4 - Configure ltdl for the target system. -*-Autoconf-*-
+#
+# Copyright (C) 1999-2006, 2007, 2008, 2011 Free Software Foundation, Inc.
+# Written by Thomas Tanner, 1999
+#
+# This file is free software; the Free Software Foundation gives
+# unlimited permission to copy and/or distribute it, with or without
+# modifications, as long as this notice is preserved.
+
+# serial 18 LTDL_INIT
+
+# LT_CONFIG_LTDL_DIR(DIRECTORY, [LTDL-MODE])
+# ------------------------------------------
+# DIRECTORY contains the libltdl sources. It is okay to call this
+# function multiple times, as long as the same DIRECTORY is always given.
+AC_DEFUN([LT_CONFIG_LTDL_DIR],
+[AC_BEFORE([$0], [LTDL_INIT])
+_$0($*)
+])# LT_CONFIG_LTDL_DIR
+
+# We break this out into a separate macro, so that we can call it safely
+# internally without being caught accidentally by the sed scan in libtoolize.
+m4_defun([_LT_CONFIG_LTDL_DIR],
+[dnl remove trailing slashes
+m4_pushdef([_ARG_DIR], m4_bpatsubst([$1], [/*$]))
+m4_case(_LTDL_DIR,
+ [], [dnl only set lt_ltdl_dir if _ARG_DIR is not simply `.'
+ m4_if(_ARG_DIR, [.],
+ [],
+ [m4_define([_LTDL_DIR], _ARG_DIR)
+ _LT_SHELL_INIT([lt_ltdl_dir=']_ARG_DIR['])])],
+ [m4_if(_ARG_DIR, _LTDL_DIR,
+ [],
+ [m4_fatal([multiple libltdl directories: `]_LTDL_DIR[', `]_ARG_DIR['])])])
+m4_popdef([_ARG_DIR])
+])# _LT_CONFIG_LTDL_DIR
+
+# Initialise:
+m4_define([_LTDL_DIR], [])
+
+
+# _LT_BUILD_PREFIX
+# ----------------
+# If Autoconf is new enough, expand to `${top_build_prefix}', otherwise
+# to `${top_builddir}/'.
+m4_define([_LT_BUILD_PREFIX],
+[m4_ifdef([AC_AUTOCONF_VERSION],
+ [m4_if(m4_version_compare(m4_defn([AC_AUTOCONF_VERSION]), [2.62]),
+ [-1], [m4_ifdef([_AC_HAVE_TOP_BUILD_PREFIX],
+ [${top_build_prefix}],
+ [${top_builddir}/])],
+ [${top_build_prefix}])],
+ [${top_builddir}/])[]dnl
+])
+
+
+# LTDL_CONVENIENCE
+# ----------------
+# sets LIBLTDL to the link flags for the libltdl convenience library and
+# LTDLINCL to the include flags for the libltdl header and adds
+# --enable-ltdl-convenience to the configure arguments. Note that
+# AC_CONFIG_SUBDIRS is not called here. LIBLTDL will be prefixed with
+# '${top_build_prefix}' if available, otherwise with '${top_builddir}/',
+# and LTDLINCL will be prefixed with '${top_srcdir}/' (note the single
+# quotes!). If your package is not flat and you're not using automake,
+# define top_build_prefix, top_builddir, and top_srcdir appropriately
+# in your Makefiles.
+AC_DEFUN([LTDL_CONVENIENCE],
+[AC_BEFORE([$0], [LTDL_INIT])dnl
+dnl Although the argument is deprecated and no longer documented,
+dnl LTDL_CONVENIENCE used to take a DIRECTORY orgument, if we have one
+dnl here make sure it is the same as any other declaration of libltdl's
+dnl location! This also ensures lt_ltdl_dir is set when configure.ac is
+dnl not yet using an explicit LT_CONFIG_LTDL_DIR.
+m4_ifval([$1], [_LT_CONFIG_LTDL_DIR([$1])])dnl
+_$0()
+])# LTDL_CONVENIENCE
+
+# AC_LIBLTDL_CONVENIENCE accepted a directory argument in older libtools,
+# now we have LT_CONFIG_LTDL_DIR:
+AU_DEFUN([AC_LIBLTDL_CONVENIENCE],
+[_LT_CONFIG_LTDL_DIR([m4_default([$1], [libltdl])])
+_LTDL_CONVENIENCE])
+
+dnl aclocal-1.4 backwards compatibility:
+dnl AC_DEFUN([AC_LIBLTDL_CONVENIENCE], [])
+
+
+# _LTDL_CONVENIENCE
+# -----------------
+# Code shared by LTDL_CONVENIENCE and LTDL_INIT([convenience]).
+m4_defun([_LTDL_CONVENIENCE],
+[case $enable_ltdl_convenience in
+ no) AC_MSG_ERROR([this package needs a convenience libltdl]) ;;
+ "") enable_ltdl_convenience=yes
+ ac_configure_args="$ac_configure_args --enable-ltdl-convenience" ;;
+esac
+LIBLTDL='_LT_BUILD_PREFIX'"${lt_ltdl_dir+$lt_ltdl_dir/}libltdlc.la"
+LTDLDEPS=$LIBLTDL
+LTDLINCL='-I${top_srcdir}'"${lt_ltdl_dir+/$lt_ltdl_dir}"
+
+AC_SUBST([LIBLTDL])
+AC_SUBST([LTDLDEPS])
+AC_SUBST([LTDLINCL])
+
+# For backwards non-gettext consistent compatibility...
+INCLTDL="$LTDLINCL"
+AC_SUBST([INCLTDL])
+])# _LTDL_CONVENIENCE
+
+
+# LTDL_INSTALLABLE
+# ----------------
+# sets LIBLTDL to the link flags for the libltdl installable library
+# and LTDLINCL to the include flags for the libltdl header and adds
+# --enable-ltdl-install to the configure arguments. Note that
+# AC_CONFIG_SUBDIRS is not called from here. If an installed libltdl
+# is not found, LIBLTDL will be prefixed with '${top_build_prefix}' if
+# available, otherwise with '${top_builddir}/', and LTDLINCL will be
+# prefixed with '${top_srcdir}/' (note the single quotes!). If your
+# package is not flat and you're not using automake, define top_build_prefix,
+# top_builddir, and top_srcdir appropriately in your Makefiles.
+# In the future, this macro may have to be called after LT_INIT.
+AC_DEFUN([LTDL_INSTALLABLE],
+[AC_BEFORE([$0], [LTDL_INIT])dnl
+dnl Although the argument is deprecated and no longer documented,
+dnl LTDL_INSTALLABLE used to take a DIRECTORY orgument, if we have one
+dnl here make sure it is the same as any other declaration of libltdl's
+dnl location! This also ensures lt_ltdl_dir is set when configure.ac is
+dnl not yet using an explicit LT_CONFIG_LTDL_DIR.
+m4_ifval([$1], [_LT_CONFIG_LTDL_DIR([$1])])dnl
+_$0()
+])# LTDL_INSTALLABLE
+
+# AC_LIBLTDL_INSTALLABLE accepted a directory argument in older libtools,
+# now we have LT_CONFIG_LTDL_DIR:
+AU_DEFUN([AC_LIBLTDL_INSTALLABLE],
+[_LT_CONFIG_LTDL_DIR([m4_default([$1], [libltdl])])
+_LTDL_INSTALLABLE])
+
+dnl aclocal-1.4 backwards compatibility:
+dnl AC_DEFUN([AC_LIBLTDL_INSTALLABLE], [])
+
+
+# _LTDL_INSTALLABLE
+# -----------------
+# Code shared by LTDL_INSTALLABLE and LTDL_INIT([installable]).
+m4_defun([_LTDL_INSTALLABLE],
+[if test -f $prefix/lib/libltdl.la; then
+ lt_save_LDFLAGS="$LDFLAGS"
+ LDFLAGS="-L$prefix/lib $LDFLAGS"
+ AC_CHECK_LIB([ltdl], [lt_dlinit], [lt_lib_ltdl=yes])
+ LDFLAGS="$lt_save_LDFLAGS"
+ if test x"${lt_lib_ltdl-no}" = xyes; then
+ if test x"$enable_ltdl_install" != xyes; then
+ # Don't overwrite $prefix/lib/libltdl.la without --enable-ltdl-install
+ AC_MSG_WARN([not overwriting libltdl at $prefix, force with `--enable-ltdl-install'])
+ enable_ltdl_install=no
+ fi
+ elif test x"$enable_ltdl_install" = xno; then
+ AC_MSG_WARN([libltdl not installed, but installation disabled])
+ fi
+fi
+
+# If configure.ac declared an installable ltdl, and the user didn't override
+# with --disable-ltdl-install, we will install the shipped libltdl.
+case $enable_ltdl_install in
+ no) ac_configure_args="$ac_configure_args --enable-ltdl-install=no"
+ LIBLTDL="-lltdl"
+ LTDLDEPS=
+ LTDLINCL=
+ ;;
+ *) enable_ltdl_install=yes
+ ac_configure_args="$ac_configure_args --enable-ltdl-install"
+ LIBLTDL='_LT_BUILD_PREFIX'"${lt_ltdl_dir+$lt_ltdl_dir/}libltdl.la"
+ LTDLDEPS=$LIBLTDL
+ LTDLINCL='-I${top_srcdir}'"${lt_ltdl_dir+/$lt_ltdl_dir}"
+ ;;
+esac
+
+AC_SUBST([LIBLTDL])
+AC_SUBST([LTDLDEPS])
+AC_SUBST([LTDLINCL])
+
+# For backwards non-gettext consistent compatibility...
+INCLTDL="$LTDLINCL"
+AC_SUBST([INCLTDL])
+])# LTDL_INSTALLABLE
+
+
+# _LTDL_MODE_DISPATCH
+# -------------------
+m4_define([_LTDL_MODE_DISPATCH],
+[dnl If _LTDL_DIR is `.', then we are configuring libltdl itself:
+m4_if(_LTDL_DIR, [],
+ [],
+ dnl if _LTDL_MODE was not set already, the default value is `subproject':
+ [m4_case(m4_default(_LTDL_MODE, [subproject]),
+ [subproject], [AC_CONFIG_SUBDIRS(_LTDL_DIR)
+ _LT_SHELL_INIT([lt_dlopen_dir="$lt_ltdl_dir"])],
+ [nonrecursive], [_LT_SHELL_INIT([lt_dlopen_dir="$lt_ltdl_dir"; lt_libobj_prefix="$lt_ltdl_dir/"])],
+ [recursive], [],
+ [m4_fatal([unknown libltdl mode: ]_LTDL_MODE)])])dnl
+dnl Be careful not to expand twice:
+m4_define([$0], [])
+])# _LTDL_MODE_DISPATCH
+
+
+# _LT_LIBOBJ(MODULE_NAME)
+# -----------------------
+# Like AC_LIBOBJ, except that MODULE_NAME goes into _LT_LIBOBJS instead
+# of into LIBOBJS.
+AC_DEFUN([_LT_LIBOBJ], [
+ m4_pattern_allow([^_LT_LIBOBJS$])
+ _LT_LIBOBJS="$_LT_LIBOBJS $1.$ac_objext"
+])# _LT_LIBOBJS
+
+
+# LTDL_INIT([OPTIONS])
+# --------------------
+# Clients of libltdl can use this macro to allow the installer to
+# choose between a shipped copy of the ltdl sources or a preinstalled
+# version of the library. If the shipped ltdl sources are not in a
+# subdirectory named libltdl, the directory name must be given by
+# LT_CONFIG_LTDL_DIR.
+AC_DEFUN([LTDL_INIT],
+[dnl Parse OPTIONS
+_LT_SET_OPTIONS([$0], [$1])
+
+dnl We need to keep our own list of libobjs separate from our parent project,
+dnl and the easiest way to do that is redefine the AC_LIBOBJs macro while
+dnl we look for our own LIBOBJs.
+m4_pushdef([AC_LIBOBJ], m4_defn([_LT_LIBOBJ]))
+m4_pushdef([AC_LIBSOURCES])
+
+dnl If not otherwise defined, default to the 1.5.x compatible subproject mode:
+m4_if(_LTDL_MODE, [],
+ [m4_define([_LTDL_MODE], m4_default([$2], [subproject]))
+ m4_if([-1], [m4_bregexp(_LTDL_MODE, [\(subproject\|\(non\)?recursive\)])],
+ [m4_fatal([unknown libltdl mode: ]_LTDL_MODE)])])
+
+AC_ARG_WITH([included_ltdl],
+ [AS_HELP_STRING([--with-included-ltdl],
+ [use the GNU ltdl sources included here])])
+
+if test "x$with_included_ltdl" != xyes; then
+ # We are not being forced to use the included libltdl sources, so
+ # decide whether there is a useful installed version we can use.
+ AC_CHECK_HEADER([ltdl.h],
+ [AC_CHECK_DECL([lt_dlinterface_register],
+ [AC_CHECK_LIB([ltdl], [lt_dladvise_preload],
+ [with_included_ltdl=no],
+ [with_included_ltdl=yes])],
+ [with_included_ltdl=yes],
+ [AC_INCLUDES_DEFAULT
+ #include <ltdl.h>])],
+ [with_included_ltdl=yes],
+ [AC_INCLUDES_DEFAULT]
+ )
+fi
+
+dnl If neither LT_CONFIG_LTDL_DIR, LTDL_CONVENIENCE nor LTDL_INSTALLABLE
+dnl was called yet, then for old times' sake, we assume libltdl is in an
+dnl eponymous directory:
+AC_PROVIDE_IFELSE([LT_CONFIG_LTDL_DIR], [], [_LT_CONFIG_LTDL_DIR([libltdl])])
+
+AC_ARG_WITH([ltdl_include],
+ [AS_HELP_STRING([--with-ltdl-include=DIR],
+ [use the ltdl headers installed in DIR])])
+
+if test -n "$with_ltdl_include"; then
+ if test -f "$with_ltdl_include/ltdl.h"; then :
+ else
+ AC_MSG_ERROR([invalid ltdl include directory: `$with_ltdl_include'])
+ fi
+else
+ with_ltdl_include=no
+fi
+
+AC_ARG_WITH([ltdl_lib],
+ [AS_HELP_STRING([--with-ltdl-lib=DIR],
+ [use the libltdl.la installed in DIR])])
+
+if test -n "$with_ltdl_lib"; then
+ if test -f "$with_ltdl_lib/libltdl.la"; then :
+ else
+ AC_MSG_ERROR([invalid ltdl library directory: `$with_ltdl_lib'])
+ fi
+else
+ with_ltdl_lib=no
+fi
+
+case ,$with_included_ltdl,$with_ltdl_include,$with_ltdl_lib, in
+ ,yes,no,no,)
+ m4_case(m4_default(_LTDL_TYPE, [convenience]),
+ [convenience], [_LTDL_CONVENIENCE],
+ [installable], [_LTDL_INSTALLABLE],
+ [m4_fatal([unknown libltdl build type: ]_LTDL_TYPE)])
+ ;;
+ ,no,no,no,)
+ # If the included ltdl is not to be used, then use the
+ # preinstalled libltdl we found.
+ AC_DEFINE([HAVE_LTDL], [1],
+ [Define this if a modern libltdl is already installed])
+ LIBLTDL=-lltdl
+ LTDLDEPS=
+ LTDLINCL=
+ ;;
+ ,no*,no,*)
+ AC_MSG_ERROR([`--with-ltdl-include' and `--with-ltdl-lib' options must be used together])
+ ;;
+ *) with_included_ltdl=no
+ LIBLTDL="-L$with_ltdl_lib -lltdl"
+ LTDLDEPS=
+ LTDLINCL="-I$with_ltdl_include"
+ ;;
+esac
+INCLTDL="$LTDLINCL"
+
+# Report our decision...
+AC_MSG_CHECKING([where to find libltdl headers])
+AC_MSG_RESULT([$LTDLINCL])
+AC_MSG_CHECKING([where to find libltdl library])
+AC_MSG_RESULT([$LIBLTDL])
+
+_LTDL_SETUP
+
+dnl restore autoconf definition.
+m4_popdef([AC_LIBOBJ])
+m4_popdef([AC_LIBSOURCES])
+
+AC_CONFIG_COMMANDS_PRE([
+ _ltdl_libobjs=
+ _ltdl_ltlibobjs=
+ if test -n "$_LT_LIBOBJS"; then
+ # Remove the extension.
+ _lt_sed_drop_objext='s/\.o$//;s/\.obj$//'
+ for i in `for i in $_LT_LIBOBJS; do echo "$i"; done | sed "$_lt_sed_drop_objext" | sort -u`; do
+ _ltdl_libobjs="$_ltdl_libobjs $lt_libobj_prefix$i.$ac_objext"
+ _ltdl_ltlibobjs="$_ltdl_ltlibobjs $lt_libobj_prefix$i.lo"
+ done
+ fi
+ AC_SUBST([ltdl_LIBOBJS], [$_ltdl_libobjs])
+ AC_SUBST([ltdl_LTLIBOBJS], [$_ltdl_ltlibobjs])
+])
+
+# Only expand once:
+m4_define([LTDL_INIT])
+])# LTDL_INIT
+
+# Old names:
+AU_DEFUN([AC_LIB_LTDL], [LTDL_INIT($@)])
+AU_DEFUN([AC_WITH_LTDL], [LTDL_INIT($@)])
+AU_DEFUN([LT_WITH_LTDL], [LTDL_INIT($@)])
+dnl aclocal-1.4 backwards compatibility:
+dnl AC_DEFUN([AC_LIB_LTDL], [])
+dnl AC_DEFUN([AC_WITH_LTDL], [])
+dnl AC_DEFUN([LT_WITH_LTDL], [])
+
+
+# _LTDL_SETUP
+# -----------
+# Perform all the checks necessary for compilation of the ltdl objects
+# -- including compiler checks and header checks. This is a public
+# interface mainly for the benefit of libltdl's own configure.ac, most
+# other users should call LTDL_INIT instead.
+AC_DEFUN([_LTDL_SETUP],
+[AC_REQUIRE([AC_PROG_CC])dnl
+AC_REQUIRE([LT_SYS_MODULE_EXT])dnl
+AC_REQUIRE([LT_SYS_MODULE_PATH])dnl
+AC_REQUIRE([LT_SYS_DLSEARCH_PATH])dnl
+AC_REQUIRE([LT_LIB_DLLOAD])dnl
+AC_REQUIRE([LT_SYS_SYMBOL_USCORE])dnl
+AC_REQUIRE([LT_FUNC_DLSYM_USCORE])dnl
+AC_REQUIRE([LT_SYS_DLOPEN_DEPLIBS])dnl
+AC_REQUIRE([gl_FUNC_ARGZ])dnl
+
+m4_require([_LT_CHECK_OBJDIR])dnl
+m4_require([_LT_HEADER_DLFCN])dnl
+m4_require([_LT_CHECK_DLPREOPEN])dnl
+m4_require([_LT_DECL_SED])dnl
+
+dnl Don't require this, or it will be expanded earlier than the code
+dnl that sets the variables it relies on:
+_LT_ENABLE_INSTALL
+
+dnl _LTDL_MODE specific code must be called at least once:
+_LTDL_MODE_DISPATCH
+
+# In order that ltdl.c can compile, find out the first AC_CONFIG_HEADERS
+# the user used. This is so that ltdl.h can pick up the parent projects
+# config.h file, The first file in AC_CONFIG_HEADERS must contain the
+# definitions required by ltdl.c.
+# FIXME: Remove use of undocumented AC_LIST_HEADERS (2.59 compatibility).
+AC_CONFIG_COMMANDS_PRE([dnl
+m4_pattern_allow([^LT_CONFIG_H$])dnl
+m4_ifset([AH_HEADER],
+ [LT_CONFIG_H=AH_HEADER],
+ [m4_ifset([AC_LIST_HEADERS],
+ [LT_CONFIG_H=`echo "AC_LIST_HEADERS" | $SED 's,^[[ ]]*,,;s,[[ :]].*$,,'`],
+ [])])])
+AC_SUBST([LT_CONFIG_H])
+
+AC_CHECK_HEADERS([unistd.h dl.h sys/dl.h dld.h mach-o/dyld.h dirent.h],
+ [], [], [AC_INCLUDES_DEFAULT])
+
+AC_CHECK_FUNCS([closedir opendir readdir], [], [AC_LIBOBJ([lt__dirent])])
+AC_CHECK_FUNCS([strlcat strlcpy], [], [AC_LIBOBJ([lt__strl])])
+
+m4_pattern_allow([LT_LIBEXT])dnl
+AC_DEFINE_UNQUOTED([LT_LIBEXT],["$libext"],[The archive extension])
+
+name=
+eval "lt_libprefix=\"$libname_spec\""
+m4_pattern_allow([LT_LIBPREFIX])dnl
+AC_DEFINE_UNQUOTED([LT_LIBPREFIX],["$lt_libprefix"],[The archive prefix])
+
+name=ltdl
+eval "LTDLOPEN=\"$libname_spec\""
+AC_SUBST([LTDLOPEN])
+])# _LTDL_SETUP
+
+
+# _LT_ENABLE_INSTALL
+# ------------------
+m4_define([_LT_ENABLE_INSTALL],
+[AC_ARG_ENABLE([ltdl-install],
+ [AS_HELP_STRING([--enable-ltdl-install], [install libltdl])])
+
+case ,${enable_ltdl_install},${enable_ltdl_convenience} in
+ *yes*) ;;
+ *) enable_ltdl_convenience=yes ;;
+esac
+
+m4_ifdef([AM_CONDITIONAL],
+[AM_CONDITIONAL(INSTALL_LTDL, test x"${enable_ltdl_install-no}" != xno)
+ AM_CONDITIONAL(CONVENIENCE_LTDL, test x"${enable_ltdl_convenience-no}" != xno)])
+])# _LT_ENABLE_INSTALL
+
+
+# LT_SYS_DLOPEN_DEPLIBS
+# ---------------------
+AC_DEFUN([LT_SYS_DLOPEN_DEPLIBS],
+[AC_REQUIRE([AC_CANONICAL_HOST])dnl
+AC_CACHE_CHECK([whether deplibs are loaded by dlopen],
+ [lt_cv_sys_dlopen_deplibs],
+ [# PORTME does your system automatically load deplibs for dlopen?
+ # or its logical equivalent (e.g. shl_load for HP-UX < 11)
+ # For now, we just catch OSes we know something about -- in the
+ # future, we'll try test this programmatically.
+ lt_cv_sys_dlopen_deplibs=unknown
+ case $host_os in
+ aix3*|aix4.1.*|aix4.2.*)
+ # Unknown whether this is true for these versions of AIX, but
+ # we want this `case' here to explicitly catch those versions.
+ lt_cv_sys_dlopen_deplibs=unknown
+ ;;
+ aix[[4-9]]*)
+ lt_cv_sys_dlopen_deplibs=yes
+ ;;
+ amigaos*)
+ case $host_cpu in
+ powerpc)
+ lt_cv_sys_dlopen_deplibs=no
+ ;;
+ esac
+ ;;
+ darwin*)
+ # Assuming the user has installed a libdl from somewhere, this is true
+ # If you are looking for one http://www.opendarwin.org/projects/dlcompat
+ lt_cv_sys_dlopen_deplibs=yes
+ ;;
+ freebsd* | dragonfly*)
+ lt_cv_sys_dlopen_deplibs=yes
+ ;;
+ gnu* | linux* | k*bsd*-gnu | kopensolaris*-gnu)
+ # GNU and its variants, using gnu ld.so (Glibc)
+ lt_cv_sys_dlopen_deplibs=yes
+ ;;
+ hpux10*|hpux11*)
+ lt_cv_sys_dlopen_deplibs=yes
+ ;;
+ interix*)
+ lt_cv_sys_dlopen_deplibs=yes
+ ;;
+ irix[[12345]]*|irix6.[[01]]*)
+ # Catch all versions of IRIX before 6.2, and indicate that we don't
+ # know how it worked for any of those versions.
+ lt_cv_sys_dlopen_deplibs=unknown
+ ;;
+ irix*)
+ # The case above catches anything before 6.2, and it's known that
+ # at 6.2 and later dlopen does load deplibs.
+ lt_cv_sys_dlopen_deplibs=yes
+ ;;
+ netbsd*)
+ lt_cv_sys_dlopen_deplibs=yes
+ ;;
+ openbsd*)
+ lt_cv_sys_dlopen_deplibs=yes
+ ;;
+ osf[[1234]]*)
+ # dlopen did load deplibs (at least at 4.x), but until the 5.x series,
+ # it did *not* use an RPATH in a shared library to find objects the
+ # library depends on, so we explicitly say `no'.
+ lt_cv_sys_dlopen_deplibs=no
+ ;;
+ osf5.0|osf5.0a|osf5.1)
+ # dlopen *does* load deplibs and with the right loader patch applied
+ # it even uses RPATH in a shared library to search for shared objects
+ # that the library depends on, but there's no easy way to know if that
+ # patch is installed. Since this is the case, all we can really
+ # say is unknown -- it depends on the patch being installed. If
+ # it is, this changes to `yes'. Without it, it would be `no'.
+ lt_cv_sys_dlopen_deplibs=unknown
+ ;;
+ osf*)
+ # the two cases above should catch all versions of osf <= 5.1. Read
+ # the comments above for what we know about them.
+ # At > 5.1, deplibs are loaded *and* any RPATH in a shared library
+ # is used to find them so we can finally say `yes'.
+ lt_cv_sys_dlopen_deplibs=yes
+ ;;
+ qnx*)
+ lt_cv_sys_dlopen_deplibs=yes
+ ;;
+ solaris*)
+ lt_cv_sys_dlopen_deplibs=yes
+ ;;
+ sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*)
+ libltdl_cv_sys_dlopen_deplibs=yes
+ ;;
+ esac
+ ])
+if test "$lt_cv_sys_dlopen_deplibs" != yes; then
+ AC_DEFINE([LTDL_DLOPEN_DEPLIBS], [1],
+ [Define if the OS needs help to load dependent libraries for dlopen().])
+fi
+])# LT_SYS_DLOPEN_DEPLIBS
+
+# Old name:
+AU_ALIAS([AC_LTDL_SYS_DLOPEN_DEPLIBS], [LT_SYS_DLOPEN_DEPLIBS])
+dnl aclocal-1.4 backwards compatibility:
+dnl AC_DEFUN([AC_LTDL_SYS_DLOPEN_DEPLIBS], [])
+
+
+# LT_SYS_MODULE_EXT
+# -----------------
+AC_DEFUN([LT_SYS_MODULE_EXT],
+[m4_require([_LT_SYS_DYNAMIC_LINKER])dnl
+AC_CACHE_CHECK([which extension is used for runtime loadable modules],
+ [libltdl_cv_shlibext],
+[
+module=yes
+eval libltdl_cv_shlibext=$shrext_cmds
+module=no
+eval libltdl_cv_shrext=$shrext_cmds
+ ])
+if test -n "$libltdl_cv_shlibext"; then
+ m4_pattern_allow([LT_MODULE_EXT])dnl
+ AC_DEFINE_UNQUOTED([LT_MODULE_EXT], ["$libltdl_cv_shlibext"],
+ [Define to the extension used for runtime loadable modules, say, ".so".])
+fi
+if test "$libltdl_cv_shrext" != "$libltdl_cv_shlibext"; then
+ m4_pattern_allow([LT_SHARED_EXT])dnl
+ AC_DEFINE_UNQUOTED([LT_SHARED_EXT], ["$libltdl_cv_shrext"],
+ [Define to the shared library suffix, say, ".dylib".])
+fi
+])# LT_SYS_MODULE_EXT
+
+# Old name:
+AU_ALIAS([AC_LTDL_SHLIBEXT], [LT_SYS_MODULE_EXT])
+dnl aclocal-1.4 backwards compatibility:
+dnl AC_DEFUN([AC_LTDL_SHLIBEXT], [])
+
+
+# LT_SYS_MODULE_PATH
+# ------------------
+AC_DEFUN([LT_SYS_MODULE_PATH],
+[m4_require([_LT_SYS_DYNAMIC_LINKER])dnl
+AC_CACHE_CHECK([which variable specifies run-time module search path],
+ [lt_cv_module_path_var], [lt_cv_module_path_var="$shlibpath_var"])
+if test -n "$lt_cv_module_path_var"; then
+ m4_pattern_allow([LT_MODULE_PATH_VAR])dnl
+ AC_DEFINE_UNQUOTED([LT_MODULE_PATH_VAR], ["$lt_cv_module_path_var"],
+ [Define to the name of the environment variable that determines the run-time module search path.])
+fi
+])# LT_SYS_MODULE_PATH
+
+# Old name:
+AU_ALIAS([AC_LTDL_SHLIBPATH], [LT_SYS_MODULE_PATH])
+dnl aclocal-1.4 backwards compatibility:
+dnl AC_DEFUN([AC_LTDL_SHLIBPATH], [])
+
+
+# LT_SYS_DLSEARCH_PATH
+# --------------------
+AC_DEFUN([LT_SYS_DLSEARCH_PATH],
+[m4_require([_LT_SYS_DYNAMIC_LINKER])dnl
+AC_CACHE_CHECK([for the default library search path],
+ [lt_cv_sys_dlsearch_path],
+ [lt_cv_sys_dlsearch_path="$sys_lib_dlsearch_path_spec"])
+if test -n "$lt_cv_sys_dlsearch_path"; then
+ sys_dlsearch_path=
+ for dir in $lt_cv_sys_dlsearch_path; do
+ if test -z "$sys_dlsearch_path"; then
+ sys_dlsearch_path="$dir"
+ else
+ sys_dlsearch_path="$sys_dlsearch_path$PATH_SEPARATOR$dir"
+ fi
+ done
+ m4_pattern_allow([LT_DLSEARCH_PATH])dnl
+ AC_DEFINE_UNQUOTED([LT_DLSEARCH_PATH], ["$sys_dlsearch_path"],
+ [Define to the system default library search path.])
+fi
+])# LT_SYS_DLSEARCH_PATH
+
+# Old name:
+AU_ALIAS([AC_LTDL_SYSSEARCHPATH], [LT_SYS_DLSEARCH_PATH])
+dnl aclocal-1.4 backwards compatibility:
+dnl AC_DEFUN([AC_LTDL_SYSSEARCHPATH], [])
+
+
+# _LT_CHECK_DLPREOPEN
+# -------------------
+m4_defun([_LT_CHECK_DLPREOPEN],
+[m4_require([_LT_CMD_GLOBAL_SYMBOLS])dnl
+AC_CACHE_CHECK([whether libtool supports -dlopen/-dlpreopen],
+ [libltdl_cv_preloaded_symbols],
+ [if test -n "$lt_cv_sys_global_symbol_pipe"; then
+ libltdl_cv_preloaded_symbols=yes
+ else
+ libltdl_cv_preloaded_symbols=no
+ fi
+ ])
+if test x"$libltdl_cv_preloaded_symbols" = xyes; then
+ AC_DEFINE([HAVE_PRELOADED_SYMBOLS], [1],
+ [Define if libtool can extract symbol lists from object files.])
+fi
+])# _LT_CHECK_DLPREOPEN
+
+
+# LT_LIB_DLLOAD
+# -------------
+AC_DEFUN([LT_LIB_DLLOAD],
+[m4_pattern_allow([^LT_DLLOADERS$])
+LT_DLLOADERS=
+AC_SUBST([LT_DLLOADERS])
+
+AC_LANG_PUSH([C])
+
+LIBADD_DLOPEN=
+AC_SEARCH_LIBS([dlopen], [dl],
+ [AC_DEFINE([HAVE_LIBDL], [1],
+ [Define if you have the libdl library or equivalent.])
+ if test "$ac_cv_search_dlopen" != "none required" ; then
+ LIBADD_DLOPEN="-ldl"
+ fi
+ libltdl_cv_lib_dl_dlopen="yes"
+ LT_DLLOADERS="$LT_DLLOADERS ${lt_dlopen_dir+$lt_dlopen_dir/}dlopen.la"],
+ [AC_LINK_IFELSE([AC_LANG_PROGRAM([[#if HAVE_DLFCN_H
+# include <dlfcn.h>
+#endif
+ ]], [[dlopen(0, 0);]])],
+ [AC_DEFINE([HAVE_LIBDL], [1],
+ [Define if you have the libdl library or equivalent.])
+ libltdl_cv_func_dlopen="yes"
+ LT_DLLOADERS="$LT_DLLOADERS ${lt_dlopen_dir+$lt_dlopen_dir/}dlopen.la"],
+ [AC_CHECK_LIB([svld], [dlopen],
+ [AC_DEFINE([HAVE_LIBDL], [1],
+ [Define if you have the libdl library or equivalent.])
+ LIBADD_DLOPEN="-lsvld" libltdl_cv_func_dlopen="yes"
+ LT_DLLOADERS="$LT_DLLOADERS ${lt_dlopen_dir+$lt_dlopen_dir/}dlopen.la"])])])
+if test x"$libltdl_cv_func_dlopen" = xyes || test x"$libltdl_cv_lib_dl_dlopen" = xyes
+then
+ lt_save_LIBS="$LIBS"
+ LIBS="$LIBS $LIBADD_DLOPEN"
+ AC_CHECK_FUNCS([dlerror])
+ LIBS="$lt_save_LIBS"
+fi
+AC_SUBST([LIBADD_DLOPEN])
+
+LIBADD_SHL_LOAD=
+AC_CHECK_FUNC([shl_load],
+ [AC_DEFINE([HAVE_SHL_LOAD], [1],
+ [Define if you have the shl_load function.])
+ LT_DLLOADERS="$LT_DLLOADERS ${lt_dlopen_dir+$lt_dlopen_dir/}shl_load.la"],
+ [AC_CHECK_LIB([dld], [shl_load],
+ [AC_DEFINE([HAVE_SHL_LOAD], [1],
+ [Define if you have the shl_load function.])
+ LT_DLLOADERS="$LT_DLLOADERS ${lt_dlopen_dir+$lt_dlopen_dir/}shl_load.la"
+ LIBADD_SHL_LOAD="-ldld"])])
+AC_SUBST([LIBADD_SHL_LOAD])
+
+case $host_os in
+darwin[[1567]].*)
+# We only want this for pre-Mac OS X 10.4.
+ AC_CHECK_FUNC([_dyld_func_lookup],
+ [AC_DEFINE([HAVE_DYLD], [1],
+ [Define if you have the _dyld_func_lookup function.])
+ LT_DLLOADERS="$LT_DLLOADERS ${lt_dlopen_dir+$lt_dlopen_dir/}dyld.la"])
+ ;;
+beos*)
+ LT_DLLOADERS="$LT_DLLOADERS ${lt_dlopen_dir+$lt_dlopen_dir/}load_add_on.la"
+ ;;
+cygwin* | mingw* | os2* | pw32*)
+ AC_CHECK_DECLS([cygwin_conv_path], [], [], [[#include <sys/cygwin.h>]])
+ LT_DLLOADERS="$LT_DLLOADERS ${lt_dlopen_dir+$lt_dlopen_dir/}loadlibrary.la"
+ ;;
+esac
+
+AC_CHECK_LIB([dld], [dld_link],
+ [AC_DEFINE([HAVE_DLD], [1],
+ [Define if you have the GNU dld library.])
+ LT_DLLOADERS="$LT_DLLOADERS ${lt_dlopen_dir+$lt_dlopen_dir/}dld_link.la"])
+AC_SUBST([LIBADD_DLD_LINK])
+
+m4_pattern_allow([^LT_DLPREOPEN$])
+LT_DLPREOPEN=
+if test -n "$LT_DLLOADERS"
+then
+ for lt_loader in $LT_DLLOADERS; do
+ LT_DLPREOPEN="$LT_DLPREOPEN-dlpreopen $lt_loader "
+ done
+ AC_DEFINE([HAVE_LIBDLLOADER], [1],
+ [Define if libdlloader will be built on this platform])
+fi
+AC_SUBST([LT_DLPREOPEN])
+
+dnl This isn't used anymore, but set it for backwards compatibility
+LIBADD_DL="$LIBADD_DLOPEN $LIBADD_SHL_LOAD"
+AC_SUBST([LIBADD_DL])
+
+AC_LANG_POP
+])# LT_LIB_DLLOAD
+
+# Old name:
+AU_ALIAS([AC_LTDL_DLLIB], [LT_LIB_DLLOAD])
+dnl aclocal-1.4 backwards compatibility:
+dnl AC_DEFUN([AC_LTDL_DLLIB], [])
+
+
+# LT_SYS_SYMBOL_USCORE
+# --------------------
+# does the compiler prefix global symbols with an underscore?
+AC_DEFUN([LT_SYS_SYMBOL_USCORE],
+[m4_require([_LT_CMD_GLOBAL_SYMBOLS])dnl
+AC_CACHE_CHECK([for _ prefix in compiled symbols],
+ [lt_cv_sys_symbol_underscore],
+ [lt_cv_sys_symbol_underscore=no
+ cat > conftest.$ac_ext <<_LT_EOF
+void nm_test_func(){}
+int main(){nm_test_func;return 0;}
+_LT_EOF
+ if AC_TRY_EVAL(ac_compile); then
+ # Now try to grab the symbols.
+ ac_nlist=conftest.nm
+ if AC_TRY_EVAL(NM conftest.$ac_objext \| $lt_cv_sys_global_symbol_pipe \> $ac_nlist) && test -s "$ac_nlist"; then
+ # See whether the symbols have a leading underscore.
+ if grep '^. _nm_test_func' "$ac_nlist" >/dev/null; then
+ lt_cv_sys_symbol_underscore=yes
+ else
+ if grep '^. nm_test_func ' "$ac_nlist" >/dev/null; then
+ :
+ else
+ echo "configure: cannot find nm_test_func in $ac_nlist" >&AS_MESSAGE_LOG_FD
+ fi
+ fi
+ else
+ echo "configure: cannot run $lt_cv_sys_global_symbol_pipe" >&AS_MESSAGE_LOG_FD
+ fi
+ else
+ echo "configure: failed program was:" >&AS_MESSAGE_LOG_FD
+ cat conftest.c >&AS_MESSAGE_LOG_FD
+ fi
+ rm -rf conftest*
+ ])
+ sys_symbol_underscore=$lt_cv_sys_symbol_underscore
+ AC_SUBST([sys_symbol_underscore])
+])# LT_SYS_SYMBOL_USCORE
+
+# Old name:
+AU_ALIAS([AC_LTDL_SYMBOL_USCORE], [LT_SYS_SYMBOL_USCORE])
+dnl aclocal-1.4 backwards compatibility:
+dnl AC_DEFUN([AC_LTDL_SYMBOL_USCORE], [])
+
+
+# LT_FUNC_DLSYM_USCORE
+# --------------------
+AC_DEFUN([LT_FUNC_DLSYM_USCORE],
+[AC_REQUIRE([LT_SYS_SYMBOL_USCORE])dnl
+if test x"$lt_cv_sys_symbol_underscore" = xyes; then
+ if test x"$libltdl_cv_func_dlopen" = xyes ||
+ test x"$libltdl_cv_lib_dl_dlopen" = xyes ; then
+ AC_CACHE_CHECK([whether we have to add an underscore for dlsym],
+ [libltdl_cv_need_uscore],
+ [libltdl_cv_need_uscore=unknown
+ save_LIBS="$LIBS"
+ LIBS="$LIBS $LIBADD_DLOPEN"
+ _LT_TRY_DLOPEN_SELF(
+ [libltdl_cv_need_uscore=no], [libltdl_cv_need_uscore=yes],
+ [], [libltdl_cv_need_uscore=cross])
+ LIBS="$save_LIBS"
+ ])
+ fi
+fi
+
+if test x"$libltdl_cv_need_uscore" = xyes; then
+ AC_DEFINE([NEED_USCORE], [1],
+ [Define if dlsym() requires a leading underscore in symbol names.])
+fi
+])# LT_FUNC_DLSYM_USCORE
+
+# Old name:
+AU_ALIAS([AC_LTDL_DLSYM_USCORE], [LT_FUNC_DLSYM_USCORE])
+dnl aclocal-1.4 backwards compatibility:
+dnl AC_DEFUN([AC_LTDL_DLSYM_USCORE], [])
+
+# Copyright (C) 2002-2013 Free Software Foundation, Inc.
+#
+# This file is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# AM_AUTOMAKE_VERSION(VERSION)
+# ----------------------------
+# Automake X.Y traces this macro to ensure aclocal.m4 has been
+# generated from the m4 files accompanying Automake X.Y.
+# (This private macro should not be called outside this file.)
+AC_DEFUN([AM_AUTOMAKE_VERSION],
+[am__api_version='1.13'
+dnl Some users find AM_AUTOMAKE_VERSION and mistake it for a way to
+dnl require some minimum version. Point them to the right macro.
+m4_if([$1], [1.13.4], [],
+ [AC_FATAL([Do not call $0, use AM_INIT_AUTOMAKE([$1]).])])dnl
+])
+
+# _AM_AUTOCONF_VERSION(VERSION)
+# -----------------------------
+# aclocal traces this macro to find the Autoconf version.
+# This is a private macro too. Using m4_define simplifies
+# the logic in aclocal, which can simply ignore this definition.
+m4_define([_AM_AUTOCONF_VERSION], [])
+
+# AM_SET_CURRENT_AUTOMAKE_VERSION
+# -------------------------------
+# Call AM_AUTOMAKE_VERSION and AM_AUTOMAKE_VERSION so they can be traced.
+# This function is AC_REQUIREd by AM_INIT_AUTOMAKE.
+AC_DEFUN([AM_SET_CURRENT_AUTOMAKE_VERSION],
+[AM_AUTOMAKE_VERSION([1.13.4])dnl
+m4_ifndef([AC_AUTOCONF_VERSION],
+ [m4_copy([m4_PACKAGE_VERSION], [AC_AUTOCONF_VERSION])])dnl
+_AM_AUTOCONF_VERSION(m4_defn([AC_AUTOCONF_VERSION]))])
+
+# Figure out how to run the assembler. -*- Autoconf -*-
+
+# Copyright (C) 2001-2013 Free Software Foundation, Inc.
+#
+# This file is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# AM_PROG_AS
+# ----------
+AC_DEFUN([AM_PROG_AS],
+[# By default we simply use the C compiler to build assembly code.
+AC_REQUIRE([AC_PROG_CC])
+test "${CCAS+set}" = set || CCAS=$CC
+test "${CCASFLAGS+set}" = set || CCASFLAGS=$CFLAGS
+AC_ARG_VAR([CCAS], [assembler compiler command (defaults to CC)])
+AC_ARG_VAR([CCASFLAGS], [assembler compiler flags (defaults to CFLAGS)])
+_AM_IF_OPTION([no-dependencies],, [_AM_DEPENDENCIES([CCAS])])dnl
+])
+
+# AM_AUX_DIR_EXPAND -*- Autoconf -*-
+
+# Copyright (C) 2001-2013 Free Software Foundation, Inc.
+#
+# This file is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# For projects using AC_CONFIG_AUX_DIR([foo]), Autoconf sets
+# $ac_aux_dir to '$srcdir/foo'. In other projects, it is set to
+# '$srcdir', '$srcdir/..', or '$srcdir/../..'.
+#
+# Of course, Automake must honor this variable whenever it calls a
+# tool from the auxiliary directory. The problem is that $srcdir (and
+# therefore $ac_aux_dir as well) can be either absolute or relative,
+# depending on how configure is run. This is pretty annoying, since
+# it makes $ac_aux_dir quite unusable in subdirectories: in the top
+# source directory, any form will work fine, but in subdirectories a
+# relative path needs to be adjusted first.
+#
+# $ac_aux_dir/missing
+# fails when called from a subdirectory if $ac_aux_dir is relative
+# $top_srcdir/$ac_aux_dir/missing
+# fails if $ac_aux_dir is absolute,
+# fails when called from a subdirectory in a VPATH build with
+# a relative $ac_aux_dir
+#
+# The reason of the latter failure is that $top_srcdir and $ac_aux_dir
+# are both prefixed by $srcdir. In an in-source build this is usually
+# harmless because $srcdir is '.', but things will broke when you
+# start a VPATH build or use an absolute $srcdir.
+#
+# So we could use something similar to $top_srcdir/$ac_aux_dir/missing,
+# iff we strip the leading $srcdir from $ac_aux_dir. That would be:
+# am_aux_dir='\$(top_srcdir)/'`expr "$ac_aux_dir" : "$srcdir//*\(.*\)"`
+# and then we would define $MISSING as
+# MISSING="\${SHELL} $am_aux_dir/missing"
+# This will work as long as MISSING is not called from configure, because
+# unfortunately $(top_srcdir) has no meaning in configure.
+# However there are other variables, like CC, which are often used in
+# configure, and could therefore not use this "fixed" $ac_aux_dir.
+#
+# Another solution, used here, is to always expand $ac_aux_dir to an
+# absolute PATH. The drawback is that using absolute paths prevent a
+# configured tree to be moved without reconfiguration.
+
+AC_DEFUN([AM_AUX_DIR_EXPAND],
+[dnl Rely on autoconf to set up CDPATH properly.
+AC_PREREQ([2.50])dnl
+# expand $ac_aux_dir to an absolute path
+am_aux_dir=`cd $ac_aux_dir && pwd`
+])
+
+# AM_CONDITIONAL -*- Autoconf -*-
+
+# Copyright (C) 1997-2013 Free Software Foundation, Inc.
+#
+# This file is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# AM_CONDITIONAL(NAME, SHELL-CONDITION)
+# -------------------------------------
+# Define a conditional.
+AC_DEFUN([AM_CONDITIONAL],
+[AC_PREREQ([2.52])dnl
+ m4_if([$1], [TRUE], [AC_FATAL([$0: invalid condition: $1])],
+ [$1], [FALSE], [AC_FATAL([$0: invalid condition: $1])])dnl
+AC_SUBST([$1_TRUE])dnl
+AC_SUBST([$1_FALSE])dnl
+_AM_SUBST_NOTMAKE([$1_TRUE])dnl
+_AM_SUBST_NOTMAKE([$1_FALSE])dnl
+m4_define([_AM_COND_VALUE_$1], [$2])dnl
+if $2; then
+ $1_TRUE=
+ $1_FALSE='#'
+else
+ $1_TRUE='#'
+ $1_FALSE=
+fi
+AC_CONFIG_COMMANDS_PRE(
+[if test -z "${$1_TRUE}" && test -z "${$1_FALSE}"; then
+ AC_MSG_ERROR([[conditional "$1" was never defined.
+Usually this means the macro was only invoked conditionally.]])
+fi])])
+
+# Copyright (C) 1999-2013 Free Software Foundation, Inc.
+#
+# This file is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+
+# There are a few dirty hacks below to avoid letting 'AC_PROG_CC' be
+# written in clear, in which case automake, when reading aclocal.m4,
+# will think it sees a *use*, and therefore will trigger all it's
+# C support machinery. Also note that it means that autoscan, seeing
+# CC etc. in the Makefile, will ask for an AC_PROG_CC use...
+
+
+# _AM_DEPENDENCIES(NAME)
+# ----------------------
+# See how the compiler implements dependency checking.
+# NAME is "CC", "CXX", "OBJC", "OBJCXX", "UPC", or "GJC".
+# We try a few techniques and use that to set a single cache variable.
+#
+# We don't AC_REQUIRE the corresponding AC_PROG_CC since the latter was
+# modified to invoke _AM_DEPENDENCIES(CC); we would have a circular
+# dependency, and given that the user is not expected to run this macro,
+# just rely on AC_PROG_CC.
+AC_DEFUN([_AM_DEPENDENCIES],
+[AC_REQUIRE([AM_SET_DEPDIR])dnl
+AC_REQUIRE([AM_OUTPUT_DEPENDENCY_COMMANDS])dnl
+AC_REQUIRE([AM_MAKE_INCLUDE])dnl
+AC_REQUIRE([AM_DEP_TRACK])dnl
+
+m4_if([$1], [CC], [depcc="$CC" am_compiler_list=],
+ [$1], [CXX], [depcc="$CXX" am_compiler_list=],
+ [$1], [OBJC], [depcc="$OBJC" am_compiler_list='gcc3 gcc'],
+ [$1], [OBJCXX], [depcc="$OBJCXX" am_compiler_list='gcc3 gcc'],
+ [$1], [UPC], [depcc="$UPC" am_compiler_list=],
+ [$1], [GCJ], [depcc="$GCJ" am_compiler_list='gcc3 gcc'],
+ [depcc="$$1" am_compiler_list=])
+
+AC_CACHE_CHECK([dependency style of $depcc],
+ [am_cv_$1_dependencies_compiler_type],
+[if test -z "$AMDEP_TRUE" && test -f "$am_depcomp"; then
+ # We make a subdir and do the tests there. Otherwise we can end up
+ # making bogus files that we don't know about and never remove. For
+ # instance it was reported that on HP-UX the gcc test will end up
+ # making a dummy file named 'D' -- because '-MD' means "put the output
+ # in D".
+ rm -rf conftest.dir
+ mkdir conftest.dir
+ # Copy depcomp to subdir because otherwise we won't find it if we're
+ # using a relative directory.
+ cp "$am_depcomp" conftest.dir
+ cd conftest.dir
+ # We will build objects and dependencies in a subdirectory because
+ # it helps to detect inapplicable dependency modes. For instance
+ # both Tru64's cc and ICC support -MD to output dependencies as a
+ # side effect of compilation, but ICC will put the dependencies in
+ # the current directory while Tru64 will put them in the object
+ # directory.
+ mkdir sub
+
+ am_cv_$1_dependencies_compiler_type=none
+ if test "$am_compiler_list" = ""; then
+ am_compiler_list=`sed -n ['s/^#*\([a-zA-Z0-9]*\))$/\1/p'] < ./depcomp`
+ fi
+ am__universal=false
+ m4_case([$1], [CC],
+ [case " $depcc " in #(
+ *\ -arch\ *\ -arch\ *) am__universal=true ;;
+ esac],
+ [CXX],
+ [case " $depcc " in #(
+ *\ -arch\ *\ -arch\ *) am__universal=true ;;
+ esac])
+
+ for depmode in $am_compiler_list; do
+ # Setup a source with many dependencies, because some compilers
+ # like to wrap large dependency lists on column 80 (with \), and
+ # we should not choose a depcomp mode which is confused by this.
+ #
+ # We need to recreate these files for each test, as the compiler may
+ # overwrite some of them when testing with obscure command lines.
+ # This happens at least with the AIX C compiler.
+ : > sub/conftest.c
+ for i in 1 2 3 4 5 6; do
+ echo '#include "conftst'$i'.h"' >> sub/conftest.c
+ # Using ": > sub/conftst$i.h" creates only sub/conftst1.h with
+ # Solaris 10 /bin/sh.
+ echo '/* dummy */' > sub/conftst$i.h
+ done
+ echo "${am__include} ${am__quote}sub/conftest.Po${am__quote}" > confmf
+
+ # We check with '-c' and '-o' for the sake of the "dashmstdout"
+ # mode. It turns out that the SunPro C++ compiler does not properly
+ # handle '-M -o', and we need to detect this. Also, some Intel
+ # versions had trouble with output in subdirs.
+ am__obj=sub/conftest.${OBJEXT-o}
+ am__minus_obj="-o $am__obj"
+ case $depmode in
+ gcc)
+ # This depmode causes a compiler race in universal mode.
+ test "$am__universal" = false || continue
+ ;;
+ nosideeffect)
+ # After this tag, mechanisms are not by side-effect, so they'll
+ # only be used when explicitly requested.
+ if test "x$enable_dependency_tracking" = xyes; then
+ continue
+ else
+ break
+ fi
+ ;;
+ msvc7 | msvc7msys | msvisualcpp | msvcmsys)
+ # This compiler won't grok '-c -o', but also, the minuso test has
+ # not run yet. These depmodes are late enough in the game, and
+ # so weak that their functioning should not be impacted.
+ am__obj=conftest.${OBJEXT-o}
+ am__minus_obj=
+ ;;
+ none) break ;;
+ esac
+ if depmode=$depmode \
+ source=sub/conftest.c object=$am__obj \
+ depfile=sub/conftest.Po tmpdepfile=sub/conftest.TPo \
+ $SHELL ./depcomp $depcc -c $am__minus_obj sub/conftest.c \
+ >/dev/null 2>conftest.err &&
+ grep sub/conftst1.h sub/conftest.Po > /dev/null 2>&1 &&
+ grep sub/conftst6.h sub/conftest.Po > /dev/null 2>&1 &&
+ grep $am__obj sub/conftest.Po > /dev/null 2>&1 &&
+ ${MAKE-make} -s -f confmf > /dev/null 2>&1; then
+ # icc doesn't choke on unknown options, it will just issue warnings
+ # or remarks (even with -Werror). So we grep stderr for any message
+ # that says an option was ignored or not supported.
+ # When given -MP, icc 7.0 and 7.1 complain thusly:
+ # icc: Command line warning: ignoring option '-M'; no argument required
+ # The diagnosis changed in icc 8.0:
+ # icc: Command line remark: option '-MP' not supported
+ if (grep 'ignoring option' conftest.err ||
+ grep 'not supported' conftest.err) >/dev/null 2>&1; then :; else
+ am_cv_$1_dependencies_compiler_type=$depmode
+ break
+ fi
+ fi
+ done
+
+ cd ..
+ rm -rf conftest.dir
+else
+ am_cv_$1_dependencies_compiler_type=none
+fi
+])
+AC_SUBST([$1DEPMODE], [depmode=$am_cv_$1_dependencies_compiler_type])
+AM_CONDITIONAL([am__fastdep$1], [
+ test "x$enable_dependency_tracking" != xno \
+ && test "$am_cv_$1_dependencies_compiler_type" = gcc3])
+])
+
+
+# AM_SET_DEPDIR
+# -------------
+# Choose a directory name for dependency files.
+# This macro is AC_REQUIREd in _AM_DEPENDENCIES.
+AC_DEFUN([AM_SET_DEPDIR],
+[AC_REQUIRE([AM_SET_LEADING_DOT])dnl
+AC_SUBST([DEPDIR], ["${am__leading_dot}deps"])dnl
+])
+
+
+# AM_DEP_TRACK
+# ------------
+AC_DEFUN([AM_DEP_TRACK],
+[AC_ARG_ENABLE([dependency-tracking], [dnl
+AS_HELP_STRING(
+ [--enable-dependency-tracking],
+ [do not reject slow dependency extractors])
+AS_HELP_STRING(
+ [--disable-dependency-tracking],
+ [speeds up one-time build])])
+if test "x$enable_dependency_tracking" != xno; then
+ am_depcomp="$ac_aux_dir/depcomp"
+ AMDEPBACKSLASH='\'
+ am__nodep='_no'
+fi
+AM_CONDITIONAL([AMDEP], [test "x$enable_dependency_tracking" != xno])
+AC_SUBST([AMDEPBACKSLASH])dnl
+_AM_SUBST_NOTMAKE([AMDEPBACKSLASH])dnl
+AC_SUBST([am__nodep])dnl
+_AM_SUBST_NOTMAKE([am__nodep])dnl
+])
+
+# Generate code to set up dependency tracking. -*- Autoconf -*-
+
+# Copyright (C) 1999-2013 Free Software Foundation, Inc.
+#
+# This file is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+
+# _AM_OUTPUT_DEPENDENCY_COMMANDS
+# ------------------------------
+AC_DEFUN([_AM_OUTPUT_DEPENDENCY_COMMANDS],
+[{
+ # Older Autoconf quotes --file arguments for eval, but not when files
+ # are listed without --file. Let's play safe and only enable the eval
+ # if we detect the quoting.
+ case $CONFIG_FILES in
+ *\'*) eval set x "$CONFIG_FILES" ;;
+ *) set x $CONFIG_FILES ;;
+ esac
+ shift
+ for mf
+ do
+ # Strip MF so we end up with the name of the file.
+ mf=`echo "$mf" | sed -e 's/:.*$//'`
+ # Check whether this is an Automake generated Makefile or not.
+ # We used to match only the files named 'Makefile.in', but
+ # some people rename them; so instead we look at the file content.
+ # Grep'ing the first line is not enough: some people post-process
+ # each Makefile.in and add a new line on top of each file to say so.
+ # Grep'ing the whole file is not good either: AIX grep has a line
+ # limit of 2048, but all sed's we know have understand at least 4000.
+ if sed -n 's,^#.*generated by automake.*,X,p' "$mf" | grep X >/dev/null 2>&1; then
+ dirpart=`AS_DIRNAME("$mf")`
+ else
+ continue
+ fi
+ # Extract the definition of DEPDIR, am__include, and am__quote
+ # from the Makefile without running 'make'.
+ DEPDIR=`sed -n 's/^DEPDIR = //p' < "$mf"`
+ test -z "$DEPDIR" && continue
+ am__include=`sed -n 's/^am__include = //p' < "$mf"`
+ test -z "$am__include" && continue
+ am__quote=`sed -n 's/^am__quote = //p' < "$mf"`
+ # Find all dependency output files, they are included files with
+ # $(DEPDIR) in their names. We invoke sed twice because it is the
+ # simplest approach to changing $(DEPDIR) to its actual value in the
+ # expansion.
+ for file in `sed -n "
+ s/^$am__include $am__quote\(.*(DEPDIR).*\)$am__quote"'$/\1/p' <"$mf" | \
+ sed -e 's/\$(DEPDIR)/'"$DEPDIR"'/g'`; do
+ # Make sure the directory exists.
+ test -f "$dirpart/$file" && continue
+ fdir=`AS_DIRNAME(["$file"])`
+ AS_MKDIR_P([$dirpart/$fdir])
+ # echo "creating $dirpart/$file"
+ echo '# dummy' > "$dirpart/$file"
+ done
+ done
+}
+])# _AM_OUTPUT_DEPENDENCY_COMMANDS
+
+
+# AM_OUTPUT_DEPENDENCY_COMMANDS
+# -----------------------------
+# This macro should only be invoked once -- use via AC_REQUIRE.
+#
+# This code is only required when automatic dependency tracking
+# is enabled. FIXME. This creates each '.P' file that we will
+# need in order to bootstrap the dependency handling code.
+AC_DEFUN([AM_OUTPUT_DEPENDENCY_COMMANDS],
+[AC_CONFIG_COMMANDS([depfiles],
+ [test x"$AMDEP_TRUE" != x"" || _AM_OUTPUT_DEPENDENCY_COMMANDS],
+ [AMDEP_TRUE="$AMDEP_TRUE" ac_aux_dir="$ac_aux_dir"])
+])
+
+# Do all the work for Automake. -*- Autoconf -*-
+
+# Copyright (C) 1996-2013 Free Software Foundation, Inc.
+#
+# This file is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# This macro actually does too much. Some checks are only needed if
+# your package does certain things. But this isn't really a big deal.
+
+# AM_INIT_AUTOMAKE(PACKAGE, VERSION, [NO-DEFINE])
+# AM_INIT_AUTOMAKE([OPTIONS])
+# -----------------------------------------------
+# The call with PACKAGE and VERSION arguments is the old style
+# call (pre autoconf-2.50), which is being phased out. PACKAGE
+# and VERSION should now be passed to AC_INIT and removed from
+# the call to AM_INIT_AUTOMAKE.
+# We support both call styles for the transition. After
+# the next Automake release, Autoconf can make the AC_INIT
+# arguments mandatory, and then we can depend on a new Autoconf
+# release and drop the old call support.
+AC_DEFUN([AM_INIT_AUTOMAKE],
+[AC_PREREQ([2.65])dnl
+dnl Autoconf wants to disallow AM_ names. We explicitly allow
+dnl the ones we care about.
+m4_pattern_allow([^AM_[A-Z]+FLAGS$])dnl
+AC_REQUIRE([AM_SET_CURRENT_AUTOMAKE_VERSION])dnl
+AC_REQUIRE([AC_PROG_INSTALL])dnl
+if test "`cd $srcdir && pwd`" != "`pwd`"; then
+ # Use -I$(srcdir) only when $(srcdir) != ., so that make's output
+ # is not polluted with repeated "-I."
+ AC_SUBST([am__isrc], [' -I$(srcdir)'])_AM_SUBST_NOTMAKE([am__isrc])dnl
+ # test to see if srcdir already configured
+ if test -f $srcdir/config.status; then
+ AC_MSG_ERROR([source directory already configured; run "make distclean" there first])
+ fi
+fi
+
+# test whether we have cygpath
+if test -z "$CYGPATH_W"; then
+ if (cygpath --version) >/dev/null 2>/dev/null; then
+ CYGPATH_W='cygpath -w'
+ else
+ CYGPATH_W=echo
+ fi
+fi
+AC_SUBST([CYGPATH_W])
+
+# Define the identity of the package.
+dnl Distinguish between old-style and new-style calls.
+m4_ifval([$2],
+[AC_DIAGNOSE([obsolete],
+ [$0: two- and three-arguments forms are deprecated.])
+m4_ifval([$3], [_AM_SET_OPTION([no-define])])dnl
+ AC_SUBST([PACKAGE], [$1])dnl
+ AC_SUBST([VERSION], [$2])],
+[_AM_SET_OPTIONS([$1])dnl
+dnl Diagnose old-style AC_INIT with new-style AM_AUTOMAKE_INIT.
+m4_if(
+ m4_ifdef([AC_PACKAGE_NAME], [ok]):m4_ifdef([AC_PACKAGE_VERSION], [ok]),
+ [ok:ok],,
+ [m4_fatal([AC_INIT should be called with package and version arguments])])dnl
+ AC_SUBST([PACKAGE], ['AC_PACKAGE_TARNAME'])dnl
+ AC_SUBST([VERSION], ['AC_PACKAGE_VERSION'])])dnl
+
+_AM_IF_OPTION([no-define],,
+[AC_DEFINE_UNQUOTED([PACKAGE], ["$PACKAGE"], [Name of package])
+ AC_DEFINE_UNQUOTED([VERSION], ["$VERSION"], [Version number of package])])dnl
+
+# Some tools Automake needs.
+AC_REQUIRE([AM_SANITY_CHECK])dnl
+AC_REQUIRE([AC_ARG_PROGRAM])dnl
+AM_MISSING_PROG([ACLOCAL], [aclocal-${am__api_version}])
+AM_MISSING_PROG([AUTOCONF], [autoconf])
+AM_MISSING_PROG([AUTOMAKE], [automake-${am__api_version}])
+AM_MISSING_PROG([AUTOHEADER], [autoheader])
+AM_MISSING_PROG([MAKEINFO], [makeinfo])
+AC_REQUIRE([AM_PROG_INSTALL_SH])dnl
+AC_REQUIRE([AM_PROG_INSTALL_STRIP])dnl
+AC_REQUIRE([AC_PROG_MKDIR_P])dnl
+# For better backward compatibility. To be removed once Automake 1.9.x
+# dies out for good. For more background, see:
+# <http://lists.gnu.org/archive/html/automake/2012-07/msg00001.html>
+# <http://lists.gnu.org/archive/html/automake/2012-07/msg00014.html>
+AC_SUBST([mkdir_p], ['$(MKDIR_P)'])
+# We need awk for the "check" target. The system "awk" is bad on
+# some platforms.
+AC_REQUIRE([AC_PROG_AWK])dnl
+AC_REQUIRE([AC_PROG_MAKE_SET])dnl
+AC_REQUIRE([AM_SET_LEADING_DOT])dnl
+_AM_IF_OPTION([tar-ustar], [_AM_PROG_TAR([ustar])],
+ [_AM_IF_OPTION([tar-pax], [_AM_PROG_TAR([pax])],
+ [_AM_PROG_TAR([v7])])])
+_AM_IF_OPTION([no-dependencies],,
+[AC_PROVIDE_IFELSE([AC_PROG_CC],
+ [_AM_DEPENDENCIES([CC])],
+ [m4_define([AC_PROG_CC],
+ m4_defn([AC_PROG_CC])[_AM_DEPENDENCIES([CC])])])dnl
+AC_PROVIDE_IFELSE([AC_PROG_CXX],
+ [_AM_DEPENDENCIES([CXX])],
+ [m4_define([AC_PROG_CXX],
+ m4_defn([AC_PROG_CXX])[_AM_DEPENDENCIES([CXX])])])dnl
+AC_PROVIDE_IFELSE([AC_PROG_OBJC],
+ [_AM_DEPENDENCIES([OBJC])],
+ [m4_define([AC_PROG_OBJC],
+ m4_defn([AC_PROG_OBJC])[_AM_DEPENDENCIES([OBJC])])])dnl
+AC_PROVIDE_IFELSE([AC_PROG_OBJCXX],
+ [_AM_DEPENDENCIES([OBJCXX])],
+ [m4_define([AC_PROG_OBJCXX],
+ m4_defn([AC_PROG_OBJCXX])[_AM_DEPENDENCIES([OBJCXX])])])dnl
+])
+AC_REQUIRE([AM_SILENT_RULES])dnl
+dnl The testsuite driver may need to know about EXEEXT, so add the
+dnl 'am__EXEEXT' conditional if _AM_COMPILER_EXEEXT was seen. This
+dnl macro is hooked onto _AC_COMPILER_EXEEXT early, see below.
+AC_CONFIG_COMMANDS_PRE(dnl
+[m4_provide_if([_AM_COMPILER_EXEEXT],
+ [AM_CONDITIONAL([am__EXEEXT], [test -n "$EXEEXT"])])])dnl
+])
+
+dnl Hook into '_AC_COMPILER_EXEEXT' early to learn its expansion. Do not
+dnl add the conditional right here, as _AC_COMPILER_EXEEXT may be further
+dnl mangled by Autoconf and run in a shell conditional statement.
+m4_define([_AC_COMPILER_EXEEXT],
+m4_defn([_AC_COMPILER_EXEEXT])[m4_provide([_AM_COMPILER_EXEEXT])])
+
+
+# When config.status generates a header, we must update the stamp-h file.
+# This file resides in the same directory as the config header
+# that is generated. The stamp files are numbered to have different names.
+
+# Autoconf calls _AC_AM_CONFIG_HEADER_HOOK (when defined) in the
+# loop where config.status creates the headers, so we can generate
+# our stamp files there.
+AC_DEFUN([_AC_AM_CONFIG_HEADER_HOOK],
+[# Compute $1's index in $config_headers.
+_am_arg=$1
+_am_stamp_count=1
+for _am_header in $config_headers :; do
+ case $_am_header in
+ $_am_arg | $_am_arg:* )
+ break ;;
+ * )
+ _am_stamp_count=`expr $_am_stamp_count + 1` ;;
+ esac
+done
+echo "timestamp for $_am_arg" >`AS_DIRNAME(["$_am_arg"])`/stamp-h[]$_am_stamp_count])
+
+# Copyright (C) 2001-2013 Free Software Foundation, Inc.
+#
+# This file is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# AM_PROG_INSTALL_SH
+# ------------------
+# Define $install_sh.
+AC_DEFUN([AM_PROG_INSTALL_SH],
+[AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl
+if test x"${install_sh}" != xset; then
+ case $am_aux_dir in
+ *\ * | *\ *)
+ install_sh="\${SHELL} '$am_aux_dir/install-sh'" ;;
+ *)
+ install_sh="\${SHELL} $am_aux_dir/install-sh"
+ esac
+fi
+AC_SUBST([install_sh])])
+
+# Copyright (C) 2003-2013 Free Software Foundation, Inc.
+#
+# This file is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# Check whether the underlying file-system supports filenames
+# with a leading dot. For instance MS-DOS doesn't.
+AC_DEFUN([AM_SET_LEADING_DOT],
+[rm -rf .tst 2>/dev/null
+mkdir .tst 2>/dev/null
+if test -d .tst; then
+ am__leading_dot=.
+else
+ am__leading_dot=_
+fi
+rmdir .tst 2>/dev/null
+AC_SUBST([am__leading_dot])])
+
+# Add --enable-maintainer-mode option to configure. -*- Autoconf -*-
+# From Jim Meyering
+
+# Copyright (C) 1996-2013 Free Software Foundation, Inc.
+#
+# This file is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# AM_MAINTAINER_MODE([DEFAULT-MODE])
+# ----------------------------------
+# Control maintainer-specific portions of Makefiles.
+# Default is to disable them, unless 'enable' is passed literally.
+# For symmetry, 'disable' may be passed as well. Anyway, the user
+# can override the default with the --enable/--disable switch.
+AC_DEFUN([AM_MAINTAINER_MODE],
+[m4_case(m4_default([$1], [disable]),
+ [enable], [m4_define([am_maintainer_other], [disable])],
+ [disable], [m4_define([am_maintainer_other], [enable])],
+ [m4_define([am_maintainer_other], [enable])
+ m4_warn([syntax], [unexpected argument to AM@&t@_MAINTAINER_MODE: $1])])
+AC_MSG_CHECKING([whether to enable maintainer-specific portions of Makefiles])
+ dnl maintainer-mode's default is 'disable' unless 'enable' is passed
+ AC_ARG_ENABLE([maintainer-mode],
+ [AS_HELP_STRING([--]am_maintainer_other[-maintainer-mode],
+ am_maintainer_other[ make rules and dependencies not useful
+ (and sometimes confusing) to the casual installer])],
+ [USE_MAINTAINER_MODE=$enableval],
+ [USE_MAINTAINER_MODE=]m4_if(am_maintainer_other, [enable], [no], [yes]))
+ AC_MSG_RESULT([$USE_MAINTAINER_MODE])
+ AM_CONDITIONAL([MAINTAINER_MODE], [test $USE_MAINTAINER_MODE = yes])
+ MAINT=$MAINTAINER_MODE_TRUE
+ AC_SUBST([MAINT])dnl
+]
+)
+
+# Check to see how 'make' treats includes. -*- Autoconf -*-
+
+# Copyright (C) 2001-2013 Free Software Foundation, Inc.
+#
+# This file is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# AM_MAKE_INCLUDE()
+# -----------------
+# Check to see how make treats includes.
+AC_DEFUN([AM_MAKE_INCLUDE],
+[am_make=${MAKE-make}
+cat > confinc << 'END'
+am__doit:
+ @echo this is the am__doit target
+.PHONY: am__doit
+END
+# If we don't find an include directive, just comment out the code.
+AC_MSG_CHECKING([for style of include used by $am_make])
+am__include="#"
+am__quote=
+_am_result=none
+# First try GNU make style include.
+echo "include confinc" > confmf
+# Ignore all kinds of additional output from 'make'.
+case `$am_make -s -f confmf 2> /dev/null` in #(
+*the\ am__doit\ target*)
+ am__include=include
+ am__quote=
+ _am_result=GNU
+ ;;
+esac
+# Now try BSD make style include.
+if test "$am__include" = "#"; then
+ echo '.include "confinc"' > confmf
+ case `$am_make -s -f confmf 2> /dev/null` in #(
+ *the\ am__doit\ target*)
+ am__include=.include
+ am__quote="\""
+ _am_result=BSD
+ ;;
+ esac
+fi
+AC_SUBST([am__include])
+AC_SUBST([am__quote])
+AC_MSG_RESULT([$_am_result])
+rm -f confinc confmf
+])
+
+# Copyright (C) 1999-2013 Free Software Foundation, Inc.
+#
+# This file is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# AM_PROG_CC_C_O
+# --------------
+# Like AC_PROG_CC_C_O, but changed for automake.
+AC_DEFUN([AM_PROG_CC_C_O],
+[AC_REQUIRE([AC_PROG_CC_C_O])dnl
+AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl
+AC_REQUIRE_AUX_FILE([compile])dnl
+# FIXME: we rely on the cache variable name because
+# there is no other way.
+set dummy $CC
+am_cc=`echo $[2] | sed ['s/[^a-zA-Z0-9_]/_/g;s/^[0-9]/_/']`
+eval am_t=\$ac_cv_prog_cc_${am_cc}_c_o
+if test "$am_t" != yes; then
+ # Losing compiler, so override with the script.
+ # FIXME: It is wrong to rewrite CC.
+ # But if we don't then we get into trouble of one sort or another.
+ # A longer-term fix would be to have automake use am__CC in this case,
+ # and then we could set am__CC="\$(top_srcdir)/compile \$(CC)"
+ CC="$am_aux_dir/compile $CC"
+fi
+dnl Make sure AC_PROG_CC is never called again, or it will override our
+dnl setting of CC.
+m4_define([AC_PROG_CC],
+ [m4_fatal([AC_PROG_CC cannot be called after AM_PROG_CC_C_O])])
+])
+
+# Fake the existence of programs that GNU maintainers use. -*- Autoconf -*-
+
+# Copyright (C) 1997-2013 Free Software Foundation, Inc.
+#
+# This file is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# AM_MISSING_PROG(NAME, PROGRAM)
+# ------------------------------
+AC_DEFUN([AM_MISSING_PROG],
+[AC_REQUIRE([AM_MISSING_HAS_RUN])
+$1=${$1-"${am_missing_run}$2"}
+AC_SUBST($1)])
+
+# AM_MISSING_HAS_RUN
+# ------------------
+# Define MISSING if not defined so far and test if it is modern enough.
+# If it is, set am_missing_run to use it, otherwise, to nothing.
+AC_DEFUN([AM_MISSING_HAS_RUN],
+[AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl
+AC_REQUIRE_AUX_FILE([missing])dnl
+if test x"${MISSING+set}" != xset; then
+ case $am_aux_dir in
+ *\ * | *\ *)
+ MISSING="\${SHELL} \"$am_aux_dir/missing\"" ;;
+ *)
+ MISSING="\${SHELL} $am_aux_dir/missing" ;;
+ esac
+fi
+# Use eval to expand $SHELL
+if eval "$MISSING --is-lightweight"; then
+ am_missing_run="$MISSING "
+else
+ am_missing_run=
+ AC_MSG_WARN(['missing' script is too old or missing])
+fi
+])
+
+# Helper functions for option handling. -*- Autoconf -*-
+
+# Copyright (C) 2001-2013 Free Software Foundation, Inc.
+#
+# This file is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# _AM_MANGLE_OPTION(NAME)
+# -----------------------
+AC_DEFUN([_AM_MANGLE_OPTION],
+[[_AM_OPTION_]m4_bpatsubst($1, [[^a-zA-Z0-9_]], [_])])
+
+# _AM_SET_OPTION(NAME)
+# --------------------
+# Set option NAME. Presently that only means defining a flag for this option.
+AC_DEFUN([_AM_SET_OPTION],
+[m4_define(_AM_MANGLE_OPTION([$1]), [1])])
+
+# _AM_SET_OPTIONS(OPTIONS)
+# ------------------------
+# OPTIONS is a space-separated list of Automake options.
+AC_DEFUN([_AM_SET_OPTIONS],
+[m4_foreach_w([_AM_Option], [$1], [_AM_SET_OPTION(_AM_Option)])])
+
+# _AM_IF_OPTION(OPTION, IF-SET, [IF-NOT-SET])
+# -------------------------------------------
+# Execute IF-SET if OPTION is set, IF-NOT-SET otherwise.
+AC_DEFUN([_AM_IF_OPTION],
+[m4_ifset(_AM_MANGLE_OPTION([$1]), [$2], [$3])])
+
+# Check to make sure that the build environment is sane. -*- Autoconf -*-
+
+# Copyright (C) 1996-2013 Free Software Foundation, Inc.
+#
+# This file is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# AM_SANITY_CHECK
+# ---------------
+AC_DEFUN([AM_SANITY_CHECK],
+[AC_MSG_CHECKING([whether build environment is sane])
+# Reject unsafe characters in $srcdir or the absolute working directory
+# name. Accept space and tab only in the latter.
+am_lf='
+'
+case `pwd` in
+ *[[\\\"\#\$\&\'\`$am_lf]]*)
+ AC_MSG_ERROR([unsafe absolute working directory name]);;
+esac
+case $srcdir in
+ *[[\\\"\#\$\&\'\`$am_lf\ \ ]]*)
+ AC_MSG_ERROR([unsafe srcdir value: '$srcdir']);;
+esac
+
+# Do 'set' in a subshell so we don't clobber the current shell's
+# arguments. Must try -L first in case configure is actually a
+# symlink; some systems play weird games with the mod time of symlinks
+# (eg FreeBSD returns the mod time of the symlink's containing
+# directory).
+if (
+ am_has_slept=no
+ for am_try in 1 2; do
+ echo "timestamp, slept: $am_has_slept" > conftest.file
+ set X `ls -Lt "$srcdir/configure" conftest.file 2> /dev/null`
+ if test "$[*]" = "X"; then
+ # -L didn't work.
+ set X `ls -t "$srcdir/configure" conftest.file`
+ fi
+ if test "$[*]" != "X $srcdir/configure conftest.file" \
+ && test "$[*]" != "X conftest.file $srcdir/configure"; then
+
+ # If neither matched, then we have a broken ls. This can happen
+ # if, for instance, CONFIG_SHELL is bash and it inherits a
+ # broken ls alias from the environment. This has actually
+ # happened. Such a system could not be considered "sane".
+ AC_MSG_ERROR([ls -t appears to fail. Make sure there is not a broken
+ alias in your environment])
+ fi
+ if test "$[2]" = conftest.file || test $am_try -eq 2; then
+ break
+ fi
+ # Just in case.
+ sleep 1
+ am_has_slept=yes
+ done
+ test "$[2]" = conftest.file
+ )
+then
+ # Ok.
+ :
+else
+ AC_MSG_ERROR([newly created file is older than distributed files!
+Check your system clock])
+fi
+AC_MSG_RESULT([yes])
+# If we didn't sleep, we still need to ensure time stamps of config.status and
+# generated files are strictly newer.
+am_sleep_pid=
+if grep 'slept: no' conftest.file >/dev/null 2>&1; then
+ ( sleep 1 ) &
+ am_sleep_pid=$!
+fi
+AC_CONFIG_COMMANDS_PRE(
+ [AC_MSG_CHECKING([that generated files are newer than configure])
+ if test -n "$am_sleep_pid"; then
+ # Hide warnings about reused PIDs.
+ wait $am_sleep_pid 2>/dev/null
+ fi
+ AC_MSG_RESULT([done])])
+rm -f conftest.file
+])
+
+# Copyright (C) 2009-2013 Free Software Foundation, Inc.
+#
+# This file is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# AM_SILENT_RULES([DEFAULT])
+# --------------------------
+# Enable less verbose build rules; with the default set to DEFAULT
+# ("yes" being less verbose, "no" or empty being verbose).
+AC_DEFUN([AM_SILENT_RULES],
+[AC_ARG_ENABLE([silent-rules], [dnl
+AS_HELP_STRING(
+ [--enable-silent-rules],
+ [less verbose build output (undo: "make V=1")])
+AS_HELP_STRING(
+ [--disable-silent-rules],
+ [verbose build output (undo: "make V=0")])dnl
+])
+case $enable_silent_rules in @%:@ (((
+ yes) AM_DEFAULT_VERBOSITY=0;;
+ no) AM_DEFAULT_VERBOSITY=1;;
+ *) AM_DEFAULT_VERBOSITY=m4_if([$1], [yes], [0], [1]);;
+esac
+dnl
+dnl A few 'make' implementations (e.g., NonStop OS and NextStep)
+dnl do not support nested variable expansions.
+dnl See automake bug#9928 and bug#10237.
+am_make=${MAKE-make}
+AC_CACHE_CHECK([whether $am_make supports nested variables],
+ [am_cv_make_support_nested_variables],
+ [if AS_ECHO([['TRUE=$(BAR$(V))
+BAR0=false
+BAR1=true
+V=1
+am__doit:
+ @$(TRUE)
+.PHONY: am__doit']]) | $am_make -f - >/dev/null 2>&1; then
+ am_cv_make_support_nested_variables=yes
+else
+ am_cv_make_support_nested_variables=no
+fi])
+if test $am_cv_make_support_nested_variables = yes; then
+ dnl Using '$V' instead of '$(V)' breaks IRIX make.
+ AM_V='$(V)'
+ AM_DEFAULT_V='$(AM_DEFAULT_VERBOSITY)'
+else
+ AM_V=$AM_DEFAULT_VERBOSITY
+ AM_DEFAULT_V=$AM_DEFAULT_VERBOSITY
+fi
+AC_SUBST([AM_V])dnl
+AM_SUBST_NOTMAKE([AM_V])dnl
+AC_SUBST([AM_DEFAULT_V])dnl
+AM_SUBST_NOTMAKE([AM_DEFAULT_V])dnl
+AC_SUBST([AM_DEFAULT_VERBOSITY])dnl
+AM_BACKSLASH='\'
+AC_SUBST([AM_BACKSLASH])dnl
+_AM_SUBST_NOTMAKE([AM_BACKSLASH])dnl
+])
+
+# Copyright (C) 2001-2013 Free Software Foundation, Inc.
+#
+# This file is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# AM_PROG_INSTALL_STRIP
+# ---------------------
+# One issue with vendor 'install' (even GNU) is that you can't
+# specify the program used to strip binaries. This is especially
+# annoying in cross-compiling environments, where the build's strip
+# is unlikely to handle the host's binaries.
+# Fortunately install-sh will honor a STRIPPROG variable, so we
+# always use install-sh in "make install-strip", and initialize
+# STRIPPROG with the value of the STRIP variable (set by the user).
+AC_DEFUN([AM_PROG_INSTALL_STRIP],
+[AC_REQUIRE([AM_PROG_INSTALL_SH])dnl
+# Installed binaries are usually stripped using 'strip' when the user
+# run "make install-strip". However 'strip' might not be the right
+# tool to use in cross-compilation environments, therefore Automake
+# will honor the 'STRIP' environment variable to overrule this program.
+dnl Don't test for $cross_compiling = yes, because it might be 'maybe'.
+if test "$cross_compiling" != no; then
+ AC_CHECK_TOOL([STRIP], [strip], :)
+fi
+INSTALL_STRIP_PROGRAM="\$(install_sh) -c -s"
+AC_SUBST([INSTALL_STRIP_PROGRAM])])
+
+# Copyright (C) 2006-2013 Free Software Foundation, Inc.
+#
+# This file is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# _AM_SUBST_NOTMAKE(VARIABLE)
+# ---------------------------
+# Prevent Automake from outputting VARIABLE = @VARIABLE@ in Makefile.in.
+# This macro is traced by Automake.
+AC_DEFUN([_AM_SUBST_NOTMAKE])
+
+# AM_SUBST_NOTMAKE(VARIABLE)
+# --------------------------
+# Public sister of _AM_SUBST_NOTMAKE.
+AC_DEFUN([AM_SUBST_NOTMAKE], [_AM_SUBST_NOTMAKE($@)])
+
+# Check how to create a tarball. -*- Autoconf -*-
+
+# Copyright (C) 2004-2013 Free Software Foundation, Inc.
+#
+# This file is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# _AM_PROG_TAR(FORMAT)
+# --------------------
+# Check how to create a tarball in format FORMAT.
+# FORMAT should be one of 'v7', 'ustar', or 'pax'.
+#
+# Substitute a variable $(am__tar) that is a command
+# writing to stdout a FORMAT-tarball containing the directory
+# $tardir.
+# tardir=directory && $(am__tar) > result.tar
+#
+# Substitute a variable $(am__untar) that extract such
+# a tarball read from stdin.
+# $(am__untar) < result.tar
+#
+AC_DEFUN([_AM_PROG_TAR],
+[# Always define AMTAR for backward compatibility. Yes, it's still used
+# in the wild :-( We should find a proper way to deprecate it ...
+AC_SUBST([AMTAR], ['$${TAR-tar}'])
+
+# We'll loop over all known methods to create a tar archive until one works.
+_am_tools='gnutar m4_if([$1], [ustar], [plaintar]) pax cpio none'
+
+m4_if([$1], [v7],
+ [am__tar='$${TAR-tar} chof - "$$tardir"' am__untar='$${TAR-tar} xf -'],
+
+ [m4_case([$1],
+ [ustar],
+ [# The POSIX 1988 'ustar' format is defined with fixed-size fields.
+ # There is notably a 21 bits limit for the UID and the GID. In fact,
+ # the 'pax' utility can hang on bigger UID/GID (see automake bug#8343
+ # and bug#13588).
+ am_max_uid=2097151 # 2^21 - 1
+ am_max_gid=$am_max_uid
+ # The $UID and $GID variables are not portable, so we need to resort
+ # to the POSIX-mandated id(1) utility. Errors in the 'id' calls
+ # below are definitely unexpected, so allow the users to see them
+ # (that is, avoid stderr redirection).
+ am_uid=`id -u || echo unknown`
+ am_gid=`id -g || echo unknown`
+ AC_MSG_CHECKING([whether UID '$am_uid' is supported by ustar format])
+ if test $am_uid -le $am_max_uid; then
+ AC_MSG_RESULT([yes])
+ else
+ AC_MSG_RESULT([no])
+ _am_tools=none
+ fi
+ AC_MSG_CHECKING([whether GID '$am_gid' is supported by ustar format])
+ if test $am_gid -le $am_max_gid; then
+ AC_MSG_RESULT([yes])
+ else
+ AC_MSG_RESULT([no])
+ _am_tools=none
+ fi],
+
+ [pax],
+ [],
+
+ [m4_fatal([Unknown tar format])])
+
+ AC_MSG_CHECKING([how to create a $1 tar archive])
+
+ # Go ahead even if we have the value already cached. We do so because we
+ # need to set the values for the 'am__tar' and 'am__untar' variables.
+ _am_tools=${am_cv_prog_tar_$1-$_am_tools}
+
+ for _am_tool in $_am_tools; do
+ case $_am_tool in
+ gnutar)
+ for _am_tar in tar gnutar gtar; do
+ AM_RUN_LOG([$_am_tar --version]) && break
+ done
+ am__tar="$_am_tar --format=m4_if([$1], [pax], [posix], [$1]) -chf - "'"$$tardir"'
+ am__tar_="$_am_tar --format=m4_if([$1], [pax], [posix], [$1]) -chf - "'"$tardir"'
+ am__untar="$_am_tar -xf -"
+ ;;
+ plaintar)
+ # Must skip GNU tar: if it does not support --format= it doesn't create
+ # ustar tarball either.
+ (tar --version) >/dev/null 2>&1 && continue
+ am__tar='tar chf - "$$tardir"'
+ am__tar_='tar chf - "$tardir"'
+ am__untar='tar xf -'
+ ;;
+ pax)
+ am__tar='pax -L -x $1 -w "$$tardir"'
+ am__tar_='pax -L -x $1 -w "$tardir"'
+ am__untar='pax -r'
+ ;;
+ cpio)
+ am__tar='find "$$tardir" -print | cpio -o -H $1 -L'
+ am__tar_='find "$tardir" -print | cpio -o -H $1 -L'
+ am__untar='cpio -i -H $1 -d'
+ ;;
+ none)
+ am__tar=false
+ am__tar_=false
+ am__untar=false
+ ;;
+ esac
+
+ # If the value was cached, stop now. We just wanted to have am__tar
+ # and am__untar set.
+ test -n "${am_cv_prog_tar_$1}" && break
+
+ # tar/untar a dummy directory, and stop if the command works.
+ rm -rf conftest.dir
+ mkdir conftest.dir
+ echo GrepMe > conftest.dir/file
+ AM_RUN_LOG([tardir=conftest.dir && eval $am__tar_ >conftest.tar])
+ rm -rf conftest.dir
+ if test -s conftest.tar; then
+ AM_RUN_LOG([$am__untar <conftest.tar])
+ AM_RUN_LOG([cat conftest.dir/file])
+ grep GrepMe conftest.dir/file >/dev/null 2>&1 && break
+ fi
+ done
+ rm -rf conftest.dir
+
+ AC_CACHE_VAL([am_cv_prog_tar_$1], [am_cv_prog_tar_$1=$_am_tool])
+ AC_MSG_RESULT([$am_cv_prog_tar_$1])])
+
+AC_SUBST([am__tar])
+AC_SUBST([am__untar])
+]) # _AM_PROG_TAR
+
+m4_include([m4/asmcfi.m4])
+m4_include([m4/ax_append_flag.m4])
+m4_include([m4/ax_cc_maxopt.m4])
+m4_include([m4/ax_cflags_warn_all.m4])
+m4_include([m4/ax_check_compile_flag.m4])
+m4_include([m4/ax_compiler_vendor.m4])
+m4_include([m4/ax_configure_args.m4])
+m4_include([m4/ax_enable_builddir.m4])
+m4_include([m4/ax_gcc_archflag.m4])
+m4_include([m4/ax_gcc_x86_cpuid.m4])
+m4_include([m4/libtool.m4])
+m4_include([m4/ltoptions.m4])
+m4_include([m4/ltsugar.m4])
+m4_include([m4/ltversion.m4])
+m4_include([m4/lt~obsolete.m4])
+m4_include([acinclude.m4])
diff --git a/jni/ruby/ext/fiddle/libffi-3.2.1/compile b/jni/ruby/ext/fiddle/libffi-3.2.1/compile
new file mode 100755
index 0000000..531136b
--- /dev/null
+++ b/jni/ruby/ext/fiddle/libffi-3.2.1/compile
@@ -0,0 +1,347 @@
+#! /bin/sh
+# Wrapper for compilers which do not understand '-c -o'.
+
+scriptversion=2012-10-14.11; # UTC
+
+# Copyright (C) 1999-2013 Free Software Foundation, Inc.
+# Written by Tom Tromey <tromey@cygnus.com>.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+# As a special exception to the GNU General Public License, if you
+# distribute this file as part of a program that contains a
+# configuration script generated by Autoconf, you may include it under
+# the same distribution terms that you use for the rest of that program.
+
+# This file is maintained in Automake, please report
+# bugs to <bug-automake@gnu.org> or send patches to
+# <automake-patches@gnu.org>.
+
+nl='
+'
+
+# We need space, tab and new line, in precisely that order. Quoting is
+# there to prevent tools from complaining about whitespace usage.
+IFS=" "" $nl"
+
+file_conv=
+
+# func_file_conv build_file lazy
+# Convert a $build file to $host form and store it in $file
+# Currently only supports Windows hosts. If the determined conversion
+# type is listed in (the comma separated) LAZY, no conversion will
+# take place.
+func_file_conv ()
+{
+ file=$1
+ case $file in
+ / | /[!/]*) # absolute file, and not a UNC file
+ if test -z "$file_conv"; then
+ # lazily determine how to convert abs files
+ case `uname -s` in
+ MINGW*)
+ file_conv=mingw
+ ;;
+ CYGWIN*)
+ file_conv=cygwin
+ ;;
+ *)
+ file_conv=wine
+ ;;
+ esac
+ fi
+ case $file_conv/,$2, in
+ *,$file_conv,*)
+ ;;
+ mingw/*)
+ file=`cmd //C echo "$file " | sed -e 's/"\(.*\) " *$/\1/'`
+ ;;
+ cygwin/*)
+ file=`cygpath -m "$file" || echo "$file"`
+ ;;
+ wine/*)
+ file=`winepath -w "$file" || echo "$file"`
+ ;;
+ esac
+ ;;
+ esac
+}
+
+# func_cl_dashL linkdir
+# Make cl look for libraries in LINKDIR
+func_cl_dashL ()
+{
+ func_file_conv "$1"
+ if test -z "$lib_path"; then
+ lib_path=$file
+ else
+ lib_path="$lib_path;$file"
+ fi
+ linker_opts="$linker_opts -LIBPATH:$file"
+}
+
+# func_cl_dashl library
+# Do a library search-path lookup for cl
+func_cl_dashl ()
+{
+ lib=$1
+ found=no
+ save_IFS=$IFS
+ IFS=';'
+ for dir in $lib_path $LIB
+ do
+ IFS=$save_IFS
+ if $shared && test -f "$dir/$lib.dll.lib"; then
+ found=yes
+ lib=$dir/$lib.dll.lib
+ break
+ fi
+ if test -f "$dir/$lib.lib"; then
+ found=yes
+ lib=$dir/$lib.lib
+ break
+ fi
+ if test -f "$dir/lib$lib.a"; then
+ found=yes
+ lib=$dir/lib$lib.a
+ break
+ fi
+ done
+ IFS=$save_IFS
+
+ if test "$found" != yes; then
+ lib=$lib.lib
+ fi
+}
+
+# func_cl_wrapper cl arg...
+# Adjust compile command to suit cl
+func_cl_wrapper ()
+{
+ # Assume a capable shell
+ lib_path=
+ shared=:
+ linker_opts=
+ for arg
+ do
+ if test -n "$eat"; then
+ eat=
+ else
+ case $1 in
+ -o)
+ # configure might choose to run compile as 'compile cc -o foo foo.c'.
+ eat=1
+ case $2 in
+ *.o | *.[oO][bB][jJ])
+ func_file_conv "$2"
+ set x "$@" -Fo"$file"
+ shift
+ ;;
+ *)
+ func_file_conv "$2"
+ set x "$@" -Fe"$file"
+ shift
+ ;;
+ esac
+ ;;
+ -I)
+ eat=1
+ func_file_conv "$2" mingw
+ set x "$@" -I"$file"
+ shift
+ ;;
+ -I*)
+ func_file_conv "${1#-I}" mingw
+ set x "$@" -I"$file"
+ shift
+ ;;
+ -l)
+ eat=1
+ func_cl_dashl "$2"
+ set x "$@" "$lib"
+ shift
+ ;;
+ -l*)
+ func_cl_dashl "${1#-l}"
+ set x "$@" "$lib"
+ shift
+ ;;
+ -L)
+ eat=1
+ func_cl_dashL "$2"
+ ;;
+ -L*)
+ func_cl_dashL "${1#-L}"
+ ;;
+ -static)
+ shared=false
+ ;;
+ -Wl,*)
+ arg=${1#-Wl,}
+ save_ifs="$IFS"; IFS=','
+ for flag in $arg; do
+ IFS="$save_ifs"
+ linker_opts="$linker_opts $flag"
+ done
+ IFS="$save_ifs"
+ ;;
+ -Xlinker)
+ eat=1
+ linker_opts="$linker_opts $2"
+ ;;
+ -*)
+ set x "$@" "$1"
+ shift
+ ;;
+ *.cc | *.CC | *.cxx | *.CXX | *.[cC]++)
+ func_file_conv "$1"
+ set x "$@" -Tp"$file"
+ shift
+ ;;
+ *.c | *.cpp | *.CPP | *.lib | *.LIB | *.Lib | *.OBJ | *.obj | *.[oO])
+ func_file_conv "$1" mingw
+ set x "$@" "$file"
+ shift
+ ;;
+ *)
+ set x "$@" "$1"
+ shift
+ ;;
+ esac
+ fi
+ shift
+ done
+ if test -n "$linker_opts"; then
+ linker_opts="-link$linker_opts"
+ fi
+ exec "$@" $linker_opts
+ exit 1
+}
+
+eat=
+
+case $1 in
+ '')
+ echo "$0: No command. Try '$0 --help' for more information." 1>&2
+ exit 1;
+ ;;
+ -h | --h*)
+ cat <<\EOF
+Usage: compile [--help] [--version] PROGRAM [ARGS]
+
+Wrapper for compilers which do not understand '-c -o'.
+Remove '-o dest.o' from ARGS, run PROGRAM with the remaining
+arguments, and rename the output as expected.
+
+If you are trying to build a whole package this is not the
+right script to run: please start by reading the file 'INSTALL'.
+
+Report bugs to <bug-automake@gnu.org>.
+EOF
+ exit $?
+ ;;
+ -v | --v*)
+ echo "compile $scriptversion"
+ exit $?
+ ;;
+ cl | *[/\\]cl | cl.exe | *[/\\]cl.exe )
+ func_cl_wrapper "$@" # Doesn't return...
+ ;;
+esac
+
+ofile=
+cfile=
+
+for arg
+do
+ if test -n "$eat"; then
+ eat=
+ else
+ case $1 in
+ -o)
+ # configure might choose to run compile as 'compile cc -o foo foo.c'.
+ # So we strip '-o arg' only if arg is an object.
+ eat=1
+ case $2 in
+ *.o | *.obj)
+ ofile=$2
+ ;;
+ *)
+ set x "$@" -o "$2"
+ shift
+ ;;
+ esac
+ ;;
+ *.c)
+ cfile=$1
+ set x "$@" "$1"
+ shift
+ ;;
+ *)
+ set x "$@" "$1"
+ shift
+ ;;
+ esac
+ fi
+ shift
+done
+
+if test -z "$ofile" || test -z "$cfile"; then
+ # If no '-o' option was seen then we might have been invoked from a
+ # pattern rule where we don't need one. That is ok -- this is a
+ # normal compilation that the losing compiler can handle. If no
+ # '.c' file was seen then we are probably linking. That is also
+ # ok.
+ exec "$@"
+fi
+
+# Name of file we expect compiler to create.
+cofile=`echo "$cfile" | sed 's|^.*[\\/]||; s|^[a-zA-Z]:||; s/\.c$/.o/'`
+
+# Create the lock directory.
+# Note: use '[/\\:.-]' here to ensure that we don't use the same name
+# that we are using for the .o file. Also, base the name on the expected
+# object file name, since that is what matters with a parallel build.
+lockdir=`echo "$cofile" | sed -e 's|[/\\:.-]|_|g'`.d
+while true; do
+ if mkdir "$lockdir" >/dev/null 2>&1; then
+ break
+ fi
+ sleep 1
+done
+# FIXME: race condition here if user kills between mkdir and trap.
+trap "rmdir '$lockdir'; exit 1" 1 2 15
+
+# Run the compile.
+"$@"
+ret=$?
+
+if test -f "$cofile"; then
+ test "$cofile" = "$ofile" || mv "$cofile" "$ofile"
+elif test -f "${cofile}bj"; then
+ test "${cofile}bj" = "$ofile" || mv "${cofile}bj" "$ofile"
+fi
+
+rmdir "$lockdir"
+exit $ret
+
+# Local Variables:
+# mode: shell-script
+# sh-indentation: 2
+# eval: (add-hook 'write-file-hooks 'time-stamp)
+# time-stamp-start: "scriptversion="
+# time-stamp-format: "%:y-%02m-%02d.%02H"
+# time-stamp-time-zone: "UTC"
+# time-stamp-end: "; # UTC"
+# End:
diff --git a/jni/ruby/ext/fiddle/libffi-3.2.1/config.guess b/jni/ruby/ext/fiddle/libffi-3.2.1/config.guess
new file mode 100755
index 0000000..b79252d
--- /dev/null
+++ b/jni/ruby/ext/fiddle/libffi-3.2.1/config.guess
@@ -0,0 +1,1558 @@
+#! /bin/sh
+# Attempt to guess a canonical system name.
+# Copyright 1992-2013 Free Software Foundation, Inc.
+
+timestamp='2013-06-10'
+
+# This file is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 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, see <http://www.gnu.org/licenses/>.
+#
+# As a special exception to the GNU General Public License, if you
+# distribute this file as part of a program that contains a
+# configuration script generated by Autoconf, you may include it under
+# the same distribution terms that you use for the rest of that
+# program. This Exception is an additional permission under section 7
+# of the GNU General Public License, version 3 ("GPLv3").
+#
+# Originally written by Per Bothner.
+#
+# You can get the latest version of this script from:
+# http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.guess;hb=HEAD
+#
+# Please send patches with a ChangeLog entry to config-patches@gnu.org.
+
+
+me=`echo "$0" | sed -e 's,.*/,,'`
+
+usage="\
+Usage: $0 [OPTION]
+
+Output the configuration name of the system \`$me' is run on.
+
+Operation modes:
+ -h, --help print this help, then exit
+ -t, --time-stamp print date of last modification, then exit
+ -v, --version print version number, then exit
+
+Report bugs and patches to <config-patches@gnu.org>."
+
+version="\
+GNU config.guess ($timestamp)
+
+Originally written by Per Bothner.
+Copyright 1992-2013 Free Software Foundation, Inc.
+
+This is free software; see the source for copying conditions. There is NO
+warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
+
+help="
+Try \`$me --help' for more information."
+
+# Parse command line
+while test $# -gt 0 ; do
+ case $1 in
+ --time-stamp | --time* | -t )
+ echo "$timestamp" ; exit ;;
+ --version | -v )
+ echo "$version" ; exit ;;
+ --help | --h* | -h )
+ echo "$usage"; exit ;;
+ -- ) # Stop option processing
+ shift; break ;;
+ - ) # Use stdin as input.
+ break ;;
+ -* )
+ echo "$me: invalid option $1$help" >&2
+ exit 1 ;;
+ * )
+ break ;;
+ esac
+done
+
+if test $# != 0; then
+ echo "$me: too many arguments$help" >&2
+ exit 1
+fi
+
+trap 'exit 1' 1 2 15
+
+# CC_FOR_BUILD -- compiler used by this script. Note that the use of a
+# compiler to aid in system detection is discouraged as it requires
+# temporary files to be created and, as you can see below, it is a
+# headache to deal with in a portable fashion.
+
+# Historically, `CC_FOR_BUILD' used to be named `HOST_CC'. We still
+# use `HOST_CC' if defined, but it is deprecated.
+
+# Portable tmp directory creation inspired by the Autoconf team.
+
+set_cc_for_build='
+trap "exitcode=\$?; (rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null) && exit \$exitcode" 0 ;
+trap "rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null; exit 1" 1 2 13 15 ;
+: ${TMPDIR=/tmp} ;
+ { tmp=`(umask 077 && mktemp -d "$TMPDIR/cgXXXXXX") 2>/dev/null` && test -n "$tmp" && test -d "$tmp" ; } ||
+ { test -n "$RANDOM" && tmp=$TMPDIR/cg$$-$RANDOM && (umask 077 && mkdir $tmp) ; } ||
+ { tmp=$TMPDIR/cg-$$ && (umask 077 && mkdir $tmp) && echo "Warning: creating insecure temp directory" >&2 ; } ||
+ { echo "$me: cannot create a temporary directory in $TMPDIR" >&2 ; exit 1 ; } ;
+dummy=$tmp/dummy ;
+tmpfiles="$dummy.c $dummy.o $dummy.rel $dummy" ;
+case $CC_FOR_BUILD,$HOST_CC,$CC in
+ ,,) echo "int x;" > $dummy.c ;
+ for c in cc gcc c89 c99 ; do
+ if ($c -c -o $dummy.o $dummy.c) >/dev/null 2>&1 ; then
+ CC_FOR_BUILD="$c"; break ;
+ fi ;
+ done ;
+ if test x"$CC_FOR_BUILD" = x ; then
+ CC_FOR_BUILD=no_compiler_found ;
+ fi
+ ;;
+ ,,*) CC_FOR_BUILD=$CC ;;
+ ,*,*) CC_FOR_BUILD=$HOST_CC ;;
+esac ; set_cc_for_build= ;'
+
+# This is needed to find uname on a Pyramid OSx when run in the BSD universe.
+# (ghazi@noc.rutgers.edu 1994-08-24)
+if (test -f /.attbin/uname) >/dev/null 2>&1 ; then
+ PATH=$PATH:/.attbin ; export PATH
+fi
+
+UNAME_MACHINE=`(uname -m) 2>/dev/null` || UNAME_MACHINE=unknown
+UNAME_RELEASE=`(uname -r) 2>/dev/null` || UNAME_RELEASE=unknown
+UNAME_SYSTEM=`(uname -s) 2>/dev/null` || UNAME_SYSTEM=unknown
+UNAME_VERSION=`(uname -v) 2>/dev/null` || UNAME_VERSION=unknown
+
+case "${UNAME_SYSTEM}" in
+Linux|GNU|GNU/*)
+ # If the system lacks a compiler, then just pick glibc.
+ # We could probably try harder.
+ LIBC=gnu
+
+ eval $set_cc_for_build
+ cat <<-EOF > $dummy.c
+ #include <features.h>
+ #if defined(__UCLIBC__)
+ LIBC=uclibc
+ #elif defined(__dietlibc__)
+ LIBC=dietlibc
+ #else
+ LIBC=gnu
+ #endif
+ EOF
+ eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep '^LIBC'`
+ ;;
+esac
+
+# Note: order is significant - the case branches are not exclusive.
+
+case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in
+ *:NetBSD:*:*)
+ # NetBSD (nbsd) targets should (where applicable) match one or
+ # more of the tuples: *-*-netbsdelf*, *-*-netbsdaout*,
+ # *-*-netbsdecoff* and *-*-netbsd*. For targets that recently
+ # switched to ELF, *-*-netbsd* would select the old
+ # object file format. This provides both forward
+ # compatibility and a consistent mechanism for selecting the
+ # object file format.
+ #
+ # Note: NetBSD doesn't particularly care about the vendor
+ # portion of the name. We always set it to "unknown".
+ sysctl="sysctl -n hw.machine_arch"
+ UNAME_MACHINE_ARCH=`(/sbin/$sysctl 2>/dev/null || \
+ /usr/sbin/$sysctl 2>/dev/null || echo unknown)`
+ case "${UNAME_MACHINE_ARCH}" in
+ armeb) machine=armeb-unknown ;;
+ arm*) machine=arm-unknown ;;
+ sh3el) machine=shl-unknown ;;
+ sh3eb) machine=sh-unknown ;;
+ sh5el) machine=sh5le-unknown ;;
+ *) machine=${UNAME_MACHINE_ARCH}-unknown ;;
+ esac
+ # The Operating System including object format, if it has switched
+ # to ELF recently, or will in the future.
+ case "${UNAME_MACHINE_ARCH}" in
+ arm*|i386|m68k|ns32k|sh3*|sparc|vax)
+ eval $set_cc_for_build
+ if echo __ELF__ | $CC_FOR_BUILD -E - 2>/dev/null \
+ | grep -q __ELF__
+ then
+ # Once all utilities can be ECOFF (netbsdecoff) or a.out (netbsdaout).
+ # Return netbsd for either. FIX?
+ os=netbsd
+ else
+ os=netbsdelf
+ fi
+ ;;
+ *)
+ os=netbsd
+ ;;
+ esac
+ # The OS release
+ # Debian GNU/NetBSD machines have a different userland, and
+ # thus, need a distinct triplet. However, they do not need
+ # kernel version information, so it can be replaced with a
+ # suitable tag, in the style of linux-gnu.
+ case "${UNAME_VERSION}" in
+ Debian*)
+ release='-gnu'
+ ;;
+ *)
+ release=`echo ${UNAME_RELEASE}|sed -e 's/[-_].*/\./'`
+ ;;
+ esac
+ # Since CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM:
+ # contains redundant information, the shorter form:
+ # CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM is used.
+ echo "${machine}-${os}${release}"
+ exit ;;
+ *:Bitrig:*:*)
+ UNAME_MACHINE_ARCH=`arch | sed 's/Bitrig.//'`
+ echo ${UNAME_MACHINE_ARCH}-unknown-bitrig${UNAME_RELEASE}
+ exit ;;
+ *:OpenBSD:*:*)
+ UNAME_MACHINE_ARCH=`arch | sed 's/OpenBSD.//'`
+ echo ${UNAME_MACHINE_ARCH}-unknown-openbsd${UNAME_RELEASE}
+ exit ;;
+ *:ekkoBSD:*:*)
+ echo ${UNAME_MACHINE}-unknown-ekkobsd${UNAME_RELEASE}
+ exit ;;
+ *:SolidBSD:*:*)
+ echo ${UNAME_MACHINE}-unknown-solidbsd${UNAME_RELEASE}
+ exit ;;
+ macppc:MirBSD:*:*)
+ echo powerpc-unknown-mirbsd${UNAME_RELEASE}
+ exit ;;
+ *:MirBSD:*:*)
+ echo ${UNAME_MACHINE}-unknown-mirbsd${UNAME_RELEASE}
+ exit ;;
+ alpha:OSF1:*:*)
+ case $UNAME_RELEASE in
+ *4.0)
+ UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $3}'`
+ ;;
+ *5.*)
+ UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $4}'`
+ ;;
+ esac
+ # According to Compaq, /usr/sbin/psrinfo has been available on
+ # OSF/1 and Tru64 systems produced since 1995. I hope that
+ # covers most systems running today. This code pipes the CPU
+ # types through head -n 1, so we only detect the type of CPU 0.
+ ALPHA_CPU_TYPE=`/usr/sbin/psrinfo -v | sed -n -e 's/^ The alpha \(.*\) processor.*$/\1/p' | head -n 1`
+ case "$ALPHA_CPU_TYPE" in
+ "EV4 (21064)")
+ UNAME_MACHINE="alpha" ;;
+ "EV4.5 (21064)")
+ UNAME_MACHINE="alpha" ;;
+ "LCA4 (21066/21068)")
+ UNAME_MACHINE="alpha" ;;
+ "EV5 (21164)")
+ UNAME_MACHINE="alphaev5" ;;
+ "EV5.6 (21164A)")
+ UNAME_MACHINE="alphaev56" ;;
+ "EV5.6 (21164PC)")
+ UNAME_MACHINE="alphapca56" ;;
+ "EV5.7 (21164PC)")
+ UNAME_MACHINE="alphapca57" ;;
+ "EV6 (21264)")
+ UNAME_MACHINE="alphaev6" ;;
+ "EV6.7 (21264A)")
+ UNAME_MACHINE="alphaev67" ;;
+ "EV6.8CB (21264C)")
+ UNAME_MACHINE="alphaev68" ;;
+ "EV6.8AL (21264B)")
+ UNAME_MACHINE="alphaev68" ;;
+ "EV6.8CX (21264D)")
+ UNAME_MACHINE="alphaev68" ;;
+ "EV6.9A (21264/EV69A)")
+ UNAME_MACHINE="alphaev69" ;;
+ "EV7 (21364)")
+ UNAME_MACHINE="alphaev7" ;;
+ "EV7.9 (21364A)")
+ UNAME_MACHINE="alphaev79" ;;
+ esac
+ # A Pn.n version is a patched version.
+ # A Vn.n version is a released version.
+ # A Tn.n version is a released field test version.
+ # A Xn.n version is an unreleased experimental baselevel.
+ # 1.2 uses "1.2" for uname -r.
+ echo ${UNAME_MACHINE}-dec-osf`echo ${UNAME_RELEASE} | sed -e 's/^[PVTX]//' | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'`
+ # Reset EXIT trap before exiting to avoid spurious non-zero exit code.
+ exitcode=$?
+ trap '' 0
+ exit $exitcode ;;
+ Alpha\ *:Windows_NT*:*)
+ # How do we know it's Interix rather than the generic POSIX subsystem?
+ # Should we change UNAME_MACHINE based on the output of uname instead
+ # of the specific Alpha model?
+ echo alpha-pc-interix
+ exit ;;
+ 21064:Windows_NT:50:3)
+ echo alpha-dec-winnt3.5
+ exit ;;
+ Amiga*:UNIX_System_V:4.0:*)
+ echo m68k-unknown-sysv4
+ exit ;;
+ *:[Aa]miga[Oo][Ss]:*:*)
+ echo ${UNAME_MACHINE}-unknown-amigaos
+ exit ;;
+ *:[Mm]orph[Oo][Ss]:*:*)
+ echo ${UNAME_MACHINE}-unknown-morphos
+ exit ;;
+ *:OS/390:*:*)
+ echo i370-ibm-openedition
+ exit ;;
+ *:z/VM:*:*)
+ echo s390-ibm-zvmoe
+ exit ;;
+ *:OS400:*:*)
+ echo powerpc-ibm-os400
+ exit ;;
+ arm:RISC*:1.[012]*:*|arm:riscix:1.[012]*:*)
+ echo arm-acorn-riscix${UNAME_RELEASE}
+ exit ;;
+ arm*:riscos:*:*|arm*:RISCOS:*:*)
+ echo arm-unknown-riscos
+ exit ;;
+ SR2?01:HI-UX/MPP:*:* | SR8000:HI-UX/MPP:*:*)
+ echo hppa1.1-hitachi-hiuxmpp
+ exit ;;
+ Pyramid*:OSx*:*:* | MIS*:OSx*:*:* | MIS*:SMP_DC-OSx*:*:*)
+ # akee@wpdis03.wpafb.af.mil (Earle F. Ake) contributed MIS and NILE.
+ if test "`(/bin/universe) 2>/dev/null`" = att ; then
+ echo pyramid-pyramid-sysv3
+ else
+ echo pyramid-pyramid-bsd
+ fi
+ exit ;;
+ NILE*:*:*:dcosx)
+ echo pyramid-pyramid-svr4
+ exit ;;
+ DRS?6000:unix:4.0:6*)
+ echo sparc-icl-nx6
+ exit ;;
+ DRS?6000:UNIX_SV:4.2*:7* | DRS?6000:isis:4.2*:7*)
+ case `/usr/bin/uname -p` in
+ sparc) echo sparc-icl-nx7; exit ;;
+ esac ;;
+ s390x:SunOS:*:*)
+ echo ${UNAME_MACHINE}-ibm-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
+ exit ;;
+ sun4H:SunOS:5.*:*)
+ echo sparc-hal-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
+ exit ;;
+ sun4*:SunOS:5.*:* | tadpole*:SunOS:5.*:*)
+ echo sparc-sun-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
+ exit ;;
+ i86pc:AuroraUX:5.*:* | i86xen:AuroraUX:5.*:*)
+ echo i386-pc-auroraux${UNAME_RELEASE}
+ exit ;;
+ i86pc:SunOS:5.*:* | i86xen:SunOS:5.*:*)
+ eval $set_cc_for_build
+ SUN_ARCH="i386"
+ # If there is a compiler, see if it is configured for 64-bit objects.
+ # Note that the Sun cc does not turn __LP64__ into 1 like gcc does.
+ # This test works for both compilers.
+ if [ "$CC_FOR_BUILD" != 'no_compiler_found' ]; then
+ if (echo '#ifdef __amd64'; echo IS_64BIT_ARCH; echo '#endif') | \
+ (CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) | \
+ grep IS_64BIT_ARCH >/dev/null
+ then
+ SUN_ARCH="x86_64"
+ fi
+ fi
+ echo ${SUN_ARCH}-pc-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
+ exit ;;
+ sun4*:SunOS:6*:*)
+ # According to config.sub, this is the proper way to canonicalize
+ # SunOS6. Hard to guess exactly what SunOS6 will be like, but
+ # it's likely to be more like Solaris than SunOS4.
+ echo sparc-sun-solaris3`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
+ exit ;;
+ sun4*:SunOS:*:*)
+ case "`/usr/bin/arch -k`" in
+ Series*|S4*)
+ UNAME_RELEASE=`uname -v`
+ ;;
+ esac
+ # Japanese Language versions have a version number like `4.1.3-JL'.
+ echo sparc-sun-sunos`echo ${UNAME_RELEASE}|sed -e 's/-/_/'`
+ exit ;;
+ sun3*:SunOS:*:*)
+ echo m68k-sun-sunos${UNAME_RELEASE}
+ exit ;;
+ sun*:*:4.2BSD:*)
+ UNAME_RELEASE=`(sed 1q /etc/motd | awk '{print substr($5,1,3)}') 2>/dev/null`
+ test "x${UNAME_RELEASE}" = "x" && UNAME_RELEASE=3
+ case "`/bin/arch`" in
+ sun3)
+ echo m68k-sun-sunos${UNAME_RELEASE}
+ ;;
+ sun4)
+ echo sparc-sun-sunos${UNAME_RELEASE}
+ ;;
+ esac
+ exit ;;
+ aushp:SunOS:*:*)
+ echo sparc-auspex-sunos${UNAME_RELEASE}
+ exit ;;
+ # The situation for MiNT is a little confusing. The machine name
+ # can be virtually everything (everything which is not
+ # "atarist" or "atariste" at least should have a processor
+ # > m68000). The system name ranges from "MiNT" over "FreeMiNT"
+ # to the lowercase version "mint" (or "freemint"). Finally
+ # the system name "TOS" denotes a system which is actually not
+ # MiNT. But MiNT is downward compatible to TOS, so this should
+ # be no problem.
+ atarist[e]:*MiNT:*:* | atarist[e]:*mint:*:* | atarist[e]:*TOS:*:*)
+ echo m68k-atari-mint${UNAME_RELEASE}
+ exit ;;
+ atari*:*MiNT:*:* | atari*:*mint:*:* | atarist[e]:*TOS:*:*)
+ echo m68k-atari-mint${UNAME_RELEASE}
+ exit ;;
+ *falcon*:*MiNT:*:* | *falcon*:*mint:*:* | *falcon*:*TOS:*:*)
+ echo m68k-atari-mint${UNAME_RELEASE}
+ exit ;;
+ milan*:*MiNT:*:* | milan*:*mint:*:* | *milan*:*TOS:*:*)
+ echo m68k-milan-mint${UNAME_RELEASE}
+ exit ;;
+ hades*:*MiNT:*:* | hades*:*mint:*:* | *hades*:*TOS:*:*)
+ echo m68k-hades-mint${UNAME_RELEASE}
+ exit ;;
+ *:*MiNT:*:* | *:*mint:*:* | *:*TOS:*:*)
+ echo m68k-unknown-mint${UNAME_RELEASE}
+ exit ;;
+ m68k:machten:*:*)
+ echo m68k-apple-machten${UNAME_RELEASE}
+ exit ;;
+ powerpc:machten:*:*)
+ echo powerpc-apple-machten${UNAME_RELEASE}
+ exit ;;
+ RISC*:Mach:*:*)
+ echo mips-dec-mach_bsd4.3
+ exit ;;
+ RISC*:ULTRIX:*:*)
+ echo mips-dec-ultrix${UNAME_RELEASE}
+ exit ;;
+ VAX*:ULTRIX*:*:*)
+ echo vax-dec-ultrix${UNAME_RELEASE}
+ exit ;;
+ 2020:CLIX:*:* | 2430:CLIX:*:*)
+ echo clipper-intergraph-clix${UNAME_RELEASE}
+ exit ;;
+ mips:*:*:UMIPS | mips:*:*:RISCos)
+ eval $set_cc_for_build
+ sed 's/^ //' << EOF >$dummy.c
+#ifdef __cplusplus
+#include <stdio.h> /* for printf() prototype */
+ int main (int argc, char *argv[]) {
+#else
+ int main (argc, argv) int argc; char *argv[]; {
+#endif
+ #if defined (host_mips) && defined (MIPSEB)
+ #if defined (SYSTYPE_SYSV)
+ printf ("mips-mips-riscos%ssysv\n", argv[1]); exit (0);
+ #endif
+ #if defined (SYSTYPE_SVR4)
+ printf ("mips-mips-riscos%ssvr4\n", argv[1]); exit (0);
+ #endif
+ #if defined (SYSTYPE_BSD43) || defined(SYSTYPE_BSD)
+ printf ("mips-mips-riscos%sbsd\n", argv[1]); exit (0);
+ #endif
+ #endif
+ exit (-1);
+ }
+EOF
+ $CC_FOR_BUILD -o $dummy $dummy.c &&
+ dummyarg=`echo "${UNAME_RELEASE}" | sed -n 's/\([0-9]*\).*/\1/p'` &&
+ SYSTEM_NAME=`$dummy $dummyarg` &&
+ { echo "$SYSTEM_NAME"; exit; }
+ echo mips-mips-riscos${UNAME_RELEASE}
+ exit ;;
+ Motorola:PowerMAX_OS:*:*)
+ echo powerpc-motorola-powermax
+ exit ;;
+ Motorola:*:4.3:PL8-*)
+ echo powerpc-harris-powermax
+ exit ;;
+ Night_Hawk:*:*:PowerMAX_OS | Synergy:PowerMAX_OS:*:*)
+ echo powerpc-harris-powermax
+ exit ;;
+ Night_Hawk:Power_UNIX:*:*)
+ echo powerpc-harris-powerunix
+ exit ;;
+ m88k:CX/UX:7*:*)
+ echo m88k-harris-cxux7
+ exit ;;
+ m88k:*:4*:R4*)
+ echo m88k-motorola-sysv4
+ exit ;;
+ m88k:*:3*:R3*)
+ echo m88k-motorola-sysv3
+ exit ;;
+ AViiON:dgux:*:*)
+ # DG/UX returns AViiON for all architectures
+ UNAME_PROCESSOR=`/usr/bin/uname -p`
+ if [ $UNAME_PROCESSOR = mc88100 ] || [ $UNAME_PROCESSOR = mc88110 ]
+ then
+ if [ ${TARGET_BINARY_INTERFACE}x = m88kdguxelfx ] || \
+ [ ${TARGET_BINARY_INTERFACE}x = x ]
+ then
+ echo m88k-dg-dgux${UNAME_RELEASE}
+ else
+ echo m88k-dg-dguxbcs${UNAME_RELEASE}
+ fi
+ else
+ echo i586-dg-dgux${UNAME_RELEASE}
+ fi
+ exit ;;
+ M88*:DolphinOS:*:*) # DolphinOS (SVR3)
+ echo m88k-dolphin-sysv3
+ exit ;;
+ M88*:*:R3*:*)
+ # Delta 88k system running SVR3
+ echo m88k-motorola-sysv3
+ exit ;;
+ XD88*:*:*:*) # Tektronix XD88 system running UTekV (SVR3)
+ echo m88k-tektronix-sysv3
+ exit ;;
+ Tek43[0-9][0-9]:UTek:*:*) # Tektronix 4300 system running UTek (BSD)
+ echo m68k-tektronix-bsd
+ exit ;;
+ *:IRIX*:*:*)
+ echo mips-sgi-irix`echo ${UNAME_RELEASE}|sed -e 's/-/_/g'`
+ exit ;;
+ ????????:AIX?:[12].1:2) # AIX 2.2.1 or AIX 2.1.1 is RT/PC AIX.
+ echo romp-ibm-aix # uname -m gives an 8 hex-code CPU id
+ exit ;; # Note that: echo "'`uname -s`'" gives 'AIX '
+ i*86:AIX:*:*)
+ echo i386-ibm-aix
+ exit ;;
+ ia64:AIX:*:*)
+ if [ -x /usr/bin/oslevel ] ; then
+ IBM_REV=`/usr/bin/oslevel`
+ else
+ IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE}
+ fi
+ echo ${UNAME_MACHINE}-ibm-aix${IBM_REV}
+ exit ;;
+ *:AIX:2:3)
+ if grep bos325 /usr/include/stdio.h >/dev/null 2>&1; then
+ eval $set_cc_for_build
+ sed 's/^ //' << EOF >$dummy.c
+ #include <sys/systemcfg.h>
+
+ main()
+ {
+ if (!__power_pc())
+ exit(1);
+ puts("powerpc-ibm-aix3.2.5");
+ exit(0);
+ }
+EOF
+ if $CC_FOR_BUILD -o $dummy $dummy.c && SYSTEM_NAME=`$dummy`
+ then
+ echo "$SYSTEM_NAME"
+ else
+ echo rs6000-ibm-aix3.2.5
+ fi
+ elif grep bos324 /usr/include/stdio.h >/dev/null 2>&1; then
+ echo rs6000-ibm-aix3.2.4
+ else
+ echo rs6000-ibm-aix3.2
+ fi
+ exit ;;
+ *:AIX:*:[4567])
+ IBM_CPU_ID=`/usr/sbin/lsdev -C -c processor -S available | sed 1q | awk '{ print $1 }'`
+ if /usr/sbin/lsattr -El ${IBM_CPU_ID} | grep ' POWER' >/dev/null 2>&1; then
+ IBM_ARCH=rs6000
+ else
+ IBM_ARCH=powerpc
+ fi
+ if [ -x /usr/bin/oslevel ] ; then
+ IBM_REV=`/usr/bin/oslevel`
+ else
+ IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE}
+ fi
+ echo ${IBM_ARCH}-ibm-aix${IBM_REV}
+ exit ;;
+ *:AIX:*:*)
+ echo rs6000-ibm-aix
+ exit ;;
+ ibmrt:4.4BSD:*|romp-ibm:BSD:*)
+ echo romp-ibm-bsd4.4
+ exit ;;
+ ibmrt:*BSD:*|romp-ibm:BSD:*) # covers RT/PC BSD and
+ echo romp-ibm-bsd${UNAME_RELEASE} # 4.3 with uname added to
+ exit ;; # report: romp-ibm BSD 4.3
+ *:BOSX:*:*)
+ echo rs6000-bull-bosx
+ exit ;;
+ DPX/2?00:B.O.S.:*:*)
+ echo m68k-bull-sysv3
+ exit ;;
+ 9000/[34]??:4.3bsd:1.*:*)
+ echo m68k-hp-bsd
+ exit ;;
+ hp300:4.4BSD:*:* | 9000/[34]??:4.3bsd:2.*:*)
+ echo m68k-hp-bsd4.4
+ exit ;;
+ 9000/[34678]??:HP-UX:*:*)
+ HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'`
+ case "${UNAME_MACHINE}" in
+ 9000/31? ) HP_ARCH=m68000 ;;
+ 9000/[34]?? ) HP_ARCH=m68k ;;
+ 9000/[678][0-9][0-9])
+ if [ -x /usr/bin/getconf ]; then
+ sc_cpu_version=`/usr/bin/getconf SC_CPU_VERSION 2>/dev/null`
+ sc_kernel_bits=`/usr/bin/getconf SC_KERNEL_BITS 2>/dev/null`
+ case "${sc_cpu_version}" in
+ 523) HP_ARCH="hppa1.0" ;; # CPU_PA_RISC1_0
+ 528) HP_ARCH="hppa1.1" ;; # CPU_PA_RISC1_1
+ 532) # CPU_PA_RISC2_0
+ case "${sc_kernel_bits}" in
+ 32) HP_ARCH="hppa2.0n" ;;
+ 64) HP_ARCH="hppa2.0w" ;;
+ '') HP_ARCH="hppa2.0" ;; # HP-UX 10.20
+ esac ;;
+ esac
+ fi
+ if [ "${HP_ARCH}" = "" ]; then
+ eval $set_cc_for_build
+ sed 's/^ //' << EOF >$dummy.c
+
+ #define _HPUX_SOURCE
+ #include <stdlib.h>
+ #include <unistd.h>
+
+ int main ()
+ {
+ #if defined(_SC_KERNEL_BITS)
+ long bits = sysconf(_SC_KERNEL_BITS);
+ #endif
+ long cpu = sysconf (_SC_CPU_VERSION);
+
+ switch (cpu)
+ {
+ case CPU_PA_RISC1_0: puts ("hppa1.0"); break;
+ case CPU_PA_RISC1_1: puts ("hppa1.1"); break;
+ case CPU_PA_RISC2_0:
+ #if defined(_SC_KERNEL_BITS)
+ switch (bits)
+ {
+ case 64: puts ("hppa2.0w"); break;
+ case 32: puts ("hppa2.0n"); break;
+ default: puts ("hppa2.0"); break;
+ } break;
+ #else /* !defined(_SC_KERNEL_BITS) */
+ puts ("hppa2.0"); break;
+ #endif
+ default: puts ("hppa1.0"); break;
+ }
+ exit (0);
+ }
+EOF
+ (CCOPTS= $CC_FOR_BUILD -o $dummy $dummy.c 2>/dev/null) && HP_ARCH=`$dummy`
+ test -z "$HP_ARCH" && HP_ARCH=hppa
+ fi ;;
+ esac
+ if [ ${HP_ARCH} = "hppa2.0w" ]
+ then
+ eval $set_cc_for_build
+
+ # hppa2.0w-hp-hpux* has a 64-bit kernel and a compiler generating
+ # 32-bit code. hppa64-hp-hpux* has the same kernel and a compiler
+ # generating 64-bit code. GNU and HP use different nomenclature:
+ #
+ # $ CC_FOR_BUILD=cc ./config.guess
+ # => hppa2.0w-hp-hpux11.23
+ # $ CC_FOR_BUILD="cc +DA2.0w" ./config.guess
+ # => hppa64-hp-hpux11.23
+
+ if echo __LP64__ | (CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) |
+ grep -q __LP64__
+ then
+ HP_ARCH="hppa2.0w"
+ else
+ HP_ARCH="hppa64"
+ fi
+ fi
+ echo ${HP_ARCH}-hp-hpux${HPUX_REV}
+ exit ;;
+ ia64:HP-UX:*:*)
+ HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'`
+ echo ia64-hp-hpux${HPUX_REV}
+ exit ;;
+ 3050*:HI-UX:*:*)
+ eval $set_cc_for_build
+ sed 's/^ //' << EOF >$dummy.c
+ #include <unistd.h>
+ int
+ main ()
+ {
+ long cpu = sysconf (_SC_CPU_VERSION);
+ /* The order matters, because CPU_IS_HP_MC68K erroneously returns
+ true for CPU_PA_RISC1_0. CPU_IS_PA_RISC returns correct
+ results, however. */
+ if (CPU_IS_PA_RISC (cpu))
+ {
+ switch (cpu)
+ {
+ case CPU_PA_RISC1_0: puts ("hppa1.0-hitachi-hiuxwe2"); break;
+ case CPU_PA_RISC1_1: puts ("hppa1.1-hitachi-hiuxwe2"); break;
+ case CPU_PA_RISC2_0: puts ("hppa2.0-hitachi-hiuxwe2"); break;
+ default: puts ("hppa-hitachi-hiuxwe2"); break;
+ }
+ }
+ else if (CPU_IS_HP_MC68K (cpu))
+ puts ("m68k-hitachi-hiuxwe2");
+ else puts ("unknown-hitachi-hiuxwe2");
+ exit (0);
+ }
+EOF
+ $CC_FOR_BUILD -o $dummy $dummy.c && SYSTEM_NAME=`$dummy` &&
+ { echo "$SYSTEM_NAME"; exit; }
+ echo unknown-hitachi-hiuxwe2
+ exit ;;
+ 9000/7??:4.3bsd:*:* | 9000/8?[79]:4.3bsd:*:* )
+ echo hppa1.1-hp-bsd
+ exit ;;
+ 9000/8??:4.3bsd:*:*)
+ echo hppa1.0-hp-bsd
+ exit ;;
+ *9??*:MPE/iX:*:* | *3000*:MPE/iX:*:*)
+ echo hppa1.0-hp-mpeix
+ exit ;;
+ hp7??:OSF1:*:* | hp8?[79]:OSF1:*:* )
+ echo hppa1.1-hp-osf
+ exit ;;
+ hp8??:OSF1:*:*)
+ echo hppa1.0-hp-osf
+ exit ;;
+ i*86:OSF1:*:*)
+ if [ -x /usr/sbin/sysversion ] ; then
+ echo ${UNAME_MACHINE}-unknown-osf1mk
+ else
+ echo ${UNAME_MACHINE}-unknown-osf1
+ fi
+ exit ;;
+ parisc*:Lites*:*:*)
+ echo hppa1.1-hp-lites
+ exit ;;
+ C1*:ConvexOS:*:* | convex:ConvexOS:C1*:*)
+ echo c1-convex-bsd
+ exit ;;
+ C2*:ConvexOS:*:* | convex:ConvexOS:C2*:*)
+ if getsysinfo -f scalar_acc
+ then echo c32-convex-bsd
+ else echo c2-convex-bsd
+ fi
+ exit ;;
+ C34*:ConvexOS:*:* | convex:ConvexOS:C34*:*)
+ echo c34-convex-bsd
+ exit ;;
+ C38*:ConvexOS:*:* | convex:ConvexOS:C38*:*)
+ echo c38-convex-bsd
+ exit ;;
+ C4*:ConvexOS:*:* | convex:ConvexOS:C4*:*)
+ echo c4-convex-bsd
+ exit ;;
+ CRAY*Y-MP:*:*:*)
+ echo ymp-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
+ exit ;;
+ CRAY*[A-Z]90:*:*:*)
+ echo ${UNAME_MACHINE}-cray-unicos${UNAME_RELEASE} \
+ | sed -e 's/CRAY.*\([A-Z]90\)/\1/' \
+ -e y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/ \
+ -e 's/\.[^.]*$/.X/'
+ exit ;;
+ CRAY*TS:*:*:*)
+ echo t90-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
+ exit ;;
+ CRAY*T3E:*:*:*)
+ echo alphaev5-cray-unicosmk${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
+ exit ;;
+ CRAY*SV1:*:*:*)
+ echo sv1-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
+ exit ;;
+ *:UNICOS/mp:*:*)
+ echo craynv-cray-unicosmp${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
+ exit ;;
+ F30[01]:UNIX_System_V:*:* | F700:UNIX_System_V:*:*)
+ FUJITSU_PROC=`uname -m | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'`
+ FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'`
+ FUJITSU_REL=`echo ${UNAME_RELEASE} | sed -e 's/ /_/'`
+ echo "${FUJITSU_PROC}-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}"
+ exit ;;
+ 5000:UNIX_System_V:4.*:*)
+ FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'`
+ FUJITSU_REL=`echo ${UNAME_RELEASE} | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/ /_/'`
+ echo "sparc-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}"
+ exit ;;
+ i*86:BSD/386:*:* | i*86:BSD/OS:*:* | *:Ascend\ Embedded/OS:*:*)
+ echo ${UNAME_MACHINE}-pc-bsdi${UNAME_RELEASE}
+ exit ;;
+ sparc*:BSD/OS:*:*)
+ echo sparc-unknown-bsdi${UNAME_RELEASE}
+ exit ;;
+ *:BSD/OS:*:*)
+ echo ${UNAME_MACHINE}-unknown-bsdi${UNAME_RELEASE}
+ exit ;;
+ *:FreeBSD:*:*)
+ UNAME_PROCESSOR=`/usr/bin/uname -p`
+ case ${UNAME_PROCESSOR} in
+ amd64)
+ echo x86_64-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;;
+ *)
+ echo ${UNAME_PROCESSOR}-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;;
+ esac
+ exit ;;
+ i*:CYGWIN*:*)
+ echo ${UNAME_MACHINE}-pc-cygwin
+ exit ;;
+ *:MINGW64*:*)
+ echo ${UNAME_MACHINE}-pc-mingw64
+ exit ;;
+ *:MINGW*:*)
+ echo ${UNAME_MACHINE}-pc-mingw32
+ exit ;;
+ i*:MSYS*:*)
+ echo ${UNAME_MACHINE}-pc-msys
+ exit ;;
+ i*:windows32*:*)
+ # uname -m includes "-pc" on this system.
+ echo ${UNAME_MACHINE}-mingw32
+ exit ;;
+ i*:PW*:*)
+ echo ${UNAME_MACHINE}-pc-pw32
+ exit ;;
+ *:Interix*:*)
+ case ${UNAME_MACHINE} in
+ x86)
+ echo i586-pc-interix${UNAME_RELEASE}
+ exit ;;
+ authenticamd | genuineintel | EM64T)
+ echo x86_64-unknown-interix${UNAME_RELEASE}
+ exit ;;
+ IA64)
+ echo ia64-unknown-interix${UNAME_RELEASE}
+ exit ;;
+ esac ;;
+ [345]86:Windows_95:* | [345]86:Windows_98:* | [345]86:Windows_NT:*)
+ echo i${UNAME_MACHINE}-pc-mks
+ exit ;;
+ 8664:Windows_NT:*)
+ echo x86_64-pc-mks
+ exit ;;
+ i*:Windows_NT*:* | Pentium*:Windows_NT*:*)
+ # How do we know it's Interix rather than the generic POSIX subsystem?
+ # It also conflicts with pre-2.0 versions of AT&T UWIN. Should we
+ # UNAME_MACHINE based on the output of uname instead of i386?
+ echo i586-pc-interix
+ exit ;;
+ i*:UWIN*:*)
+ echo ${UNAME_MACHINE}-pc-uwin
+ exit ;;
+ amd64:CYGWIN*:*:* | x86_64:CYGWIN*:*:*)
+ echo x86_64-unknown-cygwin
+ exit ;;
+ p*:CYGWIN*:*)
+ echo powerpcle-unknown-cygwin
+ exit ;;
+ prep*:SunOS:5.*:*)
+ echo powerpcle-unknown-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
+ exit ;;
+ *:GNU:*:*)
+ # the GNU system
+ echo `echo ${UNAME_MACHINE}|sed -e 's,[-/].*$,,'`-unknown-${LIBC}`echo ${UNAME_RELEASE}|sed -e 's,/.*$,,'`
+ exit ;;
+ *:GNU/*:*:*)
+ # other systems with GNU libc and userland
+ echo ${UNAME_MACHINE}-unknown-`echo ${UNAME_SYSTEM} | sed 's,^[^/]*/,,' | tr '[A-Z]' '[a-z]'``echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`-${LIBC}
+ exit ;;
+ i*86:Minix:*:*)
+ echo ${UNAME_MACHINE}-pc-minix
+ exit ;;
+ aarch64:Linux:*:*)
+ echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
+ exit ;;
+ aarch64_be:Linux:*:*)
+ UNAME_MACHINE=aarch64_be
+ echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
+ exit ;;
+ alpha:Linux:*:*)
+ case `sed -n '/^cpu model/s/^.*: \(.*\)/\1/p' < /proc/cpuinfo` in
+ EV5) UNAME_MACHINE=alphaev5 ;;
+ EV56) UNAME_MACHINE=alphaev56 ;;
+ PCA56) UNAME_MACHINE=alphapca56 ;;
+ PCA57) UNAME_MACHINE=alphapca56 ;;
+ EV6) UNAME_MACHINE=alphaev6 ;;
+ EV67) UNAME_MACHINE=alphaev67 ;;
+ EV68*) UNAME_MACHINE=alphaev68 ;;
+ esac
+ objdump --private-headers /bin/sh | grep -q ld.so.1
+ if test "$?" = 0 ; then LIBC="gnulibc1" ; fi
+ echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
+ exit ;;
+ arc:Linux:*:* | arceb:Linux:*:*)
+ echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
+ exit ;;
+ arm*:Linux:*:*)
+ eval $set_cc_for_build
+ if echo __ARM_EABI__ | $CC_FOR_BUILD -E - 2>/dev/null \
+ | grep -q __ARM_EABI__
+ then
+ echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
+ else
+ if echo __ARM_PCS_VFP | $CC_FOR_BUILD -E - 2>/dev/null \
+ | grep -q __ARM_PCS_VFP
+ then
+ echo ${UNAME_MACHINE}-unknown-linux-${LIBC}eabi
+ else
+ echo ${UNAME_MACHINE}-unknown-linux-${LIBC}eabihf
+ fi
+ fi
+ exit ;;
+ avr32*:Linux:*:*)
+ echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
+ exit ;;
+ cris:Linux:*:*)
+ echo ${UNAME_MACHINE}-axis-linux-${LIBC}
+ exit ;;
+ crisv32:Linux:*:*)
+ echo ${UNAME_MACHINE}-axis-linux-${LIBC}
+ exit ;;
+ frv:Linux:*:*)
+ echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
+ exit ;;
+ hexagon:Linux:*:*)
+ echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
+ exit ;;
+ i*86:Linux:*:*)
+ echo ${UNAME_MACHINE}-pc-linux-${LIBC}
+ exit ;;
+ ia64:Linux:*:*)
+ echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
+ exit ;;
+ m32r*:Linux:*:*)
+ echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
+ exit ;;
+ m68*:Linux:*:*)
+ echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
+ exit ;;
+ mips:Linux:*:* | mips64:Linux:*:*)
+ eval $set_cc_for_build
+ sed 's/^ //' << EOF >$dummy.c
+ #undef CPU
+ #undef ${UNAME_MACHINE}
+ #undef ${UNAME_MACHINE}el
+ #if defined(__MIPSEL__) || defined(__MIPSEL) || defined(_MIPSEL) || defined(MIPSEL)
+ CPU=${UNAME_MACHINE}el
+ #else
+ #if defined(__MIPSEB__) || defined(__MIPSEB) || defined(_MIPSEB) || defined(MIPSEB)
+ CPU=${UNAME_MACHINE}
+ #else
+ CPU=
+ #endif
+ #endif
+EOF
+ eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep '^CPU'`
+ test x"${CPU}" != x && { echo "${CPU}-unknown-linux-${LIBC}"; exit; }
+ ;;
+ or1k:Linux:*:*)
+ echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
+ exit ;;
+ or32:Linux:*:*)
+ echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
+ exit ;;
+ padre:Linux:*:*)
+ echo sparc-unknown-linux-${LIBC}
+ exit ;;
+ parisc64:Linux:*:* | hppa64:Linux:*:*)
+ echo hppa64-unknown-linux-${LIBC}
+ exit ;;
+ parisc:Linux:*:* | hppa:Linux:*:*)
+ # Look for CPU level
+ case `grep '^cpu[^a-z]*:' /proc/cpuinfo 2>/dev/null | cut -d' ' -f2` in
+ PA7*) echo hppa1.1-unknown-linux-${LIBC} ;;
+ PA8*) echo hppa2.0-unknown-linux-${LIBC} ;;
+ *) echo hppa-unknown-linux-${LIBC} ;;
+ esac
+ exit ;;
+ ppc64:Linux:*:*)
+ echo powerpc64-unknown-linux-${LIBC}
+ exit ;;
+ ppc:Linux:*:*)
+ echo powerpc-unknown-linux-${LIBC}
+ exit ;;
+ ppc64le:Linux:*:*)
+ echo powerpc64le-unknown-linux-${LIBC}
+ exit ;;
+ ppcle:Linux:*:*)
+ echo powerpcle-unknown-linux-${LIBC}
+ exit ;;
+ s390:Linux:*:* | s390x:Linux:*:*)
+ echo ${UNAME_MACHINE}-ibm-linux-${LIBC}
+ exit ;;
+ sh64*:Linux:*:*)
+ echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
+ exit ;;
+ sh*:Linux:*:*)
+ echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
+ exit ;;
+ sparc:Linux:*:* | sparc64:Linux:*:*)
+ echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
+ exit ;;
+ tile*:Linux:*:*)
+ echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
+ exit ;;
+ vax:Linux:*:*)
+ echo ${UNAME_MACHINE}-dec-linux-${LIBC}
+ exit ;;
+ x86_64:Linux:*:*)
+ echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
+ exit ;;
+ xtensa*:Linux:*:*)
+ echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
+ exit ;;
+ i*86:DYNIX/ptx:4*:*)
+ # ptx 4.0 does uname -s correctly, with DYNIX/ptx in there.
+ # earlier versions are messed up and put the nodename in both
+ # sysname and nodename.
+ echo i386-sequent-sysv4
+ exit ;;
+ i*86:UNIX_SV:4.2MP:2.*)
+ # Unixware is an offshoot of SVR4, but it has its own version
+ # number series starting with 2...
+ # I am not positive that other SVR4 systems won't match this,
+ # I just have to hope. -- rms.
+ # Use sysv4.2uw... so that sysv4* matches it.
+ echo ${UNAME_MACHINE}-pc-sysv4.2uw${UNAME_VERSION}
+ exit ;;
+ i*86:OS/2:*:*)
+ # If we were able to find `uname', then EMX Unix compatibility
+ # is probably installed.
+ echo ${UNAME_MACHINE}-pc-os2-emx
+ exit ;;
+ i*86:XTS-300:*:STOP)
+ echo ${UNAME_MACHINE}-unknown-stop
+ exit ;;
+ i*86:atheos:*:*)
+ echo ${UNAME_MACHINE}-unknown-atheos
+ exit ;;
+ i*86:syllable:*:*)
+ echo ${UNAME_MACHINE}-pc-syllable
+ exit ;;
+ i*86:LynxOS:2.*:* | i*86:LynxOS:3.[01]*:* | i*86:LynxOS:4.[02]*:*)
+ echo i386-unknown-lynxos${UNAME_RELEASE}
+ exit ;;
+ i*86:*DOS:*:*)
+ echo ${UNAME_MACHINE}-pc-msdosdjgpp
+ exit ;;
+ i*86:*:4.*:* | i*86:SYSTEM_V:4.*:*)
+ UNAME_REL=`echo ${UNAME_RELEASE} | sed 's/\/MP$//'`
+ if grep Novell /usr/include/link.h >/dev/null 2>/dev/null; then
+ echo ${UNAME_MACHINE}-univel-sysv${UNAME_REL}
+ else
+ echo ${UNAME_MACHINE}-pc-sysv${UNAME_REL}
+ fi
+ exit ;;
+ i*86:*:5:[678]*)
+ # UnixWare 7.x, OpenUNIX and OpenServer 6.
+ case `/bin/uname -X | grep "^Machine"` in
+ *486*) UNAME_MACHINE=i486 ;;
+ *Pentium) UNAME_MACHINE=i586 ;;
+ *Pent*|*Celeron) UNAME_MACHINE=i686 ;;
+ esac
+ echo ${UNAME_MACHINE}-unknown-sysv${UNAME_RELEASE}${UNAME_SYSTEM}${UNAME_VERSION}
+ exit ;;
+ i*86:*:3.2:*)
+ if test -f /usr/options/cb.name; then
+ UNAME_REL=`sed -n 's/.*Version //p' </usr/options/cb.name`
+ echo ${UNAME_MACHINE}-pc-isc$UNAME_REL
+ elif /bin/uname -X 2>/dev/null >/dev/null ; then
+ UNAME_REL=`(/bin/uname -X|grep Release|sed -e 's/.*= //')`
+ (/bin/uname -X|grep i80486 >/dev/null) && UNAME_MACHINE=i486
+ (/bin/uname -X|grep '^Machine.*Pentium' >/dev/null) \
+ && UNAME_MACHINE=i586
+ (/bin/uname -X|grep '^Machine.*Pent *II' >/dev/null) \
+ && UNAME_MACHINE=i686
+ (/bin/uname -X|grep '^Machine.*Pentium Pro' >/dev/null) \
+ && UNAME_MACHINE=i686
+ echo ${UNAME_MACHINE}-pc-sco$UNAME_REL
+ else
+ echo ${UNAME_MACHINE}-pc-sysv32
+ fi
+ exit ;;
+ pc:*:*:*)
+ # Left here for compatibility:
+ # uname -m prints for DJGPP always 'pc', but it prints nothing about
+ # the processor, so we play safe by assuming i586.
+ # Note: whatever this is, it MUST be the same as what config.sub
+ # prints for the "djgpp" host, or else GDB configury will decide that
+ # this is a cross-build.
+ echo i586-pc-msdosdjgpp
+ exit ;;
+ Intel:Mach:3*:*)
+ echo i386-pc-mach3
+ exit ;;
+ paragon:*:*:*)
+ echo i860-intel-osf1
+ exit ;;
+ i860:*:4.*:*) # i860-SVR4
+ if grep Stardent /usr/include/sys/uadmin.h >/dev/null 2>&1 ; then
+ echo i860-stardent-sysv${UNAME_RELEASE} # Stardent Vistra i860-SVR4
+ else # Add other i860-SVR4 vendors below as they are discovered.
+ echo i860-unknown-sysv${UNAME_RELEASE} # Unknown i860-SVR4
+ fi
+ exit ;;
+ mini*:CTIX:SYS*5:*)
+ # "miniframe"
+ echo m68010-convergent-sysv
+ exit ;;
+ mc68k:UNIX:SYSTEM5:3.51m)
+ echo m68k-convergent-sysv
+ exit ;;
+ M680?0:D-NIX:5.3:*)
+ echo m68k-diab-dnix
+ exit ;;
+ M68*:*:R3V[5678]*:*)
+ test -r /sysV68 && { echo 'm68k-motorola-sysv'; exit; } ;;
+ 3[345]??:*:4.0:3.0 | 3[34]??A:*:4.0:3.0 | 3[34]??,*:*:4.0:3.0 | 3[34]??/*:*:4.0:3.0 | 4400:*:4.0:3.0 | 4850:*:4.0:3.0 | SKA40:*:4.0:3.0 | SDS2:*:4.0:3.0 | SHG2:*:4.0:3.0 | S7501*:*:4.0:3.0)
+ OS_REL=''
+ test -r /etc/.relid \
+ && OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid`
+ /bin/uname -p 2>/dev/null | grep 86 >/dev/null \
+ && { echo i486-ncr-sysv4.3${OS_REL}; exit; }
+ /bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \
+ && { echo i586-ncr-sysv4.3${OS_REL}; exit; } ;;
+ 3[34]??:*:4.0:* | 3[34]??,*:*:4.0:*)
+ /bin/uname -p 2>/dev/null | grep 86 >/dev/null \
+ && { echo i486-ncr-sysv4; exit; } ;;
+ NCR*:*:4.2:* | MPRAS*:*:4.2:*)
+ OS_REL='.3'
+ test -r /etc/.relid \
+ && OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid`
+ /bin/uname -p 2>/dev/null | grep 86 >/dev/null \
+ && { echo i486-ncr-sysv4.3${OS_REL}; exit; }
+ /bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \
+ && { echo i586-ncr-sysv4.3${OS_REL}; exit; }
+ /bin/uname -p 2>/dev/null | /bin/grep pteron >/dev/null \
+ && { echo i586-ncr-sysv4.3${OS_REL}; exit; } ;;
+ m68*:LynxOS:2.*:* | m68*:LynxOS:3.0*:*)
+ echo m68k-unknown-lynxos${UNAME_RELEASE}
+ exit ;;
+ mc68030:UNIX_System_V:4.*:*)
+ echo m68k-atari-sysv4
+ exit ;;
+ TSUNAMI:LynxOS:2.*:*)
+ echo sparc-unknown-lynxos${UNAME_RELEASE}
+ exit ;;
+ rs6000:LynxOS:2.*:*)
+ echo rs6000-unknown-lynxos${UNAME_RELEASE}
+ exit ;;
+ PowerPC:LynxOS:2.*:* | PowerPC:LynxOS:3.[01]*:* | PowerPC:LynxOS:4.[02]*:*)
+ echo powerpc-unknown-lynxos${UNAME_RELEASE}
+ exit ;;
+ SM[BE]S:UNIX_SV:*:*)
+ echo mips-dde-sysv${UNAME_RELEASE}
+ exit ;;
+ RM*:ReliantUNIX-*:*:*)
+ echo mips-sni-sysv4
+ exit ;;
+ RM*:SINIX-*:*:*)
+ echo mips-sni-sysv4
+ exit ;;
+ *:SINIX-*:*:*)
+ if uname -p 2>/dev/null >/dev/null ; then
+ UNAME_MACHINE=`(uname -p) 2>/dev/null`
+ echo ${UNAME_MACHINE}-sni-sysv4
+ else
+ echo ns32k-sni-sysv
+ fi
+ exit ;;
+ PENTIUM:*:4.0*:*) # Unisys `ClearPath HMP IX 4000' SVR4/MP effort
+ # says <Richard.M.Bartel@ccMail.Census.GOV>
+ echo i586-unisys-sysv4
+ exit ;;
+ *:UNIX_System_V:4*:FTX*)
+ # From Gerald Hewes <hewes@openmarket.com>.
+ # How about differentiating between stratus architectures? -djm
+ echo hppa1.1-stratus-sysv4
+ exit ;;
+ *:*:*:FTX*)
+ # From seanf@swdc.stratus.com.
+ echo i860-stratus-sysv4
+ exit ;;
+ i*86:VOS:*:*)
+ # From Paul.Green@stratus.com.
+ echo ${UNAME_MACHINE}-stratus-vos
+ exit ;;
+ *:VOS:*:*)
+ # From Paul.Green@stratus.com.
+ echo hppa1.1-stratus-vos
+ exit ;;
+ mc68*:A/UX:*:*)
+ echo m68k-apple-aux${UNAME_RELEASE}
+ exit ;;
+ news*:NEWS-OS:6*:*)
+ echo mips-sony-newsos6
+ exit ;;
+ R[34]000:*System_V*:*:* | R4000:UNIX_SYSV:*:* | R*000:UNIX_SV:*:*)
+ if [ -d /usr/nec ]; then
+ echo mips-nec-sysv${UNAME_RELEASE}
+ else
+ echo mips-unknown-sysv${UNAME_RELEASE}
+ fi
+ exit ;;
+ BeBox:BeOS:*:*) # BeOS running on hardware made by Be, PPC only.
+ echo powerpc-be-beos
+ exit ;;
+ BeMac:BeOS:*:*) # BeOS running on Mac or Mac clone, PPC only.
+ echo powerpc-apple-beos
+ exit ;;
+ BePC:BeOS:*:*) # BeOS running on Intel PC compatible.
+ echo i586-pc-beos
+ exit ;;
+ BePC:Haiku:*:*) # Haiku running on Intel PC compatible.
+ echo i586-pc-haiku
+ exit ;;
+ x86_64:Haiku:*:*)
+ echo x86_64-unknown-haiku
+ exit ;;
+ SX-4:SUPER-UX:*:*)
+ echo sx4-nec-superux${UNAME_RELEASE}
+ exit ;;
+ SX-5:SUPER-UX:*:*)
+ echo sx5-nec-superux${UNAME_RELEASE}
+ exit ;;
+ SX-6:SUPER-UX:*:*)
+ echo sx6-nec-superux${UNAME_RELEASE}
+ exit ;;
+ SX-7:SUPER-UX:*:*)
+ echo sx7-nec-superux${UNAME_RELEASE}
+ exit ;;
+ SX-8:SUPER-UX:*:*)
+ echo sx8-nec-superux${UNAME_RELEASE}
+ exit ;;
+ SX-8R:SUPER-UX:*:*)
+ echo sx8r-nec-superux${UNAME_RELEASE}
+ exit ;;
+ Power*:Rhapsody:*:*)
+ echo powerpc-apple-rhapsody${UNAME_RELEASE}
+ exit ;;
+ *:Rhapsody:*:*)
+ echo ${UNAME_MACHINE}-apple-rhapsody${UNAME_RELEASE}
+ exit ;;
+ *:Darwin:*:*)
+ UNAME_PROCESSOR=`uname -p` || UNAME_PROCESSOR=unknown
+ eval $set_cc_for_build
+ if test "$UNAME_PROCESSOR" = unknown ; then
+ UNAME_PROCESSOR=powerpc
+ fi
+ if [ "$CC_FOR_BUILD" != 'no_compiler_found' ]; then
+ if (echo '#ifdef __LP64__'; echo IS_64BIT_ARCH; echo '#endif') | \
+ (CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) | \
+ grep IS_64BIT_ARCH >/dev/null
+ then
+ case $UNAME_PROCESSOR in
+ i386) UNAME_PROCESSOR=x86_64 ;;
+ powerpc) UNAME_PROCESSOR=powerpc64 ;;
+ esac
+ fi
+ fi
+ echo ${UNAME_PROCESSOR}-apple-darwin${UNAME_RELEASE}
+ exit ;;
+ *:procnto*:*:* | *:QNX:[0123456789]*:*)
+ UNAME_PROCESSOR=`uname -p`
+ if test "$UNAME_PROCESSOR" = "x86"; then
+ UNAME_PROCESSOR=i386
+ UNAME_MACHINE=pc
+ fi
+ echo ${UNAME_PROCESSOR}-${UNAME_MACHINE}-nto-qnx${UNAME_RELEASE}
+ exit ;;
+ *:QNX:*:4*)
+ echo i386-pc-qnx
+ exit ;;
+ NEO-?:NONSTOP_KERNEL:*:*)
+ echo neo-tandem-nsk${UNAME_RELEASE}
+ exit ;;
+ NSE-*:NONSTOP_KERNEL:*:*)
+ echo nse-tandem-nsk${UNAME_RELEASE}
+ exit ;;
+ NSR-?:NONSTOP_KERNEL:*:*)
+ echo nsr-tandem-nsk${UNAME_RELEASE}
+ exit ;;
+ *:NonStop-UX:*:*)
+ echo mips-compaq-nonstopux
+ exit ;;
+ BS2000:POSIX*:*:*)
+ echo bs2000-siemens-sysv
+ exit ;;
+ DS/*:UNIX_System_V:*:*)
+ echo ${UNAME_MACHINE}-${UNAME_SYSTEM}-${UNAME_RELEASE}
+ exit ;;
+ *:Plan9:*:*)
+ # "uname -m" is not consistent, so use $cputype instead. 386
+ # is converted to i386 for consistency with other x86
+ # operating systems.
+ if test "$cputype" = "386"; then
+ UNAME_MACHINE=i386
+ else
+ UNAME_MACHINE="$cputype"
+ fi
+ echo ${UNAME_MACHINE}-unknown-plan9
+ exit ;;
+ *:TOPS-10:*:*)
+ echo pdp10-unknown-tops10
+ exit ;;
+ *:TENEX:*:*)
+ echo pdp10-unknown-tenex
+ exit ;;
+ KS10:TOPS-20:*:* | KL10:TOPS-20:*:* | TYPE4:TOPS-20:*:*)
+ echo pdp10-dec-tops20
+ exit ;;
+ XKL-1:TOPS-20:*:* | TYPE5:TOPS-20:*:*)
+ echo pdp10-xkl-tops20
+ exit ;;
+ *:TOPS-20:*:*)
+ echo pdp10-unknown-tops20
+ exit ;;
+ *:ITS:*:*)
+ echo pdp10-unknown-its
+ exit ;;
+ SEI:*:*:SEIUX)
+ echo mips-sei-seiux${UNAME_RELEASE}
+ exit ;;
+ *:DragonFly:*:*)
+ echo ${UNAME_MACHINE}-unknown-dragonfly`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`
+ exit ;;
+ *:*VMS:*:*)
+ UNAME_MACHINE=`(uname -p) 2>/dev/null`
+ case "${UNAME_MACHINE}" in
+ A*) echo alpha-dec-vms ; exit ;;
+ I*) echo ia64-dec-vms ; exit ;;
+ V*) echo vax-dec-vms ; exit ;;
+ esac ;;
+ *:XENIX:*:SysV)
+ echo i386-pc-xenix
+ exit ;;
+ i*86:skyos:*:*)
+ echo ${UNAME_MACHINE}-pc-skyos`echo ${UNAME_RELEASE}` | sed -e 's/ .*$//'
+ exit ;;
+ i*86:rdos:*:*)
+ echo ${UNAME_MACHINE}-pc-rdos
+ exit ;;
+ i*86:AROS:*:*)
+ echo ${UNAME_MACHINE}-pc-aros
+ exit ;;
+ x86_64:VMkernel:*:*)
+ echo ${UNAME_MACHINE}-unknown-esx
+ exit ;;
+esac
+
+eval $set_cc_for_build
+cat >$dummy.c <<EOF
+#ifdef _SEQUENT_
+# include <sys/types.h>
+# include <sys/utsname.h>
+#endif
+main ()
+{
+#if defined (sony)
+#if defined (MIPSEB)
+ /* BFD wants "bsd" instead of "newsos". Perhaps BFD should be changed,
+ I don't know.... */
+ printf ("mips-sony-bsd\n"); exit (0);
+#else
+#include <sys/param.h>
+ printf ("m68k-sony-newsos%s\n",
+#ifdef NEWSOS4
+ "4"
+#else
+ ""
+#endif
+ ); exit (0);
+#endif
+#endif
+
+#if defined (__arm) && defined (__acorn) && defined (__unix)
+ printf ("arm-acorn-riscix\n"); exit (0);
+#endif
+
+#if defined (hp300) && !defined (hpux)
+ printf ("m68k-hp-bsd\n"); exit (0);
+#endif
+
+#if defined (NeXT)
+#if !defined (__ARCHITECTURE__)
+#define __ARCHITECTURE__ "m68k"
+#endif
+ int version;
+ version=`(hostinfo | sed -n 's/.*NeXT Mach \([0-9]*\).*/\1/p') 2>/dev/null`;
+ if (version < 4)
+ printf ("%s-next-nextstep%d\n", __ARCHITECTURE__, version);
+ else
+ printf ("%s-next-openstep%d\n", __ARCHITECTURE__, version);
+ exit (0);
+#endif
+
+#if defined (MULTIMAX) || defined (n16)
+#if defined (UMAXV)
+ printf ("ns32k-encore-sysv\n"); exit (0);
+#else
+#if defined (CMU)
+ printf ("ns32k-encore-mach\n"); exit (0);
+#else
+ printf ("ns32k-encore-bsd\n"); exit (0);
+#endif
+#endif
+#endif
+
+#if defined (__386BSD__)
+ printf ("i386-pc-bsd\n"); exit (0);
+#endif
+
+#if defined (sequent)
+#if defined (i386)
+ printf ("i386-sequent-dynix\n"); exit (0);
+#endif
+#if defined (ns32000)
+ printf ("ns32k-sequent-dynix\n"); exit (0);
+#endif
+#endif
+
+#if defined (_SEQUENT_)
+ struct utsname un;
+
+ uname(&un);
+
+ if (strncmp(un.version, "V2", 2) == 0) {
+ printf ("i386-sequent-ptx2\n"); exit (0);
+ }
+ if (strncmp(un.version, "V1", 2) == 0) { /* XXX is V1 correct? */
+ printf ("i386-sequent-ptx1\n"); exit (0);
+ }
+ printf ("i386-sequent-ptx\n"); exit (0);
+
+#endif
+
+#if defined (vax)
+# if !defined (ultrix)
+# include <sys/param.h>
+# if defined (BSD)
+# if BSD == 43
+ printf ("vax-dec-bsd4.3\n"); exit (0);
+# else
+# if BSD == 199006
+ printf ("vax-dec-bsd4.3reno\n"); exit (0);
+# else
+ printf ("vax-dec-bsd\n"); exit (0);
+# endif
+# endif
+# else
+ printf ("vax-dec-bsd\n"); exit (0);
+# endif
+# else
+ printf ("vax-dec-ultrix\n"); exit (0);
+# endif
+#endif
+
+#if defined (alliant) && defined (i860)
+ printf ("i860-alliant-bsd\n"); exit (0);
+#endif
+
+ exit (1);
+}
+EOF
+
+$CC_FOR_BUILD -o $dummy $dummy.c 2>/dev/null && SYSTEM_NAME=`$dummy` &&
+ { echo "$SYSTEM_NAME"; exit; }
+
+# Apollos put the system type in the environment.
+
+test -d /usr/apollo && { echo ${ISP}-apollo-${SYSTYPE}; exit; }
+
+# Convex versions that predate uname can use getsysinfo(1)
+
+if [ -x /usr/convex/getsysinfo ]
+then
+ case `getsysinfo -f cpu_type` in
+ c1*)
+ echo c1-convex-bsd
+ exit ;;
+ c2*)
+ if getsysinfo -f scalar_acc
+ then echo c32-convex-bsd
+ else echo c2-convex-bsd
+ fi
+ exit ;;
+ c34*)
+ echo c34-convex-bsd
+ exit ;;
+ c38*)
+ echo c38-convex-bsd
+ exit ;;
+ c4*)
+ echo c4-convex-bsd
+ exit ;;
+ esac
+fi
+
+cat >&2 <<EOF
+$0: unable to guess system type
+
+This script, last modified $timestamp, has failed to recognize
+the operating system you are using. It is advised that you
+download the most up to date version of the config scripts from
+
+ http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.guess;hb=HEAD
+and
+ http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.sub;hb=HEAD
+
+If the version you run ($0) is already up to date, please
+send the following data and any information you think might be
+pertinent to <config-patches@gnu.org> in order to provide the needed
+information to handle your system.
+
+config.guess timestamp = $timestamp
+
+uname -m = `(uname -m) 2>/dev/null || echo unknown`
+uname -r = `(uname -r) 2>/dev/null || echo unknown`
+uname -s = `(uname -s) 2>/dev/null || echo unknown`
+uname -v = `(uname -v) 2>/dev/null || echo unknown`
+
+/usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null`
+/bin/uname -X = `(/bin/uname -X) 2>/dev/null`
+
+hostinfo = `(hostinfo) 2>/dev/null`
+/bin/universe = `(/bin/universe) 2>/dev/null`
+/usr/bin/arch -k = `(/usr/bin/arch -k) 2>/dev/null`
+/bin/arch = `(/bin/arch) 2>/dev/null`
+/usr/bin/oslevel = `(/usr/bin/oslevel) 2>/dev/null`
+/usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null`
+
+UNAME_MACHINE = ${UNAME_MACHINE}
+UNAME_RELEASE = ${UNAME_RELEASE}
+UNAME_SYSTEM = ${UNAME_SYSTEM}
+UNAME_VERSION = ${UNAME_VERSION}
+EOF
+
+exit 1
+
+# Local variables:
+# eval: (add-hook 'write-file-hooks 'time-stamp)
+# time-stamp-start: "timestamp='"
+# time-stamp-format: "%:y-%02m-%02d"
+# time-stamp-end: "'"
+# End:
diff --git a/jni/ruby/ext/fiddle/libffi-3.2.1/config.sub b/jni/ruby/ext/fiddle/libffi-3.2.1/config.sub
new file mode 100755
index 0000000..c765b34
--- /dev/null
+++ b/jni/ruby/ext/fiddle/libffi-3.2.1/config.sub
@@ -0,0 +1,1788 @@
+#! /bin/sh
+# Configuration validation subroutine script.
+# Copyright 1992-2013 Free Software Foundation, Inc.
+
+timestamp='2013-04-24'
+
+# This file is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 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, see <http://www.gnu.org/licenses/>.
+#
+# As a special exception to the GNU General Public License, if you
+# distribute this file as part of a program that contains a
+# configuration script generated by Autoconf, you may include it under
+# the same distribution terms that you use for the rest of that
+# program. This Exception is an additional permission under section 7
+# of the GNU General Public License, version 3 ("GPLv3").
+
+
+# Please send patches with a ChangeLog entry to config-patches@gnu.org.
+#
+# Configuration subroutine to validate and canonicalize a configuration type.
+# Supply the specified configuration type as an argument.
+# If it is invalid, we print an error message on stderr and exit with code 1.
+# Otherwise, we print the canonical config type on stdout and succeed.
+
+# You can get the latest version of this script from:
+# http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.sub;hb=HEAD
+
+# This file is supposed to be the same for all GNU packages
+# and recognize all the CPU types, system types and aliases
+# that are meaningful with *any* GNU software.
+# Each package is responsible for reporting which valid configurations
+# it does not support. The user should be able to distinguish
+# a failure to support a valid configuration from a meaningless
+# configuration.
+
+# The goal of this file is to map all the various variations of a given
+# machine specification into a single specification in the form:
+# CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM
+# or in some cases, the newer four-part form:
+# CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM
+# It is wrong to echo any other type of specification.
+
+me=`echo "$0" | sed -e 's,.*/,,'`
+
+usage="\
+Usage: $0 [OPTION] CPU-MFR-OPSYS
+ $0 [OPTION] ALIAS
+
+Canonicalize a configuration name.
+
+Operation modes:
+ -h, --help print this help, then exit
+ -t, --time-stamp print date of last modification, then exit
+ -v, --version print version number, then exit
+
+Report bugs and patches to <config-patches@gnu.org>."
+
+version="\
+GNU config.sub ($timestamp)
+
+Copyright 1992-2013 Free Software Foundation, Inc.
+
+This is free software; see the source for copying conditions. There is NO
+warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
+
+help="
+Try \`$me --help' for more information."
+
+# Parse command line
+while test $# -gt 0 ; do
+ case $1 in
+ --time-stamp | --time* | -t )
+ echo "$timestamp" ; exit ;;
+ --version | -v )
+ echo "$version" ; exit ;;
+ --help | --h* | -h )
+ echo "$usage"; exit ;;
+ -- ) # Stop option processing
+ shift; break ;;
+ - ) # Use stdin as input.
+ break ;;
+ -* )
+ echo "$me: invalid option $1$help"
+ exit 1 ;;
+
+ *local*)
+ # First pass through any local machine types.
+ echo $1
+ exit ;;
+
+ * )
+ break ;;
+ esac
+done
+
+case $# in
+ 0) echo "$me: missing argument$help" >&2
+ exit 1;;
+ 1) ;;
+ *) echo "$me: too many arguments$help" >&2
+ exit 1;;
+esac
+
+# Separate what the user gave into CPU-COMPANY and OS or KERNEL-OS (if any).
+# Here we must recognize all the valid KERNEL-OS combinations.
+maybe_os=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\2/'`
+case $maybe_os in
+ nto-qnx* | linux-gnu* | linux-android* | linux-dietlibc | linux-newlib* | \
+ linux-musl* | linux-uclibc* | uclinux-uclibc* | uclinux-gnu* | kfreebsd*-gnu* | \
+ knetbsd*-gnu* | netbsd*-gnu* | \
+ kopensolaris*-gnu* | \
+ storm-chaos* | os2-emx* | rtmk-nova*)
+ os=-$maybe_os
+ basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'`
+ ;;
+ android-linux)
+ os=-linux-android
+ basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'`-unknown
+ ;;
+ *)
+ basic_machine=`echo $1 | sed 's/-[^-]*$//'`
+ if [ $basic_machine != $1 ]
+ then os=`echo $1 | sed 's/.*-/-/'`
+ else os=; fi
+ ;;
+esac
+
+### Let's recognize common machines as not being operating systems so
+### that things like config.sub decstation-3100 work. We also
+### recognize some manufacturers as not being operating systems, so we
+### can provide default operating systems below.
+case $os in
+ -sun*os*)
+ # Prevent following clause from handling this invalid input.
+ ;;
+ -dec* | -mips* | -sequent* | -encore* | -pc532* | -sgi* | -sony* | \
+ -att* | -7300* | -3300* | -delta* | -motorola* | -sun[234]* | \
+ -unicom* | -ibm* | -next | -hp | -isi* | -apollo | -altos* | \
+ -convergent* | -ncr* | -news | -32* | -3600* | -3100* | -hitachi* |\
+ -c[123]* | -convex* | -sun | -crds | -omron* | -dg | -ultra | -tti* | \
+ -harris | -dolphin | -highlevel | -gould | -cbm | -ns | -masscomp | \
+ -apple | -axis | -knuth | -cray | -microblaze*)
+ os=
+ basic_machine=$1
+ ;;
+ -bluegene*)
+ os=-cnk
+ ;;
+ -sim | -cisco | -oki | -wec | -winbond)
+ os=
+ basic_machine=$1
+ ;;
+ -scout)
+ ;;
+ -wrs)
+ os=-vxworks
+ basic_machine=$1
+ ;;
+ -chorusos*)
+ os=-chorusos
+ basic_machine=$1
+ ;;
+ -chorusrdb)
+ os=-chorusrdb
+ basic_machine=$1
+ ;;
+ -hiux*)
+ os=-hiuxwe2
+ ;;
+ -sco6)
+ os=-sco5v6
+ basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
+ ;;
+ -sco5)
+ os=-sco3.2v5
+ basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
+ ;;
+ -sco4)
+ os=-sco3.2v4
+ basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
+ ;;
+ -sco3.2.[4-9]*)
+ os=`echo $os | sed -e 's/sco3.2./sco3.2v/'`
+ basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
+ ;;
+ -sco3.2v[4-9]*)
+ # Don't forget version if it is 3.2v4 or newer.
+ basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
+ ;;
+ -sco5v6*)
+ # Don't forget version if it is 3.2v4 or newer.
+ basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
+ ;;
+ -sco*)
+ os=-sco3.2v2
+ basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
+ ;;
+ -udk*)
+ basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
+ ;;
+ -isc)
+ os=-isc2.2
+ basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
+ ;;
+ -clix*)
+ basic_machine=clipper-intergraph
+ ;;
+ -isc*)
+ basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
+ ;;
+ -lynx*178)
+ os=-lynxos178
+ ;;
+ -lynx*5)
+ os=-lynxos5
+ ;;
+ -lynx*)
+ os=-lynxos
+ ;;
+ -ptx*)
+ basic_machine=`echo $1 | sed -e 's/86-.*/86-sequent/'`
+ ;;
+ -windowsnt*)
+ os=`echo $os | sed -e 's/windowsnt/winnt/'`
+ ;;
+ -psos*)
+ os=-psos
+ ;;
+ -mint | -mint[0-9]*)
+ basic_machine=m68k-atari
+ os=-mint
+ ;;
+esac
+
+# Decode aliases for certain CPU-COMPANY combinations.
+case $basic_machine in
+ # Recognize the basic CPU types without company name.
+ # Some are omitted here because they have special meanings below.
+ 1750a | 580 \
+ | a29k \
+ | aarch64 | aarch64_be \
+ | alpha | alphaev[4-8] | alphaev56 | alphaev6[78] | alphapca5[67] \
+ | alpha64 | alpha64ev[4-8] | alpha64ev56 | alpha64ev6[78] | alpha64pca5[67] \
+ | am33_2.0 \
+ | arc | arceb \
+ | arm | arm[bl]e | arme[lb] | armv[2-8] | armv[3-8][lb] | armv7[arm] \
+ | avr | avr32 \
+ | be32 | be64 \
+ | bfin \
+ | c4x | clipper \
+ | d10v | d30v | dlx | dsp16xx \
+ | epiphany \
+ | fido | fr30 | frv \
+ | h8300 | h8500 | hppa | hppa1.[01] | hppa2.0 | hppa2.0[nw] | hppa64 \
+ | hexagon \
+ | i370 | i860 | i960 | ia64 \
+ | ip2k | iq2000 \
+ | le32 | le64 \
+ | lm32 \
+ | m32c | m32r | m32rle | m68000 | m68k | m88k \
+ | maxq | mb | microblaze | microblazeel | mcore | mep | metag \
+ | mips | mipsbe | mipseb | mipsel | mipsle \
+ | mips16 \
+ | mips64 | mips64el \
+ | mips64octeon | mips64octeonel \
+ | mips64orion | mips64orionel \
+ | mips64r5900 | mips64r5900el \
+ | mips64vr | mips64vrel \
+ | mips64vr4100 | mips64vr4100el \
+ | mips64vr4300 | mips64vr4300el \
+ | mips64vr5000 | mips64vr5000el \
+ | mips64vr5900 | mips64vr5900el \
+ | mipsisa32 | mipsisa32el \
+ | mipsisa32r2 | mipsisa32r2el \
+ | mipsisa64 | mipsisa64el \
+ | mipsisa64r2 | mipsisa64r2el \
+ | mipsisa64sb1 | mipsisa64sb1el \
+ | mipsisa64sr71k | mipsisa64sr71kel \
+ | mipsr5900 | mipsr5900el \
+ | mipstx39 | mipstx39el \
+ | mn10200 | mn10300 \
+ | moxie \
+ | mt \
+ | msp430 \
+ | nds32 | nds32le | nds32be \
+ | nios | nios2 | nios2eb | nios2el \
+ | ns16k | ns32k \
+ | open8 \
+ | or1k | or32 \
+ | pdp10 | pdp11 | pj | pjl \
+ | powerpc | powerpc64 | powerpc64le | powerpcle \
+ | pyramid \
+ | rl78 | rx \
+ | score \
+ | sh | sh[1234] | sh[24]a | sh[24]aeb | sh[23]e | sh[34]eb | sheb | shbe | shle | sh[1234]le | sh3ele \
+ | sh64 | sh64le \
+ | sparc | sparc64 | sparc64b | sparc64v | sparc86x | sparclet | sparclite \
+ | sparcv8 | sparcv9 | sparcv9b | sparcv9v \
+ | spu \
+ | tahoe | tic4x | tic54x | tic55x | tic6x | tic80 | tron \
+ | ubicom32 \
+ | v850 | v850e | v850e1 | v850e2 | v850es | v850e2v3 \
+ | we32k \
+ | x86 | xc16x | xstormy16 | xtensa \
+ | z8k | z80)
+ basic_machine=$basic_machine-unknown
+ ;;
+ c54x)
+ basic_machine=tic54x-unknown
+ ;;
+ c55x)
+ basic_machine=tic55x-unknown
+ ;;
+ c6x)
+ basic_machine=tic6x-unknown
+ ;;
+ m6811 | m68hc11 | m6812 | m68hc12 | m68hcs12x | picochip)
+ basic_machine=$basic_machine-unknown
+ os=-none
+ ;;
+ m88110 | m680[12346]0 | m683?2 | m68360 | m5200 | v70 | w65 | z8k)
+ ;;
+ ms1)
+ basic_machine=mt-unknown
+ ;;
+
+ strongarm | thumb | xscale)
+ basic_machine=arm-unknown
+ ;;
+ xgate)
+ basic_machine=$basic_machine-unknown
+ os=-none
+ ;;
+ xscaleeb)
+ basic_machine=armeb-unknown
+ ;;
+
+ xscaleel)
+ basic_machine=armel-unknown
+ ;;
+
+ # We use `pc' rather than `unknown'
+ # because (1) that's what they normally are, and
+ # (2) the word "unknown" tends to confuse beginning users.
+ i*86 | x86_64)
+ basic_machine=$basic_machine-pc
+ ;;
+ # Object if more than one company name word.
+ *-*-*)
+ echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2
+ exit 1
+ ;;
+ # Recognize the basic CPU types with company name.
+ 580-* \
+ | a29k-* \
+ | aarch64-* | aarch64_be-* \
+ | alpha-* | alphaev[4-8]-* | alphaev56-* | alphaev6[78]-* \
+ | alpha64-* | alpha64ev[4-8]-* | alpha64ev56-* | alpha64ev6[78]-* \
+ | alphapca5[67]-* | alpha64pca5[67]-* | arc-* | arceb-* \
+ | arm-* | armbe-* | armle-* | armeb-* | armv*-* \
+ | avr-* | avr32-* \
+ | be32-* | be64-* \
+ | bfin-* | bs2000-* \
+ | c[123]* | c30-* | [cjt]90-* | c4x-* \
+ | clipper-* | craynv-* | cydra-* \
+ | d10v-* | d30v-* | dlx-* \
+ | elxsi-* \
+ | f30[01]-* | f700-* | fido-* | fr30-* | frv-* | fx80-* \
+ | h8300-* | h8500-* \
+ | hppa-* | hppa1.[01]-* | hppa2.0-* | hppa2.0[nw]-* | hppa64-* \
+ | hexagon-* \
+ | i*86-* | i860-* | i960-* | ia64-* \
+ | ip2k-* | iq2000-* \
+ | le32-* | le64-* \
+ | lm32-* \
+ | m32c-* | m32r-* | m32rle-* \
+ | m68000-* | m680[012346]0-* | m68360-* | m683?2-* | m68k-* \
+ | m88110-* | m88k-* | maxq-* | mcore-* | metag-* \
+ | microblaze-* | microblazeel-* \
+ | mips-* | mipsbe-* | mipseb-* | mipsel-* | mipsle-* \
+ | mips16-* \
+ | mips64-* | mips64el-* \
+ | mips64octeon-* | mips64octeonel-* \
+ | mips64orion-* | mips64orionel-* \
+ | mips64r5900-* | mips64r5900el-* \
+ | mips64vr-* | mips64vrel-* \
+ | mips64vr4100-* | mips64vr4100el-* \
+ | mips64vr4300-* | mips64vr4300el-* \
+ | mips64vr5000-* | mips64vr5000el-* \
+ | mips64vr5900-* | mips64vr5900el-* \
+ | mipsisa32-* | mipsisa32el-* \
+ | mipsisa32r2-* | mipsisa32r2el-* \
+ | mipsisa64-* | mipsisa64el-* \
+ | mipsisa64r2-* | mipsisa64r2el-* \
+ | mipsisa64sb1-* | mipsisa64sb1el-* \
+ | mipsisa64sr71k-* | mipsisa64sr71kel-* \
+ | mipsr5900-* | mipsr5900el-* \
+ | mipstx39-* | mipstx39el-* \
+ | mmix-* \
+ | mt-* \
+ | msp430-* \
+ | nds32-* | nds32le-* | nds32be-* \
+ | nios-* | nios2-* | nios2eb-* | nios2el-* \
+ | none-* | np1-* | ns16k-* | ns32k-* \
+ | open8-* \
+ | orion-* \
+ | pdp10-* | pdp11-* | pj-* | pjl-* | pn-* | power-* \
+ | powerpc-* | powerpc64-* | powerpc64le-* | powerpcle-* \
+ | pyramid-* \
+ | rl78-* | romp-* | rs6000-* | rx-* \
+ | sh-* | sh[1234]-* | sh[24]a-* | sh[24]aeb-* | sh[23]e-* | sh[34]eb-* | sheb-* | shbe-* \
+ | shle-* | sh[1234]le-* | sh3ele-* | sh64-* | sh64le-* \
+ | sparc-* | sparc64-* | sparc64b-* | sparc64v-* | sparc86x-* | sparclet-* \
+ | sparclite-* \
+ | sparcv8-* | sparcv9-* | sparcv9b-* | sparcv9v-* | sv1-* | sx?-* \
+ | tahoe-* \
+ | tic30-* | tic4x-* | tic54x-* | tic55x-* | tic6x-* | tic80-* \
+ | tile*-* \
+ | tron-* \
+ | ubicom32-* \
+ | v850-* | v850e-* | v850e1-* | v850es-* | v850e2-* | v850e2v3-* \
+ | vax-* \
+ | we32k-* \
+ | x86-* | x86_64-* | xc16x-* | xps100-* \
+ | xstormy16-* | xtensa*-* \
+ | ymp-* \
+ | z8k-* | z80-*)
+ ;;
+ # Recognize the basic CPU types without company name, with glob match.
+ xtensa*)
+ basic_machine=$basic_machine-unknown
+ ;;
+ # Recognize the various machine names and aliases which stand
+ # for a CPU type and a company and sometimes even an OS.
+ 386bsd)
+ basic_machine=i386-unknown
+ os=-bsd
+ ;;
+ 3b1 | 7300 | 7300-att | att-7300 | pc7300 | safari | unixpc)
+ basic_machine=m68000-att
+ ;;
+ 3b*)
+ basic_machine=we32k-att
+ ;;
+ a29khif)
+ basic_machine=a29k-amd
+ os=-udi
+ ;;
+ abacus)
+ basic_machine=abacus-unknown
+ ;;
+ adobe68k)
+ basic_machine=m68010-adobe
+ os=-scout
+ ;;
+ alliant | fx80)
+ basic_machine=fx80-alliant
+ ;;
+ altos | altos3068)
+ basic_machine=m68k-altos
+ ;;
+ am29k)
+ basic_machine=a29k-none
+ os=-bsd
+ ;;
+ amd64)
+ basic_machine=x86_64-pc
+ ;;
+ amd64-*)
+ basic_machine=x86_64-`echo $basic_machine | sed 's/^[^-]*-//'`
+ ;;
+ amdahl)
+ basic_machine=580-amdahl
+ os=-sysv
+ ;;
+ amiga | amiga-*)
+ basic_machine=m68k-unknown
+ ;;
+ amigaos | amigados)
+ basic_machine=m68k-unknown
+ os=-amigaos
+ ;;
+ amigaunix | amix)
+ basic_machine=m68k-unknown
+ os=-sysv4
+ ;;
+ apollo68)
+ basic_machine=m68k-apollo
+ os=-sysv
+ ;;
+ apollo68bsd)
+ basic_machine=m68k-apollo
+ os=-bsd
+ ;;
+ aros)
+ basic_machine=i386-pc
+ os=-aros
+ ;;
+ aux)
+ basic_machine=m68k-apple
+ os=-aux
+ ;;
+ balance)
+ basic_machine=ns32k-sequent
+ os=-dynix
+ ;;
+ blackfin)
+ basic_machine=bfin-unknown
+ os=-linux
+ ;;
+ blackfin-*)
+ basic_machine=bfin-`echo $basic_machine | sed 's/^[^-]*-//'`
+ os=-linux
+ ;;
+ bluegene*)
+ basic_machine=powerpc-ibm
+ os=-cnk
+ ;;
+ c54x-*)
+ basic_machine=tic54x-`echo $basic_machine | sed 's/^[^-]*-//'`
+ ;;
+ c55x-*)
+ basic_machine=tic55x-`echo $basic_machine | sed 's/^[^-]*-//'`
+ ;;
+ c6x-*)
+ basic_machine=tic6x-`echo $basic_machine | sed 's/^[^-]*-//'`
+ ;;
+ c90)
+ basic_machine=c90-cray
+ os=-unicos
+ ;;
+ cegcc)
+ basic_machine=arm-unknown
+ os=-cegcc
+ ;;
+ convex-c1)
+ basic_machine=c1-convex
+ os=-bsd
+ ;;
+ convex-c2)
+ basic_machine=c2-convex
+ os=-bsd
+ ;;
+ convex-c32)
+ basic_machine=c32-convex
+ os=-bsd
+ ;;
+ convex-c34)
+ basic_machine=c34-convex
+ os=-bsd
+ ;;
+ convex-c38)
+ basic_machine=c38-convex
+ os=-bsd
+ ;;
+ cray | j90)
+ basic_machine=j90-cray
+ os=-unicos
+ ;;
+ craynv)
+ basic_machine=craynv-cray
+ os=-unicosmp
+ ;;
+ cr16 | cr16-*)
+ basic_machine=cr16-unknown
+ os=-elf
+ ;;
+ crds | unos)
+ basic_machine=m68k-crds
+ ;;
+ crisv32 | crisv32-* | etraxfs*)
+ basic_machine=crisv32-axis
+ ;;
+ cris | cris-* | etrax*)
+ basic_machine=cris-axis
+ ;;
+ crx)
+ basic_machine=crx-unknown
+ os=-elf
+ ;;
+ da30 | da30-*)
+ basic_machine=m68k-da30
+ ;;
+ decstation | decstation-3100 | pmax | pmax-* | pmin | dec3100 | decstatn)
+ basic_machine=mips-dec
+ ;;
+ decsystem10* | dec10*)
+ basic_machine=pdp10-dec
+ os=-tops10
+ ;;
+ decsystem20* | dec20*)
+ basic_machine=pdp10-dec
+ os=-tops20
+ ;;
+ delta | 3300 | motorola-3300 | motorola-delta \
+ | 3300-motorola | delta-motorola)
+ basic_machine=m68k-motorola
+ ;;
+ delta88)
+ basic_machine=m88k-motorola
+ os=-sysv3
+ ;;
+ dicos)
+ basic_machine=i686-pc
+ os=-dicos
+ ;;
+ djgpp)
+ basic_machine=i586-pc
+ os=-msdosdjgpp
+ ;;
+ dpx20 | dpx20-*)
+ basic_machine=rs6000-bull
+ os=-bosx
+ ;;
+ dpx2* | dpx2*-bull)
+ basic_machine=m68k-bull
+ os=-sysv3
+ ;;
+ ebmon29k)
+ basic_machine=a29k-amd
+ os=-ebmon
+ ;;
+ elxsi)
+ basic_machine=elxsi-elxsi
+ os=-bsd
+ ;;
+ encore | umax | mmax)
+ basic_machine=ns32k-encore
+ ;;
+ es1800 | OSE68k | ose68k | ose | OSE)
+ basic_machine=m68k-ericsson
+ os=-ose
+ ;;
+ fx2800)
+ basic_machine=i860-alliant
+ ;;
+ genix)
+ basic_machine=ns32k-ns
+ ;;
+ gmicro)
+ basic_machine=tron-gmicro
+ os=-sysv
+ ;;
+ go32)
+ basic_machine=i386-pc
+ os=-go32
+ ;;
+ h3050r* | hiux*)
+ basic_machine=hppa1.1-hitachi
+ os=-hiuxwe2
+ ;;
+ h8300hms)
+ basic_machine=h8300-hitachi
+ os=-hms
+ ;;
+ h8300xray)
+ basic_machine=h8300-hitachi
+ os=-xray
+ ;;
+ h8500hms)
+ basic_machine=h8500-hitachi
+ os=-hms
+ ;;
+ harris)
+ basic_machine=m88k-harris
+ os=-sysv3
+ ;;
+ hp300-*)
+ basic_machine=m68k-hp
+ ;;
+ hp300bsd)
+ basic_machine=m68k-hp
+ os=-bsd
+ ;;
+ hp300hpux)
+ basic_machine=m68k-hp
+ os=-hpux
+ ;;
+ hp3k9[0-9][0-9] | hp9[0-9][0-9])
+ basic_machine=hppa1.0-hp
+ ;;
+ hp9k2[0-9][0-9] | hp9k31[0-9])
+ basic_machine=m68000-hp
+ ;;
+ hp9k3[2-9][0-9])
+ basic_machine=m68k-hp
+ ;;
+ hp9k6[0-9][0-9] | hp6[0-9][0-9])
+ basic_machine=hppa1.0-hp
+ ;;
+ hp9k7[0-79][0-9] | hp7[0-79][0-9])
+ basic_machine=hppa1.1-hp
+ ;;
+ hp9k78[0-9] | hp78[0-9])
+ # FIXME: really hppa2.0-hp
+ basic_machine=hppa1.1-hp
+ ;;
+ hp9k8[67]1 | hp8[67]1 | hp9k80[24] | hp80[24] | hp9k8[78]9 | hp8[78]9 | hp9k893 | hp893)
+ # FIXME: really hppa2.0-hp
+ basic_machine=hppa1.1-hp
+ ;;
+ hp9k8[0-9][13679] | hp8[0-9][13679])
+ basic_machine=hppa1.1-hp
+ ;;
+ hp9k8[0-9][0-9] | hp8[0-9][0-9])
+ basic_machine=hppa1.0-hp
+ ;;
+ hppa-next)
+ os=-nextstep3
+ ;;
+ hppaosf)
+ basic_machine=hppa1.1-hp
+ os=-osf
+ ;;
+ hppro)
+ basic_machine=hppa1.1-hp
+ os=-proelf
+ ;;
+ i370-ibm* | ibm*)
+ basic_machine=i370-ibm
+ ;;
+ i*86v32)
+ basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'`
+ os=-sysv32
+ ;;
+ i*86v4*)
+ basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'`
+ os=-sysv4
+ ;;
+ i*86v)
+ basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'`
+ os=-sysv
+ ;;
+ i*86sol2)
+ basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'`
+ os=-solaris2
+ ;;
+ i386mach)
+ basic_machine=i386-mach
+ os=-mach
+ ;;
+ i386-vsta | vsta)
+ basic_machine=i386-unknown
+ os=-vsta
+ ;;
+ iris | iris4d)
+ basic_machine=mips-sgi
+ case $os in
+ -irix*)
+ ;;
+ *)
+ os=-irix4
+ ;;
+ esac
+ ;;
+ isi68 | isi)
+ basic_machine=m68k-isi
+ os=-sysv
+ ;;
+ m68knommu)
+ basic_machine=m68k-unknown
+ os=-linux
+ ;;
+ m68knommu-*)
+ basic_machine=m68k-`echo $basic_machine | sed 's/^[^-]*-//'`
+ os=-linux
+ ;;
+ m88k-omron*)
+ basic_machine=m88k-omron
+ ;;
+ magnum | m3230)
+ basic_machine=mips-mips
+ os=-sysv
+ ;;
+ merlin)
+ basic_machine=ns32k-utek
+ os=-sysv
+ ;;
+ microblaze*)
+ basic_machine=microblaze-xilinx
+ ;;
+ mingw64)
+ basic_machine=x86_64-pc
+ os=-mingw64
+ ;;
+ mingw32)
+ basic_machine=i386-pc
+ os=-mingw32
+ ;;
+ mingw32ce)
+ basic_machine=arm-unknown
+ os=-mingw32ce
+ ;;
+ miniframe)
+ basic_machine=m68000-convergent
+ ;;
+ *mint | -mint[0-9]* | *MiNT | *MiNT[0-9]*)
+ basic_machine=m68k-atari
+ os=-mint
+ ;;
+ mips3*-*)
+ basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'`
+ ;;
+ mips3*)
+ basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'`-unknown
+ ;;
+ monitor)
+ basic_machine=m68k-rom68k
+ os=-coff
+ ;;
+ morphos)
+ basic_machine=powerpc-unknown
+ os=-morphos
+ ;;
+ msdos)
+ basic_machine=i386-pc
+ os=-msdos
+ ;;
+ ms1-*)
+ basic_machine=`echo $basic_machine | sed -e 's/ms1-/mt-/'`
+ ;;
+ msys)
+ basic_machine=i386-pc
+ os=-msys
+ ;;
+ mvs)
+ basic_machine=i370-ibm
+ os=-mvs
+ ;;
+ nacl)
+ basic_machine=le32-unknown
+ os=-nacl
+ ;;
+ ncr3000)
+ basic_machine=i486-ncr
+ os=-sysv4
+ ;;
+ netbsd386)
+ basic_machine=i386-unknown
+ os=-netbsd
+ ;;
+ netwinder)
+ basic_machine=armv4l-rebel
+ os=-linux
+ ;;
+ news | news700 | news800 | news900)
+ basic_machine=m68k-sony
+ os=-newsos
+ ;;
+ news1000)
+ basic_machine=m68030-sony
+ os=-newsos
+ ;;
+ news-3600 | risc-news)
+ basic_machine=mips-sony
+ os=-newsos
+ ;;
+ necv70)
+ basic_machine=v70-nec
+ os=-sysv
+ ;;
+ next | m*-next )
+ basic_machine=m68k-next
+ case $os in
+ -nextstep* )
+ ;;
+ -ns2*)
+ os=-nextstep2
+ ;;
+ *)
+ os=-nextstep3
+ ;;
+ esac
+ ;;
+ nh3000)
+ basic_machine=m68k-harris
+ os=-cxux
+ ;;
+ nh[45]000)
+ basic_machine=m88k-harris
+ os=-cxux
+ ;;
+ nindy960)
+ basic_machine=i960-intel
+ os=-nindy
+ ;;
+ mon960)
+ basic_machine=i960-intel
+ os=-mon960
+ ;;
+ nonstopux)
+ basic_machine=mips-compaq
+ os=-nonstopux
+ ;;
+ np1)
+ basic_machine=np1-gould
+ ;;
+ neo-tandem)
+ basic_machine=neo-tandem
+ ;;
+ nse-tandem)
+ basic_machine=nse-tandem
+ ;;
+ nsr-tandem)
+ basic_machine=nsr-tandem
+ ;;
+ op50n-* | op60c-*)
+ basic_machine=hppa1.1-oki
+ os=-proelf
+ ;;
+ openrisc | openrisc-*)
+ basic_machine=or32-unknown
+ ;;
+ os400)
+ basic_machine=powerpc-ibm
+ os=-os400
+ ;;
+ OSE68000 | ose68000)
+ basic_machine=m68000-ericsson
+ os=-ose
+ ;;
+ os68k)
+ basic_machine=m68k-none
+ os=-os68k
+ ;;
+ pa-hitachi)
+ basic_machine=hppa1.1-hitachi
+ os=-hiuxwe2
+ ;;
+ paragon)
+ basic_machine=i860-intel
+ os=-osf
+ ;;
+ parisc)
+ basic_machine=hppa-unknown
+ os=-linux
+ ;;
+ parisc-*)
+ basic_machine=hppa-`echo $basic_machine | sed 's/^[^-]*-//'`
+ os=-linux
+ ;;
+ pbd)
+ basic_machine=sparc-tti
+ ;;
+ pbb)
+ basic_machine=m68k-tti
+ ;;
+ pc532 | pc532-*)
+ basic_machine=ns32k-pc532
+ ;;
+ pc98)
+ basic_machine=i386-pc
+ ;;
+ pc98-*)
+ basic_machine=i386-`echo $basic_machine | sed 's/^[^-]*-//'`
+ ;;
+ pentium | p5 | k5 | k6 | nexgen | viac3)
+ basic_machine=i586-pc
+ ;;
+ pentiumpro | p6 | 6x86 | athlon | athlon_*)
+ basic_machine=i686-pc
+ ;;
+ pentiumii | pentium2 | pentiumiii | pentium3)
+ basic_machine=i686-pc
+ ;;
+ pentium4)
+ basic_machine=i786-pc
+ ;;
+ pentium-* | p5-* | k5-* | k6-* | nexgen-* | viac3-*)
+ basic_machine=i586-`echo $basic_machine | sed 's/^[^-]*-//'`
+ ;;
+ pentiumpro-* | p6-* | 6x86-* | athlon-*)
+ basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'`
+ ;;
+ pentiumii-* | pentium2-* | pentiumiii-* | pentium3-*)
+ basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'`
+ ;;
+ pentium4-*)
+ basic_machine=i786-`echo $basic_machine | sed 's/^[^-]*-//'`
+ ;;
+ pn)
+ basic_machine=pn-gould
+ ;;
+ power) basic_machine=power-ibm
+ ;;
+ ppc | ppcbe) basic_machine=powerpc-unknown
+ ;;
+ ppc-* | ppcbe-*)
+ basic_machine=powerpc-`echo $basic_machine | sed 's/^[^-]*-//'`
+ ;;
+ ppcle | powerpclittle | ppc-le | powerpc-little)
+ basic_machine=powerpcle-unknown
+ ;;
+ ppcle-* | powerpclittle-*)
+ basic_machine=powerpcle-`echo $basic_machine | sed 's/^[^-]*-//'`
+ ;;
+ ppc64) basic_machine=powerpc64-unknown
+ ;;
+ ppc64-* | ppc64p7-*) basic_machine=powerpc64-`echo $basic_machine | sed 's/^[^-]*-//'`
+ ;;
+ ppc64le | powerpc64little | ppc64-le | powerpc64-little)
+ basic_machine=powerpc64le-unknown
+ ;;
+ ppc64le-* | powerpc64little-*)
+ basic_machine=powerpc64le-`echo $basic_machine | sed 's/^[^-]*-//'`
+ ;;
+ ps2)
+ basic_machine=i386-ibm
+ ;;
+ pw32)
+ basic_machine=i586-unknown
+ os=-pw32
+ ;;
+ rdos | rdos64)
+ basic_machine=x86_64-pc
+ os=-rdos
+ ;;
+ rdos32)
+ basic_machine=i386-pc
+ os=-rdos
+ ;;
+ rom68k)
+ basic_machine=m68k-rom68k
+ os=-coff
+ ;;
+ rm[46]00)
+ basic_machine=mips-siemens
+ ;;
+ rtpc | rtpc-*)
+ basic_machine=romp-ibm
+ ;;
+ s390 | s390-*)
+ basic_machine=s390-ibm
+ ;;
+ s390x | s390x-*)
+ basic_machine=s390x-ibm
+ ;;
+ sa29200)
+ basic_machine=a29k-amd
+ os=-udi
+ ;;
+ sb1)
+ basic_machine=mipsisa64sb1-unknown
+ ;;
+ sb1el)
+ basic_machine=mipsisa64sb1el-unknown
+ ;;
+ sde)
+ basic_machine=mipsisa32-sde
+ os=-elf
+ ;;
+ sei)
+ basic_machine=mips-sei
+ os=-seiux
+ ;;
+ sequent)
+ basic_machine=i386-sequent
+ ;;
+ sh)
+ basic_machine=sh-hitachi
+ os=-hms
+ ;;
+ sh5el)
+ basic_machine=sh5le-unknown
+ ;;
+ sh64)
+ basic_machine=sh64-unknown
+ ;;
+ sparclite-wrs | simso-wrs)
+ basic_machine=sparclite-wrs
+ os=-vxworks
+ ;;
+ sps7)
+ basic_machine=m68k-bull
+ os=-sysv2
+ ;;
+ spur)
+ basic_machine=spur-unknown
+ ;;
+ st2000)
+ basic_machine=m68k-tandem
+ ;;
+ stratus)
+ basic_machine=i860-stratus
+ os=-sysv4
+ ;;
+ strongarm-* | thumb-*)
+ basic_machine=arm-`echo $basic_machine | sed 's/^[^-]*-//'`
+ ;;
+ sun2)
+ basic_machine=m68000-sun
+ ;;
+ sun2os3)
+ basic_machine=m68000-sun
+ os=-sunos3
+ ;;
+ sun2os4)
+ basic_machine=m68000-sun
+ os=-sunos4
+ ;;
+ sun3os3)
+ basic_machine=m68k-sun
+ os=-sunos3
+ ;;
+ sun3os4)
+ basic_machine=m68k-sun
+ os=-sunos4
+ ;;
+ sun4os3)
+ basic_machine=sparc-sun
+ os=-sunos3
+ ;;
+ sun4os4)
+ basic_machine=sparc-sun
+ os=-sunos4
+ ;;
+ sun4sol2)
+ basic_machine=sparc-sun
+ os=-solaris2
+ ;;
+ sun3 | sun3-*)
+ basic_machine=m68k-sun
+ ;;
+ sun4)
+ basic_machine=sparc-sun
+ ;;
+ sun386 | sun386i | roadrunner)
+ basic_machine=i386-sun
+ ;;
+ sv1)
+ basic_machine=sv1-cray
+ os=-unicos
+ ;;
+ symmetry)
+ basic_machine=i386-sequent
+ os=-dynix
+ ;;
+ t3e)
+ basic_machine=alphaev5-cray
+ os=-unicos
+ ;;
+ t90)
+ basic_machine=t90-cray
+ os=-unicos
+ ;;
+ tile*)
+ basic_machine=$basic_machine-unknown
+ os=-linux-gnu
+ ;;
+ tx39)
+ basic_machine=mipstx39-unknown
+ ;;
+ tx39el)
+ basic_machine=mipstx39el-unknown
+ ;;
+ toad1)
+ basic_machine=pdp10-xkl
+ os=-tops20
+ ;;
+ tower | tower-32)
+ basic_machine=m68k-ncr
+ ;;
+ tpf)
+ basic_machine=s390x-ibm
+ os=-tpf
+ ;;
+ udi29k)
+ basic_machine=a29k-amd
+ os=-udi
+ ;;
+ ultra3)
+ basic_machine=a29k-nyu
+ os=-sym1
+ ;;
+ v810 | necv810)
+ basic_machine=v810-nec
+ os=-none
+ ;;
+ vaxv)
+ basic_machine=vax-dec
+ os=-sysv
+ ;;
+ vms)
+ basic_machine=vax-dec
+ os=-vms
+ ;;
+ vpp*|vx|vx-*)
+ basic_machine=f301-fujitsu
+ ;;
+ vxworks960)
+ basic_machine=i960-wrs
+ os=-vxworks
+ ;;
+ vxworks68)
+ basic_machine=m68k-wrs
+ os=-vxworks
+ ;;
+ vxworks29k)
+ basic_machine=a29k-wrs
+ os=-vxworks
+ ;;
+ w65*)
+ basic_machine=w65-wdc
+ os=-none
+ ;;
+ w89k-*)
+ basic_machine=hppa1.1-winbond
+ os=-proelf
+ ;;
+ xbox)
+ basic_machine=i686-pc
+ os=-mingw32
+ ;;
+ xps | xps100)
+ basic_machine=xps100-honeywell
+ ;;
+ xscale-* | xscalee[bl]-*)
+ basic_machine=`echo $basic_machine | sed 's/^xscale/arm/'`
+ ;;
+ ymp)
+ basic_machine=ymp-cray
+ os=-unicos
+ ;;
+ z8k-*-coff)
+ basic_machine=z8k-unknown
+ os=-sim
+ ;;
+ z80-*-coff)
+ basic_machine=z80-unknown
+ os=-sim
+ ;;
+ none)
+ basic_machine=none-none
+ os=-none
+ ;;
+
+# Here we handle the default manufacturer of certain CPU types. It is in
+# some cases the only manufacturer, in others, it is the most popular.
+ w89k)
+ basic_machine=hppa1.1-winbond
+ ;;
+ op50n)
+ basic_machine=hppa1.1-oki
+ ;;
+ op60c)
+ basic_machine=hppa1.1-oki
+ ;;
+ romp)
+ basic_machine=romp-ibm
+ ;;
+ mmix)
+ basic_machine=mmix-knuth
+ ;;
+ rs6000)
+ basic_machine=rs6000-ibm
+ ;;
+ vax)
+ basic_machine=vax-dec
+ ;;
+ pdp10)
+ # there are many clones, so DEC is not a safe bet
+ basic_machine=pdp10-unknown
+ ;;
+ pdp11)
+ basic_machine=pdp11-dec
+ ;;
+ we32k)
+ basic_machine=we32k-att
+ ;;
+ sh[1234] | sh[24]a | sh[24]aeb | sh[34]eb | sh[1234]le | sh[23]ele)
+ basic_machine=sh-unknown
+ ;;
+ sparc | sparcv8 | sparcv9 | sparcv9b | sparcv9v)
+ basic_machine=sparc-sun
+ ;;
+ cydra)
+ basic_machine=cydra-cydrome
+ ;;
+ orion)
+ basic_machine=orion-highlevel
+ ;;
+ orion105)
+ basic_machine=clipper-highlevel
+ ;;
+ mac | mpw | mac-mpw)
+ basic_machine=m68k-apple
+ ;;
+ pmac | pmac-mpw)
+ basic_machine=powerpc-apple
+ ;;
+ *-unknown)
+ # Make sure to match an already-canonicalized machine name.
+ ;;
+ *)
+ echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2
+ exit 1
+ ;;
+esac
+
+# Here we canonicalize certain aliases for manufacturers.
+case $basic_machine in
+ *-digital*)
+ basic_machine=`echo $basic_machine | sed 's/digital.*/dec/'`
+ ;;
+ *-commodore*)
+ basic_machine=`echo $basic_machine | sed 's/commodore.*/cbm/'`
+ ;;
+ *)
+ ;;
+esac
+
+# Decode manufacturer-specific aliases for certain operating systems.
+
+if [ x"$os" != x"" ]
+then
+case $os in
+ # First match some system type aliases
+ # that might get confused with valid system types.
+ # -solaris* is a basic system type, with this one exception.
+ -auroraux)
+ os=-auroraux
+ ;;
+ -solaris1 | -solaris1.*)
+ os=`echo $os | sed -e 's|solaris1|sunos4|'`
+ ;;
+ -solaris)
+ os=-solaris2
+ ;;
+ -svr4*)
+ os=-sysv4
+ ;;
+ -unixware*)
+ os=-sysv4.2uw
+ ;;
+ -gnu/linux*)
+ os=`echo $os | sed -e 's|gnu/linux|linux-gnu|'`
+ ;;
+ # First accept the basic system types.
+ # The portable systems comes first.
+ # Each alternative MUST END IN A *, to match a version number.
+ # -sysv* is not here because it comes later, after sysvr4.
+ -gnu* | -bsd* | -mach* | -minix* | -genix* | -ultrix* | -irix* \
+ | -*vms* | -sco* | -esix* | -isc* | -aix* | -cnk* | -sunos | -sunos[34]*\
+ | -hpux* | -unos* | -osf* | -luna* | -dgux* | -auroraux* | -solaris* \
+ | -sym* | -kopensolaris* | -plan9* \
+ | -amigaos* | -amigados* | -msdos* | -newsos* | -unicos* | -aof* \
+ | -aos* | -aros* \
+ | -nindy* | -vxsim* | -vxworks* | -ebmon* | -hms* | -mvs* \
+ | -clix* | -riscos* | -uniplus* | -iris* | -rtu* | -xenix* \
+ | -hiux* | -386bsd* | -knetbsd* | -mirbsd* | -netbsd* \
+ | -bitrig* | -openbsd* | -solidbsd* \
+ | -ekkobsd* | -kfreebsd* | -freebsd* | -riscix* | -lynxos* \
+ | -bosx* | -nextstep* | -cxux* | -aout* | -elf* | -oabi* \
+ | -ptx* | -coff* | -ecoff* | -winnt* | -domain* | -vsta* \
+ | -udi* | -eabi* | -lites* | -ieee* | -go32* | -aux* \
+ | -chorusos* | -chorusrdb* | -cegcc* \
+ | -cygwin* | -msys* | -pe* | -psos* | -moss* | -proelf* | -rtems* \
+ | -mingw32* | -mingw64* | -linux-gnu* | -linux-android* \
+ | -linux-newlib* | -linux-musl* | -linux-uclibc* \
+ | -uxpv* | -beos* | -mpeix* | -udk* \
+ | -interix* | -uwin* | -mks* | -rhapsody* | -darwin* | -opened* \
+ | -openstep* | -oskit* | -conix* | -pw32* | -nonstopux* \
+ | -storm-chaos* | -tops10* | -tenex* | -tops20* | -its* \
+ | -os2* | -vos* | -palmos* | -uclinux* | -nucleus* \
+ | -morphos* | -superux* | -rtmk* | -rtmk-nova* | -windiss* \
+ | -powermax* | -dnix* | -nx6 | -nx7 | -sei* | -dragonfly* \
+ | -skyos* | -haiku* | -rdos* | -toppers* | -drops* | -es*)
+ # Remember, each alternative MUST END IN *, to match a version number.
+ ;;
+ -qnx*)
+ case $basic_machine in
+ x86-* | i*86-*)
+ ;;
+ *)
+ os=-nto$os
+ ;;
+ esac
+ ;;
+ -nto-qnx*)
+ ;;
+ -nto*)
+ os=`echo $os | sed -e 's|nto|nto-qnx|'`
+ ;;
+ -sim | -es1800* | -hms* | -xray | -os68k* | -none* | -v88r* \
+ | -windows* | -osx | -abug | -netware* | -os9* | -beos* | -haiku* \
+ | -macos* | -mpw* | -magic* | -mmixware* | -mon960* | -lnews*)
+ ;;
+ -mac*)
+ os=`echo $os | sed -e 's|mac|macos|'`
+ ;;
+ -linux-dietlibc)
+ os=-linux-dietlibc
+ ;;
+ -linux*)
+ os=`echo $os | sed -e 's|linux|linux-gnu|'`
+ ;;
+ -sunos5*)
+ os=`echo $os | sed -e 's|sunos5|solaris2|'`
+ ;;
+ -sunos6*)
+ os=`echo $os | sed -e 's|sunos6|solaris3|'`
+ ;;
+ -opened*)
+ os=-openedition
+ ;;
+ -os400*)
+ os=-os400
+ ;;
+ -wince*)
+ os=-wince
+ ;;
+ -osfrose*)
+ os=-osfrose
+ ;;
+ -osf*)
+ os=-osf
+ ;;
+ -utek*)
+ os=-bsd
+ ;;
+ -dynix*)
+ os=-bsd
+ ;;
+ -acis*)
+ os=-aos
+ ;;
+ -atheos*)
+ os=-atheos
+ ;;
+ -syllable*)
+ os=-syllable
+ ;;
+ -386bsd)
+ os=-bsd
+ ;;
+ -ctix* | -uts*)
+ os=-sysv
+ ;;
+ -nova*)
+ os=-rtmk-nova
+ ;;
+ -ns2 )
+ os=-nextstep2
+ ;;
+ -nsk*)
+ os=-nsk
+ ;;
+ # Preserve the version number of sinix5.
+ -sinix5.*)
+ os=`echo $os | sed -e 's|sinix|sysv|'`
+ ;;
+ -sinix*)
+ os=-sysv4
+ ;;
+ -tpf*)
+ os=-tpf
+ ;;
+ -triton*)
+ os=-sysv3
+ ;;
+ -oss*)
+ os=-sysv3
+ ;;
+ -svr4)
+ os=-sysv4
+ ;;
+ -svr3)
+ os=-sysv3
+ ;;
+ -sysvr4)
+ os=-sysv4
+ ;;
+ # This must come after -sysvr4.
+ -sysv*)
+ ;;
+ -ose*)
+ os=-ose
+ ;;
+ -es1800*)
+ os=-ose
+ ;;
+ -xenix)
+ os=-xenix
+ ;;
+ -*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*)
+ os=-mint
+ ;;
+ -aros*)
+ os=-aros
+ ;;
+ -zvmoe)
+ os=-zvmoe
+ ;;
+ -dicos*)
+ os=-dicos
+ ;;
+ -nacl*)
+ ;;
+ -none)
+ ;;
+ *)
+ # Get rid of the `-' at the beginning of $os.
+ os=`echo $os | sed 's/[^-]*-//'`
+ echo Invalid configuration \`$1\': system \`$os\' not recognized 1>&2
+ exit 1
+ ;;
+esac
+else
+
+# Here we handle the default operating systems that come with various machines.
+# The value should be what the vendor currently ships out the door with their
+# machine or put another way, the most popular os provided with the machine.
+
+# Note that if you're going to try to match "-MANUFACTURER" here (say,
+# "-sun"), then you have to tell the case statement up towards the top
+# that MANUFACTURER isn't an operating system. Otherwise, code above
+# will signal an error saying that MANUFACTURER isn't an operating
+# system, and we'll never get to this point.
+
+case $basic_machine in
+ score-*)
+ os=-elf
+ ;;
+ spu-*)
+ os=-elf
+ ;;
+ *-acorn)
+ os=-riscix1.2
+ ;;
+ arm*-rebel)
+ os=-linux
+ ;;
+ arm*-semi)
+ os=-aout
+ ;;
+ c4x-* | tic4x-*)
+ os=-coff
+ ;;
+ hexagon-*)
+ os=-elf
+ ;;
+ tic54x-*)
+ os=-coff
+ ;;
+ tic55x-*)
+ os=-coff
+ ;;
+ tic6x-*)
+ os=-coff
+ ;;
+ # This must come before the *-dec entry.
+ pdp10-*)
+ os=-tops20
+ ;;
+ pdp11-*)
+ os=-none
+ ;;
+ *-dec | vax-*)
+ os=-ultrix4.2
+ ;;
+ m68*-apollo)
+ os=-domain
+ ;;
+ i386-sun)
+ os=-sunos4.0.2
+ ;;
+ m68000-sun)
+ os=-sunos3
+ ;;
+ m68*-cisco)
+ os=-aout
+ ;;
+ mep-*)
+ os=-elf
+ ;;
+ mips*-cisco)
+ os=-elf
+ ;;
+ mips*-*)
+ os=-elf
+ ;;
+ or1k-*)
+ os=-elf
+ ;;
+ or32-*)
+ os=-coff
+ ;;
+ *-tti) # must be before sparc entry or we get the wrong os.
+ os=-sysv3
+ ;;
+ sparc-* | *-sun)
+ os=-sunos4.1.1
+ ;;
+ *-be)
+ os=-beos
+ ;;
+ *-haiku)
+ os=-haiku
+ ;;
+ *-ibm)
+ os=-aix
+ ;;
+ *-knuth)
+ os=-mmixware
+ ;;
+ *-wec)
+ os=-proelf
+ ;;
+ *-winbond)
+ os=-proelf
+ ;;
+ *-oki)
+ os=-proelf
+ ;;
+ *-hp)
+ os=-hpux
+ ;;
+ *-hitachi)
+ os=-hiux
+ ;;
+ i860-* | *-att | *-ncr | *-altos | *-motorola | *-convergent)
+ os=-sysv
+ ;;
+ *-cbm)
+ os=-amigaos
+ ;;
+ *-dg)
+ os=-dgux
+ ;;
+ *-dolphin)
+ os=-sysv3
+ ;;
+ m68k-ccur)
+ os=-rtu
+ ;;
+ m88k-omron*)
+ os=-luna
+ ;;
+ *-next )
+ os=-nextstep
+ ;;
+ *-sequent)
+ os=-ptx
+ ;;
+ *-crds)
+ os=-unos
+ ;;
+ *-ns)
+ os=-genix
+ ;;
+ i370-*)
+ os=-mvs
+ ;;
+ *-next)
+ os=-nextstep3
+ ;;
+ *-gould)
+ os=-sysv
+ ;;
+ *-highlevel)
+ os=-bsd
+ ;;
+ *-encore)
+ os=-bsd
+ ;;
+ *-sgi)
+ os=-irix
+ ;;
+ *-siemens)
+ os=-sysv4
+ ;;
+ *-masscomp)
+ os=-rtu
+ ;;
+ f30[01]-fujitsu | f700-fujitsu)
+ os=-uxpv
+ ;;
+ *-rom68k)
+ os=-coff
+ ;;
+ *-*bug)
+ os=-coff
+ ;;
+ *-apple)
+ os=-macos
+ ;;
+ *-atari*)
+ os=-mint
+ ;;
+ *)
+ os=-none
+ ;;
+esac
+fi
+
+# Here we handle the case where we know the os, and the CPU type, but not the
+# manufacturer. We pick the logical manufacturer.
+vendor=unknown
+case $basic_machine in
+ *-unknown)
+ case $os in
+ -riscix*)
+ vendor=acorn
+ ;;
+ -sunos*)
+ vendor=sun
+ ;;
+ -cnk*|-aix*)
+ vendor=ibm
+ ;;
+ -beos*)
+ vendor=be
+ ;;
+ -hpux*)
+ vendor=hp
+ ;;
+ -mpeix*)
+ vendor=hp
+ ;;
+ -hiux*)
+ vendor=hitachi
+ ;;
+ -unos*)
+ vendor=crds
+ ;;
+ -dgux*)
+ vendor=dg
+ ;;
+ -luna*)
+ vendor=omron
+ ;;
+ -genix*)
+ vendor=ns
+ ;;
+ -mvs* | -opened*)
+ vendor=ibm
+ ;;
+ -os400*)
+ vendor=ibm
+ ;;
+ -ptx*)
+ vendor=sequent
+ ;;
+ -tpf*)
+ vendor=ibm
+ ;;
+ -vxsim* | -vxworks* | -windiss*)
+ vendor=wrs
+ ;;
+ -aux*)
+ vendor=apple
+ ;;
+ -hms*)
+ vendor=hitachi
+ ;;
+ -mpw* | -macos*)
+ vendor=apple
+ ;;
+ -*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*)
+ vendor=atari
+ ;;
+ -vos*)
+ vendor=stratus
+ ;;
+ esac
+ basic_machine=`echo $basic_machine | sed "s/unknown/$vendor/"`
+ ;;
+esac
+
+echo $basic_machine$os
+exit
+
+# Local variables:
+# eval: (add-hook 'write-file-hooks 'time-stamp)
+# time-stamp-start: "timestamp='"
+# time-stamp-format: "%:y-%02m-%02d"
+# time-stamp-end: "'"
+# End:
diff --git a/jni/ruby/ext/fiddle/libffi-3.2.1/configure b/jni/ruby/ext/fiddle/libffi-3.2.1/configure
new file mode 100755
index 0000000..c6da467
--- /dev/null
+++ b/jni/ruby/ext/fiddle/libffi-3.2.1/configure
@@ -0,0 +1,21768 @@
+#! /bin/sh
+# Guess values for system-dependent variables and create Makefiles.
+# Generated by GNU Autoconf 2.69 for libffi 3.2.1.
+#
+# Report bugs to <http://github.com/atgreen/libffi/issues>.
+#
+#
+# Copyright (C) 1992-1996, 1998-2012 Free Software Foundation, Inc.
+#
+#
+# This configure script is free software; the Free Software Foundation
+# gives unlimited permission to copy, distribute and modify it.
+## -------------------- ##
+## M4sh Initialization. ##
+## -------------------- ##
+
+# Be more Bourne compatible
+DUALCASE=1; export DUALCASE # for MKS sh
+if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then :
+ emulate sh
+ NULLCMD=:
+ # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which
+ # is contrary to our usage. Disable this feature.
+ alias -g '${1+"$@"}'='"$@"'
+ setopt NO_GLOB_SUBST
+else
+ case `(set -o) 2>/dev/null` in #(
+ *posix*) :
+ set -o posix ;; #(
+ *) :
+ ;;
+esac
+fi
+
+
+as_nl='
+'
+export as_nl
+# Printing a long string crashes Solaris 7 /usr/bin/printf.
+as_echo='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\'
+as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo
+as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo$as_echo
+# Prefer a ksh shell builtin over an external printf program on Solaris,
+# but without wasting forks for bash or zsh.
+if test -z "$BASH_VERSION$ZSH_VERSION" \
+ && (test "X`print -r -- $as_echo`" = "X$as_echo") 2>/dev/null; then
+ as_echo='print -r --'
+ as_echo_n='print -rn --'
+elif (test "X`printf %s $as_echo`" = "X$as_echo") 2>/dev/null; then
+ as_echo='printf %s\n'
+ as_echo_n='printf %s'
+else
+ if test "X`(/usr/ucb/echo -n -n $as_echo) 2>/dev/null`" = "X-n $as_echo"; then
+ as_echo_body='eval /usr/ucb/echo -n "$1$as_nl"'
+ as_echo_n='/usr/ucb/echo -n'
+ else
+ as_echo_body='eval expr "X$1" : "X\\(.*\\)"'
+ as_echo_n_body='eval
+ arg=$1;
+ case $arg in #(
+ *"$as_nl"*)
+ expr "X$arg" : "X\\(.*\\)$as_nl";
+ arg=`expr "X$arg" : ".*$as_nl\\(.*\\)"`;;
+ esac;
+ expr "X$arg" : "X\\(.*\\)" | tr -d "$as_nl"
+ '
+ export as_echo_n_body
+ as_echo_n='sh -c $as_echo_n_body as_echo'
+ fi
+ export as_echo_body
+ as_echo='sh -c $as_echo_body as_echo'
+fi
+
+# The user is always right.
+if test "${PATH_SEPARATOR+set}" != set; then
+ PATH_SEPARATOR=:
+ (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && {
+ (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 ||
+ PATH_SEPARATOR=';'
+ }
+fi
+
+
+# IFS
+# We need space, tab and new line, in precisely that order. Quoting is
+# there to prevent editors from complaining about space-tab.
+# (If _AS_PATH_WALK were called with IFS unset, it would disable word
+# splitting by setting IFS to empty value.)
+IFS=" "" $as_nl"
+
+# Find who we are. Look in the path if we contain no directory separator.
+as_myself=
+case $0 in #((
+ *[\\/]* ) as_myself=$0 ;;
+ *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break
+ done
+IFS=$as_save_IFS
+
+ ;;
+esac
+# We did not find ourselves, most probably we were run as `sh COMMAND'
+# in which case we are not to be found in the path.
+if test "x$as_myself" = x; then
+ as_myself=$0
+fi
+if test ! -f "$as_myself"; then
+ $as_echo "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2
+ exit 1
+fi
+
+# Unset variables that we do not need and which cause bugs (e.g. in
+# pre-3.0 UWIN ksh). But do not cause bugs in bash 2.01; the "|| exit 1"
+# suppresses any "Segmentation fault" message there. '((' could
+# trigger a bug in pdksh 5.2.14.
+for as_var in BASH_ENV ENV MAIL MAILPATH
+do eval test x\${$as_var+set} = xset \
+ && ( (unset $as_var) || exit 1) >/dev/null 2>&1 && unset $as_var || :
+done
+PS1='$ '
+PS2='> '
+PS4='+ '
+
+# NLS nuisances.
+LC_ALL=C
+export LC_ALL
+LANGUAGE=C
+export LANGUAGE
+
+# CDPATH.
+(unset CDPATH) >/dev/null 2>&1 && unset CDPATH
+
+# Use a proper internal environment variable to ensure we don't fall
+ # into an infinite loop, continuously re-executing ourselves.
+ if test x"${_as_can_reexec}" != xno && test "x$CONFIG_SHELL" != x; then
+ _as_can_reexec=no; export _as_can_reexec;
+ # We cannot yet assume a decent shell, so we have to provide a
+# neutralization value for shells without unset; and this also
+# works around shells that cannot unset nonexistent variables.
+# Preserve -v and -x to the replacement shell.
+BASH_ENV=/dev/null
+ENV=/dev/null
+(unset BASH_ENV) >/dev/null 2>&1 && unset BASH_ENV ENV
+case $- in # ((((
+ *v*x* | *x*v* ) as_opts=-vx ;;
+ *v* ) as_opts=-v ;;
+ *x* ) as_opts=-x ;;
+ * ) as_opts= ;;
+esac
+exec $CONFIG_SHELL $as_opts "$as_myself" ${1+"$@"}
+# Admittedly, this is quite paranoid, since all the known shells bail
+# out after a failed `exec'.
+$as_echo "$0: could not re-execute with $CONFIG_SHELL" >&2
+as_fn_exit 255
+ fi
+ # We don't want this to propagate to other subprocesses.
+ { _as_can_reexec=; unset _as_can_reexec;}
+if test "x$CONFIG_SHELL" = x; then
+ as_bourne_compatible="if test -n \"\${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then :
+ emulate sh
+ NULLCMD=:
+ # Pre-4.2 versions of Zsh do word splitting on \${1+\"\$@\"}, which
+ # is contrary to our usage. Disable this feature.
+ alias -g '\${1+\"\$@\"}'='\"\$@\"'
+ setopt NO_GLOB_SUBST
+else
+ case \`(set -o) 2>/dev/null\` in #(
+ *posix*) :
+ set -o posix ;; #(
+ *) :
+ ;;
+esac
+fi
+"
+ as_required="as_fn_return () { (exit \$1); }
+as_fn_success () { as_fn_return 0; }
+as_fn_failure () { as_fn_return 1; }
+as_fn_ret_success () { return 0; }
+as_fn_ret_failure () { return 1; }
+
+exitcode=0
+as_fn_success || { exitcode=1; echo as_fn_success failed.; }
+as_fn_failure && { exitcode=1; echo as_fn_failure succeeded.; }
+as_fn_ret_success || { exitcode=1; echo as_fn_ret_success failed.; }
+as_fn_ret_failure && { exitcode=1; echo as_fn_ret_failure succeeded.; }
+if ( set x; as_fn_ret_success y && test x = \"\$1\" ); then :
+
+else
+ exitcode=1; echo positional parameters were not saved.
+fi
+test x\$exitcode = x0 || exit 1
+test -x / || exit 1"
+ as_suggested=" as_lineno_1=";as_suggested=$as_suggested$LINENO;as_suggested=$as_suggested" as_lineno_1a=\$LINENO
+ as_lineno_2=";as_suggested=$as_suggested$LINENO;as_suggested=$as_suggested" as_lineno_2a=\$LINENO
+ eval 'test \"x\$as_lineno_1'\$as_run'\" != \"x\$as_lineno_2'\$as_run'\" &&
+ test \"x\`expr \$as_lineno_1'\$as_run' + 1\`\" = \"x\$as_lineno_2'\$as_run'\"' || exit 1
+
+ test -n \"\${ZSH_VERSION+set}\${BASH_VERSION+set}\" || (
+ ECHO='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\'
+ ECHO=\$ECHO\$ECHO\$ECHO\$ECHO\$ECHO
+ ECHO=\$ECHO\$ECHO\$ECHO\$ECHO\$ECHO\$ECHO
+ PATH=/empty FPATH=/empty; export PATH FPATH
+ test \"X\`printf %s \$ECHO\`\" = \"X\$ECHO\" \\
+ || test \"X\`print -r -- \$ECHO\`\" = \"X\$ECHO\" ) || exit 1
+test \$(( 1 + 1 )) = 2 || exit 1"
+ if (eval "$as_required") 2>/dev/null; then :
+ as_have_required=yes
+else
+ as_have_required=no
+fi
+ if test x$as_have_required = xyes && (eval "$as_suggested") 2>/dev/null; then :
+
+else
+ as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+as_found=false
+for as_dir in /bin$PATH_SEPARATOR/usr/bin$PATH_SEPARATOR$PATH
+do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ as_found=:
+ case $as_dir in #(
+ /*)
+ for as_base in sh bash ksh sh5; do
+ # Try only shells that exist, to save several forks.
+ as_shell=$as_dir/$as_base
+ if { test -f "$as_shell" || test -f "$as_shell.exe"; } &&
+ { $as_echo "$as_bourne_compatible""$as_required" | as_run=a "$as_shell"; } 2>/dev/null; then :
+ CONFIG_SHELL=$as_shell as_have_required=yes
+ if { $as_echo "$as_bourne_compatible""$as_suggested" | as_run=a "$as_shell"; } 2>/dev/null; then :
+ break 2
+fi
+fi
+ done;;
+ esac
+ as_found=false
+done
+$as_found || { if { test -f "$SHELL" || test -f "$SHELL.exe"; } &&
+ { $as_echo "$as_bourne_compatible""$as_required" | as_run=a "$SHELL"; } 2>/dev/null; then :
+ CONFIG_SHELL=$SHELL as_have_required=yes
+fi; }
+IFS=$as_save_IFS
+
+
+ if test "x$CONFIG_SHELL" != x; then :
+ export CONFIG_SHELL
+ # We cannot yet assume a decent shell, so we have to provide a
+# neutralization value for shells without unset; and this also
+# works around shells that cannot unset nonexistent variables.
+# Preserve -v and -x to the replacement shell.
+BASH_ENV=/dev/null
+ENV=/dev/null
+(unset BASH_ENV) >/dev/null 2>&1 && unset BASH_ENV ENV
+case $- in # ((((
+ *v*x* | *x*v* ) as_opts=-vx ;;
+ *v* ) as_opts=-v ;;
+ *x* ) as_opts=-x ;;
+ * ) as_opts= ;;
+esac
+exec $CONFIG_SHELL $as_opts "$as_myself" ${1+"$@"}
+# Admittedly, this is quite paranoid, since all the known shells bail
+# out after a failed `exec'.
+$as_echo "$0: could not re-execute with $CONFIG_SHELL" >&2
+exit 255
+fi
+
+ if test x$as_have_required = xno; then :
+ $as_echo "$0: This script requires a shell more modern than all"
+ $as_echo "$0: the shells that I found on your system."
+ if test x${ZSH_VERSION+set} = xset ; then
+ $as_echo "$0: In particular, zsh $ZSH_VERSION has bugs and should"
+ $as_echo "$0: be upgraded to zsh 4.3.4 or later."
+ else
+ $as_echo "$0: Please tell bug-autoconf@gnu.org and
+$0: http://github.com/atgreen/libffi/issues about your
+$0: system, including any error possibly output before this
+$0: message. Then install a modern shell, or manually run
+$0: the script under such a shell if you do have one."
+ fi
+ exit 1
+fi
+fi
+fi
+SHELL=${CONFIG_SHELL-/bin/sh}
+export SHELL
+# Unset more variables known to interfere with behavior of common tools.
+CLICOLOR_FORCE= GREP_OPTIONS=
+unset CLICOLOR_FORCE GREP_OPTIONS
+
+## --------------------- ##
+## M4sh Shell Functions. ##
+## --------------------- ##
+# as_fn_unset VAR
+# ---------------
+# Portably unset VAR.
+as_fn_unset ()
+{
+ { eval $1=; unset $1;}
+}
+as_unset=as_fn_unset
+
+# as_fn_set_status STATUS
+# -----------------------
+# Set $? to STATUS, without forking.
+as_fn_set_status ()
+{
+ return $1
+} # as_fn_set_status
+
+# as_fn_exit STATUS
+# -----------------
+# Exit the shell with STATUS, even in a "trap 0" or "set -e" context.
+as_fn_exit ()
+{
+ set +e
+ as_fn_set_status $1
+ exit $1
+} # as_fn_exit
+
+# as_fn_mkdir_p
+# -------------
+# Create "$as_dir" as a directory, including parents if necessary.
+as_fn_mkdir_p ()
+{
+
+ case $as_dir in #(
+ -*) as_dir=./$as_dir;;
+ esac
+ test -d "$as_dir" || eval $as_mkdir_p || {
+ as_dirs=
+ while :; do
+ case $as_dir in #(
+ *\'*) as_qdir=`$as_echo "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #'(
+ *) as_qdir=$as_dir;;
+ esac
+ as_dirs="'$as_qdir' $as_dirs"
+ as_dir=`$as_dirname -- "$as_dir" ||
+$as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
+ X"$as_dir" : 'X\(//\)[^/]' \| \
+ X"$as_dir" : 'X\(//\)$' \| \
+ X"$as_dir" : 'X\(/\)' \| . 2>/dev/null ||
+$as_echo X"$as_dir" |
+ sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{
+ s//\1/
+ q
+ }
+ /^X\(\/\/\)[^/].*/{
+ s//\1/
+ q
+ }
+ /^X\(\/\/\)$/{
+ s//\1/
+ q
+ }
+ /^X\(\/\).*/{
+ s//\1/
+ q
+ }
+ s/.*/./; q'`
+ test -d "$as_dir" && break
+ done
+ test -z "$as_dirs" || eval "mkdir $as_dirs"
+ } || test -d "$as_dir" || as_fn_error $? "cannot create directory $as_dir"
+
+
+} # as_fn_mkdir_p
+
+# as_fn_executable_p FILE
+# -----------------------
+# Test if FILE is an executable regular file.
+as_fn_executable_p ()
+{
+ test -f "$1" && test -x "$1"
+} # as_fn_executable_p
+# as_fn_append VAR VALUE
+# ----------------------
+# Append the text in VALUE to the end of the definition contained in VAR. Take
+# advantage of any shell optimizations that allow amortized linear growth over
+# repeated appends, instead of the typical quadratic growth present in naive
+# implementations.
+if (eval "as_var=1; as_var+=2; test x\$as_var = x12") 2>/dev/null; then :
+ eval 'as_fn_append ()
+ {
+ eval $1+=\$2
+ }'
+else
+ as_fn_append ()
+ {
+ eval $1=\$$1\$2
+ }
+fi # as_fn_append
+
+# as_fn_arith ARG...
+# ------------------
+# Perform arithmetic evaluation on the ARGs, and store the result in the
+# global $as_val. Take advantage of shells that can avoid forks. The arguments
+# must be portable across $(()) and expr.
+if (eval "test \$(( 1 + 1 )) = 2") 2>/dev/null; then :
+ eval 'as_fn_arith ()
+ {
+ as_val=$(( $* ))
+ }'
+else
+ as_fn_arith ()
+ {
+ as_val=`expr "$@" || test $? -eq 1`
+ }
+fi # as_fn_arith
+
+
+# as_fn_error STATUS ERROR [LINENO LOG_FD]
+# ----------------------------------------
+# Output "`basename $0`: error: ERROR" to stderr. If LINENO and LOG_FD are
+# provided, also output the error to LOG_FD, referencing LINENO. Then exit the
+# script with STATUS, using 1 if that was 0.
+as_fn_error ()
+{
+ as_status=$1; test $as_status -eq 0 && as_status=1
+ if test "$4"; then
+ as_lineno=${as_lineno-"$3"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
+ $as_echo "$as_me:${as_lineno-$LINENO}: error: $2" >&$4
+ fi
+ $as_echo "$as_me: error: $2" >&2
+ as_fn_exit $as_status
+} # as_fn_error
+
+if expr a : '\(a\)' >/dev/null 2>&1 &&
+ test "X`expr 00001 : '.*\(...\)'`" = X001; then
+ as_expr=expr
+else
+ as_expr=false
+fi
+
+if (basename -- /) >/dev/null 2>&1 && test "X`basename -- / 2>&1`" = "X/"; then
+ as_basename=basename
+else
+ as_basename=false
+fi
+
+if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then
+ as_dirname=dirname
+else
+ as_dirname=false
+fi
+
+as_me=`$as_basename -- "$0" ||
+$as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \
+ X"$0" : 'X\(//\)$' \| \
+ X"$0" : 'X\(/\)' \| . 2>/dev/null ||
+$as_echo X/"$0" |
+ sed '/^.*\/\([^/][^/]*\)\/*$/{
+ s//\1/
+ q
+ }
+ /^X\/\(\/\/\)$/{
+ s//\1/
+ q
+ }
+ /^X\/\(\/\).*/{
+ s//\1/
+ q
+ }
+ s/.*/./; q'`
+
+# Avoid depending upon Character Ranges.
+as_cr_letters='abcdefghijklmnopqrstuvwxyz'
+as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ'
+as_cr_Letters=$as_cr_letters$as_cr_LETTERS
+as_cr_digits='0123456789'
+as_cr_alnum=$as_cr_Letters$as_cr_digits
+
+
+ as_lineno_1=$LINENO as_lineno_1a=$LINENO
+ as_lineno_2=$LINENO as_lineno_2a=$LINENO
+ eval 'test "x$as_lineno_1'$as_run'" != "x$as_lineno_2'$as_run'" &&
+ test "x`expr $as_lineno_1'$as_run' + 1`" = "x$as_lineno_2'$as_run'"' || {
+ # Blame Lee E. McMahon (1931-1989) for sed's syntax. :-)
+ sed -n '
+ p
+ /[$]LINENO/=
+ ' <$as_myself |
+ sed '
+ s/[$]LINENO.*/&-/
+ t lineno
+ b
+ :lineno
+ N
+ :loop
+ s/[$]LINENO\([^'$as_cr_alnum'_].*\n\)\(.*\)/\2\1\2/
+ t loop
+ s/-\n.*//
+ ' >$as_me.lineno &&
+ chmod +x "$as_me.lineno" ||
+ { $as_echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2; as_fn_exit 1; }
+
+ # If we had to re-execute with $CONFIG_SHELL, we're ensured to have
+ # already done that, so ensure we don't try to do so again and fall
+ # in an infinite loop. This has already happened in practice.
+ _as_can_reexec=no; export _as_can_reexec
+ # Don't try to exec as it changes $[0], causing all sort of problems
+ # (the dirname of $[0] is not the place where we might find the
+ # original and so on. Autoconf is especially sensitive to this).
+ . "./$as_me.lineno"
+ # Exit status is that of the last command.
+ exit
+}
+
+ECHO_C= ECHO_N= ECHO_T=
+case `echo -n x` in #(((((
+-n*)
+ case `echo 'xy\c'` in
+ *c*) ECHO_T=' ';; # ECHO_T is single tab character.
+ xy) ECHO_C='\c';;
+ *) echo `echo ksh88 bug on AIX 6.1` > /dev/null
+ ECHO_T=' ';;
+ esac;;
+*)
+ ECHO_N='-n';;
+esac
+
+rm -f conf$$ conf$$.exe conf$$.file
+if test -d conf$$.dir; then
+ rm -f conf$$.dir/conf$$.file
+else
+ rm -f conf$$.dir
+ mkdir conf$$.dir 2>/dev/null
+fi
+if (echo >conf$$.file) 2>/dev/null; then
+ if ln -s conf$$.file conf$$ 2>/dev/null; then
+ as_ln_s='ln -s'
+ # ... but there are two gotchas:
+ # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail.
+ # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable.
+ # In both cases, we have to default to `cp -pR'.
+ ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe ||
+ as_ln_s='cp -pR'
+ elif ln conf$$.file conf$$ 2>/dev/null; then
+ as_ln_s=ln
+ else
+ as_ln_s='cp -pR'
+ fi
+else
+ as_ln_s='cp -pR'
+fi
+rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file
+rmdir conf$$.dir 2>/dev/null
+
+if mkdir -p . 2>/dev/null; then
+ as_mkdir_p='mkdir -p "$as_dir"'
+else
+ test -d ./-p && rmdir ./-p
+ as_mkdir_p=false
+fi
+
+as_test_x='test -x'
+as_executable_p=as_fn_executable_p
+
+# Sed expression to map a string onto a valid CPP name.
+as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'"
+
+# Sed expression to map a string onto a valid variable name.
+as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'"
+
+SHELL=${CONFIG_SHELL-/bin/sh}
+
+
+test -n "$DJDIR" || exec 7<&0 </dev/null
+exec 6>&1
+
+# Name of the host.
+# hostname on some systems (SVR3.2, old GNU/Linux) returns a bogus exit status,
+# so uname gets run too.
+ac_hostname=`(hostname || uname -n) 2>/dev/null | sed 1q`
+
+#
+# Initializations.
+#
+ac_default_prefix=/usr/local
+ac_clean_files=
+ac_config_libobj_dir=.
+LIBOBJS=
+cross_compiling=no
+subdirs=
+MFLAGS=
+MAKEFLAGS=
+
+# Identity of this package.
+PACKAGE_NAME='libffi'
+PACKAGE_TARNAME='libffi'
+PACKAGE_VERSION='3.2.1'
+PACKAGE_STRING='libffi 3.2.1'
+PACKAGE_BUGREPORT='http://github.com/atgreen/libffi/issues'
+PACKAGE_URL=''
+
+# Factoring default headers for most tests.
+ac_includes_default="\
+#include <stdio.h>
+#ifdef HAVE_SYS_TYPES_H
+# include <sys/types.h>
+#endif
+#ifdef HAVE_SYS_STAT_H
+# include <sys/stat.h>
+#endif
+#ifdef STDC_HEADERS
+# include <stdlib.h>
+# include <stddef.h>
+#else
+# ifdef HAVE_STDLIB_H
+# include <stdlib.h>
+# endif
+#endif
+#ifdef HAVE_STRING_H
+# if !defined STDC_HEADERS && defined HAVE_MEMORY_H
+# include <memory.h>
+# endif
+# include <string.h>
+#endif
+#ifdef HAVE_STRINGS_H
+# include <strings.h>
+#endif
+#ifdef HAVE_INTTYPES_H
+# include <inttypes.h>
+#endif
+#ifdef HAVE_STDINT_H
+# include <stdint.h>
+#endif
+#ifdef HAVE_UNISTD_H
+# include <unistd.h>
+#endif"
+
+ac_subst_vars='am__EXEEXT_FALSE
+am__EXEEXT_TRUE
+LTLIBOBJS
+LIBOBJS
+toolexeclibdir
+toolexecdir
+FFI_DEBUG_FALSE
+FFI_DEBUG_TRUE
+TARGETDIR
+TARGET
+FFI_EXEC_TRAMPOLINE_TABLE
+FFI_EXEC_TRAMPOLINE_TABLE_FALSE
+FFI_EXEC_TRAMPOLINE_TABLE_TRUE
+sys_symbol_underscore
+HAVE_LONG_DOUBLE_VARIANT
+HAVE_LONG_DOUBLE
+ALLOCA
+XTENSA_FALSE
+XTENSA_TRUE
+VAX_FALSE
+VAX_TRUE
+TILE_FALSE
+TILE_TRUE
+PA64_HPUX_FALSE
+PA64_HPUX_TRUE
+PA_HPUX_FALSE
+PA_HPUX_TRUE
+PA_LINUX_FALSE
+PA_LINUX_TRUE
+SH64_FALSE
+SH64_TRUE
+SH_FALSE
+SH_TRUE
+X86_64_FALSE
+X86_64_TRUE
+S390_FALSE
+S390_TRUE
+FRV_FALSE
+FRV_TRUE
+LIBFFI_CRIS_FALSE
+LIBFFI_CRIS_TRUE
+AVR32_FALSE
+AVR32_TRUE
+ARM_FALSE
+ARM_TRUE
+ARC_FALSE
+ARC_TRUE
+AARCH64_FALSE
+AARCH64_TRUE
+POWERPC_FREEBSD_FALSE
+POWERPC_FREEBSD_TRUE
+POWERPC_DARWIN_FALSE
+POWERPC_DARWIN_TRUE
+POWERPC_AIX_FALSE
+POWERPC_AIX_TRUE
+POWERPC_FALSE
+POWERPC_TRUE
+OR1K_FALSE
+OR1K_TRUE
+NIOS2_FALSE
+NIOS2_TRUE
+MOXIE_FALSE
+MOXIE_TRUE
+METAG_FALSE
+METAG_TRUE
+MICROBLAZE_FALSE
+MICROBLAZE_TRUE
+M88K_FALSE
+M88K_TRUE
+M68K_FALSE
+M68K_TRUE
+M32R_FALSE
+M32R_TRUE
+IA64_FALSE
+IA64_TRUE
+ALPHA_FALSE
+ALPHA_TRUE
+X86_DARWIN64_FALSE
+X86_DARWIN64_TRUE
+X86_DARWIN32_FALSE
+X86_DARWIN32_TRUE
+X86_DARWIN_FALSE
+X86_DARWIN_TRUE
+X86_WIN64_FALSE
+X86_WIN64_TRUE
+X86_WIN32_FALSE
+X86_WIN32_TRUE
+X86_FREEBSD_FALSE
+X86_FREEBSD_TRUE
+X86_FALSE
+X86_TRUE
+SPARC_FALSE
+SPARC_TRUE
+BFIN_FALSE
+BFIN_TRUE
+MIPS_FALSE
+MIPS_TRUE
+AM_LTLDFLAGS
+AM_RUNTESTFLAGS
+TESTSUBDIR_FALSE
+TESTSUBDIR_TRUE
+MAINT
+MAINTAINER_MODE_FALSE
+MAINTAINER_MODE_TRUE
+PRTDIAG
+CXXCPP
+CPP
+OTOOL64
+OTOOL
+LIPO
+NMEDIT
+DSYMUTIL
+MANIFEST_TOOL
+RANLIB
+ac_ct_AR
+AR
+DLLTOOL
+OBJDUMP
+LN_S
+NM
+ac_ct_DUMPBIN
+DUMPBIN
+LD
+FGREP
+EGREP
+GREP
+SED
+LIBTOOL
+am__fastdepCCAS_FALSE
+am__fastdepCCAS_TRUE
+CCASDEPMODE
+CCASFLAGS
+CCAS
+am__fastdepCXX_FALSE
+am__fastdepCXX_TRUE
+CXXDEPMODE
+ac_ct_CXX
+CXXFLAGS
+CXX
+am__fastdepCC_FALSE
+am__fastdepCC_TRUE
+CCDEPMODE
+am__nodep
+AMDEPBACKSLASH
+AMDEP_FALSE
+AMDEP_TRUE
+am__quote
+am__include
+DEPDIR
+OBJEXT
+EXEEXT
+ac_ct_CC
+CPPFLAGS
+LDFLAGS
+CFLAGS
+CC
+AM_BACKSLASH
+AM_DEFAULT_VERBOSITY
+AM_DEFAULT_V
+AM_V
+am__untar
+am__tar
+AMTAR
+am__leading_dot
+SET_MAKE
+AWK
+mkdir_p
+MKDIR_P
+INSTALL_STRIP_PROGRAM
+STRIP
+install_sh
+MAKEINFO
+AUTOHEADER
+AUTOMAKE
+AUTOCONF
+ACLOCAL
+VERSION
+PACKAGE
+CYGPATH_W
+am__isrc
+INSTALL_DATA
+INSTALL_SCRIPT
+INSTALL_PROGRAM
+ax_enable_builddir_sed
+target_os
+target_vendor
+target_cpu
+target
+host_os
+host_vendor
+host_cpu
+host
+build_os
+build_vendor
+build_cpu
+build
+target_alias
+host_alias
+build_alias
+LIBS
+ECHO_T
+ECHO_N
+ECHO_C
+DEFS
+mandir
+localedir
+libdir
+psdir
+pdfdir
+dvidir
+htmldir
+infodir
+docdir
+oldincludedir
+includedir
+localstatedir
+sharedstatedir
+sysconfdir
+datadir
+datarootdir
+libexecdir
+sbindir
+bindir
+program_transform_name
+prefix
+exec_prefix
+PACKAGE_URL
+PACKAGE_BUGREPORT
+PACKAGE_STRING
+PACKAGE_VERSION
+PACKAGE_TARNAME
+PACKAGE_NAME
+PATH_SEPARATOR
+SHELL'
+ac_subst_files=''
+ac_user_opts='
+enable_option_checking
+enable_builddir
+enable_silent_rules
+enable_dependency_tracking
+enable_shared
+enable_static
+with_pic
+enable_fast_install
+with_gnu_ld
+with_sysroot
+enable_libtool_lock
+enable_portable_binary
+with_gcc_arch
+enable_maintainer_mode
+enable_pax_emutramp
+enable_debug
+enable_structs
+enable_raw_api
+enable_purify_safety
+'
+ ac_precious_vars='build_alias
+host_alias
+target_alias
+CCAS
+CCASFLAGS
+CPP
+CPPFLAGS
+CXXCPP'
+
+
+# Initialize some variables set by options.
+ac_init_help=
+ac_init_version=false
+ac_unrecognized_opts=
+ac_unrecognized_sep=
+# The variables have the same names as the options, with
+# dashes changed to underlines.
+cache_file=/dev/null
+exec_prefix=NONE
+no_create=
+no_recursion=
+prefix=NONE
+program_prefix=NONE
+program_suffix=NONE
+program_transform_name=s,x,x,
+silent=
+site=
+srcdir=
+verbose=
+x_includes=NONE
+x_libraries=NONE
+
+# Installation directory options.
+# These are left unexpanded so users can "make install exec_prefix=/foo"
+# and all the variables that are supposed to be based on exec_prefix
+# by default will actually change.
+# Use braces instead of parens because sh, perl, etc. also accept them.
+# (The list follows the same order as the GNU Coding Standards.)
+bindir='${exec_prefix}/bin'
+sbindir='${exec_prefix}/sbin'
+libexecdir='${exec_prefix}/libexec'
+datarootdir='${prefix}/share'
+datadir='${datarootdir}'
+sysconfdir='${prefix}/etc'
+sharedstatedir='${prefix}/com'
+localstatedir='${prefix}/var'
+includedir='${prefix}/include'
+oldincludedir='/usr/include'
+docdir='${datarootdir}/doc/${PACKAGE_TARNAME}'
+infodir='${datarootdir}/info'
+htmldir='${docdir}'
+dvidir='${docdir}'
+pdfdir='${docdir}'
+psdir='${docdir}'
+libdir='${exec_prefix}/lib'
+localedir='${datarootdir}/locale'
+mandir='${datarootdir}/man'
+
+ac_prev=
+ac_dashdash=
+for ac_option
+do
+ # If the previous option needs an argument, assign it.
+ if test -n "$ac_prev"; then
+ eval $ac_prev=\$ac_option
+ ac_prev=
+ continue
+ fi
+
+ case $ac_option in
+ *=?*) ac_optarg=`expr "X$ac_option" : '[^=]*=\(.*\)'` ;;
+ *=) ac_optarg= ;;
+ *) ac_optarg=yes ;;
+ esac
+
+ # Accept the important Cygnus configure options, so we can diagnose typos.
+
+ case $ac_dashdash$ac_option in
+ --)
+ ac_dashdash=yes ;;
+
+ -bindir | --bindir | --bindi | --bind | --bin | --bi)
+ ac_prev=bindir ;;
+ -bindir=* | --bindir=* | --bindi=* | --bind=* | --bin=* | --bi=*)
+ bindir=$ac_optarg ;;
+
+ -build | --build | --buil | --bui | --bu)
+ ac_prev=build_alias ;;
+ -build=* | --build=* | --buil=* | --bui=* | --bu=*)
+ build_alias=$ac_optarg ;;
+
+ -cache-file | --cache-file | --cache-fil | --cache-fi \
+ | --cache-f | --cache- | --cache | --cach | --cac | --ca | --c)
+ ac_prev=cache_file ;;
+ -cache-file=* | --cache-file=* | --cache-fil=* | --cache-fi=* \
+ | --cache-f=* | --cache-=* | --cache=* | --cach=* | --cac=* | --ca=* | --c=*)
+ cache_file=$ac_optarg ;;
+
+ --config-cache | -C)
+ cache_file=config.cache ;;
+
+ -datadir | --datadir | --datadi | --datad)
+ ac_prev=datadir ;;
+ -datadir=* | --datadir=* | --datadi=* | --datad=*)
+ datadir=$ac_optarg ;;
+
+ -datarootdir | --datarootdir | --datarootdi | --datarootd | --dataroot \
+ | --dataroo | --dataro | --datar)
+ ac_prev=datarootdir ;;
+ -datarootdir=* | --datarootdir=* | --datarootdi=* | --datarootd=* \
+ | --dataroot=* | --dataroo=* | --dataro=* | --datar=*)
+ datarootdir=$ac_optarg ;;
+
+ -disable-* | --disable-*)
+ ac_useropt=`expr "x$ac_option" : 'x-*disable-\(.*\)'`
+ # Reject names that are not valid shell variable names.
+ expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null &&
+ as_fn_error $? "invalid feature name: $ac_useropt"
+ ac_useropt_orig=$ac_useropt
+ ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'`
+ case $ac_user_opts in
+ *"
+"enable_$ac_useropt"
+"*) ;;
+ *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--disable-$ac_useropt_orig"
+ ac_unrecognized_sep=', ';;
+ esac
+ eval enable_$ac_useropt=no ;;
+
+ -docdir | --docdir | --docdi | --doc | --do)
+ ac_prev=docdir ;;
+ -docdir=* | --docdir=* | --docdi=* | --doc=* | --do=*)
+ docdir=$ac_optarg ;;
+
+ -dvidir | --dvidir | --dvidi | --dvid | --dvi | --dv)
+ ac_prev=dvidir ;;
+ -dvidir=* | --dvidir=* | --dvidi=* | --dvid=* | --dvi=* | --dv=*)
+ dvidir=$ac_optarg ;;
+
+ -enable-* | --enable-*)
+ ac_useropt=`expr "x$ac_option" : 'x-*enable-\([^=]*\)'`
+ # Reject names that are not valid shell variable names.
+ expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null &&
+ as_fn_error $? "invalid feature name: $ac_useropt"
+ ac_useropt_orig=$ac_useropt
+ ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'`
+ case $ac_user_opts in
+ *"
+"enable_$ac_useropt"
+"*) ;;
+ *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--enable-$ac_useropt_orig"
+ ac_unrecognized_sep=', ';;
+ esac
+ eval enable_$ac_useropt=\$ac_optarg ;;
+
+ -exec-prefix | --exec_prefix | --exec-prefix | --exec-prefi \
+ | --exec-pref | --exec-pre | --exec-pr | --exec-p | --exec- \
+ | --exec | --exe | --ex)
+ ac_prev=exec_prefix ;;
+ -exec-prefix=* | --exec_prefix=* | --exec-prefix=* | --exec-prefi=* \
+ | --exec-pref=* | --exec-pre=* | --exec-pr=* | --exec-p=* | --exec-=* \
+ | --exec=* | --exe=* | --ex=*)
+ exec_prefix=$ac_optarg ;;
+
+ -gas | --gas | --ga | --g)
+ # Obsolete; use --with-gas.
+ with_gas=yes ;;
+
+ -help | --help | --hel | --he | -h)
+ ac_init_help=long ;;
+ -help=r* | --help=r* | --hel=r* | --he=r* | -hr*)
+ ac_init_help=recursive ;;
+ -help=s* | --help=s* | --hel=s* | --he=s* | -hs*)
+ ac_init_help=short ;;
+
+ -host | --host | --hos | --ho)
+ ac_prev=host_alias ;;
+ -host=* | --host=* | --hos=* | --ho=*)
+ host_alias=$ac_optarg ;;
+
+ -htmldir | --htmldir | --htmldi | --htmld | --html | --htm | --ht)
+ ac_prev=htmldir ;;
+ -htmldir=* | --htmldir=* | --htmldi=* | --htmld=* | --html=* | --htm=* \
+ | --ht=*)
+ htmldir=$ac_optarg ;;
+
+ -includedir | --includedir | --includedi | --included | --include \
+ | --includ | --inclu | --incl | --inc)
+ ac_prev=includedir ;;
+ -includedir=* | --includedir=* | --includedi=* | --included=* | --include=* \
+ | --includ=* | --inclu=* | --incl=* | --inc=*)
+ includedir=$ac_optarg ;;
+
+ -infodir | --infodir | --infodi | --infod | --info | --inf)
+ ac_prev=infodir ;;
+ -infodir=* | --infodir=* | --infodi=* | --infod=* | --info=* | --inf=*)
+ infodir=$ac_optarg ;;
+
+ -libdir | --libdir | --libdi | --libd)
+ ac_prev=libdir ;;
+ -libdir=* | --libdir=* | --libdi=* | --libd=*)
+ libdir=$ac_optarg ;;
+
+ -libexecdir | --libexecdir | --libexecdi | --libexecd | --libexec \
+ | --libexe | --libex | --libe)
+ ac_prev=libexecdir ;;
+ -libexecdir=* | --libexecdir=* | --libexecdi=* | --libexecd=* | --libexec=* \
+ | --libexe=* | --libex=* | --libe=*)
+ libexecdir=$ac_optarg ;;
+
+ -localedir | --localedir | --localedi | --localed | --locale)
+ ac_prev=localedir ;;
+ -localedir=* | --localedir=* | --localedi=* | --localed=* | --locale=*)
+ localedir=$ac_optarg ;;
+
+ -localstatedir | --localstatedir | --localstatedi | --localstated \
+ | --localstate | --localstat | --localsta | --localst | --locals)
+ ac_prev=localstatedir ;;
+ -localstatedir=* | --localstatedir=* | --localstatedi=* | --localstated=* \
+ | --localstate=* | --localstat=* | --localsta=* | --localst=* | --locals=*)
+ localstatedir=$ac_optarg ;;
+
+ -mandir | --mandir | --mandi | --mand | --man | --ma | --m)
+ ac_prev=mandir ;;
+ -mandir=* | --mandir=* | --mandi=* | --mand=* | --man=* | --ma=* | --m=*)
+ mandir=$ac_optarg ;;
+
+ -nfp | --nfp | --nf)
+ # Obsolete; use --without-fp.
+ with_fp=no ;;
+
+ -no-create | --no-create | --no-creat | --no-crea | --no-cre \
+ | --no-cr | --no-c | -n)
+ no_create=yes ;;
+
+ -no-recursion | --no-recursion | --no-recursio | --no-recursi \
+ | --no-recurs | --no-recur | --no-recu | --no-rec | --no-re | --no-r)
+ no_recursion=yes ;;
+
+ -oldincludedir | --oldincludedir | --oldincludedi | --oldincluded \
+ | --oldinclude | --oldinclud | --oldinclu | --oldincl | --oldinc \
+ | --oldin | --oldi | --old | --ol | --o)
+ ac_prev=oldincludedir ;;
+ -oldincludedir=* | --oldincludedir=* | --oldincludedi=* | --oldincluded=* \
+ | --oldinclude=* | --oldinclud=* | --oldinclu=* | --oldincl=* | --oldinc=* \
+ | --oldin=* | --oldi=* | --old=* | --ol=* | --o=*)
+ oldincludedir=$ac_optarg ;;
+
+ -prefix | --prefix | --prefi | --pref | --pre | --pr | --p)
+ ac_prev=prefix ;;
+ -prefix=* | --prefix=* | --prefi=* | --pref=* | --pre=* | --pr=* | --p=*)
+ prefix=$ac_optarg ;;
+
+ -program-prefix | --program-prefix | --program-prefi | --program-pref \
+ | --program-pre | --program-pr | --program-p)
+ ac_prev=program_prefix ;;
+ -program-prefix=* | --program-prefix=* | --program-prefi=* \
+ | --program-pref=* | --program-pre=* | --program-pr=* | --program-p=*)
+ program_prefix=$ac_optarg ;;
+
+ -program-suffix | --program-suffix | --program-suffi | --program-suff \
+ | --program-suf | --program-su | --program-s)
+ ac_prev=program_suffix ;;
+ -program-suffix=* | --program-suffix=* | --program-suffi=* \
+ | --program-suff=* | --program-suf=* | --program-su=* | --program-s=*)
+ program_suffix=$ac_optarg ;;
+
+ -program-transform-name | --program-transform-name \
+ | --program-transform-nam | --program-transform-na \
+ | --program-transform-n | --program-transform- \
+ | --program-transform | --program-transfor \
+ | --program-transfo | --program-transf \
+ | --program-trans | --program-tran \
+ | --progr-tra | --program-tr | --program-t)
+ ac_prev=program_transform_name ;;
+ -program-transform-name=* | --program-transform-name=* \
+ | --program-transform-nam=* | --program-transform-na=* \
+ | --program-transform-n=* | --program-transform-=* \
+ | --program-transform=* | --program-transfor=* \
+ | --program-transfo=* | --program-transf=* \
+ | --program-trans=* | --program-tran=* \
+ | --progr-tra=* | --program-tr=* | --program-t=*)
+ program_transform_name=$ac_optarg ;;
+
+ -pdfdir | --pdfdir | --pdfdi | --pdfd | --pdf | --pd)
+ ac_prev=pdfdir ;;
+ -pdfdir=* | --pdfdir=* | --pdfdi=* | --pdfd=* | --pdf=* | --pd=*)
+ pdfdir=$ac_optarg ;;
+
+ -psdir | --psdir | --psdi | --psd | --ps)
+ ac_prev=psdir ;;
+ -psdir=* | --psdir=* | --psdi=* | --psd=* | --ps=*)
+ psdir=$ac_optarg ;;
+
+ -q | -quiet | --quiet | --quie | --qui | --qu | --q \
+ | -silent | --silent | --silen | --sile | --sil)
+ silent=yes ;;
+
+ -sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb)
+ ac_prev=sbindir ;;
+ -sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \
+ | --sbi=* | --sb=*)
+ sbindir=$ac_optarg ;;
+
+ -sharedstatedir | --sharedstatedir | --sharedstatedi \
+ | --sharedstated | --sharedstate | --sharedstat | --sharedsta \
+ | --sharedst | --shareds | --shared | --share | --shar \
+ | --sha | --sh)
+ ac_prev=sharedstatedir ;;
+ -sharedstatedir=* | --sharedstatedir=* | --sharedstatedi=* \
+ | --sharedstated=* | --sharedstate=* | --sharedstat=* | --sharedsta=* \
+ | --sharedst=* | --shareds=* | --shared=* | --share=* | --shar=* \
+ | --sha=* | --sh=*)
+ sharedstatedir=$ac_optarg ;;
+
+ -site | --site | --sit)
+ ac_prev=site ;;
+ -site=* | --site=* | --sit=*)
+ site=$ac_optarg ;;
+
+ -srcdir | --srcdir | --srcdi | --srcd | --src | --sr)
+ ac_prev=srcdir ;;
+ -srcdir=* | --srcdir=* | --srcdi=* | --srcd=* | --src=* | --sr=*)
+ srcdir=$ac_optarg ;;
+
+ -sysconfdir | --sysconfdir | --sysconfdi | --sysconfd | --sysconf \
+ | --syscon | --sysco | --sysc | --sys | --sy)
+ ac_prev=sysconfdir ;;
+ -sysconfdir=* | --sysconfdir=* | --sysconfdi=* | --sysconfd=* | --sysconf=* \
+ | --syscon=* | --sysco=* | --sysc=* | --sys=* | --sy=*)
+ sysconfdir=$ac_optarg ;;
+
+ -target | --target | --targe | --targ | --tar | --ta | --t)
+ ac_prev=target_alias ;;
+ -target=* | --target=* | --targe=* | --targ=* | --tar=* | --ta=* | --t=*)
+ target_alias=$ac_optarg ;;
+
+ -v | -verbose | --verbose | --verbos | --verbo | --verb)
+ verbose=yes ;;
+
+ -version | --version | --versio | --versi | --vers | -V)
+ ac_init_version=: ;;
+
+ -with-* | --with-*)
+ ac_useropt=`expr "x$ac_option" : 'x-*with-\([^=]*\)'`
+ # Reject names that are not valid shell variable names.
+ expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null &&
+ as_fn_error $? "invalid package name: $ac_useropt"
+ ac_useropt_orig=$ac_useropt
+ ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'`
+ case $ac_user_opts in
+ *"
+"with_$ac_useropt"
+"*) ;;
+ *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--with-$ac_useropt_orig"
+ ac_unrecognized_sep=', ';;
+ esac
+ eval with_$ac_useropt=\$ac_optarg ;;
+
+ -without-* | --without-*)
+ ac_useropt=`expr "x$ac_option" : 'x-*without-\(.*\)'`
+ # Reject names that are not valid shell variable names.
+ expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null &&
+ as_fn_error $? "invalid package name: $ac_useropt"
+ ac_useropt_orig=$ac_useropt
+ ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'`
+ case $ac_user_opts in
+ *"
+"with_$ac_useropt"
+"*) ;;
+ *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--without-$ac_useropt_orig"
+ ac_unrecognized_sep=', ';;
+ esac
+ eval with_$ac_useropt=no ;;
+
+ --x)
+ # Obsolete; use --with-x.
+ with_x=yes ;;
+
+ -x-includes | --x-includes | --x-include | --x-includ | --x-inclu \
+ | --x-incl | --x-inc | --x-in | --x-i)
+ ac_prev=x_includes ;;
+ -x-includes=* | --x-includes=* | --x-include=* | --x-includ=* | --x-inclu=* \
+ | --x-incl=* | --x-inc=* | --x-in=* | --x-i=*)
+ x_includes=$ac_optarg ;;
+
+ -x-libraries | --x-libraries | --x-librarie | --x-librari \
+ | --x-librar | --x-libra | --x-libr | --x-lib | --x-li | --x-l)
+ ac_prev=x_libraries ;;
+ -x-libraries=* | --x-libraries=* | --x-librarie=* | --x-librari=* \
+ | --x-librar=* | --x-libra=* | --x-libr=* | --x-lib=* | --x-li=* | --x-l=*)
+ x_libraries=$ac_optarg ;;
+
+ -*) as_fn_error $? "unrecognized option: \`$ac_option'
+Try \`$0 --help' for more information"
+ ;;
+
+ *=*)
+ ac_envvar=`expr "x$ac_option" : 'x\([^=]*\)='`
+ # Reject names that are not valid shell variable names.
+ case $ac_envvar in #(
+ '' | [0-9]* | *[!_$as_cr_alnum]* )
+ as_fn_error $? "invalid variable name: \`$ac_envvar'" ;;
+ esac
+ eval $ac_envvar=\$ac_optarg
+ export $ac_envvar ;;
+
+ *)
+ # FIXME: should be removed in autoconf 3.0.
+ $as_echo "$as_me: WARNING: you should use --build, --host, --target" >&2
+ expr "x$ac_option" : ".*[^-._$as_cr_alnum]" >/dev/null &&
+ $as_echo "$as_me: WARNING: invalid host type: $ac_option" >&2
+ : "${build_alias=$ac_option} ${host_alias=$ac_option} ${target_alias=$ac_option}"
+ ;;
+
+ esac
+done
+
+if test -n "$ac_prev"; then
+ ac_option=--`echo $ac_prev | sed 's/_/-/g'`
+ as_fn_error $? "missing argument to $ac_option"
+fi
+
+if test -n "$ac_unrecognized_opts"; then
+ case $enable_option_checking in
+ no) ;;
+ fatal) as_fn_error $? "unrecognized options: $ac_unrecognized_opts" ;;
+ *) $as_echo "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2 ;;
+ esac
+fi
+
+# Check all directory arguments for consistency.
+for ac_var in exec_prefix prefix bindir sbindir libexecdir datarootdir \
+ datadir sysconfdir sharedstatedir localstatedir includedir \
+ oldincludedir docdir infodir htmldir dvidir pdfdir psdir \
+ libdir localedir mandir
+do
+ eval ac_val=\$$ac_var
+ # Remove trailing slashes.
+ case $ac_val in
+ */ )
+ ac_val=`expr "X$ac_val" : 'X\(.*[^/]\)' \| "X$ac_val" : 'X\(.*\)'`
+ eval $ac_var=\$ac_val;;
+ esac
+ # Be sure to have absolute directory names.
+ case $ac_val in
+ [\\/$]* | ?:[\\/]* ) continue;;
+ NONE | '' ) case $ac_var in *prefix ) continue;; esac;;
+ esac
+ as_fn_error $? "expected an absolute directory name for --$ac_var: $ac_val"
+done
+
+# There might be people who depend on the old broken behavior: `$host'
+# used to hold the argument of --host etc.
+# FIXME: To remove some day.
+build=$build_alias
+host=$host_alias
+target=$target_alias
+
+# FIXME: To remove some day.
+if test "x$host_alias" != x; then
+ if test "x$build_alias" = x; then
+ cross_compiling=maybe
+ elif test "x$build_alias" != "x$host_alias"; then
+ cross_compiling=yes
+ fi
+fi
+
+ac_tool_prefix=
+test -n "$host_alias" && ac_tool_prefix=$host_alias-
+
+test "$silent" = yes && exec 6>/dev/null
+
+
+ac_pwd=`pwd` && test -n "$ac_pwd" &&
+ac_ls_di=`ls -di .` &&
+ac_pwd_ls_di=`cd "$ac_pwd" && ls -di .` ||
+ as_fn_error $? "working directory cannot be determined"
+test "X$ac_ls_di" = "X$ac_pwd_ls_di" ||
+ as_fn_error $? "pwd does not report name of working directory"
+
+
+# Find the source files, if location was not specified.
+if test -z "$srcdir"; then
+ ac_srcdir_defaulted=yes
+ # Try the directory containing this script, then the parent directory.
+ ac_confdir=`$as_dirname -- "$as_myself" ||
+$as_expr X"$as_myself" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
+ X"$as_myself" : 'X\(//\)[^/]' \| \
+ X"$as_myself" : 'X\(//\)$' \| \
+ X"$as_myself" : 'X\(/\)' \| . 2>/dev/null ||
+$as_echo X"$as_myself" |
+ sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{
+ s//\1/
+ q
+ }
+ /^X\(\/\/\)[^/].*/{
+ s//\1/
+ q
+ }
+ /^X\(\/\/\)$/{
+ s//\1/
+ q
+ }
+ /^X\(\/\).*/{
+ s//\1/
+ q
+ }
+ s/.*/./; q'`
+ srcdir=$ac_confdir
+ if test ! -r "$srcdir/$ac_unique_file"; then
+ srcdir=..
+ fi
+else
+ ac_srcdir_defaulted=no
+fi
+if test ! -r "$srcdir/$ac_unique_file"; then
+ test "$ac_srcdir_defaulted" = yes && srcdir="$ac_confdir or .."
+ as_fn_error $? "cannot find sources ($ac_unique_file) in $srcdir"
+fi
+ac_msg="sources are in $srcdir, but \`cd $srcdir' does not work"
+ac_abs_confdir=`(
+ cd "$srcdir" && test -r "./$ac_unique_file" || as_fn_error $? "$ac_msg"
+ pwd)`
+# When building in place, set srcdir=.
+if test "$ac_abs_confdir" = "$ac_pwd"; then
+ srcdir=.
+fi
+# Remove unnecessary trailing slashes from srcdir.
+# Double slashes in file names in object file debugging info
+# mess up M-x gdb in Emacs.
+case $srcdir in
+*/) srcdir=`expr "X$srcdir" : 'X\(.*[^/]\)' \| "X$srcdir" : 'X\(.*\)'`;;
+esac
+for ac_var in $ac_precious_vars; do
+ eval ac_env_${ac_var}_set=\${${ac_var}+set}
+ eval ac_env_${ac_var}_value=\$${ac_var}
+ eval ac_cv_env_${ac_var}_set=\${${ac_var}+set}
+ eval ac_cv_env_${ac_var}_value=\$${ac_var}
+done
+
+#
+# Report the --help message.
+#
+if test "$ac_init_help" = "long"; then
+ # Omit some internal or obsolete options to make the list less imposing.
+ # This message is too long to be a string in the A/UX 3.1 sh.
+ cat <<_ACEOF
+\`configure' configures libffi 3.2.1 to adapt to many kinds of systems.
+
+Usage: $0 [OPTION]... [VAR=VALUE]...
+
+To assign environment variables (e.g., CC, CFLAGS...), specify them as
+VAR=VALUE. See below for descriptions of some of the useful variables.
+
+Defaults for the options are specified in brackets.
+
+Configuration:
+ -h, --help display this help and exit
+ --help=short display options specific to this package
+ --help=recursive display the short help of all the included packages
+ -V, --version display version information and exit
+ -q, --quiet, --silent do not print \`checking ...' messages
+ --cache-file=FILE cache test results in FILE [disabled]
+ -C, --config-cache alias for \`--cache-file=config.cache'
+ -n, --no-create do not create output files
+ --srcdir=DIR find the sources in DIR [configure dir or \`..']
+
+Installation directories:
+ --prefix=PREFIX install architecture-independent files in PREFIX
+ [$ac_default_prefix]
+ --exec-prefix=EPREFIX install architecture-dependent files in EPREFIX
+ [PREFIX]
+
+By default, \`make install' will install all the files in
+\`$ac_default_prefix/bin', \`$ac_default_prefix/lib' etc. You can specify
+an installation prefix other than \`$ac_default_prefix' using \`--prefix',
+for instance \`--prefix=\$HOME'.
+
+For better control, use the options below.
+
+Fine tuning of the installation directories:
+ --bindir=DIR user executables [EPREFIX/bin]
+ --sbindir=DIR system admin executables [EPREFIX/sbin]
+ --libexecdir=DIR program executables [EPREFIX/libexec]
+ --sysconfdir=DIR read-only single-machine data [PREFIX/etc]
+ --sharedstatedir=DIR modifiable architecture-independent data [PREFIX/com]
+ --localstatedir=DIR modifiable single-machine data [PREFIX/var]
+ --libdir=DIR object code libraries [EPREFIX/lib]
+ --includedir=DIR C header files [PREFIX/include]
+ --oldincludedir=DIR C header files for non-gcc [/usr/include]
+ --datarootdir=DIR read-only arch.-independent data root [PREFIX/share]
+ --datadir=DIR read-only architecture-independent data [DATAROOTDIR]
+ --infodir=DIR info documentation [DATAROOTDIR/info]
+ --localedir=DIR locale-dependent data [DATAROOTDIR/locale]
+ --mandir=DIR man documentation [DATAROOTDIR/man]
+ --docdir=DIR documentation root [DATAROOTDIR/doc/libffi]
+ --htmldir=DIR html documentation [DOCDIR]
+ --dvidir=DIR dvi documentation [DOCDIR]
+ --pdfdir=DIR pdf documentation [DOCDIR]
+ --psdir=DIR ps documentation [DOCDIR]
+_ACEOF
+
+ cat <<\_ACEOF
+
+Program names:
+ --program-prefix=PREFIX prepend PREFIX to installed program names
+ --program-suffix=SUFFIX append SUFFIX to installed program names
+ --program-transform-name=PROGRAM run sed PROGRAM on installed program names
+
+System types:
+ --build=BUILD configure for building on BUILD [guessed]
+ --host=HOST cross-compile to build programs to run on HOST [BUILD]
+ --target=TARGET configure for building compilers for TARGET [HOST]
+_ACEOF
+fi
+
+if test -n "$ac_init_help"; then
+ case $ac_init_help in
+ short | recursive ) echo "Configuration of libffi 3.2.1:";;
+ esac
+ cat <<\_ACEOF
+
+Optional Features:
+ --disable-option-checking ignore unrecognized --enable/--with options
+ --disable-FEATURE do not include FEATURE (same as --enable-FEATURE=no)
+ --enable-FEATURE[=ARG] include FEATURE [ARG=yes]
+ --disable-builddir disable automatic build in subdir of sources
+
+ --enable-silent-rules less verbose build output (undo: "make V=1")
+ --disable-silent-rules verbose build output (undo: "make V=0")
+ --enable-dependency-tracking
+ do not reject slow dependency extractors
+ --disable-dependency-tracking
+ speeds up one-time build
+ --enable-shared[=PKGS] build shared libraries [default=yes]
+ --enable-static[=PKGS] build static libraries [default=yes]
+ --enable-fast-install[=PKGS]
+ optimize for fast installation [default=yes]
+ --disable-libtool-lock avoid locking (might break parallel builds)
+ --enable-portable-binary
+ disable compiler optimizations that would produce
+ unportable binaries
+ --enable-maintainer-mode
+ enable make rules and dependencies not useful (and
+ sometimes confusing) to the casual installer
+ --enable-pax_emutramp enable pax emulated trampolines, for we can't use PROT_EXEC
+ --enable-debug debugging mode
+ --disable-structs omit code for struct support
+ --disable-raw-api make the raw api unavailable
+ --enable-purify-safety purify-safe mode
+
+Optional Packages:
+ --with-PACKAGE[=ARG] use PACKAGE [ARG=yes]
+ --without-PACKAGE do not use PACKAGE (same as --with-PACKAGE=no)
+ --with-pic[=PKGS] try to use only PIC/non-PIC objects [default=use
+ both]
+ --with-gnu-ld assume the C compiler uses GNU ld [default=no]
+ --with-sysroot=DIR Search for dependent libraries within DIR
+ (or the compiler's sysroot if not specified).
+ --with-gcc-arch=<arch> use architecture <arch> for gcc -march/-mtune,
+ instead of guessing
+
+Some influential environment variables:
+ CC C compiler command
+ CFLAGS C compiler flags
+ LDFLAGS linker flags, e.g. -L<lib dir> if you have libraries in a
+ nonstandard directory <lib dir>
+ LIBS libraries to pass to the linker, e.g. -l<library>
+ CPPFLAGS (Objective) C/C++ preprocessor flags, e.g. -I<include dir> if
+ you have headers in a nonstandard directory <include dir>
+ CXX C++ compiler command
+ CXXFLAGS C++ compiler flags
+ CCAS assembler compiler command (defaults to CC)
+ CCASFLAGS assembler compiler flags (defaults to CFLAGS)
+ CPP C preprocessor
+ CXXCPP C++ preprocessor
+
+Use these variables to override the choices made by `configure' or to help
+it to find libraries and programs with nonstandard names/locations.
+
+Report bugs to <http://github.com/atgreen/libffi/issues>.
+_ACEOF
+ac_status=$?
+fi
+
+if test "$ac_init_help" = "recursive"; then
+ # If there are subdirs, report their specific --help.
+ for ac_dir in : $ac_subdirs_all; do test "x$ac_dir" = x: && continue
+ test -d "$ac_dir" ||
+ { cd "$srcdir" && ac_pwd=`pwd` && srcdir=. && test -d "$ac_dir"; } ||
+ continue
+ ac_builddir=.
+
+case "$ac_dir" in
+.) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;;
+*)
+ ac_dir_suffix=/`$as_echo "$ac_dir" | sed 's|^\.[\\/]||'`
+ # A ".." for each directory in $ac_dir_suffix.
+ ac_top_builddir_sub=`$as_echo "$ac_dir_suffix" | sed 's|/[^\\/]*|/..|g;s|/||'`
+ case $ac_top_builddir_sub in
+ "") ac_top_builddir_sub=. ac_top_build_prefix= ;;
+ *) ac_top_build_prefix=$ac_top_builddir_sub/ ;;
+ esac ;;
+esac
+ac_abs_top_builddir=$ac_pwd
+ac_abs_builddir=$ac_pwd$ac_dir_suffix
+# for backward compatibility:
+ac_top_builddir=$ac_top_build_prefix
+
+case $srcdir in
+ .) # We are building in place.
+ ac_srcdir=.
+ ac_top_srcdir=$ac_top_builddir_sub
+ ac_abs_top_srcdir=$ac_pwd ;;
+ [\\/]* | ?:[\\/]* ) # Absolute name.
+ ac_srcdir=$srcdir$ac_dir_suffix;
+ ac_top_srcdir=$srcdir
+ ac_abs_top_srcdir=$srcdir ;;
+ *) # Relative name.
+ ac_srcdir=$ac_top_build_prefix$srcdir$ac_dir_suffix
+ ac_top_srcdir=$ac_top_build_prefix$srcdir
+ ac_abs_top_srcdir=$ac_pwd/$srcdir ;;
+esac
+ac_abs_srcdir=$ac_abs_top_srcdir$ac_dir_suffix
+
+ cd "$ac_dir" || { ac_status=$?; continue; }
+ # Check for guested configure.
+ if test -f "$ac_srcdir/configure.gnu"; then
+ echo &&
+ $SHELL "$ac_srcdir/configure.gnu" --help=recursive
+ elif test -f "$ac_srcdir/configure"; then
+ echo &&
+ $SHELL "$ac_srcdir/configure" --help=recursive
+ else
+ $as_echo "$as_me: WARNING: no configuration information is in $ac_dir" >&2
+ fi || ac_status=$?
+ cd "$ac_pwd" || { ac_status=$?; break; }
+ done
+fi
+
+test -n "$ac_init_help" && exit $ac_status
+if $ac_init_version; then
+ cat <<\_ACEOF
+libffi configure 3.2.1
+generated by GNU Autoconf 2.69
+
+Copyright (C) 2012 Free Software Foundation, Inc.
+This configure script is free software; the Free Software Foundation
+gives unlimited permission to copy, distribute and modify it.
+_ACEOF
+ exit
+fi
+
+## ------------------------ ##
+## Autoconf initialization. ##
+## ------------------------ ##
+
+# ac_fn_c_try_compile LINENO
+# --------------------------
+# Try to compile conftest.$ac_ext, and return whether this succeeded.
+ac_fn_c_try_compile ()
+{
+ as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
+ rm -f conftest.$ac_objext
+ if { { ac_try="$ac_compile"
+case "(($ac_try" in
+ *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+ *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
+$as_echo "$ac_try_echo"; } >&5
+ (eval "$ac_compile") 2>conftest.err
+ ac_status=$?
+ if test -s conftest.err; then
+ grep -v '^ *+' conftest.err >conftest.er1
+ cat conftest.er1 >&5
+ mv -f conftest.er1 conftest.err
+ fi
+ $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+ test $ac_status = 0; } && {
+ test -z "$ac_c_werror_flag" ||
+ test ! -s conftest.err
+ } && test -s conftest.$ac_objext; then :
+ ac_retval=0
+else
+ $as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ ac_retval=1
+fi
+ eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
+ as_fn_set_status $ac_retval
+
+} # ac_fn_c_try_compile
+
+# ac_fn_cxx_try_compile LINENO
+# ----------------------------
+# Try to compile conftest.$ac_ext, and return whether this succeeded.
+ac_fn_cxx_try_compile ()
+{
+ as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
+ rm -f conftest.$ac_objext
+ if { { ac_try="$ac_compile"
+case "(($ac_try" in
+ *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+ *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
+$as_echo "$ac_try_echo"; } >&5
+ (eval "$ac_compile") 2>conftest.err
+ ac_status=$?
+ if test -s conftest.err; then
+ grep -v '^ *+' conftest.err >conftest.er1
+ cat conftest.er1 >&5
+ mv -f conftest.er1 conftest.err
+ fi
+ $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+ test $ac_status = 0; } && {
+ test -z "$ac_cxx_werror_flag" ||
+ test ! -s conftest.err
+ } && test -s conftest.$ac_objext; then :
+ ac_retval=0
+else
+ $as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ ac_retval=1
+fi
+ eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
+ as_fn_set_status $ac_retval
+
+} # ac_fn_cxx_try_compile
+
+# ac_fn_c_try_link LINENO
+# -----------------------
+# Try to link conftest.$ac_ext, and return whether this succeeded.
+ac_fn_c_try_link ()
+{
+ as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
+ rm -f conftest.$ac_objext conftest$ac_exeext
+ if { { ac_try="$ac_link"
+case "(($ac_try" in
+ *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+ *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
+$as_echo "$ac_try_echo"; } >&5
+ (eval "$ac_link") 2>conftest.err
+ ac_status=$?
+ if test -s conftest.err; then
+ grep -v '^ *+' conftest.err >conftest.er1
+ cat conftest.er1 >&5
+ mv -f conftest.er1 conftest.err
+ fi
+ $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+ test $ac_status = 0; } && {
+ test -z "$ac_c_werror_flag" ||
+ test ! -s conftest.err
+ } && test -s conftest$ac_exeext && {
+ test "$cross_compiling" = yes ||
+ test -x conftest$ac_exeext
+ }; then :
+ ac_retval=0
+else
+ $as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ ac_retval=1
+fi
+ # Delete the IPA/IPO (Inter Procedural Analysis/Optimization) information
+ # created by the PGI compiler (conftest_ipa8_conftest.oo), as it would
+ # interfere with the next link command; also delete a directory that is
+ # left behind by Apple's compiler. We do this before executing the actions.
+ rm -rf conftest.dSYM conftest_ipa8_conftest.oo
+ eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
+ as_fn_set_status $ac_retval
+
+} # ac_fn_c_try_link
+
+# ac_fn_c_check_header_compile LINENO HEADER VAR INCLUDES
+# -------------------------------------------------------
+# Tests whether HEADER exists and can be compiled using the include files in
+# INCLUDES, setting the cache variable VAR accordingly.
+ac_fn_c_check_header_compile ()
+{
+ as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5
+$as_echo_n "checking for $2... " >&6; }
+if eval \${$3+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+$4
+#include <$2>
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+ eval "$3=yes"
+else
+ eval "$3=no"
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+eval ac_res=\$$3
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5
+$as_echo "$ac_res" >&6; }
+ eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
+
+} # ac_fn_c_check_header_compile
+
+# ac_fn_c_try_cpp LINENO
+# ----------------------
+# Try to preprocess conftest.$ac_ext, and return whether this succeeded.
+ac_fn_c_try_cpp ()
+{
+ as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
+ if { { ac_try="$ac_cpp conftest.$ac_ext"
+case "(($ac_try" in
+ *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+ *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
+$as_echo "$ac_try_echo"; } >&5
+ (eval "$ac_cpp conftest.$ac_ext") 2>conftest.err
+ ac_status=$?
+ if test -s conftest.err; then
+ grep -v '^ *+' conftest.err >conftest.er1
+ cat conftest.er1 >&5
+ mv -f conftest.er1 conftest.err
+ fi
+ $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+ test $ac_status = 0; } > conftest.i && {
+ test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" ||
+ test ! -s conftest.err
+ }; then :
+ ac_retval=0
+else
+ $as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ ac_retval=1
+fi
+ eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
+ as_fn_set_status $ac_retval
+
+} # ac_fn_c_try_cpp
+
+# ac_fn_c_try_run LINENO
+# ----------------------
+# Try to link conftest.$ac_ext, and return whether this succeeded. Assumes
+# that executables *can* be run.
+ac_fn_c_try_run ()
+{
+ as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
+ if { { ac_try="$ac_link"
+case "(($ac_try" in
+ *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+ *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
+$as_echo "$ac_try_echo"; } >&5
+ (eval "$ac_link") 2>&5
+ ac_status=$?
+ $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+ test $ac_status = 0; } && { ac_try='./conftest$ac_exeext'
+ { { case "(($ac_try" in
+ *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+ *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
+$as_echo "$ac_try_echo"; } >&5
+ (eval "$ac_try") 2>&5
+ ac_status=$?
+ $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+ test $ac_status = 0; }; }; then :
+ ac_retval=0
+else
+ $as_echo "$as_me: program exited with status $ac_status" >&5
+ $as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ ac_retval=$ac_status
+fi
+ rm -rf conftest.dSYM conftest_ipa8_conftest.oo
+ eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
+ as_fn_set_status $ac_retval
+
+} # ac_fn_c_try_run
+
+# ac_fn_c_check_func LINENO FUNC VAR
+# ----------------------------------
+# Tests whether FUNC exists, setting the cache variable VAR accordingly
+ac_fn_c_check_func ()
+{
+ as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5
+$as_echo_n "checking for $2... " >&6; }
+if eval \${$3+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+/* Define $2 to an innocuous variant, in case <limits.h> declares $2.
+ For example, HP-UX 11i <limits.h> declares gettimeofday. */
+#define $2 innocuous_$2
+
+/* System header to define __stub macros and hopefully few prototypes,
+ which can conflict with char $2 (); below.
+ Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
+ <limits.h> exists even on freestanding compilers. */
+
+#ifdef __STDC__
+# include <limits.h>
+#else
+# include <assert.h>
+#endif
+
+#undef $2
+
+/* Override any GCC internal prototype to avoid an error.
+ Use char because int might match the return type of a GCC
+ builtin and then its argument prototype would still apply. */
+#ifdef __cplusplus
+extern "C"
+#endif
+char $2 ();
+/* The GNU C library defines this for functions which it implements
+ to always fail with ENOSYS. Some functions are actually named
+ something starting with __ and the normal name is an alias. */
+#if defined __stub_$2 || defined __stub___$2
+choke me
+#endif
+
+int
+main ()
+{
+return $2 ();
+ ;
+ return 0;
+}
+_ACEOF
+if ac_fn_c_try_link "$LINENO"; then :
+ eval "$3=yes"
+else
+ eval "$3=no"
+fi
+rm -f core conftest.err conftest.$ac_objext \
+ conftest$ac_exeext conftest.$ac_ext
+fi
+eval ac_res=\$$3
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5
+$as_echo "$ac_res" >&6; }
+ eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
+
+} # ac_fn_c_check_func
+
+# ac_fn_cxx_try_cpp LINENO
+# ------------------------
+# Try to preprocess conftest.$ac_ext, and return whether this succeeded.
+ac_fn_cxx_try_cpp ()
+{
+ as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
+ if { { ac_try="$ac_cpp conftest.$ac_ext"
+case "(($ac_try" in
+ *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+ *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
+$as_echo "$ac_try_echo"; } >&5
+ (eval "$ac_cpp conftest.$ac_ext") 2>conftest.err
+ ac_status=$?
+ if test -s conftest.err; then
+ grep -v '^ *+' conftest.err >conftest.er1
+ cat conftest.er1 >&5
+ mv -f conftest.er1 conftest.err
+ fi
+ $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+ test $ac_status = 0; } > conftest.i && {
+ test -z "$ac_cxx_preproc_warn_flag$ac_cxx_werror_flag" ||
+ test ! -s conftest.err
+ }; then :
+ ac_retval=0
+else
+ $as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ ac_retval=1
+fi
+ eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
+ as_fn_set_status $ac_retval
+
+} # ac_fn_cxx_try_cpp
+
+# ac_fn_cxx_try_link LINENO
+# -------------------------
+# Try to link conftest.$ac_ext, and return whether this succeeded.
+ac_fn_cxx_try_link ()
+{
+ as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
+ rm -f conftest.$ac_objext conftest$ac_exeext
+ if { { ac_try="$ac_link"
+case "(($ac_try" in
+ *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+ *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
+$as_echo "$ac_try_echo"; } >&5
+ (eval "$ac_link") 2>conftest.err
+ ac_status=$?
+ if test -s conftest.err; then
+ grep -v '^ *+' conftest.err >conftest.er1
+ cat conftest.er1 >&5
+ mv -f conftest.er1 conftest.err
+ fi
+ $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+ test $ac_status = 0; } && {
+ test -z "$ac_cxx_werror_flag" ||
+ test ! -s conftest.err
+ } && test -s conftest$ac_exeext && {
+ test "$cross_compiling" = yes ||
+ test -x conftest$ac_exeext
+ }; then :
+ ac_retval=0
+else
+ $as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ ac_retval=1
+fi
+ # Delete the IPA/IPO (Inter Procedural Analysis/Optimization) information
+ # created by the PGI compiler (conftest_ipa8_conftest.oo), as it would
+ # interfere with the next link command; also delete a directory that is
+ # left behind by Apple's compiler. We do this before executing the actions.
+ rm -rf conftest.dSYM conftest_ipa8_conftest.oo
+ eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
+ as_fn_set_status $ac_retval
+
+} # ac_fn_cxx_try_link
+
+# ac_fn_c_compute_int LINENO EXPR VAR INCLUDES
+# --------------------------------------------
+# Tries to find the compile-time value of EXPR in a program that includes
+# INCLUDES, setting VAR accordingly. Returns whether the value could be
+# computed
+ac_fn_c_compute_int ()
+{
+ as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
+ if test "$cross_compiling" = yes; then
+ # Depending upon the size, compute the lo and hi bounds.
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+$4
+int
+main ()
+{
+static int test_array [1 - 2 * !(($2) >= 0)];
+test_array [0] = 0;
+return test_array [0];
+
+ ;
+ return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+ ac_lo=0 ac_mid=0
+ while :; do
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+$4
+int
+main ()
+{
+static int test_array [1 - 2 * !(($2) <= $ac_mid)];
+test_array [0] = 0;
+return test_array [0];
+
+ ;
+ return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+ ac_hi=$ac_mid; break
+else
+ as_fn_arith $ac_mid + 1 && ac_lo=$as_val
+ if test $ac_lo -le $ac_mid; then
+ ac_lo= ac_hi=
+ break
+ fi
+ as_fn_arith 2 '*' $ac_mid + 1 && ac_mid=$as_val
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+ done
+else
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+$4
+int
+main ()
+{
+static int test_array [1 - 2 * !(($2) < 0)];
+test_array [0] = 0;
+return test_array [0];
+
+ ;
+ return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+ ac_hi=-1 ac_mid=-1
+ while :; do
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+$4
+int
+main ()
+{
+static int test_array [1 - 2 * !(($2) >= $ac_mid)];
+test_array [0] = 0;
+return test_array [0];
+
+ ;
+ return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+ ac_lo=$ac_mid; break
+else
+ as_fn_arith '(' $ac_mid ')' - 1 && ac_hi=$as_val
+ if test $ac_mid -le $ac_hi; then
+ ac_lo= ac_hi=
+ break
+ fi
+ as_fn_arith 2 '*' $ac_mid && ac_mid=$as_val
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+ done
+else
+ ac_lo= ac_hi=
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+# Binary search between lo and hi bounds.
+while test "x$ac_lo" != "x$ac_hi"; do
+ as_fn_arith '(' $ac_hi - $ac_lo ')' / 2 + $ac_lo && ac_mid=$as_val
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+$4
+int
+main ()
+{
+static int test_array [1 - 2 * !(($2) <= $ac_mid)];
+test_array [0] = 0;
+return test_array [0];
+
+ ;
+ return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+ ac_hi=$ac_mid
+else
+ as_fn_arith '(' $ac_mid ')' + 1 && ac_lo=$as_val
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+done
+case $ac_lo in #((
+?*) eval "$3=\$ac_lo"; ac_retval=0 ;;
+'') ac_retval=1 ;;
+esac
+ else
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+$4
+static long int longval () { return $2; }
+static unsigned long int ulongval () { return $2; }
+#include <stdio.h>
+#include <stdlib.h>
+int
+main ()
+{
+
+ FILE *f = fopen ("conftest.val", "w");
+ if (! f)
+ return 1;
+ if (($2) < 0)
+ {
+ long int i = longval ();
+ if (i != ($2))
+ return 1;
+ fprintf (f, "%ld", i);
+ }
+ else
+ {
+ unsigned long int i = ulongval ();
+ if (i != ($2))
+ return 1;
+ fprintf (f, "%lu", i);
+ }
+ /* Do not output a trailing newline, as this causes \r\n confusion
+ on some platforms. */
+ return ferror (f) || fclose (f) != 0;
+
+ ;
+ return 0;
+}
+_ACEOF
+if ac_fn_c_try_run "$LINENO"; then :
+ echo >>conftest.val; read $3 <conftest.val; ac_retval=0
+else
+ ac_retval=1
+fi
+rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
+ conftest.$ac_objext conftest.beam conftest.$ac_ext
+rm -f conftest.val
+
+ fi
+ eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
+ as_fn_set_status $ac_retval
+
+} # ac_fn_c_compute_int
+
+# ac_fn_c_check_header_mongrel LINENO HEADER VAR INCLUDES
+# -------------------------------------------------------
+# Tests whether HEADER exists, giving a warning if it cannot be compiled using
+# the include files in INCLUDES and setting the cache variable VAR
+# accordingly.
+ac_fn_c_check_header_mongrel ()
+{
+ as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
+ if eval \${$3+:} false; then :
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5
+$as_echo_n "checking for $2... " >&6; }
+if eval \${$3+:} false; then :
+ $as_echo_n "(cached) " >&6
+fi
+eval ac_res=\$$3
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5
+$as_echo "$ac_res" >&6; }
+else
+ # Is the header compilable?
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking $2 usability" >&5
+$as_echo_n "checking $2 usability... " >&6; }
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+$4
+#include <$2>
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+ ac_header_compiler=yes
+else
+ ac_header_compiler=no
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_header_compiler" >&5
+$as_echo "$ac_header_compiler" >&6; }
+
+# Is the header present?
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking $2 presence" >&5
+$as_echo_n "checking $2 presence... " >&6; }
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+#include <$2>
+_ACEOF
+if ac_fn_c_try_cpp "$LINENO"; then :
+ ac_header_preproc=yes
+else
+ ac_header_preproc=no
+fi
+rm -f conftest.err conftest.i conftest.$ac_ext
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_header_preproc" >&5
+$as_echo "$ac_header_preproc" >&6; }
+
+# So? What about this header?
+case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in #((
+ yes:no: )
+ { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: accepted by the compiler, rejected by the preprocessor!" >&5
+$as_echo "$as_me: WARNING: $2: accepted by the compiler, rejected by the preprocessor!" >&2;}
+ { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: proceeding with the compiler's result" >&5
+$as_echo "$as_me: WARNING: $2: proceeding with the compiler's result" >&2;}
+ ;;
+ no:yes:* )
+ { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: present but cannot be compiled" >&5
+$as_echo "$as_me: WARNING: $2: present but cannot be compiled" >&2;}
+ { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: check for missing prerequisite headers?" >&5
+$as_echo "$as_me: WARNING: $2: check for missing prerequisite headers?" >&2;}
+ { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: see the Autoconf documentation" >&5
+$as_echo "$as_me: WARNING: $2: see the Autoconf documentation" >&2;}
+ { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: section \"Present But Cannot Be Compiled\"" >&5
+$as_echo "$as_me: WARNING: $2: section \"Present But Cannot Be Compiled\"" >&2;}
+ { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: proceeding with the compiler's result" >&5
+$as_echo "$as_me: WARNING: $2: proceeding with the compiler's result" >&2;}
+( $as_echo "## ------------------------------------------------------ ##
+## Report this to http://github.com/atgreen/libffi/issues ##
+## ------------------------------------------------------ ##"
+ ) | sed "s/^/$as_me: WARNING: /" >&2
+ ;;
+esac
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5
+$as_echo_n "checking for $2... " >&6; }
+if eval \${$3+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ eval "$3=\$ac_header_compiler"
+fi
+eval ac_res=\$$3
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5
+$as_echo "$ac_res" >&6; }
+fi
+ eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
+
+} # ac_fn_c_check_header_mongrel
+
+# ac_fn_c_check_type LINENO TYPE VAR INCLUDES
+# -------------------------------------------
+# Tests whether TYPE exists after having included INCLUDES, setting cache
+# variable VAR accordingly.
+ac_fn_c_check_type ()
+{
+ as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5
+$as_echo_n "checking for $2... " >&6; }
+if eval \${$3+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ eval "$3=no"
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+$4
+int
+main ()
+{
+if (sizeof ($2))
+ return 0;
+ ;
+ return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+$4
+int
+main ()
+{
+if (sizeof (($2)))
+ return 0;
+ ;
+ return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+
+else
+ eval "$3=yes"
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+eval ac_res=\$$3
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5
+$as_echo "$ac_res" >&6; }
+ eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
+
+} # ac_fn_c_check_type
+cat >config.log <<_ACEOF
+This file contains any messages produced by compilers while
+running configure, to aid debugging if configure makes a mistake.
+
+It was created by libffi $as_me 3.2.1, which was
+generated by GNU Autoconf 2.69. Invocation command line was
+
+ $ $0 $@
+
+_ACEOF
+exec 5>>config.log
+{
+cat <<_ASUNAME
+## --------- ##
+## Platform. ##
+## --------- ##
+
+hostname = `(hostname || uname -n) 2>/dev/null | sed 1q`
+uname -m = `(uname -m) 2>/dev/null || echo unknown`
+uname -r = `(uname -r) 2>/dev/null || echo unknown`
+uname -s = `(uname -s) 2>/dev/null || echo unknown`
+uname -v = `(uname -v) 2>/dev/null || echo unknown`
+
+/usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null || echo unknown`
+/bin/uname -X = `(/bin/uname -X) 2>/dev/null || echo unknown`
+
+/bin/arch = `(/bin/arch) 2>/dev/null || echo unknown`
+/usr/bin/arch -k = `(/usr/bin/arch -k) 2>/dev/null || echo unknown`
+/usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null || echo unknown`
+/usr/bin/hostinfo = `(/usr/bin/hostinfo) 2>/dev/null || echo unknown`
+/bin/machine = `(/bin/machine) 2>/dev/null || echo unknown`
+/usr/bin/oslevel = `(/usr/bin/oslevel) 2>/dev/null || echo unknown`
+/bin/universe = `(/bin/universe) 2>/dev/null || echo unknown`
+
+_ASUNAME
+
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ $as_echo "PATH: $as_dir"
+ done
+IFS=$as_save_IFS
+
+} >&5
+
+cat >&5 <<_ACEOF
+
+
+## ----------- ##
+## Core tests. ##
+## ----------- ##
+
+_ACEOF
+
+
+# Keep a trace of the command line.
+# Strip out --no-create and --no-recursion so they do not pile up.
+# Strip out --silent because we don't want to record it for future runs.
+# Also quote any args containing shell meta-characters.
+# Make two passes to allow for proper duplicate-argument suppression.
+ac_configure_args=
+ac_configure_args0=
+ac_configure_args1=
+ac_must_keep_next=false
+for ac_pass in 1 2
+do
+ for ac_arg
+ do
+ case $ac_arg in
+ -no-create | --no-c* | -n | -no-recursion | --no-r*) continue ;;
+ -q | -quiet | --quiet | --quie | --qui | --qu | --q \
+ | -silent | --silent | --silen | --sile | --sil)
+ continue ;;
+ *\'*)
+ ac_arg=`$as_echo "$ac_arg" | sed "s/'/'\\\\\\\\''/g"` ;;
+ esac
+ case $ac_pass in
+ 1) as_fn_append ac_configure_args0 " '$ac_arg'" ;;
+ 2)
+ as_fn_append ac_configure_args1 " '$ac_arg'"
+ if test $ac_must_keep_next = true; then
+ ac_must_keep_next=false # Got value, back to normal.
+ else
+ case $ac_arg in
+ *=* | --config-cache | -C | -disable-* | --disable-* \
+ | -enable-* | --enable-* | -gas | --g* | -nfp | --nf* \
+ | -q | -quiet | --q* | -silent | --sil* | -v | -verb* \
+ | -with-* | --with-* | -without-* | --without-* | --x)
+ case "$ac_configure_args0 " in
+ "$ac_configure_args1"*" '$ac_arg' "* ) continue ;;
+ esac
+ ;;
+ -* ) ac_must_keep_next=true ;;
+ esac
+ fi
+ as_fn_append ac_configure_args " '$ac_arg'"
+ ;;
+ esac
+ done
+done
+{ ac_configure_args0=; unset ac_configure_args0;}
+{ ac_configure_args1=; unset ac_configure_args1;}
+
+# When interrupted or exit'd, cleanup temporary files, and complete
+# config.log. We remove comments because anyway the quotes in there
+# would cause problems or look ugly.
+# WARNING: Use '\'' to represent an apostrophe within the trap.
+# WARNING: Do not start the trap code with a newline, due to a FreeBSD 4.0 bug.
+trap 'exit_status=$?
+ # Save into config.log some information that might help in debugging.
+ {
+ echo
+
+ $as_echo "## ---------------- ##
+## Cache variables. ##
+## ---------------- ##"
+ echo
+ # The following way of writing the cache mishandles newlines in values,
+(
+ for ac_var in `(set) 2>&1 | sed -n '\''s/^\([a-zA-Z_][a-zA-Z0-9_]*\)=.*/\1/p'\''`; do
+ eval ac_val=\$$ac_var
+ case $ac_val in #(
+ *${as_nl}*)
+ case $ac_var in #(
+ *_cv_*) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: cache variable $ac_var contains a newline" >&5
+$as_echo "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} ;;
+ esac
+ case $ac_var in #(
+ _ | IFS | as_nl) ;; #(
+ BASH_ARGV | BASH_SOURCE) eval $ac_var= ;; #(
+ *) { eval $ac_var=; unset $ac_var;} ;;
+ esac ;;
+ esac
+ done
+ (set) 2>&1 |
+ case $as_nl`(ac_space='\'' '\''; set) 2>&1` in #(
+ *${as_nl}ac_space=\ *)
+ sed -n \
+ "s/'\''/'\''\\\\'\'''\''/g;
+ s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\''\\2'\''/p"
+ ;; #(
+ *)
+ sed -n "/^[_$as_cr_alnum]*_cv_[_$as_cr_alnum]*=/p"
+ ;;
+ esac |
+ sort
+)
+ echo
+
+ $as_echo "## ----------------- ##
+## Output variables. ##
+## ----------------- ##"
+ echo
+ for ac_var in $ac_subst_vars
+ do
+ eval ac_val=\$$ac_var
+ case $ac_val in
+ *\'\''*) ac_val=`$as_echo "$ac_val" | sed "s/'\''/'\''\\\\\\\\'\'''\''/g"`;;
+ esac
+ $as_echo "$ac_var='\''$ac_val'\''"
+ done | sort
+ echo
+
+ if test -n "$ac_subst_files"; then
+ $as_echo "## ------------------- ##
+## File substitutions. ##
+## ------------------- ##"
+ echo
+ for ac_var in $ac_subst_files
+ do
+ eval ac_val=\$$ac_var
+ case $ac_val in
+ *\'\''*) ac_val=`$as_echo "$ac_val" | sed "s/'\''/'\''\\\\\\\\'\'''\''/g"`;;
+ esac
+ $as_echo "$ac_var='\''$ac_val'\''"
+ done | sort
+ echo
+ fi
+
+ if test -s confdefs.h; then
+ $as_echo "## ----------- ##
+## confdefs.h. ##
+## ----------- ##"
+ echo
+ cat confdefs.h
+ echo
+ fi
+ test "$ac_signal" != 0 &&
+ $as_echo "$as_me: caught signal $ac_signal"
+ $as_echo "$as_me: exit $exit_status"
+ } >&5
+ rm -f core *.core core.conftest.* &&
+ rm -f -r conftest* confdefs* conf$$* $ac_clean_files &&
+ exit $exit_status
+' 0
+for ac_signal in 1 2 13 15; do
+ trap 'ac_signal='$ac_signal'; as_fn_exit 1' $ac_signal
+done
+ac_signal=0
+
+# confdefs.h avoids OS command line length limits that DEFS can exceed.
+rm -f -r conftest* confdefs.h
+
+$as_echo "/* confdefs.h */" > confdefs.h
+
+# Predefined preprocessor variables.
+
+cat >>confdefs.h <<_ACEOF
+#define PACKAGE_NAME "$PACKAGE_NAME"
+_ACEOF
+
+cat >>confdefs.h <<_ACEOF
+#define PACKAGE_TARNAME "$PACKAGE_TARNAME"
+_ACEOF
+
+cat >>confdefs.h <<_ACEOF
+#define PACKAGE_VERSION "$PACKAGE_VERSION"
+_ACEOF
+
+cat >>confdefs.h <<_ACEOF
+#define PACKAGE_STRING "$PACKAGE_STRING"
+_ACEOF
+
+cat >>confdefs.h <<_ACEOF
+#define PACKAGE_BUGREPORT "$PACKAGE_BUGREPORT"
+_ACEOF
+
+cat >>confdefs.h <<_ACEOF
+#define PACKAGE_URL "$PACKAGE_URL"
+_ACEOF
+
+
+# Let the site file select an alternate cache file if it wants to.
+# Prefer an explicitly selected file to automatically selected ones.
+ac_site_file1=NONE
+ac_site_file2=NONE
+if test -n "$CONFIG_SITE"; then
+ # We do not want a PATH search for config.site.
+ case $CONFIG_SITE in #((
+ -*) ac_site_file1=./$CONFIG_SITE;;
+ */*) ac_site_file1=$CONFIG_SITE;;
+ *) ac_site_file1=./$CONFIG_SITE;;
+ esac
+elif test "x$prefix" != xNONE; then
+ ac_site_file1=$prefix/share/config.site
+ ac_site_file2=$prefix/etc/config.site
+else
+ ac_site_file1=$ac_default_prefix/share/config.site
+ ac_site_file2=$ac_default_prefix/etc/config.site
+fi
+for ac_site_file in "$ac_site_file1" "$ac_site_file2"
+do
+ test "x$ac_site_file" = xNONE && continue
+ if test /dev/null != "$ac_site_file" && test -r "$ac_site_file"; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: loading site script $ac_site_file" >&5
+$as_echo "$as_me: loading site script $ac_site_file" >&6;}
+ sed 's/^/| /' "$ac_site_file" >&5
+ . "$ac_site_file" \
+ || { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
+$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
+as_fn_error $? "failed to load site script $ac_site_file
+See \`config.log' for more details" "$LINENO" 5; }
+ fi
+done
+
+if test -r "$cache_file"; then
+ # Some versions of bash will fail to source /dev/null (special files
+ # actually), so we avoid doing that. DJGPP emulates it as a regular file.
+ if test /dev/null != "$cache_file" && test -f "$cache_file"; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: loading cache $cache_file" >&5
+$as_echo "$as_me: loading cache $cache_file" >&6;}
+ case $cache_file in
+ [\\/]* | ?:[\\/]* ) . "$cache_file";;
+ *) . "./$cache_file";;
+ esac
+ fi
+else
+ { $as_echo "$as_me:${as_lineno-$LINENO}: creating cache $cache_file" >&5
+$as_echo "$as_me: creating cache $cache_file" >&6;}
+ >$cache_file
+fi
+
+# Check that the precious variables saved in the cache have kept the same
+# value.
+ac_cache_corrupted=false
+for ac_var in $ac_precious_vars; do
+ eval ac_old_set=\$ac_cv_env_${ac_var}_set
+ eval ac_new_set=\$ac_env_${ac_var}_set
+ eval ac_old_val=\$ac_cv_env_${ac_var}_value
+ eval ac_new_val=\$ac_env_${ac_var}_value
+ case $ac_old_set,$ac_new_set in
+ set,)
+ { $as_echo "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&5
+$as_echo "$as_me: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&2;}
+ ac_cache_corrupted=: ;;
+ ,set)
+ { $as_echo "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' was not set in the previous run" >&5
+$as_echo "$as_me: error: \`$ac_var' was not set in the previous run" >&2;}
+ ac_cache_corrupted=: ;;
+ ,);;
+ *)
+ if test "x$ac_old_val" != "x$ac_new_val"; then
+ # differences in whitespace do not lead to failure.
+ ac_old_val_w=`echo x $ac_old_val`
+ ac_new_val_w=`echo x $ac_new_val`
+ if test "$ac_old_val_w" != "$ac_new_val_w"; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' has changed since the previous run:" >&5
+$as_echo "$as_me: error: \`$ac_var' has changed since the previous run:" >&2;}
+ ac_cache_corrupted=:
+ else
+ { $as_echo "$as_me:${as_lineno-$LINENO}: warning: ignoring whitespace changes in \`$ac_var' since the previous run:" >&5
+$as_echo "$as_me: warning: ignoring whitespace changes in \`$ac_var' since the previous run:" >&2;}
+ eval $ac_var=\$ac_old_val
+ fi
+ { $as_echo "$as_me:${as_lineno-$LINENO}: former value: \`$ac_old_val'" >&5
+$as_echo "$as_me: former value: \`$ac_old_val'" >&2;}
+ { $as_echo "$as_me:${as_lineno-$LINENO}: current value: \`$ac_new_val'" >&5
+$as_echo "$as_me: current value: \`$ac_new_val'" >&2;}
+ fi;;
+ esac
+ # Pass precious variables to config.status.
+ if test "$ac_new_set" = set; then
+ case $ac_new_val in
+ *\'*) ac_arg=$ac_var=`$as_echo "$ac_new_val" | sed "s/'/'\\\\\\\\''/g"` ;;
+ *) ac_arg=$ac_var=$ac_new_val ;;
+ esac
+ case " $ac_configure_args " in
+ *" '$ac_arg' "*) ;; # Avoid dups. Use of quotes ensures accuracy.
+ *) as_fn_append ac_configure_args " '$ac_arg'" ;;
+ esac
+ fi
+done
+if $ac_cache_corrupted; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
+$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
+ { $as_echo "$as_me:${as_lineno-$LINENO}: error: changes in the environment can compromise the build" >&5
+$as_echo "$as_me: error: changes in the environment can compromise the build" >&2;}
+ as_fn_error $? "run \`make distclean' and/or \`rm $cache_file' and start over" "$LINENO" 5
+fi
+## -------------------- ##
+## Main body of script. ##
+## -------------------- ##
+
+ac_ext=c
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
+
+
+ac_config_headers="$ac_config_headers fficonfig.h"
+
+
+ac_aux_dir=
+for ac_dir in "$srcdir" "$srcdir/.." "$srcdir/../.."; do
+ if test -f "$ac_dir/install-sh"; then
+ ac_aux_dir=$ac_dir
+ ac_install_sh="$ac_aux_dir/install-sh -c"
+ break
+ elif test -f "$ac_dir/install.sh"; then
+ ac_aux_dir=$ac_dir
+ ac_install_sh="$ac_aux_dir/install.sh -c"
+ break
+ elif test -f "$ac_dir/shtool"; then
+ ac_aux_dir=$ac_dir
+ ac_install_sh="$ac_aux_dir/shtool install -c"
+ break
+ fi
+done
+if test -z "$ac_aux_dir"; then
+ as_fn_error $? "cannot find install-sh, install.sh, or shtool in \"$srcdir\" \"$srcdir/..\" \"$srcdir/../..\"" "$LINENO" 5
+fi
+
+# These three variables are undocumented and unsupported,
+# and are intended to be withdrawn in a future Autoconf release.
+# They can cause serious problems if a builder's source tree is in a directory
+# whose full name contains unusual characters.
+ac_config_guess="$SHELL $ac_aux_dir/config.guess" # Please don't use this var.
+ac_config_sub="$SHELL $ac_aux_dir/config.sub" # Please don't use this var.
+ac_configure="$SHELL $ac_aux_dir/configure" # Please don't use this var.
+
+
+# Make sure we can run config.sub.
+$SHELL "$ac_aux_dir/config.sub" sun4 >/dev/null 2>&1 ||
+ as_fn_error $? "cannot run $SHELL $ac_aux_dir/config.sub" "$LINENO" 5
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking build system type" >&5
+$as_echo_n "checking build system type... " >&6; }
+if ${ac_cv_build+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ ac_build_alias=$build_alias
+test "x$ac_build_alias" = x &&
+ ac_build_alias=`$SHELL "$ac_aux_dir/config.guess"`
+test "x$ac_build_alias" = x &&
+ as_fn_error $? "cannot guess build type; you must specify one" "$LINENO" 5
+ac_cv_build=`$SHELL "$ac_aux_dir/config.sub" $ac_build_alias` ||
+ as_fn_error $? "$SHELL $ac_aux_dir/config.sub $ac_build_alias failed" "$LINENO" 5
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_build" >&5
+$as_echo "$ac_cv_build" >&6; }
+case $ac_cv_build in
+*-*-*) ;;
+*) as_fn_error $? "invalid value of canonical build" "$LINENO" 5;;
+esac
+build=$ac_cv_build
+ac_save_IFS=$IFS; IFS='-'
+set x $ac_cv_build
+shift
+build_cpu=$1
+build_vendor=$2
+shift; shift
+# Remember, the first character of IFS is used to create $*,
+# except with old shells:
+build_os=$*
+IFS=$ac_save_IFS
+case $build_os in *\ *) build_os=`echo "$build_os" | sed 's/ /-/g'`;; esac
+
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking host system type" >&5
+$as_echo_n "checking host system type... " >&6; }
+if ${ac_cv_host+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ if test "x$host_alias" = x; then
+ ac_cv_host=$ac_cv_build
+else
+ ac_cv_host=`$SHELL "$ac_aux_dir/config.sub" $host_alias` ||
+ as_fn_error $? "$SHELL $ac_aux_dir/config.sub $host_alias failed" "$LINENO" 5
+fi
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_host" >&5
+$as_echo "$ac_cv_host" >&6; }
+case $ac_cv_host in
+*-*-*) ;;
+*) as_fn_error $? "invalid value of canonical host" "$LINENO" 5;;
+esac
+host=$ac_cv_host
+ac_save_IFS=$IFS; IFS='-'
+set x $ac_cv_host
+shift
+host_cpu=$1
+host_vendor=$2
+shift; shift
+# Remember, the first character of IFS is used to create $*,
+# except with old shells:
+host_os=$*
+IFS=$ac_save_IFS
+case $host_os in *\ *) host_os=`echo "$host_os" | sed 's/ /-/g'`;; esac
+
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking target system type" >&5
+$as_echo_n "checking target system type... " >&6; }
+if ${ac_cv_target+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ if test "x$target_alias" = x; then
+ ac_cv_target=$ac_cv_host
+else
+ ac_cv_target=`$SHELL "$ac_aux_dir/config.sub" $target_alias` ||
+ as_fn_error $? "$SHELL $ac_aux_dir/config.sub $target_alias failed" "$LINENO" 5
+fi
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_target" >&5
+$as_echo "$ac_cv_target" >&6; }
+case $ac_cv_target in
+*-*-*) ;;
+*) as_fn_error $? "invalid value of canonical target" "$LINENO" 5;;
+esac
+target=$ac_cv_target
+ac_save_IFS=$IFS; IFS='-'
+set x $ac_cv_target
+shift
+target_cpu=$1
+target_vendor=$2
+shift; shift
+# Remember, the first character of IFS is used to create $*,
+# except with old shells:
+target_os=$*
+IFS=$ac_save_IFS
+case $target_os in *\ *) target_os=`echo "$target_os" | sed 's/ /-/g'`;; esac
+
+
+# The aliases save the names the user supplied, while $host etc.
+# will get canonicalized.
+test -n "$target_alias" &&
+ test "$program_prefix$program_suffix$program_transform_name" = \
+ NONENONEs,x,x, &&
+ program_prefix=${target_alias}-
+
+target_alias=${target_alias-$host_alias}
+
+case "${host}" in
+ frv*-elf)
+ LDFLAGS=`echo $LDFLAGS | sed "s/\-B^ *libgloss\/frv\///"`\ -B`pwd`/../libgloss/frv/
+ ;;
+esac
+
+
+ # [$]@ is unsable in 2.60+ but earlier autoconf had no ac_configure_args
+ if test "${ac_configure_args+set}" != "set" ; then
+ ac_configure_args=
+ for ac_arg in ${1+"$@"}; do
+ ac_configure_args="$ac_configure_args '$ac_arg'"
+ done
+ fi
+
+# expand $ac_aux_dir to an absolute path
+am_aux_dir=`cd $ac_aux_dir && pwd`
+
+
+ax_enable_builddir="."
+# Check whether --enable-builddir was given.
+if test "${enable_builddir+set}" = set; then :
+ enableval=$enable_builddir; ax_enable_builddir="$enableval"
+else
+ ax_enable_builddir="auto"
+fi
+
+if test ".$ac_srcdir_defaulted" != ".no" ; then
+if test ".$srcdir" = ".." ; then
+ if test -f config.status ; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: toplevel srcdir already configured... skipping subdir build" >&5
+$as_echo "$as_me: toplevel srcdir already configured... skipping subdir build" >&6;}
+ else
+ test ".$ax_enable_builddir" = "." && ax_enable_builddir="."
+ test ".$ax_enable_builddir" = ".no" && ax_enable_builddir="."
+ test ".$TARGET" = "." && TARGET="$target"
+ test ".$ax_enable_builddir" = ".auto" && ax_enable_builddir="$TARGET"
+ if test ".$ax_enable_builddir" != ".." ; then # we know where to go and
+ as_dir=$ax_enable_builddir; as_fn_mkdir_p
+ echo __.$ax_enable_builddir.__ > $ax_enable_builddir/conftest.tmp
+ cd $ax_enable_builddir
+ if grep __.$ax_enable_builddir.__ conftest.tmp >/dev/null 2>/dev/null ; then
+ rm conftest.tmp
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: continue configure in default builddir \"./$ax_enable_builddir\"" >&5
+$as_echo "continue configure in default builddir \"./$ax_enable_builddir\"" >&6; }
+ else
+ as_fn_error $? "could not change to default builddir \"./$ax_enable_builddir\"" "$LINENO" 5
+ fi
+ srcdir=`echo "$ax_enable_builddir" |
+ sed -e 's,^\./,,;s,[^/]$,&/,;s,[^/]*/,../,g;s,[/]$,,;'`
+ # going to restart from subdirectory location
+ test -f $srcdir/config.log && mv $srcdir/config.log .
+ test -f $srcdir/confdefs.h && mv $srcdir/confdefs.h .
+ test -f $srcdir/conftest.log && mv $srcdir/conftest.log .
+ test -f $srcdir/$cache_file && mv $srcdir/$cache_file .
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: ....exec $SHELL $srcdir/$0 \"--srcdir=$srcdir\" \"--enable-builddir=$ax_enable_builddir\" ${1+\"$@\"}" >&5
+$as_echo "....exec $SHELL $srcdir/$0 \"--srcdir=$srcdir\" \"--enable-builddir=$ax_enable_builddir\" ${1+\"$@\"}" >&6; }
+ case "$0" in # restart
+ [\\/]* | ?:[\\/]*) # Asbolute name
+ eval $SHELL "'$0'" "'--srcdir=$srcdir'" "'--enable-builddir=$ax_enable_builddir'" $ac_configure_args ;;
+ *) eval $SHELL "'$srcdir/$0'" "'--srcdir=$srcdir'" "'--enable-builddir=$ax_enable_builddir'" $ac_configure_args ;;
+ esac ; exit $?
+ fi
+ fi
+fi fi
+test ".$ax_enable_builddir" = ".auto" && ax_enable_builddir="."
+# Extract the first word of "gsed sed", so it can be a program name with args.
+set dummy gsed sed; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if ${ac_cv_path_ax_enable_builddir_sed+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ case $ax_enable_builddir_sed in
+ [\\/]* | ?:[\\/]*)
+ ac_cv_path_ax_enable_builddir_sed="$ax_enable_builddir_sed" # Let the user override the test with a path.
+ ;;
+ *)
+ as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ for ac_exec_ext in '' $ac_executable_extensions; do
+ if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+ ac_cv_path_ax_enable_builddir_sed="$as_dir/$ac_word$ac_exec_ext"
+ $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+ break 2
+ fi
+done
+ done
+IFS=$as_save_IFS
+
+ test -z "$ac_cv_path_ax_enable_builddir_sed" && ac_cv_path_ax_enable_builddir_sed="sed"
+ ;;
+esac
+fi
+ax_enable_builddir_sed=$ac_cv_path_ax_enable_builddir_sed
+if test -n "$ax_enable_builddir_sed"; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ax_enable_builddir_sed" >&5
+$as_echo "$ax_enable_builddir_sed" >&6; }
+else
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+ax_enable_builddir_auxdir="$am_aux_dir"
+ac_config_commands="$ac_config_commands buildir"
+
+
+am__api_version='1.13'
+
+# Find a good install program. We prefer a C program (faster),
+# so one script is as good as another. But avoid the broken or
+# incompatible versions:
+# SysV /etc/install, /usr/sbin/install
+# SunOS /usr/etc/install
+# IRIX /sbin/install
+# AIX /bin/install
+# AmigaOS /C/install, which installs bootblocks on floppy discs
+# AIX 4 /usr/bin/installbsd, which doesn't work without a -g flag
+# AFS /usr/afsws/bin/install, which mishandles nonexistent args
+# SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff"
+# OS/2's system install, which has a completely different semantic
+# ./install, which can be erroneously created by make from ./install.sh.
+# Reject install programs that cannot install multiple files.
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for a BSD-compatible install" >&5
+$as_echo_n "checking for a BSD-compatible install... " >&6; }
+if test -z "$INSTALL"; then
+if ${ac_cv_path_install+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ # Account for people who put trailing slashes in PATH elements.
+case $as_dir/ in #((
+ ./ | .// | /[cC]/* | \
+ /etc/* | /usr/sbin/* | /usr/etc/* | /sbin/* | /usr/afsws/bin/* | \
+ ?:[\\/]os2[\\/]install[\\/]* | ?:[\\/]OS2[\\/]INSTALL[\\/]* | \
+ /usr/ucb/* ) ;;
+ *)
+ # OSF1 and SCO ODT 3.0 have their own names for install.
+ # Don't use installbsd from OSF since it installs stuff as root
+ # by default.
+ for ac_prog in ginstall scoinst install; do
+ for ac_exec_ext in '' $ac_executable_extensions; do
+ if as_fn_executable_p "$as_dir/$ac_prog$ac_exec_ext"; then
+ if test $ac_prog = install &&
+ grep dspmsg "$as_dir/$ac_prog$ac_exec_ext" >/dev/null 2>&1; then
+ # AIX install. It has an incompatible calling convention.
+ :
+ elif test $ac_prog = install &&
+ grep pwplus "$as_dir/$ac_prog$ac_exec_ext" >/dev/null 2>&1; then
+ # program-specific install script used by HP pwplus--don't use.
+ :
+ else
+ rm -rf conftest.one conftest.two conftest.dir
+ echo one > conftest.one
+ echo two > conftest.two
+ mkdir conftest.dir
+ if "$as_dir/$ac_prog$ac_exec_ext" -c conftest.one conftest.two "`pwd`/conftest.dir" &&
+ test -s conftest.one && test -s conftest.two &&
+ test -s conftest.dir/conftest.one &&
+ test -s conftest.dir/conftest.two
+ then
+ ac_cv_path_install="$as_dir/$ac_prog$ac_exec_ext -c"
+ break 3
+ fi
+ fi
+ fi
+ done
+ done
+ ;;
+esac
+
+ done
+IFS=$as_save_IFS
+
+rm -rf conftest.one conftest.two conftest.dir
+
+fi
+ if test "${ac_cv_path_install+set}" = set; then
+ INSTALL=$ac_cv_path_install
+ else
+ # As a last resort, use the slow shell script. Don't cache a
+ # value for INSTALL within a source directory, because that will
+ # break other packages using the cache if that directory is
+ # removed, or if the value is a relative name.
+ INSTALL=$ac_install_sh
+ fi
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $INSTALL" >&5
+$as_echo "$INSTALL" >&6; }
+
+# Use test -z because SunOS4 sh mishandles braces in ${var-val}.
+# It thinks the first close brace ends the variable substitution.
+test -z "$INSTALL_PROGRAM" && INSTALL_PROGRAM='${INSTALL}'
+
+test -z "$INSTALL_SCRIPT" && INSTALL_SCRIPT='${INSTALL}'
+
+test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644'
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether build environment is sane" >&5
+$as_echo_n "checking whether build environment is sane... " >&6; }
+# Reject unsafe characters in $srcdir or the absolute working directory
+# name. Accept space and tab only in the latter.
+am_lf='
+'
+case `pwd` in
+ *[\\\"\#\$\&\'\`$am_lf]*)
+ as_fn_error $? "unsafe absolute working directory name" "$LINENO" 5;;
+esac
+case $srcdir in
+ *[\\\"\#\$\&\'\`$am_lf\ \ ]*)
+ as_fn_error $? "unsafe srcdir value: '$srcdir'" "$LINENO" 5;;
+esac
+
+# Do 'set' in a subshell so we don't clobber the current shell's
+# arguments. Must try -L first in case configure is actually a
+# symlink; some systems play weird games with the mod time of symlinks
+# (eg FreeBSD returns the mod time of the symlink's containing
+# directory).
+if (
+ am_has_slept=no
+ for am_try in 1 2; do
+ echo "timestamp, slept: $am_has_slept" > conftest.file
+ set X `ls -Lt "$srcdir/configure" conftest.file 2> /dev/null`
+ if test "$*" = "X"; then
+ # -L didn't work.
+ set X `ls -t "$srcdir/configure" conftest.file`
+ fi
+ if test "$*" != "X $srcdir/configure conftest.file" \
+ && test "$*" != "X conftest.file $srcdir/configure"; then
+
+ # If neither matched, then we have a broken ls. This can happen
+ # if, for instance, CONFIG_SHELL is bash and it inherits a
+ # broken ls alias from the environment. This has actually
+ # happened. Such a system could not be considered "sane".
+ as_fn_error $? "ls -t appears to fail. Make sure there is not a broken
+ alias in your environment" "$LINENO" 5
+ fi
+ if test "$2" = conftest.file || test $am_try -eq 2; then
+ break
+ fi
+ # Just in case.
+ sleep 1
+ am_has_slept=yes
+ done
+ test "$2" = conftest.file
+ )
+then
+ # Ok.
+ :
+else
+ as_fn_error $? "newly created file is older than distributed files!
+Check your system clock" "$LINENO" 5
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+$as_echo "yes" >&6; }
+# If we didn't sleep, we still need to ensure time stamps of config.status and
+# generated files are strictly newer.
+am_sleep_pid=
+if grep 'slept: no' conftest.file >/dev/null 2>&1; then
+ ( sleep 1 ) &
+ am_sleep_pid=$!
+fi
+
+rm -f conftest.file
+
+test "$program_prefix" != NONE &&
+ program_transform_name="s&^&$program_prefix&;$program_transform_name"
+# Use a double $ so make ignores it.
+test "$program_suffix" != NONE &&
+ program_transform_name="s&\$&$program_suffix&;$program_transform_name"
+# Double any \ or $.
+# By default was `s,x,x', remove it if useless.
+ac_script='s/[\\$]/&&/g;s/;s,x,x,$//'
+program_transform_name=`$as_echo "$program_transform_name" | sed "$ac_script"`
+
+if test x"${MISSING+set}" != xset; then
+ case $am_aux_dir in
+ *\ * | *\ *)
+ MISSING="\${SHELL} \"$am_aux_dir/missing\"" ;;
+ *)
+ MISSING="\${SHELL} $am_aux_dir/missing" ;;
+ esac
+fi
+# Use eval to expand $SHELL
+if eval "$MISSING --is-lightweight"; then
+ am_missing_run="$MISSING "
+else
+ am_missing_run=
+ { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: 'missing' script is too old or missing" >&5
+$as_echo "$as_me: WARNING: 'missing' script is too old or missing" >&2;}
+fi
+
+if test x"${install_sh}" != xset; then
+ case $am_aux_dir in
+ *\ * | *\ *)
+ install_sh="\${SHELL} '$am_aux_dir/install-sh'" ;;
+ *)
+ install_sh="\${SHELL} $am_aux_dir/install-sh"
+ esac
+fi
+
+# Installed binaries are usually stripped using 'strip' when the user
+# run "make install-strip". However 'strip' might not be the right
+# tool to use in cross-compilation environments, therefore Automake
+# will honor the 'STRIP' environment variable to overrule this program.
+if test "$cross_compiling" != no; then
+ if test -n "$ac_tool_prefix"; then
+ # Extract the first word of "${ac_tool_prefix}strip", so it can be a program name with args.
+set dummy ${ac_tool_prefix}strip; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if ${ac_cv_prog_STRIP+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ if test -n "$STRIP"; then
+ ac_cv_prog_STRIP="$STRIP" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ for ac_exec_ext in '' $ac_executable_extensions; do
+ if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+ ac_cv_prog_STRIP="${ac_tool_prefix}strip"
+ $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+ break 2
+ fi
+done
+ done
+IFS=$as_save_IFS
+
+fi
+fi
+STRIP=$ac_cv_prog_STRIP
+if test -n "$STRIP"; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $STRIP" >&5
+$as_echo "$STRIP" >&6; }
+else
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+fi
+if test -z "$ac_cv_prog_STRIP"; then
+ ac_ct_STRIP=$STRIP
+ # Extract the first word of "strip", so it can be a program name with args.
+set dummy strip; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if ${ac_cv_prog_ac_ct_STRIP+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ if test -n "$ac_ct_STRIP"; then
+ ac_cv_prog_ac_ct_STRIP="$ac_ct_STRIP" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ for ac_exec_ext in '' $ac_executable_extensions; do
+ if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+ ac_cv_prog_ac_ct_STRIP="strip"
+ $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+ break 2
+ fi
+done
+ done
+IFS=$as_save_IFS
+
+fi
+fi
+ac_ct_STRIP=$ac_cv_prog_ac_ct_STRIP
+if test -n "$ac_ct_STRIP"; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_STRIP" >&5
+$as_echo "$ac_ct_STRIP" >&6; }
+else
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+ if test "x$ac_ct_STRIP" = x; then
+ STRIP=":"
+ else
+ case $cross_compiling:$ac_tool_warned in
+yes:)
+{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
+$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
+ac_tool_warned=yes ;;
+esac
+ STRIP=$ac_ct_STRIP
+ fi
+else
+ STRIP="$ac_cv_prog_STRIP"
+fi
+
+fi
+INSTALL_STRIP_PROGRAM="\$(install_sh) -c -s"
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for a thread-safe mkdir -p" >&5
+$as_echo_n "checking for a thread-safe mkdir -p... " >&6; }
+if test -z "$MKDIR_P"; then
+ if ${ac_cv_path_mkdir+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH$PATH_SEPARATOR/opt/sfw/bin
+do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ for ac_prog in mkdir gmkdir; do
+ for ac_exec_ext in '' $ac_executable_extensions; do
+ as_fn_executable_p "$as_dir/$ac_prog$ac_exec_ext" || continue
+ case `"$as_dir/$ac_prog$ac_exec_ext" --version 2>&1` in #(
+ 'mkdir (GNU coreutils) '* | \
+ 'mkdir (coreutils) '* | \
+ 'mkdir (fileutils) '4.1*)
+ ac_cv_path_mkdir=$as_dir/$ac_prog$ac_exec_ext
+ break 3;;
+ esac
+ done
+ done
+ done
+IFS=$as_save_IFS
+
+fi
+
+ test -d ./--version && rmdir ./--version
+ if test "${ac_cv_path_mkdir+set}" = set; then
+ MKDIR_P="$ac_cv_path_mkdir -p"
+ else
+ # As a last resort, use the slow shell script. Don't cache a
+ # value for MKDIR_P within a source directory, because that will
+ # break other packages using the cache if that directory is
+ # removed, or if the value is a relative name.
+ MKDIR_P="$ac_install_sh -d"
+ fi
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $MKDIR_P" >&5
+$as_echo "$MKDIR_P" >&6; }
+
+for ac_prog in gawk mawk nawk awk
+do
+ # Extract the first word of "$ac_prog", so it can be a program name with args.
+set dummy $ac_prog; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if ${ac_cv_prog_AWK+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ if test -n "$AWK"; then
+ ac_cv_prog_AWK="$AWK" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ for ac_exec_ext in '' $ac_executable_extensions; do
+ if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+ ac_cv_prog_AWK="$ac_prog"
+ $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+ break 2
+ fi
+done
+ done
+IFS=$as_save_IFS
+
+fi
+fi
+AWK=$ac_cv_prog_AWK
+if test -n "$AWK"; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $AWK" >&5
+$as_echo "$AWK" >&6; }
+else
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+ test -n "$AWK" && break
+done
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether ${MAKE-make} sets \$(MAKE)" >&5
+$as_echo_n "checking whether ${MAKE-make} sets \$(MAKE)... " >&6; }
+set x ${MAKE-make}
+ac_make=`$as_echo "$2" | sed 's/+/p/g; s/[^a-zA-Z0-9_]/_/g'`
+if eval \${ac_cv_prog_make_${ac_make}_set+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ cat >conftest.make <<\_ACEOF
+SHELL = /bin/sh
+all:
+ @echo '@@@%%%=$(MAKE)=@@@%%%'
+_ACEOF
+# GNU make sometimes prints "make[1]: Entering ...", which would confuse us.
+case `${MAKE-make} -f conftest.make 2>/dev/null` in
+ *@@@%%%=?*=@@@%%%*)
+ eval ac_cv_prog_make_${ac_make}_set=yes;;
+ *)
+ eval ac_cv_prog_make_${ac_make}_set=no;;
+esac
+rm -f conftest.make
+fi
+if eval test \$ac_cv_prog_make_${ac_make}_set = yes; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+$as_echo "yes" >&6; }
+ SET_MAKE=
+else
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+ SET_MAKE="MAKE=${MAKE-make}"
+fi
+
+rm -rf .tst 2>/dev/null
+mkdir .tst 2>/dev/null
+if test -d .tst; then
+ am__leading_dot=.
+else
+ am__leading_dot=_
+fi
+rmdir .tst 2>/dev/null
+
+# Check whether --enable-silent-rules was given.
+if test "${enable_silent_rules+set}" = set; then :
+ enableval=$enable_silent_rules;
+fi
+
+case $enable_silent_rules in # (((
+ yes) AM_DEFAULT_VERBOSITY=0;;
+ no) AM_DEFAULT_VERBOSITY=1;;
+ *) AM_DEFAULT_VERBOSITY=1;;
+esac
+am_make=${MAKE-make}
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $am_make supports nested variables" >&5
+$as_echo_n "checking whether $am_make supports nested variables... " >&6; }
+if ${am_cv_make_support_nested_variables+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ if $as_echo 'TRUE=$(BAR$(V))
+BAR0=false
+BAR1=true
+V=1
+am__doit:
+ @$(TRUE)
+.PHONY: am__doit' | $am_make -f - >/dev/null 2>&1; then
+ am_cv_make_support_nested_variables=yes
+else
+ am_cv_make_support_nested_variables=no
+fi
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $am_cv_make_support_nested_variables" >&5
+$as_echo "$am_cv_make_support_nested_variables" >&6; }
+if test $am_cv_make_support_nested_variables = yes; then
+ AM_V='$(V)'
+ AM_DEFAULT_V='$(AM_DEFAULT_VERBOSITY)'
+else
+ AM_V=$AM_DEFAULT_VERBOSITY
+ AM_DEFAULT_V=$AM_DEFAULT_VERBOSITY
+fi
+AM_BACKSLASH='\'
+
+if test "`cd $srcdir && pwd`" != "`pwd`"; then
+ # Use -I$(srcdir) only when $(srcdir) != ., so that make's output
+ # is not polluted with repeated "-I."
+ am__isrc=' -I$(srcdir)'
+ # test to see if srcdir already configured
+ if test -f $srcdir/config.status; then
+ as_fn_error $? "source directory already configured; run \"make distclean\" there first" "$LINENO" 5
+ fi
+fi
+
+# test whether we have cygpath
+if test -z "$CYGPATH_W"; then
+ if (cygpath --version) >/dev/null 2>/dev/null; then
+ CYGPATH_W='cygpath -w'
+ else
+ CYGPATH_W=echo
+ fi
+fi
+
+
+# Define the identity of the package.
+ PACKAGE='libffi'
+ VERSION='3.2.1'
+
+
+cat >>confdefs.h <<_ACEOF
+#define PACKAGE "$PACKAGE"
+_ACEOF
+
+
+cat >>confdefs.h <<_ACEOF
+#define VERSION "$VERSION"
+_ACEOF
+
+# Some tools Automake needs.
+
+ACLOCAL=${ACLOCAL-"${am_missing_run}aclocal-${am__api_version}"}
+
+
+AUTOCONF=${AUTOCONF-"${am_missing_run}autoconf"}
+
+
+AUTOMAKE=${AUTOMAKE-"${am_missing_run}automake-${am__api_version}"}
+
+
+AUTOHEADER=${AUTOHEADER-"${am_missing_run}autoheader"}
+
+
+MAKEINFO=${MAKEINFO-"${am_missing_run}makeinfo"}
+
+# For better backward compatibility. To be removed once Automake 1.9.x
+# dies out for good. For more background, see:
+# <http://lists.gnu.org/archive/html/automake/2012-07/msg00001.html>
+# <http://lists.gnu.org/archive/html/automake/2012-07/msg00014.html>
+mkdir_p='$(MKDIR_P)'
+
+# We need awk for the "check" target. The system "awk" is bad on
+# some platforms.
+# Always define AMTAR for backward compatibility. Yes, it's still used
+# in the wild :-( We should find a proper way to deprecate it ...
+AMTAR='$${TAR-tar}'
+
+
+# We'll loop over all known methods to create a tar archive until one works.
+_am_tools='gnutar pax cpio none'
+
+am__tar='$${TAR-tar} chof - "$$tardir"' am__untar='$${TAR-tar} xf -'
+
+
+
+
+
+
+
+# The same as in boehm-gc and libstdc++. Have to borrow it from there.
+# We must force CC to /not/ be precious variables; otherwise
+# the wrong, non-multilib-adjusted value will be used in multilibs.
+# As a side effect, we have to subst CFLAGS ourselves.
+# Also save and restore CFLAGS, since AC_PROG_CC will come up with
+# defaults of its own if none are provided.
+
+
+
+save_CFLAGS=$CFLAGS
+ac_ext=c
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
+if test -n "$ac_tool_prefix"; then
+ # Extract the first word of "${ac_tool_prefix}gcc", so it can be a program name with args.
+set dummy ${ac_tool_prefix}gcc; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if ${ac_cv_prog_CC+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ if test -n "$CC"; then
+ ac_cv_prog_CC="$CC" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ for ac_exec_ext in '' $ac_executable_extensions; do
+ if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+ ac_cv_prog_CC="${ac_tool_prefix}gcc"
+ $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+ break 2
+ fi
+done
+ done
+IFS=$as_save_IFS
+
+fi
+fi
+CC=$ac_cv_prog_CC
+if test -n "$CC"; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5
+$as_echo "$CC" >&6; }
+else
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+fi
+if test -z "$ac_cv_prog_CC"; then
+ ac_ct_CC=$CC
+ # Extract the first word of "gcc", so it can be a program name with args.
+set dummy gcc; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if ${ac_cv_prog_ac_ct_CC+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ if test -n "$ac_ct_CC"; then
+ ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ for ac_exec_ext in '' $ac_executable_extensions; do
+ if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+ ac_cv_prog_ac_ct_CC="gcc"
+ $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+ break 2
+ fi
+done
+ done
+IFS=$as_save_IFS
+
+fi
+fi
+ac_ct_CC=$ac_cv_prog_ac_ct_CC
+if test -n "$ac_ct_CC"; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CC" >&5
+$as_echo "$ac_ct_CC" >&6; }
+else
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+ if test "x$ac_ct_CC" = x; then
+ CC=""
+ else
+ case $cross_compiling:$ac_tool_warned in
+yes:)
+{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
+$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
+ac_tool_warned=yes ;;
+esac
+ CC=$ac_ct_CC
+ fi
+else
+ CC="$ac_cv_prog_CC"
+fi
+
+if test -z "$CC"; then
+ if test -n "$ac_tool_prefix"; then
+ # Extract the first word of "${ac_tool_prefix}cc", so it can be a program name with args.
+set dummy ${ac_tool_prefix}cc; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if ${ac_cv_prog_CC+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ if test -n "$CC"; then
+ ac_cv_prog_CC="$CC" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ for ac_exec_ext in '' $ac_executable_extensions; do
+ if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+ ac_cv_prog_CC="${ac_tool_prefix}cc"
+ $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+ break 2
+ fi
+done
+ done
+IFS=$as_save_IFS
+
+fi
+fi
+CC=$ac_cv_prog_CC
+if test -n "$CC"; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5
+$as_echo "$CC" >&6; }
+else
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+ fi
+fi
+if test -z "$CC"; then
+ # Extract the first word of "cc", so it can be a program name with args.
+set dummy cc; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if ${ac_cv_prog_CC+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ if test -n "$CC"; then
+ ac_cv_prog_CC="$CC" # Let the user override the test.
+else
+ ac_prog_rejected=no
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ for ac_exec_ext in '' $ac_executable_extensions; do
+ if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+ if test "$as_dir/$ac_word$ac_exec_ext" = "/usr/ucb/cc"; then
+ ac_prog_rejected=yes
+ continue
+ fi
+ ac_cv_prog_CC="cc"
+ $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+ break 2
+ fi
+done
+ done
+IFS=$as_save_IFS
+
+if test $ac_prog_rejected = yes; then
+ # We found a bogon in the path, so make sure we never use it.
+ set dummy $ac_cv_prog_CC
+ shift
+ if test $# != 0; then
+ # We chose a different compiler from the bogus one.
+ # However, it has the same basename, so the bogon will be chosen
+ # first if we set CC to just the basename; use the full file name.
+ shift
+ ac_cv_prog_CC="$as_dir/$ac_word${1+' '}$@"
+ fi
+fi
+fi
+fi
+CC=$ac_cv_prog_CC
+if test -n "$CC"; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5
+$as_echo "$CC" >&6; }
+else
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+fi
+if test -z "$CC"; then
+ if test -n "$ac_tool_prefix"; then
+ for ac_prog in cl.exe
+ do
+ # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args.
+set dummy $ac_tool_prefix$ac_prog; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if ${ac_cv_prog_CC+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ if test -n "$CC"; then
+ ac_cv_prog_CC="$CC" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ for ac_exec_ext in '' $ac_executable_extensions; do
+ if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+ ac_cv_prog_CC="$ac_tool_prefix$ac_prog"
+ $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+ break 2
+ fi
+done
+ done
+IFS=$as_save_IFS
+
+fi
+fi
+CC=$ac_cv_prog_CC
+if test -n "$CC"; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5
+$as_echo "$CC" >&6; }
+else
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+ test -n "$CC" && break
+ done
+fi
+if test -z "$CC"; then
+ ac_ct_CC=$CC
+ for ac_prog in cl.exe
+do
+ # Extract the first word of "$ac_prog", so it can be a program name with args.
+set dummy $ac_prog; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if ${ac_cv_prog_ac_ct_CC+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ if test -n "$ac_ct_CC"; then
+ ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ for ac_exec_ext in '' $ac_executable_extensions; do
+ if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+ ac_cv_prog_ac_ct_CC="$ac_prog"
+ $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+ break 2
+ fi
+done
+ done
+IFS=$as_save_IFS
+
+fi
+fi
+ac_ct_CC=$ac_cv_prog_ac_ct_CC
+if test -n "$ac_ct_CC"; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CC" >&5
+$as_echo "$ac_ct_CC" >&6; }
+else
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+ test -n "$ac_ct_CC" && break
+done
+
+ if test "x$ac_ct_CC" = x; then
+ CC=""
+ else
+ case $cross_compiling:$ac_tool_warned in
+yes:)
+{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
+$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
+ac_tool_warned=yes ;;
+esac
+ CC=$ac_ct_CC
+ fi
+fi
+
+fi
+
+
+test -z "$CC" && { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
+$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
+as_fn_error $? "no acceptable C compiler found in \$PATH
+See \`config.log' for more details" "$LINENO" 5; }
+
+# Provide some information about the compiler.
+$as_echo "$as_me:${as_lineno-$LINENO}: checking for C compiler version" >&5
+set X $ac_compile
+ac_compiler=$2
+for ac_option in --version -v -V -qversion; do
+ { { ac_try="$ac_compiler $ac_option >&5"
+case "(($ac_try" in
+ *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+ *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
+$as_echo "$ac_try_echo"; } >&5
+ (eval "$ac_compiler $ac_option >&5") 2>conftest.err
+ ac_status=$?
+ if test -s conftest.err; then
+ sed '10a\
+... rest of stderr output deleted ...
+ 10q' conftest.err >conftest.er1
+ cat conftest.er1 >&5
+ fi
+ rm -f conftest.er1 conftest.err
+ $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+ test $ac_status = 0; }
+done
+
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+
+int
+main ()
+{
+
+ ;
+ return 0;
+}
+_ACEOF
+ac_clean_files_save=$ac_clean_files
+ac_clean_files="$ac_clean_files a.out a.out.dSYM a.exe b.out"
+# Try to create an executable without -o first, disregard a.out.
+# It will help us diagnose broken compilers, and finding out an intuition
+# of exeext.
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the C compiler works" >&5
+$as_echo_n "checking whether the C compiler works... " >&6; }
+ac_link_default=`$as_echo "$ac_link" | sed 's/ -o *conftest[^ ]*//'`
+
+# The possible output files:
+ac_files="a.out conftest.exe conftest a.exe a_out.exe b.out conftest.*"
+
+ac_rmfiles=
+for ac_file in $ac_files
+do
+ case $ac_file in
+ *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) ;;
+ * ) ac_rmfiles="$ac_rmfiles $ac_file";;
+ esac
+done
+rm -f $ac_rmfiles
+
+if { { ac_try="$ac_link_default"
+case "(($ac_try" in
+ *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+ *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
+$as_echo "$ac_try_echo"; } >&5
+ (eval "$ac_link_default") 2>&5
+ ac_status=$?
+ $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+ test $ac_status = 0; }; then :
+ # Autoconf-2.13 could set the ac_cv_exeext variable to `no'.
+# So ignore a value of `no', otherwise this would lead to `EXEEXT = no'
+# in a Makefile. We should not override ac_cv_exeext if it was cached,
+# so that the user can short-circuit this test for compilers unknown to
+# Autoconf.
+for ac_file in $ac_files ''
+do
+ test -f "$ac_file" || continue
+ case $ac_file in
+ *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj )
+ ;;
+ [ab].out )
+ # We found the default executable, but exeext='' is most
+ # certainly right.
+ break;;
+ *.* )
+ if test "${ac_cv_exeext+set}" = set && test "$ac_cv_exeext" != no;
+ then :; else
+ ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'`
+ fi
+ # We set ac_cv_exeext here because the later test for it is not
+ # safe: cross compilers may not add the suffix if given an `-o'
+ # argument, so we may need to know it at that point already.
+ # Even if this section looks crufty: it has the advantage of
+ # actually working.
+ break;;
+ * )
+ break;;
+ esac
+done
+test "$ac_cv_exeext" = no && ac_cv_exeext=
+
+else
+ ac_file=''
+fi
+if test -z "$ac_file"; then :
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+$as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+{ { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
+$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
+as_fn_error 77 "C compiler cannot create executables
+See \`config.log' for more details" "$LINENO" 5; }
+else
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+$as_echo "yes" >&6; }
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for C compiler default output file name" >&5
+$as_echo_n "checking for C compiler default output file name... " >&6; }
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_file" >&5
+$as_echo "$ac_file" >&6; }
+ac_exeext=$ac_cv_exeext
+
+rm -f -r a.out a.out.dSYM a.exe conftest$ac_cv_exeext b.out
+ac_clean_files=$ac_clean_files_save
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for suffix of executables" >&5
+$as_echo_n "checking for suffix of executables... " >&6; }
+if { { ac_try="$ac_link"
+case "(($ac_try" in
+ *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+ *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
+$as_echo "$ac_try_echo"; } >&5
+ (eval "$ac_link") 2>&5
+ ac_status=$?
+ $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+ test $ac_status = 0; }; then :
+ # If both `conftest.exe' and `conftest' are `present' (well, observable)
+# catch `conftest.exe'. For instance with Cygwin, `ls conftest' will
+# work properly (i.e., refer to `conftest.exe'), while it won't with
+# `rm'.
+for ac_file in conftest.exe conftest conftest.*; do
+ test -f "$ac_file" || continue
+ case $ac_file in
+ *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) ;;
+ *.* ) ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'`
+ break;;
+ * ) break;;
+ esac
+done
+else
+ { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
+$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
+as_fn_error $? "cannot compute suffix of executables: cannot compile and link
+See \`config.log' for more details" "$LINENO" 5; }
+fi
+rm -f conftest conftest$ac_cv_exeext
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_exeext" >&5
+$as_echo "$ac_cv_exeext" >&6; }
+
+rm -f conftest.$ac_ext
+EXEEXT=$ac_cv_exeext
+ac_exeext=$EXEEXT
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+#include <stdio.h>
+int
+main ()
+{
+FILE *f = fopen ("conftest.out", "w");
+ return ferror (f) || fclose (f) != 0;
+
+ ;
+ return 0;
+}
+_ACEOF
+ac_clean_files="$ac_clean_files conftest.out"
+# Check that the compiler produces executables we can run. If not, either
+# the compiler is broken, or we cross compile.
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are cross compiling" >&5
+$as_echo_n "checking whether we are cross compiling... " >&6; }
+if test "$cross_compiling" != yes; then
+ { { ac_try="$ac_link"
+case "(($ac_try" in
+ *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+ *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
+$as_echo "$ac_try_echo"; } >&5
+ (eval "$ac_link") 2>&5
+ ac_status=$?
+ $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+ test $ac_status = 0; }
+ if { ac_try='./conftest$ac_cv_exeext'
+ { { case "(($ac_try" in
+ *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+ *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
+$as_echo "$ac_try_echo"; } >&5
+ (eval "$ac_try") 2>&5
+ ac_status=$?
+ $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+ test $ac_status = 0; }; }; then
+ cross_compiling=no
+ else
+ if test "$cross_compiling" = maybe; then
+ cross_compiling=yes
+ else
+ { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
+$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
+as_fn_error $? "cannot run C compiled programs.
+If you meant to cross compile, use \`--host'.
+See \`config.log' for more details" "$LINENO" 5; }
+ fi
+ fi
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $cross_compiling" >&5
+$as_echo "$cross_compiling" >&6; }
+
+rm -f conftest.$ac_ext conftest$ac_cv_exeext conftest.out
+ac_clean_files=$ac_clean_files_save
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for suffix of object files" >&5
+$as_echo_n "checking for suffix of object files... " >&6; }
+if ${ac_cv_objext+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+
+int
+main ()
+{
+
+ ;
+ return 0;
+}
+_ACEOF
+rm -f conftest.o conftest.obj
+if { { ac_try="$ac_compile"
+case "(($ac_try" in
+ *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+ *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
+$as_echo "$ac_try_echo"; } >&5
+ (eval "$ac_compile") 2>&5
+ ac_status=$?
+ $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+ test $ac_status = 0; }; then :
+ for ac_file in conftest.o conftest.obj conftest.*; do
+ test -f "$ac_file" || continue;
+ case $ac_file in
+ *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM ) ;;
+ *) ac_cv_objext=`expr "$ac_file" : '.*\.\(.*\)'`
+ break;;
+ esac
+done
+else
+ $as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+{ { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
+$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
+as_fn_error $? "cannot compute suffix of object files: cannot compile
+See \`config.log' for more details" "$LINENO" 5; }
+fi
+rm -f conftest.$ac_cv_objext conftest.$ac_ext
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_objext" >&5
+$as_echo "$ac_cv_objext" >&6; }
+OBJEXT=$ac_cv_objext
+ac_objext=$OBJEXT
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are using the GNU C compiler" >&5
+$as_echo_n "checking whether we are using the GNU C compiler... " >&6; }
+if ${ac_cv_c_compiler_gnu+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+
+int
+main ()
+{
+#ifndef __GNUC__
+ choke me
+#endif
+
+ ;
+ return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+ ac_compiler_gnu=yes
+else
+ ac_compiler_gnu=no
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+ac_cv_c_compiler_gnu=$ac_compiler_gnu
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_compiler_gnu" >&5
+$as_echo "$ac_cv_c_compiler_gnu" >&6; }
+if test $ac_compiler_gnu = yes; then
+ GCC=yes
+else
+ GCC=
+fi
+ac_test_CFLAGS=${CFLAGS+set}
+ac_save_CFLAGS=$CFLAGS
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CC accepts -g" >&5
+$as_echo_n "checking whether $CC accepts -g... " >&6; }
+if ${ac_cv_prog_cc_g+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ ac_save_c_werror_flag=$ac_c_werror_flag
+ ac_c_werror_flag=yes
+ ac_cv_prog_cc_g=no
+ CFLAGS="-g"
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+
+int
+main ()
+{
+
+ ;
+ return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+ ac_cv_prog_cc_g=yes
+else
+ CFLAGS=""
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+
+int
+main ()
+{
+
+ ;
+ return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+
+else
+ ac_c_werror_flag=$ac_save_c_werror_flag
+ CFLAGS="-g"
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+
+int
+main ()
+{
+
+ ;
+ return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+ ac_cv_prog_cc_g=yes
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+ ac_c_werror_flag=$ac_save_c_werror_flag
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_g" >&5
+$as_echo "$ac_cv_prog_cc_g" >&6; }
+if test "$ac_test_CFLAGS" = set; then
+ CFLAGS=$ac_save_CFLAGS
+elif test $ac_cv_prog_cc_g = yes; then
+ if test "$GCC" = yes; then
+ CFLAGS="-g -O2"
+ else
+ CFLAGS="-g"
+ fi
+else
+ if test "$GCC" = yes; then
+ CFLAGS="-O2"
+ else
+ CFLAGS=
+ fi
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $CC option to accept ISO C89" >&5
+$as_echo_n "checking for $CC option to accept ISO C89... " >&6; }
+if ${ac_cv_prog_cc_c89+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ ac_cv_prog_cc_c89=no
+ac_save_CC=$CC
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+#include <stdarg.h>
+#include <stdio.h>
+struct stat;
+/* Most of the following tests are stolen from RCS 5.7's src/conf.sh. */
+struct buf { int x; };
+FILE * (*rcsopen) (struct buf *, struct stat *, int);
+static char *e (p, i)
+ char **p;
+ int i;
+{
+ return p[i];
+}
+static char *f (char * (*g) (char **, int), char **p, ...)
+{
+ char *s;
+ va_list v;
+ va_start (v,p);
+ s = g (p, va_arg (v,int));
+ va_end (v);
+ return s;
+}
+
+/* OSF 4.0 Compaq cc is some sort of almost-ANSI by default. It has
+ function prototypes and stuff, but not '\xHH' hex character constants.
+ These don't provoke an error unfortunately, instead are silently treated
+ as 'x'. The following induces an error, until -std is added to get
+ proper ANSI mode. Curiously '\x00'!='x' always comes out true, for an
+ array size at least. It's necessary to write '\x00'==0 to get something
+ that's true only with -std. */
+int osf4_cc_array ['\x00' == 0 ? 1 : -1];
+
+/* IBM C 6 for AIX is almost-ANSI by default, but it replaces macro parameters
+ inside strings and character constants. */
+#define FOO(x) 'x'
+int xlc6_cc_array[FOO(a) == 'x' ? 1 : -1];
+
+int test (int i, double x);
+struct s1 {int (*f) (int a);};
+struct s2 {int (*f) (double a);};
+int pairnames (int, char **, FILE *(*)(struct buf *, struct stat *, int), int, int);
+int argc;
+char **argv;
+int
+main ()
+{
+return f (e, argv, 0) != argv[0] || f (e, argv, 1) != argv[1];
+ ;
+ return 0;
+}
+_ACEOF
+for ac_arg in '' -qlanglvl=extc89 -qlanglvl=ansi -std \
+ -Ae "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__"
+do
+ CC="$ac_save_CC $ac_arg"
+ if ac_fn_c_try_compile "$LINENO"; then :
+ ac_cv_prog_cc_c89=$ac_arg
+fi
+rm -f core conftest.err conftest.$ac_objext
+ test "x$ac_cv_prog_cc_c89" != "xno" && break
+done
+rm -f conftest.$ac_ext
+CC=$ac_save_CC
+
+fi
+# AC_CACHE_VAL
+case "x$ac_cv_prog_cc_c89" in
+ x)
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: none needed" >&5
+$as_echo "none needed" >&6; } ;;
+ xno)
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: unsupported" >&5
+$as_echo "unsupported" >&6; } ;;
+ *)
+ CC="$CC $ac_cv_prog_cc_c89"
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_c89" >&5
+$as_echo "$ac_cv_prog_cc_c89" >&6; } ;;
+esac
+if test "x$ac_cv_prog_cc_c89" != xno; then :
+
+fi
+
+ac_ext=c
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
+DEPDIR="${am__leading_dot}deps"
+
+ac_config_commands="$ac_config_commands depfiles"
+
+
+am_make=${MAKE-make}
+cat > confinc << 'END'
+am__doit:
+ @echo this is the am__doit target
+.PHONY: am__doit
+END
+# If we don't find an include directive, just comment out the code.
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for style of include used by $am_make" >&5
+$as_echo_n "checking for style of include used by $am_make... " >&6; }
+am__include="#"
+am__quote=
+_am_result=none
+# First try GNU make style include.
+echo "include confinc" > confmf
+# Ignore all kinds of additional output from 'make'.
+case `$am_make -s -f confmf 2> /dev/null` in #(
+*the\ am__doit\ target*)
+ am__include=include
+ am__quote=
+ _am_result=GNU
+ ;;
+esac
+# Now try BSD make style include.
+if test "$am__include" = "#"; then
+ echo '.include "confinc"' > confmf
+ case `$am_make -s -f confmf 2> /dev/null` in #(
+ *the\ am__doit\ target*)
+ am__include=.include
+ am__quote="\""
+ _am_result=BSD
+ ;;
+ esac
+fi
+
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $_am_result" >&5
+$as_echo "$_am_result" >&6; }
+rm -f confinc confmf
+
+# Check whether --enable-dependency-tracking was given.
+if test "${enable_dependency_tracking+set}" = set; then :
+ enableval=$enable_dependency_tracking;
+fi
+
+if test "x$enable_dependency_tracking" != xno; then
+ am_depcomp="$ac_aux_dir/depcomp"
+ AMDEPBACKSLASH='\'
+ am__nodep='_no'
+fi
+ if test "x$enable_dependency_tracking" != xno; then
+ AMDEP_TRUE=
+ AMDEP_FALSE='#'
+else
+ AMDEP_TRUE='#'
+ AMDEP_FALSE=
+fi
+
+
+
+depcc="$CC" am_compiler_list=
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking dependency style of $depcc" >&5
+$as_echo_n "checking dependency style of $depcc... " >&6; }
+if ${am_cv_CC_dependencies_compiler_type+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ if test -z "$AMDEP_TRUE" && test -f "$am_depcomp"; then
+ # We make a subdir and do the tests there. Otherwise we can end up
+ # making bogus files that we don't know about and never remove. For
+ # instance it was reported that on HP-UX the gcc test will end up
+ # making a dummy file named 'D' -- because '-MD' means "put the output
+ # in D".
+ rm -rf conftest.dir
+ mkdir conftest.dir
+ # Copy depcomp to subdir because otherwise we won't find it if we're
+ # using a relative directory.
+ cp "$am_depcomp" conftest.dir
+ cd conftest.dir
+ # We will build objects and dependencies in a subdirectory because
+ # it helps to detect inapplicable dependency modes. For instance
+ # both Tru64's cc and ICC support -MD to output dependencies as a
+ # side effect of compilation, but ICC will put the dependencies in
+ # the current directory while Tru64 will put them in the object
+ # directory.
+ mkdir sub
+
+ am_cv_CC_dependencies_compiler_type=none
+ if test "$am_compiler_list" = ""; then
+ am_compiler_list=`sed -n 's/^#*\([a-zA-Z0-9]*\))$/\1/p' < ./depcomp`
+ fi
+ am__universal=false
+ case " $depcc " in #(
+ *\ -arch\ *\ -arch\ *) am__universal=true ;;
+ esac
+
+ for depmode in $am_compiler_list; do
+ # Setup a source with many dependencies, because some compilers
+ # like to wrap large dependency lists on column 80 (with \), and
+ # we should not choose a depcomp mode which is confused by this.
+ #
+ # We need to recreate these files for each test, as the compiler may
+ # overwrite some of them when testing with obscure command lines.
+ # This happens at least with the AIX C compiler.
+ : > sub/conftest.c
+ for i in 1 2 3 4 5 6; do
+ echo '#include "conftst'$i'.h"' >> sub/conftest.c
+ # Using ": > sub/conftst$i.h" creates only sub/conftst1.h with
+ # Solaris 10 /bin/sh.
+ echo '/* dummy */' > sub/conftst$i.h
+ done
+ echo "${am__include} ${am__quote}sub/conftest.Po${am__quote}" > confmf
+
+ # We check with '-c' and '-o' for the sake of the "dashmstdout"
+ # mode. It turns out that the SunPro C++ compiler does not properly
+ # handle '-M -o', and we need to detect this. Also, some Intel
+ # versions had trouble with output in subdirs.
+ am__obj=sub/conftest.${OBJEXT-o}
+ am__minus_obj="-o $am__obj"
+ case $depmode in
+ gcc)
+ # This depmode causes a compiler race in universal mode.
+ test "$am__universal" = false || continue
+ ;;
+ nosideeffect)
+ # After this tag, mechanisms are not by side-effect, so they'll
+ # only be used when explicitly requested.
+ if test "x$enable_dependency_tracking" = xyes; then
+ continue
+ else
+ break
+ fi
+ ;;
+ msvc7 | msvc7msys | msvisualcpp | msvcmsys)
+ # This compiler won't grok '-c -o', but also, the minuso test has
+ # not run yet. These depmodes are late enough in the game, and
+ # so weak that their functioning should not be impacted.
+ am__obj=conftest.${OBJEXT-o}
+ am__minus_obj=
+ ;;
+ none) break ;;
+ esac
+ if depmode=$depmode \
+ source=sub/conftest.c object=$am__obj \
+ depfile=sub/conftest.Po tmpdepfile=sub/conftest.TPo \
+ $SHELL ./depcomp $depcc -c $am__minus_obj sub/conftest.c \
+ >/dev/null 2>conftest.err &&
+ grep sub/conftst1.h sub/conftest.Po > /dev/null 2>&1 &&
+ grep sub/conftst6.h sub/conftest.Po > /dev/null 2>&1 &&
+ grep $am__obj sub/conftest.Po > /dev/null 2>&1 &&
+ ${MAKE-make} -s -f confmf > /dev/null 2>&1; then
+ # icc doesn't choke on unknown options, it will just issue warnings
+ # or remarks (even with -Werror). So we grep stderr for any message
+ # that says an option was ignored or not supported.
+ # When given -MP, icc 7.0 and 7.1 complain thusly:
+ # icc: Command line warning: ignoring option '-M'; no argument required
+ # The diagnosis changed in icc 8.0:
+ # icc: Command line remark: option '-MP' not supported
+ if (grep 'ignoring option' conftest.err ||
+ grep 'not supported' conftest.err) >/dev/null 2>&1; then :; else
+ am_cv_CC_dependencies_compiler_type=$depmode
+ break
+ fi
+ fi
+ done
+
+ cd ..
+ rm -rf conftest.dir
+else
+ am_cv_CC_dependencies_compiler_type=none
+fi
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $am_cv_CC_dependencies_compiler_type" >&5
+$as_echo "$am_cv_CC_dependencies_compiler_type" >&6; }
+CCDEPMODE=depmode=$am_cv_CC_dependencies_compiler_type
+
+ if
+ test "x$enable_dependency_tracking" != xno \
+ && test "$am_cv_CC_dependencies_compiler_type" = gcc3; then
+ am__fastdepCC_TRUE=
+ am__fastdepCC_FALSE='#'
+else
+ am__fastdepCC_TRUE='#'
+ am__fastdepCC_FALSE=
+fi
+
+
+ac_ext=cpp
+ac_cpp='$CXXCPP $CPPFLAGS'
+ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_cxx_compiler_gnu
+if test -z "$CXX"; then
+ if test -n "$CCC"; then
+ CXX=$CCC
+ else
+ if test -n "$ac_tool_prefix"; then
+ for ac_prog in g++ c++ gpp aCC CC cxx cc++ cl.exe FCC KCC RCC xlC_r xlC
+ do
+ # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args.
+set dummy $ac_tool_prefix$ac_prog; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if ${ac_cv_prog_CXX+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ if test -n "$CXX"; then
+ ac_cv_prog_CXX="$CXX" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ for ac_exec_ext in '' $ac_executable_extensions; do
+ if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+ ac_cv_prog_CXX="$ac_tool_prefix$ac_prog"
+ $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+ break 2
+ fi
+done
+ done
+IFS=$as_save_IFS
+
+fi
+fi
+CXX=$ac_cv_prog_CXX
+if test -n "$CXX"; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CXX" >&5
+$as_echo "$CXX" >&6; }
+else
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+ test -n "$CXX" && break
+ done
+fi
+if test -z "$CXX"; then
+ ac_ct_CXX=$CXX
+ for ac_prog in g++ c++ gpp aCC CC cxx cc++ cl.exe FCC KCC RCC xlC_r xlC
+do
+ # Extract the first word of "$ac_prog", so it can be a program name with args.
+set dummy $ac_prog; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if ${ac_cv_prog_ac_ct_CXX+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ if test -n "$ac_ct_CXX"; then
+ ac_cv_prog_ac_ct_CXX="$ac_ct_CXX" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ for ac_exec_ext in '' $ac_executable_extensions; do
+ if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+ ac_cv_prog_ac_ct_CXX="$ac_prog"
+ $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+ break 2
+ fi
+done
+ done
+IFS=$as_save_IFS
+
+fi
+fi
+ac_ct_CXX=$ac_cv_prog_ac_ct_CXX
+if test -n "$ac_ct_CXX"; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CXX" >&5
+$as_echo "$ac_ct_CXX" >&6; }
+else
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+ test -n "$ac_ct_CXX" && break
+done
+
+ if test "x$ac_ct_CXX" = x; then
+ CXX="g++"
+ else
+ case $cross_compiling:$ac_tool_warned in
+yes:)
+{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
+$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
+ac_tool_warned=yes ;;
+esac
+ CXX=$ac_ct_CXX
+ fi
+fi
+
+ fi
+fi
+# Provide some information about the compiler.
+$as_echo "$as_me:${as_lineno-$LINENO}: checking for C++ compiler version" >&5
+set X $ac_compile
+ac_compiler=$2
+for ac_option in --version -v -V -qversion; do
+ { { ac_try="$ac_compiler $ac_option >&5"
+case "(($ac_try" in
+ *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+ *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
+$as_echo "$ac_try_echo"; } >&5
+ (eval "$ac_compiler $ac_option >&5") 2>conftest.err
+ ac_status=$?
+ if test -s conftest.err; then
+ sed '10a\
+... rest of stderr output deleted ...
+ 10q' conftest.err >conftest.er1
+ cat conftest.er1 >&5
+ fi
+ rm -f conftest.er1 conftest.err
+ $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+ test $ac_status = 0; }
+done
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are using the GNU C++ compiler" >&5
+$as_echo_n "checking whether we are using the GNU C++ compiler... " >&6; }
+if ${ac_cv_cxx_compiler_gnu+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+
+int
+main ()
+{
+#ifndef __GNUC__
+ choke me
+#endif
+
+ ;
+ return 0;
+}
+_ACEOF
+if ac_fn_cxx_try_compile "$LINENO"; then :
+ ac_compiler_gnu=yes
+else
+ ac_compiler_gnu=no
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+ac_cv_cxx_compiler_gnu=$ac_compiler_gnu
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_cxx_compiler_gnu" >&5
+$as_echo "$ac_cv_cxx_compiler_gnu" >&6; }
+if test $ac_compiler_gnu = yes; then
+ GXX=yes
+else
+ GXX=
+fi
+ac_test_CXXFLAGS=${CXXFLAGS+set}
+ac_save_CXXFLAGS=$CXXFLAGS
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CXX accepts -g" >&5
+$as_echo_n "checking whether $CXX accepts -g... " >&6; }
+if ${ac_cv_prog_cxx_g+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ ac_save_cxx_werror_flag=$ac_cxx_werror_flag
+ ac_cxx_werror_flag=yes
+ ac_cv_prog_cxx_g=no
+ CXXFLAGS="-g"
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+
+int
+main ()
+{
+
+ ;
+ return 0;
+}
+_ACEOF
+if ac_fn_cxx_try_compile "$LINENO"; then :
+ ac_cv_prog_cxx_g=yes
+else
+ CXXFLAGS=""
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+
+int
+main ()
+{
+
+ ;
+ return 0;
+}
+_ACEOF
+if ac_fn_cxx_try_compile "$LINENO"; then :
+
+else
+ ac_cxx_werror_flag=$ac_save_cxx_werror_flag
+ CXXFLAGS="-g"
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+
+int
+main ()
+{
+
+ ;
+ return 0;
+}
+_ACEOF
+if ac_fn_cxx_try_compile "$LINENO"; then :
+ ac_cv_prog_cxx_g=yes
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+ ac_cxx_werror_flag=$ac_save_cxx_werror_flag
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cxx_g" >&5
+$as_echo "$ac_cv_prog_cxx_g" >&6; }
+if test "$ac_test_CXXFLAGS" = set; then
+ CXXFLAGS=$ac_save_CXXFLAGS
+elif test $ac_cv_prog_cxx_g = yes; then
+ if test "$GXX" = yes; then
+ CXXFLAGS="-g -O2"
+ else
+ CXXFLAGS="-g"
+ fi
+else
+ if test "$GXX" = yes; then
+ CXXFLAGS="-O2"
+ else
+ CXXFLAGS=
+ fi
+fi
+ac_ext=c
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
+
+depcc="$CXX" am_compiler_list=
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking dependency style of $depcc" >&5
+$as_echo_n "checking dependency style of $depcc... " >&6; }
+if ${am_cv_CXX_dependencies_compiler_type+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ if test -z "$AMDEP_TRUE" && test -f "$am_depcomp"; then
+ # We make a subdir and do the tests there. Otherwise we can end up
+ # making bogus files that we don't know about and never remove. For
+ # instance it was reported that on HP-UX the gcc test will end up
+ # making a dummy file named 'D' -- because '-MD' means "put the output
+ # in D".
+ rm -rf conftest.dir
+ mkdir conftest.dir
+ # Copy depcomp to subdir because otherwise we won't find it if we're
+ # using a relative directory.
+ cp "$am_depcomp" conftest.dir
+ cd conftest.dir
+ # We will build objects and dependencies in a subdirectory because
+ # it helps to detect inapplicable dependency modes. For instance
+ # both Tru64's cc and ICC support -MD to output dependencies as a
+ # side effect of compilation, but ICC will put the dependencies in
+ # the current directory while Tru64 will put them in the object
+ # directory.
+ mkdir sub
+
+ am_cv_CXX_dependencies_compiler_type=none
+ if test "$am_compiler_list" = ""; then
+ am_compiler_list=`sed -n 's/^#*\([a-zA-Z0-9]*\))$/\1/p' < ./depcomp`
+ fi
+ am__universal=false
+ case " $depcc " in #(
+ *\ -arch\ *\ -arch\ *) am__universal=true ;;
+ esac
+
+ for depmode in $am_compiler_list; do
+ # Setup a source with many dependencies, because some compilers
+ # like to wrap large dependency lists on column 80 (with \), and
+ # we should not choose a depcomp mode which is confused by this.
+ #
+ # We need to recreate these files for each test, as the compiler may
+ # overwrite some of them when testing with obscure command lines.
+ # This happens at least with the AIX C compiler.
+ : > sub/conftest.c
+ for i in 1 2 3 4 5 6; do
+ echo '#include "conftst'$i'.h"' >> sub/conftest.c
+ # Using ": > sub/conftst$i.h" creates only sub/conftst1.h with
+ # Solaris 10 /bin/sh.
+ echo '/* dummy */' > sub/conftst$i.h
+ done
+ echo "${am__include} ${am__quote}sub/conftest.Po${am__quote}" > confmf
+
+ # We check with '-c' and '-o' for the sake of the "dashmstdout"
+ # mode. It turns out that the SunPro C++ compiler does not properly
+ # handle '-M -o', and we need to detect this. Also, some Intel
+ # versions had trouble with output in subdirs.
+ am__obj=sub/conftest.${OBJEXT-o}
+ am__minus_obj="-o $am__obj"
+ case $depmode in
+ gcc)
+ # This depmode causes a compiler race in universal mode.
+ test "$am__universal" = false || continue
+ ;;
+ nosideeffect)
+ # After this tag, mechanisms are not by side-effect, so they'll
+ # only be used when explicitly requested.
+ if test "x$enable_dependency_tracking" = xyes; then
+ continue
+ else
+ break
+ fi
+ ;;
+ msvc7 | msvc7msys | msvisualcpp | msvcmsys)
+ # This compiler won't grok '-c -o', but also, the minuso test has
+ # not run yet. These depmodes are late enough in the game, and
+ # so weak that their functioning should not be impacted.
+ am__obj=conftest.${OBJEXT-o}
+ am__minus_obj=
+ ;;
+ none) break ;;
+ esac
+ if depmode=$depmode \
+ source=sub/conftest.c object=$am__obj \
+ depfile=sub/conftest.Po tmpdepfile=sub/conftest.TPo \
+ $SHELL ./depcomp $depcc -c $am__minus_obj sub/conftest.c \
+ >/dev/null 2>conftest.err &&
+ grep sub/conftst1.h sub/conftest.Po > /dev/null 2>&1 &&
+ grep sub/conftst6.h sub/conftest.Po > /dev/null 2>&1 &&
+ grep $am__obj sub/conftest.Po > /dev/null 2>&1 &&
+ ${MAKE-make} -s -f confmf > /dev/null 2>&1; then
+ # icc doesn't choke on unknown options, it will just issue warnings
+ # or remarks (even with -Werror). So we grep stderr for any message
+ # that says an option was ignored or not supported.
+ # When given -MP, icc 7.0 and 7.1 complain thusly:
+ # icc: Command line warning: ignoring option '-M'; no argument required
+ # The diagnosis changed in icc 8.0:
+ # icc: Command line remark: option '-MP' not supported
+ if (grep 'ignoring option' conftest.err ||
+ grep 'not supported' conftest.err) >/dev/null 2>&1; then :; else
+ am_cv_CXX_dependencies_compiler_type=$depmode
+ break
+ fi
+ fi
+ done
+
+ cd ..
+ rm -rf conftest.dir
+else
+ am_cv_CXX_dependencies_compiler_type=none
+fi
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $am_cv_CXX_dependencies_compiler_type" >&5
+$as_echo "$am_cv_CXX_dependencies_compiler_type" >&6; }
+CXXDEPMODE=depmode=$am_cv_CXX_dependencies_compiler_type
+
+ if
+ test "x$enable_dependency_tracking" != xno \
+ && test "$am_cv_CXX_dependencies_compiler_type" = gcc3; then
+ am__fastdepCXX_TRUE=
+ am__fastdepCXX_FALSE='#'
+else
+ am__fastdepCXX_TRUE='#'
+ am__fastdepCXX_FALSE=
+fi
+
+
+CFLAGS=$save_CFLAGS
+
+
+
+
+
+# By default we simply use the C compiler to build assembly code.
+
+test "${CCAS+set}" = set || CCAS=$CC
+test "${CCASFLAGS+set}" = set || CCASFLAGS=$CFLAGS
+
+
+
+depcc="$CCAS" am_compiler_list=
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking dependency style of $depcc" >&5
+$as_echo_n "checking dependency style of $depcc... " >&6; }
+if ${am_cv_CCAS_dependencies_compiler_type+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ if test -z "$AMDEP_TRUE" && test -f "$am_depcomp"; then
+ # We make a subdir and do the tests there. Otherwise we can end up
+ # making bogus files that we don't know about and never remove. For
+ # instance it was reported that on HP-UX the gcc test will end up
+ # making a dummy file named 'D' -- because '-MD' means "put the output
+ # in D".
+ rm -rf conftest.dir
+ mkdir conftest.dir
+ # Copy depcomp to subdir because otherwise we won't find it if we're
+ # using a relative directory.
+ cp "$am_depcomp" conftest.dir
+ cd conftest.dir
+ # We will build objects and dependencies in a subdirectory because
+ # it helps to detect inapplicable dependency modes. For instance
+ # both Tru64's cc and ICC support -MD to output dependencies as a
+ # side effect of compilation, but ICC will put the dependencies in
+ # the current directory while Tru64 will put them in the object
+ # directory.
+ mkdir sub
+
+ am_cv_CCAS_dependencies_compiler_type=none
+ if test "$am_compiler_list" = ""; then
+ am_compiler_list=`sed -n 's/^#*\([a-zA-Z0-9]*\))$/\1/p' < ./depcomp`
+ fi
+ am__universal=false
+
+
+ for depmode in $am_compiler_list; do
+ # Setup a source with many dependencies, because some compilers
+ # like to wrap large dependency lists on column 80 (with \), and
+ # we should not choose a depcomp mode which is confused by this.
+ #
+ # We need to recreate these files for each test, as the compiler may
+ # overwrite some of them when testing with obscure command lines.
+ # This happens at least with the AIX C compiler.
+ : > sub/conftest.c
+ for i in 1 2 3 4 5 6; do
+ echo '#include "conftst'$i'.h"' >> sub/conftest.c
+ # Using ": > sub/conftst$i.h" creates only sub/conftst1.h with
+ # Solaris 10 /bin/sh.
+ echo '/* dummy */' > sub/conftst$i.h
+ done
+ echo "${am__include} ${am__quote}sub/conftest.Po${am__quote}" > confmf
+
+ # We check with '-c' and '-o' for the sake of the "dashmstdout"
+ # mode. It turns out that the SunPro C++ compiler does not properly
+ # handle '-M -o', and we need to detect this. Also, some Intel
+ # versions had trouble with output in subdirs.
+ am__obj=sub/conftest.${OBJEXT-o}
+ am__minus_obj="-o $am__obj"
+ case $depmode in
+ gcc)
+ # This depmode causes a compiler race in universal mode.
+ test "$am__universal" = false || continue
+ ;;
+ nosideeffect)
+ # After this tag, mechanisms are not by side-effect, so they'll
+ # only be used when explicitly requested.
+ if test "x$enable_dependency_tracking" = xyes; then
+ continue
+ else
+ break
+ fi
+ ;;
+ msvc7 | msvc7msys | msvisualcpp | msvcmsys)
+ # This compiler won't grok '-c -o', but also, the minuso test has
+ # not run yet. These depmodes are late enough in the game, and
+ # so weak that their functioning should not be impacted.
+ am__obj=conftest.${OBJEXT-o}
+ am__minus_obj=
+ ;;
+ none) break ;;
+ esac
+ if depmode=$depmode \
+ source=sub/conftest.c object=$am__obj \
+ depfile=sub/conftest.Po tmpdepfile=sub/conftest.TPo \
+ $SHELL ./depcomp $depcc -c $am__minus_obj sub/conftest.c \
+ >/dev/null 2>conftest.err &&
+ grep sub/conftst1.h sub/conftest.Po > /dev/null 2>&1 &&
+ grep sub/conftst6.h sub/conftest.Po > /dev/null 2>&1 &&
+ grep $am__obj sub/conftest.Po > /dev/null 2>&1 &&
+ ${MAKE-make} -s -f confmf > /dev/null 2>&1; then
+ # icc doesn't choke on unknown options, it will just issue warnings
+ # or remarks (even with -Werror). So we grep stderr for any message
+ # that says an option was ignored or not supported.
+ # When given -MP, icc 7.0 and 7.1 complain thusly:
+ # icc: Command line warning: ignoring option '-M'; no argument required
+ # The diagnosis changed in icc 8.0:
+ # icc: Command line remark: option '-MP' not supported
+ if (grep 'ignoring option' conftest.err ||
+ grep 'not supported' conftest.err) >/dev/null 2>&1; then :; else
+ am_cv_CCAS_dependencies_compiler_type=$depmode
+ break
+ fi
+ fi
+ done
+
+ cd ..
+ rm -rf conftest.dir
+else
+ am_cv_CCAS_dependencies_compiler_type=none
+fi
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $am_cv_CCAS_dependencies_compiler_type" >&5
+$as_echo "$am_cv_CCAS_dependencies_compiler_type" >&6; }
+CCASDEPMODE=depmode=$am_cv_CCAS_dependencies_compiler_type
+
+ if
+ test "x$enable_dependency_tracking" != xno \
+ && test "$am_cv_CCAS_dependencies_compiler_type" = gcc3; then
+ am__fastdepCCAS_TRUE=
+ am__fastdepCCAS_FALSE='#'
+else
+ am__fastdepCCAS_TRUE='#'
+ am__fastdepCCAS_FALSE=
+fi
+
+
+if test "x$CC" != xcc; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CC and cc understand -c and -o together" >&5
+$as_echo_n "checking whether $CC and cc understand -c and -o together... " >&6; }
+else
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether cc understands -c and -o together" >&5
+$as_echo_n "checking whether cc understands -c and -o together... " >&6; }
+fi
+set dummy $CC; ac_cc=`$as_echo "$2" |
+ sed 's/[^a-zA-Z0-9_]/_/g;s/^[0-9]/_/'`
+if eval \${ac_cv_prog_cc_${ac_cc}_c_o+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+
+int
+main ()
+{
+
+ ;
+ return 0;
+}
+_ACEOF
+# Make sure it works both with $CC and with simple cc.
+# We do the test twice because some compilers refuse to overwrite an
+# existing .o file with -o, though they will create one.
+ac_try='$CC -c conftest.$ac_ext -o conftest2.$ac_objext >&5'
+rm -f conftest2.*
+if { { case "(($ac_try" in
+ *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+ *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
+$as_echo "$ac_try_echo"; } >&5
+ (eval "$ac_try") 2>&5
+ ac_status=$?
+ $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+ test $ac_status = 0; } &&
+ test -f conftest2.$ac_objext && { { case "(($ac_try" in
+ *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+ *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
+$as_echo "$ac_try_echo"; } >&5
+ (eval "$ac_try") 2>&5
+ ac_status=$?
+ $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+ test $ac_status = 0; };
+then
+ eval ac_cv_prog_cc_${ac_cc}_c_o=yes
+ if test "x$CC" != xcc; then
+ # Test first that cc exists at all.
+ if { ac_try='cc -c conftest.$ac_ext >&5'
+ { { case "(($ac_try" in
+ *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+ *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
+$as_echo "$ac_try_echo"; } >&5
+ (eval "$ac_try") 2>&5
+ ac_status=$?
+ $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+ test $ac_status = 0; }; }; then
+ ac_try='cc -c conftest.$ac_ext -o conftest2.$ac_objext >&5'
+ rm -f conftest2.*
+ if { { case "(($ac_try" in
+ *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+ *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
+$as_echo "$ac_try_echo"; } >&5
+ (eval "$ac_try") 2>&5
+ ac_status=$?
+ $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+ test $ac_status = 0; } &&
+ test -f conftest2.$ac_objext && { { case "(($ac_try" in
+ *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+ *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
+$as_echo "$ac_try_echo"; } >&5
+ (eval "$ac_try") 2>&5
+ ac_status=$?
+ $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+ test $ac_status = 0; };
+ then
+ # cc works too.
+ :
+ else
+ # cc exists but doesn't like -o.
+ eval ac_cv_prog_cc_${ac_cc}_c_o=no
+ fi
+ fi
+ fi
+else
+ eval ac_cv_prog_cc_${ac_cc}_c_o=no
+fi
+rm -f core conftest*
+
+fi
+if eval test \$ac_cv_prog_cc_${ac_cc}_c_o = yes; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+$as_echo "yes" >&6; }
+else
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+
+$as_echo "#define NO_MINUS_C_MINUS_O 1" >>confdefs.h
+
+fi
+
+# FIXME: we rely on the cache variable name because
+# there is no other way.
+set dummy $CC
+am_cc=`echo $2 | sed 's/[^a-zA-Z0-9_]/_/g;s/^[0-9]/_/'`
+eval am_t=\$ac_cv_prog_cc_${am_cc}_c_o
+if test "$am_t" != yes; then
+ # Losing compiler, so override with the script.
+ # FIXME: It is wrong to rewrite CC.
+ # But if we don't then we get into trouble of one sort or another.
+ # A longer-term fix would be to have automake use am__CC in this case,
+ # and then we could set am__CC="\$(top_srcdir)/compile \$(CC)"
+ CC="$am_aux_dir/compile $CC"
+fi
+
+
+case `pwd` in
+ *\ * | *\ *)
+ { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Libtool does not cope well with whitespace in \`pwd\`" >&5
+$as_echo "$as_me: WARNING: Libtool does not cope well with whitespace in \`pwd\`" >&2;} ;;
+esac
+
+
+
+macro_version='2.4.2'
+macro_revision='1.3337'
+
+
+
+
+
+
+
+
+
+
+
+
+
+ltmain="$ac_aux_dir/ltmain.sh"
+
+# Backslashify metacharacters that are still active within
+# double-quoted strings.
+sed_quote_subst='s/\(["`$\\]\)/\\\1/g'
+
+# Same as above, but do not quote variable references.
+double_quote_subst='s/\(["`\\]\)/\\\1/g'
+
+# Sed substitution to delay expansion of an escaped shell variable in a
+# double_quote_subst'ed string.
+delay_variable_subst='s/\\\\\\\\\\\$/\\\\\\$/g'
+
+# Sed substitution to delay expansion of an escaped single quote.
+delay_single_quote_subst='s/'\''/'\'\\\\\\\'\''/g'
+
+# Sed substitution to avoid accidental globbing in evaled expressions
+no_glob_subst='s/\*/\\\*/g'
+
+ECHO='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\'
+ECHO=$ECHO$ECHO$ECHO$ECHO$ECHO
+ECHO=$ECHO$ECHO$ECHO$ECHO$ECHO$ECHO
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking how to print strings" >&5
+$as_echo_n "checking how to print strings... " >&6; }
+# Test print first, because it will be a builtin if present.
+if test "X`( print -r -- -n ) 2>/dev/null`" = X-n && \
+ test "X`print -r -- $ECHO 2>/dev/null`" = "X$ECHO"; then
+ ECHO='print -r --'
+elif test "X`printf %s $ECHO 2>/dev/null`" = "X$ECHO"; then
+ ECHO='printf %s\n'
+else
+ # Use this function as a fallback that always works.
+ func_fallback_echo ()
+ {
+ eval 'cat <<_LTECHO_EOF
+$1
+_LTECHO_EOF'
+ }
+ ECHO='func_fallback_echo'
+fi
+
+# func_echo_all arg...
+# Invoke $ECHO with all args, space-separated.
+func_echo_all ()
+{
+ $ECHO ""
+}
+
+case "$ECHO" in
+ printf*) { $as_echo "$as_me:${as_lineno-$LINENO}: result: printf" >&5
+$as_echo "printf" >&6; } ;;
+ print*) { $as_echo "$as_me:${as_lineno-$LINENO}: result: print -r" >&5
+$as_echo "print -r" >&6; } ;;
+ *) { $as_echo "$as_me:${as_lineno-$LINENO}: result: cat" >&5
+$as_echo "cat" >&6; } ;;
+esac
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for a sed that does not truncate output" >&5
+$as_echo_n "checking for a sed that does not truncate output... " >&6; }
+if ${ac_cv_path_SED+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ ac_script=s/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb/
+ for ac_i in 1 2 3 4 5 6 7; do
+ ac_script="$ac_script$as_nl$ac_script"
+ done
+ echo "$ac_script" 2>/dev/null | sed 99q >conftest.sed
+ { ac_script=; unset ac_script;}
+ if test -z "$SED"; then
+ ac_path_SED_found=false
+ # Loop through the user's path and test for each of PROGNAME-LIST
+ as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ for ac_prog in sed gsed; do
+ for ac_exec_ext in '' $ac_executable_extensions; do
+ ac_path_SED="$as_dir/$ac_prog$ac_exec_ext"
+ as_fn_executable_p "$ac_path_SED" || continue
+# Check for GNU ac_path_SED and select it if it is found.
+ # Check for GNU $ac_path_SED
+case `"$ac_path_SED" --version 2>&1` in
+*GNU*)
+ ac_cv_path_SED="$ac_path_SED" ac_path_SED_found=:;;
+*)
+ ac_count=0
+ $as_echo_n 0123456789 >"conftest.in"
+ while :
+ do
+ cat "conftest.in" "conftest.in" >"conftest.tmp"
+ mv "conftest.tmp" "conftest.in"
+ cp "conftest.in" "conftest.nl"
+ $as_echo '' >> "conftest.nl"
+ "$ac_path_SED" -f conftest.sed < "conftest.nl" >"conftest.out" 2>/dev/null || break
+ diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break
+ as_fn_arith $ac_count + 1 && ac_count=$as_val
+ if test $ac_count -gt ${ac_path_SED_max-0}; then
+ # Best one so far, save it but keep looking for a better one
+ ac_cv_path_SED="$ac_path_SED"
+ ac_path_SED_max=$ac_count
+ fi
+ # 10*(2^10) chars as input seems more than enough
+ test $ac_count -gt 10 && break
+ done
+ rm -f conftest.in conftest.tmp conftest.nl conftest.out;;
+esac
+
+ $ac_path_SED_found && break 3
+ done
+ done
+ done
+IFS=$as_save_IFS
+ if test -z "$ac_cv_path_SED"; then
+ as_fn_error $? "no acceptable sed could be found in \$PATH" "$LINENO" 5
+ fi
+else
+ ac_cv_path_SED=$SED
+fi
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_SED" >&5
+$as_echo "$ac_cv_path_SED" >&6; }
+ SED="$ac_cv_path_SED"
+ rm -f conftest.sed
+
+test -z "$SED" && SED=sed
+Xsed="$SED -e 1s/^X//"
+
+
+
+
+
+
+
+
+
+
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for grep that handles long lines and -e" >&5
+$as_echo_n "checking for grep that handles long lines and -e... " >&6; }
+if ${ac_cv_path_GREP+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ if test -z "$GREP"; then
+ ac_path_GREP_found=false
+ # Loop through the user's path and test for each of PROGNAME-LIST
+ as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin
+do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ for ac_prog in grep ggrep; do
+ for ac_exec_ext in '' $ac_executable_extensions; do
+ ac_path_GREP="$as_dir/$ac_prog$ac_exec_ext"
+ as_fn_executable_p "$ac_path_GREP" || continue
+# Check for GNU ac_path_GREP and select it if it is found.
+ # Check for GNU $ac_path_GREP
+case `"$ac_path_GREP" --version 2>&1` in
+*GNU*)
+ ac_cv_path_GREP="$ac_path_GREP" ac_path_GREP_found=:;;
+*)
+ ac_count=0
+ $as_echo_n 0123456789 >"conftest.in"
+ while :
+ do
+ cat "conftest.in" "conftest.in" >"conftest.tmp"
+ mv "conftest.tmp" "conftest.in"
+ cp "conftest.in" "conftest.nl"
+ $as_echo 'GREP' >> "conftest.nl"
+ "$ac_path_GREP" -e 'GREP$' -e '-(cannot match)-' < "conftest.nl" >"conftest.out" 2>/dev/null || break
+ diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break
+ as_fn_arith $ac_count + 1 && ac_count=$as_val
+ if test $ac_count -gt ${ac_path_GREP_max-0}; then
+ # Best one so far, save it but keep looking for a better one
+ ac_cv_path_GREP="$ac_path_GREP"
+ ac_path_GREP_max=$ac_count
+ fi
+ # 10*(2^10) chars as input seems more than enough
+ test $ac_count -gt 10 && break
+ done
+ rm -f conftest.in conftest.tmp conftest.nl conftest.out;;
+esac
+
+ $ac_path_GREP_found && break 3
+ done
+ done
+ done
+IFS=$as_save_IFS
+ if test -z "$ac_cv_path_GREP"; then
+ as_fn_error $? "no acceptable grep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5
+ fi
+else
+ ac_cv_path_GREP=$GREP
+fi
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_GREP" >&5
+$as_echo "$ac_cv_path_GREP" >&6; }
+ GREP="$ac_cv_path_GREP"
+
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for egrep" >&5
+$as_echo_n "checking for egrep... " >&6; }
+if ${ac_cv_path_EGREP+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ if echo a | $GREP -E '(a|b)' >/dev/null 2>&1
+ then ac_cv_path_EGREP="$GREP -E"
+ else
+ if test -z "$EGREP"; then
+ ac_path_EGREP_found=false
+ # Loop through the user's path and test for each of PROGNAME-LIST
+ as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin
+do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ for ac_prog in egrep; do
+ for ac_exec_ext in '' $ac_executable_extensions; do
+ ac_path_EGREP="$as_dir/$ac_prog$ac_exec_ext"
+ as_fn_executable_p "$ac_path_EGREP" || continue
+# Check for GNU ac_path_EGREP and select it if it is found.
+ # Check for GNU $ac_path_EGREP
+case `"$ac_path_EGREP" --version 2>&1` in
+*GNU*)
+ ac_cv_path_EGREP="$ac_path_EGREP" ac_path_EGREP_found=:;;
+*)
+ ac_count=0
+ $as_echo_n 0123456789 >"conftest.in"
+ while :
+ do
+ cat "conftest.in" "conftest.in" >"conftest.tmp"
+ mv "conftest.tmp" "conftest.in"
+ cp "conftest.in" "conftest.nl"
+ $as_echo 'EGREP' >> "conftest.nl"
+ "$ac_path_EGREP" 'EGREP$' < "conftest.nl" >"conftest.out" 2>/dev/null || break
+ diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break
+ as_fn_arith $ac_count + 1 && ac_count=$as_val
+ if test $ac_count -gt ${ac_path_EGREP_max-0}; then
+ # Best one so far, save it but keep looking for a better one
+ ac_cv_path_EGREP="$ac_path_EGREP"
+ ac_path_EGREP_max=$ac_count
+ fi
+ # 10*(2^10) chars as input seems more than enough
+ test $ac_count -gt 10 && break
+ done
+ rm -f conftest.in conftest.tmp conftest.nl conftest.out;;
+esac
+
+ $ac_path_EGREP_found && break 3
+ done
+ done
+ done
+IFS=$as_save_IFS
+ if test -z "$ac_cv_path_EGREP"; then
+ as_fn_error $? "no acceptable egrep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5
+ fi
+else
+ ac_cv_path_EGREP=$EGREP
+fi
+
+ fi
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_EGREP" >&5
+$as_echo "$ac_cv_path_EGREP" >&6; }
+ EGREP="$ac_cv_path_EGREP"
+
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for fgrep" >&5
+$as_echo_n "checking for fgrep... " >&6; }
+if ${ac_cv_path_FGREP+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ if echo 'ab*c' | $GREP -F 'ab*c' >/dev/null 2>&1
+ then ac_cv_path_FGREP="$GREP -F"
+ else
+ if test -z "$FGREP"; then
+ ac_path_FGREP_found=false
+ # Loop through the user's path and test for each of PROGNAME-LIST
+ as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin
+do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ for ac_prog in fgrep; do
+ for ac_exec_ext in '' $ac_executable_extensions; do
+ ac_path_FGREP="$as_dir/$ac_prog$ac_exec_ext"
+ as_fn_executable_p "$ac_path_FGREP" || continue
+# Check for GNU ac_path_FGREP and select it if it is found.
+ # Check for GNU $ac_path_FGREP
+case `"$ac_path_FGREP" --version 2>&1` in
+*GNU*)
+ ac_cv_path_FGREP="$ac_path_FGREP" ac_path_FGREP_found=:;;
+*)
+ ac_count=0
+ $as_echo_n 0123456789 >"conftest.in"
+ while :
+ do
+ cat "conftest.in" "conftest.in" >"conftest.tmp"
+ mv "conftest.tmp" "conftest.in"
+ cp "conftest.in" "conftest.nl"
+ $as_echo 'FGREP' >> "conftest.nl"
+ "$ac_path_FGREP" FGREP < "conftest.nl" >"conftest.out" 2>/dev/null || break
+ diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break
+ as_fn_arith $ac_count + 1 && ac_count=$as_val
+ if test $ac_count -gt ${ac_path_FGREP_max-0}; then
+ # Best one so far, save it but keep looking for a better one
+ ac_cv_path_FGREP="$ac_path_FGREP"
+ ac_path_FGREP_max=$ac_count
+ fi
+ # 10*(2^10) chars as input seems more than enough
+ test $ac_count -gt 10 && break
+ done
+ rm -f conftest.in conftest.tmp conftest.nl conftest.out;;
+esac
+
+ $ac_path_FGREP_found && break 3
+ done
+ done
+ done
+IFS=$as_save_IFS
+ if test -z "$ac_cv_path_FGREP"; then
+ as_fn_error $? "no acceptable fgrep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5
+ fi
+else
+ ac_cv_path_FGREP=$FGREP
+fi
+
+ fi
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_FGREP" >&5
+$as_echo "$ac_cv_path_FGREP" >&6; }
+ FGREP="$ac_cv_path_FGREP"
+
+
+test -z "$GREP" && GREP=grep
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+# Check whether --with-gnu-ld was given.
+if test "${with_gnu_ld+set}" = set; then :
+ withval=$with_gnu_ld; test "$withval" = no || with_gnu_ld=yes
+else
+ with_gnu_ld=no
+fi
+
+ac_prog=ld
+if test "$GCC" = yes; then
+ # Check if gcc -print-prog-name=ld gives a path.
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ld used by $CC" >&5
+$as_echo_n "checking for ld used by $CC... " >&6; }
+ case $host in
+ *-*-mingw*)
+ # gcc leaves a trailing carriage return which upsets mingw
+ ac_prog=`($CC -print-prog-name=ld) 2>&5 | tr -d '\015'` ;;
+ *)
+ ac_prog=`($CC -print-prog-name=ld) 2>&5` ;;
+ esac
+ case $ac_prog in
+ # Accept absolute paths.
+ [\\/]* | ?:[\\/]*)
+ re_direlt='/[^/][^/]*/\.\./'
+ # Canonicalize the pathname of ld
+ ac_prog=`$ECHO "$ac_prog"| $SED 's%\\\\%/%g'`
+ while $ECHO "$ac_prog" | $GREP "$re_direlt" > /dev/null 2>&1; do
+ ac_prog=`$ECHO $ac_prog| $SED "s%$re_direlt%/%"`
+ done
+ test -z "$LD" && LD="$ac_prog"
+ ;;
+ "")
+ # If it fails, then pretend we aren't using GCC.
+ ac_prog=ld
+ ;;
+ *)
+ # If it is relative, then search for the first ld in PATH.
+ with_gnu_ld=unknown
+ ;;
+ esac
+elif test "$with_gnu_ld" = yes; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for GNU ld" >&5
+$as_echo_n "checking for GNU ld... " >&6; }
+else
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for non-GNU ld" >&5
+$as_echo_n "checking for non-GNU ld... " >&6; }
+fi
+if ${lt_cv_path_LD+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ if test -z "$LD"; then
+ lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR
+ for ac_dir in $PATH; do
+ IFS="$lt_save_ifs"
+ test -z "$ac_dir" && ac_dir=.
+ if test -f "$ac_dir/$ac_prog" || test -f "$ac_dir/$ac_prog$ac_exeext"; then
+ lt_cv_path_LD="$ac_dir/$ac_prog"
+ # Check to see if the program is GNU ld. I'd rather use --version,
+ # but apparently some variants of GNU ld only accept -v.
+ # Break only if it was the GNU/non-GNU ld that we prefer.
+ case `"$lt_cv_path_LD" -v 2>&1 </dev/null` in
+ *GNU* | *'with BFD'*)
+ test "$with_gnu_ld" != no && break
+ ;;
+ *)
+ test "$with_gnu_ld" != yes && break
+ ;;
+ esac
+ fi
+ done
+ IFS="$lt_save_ifs"
+else
+ lt_cv_path_LD="$LD" # Let the user override the test with a path.
+fi
+fi
+
+LD="$lt_cv_path_LD"
+if test -n "$LD"; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $LD" >&5
+$as_echo "$LD" >&6; }
+else
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+test -z "$LD" && as_fn_error $? "no acceptable ld found in \$PATH" "$LINENO" 5
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if the linker ($LD) is GNU ld" >&5
+$as_echo_n "checking if the linker ($LD) is GNU ld... " >&6; }
+if ${lt_cv_prog_gnu_ld+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ # I'd rather use --version here, but apparently some GNU lds only accept -v.
+case `$LD -v 2>&1 </dev/null` in
+*GNU* | *'with BFD'*)
+ lt_cv_prog_gnu_ld=yes
+ ;;
+*)
+ lt_cv_prog_gnu_ld=no
+ ;;
+esac
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_gnu_ld" >&5
+$as_echo "$lt_cv_prog_gnu_ld" >&6; }
+with_gnu_ld=$lt_cv_prog_gnu_ld
+
+
+
+
+
+
+
+
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for BSD- or MS-compatible name lister (nm)" >&5
+$as_echo_n "checking for BSD- or MS-compatible name lister (nm)... " >&6; }
+if ${lt_cv_path_NM+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ if test -n "$NM"; then
+ # Let the user override the test.
+ lt_cv_path_NM="$NM"
+else
+ lt_nm_to_check="${ac_tool_prefix}nm"
+ if test -n "$ac_tool_prefix" && test "$build" = "$host"; then
+ lt_nm_to_check="$lt_nm_to_check nm"
+ fi
+ for lt_tmp_nm in $lt_nm_to_check; do
+ lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR
+ for ac_dir in $PATH /usr/ccs/bin/elf /usr/ccs/bin /usr/ucb /bin; do
+ IFS="$lt_save_ifs"
+ test -z "$ac_dir" && ac_dir=.
+ tmp_nm="$ac_dir/$lt_tmp_nm"
+ if test -f "$tmp_nm" || test -f "$tmp_nm$ac_exeext" ; then
+ # Check to see if the nm accepts a BSD-compat flag.
+ # Adding the `sed 1q' prevents false positives on HP-UX, which says:
+ # nm: unknown option "B" ignored
+ # Tru64's nm complains that /dev/null is an invalid object file
+ case `"$tmp_nm" -B /dev/null 2>&1 | sed '1q'` in
+ */dev/null* | *'Invalid file or object type'*)
+ lt_cv_path_NM="$tmp_nm -B"
+ break
+ ;;
+ *)
+ case `"$tmp_nm" -p /dev/null 2>&1 | sed '1q'` in
+ */dev/null*)
+ lt_cv_path_NM="$tmp_nm -p"
+ break
+ ;;
+ *)
+ lt_cv_path_NM=${lt_cv_path_NM="$tmp_nm"} # keep the first match, but
+ continue # so that we can try to find one that supports BSD flags
+ ;;
+ esac
+ ;;
+ esac
+ fi
+ done
+ IFS="$lt_save_ifs"
+ done
+ : ${lt_cv_path_NM=no}
+fi
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_path_NM" >&5
+$as_echo "$lt_cv_path_NM" >&6; }
+if test "$lt_cv_path_NM" != "no"; then
+ NM="$lt_cv_path_NM"
+else
+ # Didn't find any BSD compatible name lister, look for dumpbin.
+ if test -n "$DUMPBIN"; then :
+ # Let the user override the test.
+ else
+ if test -n "$ac_tool_prefix"; then
+ for ac_prog in dumpbin "link -dump"
+ do
+ # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args.
+set dummy $ac_tool_prefix$ac_prog; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if ${ac_cv_prog_DUMPBIN+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ if test -n "$DUMPBIN"; then
+ ac_cv_prog_DUMPBIN="$DUMPBIN" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ for ac_exec_ext in '' $ac_executable_extensions; do
+ if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+ ac_cv_prog_DUMPBIN="$ac_tool_prefix$ac_prog"
+ $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+ break 2
+ fi
+done
+ done
+IFS=$as_save_IFS
+
+fi
+fi
+DUMPBIN=$ac_cv_prog_DUMPBIN
+if test -n "$DUMPBIN"; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $DUMPBIN" >&5
+$as_echo "$DUMPBIN" >&6; }
+else
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+ test -n "$DUMPBIN" && break
+ done
+fi
+if test -z "$DUMPBIN"; then
+ ac_ct_DUMPBIN=$DUMPBIN
+ for ac_prog in dumpbin "link -dump"
+do
+ # Extract the first word of "$ac_prog", so it can be a program name with args.
+set dummy $ac_prog; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if ${ac_cv_prog_ac_ct_DUMPBIN+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ if test -n "$ac_ct_DUMPBIN"; then
+ ac_cv_prog_ac_ct_DUMPBIN="$ac_ct_DUMPBIN" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ for ac_exec_ext in '' $ac_executable_extensions; do
+ if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+ ac_cv_prog_ac_ct_DUMPBIN="$ac_prog"
+ $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+ break 2
+ fi
+done
+ done
+IFS=$as_save_IFS
+
+fi
+fi
+ac_ct_DUMPBIN=$ac_cv_prog_ac_ct_DUMPBIN
+if test -n "$ac_ct_DUMPBIN"; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_DUMPBIN" >&5
+$as_echo "$ac_ct_DUMPBIN" >&6; }
+else
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+ test -n "$ac_ct_DUMPBIN" && break
+done
+
+ if test "x$ac_ct_DUMPBIN" = x; then
+ DUMPBIN=":"
+ else
+ case $cross_compiling:$ac_tool_warned in
+yes:)
+{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
+$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
+ac_tool_warned=yes ;;
+esac
+ DUMPBIN=$ac_ct_DUMPBIN
+ fi
+fi
+
+ case `$DUMPBIN -symbols /dev/null 2>&1 | sed '1q'` in
+ *COFF*)
+ DUMPBIN="$DUMPBIN -symbols"
+ ;;
+ *)
+ DUMPBIN=:
+ ;;
+ esac
+ fi
+
+ if test "$DUMPBIN" != ":"; then
+ NM="$DUMPBIN"
+ fi
+fi
+test -z "$NM" && NM=nm
+
+
+
+
+
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking the name lister ($NM) interface" >&5
+$as_echo_n "checking the name lister ($NM) interface... " >&6; }
+if ${lt_cv_nm_interface+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ lt_cv_nm_interface="BSD nm"
+ echo "int some_variable = 0;" > conftest.$ac_ext
+ (eval echo "\"\$as_me:$LINENO: $ac_compile\"" >&5)
+ (eval "$ac_compile" 2>conftest.err)
+ cat conftest.err >&5
+ (eval echo "\"\$as_me:$LINENO: $NM \\\"conftest.$ac_objext\\\"\"" >&5)
+ (eval "$NM \"conftest.$ac_objext\"" 2>conftest.err > conftest.out)
+ cat conftest.err >&5
+ (eval echo "\"\$as_me:$LINENO: output\"" >&5)
+ cat conftest.out >&5
+ if $GREP 'External.*some_variable' conftest.out > /dev/null; then
+ lt_cv_nm_interface="MS dumpbin"
+ fi
+ rm -f conftest*
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_nm_interface" >&5
+$as_echo "$lt_cv_nm_interface" >&6; }
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether ln -s works" >&5
+$as_echo_n "checking whether ln -s works... " >&6; }
+LN_S=$as_ln_s
+if test "$LN_S" = "ln -s"; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+$as_echo "yes" >&6; }
+else
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no, using $LN_S" >&5
+$as_echo "no, using $LN_S" >&6; }
+fi
+
+# find the maximum length of command line arguments
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking the maximum length of command line arguments" >&5
+$as_echo_n "checking the maximum length of command line arguments... " >&6; }
+if ${lt_cv_sys_max_cmd_len+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ i=0
+ teststring="ABCD"
+
+ case $build_os in
+ msdosdjgpp*)
+ # On DJGPP, this test can blow up pretty badly due to problems in libc
+ # (any single argument exceeding 2000 bytes causes a buffer overrun
+ # during glob expansion). Even if it were fixed, the result of this
+ # check would be larger than it should be.
+ lt_cv_sys_max_cmd_len=12288; # 12K is about right
+ ;;
+
+ gnu*)
+ # Under GNU Hurd, this test is not required because there is
+ # no limit to the length of command line arguments.
+ # Libtool will interpret -1 as no limit whatsoever
+ lt_cv_sys_max_cmd_len=-1;
+ ;;
+
+ cygwin* | mingw* | cegcc*)
+ # On Win9x/ME, this test blows up -- it succeeds, but takes
+ # about 5 minutes as the teststring grows exponentially.
+ # Worse, since 9x/ME are not pre-emptively multitasking,
+ # you end up with a "frozen" computer, even though with patience
+ # the test eventually succeeds (with a max line length of 256k).
+ # Instead, let's just punt: use the minimum linelength reported by
+ # all of the supported platforms: 8192 (on NT/2K/XP).
+ lt_cv_sys_max_cmd_len=8192;
+ ;;
+
+ mint*)
+ # On MiNT this can take a long time and run out of memory.
+ lt_cv_sys_max_cmd_len=8192;
+ ;;
+
+ amigaos*)
+ # On AmigaOS with pdksh, this test takes hours, literally.
+ # So we just punt and use a minimum line length of 8192.
+ lt_cv_sys_max_cmd_len=8192;
+ ;;
+
+ netbsd* | freebsd* | openbsd* | darwin* | dragonfly*)
+ # This has been around since 386BSD, at least. Likely further.
+ if test -x /sbin/sysctl; then
+ lt_cv_sys_max_cmd_len=`/sbin/sysctl -n kern.argmax`
+ elif test -x /usr/sbin/sysctl; then
+ lt_cv_sys_max_cmd_len=`/usr/sbin/sysctl -n kern.argmax`
+ else
+ lt_cv_sys_max_cmd_len=65536 # usable default for all BSDs
+ fi
+ # And add a safety zone
+ lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 4`
+ lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \* 3`
+ ;;
+
+ interix*)
+ # We know the value 262144 and hardcode it with a safety zone (like BSD)
+ lt_cv_sys_max_cmd_len=196608
+ ;;
+
+ os2*)
+ # The test takes a long time on OS/2.
+ lt_cv_sys_max_cmd_len=8192
+ ;;
+
+ osf*)
+ # Dr. Hans Ekkehard Plesser reports seeing a kernel panic running configure
+ # due to this test when exec_disable_arg_limit is 1 on Tru64. It is not
+ # nice to cause kernel panics so lets avoid the loop below.
+ # First set a reasonable default.
+ lt_cv_sys_max_cmd_len=16384
+ #
+ if test -x /sbin/sysconfig; then
+ case `/sbin/sysconfig -q proc exec_disable_arg_limit` in
+ *1*) lt_cv_sys_max_cmd_len=-1 ;;
+ esac
+ fi
+ ;;
+ sco3.2v5*)
+ lt_cv_sys_max_cmd_len=102400
+ ;;
+ sysv5* | sco5v6* | sysv4.2uw2*)
+ kargmax=`grep ARG_MAX /etc/conf/cf.d/stune 2>/dev/null`
+ if test -n "$kargmax"; then
+ lt_cv_sys_max_cmd_len=`echo $kargmax | sed 's/.*[ ]//'`
+ else
+ lt_cv_sys_max_cmd_len=32768
+ fi
+ ;;
+ *)
+ lt_cv_sys_max_cmd_len=`(getconf ARG_MAX) 2> /dev/null`
+ if test -n "$lt_cv_sys_max_cmd_len"; then
+ lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 4`
+ lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \* 3`
+ else
+ # Make teststring a little bigger before we do anything with it.
+ # a 1K string should be a reasonable start.
+ for i in 1 2 3 4 5 6 7 8 ; do
+ teststring=$teststring$teststring
+ done
+ SHELL=${SHELL-${CONFIG_SHELL-/bin/sh}}
+ # If test is not a shell built-in, we'll probably end up computing a
+ # maximum length that is only half of the actual maximum length, but
+ # we can't tell.
+ while { test "X"`env echo "$teststring$teststring" 2>/dev/null` \
+ = "X$teststring$teststring"; } >/dev/null 2>&1 &&
+ test $i != 17 # 1/2 MB should be enough
+ do
+ i=`expr $i + 1`
+ teststring=$teststring$teststring
+ done
+ # Only check the string length outside the loop.
+ lt_cv_sys_max_cmd_len=`expr "X$teststring" : ".*" 2>&1`
+ teststring=
+ # Add a significant safety factor because C++ compilers can tack on
+ # massive amounts of additional arguments before passing them to the
+ # linker. It appears as though 1/2 is a usable value.
+ lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 2`
+ fi
+ ;;
+ esac
+
+fi
+
+if test -n $lt_cv_sys_max_cmd_len ; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_sys_max_cmd_len" >&5
+$as_echo "$lt_cv_sys_max_cmd_len" >&6; }
+else
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: none" >&5
+$as_echo "none" >&6; }
+fi
+max_cmd_len=$lt_cv_sys_max_cmd_len
+
+
+
+
+
+
+: ${CP="cp -f"}
+: ${MV="mv -f"}
+: ${RM="rm -f"}
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the shell understands some XSI constructs" >&5
+$as_echo_n "checking whether the shell understands some XSI constructs... " >&6; }
+# Try some XSI features
+xsi_shell=no
+( _lt_dummy="a/b/c"
+ test "${_lt_dummy##*/},${_lt_dummy%/*},${_lt_dummy#??}"${_lt_dummy%"$_lt_dummy"}, \
+ = c,a/b,b/c, \
+ && eval 'test $(( 1 + 1 )) -eq 2 \
+ && test "${#_lt_dummy}" -eq 5' ) >/dev/null 2>&1 \
+ && xsi_shell=yes
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $xsi_shell" >&5
+$as_echo "$xsi_shell" >&6; }
+
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the shell understands \"+=\"" >&5
+$as_echo_n "checking whether the shell understands \"+=\"... " >&6; }
+lt_shell_append=no
+( foo=bar; set foo baz; eval "$1+=\$2" && test "$foo" = barbaz ) \
+ >/dev/null 2>&1 \
+ && lt_shell_append=yes
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_shell_append" >&5
+$as_echo "$lt_shell_append" >&6; }
+
+
+if ( (MAIL=60; unset MAIL) || exit) >/dev/null 2>&1; then
+ lt_unset=unset
+else
+ lt_unset=false
+fi
+
+
+
+
+
+# test EBCDIC or ASCII
+case `echo X|tr X '\101'` in
+ A) # ASCII based system
+ # \n is not interpreted correctly by Solaris 8 /usr/ucb/tr
+ lt_SP2NL='tr \040 \012'
+ lt_NL2SP='tr \015\012 \040\040'
+ ;;
+ *) # EBCDIC based system
+ lt_SP2NL='tr \100 \n'
+ lt_NL2SP='tr \r\n \100\100'
+ ;;
+esac
+
+
+
+
+
+
+
+
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking how to convert $build file names to $host format" >&5
+$as_echo_n "checking how to convert $build file names to $host format... " >&6; }
+if ${lt_cv_to_host_file_cmd+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ case $host in
+ *-*-mingw* )
+ case $build in
+ *-*-mingw* ) # actually msys
+ lt_cv_to_host_file_cmd=func_convert_file_msys_to_w32
+ ;;
+ *-*-cygwin* )
+ lt_cv_to_host_file_cmd=func_convert_file_cygwin_to_w32
+ ;;
+ * ) # otherwise, assume *nix
+ lt_cv_to_host_file_cmd=func_convert_file_nix_to_w32
+ ;;
+ esac
+ ;;
+ *-*-cygwin* )
+ case $build in
+ *-*-mingw* ) # actually msys
+ lt_cv_to_host_file_cmd=func_convert_file_msys_to_cygwin
+ ;;
+ *-*-cygwin* )
+ lt_cv_to_host_file_cmd=func_convert_file_noop
+ ;;
+ * ) # otherwise, assume *nix
+ lt_cv_to_host_file_cmd=func_convert_file_nix_to_cygwin
+ ;;
+ esac
+ ;;
+ * ) # unhandled hosts (and "normal" native builds)
+ lt_cv_to_host_file_cmd=func_convert_file_noop
+ ;;
+esac
+
+fi
+
+to_host_file_cmd=$lt_cv_to_host_file_cmd
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_to_host_file_cmd" >&5
+$as_echo "$lt_cv_to_host_file_cmd" >&6; }
+
+
+
+
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking how to convert $build file names to toolchain format" >&5
+$as_echo_n "checking how to convert $build file names to toolchain format... " >&6; }
+if ${lt_cv_to_tool_file_cmd+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ #assume ordinary cross tools, or native build.
+lt_cv_to_tool_file_cmd=func_convert_file_noop
+case $host in
+ *-*-mingw* )
+ case $build in
+ *-*-mingw* ) # actually msys
+ lt_cv_to_tool_file_cmd=func_convert_file_msys_to_w32
+ ;;
+ esac
+ ;;
+esac
+
+fi
+
+to_tool_file_cmd=$lt_cv_to_tool_file_cmd
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_to_tool_file_cmd" >&5
+$as_echo "$lt_cv_to_tool_file_cmd" >&6; }
+
+
+
+
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $LD option to reload object files" >&5
+$as_echo_n "checking for $LD option to reload object files... " >&6; }
+if ${lt_cv_ld_reload_flag+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ lt_cv_ld_reload_flag='-r'
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_ld_reload_flag" >&5
+$as_echo "$lt_cv_ld_reload_flag" >&6; }
+reload_flag=$lt_cv_ld_reload_flag
+case $reload_flag in
+"" | " "*) ;;
+*) reload_flag=" $reload_flag" ;;
+esac
+reload_cmds='$LD$reload_flag -o $output$reload_objs'
+case $host_os in
+ cygwin* | mingw* | pw32* | cegcc*)
+ if test "$GCC" != yes; then
+ reload_cmds=false
+ fi
+ ;;
+ darwin*)
+ if test "$GCC" = yes; then
+ reload_cmds='$LTCC $LTCFLAGS -nostdlib ${wl}-r -o $output$reload_objs'
+ else
+ reload_cmds='$LD$reload_flag -o $output$reload_objs'
+ fi
+ ;;
+esac
+
+
+
+
+
+
+
+
+
+if test -n "$ac_tool_prefix"; then
+ # Extract the first word of "${ac_tool_prefix}objdump", so it can be a program name with args.
+set dummy ${ac_tool_prefix}objdump; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if ${ac_cv_prog_OBJDUMP+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ if test -n "$OBJDUMP"; then
+ ac_cv_prog_OBJDUMP="$OBJDUMP" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ for ac_exec_ext in '' $ac_executable_extensions; do
+ if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+ ac_cv_prog_OBJDUMP="${ac_tool_prefix}objdump"
+ $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+ break 2
+ fi
+done
+ done
+IFS=$as_save_IFS
+
+fi
+fi
+OBJDUMP=$ac_cv_prog_OBJDUMP
+if test -n "$OBJDUMP"; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $OBJDUMP" >&5
+$as_echo "$OBJDUMP" >&6; }
+else
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+fi
+if test -z "$ac_cv_prog_OBJDUMP"; then
+ ac_ct_OBJDUMP=$OBJDUMP
+ # Extract the first word of "objdump", so it can be a program name with args.
+set dummy objdump; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if ${ac_cv_prog_ac_ct_OBJDUMP+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ if test -n "$ac_ct_OBJDUMP"; then
+ ac_cv_prog_ac_ct_OBJDUMP="$ac_ct_OBJDUMP" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ for ac_exec_ext in '' $ac_executable_extensions; do
+ if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+ ac_cv_prog_ac_ct_OBJDUMP="objdump"
+ $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+ break 2
+ fi
+done
+ done
+IFS=$as_save_IFS
+
+fi
+fi
+ac_ct_OBJDUMP=$ac_cv_prog_ac_ct_OBJDUMP
+if test -n "$ac_ct_OBJDUMP"; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_OBJDUMP" >&5
+$as_echo "$ac_ct_OBJDUMP" >&6; }
+else
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+ if test "x$ac_ct_OBJDUMP" = x; then
+ OBJDUMP="false"
+ else
+ case $cross_compiling:$ac_tool_warned in
+yes:)
+{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
+$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
+ac_tool_warned=yes ;;
+esac
+ OBJDUMP=$ac_ct_OBJDUMP
+ fi
+else
+ OBJDUMP="$ac_cv_prog_OBJDUMP"
+fi
+
+test -z "$OBJDUMP" && OBJDUMP=objdump
+
+
+
+
+
+
+
+
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking how to recognize dependent libraries" >&5
+$as_echo_n "checking how to recognize dependent libraries... " >&6; }
+if ${lt_cv_deplibs_check_method+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ lt_cv_file_magic_cmd='$MAGIC_CMD'
+lt_cv_file_magic_test_file=
+lt_cv_deplibs_check_method='unknown'
+# Need to set the preceding variable on all platforms that support
+# interlibrary dependencies.
+# 'none' -- dependencies not supported.
+# `unknown' -- same as none, but documents that we really don't know.
+# 'pass_all' -- all dependencies passed with no checks.
+# 'test_compile' -- check by making test program.
+# 'file_magic [[regex]]' -- check by looking for files in library path
+# which responds to the $file_magic_cmd with a given extended regex.
+# If you have `file' or equivalent on your system and you're not sure
+# whether `pass_all' will *always* work, you probably want this one.
+
+case $host_os in
+aix[4-9]*)
+ lt_cv_deplibs_check_method=pass_all
+ ;;
+
+beos*)
+ lt_cv_deplibs_check_method=pass_all
+ ;;
+
+bsdi[45]*)
+ lt_cv_deplibs_check_method='file_magic ELF [0-9][0-9]*-bit [ML]SB (shared object|dynamic lib)'
+ lt_cv_file_magic_cmd='/usr/bin/file -L'
+ lt_cv_file_magic_test_file=/shlib/libc.so
+ ;;
+
+cygwin*)
+ # func_win32_libid is a shell function defined in ltmain.sh
+ lt_cv_deplibs_check_method='file_magic ^x86 archive import|^x86 DLL'
+ lt_cv_file_magic_cmd='func_win32_libid'
+ ;;
+
+mingw* | pw32*)
+ # Base MSYS/MinGW do not provide the 'file' command needed by
+ # func_win32_libid shell function, so use a weaker test based on 'objdump',
+ # unless we find 'file', for example because we are cross-compiling.
+ # func_win32_libid assumes BSD nm, so disallow it if using MS dumpbin.
+ if ( test "$lt_cv_nm_interface" = "BSD nm" && file / ) >/dev/null 2>&1; then
+ lt_cv_deplibs_check_method='file_magic ^x86 archive import|^x86 DLL'
+ lt_cv_file_magic_cmd='func_win32_libid'
+ else
+ # Keep this pattern in sync with the one in func_win32_libid.
+ lt_cv_deplibs_check_method='file_magic file format (pei*-i386(.*architecture: i386)?|pe-arm-wince|pe-x86-64)'
+ lt_cv_file_magic_cmd='$OBJDUMP -f'
+ fi
+ ;;
+
+cegcc*)
+ # use the weaker test based on 'objdump'. See mingw*.
+ lt_cv_deplibs_check_method='file_magic file format pe-arm-.*little(.*architecture: arm)?'
+ lt_cv_file_magic_cmd='$OBJDUMP -f'
+ ;;
+
+darwin* | rhapsody*)
+ lt_cv_deplibs_check_method=pass_all
+ ;;
+
+freebsd* | dragonfly*)
+ if echo __ELF__ | $CC -E - | $GREP __ELF__ > /dev/null; then
+ case $host_cpu in
+ i*86 )
+ # Not sure whether the presence of OpenBSD here was a mistake.
+ # Let's accept both of them until this is cleared up.
+ lt_cv_deplibs_check_method='file_magic (FreeBSD|OpenBSD|DragonFly)/i[3-9]86 (compact )?demand paged shared library'
+ lt_cv_file_magic_cmd=/usr/bin/file
+ lt_cv_file_magic_test_file=`echo /usr/lib/libc.so.*`
+ ;;
+ esac
+ else
+ lt_cv_deplibs_check_method=pass_all
+ fi
+ ;;
+
+gnu*)
+ lt_cv_deplibs_check_method=pass_all
+ ;;
+
+haiku*)
+ lt_cv_deplibs_check_method=pass_all
+ ;;
+
+hpux10.20* | hpux11*)
+ lt_cv_file_magic_cmd=/usr/bin/file
+ case $host_cpu in
+ ia64*)
+ lt_cv_deplibs_check_method='file_magic (s[0-9][0-9][0-9]|ELF-[0-9][0-9]) shared object file - IA64'
+ lt_cv_file_magic_test_file=/usr/lib/hpux32/libc.so
+ ;;
+ hppa*64*)
+ lt_cv_deplibs_check_method='file_magic (s[0-9][0-9][0-9]|ELF[ -][0-9][0-9])(-bit)?( [LM]SB)? shared object( file)?[, -]* PA-RISC [0-9]\.[0-9]'
+ lt_cv_file_magic_test_file=/usr/lib/pa20_64/libc.sl
+ ;;
+ *)
+ lt_cv_deplibs_check_method='file_magic (s[0-9][0-9][0-9]|PA-RISC[0-9]\.[0-9]) shared library'
+ lt_cv_file_magic_test_file=/usr/lib/libc.sl
+ ;;
+ esac
+ ;;
+
+interix[3-9]*)
+ # PIC code is broken on Interix 3.x, that's why |\.a not |_pic\.a here
+ lt_cv_deplibs_check_method='match_pattern /lib[^/]+(\.so|\.a)$'
+ ;;
+
+irix5* | irix6* | nonstopux*)
+ case $LD in
+ *-32|*"-32 ") libmagic=32-bit;;
+ *-n32|*"-n32 ") libmagic=N32;;
+ *-64|*"-64 ") libmagic=64-bit;;
+ *) libmagic=never-match;;
+ esac
+ lt_cv_deplibs_check_method=pass_all
+ ;;
+
+# This must be glibc/ELF.
+linux* | k*bsd*-gnu | kopensolaris*-gnu)
+ lt_cv_deplibs_check_method=pass_all
+ ;;
+
+netbsd*)
+ if echo __ELF__ | $CC -E - | $GREP __ELF__ > /dev/null; then
+ lt_cv_deplibs_check_method='match_pattern /lib[^/]+(\.so\.[0-9]+\.[0-9]+|_pic\.a)$'
+ else
+ lt_cv_deplibs_check_method='match_pattern /lib[^/]+(\.so|_pic\.a)$'
+ fi
+ ;;
+
+newos6*)
+ lt_cv_deplibs_check_method='file_magic ELF [0-9][0-9]*-bit [ML]SB (executable|dynamic lib)'
+ lt_cv_file_magic_cmd=/usr/bin/file
+ lt_cv_file_magic_test_file=/usr/lib/libnls.so
+ ;;
+
+*nto* | *qnx*)
+ lt_cv_deplibs_check_method=pass_all
+ ;;
+
+openbsd*)
+ if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then
+ lt_cv_deplibs_check_method='match_pattern /lib[^/]+(\.so\.[0-9]+\.[0-9]+|\.so|_pic\.a)$'
+ else
+ lt_cv_deplibs_check_method='match_pattern /lib[^/]+(\.so\.[0-9]+\.[0-9]+|_pic\.a)$'
+ fi
+ ;;
+
+osf3* | osf4* | osf5*)
+ lt_cv_deplibs_check_method=pass_all
+ ;;
+
+rdos*)
+ lt_cv_deplibs_check_method=pass_all
+ ;;
+
+solaris*)
+ lt_cv_deplibs_check_method=pass_all
+ ;;
+
+sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*)
+ lt_cv_deplibs_check_method=pass_all
+ ;;
+
+sysv4 | sysv4.3*)
+ case $host_vendor in
+ motorola)
+ lt_cv_deplibs_check_method='file_magic ELF [0-9][0-9]*-bit [ML]SB (shared object|dynamic lib) M[0-9][0-9]* Version [0-9]'
+ lt_cv_file_magic_test_file=`echo /usr/lib/libc.so*`
+ ;;
+ ncr)
+ lt_cv_deplibs_check_method=pass_all
+ ;;
+ sequent)
+ lt_cv_file_magic_cmd='/bin/file'
+ lt_cv_deplibs_check_method='file_magic ELF [0-9][0-9]*-bit [LM]SB (shared object|dynamic lib )'
+ ;;
+ sni)
+ lt_cv_file_magic_cmd='/bin/file'
+ lt_cv_deplibs_check_method="file_magic ELF [0-9][0-9]*-bit [LM]SB dynamic lib"
+ lt_cv_file_magic_test_file=/lib/libc.so
+ ;;
+ siemens)
+ lt_cv_deplibs_check_method=pass_all
+ ;;
+ pc)
+ lt_cv_deplibs_check_method=pass_all
+ ;;
+ esac
+ ;;
+
+tpf*)
+ lt_cv_deplibs_check_method=pass_all
+ ;;
+esac
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_deplibs_check_method" >&5
+$as_echo "$lt_cv_deplibs_check_method" >&6; }
+
+file_magic_glob=
+want_nocaseglob=no
+if test "$build" = "$host"; then
+ case $host_os in
+ mingw* | pw32*)
+ if ( shopt | grep nocaseglob ) >/dev/null 2>&1; then
+ want_nocaseglob=yes
+ else
+ file_magic_glob=`echo aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZ | $SED -e "s/\(..\)/s\/[\1]\/[\1]\/g;/g"`
+ fi
+ ;;
+ esac
+fi
+
+file_magic_cmd=$lt_cv_file_magic_cmd
+deplibs_check_method=$lt_cv_deplibs_check_method
+test -z "$deplibs_check_method" && deplibs_check_method=unknown
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+if test -n "$ac_tool_prefix"; then
+ # Extract the first word of "${ac_tool_prefix}dlltool", so it can be a program name with args.
+set dummy ${ac_tool_prefix}dlltool; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if ${ac_cv_prog_DLLTOOL+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ if test -n "$DLLTOOL"; then
+ ac_cv_prog_DLLTOOL="$DLLTOOL" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ for ac_exec_ext in '' $ac_executable_extensions; do
+ if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+ ac_cv_prog_DLLTOOL="${ac_tool_prefix}dlltool"
+ $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+ break 2
+ fi
+done
+ done
+IFS=$as_save_IFS
+
+fi
+fi
+DLLTOOL=$ac_cv_prog_DLLTOOL
+if test -n "$DLLTOOL"; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $DLLTOOL" >&5
+$as_echo "$DLLTOOL" >&6; }
+else
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+fi
+if test -z "$ac_cv_prog_DLLTOOL"; then
+ ac_ct_DLLTOOL=$DLLTOOL
+ # Extract the first word of "dlltool", so it can be a program name with args.
+set dummy dlltool; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if ${ac_cv_prog_ac_ct_DLLTOOL+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ if test -n "$ac_ct_DLLTOOL"; then
+ ac_cv_prog_ac_ct_DLLTOOL="$ac_ct_DLLTOOL" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ for ac_exec_ext in '' $ac_executable_extensions; do
+ if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+ ac_cv_prog_ac_ct_DLLTOOL="dlltool"
+ $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+ break 2
+ fi
+done
+ done
+IFS=$as_save_IFS
+
+fi
+fi
+ac_ct_DLLTOOL=$ac_cv_prog_ac_ct_DLLTOOL
+if test -n "$ac_ct_DLLTOOL"; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_DLLTOOL" >&5
+$as_echo "$ac_ct_DLLTOOL" >&6; }
+else
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+ if test "x$ac_ct_DLLTOOL" = x; then
+ DLLTOOL="false"
+ else
+ case $cross_compiling:$ac_tool_warned in
+yes:)
+{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
+$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
+ac_tool_warned=yes ;;
+esac
+ DLLTOOL=$ac_ct_DLLTOOL
+ fi
+else
+ DLLTOOL="$ac_cv_prog_DLLTOOL"
+fi
+
+test -z "$DLLTOOL" && DLLTOOL=dlltool
+
+
+
+
+
+
+
+
+
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking how to associate runtime and link libraries" >&5
+$as_echo_n "checking how to associate runtime and link libraries... " >&6; }
+if ${lt_cv_sharedlib_from_linklib_cmd+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ lt_cv_sharedlib_from_linklib_cmd='unknown'
+
+case $host_os in
+cygwin* | mingw* | pw32* | cegcc*)
+ # two different shell functions defined in ltmain.sh
+ # decide which to use based on capabilities of $DLLTOOL
+ case `$DLLTOOL --help 2>&1` in
+ *--identify-strict*)
+ lt_cv_sharedlib_from_linklib_cmd=func_cygming_dll_for_implib
+ ;;
+ *)
+ lt_cv_sharedlib_from_linklib_cmd=func_cygming_dll_for_implib_fallback
+ ;;
+ esac
+ ;;
+*)
+ # fallback: assume linklib IS sharedlib
+ lt_cv_sharedlib_from_linklib_cmd="$ECHO"
+ ;;
+esac
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_sharedlib_from_linklib_cmd" >&5
+$as_echo "$lt_cv_sharedlib_from_linklib_cmd" >&6; }
+sharedlib_from_linklib_cmd=$lt_cv_sharedlib_from_linklib_cmd
+test -z "$sharedlib_from_linklib_cmd" && sharedlib_from_linklib_cmd=$ECHO
+
+
+
+
+
+
+
+
+if test -n "$ac_tool_prefix"; then
+ for ac_prog in ar
+ do
+ # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args.
+set dummy $ac_tool_prefix$ac_prog; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if ${ac_cv_prog_AR+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ if test -n "$AR"; then
+ ac_cv_prog_AR="$AR" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ for ac_exec_ext in '' $ac_executable_extensions; do
+ if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+ ac_cv_prog_AR="$ac_tool_prefix$ac_prog"
+ $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+ break 2
+ fi
+done
+ done
+IFS=$as_save_IFS
+
+fi
+fi
+AR=$ac_cv_prog_AR
+if test -n "$AR"; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $AR" >&5
+$as_echo "$AR" >&6; }
+else
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+ test -n "$AR" && break
+ done
+fi
+if test -z "$AR"; then
+ ac_ct_AR=$AR
+ for ac_prog in ar
+do
+ # Extract the first word of "$ac_prog", so it can be a program name with args.
+set dummy $ac_prog; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if ${ac_cv_prog_ac_ct_AR+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ if test -n "$ac_ct_AR"; then
+ ac_cv_prog_ac_ct_AR="$ac_ct_AR" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ for ac_exec_ext in '' $ac_executable_extensions; do
+ if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+ ac_cv_prog_ac_ct_AR="$ac_prog"
+ $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+ break 2
+ fi
+done
+ done
+IFS=$as_save_IFS
+
+fi
+fi
+ac_ct_AR=$ac_cv_prog_ac_ct_AR
+if test -n "$ac_ct_AR"; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_AR" >&5
+$as_echo "$ac_ct_AR" >&6; }
+else
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+ test -n "$ac_ct_AR" && break
+done
+
+ if test "x$ac_ct_AR" = x; then
+ AR="false"
+ else
+ case $cross_compiling:$ac_tool_warned in
+yes:)
+{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
+$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
+ac_tool_warned=yes ;;
+esac
+ AR=$ac_ct_AR
+ fi
+fi
+
+: ${AR=ar}
+: ${AR_FLAGS=cru}
+
+
+
+
+
+
+
+
+
+
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for archiver @FILE support" >&5
+$as_echo_n "checking for archiver @FILE support... " >&6; }
+if ${lt_cv_ar_at_file+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ lt_cv_ar_at_file=no
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+
+int
+main ()
+{
+
+ ;
+ return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+ echo conftest.$ac_objext > conftest.lst
+ lt_ar_try='$AR $AR_FLAGS libconftest.a @conftest.lst >&5'
+ { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$lt_ar_try\""; } >&5
+ (eval $lt_ar_try) 2>&5
+ ac_status=$?
+ $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+ test $ac_status = 0; }
+ if test "$ac_status" -eq 0; then
+ # Ensure the archiver fails upon bogus file names.
+ rm -f conftest.$ac_objext libconftest.a
+ { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$lt_ar_try\""; } >&5
+ (eval $lt_ar_try) 2>&5
+ ac_status=$?
+ $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+ test $ac_status = 0; }
+ if test "$ac_status" -ne 0; then
+ lt_cv_ar_at_file=@
+ fi
+ fi
+ rm -f conftest.* libconftest.a
+
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_ar_at_file" >&5
+$as_echo "$lt_cv_ar_at_file" >&6; }
+
+if test "x$lt_cv_ar_at_file" = xno; then
+ archiver_list_spec=
+else
+ archiver_list_spec=$lt_cv_ar_at_file
+fi
+
+
+
+
+
+
+
+if test -n "$ac_tool_prefix"; then
+ # Extract the first word of "${ac_tool_prefix}strip", so it can be a program name with args.
+set dummy ${ac_tool_prefix}strip; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if ${ac_cv_prog_STRIP+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ if test -n "$STRIP"; then
+ ac_cv_prog_STRIP="$STRIP" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ for ac_exec_ext in '' $ac_executable_extensions; do
+ if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+ ac_cv_prog_STRIP="${ac_tool_prefix}strip"
+ $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+ break 2
+ fi
+done
+ done
+IFS=$as_save_IFS
+
+fi
+fi
+STRIP=$ac_cv_prog_STRIP
+if test -n "$STRIP"; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $STRIP" >&5
+$as_echo "$STRIP" >&6; }
+else
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+fi
+if test -z "$ac_cv_prog_STRIP"; then
+ ac_ct_STRIP=$STRIP
+ # Extract the first word of "strip", so it can be a program name with args.
+set dummy strip; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if ${ac_cv_prog_ac_ct_STRIP+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ if test -n "$ac_ct_STRIP"; then
+ ac_cv_prog_ac_ct_STRIP="$ac_ct_STRIP" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ for ac_exec_ext in '' $ac_executable_extensions; do
+ if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+ ac_cv_prog_ac_ct_STRIP="strip"
+ $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+ break 2
+ fi
+done
+ done
+IFS=$as_save_IFS
+
+fi
+fi
+ac_ct_STRIP=$ac_cv_prog_ac_ct_STRIP
+if test -n "$ac_ct_STRIP"; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_STRIP" >&5
+$as_echo "$ac_ct_STRIP" >&6; }
+else
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+ if test "x$ac_ct_STRIP" = x; then
+ STRIP=":"
+ else
+ case $cross_compiling:$ac_tool_warned in
+yes:)
+{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
+$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
+ac_tool_warned=yes ;;
+esac
+ STRIP=$ac_ct_STRIP
+ fi
+else
+ STRIP="$ac_cv_prog_STRIP"
+fi
+
+test -z "$STRIP" && STRIP=:
+
+
+
+
+
+
+if test -n "$ac_tool_prefix"; then
+ # Extract the first word of "${ac_tool_prefix}ranlib", so it can be a program name with args.
+set dummy ${ac_tool_prefix}ranlib; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if ${ac_cv_prog_RANLIB+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ if test -n "$RANLIB"; then
+ ac_cv_prog_RANLIB="$RANLIB" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ for ac_exec_ext in '' $ac_executable_extensions; do
+ if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+ ac_cv_prog_RANLIB="${ac_tool_prefix}ranlib"
+ $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+ break 2
+ fi
+done
+ done
+IFS=$as_save_IFS
+
+fi
+fi
+RANLIB=$ac_cv_prog_RANLIB
+if test -n "$RANLIB"; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $RANLIB" >&5
+$as_echo "$RANLIB" >&6; }
+else
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+fi
+if test -z "$ac_cv_prog_RANLIB"; then
+ ac_ct_RANLIB=$RANLIB
+ # Extract the first word of "ranlib", so it can be a program name with args.
+set dummy ranlib; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if ${ac_cv_prog_ac_ct_RANLIB+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ if test -n "$ac_ct_RANLIB"; then
+ ac_cv_prog_ac_ct_RANLIB="$ac_ct_RANLIB" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ for ac_exec_ext in '' $ac_executable_extensions; do
+ if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+ ac_cv_prog_ac_ct_RANLIB="ranlib"
+ $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+ break 2
+ fi
+done
+ done
+IFS=$as_save_IFS
+
+fi
+fi
+ac_ct_RANLIB=$ac_cv_prog_ac_ct_RANLIB
+if test -n "$ac_ct_RANLIB"; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_RANLIB" >&5
+$as_echo "$ac_ct_RANLIB" >&6; }
+else
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+ if test "x$ac_ct_RANLIB" = x; then
+ RANLIB=":"
+ else
+ case $cross_compiling:$ac_tool_warned in
+yes:)
+{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
+$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
+ac_tool_warned=yes ;;
+esac
+ RANLIB=$ac_ct_RANLIB
+ fi
+else
+ RANLIB="$ac_cv_prog_RANLIB"
+fi
+
+test -z "$RANLIB" && RANLIB=:
+
+
+
+
+
+
+# Determine commands to create old-style static archives.
+old_archive_cmds='$AR $AR_FLAGS $oldlib$oldobjs'
+old_postinstall_cmds='chmod 644 $oldlib'
+old_postuninstall_cmds=
+
+if test -n "$RANLIB"; then
+ case $host_os in
+ openbsd*)
+ old_postinstall_cmds="$old_postinstall_cmds~\$RANLIB -t \$tool_oldlib"
+ ;;
+ *)
+ old_postinstall_cmds="$old_postinstall_cmds~\$RANLIB \$tool_oldlib"
+ ;;
+ esac
+ old_archive_cmds="$old_archive_cmds~\$RANLIB \$tool_oldlib"
+fi
+
+case $host_os in
+ darwin*)
+ lock_old_archive_extraction=yes ;;
+ *)
+ lock_old_archive_extraction=no ;;
+esac
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+# If no C compiler was specified, use CC.
+LTCC=${LTCC-"$CC"}
+
+# If no C compiler flags were specified, use CFLAGS.
+LTCFLAGS=${LTCFLAGS-"$CFLAGS"}
+
+# Allow CC to be a program name with arguments.
+compiler=$CC
+
+
+# Check for command to grab the raw symbol name followed by C symbol from nm.
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking command to parse $NM output from $compiler object" >&5
+$as_echo_n "checking command to parse $NM output from $compiler object... " >&6; }
+if ${lt_cv_sys_global_symbol_pipe+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+
+# These are sane defaults that work on at least a few old systems.
+# [They come from Ultrix. What could be older than Ultrix?!! ;)]
+
+# Character class describing NM global symbol codes.
+symcode='[BCDEGRST]'
+
+# Regexp to match symbols that can be accessed directly from C.
+sympat='\([_A-Za-z][_A-Za-z0-9]*\)'
+
+# Define system-specific variables.
+case $host_os in
+aix*)
+ symcode='[BCDT]'
+ ;;
+cygwin* | mingw* | pw32* | cegcc*)
+ symcode='[ABCDGISTW]'
+ ;;
+hpux*)
+ if test "$host_cpu" = ia64; then
+ symcode='[ABCDEGRST]'
+ fi
+ ;;
+irix* | nonstopux*)
+ symcode='[BCDEGRST]'
+ ;;
+osf*)
+ symcode='[BCDEGQRST]'
+ ;;
+solaris*)
+ symcode='[BDRT]'
+ ;;
+sco3.2v5*)
+ symcode='[DT]'
+ ;;
+sysv4.2uw2*)
+ symcode='[DT]'
+ ;;
+sysv5* | sco5v6* | unixware* | OpenUNIX*)
+ symcode='[ABDT]'
+ ;;
+sysv4)
+ symcode='[DFNSTU]'
+ ;;
+esac
+
+# If we're using GNU nm, then use its standard symbol codes.
+case `$NM -V 2>&1` in
+*GNU* | *'with BFD'*)
+ symcode='[ABCDGIRSTW]' ;;
+esac
+
+# Transform an extracted symbol line into a proper C declaration.
+# Some systems (esp. on ia64) link data and code symbols differently,
+# so use this general approach.
+lt_cv_sys_global_symbol_to_cdecl="sed -n -e 's/^T .* \(.*\)$/extern int \1();/p' -e 's/^$symcode* .* \(.*\)$/extern char \1;/p'"
+
+# Transform an extracted symbol line into symbol name and symbol address
+lt_cv_sys_global_symbol_to_c_name_address="sed -n -e 's/^: \([^ ]*\)[ ]*$/ {\\\"\1\\\", (void *) 0},/p' -e 's/^$symcode* \([^ ]*\) \([^ ]*\)$/ {\"\2\", (void *) \&\2},/p'"
+lt_cv_sys_global_symbol_to_c_name_address_lib_prefix="sed -n -e 's/^: \([^ ]*\)[ ]*$/ {\\\"\1\\\", (void *) 0},/p' -e 's/^$symcode* \([^ ]*\) \(lib[^ ]*\)$/ {\"\2\", (void *) \&\2},/p' -e 's/^$symcode* \([^ ]*\) \([^ ]*\)$/ {\"lib\2\", (void *) \&\2},/p'"
+
+# Handle CRLF in mingw tool chain
+opt_cr=
+case $build_os in
+mingw*)
+ opt_cr=`$ECHO 'x\{0,1\}' | tr x '\015'` # option cr in regexp
+ ;;
+esac
+
+# Try without a prefix underscore, then with it.
+for ac_symprfx in "" "_"; do
+
+ # Transform symcode, sympat, and symprfx into a raw symbol and a C symbol.
+ symxfrm="\\1 $ac_symprfx\\2 \\2"
+
+ # Write the raw and C identifiers.
+ if test "$lt_cv_nm_interface" = "MS dumpbin"; then
+ # Fake it for dumpbin and say T for any non-static function
+ # and D for any global variable.
+ # Also find C++ and __fastcall symbols from MSVC++,
+ # which start with @ or ?.
+ lt_cv_sys_global_symbol_pipe="$AWK '"\
+" {last_section=section; section=\$ 3};"\
+" /^COFF SYMBOL TABLE/{for(i in hide) delete hide[i]};"\
+" /Section length .*#relocs.*(pick any)/{hide[last_section]=1};"\
+" \$ 0!~/External *\|/{next};"\
+" / 0+ UNDEF /{next}; / UNDEF \([^|]\)*()/{next};"\
+" {if(hide[section]) next};"\
+" {f=0}; \$ 0~/\(\).*\|/{f=1}; {printf f ? \"T \" : \"D \"};"\
+" {split(\$ 0, a, /\||\r/); split(a[2], s)};"\
+" s[1]~/^[@?]/{print s[1], s[1]; next};"\
+" s[1]~prfx {split(s[1],t,\"@\"); print t[1], substr(t[1],length(prfx))}"\
+" ' prfx=^$ac_symprfx"
+ else
+ lt_cv_sys_global_symbol_pipe="sed -n -e 's/^.*[ ]\($symcode$symcode*\)[ ][ ]*$ac_symprfx$sympat$opt_cr$/$symxfrm/p'"
+ fi
+ lt_cv_sys_global_symbol_pipe="$lt_cv_sys_global_symbol_pipe | sed '/ __gnu_lto/d'"
+
+ # Check to see that the pipe works correctly.
+ pipe_works=no
+
+ rm -f conftest*
+ cat > conftest.$ac_ext <<_LT_EOF
+#ifdef __cplusplus
+extern "C" {
+#endif
+char nm_test_var;
+void nm_test_func(void);
+void nm_test_func(void){}
+#ifdef __cplusplus
+}
+#endif
+int main(){nm_test_var='a';nm_test_func();return(0);}
+_LT_EOF
+
+ if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5
+ (eval $ac_compile) 2>&5
+ ac_status=$?
+ $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+ test $ac_status = 0; }; then
+ # Now try to grab the symbols.
+ nlist=conftest.nm
+ if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$NM conftest.$ac_objext \| "$lt_cv_sys_global_symbol_pipe" \> $nlist\""; } >&5
+ (eval $NM conftest.$ac_objext \| "$lt_cv_sys_global_symbol_pipe" \> $nlist) 2>&5
+ ac_status=$?
+ $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+ test $ac_status = 0; } && test -s "$nlist"; then
+ # Try sorting and uniquifying the output.
+ if sort "$nlist" | uniq > "$nlist"T; then
+ mv -f "$nlist"T "$nlist"
+ else
+ rm -f "$nlist"T
+ fi
+
+ # Make sure that we snagged all the symbols we need.
+ if $GREP ' nm_test_var$' "$nlist" >/dev/null; then
+ if $GREP ' nm_test_func$' "$nlist" >/dev/null; then
+ cat <<_LT_EOF > conftest.$ac_ext
+/* Keep this code in sync between libtool.m4, ltmain, lt_system.h, and tests. */
+#if defined(_WIN32) || defined(__CYGWIN__) || defined(_WIN32_WCE)
+/* DATA imports from DLLs on WIN32 con't be const, because runtime
+ relocations are performed -- see ld's documentation on pseudo-relocs. */
+# define LT_DLSYM_CONST
+#elif defined(__osf__)
+/* This system does not cope well with relocations in const data. */
+# define LT_DLSYM_CONST
+#else
+# define LT_DLSYM_CONST const
+#endif
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+_LT_EOF
+ # Now generate the symbol file.
+ eval "$lt_cv_sys_global_symbol_to_cdecl"' < "$nlist" | $GREP -v main >> conftest.$ac_ext'
+
+ cat <<_LT_EOF >> conftest.$ac_ext
+
+/* The mapping between symbol names and symbols. */
+LT_DLSYM_CONST struct {
+ const char *name;
+ void *address;
+}
+lt__PROGRAM__LTX_preloaded_symbols[] =
+{
+ { "@PROGRAM@", (void *) 0 },
+_LT_EOF
+ $SED "s/^$symcode$symcode* \(.*\) \(.*\)$/ {\"\2\", (void *) \&\2},/" < "$nlist" | $GREP -v main >> conftest.$ac_ext
+ cat <<\_LT_EOF >> conftest.$ac_ext
+ {0, (void *) 0}
+};
+
+/* This works around a problem in FreeBSD linker */
+#ifdef FREEBSD_WORKAROUND
+static const void *lt_preloaded_setup() {
+ return lt__PROGRAM__LTX_preloaded_symbols;
+}
+#endif
+
+#ifdef __cplusplus
+}
+#endif
+_LT_EOF
+ # Now try linking the two files.
+ mv conftest.$ac_objext conftstm.$ac_objext
+ lt_globsym_save_LIBS=$LIBS
+ lt_globsym_save_CFLAGS=$CFLAGS
+ LIBS="conftstm.$ac_objext"
+ CFLAGS="$CFLAGS$lt_prog_compiler_no_builtin_flag"
+ if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_link\""; } >&5
+ (eval $ac_link) 2>&5
+ ac_status=$?
+ $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+ test $ac_status = 0; } && test -s conftest${ac_exeext}; then
+ pipe_works=yes
+ fi
+ LIBS=$lt_globsym_save_LIBS
+ CFLAGS=$lt_globsym_save_CFLAGS
+ else
+ echo "cannot find nm_test_func in $nlist" >&5
+ fi
+ else
+ echo "cannot find nm_test_var in $nlist" >&5
+ fi
+ else
+ echo "cannot run $lt_cv_sys_global_symbol_pipe" >&5
+ fi
+ else
+ echo "$progname: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ fi
+ rm -rf conftest* conftst*
+
+ # Do not use the global_symbol_pipe unless it works.
+ if test "$pipe_works" = yes; then
+ break
+ else
+ lt_cv_sys_global_symbol_pipe=
+ fi
+done
+
+fi
+
+if test -z "$lt_cv_sys_global_symbol_pipe"; then
+ lt_cv_sys_global_symbol_to_cdecl=
+fi
+if test -z "$lt_cv_sys_global_symbol_pipe$lt_cv_sys_global_symbol_to_cdecl"; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: failed" >&5
+$as_echo "failed" >&6; }
+else
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: ok" >&5
+$as_echo "ok" >&6; }
+fi
+
+# Response file support.
+if test "$lt_cv_nm_interface" = "MS dumpbin"; then
+ nm_file_list_spec='@'
+elif $NM --help 2>/dev/null | grep '[@]FILE' >/dev/null; then
+ nm_file_list_spec='@'
+fi
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for sysroot" >&5
+$as_echo_n "checking for sysroot... " >&6; }
+
+# Check whether --with-sysroot was given.
+if test "${with_sysroot+set}" = set; then :
+ withval=$with_sysroot;
+else
+ with_sysroot=no
+fi
+
+
+lt_sysroot=
+case ${with_sysroot} in #(
+ yes)
+ if test "$GCC" = yes; then
+ lt_sysroot=`$CC --print-sysroot 2>/dev/null`
+ fi
+ ;; #(
+ /*)
+ lt_sysroot=`echo "$with_sysroot" | sed -e "$sed_quote_subst"`
+ ;; #(
+ no|'')
+ ;; #(
+ *)
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: ${with_sysroot}" >&5
+$as_echo "${with_sysroot}" >&6; }
+ as_fn_error $? "The sysroot must be an absolute path." "$LINENO" 5
+ ;;
+esac
+
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: ${lt_sysroot:-no}" >&5
+$as_echo "${lt_sysroot:-no}" >&6; }
+
+
+
+
+
+# Check whether --enable-libtool-lock was given.
+if test "${enable_libtool_lock+set}" = set; then :
+ enableval=$enable_libtool_lock;
+fi
+
+test "x$enable_libtool_lock" != xno && enable_libtool_lock=yes
+
+# Some flags need to be propagated to the compiler or linker for good
+# libtool support.
+case $host in
+ia64-*-hpux*)
+ # Find out which ABI we are using.
+ echo 'int i;' > conftest.$ac_ext
+ if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5
+ (eval $ac_compile) 2>&5
+ ac_status=$?
+ $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+ test $ac_status = 0; }; then
+ case `/usr/bin/file conftest.$ac_objext` in
+ *ELF-32*)
+ HPUX_IA64_MODE="32"
+ ;;
+ *ELF-64*)
+ HPUX_IA64_MODE="64"
+ ;;
+ esac
+ fi
+ rm -rf conftest*
+ ;;
+*-*-irix6*)
+ # Find out which ABI we are using.
+ echo '#line '$LINENO' "configure"' > conftest.$ac_ext
+ if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5
+ (eval $ac_compile) 2>&5
+ ac_status=$?
+ $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+ test $ac_status = 0; }; then
+ if test "$lt_cv_prog_gnu_ld" = yes; then
+ case `/usr/bin/file conftest.$ac_objext` in
+ *32-bit*)
+ LD="${LD-ld} -melf32bsmip"
+ ;;
+ *N32*)
+ LD="${LD-ld} -melf32bmipn32"
+ ;;
+ *64-bit*)
+ LD="${LD-ld} -melf64bmip"
+ ;;
+ esac
+ else
+ case `/usr/bin/file conftest.$ac_objext` in
+ *32-bit*)
+ LD="${LD-ld} -32"
+ ;;
+ *N32*)
+ LD="${LD-ld} -n32"
+ ;;
+ *64-bit*)
+ LD="${LD-ld} -64"
+ ;;
+ esac
+ fi
+ fi
+ rm -rf conftest*
+ ;;
+
+x86_64-*kfreebsd*-gnu|x86_64-*linux*|ppc*-*linux*|powerpc*-*linux*| \
+s390*-*linux*|s390*-*tpf*|sparc*-*linux*)
+ # Find out which ABI we are using.
+ echo 'int i;' > conftest.$ac_ext
+ if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5
+ (eval $ac_compile) 2>&5
+ ac_status=$?
+ $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+ test $ac_status = 0; }; then
+ case `/usr/bin/file conftest.o` in
+ *32-bit*)
+ case $host in
+ x86_64-*kfreebsd*-gnu)
+ LD="${LD-ld} -m elf_i386_fbsd"
+ ;;
+ x86_64-*linux*)
+ LD="${LD-ld} -m elf_i386"
+ ;;
+ ppc64-*linux*|powerpc64-*linux*)
+ LD="${LD-ld} -m elf32ppclinux"
+ ;;
+ s390x-*linux*)
+ LD="${LD-ld} -m elf_s390"
+ ;;
+ sparc64-*linux*)
+ LD="${LD-ld} -m elf32_sparc"
+ ;;
+ esac
+ ;;
+ *64-bit*)
+ case $host in
+ x86_64-*kfreebsd*-gnu)
+ LD="${LD-ld} -m elf_x86_64_fbsd"
+ ;;
+ x86_64-*linux*)
+ LD="${LD-ld} -m elf_x86_64"
+ ;;
+ ppc*-*linux*|powerpc*-*linux*)
+ LD="${LD-ld} -m elf64ppc"
+ ;;
+ s390*-*linux*|s390*-*tpf*)
+ LD="${LD-ld} -m elf64_s390"
+ ;;
+ sparc*-*linux*)
+ LD="${LD-ld} -m elf64_sparc"
+ ;;
+ esac
+ ;;
+ esac
+ fi
+ rm -rf conftest*
+ ;;
+
+*-*-sco3.2v5*)
+ # On SCO OpenServer 5, we need -belf to get full-featured binaries.
+ SAVE_CFLAGS="$CFLAGS"
+ CFLAGS="$CFLAGS -belf"
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the C compiler needs -belf" >&5
+$as_echo_n "checking whether the C compiler needs -belf... " >&6; }
+if ${lt_cv_cc_needs_belf+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ ac_ext=c
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
+
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+
+int
+main ()
+{
+
+ ;
+ return 0;
+}
+_ACEOF
+if ac_fn_c_try_link "$LINENO"; then :
+ lt_cv_cc_needs_belf=yes
+else
+ lt_cv_cc_needs_belf=no
+fi
+rm -f core conftest.err conftest.$ac_objext \
+ conftest$ac_exeext conftest.$ac_ext
+ ac_ext=c
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_cc_needs_belf" >&5
+$as_echo "$lt_cv_cc_needs_belf" >&6; }
+ if test x"$lt_cv_cc_needs_belf" != x"yes"; then
+ # this is probably gcc 2.8.0, egcs 1.0 or newer; no need for -belf
+ CFLAGS="$SAVE_CFLAGS"
+ fi
+ ;;
+*-*solaris*)
+ # Find out which ABI we are using.
+ echo 'int i;' > conftest.$ac_ext
+ if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5
+ (eval $ac_compile) 2>&5
+ ac_status=$?
+ $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+ test $ac_status = 0; }; then
+ case `/usr/bin/file conftest.o` in
+ *64-bit*)
+ case $lt_cv_prog_gnu_ld in
+ yes*)
+ case $host in
+ i?86-*-solaris*)
+ LD="${LD-ld} -m elf_x86_64"
+ ;;
+ sparc*-*-solaris*)
+ LD="${LD-ld} -m elf64_sparc"
+ ;;
+ esac
+ # GNU ld 2.21 introduced _sol2 emulations. Use them if available.
+ if ${LD-ld} -V | grep _sol2 >/dev/null 2>&1; then
+ LD="${LD-ld}_sol2"
+ fi
+ ;;
+ *)
+ if ${LD-ld} -64 -r -o conftest2.o conftest.o >/dev/null 2>&1; then
+ LD="${LD-ld} -64"
+ fi
+ ;;
+ esac
+ ;;
+ esac
+ fi
+ rm -rf conftest*
+ ;;
+esac
+
+need_locks="$enable_libtool_lock"
+
+if test -n "$ac_tool_prefix"; then
+ # Extract the first word of "${ac_tool_prefix}mt", so it can be a program name with args.
+set dummy ${ac_tool_prefix}mt; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if ${ac_cv_prog_MANIFEST_TOOL+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ if test -n "$MANIFEST_TOOL"; then
+ ac_cv_prog_MANIFEST_TOOL="$MANIFEST_TOOL" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ for ac_exec_ext in '' $ac_executable_extensions; do
+ if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+ ac_cv_prog_MANIFEST_TOOL="${ac_tool_prefix}mt"
+ $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+ break 2
+ fi
+done
+ done
+IFS=$as_save_IFS
+
+fi
+fi
+MANIFEST_TOOL=$ac_cv_prog_MANIFEST_TOOL
+if test -n "$MANIFEST_TOOL"; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $MANIFEST_TOOL" >&5
+$as_echo "$MANIFEST_TOOL" >&6; }
+else
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+fi
+if test -z "$ac_cv_prog_MANIFEST_TOOL"; then
+ ac_ct_MANIFEST_TOOL=$MANIFEST_TOOL
+ # Extract the first word of "mt", so it can be a program name with args.
+set dummy mt; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if ${ac_cv_prog_ac_ct_MANIFEST_TOOL+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ if test -n "$ac_ct_MANIFEST_TOOL"; then
+ ac_cv_prog_ac_ct_MANIFEST_TOOL="$ac_ct_MANIFEST_TOOL" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ for ac_exec_ext in '' $ac_executable_extensions; do
+ if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+ ac_cv_prog_ac_ct_MANIFEST_TOOL="mt"
+ $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+ break 2
+ fi
+done
+ done
+IFS=$as_save_IFS
+
+fi
+fi
+ac_ct_MANIFEST_TOOL=$ac_cv_prog_ac_ct_MANIFEST_TOOL
+if test -n "$ac_ct_MANIFEST_TOOL"; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_MANIFEST_TOOL" >&5
+$as_echo "$ac_ct_MANIFEST_TOOL" >&6; }
+else
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+ if test "x$ac_ct_MANIFEST_TOOL" = x; then
+ MANIFEST_TOOL=":"
+ else
+ case $cross_compiling:$ac_tool_warned in
+yes:)
+{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
+$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
+ac_tool_warned=yes ;;
+esac
+ MANIFEST_TOOL=$ac_ct_MANIFEST_TOOL
+ fi
+else
+ MANIFEST_TOOL="$ac_cv_prog_MANIFEST_TOOL"
+fi
+
+test -z "$MANIFEST_TOOL" && MANIFEST_TOOL=mt
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if $MANIFEST_TOOL is a manifest tool" >&5
+$as_echo_n "checking if $MANIFEST_TOOL is a manifest tool... " >&6; }
+if ${lt_cv_path_mainfest_tool+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ lt_cv_path_mainfest_tool=no
+ echo "$as_me:$LINENO: $MANIFEST_TOOL '-?'" >&5
+ $MANIFEST_TOOL '-?' 2>conftest.err > conftest.out
+ cat conftest.err >&5
+ if $GREP 'Manifest Tool' conftest.out > /dev/null; then
+ lt_cv_path_mainfest_tool=yes
+ fi
+ rm -f conftest*
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_path_mainfest_tool" >&5
+$as_echo "$lt_cv_path_mainfest_tool" >&6; }
+if test "x$lt_cv_path_mainfest_tool" != xyes; then
+ MANIFEST_TOOL=:
+fi
+
+
+
+
+
+
+ case $host_os in
+ rhapsody* | darwin*)
+ if test -n "$ac_tool_prefix"; then
+ # Extract the first word of "${ac_tool_prefix}dsymutil", so it can be a program name with args.
+set dummy ${ac_tool_prefix}dsymutil; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if ${ac_cv_prog_DSYMUTIL+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ if test -n "$DSYMUTIL"; then
+ ac_cv_prog_DSYMUTIL="$DSYMUTIL" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ for ac_exec_ext in '' $ac_executable_extensions; do
+ if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+ ac_cv_prog_DSYMUTIL="${ac_tool_prefix}dsymutil"
+ $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+ break 2
+ fi
+done
+ done
+IFS=$as_save_IFS
+
+fi
+fi
+DSYMUTIL=$ac_cv_prog_DSYMUTIL
+if test -n "$DSYMUTIL"; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $DSYMUTIL" >&5
+$as_echo "$DSYMUTIL" >&6; }
+else
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+fi
+if test -z "$ac_cv_prog_DSYMUTIL"; then
+ ac_ct_DSYMUTIL=$DSYMUTIL
+ # Extract the first word of "dsymutil", so it can be a program name with args.
+set dummy dsymutil; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if ${ac_cv_prog_ac_ct_DSYMUTIL+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ if test -n "$ac_ct_DSYMUTIL"; then
+ ac_cv_prog_ac_ct_DSYMUTIL="$ac_ct_DSYMUTIL" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ for ac_exec_ext in '' $ac_executable_extensions; do
+ if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+ ac_cv_prog_ac_ct_DSYMUTIL="dsymutil"
+ $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+ break 2
+ fi
+done
+ done
+IFS=$as_save_IFS
+
+fi
+fi
+ac_ct_DSYMUTIL=$ac_cv_prog_ac_ct_DSYMUTIL
+if test -n "$ac_ct_DSYMUTIL"; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_DSYMUTIL" >&5
+$as_echo "$ac_ct_DSYMUTIL" >&6; }
+else
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+ if test "x$ac_ct_DSYMUTIL" = x; then
+ DSYMUTIL=":"
+ else
+ case $cross_compiling:$ac_tool_warned in
+yes:)
+{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
+$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
+ac_tool_warned=yes ;;
+esac
+ DSYMUTIL=$ac_ct_DSYMUTIL
+ fi
+else
+ DSYMUTIL="$ac_cv_prog_DSYMUTIL"
+fi
+
+ if test -n "$ac_tool_prefix"; then
+ # Extract the first word of "${ac_tool_prefix}nmedit", so it can be a program name with args.
+set dummy ${ac_tool_prefix}nmedit; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if ${ac_cv_prog_NMEDIT+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ if test -n "$NMEDIT"; then
+ ac_cv_prog_NMEDIT="$NMEDIT" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ for ac_exec_ext in '' $ac_executable_extensions; do
+ if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+ ac_cv_prog_NMEDIT="${ac_tool_prefix}nmedit"
+ $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+ break 2
+ fi
+done
+ done
+IFS=$as_save_IFS
+
+fi
+fi
+NMEDIT=$ac_cv_prog_NMEDIT
+if test -n "$NMEDIT"; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $NMEDIT" >&5
+$as_echo "$NMEDIT" >&6; }
+else
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+fi
+if test -z "$ac_cv_prog_NMEDIT"; then
+ ac_ct_NMEDIT=$NMEDIT
+ # Extract the first word of "nmedit", so it can be a program name with args.
+set dummy nmedit; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if ${ac_cv_prog_ac_ct_NMEDIT+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ if test -n "$ac_ct_NMEDIT"; then
+ ac_cv_prog_ac_ct_NMEDIT="$ac_ct_NMEDIT" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ for ac_exec_ext in '' $ac_executable_extensions; do
+ if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+ ac_cv_prog_ac_ct_NMEDIT="nmedit"
+ $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+ break 2
+ fi
+done
+ done
+IFS=$as_save_IFS
+
+fi
+fi
+ac_ct_NMEDIT=$ac_cv_prog_ac_ct_NMEDIT
+if test -n "$ac_ct_NMEDIT"; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_NMEDIT" >&5
+$as_echo "$ac_ct_NMEDIT" >&6; }
+else
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+ if test "x$ac_ct_NMEDIT" = x; then
+ NMEDIT=":"
+ else
+ case $cross_compiling:$ac_tool_warned in
+yes:)
+{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
+$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
+ac_tool_warned=yes ;;
+esac
+ NMEDIT=$ac_ct_NMEDIT
+ fi
+else
+ NMEDIT="$ac_cv_prog_NMEDIT"
+fi
+
+ if test -n "$ac_tool_prefix"; then
+ # Extract the first word of "${ac_tool_prefix}lipo", so it can be a program name with args.
+set dummy ${ac_tool_prefix}lipo; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if ${ac_cv_prog_LIPO+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ if test -n "$LIPO"; then
+ ac_cv_prog_LIPO="$LIPO" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ for ac_exec_ext in '' $ac_executable_extensions; do
+ if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+ ac_cv_prog_LIPO="${ac_tool_prefix}lipo"
+ $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+ break 2
+ fi
+done
+ done
+IFS=$as_save_IFS
+
+fi
+fi
+LIPO=$ac_cv_prog_LIPO
+if test -n "$LIPO"; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $LIPO" >&5
+$as_echo "$LIPO" >&6; }
+else
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+fi
+if test -z "$ac_cv_prog_LIPO"; then
+ ac_ct_LIPO=$LIPO
+ # Extract the first word of "lipo", so it can be a program name with args.
+set dummy lipo; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if ${ac_cv_prog_ac_ct_LIPO+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ if test -n "$ac_ct_LIPO"; then
+ ac_cv_prog_ac_ct_LIPO="$ac_ct_LIPO" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ for ac_exec_ext in '' $ac_executable_extensions; do
+ if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+ ac_cv_prog_ac_ct_LIPO="lipo"
+ $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+ break 2
+ fi
+done
+ done
+IFS=$as_save_IFS
+
+fi
+fi
+ac_ct_LIPO=$ac_cv_prog_ac_ct_LIPO
+if test -n "$ac_ct_LIPO"; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_LIPO" >&5
+$as_echo "$ac_ct_LIPO" >&6; }
+else
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+ if test "x$ac_ct_LIPO" = x; then
+ LIPO=":"
+ else
+ case $cross_compiling:$ac_tool_warned in
+yes:)
+{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
+$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
+ac_tool_warned=yes ;;
+esac
+ LIPO=$ac_ct_LIPO
+ fi
+else
+ LIPO="$ac_cv_prog_LIPO"
+fi
+
+ if test -n "$ac_tool_prefix"; then
+ # Extract the first word of "${ac_tool_prefix}otool", so it can be a program name with args.
+set dummy ${ac_tool_prefix}otool; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if ${ac_cv_prog_OTOOL+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ if test -n "$OTOOL"; then
+ ac_cv_prog_OTOOL="$OTOOL" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ for ac_exec_ext in '' $ac_executable_extensions; do
+ if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+ ac_cv_prog_OTOOL="${ac_tool_prefix}otool"
+ $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+ break 2
+ fi
+done
+ done
+IFS=$as_save_IFS
+
+fi
+fi
+OTOOL=$ac_cv_prog_OTOOL
+if test -n "$OTOOL"; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $OTOOL" >&5
+$as_echo "$OTOOL" >&6; }
+else
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+fi
+if test -z "$ac_cv_prog_OTOOL"; then
+ ac_ct_OTOOL=$OTOOL
+ # Extract the first word of "otool", so it can be a program name with args.
+set dummy otool; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if ${ac_cv_prog_ac_ct_OTOOL+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ if test -n "$ac_ct_OTOOL"; then
+ ac_cv_prog_ac_ct_OTOOL="$ac_ct_OTOOL" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ for ac_exec_ext in '' $ac_executable_extensions; do
+ if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+ ac_cv_prog_ac_ct_OTOOL="otool"
+ $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+ break 2
+ fi
+done
+ done
+IFS=$as_save_IFS
+
+fi
+fi
+ac_ct_OTOOL=$ac_cv_prog_ac_ct_OTOOL
+if test -n "$ac_ct_OTOOL"; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_OTOOL" >&5
+$as_echo "$ac_ct_OTOOL" >&6; }
+else
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+ if test "x$ac_ct_OTOOL" = x; then
+ OTOOL=":"
+ else
+ case $cross_compiling:$ac_tool_warned in
+yes:)
+{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
+$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
+ac_tool_warned=yes ;;
+esac
+ OTOOL=$ac_ct_OTOOL
+ fi
+else
+ OTOOL="$ac_cv_prog_OTOOL"
+fi
+
+ if test -n "$ac_tool_prefix"; then
+ # Extract the first word of "${ac_tool_prefix}otool64", so it can be a program name with args.
+set dummy ${ac_tool_prefix}otool64; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if ${ac_cv_prog_OTOOL64+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ if test -n "$OTOOL64"; then
+ ac_cv_prog_OTOOL64="$OTOOL64" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ for ac_exec_ext in '' $ac_executable_extensions; do
+ if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+ ac_cv_prog_OTOOL64="${ac_tool_prefix}otool64"
+ $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+ break 2
+ fi
+done
+ done
+IFS=$as_save_IFS
+
+fi
+fi
+OTOOL64=$ac_cv_prog_OTOOL64
+if test -n "$OTOOL64"; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $OTOOL64" >&5
+$as_echo "$OTOOL64" >&6; }
+else
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+fi
+if test -z "$ac_cv_prog_OTOOL64"; then
+ ac_ct_OTOOL64=$OTOOL64
+ # Extract the first word of "otool64", so it can be a program name with args.
+set dummy otool64; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if ${ac_cv_prog_ac_ct_OTOOL64+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ if test -n "$ac_ct_OTOOL64"; then
+ ac_cv_prog_ac_ct_OTOOL64="$ac_ct_OTOOL64" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ for ac_exec_ext in '' $ac_executable_extensions; do
+ if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+ ac_cv_prog_ac_ct_OTOOL64="otool64"
+ $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+ break 2
+ fi
+done
+ done
+IFS=$as_save_IFS
+
+fi
+fi
+ac_ct_OTOOL64=$ac_cv_prog_ac_ct_OTOOL64
+if test -n "$ac_ct_OTOOL64"; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_OTOOL64" >&5
+$as_echo "$ac_ct_OTOOL64" >&6; }
+else
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+ if test "x$ac_ct_OTOOL64" = x; then
+ OTOOL64=":"
+ else
+ case $cross_compiling:$ac_tool_warned in
+yes:)
+{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
+$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
+ac_tool_warned=yes ;;
+esac
+ OTOOL64=$ac_ct_OTOOL64
+ fi
+else
+ OTOOL64="$ac_cv_prog_OTOOL64"
+fi
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for -single_module linker flag" >&5
+$as_echo_n "checking for -single_module linker flag... " >&6; }
+if ${lt_cv_apple_cc_single_mod+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ lt_cv_apple_cc_single_mod=no
+ if test -z "${LT_MULTI_MODULE}"; then
+ # By default we will add the -single_module flag. You can override
+ # by either setting the environment variable LT_MULTI_MODULE
+ # non-empty at configure time, or by adding -multi_module to the
+ # link flags.
+ rm -rf libconftest.dylib*
+ echo "int foo(void){return 1;}" > conftest.c
+ echo "$LTCC $LTCFLAGS $LDFLAGS -o libconftest.dylib \
+-dynamiclib -Wl,-single_module conftest.c" >&5
+ $LTCC $LTCFLAGS $LDFLAGS -o libconftest.dylib \
+ -dynamiclib -Wl,-single_module conftest.c 2>conftest.err
+ _lt_result=$?
+ # If there is a non-empty error log, and "single_module"
+ # appears in it, assume the flag caused a linker warning
+ if test -s conftest.err && $GREP single_module conftest.err; then
+ cat conftest.err >&5
+ # Otherwise, if the output was created with a 0 exit code from
+ # the compiler, it worked.
+ elif test -f libconftest.dylib && test $_lt_result -eq 0; then
+ lt_cv_apple_cc_single_mod=yes
+ else
+ cat conftest.err >&5
+ fi
+ rm -rf libconftest.dylib*
+ rm -f conftest.*
+ fi
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_apple_cc_single_mod" >&5
+$as_echo "$lt_cv_apple_cc_single_mod" >&6; }
+
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for -exported_symbols_list linker flag" >&5
+$as_echo_n "checking for -exported_symbols_list linker flag... " >&6; }
+if ${lt_cv_ld_exported_symbols_list+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ lt_cv_ld_exported_symbols_list=no
+ save_LDFLAGS=$LDFLAGS
+ echo "_main" > conftest.sym
+ LDFLAGS="$LDFLAGS -Wl,-exported_symbols_list,conftest.sym"
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+
+int
+main ()
+{
+
+ ;
+ return 0;
+}
+_ACEOF
+if ac_fn_c_try_link "$LINENO"; then :
+ lt_cv_ld_exported_symbols_list=yes
+else
+ lt_cv_ld_exported_symbols_list=no
+fi
+rm -f core conftest.err conftest.$ac_objext \
+ conftest$ac_exeext conftest.$ac_ext
+ LDFLAGS="$save_LDFLAGS"
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_ld_exported_symbols_list" >&5
+$as_echo "$lt_cv_ld_exported_symbols_list" >&6; }
+
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for -force_load linker flag" >&5
+$as_echo_n "checking for -force_load linker flag... " >&6; }
+if ${lt_cv_ld_force_load+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ lt_cv_ld_force_load=no
+ cat > conftest.c << _LT_EOF
+int forced_loaded() { return 2;}
+_LT_EOF
+ echo "$LTCC $LTCFLAGS -c -o conftest.o conftest.c" >&5
+ $LTCC $LTCFLAGS -c -o conftest.o conftest.c 2>&5
+ echo "$AR cru libconftest.a conftest.o" >&5
+ $AR cru libconftest.a conftest.o 2>&5
+ echo "$RANLIB libconftest.a" >&5
+ $RANLIB libconftest.a 2>&5
+ cat > conftest.c << _LT_EOF
+int main() { return 0;}
+_LT_EOF
+ echo "$LTCC $LTCFLAGS $LDFLAGS -o conftest conftest.c -Wl,-force_load,./libconftest.a" >&5
+ $LTCC $LTCFLAGS $LDFLAGS -o conftest conftest.c -Wl,-force_load,./libconftest.a 2>conftest.err
+ _lt_result=$?
+ if test -s conftest.err && $GREP force_load conftest.err; then
+ cat conftest.err >&5
+ elif test -f conftest && test $_lt_result -eq 0 && $GREP forced_load conftest >/dev/null 2>&1 ; then
+ lt_cv_ld_force_load=yes
+ else
+ cat conftest.err >&5
+ fi
+ rm -f conftest.err libconftest.a conftest conftest.c
+ rm -rf conftest.dSYM
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_ld_force_load" >&5
+$as_echo "$lt_cv_ld_force_load" >&6; }
+ case $host_os in
+ rhapsody* | darwin1.[012])
+ _lt_dar_allow_undefined='${wl}-undefined ${wl}suppress' ;;
+ darwin1.*)
+ _lt_dar_allow_undefined='${wl}-flat_namespace ${wl}-undefined ${wl}suppress' ;;
+ darwin*) # darwin 5.x on
+ # if running on 10.5 or later, the deployment target defaults
+ # to the OS version, if on x86, and 10.4, the deployment
+ # target defaults to 10.4. Don't you love it?
+ case ${MACOSX_DEPLOYMENT_TARGET-10.0},$host in
+ 10.0,*86*-darwin8*|10.0,*-darwin[91]*)
+ _lt_dar_allow_undefined='${wl}-undefined ${wl}dynamic_lookup' ;;
+ 10.[012]*)
+ _lt_dar_allow_undefined='${wl}-flat_namespace ${wl}-undefined ${wl}suppress' ;;
+ 10.*)
+ _lt_dar_allow_undefined='${wl}-undefined ${wl}dynamic_lookup' ;;
+ esac
+ ;;
+ esac
+ if test "$lt_cv_apple_cc_single_mod" = "yes"; then
+ _lt_dar_single_mod='$single_module'
+ fi
+ if test "$lt_cv_ld_exported_symbols_list" = "yes"; then
+ _lt_dar_export_syms=' ${wl}-exported_symbols_list,$output_objdir/${libname}-symbols.expsym'
+ else
+ _lt_dar_export_syms='~$NMEDIT -s $output_objdir/${libname}-symbols.expsym ${lib}'
+ fi
+ if test "$DSYMUTIL" != ":" && test "$lt_cv_ld_force_load" = "no"; then
+ _lt_dsymutil='~$DSYMUTIL $lib || :'
+ else
+ _lt_dsymutil=
+ fi
+ ;;
+ esac
+
+ac_ext=c
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking how to run the C preprocessor" >&5
+$as_echo_n "checking how to run the C preprocessor... " >&6; }
+# On Suns, sometimes $CPP names a directory.
+if test -n "$CPP" && test -d "$CPP"; then
+ CPP=
+fi
+if test -z "$CPP"; then
+ if ${ac_cv_prog_CPP+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ # Double quotes because CPP needs to be expanded
+ for CPP in "$CC -E" "$CC -E -traditional-cpp" "/lib/cpp"
+ do
+ ac_preproc_ok=false
+for ac_c_preproc_warn_flag in '' yes
+do
+ # Use a header file that comes with gcc, so configuring glibc
+ # with a fresh cross-compiler works.
+ # Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
+ # <limits.h> exists even on freestanding compilers.
+ # On the NeXT, cc -E runs the code through the compiler's parser,
+ # not just through cpp. "Syntax error" is here to catch this case.
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+#ifdef __STDC__
+# include <limits.h>
+#else
+# include <assert.h>
+#endif
+ Syntax error
+_ACEOF
+if ac_fn_c_try_cpp "$LINENO"; then :
+
+else
+ # Broken: fails on valid input.
+continue
+fi
+rm -f conftest.err conftest.i conftest.$ac_ext
+
+ # OK, works on sane cases. Now check whether nonexistent headers
+ # can be detected and how.
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+#include <ac_nonexistent.h>
+_ACEOF
+if ac_fn_c_try_cpp "$LINENO"; then :
+ # Broken: success on invalid input.
+continue
+else
+ # Passes both tests.
+ac_preproc_ok=:
+break
+fi
+rm -f conftest.err conftest.i conftest.$ac_ext
+
+done
+# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped.
+rm -f conftest.i conftest.err conftest.$ac_ext
+if $ac_preproc_ok; then :
+ break
+fi
+
+ done
+ ac_cv_prog_CPP=$CPP
+
+fi
+ CPP=$ac_cv_prog_CPP
+else
+ ac_cv_prog_CPP=$CPP
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $CPP" >&5
+$as_echo "$CPP" >&6; }
+ac_preproc_ok=false
+for ac_c_preproc_warn_flag in '' yes
+do
+ # Use a header file that comes with gcc, so configuring glibc
+ # with a fresh cross-compiler works.
+ # Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
+ # <limits.h> exists even on freestanding compilers.
+ # On the NeXT, cc -E runs the code through the compiler's parser,
+ # not just through cpp. "Syntax error" is here to catch this case.
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+#ifdef __STDC__
+# include <limits.h>
+#else
+# include <assert.h>
+#endif
+ Syntax error
+_ACEOF
+if ac_fn_c_try_cpp "$LINENO"; then :
+
+else
+ # Broken: fails on valid input.
+continue
+fi
+rm -f conftest.err conftest.i conftest.$ac_ext
+
+ # OK, works on sane cases. Now check whether nonexistent headers
+ # can be detected and how.
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+#include <ac_nonexistent.h>
+_ACEOF
+if ac_fn_c_try_cpp "$LINENO"; then :
+ # Broken: success on invalid input.
+continue
+else
+ # Passes both tests.
+ac_preproc_ok=:
+break
+fi
+rm -f conftest.err conftest.i conftest.$ac_ext
+
+done
+# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped.
+rm -f conftest.i conftest.err conftest.$ac_ext
+if $ac_preproc_ok; then :
+
+else
+ { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
+$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
+as_fn_error $? "C preprocessor \"$CPP\" fails sanity check
+See \`config.log' for more details" "$LINENO" 5; }
+fi
+
+ac_ext=c
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
+
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for ANSI C header files" >&5
+$as_echo_n "checking for ANSI C header files... " >&6; }
+if ${ac_cv_header_stdc+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+#include <stdlib.h>
+#include <stdarg.h>
+#include <string.h>
+#include <float.h>
+
+int
+main ()
+{
+
+ ;
+ return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+ ac_cv_header_stdc=yes
+else
+ ac_cv_header_stdc=no
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+
+if test $ac_cv_header_stdc = yes; then
+ # SunOS 4.x string.h does not declare mem*, contrary to ANSI.
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+#include <string.h>
+
+_ACEOF
+if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
+ $EGREP "memchr" >/dev/null 2>&1; then :
+
+else
+ ac_cv_header_stdc=no
+fi
+rm -f conftest*
+
+fi
+
+if test $ac_cv_header_stdc = yes; then
+ # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI.
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+#include <stdlib.h>
+
+_ACEOF
+if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
+ $EGREP "free" >/dev/null 2>&1; then :
+
+else
+ ac_cv_header_stdc=no
+fi
+rm -f conftest*
+
+fi
+
+if test $ac_cv_header_stdc = yes; then
+ # /bin/cc in Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi.
+ if test "$cross_compiling" = yes; then :
+ :
+else
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+#include <ctype.h>
+#include <stdlib.h>
+#if ((' ' & 0x0FF) == 0x020)
+# define ISLOWER(c) ('a' <= (c) && (c) <= 'z')
+# define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c))
+#else
+# define ISLOWER(c) \
+ (('a' <= (c) && (c) <= 'i') \
+ || ('j' <= (c) && (c) <= 'r') \
+ || ('s' <= (c) && (c) <= 'z'))
+# define TOUPPER(c) (ISLOWER(c) ? ((c) | 0x40) : (c))
+#endif
+
+#define XOR(e, f) (((e) && !(f)) || (!(e) && (f)))
+int
+main ()
+{
+ int i;
+ for (i = 0; i < 256; i++)
+ if (XOR (islower (i), ISLOWER (i))
+ || toupper (i) != TOUPPER (i))
+ return 2;
+ return 0;
+}
+_ACEOF
+if ac_fn_c_try_run "$LINENO"; then :
+
+else
+ ac_cv_header_stdc=no
+fi
+rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
+ conftest.$ac_objext conftest.beam conftest.$ac_ext
+fi
+
+fi
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_header_stdc" >&5
+$as_echo "$ac_cv_header_stdc" >&6; }
+if test $ac_cv_header_stdc = yes; then
+
+$as_echo "#define STDC_HEADERS 1" >>confdefs.h
+
+fi
+
+# On IRIX 5.3, sys/types and inttypes.h are conflicting.
+for ac_header in sys/types.h sys/stat.h stdlib.h string.h memory.h strings.h \
+ inttypes.h stdint.h unistd.h
+do :
+ as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh`
+ac_fn_c_check_header_compile "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default
+"
+if eval test \"x\$"$as_ac_Header"\" = x"yes"; then :
+ cat >>confdefs.h <<_ACEOF
+#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1
+_ACEOF
+
+fi
+
+done
+
+
+for ac_header in dlfcn.h
+do :
+ ac_fn_c_check_header_compile "$LINENO" "dlfcn.h" "ac_cv_header_dlfcn_h" "$ac_includes_default
+"
+if test "x$ac_cv_header_dlfcn_h" = xyes; then :
+ cat >>confdefs.h <<_ACEOF
+#define HAVE_DLFCN_H 1
+_ACEOF
+
+fi
+
+done
+
+
+
+
+func_stripname_cnf ()
+{
+ case ${2} in
+ .*) func_stripname_result=`$ECHO "${3}" | $SED "s%^${1}%%; s%\\\\${2}\$%%"`;;
+ *) func_stripname_result=`$ECHO "${3}" | $SED "s%^${1}%%; s%${2}\$%%"`;;
+ esac
+} # func_stripname_cnf
+
+
+
+
+
+# Set options
+
+
+
+ enable_dlopen=no
+
+
+ enable_win32_dll=no
+
+
+ # Check whether --enable-shared was given.
+if test "${enable_shared+set}" = set; then :
+ enableval=$enable_shared; p=${PACKAGE-default}
+ case $enableval in
+ yes) enable_shared=yes ;;
+ no) enable_shared=no ;;
+ *)
+ enable_shared=no
+ # Look at the argument we got. We use all the common list separators.
+ lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR,"
+ for pkg in $enableval; do
+ IFS="$lt_save_ifs"
+ if test "X$pkg" = "X$p"; then
+ enable_shared=yes
+ fi
+ done
+ IFS="$lt_save_ifs"
+ ;;
+ esac
+else
+ enable_shared=yes
+fi
+
+
+
+
+
+
+
+
+
+ # Check whether --enable-static was given.
+if test "${enable_static+set}" = set; then :
+ enableval=$enable_static; p=${PACKAGE-default}
+ case $enableval in
+ yes) enable_static=yes ;;
+ no) enable_static=no ;;
+ *)
+ enable_static=no
+ # Look at the argument we got. We use all the common list separators.
+ lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR,"
+ for pkg in $enableval; do
+ IFS="$lt_save_ifs"
+ if test "X$pkg" = "X$p"; then
+ enable_static=yes
+ fi
+ done
+ IFS="$lt_save_ifs"
+ ;;
+ esac
+else
+ enable_static=yes
+fi
+
+
+
+
+
+
+
+
+
+
+# Check whether --with-pic was given.
+if test "${with_pic+set}" = set; then :
+ withval=$with_pic; lt_p=${PACKAGE-default}
+ case $withval in
+ yes|no) pic_mode=$withval ;;
+ *)
+ pic_mode=default
+ # Look at the argument we got. We use all the common list separators.
+ lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR,"
+ for lt_pkg in $withval; do
+ IFS="$lt_save_ifs"
+ if test "X$lt_pkg" = "X$lt_p"; then
+ pic_mode=yes
+ fi
+ done
+ IFS="$lt_save_ifs"
+ ;;
+ esac
+else
+ pic_mode=default
+fi
+
+
+test -z "$pic_mode" && pic_mode=default
+
+
+
+
+
+
+
+ # Check whether --enable-fast-install was given.
+if test "${enable_fast_install+set}" = set; then :
+ enableval=$enable_fast_install; p=${PACKAGE-default}
+ case $enableval in
+ yes) enable_fast_install=yes ;;
+ no) enable_fast_install=no ;;
+ *)
+ enable_fast_install=no
+ # Look at the argument we got. We use all the common list separators.
+ lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR,"
+ for pkg in $enableval; do
+ IFS="$lt_save_ifs"
+ if test "X$pkg" = "X$p"; then
+ enable_fast_install=yes
+ fi
+ done
+ IFS="$lt_save_ifs"
+ ;;
+ esac
+else
+ enable_fast_install=yes
+fi
+
+
+
+
+
+
+
+
+
+
+
+# This can be used to rebuild libtool when needed
+LIBTOOL_DEPS="$ltmain"
+
+# Always use our own libtool.
+LIBTOOL='$(SHELL) $(top_builddir)/libtool'
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+test -z "$LN_S" && LN_S="ln -s"
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+if test -n "${ZSH_VERSION+set}" ; then
+ setopt NO_GLOB_SUBST
+fi
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for objdir" >&5
+$as_echo_n "checking for objdir... " >&6; }
+if ${lt_cv_objdir+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ rm -f .libs 2>/dev/null
+mkdir .libs 2>/dev/null
+if test -d .libs; then
+ lt_cv_objdir=.libs
+else
+ # MS-DOS does not allow filenames that begin with a dot.
+ lt_cv_objdir=_libs
+fi
+rmdir .libs 2>/dev/null
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_objdir" >&5
+$as_echo "$lt_cv_objdir" >&6; }
+objdir=$lt_cv_objdir
+
+
+
+
+
+cat >>confdefs.h <<_ACEOF
+#define LT_OBJDIR "$lt_cv_objdir/"
+_ACEOF
+
+
+
+
+case $host_os in
+aix3*)
+ # AIX sometimes has problems with the GCC collect2 program. For some
+ # reason, if we set the COLLECT_NAMES environment variable, the problems
+ # vanish in a puff of smoke.
+ if test "X${COLLECT_NAMES+set}" != Xset; then
+ COLLECT_NAMES=
+ export COLLECT_NAMES
+ fi
+ ;;
+esac
+
+# Global variables:
+ofile=libtool
+can_build_shared=yes
+
+# All known linkers require a `.a' archive for static linking (except MSVC,
+# which needs '.lib').
+libext=a
+
+with_gnu_ld="$lt_cv_prog_gnu_ld"
+
+old_CC="$CC"
+old_CFLAGS="$CFLAGS"
+
+# Set sane defaults for various variables
+test -z "$CC" && CC=cc
+test -z "$LTCC" && LTCC=$CC
+test -z "$LTCFLAGS" && LTCFLAGS=$CFLAGS
+test -z "$LD" && LD=ld
+test -z "$ac_objext" && ac_objext=o
+
+for cc_temp in $compiler""; do
+ case $cc_temp in
+ compile | *[\\/]compile | ccache | *[\\/]ccache ) ;;
+ distcc | *[\\/]distcc | purify | *[\\/]purify ) ;;
+ \-*) ;;
+ *) break;;
+ esac
+done
+cc_basename=`$ECHO "$cc_temp" | $SED "s%.*/%%; s%^$host_alias-%%"`
+
+
+# Only perform the check for file, if the check method requires it
+test -z "$MAGIC_CMD" && MAGIC_CMD=file
+case $deplibs_check_method in
+file_magic*)
+ if test "$file_magic_cmd" = '$MAGIC_CMD'; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ${ac_tool_prefix}file" >&5
+$as_echo_n "checking for ${ac_tool_prefix}file... " >&6; }
+if ${lt_cv_path_MAGIC_CMD+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ case $MAGIC_CMD in
+[\\/*] | ?:[\\/]*)
+ lt_cv_path_MAGIC_CMD="$MAGIC_CMD" # Let the user override the test with a path.
+ ;;
+*)
+ lt_save_MAGIC_CMD="$MAGIC_CMD"
+ lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR
+ ac_dummy="/usr/bin$PATH_SEPARATOR$PATH"
+ for ac_dir in $ac_dummy; do
+ IFS="$lt_save_ifs"
+ test -z "$ac_dir" && ac_dir=.
+ if test -f $ac_dir/${ac_tool_prefix}file; then
+ lt_cv_path_MAGIC_CMD="$ac_dir/${ac_tool_prefix}file"
+ if test -n "$file_magic_test_file"; then
+ case $deplibs_check_method in
+ "file_magic "*)
+ file_magic_regex=`expr "$deplibs_check_method" : "file_magic \(.*\)"`
+ MAGIC_CMD="$lt_cv_path_MAGIC_CMD"
+ if eval $file_magic_cmd \$file_magic_test_file 2> /dev/null |
+ $EGREP "$file_magic_regex" > /dev/null; then
+ :
+ else
+ cat <<_LT_EOF 1>&2
+
+*** Warning: the command libtool uses to detect shared libraries,
+*** $file_magic_cmd, produces output that libtool cannot recognize.
+*** The result is that libtool may fail to recognize shared libraries
+*** as such. This will affect the creation of libtool libraries that
+*** depend on shared libraries, but programs linked with such libtool
+*** libraries will work regardless of this problem. Nevertheless, you
+*** may want to report the problem to your system manager and/or to
+*** bug-libtool@gnu.org
+
+_LT_EOF
+ fi ;;
+ esac
+ fi
+ break
+ fi
+ done
+ IFS="$lt_save_ifs"
+ MAGIC_CMD="$lt_save_MAGIC_CMD"
+ ;;
+esac
+fi
+
+MAGIC_CMD="$lt_cv_path_MAGIC_CMD"
+if test -n "$MAGIC_CMD"; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $MAGIC_CMD" >&5
+$as_echo "$MAGIC_CMD" >&6; }
+else
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+
+
+
+if test -z "$lt_cv_path_MAGIC_CMD"; then
+ if test -n "$ac_tool_prefix"; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for file" >&5
+$as_echo_n "checking for file... " >&6; }
+if ${lt_cv_path_MAGIC_CMD+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ case $MAGIC_CMD in
+[\\/*] | ?:[\\/]*)
+ lt_cv_path_MAGIC_CMD="$MAGIC_CMD" # Let the user override the test with a path.
+ ;;
+*)
+ lt_save_MAGIC_CMD="$MAGIC_CMD"
+ lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR
+ ac_dummy="/usr/bin$PATH_SEPARATOR$PATH"
+ for ac_dir in $ac_dummy; do
+ IFS="$lt_save_ifs"
+ test -z "$ac_dir" && ac_dir=.
+ if test -f $ac_dir/file; then
+ lt_cv_path_MAGIC_CMD="$ac_dir/file"
+ if test -n "$file_magic_test_file"; then
+ case $deplibs_check_method in
+ "file_magic "*)
+ file_magic_regex=`expr "$deplibs_check_method" : "file_magic \(.*\)"`
+ MAGIC_CMD="$lt_cv_path_MAGIC_CMD"
+ if eval $file_magic_cmd \$file_magic_test_file 2> /dev/null |
+ $EGREP "$file_magic_regex" > /dev/null; then
+ :
+ else
+ cat <<_LT_EOF 1>&2
+
+*** Warning: the command libtool uses to detect shared libraries,
+*** $file_magic_cmd, produces output that libtool cannot recognize.
+*** The result is that libtool may fail to recognize shared libraries
+*** as such. This will affect the creation of libtool libraries that
+*** depend on shared libraries, but programs linked with such libtool
+*** libraries will work regardless of this problem. Nevertheless, you
+*** may want to report the problem to your system manager and/or to
+*** bug-libtool@gnu.org
+
+_LT_EOF
+ fi ;;
+ esac
+ fi
+ break
+ fi
+ done
+ IFS="$lt_save_ifs"
+ MAGIC_CMD="$lt_save_MAGIC_CMD"
+ ;;
+esac
+fi
+
+MAGIC_CMD="$lt_cv_path_MAGIC_CMD"
+if test -n "$MAGIC_CMD"; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $MAGIC_CMD" >&5
+$as_echo "$MAGIC_CMD" >&6; }
+else
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+ else
+ MAGIC_CMD=:
+ fi
+fi
+
+ fi
+ ;;
+esac
+
+# Use C for the default configuration in the libtool script
+
+lt_save_CC="$CC"
+ac_ext=c
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
+
+
+# Source file extension for C test sources.
+ac_ext=c
+
+# Object file extension for compiled C test sources.
+objext=o
+objext=$objext
+
+# Code to be used in simple compile tests
+lt_simple_compile_test_code="int some_variable = 0;"
+
+# Code to be used in simple link tests
+lt_simple_link_test_code='int main(){return(0);}'
+
+
+
+
+
+
+
+# If no C compiler was specified, use CC.
+LTCC=${LTCC-"$CC"}
+
+# If no C compiler flags were specified, use CFLAGS.
+LTCFLAGS=${LTCFLAGS-"$CFLAGS"}
+
+# Allow CC to be a program name with arguments.
+compiler=$CC
+
+# Save the default compiler, since it gets overwritten when the other
+# tags are being tested, and _LT_TAGVAR(compiler, []) is a NOP.
+compiler_DEFAULT=$CC
+
+# save warnings/boilerplate of simple test code
+ac_outfile=conftest.$ac_objext
+echo "$lt_simple_compile_test_code" >conftest.$ac_ext
+eval "$ac_compile" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err
+_lt_compiler_boilerplate=`cat conftest.err`
+$RM conftest*
+
+ac_outfile=conftest.$ac_objext
+echo "$lt_simple_link_test_code" >conftest.$ac_ext
+eval "$ac_link" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err
+_lt_linker_boilerplate=`cat conftest.err`
+$RM -r conftest*
+
+
+## CAVEAT EMPTOR:
+## There is no encapsulation within the following macros, do not change
+## the running order or otherwise move them around unless you know exactly
+## what you are doing...
+if test -n "$compiler"; then
+
+lt_prog_compiler_no_builtin_flag=
+
+if test "$GCC" = yes; then
+ case $cc_basename in
+ nvcc*)
+ lt_prog_compiler_no_builtin_flag=' -Xcompiler -fno-builtin' ;;
+ *)
+ lt_prog_compiler_no_builtin_flag=' -fno-builtin' ;;
+ esac
+
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $compiler supports -fno-rtti -fno-exceptions" >&5
+$as_echo_n "checking if $compiler supports -fno-rtti -fno-exceptions... " >&6; }
+if ${lt_cv_prog_compiler_rtti_exceptions+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ lt_cv_prog_compiler_rtti_exceptions=no
+ ac_outfile=conftest.$ac_objext
+ echo "$lt_simple_compile_test_code" > conftest.$ac_ext
+ lt_compiler_flag="-fno-rtti -fno-exceptions"
+ # Insert the option either (1) after the last *FLAGS variable, or
+ # (2) before a word containing "conftest.", or (3) at the end.
+ # Note that $ac_compile itself does not contain backslashes and begins
+ # with a dollar sign (not a hyphen), so the echo should work correctly.
+ # The option is referenced via a variable to avoid confusing sed.
+ lt_compile=`echo "$ac_compile" | $SED \
+ -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
+ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
+ -e 's:$: $lt_compiler_flag:'`
+ (eval echo "\"\$as_me:$LINENO: $lt_compile\"" >&5)
+ (eval "$lt_compile" 2>conftest.err)
+ ac_status=$?
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ if (exit $ac_status) && test -s "$ac_outfile"; then
+ # The compiler can only warn and ignore the option if not recognized
+ # So say no if there are warnings other than the usual output.
+ $ECHO "$_lt_compiler_boilerplate" | $SED '/^$/d' >conftest.exp
+ $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2
+ if test ! -s conftest.er2 || diff conftest.exp conftest.er2 >/dev/null; then
+ lt_cv_prog_compiler_rtti_exceptions=yes
+ fi
+ fi
+ $RM conftest*
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_rtti_exceptions" >&5
+$as_echo "$lt_cv_prog_compiler_rtti_exceptions" >&6; }
+
+if test x"$lt_cv_prog_compiler_rtti_exceptions" = xyes; then
+ lt_prog_compiler_no_builtin_flag="$lt_prog_compiler_no_builtin_flag -fno-rtti -fno-exceptions"
+else
+ :
+fi
+
+fi
+
+
+
+
+
+
+ lt_prog_compiler_wl=
+lt_prog_compiler_pic=
+lt_prog_compiler_static=
+
+
+ if test "$GCC" = yes; then
+ lt_prog_compiler_wl='-Wl,'
+ lt_prog_compiler_static='-static'
+
+ case $host_os in
+ aix*)
+ # All AIX code is PIC.
+ if test "$host_cpu" = ia64; then
+ # AIX 5 now supports IA64 processor
+ lt_prog_compiler_static='-Bstatic'
+ fi
+ ;;
+
+ amigaos*)
+ case $host_cpu in
+ powerpc)
+ # see comment about AmigaOS4 .so support
+ lt_prog_compiler_pic='-fPIC'
+ ;;
+ m68k)
+ # FIXME: we need at least 68020 code to build shared libraries, but
+ # adding the `-m68020' flag to GCC prevents building anything better,
+ # like `-m68040'.
+ lt_prog_compiler_pic='-m68020 -resident32 -malways-restore-a4'
+ ;;
+ esac
+ ;;
+
+ beos* | irix5* | irix6* | nonstopux* | osf3* | osf4* | osf5*)
+ # PIC is the default for these OSes.
+ ;;
+
+ mingw* | cygwin* | pw32* | os2* | cegcc*)
+ # This hack is so that the source file can tell whether it is being
+ # built for inclusion in a dll (and should export symbols for example).
+ # Although the cygwin gcc ignores -fPIC, still need this for old-style
+ # (--disable-auto-import) libraries
+ lt_prog_compiler_pic='-DDLL_EXPORT'
+ ;;
+
+ darwin* | rhapsody*)
+ # PIC is the default on this platform
+ # Common symbols not allowed in MH_DYLIB files
+ lt_prog_compiler_pic='-fno-common'
+ ;;
+
+ haiku*)
+ # PIC is the default for Haiku.
+ # The "-static" flag exists, but is broken.
+ lt_prog_compiler_static=
+ ;;
+
+ hpux*)
+ # PIC is the default for 64-bit PA HP-UX, but not for 32-bit
+ # PA HP-UX. On IA64 HP-UX, PIC is the default but the pic flag
+ # sets the default TLS model and affects inlining.
+ case $host_cpu in
+ hppa*64*)
+ # +Z the default
+ ;;
+ *)
+ lt_prog_compiler_pic='-fPIC'
+ ;;
+ esac
+ ;;
+
+ interix[3-9]*)
+ # Interix 3.x gcc -fpic/-fPIC options generate broken code.
+ # Instead, we relocate shared libraries at runtime.
+ ;;
+
+ msdosdjgpp*)
+ # Just because we use GCC doesn't mean we suddenly get shared libraries
+ # on systems that don't support them.
+ lt_prog_compiler_can_build_shared=no
+ enable_shared=no
+ ;;
+
+ *nto* | *qnx*)
+ # QNX uses GNU C++, but need to define -shared option too, otherwise
+ # it will coredump.
+ lt_prog_compiler_pic='-fPIC -shared'
+ ;;
+
+ sysv4*MP*)
+ if test -d /usr/nec; then
+ lt_prog_compiler_pic=-Kconform_pic
+ fi
+ ;;
+
+ *)
+ lt_prog_compiler_pic='-fPIC'
+ ;;
+ esac
+
+ case $cc_basename in
+ nvcc*) # Cuda Compiler Driver 2.2
+ lt_prog_compiler_wl='-Xlinker '
+ if test -n "$lt_prog_compiler_pic"; then
+ lt_prog_compiler_pic="-Xcompiler $lt_prog_compiler_pic"
+ fi
+ ;;
+ esac
+ else
+ # PORTME Check for flag to pass linker flags through the system compiler.
+ case $host_os in
+ aix*)
+ lt_prog_compiler_wl='-Wl,'
+ if test "$host_cpu" = ia64; then
+ # AIX 5 now supports IA64 processor
+ lt_prog_compiler_static='-Bstatic'
+ else
+ lt_prog_compiler_static='-bnso -bI:/lib/syscalls.exp'
+ fi
+ ;;
+
+ mingw* | cygwin* | pw32* | os2* | cegcc*)
+ # This hack is so that the source file can tell whether it is being
+ # built for inclusion in a dll (and should export symbols for example).
+ lt_prog_compiler_pic='-DDLL_EXPORT'
+ ;;
+
+ hpux9* | hpux10* | hpux11*)
+ lt_prog_compiler_wl='-Wl,'
+ # PIC is the default for IA64 HP-UX and 64-bit HP-UX, but
+ # not for PA HP-UX.
+ case $host_cpu in
+ hppa*64*|ia64*)
+ # +Z the default
+ ;;
+ *)
+ lt_prog_compiler_pic='+Z'
+ ;;
+ esac
+ # Is there a better lt_prog_compiler_static that works with the bundled CC?
+ lt_prog_compiler_static='${wl}-a ${wl}archive'
+ ;;
+
+ irix5* | irix6* | nonstopux*)
+ lt_prog_compiler_wl='-Wl,'
+ # PIC (with -KPIC) is the default.
+ lt_prog_compiler_static='-non_shared'
+ ;;
+
+ linux* | k*bsd*-gnu | kopensolaris*-gnu)
+ case $cc_basename in
+ # old Intel for x86_64 which still supported -KPIC.
+ ecc*)
+ lt_prog_compiler_wl='-Wl,'
+ lt_prog_compiler_pic='-KPIC'
+ lt_prog_compiler_static='-static'
+ ;;
+ # icc used to be incompatible with GCC.
+ # ICC 10 doesn't accept -KPIC any more.
+ icc* | ifort*)
+ lt_prog_compiler_wl='-Wl,'
+ lt_prog_compiler_pic='-fPIC'
+ lt_prog_compiler_static='-static'
+ ;;
+ # Lahey Fortran 8.1.
+ lf95*)
+ lt_prog_compiler_wl='-Wl,'
+ lt_prog_compiler_pic='--shared'
+ lt_prog_compiler_static='--static'
+ ;;
+ nagfor*)
+ # NAG Fortran compiler
+ lt_prog_compiler_wl='-Wl,-Wl,,'
+ lt_prog_compiler_pic='-PIC'
+ lt_prog_compiler_static='-Bstatic'
+ ;;
+ pgcc* | pgf77* | pgf90* | pgf95* | pgfortran*)
+ # Portland Group compilers (*not* the Pentium gcc compiler,
+ # which looks to be a dead project)
+ lt_prog_compiler_wl='-Wl,'
+ lt_prog_compiler_pic='-fpic'
+ lt_prog_compiler_static='-Bstatic'
+ ;;
+ ccc*)
+ lt_prog_compiler_wl='-Wl,'
+ # All Alpha code is PIC.
+ lt_prog_compiler_static='-non_shared'
+ ;;
+ xl* | bgxl* | bgf* | mpixl*)
+ # IBM XL C 8.0/Fortran 10.1, 11.1 on PPC and BlueGene
+ lt_prog_compiler_wl='-Wl,'
+ lt_prog_compiler_pic='-qpic'
+ lt_prog_compiler_static='-qstaticlink'
+ ;;
+ *)
+ case `$CC -V 2>&1 | sed 5q` in
+ *Sun\ Ceres\ Fortran* | *Sun*Fortran*\ [1-7].* | *Sun*Fortran*\ 8.[0-3]*)
+ # Sun Fortran 8.3 passes all unrecognized flags to the linker
+ lt_prog_compiler_pic='-KPIC'
+ lt_prog_compiler_static='-Bstatic'
+ lt_prog_compiler_wl=''
+ ;;
+ *Sun\ F* | *Sun*Fortran*)
+ lt_prog_compiler_pic='-KPIC'
+ lt_prog_compiler_static='-Bstatic'
+ lt_prog_compiler_wl='-Qoption ld '
+ ;;
+ *Sun\ C*)
+ # Sun C 5.9
+ lt_prog_compiler_pic='-KPIC'
+ lt_prog_compiler_static='-Bstatic'
+ lt_prog_compiler_wl='-Wl,'
+ ;;
+ *Intel*\ [CF]*Compiler*)
+ lt_prog_compiler_wl='-Wl,'
+ lt_prog_compiler_pic='-fPIC'
+ lt_prog_compiler_static='-static'
+ ;;
+ *Portland\ Group*)
+ lt_prog_compiler_wl='-Wl,'
+ lt_prog_compiler_pic='-fpic'
+ lt_prog_compiler_static='-Bstatic'
+ ;;
+ esac
+ ;;
+ esac
+ ;;
+
+ newsos6)
+ lt_prog_compiler_pic='-KPIC'
+ lt_prog_compiler_static='-Bstatic'
+ ;;
+
+ *nto* | *qnx*)
+ # QNX uses GNU C++, but need to define -shared option too, otherwise
+ # it will coredump.
+ lt_prog_compiler_pic='-fPIC -shared'
+ ;;
+
+ osf3* | osf4* | osf5*)
+ lt_prog_compiler_wl='-Wl,'
+ # All OSF/1 code is PIC.
+ lt_prog_compiler_static='-non_shared'
+ ;;
+
+ rdos*)
+ lt_prog_compiler_static='-non_shared'
+ ;;
+
+ solaris*)
+ lt_prog_compiler_pic='-KPIC'
+ lt_prog_compiler_static='-Bstatic'
+ case $cc_basename in
+ f77* | f90* | f95* | sunf77* | sunf90* | sunf95*)
+ lt_prog_compiler_wl='-Qoption ld ';;
+ *)
+ lt_prog_compiler_wl='-Wl,';;
+ esac
+ ;;
+
+ sunos4*)
+ lt_prog_compiler_wl='-Qoption ld '
+ lt_prog_compiler_pic='-PIC'
+ lt_prog_compiler_static='-Bstatic'
+ ;;
+
+ sysv4 | sysv4.2uw2* | sysv4.3*)
+ lt_prog_compiler_wl='-Wl,'
+ lt_prog_compiler_pic='-KPIC'
+ lt_prog_compiler_static='-Bstatic'
+ ;;
+
+ sysv4*MP*)
+ if test -d /usr/nec ;then
+ lt_prog_compiler_pic='-Kconform_pic'
+ lt_prog_compiler_static='-Bstatic'
+ fi
+ ;;
+
+ sysv5* | unixware* | sco3.2v5* | sco5v6* | OpenUNIX*)
+ lt_prog_compiler_wl='-Wl,'
+ lt_prog_compiler_pic='-KPIC'
+ lt_prog_compiler_static='-Bstatic'
+ ;;
+
+ unicos*)
+ lt_prog_compiler_wl='-Wl,'
+ lt_prog_compiler_can_build_shared=no
+ ;;
+
+ uts4*)
+ lt_prog_compiler_pic='-pic'
+ lt_prog_compiler_static='-Bstatic'
+ ;;
+
+ *)
+ lt_prog_compiler_can_build_shared=no
+ ;;
+ esac
+ fi
+
+case $host_os in
+ # For platforms which do not support PIC, -DPIC is meaningless:
+ *djgpp*)
+ lt_prog_compiler_pic=
+ ;;
+ *)
+ lt_prog_compiler_pic="$lt_prog_compiler_pic -DPIC"
+ ;;
+esac
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $compiler option to produce PIC" >&5
+$as_echo_n "checking for $compiler option to produce PIC... " >&6; }
+if ${lt_cv_prog_compiler_pic+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ lt_cv_prog_compiler_pic=$lt_prog_compiler_pic
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_pic" >&5
+$as_echo "$lt_cv_prog_compiler_pic" >&6; }
+lt_prog_compiler_pic=$lt_cv_prog_compiler_pic
+
+#
+# Check to make sure the PIC flag actually works.
+#
+if test -n "$lt_prog_compiler_pic"; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $compiler PIC flag $lt_prog_compiler_pic works" >&5
+$as_echo_n "checking if $compiler PIC flag $lt_prog_compiler_pic works... " >&6; }
+if ${lt_cv_prog_compiler_pic_works+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ lt_cv_prog_compiler_pic_works=no
+ ac_outfile=conftest.$ac_objext
+ echo "$lt_simple_compile_test_code" > conftest.$ac_ext
+ lt_compiler_flag="$lt_prog_compiler_pic -DPIC"
+ # Insert the option either (1) after the last *FLAGS variable, or
+ # (2) before a word containing "conftest.", or (3) at the end.
+ # Note that $ac_compile itself does not contain backslashes and begins
+ # with a dollar sign (not a hyphen), so the echo should work correctly.
+ # The option is referenced via a variable to avoid confusing sed.
+ lt_compile=`echo "$ac_compile" | $SED \
+ -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
+ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
+ -e 's:$: $lt_compiler_flag:'`
+ (eval echo "\"\$as_me:$LINENO: $lt_compile\"" >&5)
+ (eval "$lt_compile" 2>conftest.err)
+ ac_status=$?
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ if (exit $ac_status) && test -s "$ac_outfile"; then
+ # The compiler can only warn and ignore the option if not recognized
+ # So say no if there are warnings other than the usual output.
+ $ECHO "$_lt_compiler_boilerplate" | $SED '/^$/d' >conftest.exp
+ $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2
+ if test ! -s conftest.er2 || diff conftest.exp conftest.er2 >/dev/null; then
+ lt_cv_prog_compiler_pic_works=yes
+ fi
+ fi
+ $RM conftest*
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_pic_works" >&5
+$as_echo "$lt_cv_prog_compiler_pic_works" >&6; }
+
+if test x"$lt_cv_prog_compiler_pic_works" = xyes; then
+ case $lt_prog_compiler_pic in
+ "" | " "*) ;;
+ *) lt_prog_compiler_pic=" $lt_prog_compiler_pic" ;;
+ esac
+else
+ lt_prog_compiler_pic=
+ lt_prog_compiler_can_build_shared=no
+fi
+
+fi
+
+
+
+
+
+
+
+
+
+
+
+#
+# Check to make sure the static flag actually works.
+#
+wl=$lt_prog_compiler_wl eval lt_tmp_static_flag=\"$lt_prog_compiler_static\"
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if $compiler static flag $lt_tmp_static_flag works" >&5
+$as_echo_n "checking if $compiler static flag $lt_tmp_static_flag works... " >&6; }
+if ${lt_cv_prog_compiler_static_works+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ lt_cv_prog_compiler_static_works=no
+ save_LDFLAGS="$LDFLAGS"
+ LDFLAGS="$LDFLAGS $lt_tmp_static_flag"
+ echo "$lt_simple_link_test_code" > conftest.$ac_ext
+ if (eval $ac_link 2>conftest.err) && test -s conftest$ac_exeext; then
+ # The linker can only warn and ignore the option if not recognized
+ # So say no if there are warnings
+ if test -s conftest.err; then
+ # Append any errors to the config.log.
+ cat conftest.err 1>&5
+ $ECHO "$_lt_linker_boilerplate" | $SED '/^$/d' > conftest.exp
+ $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2
+ if diff conftest.exp conftest.er2 >/dev/null; then
+ lt_cv_prog_compiler_static_works=yes
+ fi
+ else
+ lt_cv_prog_compiler_static_works=yes
+ fi
+ fi
+ $RM -r conftest*
+ LDFLAGS="$save_LDFLAGS"
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_static_works" >&5
+$as_echo "$lt_cv_prog_compiler_static_works" >&6; }
+
+if test x"$lt_cv_prog_compiler_static_works" = xyes; then
+ :
+else
+ lt_prog_compiler_static=
+fi
+
+
+
+
+
+
+
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $compiler supports -c -o file.$ac_objext" >&5
+$as_echo_n "checking if $compiler supports -c -o file.$ac_objext... " >&6; }
+if ${lt_cv_prog_compiler_c_o+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ lt_cv_prog_compiler_c_o=no
+ $RM -r conftest 2>/dev/null
+ mkdir conftest
+ cd conftest
+ mkdir out
+ echo "$lt_simple_compile_test_code" > conftest.$ac_ext
+
+ lt_compiler_flag="-o out/conftest2.$ac_objext"
+ # Insert the option either (1) after the last *FLAGS variable, or
+ # (2) before a word containing "conftest.", or (3) at the end.
+ # Note that $ac_compile itself does not contain backslashes and begins
+ # with a dollar sign (not a hyphen), so the echo should work correctly.
+ lt_compile=`echo "$ac_compile" | $SED \
+ -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
+ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
+ -e 's:$: $lt_compiler_flag:'`
+ (eval echo "\"\$as_me:$LINENO: $lt_compile\"" >&5)
+ (eval "$lt_compile" 2>out/conftest.err)
+ ac_status=$?
+ cat out/conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ if (exit $ac_status) && test -s out/conftest2.$ac_objext
+ then
+ # The compiler can only warn and ignore the option if not recognized
+ # So say no if there are warnings
+ $ECHO "$_lt_compiler_boilerplate" | $SED '/^$/d' > out/conftest.exp
+ $SED '/^$/d; /^ *+/d' out/conftest.err >out/conftest.er2
+ if test ! -s out/conftest.er2 || diff out/conftest.exp out/conftest.er2 >/dev/null; then
+ lt_cv_prog_compiler_c_o=yes
+ fi
+ fi
+ chmod u+w . 2>&5
+ $RM conftest*
+ # SGI C++ compiler will create directory out/ii_files/ for
+ # template instantiation
+ test -d out/ii_files && $RM out/ii_files/* && rmdir out/ii_files
+ $RM out/* && rmdir out
+ cd ..
+ $RM -r conftest
+ $RM conftest*
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_c_o" >&5
+$as_echo "$lt_cv_prog_compiler_c_o" >&6; }
+
+
+
+
+
+
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $compiler supports -c -o file.$ac_objext" >&5
+$as_echo_n "checking if $compiler supports -c -o file.$ac_objext... " >&6; }
+if ${lt_cv_prog_compiler_c_o+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ lt_cv_prog_compiler_c_o=no
+ $RM -r conftest 2>/dev/null
+ mkdir conftest
+ cd conftest
+ mkdir out
+ echo "$lt_simple_compile_test_code" > conftest.$ac_ext
+
+ lt_compiler_flag="-o out/conftest2.$ac_objext"
+ # Insert the option either (1) after the last *FLAGS variable, or
+ # (2) before a word containing "conftest.", or (3) at the end.
+ # Note that $ac_compile itself does not contain backslashes and begins
+ # with a dollar sign (not a hyphen), so the echo should work correctly.
+ lt_compile=`echo "$ac_compile" | $SED \
+ -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
+ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
+ -e 's:$: $lt_compiler_flag:'`
+ (eval echo "\"\$as_me:$LINENO: $lt_compile\"" >&5)
+ (eval "$lt_compile" 2>out/conftest.err)
+ ac_status=$?
+ cat out/conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ if (exit $ac_status) && test -s out/conftest2.$ac_objext
+ then
+ # The compiler can only warn and ignore the option if not recognized
+ # So say no if there are warnings
+ $ECHO "$_lt_compiler_boilerplate" | $SED '/^$/d' > out/conftest.exp
+ $SED '/^$/d; /^ *+/d' out/conftest.err >out/conftest.er2
+ if test ! -s out/conftest.er2 || diff out/conftest.exp out/conftest.er2 >/dev/null; then
+ lt_cv_prog_compiler_c_o=yes
+ fi
+ fi
+ chmod u+w . 2>&5
+ $RM conftest*
+ # SGI C++ compiler will create directory out/ii_files/ for
+ # template instantiation
+ test -d out/ii_files && $RM out/ii_files/* && rmdir out/ii_files
+ $RM out/* && rmdir out
+ cd ..
+ $RM -r conftest
+ $RM conftest*
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_c_o" >&5
+$as_echo "$lt_cv_prog_compiler_c_o" >&6; }
+
+
+
+
+hard_links="nottested"
+if test "$lt_cv_prog_compiler_c_o" = no && test "$need_locks" != no; then
+ # do not overwrite the value of need_locks provided by the user
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking if we can lock with hard links" >&5
+$as_echo_n "checking if we can lock with hard links... " >&6; }
+ hard_links=yes
+ $RM conftest*
+ ln conftest.a conftest.b 2>/dev/null && hard_links=no
+ touch conftest.a
+ ln conftest.a conftest.b 2>&5 || hard_links=no
+ ln conftest.a conftest.b 2>/dev/null && hard_links=no
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $hard_links" >&5
+$as_echo "$hard_links" >&6; }
+ if test "$hard_links" = no; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: \`$CC' does not support \`-c -o', so \`make -j' may be unsafe" >&5
+$as_echo "$as_me: WARNING: \`$CC' does not support \`-c -o', so \`make -j' may be unsafe" >&2;}
+ need_locks=warn
+ fi
+else
+ need_locks=no
+fi
+
+
+
+
+
+
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the $compiler linker ($LD) supports shared libraries" >&5
+$as_echo_n "checking whether the $compiler linker ($LD) supports shared libraries... " >&6; }
+
+ runpath_var=
+ allow_undefined_flag=
+ always_export_symbols=no
+ archive_cmds=
+ archive_expsym_cmds=
+ compiler_needs_object=no
+ enable_shared_with_static_runtimes=no
+ export_dynamic_flag_spec=
+ export_symbols_cmds='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols'
+ hardcode_automatic=no
+ hardcode_direct=no
+ hardcode_direct_absolute=no
+ hardcode_libdir_flag_spec=
+ hardcode_libdir_separator=
+ hardcode_minus_L=no
+ hardcode_shlibpath_var=unsupported
+ inherit_rpath=no
+ link_all_deplibs=unknown
+ module_cmds=
+ module_expsym_cmds=
+ old_archive_from_new_cmds=
+ old_archive_from_expsyms_cmds=
+ thread_safe_flag_spec=
+ whole_archive_flag_spec=
+ # include_expsyms should be a list of space-separated symbols to be *always*
+ # included in the symbol list
+ include_expsyms=
+ # exclude_expsyms can be an extended regexp of symbols to exclude
+ # it will be wrapped by ` (' and `)$', so one must not match beginning or
+ # end of line. Example: `a|bc|.*d.*' will exclude the symbols `a' and `bc',
+ # as well as any symbol that contains `d'.
+ exclude_expsyms='_GLOBAL_OFFSET_TABLE_|_GLOBAL__F[ID]_.*'
+ # Although _GLOBAL_OFFSET_TABLE_ is a valid symbol C name, most a.out
+ # platforms (ab)use it in PIC code, but their linkers get confused if
+ # the symbol is explicitly referenced. Since portable code cannot
+ # rely on this symbol name, it's probably fine to never include it in
+ # preloaded symbol tables.
+ # Exclude shared library initialization/finalization symbols.
+ extract_expsyms_cmds=
+
+ case $host_os in
+ cygwin* | mingw* | pw32* | cegcc*)
+ # FIXME: the MSVC++ port hasn't been tested in a loooong time
+ # When not using gcc, we currently assume that we are using
+ # Microsoft Visual C++.
+ if test "$GCC" != yes; then
+ with_gnu_ld=no
+ fi
+ ;;
+ interix*)
+ # we just hope/assume this is gcc and not c89 (= MSVC++)
+ with_gnu_ld=yes
+ ;;
+ openbsd*)
+ with_gnu_ld=no
+ ;;
+ esac
+
+ ld_shlibs=yes
+
+ # On some targets, GNU ld is compatible enough with the native linker
+ # that we're better off using the native interface for both.
+ lt_use_gnu_ld_interface=no
+ if test "$with_gnu_ld" = yes; then
+ case $host_os in
+ aix*)
+ # The AIX port of GNU ld has always aspired to compatibility
+ # with the native linker. However, as the warning in the GNU ld
+ # block says, versions before 2.19.5* couldn't really create working
+ # shared libraries, regardless of the interface used.
+ case `$LD -v 2>&1` in
+ *\ \(GNU\ Binutils\)\ 2.19.5*) ;;
+ *\ \(GNU\ Binutils\)\ 2.[2-9]*) ;;
+ *\ \(GNU\ Binutils\)\ [3-9]*) ;;
+ *)
+ lt_use_gnu_ld_interface=yes
+ ;;
+ esac
+ ;;
+ *)
+ lt_use_gnu_ld_interface=yes
+ ;;
+ esac
+ fi
+
+ if test "$lt_use_gnu_ld_interface" = yes; then
+ # If archive_cmds runs LD, not CC, wlarc should be empty
+ wlarc='${wl}'
+
+ # Set some defaults for GNU ld with shared library support. These
+ # are reset later if shared libraries are not supported. Putting them
+ # here allows them to be overridden if necessary.
+ runpath_var=LD_RUN_PATH
+ hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir'
+ export_dynamic_flag_spec='${wl}--export-dynamic'
+ # ancient GNU ld didn't support --whole-archive et. al.
+ if $LD --help 2>&1 | $GREP 'no-whole-archive' > /dev/null; then
+ whole_archive_flag_spec="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive'
+ else
+ whole_archive_flag_spec=
+ fi
+ supports_anon_versioning=no
+ case `$LD -v 2>&1` in
+ *GNU\ gold*) supports_anon_versioning=yes ;;
+ *\ [01].* | *\ 2.[0-9].* | *\ 2.10.*) ;; # catch versions < 2.11
+ *\ 2.11.93.0.2\ *) supports_anon_versioning=yes ;; # RH7.3 ...
+ *\ 2.11.92.0.12\ *) supports_anon_versioning=yes ;; # Mandrake 8.2 ...
+ *\ 2.11.*) ;; # other 2.11 versions
+ *) supports_anon_versioning=yes ;;
+ esac
+
+ # See if GNU ld supports shared libraries.
+ case $host_os in
+ aix[3-9]*)
+ # On AIX/PPC, the GNU linker is very broken
+ if test "$host_cpu" != ia64; then
+ ld_shlibs=no
+ cat <<_LT_EOF 1>&2
+
+*** Warning: the GNU linker, at least up to release 2.19, is reported
+*** to be unable to reliably create shared libraries on AIX.
+*** Therefore, libtool is disabling shared libraries support. If you
+*** really care for shared libraries, you may want to install binutils
+*** 2.20 or above, or modify your PATH so that a non-GNU linker is found.
+*** You will then need to restart the configuration process.
+
+_LT_EOF
+ fi
+ ;;
+
+ amigaos*)
+ case $host_cpu in
+ powerpc)
+ # see comment about AmigaOS4 .so support
+ archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+ archive_expsym_cmds=''
+ ;;
+ m68k)
+ archive_cmds='$RM $output_objdir/a2ixlibrary.data~$ECHO "#define NAME $libname" > $output_objdir/a2ixlibrary.data~$ECHO "#define LIBRARY_ID 1" >> $output_objdir/a2ixlibrary.data~$ECHO "#define VERSION $major" >> $output_objdir/a2ixlibrary.data~$ECHO "#define REVISION $revision" >> $output_objdir/a2ixlibrary.data~$AR $AR_FLAGS $lib $libobjs~$RANLIB $lib~(cd $output_objdir && a2ixlibrary -32)'
+ hardcode_libdir_flag_spec='-L$libdir'
+ hardcode_minus_L=yes
+ ;;
+ esac
+ ;;
+
+ beos*)
+ if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then
+ allow_undefined_flag=unsupported
+ # Joseph Beckenbach <jrb3@best.com> says some releases of gcc
+ # support --undefined. This deserves some investigation. FIXME
+ archive_cmds='$CC -nostart $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+ else
+ ld_shlibs=no
+ fi
+ ;;
+
+ cygwin* | mingw* | pw32* | cegcc*)
+ # _LT_TAGVAR(hardcode_libdir_flag_spec, ) is actually meaningless,
+ # as there is no search path for DLLs.
+ hardcode_libdir_flag_spec='-L$libdir'
+ export_dynamic_flag_spec='${wl}--export-all-symbols'
+ allow_undefined_flag=unsupported
+ always_export_symbols=no
+ enable_shared_with_static_runtimes=yes
+ export_symbols_cmds='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[BCDGRS][ ]/s/.*[ ]\([^ ]*\)/\1 DATA/;s/^.*[ ]__nm__\([^ ]*\)[ ][^ ]*/\1 DATA/;/^I[ ]/d;/^[AITW][ ]/s/.* //'\'' | sort | uniq > $export_symbols'
+ exclude_expsyms='[_]+GLOBAL_OFFSET_TABLE_|[_]+GLOBAL__[FID]_.*|[_]+head_[A-Za-z0-9_]+_dll|[A-Za-z0-9_]+_dll_iname'
+
+ if $LD --help 2>&1 | $GREP 'auto-import' > /dev/null; then
+ archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib'
+ # If the export-symbols file already is a .def file (1st line
+ # is EXPORTS), use it as is; otherwise, prepend...
+ archive_expsym_cmds='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then
+ cp $export_symbols $output_objdir/$soname.def;
+ else
+ echo EXPORTS > $output_objdir/$soname.def;
+ cat $export_symbols >> $output_objdir/$soname.def;
+ fi~
+ $CC -shared $output_objdir/$soname.def $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib'
+ else
+ ld_shlibs=no
+ fi
+ ;;
+
+ haiku*)
+ archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+ link_all_deplibs=yes
+ ;;
+
+ interix[3-9]*)
+ hardcode_direct=no
+ hardcode_shlibpath_var=no
+ hardcode_libdir_flag_spec='${wl}-rpath,$libdir'
+ export_dynamic_flag_spec='${wl}-E'
+ # Hack: On Interix 3.x, we cannot compile PIC because of a broken gcc.
+ # Instead, shared libraries are loaded at an image base (0x10000000 by
+ # default) and relocated if they conflict, which is a slow very memory
+ # consuming and fragmenting process. To avoid this, we pick a random,
+ # 256 KiB-aligned image base between 0x50000000 and 0x6FFC0000 at link
+ # time. Moving up from 0x10000000 also allows more sbrk(2) space.
+ archive_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib'
+ archive_expsym_cmds='sed "s,^,_," $export_symbols >$output_objdir/$soname.expsym~$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--retain-symbols-file,$output_objdir/$soname.expsym ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib'
+ ;;
+
+ gnu* | linux* | tpf* | k*bsd*-gnu | kopensolaris*-gnu)
+ tmp_diet=no
+ if test "$host_os" = linux-dietlibc; then
+ case $cc_basename in
+ diet\ *) tmp_diet=yes;; # linux-dietlibc with static linking (!diet-dyn)
+ esac
+ fi
+ if $LD --help 2>&1 | $EGREP ': supported targets:.* elf' > /dev/null \
+ && test "$tmp_diet" = no
+ then
+ tmp_addflag=' $pic_flag'
+ tmp_sharedflag='-shared'
+ case $cc_basename,$host_cpu in
+ pgcc*) # Portland Group C compiler
+ whole_archive_flag_spec='${wl}--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` ${wl}--no-whole-archive'
+ tmp_addflag=' $pic_flag'
+ ;;
+ pgf77* | pgf90* | pgf95* | pgfortran*)
+ # Portland Group f77 and f90 compilers
+ whole_archive_flag_spec='${wl}--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` ${wl}--no-whole-archive'
+ tmp_addflag=' $pic_flag -Mnomain' ;;
+ ecc*,ia64* | icc*,ia64*) # Intel C compiler on ia64
+ tmp_addflag=' -i_dynamic' ;;
+ efc*,ia64* | ifort*,ia64*) # Intel Fortran compiler on ia64
+ tmp_addflag=' -i_dynamic -nofor_main' ;;
+ ifc* | ifort*) # Intel Fortran compiler
+ tmp_addflag=' -nofor_main' ;;
+ lf95*) # Lahey Fortran 8.1
+ whole_archive_flag_spec=
+ tmp_sharedflag='--shared' ;;
+ xl[cC]* | bgxl[cC]* | mpixl[cC]*) # IBM XL C 8.0 on PPC (deal with xlf below)
+ tmp_sharedflag='-qmkshrobj'
+ tmp_addflag= ;;
+ nvcc*) # Cuda Compiler Driver 2.2
+ whole_archive_flag_spec='${wl}--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` ${wl}--no-whole-archive'
+ compiler_needs_object=yes
+ ;;
+ esac
+ case `$CC -V 2>&1 | sed 5q` in
+ *Sun\ C*) # Sun C 5.9
+ whole_archive_flag_spec='${wl}--whole-archive`new_convenience=; for conv in $convenience\"\"; do test -z \"$conv\" || new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` ${wl}--no-whole-archive'
+ compiler_needs_object=yes
+ tmp_sharedflag='-G' ;;
+ *Sun\ F*) # Sun Fortran 8.3
+ tmp_sharedflag='-G' ;;
+ esac
+ archive_cmds='$CC '"$tmp_sharedflag""$tmp_addflag"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+
+ if test "x$supports_anon_versioning" = xyes; then
+ archive_expsym_cmds='echo "{ global:" > $output_objdir/$libname.ver~
+ cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~
+ echo "local: *; };" >> $output_objdir/$libname.ver~
+ $CC '"$tmp_sharedflag""$tmp_addflag"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-version-script ${wl}$output_objdir/$libname.ver -o $lib'
+ fi
+
+ case $cc_basename in
+ xlf* | bgf* | bgxlf* | mpixlf*)
+ # IBM XL Fortran 10.1 on PPC cannot create shared libs itself
+ whole_archive_flag_spec='--whole-archive$convenience --no-whole-archive'
+ hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir'
+ archive_cmds='$LD -shared $libobjs $deplibs $linker_flags -soname $soname -o $lib'
+ if test "x$supports_anon_versioning" = xyes; then
+ archive_expsym_cmds='echo "{ global:" > $output_objdir/$libname.ver~
+ cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~
+ echo "local: *; };" >> $output_objdir/$libname.ver~
+ $LD -shared $libobjs $deplibs $linker_flags -soname $soname -version-script $output_objdir/$libname.ver -o $lib'
+ fi
+ ;;
+ esac
+ else
+ ld_shlibs=no
+ fi
+ ;;
+
+ netbsd*)
+ if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then
+ archive_cmds='$LD -Bshareable $libobjs $deplibs $linker_flags -o $lib'
+ wlarc=
+ else
+ archive_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+ archive_expsym_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
+ fi
+ ;;
+
+ solaris*)
+ if $LD -v 2>&1 | $GREP 'BFD 2\.8' > /dev/null; then
+ ld_shlibs=no
+ cat <<_LT_EOF 1>&2
+
+*** Warning: The releases 2.8.* of the GNU linker cannot reliably
+*** create shared libraries on Solaris systems. Therefore, libtool
+*** is disabling shared libraries support. We urge you to upgrade GNU
+*** binutils to release 2.9.1 or newer. Another option is to modify
+*** your PATH or compiler configuration so that the native linker is
+*** used, and then restart.
+
+_LT_EOF
+ elif $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then
+ archive_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+ archive_expsym_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
+ else
+ ld_shlibs=no
+ fi
+ ;;
+
+ sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX*)
+ case `$LD -v 2>&1` in
+ *\ [01].* | *\ 2.[0-9].* | *\ 2.1[0-5].*)
+ ld_shlibs=no
+ cat <<_LT_EOF 1>&2
+
+*** Warning: Releases of the GNU linker prior to 2.16.91.0.3 can not
+*** reliably create shared libraries on SCO systems. Therefore, libtool
+*** is disabling shared libraries support. We urge you to upgrade GNU
+*** binutils to release 2.16.91.0.3 or newer. Another option is to modify
+*** your PATH or compiler configuration so that the native linker is
+*** used, and then restart.
+
+_LT_EOF
+ ;;
+ *)
+ # For security reasons, it is highly recommended that you always
+ # use absolute paths for naming shared libraries, and exclude the
+ # DT_RUNPATH tag from executables and libraries. But doing so
+ # requires that you compile everything twice, which is a pain.
+ if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then
+ hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir'
+ archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+ archive_expsym_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
+ else
+ ld_shlibs=no
+ fi
+ ;;
+ esac
+ ;;
+
+ sunos4*)
+ archive_cmds='$LD -assert pure-text -Bshareable -o $lib $libobjs $deplibs $linker_flags'
+ wlarc=
+ hardcode_direct=yes
+ hardcode_shlibpath_var=no
+ ;;
+
+ *)
+ if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then
+ archive_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+ archive_expsym_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
+ else
+ ld_shlibs=no
+ fi
+ ;;
+ esac
+
+ if test "$ld_shlibs" = no; then
+ runpath_var=
+ hardcode_libdir_flag_spec=
+ export_dynamic_flag_spec=
+ whole_archive_flag_spec=
+ fi
+ else
+ # PORTME fill in a description of your system's linker (not GNU ld)
+ case $host_os in
+ aix3*)
+ allow_undefined_flag=unsupported
+ always_export_symbols=yes
+ archive_expsym_cmds='$LD -o $output_objdir/$soname $libobjs $deplibs $linker_flags -bE:$export_symbols -T512 -H512 -bM:SRE~$AR $AR_FLAGS $lib $output_objdir/$soname'
+ # Note: this linker hardcodes the directories in LIBPATH if there
+ # are no directories specified by -L.
+ hardcode_minus_L=yes
+ if test "$GCC" = yes && test -z "$lt_prog_compiler_static"; then
+ # Neither direct hardcoding nor static linking is supported with a
+ # broken collect2.
+ hardcode_direct=unsupported
+ fi
+ ;;
+
+ aix[4-9]*)
+ if test "$host_cpu" = ia64; then
+ # On IA64, the linker does run time linking by default, so we don't
+ # have to do anything special.
+ aix_use_runtimelinking=no
+ exp_sym_flag='-Bexport'
+ no_entry_flag=""
+ else
+ # If we're using GNU nm, then we don't want the "-C" option.
+ # -C means demangle to AIX nm, but means don't demangle with GNU nm
+ # Also, AIX nm treats weak defined symbols like other global
+ # defined symbols, whereas GNU nm marks them as "W".
+ if $NM -V 2>&1 | $GREP 'GNU' > /dev/null; then
+ export_symbols_cmds='$NM -Bpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B") || (\$ 2 == "W")) && (substr(\$ 3,1,1) != ".")) { print \$ 3 } }'\'' | sort -u > $export_symbols'
+ else
+ export_symbols_cmds='$NM -BCpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B")) && (substr(\$ 3,1,1) != ".")) { print \$ 3 } }'\'' | sort -u > $export_symbols'
+ fi
+ aix_use_runtimelinking=no
+
+ # Test if we are trying to use run time linking or normal
+ # AIX style linking. If -brtl is somewhere in LDFLAGS, we
+ # need to do runtime linking.
+ case $host_os in aix4.[23]|aix4.[23].*|aix[5-9]*)
+ for ld_flag in $LDFLAGS; do
+ if (test $ld_flag = "-brtl" || test $ld_flag = "-Wl,-brtl"); then
+ aix_use_runtimelinking=yes
+ break
+ fi
+ done
+ ;;
+ esac
+
+ exp_sym_flag='-bexport'
+ no_entry_flag='-bnoentry'
+ fi
+
+ # When large executables or shared objects are built, AIX ld can
+ # have problems creating the table of contents. If linking a library
+ # or program results in "error TOC overflow" add -mminimal-toc to
+ # CXXFLAGS/CFLAGS for g++/gcc. In the cases where that is not
+ # enough to fix the problem, add -Wl,-bbigtoc to LDFLAGS.
+
+ archive_cmds=''
+ hardcode_direct=yes
+ hardcode_direct_absolute=yes
+ hardcode_libdir_separator=':'
+ link_all_deplibs=yes
+ file_list_spec='${wl}-f,'
+
+ if test "$GCC" = yes; then
+ case $host_os in aix4.[012]|aix4.[012].*)
+ # We only want to do this on AIX 4.2 and lower, the check
+ # below for broken collect2 doesn't work under 4.3+
+ collect2name=`${CC} -print-prog-name=collect2`
+ if test -f "$collect2name" &&
+ strings "$collect2name" | $GREP resolve_lib_name >/dev/null
+ then
+ # We have reworked collect2
+ :
+ else
+ # We have old collect2
+ hardcode_direct=unsupported
+ # It fails to find uninstalled libraries when the uninstalled
+ # path is not listed in the libpath. Setting hardcode_minus_L
+ # to unsupported forces relinking
+ hardcode_minus_L=yes
+ hardcode_libdir_flag_spec='-L$libdir'
+ hardcode_libdir_separator=
+ fi
+ ;;
+ esac
+ shared_flag='-shared'
+ if test "$aix_use_runtimelinking" = yes; then
+ shared_flag="$shared_flag "'${wl}-G'
+ fi
+ else
+ # not using gcc
+ if test "$host_cpu" = ia64; then
+ # VisualAge C++, Version 5.5 for AIX 5L for IA-64, Beta 3 Release
+ # chokes on -Wl,-G. The following line is correct:
+ shared_flag='-G'
+ else
+ if test "$aix_use_runtimelinking" = yes; then
+ shared_flag='${wl}-G'
+ else
+ shared_flag='${wl}-bM:SRE'
+ fi
+ fi
+ fi
+
+ export_dynamic_flag_spec='${wl}-bexpall'
+ # It seems that -bexpall does not export symbols beginning with
+ # underscore (_), so it is better to generate a list of symbols to export.
+ always_export_symbols=yes
+ if test "$aix_use_runtimelinking" = yes; then
+ # Warning - without using the other runtime loading flags (-brtl),
+ # -berok will link without error, but may produce a broken library.
+ allow_undefined_flag='-berok'
+ # Determine the default libpath from the value encoded in an
+ # empty executable.
+ if test "${lt_cv_aix_libpath+set}" = set; then
+ aix_libpath=$lt_cv_aix_libpath
+else
+ if ${lt_cv_aix_libpath_+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+
+int
+main ()
+{
+
+ ;
+ return 0;
+}
+_ACEOF
+if ac_fn_c_try_link "$LINENO"; then :
+
+ lt_aix_libpath_sed='
+ /Import File Strings/,/^$/ {
+ /^0/ {
+ s/^0 *\([^ ]*\) *$/\1/
+ p
+ }
+ }'
+ lt_cv_aix_libpath_=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"`
+ # Check for a 64-bit object if we didn't find anything.
+ if test -z "$lt_cv_aix_libpath_"; then
+ lt_cv_aix_libpath_=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"`
+ fi
+fi
+rm -f core conftest.err conftest.$ac_objext \
+ conftest$ac_exeext conftest.$ac_ext
+ if test -z "$lt_cv_aix_libpath_"; then
+ lt_cv_aix_libpath_="/usr/lib:/lib"
+ fi
+
+fi
+
+ aix_libpath=$lt_cv_aix_libpath_
+fi
+
+ hardcode_libdir_flag_spec='${wl}-blibpath:$libdir:'"$aix_libpath"
+ archive_expsym_cmds='$CC -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags `if test "x${allow_undefined_flag}" != "x"; then func_echo_all "${wl}${allow_undefined_flag}"; else :; fi` '"\${wl}$exp_sym_flag:\$export_symbols $shared_flag"
+ else
+ if test "$host_cpu" = ia64; then
+ hardcode_libdir_flag_spec='${wl}-R $libdir:/usr/lib:/lib'
+ allow_undefined_flag="-z nodefs"
+ archive_expsym_cmds="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags ${wl}${allow_undefined_flag} '"\${wl}$exp_sym_flag:\$export_symbols"
+ else
+ # Determine the default libpath from the value encoded in an
+ # empty executable.
+ if test "${lt_cv_aix_libpath+set}" = set; then
+ aix_libpath=$lt_cv_aix_libpath
+else
+ if ${lt_cv_aix_libpath_+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+
+int
+main ()
+{
+
+ ;
+ return 0;
+}
+_ACEOF
+if ac_fn_c_try_link "$LINENO"; then :
+
+ lt_aix_libpath_sed='
+ /Import File Strings/,/^$/ {
+ /^0/ {
+ s/^0 *\([^ ]*\) *$/\1/
+ p
+ }
+ }'
+ lt_cv_aix_libpath_=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"`
+ # Check for a 64-bit object if we didn't find anything.
+ if test -z "$lt_cv_aix_libpath_"; then
+ lt_cv_aix_libpath_=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"`
+ fi
+fi
+rm -f core conftest.err conftest.$ac_objext \
+ conftest$ac_exeext conftest.$ac_ext
+ if test -z "$lt_cv_aix_libpath_"; then
+ lt_cv_aix_libpath_="/usr/lib:/lib"
+ fi
+
+fi
+
+ aix_libpath=$lt_cv_aix_libpath_
+fi
+
+ hardcode_libdir_flag_spec='${wl}-blibpath:$libdir:'"$aix_libpath"
+ # Warning - without using the other run time loading flags,
+ # -berok will link without error, but may produce a broken library.
+ no_undefined_flag=' ${wl}-bernotok'
+ allow_undefined_flag=' ${wl}-berok'
+ if test "$with_gnu_ld" = yes; then
+ # We only use this code for GNU lds that support --whole-archive.
+ whole_archive_flag_spec='${wl}--whole-archive$convenience ${wl}--no-whole-archive'
+ else
+ # Exported symbols can be pulled into shared objects from archives
+ whole_archive_flag_spec='$convenience'
+ fi
+ archive_cmds_need_lc=yes
+ # This is similar to how AIX traditionally builds its shared libraries.
+ archive_expsym_cmds="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs ${wl}-bnoentry $compiler_flags ${wl}-bE:$export_symbols${allow_undefined_flag}~$AR $AR_FLAGS $output_objdir/$libname$release.a $output_objdir/$soname'
+ fi
+ fi
+ ;;
+
+ amigaos*)
+ case $host_cpu in
+ powerpc)
+ # see comment about AmigaOS4 .so support
+ archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+ archive_expsym_cmds=''
+ ;;
+ m68k)
+ archive_cmds='$RM $output_objdir/a2ixlibrary.data~$ECHO "#define NAME $libname" > $output_objdir/a2ixlibrary.data~$ECHO "#define LIBRARY_ID 1" >> $output_objdir/a2ixlibrary.data~$ECHO "#define VERSION $major" >> $output_objdir/a2ixlibrary.data~$ECHO "#define REVISION $revision" >> $output_objdir/a2ixlibrary.data~$AR $AR_FLAGS $lib $libobjs~$RANLIB $lib~(cd $output_objdir && a2ixlibrary -32)'
+ hardcode_libdir_flag_spec='-L$libdir'
+ hardcode_minus_L=yes
+ ;;
+ esac
+ ;;
+
+ bsdi[45]*)
+ export_dynamic_flag_spec=-rdynamic
+ ;;
+
+ cygwin* | mingw* | pw32* | cegcc*)
+ # When not using gcc, we currently assume that we are using
+ # Microsoft Visual C++.
+ # hardcode_libdir_flag_spec is actually meaningless, as there is
+ # no search path for DLLs.
+ case $cc_basename in
+ cl*)
+ # Native MSVC
+ hardcode_libdir_flag_spec=' '
+ allow_undefined_flag=unsupported
+ always_export_symbols=yes
+ file_list_spec='@'
+ # Tell ltmain to make .lib files, not .a files.
+ libext=lib
+ # Tell ltmain to make .dll files, not .so files.
+ shrext_cmds=".dll"
+ # FIXME: Setting linknames here is a bad hack.
+ archive_cmds='$CC -o $output_objdir/$soname $libobjs $compiler_flags $deplibs -Wl,-dll~linknames='
+ archive_expsym_cmds='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then
+ sed -n -e 's/\\\\\\\(.*\\\\\\\)/-link\\\ -EXPORT:\\\\\\\1/' -e '1\\\!p' < $export_symbols > $output_objdir/$soname.exp;
+ else
+ sed -e 's/\\\\\\\(.*\\\\\\\)/-link\\\ -EXPORT:\\\\\\\1/' < $export_symbols > $output_objdir/$soname.exp;
+ fi~
+ $CC -o $tool_output_objdir$soname $libobjs $compiler_flags $deplibs "@$tool_output_objdir$soname.exp" -Wl,-DLL,-IMPLIB:"$tool_output_objdir$libname.dll.lib"~
+ linknames='
+ # The linker will not automatically build a static lib if we build a DLL.
+ # _LT_TAGVAR(old_archive_from_new_cmds, )='true'
+ enable_shared_with_static_runtimes=yes
+ exclude_expsyms='_NULL_IMPORT_DESCRIPTOR|_IMPORT_DESCRIPTOR_.*'
+ export_symbols_cmds='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[BCDGRS][ ]/s/.*[ ]\([^ ]*\)/\1,DATA/'\'' | $SED -e '\''/^[AITW][ ]/s/.*[ ]//'\'' | sort | uniq > $export_symbols'
+ # Don't use ranlib
+ old_postinstall_cmds='chmod 644 $oldlib'
+ postlink_cmds='lt_outputfile="@OUTPUT@"~
+ lt_tool_outputfile="@TOOL_OUTPUT@"~
+ case $lt_outputfile in
+ *.exe|*.EXE) ;;
+ *)
+ lt_outputfile="$lt_outputfile.exe"
+ lt_tool_outputfile="$lt_tool_outputfile.exe"
+ ;;
+ esac~
+ if test "$MANIFEST_TOOL" != ":" && test -f "$lt_outputfile.manifest"; then
+ $MANIFEST_TOOL -manifest "$lt_tool_outputfile.manifest" -outputresource:"$lt_tool_outputfile" || exit 1;
+ $RM "$lt_outputfile.manifest";
+ fi'
+ ;;
+ *)
+ # Assume MSVC wrapper
+ hardcode_libdir_flag_spec=' '
+ allow_undefined_flag=unsupported
+ # Tell ltmain to make .lib files, not .a files.
+ libext=lib
+ # Tell ltmain to make .dll files, not .so files.
+ shrext_cmds=".dll"
+ # FIXME: Setting linknames here is a bad hack.
+ archive_cmds='$CC -o $lib $libobjs $compiler_flags `func_echo_all "$deplibs" | $SED '\''s/ -lc$//'\''` -link -dll~linknames='
+ # The linker will automatically build a .lib file if we build a DLL.
+ old_archive_from_new_cmds='true'
+ # FIXME: Should let the user specify the lib program.
+ old_archive_cmds='lib -OUT:$oldlib$oldobjs$old_deplibs'
+ enable_shared_with_static_runtimes=yes
+ ;;
+ esac
+ ;;
+
+ darwin* | rhapsody*)
+
+
+ archive_cmds_need_lc=no
+ hardcode_direct=no
+ hardcode_automatic=yes
+ hardcode_shlibpath_var=unsupported
+ if test "$lt_cv_ld_force_load" = "yes"; then
+ whole_archive_flag_spec='`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience ${wl}-force_load,$conv\"; done; func_echo_all \"$new_convenience\"`'
+
+ else
+ whole_archive_flag_spec=''
+ fi
+ link_all_deplibs=yes
+ allow_undefined_flag="$_lt_dar_allow_undefined"
+ case $cc_basename in
+ ifort*) _lt_dar_can_shared=yes ;;
+ *) _lt_dar_can_shared=$GCC ;;
+ esac
+ if test "$_lt_dar_can_shared" = "yes"; then
+ output_verbose_link_cmd=func_echo_all
+ archive_cmds="\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring $_lt_dar_single_mod${_lt_dsymutil}"
+ module_cmds="\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dsymutil}"
+ archive_expsym_cmds="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring ${_lt_dar_single_mod}${_lt_dar_export_syms}${_lt_dsymutil}"
+ module_expsym_cmds="sed -e 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dar_export_syms}${_lt_dsymutil}"
+
+ else
+ ld_shlibs=no
+ fi
+
+ ;;
+
+ dgux*)
+ archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
+ hardcode_libdir_flag_spec='-L$libdir'
+ hardcode_shlibpath_var=no
+ ;;
+
+ # FreeBSD 2.2.[012] allows us to include c++rt0.o to get C++ constructor
+ # support. Future versions do this automatically, but an explicit c++rt0.o
+ # does not break anything, and helps significantly (at the cost of a little
+ # extra space).
+ freebsd2.2*)
+ archive_cmds='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags /usr/lib/c++rt0.o'
+ hardcode_libdir_flag_spec='-R$libdir'
+ hardcode_direct=yes
+ hardcode_shlibpath_var=no
+ ;;
+
+ # Unfortunately, older versions of FreeBSD 2 do not have this feature.
+ freebsd2.*)
+ archive_cmds='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags'
+ hardcode_direct=yes
+ hardcode_minus_L=yes
+ hardcode_shlibpath_var=no
+ ;;
+
+ # FreeBSD 3 and greater uses gcc -shared to do shared libraries.
+ freebsd* | dragonfly*)
+ archive_cmds='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags'
+ hardcode_libdir_flag_spec='-R$libdir'
+ hardcode_direct=yes
+ hardcode_shlibpath_var=no
+ ;;
+
+ hpux9*)
+ if test "$GCC" = yes; then
+ archive_cmds='$RM $output_objdir/$soname~$CC -shared $pic_flag ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $libobjs $deplibs $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib'
+ else
+ archive_cmds='$RM $output_objdir/$soname~$LD -b +b $install_libdir -o $output_objdir/$soname $libobjs $deplibs $linker_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib'
+ fi
+ hardcode_libdir_flag_spec='${wl}+b ${wl}$libdir'
+ hardcode_libdir_separator=:
+ hardcode_direct=yes
+
+ # hardcode_minus_L: Not really in the search PATH,
+ # but as the default location of the library.
+ hardcode_minus_L=yes
+ export_dynamic_flag_spec='${wl}-E'
+ ;;
+
+ hpux10*)
+ if test "$GCC" = yes && test "$with_gnu_ld" = no; then
+ archive_cmds='$CC -shared $pic_flag ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags'
+ else
+ archive_cmds='$LD -b +h $soname +b $install_libdir -o $lib $libobjs $deplibs $linker_flags'
+ fi
+ if test "$with_gnu_ld" = no; then
+ hardcode_libdir_flag_spec='${wl}+b ${wl}$libdir'
+ hardcode_libdir_separator=:
+ hardcode_direct=yes
+ hardcode_direct_absolute=yes
+ export_dynamic_flag_spec='${wl}-E'
+ # hardcode_minus_L: Not really in the search PATH,
+ # but as the default location of the library.
+ hardcode_minus_L=yes
+ fi
+ ;;
+
+ hpux11*)
+ if test "$GCC" = yes && test "$with_gnu_ld" = no; then
+ case $host_cpu in
+ hppa*64*)
+ archive_cmds='$CC -shared ${wl}+h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags'
+ ;;
+ ia64*)
+ archive_cmds='$CC -shared $pic_flag ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags'
+ ;;
+ *)
+ archive_cmds='$CC -shared $pic_flag ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags'
+ ;;
+ esac
+ else
+ case $host_cpu in
+ hppa*64*)
+ archive_cmds='$CC -b ${wl}+h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags'
+ ;;
+ ia64*)
+ archive_cmds='$CC -b ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags'
+ ;;
+ *)
+
+ # Older versions of the 11.00 compiler do not understand -b yet
+ # (HP92453-01 A.11.01.20 doesn't, HP92453-01 B.11.X.35175-35176.GP does)
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $CC understands -b" >&5
+$as_echo_n "checking if $CC understands -b... " >&6; }
+if ${lt_cv_prog_compiler__b+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ lt_cv_prog_compiler__b=no
+ save_LDFLAGS="$LDFLAGS"
+ LDFLAGS="$LDFLAGS -b"
+ echo "$lt_simple_link_test_code" > conftest.$ac_ext
+ if (eval $ac_link 2>conftest.err) && test -s conftest$ac_exeext; then
+ # The linker can only warn and ignore the option if not recognized
+ # So say no if there are warnings
+ if test -s conftest.err; then
+ # Append any errors to the config.log.
+ cat conftest.err 1>&5
+ $ECHO "$_lt_linker_boilerplate" | $SED '/^$/d' > conftest.exp
+ $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2
+ if diff conftest.exp conftest.er2 >/dev/null; then
+ lt_cv_prog_compiler__b=yes
+ fi
+ else
+ lt_cv_prog_compiler__b=yes
+ fi
+ fi
+ $RM -r conftest*
+ LDFLAGS="$save_LDFLAGS"
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler__b" >&5
+$as_echo "$lt_cv_prog_compiler__b" >&6; }
+
+if test x"$lt_cv_prog_compiler__b" = xyes; then
+ archive_cmds='$CC -b ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags'
+else
+ archive_cmds='$LD -b +h $soname +b $install_libdir -o $lib $libobjs $deplibs $linker_flags'
+fi
+
+ ;;
+ esac
+ fi
+ if test "$with_gnu_ld" = no; then
+ hardcode_libdir_flag_spec='${wl}+b ${wl}$libdir'
+ hardcode_libdir_separator=:
+
+ case $host_cpu in
+ hppa*64*|ia64*)
+ hardcode_direct=no
+ hardcode_shlibpath_var=no
+ ;;
+ *)
+ hardcode_direct=yes
+ hardcode_direct_absolute=yes
+ export_dynamic_flag_spec='${wl}-E'
+
+ # hardcode_minus_L: Not really in the search PATH,
+ # but as the default location of the library.
+ hardcode_minus_L=yes
+ ;;
+ esac
+ fi
+ ;;
+
+ irix5* | irix6* | nonstopux*)
+ if test "$GCC" = yes; then
+ archive_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
+ # Try to use the -exported_symbol ld option, if it does not
+ # work, assume that -exports_file does not work either and
+ # implicitly export all symbols.
+ # This should be the same for all languages, so no per-tag cache variable.
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the $host_os linker accepts -exported_symbol" >&5
+$as_echo_n "checking whether the $host_os linker accepts -exported_symbol... " >&6; }
+if ${lt_cv_irix_exported_symbol+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ save_LDFLAGS="$LDFLAGS"
+ LDFLAGS="$LDFLAGS -shared ${wl}-exported_symbol ${wl}foo ${wl}-update_registry ${wl}/dev/null"
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+int foo (void) { return 0; }
+_ACEOF
+if ac_fn_c_try_link "$LINENO"; then :
+ lt_cv_irix_exported_symbol=yes
+else
+ lt_cv_irix_exported_symbol=no
+fi
+rm -f core conftest.err conftest.$ac_objext \
+ conftest$ac_exeext conftest.$ac_ext
+ LDFLAGS="$save_LDFLAGS"
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_irix_exported_symbol" >&5
+$as_echo "$lt_cv_irix_exported_symbol" >&6; }
+ if test "$lt_cv_irix_exported_symbol" = yes; then
+ archive_expsym_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations ${wl}-exports_file ${wl}$export_symbols -o $lib'
+ fi
+ else
+ archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib'
+ archive_expsym_cmds='$CC -shared $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -exports_file $export_symbols -o $lib'
+ fi
+ archive_cmds_need_lc='no'
+ hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir'
+ hardcode_libdir_separator=:
+ inherit_rpath=yes
+ link_all_deplibs=yes
+ ;;
+
+ netbsd*)
+ if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then
+ archive_cmds='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' # a.out
+ else
+ archive_cmds='$LD -shared -o $lib $libobjs $deplibs $linker_flags' # ELF
+ fi
+ hardcode_libdir_flag_spec='-R$libdir'
+ hardcode_direct=yes
+ hardcode_shlibpath_var=no
+ ;;
+
+ newsos6)
+ archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
+ hardcode_direct=yes
+ hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir'
+ hardcode_libdir_separator=:
+ hardcode_shlibpath_var=no
+ ;;
+
+ *nto* | *qnx*)
+ ;;
+
+ openbsd*)
+ if test -f /usr/libexec/ld.so; then
+ hardcode_direct=yes
+ hardcode_shlibpath_var=no
+ hardcode_direct_absolute=yes
+ if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then
+ archive_cmds='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags'
+ archive_expsym_cmds='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-retain-symbols-file,$export_symbols'
+ hardcode_libdir_flag_spec='${wl}-rpath,$libdir'
+ export_dynamic_flag_spec='${wl}-E'
+ else
+ case $host_os in
+ openbsd[01].* | openbsd2.[0-7] | openbsd2.[0-7].*)
+ archive_cmds='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags'
+ hardcode_libdir_flag_spec='-R$libdir'
+ ;;
+ *)
+ archive_cmds='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags'
+ hardcode_libdir_flag_spec='${wl}-rpath,$libdir'
+ ;;
+ esac
+ fi
+ else
+ ld_shlibs=no
+ fi
+ ;;
+
+ os2*)
+ hardcode_libdir_flag_spec='-L$libdir'
+ hardcode_minus_L=yes
+ allow_undefined_flag=unsupported
+ archive_cmds='$ECHO "LIBRARY $libname INITINSTANCE" > $output_objdir/$libname.def~$ECHO "DESCRIPTION \"$libname\"" >> $output_objdir/$libname.def~echo DATA >> $output_objdir/$libname.def~echo " SINGLE NONSHARED" >> $output_objdir/$libname.def~echo EXPORTS >> $output_objdir/$libname.def~emxexp $libobjs >> $output_objdir/$libname.def~$CC -Zdll -Zcrtdll -o $lib $libobjs $deplibs $compiler_flags $output_objdir/$libname.def'
+ old_archive_from_new_cmds='emximp -o $output_objdir/$libname.a $output_objdir/$libname.def'
+ ;;
+
+ osf3*)
+ if test "$GCC" = yes; then
+ allow_undefined_flag=' ${wl}-expect_unresolved ${wl}\*'
+ archive_cmds='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
+ else
+ allow_undefined_flag=' -expect_unresolved \*'
+ archive_cmds='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib'
+ fi
+ archive_cmds_need_lc='no'
+ hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir'
+ hardcode_libdir_separator=:
+ ;;
+
+ osf4* | osf5*) # as osf3* with the addition of -msym flag
+ if test "$GCC" = yes; then
+ allow_undefined_flag=' ${wl}-expect_unresolved ${wl}\*'
+ archive_cmds='$CC -shared${allow_undefined_flag} $pic_flag $libobjs $deplibs $compiler_flags ${wl}-msym ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
+ hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir'
+ else
+ allow_undefined_flag=' -expect_unresolved \*'
+ archive_cmds='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags -msym -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib'
+ archive_expsym_cmds='for i in `cat $export_symbols`; do printf "%s %s\\n" -exported_symbol "\$i" >> $lib.exp; done; printf "%s\\n" "-hidden">> $lib.exp~
+ $CC -shared${allow_undefined_flag} ${wl}-input ${wl}$lib.exp $compiler_flags $libobjs $deplibs -soname $soname `test -n "$verstring" && $ECHO "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib~$RM $lib.exp'
+
+ # Both c and cxx compiler support -rpath directly
+ hardcode_libdir_flag_spec='-rpath $libdir'
+ fi
+ archive_cmds_need_lc='no'
+ hardcode_libdir_separator=:
+ ;;
+
+ solaris*)
+ no_undefined_flag=' -z defs'
+ if test "$GCC" = yes; then
+ wlarc='${wl}'
+ archive_cmds='$CC -shared $pic_flag ${wl}-z ${wl}text ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags'
+ archive_expsym_cmds='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~
+ $CC -shared $pic_flag ${wl}-z ${wl}text ${wl}-M ${wl}$lib.exp ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags~$RM $lib.exp'
+ else
+ case `$CC -V 2>&1` in
+ *"Compilers 5.0"*)
+ wlarc=''
+ archive_cmds='$LD -G${allow_undefined_flag} -h $soname -o $lib $libobjs $deplibs $linker_flags'
+ archive_expsym_cmds='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~
+ $LD -G${allow_undefined_flag} -M $lib.exp -h $soname -o $lib $libobjs $deplibs $linker_flags~$RM $lib.exp'
+ ;;
+ *)
+ wlarc='${wl}'
+ archive_cmds='$CC -G${allow_undefined_flag} -h $soname -o $lib $libobjs $deplibs $compiler_flags'
+ archive_expsym_cmds='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~
+ $CC -G${allow_undefined_flag} -M $lib.exp -h $soname -o $lib $libobjs $deplibs $compiler_flags~$RM $lib.exp'
+ ;;
+ esac
+ fi
+ hardcode_libdir_flag_spec='-R$libdir'
+ hardcode_shlibpath_var=no
+ case $host_os in
+ solaris2.[0-5] | solaris2.[0-5].*) ;;
+ *)
+ # The compiler driver will combine and reorder linker options,
+ # but understands `-z linker_flag'. GCC discards it without `$wl',
+ # but is careful enough not to reorder.
+ # Supported since Solaris 2.6 (maybe 2.5.1?)
+ if test "$GCC" = yes; then
+ whole_archive_flag_spec='${wl}-z ${wl}allextract$convenience ${wl}-z ${wl}defaultextract'
+ else
+ whole_archive_flag_spec='-z allextract$convenience -z defaultextract'
+ fi
+ ;;
+ esac
+ link_all_deplibs=yes
+ ;;
+
+ sunos4*)
+ if test "x$host_vendor" = xsequent; then
+ # Use $CC to link under sequent, because it throws in some extra .o
+ # files that make .init and .fini sections work.
+ archive_cmds='$CC -G ${wl}-h $soname -o $lib $libobjs $deplibs $compiler_flags'
+ else
+ archive_cmds='$LD -assert pure-text -Bstatic -o $lib $libobjs $deplibs $linker_flags'
+ fi
+ hardcode_libdir_flag_spec='-L$libdir'
+ hardcode_direct=yes
+ hardcode_minus_L=yes
+ hardcode_shlibpath_var=no
+ ;;
+
+ sysv4)
+ case $host_vendor in
+ sni)
+ archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
+ hardcode_direct=yes # is this really true???
+ ;;
+ siemens)
+ ## LD is ld it makes a PLAMLIB
+ ## CC just makes a GrossModule.
+ archive_cmds='$LD -G -o $lib $libobjs $deplibs $linker_flags'
+ reload_cmds='$CC -r -o $output$reload_objs'
+ hardcode_direct=no
+ ;;
+ motorola)
+ archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
+ hardcode_direct=no #Motorola manual says yes, but my tests say they lie
+ ;;
+ esac
+ runpath_var='LD_RUN_PATH'
+ hardcode_shlibpath_var=no
+ ;;
+
+ sysv4.3*)
+ archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
+ hardcode_shlibpath_var=no
+ export_dynamic_flag_spec='-Bexport'
+ ;;
+
+ sysv4*MP*)
+ if test -d /usr/nec; then
+ archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
+ hardcode_shlibpath_var=no
+ runpath_var=LD_RUN_PATH
+ hardcode_runpath_var=yes
+ ld_shlibs=yes
+ fi
+ ;;
+
+ sysv4*uw2* | sysv5OpenUNIX* | sysv5UnixWare7.[01].[10]* | unixware7* | sco3.2v5.0.[024]*)
+ no_undefined_flag='${wl}-z,text'
+ archive_cmds_need_lc=no
+ hardcode_shlibpath_var=no
+ runpath_var='LD_RUN_PATH'
+
+ if test "$GCC" = yes; then
+ archive_cmds='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+ archive_expsym_cmds='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+ else
+ archive_cmds='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+ archive_expsym_cmds='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+ fi
+ ;;
+
+ sysv5* | sco3.2v5* | sco5v6*)
+ # Note: We can NOT use -z defs as we might desire, because we do not
+ # link with -lc, and that would cause any symbols used from libc to
+ # always be unresolved, which means just about no library would
+ # ever link correctly. If we're not using GNU ld we use -z text
+ # though, which does catch some bad symbols but isn't as heavy-handed
+ # as -z defs.
+ no_undefined_flag='${wl}-z,text'
+ allow_undefined_flag='${wl}-z,nodefs'
+ archive_cmds_need_lc=no
+ hardcode_shlibpath_var=no
+ hardcode_libdir_flag_spec='${wl}-R,$libdir'
+ hardcode_libdir_separator=':'
+ link_all_deplibs=yes
+ export_dynamic_flag_spec='${wl}-Bexport'
+ runpath_var='LD_RUN_PATH'
+
+ if test "$GCC" = yes; then
+ archive_cmds='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+ archive_expsym_cmds='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+ else
+ archive_cmds='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+ archive_expsym_cmds='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+ fi
+ ;;
+
+ uts4*)
+ archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
+ hardcode_libdir_flag_spec='-L$libdir'
+ hardcode_shlibpath_var=no
+ ;;
+
+ *)
+ ld_shlibs=no
+ ;;
+ esac
+
+ if test x$host_vendor = xsni; then
+ case $host in
+ sysv4 | sysv4.2uw2* | sysv4.3* | sysv5*)
+ export_dynamic_flag_spec='${wl}-Blargedynsym'
+ ;;
+ esac
+ fi
+ fi
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ld_shlibs" >&5
+$as_echo "$ld_shlibs" >&6; }
+test "$ld_shlibs" = no && can_build_shared=no
+
+with_gnu_ld=$with_gnu_ld
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+#
+# Do we need to explicitly link libc?
+#
+case "x$archive_cmds_need_lc" in
+x|xyes)
+ # Assume -lc should be added
+ archive_cmds_need_lc=yes
+
+ if test "$enable_shared" = yes && test "$GCC" = yes; then
+ case $archive_cmds in
+ *'~'*)
+ # FIXME: we may have to deal with multi-command sequences.
+ ;;
+ '$CC '*)
+ # Test whether the compiler implicitly links with -lc since on some
+ # systems, -lgcc has to come before -lc. If gcc already passes -lc
+ # to ld, don't add -lc before -lgcc.
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether -lc should be explicitly linked in" >&5
+$as_echo_n "checking whether -lc should be explicitly linked in... " >&6; }
+if ${lt_cv_archive_cmds_need_lc+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ $RM conftest*
+ echo "$lt_simple_compile_test_code" > conftest.$ac_ext
+
+ if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5
+ (eval $ac_compile) 2>&5
+ ac_status=$?
+ $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+ test $ac_status = 0; } 2>conftest.err; then
+ soname=conftest
+ lib=conftest
+ libobjs=conftest.$ac_objext
+ deplibs=
+ wl=$lt_prog_compiler_wl
+ pic_flag=$lt_prog_compiler_pic
+ compiler_flags=-v
+ linker_flags=-v
+ verstring=
+ output_objdir=.
+ libname=conftest
+ lt_save_allow_undefined_flag=$allow_undefined_flag
+ allow_undefined_flag=
+ if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$archive_cmds 2\>\&1 \| $GREP \" -lc \" \>/dev/null 2\>\&1\""; } >&5
+ (eval $archive_cmds 2\>\&1 \| $GREP \" -lc \" \>/dev/null 2\>\&1) 2>&5
+ ac_status=$?
+ $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+ test $ac_status = 0; }
+ then
+ lt_cv_archive_cmds_need_lc=no
+ else
+ lt_cv_archive_cmds_need_lc=yes
+ fi
+ allow_undefined_flag=$lt_save_allow_undefined_flag
+ else
+ cat conftest.err 1>&5
+ fi
+ $RM conftest*
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_archive_cmds_need_lc" >&5
+$as_echo "$lt_cv_archive_cmds_need_lc" >&6; }
+ archive_cmds_need_lc=$lt_cv_archive_cmds_need_lc
+ ;;
+ esac
+ fi
+ ;;
+esac
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking dynamic linker characteristics" >&5
+$as_echo_n "checking dynamic linker characteristics... " >&6; }
+
+if test "$GCC" = yes; then
+ case $host_os in
+ darwin*) lt_awk_arg="/^libraries:/,/LR/" ;;
+ *) lt_awk_arg="/^libraries:/" ;;
+ esac
+ case $host_os in
+ mingw* | cegcc*) lt_sed_strip_eq="s,=\([A-Za-z]:\),\1,g" ;;
+ *) lt_sed_strip_eq="s,=/,/,g" ;;
+ esac
+ lt_search_path_spec=`$CC -print-search-dirs | awk $lt_awk_arg | $SED -e "s/^libraries://" -e $lt_sed_strip_eq`
+ case $lt_search_path_spec in
+ *\;*)
+ # if the path contains ";" then we assume it to be the separator
+ # otherwise default to the standard path separator (i.e. ":") - it is
+ # assumed that no part of a normal pathname contains ";" but that should
+ # okay in the real world where ";" in dirpaths is itself problematic.
+ lt_search_path_spec=`$ECHO "$lt_search_path_spec" | $SED 's/;/ /g'`
+ ;;
+ *)
+ lt_search_path_spec=`$ECHO "$lt_search_path_spec" | $SED "s/$PATH_SEPARATOR/ /g"`
+ ;;
+ esac
+ # Ok, now we have the path, separated by spaces, we can step through it
+ # and add multilib dir if necessary.
+ lt_tmp_lt_search_path_spec=
+ lt_multi_os_dir=`$CC $CPPFLAGS $CFLAGS $LDFLAGS -print-multi-os-directory 2>/dev/null`
+ for lt_sys_path in $lt_search_path_spec; do
+ if test -d "$lt_sys_path/$lt_multi_os_dir"; then
+ lt_tmp_lt_search_path_spec="$lt_tmp_lt_search_path_spec $lt_sys_path/$lt_multi_os_dir"
+ else
+ test -d "$lt_sys_path" && \
+ lt_tmp_lt_search_path_spec="$lt_tmp_lt_search_path_spec $lt_sys_path"
+ fi
+ done
+ lt_search_path_spec=`$ECHO "$lt_tmp_lt_search_path_spec" | awk '
+BEGIN {RS=" "; FS="/|\n";} {
+ lt_foo="";
+ lt_count=0;
+ for (lt_i = NF; lt_i > 0; lt_i--) {
+ if ($lt_i != "" && $lt_i != ".") {
+ if ($lt_i == "..") {
+ lt_count++;
+ } else {
+ if (lt_count == 0) {
+ lt_foo="/" $lt_i lt_foo;
+ } else {
+ lt_count--;
+ }
+ }
+ }
+ }
+ if (lt_foo != "") { lt_freq[lt_foo]++; }
+ if (lt_freq[lt_foo] == 1) { print lt_foo; }
+}'`
+ # AWK program above erroneously prepends '/' to C:/dos/paths
+ # for these hosts.
+ case $host_os in
+ mingw* | cegcc*) lt_search_path_spec=`$ECHO "$lt_search_path_spec" |\
+ $SED 's,/\([A-Za-z]:\),\1,g'` ;;
+ esac
+ sys_lib_search_path_spec=`$ECHO "$lt_search_path_spec" | $lt_NL2SP`
+else
+ sys_lib_search_path_spec="/lib /usr/lib /usr/local/lib"
+fi
+library_names_spec=
+libname_spec='lib$name'
+soname_spec=
+shrext_cmds=".so"
+postinstall_cmds=
+postuninstall_cmds=
+finish_cmds=
+finish_eval=
+shlibpath_var=
+shlibpath_overrides_runpath=unknown
+version_type=none
+dynamic_linker="$host_os ld.so"
+sys_lib_dlsearch_path_spec="/lib /usr/lib"
+need_lib_prefix=unknown
+hardcode_into_libs=no
+
+# when you set need_version to no, make sure it does not cause -set_version
+# flags to be left without arguments
+need_version=unknown
+
+case $host_os in
+aix3*)
+ version_type=linux # correct to gnu/linux during the next big refactor
+ library_names_spec='${libname}${release}${shared_ext}$versuffix $libname.a'
+ shlibpath_var=LIBPATH
+
+ # AIX 3 has no versioning support, so we append a major version to the name.
+ soname_spec='${libname}${release}${shared_ext}$major'
+ ;;
+
+aix[4-9]*)
+ version_type=linux # correct to gnu/linux during the next big refactor
+ need_lib_prefix=no
+ need_version=no
+ hardcode_into_libs=yes
+ if test "$host_cpu" = ia64; then
+ # AIX 5 supports IA64
+ library_names_spec='${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext}$versuffix $libname${shared_ext}'
+ shlibpath_var=LD_LIBRARY_PATH
+ else
+ # With GCC up to 2.95.x, collect2 would create an import file
+ # for dependence libraries. The import file would start with
+ # the line `#! .'. This would cause the generated library to
+ # depend on `.', always an invalid library. This was fixed in
+ # development snapshots of GCC prior to 3.0.
+ case $host_os in
+ aix4 | aix4.[01] | aix4.[01].*)
+ if { echo '#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 97)'
+ echo ' yes '
+ echo '#endif'; } | ${CC} -E - | $GREP yes > /dev/null; then
+ :
+ else
+ can_build_shared=no
+ fi
+ ;;
+ esac
+ # AIX (on Power*) has no versioning support, so currently we can not hardcode correct
+ # soname into executable. Probably we can add versioning support to
+ # collect2, so additional links can be useful in future.
+ if test "$aix_use_runtimelinking" = yes; then
+ # If using run time linking (on AIX 4.2 or later) use lib<name>.so
+ # instead of lib<name>.a to let people know that these are not
+ # typical AIX shared libraries.
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+ else
+ # We preserve .a as extension for shared libraries through AIX4.2
+ # and later when we are not doing run time linking.
+ library_names_spec='${libname}${release}.a $libname.a'
+ soname_spec='${libname}${release}${shared_ext}$major'
+ fi
+ shlibpath_var=LIBPATH
+ fi
+ ;;
+
+amigaos*)
+ case $host_cpu in
+ powerpc)
+ # Since July 2007 AmigaOS4 officially supports .so libraries.
+ # When compiling the executable, add -use-dynld -Lsobjs: to the compileline.
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+ ;;
+ m68k)
+ library_names_spec='$libname.ixlibrary $libname.a'
+ # Create ${libname}_ixlibrary.a entries in /sys/libs.
+ finish_eval='for lib in `ls $libdir/*.ixlibrary 2>/dev/null`; do libname=`func_echo_all "$lib" | $SED '\''s%^.*/\([^/]*\)\.ixlibrary$%\1%'\''`; test $RM /sys/libs/${libname}_ixlibrary.a; $show "cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a"; cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a || exit 1; done'
+ ;;
+ esac
+ ;;
+
+beos*)
+ library_names_spec='${libname}${shared_ext}'
+ dynamic_linker="$host_os ld.so"
+ shlibpath_var=LIBRARY_PATH
+ ;;
+
+bsdi[45]*)
+ version_type=linux # correct to gnu/linux during the next big refactor
+ need_version=no
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+ soname_spec='${libname}${release}${shared_ext}$major'
+ finish_cmds='PATH="\$PATH:/sbin" ldconfig $libdir'
+ shlibpath_var=LD_LIBRARY_PATH
+ sys_lib_search_path_spec="/shlib /usr/lib /usr/X11/lib /usr/contrib/lib /lib /usr/local/lib"
+ sys_lib_dlsearch_path_spec="/shlib /usr/lib /usr/local/lib"
+ # the default ld.so.conf also contains /usr/contrib/lib and
+ # /usr/X11R6/lib (/usr/X11 is a link to /usr/X11R6), but let us allow
+ # libtool to hard-code these into programs
+ ;;
+
+cygwin* | mingw* | pw32* | cegcc*)
+ version_type=windows
+ shrext_cmds=".dll"
+ need_version=no
+ need_lib_prefix=no
+
+ case $GCC,$cc_basename in
+ yes,*)
+ # gcc
+ library_names_spec='$libname.dll.a'
+ # DLL is installed to $(libdir)/../bin by postinstall_cmds
+ postinstall_cmds='base_file=`basename \${file}`~
+ dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\${base_file}'\''i; echo \$dlname'\''`~
+ dldir=$destdir/`dirname \$dlpath`~
+ test -d \$dldir || mkdir -p \$dldir~
+ $install_prog $dir/$dlname \$dldir/$dlname~
+ chmod a+x \$dldir/$dlname~
+ if test -n '\''$stripme'\'' && test -n '\''$striplib'\''; then
+ eval '\''$striplib \$dldir/$dlname'\'' || exit \$?;
+ fi'
+ postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; echo \$dlname'\''`~
+ dlpath=$dir/\$dldll~
+ $RM \$dlpath'
+ shlibpath_overrides_runpath=yes
+
+ case $host_os in
+ cygwin*)
+ # Cygwin DLLs use 'cyg' prefix rather than 'lib'
+ soname_spec='`echo ${libname} | sed -e 's/^lib/cyg/'``echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}'
+
+ sys_lib_search_path_spec="$sys_lib_search_path_spec /usr/lib/w32api"
+ ;;
+ mingw* | cegcc*)
+ # MinGW DLLs use traditional 'lib' prefix
+ soname_spec='${libname}`echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}'
+ ;;
+ pw32*)
+ # pw32 DLLs use 'pw' prefix rather than 'lib'
+ library_names_spec='`echo ${libname} | sed -e 's/^lib/pw/'``echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}'
+ ;;
+ esac
+ dynamic_linker='Win32 ld.exe'
+ ;;
+
+ *,cl*)
+ # Native MSVC
+ libname_spec='$name'
+ soname_spec='${libname}`echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}'
+ library_names_spec='${libname}.dll.lib'
+
+ case $build_os in
+ mingw*)
+ sys_lib_search_path_spec=
+ lt_save_ifs=$IFS
+ IFS=';'
+ for lt_path in $LIB
+ do
+ IFS=$lt_save_ifs
+ # Let DOS variable expansion print the short 8.3 style file name.
+ lt_path=`cd "$lt_path" 2>/dev/null && cmd //C "for %i in (".") do @echo %~si"`
+ sys_lib_search_path_spec="$sys_lib_search_path_spec $lt_path"
+ done
+ IFS=$lt_save_ifs
+ # Convert to MSYS style.
+ sys_lib_search_path_spec=`$ECHO "$sys_lib_search_path_spec" | sed -e 's|\\\\|/|g' -e 's| \\([a-zA-Z]\\):| /\\1|g' -e 's|^ ||'`
+ ;;
+ cygwin*)
+ # Convert to unix form, then to dos form, then back to unix form
+ # but this time dos style (no spaces!) so that the unix form looks
+ # like /cygdrive/c/PROGRA~1:/cygdr...
+ sys_lib_search_path_spec=`cygpath --path --unix "$LIB"`
+ sys_lib_search_path_spec=`cygpath --path --dos "$sys_lib_search_path_spec" 2>/dev/null`
+ sys_lib_search_path_spec=`cygpath --path --unix "$sys_lib_search_path_spec" | $SED -e "s/$PATH_SEPARATOR/ /g"`
+ ;;
+ *)
+ sys_lib_search_path_spec="$LIB"
+ if $ECHO "$sys_lib_search_path_spec" | $GREP ';[c-zC-Z]:/' >/dev/null; then
+ # It is most probably a Windows format PATH.
+ sys_lib_search_path_spec=`$ECHO "$sys_lib_search_path_spec" | $SED -e 's/;/ /g'`
+ else
+ sys_lib_search_path_spec=`$ECHO "$sys_lib_search_path_spec" | $SED -e "s/$PATH_SEPARATOR/ /g"`
+ fi
+ # FIXME: find the short name or the path components, as spaces are
+ # common. (e.g. "Program Files" -> "PROGRA~1")
+ ;;
+ esac
+
+ # DLL is installed to $(libdir)/../bin by postinstall_cmds
+ postinstall_cmds='base_file=`basename \${file}`~
+ dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\${base_file}'\''i; echo \$dlname'\''`~
+ dldir=$destdir/`dirname \$dlpath`~
+ test -d \$dldir || mkdir -p \$dldir~
+ $install_prog $dir/$dlname \$dldir/$dlname'
+ postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; echo \$dlname'\''`~
+ dlpath=$dir/\$dldll~
+ $RM \$dlpath'
+ shlibpath_overrides_runpath=yes
+ dynamic_linker='Win32 link.exe'
+ ;;
+
+ *)
+ # Assume MSVC wrapper
+ library_names_spec='${libname}`echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext} $libname.lib'
+ dynamic_linker='Win32 ld.exe'
+ ;;
+ esac
+ # FIXME: first we should search . and the directory the executable is in
+ shlibpath_var=PATH
+ ;;
+
+darwin* | rhapsody*)
+ dynamic_linker="$host_os dyld"
+ version_type=darwin
+ need_lib_prefix=no
+ need_version=no
+ library_names_spec='${libname}${release}${major}$shared_ext ${libname}$shared_ext'
+ soname_spec='${libname}${release}${major}$shared_ext'
+ shlibpath_overrides_runpath=yes
+ shlibpath_var=DYLD_LIBRARY_PATH
+ shrext_cmds='`test .$module = .yes && echo .so || echo .dylib`'
+
+ sys_lib_search_path_spec="$sys_lib_search_path_spec /usr/local/lib"
+ sys_lib_dlsearch_path_spec='/usr/local/lib /lib /usr/lib'
+ ;;
+
+dgux*)
+ version_type=linux # correct to gnu/linux during the next big refactor
+ need_lib_prefix=no
+ need_version=no
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname$shared_ext'
+ soname_spec='${libname}${release}${shared_ext}$major'
+ shlibpath_var=LD_LIBRARY_PATH
+ ;;
+
+freebsd* | dragonfly*)
+ # DragonFly does not have aout. When/if they implement a new
+ # versioning mechanism, adjust this.
+ if test -x /usr/bin/objformat; then
+ objformat=`/usr/bin/objformat`
+ else
+ case $host_os in
+ freebsd[23].*) objformat=aout ;;
+ *) objformat=elf ;;
+ esac
+ fi
+ version_type=freebsd-$objformat
+ case $version_type in
+ freebsd-elf*)
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}'
+ need_version=no
+ need_lib_prefix=no
+ ;;
+ freebsd-*)
+ library_names_spec='${libname}${release}${shared_ext}$versuffix $libname${shared_ext}$versuffix'
+ need_version=yes
+ ;;
+ esac
+ shlibpath_var=LD_LIBRARY_PATH
+ case $host_os in
+ freebsd2.*)
+ shlibpath_overrides_runpath=yes
+ ;;
+ freebsd3.[01]* | freebsdelf3.[01]*)
+ shlibpath_overrides_runpath=yes
+ hardcode_into_libs=yes
+ ;;
+ freebsd3.[2-9]* | freebsdelf3.[2-9]* | \
+ freebsd4.[0-5] | freebsdelf4.[0-5] | freebsd4.1.1 | freebsdelf4.1.1)
+ shlibpath_overrides_runpath=no
+ hardcode_into_libs=yes
+ ;;
+ *) # from 4.6 on, and DragonFly
+ shlibpath_overrides_runpath=yes
+ hardcode_into_libs=yes
+ ;;
+ esac
+ ;;
+
+gnu*)
+ version_type=linux # correct to gnu/linux during the next big refactor
+ need_lib_prefix=no
+ need_version=no
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}${major} ${libname}${shared_ext}'
+ soname_spec='${libname}${release}${shared_ext}$major'
+ shlibpath_var=LD_LIBRARY_PATH
+ shlibpath_overrides_runpath=no
+ hardcode_into_libs=yes
+ ;;
+
+haiku*)
+ version_type=linux # correct to gnu/linux during the next big refactor
+ need_lib_prefix=no
+ need_version=no
+ dynamic_linker="$host_os runtime_loader"
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}${major} ${libname}${shared_ext}'
+ soname_spec='${libname}${release}${shared_ext}$major'
+ shlibpath_var=LIBRARY_PATH
+ shlibpath_overrides_runpath=yes
+ sys_lib_dlsearch_path_spec='/boot/home/config/lib /boot/common/lib /boot/system/lib'
+ hardcode_into_libs=yes
+ ;;
+
+hpux9* | hpux10* | hpux11*)
+ # Give a soname corresponding to the major version so that dld.sl refuses to
+ # link against other versions.
+ version_type=sunos
+ need_lib_prefix=no
+ need_version=no
+ case $host_cpu in
+ ia64*)
+ shrext_cmds='.so'
+ hardcode_into_libs=yes
+ dynamic_linker="$host_os dld.so"
+ shlibpath_var=LD_LIBRARY_PATH
+ shlibpath_overrides_runpath=yes # Unless +noenvvar is specified.
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+ soname_spec='${libname}${release}${shared_ext}$major'
+ if test "X$HPUX_IA64_MODE" = X32; then
+ sys_lib_search_path_spec="/usr/lib/hpux32 /usr/local/lib/hpux32 /usr/local/lib"
+ else
+ sys_lib_search_path_spec="/usr/lib/hpux64 /usr/local/lib/hpux64"
+ fi
+ sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec
+ ;;
+ hppa*64*)
+ shrext_cmds='.sl'
+ hardcode_into_libs=yes
+ dynamic_linker="$host_os dld.sl"
+ shlibpath_var=LD_LIBRARY_PATH # How should we handle SHLIB_PATH
+ shlibpath_overrides_runpath=yes # Unless +noenvvar is specified.
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+ soname_spec='${libname}${release}${shared_ext}$major'
+ sys_lib_search_path_spec="/usr/lib/pa20_64 /usr/ccs/lib/pa20_64"
+ sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec
+ ;;
+ *)
+ shrext_cmds='.sl'
+ dynamic_linker="$host_os dld.sl"
+ shlibpath_var=SHLIB_PATH
+ shlibpath_overrides_runpath=no # +s is required to enable SHLIB_PATH
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+ soname_spec='${libname}${release}${shared_ext}$major'
+ ;;
+ esac
+ # HP-UX runs *really* slowly unless shared libraries are mode 555, ...
+ postinstall_cmds='chmod 555 $lib'
+ # or fails outright, so override atomically:
+ install_override_mode=555
+ ;;
+
+interix[3-9]*)
+ version_type=linux # correct to gnu/linux during the next big refactor
+ need_lib_prefix=no
+ need_version=no
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}'
+ soname_spec='${libname}${release}${shared_ext}$major'
+ dynamic_linker='Interix 3.x ld.so.1 (PE, like ELF)'
+ shlibpath_var=LD_LIBRARY_PATH
+ shlibpath_overrides_runpath=no
+ hardcode_into_libs=yes
+ ;;
+
+irix5* | irix6* | nonstopux*)
+ case $host_os in
+ nonstopux*) version_type=nonstopux ;;
+ *)
+ if test "$lt_cv_prog_gnu_ld" = yes; then
+ version_type=linux # correct to gnu/linux during the next big refactor
+ else
+ version_type=irix
+ fi ;;
+ esac
+ need_lib_prefix=no
+ need_version=no
+ soname_spec='${libname}${release}${shared_ext}$major'
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext} $libname${shared_ext}'
+ case $host_os in
+ irix5* | nonstopux*)
+ libsuff= shlibsuff=
+ ;;
+ *)
+ case $LD in # libtool.m4 will add one of these switches to LD
+ *-32|*"-32 "|*-melf32bsmip|*"-melf32bsmip ")
+ libsuff= shlibsuff= libmagic=32-bit;;
+ *-n32|*"-n32 "|*-melf32bmipn32|*"-melf32bmipn32 ")
+ libsuff=32 shlibsuff=N32 libmagic=N32;;
+ *-64|*"-64 "|*-melf64bmip|*"-melf64bmip ")
+ libsuff=64 shlibsuff=64 libmagic=64-bit;;
+ *) libsuff= shlibsuff= libmagic=never-match;;
+ esac
+ ;;
+ esac
+ shlibpath_var=LD_LIBRARY${shlibsuff}_PATH
+ shlibpath_overrides_runpath=no
+ sys_lib_search_path_spec="/usr/lib${libsuff} /lib${libsuff} /usr/local/lib${libsuff}"
+ sys_lib_dlsearch_path_spec="/usr/lib${libsuff} /lib${libsuff}"
+ hardcode_into_libs=yes
+ ;;
+
+# No shared lib support for Linux oldld, aout, or coff.
+linux*oldld* | linux*aout* | linux*coff*)
+ dynamic_linker=no
+ ;;
+
+# This must be glibc/ELF.
+linux* | k*bsd*-gnu | kopensolaris*-gnu)
+ version_type=linux # correct to gnu/linux during the next big refactor
+ need_lib_prefix=no
+ need_version=no
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+ soname_spec='${libname}${release}${shared_ext}$major'
+ finish_cmds='PATH="\$PATH:/sbin" ldconfig -n $libdir'
+ shlibpath_var=LD_LIBRARY_PATH
+ shlibpath_overrides_runpath=no
+
+ # Some binutils ld are patched to set DT_RUNPATH
+ if ${lt_cv_shlibpath_overrides_runpath+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ lt_cv_shlibpath_overrides_runpath=no
+ save_LDFLAGS=$LDFLAGS
+ save_libdir=$libdir
+ eval "libdir=/foo; wl=\"$lt_prog_compiler_wl\"; \
+ LDFLAGS=\"\$LDFLAGS $hardcode_libdir_flag_spec\""
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+
+int
+main ()
+{
+
+ ;
+ return 0;
+}
+_ACEOF
+if ac_fn_c_try_link "$LINENO"; then :
+ if ($OBJDUMP -p conftest$ac_exeext) 2>/dev/null | grep "RUNPATH.*$libdir" >/dev/null; then :
+ lt_cv_shlibpath_overrides_runpath=yes
+fi
+fi
+rm -f core conftest.err conftest.$ac_objext \
+ conftest$ac_exeext conftest.$ac_ext
+ LDFLAGS=$save_LDFLAGS
+ libdir=$save_libdir
+
+fi
+
+ shlibpath_overrides_runpath=$lt_cv_shlibpath_overrides_runpath
+
+ # This implies no fast_install, which is unacceptable.
+ # Some rework will be needed to allow for fast_install
+ # before this can be enabled.
+ hardcode_into_libs=yes
+
+ # Add ABI-specific directories to the system library path.
+ sys_lib_dlsearch_path_spec="/lib64 /usr/lib64 /lib /usr/lib"
+
+ # Append ld.so.conf contents to the search path
+ if test -f /etc/ld.so.conf; then
+ lt_ld_extra=`awk '/^include / { system(sprintf("cd /etc; cat %s 2>/dev/null", \$2)); skip = 1; } { if (!skip) print \$0; skip = 0; }' < /etc/ld.so.conf | $SED -e 's/#.*//;/^[ ]*hwcap[ ]/d;s/[:, ]/ /g;s/=[^=]*$//;s/=[^= ]* / /g;s/"//g;/^$/d' | tr '\n' ' '`
+ sys_lib_dlsearch_path_spec="$sys_lib_dlsearch_path_spec $lt_ld_extra"
+
+ fi
+
+ # We used to test for /lib/ld.so.1 and disable shared libraries on
+ # powerpc, because MkLinux only supported shared libraries with the
+ # GNU dynamic linker. Since this was broken with cross compilers,
+ # most powerpc-linux boxes support dynamic linking these days and
+ # people can always --disable-shared, the test was removed, and we
+ # assume the GNU/Linux dynamic linker is in use.
+ dynamic_linker='GNU/Linux ld.so'
+ ;;
+
+netbsd*)
+ version_type=sunos
+ need_lib_prefix=no
+ need_version=no
+ if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix'
+ finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir'
+ dynamic_linker='NetBSD (a.out) ld.so'
+ else
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}'
+ soname_spec='${libname}${release}${shared_ext}$major'
+ dynamic_linker='NetBSD ld.elf_so'
+ fi
+ shlibpath_var=LD_LIBRARY_PATH
+ shlibpath_overrides_runpath=yes
+ hardcode_into_libs=yes
+ ;;
+
+newsos6)
+ version_type=linux # correct to gnu/linux during the next big refactor
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+ shlibpath_var=LD_LIBRARY_PATH
+ shlibpath_overrides_runpath=yes
+ ;;
+
+*nto* | *qnx*)
+ version_type=qnx
+ need_lib_prefix=no
+ need_version=no
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+ soname_spec='${libname}${release}${shared_ext}$major'
+ shlibpath_var=LD_LIBRARY_PATH
+ shlibpath_overrides_runpath=no
+ hardcode_into_libs=yes
+ dynamic_linker='ldqnx.so'
+ ;;
+
+openbsd*)
+ version_type=sunos
+ sys_lib_dlsearch_path_spec="/usr/lib"
+ need_lib_prefix=no
+ # Some older versions of OpenBSD (3.3 at least) *do* need versioned libs.
+ case $host_os in
+ openbsd3.3 | openbsd3.3.*) need_version=yes ;;
+ *) need_version=no ;;
+ esac
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix'
+ finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir'
+ shlibpath_var=LD_LIBRARY_PATH
+ if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then
+ case $host_os in
+ openbsd2.[89] | openbsd2.[89].*)
+ shlibpath_overrides_runpath=no
+ ;;
+ *)
+ shlibpath_overrides_runpath=yes
+ ;;
+ esac
+ else
+ shlibpath_overrides_runpath=yes
+ fi
+ ;;
+
+os2*)
+ libname_spec='$name'
+ shrext_cmds=".dll"
+ need_lib_prefix=no
+ library_names_spec='$libname${shared_ext} $libname.a'
+ dynamic_linker='OS/2 ld.exe'
+ shlibpath_var=LIBPATH
+ ;;
+
+osf3* | osf4* | osf5*)
+ version_type=osf
+ need_lib_prefix=no
+ need_version=no
+ soname_spec='${libname}${release}${shared_ext}$major'
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+ shlibpath_var=LD_LIBRARY_PATH
+ sys_lib_search_path_spec="/usr/shlib /usr/ccs/lib /usr/lib/cmplrs/cc /usr/lib /usr/local/lib /var/shlib"
+ sys_lib_dlsearch_path_spec="$sys_lib_search_path_spec"
+ ;;
+
+rdos*)
+ dynamic_linker=no
+ ;;
+
+solaris*)
+ version_type=linux # correct to gnu/linux during the next big refactor
+ need_lib_prefix=no
+ need_version=no
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+ soname_spec='${libname}${release}${shared_ext}$major'
+ shlibpath_var=LD_LIBRARY_PATH
+ shlibpath_overrides_runpath=yes
+ hardcode_into_libs=yes
+ # ldd complains unless libraries are executable
+ postinstall_cmds='chmod +x $lib'
+ ;;
+
+sunos4*)
+ version_type=sunos
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix'
+ finish_cmds='PATH="\$PATH:/usr/etc" ldconfig $libdir'
+ shlibpath_var=LD_LIBRARY_PATH
+ shlibpath_overrides_runpath=yes
+ if test "$with_gnu_ld" = yes; then
+ need_lib_prefix=no
+ fi
+ need_version=yes
+ ;;
+
+sysv4 | sysv4.3*)
+ version_type=linux # correct to gnu/linux during the next big refactor
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+ soname_spec='${libname}${release}${shared_ext}$major'
+ shlibpath_var=LD_LIBRARY_PATH
+ case $host_vendor in
+ sni)
+ shlibpath_overrides_runpath=no
+ need_lib_prefix=no
+ runpath_var=LD_RUN_PATH
+ ;;
+ siemens)
+ need_lib_prefix=no
+ ;;
+ motorola)
+ need_lib_prefix=no
+ need_version=no
+ shlibpath_overrides_runpath=no
+ sys_lib_search_path_spec='/lib /usr/lib /usr/ccs/lib'
+ ;;
+ esac
+ ;;
+
+sysv4*MP*)
+ if test -d /usr/nec ;then
+ version_type=linux # correct to gnu/linux during the next big refactor
+ library_names_spec='$libname${shared_ext}.$versuffix $libname${shared_ext}.$major $libname${shared_ext}'
+ soname_spec='$libname${shared_ext}.$major'
+ shlibpath_var=LD_LIBRARY_PATH
+ fi
+ ;;
+
+sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*)
+ version_type=freebsd-elf
+ need_lib_prefix=no
+ need_version=no
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}'
+ soname_spec='${libname}${release}${shared_ext}$major'
+ shlibpath_var=LD_LIBRARY_PATH
+ shlibpath_overrides_runpath=yes
+ hardcode_into_libs=yes
+ if test "$with_gnu_ld" = yes; then
+ sys_lib_search_path_spec='/usr/local/lib /usr/gnu/lib /usr/ccs/lib /usr/lib /lib'
+ else
+ sys_lib_search_path_spec='/usr/ccs/lib /usr/lib'
+ case $host_os in
+ sco3.2v5*)
+ sys_lib_search_path_spec="$sys_lib_search_path_spec /lib"
+ ;;
+ esac
+ fi
+ sys_lib_dlsearch_path_spec='/usr/lib'
+ ;;
+
+tpf*)
+ # TPF is a cross-target only. Preferred cross-host = GNU/Linux.
+ version_type=linux # correct to gnu/linux during the next big refactor
+ need_lib_prefix=no
+ need_version=no
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+ shlibpath_var=LD_LIBRARY_PATH
+ shlibpath_overrides_runpath=no
+ hardcode_into_libs=yes
+ ;;
+
+uts4*)
+ version_type=linux # correct to gnu/linux during the next big refactor
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+ soname_spec='${libname}${release}${shared_ext}$major'
+ shlibpath_var=LD_LIBRARY_PATH
+ ;;
+
+*)
+ dynamic_linker=no
+ ;;
+esac
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $dynamic_linker" >&5
+$as_echo "$dynamic_linker" >&6; }
+test "$dynamic_linker" = no && can_build_shared=no
+
+variables_saved_for_relink="PATH $shlibpath_var $runpath_var"
+if test "$GCC" = yes; then
+ variables_saved_for_relink="$variables_saved_for_relink GCC_EXEC_PREFIX COMPILER_PATH LIBRARY_PATH"
+fi
+
+if test "${lt_cv_sys_lib_search_path_spec+set}" = set; then
+ sys_lib_search_path_spec="$lt_cv_sys_lib_search_path_spec"
+fi
+if test "${lt_cv_sys_lib_dlsearch_path_spec+set}" = set; then
+ sys_lib_dlsearch_path_spec="$lt_cv_sys_lib_dlsearch_path_spec"
+fi
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking how to hardcode library paths into programs" >&5
+$as_echo_n "checking how to hardcode library paths into programs... " >&6; }
+hardcode_action=
+if test -n "$hardcode_libdir_flag_spec" ||
+ test -n "$runpath_var" ||
+ test "X$hardcode_automatic" = "Xyes" ; then
+
+ # We can hardcode non-existent directories.
+ if test "$hardcode_direct" != no &&
+ # If the only mechanism to avoid hardcoding is shlibpath_var, we
+ # have to relink, otherwise we might link with an installed library
+ # when we should be linking with a yet-to-be-installed one
+ ## test "$_LT_TAGVAR(hardcode_shlibpath_var, )" != no &&
+ test "$hardcode_minus_L" != no; then
+ # Linking always hardcodes the temporary library directory.
+ hardcode_action=relink
+ else
+ # We can link without hardcoding, and we can hardcode nonexisting dirs.
+ hardcode_action=immediate
+ fi
+else
+ # We cannot hardcode anything, or else we can only hardcode existing
+ # directories.
+ hardcode_action=unsupported
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $hardcode_action" >&5
+$as_echo "$hardcode_action" >&6; }
+
+if test "$hardcode_action" = relink ||
+ test "$inherit_rpath" = yes; then
+ # Fast installation is not supported
+ enable_fast_install=no
+elif test "$shlibpath_overrides_runpath" = yes ||
+ test "$enable_shared" = no; then
+ # Fast installation is not necessary
+ enable_fast_install=needless
+fi
+
+
+
+
+
+
+ if test "x$enable_dlopen" != xyes; then
+ enable_dlopen=unknown
+ enable_dlopen_self=unknown
+ enable_dlopen_self_static=unknown
+else
+ lt_cv_dlopen=no
+ lt_cv_dlopen_libs=
+
+ case $host_os in
+ beos*)
+ lt_cv_dlopen="load_add_on"
+ lt_cv_dlopen_libs=
+ lt_cv_dlopen_self=yes
+ ;;
+
+ mingw* | pw32* | cegcc*)
+ lt_cv_dlopen="LoadLibrary"
+ lt_cv_dlopen_libs=
+ ;;
+
+ cygwin*)
+ lt_cv_dlopen="dlopen"
+ lt_cv_dlopen_libs=
+ ;;
+
+ darwin*)
+ # if libdl is installed we need to link against it
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for dlopen in -ldl" >&5
+$as_echo_n "checking for dlopen in -ldl... " >&6; }
+if ${ac_cv_lib_dl_dlopen+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ ac_check_lib_save_LIBS=$LIBS
+LIBS="-ldl $LIBS"
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+
+/* Override any GCC internal prototype to avoid an error.
+ Use char because int might match the return type of a GCC
+ builtin and then its argument prototype would still apply. */
+#ifdef __cplusplus
+extern "C"
+#endif
+char dlopen ();
+int
+main ()
+{
+return dlopen ();
+ ;
+ return 0;
+}
+_ACEOF
+if ac_fn_c_try_link "$LINENO"; then :
+ ac_cv_lib_dl_dlopen=yes
+else
+ ac_cv_lib_dl_dlopen=no
+fi
+rm -f core conftest.err conftest.$ac_objext \
+ conftest$ac_exeext conftest.$ac_ext
+LIBS=$ac_check_lib_save_LIBS
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dl_dlopen" >&5
+$as_echo "$ac_cv_lib_dl_dlopen" >&6; }
+if test "x$ac_cv_lib_dl_dlopen" = xyes; then :
+ lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-ldl"
+else
+
+ lt_cv_dlopen="dyld"
+ lt_cv_dlopen_libs=
+ lt_cv_dlopen_self=yes
+
+fi
+
+ ;;
+
+ *)
+ ac_fn_c_check_func "$LINENO" "shl_load" "ac_cv_func_shl_load"
+if test "x$ac_cv_func_shl_load" = xyes; then :
+ lt_cv_dlopen="shl_load"
+else
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for shl_load in -ldld" >&5
+$as_echo_n "checking for shl_load in -ldld... " >&6; }
+if ${ac_cv_lib_dld_shl_load+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ ac_check_lib_save_LIBS=$LIBS
+LIBS="-ldld $LIBS"
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+
+/* Override any GCC internal prototype to avoid an error.
+ Use char because int might match the return type of a GCC
+ builtin and then its argument prototype would still apply. */
+#ifdef __cplusplus
+extern "C"
+#endif
+char shl_load ();
+int
+main ()
+{
+return shl_load ();
+ ;
+ return 0;
+}
+_ACEOF
+if ac_fn_c_try_link "$LINENO"; then :
+ ac_cv_lib_dld_shl_load=yes
+else
+ ac_cv_lib_dld_shl_load=no
+fi
+rm -f core conftest.err conftest.$ac_objext \
+ conftest$ac_exeext conftest.$ac_ext
+LIBS=$ac_check_lib_save_LIBS
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dld_shl_load" >&5
+$as_echo "$ac_cv_lib_dld_shl_load" >&6; }
+if test "x$ac_cv_lib_dld_shl_load" = xyes; then :
+ lt_cv_dlopen="shl_load" lt_cv_dlopen_libs="-ldld"
+else
+ ac_fn_c_check_func "$LINENO" "dlopen" "ac_cv_func_dlopen"
+if test "x$ac_cv_func_dlopen" = xyes; then :
+ lt_cv_dlopen="dlopen"
+else
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for dlopen in -ldl" >&5
+$as_echo_n "checking for dlopen in -ldl... " >&6; }
+if ${ac_cv_lib_dl_dlopen+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ ac_check_lib_save_LIBS=$LIBS
+LIBS="-ldl $LIBS"
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+
+/* Override any GCC internal prototype to avoid an error.
+ Use char because int might match the return type of a GCC
+ builtin and then its argument prototype would still apply. */
+#ifdef __cplusplus
+extern "C"
+#endif
+char dlopen ();
+int
+main ()
+{
+return dlopen ();
+ ;
+ return 0;
+}
+_ACEOF
+if ac_fn_c_try_link "$LINENO"; then :
+ ac_cv_lib_dl_dlopen=yes
+else
+ ac_cv_lib_dl_dlopen=no
+fi
+rm -f core conftest.err conftest.$ac_objext \
+ conftest$ac_exeext conftest.$ac_ext
+LIBS=$ac_check_lib_save_LIBS
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dl_dlopen" >&5
+$as_echo "$ac_cv_lib_dl_dlopen" >&6; }
+if test "x$ac_cv_lib_dl_dlopen" = xyes; then :
+ lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-ldl"
+else
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for dlopen in -lsvld" >&5
+$as_echo_n "checking for dlopen in -lsvld... " >&6; }
+if ${ac_cv_lib_svld_dlopen+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ ac_check_lib_save_LIBS=$LIBS
+LIBS="-lsvld $LIBS"
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+
+/* Override any GCC internal prototype to avoid an error.
+ Use char because int might match the return type of a GCC
+ builtin and then its argument prototype would still apply. */
+#ifdef __cplusplus
+extern "C"
+#endif
+char dlopen ();
+int
+main ()
+{
+return dlopen ();
+ ;
+ return 0;
+}
+_ACEOF
+if ac_fn_c_try_link "$LINENO"; then :
+ ac_cv_lib_svld_dlopen=yes
+else
+ ac_cv_lib_svld_dlopen=no
+fi
+rm -f core conftest.err conftest.$ac_objext \
+ conftest$ac_exeext conftest.$ac_ext
+LIBS=$ac_check_lib_save_LIBS
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_svld_dlopen" >&5
+$as_echo "$ac_cv_lib_svld_dlopen" >&6; }
+if test "x$ac_cv_lib_svld_dlopen" = xyes; then :
+ lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-lsvld"
+else
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for dld_link in -ldld" >&5
+$as_echo_n "checking for dld_link in -ldld... " >&6; }
+if ${ac_cv_lib_dld_dld_link+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ ac_check_lib_save_LIBS=$LIBS
+LIBS="-ldld $LIBS"
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+
+/* Override any GCC internal prototype to avoid an error.
+ Use char because int might match the return type of a GCC
+ builtin and then its argument prototype would still apply. */
+#ifdef __cplusplus
+extern "C"
+#endif
+char dld_link ();
+int
+main ()
+{
+return dld_link ();
+ ;
+ return 0;
+}
+_ACEOF
+if ac_fn_c_try_link "$LINENO"; then :
+ ac_cv_lib_dld_dld_link=yes
+else
+ ac_cv_lib_dld_dld_link=no
+fi
+rm -f core conftest.err conftest.$ac_objext \
+ conftest$ac_exeext conftest.$ac_ext
+LIBS=$ac_check_lib_save_LIBS
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dld_dld_link" >&5
+$as_echo "$ac_cv_lib_dld_dld_link" >&6; }
+if test "x$ac_cv_lib_dld_dld_link" = xyes; then :
+ lt_cv_dlopen="dld_link" lt_cv_dlopen_libs="-ldld"
+fi
+
+
+fi
+
+
+fi
+
+
+fi
+
+
+fi
+
+
+fi
+
+ ;;
+ esac
+
+ if test "x$lt_cv_dlopen" != xno; then
+ enable_dlopen=yes
+ else
+ enable_dlopen=no
+ fi
+
+ case $lt_cv_dlopen in
+ dlopen)
+ save_CPPFLAGS="$CPPFLAGS"
+ test "x$ac_cv_header_dlfcn_h" = xyes && CPPFLAGS="$CPPFLAGS -DHAVE_DLFCN_H"
+
+ save_LDFLAGS="$LDFLAGS"
+ wl=$lt_prog_compiler_wl eval LDFLAGS=\"\$LDFLAGS $export_dynamic_flag_spec\"
+
+ save_LIBS="$LIBS"
+ LIBS="$lt_cv_dlopen_libs $LIBS"
+
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether a program can dlopen itself" >&5
+$as_echo_n "checking whether a program can dlopen itself... " >&6; }
+if ${lt_cv_dlopen_self+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ if test "$cross_compiling" = yes; then :
+ lt_cv_dlopen_self=cross
+else
+ lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
+ lt_status=$lt_dlunknown
+ cat > conftest.$ac_ext <<_LT_EOF
+#line $LINENO "configure"
+#include "confdefs.h"
+
+#if HAVE_DLFCN_H
+#include <dlfcn.h>
+#endif
+
+#include <stdio.h>
+
+#ifdef RTLD_GLOBAL
+# define LT_DLGLOBAL RTLD_GLOBAL
+#else
+# ifdef DL_GLOBAL
+# define LT_DLGLOBAL DL_GLOBAL
+# else
+# define LT_DLGLOBAL 0
+# endif
+#endif
+
+/* We may have to define LT_DLLAZY_OR_NOW in the command line if we
+ find out it does not work in some platform. */
+#ifndef LT_DLLAZY_OR_NOW
+# ifdef RTLD_LAZY
+# define LT_DLLAZY_OR_NOW RTLD_LAZY
+# else
+# ifdef DL_LAZY
+# define LT_DLLAZY_OR_NOW DL_LAZY
+# else
+# ifdef RTLD_NOW
+# define LT_DLLAZY_OR_NOW RTLD_NOW
+# else
+# ifdef DL_NOW
+# define LT_DLLAZY_OR_NOW DL_NOW
+# else
+# define LT_DLLAZY_OR_NOW 0
+# endif
+# endif
+# endif
+# endif
+#endif
+
+/* When -fvisbility=hidden is used, assume the code has been annotated
+ correspondingly for the symbols needed. */
+#if defined(__GNUC__) && (((__GNUC__ == 3) && (__GNUC_MINOR__ >= 3)) || (__GNUC__ > 3))
+int fnord () __attribute__((visibility("default")));
+#endif
+
+int fnord () { return 42; }
+int main ()
+{
+ void *self = dlopen (0, LT_DLGLOBAL|LT_DLLAZY_OR_NOW);
+ int status = $lt_dlunknown;
+
+ if (self)
+ {
+ if (dlsym (self,"fnord")) status = $lt_dlno_uscore;
+ else
+ {
+ if (dlsym( self,"_fnord")) status = $lt_dlneed_uscore;
+ else puts (dlerror ());
+ }
+ /* dlclose (self); */
+ }
+ else
+ puts (dlerror ());
+
+ return status;
+}
+_LT_EOF
+ if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_link\""; } >&5
+ (eval $ac_link) 2>&5
+ ac_status=$?
+ $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+ test $ac_status = 0; } && test -s conftest${ac_exeext} 2>/dev/null; then
+ (./conftest; exit; ) >&5 2>/dev/null
+ lt_status=$?
+ case x$lt_status in
+ x$lt_dlno_uscore) lt_cv_dlopen_self=yes ;;
+ x$lt_dlneed_uscore) lt_cv_dlopen_self=yes ;;
+ x$lt_dlunknown|x*) lt_cv_dlopen_self=no ;;
+ esac
+ else :
+ # compilation failed
+ lt_cv_dlopen_self=no
+ fi
+fi
+rm -fr conftest*
+
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_dlopen_self" >&5
+$as_echo "$lt_cv_dlopen_self" >&6; }
+
+ if test "x$lt_cv_dlopen_self" = xyes; then
+ wl=$lt_prog_compiler_wl eval LDFLAGS=\"\$LDFLAGS $lt_prog_compiler_static\"
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether a statically linked program can dlopen itself" >&5
+$as_echo_n "checking whether a statically linked program can dlopen itself... " >&6; }
+if ${lt_cv_dlopen_self_static+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ if test "$cross_compiling" = yes; then :
+ lt_cv_dlopen_self_static=cross
+else
+ lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
+ lt_status=$lt_dlunknown
+ cat > conftest.$ac_ext <<_LT_EOF
+#line $LINENO "configure"
+#include "confdefs.h"
+
+#if HAVE_DLFCN_H
+#include <dlfcn.h>
+#endif
+
+#include <stdio.h>
+
+#ifdef RTLD_GLOBAL
+# define LT_DLGLOBAL RTLD_GLOBAL
+#else
+# ifdef DL_GLOBAL
+# define LT_DLGLOBAL DL_GLOBAL
+# else
+# define LT_DLGLOBAL 0
+# endif
+#endif
+
+/* We may have to define LT_DLLAZY_OR_NOW in the command line if we
+ find out it does not work in some platform. */
+#ifndef LT_DLLAZY_OR_NOW
+# ifdef RTLD_LAZY
+# define LT_DLLAZY_OR_NOW RTLD_LAZY
+# else
+# ifdef DL_LAZY
+# define LT_DLLAZY_OR_NOW DL_LAZY
+# else
+# ifdef RTLD_NOW
+# define LT_DLLAZY_OR_NOW RTLD_NOW
+# else
+# ifdef DL_NOW
+# define LT_DLLAZY_OR_NOW DL_NOW
+# else
+# define LT_DLLAZY_OR_NOW 0
+# endif
+# endif
+# endif
+# endif
+#endif
+
+/* When -fvisbility=hidden is used, assume the code has been annotated
+ correspondingly for the symbols needed. */
+#if defined(__GNUC__) && (((__GNUC__ == 3) && (__GNUC_MINOR__ >= 3)) || (__GNUC__ > 3))
+int fnord () __attribute__((visibility("default")));
+#endif
+
+int fnord () { return 42; }
+int main ()
+{
+ void *self = dlopen (0, LT_DLGLOBAL|LT_DLLAZY_OR_NOW);
+ int status = $lt_dlunknown;
+
+ if (self)
+ {
+ if (dlsym (self,"fnord")) status = $lt_dlno_uscore;
+ else
+ {
+ if (dlsym( self,"_fnord")) status = $lt_dlneed_uscore;
+ else puts (dlerror ());
+ }
+ /* dlclose (self); */
+ }
+ else
+ puts (dlerror ());
+
+ return status;
+}
+_LT_EOF
+ if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_link\""; } >&5
+ (eval $ac_link) 2>&5
+ ac_status=$?
+ $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+ test $ac_status = 0; } && test -s conftest${ac_exeext} 2>/dev/null; then
+ (./conftest; exit; ) >&5 2>/dev/null
+ lt_status=$?
+ case x$lt_status in
+ x$lt_dlno_uscore) lt_cv_dlopen_self_static=yes ;;
+ x$lt_dlneed_uscore) lt_cv_dlopen_self_static=yes ;;
+ x$lt_dlunknown|x*) lt_cv_dlopen_self_static=no ;;
+ esac
+ else :
+ # compilation failed
+ lt_cv_dlopen_self_static=no
+ fi
+fi
+rm -fr conftest*
+
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_dlopen_self_static" >&5
+$as_echo "$lt_cv_dlopen_self_static" >&6; }
+ fi
+
+ CPPFLAGS="$save_CPPFLAGS"
+ LDFLAGS="$save_LDFLAGS"
+ LIBS="$save_LIBS"
+ ;;
+ esac
+
+ case $lt_cv_dlopen_self in
+ yes|no) enable_dlopen_self=$lt_cv_dlopen_self ;;
+ *) enable_dlopen_self=unknown ;;
+ esac
+
+ case $lt_cv_dlopen_self_static in
+ yes|no) enable_dlopen_self_static=$lt_cv_dlopen_self_static ;;
+ *) enable_dlopen_self_static=unknown ;;
+ esac
+fi
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+striplib=
+old_striplib=
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether stripping libraries is possible" >&5
+$as_echo_n "checking whether stripping libraries is possible... " >&6; }
+if test -n "$STRIP" && $STRIP -V 2>&1 | $GREP "GNU strip" >/dev/null; then
+ test -z "$old_striplib" && old_striplib="$STRIP --strip-debug"
+ test -z "$striplib" && striplib="$STRIP --strip-unneeded"
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+$as_echo "yes" >&6; }
+else
+# FIXME - insert some real tests, host_os isn't really good enough
+ case $host_os in
+ darwin*)
+ if test -n "$STRIP" ; then
+ striplib="$STRIP -x"
+ old_striplib="$STRIP -S"
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+$as_echo "yes" >&6; }
+ else
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+ fi
+ ;;
+ *)
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+ ;;
+ esac
+fi
+
+
+
+
+
+
+
+
+
+
+
+
+ # Report which library types will actually be built
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking if libtool supports shared libraries" >&5
+$as_echo_n "checking if libtool supports shared libraries... " >&6; }
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $can_build_shared" >&5
+$as_echo "$can_build_shared" >&6; }
+
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to build shared libraries" >&5
+$as_echo_n "checking whether to build shared libraries... " >&6; }
+ test "$can_build_shared" = "no" && enable_shared=no
+
+ # On AIX, shared libraries and static libraries use the same namespace, and
+ # are all built from PIC.
+ case $host_os in
+ aix3*)
+ test "$enable_shared" = yes && enable_static=no
+ if test -n "$RANLIB"; then
+ archive_cmds="$archive_cmds~\$RANLIB \$lib"
+ postinstall_cmds='$RANLIB $lib'
+ fi
+ ;;
+
+ aix[4-9]*)
+ if test "$host_cpu" != ia64 && test "$aix_use_runtimelinking" = no ; then
+ test "$enable_shared" = yes && enable_static=no
+ fi
+ ;;
+ esac
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $enable_shared" >&5
+$as_echo "$enable_shared" >&6; }
+
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to build static libraries" >&5
+$as_echo_n "checking whether to build static libraries... " >&6; }
+ # Make sure either enable_shared or enable_static is yes.
+ test "$enable_shared" = yes || enable_static=yes
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $enable_static" >&5
+$as_echo "$enable_static" >&6; }
+
+
+
+
+fi
+ac_ext=c
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
+
+CC="$lt_save_CC"
+
+ if test -n "$CXX" && ( test "X$CXX" != "Xno" &&
+ ( (test "X$CXX" = "Xg++" && `g++ -v >/dev/null 2>&1` ) ||
+ (test "X$CXX" != "Xg++"))) ; then
+ ac_ext=cpp
+ac_cpp='$CXXCPP $CPPFLAGS'
+ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_cxx_compiler_gnu
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking how to run the C++ preprocessor" >&5
+$as_echo_n "checking how to run the C++ preprocessor... " >&6; }
+if test -z "$CXXCPP"; then
+ if ${ac_cv_prog_CXXCPP+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ # Double quotes because CXXCPP needs to be expanded
+ for CXXCPP in "$CXX -E" "/lib/cpp"
+ do
+ ac_preproc_ok=false
+for ac_cxx_preproc_warn_flag in '' yes
+do
+ # Use a header file that comes with gcc, so configuring glibc
+ # with a fresh cross-compiler works.
+ # Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
+ # <limits.h> exists even on freestanding compilers.
+ # On the NeXT, cc -E runs the code through the compiler's parser,
+ # not just through cpp. "Syntax error" is here to catch this case.
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+#ifdef __STDC__
+# include <limits.h>
+#else
+# include <assert.h>
+#endif
+ Syntax error
+_ACEOF
+if ac_fn_cxx_try_cpp "$LINENO"; then :
+
+else
+ # Broken: fails on valid input.
+continue
+fi
+rm -f conftest.err conftest.i conftest.$ac_ext
+
+ # OK, works on sane cases. Now check whether nonexistent headers
+ # can be detected and how.
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+#include <ac_nonexistent.h>
+_ACEOF
+if ac_fn_cxx_try_cpp "$LINENO"; then :
+ # Broken: success on invalid input.
+continue
+else
+ # Passes both tests.
+ac_preproc_ok=:
+break
+fi
+rm -f conftest.err conftest.i conftest.$ac_ext
+
+done
+# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped.
+rm -f conftest.i conftest.err conftest.$ac_ext
+if $ac_preproc_ok; then :
+ break
+fi
+
+ done
+ ac_cv_prog_CXXCPP=$CXXCPP
+
+fi
+ CXXCPP=$ac_cv_prog_CXXCPP
+else
+ ac_cv_prog_CXXCPP=$CXXCPP
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $CXXCPP" >&5
+$as_echo "$CXXCPP" >&6; }
+ac_preproc_ok=false
+for ac_cxx_preproc_warn_flag in '' yes
+do
+ # Use a header file that comes with gcc, so configuring glibc
+ # with a fresh cross-compiler works.
+ # Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
+ # <limits.h> exists even on freestanding compilers.
+ # On the NeXT, cc -E runs the code through the compiler's parser,
+ # not just through cpp. "Syntax error" is here to catch this case.
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+#ifdef __STDC__
+# include <limits.h>
+#else
+# include <assert.h>
+#endif
+ Syntax error
+_ACEOF
+if ac_fn_cxx_try_cpp "$LINENO"; then :
+
+else
+ # Broken: fails on valid input.
+continue
+fi
+rm -f conftest.err conftest.i conftest.$ac_ext
+
+ # OK, works on sane cases. Now check whether nonexistent headers
+ # can be detected and how.
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+#include <ac_nonexistent.h>
+_ACEOF
+if ac_fn_cxx_try_cpp "$LINENO"; then :
+ # Broken: success on invalid input.
+continue
+else
+ # Passes both tests.
+ac_preproc_ok=:
+break
+fi
+rm -f conftest.err conftest.i conftest.$ac_ext
+
+done
+# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped.
+rm -f conftest.i conftest.err conftest.$ac_ext
+if $ac_preproc_ok; then :
+
+else
+ { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
+$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
+as_fn_error $? "C++ preprocessor \"$CXXCPP\" fails sanity check
+See \`config.log' for more details" "$LINENO" 5; }
+fi
+
+ac_ext=c
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
+
+else
+ _lt_caught_CXX_error=yes
+fi
+
+ac_ext=cpp
+ac_cpp='$CXXCPP $CPPFLAGS'
+ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_cxx_compiler_gnu
+
+archive_cmds_need_lc_CXX=no
+allow_undefined_flag_CXX=
+always_export_symbols_CXX=no
+archive_expsym_cmds_CXX=
+compiler_needs_object_CXX=no
+export_dynamic_flag_spec_CXX=
+hardcode_direct_CXX=no
+hardcode_direct_absolute_CXX=no
+hardcode_libdir_flag_spec_CXX=
+hardcode_libdir_separator_CXX=
+hardcode_minus_L_CXX=no
+hardcode_shlibpath_var_CXX=unsupported
+hardcode_automatic_CXX=no
+inherit_rpath_CXX=no
+module_cmds_CXX=
+module_expsym_cmds_CXX=
+link_all_deplibs_CXX=unknown
+old_archive_cmds_CXX=$old_archive_cmds
+reload_flag_CXX=$reload_flag
+reload_cmds_CXX=$reload_cmds
+no_undefined_flag_CXX=
+whole_archive_flag_spec_CXX=
+enable_shared_with_static_runtimes_CXX=no
+
+# Source file extension for C++ test sources.
+ac_ext=cpp
+
+# Object file extension for compiled C++ test sources.
+objext=o
+objext_CXX=$objext
+
+# No sense in running all these tests if we already determined that
+# the CXX compiler isn't working. Some variables (like enable_shared)
+# are currently assumed to apply to all compilers on this platform,
+# and will be corrupted by setting them based on a non-working compiler.
+if test "$_lt_caught_CXX_error" != yes; then
+ # Code to be used in simple compile tests
+ lt_simple_compile_test_code="int some_variable = 0;"
+
+ # Code to be used in simple link tests
+ lt_simple_link_test_code='int main(int, char *[]) { return(0); }'
+
+ # ltmain only uses $CC for tagged configurations so make sure $CC is set.
+
+
+
+
+
+
+# If no C compiler was specified, use CC.
+LTCC=${LTCC-"$CC"}
+
+# If no C compiler flags were specified, use CFLAGS.
+LTCFLAGS=${LTCFLAGS-"$CFLAGS"}
+
+# Allow CC to be a program name with arguments.
+compiler=$CC
+
+
+ # save warnings/boilerplate of simple test code
+ ac_outfile=conftest.$ac_objext
+echo "$lt_simple_compile_test_code" >conftest.$ac_ext
+eval "$ac_compile" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err
+_lt_compiler_boilerplate=`cat conftest.err`
+$RM conftest*
+
+ ac_outfile=conftest.$ac_objext
+echo "$lt_simple_link_test_code" >conftest.$ac_ext
+eval "$ac_link" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err
+_lt_linker_boilerplate=`cat conftest.err`
+$RM -r conftest*
+
+
+ # Allow CC to be a program name with arguments.
+ lt_save_CC=$CC
+ lt_save_CFLAGS=$CFLAGS
+ lt_save_LD=$LD
+ lt_save_GCC=$GCC
+ GCC=$GXX
+ lt_save_with_gnu_ld=$with_gnu_ld
+ lt_save_path_LD=$lt_cv_path_LD
+ if test -n "${lt_cv_prog_gnu_ldcxx+set}"; then
+ lt_cv_prog_gnu_ld=$lt_cv_prog_gnu_ldcxx
+ else
+ $as_unset lt_cv_prog_gnu_ld
+ fi
+ if test -n "${lt_cv_path_LDCXX+set}"; then
+ lt_cv_path_LD=$lt_cv_path_LDCXX
+ else
+ $as_unset lt_cv_path_LD
+ fi
+ test -z "${LDCXX+set}" || LD=$LDCXX
+ CC=${CXX-"c++"}
+ CFLAGS=$CXXFLAGS
+ compiler=$CC
+ compiler_CXX=$CC
+ for cc_temp in $compiler""; do
+ case $cc_temp in
+ compile | *[\\/]compile | ccache | *[\\/]ccache ) ;;
+ distcc | *[\\/]distcc | purify | *[\\/]purify ) ;;
+ \-*) ;;
+ *) break;;
+ esac
+done
+cc_basename=`$ECHO "$cc_temp" | $SED "s%.*/%%; s%^$host_alias-%%"`
+
+
+ if test -n "$compiler"; then
+ # We don't want -fno-exception when compiling C++ code, so set the
+ # no_builtin_flag separately
+ if test "$GXX" = yes; then
+ lt_prog_compiler_no_builtin_flag_CXX=' -fno-builtin'
+ else
+ lt_prog_compiler_no_builtin_flag_CXX=
+ fi
+
+ if test "$GXX" = yes; then
+ # Set up default GNU C++ configuration
+
+
+
+# Check whether --with-gnu-ld was given.
+if test "${with_gnu_ld+set}" = set; then :
+ withval=$with_gnu_ld; test "$withval" = no || with_gnu_ld=yes
+else
+ with_gnu_ld=no
+fi
+
+ac_prog=ld
+if test "$GCC" = yes; then
+ # Check if gcc -print-prog-name=ld gives a path.
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ld used by $CC" >&5
+$as_echo_n "checking for ld used by $CC... " >&6; }
+ case $host in
+ *-*-mingw*)
+ # gcc leaves a trailing carriage return which upsets mingw
+ ac_prog=`($CC -print-prog-name=ld) 2>&5 | tr -d '\015'` ;;
+ *)
+ ac_prog=`($CC -print-prog-name=ld) 2>&5` ;;
+ esac
+ case $ac_prog in
+ # Accept absolute paths.
+ [\\/]* | ?:[\\/]*)
+ re_direlt='/[^/][^/]*/\.\./'
+ # Canonicalize the pathname of ld
+ ac_prog=`$ECHO "$ac_prog"| $SED 's%\\\\%/%g'`
+ while $ECHO "$ac_prog" | $GREP "$re_direlt" > /dev/null 2>&1; do
+ ac_prog=`$ECHO $ac_prog| $SED "s%$re_direlt%/%"`
+ done
+ test -z "$LD" && LD="$ac_prog"
+ ;;
+ "")
+ # If it fails, then pretend we aren't using GCC.
+ ac_prog=ld
+ ;;
+ *)
+ # If it is relative, then search for the first ld in PATH.
+ with_gnu_ld=unknown
+ ;;
+ esac
+elif test "$with_gnu_ld" = yes; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for GNU ld" >&5
+$as_echo_n "checking for GNU ld... " >&6; }
+else
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for non-GNU ld" >&5
+$as_echo_n "checking for non-GNU ld... " >&6; }
+fi
+if ${lt_cv_path_LD+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ if test -z "$LD"; then
+ lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR
+ for ac_dir in $PATH; do
+ IFS="$lt_save_ifs"
+ test -z "$ac_dir" && ac_dir=.
+ if test -f "$ac_dir/$ac_prog" || test -f "$ac_dir/$ac_prog$ac_exeext"; then
+ lt_cv_path_LD="$ac_dir/$ac_prog"
+ # Check to see if the program is GNU ld. I'd rather use --version,
+ # but apparently some variants of GNU ld only accept -v.
+ # Break only if it was the GNU/non-GNU ld that we prefer.
+ case `"$lt_cv_path_LD" -v 2>&1 </dev/null` in
+ *GNU* | *'with BFD'*)
+ test "$with_gnu_ld" != no && break
+ ;;
+ *)
+ test "$with_gnu_ld" != yes && break
+ ;;
+ esac
+ fi
+ done
+ IFS="$lt_save_ifs"
+else
+ lt_cv_path_LD="$LD" # Let the user override the test with a path.
+fi
+fi
+
+LD="$lt_cv_path_LD"
+if test -n "$LD"; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $LD" >&5
+$as_echo "$LD" >&6; }
+else
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+test -z "$LD" && as_fn_error $? "no acceptable ld found in \$PATH" "$LINENO" 5
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if the linker ($LD) is GNU ld" >&5
+$as_echo_n "checking if the linker ($LD) is GNU ld... " >&6; }
+if ${lt_cv_prog_gnu_ld+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ # I'd rather use --version here, but apparently some GNU lds only accept -v.
+case `$LD -v 2>&1 </dev/null` in
+*GNU* | *'with BFD'*)
+ lt_cv_prog_gnu_ld=yes
+ ;;
+*)
+ lt_cv_prog_gnu_ld=no
+ ;;
+esac
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_gnu_ld" >&5
+$as_echo "$lt_cv_prog_gnu_ld" >&6; }
+with_gnu_ld=$lt_cv_prog_gnu_ld
+
+
+
+
+
+
+
+ # Check if GNU C++ uses GNU ld as the underlying linker, since the
+ # archiving commands below assume that GNU ld is being used.
+ if test "$with_gnu_ld" = yes; then
+ archive_cmds_CXX='$CC $pic_flag -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib'
+ archive_expsym_cmds_CXX='$CC $pic_flag -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
+
+ hardcode_libdir_flag_spec_CXX='${wl}-rpath ${wl}$libdir'
+ export_dynamic_flag_spec_CXX='${wl}--export-dynamic'
+
+ # If archive_cmds runs LD, not CC, wlarc should be empty
+ # XXX I think wlarc can be eliminated in ltcf-cxx, but I need to
+ # investigate it a little bit more. (MM)
+ wlarc='${wl}'
+
+ # ancient GNU ld didn't support --whole-archive et. al.
+ if eval "`$CC -print-prog-name=ld` --help 2>&1" |
+ $GREP 'no-whole-archive' > /dev/null; then
+ whole_archive_flag_spec_CXX="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive'
+ else
+ whole_archive_flag_spec_CXX=
+ fi
+ else
+ with_gnu_ld=no
+ wlarc=
+
+ # A generic and very simple default shared library creation
+ # command for GNU C++ for the case where it uses the native
+ # linker, instead of GNU ld. If possible, this setting should
+ # overridden to take advantage of the native linker features on
+ # the platform it is being used on.
+ archive_cmds_CXX='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $lib'
+ fi
+
+ # Commands to make compiler produce verbose output that lists
+ # what "hidden" libraries, object files and flags are used when
+ # linking a shared library.
+ output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP -v "^Configured with:" | $GREP "\-L"'
+
+ else
+ GXX=no
+ with_gnu_ld=no
+ wlarc=
+ fi
+
+ # PORTME: fill in a description of your system's C++ link characteristics
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the $compiler linker ($LD) supports shared libraries" >&5
+$as_echo_n "checking whether the $compiler linker ($LD) supports shared libraries... " >&6; }
+ ld_shlibs_CXX=yes
+ case $host_os in
+ aix3*)
+ # FIXME: insert proper C++ library support
+ ld_shlibs_CXX=no
+ ;;
+ aix[4-9]*)
+ if test "$host_cpu" = ia64; then
+ # On IA64, the linker does run time linking by default, so we don't
+ # have to do anything special.
+ aix_use_runtimelinking=no
+ exp_sym_flag='-Bexport'
+ no_entry_flag=""
+ else
+ aix_use_runtimelinking=no
+
+ # Test if we are trying to use run time linking or normal
+ # AIX style linking. If -brtl is somewhere in LDFLAGS, we
+ # need to do runtime linking.
+ case $host_os in aix4.[23]|aix4.[23].*|aix[5-9]*)
+ for ld_flag in $LDFLAGS; do
+ case $ld_flag in
+ *-brtl*)
+ aix_use_runtimelinking=yes
+ break
+ ;;
+ esac
+ done
+ ;;
+ esac
+
+ exp_sym_flag='-bexport'
+ no_entry_flag='-bnoentry'
+ fi
+
+ # When large executables or shared objects are built, AIX ld can
+ # have problems creating the table of contents. If linking a library
+ # or program results in "error TOC overflow" add -mminimal-toc to
+ # CXXFLAGS/CFLAGS for g++/gcc. In the cases where that is not
+ # enough to fix the problem, add -Wl,-bbigtoc to LDFLAGS.
+
+ archive_cmds_CXX=''
+ hardcode_direct_CXX=yes
+ hardcode_direct_absolute_CXX=yes
+ hardcode_libdir_separator_CXX=':'
+ link_all_deplibs_CXX=yes
+ file_list_spec_CXX='${wl}-f,'
+
+ if test "$GXX" = yes; then
+ case $host_os in aix4.[012]|aix4.[012].*)
+ # We only want to do this on AIX 4.2 and lower, the check
+ # below for broken collect2 doesn't work under 4.3+
+ collect2name=`${CC} -print-prog-name=collect2`
+ if test -f "$collect2name" &&
+ strings "$collect2name" | $GREP resolve_lib_name >/dev/null
+ then
+ # We have reworked collect2
+ :
+ else
+ # We have old collect2
+ hardcode_direct_CXX=unsupported
+ # It fails to find uninstalled libraries when the uninstalled
+ # path is not listed in the libpath. Setting hardcode_minus_L
+ # to unsupported forces relinking
+ hardcode_minus_L_CXX=yes
+ hardcode_libdir_flag_spec_CXX='-L$libdir'
+ hardcode_libdir_separator_CXX=
+ fi
+ esac
+ shared_flag='-shared'
+ if test "$aix_use_runtimelinking" = yes; then
+ shared_flag="$shared_flag "'${wl}-G'
+ fi
+ else
+ # not using gcc
+ if test "$host_cpu" = ia64; then
+ # VisualAge C++, Version 5.5 for AIX 5L for IA-64, Beta 3 Release
+ # chokes on -Wl,-G. The following line is correct:
+ shared_flag='-G'
+ else
+ if test "$aix_use_runtimelinking" = yes; then
+ shared_flag='${wl}-G'
+ else
+ shared_flag='${wl}-bM:SRE'
+ fi
+ fi
+ fi
+
+ export_dynamic_flag_spec_CXX='${wl}-bexpall'
+ # It seems that -bexpall does not export symbols beginning with
+ # underscore (_), so it is better to generate a list of symbols to
+ # export.
+ always_export_symbols_CXX=yes
+ if test "$aix_use_runtimelinking" = yes; then
+ # Warning - without using the other runtime loading flags (-brtl),
+ # -berok will link without error, but may produce a broken library.
+ allow_undefined_flag_CXX='-berok'
+ # Determine the default libpath from the value encoded in an empty
+ # executable.
+ if test "${lt_cv_aix_libpath+set}" = set; then
+ aix_libpath=$lt_cv_aix_libpath
+else
+ if ${lt_cv_aix_libpath__CXX+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+
+int
+main ()
+{
+
+ ;
+ return 0;
+}
+_ACEOF
+if ac_fn_cxx_try_link "$LINENO"; then :
+
+ lt_aix_libpath_sed='
+ /Import File Strings/,/^$/ {
+ /^0/ {
+ s/^0 *\([^ ]*\) *$/\1/
+ p
+ }
+ }'
+ lt_cv_aix_libpath__CXX=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"`
+ # Check for a 64-bit object if we didn't find anything.
+ if test -z "$lt_cv_aix_libpath__CXX"; then
+ lt_cv_aix_libpath__CXX=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"`
+ fi
+fi
+rm -f core conftest.err conftest.$ac_objext \
+ conftest$ac_exeext conftest.$ac_ext
+ if test -z "$lt_cv_aix_libpath__CXX"; then
+ lt_cv_aix_libpath__CXX="/usr/lib:/lib"
+ fi
+
+fi
+
+ aix_libpath=$lt_cv_aix_libpath__CXX
+fi
+
+ hardcode_libdir_flag_spec_CXX='${wl}-blibpath:$libdir:'"$aix_libpath"
+
+ archive_expsym_cmds_CXX='$CC -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags `if test "x${allow_undefined_flag}" != "x"; then func_echo_all "${wl}${allow_undefined_flag}"; else :; fi` '"\${wl}$exp_sym_flag:\$export_symbols $shared_flag"
+ else
+ if test "$host_cpu" = ia64; then
+ hardcode_libdir_flag_spec_CXX='${wl}-R $libdir:/usr/lib:/lib'
+ allow_undefined_flag_CXX="-z nodefs"
+ archive_expsym_cmds_CXX="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags ${wl}${allow_undefined_flag} '"\${wl}$exp_sym_flag:\$export_symbols"
+ else
+ # Determine the default libpath from the value encoded in an
+ # empty executable.
+ if test "${lt_cv_aix_libpath+set}" = set; then
+ aix_libpath=$lt_cv_aix_libpath
+else
+ if ${lt_cv_aix_libpath__CXX+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+
+int
+main ()
+{
+
+ ;
+ return 0;
+}
+_ACEOF
+if ac_fn_cxx_try_link "$LINENO"; then :
+
+ lt_aix_libpath_sed='
+ /Import File Strings/,/^$/ {
+ /^0/ {
+ s/^0 *\([^ ]*\) *$/\1/
+ p
+ }
+ }'
+ lt_cv_aix_libpath__CXX=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"`
+ # Check for a 64-bit object if we didn't find anything.
+ if test -z "$lt_cv_aix_libpath__CXX"; then
+ lt_cv_aix_libpath__CXX=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"`
+ fi
+fi
+rm -f core conftest.err conftest.$ac_objext \
+ conftest$ac_exeext conftest.$ac_ext
+ if test -z "$lt_cv_aix_libpath__CXX"; then
+ lt_cv_aix_libpath__CXX="/usr/lib:/lib"
+ fi
+
+fi
+
+ aix_libpath=$lt_cv_aix_libpath__CXX
+fi
+
+ hardcode_libdir_flag_spec_CXX='${wl}-blibpath:$libdir:'"$aix_libpath"
+ # Warning - without using the other run time loading flags,
+ # -berok will link without error, but may produce a broken library.
+ no_undefined_flag_CXX=' ${wl}-bernotok'
+ allow_undefined_flag_CXX=' ${wl}-berok'
+ if test "$with_gnu_ld" = yes; then
+ # We only use this code for GNU lds that support --whole-archive.
+ whole_archive_flag_spec_CXX='${wl}--whole-archive$convenience ${wl}--no-whole-archive'
+ else
+ # Exported symbols can be pulled into shared objects from archives
+ whole_archive_flag_spec_CXX='$convenience'
+ fi
+ archive_cmds_need_lc_CXX=yes
+ # This is similar to how AIX traditionally builds its shared
+ # libraries.
+ archive_expsym_cmds_CXX="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs ${wl}-bnoentry $compiler_flags ${wl}-bE:$export_symbols${allow_undefined_flag}~$AR $AR_FLAGS $output_objdir/$libname$release.a $output_objdir/$soname'
+ fi
+ fi
+ ;;
+
+ beos*)
+ if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then
+ allow_undefined_flag_CXX=unsupported
+ # Joseph Beckenbach <jrb3@best.com> says some releases of gcc
+ # support --undefined. This deserves some investigation. FIXME
+ archive_cmds_CXX='$CC -nostart $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+ else
+ ld_shlibs_CXX=no
+ fi
+ ;;
+
+ chorus*)
+ case $cc_basename in
+ *)
+ # FIXME: insert proper C++ library support
+ ld_shlibs_CXX=no
+ ;;
+ esac
+ ;;
+
+ cygwin* | mingw* | pw32* | cegcc*)
+ case $GXX,$cc_basename in
+ ,cl* | no,cl*)
+ # Native MSVC
+ # hardcode_libdir_flag_spec is actually meaningless, as there is
+ # no search path for DLLs.
+ hardcode_libdir_flag_spec_CXX=' '
+ allow_undefined_flag_CXX=unsupported
+ always_export_symbols_CXX=yes
+ file_list_spec_CXX='@'
+ # Tell ltmain to make .lib files, not .a files.
+ libext=lib
+ # Tell ltmain to make .dll files, not .so files.
+ shrext_cmds=".dll"
+ # FIXME: Setting linknames here is a bad hack.
+ archive_cmds_CXX='$CC -o $output_objdir/$soname $libobjs $compiler_flags $deplibs -Wl,-dll~linknames='
+ archive_expsym_cmds_CXX='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then
+ $SED -n -e 's/\\\\\\\(.*\\\\\\\)/-link\\\ -EXPORT:\\\\\\\1/' -e '1\\\!p' < $export_symbols > $output_objdir/$soname.exp;
+ else
+ $SED -e 's/\\\\\\\(.*\\\\\\\)/-link\\\ -EXPORT:\\\\\\\1/' < $export_symbols > $output_objdir/$soname.exp;
+ fi~
+ $CC -o $tool_output_objdir$soname $libobjs $compiler_flags $deplibs "@$tool_output_objdir$soname.exp" -Wl,-DLL,-IMPLIB:"$tool_output_objdir$libname.dll.lib"~
+ linknames='
+ # The linker will not automatically build a static lib if we build a DLL.
+ # _LT_TAGVAR(old_archive_from_new_cmds, CXX)='true'
+ enable_shared_with_static_runtimes_CXX=yes
+ # Don't use ranlib
+ old_postinstall_cmds_CXX='chmod 644 $oldlib'
+ postlink_cmds_CXX='lt_outputfile="@OUTPUT@"~
+ lt_tool_outputfile="@TOOL_OUTPUT@"~
+ case $lt_outputfile in
+ *.exe|*.EXE) ;;
+ *)
+ lt_outputfile="$lt_outputfile.exe"
+ lt_tool_outputfile="$lt_tool_outputfile.exe"
+ ;;
+ esac~
+ func_to_tool_file "$lt_outputfile"~
+ if test "$MANIFEST_TOOL" != ":" && test -f "$lt_outputfile.manifest"; then
+ $MANIFEST_TOOL -manifest "$lt_tool_outputfile.manifest" -outputresource:"$lt_tool_outputfile" || exit 1;
+ $RM "$lt_outputfile.manifest";
+ fi'
+ ;;
+ *)
+ # g++
+ # _LT_TAGVAR(hardcode_libdir_flag_spec, CXX) is actually meaningless,
+ # as there is no search path for DLLs.
+ hardcode_libdir_flag_spec_CXX='-L$libdir'
+ export_dynamic_flag_spec_CXX='${wl}--export-all-symbols'
+ allow_undefined_flag_CXX=unsupported
+ always_export_symbols_CXX=no
+ enable_shared_with_static_runtimes_CXX=yes
+
+ if $LD --help 2>&1 | $GREP 'auto-import' > /dev/null; then
+ archive_cmds_CXX='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib'
+ # If the export-symbols file already is a .def file (1st line
+ # is EXPORTS), use it as is; otherwise, prepend...
+ archive_expsym_cmds_CXX='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then
+ cp $export_symbols $output_objdir/$soname.def;
+ else
+ echo EXPORTS > $output_objdir/$soname.def;
+ cat $export_symbols >> $output_objdir/$soname.def;
+ fi~
+ $CC -shared -nostdlib $output_objdir/$soname.def $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib'
+ else
+ ld_shlibs_CXX=no
+ fi
+ ;;
+ esac
+ ;;
+ darwin* | rhapsody*)
+
+
+ archive_cmds_need_lc_CXX=no
+ hardcode_direct_CXX=no
+ hardcode_automatic_CXX=yes
+ hardcode_shlibpath_var_CXX=unsupported
+ if test "$lt_cv_ld_force_load" = "yes"; then
+ whole_archive_flag_spec_CXX='`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience ${wl}-force_load,$conv\"; done; func_echo_all \"$new_convenience\"`'
+
+ else
+ whole_archive_flag_spec_CXX=''
+ fi
+ link_all_deplibs_CXX=yes
+ allow_undefined_flag_CXX="$_lt_dar_allow_undefined"
+ case $cc_basename in
+ ifort*) _lt_dar_can_shared=yes ;;
+ *) _lt_dar_can_shared=$GCC ;;
+ esac
+ if test "$_lt_dar_can_shared" = "yes"; then
+ output_verbose_link_cmd=func_echo_all
+ archive_cmds_CXX="\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring $_lt_dar_single_mod${_lt_dsymutil}"
+ module_cmds_CXX="\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dsymutil}"
+ archive_expsym_cmds_CXX="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring ${_lt_dar_single_mod}${_lt_dar_export_syms}${_lt_dsymutil}"
+ module_expsym_cmds_CXX="sed -e 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dar_export_syms}${_lt_dsymutil}"
+ if test "$lt_cv_apple_cc_single_mod" != "yes"; then
+ archive_cmds_CXX="\$CC -r -keep_private_externs -nostdlib -o \${lib}-master.o \$libobjs~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \${lib}-master.o \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring${_lt_dsymutil}"
+ archive_expsym_cmds_CXX="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -r -keep_private_externs -nostdlib -o \${lib}-master.o \$libobjs~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \${lib}-master.o \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring${_lt_dar_export_syms}${_lt_dsymutil}"
+ fi
+
+ else
+ ld_shlibs_CXX=no
+ fi
+
+ ;;
+
+ dgux*)
+ case $cc_basename in
+ ec++*)
+ # FIXME: insert proper C++ library support
+ ld_shlibs_CXX=no
+ ;;
+ ghcx*)
+ # Green Hills C++ Compiler
+ # FIXME: insert proper C++ library support
+ ld_shlibs_CXX=no
+ ;;
+ *)
+ # FIXME: insert proper C++ library support
+ ld_shlibs_CXX=no
+ ;;
+ esac
+ ;;
+
+ freebsd2.*)
+ # C++ shared libraries reported to be fairly broken before
+ # switch to ELF
+ ld_shlibs_CXX=no
+ ;;
+
+ freebsd-elf*)
+ archive_cmds_need_lc_CXX=no
+ ;;
+
+ freebsd* | dragonfly*)
+ # FreeBSD 3 and later use GNU C++ and GNU ld with standard ELF
+ # conventions
+ ld_shlibs_CXX=yes
+ ;;
+
+ gnu*)
+ ;;
+
+ haiku*)
+ archive_cmds_CXX='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+ link_all_deplibs_CXX=yes
+ ;;
+
+ hpux9*)
+ hardcode_libdir_flag_spec_CXX='${wl}+b ${wl}$libdir'
+ hardcode_libdir_separator_CXX=:
+ export_dynamic_flag_spec_CXX='${wl}-E'
+ hardcode_direct_CXX=yes
+ hardcode_minus_L_CXX=yes # Not in the search PATH,
+ # but as the default
+ # location of the library.
+
+ case $cc_basename in
+ CC*)
+ # FIXME: insert proper C++ library support
+ ld_shlibs_CXX=no
+ ;;
+ aCC*)
+ archive_cmds_CXX='$RM $output_objdir/$soname~$CC -b ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib'
+ # Commands to make compiler produce verbose output that lists
+ # what "hidden" libraries, object files and flags are used when
+ # linking a shared library.
+ #
+ # There doesn't appear to be a way to prevent this compiler from
+ # explicitly linking system object files so we need to strip them
+ # from the output so that they don't get included in the library
+ # dependencies.
+ output_verbose_link_cmd='templist=`($CC -b $CFLAGS -v conftest.$objext 2>&1) | $EGREP "\-L"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "$list"'
+ ;;
+ *)
+ if test "$GXX" = yes; then
+ archive_cmds_CXX='$RM $output_objdir/$soname~$CC -shared -nostdlib $pic_flag ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib'
+ else
+ # FIXME: insert proper C++ library support
+ ld_shlibs_CXX=no
+ fi
+ ;;
+ esac
+ ;;
+
+ hpux10*|hpux11*)
+ if test $with_gnu_ld = no; then
+ hardcode_libdir_flag_spec_CXX='${wl}+b ${wl}$libdir'
+ hardcode_libdir_separator_CXX=:
+
+ case $host_cpu in
+ hppa*64*|ia64*)
+ ;;
+ *)
+ export_dynamic_flag_spec_CXX='${wl}-E'
+ ;;
+ esac
+ fi
+ case $host_cpu in
+ hppa*64*|ia64*)
+ hardcode_direct_CXX=no
+ hardcode_shlibpath_var_CXX=no
+ ;;
+ *)
+ hardcode_direct_CXX=yes
+ hardcode_direct_absolute_CXX=yes
+ hardcode_minus_L_CXX=yes # Not in the search PATH,
+ # but as the default
+ # location of the library.
+ ;;
+ esac
+
+ case $cc_basename in
+ CC*)
+ # FIXME: insert proper C++ library support
+ ld_shlibs_CXX=no
+ ;;
+ aCC*)
+ case $host_cpu in
+ hppa*64*)
+ archive_cmds_CXX='$CC -b ${wl}+h ${wl}$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
+ ;;
+ ia64*)
+ archive_cmds_CXX='$CC -b ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
+ ;;
+ *)
+ archive_cmds_CXX='$CC -b ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
+ ;;
+ esac
+ # Commands to make compiler produce verbose output that lists
+ # what "hidden" libraries, object files and flags are used when
+ # linking a shared library.
+ #
+ # There doesn't appear to be a way to prevent this compiler from
+ # explicitly linking system object files so we need to strip them
+ # from the output so that they don't get included in the library
+ # dependencies.
+ output_verbose_link_cmd='templist=`($CC -b $CFLAGS -v conftest.$objext 2>&1) | $GREP "\-L"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "$list"'
+ ;;
+ *)
+ if test "$GXX" = yes; then
+ if test $with_gnu_ld = no; then
+ case $host_cpu in
+ hppa*64*)
+ archive_cmds_CXX='$CC -shared -nostdlib -fPIC ${wl}+h ${wl}$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
+ ;;
+ ia64*)
+ archive_cmds_CXX='$CC -shared -nostdlib $pic_flag ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
+ ;;
+ *)
+ archive_cmds_CXX='$CC -shared -nostdlib $pic_flag ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
+ ;;
+ esac
+ fi
+ else
+ # FIXME: insert proper C++ library support
+ ld_shlibs_CXX=no
+ fi
+ ;;
+ esac
+ ;;
+
+ interix[3-9]*)
+ hardcode_direct_CXX=no
+ hardcode_shlibpath_var_CXX=no
+ hardcode_libdir_flag_spec_CXX='${wl}-rpath,$libdir'
+ export_dynamic_flag_spec_CXX='${wl}-E'
+ # Hack: On Interix 3.x, we cannot compile PIC because of a broken gcc.
+ # Instead, shared libraries are loaded at an image base (0x10000000 by
+ # default) and relocated if they conflict, which is a slow very memory
+ # consuming and fragmenting process. To avoid this, we pick a random,
+ # 256 KiB-aligned image base between 0x50000000 and 0x6FFC0000 at link
+ # time. Moving up from 0x10000000 also allows more sbrk(2) space.
+ archive_cmds_CXX='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib'
+ archive_expsym_cmds_CXX='sed "s,^,_," $export_symbols >$output_objdir/$soname.expsym~$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--retain-symbols-file,$output_objdir/$soname.expsym ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib'
+ ;;
+ irix5* | irix6*)
+ case $cc_basename in
+ CC*)
+ # SGI C++
+ archive_cmds_CXX='$CC -shared -all -multigot $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib'
+
+ # Archives containing C++ object files must be created using
+ # "CC -ar", where "CC" is the IRIX C++ compiler. This is
+ # necessary to make sure instantiated templates are included
+ # in the archive.
+ old_archive_cmds_CXX='$CC -ar -WR,-u -o $oldlib $oldobjs'
+ ;;
+ *)
+ if test "$GXX" = yes; then
+ if test "$with_gnu_ld" = no; then
+ archive_cmds_CXX='$CC -shared $pic_flag -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
+ else
+ archive_cmds_CXX='$CC -shared $pic_flag -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` -o $lib'
+ fi
+ fi
+ link_all_deplibs_CXX=yes
+ ;;
+ esac
+ hardcode_libdir_flag_spec_CXX='${wl}-rpath ${wl}$libdir'
+ hardcode_libdir_separator_CXX=:
+ inherit_rpath_CXX=yes
+ ;;
+
+ linux* | k*bsd*-gnu | kopensolaris*-gnu)
+ case $cc_basename in
+ KCC*)
+ # Kuck and Associates, Inc. (KAI) C++ Compiler
+
+ # KCC will only create a shared library if the output file
+ # ends with ".so" (or ".sl" for HP-UX), so rename the library
+ # to its proper name (with version) after linking.
+ archive_cmds_CXX='tempext=`echo $shared_ext | $SED -e '\''s/\([^()0-9A-Za-z{}]\)/\\\\\1/g'\''`; templib=`echo $lib | $SED -e "s/\${tempext}\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib; mv \$templib $lib'
+ archive_expsym_cmds_CXX='tempext=`echo $shared_ext | $SED -e '\''s/\([^()0-9A-Za-z{}]\)/\\\\\1/g'\''`; templib=`echo $lib | $SED -e "s/\${tempext}\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib ${wl}-retain-symbols-file,$export_symbols; mv \$templib $lib'
+ # Commands to make compiler produce verbose output that lists
+ # what "hidden" libraries, object files and flags are used when
+ # linking a shared library.
+ #
+ # There doesn't appear to be a way to prevent this compiler from
+ # explicitly linking system object files so we need to strip them
+ # from the output so that they don't get included in the library
+ # dependencies.
+ output_verbose_link_cmd='templist=`$CC $CFLAGS -v conftest.$objext -o libconftest$shared_ext 2>&1 | $GREP "ld"`; rm -f libconftest$shared_ext; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "$list"'
+
+ hardcode_libdir_flag_spec_CXX='${wl}-rpath,$libdir'
+ export_dynamic_flag_spec_CXX='${wl}--export-dynamic'
+
+ # Archives containing C++ object files must be created using
+ # "CC -Bstatic", where "CC" is the KAI C++ compiler.
+ old_archive_cmds_CXX='$CC -Bstatic -o $oldlib $oldobjs'
+ ;;
+ icpc* | ecpc* )
+ # Intel C++
+ with_gnu_ld=yes
+ # version 8.0 and above of icpc choke on multiply defined symbols
+ # if we add $predep_objects and $postdep_objects, however 7.1 and
+ # earlier do not add the objects themselves.
+ case `$CC -V 2>&1` in
+ *"Version 7."*)
+ archive_cmds_CXX='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib'
+ archive_expsym_cmds_CXX='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
+ ;;
+ *) # Version 8.0 or newer
+ tmp_idyn=
+ case $host_cpu in
+ ia64*) tmp_idyn=' -i_dynamic';;
+ esac
+ archive_cmds_CXX='$CC -shared'"$tmp_idyn"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+ archive_expsym_cmds_CXX='$CC -shared'"$tmp_idyn"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
+ ;;
+ esac
+ archive_cmds_need_lc_CXX=no
+ hardcode_libdir_flag_spec_CXX='${wl}-rpath,$libdir'
+ export_dynamic_flag_spec_CXX='${wl}--export-dynamic'
+ whole_archive_flag_spec_CXX='${wl}--whole-archive$convenience ${wl}--no-whole-archive'
+ ;;
+ pgCC* | pgcpp*)
+ # Portland Group C++ compiler
+ case `$CC -V` in
+ *pgCC\ [1-5].* | *pgcpp\ [1-5].*)
+ prelink_cmds_CXX='tpldir=Template.dir~
+ rm -rf $tpldir~
+ $CC --prelink_objects --instantiation_dir $tpldir $objs $libobjs $compile_deplibs~
+ compile_command="$compile_command `find $tpldir -name \*.o | sort | $NL2SP`"'
+ old_archive_cmds_CXX='tpldir=Template.dir~
+ rm -rf $tpldir~
+ $CC --prelink_objects --instantiation_dir $tpldir $oldobjs$old_deplibs~
+ $AR $AR_FLAGS $oldlib$oldobjs$old_deplibs `find $tpldir -name \*.o | sort | $NL2SP`~
+ $RANLIB $oldlib'
+ archive_cmds_CXX='tpldir=Template.dir~
+ rm -rf $tpldir~
+ $CC --prelink_objects --instantiation_dir $tpldir $predep_objects $libobjs $deplibs $convenience $postdep_objects~
+ $CC -shared $pic_flag $predep_objects $libobjs $deplibs `find $tpldir -name \*.o | sort | $NL2SP` $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname -o $lib'
+ archive_expsym_cmds_CXX='tpldir=Template.dir~
+ rm -rf $tpldir~
+ $CC --prelink_objects --instantiation_dir $tpldir $predep_objects $libobjs $deplibs $convenience $postdep_objects~
+ $CC -shared $pic_flag $predep_objects $libobjs $deplibs `find $tpldir -name \*.o | sort | $NL2SP` $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname ${wl}-retain-symbols-file ${wl}$export_symbols -o $lib'
+ ;;
+ *) # Version 6 and above use weak symbols
+ archive_cmds_CXX='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname -o $lib'
+ archive_expsym_cmds_CXX='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname ${wl}-retain-symbols-file ${wl}$export_symbols -o $lib'
+ ;;
+ esac
+
+ hardcode_libdir_flag_spec_CXX='${wl}--rpath ${wl}$libdir'
+ export_dynamic_flag_spec_CXX='${wl}--export-dynamic'
+ whole_archive_flag_spec_CXX='${wl}--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` ${wl}--no-whole-archive'
+ ;;
+ cxx*)
+ # Compaq C++
+ archive_cmds_CXX='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib'
+ archive_expsym_cmds_CXX='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib ${wl}-retain-symbols-file $wl$export_symbols'
+
+ runpath_var=LD_RUN_PATH
+ hardcode_libdir_flag_spec_CXX='-rpath $libdir'
+ hardcode_libdir_separator_CXX=:
+
+ # Commands to make compiler produce verbose output that lists
+ # what "hidden" libraries, object files and flags are used when
+ # linking a shared library.
+ #
+ # There doesn't appear to be a way to prevent this compiler from
+ # explicitly linking system object files so we need to strip them
+ # from the output so that they don't get included in the library
+ # dependencies.
+ output_verbose_link_cmd='templist=`$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP "ld"`; templist=`func_echo_all "$templist" | $SED "s/\(^.*ld.*\)\( .*ld .*$\)/\1/"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "X$list" | $Xsed'
+ ;;
+ xl* | mpixl* | bgxl*)
+ # IBM XL 8.0 on PPC, with GNU ld
+ hardcode_libdir_flag_spec_CXX='${wl}-rpath ${wl}$libdir'
+ export_dynamic_flag_spec_CXX='${wl}--export-dynamic'
+ archive_cmds_CXX='$CC -qmkshrobj $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+ if test "x$supports_anon_versioning" = xyes; then
+ archive_expsym_cmds_CXX='echo "{ global:" > $output_objdir/$libname.ver~
+ cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~
+ echo "local: *; };" >> $output_objdir/$libname.ver~
+ $CC -qmkshrobj $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-version-script ${wl}$output_objdir/$libname.ver -o $lib'
+ fi
+ ;;
+ *)
+ case `$CC -V 2>&1 | sed 5q` in
+ *Sun\ C*)
+ # Sun C++ 5.9
+ no_undefined_flag_CXX=' -zdefs'
+ archive_cmds_CXX='$CC -G${allow_undefined_flag} -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
+ archive_expsym_cmds_CXX='$CC -G${allow_undefined_flag} -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-retain-symbols-file ${wl}$export_symbols'
+ hardcode_libdir_flag_spec_CXX='-R$libdir'
+ whole_archive_flag_spec_CXX='${wl}--whole-archive`new_convenience=; for conv in $convenience\"\"; do test -z \"$conv\" || new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` ${wl}--no-whole-archive'
+ compiler_needs_object_CXX=yes
+
+ # Not sure whether something based on
+ # $CC $CFLAGS -v conftest.$objext -o libconftest$shared_ext 2>&1
+ # would be better.
+ output_verbose_link_cmd='func_echo_all'
+
+ # Archives containing C++ object files must be created using
+ # "CC -xar", where "CC" is the Sun C++ compiler. This is
+ # necessary to make sure instantiated templates are included
+ # in the archive.
+ old_archive_cmds_CXX='$CC -xar -o $oldlib $oldobjs'
+ ;;
+ esac
+ ;;
+ esac
+ ;;
+
+ lynxos*)
+ # FIXME: insert proper C++ library support
+ ld_shlibs_CXX=no
+ ;;
+
+ m88k*)
+ # FIXME: insert proper C++ library support
+ ld_shlibs_CXX=no
+ ;;
+
+ mvs*)
+ case $cc_basename in
+ cxx*)
+ # FIXME: insert proper C++ library support
+ ld_shlibs_CXX=no
+ ;;
+ *)
+ # FIXME: insert proper C++ library support
+ ld_shlibs_CXX=no
+ ;;
+ esac
+ ;;
+
+ netbsd*)
+ if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then
+ archive_cmds_CXX='$LD -Bshareable -o $lib $predep_objects $libobjs $deplibs $postdep_objects $linker_flags'
+ wlarc=
+ hardcode_libdir_flag_spec_CXX='-R$libdir'
+ hardcode_direct_CXX=yes
+ hardcode_shlibpath_var_CXX=no
+ fi
+ # Workaround some broken pre-1.5 toolchains
+ output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP conftest.$objext | $SED -e "s:-lgcc -lc -lgcc::"'
+ ;;
+
+ *nto* | *qnx*)
+ ld_shlibs_CXX=yes
+ ;;
+
+ openbsd2*)
+ # C++ shared libraries are fairly broken
+ ld_shlibs_CXX=no
+ ;;
+
+ openbsd*)
+ if test -f /usr/libexec/ld.so; then
+ hardcode_direct_CXX=yes
+ hardcode_shlibpath_var_CXX=no
+ hardcode_direct_absolute_CXX=yes
+ archive_cmds_CXX='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $lib'
+ hardcode_libdir_flag_spec_CXX='${wl}-rpath,$libdir'
+ if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then
+ archive_expsym_cmds_CXX='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-retain-symbols-file,$export_symbols -o $lib'
+ export_dynamic_flag_spec_CXX='${wl}-E'
+ whole_archive_flag_spec_CXX="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive'
+ fi
+ output_verbose_link_cmd=func_echo_all
+ else
+ ld_shlibs_CXX=no
+ fi
+ ;;
+
+ osf3* | osf4* | osf5*)
+ case $cc_basename in
+ KCC*)
+ # Kuck and Associates, Inc. (KAI) C++ Compiler
+
+ # KCC will only create a shared library if the output file
+ # ends with ".so" (or ".sl" for HP-UX), so rename the library
+ # to its proper name (with version) after linking.
+ archive_cmds_CXX='tempext=`echo $shared_ext | $SED -e '\''s/\([^()0-9A-Za-z{}]\)/\\\\\1/g'\''`; templib=`echo "$lib" | $SED -e "s/\${tempext}\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib; mv \$templib $lib'
+
+ hardcode_libdir_flag_spec_CXX='${wl}-rpath,$libdir'
+ hardcode_libdir_separator_CXX=:
+
+ # Archives containing C++ object files must be created using
+ # the KAI C++ compiler.
+ case $host in
+ osf3*) old_archive_cmds_CXX='$CC -Bstatic -o $oldlib $oldobjs' ;;
+ *) old_archive_cmds_CXX='$CC -o $oldlib $oldobjs' ;;
+ esac
+ ;;
+ RCC*)
+ # Rational C++ 2.4.1
+ # FIXME: insert proper C++ library support
+ ld_shlibs_CXX=no
+ ;;
+ cxx*)
+ case $host in
+ osf3*)
+ allow_undefined_flag_CXX=' ${wl}-expect_unresolved ${wl}\*'
+ archive_cmds_CXX='$CC -shared${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $soname `test -n "$verstring" && func_echo_all "${wl}-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib'
+ hardcode_libdir_flag_spec_CXX='${wl}-rpath ${wl}$libdir'
+ ;;
+ *)
+ allow_undefined_flag_CXX=' -expect_unresolved \*'
+ archive_cmds_CXX='$CC -shared${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -msym -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib'
+ archive_expsym_cmds_CXX='for i in `cat $export_symbols`; do printf "%s %s\\n" -exported_symbol "\$i" >> $lib.exp; done~
+ echo "-hidden">> $lib.exp~
+ $CC -shared$allow_undefined_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -msym -soname $soname ${wl}-input ${wl}$lib.exp `test -n "$verstring" && $ECHO "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib~
+ $RM $lib.exp'
+ hardcode_libdir_flag_spec_CXX='-rpath $libdir'
+ ;;
+ esac
+
+ hardcode_libdir_separator_CXX=:
+
+ # Commands to make compiler produce verbose output that lists
+ # what "hidden" libraries, object files and flags are used when
+ # linking a shared library.
+ #
+ # There doesn't appear to be a way to prevent this compiler from
+ # explicitly linking system object files so we need to strip them
+ # from the output so that they don't get included in the library
+ # dependencies.
+ output_verbose_link_cmd='templist=`$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP "ld" | $GREP -v "ld:"`; templist=`func_echo_all "$templist" | $SED "s/\(^.*ld.*\)\( .*ld.*$\)/\1/"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "$list"'
+ ;;
+ *)
+ if test "$GXX" = yes && test "$with_gnu_ld" = no; then
+ allow_undefined_flag_CXX=' ${wl}-expect_unresolved ${wl}\*'
+ case $host in
+ osf3*)
+ archive_cmds_CXX='$CC -shared -nostdlib ${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
+ ;;
+ *)
+ archive_cmds_CXX='$CC -shared $pic_flag -nostdlib ${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-msym ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
+ ;;
+ esac
+
+ hardcode_libdir_flag_spec_CXX='${wl}-rpath ${wl}$libdir'
+ hardcode_libdir_separator_CXX=:
+
+ # Commands to make compiler produce verbose output that lists
+ # what "hidden" libraries, object files and flags are used when
+ # linking a shared library.
+ output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP -v "^Configured with:" | $GREP "\-L"'
+
+ else
+ # FIXME: insert proper C++ library support
+ ld_shlibs_CXX=no
+ fi
+ ;;
+ esac
+ ;;
+
+ psos*)
+ # FIXME: insert proper C++ library support
+ ld_shlibs_CXX=no
+ ;;
+
+ sunos4*)
+ case $cc_basename in
+ CC*)
+ # Sun C++ 4.x
+ # FIXME: insert proper C++ library support
+ ld_shlibs_CXX=no
+ ;;
+ lcc*)
+ # Lucid
+ # FIXME: insert proper C++ library support
+ ld_shlibs_CXX=no
+ ;;
+ *)
+ # FIXME: insert proper C++ library support
+ ld_shlibs_CXX=no
+ ;;
+ esac
+ ;;
+
+ solaris*)
+ case $cc_basename in
+ CC* | sunCC*)
+ # Sun C++ 4.2, 5.x and Centerline C++
+ archive_cmds_need_lc_CXX=yes
+ no_undefined_flag_CXX=' -zdefs'
+ archive_cmds_CXX='$CC -G${allow_undefined_flag} -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
+ archive_expsym_cmds_CXX='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~
+ $CC -G${allow_undefined_flag} ${wl}-M ${wl}$lib.exp -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$RM $lib.exp'
+
+ hardcode_libdir_flag_spec_CXX='-R$libdir'
+ hardcode_shlibpath_var_CXX=no
+ case $host_os in
+ solaris2.[0-5] | solaris2.[0-5].*) ;;
+ *)
+ # The compiler driver will combine and reorder linker options,
+ # but understands `-z linker_flag'.
+ # Supported since Solaris 2.6 (maybe 2.5.1?)
+ whole_archive_flag_spec_CXX='-z allextract$convenience -z defaultextract'
+ ;;
+ esac
+ link_all_deplibs_CXX=yes
+
+ output_verbose_link_cmd='func_echo_all'
+
+ # Archives containing C++ object files must be created using
+ # "CC -xar", where "CC" is the Sun C++ compiler. This is
+ # necessary to make sure instantiated templates are included
+ # in the archive.
+ old_archive_cmds_CXX='$CC -xar -o $oldlib $oldobjs'
+ ;;
+ gcx*)
+ # Green Hills C++ Compiler
+ archive_cmds_CXX='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-h $wl$soname -o $lib'
+
+ # The C++ compiler must be used to create the archive.
+ old_archive_cmds_CXX='$CC $LDFLAGS -archive -o $oldlib $oldobjs'
+ ;;
+ *)
+ # GNU C++ compiler with Solaris linker
+ if test "$GXX" = yes && test "$with_gnu_ld" = no; then
+ no_undefined_flag_CXX=' ${wl}-z ${wl}defs'
+ if $CC --version | $GREP -v '^2\.7' > /dev/null; then
+ archive_cmds_CXX='$CC -shared $pic_flag -nostdlib $LDFLAGS $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-h $wl$soname -o $lib'
+ archive_expsym_cmds_CXX='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~
+ $CC -shared $pic_flag -nostdlib ${wl}-M $wl$lib.exp -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$RM $lib.exp'
+
+ # Commands to make compiler produce verbose output that lists
+ # what "hidden" libraries, object files and flags are used when
+ # linking a shared library.
+ output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP -v "^Configured with:" | $GREP "\-L"'
+ else
+ # g++ 2.7 appears to require `-G' NOT `-shared' on this
+ # platform.
+ archive_cmds_CXX='$CC -G -nostdlib $LDFLAGS $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-h $wl$soname -o $lib'
+ archive_expsym_cmds_CXX='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~
+ $CC -G -nostdlib ${wl}-M $wl$lib.exp -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$RM $lib.exp'
+
+ # Commands to make compiler produce verbose output that lists
+ # what "hidden" libraries, object files and flags are used when
+ # linking a shared library.
+ output_verbose_link_cmd='$CC -G $CFLAGS -v conftest.$objext 2>&1 | $GREP -v "^Configured with:" | $GREP "\-L"'
+ fi
+
+ hardcode_libdir_flag_spec_CXX='${wl}-R $wl$libdir'
+ case $host_os in
+ solaris2.[0-5] | solaris2.[0-5].*) ;;
+ *)
+ whole_archive_flag_spec_CXX='${wl}-z ${wl}allextract$convenience ${wl}-z ${wl}defaultextract'
+ ;;
+ esac
+ fi
+ ;;
+ esac
+ ;;
+
+ sysv4*uw2* | sysv5OpenUNIX* | sysv5UnixWare7.[01].[10]* | unixware7* | sco3.2v5.0.[024]*)
+ no_undefined_flag_CXX='${wl}-z,text'
+ archive_cmds_need_lc_CXX=no
+ hardcode_shlibpath_var_CXX=no
+ runpath_var='LD_RUN_PATH'
+
+ case $cc_basename in
+ CC*)
+ archive_cmds_CXX='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+ archive_expsym_cmds_CXX='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+ ;;
+ *)
+ archive_cmds_CXX='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+ archive_expsym_cmds_CXX='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+ ;;
+ esac
+ ;;
+
+ sysv5* | sco3.2v5* | sco5v6*)
+ # Note: We can NOT use -z defs as we might desire, because we do not
+ # link with -lc, and that would cause any symbols used from libc to
+ # always be unresolved, which means just about no library would
+ # ever link correctly. If we're not using GNU ld we use -z text
+ # though, which does catch some bad symbols but isn't as heavy-handed
+ # as -z defs.
+ no_undefined_flag_CXX='${wl}-z,text'
+ allow_undefined_flag_CXX='${wl}-z,nodefs'
+ archive_cmds_need_lc_CXX=no
+ hardcode_shlibpath_var_CXX=no
+ hardcode_libdir_flag_spec_CXX='${wl}-R,$libdir'
+ hardcode_libdir_separator_CXX=':'
+ link_all_deplibs_CXX=yes
+ export_dynamic_flag_spec_CXX='${wl}-Bexport'
+ runpath_var='LD_RUN_PATH'
+
+ case $cc_basename in
+ CC*)
+ archive_cmds_CXX='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+ archive_expsym_cmds_CXX='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+ old_archive_cmds_CXX='$CC -Tprelink_objects $oldobjs~
+ '"$old_archive_cmds_CXX"
+ reload_cmds_CXX='$CC -Tprelink_objects $reload_objs~
+ '"$reload_cmds_CXX"
+ ;;
+ *)
+ archive_cmds_CXX='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+ archive_expsym_cmds_CXX='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+ ;;
+ esac
+ ;;
+
+ tandem*)
+ case $cc_basename in
+ NCC*)
+ # NonStop-UX NCC 3.20
+ # FIXME: insert proper C++ library support
+ ld_shlibs_CXX=no
+ ;;
+ *)
+ # FIXME: insert proper C++ library support
+ ld_shlibs_CXX=no
+ ;;
+ esac
+ ;;
+
+ vxworks*)
+ # FIXME: insert proper C++ library support
+ ld_shlibs_CXX=no
+ ;;
+
+ *)
+ # FIXME: insert proper C++ library support
+ ld_shlibs_CXX=no
+ ;;
+ esac
+
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ld_shlibs_CXX" >&5
+$as_echo "$ld_shlibs_CXX" >&6; }
+ test "$ld_shlibs_CXX" = no && can_build_shared=no
+
+ GCC_CXX="$GXX"
+ LD_CXX="$LD"
+
+ ## CAVEAT EMPTOR:
+ ## There is no encapsulation within the following macros, do not change
+ ## the running order or otherwise move them around unless you know exactly
+ ## what you are doing...
+ # Dependencies to place before and after the object being linked:
+predep_objects_CXX=
+postdep_objects_CXX=
+predeps_CXX=
+postdeps_CXX=
+compiler_lib_search_path_CXX=
+
+cat > conftest.$ac_ext <<_LT_EOF
+class Foo
+{
+public:
+ Foo (void) { a = 0; }
+private:
+ int a;
+};
+_LT_EOF
+
+
+_lt_libdeps_save_CFLAGS=$CFLAGS
+case "$CC $CFLAGS " in #(
+*\ -flto*\ *) CFLAGS="$CFLAGS -fno-lto" ;;
+*\ -fwhopr*\ *) CFLAGS="$CFLAGS -fno-whopr" ;;
+*\ -fuse-linker-plugin*\ *) CFLAGS="$CFLAGS -fno-use-linker-plugin" ;;
+esac
+
+if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5
+ (eval $ac_compile) 2>&5
+ ac_status=$?
+ $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+ test $ac_status = 0; }; then
+ # Parse the compiler output and extract the necessary
+ # objects, libraries and library flags.
+
+ # Sentinel used to keep track of whether or not we are before
+ # the conftest object file.
+ pre_test_object_deps_done=no
+
+ for p in `eval "$output_verbose_link_cmd"`; do
+ case ${prev}${p} in
+
+ -L* | -R* | -l*)
+ # Some compilers place space between "-{L,R}" and the path.
+ # Remove the space.
+ if test $p = "-L" ||
+ test $p = "-R"; then
+ prev=$p
+ continue
+ fi
+
+ # Expand the sysroot to ease extracting the directories later.
+ if test -z "$prev"; then
+ case $p in
+ -L*) func_stripname_cnf '-L' '' "$p"; prev=-L; p=$func_stripname_result ;;
+ -R*) func_stripname_cnf '-R' '' "$p"; prev=-R; p=$func_stripname_result ;;
+ -l*) func_stripname_cnf '-l' '' "$p"; prev=-l; p=$func_stripname_result ;;
+ esac
+ fi
+ case $p in
+ =*) func_stripname_cnf '=' '' "$p"; p=$lt_sysroot$func_stripname_result ;;
+ esac
+ if test "$pre_test_object_deps_done" = no; then
+ case ${prev} in
+ -L | -R)
+ # Internal compiler library paths should come after those
+ # provided the user. The postdeps already come after the
+ # user supplied libs so there is no need to process them.
+ if test -z "$compiler_lib_search_path_CXX"; then
+ compiler_lib_search_path_CXX="${prev}${p}"
+ else
+ compiler_lib_search_path_CXX="${compiler_lib_search_path_CXX} ${prev}${p}"
+ fi
+ ;;
+ # The "-l" case would never come before the object being
+ # linked, so don't bother handling this case.
+ esac
+ else
+ if test -z "$postdeps_CXX"; then
+ postdeps_CXX="${prev}${p}"
+ else
+ postdeps_CXX="${postdeps_CXX} ${prev}${p}"
+ fi
+ fi
+ prev=
+ ;;
+
+ *.lto.$objext) ;; # Ignore GCC LTO objects
+ *.$objext)
+ # This assumes that the test object file only shows up
+ # once in the compiler output.
+ if test "$p" = "conftest.$objext"; then
+ pre_test_object_deps_done=yes
+ continue
+ fi
+
+ if test "$pre_test_object_deps_done" = no; then
+ if test -z "$predep_objects_CXX"; then
+ predep_objects_CXX="$p"
+ else
+ predep_objects_CXX="$predep_objects_CXX $p"
+ fi
+ else
+ if test -z "$postdep_objects_CXX"; then
+ postdep_objects_CXX="$p"
+ else
+ postdep_objects_CXX="$postdep_objects_CXX $p"
+ fi
+ fi
+ ;;
+
+ *) ;; # Ignore the rest.
+
+ esac
+ done
+
+ # Clean up.
+ rm -f a.out a.exe
+else
+ echo "libtool.m4: error: problem compiling CXX test program"
+fi
+
+$RM -f confest.$objext
+CFLAGS=$_lt_libdeps_save_CFLAGS
+
+# PORTME: override above test on systems where it is broken
+case $host_os in
+interix[3-9]*)
+ # Interix 3.5 installs completely hosed .la files for C++, so rather than
+ # hack all around it, let's just trust "g++" to DTRT.
+ predep_objects_CXX=
+ postdep_objects_CXX=
+ postdeps_CXX=
+ ;;
+
+linux*)
+ case `$CC -V 2>&1 | sed 5q` in
+ *Sun\ C*)
+ # Sun C++ 5.9
+
+ # The more standards-conforming stlport4 library is
+ # incompatible with the Cstd library. Avoid specifying
+ # it if it's in CXXFLAGS. Ignore libCrun as
+ # -library=stlport4 depends on it.
+ case " $CXX $CXXFLAGS " in
+ *" -library=stlport4 "*)
+ solaris_use_stlport4=yes
+ ;;
+ esac
+
+ if test "$solaris_use_stlport4" != yes; then
+ postdeps_CXX='-library=Cstd -library=Crun'
+ fi
+ ;;
+ esac
+ ;;
+
+solaris*)
+ case $cc_basename in
+ CC* | sunCC*)
+ # The more standards-conforming stlport4 library is
+ # incompatible with the Cstd library. Avoid specifying
+ # it if it's in CXXFLAGS. Ignore libCrun as
+ # -library=stlport4 depends on it.
+ case " $CXX $CXXFLAGS " in
+ *" -library=stlport4 "*)
+ solaris_use_stlport4=yes
+ ;;
+ esac
+
+ # Adding this requires a known-good setup of shared libraries for
+ # Sun compiler versions before 5.6, else PIC objects from an old
+ # archive will be linked into the output, leading to subtle bugs.
+ if test "$solaris_use_stlport4" != yes; then
+ postdeps_CXX='-library=Cstd -library=Crun'
+ fi
+ ;;
+ esac
+ ;;
+esac
+
+
+case " $postdeps_CXX " in
+*" -lc "*) archive_cmds_need_lc_CXX=no ;;
+esac
+ compiler_lib_search_dirs_CXX=
+if test -n "${compiler_lib_search_path_CXX}"; then
+ compiler_lib_search_dirs_CXX=`echo " ${compiler_lib_search_path_CXX}" | ${SED} -e 's! -L! !g' -e 's!^ !!'`
+fi
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ lt_prog_compiler_wl_CXX=
+lt_prog_compiler_pic_CXX=
+lt_prog_compiler_static_CXX=
+
+
+ # C++ specific cases for pic, static, wl, etc.
+ if test "$GXX" = yes; then
+ lt_prog_compiler_wl_CXX='-Wl,'
+ lt_prog_compiler_static_CXX='-static'
+
+ case $host_os in
+ aix*)
+ # All AIX code is PIC.
+ if test "$host_cpu" = ia64; then
+ # AIX 5 now supports IA64 processor
+ lt_prog_compiler_static_CXX='-Bstatic'
+ fi
+ ;;
+
+ amigaos*)
+ case $host_cpu in
+ powerpc)
+ # see comment about AmigaOS4 .so support
+ lt_prog_compiler_pic_CXX='-fPIC'
+ ;;
+ m68k)
+ # FIXME: we need at least 68020 code to build shared libraries, but
+ # adding the `-m68020' flag to GCC prevents building anything better,
+ # like `-m68040'.
+ lt_prog_compiler_pic_CXX='-m68020 -resident32 -malways-restore-a4'
+ ;;
+ esac
+ ;;
+
+ beos* | irix5* | irix6* | nonstopux* | osf3* | osf4* | osf5*)
+ # PIC is the default for these OSes.
+ ;;
+ mingw* | cygwin* | os2* | pw32* | cegcc*)
+ # This hack is so that the source file can tell whether it is being
+ # built for inclusion in a dll (and should export symbols for example).
+ # Although the cygwin gcc ignores -fPIC, still need this for old-style
+ # (--disable-auto-import) libraries
+ lt_prog_compiler_pic_CXX='-DDLL_EXPORT'
+ ;;
+ darwin* | rhapsody*)
+ # PIC is the default on this platform
+ # Common symbols not allowed in MH_DYLIB files
+ lt_prog_compiler_pic_CXX='-fno-common'
+ ;;
+ *djgpp*)
+ # DJGPP does not support shared libraries at all
+ lt_prog_compiler_pic_CXX=
+ ;;
+ haiku*)
+ # PIC is the default for Haiku.
+ # The "-static" flag exists, but is broken.
+ lt_prog_compiler_static_CXX=
+ ;;
+ interix[3-9]*)
+ # Interix 3.x gcc -fpic/-fPIC options generate broken code.
+ # Instead, we relocate shared libraries at runtime.
+ ;;
+ sysv4*MP*)
+ if test -d /usr/nec; then
+ lt_prog_compiler_pic_CXX=-Kconform_pic
+ fi
+ ;;
+ hpux*)
+ # PIC is the default for 64-bit PA HP-UX, but not for 32-bit
+ # PA HP-UX. On IA64 HP-UX, PIC is the default but the pic flag
+ # sets the default TLS model and affects inlining.
+ case $host_cpu in
+ hppa*64*)
+ ;;
+ *)
+ lt_prog_compiler_pic_CXX='-fPIC'
+ ;;
+ esac
+ ;;
+ *qnx* | *nto*)
+ # QNX uses GNU C++, but need to define -shared option too, otherwise
+ # it will coredump.
+ lt_prog_compiler_pic_CXX='-fPIC -shared'
+ ;;
+ *)
+ lt_prog_compiler_pic_CXX='-fPIC'
+ ;;
+ esac
+ else
+ case $host_os in
+ aix[4-9]*)
+ # All AIX code is PIC.
+ if test "$host_cpu" = ia64; then
+ # AIX 5 now supports IA64 processor
+ lt_prog_compiler_static_CXX='-Bstatic'
+ else
+ lt_prog_compiler_static_CXX='-bnso -bI:/lib/syscalls.exp'
+ fi
+ ;;
+ chorus*)
+ case $cc_basename in
+ cxch68*)
+ # Green Hills C++ Compiler
+ # _LT_TAGVAR(lt_prog_compiler_static, CXX)="--no_auto_instantiation -u __main -u __premain -u _abort -r $COOL_DIR/lib/libOrb.a $MVME_DIR/lib/CC/libC.a $MVME_DIR/lib/classix/libcx.s.a"
+ ;;
+ esac
+ ;;
+ mingw* | cygwin* | os2* | pw32* | cegcc*)
+ # This hack is so that the source file can tell whether it is being
+ # built for inclusion in a dll (and should export symbols for example).
+ lt_prog_compiler_pic_CXX='-DDLL_EXPORT'
+ ;;
+ dgux*)
+ case $cc_basename in
+ ec++*)
+ lt_prog_compiler_pic_CXX='-KPIC'
+ ;;
+ ghcx*)
+ # Green Hills C++ Compiler
+ lt_prog_compiler_pic_CXX='-pic'
+ ;;
+ *)
+ ;;
+ esac
+ ;;
+ freebsd* | dragonfly*)
+ # FreeBSD uses GNU C++
+ ;;
+ hpux9* | hpux10* | hpux11*)
+ case $cc_basename in
+ CC*)
+ lt_prog_compiler_wl_CXX='-Wl,'
+ lt_prog_compiler_static_CXX='${wl}-a ${wl}archive'
+ if test "$host_cpu" != ia64; then
+ lt_prog_compiler_pic_CXX='+Z'
+ fi
+ ;;
+ aCC*)
+ lt_prog_compiler_wl_CXX='-Wl,'
+ lt_prog_compiler_static_CXX='${wl}-a ${wl}archive'
+ case $host_cpu in
+ hppa*64*|ia64*)
+ # +Z the default
+ ;;
+ *)
+ lt_prog_compiler_pic_CXX='+Z'
+ ;;
+ esac
+ ;;
+ *)
+ ;;
+ esac
+ ;;
+ interix*)
+ # This is c89, which is MS Visual C++ (no shared libs)
+ # Anyone wants to do a port?
+ ;;
+ irix5* | irix6* | nonstopux*)
+ case $cc_basename in
+ CC*)
+ lt_prog_compiler_wl_CXX='-Wl,'
+ lt_prog_compiler_static_CXX='-non_shared'
+ # CC pic flag -KPIC is the default.
+ ;;
+ *)
+ ;;
+ esac
+ ;;
+ linux* | k*bsd*-gnu | kopensolaris*-gnu)
+ case $cc_basename in
+ KCC*)
+ # KAI C++ Compiler
+ lt_prog_compiler_wl_CXX='--backend -Wl,'
+ lt_prog_compiler_pic_CXX='-fPIC'
+ ;;
+ ecpc* )
+ # old Intel C++ for x86_64 which still supported -KPIC.
+ lt_prog_compiler_wl_CXX='-Wl,'
+ lt_prog_compiler_pic_CXX='-KPIC'
+ lt_prog_compiler_static_CXX='-static'
+ ;;
+ icpc* )
+ # Intel C++, used to be incompatible with GCC.
+ # ICC 10 doesn't accept -KPIC any more.
+ lt_prog_compiler_wl_CXX='-Wl,'
+ lt_prog_compiler_pic_CXX='-fPIC'
+ lt_prog_compiler_static_CXX='-static'
+ ;;
+ pgCC* | pgcpp*)
+ # Portland Group C++ compiler
+ lt_prog_compiler_wl_CXX='-Wl,'
+ lt_prog_compiler_pic_CXX='-fpic'
+ lt_prog_compiler_static_CXX='-Bstatic'
+ ;;
+ cxx*)
+ # Compaq C++
+ # Make sure the PIC flag is empty. It appears that all Alpha
+ # Linux and Compaq Tru64 Unix objects are PIC.
+ lt_prog_compiler_pic_CXX=
+ lt_prog_compiler_static_CXX='-non_shared'
+ ;;
+ xlc* | xlC* | bgxl[cC]* | mpixl[cC]*)
+ # IBM XL 8.0, 9.0 on PPC and BlueGene
+ lt_prog_compiler_wl_CXX='-Wl,'
+ lt_prog_compiler_pic_CXX='-qpic'
+ lt_prog_compiler_static_CXX='-qstaticlink'
+ ;;
+ *)
+ case `$CC -V 2>&1 | sed 5q` in
+ *Sun\ C*)
+ # Sun C++ 5.9
+ lt_prog_compiler_pic_CXX='-KPIC'
+ lt_prog_compiler_static_CXX='-Bstatic'
+ lt_prog_compiler_wl_CXX='-Qoption ld '
+ ;;
+ esac
+ ;;
+ esac
+ ;;
+ lynxos*)
+ ;;
+ m88k*)
+ ;;
+ mvs*)
+ case $cc_basename in
+ cxx*)
+ lt_prog_compiler_pic_CXX='-W c,exportall'
+ ;;
+ *)
+ ;;
+ esac
+ ;;
+ netbsd*)
+ ;;
+ *qnx* | *nto*)
+ # QNX uses GNU C++, but need to define -shared option too, otherwise
+ # it will coredump.
+ lt_prog_compiler_pic_CXX='-fPIC -shared'
+ ;;
+ osf3* | osf4* | osf5*)
+ case $cc_basename in
+ KCC*)
+ lt_prog_compiler_wl_CXX='--backend -Wl,'
+ ;;
+ RCC*)
+ # Rational C++ 2.4.1
+ lt_prog_compiler_pic_CXX='-pic'
+ ;;
+ cxx*)
+ # Digital/Compaq C++
+ lt_prog_compiler_wl_CXX='-Wl,'
+ # Make sure the PIC flag is empty. It appears that all Alpha
+ # Linux and Compaq Tru64 Unix objects are PIC.
+ lt_prog_compiler_pic_CXX=
+ lt_prog_compiler_static_CXX='-non_shared'
+ ;;
+ *)
+ ;;
+ esac
+ ;;
+ psos*)
+ ;;
+ solaris*)
+ case $cc_basename in
+ CC* | sunCC*)
+ # Sun C++ 4.2, 5.x and Centerline C++
+ lt_prog_compiler_pic_CXX='-KPIC'
+ lt_prog_compiler_static_CXX='-Bstatic'
+ lt_prog_compiler_wl_CXX='-Qoption ld '
+ ;;
+ gcx*)
+ # Green Hills C++ Compiler
+ lt_prog_compiler_pic_CXX='-PIC'
+ ;;
+ *)
+ ;;
+ esac
+ ;;
+ sunos4*)
+ case $cc_basename in
+ CC*)
+ # Sun C++ 4.x
+ lt_prog_compiler_pic_CXX='-pic'
+ lt_prog_compiler_static_CXX='-Bstatic'
+ ;;
+ lcc*)
+ # Lucid
+ lt_prog_compiler_pic_CXX='-pic'
+ ;;
+ *)
+ ;;
+ esac
+ ;;
+ sysv5* | unixware* | sco3.2v5* | sco5v6* | OpenUNIX*)
+ case $cc_basename in
+ CC*)
+ lt_prog_compiler_wl_CXX='-Wl,'
+ lt_prog_compiler_pic_CXX='-KPIC'
+ lt_prog_compiler_static_CXX='-Bstatic'
+ ;;
+ esac
+ ;;
+ tandem*)
+ case $cc_basename in
+ NCC*)
+ # NonStop-UX NCC 3.20
+ lt_prog_compiler_pic_CXX='-KPIC'
+ ;;
+ *)
+ ;;
+ esac
+ ;;
+ vxworks*)
+ ;;
+ *)
+ lt_prog_compiler_can_build_shared_CXX=no
+ ;;
+ esac
+ fi
+
+case $host_os in
+ # For platforms which do not support PIC, -DPIC is meaningless:
+ *djgpp*)
+ lt_prog_compiler_pic_CXX=
+ ;;
+ *)
+ lt_prog_compiler_pic_CXX="$lt_prog_compiler_pic_CXX -DPIC"
+ ;;
+esac
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $compiler option to produce PIC" >&5
+$as_echo_n "checking for $compiler option to produce PIC... " >&6; }
+if ${lt_cv_prog_compiler_pic_CXX+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ lt_cv_prog_compiler_pic_CXX=$lt_prog_compiler_pic_CXX
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_pic_CXX" >&5
+$as_echo "$lt_cv_prog_compiler_pic_CXX" >&6; }
+lt_prog_compiler_pic_CXX=$lt_cv_prog_compiler_pic_CXX
+
+#
+# Check to make sure the PIC flag actually works.
+#
+if test -n "$lt_prog_compiler_pic_CXX"; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $compiler PIC flag $lt_prog_compiler_pic_CXX works" >&5
+$as_echo_n "checking if $compiler PIC flag $lt_prog_compiler_pic_CXX works... " >&6; }
+if ${lt_cv_prog_compiler_pic_works_CXX+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ lt_cv_prog_compiler_pic_works_CXX=no
+ ac_outfile=conftest.$ac_objext
+ echo "$lt_simple_compile_test_code" > conftest.$ac_ext
+ lt_compiler_flag="$lt_prog_compiler_pic_CXX -DPIC"
+ # Insert the option either (1) after the last *FLAGS variable, or
+ # (2) before a word containing "conftest.", or (3) at the end.
+ # Note that $ac_compile itself does not contain backslashes and begins
+ # with a dollar sign (not a hyphen), so the echo should work correctly.
+ # The option is referenced via a variable to avoid confusing sed.
+ lt_compile=`echo "$ac_compile" | $SED \
+ -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
+ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
+ -e 's:$: $lt_compiler_flag:'`
+ (eval echo "\"\$as_me:$LINENO: $lt_compile\"" >&5)
+ (eval "$lt_compile" 2>conftest.err)
+ ac_status=$?
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ if (exit $ac_status) && test -s "$ac_outfile"; then
+ # The compiler can only warn and ignore the option if not recognized
+ # So say no if there are warnings other than the usual output.
+ $ECHO "$_lt_compiler_boilerplate" | $SED '/^$/d' >conftest.exp
+ $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2
+ if test ! -s conftest.er2 || diff conftest.exp conftest.er2 >/dev/null; then
+ lt_cv_prog_compiler_pic_works_CXX=yes
+ fi
+ fi
+ $RM conftest*
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_pic_works_CXX" >&5
+$as_echo "$lt_cv_prog_compiler_pic_works_CXX" >&6; }
+
+if test x"$lt_cv_prog_compiler_pic_works_CXX" = xyes; then
+ case $lt_prog_compiler_pic_CXX in
+ "" | " "*) ;;
+ *) lt_prog_compiler_pic_CXX=" $lt_prog_compiler_pic_CXX" ;;
+ esac
+else
+ lt_prog_compiler_pic_CXX=
+ lt_prog_compiler_can_build_shared_CXX=no
+fi
+
+fi
+
+
+
+
+
+#
+# Check to make sure the static flag actually works.
+#
+wl=$lt_prog_compiler_wl_CXX eval lt_tmp_static_flag=\"$lt_prog_compiler_static_CXX\"
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if $compiler static flag $lt_tmp_static_flag works" >&5
+$as_echo_n "checking if $compiler static flag $lt_tmp_static_flag works... " >&6; }
+if ${lt_cv_prog_compiler_static_works_CXX+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ lt_cv_prog_compiler_static_works_CXX=no
+ save_LDFLAGS="$LDFLAGS"
+ LDFLAGS="$LDFLAGS $lt_tmp_static_flag"
+ echo "$lt_simple_link_test_code" > conftest.$ac_ext
+ if (eval $ac_link 2>conftest.err) && test -s conftest$ac_exeext; then
+ # The linker can only warn and ignore the option if not recognized
+ # So say no if there are warnings
+ if test -s conftest.err; then
+ # Append any errors to the config.log.
+ cat conftest.err 1>&5
+ $ECHO "$_lt_linker_boilerplate" | $SED '/^$/d' > conftest.exp
+ $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2
+ if diff conftest.exp conftest.er2 >/dev/null; then
+ lt_cv_prog_compiler_static_works_CXX=yes
+ fi
+ else
+ lt_cv_prog_compiler_static_works_CXX=yes
+ fi
+ fi
+ $RM -r conftest*
+ LDFLAGS="$save_LDFLAGS"
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_static_works_CXX" >&5
+$as_echo "$lt_cv_prog_compiler_static_works_CXX" >&6; }
+
+if test x"$lt_cv_prog_compiler_static_works_CXX" = xyes; then
+ :
+else
+ lt_prog_compiler_static_CXX=
+fi
+
+
+
+
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $compiler supports -c -o file.$ac_objext" >&5
+$as_echo_n "checking if $compiler supports -c -o file.$ac_objext... " >&6; }
+if ${lt_cv_prog_compiler_c_o_CXX+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ lt_cv_prog_compiler_c_o_CXX=no
+ $RM -r conftest 2>/dev/null
+ mkdir conftest
+ cd conftest
+ mkdir out
+ echo "$lt_simple_compile_test_code" > conftest.$ac_ext
+
+ lt_compiler_flag="-o out/conftest2.$ac_objext"
+ # Insert the option either (1) after the last *FLAGS variable, or
+ # (2) before a word containing "conftest.", or (3) at the end.
+ # Note that $ac_compile itself does not contain backslashes and begins
+ # with a dollar sign (not a hyphen), so the echo should work correctly.
+ lt_compile=`echo "$ac_compile" | $SED \
+ -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
+ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
+ -e 's:$: $lt_compiler_flag:'`
+ (eval echo "\"\$as_me:$LINENO: $lt_compile\"" >&5)
+ (eval "$lt_compile" 2>out/conftest.err)
+ ac_status=$?
+ cat out/conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ if (exit $ac_status) && test -s out/conftest2.$ac_objext
+ then
+ # The compiler can only warn and ignore the option if not recognized
+ # So say no if there are warnings
+ $ECHO "$_lt_compiler_boilerplate" | $SED '/^$/d' > out/conftest.exp
+ $SED '/^$/d; /^ *+/d' out/conftest.err >out/conftest.er2
+ if test ! -s out/conftest.er2 || diff out/conftest.exp out/conftest.er2 >/dev/null; then
+ lt_cv_prog_compiler_c_o_CXX=yes
+ fi
+ fi
+ chmod u+w . 2>&5
+ $RM conftest*
+ # SGI C++ compiler will create directory out/ii_files/ for
+ # template instantiation
+ test -d out/ii_files && $RM out/ii_files/* && rmdir out/ii_files
+ $RM out/* && rmdir out
+ cd ..
+ $RM -r conftest
+ $RM conftest*
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_c_o_CXX" >&5
+$as_echo "$lt_cv_prog_compiler_c_o_CXX" >&6; }
+
+
+
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $compiler supports -c -o file.$ac_objext" >&5
+$as_echo_n "checking if $compiler supports -c -o file.$ac_objext... " >&6; }
+if ${lt_cv_prog_compiler_c_o_CXX+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ lt_cv_prog_compiler_c_o_CXX=no
+ $RM -r conftest 2>/dev/null
+ mkdir conftest
+ cd conftest
+ mkdir out
+ echo "$lt_simple_compile_test_code" > conftest.$ac_ext
+
+ lt_compiler_flag="-o out/conftest2.$ac_objext"
+ # Insert the option either (1) after the last *FLAGS variable, or
+ # (2) before a word containing "conftest.", or (3) at the end.
+ # Note that $ac_compile itself does not contain backslashes and begins
+ # with a dollar sign (not a hyphen), so the echo should work correctly.
+ lt_compile=`echo "$ac_compile" | $SED \
+ -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
+ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
+ -e 's:$: $lt_compiler_flag:'`
+ (eval echo "\"\$as_me:$LINENO: $lt_compile\"" >&5)
+ (eval "$lt_compile" 2>out/conftest.err)
+ ac_status=$?
+ cat out/conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ if (exit $ac_status) && test -s out/conftest2.$ac_objext
+ then
+ # The compiler can only warn and ignore the option if not recognized
+ # So say no if there are warnings
+ $ECHO "$_lt_compiler_boilerplate" | $SED '/^$/d' > out/conftest.exp
+ $SED '/^$/d; /^ *+/d' out/conftest.err >out/conftest.er2
+ if test ! -s out/conftest.er2 || diff out/conftest.exp out/conftest.er2 >/dev/null; then
+ lt_cv_prog_compiler_c_o_CXX=yes
+ fi
+ fi
+ chmod u+w . 2>&5
+ $RM conftest*
+ # SGI C++ compiler will create directory out/ii_files/ for
+ # template instantiation
+ test -d out/ii_files && $RM out/ii_files/* && rmdir out/ii_files
+ $RM out/* && rmdir out
+ cd ..
+ $RM -r conftest
+ $RM conftest*
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_c_o_CXX" >&5
+$as_echo "$lt_cv_prog_compiler_c_o_CXX" >&6; }
+
+
+
+
+hard_links="nottested"
+if test "$lt_cv_prog_compiler_c_o_CXX" = no && test "$need_locks" != no; then
+ # do not overwrite the value of need_locks provided by the user
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking if we can lock with hard links" >&5
+$as_echo_n "checking if we can lock with hard links... " >&6; }
+ hard_links=yes
+ $RM conftest*
+ ln conftest.a conftest.b 2>/dev/null && hard_links=no
+ touch conftest.a
+ ln conftest.a conftest.b 2>&5 || hard_links=no
+ ln conftest.a conftest.b 2>/dev/null && hard_links=no
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $hard_links" >&5
+$as_echo "$hard_links" >&6; }
+ if test "$hard_links" = no; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: \`$CC' does not support \`-c -o', so \`make -j' may be unsafe" >&5
+$as_echo "$as_me: WARNING: \`$CC' does not support \`-c -o', so \`make -j' may be unsafe" >&2;}
+ need_locks=warn
+ fi
+else
+ need_locks=no
+fi
+
+
+
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the $compiler linker ($LD) supports shared libraries" >&5
+$as_echo_n "checking whether the $compiler linker ($LD) supports shared libraries... " >&6; }
+
+ export_symbols_cmds_CXX='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols'
+ exclude_expsyms_CXX='_GLOBAL_OFFSET_TABLE_|_GLOBAL__F[ID]_.*'
+ case $host_os in
+ aix[4-9]*)
+ # If we're using GNU nm, then we don't want the "-C" option.
+ # -C means demangle to AIX nm, but means don't demangle with GNU nm
+ # Also, AIX nm treats weak defined symbols like other global defined
+ # symbols, whereas GNU nm marks them as "W".
+ if $NM -V 2>&1 | $GREP 'GNU' > /dev/null; then
+ export_symbols_cmds_CXX='$NM -Bpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B") || (\$ 2 == "W")) && (substr(\$ 3,1,1) != ".")) { print \$ 3 } }'\'' | sort -u > $export_symbols'
+ else
+ export_symbols_cmds_CXX='$NM -BCpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B")) && (substr(\$ 3,1,1) != ".")) { print \$ 3 } }'\'' | sort -u > $export_symbols'
+ fi
+ ;;
+ pw32*)
+ export_symbols_cmds_CXX="$ltdll_cmds"
+ ;;
+ cygwin* | mingw* | cegcc*)
+ case $cc_basename in
+ cl*)
+ exclude_expsyms_CXX='_NULL_IMPORT_DESCRIPTOR|_IMPORT_DESCRIPTOR_.*'
+ ;;
+ *)
+ export_symbols_cmds_CXX='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[BCDGRS][ ]/s/.*[ ]\([^ ]*\)/\1 DATA/;s/^.*[ ]__nm__\([^ ]*\)[ ][^ ]*/\1 DATA/;/^I[ ]/d;/^[AITW][ ]/s/.* //'\'' | sort | uniq > $export_symbols'
+ exclude_expsyms_CXX='[_]+GLOBAL_OFFSET_TABLE_|[_]+GLOBAL__[FID]_.*|[_]+head_[A-Za-z0-9_]+_dll|[A-Za-z0-9_]+_dll_iname'
+ ;;
+ esac
+ ;;
+ *)
+ export_symbols_cmds_CXX='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols'
+ ;;
+ esac
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ld_shlibs_CXX" >&5
+$as_echo "$ld_shlibs_CXX" >&6; }
+test "$ld_shlibs_CXX" = no && can_build_shared=no
+
+with_gnu_ld_CXX=$with_gnu_ld
+
+
+
+
+
+
+#
+# Do we need to explicitly link libc?
+#
+case "x$archive_cmds_need_lc_CXX" in
+x|xyes)
+ # Assume -lc should be added
+ archive_cmds_need_lc_CXX=yes
+
+ if test "$enable_shared" = yes && test "$GCC" = yes; then
+ case $archive_cmds_CXX in
+ *'~'*)
+ # FIXME: we may have to deal with multi-command sequences.
+ ;;
+ '$CC '*)
+ # Test whether the compiler implicitly links with -lc since on some
+ # systems, -lgcc has to come before -lc. If gcc already passes -lc
+ # to ld, don't add -lc before -lgcc.
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether -lc should be explicitly linked in" >&5
+$as_echo_n "checking whether -lc should be explicitly linked in... " >&6; }
+if ${lt_cv_archive_cmds_need_lc_CXX+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ $RM conftest*
+ echo "$lt_simple_compile_test_code" > conftest.$ac_ext
+
+ if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5
+ (eval $ac_compile) 2>&5
+ ac_status=$?
+ $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+ test $ac_status = 0; } 2>conftest.err; then
+ soname=conftest
+ lib=conftest
+ libobjs=conftest.$ac_objext
+ deplibs=
+ wl=$lt_prog_compiler_wl_CXX
+ pic_flag=$lt_prog_compiler_pic_CXX
+ compiler_flags=-v
+ linker_flags=-v
+ verstring=
+ output_objdir=.
+ libname=conftest
+ lt_save_allow_undefined_flag=$allow_undefined_flag_CXX
+ allow_undefined_flag_CXX=
+ if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$archive_cmds_CXX 2\>\&1 \| $GREP \" -lc \" \>/dev/null 2\>\&1\""; } >&5
+ (eval $archive_cmds_CXX 2\>\&1 \| $GREP \" -lc \" \>/dev/null 2\>\&1) 2>&5
+ ac_status=$?
+ $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+ test $ac_status = 0; }
+ then
+ lt_cv_archive_cmds_need_lc_CXX=no
+ else
+ lt_cv_archive_cmds_need_lc_CXX=yes
+ fi
+ allow_undefined_flag_CXX=$lt_save_allow_undefined_flag
+ else
+ cat conftest.err 1>&5
+ fi
+ $RM conftest*
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_archive_cmds_need_lc_CXX" >&5
+$as_echo "$lt_cv_archive_cmds_need_lc_CXX" >&6; }
+ archive_cmds_need_lc_CXX=$lt_cv_archive_cmds_need_lc_CXX
+ ;;
+ esac
+ fi
+ ;;
+esac
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking dynamic linker characteristics" >&5
+$as_echo_n "checking dynamic linker characteristics... " >&6; }
+
+library_names_spec=
+libname_spec='lib$name'
+soname_spec=
+shrext_cmds=".so"
+postinstall_cmds=
+postuninstall_cmds=
+finish_cmds=
+finish_eval=
+shlibpath_var=
+shlibpath_overrides_runpath=unknown
+version_type=none
+dynamic_linker="$host_os ld.so"
+sys_lib_dlsearch_path_spec="/lib /usr/lib"
+need_lib_prefix=unknown
+hardcode_into_libs=no
+
+# when you set need_version to no, make sure it does not cause -set_version
+# flags to be left without arguments
+need_version=unknown
+
+case $host_os in
+aix3*)
+ version_type=linux # correct to gnu/linux during the next big refactor
+ library_names_spec='${libname}${release}${shared_ext}$versuffix $libname.a'
+ shlibpath_var=LIBPATH
+
+ # AIX 3 has no versioning support, so we append a major version to the name.
+ soname_spec='${libname}${release}${shared_ext}$major'
+ ;;
+
+aix[4-9]*)
+ version_type=linux # correct to gnu/linux during the next big refactor
+ need_lib_prefix=no
+ need_version=no
+ hardcode_into_libs=yes
+ if test "$host_cpu" = ia64; then
+ # AIX 5 supports IA64
+ library_names_spec='${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext}$versuffix $libname${shared_ext}'
+ shlibpath_var=LD_LIBRARY_PATH
+ else
+ # With GCC up to 2.95.x, collect2 would create an import file
+ # for dependence libraries. The import file would start with
+ # the line `#! .'. This would cause the generated library to
+ # depend on `.', always an invalid library. This was fixed in
+ # development snapshots of GCC prior to 3.0.
+ case $host_os in
+ aix4 | aix4.[01] | aix4.[01].*)
+ if { echo '#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 97)'
+ echo ' yes '
+ echo '#endif'; } | ${CC} -E - | $GREP yes > /dev/null; then
+ :
+ else
+ can_build_shared=no
+ fi
+ ;;
+ esac
+ # AIX (on Power*) has no versioning support, so currently we can not hardcode correct
+ # soname into executable. Probably we can add versioning support to
+ # collect2, so additional links can be useful in future.
+ if test "$aix_use_runtimelinking" = yes; then
+ # If using run time linking (on AIX 4.2 or later) use lib<name>.so
+ # instead of lib<name>.a to let people know that these are not
+ # typical AIX shared libraries.
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+ else
+ # We preserve .a as extension for shared libraries through AIX4.2
+ # and later when we are not doing run time linking.
+ library_names_spec='${libname}${release}.a $libname.a'
+ soname_spec='${libname}${release}${shared_ext}$major'
+ fi
+ shlibpath_var=LIBPATH
+ fi
+ ;;
+
+amigaos*)
+ case $host_cpu in
+ powerpc)
+ # Since July 2007 AmigaOS4 officially supports .so libraries.
+ # When compiling the executable, add -use-dynld -Lsobjs: to the compileline.
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+ ;;
+ m68k)
+ library_names_spec='$libname.ixlibrary $libname.a'
+ # Create ${libname}_ixlibrary.a entries in /sys/libs.
+ finish_eval='for lib in `ls $libdir/*.ixlibrary 2>/dev/null`; do libname=`func_echo_all "$lib" | $SED '\''s%^.*/\([^/]*\)\.ixlibrary$%\1%'\''`; test $RM /sys/libs/${libname}_ixlibrary.a; $show "cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a"; cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a || exit 1; done'
+ ;;
+ esac
+ ;;
+
+beos*)
+ library_names_spec='${libname}${shared_ext}'
+ dynamic_linker="$host_os ld.so"
+ shlibpath_var=LIBRARY_PATH
+ ;;
+
+bsdi[45]*)
+ version_type=linux # correct to gnu/linux during the next big refactor
+ need_version=no
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+ soname_spec='${libname}${release}${shared_ext}$major'
+ finish_cmds='PATH="\$PATH:/sbin" ldconfig $libdir'
+ shlibpath_var=LD_LIBRARY_PATH
+ sys_lib_search_path_spec="/shlib /usr/lib /usr/X11/lib /usr/contrib/lib /lib /usr/local/lib"
+ sys_lib_dlsearch_path_spec="/shlib /usr/lib /usr/local/lib"
+ # the default ld.so.conf also contains /usr/contrib/lib and
+ # /usr/X11R6/lib (/usr/X11 is a link to /usr/X11R6), but let us allow
+ # libtool to hard-code these into programs
+ ;;
+
+cygwin* | mingw* | pw32* | cegcc*)
+ version_type=windows
+ shrext_cmds=".dll"
+ need_version=no
+ need_lib_prefix=no
+
+ case $GCC,$cc_basename in
+ yes,*)
+ # gcc
+ library_names_spec='$libname.dll.a'
+ # DLL is installed to $(libdir)/../bin by postinstall_cmds
+ postinstall_cmds='base_file=`basename \${file}`~
+ dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\${base_file}'\''i; echo \$dlname'\''`~
+ dldir=$destdir/`dirname \$dlpath`~
+ test -d \$dldir || mkdir -p \$dldir~
+ $install_prog $dir/$dlname \$dldir/$dlname~
+ chmod a+x \$dldir/$dlname~
+ if test -n '\''$stripme'\'' && test -n '\''$striplib'\''; then
+ eval '\''$striplib \$dldir/$dlname'\'' || exit \$?;
+ fi'
+ postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; echo \$dlname'\''`~
+ dlpath=$dir/\$dldll~
+ $RM \$dlpath'
+ shlibpath_overrides_runpath=yes
+
+ case $host_os in
+ cygwin*)
+ # Cygwin DLLs use 'cyg' prefix rather than 'lib'
+ soname_spec='`echo ${libname} | sed -e 's/^lib/cyg/'``echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}'
+
+ ;;
+ mingw* | cegcc*)
+ # MinGW DLLs use traditional 'lib' prefix
+ soname_spec='${libname}`echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}'
+ ;;
+ pw32*)
+ # pw32 DLLs use 'pw' prefix rather than 'lib'
+ library_names_spec='`echo ${libname} | sed -e 's/^lib/pw/'``echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}'
+ ;;
+ esac
+ dynamic_linker='Win32 ld.exe'
+ ;;
+
+ *,cl*)
+ # Native MSVC
+ libname_spec='$name'
+ soname_spec='${libname}`echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}'
+ library_names_spec='${libname}.dll.lib'
+
+ case $build_os in
+ mingw*)
+ sys_lib_search_path_spec=
+ lt_save_ifs=$IFS
+ IFS=';'
+ for lt_path in $LIB
+ do
+ IFS=$lt_save_ifs
+ # Let DOS variable expansion print the short 8.3 style file name.
+ lt_path=`cd "$lt_path" 2>/dev/null && cmd //C "for %i in (".") do @echo %~si"`
+ sys_lib_search_path_spec="$sys_lib_search_path_spec $lt_path"
+ done
+ IFS=$lt_save_ifs
+ # Convert to MSYS style.
+ sys_lib_search_path_spec=`$ECHO "$sys_lib_search_path_spec" | sed -e 's|\\\\|/|g' -e 's| \\([a-zA-Z]\\):| /\\1|g' -e 's|^ ||'`
+ ;;
+ cygwin*)
+ # Convert to unix form, then to dos form, then back to unix form
+ # but this time dos style (no spaces!) so that the unix form looks
+ # like /cygdrive/c/PROGRA~1:/cygdr...
+ sys_lib_search_path_spec=`cygpath --path --unix "$LIB"`
+ sys_lib_search_path_spec=`cygpath --path --dos "$sys_lib_search_path_spec" 2>/dev/null`
+ sys_lib_search_path_spec=`cygpath --path --unix "$sys_lib_search_path_spec" | $SED -e "s/$PATH_SEPARATOR/ /g"`
+ ;;
+ *)
+ sys_lib_search_path_spec="$LIB"
+ if $ECHO "$sys_lib_search_path_spec" | $GREP ';[c-zC-Z]:/' >/dev/null; then
+ # It is most probably a Windows format PATH.
+ sys_lib_search_path_spec=`$ECHO "$sys_lib_search_path_spec" | $SED -e 's/;/ /g'`
+ else
+ sys_lib_search_path_spec=`$ECHO "$sys_lib_search_path_spec" | $SED -e "s/$PATH_SEPARATOR/ /g"`
+ fi
+ # FIXME: find the short name or the path components, as spaces are
+ # common. (e.g. "Program Files" -> "PROGRA~1")
+ ;;
+ esac
+
+ # DLL is installed to $(libdir)/../bin by postinstall_cmds
+ postinstall_cmds='base_file=`basename \${file}`~
+ dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\${base_file}'\''i; echo \$dlname'\''`~
+ dldir=$destdir/`dirname \$dlpath`~
+ test -d \$dldir || mkdir -p \$dldir~
+ $install_prog $dir/$dlname \$dldir/$dlname'
+ postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; echo \$dlname'\''`~
+ dlpath=$dir/\$dldll~
+ $RM \$dlpath'
+ shlibpath_overrides_runpath=yes
+ dynamic_linker='Win32 link.exe'
+ ;;
+
+ *)
+ # Assume MSVC wrapper
+ library_names_spec='${libname}`echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext} $libname.lib'
+ dynamic_linker='Win32 ld.exe'
+ ;;
+ esac
+ # FIXME: first we should search . and the directory the executable is in
+ shlibpath_var=PATH
+ ;;
+
+darwin* | rhapsody*)
+ dynamic_linker="$host_os dyld"
+ version_type=darwin
+ need_lib_prefix=no
+ need_version=no
+ library_names_spec='${libname}${release}${major}$shared_ext ${libname}$shared_ext'
+ soname_spec='${libname}${release}${major}$shared_ext'
+ shlibpath_overrides_runpath=yes
+ shlibpath_var=DYLD_LIBRARY_PATH
+ shrext_cmds='`test .$module = .yes && echo .so || echo .dylib`'
+
+ sys_lib_dlsearch_path_spec='/usr/local/lib /lib /usr/lib'
+ ;;
+
+dgux*)
+ version_type=linux # correct to gnu/linux during the next big refactor
+ need_lib_prefix=no
+ need_version=no
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname$shared_ext'
+ soname_spec='${libname}${release}${shared_ext}$major'
+ shlibpath_var=LD_LIBRARY_PATH
+ ;;
+
+freebsd* | dragonfly*)
+ # DragonFly does not have aout. When/if they implement a new
+ # versioning mechanism, adjust this.
+ if test -x /usr/bin/objformat; then
+ objformat=`/usr/bin/objformat`
+ else
+ case $host_os in
+ freebsd[23].*) objformat=aout ;;
+ *) objformat=elf ;;
+ esac
+ fi
+ version_type=freebsd-$objformat
+ case $version_type in
+ freebsd-elf*)
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}'
+ need_version=no
+ need_lib_prefix=no
+ ;;
+ freebsd-*)
+ library_names_spec='${libname}${release}${shared_ext}$versuffix $libname${shared_ext}$versuffix'
+ need_version=yes
+ ;;
+ esac
+ shlibpath_var=LD_LIBRARY_PATH
+ case $host_os in
+ freebsd2.*)
+ shlibpath_overrides_runpath=yes
+ ;;
+ freebsd3.[01]* | freebsdelf3.[01]*)
+ shlibpath_overrides_runpath=yes
+ hardcode_into_libs=yes
+ ;;
+ freebsd3.[2-9]* | freebsdelf3.[2-9]* | \
+ freebsd4.[0-5] | freebsdelf4.[0-5] | freebsd4.1.1 | freebsdelf4.1.1)
+ shlibpath_overrides_runpath=no
+ hardcode_into_libs=yes
+ ;;
+ *) # from 4.6 on, and DragonFly
+ shlibpath_overrides_runpath=yes
+ hardcode_into_libs=yes
+ ;;
+ esac
+ ;;
+
+gnu*)
+ version_type=linux # correct to gnu/linux during the next big refactor
+ need_lib_prefix=no
+ need_version=no
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}${major} ${libname}${shared_ext}'
+ soname_spec='${libname}${release}${shared_ext}$major'
+ shlibpath_var=LD_LIBRARY_PATH
+ shlibpath_overrides_runpath=no
+ hardcode_into_libs=yes
+ ;;
+
+haiku*)
+ version_type=linux # correct to gnu/linux during the next big refactor
+ need_lib_prefix=no
+ need_version=no
+ dynamic_linker="$host_os runtime_loader"
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}${major} ${libname}${shared_ext}'
+ soname_spec='${libname}${release}${shared_ext}$major'
+ shlibpath_var=LIBRARY_PATH
+ shlibpath_overrides_runpath=yes
+ sys_lib_dlsearch_path_spec='/boot/home/config/lib /boot/common/lib /boot/system/lib'
+ hardcode_into_libs=yes
+ ;;
+
+hpux9* | hpux10* | hpux11*)
+ # Give a soname corresponding to the major version so that dld.sl refuses to
+ # link against other versions.
+ version_type=sunos
+ need_lib_prefix=no
+ need_version=no
+ case $host_cpu in
+ ia64*)
+ shrext_cmds='.so'
+ hardcode_into_libs=yes
+ dynamic_linker="$host_os dld.so"
+ shlibpath_var=LD_LIBRARY_PATH
+ shlibpath_overrides_runpath=yes # Unless +noenvvar is specified.
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+ soname_spec='${libname}${release}${shared_ext}$major'
+ if test "X$HPUX_IA64_MODE" = X32; then
+ sys_lib_search_path_spec="/usr/lib/hpux32 /usr/local/lib/hpux32 /usr/local/lib"
+ else
+ sys_lib_search_path_spec="/usr/lib/hpux64 /usr/local/lib/hpux64"
+ fi
+ sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec
+ ;;
+ hppa*64*)
+ shrext_cmds='.sl'
+ hardcode_into_libs=yes
+ dynamic_linker="$host_os dld.sl"
+ shlibpath_var=LD_LIBRARY_PATH # How should we handle SHLIB_PATH
+ shlibpath_overrides_runpath=yes # Unless +noenvvar is specified.
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+ soname_spec='${libname}${release}${shared_ext}$major'
+ sys_lib_search_path_spec="/usr/lib/pa20_64 /usr/ccs/lib/pa20_64"
+ sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec
+ ;;
+ *)
+ shrext_cmds='.sl'
+ dynamic_linker="$host_os dld.sl"
+ shlibpath_var=SHLIB_PATH
+ shlibpath_overrides_runpath=no # +s is required to enable SHLIB_PATH
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+ soname_spec='${libname}${release}${shared_ext}$major'
+ ;;
+ esac
+ # HP-UX runs *really* slowly unless shared libraries are mode 555, ...
+ postinstall_cmds='chmod 555 $lib'
+ # or fails outright, so override atomically:
+ install_override_mode=555
+ ;;
+
+interix[3-9]*)
+ version_type=linux # correct to gnu/linux during the next big refactor
+ need_lib_prefix=no
+ need_version=no
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}'
+ soname_spec='${libname}${release}${shared_ext}$major'
+ dynamic_linker='Interix 3.x ld.so.1 (PE, like ELF)'
+ shlibpath_var=LD_LIBRARY_PATH
+ shlibpath_overrides_runpath=no
+ hardcode_into_libs=yes
+ ;;
+
+irix5* | irix6* | nonstopux*)
+ case $host_os in
+ nonstopux*) version_type=nonstopux ;;
+ *)
+ if test "$lt_cv_prog_gnu_ld" = yes; then
+ version_type=linux # correct to gnu/linux during the next big refactor
+ else
+ version_type=irix
+ fi ;;
+ esac
+ need_lib_prefix=no
+ need_version=no
+ soname_spec='${libname}${release}${shared_ext}$major'
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext} $libname${shared_ext}'
+ case $host_os in
+ irix5* | nonstopux*)
+ libsuff= shlibsuff=
+ ;;
+ *)
+ case $LD in # libtool.m4 will add one of these switches to LD
+ *-32|*"-32 "|*-melf32bsmip|*"-melf32bsmip ")
+ libsuff= shlibsuff= libmagic=32-bit;;
+ *-n32|*"-n32 "|*-melf32bmipn32|*"-melf32bmipn32 ")
+ libsuff=32 shlibsuff=N32 libmagic=N32;;
+ *-64|*"-64 "|*-melf64bmip|*"-melf64bmip ")
+ libsuff=64 shlibsuff=64 libmagic=64-bit;;
+ *) libsuff= shlibsuff= libmagic=never-match;;
+ esac
+ ;;
+ esac
+ shlibpath_var=LD_LIBRARY${shlibsuff}_PATH
+ shlibpath_overrides_runpath=no
+ sys_lib_search_path_spec="/usr/lib${libsuff} /lib${libsuff} /usr/local/lib${libsuff}"
+ sys_lib_dlsearch_path_spec="/usr/lib${libsuff} /lib${libsuff}"
+ hardcode_into_libs=yes
+ ;;
+
+# No shared lib support for Linux oldld, aout, or coff.
+linux*oldld* | linux*aout* | linux*coff*)
+ dynamic_linker=no
+ ;;
+
+# This must be glibc/ELF.
+linux* | k*bsd*-gnu | kopensolaris*-gnu)
+ version_type=linux # correct to gnu/linux during the next big refactor
+ need_lib_prefix=no
+ need_version=no
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+ soname_spec='${libname}${release}${shared_ext}$major'
+ finish_cmds='PATH="\$PATH:/sbin" ldconfig -n $libdir'
+ shlibpath_var=LD_LIBRARY_PATH
+ shlibpath_overrides_runpath=no
+
+ # Some binutils ld are patched to set DT_RUNPATH
+ if ${lt_cv_shlibpath_overrides_runpath+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ lt_cv_shlibpath_overrides_runpath=no
+ save_LDFLAGS=$LDFLAGS
+ save_libdir=$libdir
+ eval "libdir=/foo; wl=\"$lt_prog_compiler_wl_CXX\"; \
+ LDFLAGS=\"\$LDFLAGS $hardcode_libdir_flag_spec_CXX\""
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+
+int
+main ()
+{
+
+ ;
+ return 0;
+}
+_ACEOF
+if ac_fn_cxx_try_link "$LINENO"; then :
+ if ($OBJDUMP -p conftest$ac_exeext) 2>/dev/null | grep "RUNPATH.*$libdir" >/dev/null; then :
+ lt_cv_shlibpath_overrides_runpath=yes
+fi
+fi
+rm -f core conftest.err conftest.$ac_objext \
+ conftest$ac_exeext conftest.$ac_ext
+ LDFLAGS=$save_LDFLAGS
+ libdir=$save_libdir
+
+fi
+
+ shlibpath_overrides_runpath=$lt_cv_shlibpath_overrides_runpath
+
+ # This implies no fast_install, which is unacceptable.
+ # Some rework will be needed to allow for fast_install
+ # before this can be enabled.
+ hardcode_into_libs=yes
+
+ # Add ABI-specific directories to the system library path.
+ sys_lib_dlsearch_path_spec="/lib64 /usr/lib64 /lib /usr/lib"
+
+ # Append ld.so.conf contents to the search path
+ if test -f /etc/ld.so.conf; then
+ lt_ld_extra=`awk '/^include / { system(sprintf("cd /etc; cat %s 2>/dev/null", \$2)); skip = 1; } { if (!skip) print \$0; skip = 0; }' < /etc/ld.so.conf | $SED -e 's/#.*//;/^[ ]*hwcap[ ]/d;s/[:, ]/ /g;s/=[^=]*$//;s/=[^= ]* / /g;s/"//g;/^$/d' | tr '\n' ' '`
+ sys_lib_dlsearch_path_spec="$sys_lib_dlsearch_path_spec $lt_ld_extra"
+
+ fi
+
+ # We used to test for /lib/ld.so.1 and disable shared libraries on
+ # powerpc, because MkLinux only supported shared libraries with the
+ # GNU dynamic linker. Since this was broken with cross compilers,
+ # most powerpc-linux boxes support dynamic linking these days and
+ # people can always --disable-shared, the test was removed, and we
+ # assume the GNU/Linux dynamic linker is in use.
+ dynamic_linker='GNU/Linux ld.so'
+ ;;
+
+netbsd*)
+ version_type=sunos
+ need_lib_prefix=no
+ need_version=no
+ if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix'
+ finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir'
+ dynamic_linker='NetBSD (a.out) ld.so'
+ else
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}'
+ soname_spec='${libname}${release}${shared_ext}$major'
+ dynamic_linker='NetBSD ld.elf_so'
+ fi
+ shlibpath_var=LD_LIBRARY_PATH
+ shlibpath_overrides_runpath=yes
+ hardcode_into_libs=yes
+ ;;
+
+newsos6)
+ version_type=linux # correct to gnu/linux during the next big refactor
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+ shlibpath_var=LD_LIBRARY_PATH
+ shlibpath_overrides_runpath=yes
+ ;;
+
+*nto* | *qnx*)
+ version_type=qnx
+ need_lib_prefix=no
+ need_version=no
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+ soname_spec='${libname}${release}${shared_ext}$major'
+ shlibpath_var=LD_LIBRARY_PATH
+ shlibpath_overrides_runpath=no
+ hardcode_into_libs=yes
+ dynamic_linker='ldqnx.so'
+ ;;
+
+openbsd*)
+ version_type=sunos
+ sys_lib_dlsearch_path_spec="/usr/lib"
+ need_lib_prefix=no
+ # Some older versions of OpenBSD (3.3 at least) *do* need versioned libs.
+ case $host_os in
+ openbsd3.3 | openbsd3.3.*) need_version=yes ;;
+ *) need_version=no ;;
+ esac
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix'
+ finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir'
+ shlibpath_var=LD_LIBRARY_PATH
+ if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then
+ case $host_os in
+ openbsd2.[89] | openbsd2.[89].*)
+ shlibpath_overrides_runpath=no
+ ;;
+ *)
+ shlibpath_overrides_runpath=yes
+ ;;
+ esac
+ else
+ shlibpath_overrides_runpath=yes
+ fi
+ ;;
+
+os2*)
+ libname_spec='$name'
+ shrext_cmds=".dll"
+ need_lib_prefix=no
+ library_names_spec='$libname${shared_ext} $libname.a'
+ dynamic_linker='OS/2 ld.exe'
+ shlibpath_var=LIBPATH
+ ;;
+
+osf3* | osf4* | osf5*)
+ version_type=osf
+ need_lib_prefix=no
+ need_version=no
+ soname_spec='${libname}${release}${shared_ext}$major'
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+ shlibpath_var=LD_LIBRARY_PATH
+ sys_lib_search_path_spec="/usr/shlib /usr/ccs/lib /usr/lib/cmplrs/cc /usr/lib /usr/local/lib /var/shlib"
+ sys_lib_dlsearch_path_spec="$sys_lib_search_path_spec"
+ ;;
+
+rdos*)
+ dynamic_linker=no
+ ;;
+
+solaris*)
+ version_type=linux # correct to gnu/linux during the next big refactor
+ need_lib_prefix=no
+ need_version=no
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+ soname_spec='${libname}${release}${shared_ext}$major'
+ shlibpath_var=LD_LIBRARY_PATH
+ shlibpath_overrides_runpath=yes
+ hardcode_into_libs=yes
+ # ldd complains unless libraries are executable
+ postinstall_cmds='chmod +x $lib'
+ ;;
+
+sunos4*)
+ version_type=sunos
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix'
+ finish_cmds='PATH="\$PATH:/usr/etc" ldconfig $libdir'
+ shlibpath_var=LD_LIBRARY_PATH
+ shlibpath_overrides_runpath=yes
+ if test "$with_gnu_ld" = yes; then
+ need_lib_prefix=no
+ fi
+ need_version=yes
+ ;;
+
+sysv4 | sysv4.3*)
+ version_type=linux # correct to gnu/linux during the next big refactor
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+ soname_spec='${libname}${release}${shared_ext}$major'
+ shlibpath_var=LD_LIBRARY_PATH
+ case $host_vendor in
+ sni)
+ shlibpath_overrides_runpath=no
+ need_lib_prefix=no
+ runpath_var=LD_RUN_PATH
+ ;;
+ siemens)
+ need_lib_prefix=no
+ ;;
+ motorola)
+ need_lib_prefix=no
+ need_version=no
+ shlibpath_overrides_runpath=no
+ sys_lib_search_path_spec='/lib /usr/lib /usr/ccs/lib'
+ ;;
+ esac
+ ;;
+
+sysv4*MP*)
+ if test -d /usr/nec ;then
+ version_type=linux # correct to gnu/linux during the next big refactor
+ library_names_spec='$libname${shared_ext}.$versuffix $libname${shared_ext}.$major $libname${shared_ext}'
+ soname_spec='$libname${shared_ext}.$major'
+ shlibpath_var=LD_LIBRARY_PATH
+ fi
+ ;;
+
+sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*)
+ version_type=freebsd-elf
+ need_lib_prefix=no
+ need_version=no
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}'
+ soname_spec='${libname}${release}${shared_ext}$major'
+ shlibpath_var=LD_LIBRARY_PATH
+ shlibpath_overrides_runpath=yes
+ hardcode_into_libs=yes
+ if test "$with_gnu_ld" = yes; then
+ sys_lib_search_path_spec='/usr/local/lib /usr/gnu/lib /usr/ccs/lib /usr/lib /lib'
+ else
+ sys_lib_search_path_spec='/usr/ccs/lib /usr/lib'
+ case $host_os in
+ sco3.2v5*)
+ sys_lib_search_path_spec="$sys_lib_search_path_spec /lib"
+ ;;
+ esac
+ fi
+ sys_lib_dlsearch_path_spec='/usr/lib'
+ ;;
+
+tpf*)
+ # TPF is a cross-target only. Preferred cross-host = GNU/Linux.
+ version_type=linux # correct to gnu/linux during the next big refactor
+ need_lib_prefix=no
+ need_version=no
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+ shlibpath_var=LD_LIBRARY_PATH
+ shlibpath_overrides_runpath=no
+ hardcode_into_libs=yes
+ ;;
+
+uts4*)
+ version_type=linux # correct to gnu/linux during the next big refactor
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+ soname_spec='${libname}${release}${shared_ext}$major'
+ shlibpath_var=LD_LIBRARY_PATH
+ ;;
+
+*)
+ dynamic_linker=no
+ ;;
+esac
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $dynamic_linker" >&5
+$as_echo "$dynamic_linker" >&6; }
+test "$dynamic_linker" = no && can_build_shared=no
+
+variables_saved_for_relink="PATH $shlibpath_var $runpath_var"
+if test "$GCC" = yes; then
+ variables_saved_for_relink="$variables_saved_for_relink GCC_EXEC_PREFIX COMPILER_PATH LIBRARY_PATH"
+fi
+
+if test "${lt_cv_sys_lib_search_path_spec+set}" = set; then
+ sys_lib_search_path_spec="$lt_cv_sys_lib_search_path_spec"
+fi
+if test "${lt_cv_sys_lib_dlsearch_path_spec+set}" = set; then
+ sys_lib_dlsearch_path_spec="$lt_cv_sys_lib_dlsearch_path_spec"
+fi
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking how to hardcode library paths into programs" >&5
+$as_echo_n "checking how to hardcode library paths into programs... " >&6; }
+hardcode_action_CXX=
+if test -n "$hardcode_libdir_flag_spec_CXX" ||
+ test -n "$runpath_var_CXX" ||
+ test "X$hardcode_automatic_CXX" = "Xyes" ; then
+
+ # We can hardcode non-existent directories.
+ if test "$hardcode_direct_CXX" != no &&
+ # If the only mechanism to avoid hardcoding is shlibpath_var, we
+ # have to relink, otherwise we might link with an installed library
+ # when we should be linking with a yet-to-be-installed one
+ ## test "$_LT_TAGVAR(hardcode_shlibpath_var, CXX)" != no &&
+ test "$hardcode_minus_L_CXX" != no; then
+ # Linking always hardcodes the temporary library directory.
+ hardcode_action_CXX=relink
+ else
+ # We can link without hardcoding, and we can hardcode nonexisting dirs.
+ hardcode_action_CXX=immediate
+ fi
+else
+ # We cannot hardcode anything, or else we can only hardcode existing
+ # directories.
+ hardcode_action_CXX=unsupported
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $hardcode_action_CXX" >&5
+$as_echo "$hardcode_action_CXX" >&6; }
+
+if test "$hardcode_action_CXX" = relink ||
+ test "$inherit_rpath_CXX" = yes; then
+ # Fast installation is not supported
+ enable_fast_install=no
+elif test "$shlibpath_overrides_runpath" = yes ||
+ test "$enable_shared" = no; then
+ # Fast installation is not necessary
+ enable_fast_install=needless
+fi
+
+
+
+
+
+
+
+ fi # test -n "$compiler"
+
+ CC=$lt_save_CC
+ CFLAGS=$lt_save_CFLAGS
+ LDCXX=$LD
+ LD=$lt_save_LD
+ GCC=$lt_save_GCC
+ with_gnu_ld=$lt_save_with_gnu_ld
+ lt_cv_path_LDCXX=$lt_cv_path_LD
+ lt_cv_path_LD=$lt_save_path_LD
+ lt_cv_prog_gnu_ldcxx=$lt_cv_prog_gnu_ld
+ lt_cv_prog_gnu_ld=$lt_save_with_gnu_ld
+fi # test "$_lt_caught_CXX_error" != yes
+
+ac_ext=c
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ ac_config_commands="$ac_config_commands libtool"
+
+
+
+
+# Only expand once:
+
+
+
+
+# Test for 64-bit build.
+# The cast to long int works around a bug in the HP C Compiler
+# version HP92453-01 B.11.11.23709.GP, which incorrectly rejects
+# declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'.
+# This bug is HP SR number 8606223364.
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking size of size_t" >&5
+$as_echo_n "checking size of size_t... " >&6; }
+if ${ac_cv_sizeof_size_t+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ if ac_fn_c_compute_int "$LINENO" "(long int) (sizeof (size_t))" "ac_cv_sizeof_size_t" "$ac_includes_default"; then :
+
+else
+ if test "$ac_cv_type_size_t" = yes; then
+ { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
+$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
+as_fn_error 77 "cannot compute sizeof (size_t)
+See \`config.log' for more details" "$LINENO" 5; }
+ else
+ ac_cv_sizeof_size_t=0
+ fi
+fi
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_sizeof_size_t" >&5
+$as_echo "$ac_cv_sizeof_size_t" >&6; }
+
+
+
+cat >>confdefs.h <<_ACEOF
+#define SIZEOF_SIZE_T $ac_cv_sizeof_size_t
+_ACEOF
+
+
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for C compiler vendor" >&5
+$as_echo_n "checking for C compiler vendor... " >&6; }
+if ${ax_cv_c_compiler_vendor+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ # note: don't check for gcc first since some other compilers define __GNUC__
+ vendors="intel: __ICC,__ECC,__INTEL_COMPILER
+ ibm: __xlc__,__xlC__,__IBMC__,__IBMCPP__
+ pathscale: __PATHCC__,__PATHSCALE__
+ clang: __clang__
+ gnu: __GNUC__
+ sun: __SUNPRO_C,__SUNPRO_CC
+ hp: __HP_cc,__HP_aCC
+ dec: __DECC,__DECCXX,__DECC_VER,__DECCXX_VER
+ borland: __BORLANDC__,__TURBOC__
+ comeau: __COMO__
+ cray: _CRAYC
+ kai: __KCC
+ lcc: __LCC__
+ sgi: __sgi,sgi
+ microsoft: _MSC_VER
+ metrowerks: __MWERKS__
+ watcom: __WATCOMC__
+ portland: __PGI
+ unknown: UNKNOWN"
+ for ventest in $vendors; do
+ case $ventest in
+ *:) vendor=$ventest; continue ;;
+ *) vencpp="defined("`echo $ventest | sed 's/,/) || defined(/g'`")" ;;
+ esac
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+
+int
+main ()
+{
+
+ #if !($vencpp)
+ thisisanerror;
+ #endif
+
+ ;
+ return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+ break
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+ done
+ ax_cv_c_compiler_vendor=`echo $vendor | cut -d: -f1`
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ax_cv_c_compiler_vendor" >&5
+$as_echo "$ax_cv_c_compiler_vendor" >&6; }
+
+
+
+
+
+
+# Check whether --enable-portable-binary was given.
+if test "${enable_portable_binary+set}" = set; then :
+ enableval=$enable_portable_binary; acx_maxopt_portable=$enableval
+else
+ acx_maxopt_portable=no
+fi
+
+
+# Try to determine "good" native compiler flags if none specified via CFLAGS
+if test "$ac_test_CFLAGS" != "set"; then
+ CFLAGS=""
+ case $ax_cv_c_compiler_vendor in
+ dec) CFLAGS="-newc -w0 -O5 -ansi_alias -ansi_args -fp_reorder -tune host"
+ if test "x$acx_maxopt_portable" = xno; then
+ CFLAGS="$CFLAGS -arch host"
+ fi;;
+
+ sun) CFLAGS="-native -fast -xO5 -dalign"
+ if test "x$acx_maxopt_portable" = xyes; then
+ CFLAGS="$CFLAGS -xarch=generic"
+ fi;;
+
+ hp) CFLAGS="+Oall +Optrs_ansi +DSnative"
+ if test "x$acx_maxopt_portable" = xyes; then
+ CFLAGS="$CFLAGS +DAportable"
+ fi;;
+
+ ibm) if test "x$acx_maxopt_portable" = xno; then
+ xlc_opt="-qarch=auto -qtune=auto"
+ else
+ xlc_opt="-qtune=auto"
+ fi
+ as_CACHEVAR=`$as_echo "ax_cv_check_cflags__$xlc_opt" | $as_tr_sh`
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether C compiler accepts $xlc_opt" >&5
+$as_echo_n "checking whether C compiler accepts $xlc_opt... " >&6; }
+if eval \${$as_CACHEVAR+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+
+ ax_check_save_flags=$CFLAGS
+ CFLAGS="$CFLAGS $xlc_opt"
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+
+int
+main ()
+{
+
+ ;
+ return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+ eval "$as_CACHEVAR=yes"
+else
+ eval "$as_CACHEVAR=no"
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+ CFLAGS=$ax_check_save_flags
+fi
+eval ac_res=\$$as_CACHEVAR
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5
+$as_echo "$ac_res" >&6; }
+if test x"`eval 'as_val=${'$as_CACHEVAR'};$as_echo "$as_val"'`" = xyes; then :
+ CFLAGS="-O3 -qansialias -w $xlc_opt"
+else
+ CFLAGS="-O3 -qansialias -w"
+ echo "******************************************************"
+ echo "* You seem to have the IBM C compiler. It is *"
+ echo "* recommended for best performance that you use: *"
+ echo "* *"
+ echo "* CFLAGS=-O3 -qarch=xxx -qtune=xxx -qansialias -w *"
+ echo "* ^^^ ^^^ *"
+ echo "* where xxx is pwr2, pwr3, 604, or whatever kind of *"
+ echo "* CPU you have. (Set the CFLAGS environment var. *"
+ echo "* and re-run configure.) For more info, man cc. *"
+ echo "******************************************************"
+fi
+
+ ;;
+
+ intel) CFLAGS="-O3 -ansi_alias"
+ if test "x$acx_maxopt_portable" = xno; then
+ icc_archflag=unknown
+ icc_flags=""
+ case $host_cpu in
+ i686*|x86_64*)
+ # icc accepts gcc assembly syntax, so these should work:
+
+ac_ext=c
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for x86 cpuid 0 output" >&5
+$as_echo_n "checking for x86 cpuid 0 output... " >&6; }
+if ${ax_cv_gcc_x86_cpuid_0+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ if test "$cross_compiling" = yes; then :
+ ax_cv_gcc_x86_cpuid_0=unknown
+else
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+#include <stdio.h>
+int
+main ()
+{
+
+ int op = 0, eax, ebx, ecx, edx;
+ FILE *f;
+ __asm__("cpuid"
+ : "=a" (eax), "=b" (ebx), "=c" (ecx), "=d" (edx)
+ : "a" (op));
+ f = fopen("conftest_cpuid", "w"); if (!f) return 1;
+ fprintf(f, "%x:%x:%x:%x\n", eax, ebx, ecx, edx);
+ fclose(f);
+ return 0;
+
+ ;
+ return 0;
+}
+_ACEOF
+if ac_fn_c_try_run "$LINENO"; then :
+ ax_cv_gcc_x86_cpuid_0=`cat conftest_cpuid`; rm -f conftest_cpuid
+else
+ ax_cv_gcc_x86_cpuid_0=unknown; rm -f conftest_cpuid
+fi
+rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
+ conftest.$ac_objext conftest.beam conftest.$ac_ext
+fi
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ax_cv_gcc_x86_cpuid_0" >&5
+$as_echo "$ax_cv_gcc_x86_cpuid_0" >&6; }
+ac_ext=c
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
+
+
+
+ac_ext=c
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for x86 cpuid 1 output" >&5
+$as_echo_n "checking for x86 cpuid 1 output... " >&6; }
+if ${ax_cv_gcc_x86_cpuid_1+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ if test "$cross_compiling" = yes; then :
+ ax_cv_gcc_x86_cpuid_1=unknown
+else
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+#include <stdio.h>
+int
+main ()
+{
+
+ int op = 1, eax, ebx, ecx, edx;
+ FILE *f;
+ __asm__("cpuid"
+ : "=a" (eax), "=b" (ebx), "=c" (ecx), "=d" (edx)
+ : "a" (op));
+ f = fopen("conftest_cpuid", "w"); if (!f) return 1;
+ fprintf(f, "%x:%x:%x:%x\n", eax, ebx, ecx, edx);
+ fclose(f);
+ return 0;
+
+ ;
+ return 0;
+}
+_ACEOF
+if ac_fn_c_try_run "$LINENO"; then :
+ ax_cv_gcc_x86_cpuid_1=`cat conftest_cpuid`; rm -f conftest_cpuid
+else
+ ax_cv_gcc_x86_cpuid_1=unknown; rm -f conftest_cpuid
+fi
+rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
+ conftest.$ac_objext conftest.beam conftest.$ac_ext
+fi
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ax_cv_gcc_x86_cpuid_1" >&5
+$as_echo "$ax_cv_gcc_x86_cpuid_1" >&6; }
+ac_ext=c
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
+
+
+ case $ax_cv_gcc_x86_cpuid_0 in # see AX_GCC_ARCHFLAG
+ *:756e6547:*:*) # Intel
+ case $ax_cv_gcc_x86_cpuid_1 in
+ *6a?:*[234]:*:*|*6[789b]?:*:*:*) icc_flags="-xK";;
+ *f3[347]:*:*:*|*f41347:*:*:*) icc_flags="-xP -xN -xW -xK";;
+ *f??:*:*:*) icc_flags="-xN -xW -xK";;
+ esac ;;
+ esac ;;
+ esac
+ if test "x$icc_flags" != x; then
+ for flag in $icc_flags; do
+ as_CACHEVAR=`$as_echo "ax_cv_check_cflags__$flag" | $as_tr_sh`
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether C compiler accepts $flag" >&5
+$as_echo_n "checking whether C compiler accepts $flag... " >&6; }
+if eval \${$as_CACHEVAR+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+
+ ax_check_save_flags=$CFLAGS
+ CFLAGS="$CFLAGS $flag"
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+
+int
+main ()
+{
+
+ ;
+ return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+ eval "$as_CACHEVAR=yes"
+else
+ eval "$as_CACHEVAR=no"
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+ CFLAGS=$ax_check_save_flags
+fi
+eval ac_res=\$$as_CACHEVAR
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5
+$as_echo "$ac_res" >&6; }
+if test x"`eval 'as_val=${'$as_CACHEVAR'};$as_echo "$as_val"'`" = xyes; then :
+ icc_archflag=$flag; break
+else
+ :
+fi
+
+ done
+ fi
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for icc architecture flag" >&5
+$as_echo_n "checking for icc architecture flag... " >&6; }
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $icc_archflag" >&5
+$as_echo "$icc_archflag" >&6; }
+ if test "x$icc_archflag" != xunknown; then
+ CFLAGS="$CFLAGS $icc_archflag"
+ fi
+ fi
+ ;;
+
+ gnu)
+ # default optimization flags for gcc on all systems
+ CFLAGS="-O3 -fomit-frame-pointer"
+
+ # -malign-double for x86 systems
+ # LIBFFI -- DON'T DO THIS - CHANGES ABI
+ # AX_CHECK_COMPILE_FLAG(-malign-double, CFLAGS="$CFLAGS -malign-double")
+
+ # -fstrict-aliasing for gcc-2.95+
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether C compiler accepts -fstrict-aliasing" >&5
+$as_echo_n "checking whether C compiler accepts -fstrict-aliasing... " >&6; }
+if ${ax_cv_check_cflags___fstrict_aliasing+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+
+ ax_check_save_flags=$CFLAGS
+ CFLAGS="$CFLAGS -fstrict-aliasing"
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+
+int
+main ()
+{
+
+ ;
+ return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+ ax_cv_check_cflags___fstrict_aliasing=yes
+else
+ ax_cv_check_cflags___fstrict_aliasing=no
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+ CFLAGS=$ax_check_save_flags
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ax_cv_check_cflags___fstrict_aliasing" >&5
+$as_echo "$ax_cv_check_cflags___fstrict_aliasing" >&6; }
+if test x"$ax_cv_check_cflags___fstrict_aliasing" = xyes; then :
+ CFLAGS="$CFLAGS -fstrict-aliasing"
+else
+ :
+fi
+
+
+ # note that we enable "unsafe" fp optimization with other compilers, too
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether C compiler accepts -ffast-math" >&5
+$as_echo_n "checking whether C compiler accepts -ffast-math... " >&6; }
+if ${ax_cv_check_cflags___ffast_math+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+
+ ax_check_save_flags=$CFLAGS
+ CFLAGS="$CFLAGS -ffast-math"
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+
+int
+main ()
+{
+
+ ;
+ return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+ ax_cv_check_cflags___ffast_math=yes
+else
+ ax_cv_check_cflags___ffast_math=no
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+ CFLAGS=$ax_check_save_flags
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ax_cv_check_cflags___ffast_math" >&5
+$as_echo "$ax_cv_check_cflags___ffast_math" >&6; }
+if test x"$ax_cv_check_cflags___ffast_math" = xyes; then :
+ CFLAGS="$CFLAGS -ffast-math"
+else
+ :
+fi
+
+
+
+
+
+
+# Check whether --with-gcc-arch was given.
+if test "${with_gcc_arch+set}" = set; then :
+ withval=$with_gcc_arch; ax_gcc_arch=$withval
+else
+ ax_gcc_arch=yes
+fi
+
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for gcc architecture flag" >&5
+$as_echo_n "checking for gcc architecture flag... " >&6; }
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: " >&5
+$as_echo "" >&6; }
+if ${ax_cv_gcc_archflag+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+
+ax_cv_gcc_archflag="unknown"
+
+if test "$GCC" = yes; then
+
+if test "x$ax_gcc_arch" = xyes; then
+ax_gcc_arch=""
+if test "$cross_compiling" = no; then
+case $host_cpu in
+ i[3456]86*|x86_64*) # use cpuid codes
+
+ac_ext=c
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for x86 cpuid 0 output" >&5
+$as_echo_n "checking for x86 cpuid 0 output... " >&6; }
+if ${ax_cv_gcc_x86_cpuid_0+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ if test "$cross_compiling" = yes; then :
+ ax_cv_gcc_x86_cpuid_0=unknown
+else
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+#include <stdio.h>
+int
+main ()
+{
+
+ int op = 0, eax, ebx, ecx, edx;
+ FILE *f;
+ __asm__("cpuid"
+ : "=a" (eax), "=b" (ebx), "=c" (ecx), "=d" (edx)
+ : "a" (op));
+ f = fopen("conftest_cpuid", "w"); if (!f) return 1;
+ fprintf(f, "%x:%x:%x:%x\n", eax, ebx, ecx, edx);
+ fclose(f);
+ return 0;
+
+ ;
+ return 0;
+}
+_ACEOF
+if ac_fn_c_try_run "$LINENO"; then :
+ ax_cv_gcc_x86_cpuid_0=`cat conftest_cpuid`; rm -f conftest_cpuid
+else
+ ax_cv_gcc_x86_cpuid_0=unknown; rm -f conftest_cpuid
+fi
+rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
+ conftest.$ac_objext conftest.beam conftest.$ac_ext
+fi
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ax_cv_gcc_x86_cpuid_0" >&5
+$as_echo "$ax_cv_gcc_x86_cpuid_0" >&6; }
+ac_ext=c
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
+
+
+
+ac_ext=c
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for x86 cpuid 1 output" >&5
+$as_echo_n "checking for x86 cpuid 1 output... " >&6; }
+if ${ax_cv_gcc_x86_cpuid_1+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ if test "$cross_compiling" = yes; then :
+ ax_cv_gcc_x86_cpuid_1=unknown
+else
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+#include <stdio.h>
+int
+main ()
+{
+
+ int op = 1, eax, ebx, ecx, edx;
+ FILE *f;
+ __asm__("cpuid"
+ : "=a" (eax), "=b" (ebx), "=c" (ecx), "=d" (edx)
+ : "a" (op));
+ f = fopen("conftest_cpuid", "w"); if (!f) return 1;
+ fprintf(f, "%x:%x:%x:%x\n", eax, ebx, ecx, edx);
+ fclose(f);
+ return 0;
+
+ ;
+ return 0;
+}
+_ACEOF
+if ac_fn_c_try_run "$LINENO"; then :
+ ax_cv_gcc_x86_cpuid_1=`cat conftest_cpuid`; rm -f conftest_cpuid
+else
+ ax_cv_gcc_x86_cpuid_1=unknown; rm -f conftest_cpuid
+fi
+rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
+ conftest.$ac_objext conftest.beam conftest.$ac_ext
+fi
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ax_cv_gcc_x86_cpuid_1" >&5
+$as_echo "$ax_cv_gcc_x86_cpuid_1" >&6; }
+ac_ext=c
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
+
+
+ case $ax_cv_gcc_x86_cpuid_0 in
+ *:756e6547:*:*) # Intel
+ case $ax_cv_gcc_x86_cpuid_1 in
+ *5[48]?:*:*:*) ax_gcc_arch="pentium-mmx pentium" ;;
+ *5??:*:*:*) ax_gcc_arch=pentium ;;
+ *0?6[3456]?:*:*:*) ax_gcc_arch="pentium2 pentiumpro" ;;
+ *0?6a?:*[01]:*:*) ax_gcc_arch="pentium2 pentiumpro" ;;
+ *0?6a?:*[234]:*:*) ax_gcc_arch="pentium3 pentiumpro" ;;
+ *0?6[9de]?:*:*:*) ax_gcc_arch="pentium-m pentium3 pentiumpro" ;;
+ *0?6[78b]?:*:*:*) ax_gcc_arch="pentium3 pentiumpro" ;;
+ *0?6f?:*:*:*|*1?66?:*:*:*) ax_gcc_arch="core2 pentium-m pentium3 pentiumpro" ;;
+ *1?6[7d]?:*:*:*) ax_gcc_arch="penryn core2 pentium-m pentium3 pentiumpro" ;;
+ *1?6[aef]?:*:*:*|*2?6[5cef]?:*:*:*) ax_gcc_arch="corei7 core2 pentium-m pentium3 pentiumpro" ;;
+ *1?6c?:*:*:*|*[23]?66?:*:*:*) ax_gcc_arch="atom core2 pentium-m pentium3 pentiumpro" ;;
+ *2?6[ad]?:*:*:*) ax_gcc_arch="corei7-avx corei7 core2 pentium-m pentium3 pentiumpro" ;;
+ *0?6??:*:*:*) ax_gcc_arch=pentiumpro ;;
+ *6??:*:*:*) ax_gcc_arch="core2 pentiumpro" ;;
+ ?000?f3[347]:*:*:*|?000?f41347:*:*:*|?000?f6?:*:*:*)
+ case $host_cpu in
+ x86_64*) ax_gcc_arch="nocona pentium4 pentiumpro" ;;
+ *) ax_gcc_arch="prescott pentium4 pentiumpro" ;;
+ esac ;;
+ ?000?f??:*:*:*) ax_gcc_arch="pentium4 pentiumpro";;
+ esac ;;
+ *:68747541:*:*) # AMD
+ case $ax_cv_gcc_x86_cpuid_1 in
+ *5[67]?:*:*:*) ax_gcc_arch=k6 ;;
+ *5[8d]?:*:*:*) ax_gcc_arch="k6-2 k6" ;;
+ *5[9]?:*:*:*) ax_gcc_arch="k6-3 k6" ;;
+ *60?:*:*:*) ax_gcc_arch=k7 ;;
+ *6[12]?:*:*:*) ax_gcc_arch="athlon k7" ;;
+ *6[34]?:*:*:*) ax_gcc_arch="athlon-tbird k7" ;;
+ *67?:*:*:*) ax_gcc_arch="athlon-4 athlon k7" ;;
+ *6[68a]?:*:*:*)
+
+ac_ext=c
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for x86 cpuid 0x80000006 output" >&5
+$as_echo_n "checking for x86 cpuid 0x80000006 output... " >&6; }
+if ${ax_cv_gcc_x86_cpuid_0x80000006+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ if test "$cross_compiling" = yes; then :
+ ax_cv_gcc_x86_cpuid_0x80000006=unknown
+else
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+#include <stdio.h>
+int
+main ()
+{
+
+ int op = 0x80000006, eax, ebx, ecx, edx;
+ FILE *f;
+ __asm__("cpuid"
+ : "=a" (eax), "=b" (ebx), "=c" (ecx), "=d" (edx)
+ : "a" (op));
+ f = fopen("conftest_cpuid", "w"); if (!f) return 1;
+ fprintf(f, "%x:%x:%x:%x\n", eax, ebx, ecx, edx);
+ fclose(f);
+ return 0;
+
+ ;
+ return 0;
+}
+_ACEOF
+if ac_fn_c_try_run "$LINENO"; then :
+ ax_cv_gcc_x86_cpuid_0x80000006=`cat conftest_cpuid`; rm -f conftest_cpuid
+else
+ ax_cv_gcc_x86_cpuid_0x80000006=unknown; rm -f conftest_cpuid
+fi
+rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
+ conftest.$ac_objext conftest.beam conftest.$ac_ext
+fi
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ax_cv_gcc_x86_cpuid_0x80000006" >&5
+$as_echo "$ax_cv_gcc_x86_cpuid_0x80000006" >&6; }
+ac_ext=c
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
+
+ # L2 cache size
+ case $ax_cv_gcc_x86_cpuid_0x80000006 in
+ *:*:*[1-9a-f]??????:*) # (L2 = ecx >> 16) >= 256
+ ax_gcc_arch="athlon-xp athlon-4 athlon k7" ;;
+ *) ax_gcc_arch="athlon-4 athlon k7" ;;
+ esac ;;
+ ?00??f[4cef8b]?:*:*:*) ax_gcc_arch="athlon64 k8" ;;
+ ?00??f5?:*:*:*) ax_gcc_arch="opteron k8" ;;
+ ?00??f7?:*:*:*) ax_gcc_arch="athlon-fx opteron k8" ;;
+ ?00??f??:*:*:*) ax_gcc_arch="k8" ;;
+ ?05??f??:*:*:*) ax_gcc_arch="btver1 amdfam10 k8" ;;
+ ?06??f??:*:*:*) ax_gcc_arch="bdver1 amdfam10 k8" ;;
+ *f??:*:*:*) ax_gcc_arch="amdfam10 k8" ;;
+ esac ;;
+ *:746e6543:*:*) # IDT
+ case $ax_cv_gcc_x86_cpuid_1 in
+ *54?:*:*:*) ax_gcc_arch=winchip-c6 ;;
+ *58?:*:*:*) ax_gcc_arch=winchip2 ;;
+ *6[78]?:*:*:*) ax_gcc_arch=c3 ;;
+ *69?:*:*:*) ax_gcc_arch="c3-2 c3" ;;
+ esac ;;
+ esac
+ if test x"$ax_gcc_arch" = x; then # fallback
+ case $host_cpu in
+ i586*) ax_gcc_arch=pentium ;;
+ i686*) ax_gcc_arch=pentiumpro ;;
+ esac
+ fi
+ ;;
+
+ sparc*)
+ # Extract the first word of "prtdiag", so it can be a program name with args.
+set dummy prtdiag; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if ${ac_cv_path_PRTDIAG+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ case $PRTDIAG in
+ [\\/]* | ?:[\\/]*)
+ ac_cv_path_PRTDIAG="$PRTDIAG" # Let the user override the test with a path.
+ ;;
+ *)
+ as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+as_dummy="$PATH:/usr/platform/`uname -i`/sbin/:/usr/platform/`uname -m`/sbin/"
+for as_dir in $as_dummy
+do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ for ac_exec_ext in '' $ac_executable_extensions; do
+ if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+ ac_cv_path_PRTDIAG="$as_dir/$ac_word$ac_exec_ext"
+ $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+ break 2
+ fi
+done
+ done
+IFS=$as_save_IFS
+
+ test -z "$ac_cv_path_PRTDIAG" && ac_cv_path_PRTDIAG="prtdiag"
+ ;;
+esac
+fi
+PRTDIAG=$ac_cv_path_PRTDIAG
+if test -n "$PRTDIAG"; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $PRTDIAG" >&5
+$as_echo "$PRTDIAG" >&6; }
+else
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+ cputype=`(((grep cpu /proc/cpuinfo | cut -d: -f2) ; ($PRTDIAG -v |grep -i sparc) ; grep -i cpu /var/run/dmesg.boot ) | head -n 1) 2> /dev/null`
+ cputype=`echo "$cputype" | tr -d ' -' | sed 's/SPARCIIi/SPARCII/' | tr $as_cr_LETTERS $as_cr_letters`
+ case $cputype in
+ *ultrasparciv*) ax_gcc_arch="ultrasparc4 ultrasparc3 ultrasparc v9" ;;
+ *ultrasparciii*) ax_gcc_arch="ultrasparc3 ultrasparc v9" ;;
+ *ultrasparc*) ax_gcc_arch="ultrasparc v9" ;;
+ *supersparc*|*tms390z5[05]*) ax_gcc_arch="supersparc v8" ;;
+ *hypersparc*|*rt62[056]*) ax_gcc_arch="hypersparc v8" ;;
+ *cypress*) ax_gcc_arch=cypress ;;
+ esac ;;
+
+ alphaev5) ax_gcc_arch=ev5 ;;
+ alphaev56) ax_gcc_arch=ev56 ;;
+ alphapca56) ax_gcc_arch="pca56 ev56" ;;
+ alphapca57) ax_gcc_arch="pca57 pca56 ev56" ;;
+ alphaev6) ax_gcc_arch=ev6 ;;
+ alphaev67) ax_gcc_arch=ev67 ;;
+ alphaev68) ax_gcc_arch="ev68 ev67" ;;
+ alphaev69) ax_gcc_arch="ev69 ev68 ev67" ;;
+ alphaev7) ax_gcc_arch="ev7 ev69 ev68 ev67" ;;
+ alphaev79) ax_gcc_arch="ev79 ev7 ev69 ev68 ev67" ;;
+
+ powerpc*)
+ cputype=`((grep cpu /proc/cpuinfo | head -n 1 | cut -d: -f2 | cut -d, -f1 | sed 's/ //g') ; /usr/bin/machine ; /bin/machine; grep CPU /var/run/dmesg.boot | head -n 1 | cut -d" " -f2) 2> /dev/null`
+ cputype=`echo $cputype | sed -e 's/ppc//g;s/ *//g'`
+ case $cputype in
+ *750*) ax_gcc_arch="750 G3" ;;
+ *740[0-9]*) ax_gcc_arch="$cputype 7400 G4" ;;
+ *74[4-5][0-9]*) ax_gcc_arch="$cputype 7450 G4" ;;
+ *74[0-9][0-9]*) ax_gcc_arch="$cputype G4" ;;
+ *970*) ax_gcc_arch="970 G5 power4";;
+ *POWER4*|*power4*|*gq*) ax_gcc_arch="power4 970";;
+ *POWER5*|*power5*|*gr*|*gs*) ax_gcc_arch="power5 power4 970";;
+ 603ev|8240) ax_gcc_arch="$cputype 603e 603";;
+ *) ax_gcc_arch=$cputype ;;
+ esac
+ ax_gcc_arch="$ax_gcc_arch powerpc"
+ ;;
+esac
+fi # not cross-compiling
+fi # guess arch
+
+if test "x$ax_gcc_arch" != x -a "x$ax_gcc_arch" != xno; then
+for arch in $ax_gcc_arch; do
+ if test "x$acx_maxopt_portable" = xyes; then # if we require portable code
+ flags="-mtune=$arch"
+ # -mcpu=$arch and m$arch generate nonportable code on every arch except
+ # x86. And some other arches (e.g. Alpha) don't accept -mtune. Grrr.
+ case $host_cpu in i*86|x86_64*) flags="$flags -mcpu=$arch -m$arch";; esac
+ else
+ flags="-march=$arch -mcpu=$arch -m$arch"
+ fi
+ for flag in $flags; do
+ as_CACHEVAR=`$as_echo "ax_cv_check_cflags__$flag" | $as_tr_sh`
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether C compiler accepts $flag" >&5
+$as_echo_n "checking whether C compiler accepts $flag... " >&6; }
+if eval \${$as_CACHEVAR+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+
+ ax_check_save_flags=$CFLAGS
+ CFLAGS="$CFLAGS $flag"
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+
+int
+main ()
+{
+
+ ;
+ return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+ eval "$as_CACHEVAR=yes"
+else
+ eval "$as_CACHEVAR=no"
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+ CFLAGS=$ax_check_save_flags
+fi
+eval ac_res=\$$as_CACHEVAR
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5
+$as_echo "$ac_res" >&6; }
+if test x"`eval 'as_val=${'$as_CACHEVAR'};$as_echo "$as_val"'`" = xyes; then :
+ ax_cv_gcc_archflag=$flag; break
+else
+ :
+fi
+
+ done
+ test "x$ax_cv_gcc_archflag" = xunknown || break
+done
+fi
+
+fi # $GCC=yes
+
+fi
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for gcc architecture flag" >&5
+$as_echo_n "checking for gcc architecture flag... " >&6; }
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ax_cv_gcc_archflag" >&5
+$as_echo "$ax_cv_gcc_archflag" >&6; }
+if test "x$ax_cv_gcc_archflag" = xunknown; then
+ :
+else
+ CFLAGS="$CFLAGS $ax_cv_gcc_archflag"
+fi
+
+ ;;
+ esac
+
+ if test -z "$CFLAGS"; then
+ echo ""
+ echo "********************************************************"
+ echo "* WARNING: Don't know the best CFLAGS for this system *"
+ echo "* Use ./configure CFLAGS=... to specify your own flags *"
+ echo "* (otherwise, a default of CFLAGS=-O3 will be used) *"
+ echo "********************************************************"
+ echo ""
+ CFLAGS="-O3"
+ fi
+
+ as_CACHEVAR=`$as_echo "ax_cv_check_cflags__$CFLAGS" | $as_tr_sh`
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether C compiler accepts $CFLAGS" >&5
+$as_echo_n "checking whether C compiler accepts $CFLAGS... " >&6; }
+if eval \${$as_CACHEVAR+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+
+ ax_check_save_flags=$CFLAGS
+ CFLAGS="$CFLAGS $CFLAGS"
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+
+int
+main ()
+{
+
+ ;
+ return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+ eval "$as_CACHEVAR=yes"
+else
+ eval "$as_CACHEVAR=no"
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+ CFLAGS=$ax_check_save_flags
+fi
+eval ac_res=\$$as_CACHEVAR
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5
+$as_echo "$ac_res" >&6; }
+if test x"`eval 'as_val=${'$as_CACHEVAR'};$as_echo "$as_val"'`" = xyes; then :
+ :
+else
+
+ echo ""
+ echo "********************************************************"
+ echo "* WARNING: The guessed CFLAGS don't seem to work with *"
+ echo "* your compiler. *"
+ echo "* Use ./configure CFLAGS=... to specify your own flags *"
+ echo "********************************************************"
+ echo ""
+ CFLAGS=""
+
+fi
+
+
+fi
+
+# The AX_CFLAGS_WARN_ALL macro doesn't currently work for sunpro
+# compiler.
+if test "$ax_cv_c_compiler_vendor" != "sun"; then
+ if ${CFLAGS+:} false; then :
+ case " $CFLAGS " in
+ *" "*)
+ { { $as_echo "$as_me:${as_lineno-$LINENO}: : CFLAGS already contains "; } >&5
+ (: CFLAGS already contains ) 2>&5
+ ac_status=$?
+ $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+ test $ac_status = 0; }
+ ;;
+ *)
+ { { $as_echo "$as_me:${as_lineno-$LINENO}: : CFLAGS=\"\$CFLAGS \""; } >&5
+ (: CFLAGS="$CFLAGS ") 2>&5
+ ac_status=$?
+ $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+ test $ac_status = 0; }
+ CFLAGS="$CFLAGS "
+ ;;
+ esac
+else
+ CFLAGS=""
+fi
+
+ac_ext=c
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking CFLAGS for maximum warnings" >&5
+$as_echo_n "checking CFLAGS for maximum warnings... " >&6; }
+if ${ac_cv_cflags_warn_all+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ ac_cv_cflags_warn_all="no, unknown"
+ac_save_CFLAGS="$CFLAGS"
+for ac_arg in "-warn all % -warn all" "-pedantic % -Wall" "-xstrconst % -v" "-std1 % -verbose -w0 -warnprotos" "-qlanglvl=ansi % -qsrcmsg -qinfo=all:noppt:noppc:noobs:nocnd" "-ansi -ansiE % -fullwarn" "+ESlit % +w1" "-Xc % -pvctl,fullmsg" "-h conform % -h msglevel 2" #
+do CFLAGS="$ac_save_CFLAGS "`echo $ac_arg | sed -e 's,%%.*,,' -e 's,%,,'`
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+
+int
+main ()
+{
+
+ ;
+ return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+ ac_cv_cflags_warn_all=`echo $ac_arg | sed -e 's,.*% *,,'` ; break
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+done
+CFLAGS="$ac_save_CFLAGS"
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_cflags_warn_all" >&5
+$as_echo "$ac_cv_cflags_warn_all" >&6; }
+
+case ".$ac_cv_cflags_warn_all" in
+ .ok|.ok,*) ;;
+ .|.no|.no,*) ;;
+ *) if ${CFLAGS+:} false; then :
+ case " $CFLAGS " in
+ *" $ac_cv_cflags_warn_all "*)
+ { { $as_echo "$as_me:${as_lineno-$LINENO}: : CFLAGS already contains \$ac_cv_cflags_warn_all"; } >&5
+ (: CFLAGS already contains $ac_cv_cflags_warn_all) 2>&5
+ ac_status=$?
+ $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+ test $ac_status = 0; }
+ ;;
+ *)
+ { { $as_echo "$as_me:${as_lineno-$LINENO}: : CFLAGS=\"\$CFLAGS \$ac_cv_cflags_warn_all\""; } >&5
+ (: CFLAGS="$CFLAGS $ac_cv_cflags_warn_all") 2>&5
+ ac_status=$?
+ $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+ test $ac_status = 0; }
+ CFLAGS="$CFLAGS $ac_cv_cflags_warn_all"
+ ;;
+ esac
+else
+ CFLAGS="$ac_cv_cflags_warn_all"
+fi
+ ;;
+esac
+
+ac_ext=c
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
+
+
+fi
+
+if test "x$GCC" = "xyes"; then
+ CFLAGS="$CFLAGS -fexceptions"
+fi
+
+cat > local.exp <<EOF
+set CC_FOR_TARGET "$CC"
+set CXX_FOR_TARGET "$CXX"
+EOF
+
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to enable maintainer-specific portions of Makefiles" >&5
+$as_echo_n "checking whether to enable maintainer-specific portions of Makefiles... " >&6; }
+ # Check whether --enable-maintainer-mode was given.
+if test "${enable_maintainer_mode+set}" = set; then :
+ enableval=$enable_maintainer_mode; USE_MAINTAINER_MODE=$enableval
+else
+ USE_MAINTAINER_MODE=no
+fi
+
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $USE_MAINTAINER_MODE" >&5
+$as_echo "$USE_MAINTAINER_MODE" >&6; }
+ if test $USE_MAINTAINER_MODE = yes; then
+ MAINTAINER_MODE_TRUE=
+ MAINTAINER_MODE_FALSE='#'
+else
+ MAINTAINER_MODE_TRUE='#'
+ MAINTAINER_MODE_FALSE=
+fi
+
+ MAINT=$MAINTAINER_MODE_TRUE
+
+
+
+for ac_header in sys/mman.h
+do :
+ ac_fn_c_check_header_mongrel "$LINENO" "sys/mman.h" "ac_cv_header_sys_mman_h" "$ac_includes_default"
+if test "x$ac_cv_header_sys_mman_h" = xyes; then :
+ cat >>confdefs.h <<_ACEOF
+#define HAVE_SYS_MMAN_H 1
+_ACEOF
+
+fi
+
+done
+
+for ac_func in mmap mkostemp
+do :
+ as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh`
+ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var"
+if eval test \"x\$"$as_ac_var"\" = x"yes"; then :
+ cat >>confdefs.h <<_ACEOF
+#define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1
+_ACEOF
+
+fi
+done
+
+
+ac_fn_c_check_header_mongrel "$LINENO" "sys/mman.h" "ac_cv_header_sys_mman_h" "$ac_includes_default"
+if test "x$ac_cv_header_sys_mman_h" = xyes; then :
+ libffi_header_sys_mman_h=yes
+else
+ libffi_header_sys_mman_h=no
+fi
+
+
+ac_fn_c_check_func "$LINENO" "mmap" "ac_cv_func_mmap"
+if test "x$ac_cv_func_mmap" = xyes; then :
+ libffi_func_mmap=yes
+else
+ libffi_func_mmap=no
+fi
+
+if test "$libffi_header_sys_mman_h" != yes \
+ || test "$libffi_func_mmap" != yes; then
+ ac_cv_func_mmap_file=no
+ ac_cv_func_mmap_dev_zero=no
+ ac_cv_func_mmap_anon=no
+else
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether read-only mmap of a plain file works" >&5
+$as_echo_n "checking whether read-only mmap of a plain file works... " >&6; }
+if ${ac_cv_func_mmap_file+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ # Add a system to this blacklist if
+ # mmap(0, stat_size, PROT_READ, MAP_PRIVATE, fd, 0) doesn't return a
+ # memory area containing the same data that you'd get if you applied
+ # read() to the same fd. The only system known to have a problem here
+ # is VMS, where text files have record structure.
+ case "$host_os" in
+ vms* | ultrix*)
+ ac_cv_func_mmap_file=no ;;
+ *)
+ ac_cv_func_mmap_file=yes;;
+ esac
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_func_mmap_file" >&5
+$as_echo "$ac_cv_func_mmap_file" >&6; }
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether mmap from /dev/zero works" >&5
+$as_echo_n "checking whether mmap from /dev/zero works... " >&6; }
+if ${ac_cv_func_mmap_dev_zero+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ # Add a system to this blacklist if it has mmap() but /dev/zero
+ # does not exist, or if mmapping /dev/zero does not give anonymous
+ # zeroed pages with both the following properties:
+ # 1. If you map N consecutive pages in with one call, and then
+ # unmap any subset of those pages, the pages that were not
+ # explicitly unmapped remain accessible.
+ # 2. If you map two adjacent blocks of memory and then unmap them
+ # both at once, they must both go away.
+ # Systems known to be in this category are Windows (all variants),
+ # VMS, and Darwin.
+ case "$host_os" in
+ vms* | cygwin* | pe | mingw* | darwin* | ultrix* | hpux10* | hpux11.00)
+ ac_cv_func_mmap_dev_zero=no ;;
+ *)
+ ac_cv_func_mmap_dev_zero=yes;;
+ esac
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_func_mmap_dev_zero" >&5
+$as_echo "$ac_cv_func_mmap_dev_zero" >&6; }
+
+ # Unlike /dev/zero, the MAP_ANON(YMOUS) defines can be probed for.
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for MAP_ANON(YMOUS)" >&5
+$as_echo_n "checking for MAP_ANON(YMOUS)... " >&6; }
+if ${ac_cv_decl_map_anon+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+#include <sys/types.h>
+#include <sys/mman.h>
+#include <unistd.h>
+
+#ifndef MAP_ANONYMOUS
+#define MAP_ANONYMOUS MAP_ANON
+#endif
+
+int
+main ()
+{
+int n = MAP_ANONYMOUS;
+ ;
+ return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+ ac_cv_decl_map_anon=yes
+else
+ ac_cv_decl_map_anon=no
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_decl_map_anon" >&5
+$as_echo "$ac_cv_decl_map_anon" >&6; }
+
+ if test $ac_cv_decl_map_anon = no; then
+ ac_cv_func_mmap_anon=no
+ else
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether mmap with MAP_ANON(YMOUS) works" >&5
+$as_echo_n "checking whether mmap with MAP_ANON(YMOUS) works... " >&6; }
+if ${ac_cv_func_mmap_anon+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ # Add a system to this blacklist if it has mmap() and MAP_ANON or
+ # MAP_ANONYMOUS, but using mmap(..., MAP_PRIVATE|MAP_ANONYMOUS, -1, 0)
+ # doesn't give anonymous zeroed pages with the same properties listed
+ # above for use of /dev/zero.
+ # Systems known to be in this category are Windows, VMS, and SCO Unix.
+ case "$host_os" in
+ vms* | cygwin* | pe | mingw* | sco* | udk* )
+ ac_cv_func_mmap_anon=no ;;
+ *)
+ ac_cv_func_mmap_anon=yes;;
+ esac
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_func_mmap_anon" >&5
+$as_echo "$ac_cv_func_mmap_anon" >&6; }
+ fi
+fi
+
+if test $ac_cv_func_mmap_file = yes; then
+
+$as_echo "#define HAVE_MMAP_FILE 1" >>confdefs.h
+
+fi
+if test $ac_cv_func_mmap_dev_zero = yes; then
+
+$as_echo "#define HAVE_MMAP_DEV_ZERO 1" >>confdefs.h
+
+fi
+if test $ac_cv_func_mmap_anon = yes; then
+
+$as_echo "#define HAVE_MMAP_ANON 1" >>confdefs.h
+
+fi
+
+
+ if test -d $srcdir/testsuite; then
+ TESTSUBDIR_TRUE=
+ TESTSUBDIR_FALSE='#'
+else
+ TESTSUBDIR_TRUE='#'
+ TESTSUBDIR_FALSE=
+fi
+
+
+TARGETDIR="unknown"
+HAVE_LONG_DOUBLE_VARIANT=0
+case "$host" in
+ aarch64*-*-*)
+ TARGET=AARCH64; TARGETDIR=aarch64
+ ;;
+
+ alpha*-*-*)
+ TARGET=ALPHA; TARGETDIR=alpha;
+ # Support 128-bit long double, changeable via command-line switch.
+ HAVE_LONG_DOUBLE='defined(__LONG_DOUBLE_128__)'
+ ;;
+
+ arc*-*-*)
+ TARGET=ARC; TARGETDIR=arc
+ ;;
+
+ arm*-*-*)
+ TARGET=ARM; TARGETDIR=arm
+ ;;
+
+ amd64-*-freebsd* | amd64-*-openbsd*)
+ TARGET=X86_64; TARGETDIR=x86
+ ;;
+
+ amd64-*-freebsd*)
+ TARGET=X86_64; TARGETDIR=x86
+ ;;
+
+ amd64-*-freebsd*)
+ TARGET=X86_64; TARGETDIR=x86
+ ;;
+
+ avr32*-*-*)
+ TARGET=AVR32; TARGETDIR=avr32
+ ;;
+
+ bfin*)
+ TARGET=BFIN; TARGETDIR=bfin
+ ;;
+
+ cris-*-*)
+ TARGET=LIBFFI_CRIS; TARGETDIR=cris
+ ;;
+
+ frv-*-*)
+ TARGET=FRV; TARGETDIR=frv
+ ;;
+
+ hppa*-*-linux* | parisc*-*-linux* | hppa*-*-openbsd*)
+ TARGET=PA_LINUX; TARGETDIR=pa
+ ;;
+ hppa*64-*-hpux*)
+ TARGET=PA64_HPUX; TARGETDIR=pa
+ ;;
+ hppa*-*-hpux*)
+ TARGET=PA_HPUX; TARGETDIR=pa
+ ;;
+
+ i?86-*-freebsd* | i?86-*-openbsd*)
+ TARGET=X86_FREEBSD; TARGETDIR=x86
+ ;;
+ i?86-win32* | i?86-*-cygwin* | i?86-*-mingw* | i?86-*-os2* | i?86-*-interix*)
+ TARGET=X86_WIN32; TARGETDIR=x86
+ # All mingw/cygwin/win32 builds require -no-undefined for sharedlib.
+ # We must also check with_cross_host to decide if this is a native
+ # or cross-build and select where to install dlls appropriately.
+ if test -n "$with_cross_host" &&
+ test x"$with_cross_host" != x"no"; then
+ AM_LTLDFLAGS='-no-undefined -bindir "$(toolexeclibdir)"';
+ else
+ AM_LTLDFLAGS='-no-undefined -bindir "$(bindir)"';
+ fi
+ ;;
+ i?86-*-darwin*)
+ TARGET=X86_DARWIN; TARGETDIR=x86
+ ;;
+ i?86-*-solaris2.1[0-9]*)
+ TARGETDIR=x86
+ if test $ac_cv_sizeof_size_t = 4; then
+ TARGET=X86;
+ else
+ TARGET=X86_64;
+ fi
+ ;;
+
+ x86_64-*-darwin*)
+ TARGET=X86_DARWIN; TARGETDIR=x86
+ ;;
+
+ x86_64-*-cygwin* | x86_64-*-mingw*)
+ TARGET=X86_WIN64; TARGETDIR=x86
+ # All mingw/cygwin/win32 builds require -no-undefined for sharedlib.
+ # We must also check with_cross_host to decide if this is a native
+ # or cross-build and select where to install dlls appropriately.
+ if test -n "$with_cross_host" &&
+ test x"$with_cross_host" != x"no"; then
+ AM_LTLDFLAGS='-no-undefined -bindir "$(toolexeclibdir)"';
+ else
+ AM_LTLDFLAGS='-no-undefined -bindir "$(bindir)"';
+ fi
+ ;;
+
+ i?86-*-* | x86_64-*-*)
+ TARGETDIR=x86
+ if test $ac_cv_sizeof_size_t = 4; then
+ case "$host" in
+ *-gnux32)
+ TARGET=X86_64
+ ;;
+ *)
+ TARGET=X86
+ ;;
+ esac
+ else
+ TARGET=X86_64;
+ fi
+ ;;
+
+ ia64*-*-*)
+ TARGET=IA64; TARGETDIR=ia64
+ ;;
+
+ m32r*-*-*)
+ TARGET=M32R; TARGETDIR=m32r
+ ;;
+
+ m68k-*-*)
+ TARGET=M68K; TARGETDIR=m68k
+ ;;
+
+ m88k-*-*)
+ TARGET=M88K; TARGETDIR=m88k
+ ;;
+
+ microblaze*-*-*)
+ TARGET=MICROBLAZE; TARGETDIR=microblaze
+ ;;
+
+ moxie-*-*)
+ TARGET=MOXIE; TARGETDIR=moxie
+ ;;
+
+ metag-*-*)
+ TARGET=METAG; TARGETDIR=metag
+ ;;
+
+ mips-sgi-irix5.* | mips-sgi-irix6.* | mips*-*-rtems*)
+ TARGET=MIPS; TARGETDIR=mips
+ ;;
+ mips*-*linux* | mips*-*-openbsd*)
+ # Support 128-bit long double for NewABI.
+ HAVE_LONG_DOUBLE='defined(__mips64)'
+ TARGET=MIPS; TARGETDIR=mips
+ ;;
+
+ nios2*-linux*)
+ TARGET=NIOS2; TARGETDIR=nios2
+ ;;
+
+ or1k*-linux*)
+ TARGET=OR1K; TARGETDIR=or1k
+ ;;
+
+ powerpc*-*-linux* | powerpc-*-sysv*)
+ TARGET=POWERPC; TARGETDIR=powerpc
+ HAVE_LONG_DOUBLE_VARIANT=1
+ ;;
+ powerpc-*-amigaos*)
+ TARGET=POWERPC; TARGETDIR=powerpc
+ ;;
+ powerpc-*-beos*)
+ TARGET=POWERPC; TARGETDIR=powerpc
+ ;;
+ powerpc-*-darwin* | powerpc64-*-darwin*)
+ TARGET=POWERPC_DARWIN; TARGETDIR=powerpc
+ ;;
+ powerpc-*-aix* | rs6000-*-aix*)
+ TARGET=POWERPC_AIX; TARGETDIR=powerpc
+ ;;
+ powerpc-*-freebsd* | powerpc-*-openbsd*)
+ TARGET=POWERPC_FREEBSD; TARGETDIR=powerpc
+ HAVE_LONG_DOUBLE_VARIANT=1
+ ;;
+ powerpc64-*-freebsd*)
+ TARGET=POWERPC; TARGETDIR=powerpc
+ ;;
+ powerpc*-*-rtems*)
+ TARGET=POWERPC; TARGETDIR=powerpc
+ ;;
+
+ s390-*-* | s390x-*-*)
+ TARGET=S390; TARGETDIR=s390
+ ;;
+
+ sh-*-* | sh[34]*-*-*)
+ TARGET=SH; TARGETDIR=sh
+ ;;
+ sh64-*-* | sh5*-*-*)
+ TARGET=SH64; TARGETDIR=sh64
+ ;;
+
+ sparc*-*-*)
+ TARGET=SPARC; TARGETDIR=sparc
+ ;;
+
+ tile*-*)
+ TARGET=TILE; TARGETDIR=tile
+ ;;
+
+ vax-*-*)
+ TARGET=VAX; TARGETDIR=vax
+ ;;
+
+ xtensa*-*)
+ TARGET=XTENSA; TARGETDIR=xtensa
+ ;;
+
+esac
+
+
+
+
+if test $TARGETDIR = unknown; then
+ as_fn_error $? "\"libffi has not been ported to $host.\"" "$LINENO" 5
+fi
+
+ if test x$TARGET = xMIPS; then
+ MIPS_TRUE=
+ MIPS_FALSE='#'
+else
+ MIPS_TRUE='#'
+ MIPS_FALSE=
+fi
+
+ if test x$TARGET = xBFIN; then
+ BFIN_TRUE=
+ BFIN_FALSE='#'
+else
+ BFIN_TRUE='#'
+ BFIN_FALSE=
+fi
+
+ if test x$TARGET = xSPARC; then
+ SPARC_TRUE=
+ SPARC_FALSE='#'
+else
+ SPARC_TRUE='#'
+ SPARC_FALSE=
+fi
+
+ if test x$TARGET = xX86; then
+ X86_TRUE=
+ X86_FALSE='#'
+else
+ X86_TRUE='#'
+ X86_FALSE=
+fi
+
+ if test x$TARGET = xX86_FREEBSD; then
+ X86_FREEBSD_TRUE=
+ X86_FREEBSD_FALSE='#'
+else
+ X86_FREEBSD_TRUE='#'
+ X86_FREEBSD_FALSE=
+fi
+
+ if test x$TARGET = xX86_WIN32; then
+ X86_WIN32_TRUE=
+ X86_WIN32_FALSE='#'
+else
+ X86_WIN32_TRUE='#'
+ X86_WIN32_FALSE=
+fi
+
+ if test x$TARGET = xX86_WIN64; then
+ X86_WIN64_TRUE=
+ X86_WIN64_FALSE='#'
+else
+ X86_WIN64_TRUE='#'
+ X86_WIN64_FALSE=
+fi
+
+ if test x$TARGET = xX86_DARWIN; then
+ X86_DARWIN_TRUE=
+ X86_DARWIN_FALSE='#'
+else
+ X86_DARWIN_TRUE='#'
+ X86_DARWIN_FALSE=
+fi
+
+ if test x$TARGET = xX86_DARWIN && test $ac_cv_sizeof_size_t = 4; then
+ X86_DARWIN32_TRUE=
+ X86_DARWIN32_FALSE='#'
+else
+ X86_DARWIN32_TRUE='#'
+ X86_DARWIN32_FALSE=
+fi
+
+ if test x$TARGET = xX86_DARWIN && test $ac_cv_sizeof_size_t = 8; then
+ X86_DARWIN64_TRUE=
+ X86_DARWIN64_FALSE='#'
+else
+ X86_DARWIN64_TRUE='#'
+ X86_DARWIN64_FALSE=
+fi
+
+ if test x$TARGET = xALPHA; then
+ ALPHA_TRUE=
+ ALPHA_FALSE='#'
+else
+ ALPHA_TRUE='#'
+ ALPHA_FALSE=
+fi
+
+ if test x$TARGET = xIA64; then
+ IA64_TRUE=
+ IA64_FALSE='#'
+else
+ IA64_TRUE='#'
+ IA64_FALSE=
+fi
+
+ if test x$TARGET = xM32R; then
+ M32R_TRUE=
+ M32R_FALSE='#'
+else
+ M32R_TRUE='#'
+ M32R_FALSE=
+fi
+
+ if test x$TARGET = xM68K; then
+ M68K_TRUE=
+ M68K_FALSE='#'
+else
+ M68K_TRUE='#'
+ M68K_FALSE=
+fi
+
+ if test x$TARGET = xM88K; then
+ M88K_TRUE=
+ M88K_FALSE='#'
+else
+ M88K_TRUE='#'
+ M88K_FALSE=
+fi
+
+ if test x$TARGET = xMICROBLAZE; then
+ MICROBLAZE_TRUE=
+ MICROBLAZE_FALSE='#'
+else
+ MICROBLAZE_TRUE='#'
+ MICROBLAZE_FALSE=
+fi
+
+ if test x$TARGET = xMETAG; then
+ METAG_TRUE=
+ METAG_FALSE='#'
+else
+ METAG_TRUE='#'
+ METAG_FALSE=
+fi
+
+ if test x$TARGET = xMOXIE; then
+ MOXIE_TRUE=
+ MOXIE_FALSE='#'
+else
+ MOXIE_TRUE='#'
+ MOXIE_FALSE=
+fi
+
+ if test x$TARGET = xNIOS2; then
+ NIOS2_TRUE=
+ NIOS2_FALSE='#'
+else
+ NIOS2_TRUE='#'
+ NIOS2_FALSE=
+fi
+
+ if test x$TARGET = xOR1K; then
+ OR1K_TRUE=
+ OR1K_FALSE='#'
+else
+ OR1K_TRUE='#'
+ OR1K_FALSE=
+fi
+
+ if test x$TARGET = xPOWERPC; then
+ POWERPC_TRUE=
+ POWERPC_FALSE='#'
+else
+ POWERPC_TRUE='#'
+ POWERPC_FALSE=
+fi
+
+ if test x$TARGET = xPOWERPC_AIX; then
+ POWERPC_AIX_TRUE=
+ POWERPC_AIX_FALSE='#'
+else
+ POWERPC_AIX_TRUE='#'
+ POWERPC_AIX_FALSE=
+fi
+
+ if test x$TARGET = xPOWERPC_DARWIN; then
+ POWERPC_DARWIN_TRUE=
+ POWERPC_DARWIN_FALSE='#'
+else
+ POWERPC_DARWIN_TRUE='#'
+ POWERPC_DARWIN_FALSE=
+fi
+
+ if test x$TARGET = xPOWERPC_FREEBSD; then
+ POWERPC_FREEBSD_TRUE=
+ POWERPC_FREEBSD_FALSE='#'
+else
+ POWERPC_FREEBSD_TRUE='#'
+ POWERPC_FREEBSD_FALSE=
+fi
+
+ if test x$TARGET = xAARCH64; then
+ AARCH64_TRUE=
+ AARCH64_FALSE='#'
+else
+ AARCH64_TRUE='#'
+ AARCH64_FALSE=
+fi
+
+ if test x$TARGET = xARC; then
+ ARC_TRUE=
+ ARC_FALSE='#'
+else
+ ARC_TRUE='#'
+ ARC_FALSE=
+fi
+
+ if test x$TARGET = xARM; then
+ ARM_TRUE=
+ ARM_FALSE='#'
+else
+ ARM_TRUE='#'
+ ARM_FALSE=
+fi
+
+ if test x$TARGET = xAVR32; then
+ AVR32_TRUE=
+ AVR32_FALSE='#'
+else
+ AVR32_TRUE='#'
+ AVR32_FALSE=
+fi
+
+ if test x$TARGET = xLIBFFI_CRIS; then
+ LIBFFI_CRIS_TRUE=
+ LIBFFI_CRIS_FALSE='#'
+else
+ LIBFFI_CRIS_TRUE='#'
+ LIBFFI_CRIS_FALSE=
+fi
+
+ if test x$TARGET = xFRV; then
+ FRV_TRUE=
+ FRV_FALSE='#'
+else
+ FRV_TRUE='#'
+ FRV_FALSE=
+fi
+
+ if test x$TARGET = xS390; then
+ S390_TRUE=
+ S390_FALSE='#'
+else
+ S390_TRUE='#'
+ S390_FALSE=
+fi
+
+ if test x$TARGET = xX86_64; then
+ X86_64_TRUE=
+ X86_64_FALSE='#'
+else
+ X86_64_TRUE='#'
+ X86_64_FALSE=
+fi
+
+ if test x$TARGET = xSH; then
+ SH_TRUE=
+ SH_FALSE='#'
+else
+ SH_TRUE='#'
+ SH_FALSE=
+fi
+
+ if test x$TARGET = xSH64; then
+ SH64_TRUE=
+ SH64_FALSE='#'
+else
+ SH64_TRUE='#'
+ SH64_FALSE=
+fi
+
+ if test x$TARGET = xPA_LINUX; then
+ PA_LINUX_TRUE=
+ PA_LINUX_FALSE='#'
+else
+ PA_LINUX_TRUE='#'
+ PA_LINUX_FALSE=
+fi
+
+ if test x$TARGET = xPA_HPUX; then
+ PA_HPUX_TRUE=
+ PA_HPUX_FALSE='#'
+else
+ PA_HPUX_TRUE='#'
+ PA_HPUX_FALSE=
+fi
+
+ if test x$TARGET = xPA64_HPUX; then
+ PA64_HPUX_TRUE=
+ PA64_HPUX_FALSE='#'
+else
+ PA64_HPUX_TRUE='#'
+ PA64_HPUX_FALSE=
+fi
+
+ if test x$TARGET = xTILE; then
+ TILE_TRUE=
+ TILE_FALSE='#'
+else
+ TILE_TRUE='#'
+ TILE_FALSE=
+fi
+
+ if test x$TARGET = xVAX; then
+ VAX_TRUE=
+ VAX_FALSE='#'
+else
+ VAX_TRUE='#'
+ VAX_FALSE=
+fi
+
+ if test x$TARGET = xXTENSA; then
+ XTENSA_TRUE=
+ XTENSA_FALSE='#'
+else
+ XTENSA_TRUE='#'
+ XTENSA_FALSE=
+fi
+
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for ANSI C header files" >&5
+$as_echo_n "checking for ANSI C header files... " >&6; }
+if ${ac_cv_header_stdc+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+#include <stdlib.h>
+#include <stdarg.h>
+#include <string.h>
+#include <float.h>
+
+int
+main ()
+{
+
+ ;
+ return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+ ac_cv_header_stdc=yes
+else
+ ac_cv_header_stdc=no
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+
+if test $ac_cv_header_stdc = yes; then
+ # SunOS 4.x string.h does not declare mem*, contrary to ANSI.
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+#include <string.h>
+
+_ACEOF
+if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
+ $EGREP "memchr" >/dev/null 2>&1; then :
+
+else
+ ac_cv_header_stdc=no
+fi
+rm -f conftest*
+
+fi
+
+if test $ac_cv_header_stdc = yes; then
+ # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI.
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+#include <stdlib.h>
+
+_ACEOF
+if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
+ $EGREP "free" >/dev/null 2>&1; then :
+
+else
+ ac_cv_header_stdc=no
+fi
+rm -f conftest*
+
+fi
+
+if test $ac_cv_header_stdc = yes; then
+ # /bin/cc in Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi.
+ if test "$cross_compiling" = yes; then :
+ :
+else
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+#include <ctype.h>
+#include <stdlib.h>
+#if ((' ' & 0x0FF) == 0x020)
+# define ISLOWER(c) ('a' <= (c) && (c) <= 'z')
+# define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c))
+#else
+# define ISLOWER(c) \
+ (('a' <= (c) && (c) <= 'i') \
+ || ('j' <= (c) && (c) <= 'r') \
+ || ('s' <= (c) && (c) <= 'z'))
+# define TOUPPER(c) (ISLOWER(c) ? ((c) | 0x40) : (c))
+#endif
+
+#define XOR(e, f) (((e) && !(f)) || (!(e) && (f)))
+int
+main ()
+{
+ int i;
+ for (i = 0; i < 256; i++)
+ if (XOR (islower (i), ISLOWER (i))
+ || toupper (i) != TOUPPER (i))
+ return 2;
+ return 0;
+}
+_ACEOF
+if ac_fn_c_try_run "$LINENO"; then :
+
+else
+ ac_cv_header_stdc=no
+fi
+rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
+ conftest.$ac_objext conftest.beam conftest.$ac_ext
+fi
+
+fi
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_header_stdc" >&5
+$as_echo "$ac_cv_header_stdc" >&6; }
+if test $ac_cv_header_stdc = yes; then
+
+$as_echo "#define STDC_HEADERS 1" >>confdefs.h
+
+fi
+
+for ac_func in memcpy
+do :
+ ac_fn_c_check_func "$LINENO" "memcpy" "ac_cv_func_memcpy"
+if test "x$ac_cv_func_memcpy" = xyes; then :
+ cat >>confdefs.h <<_ACEOF
+#define HAVE_MEMCPY 1
+_ACEOF
+
+fi
+done
+
+ac_fn_c_check_type "$LINENO" "size_t" "ac_cv_type_size_t" "$ac_includes_default"
+if test "x$ac_cv_type_size_t" = xyes; then :
+
+else
+
+cat >>confdefs.h <<_ACEOF
+#define size_t unsigned int
+_ACEOF
+
+fi
+
+# The Ultrix 4.2 mips builtin alloca declared by alloca.h only works
+# for constant arguments. Useless!
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for working alloca.h" >&5
+$as_echo_n "checking for working alloca.h... " >&6; }
+if ${ac_cv_working_alloca_h+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+#include <alloca.h>
+int
+main ()
+{
+char *p = (char *) alloca (2 * sizeof (int));
+ if (p) return 0;
+ ;
+ return 0;
+}
+_ACEOF
+if ac_fn_c_try_link "$LINENO"; then :
+ ac_cv_working_alloca_h=yes
+else
+ ac_cv_working_alloca_h=no
+fi
+rm -f core conftest.err conftest.$ac_objext \
+ conftest$ac_exeext conftest.$ac_ext
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_working_alloca_h" >&5
+$as_echo "$ac_cv_working_alloca_h" >&6; }
+if test $ac_cv_working_alloca_h = yes; then
+
+$as_echo "#define HAVE_ALLOCA_H 1" >>confdefs.h
+
+fi
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for alloca" >&5
+$as_echo_n "checking for alloca... " >&6; }
+if ${ac_cv_func_alloca_works+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+#ifdef __GNUC__
+# define alloca __builtin_alloca
+#else
+# ifdef _MSC_VER
+# include <malloc.h>
+# define alloca _alloca
+# else
+# ifdef HAVE_ALLOCA_H
+# include <alloca.h>
+# else
+# ifdef _AIX
+ #pragma alloca
+# else
+# ifndef alloca /* predefined by HP cc +Olibcalls */
+void *alloca (size_t);
+# endif
+# endif
+# endif
+# endif
+#endif
+
+int
+main ()
+{
+char *p = (char *) alloca (1);
+ if (p) return 0;
+ ;
+ return 0;
+}
+_ACEOF
+if ac_fn_c_try_link "$LINENO"; then :
+ ac_cv_func_alloca_works=yes
+else
+ ac_cv_func_alloca_works=no
+fi
+rm -f core conftest.err conftest.$ac_objext \
+ conftest$ac_exeext conftest.$ac_ext
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_func_alloca_works" >&5
+$as_echo "$ac_cv_func_alloca_works" >&6; }
+
+if test $ac_cv_func_alloca_works = yes; then
+
+$as_echo "#define HAVE_ALLOCA 1" >>confdefs.h
+
+else
+ # The SVR3 libPW and SVR4 libucb both contain incompatible functions
+# that cause trouble. Some versions do not even contain alloca or
+# contain a buggy version. If you still want to use their alloca,
+# use ar to extract alloca.o from them instead of compiling alloca.c.
+
+ALLOCA=\${LIBOBJDIR}alloca.$ac_objext
+
+$as_echo "#define C_ALLOCA 1" >>confdefs.h
+
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether \`alloca.c' needs Cray hooks" >&5
+$as_echo_n "checking whether \`alloca.c' needs Cray hooks... " >&6; }
+if ${ac_cv_os_cray+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+#if defined CRAY && ! defined CRAY2
+webecray
+#else
+wenotbecray
+#endif
+
+_ACEOF
+if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
+ $EGREP "webecray" >/dev/null 2>&1; then :
+ ac_cv_os_cray=yes
+else
+ ac_cv_os_cray=no
+fi
+rm -f conftest*
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_os_cray" >&5
+$as_echo "$ac_cv_os_cray" >&6; }
+if test $ac_cv_os_cray = yes; then
+ for ac_func in _getb67 GETB67 getb67; do
+ as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh`
+ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var"
+if eval test \"x\$"$as_ac_var"\" = x"yes"; then :
+
+cat >>confdefs.h <<_ACEOF
+#define CRAY_STACKSEG_END $ac_func
+_ACEOF
+
+ break
+fi
+
+ done
+fi
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking stack direction for C alloca" >&5
+$as_echo_n "checking stack direction for C alloca... " >&6; }
+if ${ac_cv_c_stack_direction+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ if test "$cross_compiling" = yes; then :
+ ac_cv_c_stack_direction=0
+else
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+$ac_includes_default
+int
+find_stack_direction (int *addr, int depth)
+{
+ int dir, dummy = 0;
+ if (! addr)
+ addr = &dummy;
+ *addr = addr < &dummy ? 1 : addr == &dummy ? 0 : -1;
+ dir = depth ? find_stack_direction (addr, depth - 1) : 0;
+ return dir + dummy;
+}
+
+int
+main (int argc, char **argv)
+{
+ return find_stack_direction (0, argc + !argv + 20) < 0;
+}
+_ACEOF
+if ac_fn_c_try_run "$LINENO"; then :
+ ac_cv_c_stack_direction=1
+else
+ ac_cv_c_stack_direction=-1
+fi
+rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
+ conftest.$ac_objext conftest.beam conftest.$ac_ext
+fi
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_stack_direction" >&5
+$as_echo "$ac_cv_c_stack_direction" >&6; }
+cat >>confdefs.h <<_ACEOF
+#define STACK_DIRECTION $ac_cv_c_stack_direction
+_ACEOF
+
+
+fi
+
+
+# The cast to long int works around a bug in the HP C Compiler
+# version HP92453-01 B.11.11.23709.GP, which incorrectly rejects
+# declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'.
+# This bug is HP SR number 8606223364.
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking size of double" >&5
+$as_echo_n "checking size of double... " >&6; }
+if ${ac_cv_sizeof_double+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ if ac_fn_c_compute_int "$LINENO" "(long int) (sizeof (double))" "ac_cv_sizeof_double" "$ac_includes_default"; then :
+
+else
+ if test "$ac_cv_type_double" = yes; then
+ { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
+$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
+as_fn_error 77 "cannot compute sizeof (double)
+See \`config.log' for more details" "$LINENO" 5; }
+ else
+ ac_cv_sizeof_double=0
+ fi
+fi
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_sizeof_double" >&5
+$as_echo "$ac_cv_sizeof_double" >&6; }
+
+
+
+cat >>confdefs.h <<_ACEOF
+#define SIZEOF_DOUBLE $ac_cv_sizeof_double
+_ACEOF
+
+
+# The cast to long int works around a bug in the HP C Compiler
+# version HP92453-01 B.11.11.23709.GP, which incorrectly rejects
+# declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'.
+# This bug is HP SR number 8606223364.
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking size of long double" >&5
+$as_echo_n "checking size of long double... " >&6; }
+if ${ac_cv_sizeof_long_double+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ if ac_fn_c_compute_int "$LINENO" "(long int) (sizeof (long double))" "ac_cv_sizeof_long_double" "$ac_includes_default"; then :
+
+else
+ if test "$ac_cv_type_long_double" = yes; then
+ { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
+$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
+as_fn_error 77 "cannot compute sizeof (long double)
+See \`config.log' for more details" "$LINENO" 5; }
+ else
+ ac_cv_sizeof_long_double=0
+ fi
+fi
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_sizeof_long_double" >&5
+$as_echo "$ac_cv_sizeof_long_double" >&6; }
+
+
+
+cat >>confdefs.h <<_ACEOF
+#define SIZEOF_LONG_DOUBLE $ac_cv_sizeof_long_double
+_ACEOF
+
+
+
+# Also AC_SUBST this variable for ffi.h.
+if test -z "$HAVE_LONG_DOUBLE"; then
+ HAVE_LONG_DOUBLE=0
+ if test $ac_cv_sizeof_long_double != 0; then
+ if test $HAVE_LONG_DOUBLE_VARIANT != 0; then
+
+$as_echo "#define HAVE_LONG_DOUBLE_VARIANT 1" >>confdefs.h
+
+ HAVE_LONG_DOUBLE=1
+ else
+ if test $ac_cv_sizeof_double != $ac_cv_sizeof_long_double; then
+ HAVE_LONG_DOUBLE=1
+
+$as_echo "#define HAVE_LONG_DOUBLE 1" >>confdefs.h
+
+ fi
+ fi
+ fi
+fi
+
+
+
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether byte ordering is bigendian" >&5
+$as_echo_n "checking whether byte ordering is bigendian... " >&6; }
+if ${ac_cv_c_bigendian+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ ac_cv_c_bigendian=unknown
+ # See if we're dealing with a universal compiler.
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+#ifndef __APPLE_CC__
+ not a universal capable compiler
+ #endif
+ typedef int dummy;
+
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+
+ # Check for potential -arch flags. It is not universal unless
+ # there are at least two -arch flags with different values.
+ ac_arch=
+ ac_prev=
+ for ac_word in $CC $CFLAGS $CPPFLAGS $LDFLAGS; do
+ if test -n "$ac_prev"; then
+ case $ac_word in
+ i?86 | x86_64 | ppc | ppc64)
+ if test -z "$ac_arch" || test "$ac_arch" = "$ac_word"; then
+ ac_arch=$ac_word
+ else
+ ac_cv_c_bigendian=universal
+ break
+ fi
+ ;;
+ esac
+ ac_prev=
+ elif test "x$ac_word" = "x-arch"; then
+ ac_prev=arch
+ fi
+ done
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+ if test $ac_cv_c_bigendian = unknown; then
+ # See if sys/param.h defines the BYTE_ORDER macro.
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+#include <sys/types.h>
+ #include <sys/param.h>
+
+int
+main ()
+{
+#if ! (defined BYTE_ORDER && defined BIG_ENDIAN \
+ && defined LITTLE_ENDIAN && BYTE_ORDER && BIG_ENDIAN \
+ && LITTLE_ENDIAN)
+ bogus endian macros
+ #endif
+
+ ;
+ return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+ # It does; now see whether it defined to BIG_ENDIAN or not.
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+#include <sys/types.h>
+ #include <sys/param.h>
+
+int
+main ()
+{
+#if BYTE_ORDER != BIG_ENDIAN
+ not big endian
+ #endif
+
+ ;
+ return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+ ac_cv_c_bigendian=yes
+else
+ ac_cv_c_bigendian=no
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+ fi
+ if test $ac_cv_c_bigendian = unknown; then
+ # See if <limits.h> defines _LITTLE_ENDIAN or _BIG_ENDIAN (e.g., Solaris).
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+#include <limits.h>
+
+int
+main ()
+{
+#if ! (defined _LITTLE_ENDIAN || defined _BIG_ENDIAN)
+ bogus endian macros
+ #endif
+
+ ;
+ return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+ # It does; now see whether it defined to _BIG_ENDIAN or not.
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+#include <limits.h>
+
+int
+main ()
+{
+#ifndef _BIG_ENDIAN
+ not big endian
+ #endif
+
+ ;
+ return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+ ac_cv_c_bigendian=yes
+else
+ ac_cv_c_bigendian=no
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+ fi
+ if test $ac_cv_c_bigendian = unknown; then
+ # Compile a test program.
+ if test "$cross_compiling" = yes; then :
+ # Try to guess by grepping values from an object file.
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+short int ascii_mm[] =
+ { 0x4249, 0x4765, 0x6E44, 0x6961, 0x6E53, 0x7953, 0 };
+ short int ascii_ii[] =
+ { 0x694C, 0x5454, 0x656C, 0x6E45, 0x6944, 0x6E61, 0 };
+ int use_ascii (int i) {
+ return ascii_mm[i] + ascii_ii[i];
+ }
+ short int ebcdic_ii[] =
+ { 0x89D3, 0xE3E3, 0x8593, 0x95C5, 0x89C4, 0x9581, 0 };
+ short int ebcdic_mm[] =
+ { 0xC2C9, 0xC785, 0x95C4, 0x8981, 0x95E2, 0xA8E2, 0 };
+ int use_ebcdic (int i) {
+ return ebcdic_mm[i] + ebcdic_ii[i];
+ }
+ extern int foo;
+
+int
+main ()
+{
+return use_ascii (foo) == use_ebcdic (foo);
+ ;
+ return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+ if grep BIGenDianSyS conftest.$ac_objext >/dev/null; then
+ ac_cv_c_bigendian=yes
+ fi
+ if grep LiTTleEnDian conftest.$ac_objext >/dev/null ; then
+ if test "$ac_cv_c_bigendian" = unknown; then
+ ac_cv_c_bigendian=no
+ else
+ # finding both strings is unlikely to happen, but who knows?
+ ac_cv_c_bigendian=unknown
+ fi
+ fi
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+else
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+$ac_includes_default
+int
+main ()
+{
+
+ /* Are we little or big endian? From Harbison&Steele. */
+ union
+ {
+ long int l;
+ char c[sizeof (long int)];
+ } u;
+ u.l = 1;
+ return u.c[sizeof (long int) - 1] == 1;
+
+ ;
+ return 0;
+}
+_ACEOF
+if ac_fn_c_try_run "$LINENO"; then :
+ ac_cv_c_bigendian=no
+else
+ ac_cv_c_bigendian=yes
+fi
+rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
+ conftest.$ac_objext conftest.beam conftest.$ac_ext
+fi
+
+ fi
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_bigendian" >&5
+$as_echo "$ac_cv_c_bigendian" >&6; }
+ case $ac_cv_c_bigendian in #(
+ yes)
+ $as_echo "#define WORDS_BIGENDIAN 1" >>confdefs.h
+;; #(
+ no)
+ ;; #(
+ universal)
+
+$as_echo "#define AC_APPLE_UNIVERSAL_BUILD 1" >>confdefs.h
+
+ ;; #(
+ *)
+ as_fn_error $? "unknown endianness
+ presetting ac_cv_c_bigendian=no (or yes) will help" "$LINENO" 5 ;;
+ esac
+
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking assembler .cfi pseudo-op support" >&5
+$as_echo_n "checking assembler .cfi pseudo-op support... " >&6; }
+if ${gcc_cv_as_cfi_pseudo_op+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+
+ gcc_cv_as_cfi_pseudo_op=unknown
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+asm (".cfi_startproc\n\t.cfi_endproc");
+int
+main ()
+{
+
+ ;
+ return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+ gcc_cv_as_cfi_pseudo_op=yes
+else
+ gcc_cv_as_cfi_pseudo_op=no
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gcc_cv_as_cfi_pseudo_op" >&5
+$as_echo "$gcc_cv_as_cfi_pseudo_op" >&6; }
+ if test "x$gcc_cv_as_cfi_pseudo_op" = xyes; then
+
+$as_echo "#define HAVE_AS_CFI_PSEUDO_OP 1" >>confdefs.h
+
+ fi
+
+
+if test x$TARGET = xSPARC; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking assembler and linker support unaligned pc related relocs" >&5
+$as_echo_n "checking assembler and linker support unaligned pc related relocs... " >&6; }
+if ${libffi_cv_as_sparc_ua_pcrel+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+
+ save_CFLAGS="$CFLAGS"
+ save_LDFLAGS="$LDFLAGS"
+ CFLAGS="$CFLAGS -fpic"
+ LDFLAGS="$LDFLAGS -shared"
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+asm (".text; foo: nop; .data; .align 4; .byte 0; .uaword %r_disp32(foo); .text");
+int
+main ()
+{
+
+ ;
+ return 0;
+}
+_ACEOF
+if ac_fn_c_try_link "$LINENO"; then :
+ libffi_cv_as_sparc_ua_pcrel=yes
+else
+ libffi_cv_as_sparc_ua_pcrel=no
+fi
+rm -f core conftest.err conftest.$ac_objext \
+ conftest$ac_exeext conftest.$ac_ext
+ CFLAGS="$save_CFLAGS"
+ LDFLAGS="$save_LDFLAGS"
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $libffi_cv_as_sparc_ua_pcrel" >&5
+$as_echo "$libffi_cv_as_sparc_ua_pcrel" >&6; }
+ if test "x$libffi_cv_as_sparc_ua_pcrel" = xyes; then
+
+$as_echo "#define HAVE_AS_SPARC_UA_PCREL 1" >>confdefs.h
+
+ fi
+
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking assembler .register pseudo-op support" >&5
+$as_echo_n "checking assembler .register pseudo-op support... " >&6; }
+if ${libffi_cv_as_register_pseudo_op+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+
+ libffi_cv_as_register_pseudo_op=unknown
+ # Check if we have .register
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+
+int
+main ()
+{
+asm (".register %g2, #scratch");
+ ;
+ return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+ libffi_cv_as_register_pseudo_op=yes
+else
+ libffi_cv_as_register_pseudo_op=no
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $libffi_cv_as_register_pseudo_op" >&5
+$as_echo "$libffi_cv_as_register_pseudo_op" >&6; }
+ if test "x$libffi_cv_as_register_pseudo_op" = xyes; then
+
+$as_echo "#define HAVE_AS_REGISTER_PSEUDO_OP 1" >>confdefs.h
+
+ fi
+fi
+
+if test x$TARGET = xX86 || test x$TARGET = xX86_WIN32 || test x$TARGET = xX86_64; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking assembler supports pc related relocs" >&5
+$as_echo_n "checking assembler supports pc related relocs... " >&6; }
+if ${libffi_cv_as_x86_pcrel+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+
+ libffi_cv_as_x86_pcrel=no
+ echo '.text; foo: nop; .data; .long foo-.; .text' > conftest.s
+ if $CC $CFLAGS -c conftest.s > /dev/null 2>&1; then
+ libffi_cv_as_x86_pcrel=yes
+ fi
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $libffi_cv_as_x86_pcrel" >&5
+$as_echo "$libffi_cv_as_x86_pcrel" >&6; }
+ if test "x$libffi_cv_as_x86_pcrel" = xyes; then
+
+$as_echo "#define HAVE_AS_X86_PCREL 1" >>confdefs.h
+
+ fi
+
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking assembler .ascii pseudo-op support" >&5
+$as_echo_n "checking assembler .ascii pseudo-op support... " >&6; }
+if ${libffi_cv_as_ascii_pseudo_op+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+
+ libffi_cv_as_ascii_pseudo_op=unknown
+ # Check if we have .ascii
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+
+int
+main ()
+{
+asm (".ascii \\"string\\"");
+ ;
+ return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+ libffi_cv_as_ascii_pseudo_op=yes
+else
+ libffi_cv_as_ascii_pseudo_op=no
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $libffi_cv_as_ascii_pseudo_op" >&5
+$as_echo "$libffi_cv_as_ascii_pseudo_op" >&6; }
+ if test "x$libffi_cv_as_ascii_pseudo_op" = xyes; then
+
+$as_echo "#define HAVE_AS_ASCII_PSEUDO_OP 1" >>confdefs.h
+
+ fi
+
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking assembler .string pseudo-op support" >&5
+$as_echo_n "checking assembler .string pseudo-op support... " >&6; }
+if ${libffi_cv_as_string_pseudo_op+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+
+ libffi_cv_as_string_pseudo_op=unknown
+ # Check if we have .string
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+
+int
+main ()
+{
+asm (".string \\"string\\"");
+ ;
+ return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+ libffi_cv_as_string_pseudo_op=yes
+else
+ libffi_cv_as_string_pseudo_op=no
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $libffi_cv_as_string_pseudo_op" >&5
+$as_echo "$libffi_cv_as_string_pseudo_op" >&6; }
+ if test "x$libffi_cv_as_string_pseudo_op" = xyes; then
+
+$as_echo "#define HAVE_AS_STRING_PSEUDO_OP 1" >>confdefs.h
+
+ fi
+fi
+
+# On PaX enable kernels that have MPROTECT enable we can't use PROT_EXEC.
+# Check whether --enable-pax_emutramp was given.
+if test "${enable_pax_emutramp+set}" = set; then :
+ enableval=$enable_pax_emutramp; if test "$enable_pax_emutramp" = "yes"; then
+
+$as_echo "#define FFI_MMAP_EXEC_EMUTRAMP_PAX 1" >>confdefs.h
+
+ fi
+fi
+
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for _ prefix in compiled symbols" >&5
+$as_echo_n "checking for _ prefix in compiled symbols... " >&6; }
+if ${lt_cv_sys_symbol_underscore+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ lt_cv_sys_symbol_underscore=no
+ cat > conftest.$ac_ext <<_LT_EOF
+void nm_test_func(){}
+int main(){nm_test_func;return 0;}
+_LT_EOF
+ if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5
+ (eval $ac_compile) 2>&5
+ ac_status=$?
+ $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+ test $ac_status = 0; }; then
+ # Now try to grab the symbols.
+ ac_nlist=conftest.nm
+ if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$NM conftest.$ac_objext \| $lt_cv_sys_global_symbol_pipe \> $ac_nlist\""; } >&5
+ (eval $NM conftest.$ac_objext \| $lt_cv_sys_global_symbol_pipe \> $ac_nlist) 2>&5
+ ac_status=$?
+ $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+ test $ac_status = 0; } && test -s "$ac_nlist"; then
+ # See whether the symbols have a leading underscore.
+ if grep '^. _nm_test_func' "$ac_nlist" >/dev/null; then
+ lt_cv_sys_symbol_underscore=yes
+ else
+ if grep '^. nm_test_func ' "$ac_nlist" >/dev/null; then
+ :
+ else
+ echo "configure: cannot find nm_test_func in $ac_nlist" >&5
+ fi
+ fi
+ else
+ echo "configure: cannot run $lt_cv_sys_global_symbol_pipe" >&5
+ fi
+ else
+ echo "configure: failed program was:" >&5
+ cat conftest.c >&5
+ fi
+ rm -rf conftest*
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_sys_symbol_underscore" >&5
+$as_echo "$lt_cv_sys_symbol_underscore" >&6; }
+ sys_symbol_underscore=$lt_cv_sys_symbol_underscore
+
+
+if test "x$sys_symbol_underscore" = xyes; then
+
+$as_echo "#define SYMBOL_UNDERSCORE 1" >>confdefs.h
+
+fi
+
+FFI_EXEC_TRAMPOLINE_TABLE=0
+case "$target" in
+ *arm*-apple-darwin*)
+ FFI_EXEC_TRAMPOLINE_TABLE=1
+
+$as_echo "#define FFI_EXEC_TRAMPOLINE_TABLE 1" >>confdefs.h
+
+ ;;
+ *-apple-darwin1* | *-*-freebsd* | *-*-kfreebsd* | *-*-openbsd* | *-pc-solaris*)
+
+$as_echo "#define FFI_MMAP_EXEC_WRIT 1" >>confdefs.h
+
+ ;;
+esac
+ if test x$FFI_EXEC_TRAMPOLINE_TABLE = x1; then
+ FFI_EXEC_TRAMPOLINE_TABLE_TRUE=
+ FFI_EXEC_TRAMPOLINE_TABLE_FALSE='#'
+else
+ FFI_EXEC_TRAMPOLINE_TABLE_TRUE='#'
+ FFI_EXEC_TRAMPOLINE_TABLE_FALSE=
+fi
+
+
+
+if test x$TARGET = xX86_64; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking toolchain supports unwind section type" >&5
+$as_echo_n "checking toolchain supports unwind section type... " >&6; }
+if ${libffi_cv_as_x86_64_unwind_section_type+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+
+ cat > conftest1.s << EOF
+.text
+.globl foo
+foo:
+jmp bar
+.section .eh_frame,"a",@unwind
+bar:
+EOF
+
+ cat > conftest2.c << EOF
+extern void foo();
+int main(){foo();}
+EOF
+
+ libffi_cv_as_x86_64_unwind_section_type=no
+ # we ensure that we can compile _and_ link an assembly file containing an @unwind section
+ # since the compiler can support it and not the linker (ie old binutils)
+ if $CC -Wa,--fatal-warnings $CFLAGS -c conftest1.s > /dev/null 2>&1 && \
+ $CC conftest2.c conftest1.o > /dev/null 2>&1 ; then
+ libffi_cv_as_x86_64_unwind_section_type=yes
+ fi
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $libffi_cv_as_x86_64_unwind_section_type" >&5
+$as_echo "$libffi_cv_as_x86_64_unwind_section_type" >&6; }
+ if test "x$libffi_cv_as_x86_64_unwind_section_type" = xyes; then
+
+$as_echo "#define HAVE_AS_X86_64_UNWIND_SECTION_TYPE 1" >>confdefs.h
+
+ fi
+fi
+
+if test "x$GCC" = "xyes"; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether .eh_frame section should be read-only" >&5
+$as_echo_n "checking whether .eh_frame section should be read-only... " >&6; }
+if ${libffi_cv_ro_eh_frame+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+
+ libffi_cv_ro_eh_frame=no
+ echo 'extern void foo (void); void bar (void) { foo (); foo (); }' > conftest.c
+ if $CC $CFLAGS -c -fpic -fexceptions -o conftest.o conftest.c > /dev/null 2>&1; then
+ objdump -h conftest.o > conftest.dump 2>&1
+ libffi_eh_frame_line=`grep -n eh_frame conftest.dump | cut -d: -f 1`
+ libffi_test_line=`expr $libffi_eh_frame_line + 1`p
+ sed -n $libffi_test_line conftest.dump > conftest.line
+ if grep READONLY conftest.line > /dev/null; then
+ libffi_cv_ro_eh_frame=yes
+ fi
+ fi
+ rm -f conftest.*
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $libffi_cv_ro_eh_frame" >&5
+$as_echo "$libffi_cv_ro_eh_frame" >&6; }
+ if test "x$libffi_cv_ro_eh_frame" = xyes; then
+
+$as_echo "#define HAVE_RO_EH_FRAME 1" >>confdefs.h
+
+
+$as_echo "#define EH_FRAME_FLAGS \"a\"" >>confdefs.h
+
+ else
+
+$as_echo "#define EH_FRAME_FLAGS \"aw\"" >>confdefs.h
+
+ fi
+
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for __attribute__((visibility(\"hidden\")))" >&5
+$as_echo_n "checking for __attribute__((visibility(\"hidden\")))... " >&6; }
+if ${libffi_cv_hidden_visibility_attribute+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+
+ echo 'int __attribute__ ((visibility ("hidden"))) foo (void) { return 1 ; }' > conftest.c
+ libffi_cv_hidden_visibility_attribute=no
+ if { ac_try='${CC-cc} -Werror -S conftest.c -o conftest.s 1>&5'
+ { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_try\""; } >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+ test $ac_status = 0; }; }; then
+ if grep '\.hidden.*foo' conftest.s >/dev/null; then
+ libffi_cv_hidden_visibility_attribute=yes
+ fi
+ fi
+ rm -f conftest.*
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $libffi_cv_hidden_visibility_attribute" >&5
+$as_echo "$libffi_cv_hidden_visibility_attribute" >&6; }
+ if test $libffi_cv_hidden_visibility_attribute = yes; then
+
+$as_echo "#define HAVE_HIDDEN_VISIBILITY_ATTRIBUTE 1" >>confdefs.h
+
+ fi
+fi
+
+
+
+
+
+
+
+
+# Check whether --enable-debug was given.
+if test "${enable_debug+set}" = set; then :
+ enableval=$enable_debug; if test "$enable_debug" = "yes"; then
+
+$as_echo "#define FFI_DEBUG 1" >>confdefs.h
+
+ fi
+fi
+
+ if test "$enable_debug" = "yes"; then
+ FFI_DEBUG_TRUE=
+ FFI_DEBUG_FALSE='#'
+else
+ FFI_DEBUG_TRUE='#'
+ FFI_DEBUG_FALSE=
+fi
+
+
+# Check whether --enable-structs was given.
+if test "${enable_structs+set}" = set; then :
+ enableval=$enable_structs; if test "$enable_structs" = "no"; then
+
+$as_echo "#define FFI_NO_STRUCTS 1" >>confdefs.h
+
+ fi
+fi
+
+ if test "$enable_debug" = "yes"; then
+ FFI_DEBUG_TRUE=
+ FFI_DEBUG_FALSE='#'
+else
+ FFI_DEBUG_TRUE='#'
+ FFI_DEBUG_FALSE=
+fi
+
+
+# Check whether --enable-raw-api was given.
+if test "${enable_raw_api+set}" = set; then :
+ enableval=$enable_raw_api; if test "$enable_raw_api" = "no"; then
+
+$as_echo "#define FFI_NO_RAW_API 1" >>confdefs.h
+
+ fi
+fi
+
+
+# Check whether --enable-purify-safety was given.
+if test "${enable_purify_safety+set}" = set; then :
+ enableval=$enable_purify_safety; if test "$enable_purify_safety" = "yes"; then
+
+$as_echo "#define USING_PURIFY 1" >>confdefs.h
+
+ fi
+fi
+
+
+# These variables are only ever used when we cross-build to X86_WIN32.
+# And we only support this with GCC, so...
+if test "x$GCC" = "xyes"; then
+ if test -n "$with_cross_host" &&
+ test x"$with_cross_host" != x"no"; then
+ toolexecdir="${exec_prefix}"/'$(target_alias)'
+ toolexeclibdir="${toolexecdir}"/lib
+ else
+ toolexecdir="${libdir}"/gcc-lib/'$(target_alias)'
+ toolexeclibdir="${libdir}"
+ fi
+ multi_os_directory=`$CC $CFLAGS -print-multi-os-directory`
+ case $multi_os_directory in
+ .) ;; # Avoid trailing /.
+ ../*) toolexeclibdir=$toolexeclibdir/$multi_os_directory ;;
+ esac
+
+else
+ toolexeclibdir="${libdir}"
+fi
+
+
+ac_config_commands="$ac_config_commands include"
+
+ac_config_commands="$ac_config_commands src"
+
+
+ac_config_links="$ac_config_links include/ffitarget.h:src/$TARGETDIR/ffitarget.h"
+
+
+ac_config_files="$ac_config_files include/Makefile include/ffi.h Makefile testsuite/Makefile man/Makefile libffi.pc"
+
+
+cat >confcache <<\_ACEOF
+# This file is a shell script that caches the results of configure
+# tests run on this system so they can be shared between configure
+# scripts and configure runs, see configure's option --config-cache.
+# It is not useful on other systems. If it contains results you don't
+# want to keep, you may remove or edit it.
+#
+# config.status only pays attention to the cache file if you give it
+# the --recheck option to rerun configure.
+#
+# `ac_cv_env_foo' variables (set or unset) will be overridden when
+# loading this file, other *unset* `ac_cv_foo' will be assigned the
+# following values.
+
+_ACEOF
+
+# The following way of writing the cache mishandles newlines in values,
+# but we know of no workaround that is simple, portable, and efficient.
+# So, we kill variables containing newlines.
+# Ultrix sh set writes to stderr and can't be redirected directly,
+# and sets the high bit in the cache file unless we assign to the vars.
+(
+ for ac_var in `(set) 2>&1 | sed -n 's/^\([a-zA-Z_][a-zA-Z0-9_]*\)=.*/\1/p'`; do
+ eval ac_val=\$$ac_var
+ case $ac_val in #(
+ *${as_nl}*)
+ case $ac_var in #(
+ *_cv_*) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: cache variable $ac_var contains a newline" >&5
+$as_echo "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} ;;
+ esac
+ case $ac_var in #(
+ _ | IFS | as_nl) ;; #(
+ BASH_ARGV | BASH_SOURCE) eval $ac_var= ;; #(
+ *) { eval $ac_var=; unset $ac_var;} ;;
+ esac ;;
+ esac
+ done
+
+ (set) 2>&1 |
+ case $as_nl`(ac_space=' '; set) 2>&1` in #(
+ *${as_nl}ac_space=\ *)
+ # `set' does not quote correctly, so add quotes: double-quote
+ # substitution turns \\\\ into \\, and sed turns \\ into \.
+ sed -n \
+ "s/'/'\\\\''/g;
+ s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\\2'/p"
+ ;; #(
+ *)
+ # `set' quotes correctly as required by POSIX, so do not add quotes.
+ sed -n "/^[_$as_cr_alnum]*_cv_[_$as_cr_alnum]*=/p"
+ ;;
+ esac |
+ sort
+) |
+ sed '
+ /^ac_cv_env_/b end
+ t clear
+ :clear
+ s/^\([^=]*\)=\(.*[{}].*\)$/test "${\1+set}" = set || &/
+ t end
+ s/^\([^=]*\)=\(.*\)$/\1=${\1=\2}/
+ :end' >>confcache
+if diff "$cache_file" confcache >/dev/null 2>&1; then :; else
+ if test -w "$cache_file"; then
+ if test "x$cache_file" != "x/dev/null"; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: updating cache $cache_file" >&5
+$as_echo "$as_me: updating cache $cache_file" >&6;}
+ if test ! -f "$cache_file" || test -h "$cache_file"; then
+ cat confcache >"$cache_file"
+ else
+ case $cache_file in #(
+ */* | ?:*)
+ mv -f confcache "$cache_file"$$ &&
+ mv -f "$cache_file"$$ "$cache_file" ;; #(
+ *)
+ mv -f confcache "$cache_file" ;;
+ esac
+ fi
+ fi
+ else
+ { $as_echo "$as_me:${as_lineno-$LINENO}: not updating unwritable cache $cache_file" >&5
+$as_echo "$as_me: not updating unwritable cache $cache_file" >&6;}
+ fi
+fi
+rm -f confcache
+
+test "x$prefix" = xNONE && prefix=$ac_default_prefix
+# Let make expand exec_prefix.
+test "x$exec_prefix" = xNONE && exec_prefix='${prefix}'
+
+DEFS=-DHAVE_CONFIG_H
+
+ac_libobjs=
+ac_ltlibobjs=
+U=
+for ac_i in : $LIBOBJS; do test "x$ac_i" = x: && continue
+ # 1. Remove the extension, and $U if already installed.
+ ac_script='s/\$U\././;s/\.o$//;s/\.obj$//'
+ ac_i=`$as_echo "$ac_i" | sed "$ac_script"`
+ # 2. Prepend LIBOBJDIR. When used with automake>=1.10 LIBOBJDIR
+ # will be set to the directory where LIBOBJS objects are built.
+ as_fn_append ac_libobjs " \${LIBOBJDIR}$ac_i\$U.$ac_objext"
+ as_fn_append ac_ltlibobjs " \${LIBOBJDIR}$ac_i"'$U.lo'
+done
+LIBOBJS=$ac_libobjs
+
+LTLIBOBJS=$ac_ltlibobjs
+
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking that generated files are newer than configure" >&5
+$as_echo_n "checking that generated files are newer than configure... " >&6; }
+ if test -n "$am_sleep_pid"; then
+ # Hide warnings about reused PIDs.
+ wait $am_sleep_pid 2>/dev/null
+ fi
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: done" >&5
+$as_echo "done" >&6; }
+ if test -n "$EXEEXT"; then
+ am__EXEEXT_TRUE=
+ am__EXEEXT_FALSE='#'
+else
+ am__EXEEXT_TRUE='#'
+ am__EXEEXT_FALSE=
+fi
+
+if test -z "${AMDEP_TRUE}" && test -z "${AMDEP_FALSE}"; then
+ as_fn_error $? "conditional \"AMDEP\" was never defined.
+Usually this means the macro was only invoked conditionally." "$LINENO" 5
+fi
+if test -z "${am__fastdepCC_TRUE}" && test -z "${am__fastdepCC_FALSE}"; then
+ as_fn_error $? "conditional \"am__fastdepCC\" was never defined.
+Usually this means the macro was only invoked conditionally." "$LINENO" 5
+fi
+if test -z "${am__fastdepCXX_TRUE}" && test -z "${am__fastdepCXX_FALSE}"; then
+ as_fn_error $? "conditional \"am__fastdepCXX\" was never defined.
+Usually this means the macro was only invoked conditionally." "$LINENO" 5
+fi
+if test -z "${am__fastdepCCAS_TRUE}" && test -z "${am__fastdepCCAS_FALSE}"; then
+ as_fn_error $? "conditional \"am__fastdepCCAS\" was never defined.
+Usually this means the macro was only invoked conditionally." "$LINENO" 5
+fi
+if test -z "${MAINTAINER_MODE_TRUE}" && test -z "${MAINTAINER_MODE_FALSE}"; then
+ as_fn_error $? "conditional \"MAINTAINER_MODE\" was never defined.
+Usually this means the macro was only invoked conditionally." "$LINENO" 5
+fi
+if test -z "${TESTSUBDIR_TRUE}" && test -z "${TESTSUBDIR_FALSE}"; then
+ as_fn_error $? "conditional \"TESTSUBDIR\" was never defined.
+Usually this means the macro was only invoked conditionally." "$LINENO" 5
+fi
+if test -z "${MIPS_TRUE}" && test -z "${MIPS_FALSE}"; then
+ as_fn_error $? "conditional \"MIPS\" was never defined.
+Usually this means the macro was only invoked conditionally." "$LINENO" 5
+fi
+if test -z "${BFIN_TRUE}" && test -z "${BFIN_FALSE}"; then
+ as_fn_error $? "conditional \"BFIN\" was never defined.
+Usually this means the macro was only invoked conditionally." "$LINENO" 5
+fi
+if test -z "${SPARC_TRUE}" && test -z "${SPARC_FALSE}"; then
+ as_fn_error $? "conditional \"SPARC\" was never defined.
+Usually this means the macro was only invoked conditionally." "$LINENO" 5
+fi
+if test -z "${X86_TRUE}" && test -z "${X86_FALSE}"; then
+ as_fn_error $? "conditional \"X86\" was never defined.
+Usually this means the macro was only invoked conditionally." "$LINENO" 5
+fi
+if test -z "${X86_FREEBSD_TRUE}" && test -z "${X86_FREEBSD_FALSE}"; then
+ as_fn_error $? "conditional \"X86_FREEBSD\" was never defined.
+Usually this means the macro was only invoked conditionally." "$LINENO" 5
+fi
+if test -z "${X86_WIN32_TRUE}" && test -z "${X86_WIN32_FALSE}"; then
+ as_fn_error $? "conditional \"X86_WIN32\" was never defined.
+Usually this means the macro was only invoked conditionally." "$LINENO" 5
+fi
+if test -z "${X86_WIN64_TRUE}" && test -z "${X86_WIN64_FALSE}"; then
+ as_fn_error $? "conditional \"X86_WIN64\" was never defined.
+Usually this means the macro was only invoked conditionally." "$LINENO" 5
+fi
+if test -z "${X86_DARWIN_TRUE}" && test -z "${X86_DARWIN_FALSE}"; then
+ as_fn_error $? "conditional \"X86_DARWIN\" was never defined.
+Usually this means the macro was only invoked conditionally." "$LINENO" 5
+fi
+if test -z "${X86_DARWIN32_TRUE}" && test -z "${X86_DARWIN32_FALSE}"; then
+ as_fn_error $? "conditional \"X86_DARWIN32\" was never defined.
+Usually this means the macro was only invoked conditionally." "$LINENO" 5
+fi
+if test -z "${X86_DARWIN64_TRUE}" && test -z "${X86_DARWIN64_FALSE}"; then
+ as_fn_error $? "conditional \"X86_DARWIN64\" was never defined.
+Usually this means the macro was only invoked conditionally." "$LINENO" 5
+fi
+if test -z "${ALPHA_TRUE}" && test -z "${ALPHA_FALSE}"; then
+ as_fn_error $? "conditional \"ALPHA\" was never defined.
+Usually this means the macro was only invoked conditionally." "$LINENO" 5
+fi
+if test -z "${IA64_TRUE}" && test -z "${IA64_FALSE}"; then
+ as_fn_error $? "conditional \"IA64\" was never defined.
+Usually this means the macro was only invoked conditionally." "$LINENO" 5
+fi
+if test -z "${M32R_TRUE}" && test -z "${M32R_FALSE}"; then
+ as_fn_error $? "conditional \"M32R\" was never defined.
+Usually this means the macro was only invoked conditionally." "$LINENO" 5
+fi
+if test -z "${M68K_TRUE}" && test -z "${M68K_FALSE}"; then
+ as_fn_error $? "conditional \"M68K\" was never defined.
+Usually this means the macro was only invoked conditionally." "$LINENO" 5
+fi
+if test -z "${M88K_TRUE}" && test -z "${M88K_FALSE}"; then
+ as_fn_error $? "conditional \"M88K\" was never defined.
+Usually this means the macro was only invoked conditionally." "$LINENO" 5
+fi
+if test -z "${MICROBLAZE_TRUE}" && test -z "${MICROBLAZE_FALSE}"; then
+ as_fn_error $? "conditional \"MICROBLAZE\" was never defined.
+Usually this means the macro was only invoked conditionally." "$LINENO" 5
+fi
+if test -z "${METAG_TRUE}" && test -z "${METAG_FALSE}"; then
+ as_fn_error $? "conditional \"METAG\" was never defined.
+Usually this means the macro was only invoked conditionally." "$LINENO" 5
+fi
+if test -z "${MOXIE_TRUE}" && test -z "${MOXIE_FALSE}"; then
+ as_fn_error $? "conditional \"MOXIE\" was never defined.
+Usually this means the macro was only invoked conditionally." "$LINENO" 5
+fi
+if test -z "${NIOS2_TRUE}" && test -z "${NIOS2_FALSE}"; then
+ as_fn_error $? "conditional \"NIOS2\" was never defined.
+Usually this means the macro was only invoked conditionally." "$LINENO" 5
+fi
+if test -z "${OR1K_TRUE}" && test -z "${OR1K_FALSE}"; then
+ as_fn_error $? "conditional \"OR1K\" was never defined.
+Usually this means the macro was only invoked conditionally." "$LINENO" 5
+fi
+if test -z "${POWERPC_TRUE}" && test -z "${POWERPC_FALSE}"; then
+ as_fn_error $? "conditional \"POWERPC\" was never defined.
+Usually this means the macro was only invoked conditionally." "$LINENO" 5
+fi
+if test -z "${POWERPC_AIX_TRUE}" && test -z "${POWERPC_AIX_FALSE}"; then
+ as_fn_error $? "conditional \"POWERPC_AIX\" was never defined.
+Usually this means the macro was only invoked conditionally." "$LINENO" 5
+fi
+if test -z "${POWERPC_DARWIN_TRUE}" && test -z "${POWERPC_DARWIN_FALSE}"; then
+ as_fn_error $? "conditional \"POWERPC_DARWIN\" was never defined.
+Usually this means the macro was only invoked conditionally." "$LINENO" 5
+fi
+if test -z "${POWERPC_FREEBSD_TRUE}" && test -z "${POWERPC_FREEBSD_FALSE}"; then
+ as_fn_error $? "conditional \"POWERPC_FREEBSD\" was never defined.
+Usually this means the macro was only invoked conditionally." "$LINENO" 5
+fi
+if test -z "${AARCH64_TRUE}" && test -z "${AARCH64_FALSE}"; then
+ as_fn_error $? "conditional \"AARCH64\" was never defined.
+Usually this means the macro was only invoked conditionally." "$LINENO" 5
+fi
+if test -z "${ARC_TRUE}" && test -z "${ARC_FALSE}"; then
+ as_fn_error $? "conditional \"ARC\" was never defined.
+Usually this means the macro was only invoked conditionally." "$LINENO" 5
+fi
+if test -z "${ARM_TRUE}" && test -z "${ARM_FALSE}"; then
+ as_fn_error $? "conditional \"ARM\" was never defined.
+Usually this means the macro was only invoked conditionally." "$LINENO" 5
+fi
+if test -z "${AVR32_TRUE}" && test -z "${AVR32_FALSE}"; then
+ as_fn_error $? "conditional \"AVR32\" was never defined.
+Usually this means the macro was only invoked conditionally." "$LINENO" 5
+fi
+if test -z "${LIBFFI_CRIS_TRUE}" && test -z "${LIBFFI_CRIS_FALSE}"; then
+ as_fn_error $? "conditional \"LIBFFI_CRIS\" was never defined.
+Usually this means the macro was only invoked conditionally." "$LINENO" 5
+fi
+if test -z "${FRV_TRUE}" && test -z "${FRV_FALSE}"; then
+ as_fn_error $? "conditional \"FRV\" was never defined.
+Usually this means the macro was only invoked conditionally." "$LINENO" 5
+fi
+if test -z "${S390_TRUE}" && test -z "${S390_FALSE}"; then
+ as_fn_error $? "conditional \"S390\" was never defined.
+Usually this means the macro was only invoked conditionally." "$LINENO" 5
+fi
+if test -z "${X86_64_TRUE}" && test -z "${X86_64_FALSE}"; then
+ as_fn_error $? "conditional \"X86_64\" was never defined.
+Usually this means the macro was only invoked conditionally." "$LINENO" 5
+fi
+if test -z "${SH_TRUE}" && test -z "${SH_FALSE}"; then
+ as_fn_error $? "conditional \"SH\" was never defined.
+Usually this means the macro was only invoked conditionally." "$LINENO" 5
+fi
+if test -z "${SH64_TRUE}" && test -z "${SH64_FALSE}"; then
+ as_fn_error $? "conditional \"SH64\" was never defined.
+Usually this means the macro was only invoked conditionally." "$LINENO" 5
+fi
+if test -z "${PA_LINUX_TRUE}" && test -z "${PA_LINUX_FALSE}"; then
+ as_fn_error $? "conditional \"PA_LINUX\" was never defined.
+Usually this means the macro was only invoked conditionally." "$LINENO" 5
+fi
+if test -z "${PA_HPUX_TRUE}" && test -z "${PA_HPUX_FALSE}"; then
+ as_fn_error $? "conditional \"PA_HPUX\" was never defined.
+Usually this means the macro was only invoked conditionally." "$LINENO" 5
+fi
+if test -z "${PA64_HPUX_TRUE}" && test -z "${PA64_HPUX_FALSE}"; then
+ as_fn_error $? "conditional \"PA64_HPUX\" was never defined.
+Usually this means the macro was only invoked conditionally." "$LINENO" 5
+fi
+if test -z "${TILE_TRUE}" && test -z "${TILE_FALSE}"; then
+ as_fn_error $? "conditional \"TILE\" was never defined.
+Usually this means the macro was only invoked conditionally." "$LINENO" 5
+fi
+if test -z "${VAX_TRUE}" && test -z "${VAX_FALSE}"; then
+ as_fn_error $? "conditional \"VAX\" was never defined.
+Usually this means the macro was only invoked conditionally." "$LINENO" 5
+fi
+if test -z "${XTENSA_TRUE}" && test -z "${XTENSA_FALSE}"; then
+ as_fn_error $? "conditional \"XTENSA\" was never defined.
+Usually this means the macro was only invoked conditionally." "$LINENO" 5
+fi
+
+if test -z "${FFI_EXEC_TRAMPOLINE_TABLE_TRUE}" && test -z "${FFI_EXEC_TRAMPOLINE_TABLE_FALSE}"; then
+ as_fn_error $? "conditional \"FFI_EXEC_TRAMPOLINE_TABLE\" was never defined.
+Usually this means the macro was only invoked conditionally." "$LINENO" 5
+fi
+if test -z "${FFI_DEBUG_TRUE}" && test -z "${FFI_DEBUG_FALSE}"; then
+ as_fn_error $? "conditional \"FFI_DEBUG\" was never defined.
+Usually this means the macro was only invoked conditionally." "$LINENO" 5
+fi
+if test -z "${FFI_DEBUG_TRUE}" && test -z "${FFI_DEBUG_FALSE}"; then
+ as_fn_error $? "conditional \"FFI_DEBUG\" was never defined.
+Usually this means the macro was only invoked conditionally." "$LINENO" 5
+fi
+
+: "${CONFIG_STATUS=./config.status}"
+ac_write_fail=0
+ac_clean_files_save=$ac_clean_files
+ac_clean_files="$ac_clean_files $CONFIG_STATUS"
+{ $as_echo "$as_me:${as_lineno-$LINENO}: creating $CONFIG_STATUS" >&5
+$as_echo "$as_me: creating $CONFIG_STATUS" >&6;}
+as_write_fail=0
+cat >$CONFIG_STATUS <<_ASEOF || as_write_fail=1
+#! $SHELL
+# Generated by $as_me.
+# Run this file to recreate the current configuration.
+# Compiler output produced by configure, useful for debugging
+# configure, is in config.log if it exists.
+
+debug=false
+ac_cs_recheck=false
+ac_cs_silent=false
+
+SHELL=\${CONFIG_SHELL-$SHELL}
+export SHELL
+_ASEOF
+cat >>$CONFIG_STATUS <<\_ASEOF || as_write_fail=1
+## -------------------- ##
+## M4sh Initialization. ##
+## -------------------- ##
+
+# Be more Bourne compatible
+DUALCASE=1; export DUALCASE # for MKS sh
+if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then :
+ emulate sh
+ NULLCMD=:
+ # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which
+ # is contrary to our usage. Disable this feature.
+ alias -g '${1+"$@"}'='"$@"'
+ setopt NO_GLOB_SUBST
+else
+ case `(set -o) 2>/dev/null` in #(
+ *posix*) :
+ set -o posix ;; #(
+ *) :
+ ;;
+esac
+fi
+
+
+as_nl='
+'
+export as_nl
+# Printing a long string crashes Solaris 7 /usr/bin/printf.
+as_echo='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\'
+as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo
+as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo$as_echo
+# Prefer a ksh shell builtin over an external printf program on Solaris,
+# but without wasting forks for bash or zsh.
+if test -z "$BASH_VERSION$ZSH_VERSION" \
+ && (test "X`print -r -- $as_echo`" = "X$as_echo") 2>/dev/null; then
+ as_echo='print -r --'
+ as_echo_n='print -rn --'
+elif (test "X`printf %s $as_echo`" = "X$as_echo") 2>/dev/null; then
+ as_echo='printf %s\n'
+ as_echo_n='printf %s'
+else
+ if test "X`(/usr/ucb/echo -n -n $as_echo) 2>/dev/null`" = "X-n $as_echo"; then
+ as_echo_body='eval /usr/ucb/echo -n "$1$as_nl"'
+ as_echo_n='/usr/ucb/echo -n'
+ else
+ as_echo_body='eval expr "X$1" : "X\\(.*\\)"'
+ as_echo_n_body='eval
+ arg=$1;
+ case $arg in #(
+ *"$as_nl"*)
+ expr "X$arg" : "X\\(.*\\)$as_nl";
+ arg=`expr "X$arg" : ".*$as_nl\\(.*\\)"`;;
+ esac;
+ expr "X$arg" : "X\\(.*\\)" | tr -d "$as_nl"
+ '
+ export as_echo_n_body
+ as_echo_n='sh -c $as_echo_n_body as_echo'
+ fi
+ export as_echo_body
+ as_echo='sh -c $as_echo_body as_echo'
+fi
+
+# The user is always right.
+if test "${PATH_SEPARATOR+set}" != set; then
+ PATH_SEPARATOR=:
+ (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && {
+ (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 ||
+ PATH_SEPARATOR=';'
+ }
+fi
+
+
+# IFS
+# We need space, tab and new line, in precisely that order. Quoting is
+# there to prevent editors from complaining about space-tab.
+# (If _AS_PATH_WALK were called with IFS unset, it would disable word
+# splitting by setting IFS to empty value.)
+IFS=" "" $as_nl"
+
+# Find who we are. Look in the path if we contain no directory separator.
+as_myself=
+case $0 in #((
+ *[\\/]* ) as_myself=$0 ;;
+ *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break
+ done
+IFS=$as_save_IFS
+
+ ;;
+esac
+# We did not find ourselves, most probably we were run as `sh COMMAND'
+# in which case we are not to be found in the path.
+if test "x$as_myself" = x; then
+ as_myself=$0
+fi
+if test ! -f "$as_myself"; then
+ $as_echo "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2
+ exit 1
+fi
+
+# Unset variables that we do not need and which cause bugs (e.g. in
+# pre-3.0 UWIN ksh). But do not cause bugs in bash 2.01; the "|| exit 1"
+# suppresses any "Segmentation fault" message there. '((' could
+# trigger a bug in pdksh 5.2.14.
+for as_var in BASH_ENV ENV MAIL MAILPATH
+do eval test x\${$as_var+set} = xset \
+ && ( (unset $as_var) || exit 1) >/dev/null 2>&1 && unset $as_var || :
+done
+PS1='$ '
+PS2='> '
+PS4='+ '
+
+# NLS nuisances.
+LC_ALL=C
+export LC_ALL
+LANGUAGE=C
+export LANGUAGE
+
+# CDPATH.
+(unset CDPATH) >/dev/null 2>&1 && unset CDPATH
+
+
+# as_fn_error STATUS ERROR [LINENO LOG_FD]
+# ----------------------------------------
+# Output "`basename $0`: error: ERROR" to stderr. If LINENO and LOG_FD are
+# provided, also output the error to LOG_FD, referencing LINENO. Then exit the
+# script with STATUS, using 1 if that was 0.
+as_fn_error ()
+{
+ as_status=$1; test $as_status -eq 0 && as_status=1
+ if test "$4"; then
+ as_lineno=${as_lineno-"$3"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
+ $as_echo "$as_me:${as_lineno-$LINENO}: error: $2" >&$4
+ fi
+ $as_echo "$as_me: error: $2" >&2
+ as_fn_exit $as_status
+} # as_fn_error
+
+
+# as_fn_set_status STATUS
+# -----------------------
+# Set $? to STATUS, without forking.
+as_fn_set_status ()
+{
+ return $1
+} # as_fn_set_status
+
+# as_fn_exit STATUS
+# -----------------
+# Exit the shell with STATUS, even in a "trap 0" or "set -e" context.
+as_fn_exit ()
+{
+ set +e
+ as_fn_set_status $1
+ exit $1
+} # as_fn_exit
+
+# as_fn_unset VAR
+# ---------------
+# Portably unset VAR.
+as_fn_unset ()
+{
+ { eval $1=; unset $1;}
+}
+as_unset=as_fn_unset
+# as_fn_append VAR VALUE
+# ----------------------
+# Append the text in VALUE to the end of the definition contained in VAR. Take
+# advantage of any shell optimizations that allow amortized linear growth over
+# repeated appends, instead of the typical quadratic growth present in naive
+# implementations.
+if (eval "as_var=1; as_var+=2; test x\$as_var = x12") 2>/dev/null; then :
+ eval 'as_fn_append ()
+ {
+ eval $1+=\$2
+ }'
+else
+ as_fn_append ()
+ {
+ eval $1=\$$1\$2
+ }
+fi # as_fn_append
+
+# as_fn_arith ARG...
+# ------------------
+# Perform arithmetic evaluation on the ARGs, and store the result in the
+# global $as_val. Take advantage of shells that can avoid forks. The arguments
+# must be portable across $(()) and expr.
+if (eval "test \$(( 1 + 1 )) = 2") 2>/dev/null; then :
+ eval 'as_fn_arith ()
+ {
+ as_val=$(( $* ))
+ }'
+else
+ as_fn_arith ()
+ {
+ as_val=`expr "$@" || test $? -eq 1`
+ }
+fi # as_fn_arith
+
+
+if expr a : '\(a\)' >/dev/null 2>&1 &&
+ test "X`expr 00001 : '.*\(...\)'`" = X001; then
+ as_expr=expr
+else
+ as_expr=false
+fi
+
+if (basename -- /) >/dev/null 2>&1 && test "X`basename -- / 2>&1`" = "X/"; then
+ as_basename=basename
+else
+ as_basename=false
+fi
+
+if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then
+ as_dirname=dirname
+else
+ as_dirname=false
+fi
+
+as_me=`$as_basename -- "$0" ||
+$as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \
+ X"$0" : 'X\(//\)$' \| \
+ X"$0" : 'X\(/\)' \| . 2>/dev/null ||
+$as_echo X/"$0" |
+ sed '/^.*\/\([^/][^/]*\)\/*$/{
+ s//\1/
+ q
+ }
+ /^X\/\(\/\/\)$/{
+ s//\1/
+ q
+ }
+ /^X\/\(\/\).*/{
+ s//\1/
+ q
+ }
+ s/.*/./; q'`
+
+# Avoid depending upon Character Ranges.
+as_cr_letters='abcdefghijklmnopqrstuvwxyz'
+as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ'
+as_cr_Letters=$as_cr_letters$as_cr_LETTERS
+as_cr_digits='0123456789'
+as_cr_alnum=$as_cr_Letters$as_cr_digits
+
+ECHO_C= ECHO_N= ECHO_T=
+case `echo -n x` in #(((((
+-n*)
+ case `echo 'xy\c'` in
+ *c*) ECHO_T=' ';; # ECHO_T is single tab character.
+ xy) ECHO_C='\c';;
+ *) echo `echo ksh88 bug on AIX 6.1` > /dev/null
+ ECHO_T=' ';;
+ esac;;
+*)
+ ECHO_N='-n';;
+esac
+
+rm -f conf$$ conf$$.exe conf$$.file
+if test -d conf$$.dir; then
+ rm -f conf$$.dir/conf$$.file
+else
+ rm -f conf$$.dir
+ mkdir conf$$.dir 2>/dev/null
+fi
+if (echo >conf$$.file) 2>/dev/null; then
+ if ln -s conf$$.file conf$$ 2>/dev/null; then
+ as_ln_s='ln -s'
+ # ... but there are two gotchas:
+ # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail.
+ # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable.
+ # In both cases, we have to default to `cp -pR'.
+ ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe ||
+ as_ln_s='cp -pR'
+ elif ln conf$$.file conf$$ 2>/dev/null; then
+ as_ln_s=ln
+ else
+ as_ln_s='cp -pR'
+ fi
+else
+ as_ln_s='cp -pR'
+fi
+rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file
+rmdir conf$$.dir 2>/dev/null
+
+
+# as_fn_mkdir_p
+# -------------
+# Create "$as_dir" as a directory, including parents if necessary.
+as_fn_mkdir_p ()
+{
+
+ case $as_dir in #(
+ -*) as_dir=./$as_dir;;
+ esac
+ test -d "$as_dir" || eval $as_mkdir_p || {
+ as_dirs=
+ while :; do
+ case $as_dir in #(
+ *\'*) as_qdir=`$as_echo "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #'(
+ *) as_qdir=$as_dir;;
+ esac
+ as_dirs="'$as_qdir' $as_dirs"
+ as_dir=`$as_dirname -- "$as_dir" ||
+$as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
+ X"$as_dir" : 'X\(//\)[^/]' \| \
+ X"$as_dir" : 'X\(//\)$' \| \
+ X"$as_dir" : 'X\(/\)' \| . 2>/dev/null ||
+$as_echo X"$as_dir" |
+ sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{
+ s//\1/
+ q
+ }
+ /^X\(\/\/\)[^/].*/{
+ s//\1/
+ q
+ }
+ /^X\(\/\/\)$/{
+ s//\1/
+ q
+ }
+ /^X\(\/\).*/{
+ s//\1/
+ q
+ }
+ s/.*/./; q'`
+ test -d "$as_dir" && break
+ done
+ test -z "$as_dirs" || eval "mkdir $as_dirs"
+ } || test -d "$as_dir" || as_fn_error $? "cannot create directory $as_dir"
+
+
+} # as_fn_mkdir_p
+if mkdir -p . 2>/dev/null; then
+ as_mkdir_p='mkdir -p "$as_dir"'
+else
+ test -d ./-p && rmdir ./-p
+ as_mkdir_p=false
+fi
+
+
+# as_fn_executable_p FILE
+# -----------------------
+# Test if FILE is an executable regular file.
+as_fn_executable_p ()
+{
+ test -f "$1" && test -x "$1"
+} # as_fn_executable_p
+as_test_x='test -x'
+as_executable_p=as_fn_executable_p
+
+# Sed expression to map a string onto a valid CPP name.
+as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'"
+
+# Sed expression to map a string onto a valid variable name.
+as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'"
+
+
+exec 6>&1
+## ----------------------------------- ##
+## Main body of $CONFIG_STATUS script. ##
+## ----------------------------------- ##
+_ASEOF
+test $as_write_fail = 0 && chmod +x $CONFIG_STATUS || ac_write_fail=1
+
+cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
+# Save the log message, to keep $0 and so on meaningful, and to
+# report actual input values of CONFIG_FILES etc. instead of their
+# values after options handling.
+ac_log="
+This file was extended by libffi $as_me 3.2.1, which was
+generated by GNU Autoconf 2.69. Invocation command line was
+
+ CONFIG_FILES = $CONFIG_FILES
+ CONFIG_HEADERS = $CONFIG_HEADERS
+ CONFIG_LINKS = $CONFIG_LINKS
+ CONFIG_COMMANDS = $CONFIG_COMMANDS
+ $ $0 $@
+
+on `(hostname || uname -n) 2>/dev/null | sed 1q`
+"
+
+_ACEOF
+
+case $ac_config_files in *"
+"*) set x $ac_config_files; shift; ac_config_files=$*;;
+esac
+
+case $ac_config_headers in *"
+"*) set x $ac_config_headers; shift; ac_config_headers=$*;;
+esac
+
+
+cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
+# Files that config.status was made for.
+config_files="$ac_config_files"
+config_headers="$ac_config_headers"
+config_links="$ac_config_links"
+config_commands="$ac_config_commands"
+
+_ACEOF
+
+cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
+ac_cs_usage="\
+\`$as_me' instantiates files and other configuration actions
+from templates according to the current configuration. Unless the files
+and actions are specified as TAGs, all are instantiated by default.
+
+Usage: $0 [OPTION]... [TAG]...
+
+ -h, --help print this help, then exit
+ -V, --version print version number and configuration settings, then exit
+ --config print configuration, then exit
+ -q, --quiet, --silent
+ do not print progress messages
+ -d, --debug don't remove temporary files
+ --recheck update $as_me by reconfiguring in the same conditions
+ --file=FILE[:TEMPLATE]
+ instantiate the configuration file FILE
+ --header=FILE[:TEMPLATE]
+ instantiate the configuration header FILE
+
+Configuration files:
+$config_files
+
+Configuration headers:
+$config_headers
+
+Configuration links:
+$config_links
+
+Configuration commands:
+$config_commands
+
+Report bugs to <http://github.com/atgreen/libffi/issues>."
+
+_ACEOF
+cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
+ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`"
+ac_cs_version="\\
+libffi config.status 3.2.1
+configured by $0, generated by GNU Autoconf 2.69,
+ with options \\"\$ac_cs_config\\"
+
+Copyright (C) 2012 Free Software Foundation, Inc.
+This config.status script is free software; the Free Software Foundation
+gives unlimited permission to copy, distribute and modify it."
+
+ac_pwd='$ac_pwd'
+srcdir='$srcdir'
+INSTALL='$INSTALL'
+MKDIR_P='$MKDIR_P'
+AWK='$AWK'
+test -n "\$AWK" || AWK=awk
+_ACEOF
+
+cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
+# The default lists apply if the user does not specify any file.
+ac_need_defaults=:
+while test $# != 0
+do
+ case $1 in
+ --*=?*)
+ ac_option=`expr "X$1" : 'X\([^=]*\)='`
+ ac_optarg=`expr "X$1" : 'X[^=]*=\(.*\)'`
+ ac_shift=:
+ ;;
+ --*=)
+ ac_option=`expr "X$1" : 'X\([^=]*\)='`
+ ac_optarg=
+ ac_shift=:
+ ;;
+ *)
+ ac_option=$1
+ ac_optarg=$2
+ ac_shift=shift
+ ;;
+ esac
+
+ case $ac_option in
+ # Handling of the options.
+ -recheck | --recheck | --rechec | --reche | --rech | --rec | --re | --r)
+ ac_cs_recheck=: ;;
+ --version | --versio | --versi | --vers | --ver | --ve | --v | -V )
+ $as_echo "$ac_cs_version"; exit ;;
+ --config | --confi | --conf | --con | --co | --c )
+ $as_echo "$ac_cs_config"; exit ;;
+ --debug | --debu | --deb | --de | --d | -d )
+ debug=: ;;
+ --file | --fil | --fi | --f )
+ $ac_shift
+ case $ac_optarg in
+ *\'*) ac_optarg=`$as_echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"` ;;
+ '') as_fn_error $? "missing file argument" ;;
+ esac
+ as_fn_append CONFIG_FILES " '$ac_optarg'"
+ ac_need_defaults=false;;
+ --header | --heade | --head | --hea )
+ $ac_shift
+ case $ac_optarg in
+ *\'*) ac_optarg=`$as_echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"` ;;
+ esac
+ as_fn_append CONFIG_HEADERS " '$ac_optarg'"
+ ac_need_defaults=false;;
+ --he | --h)
+ # Conflict between --help and --header
+ as_fn_error $? "ambiguous option: \`$1'
+Try \`$0 --help' for more information.";;
+ --help | --hel | -h )
+ $as_echo "$ac_cs_usage"; exit ;;
+ -q | -quiet | --quiet | --quie | --qui | --qu | --q \
+ | -silent | --silent | --silen | --sile | --sil | --si | --s)
+ ac_cs_silent=: ;;
+
+ # This is an error.
+ -*) as_fn_error $? "unrecognized option: \`$1'
+Try \`$0 --help' for more information." ;;
+
+ *) as_fn_append ac_config_targets " $1"
+ ac_need_defaults=false ;;
+
+ esac
+ shift
+done
+
+ac_configure_extra_args=
+
+if $ac_cs_silent; then
+ exec 6>/dev/null
+ ac_configure_extra_args="$ac_configure_extra_args --silent"
+fi
+
+_ACEOF
+cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
+if \$ac_cs_recheck; then
+ set X $SHELL '$0' $ac_configure_args \$ac_configure_extra_args --no-create --no-recursion
+ shift
+ \$as_echo "running CONFIG_SHELL=$SHELL \$*" >&6
+ CONFIG_SHELL='$SHELL'
+ export CONFIG_SHELL
+ exec "\$@"
+fi
+
+_ACEOF
+cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
+exec 5>>config.log
+{
+ echo
+ sed 'h;s/./-/g;s/^.../## /;s/...$/ ##/;p;x;p;x' <<_ASBOX
+## Running $as_me. ##
+_ASBOX
+ $as_echo "$ac_log"
+} >&5
+
+_ACEOF
+cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
+#
+# INIT-COMMANDS
+#
+ax_enable_builddir_srcdir="$srcdir" # $srcdir
+ax_enable_builddir_host="$HOST" # $HOST / $host
+ax_enable_builddir_version="$VERSION" # $VERSION
+ax_enable_builddir_package="$PACKAGE" # $PACKAGE
+ax_enable_builddir_auxdir="$ax_enable_builddir_auxdir" # $AUX
+ax_enable_builddir_sed="$ax_enable_builddir_sed" # $SED
+ax_enable_builddir="$ax_enable_builddir" # $SUB
+
+AMDEP_TRUE="$AMDEP_TRUE" ac_aux_dir="$ac_aux_dir"
+
+
+# The HP-UX ksh and POSIX shell print the target directory to stdout
+# if CDPATH is set.
+(unset CDPATH) >/dev/null 2>&1 && unset CDPATH
+
+sed_quote_subst='$sed_quote_subst'
+double_quote_subst='$double_quote_subst'
+delay_variable_subst='$delay_variable_subst'
+macro_version='`$ECHO "$macro_version" | $SED "$delay_single_quote_subst"`'
+macro_revision='`$ECHO "$macro_revision" | $SED "$delay_single_quote_subst"`'
+enable_shared='`$ECHO "$enable_shared" | $SED "$delay_single_quote_subst"`'
+enable_static='`$ECHO "$enable_static" | $SED "$delay_single_quote_subst"`'
+pic_mode='`$ECHO "$pic_mode" | $SED "$delay_single_quote_subst"`'
+enable_fast_install='`$ECHO "$enable_fast_install" | $SED "$delay_single_quote_subst"`'
+SHELL='`$ECHO "$SHELL" | $SED "$delay_single_quote_subst"`'
+ECHO='`$ECHO "$ECHO" | $SED "$delay_single_quote_subst"`'
+PATH_SEPARATOR='`$ECHO "$PATH_SEPARATOR" | $SED "$delay_single_quote_subst"`'
+host_alias='`$ECHO "$host_alias" | $SED "$delay_single_quote_subst"`'
+host='`$ECHO "$host" | $SED "$delay_single_quote_subst"`'
+host_os='`$ECHO "$host_os" | $SED "$delay_single_quote_subst"`'
+build_alias='`$ECHO "$build_alias" | $SED "$delay_single_quote_subst"`'
+build='`$ECHO "$build" | $SED "$delay_single_quote_subst"`'
+build_os='`$ECHO "$build_os" | $SED "$delay_single_quote_subst"`'
+SED='`$ECHO "$SED" | $SED "$delay_single_quote_subst"`'
+Xsed='`$ECHO "$Xsed" | $SED "$delay_single_quote_subst"`'
+GREP='`$ECHO "$GREP" | $SED "$delay_single_quote_subst"`'
+EGREP='`$ECHO "$EGREP" | $SED "$delay_single_quote_subst"`'
+FGREP='`$ECHO "$FGREP" | $SED "$delay_single_quote_subst"`'
+LD='`$ECHO "$LD" | $SED "$delay_single_quote_subst"`'
+NM='`$ECHO "$NM" | $SED "$delay_single_quote_subst"`'
+LN_S='`$ECHO "$LN_S" | $SED "$delay_single_quote_subst"`'
+max_cmd_len='`$ECHO "$max_cmd_len" | $SED "$delay_single_quote_subst"`'
+ac_objext='`$ECHO "$ac_objext" | $SED "$delay_single_quote_subst"`'
+exeext='`$ECHO "$exeext" | $SED "$delay_single_quote_subst"`'
+lt_unset='`$ECHO "$lt_unset" | $SED "$delay_single_quote_subst"`'
+lt_SP2NL='`$ECHO "$lt_SP2NL" | $SED "$delay_single_quote_subst"`'
+lt_NL2SP='`$ECHO "$lt_NL2SP" | $SED "$delay_single_quote_subst"`'
+lt_cv_to_host_file_cmd='`$ECHO "$lt_cv_to_host_file_cmd" | $SED "$delay_single_quote_subst"`'
+lt_cv_to_tool_file_cmd='`$ECHO "$lt_cv_to_tool_file_cmd" | $SED "$delay_single_quote_subst"`'
+reload_flag='`$ECHO "$reload_flag" | $SED "$delay_single_quote_subst"`'
+reload_cmds='`$ECHO "$reload_cmds" | $SED "$delay_single_quote_subst"`'
+OBJDUMP='`$ECHO "$OBJDUMP" | $SED "$delay_single_quote_subst"`'
+deplibs_check_method='`$ECHO "$deplibs_check_method" | $SED "$delay_single_quote_subst"`'
+file_magic_cmd='`$ECHO "$file_magic_cmd" | $SED "$delay_single_quote_subst"`'
+file_magic_glob='`$ECHO "$file_magic_glob" | $SED "$delay_single_quote_subst"`'
+want_nocaseglob='`$ECHO "$want_nocaseglob" | $SED "$delay_single_quote_subst"`'
+DLLTOOL='`$ECHO "$DLLTOOL" | $SED "$delay_single_quote_subst"`'
+sharedlib_from_linklib_cmd='`$ECHO "$sharedlib_from_linklib_cmd" | $SED "$delay_single_quote_subst"`'
+AR='`$ECHO "$AR" | $SED "$delay_single_quote_subst"`'
+AR_FLAGS='`$ECHO "$AR_FLAGS" | $SED "$delay_single_quote_subst"`'
+archiver_list_spec='`$ECHO "$archiver_list_spec" | $SED "$delay_single_quote_subst"`'
+STRIP='`$ECHO "$STRIP" | $SED "$delay_single_quote_subst"`'
+RANLIB='`$ECHO "$RANLIB" | $SED "$delay_single_quote_subst"`'
+old_postinstall_cmds='`$ECHO "$old_postinstall_cmds" | $SED "$delay_single_quote_subst"`'
+old_postuninstall_cmds='`$ECHO "$old_postuninstall_cmds" | $SED "$delay_single_quote_subst"`'
+old_archive_cmds='`$ECHO "$old_archive_cmds" | $SED "$delay_single_quote_subst"`'
+lock_old_archive_extraction='`$ECHO "$lock_old_archive_extraction" | $SED "$delay_single_quote_subst"`'
+CC='`$ECHO "$CC" | $SED "$delay_single_quote_subst"`'
+CFLAGS='`$ECHO "$CFLAGS" | $SED "$delay_single_quote_subst"`'
+compiler='`$ECHO "$compiler" | $SED "$delay_single_quote_subst"`'
+GCC='`$ECHO "$GCC" | $SED "$delay_single_quote_subst"`'
+lt_cv_sys_global_symbol_pipe='`$ECHO "$lt_cv_sys_global_symbol_pipe" | $SED "$delay_single_quote_subst"`'
+lt_cv_sys_global_symbol_to_cdecl='`$ECHO "$lt_cv_sys_global_symbol_to_cdecl" | $SED "$delay_single_quote_subst"`'
+lt_cv_sys_global_symbol_to_c_name_address='`$ECHO "$lt_cv_sys_global_symbol_to_c_name_address" | $SED "$delay_single_quote_subst"`'
+lt_cv_sys_global_symbol_to_c_name_address_lib_prefix='`$ECHO "$lt_cv_sys_global_symbol_to_c_name_address_lib_prefix" | $SED "$delay_single_quote_subst"`'
+nm_file_list_spec='`$ECHO "$nm_file_list_spec" | $SED "$delay_single_quote_subst"`'
+lt_sysroot='`$ECHO "$lt_sysroot" | $SED "$delay_single_quote_subst"`'
+objdir='`$ECHO "$objdir" | $SED "$delay_single_quote_subst"`'
+MAGIC_CMD='`$ECHO "$MAGIC_CMD" | $SED "$delay_single_quote_subst"`'
+lt_prog_compiler_no_builtin_flag='`$ECHO "$lt_prog_compiler_no_builtin_flag" | $SED "$delay_single_quote_subst"`'
+lt_prog_compiler_pic='`$ECHO "$lt_prog_compiler_pic" | $SED "$delay_single_quote_subst"`'
+lt_prog_compiler_wl='`$ECHO "$lt_prog_compiler_wl" | $SED "$delay_single_quote_subst"`'
+lt_prog_compiler_static='`$ECHO "$lt_prog_compiler_static" | $SED "$delay_single_quote_subst"`'
+lt_cv_prog_compiler_c_o='`$ECHO "$lt_cv_prog_compiler_c_o" | $SED "$delay_single_quote_subst"`'
+need_locks='`$ECHO "$need_locks" | $SED "$delay_single_quote_subst"`'
+MANIFEST_TOOL='`$ECHO "$MANIFEST_TOOL" | $SED "$delay_single_quote_subst"`'
+DSYMUTIL='`$ECHO "$DSYMUTIL" | $SED "$delay_single_quote_subst"`'
+NMEDIT='`$ECHO "$NMEDIT" | $SED "$delay_single_quote_subst"`'
+LIPO='`$ECHO "$LIPO" | $SED "$delay_single_quote_subst"`'
+OTOOL='`$ECHO "$OTOOL" | $SED "$delay_single_quote_subst"`'
+OTOOL64='`$ECHO "$OTOOL64" | $SED "$delay_single_quote_subst"`'
+libext='`$ECHO "$libext" | $SED "$delay_single_quote_subst"`'
+shrext_cmds='`$ECHO "$shrext_cmds" | $SED "$delay_single_quote_subst"`'
+extract_expsyms_cmds='`$ECHO "$extract_expsyms_cmds" | $SED "$delay_single_quote_subst"`'
+archive_cmds_need_lc='`$ECHO "$archive_cmds_need_lc" | $SED "$delay_single_quote_subst"`'
+enable_shared_with_static_runtimes='`$ECHO "$enable_shared_with_static_runtimes" | $SED "$delay_single_quote_subst"`'
+export_dynamic_flag_spec='`$ECHO "$export_dynamic_flag_spec" | $SED "$delay_single_quote_subst"`'
+whole_archive_flag_spec='`$ECHO "$whole_archive_flag_spec" | $SED "$delay_single_quote_subst"`'
+compiler_needs_object='`$ECHO "$compiler_needs_object" | $SED "$delay_single_quote_subst"`'
+old_archive_from_new_cmds='`$ECHO "$old_archive_from_new_cmds" | $SED "$delay_single_quote_subst"`'
+old_archive_from_expsyms_cmds='`$ECHO "$old_archive_from_expsyms_cmds" | $SED "$delay_single_quote_subst"`'
+archive_cmds='`$ECHO "$archive_cmds" | $SED "$delay_single_quote_subst"`'
+archive_expsym_cmds='`$ECHO "$archive_expsym_cmds" | $SED "$delay_single_quote_subst"`'
+module_cmds='`$ECHO "$module_cmds" | $SED "$delay_single_quote_subst"`'
+module_expsym_cmds='`$ECHO "$module_expsym_cmds" | $SED "$delay_single_quote_subst"`'
+with_gnu_ld='`$ECHO "$with_gnu_ld" | $SED "$delay_single_quote_subst"`'
+allow_undefined_flag='`$ECHO "$allow_undefined_flag" | $SED "$delay_single_quote_subst"`'
+no_undefined_flag='`$ECHO "$no_undefined_flag" | $SED "$delay_single_quote_subst"`'
+hardcode_libdir_flag_spec='`$ECHO "$hardcode_libdir_flag_spec" | $SED "$delay_single_quote_subst"`'
+hardcode_libdir_separator='`$ECHO "$hardcode_libdir_separator" | $SED "$delay_single_quote_subst"`'
+hardcode_direct='`$ECHO "$hardcode_direct" | $SED "$delay_single_quote_subst"`'
+hardcode_direct_absolute='`$ECHO "$hardcode_direct_absolute" | $SED "$delay_single_quote_subst"`'
+hardcode_minus_L='`$ECHO "$hardcode_minus_L" | $SED "$delay_single_quote_subst"`'
+hardcode_shlibpath_var='`$ECHO "$hardcode_shlibpath_var" | $SED "$delay_single_quote_subst"`'
+hardcode_automatic='`$ECHO "$hardcode_automatic" | $SED "$delay_single_quote_subst"`'
+inherit_rpath='`$ECHO "$inherit_rpath" | $SED "$delay_single_quote_subst"`'
+link_all_deplibs='`$ECHO "$link_all_deplibs" | $SED "$delay_single_quote_subst"`'
+always_export_symbols='`$ECHO "$always_export_symbols" | $SED "$delay_single_quote_subst"`'
+export_symbols_cmds='`$ECHO "$export_symbols_cmds" | $SED "$delay_single_quote_subst"`'
+exclude_expsyms='`$ECHO "$exclude_expsyms" | $SED "$delay_single_quote_subst"`'
+include_expsyms='`$ECHO "$include_expsyms" | $SED "$delay_single_quote_subst"`'
+prelink_cmds='`$ECHO "$prelink_cmds" | $SED "$delay_single_quote_subst"`'
+postlink_cmds='`$ECHO "$postlink_cmds" | $SED "$delay_single_quote_subst"`'
+file_list_spec='`$ECHO "$file_list_spec" | $SED "$delay_single_quote_subst"`'
+variables_saved_for_relink='`$ECHO "$variables_saved_for_relink" | $SED "$delay_single_quote_subst"`'
+need_lib_prefix='`$ECHO "$need_lib_prefix" | $SED "$delay_single_quote_subst"`'
+need_version='`$ECHO "$need_version" | $SED "$delay_single_quote_subst"`'
+version_type='`$ECHO "$version_type" | $SED "$delay_single_quote_subst"`'
+runpath_var='`$ECHO "$runpath_var" | $SED "$delay_single_quote_subst"`'
+shlibpath_var='`$ECHO "$shlibpath_var" | $SED "$delay_single_quote_subst"`'
+shlibpath_overrides_runpath='`$ECHO "$shlibpath_overrides_runpath" | $SED "$delay_single_quote_subst"`'
+libname_spec='`$ECHO "$libname_spec" | $SED "$delay_single_quote_subst"`'
+library_names_spec='`$ECHO "$library_names_spec" | $SED "$delay_single_quote_subst"`'
+soname_spec='`$ECHO "$soname_spec" | $SED "$delay_single_quote_subst"`'
+install_override_mode='`$ECHO "$install_override_mode" | $SED "$delay_single_quote_subst"`'
+postinstall_cmds='`$ECHO "$postinstall_cmds" | $SED "$delay_single_quote_subst"`'
+postuninstall_cmds='`$ECHO "$postuninstall_cmds" | $SED "$delay_single_quote_subst"`'
+finish_cmds='`$ECHO "$finish_cmds" | $SED "$delay_single_quote_subst"`'
+finish_eval='`$ECHO "$finish_eval" | $SED "$delay_single_quote_subst"`'
+hardcode_into_libs='`$ECHO "$hardcode_into_libs" | $SED "$delay_single_quote_subst"`'
+sys_lib_search_path_spec='`$ECHO "$sys_lib_search_path_spec" | $SED "$delay_single_quote_subst"`'
+sys_lib_dlsearch_path_spec='`$ECHO "$sys_lib_dlsearch_path_spec" | $SED "$delay_single_quote_subst"`'
+hardcode_action='`$ECHO "$hardcode_action" | $SED "$delay_single_quote_subst"`'
+enable_dlopen='`$ECHO "$enable_dlopen" | $SED "$delay_single_quote_subst"`'
+enable_dlopen_self='`$ECHO "$enable_dlopen_self" | $SED "$delay_single_quote_subst"`'
+enable_dlopen_self_static='`$ECHO "$enable_dlopen_self_static" | $SED "$delay_single_quote_subst"`'
+old_striplib='`$ECHO "$old_striplib" | $SED "$delay_single_quote_subst"`'
+striplib='`$ECHO "$striplib" | $SED "$delay_single_quote_subst"`'
+compiler_lib_search_dirs='`$ECHO "$compiler_lib_search_dirs" | $SED "$delay_single_quote_subst"`'
+predep_objects='`$ECHO "$predep_objects" | $SED "$delay_single_quote_subst"`'
+postdep_objects='`$ECHO "$postdep_objects" | $SED "$delay_single_quote_subst"`'
+predeps='`$ECHO "$predeps" | $SED "$delay_single_quote_subst"`'
+postdeps='`$ECHO "$postdeps" | $SED "$delay_single_quote_subst"`'
+compiler_lib_search_path='`$ECHO "$compiler_lib_search_path" | $SED "$delay_single_quote_subst"`'
+LD_CXX='`$ECHO "$LD_CXX" | $SED "$delay_single_quote_subst"`'
+reload_flag_CXX='`$ECHO "$reload_flag_CXX" | $SED "$delay_single_quote_subst"`'
+reload_cmds_CXX='`$ECHO "$reload_cmds_CXX" | $SED "$delay_single_quote_subst"`'
+old_archive_cmds_CXX='`$ECHO "$old_archive_cmds_CXX" | $SED "$delay_single_quote_subst"`'
+compiler_CXX='`$ECHO "$compiler_CXX" | $SED "$delay_single_quote_subst"`'
+GCC_CXX='`$ECHO "$GCC_CXX" | $SED "$delay_single_quote_subst"`'
+lt_prog_compiler_no_builtin_flag_CXX='`$ECHO "$lt_prog_compiler_no_builtin_flag_CXX" | $SED "$delay_single_quote_subst"`'
+lt_prog_compiler_pic_CXX='`$ECHO "$lt_prog_compiler_pic_CXX" | $SED "$delay_single_quote_subst"`'
+lt_prog_compiler_wl_CXX='`$ECHO "$lt_prog_compiler_wl_CXX" | $SED "$delay_single_quote_subst"`'
+lt_prog_compiler_static_CXX='`$ECHO "$lt_prog_compiler_static_CXX" | $SED "$delay_single_quote_subst"`'
+lt_cv_prog_compiler_c_o_CXX='`$ECHO "$lt_cv_prog_compiler_c_o_CXX" | $SED "$delay_single_quote_subst"`'
+archive_cmds_need_lc_CXX='`$ECHO "$archive_cmds_need_lc_CXX" | $SED "$delay_single_quote_subst"`'
+enable_shared_with_static_runtimes_CXX='`$ECHO "$enable_shared_with_static_runtimes_CXX" | $SED "$delay_single_quote_subst"`'
+export_dynamic_flag_spec_CXX='`$ECHO "$export_dynamic_flag_spec_CXX" | $SED "$delay_single_quote_subst"`'
+whole_archive_flag_spec_CXX='`$ECHO "$whole_archive_flag_spec_CXX" | $SED "$delay_single_quote_subst"`'
+compiler_needs_object_CXX='`$ECHO "$compiler_needs_object_CXX" | $SED "$delay_single_quote_subst"`'
+old_archive_from_new_cmds_CXX='`$ECHO "$old_archive_from_new_cmds_CXX" | $SED "$delay_single_quote_subst"`'
+old_archive_from_expsyms_cmds_CXX='`$ECHO "$old_archive_from_expsyms_cmds_CXX" | $SED "$delay_single_quote_subst"`'
+archive_cmds_CXX='`$ECHO "$archive_cmds_CXX" | $SED "$delay_single_quote_subst"`'
+archive_expsym_cmds_CXX='`$ECHO "$archive_expsym_cmds_CXX" | $SED "$delay_single_quote_subst"`'
+module_cmds_CXX='`$ECHO "$module_cmds_CXX" | $SED "$delay_single_quote_subst"`'
+module_expsym_cmds_CXX='`$ECHO "$module_expsym_cmds_CXX" | $SED "$delay_single_quote_subst"`'
+with_gnu_ld_CXX='`$ECHO "$with_gnu_ld_CXX" | $SED "$delay_single_quote_subst"`'
+allow_undefined_flag_CXX='`$ECHO "$allow_undefined_flag_CXX" | $SED "$delay_single_quote_subst"`'
+no_undefined_flag_CXX='`$ECHO "$no_undefined_flag_CXX" | $SED "$delay_single_quote_subst"`'
+hardcode_libdir_flag_spec_CXX='`$ECHO "$hardcode_libdir_flag_spec_CXX" | $SED "$delay_single_quote_subst"`'
+hardcode_libdir_separator_CXX='`$ECHO "$hardcode_libdir_separator_CXX" | $SED "$delay_single_quote_subst"`'
+hardcode_direct_CXX='`$ECHO "$hardcode_direct_CXX" | $SED "$delay_single_quote_subst"`'
+hardcode_direct_absolute_CXX='`$ECHO "$hardcode_direct_absolute_CXX" | $SED "$delay_single_quote_subst"`'
+hardcode_minus_L_CXX='`$ECHO "$hardcode_minus_L_CXX" | $SED "$delay_single_quote_subst"`'
+hardcode_shlibpath_var_CXX='`$ECHO "$hardcode_shlibpath_var_CXX" | $SED "$delay_single_quote_subst"`'
+hardcode_automatic_CXX='`$ECHO "$hardcode_automatic_CXX" | $SED "$delay_single_quote_subst"`'
+inherit_rpath_CXX='`$ECHO "$inherit_rpath_CXX" | $SED "$delay_single_quote_subst"`'
+link_all_deplibs_CXX='`$ECHO "$link_all_deplibs_CXX" | $SED "$delay_single_quote_subst"`'
+always_export_symbols_CXX='`$ECHO "$always_export_symbols_CXX" | $SED "$delay_single_quote_subst"`'
+export_symbols_cmds_CXX='`$ECHO "$export_symbols_cmds_CXX" | $SED "$delay_single_quote_subst"`'
+exclude_expsyms_CXX='`$ECHO "$exclude_expsyms_CXX" | $SED "$delay_single_quote_subst"`'
+include_expsyms_CXX='`$ECHO "$include_expsyms_CXX" | $SED "$delay_single_quote_subst"`'
+prelink_cmds_CXX='`$ECHO "$prelink_cmds_CXX" | $SED "$delay_single_quote_subst"`'
+postlink_cmds_CXX='`$ECHO "$postlink_cmds_CXX" | $SED "$delay_single_quote_subst"`'
+file_list_spec_CXX='`$ECHO "$file_list_spec_CXX" | $SED "$delay_single_quote_subst"`'
+hardcode_action_CXX='`$ECHO "$hardcode_action_CXX" | $SED "$delay_single_quote_subst"`'
+compiler_lib_search_dirs_CXX='`$ECHO "$compiler_lib_search_dirs_CXX" | $SED "$delay_single_quote_subst"`'
+predep_objects_CXX='`$ECHO "$predep_objects_CXX" | $SED "$delay_single_quote_subst"`'
+postdep_objects_CXX='`$ECHO "$postdep_objects_CXX" | $SED "$delay_single_quote_subst"`'
+predeps_CXX='`$ECHO "$predeps_CXX" | $SED "$delay_single_quote_subst"`'
+postdeps_CXX='`$ECHO "$postdeps_CXX" | $SED "$delay_single_quote_subst"`'
+compiler_lib_search_path_CXX='`$ECHO "$compiler_lib_search_path_CXX" | $SED "$delay_single_quote_subst"`'
+
+LTCC='$LTCC'
+LTCFLAGS='$LTCFLAGS'
+compiler='$compiler_DEFAULT'
+
+# A function that is used when there is no print builtin or printf.
+func_fallback_echo ()
+{
+ eval 'cat <<_LTECHO_EOF
+\$1
+_LTECHO_EOF'
+}
+
+# Quote evaled strings.
+for var in SHELL \
+ECHO \
+PATH_SEPARATOR \
+SED \
+GREP \
+EGREP \
+FGREP \
+LD \
+NM \
+LN_S \
+lt_SP2NL \
+lt_NL2SP \
+reload_flag \
+OBJDUMP \
+deplibs_check_method \
+file_magic_cmd \
+file_magic_glob \
+want_nocaseglob \
+DLLTOOL \
+sharedlib_from_linklib_cmd \
+AR \
+AR_FLAGS \
+archiver_list_spec \
+STRIP \
+RANLIB \
+CC \
+CFLAGS \
+compiler \
+lt_cv_sys_global_symbol_pipe \
+lt_cv_sys_global_symbol_to_cdecl \
+lt_cv_sys_global_symbol_to_c_name_address \
+lt_cv_sys_global_symbol_to_c_name_address_lib_prefix \
+nm_file_list_spec \
+lt_prog_compiler_no_builtin_flag \
+lt_prog_compiler_pic \
+lt_prog_compiler_wl \
+lt_prog_compiler_static \
+lt_cv_prog_compiler_c_o \
+need_locks \
+MANIFEST_TOOL \
+DSYMUTIL \
+NMEDIT \
+LIPO \
+OTOOL \
+OTOOL64 \
+shrext_cmds \
+export_dynamic_flag_spec \
+whole_archive_flag_spec \
+compiler_needs_object \
+with_gnu_ld \
+allow_undefined_flag \
+no_undefined_flag \
+hardcode_libdir_flag_spec \
+hardcode_libdir_separator \
+exclude_expsyms \
+include_expsyms \
+file_list_spec \
+variables_saved_for_relink \
+libname_spec \
+library_names_spec \
+soname_spec \
+install_override_mode \
+finish_eval \
+old_striplib \
+striplib \
+compiler_lib_search_dirs \
+predep_objects \
+postdep_objects \
+predeps \
+postdeps \
+compiler_lib_search_path \
+LD_CXX \
+reload_flag_CXX \
+compiler_CXX \
+lt_prog_compiler_no_builtin_flag_CXX \
+lt_prog_compiler_pic_CXX \
+lt_prog_compiler_wl_CXX \
+lt_prog_compiler_static_CXX \
+lt_cv_prog_compiler_c_o_CXX \
+export_dynamic_flag_spec_CXX \
+whole_archive_flag_spec_CXX \
+compiler_needs_object_CXX \
+with_gnu_ld_CXX \
+allow_undefined_flag_CXX \
+no_undefined_flag_CXX \
+hardcode_libdir_flag_spec_CXX \
+hardcode_libdir_separator_CXX \
+exclude_expsyms_CXX \
+include_expsyms_CXX \
+file_list_spec_CXX \
+compiler_lib_search_dirs_CXX \
+predep_objects_CXX \
+postdep_objects_CXX \
+predeps_CXX \
+postdeps_CXX \
+compiler_lib_search_path_CXX; do
+ case \`eval \\\\\$ECHO \\\\""\\\\\$\$var"\\\\"\` in
+ *[\\\\\\\`\\"\\\$]*)
+ eval "lt_\$var=\\\\\\"\\\`\\\$ECHO \\"\\\$\$var\\" | \\\$SED \\"\\\$sed_quote_subst\\"\\\`\\\\\\""
+ ;;
+ *)
+ eval "lt_\$var=\\\\\\"\\\$\$var\\\\\\""
+ ;;
+ esac
+done
+
+# Double-quote double-evaled strings.
+for var in reload_cmds \
+old_postinstall_cmds \
+old_postuninstall_cmds \
+old_archive_cmds \
+extract_expsyms_cmds \
+old_archive_from_new_cmds \
+old_archive_from_expsyms_cmds \
+archive_cmds \
+archive_expsym_cmds \
+module_cmds \
+module_expsym_cmds \
+export_symbols_cmds \
+prelink_cmds \
+postlink_cmds \
+postinstall_cmds \
+postuninstall_cmds \
+finish_cmds \
+sys_lib_search_path_spec \
+sys_lib_dlsearch_path_spec \
+reload_cmds_CXX \
+old_archive_cmds_CXX \
+old_archive_from_new_cmds_CXX \
+old_archive_from_expsyms_cmds_CXX \
+archive_cmds_CXX \
+archive_expsym_cmds_CXX \
+module_cmds_CXX \
+module_expsym_cmds_CXX \
+export_symbols_cmds_CXX \
+prelink_cmds_CXX \
+postlink_cmds_CXX; do
+ case \`eval \\\\\$ECHO \\\\""\\\\\$\$var"\\\\"\` in
+ *[\\\\\\\`\\"\\\$]*)
+ eval "lt_\$var=\\\\\\"\\\`\\\$ECHO \\"\\\$\$var\\" | \\\$SED -e \\"\\\$double_quote_subst\\" -e \\"\\\$sed_quote_subst\\" -e \\"\\\$delay_variable_subst\\"\\\`\\\\\\""
+ ;;
+ *)
+ eval "lt_\$var=\\\\\\"\\\$\$var\\\\\\""
+ ;;
+ esac
+done
+
+ac_aux_dir='$ac_aux_dir'
+xsi_shell='$xsi_shell'
+lt_shell_append='$lt_shell_append'
+
+# See if we are running on zsh, and set the options which allow our
+# commands through without removal of \ escapes INIT.
+if test -n "\${ZSH_VERSION+set}" ; then
+ setopt NO_GLOB_SUBST
+fi
+
+
+ PACKAGE='$PACKAGE'
+ VERSION='$VERSION'
+ TIMESTAMP='$TIMESTAMP'
+ RM='$RM'
+ ofile='$ofile'
+
+
+
+
+
+TARGETDIR="$TARGETDIR"
+
+_ACEOF
+
+cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
+
+# Handling of arguments.
+for ac_config_target in $ac_config_targets
+do
+ case $ac_config_target in
+ "fficonfig.h") CONFIG_HEADERS="$CONFIG_HEADERS fficonfig.h" ;;
+ "buildir") CONFIG_COMMANDS="$CONFIG_COMMANDS buildir" ;;
+ "depfiles") CONFIG_COMMANDS="$CONFIG_COMMANDS depfiles" ;;
+ "libtool") CONFIG_COMMANDS="$CONFIG_COMMANDS libtool" ;;
+ "include") CONFIG_COMMANDS="$CONFIG_COMMANDS include" ;;
+ "src") CONFIG_COMMANDS="$CONFIG_COMMANDS src" ;;
+ "include/ffitarget.h") CONFIG_LINKS="$CONFIG_LINKS include/ffitarget.h:src/$TARGETDIR/ffitarget.h" ;;
+ "include/Makefile") CONFIG_FILES="$CONFIG_FILES include/Makefile" ;;
+ "include/ffi.h") CONFIG_FILES="$CONFIG_FILES include/ffi.h" ;;
+ "Makefile") CONFIG_FILES="$CONFIG_FILES Makefile" ;;
+ "testsuite/Makefile") CONFIG_FILES="$CONFIG_FILES testsuite/Makefile" ;;
+ "man/Makefile") CONFIG_FILES="$CONFIG_FILES man/Makefile" ;;
+ "libffi.pc") CONFIG_FILES="$CONFIG_FILES libffi.pc" ;;
+
+ *) as_fn_error $? "invalid argument: \`$ac_config_target'" "$LINENO" 5;;
+ esac
+done
+
+
+# If the user did not use the arguments to specify the items to instantiate,
+# then the envvar interface is used. Set only those that are not.
+# We use the long form for the default assignment because of an extremely
+# bizarre bug on SunOS 4.1.3.
+if $ac_need_defaults; then
+ test "${CONFIG_FILES+set}" = set || CONFIG_FILES=$config_files
+ test "${CONFIG_HEADERS+set}" = set || CONFIG_HEADERS=$config_headers
+ test "${CONFIG_LINKS+set}" = set || CONFIG_LINKS=$config_links
+ test "${CONFIG_COMMANDS+set}" = set || CONFIG_COMMANDS=$config_commands
+fi
+
+# Have a temporary directory for convenience. Make it in the build tree
+# simply because there is no reason against having it here, and in addition,
+# creating and moving files from /tmp can sometimes cause problems.
+# Hook for its removal unless debugging.
+# Note that there is a small window in which the directory will not be cleaned:
+# after its creation but before its name has been assigned to `$tmp'.
+$debug ||
+{
+ tmp= ac_tmp=
+ trap 'exit_status=$?
+ : "${ac_tmp:=$tmp}"
+ { test ! -d "$ac_tmp" || rm -fr "$ac_tmp"; } && exit $exit_status
+' 0
+ trap 'as_fn_exit 1' 1 2 13 15
+}
+# Create a (secure) tmp directory for tmp files.
+
+{
+ tmp=`(umask 077 && mktemp -d "./confXXXXXX") 2>/dev/null` &&
+ test -d "$tmp"
+} ||
+{
+ tmp=./conf$$-$RANDOM
+ (umask 077 && mkdir "$tmp")
+} || as_fn_error $? "cannot create a temporary directory in ." "$LINENO" 5
+ac_tmp=$tmp
+
+# Set up the scripts for CONFIG_FILES section.
+# No need to generate them if there are no CONFIG_FILES.
+# This happens for instance with `./config.status config.h'.
+if test -n "$CONFIG_FILES"; then
+
+
+ac_cr=`echo X | tr X '\015'`
+# On cygwin, bash can eat \r inside `` if the user requested igncr.
+# But we know of no other shell where ac_cr would be empty at this
+# point, so we can use a bashism as a fallback.
+if test "x$ac_cr" = x; then
+ eval ac_cr=\$\'\\r\'
+fi
+ac_cs_awk_cr=`$AWK 'BEGIN { print "a\rb" }' </dev/null 2>/dev/null`
+if test "$ac_cs_awk_cr" = "a${ac_cr}b"; then
+ ac_cs_awk_cr='\\r'
+else
+ ac_cs_awk_cr=$ac_cr
+fi
+
+echo 'BEGIN {' >"$ac_tmp/subs1.awk" &&
+_ACEOF
+
+
+{
+ echo "cat >conf$$subs.awk <<_ACEOF" &&
+ echo "$ac_subst_vars" | sed 's/.*/&!$&$ac_delim/' &&
+ echo "_ACEOF"
+} >conf$$subs.sh ||
+ as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5
+ac_delim_num=`echo "$ac_subst_vars" | grep -c '^'`
+ac_delim='%!_!# '
+for ac_last_try in false false false false false :; do
+ . ./conf$$subs.sh ||
+ as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5
+
+ ac_delim_n=`sed -n "s/.*$ac_delim\$/X/p" conf$$subs.awk | grep -c X`
+ if test $ac_delim_n = $ac_delim_num; then
+ break
+ elif $ac_last_try; then
+ as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5
+ else
+ ac_delim="$ac_delim!$ac_delim _$ac_delim!! "
+ fi
+done
+rm -f conf$$subs.sh
+
+cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
+cat >>"\$ac_tmp/subs1.awk" <<\\_ACAWK &&
+_ACEOF
+sed -n '
+h
+s/^/S["/; s/!.*/"]=/
+p
+g
+s/^[^!]*!//
+:repl
+t repl
+s/'"$ac_delim"'$//
+t delim
+:nl
+h
+s/\(.\{148\}\)..*/\1/
+t more1
+s/["\\]/\\&/g; s/^/"/; s/$/\\n"\\/
+p
+n
+b repl
+:more1
+s/["\\]/\\&/g; s/^/"/; s/$/"\\/
+p
+g
+s/.\{148\}//
+t nl
+:delim
+h
+s/\(.\{148\}\)..*/\1/
+t more2
+s/["\\]/\\&/g; s/^/"/; s/$/"/
+p
+b
+:more2
+s/["\\]/\\&/g; s/^/"/; s/$/"\\/
+p
+g
+s/.\{148\}//
+t delim
+' <conf$$subs.awk | sed '
+/^[^""]/{
+ N
+ s/\n//
+}
+' >>$CONFIG_STATUS || ac_write_fail=1
+rm -f conf$$subs.awk
+cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
+_ACAWK
+cat >>"\$ac_tmp/subs1.awk" <<_ACAWK &&
+ for (key in S) S_is_set[key] = 1
+ FS = ""
+
+}
+{
+ line = $ 0
+ nfields = split(line, field, "@")
+ substed = 0
+ len = length(field[1])
+ for (i = 2; i < nfields; i++) {
+ key = field[i]
+ keylen = length(key)
+ if (S_is_set[key]) {
+ value = S[key]
+ line = substr(line, 1, len) "" value "" substr(line, len + keylen + 3)
+ len += length(value) + length(field[++i])
+ substed = 1
+ } else
+ len += 1 + keylen
+ }
+
+ print line
+}
+
+_ACAWK
+_ACEOF
+cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
+if sed "s/$ac_cr//" < /dev/null > /dev/null 2>&1; then
+ sed "s/$ac_cr\$//; s/$ac_cr/$ac_cs_awk_cr/g"
+else
+ cat
+fi < "$ac_tmp/subs1.awk" > "$ac_tmp/subs.awk" \
+ || as_fn_error $? "could not setup config files machinery" "$LINENO" 5
+_ACEOF
+
+# VPATH may cause trouble with some makes, so we remove sole $(srcdir),
+# ${srcdir} and @srcdir@ entries from VPATH if srcdir is ".", strip leading and
+# trailing colons and then remove the whole line if VPATH becomes empty
+# (actually we leave an empty line to preserve line numbers).
+if test "x$srcdir" = x.; then
+ ac_vpsub='/^[ ]*VPATH[ ]*=[ ]*/{
+h
+s///
+s/^/:/
+s/[ ]*$/:/
+s/:\$(srcdir):/:/g
+s/:\${srcdir}:/:/g
+s/:@srcdir@:/:/g
+s/^:*//
+s/:*$//
+x
+s/\(=[ ]*\).*/\1/
+G
+s/\n//
+s/^[^=]*=[ ]*$//
+}'
+fi
+
+cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
+fi # test -n "$CONFIG_FILES"
+
+# Set up the scripts for CONFIG_HEADERS section.
+# No need to generate them if there are no CONFIG_HEADERS.
+# This happens for instance with `./config.status Makefile'.
+if test -n "$CONFIG_HEADERS"; then
+cat >"$ac_tmp/defines.awk" <<\_ACAWK ||
+BEGIN {
+_ACEOF
+
+# Transform confdefs.h into an awk script `defines.awk', embedded as
+# here-document in config.status, that substitutes the proper values into
+# config.h.in to produce config.h.
+
+# Create a delimiter string that does not exist in confdefs.h, to ease
+# handling of long lines.
+ac_delim='%!_!# '
+for ac_last_try in false false :; do
+ ac_tt=`sed -n "/$ac_delim/p" confdefs.h`
+ if test -z "$ac_tt"; then
+ break
+ elif $ac_last_try; then
+ as_fn_error $? "could not make $CONFIG_HEADERS" "$LINENO" 5
+ else
+ ac_delim="$ac_delim!$ac_delim _$ac_delim!! "
+ fi
+done
+
+# For the awk script, D is an array of macro values keyed by name,
+# likewise P contains macro parameters if any. Preserve backslash
+# newline sequences.
+
+ac_word_re=[_$as_cr_Letters][_$as_cr_alnum]*
+sed -n '
+s/.\{148\}/&'"$ac_delim"'/g
+t rset
+:rset
+s/^[ ]*#[ ]*define[ ][ ]*/ /
+t def
+d
+:def
+s/\\$//
+t bsnl
+s/["\\]/\\&/g
+s/^ \('"$ac_word_re"'\)\(([^()]*)\)[ ]*\(.*\)/P["\1"]="\2"\
+D["\1"]=" \3"/p
+s/^ \('"$ac_word_re"'\)[ ]*\(.*\)/D["\1"]=" \2"/p
+d
+:bsnl
+s/["\\]/\\&/g
+s/^ \('"$ac_word_re"'\)\(([^()]*)\)[ ]*\(.*\)/P["\1"]="\2"\
+D["\1"]=" \3\\\\\\n"\\/p
+t cont
+s/^ \('"$ac_word_re"'\)[ ]*\(.*\)/D["\1"]=" \2\\\\\\n"\\/p
+t cont
+d
+:cont
+n
+s/.\{148\}/&'"$ac_delim"'/g
+t clear
+:clear
+s/\\$//
+t bsnlc
+s/["\\]/\\&/g; s/^/"/; s/$/"/p
+d
+:bsnlc
+s/["\\]/\\&/g; s/^/"/; s/$/\\\\\\n"\\/p
+b cont
+' <confdefs.h | sed '
+s/'"$ac_delim"'/"\\\
+"/g' >>$CONFIG_STATUS || ac_write_fail=1
+
+cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
+ for (key in D) D_is_set[key] = 1
+ FS = ""
+}
+/^[\t ]*#[\t ]*(define|undef)[\t ]+$ac_word_re([\t (]|\$)/ {
+ line = \$ 0
+ split(line, arg, " ")
+ if (arg[1] == "#") {
+ defundef = arg[2]
+ mac1 = arg[3]
+ } else {
+ defundef = substr(arg[1], 2)
+ mac1 = arg[2]
+ }
+ split(mac1, mac2, "(") #)
+ macro = mac2[1]
+ prefix = substr(line, 1, index(line, defundef) - 1)
+ if (D_is_set[macro]) {
+ # Preserve the white space surrounding the "#".
+ print prefix "define", macro P[macro] D[macro]
+ next
+ } else {
+ # Replace #undef with comments. This is necessary, for example,
+ # in the case of _POSIX_SOURCE, which is predefined and required
+ # on some systems where configure will not decide to define it.
+ if (defundef == "undef") {
+ print "/*", prefix defundef, macro, "*/"
+ next
+ }
+ }
+}
+{ print }
+_ACAWK
+_ACEOF
+cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
+ as_fn_error $? "could not setup config headers machinery" "$LINENO" 5
+fi # test -n "$CONFIG_HEADERS"
+
+
+eval set X " :F $CONFIG_FILES :H $CONFIG_HEADERS :L $CONFIG_LINKS :C $CONFIG_COMMANDS"
+shift
+for ac_tag
+do
+ case $ac_tag in
+ :[FHLC]) ac_mode=$ac_tag; continue;;
+ esac
+ case $ac_mode$ac_tag in
+ :[FHL]*:*);;
+ :L* | :C*:*) as_fn_error $? "invalid tag \`$ac_tag'" "$LINENO" 5;;
+ :[FH]-) ac_tag=-:-;;
+ :[FH]*) ac_tag=$ac_tag:$ac_tag.in;;
+ esac
+ ac_save_IFS=$IFS
+ IFS=:
+ set x $ac_tag
+ IFS=$ac_save_IFS
+ shift
+ ac_file=$1
+ shift
+
+ case $ac_mode in
+ :L) ac_source=$1;;
+ :[FH])
+ ac_file_inputs=
+ for ac_f
+ do
+ case $ac_f in
+ -) ac_f="$ac_tmp/stdin";;
+ *) # Look for the file first in the build tree, then in the source tree
+ # (if the path is not absolute). The absolute path cannot be DOS-style,
+ # because $ac_f cannot contain `:'.
+ test -f "$ac_f" ||
+ case $ac_f in
+ [\\/$]*) false;;
+ *) test -f "$srcdir/$ac_f" && ac_f="$srcdir/$ac_f";;
+ esac ||
+ as_fn_error 1 "cannot find input file: \`$ac_f'" "$LINENO" 5;;
+ esac
+ case $ac_f in *\'*) ac_f=`$as_echo "$ac_f" | sed "s/'/'\\\\\\\\''/g"`;; esac
+ as_fn_append ac_file_inputs " '$ac_f'"
+ done
+
+ # Let's still pretend it is `configure' which instantiates (i.e., don't
+ # use $as_me), people would be surprised to read:
+ # /* config.h. Generated by config.status. */
+ configure_input='Generated from '`
+ $as_echo "$*" | sed 's|^[^:]*/||;s|:[^:]*/|, |g'
+ `' by configure.'
+ if test x"$ac_file" != x-; then
+ configure_input="$ac_file. $configure_input"
+ { $as_echo "$as_me:${as_lineno-$LINENO}: creating $ac_file" >&5
+$as_echo "$as_me: creating $ac_file" >&6;}
+ fi
+ # Neutralize special characters interpreted by sed in replacement strings.
+ case $configure_input in #(
+ *\&* | *\|* | *\\* )
+ ac_sed_conf_input=`$as_echo "$configure_input" |
+ sed 's/[\\\\&|]/\\\\&/g'`;; #(
+ *) ac_sed_conf_input=$configure_input;;
+ esac
+
+ case $ac_tag in
+ *:-:* | *:-) cat >"$ac_tmp/stdin" \
+ || as_fn_error $? "could not create $ac_file" "$LINENO" 5 ;;
+ esac
+ ;;
+ esac
+
+ ac_dir=`$as_dirname -- "$ac_file" ||
+$as_expr X"$ac_file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
+ X"$ac_file" : 'X\(//\)[^/]' \| \
+ X"$ac_file" : 'X\(//\)$' \| \
+ X"$ac_file" : 'X\(/\)' \| . 2>/dev/null ||
+$as_echo X"$ac_file" |
+ sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{
+ s//\1/
+ q
+ }
+ /^X\(\/\/\)[^/].*/{
+ s//\1/
+ q
+ }
+ /^X\(\/\/\)$/{
+ s//\1/
+ q
+ }
+ /^X\(\/\).*/{
+ s//\1/
+ q
+ }
+ s/.*/./; q'`
+ as_dir="$ac_dir"; as_fn_mkdir_p
+ ac_builddir=.
+
+case "$ac_dir" in
+.) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;;
+*)
+ ac_dir_suffix=/`$as_echo "$ac_dir" | sed 's|^\.[\\/]||'`
+ # A ".." for each directory in $ac_dir_suffix.
+ ac_top_builddir_sub=`$as_echo "$ac_dir_suffix" | sed 's|/[^\\/]*|/..|g;s|/||'`
+ case $ac_top_builddir_sub in
+ "") ac_top_builddir_sub=. ac_top_build_prefix= ;;
+ *) ac_top_build_prefix=$ac_top_builddir_sub/ ;;
+ esac ;;
+esac
+ac_abs_top_builddir=$ac_pwd
+ac_abs_builddir=$ac_pwd$ac_dir_suffix
+# for backward compatibility:
+ac_top_builddir=$ac_top_build_prefix
+
+case $srcdir in
+ .) # We are building in place.
+ ac_srcdir=.
+ ac_top_srcdir=$ac_top_builddir_sub
+ ac_abs_top_srcdir=$ac_pwd ;;
+ [\\/]* | ?:[\\/]* ) # Absolute name.
+ ac_srcdir=$srcdir$ac_dir_suffix;
+ ac_top_srcdir=$srcdir
+ ac_abs_top_srcdir=$srcdir ;;
+ *) # Relative name.
+ ac_srcdir=$ac_top_build_prefix$srcdir$ac_dir_suffix
+ ac_top_srcdir=$ac_top_build_prefix$srcdir
+ ac_abs_top_srcdir=$ac_pwd/$srcdir ;;
+esac
+ac_abs_srcdir=$ac_abs_top_srcdir$ac_dir_suffix
+
+
+ case $ac_mode in
+ :F)
+ #
+ # CONFIG_FILE
+ #
+
+ case $INSTALL in
+ [\\/$]* | ?:[\\/]* ) ac_INSTALL=$INSTALL ;;
+ *) ac_INSTALL=$ac_top_build_prefix$INSTALL ;;
+ esac
+ ac_MKDIR_P=$MKDIR_P
+ case $MKDIR_P in
+ [\\/$]* | ?:[\\/]* ) ;;
+ */*) ac_MKDIR_P=$ac_top_build_prefix$MKDIR_P ;;
+ esac
+_ACEOF
+
+cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
+# If the template does not know about datarootdir, expand it.
+# FIXME: This hack should be removed a few years after 2.60.
+ac_datarootdir_hack=; ac_datarootdir_seen=
+ac_sed_dataroot='
+/datarootdir/ {
+ p
+ q
+}
+/@datadir@/p
+/@docdir@/p
+/@infodir@/p
+/@localedir@/p
+/@mandir@/p'
+case `eval "sed -n \"\$ac_sed_dataroot\" $ac_file_inputs"` in
+*datarootdir*) ac_datarootdir_seen=yes;;
+*@datadir@*|*@docdir@*|*@infodir@*|*@localedir@*|*@mandir@*)
+ { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&5
+$as_echo "$as_me: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&2;}
+_ACEOF
+cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
+ ac_datarootdir_hack='
+ s&@datadir@&$datadir&g
+ s&@docdir@&$docdir&g
+ s&@infodir@&$infodir&g
+ s&@localedir@&$localedir&g
+ s&@mandir@&$mandir&g
+ s&\\\${datarootdir}&$datarootdir&g' ;;
+esac
+_ACEOF
+
+# Neutralize VPATH when `$srcdir' = `.'.
+# Shell code in configure.ac might set extrasub.
+# FIXME: do we really want to maintain this feature?
+cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
+ac_sed_extra="$ac_vpsub
+$extrasub
+_ACEOF
+cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
+:t
+/@[a-zA-Z_][a-zA-Z_0-9]*@/!b
+s|@configure_input@|$ac_sed_conf_input|;t t
+s&@top_builddir@&$ac_top_builddir_sub&;t t
+s&@top_build_prefix@&$ac_top_build_prefix&;t t
+s&@srcdir@&$ac_srcdir&;t t
+s&@abs_srcdir@&$ac_abs_srcdir&;t t
+s&@top_srcdir@&$ac_top_srcdir&;t t
+s&@abs_top_srcdir@&$ac_abs_top_srcdir&;t t
+s&@builddir@&$ac_builddir&;t t
+s&@abs_builddir@&$ac_abs_builddir&;t t
+s&@abs_top_builddir@&$ac_abs_top_builddir&;t t
+s&@INSTALL@&$ac_INSTALL&;t t
+s&@MKDIR_P@&$ac_MKDIR_P&;t t
+$ac_datarootdir_hack
+"
+eval sed \"\$ac_sed_extra\" "$ac_file_inputs" | $AWK -f "$ac_tmp/subs.awk" \
+ >$ac_tmp/out || as_fn_error $? "could not create $ac_file" "$LINENO" 5
+
+test -z "$ac_datarootdir_hack$ac_datarootdir_seen" &&
+ { ac_out=`sed -n '/\${datarootdir}/p' "$ac_tmp/out"`; test -n "$ac_out"; } &&
+ { ac_out=`sed -n '/^[ ]*datarootdir[ ]*:*=/p' \
+ "$ac_tmp/out"`; test -z "$ac_out"; } &&
+ { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $ac_file contains a reference to the variable \`datarootdir'
+which seems to be undefined. Please make sure it is defined" >&5
+$as_echo "$as_me: WARNING: $ac_file contains a reference to the variable \`datarootdir'
+which seems to be undefined. Please make sure it is defined" >&2;}
+
+ rm -f "$ac_tmp/stdin"
+ case $ac_file in
+ -) cat "$ac_tmp/out" && rm -f "$ac_tmp/out";;
+ *) rm -f "$ac_file" && mv "$ac_tmp/out" "$ac_file";;
+ esac \
+ || as_fn_error $? "could not create $ac_file" "$LINENO" 5
+ ;;
+ :H)
+ #
+ # CONFIG_HEADER
+ #
+ if test x"$ac_file" != x-; then
+ {
+ $as_echo "/* $configure_input */" \
+ && eval '$AWK -f "$ac_tmp/defines.awk"' "$ac_file_inputs"
+ } >"$ac_tmp/config.h" \
+ || as_fn_error $? "could not create $ac_file" "$LINENO" 5
+ if diff "$ac_file" "$ac_tmp/config.h" >/dev/null 2>&1; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: $ac_file is unchanged" >&5
+$as_echo "$as_me: $ac_file is unchanged" >&6;}
+ else
+ rm -f "$ac_file"
+ mv "$ac_tmp/config.h" "$ac_file" \
+ || as_fn_error $? "could not create $ac_file" "$LINENO" 5
+ fi
+ else
+ $as_echo "/* $configure_input */" \
+ && eval '$AWK -f "$ac_tmp/defines.awk"' "$ac_file_inputs" \
+ || as_fn_error $? "could not create -" "$LINENO" 5
+ fi
+# Compute "$ac_file"'s index in $config_headers.
+_am_arg="$ac_file"
+_am_stamp_count=1
+for _am_header in $config_headers :; do
+ case $_am_header in
+ $_am_arg | $_am_arg:* )
+ break ;;
+ * )
+ _am_stamp_count=`expr $_am_stamp_count + 1` ;;
+ esac
+done
+echo "timestamp for $_am_arg" >`$as_dirname -- "$_am_arg" ||
+$as_expr X"$_am_arg" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
+ X"$_am_arg" : 'X\(//\)[^/]' \| \
+ X"$_am_arg" : 'X\(//\)$' \| \
+ X"$_am_arg" : 'X\(/\)' \| . 2>/dev/null ||
+$as_echo X"$_am_arg" |
+ sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{
+ s//\1/
+ q
+ }
+ /^X\(\/\/\)[^/].*/{
+ s//\1/
+ q
+ }
+ /^X\(\/\/\)$/{
+ s//\1/
+ q
+ }
+ /^X\(\/\).*/{
+ s//\1/
+ q
+ }
+ s/.*/./; q'`/stamp-h$_am_stamp_count
+ ;;
+ :L)
+ #
+ # CONFIG_LINK
+ #
+
+ if test "$ac_source" = "$ac_file" && test "$srcdir" = '.'; then
+ :
+ else
+ # Prefer the file from the source tree if names are identical.
+ if test "$ac_source" = "$ac_file" || test ! -r "$ac_source"; then
+ ac_source=$srcdir/$ac_source
+ fi
+
+ { $as_echo "$as_me:${as_lineno-$LINENO}: linking $ac_source to $ac_file" >&5
+$as_echo "$as_me: linking $ac_source to $ac_file" >&6;}
+
+ if test ! -r "$ac_source"; then
+ as_fn_error $? "$ac_source: file not found" "$LINENO" 5
+ fi
+ rm -f "$ac_file"
+
+ # Try a relative symlink, then a hard link, then a copy.
+ case $ac_source in
+ [\\/$]* | ?:[\\/]* ) ac_rel_source=$ac_source ;;
+ *) ac_rel_source=$ac_top_build_prefix$ac_source ;;
+ esac
+ ln -s "$ac_rel_source" "$ac_file" 2>/dev/null ||
+ ln "$ac_source" "$ac_file" 2>/dev/null ||
+ cp -p "$ac_source" "$ac_file" ||
+ as_fn_error $? "cannot link or copy $ac_source to $ac_file" "$LINENO" 5
+ fi
+ ;;
+ :C) { $as_echo "$as_me:${as_lineno-$LINENO}: executing $ac_file commands" >&5
+$as_echo "$as_me: executing $ac_file commands" >&6;}
+ ;;
+ esac
+
+
+ case $ac_file$ac_mode in
+ "buildir":C) ac_top_srcdir="$ax_enable_builddir_srcdir"
+ if test ".$ax_enable_builddir" = ".." ; then
+ if test -f "$top_srcdir/Makefile" ; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: skipping top_srcdir/Makefile - left untouched" >&5
+$as_echo "$as_me: skipping top_srcdir/Makefile - left untouched" >&6;}
+ else
+ { $as_echo "$as_me:${as_lineno-$LINENO}: skipping top_srcdir/Makefile - not created" >&5
+$as_echo "$as_me: skipping top_srcdir/Makefile - not created" >&6;}
+ fi
+ else
+ if test -f "$ac_top_srcdir/Makefile" ; then
+ a=`grep "^VERSION " "$ac_top_srcdir/Makefile"` ; b=`grep "^VERSION " Makefile`
+ test "$a" != "$b" && rm "$ac_top_srcdir/Makefile"
+ fi
+ if test -f "$ac_top_srcdir/Makefile" ; then
+ echo "$ac_top_srcdir/Makefile : $ac_top_srcdir/Makefile.in" > $tmp/conftemp.mk
+ echo " @ echo 'REMOVED,,,' >\$@" >> $tmp/conftemp.mk
+ eval "${MAKE-make} -f $tmp/conftemp.mk 2>/dev/null >/dev/null"
+ if grep '^REMOVED,,,' "$ac_top_srcdir/Makefile" >/dev/null
+ then rm $ac_top_srcdir/Makefile ; fi
+ cp $tmp/conftemp.mk $ac_top_srcdir/makefiles.mk~ ## DEBUGGING
+ fi
+ if test ! -f "$ac_top_srcdir/Makefile" ; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: create top_srcdir/Makefile guessed from local Makefile" >&5
+$as_echo "$as_me: create top_srcdir/Makefile guessed from local Makefile" >&6;}
+ x='`' ; cat >$tmp/conftemp.sed <<_EOF
+/^\$/n
+x
+/^\$/bS
+x
+/\\\\\$/{H;d;}
+{H;s/.*//;x;}
+bM
+:S
+x
+/\\\\\$/{h;d;}
+{h;s/.*//;x;}
+:M
+s/\\(\\n\\) /\\1 /g
+/^ /d
+/^[ ]*[\\#]/d
+/^VPATH *=/d
+s/^srcdir *=.*/srcdir = ./
+s/^top_srcdir *=.*/top_srcdir = ./
+/[:=]/!d
+/^\\./d
+/ = /b
+/ .= /b
+/:/!b
+s/:.*/:/
+s/ / /g
+s/ \\([a-z][a-z-]*[a-zA-Z0-9]\\)\\([ :]\\)/ \\1 \\1-all\\2/g
+s/^\\([a-z][a-z-]*[a-zA-Z0-9]\\)\\([ :]\\)/\\1 \\1-all\\2/
+s/ / /g
+/^all all-all[ :]/i\\
+all-configured : all-all
+s/ [a-zA-Z0-9-]*-all [a-zA-Z0-9-]*-all-all//g
+/-all-all/d
+a\\
+ @ HOST="\$(HOST)\" \\\\\\
+ ; test ".\$\$HOST" = "." && HOST=$x sh $ax_enable_builddir_auxdir/config.guess $x \\\\\\
+ ; BUILD=$x grep "^#### \$\$HOST " Makefile | sed -e 's/.*|//' $x \\\\\\
+ ; use=$x basename "\$\@" -all $x; n=$x echo \$\$BUILD | wc -w $x \\\\\\
+ ; echo "MAKE \$\$HOST : \$\$n * \$\@"; if test "\$\$n" -eq "0" ; then : \\\\\\
+ ; BUILD=$x grep "^####.*|" Makefile |tail -1| sed -e 's/.*|//' $x ; fi \\\\\\
+ ; test ".\$\$BUILD" = "." && BUILD="." \\\\\\
+ ; test "\$\$use" = "\$\@" && BUILD=$x echo "\$\$BUILD" | tail -1 $x \\\\\\
+ ; for i in \$\$BUILD ; do test ".\$\$i" = "." && continue \\\\\\
+ ; (cd "\$\$i" && test ! -f configure && \$(MAKE) \$\$use) || exit; done
+/dist-all *:/a\\
+ @ HOST="\$(HOST)\" \\\\\\
+ ; test ".\$\$HOST" = "." && HOST=$x sh $ax_enable_builddir_auxdir/config.guess $x \\\\\\
+ ; BUILD=$x grep "^#### \$\$HOST " Makefile | sed -e 's/.*|//' $x \\\\\\
+ ; found=$x echo \$\$BUILD | wc -w $x \\\\\\
+ ; echo "MAKE \$\$HOST : \$\$found \$(PACKAGE)-\$(VERSION).tar.*" \\\\\\
+ ; if test "\$\$found" -eq "0" ; then : \\\\\\
+ ; BUILD=$x grep "^#### .*|" Makefile |tail -1| sed -e 's/.*|//' $x \\\\\\
+ ; fi ; for i in \$\$BUILD ; do test ".\$\$i" = "." && continue \\\\\\
+ ; for f in \$\$i/\$(PACKAGE)-\$(VERSION).tar.* \\\\\\
+ ; do test -f "\$\$f" && mv "\$\$f" \$(PUB). ; done ; break ; done
+/dist-[a-zA-Z0-9]*-all *:/a\\
+ @ HOST="\$(HOST)\" \\\\\\
+ ; test ".\$\$HOST" = "." && HOST=$x sh ./config.guess $x \\\\\\
+ ; BUILD=$x grep "^#### \$\$HOST " Makefile | sed -e 's/.*|//' $x \\\\\\
+ ; found=$x echo \$\$BUILD | wc -w $x \\\\\\
+ ; echo "MAKE \$\$HOST : \$\$found \$(PACKAGE)-\$(VERSION).*" \\\\\\
+ ; if test "\$\$found" -eq "0" ; then : \\\\\\
+ ; BUILD=$x grep "^#### .*|" Makefile |tail -1| sed -e 's/.*|//' $x \\\\\\
+ ; fi ; for i in \$\$BUILD ; do test ".\$\$i" = "." && continue \\\\\\
+ ; for f in \$\$i/\$(PACKAGE)-\$(VERSION).* \\\\\\
+ ; do test -f "\$\$f" && mv "\$\$f" \$(PUB). ; done ; break ; done
+/distclean-all *:/a\\
+ @ HOST="\$(HOST)\" \\\\\\
+ ; test ".\$\$HOST" = "." && HOST=$x sh $ax_enable_builddir_auxdir/config.guess $x \\\\\\
+ ; BUILD=$x grep "^#### .*|" Makefile | sed -e 's/.*|//' $x \\\\\\
+ ; use=$x basename "\$\@" -all $x; n=$x echo \$\$BUILD | wc -w $x \\\\\\
+ ; echo "MAKE \$\$HOST : \$\$n * \$\@ (all local builds)" \\\\\\
+ ; test ".\$\$BUILD" = "." && BUILD="." \\\\\\
+ ; for i in \$\$BUILD ; do test ".\$\$i" = "." && continue \\\\\\
+ ; echo "# rm -r \$\$i"; done ; echo "# (sleep 3)" ; sleep 3 \\\\\\
+ ; for i in \$\$BUILD ; do test ".\$\$i" = "." && continue \\\\\\
+ ; echo "\$\$i" | grep "^/" > /dev/null && continue \\\\\\
+ ; echo "\$\$i" | grep "^../" > /dev/null && continue \\\\\\
+ ; echo "rm -r \$\$i"; (rm -r "\$\$i") ; done ; rm Makefile
+_EOF
+ cp "$tmp/conftemp.sed" "$ac_top_srcdir/makefile.sed~" ## DEBUGGING
+ $ax_enable_builddir_sed -f $tmp/conftemp.sed Makefile >$ac_top_srcdir/Makefile
+ if test -f "$ac_top_srcdir/Makefile.mk" ; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: extend top_srcdir/Makefile with top_srcdir/Makefile.mk" >&5
+$as_echo "$as_me: extend top_srcdir/Makefile with top_srcdir/Makefile.mk" >&6;}
+ cat $ac_top_srcdir/Makefile.mk >>$ac_top_srcdir/Makefile
+ fi ; xxxx="####"
+ echo "$xxxx CONFIGURATIONS FOR TOPLEVEL MAKEFILE: " >>$ac_top_srcdir/Makefile
+ # sanity check
+ if grep '^; echo "MAKE ' $ac_top_srcdir/Makefile >/dev/null ; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: buggy sed found - it deletes tab in \"a\" text parts" >&5
+$as_echo "$as_me: buggy sed found - it deletes tab in \"a\" text parts" >&6;}
+ $ax_enable_builddir_sed -e '/^@ HOST=/s/^/ /' -e '/^; /s/^/ /' $ac_top_srcdir/Makefile \
+ >$ac_top_srcdir/Makefile~
+ (test -s $ac_top_srcdir/Makefile~ && mv $ac_top_srcdir/Makefile~ $ac_top_srcdir/Makefile) 2>/dev/null
+ fi
+ else
+ xxxx="\\#\\#\\#\\#"
+ # echo "/^$xxxx *$ax_enable_builddir_host /d" >$tmp/conftemp.sed
+ echo "s!^$xxxx [^|]* | *$ax_enable_builddir *\$!$xxxx ...... $ax_enable_builddir!" >$tmp/conftemp.sed
+ $ax_enable_builddir_sed -f "$tmp/conftemp.sed" "$ac_top_srcdir/Makefile" >$tmp/mkfile.tmp
+ cp "$tmp/conftemp.sed" "$ac_top_srcdir/makefiles.sed~" ## DEBUGGING
+ cp "$tmp/mkfile.tmp" "$ac_top_srcdir/makefiles.out~" ## DEBUGGING
+ if cmp -s "$ac_top_srcdir/Makefile" "$tmp/mkfile.tmp" 2>/dev/null ; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: keeping top_srcdir/Makefile from earlier configure" >&5
+$as_echo "$as_me: keeping top_srcdir/Makefile from earlier configure" >&6;}
+ rm "$tmp/mkfile.tmp"
+ else
+ { $as_echo "$as_me:${as_lineno-$LINENO}: reusing top_srcdir/Makefile from earlier configure" >&5
+$as_echo "$as_me: reusing top_srcdir/Makefile from earlier configure" >&6;}
+ mv "$tmp/mkfile.tmp" "$ac_top_srcdir/Makefile"
+ fi
+ fi
+ { $as_echo "$as_me:${as_lineno-$LINENO}: build in $ax_enable_builddir (HOST=$ax_enable_builddir_host)" >&5
+$as_echo "$as_me: build in $ax_enable_builddir (HOST=$ax_enable_builddir_host)" >&6;}
+ xxxx="####"
+ echo "$xxxx" "$ax_enable_builddir_host" "|$ax_enable_builddir" >>$ac_top_srcdir/Makefile
+ fi
+ ;;
+ "depfiles":C) test x"$AMDEP_TRUE" != x"" || {
+ # Older Autoconf quotes --file arguments for eval, but not when files
+ # are listed without --file. Let's play safe and only enable the eval
+ # if we detect the quoting.
+ case $CONFIG_FILES in
+ *\'*) eval set x "$CONFIG_FILES" ;;
+ *) set x $CONFIG_FILES ;;
+ esac
+ shift
+ for mf
+ do
+ # Strip MF so we end up with the name of the file.
+ mf=`echo "$mf" | sed -e 's/:.*$//'`
+ # Check whether this is an Automake generated Makefile or not.
+ # We used to match only the files named 'Makefile.in', but
+ # some people rename them; so instead we look at the file content.
+ # Grep'ing the first line is not enough: some people post-process
+ # each Makefile.in and add a new line on top of each file to say so.
+ # Grep'ing the whole file is not good either: AIX grep has a line
+ # limit of 2048, but all sed's we know have understand at least 4000.
+ if sed -n 's,^#.*generated by automake.*,X,p' "$mf" | grep X >/dev/null 2>&1; then
+ dirpart=`$as_dirname -- "$mf" ||
+$as_expr X"$mf" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
+ X"$mf" : 'X\(//\)[^/]' \| \
+ X"$mf" : 'X\(//\)$' \| \
+ X"$mf" : 'X\(/\)' \| . 2>/dev/null ||
+$as_echo X"$mf" |
+ sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{
+ s//\1/
+ q
+ }
+ /^X\(\/\/\)[^/].*/{
+ s//\1/
+ q
+ }
+ /^X\(\/\/\)$/{
+ s//\1/
+ q
+ }
+ /^X\(\/\).*/{
+ s//\1/
+ q
+ }
+ s/.*/./; q'`
+ else
+ continue
+ fi
+ # Extract the definition of DEPDIR, am__include, and am__quote
+ # from the Makefile without running 'make'.
+ DEPDIR=`sed -n 's/^DEPDIR = //p' < "$mf"`
+ test -z "$DEPDIR" && continue
+ am__include=`sed -n 's/^am__include = //p' < "$mf"`
+ test -z "$am__include" && continue
+ am__quote=`sed -n 's/^am__quote = //p' < "$mf"`
+ # Find all dependency output files, they are included files with
+ # $(DEPDIR) in their names. We invoke sed twice because it is the
+ # simplest approach to changing $(DEPDIR) to its actual value in the
+ # expansion.
+ for file in `sed -n "
+ s/^$am__include $am__quote\(.*(DEPDIR).*\)$am__quote"'$/\1/p' <"$mf" | \
+ sed -e 's/\$(DEPDIR)/'"$DEPDIR"'/g'`; do
+ # Make sure the directory exists.
+ test -f "$dirpart/$file" && continue
+ fdir=`$as_dirname -- "$file" ||
+$as_expr X"$file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
+ X"$file" : 'X\(//\)[^/]' \| \
+ X"$file" : 'X\(//\)$' \| \
+ X"$file" : 'X\(/\)' \| . 2>/dev/null ||
+$as_echo X"$file" |
+ sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{
+ s//\1/
+ q
+ }
+ /^X\(\/\/\)[^/].*/{
+ s//\1/
+ q
+ }
+ /^X\(\/\/\)$/{
+ s//\1/
+ q
+ }
+ /^X\(\/\).*/{
+ s//\1/
+ q
+ }
+ s/.*/./; q'`
+ as_dir=$dirpart/$fdir; as_fn_mkdir_p
+ # echo "creating $dirpart/$file"
+ echo '# dummy' > "$dirpart/$file"
+ done
+ done
+}
+ ;;
+ "libtool":C)
+
+ # See if we are running on zsh, and set the options which allow our
+ # commands through without removal of \ escapes.
+ if test -n "${ZSH_VERSION+set}" ; then
+ setopt NO_GLOB_SUBST
+ fi
+
+ cfgfile="${ofile}T"
+ trap "$RM \"$cfgfile\"; exit 1" 1 2 15
+ $RM "$cfgfile"
+
+ cat <<_LT_EOF >> "$cfgfile"
+#! $SHELL
+
+# `$ECHO "$ofile" | sed 's%^.*/%%'` - Provide generalized library-building support services.
+# Generated automatically by $as_me ($PACKAGE$TIMESTAMP) $VERSION
+# Libtool was configured on host `(hostname || uname -n) 2>/dev/null | sed 1q`:
+# NOTE: Changes made to this file will be lost: look at ltmain.sh.
+#
+# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005,
+# 2006, 2007, 2008, 2009, 2010, 2011 Free Software
+# Foundation, Inc.
+# Written by Gordon Matzigkeit, 1996
+#
+# This file is part of GNU Libtool.
+#
+# GNU Libtool is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License as
+# published by the Free Software Foundation; either version 2 of
+# the License, or (at your option) any later version.
+#
+# As a special exception to the GNU General Public License,
+# if you distribute this file as part of a program or library that
+# is built using GNU Libtool, you may include this file under the
+# same distribution terms that you use for the rest of that program.
+#
+# GNU Libtool is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with GNU Libtool; see the file COPYING. If not, a copy
+# can be downloaded from http://www.gnu.org/licenses/gpl.html, or
+# obtained by writing to the Free Software Foundation, Inc.,
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+
+# The names of the tagged configurations supported by this script.
+available_tags="CXX "
+
+# ### BEGIN LIBTOOL CONFIG
+
+# Which release of libtool.m4 was used?
+macro_version=$macro_version
+macro_revision=$macro_revision
+
+# Whether or not to build shared libraries.
+build_libtool_libs=$enable_shared
+
+# Whether or not to build static libraries.
+build_old_libs=$enable_static
+
+# What type of objects to build.
+pic_mode=$pic_mode
+
+# Whether or not to optimize for fast installation.
+fast_install=$enable_fast_install
+
+# Shell to use when invoking shell scripts.
+SHELL=$lt_SHELL
+
+# An echo program that protects backslashes.
+ECHO=$lt_ECHO
+
+# The PATH separator for the build system.
+PATH_SEPARATOR=$lt_PATH_SEPARATOR
+
+# The host system.
+host_alias=$host_alias
+host=$host
+host_os=$host_os
+
+# The build system.
+build_alias=$build_alias
+build=$build
+build_os=$build_os
+
+# A sed program that does not truncate output.
+SED=$lt_SED
+
+# Sed that helps us avoid accidentally triggering echo(1) options like -n.
+Xsed="\$SED -e 1s/^X//"
+
+# A grep program that handles long lines.
+GREP=$lt_GREP
+
+# An ERE matcher.
+EGREP=$lt_EGREP
+
+# A literal string matcher.
+FGREP=$lt_FGREP
+
+# A BSD- or MS-compatible name lister.
+NM=$lt_NM
+
+# Whether we need soft or hard links.
+LN_S=$lt_LN_S
+
+# What is the maximum length of a command?
+max_cmd_len=$max_cmd_len
+
+# Object file suffix (normally "o").
+objext=$ac_objext
+
+# Executable file suffix (normally "").
+exeext=$exeext
+
+# whether the shell understands "unset".
+lt_unset=$lt_unset
+
+# turn spaces into newlines.
+SP2NL=$lt_lt_SP2NL
+
+# turn newlines into spaces.
+NL2SP=$lt_lt_NL2SP
+
+# convert \$build file names to \$host format.
+to_host_file_cmd=$lt_cv_to_host_file_cmd
+
+# convert \$build files to toolchain format.
+to_tool_file_cmd=$lt_cv_to_tool_file_cmd
+
+# An object symbol dumper.
+OBJDUMP=$lt_OBJDUMP
+
+# Method to check whether dependent libraries are shared objects.
+deplibs_check_method=$lt_deplibs_check_method
+
+# Command to use when deplibs_check_method = "file_magic".
+file_magic_cmd=$lt_file_magic_cmd
+
+# How to find potential files when deplibs_check_method = "file_magic".
+file_magic_glob=$lt_file_magic_glob
+
+# Find potential files using nocaseglob when deplibs_check_method = "file_magic".
+want_nocaseglob=$lt_want_nocaseglob
+
+# DLL creation program.
+DLLTOOL=$lt_DLLTOOL
+
+# Command to associate shared and link libraries.
+sharedlib_from_linklib_cmd=$lt_sharedlib_from_linklib_cmd
+
+# The archiver.
+AR=$lt_AR
+
+# Flags to create an archive.
+AR_FLAGS=$lt_AR_FLAGS
+
+# How to feed a file listing to the archiver.
+archiver_list_spec=$lt_archiver_list_spec
+
+# A symbol stripping program.
+STRIP=$lt_STRIP
+
+# Commands used to install an old-style archive.
+RANLIB=$lt_RANLIB
+old_postinstall_cmds=$lt_old_postinstall_cmds
+old_postuninstall_cmds=$lt_old_postuninstall_cmds
+
+# Whether to use a lock for old archive extraction.
+lock_old_archive_extraction=$lock_old_archive_extraction
+
+# A C compiler.
+LTCC=$lt_CC
+
+# LTCC compiler flags.
+LTCFLAGS=$lt_CFLAGS
+
+# Take the output of nm and produce a listing of raw symbols and C names.
+global_symbol_pipe=$lt_lt_cv_sys_global_symbol_pipe
+
+# Transform the output of nm in a proper C declaration.
+global_symbol_to_cdecl=$lt_lt_cv_sys_global_symbol_to_cdecl
+
+# Transform the output of nm in a C name address pair.
+global_symbol_to_c_name_address=$lt_lt_cv_sys_global_symbol_to_c_name_address
+
+# Transform the output of nm in a C name address pair when lib prefix is needed.
+global_symbol_to_c_name_address_lib_prefix=$lt_lt_cv_sys_global_symbol_to_c_name_address_lib_prefix
+
+# Specify filename containing input files for \$NM.
+nm_file_list_spec=$lt_nm_file_list_spec
+
+# The root where to search for dependent libraries,and in which our libraries should be installed.
+lt_sysroot=$lt_sysroot
+
+# The name of the directory that contains temporary libtool files.
+objdir=$objdir
+
+# Used to examine libraries when file_magic_cmd begins with "file".
+MAGIC_CMD=$MAGIC_CMD
+
+# Must we lock files when doing compilation?
+need_locks=$lt_need_locks
+
+# Manifest tool.
+MANIFEST_TOOL=$lt_MANIFEST_TOOL
+
+# Tool to manipulate archived DWARF debug symbol files on Mac OS X.
+DSYMUTIL=$lt_DSYMUTIL
+
+# Tool to change global to local symbols on Mac OS X.
+NMEDIT=$lt_NMEDIT
+
+# Tool to manipulate fat objects and archives on Mac OS X.
+LIPO=$lt_LIPO
+
+# ldd/readelf like tool for Mach-O binaries on Mac OS X.
+OTOOL=$lt_OTOOL
+
+# ldd/readelf like tool for 64 bit Mach-O binaries on Mac OS X 10.4.
+OTOOL64=$lt_OTOOL64
+
+# Old archive suffix (normally "a").
+libext=$libext
+
+# Shared library suffix (normally ".so").
+shrext_cmds=$lt_shrext_cmds
+
+# The commands to extract the exported symbol list from a shared archive.
+extract_expsyms_cmds=$lt_extract_expsyms_cmds
+
+# Variables whose values should be saved in libtool wrapper scripts and
+# restored at link time.
+variables_saved_for_relink=$lt_variables_saved_for_relink
+
+# Do we need the "lib" prefix for modules?
+need_lib_prefix=$need_lib_prefix
+
+# Do we need a version for libraries?
+need_version=$need_version
+
+# Library versioning type.
+version_type=$version_type
+
+# Shared library runtime path variable.
+runpath_var=$runpath_var
+
+# Shared library path variable.
+shlibpath_var=$shlibpath_var
+
+# Is shlibpath searched before the hard-coded library search path?
+shlibpath_overrides_runpath=$shlibpath_overrides_runpath
+
+# Format of library name prefix.
+libname_spec=$lt_libname_spec
+
+# List of archive names. First name is the real one, the rest are links.
+# The last name is the one that the linker finds with -lNAME
+library_names_spec=$lt_library_names_spec
+
+# The coded name of the library, if different from the real name.
+soname_spec=$lt_soname_spec
+
+# Permission mode override for installation of shared libraries.
+install_override_mode=$lt_install_override_mode
+
+# Command to use after installation of a shared archive.
+postinstall_cmds=$lt_postinstall_cmds
+
+# Command to use after uninstallation of a shared archive.
+postuninstall_cmds=$lt_postuninstall_cmds
+
+# Commands used to finish a libtool library installation in a directory.
+finish_cmds=$lt_finish_cmds
+
+# As "finish_cmds", except a single script fragment to be evaled but
+# not shown.
+finish_eval=$lt_finish_eval
+
+# Whether we should hardcode library paths into libraries.
+hardcode_into_libs=$hardcode_into_libs
+
+# Compile-time system search path for libraries.
+sys_lib_search_path_spec=$lt_sys_lib_search_path_spec
+
+# Run-time system search path for libraries.
+sys_lib_dlsearch_path_spec=$lt_sys_lib_dlsearch_path_spec
+
+# Whether dlopen is supported.
+dlopen_support=$enable_dlopen
+
+# Whether dlopen of programs is supported.
+dlopen_self=$enable_dlopen_self
+
+# Whether dlopen of statically linked programs is supported.
+dlopen_self_static=$enable_dlopen_self_static
+
+# Commands to strip libraries.
+old_striplib=$lt_old_striplib
+striplib=$lt_striplib
+
+
+# The linker used to build libraries.
+LD=$lt_LD
+
+# How to create reloadable object files.
+reload_flag=$lt_reload_flag
+reload_cmds=$lt_reload_cmds
+
+# Commands used to build an old-style archive.
+old_archive_cmds=$lt_old_archive_cmds
+
+# A language specific compiler.
+CC=$lt_compiler
+
+# Is the compiler the GNU compiler?
+with_gcc=$GCC
+
+# Compiler flag to turn off builtin functions.
+no_builtin_flag=$lt_lt_prog_compiler_no_builtin_flag
+
+# Additional compiler flags for building library objects.
+pic_flag=$lt_lt_prog_compiler_pic
+
+# How to pass a linker flag through the compiler.
+wl=$lt_lt_prog_compiler_wl
+
+# Compiler flag to prevent dynamic linking.
+link_static_flag=$lt_lt_prog_compiler_static
+
+# Does compiler simultaneously support -c and -o options?
+compiler_c_o=$lt_lt_cv_prog_compiler_c_o
+
+# Whether or not to add -lc for building shared libraries.
+build_libtool_need_lc=$archive_cmds_need_lc
+
+# Whether or not to disallow shared libs when runtime libs are static.
+allow_libtool_libs_with_static_runtimes=$enable_shared_with_static_runtimes
+
+# Compiler flag to allow reflexive dlopens.
+export_dynamic_flag_spec=$lt_export_dynamic_flag_spec
+
+# Compiler flag to generate shared objects directly from archives.
+whole_archive_flag_spec=$lt_whole_archive_flag_spec
+
+# Whether the compiler copes with passing no objects directly.
+compiler_needs_object=$lt_compiler_needs_object
+
+# Create an old-style archive from a shared archive.
+old_archive_from_new_cmds=$lt_old_archive_from_new_cmds
+
+# Create a temporary old-style archive to link instead of a shared archive.
+old_archive_from_expsyms_cmds=$lt_old_archive_from_expsyms_cmds
+
+# Commands used to build a shared archive.
+archive_cmds=$lt_archive_cmds
+archive_expsym_cmds=$lt_archive_expsym_cmds
+
+# Commands used to build a loadable module if different from building
+# a shared archive.
+module_cmds=$lt_module_cmds
+module_expsym_cmds=$lt_module_expsym_cmds
+
+# Whether we are building with GNU ld or not.
+with_gnu_ld=$lt_with_gnu_ld
+
+# Flag that allows shared libraries with undefined symbols to be built.
+allow_undefined_flag=$lt_allow_undefined_flag
+
+# Flag that enforces no undefined symbols.
+no_undefined_flag=$lt_no_undefined_flag
+
+# Flag to hardcode \$libdir into a binary during linking.
+# This must work even if \$libdir does not exist
+hardcode_libdir_flag_spec=$lt_hardcode_libdir_flag_spec
+
+# Whether we need a single "-rpath" flag with a separated argument.
+hardcode_libdir_separator=$lt_hardcode_libdir_separator
+
+# Set to "yes" if using DIR/libNAME\${shared_ext} during linking hardcodes
+# DIR into the resulting binary.
+hardcode_direct=$hardcode_direct
+
+# Set to "yes" if using DIR/libNAME\${shared_ext} during linking hardcodes
+# DIR into the resulting binary and the resulting library dependency is
+# "absolute",i.e impossible to change by setting \${shlibpath_var} if the
+# library is relocated.
+hardcode_direct_absolute=$hardcode_direct_absolute
+
+# Set to "yes" if using the -LDIR flag during linking hardcodes DIR
+# into the resulting binary.
+hardcode_minus_L=$hardcode_minus_L
+
+# Set to "yes" if using SHLIBPATH_VAR=DIR during linking hardcodes DIR
+# into the resulting binary.
+hardcode_shlibpath_var=$hardcode_shlibpath_var
+
+# Set to "yes" if building a shared library automatically hardcodes DIR
+# into the library and all subsequent libraries and executables linked
+# against it.
+hardcode_automatic=$hardcode_automatic
+
+# Set to yes if linker adds runtime paths of dependent libraries
+# to runtime path list.
+inherit_rpath=$inherit_rpath
+
+# Whether libtool must link a program against all its dependency libraries.
+link_all_deplibs=$link_all_deplibs
+
+# Set to "yes" if exported symbols are required.
+always_export_symbols=$always_export_symbols
+
+# The commands to list exported symbols.
+export_symbols_cmds=$lt_export_symbols_cmds
+
+# Symbols that should not be listed in the preloaded symbols.
+exclude_expsyms=$lt_exclude_expsyms
+
+# Symbols that must always be exported.
+include_expsyms=$lt_include_expsyms
+
+# Commands necessary for linking programs (against libraries) with templates.
+prelink_cmds=$lt_prelink_cmds
+
+# Commands necessary for finishing linking programs.
+postlink_cmds=$lt_postlink_cmds
+
+# Specify filename containing input files.
+file_list_spec=$lt_file_list_spec
+
+# How to hardcode a shared library path into an executable.
+hardcode_action=$hardcode_action
+
+# The directories searched by this compiler when creating a shared library.
+compiler_lib_search_dirs=$lt_compiler_lib_search_dirs
+
+# Dependencies to place before and after the objects being linked to
+# create a shared library.
+predep_objects=$lt_predep_objects
+postdep_objects=$lt_postdep_objects
+predeps=$lt_predeps
+postdeps=$lt_postdeps
+
+# The library search path used internally by the compiler when linking
+# a shared library.
+compiler_lib_search_path=$lt_compiler_lib_search_path
+
+# ### END LIBTOOL CONFIG
+
+_LT_EOF
+
+ case $host_os in
+ aix3*)
+ cat <<\_LT_EOF >> "$cfgfile"
+# AIX sometimes has problems with the GCC collect2 program. For some
+# reason, if we set the COLLECT_NAMES environment variable, the problems
+# vanish in a puff of smoke.
+if test "X${COLLECT_NAMES+set}" != Xset; then
+ COLLECT_NAMES=
+ export COLLECT_NAMES
+fi
+_LT_EOF
+ ;;
+ esac
+
+
+ltmain="$ac_aux_dir/ltmain.sh"
+
+
+ # We use sed instead of cat because bash on DJGPP gets confused if
+ # if finds mixed CR/LF and LF-only lines. Since sed operates in
+ # text mode, it properly converts lines to CR/LF. This bash problem
+ # is reportedly fixed, but why not run on old versions too?
+ sed '$q' "$ltmain" >> "$cfgfile" \
+ || (rm -f "$cfgfile"; exit 1)
+
+ if test x"$xsi_shell" = xyes; then
+ sed -e '/^func_dirname ()$/,/^} # func_dirname /c\
+func_dirname ()\
+{\
+\ case ${1} in\
+\ */*) func_dirname_result="${1%/*}${2}" ;;\
+\ * ) func_dirname_result="${3}" ;;\
+\ esac\
+} # Extended-shell func_dirname implementation' "$cfgfile" > $cfgfile.tmp \
+ && mv -f "$cfgfile.tmp" "$cfgfile" \
+ || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp")
+test 0 -eq $? || _lt_function_replace_fail=:
+
+
+ sed -e '/^func_basename ()$/,/^} # func_basename /c\
+func_basename ()\
+{\
+\ func_basename_result="${1##*/}"\
+} # Extended-shell func_basename implementation' "$cfgfile" > $cfgfile.tmp \
+ && mv -f "$cfgfile.tmp" "$cfgfile" \
+ || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp")
+test 0 -eq $? || _lt_function_replace_fail=:
+
+
+ sed -e '/^func_dirname_and_basename ()$/,/^} # func_dirname_and_basename /c\
+func_dirname_and_basename ()\
+{\
+\ case ${1} in\
+\ */*) func_dirname_result="${1%/*}${2}" ;;\
+\ * ) func_dirname_result="${3}" ;;\
+\ esac\
+\ func_basename_result="${1##*/}"\
+} # Extended-shell func_dirname_and_basename implementation' "$cfgfile" > $cfgfile.tmp \
+ && mv -f "$cfgfile.tmp" "$cfgfile" \
+ || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp")
+test 0 -eq $? || _lt_function_replace_fail=:
+
+
+ sed -e '/^func_stripname ()$/,/^} # func_stripname /c\
+func_stripname ()\
+{\
+\ # pdksh 5.2.14 does not do ${X%$Y} correctly if both X and Y are\
+\ # positional parameters, so assign one to ordinary parameter first.\
+\ func_stripname_result=${3}\
+\ func_stripname_result=${func_stripname_result#"${1}"}\
+\ func_stripname_result=${func_stripname_result%"${2}"}\
+} # Extended-shell func_stripname implementation' "$cfgfile" > $cfgfile.tmp \
+ && mv -f "$cfgfile.tmp" "$cfgfile" \
+ || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp")
+test 0 -eq $? || _lt_function_replace_fail=:
+
+
+ sed -e '/^func_split_long_opt ()$/,/^} # func_split_long_opt /c\
+func_split_long_opt ()\
+{\
+\ func_split_long_opt_name=${1%%=*}\
+\ func_split_long_opt_arg=${1#*=}\
+} # Extended-shell func_split_long_opt implementation' "$cfgfile" > $cfgfile.tmp \
+ && mv -f "$cfgfile.tmp" "$cfgfile" \
+ || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp")
+test 0 -eq $? || _lt_function_replace_fail=:
+
+
+ sed -e '/^func_split_short_opt ()$/,/^} # func_split_short_opt /c\
+func_split_short_opt ()\
+{\
+\ func_split_short_opt_arg=${1#??}\
+\ func_split_short_opt_name=${1%"$func_split_short_opt_arg"}\
+} # Extended-shell func_split_short_opt implementation' "$cfgfile" > $cfgfile.tmp \
+ && mv -f "$cfgfile.tmp" "$cfgfile" \
+ || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp")
+test 0 -eq $? || _lt_function_replace_fail=:
+
+
+ sed -e '/^func_lo2o ()$/,/^} # func_lo2o /c\
+func_lo2o ()\
+{\
+\ case ${1} in\
+\ *.lo) func_lo2o_result=${1%.lo}.${objext} ;;\
+\ *) func_lo2o_result=${1} ;;\
+\ esac\
+} # Extended-shell func_lo2o implementation' "$cfgfile" > $cfgfile.tmp \
+ && mv -f "$cfgfile.tmp" "$cfgfile" \
+ || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp")
+test 0 -eq $? || _lt_function_replace_fail=:
+
+
+ sed -e '/^func_xform ()$/,/^} # func_xform /c\
+func_xform ()\
+{\
+ func_xform_result=${1%.*}.lo\
+} # Extended-shell func_xform implementation' "$cfgfile" > $cfgfile.tmp \
+ && mv -f "$cfgfile.tmp" "$cfgfile" \
+ || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp")
+test 0 -eq $? || _lt_function_replace_fail=:
+
+
+ sed -e '/^func_arith ()$/,/^} # func_arith /c\
+func_arith ()\
+{\
+ func_arith_result=$(( $* ))\
+} # Extended-shell func_arith implementation' "$cfgfile" > $cfgfile.tmp \
+ && mv -f "$cfgfile.tmp" "$cfgfile" \
+ || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp")
+test 0 -eq $? || _lt_function_replace_fail=:
+
+
+ sed -e '/^func_len ()$/,/^} # func_len /c\
+func_len ()\
+{\
+ func_len_result=${#1}\
+} # Extended-shell func_len implementation' "$cfgfile" > $cfgfile.tmp \
+ && mv -f "$cfgfile.tmp" "$cfgfile" \
+ || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp")
+test 0 -eq $? || _lt_function_replace_fail=:
+
+fi
+
+if test x"$lt_shell_append" = xyes; then
+ sed -e '/^func_append ()$/,/^} # func_append /c\
+func_append ()\
+{\
+ eval "${1}+=\\${2}"\
+} # Extended-shell func_append implementation' "$cfgfile" > $cfgfile.tmp \
+ && mv -f "$cfgfile.tmp" "$cfgfile" \
+ || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp")
+test 0 -eq $? || _lt_function_replace_fail=:
+
+
+ sed -e '/^func_append_quoted ()$/,/^} # func_append_quoted /c\
+func_append_quoted ()\
+{\
+\ func_quote_for_eval "${2}"\
+\ eval "${1}+=\\\\ \\$func_quote_for_eval_result"\
+} # Extended-shell func_append_quoted implementation' "$cfgfile" > $cfgfile.tmp \
+ && mv -f "$cfgfile.tmp" "$cfgfile" \
+ || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp")
+test 0 -eq $? || _lt_function_replace_fail=:
+
+
+ # Save a `func_append' function call where possible by direct use of '+='
+ sed -e 's%func_append \([a-zA-Z_]\{1,\}\) "%\1+="%g' $cfgfile > $cfgfile.tmp \
+ && mv -f "$cfgfile.tmp" "$cfgfile" \
+ || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp")
+ test 0 -eq $? || _lt_function_replace_fail=:
+else
+ # Save a `func_append' function call even when '+=' is not available
+ sed -e 's%func_append \([a-zA-Z_]\{1,\}\) "%\1="$\1%g' $cfgfile > $cfgfile.tmp \
+ && mv -f "$cfgfile.tmp" "$cfgfile" \
+ || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp")
+ test 0 -eq $? || _lt_function_replace_fail=:
+fi
+
+if test x"$_lt_function_replace_fail" = x":"; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Unable to substitute extended shell functions in $ofile" >&5
+$as_echo "$as_me: WARNING: Unable to substitute extended shell functions in $ofile" >&2;}
+fi
+
+
+ mv -f "$cfgfile" "$ofile" ||
+ (rm -f "$ofile" && cp "$cfgfile" "$ofile" && rm -f "$cfgfile")
+ chmod +x "$ofile"
+
+
+ cat <<_LT_EOF >> "$ofile"
+
+# ### BEGIN LIBTOOL TAG CONFIG: CXX
+
+# The linker used to build libraries.
+LD=$lt_LD_CXX
+
+# How to create reloadable object files.
+reload_flag=$lt_reload_flag_CXX
+reload_cmds=$lt_reload_cmds_CXX
+
+# Commands used to build an old-style archive.
+old_archive_cmds=$lt_old_archive_cmds_CXX
+
+# A language specific compiler.
+CC=$lt_compiler_CXX
+
+# Is the compiler the GNU compiler?
+with_gcc=$GCC_CXX
+
+# Compiler flag to turn off builtin functions.
+no_builtin_flag=$lt_lt_prog_compiler_no_builtin_flag_CXX
+
+# Additional compiler flags for building library objects.
+pic_flag=$lt_lt_prog_compiler_pic_CXX
+
+# How to pass a linker flag through the compiler.
+wl=$lt_lt_prog_compiler_wl_CXX
+
+# Compiler flag to prevent dynamic linking.
+link_static_flag=$lt_lt_prog_compiler_static_CXX
+
+# Does compiler simultaneously support -c and -o options?
+compiler_c_o=$lt_lt_cv_prog_compiler_c_o_CXX
+
+# Whether or not to add -lc for building shared libraries.
+build_libtool_need_lc=$archive_cmds_need_lc_CXX
+
+# Whether or not to disallow shared libs when runtime libs are static.
+allow_libtool_libs_with_static_runtimes=$enable_shared_with_static_runtimes_CXX
+
+# Compiler flag to allow reflexive dlopens.
+export_dynamic_flag_spec=$lt_export_dynamic_flag_spec_CXX
+
+# Compiler flag to generate shared objects directly from archives.
+whole_archive_flag_spec=$lt_whole_archive_flag_spec_CXX
+
+# Whether the compiler copes with passing no objects directly.
+compiler_needs_object=$lt_compiler_needs_object_CXX
+
+# Create an old-style archive from a shared archive.
+old_archive_from_new_cmds=$lt_old_archive_from_new_cmds_CXX
+
+# Create a temporary old-style archive to link instead of a shared archive.
+old_archive_from_expsyms_cmds=$lt_old_archive_from_expsyms_cmds_CXX
+
+# Commands used to build a shared archive.
+archive_cmds=$lt_archive_cmds_CXX
+archive_expsym_cmds=$lt_archive_expsym_cmds_CXX
+
+# Commands used to build a loadable module if different from building
+# a shared archive.
+module_cmds=$lt_module_cmds_CXX
+module_expsym_cmds=$lt_module_expsym_cmds_CXX
+
+# Whether we are building with GNU ld or not.
+with_gnu_ld=$lt_with_gnu_ld_CXX
+
+# Flag that allows shared libraries with undefined symbols to be built.
+allow_undefined_flag=$lt_allow_undefined_flag_CXX
+
+# Flag that enforces no undefined symbols.
+no_undefined_flag=$lt_no_undefined_flag_CXX
+
+# Flag to hardcode \$libdir into a binary during linking.
+# This must work even if \$libdir does not exist
+hardcode_libdir_flag_spec=$lt_hardcode_libdir_flag_spec_CXX
+
+# Whether we need a single "-rpath" flag with a separated argument.
+hardcode_libdir_separator=$lt_hardcode_libdir_separator_CXX
+
+# Set to "yes" if using DIR/libNAME\${shared_ext} during linking hardcodes
+# DIR into the resulting binary.
+hardcode_direct=$hardcode_direct_CXX
+
+# Set to "yes" if using DIR/libNAME\${shared_ext} during linking hardcodes
+# DIR into the resulting binary and the resulting library dependency is
+# "absolute",i.e impossible to change by setting \${shlibpath_var} if the
+# library is relocated.
+hardcode_direct_absolute=$hardcode_direct_absolute_CXX
+
+# Set to "yes" if using the -LDIR flag during linking hardcodes DIR
+# into the resulting binary.
+hardcode_minus_L=$hardcode_minus_L_CXX
+
+# Set to "yes" if using SHLIBPATH_VAR=DIR during linking hardcodes DIR
+# into the resulting binary.
+hardcode_shlibpath_var=$hardcode_shlibpath_var_CXX
+
+# Set to "yes" if building a shared library automatically hardcodes DIR
+# into the library and all subsequent libraries and executables linked
+# against it.
+hardcode_automatic=$hardcode_automatic_CXX
+
+# Set to yes if linker adds runtime paths of dependent libraries
+# to runtime path list.
+inherit_rpath=$inherit_rpath_CXX
+
+# Whether libtool must link a program against all its dependency libraries.
+link_all_deplibs=$link_all_deplibs_CXX
+
+# Set to "yes" if exported symbols are required.
+always_export_symbols=$always_export_symbols_CXX
+
+# The commands to list exported symbols.
+export_symbols_cmds=$lt_export_symbols_cmds_CXX
+
+# Symbols that should not be listed in the preloaded symbols.
+exclude_expsyms=$lt_exclude_expsyms_CXX
+
+# Symbols that must always be exported.
+include_expsyms=$lt_include_expsyms_CXX
+
+# Commands necessary for linking programs (against libraries) with templates.
+prelink_cmds=$lt_prelink_cmds_CXX
+
+# Commands necessary for finishing linking programs.
+postlink_cmds=$lt_postlink_cmds_CXX
+
+# Specify filename containing input files.
+file_list_spec=$lt_file_list_spec_CXX
+
+# How to hardcode a shared library path into an executable.
+hardcode_action=$hardcode_action_CXX
+
+# The directories searched by this compiler when creating a shared library.
+compiler_lib_search_dirs=$lt_compiler_lib_search_dirs_CXX
+
+# Dependencies to place before and after the objects being linked to
+# create a shared library.
+predep_objects=$lt_predep_objects_CXX
+postdep_objects=$lt_postdep_objects_CXX
+predeps=$lt_predeps_CXX
+postdeps=$lt_postdeps_CXX
+
+# The library search path used internally by the compiler when linking
+# a shared library.
+compiler_lib_search_path=$lt_compiler_lib_search_path_CXX
+
+# ### END LIBTOOL TAG CONFIG: CXX
+_LT_EOF
+
+ ;;
+ "include":C) test -d include || mkdir include ;;
+ "src":C)
+test -d src || mkdir src
+test -d src/$TARGETDIR || mkdir src/$TARGETDIR
+ ;;
+
+ esac
+done # for ac_tag
+
+
+as_fn_exit 0
+_ACEOF
+ac_clean_files=$ac_clean_files_save
+
+test $ac_write_fail = 0 ||
+ as_fn_error $? "write failure creating $CONFIG_STATUS" "$LINENO" 5
+
+
+# configure is writing to config.log, and then calls config.status.
+# config.status does its own redirection, appending to config.log.
+# Unfortunately, on DOS this fails, as config.log is still kept open
+# by configure, so config.status won't be able to write to it; its
+# output is simply discarded. So we exec the FD to /dev/null,
+# effectively closing config.log, so it can be properly (re)opened and
+# appended to by config.status. When coming back to configure, we
+# need to make the FD available again.
+if test "$no_create" != yes; then
+ ac_cs_success=:
+ ac_config_status_args=
+ test "$silent" = yes &&
+ ac_config_status_args="$ac_config_status_args --quiet"
+ exec 5>/dev/null
+ $SHELL $CONFIG_STATUS $ac_config_status_args || ac_cs_success=false
+ exec 5>>config.log
+ # Use ||, not &&, to avoid exiting from the if with $? = 1, which
+ # would make configure fail if this is the last instruction.
+ $ac_cs_success || as_fn_exit 1
+fi
+if test -n "$ac_unrecognized_opts" && test "$enable_option_checking" != no; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: unrecognized options: $ac_unrecognized_opts" >&5
+$as_echo "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2;}
+fi
+
diff --git a/jni/ruby/ext/fiddle/libffi-3.2.1/configure.ac b/jni/ruby/ext/fiddle/libffi-3.2.1/configure.ac
new file mode 100644
index 0000000..a7bf5ee
--- /dev/null
+++ b/jni/ruby/ext/fiddle/libffi-3.2.1/configure.ac
@@ -0,0 +1,625 @@
+dnl Process this with autoconf to create configure
+
+AC_PREREQ(2.68)
+
+AC_INIT([libffi], [3.2.1], [http://github.com/atgreen/libffi/issues])
+AC_CONFIG_HEADERS([fficonfig.h])
+
+AC_CANONICAL_SYSTEM
+target_alias=${target_alias-$host_alias}
+
+case "${host}" in
+ frv*-elf)
+ LDFLAGS=`echo $LDFLAGS | sed "s/\-B[^ ]*libgloss\/frv\///"`\ -B`pwd`/../libgloss/frv/
+ ;;
+esac
+
+AX_ENABLE_BUILDDIR
+
+AM_INIT_AUTOMAKE
+
+# The same as in boehm-gc and libstdc++. Have to borrow it from there.
+# We must force CC to /not/ be precious variables; otherwise
+# the wrong, non-multilib-adjusted value will be used in multilibs.
+# As a side effect, we have to subst CFLAGS ourselves.
+# Also save and restore CFLAGS, since AC_PROG_CC will come up with
+# defaults of its own if none are provided.
+
+m4_rename([_AC_ARG_VAR_PRECIOUS],[real_PRECIOUS])
+m4_define([_AC_ARG_VAR_PRECIOUS],[])
+save_CFLAGS=$CFLAGS
+AC_PROG_CC
+AC_PROG_CXX
+CFLAGS=$save_CFLAGS
+m4_undefine([_AC_ARG_VAR_PRECIOUS])
+m4_rename_force([real_PRECIOUS],[_AC_ARG_VAR_PRECIOUS])
+
+AC_SUBST(CFLAGS)
+
+AM_PROG_AS
+AM_PROG_CC_C_O
+AC_PROG_LIBTOOL
+AC_CONFIG_MACRO_DIR([m4])
+
+# Test for 64-bit build.
+AC_CHECK_SIZEOF([size_t])
+
+AX_COMPILER_VENDOR
+AX_CC_MAXOPT
+# The AX_CFLAGS_WARN_ALL macro doesn't currently work for sunpro
+# compiler.
+if test "$ax_cv_c_compiler_vendor" != "sun"; then
+ AX_CFLAGS_WARN_ALL
+fi
+
+if test "x$GCC" = "xyes"; then
+ CFLAGS="$CFLAGS -fexceptions"
+fi
+
+cat > local.exp <<EOF
+set CC_FOR_TARGET "$CC"
+set CXX_FOR_TARGET "$CXX"
+EOF
+
+AM_MAINTAINER_MODE
+
+AC_CHECK_HEADERS(sys/mman.h)
+AC_CHECK_FUNCS([mmap mkostemp])
+AC_FUNC_MMAP_BLACKLIST
+
+dnl The -no-testsuite modules omit the test subdir.
+AM_CONDITIONAL(TESTSUBDIR, test -d $srcdir/testsuite)
+
+TARGETDIR="unknown"
+HAVE_LONG_DOUBLE_VARIANT=0
+case "$host" in
+ aarch64*-*-*)
+ TARGET=AARCH64; TARGETDIR=aarch64
+ ;;
+
+ alpha*-*-*)
+ TARGET=ALPHA; TARGETDIR=alpha;
+ # Support 128-bit long double, changeable via command-line switch.
+ HAVE_LONG_DOUBLE='defined(__LONG_DOUBLE_128__)'
+ ;;
+
+ arc*-*-*)
+ TARGET=ARC; TARGETDIR=arc
+ ;;
+
+ arm*-*-*)
+ TARGET=ARM; TARGETDIR=arm
+ ;;
+
+ amd64-*-freebsd* | amd64-*-openbsd*)
+ TARGET=X86_64; TARGETDIR=x86
+ ;;
+
+ amd64-*-freebsd*)
+ TARGET=X86_64; TARGETDIR=x86
+ ;;
+
+ amd64-*-freebsd*)
+ TARGET=X86_64; TARGETDIR=x86
+ ;;
+
+ avr32*-*-*)
+ TARGET=AVR32; TARGETDIR=avr32
+ ;;
+
+ bfin*)
+ TARGET=BFIN; TARGETDIR=bfin
+ ;;
+
+ cris-*-*)
+ TARGET=LIBFFI_CRIS; TARGETDIR=cris
+ ;;
+
+ frv-*-*)
+ TARGET=FRV; TARGETDIR=frv
+ ;;
+
+ hppa*-*-linux* | parisc*-*-linux* | hppa*-*-openbsd*)
+ TARGET=PA_LINUX; TARGETDIR=pa
+ ;;
+ hppa*64-*-hpux*)
+ TARGET=PA64_HPUX; TARGETDIR=pa
+ ;;
+ hppa*-*-hpux*)
+ TARGET=PA_HPUX; TARGETDIR=pa
+ ;;
+
+ i?86-*-freebsd* | i?86-*-openbsd*)
+ TARGET=X86_FREEBSD; TARGETDIR=x86
+ ;;
+ i?86-win32* | i?86-*-cygwin* | i?86-*-mingw* | i?86-*-os2* | i?86-*-interix*)
+ TARGET=X86_WIN32; TARGETDIR=x86
+ # All mingw/cygwin/win32 builds require -no-undefined for sharedlib.
+ # We must also check with_cross_host to decide if this is a native
+ # or cross-build and select where to install dlls appropriately.
+ if test -n "$with_cross_host" &&
+ test x"$with_cross_host" != x"no"; then
+ AM_LTLDFLAGS='-no-undefined -bindir "$(toolexeclibdir)"';
+ else
+ AM_LTLDFLAGS='-no-undefined -bindir "$(bindir)"';
+ fi
+ ;;
+ i?86-*-darwin*)
+ TARGET=X86_DARWIN; TARGETDIR=x86
+ ;;
+ i?86-*-solaris2.1[[0-9]]*)
+ TARGETDIR=x86
+ if test $ac_cv_sizeof_size_t = 4; then
+ TARGET=X86;
+ else
+ TARGET=X86_64;
+ fi
+ ;;
+
+ x86_64-*-darwin*)
+ TARGET=X86_DARWIN; TARGETDIR=x86
+ ;;
+
+ x86_64-*-cygwin* | x86_64-*-mingw*)
+ TARGET=X86_WIN64; TARGETDIR=x86
+ # All mingw/cygwin/win32 builds require -no-undefined for sharedlib.
+ # We must also check with_cross_host to decide if this is a native
+ # or cross-build and select where to install dlls appropriately.
+ if test -n "$with_cross_host" &&
+ test x"$with_cross_host" != x"no"; then
+ AM_LTLDFLAGS='-no-undefined -bindir "$(toolexeclibdir)"';
+ else
+ AM_LTLDFLAGS='-no-undefined -bindir "$(bindir)"';
+ fi
+ ;;
+
+ i?86-*-* | x86_64-*-*)
+ TARGETDIR=x86
+ if test $ac_cv_sizeof_size_t = 4; then
+ case "$host" in
+ *-gnux32)
+ TARGET=X86_64
+ ;;
+ *)
+ TARGET=X86
+ ;;
+ esac
+ else
+ TARGET=X86_64;
+ fi
+ ;;
+
+ ia64*-*-*)
+ TARGET=IA64; TARGETDIR=ia64
+ ;;
+
+ m32r*-*-*)
+ TARGET=M32R; TARGETDIR=m32r
+ ;;
+
+ m68k-*-*)
+ TARGET=M68K; TARGETDIR=m68k
+ ;;
+
+ m88k-*-*)
+ TARGET=M88K; TARGETDIR=m88k
+ ;;
+
+ microblaze*-*-*)
+ TARGET=MICROBLAZE; TARGETDIR=microblaze
+ ;;
+
+ moxie-*-*)
+ TARGET=MOXIE; TARGETDIR=moxie
+ ;;
+
+ metag-*-*)
+ TARGET=METAG; TARGETDIR=metag
+ ;;
+
+ mips-sgi-irix5.* | mips-sgi-irix6.* | mips*-*-rtems*)
+ TARGET=MIPS; TARGETDIR=mips
+ ;;
+ mips*-*linux* | mips*-*-openbsd*)
+ # Support 128-bit long double for NewABI.
+ HAVE_LONG_DOUBLE='defined(__mips64)'
+ TARGET=MIPS; TARGETDIR=mips
+ ;;
+
+ nios2*-linux*)
+ TARGET=NIOS2; TARGETDIR=nios2
+ ;;
+
+ or1k*-linux*)
+ TARGET=OR1K; TARGETDIR=or1k
+ ;;
+
+ powerpc*-*-linux* | powerpc-*-sysv*)
+ TARGET=POWERPC; TARGETDIR=powerpc
+ HAVE_LONG_DOUBLE_VARIANT=1
+ ;;
+ powerpc-*-amigaos*)
+ TARGET=POWERPC; TARGETDIR=powerpc
+ ;;
+ powerpc-*-beos*)
+ TARGET=POWERPC; TARGETDIR=powerpc
+ ;;
+ powerpc-*-darwin* | powerpc64-*-darwin*)
+ TARGET=POWERPC_DARWIN; TARGETDIR=powerpc
+ ;;
+ powerpc-*-aix* | rs6000-*-aix*)
+ TARGET=POWERPC_AIX; TARGETDIR=powerpc
+ ;;
+ powerpc-*-freebsd* | powerpc-*-openbsd*)
+ TARGET=POWERPC_FREEBSD; TARGETDIR=powerpc
+ HAVE_LONG_DOUBLE_VARIANT=1
+ ;;
+ powerpc64-*-freebsd*)
+ TARGET=POWERPC; TARGETDIR=powerpc
+ ;;
+ powerpc*-*-rtems*)
+ TARGET=POWERPC; TARGETDIR=powerpc
+ ;;
+
+ s390-*-* | s390x-*-*)
+ TARGET=S390; TARGETDIR=s390
+ ;;
+
+ sh-*-* | sh[[34]]*-*-*)
+ TARGET=SH; TARGETDIR=sh
+ ;;
+ sh64-*-* | sh5*-*-*)
+ TARGET=SH64; TARGETDIR=sh64
+ ;;
+
+ sparc*-*-*)
+ TARGET=SPARC; TARGETDIR=sparc
+ ;;
+
+ tile*-*)
+ TARGET=TILE; TARGETDIR=tile
+ ;;
+
+ vax-*-*)
+ TARGET=VAX; TARGETDIR=vax
+ ;;
+
+ xtensa*-*)
+ TARGET=XTENSA; TARGETDIR=xtensa
+ ;;
+
+esac
+
+AC_SUBST(AM_RUNTESTFLAGS)
+AC_SUBST(AM_LTLDFLAGS)
+
+if test $TARGETDIR = unknown; then
+ AC_MSG_ERROR(["libffi has not been ported to $host."])
+fi
+
+AM_CONDITIONAL(MIPS, test x$TARGET = xMIPS)
+AM_CONDITIONAL(BFIN, test x$TARGET = xBFIN)
+AM_CONDITIONAL(SPARC, test x$TARGET = xSPARC)
+AM_CONDITIONAL(X86, test x$TARGET = xX86)
+AM_CONDITIONAL(X86_FREEBSD, test x$TARGET = xX86_FREEBSD)
+AM_CONDITIONAL(X86_WIN32, test x$TARGET = xX86_WIN32)
+AM_CONDITIONAL(X86_WIN64, test x$TARGET = xX86_WIN64)
+AM_CONDITIONAL(X86_DARWIN, test x$TARGET = xX86_DARWIN)
+AM_CONDITIONAL(X86_DARWIN32, test x$TARGET = xX86_DARWIN && test $ac_cv_sizeof_size_t = 4)
+AM_CONDITIONAL(X86_DARWIN64, test x$TARGET = xX86_DARWIN && test $ac_cv_sizeof_size_t = 8)
+AM_CONDITIONAL(ALPHA, test x$TARGET = xALPHA)
+AM_CONDITIONAL(IA64, test x$TARGET = xIA64)
+AM_CONDITIONAL(M32R, test x$TARGET = xM32R)
+AM_CONDITIONAL(M68K, test x$TARGET = xM68K)
+AM_CONDITIONAL(M88K, test x$TARGET = xM88K)
+AM_CONDITIONAL(MICROBLAZE, test x$TARGET = xMICROBLAZE)
+AM_CONDITIONAL(METAG, test x$TARGET = xMETAG)
+AM_CONDITIONAL(MOXIE, test x$TARGET = xMOXIE)
+AM_CONDITIONAL(NIOS2, test x$TARGET = xNIOS2)
+AM_CONDITIONAL(OR1K, test x$TARGET = xOR1K)
+AM_CONDITIONAL(POWERPC, test x$TARGET = xPOWERPC)
+AM_CONDITIONAL(POWERPC_AIX, test x$TARGET = xPOWERPC_AIX)
+AM_CONDITIONAL(POWERPC_DARWIN, test x$TARGET = xPOWERPC_DARWIN)
+AM_CONDITIONAL(POWERPC_FREEBSD, test x$TARGET = xPOWERPC_FREEBSD)
+AM_CONDITIONAL(AARCH64, test x$TARGET = xAARCH64)
+AM_CONDITIONAL(ARC, test x$TARGET = xARC)
+AM_CONDITIONAL(ARM, test x$TARGET = xARM)
+AM_CONDITIONAL(AVR32, test x$TARGET = xAVR32)
+AM_CONDITIONAL(LIBFFI_CRIS, test x$TARGET = xLIBFFI_CRIS)
+AM_CONDITIONAL(FRV, test x$TARGET = xFRV)
+AM_CONDITIONAL(S390, test x$TARGET = xS390)
+AM_CONDITIONAL(X86_64, test x$TARGET = xX86_64)
+AM_CONDITIONAL(SH, test x$TARGET = xSH)
+AM_CONDITIONAL(SH64, test x$TARGET = xSH64)
+AM_CONDITIONAL(PA_LINUX, test x$TARGET = xPA_LINUX)
+AM_CONDITIONAL(PA_HPUX, test x$TARGET = xPA_HPUX)
+AM_CONDITIONAL(PA64_HPUX, test x$TARGET = xPA64_HPUX)
+AM_CONDITIONAL(TILE, test x$TARGET = xTILE)
+AM_CONDITIONAL(VAX, test x$TARGET = xVAX)
+AM_CONDITIONAL(XTENSA, test x$TARGET = xXTENSA)
+
+AC_HEADER_STDC
+AC_CHECK_FUNCS(memcpy)
+AC_FUNC_ALLOCA
+
+AC_CHECK_SIZEOF(double)
+AC_CHECK_SIZEOF(long double)
+
+# Also AC_SUBST this variable for ffi.h.
+if test -z "$HAVE_LONG_DOUBLE"; then
+ HAVE_LONG_DOUBLE=0
+ if test $ac_cv_sizeof_long_double != 0; then
+ if test $HAVE_LONG_DOUBLE_VARIANT != 0; then
+ AC_DEFINE(HAVE_LONG_DOUBLE_VARIANT, 1, [Define if you support more than one size of the long double type])
+ HAVE_LONG_DOUBLE=1
+ else
+ if test $ac_cv_sizeof_double != $ac_cv_sizeof_long_double; then
+ HAVE_LONG_DOUBLE=1
+ AC_DEFINE(HAVE_LONG_DOUBLE, 1, [Define if you have the long double type and it is bigger than a double])
+ fi
+ fi
+ fi
+fi
+AC_SUBST(HAVE_LONG_DOUBLE)
+AC_SUBST(HAVE_LONG_DOUBLE_VARIANT)
+
+AC_C_BIGENDIAN
+
+GCC_AS_CFI_PSEUDO_OP
+
+if test x$TARGET = xSPARC; then
+ AC_CACHE_CHECK([assembler and linker support unaligned pc related relocs],
+ libffi_cv_as_sparc_ua_pcrel, [
+ save_CFLAGS="$CFLAGS"
+ save_LDFLAGS="$LDFLAGS"
+ CFLAGS="$CFLAGS -fpic"
+ LDFLAGS="$LDFLAGS -shared"
+ AC_TRY_LINK([asm (".text; foo: nop; .data; .align 4; .byte 0; .uaword %r_disp32(foo); .text");],,
+ [libffi_cv_as_sparc_ua_pcrel=yes],
+ [libffi_cv_as_sparc_ua_pcrel=no])
+ CFLAGS="$save_CFLAGS"
+ LDFLAGS="$save_LDFLAGS"])
+ if test "x$libffi_cv_as_sparc_ua_pcrel" = xyes; then
+ AC_DEFINE(HAVE_AS_SPARC_UA_PCREL, 1,
+ [Define if your assembler and linker support unaligned PC relative relocs.])
+ fi
+
+ AC_CACHE_CHECK([assembler .register pseudo-op support],
+ libffi_cv_as_register_pseudo_op, [
+ libffi_cv_as_register_pseudo_op=unknown
+ # Check if we have .register
+ AC_TRY_COMPILE(,[asm (".register %g2, #scratch");],
+ [libffi_cv_as_register_pseudo_op=yes],
+ [libffi_cv_as_register_pseudo_op=no])
+ ])
+ if test "x$libffi_cv_as_register_pseudo_op" = xyes; then
+ AC_DEFINE(HAVE_AS_REGISTER_PSEUDO_OP, 1,
+ [Define if your assembler supports .register.])
+ fi
+fi
+
+if test x$TARGET = xX86 || test x$TARGET = xX86_WIN32 || test x$TARGET = xX86_64; then
+ AC_CACHE_CHECK([assembler supports pc related relocs],
+ libffi_cv_as_x86_pcrel, [
+ libffi_cv_as_x86_pcrel=no
+ echo '.text; foo: nop; .data; .long foo-.; .text' > conftest.s
+ if $CC $CFLAGS -c conftest.s > /dev/null 2>&1; then
+ libffi_cv_as_x86_pcrel=yes
+ fi
+ ])
+ if test "x$libffi_cv_as_x86_pcrel" = xyes; then
+ AC_DEFINE(HAVE_AS_X86_PCREL, 1,
+ [Define if your assembler supports PC relative relocs.])
+ fi
+
+ AC_CACHE_CHECK([assembler .ascii pseudo-op support],
+ libffi_cv_as_ascii_pseudo_op, [
+ libffi_cv_as_ascii_pseudo_op=unknown
+ # Check if we have .ascii
+ AC_TRY_COMPILE(,[asm (".ascii \\"string\\"");],
+ [libffi_cv_as_ascii_pseudo_op=yes],
+ [libffi_cv_as_ascii_pseudo_op=no])
+ ])
+ if test "x$libffi_cv_as_ascii_pseudo_op" = xyes; then
+ AC_DEFINE(HAVE_AS_ASCII_PSEUDO_OP, 1,
+ [Define if your assembler supports .ascii.])
+ fi
+
+ AC_CACHE_CHECK([assembler .string pseudo-op support],
+ libffi_cv_as_string_pseudo_op, [
+ libffi_cv_as_string_pseudo_op=unknown
+ # Check if we have .string
+ AC_TRY_COMPILE(,[asm (".string \\"string\\"");],
+ [libffi_cv_as_string_pseudo_op=yes],
+ [libffi_cv_as_string_pseudo_op=no])
+ ])
+ if test "x$libffi_cv_as_string_pseudo_op" = xyes; then
+ AC_DEFINE(HAVE_AS_STRING_PSEUDO_OP, 1,
+ [Define if your assembler supports .string.])
+ fi
+fi
+
+# On PaX enable kernels that have MPROTECT enable we can't use PROT_EXEC.
+AC_ARG_ENABLE(pax_emutramp,
+ [ --enable-pax_emutramp enable pax emulated trampolines, for we can't use PROT_EXEC],
+ if test "$enable_pax_emutramp" = "yes"; then
+ AC_DEFINE(FFI_MMAP_EXEC_EMUTRAMP_PAX, 1,
+ [Define this if you want to enable pax emulated trampolines])
+ fi)
+
+LT_SYS_SYMBOL_USCORE
+if test "x$sys_symbol_underscore" = xyes; then
+ AC_DEFINE(SYMBOL_UNDERSCORE, 1, [Define if symbols are underscored.])
+fi
+
+FFI_EXEC_TRAMPOLINE_TABLE=0
+case "$target" in
+ *arm*-apple-darwin*)
+ FFI_EXEC_TRAMPOLINE_TABLE=1
+ AC_DEFINE(FFI_EXEC_TRAMPOLINE_TABLE, 1,
+ [Cannot use PROT_EXEC on this target, so, we revert to
+ alternative means])
+ ;;
+ *-apple-darwin1* | *-*-freebsd* | *-*-kfreebsd* | *-*-openbsd* | *-pc-solaris*)
+ AC_DEFINE(FFI_MMAP_EXEC_WRIT, 1,
+ [Cannot use malloc on this target, so, we revert to
+ alternative means])
+ ;;
+esac
+AM_CONDITIONAL(FFI_EXEC_TRAMPOLINE_TABLE, test x$FFI_EXEC_TRAMPOLINE_TABLE = x1)
+AC_SUBST(FFI_EXEC_TRAMPOLINE_TABLE)
+
+if test x$TARGET = xX86_64; then
+ AC_CACHE_CHECK([toolchain supports unwind section type],
+ libffi_cv_as_x86_64_unwind_section_type, [
+ cat > conftest1.s << EOF
+.text
+.globl foo
+foo:
+jmp bar
+.section .eh_frame,"a",@unwind
+bar:
+EOF
+
+ cat > conftest2.c << EOF
+extern void foo();
+int main(){foo();}
+EOF
+
+ libffi_cv_as_x86_64_unwind_section_type=no
+ # we ensure that we can compile _and_ link an assembly file containing an @unwind section
+ # since the compiler can support it and not the linker (ie old binutils)
+ if $CC -Wa,--fatal-warnings $CFLAGS -c conftest1.s > /dev/null 2>&1 && \
+ $CC conftest2.c conftest1.o > /dev/null 2>&1 ; then
+ libffi_cv_as_x86_64_unwind_section_type=yes
+ fi
+ ])
+ if test "x$libffi_cv_as_x86_64_unwind_section_type" = xyes; then
+ AC_DEFINE(HAVE_AS_X86_64_UNWIND_SECTION_TYPE, 1,
+ [Define if your assembler supports unwind section type.])
+ fi
+fi
+
+if test "x$GCC" = "xyes"; then
+ AC_CACHE_CHECK([whether .eh_frame section should be read-only],
+ libffi_cv_ro_eh_frame, [
+ libffi_cv_ro_eh_frame=no
+ echo 'extern void foo (void); void bar (void) { foo (); foo (); }' > conftest.c
+ if $CC $CFLAGS -c -fpic -fexceptions -o conftest.o conftest.c > /dev/null 2>&1; then
+ objdump -h conftest.o > conftest.dump 2>&1
+ libffi_eh_frame_line=`grep -n eh_frame conftest.dump | cut -d: -f 1`
+ libffi_test_line=`expr $libffi_eh_frame_line + 1`p
+ sed -n $libffi_test_line conftest.dump > conftest.line
+ if grep READONLY conftest.line > /dev/null; then
+ libffi_cv_ro_eh_frame=yes
+ fi
+ fi
+ rm -f conftest.*
+ ])
+ if test "x$libffi_cv_ro_eh_frame" = xyes; then
+ AC_DEFINE(HAVE_RO_EH_FRAME, 1,
+ [Define if .eh_frame sections should be read-only.])
+ AC_DEFINE(EH_FRAME_FLAGS, "a",
+ [Define to the flags needed for the .section .eh_frame directive. ])
+ else
+ AC_DEFINE(EH_FRAME_FLAGS, "aw",
+ [Define to the flags needed for the .section .eh_frame directive. ])
+ fi
+
+ AC_CACHE_CHECK([for __attribute__((visibility("hidden")))],
+ libffi_cv_hidden_visibility_attribute, [
+ echo 'int __attribute__ ((visibility ("hidden"))) foo (void) { return 1 ; }' > conftest.c
+ libffi_cv_hidden_visibility_attribute=no
+ if AC_TRY_COMMAND(${CC-cc} -Werror -S conftest.c -o conftest.s 1>&AS_MESSAGE_LOG_FD); then
+ if grep '\.hidden.*foo' conftest.s >/dev/null; then
+ libffi_cv_hidden_visibility_attribute=yes
+ fi
+ fi
+ rm -f conftest.*
+ ])
+ if test $libffi_cv_hidden_visibility_attribute = yes; then
+ AC_DEFINE(HAVE_HIDDEN_VISIBILITY_ATTRIBUTE, 1,
+ [Define if __attribute__((visibility("hidden"))) is supported.])
+ fi
+fi
+
+AH_BOTTOM([
+#ifdef HAVE_HIDDEN_VISIBILITY_ATTRIBUTE
+#ifdef LIBFFI_ASM
+#define FFI_HIDDEN(name) .hidden name
+#else
+#define FFI_HIDDEN __attribute__ ((visibility ("hidden")))
+#endif
+#else
+#ifdef LIBFFI_ASM
+#define FFI_HIDDEN(name)
+#else
+#define FFI_HIDDEN
+#endif
+#endif
+])
+
+AC_SUBST(TARGET)
+AC_SUBST(TARGETDIR)
+
+AC_SUBST(SHELL)
+
+AC_ARG_ENABLE(debug,
+[ --enable-debug debugging mode],
+ if test "$enable_debug" = "yes"; then
+ AC_DEFINE(FFI_DEBUG, 1, [Define this if you want extra debugging.])
+ fi)
+AM_CONDITIONAL(FFI_DEBUG, test "$enable_debug" = "yes")
+
+AC_ARG_ENABLE(structs,
+[ --disable-structs omit code for struct support],
+ if test "$enable_structs" = "no"; then
+ AC_DEFINE(FFI_NO_STRUCTS, 1, [Define this if you do not want support for aggregate types.])
+ fi)
+AM_CONDITIONAL(FFI_DEBUG, test "$enable_debug" = "yes")
+
+AC_ARG_ENABLE(raw-api,
+[ --disable-raw-api make the raw api unavailable],
+ if test "$enable_raw_api" = "no"; then
+ AC_DEFINE(FFI_NO_RAW_API, 1, [Define this if you do not want support for the raw API.])
+ fi)
+
+AC_ARG_ENABLE(purify-safety,
+[ --enable-purify-safety purify-safe mode],
+ if test "$enable_purify_safety" = "yes"; then
+ AC_DEFINE(USING_PURIFY, 1, [Define this if you are using Purify and want to suppress spurious messages.])
+ fi)
+
+# These variables are only ever used when we cross-build to X86_WIN32.
+# And we only support this with GCC, so...
+if test "x$GCC" = "xyes"; then
+ if test -n "$with_cross_host" &&
+ test x"$with_cross_host" != x"no"; then
+ toolexecdir="${exec_prefix}"/'$(target_alias)'
+ toolexeclibdir="${toolexecdir}"/lib
+ else
+ toolexecdir="${libdir}"/gcc-lib/'$(target_alias)'
+ toolexeclibdir="${libdir}"
+ fi
+ multi_os_directory=`$CC $CFLAGS -print-multi-os-directory`
+ case $multi_os_directory in
+ .) ;; # Avoid trailing /.
+ ../*) toolexeclibdir=$toolexeclibdir/$multi_os_directory ;;
+ esac
+ AC_SUBST(toolexecdir)
+else
+ toolexeclibdir="${libdir}"
+fi
+AC_SUBST(toolexeclibdir)
+
+AC_CONFIG_COMMANDS(include, [test -d include || mkdir include])
+AC_CONFIG_COMMANDS(src, [
+test -d src || mkdir src
+test -d src/$TARGETDIR || mkdir src/$TARGETDIR
+], [TARGETDIR="$TARGETDIR"])
+
+AC_CONFIG_LINKS(include/ffitarget.h:src/$TARGETDIR/ffitarget.h)
+
+AC_CONFIG_FILES(include/Makefile include/ffi.h Makefile testsuite/Makefile man/Makefile libffi.pc)
+
+AC_OUTPUT
diff --git a/jni/ruby/ext/fiddle/libffi-3.2.1/depcomp b/jni/ruby/ext/fiddle/libffi-3.2.1/depcomp
new file mode 100755
index 0000000..4ebd5b3
--- /dev/null
+++ b/jni/ruby/ext/fiddle/libffi-3.2.1/depcomp
@@ -0,0 +1,791 @@
+#! /bin/sh
+# depcomp - compile a program generating dependencies as side-effects
+
+scriptversion=2013-05-30.07; # UTC
+
+# Copyright (C) 1999-2013 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+# As a special exception to the GNU General Public License, if you
+# distribute this file as part of a program that contains a
+# configuration script generated by Autoconf, you may include it under
+# the same distribution terms that you use for the rest of that program.
+
+# Originally written by Alexandre Oliva <oliva@dcc.unicamp.br>.
+
+case $1 in
+ '')
+ echo "$0: No command. Try '$0 --help' for more information." 1>&2
+ exit 1;
+ ;;
+ -h | --h*)
+ cat <<\EOF
+Usage: depcomp [--help] [--version] PROGRAM [ARGS]
+
+Run PROGRAMS ARGS to compile a file, generating dependencies
+as side-effects.
+
+Environment variables:
+ depmode Dependency tracking mode.
+ source Source file read by 'PROGRAMS ARGS'.
+ object Object file output by 'PROGRAMS ARGS'.
+ DEPDIR directory where to store dependencies.
+ depfile Dependency file to output.
+ tmpdepfile Temporary file to use when outputting dependencies.
+ libtool Whether libtool is used (yes/no).
+
+Report bugs to <bug-automake@gnu.org>.
+EOF
+ exit $?
+ ;;
+ -v | --v*)
+ echo "depcomp $scriptversion"
+ exit $?
+ ;;
+esac
+
+# Get the directory component of the given path, and save it in the
+# global variables '$dir'. Note that this directory component will
+# be either empty or ending with a '/' character. This is deliberate.
+set_dir_from ()
+{
+ case $1 in
+ */*) dir=`echo "$1" | sed -e 's|/[^/]*$|/|'`;;
+ *) dir=;;
+ esac
+}
+
+# Get the suffix-stripped basename of the given path, and save it the
+# global variable '$base'.
+set_base_from ()
+{
+ base=`echo "$1" | sed -e 's|^.*/||' -e 's/\.[^.]*$//'`
+}
+
+# If no dependency file was actually created by the compiler invocation,
+# we still have to create a dummy depfile, to avoid errors with the
+# Makefile "include basename.Plo" scheme.
+make_dummy_depfile ()
+{
+ echo "#dummy" > "$depfile"
+}
+
+# Factor out some common post-processing of the generated depfile.
+# Requires the auxiliary global variable '$tmpdepfile' to be set.
+aix_post_process_depfile ()
+{
+ # If the compiler actually managed to produce a dependency file,
+ # post-process it.
+ if test -f "$tmpdepfile"; then
+ # Each line is of the form 'foo.o: dependency.h'.
+ # Do two passes, one to just change these to
+ # $object: dependency.h
+ # and one to simply output
+ # dependency.h:
+ # which is needed to avoid the deleted-header problem.
+ { sed -e "s,^.*\.[$lower]*:,$object:," < "$tmpdepfile"
+ sed -e "s,^.*\.[$lower]*:[$tab ]*,," -e 's,$,:,' < "$tmpdepfile"
+ } > "$depfile"
+ rm -f "$tmpdepfile"
+ else
+ make_dummy_depfile
+ fi
+}
+
+# A tabulation character.
+tab=' '
+# A newline character.
+nl='
+'
+# Character ranges might be problematic outside the C locale.
+# These definitions help.
+upper=ABCDEFGHIJKLMNOPQRSTUVWXYZ
+lower=abcdefghijklmnopqrstuvwxyz
+digits=0123456789
+alpha=${upper}${lower}
+
+if test -z "$depmode" || test -z "$source" || test -z "$object"; then
+ echo "depcomp: Variables source, object and depmode must be set" 1>&2
+ exit 1
+fi
+
+# Dependencies for sub/bar.o or sub/bar.obj go into sub/.deps/bar.Po.
+depfile=${depfile-`echo "$object" |
+ sed 's|[^\\/]*$|'${DEPDIR-.deps}'/&|;s|\.\([^.]*\)$|.P\1|;s|Pobj$|Po|'`}
+tmpdepfile=${tmpdepfile-`echo "$depfile" | sed 's/\.\([^.]*\)$/.T\1/'`}
+
+rm -f "$tmpdepfile"
+
+# Avoid interferences from the environment.
+gccflag= dashmflag=
+
+# Some modes work just like other modes, but use different flags. We
+# parameterize here, but still list the modes in the big case below,
+# to make depend.m4 easier to write. Note that we *cannot* use a case
+# here, because this file can only contain one case statement.
+if test "$depmode" = hp; then
+ # HP compiler uses -M and no extra arg.
+ gccflag=-M
+ depmode=gcc
+fi
+
+if test "$depmode" = dashXmstdout; then
+ # This is just like dashmstdout with a different argument.
+ dashmflag=-xM
+ depmode=dashmstdout
+fi
+
+cygpath_u="cygpath -u -f -"
+if test "$depmode" = msvcmsys; then
+ # This is just like msvisualcpp but w/o cygpath translation.
+ # Just convert the backslash-escaped backslashes to single forward
+ # slashes to satisfy depend.m4
+ cygpath_u='sed s,\\\\,/,g'
+ depmode=msvisualcpp
+fi
+
+if test "$depmode" = msvc7msys; then
+ # This is just like msvc7 but w/o cygpath translation.
+ # Just convert the backslash-escaped backslashes to single forward
+ # slashes to satisfy depend.m4
+ cygpath_u='sed s,\\\\,/,g'
+ depmode=msvc7
+fi
+
+if test "$depmode" = xlc; then
+ # IBM C/C++ Compilers xlc/xlC can output gcc-like dependency information.
+ gccflag=-qmakedep=gcc,-MF
+ depmode=gcc
+fi
+
+case "$depmode" in
+gcc3)
+## gcc 3 implements dependency tracking that does exactly what
+## we want. Yay! Note: for some reason libtool 1.4 doesn't like
+## it if -MD -MP comes after the -MF stuff. Hmm.
+## Unfortunately, FreeBSD c89 acceptance of flags depends upon
+## the command line argument order; so add the flags where they
+## appear in depend2.am. Note that the slowdown incurred here
+## affects only configure: in makefiles, %FASTDEP% shortcuts this.
+ for arg
+ do
+ case $arg in
+ -c) set fnord "$@" -MT "$object" -MD -MP -MF "$tmpdepfile" "$arg" ;;
+ *) set fnord "$@" "$arg" ;;
+ esac
+ shift # fnord
+ shift # $arg
+ done
+ "$@"
+ stat=$?
+ if test $stat -ne 0; then
+ rm -f "$tmpdepfile"
+ exit $stat
+ fi
+ mv "$tmpdepfile" "$depfile"
+ ;;
+
+gcc)
+## Note that this doesn't just cater to obsosete pre-3.x GCC compilers.
+## but also to in-use compilers like IMB xlc/xlC and the HP C compiler.
+## (see the conditional assignment to $gccflag above).
+## There are various ways to get dependency output from gcc. Here's
+## why we pick this rather obscure method:
+## - Don't want to use -MD because we'd like the dependencies to end
+## up in a subdir. Having to rename by hand is ugly.
+## (We might end up doing this anyway to support other compilers.)
+## - The DEPENDENCIES_OUTPUT environment variable makes gcc act like
+## -MM, not -M (despite what the docs say). Also, it might not be
+## supported by the other compilers which use the 'gcc' depmode.
+## - Using -M directly means running the compiler twice (even worse
+## than renaming).
+ if test -z "$gccflag"; then
+ gccflag=-MD,
+ fi
+ "$@" -Wp,"$gccflag$tmpdepfile"
+ stat=$?
+ if test $stat -ne 0; then
+ rm -f "$tmpdepfile"
+ exit $stat
+ fi
+ rm -f "$depfile"
+ echo "$object : \\" > "$depfile"
+ # The second -e expression handles DOS-style file names with drive
+ # letters.
+ sed -e 's/^[^:]*: / /' \
+ -e 's/^['$alpha']:\/[^:]*: / /' < "$tmpdepfile" >> "$depfile"
+## This next piece of magic avoids the "deleted header file" problem.
+## The problem is that when a header file which appears in a .P file
+## is deleted, the dependency causes make to die (because there is
+## typically no way to rebuild the header). We avoid this by adding
+## dummy dependencies for each header file. Too bad gcc doesn't do
+## this for us directly.
+## Some versions of gcc put a space before the ':'. On the theory
+## that the space means something, we add a space to the output as
+## well. hp depmode also adds that space, but also prefixes the VPATH
+## to the object. Take care to not repeat it in the output.
+## Some versions of the HPUX 10.20 sed can't process this invocation
+## correctly. Breaking it into two sed invocations is a workaround.
+ tr ' ' "$nl" < "$tmpdepfile" \
+ | sed -e 's/^\\$//' -e '/^$/d' -e "s|.*$object$||" -e '/:$/d' \
+ | sed -e 's/$/ :/' >> "$depfile"
+ rm -f "$tmpdepfile"
+ ;;
+
+hp)
+ # This case exists only to let depend.m4 do its work. It works by
+ # looking at the text of this script. This case will never be run,
+ # since it is checked for above.
+ exit 1
+ ;;
+
+sgi)
+ if test "$libtool" = yes; then
+ "$@" "-Wp,-MDupdate,$tmpdepfile"
+ else
+ "$@" -MDupdate "$tmpdepfile"
+ fi
+ stat=$?
+ if test $stat -ne 0; then
+ rm -f "$tmpdepfile"
+ exit $stat
+ fi
+ rm -f "$depfile"
+
+ if test -f "$tmpdepfile"; then # yes, the sourcefile depend on other files
+ echo "$object : \\" > "$depfile"
+ # Clip off the initial element (the dependent). Don't try to be
+ # clever and replace this with sed code, as IRIX sed won't handle
+ # lines with more than a fixed number of characters (4096 in
+ # IRIX 6.2 sed, 8192 in IRIX 6.5). We also remove comment lines;
+ # the IRIX cc adds comments like '#:fec' to the end of the
+ # dependency line.
+ tr ' ' "$nl" < "$tmpdepfile" \
+ | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' \
+ | tr "$nl" ' ' >> "$depfile"
+ echo >> "$depfile"
+ # The second pass generates a dummy entry for each header file.
+ tr ' ' "$nl" < "$tmpdepfile" \
+ | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' -e 's/$/:/' \
+ >> "$depfile"
+ else
+ make_dummy_depfile
+ fi
+ rm -f "$tmpdepfile"
+ ;;
+
+xlc)
+ # This case exists only to let depend.m4 do its work. It works by
+ # looking at the text of this script. This case will never be run,
+ # since it is checked for above.
+ exit 1
+ ;;
+
+aix)
+ # The C for AIX Compiler uses -M and outputs the dependencies
+ # in a .u file. In older versions, this file always lives in the
+ # current directory. Also, the AIX compiler puts '$object:' at the
+ # start of each line; $object doesn't have directory information.
+ # Version 6 uses the directory in both cases.
+ set_dir_from "$object"
+ set_base_from "$object"
+ if test "$libtool" = yes; then
+ tmpdepfile1=$dir$base.u
+ tmpdepfile2=$base.u
+ tmpdepfile3=$dir.libs/$base.u
+ "$@" -Wc,-M
+ else
+ tmpdepfile1=$dir$base.u
+ tmpdepfile2=$dir$base.u
+ tmpdepfile3=$dir$base.u
+ "$@" -M
+ fi
+ stat=$?
+ if test $stat -ne 0; then
+ rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3"
+ exit $stat
+ fi
+
+ for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3"
+ do
+ test -f "$tmpdepfile" && break
+ done
+ aix_post_process_depfile
+ ;;
+
+tcc)
+ # tcc (Tiny C Compiler) understand '-MD -MF file' since version 0.9.26
+ # FIXME: That version still under development at the moment of writing.
+ # Make that this statement remains true also for stable, released
+ # versions.
+ # It will wrap lines (doesn't matter whether long or short) with a
+ # trailing '\', as in:
+ #
+ # foo.o : \
+ # foo.c \
+ # foo.h \
+ #
+ # It will put a trailing '\' even on the last line, and will use leading
+ # spaces rather than leading tabs (at least since its commit 0394caf7
+ # "Emit spaces for -MD").
+ "$@" -MD -MF "$tmpdepfile"
+ stat=$?
+ if test $stat -ne 0; then
+ rm -f "$tmpdepfile"
+ exit $stat
+ fi
+ rm -f "$depfile"
+ # Each non-empty line is of the form 'foo.o : \' or ' dep.h \'.
+ # We have to change lines of the first kind to '$object: \'.
+ sed -e "s|.*:|$object :|" < "$tmpdepfile" > "$depfile"
+ # And for each line of the second kind, we have to emit a 'dep.h:'
+ # dummy dependency, to avoid the deleted-header problem.
+ sed -n -e 's|^ *\(.*\) *\\$|\1:|p' < "$tmpdepfile" >> "$depfile"
+ rm -f "$tmpdepfile"
+ ;;
+
+## The order of this option in the case statement is important, since the
+## shell code in configure will try each of these formats in the order
+## listed in this file. A plain '-MD' option would be understood by many
+## compilers, so we must ensure this comes after the gcc and icc options.
+pgcc)
+ # Portland's C compiler understands '-MD'.
+ # Will always output deps to 'file.d' where file is the root name of the
+ # source file under compilation, even if file resides in a subdirectory.
+ # The object file name does not affect the name of the '.d' file.
+ # pgcc 10.2 will output
+ # foo.o: sub/foo.c sub/foo.h
+ # and will wrap long lines using '\' :
+ # foo.o: sub/foo.c ... \
+ # sub/foo.h ... \
+ # ...
+ set_dir_from "$object"
+ # Use the source, not the object, to determine the base name, since
+ # that's sadly what pgcc will do too.
+ set_base_from "$source"
+ tmpdepfile=$base.d
+
+ # For projects that build the same source file twice into different object
+ # files, the pgcc approach of using the *source* file root name can cause
+ # problems in parallel builds. Use a locking strategy to avoid stomping on
+ # the same $tmpdepfile.
+ lockdir=$base.d-lock
+ trap "
+ echo '$0: caught signal, cleaning up...' >&2
+ rmdir '$lockdir'
+ exit 1
+ " 1 2 13 15
+ numtries=100
+ i=$numtries
+ while test $i -gt 0; do
+ # mkdir is a portable test-and-set.
+ if mkdir "$lockdir" 2>/dev/null; then
+ # This process acquired the lock.
+ "$@" -MD
+ stat=$?
+ # Release the lock.
+ rmdir "$lockdir"
+ break
+ else
+ # If the lock is being held by a different process, wait
+ # until the winning process is done or we timeout.
+ while test -d "$lockdir" && test $i -gt 0; do
+ sleep 1
+ i=`expr $i - 1`
+ done
+ fi
+ i=`expr $i - 1`
+ done
+ trap - 1 2 13 15
+ if test $i -le 0; then
+ echo "$0: failed to acquire lock after $numtries attempts" >&2
+ echo "$0: check lockdir '$lockdir'" >&2
+ exit 1
+ fi
+
+ if test $stat -ne 0; then
+ rm -f "$tmpdepfile"
+ exit $stat
+ fi
+ rm -f "$depfile"
+ # Each line is of the form `foo.o: dependent.h',
+ # or `foo.o: dep1.h dep2.h \', or ` dep3.h dep4.h \'.
+ # Do two passes, one to just change these to
+ # `$object: dependent.h' and one to simply `dependent.h:'.
+ sed "s,^[^:]*:,$object :," < "$tmpdepfile" > "$depfile"
+ # Some versions of the HPUX 10.20 sed can't process this invocation
+ # correctly. Breaking it into two sed invocations is a workaround.
+ sed 's,^[^:]*: \(.*\)$,\1,;s/^\\$//;/^$/d;/:$/d' < "$tmpdepfile" \
+ | sed -e 's/$/ :/' >> "$depfile"
+ rm -f "$tmpdepfile"
+ ;;
+
+hp2)
+ # The "hp" stanza above does not work with aCC (C++) and HP's ia64
+ # compilers, which have integrated preprocessors. The correct option
+ # to use with these is +Maked; it writes dependencies to a file named
+ # 'foo.d', which lands next to the object file, wherever that
+ # happens to be.
+ # Much of this is similar to the tru64 case; see comments there.
+ set_dir_from "$object"
+ set_base_from "$object"
+ if test "$libtool" = yes; then
+ tmpdepfile1=$dir$base.d
+ tmpdepfile2=$dir.libs/$base.d
+ "$@" -Wc,+Maked
+ else
+ tmpdepfile1=$dir$base.d
+ tmpdepfile2=$dir$base.d
+ "$@" +Maked
+ fi
+ stat=$?
+ if test $stat -ne 0; then
+ rm -f "$tmpdepfile1" "$tmpdepfile2"
+ exit $stat
+ fi
+
+ for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2"
+ do
+ test -f "$tmpdepfile" && break
+ done
+ if test -f "$tmpdepfile"; then
+ sed -e "s,^.*\.[$lower]*:,$object:," "$tmpdepfile" > "$depfile"
+ # Add 'dependent.h:' lines.
+ sed -ne '2,${
+ s/^ *//
+ s/ \\*$//
+ s/$/:/
+ p
+ }' "$tmpdepfile" >> "$depfile"
+ else
+ make_dummy_depfile
+ fi
+ rm -f "$tmpdepfile" "$tmpdepfile2"
+ ;;
+
+tru64)
+ # The Tru64 compiler uses -MD to generate dependencies as a side
+ # effect. 'cc -MD -o foo.o ...' puts the dependencies into 'foo.o.d'.
+ # At least on Alpha/Redhat 6.1, Compaq CCC V6.2-504 seems to put
+ # dependencies in 'foo.d' instead, so we check for that too.
+ # Subdirectories are respected.
+ set_dir_from "$object"
+ set_base_from "$object"
+
+ if test "$libtool" = yes; then
+ # Libtool generates 2 separate objects for the 2 libraries. These
+ # two compilations output dependencies in $dir.libs/$base.o.d and
+ # in $dir$base.o.d. We have to check for both files, because
+ # one of the two compilations can be disabled. We should prefer
+ # $dir$base.o.d over $dir.libs/$base.o.d because the latter is
+ # automatically cleaned when .libs/ is deleted, while ignoring
+ # the former would cause a distcleancheck panic.
+ tmpdepfile1=$dir$base.o.d # libtool 1.5
+ tmpdepfile2=$dir.libs/$base.o.d # Likewise.
+ tmpdepfile3=$dir.libs/$base.d # Compaq CCC V6.2-504
+ "$@" -Wc,-MD
+ else
+ tmpdepfile1=$dir$base.d
+ tmpdepfile2=$dir$base.d
+ tmpdepfile3=$dir$base.d
+ "$@" -MD
+ fi
+
+ stat=$?
+ if test $stat -ne 0; then
+ rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3"
+ exit $stat
+ fi
+
+ for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3"
+ do
+ test -f "$tmpdepfile" && break
+ done
+ # Same post-processing that is required for AIX mode.
+ aix_post_process_depfile
+ ;;
+
+msvc7)
+ if test "$libtool" = yes; then
+ showIncludes=-Wc,-showIncludes
+ else
+ showIncludes=-showIncludes
+ fi
+ "$@" $showIncludes > "$tmpdepfile"
+ stat=$?
+ grep -v '^Note: including file: ' "$tmpdepfile"
+ if test $stat -ne 0; then
+ rm -f "$tmpdepfile"
+ exit $stat
+ fi
+ rm -f "$depfile"
+ echo "$object : \\" > "$depfile"
+ # The first sed program below extracts the file names and escapes
+ # backslashes for cygpath. The second sed program outputs the file
+ # name when reading, but also accumulates all include files in the
+ # hold buffer in order to output them again at the end. This only
+ # works with sed implementations that can handle large buffers.
+ sed < "$tmpdepfile" -n '
+/^Note: including file: *\(.*\)/ {
+ s//\1/
+ s/\\/\\\\/g
+ p
+}' | $cygpath_u | sort -u | sed -n '
+s/ /\\ /g
+s/\(.*\)/'"$tab"'\1 \\/p
+s/.\(.*\) \\/\1:/
+H
+$ {
+ s/.*/'"$tab"'/
+ G
+ p
+}' >> "$depfile"
+ echo >> "$depfile" # make sure the fragment doesn't end with a backslash
+ rm -f "$tmpdepfile"
+ ;;
+
+msvc7msys)
+ # This case exists only to let depend.m4 do its work. It works by
+ # looking at the text of this script. This case will never be run,
+ # since it is checked for above.
+ exit 1
+ ;;
+
+#nosideeffect)
+ # This comment above is used by automake to tell side-effect
+ # dependency tracking mechanisms from slower ones.
+
+dashmstdout)
+ # Important note: in order to support this mode, a compiler *must*
+ # always write the preprocessed file to stdout, regardless of -o.
+ "$@" || exit $?
+
+ # Remove the call to Libtool.
+ if test "$libtool" = yes; then
+ while test "X$1" != 'X--mode=compile'; do
+ shift
+ done
+ shift
+ fi
+
+ # Remove '-o $object'.
+ IFS=" "
+ for arg
+ do
+ case $arg in
+ -o)
+ shift
+ ;;
+ $object)
+ shift
+ ;;
+ *)
+ set fnord "$@" "$arg"
+ shift # fnord
+ shift # $arg
+ ;;
+ esac
+ done
+
+ test -z "$dashmflag" && dashmflag=-M
+ # Require at least two characters before searching for ':'
+ # in the target name. This is to cope with DOS-style filenames:
+ # a dependency such as 'c:/foo/bar' could be seen as target 'c' otherwise.
+ "$@" $dashmflag |
+ sed "s|^[$tab ]*[^:$tab ][^:][^:]*:[$tab ]*|$object: |" > "$tmpdepfile"
+ rm -f "$depfile"
+ cat < "$tmpdepfile" > "$depfile"
+ # Some versions of the HPUX 10.20 sed can't process this sed invocation
+ # correctly. Breaking it into two sed invocations is a workaround.
+ tr ' ' "$nl" < "$tmpdepfile" \
+ | sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' \
+ | sed -e 's/$/ :/' >> "$depfile"
+ rm -f "$tmpdepfile"
+ ;;
+
+dashXmstdout)
+ # This case only exists to satisfy depend.m4. It is never actually
+ # run, as this mode is specially recognized in the preamble.
+ exit 1
+ ;;
+
+makedepend)
+ "$@" || exit $?
+ # Remove any Libtool call
+ if test "$libtool" = yes; then
+ while test "X$1" != 'X--mode=compile'; do
+ shift
+ done
+ shift
+ fi
+ # X makedepend
+ shift
+ cleared=no eat=no
+ for arg
+ do
+ case $cleared in
+ no)
+ set ""; shift
+ cleared=yes ;;
+ esac
+ if test $eat = yes; then
+ eat=no
+ continue
+ fi
+ case "$arg" in
+ -D*|-I*)
+ set fnord "$@" "$arg"; shift ;;
+ # Strip any option that makedepend may not understand. Remove
+ # the object too, otherwise makedepend will parse it as a source file.
+ -arch)
+ eat=yes ;;
+ -*|$object)
+ ;;
+ *)
+ set fnord "$@" "$arg"; shift ;;
+ esac
+ done
+ obj_suffix=`echo "$object" | sed 's/^.*\././'`
+ touch "$tmpdepfile"
+ ${MAKEDEPEND-makedepend} -o"$obj_suffix" -f"$tmpdepfile" "$@"
+ rm -f "$depfile"
+ # makedepend may prepend the VPATH from the source file name to the object.
+ # No need to regex-escape $object, excess matching of '.' is harmless.
+ sed "s|^.*\($object *:\)|\1|" "$tmpdepfile" > "$depfile"
+ # Some versions of the HPUX 10.20 sed can't process the last invocation
+ # correctly. Breaking it into two sed invocations is a workaround.
+ sed '1,2d' "$tmpdepfile" \
+ | tr ' ' "$nl" \
+ | sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' \
+ | sed -e 's/$/ :/' >> "$depfile"
+ rm -f "$tmpdepfile" "$tmpdepfile".bak
+ ;;
+
+cpp)
+ # Important note: in order to support this mode, a compiler *must*
+ # always write the preprocessed file to stdout.
+ "$@" || exit $?
+
+ # Remove the call to Libtool.
+ if test "$libtool" = yes; then
+ while test "X$1" != 'X--mode=compile'; do
+ shift
+ done
+ shift
+ fi
+
+ # Remove '-o $object'.
+ IFS=" "
+ for arg
+ do
+ case $arg in
+ -o)
+ shift
+ ;;
+ $object)
+ shift
+ ;;
+ *)
+ set fnord "$@" "$arg"
+ shift # fnord
+ shift # $arg
+ ;;
+ esac
+ done
+
+ "$@" -E \
+ | sed -n -e '/^# [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' \
+ -e '/^#line [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' \
+ | sed '$ s: \\$::' > "$tmpdepfile"
+ rm -f "$depfile"
+ echo "$object : \\" > "$depfile"
+ cat < "$tmpdepfile" >> "$depfile"
+ sed < "$tmpdepfile" '/^$/d;s/^ //;s/ \\$//;s/$/ :/' >> "$depfile"
+ rm -f "$tmpdepfile"
+ ;;
+
+msvisualcpp)
+ # Important note: in order to support this mode, a compiler *must*
+ # always write the preprocessed file to stdout.
+ "$@" || exit $?
+
+ # Remove the call to Libtool.
+ if test "$libtool" = yes; then
+ while test "X$1" != 'X--mode=compile'; do
+ shift
+ done
+ shift
+ fi
+
+ IFS=" "
+ for arg
+ do
+ case "$arg" in
+ -o)
+ shift
+ ;;
+ $object)
+ shift
+ ;;
+ "-Gm"|"/Gm"|"-Gi"|"/Gi"|"-ZI"|"/ZI")
+ set fnord "$@"
+ shift
+ shift
+ ;;
+ *)
+ set fnord "$@" "$arg"
+ shift
+ shift
+ ;;
+ esac
+ done
+ "$@" -E 2>/dev/null |
+ sed -n '/^#line [0-9][0-9]* "\([^"]*\)"/ s::\1:p' | $cygpath_u | sort -u > "$tmpdepfile"
+ rm -f "$depfile"
+ echo "$object : \\" > "$depfile"
+ sed < "$tmpdepfile" -n -e 's% %\\ %g' -e '/^\(.*\)$/ s::'"$tab"'\1 \\:p' >> "$depfile"
+ echo "$tab" >> "$depfile"
+ sed < "$tmpdepfile" -n -e 's% %\\ %g' -e '/^\(.*\)$/ s::\1\::p' >> "$depfile"
+ rm -f "$tmpdepfile"
+ ;;
+
+msvcmsys)
+ # This case exists only to let depend.m4 do its work. It works by
+ # looking at the text of this script. This case will never be run,
+ # since it is checked for above.
+ exit 1
+ ;;
+
+none)
+ exec "$@"
+ ;;
+
+*)
+ echo "Unknown depmode $depmode" 1>&2
+ exit 1
+ ;;
+esac
+
+exit 0
+
+# Local Variables:
+# mode: shell-script
+# sh-indentation: 2
+# eval: (add-hook 'write-file-hooks 'time-stamp)
+# time-stamp-start: "scriptversion="
+# time-stamp-format: "%:y-%02m-%02d.%02H"
+# time-stamp-time-zone: "UTC"
+# time-stamp-end: "; # UTC"
+# End:
diff --git a/jni/ruby/ext/fiddle/libffi-3.2.1/doc/libffi.info b/jni/ruby/ext/fiddle/libffi-3.2.1/doc/libffi.info
new file mode 100644
index 0000000..c4d0f0c
--- /dev/null
+++ b/jni/ruby/ext/fiddle/libffi-3.2.1/doc/libffi.info
@@ -0,0 +1,765 @@
+This is libffi.info, produced by makeinfo version 5.1 from libffi.texi.
+
+This manual is for Libffi, a portable foreign-function interface
+library.
+
+ Copyright (C) 2008, 2010, 2011 Red Hat, Inc.
+
+ Permission is granted to copy, distribute and/or modify this
+ document under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2, or (at
+ your option) any later version. A copy of the license is included
+ in the section entitled "GNU General Public License".
+
+INFO-DIR-SECTION Development
+START-INFO-DIR-ENTRY
+* libffi: (libffi). Portable foreign-function interface library.
+END-INFO-DIR-ENTRY
+
+
+File: libffi.info, Node: Top, Next: Introduction, Up: (dir)
+
+libffi
+******
+
+This manual is for Libffi, a portable foreign-function interface
+library.
+
+ Copyright (C) 2008, 2010, 2011 Red Hat, Inc.
+
+ Permission is granted to copy, distribute and/or modify this
+ document under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2, or (at
+ your option) any later version. A copy of the license is included
+ in the section entitled "GNU General Public License".
+
+* Menu:
+
+* Introduction:: What is libffi?
+* Using libffi:: How to use libffi.
+* Missing Features:: Things libffi can't do.
+* Index:: Index.
+
+
+File: libffi.info, Node: Introduction, Next: Using libffi, Prev: Top, Up: Top
+
+1 What is libffi?
+*****************
+
+Compilers for high level languages generate code that follow certain
+conventions. These conventions are necessary, in part, for separate
+compilation to work. One such convention is the "calling convention".
+The calling convention is a set of assumptions made by the compiler
+about where function arguments will be found on entry to a function. A
+calling convention also specifies where the return value for a function
+is found. The calling convention is also sometimes called the "ABI" or
+"Application Binary Interface".
+
+ Some programs may not know at the time of compilation what arguments
+are to be passed to a function. For instance, an interpreter may be
+told at run-time about the number and types of arguments used to call a
+given function. 'Libffi' can be used in such programs to provide a
+bridge from the interpreter program to compiled code.
+
+ The 'libffi' library provides a portable, high level programming
+interface to various calling conventions. This allows a programmer to
+call any function specified by a call interface description at run time.
+
+ FFI stands for Foreign Function Interface. A foreign function
+interface is the popular name for the interface that allows code written
+in one language to call code written in another language. The 'libffi'
+library really only provides the lowest, machine dependent layer of a
+fully featured foreign function interface. A layer must exist above
+'libffi' that handles type conversions for values passed between the two
+languages.
+
+
+File: libffi.info, Node: Using libffi, Next: Missing Features, Prev: Introduction, Up: Top
+
+2 Using libffi
+**************
+
+* Menu:
+
+* The Basics:: The basic libffi API.
+* Simple Example:: A simple example.
+* Types:: libffi type descriptions.
+* Multiple ABIs:: Different passing styles on one platform.
+* The Closure API:: Writing a generic function.
+* Closure Example:: A closure example.
+
+
+File: libffi.info, Node: The Basics, Next: Simple Example, Up: Using libffi
+
+2.1 The Basics
+==============
+
+'Libffi' assumes that you have a pointer to the function you wish to
+call and that you know the number and types of arguments to pass it, as
+well as the return type of the function.
+
+ The first thing you must do is create an 'ffi_cif' object that
+matches the signature of the function you wish to call. This is a
+separate step because it is common to make multiple calls using a single
+'ffi_cif'. The "cif" in 'ffi_cif' stands for Call InterFace. To
+prepare a call interface object, use the function 'ffi_prep_cif'.
+
+ -- Function: ffi_status ffi_prep_cif (ffi_cif *CIF, ffi_abi ABI,
+ unsigned int NARGS, ffi_type *RTYPE, ffi_type **ARGTYPES)
+ This initializes CIF according to the given parameters.
+
+ ABI is the ABI to use; normally 'FFI_DEFAULT_ABI' is what you want.
+ *note Multiple ABIs:: for more information.
+
+ NARGS is the number of arguments that this function accepts.
+
+ RTYPE is a pointer to an 'ffi_type' structure that describes the
+ return type of the function. *Note Types::.
+
+ ARGTYPES is a vector of 'ffi_type' pointers. ARGTYPES must have
+ NARGS elements. If NARGS is 0, this argument is ignored.
+
+ 'ffi_prep_cif' returns a 'libffi' status code, of type
+ 'ffi_status'. This will be either 'FFI_OK' if everything worked
+ properly; 'FFI_BAD_TYPEDEF' if one of the 'ffi_type' objects is
+ incorrect; or 'FFI_BAD_ABI' if the ABI parameter is invalid.
+
+ If the function being called is variadic (varargs) then
+'ffi_prep_cif_var' must be used instead of 'ffi_prep_cif'.
+
+ -- Function: ffi_status ffi_prep_cif_var (ffi_cif *CIF, ffi_abi varabi,
+ unsigned int NFIXEDARGS, unsigned int varntotalargs, ffi_type
+ *RTYPE, ffi_type **ARGTYPES)
+ This initializes CIF according to the given parameters for a call
+ to a variadic function. In general it's operation is the same as
+ for 'ffi_prep_cif' except that:
+
+ NFIXEDARGS is the number of fixed arguments, prior to any variadic
+ arguments. It must be greater than zero.
+
+ NTOTALARGS the total number of arguments, including variadic and
+ fixed arguments.
+
+ Note that, different cif's must be prepped for calls to the same
+ function when different numbers of arguments are passed.
+
+ Also note that a call to 'ffi_prep_cif_var' with
+ NFIXEDARGS=NOTOTALARGS is NOT equivalent to a call to
+ 'ffi_prep_cif'.
+
+ To call a function using an initialized 'ffi_cif', use the 'ffi_call'
+function:
+
+ -- Function: void ffi_call (ffi_cif *CIF, void *FN, void *RVALUE, void
+ **AVALUES)
+ This calls the function FN according to the description given in
+ CIF. CIF must have already been prepared using 'ffi_prep_cif'.
+
+ RVALUE is a pointer to a chunk of memory that will hold the result
+ of the function call. This must be large enough to hold the
+ result, no smaller than the system register size (generally 32 or
+ 64 bits), and must be suitably aligned; it is the caller's
+ responsibility to ensure this. If CIF declares that the function
+ returns 'void' (using 'ffi_type_void'), then RVALUE is ignored.
+
+ AVALUES is a vector of 'void *' pointers that point to the memory
+ locations holding the argument values for a call. If CIF declares
+ that the function has no arguments (i.e., NARGS was 0), then
+ AVALUES is ignored. Note that argument values may be modified by
+ the callee (for instance, structs passed by value); the burden of
+ copying pass-by-value arguments is placed on the caller.
+
+
+File: libffi.info, Node: Simple Example, Next: Types, Prev: The Basics, Up: Using libffi
+
+2.2 Simple Example
+==================
+
+Here is a trivial example that calls 'puts' a few times.
+
+ #include <stdio.h>
+ #include <ffi.h>
+
+ int main()
+ {
+ ffi_cif cif;
+ ffi_type *args[1];
+ void *values[1];
+ char *s;
+ ffi_arg rc;
+
+ /* Initialize the argument info vectors */
+ args[0] = &ffi_type_pointer;
+ values[0] = &s;
+
+ /* Initialize the cif */
+ if (ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 1,
+ &ffi_type_sint, args) == FFI_OK)
+ {
+ s = "Hello World!";
+ ffi_call(&cif, puts, &rc, values);
+ /* rc now holds the result of the call to puts */
+
+ /* values holds a pointer to the function's arg, so to
+ call puts() again all we need to do is change the
+ value of s */
+ s = "This is cool!";
+ ffi_call(&cif, puts, &rc, values);
+ }
+
+ return 0;
+ }
+
+
+File: libffi.info, Node: Types, Next: Multiple ABIs, Prev: Simple Example, Up: Using libffi
+
+2.3 Types
+=========
+
+* Menu:
+
+* Primitive Types:: Built-in types.
+* Structures:: Structure types.
+* Type Example:: Structure type example.
+* Complex:: Complex types.
+* Complex Type Example:: Complex type example.
+
+
+File: libffi.info, Node: Primitive Types, Next: Structures, Up: Types
+
+2.3.1 Primitive Types
+---------------------
+
+'Libffi' provides a number of built-in type descriptors that can be used
+to describe argument and return types:
+
+'ffi_type_void'
+ The type 'void'. This cannot be used for argument types, only for
+ return values.
+
+'ffi_type_uint8'
+ An unsigned, 8-bit integer type.
+
+'ffi_type_sint8'
+ A signed, 8-bit integer type.
+
+'ffi_type_uint16'
+ An unsigned, 16-bit integer type.
+
+'ffi_type_sint16'
+ A signed, 16-bit integer type.
+
+'ffi_type_uint32'
+ An unsigned, 32-bit integer type.
+
+'ffi_type_sint32'
+ A signed, 32-bit integer type.
+
+'ffi_type_uint64'
+ An unsigned, 64-bit integer type.
+
+'ffi_type_sint64'
+ A signed, 64-bit integer type.
+
+'ffi_type_float'
+ The C 'float' type.
+
+'ffi_type_double'
+ The C 'double' type.
+
+'ffi_type_uchar'
+ The C 'unsigned char' type.
+
+'ffi_type_schar'
+ The C 'signed char' type. (Note that there is not an exact
+ equivalent to the C 'char' type in 'libffi'; ordinarily you should
+ either use 'ffi_type_schar' or 'ffi_type_uchar' depending on
+ whether 'char' is signed.)
+
+'ffi_type_ushort'
+ The C 'unsigned short' type.
+
+'ffi_type_sshort'
+ The C 'short' type.
+
+'ffi_type_uint'
+ The C 'unsigned int' type.
+
+'ffi_type_sint'
+ The C 'int' type.
+
+'ffi_type_ulong'
+ The C 'unsigned long' type.
+
+'ffi_type_slong'
+ The C 'long' type.
+
+'ffi_type_longdouble'
+ On platforms that have a C 'long double' type, this is defined. On
+ other platforms, it is not.
+
+'ffi_type_pointer'
+ A generic 'void *' pointer. You should use this for all pointers,
+ regardless of their real type.
+
+'ffi_type_complex_float'
+ The C '_Complex float' type.
+
+'ffi_type_complex_double'
+ The C '_Complex double' type.
+
+'ffi_type_complex_longdouble'
+ The C '_Complex long double' type. On platforms that have a C
+ 'long double' type, this is defined. On other platforms, it is
+ not.
+
+ Each of these is of type 'ffi_type', so you must take the address
+when passing to 'ffi_prep_cif'.
+
+
+File: libffi.info, Node: Structures, Next: Type Example, Prev: Primitive Types, Up: Types
+
+2.3.2 Structures
+----------------
+
+Although 'libffi' has no special support for unions or bit-fields, it is
+perfectly happy passing structures back and forth. You must first
+describe the structure to 'libffi' by creating a new 'ffi_type' object
+for it.
+
+ -- Data type: ffi_type
+ The 'ffi_type' has the following members:
+ 'size_t size'
+ This is set by 'libffi'; you should initialize it to zero.
+
+ 'unsigned short alignment'
+ This is set by 'libffi'; you should initialize it to zero.
+
+ 'unsigned short type'
+ For a structure, this should be set to 'FFI_TYPE_STRUCT'.
+
+ 'ffi_type **elements'
+ This is a 'NULL'-terminated array of pointers to 'ffi_type'
+ objects. There is one element per field of the struct.
+
+
+File: libffi.info, Node: Type Example, Next: Complex, Prev: Structures, Up: Types
+
+2.3.3 Type Example
+------------------
+
+The following example initializes a 'ffi_type' object representing the
+'tm' struct from Linux's 'time.h'.
+
+ Here is how the struct is defined:
+
+ struct tm {
+ int tm_sec;
+ int tm_min;
+ int tm_hour;
+ int tm_mday;
+ int tm_mon;
+ int tm_year;
+ int tm_wday;
+ int tm_yday;
+ int tm_isdst;
+ /* Those are for future use. */
+ long int __tm_gmtoff__;
+ __const char *__tm_zone__;
+ };
+
+ Here is the corresponding code to describe this struct to 'libffi':
+
+ {
+ ffi_type tm_type;
+ ffi_type *tm_type_elements[12];
+ int i;
+
+ tm_type.size = tm_type.alignment = 0;
+ tm_type.type = FFI_TYPE_STRUCT;
+ tm_type.elements = &tm_type_elements;
+
+ for (i = 0; i < 9; i++)
+ tm_type_elements[i] = &ffi_type_sint;
+
+ tm_type_elements[9] = &ffi_type_slong;
+ tm_type_elements[10] = &ffi_type_pointer;
+ tm_type_elements[11] = NULL;
+
+ /* tm_type can now be used to represent tm argument types and
+ return types for ffi_prep_cif() */
+ }
+
+
+File: libffi.info, Node: Complex, Next: Complex Type Example, Prev: Type Example, Up: Types
+
+2.3.4 Complex Types
+-------------------
+
+'libffi' supports the complex types defined by the C99 standard
+('_Complex float', '_Complex double' and '_Complex long double' with the
+built-in type descriptors 'ffi_type_complex_float',
+'ffi_type_complex_double' and 'ffi_type_complex_longdouble'.
+
+ Custom complex types like '_Complex int' can also be used. An
+'ffi_type' object has to be defined to describe the complex type to
+'libffi'.
+
+ -- Data type: ffi_type
+ 'size_t size'
+ This must be manually set to the size of the complex type.
+
+ 'unsigned short alignment'
+ This must be manually set to the alignment of the complex
+ type.
+
+ 'unsigned short type'
+ For a complex type, this must be set to 'FFI_TYPE_COMPLEX'.
+
+ 'ffi_type **elements'
+
+ This is a 'NULL'-terminated array of pointers to 'ffi_type'
+ objects. The first element is set to the 'ffi_type' of the
+ complex's base type. The second element must be set to
+ 'NULL'.
+
+ The section *note Complex Type Example:: shows a way to determine the
+'size' and 'alignment' members in a platform independent way.
+
+ For platforms that have no complex support in 'libffi' yet, the
+functions 'ffi_prep_cif' and 'ffi_prep_args' abort the program if they
+encounter a complex type.
+
+
+File: libffi.info, Node: Complex Type Example, Prev: Complex, Up: Types
+
+2.3.5 Complex Type Example
+--------------------------
+
+This example demonstrates how to use complex types:
+
+ #include <stdio.h>
+ #include <ffi.h>
+ #include <complex.h>
+
+ void complex_fn(_Complex float cf,
+ _Complex double cd,
+ _Complex long double cld)
+ {
+ printf("cf=%f+%fi\ncd=%f+%fi\ncld=%f+%fi\n",
+ (float)creal (cf), (float)cimag (cf),
+ (float)creal (cd), (float)cimag (cd),
+ (float)creal (cld), (float)cimag (cld));
+ }
+
+ int main()
+ {
+ ffi_cif cif;
+ ffi_type *args[3];
+ void *values[3];
+ _Complex float cf;
+ _Complex double cd;
+ _Complex long double cld;
+
+ /* Initialize the argument info vectors */
+ args[0] = &ffi_type_complex_float;
+ args[1] = &ffi_type_complex_double;
+ args[2] = &ffi_type_complex_longdouble;
+ values[0] = &cf;
+ values[1] = &cd;
+ values[2] = &cld;
+
+ /* Initialize the cif */
+ if (ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 3,
+ &ffi_type_void, args) == FFI_OK)
+ {
+ cf = 1.0 + 20.0 * I;
+ cd = 300.0 + 4000.0 * I;
+ cld = 50000.0 + 600000.0 * I;
+ /* Call the function */
+ ffi_call(&cif, (void (*)(void))complex_fn, 0, values);
+ }
+
+ return 0;
+ }
+
+ This is an example for defining a custom complex type descriptor for
+compilers that support them:
+
+ /*
+ * This macro can be used to define new complex type descriptors
+ * in a platform independent way.
+ *
+ * name: Name of the new descriptor is ffi_type_complex_<name>.
+ * type: The C base type of the complex type.
+ */
+ #define FFI_COMPLEX_TYPEDEF(name, type, ffitype) \
+ static ffi_type *ffi_elements_complex_##name [2] = { \
+ (ffi_type *)(&ffitype), NULL \
+ }; \
+ struct struct_align_complex_##name { \
+ char c; \
+ _Complex type x; \
+ }; \
+ ffi_type ffi_type_complex_##name = { \
+ sizeof(_Complex type), \
+ offsetof(struct struct_align_complex_##name, x), \
+ FFI_TYPE_COMPLEX, \
+ (ffi_type **)ffi_elements_complex_##name \
+ }
+
+ /* Define new complex type descriptors using the macro: */
+ /* ffi_type_complex_sint */
+ FFI_COMPLEX_TYPEDEF(sint, int, ffi_type_sint);
+ /* ffi_type_complex_uchar */
+ FFI_COMPLEX_TYPEDEF(uchar, unsigned char, ffi_type_uint8);
+
+ The new type descriptors can then be used like one of the built-in
+type descriptors in the previous example.
+
+
+File: libffi.info, Node: Multiple ABIs, Next: The Closure API, Prev: Types, Up: Using libffi
+
+2.4 Multiple ABIs
+=================
+
+A given platform may provide multiple different ABIs at once. For
+instance, the x86 platform has both 'stdcall' and 'fastcall' functions.
+
+ 'libffi' provides some support for this. However, this is
+necessarily platform-specific.
+
+
+File: libffi.info, Node: The Closure API, Next: Closure Example, Prev: Multiple ABIs, Up: Using libffi
+
+2.5 The Closure API
+===================
+
+'libffi' also provides a way to write a generic function - a function
+that can accept and decode any combination of arguments. This can be
+useful when writing an interpreter, or to provide wrappers for arbitrary
+functions.
+
+ This facility is called the "closure API". Closures are not supported
+on all platforms; you can check the 'FFI_CLOSURES' define to determine
+whether they are supported on the current platform.
+
+ Because closures work by assembling a tiny function at runtime, they
+require special allocation on platforms that have a non-executable heap.
+Memory management for closures is handled by a pair of functions:
+
+ -- Function: void *ffi_closure_alloc (size_t SIZE, void **CODE)
+ Allocate a chunk of memory holding SIZE bytes. This returns a
+ pointer to the writable address, and sets *CODE to the
+ corresponding executable address.
+
+ SIZE should be sufficient to hold a 'ffi_closure' object.
+
+ -- Function: void ffi_closure_free (void *WRITABLE)
+ Free memory allocated using 'ffi_closure_alloc'. The argument is
+ the writable address that was returned.
+
+ Once you have allocated the memory for a closure, you must construct
+a 'ffi_cif' describing the function call. Finally you can prepare the
+closure function:
+
+ -- Function: ffi_status ffi_prep_closure_loc (ffi_closure *CLOSURE,
+ ffi_cif *CIF, void (*FUN) (ffi_cif *CIF, void *RET, void
+ **ARGS, void *USER_DATA), void *USER_DATA, void *CODELOC)
+ Prepare a closure function.
+
+ CLOSURE is the address of a 'ffi_closure' object; this is the
+ writable address returned by 'ffi_closure_alloc'.
+
+ CIF is the 'ffi_cif' describing the function parameters.
+
+ USER_DATA is an arbitrary datum that is passed, uninterpreted, to
+ your closure function.
+
+ CODELOC is the executable address returned by 'ffi_closure_alloc'.
+
+ FUN is the function which will be called when the closure is
+ invoked. It is called with the arguments:
+ CIF
+ The 'ffi_cif' passed to 'ffi_prep_closure_loc'.
+
+ RET
+ A pointer to the memory used for the function's return value.
+ FUN must fill this, unless the function is declared as
+ returning 'void'.
+
+ ARGS
+ A vector of pointers to memory holding the arguments to the
+ function.
+
+ USER_DATA
+ The same USER_DATA that was passed to 'ffi_prep_closure_loc'.
+
+ 'ffi_prep_closure_loc' will return 'FFI_OK' if everything went ok,
+ and something else on error.
+
+ After calling 'ffi_prep_closure_loc', you can cast CODELOC to the
+ appropriate pointer-to-function type.
+
+ You may see old code referring to 'ffi_prep_closure'. This function
+is deprecated, as it cannot handle the need for separate writable and
+executable addresses.
+
+
+File: libffi.info, Node: Closure Example, Prev: The Closure API, Up: Using libffi
+
+2.6 Closure Example
+===================
+
+A trivial example that creates a new 'puts' by binding 'fputs' with
+'stdout'.
+
+ #include <stdio.h>
+ #include <ffi.h>
+
+ /* Acts like puts with the file given at time of enclosure. */
+ void puts_binding(ffi_cif *cif, void *ret, void* args[],
+ void *stream)
+ {
+ *(ffi_arg *)ret = fputs(*(char **)args[0], (FILE *)stream);
+ }
+
+ typedef int (*puts_t)(char *);
+
+ int main()
+ {
+ ffi_cif cif;
+ ffi_type *args[1];
+ ffi_closure *closure;
+
+ void *bound_puts;
+ int rc;
+
+ /* Allocate closure and bound_puts */
+ closure = ffi_closure_alloc(sizeof(ffi_closure), &bound_puts);
+
+ if (closure)
+ {
+ /* Initialize the argument info vectors */
+ args[0] = &ffi_type_pointer;
+
+ /* Initialize the cif */
+ if (ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 1,
+ &ffi_type_sint, args) == FFI_OK)
+ {
+ /* Initialize the closure, setting stream to stdout */
+ if (ffi_prep_closure_loc(closure, &cif, puts_binding,
+ stdout, bound_puts) == FFI_OK)
+ {
+ rc = ((puts_t)bound_puts)("Hello World!");
+ /* rc now holds the result of the call to fputs */
+ }
+ }
+ }
+
+ /* Deallocate both closure, and bound_puts */
+ ffi_closure_free(closure);
+
+ return 0;
+ }
+
+
+File: libffi.info, Node: Missing Features, Next: Index, Prev: Using libffi, Up: Top
+
+3 Missing Features
+******************
+
+'libffi' is missing a few features. We welcome patches to add support
+for these.
+
+ * Variadic closures.
+
+ * There is no support for bit fields in structures.
+
+ * The closure API is
+
+ * The "raw" API is undocumented.
+
+ Note that variadic support is very new and tested on a relatively
+small number of platforms.
+
+
+File: libffi.info, Node: Index, Prev: Missing Features, Up: Top
+
+Index
+*****
+
+
+* Menu:
+
+* ABI: Introduction. (line 13)
+* Application Binary Interface: Introduction. (line 13)
+* calling convention: Introduction. (line 13)
+* cif: The Basics. (line 14)
+* closure API: The Closure API. (line 13)
+* closures: The Closure API. (line 13)
+* FFI: Introduction. (line 31)
+* ffi_call: The Basics. (line 62)
+* FFI_CLOSURES: The Closure API. (line 13)
+* ffi_closure_alloc: The Closure API. (line 19)
+* ffi_closure_free: The Closure API. (line 26)
+* ffi_prep_cif: The Basics. (line 16)
+* ffi_prep_cif_var: The Basics. (line 39)
+* ffi_prep_closure_loc: The Closure API. (line 34)
+* ffi_status: The Basics. (line 16)
+* ffi_status <1>: The Basics. (line 39)
+* ffi_status <2>: The Closure API. (line 34)
+* ffi_type: Structures. (line 11)
+* ffi_type <1>: Structures. (line 11)
+* ffi_type <2>: Complex. (line 15)
+* ffi_type <3>: Complex. (line 15)
+* ffi_type_complex_double: Primitive Types. (line 82)
+* ffi_type_complex_float: Primitive Types. (line 79)
+* ffi_type_complex_longdouble: Primitive Types. (line 85)
+* ffi_type_double: Primitive Types. (line 41)
+* ffi_type_float: Primitive Types. (line 38)
+* ffi_type_longdouble: Primitive Types. (line 71)
+* ffi_type_pointer: Primitive Types. (line 75)
+* ffi_type_schar: Primitive Types. (line 47)
+* ffi_type_sint: Primitive Types. (line 62)
+* ffi_type_sint16: Primitive Types. (line 23)
+* ffi_type_sint32: Primitive Types. (line 29)
+* ffi_type_sint64: Primitive Types. (line 35)
+* ffi_type_sint8: Primitive Types. (line 17)
+* ffi_type_slong: Primitive Types. (line 68)
+* ffi_type_sshort: Primitive Types. (line 56)
+* ffi_type_uchar: Primitive Types. (line 44)
+* ffi_type_uint: Primitive Types. (line 59)
+* ffi_type_uint16: Primitive Types. (line 20)
+* ffi_type_uint32: Primitive Types. (line 26)
+* ffi_type_uint64: Primitive Types. (line 32)
+* ffi_type_uint8: Primitive Types. (line 14)
+* ffi_type_ulong: Primitive Types. (line 65)
+* ffi_type_ushort: Primitive Types. (line 53)
+* ffi_type_void: Primitive Types. (line 10)
+* Foreign Function Interface: Introduction. (line 31)
+* void: The Basics. (line 62)
+* void <1>: The Closure API. (line 19)
+* void <2>: The Closure API. (line 26)
+
+
+
+Tag Table:
+Node: Top682
+Node: Introduction1429
+Node: Using libffi3061
+Node: The Basics3547
+Node: Simple Example7198
+Node: Types8229
+Node: Primitive Types8613
+Node: Structures10734
+Node: Type Example11608
+Node: Complex12890
+Node: Complex Type Example14308
+Node: Multiple ABIs17360
+Node: The Closure API17731
+Node: Closure Example20675
+Node: Missing Features22284
+Node: Index22737
+
+End Tag Table
diff --git a/jni/ruby/ext/fiddle/libffi-3.2.1/doc/libffi.texi b/jni/ruby/ext/fiddle/libffi-3.2.1/doc/libffi.texi
new file mode 100644
index 0000000..b1c9bc3
--- /dev/null
+++ b/jni/ruby/ext/fiddle/libffi-3.2.1/doc/libffi.texi
@@ -0,0 +1,770 @@
+\input texinfo @c -*-texinfo-*-
+@c %**start of header
+@setfilename libffi.info
+@settitle libffi
+@setchapternewpage off
+@c %**end of header
+
+@c Merge the standard indexes into a single one.
+@syncodeindex fn cp
+@syncodeindex vr cp
+@syncodeindex ky cp
+@syncodeindex pg cp
+@syncodeindex tp cp
+
+@include version.texi
+
+@copying
+
+This manual is for Libffi, a portable foreign-function interface
+library.
+
+Copyright @copyright{} 2008, 2010, 2011 Red Hat, Inc.
+
+@quotation
+Permission is granted to copy, distribute and/or modify this document
+under the terms of the GNU General Public License as published by the
+Free Software Foundation; either version 2, or (at your option) any
+later version. A copy of the license is included in the
+section entitled ``GNU General Public License''.
+
+@end quotation
+@end copying
+
+@dircategory Development
+@direntry
+* libffi: (libffi). Portable foreign-function interface library.
+@end direntry
+
+@titlepage
+@title Libffi
+@page
+@vskip 0pt plus 1filll
+@insertcopying
+@end titlepage
+
+
+@ifnottex
+@node Top
+@top libffi
+
+@insertcopying
+
+@menu
+* Introduction:: What is libffi?
+* Using libffi:: How to use libffi.
+* Missing Features:: Things libffi can't do.
+* Index:: Index.
+@end menu
+
+@end ifnottex
+
+
+@node Introduction
+@chapter What is libffi?
+
+Compilers for high level languages generate code that follow certain
+conventions. These conventions are necessary, in part, for separate
+compilation to work. One such convention is the @dfn{calling
+convention}. The calling convention is a set of assumptions made by
+the compiler about where function arguments will be found on entry to
+a function. A calling convention also specifies where the return
+value for a function is found. The calling convention is also
+sometimes called the @dfn{ABI} or @dfn{Application Binary Interface}.
+@cindex calling convention
+@cindex ABI
+@cindex Application Binary Interface
+
+Some programs may not know at the time of compilation what arguments
+are to be passed to a function. For instance, an interpreter may be
+told at run-time about the number and types of arguments used to call
+a given function. @samp{Libffi} can be used in such programs to
+provide a bridge from the interpreter program to compiled code.
+
+The @samp{libffi} library provides a portable, high level programming
+interface to various calling conventions. This allows a programmer to
+call any function specified by a call interface description at run
+time.
+
+@acronym{FFI} stands for Foreign Function Interface. A foreign
+function interface is the popular name for the interface that allows
+code written in one language to call code written in another language.
+The @samp{libffi} library really only provides the lowest, machine
+dependent layer of a fully featured foreign function interface. A
+layer must exist above @samp{libffi} that handles type conversions for
+values passed between the two languages.
+@cindex FFI
+@cindex Foreign Function Interface
+
+
+@node Using libffi
+@chapter Using libffi
+
+@menu
+* The Basics:: The basic libffi API.
+* Simple Example:: A simple example.
+* Types:: libffi type descriptions.
+* Multiple ABIs:: Different passing styles on one platform.
+* The Closure API:: Writing a generic function.
+* Closure Example:: A closure example.
+@end menu
+
+
+@node The Basics
+@section The Basics
+
+@samp{Libffi} assumes that you have a pointer to the function you wish
+to call and that you know the number and types of arguments to pass
+it, as well as the return type of the function.
+
+The first thing you must do is create an @code{ffi_cif} object that
+matches the signature of the function you wish to call. This is a
+separate step because it is common to make multiple calls using a
+single @code{ffi_cif}. The @dfn{cif} in @code{ffi_cif} stands for
+Call InterFace. To prepare a call interface object, use the function
+@code{ffi_prep_cif}.
+@cindex cif
+
+@findex ffi_prep_cif
+@defun ffi_status ffi_prep_cif (ffi_cif *@var{cif}, ffi_abi @var{abi}, unsigned int @var{nargs}, ffi_type *@var{rtype}, ffi_type **@var{argtypes})
+This initializes @var{cif} according to the given parameters.
+
+@var{abi} is the ABI to use; normally @code{FFI_DEFAULT_ABI} is what
+you want. @ref{Multiple ABIs} for more information.
+
+@var{nargs} is the number of arguments that this function accepts.
+
+@var{rtype} is a pointer to an @code{ffi_type} structure that
+describes the return type of the function. @xref{Types}.
+
+@var{argtypes} is a vector of @code{ffi_type} pointers.
+@var{argtypes} must have @var{nargs} elements. If @var{nargs} is 0,
+this argument is ignored.
+
+@code{ffi_prep_cif} returns a @code{libffi} status code, of type
+@code{ffi_status}. This will be either @code{FFI_OK} if everything
+worked properly; @code{FFI_BAD_TYPEDEF} if one of the @code{ffi_type}
+objects is incorrect; or @code{FFI_BAD_ABI} if the @var{abi} parameter
+is invalid.
+@end defun
+
+If the function being called is variadic (varargs) then
+@code{ffi_prep_cif_var} must be used instead of @code{ffi_prep_cif}.
+
+@findex ffi_prep_cif_var
+@defun ffi_status ffi_prep_cif_var (ffi_cif *@var{cif}, ffi_abi var{abi}, unsigned int @var{nfixedargs}, unsigned int var{ntotalargs}, ffi_type *@var{rtype}, ffi_type **@var{argtypes})
+This initializes @var{cif} according to the given parameters for
+a call to a variadic function. In general it's operation is the
+same as for @code{ffi_prep_cif} except that:
+
+@var{nfixedargs} is the number of fixed arguments, prior to any
+variadic arguments. It must be greater than zero.
+
+@var{ntotalargs} the total number of arguments, including variadic
+and fixed arguments.
+
+Note that, different cif's must be prepped for calls to the same
+function when different numbers of arguments are passed.
+
+Also note that a call to @code{ffi_prep_cif_var} with
+@var{nfixedargs}=@var{nototalargs} is NOT equivalent to a call to
+@code{ffi_prep_cif}.
+
+@end defun
+
+
+To call a function using an initialized @code{ffi_cif}, use the
+@code{ffi_call} function:
+
+@findex ffi_call
+@defun void ffi_call (ffi_cif *@var{cif}, void *@var{fn}, void *@var{rvalue}, void **@var{avalues})
+This calls the function @var{fn} according to the description given in
+@var{cif}. @var{cif} must have already been prepared using
+@code{ffi_prep_cif}.
+
+@var{rvalue} is a pointer to a chunk of memory that will hold the
+result of the function call. This must be large enough to hold the
+result, no smaller than the system register size (generally 32 or 64
+bits), and must be suitably aligned; it is the caller's responsibility
+to ensure this. If @var{cif} declares that the function returns
+@code{void} (using @code{ffi_type_void}), then @var{rvalue} is
+ignored.
+
+@var{avalues} is a vector of @code{void *} pointers that point to the
+memory locations holding the argument values for a call. If @var{cif}
+declares that the function has no arguments (i.e., @var{nargs} was 0),
+then @var{avalues} is ignored. Note that argument values may be
+modified by the callee (for instance, structs passed by value); the
+burden of copying pass-by-value arguments is placed on the caller.
+@end defun
+
+
+@node Simple Example
+@section Simple Example
+
+Here is a trivial example that calls @code{puts} a few times.
+
+@example
+#include <stdio.h>
+#include <ffi.h>
+
+int main()
+@{
+ ffi_cif cif;
+ ffi_type *args[1];
+ void *values[1];
+ char *s;
+ ffi_arg rc;
+
+ /* Initialize the argument info vectors */
+ args[0] = &ffi_type_pointer;
+ values[0] = &s;
+
+ /* Initialize the cif */
+ if (ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 1,
+ &ffi_type_sint, args) == FFI_OK)
+ @{
+ s = "Hello World!";
+ ffi_call(&cif, puts, &rc, values);
+ /* rc now holds the result of the call to puts */
+
+ /* values holds a pointer to the function's arg, so to
+ call puts() again all we need to do is change the
+ value of s */
+ s = "This is cool!";
+ ffi_call(&cif, puts, &rc, values);
+ @}
+
+ return 0;
+@}
+@end example
+
+
+@node Types
+@section Types
+
+@menu
+* Primitive Types:: Built-in types.
+* Structures:: Structure types.
+* Type Example:: Structure type example.
+* Complex:: Complex types.
+* Complex Type Example:: Complex type example.
+@end menu
+
+@node Primitive Types
+@subsection Primitive Types
+
+@code{Libffi} provides a number of built-in type descriptors that can
+be used to describe argument and return types:
+
+@table @code
+@item ffi_type_void
+@tindex ffi_type_void
+The type @code{void}. This cannot be used for argument types, only
+for return values.
+
+@item ffi_type_uint8
+@tindex ffi_type_uint8
+An unsigned, 8-bit integer type.
+
+@item ffi_type_sint8
+@tindex ffi_type_sint8
+A signed, 8-bit integer type.
+
+@item ffi_type_uint16
+@tindex ffi_type_uint16
+An unsigned, 16-bit integer type.
+
+@item ffi_type_sint16
+@tindex ffi_type_sint16
+A signed, 16-bit integer type.
+
+@item ffi_type_uint32
+@tindex ffi_type_uint32
+An unsigned, 32-bit integer type.
+
+@item ffi_type_sint32
+@tindex ffi_type_sint32
+A signed, 32-bit integer type.
+
+@item ffi_type_uint64
+@tindex ffi_type_uint64
+An unsigned, 64-bit integer type.
+
+@item ffi_type_sint64
+@tindex ffi_type_sint64
+A signed, 64-bit integer type.
+
+@item ffi_type_float
+@tindex ffi_type_float
+The C @code{float} type.
+
+@item ffi_type_double
+@tindex ffi_type_double
+The C @code{double} type.
+
+@item ffi_type_uchar
+@tindex ffi_type_uchar
+The C @code{unsigned char} type.
+
+@item ffi_type_schar
+@tindex ffi_type_schar
+The C @code{signed char} type. (Note that there is not an exact
+equivalent to the C @code{char} type in @code{libffi}; ordinarily you
+should either use @code{ffi_type_schar} or @code{ffi_type_uchar}
+depending on whether @code{char} is signed.)
+
+@item ffi_type_ushort
+@tindex ffi_type_ushort
+The C @code{unsigned short} type.
+
+@item ffi_type_sshort
+@tindex ffi_type_sshort
+The C @code{short} type.
+
+@item ffi_type_uint
+@tindex ffi_type_uint
+The C @code{unsigned int} type.
+
+@item ffi_type_sint
+@tindex ffi_type_sint
+The C @code{int} type.
+
+@item ffi_type_ulong
+@tindex ffi_type_ulong
+The C @code{unsigned long} type.
+
+@item ffi_type_slong
+@tindex ffi_type_slong
+The C @code{long} type.
+
+@item ffi_type_longdouble
+@tindex ffi_type_longdouble
+On platforms that have a C @code{long double} type, this is defined.
+On other platforms, it is not.
+
+@item ffi_type_pointer
+@tindex ffi_type_pointer
+A generic @code{void *} pointer. You should use this for all
+pointers, regardless of their real type.
+
+@item ffi_type_complex_float
+@tindex ffi_type_complex_float
+The C @code{_Complex float} type.
+
+@item ffi_type_complex_double
+@tindex ffi_type_complex_double
+The C @code{_Complex double} type.
+
+@item ffi_type_complex_longdouble
+@tindex ffi_type_complex_longdouble
+The C @code{_Complex long double} type.
+On platforms that have a C @code{long double} type, this is defined.
+On other platforms, it is not.
+@end table
+
+Each of these is of type @code{ffi_type}, so you must take the address
+when passing to @code{ffi_prep_cif}.
+
+
+@node Structures
+@subsection Structures
+
+Although @samp{libffi} has no special support for unions or
+bit-fields, it is perfectly happy passing structures back and forth.
+You must first describe the structure to @samp{libffi} by creating a
+new @code{ffi_type} object for it.
+
+@tindex ffi_type
+@deftp {Data type} ffi_type
+The @code{ffi_type} has the following members:
+@table @code
+@item size_t size
+This is set by @code{libffi}; you should initialize it to zero.
+
+@item unsigned short alignment
+This is set by @code{libffi}; you should initialize it to zero.
+
+@item unsigned short type
+For a structure, this should be set to @code{FFI_TYPE_STRUCT}.
+
+@item ffi_type **elements
+This is a @samp{NULL}-terminated array of pointers to @code{ffi_type}
+objects. There is one element per field of the struct.
+@end table
+@end deftp
+
+
+@node Type Example
+@subsection Type Example
+
+The following example initializes a @code{ffi_type} object
+representing the @code{tm} struct from Linux's @file{time.h}.
+
+Here is how the struct is defined:
+
+@example
+struct tm @{
+ int tm_sec;
+ int tm_min;
+ int tm_hour;
+ int tm_mday;
+ int tm_mon;
+ int tm_year;
+ int tm_wday;
+ int tm_yday;
+ int tm_isdst;
+ /* Those are for future use. */
+ long int __tm_gmtoff__;
+ __const char *__tm_zone__;
+@};
+@end example
+
+Here is the corresponding code to describe this struct to
+@code{libffi}:
+
+@example
+ @{
+ ffi_type tm_type;
+ ffi_type *tm_type_elements[12];
+ int i;
+
+ tm_type.size = tm_type.alignment = 0;
+ tm_type.type = FFI_TYPE_STRUCT;
+ tm_type.elements = &tm_type_elements;
+
+ for (i = 0; i < 9; i++)
+ tm_type_elements[i] = &ffi_type_sint;
+
+ tm_type_elements[9] = &ffi_type_slong;
+ tm_type_elements[10] = &ffi_type_pointer;
+ tm_type_elements[11] = NULL;
+
+ /* tm_type can now be used to represent tm argument types and
+ return types for ffi_prep_cif() */
+ @}
+@end example
+
+@node Complex
+@subsection Complex Types
+
+@samp{libffi} supports the complex types defined by the C99
+standard (@code{_Complex float}, @code{_Complex double} and
+@code{_Complex long double} with the built-in type descriptors
+@code{ffi_type_complex_float}, @code{ffi_type_complex_double} and
+@code{ffi_type_complex_longdouble}.
+
+Custom complex types like @code{_Complex int} can also be used.
+An @code{ffi_type} object has to be defined to describe the
+complex type to @samp{libffi}.
+
+@tindex ffi_type
+@deftp {Data type} ffi_type
+@table @code
+@item size_t size
+This must be manually set to the size of the complex type.
+
+@item unsigned short alignment
+This must be manually set to the alignment of the complex type.
+
+@item unsigned short type
+For a complex type, this must be set to @code{FFI_TYPE_COMPLEX}.
+
+@item ffi_type **elements
+
+This is a @samp{NULL}-terminated array of pointers to
+@code{ffi_type} objects. The first element is set to the
+@code{ffi_type} of the complex's base type. The second element
+must be set to @code{NULL}.
+@end table
+@end deftp
+
+The section @ref{Complex Type Example} shows a way to determine
+the @code{size} and @code{alignment} members in a platform
+independent way.
+
+For platforms that have no complex support in @code{libffi} yet,
+the functions @code{ffi_prep_cif} and @code{ffi_prep_args} abort
+the program if they encounter a complex type.
+
+@node Complex Type Example
+@subsection Complex Type Example
+
+This example demonstrates how to use complex types:
+
+@example
+#include <stdio.h>
+#include <ffi.h>
+#include <complex.h>
+
+void complex_fn(_Complex float cf,
+ _Complex double cd,
+ _Complex long double cld)
+@{
+ printf("cf=%f+%fi\ncd=%f+%fi\ncld=%f+%fi\n",
+ (float)creal (cf), (float)cimag (cf),
+ (float)creal (cd), (float)cimag (cd),
+ (float)creal (cld), (float)cimag (cld));
+@}
+
+int main()
+@{
+ ffi_cif cif;
+ ffi_type *args[3];
+ void *values[3];
+ _Complex float cf;
+ _Complex double cd;
+ _Complex long double cld;
+
+ /* Initialize the argument info vectors */
+ args[0] = &ffi_type_complex_float;
+ args[1] = &ffi_type_complex_double;
+ args[2] = &ffi_type_complex_longdouble;
+ values[0] = &cf;
+ values[1] = &cd;
+ values[2] = &cld;
+
+ /* Initialize the cif */
+ if (ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 3,
+ &ffi_type_void, args) == FFI_OK)
+ @{
+ cf = 1.0 + 20.0 * I;
+ cd = 300.0 + 4000.0 * I;
+ cld = 50000.0 + 600000.0 * I;
+ /* Call the function */
+ ffi_call(&cif, (void (*)(void))complex_fn, 0, values);
+ @}
+
+ return 0;
+@}
+@end example
+
+This is an example for defining a custom complex type descriptor
+for compilers that support them:
+
+@example
+/*
+ * This macro can be used to define new complex type descriptors
+ * in a platform independent way.
+ *
+ * name: Name of the new descriptor is ffi_type_complex_<name>.
+ * type: The C base type of the complex type.
+ */
+#define FFI_COMPLEX_TYPEDEF(name, type, ffitype) \
+ static ffi_type *ffi_elements_complex_##name [2] = @{ \
+ (ffi_type *)(&ffitype), NULL \
+ @}; \
+ struct struct_align_complex_##name @{ \
+ char c; \
+ _Complex type x; \
+ @}; \
+ ffi_type ffi_type_complex_##name = @{ \
+ sizeof(_Complex type), \
+ offsetof(struct struct_align_complex_##name, x), \
+ FFI_TYPE_COMPLEX, \
+ (ffi_type **)ffi_elements_complex_##name \
+ @}
+
+/* Define new complex type descriptors using the macro: */
+/* ffi_type_complex_sint */
+FFI_COMPLEX_TYPEDEF(sint, int, ffi_type_sint);
+/* ffi_type_complex_uchar */
+FFI_COMPLEX_TYPEDEF(uchar, unsigned char, ffi_type_uint8);
+@end example
+
+The new type descriptors can then be used like one of the built-in
+type descriptors in the previous example.
+
+@node Multiple ABIs
+@section Multiple ABIs
+
+A given platform may provide multiple different ABIs at once. For
+instance, the x86 platform has both @samp{stdcall} and @samp{fastcall}
+functions.
+
+@code{libffi} provides some support for this. However, this is
+necessarily platform-specific.
+
+@c FIXME: document the platforms
+
+@node The Closure API
+@section The Closure API
+
+@code{libffi} also provides a way to write a generic function -- a
+function that can accept and decode any combination of arguments.
+This can be useful when writing an interpreter, or to provide wrappers
+for arbitrary functions.
+
+This facility is called the @dfn{closure API}. Closures are not
+supported on all platforms; you can check the @code{FFI_CLOSURES}
+define to determine whether they are supported on the current
+platform.
+@cindex closures
+@cindex closure API
+@findex FFI_CLOSURES
+
+Because closures work by assembling a tiny function at runtime, they
+require special allocation on platforms that have a non-executable
+heap. Memory management for closures is handled by a pair of
+functions:
+
+@findex ffi_closure_alloc
+@defun void *ffi_closure_alloc (size_t @var{size}, void **@var{code})
+Allocate a chunk of memory holding @var{size} bytes. This returns a
+pointer to the writable address, and sets *@var{code} to the
+corresponding executable address.
+
+@var{size} should be sufficient to hold a @code{ffi_closure} object.
+@end defun
+
+@findex ffi_closure_free
+@defun void ffi_closure_free (void *@var{writable})
+Free memory allocated using @code{ffi_closure_alloc}. The argument is
+the writable address that was returned.
+@end defun
+
+
+Once you have allocated the memory for a closure, you must construct a
+@code{ffi_cif} describing the function call. Finally you can prepare
+the closure function:
+
+@findex ffi_prep_closure_loc
+@defun ffi_status ffi_prep_closure_loc (ffi_closure *@var{closure}, ffi_cif *@var{cif}, void (*@var{fun}) (ffi_cif *@var{cif}, void *@var{ret}, void **@var{args}, void *@var{user_data}), void *@var{user_data}, void *@var{codeloc})
+Prepare a closure function.
+
+@var{closure} is the address of a @code{ffi_closure} object; this is
+the writable address returned by @code{ffi_closure_alloc}.
+
+@var{cif} is the @code{ffi_cif} describing the function parameters.
+
+@var{user_data} is an arbitrary datum that is passed, uninterpreted,
+to your closure function.
+
+@var{codeloc} is the executable address returned by
+@code{ffi_closure_alloc}.
+
+@var{fun} is the function which will be called when the closure is
+invoked. It is called with the arguments:
+@table @var
+@item cif
+The @code{ffi_cif} passed to @code{ffi_prep_closure_loc}.
+
+@item ret
+A pointer to the memory used for the function's return value.
+@var{fun} must fill this, unless the function is declared as returning
+@code{void}.
+@c FIXME: is this NULL for void-returning functions?
+
+@item args
+A vector of pointers to memory holding the arguments to the function.
+
+@item user_data
+The same @var{user_data} that was passed to
+@code{ffi_prep_closure_loc}.
+@end table
+
+@code{ffi_prep_closure_loc} will return @code{FFI_OK} if everything
+went ok, and something else on error.
+@c FIXME: what?
+
+After calling @code{ffi_prep_closure_loc}, you can cast @var{codeloc}
+to the appropriate pointer-to-function type.
+@end defun
+
+You may see old code referring to @code{ffi_prep_closure}. This
+function is deprecated, as it cannot handle the need for separate
+writable and executable addresses.
+
+@node Closure Example
+@section Closure Example
+
+A trivial example that creates a new @code{puts} by binding
+@code{fputs} with @code{stdout}.
+
+@example
+#include <stdio.h>
+#include <ffi.h>
+
+/* Acts like puts with the file given at time of enclosure. */
+void puts_binding(ffi_cif *cif, void *ret, void* args[],
+ void *stream)
+@{
+ *(ffi_arg *)ret = fputs(*(char **)args[0], (FILE *)stream);
+@}
+
+typedef int (*puts_t)(char *);
+
+int main()
+@{
+ ffi_cif cif;
+ ffi_type *args[1];
+ ffi_closure *closure;
+
+ void *bound_puts;
+ int rc;
+
+ /* Allocate closure and bound_puts */
+ closure = ffi_closure_alloc(sizeof(ffi_closure), &bound_puts);
+
+ if (closure)
+ @{
+ /* Initialize the argument info vectors */
+ args[0] = &ffi_type_pointer;
+
+ /* Initialize the cif */
+ if (ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 1,
+ &ffi_type_sint, args) == FFI_OK)
+ @{
+ /* Initialize the closure, setting stream to stdout */
+ if (ffi_prep_closure_loc(closure, &cif, puts_binding,
+ stdout, bound_puts) == FFI_OK)
+ @{
+ rc = ((puts_t)bound_puts)("Hello World!");
+ /* rc now holds the result of the call to fputs */
+ @}
+ @}
+ @}
+
+ /* Deallocate both closure, and bound_puts */
+ ffi_closure_free(closure);
+
+ return 0;
+@}
+
+@end example
+
+
+@node Missing Features
+@chapter Missing Features
+
+@code{libffi} is missing a few features. We welcome patches to add
+support for these.
+
+@itemize @bullet
+@item
+Variadic closures.
+
+@item
+There is no support for bit fields in structures.
+
+@item
+The closure API is
+
+@c FIXME: ...
+
+@item
+The ``raw'' API is undocumented.
+@c argument promotion?
+@c unions?
+@c anything else?
+@end itemize
+
+Note that variadic support is very new and tested on a relatively
+small number of platforms.
+
+@node Index
+@unnumbered Index
+
+@printindex cp
+
+@bye
diff --git a/jni/ruby/ext/fiddle/libffi-3.2.1/doc/stamp-vti b/jni/ruby/ext/fiddle/libffi-3.2.1/doc/stamp-vti
new file mode 100644
index 0000000..ccef70f
--- /dev/null
+++ b/jni/ruby/ext/fiddle/libffi-3.2.1/doc/stamp-vti
@@ -0,0 +1,4 @@
+@set UPDATED 8 November 2014
+@set UPDATED-MONTH November 2014
+@set EDITION 3.2.1
+@set VERSION 3.2.1
diff --git a/jni/ruby/ext/fiddle/libffi-3.2.1/doc/version.texi b/jni/ruby/ext/fiddle/libffi-3.2.1/doc/version.texi
new file mode 100644
index 0000000..ccef70f
--- /dev/null
+++ b/jni/ruby/ext/fiddle/libffi-3.2.1/doc/version.texi
@@ -0,0 +1,4 @@
+@set UPDATED 8 November 2014
+@set UPDATED-MONTH November 2014
+@set EDITION 3.2.1
+@set VERSION 3.2.1
diff --git a/jni/ruby/ext/fiddle/libffi-3.2.1/fficonfig.h.in b/jni/ruby/ext/fiddle/libffi-3.2.1/fficonfig.h.in
new file mode 100644
index 0000000..8aec513
--- /dev/null
+++ b/jni/ruby/ext/fiddle/libffi-3.2.1/fficonfig.h.in
@@ -0,0 +1,214 @@
+/* fficonfig.h.in. Generated from configure.ac by autoheader. */
+
+/* Define if building universal (internal helper macro) */
+#undef AC_APPLE_UNIVERSAL_BUILD
+
+/* Define to one of `_getb67', `GETB67', `getb67' for Cray-2 and Cray-YMP
+ systems. This function is required for `alloca.c' support on those systems.
+ */
+#undef CRAY_STACKSEG_END
+
+/* Define to 1 if using `alloca.c'. */
+#undef C_ALLOCA
+
+/* Define to the flags needed for the .section .eh_frame directive. */
+#undef EH_FRAME_FLAGS
+
+/* Define this if you want extra debugging. */
+#undef FFI_DEBUG
+
+/* Cannot use PROT_EXEC on this target, so, we revert to alternative means */
+#undef FFI_EXEC_TRAMPOLINE_TABLE
+
+/* Define this if you want to enable pax emulated trampolines */
+#undef FFI_MMAP_EXEC_EMUTRAMP_PAX
+
+/* Cannot use malloc on this target, so, we revert to alternative means */
+#undef FFI_MMAP_EXEC_WRIT
+
+/* Define this if you do not want support for the raw API. */
+#undef FFI_NO_RAW_API
+
+/* Define this if you do not want support for aggregate types. */
+#undef FFI_NO_STRUCTS
+
+/* Define to 1 if you have `alloca', as a function or macro. */
+#undef HAVE_ALLOCA
+
+/* Define to 1 if you have <alloca.h> and it should be used (not on Ultrix).
+ */
+#undef HAVE_ALLOCA_H
+
+/* Define if your assembler supports .ascii. */
+#undef HAVE_AS_ASCII_PSEUDO_OP
+
+/* Define if your assembler supports .cfi_* directives. */
+#undef HAVE_AS_CFI_PSEUDO_OP
+
+/* Define if your assembler supports .register. */
+#undef HAVE_AS_REGISTER_PSEUDO_OP
+
+/* Define if your assembler and linker support unaligned PC relative relocs.
+ */
+#undef HAVE_AS_SPARC_UA_PCREL
+
+/* Define if your assembler supports .string. */
+#undef HAVE_AS_STRING_PSEUDO_OP
+
+/* Define if your assembler supports unwind section type. */
+#undef HAVE_AS_X86_64_UNWIND_SECTION_TYPE
+
+/* Define if your assembler supports PC relative relocs. */
+#undef HAVE_AS_X86_PCREL
+
+/* Define to 1 if you have the <dlfcn.h> header file. */
+#undef HAVE_DLFCN_H
+
+/* Define if __attribute__((visibility("hidden"))) is supported. */
+#undef HAVE_HIDDEN_VISIBILITY_ATTRIBUTE
+
+/* Define to 1 if you have the <inttypes.h> header file. */
+#undef HAVE_INTTYPES_H
+
+/* Define if you have the long double type and it is bigger than a double */
+#undef HAVE_LONG_DOUBLE
+
+/* Define if you support more than one size of the long double type */
+#undef HAVE_LONG_DOUBLE_VARIANT
+
+/* Define to 1 if you have the `memcpy' function. */
+#undef HAVE_MEMCPY
+
+/* Define to 1 if you have the <memory.h> header file. */
+#undef HAVE_MEMORY_H
+
+/* Define to 1 if you have the `mkostemp' function. */
+#undef HAVE_MKOSTEMP
+
+/* Define to 1 if you have the `mmap' function. */
+#undef HAVE_MMAP
+
+/* Define if mmap with MAP_ANON(YMOUS) works. */
+#undef HAVE_MMAP_ANON
+
+/* Define if mmap of /dev/zero works. */
+#undef HAVE_MMAP_DEV_ZERO
+
+/* Define if read-only mmap of a plain file works. */
+#undef HAVE_MMAP_FILE
+
+/* Define if .eh_frame sections should be read-only. */
+#undef HAVE_RO_EH_FRAME
+
+/* Define to 1 if you have the <stdint.h> header file. */
+#undef HAVE_STDINT_H
+
+/* Define to 1 if you have the <stdlib.h> header file. */
+#undef HAVE_STDLIB_H
+
+/* Define to 1 if you have the <strings.h> header file. */
+#undef HAVE_STRINGS_H
+
+/* Define to 1 if you have the <string.h> header file. */
+#undef HAVE_STRING_H
+
+/* Define to 1 if you have the <sys/mman.h> header file. */
+#undef HAVE_SYS_MMAN_H
+
+/* Define to 1 if you have the <sys/stat.h> header file. */
+#undef HAVE_SYS_STAT_H
+
+/* Define to 1 if you have the <sys/types.h> header file. */
+#undef HAVE_SYS_TYPES_H
+
+/* Define to 1 if you have the <unistd.h> header file. */
+#undef HAVE_UNISTD_H
+
+/* Define to the sub-directory in which libtool stores uninstalled libraries.
+ */
+#undef LT_OBJDIR
+
+/* Define to 1 if your C compiler doesn't accept -c and -o together. */
+#undef NO_MINUS_C_MINUS_O
+
+/* Name of package */
+#undef PACKAGE
+
+/* Define to the address where bug reports for this package should be sent. */
+#undef PACKAGE_BUGREPORT
+
+/* Define to the full name of this package. */
+#undef PACKAGE_NAME
+
+/* Define to the full name and version of this package. */
+#undef PACKAGE_STRING
+
+/* Define to the one symbol short name of this package. */
+#undef PACKAGE_TARNAME
+
+/* Define to the home page for this package. */
+#undef PACKAGE_URL
+
+/* Define to the version of this package. */
+#undef PACKAGE_VERSION
+
+/* The size of `double', as computed by sizeof. */
+#undef SIZEOF_DOUBLE
+
+/* The size of `long double', as computed by sizeof. */
+#undef SIZEOF_LONG_DOUBLE
+
+/* The size of `size_t', as computed by sizeof. */
+#undef SIZEOF_SIZE_T
+
+/* If using the C implementation of alloca, define if you know the
+ direction of stack growth for your system; otherwise it will be
+ automatically deduced at runtime.
+ STACK_DIRECTION > 0 => grows toward higher addresses
+ STACK_DIRECTION < 0 => grows toward lower addresses
+ STACK_DIRECTION = 0 => direction of growth unknown */
+#undef STACK_DIRECTION
+
+/* Define to 1 if you have the ANSI C header files. */
+#undef STDC_HEADERS
+
+/* Define if symbols are underscored. */
+#undef SYMBOL_UNDERSCORE
+
+/* Define this if you are using Purify and want to suppress spurious messages.
+ */
+#undef USING_PURIFY
+
+/* Version number of package */
+#undef VERSION
+
+/* Define WORDS_BIGENDIAN to 1 if your processor stores words with the most
+ significant byte first (like Motorola and SPARC, unlike Intel). */
+#if defined AC_APPLE_UNIVERSAL_BUILD
+# if defined __BIG_ENDIAN__
+# define WORDS_BIGENDIAN 1
+# endif
+#else
+# ifndef WORDS_BIGENDIAN
+# undef WORDS_BIGENDIAN
+# endif
+#endif
+
+/* Define to `unsigned int' if <sys/types.h> does not define. */
+#undef size_t
+
+
+#ifdef HAVE_HIDDEN_VISIBILITY_ATTRIBUTE
+#ifdef LIBFFI_ASM
+#define FFI_HIDDEN(name) .hidden name
+#else
+#define FFI_HIDDEN __attribute__ ((visibility ("hidden")))
+#endif
+#else
+#ifdef LIBFFI_ASM
+#define FFI_HIDDEN(name)
+#else
+#define FFI_HIDDEN
+#endif
+#endif
+
diff --git a/jni/ruby/ext/fiddle/libffi-3.2.1/generate-darwin-source-and-headers.py b/jni/ruby/ext/fiddle/libffi-3.2.1/generate-darwin-source-and-headers.py
new file mode 100644
index 0000000..964e861
--- /dev/null
+++ b/jni/ruby/ext/fiddle/libffi-3.2.1/generate-darwin-source-and-headers.py
@@ -0,0 +1,209 @@
+#!/usr/bin/env python
+import subprocess
+import os
+import errno
+import collections
+import glob
+import argparse
+
+class Platform(object):
+ pass
+
+class simulator_platform(Platform):
+ directory = 'darwin_ios'
+ sdk = 'iphonesimulator'
+ arch = 'i386'
+ triple = 'i386-apple-darwin11'
+ version_min = '-miphoneos-version-min=5.1.1'
+
+ prefix = "#ifdef __i386__\n\n"
+ suffix = "\n\n#endif"
+ src_dir = 'x86'
+ src_files = ['darwin.S', 'win32.S', 'ffi.c']
+
+
+class simulator64_platform(Platform):
+ directory = 'darwin_ios'
+ sdk = 'iphonesimulator'
+ arch = 'x86_64'
+ triple = 'x86_64-apple-darwin13'
+ version_min = '-miphoneos-version-min=7.0'
+
+ prefix = "#ifdef __x86_64__\n\n"
+ suffix = "\n\n#endif"
+ src_dir = 'x86'
+ src_files = ['darwin64.S', 'ffi64.c']
+
+
+class device_platform(Platform):
+ directory = 'darwin_ios'
+ sdk = 'iphoneos'
+ arch = 'armv7'
+ triple = 'arm-apple-darwin11'
+ version_min = '-miphoneos-version-min=5.1.1'
+
+ prefix = "#ifdef __arm__\n\n"
+ suffix = "\n\n#endif"
+ src_dir = 'arm'
+ src_files = ['sysv.S', 'trampoline.S', 'ffi.c']
+
+
+class device64_platform(Platform):
+ directory = 'darwin_ios'
+ sdk = 'iphoneos'
+ arch = 'arm64'
+ triple = 'aarch64-apple-darwin13'
+ version_min = '-miphoneos-version-min=7.0'
+
+ prefix = "#ifdef __arm64__\n\n"
+ suffix = "\n\n#endif"
+ src_dir = 'aarch64'
+ src_files = ['sysv.S', 'ffi.c']
+
+
+class desktop32_platform(Platform):
+ directory = 'darwin_osx'
+ sdk = 'macosx'
+ arch = 'i386'
+ triple = 'i386-apple-darwin10'
+ version_min = '-mmacosx-version-min=10.6'
+ src_dir = 'x86'
+ src_files = ['darwin.S', 'win32.S', 'ffi.c']
+
+ prefix = "#ifdef __i386__\n\n"
+ suffix = "\n\n#endif"
+
+
+class desktop64_platform(Platform):
+ directory = 'darwin_osx'
+ sdk = 'macosx'
+ arch = 'x86_64'
+ triple = 'x86_64-apple-darwin10'
+ version_min = '-mmacosx-version-min=10.6'
+
+ prefix = "#ifdef __x86_64__\n\n"
+ suffix = "\n\n#endif"
+ src_dir = 'x86'
+ src_files = ['darwin64.S', 'ffi64.c']
+
+
+def mkdir_p(path):
+ try:
+ os.makedirs(path)
+ except OSError as exc: # Python >2.5
+ if exc.errno == errno.EEXIST:
+ pass
+ else:
+ raise
+
+
+def move_file(src_dir, dst_dir, filename, file_suffix=None, prefix='', suffix=''):
+ mkdir_p(dst_dir)
+ out_filename = filename
+
+ if file_suffix:
+ split_name = os.path.splitext(filename)
+ out_filename = "%s_%s%s" % (split_name[0], file_suffix, split_name[1])
+
+ with open(os.path.join(src_dir, filename)) as in_file:
+ with open(os.path.join(dst_dir, out_filename), 'w') as out_file:
+ if prefix:
+ out_file.write(prefix)
+
+ out_file.write(in_file.read())
+
+ if suffix:
+ out_file.write(suffix)
+
+
+def list_files(src_dir, pattern=None, filelist=None):
+ if pattern: filelist = glob.iglob(os.path.join(src_dir, pattern))
+ for file in filelist:
+ yield os.path.basename(file)
+
+
+def copy_files(src_dir, dst_dir, pattern=None, filelist=None, file_suffix=None, prefix=None, suffix=None):
+ for filename in list_files(src_dir, pattern=pattern, filelist=filelist):
+ move_file(src_dir, dst_dir, filename, file_suffix=file_suffix, prefix=prefix, suffix=suffix)
+
+
+def copy_src_platform_files(platform):
+ src_dir = os.path.join('src', platform.src_dir)
+ dst_dir = os.path.join(platform.directory, 'src', platform.src_dir)
+ copy_files(src_dir, dst_dir, filelist=platform.src_files, file_suffix=platform.arch, prefix=platform.prefix, suffix=platform.suffix)
+
+
+def build_target(platform, platform_headers):
+ def xcrun_cmd(cmd):
+ return 'xcrun -sdk %s %s -arch %s' % (platform.sdk, cmd, platform.arch)
+
+ tag='%s-%s' % (platform.sdk, platform.arch)
+ build_dir = 'build_%s' % tag
+ mkdir_p(build_dir)
+ env = dict(CC=xcrun_cmd('clang'),
+ LD=xcrun_cmd('ld'),
+ CFLAGS='%s' % (platform.version_min))
+ working_dir = os.getcwd()
+ try:
+ os.chdir(build_dir)
+ subprocess.check_call(['../configure', '-host', platform.triple], env=env)
+ finally:
+ os.chdir(working_dir)
+
+ for src_dir in [build_dir, os.path.join(build_dir, 'include')]:
+ copy_files(src_dir,
+ os.path.join(platform.directory, 'include'),
+ pattern='*.h',
+ file_suffix=platform.arch,
+ prefix=platform.prefix,
+ suffix=platform.suffix)
+
+ for filename in list_files(src_dir, pattern='*.h'):
+ platform_headers[filename].add((platform.prefix, platform.arch, platform.suffix))
+
+
+def make_tramp():
+ with open('src/arm/trampoline.S', 'w') as tramp_out:
+ p = subprocess.Popen(['bash', 'src/arm/gentramp.sh'], stdout=tramp_out)
+ p.wait()
+
+
+def generate_source_and_headers(generate_osx=True, generate_ios=True):
+ copy_files('src', 'darwin_common/src', pattern='*.c')
+ copy_files('include', 'darwin_common/include', pattern='*.h')
+
+ if generate_ios:
+ make_tramp()
+ copy_src_platform_files(simulator_platform)
+ copy_src_platform_files(simulator64_platform)
+ copy_src_platform_files(device_platform)
+ copy_src_platform_files(device64_platform)
+ if generate_osx:
+ copy_src_platform_files(desktop32_platform)
+ copy_src_platform_files(desktop64_platform)
+
+ platform_headers = collections.defaultdict(set)
+
+ if generate_ios:
+ build_target(simulator_platform, platform_headers)
+ build_target(simulator64_platform, platform_headers)
+ build_target(device_platform, platform_headers)
+ build_target(device64_platform, platform_headers)
+ if generate_osx:
+ build_target(desktop32_platform, platform_headers)
+ build_target(desktop64_platform, platform_headers)
+
+ mkdir_p('darwin_common/include')
+ for header_name, tag_tuples in platform_headers.iteritems():
+ basename, suffix = os.path.splitext(header_name)
+ with open(os.path.join('darwin_common/include', header_name), 'w') as header:
+ for tag_tuple in tag_tuples:
+ header.write('%s#include <%s_%s%s>\n%s\n' % (tag_tuple[0], basename, tag_tuple[1], suffix, tag_tuple[2]))
+
+if __name__ == '__main__':
+ parser = argparse.ArgumentParser()
+ parser.add_argument('--only-ios', action='store_true', default=False)
+ parser.add_argument('--only-osx', action='store_true', default=False)
+ args = parser.parse_args()
+
+ generate_source_and_headers(generate_osx=not args.only_ios, generate_ios=not args.only_osx)
diff --git a/jni/ruby/ext/fiddle/libffi-3.2.1/include/Makefile.am b/jni/ruby/ext/fiddle/libffi-3.2.1/include/Makefile.am
new file mode 100644
index 0000000..fd28024
--- /dev/null
+++ b/jni/ruby/ext/fiddle/libffi-3.2.1/include/Makefile.am
@@ -0,0 +1,9 @@
+## Process this with automake to create Makefile.in
+
+AUTOMAKE_OPTIONS=foreign
+
+DISTCLEANFILES=ffitarget.h
+EXTRA_DIST=ffi.h.in ffi_common.h
+
+includesdir = $(libdir)/@PACKAGE_NAME@-@PACKAGE_VERSION@/include
+nodist_includes_HEADERS = ffi.h ffitarget.h
diff --git a/jni/ruby/ext/fiddle/libffi-3.2.1/include/Makefile.in b/jni/ruby/ext/fiddle/libffi-3.2.1/include/Makefile.in
new file mode 100644
index 0000000..9d747e8
--- /dev/null
+++ b/jni/ruby/ext/fiddle/libffi-3.2.1/include/Makefile.in
@@ -0,0 +1,587 @@
+# Makefile.in generated by automake 1.13.4 from Makefile.am.
+# @configure_input@
+
+# Copyright (C) 1994-2013 Free Software Foundation, Inc.
+
+# This Makefile.in is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
+# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE.
+
+@SET_MAKE@
+
+VPATH = @srcdir@
+am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)'
+am__make_running_with_option = \
+ case $${target_option-} in \
+ ?) ;; \
+ *) echo "am__make_running_with_option: internal error: invalid" \
+ "target option '$${target_option-}' specified" >&2; \
+ exit 1;; \
+ esac; \
+ has_opt=no; \
+ sane_makeflags=$$MAKEFLAGS; \
+ if $(am__is_gnu_make); then \
+ sane_makeflags=$$MFLAGS; \
+ else \
+ case $$MAKEFLAGS in \
+ *\\[\ \ ]*) \
+ bs=\\; \
+ sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \
+ | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \
+ esac; \
+ fi; \
+ skip_next=no; \
+ strip_trailopt () \
+ { \
+ flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \
+ }; \
+ for flg in $$sane_makeflags; do \
+ test $$skip_next = yes && { skip_next=no; continue; }; \
+ case $$flg in \
+ *=*|--*) continue;; \
+ -*I) strip_trailopt 'I'; skip_next=yes;; \
+ -*I?*) strip_trailopt 'I';; \
+ -*O) strip_trailopt 'O'; skip_next=yes;; \
+ -*O?*) strip_trailopt 'O';; \
+ -*l) strip_trailopt 'l'; skip_next=yes;; \
+ -*l?*) strip_trailopt 'l';; \
+ -[dEDm]) skip_next=yes;; \
+ -[JT]) skip_next=yes;; \
+ esac; \
+ case $$flg in \
+ *$$target_option*) has_opt=yes; break;; \
+ esac; \
+ done; \
+ test $$has_opt = yes
+am__make_dryrun = (target_option=n; $(am__make_running_with_option))
+am__make_keepgoing = (target_option=k; $(am__make_running_with_option))
+pkgdatadir = $(datadir)/@PACKAGE@
+pkgincludedir = $(includedir)/@PACKAGE@
+pkglibdir = $(libdir)/@PACKAGE@
+pkglibexecdir = $(libexecdir)/@PACKAGE@
+am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
+install_sh_DATA = $(install_sh) -c -m 644
+install_sh_PROGRAM = $(install_sh) -c
+install_sh_SCRIPT = $(install_sh) -c
+INSTALL_HEADER = $(INSTALL_DATA)
+transform = $(program_transform_name)
+NORMAL_INSTALL = :
+PRE_INSTALL = :
+POST_INSTALL = :
+NORMAL_UNINSTALL = :
+PRE_UNINSTALL = :
+POST_UNINSTALL = :
+build_triplet = @build@
+host_triplet = @host@
+target_triplet = @target@
+subdir = include
+DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am \
+ $(srcdir)/ffi.h.in
+ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
+am__aclocal_m4_deps = $(top_srcdir)/m4/asmcfi.m4 \
+ $(top_srcdir)/m4/ax_append_flag.m4 \
+ $(top_srcdir)/m4/ax_cc_maxopt.m4 \
+ $(top_srcdir)/m4/ax_cflags_warn_all.m4 \
+ $(top_srcdir)/m4/ax_check_compile_flag.m4 \
+ $(top_srcdir)/m4/ax_compiler_vendor.m4 \
+ $(top_srcdir)/m4/ax_configure_args.m4 \
+ $(top_srcdir)/m4/ax_enable_builddir.m4 \
+ $(top_srcdir)/m4/ax_gcc_archflag.m4 \
+ $(top_srcdir)/m4/ax_gcc_x86_cpuid.m4 \
+ $(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \
+ $(top_srcdir)/m4/ltsugar.m4 $(top_srcdir)/m4/ltversion.m4 \
+ $(top_srcdir)/m4/lt~obsolete.m4 $(top_srcdir)/acinclude.m4 \
+ $(top_srcdir)/configure.ac
+am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
+ $(ACLOCAL_M4)
+mkinstalldirs = $(install_sh) -d
+CONFIG_HEADER = $(top_builddir)/fficonfig.h
+CONFIG_CLEAN_FILES = ffi.h ffitarget.h
+CONFIG_CLEAN_VPATH_FILES =
+AM_V_P = $(am__v_P_@AM_V@)
+am__v_P_ = $(am__v_P_@AM_DEFAULT_V@)
+am__v_P_0 = false
+am__v_P_1 = :
+AM_V_GEN = $(am__v_GEN_@AM_V@)
+am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@)
+am__v_GEN_0 = @echo " GEN " $@;
+am__v_GEN_1 =
+AM_V_at = $(am__v_at_@AM_V@)
+am__v_at_ = $(am__v_at_@AM_DEFAULT_V@)
+am__v_at_0 = @
+am__v_at_1 =
+SOURCES =
+DIST_SOURCES =
+am__can_run_installinfo = \
+ case $$AM_UPDATE_INFO_DIR in \
+ n|no|NO) false;; \
+ *) (install-info --version) >/dev/null 2>&1;; \
+ esac
+am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`;
+am__vpath_adj = case $$p in \
+ $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \
+ *) f=$$p;; \
+ esac;
+am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`;
+am__install_max = 40
+am__nobase_strip_setup = \
+ srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'`
+am__nobase_strip = \
+ for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||"
+am__nobase_list = $(am__nobase_strip_setup); \
+ for p in $$list; do echo "$$p $$p"; done | \
+ sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \
+ $(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \
+ if (++n[$$2] == $(am__install_max)) \
+ { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \
+ END { for (dir in files) print dir, files[dir] }'
+am__base_list = \
+ sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \
+ sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g'
+am__uninstall_files_from_dir = { \
+ test -z "$$files" \
+ || { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \
+ || { echo " ( cd '$$dir' && rm -f" $$files ")"; \
+ $(am__cd) "$$dir" && rm -f $$files; }; \
+ }
+am__installdirs = "$(DESTDIR)$(includesdir)"
+HEADERS = $(nodist_includes_HEADERS)
+am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP)
+# Read a list of newline-separated strings from the standard input,
+# and print each of them once, without duplicates. Input order is
+# *not* preserved.
+am__uniquify_input = $(AWK) '\
+ BEGIN { nonempty = 0; } \
+ { items[$$0] = 1; nonempty = 1; } \
+ END { if (nonempty) { for (i in items) print i; }; } \
+'
+# Make sure the list of sources is unique. This is necessary because,
+# e.g., the same source file might be shared among _SOURCES variables
+# for different programs/libraries.
+am__define_uniq_tagged_files = \
+ list='$(am__tagged_files)'; \
+ unique=`for i in $$list; do \
+ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+ done | $(am__uniquify_input)`
+ETAGS = etags
+CTAGS = ctags
+DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
+ACLOCAL = @ACLOCAL@
+ALLOCA = @ALLOCA@
+AMTAR = @AMTAR@
+AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@
+AM_LTLDFLAGS = @AM_LTLDFLAGS@
+AM_RUNTESTFLAGS = @AM_RUNTESTFLAGS@
+AR = @AR@
+AUTOCONF = @AUTOCONF@
+AUTOHEADER = @AUTOHEADER@
+AUTOMAKE = @AUTOMAKE@
+AWK = @AWK@
+CC = @CC@
+CCAS = @CCAS@
+CCASDEPMODE = @CCASDEPMODE@
+CCASFLAGS = @CCASFLAGS@
+CCDEPMODE = @CCDEPMODE@
+CFLAGS = @CFLAGS@
+CPP = @CPP@
+CPPFLAGS = @CPPFLAGS@
+CXX = @CXX@
+CXXCPP = @CXXCPP@
+CXXDEPMODE = @CXXDEPMODE@
+CXXFLAGS = @CXXFLAGS@
+CYGPATH_W = @CYGPATH_W@
+DEFS = @DEFS@
+DEPDIR = @DEPDIR@
+DLLTOOL = @DLLTOOL@
+DSYMUTIL = @DSYMUTIL@
+DUMPBIN = @DUMPBIN@
+ECHO_C = @ECHO_C@
+ECHO_N = @ECHO_N@
+ECHO_T = @ECHO_T@
+EGREP = @EGREP@
+EXEEXT = @EXEEXT@
+FFI_EXEC_TRAMPOLINE_TABLE = @FFI_EXEC_TRAMPOLINE_TABLE@
+FGREP = @FGREP@
+GREP = @GREP@
+HAVE_LONG_DOUBLE = @HAVE_LONG_DOUBLE@
+HAVE_LONG_DOUBLE_VARIANT = @HAVE_LONG_DOUBLE_VARIANT@
+INSTALL = @INSTALL@
+INSTALL_DATA = @INSTALL_DATA@
+INSTALL_PROGRAM = @INSTALL_PROGRAM@
+INSTALL_SCRIPT = @INSTALL_SCRIPT@
+INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
+LD = @LD@
+LDFLAGS = @LDFLAGS@
+LIBOBJS = @LIBOBJS@
+LIBS = @LIBS@
+LIBTOOL = @LIBTOOL@
+LIPO = @LIPO@
+LN_S = @LN_S@
+LTLIBOBJS = @LTLIBOBJS@
+MAINT = @MAINT@
+MAKEINFO = @MAKEINFO@
+MANIFEST_TOOL = @MANIFEST_TOOL@
+MKDIR_P = @MKDIR_P@
+NM = @NM@
+NMEDIT = @NMEDIT@
+OBJDUMP = @OBJDUMP@
+OBJEXT = @OBJEXT@
+OTOOL = @OTOOL@
+OTOOL64 = @OTOOL64@
+PACKAGE = @PACKAGE@
+PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
+PACKAGE_NAME = @PACKAGE_NAME@
+PACKAGE_STRING = @PACKAGE_STRING@
+PACKAGE_TARNAME = @PACKAGE_TARNAME@
+PACKAGE_URL = @PACKAGE_URL@
+PACKAGE_VERSION = @PACKAGE_VERSION@
+PATH_SEPARATOR = @PATH_SEPARATOR@
+PRTDIAG = @PRTDIAG@
+RANLIB = @RANLIB@
+SED = @SED@
+SET_MAKE = @SET_MAKE@
+SHELL = @SHELL@
+STRIP = @STRIP@
+TARGET = @TARGET@
+TARGETDIR = @TARGETDIR@
+VERSION = @VERSION@
+abs_builddir = @abs_builddir@
+abs_srcdir = @abs_srcdir@
+abs_top_builddir = @abs_top_builddir@
+abs_top_srcdir = @abs_top_srcdir@
+ac_ct_AR = @ac_ct_AR@
+ac_ct_CC = @ac_ct_CC@
+ac_ct_CXX = @ac_ct_CXX@
+ac_ct_DUMPBIN = @ac_ct_DUMPBIN@
+am__include = @am__include@
+am__leading_dot = @am__leading_dot@
+am__quote = @am__quote@
+am__tar = @am__tar@
+am__untar = @am__untar@
+ax_enable_builddir_sed = @ax_enable_builddir_sed@
+bindir = @bindir@
+build = @build@
+build_alias = @build_alias@
+build_cpu = @build_cpu@
+build_os = @build_os@
+build_vendor = @build_vendor@
+builddir = @builddir@
+datadir = @datadir@
+datarootdir = @datarootdir@
+docdir = @docdir@
+dvidir = @dvidir@
+exec_prefix = @exec_prefix@
+host = @host@
+host_alias = @host_alias@
+host_cpu = @host_cpu@
+host_os = @host_os@
+host_vendor = @host_vendor@
+htmldir = @htmldir@
+includedir = @includedir@
+infodir = @infodir@
+install_sh = @install_sh@
+libdir = @libdir@
+libexecdir = @libexecdir@
+localedir = @localedir@
+localstatedir = @localstatedir@
+mandir = @mandir@
+mkdir_p = @mkdir_p@
+oldincludedir = @oldincludedir@
+pdfdir = @pdfdir@
+prefix = @prefix@
+program_transform_name = @program_transform_name@
+psdir = @psdir@
+sbindir = @sbindir@
+sharedstatedir = @sharedstatedir@
+srcdir = @srcdir@
+sys_symbol_underscore = @sys_symbol_underscore@
+sysconfdir = @sysconfdir@
+target = @target@
+target_alias = @target_alias@
+target_cpu = @target_cpu@
+target_os = @target_os@
+target_vendor = @target_vendor@
+toolexecdir = @toolexecdir@
+toolexeclibdir = @toolexeclibdir@
+top_build_prefix = @top_build_prefix@
+top_builddir = @top_builddir@
+top_srcdir = @top_srcdir@
+AUTOMAKE_OPTIONS = foreign
+DISTCLEANFILES = ffitarget.h
+EXTRA_DIST = ffi.h.in ffi_common.h
+includesdir = $(libdir)/@PACKAGE_NAME@-@PACKAGE_VERSION@/include
+nodist_includes_HEADERS = ffi.h ffitarget.h
+all: all-am
+
+.SUFFIXES:
+$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps)
+ @for dep in $?; do \
+ case '$(am__configure_deps)' in \
+ *$$dep*) \
+ ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \
+ && { if test -f $@; then exit 0; else break; fi; }; \
+ exit 1;; \
+ esac; \
+ done; \
+ echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign include/Makefile'; \
+ $(am__cd) $(top_srcdir) && \
+ $(AUTOMAKE) --foreign include/Makefile
+.PRECIOUS: Makefile
+Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
+ @case '$?' in \
+ *config.status*) \
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
+ *) \
+ echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
+ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
+ esac;
+
+$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+
+$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(am__aclocal_m4_deps):
+ffi.h: $(top_builddir)/config.status $(srcdir)/ffi.h.in
+ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@
+
+mostlyclean-libtool:
+ -rm -f *.lo
+
+clean-libtool:
+ -rm -rf .libs _libs
+install-nodist_includesHEADERS: $(nodist_includes_HEADERS)
+ @$(NORMAL_INSTALL)
+ @list='$(nodist_includes_HEADERS)'; test -n "$(includesdir)" || list=; \
+ if test -n "$$list"; then \
+ echo " $(MKDIR_P) '$(DESTDIR)$(includesdir)'"; \
+ $(MKDIR_P) "$(DESTDIR)$(includesdir)" || exit 1; \
+ fi; \
+ for p in $$list; do \
+ if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \
+ echo "$$d$$p"; \
+ done | $(am__base_list) | \
+ while read files; do \
+ echo " $(INSTALL_HEADER) $$files '$(DESTDIR)$(includesdir)'"; \
+ $(INSTALL_HEADER) $$files "$(DESTDIR)$(includesdir)" || exit $$?; \
+ done
+
+uninstall-nodist_includesHEADERS:
+ @$(NORMAL_UNINSTALL)
+ @list='$(nodist_includes_HEADERS)'; test -n "$(includesdir)" || list=; \
+ files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \
+ dir='$(DESTDIR)$(includesdir)'; $(am__uninstall_files_from_dir)
+
+ID: $(am__tagged_files)
+ $(am__define_uniq_tagged_files); mkid -fID $$unique
+tags: tags-am
+TAGS: tags
+
+tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files)
+ set x; \
+ here=`pwd`; \
+ $(am__define_uniq_tagged_files); \
+ shift; \
+ if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \
+ test -n "$$unique" || unique=$$empty_fix; \
+ if test $$# -gt 0; then \
+ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+ "$$@" $$unique; \
+ else \
+ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+ $$unique; \
+ fi; \
+ fi
+ctags: ctags-am
+
+CTAGS: ctags
+ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files)
+ $(am__define_uniq_tagged_files); \
+ test -z "$(CTAGS_ARGS)$$unique" \
+ || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
+ $$unique
+
+GTAGS:
+ here=`$(am__cd) $(top_builddir) && pwd` \
+ && $(am__cd) $(top_srcdir) \
+ && gtags -i $(GTAGS_ARGS) "$$here"
+cscopelist: cscopelist-am
+
+cscopelist-am: $(am__tagged_files)
+ list='$(am__tagged_files)'; \
+ case "$(srcdir)" in \
+ [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \
+ *) sdir=$(subdir)/$(srcdir) ;; \
+ esac; \
+ for i in $$list; do \
+ if test -f "$$i"; then \
+ echo "$(subdir)/$$i"; \
+ else \
+ echo "$$sdir/$$i"; \
+ fi; \
+ done >> $(top_builddir)/cscope.files
+
+distclean-tags:
+ -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
+
+distdir: $(DISTFILES)
+ @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+ list='$(DISTFILES)'; \
+ dist_files=`for file in $$list; do echo $$file; done | \
+ sed -e "s|^$$srcdirstrip/||;t" \
+ -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
+ case $$dist_files in \
+ */*) $(MKDIR_P) `echo "$$dist_files" | \
+ sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
+ sort -u` ;; \
+ esac; \
+ for file in $$dist_files; do \
+ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
+ if test -d $$d/$$file; then \
+ dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
+ if test -d "$(distdir)/$$file"; then \
+ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
+ fi; \
+ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
+ cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \
+ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
+ fi; \
+ cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \
+ else \
+ test -f "$(distdir)/$$file" \
+ || cp -p $$d/$$file "$(distdir)/$$file" \
+ || exit 1; \
+ fi; \
+ done
+check-am: all-am
+check: check-am
+all-am: Makefile $(HEADERS)
+installdirs:
+ for dir in "$(DESTDIR)$(includesdir)"; do \
+ test -z "$$dir" || $(MKDIR_P) "$$dir"; \
+ done
+install: install-am
+install-exec: install-exec-am
+install-data: install-data-am
+uninstall: uninstall-am
+
+install-am: all-am
+ @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
+
+installcheck: installcheck-am
+install-strip:
+ if test -z '$(STRIP)'; then \
+ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
+ install; \
+ else \
+ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
+ "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \
+ fi
+mostlyclean-generic:
+
+clean-generic:
+
+distclean-generic:
+ -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
+ -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES)
+ -test -z "$(DISTCLEANFILES)" || rm -f $(DISTCLEANFILES)
+
+maintainer-clean-generic:
+ @echo "This command is intended for maintainers to use"
+ @echo "it deletes files that may require special tools to rebuild."
+clean: clean-am
+
+clean-am: clean-generic clean-libtool mostlyclean-am
+
+distclean: distclean-am
+ -rm -f Makefile
+distclean-am: clean-am distclean-generic distclean-tags
+
+dvi: dvi-am
+
+dvi-am:
+
+html: html-am
+
+html-am:
+
+info: info-am
+
+info-am:
+
+install-data-am: install-nodist_includesHEADERS
+
+install-dvi: install-dvi-am
+
+install-dvi-am:
+
+install-exec-am:
+
+install-html: install-html-am
+
+install-html-am:
+
+install-info: install-info-am
+
+install-info-am:
+
+install-man:
+
+install-pdf: install-pdf-am
+
+install-pdf-am:
+
+install-ps: install-ps-am
+
+install-ps-am:
+
+installcheck-am:
+
+maintainer-clean: maintainer-clean-am
+ -rm -f Makefile
+maintainer-clean-am: distclean-am maintainer-clean-generic
+
+mostlyclean: mostlyclean-am
+
+mostlyclean-am: mostlyclean-generic mostlyclean-libtool
+
+pdf: pdf-am
+
+pdf-am:
+
+ps: ps-am
+
+ps-am:
+
+uninstall-am: uninstall-nodist_includesHEADERS
+
+.MAKE: install-am install-strip
+
+.PHONY: CTAGS GTAGS TAGS all all-am check check-am clean clean-generic \
+ clean-libtool cscopelist-am ctags ctags-am distclean \
+ distclean-generic distclean-libtool distclean-tags distdir dvi \
+ dvi-am html html-am info info-am install install-am \
+ install-data install-data-am install-dvi install-dvi-am \
+ install-exec install-exec-am install-html install-html-am \
+ install-info install-info-am install-man \
+ install-nodist_includesHEADERS install-pdf install-pdf-am \
+ install-ps install-ps-am install-strip installcheck \
+ installcheck-am installdirs maintainer-clean \
+ maintainer-clean-generic mostlyclean mostlyclean-generic \
+ mostlyclean-libtool pdf pdf-am ps ps-am tags tags-am uninstall \
+ uninstall-am uninstall-nodist_includesHEADERS
+
+
+# Tell versions [3.59,3.63) of GNU make to not export all variables.
+# Otherwise a system limit (for SysV at least) may be exceeded.
+.NOEXPORT:
diff --git a/jni/ruby/ext/fiddle/libffi-3.2.1/include/ffi.h.in b/jni/ruby/ext/fiddle/libffi-3.2.1/include/ffi.h.in
new file mode 100644
index 0000000..f403ae0
--- /dev/null
+++ b/jni/ruby/ext/fiddle/libffi-3.2.1/include/ffi.h.in
@@ -0,0 +1,487 @@
+/* -----------------------------------------------------------------*-C-*-
+ libffi @VERSION@ - Copyright (c) 2011, 2014 Anthony Green
+ - Copyright (c) 1996-2003, 2007, 2008 Red Hat, Inc.
+
+ Permission is hereby granted, free of charge, to any person
+ obtaining a copy of this software and associated documentation
+ files (the ``Software''), to deal in the Software without
+ restriction, including without limitation the rights to use, copy,
+ modify, merge, publish, distribute, sublicense, and/or sell copies
+ of the Software, and to permit persons to whom the Software is
+ furnished to do so, subject to the following conditions:
+
+ The above copyright notice and this permission notice shall be
+ included in all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND,
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+ HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ DEALINGS IN THE SOFTWARE.
+
+ ----------------------------------------------------------------------- */
+
+/* -------------------------------------------------------------------
+ The basic API is described in the README file.
+
+ The raw API is designed to bypass some of the argument packing
+ and unpacking on architectures for which it can be avoided.
+
+ The closure API allows interpreted functions to be packaged up
+ inside a C function pointer, so that they can be called as C functions,
+ with no understanding on the client side that they are interpreted.
+ It can also be used in other cases in which it is necessary to package
+ up a user specified parameter and a function pointer as a single
+ function pointer.
+
+ The closure API must be implemented in order to get its functionality,
+ e.g. for use by gij. Routines are provided to emulate the raw API
+ if the underlying platform doesn't allow faster implementation.
+
+ More details on the raw and cloure API can be found in:
+
+ http://gcc.gnu.org/ml/java/1999-q3/msg00138.html
+
+ and
+
+ http://gcc.gnu.org/ml/java/1999-q3/msg00174.html
+ -------------------------------------------------------------------- */
+
+#ifndef LIBFFI_H
+#define LIBFFI_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* Specify which architecture libffi is configured for. */
+#ifndef @TARGET@
+#define @TARGET@
+#endif
+
+/* ---- System configuration information --------------------------------- */
+
+#include <ffitarget.h>
+
+#ifndef LIBFFI_ASM
+
+#if defined(_MSC_VER) && !defined(__clang__)
+#define __attribute__(X)
+#endif
+
+#include <stddef.h>
+#include <limits.h>
+
+/* LONG_LONG_MAX is not always defined (not if STRICT_ANSI, for example).
+ But we can find it either under the correct ANSI name, or under GNU
+ C's internal name. */
+
+#define FFI_64_BIT_MAX 9223372036854775807
+
+#ifdef LONG_LONG_MAX
+# define FFI_LONG_LONG_MAX LONG_LONG_MAX
+#else
+# ifdef LLONG_MAX
+# define FFI_LONG_LONG_MAX LLONG_MAX
+# ifdef _AIX52 /* or newer has C99 LLONG_MAX */
+# undef FFI_64_BIT_MAX
+# define FFI_64_BIT_MAX 9223372036854775807LL
+# endif /* _AIX52 or newer */
+# else
+# ifdef __GNUC__
+# define FFI_LONG_LONG_MAX __LONG_LONG_MAX__
+# endif
+# ifdef _AIX /* AIX 5.1 and earlier have LONGLONG_MAX */
+# ifndef __PPC64__
+# if defined (__IBMC__) || defined (__IBMCPP__)
+# define FFI_LONG_LONG_MAX LONGLONG_MAX
+# endif
+# endif /* __PPC64__ */
+# undef FFI_64_BIT_MAX
+# define FFI_64_BIT_MAX 9223372036854775807LL
+# endif
+# endif
+#endif
+
+/* The closure code assumes that this works on pointers, i.e. a size_t */
+/* can hold a pointer. */
+
+typedef struct _ffi_type
+{
+ size_t size;
+ unsigned short alignment;
+ unsigned short type;
+ struct _ffi_type **elements;
+} ffi_type;
+
+#ifndef LIBFFI_HIDE_BASIC_TYPES
+#if SCHAR_MAX == 127
+# define ffi_type_uchar ffi_type_uint8
+# define ffi_type_schar ffi_type_sint8
+#else
+ #error "char size not supported"
+#endif
+
+#if SHRT_MAX == 32767
+# define ffi_type_ushort ffi_type_uint16
+# define ffi_type_sshort ffi_type_sint16
+#elif SHRT_MAX == 2147483647
+# define ffi_type_ushort ffi_type_uint32
+# define ffi_type_sshort ffi_type_sint32
+#else
+ #error "short size not supported"
+#endif
+
+#if INT_MAX == 32767
+# define ffi_type_uint ffi_type_uint16
+# define ffi_type_sint ffi_type_sint16
+#elif INT_MAX == 2147483647
+# define ffi_type_uint ffi_type_uint32
+# define ffi_type_sint ffi_type_sint32
+#elif INT_MAX == 9223372036854775807
+# define ffi_type_uint ffi_type_uint64
+# define ffi_type_sint ffi_type_sint64
+#else
+ #error "int size not supported"
+#endif
+
+#if LONG_MAX == 2147483647
+# if FFI_LONG_LONG_MAX != FFI_64_BIT_MAX
+ #error "no 64-bit data type supported"
+# endif
+#elif LONG_MAX != FFI_64_BIT_MAX
+ #error "long size not supported"
+#endif
+
+#if LONG_MAX == 2147483647
+# define ffi_type_ulong ffi_type_uint32
+# define ffi_type_slong ffi_type_sint32
+#elif LONG_MAX == FFI_64_BIT_MAX
+# define ffi_type_ulong ffi_type_uint64
+# define ffi_type_slong ffi_type_sint64
+#else
+ #error "long size not supported"
+#endif
+
+/* Need minimal decorations for DLLs to works on Windows. */
+/* GCC has autoimport and autoexport. Rely on Libtool to */
+/* help MSVC export from a DLL, but always declare data */
+/* to be imported for MSVC clients. This costs an extra */
+/* indirection for MSVC clients using the static version */
+/* of the library, but don't worry about that. Besides, */
+/* as a workaround, they can define FFI_BUILDING if they */
+/* *know* they are going to link with the static library. */
+#if defined _MSC_VER && !defined FFI_BUILDING
+#define FFI_EXTERN extern __declspec(dllimport)
+#else
+#define FFI_EXTERN extern
+#endif
+
+/* These are defined in types.c */
+FFI_EXTERN ffi_type ffi_type_void;
+FFI_EXTERN ffi_type ffi_type_uint8;
+FFI_EXTERN ffi_type ffi_type_sint8;
+FFI_EXTERN ffi_type ffi_type_uint16;
+FFI_EXTERN ffi_type ffi_type_sint16;
+FFI_EXTERN ffi_type ffi_type_uint32;
+FFI_EXTERN ffi_type ffi_type_sint32;
+FFI_EXTERN ffi_type ffi_type_uint64;
+FFI_EXTERN ffi_type ffi_type_sint64;
+FFI_EXTERN ffi_type ffi_type_float;
+FFI_EXTERN ffi_type ffi_type_double;
+FFI_EXTERN ffi_type ffi_type_pointer;
+
+#if @HAVE_LONG_DOUBLE@
+FFI_EXTERN ffi_type ffi_type_longdouble;
+#else
+#define ffi_type_longdouble ffi_type_double
+#endif
+
+#ifdef FFI_TARGET_HAS_COMPLEX_TYPE
+FFI_EXTERN ffi_type ffi_type_complex_float;
+FFI_EXTERN ffi_type ffi_type_complex_double;
+#if @HAVE_LONG_DOUBLE@
+FFI_EXTERN ffi_type ffi_type_complex_longdouble;
+#else
+#define ffi_type_complex_longdouble ffi_type_complex_double
+#endif
+#endif
+#endif /* LIBFFI_HIDE_BASIC_TYPES */
+
+typedef enum {
+ FFI_OK = 0,
+ FFI_BAD_TYPEDEF,
+ FFI_BAD_ABI
+} ffi_status;
+
+typedef unsigned FFI_TYPE;
+
+typedef struct {
+ ffi_abi abi;
+ unsigned nargs;
+ ffi_type **arg_types;
+ ffi_type *rtype;
+ unsigned bytes;
+ unsigned flags;
+#ifdef FFI_EXTRA_CIF_FIELDS
+ FFI_EXTRA_CIF_FIELDS;
+#endif
+} ffi_cif;
+
+#if @HAVE_LONG_DOUBLE_VARIANT@
+/* Used to adjust size/alignment of ffi types. */
+void ffi_prep_types (ffi_abi abi);
+#endif
+
+/* Used internally, but overridden by some architectures */
+ffi_status ffi_prep_cif_core(ffi_cif *cif,
+ ffi_abi abi,
+ unsigned int isvariadic,
+ unsigned int nfixedargs,
+ unsigned int ntotalargs,
+ ffi_type *rtype,
+ ffi_type **atypes);
+
+/* ---- Definitions for the raw API -------------------------------------- */
+
+#ifndef FFI_SIZEOF_ARG
+# if LONG_MAX == 2147483647
+# define FFI_SIZEOF_ARG 4
+# elif LONG_MAX == FFI_64_BIT_MAX
+# define FFI_SIZEOF_ARG 8
+# endif
+#endif
+
+#ifndef FFI_SIZEOF_JAVA_RAW
+# define FFI_SIZEOF_JAVA_RAW FFI_SIZEOF_ARG
+#endif
+
+typedef union {
+ ffi_sarg sint;
+ ffi_arg uint;
+ float flt;
+ char data[FFI_SIZEOF_ARG];
+ void* ptr;
+} ffi_raw;
+
+#if FFI_SIZEOF_JAVA_RAW == 4 && FFI_SIZEOF_ARG == 8
+/* This is a special case for mips64/n32 ABI (and perhaps others) where
+ sizeof(void *) is 4 and FFI_SIZEOF_ARG is 8. */
+typedef union {
+ signed int sint;
+ unsigned int uint;
+ float flt;
+ char data[FFI_SIZEOF_JAVA_RAW];
+ void* ptr;
+} ffi_java_raw;
+#else
+typedef ffi_raw ffi_java_raw;
+#endif
+
+
+void ffi_raw_call (ffi_cif *cif,
+ void (*fn)(void),
+ void *rvalue,
+ ffi_raw *avalue);
+
+void ffi_ptrarray_to_raw (ffi_cif *cif, void **args, ffi_raw *raw);
+void ffi_raw_to_ptrarray (ffi_cif *cif, ffi_raw *raw, void **args);
+size_t ffi_raw_size (ffi_cif *cif);
+
+/* This is analogous to the raw API, except it uses Java parameter */
+/* packing, even on 64-bit machines. I.e. on 64-bit machines */
+/* longs and doubles are followed by an empty 64-bit word. */
+
+void ffi_java_raw_call (ffi_cif *cif,
+ void (*fn)(void),
+ void *rvalue,
+ ffi_java_raw *avalue);
+
+void ffi_java_ptrarray_to_raw (ffi_cif *cif, void **args, ffi_java_raw *raw);
+void ffi_java_raw_to_ptrarray (ffi_cif *cif, ffi_java_raw *raw, void **args);
+size_t ffi_java_raw_size (ffi_cif *cif);
+
+/* ---- Definitions for closures ----------------------------------------- */
+
+#if FFI_CLOSURES
+
+#ifdef _MSC_VER
+__declspec(align(8))
+#endif
+typedef struct {
+#if @FFI_EXEC_TRAMPOLINE_TABLE@
+ void *trampoline_table;
+ void *trampoline_table_entry;
+#else
+ char tramp[FFI_TRAMPOLINE_SIZE];
+#endif
+ ffi_cif *cif;
+ void (*fun)(ffi_cif*,void*,void**,void*);
+ void *user_data;
+#ifdef __GNUC__
+} ffi_closure __attribute__((aligned (8)));
+#else
+} ffi_closure;
+# ifdef __sgi
+# pragma pack 0
+# endif
+#endif
+
+void *ffi_closure_alloc (size_t size, void **code);
+void ffi_closure_free (void *);
+
+ffi_status
+ffi_prep_closure (ffi_closure*,
+ ffi_cif *,
+ void (*fun)(ffi_cif*,void*,void**,void*),
+ void *user_data);
+
+ffi_status
+ffi_prep_closure_loc (ffi_closure*,
+ ffi_cif *,
+ void (*fun)(ffi_cif*,void*,void**,void*),
+ void *user_data,
+ void*codeloc);
+
+#ifdef __sgi
+# pragma pack 8
+#endif
+typedef struct {
+#if @FFI_EXEC_TRAMPOLINE_TABLE@
+ void *trampoline_table;
+ void *trampoline_table_entry;
+#else
+ char tramp[FFI_TRAMPOLINE_SIZE];
+#endif
+ ffi_cif *cif;
+
+#if !FFI_NATIVE_RAW_API
+
+ /* if this is enabled, then a raw closure has the same layout
+ as a regular closure. We use this to install an intermediate
+ handler to do the transaltion, void** -> ffi_raw*. */
+
+ void (*translate_args)(ffi_cif*,void*,void**,void*);
+ void *this_closure;
+
+#endif
+
+ void (*fun)(ffi_cif*,void*,ffi_raw*,void*);
+ void *user_data;
+
+} ffi_raw_closure;
+
+typedef struct {
+#if @FFI_EXEC_TRAMPOLINE_TABLE@
+ void *trampoline_table;
+ void *trampoline_table_entry;
+#else
+ char tramp[FFI_TRAMPOLINE_SIZE];
+#endif
+
+ ffi_cif *cif;
+
+#if !FFI_NATIVE_RAW_API
+
+ /* if this is enabled, then a raw closure has the same layout
+ as a regular closure. We use this to install an intermediate
+ handler to do the transaltion, void** -> ffi_raw*. */
+
+ void (*translate_args)(ffi_cif*,void*,void**,void*);
+ void *this_closure;
+
+#endif
+
+ void (*fun)(ffi_cif*,void*,ffi_java_raw*,void*);
+ void *user_data;
+
+} ffi_java_raw_closure;
+
+ffi_status
+ffi_prep_raw_closure (ffi_raw_closure*,
+ ffi_cif *cif,
+ void (*fun)(ffi_cif*,void*,ffi_raw*,void*),
+ void *user_data);
+
+ffi_status
+ffi_prep_raw_closure_loc (ffi_raw_closure*,
+ ffi_cif *cif,
+ void (*fun)(ffi_cif*,void*,ffi_raw*,void*),
+ void *user_data,
+ void *codeloc);
+
+ffi_status
+ffi_prep_java_raw_closure (ffi_java_raw_closure*,
+ ffi_cif *cif,
+ void (*fun)(ffi_cif*,void*,ffi_java_raw*,void*),
+ void *user_data);
+
+ffi_status
+ffi_prep_java_raw_closure_loc (ffi_java_raw_closure*,
+ ffi_cif *cif,
+ void (*fun)(ffi_cif*,void*,ffi_java_raw*,void*),
+ void *user_data,
+ void *codeloc);
+
+#endif /* FFI_CLOSURES */
+
+/* ---- Public interface definition -------------------------------------- */
+
+ffi_status ffi_prep_cif(ffi_cif *cif,
+ ffi_abi abi,
+ unsigned int nargs,
+ ffi_type *rtype,
+ ffi_type **atypes);
+
+ffi_status ffi_prep_cif_var(ffi_cif *cif,
+ ffi_abi abi,
+ unsigned int nfixedargs,
+ unsigned int ntotalargs,
+ ffi_type *rtype,
+ ffi_type **atypes);
+
+void ffi_call(ffi_cif *cif,
+ void (*fn)(void),
+ void *rvalue,
+ void **avalue);
+
+/* Useful for eliminating compiler warnings */
+#define FFI_FN(f) ((void (*)(void))f)
+
+/* ---- Definitions shared with assembly code ---------------------------- */
+
+#endif
+
+/* If these change, update src/mips/ffitarget.h. */
+#define FFI_TYPE_VOID 0
+#define FFI_TYPE_INT 1
+#define FFI_TYPE_FLOAT 2
+#define FFI_TYPE_DOUBLE 3
+#if @HAVE_LONG_DOUBLE@
+#define FFI_TYPE_LONGDOUBLE 4
+#else
+#define FFI_TYPE_LONGDOUBLE FFI_TYPE_DOUBLE
+#endif
+#define FFI_TYPE_UINT8 5
+#define FFI_TYPE_SINT8 6
+#define FFI_TYPE_UINT16 7
+#define FFI_TYPE_SINT16 8
+#define FFI_TYPE_UINT32 9
+#define FFI_TYPE_SINT32 10
+#define FFI_TYPE_UINT64 11
+#define FFI_TYPE_SINT64 12
+#define FFI_TYPE_STRUCT 13
+#define FFI_TYPE_POINTER 14
+#define FFI_TYPE_COMPLEX 15
+
+/* This should always refer to the last type code (for sanity checks) */
+#define FFI_TYPE_LAST FFI_TYPE_COMPLEX
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/jni/ruby/ext/fiddle/libffi-3.2.1/include/ffi_common.h b/jni/ruby/ext/fiddle/libffi-3.2.1/include/ffi_common.h
new file mode 100644
index 0000000..37f5a9e
--- /dev/null
+++ b/jni/ruby/ext/fiddle/libffi-3.2.1/include/ffi_common.h
@@ -0,0 +1,132 @@
+/* -----------------------------------------------------------------------
+ ffi_common.h - Copyright (C) 2011, 2012, 2013 Anthony Green
+ Copyright (C) 2007 Free Software Foundation, Inc
+ Copyright (c) 1996 Red Hat, Inc.
+
+ Common internal definitions and macros. Only necessary for building
+ libffi.
+ ----------------------------------------------------------------------- */
+
+#ifndef FFI_COMMON_H
+#define FFI_COMMON_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <fficonfig.h>
+
+/* Do not move this. Some versions of AIX are very picky about where
+ this is positioned. */
+#ifdef __GNUC__
+# if HAVE_ALLOCA_H
+# include <alloca.h>
+# else
+ /* mingw64 defines this already in malloc.h. */
+# ifndef alloca
+# define alloca __builtin_alloca
+# endif
+# endif
+# define MAYBE_UNUSED __attribute__((__unused__))
+#else
+# define MAYBE_UNUSED
+# if HAVE_ALLOCA_H
+# include <alloca.h>
+# else
+# ifdef _AIX
+# pragma alloca
+# else
+# ifndef alloca /* predefined by HP cc +Olibcalls */
+# ifdef _MSC_VER
+# define alloca _alloca
+# else
+char *alloca ();
+# endif
+# endif
+# endif
+# endif
+#endif
+
+/* Check for the existence of memcpy. */
+#if STDC_HEADERS
+# include <string.h>
+#else
+# ifndef HAVE_MEMCPY
+# define memcpy(d, s, n) bcopy ((s), (d), (n))
+# endif
+#endif
+
+#if defined(FFI_DEBUG)
+#include <stdio.h>
+#endif
+
+#ifdef FFI_DEBUG
+void ffi_assert(char *expr, char *file, int line);
+void ffi_stop_here(void);
+void ffi_type_test(ffi_type *a, char *file, int line);
+
+#define FFI_ASSERT(x) ((x) ? (void)0 : ffi_assert(#x, __FILE__,__LINE__))
+#define FFI_ASSERT_AT(x, f, l) ((x) ? 0 : ffi_assert(#x, (f), (l)))
+#define FFI_ASSERT_VALID_TYPE(x) ffi_type_test (x, __FILE__, __LINE__)
+#else
+#define FFI_ASSERT(x)
+#define FFI_ASSERT_AT(x, f, l)
+#define FFI_ASSERT_VALID_TYPE(x)
+#endif
+
+#define ALIGN(v, a) (((((size_t) (v))-1) | ((a)-1))+1)
+#define ALIGN_DOWN(v, a) (((size_t) (v)) & -a)
+
+/* Perform machine dependent cif processing */
+ffi_status ffi_prep_cif_machdep(ffi_cif *cif);
+ffi_status ffi_prep_cif_machdep_var(ffi_cif *cif,
+ unsigned int nfixedargs, unsigned int ntotalargs);
+
+/* Extended cif, used in callback from assembly routine */
+typedef struct
+{
+ ffi_cif *cif;
+ void *rvalue;
+ void **avalue;
+} extended_cif;
+
+/* Terse sized type definitions. */
+#if defined(_MSC_VER) || defined(__sgi) || defined(__SUNPRO_C)
+typedef unsigned char UINT8;
+typedef signed char SINT8;
+typedef unsigned short UINT16;
+typedef signed short SINT16;
+typedef unsigned int UINT32;
+typedef signed int SINT32;
+# ifdef _MSC_VER
+typedef unsigned __int64 UINT64;
+typedef signed __int64 SINT64;
+# else
+# include <inttypes.h>
+typedef uint64_t UINT64;
+typedef int64_t SINT64;
+# endif
+#else
+typedef unsigned int UINT8 __attribute__((__mode__(__QI__)));
+typedef signed int SINT8 __attribute__((__mode__(__QI__)));
+typedef unsigned int UINT16 __attribute__((__mode__(__HI__)));
+typedef signed int SINT16 __attribute__((__mode__(__HI__)));
+typedef unsigned int UINT32 __attribute__((__mode__(__SI__)));
+typedef signed int SINT32 __attribute__((__mode__(__SI__)));
+typedef unsigned int UINT64 __attribute__((__mode__(__DI__)));
+typedef signed int SINT64 __attribute__((__mode__(__DI__)));
+#endif
+
+typedef float FLOAT32;
+
+#ifndef __GNUC__
+#define __builtin_expect(x, expected_value) (x)
+#endif
+#define LIKELY(x) __builtin_expect(!!(x),1)
+#define UNLIKELY(x) __builtin_expect((x)!=0,0)
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/jni/ruby/ext/fiddle/libffi-3.2.1/install-sh b/jni/ruby/ext/fiddle/libffi-3.2.1/install-sh
new file mode 100755
index 0000000..377bb86
--- /dev/null
+++ b/jni/ruby/ext/fiddle/libffi-3.2.1/install-sh
@@ -0,0 +1,527 @@
+#!/bin/sh
+# install - install a program, script, or datafile
+
+scriptversion=2011-11-20.07; # UTC
+
+# This originates from X11R5 (mit/util/scripts/install.sh), which was
+# later released in X11R6 (xc/config/util/install.sh) with the
+# following copyright and license.
+#
+# Copyright (C) 1994 X Consortium
+#
+# Permission is hereby granted, free of charge, to any person obtaining a copy
+# of this software and associated documentation files (the "Software"), to
+# deal in the Software without restriction, including without limitation the
+# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+# sell copies of the Software, and to permit persons to whom the Software is
+# furnished to do so, subject to the following conditions:
+#
+# The above copyright notice and this permission notice shall be included in
+# all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+# X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+# AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNEC-
+# TION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+#
+# Except as contained in this notice, the name of the X Consortium shall not
+# be used in advertising or otherwise to promote the sale, use or other deal-
+# ings in this Software without prior written authorization from the X Consor-
+# tium.
+#
+#
+# FSF changes to this file are in the public domain.
+#
+# Calling this script install-sh is preferred over install.sh, to prevent
+# 'make' implicit rules from creating a file called install from it
+# when there is no Makefile.
+#
+# This script is compatible with the BSD install script, but was written
+# from scratch.
+
+nl='
+'
+IFS=" "" $nl"
+
+# set DOITPROG to echo to test this script
+
+# Don't use :- since 4.3BSD and earlier shells don't like it.
+doit=${DOITPROG-}
+if test -z "$doit"; then
+ doit_exec=exec
+else
+ doit_exec=$doit
+fi
+
+# Put in absolute file names if you don't have them in your path;
+# or use environment vars.
+
+chgrpprog=${CHGRPPROG-chgrp}
+chmodprog=${CHMODPROG-chmod}
+chownprog=${CHOWNPROG-chown}
+cmpprog=${CMPPROG-cmp}
+cpprog=${CPPROG-cp}
+mkdirprog=${MKDIRPROG-mkdir}
+mvprog=${MVPROG-mv}
+rmprog=${RMPROG-rm}
+stripprog=${STRIPPROG-strip}
+
+posix_glob='?'
+initialize_posix_glob='
+ test "$posix_glob" != "?" || {
+ if (set -f) 2>/dev/null; then
+ posix_glob=
+ else
+ posix_glob=:
+ fi
+ }
+'
+
+posix_mkdir=
+
+# Desired mode of installed file.
+mode=0755
+
+chgrpcmd=
+chmodcmd=$chmodprog
+chowncmd=
+mvcmd=$mvprog
+rmcmd="$rmprog -f"
+stripcmd=
+
+src=
+dst=
+dir_arg=
+dst_arg=
+
+copy_on_change=false
+no_target_directory=
+
+usage="\
+Usage: $0 [OPTION]... [-T] SRCFILE DSTFILE
+ or: $0 [OPTION]... SRCFILES... DIRECTORY
+ or: $0 [OPTION]... -t DIRECTORY SRCFILES...
+ or: $0 [OPTION]... -d DIRECTORIES...
+
+In the 1st form, copy SRCFILE to DSTFILE.
+In the 2nd and 3rd, copy all SRCFILES to DIRECTORY.
+In the 4th, create DIRECTORIES.
+
+Options:
+ --help display this help and exit.
+ --version display version info and exit.
+
+ -c (ignored)
+ -C install only if different (preserve the last data modification time)
+ -d create directories instead of installing files.
+ -g GROUP $chgrpprog installed files to GROUP.
+ -m MODE $chmodprog installed files to MODE.
+ -o USER $chownprog installed files to USER.
+ -s $stripprog installed files.
+ -t DIRECTORY install into DIRECTORY.
+ -T report an error if DSTFILE is a directory.
+
+Environment variables override the default commands:
+ CHGRPPROG CHMODPROG CHOWNPROG CMPPROG CPPROG MKDIRPROG MVPROG
+ RMPROG STRIPPROG
+"
+
+while test $# -ne 0; do
+ case $1 in
+ -c) ;;
+
+ -C) copy_on_change=true;;
+
+ -d) dir_arg=true;;
+
+ -g) chgrpcmd="$chgrpprog $2"
+ shift;;
+
+ --help) echo "$usage"; exit $?;;
+
+ -m) mode=$2
+ case $mode in
+ *' '* | *' '* | *'
+'* | *'*'* | *'?'* | *'['*)
+ echo "$0: invalid mode: $mode" >&2
+ exit 1;;
+ esac
+ shift;;
+
+ -o) chowncmd="$chownprog $2"
+ shift;;
+
+ -s) stripcmd=$stripprog;;
+
+ -t) dst_arg=$2
+ # Protect names problematic for 'test' and other utilities.
+ case $dst_arg in
+ -* | [=\(\)!]) dst_arg=./$dst_arg;;
+ esac
+ shift;;
+
+ -T) no_target_directory=true;;
+
+ --version) echo "$0 $scriptversion"; exit $?;;
+
+ --) shift
+ break;;
+
+ -*) echo "$0: invalid option: $1" >&2
+ exit 1;;
+
+ *) break;;
+ esac
+ shift
+done
+
+if test $# -ne 0 && test -z "$dir_arg$dst_arg"; then
+ # When -d is used, all remaining arguments are directories to create.
+ # When -t is used, the destination is already specified.
+ # Otherwise, the last argument is the destination. Remove it from $@.
+ for arg
+ do
+ if test -n "$dst_arg"; then
+ # $@ is not empty: it contains at least $arg.
+ set fnord "$@" "$dst_arg"
+ shift # fnord
+ fi
+ shift # arg
+ dst_arg=$arg
+ # Protect names problematic for 'test' and other utilities.
+ case $dst_arg in
+ -* | [=\(\)!]) dst_arg=./$dst_arg;;
+ esac
+ done
+fi
+
+if test $# -eq 0; then
+ if test -z "$dir_arg"; then
+ echo "$0: no input file specified." >&2
+ exit 1
+ fi
+ # It's OK to call 'install-sh -d' without argument.
+ # This can happen when creating conditional directories.
+ exit 0
+fi
+
+if test -z "$dir_arg"; then
+ do_exit='(exit $ret); exit $ret'
+ trap "ret=129; $do_exit" 1
+ trap "ret=130; $do_exit" 2
+ trap "ret=141; $do_exit" 13
+ trap "ret=143; $do_exit" 15
+
+ # Set umask so as not to create temps with too-generous modes.
+ # However, 'strip' requires both read and write access to temps.
+ case $mode in
+ # Optimize common cases.
+ *644) cp_umask=133;;
+ *755) cp_umask=22;;
+
+ *[0-7])
+ if test -z "$stripcmd"; then
+ u_plus_rw=
+ else
+ u_plus_rw='% 200'
+ fi
+ cp_umask=`expr '(' 777 - $mode % 1000 ')' $u_plus_rw`;;
+ *)
+ if test -z "$stripcmd"; then
+ u_plus_rw=
+ else
+ u_plus_rw=,u+rw
+ fi
+ cp_umask=$mode$u_plus_rw;;
+ esac
+fi
+
+for src
+do
+ # Protect names problematic for 'test' and other utilities.
+ case $src in
+ -* | [=\(\)!]) src=./$src;;
+ esac
+
+ if test -n "$dir_arg"; then
+ dst=$src
+ dstdir=$dst
+ test -d "$dstdir"
+ dstdir_status=$?
+ else
+
+ # Waiting for this to be detected by the "$cpprog $src $dsttmp" command
+ # might cause directories to be created, which would be especially bad
+ # if $src (and thus $dsttmp) contains '*'.
+ if test ! -f "$src" && test ! -d "$src"; then
+ echo "$0: $src does not exist." >&2
+ exit 1
+ fi
+
+ if test -z "$dst_arg"; then
+ echo "$0: no destination specified." >&2
+ exit 1
+ fi
+ dst=$dst_arg
+
+ # If destination is a directory, append the input filename; won't work
+ # if double slashes aren't ignored.
+ if test -d "$dst"; then
+ if test -n "$no_target_directory"; then
+ echo "$0: $dst_arg: Is a directory" >&2
+ exit 1
+ fi
+ dstdir=$dst
+ dst=$dstdir/`basename "$src"`
+ dstdir_status=0
+ else
+ # Prefer dirname, but fall back on a substitute if dirname fails.
+ dstdir=`
+ (dirname "$dst") 2>/dev/null ||
+ expr X"$dst" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
+ X"$dst" : 'X\(//\)[^/]' \| \
+ X"$dst" : 'X\(//\)$' \| \
+ X"$dst" : 'X\(/\)' \| . 2>/dev/null ||
+ echo X"$dst" |
+ sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{
+ s//\1/
+ q
+ }
+ /^X\(\/\/\)[^/].*/{
+ s//\1/
+ q
+ }
+ /^X\(\/\/\)$/{
+ s//\1/
+ q
+ }
+ /^X\(\/\).*/{
+ s//\1/
+ q
+ }
+ s/.*/./; q'
+ `
+
+ test -d "$dstdir"
+ dstdir_status=$?
+ fi
+ fi
+
+ obsolete_mkdir_used=false
+
+ if test $dstdir_status != 0; then
+ case $posix_mkdir in
+ '')
+ # Create intermediate dirs using mode 755 as modified by the umask.
+ # This is like FreeBSD 'install' as of 1997-10-28.
+ umask=`umask`
+ case $stripcmd.$umask in
+ # Optimize common cases.
+ *[2367][2367]) mkdir_umask=$umask;;
+ .*0[02][02] | .[02][02] | .[02]) mkdir_umask=22;;
+
+ *[0-7])
+ mkdir_umask=`expr $umask + 22 \
+ - $umask % 100 % 40 + $umask % 20 \
+ - $umask % 10 % 4 + $umask % 2
+ `;;
+ *) mkdir_umask=$umask,go-w;;
+ esac
+
+ # With -d, create the new directory with the user-specified mode.
+ # Otherwise, rely on $mkdir_umask.
+ if test -n "$dir_arg"; then
+ mkdir_mode=-m$mode
+ else
+ mkdir_mode=
+ fi
+
+ posix_mkdir=false
+ case $umask in
+ *[123567][0-7][0-7])
+ # POSIX mkdir -p sets u+wx bits regardless of umask, which
+ # is incompatible with FreeBSD 'install' when (umask & 300) != 0.
+ ;;
+ *)
+ tmpdir=${TMPDIR-/tmp}/ins$RANDOM-$$
+ trap 'ret=$?; rmdir "$tmpdir/d" "$tmpdir" 2>/dev/null; exit $ret' 0
+
+ if (umask $mkdir_umask &&
+ exec $mkdirprog $mkdir_mode -p -- "$tmpdir/d") >/dev/null 2>&1
+ then
+ if test -z "$dir_arg" || {
+ # Check for POSIX incompatibilities with -m.
+ # HP-UX 11.23 and IRIX 6.5 mkdir -m -p sets group- or
+ # other-writable bit of parent directory when it shouldn't.
+ # FreeBSD 6.1 mkdir -m -p sets mode of existing directory.
+ ls_ld_tmpdir=`ls -ld "$tmpdir"`
+ case $ls_ld_tmpdir in
+ d????-?r-*) different_mode=700;;
+ d????-?--*) different_mode=755;;
+ *) false;;
+ esac &&
+ $mkdirprog -m$different_mode -p -- "$tmpdir" && {
+ ls_ld_tmpdir_1=`ls -ld "$tmpdir"`
+ test "$ls_ld_tmpdir" = "$ls_ld_tmpdir_1"
+ }
+ }
+ then posix_mkdir=:
+ fi
+ rmdir "$tmpdir/d" "$tmpdir"
+ else
+ # Remove any dirs left behind by ancient mkdir implementations.
+ rmdir ./$mkdir_mode ./-p ./-- 2>/dev/null
+ fi
+ trap '' 0;;
+ esac;;
+ esac
+
+ if
+ $posix_mkdir && (
+ umask $mkdir_umask &&
+ $doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir"
+ )
+ then :
+ else
+
+ # The umask is ridiculous, or mkdir does not conform to POSIX,
+ # or it failed possibly due to a race condition. Create the
+ # directory the slow way, step by step, checking for races as we go.
+
+ case $dstdir in
+ /*) prefix='/';;
+ [-=\(\)!]*) prefix='./';;
+ *) prefix='';;
+ esac
+
+ eval "$initialize_posix_glob"
+
+ oIFS=$IFS
+ IFS=/
+ $posix_glob set -f
+ set fnord $dstdir
+ shift
+ $posix_glob set +f
+ IFS=$oIFS
+
+ prefixes=
+
+ for d
+ do
+ test X"$d" = X && continue
+
+ prefix=$prefix$d
+ if test -d "$prefix"; then
+ prefixes=
+ else
+ if $posix_mkdir; then
+ (umask=$mkdir_umask &&
+ $doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir") && break
+ # Don't fail if two instances are running concurrently.
+ test -d "$prefix" || exit 1
+ else
+ case $prefix in
+ *\'*) qprefix=`echo "$prefix" | sed "s/'/'\\\\\\\\''/g"`;;
+ *) qprefix=$prefix;;
+ esac
+ prefixes="$prefixes '$qprefix'"
+ fi
+ fi
+ prefix=$prefix/
+ done
+
+ if test -n "$prefixes"; then
+ # Don't fail if two instances are running concurrently.
+ (umask $mkdir_umask &&
+ eval "\$doit_exec \$mkdirprog $prefixes") ||
+ test -d "$dstdir" || exit 1
+ obsolete_mkdir_used=true
+ fi
+ fi
+ fi
+
+ if test -n "$dir_arg"; then
+ { test -z "$chowncmd" || $doit $chowncmd "$dst"; } &&
+ { test -z "$chgrpcmd" || $doit $chgrpcmd "$dst"; } &&
+ { test "$obsolete_mkdir_used$chowncmd$chgrpcmd" = false ||
+ test -z "$chmodcmd" || $doit $chmodcmd $mode "$dst"; } || exit 1
+ else
+
+ # Make a couple of temp file names in the proper directory.
+ dsttmp=$dstdir/_inst.$$_
+ rmtmp=$dstdir/_rm.$$_
+
+ # Trap to clean up those temp files at exit.
+ trap 'ret=$?; rm -f "$dsttmp" "$rmtmp" && exit $ret' 0
+
+ # Copy the file name to the temp name.
+ (umask $cp_umask && $doit_exec $cpprog "$src" "$dsttmp") &&
+
+ # and set any options; do chmod last to preserve setuid bits.
+ #
+ # If any of these fail, we abort the whole thing. If we want to
+ # ignore errors from any of these, just make sure not to ignore
+ # errors from the above "$doit $cpprog $src $dsttmp" command.
+ #
+ { test -z "$chowncmd" || $doit $chowncmd "$dsttmp"; } &&
+ { test -z "$chgrpcmd" || $doit $chgrpcmd "$dsttmp"; } &&
+ { test -z "$stripcmd" || $doit $stripcmd "$dsttmp"; } &&
+ { test -z "$chmodcmd" || $doit $chmodcmd $mode "$dsttmp"; } &&
+
+ # If -C, don't bother to copy if it wouldn't change the file.
+ if $copy_on_change &&
+ old=`LC_ALL=C ls -dlL "$dst" 2>/dev/null` &&
+ new=`LC_ALL=C ls -dlL "$dsttmp" 2>/dev/null` &&
+
+ eval "$initialize_posix_glob" &&
+ $posix_glob set -f &&
+ set X $old && old=:$2:$4:$5:$6 &&
+ set X $new && new=:$2:$4:$5:$6 &&
+ $posix_glob set +f &&
+
+ test "$old" = "$new" &&
+ $cmpprog "$dst" "$dsttmp" >/dev/null 2>&1
+ then
+ rm -f "$dsttmp"
+ else
+ # Rename the file to the real destination.
+ $doit $mvcmd -f "$dsttmp" "$dst" 2>/dev/null ||
+
+ # The rename failed, perhaps because mv can't rename something else
+ # to itself, or perhaps because mv is so ancient that it does not
+ # support -f.
+ {
+ # Now remove or move aside any old file at destination location.
+ # We try this two ways since rm can't unlink itself on some
+ # systems and the destination file might be busy for other
+ # reasons. In this case, the final cleanup might fail but the new
+ # file should still install successfully.
+ {
+ test ! -f "$dst" ||
+ $doit $rmcmd -f "$dst" 2>/dev/null ||
+ { $doit $mvcmd -f "$dst" "$rmtmp" 2>/dev/null &&
+ { $doit $rmcmd -f "$rmtmp" 2>/dev/null; :; }
+ } ||
+ { echo "$0: cannot unlink or rename $dst" >&2
+ (exit 1); exit 1
+ }
+ } &&
+
+ # Now rename the file to the real destination.
+ $doit $mvcmd "$dsttmp" "$dst"
+ }
+ fi || exit 1
+
+ trap '' 0
+ fi
+done
+
+# Local variables:
+# eval: (add-hook 'write-file-hooks 'time-stamp)
+# time-stamp-start: "scriptversion="
+# time-stamp-format: "%:y-%02m-%02d.%02H"
+# time-stamp-time-zone: "UTC"
+# time-stamp-end: "; # UTC"
+# End:
diff --git a/jni/ruby/ext/fiddle/libffi-3.2.1/libffi.pc.in b/jni/ruby/ext/fiddle/libffi-3.2.1/libffi.pc.in
new file mode 100644
index 0000000..edf6fde
--- /dev/null
+++ b/jni/ruby/ext/fiddle/libffi-3.2.1/libffi.pc.in
@@ -0,0 +1,11 @@
+prefix=@prefix@
+exec_prefix=@exec_prefix@
+libdir=@libdir@
+toolexeclibdir=@toolexeclibdir@
+includedir=${libdir}/@PACKAGE_NAME@-@PACKAGE_VERSION@/include
+
+Name: @PACKAGE_NAME@
+Description: Library supporting Foreign Function Interfaces
+Version: @PACKAGE_VERSION@
+Libs: -L${toolexeclibdir} -lffi
+Cflags: -I${includedir}
diff --git a/jni/ruby/ext/fiddle/libffi-3.2.1/libffi.xcodeproj/project.pbxproj b/jni/ruby/ext/fiddle/libffi-3.2.1/libffi.xcodeproj/project.pbxproj
new file mode 100644
index 0000000..1cf396f
--- /dev/null
+++ b/jni/ruby/ext/fiddle/libffi-3.2.1/libffi.xcodeproj/project.pbxproj
@@ -0,0 +1,637 @@
+// !$*UTF8*$!
+{
+ archiveVersion = 1;
+ classes = {
+ };
+ objectVersion = 46;
+ objects = {
+
+/* Begin PBXBuildFile section */
+ DBFA714A187F1D8600A76262 /* ffi.h in Headers */ = {isa = PBXBuildFile; fileRef = DBFA713E187F1D8600A76262 /* ffi.h */; };
+ DBFA714B187F1D8600A76262 /* ffi_common.h in Headers */ = {isa = PBXBuildFile; fileRef = DBFA713F187F1D8600A76262 /* ffi_common.h */; };
+ DBFA714C187F1D8600A76262 /* fficonfig.h in Headers */ = {isa = PBXBuildFile; fileRef = DBFA7140187F1D8600A76262 /* fficonfig.h */; };
+ DBFA714D187F1D8600A76262 /* ffitarget.h in Headers */ = {isa = PBXBuildFile; fileRef = DBFA7141187F1D8600A76262 /* ffitarget.h */; };
+ DBFA714E187F1D8600A76262 /* closures.c in Sources */ = {isa = PBXBuildFile; fileRef = DBFA7143187F1D8600A76262 /* closures.c */; };
+ DBFA714F187F1D8600A76262 /* closures.c in Sources */ = {isa = PBXBuildFile; fileRef = DBFA7143187F1D8600A76262 /* closures.c */; };
+ DBFA7156187F1D8600A76262 /* prep_cif.c in Sources */ = {isa = PBXBuildFile; fileRef = DBFA7147187F1D8600A76262 /* prep_cif.c */; };
+ DBFA7157187F1D8600A76262 /* prep_cif.c in Sources */ = {isa = PBXBuildFile; fileRef = DBFA7147187F1D8600A76262 /* prep_cif.c */; };
+ DBFA7158187F1D8600A76262 /* raw_api.c in Sources */ = {isa = PBXBuildFile; fileRef = DBFA7148187F1D8600A76262 /* raw_api.c */; };
+ DBFA7159187F1D8600A76262 /* raw_api.c in Sources */ = {isa = PBXBuildFile; fileRef = DBFA7148187F1D8600A76262 /* raw_api.c */; };
+ DBFA715A187F1D8600A76262 /* types.c in Sources */ = {isa = PBXBuildFile; fileRef = DBFA7149187F1D8600A76262 /* types.c */; };
+ DBFA715B187F1D8600A76262 /* types.c in Sources */ = {isa = PBXBuildFile; fileRef = DBFA7149187F1D8600A76262 /* types.c */; };
+ DBFA7177187F1D9B00A76262 /* ffi_arm64.c in Sources */ = {isa = PBXBuildFile; fileRef = DBFA716C187F1D9B00A76262 /* ffi_arm64.c */; };
+ DBFA7178187F1D9B00A76262 /* sysv_arm64.S in Sources */ = {isa = PBXBuildFile; fileRef = DBFA716D187F1D9B00A76262 /* sysv_arm64.S */; };
+ DBFA7179187F1D9B00A76262 /* ffi_armv7.c in Sources */ = {isa = PBXBuildFile; fileRef = DBFA716F187F1D9B00A76262 /* ffi_armv7.c */; };
+ DBFA717A187F1D9B00A76262 /* sysv_armv7.S in Sources */ = {isa = PBXBuildFile; fileRef = DBFA7170187F1D9B00A76262 /* sysv_armv7.S */; };
+ DBFA717B187F1D9B00A76262 /* trampoline_armv7.S in Sources */ = {isa = PBXBuildFile; fileRef = DBFA7171187F1D9B00A76262 /* trampoline_armv7.S */; };
+ DBFA717C187F1D9B00A76262 /* darwin64_x86_64.S in Sources */ = {isa = PBXBuildFile; fileRef = DBFA7173187F1D9B00A76262 /* darwin64_x86_64.S */; };
+ DBFA717D187F1D9B00A76262 /* darwin_i386.S in Sources */ = {isa = PBXBuildFile; fileRef = DBFA7174187F1D9B00A76262 /* darwin_i386.S */; };
+ DBFA717E187F1D9B00A76262 /* ffi64_x86_64.c in Sources */ = {isa = PBXBuildFile; fileRef = DBFA7175187F1D9B00A76262 /* ffi64_x86_64.c */; };
+ DBFA717F187F1D9B00A76262 /* ffi_i386.c in Sources */ = {isa = PBXBuildFile; fileRef = DBFA7176187F1D9B00A76262 /* ffi_i386.c */; };
+ DBFA718E187F1DA100A76262 /* ffi_i386.h in Headers */ = {isa = PBXBuildFile; fileRef = DBFA7182187F1DA100A76262 /* ffi_i386.h */; };
+ DBFA718F187F1DA100A76262 /* ffi_x86_64.h in Headers */ = {isa = PBXBuildFile; fileRef = DBFA7183187F1DA100A76262 /* ffi_x86_64.h */; };
+ DBFA7190187F1DA100A76262 /* fficonfig_i386.h in Headers */ = {isa = PBXBuildFile; fileRef = DBFA7184187F1DA100A76262 /* fficonfig_i386.h */; };
+ DBFA7191187F1DA100A76262 /* fficonfig_x86_64.h in Headers */ = {isa = PBXBuildFile; fileRef = DBFA7185187F1DA100A76262 /* fficonfig_x86_64.h */; };
+ DBFA7192187F1DA100A76262 /* ffitarget_i386.h in Headers */ = {isa = PBXBuildFile; fileRef = DBFA7186187F1DA100A76262 /* ffitarget_i386.h */; };
+ DBFA7193187F1DA100A76262 /* ffitarget_x86_64.h in Headers */ = {isa = PBXBuildFile; fileRef = DBFA7187187F1DA100A76262 /* ffitarget_x86_64.h */; };
+ DBFA7194187F1DA100A76262 /* darwin64_x86_64.S in Sources */ = {isa = PBXBuildFile; fileRef = DBFA718A187F1DA100A76262 /* darwin64_x86_64.S */; };
+ DBFA7195187F1DA100A76262 /* darwin_i386.S in Sources */ = {isa = PBXBuildFile; fileRef = DBFA718B187F1DA100A76262 /* darwin_i386.S */; };
+ DBFA7196187F1DA100A76262 /* ffi64_x86_64.c in Sources */ = {isa = PBXBuildFile; fileRef = DBFA718C187F1DA100A76262 /* ffi64_x86_64.c */; };
+ DBFA7197187F1DA100A76262 /* ffi_i386.c in Sources */ = {isa = PBXBuildFile; fileRef = DBFA718D187F1DA100A76262 /* ffi_i386.c */; };
+/* End PBXBuildFile section */
+
+/* Begin PBXCopyFilesBuildPhase section */
+ DB13B1641849DF1E0010F42D /* CopyFiles */ = {
+ isa = PBXCopyFilesBuildPhase;
+ buildActionMask = 8;
+ dstPath = "include/$(PRODUCT_NAME)";
+ dstSubfolderSpec = 16;
+ files = (
+ );
+ runOnlyForDeploymentPostprocessing = 1;
+ };
+/* End PBXCopyFilesBuildPhase section */
+
+/* Begin PBXFileReference section */
+ DB13B1661849DF1E0010F42D /* libffi.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libffi.a; sourceTree = BUILT_PRODUCTS_DIR; };
+ DB13B1911849DF510010F42D /* ffi.dylib */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.dylib"; includeInIndex = 0; path = ffi.dylib; sourceTree = BUILT_PRODUCTS_DIR; };
+ DBFA713E187F1D8600A76262 /* ffi.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ffi.h; sourceTree = "<group>"; };
+ DBFA713F187F1D8600A76262 /* ffi_common.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ffi_common.h; sourceTree = "<group>"; };
+ DBFA7140187F1D8600A76262 /* fficonfig.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = fficonfig.h; sourceTree = "<group>"; };
+ DBFA7141187F1D8600A76262 /* ffitarget.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ffitarget.h; sourceTree = "<group>"; };
+ DBFA7143187F1D8600A76262 /* closures.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = closures.c; sourceTree = "<group>"; };
+ DBFA7145187F1D8600A76262 /* dlmalloc.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = dlmalloc.c; sourceTree = "<group>"; };
+ DBFA7147187F1D8600A76262 /* prep_cif.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = prep_cif.c; sourceTree = "<group>"; };
+ DBFA7148187F1D8600A76262 /* raw_api.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = raw_api.c; sourceTree = "<group>"; };
+ DBFA7149187F1D8600A76262 /* types.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = types.c; sourceTree = "<group>"; };
+ DBFA715E187F1D9B00A76262 /* ffi_arm64.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ffi_arm64.h; sourceTree = "<group>"; };
+ DBFA715F187F1D9B00A76262 /* ffi_armv7.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ffi_armv7.h; sourceTree = "<group>"; };
+ DBFA7160187F1D9B00A76262 /* ffi_i386.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ffi_i386.h; sourceTree = "<group>"; };
+ DBFA7161187F1D9B00A76262 /* ffi_x86_64.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ffi_x86_64.h; sourceTree = "<group>"; };
+ DBFA7162187F1D9B00A76262 /* fficonfig_arm64.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = fficonfig_arm64.h; sourceTree = "<group>"; };
+ DBFA7163187F1D9B00A76262 /* fficonfig_armv7.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = fficonfig_armv7.h; sourceTree = "<group>"; };
+ DBFA7164187F1D9B00A76262 /* fficonfig_i386.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = fficonfig_i386.h; sourceTree = "<group>"; };
+ DBFA7165187F1D9B00A76262 /* fficonfig_x86_64.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = fficonfig_x86_64.h; sourceTree = "<group>"; };
+ DBFA7166187F1D9B00A76262 /* ffitarget_arm64.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ffitarget_arm64.h; sourceTree = "<group>"; };
+ DBFA7167187F1D9B00A76262 /* ffitarget_armv7.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ffitarget_armv7.h; sourceTree = "<group>"; };
+ DBFA7168187F1D9B00A76262 /* ffitarget_i386.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ffitarget_i386.h; sourceTree = "<group>"; };
+ DBFA7169187F1D9B00A76262 /* ffitarget_x86_64.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ffitarget_x86_64.h; sourceTree = "<group>"; };
+ DBFA716C187F1D9B00A76262 /* ffi_arm64.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = ffi_arm64.c; sourceTree = "<group>"; };
+ DBFA716D187F1D9B00A76262 /* sysv_arm64.S */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.asm; path = sysv_arm64.S; sourceTree = "<group>"; };
+ DBFA716F187F1D9B00A76262 /* ffi_armv7.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = ffi_armv7.c; sourceTree = "<group>"; };
+ DBFA7170187F1D9B00A76262 /* sysv_armv7.S */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.asm; path = sysv_armv7.S; sourceTree = "<group>"; };
+ DBFA7171187F1D9B00A76262 /* trampoline_armv7.S */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.asm; path = trampoline_armv7.S; sourceTree = "<group>"; };
+ DBFA7173187F1D9B00A76262 /* darwin64_x86_64.S */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.asm; path = darwin64_x86_64.S; sourceTree = "<group>"; };
+ DBFA7174187F1D9B00A76262 /* darwin_i386.S */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.asm; path = darwin_i386.S; sourceTree = "<group>"; };
+ DBFA7175187F1D9B00A76262 /* ffi64_x86_64.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = ffi64_x86_64.c; sourceTree = "<group>"; };
+ DBFA7176187F1D9B00A76262 /* ffi_i386.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = ffi_i386.c; sourceTree = "<group>"; };
+ DBFA7182187F1DA100A76262 /* ffi_i386.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ffi_i386.h; sourceTree = "<group>"; };
+ DBFA7183187F1DA100A76262 /* ffi_x86_64.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ffi_x86_64.h; sourceTree = "<group>"; };
+ DBFA7184187F1DA100A76262 /* fficonfig_i386.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = fficonfig_i386.h; sourceTree = "<group>"; };
+ DBFA7185187F1DA100A76262 /* fficonfig_x86_64.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = fficonfig_x86_64.h; sourceTree = "<group>"; };
+ DBFA7186187F1DA100A76262 /* ffitarget_i386.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ffitarget_i386.h; sourceTree = "<group>"; };
+ DBFA7187187F1DA100A76262 /* ffitarget_x86_64.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ffitarget_x86_64.h; sourceTree = "<group>"; };
+ DBFA718A187F1DA100A76262 /* darwin64_x86_64.S */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.asm; path = darwin64_x86_64.S; sourceTree = "<group>"; };
+ DBFA718B187F1DA100A76262 /* darwin_i386.S */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.asm; path = darwin_i386.S; sourceTree = "<group>"; };
+ DBFA718C187F1DA100A76262 /* ffi64_x86_64.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = ffi64_x86_64.c; sourceTree = "<group>"; };
+ DBFA718D187F1DA100A76262 /* ffi_i386.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = ffi_i386.c; sourceTree = "<group>"; };
+/* End PBXFileReference section */
+
+/* Begin PBXGroup section */
+ DB13B15B1849DEB70010F42D = {
+ isa = PBXGroup;
+ children = (
+ DBFA713C187F1D8600A76262 /* darwin_common */,
+ DBFA715C187F1D9B00A76262 /* darwin_ios */,
+ DBFA7180187F1DA100A76262 /* darwin_osx */,
+ DB13B1671849DF1E0010F42D /* Products */,
+ );
+ sourceTree = "<group>";
+ };
+ DB13B1671849DF1E0010F42D /* Products */ = {
+ isa = PBXGroup;
+ children = (
+ DB13B1661849DF1E0010F42D /* libffi.a */,
+ DB13B1911849DF510010F42D /* ffi.dylib */,
+ );
+ name = Products;
+ sourceTree = "<group>";
+ };
+ DBFA713C187F1D8600A76262 /* darwin_common */ = {
+ isa = PBXGroup;
+ children = (
+ DBFA713D187F1D8600A76262 /* include */,
+ DBFA7142187F1D8600A76262 /* src */,
+ );
+ path = "darwin_common";
+ sourceTree = "<group>";
+ };
+ DBFA713D187F1D8600A76262 /* include */ = {
+ isa = PBXGroup;
+ children = (
+ DBFA713E187F1D8600A76262 /* ffi.h */,
+ DBFA713F187F1D8600A76262 /* ffi_common.h */,
+ DBFA7140187F1D8600A76262 /* fficonfig.h */,
+ DBFA7141187F1D8600A76262 /* ffitarget.h */,
+ );
+ path = include;
+ sourceTree = "<group>";
+ };
+ DBFA7142187F1D8600A76262 /* src */ = {
+ isa = PBXGroup;
+ children = (
+ DBFA7143187F1D8600A76262 /* closures.c */,
+ DBFA7145187F1D8600A76262 /* dlmalloc.c */,
+ DBFA7147187F1D8600A76262 /* prep_cif.c */,
+ DBFA7148187F1D8600A76262 /* raw_api.c */,
+ DBFA7149187F1D8600A76262 /* types.c */,
+ );
+ path = src;
+ sourceTree = "<group>";
+ };
+ DBFA715C187F1D9B00A76262 /* darwin_ios */ = {
+ isa = PBXGroup;
+ children = (
+ DBFA715D187F1D9B00A76262 /* include */,
+ DBFA716A187F1D9B00A76262 /* src */,
+ );
+ path = "darwin_ios";
+ sourceTree = "<group>";
+ };
+ DBFA715D187F1D9B00A76262 /* include */ = {
+ isa = PBXGroup;
+ children = (
+ DBFA715E187F1D9B00A76262 /* ffi_arm64.h */,
+ DBFA715F187F1D9B00A76262 /* ffi_armv7.h */,
+ DBFA7160187F1D9B00A76262 /* ffi_i386.h */,
+ DBFA7161187F1D9B00A76262 /* ffi_x86_64.h */,
+ DBFA7162187F1D9B00A76262 /* fficonfig_arm64.h */,
+ DBFA7163187F1D9B00A76262 /* fficonfig_armv7.h */,
+ DBFA7164187F1D9B00A76262 /* fficonfig_i386.h */,
+ DBFA7165187F1D9B00A76262 /* fficonfig_x86_64.h */,
+ DBFA7166187F1D9B00A76262 /* ffitarget_arm64.h */,
+ DBFA7167187F1D9B00A76262 /* ffitarget_armv7.h */,
+ DBFA7168187F1D9B00A76262 /* ffitarget_i386.h */,
+ DBFA7169187F1D9B00A76262 /* ffitarget_x86_64.h */,
+ );
+ path = include;
+ sourceTree = "<group>";
+ };
+ DBFA716A187F1D9B00A76262 /* src */ = {
+ isa = PBXGroup;
+ children = (
+ DBFA716B187F1D9B00A76262 /* aarch64 */,
+ DBFA716E187F1D9B00A76262 /* arm */,
+ DBFA7172187F1D9B00A76262 /* x86 */,
+ );
+ path = src;
+ sourceTree = "<group>";
+ };
+ DBFA716B187F1D9B00A76262 /* aarch64 */ = {
+ isa = PBXGroup;
+ children = (
+ DBFA716C187F1D9B00A76262 /* ffi_arm64.c */,
+ DBFA716D187F1D9B00A76262 /* sysv_arm64.S */,
+ );
+ path = aarch64;
+ sourceTree = "<group>";
+ };
+ DBFA716E187F1D9B00A76262 /* arm */ = {
+ isa = PBXGroup;
+ children = (
+ DBFA716F187F1D9B00A76262 /* ffi_armv7.c */,
+ DBFA7170187F1D9B00A76262 /* sysv_armv7.S */,
+ DBFA7171187F1D9B00A76262 /* trampoline_armv7.S */,
+ );
+ path = arm;
+ sourceTree = "<group>";
+ };
+ DBFA7172187F1D9B00A76262 /* x86 */ = {
+ isa = PBXGroup;
+ children = (
+ DBFA7173187F1D9B00A76262 /* darwin64_x86_64.S */,
+ DBFA7174187F1D9B00A76262 /* darwin_i386.S */,
+ DBFA7175187F1D9B00A76262 /* ffi64_x86_64.c */,
+ DBFA7176187F1D9B00A76262 /* ffi_i386.c */,
+ );
+ path = x86;
+ sourceTree = "<group>";
+ };
+ DBFA7180187F1DA100A76262 /* darwin_osx */ = {
+ isa = PBXGroup;
+ children = (
+ DBFA7181187F1DA100A76262 /* include */,
+ DBFA7188187F1DA100A76262 /* src */,
+ );
+ path = "darwin_osx";
+ sourceTree = "<group>";
+ };
+ DBFA7181187F1DA100A76262 /* include */ = {
+ isa = PBXGroup;
+ children = (
+ DBFA7182187F1DA100A76262 /* ffi_i386.h */,
+ DBFA7183187F1DA100A76262 /* ffi_x86_64.h */,
+ DBFA7184187F1DA100A76262 /* fficonfig_i386.h */,
+ DBFA7185187F1DA100A76262 /* fficonfig_x86_64.h */,
+ DBFA7186187F1DA100A76262 /* ffitarget_i386.h */,
+ DBFA7187187F1DA100A76262 /* ffitarget_x86_64.h */,
+ );
+ path = include;
+ sourceTree = "<group>";
+ };
+ DBFA7188187F1DA100A76262 /* src */ = {
+ isa = PBXGroup;
+ children = (
+ DBFA7189187F1DA100A76262 /* x86 */,
+ );
+ path = src;
+ sourceTree = "<group>";
+ };
+ DBFA7189187F1DA100A76262 /* x86 */ = {
+ isa = PBXGroup;
+ children = (
+ DBFA718A187F1DA100A76262 /* darwin64_x86_64.S */,
+ DBFA718B187F1DA100A76262 /* darwin_i386.S */,
+ DBFA718C187F1DA100A76262 /* ffi64_x86_64.c */,
+ DBFA718D187F1DA100A76262 /* ffi_i386.c */,
+ );
+ path = x86;
+ sourceTree = "<group>";
+ };
+/* End PBXGroup section */
+
+/* Begin PBXHeadersBuildPhase section */
+ DB13B18F1849DF510010F42D /* Headers */ = {
+ isa = PBXHeadersBuildPhase;
+ buildActionMask = 2147483647;
+ files = (
+ DBFA714C187F1D8600A76262 /* fficonfig.h in Headers */,
+ DBFA714D187F1D8600A76262 /* ffitarget.h in Headers */,
+ DBFA714A187F1D8600A76262 /* ffi.h in Headers */,
+ DBFA718F187F1DA100A76262 /* ffi_x86_64.h in Headers */,
+ DBFA7191187F1DA100A76262 /* fficonfig_x86_64.h in Headers */,
+ DBFA718E187F1DA100A76262 /* ffi_i386.h in Headers */,
+ DBFA7190187F1DA100A76262 /* fficonfig_i386.h in Headers */,
+ DBFA714B187F1D8600A76262 /* ffi_common.h in Headers */,
+ DBFA7193187F1DA100A76262 /* ffitarget_x86_64.h in Headers */,
+ DBFA7192187F1DA100A76262 /* ffitarget_i386.h in Headers */,
+ );
+ runOnlyForDeploymentPostprocessing = 0;
+ };
+/* End PBXHeadersBuildPhase section */
+
+/* Begin PBXNativeTarget section */
+ DB13B1651849DF1E0010F42D /* libffi-iOS */ = {
+ isa = PBXNativeTarget;
+ buildConfigurationList = DB13B18B1849DF1E0010F42D /* Build configuration list for PBXNativeTarget "libffi-iOS" */;
+ buildPhases = (
+ DB13B3051849E01C0010F42D /* ShellScript */,
+ DB13B1621849DF1E0010F42D /* Sources */,
+ DB13B1641849DF1E0010F42D /* CopyFiles */,
+ );
+ buildRules = (
+ );
+ dependencies = (
+ );
+ name = "libffi-iOS";
+ productName = ffi;
+ productReference = DB13B1661849DF1E0010F42D /* libffi.a */;
+ productType = "com.apple.product-type.library.static";
+ };
+ DB13B1901849DF510010F42D /* libffi-Mac */ = {
+ isa = PBXNativeTarget;
+ buildConfigurationList = DB13B1B01849DF520010F42D /* Build configuration list for PBXNativeTarget "libffi-Mac" */;
+ buildPhases = (
+ DB13B3061849E0490010F42D /* ShellScript */,
+ DB13B18D1849DF510010F42D /* Sources */,
+ DB13B18F1849DF510010F42D /* Headers */,
+ );
+ buildRules = (
+ );
+ dependencies = (
+ );
+ name = "libffi-Mac";
+ productName = ffi;
+ productReference = DB13B1911849DF510010F42D /* ffi.dylib */;
+ productType = "com.apple.product-type.library.dynamic";
+ };
+/* End PBXNativeTarget section */
+
+/* Begin PBXProject section */
+ DB13B15C1849DEB70010F42D /* Project object */ = {
+ isa = PBXProject;
+ attributes = {
+ LastUpgradeCheck = 0510;
+ };
+ buildConfigurationList = DB13B15F1849DEB70010F42D /* Build configuration list for PBXProject "libffi" */;
+ compatibilityVersion = "Xcode 3.2";
+ developmentRegion = English;
+ hasScannedForEncodings = 0;
+ knownRegions = (
+ en,
+ );
+ mainGroup = DB13B15B1849DEB70010F42D;
+ productRefGroup = DB13B1671849DF1E0010F42D /* Products */;
+ projectDirPath = "";
+ projectRoot = "";
+ targets = (
+ DB13B1651849DF1E0010F42D /* libffi-iOS */,
+ DB13B1901849DF510010F42D /* libffi-Mac */,
+ );
+ };
+/* End PBXProject section */
+
+/* Begin PBXShellScriptBuildPhase section */
+ DB13B3051849E01C0010F42D /* ShellScript */ = {
+ isa = PBXShellScriptBuildPhase;
+ buildActionMask = 2147483647;
+ files = (
+ );
+ inputPaths = (
+ );
+ outputPaths = (
+ );
+ runOnlyForDeploymentPostprocessing = 0;
+ shellPath = /bin/sh;
+ shellScript = "/usr/bin/python generate-darwin-source-and-headers.py --only-ios";
+ };
+ DB13B3061849E0490010F42D /* ShellScript */ = {
+ isa = PBXShellScriptBuildPhase;
+ buildActionMask = 2147483647;
+ files = (
+ );
+ inputPaths = (
+ );
+ outputPaths = (
+ );
+ runOnlyForDeploymentPostprocessing = 0;
+ shellPath = /bin/sh;
+ shellScript = "/usr/bin/python generate-darwin-source-and-headers.py --only-osx";
+ };
+/* End PBXShellScriptBuildPhase section */
+
+/* Begin PBXSourcesBuildPhase section */
+ DB13B1621849DF1E0010F42D /* Sources */ = {
+ isa = PBXSourcesBuildPhase;
+ buildActionMask = 2147483647;
+ files = (
+ DBFA717E187F1D9B00A76262 /* ffi64_x86_64.c in Sources */,
+ DBFA7179187F1D9B00A76262 /* ffi_armv7.c in Sources */,
+ DBFA717B187F1D9B00A76262 /* trampoline_armv7.S in Sources */,
+ DBFA714E187F1D8600A76262 /* closures.c in Sources */,
+ DBFA717A187F1D9B00A76262 /* sysv_armv7.S in Sources */,
+ DBFA717D187F1D9B00A76262 /* darwin_i386.S in Sources */,
+ DBFA7156187F1D8600A76262 /* prep_cif.c in Sources */,
+ DBFA717F187F1D9B00A76262 /* ffi_i386.c in Sources */,
+ DBFA7158187F1D8600A76262 /* raw_api.c in Sources */,
+ DBFA7178187F1D9B00A76262 /* sysv_arm64.S in Sources */,
+ DBFA717C187F1D9B00A76262 /* darwin64_x86_64.S in Sources */,
+ DBFA715A187F1D8600A76262 /* types.c in Sources */,
+ DBFA7177187F1D9B00A76262 /* ffi_arm64.c in Sources */,
+ );
+ runOnlyForDeploymentPostprocessing = 0;
+ };
+ DB13B18D1849DF510010F42D /* Sources */ = {
+ isa = PBXSourcesBuildPhase;
+ buildActionMask = 2147483647;
+ files = (
+ DBFA7196187F1DA100A76262 /* ffi64_x86_64.c in Sources */,
+ DBFA7195187F1DA100A76262 /* darwin_i386.S in Sources */,
+ DBFA7157187F1D8600A76262 /* prep_cif.c in Sources */,
+ DBFA7197187F1DA100A76262 /* ffi_i386.c in Sources */,
+ DBFA715B187F1D8600A76262 /* types.c in Sources */,
+ DBFA7159187F1D8600A76262 /* raw_api.c in Sources */,
+ DBFA714F187F1D8600A76262 /* closures.c in Sources */,
+ DBFA7194187F1DA100A76262 /* darwin64_x86_64.S in Sources */,
+ );
+ runOnlyForDeploymentPostprocessing = 0;
+ };
+/* End PBXSourcesBuildPhase section */
+
+/* Begin XCBuildConfiguration section */
+ DB13B1601849DEB70010F42D /* Debug */ = {
+ isa = XCBuildConfiguration;
+ buildSettings = {
+ HEADER_SEARCH_PATHS = (
+ "$(inherited)",
+ "darwin_common/include",
+ );
+ ONLY_ACTIVE_ARCH = YES;
+ };
+ name = Debug;
+ };
+ DB13B1611849DEB70010F42D /* Release */ = {
+ isa = XCBuildConfiguration;
+ buildSettings = {
+ HEADER_SEARCH_PATHS = (
+ "$(inherited)",
+ "darwin_common/include",
+ );
+ };
+ name = Release;
+ };
+ DB13B1871849DF1E0010F42D /* Debug */ = {
+ isa = XCBuildConfiguration;
+ buildSettings = {
+ ALWAYS_SEARCH_USER_PATHS = NO;
+ ARCHS = "$(ARCHS_STANDARD_INCLUDING_64_BIT)";
+ CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
+ CLANG_CXX_LIBRARY = "libc++";
+ CLANG_ENABLE_MODULES = YES;
+ CLANG_ENABLE_OBJC_ARC = YES;
+ CLANG_WARN_BOOL_CONVERSION = YES;
+ CLANG_WARN_CONSTANT_CONVERSION = YES;
+ CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
+ CLANG_WARN_EMPTY_BODY = YES;
+ CLANG_WARN_ENUM_CONVERSION = YES;
+ CLANG_WARN_INT_CONVERSION = YES;
+ CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
+ CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
+ COPY_PHASE_STRIP = NO;
+ DSTROOT = /tmp/ffi.dst;
+ GCC_C_LANGUAGE_STANDARD = gnu99;
+ GCC_DYNAMIC_NO_PIC = NO;
+ GCC_OPTIMIZATION_LEVEL = 0;
+ GCC_PREPROCESSOR_DEFINITIONS = (
+ "DEBUG=1",
+ "$(inherited)",
+ );
+ GCC_SYMBOLS_PRIVATE_EXTERN = NO;
+ GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
+ GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
+ GCC_WARN_UNDECLARED_SELECTOR = YES;
+ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
+ GCC_WARN_UNUSED_FUNCTION = YES;
+ GCC_WARN_UNUSED_VARIABLE = YES;
+ HEADER_SEARCH_PATHS = (
+ "$(inherited)",
+ "darwin_ios/include",
+ );
+ IPHONEOS_DEPLOYMENT_TARGET = 5.0;
+ "IPHONEOS_DEPLOYMENT_TARGET[arch=arm64]" = 7.0;
+ OTHER_LDFLAGS = "-ObjC";
+ PRODUCT_NAME = ffi;
+ SDKROOT = iphoneos;
+ SKIP_INSTALL = YES;
+ };
+ name = Debug;
+ };
+ DB13B1881849DF1E0010F42D /* Release */ = {
+ isa = XCBuildConfiguration;
+ buildSettings = {
+ ALWAYS_SEARCH_USER_PATHS = NO;
+ ARCHS = "$(ARCHS_STANDARD_INCLUDING_64_BIT)";
+ CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
+ CLANG_CXX_LIBRARY = "libc++";
+ CLANG_ENABLE_MODULES = YES;
+ CLANG_ENABLE_OBJC_ARC = YES;
+ CLANG_WARN_BOOL_CONVERSION = YES;
+ CLANG_WARN_CONSTANT_CONVERSION = YES;
+ CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
+ CLANG_WARN_EMPTY_BODY = YES;
+ CLANG_WARN_ENUM_CONVERSION = YES;
+ CLANG_WARN_INT_CONVERSION = YES;
+ CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
+ CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
+ COPY_PHASE_STRIP = YES;
+ DSTROOT = /tmp/ffi.dst;
+ ENABLE_NS_ASSERTIONS = NO;
+ GCC_C_LANGUAGE_STANDARD = gnu99;
+ GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
+ GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
+ GCC_WARN_UNDECLARED_SELECTOR = YES;
+ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
+ GCC_WARN_UNUSED_FUNCTION = YES;
+ GCC_WARN_UNUSED_VARIABLE = YES;
+ HEADER_SEARCH_PATHS = (
+ "$(inherited)",
+ "darwin_ios/include",
+ );
+ IPHONEOS_DEPLOYMENT_TARGET = 5.0;
+ "IPHONEOS_DEPLOYMENT_TARGET[arch=arm64]" = 7.0;
+ OTHER_LDFLAGS = "-ObjC";
+ PRODUCT_NAME = ffi;
+ SDKROOT = iphoneos;
+ SKIP_INSTALL = YES;
+ VALIDATE_PRODUCT = YES;
+ };
+ name = Release;
+ };
+ DB13B1B11849DF520010F42D /* Debug */ = {
+ isa = XCBuildConfiguration;
+ buildSettings = {
+ ALWAYS_SEARCH_USER_PATHS = NO;
+ CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
+ CLANG_CXX_LIBRARY = "libc++";
+ CLANG_ENABLE_OBJC_ARC = YES;
+ CLANG_WARN_BOOL_CONVERSION = YES;
+ CLANG_WARN_CONSTANT_CONVERSION = YES;
+ CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
+ CLANG_WARN_EMPTY_BODY = YES;
+ CLANG_WARN_ENUM_CONVERSION = YES;
+ CLANG_WARN_INT_CONVERSION = YES;
+ CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
+ CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
+ COPY_PHASE_STRIP = NO;
+ DYLIB_COMPATIBILITY_VERSION = 1;
+ DYLIB_CURRENT_VERSION = 1;
+ GCC_C_LANGUAGE_STANDARD = gnu99;
+ GCC_DYNAMIC_NO_PIC = NO;
+ GCC_ENABLE_OBJC_EXCEPTIONS = YES;
+ GCC_OPTIMIZATION_LEVEL = 0;
+ GCC_PREPROCESSOR_DEFINITIONS = (
+ "DEBUG=1",
+ "$(inherited)",
+ );
+ GCC_SYMBOLS_PRIVATE_EXTERN = NO;
+ GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
+ GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
+ GCC_WARN_UNDECLARED_SELECTOR = YES;
+ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
+ GCC_WARN_UNUSED_FUNCTION = YES;
+ GCC_WARN_UNUSED_VARIABLE = YES;
+ HEADER_SEARCH_PATHS = (
+ "$(inherited)",
+ "darwin_osx/include",
+ );
+ MACOSX_DEPLOYMENT_TARGET = 10.6;
+ ONLY_ACTIVE_ARCH = YES;
+ OTHER_LDFLAGS = "-Wl,-no_compact_unwind";
+ PRODUCT_NAME = ffi;
+ SDKROOT = macosx;
+ };
+ name = Debug;
+ };
+ DB13B1B21849DF520010F42D /* Release */ = {
+ isa = XCBuildConfiguration;
+ buildSettings = {
+ ALWAYS_SEARCH_USER_PATHS = NO;
+ CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
+ CLANG_CXX_LIBRARY = "libc++";
+ CLANG_ENABLE_OBJC_ARC = YES;
+ CLANG_WARN_BOOL_CONVERSION = YES;
+ CLANG_WARN_CONSTANT_CONVERSION = YES;
+ CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
+ CLANG_WARN_EMPTY_BODY = YES;
+ CLANG_WARN_ENUM_CONVERSION = YES;
+ CLANG_WARN_INT_CONVERSION = YES;
+ CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
+ CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
+ COPY_PHASE_STRIP = YES;
+ DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
+ DYLIB_COMPATIBILITY_VERSION = 1;
+ DYLIB_CURRENT_VERSION = 1;
+ ENABLE_NS_ASSERTIONS = NO;
+ GCC_C_LANGUAGE_STANDARD = gnu99;
+ GCC_ENABLE_OBJC_EXCEPTIONS = YES;
+ GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
+ GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
+ GCC_WARN_UNDECLARED_SELECTOR = YES;
+ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
+ GCC_WARN_UNUSED_FUNCTION = YES;
+ GCC_WARN_UNUSED_VARIABLE = YES;
+ HEADER_SEARCH_PATHS = (
+ "$(inherited)",
+ "darwin_osx/include",
+ );
+ MACOSX_DEPLOYMENT_TARGET = 10.6;
+ OTHER_LDFLAGS = "-Wl,-no_compact_unwind";
+ PRODUCT_NAME = ffi;
+ SDKROOT = macosx;
+ };
+ name = Release;
+ };
+/* End XCBuildConfiguration section */
+
+/* Begin XCConfigurationList section */
+ DB13B15F1849DEB70010F42D /* Build configuration list for PBXProject "libffi" */ = {
+ isa = XCConfigurationList;
+ buildConfigurations = (
+ DB13B1601849DEB70010F42D /* Debug */,
+ DB13B1611849DEB70010F42D /* Release */,
+ );
+ defaultConfigurationIsVisible = 0;
+ defaultConfigurationName = Release;
+ };
+ DB13B18B1849DF1E0010F42D /* Build configuration list for PBXNativeTarget "libffi-iOS" */ = {
+ isa = XCConfigurationList;
+ buildConfigurations = (
+ DB13B1871849DF1E0010F42D /* Debug */,
+ DB13B1881849DF1E0010F42D /* Release */,
+ );
+ defaultConfigurationIsVisible = 0;
+ defaultConfigurationName = Release;
+ };
+ DB13B1B01849DF520010F42D /* Build configuration list for PBXNativeTarget "libffi-Mac" */ = {
+ isa = XCConfigurationList;
+ buildConfigurations = (
+ DB13B1B11849DF520010F42D /* Debug */,
+ DB13B1B21849DF520010F42D /* Release */,
+ );
+ defaultConfigurationIsVisible = 0;
+ defaultConfigurationName = Release;
+ };
+/* End XCConfigurationList section */
+ };
+ rootObject = DB13B15C1849DEB70010F42D /* Project object */;
+}
diff --git a/jni/ruby/ext/fiddle/libffi-3.2.1/libtool-ldflags b/jni/ruby/ext/fiddle/libffi-3.2.1/libtool-ldflags
new file mode 100755
index 0000000..e32e37b
--- /dev/null
+++ b/jni/ruby/ext/fiddle/libffi-3.2.1/libtool-ldflags
@@ -0,0 +1,106 @@
+#! /bin/sh
+
+# Script to translate LDFLAGS into a form suitable for use with libtool.
+
+# Copyright (C) 2005 Free Software Foundation, Inc.
+#
+# This file is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+# MA 02110-1301, USA.
+
+# Contributed by CodeSourcery, LLC.
+
+# This script is designed to be used from a Makefile that uses libtool
+# to build libraries as follows:
+#
+# LTLDFLAGS = $(shell libtool-ldflags $(LDFLAGS))
+#
+# Then, use (LTLDFLAGS) in place of $(LDFLAGS) in your link line.
+
+# The output of the script. This string is built up as we process the
+# arguments.
+result=
+prev_arg=
+
+for arg
+do
+ case $arg in
+ -f*|--*)
+ # Libtool does not ascribe any special meaning options
+ # that begin with -f or with a double-dash. So, it will
+ # think these options are linker options, and prefix them
+ # with "-Wl,". Then, the compiler driver will ignore the
+ # options. So, we prefix these options with -Xcompiler to
+ # make clear to libtool that they are in fact compiler
+ # options.
+ case $prev_arg in
+ -Xpreprocessor|-Xcompiler|-Xlinker)
+ # This option is already prefixed; don't prefix it again.
+ ;;
+ *)
+ result="$result -Xcompiler"
+ ;;
+ esac
+ ;;
+ *)
+ # We do not want to add -Xcompiler to other options because
+ # that would prevent libtool itself from recognizing them.
+ ;;
+ esac
+ prev_arg=$arg
+
+ # If $(LDFLAGS) is (say):
+ # a "b'c d" e
+ # then the user expects that:
+ # $(LD) $(LDFLAGS)
+ # will pass three arguments to $(LD):
+ # 1) a
+ # 2) b'c d
+ # 3) e
+ # We must ensure, therefore, that the arguments are appropriately
+ # quoted so that using:
+ # libtool --mode=link ... $(LTLDFLAGS)
+ # will result in the same number of arguments being passed to
+ # libtool. In other words, when this script was invoked, the shell
+ # removed one level of quoting, present in $(LDFLAGS); we have to put
+ # it back.
+
+ # Quote any embedded single quotes.
+ case $arg in
+ *"'"*)
+ # The following command creates the script:
+ # 1s,^X,,;s|'|'"'"'|g
+ # which removes a leading X, and then quotes and embedded single
+ # quotes.
+ sed_script="1s,^X,,;s|'|'\"'\"'|g"
+ # Add a leading "X" so that if $arg starts with a dash,
+ # the echo command will not try to interpret the argument
+ # as a command-line option.
+ arg="X$arg"
+ # Generate the quoted string.
+ quoted_arg=`echo "$arg" | sed -e "$sed_script"`
+ ;;
+ *)
+ quoted_arg=$arg
+ ;;
+ esac
+ # Surround the entire argument with single quotes.
+ quoted_arg="'"$quoted_arg"'"
+
+ # Add it to the string.
+ result="$result $quoted_arg"
+done
+
+# Output the string we have built up.
+echo "$result"
diff --git a/jni/ruby/ext/fiddle/libffi-3.2.1/libtool-version b/jni/ruby/ext/fiddle/libffi-3.2.1/libtool-version
new file mode 100644
index 0000000..149a51a
--- /dev/null
+++ b/jni/ruby/ext/fiddle/libffi-3.2.1/libtool-version
@@ -0,0 +1,29 @@
+# This file is used to maintain libtool version info for libffi. See
+# the libtool manual to understand the meaning of the fields. This is
+# a separate file so that version updates don't involve re-running
+# automake.
+#
+# Here are a set of rules to help you update your library version
+# information:
+#
+# 1. Start with version information of `0:0:0' for each libtool library.
+#
+# 2. Update the version information only immediately before a public
+# release of your software. More frequent updates are unnecessary,
+# and only guarantee that the current interface number gets larger
+# faster.
+#
+# 3. If the library source code has changed at all since the last
+# update, then increment revision (`c:r:a' becomes `c:r+1:a').
+#
+# 4. If any interfaces have been added, removed, or changed since the
+# last update, increment current, and set revision to 0.
+#
+# 5. If any interfaces have been added since the last public release,
+# then increment age.
+#
+# 6. If any interfaces have been removed since the last public
+# release, then set age to 0.
+#
+# CURRENT:REVISION:AGE
+6:4:0
diff --git a/jni/ruby/ext/fiddle/libffi-3.2.1/ltmain.sh b/jni/ruby/ext/fiddle/libffi-3.2.1/ltmain.sh
new file mode 100644
index 0000000..63ae69d
--- /dev/null
+++ b/jni/ruby/ext/fiddle/libffi-3.2.1/ltmain.sh
@@ -0,0 +1,9655 @@
+
+# libtool (GNU libtool) 2.4.2
+# Written by Gordon Matzigkeit <gord@gnu.ai.mit.edu>, 1996
+
+# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005, 2006,
+# 2007, 2008, 2009, 2010, 2011 Free Software Foundation, Inc.
+# This is free software; see the source for copying conditions. There is NO
+# warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+
+# GNU Libtool is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# As a special exception to the GNU General Public License,
+# if you distribute this file as part of a program or library that
+# is built using GNU Libtool, you may include this file under the
+# same distribution terms that you use for the rest of that program.
+#
+# GNU Libtool is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with GNU Libtool; see the file COPYING. If not, a copy
+# can be downloaded from http://www.gnu.org/licenses/gpl.html,
+# or obtained by writing to the Free Software Foundation, Inc.,
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+# Usage: $progname [OPTION]... [MODE-ARG]...
+#
+# Provide generalized library-building support services.
+#
+# --config show all configuration variables
+# --debug enable verbose shell tracing
+# -n, --dry-run display commands without modifying any files
+# --features display basic configuration information and exit
+# --mode=MODE use operation mode MODE
+# --preserve-dup-deps don't remove duplicate dependency libraries
+# --quiet, --silent don't print informational messages
+# --no-quiet, --no-silent
+# print informational messages (default)
+# --no-warn don't display warning messages
+# --tag=TAG use configuration variables from tag TAG
+# -v, --verbose print more informational messages than default
+# --no-verbose don't print the extra informational messages
+# --version print version information
+# -h, --help, --help-all print short, long, or detailed help message
+#
+# MODE must be one of the following:
+#
+# clean remove files from the build directory
+# compile compile a source file into a libtool object
+# execute automatically set library path, then run a program
+# finish complete the installation of libtool libraries
+# install install libraries or executables
+# link create a library or an executable
+# uninstall remove libraries from an installed directory
+#
+# MODE-ARGS vary depending on the MODE. When passed as first option,
+# `--mode=MODE' may be abbreviated as `MODE' or a unique abbreviation of that.
+# Try `$progname --help --mode=MODE' for a more detailed description of MODE.
+#
+# When reporting a bug, please describe a test case to reproduce it and
+# include the following information:
+#
+# host-triplet: $host
+# shell: $SHELL
+# compiler: $LTCC
+# compiler flags: $LTCFLAGS
+# linker: $LD (gnu? $with_gnu_ld)
+# $progname: (GNU libtool) 2.4.2
+# automake: $automake_version
+# autoconf: $autoconf_version
+#
+# Report bugs to <bug-libtool@gnu.org>.
+# GNU libtool home page: <http://www.gnu.org/software/libtool/>.
+# General help using GNU software: <http://www.gnu.org/gethelp/>.
+
+PROGRAM=libtool
+PACKAGE=libtool
+VERSION=2.4.2
+TIMESTAMP=""
+package_revision=1.3337
+
+# Be Bourne compatible
+if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then
+ emulate sh
+ NULLCMD=:
+ # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which
+ # is contrary to our usage. Disable this feature.
+ alias -g '${1+"$@"}'='"$@"'
+ setopt NO_GLOB_SUBST
+else
+ case `(set -o) 2>/dev/null` in *posix*) set -o posix;; esac
+fi
+BIN_SH=xpg4; export BIN_SH # for Tru64
+DUALCASE=1; export DUALCASE # for MKS sh
+
+# A function that is used when there is no print builtin or printf.
+func_fallback_echo ()
+{
+ eval 'cat <<_LTECHO_EOF
+$1
+_LTECHO_EOF'
+}
+
+# NLS nuisances: We save the old values to restore during execute mode.
+lt_user_locale=
+lt_safe_locale=
+for lt_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES
+do
+ eval "if test \"\${$lt_var+set}\" = set; then
+ save_$lt_var=\$$lt_var
+ $lt_var=C
+ export $lt_var
+ lt_user_locale=\"$lt_var=\\\$save_\$lt_var; \$lt_user_locale\"
+ lt_safe_locale=\"$lt_var=C; \$lt_safe_locale\"
+ fi"
+done
+LC_ALL=C
+LANGUAGE=C
+export LANGUAGE LC_ALL
+
+$lt_unset CDPATH
+
+
+# Work around backward compatibility issue on IRIX 6.5. On IRIX 6.4+, sh
+# is ksh but when the shell is invoked as "sh" and the current value of
+# the _XPG environment variable is not equal to 1 (one), the special
+# positional parameter $0, within a function call, is the name of the
+# function.
+progpath="$0"
+
+
+
+: ${CP="cp -f"}
+test "${ECHO+set}" = set || ECHO=${as_echo-'printf %s\n'}
+: ${MAKE="make"}
+: ${MKDIR="mkdir"}
+: ${MV="mv -f"}
+: ${RM="rm -f"}
+: ${SHELL="${CONFIG_SHELL-/bin/sh}"}
+: ${Xsed="$SED -e 1s/^X//"}
+
+# Global variables:
+EXIT_SUCCESS=0
+EXIT_FAILURE=1
+EXIT_MISMATCH=63 # $? = 63 is used to indicate version mismatch to missing.
+EXIT_SKIP=77 # $? = 77 is used to indicate a skipped test to automake.
+
+exit_status=$EXIT_SUCCESS
+
+# Make sure IFS has a sensible default
+lt_nl='
+'
+IFS=" $lt_nl"
+
+dirname="s,/[^/]*$,,"
+basename="s,^.*/,,"
+
+# func_dirname file append nondir_replacement
+# Compute the dirname of FILE. If nonempty, add APPEND to the result,
+# otherwise set result to NONDIR_REPLACEMENT.
+func_dirname ()
+{
+ func_dirname_result=`$ECHO "${1}" | $SED "$dirname"`
+ if test "X$func_dirname_result" = "X${1}"; then
+ func_dirname_result="${3}"
+ else
+ func_dirname_result="$func_dirname_result${2}"
+ fi
+} # func_dirname may be replaced by extended shell implementation
+
+
+# func_basename file
+func_basename ()
+{
+ func_basename_result=`$ECHO "${1}" | $SED "$basename"`
+} # func_basename may be replaced by extended shell implementation
+
+
+# func_dirname_and_basename file append nondir_replacement
+# perform func_basename and func_dirname in a single function
+# call:
+# dirname: Compute the dirname of FILE. If nonempty,
+# add APPEND to the result, otherwise set result
+# to NONDIR_REPLACEMENT.
+# value returned in "$func_dirname_result"
+# basename: Compute filename of FILE.
+# value retuned in "$func_basename_result"
+# Implementation must be kept synchronized with func_dirname
+# and func_basename. For efficiency, we do not delegate to
+# those functions but instead duplicate the functionality here.
+func_dirname_and_basename ()
+{
+ # Extract subdirectory from the argument.
+ func_dirname_result=`$ECHO "${1}" | $SED -e "$dirname"`
+ if test "X$func_dirname_result" = "X${1}"; then
+ func_dirname_result="${3}"
+ else
+ func_dirname_result="$func_dirname_result${2}"
+ fi
+ func_basename_result=`$ECHO "${1}" | $SED -e "$basename"`
+} # func_dirname_and_basename may be replaced by extended shell implementation
+
+
+# func_stripname prefix suffix name
+# strip PREFIX and SUFFIX off of NAME.
+# PREFIX and SUFFIX must not contain globbing or regex special
+# characters, hashes, percent signs, but SUFFIX may contain a leading
+# dot (in which case that matches only a dot).
+# func_strip_suffix prefix name
+func_stripname ()
+{
+ case ${2} in
+ .*) func_stripname_result=`$ECHO "${3}" | $SED "s%^${1}%%; s%\\\\${2}\$%%"`;;
+ *) func_stripname_result=`$ECHO "${3}" | $SED "s%^${1}%%; s%${2}\$%%"`;;
+ esac
+} # func_stripname may be replaced by extended shell implementation
+
+
+# These SED scripts presuppose an absolute path with a trailing slash.
+pathcar='s,^/\([^/]*\).*$,\1,'
+pathcdr='s,^/[^/]*,,'
+removedotparts=':dotsl
+ s@/\./@/@g
+ t dotsl
+ s,/\.$,/,'
+collapseslashes='s@/\{1,\}@/@g'
+finalslash='s,/*$,/,'
+
+# func_normal_abspath PATH
+# Remove doubled-up and trailing slashes, "." path components,
+# and cancel out any ".." path components in PATH after making
+# it an absolute path.
+# value returned in "$func_normal_abspath_result"
+func_normal_abspath ()
+{
+ # Start from root dir and reassemble the path.
+ func_normal_abspath_result=
+ func_normal_abspath_tpath=$1
+ func_normal_abspath_altnamespace=
+ case $func_normal_abspath_tpath in
+ "")
+ # Empty path, that just means $cwd.
+ func_stripname '' '/' "`pwd`"
+ func_normal_abspath_result=$func_stripname_result
+ return
+ ;;
+ # The next three entries are used to spot a run of precisely
+ # two leading slashes without using negated character classes;
+ # we take advantage of case's first-match behaviour.
+ ///*)
+ # Unusual form of absolute path, do nothing.
+ ;;
+ //*)
+ # Not necessarily an ordinary path; POSIX reserves leading '//'
+ # and for example Cygwin uses it to access remote file shares
+ # over CIFS/SMB, so we conserve a leading double slash if found.
+ func_normal_abspath_altnamespace=/
+ ;;
+ /*)
+ # Absolute path, do nothing.
+ ;;
+ *)
+ # Relative path, prepend $cwd.
+ func_normal_abspath_tpath=`pwd`/$func_normal_abspath_tpath
+ ;;
+ esac
+ # Cancel out all the simple stuff to save iterations. We also want
+ # the path to end with a slash for ease of parsing, so make sure
+ # there is one (and only one) here.
+ func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \
+ -e "$removedotparts" -e "$collapseslashes" -e "$finalslash"`
+ while :; do
+ # Processed it all yet?
+ if test "$func_normal_abspath_tpath" = / ; then
+ # If we ascended to the root using ".." the result may be empty now.
+ if test -z "$func_normal_abspath_result" ; then
+ func_normal_abspath_result=/
+ fi
+ break
+ fi
+ func_normal_abspath_tcomponent=`$ECHO "$func_normal_abspath_tpath" | $SED \
+ -e "$pathcar"`
+ func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \
+ -e "$pathcdr"`
+ # Figure out what to do with it
+ case $func_normal_abspath_tcomponent in
+ "")
+ # Trailing empty path component, ignore it.
+ ;;
+ ..)
+ # Parent dir; strip last assembled component from result.
+ func_dirname "$func_normal_abspath_result"
+ func_normal_abspath_result=$func_dirname_result
+ ;;
+ *)
+ # Actual path component, append it.
+ func_normal_abspath_result=$func_normal_abspath_result/$func_normal_abspath_tcomponent
+ ;;
+ esac
+ done
+ # Restore leading double-slash if one was found on entry.
+ func_normal_abspath_result=$func_normal_abspath_altnamespace$func_normal_abspath_result
+}
+
+# func_relative_path SRCDIR DSTDIR
+# generates a relative path from SRCDIR to DSTDIR, with a trailing
+# slash if non-empty, suitable for immediately appending a filename
+# without needing to append a separator.
+# value returned in "$func_relative_path_result"
+func_relative_path ()
+{
+ func_relative_path_result=
+ func_normal_abspath "$1"
+ func_relative_path_tlibdir=$func_normal_abspath_result
+ func_normal_abspath "$2"
+ func_relative_path_tbindir=$func_normal_abspath_result
+
+ # Ascend the tree starting from libdir
+ while :; do
+ # check if we have found a prefix of bindir
+ case $func_relative_path_tbindir in
+ $func_relative_path_tlibdir)
+ # found an exact match
+ func_relative_path_tcancelled=
+ break
+ ;;
+ $func_relative_path_tlibdir*)
+ # found a matching prefix
+ func_stripname "$func_relative_path_tlibdir" '' "$func_relative_path_tbindir"
+ func_relative_path_tcancelled=$func_stripname_result
+ if test -z "$func_relative_path_result"; then
+ func_relative_path_result=.
+ fi
+ break
+ ;;
+ *)
+ func_dirname $func_relative_path_tlibdir
+ func_relative_path_tlibdir=${func_dirname_result}
+ if test "x$func_relative_path_tlibdir" = x ; then
+ # Have to descend all the way to the root!
+ func_relative_path_result=../$func_relative_path_result
+ func_relative_path_tcancelled=$func_relative_path_tbindir
+ break
+ fi
+ func_relative_path_result=../$func_relative_path_result
+ ;;
+ esac
+ done
+
+ # Now calculate path; take care to avoid doubling-up slashes.
+ func_stripname '' '/' "$func_relative_path_result"
+ func_relative_path_result=$func_stripname_result
+ func_stripname '/' '/' "$func_relative_path_tcancelled"
+ if test "x$func_stripname_result" != x ; then
+ func_relative_path_result=${func_relative_path_result}/${func_stripname_result}
+ fi
+
+ # Normalisation. If bindir is libdir, return empty string,
+ # else relative path ending with a slash; either way, target
+ # file name can be directly appended.
+ if test ! -z "$func_relative_path_result"; then
+ func_stripname './' '' "$func_relative_path_result/"
+ func_relative_path_result=$func_stripname_result
+ fi
+}
+
+# The name of this program:
+func_dirname_and_basename "$progpath"
+progname=$func_basename_result
+
+# Make sure we have an absolute path for reexecution:
+case $progpath in
+ [\\/]*|[A-Za-z]:\\*) ;;
+ *[\\/]*)
+ progdir=$func_dirname_result
+ progdir=`cd "$progdir" && pwd`
+ progpath="$progdir/$progname"
+ ;;
+ *)
+ save_IFS="$IFS"
+ IFS=${PATH_SEPARATOR-:}
+ for progdir in $PATH; do
+ IFS="$save_IFS"
+ test -x "$progdir/$progname" && break
+ done
+ IFS="$save_IFS"
+ test -n "$progdir" || progdir=`pwd`
+ progpath="$progdir/$progname"
+ ;;
+esac
+
+# Sed substitution that helps us do robust quoting. It backslashifies
+# metacharacters that are still active within double-quoted strings.
+Xsed="${SED}"' -e 1s/^X//'
+sed_quote_subst='s/\([`"$\\]\)/\\\1/g'
+
+# Same as above, but do not quote variable references.
+double_quote_subst='s/\(["`\\]\)/\\\1/g'
+
+# Sed substitution that turns a string into a regex matching for the
+# string literally.
+sed_make_literal_regex='s,[].[^$\\*\/],\\&,g'
+
+# Sed substitution that converts a w32 file name or path
+# which contains forward slashes, into one that contains
+# (escaped) backslashes. A very naive implementation.
+lt_sed_naive_backslashify='s|\\\\*|\\|g;s|/|\\|g;s|\\|\\\\|g'
+
+# Re-`\' parameter expansions in output of double_quote_subst that were
+# `\'-ed in input to the same. If an odd number of `\' preceded a '$'
+# in input to double_quote_subst, that '$' was protected from expansion.
+# Since each input `\' is now two `\'s, look for any number of runs of
+# four `\'s followed by two `\'s and then a '$'. `\' that '$'.
+bs='\\'
+bs2='\\\\'
+bs4='\\\\\\\\'
+dollar='\$'
+sed_double_backslash="\
+ s/$bs4/&\\
+/g
+ s/^$bs2$dollar/$bs&/
+ s/\\([^$bs]\\)$bs2$dollar/\\1$bs2$bs$dollar/g
+ s/\n//g"
+
+# Standard options:
+opt_dry_run=false
+opt_help=false
+opt_quiet=false
+opt_verbose=false
+opt_warning=:
+
+# func_echo arg...
+# Echo program name prefixed message, along with the current mode
+# name if it has been set yet.
+func_echo ()
+{
+ $ECHO "$progname: ${opt_mode+$opt_mode: }$*"
+}
+
+# func_verbose arg...
+# Echo program name prefixed message in verbose mode only.
+func_verbose ()
+{
+ $opt_verbose && func_echo ${1+"$@"}
+
+ # A bug in bash halts the script if the last line of a function
+ # fails when set -e is in force, so we need another command to
+ # work around that:
+ :
+}
+
+# func_echo_all arg...
+# Invoke $ECHO with all args, space-separated.
+func_echo_all ()
+{
+ $ECHO "$*"
+}
+
+# func_error arg...
+# Echo program name prefixed message to standard error.
+func_error ()
+{
+ $ECHO "$progname: ${opt_mode+$opt_mode: }"${1+"$@"} 1>&2
+}
+
+# func_warning arg...
+# Echo program name prefixed warning message to standard error.
+func_warning ()
+{
+ $opt_warning && $ECHO "$progname: ${opt_mode+$opt_mode: }warning: "${1+"$@"} 1>&2
+
+ # bash bug again:
+ :
+}
+
+# func_fatal_error arg...
+# Echo program name prefixed message to standard error, and exit.
+func_fatal_error ()
+{
+ func_error ${1+"$@"}
+ exit $EXIT_FAILURE
+}
+
+# func_fatal_help arg...
+# Echo program name prefixed message to standard error, followed by
+# a help hint, and exit.
+func_fatal_help ()
+{
+ func_error ${1+"$@"}
+ func_fatal_error "$help"
+}
+help="Try \`$progname --help' for more information." ## default
+
+
+# func_grep expression filename
+# Check whether EXPRESSION matches any line of FILENAME, without output.
+func_grep ()
+{
+ $GREP "$1" "$2" >/dev/null 2>&1
+}
+
+
+# func_mkdir_p directory-path
+# Make sure the entire path to DIRECTORY-PATH is available.
+func_mkdir_p ()
+{
+ my_directory_path="$1"
+ my_dir_list=
+
+ if test -n "$my_directory_path" && test "$opt_dry_run" != ":"; then
+
+ # Protect directory names starting with `-'
+ case $my_directory_path in
+ -*) my_directory_path="./$my_directory_path" ;;
+ esac
+
+ # While some portion of DIR does not yet exist...
+ while test ! -d "$my_directory_path"; do
+ # ...make a list in topmost first order. Use a colon delimited
+ # list incase some portion of path contains whitespace.
+ my_dir_list="$my_directory_path:$my_dir_list"
+
+ # If the last portion added has no slash in it, the list is done
+ case $my_directory_path in */*) ;; *) break ;; esac
+
+ # ...otherwise throw away the child directory and loop
+ my_directory_path=`$ECHO "$my_directory_path" | $SED -e "$dirname"`
+ done
+ my_dir_list=`$ECHO "$my_dir_list" | $SED 's,:*$,,'`
+
+ save_mkdir_p_IFS="$IFS"; IFS=':'
+ for my_dir in $my_dir_list; do
+ IFS="$save_mkdir_p_IFS"
+ # mkdir can fail with a `File exist' error if two processes
+ # try to create one of the directories concurrently. Don't
+ # stop in that case!
+ $MKDIR "$my_dir" 2>/dev/null || :
+ done
+ IFS="$save_mkdir_p_IFS"
+
+ # Bail out if we (or some other process) failed to create a directory.
+ test -d "$my_directory_path" || \
+ func_fatal_error "Failed to create \`$1'"
+ fi
+}
+
+
+# func_mktempdir [string]
+# Make a temporary directory that won't clash with other running
+# libtool processes, and avoids race conditions if possible. If
+# given, STRING is the basename for that directory.
+func_mktempdir ()
+{
+ my_template="${TMPDIR-/tmp}/${1-$progname}"
+
+ if test "$opt_dry_run" = ":"; then
+ # Return a directory name, but don't create it in dry-run mode
+ my_tmpdir="${my_template}-$$"
+ else
+
+ # If mktemp works, use that first and foremost
+ my_tmpdir=`mktemp -d "${my_template}-XXXXXXXX" 2>/dev/null`
+
+ if test ! -d "$my_tmpdir"; then
+ # Failing that, at least try and use $RANDOM to avoid a race
+ my_tmpdir="${my_template}-${RANDOM-0}$$"
+
+ save_mktempdir_umask=`umask`
+ umask 0077
+ $MKDIR "$my_tmpdir"
+ umask $save_mktempdir_umask
+ fi
+
+ # If we're not in dry-run mode, bomb out on failure
+ test -d "$my_tmpdir" || \
+ func_fatal_error "cannot create temporary directory \`$my_tmpdir'"
+ fi
+
+ $ECHO "$my_tmpdir"
+}
+
+
+# func_quote_for_eval arg
+# Aesthetically quote ARG to be evaled later.
+# This function returns two values: FUNC_QUOTE_FOR_EVAL_RESULT
+# is double-quoted, suitable for a subsequent eval, whereas
+# FUNC_QUOTE_FOR_EVAL_UNQUOTED_RESULT has merely all characters
+# which are still active within double quotes backslashified.
+func_quote_for_eval ()
+{
+ case $1 in
+ *[\\\`\"\$]*)
+ func_quote_for_eval_unquoted_result=`$ECHO "$1" | $SED "$sed_quote_subst"` ;;
+ *)
+ func_quote_for_eval_unquoted_result="$1" ;;
+ esac
+
+ case $func_quote_for_eval_unquoted_result in
+ # Double-quote args containing shell metacharacters to delay
+ # word splitting, command substitution and and variable
+ # expansion for a subsequent eval.
+ # Many Bourne shells cannot handle close brackets correctly
+ # in scan sets, so we specify it separately.
+ *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"")
+ func_quote_for_eval_result="\"$func_quote_for_eval_unquoted_result\""
+ ;;
+ *)
+ func_quote_for_eval_result="$func_quote_for_eval_unquoted_result"
+ esac
+}
+
+
+# func_quote_for_expand arg
+# Aesthetically quote ARG to be evaled later; same as above,
+# but do not quote variable references.
+func_quote_for_expand ()
+{
+ case $1 in
+ *[\\\`\"]*)
+ my_arg=`$ECHO "$1" | $SED \
+ -e "$double_quote_subst" -e "$sed_double_backslash"` ;;
+ *)
+ my_arg="$1" ;;
+ esac
+
+ case $my_arg in
+ # Double-quote args containing shell metacharacters to delay
+ # word splitting and command substitution for a subsequent eval.
+ # Many Bourne shells cannot handle close brackets correctly
+ # in scan sets, so we specify it separately.
+ *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"")
+ my_arg="\"$my_arg\""
+ ;;
+ esac
+
+ func_quote_for_expand_result="$my_arg"
+}
+
+
+# func_show_eval cmd [fail_exp]
+# Unless opt_silent is true, then output CMD. Then, if opt_dryrun is
+# not true, evaluate CMD. If the evaluation of CMD fails, and FAIL_EXP
+# is given, then evaluate it.
+func_show_eval ()
+{
+ my_cmd="$1"
+ my_fail_exp="${2-:}"
+
+ ${opt_silent-false} || {
+ func_quote_for_expand "$my_cmd"
+ eval "func_echo $func_quote_for_expand_result"
+ }
+
+ if ${opt_dry_run-false}; then :; else
+ eval "$my_cmd"
+ my_status=$?
+ if test "$my_status" -eq 0; then :; else
+ eval "(exit $my_status); $my_fail_exp"
+ fi
+ fi
+}
+
+
+# func_show_eval_locale cmd [fail_exp]
+# Unless opt_silent is true, then output CMD. Then, if opt_dryrun is
+# not true, evaluate CMD. If the evaluation of CMD fails, and FAIL_EXP
+# is given, then evaluate it. Use the saved locale for evaluation.
+func_show_eval_locale ()
+{
+ my_cmd="$1"
+ my_fail_exp="${2-:}"
+
+ ${opt_silent-false} || {
+ func_quote_for_expand "$my_cmd"
+ eval "func_echo $func_quote_for_expand_result"
+ }
+
+ if ${opt_dry_run-false}; then :; else
+ eval "$lt_user_locale
+ $my_cmd"
+ my_status=$?
+ eval "$lt_safe_locale"
+ if test "$my_status" -eq 0; then :; else
+ eval "(exit $my_status); $my_fail_exp"
+ fi
+ fi
+}
+
+# func_tr_sh
+# Turn $1 into a string suitable for a shell variable name.
+# Result is stored in $func_tr_sh_result. All characters
+# not in the set a-zA-Z0-9_ are replaced with '_'. Further,
+# if $1 begins with a digit, a '_' is prepended as well.
+func_tr_sh ()
+{
+ case $1 in
+ [0-9]* | *[!a-zA-Z0-9_]*)
+ func_tr_sh_result=`$ECHO "$1" | $SED 's/^\([0-9]\)/_\1/; s/[^a-zA-Z0-9_]/_/g'`
+ ;;
+ * )
+ func_tr_sh_result=$1
+ ;;
+ esac
+}
+
+
+# func_version
+# Echo version message to standard output and exit.
+func_version ()
+{
+ $opt_debug
+
+ $SED -n '/(C)/!b go
+ :more
+ /\./!{
+ N
+ s/\n# / /
+ b more
+ }
+ :go
+ /^# '$PROGRAM' (GNU /,/# warranty; / {
+ s/^# //
+ s/^# *$//
+ s/\((C)\)[ 0-9,-]*\( [1-9][0-9]*\)/\1\2/
+ p
+ }' < "$progpath"
+ exit $?
+}
+
+# func_usage
+# Echo short help message to standard output and exit.
+func_usage ()
+{
+ $opt_debug
+
+ $SED -n '/^# Usage:/,/^# *.*--help/ {
+ s/^# //
+ s/^# *$//
+ s/\$progname/'$progname'/
+ p
+ }' < "$progpath"
+ echo
+ $ECHO "run \`$progname --help | more' for full usage"
+ exit $?
+}
+
+# func_help [NOEXIT]
+# Echo long help message to standard output and exit,
+# unless 'noexit' is passed as argument.
+func_help ()
+{
+ $opt_debug
+
+ $SED -n '/^# Usage:/,/# Report bugs to/ {
+ :print
+ s/^# //
+ s/^# *$//
+ s*\$progname*'$progname'*
+ s*\$host*'"$host"'*
+ s*\$SHELL*'"$SHELL"'*
+ s*\$LTCC*'"$LTCC"'*
+ s*\$LTCFLAGS*'"$LTCFLAGS"'*
+ s*\$LD*'"$LD"'*
+ s/\$with_gnu_ld/'"$with_gnu_ld"'/
+ s/\$automake_version/'"`(${AUTOMAKE-automake} --version) 2>/dev/null |$SED 1q`"'/
+ s/\$autoconf_version/'"`(${AUTOCONF-autoconf} --version) 2>/dev/null |$SED 1q`"'/
+ p
+ d
+ }
+ /^# .* home page:/b print
+ /^# General help using/b print
+ ' < "$progpath"
+ ret=$?
+ if test -z "$1"; then
+ exit $ret
+ fi
+}
+
+# func_missing_arg argname
+# Echo program name prefixed message to standard error and set global
+# exit_cmd.
+func_missing_arg ()
+{
+ $opt_debug
+
+ func_error "missing argument for $1."
+ exit_cmd=exit
+}
+
+
+# func_split_short_opt shortopt
+# Set func_split_short_opt_name and func_split_short_opt_arg shell
+# variables after splitting SHORTOPT after the 2nd character.
+func_split_short_opt ()
+{
+ my_sed_short_opt='1s/^\(..\).*$/\1/;q'
+ my_sed_short_rest='1s/^..\(.*\)$/\1/;q'
+
+ func_split_short_opt_name=`$ECHO "$1" | $SED "$my_sed_short_opt"`
+ func_split_short_opt_arg=`$ECHO "$1" | $SED "$my_sed_short_rest"`
+} # func_split_short_opt may be replaced by extended shell implementation
+
+
+# func_split_long_opt longopt
+# Set func_split_long_opt_name and func_split_long_opt_arg shell
+# variables after splitting LONGOPT at the `=' sign.
+func_split_long_opt ()
+{
+ my_sed_long_opt='1s/^\(--[^=]*\)=.*/\1/;q'
+ my_sed_long_arg='1s/^--[^=]*=//'
+
+ func_split_long_opt_name=`$ECHO "$1" | $SED "$my_sed_long_opt"`
+ func_split_long_opt_arg=`$ECHO "$1" | $SED "$my_sed_long_arg"`
+} # func_split_long_opt may be replaced by extended shell implementation
+
+exit_cmd=:
+
+
+
+
+
+magic="%%%MAGIC variable%%%"
+magic_exe="%%%MAGIC EXE variable%%%"
+
+# Global variables.
+nonopt=
+preserve_args=
+lo2o="s/\\.lo\$/.${objext}/"
+o2lo="s/\\.${objext}\$/.lo/"
+extracted_archives=
+extracted_serial=0
+
+# If this variable is set in any of the actions, the command in it
+# will be execed at the end. This prevents here-documents from being
+# left over by shells.
+exec_cmd=
+
+# func_append var value
+# Append VALUE to the end of shell variable VAR.
+func_append ()
+{
+ eval "${1}=\$${1}\${2}"
+} # func_append may be replaced by extended shell implementation
+
+# func_append_quoted var value
+# Quote VALUE and append to the end of shell variable VAR, separated
+# by a space.
+func_append_quoted ()
+{
+ func_quote_for_eval "${2}"
+ eval "${1}=\$${1}\\ \$func_quote_for_eval_result"
+} # func_append_quoted may be replaced by extended shell implementation
+
+
+# func_arith arithmetic-term...
+func_arith ()
+{
+ func_arith_result=`expr "${@}"`
+} # func_arith may be replaced by extended shell implementation
+
+
+# func_len string
+# STRING may not start with a hyphen.
+func_len ()
+{
+ func_len_result=`expr "${1}" : ".*" 2>/dev/null || echo $max_cmd_len`
+} # func_len may be replaced by extended shell implementation
+
+
+# func_lo2o object
+func_lo2o ()
+{
+ func_lo2o_result=`$ECHO "${1}" | $SED "$lo2o"`
+} # func_lo2o may be replaced by extended shell implementation
+
+
+# func_xform libobj-or-source
+func_xform ()
+{
+ func_xform_result=`$ECHO "${1}" | $SED 's/\.[^.]*$/.lo/'`
+} # func_xform may be replaced by extended shell implementation
+
+
+# func_fatal_configuration arg...
+# Echo program name prefixed message to standard error, followed by
+# a configuration failure hint, and exit.
+func_fatal_configuration ()
+{
+ func_error ${1+"$@"}
+ func_error "See the $PACKAGE documentation for more information."
+ func_fatal_error "Fatal configuration error."
+}
+
+
+# func_config
+# Display the configuration for all the tags in this script.
+func_config ()
+{
+ re_begincf='^# ### BEGIN LIBTOOL'
+ re_endcf='^# ### END LIBTOOL'
+
+ # Default configuration.
+ $SED "1,/$re_begincf CONFIG/d;/$re_endcf CONFIG/,\$d" < "$progpath"
+
+ # Now print the configurations for the tags.
+ for tagname in $taglist; do
+ $SED -n "/$re_begincf TAG CONFIG: $tagname\$/,/$re_endcf TAG CONFIG: $tagname\$/p" < "$progpath"
+ done
+
+ exit $?
+}
+
+# func_features
+# Display the features supported by this script.
+func_features ()
+{
+ echo "host: $host"
+ if test "$build_libtool_libs" = yes; then
+ echo "enable shared libraries"
+ else
+ echo "disable shared libraries"
+ fi
+ if test "$build_old_libs" = yes; then
+ echo "enable static libraries"
+ else
+ echo "disable static libraries"
+ fi
+
+ exit $?
+}
+
+# func_enable_tag tagname
+# Verify that TAGNAME is valid, and either flag an error and exit, or
+# enable the TAGNAME tag. We also add TAGNAME to the global $taglist
+# variable here.
+func_enable_tag ()
+{
+ # Global variable:
+ tagname="$1"
+
+ re_begincf="^# ### BEGIN LIBTOOL TAG CONFIG: $tagname\$"
+ re_endcf="^# ### END LIBTOOL TAG CONFIG: $tagname\$"
+ sed_extractcf="/$re_begincf/,/$re_endcf/p"
+
+ # Validate tagname.
+ case $tagname in
+ *[!-_A-Za-z0-9,/]*)
+ func_fatal_error "invalid tag name: $tagname"
+ ;;
+ esac
+
+ # Don't test for the "default" C tag, as we know it's
+ # there but not specially marked.
+ case $tagname in
+ CC) ;;
+ *)
+ if $GREP "$re_begincf" "$progpath" >/dev/null 2>&1; then
+ taglist="$taglist $tagname"
+
+ # Evaluate the configuration. Be careful to quote the path
+ # and the sed script, to avoid splitting on whitespace, but
+ # also don't use non-portable quotes within backquotes within
+ # quotes we have to do it in 2 steps:
+ extractedcf=`$SED -n -e "$sed_extractcf" < "$progpath"`
+ eval "$extractedcf"
+ else
+ func_error "ignoring unknown tag $tagname"
+ fi
+ ;;
+ esac
+}
+
+# func_check_version_match
+# Ensure that we are using m4 macros, and libtool script from the same
+# release of libtool.
+func_check_version_match ()
+{
+ if test "$package_revision" != "$macro_revision"; then
+ if test "$VERSION" != "$macro_version"; then
+ if test -z "$macro_version"; then
+ cat >&2 <<_LT_EOF
+$progname: Version mismatch error. This is $PACKAGE $VERSION, but the
+$progname: definition of this LT_INIT comes from an older release.
+$progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION
+$progname: and run autoconf again.
+_LT_EOF
+ else
+ cat >&2 <<_LT_EOF
+$progname: Version mismatch error. This is $PACKAGE $VERSION, but the
+$progname: definition of this LT_INIT comes from $PACKAGE $macro_version.
+$progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION
+$progname: and run autoconf again.
+_LT_EOF
+ fi
+ else
+ cat >&2 <<_LT_EOF
+$progname: Version mismatch error. This is $PACKAGE $VERSION, revision $package_revision,
+$progname: but the definition of this LT_INIT comes from revision $macro_revision.
+$progname: You should recreate aclocal.m4 with macros from revision $package_revision
+$progname: of $PACKAGE $VERSION and run autoconf again.
+_LT_EOF
+ fi
+
+ exit $EXIT_MISMATCH
+ fi
+}
+
+
+# Shorthand for --mode=foo, only valid as the first argument
+case $1 in
+clean|clea|cle|cl)
+ shift; set dummy --mode clean ${1+"$@"}; shift
+ ;;
+compile|compil|compi|comp|com|co|c)
+ shift; set dummy --mode compile ${1+"$@"}; shift
+ ;;
+execute|execut|execu|exec|exe|ex|e)
+ shift; set dummy --mode execute ${1+"$@"}; shift
+ ;;
+finish|finis|fini|fin|fi|f)
+ shift; set dummy --mode finish ${1+"$@"}; shift
+ ;;
+install|instal|insta|inst|ins|in|i)
+ shift; set dummy --mode install ${1+"$@"}; shift
+ ;;
+link|lin|li|l)
+ shift; set dummy --mode link ${1+"$@"}; shift
+ ;;
+uninstall|uninstal|uninsta|uninst|unins|unin|uni|un|u)
+ shift; set dummy --mode uninstall ${1+"$@"}; shift
+ ;;
+esac
+
+
+
+# Option defaults:
+opt_debug=:
+opt_dry_run=false
+opt_config=false
+opt_preserve_dup_deps=false
+opt_features=false
+opt_finish=false
+opt_help=false
+opt_help_all=false
+opt_silent=:
+opt_warning=:
+opt_verbose=:
+opt_silent=false
+opt_verbose=false
+
+
+# Parse options once, thoroughly. This comes as soon as possible in the
+# script to make things like `--version' happen as quickly as we can.
+{
+ # this just eases exit handling
+ while test $# -gt 0; do
+ opt="$1"
+ shift
+ case $opt in
+ --debug|-x) opt_debug='set -x'
+ func_echo "enabling shell trace mode"
+ $opt_debug
+ ;;
+ --dry-run|--dryrun|-n)
+ opt_dry_run=:
+ ;;
+ --config)
+ opt_config=:
+func_config
+ ;;
+ --dlopen|-dlopen)
+ optarg="$1"
+ opt_dlopen="${opt_dlopen+$opt_dlopen
+}$optarg"
+ shift
+ ;;
+ --preserve-dup-deps)
+ opt_preserve_dup_deps=:
+ ;;
+ --features)
+ opt_features=:
+func_features
+ ;;
+ --finish)
+ opt_finish=:
+set dummy --mode finish ${1+"$@"}; shift
+ ;;
+ --help)
+ opt_help=:
+ ;;
+ --help-all)
+ opt_help_all=:
+opt_help=': help-all'
+ ;;
+ --mode)
+ test $# = 0 && func_missing_arg $opt && break
+ optarg="$1"
+ opt_mode="$optarg"
+case $optarg in
+ # Valid mode arguments:
+ clean|compile|execute|finish|install|link|relink|uninstall) ;;
+
+ # Catch anything else as an error
+ *) func_error "invalid argument for $opt"
+ exit_cmd=exit
+ break
+ ;;
+esac
+ shift
+ ;;
+ --no-silent|--no-quiet)
+ opt_silent=false
+func_append preserve_args " $opt"
+ ;;
+ --no-warning|--no-warn)
+ opt_warning=false
+func_append preserve_args " $opt"
+ ;;
+ --no-verbose)
+ opt_verbose=false
+func_append preserve_args " $opt"
+ ;;
+ --silent|--quiet)
+ opt_silent=:
+func_append preserve_args " $opt"
+ opt_verbose=false
+ ;;
+ --verbose|-v)
+ opt_verbose=:
+func_append preserve_args " $opt"
+opt_silent=false
+ ;;
+ --tag)
+ test $# = 0 && func_missing_arg $opt && break
+ optarg="$1"
+ opt_tag="$optarg"
+func_append preserve_args " $opt $optarg"
+func_enable_tag "$optarg"
+ shift
+ ;;
+
+ -\?|-h) func_usage ;;
+ --help) func_help ;;
+ --version) func_version ;;
+
+ # Separate optargs to long options:
+ --*=*)
+ func_split_long_opt "$opt"
+ set dummy "$func_split_long_opt_name" "$func_split_long_opt_arg" ${1+"$@"}
+ shift
+ ;;
+
+ # Separate non-argument short options:
+ -\?*|-h*|-n*|-v*)
+ func_split_short_opt "$opt"
+ set dummy "$func_split_short_opt_name" "-$func_split_short_opt_arg" ${1+"$@"}
+ shift
+ ;;
+
+ --) break ;;
+ -*) func_fatal_help "unrecognized option \`$opt'" ;;
+ *) set dummy "$opt" ${1+"$@"}; shift; break ;;
+ esac
+ done
+
+ # Validate options:
+
+ # save first non-option argument
+ if test "$#" -gt 0; then
+ nonopt="$opt"
+ shift
+ fi
+
+ # preserve --debug
+ test "$opt_debug" = : || func_append preserve_args " --debug"
+
+ case $host in
+ *cygwin* | *mingw* | *pw32* | *cegcc*)
+ # don't eliminate duplications in $postdeps and $predeps
+ opt_duplicate_compiler_generated_deps=:
+ ;;
+ *)
+ opt_duplicate_compiler_generated_deps=$opt_preserve_dup_deps
+ ;;
+ esac
+
+ $opt_help || {
+ # Sanity checks first:
+ func_check_version_match
+
+ if test "$build_libtool_libs" != yes && test "$build_old_libs" != yes; then
+ func_fatal_configuration "not configured to build any kind of library"
+ fi
+
+ # Darwin sucks
+ eval std_shrext=\"$shrext_cmds\"
+
+ # Only execute mode is allowed to have -dlopen flags.
+ if test -n "$opt_dlopen" && test "$opt_mode" != execute; then
+ func_error "unrecognized option \`-dlopen'"
+ $ECHO "$help" 1>&2
+ exit $EXIT_FAILURE
+ fi
+
+ # Change the help message to a mode-specific one.
+ generic_help="$help"
+ help="Try \`$progname --help --mode=$opt_mode' for more information."
+ }
+
+
+ # Bail if the options were screwed
+ $exit_cmd $EXIT_FAILURE
+}
+
+
+
+
+## ----------- ##
+## Main. ##
+## ----------- ##
+
+# func_lalib_p file
+# True iff FILE is a libtool `.la' library or `.lo' object file.
+# This function is only a basic sanity check; it will hardly flush out
+# determined imposters.
+func_lalib_p ()
+{
+ test -f "$1" &&
+ $SED -e 4q "$1" 2>/dev/null \
+ | $GREP "^# Generated by .*$PACKAGE" > /dev/null 2>&1
+}
+
+# func_lalib_unsafe_p file
+# True iff FILE is a libtool `.la' library or `.lo' object file.
+# This function implements the same check as func_lalib_p without
+# resorting to external programs. To this end, it redirects stdin and
+# closes it afterwards, without saving the original file descriptor.
+# As a safety measure, use it only where a negative result would be
+# fatal anyway. Works if `file' does not exist.
+func_lalib_unsafe_p ()
+{
+ lalib_p=no
+ if test -f "$1" && test -r "$1" && exec 5<&0 <"$1"; then
+ for lalib_p_l in 1 2 3 4
+ do
+ read lalib_p_line
+ case "$lalib_p_line" in
+ \#\ Generated\ by\ *$PACKAGE* ) lalib_p=yes; break;;
+ esac
+ done
+ exec 0<&5 5<&-
+ fi
+ test "$lalib_p" = yes
+}
+
+# func_ltwrapper_script_p file
+# True iff FILE is a libtool wrapper script
+# This function is only a basic sanity check; it will hardly flush out
+# determined imposters.
+func_ltwrapper_script_p ()
+{
+ func_lalib_p "$1"
+}
+
+# func_ltwrapper_executable_p file
+# True iff FILE is a libtool wrapper executable
+# This function is only a basic sanity check; it will hardly flush out
+# determined imposters.
+func_ltwrapper_executable_p ()
+{
+ func_ltwrapper_exec_suffix=
+ case $1 in
+ *.exe) ;;
+ *) func_ltwrapper_exec_suffix=.exe ;;
+ esac
+ $GREP "$magic_exe" "$1$func_ltwrapper_exec_suffix" >/dev/null 2>&1
+}
+
+# func_ltwrapper_scriptname file
+# Assumes file is an ltwrapper_executable
+# uses $file to determine the appropriate filename for a
+# temporary ltwrapper_script.
+func_ltwrapper_scriptname ()
+{
+ func_dirname_and_basename "$1" "" "."
+ func_stripname '' '.exe' "$func_basename_result"
+ func_ltwrapper_scriptname_result="$func_dirname_result/$objdir/${func_stripname_result}_ltshwrapper"
+}
+
+# func_ltwrapper_p file
+# True iff FILE is a libtool wrapper script or wrapper executable
+# This function is only a basic sanity check; it will hardly flush out
+# determined imposters.
+func_ltwrapper_p ()
+{
+ func_ltwrapper_script_p "$1" || func_ltwrapper_executable_p "$1"
+}
+
+
+# func_execute_cmds commands fail_cmd
+# Execute tilde-delimited COMMANDS.
+# If FAIL_CMD is given, eval that upon failure.
+# FAIL_CMD may read-access the current command in variable CMD!
+func_execute_cmds ()
+{
+ $opt_debug
+ save_ifs=$IFS; IFS='~'
+ for cmd in $1; do
+ IFS=$save_ifs
+ eval cmd=\"$cmd\"
+ func_show_eval "$cmd" "${2-:}"
+ done
+ IFS=$save_ifs
+}
+
+
+# func_source file
+# Source FILE, adding directory component if necessary.
+# Note that it is not necessary on cygwin/mingw to append a dot to
+# FILE even if both FILE and FILE.exe exist: automatic-append-.exe
+# behavior happens only for exec(3), not for open(2)! Also, sourcing
+# `FILE.' does not work on cygwin managed mounts.
+func_source ()
+{
+ $opt_debug
+ case $1 in
+ */* | *\\*) . "$1" ;;
+ *) . "./$1" ;;
+ esac
+}
+
+
+# func_resolve_sysroot PATH
+# Replace a leading = in PATH with a sysroot. Store the result into
+# func_resolve_sysroot_result
+func_resolve_sysroot ()
+{
+ func_resolve_sysroot_result=$1
+ case $func_resolve_sysroot_result in
+ =*)
+ func_stripname '=' '' "$func_resolve_sysroot_result"
+ func_resolve_sysroot_result=$lt_sysroot$func_stripname_result
+ ;;
+ esac
+}
+
+# func_replace_sysroot PATH
+# If PATH begins with the sysroot, replace it with = and
+# store the result into func_replace_sysroot_result.
+func_replace_sysroot ()
+{
+ case "$lt_sysroot:$1" in
+ ?*:"$lt_sysroot"*)
+ func_stripname "$lt_sysroot" '' "$1"
+ func_replace_sysroot_result="=$func_stripname_result"
+ ;;
+ *)
+ # Including no sysroot.
+ func_replace_sysroot_result=$1
+ ;;
+ esac
+}
+
+# func_infer_tag arg
+# Infer tagged configuration to use if any are available and
+# if one wasn't chosen via the "--tag" command line option.
+# Only attempt this if the compiler in the base compile
+# command doesn't match the default compiler.
+# arg is usually of the form 'gcc ...'
+func_infer_tag ()
+{
+ $opt_debug
+ if test -n "$available_tags" && test -z "$tagname"; then
+ CC_quoted=
+ for arg in $CC; do
+ func_append_quoted CC_quoted "$arg"
+ done
+ CC_expanded=`func_echo_all $CC`
+ CC_quoted_expanded=`func_echo_all $CC_quoted`
+ case $@ in
+ # Blanks in the command may have been stripped by the calling shell,
+ # but not from the CC environment variable when configure was run.
+ " $CC "* | "$CC "* | " $CC_expanded "* | "$CC_expanded "* | \
+ " $CC_quoted"* | "$CC_quoted "* | " $CC_quoted_expanded "* | "$CC_quoted_expanded "*) ;;
+ # Blanks at the start of $base_compile will cause this to fail
+ # if we don't check for them as well.
+ *)
+ for z in $available_tags; do
+ if $GREP "^# ### BEGIN LIBTOOL TAG CONFIG: $z$" < "$progpath" > /dev/null; then
+ # Evaluate the configuration.
+ eval "`${SED} -n -e '/^# ### BEGIN LIBTOOL TAG CONFIG: '$z'$/,/^# ### END LIBTOOL TAG CONFIG: '$z'$/p' < $progpath`"
+ CC_quoted=
+ for arg in $CC; do
+ # Double-quote args containing other shell metacharacters.
+ func_append_quoted CC_quoted "$arg"
+ done
+ CC_expanded=`func_echo_all $CC`
+ CC_quoted_expanded=`func_echo_all $CC_quoted`
+ case "$@ " in
+ " $CC "* | "$CC "* | " $CC_expanded "* | "$CC_expanded "* | \
+ " $CC_quoted"* | "$CC_quoted "* | " $CC_quoted_expanded "* | "$CC_quoted_expanded "*)
+ # The compiler in the base compile command matches
+ # the one in the tagged configuration.
+ # Assume this is the tagged configuration we want.
+ tagname=$z
+ break
+ ;;
+ esac
+ fi
+ done
+ # If $tagname still isn't set, then no tagged configuration
+ # was found and let the user know that the "--tag" command
+ # line option must be used.
+ if test -z "$tagname"; then
+ func_echo "unable to infer tagged configuration"
+ func_fatal_error "specify a tag with \`--tag'"
+# else
+# func_verbose "using $tagname tagged configuration"
+ fi
+ ;;
+ esac
+ fi
+}
+
+
+
+# func_write_libtool_object output_name pic_name nonpic_name
+# Create a libtool object file (analogous to a ".la" file),
+# but don't create it if we're doing a dry run.
+func_write_libtool_object ()
+{
+ write_libobj=${1}
+ if test "$build_libtool_libs" = yes; then
+ write_lobj=\'${2}\'
+ else
+ write_lobj=none
+ fi
+
+ if test "$build_old_libs" = yes; then
+ write_oldobj=\'${3}\'
+ else
+ write_oldobj=none
+ fi
+
+ $opt_dry_run || {
+ cat >${write_libobj}T <<EOF
+# $write_libobj - a libtool object file
+# Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION
+#
+# Please DO NOT delete this file!
+# It is necessary for linking the library.
+
+# Name of the PIC object.
+pic_object=$write_lobj
+
+# Name of the non-PIC object
+non_pic_object=$write_oldobj
+
+EOF
+ $MV "${write_libobj}T" "${write_libobj}"
+ }
+}
+
+
+##################################################
+# FILE NAME AND PATH CONVERSION HELPER FUNCTIONS #
+##################################################
+
+# func_convert_core_file_wine_to_w32 ARG
+# Helper function used by file name conversion functions when $build is *nix,
+# and $host is mingw, cygwin, or some other w32 environment. Relies on a
+# correctly configured wine environment available, with the winepath program
+# in $build's $PATH.
+#
+# ARG is the $build file name to be converted to w32 format.
+# Result is available in $func_convert_core_file_wine_to_w32_result, and will
+# be empty on error (or when ARG is empty)
+func_convert_core_file_wine_to_w32 ()
+{
+ $opt_debug
+ func_convert_core_file_wine_to_w32_result="$1"
+ if test -n "$1"; then
+ # Unfortunately, winepath does not exit with a non-zero error code, so we
+ # are forced to check the contents of stdout. On the other hand, if the
+ # command is not found, the shell will set an exit code of 127 and print
+ # *an error message* to stdout. So we must check for both error code of
+ # zero AND non-empty stdout, which explains the odd construction:
+ func_convert_core_file_wine_to_w32_tmp=`winepath -w "$1" 2>/dev/null`
+ if test "$?" -eq 0 && test -n "${func_convert_core_file_wine_to_w32_tmp}"; then
+ func_convert_core_file_wine_to_w32_result=`$ECHO "$func_convert_core_file_wine_to_w32_tmp" |
+ $SED -e "$lt_sed_naive_backslashify"`
+ else
+ func_convert_core_file_wine_to_w32_result=
+ fi
+ fi
+}
+# end: func_convert_core_file_wine_to_w32
+
+
+# func_convert_core_path_wine_to_w32 ARG
+# Helper function used by path conversion functions when $build is *nix, and
+# $host is mingw, cygwin, or some other w32 environment. Relies on a correctly
+# configured wine environment available, with the winepath program in $build's
+# $PATH. Assumes ARG has no leading or trailing path separator characters.
+#
+# ARG is path to be converted from $build format to win32.
+# Result is available in $func_convert_core_path_wine_to_w32_result.
+# Unconvertible file (directory) names in ARG are skipped; if no directory names
+# are convertible, then the result may be empty.
+func_convert_core_path_wine_to_w32 ()
+{
+ $opt_debug
+ # unfortunately, winepath doesn't convert paths, only file names
+ func_convert_core_path_wine_to_w32_result=""
+ if test -n "$1"; then
+ oldIFS=$IFS
+ IFS=:
+ for func_convert_core_path_wine_to_w32_f in $1; do
+ IFS=$oldIFS
+ func_convert_core_file_wine_to_w32 "$func_convert_core_path_wine_to_w32_f"
+ if test -n "$func_convert_core_file_wine_to_w32_result" ; then
+ if test -z "$func_convert_core_path_wine_to_w32_result"; then
+ func_convert_core_path_wine_to_w32_result="$func_convert_core_file_wine_to_w32_result"
+ else
+ func_append func_convert_core_path_wine_to_w32_result ";$func_convert_core_file_wine_to_w32_result"
+ fi
+ fi
+ done
+ IFS=$oldIFS
+ fi
+}
+# end: func_convert_core_path_wine_to_w32
+
+
+# func_cygpath ARGS...
+# Wrapper around calling the cygpath program via LT_CYGPATH. This is used when
+# when (1) $build is *nix and Cygwin is hosted via a wine environment; or (2)
+# $build is MSYS and $host is Cygwin, or (3) $build is Cygwin. In case (1) or
+# (2), returns the Cygwin file name or path in func_cygpath_result (input
+# file name or path is assumed to be in w32 format, as previously converted
+# from $build's *nix or MSYS format). In case (3), returns the w32 file name
+# or path in func_cygpath_result (input file name or path is assumed to be in
+# Cygwin format). Returns an empty string on error.
+#
+# ARGS are passed to cygpath, with the last one being the file name or path to
+# be converted.
+#
+# Specify the absolute *nix (or w32) name to cygpath in the LT_CYGPATH
+# environment variable; do not put it in $PATH.
+func_cygpath ()
+{
+ $opt_debug
+ if test -n "$LT_CYGPATH" && test -f "$LT_CYGPATH"; then
+ func_cygpath_result=`$LT_CYGPATH "$@" 2>/dev/null`
+ if test "$?" -ne 0; then
+ # on failure, ensure result is empty
+ func_cygpath_result=
+ fi
+ else
+ func_cygpath_result=
+ func_error "LT_CYGPATH is empty or specifies non-existent file: \`$LT_CYGPATH'"
+ fi
+}
+#end: func_cygpath
+
+
+# func_convert_core_msys_to_w32 ARG
+# Convert file name or path ARG from MSYS format to w32 format. Return
+# result in func_convert_core_msys_to_w32_result.
+func_convert_core_msys_to_w32 ()
+{
+ $opt_debug
+ # awkward: cmd appends spaces to result
+ func_convert_core_msys_to_w32_result=`( cmd //c echo "$1" ) 2>/dev/null |
+ $SED -e 's/[ ]*$//' -e "$lt_sed_naive_backslashify"`
+}
+#end: func_convert_core_msys_to_w32
+
+
+# func_convert_file_check ARG1 ARG2
+# Verify that ARG1 (a file name in $build format) was converted to $host
+# format in ARG2. Otherwise, emit an error message, but continue (resetting
+# func_to_host_file_result to ARG1).
+func_convert_file_check ()
+{
+ $opt_debug
+ if test -z "$2" && test -n "$1" ; then
+ func_error "Could not determine host file name corresponding to"
+ func_error " \`$1'"
+ func_error "Continuing, but uninstalled executables may not work."
+ # Fallback:
+ func_to_host_file_result="$1"
+ fi
+}
+# end func_convert_file_check
+
+
+# func_convert_path_check FROM_PATHSEP TO_PATHSEP FROM_PATH TO_PATH
+# Verify that FROM_PATH (a path in $build format) was converted to $host
+# format in TO_PATH. Otherwise, emit an error message, but continue, resetting
+# func_to_host_file_result to a simplistic fallback value (see below).
+func_convert_path_check ()
+{
+ $opt_debug
+ if test -z "$4" && test -n "$3"; then
+ func_error "Could not determine the host path corresponding to"
+ func_error " \`$3'"
+ func_error "Continuing, but uninstalled executables may not work."
+ # Fallback. This is a deliberately simplistic "conversion" and
+ # should not be "improved". See libtool.info.
+ if test "x$1" != "x$2"; then
+ lt_replace_pathsep_chars="s|$1|$2|g"
+ func_to_host_path_result=`echo "$3" |
+ $SED -e "$lt_replace_pathsep_chars"`
+ else
+ func_to_host_path_result="$3"
+ fi
+ fi
+}
+# end func_convert_path_check
+
+
+# func_convert_path_front_back_pathsep FRONTPAT BACKPAT REPL ORIG
+# Modifies func_to_host_path_result by prepending REPL if ORIG matches FRONTPAT
+# and appending REPL if ORIG matches BACKPAT.
+func_convert_path_front_back_pathsep ()
+{
+ $opt_debug
+ case $4 in
+ $1 ) func_to_host_path_result="$3$func_to_host_path_result"
+ ;;
+ esac
+ case $4 in
+ $2 ) func_append func_to_host_path_result "$3"
+ ;;
+ esac
+}
+# end func_convert_path_front_back_pathsep
+
+
+##################################################
+# $build to $host FILE NAME CONVERSION FUNCTIONS #
+##################################################
+# invoked via `$to_host_file_cmd ARG'
+#
+# In each case, ARG is the path to be converted from $build to $host format.
+# Result will be available in $func_to_host_file_result.
+
+
+# func_to_host_file ARG
+# Converts the file name ARG from $build format to $host format. Return result
+# in func_to_host_file_result.
+func_to_host_file ()
+{
+ $opt_debug
+ $to_host_file_cmd "$1"
+}
+# end func_to_host_file
+
+
+# func_to_tool_file ARG LAZY
+# converts the file name ARG from $build format to toolchain format. Return
+# result in func_to_tool_file_result. If the conversion in use is listed
+# in (the comma separated) LAZY, no conversion takes place.
+func_to_tool_file ()
+{
+ $opt_debug
+ case ,$2, in
+ *,"$to_tool_file_cmd",*)
+ func_to_tool_file_result=$1
+ ;;
+ *)
+ $to_tool_file_cmd "$1"
+ func_to_tool_file_result=$func_to_host_file_result
+ ;;
+ esac
+}
+# end func_to_tool_file
+
+
+# func_convert_file_noop ARG
+# Copy ARG to func_to_host_file_result.
+func_convert_file_noop ()
+{
+ func_to_host_file_result="$1"
+}
+# end func_convert_file_noop
+
+
+# func_convert_file_msys_to_w32 ARG
+# Convert file name ARG from (mingw) MSYS to (mingw) w32 format; automatic
+# conversion to w32 is not available inside the cwrapper. Returns result in
+# func_to_host_file_result.
+func_convert_file_msys_to_w32 ()
+{
+ $opt_debug
+ func_to_host_file_result="$1"
+ if test -n "$1"; then
+ func_convert_core_msys_to_w32 "$1"
+ func_to_host_file_result="$func_convert_core_msys_to_w32_result"
+ fi
+ func_convert_file_check "$1" "$func_to_host_file_result"
+}
+# end func_convert_file_msys_to_w32
+
+
+# func_convert_file_cygwin_to_w32 ARG
+# Convert file name ARG from Cygwin to w32 format. Returns result in
+# func_to_host_file_result.
+func_convert_file_cygwin_to_w32 ()
+{
+ $opt_debug
+ func_to_host_file_result="$1"
+ if test -n "$1"; then
+ # because $build is cygwin, we call "the" cygpath in $PATH; no need to use
+ # LT_CYGPATH in this case.
+ func_to_host_file_result=`cygpath -m "$1"`
+ fi
+ func_convert_file_check "$1" "$func_to_host_file_result"
+}
+# end func_convert_file_cygwin_to_w32
+
+
+# func_convert_file_nix_to_w32 ARG
+# Convert file name ARG from *nix to w32 format. Requires a wine environment
+# and a working winepath. Returns result in func_to_host_file_result.
+func_convert_file_nix_to_w32 ()
+{
+ $opt_debug
+ func_to_host_file_result="$1"
+ if test -n "$1"; then
+ func_convert_core_file_wine_to_w32 "$1"
+ func_to_host_file_result="$func_convert_core_file_wine_to_w32_result"
+ fi
+ func_convert_file_check "$1" "$func_to_host_file_result"
+}
+# end func_convert_file_nix_to_w32
+
+
+# func_convert_file_msys_to_cygwin ARG
+# Convert file name ARG from MSYS to Cygwin format. Requires LT_CYGPATH set.
+# Returns result in func_to_host_file_result.
+func_convert_file_msys_to_cygwin ()
+{
+ $opt_debug
+ func_to_host_file_result="$1"
+ if test -n "$1"; then
+ func_convert_core_msys_to_w32 "$1"
+ func_cygpath -u "$func_convert_core_msys_to_w32_result"
+ func_to_host_file_result="$func_cygpath_result"
+ fi
+ func_convert_file_check "$1" "$func_to_host_file_result"
+}
+# end func_convert_file_msys_to_cygwin
+
+
+# func_convert_file_nix_to_cygwin ARG
+# Convert file name ARG from *nix to Cygwin format. Requires Cygwin installed
+# in a wine environment, working winepath, and LT_CYGPATH set. Returns result
+# in func_to_host_file_result.
+func_convert_file_nix_to_cygwin ()
+{
+ $opt_debug
+ func_to_host_file_result="$1"
+ if test -n "$1"; then
+ # convert from *nix to w32, then use cygpath to convert from w32 to cygwin.
+ func_convert_core_file_wine_to_w32 "$1"
+ func_cygpath -u "$func_convert_core_file_wine_to_w32_result"
+ func_to_host_file_result="$func_cygpath_result"
+ fi
+ func_convert_file_check "$1" "$func_to_host_file_result"
+}
+# end func_convert_file_nix_to_cygwin
+
+
+#############################################
+# $build to $host PATH CONVERSION FUNCTIONS #
+#############################################
+# invoked via `$to_host_path_cmd ARG'
+#
+# In each case, ARG is the path to be converted from $build to $host format.
+# The result will be available in $func_to_host_path_result.
+#
+# Path separators are also converted from $build format to $host format. If
+# ARG begins or ends with a path separator character, it is preserved (but
+# converted to $host format) on output.
+#
+# All path conversion functions are named using the following convention:
+# file name conversion function : func_convert_file_X_to_Y ()
+# path conversion function : func_convert_path_X_to_Y ()
+# where, for any given $build/$host combination the 'X_to_Y' value is the
+# same. If conversion functions are added for new $build/$host combinations,
+# the two new functions must follow this pattern, or func_init_to_host_path_cmd
+# will break.
+
+
+# func_init_to_host_path_cmd
+# Ensures that function "pointer" variable $to_host_path_cmd is set to the
+# appropriate value, based on the value of $to_host_file_cmd.
+to_host_path_cmd=
+func_init_to_host_path_cmd ()
+{
+ $opt_debug
+ if test -z "$to_host_path_cmd"; then
+ func_stripname 'func_convert_file_' '' "$to_host_file_cmd"
+ to_host_path_cmd="func_convert_path_${func_stripname_result}"
+ fi
+}
+
+
+# func_to_host_path ARG
+# Converts the path ARG from $build format to $host format. Return result
+# in func_to_host_path_result.
+func_to_host_path ()
+{
+ $opt_debug
+ func_init_to_host_path_cmd
+ $to_host_path_cmd "$1"
+}
+# end func_to_host_path
+
+
+# func_convert_path_noop ARG
+# Copy ARG to func_to_host_path_result.
+func_convert_path_noop ()
+{
+ func_to_host_path_result="$1"
+}
+# end func_convert_path_noop
+
+
+# func_convert_path_msys_to_w32 ARG
+# Convert path ARG from (mingw) MSYS to (mingw) w32 format; automatic
+# conversion to w32 is not available inside the cwrapper. Returns result in
+# func_to_host_path_result.
+func_convert_path_msys_to_w32 ()
+{
+ $opt_debug
+ func_to_host_path_result="$1"
+ if test -n "$1"; then
+ # Remove leading and trailing path separator characters from ARG. MSYS
+ # behavior is inconsistent here; cygpath turns them into '.;' and ';.';
+ # and winepath ignores them completely.
+ func_stripname : : "$1"
+ func_to_host_path_tmp1=$func_stripname_result
+ func_convert_core_msys_to_w32 "$func_to_host_path_tmp1"
+ func_to_host_path_result="$func_convert_core_msys_to_w32_result"
+ func_convert_path_check : ";" \
+ "$func_to_host_path_tmp1" "$func_to_host_path_result"
+ func_convert_path_front_back_pathsep ":*" "*:" ";" "$1"
+ fi
+}
+# end func_convert_path_msys_to_w32
+
+
+# func_convert_path_cygwin_to_w32 ARG
+# Convert path ARG from Cygwin to w32 format. Returns result in
+# func_to_host_file_result.
+func_convert_path_cygwin_to_w32 ()
+{
+ $opt_debug
+ func_to_host_path_result="$1"
+ if test -n "$1"; then
+ # See func_convert_path_msys_to_w32:
+ func_stripname : : "$1"
+ func_to_host_path_tmp1=$func_stripname_result
+ func_to_host_path_result=`cygpath -m -p "$func_to_host_path_tmp1"`
+ func_convert_path_check : ";" \
+ "$func_to_host_path_tmp1" "$func_to_host_path_result"
+ func_convert_path_front_back_pathsep ":*" "*:" ";" "$1"
+ fi
+}
+# end func_convert_path_cygwin_to_w32
+
+
+# func_convert_path_nix_to_w32 ARG
+# Convert path ARG from *nix to w32 format. Requires a wine environment and
+# a working winepath. Returns result in func_to_host_file_result.
+func_convert_path_nix_to_w32 ()
+{
+ $opt_debug
+ func_to_host_path_result="$1"
+ if test -n "$1"; then
+ # See func_convert_path_msys_to_w32:
+ func_stripname : : "$1"
+ func_to_host_path_tmp1=$func_stripname_result
+ func_convert_core_path_wine_to_w32 "$func_to_host_path_tmp1"
+ func_to_host_path_result="$func_convert_core_path_wine_to_w32_result"
+ func_convert_path_check : ";" \
+ "$func_to_host_path_tmp1" "$func_to_host_path_result"
+ func_convert_path_front_back_pathsep ":*" "*:" ";" "$1"
+ fi
+}
+# end func_convert_path_nix_to_w32
+
+
+# func_convert_path_msys_to_cygwin ARG
+# Convert path ARG from MSYS to Cygwin format. Requires LT_CYGPATH set.
+# Returns result in func_to_host_file_result.
+func_convert_path_msys_to_cygwin ()
+{
+ $opt_debug
+ func_to_host_path_result="$1"
+ if test -n "$1"; then
+ # See func_convert_path_msys_to_w32:
+ func_stripname : : "$1"
+ func_to_host_path_tmp1=$func_stripname_result
+ func_convert_core_msys_to_w32 "$func_to_host_path_tmp1"
+ func_cygpath -u -p "$func_convert_core_msys_to_w32_result"
+ func_to_host_path_result="$func_cygpath_result"
+ func_convert_path_check : : \
+ "$func_to_host_path_tmp1" "$func_to_host_path_result"
+ func_convert_path_front_back_pathsep ":*" "*:" : "$1"
+ fi
+}
+# end func_convert_path_msys_to_cygwin
+
+
+# func_convert_path_nix_to_cygwin ARG
+# Convert path ARG from *nix to Cygwin format. Requires Cygwin installed in a
+# a wine environment, working winepath, and LT_CYGPATH set. Returns result in
+# func_to_host_file_result.
+func_convert_path_nix_to_cygwin ()
+{
+ $opt_debug
+ func_to_host_path_result="$1"
+ if test -n "$1"; then
+ # Remove leading and trailing path separator characters from
+ # ARG. msys behavior is inconsistent here, cygpath turns them
+ # into '.;' and ';.', and winepath ignores them completely.
+ func_stripname : : "$1"
+ func_to_host_path_tmp1=$func_stripname_result
+ func_convert_core_path_wine_to_w32 "$func_to_host_path_tmp1"
+ func_cygpath -u -p "$func_convert_core_path_wine_to_w32_result"
+ func_to_host_path_result="$func_cygpath_result"
+ func_convert_path_check : : \
+ "$func_to_host_path_tmp1" "$func_to_host_path_result"
+ func_convert_path_front_back_pathsep ":*" "*:" : "$1"
+ fi
+}
+# end func_convert_path_nix_to_cygwin
+
+
+# func_mode_compile arg...
+func_mode_compile ()
+{
+ $opt_debug
+ # Get the compilation command and the source file.
+ base_compile=
+ srcfile="$nonopt" # always keep a non-empty value in "srcfile"
+ suppress_opt=yes
+ suppress_output=
+ arg_mode=normal
+ libobj=
+ later=
+ pie_flag=
+
+ for arg
+ do
+ case $arg_mode in
+ arg )
+ # do not "continue". Instead, add this to base_compile
+ lastarg="$arg"
+ arg_mode=normal
+ ;;
+
+ target )
+ libobj="$arg"
+ arg_mode=normal
+ continue
+ ;;
+
+ normal )
+ # Accept any command-line options.
+ case $arg in
+ -o)
+ test -n "$libobj" && \
+ func_fatal_error "you cannot specify \`-o' more than once"
+ arg_mode=target
+ continue
+ ;;
+
+ -pie | -fpie | -fPIE)
+ func_append pie_flag " $arg"
+ continue
+ ;;
+
+ -shared | -static | -prefer-pic | -prefer-non-pic)
+ func_append later " $arg"
+ continue
+ ;;
+
+ -no-suppress)
+ suppress_opt=no
+ continue
+ ;;
+
+ -Xcompiler)
+ arg_mode=arg # the next one goes into the "base_compile" arg list
+ continue # The current "srcfile" will either be retained or
+ ;; # replaced later. I would guess that would be a bug.
+
+ -Wc,*)
+ func_stripname '-Wc,' '' "$arg"
+ args=$func_stripname_result
+ lastarg=
+ save_ifs="$IFS"; IFS=','
+ for arg in $args; do
+ IFS="$save_ifs"
+ func_append_quoted lastarg "$arg"
+ done
+ IFS="$save_ifs"
+ func_stripname ' ' '' "$lastarg"
+ lastarg=$func_stripname_result
+
+ # Add the arguments to base_compile.
+ func_append base_compile " $lastarg"
+ continue
+ ;;
+
+ *)
+ # Accept the current argument as the source file.
+ # The previous "srcfile" becomes the current argument.
+ #
+ lastarg="$srcfile"
+ srcfile="$arg"
+ ;;
+ esac # case $arg
+ ;;
+ esac # case $arg_mode
+
+ # Aesthetically quote the previous argument.
+ func_append_quoted base_compile "$lastarg"
+ done # for arg
+
+ case $arg_mode in
+ arg)
+ func_fatal_error "you must specify an argument for -Xcompile"
+ ;;
+ target)
+ func_fatal_error "you must specify a target with \`-o'"
+ ;;
+ *)
+ # Get the name of the library object.
+ test -z "$libobj" && {
+ func_basename "$srcfile"
+ libobj="$func_basename_result"
+ }
+ ;;
+ esac
+
+ # Recognize several different file suffixes.
+ # If the user specifies -o file.o, it is replaced with file.lo
+ case $libobj in
+ *.[cCFSifmso] | \
+ *.ada | *.adb | *.ads | *.asm | \
+ *.c++ | *.cc | *.ii | *.class | *.cpp | *.cxx | \
+ *.[fF][09]? | *.for | *.java | *.go | *.obj | *.sx | *.cu | *.cup)
+ func_xform "$libobj"
+ libobj=$func_xform_result
+ ;;
+ esac
+
+ case $libobj in
+ *.lo) func_lo2o "$libobj"; obj=$func_lo2o_result ;;
+ *)
+ func_fatal_error "cannot determine name of library object from \`$libobj'"
+ ;;
+ esac
+
+ func_infer_tag $base_compile
+
+ for arg in $later; do
+ case $arg in
+ -shared)
+ test "$build_libtool_libs" != yes && \
+ func_fatal_configuration "can not build a shared library"
+ build_old_libs=no
+ continue
+ ;;
+
+ -static)
+ build_libtool_libs=no
+ build_old_libs=yes
+ continue
+ ;;
+
+ -prefer-pic)
+ pic_mode=yes
+ continue
+ ;;
+
+ -prefer-non-pic)
+ pic_mode=no
+ continue
+ ;;
+ esac
+ done
+
+ func_quote_for_eval "$libobj"
+ test "X$libobj" != "X$func_quote_for_eval_result" \
+ && $ECHO "X$libobj" | $GREP '[]~#^*{};<>?"'"'"' &()|`$[]' \
+ && func_warning "libobj name \`$libobj' may not contain shell special characters."
+ func_dirname_and_basename "$obj" "/" ""
+ objname="$func_basename_result"
+ xdir="$func_dirname_result"
+ lobj=${xdir}$objdir/$objname
+
+ test -z "$base_compile" && \
+ func_fatal_help "you must specify a compilation command"
+
+ # Delete any leftover library objects.
+ if test "$build_old_libs" = yes; then
+ removelist="$obj $lobj $libobj ${libobj}T"
+ else
+ removelist="$lobj $libobj ${libobj}T"
+ fi
+
+ # On Cygwin there's no "real" PIC flag so we must build both object types
+ case $host_os in
+ cygwin* | mingw* | pw32* | os2* | cegcc*)
+ pic_mode=default
+ ;;
+ esac
+ if test "$pic_mode" = no && test "$deplibs_check_method" != pass_all; then
+ # non-PIC code in shared libraries is not supported
+ pic_mode=default
+ fi
+
+ # Calculate the filename of the output object if compiler does
+ # not support -o with -c
+ if test "$compiler_c_o" = no; then
+ output_obj=`$ECHO "$srcfile" | $SED 's%^.*/%%; s%\.[^.]*$%%'`.${objext}
+ lockfile="$output_obj.lock"
+ else
+ output_obj=
+ need_locks=no
+ lockfile=
+ fi
+
+ # Lock this critical section if it is needed
+ # We use this script file to make the link, it avoids creating a new file
+ if test "$need_locks" = yes; then
+ until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do
+ func_echo "Waiting for $lockfile to be removed"
+ sleep 2
+ done
+ elif test "$need_locks" = warn; then
+ if test -f "$lockfile"; then
+ $ECHO "\
+*** ERROR, $lockfile exists and contains:
+`cat $lockfile 2>/dev/null`
+
+This indicates that another process is trying to use the same
+temporary object file, and libtool could not work around it because
+your compiler does not support \`-c' and \`-o' together. If you
+repeat this compilation, it may succeed, by chance, but you had better
+avoid parallel builds (make -j) in this platform, or get a better
+compiler."
+
+ $opt_dry_run || $RM $removelist
+ exit $EXIT_FAILURE
+ fi
+ func_append removelist " $output_obj"
+ $ECHO "$srcfile" > "$lockfile"
+ fi
+
+ $opt_dry_run || $RM $removelist
+ func_append removelist " $lockfile"
+ trap '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE' 1 2 15
+
+ func_to_tool_file "$srcfile" func_convert_file_msys_to_w32
+ srcfile=$func_to_tool_file_result
+ func_quote_for_eval "$srcfile"
+ qsrcfile=$func_quote_for_eval_result
+
+ # Only build a PIC object if we are building libtool libraries.
+ if test "$build_libtool_libs" = yes; then
+ # Without this assignment, base_compile gets emptied.
+ fbsd_hideous_sh_bug=$base_compile
+
+ if test "$pic_mode" != no; then
+ command="$base_compile $qsrcfile $pic_flag"
+ else
+ # Don't build PIC code
+ command="$base_compile $qsrcfile"
+ fi
+
+ func_mkdir_p "$xdir$objdir"
+
+ if test -z "$output_obj"; then
+ # Place PIC objects in $objdir
+ func_append command " -o $lobj"
+ fi
+
+ func_show_eval_locale "$command" \
+ 'test -n "$output_obj" && $RM $removelist; exit $EXIT_FAILURE'
+
+ if test "$need_locks" = warn &&
+ test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then
+ $ECHO "\
+*** ERROR, $lockfile contains:
+`cat $lockfile 2>/dev/null`
+
+but it should contain:
+$srcfile
+
+This indicates that another process is trying to use the same
+temporary object file, and libtool could not work around it because
+your compiler does not support \`-c' and \`-o' together. If you
+repeat this compilation, it may succeed, by chance, but you had better
+avoid parallel builds (make -j) in this platform, or get a better
+compiler."
+
+ $opt_dry_run || $RM $removelist
+ exit $EXIT_FAILURE
+ fi
+
+ # Just move the object if needed, then go on to compile the next one
+ if test -n "$output_obj" && test "X$output_obj" != "X$lobj"; then
+ func_show_eval '$MV "$output_obj" "$lobj"' \
+ 'error=$?; $opt_dry_run || $RM $removelist; exit $error'
+ fi
+
+ # Allow error messages only from the first compilation.
+ if test "$suppress_opt" = yes; then
+ suppress_output=' >/dev/null 2>&1'
+ fi
+ fi
+
+ # Only build a position-dependent object if we build old libraries.
+ if test "$build_old_libs" = yes; then
+ if test "$pic_mode" != yes; then
+ # Don't build PIC code
+ command="$base_compile $qsrcfile$pie_flag"
+ else
+ command="$base_compile $qsrcfile $pic_flag"
+ fi
+ if test "$compiler_c_o" = yes; then
+ func_append command " -o $obj"
+ fi
+
+ # Suppress compiler output if we already did a PIC compilation.
+ func_append command "$suppress_output"
+ func_show_eval_locale "$command" \
+ '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE'
+
+ if test "$need_locks" = warn &&
+ test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then
+ $ECHO "\
+*** ERROR, $lockfile contains:
+`cat $lockfile 2>/dev/null`
+
+but it should contain:
+$srcfile
+
+This indicates that another process is trying to use the same
+temporary object file, and libtool could not work around it because
+your compiler does not support \`-c' and \`-o' together. If you
+repeat this compilation, it may succeed, by chance, but you had better
+avoid parallel builds (make -j) in this platform, or get a better
+compiler."
+
+ $opt_dry_run || $RM $removelist
+ exit $EXIT_FAILURE
+ fi
+
+ # Just move the object if needed
+ if test -n "$output_obj" && test "X$output_obj" != "X$obj"; then
+ func_show_eval '$MV "$output_obj" "$obj"' \
+ 'error=$?; $opt_dry_run || $RM $removelist; exit $error'
+ fi
+ fi
+
+ $opt_dry_run || {
+ func_write_libtool_object "$libobj" "$objdir/$objname" "$objname"
+
+ # Unlock the critical section if it was locked
+ if test "$need_locks" != no; then
+ removelist=$lockfile
+ $RM "$lockfile"
+ fi
+ }
+
+ exit $EXIT_SUCCESS
+}
+
+$opt_help || {
+ test "$opt_mode" = compile && func_mode_compile ${1+"$@"}
+}
+
+func_mode_help ()
+{
+ # We need to display help for each of the modes.
+ case $opt_mode in
+ "")
+ # Generic help is extracted from the usage comments
+ # at the start of this file.
+ func_help
+ ;;
+
+ clean)
+ $ECHO \
+"Usage: $progname [OPTION]... --mode=clean RM [RM-OPTION]... FILE...
+
+Remove files from the build directory.
+
+RM is the name of the program to use to delete files associated with each FILE
+(typically \`/bin/rm'). RM-OPTIONS are options (such as \`-f') to be passed
+to RM.
+
+If FILE is a libtool library, object or program, all the files associated
+with it are deleted. Otherwise, only FILE itself is deleted using RM."
+ ;;
+
+ compile)
+ $ECHO \
+"Usage: $progname [OPTION]... --mode=compile COMPILE-COMMAND... SOURCEFILE
+
+Compile a source file into a libtool library object.
+
+This mode accepts the following additional options:
+
+ -o OUTPUT-FILE set the output file name to OUTPUT-FILE
+ -no-suppress do not suppress compiler output for multiple passes
+ -prefer-pic try to build PIC objects only
+ -prefer-non-pic try to build non-PIC objects only
+ -shared do not build a \`.o' file suitable for static linking
+ -static only build a \`.o' file suitable for static linking
+ -Wc,FLAG pass FLAG directly to the compiler
+
+COMPILE-COMMAND is a command to be used in creating a \`standard' object file
+from the given SOURCEFILE.
+
+The output file name is determined by removing the directory component from
+SOURCEFILE, then substituting the C source code suffix \`.c' with the
+library object suffix, \`.lo'."
+ ;;
+
+ execute)
+ $ECHO \
+"Usage: $progname [OPTION]... --mode=execute COMMAND [ARGS]...
+
+Automatically set library path, then run a program.
+
+This mode accepts the following additional options:
+
+ -dlopen FILE add the directory containing FILE to the library path
+
+This mode sets the library path environment variable according to \`-dlopen'
+flags.
+
+If any of the ARGS are libtool executable wrappers, then they are translated
+into their corresponding uninstalled binary, and any of their required library
+directories are added to the library path.
+
+Then, COMMAND is executed, with ARGS as arguments."
+ ;;
+
+ finish)
+ $ECHO \
+"Usage: $progname [OPTION]... --mode=finish [LIBDIR]...
+
+Complete the installation of libtool libraries.
+
+Each LIBDIR is a directory that contains libtool libraries.
+
+The commands that this mode executes may require superuser privileges. Use
+the \`--dry-run' option if you just want to see what would be executed."
+ ;;
+
+ install)
+ $ECHO \
+"Usage: $progname [OPTION]... --mode=install INSTALL-COMMAND...
+
+Install executables or libraries.
+
+INSTALL-COMMAND is the installation command. The first component should be
+either the \`install' or \`cp' program.
+
+The following components of INSTALL-COMMAND are treated specially:
+
+ -inst-prefix-dir PREFIX-DIR Use PREFIX-DIR as a staging area for installation
+
+The rest of the components are interpreted as arguments to that command (only
+BSD-compatible install options are recognized)."
+ ;;
+
+ link)
+ $ECHO \
+"Usage: $progname [OPTION]... --mode=link LINK-COMMAND...
+
+Link object files or libraries together to form another library, or to
+create an executable program.
+
+LINK-COMMAND is a command using the C compiler that you would use to create
+a program from several object files.
+
+The following components of LINK-COMMAND are treated specially:
+
+ -all-static do not do any dynamic linking at all
+ -avoid-version do not add a version suffix if possible
+ -bindir BINDIR specify path to binaries directory (for systems where
+ libraries must be found in the PATH setting at runtime)
+ -dlopen FILE \`-dlpreopen' FILE if it cannot be dlopened at runtime
+ -dlpreopen FILE link in FILE and add its symbols to lt_preloaded_symbols
+ -export-dynamic allow symbols from OUTPUT-FILE to be resolved with dlsym(3)
+ -export-symbols SYMFILE
+ try to export only the symbols listed in SYMFILE
+ -export-symbols-regex REGEX
+ try to export only the symbols matching REGEX
+ -LLIBDIR search LIBDIR for required installed libraries
+ -lNAME OUTPUT-FILE requires the installed library libNAME
+ -module build a library that can dlopened
+ -no-fast-install disable the fast-install mode
+ -no-install link a not-installable executable
+ -no-undefined declare that a library does not refer to external symbols
+ -o OUTPUT-FILE create OUTPUT-FILE from the specified objects
+ -objectlist FILE Use a list of object files found in FILE to specify objects
+ -precious-files-regex REGEX
+ don't remove output files matching REGEX
+ -release RELEASE specify package release information
+ -rpath LIBDIR the created library will eventually be installed in LIBDIR
+ -R[ ]LIBDIR add LIBDIR to the runtime path of programs and libraries
+ -shared only do dynamic linking of libtool libraries
+ -shrext SUFFIX override the standard shared library file extension
+ -static do not do any dynamic linking of uninstalled libtool libraries
+ -static-libtool-libs
+ do not do any dynamic linking of libtool libraries
+ -version-info CURRENT[:REVISION[:AGE]]
+ specify library version info [each variable defaults to 0]
+ -weak LIBNAME declare that the target provides the LIBNAME interface
+ -Wc,FLAG
+ -Xcompiler FLAG pass linker-specific FLAG directly to the compiler
+ -Wl,FLAG
+ -Xlinker FLAG pass linker-specific FLAG directly to the linker
+ -XCClinker FLAG pass link-specific FLAG to the compiler driver (CC)
+
+All other options (arguments beginning with \`-') are ignored.
+
+Every other argument is treated as a filename. Files ending in \`.la' are
+treated as uninstalled libtool libraries, other files are standard or library
+object files.
+
+If the OUTPUT-FILE ends in \`.la', then a libtool library is created,
+only library objects (\`.lo' files) may be specified, and \`-rpath' is
+required, except when creating a convenience library.
+
+If OUTPUT-FILE ends in \`.a' or \`.lib', then a standard library is created
+using \`ar' and \`ranlib', or on Windows using \`lib'.
+
+If OUTPUT-FILE ends in \`.lo' or \`.${objext}', then a reloadable object file
+is created, otherwise an executable program is created."
+ ;;
+
+ uninstall)
+ $ECHO \
+"Usage: $progname [OPTION]... --mode=uninstall RM [RM-OPTION]... FILE...
+
+Remove libraries from an installation directory.
+
+RM is the name of the program to use to delete files associated with each FILE
+(typically \`/bin/rm'). RM-OPTIONS are options (such as \`-f') to be passed
+to RM.
+
+If FILE is a libtool library, all the files associated with it are deleted.
+Otherwise, only FILE itself is deleted using RM."
+ ;;
+
+ *)
+ func_fatal_help "invalid operation mode \`$opt_mode'"
+ ;;
+ esac
+
+ echo
+ $ECHO "Try \`$progname --help' for more information about other modes."
+}
+
+# Now that we've collected a possible --mode arg, show help if necessary
+if $opt_help; then
+ if test "$opt_help" = :; then
+ func_mode_help
+ else
+ {
+ func_help noexit
+ for opt_mode in compile link execute install finish uninstall clean; do
+ func_mode_help
+ done
+ } | sed -n '1p; 2,$s/^Usage:/ or: /p'
+ {
+ func_help noexit
+ for opt_mode in compile link execute install finish uninstall clean; do
+ echo
+ func_mode_help
+ done
+ } |
+ sed '1d
+ /^When reporting/,/^Report/{
+ H
+ d
+ }
+ $x
+ /information about other modes/d
+ /more detailed .*MODE/d
+ s/^Usage:.*--mode=\([^ ]*\) .*/Description of \1 mode:/'
+ fi
+ exit $?
+fi
+
+
+# func_mode_execute arg...
+func_mode_execute ()
+{
+ $opt_debug
+ # The first argument is the command name.
+ cmd="$nonopt"
+ test -z "$cmd" && \
+ func_fatal_help "you must specify a COMMAND"
+
+ # Handle -dlopen flags immediately.
+ for file in $opt_dlopen; do
+ test -f "$file" \
+ || func_fatal_help "\`$file' is not a file"
+
+ dir=
+ case $file in
+ *.la)
+ func_resolve_sysroot "$file"
+ file=$func_resolve_sysroot_result
+
+ # Check to see that this really is a libtool archive.
+ func_lalib_unsafe_p "$file" \
+ || func_fatal_help "\`$lib' is not a valid libtool archive"
+
+ # Read the libtool library.
+ dlname=
+ library_names=
+ func_source "$file"
+
+ # Skip this library if it cannot be dlopened.
+ if test -z "$dlname"; then
+ # Warn if it was a shared library.
+ test -n "$library_names" && \
+ func_warning "\`$file' was not linked with \`-export-dynamic'"
+ continue
+ fi
+
+ func_dirname "$file" "" "."
+ dir="$func_dirname_result"
+
+ if test -f "$dir/$objdir/$dlname"; then
+ func_append dir "/$objdir"
+ else
+ if test ! -f "$dir/$dlname"; then
+ func_fatal_error "cannot find \`$dlname' in \`$dir' or \`$dir/$objdir'"
+ fi
+ fi
+ ;;
+
+ *.lo)
+ # Just add the directory containing the .lo file.
+ func_dirname "$file" "" "."
+ dir="$func_dirname_result"
+ ;;
+
+ *)
+ func_warning "\`-dlopen' is ignored for non-libtool libraries and objects"
+ continue
+ ;;
+ esac
+
+ # Get the absolute pathname.
+ absdir=`cd "$dir" && pwd`
+ test -n "$absdir" && dir="$absdir"
+
+ # Now add the directory to shlibpath_var.
+ if eval "test -z \"\$$shlibpath_var\""; then
+ eval "$shlibpath_var=\"\$dir\""
+ else
+ eval "$shlibpath_var=\"\$dir:\$$shlibpath_var\""
+ fi
+ done
+
+ # This variable tells wrapper scripts just to set shlibpath_var
+ # rather than running their programs.
+ libtool_execute_magic="$magic"
+
+ # Check if any of the arguments is a wrapper script.
+ args=
+ for file
+ do
+ case $file in
+ -* | *.la | *.lo ) ;;
+ *)
+ # Do a test to see if this is really a libtool program.
+ if func_ltwrapper_script_p "$file"; then
+ func_source "$file"
+ # Transform arg to wrapped name.
+ file="$progdir/$program"
+ elif func_ltwrapper_executable_p "$file"; then
+ func_ltwrapper_scriptname "$file"
+ func_source "$func_ltwrapper_scriptname_result"
+ # Transform arg to wrapped name.
+ file="$progdir/$program"
+ fi
+ ;;
+ esac
+ # Quote arguments (to preserve shell metacharacters).
+ func_append_quoted args "$file"
+ done
+
+ if test "X$opt_dry_run" = Xfalse; then
+ if test -n "$shlibpath_var"; then
+ # Export the shlibpath_var.
+ eval "export $shlibpath_var"
+ fi
+
+ # Restore saved environment variables
+ for lt_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES
+ do
+ eval "if test \"\${save_$lt_var+set}\" = set; then
+ $lt_var=\$save_$lt_var; export $lt_var
+ else
+ $lt_unset $lt_var
+ fi"
+ done
+
+ # Now prepare to actually exec the command.
+ exec_cmd="\$cmd$args"
+ else
+ # Display what would be done.
+ if test -n "$shlibpath_var"; then
+ eval "\$ECHO \"\$shlibpath_var=\$$shlibpath_var\""
+ echo "export $shlibpath_var"
+ fi
+ $ECHO "$cmd$args"
+ exit $EXIT_SUCCESS
+ fi
+}
+
+test "$opt_mode" = execute && func_mode_execute ${1+"$@"}
+
+
+# func_mode_finish arg...
+func_mode_finish ()
+{
+ $opt_debug
+ libs=
+ libdirs=
+ admincmds=
+
+ for opt in "$nonopt" ${1+"$@"}
+ do
+ if test -d "$opt"; then
+ func_append libdirs " $opt"
+
+ elif test -f "$opt"; then
+ if func_lalib_unsafe_p "$opt"; then
+ func_append libs " $opt"
+ else
+ func_warning "\`$opt' is not a valid libtool archive"
+ fi
+
+ else
+ func_fatal_error "invalid argument \`$opt'"
+ fi
+ done
+
+ if test -n "$libs"; then
+ if test -n "$lt_sysroot"; then
+ sysroot_regex=`$ECHO "$lt_sysroot" | $SED "$sed_make_literal_regex"`
+ sysroot_cmd="s/\([ ']\)$sysroot_regex/\1/g;"
+ else
+ sysroot_cmd=
+ fi
+
+ # Remove sysroot references
+ if $opt_dry_run; then
+ for lib in $libs; do
+ echo "removing references to $lt_sysroot and \`=' prefixes from $lib"
+ done
+ else
+ tmpdir=`func_mktempdir`
+ for lib in $libs; do
+ sed -e "${sysroot_cmd} s/\([ ']-[LR]\)=/\1/g; s/\([ ']\)=/\1/g" $lib \
+ > $tmpdir/tmp-la
+ mv -f $tmpdir/tmp-la $lib
+ done
+ ${RM}r "$tmpdir"
+ fi
+ fi
+
+ if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then
+ for libdir in $libdirs; do
+ if test -n "$finish_cmds"; then
+ # Do each command in the finish commands.
+ func_execute_cmds "$finish_cmds" 'admincmds="$admincmds
+'"$cmd"'"'
+ fi
+ if test -n "$finish_eval"; then
+ # Do the single finish_eval.
+ eval cmds=\"$finish_eval\"
+ $opt_dry_run || eval "$cmds" || func_append admincmds "
+ $cmds"
+ fi
+ done
+ fi
+
+ # Exit here if they wanted silent mode.
+ $opt_silent && exit $EXIT_SUCCESS
+
+ if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then
+ echo "----------------------------------------------------------------------"
+ echo "Libraries have been installed in:"
+ for libdir in $libdirs; do
+ $ECHO " $libdir"
+ done
+ echo
+ echo "If you ever happen to want to link against installed libraries"
+ echo "in a given directory, LIBDIR, you must either use libtool, and"
+ echo "specify the full pathname of the library, or use the \`-LLIBDIR'"
+ echo "flag during linking and do at least one of the following:"
+ if test -n "$shlibpath_var"; then
+ echo " - add LIBDIR to the \`$shlibpath_var' environment variable"
+ echo " during execution"
+ fi
+ if test -n "$runpath_var"; then
+ echo " - add LIBDIR to the \`$runpath_var' environment variable"
+ echo " during linking"
+ fi
+ if test -n "$hardcode_libdir_flag_spec"; then
+ libdir=LIBDIR
+ eval flag=\"$hardcode_libdir_flag_spec\"
+
+ $ECHO " - use the \`$flag' linker flag"
+ fi
+ if test -n "$admincmds"; then
+ $ECHO " - have your system administrator run these commands:$admincmds"
+ fi
+ if test -f /etc/ld.so.conf; then
+ echo " - have your system administrator add LIBDIR to \`/etc/ld.so.conf'"
+ fi
+ echo
+
+ echo "See any operating system documentation about shared libraries for"
+ case $host in
+ solaris2.[6789]|solaris2.1[0-9])
+ echo "more information, such as the ld(1), crle(1) and ld.so(8) manual"
+ echo "pages."
+ ;;
+ *)
+ echo "more information, such as the ld(1) and ld.so(8) manual pages."
+ ;;
+ esac
+ echo "----------------------------------------------------------------------"
+ fi
+ exit $EXIT_SUCCESS
+}
+
+test "$opt_mode" = finish && func_mode_finish ${1+"$@"}
+
+
+# func_mode_install arg...
+func_mode_install ()
+{
+ $opt_debug
+ # There may be an optional sh(1) argument at the beginning of
+ # install_prog (especially on Windows NT).
+ if test "$nonopt" = "$SHELL" || test "$nonopt" = /bin/sh ||
+ # Allow the use of GNU shtool's install command.
+ case $nonopt in *shtool*) :;; *) false;; esac; then
+ # Aesthetically quote it.
+ func_quote_for_eval "$nonopt"
+ install_prog="$func_quote_for_eval_result "
+ arg=$1
+ shift
+ else
+ install_prog=
+ arg=$nonopt
+ fi
+
+ # The real first argument should be the name of the installation program.
+ # Aesthetically quote it.
+ func_quote_for_eval "$arg"
+ func_append install_prog "$func_quote_for_eval_result"
+ install_shared_prog=$install_prog
+ case " $install_prog " in
+ *[\\\ /]cp\ *) install_cp=: ;;
+ *) install_cp=false ;;
+ esac
+
+ # We need to accept at least all the BSD install flags.
+ dest=
+ files=
+ opts=
+ prev=
+ install_type=
+ isdir=no
+ stripme=
+ no_mode=:
+ for arg
+ do
+ arg2=
+ if test -n "$dest"; then
+ func_append files " $dest"
+ dest=$arg
+ continue
+ fi
+
+ case $arg in
+ -d) isdir=yes ;;
+ -f)
+ if $install_cp; then :; else
+ prev=$arg
+ fi
+ ;;
+ -g | -m | -o)
+ prev=$arg
+ ;;
+ -s)
+ stripme=" -s"
+ continue
+ ;;
+ -*)
+ ;;
+ *)
+ # If the previous option needed an argument, then skip it.
+ if test -n "$prev"; then
+ if test "x$prev" = x-m && test -n "$install_override_mode"; then
+ arg2=$install_override_mode
+ no_mode=false
+ fi
+ prev=
+ else
+ dest=$arg
+ continue
+ fi
+ ;;
+ esac
+
+ # Aesthetically quote the argument.
+ func_quote_for_eval "$arg"
+ func_append install_prog " $func_quote_for_eval_result"
+ if test -n "$arg2"; then
+ func_quote_for_eval "$arg2"
+ fi
+ func_append install_shared_prog " $func_quote_for_eval_result"
+ done
+
+ test -z "$install_prog" && \
+ func_fatal_help "you must specify an install program"
+
+ test -n "$prev" && \
+ func_fatal_help "the \`$prev' option requires an argument"
+
+ if test -n "$install_override_mode" && $no_mode; then
+ if $install_cp; then :; else
+ func_quote_for_eval "$install_override_mode"
+ func_append install_shared_prog " -m $func_quote_for_eval_result"
+ fi
+ fi
+
+ if test -z "$files"; then
+ if test -z "$dest"; then
+ func_fatal_help "no file or destination specified"
+ else
+ func_fatal_help "you must specify a destination"
+ fi
+ fi
+
+ # Strip any trailing slash from the destination.
+ func_stripname '' '/' "$dest"
+ dest=$func_stripname_result
+
+ # Check to see that the destination is a directory.
+ test -d "$dest" && isdir=yes
+ if test "$isdir" = yes; then
+ destdir="$dest"
+ destname=
+ else
+ func_dirname_and_basename "$dest" "" "."
+ destdir="$func_dirname_result"
+ destname="$func_basename_result"
+
+ # Not a directory, so check to see that there is only one file specified.
+ set dummy $files; shift
+ test "$#" -gt 1 && \
+ func_fatal_help "\`$dest' is not a directory"
+ fi
+ case $destdir in
+ [\\/]* | [A-Za-z]:[\\/]*) ;;
+ *)
+ for file in $files; do
+ case $file in
+ *.lo) ;;
+ *)
+ func_fatal_help "\`$destdir' must be an absolute directory name"
+ ;;
+ esac
+ done
+ ;;
+ esac
+
+ # This variable tells wrapper scripts just to set variables rather
+ # than running their programs.
+ libtool_install_magic="$magic"
+
+ staticlibs=
+ future_libdirs=
+ current_libdirs=
+ for file in $files; do
+
+ # Do each installation.
+ case $file in
+ *.$libext)
+ # Do the static libraries later.
+ func_append staticlibs " $file"
+ ;;
+
+ *.la)
+ func_resolve_sysroot "$file"
+ file=$func_resolve_sysroot_result
+
+ # Check to see that this really is a libtool archive.
+ func_lalib_unsafe_p "$file" \
+ || func_fatal_help "\`$file' is not a valid libtool archive"
+
+ library_names=
+ old_library=
+ relink_command=
+ func_source "$file"
+
+ # Add the libdir to current_libdirs if it is the destination.
+ if test "X$destdir" = "X$libdir"; then
+ case "$current_libdirs " in
+ *" $libdir "*) ;;
+ *) func_append current_libdirs " $libdir" ;;
+ esac
+ else
+ # Note the libdir as a future libdir.
+ case "$future_libdirs " in
+ *" $libdir "*) ;;
+ *) func_append future_libdirs " $libdir" ;;
+ esac
+ fi
+
+ func_dirname "$file" "/" ""
+ dir="$func_dirname_result"
+ func_append dir "$objdir"
+
+ if test -n "$relink_command"; then
+ # Determine the prefix the user has applied to our future dir.
+ inst_prefix_dir=`$ECHO "$destdir" | $SED -e "s%$libdir\$%%"`
+
+ # Don't allow the user to place us outside of our expected
+ # location b/c this prevents finding dependent libraries that
+ # are installed to the same prefix.
+ # At present, this check doesn't affect windows .dll's that
+ # are installed into $libdir/../bin (currently, that works fine)
+ # but it's something to keep an eye on.
+ test "$inst_prefix_dir" = "$destdir" && \
+ func_fatal_error "error: cannot install \`$file' to a directory not ending in $libdir"
+
+ if test -n "$inst_prefix_dir"; then
+ # Stick the inst_prefix_dir data into the link command.
+ relink_command=`$ECHO "$relink_command" | $SED "s%@inst_prefix_dir@%-inst-prefix-dir $inst_prefix_dir%"`
+ else
+ relink_command=`$ECHO "$relink_command" | $SED "s%@inst_prefix_dir@%%"`
+ fi
+
+ func_warning "relinking \`$file'"
+ func_show_eval "$relink_command" \
+ 'func_fatal_error "error: relink \`$file'\'' with the above command before installing it"'
+ fi
+
+ # See the names of the shared library.
+ set dummy $library_names; shift
+ if test -n "$1"; then
+ realname="$1"
+ shift
+
+ srcname="$realname"
+ test -n "$relink_command" && srcname="$realname"T
+
+ # Install the shared library and build the symlinks.
+ func_show_eval "$install_shared_prog $dir/$srcname $destdir/$realname" \
+ 'exit $?'
+ tstripme="$stripme"
+ case $host_os in
+ cygwin* | mingw* | pw32* | cegcc*)
+ case $realname in
+ *.dll.a)
+ tstripme=""
+ ;;
+ esac
+ ;;
+ esac
+ if test -n "$tstripme" && test -n "$striplib"; then
+ func_show_eval "$striplib $destdir/$realname" 'exit $?'
+ fi
+
+ if test "$#" -gt 0; then
+ # Delete the old symlinks, and create new ones.
+ # Try `ln -sf' first, because the `ln' binary might depend on
+ # the symlink we replace! Solaris /bin/ln does not understand -f,
+ # so we also need to try rm && ln -s.
+ for linkname
+ do
+ test "$linkname" != "$realname" \
+ && func_show_eval "(cd $destdir && { $LN_S -f $realname $linkname || { $RM $linkname && $LN_S $realname $linkname; }; })"
+ done
+ fi
+
+ # Do each command in the postinstall commands.
+ lib="$destdir/$realname"
+ func_execute_cmds "$postinstall_cmds" 'exit $?'
+ fi
+
+ # Install the pseudo-library for information purposes.
+ func_basename "$file"
+ name="$func_basename_result"
+ instname="$dir/$name"i
+ func_show_eval "$install_prog $instname $destdir/$name" 'exit $?'
+
+ # Maybe install the static library, too.
+ test -n "$old_library" && func_append staticlibs " $dir/$old_library"
+ ;;
+
+ *.lo)
+ # Install (i.e. copy) a libtool object.
+
+ # Figure out destination file name, if it wasn't already specified.
+ if test -n "$destname"; then
+ destfile="$destdir/$destname"
+ else
+ func_basename "$file"
+ destfile="$func_basename_result"
+ destfile="$destdir/$destfile"
+ fi
+
+ # Deduce the name of the destination old-style object file.
+ case $destfile in
+ *.lo)
+ func_lo2o "$destfile"
+ staticdest=$func_lo2o_result
+ ;;
+ *.$objext)
+ staticdest="$destfile"
+ destfile=
+ ;;
+ *)
+ func_fatal_help "cannot copy a libtool object to \`$destfile'"
+ ;;
+ esac
+
+ # Install the libtool object if requested.
+ test -n "$destfile" && \
+ func_show_eval "$install_prog $file $destfile" 'exit $?'
+
+ # Install the old object if enabled.
+ if test "$build_old_libs" = yes; then
+ # Deduce the name of the old-style object file.
+ func_lo2o "$file"
+ staticobj=$func_lo2o_result
+ func_show_eval "$install_prog \$staticobj \$staticdest" 'exit $?'
+ fi
+ exit $EXIT_SUCCESS
+ ;;
+
+ *)
+ # Figure out destination file name, if it wasn't already specified.
+ if test -n "$destname"; then
+ destfile="$destdir/$destname"
+ else
+ func_basename "$file"
+ destfile="$func_basename_result"
+ destfile="$destdir/$destfile"
+ fi
+
+ # If the file is missing, and there is a .exe on the end, strip it
+ # because it is most likely a libtool script we actually want to
+ # install
+ stripped_ext=""
+ case $file in
+ *.exe)
+ if test ! -f "$file"; then
+ func_stripname '' '.exe' "$file"
+ file=$func_stripname_result
+ stripped_ext=".exe"
+ fi
+ ;;
+ esac
+
+ # Do a test to see if this is really a libtool program.
+ case $host in
+ *cygwin* | *mingw*)
+ if func_ltwrapper_executable_p "$file"; then
+ func_ltwrapper_scriptname "$file"
+ wrapper=$func_ltwrapper_scriptname_result
+ else
+ func_stripname '' '.exe' "$file"
+ wrapper=$func_stripname_result
+ fi
+ ;;
+ *)
+ wrapper=$file
+ ;;
+ esac
+ if func_ltwrapper_script_p "$wrapper"; then
+ notinst_deplibs=
+ relink_command=
+
+ func_source "$wrapper"
+
+ # Check the variables that should have been set.
+ test -z "$generated_by_libtool_version" && \
+ func_fatal_error "invalid libtool wrapper script \`$wrapper'"
+
+ finalize=yes
+ for lib in $notinst_deplibs; do
+ # Check to see that each library is installed.
+ libdir=
+ if test -f "$lib"; then
+ func_source "$lib"
+ fi
+ libfile="$libdir/"`$ECHO "$lib" | $SED 's%^.*/%%g'` ### testsuite: skip nested quoting test
+ if test -n "$libdir" && test ! -f "$libfile"; then
+ func_warning "\`$lib' has not been installed in \`$libdir'"
+ finalize=no
+ fi
+ done
+
+ relink_command=
+ func_source "$wrapper"
+
+ outputname=
+ if test "$fast_install" = no && test -n "$relink_command"; then
+ $opt_dry_run || {
+ if test "$finalize" = yes; then
+ tmpdir=`func_mktempdir`
+ func_basename "$file$stripped_ext"
+ file="$func_basename_result"
+ outputname="$tmpdir/$file"
+ # Replace the output file specification.
+ relink_command=`$ECHO "$relink_command" | $SED 's%@OUTPUT@%'"$outputname"'%g'`
+
+ $opt_silent || {
+ func_quote_for_expand "$relink_command"
+ eval "func_echo $func_quote_for_expand_result"
+ }
+ if eval "$relink_command"; then :
+ else
+ func_error "error: relink \`$file' with the above command before installing it"
+ $opt_dry_run || ${RM}r "$tmpdir"
+ continue
+ fi
+ file="$outputname"
+ else
+ func_warning "cannot relink \`$file'"
+ fi
+ }
+ else
+ # Install the binary that we compiled earlier.
+ file=`$ECHO "$file$stripped_ext" | $SED "s%\([^/]*\)$%$objdir/\1%"`
+ fi
+ fi
+
+ # remove .exe since cygwin /usr/bin/install will append another
+ # one anyway
+ case $install_prog,$host in
+ */usr/bin/install*,*cygwin*)
+ case $file:$destfile in
+ *.exe:*.exe)
+ # this is ok
+ ;;
+ *.exe:*)
+ destfile=$destfile.exe
+ ;;
+ *:*.exe)
+ func_stripname '' '.exe' "$destfile"
+ destfile=$func_stripname_result
+ ;;
+ esac
+ ;;
+ esac
+ func_show_eval "$install_prog\$stripme \$file \$destfile" 'exit $?'
+ $opt_dry_run || if test -n "$outputname"; then
+ ${RM}r "$tmpdir"
+ fi
+ ;;
+ esac
+ done
+
+ for file in $staticlibs; do
+ func_basename "$file"
+ name="$func_basename_result"
+
+ # Set up the ranlib parameters.
+ oldlib="$destdir/$name"
+ func_to_tool_file "$oldlib" func_convert_file_msys_to_w32
+ tool_oldlib=$func_to_tool_file_result
+
+ func_show_eval "$install_prog \$file \$oldlib" 'exit $?'
+
+ if test -n "$stripme" && test -n "$old_striplib"; then
+ func_show_eval "$old_striplib $tool_oldlib" 'exit $?'
+ fi
+
+ # Do each command in the postinstall commands.
+ func_execute_cmds "$old_postinstall_cmds" 'exit $?'
+ done
+
+ test -n "$future_libdirs" && \
+ func_warning "remember to run \`$progname --finish$future_libdirs'"
+
+ if test -n "$current_libdirs"; then
+ # Maybe just do a dry run.
+ $opt_dry_run && current_libdirs=" -n$current_libdirs"
+ exec_cmd='$SHELL $progpath $preserve_args --finish$current_libdirs'
+ else
+ exit $EXIT_SUCCESS
+ fi
+}
+
+test "$opt_mode" = install && func_mode_install ${1+"$@"}
+
+
+# func_generate_dlsyms outputname originator pic_p
+# Extract symbols from dlprefiles and create ${outputname}S.o with
+# a dlpreopen symbol table.
+func_generate_dlsyms ()
+{
+ $opt_debug
+ my_outputname="$1"
+ my_originator="$2"
+ my_pic_p="${3-no}"
+ my_prefix=`$ECHO "$my_originator" | sed 's%[^a-zA-Z0-9]%_%g'`
+ my_dlsyms=
+
+ if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then
+ if test -n "$NM" && test -n "$global_symbol_pipe"; then
+ my_dlsyms="${my_outputname}S.c"
+ else
+ func_error "not configured to extract global symbols from dlpreopened files"
+ fi
+ fi
+
+ if test -n "$my_dlsyms"; then
+ case $my_dlsyms in
+ "") ;;
+ *.c)
+ # Discover the nlist of each of the dlfiles.
+ nlist="$output_objdir/${my_outputname}.nm"
+
+ func_show_eval "$RM $nlist ${nlist}S ${nlist}T"
+
+ # Parse the name list into a source file.
+ func_verbose "creating $output_objdir/$my_dlsyms"
+
+ $opt_dry_run || $ECHO > "$output_objdir/$my_dlsyms" "\
+/* $my_dlsyms - symbol resolution table for \`$my_outputname' dlsym emulation. */
+/* Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION */
+
+#ifdef __cplusplus
+extern \"C\" {
+#endif
+
+#if defined(__GNUC__) && (((__GNUC__ == 4) && (__GNUC_MINOR__ >= 4)) || (__GNUC__ > 4))
+#pragma GCC diagnostic ignored \"-Wstrict-prototypes\"
+#endif
+
+/* Keep this code in sync between libtool.m4, ltmain, lt_system.h, and tests. */
+#if defined(_WIN32) || defined(__CYGWIN__) || defined(_WIN32_WCE)
+/* DATA imports from DLLs on WIN32 con't be const, because runtime
+ relocations are performed -- see ld's documentation on pseudo-relocs. */
+# define LT_DLSYM_CONST
+#elif defined(__osf__)
+/* This system does not cope well with relocations in const data. */
+# define LT_DLSYM_CONST
+#else
+# define LT_DLSYM_CONST const
+#endif
+
+/* External symbol declarations for the compiler. */\
+"
+
+ if test "$dlself" = yes; then
+ func_verbose "generating symbol list for \`$output'"
+
+ $opt_dry_run || echo ': @PROGRAM@ ' > "$nlist"
+
+ # Add our own program objects to the symbol list.
+ progfiles=`$ECHO "$objs$old_deplibs" | $SP2NL | $SED "$lo2o" | $NL2SP`
+ for progfile in $progfiles; do
+ func_to_tool_file "$progfile" func_convert_file_msys_to_w32
+ func_verbose "extracting global C symbols from \`$func_to_tool_file_result'"
+ $opt_dry_run || eval "$NM $func_to_tool_file_result | $global_symbol_pipe >> '$nlist'"
+ done
+
+ if test -n "$exclude_expsyms"; then
+ $opt_dry_run || {
+ eval '$EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T'
+ eval '$MV "$nlist"T "$nlist"'
+ }
+ fi
+
+ if test -n "$export_symbols_regex"; then
+ $opt_dry_run || {
+ eval '$EGREP -e "$export_symbols_regex" "$nlist" > "$nlist"T'
+ eval '$MV "$nlist"T "$nlist"'
+ }
+ fi
+
+ # Prepare the list of exported symbols
+ if test -z "$export_symbols"; then
+ export_symbols="$output_objdir/$outputname.exp"
+ $opt_dry_run || {
+ $RM $export_symbols
+ eval "${SED} -n -e '/^: @PROGRAM@ $/d' -e 's/^.* \(.*\)$/\1/p' "'< "$nlist" > "$export_symbols"'
+ case $host in
+ *cygwin* | *mingw* | *cegcc* )
+ eval "echo EXPORTS "'> "$output_objdir/$outputname.def"'
+ eval 'cat "$export_symbols" >> "$output_objdir/$outputname.def"'
+ ;;
+ esac
+ }
+ else
+ $opt_dry_run || {
+ eval "${SED} -e 's/\([].[*^$]\)/\\\\\1/g' -e 's/^/ /' -e 's/$/$/'"' < "$export_symbols" > "$output_objdir/$outputname.exp"'
+ eval '$GREP -f "$output_objdir/$outputname.exp" < "$nlist" > "$nlist"T'
+ eval '$MV "$nlist"T "$nlist"'
+ case $host in
+ *cygwin* | *mingw* | *cegcc* )
+ eval "echo EXPORTS "'> "$output_objdir/$outputname.def"'
+ eval 'cat "$nlist" >> "$output_objdir/$outputname.def"'
+ ;;
+ esac
+ }
+ fi
+ fi
+
+ for dlprefile in $dlprefiles; do
+ func_verbose "extracting global C symbols from \`$dlprefile'"
+ func_basename "$dlprefile"
+ name="$func_basename_result"
+ case $host in
+ *cygwin* | *mingw* | *cegcc* )
+ # if an import library, we need to obtain dlname
+ if func_win32_import_lib_p "$dlprefile"; then
+ func_tr_sh "$dlprefile"
+ eval "curr_lafile=\$libfile_$func_tr_sh_result"
+ dlprefile_dlbasename=""
+ if test -n "$curr_lafile" && func_lalib_p "$curr_lafile"; then
+ # Use subshell, to avoid clobbering current variable values
+ dlprefile_dlname=`source "$curr_lafile" && echo "$dlname"`
+ if test -n "$dlprefile_dlname" ; then
+ func_basename "$dlprefile_dlname"
+ dlprefile_dlbasename="$func_basename_result"
+ else
+ # no lafile. user explicitly requested -dlpreopen <import library>.
+ $sharedlib_from_linklib_cmd "$dlprefile"
+ dlprefile_dlbasename=$sharedlib_from_linklib_result
+ fi
+ fi
+ $opt_dry_run || {
+ if test -n "$dlprefile_dlbasename" ; then
+ eval '$ECHO ": $dlprefile_dlbasename" >> "$nlist"'
+ else
+ func_warning "Could not compute DLL name from $name"
+ eval '$ECHO ": $name " >> "$nlist"'
+ fi
+ func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32
+ eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe |
+ $SED -e '/I __imp/d' -e 's/I __nm_/D /;s/_nm__//' >> '$nlist'"
+ }
+ else # not an import lib
+ $opt_dry_run || {
+ eval '$ECHO ": $name " >> "$nlist"'
+ func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32
+ eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe >> '$nlist'"
+ }
+ fi
+ ;;
+ *)
+ $opt_dry_run || {
+ eval '$ECHO ": $name " >> "$nlist"'
+ func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32
+ eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe >> '$nlist'"
+ }
+ ;;
+ esac
+ done
+
+ $opt_dry_run || {
+ # Make sure we have at least an empty file.
+ test -f "$nlist" || : > "$nlist"
+
+ if test -n "$exclude_expsyms"; then
+ $EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T
+ $MV "$nlist"T "$nlist"
+ fi
+
+ # Try sorting and uniquifying the output.
+ if $GREP -v "^: " < "$nlist" |
+ if sort -k 3 </dev/null >/dev/null 2>&1; then
+ sort -k 3
+ else
+ sort +2
+ fi |
+ uniq > "$nlist"S; then
+ :
+ else
+ $GREP -v "^: " < "$nlist" > "$nlist"S
+ fi
+
+ if test -f "$nlist"S; then
+ eval "$global_symbol_to_cdecl"' < "$nlist"S >> "$output_objdir/$my_dlsyms"'
+ else
+ echo '/* NONE */' >> "$output_objdir/$my_dlsyms"
+ fi
+
+ echo >> "$output_objdir/$my_dlsyms" "\
+
+/* The mapping between symbol names and symbols. */
+typedef struct {
+ const char *name;
+ void *address;
+} lt_dlsymlist;
+extern LT_DLSYM_CONST lt_dlsymlist
+lt_${my_prefix}_LTX_preloaded_symbols[];
+LT_DLSYM_CONST lt_dlsymlist
+lt_${my_prefix}_LTX_preloaded_symbols[] =
+{\
+ { \"$my_originator\", (void *) 0 },"
+
+ case $need_lib_prefix in
+ no)
+ eval "$global_symbol_to_c_name_address" < "$nlist" >> "$output_objdir/$my_dlsyms"
+ ;;
+ *)
+ eval "$global_symbol_to_c_name_address_lib_prefix" < "$nlist" >> "$output_objdir/$my_dlsyms"
+ ;;
+ esac
+ echo >> "$output_objdir/$my_dlsyms" "\
+ {0, (void *) 0}
+};
+
+/* This works around a problem in FreeBSD linker */
+#ifdef FREEBSD_WORKAROUND
+static const void *lt_preloaded_setup() {
+ return lt_${my_prefix}_LTX_preloaded_symbols;
+}
+#endif
+
+#ifdef __cplusplus
+}
+#endif\
+"
+ } # !$opt_dry_run
+
+ pic_flag_for_symtable=
+ case "$compile_command " in
+ *" -static "*) ;;
+ *)
+ case $host in
+ # compiling the symbol table file with pic_flag works around
+ # a FreeBSD bug that causes programs to crash when -lm is
+ # linked before any other PIC object. But we must not use
+ # pic_flag when linking with -static. The problem exists in
+ # FreeBSD 2.2.6 and is fixed in FreeBSD 3.1.
+ *-*-freebsd2.*|*-*-freebsd3.0*|*-*-freebsdelf3.0*)
+ pic_flag_for_symtable=" $pic_flag -DFREEBSD_WORKAROUND" ;;
+ *-*-hpux*)
+ pic_flag_for_symtable=" $pic_flag" ;;
+ *)
+ if test "X$my_pic_p" != Xno; then
+ pic_flag_for_symtable=" $pic_flag"
+ fi
+ ;;
+ esac
+ ;;
+ esac
+ symtab_cflags=
+ for arg in $LTCFLAGS; do
+ case $arg in
+ -pie | -fpie | -fPIE) ;;
+ *) func_append symtab_cflags " $arg" ;;
+ esac
+ done
+
+ # Now compile the dynamic symbol file.
+ func_show_eval '(cd $output_objdir && $LTCC$symtab_cflags -c$no_builtin_flag$pic_flag_for_symtable "$my_dlsyms")' 'exit $?'
+
+ # Clean up the generated files.
+ func_show_eval '$RM "$output_objdir/$my_dlsyms" "$nlist" "${nlist}S" "${nlist}T"'
+
+ # Transform the symbol file into the correct name.
+ symfileobj="$output_objdir/${my_outputname}S.$objext"
+ case $host in
+ *cygwin* | *mingw* | *cegcc* )
+ if test -f "$output_objdir/$my_outputname.def"; then
+ compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"`
+ finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"`
+ else
+ compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$symfileobj%"`
+ finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$symfileobj%"`
+ fi
+ ;;
+ *)
+ compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$symfileobj%"`
+ finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$symfileobj%"`
+ ;;
+ esac
+ ;;
+ *)
+ func_fatal_error "unknown suffix for \`$my_dlsyms'"
+ ;;
+ esac
+ else
+ # We keep going just in case the user didn't refer to
+ # lt_preloaded_symbols. The linker will fail if global_symbol_pipe
+ # really was required.
+
+ # Nullify the symbol file.
+ compile_command=`$ECHO "$compile_command" | $SED "s% @SYMFILE@%%"`
+ finalize_command=`$ECHO "$finalize_command" | $SED "s% @SYMFILE@%%"`
+ fi
+}
+
+# func_win32_libid arg
+# return the library type of file 'arg'
+#
+# Need a lot of goo to handle *both* DLLs and import libs
+# Has to be a shell function in order to 'eat' the argument
+# that is supplied when $file_magic_command is called.
+# Despite the name, also deal with 64 bit binaries.
+func_win32_libid ()
+{
+ $opt_debug
+ win32_libid_type="unknown"
+ win32_fileres=`file -L $1 2>/dev/null`
+ case $win32_fileres in
+ *ar\ archive\ import\ library*) # definitely import
+ win32_libid_type="x86 archive import"
+ ;;
+ *ar\ archive*) # could be an import, or static
+ # Keep the egrep pattern in sync with the one in _LT_CHECK_MAGIC_METHOD.
+ if eval $OBJDUMP -f $1 | $SED -e '10q' 2>/dev/null |
+ $EGREP 'file format (pei*-i386(.*architecture: i386)?|pe-arm-wince|pe-x86-64)' >/dev/null; then
+ func_to_tool_file "$1" func_convert_file_msys_to_w32
+ win32_nmres=`eval $NM -f posix -A \"$func_to_tool_file_result\" |
+ $SED -n -e '
+ 1,100{
+ / I /{
+ s,.*,import,
+ p
+ q
+ }
+ }'`
+ case $win32_nmres in
+ import*) win32_libid_type="x86 archive import";;
+ *) win32_libid_type="x86 archive static";;
+ esac
+ fi
+ ;;
+ *DLL*)
+ win32_libid_type="x86 DLL"
+ ;;
+ *executable*) # but shell scripts are "executable" too...
+ case $win32_fileres in
+ *MS\ Windows\ PE\ Intel*)
+ win32_libid_type="x86 DLL"
+ ;;
+ esac
+ ;;
+ esac
+ $ECHO "$win32_libid_type"
+}
+
+# func_cygming_dll_for_implib ARG
+#
+# Platform-specific function to extract the
+# name of the DLL associated with the specified
+# import library ARG.
+# Invoked by eval'ing the libtool variable
+# $sharedlib_from_linklib_cmd
+# Result is available in the variable
+# $sharedlib_from_linklib_result
+func_cygming_dll_for_implib ()
+{
+ $opt_debug
+ sharedlib_from_linklib_result=`$DLLTOOL --identify-strict --identify "$1"`
+}
+
+# func_cygming_dll_for_implib_fallback_core SECTION_NAME LIBNAMEs
+#
+# The is the core of a fallback implementation of a
+# platform-specific function to extract the name of the
+# DLL associated with the specified import library LIBNAME.
+#
+# SECTION_NAME is either .idata$6 or .idata$7, depending
+# on the platform and compiler that created the implib.
+#
+# Echos the name of the DLL associated with the
+# specified import library.
+func_cygming_dll_for_implib_fallback_core ()
+{
+ $opt_debug
+ match_literal=`$ECHO "$1" | $SED "$sed_make_literal_regex"`
+ $OBJDUMP -s --section "$1" "$2" 2>/dev/null |
+ $SED '/^Contents of section '"$match_literal"':/{
+ # Place marker at beginning of archive member dllname section
+ s/.*/====MARK====/
+ p
+ d
+ }
+ # These lines can sometimes be longer than 43 characters, but
+ # are always uninteresting
+ /:[ ]*file format pe[i]\{,1\}-/d
+ /^In archive [^:]*:/d
+ # Ensure marker is printed
+ /^====MARK====/p
+ # Remove all lines with less than 43 characters
+ /^.\{43\}/!d
+ # From remaining lines, remove first 43 characters
+ s/^.\{43\}//' |
+ $SED -n '
+ # Join marker and all lines until next marker into a single line
+ /^====MARK====/ b para
+ H
+ $ b para
+ b
+ :para
+ x
+ s/\n//g
+ # Remove the marker
+ s/^====MARK====//
+ # Remove trailing dots and whitespace
+ s/[\. \t]*$//
+ # Print
+ /./p' |
+ # we now have a list, one entry per line, of the stringified
+ # contents of the appropriate section of all members of the
+ # archive which possess that section. Heuristic: eliminate
+ # all those which have a first or second character that is
+ # a '.' (that is, objdump's representation of an unprintable
+ # character.) This should work for all archives with less than
+ # 0x302f exports -- but will fail for DLLs whose name actually
+ # begins with a literal '.' or a single character followed by
+ # a '.'.
+ #
+ # Of those that remain, print the first one.
+ $SED -e '/^\./d;/^.\./d;q'
+}
+
+# func_cygming_gnu_implib_p ARG
+# This predicate returns with zero status (TRUE) if
+# ARG is a GNU/binutils-style import library. Returns
+# with nonzero status (FALSE) otherwise.
+func_cygming_gnu_implib_p ()
+{
+ $opt_debug
+ func_to_tool_file "$1" func_convert_file_msys_to_w32
+ func_cygming_gnu_implib_tmp=`$NM "$func_to_tool_file_result" | eval "$global_symbol_pipe" | $EGREP ' (_head_[A-Za-z0-9_]+_[ad]l*|[A-Za-z0-9_]+_[ad]l*_iname)$'`
+ test -n "$func_cygming_gnu_implib_tmp"
+}
+
+# func_cygming_ms_implib_p ARG
+# This predicate returns with zero status (TRUE) if
+# ARG is an MS-style import library. Returns
+# with nonzero status (FALSE) otherwise.
+func_cygming_ms_implib_p ()
+{
+ $opt_debug
+ func_to_tool_file "$1" func_convert_file_msys_to_w32
+ func_cygming_ms_implib_tmp=`$NM "$func_to_tool_file_result" | eval "$global_symbol_pipe" | $GREP '_NULL_IMPORT_DESCRIPTOR'`
+ test -n "$func_cygming_ms_implib_tmp"
+}
+
+# func_cygming_dll_for_implib_fallback ARG
+# Platform-specific function to extract the
+# name of the DLL associated with the specified
+# import library ARG.
+#
+# This fallback implementation is for use when $DLLTOOL
+# does not support the --identify-strict option.
+# Invoked by eval'ing the libtool variable
+# $sharedlib_from_linklib_cmd
+# Result is available in the variable
+# $sharedlib_from_linklib_result
+func_cygming_dll_for_implib_fallback ()
+{
+ $opt_debug
+ if func_cygming_gnu_implib_p "$1" ; then
+ # binutils import library
+ sharedlib_from_linklib_result=`func_cygming_dll_for_implib_fallback_core '.idata$7' "$1"`
+ elif func_cygming_ms_implib_p "$1" ; then
+ # ms-generated import library
+ sharedlib_from_linklib_result=`func_cygming_dll_for_implib_fallback_core '.idata$6' "$1"`
+ else
+ # unknown
+ sharedlib_from_linklib_result=""
+ fi
+}
+
+
+# func_extract_an_archive dir oldlib
+func_extract_an_archive ()
+{
+ $opt_debug
+ f_ex_an_ar_dir="$1"; shift
+ f_ex_an_ar_oldlib="$1"
+ if test "$lock_old_archive_extraction" = yes; then
+ lockfile=$f_ex_an_ar_oldlib.lock
+ until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do
+ func_echo "Waiting for $lockfile to be removed"
+ sleep 2
+ done
+ fi
+ func_show_eval "(cd \$f_ex_an_ar_dir && $AR x \"\$f_ex_an_ar_oldlib\")" \
+ 'stat=$?; rm -f "$lockfile"; exit $stat'
+ if test "$lock_old_archive_extraction" = yes; then
+ $opt_dry_run || rm -f "$lockfile"
+ fi
+ if ($AR t "$f_ex_an_ar_oldlib" | sort | sort -uc >/dev/null 2>&1); then
+ :
+ else
+ func_fatal_error "object name conflicts in archive: $f_ex_an_ar_dir/$f_ex_an_ar_oldlib"
+ fi
+}
+
+
+# func_extract_archives gentop oldlib ...
+func_extract_archives ()
+{
+ $opt_debug
+ my_gentop="$1"; shift
+ my_oldlibs=${1+"$@"}
+ my_oldobjs=""
+ my_xlib=""
+ my_xabs=""
+ my_xdir=""
+
+ for my_xlib in $my_oldlibs; do
+ # Extract the objects.
+ case $my_xlib in
+ [\\/]* | [A-Za-z]:[\\/]*) my_xabs="$my_xlib" ;;
+ *) my_xabs=`pwd`"/$my_xlib" ;;
+ esac
+ func_basename "$my_xlib"
+ my_xlib="$func_basename_result"
+ my_xlib_u=$my_xlib
+ while :; do
+ case " $extracted_archives " in
+ *" $my_xlib_u "*)
+ func_arith $extracted_serial + 1
+ extracted_serial=$func_arith_result
+ my_xlib_u=lt$extracted_serial-$my_xlib ;;
+ *) break ;;
+ esac
+ done
+ extracted_archives="$extracted_archives $my_xlib_u"
+ my_xdir="$my_gentop/$my_xlib_u"
+
+ func_mkdir_p "$my_xdir"
+
+ case $host in
+ *-darwin*)
+ func_verbose "Extracting $my_xabs"
+ # Do not bother doing anything if just a dry run
+ $opt_dry_run || {
+ darwin_orig_dir=`pwd`
+ cd $my_xdir || exit $?
+ darwin_archive=$my_xabs
+ darwin_curdir=`pwd`
+ darwin_base_archive=`basename "$darwin_archive"`
+ darwin_arches=`$LIPO -info "$darwin_archive" 2>/dev/null | $GREP Architectures 2>/dev/null || true`
+ if test -n "$darwin_arches"; then
+ darwin_arches=`$ECHO "$darwin_arches" | $SED -e 's/.*are://'`
+ darwin_arch=
+ func_verbose "$darwin_base_archive has multiple architectures $darwin_arches"
+ for darwin_arch in $darwin_arches ; do
+ func_mkdir_p "unfat-$$/${darwin_base_archive}-${darwin_arch}"
+ $LIPO -thin $darwin_arch -output "unfat-$$/${darwin_base_archive}-${darwin_arch}/${darwin_base_archive}" "${darwin_archive}"
+ cd "unfat-$$/${darwin_base_archive}-${darwin_arch}"
+ func_extract_an_archive "`pwd`" "${darwin_base_archive}"
+ cd "$darwin_curdir"
+ $RM "unfat-$$/${darwin_base_archive}-${darwin_arch}/${darwin_base_archive}"
+ done # $darwin_arches
+ ## Okay now we've a bunch of thin objects, gotta fatten them up :)
+ darwin_filelist=`find unfat-$$ -type f -name \*.o -print -o -name \*.lo -print | $SED -e "$basename" | sort -u`
+ darwin_file=
+ darwin_files=
+ for darwin_file in $darwin_filelist; do
+ darwin_files=`find unfat-$$ -name $darwin_file -print | sort | $NL2SP`
+ $LIPO -create -output "$darwin_file" $darwin_files
+ done # $darwin_filelist
+ $RM -rf unfat-$$
+ cd "$darwin_orig_dir"
+ else
+ cd $darwin_orig_dir
+ func_extract_an_archive "$my_xdir" "$my_xabs"
+ fi # $darwin_arches
+ } # !$opt_dry_run
+ ;;
+ *)
+ func_extract_an_archive "$my_xdir" "$my_xabs"
+ ;;
+ esac
+ my_oldobjs="$my_oldobjs "`find $my_xdir -name \*.$objext -print -o -name \*.lo -print | sort | $NL2SP`
+ done
+
+ func_extract_archives_result="$my_oldobjs"
+}
+
+
+# func_emit_wrapper [arg=no]
+#
+# Emit a libtool wrapper script on stdout.
+# Don't directly open a file because we may want to
+# incorporate the script contents within a cygwin/mingw
+# wrapper executable. Must ONLY be called from within
+# func_mode_link because it depends on a number of variables
+# set therein.
+#
+# ARG is the value that the WRAPPER_SCRIPT_BELONGS_IN_OBJDIR
+# variable will take. If 'yes', then the emitted script
+# will assume that the directory in which it is stored is
+# the $objdir directory. This is a cygwin/mingw-specific
+# behavior.
+func_emit_wrapper ()
+{
+ func_emit_wrapper_arg1=${1-no}
+
+ $ECHO "\
+#! $SHELL
+
+# $output - temporary wrapper script for $objdir/$outputname
+# Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION
+#
+# The $output program cannot be directly executed until all the libtool
+# libraries that it depends on are installed.
+#
+# This wrapper script should never be moved out of the build directory.
+# If it is, it will not operate correctly.
+
+# Sed substitution that helps us do robust quoting. It backslashifies
+# metacharacters that are still active within double-quoted strings.
+sed_quote_subst='$sed_quote_subst'
+
+# Be Bourne compatible
+if test -n \"\${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then
+ emulate sh
+ NULLCMD=:
+ # Zsh 3.x and 4.x performs word splitting on \${1+\"\$@\"}, which
+ # is contrary to our usage. Disable this feature.
+ alias -g '\${1+\"\$@\"}'='\"\$@\"'
+ setopt NO_GLOB_SUBST
+else
+ case \`(set -o) 2>/dev/null\` in *posix*) set -o posix;; esac
+fi
+BIN_SH=xpg4; export BIN_SH # for Tru64
+DUALCASE=1; export DUALCASE # for MKS sh
+
+# The HP-UX ksh and POSIX shell print the target directory to stdout
+# if CDPATH is set.
+(unset CDPATH) >/dev/null 2>&1 && unset CDPATH
+
+relink_command=\"$relink_command\"
+
+# This environment variable determines our operation mode.
+if test \"\$libtool_install_magic\" = \"$magic\"; then
+ # install mode needs the following variables:
+ generated_by_libtool_version='$macro_version'
+ notinst_deplibs='$notinst_deplibs'
+else
+ # When we are sourced in execute mode, \$file and \$ECHO are already set.
+ if test \"\$libtool_execute_magic\" != \"$magic\"; then
+ file=\"\$0\""
+
+ qECHO=`$ECHO "$ECHO" | $SED "$sed_quote_subst"`
+ $ECHO "\
+
+# A function that is used when there is no print builtin or printf.
+func_fallback_echo ()
+{
+ eval 'cat <<_LTECHO_EOF
+\$1
+_LTECHO_EOF'
+}
+ ECHO=\"$qECHO\"
+ fi
+
+# Very basic option parsing. These options are (a) specific to
+# the libtool wrapper, (b) are identical between the wrapper
+# /script/ and the wrapper /executable/ which is used only on
+# windows platforms, and (c) all begin with the string "--lt-"
+# (application programs are unlikely to have options which match
+# this pattern).
+#
+# There are only two supported options: --lt-debug and
+# --lt-dump-script. There is, deliberately, no --lt-help.
+#
+# The first argument to this parsing function should be the
+# script's $0 value, followed by "$@".
+lt_option_debug=
+func_parse_lt_options ()
+{
+ lt_script_arg0=\$0
+ shift
+ for lt_opt
+ do
+ case \"\$lt_opt\" in
+ --lt-debug) lt_option_debug=1 ;;
+ --lt-dump-script)
+ lt_dump_D=\`\$ECHO \"X\$lt_script_arg0\" | $SED -e 's/^X//' -e 's%/[^/]*$%%'\`
+ test \"X\$lt_dump_D\" = \"X\$lt_script_arg0\" && lt_dump_D=.
+ lt_dump_F=\`\$ECHO \"X\$lt_script_arg0\" | $SED -e 's/^X//' -e 's%^.*/%%'\`
+ cat \"\$lt_dump_D/\$lt_dump_F\"
+ exit 0
+ ;;
+ --lt-*)
+ \$ECHO \"Unrecognized --lt- option: '\$lt_opt'\" 1>&2
+ exit 1
+ ;;
+ esac
+ done
+
+ # Print the debug banner immediately:
+ if test -n \"\$lt_option_debug\"; then
+ echo \"${outputname}:${output}:\${LINENO}: libtool wrapper (GNU $PACKAGE$TIMESTAMP) $VERSION\" 1>&2
+ fi
+}
+
+# Used when --lt-debug. Prints its arguments to stdout
+# (redirection is the responsibility of the caller)
+func_lt_dump_args ()
+{
+ lt_dump_args_N=1;
+ for lt_arg
+ do
+ \$ECHO \"${outputname}:${output}:\${LINENO}: newargv[\$lt_dump_args_N]: \$lt_arg\"
+ lt_dump_args_N=\`expr \$lt_dump_args_N + 1\`
+ done
+}
+
+# Core function for launching the target application
+func_exec_program_core ()
+{
+"
+ case $host in
+ # Backslashes separate directories on plain windows
+ *-*-mingw | *-*-os2* | *-cegcc*)
+ $ECHO "\
+ if test -n \"\$lt_option_debug\"; then
+ \$ECHO \"${outputname}:${output}:\${LINENO}: newargv[0]: \$progdir\\\\\$program\" 1>&2
+ func_lt_dump_args \${1+\"\$@\"} 1>&2
+ fi
+ exec \"\$progdir\\\\\$program\" \${1+\"\$@\"}
+"
+ ;;
+
+ *)
+ $ECHO "\
+ if test -n \"\$lt_option_debug\"; then
+ \$ECHO \"${outputname}:${output}:\${LINENO}: newargv[0]: \$progdir/\$program\" 1>&2
+ func_lt_dump_args \${1+\"\$@\"} 1>&2
+ fi
+ exec \"\$progdir/\$program\" \${1+\"\$@\"}
+"
+ ;;
+ esac
+ $ECHO "\
+ \$ECHO \"\$0: cannot exec \$program \$*\" 1>&2
+ exit 1
+}
+
+# A function to encapsulate launching the target application
+# Strips options in the --lt-* namespace from \$@ and
+# launches target application with the remaining arguments.
+func_exec_program ()
+{
+ case \" \$* \" in
+ *\\ --lt-*)
+ for lt_wr_arg
+ do
+ case \$lt_wr_arg in
+ --lt-*) ;;
+ *) set x \"\$@\" \"\$lt_wr_arg\"; shift;;
+ esac
+ shift
+ done ;;
+ esac
+ func_exec_program_core \${1+\"\$@\"}
+}
+
+ # Parse options
+ func_parse_lt_options \"\$0\" \${1+\"\$@\"}
+
+ # Find the directory that this script lives in.
+ thisdir=\`\$ECHO \"\$file\" | $SED 's%/[^/]*$%%'\`
+ test \"x\$thisdir\" = \"x\$file\" && thisdir=.
+
+ # Follow symbolic links until we get to the real thisdir.
+ file=\`ls -ld \"\$file\" | $SED -n 's/.*-> //p'\`
+ while test -n \"\$file\"; do
+ destdir=\`\$ECHO \"\$file\" | $SED 's%/[^/]*\$%%'\`
+
+ # If there was a directory component, then change thisdir.
+ if test \"x\$destdir\" != \"x\$file\"; then
+ case \"\$destdir\" in
+ [\\\\/]* | [A-Za-z]:[\\\\/]*) thisdir=\"\$destdir\" ;;
+ *) thisdir=\"\$thisdir/\$destdir\" ;;
+ esac
+ fi
+
+ file=\`\$ECHO \"\$file\" | $SED 's%^.*/%%'\`
+ file=\`ls -ld \"\$thisdir/\$file\" | $SED -n 's/.*-> //p'\`
+ done
+
+ # Usually 'no', except on cygwin/mingw when embedded into
+ # the cwrapper.
+ WRAPPER_SCRIPT_BELONGS_IN_OBJDIR=$func_emit_wrapper_arg1
+ if test \"\$WRAPPER_SCRIPT_BELONGS_IN_OBJDIR\" = \"yes\"; then
+ # special case for '.'
+ if test \"\$thisdir\" = \".\"; then
+ thisdir=\`pwd\`
+ fi
+ # remove .libs from thisdir
+ case \"\$thisdir\" in
+ *[\\\\/]$objdir ) thisdir=\`\$ECHO \"\$thisdir\" | $SED 's%[\\\\/][^\\\\/]*$%%'\` ;;
+ $objdir ) thisdir=. ;;
+ esac
+ fi
+
+ # Try to get the absolute directory name.
+ absdir=\`cd \"\$thisdir\" && pwd\`
+ test -n \"\$absdir\" && thisdir=\"\$absdir\"
+"
+
+ if test "$fast_install" = yes; then
+ $ECHO "\
+ program=lt-'$outputname'$exeext
+ progdir=\"\$thisdir/$objdir\"
+
+ if test ! -f \"\$progdir/\$program\" ||
+ { file=\`ls -1dt \"\$progdir/\$program\" \"\$progdir/../\$program\" 2>/dev/null | ${SED} 1q\`; \\
+ test \"X\$file\" != \"X\$progdir/\$program\"; }; then
+
+ file=\"\$\$-\$program\"
+
+ if test ! -d \"\$progdir\"; then
+ $MKDIR \"\$progdir\"
+ else
+ $RM \"\$progdir/\$file\"
+ fi"
+
+ $ECHO "\
+
+ # relink executable if necessary
+ if test -n \"\$relink_command\"; then
+ if relink_command_output=\`eval \$relink_command 2>&1\`; then :
+ else
+ $ECHO \"\$relink_command_output\" >&2
+ $RM \"\$progdir/\$file\"
+ exit 1
+ fi
+ fi
+
+ $MV \"\$progdir/\$file\" \"\$progdir/\$program\" 2>/dev/null ||
+ { $RM \"\$progdir/\$program\";
+ $MV \"\$progdir/\$file\" \"\$progdir/\$program\"; }
+ $RM \"\$progdir/\$file\"
+ fi"
+ else
+ $ECHO "\
+ program='$outputname'
+ progdir=\"\$thisdir/$objdir\"
+"
+ fi
+
+ $ECHO "\
+
+ if test -f \"\$progdir/\$program\"; then"
+
+ # fixup the dll searchpath if we need to.
+ #
+ # Fix the DLL searchpath if we need to. Do this before prepending
+ # to shlibpath, because on Windows, both are PATH and uninstalled
+ # libraries must come first.
+ if test -n "$dllsearchpath"; then
+ $ECHO "\
+ # Add the dll search path components to the executable PATH
+ PATH=$dllsearchpath:\$PATH
+"
+ fi
+
+ # Export our shlibpath_var if we have one.
+ if test "$shlibpath_overrides_runpath" = yes && test -n "$shlibpath_var" && test -n "$temp_rpath"; then
+ $ECHO "\
+ # Add our own library path to $shlibpath_var
+ $shlibpath_var=\"$temp_rpath\$$shlibpath_var\"
+
+ # Some systems cannot cope with colon-terminated $shlibpath_var
+ # The second colon is a workaround for a bug in BeOS R4 sed
+ $shlibpath_var=\`\$ECHO \"\$$shlibpath_var\" | $SED 's/::*\$//'\`
+
+ export $shlibpath_var
+"
+ fi
+
+ $ECHO "\
+ if test \"\$libtool_execute_magic\" != \"$magic\"; then
+ # Run the actual program with our arguments.
+ func_exec_program \${1+\"\$@\"}
+ fi
+ else
+ # The program doesn't exist.
+ \$ECHO \"\$0: error: \\\`\$progdir/\$program' does not exist\" 1>&2
+ \$ECHO \"This script is just a wrapper for \$program.\" 1>&2
+ \$ECHO \"See the $PACKAGE documentation for more information.\" 1>&2
+ exit 1
+ fi
+fi\
+"
+}
+
+
+# func_emit_cwrapperexe_src
+# emit the source code for a wrapper executable on stdout
+# Must ONLY be called from within func_mode_link because
+# it depends on a number of variable set therein.
+func_emit_cwrapperexe_src ()
+{
+ cat <<EOF
+
+/* $cwrappersource - temporary wrapper executable for $objdir/$outputname
+ Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION
+
+ The $output program cannot be directly executed until all the libtool
+ libraries that it depends on are installed.
+
+ This wrapper executable should never be moved out of the build directory.
+ If it is, it will not operate correctly.
+*/
+EOF
+ cat <<"EOF"
+#ifdef _MSC_VER
+# define _CRT_SECURE_NO_DEPRECATE 1
+#endif
+#include <stdio.h>
+#include <stdlib.h>
+#ifdef _MSC_VER
+# include <direct.h>
+# include <process.h>
+# include <io.h>
+#else
+# include <unistd.h>
+# include <stdint.h>
+# ifdef __CYGWIN__
+# include <io.h>
+# endif
+#endif
+#include <malloc.h>
+#include <stdarg.h>
+#include <assert.h>
+#include <string.h>
+#include <ctype.h>
+#include <errno.h>
+#include <fcntl.h>
+#include <sys/stat.h>
+
+/* declarations of non-ANSI functions */
+#if defined(__MINGW32__)
+# ifdef __STRICT_ANSI__
+int _putenv (const char *);
+# endif
+#elif defined(__CYGWIN__)
+# ifdef __STRICT_ANSI__
+char *realpath (const char *, char *);
+int putenv (char *);
+int setenv (const char *, const char *, int);
+# endif
+/* #elif defined (other platforms) ... */
+#endif
+
+/* portability defines, excluding path handling macros */
+#if defined(_MSC_VER)
+# define setmode _setmode
+# define stat _stat
+# define chmod _chmod
+# define getcwd _getcwd
+# define putenv _putenv
+# define S_IXUSR _S_IEXEC
+# ifndef _INTPTR_T_DEFINED
+# define _INTPTR_T_DEFINED
+# define intptr_t int
+# endif
+#elif defined(__MINGW32__)
+# define setmode _setmode
+# define stat _stat
+# define chmod _chmod
+# define getcwd _getcwd
+# define putenv _putenv
+#elif defined(__CYGWIN__)
+# define HAVE_SETENV
+# define FOPEN_WB "wb"
+/* #elif defined (other platforms) ... */
+#endif
+
+#if defined(PATH_MAX)
+# define LT_PATHMAX PATH_MAX
+#elif defined(MAXPATHLEN)
+# define LT_PATHMAX MAXPATHLEN
+#else
+# define LT_PATHMAX 1024
+#endif
+
+#ifndef S_IXOTH
+# define S_IXOTH 0
+#endif
+#ifndef S_IXGRP
+# define S_IXGRP 0
+#endif
+
+/* path handling portability macros */
+#ifndef DIR_SEPARATOR
+# define DIR_SEPARATOR '/'
+# define PATH_SEPARATOR ':'
+#endif
+
+#if defined (_WIN32) || defined (__MSDOS__) || defined (__DJGPP__) || \
+ defined (__OS2__)
+# define HAVE_DOS_BASED_FILE_SYSTEM
+# define FOPEN_WB "wb"
+# ifndef DIR_SEPARATOR_2
+# define DIR_SEPARATOR_2 '\\'
+# endif
+# ifndef PATH_SEPARATOR_2
+# define PATH_SEPARATOR_2 ';'
+# endif
+#endif
+
+#ifndef DIR_SEPARATOR_2
+# define IS_DIR_SEPARATOR(ch) ((ch) == DIR_SEPARATOR)
+#else /* DIR_SEPARATOR_2 */
+# define IS_DIR_SEPARATOR(ch) \
+ (((ch) == DIR_SEPARATOR) || ((ch) == DIR_SEPARATOR_2))
+#endif /* DIR_SEPARATOR_2 */
+
+#ifndef PATH_SEPARATOR_2
+# define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR)
+#else /* PATH_SEPARATOR_2 */
+# define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR_2)
+#endif /* PATH_SEPARATOR_2 */
+
+#ifndef FOPEN_WB
+# define FOPEN_WB "w"
+#endif
+#ifndef _O_BINARY
+# define _O_BINARY 0
+#endif
+
+#define XMALLOC(type, num) ((type *) xmalloc ((num) * sizeof(type)))
+#define XFREE(stale) do { \
+ if (stale) { free ((void *) stale); stale = 0; } \
+} while (0)
+
+#if defined(LT_DEBUGWRAPPER)
+static int lt_debug = 1;
+#else
+static int lt_debug = 0;
+#endif
+
+const char *program_name = "libtool-wrapper"; /* in case xstrdup fails */
+
+void *xmalloc (size_t num);
+char *xstrdup (const char *string);
+const char *base_name (const char *name);
+char *find_executable (const char *wrapper);
+char *chase_symlinks (const char *pathspec);
+int make_executable (const char *path);
+int check_executable (const char *path);
+char *strendzap (char *str, const char *pat);
+void lt_debugprintf (const char *file, int line, const char *fmt, ...);
+void lt_fatal (const char *file, int line, const char *message, ...);
+static const char *nonnull (const char *s);
+static const char *nonempty (const char *s);
+void lt_setenv (const char *name, const char *value);
+char *lt_extend_str (const char *orig_value, const char *add, int to_end);
+void lt_update_exe_path (const char *name, const char *value);
+void lt_update_lib_path (const char *name, const char *value);
+char **prepare_spawn (char **argv);
+void lt_dump_script (FILE *f);
+EOF
+
+ cat <<EOF
+volatile const char * MAGIC_EXE = "$magic_exe";
+const char * LIB_PATH_VARNAME = "$shlibpath_var";
+EOF
+
+ if test "$shlibpath_overrides_runpath" = yes && test -n "$shlibpath_var" && test -n "$temp_rpath"; then
+ func_to_host_path "$temp_rpath"
+ cat <<EOF
+const char * LIB_PATH_VALUE = "$func_to_host_path_result";
+EOF
+ else
+ cat <<"EOF"
+const char * LIB_PATH_VALUE = "";
+EOF
+ fi
+
+ if test -n "$dllsearchpath"; then
+ func_to_host_path "$dllsearchpath:"
+ cat <<EOF
+const char * EXE_PATH_VARNAME = "PATH";
+const char * EXE_PATH_VALUE = "$func_to_host_path_result";
+EOF
+ else
+ cat <<"EOF"
+const char * EXE_PATH_VARNAME = "";
+const char * EXE_PATH_VALUE = "";
+EOF
+ fi
+
+ if test "$fast_install" = yes; then
+ cat <<EOF
+const char * TARGET_PROGRAM_NAME = "lt-$outputname"; /* hopefully, no .exe */
+EOF
+ else
+ cat <<EOF
+const char * TARGET_PROGRAM_NAME = "$outputname"; /* hopefully, no .exe */
+EOF
+ fi
+
+
+ cat <<"EOF"
+
+#define LTWRAPPER_OPTION_PREFIX "--lt-"
+
+static const char *ltwrapper_option_prefix = LTWRAPPER_OPTION_PREFIX;
+static const char *dumpscript_opt = LTWRAPPER_OPTION_PREFIX "dump-script";
+static const char *debug_opt = LTWRAPPER_OPTION_PREFIX "debug";
+
+int
+main (int argc, char *argv[])
+{
+ char **newargz;
+ int newargc;
+ char *tmp_pathspec;
+ char *actual_cwrapper_path;
+ char *actual_cwrapper_name;
+ char *target_name;
+ char *lt_argv_zero;
+ intptr_t rval = 127;
+
+ int i;
+
+ program_name = (char *) xstrdup (base_name (argv[0]));
+ newargz = XMALLOC (char *, argc + 1);
+
+ /* very simple arg parsing; don't want to rely on getopt
+ * also, copy all non cwrapper options to newargz, except
+ * argz[0], which is handled differently
+ */
+ newargc=0;
+ for (i = 1; i < argc; i++)
+ {
+ if (strcmp (argv[i], dumpscript_opt) == 0)
+ {
+EOF
+ case "$host" in
+ *mingw* | *cygwin* )
+ # make stdout use "unix" line endings
+ echo " setmode(1,_O_BINARY);"
+ ;;
+ esac
+
+ cat <<"EOF"
+ lt_dump_script (stdout);
+ return 0;
+ }
+ if (strcmp (argv[i], debug_opt) == 0)
+ {
+ lt_debug = 1;
+ continue;
+ }
+ if (strcmp (argv[i], ltwrapper_option_prefix) == 0)
+ {
+ /* however, if there is an option in the LTWRAPPER_OPTION_PREFIX
+ namespace, but it is not one of the ones we know about and
+ have already dealt with, above (inluding dump-script), then
+ report an error. Otherwise, targets might begin to believe
+ they are allowed to use options in the LTWRAPPER_OPTION_PREFIX
+ namespace. The first time any user complains about this, we'll
+ need to make LTWRAPPER_OPTION_PREFIX a configure-time option
+ or a configure.ac-settable value.
+ */
+ lt_fatal (__FILE__, __LINE__,
+ "unrecognized %s option: '%s'",
+ ltwrapper_option_prefix, argv[i]);
+ }
+ /* otherwise ... */
+ newargz[++newargc] = xstrdup (argv[i]);
+ }
+ newargz[++newargc] = NULL;
+
+EOF
+ cat <<EOF
+ /* The GNU banner must be the first non-error debug message */
+ lt_debugprintf (__FILE__, __LINE__, "libtool wrapper (GNU $PACKAGE$TIMESTAMP) $VERSION\n");
+EOF
+ cat <<"EOF"
+ lt_debugprintf (__FILE__, __LINE__, "(main) argv[0]: %s\n", argv[0]);
+ lt_debugprintf (__FILE__, __LINE__, "(main) program_name: %s\n", program_name);
+
+ tmp_pathspec = find_executable (argv[0]);
+ if (tmp_pathspec == NULL)
+ lt_fatal (__FILE__, __LINE__, "couldn't find %s", argv[0]);
+ lt_debugprintf (__FILE__, __LINE__,
+ "(main) found exe (before symlink chase) at: %s\n",
+ tmp_pathspec);
+
+ actual_cwrapper_path = chase_symlinks (tmp_pathspec);
+ lt_debugprintf (__FILE__, __LINE__,
+ "(main) found exe (after symlink chase) at: %s\n",
+ actual_cwrapper_path);
+ XFREE (tmp_pathspec);
+
+ actual_cwrapper_name = xstrdup (base_name (actual_cwrapper_path));
+ strendzap (actual_cwrapper_path, actual_cwrapper_name);
+
+ /* wrapper name transforms */
+ strendzap (actual_cwrapper_name, ".exe");
+ tmp_pathspec = lt_extend_str (actual_cwrapper_name, ".exe", 1);
+ XFREE (actual_cwrapper_name);
+ actual_cwrapper_name = tmp_pathspec;
+ tmp_pathspec = 0;
+
+ /* target_name transforms -- use actual target program name; might have lt- prefix */
+ target_name = xstrdup (base_name (TARGET_PROGRAM_NAME));
+ strendzap (target_name, ".exe");
+ tmp_pathspec = lt_extend_str (target_name, ".exe", 1);
+ XFREE (target_name);
+ target_name = tmp_pathspec;
+ tmp_pathspec = 0;
+
+ lt_debugprintf (__FILE__, __LINE__,
+ "(main) libtool target name: %s\n",
+ target_name);
+EOF
+
+ cat <<EOF
+ newargz[0] =
+ XMALLOC (char, (strlen (actual_cwrapper_path) +
+ strlen ("$objdir") + 1 + strlen (actual_cwrapper_name) + 1));
+ strcpy (newargz[0], actual_cwrapper_path);
+ strcat (newargz[0], "$objdir");
+ strcat (newargz[0], "/");
+EOF
+
+ cat <<"EOF"
+ /* stop here, and copy so we don't have to do this twice */
+ tmp_pathspec = xstrdup (newargz[0]);
+
+ /* do NOT want the lt- prefix here, so use actual_cwrapper_name */
+ strcat (newargz[0], actual_cwrapper_name);
+
+ /* DO want the lt- prefix here if it exists, so use target_name */
+ lt_argv_zero = lt_extend_str (tmp_pathspec, target_name, 1);
+ XFREE (tmp_pathspec);
+ tmp_pathspec = NULL;
+EOF
+
+ case $host_os in
+ mingw*)
+ cat <<"EOF"
+ {
+ char* p;
+ while ((p = strchr (newargz[0], '\\')) != NULL)
+ {
+ *p = '/';
+ }
+ while ((p = strchr (lt_argv_zero, '\\')) != NULL)
+ {
+ *p = '/';
+ }
+ }
+EOF
+ ;;
+ esac
+
+ cat <<"EOF"
+ XFREE (target_name);
+ XFREE (actual_cwrapper_path);
+ XFREE (actual_cwrapper_name);
+
+ lt_setenv ("BIN_SH", "xpg4"); /* for Tru64 */
+ lt_setenv ("DUALCASE", "1"); /* for MSK sh */
+ /* Update the DLL searchpath. EXE_PATH_VALUE ($dllsearchpath) must
+ be prepended before (that is, appear after) LIB_PATH_VALUE ($temp_rpath)
+ because on Windows, both *_VARNAMEs are PATH but uninstalled
+ libraries must come first. */
+ lt_update_exe_path (EXE_PATH_VARNAME, EXE_PATH_VALUE);
+ lt_update_lib_path (LIB_PATH_VARNAME, LIB_PATH_VALUE);
+
+ lt_debugprintf (__FILE__, __LINE__, "(main) lt_argv_zero: %s\n",
+ nonnull (lt_argv_zero));
+ for (i = 0; i < newargc; i++)
+ {
+ lt_debugprintf (__FILE__, __LINE__, "(main) newargz[%d]: %s\n",
+ i, nonnull (newargz[i]));
+ }
+
+EOF
+
+ case $host_os in
+ mingw*)
+ cat <<"EOF"
+ /* execv doesn't actually work on mingw as expected on unix */
+ newargz = prepare_spawn (newargz);
+ rval = _spawnv (_P_WAIT, lt_argv_zero, (const char * const *) newargz);
+ if (rval == -1)
+ {
+ /* failed to start process */
+ lt_debugprintf (__FILE__, __LINE__,
+ "(main) failed to launch target \"%s\": %s\n",
+ lt_argv_zero, nonnull (strerror (errno)));
+ return 127;
+ }
+ return rval;
+EOF
+ ;;
+ *)
+ cat <<"EOF"
+ execv (lt_argv_zero, newargz);
+ return rval; /* =127, but avoids unused variable warning */
+EOF
+ ;;
+ esac
+
+ cat <<"EOF"
+}
+
+void *
+xmalloc (size_t num)
+{
+ void *p = (void *) malloc (num);
+ if (!p)
+ lt_fatal (__FILE__, __LINE__, "memory exhausted");
+
+ return p;
+}
+
+char *
+xstrdup (const char *string)
+{
+ return string ? strcpy ((char *) xmalloc (strlen (string) + 1),
+ string) : NULL;
+}
+
+const char *
+base_name (const char *name)
+{
+ const char *base;
+
+#if defined (HAVE_DOS_BASED_FILE_SYSTEM)
+ /* Skip over the disk name in MSDOS pathnames. */
+ if (isalpha ((unsigned char) name[0]) && name[1] == ':')
+ name += 2;
+#endif
+
+ for (base = name; *name; name++)
+ if (IS_DIR_SEPARATOR (*name))
+ base = name + 1;
+ return base;
+}
+
+int
+check_executable (const char *path)
+{
+ struct stat st;
+
+ lt_debugprintf (__FILE__, __LINE__, "(check_executable): %s\n",
+ nonempty (path));
+ if ((!path) || (!*path))
+ return 0;
+
+ if ((stat (path, &st) >= 0)
+ && (st.st_mode & (S_IXUSR | S_IXGRP | S_IXOTH)))
+ return 1;
+ else
+ return 0;
+}
+
+int
+make_executable (const char *path)
+{
+ int rval = 0;
+ struct stat st;
+
+ lt_debugprintf (__FILE__, __LINE__, "(make_executable): %s\n",
+ nonempty (path));
+ if ((!path) || (!*path))
+ return 0;
+
+ if (stat (path, &st) >= 0)
+ {
+ rval = chmod (path, st.st_mode | S_IXOTH | S_IXGRP | S_IXUSR);
+ }
+ return rval;
+}
+
+/* Searches for the full path of the wrapper. Returns
+ newly allocated full path name if found, NULL otherwise
+ Does not chase symlinks, even on platforms that support them.
+*/
+char *
+find_executable (const char *wrapper)
+{
+ int has_slash = 0;
+ const char *p;
+ const char *p_next;
+ /* static buffer for getcwd */
+ char tmp[LT_PATHMAX + 1];
+ int tmp_len;
+ char *concat_name;
+
+ lt_debugprintf (__FILE__, __LINE__, "(find_executable): %s\n",
+ nonempty (wrapper));
+
+ if ((wrapper == NULL) || (*wrapper == '\0'))
+ return NULL;
+
+ /* Absolute path? */
+#if defined (HAVE_DOS_BASED_FILE_SYSTEM)
+ if (isalpha ((unsigned char) wrapper[0]) && wrapper[1] == ':')
+ {
+ concat_name = xstrdup (wrapper);
+ if (check_executable (concat_name))
+ return concat_name;
+ XFREE (concat_name);
+ }
+ else
+ {
+#endif
+ if (IS_DIR_SEPARATOR (wrapper[0]))
+ {
+ concat_name = xstrdup (wrapper);
+ if (check_executable (concat_name))
+ return concat_name;
+ XFREE (concat_name);
+ }
+#if defined (HAVE_DOS_BASED_FILE_SYSTEM)
+ }
+#endif
+
+ for (p = wrapper; *p; p++)
+ if (*p == '/')
+ {
+ has_slash = 1;
+ break;
+ }
+ if (!has_slash)
+ {
+ /* no slashes; search PATH */
+ const char *path = getenv ("PATH");
+ if (path != NULL)
+ {
+ for (p = path; *p; p = p_next)
+ {
+ const char *q;
+ size_t p_len;
+ for (q = p; *q; q++)
+ if (IS_PATH_SEPARATOR (*q))
+ break;
+ p_len = q - p;
+ p_next = (*q == '\0' ? q : q + 1);
+ if (p_len == 0)
+ {
+ /* empty path: current directory */
+ if (getcwd (tmp, LT_PATHMAX) == NULL)
+ lt_fatal (__FILE__, __LINE__, "getcwd failed: %s",
+ nonnull (strerror (errno)));
+ tmp_len = strlen (tmp);
+ concat_name =
+ XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1);
+ memcpy (concat_name, tmp, tmp_len);
+ concat_name[tmp_len] = '/';
+ strcpy (concat_name + tmp_len + 1, wrapper);
+ }
+ else
+ {
+ concat_name =
+ XMALLOC (char, p_len + 1 + strlen (wrapper) + 1);
+ memcpy (concat_name, p, p_len);
+ concat_name[p_len] = '/';
+ strcpy (concat_name + p_len + 1, wrapper);
+ }
+ if (check_executable (concat_name))
+ return concat_name;
+ XFREE (concat_name);
+ }
+ }
+ /* not found in PATH; assume curdir */
+ }
+ /* Relative path | not found in path: prepend cwd */
+ if (getcwd (tmp, LT_PATHMAX) == NULL)
+ lt_fatal (__FILE__, __LINE__, "getcwd failed: %s",
+ nonnull (strerror (errno)));
+ tmp_len = strlen (tmp);
+ concat_name = XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1);
+ memcpy (concat_name, tmp, tmp_len);
+ concat_name[tmp_len] = '/';
+ strcpy (concat_name + tmp_len + 1, wrapper);
+
+ if (check_executable (concat_name))
+ return concat_name;
+ XFREE (concat_name);
+ return NULL;
+}
+
+char *
+chase_symlinks (const char *pathspec)
+{
+#ifndef S_ISLNK
+ return xstrdup (pathspec);
+#else
+ char buf[LT_PATHMAX];
+ struct stat s;
+ char *tmp_pathspec = xstrdup (pathspec);
+ char *p;
+ int has_symlinks = 0;
+ while (strlen (tmp_pathspec) && !has_symlinks)
+ {
+ lt_debugprintf (__FILE__, __LINE__,
+ "checking path component for symlinks: %s\n",
+ tmp_pathspec);
+ if (lstat (tmp_pathspec, &s) == 0)
+ {
+ if (S_ISLNK (s.st_mode) != 0)
+ {
+ has_symlinks = 1;
+ break;
+ }
+
+ /* search backwards for last DIR_SEPARATOR */
+ p = tmp_pathspec + strlen (tmp_pathspec) - 1;
+ while ((p > tmp_pathspec) && (!IS_DIR_SEPARATOR (*p)))
+ p--;
+ if ((p == tmp_pathspec) && (!IS_DIR_SEPARATOR (*p)))
+ {
+ /* no more DIR_SEPARATORS left */
+ break;
+ }
+ *p = '\0';
+ }
+ else
+ {
+ lt_fatal (__FILE__, __LINE__,
+ "error accessing file \"%s\": %s",
+ tmp_pathspec, nonnull (strerror (errno)));
+ }
+ }
+ XFREE (tmp_pathspec);
+
+ if (!has_symlinks)
+ {
+ return xstrdup (pathspec);
+ }
+
+ tmp_pathspec = realpath (pathspec, buf);
+ if (tmp_pathspec == 0)
+ {
+ lt_fatal (__FILE__, __LINE__,
+ "could not follow symlinks for %s", pathspec);
+ }
+ return xstrdup (tmp_pathspec);
+#endif
+}
+
+char *
+strendzap (char *str, const char *pat)
+{
+ size_t len, patlen;
+
+ assert (str != NULL);
+ assert (pat != NULL);
+
+ len = strlen (str);
+ patlen = strlen (pat);
+
+ if (patlen <= len)
+ {
+ str += len - patlen;
+ if (strcmp (str, pat) == 0)
+ *str = '\0';
+ }
+ return str;
+}
+
+void
+lt_debugprintf (const char *file, int line, const char *fmt, ...)
+{
+ va_list args;
+ if (lt_debug)
+ {
+ (void) fprintf (stderr, "%s:%s:%d: ", program_name, file, line);
+ va_start (args, fmt);
+ (void) vfprintf (stderr, fmt, args);
+ va_end (args);
+ }
+}
+
+static void
+lt_error_core (int exit_status, const char *file,
+ int line, const char *mode,
+ const char *message, va_list ap)
+{
+ fprintf (stderr, "%s:%s:%d: %s: ", program_name, file, line, mode);
+ vfprintf (stderr, message, ap);
+ fprintf (stderr, ".\n");
+
+ if (exit_status >= 0)
+ exit (exit_status);
+}
+
+void
+lt_fatal (const char *file, int line, const char *message, ...)
+{
+ va_list ap;
+ va_start (ap, message);
+ lt_error_core (EXIT_FAILURE, file, line, "FATAL", message, ap);
+ va_end (ap);
+}
+
+static const char *
+nonnull (const char *s)
+{
+ return s ? s : "(null)";
+}
+
+static const char *
+nonempty (const char *s)
+{
+ return (s && !*s) ? "(empty)" : nonnull (s);
+}
+
+void
+lt_setenv (const char *name, const char *value)
+{
+ lt_debugprintf (__FILE__, __LINE__,
+ "(lt_setenv) setting '%s' to '%s'\n",
+ nonnull (name), nonnull (value));
+ {
+#ifdef HAVE_SETENV
+ /* always make a copy, for consistency with !HAVE_SETENV */
+ char *str = xstrdup (value);
+ setenv (name, str, 1);
+#else
+ int len = strlen (name) + 1 + strlen (value) + 1;
+ char *str = XMALLOC (char, len);
+ sprintf (str, "%s=%s", name, value);
+ if (putenv (str) != EXIT_SUCCESS)
+ {
+ XFREE (str);
+ }
+#endif
+ }
+}
+
+char *
+lt_extend_str (const char *orig_value, const char *add, int to_end)
+{
+ char *new_value;
+ if (orig_value && *orig_value)
+ {
+ int orig_value_len = strlen (orig_value);
+ int add_len = strlen (add);
+ new_value = XMALLOC (char, add_len + orig_value_len + 1);
+ if (to_end)
+ {
+ strcpy (new_value, orig_value);
+ strcpy (new_value + orig_value_len, add);
+ }
+ else
+ {
+ strcpy (new_value, add);
+ strcpy (new_value + add_len, orig_value);
+ }
+ }
+ else
+ {
+ new_value = xstrdup (add);
+ }
+ return new_value;
+}
+
+void
+lt_update_exe_path (const char *name, const char *value)
+{
+ lt_debugprintf (__FILE__, __LINE__,
+ "(lt_update_exe_path) modifying '%s' by prepending '%s'\n",
+ nonnull (name), nonnull (value));
+
+ if (name && *name && value && *value)
+ {
+ char *new_value = lt_extend_str (getenv (name), value, 0);
+ /* some systems can't cope with a ':'-terminated path #' */
+ int len = strlen (new_value);
+ while (((len = strlen (new_value)) > 0) && IS_PATH_SEPARATOR (new_value[len-1]))
+ {
+ new_value[len-1] = '\0';
+ }
+ lt_setenv (name, new_value);
+ XFREE (new_value);
+ }
+}
+
+void
+lt_update_lib_path (const char *name, const char *value)
+{
+ lt_debugprintf (__FILE__, __LINE__,
+ "(lt_update_lib_path) modifying '%s' by prepending '%s'\n",
+ nonnull (name), nonnull (value));
+
+ if (name && *name && value && *value)
+ {
+ char *new_value = lt_extend_str (getenv (name), value, 0);
+ lt_setenv (name, new_value);
+ XFREE (new_value);
+ }
+}
+
+EOF
+ case $host_os in
+ mingw*)
+ cat <<"EOF"
+
+/* Prepares an argument vector before calling spawn().
+ Note that spawn() does not by itself call the command interpreter
+ (getenv ("COMSPEC") != NULL ? getenv ("COMSPEC") :
+ ({ OSVERSIONINFO v; v.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
+ GetVersionEx(&v);
+ v.dwPlatformId == VER_PLATFORM_WIN32_NT;
+ }) ? "cmd.exe" : "command.com").
+ Instead it simply concatenates the arguments, separated by ' ', and calls
+ CreateProcess(). We must quote the arguments since Win32 CreateProcess()
+ interprets characters like ' ', '\t', '\\', '"' (but not '<' and '>') in a
+ special way:
+ - Space and tab are interpreted as delimiters. They are not treated as
+ delimiters if they are surrounded by double quotes: "...".
+ - Unescaped double quotes are removed from the input. Their only effect is
+ that within double quotes, space and tab are treated like normal
+ characters.
+ - Backslashes not followed by double quotes are not special.
+ - But 2*n+1 backslashes followed by a double quote become
+ n backslashes followed by a double quote (n >= 0):
+ \" -> "
+ \\\" -> \"
+ \\\\\" -> \\"
+ */
+#define SHELL_SPECIAL_CHARS "\"\\ \001\002\003\004\005\006\007\010\011\012\013\014\015\016\017\020\021\022\023\024\025\026\027\030\031\032\033\034\035\036\037"
+#define SHELL_SPACE_CHARS " \001\002\003\004\005\006\007\010\011\012\013\014\015\016\017\020\021\022\023\024\025\026\027\030\031\032\033\034\035\036\037"
+char **
+prepare_spawn (char **argv)
+{
+ size_t argc;
+ char **new_argv;
+ size_t i;
+
+ /* Count number of arguments. */
+ for (argc = 0; argv[argc] != NULL; argc++)
+ ;
+
+ /* Allocate new argument vector. */
+ new_argv = XMALLOC (char *, argc + 1);
+
+ /* Put quoted arguments into the new argument vector. */
+ for (i = 0; i < argc; i++)
+ {
+ const char *string = argv[i];
+
+ if (string[0] == '\0')
+ new_argv[i] = xstrdup ("\"\"");
+ else if (strpbrk (string, SHELL_SPECIAL_CHARS) != NULL)
+ {
+ int quote_around = (strpbrk (string, SHELL_SPACE_CHARS) != NULL);
+ size_t length;
+ unsigned int backslashes;
+ const char *s;
+ char *quoted_string;
+ char *p;
+
+ length = 0;
+ backslashes = 0;
+ if (quote_around)
+ length++;
+ for (s = string; *s != '\0'; s++)
+ {
+ char c = *s;
+ if (c == '"')
+ length += backslashes + 1;
+ length++;
+ if (c == '\\')
+ backslashes++;
+ else
+ backslashes = 0;
+ }
+ if (quote_around)
+ length += backslashes + 1;
+
+ quoted_string = XMALLOC (char, length + 1);
+
+ p = quoted_string;
+ backslashes = 0;
+ if (quote_around)
+ *p++ = '"';
+ for (s = string; *s != '\0'; s++)
+ {
+ char c = *s;
+ if (c == '"')
+ {
+ unsigned int j;
+ for (j = backslashes + 1; j > 0; j--)
+ *p++ = '\\';
+ }
+ *p++ = c;
+ if (c == '\\')
+ backslashes++;
+ else
+ backslashes = 0;
+ }
+ if (quote_around)
+ {
+ unsigned int j;
+ for (j = backslashes; j > 0; j--)
+ *p++ = '\\';
+ *p++ = '"';
+ }
+ *p = '\0';
+
+ new_argv[i] = quoted_string;
+ }
+ else
+ new_argv[i] = (char *) string;
+ }
+ new_argv[argc] = NULL;
+
+ return new_argv;
+}
+EOF
+ ;;
+ esac
+
+ cat <<"EOF"
+void lt_dump_script (FILE* f)
+{
+EOF
+ func_emit_wrapper yes |
+ $SED -n -e '
+s/^\(.\{79\}\)\(..*\)/\1\
+\2/
+h
+s/\([\\"]\)/\\\1/g
+s/$/\\n/
+s/\([^\n]*\).*/ fputs ("\1", f);/p
+g
+D'
+ cat <<"EOF"
+}
+EOF
+}
+# end: func_emit_cwrapperexe_src
+
+# func_win32_import_lib_p ARG
+# True if ARG is an import lib, as indicated by $file_magic_cmd
+func_win32_import_lib_p ()
+{
+ $opt_debug
+ case `eval $file_magic_cmd \"\$1\" 2>/dev/null | $SED -e 10q` in
+ *import*) : ;;
+ *) false ;;
+ esac
+}
+
+# func_mode_link arg...
+func_mode_link ()
+{
+ $opt_debug
+ case $host in
+ *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*)
+ # It is impossible to link a dll without this setting, and
+ # we shouldn't force the makefile maintainer to figure out
+ # which system we are compiling for in order to pass an extra
+ # flag for every libtool invocation.
+ # allow_undefined=no
+
+ # FIXME: Unfortunately, there are problems with the above when trying
+ # to make a dll which has undefined symbols, in which case not
+ # even a static library is built. For now, we need to specify
+ # -no-undefined on the libtool link line when we can be certain
+ # that all symbols are satisfied, otherwise we get a static library.
+ allow_undefined=yes
+ ;;
+ *)
+ allow_undefined=yes
+ ;;
+ esac
+ libtool_args=$nonopt
+ base_compile="$nonopt $@"
+ compile_command=$nonopt
+ finalize_command=$nonopt
+
+ compile_rpath=
+ finalize_rpath=
+ compile_shlibpath=
+ finalize_shlibpath=
+ convenience=
+ old_convenience=
+ deplibs=
+ old_deplibs=
+ compiler_flags=
+ linker_flags=
+ dllsearchpath=
+ lib_search_path=`pwd`
+ inst_prefix_dir=
+ new_inherited_linker_flags=
+
+ avoid_version=no
+ bindir=
+ dlfiles=
+ dlprefiles=
+ dlself=no
+ export_dynamic=no
+ export_symbols=
+ export_symbols_regex=
+ generated=
+ libobjs=
+ ltlibs=
+ module=no
+ no_install=no
+ objs=
+ non_pic_objects=
+ precious_files_regex=
+ prefer_static_libs=no
+ preload=no
+ prev=
+ prevarg=
+ release=
+ rpath=
+ xrpath=
+ perm_rpath=
+ temp_rpath=
+ thread_safe=no
+ vinfo=
+ vinfo_number=no
+ weak_libs=
+ single_module="${wl}-single_module"
+ func_infer_tag $base_compile
+
+ # We need to know -static, to get the right output filenames.
+ for arg
+ do
+ case $arg in
+ -shared)
+ test "$build_libtool_libs" != yes && \
+ func_fatal_configuration "can not build a shared library"
+ build_old_libs=no
+ break
+ ;;
+ -all-static | -static | -static-libtool-libs)
+ case $arg in
+ -all-static)
+ if test "$build_libtool_libs" = yes && test -z "$link_static_flag"; then
+ func_warning "complete static linking is impossible in this configuration"
+ fi
+ if test -n "$link_static_flag"; then
+ dlopen_self=$dlopen_self_static
+ fi
+ prefer_static_libs=yes
+ ;;
+ -static)
+ if test -z "$pic_flag" && test -n "$link_static_flag"; then
+ dlopen_self=$dlopen_self_static
+ fi
+ prefer_static_libs=built
+ ;;
+ -static-libtool-libs)
+ if test -z "$pic_flag" && test -n "$link_static_flag"; then
+ dlopen_self=$dlopen_self_static
+ fi
+ prefer_static_libs=yes
+ ;;
+ esac
+ build_libtool_libs=no
+ build_old_libs=yes
+ break
+ ;;
+ esac
+ done
+
+ # See if our shared archives depend on static archives.
+ test -n "$old_archive_from_new_cmds" && build_old_libs=yes
+
+ # Go through the arguments, transforming them on the way.
+ while test "$#" -gt 0; do
+ arg="$1"
+ shift
+ func_quote_for_eval "$arg"
+ qarg=$func_quote_for_eval_unquoted_result
+ func_append libtool_args " $func_quote_for_eval_result"
+
+ # If the previous option needs an argument, assign it.
+ if test -n "$prev"; then
+ case $prev in
+ output)
+ func_append compile_command " @OUTPUT@"
+ func_append finalize_command " @OUTPUT@"
+ ;;
+ esac
+
+ case $prev in
+ bindir)
+ bindir="$arg"
+ prev=
+ continue
+ ;;
+ dlfiles|dlprefiles)
+ if test "$preload" = no; then
+ # Add the symbol object into the linking commands.
+ func_append compile_command " @SYMFILE@"
+ func_append finalize_command " @SYMFILE@"
+ preload=yes
+ fi
+ case $arg in
+ *.la | *.lo) ;; # We handle these cases below.
+ force)
+ if test "$dlself" = no; then
+ dlself=needless
+ export_dynamic=yes
+ fi
+ prev=
+ continue
+ ;;
+ self)
+ if test "$prev" = dlprefiles; then
+ dlself=yes
+ elif test "$prev" = dlfiles && test "$dlopen_self" != yes; then
+ dlself=yes
+ else
+ dlself=needless
+ export_dynamic=yes
+ fi
+ prev=
+ continue
+ ;;
+ *)
+ if test "$prev" = dlfiles; then
+ func_append dlfiles " $arg"
+ else
+ func_append dlprefiles " $arg"
+ fi
+ prev=
+ continue
+ ;;
+ esac
+ ;;
+ expsyms)
+ export_symbols="$arg"
+ test -f "$arg" \
+ || func_fatal_error "symbol file \`$arg' does not exist"
+ prev=
+ continue
+ ;;
+ expsyms_regex)
+ export_symbols_regex="$arg"
+ prev=
+ continue
+ ;;
+ framework)
+ case $host in
+ *-*-darwin*)
+ case "$deplibs " in
+ *" $qarg.ltframework "*) ;;
+ *) func_append deplibs " $qarg.ltframework" # this is fixed later
+ ;;
+ esac
+ ;;
+ esac
+ prev=
+ continue
+ ;;
+ inst_prefix)
+ inst_prefix_dir="$arg"
+ prev=
+ continue
+ ;;
+ objectlist)
+ if test -f "$arg"; then
+ save_arg=$arg
+ moreargs=
+ for fil in `cat "$save_arg"`
+ do
+# func_append moreargs " $fil"
+ arg=$fil
+ # A libtool-controlled object.
+
+ # Check to see that this really is a libtool object.
+ if func_lalib_unsafe_p "$arg"; then
+ pic_object=
+ non_pic_object=
+
+ # Read the .lo file
+ func_source "$arg"
+
+ if test -z "$pic_object" ||
+ test -z "$non_pic_object" ||
+ test "$pic_object" = none &&
+ test "$non_pic_object" = none; then
+ func_fatal_error "cannot find name of object for \`$arg'"
+ fi
+
+ # Extract subdirectory from the argument.
+ func_dirname "$arg" "/" ""
+ xdir="$func_dirname_result"
+
+ if test "$pic_object" != none; then
+ # Prepend the subdirectory the object is found in.
+ pic_object="$xdir$pic_object"
+
+ if test "$prev" = dlfiles; then
+ if test "$build_libtool_libs" = yes && test "$dlopen_support" = yes; then
+ func_append dlfiles " $pic_object"
+ prev=
+ continue
+ else
+ # If libtool objects are unsupported, then we need to preload.
+ prev=dlprefiles
+ fi
+ fi
+
+ # CHECK ME: I think I busted this. -Ossama
+ if test "$prev" = dlprefiles; then
+ # Preload the old-style object.
+ func_append dlprefiles " $pic_object"
+ prev=
+ fi
+
+ # A PIC object.
+ func_append libobjs " $pic_object"
+ arg="$pic_object"
+ fi
+
+ # Non-PIC object.
+ if test "$non_pic_object" != none; then
+ # Prepend the subdirectory the object is found in.
+ non_pic_object="$xdir$non_pic_object"
+
+ # A standard non-PIC object
+ func_append non_pic_objects " $non_pic_object"
+ if test -z "$pic_object" || test "$pic_object" = none ; then
+ arg="$non_pic_object"
+ fi
+ else
+ # If the PIC object exists, use it instead.
+ # $xdir was prepended to $pic_object above.
+ non_pic_object="$pic_object"
+ func_append non_pic_objects " $non_pic_object"
+ fi
+ else
+ # Only an error if not doing a dry-run.
+ if $opt_dry_run; then
+ # Extract subdirectory from the argument.
+ func_dirname "$arg" "/" ""
+ xdir="$func_dirname_result"
+
+ func_lo2o "$arg"
+ pic_object=$xdir$objdir/$func_lo2o_result
+ non_pic_object=$xdir$func_lo2o_result
+ func_append libobjs " $pic_object"
+ func_append non_pic_objects " $non_pic_object"
+ else
+ func_fatal_error "\`$arg' is not a valid libtool object"
+ fi
+ fi
+ done
+ else
+ func_fatal_error "link input file \`$arg' does not exist"
+ fi
+ arg=$save_arg
+ prev=
+ continue
+ ;;
+ precious_regex)
+ precious_files_regex="$arg"
+ prev=
+ continue
+ ;;
+ release)
+ release="-$arg"
+ prev=
+ continue
+ ;;
+ rpath | xrpath)
+ # We need an absolute path.
+ case $arg in
+ [\\/]* | [A-Za-z]:[\\/]*) ;;
+ *)
+ func_fatal_error "only absolute run-paths are allowed"
+ ;;
+ esac
+ if test "$prev" = rpath; then
+ case "$rpath " in
+ *" $arg "*) ;;
+ *) func_append rpath " $arg" ;;
+ esac
+ else
+ case "$xrpath " in
+ *" $arg "*) ;;
+ *) func_append xrpath " $arg" ;;
+ esac
+ fi
+ prev=
+ continue
+ ;;
+ shrext)
+ shrext_cmds="$arg"
+ prev=
+ continue
+ ;;
+ weak)
+ func_append weak_libs " $arg"
+ prev=
+ continue
+ ;;
+ xcclinker)
+ func_append linker_flags " $qarg"
+ func_append compiler_flags " $qarg"
+ prev=
+ func_append compile_command " $qarg"
+ func_append finalize_command " $qarg"
+ continue
+ ;;
+ xcompiler)
+ func_append compiler_flags " $qarg"
+ prev=
+ func_append compile_command " $qarg"
+ func_append finalize_command " $qarg"
+ continue
+ ;;
+ xlinker)
+ func_append linker_flags " $qarg"
+ func_append compiler_flags " $wl$qarg"
+ prev=
+ func_append compile_command " $wl$qarg"
+ func_append finalize_command " $wl$qarg"
+ continue
+ ;;
+ *)
+ eval "$prev=\"\$arg\""
+ prev=
+ continue
+ ;;
+ esac
+ fi # test -n "$prev"
+
+ prevarg="$arg"
+
+ case $arg in
+ -all-static)
+ if test -n "$link_static_flag"; then
+ # See comment for -static flag below, for more details.
+ func_append compile_command " $link_static_flag"
+ func_append finalize_command " $link_static_flag"
+ fi
+ continue
+ ;;
+
+ -allow-undefined)
+ # FIXME: remove this flag sometime in the future.
+ func_fatal_error "\`-allow-undefined' must not be used because it is the default"
+ ;;
+
+ -avoid-version)
+ avoid_version=yes
+ continue
+ ;;
+
+ -bindir)
+ prev=bindir
+ continue
+ ;;
+
+ -dlopen)
+ prev=dlfiles
+ continue
+ ;;
+
+ -dlpreopen)
+ prev=dlprefiles
+ continue
+ ;;
+
+ -export-dynamic)
+ export_dynamic=yes
+ continue
+ ;;
+
+ -export-symbols | -export-symbols-regex)
+ if test -n "$export_symbols" || test -n "$export_symbols_regex"; then
+ func_fatal_error "more than one -exported-symbols argument is not allowed"
+ fi
+ if test "X$arg" = "X-export-symbols"; then
+ prev=expsyms
+ else
+ prev=expsyms_regex
+ fi
+ continue
+ ;;
+
+ -framework)
+ prev=framework
+ continue
+ ;;
+
+ -inst-prefix-dir)
+ prev=inst_prefix
+ continue
+ ;;
+
+ # The native IRIX linker understands -LANG:*, -LIST:* and -LNO:*
+ # so, if we see these flags be careful not to treat them like -L
+ -L[A-Z][A-Z]*:*)
+ case $with_gcc/$host in
+ no/*-*-irix* | /*-*-irix*)
+ func_append compile_command " $arg"
+ func_append finalize_command " $arg"
+ ;;
+ esac
+ continue
+ ;;
+
+ -L*)
+ func_stripname "-L" '' "$arg"
+ if test -z "$func_stripname_result"; then
+ if test "$#" -gt 0; then
+ func_fatal_error "require no space between \`-L' and \`$1'"
+ else
+ func_fatal_error "need path for \`-L' option"
+ fi
+ fi
+ func_resolve_sysroot "$func_stripname_result"
+ dir=$func_resolve_sysroot_result
+ # We need an absolute path.
+ case $dir in
+ [\\/]* | [A-Za-z]:[\\/]*) ;;
+ *)
+ absdir=`cd "$dir" && pwd`
+ test -z "$absdir" && \
+ func_fatal_error "cannot determine absolute directory name of \`$dir'"
+ dir="$absdir"
+ ;;
+ esac
+ case "$deplibs " in
+ *" -L$dir "* | *" $arg "*)
+ # Will only happen for absolute or sysroot arguments
+ ;;
+ *)
+ # Preserve sysroot, but never include relative directories
+ case $dir in
+ [\\/]* | [A-Za-z]:[\\/]* | =*) func_append deplibs " $arg" ;;
+ *) func_append deplibs " -L$dir" ;;
+ esac
+ func_append lib_search_path " $dir"
+ ;;
+ esac
+ case $host in
+ *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*)
+ testbindir=`$ECHO "$dir" | $SED 's*/lib$*/bin*'`
+ case :$dllsearchpath: in
+ *":$dir:"*) ;;
+ ::) dllsearchpath=$dir;;
+ *) func_append dllsearchpath ":$dir";;
+ esac
+ case :$dllsearchpath: in
+ *":$testbindir:"*) ;;
+ ::) dllsearchpath=$testbindir;;
+ *) func_append dllsearchpath ":$testbindir";;
+ esac
+ ;;
+ esac
+ continue
+ ;;
+
+ -l*)
+ if test "X$arg" = "X-lc" || test "X$arg" = "X-lm"; then
+ case $host in
+ *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-beos* | *-cegcc* | *-*-haiku*)
+ # These systems don't actually have a C or math library (as such)
+ continue
+ ;;
+ *-*-os2*)
+ # These systems don't actually have a C library (as such)
+ test "X$arg" = "X-lc" && continue
+ ;;
+ *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*)
+ # Do not include libc due to us having libc/libc_r.
+ test "X$arg" = "X-lc" && continue
+ ;;
+ *-*-rhapsody* | *-*-darwin1.[012])
+ # Rhapsody C and math libraries are in the System framework
+ func_append deplibs " System.ltframework"
+ continue
+ ;;
+ *-*-sco3.2v5* | *-*-sco5v6*)
+ # Causes problems with __ctype
+ test "X$arg" = "X-lc" && continue
+ ;;
+ *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*)
+ # Compiler inserts libc in the correct place for threads to work
+ test "X$arg" = "X-lc" && continue
+ ;;
+ esac
+ elif test "X$arg" = "X-lc_r"; then
+ case $host in
+ *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*)
+ # Do not include libc_r directly, use -pthread flag.
+ continue
+ ;;
+ esac
+ fi
+ func_append deplibs " $arg"
+ continue
+ ;;
+
+ -module)
+ module=yes
+ continue
+ ;;
+
+ # Tru64 UNIX uses -model [arg] to determine the layout of C++
+ # classes, name mangling, and exception handling.
+ # Darwin uses the -arch flag to determine output architecture.
+ -model|-arch|-isysroot|--sysroot)
+ func_append compiler_flags " $arg"
+ func_append compile_command " $arg"
+ func_append finalize_command " $arg"
+ prev=xcompiler
+ continue
+ ;;
+
+ -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe \
+ |-threads|-fopenmp|-openmp|-mp|-xopenmp|-omp|-qsmp=*)
+ func_append compiler_flags " $arg"
+ func_append compile_command " $arg"
+ func_append finalize_command " $arg"
+ case "$new_inherited_linker_flags " in
+ *" $arg "*) ;;
+ * ) func_append new_inherited_linker_flags " $arg" ;;
+ esac
+ continue
+ ;;
+
+ -multi_module)
+ single_module="${wl}-multi_module"
+ continue
+ ;;
+
+ -no-fast-install)
+ fast_install=no
+ continue
+ ;;
+
+ -no-install)
+ case $host in
+ *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-darwin* | *-cegcc*)
+ # The PATH hackery in wrapper scripts is required on Windows
+ # and Darwin in order for the loader to find any dlls it needs.
+ func_warning "\`-no-install' is ignored for $host"
+ func_warning "assuming \`-no-fast-install' instead"
+ fast_install=no
+ ;;
+ *) no_install=yes ;;
+ esac
+ continue
+ ;;
+
+ -no-undefined)
+ allow_undefined=no
+ continue
+ ;;
+
+ -objectlist)
+ prev=objectlist
+ continue
+ ;;
+
+ -o) prev=output ;;
+
+ -precious-files-regex)
+ prev=precious_regex
+ continue
+ ;;
+
+ -release)
+ prev=release
+ continue
+ ;;
+
+ -rpath)
+ prev=rpath
+ continue
+ ;;
+
+ -R)
+ prev=xrpath
+ continue
+ ;;
+
+ -R*)
+ func_stripname '-R' '' "$arg"
+ dir=$func_stripname_result
+ # We need an absolute path.
+ case $dir in
+ [\\/]* | [A-Za-z]:[\\/]*) ;;
+ =*)
+ func_stripname '=' '' "$dir"
+ dir=$lt_sysroot$func_stripname_result
+ ;;
+ *)
+ func_fatal_error "only absolute run-paths are allowed"
+ ;;
+ esac
+ case "$xrpath " in
+ *" $dir "*) ;;
+ *) func_append xrpath " $dir" ;;
+ esac
+ continue
+ ;;
+
+ -shared)
+ # The effects of -shared are defined in a previous loop.
+ continue
+ ;;
+
+ -shrext)
+ prev=shrext
+ continue
+ ;;
+
+ -static | -static-libtool-libs)
+ # The effects of -static are defined in a previous loop.
+ # We used to do the same as -all-static on platforms that
+ # didn't have a PIC flag, but the assumption that the effects
+ # would be equivalent was wrong. It would break on at least
+ # Digital Unix and AIX.
+ continue
+ ;;
+
+ -thread-safe)
+ thread_safe=yes
+ continue
+ ;;
+
+ -version-info)
+ prev=vinfo
+ continue
+ ;;
+
+ -version-number)
+ prev=vinfo
+ vinfo_number=yes
+ continue
+ ;;
+
+ -weak)
+ prev=weak
+ continue
+ ;;
+
+ -Wc,*)
+ func_stripname '-Wc,' '' "$arg"
+ args=$func_stripname_result
+ arg=
+ save_ifs="$IFS"; IFS=','
+ for flag in $args; do
+ IFS="$save_ifs"
+ func_quote_for_eval "$flag"
+ func_append arg " $func_quote_for_eval_result"
+ func_append compiler_flags " $func_quote_for_eval_result"
+ done
+ IFS="$save_ifs"
+ func_stripname ' ' '' "$arg"
+ arg=$func_stripname_result
+ ;;
+
+ -Wl,*)
+ func_stripname '-Wl,' '' "$arg"
+ args=$func_stripname_result
+ arg=
+ save_ifs="$IFS"; IFS=','
+ for flag in $args; do
+ IFS="$save_ifs"
+ func_quote_for_eval "$flag"
+ func_append arg " $wl$func_quote_for_eval_result"
+ func_append compiler_flags " $wl$func_quote_for_eval_result"
+ func_append linker_flags " $func_quote_for_eval_result"
+ done
+ IFS="$save_ifs"
+ func_stripname ' ' '' "$arg"
+ arg=$func_stripname_result
+ ;;
+
+ -Xcompiler)
+ prev=xcompiler
+ continue
+ ;;
+
+ -Xlinker)
+ prev=xlinker
+ continue
+ ;;
+
+ -XCClinker)
+ prev=xcclinker
+ continue
+ ;;
+
+ # -msg_* for osf cc
+ -msg_*)
+ func_quote_for_eval "$arg"
+ arg="$func_quote_for_eval_result"
+ ;;
+
+ # Flags to be passed through unchanged, with rationale:
+ # -64, -mips[0-9] enable 64-bit mode for the SGI compiler
+ # -r[0-9][0-9]* specify processor for the SGI compiler
+ # -xarch=*, -xtarget=* enable 64-bit mode for the Sun compiler
+ # +DA*, +DD* enable 64-bit mode for the HP compiler
+ # -q* compiler args for the IBM compiler
+ # -m*, -t[45]*, -txscale* architecture-specific flags for GCC
+ # -F/path path to uninstalled frameworks, gcc on darwin
+ # -p, -pg, --coverage, -fprofile-* profiling flags for GCC
+ # @file GCC response files
+ # -tp=* Portland pgcc target processor selection
+ # --sysroot=* for sysroot support
+ # -O*, -flto*, -fwhopr*, -fuse-linker-plugin GCC link-time optimization
+ -64|-mips[0-9]|-r[0-9][0-9]*|-xarch=*|-xtarget=*|+DA*|+DD*|-q*|-m*| \
+ -t[45]*|-txscale*|-p|-pg|--coverage|-fprofile-*|-F*|@*|-tp=*|--sysroot=*| \
+ -O*|-flto*|-fwhopr*|-fuse-linker-plugin)
+ func_quote_for_eval "$arg"
+ arg="$func_quote_for_eval_result"
+ func_append compile_command " $arg"
+ func_append finalize_command " $arg"
+ func_append compiler_flags " $arg"
+ continue
+ ;;
+
+ # Some other compiler flag.
+ -* | +*)
+ func_quote_for_eval "$arg"
+ arg="$func_quote_for_eval_result"
+ ;;
+
+ *.$objext)
+ # A standard object.
+ func_append objs " $arg"
+ ;;
+
+ *.lo)
+ # A libtool-controlled object.
+
+ # Check to see that this really is a libtool object.
+ if func_lalib_unsafe_p "$arg"; then
+ pic_object=
+ non_pic_object=
+
+ # Read the .lo file
+ func_source "$arg"
+
+ if test -z "$pic_object" ||
+ test -z "$non_pic_object" ||
+ test "$pic_object" = none &&
+ test "$non_pic_object" = none; then
+ func_fatal_error "cannot find name of object for \`$arg'"
+ fi
+
+ # Extract subdirectory from the argument.
+ func_dirname "$arg" "/" ""
+ xdir="$func_dirname_result"
+
+ if test "$pic_object" != none; then
+ # Prepend the subdirectory the object is found in.
+ pic_object="$xdir$pic_object"
+
+ if test "$prev" = dlfiles; then
+ if test "$build_libtool_libs" = yes && test "$dlopen_support" = yes; then
+ func_append dlfiles " $pic_object"
+ prev=
+ continue
+ else
+ # If libtool objects are unsupported, then we need to preload.
+ prev=dlprefiles
+ fi
+ fi
+
+ # CHECK ME: I think I busted this. -Ossama
+ if test "$prev" = dlprefiles; then
+ # Preload the old-style object.
+ func_append dlprefiles " $pic_object"
+ prev=
+ fi
+
+ # A PIC object.
+ func_append libobjs " $pic_object"
+ arg="$pic_object"
+ fi
+
+ # Non-PIC object.
+ if test "$non_pic_object" != none; then
+ # Prepend the subdirectory the object is found in.
+ non_pic_object="$xdir$non_pic_object"
+
+ # A standard non-PIC object
+ func_append non_pic_objects " $non_pic_object"
+ if test -z "$pic_object" || test "$pic_object" = none ; then
+ arg="$non_pic_object"
+ fi
+ else
+ # If the PIC object exists, use it instead.
+ # $xdir was prepended to $pic_object above.
+ non_pic_object="$pic_object"
+ func_append non_pic_objects " $non_pic_object"
+ fi
+ else
+ # Only an error if not doing a dry-run.
+ if $opt_dry_run; then
+ # Extract subdirectory from the argument.
+ func_dirname "$arg" "/" ""
+ xdir="$func_dirname_result"
+
+ func_lo2o "$arg"
+ pic_object=$xdir$objdir/$func_lo2o_result
+ non_pic_object=$xdir$func_lo2o_result
+ func_append libobjs " $pic_object"
+ func_append non_pic_objects " $non_pic_object"
+ else
+ func_fatal_error "\`$arg' is not a valid libtool object"
+ fi
+ fi
+ ;;
+
+ *.$libext)
+ # An archive.
+ func_append deplibs " $arg"
+ func_append old_deplibs " $arg"
+ continue
+ ;;
+
+ *.la)
+ # A libtool-controlled library.
+
+ func_resolve_sysroot "$arg"
+ if test "$prev" = dlfiles; then
+ # This library was specified with -dlopen.
+ func_append dlfiles " $func_resolve_sysroot_result"
+ prev=
+ elif test "$prev" = dlprefiles; then
+ # The library was specified with -dlpreopen.
+ func_append dlprefiles " $func_resolve_sysroot_result"
+ prev=
+ else
+ func_append deplibs " $func_resolve_sysroot_result"
+ fi
+ continue
+ ;;
+
+ # Some other compiler argument.
+ *)
+ # Unknown arguments in both finalize_command and compile_command need
+ # to be aesthetically quoted because they are evaled later.
+ func_quote_for_eval "$arg"
+ arg="$func_quote_for_eval_result"
+ ;;
+ esac # arg
+
+ # Now actually substitute the argument into the commands.
+ if test -n "$arg"; then
+ func_append compile_command " $arg"
+ func_append finalize_command " $arg"
+ fi
+ done # argument parsing loop
+
+ test -n "$prev" && \
+ func_fatal_help "the \`$prevarg' option requires an argument"
+
+ if test "$export_dynamic" = yes && test -n "$export_dynamic_flag_spec"; then
+ eval arg=\"$export_dynamic_flag_spec\"
+ func_append compile_command " $arg"
+ func_append finalize_command " $arg"
+ fi
+
+ oldlibs=
+ # calculate the name of the file, without its directory
+ func_basename "$output"
+ outputname="$func_basename_result"
+ libobjs_save="$libobjs"
+
+ if test -n "$shlibpath_var"; then
+ # get the directories listed in $shlibpath_var
+ eval shlib_search_path=\`\$ECHO \"\${$shlibpath_var}\" \| \$SED \'s/:/ /g\'\`
+ else
+ shlib_search_path=
+ fi
+ eval sys_lib_search_path=\"$sys_lib_search_path_spec\"
+ eval sys_lib_dlsearch_path=\"$sys_lib_dlsearch_path_spec\"
+
+ func_dirname "$output" "/" ""
+ output_objdir="$func_dirname_result$objdir"
+ func_to_tool_file "$output_objdir/"
+ tool_output_objdir=$func_to_tool_file_result
+ # Create the object directory.
+ func_mkdir_p "$output_objdir"
+
+ # Determine the type of output
+ case $output in
+ "")
+ func_fatal_help "you must specify an output file"
+ ;;
+ *.$libext) linkmode=oldlib ;;
+ *.lo | *.$objext) linkmode=obj ;;
+ *.la) linkmode=lib ;;
+ *) linkmode=prog ;; # Anything else should be a program.
+ esac
+
+ specialdeplibs=
+
+ libs=
+ # Find all interdependent deplibs by searching for libraries
+ # that are linked more than once (e.g. -la -lb -la)
+ for deplib in $deplibs; do
+ if $opt_preserve_dup_deps ; then
+ case "$libs " in
+ *" $deplib "*) func_append specialdeplibs " $deplib" ;;
+ esac
+ fi
+ func_append libs " $deplib"
+ done
+
+ if test "$linkmode" = lib; then
+ libs="$predeps $libs $compiler_lib_search_path $postdeps"
+
+ # Compute libraries that are listed more than once in $predeps
+ # $postdeps and mark them as special (i.e., whose duplicates are
+ # not to be eliminated).
+ pre_post_deps=
+ if $opt_duplicate_compiler_generated_deps; then
+ for pre_post_dep in $predeps $postdeps; do
+ case "$pre_post_deps " in
+ *" $pre_post_dep "*) func_append specialdeplibs " $pre_post_deps" ;;
+ esac
+ func_append pre_post_deps " $pre_post_dep"
+ done
+ fi
+ pre_post_deps=
+ fi
+
+ deplibs=
+ newdependency_libs=
+ newlib_search_path=
+ need_relink=no # whether we're linking any uninstalled libtool libraries
+ notinst_deplibs= # not-installed libtool libraries
+ notinst_path= # paths that contain not-installed libtool libraries
+
+ case $linkmode in
+ lib)
+ passes="conv dlpreopen link"
+ for file in $dlfiles $dlprefiles; do
+ case $file in
+ *.la) ;;
+ *)
+ func_fatal_help "libraries can \`-dlopen' only libtool libraries: $file"
+ ;;
+ esac
+ done
+ ;;
+ prog)
+ compile_deplibs=
+ finalize_deplibs=
+ alldeplibs=no
+ newdlfiles=
+ newdlprefiles=
+ passes="conv scan dlopen dlpreopen link"
+ ;;
+ *) passes="conv"
+ ;;
+ esac
+
+ for pass in $passes; do
+ # The preopen pass in lib mode reverses $deplibs; put it back here
+ # so that -L comes before libs that need it for instance...
+ if test "$linkmode,$pass" = "lib,link"; then
+ ## FIXME: Find the place where the list is rebuilt in the wrong
+ ## order, and fix it there properly
+ tmp_deplibs=
+ for deplib in $deplibs; do
+ tmp_deplibs="$deplib $tmp_deplibs"
+ done
+ deplibs="$tmp_deplibs"
+ fi
+
+ if test "$linkmode,$pass" = "lib,link" ||
+ test "$linkmode,$pass" = "prog,scan"; then
+ libs="$deplibs"
+ deplibs=
+ fi
+ if test "$linkmode" = prog; then
+ case $pass in
+ dlopen) libs="$dlfiles" ;;
+ dlpreopen) libs="$dlprefiles" ;;
+ link) libs="$deplibs %DEPLIBS% $dependency_libs" ;;
+ esac
+ fi
+ if test "$linkmode,$pass" = "lib,dlpreopen"; then
+ # Collect and forward deplibs of preopened libtool libs
+ for lib in $dlprefiles; do
+ # Ignore non-libtool-libs
+ dependency_libs=
+ func_resolve_sysroot "$lib"
+ case $lib in
+ *.la) func_source "$func_resolve_sysroot_result" ;;
+ esac
+
+ # Collect preopened libtool deplibs, except any this library
+ # has declared as weak libs
+ for deplib in $dependency_libs; do
+ func_basename "$deplib"
+ deplib_base=$func_basename_result
+ case " $weak_libs " in
+ *" $deplib_base "*) ;;
+ *) func_append deplibs " $deplib" ;;
+ esac
+ done
+ done
+ libs="$dlprefiles"
+ fi
+ if test "$pass" = dlopen; then
+ # Collect dlpreopened libraries
+ save_deplibs="$deplibs"
+ deplibs=
+ fi
+
+ for deplib in $libs; do
+ lib=
+ found=no
+ case $deplib in
+ -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe \
+ |-threads|-fopenmp|-openmp|-mp|-xopenmp|-omp|-qsmp=*)
+ if test "$linkmode,$pass" = "prog,link"; then
+ compile_deplibs="$deplib $compile_deplibs"
+ finalize_deplibs="$deplib $finalize_deplibs"
+ else
+ func_append compiler_flags " $deplib"
+ if test "$linkmode" = lib ; then
+ case "$new_inherited_linker_flags " in
+ *" $deplib "*) ;;
+ * ) func_append new_inherited_linker_flags " $deplib" ;;
+ esac
+ fi
+ fi
+ continue
+ ;;
+ -l*)
+ if test "$linkmode" != lib && test "$linkmode" != prog; then
+ func_warning "\`-l' is ignored for archives/objects"
+ continue
+ fi
+ func_stripname '-l' '' "$deplib"
+ name=$func_stripname_result
+ if test "$linkmode" = lib; then
+ searchdirs="$newlib_search_path $lib_search_path $compiler_lib_search_dirs $sys_lib_search_path $shlib_search_path"
+ else
+ searchdirs="$newlib_search_path $lib_search_path $sys_lib_search_path $shlib_search_path"
+ fi
+ for searchdir in $searchdirs; do
+ for search_ext in .la $std_shrext .so .a; do
+ # Search the libtool library
+ lib="$searchdir/lib${name}${search_ext}"
+ if test -f "$lib"; then
+ if test "$search_ext" = ".la"; then
+ found=yes
+ else
+ found=no
+ fi
+ break 2
+ fi
+ done
+ done
+ if test "$found" != yes; then
+ # deplib doesn't seem to be a libtool library
+ if test "$linkmode,$pass" = "prog,link"; then
+ compile_deplibs="$deplib $compile_deplibs"
+ finalize_deplibs="$deplib $finalize_deplibs"
+ else
+ deplibs="$deplib $deplibs"
+ test "$linkmode" = lib && newdependency_libs="$deplib $newdependency_libs"
+ fi
+ continue
+ else # deplib is a libtool library
+ # If $allow_libtool_libs_with_static_runtimes && $deplib is a stdlib,
+ # We need to do some special things here, and not later.
+ if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
+ case " $predeps $postdeps " in
+ *" $deplib "*)
+ if func_lalib_p "$lib"; then
+ library_names=
+ old_library=
+ func_source "$lib"
+ for l in $old_library $library_names; do
+ ll="$l"
+ done
+ if test "X$ll" = "X$old_library" ; then # only static version available
+ found=no
+ func_dirname "$lib" "" "."
+ ladir="$func_dirname_result"
+ lib=$ladir/$old_library
+ if test "$linkmode,$pass" = "prog,link"; then
+ compile_deplibs="$deplib $compile_deplibs"
+ finalize_deplibs="$deplib $finalize_deplibs"
+ else
+ deplibs="$deplib $deplibs"
+ test "$linkmode" = lib && newdependency_libs="$deplib $newdependency_libs"
+ fi
+ continue
+ fi
+ fi
+ ;;
+ *) ;;
+ esac
+ fi
+ fi
+ ;; # -l
+ *.ltframework)
+ if test "$linkmode,$pass" = "prog,link"; then
+ compile_deplibs="$deplib $compile_deplibs"
+ finalize_deplibs="$deplib $finalize_deplibs"
+ else
+ deplibs="$deplib $deplibs"
+ if test "$linkmode" = lib ; then
+ case "$new_inherited_linker_flags " in
+ *" $deplib "*) ;;
+ * ) func_append new_inherited_linker_flags " $deplib" ;;
+ esac
+ fi
+ fi
+ continue
+ ;;
+ -L*)
+ case $linkmode in
+ lib)
+ deplibs="$deplib $deplibs"
+ test "$pass" = conv && continue
+ newdependency_libs="$deplib $newdependency_libs"
+ func_stripname '-L' '' "$deplib"
+ func_resolve_sysroot "$func_stripname_result"
+ func_append newlib_search_path " $func_resolve_sysroot_result"
+ ;;
+ prog)
+ if test "$pass" = conv; then
+ deplibs="$deplib $deplibs"
+ continue
+ fi
+ if test "$pass" = scan; then
+ deplibs="$deplib $deplibs"
+ else
+ compile_deplibs="$deplib $compile_deplibs"
+ finalize_deplibs="$deplib $finalize_deplibs"
+ fi
+ func_stripname '-L' '' "$deplib"
+ func_resolve_sysroot "$func_stripname_result"
+ func_append newlib_search_path " $func_resolve_sysroot_result"
+ ;;
+ *)
+ func_warning "\`-L' is ignored for archives/objects"
+ ;;
+ esac # linkmode
+ continue
+ ;; # -L
+ -R*)
+ if test "$pass" = link; then
+ func_stripname '-R' '' "$deplib"
+ func_resolve_sysroot "$func_stripname_result"
+ dir=$func_resolve_sysroot_result
+ # Make sure the xrpath contains only unique directories.
+ case "$xrpath " in
+ *" $dir "*) ;;
+ *) func_append xrpath " $dir" ;;
+ esac
+ fi
+ deplibs="$deplib $deplibs"
+ continue
+ ;;
+ *.la)
+ func_resolve_sysroot "$deplib"
+ lib=$func_resolve_sysroot_result
+ ;;
+ *.$libext)
+ if test "$pass" = conv; then
+ deplibs="$deplib $deplibs"
+ continue
+ fi
+ case $linkmode in
+ lib)
+ # Linking convenience modules into shared libraries is allowed,
+ # but linking other static libraries is non-portable.
+ case " $dlpreconveniencelibs " in
+ *" $deplib "*) ;;
+ *)
+ valid_a_lib=no
+ case $deplibs_check_method in
+ match_pattern*)
+ set dummy $deplibs_check_method; shift
+ match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"`
+ if eval "\$ECHO \"$deplib\"" 2>/dev/null | $SED 10q \
+ | $EGREP "$match_pattern_regex" > /dev/null; then
+ valid_a_lib=yes
+ fi
+ ;;
+ pass_all)
+ valid_a_lib=yes
+ ;;
+ esac
+ if test "$valid_a_lib" != yes; then
+ echo
+ $ECHO "*** Warning: Trying to link with static lib archive $deplib."
+ echo "*** I have the capability to make that library automatically link in when"
+ echo "*** you link to this library. But I can only do this if you have a"
+ echo "*** shared version of the library, which you do not appear to have"
+ echo "*** because the file extensions .$libext of this argument makes me believe"
+ echo "*** that it is just a static archive that I should not use here."
+ else
+ echo
+ $ECHO "*** Warning: Linking the shared library $output against the"
+ $ECHO "*** static library $deplib is not portable!"
+ deplibs="$deplib $deplibs"
+ fi
+ ;;
+ esac
+ continue
+ ;;
+ prog)
+ if test "$pass" != link; then
+ deplibs="$deplib $deplibs"
+ else
+ compile_deplibs="$deplib $compile_deplibs"
+ finalize_deplibs="$deplib $finalize_deplibs"
+ fi
+ continue
+ ;;
+ esac # linkmode
+ ;; # *.$libext
+ *.lo | *.$objext)
+ if test "$pass" = conv; then
+ deplibs="$deplib $deplibs"
+ elif test "$linkmode" = prog; then
+ if test "$pass" = dlpreopen || test "$dlopen_support" != yes || test "$build_libtool_libs" = no; then
+ # If there is no dlopen support or we're linking statically,
+ # we need to preload.
+ func_append newdlprefiles " $deplib"
+ compile_deplibs="$deplib $compile_deplibs"
+ finalize_deplibs="$deplib $finalize_deplibs"
+ else
+ func_append newdlfiles " $deplib"
+ fi
+ fi
+ continue
+ ;;
+ %DEPLIBS%)
+ alldeplibs=yes
+ continue
+ ;;
+ esac # case $deplib
+
+ if test "$found" = yes || test -f "$lib"; then :
+ else
+ func_fatal_error "cannot find the library \`$lib' or unhandled argument \`$deplib'"
+ fi
+
+ # Check to see that this really is a libtool archive.
+ func_lalib_unsafe_p "$lib" \
+ || func_fatal_error "\`$lib' is not a valid libtool archive"
+
+ func_dirname "$lib" "" "."
+ ladir="$func_dirname_result"
+
+ dlname=
+ dlopen=
+ dlpreopen=
+ libdir=
+ library_names=
+ old_library=
+ inherited_linker_flags=
+ # If the library was installed with an old release of libtool,
+ # it will not redefine variables installed, or shouldnotlink
+ installed=yes
+ shouldnotlink=no
+ avoidtemprpath=
+
+
+ # Read the .la file
+ func_source "$lib"
+
+ # Convert "-framework foo" to "foo.ltframework"
+ if test -n "$inherited_linker_flags"; then
+ tmp_inherited_linker_flags=`$ECHO "$inherited_linker_flags" | $SED 's/-framework \([^ $]*\)/\1.ltframework/g'`
+ for tmp_inherited_linker_flag in $tmp_inherited_linker_flags; do
+ case " $new_inherited_linker_flags " in
+ *" $tmp_inherited_linker_flag "*) ;;
+ *) func_append new_inherited_linker_flags " $tmp_inherited_linker_flag";;
+ esac
+ done
+ fi
+ dependency_libs=`$ECHO " $dependency_libs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
+ if test "$linkmode,$pass" = "lib,link" ||
+ test "$linkmode,$pass" = "prog,scan" ||
+ { test "$linkmode" != prog && test "$linkmode" != lib; }; then
+ test -n "$dlopen" && func_append dlfiles " $dlopen"
+ test -n "$dlpreopen" && func_append dlprefiles " $dlpreopen"
+ fi
+
+ if test "$pass" = conv; then
+ # Only check for convenience libraries
+ deplibs="$lib $deplibs"
+ if test -z "$libdir"; then
+ if test -z "$old_library"; then
+ func_fatal_error "cannot find name of link library for \`$lib'"
+ fi
+ # It is a libtool convenience library, so add in its objects.
+ func_append convenience " $ladir/$objdir/$old_library"
+ func_append old_convenience " $ladir/$objdir/$old_library"
+ elif test "$linkmode" != prog && test "$linkmode" != lib; then
+ func_fatal_error "\`$lib' is not a convenience library"
+ fi
+ tmp_libs=
+ for deplib in $dependency_libs; do
+ deplibs="$deplib $deplibs"
+ if $opt_preserve_dup_deps ; then
+ case "$tmp_libs " in
+ *" $deplib "*) func_append specialdeplibs " $deplib" ;;
+ esac
+ fi
+ func_append tmp_libs " $deplib"
+ done
+ continue
+ fi # $pass = conv
+
+
+ # Get the name of the library we link against.
+ linklib=
+ if test -n "$old_library" &&
+ { test "$prefer_static_libs" = yes ||
+ test "$prefer_static_libs,$installed" = "built,no"; }; then
+ linklib=$old_library
+ else
+ for l in $old_library $library_names; do
+ linklib="$l"
+ done
+ fi
+ if test -z "$linklib"; then
+ func_fatal_error "cannot find name of link library for \`$lib'"
+ fi
+
+ # This library was specified with -dlopen.
+ if test "$pass" = dlopen; then
+ if test -z "$libdir"; then
+ func_fatal_error "cannot -dlopen a convenience library: \`$lib'"
+ fi
+ if test -z "$dlname" ||
+ test "$dlopen_support" != yes ||
+ test "$build_libtool_libs" = no; then
+ # If there is no dlname, no dlopen support or we're linking
+ # statically, we need to preload. We also need to preload any
+ # dependent libraries so libltdl's deplib preloader doesn't
+ # bomb out in the load deplibs phase.
+ func_append dlprefiles " $lib $dependency_libs"
+ else
+ func_append newdlfiles " $lib"
+ fi
+ continue
+ fi # $pass = dlopen
+
+ # We need an absolute path.
+ case $ladir in
+ [\\/]* | [A-Za-z]:[\\/]*) abs_ladir="$ladir" ;;
+ *)
+ abs_ladir=`cd "$ladir" && pwd`
+ if test -z "$abs_ladir"; then
+ func_warning "cannot determine absolute directory name of \`$ladir'"
+ func_warning "passing it literally to the linker, although it might fail"
+ abs_ladir="$ladir"
+ fi
+ ;;
+ esac
+ func_basename "$lib"
+ laname="$func_basename_result"
+
+ # Find the relevant object directory and library name.
+ if test "X$installed" = Xyes; then
+ if test ! -f "$lt_sysroot$libdir/$linklib" && test -f "$abs_ladir/$linklib"; then
+ func_warning "library \`$lib' was moved."
+ dir="$ladir"
+ absdir="$abs_ladir"
+ libdir="$abs_ladir"
+ else
+ dir="$lt_sysroot$libdir"
+ absdir="$lt_sysroot$libdir"
+ fi
+ test "X$hardcode_automatic" = Xyes && avoidtemprpath=yes
+ else
+ if test ! -f "$ladir/$objdir/$linklib" && test -f "$abs_ladir/$linklib"; then
+ dir="$ladir"
+ absdir="$abs_ladir"
+ # Remove this search path later
+ func_append notinst_path " $abs_ladir"
+ else
+ dir="$ladir/$objdir"
+ absdir="$abs_ladir/$objdir"
+ # Remove this search path later
+ func_append notinst_path " $abs_ladir"
+ fi
+ fi # $installed = yes
+ func_stripname 'lib' '.la' "$laname"
+ name=$func_stripname_result
+
+ # This library was specified with -dlpreopen.
+ if test "$pass" = dlpreopen; then
+ if test -z "$libdir" && test "$linkmode" = prog; then
+ func_fatal_error "only libraries may -dlpreopen a convenience library: \`$lib'"
+ fi
+ case "$host" in
+ # special handling for platforms with PE-DLLs.
+ *cygwin* | *mingw* | *cegcc* )
+ # Linker will automatically link against shared library if both
+ # static and shared are present. Therefore, ensure we extract
+ # symbols from the import library if a shared library is present
+ # (otherwise, the dlopen module name will be incorrect). We do
+ # this by putting the import library name into $newdlprefiles.
+ # We recover the dlopen module name by 'saving' the la file
+ # name in a special purpose variable, and (later) extracting the
+ # dlname from the la file.
+ if test -n "$dlname"; then
+ func_tr_sh "$dir/$linklib"
+ eval "libfile_$func_tr_sh_result=\$abs_ladir/\$laname"
+ func_append newdlprefiles " $dir/$linklib"
+ else
+ func_append newdlprefiles " $dir/$old_library"
+ # Keep a list of preopened convenience libraries to check
+ # that they are being used correctly in the link pass.
+ test -z "$libdir" && \
+ func_append dlpreconveniencelibs " $dir/$old_library"
+ fi
+ ;;
+ * )
+ # Prefer using a static library (so that no silly _DYNAMIC symbols
+ # are required to link).
+ if test -n "$old_library"; then
+ func_append newdlprefiles " $dir/$old_library"
+ # Keep a list of preopened convenience libraries to check
+ # that they are being used correctly in the link pass.
+ test -z "$libdir" && \
+ func_append dlpreconveniencelibs " $dir/$old_library"
+ # Otherwise, use the dlname, so that lt_dlopen finds it.
+ elif test -n "$dlname"; then
+ func_append newdlprefiles " $dir/$dlname"
+ else
+ func_append newdlprefiles " $dir/$linklib"
+ fi
+ ;;
+ esac
+ fi # $pass = dlpreopen
+
+ if test -z "$libdir"; then
+ # Link the convenience library
+ if test "$linkmode" = lib; then
+ deplibs="$dir/$old_library $deplibs"
+ elif test "$linkmode,$pass" = "prog,link"; then
+ compile_deplibs="$dir/$old_library $compile_deplibs"
+ finalize_deplibs="$dir/$old_library $finalize_deplibs"
+ else
+ deplibs="$lib $deplibs" # used for prog,scan pass
+ fi
+ continue
+ fi
+
+
+ if test "$linkmode" = prog && test "$pass" != link; then
+ func_append newlib_search_path " $ladir"
+ deplibs="$lib $deplibs"
+
+ linkalldeplibs=no
+ if test "$link_all_deplibs" != no || test -z "$library_names" ||
+ test "$build_libtool_libs" = no; then
+ linkalldeplibs=yes
+ fi
+
+ tmp_libs=
+ for deplib in $dependency_libs; do
+ case $deplib in
+ -L*) func_stripname '-L' '' "$deplib"
+ func_resolve_sysroot "$func_stripname_result"
+ func_append newlib_search_path " $func_resolve_sysroot_result"
+ ;;
+ esac
+ # Need to link against all dependency_libs?
+ if test "$linkalldeplibs" = yes; then
+ deplibs="$deplib $deplibs"
+ else
+ # Need to hardcode shared library paths
+ # or/and link against static libraries
+ newdependency_libs="$deplib $newdependency_libs"
+ fi
+ if $opt_preserve_dup_deps ; then
+ case "$tmp_libs " in
+ *" $deplib "*) func_append specialdeplibs " $deplib" ;;
+ esac
+ fi
+ func_append tmp_libs " $deplib"
+ done # for deplib
+ continue
+ fi # $linkmode = prog...
+
+ if test "$linkmode,$pass" = "prog,link"; then
+ if test -n "$library_names" &&
+ { { test "$prefer_static_libs" = no ||
+ test "$prefer_static_libs,$installed" = "built,yes"; } ||
+ test -z "$old_library"; }; then
+ # We need to hardcode the library path
+ if test -n "$shlibpath_var" && test -z "$avoidtemprpath" ; then
+ # Make sure the rpath contains only unique directories.
+ case "$temp_rpath:" in
+ *"$absdir:"*) ;;
+ *) func_append temp_rpath "$absdir:" ;;
+ esac
+ fi
+
+ # Hardcode the library path.
+ # Skip directories that are in the system default run-time
+ # search path.
+ case " $sys_lib_dlsearch_path " in
+ *" $absdir "*) ;;
+ *)
+ case "$compile_rpath " in
+ *" $absdir "*) ;;
+ *) func_append compile_rpath " $absdir" ;;
+ esac
+ ;;
+ esac
+ case " $sys_lib_dlsearch_path " in
+ *" $libdir "*) ;;
+ *)
+ case "$finalize_rpath " in
+ *" $libdir "*) ;;
+ *) func_append finalize_rpath " $libdir" ;;
+ esac
+ ;;
+ esac
+ fi # $linkmode,$pass = prog,link...
+
+ if test "$alldeplibs" = yes &&
+ { test "$deplibs_check_method" = pass_all ||
+ { test "$build_libtool_libs" = yes &&
+ test -n "$library_names"; }; }; then
+ # We only need to search for static libraries
+ continue
+ fi
+ fi
+
+ link_static=no # Whether the deplib will be linked statically
+ use_static_libs=$prefer_static_libs
+ if test "$use_static_libs" = built && test "$installed" = yes; then
+ use_static_libs=no
+ fi
+ if test -n "$library_names" &&
+ { test "$use_static_libs" = no || test -z "$old_library"; }; then
+ case $host in
+ *cygwin* | *mingw* | *cegcc*)
+ # No point in relinking DLLs because paths are not encoded
+ func_append notinst_deplibs " $lib"
+ need_relink=no
+ ;;
+ *)
+ if test "$installed" = no; then
+ func_append notinst_deplibs " $lib"
+ need_relink=yes
+ fi
+ ;;
+ esac
+ # This is a shared library
+
+ # Warn about portability, can't link against -module's on some
+ # systems (darwin). Don't bleat about dlopened modules though!
+ dlopenmodule=""
+ for dlpremoduletest in $dlprefiles; do
+ if test "X$dlpremoduletest" = "X$lib"; then
+ dlopenmodule="$dlpremoduletest"
+ break
+ fi
+ done
+ if test -z "$dlopenmodule" && test "$shouldnotlink" = yes && test "$pass" = link; then
+ echo
+ if test "$linkmode" = prog; then
+ $ECHO "*** Warning: Linking the executable $output against the loadable module"
+ else
+ $ECHO "*** Warning: Linking the shared library $output against the loadable module"
+ fi
+ $ECHO "*** $linklib is not portable!"
+ fi
+ if test "$linkmode" = lib &&
+ test "$hardcode_into_libs" = yes; then
+ # Hardcode the library path.
+ # Skip directories that are in the system default run-time
+ # search path.
+ case " $sys_lib_dlsearch_path " in
+ *" $absdir "*) ;;
+ *)
+ case "$compile_rpath " in
+ *" $absdir "*) ;;
+ *) func_append compile_rpath " $absdir" ;;
+ esac
+ ;;
+ esac
+ case " $sys_lib_dlsearch_path " in
+ *" $libdir "*) ;;
+ *)
+ case "$finalize_rpath " in
+ *" $libdir "*) ;;
+ *) func_append finalize_rpath " $libdir" ;;
+ esac
+ ;;
+ esac
+ fi
+
+ if test -n "$old_archive_from_expsyms_cmds"; then
+ # figure out the soname
+ set dummy $library_names
+ shift
+ realname="$1"
+ shift
+ libname=`eval "\\$ECHO \"$libname_spec\""`
+ # use dlname if we got it. it's perfectly good, no?
+ if test -n "$dlname"; then
+ soname="$dlname"
+ elif test -n "$soname_spec"; then
+ # bleh windows
+ case $host in
+ *cygwin* | mingw* | *cegcc*)
+ func_arith $current - $age
+ major=$func_arith_result
+ versuffix="-$major"
+ ;;
+ esac
+ eval soname=\"$soname_spec\"
+ else
+ soname="$realname"
+ fi
+
+ # Make a new name for the extract_expsyms_cmds to use
+ soroot="$soname"
+ func_basename "$soroot"
+ soname="$func_basename_result"
+ func_stripname 'lib' '.dll' "$soname"
+ newlib=libimp-$func_stripname_result.a
+
+ # If the library has no export list, then create one now
+ if test -f "$output_objdir/$soname-def"; then :
+ else
+ func_verbose "extracting exported symbol list from \`$soname'"
+ func_execute_cmds "$extract_expsyms_cmds" 'exit $?'
+ fi
+
+ # Create $newlib
+ if test -f "$output_objdir/$newlib"; then :; else
+ func_verbose "generating import library for \`$soname'"
+ func_execute_cmds "$old_archive_from_expsyms_cmds" 'exit $?'
+ fi
+ # make sure the library variables are pointing to the new library
+ dir=$output_objdir
+ linklib=$newlib
+ fi # test -n "$old_archive_from_expsyms_cmds"
+
+ if test "$linkmode" = prog || test "$opt_mode" != relink; then
+ add_shlibpath=
+ add_dir=
+ add=
+ lib_linked=yes
+ case $hardcode_action in
+ immediate | unsupported)
+ if test "$hardcode_direct" = no; then
+ add="$dir/$linklib"
+ case $host in
+ *-*-sco3.2v5.0.[024]*) add_dir="-L$dir" ;;
+ *-*-sysv4*uw2*) add_dir="-L$dir" ;;
+ *-*-sysv5OpenUNIX* | *-*-sysv5UnixWare7.[01].[10]* | \
+ *-*-unixware7*) add_dir="-L$dir" ;;
+ *-*-darwin* )
+ # if the lib is a (non-dlopened) module then we can not
+ # link against it, someone is ignoring the earlier warnings
+ if /usr/bin/file -L $add 2> /dev/null |
+ $GREP ": [^:]* bundle" >/dev/null ; then
+ if test "X$dlopenmodule" != "X$lib"; then
+ $ECHO "*** Warning: lib $linklib is a module, not a shared library"
+ if test -z "$old_library" ; then
+ echo
+ echo "*** And there doesn't seem to be a static archive available"
+ echo "*** The link will probably fail, sorry"
+ else
+ add="$dir/$old_library"
+ fi
+ elif test -n "$old_library"; then
+ add="$dir/$old_library"
+ fi
+ fi
+ esac
+ elif test "$hardcode_minus_L" = no; then
+ case $host in
+ *-*-sunos*) add_shlibpath="$dir" ;;
+ esac
+ add_dir="-L$dir"
+ add="-l$name"
+ elif test "$hardcode_shlibpath_var" = no; then
+ add_shlibpath="$dir"
+ add="-l$name"
+ else
+ lib_linked=no
+ fi
+ ;;
+ relink)
+ if test "$hardcode_direct" = yes &&
+ test "$hardcode_direct_absolute" = no; then
+ add="$dir/$linklib"
+ elif test "$hardcode_minus_L" = yes; then
+ add_dir="-L$absdir"
+ # Try looking first in the location we're being installed to.
+ if test -n "$inst_prefix_dir"; then
+ case $libdir in
+ [\\/]*)
+ func_append add_dir " -L$inst_prefix_dir$libdir"
+ ;;
+ esac
+ fi
+ add="-l$name"
+ elif test "$hardcode_shlibpath_var" = yes; then
+ add_shlibpath="$dir"
+ add="-l$name"
+ else
+ lib_linked=no
+ fi
+ ;;
+ *) lib_linked=no ;;
+ esac
+
+ if test "$lib_linked" != yes; then
+ func_fatal_configuration "unsupported hardcode properties"
+ fi
+
+ if test -n "$add_shlibpath"; then
+ case :$compile_shlibpath: in
+ *":$add_shlibpath:"*) ;;
+ *) func_append compile_shlibpath "$add_shlibpath:" ;;
+ esac
+ fi
+ if test "$linkmode" = prog; then
+ test -n "$add_dir" && compile_deplibs="$add_dir $compile_deplibs"
+ test -n "$add" && compile_deplibs="$add $compile_deplibs"
+ else
+ test -n "$add_dir" && deplibs="$add_dir $deplibs"
+ test -n "$add" && deplibs="$add $deplibs"
+ if test "$hardcode_direct" != yes &&
+ test "$hardcode_minus_L" != yes &&
+ test "$hardcode_shlibpath_var" = yes; then
+ case :$finalize_shlibpath: in
+ *":$libdir:"*) ;;
+ *) func_append finalize_shlibpath "$libdir:" ;;
+ esac
+ fi
+ fi
+ fi
+
+ if test "$linkmode" = prog || test "$opt_mode" = relink; then
+ add_shlibpath=
+ add_dir=
+ add=
+ # Finalize command for both is simple: just hardcode it.
+ if test "$hardcode_direct" = yes &&
+ test "$hardcode_direct_absolute" = no; then
+ add="$libdir/$linklib"
+ elif test "$hardcode_minus_L" = yes; then
+ add_dir="-L$libdir"
+ add="-l$name"
+ elif test "$hardcode_shlibpath_var" = yes; then
+ case :$finalize_shlibpath: in
+ *":$libdir:"*) ;;
+ *) func_append finalize_shlibpath "$libdir:" ;;
+ esac
+ add="-l$name"
+ elif test "$hardcode_automatic" = yes; then
+ if test -n "$inst_prefix_dir" &&
+ test -f "$inst_prefix_dir$libdir/$linklib" ; then
+ add="$inst_prefix_dir$libdir/$linklib"
+ else
+ add="$libdir/$linklib"
+ fi
+ else
+ # We cannot seem to hardcode it, guess we'll fake it.
+ add_dir="-L$libdir"
+ # Try looking first in the location we're being installed to.
+ if test -n "$inst_prefix_dir"; then
+ case $libdir in
+ [\\/]*)
+ func_append add_dir " -L$inst_prefix_dir$libdir"
+ ;;
+ esac
+ fi
+ add="-l$name"
+ fi
+
+ if test "$linkmode" = prog; then
+ test -n "$add_dir" && finalize_deplibs="$add_dir $finalize_deplibs"
+ test -n "$add" && finalize_deplibs="$add $finalize_deplibs"
+ else
+ test -n "$add_dir" && deplibs="$add_dir $deplibs"
+ test -n "$add" && deplibs="$add $deplibs"
+ fi
+ fi
+ elif test "$linkmode" = prog; then
+ # Here we assume that one of hardcode_direct or hardcode_minus_L
+ # is not unsupported. This is valid on all known static and
+ # shared platforms.
+ if test "$hardcode_direct" != unsupported; then
+ test -n "$old_library" && linklib="$old_library"
+ compile_deplibs="$dir/$linklib $compile_deplibs"
+ finalize_deplibs="$dir/$linklib $finalize_deplibs"
+ else
+ compile_deplibs="-l$name -L$dir $compile_deplibs"
+ finalize_deplibs="-l$name -L$dir $finalize_deplibs"
+ fi
+ elif test "$build_libtool_libs" = yes; then
+ # Not a shared library
+ if test "$deplibs_check_method" != pass_all; then
+ # We're trying link a shared library against a static one
+ # but the system doesn't support it.
+
+ # Just print a warning and add the library to dependency_libs so
+ # that the program can be linked against the static library.
+ echo
+ $ECHO "*** Warning: This system can not link to static lib archive $lib."
+ echo "*** I have the capability to make that library automatically link in when"
+ echo "*** you link to this library. But I can only do this if you have a"
+ echo "*** shared version of the library, which you do not appear to have."
+ if test "$module" = yes; then
+ echo "*** But as you try to build a module library, libtool will still create "
+ echo "*** a static module, that should work as long as the dlopening application"
+ echo "*** is linked with the -dlopen flag to resolve symbols at runtime."
+ if test -z "$global_symbol_pipe"; then
+ echo
+ echo "*** However, this would only work if libtool was able to extract symbol"
+ echo "*** lists from a program, using \`nm' or equivalent, but libtool could"
+ echo "*** not find such a program. So, this module is probably useless."
+ echo "*** \`nm' from GNU binutils and a full rebuild may help."
+ fi
+ if test "$build_old_libs" = no; then
+ build_libtool_libs=module
+ build_old_libs=yes
+ else
+ build_libtool_libs=no
+ fi
+ fi
+ else
+ deplibs="$dir/$old_library $deplibs"
+ link_static=yes
+ fi
+ fi # link shared/static library?
+
+ if test "$linkmode" = lib; then
+ if test -n "$dependency_libs" &&
+ { test "$hardcode_into_libs" != yes ||
+ test "$build_old_libs" = yes ||
+ test "$link_static" = yes; }; then
+ # Extract -R from dependency_libs
+ temp_deplibs=
+ for libdir in $dependency_libs; do
+ case $libdir in
+ -R*) func_stripname '-R' '' "$libdir"
+ temp_xrpath=$func_stripname_result
+ case " $xrpath " in
+ *" $temp_xrpath "*) ;;
+ *) func_append xrpath " $temp_xrpath";;
+ esac;;
+ *) func_append temp_deplibs " $libdir";;
+ esac
+ done
+ dependency_libs="$temp_deplibs"
+ fi
+
+ func_append newlib_search_path " $absdir"
+ # Link against this library
+ test "$link_static" = no && newdependency_libs="$abs_ladir/$laname $newdependency_libs"
+ # ... and its dependency_libs
+ tmp_libs=
+ for deplib in $dependency_libs; do
+ newdependency_libs="$deplib $newdependency_libs"
+ case $deplib in
+ -L*) func_stripname '-L' '' "$deplib"
+ func_resolve_sysroot "$func_stripname_result";;
+ *) func_resolve_sysroot "$deplib" ;;
+ esac
+ if $opt_preserve_dup_deps ; then
+ case "$tmp_libs " in
+ *" $func_resolve_sysroot_result "*)
+ func_append specialdeplibs " $func_resolve_sysroot_result" ;;
+ esac
+ fi
+ func_append tmp_libs " $func_resolve_sysroot_result"
+ done
+
+ if test "$link_all_deplibs" != no; then
+ # Add the search paths of all dependency libraries
+ for deplib in $dependency_libs; do
+ path=
+ case $deplib in
+ -L*) path="$deplib" ;;
+ *.la)
+ func_resolve_sysroot "$deplib"
+ deplib=$func_resolve_sysroot_result
+ func_dirname "$deplib" "" "."
+ dir=$func_dirname_result
+ # We need an absolute path.
+ case $dir in
+ [\\/]* | [A-Za-z]:[\\/]*) absdir="$dir" ;;
+ *)
+ absdir=`cd "$dir" && pwd`
+ if test -z "$absdir"; then
+ func_warning "cannot determine absolute directory name of \`$dir'"
+ absdir="$dir"
+ fi
+ ;;
+ esac
+ if $GREP "^installed=no" $deplib > /dev/null; then
+ case $host in
+ *-*-darwin*)
+ depdepl=
+ eval deplibrary_names=`${SED} -n -e 's/^library_names=\(.*\)$/\1/p' $deplib`
+ if test -n "$deplibrary_names" ; then
+ for tmp in $deplibrary_names ; do
+ depdepl=$tmp
+ done
+ if test -f "$absdir/$objdir/$depdepl" ; then
+ depdepl="$absdir/$objdir/$depdepl"
+ darwin_install_name=`${OTOOL} -L $depdepl | awk '{if (NR == 2) {print $1;exit}}'`
+ if test -z "$darwin_install_name"; then
+ darwin_install_name=`${OTOOL64} -L $depdepl | awk '{if (NR == 2) {print $1;exit}}'`
+ fi
+ func_append compiler_flags " ${wl}-dylib_file ${wl}${darwin_install_name}:${depdepl}"
+ func_append linker_flags " -dylib_file ${darwin_install_name}:${depdepl}"
+ path=
+ fi
+ fi
+ ;;
+ *)
+ path="-L$absdir/$objdir"
+ ;;
+ esac
+ else
+ eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $deplib`
+ test -z "$libdir" && \
+ func_fatal_error "\`$deplib' is not a valid libtool archive"
+ test "$absdir" != "$libdir" && \
+ func_warning "\`$deplib' seems to be moved"
+
+ path="-L$absdir"
+ fi
+ ;;
+ esac
+ case " $deplibs " in
+ *" $path "*) ;;
+ *) deplibs="$path $deplibs" ;;
+ esac
+ done
+ fi # link_all_deplibs != no
+ fi # linkmode = lib
+ done # for deplib in $libs
+ if test "$pass" = link; then
+ if test "$linkmode" = "prog"; then
+ compile_deplibs="$new_inherited_linker_flags $compile_deplibs"
+ finalize_deplibs="$new_inherited_linker_flags $finalize_deplibs"
+ else
+ compiler_flags="$compiler_flags "`$ECHO " $new_inherited_linker_flags" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
+ fi
+ fi
+ dependency_libs="$newdependency_libs"
+ if test "$pass" = dlpreopen; then
+ # Link the dlpreopened libraries before other libraries
+ for deplib in $save_deplibs; do
+ deplibs="$deplib $deplibs"
+ done
+ fi
+ if test "$pass" != dlopen; then
+ if test "$pass" != conv; then
+ # Make sure lib_search_path contains only unique directories.
+ lib_search_path=
+ for dir in $newlib_search_path; do
+ case "$lib_search_path " in
+ *" $dir "*) ;;
+ *) func_append lib_search_path " $dir" ;;
+ esac
+ done
+ newlib_search_path=
+ fi
+
+ if test "$linkmode,$pass" != "prog,link"; then
+ vars="deplibs"
+ else
+ vars="compile_deplibs finalize_deplibs"
+ fi
+ for var in $vars dependency_libs; do
+ # Add libraries to $var in reverse order
+ eval tmp_libs=\"\$$var\"
+ new_libs=
+ for deplib in $tmp_libs; do
+ # FIXME: Pedantically, this is the right thing to do, so
+ # that some nasty dependency loop isn't accidentally
+ # broken:
+ #new_libs="$deplib $new_libs"
+ # Pragmatically, this seems to cause very few problems in
+ # practice:
+ case $deplib in
+ -L*) new_libs="$deplib $new_libs" ;;
+ -R*) ;;
+ *)
+ # And here is the reason: when a library appears more
+ # than once as an explicit dependence of a library, or
+ # is implicitly linked in more than once by the
+ # compiler, it is considered special, and multiple
+ # occurrences thereof are not removed. Compare this
+ # with having the same library being listed as a
+ # dependency of multiple other libraries: in this case,
+ # we know (pedantically, we assume) the library does not
+ # need to be listed more than once, so we keep only the
+ # last copy. This is not always right, but it is rare
+ # enough that we require users that really mean to play
+ # such unportable linking tricks to link the library
+ # using -Wl,-lname, so that libtool does not consider it
+ # for duplicate removal.
+ case " $specialdeplibs " in
+ *" $deplib "*) new_libs="$deplib $new_libs" ;;
+ *)
+ case " $new_libs " in
+ *" $deplib "*) ;;
+ *) new_libs="$deplib $new_libs" ;;
+ esac
+ ;;
+ esac
+ ;;
+ esac
+ done
+ tmp_libs=
+ for deplib in $new_libs; do
+ case $deplib in
+ -L*)
+ case " $tmp_libs " in
+ *" $deplib "*) ;;
+ *) func_append tmp_libs " $deplib" ;;
+ esac
+ ;;
+ *) func_append tmp_libs " $deplib" ;;
+ esac
+ done
+ eval $var=\"$tmp_libs\"
+ done # for var
+ fi
+ # Last step: remove runtime libs from dependency_libs
+ # (they stay in deplibs)
+ tmp_libs=
+ for i in $dependency_libs ; do
+ case " $predeps $postdeps $compiler_lib_search_path " in
+ *" $i "*)
+ i=""
+ ;;
+ esac
+ if test -n "$i" ; then
+ func_append tmp_libs " $i"
+ fi
+ done
+ dependency_libs=$tmp_libs
+ done # for pass
+ if test "$linkmode" = prog; then
+ dlfiles="$newdlfiles"
+ fi
+ if test "$linkmode" = prog || test "$linkmode" = lib; then
+ dlprefiles="$newdlprefiles"
+ fi
+
+ case $linkmode in
+ oldlib)
+ if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then
+ func_warning "\`-dlopen' is ignored for archives"
+ fi
+
+ case " $deplibs" in
+ *\ -l* | *\ -L*)
+ func_warning "\`-l' and \`-L' are ignored for archives" ;;
+ esac
+
+ test -n "$rpath" && \
+ func_warning "\`-rpath' is ignored for archives"
+
+ test -n "$xrpath" && \
+ func_warning "\`-R' is ignored for archives"
+
+ test -n "$vinfo" && \
+ func_warning "\`-version-info/-version-number' is ignored for archives"
+
+ test -n "$release" && \
+ func_warning "\`-release' is ignored for archives"
+
+ test -n "$export_symbols$export_symbols_regex" && \
+ func_warning "\`-export-symbols' is ignored for archives"
+
+ # Now set the variables for building old libraries.
+ build_libtool_libs=no
+ oldlibs="$output"
+ func_append objs "$old_deplibs"
+ ;;
+
+ lib)
+ # Make sure we only generate libraries of the form `libNAME.la'.
+ case $outputname in
+ lib*)
+ func_stripname 'lib' '.la' "$outputname"
+ name=$func_stripname_result
+ eval shared_ext=\"$shrext_cmds\"
+ eval libname=\"$libname_spec\"
+ ;;
+ *)
+ test "$module" = no && \
+ func_fatal_help "libtool library \`$output' must begin with \`lib'"
+
+ if test "$need_lib_prefix" != no; then
+ # Add the "lib" prefix for modules if required
+ func_stripname '' '.la' "$outputname"
+ name=$func_stripname_result
+ eval shared_ext=\"$shrext_cmds\"
+ eval libname=\"$libname_spec\"
+ else
+ func_stripname '' '.la' "$outputname"
+ libname=$func_stripname_result
+ fi
+ ;;
+ esac
+
+ if test -n "$objs"; then
+ if test "$deplibs_check_method" != pass_all; then
+ func_fatal_error "cannot build libtool library \`$output' from non-libtool objects on this host:$objs"
+ else
+ echo
+ $ECHO "*** Warning: Linking the shared library $output against the non-libtool"
+ $ECHO "*** objects $objs is not portable!"
+ func_append libobjs " $objs"
+ fi
+ fi
+
+ test "$dlself" != no && \
+ func_warning "\`-dlopen self' is ignored for libtool libraries"
+
+ set dummy $rpath
+ shift
+ test "$#" -gt 1 && \
+ func_warning "ignoring multiple \`-rpath's for a libtool library"
+
+ install_libdir="$1"
+
+ oldlibs=
+ if test -z "$rpath"; then
+ if test "$build_libtool_libs" = yes; then
+ # Building a libtool convenience library.
+ # Some compilers have problems with a `.al' extension so
+ # convenience libraries should have the same extension an
+ # archive normally would.
+ oldlibs="$output_objdir/$libname.$libext $oldlibs"
+ build_libtool_libs=convenience
+ build_old_libs=yes
+ fi
+
+ test -n "$vinfo" && \
+ func_warning "\`-version-info/-version-number' is ignored for convenience libraries"
+
+ test -n "$release" && \
+ func_warning "\`-release' is ignored for convenience libraries"
+ else
+
+ # Parse the version information argument.
+ save_ifs="$IFS"; IFS=':'
+ set dummy $vinfo 0 0 0
+ shift
+ IFS="$save_ifs"
+
+ test -n "$7" && \
+ func_fatal_help "too many parameters to \`-version-info'"
+
+ # convert absolute version numbers to libtool ages
+ # this retains compatibility with .la files and attempts
+ # to make the code below a bit more comprehensible
+
+ case $vinfo_number in
+ yes)
+ number_major="$1"
+ number_minor="$2"
+ number_revision="$3"
+ #
+ # There are really only two kinds -- those that
+ # use the current revision as the major version
+ # and those that subtract age and use age as
+ # a minor version. But, then there is irix
+ # which has an extra 1 added just for fun
+ #
+ case $version_type in
+ # correct linux to gnu/linux during the next big refactor
+ darwin|linux|osf|windows|none)
+ func_arith $number_major + $number_minor
+ current=$func_arith_result
+ age="$number_minor"
+ revision="$number_revision"
+ ;;
+ freebsd-aout|freebsd-elf|qnx|sunos)
+ current="$number_major"
+ revision="$number_minor"
+ age="0"
+ ;;
+ irix|nonstopux)
+ func_arith $number_major + $number_minor
+ current=$func_arith_result
+ age="$number_minor"
+ revision="$number_minor"
+ lt_irix_increment=no
+ ;;
+ esac
+ ;;
+ no)
+ current="$1"
+ revision="$2"
+ age="$3"
+ ;;
+ esac
+
+ # Check that each of the things are valid numbers.
+ case $current in
+ 0|[1-9]|[1-9][0-9]|[1-9][0-9][0-9]|[1-9][0-9][0-9][0-9]|[1-9][0-9][0-9][0-9][0-9]) ;;
+ *)
+ func_error "CURRENT \`$current' must be a nonnegative integer"
+ func_fatal_error "\`$vinfo' is not valid version information"
+ ;;
+ esac
+
+ case $revision in
+ 0|[1-9]|[1-9][0-9]|[1-9][0-9][0-9]|[1-9][0-9][0-9][0-9]|[1-9][0-9][0-9][0-9][0-9]) ;;
+ *)
+ func_error "REVISION \`$revision' must be a nonnegative integer"
+ func_fatal_error "\`$vinfo' is not valid version information"
+ ;;
+ esac
+
+ case $age in
+ 0|[1-9]|[1-9][0-9]|[1-9][0-9][0-9]|[1-9][0-9][0-9][0-9]|[1-9][0-9][0-9][0-9][0-9]) ;;
+ *)
+ func_error "AGE \`$age' must be a nonnegative integer"
+ func_fatal_error "\`$vinfo' is not valid version information"
+ ;;
+ esac
+
+ if test "$age" -gt "$current"; then
+ func_error "AGE \`$age' is greater than the current interface number \`$current'"
+ func_fatal_error "\`$vinfo' is not valid version information"
+ fi
+
+ # Calculate the version variables.
+ major=
+ versuffix=
+ verstring=
+ case $version_type in
+ none) ;;
+
+ darwin)
+ # Like Linux, but with the current version available in
+ # verstring for coding it into the library header
+ func_arith $current - $age
+ major=.$func_arith_result
+ versuffix="$major.$age.$revision"
+ # Darwin ld doesn't like 0 for these options...
+ func_arith $current + 1
+ minor_current=$func_arith_result
+ xlcverstring="${wl}-compatibility_version ${wl}$minor_current ${wl}-current_version ${wl}$minor_current.$revision"
+ verstring="-compatibility_version $minor_current -current_version $minor_current.$revision"
+ ;;
+
+ freebsd-aout)
+ major=".$current"
+ versuffix=".$current.$revision";
+ ;;
+
+ freebsd-elf)
+ major=".$current"
+ versuffix=".$current"
+ ;;
+
+ irix | nonstopux)
+ if test "X$lt_irix_increment" = "Xno"; then
+ func_arith $current - $age
+ else
+ func_arith $current - $age + 1
+ fi
+ major=$func_arith_result
+
+ case $version_type in
+ nonstopux) verstring_prefix=nonstopux ;;
+ *) verstring_prefix=sgi ;;
+ esac
+ verstring="$verstring_prefix$major.$revision"
+
+ # Add in all the interfaces that we are compatible with.
+ loop=$revision
+ while test "$loop" -ne 0; do
+ func_arith $revision - $loop
+ iface=$func_arith_result
+ func_arith $loop - 1
+ loop=$func_arith_result
+ verstring="$verstring_prefix$major.$iface:$verstring"
+ done
+
+ # Before this point, $major must not contain `.'.
+ major=.$major
+ versuffix="$major.$revision"
+ ;;
+
+ linux) # correct to gnu/linux during the next big refactor
+ func_arith $current - $age
+ major=.$func_arith_result
+ versuffix="$major.$age.$revision"
+ ;;
+
+ osf)
+ func_arith $current - $age
+ major=.$func_arith_result
+ versuffix=".$current.$age.$revision"
+ verstring="$current.$age.$revision"
+
+ # Add in all the interfaces that we are compatible with.
+ loop=$age
+ while test "$loop" -ne 0; do
+ func_arith $current - $loop
+ iface=$func_arith_result
+ func_arith $loop - 1
+ loop=$func_arith_result
+ verstring="$verstring:${iface}.0"
+ done
+
+ # Make executables depend on our current version.
+ func_append verstring ":${current}.0"
+ ;;
+
+ qnx)
+ major=".$current"
+ versuffix=".$current"
+ ;;
+
+ sunos)
+ major=".$current"
+ versuffix=".$current.$revision"
+ ;;
+
+ windows)
+ # Use '-' rather than '.', since we only want one
+ # extension on DOS 8.3 filesystems.
+ func_arith $current - $age
+ major=$func_arith_result
+ versuffix="-$major"
+ ;;
+
+ *)
+ func_fatal_configuration "unknown library version type \`$version_type'"
+ ;;
+ esac
+
+ # Clear the version info if we defaulted, and they specified a release.
+ if test -z "$vinfo" && test -n "$release"; then
+ major=
+ case $version_type in
+ darwin)
+ # we can't check for "0.0" in archive_cmds due to quoting
+ # problems, so we reset it completely
+ verstring=
+ ;;
+ *)
+ verstring="0.0"
+ ;;
+ esac
+ if test "$need_version" = no; then
+ versuffix=
+ else
+ versuffix=".0.0"
+ fi
+ fi
+
+ # Remove version info from name if versioning should be avoided
+ if test "$avoid_version" = yes && test "$need_version" = no; then
+ major=
+ versuffix=
+ verstring=""
+ fi
+
+ # Check to see if the archive will have undefined symbols.
+ if test "$allow_undefined" = yes; then
+ if test "$allow_undefined_flag" = unsupported; then
+ func_warning "undefined symbols not allowed in $host shared libraries"
+ build_libtool_libs=no
+ build_old_libs=yes
+ fi
+ else
+ # Don't allow undefined symbols.
+ allow_undefined_flag="$no_undefined_flag"
+ fi
+
+ fi
+
+ func_generate_dlsyms "$libname" "$libname" "yes"
+ func_append libobjs " $symfileobj"
+ test "X$libobjs" = "X " && libobjs=
+
+ if test "$opt_mode" != relink; then
+ # Remove our outputs, but don't remove object files since they
+ # may have been created when compiling PIC objects.
+ removelist=
+ tempremovelist=`$ECHO "$output_objdir/*"`
+ for p in $tempremovelist; do
+ case $p in
+ *.$objext | *.gcno)
+ ;;
+ $output_objdir/$outputname | $output_objdir/$libname.* | $output_objdir/${libname}${release}.*)
+ if test "X$precious_files_regex" != "X"; then
+ if $ECHO "$p" | $EGREP -e "$precious_files_regex" >/dev/null 2>&1
+ then
+ continue
+ fi
+ fi
+ func_append removelist " $p"
+ ;;
+ *) ;;
+ esac
+ done
+ test -n "$removelist" && \
+ func_show_eval "${RM}r \$removelist"
+ fi
+
+ # Now set the variables for building old libraries.
+ if test "$build_old_libs" = yes && test "$build_libtool_libs" != convenience ; then
+ func_append oldlibs " $output_objdir/$libname.$libext"
+
+ # Transform .lo files to .o files.
+ oldobjs="$objs "`$ECHO "$libobjs" | $SP2NL | $SED "/\.${libext}$/d; $lo2o" | $NL2SP`
+ fi
+
+ # Eliminate all temporary directories.
+ #for path in $notinst_path; do
+ # lib_search_path=`$ECHO "$lib_search_path " | $SED "s% $path % %g"`
+ # deplibs=`$ECHO "$deplibs " | $SED "s% -L$path % %g"`
+ # dependency_libs=`$ECHO "$dependency_libs " | $SED "s% -L$path % %g"`
+ #done
+
+ if test -n "$xrpath"; then
+ # If the user specified any rpath flags, then add them.
+ temp_xrpath=
+ for libdir in $xrpath; do
+ func_replace_sysroot "$libdir"
+ func_append temp_xrpath " -R$func_replace_sysroot_result"
+ case "$finalize_rpath " in
+ *" $libdir "*) ;;
+ *) func_append finalize_rpath " $libdir" ;;
+ esac
+ done
+ if test "$hardcode_into_libs" != yes || test "$build_old_libs" = yes; then
+ dependency_libs="$temp_xrpath $dependency_libs"
+ fi
+ fi
+
+ # Make sure dlfiles contains only unique files that won't be dlpreopened
+ old_dlfiles="$dlfiles"
+ dlfiles=
+ for lib in $old_dlfiles; do
+ case " $dlprefiles $dlfiles " in
+ *" $lib "*) ;;
+ *) func_append dlfiles " $lib" ;;
+ esac
+ done
+
+ # Make sure dlprefiles contains only unique files
+ old_dlprefiles="$dlprefiles"
+ dlprefiles=
+ for lib in $old_dlprefiles; do
+ case "$dlprefiles " in
+ *" $lib "*) ;;
+ *) func_append dlprefiles " $lib" ;;
+ esac
+ done
+
+ if test "$build_libtool_libs" = yes; then
+ if test -n "$rpath"; then
+ case $host in
+ *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-beos* | *-cegcc* | *-*-haiku*)
+ # these systems don't actually have a c library (as such)!
+ ;;
+ *-*-rhapsody* | *-*-darwin1.[012])
+ # Rhapsody C library is in the System framework
+ func_append deplibs " System.ltframework"
+ ;;
+ *-*-netbsd*)
+ # Don't link with libc until the a.out ld.so is fixed.
+ ;;
+ *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*)
+ # Do not include libc due to us having libc/libc_r.
+ ;;
+ *-*-sco3.2v5* | *-*-sco5v6*)
+ # Causes problems with __ctype
+ ;;
+ *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*)
+ # Compiler inserts libc in the correct place for threads to work
+ ;;
+ *)
+ # Add libc to deplibs on all other systems if necessary.
+ if test "$build_libtool_need_lc" = "yes"; then
+ func_append deplibs " -lc"
+ fi
+ ;;
+ esac
+ fi
+
+ # Transform deplibs into only deplibs that can be linked in shared.
+ name_save=$name
+ libname_save=$libname
+ release_save=$release
+ versuffix_save=$versuffix
+ major_save=$major
+ # I'm not sure if I'm treating the release correctly. I think
+ # release should show up in the -l (ie -lgmp5) so we don't want to
+ # add it in twice. Is that correct?
+ release=""
+ versuffix=""
+ major=""
+ newdeplibs=
+ droppeddeps=no
+ case $deplibs_check_method in
+ pass_all)
+ # Don't check for shared/static. Everything works.
+ # This might be a little naive. We might want to check
+ # whether the library exists or not. But this is on
+ # osf3 & osf4 and I'm not really sure... Just
+ # implementing what was already the behavior.
+ newdeplibs=$deplibs
+ ;;
+ test_compile)
+ # This code stresses the "libraries are programs" paradigm to its
+ # limits. Maybe even breaks it. We compile a program, linking it
+ # against the deplibs as a proxy for the library. Then we can check
+ # whether they linked in statically or dynamically with ldd.
+ $opt_dry_run || $RM conftest.c
+ cat > conftest.c <<EOF
+ int main() { return 0; }
+EOF
+ $opt_dry_run || $RM conftest
+ if $LTCC $LTCFLAGS -o conftest conftest.c $deplibs; then
+ ldd_output=`ldd conftest`
+ for i in $deplibs; do
+ case $i in
+ -l*)
+ func_stripname -l '' "$i"
+ name=$func_stripname_result
+ if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
+ case " $predeps $postdeps " in
+ *" $i "*)
+ func_append newdeplibs " $i"
+ i=""
+ ;;
+ esac
+ fi
+ if test -n "$i" ; then
+ libname=`eval "\\$ECHO \"$libname_spec\""`
+ deplib_matches=`eval "\\$ECHO \"$library_names_spec\""`
+ set dummy $deplib_matches; shift
+ deplib_match=$1
+ if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0 ; then
+ func_append newdeplibs " $i"
+ else
+ droppeddeps=yes
+ echo
+ $ECHO "*** Warning: dynamic linker does not accept needed library $i."
+ echo "*** I have the capability to make that library automatically link in when"
+ echo "*** you link to this library. But I can only do this if you have a"
+ echo "*** shared version of the library, which I believe you do not have"
+ echo "*** because a test_compile did reveal that the linker did not use it for"
+ echo "*** its dynamic dependency list that programs get resolved with at runtime."
+ fi
+ fi
+ ;;
+ *)
+ func_append newdeplibs " $i"
+ ;;
+ esac
+ done
+ else
+ # Error occurred in the first compile. Let's try to salvage
+ # the situation: Compile a separate program for each library.
+ for i in $deplibs; do
+ case $i in
+ -l*)
+ func_stripname -l '' "$i"
+ name=$func_stripname_result
+ $opt_dry_run || $RM conftest
+ if $LTCC $LTCFLAGS -o conftest conftest.c $i; then
+ ldd_output=`ldd conftest`
+ if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
+ case " $predeps $postdeps " in
+ *" $i "*)
+ func_append newdeplibs " $i"
+ i=""
+ ;;
+ esac
+ fi
+ if test -n "$i" ; then
+ libname=`eval "\\$ECHO \"$libname_spec\""`
+ deplib_matches=`eval "\\$ECHO \"$library_names_spec\""`
+ set dummy $deplib_matches; shift
+ deplib_match=$1
+ if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0 ; then
+ func_append newdeplibs " $i"
+ else
+ droppeddeps=yes
+ echo
+ $ECHO "*** Warning: dynamic linker does not accept needed library $i."
+ echo "*** I have the capability to make that library automatically link in when"
+ echo "*** you link to this library. But I can only do this if you have a"
+ echo "*** shared version of the library, which you do not appear to have"
+ echo "*** because a test_compile did reveal that the linker did not use this one"
+ echo "*** as a dynamic dependency that programs can get resolved with at runtime."
+ fi
+ fi
+ else
+ droppeddeps=yes
+ echo
+ $ECHO "*** Warning! Library $i is needed by this library but I was not able to"
+ echo "*** make it link in! You will probably need to install it or some"
+ echo "*** library that it depends on before this library will be fully"
+ echo "*** functional. Installing it before continuing would be even better."
+ fi
+ ;;
+ *)
+ func_append newdeplibs " $i"
+ ;;
+ esac
+ done
+ fi
+ ;;
+ file_magic*)
+ set dummy $deplibs_check_method; shift
+ file_magic_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"`
+ for a_deplib in $deplibs; do
+ case $a_deplib in
+ -l*)
+ func_stripname -l '' "$a_deplib"
+ name=$func_stripname_result
+ if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
+ case " $predeps $postdeps " in
+ *" $a_deplib "*)
+ func_append newdeplibs " $a_deplib"
+ a_deplib=""
+ ;;
+ esac
+ fi
+ if test -n "$a_deplib" ; then
+ libname=`eval "\\$ECHO \"$libname_spec\""`
+ if test -n "$file_magic_glob"; then
+ libnameglob=`func_echo_all "$libname" | $SED -e $file_magic_glob`
+ else
+ libnameglob=$libname
+ fi
+ test "$want_nocaseglob" = yes && nocaseglob=`shopt -p nocaseglob`
+ for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do
+ if test "$want_nocaseglob" = yes; then
+ shopt -s nocaseglob
+ potential_libs=`ls $i/$libnameglob[.-]* 2>/dev/null`
+ $nocaseglob
+ else
+ potential_libs=`ls $i/$libnameglob[.-]* 2>/dev/null`
+ fi
+ for potent_lib in $potential_libs; do
+ # Follow soft links.
+ if ls -lLd "$potent_lib" 2>/dev/null |
+ $GREP " -> " >/dev/null; then
+ continue
+ fi
+ # The statement above tries to avoid entering an
+ # endless loop below, in case of cyclic links.
+ # We might still enter an endless loop, since a link
+ # loop can be closed while we follow links,
+ # but so what?
+ potlib="$potent_lib"
+ while test -h "$potlib" 2>/dev/null; do
+ potliblink=`ls -ld $potlib | ${SED} 's/.* -> //'`
+ case $potliblink in
+ [\\/]* | [A-Za-z]:[\\/]*) potlib="$potliblink";;
+ *) potlib=`$ECHO "$potlib" | $SED 's,[^/]*$,,'`"$potliblink";;
+ esac
+ done
+ if eval $file_magic_cmd \"\$potlib\" 2>/dev/null |
+ $SED -e 10q |
+ $EGREP "$file_magic_regex" > /dev/null; then
+ func_append newdeplibs " $a_deplib"
+ a_deplib=""
+ break 2
+ fi
+ done
+ done
+ fi
+ if test -n "$a_deplib" ; then
+ droppeddeps=yes
+ echo
+ $ECHO "*** Warning: linker path does not have real file for library $a_deplib."
+ echo "*** I have the capability to make that library automatically link in when"
+ echo "*** you link to this library. But I can only do this if you have a"
+ echo "*** shared version of the library, which you do not appear to have"
+ echo "*** because I did check the linker path looking for a file starting"
+ if test -z "$potlib" ; then
+ $ECHO "*** with $libname but no candidates were found. (...for file magic test)"
+ else
+ $ECHO "*** with $libname and none of the candidates passed a file format test"
+ $ECHO "*** using a file magic. Last file checked: $potlib"
+ fi
+ fi
+ ;;
+ *)
+ # Add a -L argument.
+ func_append newdeplibs " $a_deplib"
+ ;;
+ esac
+ done # Gone through all deplibs.
+ ;;
+ match_pattern*)
+ set dummy $deplibs_check_method; shift
+ match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"`
+ for a_deplib in $deplibs; do
+ case $a_deplib in
+ -l*)
+ func_stripname -l '' "$a_deplib"
+ name=$func_stripname_result
+ if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
+ case " $predeps $postdeps " in
+ *" $a_deplib "*)
+ func_append newdeplibs " $a_deplib"
+ a_deplib=""
+ ;;
+ esac
+ fi
+ if test -n "$a_deplib" ; then
+ libname=`eval "\\$ECHO \"$libname_spec\""`
+ for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do
+ potential_libs=`ls $i/$libname[.-]* 2>/dev/null`
+ for potent_lib in $potential_libs; do
+ potlib="$potent_lib" # see symlink-check above in file_magic test
+ if eval "\$ECHO \"$potent_lib\"" 2>/dev/null | $SED 10q | \
+ $EGREP "$match_pattern_regex" > /dev/null; then
+ func_append newdeplibs " $a_deplib"
+ a_deplib=""
+ break 2
+ fi
+ done
+ done
+ fi
+ if test -n "$a_deplib" ; then
+ droppeddeps=yes
+ echo
+ $ECHO "*** Warning: linker path does not have real file for library $a_deplib."
+ echo "*** I have the capability to make that library automatically link in when"
+ echo "*** you link to this library. But I can only do this if you have a"
+ echo "*** shared version of the library, which you do not appear to have"
+ echo "*** because I did check the linker path looking for a file starting"
+ if test -z "$potlib" ; then
+ $ECHO "*** with $libname but no candidates were found. (...for regex pattern test)"
+ else
+ $ECHO "*** with $libname and none of the candidates passed a file format test"
+ $ECHO "*** using a regex pattern. Last file checked: $potlib"
+ fi
+ fi
+ ;;
+ *)
+ # Add a -L argument.
+ func_append newdeplibs " $a_deplib"
+ ;;
+ esac
+ done # Gone through all deplibs.
+ ;;
+ none | unknown | *)
+ newdeplibs=""
+ tmp_deplibs=`$ECHO " $deplibs" | $SED 's/ -lc$//; s/ -[LR][^ ]*//g'`
+ if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
+ for i in $predeps $postdeps ; do
+ # can't use Xsed below, because $i might contain '/'
+ tmp_deplibs=`$ECHO " $tmp_deplibs" | $SED "s,$i,,"`
+ done
+ fi
+ case $tmp_deplibs in
+ *[!\ \ ]*)
+ echo
+ if test "X$deplibs_check_method" = "Xnone"; then
+ echo "*** Warning: inter-library dependencies are not supported in this platform."
+ else
+ echo "*** Warning: inter-library dependencies are not known to be supported."
+ fi
+ echo "*** All declared inter-library dependencies are being dropped."
+ droppeddeps=yes
+ ;;
+ esac
+ ;;
+ esac
+ versuffix=$versuffix_save
+ major=$major_save
+ release=$release_save
+ libname=$libname_save
+ name=$name_save
+
+ case $host in
+ *-*-rhapsody* | *-*-darwin1.[012])
+ # On Rhapsody replace the C library with the System framework
+ newdeplibs=`$ECHO " $newdeplibs" | $SED 's/ -lc / System.ltframework /'`
+ ;;
+ esac
+
+ if test "$droppeddeps" = yes; then
+ if test "$module" = yes; then
+ echo
+ echo "*** Warning: libtool could not satisfy all declared inter-library"
+ $ECHO "*** dependencies of module $libname. Therefore, libtool will create"
+ echo "*** a static module, that should work as long as the dlopening"
+ echo "*** application is linked with the -dlopen flag."
+ if test -z "$global_symbol_pipe"; then
+ echo
+ echo "*** However, this would only work if libtool was able to extract symbol"
+ echo "*** lists from a program, using \`nm' or equivalent, but libtool could"
+ echo "*** not find such a program. So, this module is probably useless."
+ echo "*** \`nm' from GNU binutils and a full rebuild may help."
+ fi
+ if test "$build_old_libs" = no; then
+ oldlibs="$output_objdir/$libname.$libext"
+ build_libtool_libs=module
+ build_old_libs=yes
+ else
+ build_libtool_libs=no
+ fi
+ else
+ echo "*** The inter-library dependencies that have been dropped here will be"
+ echo "*** automatically added whenever a program is linked with this library"
+ echo "*** or is declared to -dlopen it."
+
+ if test "$allow_undefined" = no; then
+ echo
+ echo "*** Since this library must not contain undefined symbols,"
+ echo "*** because either the platform does not support them or"
+ echo "*** it was explicitly requested with -no-undefined,"
+ echo "*** libtool will only create a static version of it."
+ if test "$build_old_libs" = no; then
+ oldlibs="$output_objdir/$libname.$libext"
+ build_libtool_libs=module
+ build_old_libs=yes
+ else
+ build_libtool_libs=no
+ fi
+ fi
+ fi
+ fi
+ # Done checking deplibs!
+ deplibs=$newdeplibs
+ fi
+ # Time to change all our "foo.ltframework" stuff back to "-framework foo"
+ case $host in
+ *-*-darwin*)
+ newdeplibs=`$ECHO " $newdeplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
+ new_inherited_linker_flags=`$ECHO " $new_inherited_linker_flags" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
+ deplibs=`$ECHO " $deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
+ ;;
+ esac
+
+ # move library search paths that coincide with paths to not yet
+ # installed libraries to the beginning of the library search list
+ new_libs=
+ for path in $notinst_path; do
+ case " $new_libs " in
+ *" -L$path/$objdir "*) ;;
+ *)
+ case " $deplibs " in
+ *" -L$path/$objdir "*)
+ func_append new_libs " -L$path/$objdir" ;;
+ esac
+ ;;
+ esac
+ done
+ for deplib in $deplibs; do
+ case $deplib in
+ -L*)
+ case " $new_libs " in
+ *" $deplib "*) ;;
+ *) func_append new_libs " $deplib" ;;
+ esac
+ ;;
+ *) func_append new_libs " $deplib" ;;
+ esac
+ done
+ deplibs="$new_libs"
+
+ # All the library-specific variables (install_libdir is set above).
+ library_names=
+ old_library=
+ dlname=
+
+ # Test again, we may have decided not to build it any more
+ if test "$build_libtool_libs" = yes; then
+ # Remove ${wl} instances when linking with ld.
+ # FIXME: should test the right _cmds variable.
+ case $archive_cmds in
+ *\$LD\ *) wl= ;;
+ esac
+ if test "$hardcode_into_libs" = yes; then
+ # Hardcode the library paths
+ hardcode_libdirs=
+ dep_rpath=
+ rpath="$finalize_rpath"
+ test "$opt_mode" != relink && rpath="$compile_rpath$rpath"
+ for libdir in $rpath; do
+ if test -n "$hardcode_libdir_flag_spec"; then
+ if test -n "$hardcode_libdir_separator"; then
+ func_replace_sysroot "$libdir"
+ libdir=$func_replace_sysroot_result
+ if test -z "$hardcode_libdirs"; then
+ hardcode_libdirs="$libdir"
+ else
+ # Just accumulate the unique libdirs.
+ case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in
+ *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*)
+ ;;
+ *)
+ func_append hardcode_libdirs "$hardcode_libdir_separator$libdir"
+ ;;
+ esac
+ fi
+ else
+ eval flag=\"$hardcode_libdir_flag_spec\"
+ func_append dep_rpath " $flag"
+ fi
+ elif test -n "$runpath_var"; then
+ case "$perm_rpath " in
+ *" $libdir "*) ;;
+ *) func_append perm_rpath " $libdir" ;;
+ esac
+ fi
+ done
+ # Substitute the hardcoded libdirs into the rpath.
+ if test -n "$hardcode_libdir_separator" &&
+ test -n "$hardcode_libdirs"; then
+ libdir="$hardcode_libdirs"
+ eval "dep_rpath=\"$hardcode_libdir_flag_spec\""
+ fi
+ if test -n "$runpath_var" && test -n "$perm_rpath"; then
+ # We should set the runpath_var.
+ rpath=
+ for dir in $perm_rpath; do
+ func_append rpath "$dir:"
+ done
+ eval "$runpath_var='$rpath\$$runpath_var'; export $runpath_var"
+ fi
+ test -n "$dep_rpath" && deplibs="$dep_rpath $deplibs"
+ fi
+
+ shlibpath="$finalize_shlibpath"
+ test "$opt_mode" != relink && shlibpath="$compile_shlibpath$shlibpath"
+ if test -n "$shlibpath"; then
+ eval "$shlibpath_var='$shlibpath\$$shlibpath_var'; export $shlibpath_var"
+ fi
+
+ # Get the real and link names of the library.
+ eval shared_ext=\"$shrext_cmds\"
+ eval library_names=\"$library_names_spec\"
+ set dummy $library_names
+ shift
+ realname="$1"
+ shift
+
+ if test -n "$soname_spec"; then
+ eval soname=\"$soname_spec\"
+ else
+ soname="$realname"
+ fi
+ if test -z "$dlname"; then
+ dlname=$soname
+ fi
+
+ lib="$output_objdir/$realname"
+ linknames=
+ for link
+ do
+ func_append linknames " $link"
+ done
+
+ # Use standard objects if they are pic
+ test -z "$pic_flag" && libobjs=`$ECHO "$libobjs" | $SP2NL | $SED "$lo2o" | $NL2SP`
+ test "X$libobjs" = "X " && libobjs=
+
+ delfiles=
+ if test -n "$export_symbols" && test -n "$include_expsyms"; then
+ $opt_dry_run || cp "$export_symbols" "$output_objdir/$libname.uexp"
+ export_symbols="$output_objdir/$libname.uexp"
+ func_append delfiles " $export_symbols"
+ fi
+
+ orig_export_symbols=
+ case $host_os in
+ cygwin* | mingw* | cegcc*)
+ if test -n "$export_symbols" && test -z "$export_symbols_regex"; then
+ # exporting using user supplied symfile
+ if test "x`$SED 1q $export_symbols`" != xEXPORTS; then
+ # and it's NOT already a .def file. Must figure out
+ # which of the given symbols are data symbols and tag
+ # them as such. So, trigger use of export_symbols_cmds.
+ # export_symbols gets reassigned inside the "prepare
+ # the list of exported symbols" if statement, so the
+ # include_expsyms logic still works.
+ orig_export_symbols="$export_symbols"
+ export_symbols=
+ always_export_symbols=yes
+ fi
+ fi
+ ;;
+ esac
+
+ # Prepare the list of exported symbols
+ if test -z "$export_symbols"; then
+ if test "$always_export_symbols" = yes || test -n "$export_symbols_regex"; then
+ func_verbose "generating symbol list for \`$libname.la'"
+ export_symbols="$output_objdir/$libname.exp"
+ $opt_dry_run || $RM $export_symbols
+ cmds=$export_symbols_cmds
+ save_ifs="$IFS"; IFS='~'
+ for cmd1 in $cmds; do
+ IFS="$save_ifs"
+ # Take the normal branch if the nm_file_list_spec branch
+ # doesn't work or if tool conversion is not needed.
+ case $nm_file_list_spec~$to_tool_file_cmd in
+ *~func_convert_file_noop | *~func_convert_file_msys_to_w32 | ~*)
+ try_normal_branch=yes
+ eval cmd=\"$cmd1\"
+ func_len " $cmd"
+ len=$func_len_result
+ ;;
+ *)
+ try_normal_branch=no
+ ;;
+ esac
+ if test "$try_normal_branch" = yes \
+ && { test "$len" -lt "$max_cmd_len" \
+ || test "$max_cmd_len" -le -1; }
+ then
+ func_show_eval "$cmd" 'exit $?'
+ skipped_export=false
+ elif test -n "$nm_file_list_spec"; then
+ func_basename "$output"
+ output_la=$func_basename_result
+ save_libobjs=$libobjs
+ save_output=$output
+ output=${output_objdir}/${output_la}.nm
+ func_to_tool_file "$output"
+ libobjs=$nm_file_list_spec$func_to_tool_file_result
+ func_append delfiles " $output"
+ func_verbose "creating $NM input file list: $output"
+ for obj in $save_libobjs; do
+ func_to_tool_file "$obj"
+ $ECHO "$func_to_tool_file_result"
+ done > "$output"
+ eval cmd=\"$cmd1\"
+ func_show_eval "$cmd" 'exit $?'
+ output=$save_output
+ libobjs=$save_libobjs
+ skipped_export=false
+ else
+ # The command line is too long to execute in one step.
+ func_verbose "using reloadable object file for export list..."
+ skipped_export=:
+ # Break out early, otherwise skipped_export may be
+ # set to false by a later but shorter cmd.
+ break
+ fi
+ done
+ IFS="$save_ifs"
+ if test -n "$export_symbols_regex" && test "X$skipped_export" != "X:"; then
+ func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"'
+ func_show_eval '$MV "${export_symbols}T" "$export_symbols"'
+ fi
+ fi
+ fi
+
+ if test -n "$export_symbols" && test -n "$include_expsyms"; then
+ tmp_export_symbols="$export_symbols"
+ test -n "$orig_export_symbols" && tmp_export_symbols="$orig_export_symbols"
+ $opt_dry_run || eval '$ECHO "$include_expsyms" | $SP2NL >> "$tmp_export_symbols"'
+ fi
+
+ if test "X$skipped_export" != "X:" && test -n "$orig_export_symbols"; then
+ # The given exports_symbols file has to be filtered, so filter it.
+ func_verbose "filter symbol list for \`$libname.la' to tag DATA exports"
+ # FIXME: $output_objdir/$libname.filter potentially contains lots of
+ # 's' commands which not all seds can handle. GNU sed should be fine
+ # though. Also, the filter scales superlinearly with the number of
+ # global variables. join(1) would be nice here, but unfortunately
+ # isn't a blessed tool.
+ $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter
+ func_append delfiles " $export_symbols $output_objdir/$libname.filter"
+ export_symbols=$output_objdir/$libname.def
+ $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols
+ fi
+
+ tmp_deplibs=
+ for test_deplib in $deplibs; do
+ case " $convenience " in
+ *" $test_deplib "*) ;;
+ *)
+ func_append tmp_deplibs " $test_deplib"
+ ;;
+ esac
+ done
+ deplibs="$tmp_deplibs"
+
+ if test -n "$convenience"; then
+ if test -n "$whole_archive_flag_spec" &&
+ test "$compiler_needs_object" = yes &&
+ test -z "$libobjs"; then
+ # extract the archives, so we have objects to list.
+ # TODO: could optimize this to just extract one archive.
+ whole_archive_flag_spec=
+ fi
+ if test -n "$whole_archive_flag_spec"; then
+ save_libobjs=$libobjs
+ eval libobjs=\"\$libobjs $whole_archive_flag_spec\"
+ test "X$libobjs" = "X " && libobjs=
+ else
+ gentop="$output_objdir/${outputname}x"
+ func_append generated " $gentop"
+
+ func_extract_archives $gentop $convenience
+ func_append libobjs " $func_extract_archives_result"
+ test "X$libobjs" = "X " && libobjs=
+ fi
+ fi
+
+ if test "$thread_safe" = yes && test -n "$thread_safe_flag_spec"; then
+ eval flag=\"$thread_safe_flag_spec\"
+ func_append linker_flags " $flag"
+ fi
+
+ # Make a backup of the uninstalled library when relinking
+ if test "$opt_mode" = relink; then
+ $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}U && $MV $realname ${realname}U)' || exit $?
+ fi
+
+ # Do each of the archive commands.
+ if test "$module" = yes && test -n "$module_cmds" ; then
+ if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then
+ eval test_cmds=\"$module_expsym_cmds\"
+ cmds=$module_expsym_cmds
+ else
+ eval test_cmds=\"$module_cmds\"
+ cmds=$module_cmds
+ fi
+ else
+ if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then
+ eval test_cmds=\"$archive_expsym_cmds\"
+ cmds=$archive_expsym_cmds
+ else
+ eval test_cmds=\"$archive_cmds\"
+ cmds=$archive_cmds
+ fi
+ fi
+
+ if test "X$skipped_export" != "X:" &&
+ func_len " $test_cmds" &&
+ len=$func_len_result &&
+ test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then
+ :
+ else
+ # The command line is too long to link in one step, link piecewise
+ # or, if using GNU ld and skipped_export is not :, use a linker
+ # script.
+
+ # Save the value of $output and $libobjs because we want to
+ # use them later. If we have whole_archive_flag_spec, we
+ # want to use save_libobjs as it was before
+ # whole_archive_flag_spec was expanded, because we can't
+ # assume the linker understands whole_archive_flag_spec.
+ # This may have to be revisited, in case too many
+ # convenience libraries get linked in and end up exceeding
+ # the spec.
+ if test -z "$convenience" || test -z "$whole_archive_flag_spec"; then
+ save_libobjs=$libobjs
+ fi
+ save_output=$output
+ func_basename "$output"
+ output_la=$func_basename_result
+
+ # Clear the reloadable object creation command queue and
+ # initialize k to one.
+ test_cmds=
+ concat_cmds=
+ objlist=
+ last_robj=
+ k=1
+
+ if test -n "$save_libobjs" && test "X$skipped_export" != "X:" && test "$with_gnu_ld" = yes; then
+ output=${output_objdir}/${output_la}.lnkscript
+ func_verbose "creating GNU ld script: $output"
+ echo 'INPUT (' > $output
+ for obj in $save_libobjs
+ do
+ func_to_tool_file "$obj"
+ $ECHO "$func_to_tool_file_result" >> $output
+ done
+ echo ')' >> $output
+ func_append delfiles " $output"
+ func_to_tool_file "$output"
+ output=$func_to_tool_file_result
+ elif test -n "$save_libobjs" && test "X$skipped_export" != "X:" && test "X$file_list_spec" != X; then
+ output=${output_objdir}/${output_la}.lnk
+ func_verbose "creating linker input file list: $output"
+ : > $output
+ set x $save_libobjs
+ shift
+ firstobj=
+ if test "$compiler_needs_object" = yes; then
+ firstobj="$1 "
+ shift
+ fi
+ for obj
+ do
+ func_to_tool_file "$obj"
+ $ECHO "$func_to_tool_file_result" >> $output
+ done
+ func_append delfiles " $output"
+ func_to_tool_file "$output"
+ output=$firstobj\"$file_list_spec$func_to_tool_file_result\"
+ else
+ if test -n "$save_libobjs"; then
+ func_verbose "creating reloadable object files..."
+ output=$output_objdir/$output_la-${k}.$objext
+ eval test_cmds=\"$reload_cmds\"
+ func_len " $test_cmds"
+ len0=$func_len_result
+ len=$len0
+
+ # Loop over the list of objects to be linked.
+ for obj in $save_libobjs
+ do
+ func_len " $obj"
+ func_arith $len + $func_len_result
+ len=$func_arith_result
+ if test "X$objlist" = X ||
+ test "$len" -lt "$max_cmd_len"; then
+ func_append objlist " $obj"
+ else
+ # The command $test_cmds is almost too long, add a
+ # command to the queue.
+ if test "$k" -eq 1 ; then
+ # The first file doesn't have a previous command to add.
+ reload_objs=$objlist
+ eval concat_cmds=\"$reload_cmds\"
+ else
+ # All subsequent reloadable object files will link in
+ # the last one created.
+ reload_objs="$objlist $last_robj"
+ eval concat_cmds=\"\$concat_cmds~$reload_cmds~\$RM $last_robj\"
+ fi
+ last_robj=$output_objdir/$output_la-${k}.$objext
+ func_arith $k + 1
+ k=$func_arith_result
+ output=$output_objdir/$output_la-${k}.$objext
+ objlist=" $obj"
+ func_len " $last_robj"
+ func_arith $len0 + $func_len_result
+ len=$func_arith_result
+ fi
+ done
+ # Handle the remaining objects by creating one last
+ # reloadable object file. All subsequent reloadable object
+ # files will link in the last one created.
+ test -z "$concat_cmds" || concat_cmds=$concat_cmds~
+ reload_objs="$objlist $last_robj"
+ eval concat_cmds=\"\${concat_cmds}$reload_cmds\"
+ if test -n "$last_robj"; then
+ eval concat_cmds=\"\${concat_cmds}~\$RM $last_robj\"
+ fi
+ func_append delfiles " $output"
+
+ else
+ output=
+ fi
+
+ if ${skipped_export-false}; then
+ func_verbose "generating symbol list for \`$libname.la'"
+ export_symbols="$output_objdir/$libname.exp"
+ $opt_dry_run || $RM $export_symbols
+ libobjs=$output
+ # Append the command to create the export file.
+ test -z "$concat_cmds" || concat_cmds=$concat_cmds~
+ eval concat_cmds=\"\$concat_cmds$export_symbols_cmds\"
+ if test -n "$last_robj"; then
+ eval concat_cmds=\"\$concat_cmds~\$RM $last_robj\"
+ fi
+ fi
+
+ test -n "$save_libobjs" &&
+ func_verbose "creating a temporary reloadable object file: $output"
+
+ # Loop through the commands generated above and execute them.
+ save_ifs="$IFS"; IFS='~'
+ for cmd in $concat_cmds; do
+ IFS="$save_ifs"
+ $opt_silent || {
+ func_quote_for_expand "$cmd"
+ eval "func_echo $func_quote_for_expand_result"
+ }
+ $opt_dry_run || eval "$cmd" || {
+ lt_exit=$?
+
+ # Restore the uninstalled library and exit
+ if test "$opt_mode" = relink; then
+ ( cd "$output_objdir" && \
+ $RM "${realname}T" && \
+ $MV "${realname}U" "$realname" )
+ fi
+
+ exit $lt_exit
+ }
+ done
+ IFS="$save_ifs"
+
+ if test -n "$export_symbols_regex" && ${skipped_export-false}; then
+ func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"'
+ func_show_eval '$MV "${export_symbols}T" "$export_symbols"'
+ fi
+ fi
+
+ if ${skipped_export-false}; then
+ if test -n "$export_symbols" && test -n "$include_expsyms"; then
+ tmp_export_symbols="$export_symbols"
+ test -n "$orig_export_symbols" && tmp_export_symbols="$orig_export_symbols"
+ $opt_dry_run || eval '$ECHO "$include_expsyms" | $SP2NL >> "$tmp_export_symbols"'
+ fi
+
+ if test -n "$orig_export_symbols"; then
+ # The given exports_symbols file has to be filtered, so filter it.
+ func_verbose "filter symbol list for \`$libname.la' to tag DATA exports"
+ # FIXME: $output_objdir/$libname.filter potentially contains lots of
+ # 's' commands which not all seds can handle. GNU sed should be fine
+ # though. Also, the filter scales superlinearly with the number of
+ # global variables. join(1) would be nice here, but unfortunately
+ # isn't a blessed tool.
+ $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter
+ func_append delfiles " $export_symbols $output_objdir/$libname.filter"
+ export_symbols=$output_objdir/$libname.def
+ $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols
+ fi
+ fi
+
+ libobjs=$output
+ # Restore the value of output.
+ output=$save_output
+
+ if test -n "$convenience" && test -n "$whole_archive_flag_spec"; then
+ eval libobjs=\"\$libobjs $whole_archive_flag_spec\"
+ test "X$libobjs" = "X " && libobjs=
+ fi
+ # Expand the library linking commands again to reset the
+ # value of $libobjs for piecewise linking.
+
+ # Do each of the archive commands.
+ if test "$module" = yes && test -n "$module_cmds" ; then
+ if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then
+ cmds=$module_expsym_cmds
+ else
+ cmds=$module_cmds
+ fi
+ else
+ if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then
+ cmds=$archive_expsym_cmds
+ else
+ cmds=$archive_cmds
+ fi
+ fi
+ fi
+
+ if test -n "$delfiles"; then
+ # Append the command to remove temporary files to $cmds.
+ eval cmds=\"\$cmds~\$RM $delfiles\"
+ fi
+
+ # Add any objects from preloaded convenience libraries
+ if test -n "$dlprefiles"; then
+ gentop="$output_objdir/${outputname}x"
+ func_append generated " $gentop"
+
+ func_extract_archives $gentop $dlprefiles
+ func_append libobjs " $func_extract_archives_result"
+ test "X$libobjs" = "X " && libobjs=
+ fi
+
+ save_ifs="$IFS"; IFS='~'
+ for cmd in $cmds; do
+ IFS="$save_ifs"
+ eval cmd=\"$cmd\"
+ $opt_silent || {
+ func_quote_for_expand "$cmd"
+ eval "func_echo $func_quote_for_expand_result"
+ }
+ $opt_dry_run || eval "$cmd" || {
+ lt_exit=$?
+
+ # Restore the uninstalled library and exit
+ if test "$opt_mode" = relink; then
+ ( cd "$output_objdir" && \
+ $RM "${realname}T" && \
+ $MV "${realname}U" "$realname" )
+ fi
+
+ exit $lt_exit
+ }
+ done
+ IFS="$save_ifs"
+
+ # Restore the uninstalled library and exit
+ if test "$opt_mode" = relink; then
+ $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}T && $MV $realname ${realname}T && $MV ${realname}U $realname)' || exit $?
+
+ if test -n "$convenience"; then
+ if test -z "$whole_archive_flag_spec"; then
+ func_show_eval '${RM}r "$gentop"'
+ fi
+ fi
+
+ exit $EXIT_SUCCESS
+ fi
+
+ # Create links to the real library.
+ for linkname in $linknames; do
+ if test "$realname" != "$linkname"; then
+ func_show_eval '(cd "$output_objdir" && $RM "$linkname" && $LN_S "$realname" "$linkname")' 'exit $?'
+ fi
+ done
+
+ # If -module or -export-dynamic was specified, set the dlname.
+ if test "$module" = yes || test "$export_dynamic" = yes; then
+ # On all known operating systems, these are identical.
+ dlname="$soname"
+ fi
+ fi
+ ;;
+
+ obj)
+ if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then
+ func_warning "\`-dlopen' is ignored for objects"
+ fi
+
+ case " $deplibs" in
+ *\ -l* | *\ -L*)
+ func_warning "\`-l' and \`-L' are ignored for objects" ;;
+ esac
+
+ test -n "$rpath" && \
+ func_warning "\`-rpath' is ignored for objects"
+
+ test -n "$xrpath" && \
+ func_warning "\`-R' is ignored for objects"
+
+ test -n "$vinfo" && \
+ func_warning "\`-version-info' is ignored for objects"
+
+ test -n "$release" && \
+ func_warning "\`-release' is ignored for objects"
+
+ case $output in
+ *.lo)
+ test -n "$objs$old_deplibs" && \
+ func_fatal_error "cannot build library object \`$output' from non-libtool objects"
+
+ libobj=$output
+ func_lo2o "$libobj"
+ obj=$func_lo2o_result
+ ;;
+ *)
+ libobj=
+ obj="$output"
+ ;;
+ esac
+
+ # Delete the old objects.
+ $opt_dry_run || $RM $obj $libobj
+
+ # Objects from convenience libraries. This assumes
+ # single-version convenience libraries. Whenever we create
+ # different ones for PIC/non-PIC, this we'll have to duplicate
+ # the extraction.
+ reload_conv_objs=
+ gentop=
+ # reload_cmds runs $LD directly, so let us get rid of
+ # -Wl from whole_archive_flag_spec and hope we can get by with
+ # turning comma into space..
+ wl=
+
+ if test -n "$convenience"; then
+ if test -n "$whole_archive_flag_spec"; then
+ eval tmp_whole_archive_flags=\"$whole_archive_flag_spec\"
+ reload_conv_objs=$reload_objs\ `$ECHO "$tmp_whole_archive_flags" | $SED 's|,| |g'`
+ else
+ gentop="$output_objdir/${obj}x"
+ func_append generated " $gentop"
+
+ func_extract_archives $gentop $convenience
+ reload_conv_objs="$reload_objs $func_extract_archives_result"
+ fi
+ fi
+
+ # If we're not building shared, we need to use non_pic_objs
+ test "$build_libtool_libs" != yes && libobjs="$non_pic_objects"
+
+ # Create the old-style object.
+ reload_objs="$objs$old_deplibs "`$ECHO "$libobjs" | $SP2NL | $SED "/\.${libext}$/d; /\.lib$/d; $lo2o" | $NL2SP`" $reload_conv_objs" ### testsuite: skip nested quoting test
+
+ output="$obj"
+ func_execute_cmds "$reload_cmds" 'exit $?'
+
+ # Exit if we aren't doing a library object file.
+ if test -z "$libobj"; then
+ if test -n "$gentop"; then
+ func_show_eval '${RM}r "$gentop"'
+ fi
+
+ exit $EXIT_SUCCESS
+ fi
+
+ if test "$build_libtool_libs" != yes; then
+ if test -n "$gentop"; then
+ func_show_eval '${RM}r "$gentop"'
+ fi
+
+ # Create an invalid libtool object if no PIC, so that we don't
+ # accidentally link it into a program.
+ # $show "echo timestamp > $libobj"
+ # $opt_dry_run || eval "echo timestamp > $libobj" || exit $?
+ exit $EXIT_SUCCESS
+ fi
+
+ if test -n "$pic_flag" || test "$pic_mode" != default; then
+ # Only do commands if we really have different PIC objects.
+ reload_objs="$libobjs $reload_conv_objs"
+ output="$libobj"
+ func_execute_cmds "$reload_cmds" 'exit $?'
+ fi
+
+ if test -n "$gentop"; then
+ func_show_eval '${RM}r "$gentop"'
+ fi
+
+ exit $EXIT_SUCCESS
+ ;;
+
+ prog)
+ case $host in
+ *cygwin*) func_stripname '' '.exe' "$output"
+ output=$func_stripname_result.exe;;
+ esac
+ test -n "$vinfo" && \
+ func_warning "\`-version-info' is ignored for programs"
+
+ test -n "$release" && \
+ func_warning "\`-release' is ignored for programs"
+
+ test "$preload" = yes \
+ && test "$dlopen_support" = unknown \
+ && test "$dlopen_self" = unknown \
+ && test "$dlopen_self_static" = unknown && \
+ func_warning "\`LT_INIT([dlopen])' not used. Assuming no dlopen support."
+
+ case $host in
+ *-*-rhapsody* | *-*-darwin1.[012])
+ # On Rhapsody replace the C library is the System framework
+ compile_deplibs=`$ECHO " $compile_deplibs" | $SED 's/ -lc / System.ltframework /'`
+ finalize_deplibs=`$ECHO " $finalize_deplibs" | $SED 's/ -lc / System.ltframework /'`
+ ;;
+ esac
+
+ case $host in
+ *-*-darwin*)
+ # Don't allow lazy linking, it breaks C++ global constructors
+ # But is supposedly fixed on 10.4 or later (yay!).
+ if test "$tagname" = CXX ; then
+ case ${MACOSX_DEPLOYMENT_TARGET-10.0} in
+ 10.[0123])
+ func_append compile_command " ${wl}-bind_at_load"
+ func_append finalize_command " ${wl}-bind_at_load"
+ ;;
+ esac
+ fi
+ # Time to change all our "foo.ltframework" stuff back to "-framework foo"
+ compile_deplibs=`$ECHO " $compile_deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
+ finalize_deplibs=`$ECHO " $finalize_deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
+ ;;
+ esac
+
+
+ # move library search paths that coincide with paths to not yet
+ # installed libraries to the beginning of the library search list
+ new_libs=
+ for path in $notinst_path; do
+ case " $new_libs " in
+ *" -L$path/$objdir "*) ;;
+ *)
+ case " $compile_deplibs " in
+ *" -L$path/$objdir "*)
+ func_append new_libs " -L$path/$objdir" ;;
+ esac
+ ;;
+ esac
+ done
+ for deplib in $compile_deplibs; do
+ case $deplib in
+ -L*)
+ case " $new_libs " in
+ *" $deplib "*) ;;
+ *) func_append new_libs " $deplib" ;;
+ esac
+ ;;
+ *) func_append new_libs " $deplib" ;;
+ esac
+ done
+ compile_deplibs="$new_libs"
+
+
+ func_append compile_command " $compile_deplibs"
+ func_append finalize_command " $finalize_deplibs"
+
+ if test -n "$rpath$xrpath"; then
+ # If the user specified any rpath flags, then add them.
+ for libdir in $rpath $xrpath; do
+ # This is the magic to use -rpath.
+ case "$finalize_rpath " in
+ *" $libdir "*) ;;
+ *) func_append finalize_rpath " $libdir" ;;
+ esac
+ done
+ fi
+
+ # Now hardcode the library paths
+ rpath=
+ hardcode_libdirs=
+ for libdir in $compile_rpath $finalize_rpath; do
+ if test -n "$hardcode_libdir_flag_spec"; then
+ if test -n "$hardcode_libdir_separator"; then
+ if test -z "$hardcode_libdirs"; then
+ hardcode_libdirs="$libdir"
+ else
+ # Just accumulate the unique libdirs.
+ case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in
+ *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*)
+ ;;
+ *)
+ func_append hardcode_libdirs "$hardcode_libdir_separator$libdir"
+ ;;
+ esac
+ fi
+ else
+ eval flag=\"$hardcode_libdir_flag_spec\"
+ func_append rpath " $flag"
+ fi
+ elif test -n "$runpath_var"; then
+ case "$perm_rpath " in
+ *" $libdir "*) ;;
+ *) func_append perm_rpath " $libdir" ;;
+ esac
+ fi
+ case $host in
+ *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*)
+ testbindir=`${ECHO} "$libdir" | ${SED} -e 's*/lib$*/bin*'`
+ case :$dllsearchpath: in
+ *":$libdir:"*) ;;
+ ::) dllsearchpath=$libdir;;
+ *) func_append dllsearchpath ":$libdir";;
+ esac
+ case :$dllsearchpath: in
+ *":$testbindir:"*) ;;
+ ::) dllsearchpath=$testbindir;;
+ *) func_append dllsearchpath ":$testbindir";;
+ esac
+ ;;
+ esac
+ done
+ # Substitute the hardcoded libdirs into the rpath.
+ if test -n "$hardcode_libdir_separator" &&
+ test -n "$hardcode_libdirs"; then
+ libdir="$hardcode_libdirs"
+ eval rpath=\" $hardcode_libdir_flag_spec\"
+ fi
+ compile_rpath="$rpath"
+
+ rpath=
+ hardcode_libdirs=
+ for libdir in $finalize_rpath; do
+ if test -n "$hardcode_libdir_flag_spec"; then
+ if test -n "$hardcode_libdir_separator"; then
+ if test -z "$hardcode_libdirs"; then
+ hardcode_libdirs="$libdir"
+ else
+ # Just accumulate the unique libdirs.
+ case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in
+ *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*)
+ ;;
+ *)
+ func_append hardcode_libdirs "$hardcode_libdir_separator$libdir"
+ ;;
+ esac
+ fi
+ else
+ eval flag=\"$hardcode_libdir_flag_spec\"
+ func_append rpath " $flag"
+ fi
+ elif test -n "$runpath_var"; then
+ case "$finalize_perm_rpath " in
+ *" $libdir "*) ;;
+ *) func_append finalize_perm_rpath " $libdir" ;;
+ esac
+ fi
+ done
+ # Substitute the hardcoded libdirs into the rpath.
+ if test -n "$hardcode_libdir_separator" &&
+ test -n "$hardcode_libdirs"; then
+ libdir="$hardcode_libdirs"
+ eval rpath=\" $hardcode_libdir_flag_spec\"
+ fi
+ finalize_rpath="$rpath"
+
+ if test -n "$libobjs" && test "$build_old_libs" = yes; then
+ # Transform all the library objects into standard objects.
+ compile_command=`$ECHO "$compile_command" | $SP2NL | $SED "$lo2o" | $NL2SP`
+ finalize_command=`$ECHO "$finalize_command" | $SP2NL | $SED "$lo2o" | $NL2SP`
+ fi
+
+ func_generate_dlsyms "$outputname" "@PROGRAM@" "no"
+
+ # template prelinking step
+ if test -n "$prelink_cmds"; then
+ func_execute_cmds "$prelink_cmds" 'exit $?'
+ fi
+
+ wrappers_required=yes
+ case $host in
+ *cegcc* | *mingw32ce*)
+ # Disable wrappers for cegcc and mingw32ce hosts, we are cross compiling anyway.
+ wrappers_required=no
+ ;;
+ *cygwin* | *mingw* )
+ if test "$build_libtool_libs" != yes; then
+ wrappers_required=no
+ fi
+ ;;
+ *)
+ if test "$need_relink" = no || test "$build_libtool_libs" != yes; then
+ wrappers_required=no
+ fi
+ ;;
+ esac
+ if test "$wrappers_required" = no; then
+ # Replace the output file specification.
+ compile_command=`$ECHO "$compile_command" | $SED 's%@OUTPUT@%'"$output"'%g'`
+ link_command="$compile_command$compile_rpath"
+
+ # We have no uninstalled library dependencies, so finalize right now.
+ exit_status=0
+ func_show_eval "$link_command" 'exit_status=$?'
+
+ if test -n "$postlink_cmds"; then
+ func_to_tool_file "$output"
+ postlink_cmds=`func_echo_all "$postlink_cmds" | $SED -e 's%@OUTPUT@%'"$output"'%g' -e 's%@TOOL_OUTPUT@%'"$func_to_tool_file_result"'%g'`
+ func_execute_cmds "$postlink_cmds" 'exit $?'
+ fi
+
+ # Delete the generated files.
+ if test -f "$output_objdir/${outputname}S.${objext}"; then
+ func_show_eval '$RM "$output_objdir/${outputname}S.${objext}"'
+ fi
+
+ exit $exit_status
+ fi
+
+ if test -n "$compile_shlibpath$finalize_shlibpath"; then
+ compile_command="$shlibpath_var=\"$compile_shlibpath$finalize_shlibpath\$$shlibpath_var\" $compile_command"
+ fi
+ if test -n "$finalize_shlibpath"; then
+ finalize_command="$shlibpath_var=\"$finalize_shlibpath\$$shlibpath_var\" $finalize_command"
+ fi
+
+ compile_var=
+ finalize_var=
+ if test -n "$runpath_var"; then
+ if test -n "$perm_rpath"; then
+ # We should set the runpath_var.
+ rpath=
+ for dir in $perm_rpath; do
+ func_append rpath "$dir:"
+ done
+ compile_var="$runpath_var=\"$rpath\$$runpath_var\" "
+ fi
+ if test -n "$finalize_perm_rpath"; then
+ # We should set the runpath_var.
+ rpath=
+ for dir in $finalize_perm_rpath; do
+ func_append rpath "$dir:"
+ done
+ finalize_var="$runpath_var=\"$rpath\$$runpath_var\" "
+ fi
+ fi
+
+ if test "$no_install" = yes; then
+ # We don't need to create a wrapper script.
+ link_command="$compile_var$compile_command$compile_rpath"
+ # Replace the output file specification.
+ link_command=`$ECHO "$link_command" | $SED 's%@OUTPUT@%'"$output"'%g'`
+ # Delete the old output file.
+ $opt_dry_run || $RM $output
+ # Link the executable and exit
+ func_show_eval "$link_command" 'exit $?'
+
+ if test -n "$postlink_cmds"; then
+ func_to_tool_file "$output"
+ postlink_cmds=`func_echo_all "$postlink_cmds" | $SED -e 's%@OUTPUT@%'"$output"'%g' -e 's%@TOOL_OUTPUT@%'"$func_to_tool_file_result"'%g'`
+ func_execute_cmds "$postlink_cmds" 'exit $?'
+ fi
+
+ exit $EXIT_SUCCESS
+ fi
+
+ if test "$hardcode_action" = relink; then
+ # Fast installation is not supported
+ link_command="$compile_var$compile_command$compile_rpath"
+ relink_command="$finalize_var$finalize_command$finalize_rpath"
+
+ func_warning "this platform does not like uninstalled shared libraries"
+ func_warning "\`$output' will be relinked during installation"
+ else
+ if test "$fast_install" != no; then
+ link_command="$finalize_var$compile_command$finalize_rpath"
+ if test "$fast_install" = yes; then
+ relink_command=`$ECHO "$compile_var$compile_command$compile_rpath" | $SED 's%@OUTPUT@%\$progdir/\$file%g'`
+ else
+ # fast_install is set to needless
+ relink_command=
+ fi
+ else
+ link_command="$compile_var$compile_command$compile_rpath"
+ relink_command="$finalize_var$finalize_command$finalize_rpath"
+ fi
+ fi
+
+ # Replace the output file specification.
+ link_command=`$ECHO "$link_command" | $SED 's%@OUTPUT@%'"$output_objdir/$outputname"'%g'`
+
+ # Delete the old output files.
+ $opt_dry_run || $RM $output $output_objdir/$outputname $output_objdir/lt-$outputname
+
+ func_show_eval "$link_command" 'exit $?'
+
+ if test -n "$postlink_cmds"; then
+ func_to_tool_file "$output_objdir/$outputname"
+ postlink_cmds=`func_echo_all "$postlink_cmds" | $SED -e 's%@OUTPUT@%'"$output_objdir/$outputname"'%g' -e 's%@TOOL_OUTPUT@%'"$func_to_tool_file_result"'%g'`
+ func_execute_cmds "$postlink_cmds" 'exit $?'
+ fi
+
+ # Now create the wrapper script.
+ func_verbose "creating $output"
+
+ # Quote the relink command for shipping.
+ if test -n "$relink_command"; then
+ # Preserve any variables that may affect compiler behavior
+ for var in $variables_saved_for_relink; do
+ if eval test -z \"\${$var+set}\"; then
+ relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command"
+ elif eval var_value=\$$var; test -z "$var_value"; then
+ relink_command="$var=; export $var; $relink_command"
+ else
+ func_quote_for_eval "$var_value"
+ relink_command="$var=$func_quote_for_eval_result; export $var; $relink_command"
+ fi
+ done
+ relink_command="(cd `pwd`; $relink_command)"
+ relink_command=`$ECHO "$relink_command" | $SED "$sed_quote_subst"`
+ fi
+
+ # Only actually do things if not in dry run mode.
+ $opt_dry_run || {
+ # win32 will think the script is a binary if it has
+ # a .exe suffix, so we strip it off here.
+ case $output in
+ *.exe) func_stripname '' '.exe' "$output"
+ output=$func_stripname_result ;;
+ esac
+ # test for cygwin because mv fails w/o .exe extensions
+ case $host in
+ *cygwin*)
+ exeext=.exe
+ func_stripname '' '.exe' "$outputname"
+ outputname=$func_stripname_result ;;
+ *) exeext= ;;
+ esac
+ case $host in
+ *cygwin* | *mingw* )
+ func_dirname_and_basename "$output" "" "."
+ output_name=$func_basename_result
+ output_path=$func_dirname_result
+ cwrappersource="$output_path/$objdir/lt-$output_name.c"
+ cwrapper="$output_path/$output_name.exe"
+ $RM $cwrappersource $cwrapper
+ trap "$RM $cwrappersource $cwrapper; exit $EXIT_FAILURE" 1 2 15
+
+ func_emit_cwrapperexe_src > $cwrappersource
+
+ # The wrapper executable is built using the $host compiler,
+ # because it contains $host paths and files. If cross-
+ # compiling, it, like the target executable, must be
+ # executed on the $host or under an emulation environment.
+ $opt_dry_run || {
+ $LTCC $LTCFLAGS -o $cwrapper $cwrappersource
+ $STRIP $cwrapper
+ }
+
+ # Now, create the wrapper script for func_source use:
+ func_ltwrapper_scriptname $cwrapper
+ $RM $func_ltwrapper_scriptname_result
+ trap "$RM $func_ltwrapper_scriptname_result; exit $EXIT_FAILURE" 1 2 15
+ $opt_dry_run || {
+ # note: this script will not be executed, so do not chmod.
+ if test "x$build" = "x$host" ; then
+ $cwrapper --lt-dump-script > $func_ltwrapper_scriptname_result
+ else
+ func_emit_wrapper no > $func_ltwrapper_scriptname_result
+ fi
+ }
+ ;;
+ * )
+ $RM $output
+ trap "$RM $output; exit $EXIT_FAILURE" 1 2 15
+
+ func_emit_wrapper no > $output
+ chmod +x $output
+ ;;
+ esac
+ }
+ exit $EXIT_SUCCESS
+ ;;
+ esac
+
+ # See if we need to build an old-fashioned archive.
+ for oldlib in $oldlibs; do
+
+ if test "$build_libtool_libs" = convenience; then
+ oldobjs="$libobjs_save $symfileobj"
+ addlibs="$convenience"
+ build_libtool_libs=no
+ else
+ if test "$build_libtool_libs" = module; then
+ oldobjs="$libobjs_save"
+ build_libtool_libs=no
+ else
+ oldobjs="$old_deplibs $non_pic_objects"
+ if test "$preload" = yes && test -f "$symfileobj"; then
+ func_append oldobjs " $symfileobj"
+ fi
+ fi
+ addlibs="$old_convenience"
+ fi
+
+ if test -n "$addlibs"; then
+ gentop="$output_objdir/${outputname}x"
+ func_append generated " $gentop"
+
+ func_extract_archives $gentop $addlibs
+ func_append oldobjs " $func_extract_archives_result"
+ fi
+
+ # Do each command in the archive commands.
+ if test -n "$old_archive_from_new_cmds" && test "$build_libtool_libs" = yes; then
+ cmds=$old_archive_from_new_cmds
+ else
+
+ # Add any objects from preloaded convenience libraries
+ if test -n "$dlprefiles"; then
+ gentop="$output_objdir/${outputname}x"
+ func_append generated " $gentop"
+
+ func_extract_archives $gentop $dlprefiles
+ func_append oldobjs " $func_extract_archives_result"
+ fi
+
+ # POSIX demands no paths to be encoded in archives. We have
+ # to avoid creating archives with duplicate basenames if we
+ # might have to extract them afterwards, e.g., when creating a
+ # static archive out of a convenience library, or when linking
+ # the entirety of a libtool archive into another (currently
+ # not supported by libtool).
+ if (for obj in $oldobjs
+ do
+ func_basename "$obj"
+ $ECHO "$func_basename_result"
+ done | sort | sort -uc >/dev/null 2>&1); then
+ :
+ else
+ echo "copying selected object files to avoid basename conflicts..."
+ gentop="$output_objdir/${outputname}x"
+ func_append generated " $gentop"
+ func_mkdir_p "$gentop"
+ save_oldobjs=$oldobjs
+ oldobjs=
+ counter=1
+ for obj in $save_oldobjs
+ do
+ func_basename "$obj"
+ objbase="$func_basename_result"
+ case " $oldobjs " in
+ " ") oldobjs=$obj ;;
+ *[\ /]"$objbase "*)
+ while :; do
+ # Make sure we don't pick an alternate name that also
+ # overlaps.
+ newobj=lt$counter-$objbase
+ func_arith $counter + 1
+ counter=$func_arith_result
+ case " $oldobjs " in
+ *[\ /]"$newobj "*) ;;
+ *) if test ! -f "$gentop/$newobj"; then break; fi ;;
+ esac
+ done
+ func_show_eval "ln $obj $gentop/$newobj || cp $obj $gentop/$newobj"
+ func_append oldobjs " $gentop/$newobj"
+ ;;
+ *) func_append oldobjs " $obj" ;;
+ esac
+ done
+ fi
+ func_to_tool_file "$oldlib" func_convert_file_msys_to_w32
+ tool_oldlib=$func_to_tool_file_result
+ eval cmds=\"$old_archive_cmds\"
+
+ func_len " $cmds"
+ len=$func_len_result
+ if test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then
+ cmds=$old_archive_cmds
+ elif test -n "$archiver_list_spec"; then
+ func_verbose "using command file archive linking..."
+ for obj in $oldobjs
+ do
+ func_to_tool_file "$obj"
+ $ECHO "$func_to_tool_file_result"
+ done > $output_objdir/$libname.libcmd
+ func_to_tool_file "$output_objdir/$libname.libcmd"
+ oldobjs=" $archiver_list_spec$func_to_tool_file_result"
+ cmds=$old_archive_cmds
+ else
+ # the command line is too long to link in one step, link in parts
+ func_verbose "using piecewise archive linking..."
+ save_RANLIB=$RANLIB
+ RANLIB=:
+ objlist=
+ concat_cmds=
+ save_oldobjs=$oldobjs
+ oldobjs=
+ # Is there a better way of finding the last object in the list?
+ for obj in $save_oldobjs
+ do
+ last_oldobj=$obj
+ done
+ eval test_cmds=\"$old_archive_cmds\"
+ func_len " $test_cmds"
+ len0=$func_len_result
+ len=$len0
+ for obj in $save_oldobjs
+ do
+ func_len " $obj"
+ func_arith $len + $func_len_result
+ len=$func_arith_result
+ func_append objlist " $obj"
+ if test "$len" -lt "$max_cmd_len"; then
+ :
+ else
+ # the above command should be used before it gets too long
+ oldobjs=$objlist
+ if test "$obj" = "$last_oldobj" ; then
+ RANLIB=$save_RANLIB
+ fi
+ test -z "$concat_cmds" || concat_cmds=$concat_cmds~
+ eval concat_cmds=\"\${concat_cmds}$old_archive_cmds\"
+ objlist=
+ len=$len0
+ fi
+ done
+ RANLIB=$save_RANLIB
+ oldobjs=$objlist
+ if test "X$oldobjs" = "X" ; then
+ eval cmds=\"\$concat_cmds\"
+ else
+ eval cmds=\"\$concat_cmds~\$old_archive_cmds\"
+ fi
+ fi
+ fi
+ func_execute_cmds "$cmds" 'exit $?'
+ done
+
+ test -n "$generated" && \
+ func_show_eval "${RM}r$generated"
+
+ # Now create the libtool archive.
+ case $output in
+ *.la)
+ old_library=
+ test "$build_old_libs" = yes && old_library="$libname.$libext"
+ func_verbose "creating $output"
+
+ # Preserve any variables that may affect compiler behavior
+ for var in $variables_saved_for_relink; do
+ if eval test -z \"\${$var+set}\"; then
+ relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command"
+ elif eval var_value=\$$var; test -z "$var_value"; then
+ relink_command="$var=; export $var; $relink_command"
+ else
+ func_quote_for_eval "$var_value"
+ relink_command="$var=$func_quote_for_eval_result; export $var; $relink_command"
+ fi
+ done
+ # Quote the link command for shipping.
+ relink_command="(cd `pwd`; $SHELL $progpath $preserve_args --mode=relink $libtool_args @inst_prefix_dir@)"
+ relink_command=`$ECHO "$relink_command" | $SED "$sed_quote_subst"`
+ if test "$hardcode_automatic" = yes ; then
+ relink_command=
+ fi
+
+ # Only create the output if not a dry run.
+ $opt_dry_run || {
+ for installed in no yes; do
+ if test "$installed" = yes; then
+ if test -z "$install_libdir"; then
+ break
+ fi
+ output="$output_objdir/$outputname"i
+ # Replace all uninstalled libtool libraries with the installed ones
+ newdependency_libs=
+ for deplib in $dependency_libs; do
+ case $deplib in
+ *.la)
+ func_basename "$deplib"
+ name="$func_basename_result"
+ func_resolve_sysroot "$deplib"
+ eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $func_resolve_sysroot_result`
+ test -z "$libdir" && \
+ func_fatal_error "\`$deplib' is not a valid libtool archive"
+ func_append newdependency_libs " ${lt_sysroot:+=}$libdir/$name"
+ ;;
+ -L*)
+ func_stripname -L '' "$deplib"
+ func_replace_sysroot "$func_stripname_result"
+ func_append newdependency_libs " -L$func_replace_sysroot_result"
+ ;;
+ -R*)
+ func_stripname -R '' "$deplib"
+ func_replace_sysroot "$func_stripname_result"
+ func_append newdependency_libs " -R$func_replace_sysroot_result"
+ ;;
+ *) func_append newdependency_libs " $deplib" ;;
+ esac
+ done
+ dependency_libs="$newdependency_libs"
+ newdlfiles=
+
+ for lib in $dlfiles; do
+ case $lib in
+ *.la)
+ func_basename "$lib"
+ name="$func_basename_result"
+ eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $lib`
+ test -z "$libdir" && \
+ func_fatal_error "\`$lib' is not a valid libtool archive"
+ func_append newdlfiles " ${lt_sysroot:+=}$libdir/$name"
+ ;;
+ *) func_append newdlfiles " $lib" ;;
+ esac
+ done
+ dlfiles="$newdlfiles"
+ newdlprefiles=
+ for lib in $dlprefiles; do
+ case $lib in
+ *.la)
+ # Only pass preopened files to the pseudo-archive (for
+ # eventual linking with the app. that links it) if we
+ # didn't already link the preopened objects directly into
+ # the library:
+ func_basename "$lib"
+ name="$func_basename_result"
+ eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $lib`
+ test -z "$libdir" && \
+ func_fatal_error "\`$lib' is not a valid libtool archive"
+ func_append newdlprefiles " ${lt_sysroot:+=}$libdir/$name"
+ ;;
+ esac
+ done
+ dlprefiles="$newdlprefiles"
+ else
+ newdlfiles=
+ for lib in $dlfiles; do
+ case $lib in
+ [\\/]* | [A-Za-z]:[\\/]*) abs="$lib" ;;
+ *) abs=`pwd`"/$lib" ;;
+ esac
+ func_append newdlfiles " $abs"
+ done
+ dlfiles="$newdlfiles"
+ newdlprefiles=
+ for lib in $dlprefiles; do
+ case $lib in
+ [\\/]* | [A-Za-z]:[\\/]*) abs="$lib" ;;
+ *) abs=`pwd`"/$lib" ;;
+ esac
+ func_append newdlprefiles " $abs"
+ done
+ dlprefiles="$newdlprefiles"
+ fi
+ $RM $output
+ # place dlname in correct position for cygwin
+ # In fact, it would be nice if we could use this code for all target
+ # systems that can't hard-code library paths into their executables
+ # and that have no shared library path variable independent of PATH,
+ # but it turns out we can't easily determine that from inspecting
+ # libtool variables, so we have to hard-code the OSs to which it
+ # applies here; at the moment, that means platforms that use the PE
+ # object format with DLL files. See the long comment at the top of
+ # tests/bindir.at for full details.
+ tdlname=$dlname
+ case $host,$output,$installed,$module,$dlname in
+ *cygwin*,*lai,yes,no,*.dll | *mingw*,*lai,yes,no,*.dll | *cegcc*,*lai,yes,no,*.dll)
+ # If a -bindir argument was supplied, place the dll there.
+ if test "x$bindir" != x ;
+ then
+ func_relative_path "$install_libdir" "$bindir"
+ tdlname=$func_relative_path_result$dlname
+ else
+ # Otherwise fall back on heuristic.
+ tdlname=../bin/$dlname
+ fi
+ ;;
+ esac
+ $ECHO > $output "\
+# $outputname - a libtool library file
+# Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION
+#
+# Please DO NOT delete this file!
+# It is necessary for linking the library.
+
+# The name that we can dlopen(3).
+dlname='$tdlname'
+
+# Names of this library.
+library_names='$library_names'
+
+# The name of the static archive.
+old_library='$old_library'
+
+# Linker flags that can not go in dependency_libs.
+inherited_linker_flags='$new_inherited_linker_flags'
+
+# Libraries that this one depends upon.
+dependency_libs='$dependency_libs'
+
+# Names of additional weak libraries provided by this library
+weak_library_names='$weak_libs'
+
+# Version information for $libname.
+current=$current
+age=$age
+revision=$revision
+
+# Is this an already installed library?
+installed=$installed
+
+# Should we warn about portability when linking against -modules?
+shouldnotlink=$module
+
+# Files to dlopen/dlpreopen
+dlopen='$dlfiles'
+dlpreopen='$dlprefiles'
+
+# Directory that this library needs to be installed in:
+libdir='$install_libdir'"
+ if test "$installed" = no && test "$need_relink" = yes; then
+ $ECHO >> $output "\
+relink_command=\"$relink_command\""
+ fi
+ done
+ }
+
+ # Do a symbolic link so that the libtool archive can be found in
+ # LD_LIBRARY_PATH before the program is installed.
+ func_show_eval '( cd "$output_objdir" && $RM "$outputname" && $LN_S "../$outputname" "$outputname" )' 'exit $?'
+ ;;
+ esac
+ exit $EXIT_SUCCESS
+}
+
+{ test "$opt_mode" = link || test "$opt_mode" = relink; } &&
+ func_mode_link ${1+"$@"}
+
+
+# func_mode_uninstall arg...
+func_mode_uninstall ()
+{
+ $opt_debug
+ RM="$nonopt"
+ files=
+ rmforce=
+ exit_status=0
+
+ # This variable tells wrapper scripts just to set variables rather
+ # than running their programs.
+ libtool_install_magic="$magic"
+
+ for arg
+ do
+ case $arg in
+ -f) func_append RM " $arg"; rmforce=yes ;;
+ -*) func_append RM " $arg" ;;
+ *) func_append files " $arg" ;;
+ esac
+ done
+
+ test -z "$RM" && \
+ func_fatal_help "you must specify an RM program"
+
+ rmdirs=
+
+ for file in $files; do
+ func_dirname "$file" "" "."
+ dir="$func_dirname_result"
+ if test "X$dir" = X.; then
+ odir="$objdir"
+ else
+ odir="$dir/$objdir"
+ fi
+ func_basename "$file"
+ name="$func_basename_result"
+ test "$opt_mode" = uninstall && odir="$dir"
+
+ # Remember odir for removal later, being careful to avoid duplicates
+ if test "$opt_mode" = clean; then
+ case " $rmdirs " in
+ *" $odir "*) ;;
+ *) func_append rmdirs " $odir" ;;
+ esac
+ fi
+
+ # Don't error if the file doesn't exist and rm -f was used.
+ if { test -L "$file"; } >/dev/null 2>&1 ||
+ { test -h "$file"; } >/dev/null 2>&1 ||
+ test -f "$file"; then
+ :
+ elif test -d "$file"; then
+ exit_status=1
+ continue
+ elif test "$rmforce" = yes; then
+ continue
+ fi
+
+ rmfiles="$file"
+
+ case $name in
+ *.la)
+ # Possibly a libtool archive, so verify it.
+ if func_lalib_p "$file"; then
+ func_source $dir/$name
+
+ # Delete the libtool libraries and symlinks.
+ for n in $library_names; do
+ func_append rmfiles " $odir/$n"
+ done
+ test -n "$old_library" && func_append rmfiles " $odir/$old_library"
+
+ case "$opt_mode" in
+ clean)
+ case " $library_names " in
+ *" $dlname "*) ;;
+ *) test -n "$dlname" && func_append rmfiles " $odir/$dlname" ;;
+ esac
+ test -n "$libdir" && func_append rmfiles " $odir/$name $odir/${name}i"
+ ;;
+ uninstall)
+ if test -n "$library_names"; then
+ # Do each command in the postuninstall commands.
+ func_execute_cmds "$postuninstall_cmds" 'test "$rmforce" = yes || exit_status=1'
+ fi
+
+ if test -n "$old_library"; then
+ # Do each command in the old_postuninstall commands.
+ func_execute_cmds "$old_postuninstall_cmds" 'test "$rmforce" = yes || exit_status=1'
+ fi
+ # FIXME: should reinstall the best remaining shared library.
+ ;;
+ esac
+ fi
+ ;;
+
+ *.lo)
+ # Possibly a libtool object, so verify it.
+ if func_lalib_p "$file"; then
+
+ # Read the .lo file
+ func_source $dir/$name
+
+ # Add PIC object to the list of files to remove.
+ if test -n "$pic_object" &&
+ test "$pic_object" != none; then
+ func_append rmfiles " $dir/$pic_object"
+ fi
+
+ # Add non-PIC object to the list of files to remove.
+ if test -n "$non_pic_object" &&
+ test "$non_pic_object" != none; then
+ func_append rmfiles " $dir/$non_pic_object"
+ fi
+ fi
+ ;;
+
+ *)
+ if test "$opt_mode" = clean ; then
+ noexename=$name
+ case $file in
+ *.exe)
+ func_stripname '' '.exe' "$file"
+ file=$func_stripname_result
+ func_stripname '' '.exe' "$name"
+ noexename=$func_stripname_result
+ # $file with .exe has already been added to rmfiles,
+ # add $file without .exe
+ func_append rmfiles " $file"
+ ;;
+ esac
+ # Do a test to see if this is a libtool program.
+ if func_ltwrapper_p "$file"; then
+ if func_ltwrapper_executable_p "$file"; then
+ func_ltwrapper_scriptname "$file"
+ relink_command=
+ func_source $func_ltwrapper_scriptname_result
+ func_append rmfiles " $func_ltwrapper_scriptname_result"
+ else
+ relink_command=
+ func_source $dir/$noexename
+ fi
+
+ # note $name still contains .exe if it was in $file originally
+ # as does the version of $file that was added into $rmfiles
+ func_append rmfiles " $odir/$name $odir/${name}S.${objext}"
+ if test "$fast_install" = yes && test -n "$relink_command"; then
+ func_append rmfiles " $odir/lt-$name"
+ fi
+ if test "X$noexename" != "X$name" ; then
+ func_append rmfiles " $odir/lt-${noexename}.c"
+ fi
+ fi
+ fi
+ ;;
+ esac
+ func_show_eval "$RM $rmfiles" 'exit_status=1'
+ done
+
+ # Try to remove the ${objdir}s in the directories where we deleted files
+ for dir in $rmdirs; do
+ if test -d "$dir"; then
+ func_show_eval "rmdir $dir >/dev/null 2>&1"
+ fi
+ done
+
+ exit $exit_status
+}
+
+{ test "$opt_mode" = uninstall || test "$opt_mode" = clean; } &&
+ func_mode_uninstall ${1+"$@"}
+
+test -z "$opt_mode" && {
+ help="$generic_help"
+ func_fatal_help "you must specify a MODE"
+}
+
+test -z "$exec_cmd" && \
+ func_fatal_help "invalid operation mode \`$opt_mode'"
+
+if test -n "$exec_cmd"; then
+ eval exec "$exec_cmd"
+ exit $EXIT_FAILURE
+fi
+
+exit $exit_status
+
+
+# The TAGs below are defined such that we never get into a situation
+# in which we disable both kinds of libraries. Given conflicting
+# choices, we go for a static library, that is the most portable,
+# since we can't tell whether shared libraries were disabled because
+# the user asked for that or because the platform doesn't support
+# them. This is particularly important on AIX, because we don't
+# support having both static and shared libraries enabled at the same
+# time on that platform, so we default to a shared-only configuration.
+# If a disable-shared tag is given, we'll fallback to a static-only
+# configuration. But we'll never go from static-only to shared-only.
+
+# ### BEGIN LIBTOOL TAG CONFIG: disable-shared
+build_libtool_libs=no
+build_old_libs=yes
+# ### END LIBTOOL TAG CONFIG: disable-shared
+
+# ### BEGIN LIBTOOL TAG CONFIG: disable-static
+build_old_libs=`case $build_libtool_libs in yes) echo no;; *) echo yes;; esac`
+# ### END LIBTOOL TAG CONFIG: disable-static
+
+# Local Variables:
+# mode:shell-script
+# sh-indentation:2
+# End:
+# vi:sw=2
+
diff --git a/jni/ruby/ext/fiddle/libffi-3.2.1/m4/asmcfi.m4 b/jni/ruby/ext/fiddle/libffi-3.2.1/m4/asmcfi.m4
new file mode 100644
index 0000000..dbf73a0
--- /dev/null
+++ b/jni/ruby/ext/fiddle/libffi-3.2.1/m4/asmcfi.m4
@@ -0,0 +1,13 @@
+AC_DEFUN([GCC_AS_CFI_PSEUDO_OP],
+[AC_CACHE_CHECK([assembler .cfi pseudo-op support],
+ gcc_cv_as_cfi_pseudo_op, [
+ gcc_cv_as_cfi_pseudo_op=unknown
+ AC_TRY_COMPILE([asm (".cfi_startproc\n\t.cfi_endproc");],,
+ [gcc_cv_as_cfi_pseudo_op=yes],
+ [gcc_cv_as_cfi_pseudo_op=no])
+ ])
+ if test "x$gcc_cv_as_cfi_pseudo_op" = xyes; then
+ AC_DEFINE(HAVE_AS_CFI_PSEUDO_OP, 1,
+ [Define if your assembler supports .cfi_* directives.])
+ fi
+])
diff --git a/jni/ruby/ext/fiddle/libffi-3.2.1/m4/ax_append_flag.m4 b/jni/ruby/ext/fiddle/libffi-3.2.1/m4/ax_append_flag.m4
new file mode 100644
index 0000000..1d38b76
--- /dev/null
+++ b/jni/ruby/ext/fiddle/libffi-3.2.1/m4/ax_append_flag.m4
@@ -0,0 +1,69 @@
+# ===========================================================================
+# http://www.gnu.org/software/autoconf-archive/ax_append_flag.html
+# ===========================================================================
+#
+# SYNOPSIS
+#
+# AX_APPEND_FLAG(FLAG, [FLAGS-VARIABLE])
+#
+# DESCRIPTION
+#
+# FLAG is appended to the FLAGS-VARIABLE shell variable, with a space
+# added in between.
+#
+# If FLAGS-VARIABLE is not specified, the current language's flags (e.g.
+# CFLAGS) is used. FLAGS-VARIABLE is not changed if it already contains
+# FLAG. If FLAGS-VARIABLE is unset in the shell, it is set to exactly
+# FLAG.
+#
+# NOTE: Implementation based on AX_CFLAGS_GCC_OPTION.
+#
+# LICENSE
+#
+# Copyright (c) 2008 Guido U. Draheim <guidod@gmx.de>
+# Copyright (c) 2011 Maarten Bosmans <mkbosmans@gmail.com>
+#
+# This program is free software: you can redistribute it and/or modify it
+# under the terms of the GNU General Public License as published by the
+# Free Software Foundation, either version 3 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, see <http://www.gnu.org/licenses/>.
+#
+# As a special exception, the respective Autoconf Macro's copyright owner
+# gives unlimited permission to copy, distribute and modify the configure
+# scripts that are the output of Autoconf when processing the Macro. You
+# need not follow the terms of the GNU General Public License when using
+# or distributing such scripts, even though portions of the text of the
+# Macro appear in them. The GNU General Public License (GPL) does govern
+# all other use of the material that constitutes the Autoconf Macro.
+#
+# This special exception to the GPL applies to versions of the Autoconf
+# Macro released by the Autoconf Archive. When you make and distribute a
+# modified version of the Autoconf Macro, you may extend this special
+# exception to the GPL to apply to your modified version as well.
+
+#serial 2
+
+AC_DEFUN([AX_APPEND_FLAG],
+[AC_PREREQ(2.59)dnl for _AC_LANG_PREFIX
+AS_VAR_PUSHDEF([FLAGS], [m4_default($2,_AC_LANG_PREFIX[FLAGS])])dnl
+AS_VAR_SET_IF(FLAGS,
+ [case " AS_VAR_GET(FLAGS) " in
+ *" $1 "*)
+ AC_RUN_LOG([: FLAGS already contains $1])
+ ;;
+ *)
+ AC_RUN_LOG([: FLAGS="$FLAGS $1"])
+ AS_VAR_SET(FLAGS, ["AS_VAR_GET(FLAGS) $1"])
+ ;;
+ esac],
+ [AS_VAR_SET(FLAGS,["$1"])])
+AS_VAR_POPDEF([FLAGS])dnl
+])dnl AX_APPEND_FLAG
diff --git a/jni/ruby/ext/fiddle/libffi-3.2.1/m4/ax_cc_maxopt.m4 b/jni/ruby/ext/fiddle/libffi-3.2.1/m4/ax_cc_maxopt.m4
new file mode 100644
index 0000000..62e3b53
--- /dev/null
+++ b/jni/ruby/ext/fiddle/libffi-3.2.1/m4/ax_cc_maxopt.m4
@@ -0,0 +1,181 @@
+# ===========================================================================
+# http://www.gnu.org/software/autoconf-archive/ax_cc_maxopt.html
+# ===========================================================================
+#
+# SYNOPSIS
+#
+# AX_CC_MAXOPT
+#
+# DESCRIPTION
+#
+# Try to turn on "good" C optimization flags for various compilers and
+# architectures, for some definition of "good". (In our case, good for
+# FFTW and hopefully for other scientific codes. Modify as needed.)
+#
+# The user can override the flags by setting the CFLAGS environment
+# variable. The user can also specify --enable-portable-binary in order to
+# disable any optimization flags that might result in a binary that only
+# runs on the host architecture.
+#
+# Note also that the flags assume that ANSI C aliasing rules are followed
+# by the code (e.g. for gcc's -fstrict-aliasing), and that floating-point
+# computations can be re-ordered as needed.
+#
+# Requires macros: AX_CHECK_COMPILE_FLAG, AX_COMPILER_VENDOR,
+# AX_GCC_ARCHFLAG, AX_GCC_X86_CPUID.
+#
+# LICENSE
+#
+# Copyright (c) 2008 Steven G. Johnson <stevenj@alum.mit.edu>
+# Copyright (c) 2008 Matteo Frigo
+#
+# 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 3 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, see <http://www.gnu.org/licenses/>.
+#
+# As a special exception, the respective Autoconf Macro's copyright owner
+# gives unlimited permission to copy, distribute and modify the configure
+# scripts that are the output of Autoconf when processing the Macro. You
+# need not follow the terms of the GNU General Public License when using
+# or distributing such scripts, even though portions of the text of the
+# Macro appear in them. The GNU General Public License (GPL) does govern
+# all other use of the material that constitutes the Autoconf Macro.
+#
+# This special exception to the GPL applies to versions of the Autoconf
+# Macro released by the Autoconf Archive. When you make and distribute a
+# modified version of the Autoconf Macro, you may extend this special
+# exception to the GPL to apply to your modified version as well.
+
+#serial 13
+
+AC_DEFUN([AX_CC_MAXOPT],
+[
+AC_REQUIRE([AC_PROG_CC])
+AC_REQUIRE([AX_COMPILER_VENDOR])
+AC_REQUIRE([AC_CANONICAL_HOST])
+
+AC_ARG_ENABLE(portable-binary, [AS_HELP_STRING([--enable-portable-binary], [disable compiler optimizations that would produce unportable binaries])],
+ acx_maxopt_portable=$enableval, acx_maxopt_portable=no)
+
+# Try to determine "good" native compiler flags if none specified via CFLAGS
+if test "$ac_test_CFLAGS" != "set"; then
+ CFLAGS=""
+ case $ax_cv_c_compiler_vendor in
+ dec) CFLAGS="-newc -w0 -O5 -ansi_alias -ansi_args -fp_reorder -tune host"
+ if test "x$acx_maxopt_portable" = xno; then
+ CFLAGS="$CFLAGS -arch host"
+ fi;;
+
+ sun) CFLAGS="-native -fast -xO5 -dalign"
+ if test "x$acx_maxopt_portable" = xyes; then
+ CFLAGS="$CFLAGS -xarch=generic"
+ fi;;
+
+ hp) CFLAGS="+Oall +Optrs_ansi +DSnative"
+ if test "x$acx_maxopt_portable" = xyes; then
+ CFLAGS="$CFLAGS +DAportable"
+ fi;;
+
+ ibm) if test "x$acx_maxopt_portable" = xno; then
+ xlc_opt="-qarch=auto -qtune=auto"
+ else
+ xlc_opt="-qtune=auto"
+ fi
+ AX_CHECK_COMPILE_FLAG($xlc_opt,
+ CFLAGS="-O3 -qansialias -w $xlc_opt",
+ [CFLAGS="-O3 -qansialias -w"
+ echo "******************************************************"
+ echo "* You seem to have the IBM C compiler. It is *"
+ echo "* recommended for best performance that you use: *"
+ echo "* *"
+ echo "* CFLAGS=-O3 -qarch=xxx -qtune=xxx -qansialias -w *"
+ echo "* ^^^ ^^^ *"
+ echo "* where xxx is pwr2, pwr3, 604, or whatever kind of *"
+ echo "* CPU you have. (Set the CFLAGS environment var. *"
+ echo "* and re-run configure.) For more info, man cc. *"
+ echo "******************************************************"])
+ ;;
+
+ intel) CFLAGS="-O3 -ansi_alias"
+ if test "x$acx_maxopt_portable" = xno; then
+ icc_archflag=unknown
+ icc_flags=""
+ case $host_cpu in
+ i686*|x86_64*)
+ # icc accepts gcc assembly syntax, so these should work:
+ AX_GCC_X86_CPUID(0)
+ AX_GCC_X86_CPUID(1)
+ case $ax_cv_gcc_x86_cpuid_0 in # see AX_GCC_ARCHFLAG
+ *:756e6547:*:*) # Intel
+ case $ax_cv_gcc_x86_cpuid_1 in
+ *6a?:*[[234]]:*:*|*6[[789b]]?:*:*:*) icc_flags="-xK";;
+ *f3[[347]]:*:*:*|*f4[1347]:*:*:*) icc_flags="-xP -xN -xW -xK";;
+ *f??:*:*:*) icc_flags="-xN -xW -xK";;
+ esac ;;
+ esac ;;
+ esac
+ if test "x$icc_flags" != x; then
+ for flag in $icc_flags; do
+ AX_CHECK_COMPILE_FLAG($flag, [icc_archflag=$flag; break])
+ done
+ fi
+ AC_MSG_CHECKING([for icc architecture flag])
+ AC_MSG_RESULT($icc_archflag)
+ if test "x$icc_archflag" != xunknown; then
+ CFLAGS="$CFLAGS $icc_archflag"
+ fi
+ fi
+ ;;
+
+ gnu)
+ # default optimization flags for gcc on all systems
+ CFLAGS="-O3 -fomit-frame-pointer"
+
+ # -malign-double for x86 systems
+ # LIBFFI -- DON'T DO THIS - CHANGES ABI
+ # AX_CHECK_COMPILE_FLAG(-malign-double, CFLAGS="$CFLAGS -malign-double")
+
+ # -fstrict-aliasing for gcc-2.95+
+ AX_CHECK_COMPILE_FLAG(-fstrict-aliasing,
+ CFLAGS="$CFLAGS -fstrict-aliasing")
+
+ # note that we enable "unsafe" fp optimization with other compilers, too
+ AX_CHECK_COMPILE_FLAG(-ffast-math, CFLAGS="$CFLAGS -ffast-math")
+
+ AX_GCC_ARCHFLAG($acx_maxopt_portable)
+ ;;
+ esac
+
+ if test -z "$CFLAGS"; then
+ echo ""
+ echo "********************************************************"
+ echo "* WARNING: Don't know the best CFLAGS for this system *"
+ echo "* Use ./configure CFLAGS=... to specify your own flags *"
+ echo "* (otherwise, a default of CFLAGS=-O3 will be used) *"
+ echo "********************************************************"
+ echo ""
+ CFLAGS="-O3"
+ fi
+
+ AX_CHECK_COMPILE_FLAG($CFLAGS, [], [
+ echo ""
+ echo "********************************************************"
+ echo "* WARNING: The guessed CFLAGS don't seem to work with *"
+ echo "* your compiler. *"
+ echo "* Use ./configure CFLAGS=... to specify your own flags *"
+ echo "********************************************************"
+ echo ""
+ CFLAGS=""
+ ])
+
+fi
+])
diff --git a/jni/ruby/ext/fiddle/libffi-3.2.1/m4/ax_cflags_warn_all.m4 b/jni/ruby/ext/fiddle/libffi-3.2.1/m4/ax_cflags_warn_all.m4
new file mode 100644
index 0000000..0fa3e18
--- /dev/null
+++ b/jni/ruby/ext/fiddle/libffi-3.2.1/m4/ax_cflags_warn_all.m4
@@ -0,0 +1,122 @@
+# ===========================================================================
+# http://www.gnu.org/software/autoconf-archive/ax_cflags_warn_all.html
+# ===========================================================================
+#
+# SYNOPSIS
+#
+# AX_CFLAGS_WARN_ALL [(shellvar [,default, [A/NA]])]
+# AX_CXXFLAGS_WARN_ALL [(shellvar [,default, [A/NA]])]
+# AX_FCFLAGS_WARN_ALL [(shellvar [,default, [A/NA]])]
+#
+# DESCRIPTION
+#
+# Try to find a compiler option that enables most reasonable warnings.
+#
+# For the GNU compiler it will be -Wall (and -ansi -pedantic) The result
+# is added to the shellvar being CFLAGS, CXXFLAGS, or FCFLAGS by default.
+#
+# Currently this macro knows about the GCC, Solaris, Digital Unix, AIX,
+# HP-UX, IRIX, NEC SX-5 (Super-UX 10), Cray J90 (Unicos 10.0.0.8), and
+# Intel compilers. For a given compiler, the Fortran flags are much more
+# experimental than their C equivalents.
+#
+# - $1 shell-variable-to-add-to : CFLAGS, CXXFLAGS, or FCFLAGS
+# - $2 add-value-if-not-found : nothing
+# - $3 action-if-found : add value to shellvariable
+# - $4 action-if-not-found : nothing
+#
+# NOTE: These macros depend on AX_APPEND_FLAG.
+#
+# LICENSE
+#
+# Copyright (c) 2008 Guido U. Draheim <guidod@gmx.de>
+# Copyright (c) 2010 Rhys Ulerich <rhys.ulerich@gmail.com>
+#
+# This program is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License as published by the
+# Free Software Foundation; either version 3 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, see <http://www.gnu.org/licenses/>.
+#
+# As a special exception, the respective Autoconf Macro's copyright owner
+# gives unlimited permission to copy, distribute and modify the configure
+# scripts that are the output of Autoconf when processing the Macro. You
+# need not follow the terms of the GNU General Public License when using
+# or distributing such scripts, even though portions of the text of the
+# Macro appear in them. The GNU General Public License (GPL) does govern
+# all other use of the material that constitutes the Autoconf Macro.
+#
+# This special exception to the GPL applies to versions of the Autoconf
+# Macro released by the Autoconf Archive. When you make and distribute a
+# modified version of the Autoconf Macro, you may extend this special
+# exception to the GPL to apply to your modified version as well.
+
+#serial 14
+
+AC_DEFUN([AX_FLAGS_WARN_ALL],[dnl
+AS_VAR_PUSHDEF([FLAGS],[_AC_LANG_PREFIX[]FLAGS])dnl
+AS_VAR_PUSHDEF([VAR],[ac_cv_[]_AC_LANG_ABBREV[]flags_warn_all])dnl
+AC_CACHE_CHECK([m4_ifval($1,$1,FLAGS) for maximum warnings],
+VAR,[VAR="no, unknown"
+ac_save_[]FLAGS="$[]FLAGS"
+for ac_arg dnl
+in "-warn all % -warn all" dnl Intel
+ "-pedantic % -Wall" dnl GCC
+ "-xstrconst % -v" dnl Solaris C
+ "-std1 % -verbose -w0 -warnprotos" dnl Digital Unix
+ "-qlanglvl=ansi % -qsrcmsg -qinfo=all:noppt:noppc:noobs:nocnd" dnl AIX
+ "-ansi -ansiE % -fullwarn" dnl IRIX
+ "+ESlit % +w1" dnl HP-UX C
+ "-Xc % -pvctl[,]fullmsg" dnl NEC SX-5 (Super-UX 10)
+ "-h conform % -h msglevel 2" dnl Cray C (Unicos)
+ #
+do FLAGS="$ac_save_[]FLAGS "`echo $ac_arg | sed -e 's,%%.*,,' -e 's,%,,'`
+ AC_COMPILE_IFELSE([AC_LANG_PROGRAM],
+ [VAR=`echo $ac_arg | sed -e 's,.*% *,,'` ; break])
+done
+FLAGS="$ac_save_[]FLAGS"
+])
+AS_VAR_POPDEF([FLAGS])dnl
+AC_REQUIRE([AX_APPEND_FLAG])
+case ".$VAR" in
+ .ok|.ok,*) m4_ifvaln($3,$3) ;;
+ .|.no|.no,*) m4_default($4,[m4_ifval($2,[AX_APPEND_FLAG([$2], [$1])])]) ;;
+ *) m4_default($3,[AX_APPEND_FLAG([$VAR], [$1])]) ;;
+esac
+AS_VAR_POPDEF([VAR])dnl
+])dnl AX_FLAGS_WARN_ALL
+dnl implementation tactics:
+dnl the for-argument contains a list of options. The first part of
+dnl these does only exist to detect the compiler - usually it is
+dnl a global option to enable -ansi or -extrawarnings. All other
+dnl compilers will fail about it. That was needed since a lot of
+dnl compilers will give false positives for some option-syntax
+dnl like -Woption or -Xoption as they think of it is a pass-through
+dnl to later compile stages or something. The "%" is used as a
+dnl delimiter. A non-option comment can be given after "%%" marks
+dnl which will be shown but not added to the respective C/CXXFLAGS.
+
+AC_DEFUN([AX_CFLAGS_WARN_ALL],[dnl
+AC_LANG_PUSH([C])
+AX_FLAGS_WARN_ALL([$1], [$2], [$3], [$4])
+AC_LANG_POP([C])
+])
+
+AC_DEFUN([AX_CXXFLAGS_WARN_ALL],[dnl
+AC_LANG_PUSH([C++])
+AX_FLAGS_WARN_ALL([$1], [$2], [$3], [$4])
+AC_LANG_POP([C++])
+])
+
+AC_DEFUN([AX_FCFLAGS_WARN_ALL],[dnl
+AC_LANG_PUSH([Fortran])
+AX_FLAGS_WARN_ALL([$1], [$2], [$3], [$4])
+AC_LANG_POP([Fortran])
+])
diff --git a/jni/ruby/ext/fiddle/libffi-3.2.1/m4/ax_check_compile_flag.m4 b/jni/ruby/ext/fiddle/libffi-3.2.1/m4/ax_check_compile_flag.m4
new file mode 100644
index 0000000..c3a8d69
--- /dev/null
+++ b/jni/ruby/ext/fiddle/libffi-3.2.1/m4/ax_check_compile_flag.m4
@@ -0,0 +1,72 @@
+# ===========================================================================
+# http://www.gnu.org/software/autoconf-archive/ax_check_compile_flag.html
+# ===========================================================================
+#
+# SYNOPSIS
+#
+# AX_CHECK_COMPILE_FLAG(FLAG, [ACTION-SUCCESS], [ACTION-FAILURE], [EXTRA-FLAGS])
+#
+# DESCRIPTION
+#
+# Check whether the given FLAG works with the current language's compiler
+# or gives an error. (Warnings, however, are ignored)
+#
+# ACTION-SUCCESS/ACTION-FAILURE are shell commands to execute on
+# success/failure.
+#
+# If EXTRA-FLAGS is defined, it is added to the current language's default
+# flags (e.g. CFLAGS) when the check is done. The check is thus made with
+# the flags: "CFLAGS EXTRA-FLAGS FLAG". This can for example be used to
+# force the compiler to issue an error when a bad flag is given.
+#
+# NOTE: Implementation based on AX_CFLAGS_GCC_OPTION. Please keep this
+# macro in sync with AX_CHECK_{PREPROC,LINK}_FLAG.
+#
+# LICENSE
+#
+# Copyright (c) 2008 Guido U. Draheim <guidod@gmx.de>
+# Copyright (c) 2011 Maarten Bosmans <mkbosmans@gmail.com>
+#
+# This program is free software: you can redistribute it and/or modify it
+# under the terms of the GNU General Public License as published by the
+# Free Software Foundation, either version 3 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, see <http://www.gnu.org/licenses/>.
+#
+# As a special exception, the respective Autoconf Macro's copyright owner
+# gives unlimited permission to copy, distribute and modify the configure
+# scripts that are the output of Autoconf when processing the Macro. You
+# need not follow the terms of the GNU General Public License when using
+# or distributing such scripts, even though portions of the text of the
+# Macro appear in them. The GNU General Public License (GPL) does govern
+# all other use of the material that constitutes the Autoconf Macro.
+#
+# This special exception to the GPL applies to versions of the Autoconf
+# Macro released by the Autoconf Archive. When you make and distribute a
+# modified version of the Autoconf Macro, you may extend this special
+# exception to the GPL to apply to your modified version as well.
+
+#serial 2
+
+AC_DEFUN([AX_CHECK_COMPILE_FLAG],
+[AC_PREREQ(2.59)dnl for _AC_LANG_PREFIX
+AS_VAR_PUSHDEF([CACHEVAR],[ax_cv_check_[]_AC_LANG_ABBREV[]flags_$4_$1])dnl
+AC_CACHE_CHECK([whether _AC_LANG compiler accepts $1], CACHEVAR, [
+ ax_check_save_flags=$[]_AC_LANG_PREFIX[]FLAGS
+ _AC_LANG_PREFIX[]FLAGS="$[]_AC_LANG_PREFIX[]FLAGS $4 $1"
+ AC_COMPILE_IFELSE([AC_LANG_PROGRAM()],
+ [AS_VAR_SET(CACHEVAR,[yes])],
+ [AS_VAR_SET(CACHEVAR,[no])])
+ _AC_LANG_PREFIX[]FLAGS=$ax_check_save_flags])
+AS_IF([test x"AS_VAR_GET(CACHEVAR)" = xyes],
+ [m4_default([$2], :)],
+ [m4_default([$3], :)])
+AS_VAR_POPDEF([CACHEVAR])dnl
+])dnl AX_CHECK_COMPILE_FLAGS
diff --git a/jni/ruby/ext/fiddle/libffi-3.2.1/m4/ax_compiler_vendor.m4 b/jni/ruby/ext/fiddle/libffi-3.2.1/m4/ax_compiler_vendor.m4
new file mode 100644
index 0000000..73e32ea
--- /dev/null
+++ b/jni/ruby/ext/fiddle/libffi-3.2.1/m4/ax_compiler_vendor.m4
@@ -0,0 +1,84 @@
+# ===========================================================================
+# http://www.gnu.org/software/autoconf-archive/ax_compiler_vendor.html
+# ===========================================================================
+#
+# SYNOPSIS
+#
+# AX_COMPILER_VENDOR
+#
+# DESCRIPTION
+#
+# Determine the vendor of the C/C++ compiler, e.g., gnu, intel, ibm, sun,
+# hp, borland, comeau, dec, cray, kai, lcc, metrowerks, sgi, microsoft,
+# watcom, etc. The vendor is returned in the cache variable
+# $ax_cv_c_compiler_vendor for C and $ax_cv_cxx_compiler_vendor for C++.
+#
+# LICENSE
+#
+# Copyright (c) 2008 Steven G. Johnson <stevenj@alum.mit.edu>
+# Copyright (c) 2008 Matteo Frigo
+#
+# 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 3 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, see <http://www.gnu.org/licenses/>.
+#
+# As a special exception, the respective Autoconf Macro's copyright owner
+# gives unlimited permission to copy, distribute and modify the configure
+# scripts that are the output of Autoconf when processing the Macro. You
+# need not follow the terms of the GNU General Public License when using
+# or distributing such scripts, even though portions of the text of the
+# Macro appear in them. The GNU General Public License (GPL) does govern
+# all other use of the material that constitutes the Autoconf Macro.
+#
+# This special exception to the GPL applies to versions of the Autoconf
+# Macro released by the Autoconf Archive. When you make and distribute a
+# modified version of the Autoconf Macro, you may extend this special
+# exception to the GPL to apply to your modified version as well.
+
+#serial 11
+
+AC_DEFUN([AX_COMPILER_VENDOR],
+[AC_CACHE_CHECK([for _AC_LANG compiler vendor], ax_cv_[]_AC_LANG_ABBREV[]_compiler_vendor,
+ [# note: don't check for gcc first since some other compilers define __GNUC__
+ vendors="intel: __ICC,__ECC,__INTEL_COMPILER
+ ibm: __xlc__,__xlC__,__IBMC__,__IBMCPP__
+ pathscale: __PATHCC__,__PATHSCALE__
+ clang: __clang__
+ gnu: __GNUC__
+ sun: __SUNPRO_C,__SUNPRO_CC
+ hp: __HP_cc,__HP_aCC
+ dec: __DECC,__DECCXX,__DECC_VER,__DECCXX_VER
+ borland: __BORLANDC__,__TURBOC__
+ comeau: __COMO__
+ cray: _CRAYC
+ kai: __KCC
+ lcc: __LCC__
+ sgi: __sgi,sgi
+ microsoft: _MSC_VER
+ metrowerks: __MWERKS__
+ watcom: __WATCOMC__
+ portland: __PGI
+ unknown: UNKNOWN"
+ for ventest in $vendors; do
+ case $ventest in
+ *:) vendor=$ventest; continue ;;
+ *) vencpp="defined("`echo $ventest | sed 's/,/) || defined(/g'`")" ;;
+ esac
+ AC_COMPILE_IFELSE([AC_LANG_PROGRAM(,[
+ #if !($vencpp)
+ thisisanerror;
+ #endif
+ ])], [break])
+ done
+ ax_cv_[]_AC_LANG_ABBREV[]_compiler_vendor=`echo $vendor | cut -d: -f1`
+ ])
+])
diff --git a/jni/ruby/ext/fiddle/libffi-3.2.1/m4/ax_configure_args.m4 b/jni/ruby/ext/fiddle/libffi-3.2.1/m4/ax_configure_args.m4
new file mode 100644
index 0000000..0726b1b
--- /dev/null
+++ b/jni/ruby/ext/fiddle/libffi-3.2.1/m4/ax_configure_args.m4
@@ -0,0 +1,70 @@
+# ===========================================================================
+# http://www.gnu.org/software/autoconf-archive/ax_configure_args.html
+# ===========================================================================
+#
+# SYNOPSIS
+#
+# AX_CONFIGURE_ARGS
+#
+# DESCRIPTION
+#
+# Helper macro for AX_ENABLE_BUILDDIR.
+#
+# The traditional way of starting a subdir-configure is running the script
+# with ${1+"$@"} but since autoconf 2.60 this is broken. Instead we have
+# to rely on eval'ing $ac_configure_args however some old autoconf
+# versions do not provide that. To ensure maximum portability of autoconf
+# extension macros this helper can be AC_REQUIRE'd so that
+# $ac_configure_args will alsways be present.
+#
+# Sadly, the traditional "exec $SHELL" of the enable_builddir macros is
+# spoiled now and must be replaced by "eval + exit $?".
+#
+# Example:
+#
+# AC_DEFUN([AX_ENABLE_SUBDIR],[dnl
+# AC_REQUIRE([AX_CONFIGURE_ARGS])dnl
+# eval $SHELL $ac_configure_args || exit $?
+# ...])
+#
+# LICENSE
+#
+# Copyright (c) 2008 Guido U. Draheim <guidod@gmx.de>
+#
+# 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 3 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, see <http://www.gnu.org/licenses/>.
+#
+# As a special exception, the respective Autoconf Macro's copyright owner
+# gives unlimited permission to copy, distribute and modify the configure
+# scripts that are the output of Autoconf when processing the Macro. You
+# need not follow the terms of the GNU General Public License when using
+# or distributing such scripts, even though portions of the text of the
+# Macro appear in them. The GNU General Public License (GPL) does govern
+# all other use of the material that constitutes the Autoconf Macro.
+#
+# This special exception to the GPL applies to versions of the Autoconf
+# Macro released by the Autoconf Archive. When you make and distribute a
+# modified version of the Autoconf Macro, you may extend this special
+# exception to the GPL to apply to your modified version as well.
+
+#serial 9
+
+AC_DEFUN([AX_CONFIGURE_ARGS],[
+ # [$]@ is unsable in 2.60+ but earlier autoconf had no ac_configure_args
+ if test "${ac_configure_args+set}" != "set" ; then
+ ac_configure_args=
+ for ac_arg in ${1+"[$]@"}; do
+ ac_configure_args="$ac_configure_args '$ac_arg'"
+ done
+ fi
+])
diff --git a/jni/ruby/ext/fiddle/libffi-3.2.1/m4/ax_enable_builddir.m4 b/jni/ruby/ext/fiddle/libffi-3.2.1/m4/ax_enable_builddir.m4
new file mode 100644
index 0000000..3cb2093
--- /dev/null
+++ b/jni/ruby/ext/fiddle/libffi-3.2.1/m4/ax_enable_builddir.m4
@@ -0,0 +1,301 @@
+# ===========================================================================
+# http://www.gnu.org/software/autoconf-archive/ax_enable_builddir.html
+# ===========================================================================
+#
+# SYNOPSIS
+#
+# AX_ENABLE_BUILDDIR [(dirstring-or-command [,Makefile.mk [,-all]])]
+#
+# DESCRIPTION
+#
+# If the current configure was run within the srcdir then we move all
+# configure-files into a subdir and let the configure steps continue
+# there. We provide an option --disable-builddir to suppress the move into
+# a separate builddir.
+#
+# Defaults:
+#
+# $1 = $host (overridden with $HOST)
+# $2 = Makefile.mk
+# $3 = -all
+#
+# This macro must be called before AM_INIT_AUTOMAKE. It creates a default
+# toplevel srcdir Makefile from the information found in the created
+# toplevel builddir Makefile. It just copies the variables and
+# rule-targets, each extended with a default rule-execution that recurses
+# into the build directory of the current "HOST". You can override the
+# auto-dection through `config.guess` and build-time of course, as in
+#
+# make HOST=i386-mingw-cross
+#
+# which can of course set at configure time as well using
+#
+# configure --host=i386-mingw-cross
+#
+# After the default has been created, additional rules can be appended
+# that will not just recurse into the subdirectories and only ever exist
+# in the srcdir toplevel makefile - these parts are read from the $2 =
+# Makefile.mk file
+#
+# The automatic rules are usually scanning the toplevel Makefile for lines
+# like '#### $host |$builddir' to recognize the place where to recurse
+# into. Usually, the last one is the only one used. However, almost all
+# targets have an additional "*-all" rule which makes the script to
+# recurse into _all_ variants of the current HOST (!!) setting. The "-all"
+# suffix can be overriden for the macro as well.
+#
+# a special rule is only given for things like "dist" that will copy the
+# tarball from the builddir to the sourcedir (or $(PUB)) for reason of
+# convenience.
+#
+# LICENSE
+#
+# Copyright (c) 2009 Guido U. Draheim <guidod@gmx.de>
+# Copyright (c) 2009 Alan Jenkins <alan-jenkins@tuffmail.co.uk>
+#
+# 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 3 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, see <http://www.gnu.org/licenses/>.
+#
+# As a special exception, the respective Autoconf Macro's copyright owner
+# gives unlimited permission to copy, distribute and modify the configure
+# scripts that are the output of Autoconf when processing the Macro. You
+# need not follow the terms of the GNU General Public License when using
+# or distributing such scripts, even though portions of the text of the
+# Macro appear in them. The GNU General Public License (GPL) does govern
+# all other use of the material that constitutes the Autoconf Macro.
+#
+# This special exception to the GPL applies to versions of the Autoconf
+# Macro released by the Autoconf Archive. When you make and distribute a
+# modified version of the Autoconf Macro, you may extend this special
+# exception to the GPL to apply to your modified version as well.
+
+#serial 23
+
+AC_DEFUN([AX_ENABLE_BUILDDIR],[
+AC_REQUIRE([AC_CANONICAL_HOST])[]dnl
+AC_REQUIRE([AX_CONFIGURE_ARGS])[]dnl
+AC_REQUIRE([AM_AUX_DIR_EXPAND])[]dnl
+AC_BEFORE([$0],[AM_INIT_AUTOMAKE])dnl
+AS_VAR_PUSHDEF([SUB],[ax_enable_builddir])dnl
+AS_VAR_PUSHDEF([AUX],[ax_enable_builddir_auxdir])dnl
+AS_VAR_PUSHDEF([SED],[ax_enable_builddir_sed])dnl
+SUB="."
+AC_ARG_ENABLE([builddir], AS_HELP_STRING(
+ [--disable-builddir],[disable automatic build in subdir of sources])
+ ,[SUB="$enableval"], [SUB="auto"])
+if test ".$ac_srcdir_defaulted" != ".no" ; then
+if test ".$srcdir" = ".." ; then
+ if test -f config.status ; then
+ AC_MSG_NOTICE(toplevel srcdir already configured... skipping subdir build)
+ else
+ test ".$SUB" = "." && SUB="."
+ test ".$SUB" = ".no" && SUB="."
+ test ".$TARGET" = "." && TARGET="$target"
+ test ".$SUB" = ".auto" && SUB="m4_ifval([$1], [$1],[$TARGET])"
+ if test ".$SUB" != ".." ; then # we know where to go and
+ AS_MKDIR_P([$SUB])
+ echo __.$SUB.__ > $SUB/conftest.tmp
+ cd $SUB
+ if grep __.$SUB.__ conftest.tmp >/dev/null 2>/dev/null ; then
+ rm conftest.tmp
+ AC_MSG_RESULT([continue configure in default builddir "./$SUB"])
+ else
+ AC_MSG_ERROR([could not change to default builddir "./$SUB"])
+ fi
+ srcdir=`echo "$SUB" |
+ sed -e 's,^\./,,;s,[[^/]]$,&/,;s,[[^/]]*/,../,g;s,[[/]]$,,;'`
+ # going to restart from subdirectory location
+ test -f $srcdir/config.log && mv $srcdir/config.log .
+ test -f $srcdir/confdefs.h && mv $srcdir/confdefs.h .
+ test -f $srcdir/conftest.log && mv $srcdir/conftest.log .
+ test -f $srcdir/$cache_file && mv $srcdir/$cache_file .
+ AC_MSG_RESULT(....exec $SHELL $srcdir/[$]0 "--srcdir=$srcdir" "--enable-builddir=$SUB" ${1+"[$]@"})
+ case "[$]0" in # restart
+ [[\\/]]* | ?:[[\\/]]*) # Asbolute name
+ eval $SHELL "'[$]0'" "'--srcdir=$srcdir'" "'--enable-builddir=$SUB'" $ac_configure_args ;;
+ *) eval $SHELL "'$srcdir/[$]0'" "'--srcdir=$srcdir'" "'--enable-builddir=$SUB'" $ac_configure_args ;;
+ esac ; exit $?
+ fi
+ fi
+fi fi
+test ".$SUB" = ".auto" && SUB="."
+dnl ac_path_prog uses "set dummy" to override $@ which would defeat the "exec"
+AC_PATH_PROG(SED,gsed sed, sed)
+AUX="$am_aux_dir"
+AS_VAR_POPDEF([SED])dnl
+AS_VAR_POPDEF([AUX])dnl
+AS_VAR_POPDEF([SUB])dnl
+AC_CONFIG_COMMANDS([buildir],[dnl .............. config.status ..............
+AS_VAR_PUSHDEF([SUB],[ax_enable_builddir])dnl
+AS_VAR_PUSHDEF([TOP],[top_srcdir])dnl
+AS_VAR_PUSHDEF([SRC],[ac_top_srcdir])dnl
+AS_VAR_PUSHDEF([AUX],[ax_enable_builddir_auxdir])dnl
+AS_VAR_PUSHDEF([SED],[ax_enable_builddir_sed])dnl
+pushdef([END],[Makefile.mk])dnl
+pushdef([_ALL],[ifelse([$3],,[-all],[$3])])dnl
+ SRC="$ax_enable_builddir_srcdir"
+ if test ".$SUB" = ".." ; then
+ if test -f "$TOP/Makefile" ; then
+ AC_MSG_NOTICE([skipping TOP/Makefile - left untouched])
+ else
+ AC_MSG_NOTICE([skipping TOP/Makefile - not created])
+ fi
+ else
+ if test -f "$SRC/Makefile" ; then
+ a=`grep "^VERSION " "$SRC/Makefile"` ; b=`grep "^VERSION " Makefile`
+ test "$a" != "$b" && rm "$SRC/Makefile"
+ fi
+ if test -f "$SRC/Makefile" ; then
+ echo "$SRC/Makefile : $SRC/Makefile.in" > $tmp/conftemp.mk
+ echo " []@ echo 'REMOVED,,,' >\$[]@" >> $tmp/conftemp.mk
+ eval "${MAKE-make} -f $tmp/conftemp.mk 2>/dev/null >/dev/null"
+ if grep '^REMOVED,,,' "$SRC/Makefile" >/dev/null
+ then rm $SRC/Makefile ; fi
+ cp $tmp/conftemp.mk $SRC/makefiles.mk~ ## DEBUGGING
+ fi
+ if test ! -f "$SRC/Makefile" ; then
+ AC_MSG_NOTICE([create TOP/Makefile guessed from local Makefile])
+ x='`' ; cat >$tmp/conftemp.sed <<_EOF
+/^\$/n
+x
+/^\$/bS
+x
+/\\\\\$/{H;d;}
+{H;s/.*//;x;}
+bM
+:S
+x
+/\\\\\$/{h;d;}
+{h;s/.*//;x;}
+:M
+s/\\(\\n\\) /\\1 /g
+/^ /d
+/^[[ ]]*[[\\#]]/d
+/^VPATH *=/d
+s/^srcdir *=.*/srcdir = ./
+s/^top_srcdir *=.*/top_srcdir = ./
+/[[:=]]/!d
+/^\\./d
+dnl Now handle rules (i.e. lines containing ":" but not " = ").
+/ = /b
+/ .= /b
+/:/!b
+s/:.*/:/
+s/ / /g
+s/ \\([[a-z]][[a-z-]]*[[a-zA-Z0-9]]\\)\\([[ :]]\\)/ \\1 \\1[]_ALL\\2/g
+s/^\\([[a-z]][[a-z-]]*[[a-zA-Z0-9]]\\)\\([[ :]]\\)/\\1 \\1[]_ALL\\2/
+s/ / /g
+/^all all[]_ALL[[ :]]/i\\
+all-configured : all[]_ALL
+dnl dist-all exists... and would make for dist-all-all
+s/ [[a-zA-Z0-9-]]*[]_ALL [[a-zA-Z0-9-]]*[]_ALL[]_ALL//g
+/[]_ALL[]_ALL/d
+a\\
+ @ HOST="\$(HOST)\" \\\\\\
+ ; test ".\$\$HOST" = "." && HOST=$x sh $AUX/config.guess $x \\\\\\
+ ; BUILD=$x grep "^#### \$\$HOST " Makefile | sed -e 's/.*|//' $x \\\\\\
+ ; use=$x basename "\$\@" _ALL $x; n=$x echo \$\$BUILD | wc -w $x \\\\\\
+ ; echo "MAKE \$\$HOST : \$\$n * \$\@"; if test "\$\$n" -eq "0" ; then : \\\\\\
+ ; BUILD=$x grep "^####.*|" Makefile |tail -1| sed -e 's/.*|//' $x ; fi \\\\\\
+ ; test ".\$\$BUILD" = "." && BUILD="." \\\\\\
+ ; test "\$\$use" = "\$\@" && BUILD=$x echo "\$\$BUILD" | tail -1 $x \\\\\\
+ ; for i in \$\$BUILD ; do test ".\$\$i" = "." && continue \\\\\\
+ ; (cd "\$\$i" && test ! -f configure && \$(MAKE) \$\$use) || exit; done
+dnl special rule add-on: "dist" copies the tarball to $(PUB). (source tree)
+/dist[]_ALL *:/a\\
+ @ HOST="\$(HOST)\" \\\\\\
+ ; test ".\$\$HOST" = "." && HOST=$x sh $AUX/config.guess $x \\\\\\
+ ; BUILD=$x grep "^#### \$\$HOST " Makefile | sed -e 's/.*|//' $x \\\\\\
+ ; found=$x echo \$\$BUILD | wc -w $x \\\\\\
+ ; echo "MAKE \$\$HOST : \$\$found \$(PACKAGE)-\$(VERSION).tar.*" \\\\\\
+ ; if test "\$\$found" -eq "0" ; then : \\\\\\
+ ; BUILD=$x grep "^#### .*|" Makefile |tail -1| sed -e 's/.*|//' $x \\\\\\
+ ; fi ; for i in \$\$BUILD ; do test ".\$\$i" = "." && continue \\\\\\
+ ; for f in \$\$i/\$(PACKAGE)-\$(VERSION).tar.* \\\\\\
+ ; do test -f "\$\$f" && mv "\$\$f" \$(PUB). ; done ; break ; done
+dnl special rule add-on: "dist-foo" copies all the archives to $(PUB). (source tree)
+/dist-[[a-zA-Z0-9]]*[]_ALL *:/a\\
+ @ HOST="\$(HOST)\" \\\\\\
+ ; test ".\$\$HOST" = "." && HOST=$x sh ./config.guess $x \\\\\\
+ ; BUILD=$x grep "^#### \$\$HOST " Makefile | sed -e 's/.*|//' $x \\\\\\
+ ; found=$x echo \$\$BUILD | wc -w $x \\\\\\
+ ; echo "MAKE \$\$HOST : \$\$found \$(PACKAGE)-\$(VERSION).*" \\\\\\
+ ; if test "\$\$found" -eq "0" ; then : \\\\\\
+ ; BUILD=$x grep "^#### .*|" Makefile |tail -1| sed -e 's/.*|//' $x \\\\\\
+ ; fi ; for i in \$\$BUILD ; do test ".\$\$i" = "." && continue \\\\\\
+ ; for f in \$\$i/\$(PACKAGE)-\$(VERSION).* \\\\\\
+ ; do test -f "\$\$f" && mv "\$\$f" \$(PUB). ; done ; break ; done
+dnl special rule add-on: "distclean" removes all local builddirs completely
+/distclean[]_ALL *:/a\\
+ @ HOST="\$(HOST)\" \\\\\\
+ ; test ".\$\$HOST" = "." && HOST=$x sh $AUX/config.guess $x \\\\\\
+ ; BUILD=$x grep "^#### .*|" Makefile | sed -e 's/.*|//' $x \\\\\\
+ ; use=$x basename "\$\@" _ALL $x; n=$x echo \$\$BUILD | wc -w $x \\\\\\
+ ; echo "MAKE \$\$HOST : \$\$n * \$\@ (all local builds)" \\\\\\
+ ; test ".\$\$BUILD" = "." && BUILD="." \\\\\\
+ ; for i in \$\$BUILD ; do test ".\$\$i" = "." && continue \\\\\\
+ ; echo "# rm -r \$\$i"; done ; echo "# (sleep 3)" ; sleep 3 \\\\\\
+ ; for i in \$\$BUILD ; do test ".\$\$i" = "." && continue \\\\\\
+ ; echo "\$\$i" | grep "^/" > /dev/null && continue \\\\\\
+ ; echo "\$\$i" | grep "^../" > /dev/null && continue \\\\\\
+ ; echo "rm -r \$\$i"; (rm -r "\$\$i") ; done ; rm Makefile
+_EOF
+ cp "$tmp/conftemp.sed" "$SRC/makefile.sed~" ## DEBUGGING
+ $SED -f $tmp/conftemp.sed Makefile >$SRC/Makefile
+ if test -f "$SRC/m4_ifval([$2],[$2],[END])" ; then
+ AC_MSG_NOTICE([extend TOP/Makefile with TOP/m4_ifval([$2],[$2],[END])])
+ cat $SRC/END >>$SRC/Makefile
+ fi ; xxxx="####"
+ echo "$xxxx CONFIGURATIONS FOR TOPLEVEL MAKEFILE: " >>$SRC/Makefile
+ # sanity check
+ if grep '^; echo "MAKE ' $SRC/Makefile >/dev/null ; then
+ AC_MSG_NOTICE([buggy sed found - it deletes tab in "a" text parts])
+ $SED -e '/^@ HOST=/s/^/ /' -e '/^; /s/^/ /' $SRC/Makefile \
+ >$SRC/Makefile~
+ (test -s $SRC/Makefile~ && mv $SRC/Makefile~ $SRC/Makefile) 2>/dev/null
+ fi
+ else
+ xxxx="\\#\\#\\#\\#"
+ # echo "/^$xxxx *$ax_enable_builddir_host /d" >$tmp/conftemp.sed
+ echo "s!^$xxxx [[^|]]* | *$SUB *\$!$xxxx ...... $SUB!" >$tmp/conftemp.sed
+ $SED -f "$tmp/conftemp.sed" "$SRC/Makefile" >$tmp/mkfile.tmp
+ cp "$tmp/conftemp.sed" "$SRC/makefiles.sed~" ## DEBUGGING
+ cp "$tmp/mkfile.tmp" "$SRC/makefiles.out~" ## DEBUGGING
+ if cmp -s "$SRC/Makefile" "$tmp/mkfile.tmp" 2>/dev/null ; then
+ AC_MSG_NOTICE([keeping TOP/Makefile from earlier configure])
+ rm "$tmp/mkfile.tmp"
+ else
+ AC_MSG_NOTICE([reusing TOP/Makefile from earlier configure])
+ mv "$tmp/mkfile.tmp" "$SRC/Makefile"
+ fi
+ fi
+ AC_MSG_NOTICE([build in $SUB (HOST=$ax_enable_builddir_host)])
+ xxxx="####"
+ echo "$xxxx" "$ax_enable_builddir_host" "|$SUB" >>$SRC/Makefile
+ fi
+popdef([END])dnl
+AS_VAR_POPDEF([SED])dnl
+AS_VAR_POPDEF([AUX])dnl
+AS_VAR_POPDEF([SRC])dnl
+AS_VAR_POPDEF([TOP])dnl
+AS_VAR_POPDEF([SUB])dnl
+],[dnl
+ax_enable_builddir_srcdir="$srcdir" # $srcdir
+ax_enable_builddir_host="$HOST" # $HOST / $host
+ax_enable_builddir_version="$VERSION" # $VERSION
+ax_enable_builddir_package="$PACKAGE" # $PACKAGE
+ax_enable_builddir_auxdir="$ax_enable_builddir_auxdir" # $AUX
+ax_enable_builddir_sed="$ax_enable_builddir_sed" # $SED
+ax_enable_builddir="$ax_enable_builddir" # $SUB
+])dnl
+])
diff --git a/jni/ruby/ext/fiddle/libffi-3.2.1/m4/ax_gcc_archflag.m4 b/jni/ruby/ext/fiddle/libffi-3.2.1/m4/ax_gcc_archflag.m4
new file mode 100644
index 0000000..aab2661
--- /dev/null
+++ b/jni/ruby/ext/fiddle/libffi-3.2.1/m4/ax_gcc_archflag.m4
@@ -0,0 +1,225 @@
+# ===========================================================================
+# http://www.gnu.org/software/autoconf-archive/ax_gcc_archflag.html
+# ===========================================================================
+#
+# SYNOPSIS
+#
+# AX_GCC_ARCHFLAG([PORTABLE?], [ACTION-SUCCESS], [ACTION-FAILURE])
+#
+# DESCRIPTION
+#
+# This macro tries to guess the "native" arch corresponding to the target
+# architecture for use with gcc's -march=arch or -mtune=arch flags. If
+# found, the cache variable $ax_cv_gcc_archflag is set to this flag and
+# ACTION-SUCCESS is executed; otherwise $ax_cv_gcc_archflag is set to
+# "unknown" and ACTION-FAILURE is executed. The default ACTION-SUCCESS is
+# to add $ax_cv_gcc_archflag to the end of $CFLAGS.
+#
+# PORTABLE? should be either [yes] (default) or [no]. In the former case,
+# the flag is set to -mtune (or equivalent) so that the architecture is
+# only used for tuning, but the instruction set used is still portable. In
+# the latter case, the flag is set to -march (or equivalent) so that
+# architecture-specific instructions are enabled.
+#
+# The user can specify --with-gcc-arch=<arch> in order to override the
+# macro's choice of architecture, or --without-gcc-arch to disable this.
+#
+# When cross-compiling, or if $CC is not gcc, then ACTION-FAILURE is
+# called unless the user specified --with-gcc-arch manually.
+#
+# Requires macros: AX_CHECK_COMPILE_FLAG, AX_GCC_X86_CPUID
+#
+# (The main emphasis here is on recent CPUs, on the principle that doing
+# high-performance computing on old hardware is uncommon.)
+#
+# LICENSE
+#
+# Copyright (c) 2008 Steven G. Johnson <stevenj@alum.mit.edu>
+# Copyright (c) 2008 Matteo Frigo
+# Copyright (c) 2012 Tsukasa Oi
+#
+# 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 3 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, see <http://www.gnu.org/licenses/>.
+#
+# As a special exception, the respective Autoconf Macro's copyright owner
+# gives unlimited permission to copy, distribute and modify the configure
+# scripts that are the output of Autoconf when processing the Macro. You
+# need not follow the terms of the GNU General Public License when using
+# or distributing such scripts, even though portions of the text of the
+# Macro appear in them. The GNU General Public License (GPL) does govern
+# all other use of the material that constitutes the Autoconf Macro.
+#
+# This special exception to the GPL applies to versions of the Autoconf
+# Macro released by the Autoconf Archive. When you make and distribute a
+# modified version of the Autoconf Macro, you may extend this special
+# exception to the GPL to apply to your modified version as well.
+
+#serial 11
+
+AC_DEFUN([AX_GCC_ARCHFLAG],
+[AC_REQUIRE([AC_PROG_CC])
+AC_REQUIRE([AC_CANONICAL_HOST])
+
+AC_ARG_WITH(gcc-arch, [AS_HELP_STRING([--with-gcc-arch=<arch>], [use architecture <arch> for gcc -march/-mtune, instead of guessing])],
+ ax_gcc_arch=$withval, ax_gcc_arch=yes)
+
+AC_MSG_CHECKING([for gcc architecture flag])
+AC_MSG_RESULT([])
+AC_CACHE_VAL(ax_cv_gcc_archflag,
+[
+ax_cv_gcc_archflag="unknown"
+
+if test "$GCC" = yes; then
+
+if test "x$ax_gcc_arch" = xyes; then
+ax_gcc_arch=""
+if test "$cross_compiling" = no; then
+case $host_cpu in
+ i[[3456]]86*|x86_64*) # use cpuid codes
+ AX_GCC_X86_CPUID(0)
+ AX_GCC_X86_CPUID(1)
+ case $ax_cv_gcc_x86_cpuid_0 in
+ *:756e6547:*:*) # Intel
+ case $ax_cv_gcc_x86_cpuid_1 in
+ *5[[48]]?:*:*:*) ax_gcc_arch="pentium-mmx pentium" ;;
+ *5??:*:*:*) ax_gcc_arch=pentium ;;
+ *0?6[[3456]]?:*:*:*) ax_gcc_arch="pentium2 pentiumpro" ;;
+ *0?6a?:*[[01]]:*:*) ax_gcc_arch="pentium2 pentiumpro" ;;
+ *0?6a?:*[[234]]:*:*) ax_gcc_arch="pentium3 pentiumpro" ;;
+ *0?6[[9de]]?:*:*:*) ax_gcc_arch="pentium-m pentium3 pentiumpro" ;;
+ *0?6[[78b]]?:*:*:*) ax_gcc_arch="pentium3 pentiumpro" ;;
+ *0?6f?:*:*:*|*1?66?:*:*:*) ax_gcc_arch="core2 pentium-m pentium3 pentiumpro" ;;
+ *1?6[[7d]]?:*:*:*) ax_gcc_arch="penryn core2 pentium-m pentium3 pentiumpro" ;;
+ *1?6[[aef]]?:*:*:*|*2?6[[5cef]]?:*:*:*) ax_gcc_arch="corei7 core2 pentium-m pentium3 pentiumpro" ;;
+ *1?6c?:*:*:*|*[[23]]?66?:*:*:*) ax_gcc_arch="atom core2 pentium-m pentium3 pentiumpro" ;;
+ *2?6[[ad]]?:*:*:*) ax_gcc_arch="corei7-avx corei7 core2 pentium-m pentium3 pentiumpro" ;;
+ *0?6??:*:*:*) ax_gcc_arch=pentiumpro ;;
+ *6??:*:*:*) ax_gcc_arch="core2 pentiumpro" ;;
+ ?000?f3[[347]]:*:*:*|?000?f4[1347]:*:*:*|?000?f6?:*:*:*)
+ case $host_cpu in
+ x86_64*) ax_gcc_arch="nocona pentium4 pentiumpro" ;;
+ *) ax_gcc_arch="prescott pentium4 pentiumpro" ;;
+ esac ;;
+ ?000?f??:*:*:*) ax_gcc_arch="pentium4 pentiumpro";;
+ esac ;;
+ *:68747541:*:*) # AMD
+ case $ax_cv_gcc_x86_cpuid_1 in
+ *5[[67]]?:*:*:*) ax_gcc_arch=k6 ;;
+ *5[[8d]]?:*:*:*) ax_gcc_arch="k6-2 k6" ;;
+ *5[[9]]?:*:*:*) ax_gcc_arch="k6-3 k6" ;;
+ *60?:*:*:*) ax_gcc_arch=k7 ;;
+ *6[[12]]?:*:*:*) ax_gcc_arch="athlon k7" ;;
+ *6[[34]]?:*:*:*) ax_gcc_arch="athlon-tbird k7" ;;
+ *67?:*:*:*) ax_gcc_arch="athlon-4 athlon k7" ;;
+ *6[[68a]]?:*:*:*)
+ AX_GCC_X86_CPUID(0x80000006) # L2 cache size
+ case $ax_cv_gcc_x86_cpuid_0x80000006 in
+ *:*:*[[1-9a-f]]??????:*) # (L2 = ecx >> 16) >= 256
+ ax_gcc_arch="athlon-xp athlon-4 athlon k7" ;;
+ *) ax_gcc_arch="athlon-4 athlon k7" ;;
+ esac ;;
+ ?00??f[[4cef8b]]?:*:*:*) ax_gcc_arch="athlon64 k8" ;;
+ ?00??f5?:*:*:*) ax_gcc_arch="opteron k8" ;;
+ ?00??f7?:*:*:*) ax_gcc_arch="athlon-fx opteron k8" ;;
+ ?00??f??:*:*:*) ax_gcc_arch="k8" ;;
+ ?05??f??:*:*:*) ax_gcc_arch="btver1 amdfam10 k8" ;;
+ ?06??f??:*:*:*) ax_gcc_arch="bdver1 amdfam10 k8" ;;
+ *f??:*:*:*) ax_gcc_arch="amdfam10 k8" ;;
+ esac ;;
+ *:746e6543:*:*) # IDT
+ case $ax_cv_gcc_x86_cpuid_1 in
+ *54?:*:*:*) ax_gcc_arch=winchip-c6 ;;
+ *58?:*:*:*) ax_gcc_arch=winchip2 ;;
+ *6[[78]]?:*:*:*) ax_gcc_arch=c3 ;;
+ *69?:*:*:*) ax_gcc_arch="c3-2 c3" ;;
+ esac ;;
+ esac
+ if test x"$ax_gcc_arch" = x; then # fallback
+ case $host_cpu in
+ i586*) ax_gcc_arch=pentium ;;
+ i686*) ax_gcc_arch=pentiumpro ;;
+ esac
+ fi
+ ;;
+
+ sparc*)
+ AC_PATH_PROG([PRTDIAG], [prtdiag], [prtdiag], [$PATH:/usr/platform/`uname -i`/sbin/:/usr/platform/`uname -m`/sbin/])
+ cputype=`(((grep cpu /proc/cpuinfo | cut -d: -f2) ; ($PRTDIAG -v |grep -i sparc) ; grep -i cpu /var/run/dmesg.boot ) | head -n 1) 2> /dev/null`
+ cputype=`echo "$cputype" | tr -d ' -' | sed 's/SPARCIIi/SPARCII/' | tr $as_cr_LETTERS $as_cr_letters`
+ case $cputype in
+ *ultrasparciv*) ax_gcc_arch="ultrasparc4 ultrasparc3 ultrasparc v9" ;;
+ *ultrasparciii*) ax_gcc_arch="ultrasparc3 ultrasparc v9" ;;
+ *ultrasparc*) ax_gcc_arch="ultrasparc v9" ;;
+ *supersparc*|*tms390z5[[05]]*) ax_gcc_arch="supersparc v8" ;;
+ *hypersparc*|*rt62[[056]]*) ax_gcc_arch="hypersparc v8" ;;
+ *cypress*) ax_gcc_arch=cypress ;;
+ esac ;;
+
+ alphaev5) ax_gcc_arch=ev5 ;;
+ alphaev56) ax_gcc_arch=ev56 ;;
+ alphapca56) ax_gcc_arch="pca56 ev56" ;;
+ alphapca57) ax_gcc_arch="pca57 pca56 ev56" ;;
+ alphaev6) ax_gcc_arch=ev6 ;;
+ alphaev67) ax_gcc_arch=ev67 ;;
+ alphaev68) ax_gcc_arch="ev68 ev67" ;;
+ alphaev69) ax_gcc_arch="ev69 ev68 ev67" ;;
+ alphaev7) ax_gcc_arch="ev7 ev69 ev68 ev67" ;;
+ alphaev79) ax_gcc_arch="ev79 ev7 ev69 ev68 ev67" ;;
+
+ powerpc*)
+ cputype=`((grep cpu /proc/cpuinfo | head -n 1 | cut -d: -f2 | cut -d, -f1 | sed 's/ //g') ; /usr/bin/machine ; /bin/machine; grep CPU /var/run/dmesg.boot | head -n 1 | cut -d" " -f2) 2> /dev/null`
+ cputype=`echo $cputype | sed -e 's/ppc//g;s/ *//g'`
+ case $cputype in
+ *750*) ax_gcc_arch="750 G3" ;;
+ *740[[0-9]]*) ax_gcc_arch="$cputype 7400 G4" ;;
+ *74[[4-5]][[0-9]]*) ax_gcc_arch="$cputype 7450 G4" ;;
+ *74[[0-9]][[0-9]]*) ax_gcc_arch="$cputype G4" ;;
+ *970*) ax_gcc_arch="970 G5 power4";;
+ *POWER4*|*power4*|*gq*) ax_gcc_arch="power4 970";;
+ *POWER5*|*power5*|*gr*|*gs*) ax_gcc_arch="power5 power4 970";;
+ 603ev|8240) ax_gcc_arch="$cputype 603e 603";;
+ *) ax_gcc_arch=$cputype ;;
+ esac
+ ax_gcc_arch="$ax_gcc_arch powerpc"
+ ;;
+esac
+fi # not cross-compiling
+fi # guess arch
+
+if test "x$ax_gcc_arch" != x -a "x$ax_gcc_arch" != xno; then
+for arch in $ax_gcc_arch; do
+ if test "x[]m4_default([$1],yes)" = xyes; then # if we require portable code
+ flags="-mtune=$arch"
+ # -mcpu=$arch and m$arch generate nonportable code on every arch except
+ # x86. And some other arches (e.g. Alpha) don't accept -mtune. Grrr.
+ case $host_cpu in i*86|x86_64*) flags="$flags -mcpu=$arch -m$arch";; esac
+ else
+ flags="-march=$arch -mcpu=$arch -m$arch"
+ fi
+ for flag in $flags; do
+ AX_CHECK_COMPILE_FLAG($flag, [ax_cv_gcc_archflag=$flag; break])
+ done
+ test "x$ax_cv_gcc_archflag" = xunknown || break
+done
+fi
+
+fi # $GCC=yes
+])
+AC_MSG_CHECKING([for gcc architecture flag])
+AC_MSG_RESULT($ax_cv_gcc_archflag)
+if test "x$ax_cv_gcc_archflag" = xunknown; then
+ m4_default([$3],:)
+else
+ m4_default([$2], [CFLAGS="$CFLAGS $ax_cv_gcc_archflag"])
+fi
+])
diff --git a/jni/ruby/ext/fiddle/libffi-3.2.1/m4/ax_gcc_x86_cpuid.m4 b/jni/ruby/ext/fiddle/libffi-3.2.1/m4/ax_gcc_x86_cpuid.m4
new file mode 100644
index 0000000..7d46fee
--- /dev/null
+++ b/jni/ruby/ext/fiddle/libffi-3.2.1/m4/ax_gcc_x86_cpuid.m4
@@ -0,0 +1,79 @@
+# ===========================================================================
+# http://www.gnu.org/software/autoconf-archive/ax_gcc_x86_cpuid.html
+# ===========================================================================
+#
+# SYNOPSIS
+#
+# AX_GCC_X86_CPUID(OP)
+#
+# DESCRIPTION
+#
+# On Pentium and later x86 processors, with gcc or a compiler that has a
+# compatible syntax for inline assembly instructions, run a small program
+# that executes the cpuid instruction with input OP. This can be used to
+# detect the CPU type.
+#
+# On output, the values of the eax, ebx, ecx, and edx registers are stored
+# as hexadecimal strings as "eax:ebx:ecx:edx" in the cache variable
+# ax_cv_gcc_x86_cpuid_OP.
+#
+# If the cpuid instruction fails (because you are running a
+# cross-compiler, or because you are not using gcc, or because you are on
+# a processor that doesn't have this instruction), ax_cv_gcc_x86_cpuid_OP
+# is set to the string "unknown".
+#
+# This macro mainly exists to be used in AX_GCC_ARCHFLAG.
+#
+# LICENSE
+#
+# Copyright (c) 2008 Steven G. Johnson <stevenj@alum.mit.edu>
+# Copyright (c) 2008 Matteo Frigo
+#
+# 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 3 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, see <http://www.gnu.org/licenses/>.
+#
+# As a special exception, the respective Autoconf Macro's copyright owner
+# gives unlimited permission to copy, distribute and modify the configure
+# scripts that are the output of Autoconf when processing the Macro. You
+# need not follow the terms of the GNU General Public License when using
+# or distributing such scripts, even though portions of the text of the
+# Macro appear in them. The GNU General Public License (GPL) does govern
+# all other use of the material that constitutes the Autoconf Macro.
+#
+# This special exception to the GPL applies to versions of the Autoconf
+# Macro released by the Autoconf Archive. When you make and distribute a
+# modified version of the Autoconf Macro, you may extend this special
+# exception to the GPL to apply to your modified version as well.
+
+#serial 7
+
+AC_DEFUN([AX_GCC_X86_CPUID],
+[AC_REQUIRE([AC_PROG_CC])
+AC_LANG_PUSH([C])
+AC_CACHE_CHECK(for x86 cpuid $1 output, ax_cv_gcc_x86_cpuid_$1,
+ [AC_RUN_IFELSE([AC_LANG_PROGRAM([#include <stdio.h>], [
+ int op = $1, eax, ebx, ecx, edx;
+ FILE *f;
+ __asm__("cpuid"
+ : "=a" (eax), "=b" (ebx), "=c" (ecx), "=d" (edx)
+ : "a" (op));
+ f = fopen("conftest_cpuid", "w"); if (!f) return 1;
+ fprintf(f, "%x:%x:%x:%x\n", eax, ebx, ecx, edx);
+ fclose(f);
+ return 0;
+])],
+ [ax_cv_gcc_x86_cpuid_$1=`cat conftest_cpuid`; rm -f conftest_cpuid],
+ [ax_cv_gcc_x86_cpuid_$1=unknown; rm -f conftest_cpuid],
+ [ax_cv_gcc_x86_cpuid_$1=unknown])])
+AC_LANG_POP([C])
+])
diff --git a/jni/ruby/ext/fiddle/libffi-3.2.1/m4/libtool.m4 b/jni/ruby/ext/fiddle/libffi-3.2.1/m4/libtool.m4
new file mode 100644
index 0000000..56666f0
--- /dev/null
+++ b/jni/ruby/ext/fiddle/libffi-3.2.1/m4/libtool.m4
@@ -0,0 +1,7986 @@
+# libtool.m4 - Configure libtool for the host system. -*-Autoconf-*-
+#
+# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005,
+# 2006, 2007, 2008, 2009, 2010, 2011 Free Software
+# Foundation, Inc.
+# Written by Gordon Matzigkeit, 1996
+#
+# This file is free software; the Free Software Foundation gives
+# unlimited permission to copy and/or distribute it, with or without
+# modifications, as long as this notice is preserved.
+
+m4_define([_LT_COPYING], [dnl
+# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005,
+# 2006, 2007, 2008, 2009, 2010, 2011 Free Software
+# Foundation, Inc.
+# Written by Gordon Matzigkeit, 1996
+#
+# This file is part of GNU Libtool.
+#
+# GNU Libtool is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License as
+# published by the Free Software Foundation; either version 2 of
+# the License, or (at your option) any later version.
+#
+# As a special exception to the GNU General Public License,
+# if you distribute this file as part of a program or library that
+# is built using GNU Libtool, you may include this file under the
+# same distribution terms that you use for the rest of that program.
+#
+# GNU Libtool is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with GNU Libtool; see the file COPYING. If not, a copy
+# can be downloaded from http://www.gnu.org/licenses/gpl.html, or
+# obtained by writing to the Free Software Foundation, Inc.,
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+])
+
+# serial 57 LT_INIT
+
+
+# LT_PREREQ(VERSION)
+# ------------------
+# Complain and exit if this libtool version is less that VERSION.
+m4_defun([LT_PREREQ],
+[m4_if(m4_version_compare(m4_defn([LT_PACKAGE_VERSION]), [$1]), -1,
+ [m4_default([$3],
+ [m4_fatal([Libtool version $1 or higher is required],
+ 63)])],
+ [$2])])
+
+
+# _LT_CHECK_BUILDDIR
+# ------------------
+# Complain if the absolute build directory name contains unusual characters
+m4_defun([_LT_CHECK_BUILDDIR],
+[case `pwd` in
+ *\ * | *\ *)
+ AC_MSG_WARN([Libtool does not cope well with whitespace in `pwd`]) ;;
+esac
+])
+
+
+# LT_INIT([OPTIONS])
+# ------------------
+AC_DEFUN([LT_INIT],
+[AC_PREREQ([2.58])dnl We use AC_INCLUDES_DEFAULT
+AC_REQUIRE([AC_CONFIG_AUX_DIR_DEFAULT])dnl
+AC_BEFORE([$0], [LT_LANG])dnl
+AC_BEFORE([$0], [LT_OUTPUT])dnl
+AC_BEFORE([$0], [LTDL_INIT])dnl
+m4_require([_LT_CHECK_BUILDDIR])dnl
+
+dnl Autoconf doesn't catch unexpanded LT_ macros by default:
+m4_pattern_forbid([^_?LT_[A-Z_]+$])dnl
+m4_pattern_allow([^(_LT_EOF|LT_DLGLOBAL|LT_DLLAZY_OR_NOW|LT_MULTI_MODULE)$])dnl
+dnl aclocal doesn't pull ltoptions.m4, ltsugar.m4, or ltversion.m4
+dnl unless we require an AC_DEFUNed macro:
+AC_REQUIRE([LTOPTIONS_VERSION])dnl
+AC_REQUIRE([LTSUGAR_VERSION])dnl
+AC_REQUIRE([LTVERSION_VERSION])dnl
+AC_REQUIRE([LTOBSOLETE_VERSION])dnl
+m4_require([_LT_PROG_LTMAIN])dnl
+
+_LT_SHELL_INIT([SHELL=${CONFIG_SHELL-/bin/sh}])
+
+dnl Parse OPTIONS
+_LT_SET_OPTIONS([$0], [$1])
+
+# This can be used to rebuild libtool when needed
+LIBTOOL_DEPS="$ltmain"
+
+# Always use our own libtool.
+LIBTOOL='$(SHELL) $(top_builddir)/libtool'
+AC_SUBST(LIBTOOL)dnl
+
+_LT_SETUP
+
+# Only expand once:
+m4_define([LT_INIT])
+])# LT_INIT
+
+# Old names:
+AU_ALIAS([AC_PROG_LIBTOOL], [LT_INIT])
+AU_ALIAS([AM_PROG_LIBTOOL], [LT_INIT])
+dnl aclocal-1.4 backwards compatibility:
+dnl AC_DEFUN([AC_PROG_LIBTOOL], [])
+dnl AC_DEFUN([AM_PROG_LIBTOOL], [])
+
+
+# _LT_CC_BASENAME(CC)
+# -------------------
+# Calculate cc_basename. Skip known compiler wrappers and cross-prefix.
+m4_defun([_LT_CC_BASENAME],
+[for cc_temp in $1""; do
+ case $cc_temp in
+ compile | *[[\\/]]compile | ccache | *[[\\/]]ccache ) ;;
+ distcc | *[[\\/]]distcc | purify | *[[\\/]]purify ) ;;
+ \-*) ;;
+ *) break;;
+ esac
+done
+cc_basename=`$ECHO "$cc_temp" | $SED "s%.*/%%; s%^$host_alias-%%"`
+])
+
+
+# _LT_FILEUTILS_DEFAULTS
+# ----------------------
+# It is okay to use these file commands and assume they have been set
+# sensibly after `m4_require([_LT_FILEUTILS_DEFAULTS])'.
+m4_defun([_LT_FILEUTILS_DEFAULTS],
+[: ${CP="cp -f"}
+: ${MV="mv -f"}
+: ${RM="rm -f"}
+])# _LT_FILEUTILS_DEFAULTS
+
+
+# _LT_SETUP
+# ---------
+m4_defun([_LT_SETUP],
+[AC_REQUIRE([AC_CANONICAL_HOST])dnl
+AC_REQUIRE([AC_CANONICAL_BUILD])dnl
+AC_REQUIRE([_LT_PREPARE_SED_QUOTE_VARS])dnl
+AC_REQUIRE([_LT_PROG_ECHO_BACKSLASH])dnl
+
+_LT_DECL([], [PATH_SEPARATOR], [1], [The PATH separator for the build system])dnl
+dnl
+_LT_DECL([], [host_alias], [0], [The host system])dnl
+_LT_DECL([], [host], [0])dnl
+_LT_DECL([], [host_os], [0])dnl
+dnl
+_LT_DECL([], [build_alias], [0], [The build system])dnl
+_LT_DECL([], [build], [0])dnl
+_LT_DECL([], [build_os], [0])dnl
+dnl
+AC_REQUIRE([AC_PROG_CC])dnl
+AC_REQUIRE([LT_PATH_LD])dnl
+AC_REQUIRE([LT_PATH_NM])dnl
+dnl
+AC_REQUIRE([AC_PROG_LN_S])dnl
+test -z "$LN_S" && LN_S="ln -s"
+_LT_DECL([], [LN_S], [1], [Whether we need soft or hard links])dnl
+dnl
+AC_REQUIRE([LT_CMD_MAX_LEN])dnl
+_LT_DECL([objext], [ac_objext], [0], [Object file suffix (normally "o")])dnl
+_LT_DECL([], [exeext], [0], [Executable file suffix (normally "")])dnl
+dnl
+m4_require([_LT_FILEUTILS_DEFAULTS])dnl
+m4_require([_LT_CHECK_SHELL_FEATURES])dnl
+m4_require([_LT_PATH_CONVERSION_FUNCTIONS])dnl
+m4_require([_LT_CMD_RELOAD])dnl
+m4_require([_LT_CHECK_MAGIC_METHOD])dnl
+m4_require([_LT_CHECK_SHAREDLIB_FROM_LINKLIB])dnl
+m4_require([_LT_CMD_OLD_ARCHIVE])dnl
+m4_require([_LT_CMD_GLOBAL_SYMBOLS])dnl
+m4_require([_LT_WITH_SYSROOT])dnl
+
+_LT_CONFIG_LIBTOOL_INIT([
+# See if we are running on zsh, and set the options which allow our
+# commands through without removal of \ escapes INIT.
+if test -n "\${ZSH_VERSION+set}" ; then
+ setopt NO_GLOB_SUBST
+fi
+])
+if test -n "${ZSH_VERSION+set}" ; then
+ setopt NO_GLOB_SUBST
+fi
+
+_LT_CHECK_OBJDIR
+
+m4_require([_LT_TAG_COMPILER])dnl
+
+case $host_os in
+aix3*)
+ # AIX sometimes has problems with the GCC collect2 program. For some
+ # reason, if we set the COLLECT_NAMES environment variable, the problems
+ # vanish in a puff of smoke.
+ if test "X${COLLECT_NAMES+set}" != Xset; then
+ COLLECT_NAMES=
+ export COLLECT_NAMES
+ fi
+ ;;
+esac
+
+# Global variables:
+ofile=libtool
+can_build_shared=yes
+
+# All known linkers require a `.a' archive for static linking (except MSVC,
+# which needs '.lib').
+libext=a
+
+with_gnu_ld="$lt_cv_prog_gnu_ld"
+
+old_CC="$CC"
+old_CFLAGS="$CFLAGS"
+
+# Set sane defaults for various variables
+test -z "$CC" && CC=cc
+test -z "$LTCC" && LTCC=$CC
+test -z "$LTCFLAGS" && LTCFLAGS=$CFLAGS
+test -z "$LD" && LD=ld
+test -z "$ac_objext" && ac_objext=o
+
+_LT_CC_BASENAME([$compiler])
+
+# Only perform the check for file, if the check method requires it
+test -z "$MAGIC_CMD" && MAGIC_CMD=file
+case $deplibs_check_method in
+file_magic*)
+ if test "$file_magic_cmd" = '$MAGIC_CMD'; then
+ _LT_PATH_MAGIC
+ fi
+ ;;
+esac
+
+# Use C for the default configuration in the libtool script
+LT_SUPPORTED_TAG([CC])
+_LT_LANG_C_CONFIG
+_LT_LANG_DEFAULT_CONFIG
+_LT_CONFIG_COMMANDS
+])# _LT_SETUP
+
+
+# _LT_PREPARE_SED_QUOTE_VARS
+# --------------------------
+# Define a few sed substitution that help us do robust quoting.
+m4_defun([_LT_PREPARE_SED_QUOTE_VARS],
+[# Backslashify metacharacters that are still active within
+# double-quoted strings.
+sed_quote_subst='s/\([["`$\\]]\)/\\\1/g'
+
+# Same as above, but do not quote variable references.
+double_quote_subst='s/\([["`\\]]\)/\\\1/g'
+
+# Sed substitution to delay expansion of an escaped shell variable in a
+# double_quote_subst'ed string.
+delay_variable_subst='s/\\\\\\\\\\\$/\\\\\\$/g'
+
+# Sed substitution to delay expansion of an escaped single quote.
+delay_single_quote_subst='s/'\''/'\'\\\\\\\'\''/g'
+
+# Sed substitution to avoid accidental globbing in evaled expressions
+no_glob_subst='s/\*/\\\*/g'
+])
+
+# _LT_PROG_LTMAIN
+# ---------------
+# Note that this code is called both from `configure', and `config.status'
+# now that we use AC_CONFIG_COMMANDS to generate libtool. Notably,
+# `config.status' has no value for ac_aux_dir unless we are using Automake,
+# so we pass a copy along to make sure it has a sensible value anyway.
+m4_defun([_LT_PROG_LTMAIN],
+[m4_ifdef([AC_REQUIRE_AUX_FILE], [AC_REQUIRE_AUX_FILE([ltmain.sh])])dnl
+_LT_CONFIG_LIBTOOL_INIT([ac_aux_dir='$ac_aux_dir'])
+ltmain="$ac_aux_dir/ltmain.sh"
+])# _LT_PROG_LTMAIN
+
+
+## ------------------------------------- ##
+## Accumulate code for creating libtool. ##
+## ------------------------------------- ##
+
+# So that we can recreate a full libtool script including additional
+# tags, we accumulate the chunks of code to send to AC_CONFIG_COMMANDS
+# in macros and then make a single call at the end using the `libtool'
+# label.
+
+
+# _LT_CONFIG_LIBTOOL_INIT([INIT-COMMANDS])
+# ----------------------------------------
+# Register INIT-COMMANDS to be passed to AC_CONFIG_COMMANDS later.
+m4_define([_LT_CONFIG_LIBTOOL_INIT],
+[m4_ifval([$1],
+ [m4_append([_LT_OUTPUT_LIBTOOL_INIT],
+ [$1
+])])])
+
+# Initialize.
+m4_define([_LT_OUTPUT_LIBTOOL_INIT])
+
+
+# _LT_CONFIG_LIBTOOL([COMMANDS])
+# ------------------------------
+# Register COMMANDS to be passed to AC_CONFIG_COMMANDS later.
+m4_define([_LT_CONFIG_LIBTOOL],
+[m4_ifval([$1],
+ [m4_append([_LT_OUTPUT_LIBTOOL_COMMANDS],
+ [$1
+])])])
+
+# Initialize.
+m4_define([_LT_OUTPUT_LIBTOOL_COMMANDS])
+
+
+# _LT_CONFIG_SAVE_COMMANDS([COMMANDS], [INIT_COMMANDS])
+# -----------------------------------------------------
+m4_defun([_LT_CONFIG_SAVE_COMMANDS],
+[_LT_CONFIG_LIBTOOL([$1])
+_LT_CONFIG_LIBTOOL_INIT([$2])
+])
+
+
+# _LT_FORMAT_COMMENT([COMMENT])
+# -----------------------------
+# Add leading comment marks to the start of each line, and a trailing
+# full-stop to the whole comment if one is not present already.
+m4_define([_LT_FORMAT_COMMENT],
+[m4_ifval([$1], [
+m4_bpatsubst([m4_bpatsubst([$1], [^ *], [# ])],
+ [['`$\]], [\\\&])]m4_bmatch([$1], [[!?.]$], [], [.])
+)])
+
+
+
+## ------------------------ ##
+## FIXME: Eliminate VARNAME ##
+## ------------------------ ##
+
+
+# _LT_DECL([CONFIGNAME], VARNAME, VALUE, [DESCRIPTION], [IS-TAGGED?])
+# -------------------------------------------------------------------
+# CONFIGNAME is the name given to the value in the libtool script.
+# VARNAME is the (base) name used in the configure script.
+# VALUE may be 0, 1 or 2 for a computed quote escaped value based on
+# VARNAME. Any other value will be used directly.
+m4_define([_LT_DECL],
+[lt_if_append_uniq([lt_decl_varnames], [$2], [, ],
+ [lt_dict_add_subkey([lt_decl_dict], [$2], [libtool_name],
+ [m4_ifval([$1], [$1], [$2])])
+ lt_dict_add_subkey([lt_decl_dict], [$2], [value], [$3])
+ m4_ifval([$4],
+ [lt_dict_add_subkey([lt_decl_dict], [$2], [description], [$4])])
+ lt_dict_add_subkey([lt_decl_dict], [$2],
+ [tagged?], [m4_ifval([$5], [yes], [no])])])
+])
+
+
+# _LT_TAGDECL([CONFIGNAME], VARNAME, VALUE, [DESCRIPTION])
+# --------------------------------------------------------
+m4_define([_LT_TAGDECL], [_LT_DECL([$1], [$2], [$3], [$4], [yes])])
+
+
+# lt_decl_tag_varnames([SEPARATOR], [VARNAME1...])
+# ------------------------------------------------
+m4_define([lt_decl_tag_varnames],
+[_lt_decl_filter([tagged?], [yes], $@)])
+
+
+# _lt_decl_filter(SUBKEY, VALUE, [SEPARATOR], [VARNAME1..])
+# ---------------------------------------------------------
+m4_define([_lt_decl_filter],
+[m4_case([$#],
+ [0], [m4_fatal([$0: too few arguments: $#])],
+ [1], [m4_fatal([$0: too few arguments: $#: $1])],
+ [2], [lt_dict_filter([lt_decl_dict], [$1], [$2], [], lt_decl_varnames)],
+ [3], [lt_dict_filter([lt_decl_dict], [$1], [$2], [$3], lt_decl_varnames)],
+ [lt_dict_filter([lt_decl_dict], $@)])[]dnl
+])
+
+
+# lt_decl_quote_varnames([SEPARATOR], [VARNAME1...])
+# --------------------------------------------------
+m4_define([lt_decl_quote_varnames],
+[_lt_decl_filter([value], [1], $@)])
+
+
+# lt_decl_dquote_varnames([SEPARATOR], [VARNAME1...])
+# ---------------------------------------------------
+m4_define([lt_decl_dquote_varnames],
+[_lt_decl_filter([value], [2], $@)])
+
+
+# lt_decl_varnames_tagged([SEPARATOR], [VARNAME1...])
+# ---------------------------------------------------
+m4_define([lt_decl_varnames_tagged],
+[m4_assert([$# <= 2])dnl
+_$0(m4_quote(m4_default([$1], [[, ]])),
+ m4_ifval([$2], [[$2]], [m4_dquote(lt_decl_tag_varnames)]),
+ m4_split(m4_normalize(m4_quote(_LT_TAGS)), [ ]))])
+m4_define([_lt_decl_varnames_tagged],
+[m4_ifval([$3], [lt_combine([$1], [$2], [_], $3)])])
+
+
+# lt_decl_all_varnames([SEPARATOR], [VARNAME1...])
+# ------------------------------------------------
+m4_define([lt_decl_all_varnames],
+[_$0(m4_quote(m4_default([$1], [[, ]])),
+ m4_if([$2], [],
+ m4_quote(lt_decl_varnames),
+ m4_quote(m4_shift($@))))[]dnl
+])
+m4_define([_lt_decl_all_varnames],
+[lt_join($@, lt_decl_varnames_tagged([$1],
+ lt_decl_tag_varnames([[, ]], m4_shift($@))))dnl
+])
+
+
+# _LT_CONFIG_STATUS_DECLARE([VARNAME])
+# ------------------------------------
+# Quote a variable value, and forward it to `config.status' so that its
+# declaration there will have the same value as in `configure'. VARNAME
+# must have a single quote delimited value for this to work.
+m4_define([_LT_CONFIG_STATUS_DECLARE],
+[$1='`$ECHO "$][$1" | $SED "$delay_single_quote_subst"`'])
+
+
+# _LT_CONFIG_STATUS_DECLARATIONS
+# ------------------------------
+# We delimit libtool config variables with single quotes, so when
+# we write them to config.status, we have to be sure to quote all
+# embedded single quotes properly. In configure, this macro expands
+# each variable declared with _LT_DECL (and _LT_TAGDECL) into:
+#
+# <var>='`$ECHO "$<var>" | $SED "$delay_single_quote_subst"`'
+m4_defun([_LT_CONFIG_STATUS_DECLARATIONS],
+[m4_foreach([_lt_var], m4_quote(lt_decl_all_varnames),
+ [m4_n([_LT_CONFIG_STATUS_DECLARE(_lt_var)])])])
+
+
+# _LT_LIBTOOL_TAGS
+# ----------------
+# Output comment and list of tags supported by the script
+m4_defun([_LT_LIBTOOL_TAGS],
+[_LT_FORMAT_COMMENT([The names of the tagged configurations supported by this script])dnl
+available_tags="_LT_TAGS"dnl
+])
+
+
+# _LT_LIBTOOL_DECLARE(VARNAME, [TAG])
+# -----------------------------------
+# Extract the dictionary values for VARNAME (optionally with TAG) and
+# expand to a commented shell variable setting:
+#
+# # Some comment about what VAR is for.
+# visible_name=$lt_internal_name
+m4_define([_LT_LIBTOOL_DECLARE],
+[_LT_FORMAT_COMMENT(m4_quote(lt_dict_fetch([lt_decl_dict], [$1],
+ [description])))[]dnl
+m4_pushdef([_libtool_name],
+ m4_quote(lt_dict_fetch([lt_decl_dict], [$1], [libtool_name])))[]dnl
+m4_case(m4_quote(lt_dict_fetch([lt_decl_dict], [$1], [value])),
+ [0], [_libtool_name=[$]$1],
+ [1], [_libtool_name=$lt_[]$1],
+ [2], [_libtool_name=$lt_[]$1],
+ [_libtool_name=lt_dict_fetch([lt_decl_dict], [$1], [value])])[]dnl
+m4_ifval([$2], [_$2])[]m4_popdef([_libtool_name])[]dnl
+])
+
+
+# _LT_LIBTOOL_CONFIG_VARS
+# -----------------------
+# Produce commented declarations of non-tagged libtool config variables
+# suitable for insertion in the LIBTOOL CONFIG section of the `libtool'
+# script. Tagged libtool config variables (even for the LIBTOOL CONFIG
+# section) are produced by _LT_LIBTOOL_TAG_VARS.
+m4_defun([_LT_LIBTOOL_CONFIG_VARS],
+[m4_foreach([_lt_var],
+ m4_quote(_lt_decl_filter([tagged?], [no], [], lt_decl_varnames)),
+ [m4_n([_LT_LIBTOOL_DECLARE(_lt_var)])])])
+
+
+# _LT_LIBTOOL_TAG_VARS(TAG)
+# -------------------------
+m4_define([_LT_LIBTOOL_TAG_VARS],
+[m4_foreach([_lt_var], m4_quote(lt_decl_tag_varnames),
+ [m4_n([_LT_LIBTOOL_DECLARE(_lt_var, [$1])])])])
+
+
+# _LT_TAGVAR(VARNAME, [TAGNAME])
+# ------------------------------
+m4_define([_LT_TAGVAR], [m4_ifval([$2], [$1_$2], [$1])])
+
+
+# _LT_CONFIG_COMMANDS
+# -------------------
+# Send accumulated output to $CONFIG_STATUS. Thanks to the lists of
+# variables for single and double quote escaping we saved from calls
+# to _LT_DECL, we can put quote escaped variables declarations
+# into `config.status', and then the shell code to quote escape them in
+# for loops in `config.status'. Finally, any additional code accumulated
+# from calls to _LT_CONFIG_LIBTOOL_INIT is expanded.
+m4_defun([_LT_CONFIG_COMMANDS],
+[AC_PROVIDE_IFELSE([LT_OUTPUT],
+ dnl If the libtool generation code has been placed in $CONFIG_LT,
+ dnl instead of duplicating it all over again into config.status,
+ dnl then we will have config.status run $CONFIG_LT later, so it
+ dnl needs to know what name is stored there:
+ [AC_CONFIG_COMMANDS([libtool],
+ [$SHELL $CONFIG_LT || AS_EXIT(1)], [CONFIG_LT='$CONFIG_LT'])],
+ dnl If the libtool generation code is destined for config.status,
+ dnl expand the accumulated commands and init code now:
+ [AC_CONFIG_COMMANDS([libtool],
+ [_LT_OUTPUT_LIBTOOL_COMMANDS], [_LT_OUTPUT_LIBTOOL_COMMANDS_INIT])])
+])#_LT_CONFIG_COMMANDS
+
+
+# Initialize.
+m4_define([_LT_OUTPUT_LIBTOOL_COMMANDS_INIT],
+[
+
+# The HP-UX ksh and POSIX shell print the target directory to stdout
+# if CDPATH is set.
+(unset CDPATH) >/dev/null 2>&1 && unset CDPATH
+
+sed_quote_subst='$sed_quote_subst'
+double_quote_subst='$double_quote_subst'
+delay_variable_subst='$delay_variable_subst'
+_LT_CONFIG_STATUS_DECLARATIONS
+LTCC='$LTCC'
+LTCFLAGS='$LTCFLAGS'
+compiler='$compiler_DEFAULT'
+
+# A function that is used when there is no print builtin or printf.
+func_fallback_echo ()
+{
+ eval 'cat <<_LTECHO_EOF
+\$[]1
+_LTECHO_EOF'
+}
+
+# Quote evaled strings.
+for var in lt_decl_all_varnames([[ \
+]], lt_decl_quote_varnames); do
+ case \`eval \\\\\$ECHO \\\\""\\\\\$\$var"\\\\"\` in
+ *[[\\\\\\\`\\"\\\$]]*)
+ eval "lt_\$var=\\\\\\"\\\`\\\$ECHO \\"\\\$\$var\\" | \\\$SED \\"\\\$sed_quote_subst\\"\\\`\\\\\\""
+ ;;
+ *)
+ eval "lt_\$var=\\\\\\"\\\$\$var\\\\\\""
+ ;;
+ esac
+done
+
+# Double-quote double-evaled strings.
+for var in lt_decl_all_varnames([[ \
+]], lt_decl_dquote_varnames); do
+ case \`eval \\\\\$ECHO \\\\""\\\\\$\$var"\\\\"\` in
+ *[[\\\\\\\`\\"\\\$]]*)
+ eval "lt_\$var=\\\\\\"\\\`\\\$ECHO \\"\\\$\$var\\" | \\\$SED -e \\"\\\$double_quote_subst\\" -e \\"\\\$sed_quote_subst\\" -e \\"\\\$delay_variable_subst\\"\\\`\\\\\\""
+ ;;
+ *)
+ eval "lt_\$var=\\\\\\"\\\$\$var\\\\\\""
+ ;;
+ esac
+done
+
+_LT_OUTPUT_LIBTOOL_INIT
+])
+
+# _LT_GENERATED_FILE_INIT(FILE, [COMMENT])
+# ------------------------------------
+# Generate a child script FILE with all initialization necessary to
+# reuse the environment learned by the parent script, and make the
+# file executable. If COMMENT is supplied, it is inserted after the
+# `#!' sequence but before initialization text begins. After this
+# macro, additional text can be appended to FILE to form the body of
+# the child script. The macro ends with non-zero status if the
+# file could not be fully written (such as if the disk is full).
+m4_ifdef([AS_INIT_GENERATED],
+[m4_defun([_LT_GENERATED_FILE_INIT],[AS_INIT_GENERATED($@)])],
+[m4_defun([_LT_GENERATED_FILE_INIT],
+[m4_require([AS_PREPARE])]dnl
+[m4_pushdef([AS_MESSAGE_LOG_FD])]dnl
+[lt_write_fail=0
+cat >$1 <<_ASEOF || lt_write_fail=1
+#! $SHELL
+# Generated by $as_me.
+$2
+SHELL=\${CONFIG_SHELL-$SHELL}
+export SHELL
+_ASEOF
+cat >>$1 <<\_ASEOF || lt_write_fail=1
+AS_SHELL_SANITIZE
+_AS_PREPARE
+exec AS_MESSAGE_FD>&1
+_ASEOF
+test $lt_write_fail = 0 && chmod +x $1[]dnl
+m4_popdef([AS_MESSAGE_LOG_FD])])])# _LT_GENERATED_FILE_INIT
+
+# LT_OUTPUT
+# ---------
+# This macro allows early generation of the libtool script (before
+# AC_OUTPUT is called), incase it is used in configure for compilation
+# tests.
+AC_DEFUN([LT_OUTPUT],
+[: ${CONFIG_LT=./config.lt}
+AC_MSG_NOTICE([creating $CONFIG_LT])
+_LT_GENERATED_FILE_INIT(["$CONFIG_LT"],
+[# Run this file to recreate a libtool stub with the current configuration.])
+
+cat >>"$CONFIG_LT" <<\_LTEOF
+lt_cl_silent=false
+exec AS_MESSAGE_LOG_FD>>config.log
+{
+ echo
+ AS_BOX([Running $as_me.])
+} >&AS_MESSAGE_LOG_FD
+
+lt_cl_help="\
+\`$as_me' creates a local libtool stub from the current configuration,
+for use in further configure time tests before the real libtool is
+generated.
+
+Usage: $[0] [[OPTIONS]]
+
+ -h, --help print this help, then exit
+ -V, --version print version number, then exit
+ -q, --quiet do not print progress messages
+ -d, --debug don't remove temporary files
+
+Report bugs to <bug-libtool@gnu.org>."
+
+lt_cl_version="\
+m4_ifset([AC_PACKAGE_NAME], [AC_PACKAGE_NAME ])config.lt[]dnl
+m4_ifset([AC_PACKAGE_VERSION], [ AC_PACKAGE_VERSION])
+configured by $[0], generated by m4_PACKAGE_STRING.
+
+Copyright (C) 2011 Free Software Foundation, Inc.
+This config.lt script is free software; the Free Software Foundation
+gives unlimited permision to copy, distribute and modify it."
+
+while test $[#] != 0
+do
+ case $[1] in
+ --version | --v* | -V )
+ echo "$lt_cl_version"; exit 0 ;;
+ --help | --h* | -h )
+ echo "$lt_cl_help"; exit 0 ;;
+ --debug | --d* | -d )
+ debug=: ;;
+ --quiet | --q* | --silent | --s* | -q )
+ lt_cl_silent=: ;;
+
+ -*) AC_MSG_ERROR([unrecognized option: $[1]
+Try \`$[0] --help' for more information.]) ;;
+
+ *) AC_MSG_ERROR([unrecognized argument: $[1]
+Try \`$[0] --help' for more information.]) ;;
+ esac
+ shift
+done
+
+if $lt_cl_silent; then
+ exec AS_MESSAGE_FD>/dev/null
+fi
+_LTEOF
+
+cat >>"$CONFIG_LT" <<_LTEOF
+_LT_OUTPUT_LIBTOOL_COMMANDS_INIT
+_LTEOF
+
+cat >>"$CONFIG_LT" <<\_LTEOF
+AC_MSG_NOTICE([creating $ofile])
+_LT_OUTPUT_LIBTOOL_COMMANDS
+AS_EXIT(0)
+_LTEOF
+chmod +x "$CONFIG_LT"
+
+# configure is writing to config.log, but config.lt does its own redirection,
+# appending to config.log, which fails on DOS, as config.log is still kept
+# open by configure. Here we exec the FD to /dev/null, effectively closing
+# config.log, so it can be properly (re)opened and appended to by config.lt.
+lt_cl_success=:
+test "$silent" = yes &&
+ lt_config_lt_args="$lt_config_lt_args --quiet"
+exec AS_MESSAGE_LOG_FD>/dev/null
+$SHELL "$CONFIG_LT" $lt_config_lt_args || lt_cl_success=false
+exec AS_MESSAGE_LOG_FD>>config.log
+$lt_cl_success || AS_EXIT(1)
+])# LT_OUTPUT
+
+
+# _LT_CONFIG(TAG)
+# ---------------
+# If TAG is the built-in tag, create an initial libtool script with a
+# default configuration from the untagged config vars. Otherwise add code
+# to config.status for appending the configuration named by TAG from the
+# matching tagged config vars.
+m4_defun([_LT_CONFIG],
+[m4_require([_LT_FILEUTILS_DEFAULTS])dnl
+_LT_CONFIG_SAVE_COMMANDS([
+ m4_define([_LT_TAG], m4_if([$1], [], [C], [$1]))dnl
+ m4_if(_LT_TAG, [C], [
+ # See if we are running on zsh, and set the options which allow our
+ # commands through without removal of \ escapes.
+ if test -n "${ZSH_VERSION+set}" ; then
+ setopt NO_GLOB_SUBST
+ fi
+
+ cfgfile="${ofile}T"
+ trap "$RM \"$cfgfile\"; exit 1" 1 2 15
+ $RM "$cfgfile"
+
+ cat <<_LT_EOF >> "$cfgfile"
+#! $SHELL
+
+# `$ECHO "$ofile" | sed 's%^.*/%%'` - Provide generalized library-building support services.
+# Generated automatically by $as_me ($PACKAGE$TIMESTAMP) $VERSION
+# Libtool was configured on host `(hostname || uname -n) 2>/dev/null | sed 1q`:
+# NOTE: Changes made to this file will be lost: look at ltmain.sh.
+#
+_LT_COPYING
+_LT_LIBTOOL_TAGS
+
+# ### BEGIN LIBTOOL CONFIG
+_LT_LIBTOOL_CONFIG_VARS
+_LT_LIBTOOL_TAG_VARS
+# ### END LIBTOOL CONFIG
+
+_LT_EOF
+
+ case $host_os in
+ aix3*)
+ cat <<\_LT_EOF >> "$cfgfile"
+# AIX sometimes has problems with the GCC collect2 program. For some
+# reason, if we set the COLLECT_NAMES environment variable, the problems
+# vanish in a puff of smoke.
+if test "X${COLLECT_NAMES+set}" != Xset; then
+ COLLECT_NAMES=
+ export COLLECT_NAMES
+fi
+_LT_EOF
+ ;;
+ esac
+
+ _LT_PROG_LTMAIN
+
+ # We use sed instead of cat because bash on DJGPP gets confused if
+ # if finds mixed CR/LF and LF-only lines. Since sed operates in
+ # text mode, it properly converts lines to CR/LF. This bash problem
+ # is reportedly fixed, but why not run on old versions too?
+ sed '$q' "$ltmain" >> "$cfgfile" \
+ || (rm -f "$cfgfile"; exit 1)
+
+ _LT_PROG_REPLACE_SHELLFNS
+
+ mv -f "$cfgfile" "$ofile" ||
+ (rm -f "$ofile" && cp "$cfgfile" "$ofile" && rm -f "$cfgfile")
+ chmod +x "$ofile"
+],
+[cat <<_LT_EOF >> "$ofile"
+
+dnl Unfortunately we have to use $1 here, since _LT_TAG is not expanded
+dnl in a comment (ie after a #).
+# ### BEGIN LIBTOOL TAG CONFIG: $1
+_LT_LIBTOOL_TAG_VARS(_LT_TAG)
+# ### END LIBTOOL TAG CONFIG: $1
+_LT_EOF
+])dnl /m4_if
+],
+[m4_if([$1], [], [
+ PACKAGE='$PACKAGE'
+ VERSION='$VERSION'
+ TIMESTAMP='$TIMESTAMP'
+ RM='$RM'
+ ofile='$ofile'], [])
+])dnl /_LT_CONFIG_SAVE_COMMANDS
+])# _LT_CONFIG
+
+
+# LT_SUPPORTED_TAG(TAG)
+# ---------------------
+# Trace this macro to discover what tags are supported by the libtool
+# --tag option, using:
+# autoconf --trace 'LT_SUPPORTED_TAG:$1'
+AC_DEFUN([LT_SUPPORTED_TAG], [])
+
+
+# C support is built-in for now
+m4_define([_LT_LANG_C_enabled], [])
+m4_define([_LT_TAGS], [])
+
+
+# LT_LANG(LANG)
+# -------------
+# Enable libtool support for the given language if not already enabled.
+AC_DEFUN([LT_LANG],
+[AC_BEFORE([$0], [LT_OUTPUT])dnl
+m4_case([$1],
+ [C], [_LT_LANG(C)],
+ [C++], [_LT_LANG(CXX)],
+ [Go], [_LT_LANG(GO)],
+ [Java], [_LT_LANG(GCJ)],
+ [Fortran 77], [_LT_LANG(F77)],
+ [Fortran], [_LT_LANG(FC)],
+ [Windows Resource], [_LT_LANG(RC)],
+ [m4_ifdef([_LT_LANG_]$1[_CONFIG],
+ [_LT_LANG($1)],
+ [m4_fatal([$0: unsupported language: "$1"])])])dnl
+])# LT_LANG
+
+
+# _LT_LANG(LANGNAME)
+# ------------------
+m4_defun([_LT_LANG],
+[m4_ifdef([_LT_LANG_]$1[_enabled], [],
+ [LT_SUPPORTED_TAG([$1])dnl
+ m4_append([_LT_TAGS], [$1 ])dnl
+ m4_define([_LT_LANG_]$1[_enabled], [])dnl
+ _LT_LANG_$1_CONFIG($1)])dnl
+])# _LT_LANG
+
+
+m4_ifndef([AC_PROG_GO], [
+############################################################
+# NOTE: This macro has been submitted for inclusion into #
+# GNU Autoconf as AC_PROG_GO. When it is available in #
+# a released version of Autoconf we should remove this #
+# macro and use it instead. #
+############################################################
+m4_defun([AC_PROG_GO],
+[AC_LANG_PUSH(Go)dnl
+AC_ARG_VAR([GOC], [Go compiler command])dnl
+AC_ARG_VAR([GOFLAGS], [Go compiler flags])dnl
+_AC_ARG_VAR_LDFLAGS()dnl
+AC_CHECK_TOOL(GOC, gccgo)
+if test -z "$GOC"; then
+ if test -n "$ac_tool_prefix"; then
+ AC_CHECK_PROG(GOC, [${ac_tool_prefix}gccgo], [${ac_tool_prefix}gccgo])
+ fi
+fi
+if test -z "$GOC"; then
+ AC_CHECK_PROG(GOC, gccgo, gccgo, false)
+fi
+])#m4_defun
+])#m4_ifndef
+
+
+# _LT_LANG_DEFAULT_CONFIG
+# -----------------------
+m4_defun([_LT_LANG_DEFAULT_CONFIG],
+[AC_PROVIDE_IFELSE([AC_PROG_CXX],
+ [LT_LANG(CXX)],
+ [m4_define([AC_PROG_CXX], defn([AC_PROG_CXX])[LT_LANG(CXX)])])
+
+AC_PROVIDE_IFELSE([AC_PROG_F77],
+ [LT_LANG(F77)],
+ [m4_define([AC_PROG_F77], defn([AC_PROG_F77])[LT_LANG(F77)])])
+
+AC_PROVIDE_IFELSE([AC_PROG_FC],
+ [LT_LANG(FC)],
+ [m4_define([AC_PROG_FC], defn([AC_PROG_FC])[LT_LANG(FC)])])
+
+dnl The call to [A][M_PROG_GCJ] is quoted like that to stop aclocal
+dnl pulling things in needlessly.
+AC_PROVIDE_IFELSE([AC_PROG_GCJ],
+ [LT_LANG(GCJ)],
+ [AC_PROVIDE_IFELSE([A][M_PROG_GCJ],
+ [LT_LANG(GCJ)],
+ [AC_PROVIDE_IFELSE([LT_PROG_GCJ],
+ [LT_LANG(GCJ)],
+ [m4_ifdef([AC_PROG_GCJ],
+ [m4_define([AC_PROG_GCJ], defn([AC_PROG_GCJ])[LT_LANG(GCJ)])])
+ m4_ifdef([A][M_PROG_GCJ],
+ [m4_define([A][M_PROG_GCJ], defn([A][M_PROG_GCJ])[LT_LANG(GCJ)])])
+ m4_ifdef([LT_PROG_GCJ],
+ [m4_define([LT_PROG_GCJ], defn([LT_PROG_GCJ])[LT_LANG(GCJ)])])])])])
+
+AC_PROVIDE_IFELSE([AC_PROG_GO],
+ [LT_LANG(GO)],
+ [m4_define([AC_PROG_GO], defn([AC_PROG_GO])[LT_LANG(GO)])])
+
+AC_PROVIDE_IFELSE([LT_PROG_RC],
+ [LT_LANG(RC)],
+ [m4_define([LT_PROG_RC], defn([LT_PROG_RC])[LT_LANG(RC)])])
+])# _LT_LANG_DEFAULT_CONFIG
+
+# Obsolete macros:
+AU_DEFUN([AC_LIBTOOL_CXX], [LT_LANG(C++)])
+AU_DEFUN([AC_LIBTOOL_F77], [LT_LANG(Fortran 77)])
+AU_DEFUN([AC_LIBTOOL_FC], [LT_LANG(Fortran)])
+AU_DEFUN([AC_LIBTOOL_GCJ], [LT_LANG(Java)])
+AU_DEFUN([AC_LIBTOOL_RC], [LT_LANG(Windows Resource)])
+dnl aclocal-1.4 backwards compatibility:
+dnl AC_DEFUN([AC_LIBTOOL_CXX], [])
+dnl AC_DEFUN([AC_LIBTOOL_F77], [])
+dnl AC_DEFUN([AC_LIBTOOL_FC], [])
+dnl AC_DEFUN([AC_LIBTOOL_GCJ], [])
+dnl AC_DEFUN([AC_LIBTOOL_RC], [])
+
+
+# _LT_TAG_COMPILER
+# ----------------
+m4_defun([_LT_TAG_COMPILER],
+[AC_REQUIRE([AC_PROG_CC])dnl
+
+_LT_DECL([LTCC], [CC], [1], [A C compiler])dnl
+_LT_DECL([LTCFLAGS], [CFLAGS], [1], [LTCC compiler flags])dnl
+_LT_TAGDECL([CC], [compiler], [1], [A language specific compiler])dnl
+_LT_TAGDECL([with_gcc], [GCC], [0], [Is the compiler the GNU compiler?])dnl
+
+# If no C compiler was specified, use CC.
+LTCC=${LTCC-"$CC"}
+
+# If no C compiler flags were specified, use CFLAGS.
+LTCFLAGS=${LTCFLAGS-"$CFLAGS"}
+
+# Allow CC to be a program name with arguments.
+compiler=$CC
+])# _LT_TAG_COMPILER
+
+
+# _LT_COMPILER_BOILERPLATE
+# ------------------------
+# Check for compiler boilerplate output or warnings with
+# the simple compiler test code.
+m4_defun([_LT_COMPILER_BOILERPLATE],
+[m4_require([_LT_DECL_SED])dnl
+ac_outfile=conftest.$ac_objext
+echo "$lt_simple_compile_test_code" >conftest.$ac_ext
+eval "$ac_compile" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err
+_lt_compiler_boilerplate=`cat conftest.err`
+$RM conftest*
+])# _LT_COMPILER_BOILERPLATE
+
+
+# _LT_LINKER_BOILERPLATE
+# ----------------------
+# Check for linker boilerplate output or warnings with
+# the simple link test code.
+m4_defun([_LT_LINKER_BOILERPLATE],
+[m4_require([_LT_DECL_SED])dnl
+ac_outfile=conftest.$ac_objext
+echo "$lt_simple_link_test_code" >conftest.$ac_ext
+eval "$ac_link" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err
+_lt_linker_boilerplate=`cat conftest.err`
+$RM -r conftest*
+])# _LT_LINKER_BOILERPLATE
+
+# _LT_REQUIRED_DARWIN_CHECKS
+# -------------------------
+m4_defun_once([_LT_REQUIRED_DARWIN_CHECKS],[
+ case $host_os in
+ rhapsody* | darwin*)
+ AC_CHECK_TOOL([DSYMUTIL], [dsymutil], [:])
+ AC_CHECK_TOOL([NMEDIT], [nmedit], [:])
+ AC_CHECK_TOOL([LIPO], [lipo], [:])
+ AC_CHECK_TOOL([OTOOL], [otool], [:])
+ AC_CHECK_TOOL([OTOOL64], [otool64], [:])
+ _LT_DECL([], [DSYMUTIL], [1],
+ [Tool to manipulate archived DWARF debug symbol files on Mac OS X])
+ _LT_DECL([], [NMEDIT], [1],
+ [Tool to change global to local symbols on Mac OS X])
+ _LT_DECL([], [LIPO], [1],
+ [Tool to manipulate fat objects and archives on Mac OS X])
+ _LT_DECL([], [OTOOL], [1],
+ [ldd/readelf like tool for Mach-O binaries on Mac OS X])
+ _LT_DECL([], [OTOOL64], [1],
+ [ldd/readelf like tool for 64 bit Mach-O binaries on Mac OS X 10.4])
+
+ AC_CACHE_CHECK([for -single_module linker flag],[lt_cv_apple_cc_single_mod],
+ [lt_cv_apple_cc_single_mod=no
+ if test -z "${LT_MULTI_MODULE}"; then
+ # By default we will add the -single_module flag. You can override
+ # by either setting the environment variable LT_MULTI_MODULE
+ # non-empty at configure time, or by adding -multi_module to the
+ # link flags.
+ rm -rf libconftest.dylib*
+ echo "int foo(void){return 1;}" > conftest.c
+ echo "$LTCC $LTCFLAGS $LDFLAGS -o libconftest.dylib \
+-dynamiclib -Wl,-single_module conftest.c" >&AS_MESSAGE_LOG_FD
+ $LTCC $LTCFLAGS $LDFLAGS -o libconftest.dylib \
+ -dynamiclib -Wl,-single_module conftest.c 2>conftest.err
+ _lt_result=$?
+ # If there is a non-empty error log, and "single_module"
+ # appears in it, assume the flag caused a linker warning
+ if test -s conftest.err && $GREP single_module conftest.err; then
+ cat conftest.err >&AS_MESSAGE_LOG_FD
+ # Otherwise, if the output was created with a 0 exit code from
+ # the compiler, it worked.
+ elif test -f libconftest.dylib && test $_lt_result -eq 0; then
+ lt_cv_apple_cc_single_mod=yes
+ else
+ cat conftest.err >&AS_MESSAGE_LOG_FD
+ fi
+ rm -rf libconftest.dylib*
+ rm -f conftest.*
+ fi])
+
+ AC_CACHE_CHECK([for -exported_symbols_list linker flag],
+ [lt_cv_ld_exported_symbols_list],
+ [lt_cv_ld_exported_symbols_list=no
+ save_LDFLAGS=$LDFLAGS
+ echo "_main" > conftest.sym
+ LDFLAGS="$LDFLAGS -Wl,-exported_symbols_list,conftest.sym"
+ AC_LINK_IFELSE([AC_LANG_PROGRAM([],[])],
+ [lt_cv_ld_exported_symbols_list=yes],
+ [lt_cv_ld_exported_symbols_list=no])
+ LDFLAGS="$save_LDFLAGS"
+ ])
+
+ AC_CACHE_CHECK([for -force_load linker flag],[lt_cv_ld_force_load],
+ [lt_cv_ld_force_load=no
+ cat > conftest.c << _LT_EOF
+int forced_loaded() { return 2;}
+_LT_EOF
+ echo "$LTCC $LTCFLAGS -c -o conftest.o conftest.c" >&AS_MESSAGE_LOG_FD
+ $LTCC $LTCFLAGS -c -o conftest.o conftest.c 2>&AS_MESSAGE_LOG_FD
+ echo "$AR cru libconftest.a conftest.o" >&AS_MESSAGE_LOG_FD
+ $AR cru libconftest.a conftest.o 2>&AS_MESSAGE_LOG_FD
+ echo "$RANLIB libconftest.a" >&AS_MESSAGE_LOG_FD
+ $RANLIB libconftest.a 2>&AS_MESSAGE_LOG_FD
+ cat > conftest.c << _LT_EOF
+int main() { return 0;}
+_LT_EOF
+ echo "$LTCC $LTCFLAGS $LDFLAGS -o conftest conftest.c -Wl,-force_load,./libconftest.a" >&AS_MESSAGE_LOG_FD
+ $LTCC $LTCFLAGS $LDFLAGS -o conftest conftest.c -Wl,-force_load,./libconftest.a 2>conftest.err
+ _lt_result=$?
+ if test -s conftest.err && $GREP force_load conftest.err; then
+ cat conftest.err >&AS_MESSAGE_LOG_FD
+ elif test -f conftest && test $_lt_result -eq 0 && $GREP forced_load conftest >/dev/null 2>&1 ; then
+ lt_cv_ld_force_load=yes
+ else
+ cat conftest.err >&AS_MESSAGE_LOG_FD
+ fi
+ rm -f conftest.err libconftest.a conftest conftest.c
+ rm -rf conftest.dSYM
+ ])
+ case $host_os in
+ rhapsody* | darwin1.[[012]])
+ _lt_dar_allow_undefined='${wl}-undefined ${wl}suppress' ;;
+ darwin1.*)
+ _lt_dar_allow_undefined='${wl}-flat_namespace ${wl}-undefined ${wl}suppress' ;;
+ darwin*) # darwin 5.x on
+ # if running on 10.5 or later, the deployment target defaults
+ # to the OS version, if on x86, and 10.4, the deployment
+ # target defaults to 10.4. Don't you love it?
+ case ${MACOSX_DEPLOYMENT_TARGET-10.0},$host in
+ 10.0,*86*-darwin8*|10.0,*-darwin[[91]]*)
+ _lt_dar_allow_undefined='${wl}-undefined ${wl}dynamic_lookup' ;;
+ 10.[[012]]*)
+ _lt_dar_allow_undefined='${wl}-flat_namespace ${wl}-undefined ${wl}suppress' ;;
+ 10.*)
+ _lt_dar_allow_undefined='${wl}-undefined ${wl}dynamic_lookup' ;;
+ esac
+ ;;
+ esac
+ if test "$lt_cv_apple_cc_single_mod" = "yes"; then
+ _lt_dar_single_mod='$single_module'
+ fi
+ if test "$lt_cv_ld_exported_symbols_list" = "yes"; then
+ _lt_dar_export_syms=' ${wl}-exported_symbols_list,$output_objdir/${libname}-symbols.expsym'
+ else
+ _lt_dar_export_syms='~$NMEDIT -s $output_objdir/${libname}-symbols.expsym ${lib}'
+ fi
+ if test "$DSYMUTIL" != ":" && test "$lt_cv_ld_force_load" = "no"; then
+ _lt_dsymutil='~$DSYMUTIL $lib || :'
+ else
+ _lt_dsymutil=
+ fi
+ ;;
+ esac
+])
+
+
+# _LT_DARWIN_LINKER_FEATURES([TAG])
+# ---------------------------------
+# Checks for linker and compiler features on darwin
+m4_defun([_LT_DARWIN_LINKER_FEATURES],
+[
+ m4_require([_LT_REQUIRED_DARWIN_CHECKS])
+ _LT_TAGVAR(archive_cmds_need_lc, $1)=no
+ _LT_TAGVAR(hardcode_direct, $1)=no
+ _LT_TAGVAR(hardcode_automatic, $1)=yes
+ _LT_TAGVAR(hardcode_shlibpath_var, $1)=unsupported
+ if test "$lt_cv_ld_force_load" = "yes"; then
+ _LT_TAGVAR(whole_archive_flag_spec, $1)='`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience ${wl}-force_load,$conv\"; done; func_echo_all \"$new_convenience\"`'
+ m4_case([$1], [F77], [_LT_TAGVAR(compiler_needs_object, $1)=yes],
+ [FC], [_LT_TAGVAR(compiler_needs_object, $1)=yes])
+ else
+ _LT_TAGVAR(whole_archive_flag_spec, $1)=''
+ fi
+ _LT_TAGVAR(link_all_deplibs, $1)=yes
+ _LT_TAGVAR(allow_undefined_flag, $1)="$_lt_dar_allow_undefined"
+ case $cc_basename in
+ ifort*) _lt_dar_can_shared=yes ;;
+ *) _lt_dar_can_shared=$GCC ;;
+ esac
+ if test "$_lt_dar_can_shared" = "yes"; then
+ output_verbose_link_cmd=func_echo_all
+ _LT_TAGVAR(archive_cmds, $1)="\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring $_lt_dar_single_mod${_lt_dsymutil}"
+ _LT_TAGVAR(module_cmds, $1)="\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dsymutil}"
+ _LT_TAGVAR(archive_expsym_cmds, $1)="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring ${_lt_dar_single_mod}${_lt_dar_export_syms}${_lt_dsymutil}"
+ _LT_TAGVAR(module_expsym_cmds, $1)="sed -e 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dar_export_syms}${_lt_dsymutil}"
+ m4_if([$1], [CXX],
+[ if test "$lt_cv_apple_cc_single_mod" != "yes"; then
+ _LT_TAGVAR(archive_cmds, $1)="\$CC -r -keep_private_externs -nostdlib -o \${lib}-master.o \$libobjs~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \${lib}-master.o \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring${_lt_dsymutil}"
+ _LT_TAGVAR(archive_expsym_cmds, $1)="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -r -keep_private_externs -nostdlib -o \${lib}-master.o \$libobjs~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \${lib}-master.o \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring${_lt_dar_export_syms}${_lt_dsymutil}"
+ fi
+],[])
+ else
+ _LT_TAGVAR(ld_shlibs, $1)=no
+ fi
+])
+
+# _LT_SYS_MODULE_PATH_AIX([TAGNAME])
+# ----------------------------------
+# Links a minimal program and checks the executable
+# for the system default hardcoded library path. In most cases,
+# this is /usr/lib:/lib, but when the MPI compilers are used
+# the location of the communication and MPI libs are included too.
+# If we don't find anything, use the default library path according
+# to the aix ld manual.
+# Store the results from the different compilers for each TAGNAME.
+# Allow to override them for all tags through lt_cv_aix_libpath.
+m4_defun([_LT_SYS_MODULE_PATH_AIX],
+[m4_require([_LT_DECL_SED])dnl
+if test "${lt_cv_aix_libpath+set}" = set; then
+ aix_libpath=$lt_cv_aix_libpath
+else
+ AC_CACHE_VAL([_LT_TAGVAR([lt_cv_aix_libpath_], [$1])],
+ [AC_LINK_IFELSE([AC_LANG_PROGRAM],[
+ lt_aix_libpath_sed='[
+ /Import File Strings/,/^$/ {
+ /^0/ {
+ s/^0 *\([^ ]*\) *$/\1/
+ p
+ }
+ }]'
+ _LT_TAGVAR([lt_cv_aix_libpath_], [$1])=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"`
+ # Check for a 64-bit object if we didn't find anything.
+ if test -z "$_LT_TAGVAR([lt_cv_aix_libpath_], [$1])"; then
+ _LT_TAGVAR([lt_cv_aix_libpath_], [$1])=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"`
+ fi],[])
+ if test -z "$_LT_TAGVAR([lt_cv_aix_libpath_], [$1])"; then
+ _LT_TAGVAR([lt_cv_aix_libpath_], [$1])="/usr/lib:/lib"
+ fi
+ ])
+ aix_libpath=$_LT_TAGVAR([lt_cv_aix_libpath_], [$1])
+fi
+])# _LT_SYS_MODULE_PATH_AIX
+
+
+# _LT_SHELL_INIT(ARG)
+# -------------------
+m4_define([_LT_SHELL_INIT],
+[m4_divert_text([M4SH-INIT], [$1
+])])# _LT_SHELL_INIT
+
+
+
+# _LT_PROG_ECHO_BACKSLASH
+# -----------------------
+# Find how we can fake an echo command that does not interpret backslash.
+# In particular, with Autoconf 2.60 or later we add some code to the start
+# of the generated configure script which will find a shell with a builtin
+# printf (which we can use as an echo command).
+m4_defun([_LT_PROG_ECHO_BACKSLASH],
+[ECHO='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\'
+ECHO=$ECHO$ECHO$ECHO$ECHO$ECHO
+ECHO=$ECHO$ECHO$ECHO$ECHO$ECHO$ECHO
+
+AC_MSG_CHECKING([how to print strings])
+# Test print first, because it will be a builtin if present.
+if test "X`( print -r -- -n ) 2>/dev/null`" = X-n && \
+ test "X`print -r -- $ECHO 2>/dev/null`" = "X$ECHO"; then
+ ECHO='print -r --'
+elif test "X`printf %s $ECHO 2>/dev/null`" = "X$ECHO"; then
+ ECHO='printf %s\n'
+else
+ # Use this function as a fallback that always works.
+ func_fallback_echo ()
+ {
+ eval 'cat <<_LTECHO_EOF
+$[]1
+_LTECHO_EOF'
+ }
+ ECHO='func_fallback_echo'
+fi
+
+# func_echo_all arg...
+# Invoke $ECHO with all args, space-separated.
+func_echo_all ()
+{
+ $ECHO "$*"
+}
+
+case "$ECHO" in
+ printf*) AC_MSG_RESULT([printf]) ;;
+ print*) AC_MSG_RESULT([print -r]) ;;
+ *) AC_MSG_RESULT([cat]) ;;
+esac
+
+m4_ifdef([_AS_DETECT_SUGGESTED],
+[_AS_DETECT_SUGGESTED([
+ test -n "${ZSH_VERSION+set}${BASH_VERSION+set}" || (
+ ECHO='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\'
+ ECHO=$ECHO$ECHO$ECHO$ECHO$ECHO
+ ECHO=$ECHO$ECHO$ECHO$ECHO$ECHO$ECHO
+ PATH=/empty FPATH=/empty; export PATH FPATH
+ test "X`printf %s $ECHO`" = "X$ECHO" \
+ || test "X`print -r -- $ECHO`" = "X$ECHO" )])])
+
+_LT_DECL([], [SHELL], [1], [Shell to use when invoking shell scripts])
+_LT_DECL([], [ECHO], [1], [An echo program that protects backslashes])
+])# _LT_PROG_ECHO_BACKSLASH
+
+
+# _LT_WITH_SYSROOT
+# ----------------
+AC_DEFUN([_LT_WITH_SYSROOT],
+[AC_MSG_CHECKING([for sysroot])
+AC_ARG_WITH([sysroot],
+[ --with-sysroot[=DIR] Search for dependent libraries within DIR
+ (or the compiler's sysroot if not specified).],
+[], [with_sysroot=no])
+
+dnl lt_sysroot will always be passed unquoted. We quote it here
+dnl in case the user passed a directory name.
+lt_sysroot=
+case ${with_sysroot} in #(
+ yes)
+ if test "$GCC" = yes; then
+ lt_sysroot=`$CC --print-sysroot 2>/dev/null`
+ fi
+ ;; #(
+ /*)
+ lt_sysroot=`echo "$with_sysroot" | sed -e "$sed_quote_subst"`
+ ;; #(
+ no|'')
+ ;; #(
+ *)
+ AC_MSG_RESULT([${with_sysroot}])
+ AC_MSG_ERROR([The sysroot must be an absolute path.])
+ ;;
+esac
+
+ AC_MSG_RESULT([${lt_sysroot:-no}])
+_LT_DECL([], [lt_sysroot], [0], [The root where to search for ]dnl
+[dependent libraries, and in which our libraries should be installed.])])
+
+# _LT_ENABLE_LOCK
+# ---------------
+m4_defun([_LT_ENABLE_LOCK],
+[AC_ARG_ENABLE([libtool-lock],
+ [AS_HELP_STRING([--disable-libtool-lock],
+ [avoid locking (might break parallel builds)])])
+test "x$enable_libtool_lock" != xno && enable_libtool_lock=yes
+
+# Some flags need to be propagated to the compiler or linker for good
+# libtool support.
+case $host in
+ia64-*-hpux*)
+ # Find out which ABI we are using.
+ echo 'int i;' > conftest.$ac_ext
+ if AC_TRY_EVAL(ac_compile); then
+ case `/usr/bin/file conftest.$ac_objext` in
+ *ELF-32*)
+ HPUX_IA64_MODE="32"
+ ;;
+ *ELF-64*)
+ HPUX_IA64_MODE="64"
+ ;;
+ esac
+ fi
+ rm -rf conftest*
+ ;;
+*-*-irix6*)
+ # Find out which ABI we are using.
+ echo '[#]line '$LINENO' "configure"' > conftest.$ac_ext
+ if AC_TRY_EVAL(ac_compile); then
+ if test "$lt_cv_prog_gnu_ld" = yes; then
+ case `/usr/bin/file conftest.$ac_objext` in
+ *32-bit*)
+ LD="${LD-ld} -melf32bsmip"
+ ;;
+ *N32*)
+ LD="${LD-ld} -melf32bmipn32"
+ ;;
+ *64-bit*)
+ LD="${LD-ld} -melf64bmip"
+ ;;
+ esac
+ else
+ case `/usr/bin/file conftest.$ac_objext` in
+ *32-bit*)
+ LD="${LD-ld} -32"
+ ;;
+ *N32*)
+ LD="${LD-ld} -n32"
+ ;;
+ *64-bit*)
+ LD="${LD-ld} -64"
+ ;;
+ esac
+ fi
+ fi
+ rm -rf conftest*
+ ;;
+
+x86_64-*kfreebsd*-gnu|x86_64-*linux*|ppc*-*linux*|powerpc*-*linux*| \
+s390*-*linux*|s390*-*tpf*|sparc*-*linux*)
+ # Find out which ABI we are using.
+ echo 'int i;' > conftest.$ac_ext
+ if AC_TRY_EVAL(ac_compile); then
+ case `/usr/bin/file conftest.o` in
+ *32-bit*)
+ case $host in
+ x86_64-*kfreebsd*-gnu)
+ LD="${LD-ld} -m elf_i386_fbsd"
+ ;;
+ x86_64-*linux*)
+ LD="${LD-ld} -m elf_i386"
+ ;;
+ ppc64-*linux*|powerpc64-*linux*)
+ LD="${LD-ld} -m elf32ppclinux"
+ ;;
+ s390x-*linux*)
+ LD="${LD-ld} -m elf_s390"
+ ;;
+ sparc64-*linux*)
+ LD="${LD-ld} -m elf32_sparc"
+ ;;
+ esac
+ ;;
+ *64-bit*)
+ case $host in
+ x86_64-*kfreebsd*-gnu)
+ LD="${LD-ld} -m elf_x86_64_fbsd"
+ ;;
+ x86_64-*linux*)
+ LD="${LD-ld} -m elf_x86_64"
+ ;;
+ ppc*-*linux*|powerpc*-*linux*)
+ LD="${LD-ld} -m elf64ppc"
+ ;;
+ s390*-*linux*|s390*-*tpf*)
+ LD="${LD-ld} -m elf64_s390"
+ ;;
+ sparc*-*linux*)
+ LD="${LD-ld} -m elf64_sparc"
+ ;;
+ esac
+ ;;
+ esac
+ fi
+ rm -rf conftest*
+ ;;
+
+*-*-sco3.2v5*)
+ # On SCO OpenServer 5, we need -belf to get full-featured binaries.
+ SAVE_CFLAGS="$CFLAGS"
+ CFLAGS="$CFLAGS -belf"
+ AC_CACHE_CHECK([whether the C compiler needs -belf], lt_cv_cc_needs_belf,
+ [AC_LANG_PUSH(C)
+ AC_LINK_IFELSE([AC_LANG_PROGRAM([[]],[[]])],[lt_cv_cc_needs_belf=yes],[lt_cv_cc_needs_belf=no])
+ AC_LANG_POP])
+ if test x"$lt_cv_cc_needs_belf" != x"yes"; then
+ # this is probably gcc 2.8.0, egcs 1.0 or newer; no need for -belf
+ CFLAGS="$SAVE_CFLAGS"
+ fi
+ ;;
+*-*solaris*)
+ # Find out which ABI we are using.
+ echo 'int i;' > conftest.$ac_ext
+ if AC_TRY_EVAL(ac_compile); then
+ case `/usr/bin/file conftest.o` in
+ *64-bit*)
+ case $lt_cv_prog_gnu_ld in
+ yes*)
+ case $host in
+ i?86-*-solaris*)
+ LD="${LD-ld} -m elf_x86_64"
+ ;;
+ sparc*-*-solaris*)
+ LD="${LD-ld} -m elf64_sparc"
+ ;;
+ esac
+ # GNU ld 2.21 introduced _sol2 emulations. Use them if available.
+ if ${LD-ld} -V | grep _sol2 >/dev/null 2>&1; then
+ LD="${LD-ld}_sol2"
+ fi
+ ;;
+ *)
+ if ${LD-ld} -64 -r -o conftest2.o conftest.o >/dev/null 2>&1; then
+ LD="${LD-ld} -64"
+ fi
+ ;;
+ esac
+ ;;
+ esac
+ fi
+ rm -rf conftest*
+ ;;
+esac
+
+need_locks="$enable_libtool_lock"
+])# _LT_ENABLE_LOCK
+
+
+# _LT_PROG_AR
+# -----------
+m4_defun([_LT_PROG_AR],
+[AC_CHECK_TOOLS(AR, [ar], false)
+: ${AR=ar}
+: ${AR_FLAGS=cru}
+_LT_DECL([], [AR], [1], [The archiver])
+_LT_DECL([], [AR_FLAGS], [1], [Flags to create an archive])
+
+AC_CACHE_CHECK([for archiver @FILE support], [lt_cv_ar_at_file],
+ [lt_cv_ar_at_file=no
+ AC_COMPILE_IFELSE([AC_LANG_PROGRAM],
+ [echo conftest.$ac_objext > conftest.lst
+ lt_ar_try='$AR $AR_FLAGS libconftest.a @conftest.lst >&AS_MESSAGE_LOG_FD'
+ AC_TRY_EVAL([lt_ar_try])
+ if test "$ac_status" -eq 0; then
+ # Ensure the archiver fails upon bogus file names.
+ rm -f conftest.$ac_objext libconftest.a
+ AC_TRY_EVAL([lt_ar_try])
+ if test "$ac_status" -ne 0; then
+ lt_cv_ar_at_file=@
+ fi
+ fi
+ rm -f conftest.* libconftest.a
+ ])
+ ])
+
+if test "x$lt_cv_ar_at_file" = xno; then
+ archiver_list_spec=
+else
+ archiver_list_spec=$lt_cv_ar_at_file
+fi
+_LT_DECL([], [archiver_list_spec], [1],
+ [How to feed a file listing to the archiver])
+])# _LT_PROG_AR
+
+
+# _LT_CMD_OLD_ARCHIVE
+# -------------------
+m4_defun([_LT_CMD_OLD_ARCHIVE],
+[_LT_PROG_AR
+
+AC_CHECK_TOOL(STRIP, strip, :)
+test -z "$STRIP" && STRIP=:
+_LT_DECL([], [STRIP], [1], [A symbol stripping program])
+
+AC_CHECK_TOOL(RANLIB, ranlib, :)
+test -z "$RANLIB" && RANLIB=:
+_LT_DECL([], [RANLIB], [1],
+ [Commands used to install an old-style archive])
+
+# Determine commands to create old-style static archives.
+old_archive_cmds='$AR $AR_FLAGS $oldlib$oldobjs'
+old_postinstall_cmds='chmod 644 $oldlib'
+old_postuninstall_cmds=
+
+if test -n "$RANLIB"; then
+ case $host_os in
+ openbsd*)
+ old_postinstall_cmds="$old_postinstall_cmds~\$RANLIB -t \$tool_oldlib"
+ ;;
+ *)
+ old_postinstall_cmds="$old_postinstall_cmds~\$RANLIB \$tool_oldlib"
+ ;;
+ esac
+ old_archive_cmds="$old_archive_cmds~\$RANLIB \$tool_oldlib"
+fi
+
+case $host_os in
+ darwin*)
+ lock_old_archive_extraction=yes ;;
+ *)
+ lock_old_archive_extraction=no ;;
+esac
+_LT_DECL([], [old_postinstall_cmds], [2])
+_LT_DECL([], [old_postuninstall_cmds], [2])
+_LT_TAGDECL([], [old_archive_cmds], [2],
+ [Commands used to build an old-style archive])
+_LT_DECL([], [lock_old_archive_extraction], [0],
+ [Whether to use a lock for old archive extraction])
+])# _LT_CMD_OLD_ARCHIVE
+
+
+# _LT_COMPILER_OPTION(MESSAGE, VARIABLE-NAME, FLAGS,
+# [OUTPUT-FILE], [ACTION-SUCCESS], [ACTION-FAILURE])
+# ----------------------------------------------------------------
+# Check whether the given compiler option works
+AC_DEFUN([_LT_COMPILER_OPTION],
+[m4_require([_LT_FILEUTILS_DEFAULTS])dnl
+m4_require([_LT_DECL_SED])dnl
+AC_CACHE_CHECK([$1], [$2],
+ [$2=no
+ m4_if([$4], , [ac_outfile=conftest.$ac_objext], [ac_outfile=$4])
+ echo "$lt_simple_compile_test_code" > conftest.$ac_ext
+ lt_compiler_flag="$3"
+ # Insert the option either (1) after the last *FLAGS variable, or
+ # (2) before a word containing "conftest.", or (3) at the end.
+ # Note that $ac_compile itself does not contain backslashes and begins
+ # with a dollar sign (not a hyphen), so the echo should work correctly.
+ # The option is referenced via a variable to avoid confusing sed.
+ lt_compile=`echo "$ac_compile" | $SED \
+ -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
+ -e 's: [[^ ]]*conftest\.: $lt_compiler_flag&:; t' \
+ -e 's:$: $lt_compiler_flag:'`
+ (eval echo "\"\$as_me:$LINENO: $lt_compile\"" >&AS_MESSAGE_LOG_FD)
+ (eval "$lt_compile" 2>conftest.err)
+ ac_status=$?
+ cat conftest.err >&AS_MESSAGE_LOG_FD
+ echo "$as_me:$LINENO: \$? = $ac_status" >&AS_MESSAGE_LOG_FD
+ if (exit $ac_status) && test -s "$ac_outfile"; then
+ # The compiler can only warn and ignore the option if not recognized
+ # So say no if there are warnings other than the usual output.
+ $ECHO "$_lt_compiler_boilerplate" | $SED '/^$/d' >conftest.exp
+ $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2
+ if test ! -s conftest.er2 || diff conftest.exp conftest.er2 >/dev/null; then
+ $2=yes
+ fi
+ fi
+ $RM conftest*
+])
+
+if test x"[$]$2" = xyes; then
+ m4_if([$5], , :, [$5])
+else
+ m4_if([$6], , :, [$6])
+fi
+])# _LT_COMPILER_OPTION
+
+# Old name:
+AU_ALIAS([AC_LIBTOOL_COMPILER_OPTION], [_LT_COMPILER_OPTION])
+dnl aclocal-1.4 backwards compatibility:
+dnl AC_DEFUN([AC_LIBTOOL_COMPILER_OPTION], [])
+
+
+# _LT_LINKER_OPTION(MESSAGE, VARIABLE-NAME, FLAGS,
+# [ACTION-SUCCESS], [ACTION-FAILURE])
+# ----------------------------------------------------
+# Check whether the given linker option works
+AC_DEFUN([_LT_LINKER_OPTION],
+[m4_require([_LT_FILEUTILS_DEFAULTS])dnl
+m4_require([_LT_DECL_SED])dnl
+AC_CACHE_CHECK([$1], [$2],
+ [$2=no
+ save_LDFLAGS="$LDFLAGS"
+ LDFLAGS="$LDFLAGS $3"
+ echo "$lt_simple_link_test_code" > conftest.$ac_ext
+ if (eval $ac_link 2>conftest.err) && test -s conftest$ac_exeext; then
+ # The linker can only warn and ignore the option if not recognized
+ # So say no if there are warnings
+ if test -s conftest.err; then
+ # Append any errors to the config.log.
+ cat conftest.err 1>&AS_MESSAGE_LOG_FD
+ $ECHO "$_lt_linker_boilerplate" | $SED '/^$/d' > conftest.exp
+ $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2
+ if diff conftest.exp conftest.er2 >/dev/null; then
+ $2=yes
+ fi
+ else
+ $2=yes
+ fi
+ fi
+ $RM -r conftest*
+ LDFLAGS="$save_LDFLAGS"
+])
+
+if test x"[$]$2" = xyes; then
+ m4_if([$4], , :, [$4])
+else
+ m4_if([$5], , :, [$5])
+fi
+])# _LT_LINKER_OPTION
+
+# Old name:
+AU_ALIAS([AC_LIBTOOL_LINKER_OPTION], [_LT_LINKER_OPTION])
+dnl aclocal-1.4 backwards compatibility:
+dnl AC_DEFUN([AC_LIBTOOL_LINKER_OPTION], [])
+
+
+# LT_CMD_MAX_LEN
+#---------------
+AC_DEFUN([LT_CMD_MAX_LEN],
+[AC_REQUIRE([AC_CANONICAL_HOST])dnl
+# find the maximum length of command line arguments
+AC_MSG_CHECKING([the maximum length of command line arguments])
+AC_CACHE_VAL([lt_cv_sys_max_cmd_len], [dnl
+ i=0
+ teststring="ABCD"
+
+ case $build_os in
+ msdosdjgpp*)
+ # On DJGPP, this test can blow up pretty badly due to problems in libc
+ # (any single argument exceeding 2000 bytes causes a buffer overrun
+ # during glob expansion). Even if it were fixed, the result of this
+ # check would be larger than it should be.
+ lt_cv_sys_max_cmd_len=12288; # 12K is about right
+ ;;
+
+ gnu*)
+ # Under GNU Hurd, this test is not required because there is
+ # no limit to the length of command line arguments.
+ # Libtool will interpret -1 as no limit whatsoever
+ lt_cv_sys_max_cmd_len=-1;
+ ;;
+
+ cygwin* | mingw* | cegcc*)
+ # On Win9x/ME, this test blows up -- it succeeds, but takes
+ # about 5 minutes as the teststring grows exponentially.
+ # Worse, since 9x/ME are not pre-emptively multitasking,
+ # you end up with a "frozen" computer, even though with patience
+ # the test eventually succeeds (with a max line length of 256k).
+ # Instead, let's just punt: use the minimum linelength reported by
+ # all of the supported platforms: 8192 (on NT/2K/XP).
+ lt_cv_sys_max_cmd_len=8192;
+ ;;
+
+ mint*)
+ # On MiNT this can take a long time and run out of memory.
+ lt_cv_sys_max_cmd_len=8192;
+ ;;
+
+ amigaos*)
+ # On AmigaOS with pdksh, this test takes hours, literally.
+ # So we just punt and use a minimum line length of 8192.
+ lt_cv_sys_max_cmd_len=8192;
+ ;;
+
+ netbsd* | freebsd* | openbsd* | darwin* | dragonfly*)
+ # This has been around since 386BSD, at least. Likely further.
+ if test -x /sbin/sysctl; then
+ lt_cv_sys_max_cmd_len=`/sbin/sysctl -n kern.argmax`
+ elif test -x /usr/sbin/sysctl; then
+ lt_cv_sys_max_cmd_len=`/usr/sbin/sysctl -n kern.argmax`
+ else
+ lt_cv_sys_max_cmd_len=65536 # usable default for all BSDs
+ fi
+ # And add a safety zone
+ lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 4`
+ lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \* 3`
+ ;;
+
+ interix*)
+ # We know the value 262144 and hardcode it with a safety zone (like BSD)
+ lt_cv_sys_max_cmd_len=196608
+ ;;
+
+ os2*)
+ # The test takes a long time on OS/2.
+ lt_cv_sys_max_cmd_len=8192
+ ;;
+
+ osf*)
+ # Dr. Hans Ekkehard Plesser reports seeing a kernel panic running configure
+ # due to this test when exec_disable_arg_limit is 1 on Tru64. It is not
+ # nice to cause kernel panics so lets avoid the loop below.
+ # First set a reasonable default.
+ lt_cv_sys_max_cmd_len=16384
+ #
+ if test -x /sbin/sysconfig; then
+ case `/sbin/sysconfig -q proc exec_disable_arg_limit` in
+ *1*) lt_cv_sys_max_cmd_len=-1 ;;
+ esac
+ fi
+ ;;
+ sco3.2v5*)
+ lt_cv_sys_max_cmd_len=102400
+ ;;
+ sysv5* | sco5v6* | sysv4.2uw2*)
+ kargmax=`grep ARG_MAX /etc/conf/cf.d/stune 2>/dev/null`
+ if test -n "$kargmax"; then
+ lt_cv_sys_max_cmd_len=`echo $kargmax | sed 's/.*[[ ]]//'`
+ else
+ lt_cv_sys_max_cmd_len=32768
+ fi
+ ;;
+ *)
+ lt_cv_sys_max_cmd_len=`(getconf ARG_MAX) 2> /dev/null`
+ if test -n "$lt_cv_sys_max_cmd_len"; then
+ lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 4`
+ lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \* 3`
+ else
+ # Make teststring a little bigger before we do anything with it.
+ # a 1K string should be a reasonable start.
+ for i in 1 2 3 4 5 6 7 8 ; do
+ teststring=$teststring$teststring
+ done
+ SHELL=${SHELL-${CONFIG_SHELL-/bin/sh}}
+ # If test is not a shell built-in, we'll probably end up computing a
+ # maximum length that is only half of the actual maximum length, but
+ # we can't tell.
+ while { test "X"`env echo "$teststring$teststring" 2>/dev/null` \
+ = "X$teststring$teststring"; } >/dev/null 2>&1 &&
+ test $i != 17 # 1/2 MB should be enough
+ do
+ i=`expr $i + 1`
+ teststring=$teststring$teststring
+ done
+ # Only check the string length outside the loop.
+ lt_cv_sys_max_cmd_len=`expr "X$teststring" : ".*" 2>&1`
+ teststring=
+ # Add a significant safety factor because C++ compilers can tack on
+ # massive amounts of additional arguments before passing them to the
+ # linker. It appears as though 1/2 is a usable value.
+ lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 2`
+ fi
+ ;;
+ esac
+])
+if test -n $lt_cv_sys_max_cmd_len ; then
+ AC_MSG_RESULT($lt_cv_sys_max_cmd_len)
+else
+ AC_MSG_RESULT(none)
+fi
+max_cmd_len=$lt_cv_sys_max_cmd_len
+_LT_DECL([], [max_cmd_len], [0],
+ [What is the maximum length of a command?])
+])# LT_CMD_MAX_LEN
+
+# Old name:
+AU_ALIAS([AC_LIBTOOL_SYS_MAX_CMD_LEN], [LT_CMD_MAX_LEN])
+dnl aclocal-1.4 backwards compatibility:
+dnl AC_DEFUN([AC_LIBTOOL_SYS_MAX_CMD_LEN], [])
+
+
+# _LT_HEADER_DLFCN
+# ----------------
+m4_defun([_LT_HEADER_DLFCN],
+[AC_CHECK_HEADERS([dlfcn.h], [], [], [AC_INCLUDES_DEFAULT])dnl
+])# _LT_HEADER_DLFCN
+
+
+# _LT_TRY_DLOPEN_SELF (ACTION-IF-TRUE, ACTION-IF-TRUE-W-USCORE,
+# ACTION-IF-FALSE, ACTION-IF-CROSS-COMPILING)
+# ----------------------------------------------------------------
+m4_defun([_LT_TRY_DLOPEN_SELF],
+[m4_require([_LT_HEADER_DLFCN])dnl
+if test "$cross_compiling" = yes; then :
+ [$4]
+else
+ lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
+ lt_status=$lt_dlunknown
+ cat > conftest.$ac_ext <<_LT_EOF
+[#line $LINENO "configure"
+#include "confdefs.h"
+
+#if HAVE_DLFCN_H
+#include <dlfcn.h>
+#endif
+
+#include <stdio.h>
+
+#ifdef RTLD_GLOBAL
+# define LT_DLGLOBAL RTLD_GLOBAL
+#else
+# ifdef DL_GLOBAL
+# define LT_DLGLOBAL DL_GLOBAL
+# else
+# define LT_DLGLOBAL 0
+# endif
+#endif
+
+/* We may have to define LT_DLLAZY_OR_NOW in the command line if we
+ find out it does not work in some platform. */
+#ifndef LT_DLLAZY_OR_NOW
+# ifdef RTLD_LAZY
+# define LT_DLLAZY_OR_NOW RTLD_LAZY
+# else
+# ifdef DL_LAZY
+# define LT_DLLAZY_OR_NOW DL_LAZY
+# else
+# ifdef RTLD_NOW
+# define LT_DLLAZY_OR_NOW RTLD_NOW
+# else
+# ifdef DL_NOW
+# define LT_DLLAZY_OR_NOW DL_NOW
+# else
+# define LT_DLLAZY_OR_NOW 0
+# endif
+# endif
+# endif
+# endif
+#endif
+
+/* When -fvisbility=hidden is used, assume the code has been annotated
+ correspondingly for the symbols needed. */
+#if defined(__GNUC__) && (((__GNUC__ == 3) && (__GNUC_MINOR__ >= 3)) || (__GNUC__ > 3))
+int fnord () __attribute__((visibility("default")));
+#endif
+
+int fnord () { return 42; }
+int main ()
+{
+ void *self = dlopen (0, LT_DLGLOBAL|LT_DLLAZY_OR_NOW);
+ int status = $lt_dlunknown;
+
+ if (self)
+ {
+ if (dlsym (self,"fnord")) status = $lt_dlno_uscore;
+ else
+ {
+ if (dlsym( self,"_fnord")) status = $lt_dlneed_uscore;
+ else puts (dlerror ());
+ }
+ /* dlclose (self); */
+ }
+ else
+ puts (dlerror ());
+
+ return status;
+}]
+_LT_EOF
+ if AC_TRY_EVAL(ac_link) && test -s conftest${ac_exeext} 2>/dev/null; then
+ (./conftest; exit; ) >&AS_MESSAGE_LOG_FD 2>/dev/null
+ lt_status=$?
+ case x$lt_status in
+ x$lt_dlno_uscore) $1 ;;
+ x$lt_dlneed_uscore) $2 ;;
+ x$lt_dlunknown|x*) $3 ;;
+ esac
+ else :
+ # compilation failed
+ $3
+ fi
+fi
+rm -fr conftest*
+])# _LT_TRY_DLOPEN_SELF
+
+
+# LT_SYS_DLOPEN_SELF
+# ------------------
+AC_DEFUN([LT_SYS_DLOPEN_SELF],
+[m4_require([_LT_HEADER_DLFCN])dnl
+if test "x$enable_dlopen" != xyes; then
+ enable_dlopen=unknown
+ enable_dlopen_self=unknown
+ enable_dlopen_self_static=unknown
+else
+ lt_cv_dlopen=no
+ lt_cv_dlopen_libs=
+
+ case $host_os in
+ beos*)
+ lt_cv_dlopen="load_add_on"
+ lt_cv_dlopen_libs=
+ lt_cv_dlopen_self=yes
+ ;;
+
+ mingw* | pw32* | cegcc*)
+ lt_cv_dlopen="LoadLibrary"
+ lt_cv_dlopen_libs=
+ ;;
+
+ cygwin*)
+ lt_cv_dlopen="dlopen"
+ lt_cv_dlopen_libs=
+ ;;
+
+ darwin*)
+ # if libdl is installed we need to link against it
+ AC_CHECK_LIB([dl], [dlopen],
+ [lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-ldl"],[
+ lt_cv_dlopen="dyld"
+ lt_cv_dlopen_libs=
+ lt_cv_dlopen_self=yes
+ ])
+ ;;
+
+ *)
+ AC_CHECK_FUNC([shl_load],
+ [lt_cv_dlopen="shl_load"],
+ [AC_CHECK_LIB([dld], [shl_load],
+ [lt_cv_dlopen="shl_load" lt_cv_dlopen_libs="-ldld"],
+ [AC_CHECK_FUNC([dlopen],
+ [lt_cv_dlopen="dlopen"],
+ [AC_CHECK_LIB([dl], [dlopen],
+ [lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-ldl"],
+ [AC_CHECK_LIB([svld], [dlopen],
+ [lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-lsvld"],
+ [AC_CHECK_LIB([dld], [dld_link],
+ [lt_cv_dlopen="dld_link" lt_cv_dlopen_libs="-ldld"])
+ ])
+ ])
+ ])
+ ])
+ ])
+ ;;
+ esac
+
+ if test "x$lt_cv_dlopen" != xno; then
+ enable_dlopen=yes
+ else
+ enable_dlopen=no
+ fi
+
+ case $lt_cv_dlopen in
+ dlopen)
+ save_CPPFLAGS="$CPPFLAGS"
+ test "x$ac_cv_header_dlfcn_h" = xyes && CPPFLAGS="$CPPFLAGS -DHAVE_DLFCN_H"
+
+ save_LDFLAGS="$LDFLAGS"
+ wl=$lt_prog_compiler_wl eval LDFLAGS=\"\$LDFLAGS $export_dynamic_flag_spec\"
+
+ save_LIBS="$LIBS"
+ LIBS="$lt_cv_dlopen_libs $LIBS"
+
+ AC_CACHE_CHECK([whether a program can dlopen itself],
+ lt_cv_dlopen_self, [dnl
+ _LT_TRY_DLOPEN_SELF(
+ lt_cv_dlopen_self=yes, lt_cv_dlopen_self=yes,
+ lt_cv_dlopen_self=no, lt_cv_dlopen_self=cross)
+ ])
+
+ if test "x$lt_cv_dlopen_self" = xyes; then
+ wl=$lt_prog_compiler_wl eval LDFLAGS=\"\$LDFLAGS $lt_prog_compiler_static\"
+ AC_CACHE_CHECK([whether a statically linked program can dlopen itself],
+ lt_cv_dlopen_self_static, [dnl
+ _LT_TRY_DLOPEN_SELF(
+ lt_cv_dlopen_self_static=yes, lt_cv_dlopen_self_static=yes,
+ lt_cv_dlopen_self_static=no, lt_cv_dlopen_self_static=cross)
+ ])
+ fi
+
+ CPPFLAGS="$save_CPPFLAGS"
+ LDFLAGS="$save_LDFLAGS"
+ LIBS="$save_LIBS"
+ ;;
+ esac
+
+ case $lt_cv_dlopen_self in
+ yes|no) enable_dlopen_self=$lt_cv_dlopen_self ;;
+ *) enable_dlopen_self=unknown ;;
+ esac
+
+ case $lt_cv_dlopen_self_static in
+ yes|no) enable_dlopen_self_static=$lt_cv_dlopen_self_static ;;
+ *) enable_dlopen_self_static=unknown ;;
+ esac
+fi
+_LT_DECL([dlopen_support], [enable_dlopen], [0],
+ [Whether dlopen is supported])
+_LT_DECL([dlopen_self], [enable_dlopen_self], [0],
+ [Whether dlopen of programs is supported])
+_LT_DECL([dlopen_self_static], [enable_dlopen_self_static], [0],
+ [Whether dlopen of statically linked programs is supported])
+])# LT_SYS_DLOPEN_SELF
+
+# Old name:
+AU_ALIAS([AC_LIBTOOL_DLOPEN_SELF], [LT_SYS_DLOPEN_SELF])
+dnl aclocal-1.4 backwards compatibility:
+dnl AC_DEFUN([AC_LIBTOOL_DLOPEN_SELF], [])
+
+
+# _LT_COMPILER_C_O([TAGNAME])
+# ---------------------------
+# Check to see if options -c and -o are simultaneously supported by compiler.
+# This macro does not hard code the compiler like AC_PROG_CC_C_O.
+m4_defun([_LT_COMPILER_C_O],
+[m4_require([_LT_DECL_SED])dnl
+m4_require([_LT_FILEUTILS_DEFAULTS])dnl
+m4_require([_LT_TAG_COMPILER])dnl
+AC_CACHE_CHECK([if $compiler supports -c -o file.$ac_objext],
+ [_LT_TAGVAR(lt_cv_prog_compiler_c_o, $1)],
+ [_LT_TAGVAR(lt_cv_prog_compiler_c_o, $1)=no
+ $RM -r conftest 2>/dev/null
+ mkdir conftest
+ cd conftest
+ mkdir out
+ echo "$lt_simple_compile_test_code" > conftest.$ac_ext
+
+ lt_compiler_flag="-o out/conftest2.$ac_objext"
+ # Insert the option either (1) after the last *FLAGS variable, or
+ # (2) before a word containing "conftest.", or (3) at the end.
+ # Note that $ac_compile itself does not contain backslashes and begins
+ # with a dollar sign (not a hyphen), so the echo should work correctly.
+ lt_compile=`echo "$ac_compile" | $SED \
+ -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
+ -e 's: [[^ ]]*conftest\.: $lt_compiler_flag&:; t' \
+ -e 's:$: $lt_compiler_flag:'`
+ (eval echo "\"\$as_me:$LINENO: $lt_compile\"" >&AS_MESSAGE_LOG_FD)
+ (eval "$lt_compile" 2>out/conftest.err)
+ ac_status=$?
+ cat out/conftest.err >&AS_MESSAGE_LOG_FD
+ echo "$as_me:$LINENO: \$? = $ac_status" >&AS_MESSAGE_LOG_FD
+ if (exit $ac_status) && test -s out/conftest2.$ac_objext
+ then
+ # The compiler can only warn and ignore the option if not recognized
+ # So say no if there are warnings
+ $ECHO "$_lt_compiler_boilerplate" | $SED '/^$/d' > out/conftest.exp
+ $SED '/^$/d; /^ *+/d' out/conftest.err >out/conftest.er2
+ if test ! -s out/conftest.er2 || diff out/conftest.exp out/conftest.er2 >/dev/null; then
+ _LT_TAGVAR(lt_cv_prog_compiler_c_o, $1)=yes
+ fi
+ fi
+ chmod u+w . 2>&AS_MESSAGE_LOG_FD
+ $RM conftest*
+ # SGI C++ compiler will create directory out/ii_files/ for
+ # template instantiation
+ test -d out/ii_files && $RM out/ii_files/* && rmdir out/ii_files
+ $RM out/* && rmdir out
+ cd ..
+ $RM -r conftest
+ $RM conftest*
+])
+_LT_TAGDECL([compiler_c_o], [lt_cv_prog_compiler_c_o], [1],
+ [Does compiler simultaneously support -c and -o options?])
+])# _LT_COMPILER_C_O
+
+
+# _LT_COMPILER_FILE_LOCKS([TAGNAME])
+# ----------------------------------
+# Check to see if we can do hard links to lock some files if needed
+m4_defun([_LT_COMPILER_FILE_LOCKS],
+[m4_require([_LT_ENABLE_LOCK])dnl
+m4_require([_LT_FILEUTILS_DEFAULTS])dnl
+_LT_COMPILER_C_O([$1])
+
+hard_links="nottested"
+if test "$_LT_TAGVAR(lt_cv_prog_compiler_c_o, $1)" = no && test "$need_locks" != no; then
+ # do not overwrite the value of need_locks provided by the user
+ AC_MSG_CHECKING([if we can lock with hard links])
+ hard_links=yes
+ $RM conftest*
+ ln conftest.a conftest.b 2>/dev/null && hard_links=no
+ touch conftest.a
+ ln conftest.a conftest.b 2>&5 || hard_links=no
+ ln conftest.a conftest.b 2>/dev/null && hard_links=no
+ AC_MSG_RESULT([$hard_links])
+ if test "$hard_links" = no; then
+ AC_MSG_WARN([`$CC' does not support `-c -o', so `make -j' may be unsafe])
+ need_locks=warn
+ fi
+else
+ need_locks=no
+fi
+_LT_DECL([], [need_locks], [1], [Must we lock files when doing compilation?])
+])# _LT_COMPILER_FILE_LOCKS
+
+
+# _LT_CHECK_OBJDIR
+# ----------------
+m4_defun([_LT_CHECK_OBJDIR],
+[AC_CACHE_CHECK([for objdir], [lt_cv_objdir],
+[rm -f .libs 2>/dev/null
+mkdir .libs 2>/dev/null
+if test -d .libs; then
+ lt_cv_objdir=.libs
+else
+ # MS-DOS does not allow filenames that begin with a dot.
+ lt_cv_objdir=_libs
+fi
+rmdir .libs 2>/dev/null])
+objdir=$lt_cv_objdir
+_LT_DECL([], [objdir], [0],
+ [The name of the directory that contains temporary libtool files])dnl
+m4_pattern_allow([LT_OBJDIR])dnl
+AC_DEFINE_UNQUOTED(LT_OBJDIR, "$lt_cv_objdir/",
+ [Define to the sub-directory in which libtool stores uninstalled libraries.])
+])# _LT_CHECK_OBJDIR
+
+
+# _LT_LINKER_HARDCODE_LIBPATH([TAGNAME])
+# --------------------------------------
+# Check hardcoding attributes.
+m4_defun([_LT_LINKER_HARDCODE_LIBPATH],
+[AC_MSG_CHECKING([how to hardcode library paths into programs])
+_LT_TAGVAR(hardcode_action, $1)=
+if test -n "$_LT_TAGVAR(hardcode_libdir_flag_spec, $1)" ||
+ test -n "$_LT_TAGVAR(runpath_var, $1)" ||
+ test "X$_LT_TAGVAR(hardcode_automatic, $1)" = "Xyes" ; then
+
+ # We can hardcode non-existent directories.
+ if test "$_LT_TAGVAR(hardcode_direct, $1)" != no &&
+ # If the only mechanism to avoid hardcoding is shlibpath_var, we
+ # have to relink, otherwise we might link with an installed library
+ # when we should be linking with a yet-to-be-installed one
+ ## test "$_LT_TAGVAR(hardcode_shlibpath_var, $1)" != no &&
+ test "$_LT_TAGVAR(hardcode_minus_L, $1)" != no; then
+ # Linking always hardcodes the temporary library directory.
+ _LT_TAGVAR(hardcode_action, $1)=relink
+ else
+ # We can link without hardcoding, and we can hardcode nonexisting dirs.
+ _LT_TAGVAR(hardcode_action, $1)=immediate
+ fi
+else
+ # We cannot hardcode anything, or else we can only hardcode existing
+ # directories.
+ _LT_TAGVAR(hardcode_action, $1)=unsupported
+fi
+AC_MSG_RESULT([$_LT_TAGVAR(hardcode_action, $1)])
+
+if test "$_LT_TAGVAR(hardcode_action, $1)" = relink ||
+ test "$_LT_TAGVAR(inherit_rpath, $1)" = yes; then
+ # Fast installation is not supported
+ enable_fast_install=no
+elif test "$shlibpath_overrides_runpath" = yes ||
+ test "$enable_shared" = no; then
+ # Fast installation is not necessary
+ enable_fast_install=needless
+fi
+_LT_TAGDECL([], [hardcode_action], [0],
+ [How to hardcode a shared library path into an executable])
+])# _LT_LINKER_HARDCODE_LIBPATH
+
+
+# _LT_CMD_STRIPLIB
+# ----------------
+m4_defun([_LT_CMD_STRIPLIB],
+[m4_require([_LT_DECL_EGREP])
+striplib=
+old_striplib=
+AC_MSG_CHECKING([whether stripping libraries is possible])
+if test -n "$STRIP" && $STRIP -V 2>&1 | $GREP "GNU strip" >/dev/null; then
+ test -z "$old_striplib" && old_striplib="$STRIP --strip-debug"
+ test -z "$striplib" && striplib="$STRIP --strip-unneeded"
+ AC_MSG_RESULT([yes])
+else
+# FIXME - insert some real tests, host_os isn't really good enough
+ case $host_os in
+ darwin*)
+ if test -n "$STRIP" ; then
+ striplib="$STRIP -x"
+ old_striplib="$STRIP -S"
+ AC_MSG_RESULT([yes])
+ else
+ AC_MSG_RESULT([no])
+ fi
+ ;;
+ *)
+ AC_MSG_RESULT([no])
+ ;;
+ esac
+fi
+_LT_DECL([], [old_striplib], [1], [Commands to strip libraries])
+_LT_DECL([], [striplib], [1])
+])# _LT_CMD_STRIPLIB
+
+
+# _LT_SYS_DYNAMIC_LINKER([TAG])
+# -----------------------------
+# PORTME Fill in your ld.so characteristics
+m4_defun([_LT_SYS_DYNAMIC_LINKER],
+[AC_REQUIRE([AC_CANONICAL_HOST])dnl
+m4_require([_LT_DECL_EGREP])dnl
+m4_require([_LT_FILEUTILS_DEFAULTS])dnl
+m4_require([_LT_DECL_OBJDUMP])dnl
+m4_require([_LT_DECL_SED])dnl
+m4_require([_LT_CHECK_SHELL_FEATURES])dnl
+AC_MSG_CHECKING([dynamic linker characteristics])
+m4_if([$1],
+ [], [
+if test "$GCC" = yes; then
+ case $host_os in
+ darwin*) lt_awk_arg="/^libraries:/,/LR/" ;;
+ *) lt_awk_arg="/^libraries:/" ;;
+ esac
+ case $host_os in
+ mingw* | cegcc*) lt_sed_strip_eq="s,=\([[A-Za-z]]:\),\1,g" ;;
+ *) lt_sed_strip_eq="s,=/,/,g" ;;
+ esac
+ lt_search_path_spec=`$CC -print-search-dirs | awk $lt_awk_arg | $SED -e "s/^libraries://" -e $lt_sed_strip_eq`
+ case $lt_search_path_spec in
+ *\;*)
+ # if the path contains ";" then we assume it to be the separator
+ # otherwise default to the standard path separator (i.e. ":") - it is
+ # assumed that no part of a normal pathname contains ";" but that should
+ # okay in the real world where ";" in dirpaths is itself problematic.
+ lt_search_path_spec=`$ECHO "$lt_search_path_spec" | $SED 's/;/ /g'`
+ ;;
+ *)
+ lt_search_path_spec=`$ECHO "$lt_search_path_spec" | $SED "s/$PATH_SEPARATOR/ /g"`
+ ;;
+ esac
+ # Ok, now we have the path, separated by spaces, we can step through it
+ # and add multilib dir if necessary.
+ lt_tmp_lt_search_path_spec=
+ lt_multi_os_dir=`$CC $CPPFLAGS $CFLAGS $LDFLAGS -print-multi-os-directory 2>/dev/null`
+ for lt_sys_path in $lt_search_path_spec; do
+ if test -d "$lt_sys_path/$lt_multi_os_dir"; then
+ lt_tmp_lt_search_path_spec="$lt_tmp_lt_search_path_spec $lt_sys_path/$lt_multi_os_dir"
+ else
+ test -d "$lt_sys_path" && \
+ lt_tmp_lt_search_path_spec="$lt_tmp_lt_search_path_spec $lt_sys_path"
+ fi
+ done
+ lt_search_path_spec=`$ECHO "$lt_tmp_lt_search_path_spec" | awk '
+BEGIN {RS=" "; FS="/|\n";} {
+ lt_foo="";
+ lt_count=0;
+ for (lt_i = NF; lt_i > 0; lt_i--) {
+ if ($lt_i != "" && $lt_i != ".") {
+ if ($lt_i == "..") {
+ lt_count++;
+ } else {
+ if (lt_count == 0) {
+ lt_foo="/" $lt_i lt_foo;
+ } else {
+ lt_count--;
+ }
+ }
+ }
+ }
+ if (lt_foo != "") { lt_freq[[lt_foo]]++; }
+ if (lt_freq[[lt_foo]] == 1) { print lt_foo; }
+}'`
+ # AWK program above erroneously prepends '/' to C:/dos/paths
+ # for these hosts.
+ case $host_os in
+ mingw* | cegcc*) lt_search_path_spec=`$ECHO "$lt_search_path_spec" |\
+ $SED 's,/\([[A-Za-z]]:\),\1,g'` ;;
+ esac
+ sys_lib_search_path_spec=`$ECHO "$lt_search_path_spec" | $lt_NL2SP`
+else
+ sys_lib_search_path_spec="/lib /usr/lib /usr/local/lib"
+fi])
+library_names_spec=
+libname_spec='lib$name'
+soname_spec=
+shrext_cmds=".so"
+postinstall_cmds=
+postuninstall_cmds=
+finish_cmds=
+finish_eval=
+shlibpath_var=
+shlibpath_overrides_runpath=unknown
+version_type=none
+dynamic_linker="$host_os ld.so"
+sys_lib_dlsearch_path_spec="/lib /usr/lib"
+need_lib_prefix=unknown
+hardcode_into_libs=no
+
+# when you set need_version to no, make sure it does not cause -set_version
+# flags to be left without arguments
+need_version=unknown
+
+case $host_os in
+aix3*)
+ version_type=linux # correct to gnu/linux during the next big refactor
+ library_names_spec='${libname}${release}${shared_ext}$versuffix $libname.a'
+ shlibpath_var=LIBPATH
+
+ # AIX 3 has no versioning support, so we append a major version to the name.
+ soname_spec='${libname}${release}${shared_ext}$major'
+ ;;
+
+aix[[4-9]]*)
+ version_type=linux # correct to gnu/linux during the next big refactor
+ need_lib_prefix=no
+ need_version=no
+ hardcode_into_libs=yes
+ if test "$host_cpu" = ia64; then
+ # AIX 5 supports IA64
+ library_names_spec='${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext}$versuffix $libname${shared_ext}'
+ shlibpath_var=LD_LIBRARY_PATH
+ else
+ # With GCC up to 2.95.x, collect2 would create an import file
+ # for dependence libraries. The import file would start with
+ # the line `#! .'. This would cause the generated library to
+ # depend on `.', always an invalid library. This was fixed in
+ # development snapshots of GCC prior to 3.0.
+ case $host_os in
+ aix4 | aix4.[[01]] | aix4.[[01]].*)
+ if { echo '#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 97)'
+ echo ' yes '
+ echo '#endif'; } | ${CC} -E - | $GREP yes > /dev/null; then
+ :
+ else
+ can_build_shared=no
+ fi
+ ;;
+ esac
+ # AIX (on Power*) has no versioning support, so currently we can not hardcode correct
+ # soname into executable. Probably we can add versioning support to
+ # collect2, so additional links can be useful in future.
+ if test "$aix_use_runtimelinking" = yes; then
+ # If using run time linking (on AIX 4.2 or later) use lib<name>.so
+ # instead of lib<name>.a to let people know that these are not
+ # typical AIX shared libraries.
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+ else
+ # We preserve .a as extension for shared libraries through AIX4.2
+ # and later when we are not doing run time linking.
+ library_names_spec='${libname}${release}.a $libname.a'
+ soname_spec='${libname}${release}${shared_ext}$major'
+ fi
+ shlibpath_var=LIBPATH
+ fi
+ ;;
+
+amigaos*)
+ case $host_cpu in
+ powerpc)
+ # Since July 2007 AmigaOS4 officially supports .so libraries.
+ # When compiling the executable, add -use-dynld -Lsobjs: to the compileline.
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+ ;;
+ m68k)
+ library_names_spec='$libname.ixlibrary $libname.a'
+ # Create ${libname}_ixlibrary.a entries in /sys/libs.
+ finish_eval='for lib in `ls $libdir/*.ixlibrary 2>/dev/null`; do libname=`func_echo_all "$lib" | $SED '\''s%^.*/\([[^/]]*\)\.ixlibrary$%\1%'\''`; test $RM /sys/libs/${libname}_ixlibrary.a; $show "cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a"; cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a || exit 1; done'
+ ;;
+ esac
+ ;;
+
+beos*)
+ library_names_spec='${libname}${shared_ext}'
+ dynamic_linker="$host_os ld.so"
+ shlibpath_var=LIBRARY_PATH
+ ;;
+
+bsdi[[45]]*)
+ version_type=linux # correct to gnu/linux during the next big refactor
+ need_version=no
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+ soname_spec='${libname}${release}${shared_ext}$major'
+ finish_cmds='PATH="\$PATH:/sbin" ldconfig $libdir'
+ shlibpath_var=LD_LIBRARY_PATH
+ sys_lib_search_path_spec="/shlib /usr/lib /usr/X11/lib /usr/contrib/lib /lib /usr/local/lib"
+ sys_lib_dlsearch_path_spec="/shlib /usr/lib /usr/local/lib"
+ # the default ld.so.conf also contains /usr/contrib/lib and
+ # /usr/X11R6/lib (/usr/X11 is a link to /usr/X11R6), but let us allow
+ # libtool to hard-code these into programs
+ ;;
+
+cygwin* | mingw* | pw32* | cegcc*)
+ version_type=windows
+ shrext_cmds=".dll"
+ need_version=no
+ need_lib_prefix=no
+
+ case $GCC,$cc_basename in
+ yes,*)
+ # gcc
+ library_names_spec='$libname.dll.a'
+ # DLL is installed to $(libdir)/../bin by postinstall_cmds
+ postinstall_cmds='base_file=`basename \${file}`~
+ dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\${base_file}'\''i; echo \$dlname'\''`~
+ dldir=$destdir/`dirname \$dlpath`~
+ test -d \$dldir || mkdir -p \$dldir~
+ $install_prog $dir/$dlname \$dldir/$dlname~
+ chmod a+x \$dldir/$dlname~
+ if test -n '\''$stripme'\'' && test -n '\''$striplib'\''; then
+ eval '\''$striplib \$dldir/$dlname'\'' || exit \$?;
+ fi'
+ postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; echo \$dlname'\''`~
+ dlpath=$dir/\$dldll~
+ $RM \$dlpath'
+ shlibpath_overrides_runpath=yes
+
+ case $host_os in
+ cygwin*)
+ # Cygwin DLLs use 'cyg' prefix rather than 'lib'
+ soname_spec='`echo ${libname} | sed -e 's/^lib/cyg/'``echo ${release} | $SED -e 's/[[.]]/-/g'`${versuffix}${shared_ext}'
+m4_if([$1], [],[
+ sys_lib_search_path_spec="$sys_lib_search_path_spec /usr/lib/w32api"])
+ ;;
+ mingw* | cegcc*)
+ # MinGW DLLs use traditional 'lib' prefix
+ soname_spec='${libname}`echo ${release} | $SED -e 's/[[.]]/-/g'`${versuffix}${shared_ext}'
+ ;;
+ pw32*)
+ # pw32 DLLs use 'pw' prefix rather than 'lib'
+ library_names_spec='`echo ${libname} | sed -e 's/^lib/pw/'``echo ${release} | $SED -e 's/[[.]]/-/g'`${versuffix}${shared_ext}'
+ ;;
+ esac
+ dynamic_linker='Win32 ld.exe'
+ ;;
+
+ *,cl*)
+ # Native MSVC
+ libname_spec='$name'
+ soname_spec='${libname}`echo ${release} | $SED -e 's/[[.]]/-/g'`${versuffix}${shared_ext}'
+ library_names_spec='${libname}.dll.lib'
+
+ case $build_os in
+ mingw*)
+ sys_lib_search_path_spec=
+ lt_save_ifs=$IFS
+ IFS=';'
+ for lt_path in $LIB
+ do
+ IFS=$lt_save_ifs
+ # Let DOS variable expansion print the short 8.3 style file name.
+ lt_path=`cd "$lt_path" 2>/dev/null && cmd //C "for %i in (".") do @echo %~si"`
+ sys_lib_search_path_spec="$sys_lib_search_path_spec $lt_path"
+ done
+ IFS=$lt_save_ifs
+ # Convert to MSYS style.
+ sys_lib_search_path_spec=`$ECHO "$sys_lib_search_path_spec" | sed -e 's|\\\\|/|g' -e 's| \\([[a-zA-Z]]\\):| /\\1|g' -e 's|^ ||'`
+ ;;
+ cygwin*)
+ # Convert to unix form, then to dos form, then back to unix form
+ # but this time dos style (no spaces!) so that the unix form looks
+ # like /cygdrive/c/PROGRA~1:/cygdr...
+ sys_lib_search_path_spec=`cygpath --path --unix "$LIB"`
+ sys_lib_search_path_spec=`cygpath --path --dos "$sys_lib_search_path_spec" 2>/dev/null`
+ sys_lib_search_path_spec=`cygpath --path --unix "$sys_lib_search_path_spec" | $SED -e "s/$PATH_SEPARATOR/ /g"`
+ ;;
+ *)
+ sys_lib_search_path_spec="$LIB"
+ if $ECHO "$sys_lib_search_path_spec" | [$GREP ';[c-zC-Z]:/' >/dev/null]; then
+ # It is most probably a Windows format PATH.
+ sys_lib_search_path_spec=`$ECHO "$sys_lib_search_path_spec" | $SED -e 's/;/ /g'`
+ else
+ sys_lib_search_path_spec=`$ECHO "$sys_lib_search_path_spec" | $SED -e "s/$PATH_SEPARATOR/ /g"`
+ fi
+ # FIXME: find the short name or the path components, as spaces are
+ # common. (e.g. "Program Files" -> "PROGRA~1")
+ ;;
+ esac
+
+ # DLL is installed to $(libdir)/../bin by postinstall_cmds
+ postinstall_cmds='base_file=`basename \${file}`~
+ dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\${base_file}'\''i; echo \$dlname'\''`~
+ dldir=$destdir/`dirname \$dlpath`~
+ test -d \$dldir || mkdir -p \$dldir~
+ $install_prog $dir/$dlname \$dldir/$dlname'
+ postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; echo \$dlname'\''`~
+ dlpath=$dir/\$dldll~
+ $RM \$dlpath'
+ shlibpath_overrides_runpath=yes
+ dynamic_linker='Win32 link.exe'
+ ;;
+
+ *)
+ # Assume MSVC wrapper
+ library_names_spec='${libname}`echo ${release} | $SED -e 's/[[.]]/-/g'`${versuffix}${shared_ext} $libname.lib'
+ dynamic_linker='Win32 ld.exe'
+ ;;
+ esac
+ # FIXME: first we should search . and the directory the executable is in
+ shlibpath_var=PATH
+ ;;
+
+darwin* | rhapsody*)
+ dynamic_linker="$host_os dyld"
+ version_type=darwin
+ need_lib_prefix=no
+ need_version=no
+ library_names_spec='${libname}${release}${major}$shared_ext ${libname}$shared_ext'
+ soname_spec='${libname}${release}${major}$shared_ext'
+ shlibpath_overrides_runpath=yes
+ shlibpath_var=DYLD_LIBRARY_PATH
+ shrext_cmds='`test .$module = .yes && echo .so || echo .dylib`'
+m4_if([$1], [],[
+ sys_lib_search_path_spec="$sys_lib_search_path_spec /usr/local/lib"])
+ sys_lib_dlsearch_path_spec='/usr/local/lib /lib /usr/lib'
+ ;;
+
+dgux*)
+ version_type=linux # correct to gnu/linux during the next big refactor
+ need_lib_prefix=no
+ need_version=no
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname$shared_ext'
+ soname_spec='${libname}${release}${shared_ext}$major'
+ shlibpath_var=LD_LIBRARY_PATH
+ ;;
+
+freebsd* | dragonfly*)
+ # DragonFly does not have aout. When/if they implement a new
+ # versioning mechanism, adjust this.
+ if test -x /usr/bin/objformat; then
+ objformat=`/usr/bin/objformat`
+ else
+ case $host_os in
+ freebsd[[23]].*) objformat=aout ;;
+ *) objformat=elf ;;
+ esac
+ fi
+ version_type=freebsd-$objformat
+ case $version_type in
+ freebsd-elf*)
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}'
+ need_version=no
+ need_lib_prefix=no
+ ;;
+ freebsd-*)
+ library_names_spec='${libname}${release}${shared_ext}$versuffix $libname${shared_ext}$versuffix'
+ need_version=yes
+ ;;
+ esac
+ shlibpath_var=LD_LIBRARY_PATH
+ case $host_os in
+ freebsd2.*)
+ shlibpath_overrides_runpath=yes
+ ;;
+ freebsd3.[[01]]* | freebsdelf3.[[01]]*)
+ shlibpath_overrides_runpath=yes
+ hardcode_into_libs=yes
+ ;;
+ freebsd3.[[2-9]]* | freebsdelf3.[[2-9]]* | \
+ freebsd4.[[0-5]] | freebsdelf4.[[0-5]] | freebsd4.1.1 | freebsdelf4.1.1)
+ shlibpath_overrides_runpath=no
+ hardcode_into_libs=yes
+ ;;
+ *) # from 4.6 on, and DragonFly
+ shlibpath_overrides_runpath=yes
+ hardcode_into_libs=yes
+ ;;
+ esac
+ ;;
+
+gnu*)
+ version_type=linux # correct to gnu/linux during the next big refactor
+ need_lib_prefix=no
+ need_version=no
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}${major} ${libname}${shared_ext}'
+ soname_spec='${libname}${release}${shared_ext}$major'
+ shlibpath_var=LD_LIBRARY_PATH
+ shlibpath_overrides_runpath=no
+ hardcode_into_libs=yes
+ ;;
+
+haiku*)
+ version_type=linux # correct to gnu/linux during the next big refactor
+ need_lib_prefix=no
+ need_version=no
+ dynamic_linker="$host_os runtime_loader"
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}${major} ${libname}${shared_ext}'
+ soname_spec='${libname}${release}${shared_ext}$major'
+ shlibpath_var=LIBRARY_PATH
+ shlibpath_overrides_runpath=yes
+ sys_lib_dlsearch_path_spec='/boot/home/config/lib /boot/common/lib /boot/system/lib'
+ hardcode_into_libs=yes
+ ;;
+
+hpux9* | hpux10* | hpux11*)
+ # Give a soname corresponding to the major version so that dld.sl refuses to
+ # link against other versions.
+ version_type=sunos
+ need_lib_prefix=no
+ need_version=no
+ case $host_cpu in
+ ia64*)
+ shrext_cmds='.so'
+ hardcode_into_libs=yes
+ dynamic_linker="$host_os dld.so"
+ shlibpath_var=LD_LIBRARY_PATH
+ shlibpath_overrides_runpath=yes # Unless +noenvvar is specified.
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+ soname_spec='${libname}${release}${shared_ext}$major'
+ if test "X$HPUX_IA64_MODE" = X32; then
+ sys_lib_search_path_spec="/usr/lib/hpux32 /usr/local/lib/hpux32 /usr/local/lib"
+ else
+ sys_lib_search_path_spec="/usr/lib/hpux64 /usr/local/lib/hpux64"
+ fi
+ sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec
+ ;;
+ hppa*64*)
+ shrext_cmds='.sl'
+ hardcode_into_libs=yes
+ dynamic_linker="$host_os dld.sl"
+ shlibpath_var=LD_LIBRARY_PATH # How should we handle SHLIB_PATH
+ shlibpath_overrides_runpath=yes # Unless +noenvvar is specified.
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+ soname_spec='${libname}${release}${shared_ext}$major'
+ sys_lib_search_path_spec="/usr/lib/pa20_64 /usr/ccs/lib/pa20_64"
+ sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec
+ ;;
+ *)
+ shrext_cmds='.sl'
+ dynamic_linker="$host_os dld.sl"
+ shlibpath_var=SHLIB_PATH
+ shlibpath_overrides_runpath=no # +s is required to enable SHLIB_PATH
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+ soname_spec='${libname}${release}${shared_ext}$major'
+ ;;
+ esac
+ # HP-UX runs *really* slowly unless shared libraries are mode 555, ...
+ postinstall_cmds='chmod 555 $lib'
+ # or fails outright, so override atomically:
+ install_override_mode=555
+ ;;
+
+interix[[3-9]]*)
+ version_type=linux # correct to gnu/linux during the next big refactor
+ need_lib_prefix=no
+ need_version=no
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}'
+ soname_spec='${libname}${release}${shared_ext}$major'
+ dynamic_linker='Interix 3.x ld.so.1 (PE, like ELF)'
+ shlibpath_var=LD_LIBRARY_PATH
+ shlibpath_overrides_runpath=no
+ hardcode_into_libs=yes
+ ;;
+
+irix5* | irix6* | nonstopux*)
+ case $host_os in
+ nonstopux*) version_type=nonstopux ;;
+ *)
+ if test "$lt_cv_prog_gnu_ld" = yes; then
+ version_type=linux # correct to gnu/linux during the next big refactor
+ else
+ version_type=irix
+ fi ;;
+ esac
+ need_lib_prefix=no
+ need_version=no
+ soname_spec='${libname}${release}${shared_ext}$major'
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext} $libname${shared_ext}'
+ case $host_os in
+ irix5* | nonstopux*)
+ libsuff= shlibsuff=
+ ;;
+ *)
+ case $LD in # libtool.m4 will add one of these switches to LD
+ *-32|*"-32 "|*-melf32bsmip|*"-melf32bsmip ")
+ libsuff= shlibsuff= libmagic=32-bit;;
+ *-n32|*"-n32 "|*-melf32bmipn32|*"-melf32bmipn32 ")
+ libsuff=32 shlibsuff=N32 libmagic=N32;;
+ *-64|*"-64 "|*-melf64bmip|*"-melf64bmip ")
+ libsuff=64 shlibsuff=64 libmagic=64-bit;;
+ *) libsuff= shlibsuff= libmagic=never-match;;
+ esac
+ ;;
+ esac
+ shlibpath_var=LD_LIBRARY${shlibsuff}_PATH
+ shlibpath_overrides_runpath=no
+ sys_lib_search_path_spec="/usr/lib${libsuff} /lib${libsuff} /usr/local/lib${libsuff}"
+ sys_lib_dlsearch_path_spec="/usr/lib${libsuff} /lib${libsuff}"
+ hardcode_into_libs=yes
+ ;;
+
+# No shared lib support for Linux oldld, aout, or coff.
+linux*oldld* | linux*aout* | linux*coff*)
+ dynamic_linker=no
+ ;;
+
+# This must be glibc/ELF.
+linux* | k*bsd*-gnu | kopensolaris*-gnu)
+ version_type=linux # correct to gnu/linux during the next big refactor
+ need_lib_prefix=no
+ need_version=no
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+ soname_spec='${libname}${release}${shared_ext}$major'
+ finish_cmds='PATH="\$PATH:/sbin" ldconfig -n $libdir'
+ shlibpath_var=LD_LIBRARY_PATH
+ shlibpath_overrides_runpath=no
+
+ # Some binutils ld are patched to set DT_RUNPATH
+ AC_CACHE_VAL([lt_cv_shlibpath_overrides_runpath],
+ [lt_cv_shlibpath_overrides_runpath=no
+ save_LDFLAGS=$LDFLAGS
+ save_libdir=$libdir
+ eval "libdir=/foo; wl=\"$_LT_TAGVAR(lt_prog_compiler_wl, $1)\"; \
+ LDFLAGS=\"\$LDFLAGS $_LT_TAGVAR(hardcode_libdir_flag_spec, $1)\""
+ AC_LINK_IFELSE([AC_LANG_PROGRAM([],[])],
+ [AS_IF([ ($OBJDUMP -p conftest$ac_exeext) 2>/dev/null | grep "RUNPATH.*$libdir" >/dev/null],
+ [lt_cv_shlibpath_overrides_runpath=yes])])
+ LDFLAGS=$save_LDFLAGS
+ libdir=$save_libdir
+ ])
+ shlibpath_overrides_runpath=$lt_cv_shlibpath_overrides_runpath
+
+ # This implies no fast_install, which is unacceptable.
+ # Some rework will be needed to allow for fast_install
+ # before this can be enabled.
+ hardcode_into_libs=yes
+
+ # Add ABI-specific directories to the system library path.
+ sys_lib_dlsearch_path_spec="/lib64 /usr/lib64 /lib /usr/lib"
+
+ # Append ld.so.conf contents to the search path
+ if test -f /etc/ld.so.conf; then
+ lt_ld_extra=`awk '/^include / { system(sprintf("cd /etc; cat %s 2>/dev/null", \[$]2)); skip = 1; } { if (!skip) print \[$]0; skip = 0; }' < /etc/ld.so.conf | $SED -e 's/#.*//;/^[ ]*hwcap[ ]/d;s/[:, ]/ /g;s/=[^=]*$//;s/=[^= ]* / /g;s/"//g;/^$/d' | tr '\n' ' '`
+ sys_lib_dlsearch_path_spec="$sys_lib_dlsearch_path_spec $lt_ld_extra"
+
+ fi
+
+ # We used to test for /lib/ld.so.1 and disable shared libraries on
+ # powerpc, because MkLinux only supported shared libraries with the
+ # GNU dynamic linker. Since this was broken with cross compilers,
+ # most powerpc-linux boxes support dynamic linking these days and
+ # people can always --disable-shared, the test was removed, and we
+ # assume the GNU/Linux dynamic linker is in use.
+ dynamic_linker='GNU/Linux ld.so'
+ ;;
+
+netbsd*)
+ version_type=sunos
+ need_lib_prefix=no
+ need_version=no
+ if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix'
+ finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir'
+ dynamic_linker='NetBSD (a.out) ld.so'
+ else
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}'
+ soname_spec='${libname}${release}${shared_ext}$major'
+ dynamic_linker='NetBSD ld.elf_so'
+ fi
+ shlibpath_var=LD_LIBRARY_PATH
+ shlibpath_overrides_runpath=yes
+ hardcode_into_libs=yes
+ ;;
+
+newsos6)
+ version_type=linux # correct to gnu/linux during the next big refactor
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+ shlibpath_var=LD_LIBRARY_PATH
+ shlibpath_overrides_runpath=yes
+ ;;
+
+*nto* | *qnx*)
+ version_type=qnx
+ need_lib_prefix=no
+ need_version=no
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+ soname_spec='${libname}${release}${shared_ext}$major'
+ shlibpath_var=LD_LIBRARY_PATH
+ shlibpath_overrides_runpath=no
+ hardcode_into_libs=yes
+ dynamic_linker='ldqnx.so'
+ ;;
+
+openbsd*)
+ version_type=sunos
+ sys_lib_dlsearch_path_spec="/usr/lib"
+ need_lib_prefix=no
+ # Some older versions of OpenBSD (3.3 at least) *do* need versioned libs.
+ case $host_os in
+ openbsd3.3 | openbsd3.3.*) need_version=yes ;;
+ *) need_version=no ;;
+ esac
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix'
+ finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir'
+ shlibpath_var=LD_LIBRARY_PATH
+ if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then
+ case $host_os in
+ openbsd2.[[89]] | openbsd2.[[89]].*)
+ shlibpath_overrides_runpath=no
+ ;;
+ *)
+ shlibpath_overrides_runpath=yes
+ ;;
+ esac
+ else
+ shlibpath_overrides_runpath=yes
+ fi
+ ;;
+
+os2*)
+ libname_spec='$name'
+ shrext_cmds=".dll"
+ need_lib_prefix=no
+ library_names_spec='$libname${shared_ext} $libname.a'
+ dynamic_linker='OS/2 ld.exe'
+ shlibpath_var=LIBPATH
+ ;;
+
+osf3* | osf4* | osf5*)
+ version_type=osf
+ need_lib_prefix=no
+ need_version=no
+ soname_spec='${libname}${release}${shared_ext}$major'
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+ shlibpath_var=LD_LIBRARY_PATH
+ sys_lib_search_path_spec="/usr/shlib /usr/ccs/lib /usr/lib/cmplrs/cc /usr/lib /usr/local/lib /var/shlib"
+ sys_lib_dlsearch_path_spec="$sys_lib_search_path_spec"
+ ;;
+
+rdos*)
+ dynamic_linker=no
+ ;;
+
+solaris*)
+ version_type=linux # correct to gnu/linux during the next big refactor
+ need_lib_prefix=no
+ need_version=no
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+ soname_spec='${libname}${release}${shared_ext}$major'
+ shlibpath_var=LD_LIBRARY_PATH
+ shlibpath_overrides_runpath=yes
+ hardcode_into_libs=yes
+ # ldd complains unless libraries are executable
+ postinstall_cmds='chmod +x $lib'
+ ;;
+
+sunos4*)
+ version_type=sunos
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix'
+ finish_cmds='PATH="\$PATH:/usr/etc" ldconfig $libdir'
+ shlibpath_var=LD_LIBRARY_PATH
+ shlibpath_overrides_runpath=yes
+ if test "$with_gnu_ld" = yes; then
+ need_lib_prefix=no
+ fi
+ need_version=yes
+ ;;
+
+sysv4 | sysv4.3*)
+ version_type=linux # correct to gnu/linux during the next big refactor
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+ soname_spec='${libname}${release}${shared_ext}$major'
+ shlibpath_var=LD_LIBRARY_PATH
+ case $host_vendor in
+ sni)
+ shlibpath_overrides_runpath=no
+ need_lib_prefix=no
+ runpath_var=LD_RUN_PATH
+ ;;
+ siemens)
+ need_lib_prefix=no
+ ;;
+ motorola)
+ need_lib_prefix=no
+ need_version=no
+ shlibpath_overrides_runpath=no
+ sys_lib_search_path_spec='/lib /usr/lib /usr/ccs/lib'
+ ;;
+ esac
+ ;;
+
+sysv4*MP*)
+ if test -d /usr/nec ;then
+ version_type=linux # correct to gnu/linux during the next big refactor
+ library_names_spec='$libname${shared_ext}.$versuffix $libname${shared_ext}.$major $libname${shared_ext}'
+ soname_spec='$libname${shared_ext}.$major'
+ shlibpath_var=LD_LIBRARY_PATH
+ fi
+ ;;
+
+sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*)
+ version_type=freebsd-elf
+ need_lib_prefix=no
+ need_version=no
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}'
+ soname_spec='${libname}${release}${shared_ext}$major'
+ shlibpath_var=LD_LIBRARY_PATH
+ shlibpath_overrides_runpath=yes
+ hardcode_into_libs=yes
+ if test "$with_gnu_ld" = yes; then
+ sys_lib_search_path_spec='/usr/local/lib /usr/gnu/lib /usr/ccs/lib /usr/lib /lib'
+ else
+ sys_lib_search_path_spec='/usr/ccs/lib /usr/lib'
+ case $host_os in
+ sco3.2v5*)
+ sys_lib_search_path_spec="$sys_lib_search_path_spec /lib"
+ ;;
+ esac
+ fi
+ sys_lib_dlsearch_path_spec='/usr/lib'
+ ;;
+
+tpf*)
+ # TPF is a cross-target only. Preferred cross-host = GNU/Linux.
+ version_type=linux # correct to gnu/linux during the next big refactor
+ need_lib_prefix=no
+ need_version=no
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+ shlibpath_var=LD_LIBRARY_PATH
+ shlibpath_overrides_runpath=no
+ hardcode_into_libs=yes
+ ;;
+
+uts4*)
+ version_type=linux # correct to gnu/linux during the next big refactor
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+ soname_spec='${libname}${release}${shared_ext}$major'
+ shlibpath_var=LD_LIBRARY_PATH
+ ;;
+
+*)
+ dynamic_linker=no
+ ;;
+esac
+AC_MSG_RESULT([$dynamic_linker])
+test "$dynamic_linker" = no && can_build_shared=no
+
+variables_saved_for_relink="PATH $shlibpath_var $runpath_var"
+if test "$GCC" = yes; then
+ variables_saved_for_relink="$variables_saved_for_relink GCC_EXEC_PREFIX COMPILER_PATH LIBRARY_PATH"
+fi
+
+if test "${lt_cv_sys_lib_search_path_spec+set}" = set; then
+ sys_lib_search_path_spec="$lt_cv_sys_lib_search_path_spec"
+fi
+if test "${lt_cv_sys_lib_dlsearch_path_spec+set}" = set; then
+ sys_lib_dlsearch_path_spec="$lt_cv_sys_lib_dlsearch_path_spec"
+fi
+
+_LT_DECL([], [variables_saved_for_relink], [1],
+ [Variables whose values should be saved in libtool wrapper scripts and
+ restored at link time])
+_LT_DECL([], [need_lib_prefix], [0],
+ [Do we need the "lib" prefix for modules?])
+_LT_DECL([], [need_version], [0], [Do we need a version for libraries?])
+_LT_DECL([], [version_type], [0], [Library versioning type])
+_LT_DECL([], [runpath_var], [0], [Shared library runtime path variable])
+_LT_DECL([], [shlibpath_var], [0],[Shared library path variable])
+_LT_DECL([], [shlibpath_overrides_runpath], [0],
+ [Is shlibpath searched before the hard-coded library search path?])
+_LT_DECL([], [libname_spec], [1], [Format of library name prefix])
+_LT_DECL([], [library_names_spec], [1],
+ [[List of archive names. First name is the real one, the rest are links.
+ The last name is the one that the linker finds with -lNAME]])
+_LT_DECL([], [soname_spec], [1],
+ [[The coded name of the library, if different from the real name]])
+_LT_DECL([], [install_override_mode], [1],
+ [Permission mode override for installation of shared libraries])
+_LT_DECL([], [postinstall_cmds], [2],
+ [Command to use after installation of a shared archive])
+_LT_DECL([], [postuninstall_cmds], [2],
+ [Command to use after uninstallation of a shared archive])
+_LT_DECL([], [finish_cmds], [2],
+ [Commands used to finish a libtool library installation in a directory])
+_LT_DECL([], [finish_eval], [1],
+ [[As "finish_cmds", except a single script fragment to be evaled but
+ not shown]])
+_LT_DECL([], [hardcode_into_libs], [0],
+ [Whether we should hardcode library paths into libraries])
+_LT_DECL([], [sys_lib_search_path_spec], [2],
+ [Compile-time system search path for libraries])
+_LT_DECL([], [sys_lib_dlsearch_path_spec], [2],
+ [Run-time system search path for libraries])
+])# _LT_SYS_DYNAMIC_LINKER
+
+
+# _LT_PATH_TOOL_PREFIX(TOOL)
+# --------------------------
+# find a file program which can recognize shared library
+AC_DEFUN([_LT_PATH_TOOL_PREFIX],
+[m4_require([_LT_DECL_EGREP])dnl
+AC_MSG_CHECKING([for $1])
+AC_CACHE_VAL(lt_cv_path_MAGIC_CMD,
+[case $MAGIC_CMD in
+[[\\/*] | ?:[\\/]*])
+ lt_cv_path_MAGIC_CMD="$MAGIC_CMD" # Let the user override the test with a path.
+ ;;
+*)
+ lt_save_MAGIC_CMD="$MAGIC_CMD"
+ lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR
+dnl $ac_dummy forces splitting on constant user-supplied paths.
+dnl POSIX.2 word splitting is done only on the output of word expansions,
+dnl not every word. This closes a longstanding sh security hole.
+ ac_dummy="m4_if([$2], , $PATH, [$2])"
+ for ac_dir in $ac_dummy; do
+ IFS="$lt_save_ifs"
+ test -z "$ac_dir" && ac_dir=.
+ if test -f $ac_dir/$1; then
+ lt_cv_path_MAGIC_CMD="$ac_dir/$1"
+ if test -n "$file_magic_test_file"; then
+ case $deplibs_check_method in
+ "file_magic "*)
+ file_magic_regex=`expr "$deplibs_check_method" : "file_magic \(.*\)"`
+ MAGIC_CMD="$lt_cv_path_MAGIC_CMD"
+ if eval $file_magic_cmd \$file_magic_test_file 2> /dev/null |
+ $EGREP "$file_magic_regex" > /dev/null; then
+ :
+ else
+ cat <<_LT_EOF 1>&2
+
+*** Warning: the command libtool uses to detect shared libraries,
+*** $file_magic_cmd, produces output that libtool cannot recognize.
+*** The result is that libtool may fail to recognize shared libraries
+*** as such. This will affect the creation of libtool libraries that
+*** depend on shared libraries, but programs linked with such libtool
+*** libraries will work regardless of this problem. Nevertheless, you
+*** may want to report the problem to your system manager and/or to
+*** bug-libtool@gnu.org
+
+_LT_EOF
+ fi ;;
+ esac
+ fi
+ break
+ fi
+ done
+ IFS="$lt_save_ifs"
+ MAGIC_CMD="$lt_save_MAGIC_CMD"
+ ;;
+esac])
+MAGIC_CMD="$lt_cv_path_MAGIC_CMD"
+if test -n "$MAGIC_CMD"; then
+ AC_MSG_RESULT($MAGIC_CMD)
+else
+ AC_MSG_RESULT(no)
+fi
+_LT_DECL([], [MAGIC_CMD], [0],
+ [Used to examine libraries when file_magic_cmd begins with "file"])dnl
+])# _LT_PATH_TOOL_PREFIX
+
+# Old name:
+AU_ALIAS([AC_PATH_TOOL_PREFIX], [_LT_PATH_TOOL_PREFIX])
+dnl aclocal-1.4 backwards compatibility:
+dnl AC_DEFUN([AC_PATH_TOOL_PREFIX], [])
+
+
+# _LT_PATH_MAGIC
+# --------------
+# find a file program which can recognize a shared library
+m4_defun([_LT_PATH_MAGIC],
+[_LT_PATH_TOOL_PREFIX(${ac_tool_prefix}file, /usr/bin$PATH_SEPARATOR$PATH)
+if test -z "$lt_cv_path_MAGIC_CMD"; then
+ if test -n "$ac_tool_prefix"; then
+ _LT_PATH_TOOL_PREFIX(file, /usr/bin$PATH_SEPARATOR$PATH)
+ else
+ MAGIC_CMD=:
+ fi
+fi
+])# _LT_PATH_MAGIC
+
+
+# LT_PATH_LD
+# ----------
+# find the pathname to the GNU or non-GNU linker
+AC_DEFUN([LT_PATH_LD],
+[AC_REQUIRE([AC_PROG_CC])dnl
+AC_REQUIRE([AC_CANONICAL_HOST])dnl
+AC_REQUIRE([AC_CANONICAL_BUILD])dnl
+m4_require([_LT_DECL_SED])dnl
+m4_require([_LT_DECL_EGREP])dnl
+m4_require([_LT_PROG_ECHO_BACKSLASH])dnl
+
+AC_ARG_WITH([gnu-ld],
+ [AS_HELP_STRING([--with-gnu-ld],
+ [assume the C compiler uses GNU ld @<:@default=no@:>@])],
+ [test "$withval" = no || with_gnu_ld=yes],
+ [with_gnu_ld=no])dnl
+
+ac_prog=ld
+if test "$GCC" = yes; then
+ # Check if gcc -print-prog-name=ld gives a path.
+ AC_MSG_CHECKING([for ld used by $CC])
+ case $host in
+ *-*-mingw*)
+ # gcc leaves a trailing carriage return which upsets mingw
+ ac_prog=`($CC -print-prog-name=ld) 2>&5 | tr -d '\015'` ;;
+ *)
+ ac_prog=`($CC -print-prog-name=ld) 2>&5` ;;
+ esac
+ case $ac_prog in
+ # Accept absolute paths.
+ [[\\/]]* | ?:[[\\/]]*)
+ re_direlt='/[[^/]][[^/]]*/\.\./'
+ # Canonicalize the pathname of ld
+ ac_prog=`$ECHO "$ac_prog"| $SED 's%\\\\%/%g'`
+ while $ECHO "$ac_prog" | $GREP "$re_direlt" > /dev/null 2>&1; do
+ ac_prog=`$ECHO $ac_prog| $SED "s%$re_direlt%/%"`
+ done
+ test -z "$LD" && LD="$ac_prog"
+ ;;
+ "")
+ # If it fails, then pretend we aren't using GCC.
+ ac_prog=ld
+ ;;
+ *)
+ # If it is relative, then search for the first ld in PATH.
+ with_gnu_ld=unknown
+ ;;
+ esac
+elif test "$with_gnu_ld" = yes; then
+ AC_MSG_CHECKING([for GNU ld])
+else
+ AC_MSG_CHECKING([for non-GNU ld])
+fi
+AC_CACHE_VAL(lt_cv_path_LD,
+[if test -z "$LD"; then
+ lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR
+ for ac_dir in $PATH; do
+ IFS="$lt_save_ifs"
+ test -z "$ac_dir" && ac_dir=.
+ if test -f "$ac_dir/$ac_prog" || test -f "$ac_dir/$ac_prog$ac_exeext"; then
+ lt_cv_path_LD="$ac_dir/$ac_prog"
+ # Check to see if the program is GNU ld. I'd rather use --version,
+ # but apparently some variants of GNU ld only accept -v.
+ # Break only if it was the GNU/non-GNU ld that we prefer.
+ case `"$lt_cv_path_LD" -v 2>&1 </dev/null` in
+ *GNU* | *'with BFD'*)
+ test "$with_gnu_ld" != no && break
+ ;;
+ *)
+ test "$with_gnu_ld" != yes && break
+ ;;
+ esac
+ fi
+ done
+ IFS="$lt_save_ifs"
+else
+ lt_cv_path_LD="$LD" # Let the user override the test with a path.
+fi])
+LD="$lt_cv_path_LD"
+if test -n "$LD"; then
+ AC_MSG_RESULT($LD)
+else
+ AC_MSG_RESULT(no)
+fi
+test -z "$LD" && AC_MSG_ERROR([no acceptable ld found in \$PATH])
+_LT_PATH_LD_GNU
+AC_SUBST([LD])
+
+_LT_TAGDECL([], [LD], [1], [The linker used to build libraries])
+])# LT_PATH_LD
+
+# Old names:
+AU_ALIAS([AM_PROG_LD], [LT_PATH_LD])
+AU_ALIAS([AC_PROG_LD], [LT_PATH_LD])
+dnl aclocal-1.4 backwards compatibility:
+dnl AC_DEFUN([AM_PROG_LD], [])
+dnl AC_DEFUN([AC_PROG_LD], [])
+
+
+# _LT_PATH_LD_GNU
+#- --------------
+m4_defun([_LT_PATH_LD_GNU],
+[AC_CACHE_CHECK([if the linker ($LD) is GNU ld], lt_cv_prog_gnu_ld,
+[# I'd rather use --version here, but apparently some GNU lds only accept -v.
+case `$LD -v 2>&1 </dev/null` in
+*GNU* | *'with BFD'*)
+ lt_cv_prog_gnu_ld=yes
+ ;;
+*)
+ lt_cv_prog_gnu_ld=no
+ ;;
+esac])
+with_gnu_ld=$lt_cv_prog_gnu_ld
+])# _LT_PATH_LD_GNU
+
+
+# _LT_CMD_RELOAD
+# --------------
+# find reload flag for linker
+# -- PORTME Some linkers may need a different reload flag.
+m4_defun([_LT_CMD_RELOAD],
+[AC_CACHE_CHECK([for $LD option to reload object files],
+ lt_cv_ld_reload_flag,
+ [lt_cv_ld_reload_flag='-r'])
+reload_flag=$lt_cv_ld_reload_flag
+case $reload_flag in
+"" | " "*) ;;
+*) reload_flag=" $reload_flag" ;;
+esac
+reload_cmds='$LD$reload_flag -o $output$reload_objs'
+case $host_os in
+ cygwin* | mingw* | pw32* | cegcc*)
+ if test "$GCC" != yes; then
+ reload_cmds=false
+ fi
+ ;;
+ darwin*)
+ if test "$GCC" = yes; then
+ reload_cmds='$LTCC $LTCFLAGS -nostdlib ${wl}-r -o $output$reload_objs'
+ else
+ reload_cmds='$LD$reload_flag -o $output$reload_objs'
+ fi
+ ;;
+esac
+_LT_TAGDECL([], [reload_flag], [1], [How to create reloadable object files])dnl
+_LT_TAGDECL([], [reload_cmds], [2])dnl
+])# _LT_CMD_RELOAD
+
+
+# _LT_CHECK_MAGIC_METHOD
+# ----------------------
+# how to check for library dependencies
+# -- PORTME fill in with the dynamic library characteristics
+m4_defun([_LT_CHECK_MAGIC_METHOD],
+[m4_require([_LT_DECL_EGREP])
+m4_require([_LT_DECL_OBJDUMP])
+AC_CACHE_CHECK([how to recognize dependent libraries],
+lt_cv_deplibs_check_method,
+[lt_cv_file_magic_cmd='$MAGIC_CMD'
+lt_cv_file_magic_test_file=
+lt_cv_deplibs_check_method='unknown'
+# Need to set the preceding variable on all platforms that support
+# interlibrary dependencies.
+# 'none' -- dependencies not supported.
+# `unknown' -- same as none, but documents that we really don't know.
+# 'pass_all' -- all dependencies passed with no checks.
+# 'test_compile' -- check by making test program.
+# 'file_magic [[regex]]' -- check by looking for files in library path
+# which responds to the $file_magic_cmd with a given extended regex.
+# If you have `file' or equivalent on your system and you're not sure
+# whether `pass_all' will *always* work, you probably want this one.
+
+case $host_os in
+aix[[4-9]]*)
+ lt_cv_deplibs_check_method=pass_all
+ ;;
+
+beos*)
+ lt_cv_deplibs_check_method=pass_all
+ ;;
+
+bsdi[[45]]*)
+ lt_cv_deplibs_check_method='file_magic ELF [[0-9]][[0-9]]*-bit [[ML]]SB (shared object|dynamic lib)'
+ lt_cv_file_magic_cmd='/usr/bin/file -L'
+ lt_cv_file_magic_test_file=/shlib/libc.so
+ ;;
+
+cygwin*)
+ # func_win32_libid is a shell function defined in ltmain.sh
+ lt_cv_deplibs_check_method='file_magic ^x86 archive import|^x86 DLL'
+ lt_cv_file_magic_cmd='func_win32_libid'
+ ;;
+
+mingw* | pw32*)
+ # Base MSYS/MinGW do not provide the 'file' command needed by
+ # func_win32_libid shell function, so use a weaker test based on 'objdump',
+ # unless we find 'file', for example because we are cross-compiling.
+ # func_win32_libid assumes BSD nm, so disallow it if using MS dumpbin.
+ if ( test "$lt_cv_nm_interface" = "BSD nm" && file / ) >/dev/null 2>&1; then
+ lt_cv_deplibs_check_method='file_magic ^x86 archive import|^x86 DLL'
+ lt_cv_file_magic_cmd='func_win32_libid'
+ else
+ # Keep this pattern in sync with the one in func_win32_libid.
+ lt_cv_deplibs_check_method='file_magic file format (pei*-i386(.*architecture: i386)?|pe-arm-wince|pe-x86-64)'
+ lt_cv_file_magic_cmd='$OBJDUMP -f'
+ fi
+ ;;
+
+cegcc*)
+ # use the weaker test based on 'objdump'. See mingw*.
+ lt_cv_deplibs_check_method='file_magic file format pe-arm-.*little(.*architecture: arm)?'
+ lt_cv_file_magic_cmd='$OBJDUMP -f'
+ ;;
+
+darwin* | rhapsody*)
+ lt_cv_deplibs_check_method=pass_all
+ ;;
+
+freebsd* | dragonfly*)
+ if echo __ELF__ | $CC -E - | $GREP __ELF__ > /dev/null; then
+ case $host_cpu in
+ i*86 )
+ # Not sure whether the presence of OpenBSD here was a mistake.
+ # Let's accept both of them until this is cleared up.
+ lt_cv_deplibs_check_method='file_magic (FreeBSD|OpenBSD|DragonFly)/i[[3-9]]86 (compact )?demand paged shared library'
+ lt_cv_file_magic_cmd=/usr/bin/file
+ lt_cv_file_magic_test_file=`echo /usr/lib/libc.so.*`
+ ;;
+ esac
+ else
+ lt_cv_deplibs_check_method=pass_all
+ fi
+ ;;
+
+gnu*)
+ lt_cv_deplibs_check_method=pass_all
+ ;;
+
+haiku*)
+ lt_cv_deplibs_check_method=pass_all
+ ;;
+
+hpux10.20* | hpux11*)
+ lt_cv_file_magic_cmd=/usr/bin/file
+ case $host_cpu in
+ ia64*)
+ lt_cv_deplibs_check_method='file_magic (s[[0-9]][[0-9]][[0-9]]|ELF-[[0-9]][[0-9]]) shared object file - IA64'
+ lt_cv_file_magic_test_file=/usr/lib/hpux32/libc.so
+ ;;
+ hppa*64*)
+ [lt_cv_deplibs_check_method='file_magic (s[0-9][0-9][0-9]|ELF[ -][0-9][0-9])(-bit)?( [LM]SB)? shared object( file)?[, -]* PA-RISC [0-9]\.[0-9]']
+ lt_cv_file_magic_test_file=/usr/lib/pa20_64/libc.sl
+ ;;
+ *)
+ lt_cv_deplibs_check_method='file_magic (s[[0-9]][[0-9]][[0-9]]|PA-RISC[[0-9]]\.[[0-9]]) shared library'
+ lt_cv_file_magic_test_file=/usr/lib/libc.sl
+ ;;
+ esac
+ ;;
+
+interix[[3-9]]*)
+ # PIC code is broken on Interix 3.x, that's why |\.a not |_pic\.a here
+ lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so|\.a)$'
+ ;;
+
+irix5* | irix6* | nonstopux*)
+ case $LD in
+ *-32|*"-32 ") libmagic=32-bit;;
+ *-n32|*"-n32 ") libmagic=N32;;
+ *-64|*"-64 ") libmagic=64-bit;;
+ *) libmagic=never-match;;
+ esac
+ lt_cv_deplibs_check_method=pass_all
+ ;;
+
+# This must be glibc/ELF.
+linux* | k*bsd*-gnu | kopensolaris*-gnu)
+ lt_cv_deplibs_check_method=pass_all
+ ;;
+
+netbsd*)
+ if echo __ELF__ | $CC -E - | $GREP __ELF__ > /dev/null; then
+ lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so\.[[0-9]]+\.[[0-9]]+|_pic\.a)$'
+ else
+ lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so|_pic\.a)$'
+ fi
+ ;;
+
+newos6*)
+ lt_cv_deplibs_check_method='file_magic ELF [[0-9]][[0-9]]*-bit [[ML]]SB (executable|dynamic lib)'
+ lt_cv_file_magic_cmd=/usr/bin/file
+ lt_cv_file_magic_test_file=/usr/lib/libnls.so
+ ;;
+
+*nto* | *qnx*)
+ lt_cv_deplibs_check_method=pass_all
+ ;;
+
+openbsd*)
+ if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then
+ lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so\.[[0-9]]+\.[[0-9]]+|\.so|_pic\.a)$'
+ else
+ lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so\.[[0-9]]+\.[[0-9]]+|_pic\.a)$'
+ fi
+ ;;
+
+osf3* | osf4* | osf5*)
+ lt_cv_deplibs_check_method=pass_all
+ ;;
+
+rdos*)
+ lt_cv_deplibs_check_method=pass_all
+ ;;
+
+solaris*)
+ lt_cv_deplibs_check_method=pass_all
+ ;;
+
+sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*)
+ lt_cv_deplibs_check_method=pass_all
+ ;;
+
+sysv4 | sysv4.3*)
+ case $host_vendor in
+ motorola)
+ lt_cv_deplibs_check_method='file_magic ELF [[0-9]][[0-9]]*-bit [[ML]]SB (shared object|dynamic lib) M[[0-9]][[0-9]]* Version [[0-9]]'
+ lt_cv_file_magic_test_file=`echo /usr/lib/libc.so*`
+ ;;
+ ncr)
+ lt_cv_deplibs_check_method=pass_all
+ ;;
+ sequent)
+ lt_cv_file_magic_cmd='/bin/file'
+ lt_cv_deplibs_check_method='file_magic ELF [[0-9]][[0-9]]*-bit [[LM]]SB (shared object|dynamic lib )'
+ ;;
+ sni)
+ lt_cv_file_magic_cmd='/bin/file'
+ lt_cv_deplibs_check_method="file_magic ELF [[0-9]][[0-9]]*-bit [[LM]]SB dynamic lib"
+ lt_cv_file_magic_test_file=/lib/libc.so
+ ;;
+ siemens)
+ lt_cv_deplibs_check_method=pass_all
+ ;;
+ pc)
+ lt_cv_deplibs_check_method=pass_all
+ ;;
+ esac
+ ;;
+
+tpf*)
+ lt_cv_deplibs_check_method=pass_all
+ ;;
+esac
+])
+
+file_magic_glob=
+want_nocaseglob=no
+if test "$build" = "$host"; then
+ case $host_os in
+ mingw* | pw32*)
+ if ( shopt | grep nocaseglob ) >/dev/null 2>&1; then
+ want_nocaseglob=yes
+ else
+ file_magic_glob=`echo aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZ | $SED -e "s/\(..\)/s\/[[\1]]\/[[\1]]\/g;/g"`
+ fi
+ ;;
+ esac
+fi
+
+file_magic_cmd=$lt_cv_file_magic_cmd
+deplibs_check_method=$lt_cv_deplibs_check_method
+test -z "$deplibs_check_method" && deplibs_check_method=unknown
+
+_LT_DECL([], [deplibs_check_method], [1],
+ [Method to check whether dependent libraries are shared objects])
+_LT_DECL([], [file_magic_cmd], [1],
+ [Command to use when deplibs_check_method = "file_magic"])
+_LT_DECL([], [file_magic_glob], [1],
+ [How to find potential files when deplibs_check_method = "file_magic"])
+_LT_DECL([], [want_nocaseglob], [1],
+ [Find potential files using nocaseglob when deplibs_check_method = "file_magic"])
+])# _LT_CHECK_MAGIC_METHOD
+
+
+# LT_PATH_NM
+# ----------
+# find the pathname to a BSD- or MS-compatible name lister
+AC_DEFUN([LT_PATH_NM],
+[AC_REQUIRE([AC_PROG_CC])dnl
+AC_CACHE_CHECK([for BSD- or MS-compatible name lister (nm)], lt_cv_path_NM,
+[if test -n "$NM"; then
+ # Let the user override the test.
+ lt_cv_path_NM="$NM"
+else
+ lt_nm_to_check="${ac_tool_prefix}nm"
+ if test -n "$ac_tool_prefix" && test "$build" = "$host"; then
+ lt_nm_to_check="$lt_nm_to_check nm"
+ fi
+ for lt_tmp_nm in $lt_nm_to_check; do
+ lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR
+ for ac_dir in $PATH /usr/ccs/bin/elf /usr/ccs/bin /usr/ucb /bin; do
+ IFS="$lt_save_ifs"
+ test -z "$ac_dir" && ac_dir=.
+ tmp_nm="$ac_dir/$lt_tmp_nm"
+ if test -f "$tmp_nm" || test -f "$tmp_nm$ac_exeext" ; then
+ # Check to see if the nm accepts a BSD-compat flag.
+ # Adding the `sed 1q' prevents false positives on HP-UX, which says:
+ # nm: unknown option "B" ignored
+ # Tru64's nm complains that /dev/null is an invalid object file
+ case `"$tmp_nm" -B /dev/null 2>&1 | sed '1q'` in
+ */dev/null* | *'Invalid file or object type'*)
+ lt_cv_path_NM="$tmp_nm -B"
+ break
+ ;;
+ *)
+ case `"$tmp_nm" -p /dev/null 2>&1 | sed '1q'` in
+ */dev/null*)
+ lt_cv_path_NM="$tmp_nm -p"
+ break
+ ;;
+ *)
+ lt_cv_path_NM=${lt_cv_path_NM="$tmp_nm"} # keep the first match, but
+ continue # so that we can try to find one that supports BSD flags
+ ;;
+ esac
+ ;;
+ esac
+ fi
+ done
+ IFS="$lt_save_ifs"
+ done
+ : ${lt_cv_path_NM=no}
+fi])
+if test "$lt_cv_path_NM" != "no"; then
+ NM="$lt_cv_path_NM"
+else
+ # Didn't find any BSD compatible name lister, look for dumpbin.
+ if test -n "$DUMPBIN"; then :
+ # Let the user override the test.
+ else
+ AC_CHECK_TOOLS(DUMPBIN, [dumpbin "link -dump"], :)
+ case `$DUMPBIN -symbols /dev/null 2>&1 | sed '1q'` in
+ *COFF*)
+ DUMPBIN="$DUMPBIN -symbols"
+ ;;
+ *)
+ DUMPBIN=:
+ ;;
+ esac
+ fi
+ AC_SUBST([DUMPBIN])
+ if test "$DUMPBIN" != ":"; then
+ NM="$DUMPBIN"
+ fi
+fi
+test -z "$NM" && NM=nm
+AC_SUBST([NM])
+_LT_DECL([], [NM], [1], [A BSD- or MS-compatible name lister])dnl
+
+AC_CACHE_CHECK([the name lister ($NM) interface], [lt_cv_nm_interface],
+ [lt_cv_nm_interface="BSD nm"
+ echo "int some_variable = 0;" > conftest.$ac_ext
+ (eval echo "\"\$as_me:$LINENO: $ac_compile\"" >&AS_MESSAGE_LOG_FD)
+ (eval "$ac_compile" 2>conftest.err)
+ cat conftest.err >&AS_MESSAGE_LOG_FD
+ (eval echo "\"\$as_me:$LINENO: $NM \\\"conftest.$ac_objext\\\"\"" >&AS_MESSAGE_LOG_FD)
+ (eval "$NM \"conftest.$ac_objext\"" 2>conftest.err > conftest.out)
+ cat conftest.err >&AS_MESSAGE_LOG_FD
+ (eval echo "\"\$as_me:$LINENO: output\"" >&AS_MESSAGE_LOG_FD)
+ cat conftest.out >&AS_MESSAGE_LOG_FD
+ if $GREP 'External.*some_variable' conftest.out > /dev/null; then
+ lt_cv_nm_interface="MS dumpbin"
+ fi
+ rm -f conftest*])
+])# LT_PATH_NM
+
+# Old names:
+AU_ALIAS([AM_PROG_NM], [LT_PATH_NM])
+AU_ALIAS([AC_PROG_NM], [LT_PATH_NM])
+dnl aclocal-1.4 backwards compatibility:
+dnl AC_DEFUN([AM_PROG_NM], [])
+dnl AC_DEFUN([AC_PROG_NM], [])
+
+# _LT_CHECK_SHAREDLIB_FROM_LINKLIB
+# --------------------------------
+# how to determine the name of the shared library
+# associated with a specific link library.
+# -- PORTME fill in with the dynamic library characteristics
+m4_defun([_LT_CHECK_SHAREDLIB_FROM_LINKLIB],
+[m4_require([_LT_DECL_EGREP])
+m4_require([_LT_DECL_OBJDUMP])
+m4_require([_LT_DECL_DLLTOOL])
+AC_CACHE_CHECK([how to associate runtime and link libraries],
+lt_cv_sharedlib_from_linklib_cmd,
+[lt_cv_sharedlib_from_linklib_cmd='unknown'
+
+case $host_os in
+cygwin* | mingw* | pw32* | cegcc*)
+ # two different shell functions defined in ltmain.sh
+ # decide which to use based on capabilities of $DLLTOOL
+ case `$DLLTOOL --help 2>&1` in
+ *--identify-strict*)
+ lt_cv_sharedlib_from_linklib_cmd=func_cygming_dll_for_implib
+ ;;
+ *)
+ lt_cv_sharedlib_from_linklib_cmd=func_cygming_dll_for_implib_fallback
+ ;;
+ esac
+ ;;
+*)
+ # fallback: assume linklib IS sharedlib
+ lt_cv_sharedlib_from_linklib_cmd="$ECHO"
+ ;;
+esac
+])
+sharedlib_from_linklib_cmd=$lt_cv_sharedlib_from_linklib_cmd
+test -z "$sharedlib_from_linklib_cmd" && sharedlib_from_linklib_cmd=$ECHO
+
+_LT_DECL([], [sharedlib_from_linklib_cmd], [1],
+ [Command to associate shared and link libraries])
+])# _LT_CHECK_SHAREDLIB_FROM_LINKLIB
+
+
+# _LT_PATH_MANIFEST_TOOL
+# ----------------------
+# locate the manifest tool
+m4_defun([_LT_PATH_MANIFEST_TOOL],
+[AC_CHECK_TOOL(MANIFEST_TOOL, mt, :)
+test -z "$MANIFEST_TOOL" && MANIFEST_TOOL=mt
+AC_CACHE_CHECK([if $MANIFEST_TOOL is a manifest tool], [lt_cv_path_mainfest_tool],
+ [lt_cv_path_mainfest_tool=no
+ echo "$as_me:$LINENO: $MANIFEST_TOOL '-?'" >&AS_MESSAGE_LOG_FD
+ $MANIFEST_TOOL '-?' 2>conftest.err > conftest.out
+ cat conftest.err >&AS_MESSAGE_LOG_FD
+ if $GREP 'Manifest Tool' conftest.out > /dev/null; then
+ lt_cv_path_mainfest_tool=yes
+ fi
+ rm -f conftest*])
+if test "x$lt_cv_path_mainfest_tool" != xyes; then
+ MANIFEST_TOOL=:
+fi
+_LT_DECL([], [MANIFEST_TOOL], [1], [Manifest tool])dnl
+])# _LT_PATH_MANIFEST_TOOL
+
+
+# LT_LIB_M
+# --------
+# check for math library
+AC_DEFUN([LT_LIB_M],
+[AC_REQUIRE([AC_CANONICAL_HOST])dnl
+LIBM=
+case $host in
+*-*-beos* | *-*-cegcc* | *-*-cygwin* | *-*-haiku* | *-*-pw32* | *-*-darwin*)
+ # These system don't have libm, or don't need it
+ ;;
+*-ncr-sysv4.3*)
+ AC_CHECK_LIB(mw, _mwvalidcheckl, LIBM="-lmw")
+ AC_CHECK_LIB(m, cos, LIBM="$LIBM -lm")
+ ;;
+*)
+ AC_CHECK_LIB(m, cos, LIBM="-lm")
+ ;;
+esac
+AC_SUBST([LIBM])
+])# LT_LIB_M
+
+# Old name:
+AU_ALIAS([AC_CHECK_LIBM], [LT_LIB_M])
+dnl aclocal-1.4 backwards compatibility:
+dnl AC_DEFUN([AC_CHECK_LIBM], [])
+
+
+# _LT_COMPILER_NO_RTTI([TAGNAME])
+# -------------------------------
+m4_defun([_LT_COMPILER_NO_RTTI],
+[m4_require([_LT_TAG_COMPILER])dnl
+
+_LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)=
+
+if test "$GCC" = yes; then
+ case $cc_basename in
+ nvcc*)
+ _LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)=' -Xcompiler -fno-builtin' ;;
+ *)
+ _LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)=' -fno-builtin' ;;
+ esac
+
+ _LT_COMPILER_OPTION([if $compiler supports -fno-rtti -fno-exceptions],
+ lt_cv_prog_compiler_rtti_exceptions,
+ [-fno-rtti -fno-exceptions], [],
+ [_LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)="$_LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1) -fno-rtti -fno-exceptions"])
+fi
+_LT_TAGDECL([no_builtin_flag], [lt_prog_compiler_no_builtin_flag], [1],
+ [Compiler flag to turn off builtin functions])
+])# _LT_COMPILER_NO_RTTI
+
+
+# _LT_CMD_GLOBAL_SYMBOLS
+# ----------------------
+m4_defun([_LT_CMD_GLOBAL_SYMBOLS],
+[AC_REQUIRE([AC_CANONICAL_HOST])dnl
+AC_REQUIRE([AC_PROG_CC])dnl
+AC_REQUIRE([AC_PROG_AWK])dnl
+AC_REQUIRE([LT_PATH_NM])dnl
+AC_REQUIRE([LT_PATH_LD])dnl
+m4_require([_LT_DECL_SED])dnl
+m4_require([_LT_DECL_EGREP])dnl
+m4_require([_LT_TAG_COMPILER])dnl
+
+# Check for command to grab the raw symbol name followed by C symbol from nm.
+AC_MSG_CHECKING([command to parse $NM output from $compiler object])
+AC_CACHE_VAL([lt_cv_sys_global_symbol_pipe],
+[
+# These are sane defaults that work on at least a few old systems.
+# [They come from Ultrix. What could be older than Ultrix?!! ;)]
+
+# Character class describing NM global symbol codes.
+symcode='[[BCDEGRST]]'
+
+# Regexp to match symbols that can be accessed directly from C.
+sympat='\([[_A-Za-z]][[_A-Za-z0-9]]*\)'
+
+# Define system-specific variables.
+case $host_os in
+aix*)
+ symcode='[[BCDT]]'
+ ;;
+cygwin* | mingw* | pw32* | cegcc*)
+ symcode='[[ABCDGISTW]]'
+ ;;
+hpux*)
+ if test "$host_cpu" = ia64; then
+ symcode='[[ABCDEGRST]]'
+ fi
+ ;;
+irix* | nonstopux*)
+ symcode='[[BCDEGRST]]'
+ ;;
+osf*)
+ symcode='[[BCDEGQRST]]'
+ ;;
+solaris*)
+ symcode='[[BDRT]]'
+ ;;
+sco3.2v5*)
+ symcode='[[DT]]'
+ ;;
+sysv4.2uw2*)
+ symcode='[[DT]]'
+ ;;
+sysv5* | sco5v6* | unixware* | OpenUNIX*)
+ symcode='[[ABDT]]'
+ ;;
+sysv4)
+ symcode='[[DFNSTU]]'
+ ;;
+esac
+
+# If we're using GNU nm, then use its standard symbol codes.
+case `$NM -V 2>&1` in
+*GNU* | *'with BFD'*)
+ symcode='[[ABCDGIRSTW]]' ;;
+esac
+
+# Transform an extracted symbol line into a proper C declaration.
+# Some systems (esp. on ia64) link data and code symbols differently,
+# so use this general approach.
+lt_cv_sys_global_symbol_to_cdecl="sed -n -e 's/^T .* \(.*\)$/extern int \1();/p' -e 's/^$symcode* .* \(.*\)$/extern char \1;/p'"
+
+# Transform an extracted symbol line into symbol name and symbol address
+lt_cv_sys_global_symbol_to_c_name_address="sed -n -e 's/^: \([[^ ]]*\)[[ ]]*$/ {\\\"\1\\\", (void *) 0},/p' -e 's/^$symcode* \([[^ ]]*\) \([[^ ]]*\)$/ {\"\2\", (void *) \&\2},/p'"
+lt_cv_sys_global_symbol_to_c_name_address_lib_prefix="sed -n -e 's/^: \([[^ ]]*\)[[ ]]*$/ {\\\"\1\\\", (void *) 0},/p' -e 's/^$symcode* \([[^ ]]*\) \(lib[[^ ]]*\)$/ {\"\2\", (void *) \&\2},/p' -e 's/^$symcode* \([[^ ]]*\) \([[^ ]]*\)$/ {\"lib\2\", (void *) \&\2},/p'"
+
+# Handle CRLF in mingw tool chain
+opt_cr=
+case $build_os in
+mingw*)
+ opt_cr=`$ECHO 'x\{0,1\}' | tr x '\015'` # option cr in regexp
+ ;;
+esac
+
+# Try without a prefix underscore, then with it.
+for ac_symprfx in "" "_"; do
+
+ # Transform symcode, sympat, and symprfx into a raw symbol and a C symbol.
+ symxfrm="\\1 $ac_symprfx\\2 \\2"
+
+ # Write the raw and C identifiers.
+ if test "$lt_cv_nm_interface" = "MS dumpbin"; then
+ # Fake it for dumpbin and say T for any non-static function
+ # and D for any global variable.
+ # Also find C++ and __fastcall symbols from MSVC++,
+ # which start with @ or ?.
+ lt_cv_sys_global_symbol_pipe="$AWK ['"\
+" {last_section=section; section=\$ 3};"\
+" /^COFF SYMBOL TABLE/{for(i in hide) delete hide[i]};"\
+" /Section length .*#relocs.*(pick any)/{hide[last_section]=1};"\
+" \$ 0!~/External *\|/{next};"\
+" / 0+ UNDEF /{next}; / UNDEF \([^|]\)*()/{next};"\
+" {if(hide[section]) next};"\
+" {f=0}; \$ 0~/\(\).*\|/{f=1}; {printf f ? \"T \" : \"D \"};"\
+" {split(\$ 0, a, /\||\r/); split(a[2], s)};"\
+" s[1]~/^[@?]/{print s[1], s[1]; next};"\
+" s[1]~prfx {split(s[1],t,\"@\"); print t[1], substr(t[1],length(prfx))}"\
+" ' prfx=^$ac_symprfx]"
+ else
+ lt_cv_sys_global_symbol_pipe="sed -n -e 's/^.*[[ ]]\($symcode$symcode*\)[[ ]][[ ]]*$ac_symprfx$sympat$opt_cr$/$symxfrm/p'"
+ fi
+ lt_cv_sys_global_symbol_pipe="$lt_cv_sys_global_symbol_pipe | sed '/ __gnu_lto/d'"
+
+ # Check to see that the pipe works correctly.
+ pipe_works=no
+
+ rm -f conftest*
+ cat > conftest.$ac_ext <<_LT_EOF
+#ifdef __cplusplus
+extern "C" {
+#endif
+char nm_test_var;
+void nm_test_func(void);
+void nm_test_func(void){}
+#ifdef __cplusplus
+}
+#endif
+int main(){nm_test_var='a';nm_test_func();return(0);}
+_LT_EOF
+
+ if AC_TRY_EVAL(ac_compile); then
+ # Now try to grab the symbols.
+ nlist=conftest.nm
+ if AC_TRY_EVAL(NM conftest.$ac_objext \| "$lt_cv_sys_global_symbol_pipe" \> $nlist) && test -s "$nlist"; then
+ # Try sorting and uniquifying the output.
+ if sort "$nlist" | uniq > "$nlist"T; then
+ mv -f "$nlist"T "$nlist"
+ else
+ rm -f "$nlist"T
+ fi
+
+ # Make sure that we snagged all the symbols we need.
+ if $GREP ' nm_test_var$' "$nlist" >/dev/null; then
+ if $GREP ' nm_test_func$' "$nlist" >/dev/null; then
+ cat <<_LT_EOF > conftest.$ac_ext
+/* Keep this code in sync between libtool.m4, ltmain, lt_system.h, and tests. */
+#if defined(_WIN32) || defined(__CYGWIN__) || defined(_WIN32_WCE)
+/* DATA imports from DLLs on WIN32 con't be const, because runtime
+ relocations are performed -- see ld's documentation on pseudo-relocs. */
+# define LT@&t@_DLSYM_CONST
+#elif defined(__osf__)
+/* This system does not cope well with relocations in const data. */
+# define LT@&t@_DLSYM_CONST
+#else
+# define LT@&t@_DLSYM_CONST const
+#endif
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+_LT_EOF
+ # Now generate the symbol file.
+ eval "$lt_cv_sys_global_symbol_to_cdecl"' < "$nlist" | $GREP -v main >> conftest.$ac_ext'
+
+ cat <<_LT_EOF >> conftest.$ac_ext
+
+/* The mapping between symbol names and symbols. */
+LT@&t@_DLSYM_CONST struct {
+ const char *name;
+ void *address;
+}
+lt__PROGRAM__LTX_preloaded_symbols[[]] =
+{
+ { "@PROGRAM@", (void *) 0 },
+_LT_EOF
+ $SED "s/^$symcode$symcode* \(.*\) \(.*\)$/ {\"\2\", (void *) \&\2},/" < "$nlist" | $GREP -v main >> conftest.$ac_ext
+ cat <<\_LT_EOF >> conftest.$ac_ext
+ {0, (void *) 0}
+};
+
+/* This works around a problem in FreeBSD linker */
+#ifdef FREEBSD_WORKAROUND
+static const void *lt_preloaded_setup() {
+ return lt__PROGRAM__LTX_preloaded_symbols;
+}
+#endif
+
+#ifdef __cplusplus
+}
+#endif
+_LT_EOF
+ # Now try linking the two files.
+ mv conftest.$ac_objext conftstm.$ac_objext
+ lt_globsym_save_LIBS=$LIBS
+ lt_globsym_save_CFLAGS=$CFLAGS
+ LIBS="conftstm.$ac_objext"
+ CFLAGS="$CFLAGS$_LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)"
+ if AC_TRY_EVAL(ac_link) && test -s conftest${ac_exeext}; then
+ pipe_works=yes
+ fi
+ LIBS=$lt_globsym_save_LIBS
+ CFLAGS=$lt_globsym_save_CFLAGS
+ else
+ echo "cannot find nm_test_func in $nlist" >&AS_MESSAGE_LOG_FD
+ fi
+ else
+ echo "cannot find nm_test_var in $nlist" >&AS_MESSAGE_LOG_FD
+ fi
+ else
+ echo "cannot run $lt_cv_sys_global_symbol_pipe" >&AS_MESSAGE_LOG_FD
+ fi
+ else
+ echo "$progname: failed program was:" >&AS_MESSAGE_LOG_FD
+ cat conftest.$ac_ext >&5
+ fi
+ rm -rf conftest* conftst*
+
+ # Do not use the global_symbol_pipe unless it works.
+ if test "$pipe_works" = yes; then
+ break
+ else
+ lt_cv_sys_global_symbol_pipe=
+ fi
+done
+])
+if test -z "$lt_cv_sys_global_symbol_pipe"; then
+ lt_cv_sys_global_symbol_to_cdecl=
+fi
+if test -z "$lt_cv_sys_global_symbol_pipe$lt_cv_sys_global_symbol_to_cdecl"; then
+ AC_MSG_RESULT(failed)
+else
+ AC_MSG_RESULT(ok)
+fi
+
+# Response file support.
+if test "$lt_cv_nm_interface" = "MS dumpbin"; then
+ nm_file_list_spec='@'
+elif $NM --help 2>/dev/null | grep '[[@]]FILE' >/dev/null; then
+ nm_file_list_spec='@'
+fi
+
+_LT_DECL([global_symbol_pipe], [lt_cv_sys_global_symbol_pipe], [1],
+ [Take the output of nm and produce a listing of raw symbols and C names])
+_LT_DECL([global_symbol_to_cdecl], [lt_cv_sys_global_symbol_to_cdecl], [1],
+ [Transform the output of nm in a proper C declaration])
+_LT_DECL([global_symbol_to_c_name_address],
+ [lt_cv_sys_global_symbol_to_c_name_address], [1],
+ [Transform the output of nm in a C name address pair])
+_LT_DECL([global_symbol_to_c_name_address_lib_prefix],
+ [lt_cv_sys_global_symbol_to_c_name_address_lib_prefix], [1],
+ [Transform the output of nm in a C name address pair when lib prefix is needed])
+_LT_DECL([], [nm_file_list_spec], [1],
+ [Specify filename containing input files for $NM])
+]) # _LT_CMD_GLOBAL_SYMBOLS
+
+
+# _LT_COMPILER_PIC([TAGNAME])
+# ---------------------------
+m4_defun([_LT_COMPILER_PIC],
+[m4_require([_LT_TAG_COMPILER])dnl
+_LT_TAGVAR(lt_prog_compiler_wl, $1)=
+_LT_TAGVAR(lt_prog_compiler_pic, $1)=
+_LT_TAGVAR(lt_prog_compiler_static, $1)=
+
+m4_if([$1], [CXX], [
+ # C++ specific cases for pic, static, wl, etc.
+ if test "$GXX" = yes; then
+ _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+ _LT_TAGVAR(lt_prog_compiler_static, $1)='-static'
+
+ case $host_os in
+ aix*)
+ # All AIX code is PIC.
+ if test "$host_cpu" = ia64; then
+ # AIX 5 now supports IA64 processor
+ _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
+ fi
+ ;;
+
+ amigaos*)
+ case $host_cpu in
+ powerpc)
+ # see comment about AmigaOS4 .so support
+ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC'
+ ;;
+ m68k)
+ # FIXME: we need at least 68020 code to build shared libraries, but
+ # adding the `-m68020' flag to GCC prevents building anything better,
+ # like `-m68040'.
+ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-m68020 -resident32 -malways-restore-a4'
+ ;;
+ esac
+ ;;
+
+ beos* | irix5* | irix6* | nonstopux* | osf3* | osf4* | osf5*)
+ # PIC is the default for these OSes.
+ ;;
+ mingw* | cygwin* | os2* | pw32* | cegcc*)
+ # This hack is so that the source file can tell whether it is being
+ # built for inclusion in a dll (and should export symbols for example).
+ # Although the cygwin gcc ignores -fPIC, still need this for old-style
+ # (--disable-auto-import) libraries
+ m4_if([$1], [GCJ], [],
+ [_LT_TAGVAR(lt_prog_compiler_pic, $1)='-DDLL_EXPORT'])
+ ;;
+ darwin* | rhapsody*)
+ # PIC is the default on this platform
+ # Common symbols not allowed in MH_DYLIB files
+ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fno-common'
+ ;;
+ *djgpp*)
+ # DJGPP does not support shared libraries at all
+ _LT_TAGVAR(lt_prog_compiler_pic, $1)=
+ ;;
+ haiku*)
+ # PIC is the default for Haiku.
+ # The "-static" flag exists, but is broken.
+ _LT_TAGVAR(lt_prog_compiler_static, $1)=
+ ;;
+ interix[[3-9]]*)
+ # Interix 3.x gcc -fpic/-fPIC options generate broken code.
+ # Instead, we relocate shared libraries at runtime.
+ ;;
+ sysv4*MP*)
+ if test -d /usr/nec; then
+ _LT_TAGVAR(lt_prog_compiler_pic, $1)=-Kconform_pic
+ fi
+ ;;
+ hpux*)
+ # PIC is the default for 64-bit PA HP-UX, but not for 32-bit
+ # PA HP-UX. On IA64 HP-UX, PIC is the default but the pic flag
+ # sets the default TLS model and affects inlining.
+ case $host_cpu in
+ hppa*64*)
+ ;;
+ *)
+ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC'
+ ;;
+ esac
+ ;;
+ *qnx* | *nto*)
+ # QNX uses GNU C++, but need to define -shared option too, otherwise
+ # it will coredump.
+ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC -shared'
+ ;;
+ *)
+ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC'
+ ;;
+ esac
+ else
+ case $host_os in
+ aix[[4-9]]*)
+ # All AIX code is PIC.
+ if test "$host_cpu" = ia64; then
+ # AIX 5 now supports IA64 processor
+ _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
+ else
+ _LT_TAGVAR(lt_prog_compiler_static, $1)='-bnso -bI:/lib/syscalls.exp'
+ fi
+ ;;
+ chorus*)
+ case $cc_basename in
+ cxch68*)
+ # Green Hills C++ Compiler
+ # _LT_TAGVAR(lt_prog_compiler_static, $1)="--no_auto_instantiation -u __main -u __premain -u _abort -r $COOL_DIR/lib/libOrb.a $MVME_DIR/lib/CC/libC.a $MVME_DIR/lib/classix/libcx.s.a"
+ ;;
+ esac
+ ;;
+ mingw* | cygwin* | os2* | pw32* | cegcc*)
+ # This hack is so that the source file can tell whether it is being
+ # built for inclusion in a dll (and should export symbols for example).
+ m4_if([$1], [GCJ], [],
+ [_LT_TAGVAR(lt_prog_compiler_pic, $1)='-DDLL_EXPORT'])
+ ;;
+ dgux*)
+ case $cc_basename in
+ ec++*)
+ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
+ ;;
+ ghcx*)
+ # Green Hills C++ Compiler
+ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-pic'
+ ;;
+ *)
+ ;;
+ esac
+ ;;
+ freebsd* | dragonfly*)
+ # FreeBSD uses GNU C++
+ ;;
+ hpux9* | hpux10* | hpux11*)
+ case $cc_basename in
+ CC*)
+ _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+ _LT_TAGVAR(lt_prog_compiler_static, $1)='${wl}-a ${wl}archive'
+ if test "$host_cpu" != ia64; then
+ _LT_TAGVAR(lt_prog_compiler_pic, $1)='+Z'
+ fi
+ ;;
+ aCC*)
+ _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+ _LT_TAGVAR(lt_prog_compiler_static, $1)='${wl}-a ${wl}archive'
+ case $host_cpu in
+ hppa*64*|ia64*)
+ # +Z the default
+ ;;
+ *)
+ _LT_TAGVAR(lt_prog_compiler_pic, $1)='+Z'
+ ;;
+ esac
+ ;;
+ *)
+ ;;
+ esac
+ ;;
+ interix*)
+ # This is c89, which is MS Visual C++ (no shared libs)
+ # Anyone wants to do a port?
+ ;;
+ irix5* | irix6* | nonstopux*)
+ case $cc_basename in
+ CC*)
+ _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+ _LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared'
+ # CC pic flag -KPIC is the default.
+ ;;
+ *)
+ ;;
+ esac
+ ;;
+ linux* | k*bsd*-gnu | kopensolaris*-gnu)
+ case $cc_basename in
+ KCC*)
+ # KAI C++ Compiler
+ _LT_TAGVAR(lt_prog_compiler_wl, $1)='--backend -Wl,'
+ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC'
+ ;;
+ ecpc* )
+ # old Intel C++ for x86_64 which still supported -KPIC.
+ _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
+ _LT_TAGVAR(lt_prog_compiler_static, $1)='-static'
+ ;;
+ icpc* )
+ # Intel C++, used to be incompatible with GCC.
+ # ICC 10 doesn't accept -KPIC any more.
+ _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC'
+ _LT_TAGVAR(lt_prog_compiler_static, $1)='-static'
+ ;;
+ pgCC* | pgcpp*)
+ # Portland Group C++ compiler
+ _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fpic'
+ _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
+ ;;
+ cxx*)
+ # Compaq C++
+ # Make sure the PIC flag is empty. It appears that all Alpha
+ # Linux and Compaq Tru64 Unix objects are PIC.
+ _LT_TAGVAR(lt_prog_compiler_pic, $1)=
+ _LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared'
+ ;;
+ xlc* | xlC* | bgxl[[cC]]* | mpixl[[cC]]*)
+ # IBM XL 8.0, 9.0 on PPC and BlueGene
+ _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-qpic'
+ _LT_TAGVAR(lt_prog_compiler_static, $1)='-qstaticlink'
+ ;;
+ *)
+ case `$CC -V 2>&1 | sed 5q` in
+ *Sun\ C*)
+ # Sun C++ 5.9
+ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
+ _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
+ _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Qoption ld '
+ ;;
+ esac
+ ;;
+ esac
+ ;;
+ lynxos*)
+ ;;
+ m88k*)
+ ;;
+ mvs*)
+ case $cc_basename in
+ cxx*)
+ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-W c,exportall'
+ ;;
+ *)
+ ;;
+ esac
+ ;;
+ netbsd*)
+ ;;
+ *qnx* | *nto*)
+ # QNX uses GNU C++, but need to define -shared option too, otherwise
+ # it will coredump.
+ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC -shared'
+ ;;
+ osf3* | osf4* | osf5*)
+ case $cc_basename in
+ KCC*)
+ _LT_TAGVAR(lt_prog_compiler_wl, $1)='--backend -Wl,'
+ ;;
+ RCC*)
+ # Rational C++ 2.4.1
+ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-pic'
+ ;;
+ cxx*)
+ # Digital/Compaq C++
+ _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+ # Make sure the PIC flag is empty. It appears that all Alpha
+ # Linux and Compaq Tru64 Unix objects are PIC.
+ _LT_TAGVAR(lt_prog_compiler_pic, $1)=
+ _LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared'
+ ;;
+ *)
+ ;;
+ esac
+ ;;
+ psos*)
+ ;;
+ solaris*)
+ case $cc_basename in
+ CC* | sunCC*)
+ # Sun C++ 4.2, 5.x and Centerline C++
+ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
+ _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
+ _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Qoption ld '
+ ;;
+ gcx*)
+ # Green Hills C++ Compiler
+ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-PIC'
+ ;;
+ *)
+ ;;
+ esac
+ ;;
+ sunos4*)
+ case $cc_basename in
+ CC*)
+ # Sun C++ 4.x
+ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-pic'
+ _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
+ ;;
+ lcc*)
+ # Lucid
+ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-pic'
+ ;;
+ *)
+ ;;
+ esac
+ ;;
+ sysv5* | unixware* | sco3.2v5* | sco5v6* | OpenUNIX*)
+ case $cc_basename in
+ CC*)
+ _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
+ _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
+ ;;
+ esac
+ ;;
+ tandem*)
+ case $cc_basename in
+ NCC*)
+ # NonStop-UX NCC 3.20
+ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
+ ;;
+ *)
+ ;;
+ esac
+ ;;
+ vxworks*)
+ ;;
+ *)
+ _LT_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no
+ ;;
+ esac
+ fi
+],
+[
+ if test "$GCC" = yes; then
+ _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+ _LT_TAGVAR(lt_prog_compiler_static, $1)='-static'
+
+ case $host_os in
+ aix*)
+ # All AIX code is PIC.
+ if test "$host_cpu" = ia64; then
+ # AIX 5 now supports IA64 processor
+ _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
+ fi
+ ;;
+
+ amigaos*)
+ case $host_cpu in
+ powerpc)
+ # see comment about AmigaOS4 .so support
+ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC'
+ ;;
+ m68k)
+ # FIXME: we need at least 68020 code to build shared libraries, but
+ # adding the `-m68020' flag to GCC prevents building anything better,
+ # like `-m68040'.
+ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-m68020 -resident32 -malways-restore-a4'
+ ;;
+ esac
+ ;;
+
+ beos* | irix5* | irix6* | nonstopux* | osf3* | osf4* | osf5*)
+ # PIC is the default for these OSes.
+ ;;
+
+ mingw* | cygwin* | pw32* | os2* | cegcc*)
+ # This hack is so that the source file can tell whether it is being
+ # built for inclusion in a dll (and should export symbols for example).
+ # Although the cygwin gcc ignores -fPIC, still need this for old-style
+ # (--disable-auto-import) libraries
+ m4_if([$1], [GCJ], [],
+ [_LT_TAGVAR(lt_prog_compiler_pic, $1)='-DDLL_EXPORT'])
+ ;;
+
+ darwin* | rhapsody*)
+ # PIC is the default on this platform
+ # Common symbols not allowed in MH_DYLIB files
+ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fno-common'
+ ;;
+
+ haiku*)
+ # PIC is the default for Haiku.
+ # The "-static" flag exists, but is broken.
+ _LT_TAGVAR(lt_prog_compiler_static, $1)=
+ ;;
+
+ hpux*)
+ # PIC is the default for 64-bit PA HP-UX, but not for 32-bit
+ # PA HP-UX. On IA64 HP-UX, PIC is the default but the pic flag
+ # sets the default TLS model and affects inlining.
+ case $host_cpu in
+ hppa*64*)
+ # +Z the default
+ ;;
+ *)
+ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC'
+ ;;
+ esac
+ ;;
+
+ interix[[3-9]]*)
+ # Interix 3.x gcc -fpic/-fPIC options generate broken code.
+ # Instead, we relocate shared libraries at runtime.
+ ;;
+
+ msdosdjgpp*)
+ # Just because we use GCC doesn't mean we suddenly get shared libraries
+ # on systems that don't support them.
+ _LT_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no
+ enable_shared=no
+ ;;
+
+ *nto* | *qnx*)
+ # QNX uses GNU C++, but need to define -shared option too, otherwise
+ # it will coredump.
+ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC -shared'
+ ;;
+
+ sysv4*MP*)
+ if test -d /usr/nec; then
+ _LT_TAGVAR(lt_prog_compiler_pic, $1)=-Kconform_pic
+ fi
+ ;;
+
+ *)
+ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC'
+ ;;
+ esac
+
+ case $cc_basename in
+ nvcc*) # Cuda Compiler Driver 2.2
+ _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Xlinker '
+ if test -n "$_LT_TAGVAR(lt_prog_compiler_pic, $1)"; then
+ _LT_TAGVAR(lt_prog_compiler_pic, $1)="-Xcompiler $_LT_TAGVAR(lt_prog_compiler_pic, $1)"
+ fi
+ ;;
+ esac
+ else
+ # PORTME Check for flag to pass linker flags through the system compiler.
+ case $host_os in
+ aix*)
+ _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+ if test "$host_cpu" = ia64; then
+ # AIX 5 now supports IA64 processor
+ _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
+ else
+ _LT_TAGVAR(lt_prog_compiler_static, $1)='-bnso -bI:/lib/syscalls.exp'
+ fi
+ ;;
+
+ mingw* | cygwin* | pw32* | os2* | cegcc*)
+ # This hack is so that the source file can tell whether it is being
+ # built for inclusion in a dll (and should export symbols for example).
+ m4_if([$1], [GCJ], [],
+ [_LT_TAGVAR(lt_prog_compiler_pic, $1)='-DDLL_EXPORT'])
+ ;;
+
+ hpux9* | hpux10* | hpux11*)
+ _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+ # PIC is the default for IA64 HP-UX and 64-bit HP-UX, but
+ # not for PA HP-UX.
+ case $host_cpu in
+ hppa*64*|ia64*)
+ # +Z the default
+ ;;
+ *)
+ _LT_TAGVAR(lt_prog_compiler_pic, $1)='+Z'
+ ;;
+ esac
+ # Is there a better lt_prog_compiler_static that works with the bundled CC?
+ _LT_TAGVAR(lt_prog_compiler_static, $1)='${wl}-a ${wl}archive'
+ ;;
+
+ irix5* | irix6* | nonstopux*)
+ _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+ # PIC (with -KPIC) is the default.
+ _LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared'
+ ;;
+
+ linux* | k*bsd*-gnu | kopensolaris*-gnu)
+ case $cc_basename in
+ # old Intel for x86_64 which still supported -KPIC.
+ ecc*)
+ _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
+ _LT_TAGVAR(lt_prog_compiler_static, $1)='-static'
+ ;;
+ # icc used to be incompatible with GCC.
+ # ICC 10 doesn't accept -KPIC any more.
+ icc* | ifort*)
+ _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC'
+ _LT_TAGVAR(lt_prog_compiler_static, $1)='-static'
+ ;;
+ # Lahey Fortran 8.1.
+ lf95*)
+ _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+ _LT_TAGVAR(lt_prog_compiler_pic, $1)='--shared'
+ _LT_TAGVAR(lt_prog_compiler_static, $1)='--static'
+ ;;
+ nagfor*)
+ # NAG Fortran compiler
+ _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,-Wl,,'
+ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-PIC'
+ _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
+ ;;
+ pgcc* | pgf77* | pgf90* | pgf95* | pgfortran*)
+ # Portland Group compilers (*not* the Pentium gcc compiler,
+ # which looks to be a dead project)
+ _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fpic'
+ _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
+ ;;
+ ccc*)
+ _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+ # All Alpha code is PIC.
+ _LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared'
+ ;;
+ xl* | bgxl* | bgf* | mpixl*)
+ # IBM XL C 8.0/Fortran 10.1, 11.1 on PPC and BlueGene
+ _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-qpic'
+ _LT_TAGVAR(lt_prog_compiler_static, $1)='-qstaticlink'
+ ;;
+ *)
+ case `$CC -V 2>&1 | sed 5q` in
+ *Sun\ Ceres\ Fortran* | *Sun*Fortran*\ [[1-7]].* | *Sun*Fortran*\ 8.[[0-3]]*)
+ # Sun Fortran 8.3 passes all unrecognized flags to the linker
+ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
+ _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
+ _LT_TAGVAR(lt_prog_compiler_wl, $1)=''
+ ;;
+ *Sun\ F* | *Sun*Fortran*)
+ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
+ _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
+ _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Qoption ld '
+ ;;
+ *Sun\ C*)
+ # Sun C 5.9
+ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
+ _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
+ _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+ ;;
+ *Intel*\ [[CF]]*Compiler*)
+ _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC'
+ _LT_TAGVAR(lt_prog_compiler_static, $1)='-static'
+ ;;
+ *Portland\ Group*)
+ _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fpic'
+ _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
+ ;;
+ esac
+ ;;
+ esac
+ ;;
+
+ newsos6)
+ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
+ _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
+ ;;
+
+ *nto* | *qnx*)
+ # QNX uses GNU C++, but need to define -shared option too, otherwise
+ # it will coredump.
+ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC -shared'
+ ;;
+
+ osf3* | osf4* | osf5*)
+ _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+ # All OSF/1 code is PIC.
+ _LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared'
+ ;;
+
+ rdos*)
+ _LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared'
+ ;;
+
+ solaris*)
+ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
+ _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
+ case $cc_basename in
+ f77* | f90* | f95* | sunf77* | sunf90* | sunf95*)
+ _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Qoption ld ';;
+ *)
+ _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,';;
+ esac
+ ;;
+
+ sunos4*)
+ _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Qoption ld '
+ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-PIC'
+ _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
+ ;;
+
+ sysv4 | sysv4.2uw2* | sysv4.3*)
+ _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
+ _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
+ ;;
+
+ sysv4*MP*)
+ if test -d /usr/nec ;then
+ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-Kconform_pic'
+ _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
+ fi
+ ;;
+
+ sysv5* | unixware* | sco3.2v5* | sco5v6* | OpenUNIX*)
+ _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
+ _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
+ ;;
+
+ unicos*)
+ _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+ _LT_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no
+ ;;
+
+ uts4*)
+ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-pic'
+ _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
+ ;;
+
+ *)
+ _LT_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no
+ ;;
+ esac
+ fi
+])
+case $host_os in
+ # For platforms which do not support PIC, -DPIC is meaningless:
+ *djgpp*)
+ _LT_TAGVAR(lt_prog_compiler_pic, $1)=
+ ;;
+ *)
+ _LT_TAGVAR(lt_prog_compiler_pic, $1)="$_LT_TAGVAR(lt_prog_compiler_pic, $1)@&t@m4_if([$1],[],[ -DPIC],[m4_if([$1],[CXX],[ -DPIC],[])])"
+ ;;
+esac
+
+AC_CACHE_CHECK([for $compiler option to produce PIC],
+ [_LT_TAGVAR(lt_cv_prog_compiler_pic, $1)],
+ [_LT_TAGVAR(lt_cv_prog_compiler_pic, $1)=$_LT_TAGVAR(lt_prog_compiler_pic, $1)])
+_LT_TAGVAR(lt_prog_compiler_pic, $1)=$_LT_TAGVAR(lt_cv_prog_compiler_pic, $1)
+
+#
+# Check to make sure the PIC flag actually works.
+#
+if test -n "$_LT_TAGVAR(lt_prog_compiler_pic, $1)"; then
+ _LT_COMPILER_OPTION([if $compiler PIC flag $_LT_TAGVAR(lt_prog_compiler_pic, $1) works],
+ [_LT_TAGVAR(lt_cv_prog_compiler_pic_works, $1)],
+ [$_LT_TAGVAR(lt_prog_compiler_pic, $1)@&t@m4_if([$1],[],[ -DPIC],[m4_if([$1],[CXX],[ -DPIC],[])])], [],
+ [case $_LT_TAGVAR(lt_prog_compiler_pic, $1) in
+ "" | " "*) ;;
+ *) _LT_TAGVAR(lt_prog_compiler_pic, $1)=" $_LT_TAGVAR(lt_prog_compiler_pic, $1)" ;;
+ esac],
+ [_LT_TAGVAR(lt_prog_compiler_pic, $1)=
+ _LT_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no])
+fi
+_LT_TAGDECL([pic_flag], [lt_prog_compiler_pic], [1],
+ [Additional compiler flags for building library objects])
+
+_LT_TAGDECL([wl], [lt_prog_compiler_wl], [1],
+ [How to pass a linker flag through the compiler])
+#
+# Check to make sure the static flag actually works.
+#
+wl=$_LT_TAGVAR(lt_prog_compiler_wl, $1) eval lt_tmp_static_flag=\"$_LT_TAGVAR(lt_prog_compiler_static, $1)\"
+_LT_LINKER_OPTION([if $compiler static flag $lt_tmp_static_flag works],
+ _LT_TAGVAR(lt_cv_prog_compiler_static_works, $1),
+ $lt_tmp_static_flag,
+ [],
+ [_LT_TAGVAR(lt_prog_compiler_static, $1)=])
+_LT_TAGDECL([link_static_flag], [lt_prog_compiler_static], [1],
+ [Compiler flag to prevent dynamic linking])
+])# _LT_COMPILER_PIC
+
+
+# _LT_LINKER_SHLIBS([TAGNAME])
+# ----------------------------
+# See if the linker supports building shared libraries.
+m4_defun([_LT_LINKER_SHLIBS],
+[AC_REQUIRE([LT_PATH_LD])dnl
+AC_REQUIRE([LT_PATH_NM])dnl
+m4_require([_LT_PATH_MANIFEST_TOOL])dnl
+m4_require([_LT_FILEUTILS_DEFAULTS])dnl
+m4_require([_LT_DECL_EGREP])dnl
+m4_require([_LT_DECL_SED])dnl
+m4_require([_LT_CMD_GLOBAL_SYMBOLS])dnl
+m4_require([_LT_TAG_COMPILER])dnl
+AC_MSG_CHECKING([whether the $compiler linker ($LD) supports shared libraries])
+m4_if([$1], [CXX], [
+ _LT_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols'
+ _LT_TAGVAR(exclude_expsyms, $1)=['_GLOBAL_OFFSET_TABLE_|_GLOBAL__F[ID]_.*']
+ case $host_os in
+ aix[[4-9]]*)
+ # If we're using GNU nm, then we don't want the "-C" option.
+ # -C means demangle to AIX nm, but means don't demangle with GNU nm
+ # Also, AIX nm treats weak defined symbols like other global defined
+ # symbols, whereas GNU nm marks them as "W".
+ if $NM -V 2>&1 | $GREP 'GNU' > /dev/null; then
+ _LT_TAGVAR(export_symbols_cmds, $1)='$NM -Bpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B") || (\$ 2 == "W")) && ([substr](\$ 3,1,1) != ".")) { print \$ 3 } }'\'' | sort -u > $export_symbols'
+ else
+ _LT_TAGVAR(export_symbols_cmds, $1)='$NM -BCpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B")) && ([substr](\$ 3,1,1) != ".")) { print \$ 3 } }'\'' | sort -u > $export_symbols'
+ fi
+ ;;
+ pw32*)
+ _LT_TAGVAR(export_symbols_cmds, $1)="$ltdll_cmds"
+ ;;
+ cygwin* | mingw* | cegcc*)
+ case $cc_basename in
+ cl*)
+ _LT_TAGVAR(exclude_expsyms, $1)='_NULL_IMPORT_DESCRIPTOR|_IMPORT_DESCRIPTOR_.*'
+ ;;
+ *)
+ _LT_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[[BCDGRS]][[ ]]/s/.*[[ ]]\([[^ ]]*\)/\1 DATA/;s/^.*[[ ]]__nm__\([[^ ]]*\)[[ ]][[^ ]]*/\1 DATA/;/^I[[ ]]/d;/^[[AITW]][[ ]]/s/.* //'\'' | sort | uniq > $export_symbols'
+ _LT_TAGVAR(exclude_expsyms, $1)=['[_]+GLOBAL_OFFSET_TABLE_|[_]+GLOBAL__[FID]_.*|[_]+head_[A-Za-z0-9_]+_dll|[A-Za-z0-9_]+_dll_iname']
+ ;;
+ esac
+ ;;
+ *)
+ _LT_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols'
+ ;;
+ esac
+], [
+ runpath_var=
+ _LT_TAGVAR(allow_undefined_flag, $1)=
+ _LT_TAGVAR(always_export_symbols, $1)=no
+ _LT_TAGVAR(archive_cmds, $1)=
+ _LT_TAGVAR(archive_expsym_cmds, $1)=
+ _LT_TAGVAR(compiler_needs_object, $1)=no
+ _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=no
+ _LT_TAGVAR(export_dynamic_flag_spec, $1)=
+ _LT_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols'
+ _LT_TAGVAR(hardcode_automatic, $1)=no
+ _LT_TAGVAR(hardcode_direct, $1)=no
+ _LT_TAGVAR(hardcode_direct_absolute, $1)=no
+ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)=
+ _LT_TAGVAR(hardcode_libdir_separator, $1)=
+ _LT_TAGVAR(hardcode_minus_L, $1)=no
+ _LT_TAGVAR(hardcode_shlibpath_var, $1)=unsupported
+ _LT_TAGVAR(inherit_rpath, $1)=no
+ _LT_TAGVAR(link_all_deplibs, $1)=unknown
+ _LT_TAGVAR(module_cmds, $1)=
+ _LT_TAGVAR(module_expsym_cmds, $1)=
+ _LT_TAGVAR(old_archive_from_new_cmds, $1)=
+ _LT_TAGVAR(old_archive_from_expsyms_cmds, $1)=
+ _LT_TAGVAR(thread_safe_flag_spec, $1)=
+ _LT_TAGVAR(whole_archive_flag_spec, $1)=
+ # include_expsyms should be a list of space-separated symbols to be *always*
+ # included in the symbol list
+ _LT_TAGVAR(include_expsyms, $1)=
+ # exclude_expsyms can be an extended regexp of symbols to exclude
+ # it will be wrapped by ` (' and `)$', so one must not match beginning or
+ # end of line. Example: `a|bc|.*d.*' will exclude the symbols `a' and `bc',
+ # as well as any symbol that contains `d'.
+ _LT_TAGVAR(exclude_expsyms, $1)=['_GLOBAL_OFFSET_TABLE_|_GLOBAL__F[ID]_.*']
+ # Although _GLOBAL_OFFSET_TABLE_ is a valid symbol C name, most a.out
+ # platforms (ab)use it in PIC code, but their linkers get confused if
+ # the symbol is explicitly referenced. Since portable code cannot
+ # rely on this symbol name, it's probably fine to never include it in
+ # preloaded symbol tables.
+ # Exclude shared library initialization/finalization symbols.
+dnl Note also adjust exclude_expsyms for C++ above.
+ extract_expsyms_cmds=
+
+ case $host_os in
+ cygwin* | mingw* | pw32* | cegcc*)
+ # FIXME: the MSVC++ port hasn't been tested in a loooong time
+ # When not using gcc, we currently assume that we are using
+ # Microsoft Visual C++.
+ if test "$GCC" != yes; then
+ with_gnu_ld=no
+ fi
+ ;;
+ interix*)
+ # we just hope/assume this is gcc and not c89 (= MSVC++)
+ with_gnu_ld=yes
+ ;;
+ openbsd*)
+ with_gnu_ld=no
+ ;;
+ esac
+
+ _LT_TAGVAR(ld_shlibs, $1)=yes
+
+ # On some targets, GNU ld is compatible enough with the native linker
+ # that we're better off using the native interface for both.
+ lt_use_gnu_ld_interface=no
+ if test "$with_gnu_ld" = yes; then
+ case $host_os in
+ aix*)
+ # The AIX port of GNU ld has always aspired to compatibility
+ # with the native linker. However, as the warning in the GNU ld
+ # block says, versions before 2.19.5* couldn't really create working
+ # shared libraries, regardless of the interface used.
+ case `$LD -v 2>&1` in
+ *\ \(GNU\ Binutils\)\ 2.19.5*) ;;
+ *\ \(GNU\ Binutils\)\ 2.[[2-9]]*) ;;
+ *\ \(GNU\ Binutils\)\ [[3-9]]*) ;;
+ *)
+ lt_use_gnu_ld_interface=yes
+ ;;
+ esac
+ ;;
+ *)
+ lt_use_gnu_ld_interface=yes
+ ;;
+ esac
+ fi
+
+ if test "$lt_use_gnu_ld_interface" = yes; then
+ # If archive_cmds runs LD, not CC, wlarc should be empty
+ wlarc='${wl}'
+
+ # Set some defaults for GNU ld with shared library support. These
+ # are reset later if shared libraries are not supported. Putting them
+ # here allows them to be overridden if necessary.
+ runpath_var=LD_RUN_PATH
+ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
+ _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic'
+ # ancient GNU ld didn't support --whole-archive et. al.
+ if $LD --help 2>&1 | $GREP 'no-whole-archive' > /dev/null; then
+ _LT_TAGVAR(whole_archive_flag_spec, $1)="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive'
+ else
+ _LT_TAGVAR(whole_archive_flag_spec, $1)=
+ fi
+ supports_anon_versioning=no
+ case `$LD -v 2>&1` in
+ *GNU\ gold*) supports_anon_versioning=yes ;;
+ *\ [[01]].* | *\ 2.[[0-9]].* | *\ 2.10.*) ;; # catch versions < 2.11
+ *\ 2.11.93.0.2\ *) supports_anon_versioning=yes ;; # RH7.3 ...
+ *\ 2.11.92.0.12\ *) supports_anon_versioning=yes ;; # Mandrake 8.2 ...
+ *\ 2.11.*) ;; # other 2.11 versions
+ *) supports_anon_versioning=yes ;;
+ esac
+
+ # See if GNU ld supports shared libraries.
+ case $host_os in
+ aix[[3-9]]*)
+ # On AIX/PPC, the GNU linker is very broken
+ if test "$host_cpu" != ia64; then
+ _LT_TAGVAR(ld_shlibs, $1)=no
+ cat <<_LT_EOF 1>&2
+
+*** Warning: the GNU linker, at least up to release 2.19, is reported
+*** to be unable to reliably create shared libraries on AIX.
+*** Therefore, libtool is disabling shared libraries support. If you
+*** really care for shared libraries, you may want to install binutils
+*** 2.20 or above, or modify your PATH so that a non-GNU linker is found.
+*** You will then need to restart the configuration process.
+
+_LT_EOF
+ fi
+ ;;
+
+ amigaos*)
+ case $host_cpu in
+ powerpc)
+ # see comment about AmigaOS4 .so support
+ _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+ _LT_TAGVAR(archive_expsym_cmds, $1)=''
+ ;;
+ m68k)
+ _LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/a2ixlibrary.data~$ECHO "#define NAME $libname" > $output_objdir/a2ixlibrary.data~$ECHO "#define LIBRARY_ID 1" >> $output_objdir/a2ixlibrary.data~$ECHO "#define VERSION $major" >> $output_objdir/a2ixlibrary.data~$ECHO "#define REVISION $revision" >> $output_objdir/a2ixlibrary.data~$AR $AR_FLAGS $lib $libobjs~$RANLIB $lib~(cd $output_objdir && a2ixlibrary -32)'
+ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
+ _LT_TAGVAR(hardcode_minus_L, $1)=yes
+ ;;
+ esac
+ ;;
+
+ beos*)
+ if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then
+ _LT_TAGVAR(allow_undefined_flag, $1)=unsupported
+ # Joseph Beckenbach <jrb3@best.com> says some releases of gcc
+ # support --undefined. This deserves some investigation. FIXME
+ _LT_TAGVAR(archive_cmds, $1)='$CC -nostart $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+ else
+ _LT_TAGVAR(ld_shlibs, $1)=no
+ fi
+ ;;
+
+ cygwin* | mingw* | pw32* | cegcc*)
+ # _LT_TAGVAR(hardcode_libdir_flag_spec, $1) is actually meaningless,
+ # as there is no search path for DLLs.
+ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
+ _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-all-symbols'
+ _LT_TAGVAR(allow_undefined_flag, $1)=unsupported
+ _LT_TAGVAR(always_export_symbols, $1)=no
+ _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=yes
+ _LT_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[[BCDGRS]][[ ]]/s/.*[[ ]]\([[^ ]]*\)/\1 DATA/;s/^.*[[ ]]__nm__\([[^ ]]*\)[[ ]][[^ ]]*/\1 DATA/;/^I[[ ]]/d;/^[[AITW]][[ ]]/s/.* //'\'' | sort | uniq > $export_symbols'
+ _LT_TAGVAR(exclude_expsyms, $1)=['[_]+GLOBAL_OFFSET_TABLE_|[_]+GLOBAL__[FID]_.*|[_]+head_[A-Za-z0-9_]+_dll|[A-Za-z0-9_]+_dll_iname']
+
+ if $LD --help 2>&1 | $GREP 'auto-import' > /dev/null; then
+ _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib'
+ # If the export-symbols file already is a .def file (1st line
+ # is EXPORTS), use it as is; otherwise, prepend...
+ _LT_TAGVAR(archive_expsym_cmds, $1)='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then
+ cp $export_symbols $output_objdir/$soname.def;
+ else
+ echo EXPORTS > $output_objdir/$soname.def;
+ cat $export_symbols >> $output_objdir/$soname.def;
+ fi~
+ $CC -shared $output_objdir/$soname.def $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib'
+ else
+ _LT_TAGVAR(ld_shlibs, $1)=no
+ fi
+ ;;
+
+ haiku*)
+ _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+ _LT_TAGVAR(link_all_deplibs, $1)=yes
+ ;;
+
+ interix[[3-9]]*)
+ _LT_TAGVAR(hardcode_direct, $1)=no
+ _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
+ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir'
+ _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E'
+ # Hack: On Interix 3.x, we cannot compile PIC because of a broken gcc.
+ # Instead, shared libraries are loaded at an image base (0x10000000 by
+ # default) and relocated if they conflict, which is a slow very memory
+ # consuming and fragmenting process. To avoid this, we pick a random,
+ # 256 KiB-aligned image base between 0x50000000 and 0x6FFC0000 at link
+ # time. Moving up from 0x10000000 also allows more sbrk(2) space.
+ _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib'
+ _LT_TAGVAR(archive_expsym_cmds, $1)='sed "s,^,_," $export_symbols >$output_objdir/$soname.expsym~$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--retain-symbols-file,$output_objdir/$soname.expsym ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib'
+ ;;
+
+ gnu* | linux* | tpf* | k*bsd*-gnu | kopensolaris*-gnu)
+ tmp_diet=no
+ if test "$host_os" = linux-dietlibc; then
+ case $cc_basename in
+ diet\ *) tmp_diet=yes;; # linux-dietlibc with static linking (!diet-dyn)
+ esac
+ fi
+ if $LD --help 2>&1 | $EGREP ': supported targets:.* elf' > /dev/null \
+ && test "$tmp_diet" = no
+ then
+ tmp_addflag=' $pic_flag'
+ tmp_sharedflag='-shared'
+ case $cc_basename,$host_cpu in
+ pgcc*) # Portland Group C compiler
+ _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` ${wl}--no-whole-archive'
+ tmp_addflag=' $pic_flag'
+ ;;
+ pgf77* | pgf90* | pgf95* | pgfortran*)
+ # Portland Group f77 and f90 compilers
+ _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` ${wl}--no-whole-archive'
+ tmp_addflag=' $pic_flag -Mnomain' ;;
+ ecc*,ia64* | icc*,ia64*) # Intel C compiler on ia64
+ tmp_addflag=' -i_dynamic' ;;
+ efc*,ia64* | ifort*,ia64*) # Intel Fortran compiler on ia64
+ tmp_addflag=' -i_dynamic -nofor_main' ;;
+ ifc* | ifort*) # Intel Fortran compiler
+ tmp_addflag=' -nofor_main' ;;
+ lf95*) # Lahey Fortran 8.1
+ _LT_TAGVAR(whole_archive_flag_spec, $1)=
+ tmp_sharedflag='--shared' ;;
+ xl[[cC]]* | bgxl[[cC]]* | mpixl[[cC]]*) # IBM XL C 8.0 on PPC (deal with xlf below)
+ tmp_sharedflag='-qmkshrobj'
+ tmp_addflag= ;;
+ nvcc*) # Cuda Compiler Driver 2.2
+ _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` ${wl}--no-whole-archive'
+ _LT_TAGVAR(compiler_needs_object, $1)=yes
+ ;;
+ esac
+ case `$CC -V 2>&1 | sed 5q` in
+ *Sun\ C*) # Sun C 5.9
+ _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive`new_convenience=; for conv in $convenience\"\"; do test -z \"$conv\" || new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` ${wl}--no-whole-archive'
+ _LT_TAGVAR(compiler_needs_object, $1)=yes
+ tmp_sharedflag='-G' ;;
+ *Sun\ F*) # Sun Fortran 8.3
+ tmp_sharedflag='-G' ;;
+ esac
+ _LT_TAGVAR(archive_cmds, $1)='$CC '"$tmp_sharedflag""$tmp_addflag"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+
+ if test "x$supports_anon_versioning" = xyes; then
+ _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $output_objdir/$libname.ver~
+ cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~
+ echo "local: *; };" >> $output_objdir/$libname.ver~
+ $CC '"$tmp_sharedflag""$tmp_addflag"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-version-script ${wl}$output_objdir/$libname.ver -o $lib'
+ fi
+
+ case $cc_basename in
+ xlf* | bgf* | bgxlf* | mpixlf*)
+ # IBM XL Fortran 10.1 on PPC cannot create shared libs itself
+ _LT_TAGVAR(whole_archive_flag_spec, $1)='--whole-archive$convenience --no-whole-archive'
+ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
+ _LT_TAGVAR(archive_cmds, $1)='$LD -shared $libobjs $deplibs $linker_flags -soname $soname -o $lib'
+ if test "x$supports_anon_versioning" = xyes; then
+ _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $output_objdir/$libname.ver~
+ cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~
+ echo "local: *; };" >> $output_objdir/$libname.ver~
+ $LD -shared $libobjs $deplibs $linker_flags -soname $soname -version-script $output_objdir/$libname.ver -o $lib'
+ fi
+ ;;
+ esac
+ else
+ _LT_TAGVAR(ld_shlibs, $1)=no
+ fi
+ ;;
+
+ netbsd*)
+ if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then
+ _LT_TAGVAR(archive_cmds, $1)='$LD -Bshareable $libobjs $deplibs $linker_flags -o $lib'
+ wlarc=
+ else
+ _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+ _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
+ fi
+ ;;
+
+ solaris*)
+ if $LD -v 2>&1 | $GREP 'BFD 2\.8' > /dev/null; then
+ _LT_TAGVAR(ld_shlibs, $1)=no
+ cat <<_LT_EOF 1>&2
+
+*** Warning: The releases 2.8.* of the GNU linker cannot reliably
+*** create shared libraries on Solaris systems. Therefore, libtool
+*** is disabling shared libraries support. We urge you to upgrade GNU
+*** binutils to release 2.9.1 or newer. Another option is to modify
+*** your PATH or compiler configuration so that the native linker is
+*** used, and then restart.
+
+_LT_EOF
+ elif $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then
+ _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+ _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
+ else
+ _LT_TAGVAR(ld_shlibs, $1)=no
+ fi
+ ;;
+
+ sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX*)
+ case `$LD -v 2>&1` in
+ *\ [[01]].* | *\ 2.[[0-9]].* | *\ 2.1[[0-5]].*)
+ _LT_TAGVAR(ld_shlibs, $1)=no
+ cat <<_LT_EOF 1>&2
+
+*** Warning: Releases of the GNU linker prior to 2.16.91.0.3 can not
+*** reliably create shared libraries on SCO systems. Therefore, libtool
+*** is disabling shared libraries support. We urge you to upgrade GNU
+*** binutils to release 2.16.91.0.3 or newer. Another option is to modify
+*** your PATH or compiler configuration so that the native linker is
+*** used, and then restart.
+
+_LT_EOF
+ ;;
+ *)
+ # For security reasons, it is highly recommended that you always
+ # use absolute paths for naming shared libraries, and exclude the
+ # DT_RUNPATH tag from executables and libraries. But doing so
+ # requires that you compile everything twice, which is a pain.
+ if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then
+ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
+ _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+ _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
+ else
+ _LT_TAGVAR(ld_shlibs, $1)=no
+ fi
+ ;;
+ esac
+ ;;
+
+ sunos4*)
+ _LT_TAGVAR(archive_cmds, $1)='$LD -assert pure-text -Bshareable -o $lib $libobjs $deplibs $linker_flags'
+ wlarc=
+ _LT_TAGVAR(hardcode_direct, $1)=yes
+ _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
+ ;;
+
+ *)
+ if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then
+ _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+ _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
+ else
+ _LT_TAGVAR(ld_shlibs, $1)=no
+ fi
+ ;;
+ esac
+
+ if test "$_LT_TAGVAR(ld_shlibs, $1)" = no; then
+ runpath_var=
+ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)=
+ _LT_TAGVAR(export_dynamic_flag_spec, $1)=
+ _LT_TAGVAR(whole_archive_flag_spec, $1)=
+ fi
+ else
+ # PORTME fill in a description of your system's linker (not GNU ld)
+ case $host_os in
+ aix3*)
+ _LT_TAGVAR(allow_undefined_flag, $1)=unsupported
+ _LT_TAGVAR(always_export_symbols, $1)=yes
+ _LT_TAGVAR(archive_expsym_cmds, $1)='$LD -o $output_objdir/$soname $libobjs $deplibs $linker_flags -bE:$export_symbols -T512 -H512 -bM:SRE~$AR $AR_FLAGS $lib $output_objdir/$soname'
+ # Note: this linker hardcodes the directories in LIBPATH if there
+ # are no directories specified by -L.
+ _LT_TAGVAR(hardcode_minus_L, $1)=yes
+ if test "$GCC" = yes && test -z "$lt_prog_compiler_static"; then
+ # Neither direct hardcoding nor static linking is supported with a
+ # broken collect2.
+ _LT_TAGVAR(hardcode_direct, $1)=unsupported
+ fi
+ ;;
+
+ aix[[4-9]]*)
+ if test "$host_cpu" = ia64; then
+ # On IA64, the linker does run time linking by default, so we don't
+ # have to do anything special.
+ aix_use_runtimelinking=no
+ exp_sym_flag='-Bexport'
+ no_entry_flag=""
+ else
+ # If we're using GNU nm, then we don't want the "-C" option.
+ # -C means demangle to AIX nm, but means don't demangle with GNU nm
+ # Also, AIX nm treats weak defined symbols like other global
+ # defined symbols, whereas GNU nm marks them as "W".
+ if $NM -V 2>&1 | $GREP 'GNU' > /dev/null; then
+ _LT_TAGVAR(export_symbols_cmds, $1)='$NM -Bpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B") || (\$ 2 == "W")) && ([substr](\$ 3,1,1) != ".")) { print \$ 3 } }'\'' | sort -u > $export_symbols'
+ else
+ _LT_TAGVAR(export_symbols_cmds, $1)='$NM -BCpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B")) && ([substr](\$ 3,1,1) != ".")) { print \$ 3 } }'\'' | sort -u > $export_symbols'
+ fi
+ aix_use_runtimelinking=no
+
+ # Test if we are trying to use run time linking or normal
+ # AIX style linking. If -brtl is somewhere in LDFLAGS, we
+ # need to do runtime linking.
+ case $host_os in aix4.[[23]]|aix4.[[23]].*|aix[[5-9]]*)
+ for ld_flag in $LDFLAGS; do
+ if (test $ld_flag = "-brtl" || test $ld_flag = "-Wl,-brtl"); then
+ aix_use_runtimelinking=yes
+ break
+ fi
+ done
+ ;;
+ esac
+
+ exp_sym_flag='-bexport'
+ no_entry_flag='-bnoentry'
+ fi
+
+ # When large executables or shared objects are built, AIX ld can
+ # have problems creating the table of contents. If linking a library
+ # or program results in "error TOC overflow" add -mminimal-toc to
+ # CXXFLAGS/CFLAGS for g++/gcc. In the cases where that is not
+ # enough to fix the problem, add -Wl,-bbigtoc to LDFLAGS.
+
+ _LT_TAGVAR(archive_cmds, $1)=''
+ _LT_TAGVAR(hardcode_direct, $1)=yes
+ _LT_TAGVAR(hardcode_direct_absolute, $1)=yes
+ _LT_TAGVAR(hardcode_libdir_separator, $1)=':'
+ _LT_TAGVAR(link_all_deplibs, $1)=yes
+ _LT_TAGVAR(file_list_spec, $1)='${wl}-f,'
+
+ if test "$GCC" = yes; then
+ case $host_os in aix4.[[012]]|aix4.[[012]].*)
+ # We only want to do this on AIX 4.2 and lower, the check
+ # below for broken collect2 doesn't work under 4.3+
+ collect2name=`${CC} -print-prog-name=collect2`
+ if test -f "$collect2name" &&
+ strings "$collect2name" | $GREP resolve_lib_name >/dev/null
+ then
+ # We have reworked collect2
+ :
+ else
+ # We have old collect2
+ _LT_TAGVAR(hardcode_direct, $1)=unsupported
+ # It fails to find uninstalled libraries when the uninstalled
+ # path is not listed in the libpath. Setting hardcode_minus_L
+ # to unsupported forces relinking
+ _LT_TAGVAR(hardcode_minus_L, $1)=yes
+ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
+ _LT_TAGVAR(hardcode_libdir_separator, $1)=
+ fi
+ ;;
+ esac
+ shared_flag='-shared'
+ if test "$aix_use_runtimelinking" = yes; then
+ shared_flag="$shared_flag "'${wl}-G'
+ fi
+ else
+ # not using gcc
+ if test "$host_cpu" = ia64; then
+ # VisualAge C++, Version 5.5 for AIX 5L for IA-64, Beta 3 Release
+ # chokes on -Wl,-G. The following line is correct:
+ shared_flag='-G'
+ else
+ if test "$aix_use_runtimelinking" = yes; then
+ shared_flag='${wl}-G'
+ else
+ shared_flag='${wl}-bM:SRE'
+ fi
+ fi
+ fi
+
+ _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-bexpall'
+ # It seems that -bexpall does not export symbols beginning with
+ # underscore (_), so it is better to generate a list of symbols to export.
+ _LT_TAGVAR(always_export_symbols, $1)=yes
+ if test "$aix_use_runtimelinking" = yes; then
+ # Warning - without using the other runtime loading flags (-brtl),
+ # -berok will link without error, but may produce a broken library.
+ _LT_TAGVAR(allow_undefined_flag, $1)='-berok'
+ # Determine the default libpath from the value encoded in an
+ # empty executable.
+ _LT_SYS_MODULE_PATH_AIX([$1])
+ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-blibpath:$libdir:'"$aix_libpath"
+ _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags `if test "x${allow_undefined_flag}" != "x"; then func_echo_all "${wl}${allow_undefined_flag}"; else :; fi` '"\${wl}$exp_sym_flag:\$export_symbols $shared_flag"
+ else
+ if test "$host_cpu" = ia64; then
+ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-R $libdir:/usr/lib:/lib'
+ _LT_TAGVAR(allow_undefined_flag, $1)="-z nodefs"
+ _LT_TAGVAR(archive_expsym_cmds, $1)="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags ${wl}${allow_undefined_flag} '"\${wl}$exp_sym_flag:\$export_symbols"
+ else
+ # Determine the default libpath from the value encoded in an
+ # empty executable.
+ _LT_SYS_MODULE_PATH_AIX([$1])
+ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-blibpath:$libdir:'"$aix_libpath"
+ # Warning - without using the other run time loading flags,
+ # -berok will link without error, but may produce a broken library.
+ _LT_TAGVAR(no_undefined_flag, $1)=' ${wl}-bernotok'
+ _LT_TAGVAR(allow_undefined_flag, $1)=' ${wl}-berok'
+ if test "$with_gnu_ld" = yes; then
+ # We only use this code for GNU lds that support --whole-archive.
+ _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive$convenience ${wl}--no-whole-archive'
+ else
+ # Exported symbols can be pulled into shared objects from archives
+ _LT_TAGVAR(whole_archive_flag_spec, $1)='$convenience'
+ fi
+ _LT_TAGVAR(archive_cmds_need_lc, $1)=yes
+ # This is similar to how AIX traditionally builds its shared libraries.
+ _LT_TAGVAR(archive_expsym_cmds, $1)="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs ${wl}-bnoentry $compiler_flags ${wl}-bE:$export_symbols${allow_undefined_flag}~$AR $AR_FLAGS $output_objdir/$libname$release.a $output_objdir/$soname'
+ fi
+ fi
+ ;;
+
+ amigaos*)
+ case $host_cpu in
+ powerpc)
+ # see comment about AmigaOS4 .so support
+ _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+ _LT_TAGVAR(archive_expsym_cmds, $1)=''
+ ;;
+ m68k)
+ _LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/a2ixlibrary.data~$ECHO "#define NAME $libname" > $output_objdir/a2ixlibrary.data~$ECHO "#define LIBRARY_ID 1" >> $output_objdir/a2ixlibrary.data~$ECHO "#define VERSION $major" >> $output_objdir/a2ixlibrary.data~$ECHO "#define REVISION $revision" >> $output_objdir/a2ixlibrary.data~$AR $AR_FLAGS $lib $libobjs~$RANLIB $lib~(cd $output_objdir && a2ixlibrary -32)'
+ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
+ _LT_TAGVAR(hardcode_minus_L, $1)=yes
+ ;;
+ esac
+ ;;
+
+ bsdi[[45]]*)
+ _LT_TAGVAR(export_dynamic_flag_spec, $1)=-rdynamic
+ ;;
+
+ cygwin* | mingw* | pw32* | cegcc*)
+ # When not using gcc, we currently assume that we are using
+ # Microsoft Visual C++.
+ # hardcode_libdir_flag_spec is actually meaningless, as there is
+ # no search path for DLLs.
+ case $cc_basename in
+ cl*)
+ # Native MSVC
+ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)=' '
+ _LT_TAGVAR(allow_undefined_flag, $1)=unsupported
+ _LT_TAGVAR(always_export_symbols, $1)=yes
+ _LT_TAGVAR(file_list_spec, $1)='@'
+ # Tell ltmain to make .lib files, not .a files.
+ libext=lib
+ # Tell ltmain to make .dll files, not .so files.
+ shrext_cmds=".dll"
+ # FIXME: Setting linknames here is a bad hack.
+ _LT_TAGVAR(archive_cmds, $1)='$CC -o $output_objdir/$soname $libobjs $compiler_flags $deplibs -Wl,-dll~linknames='
+ _LT_TAGVAR(archive_expsym_cmds, $1)='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then
+ sed -n -e 's/\\\\\\\(.*\\\\\\\)/-link\\\ -EXPORT:\\\\\\\1/' -e '1\\\!p' < $export_symbols > $output_objdir/$soname.exp;
+ else
+ sed -e 's/\\\\\\\(.*\\\\\\\)/-link\\\ -EXPORT:\\\\\\\1/' < $export_symbols > $output_objdir/$soname.exp;
+ fi~
+ $CC -o $tool_output_objdir$soname $libobjs $compiler_flags $deplibs "@$tool_output_objdir$soname.exp" -Wl,-DLL,-IMPLIB:"$tool_output_objdir$libname.dll.lib"~
+ linknames='
+ # The linker will not automatically build a static lib if we build a DLL.
+ # _LT_TAGVAR(old_archive_from_new_cmds, $1)='true'
+ _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=yes
+ _LT_TAGVAR(exclude_expsyms, $1)='_NULL_IMPORT_DESCRIPTOR|_IMPORT_DESCRIPTOR_.*'
+ _LT_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[[BCDGRS]][[ ]]/s/.*[[ ]]\([[^ ]]*\)/\1,DATA/'\'' | $SED -e '\''/^[[AITW]][[ ]]/s/.*[[ ]]//'\'' | sort | uniq > $export_symbols'
+ # Don't use ranlib
+ _LT_TAGVAR(old_postinstall_cmds, $1)='chmod 644 $oldlib'
+ _LT_TAGVAR(postlink_cmds, $1)='lt_outputfile="@OUTPUT@"~
+ lt_tool_outputfile="@TOOL_OUTPUT@"~
+ case $lt_outputfile in
+ *.exe|*.EXE) ;;
+ *)
+ lt_outputfile="$lt_outputfile.exe"
+ lt_tool_outputfile="$lt_tool_outputfile.exe"
+ ;;
+ esac~
+ if test "$MANIFEST_TOOL" != ":" && test -f "$lt_outputfile.manifest"; then
+ $MANIFEST_TOOL -manifest "$lt_tool_outputfile.manifest" -outputresource:"$lt_tool_outputfile" || exit 1;
+ $RM "$lt_outputfile.manifest";
+ fi'
+ ;;
+ *)
+ # Assume MSVC wrapper
+ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)=' '
+ _LT_TAGVAR(allow_undefined_flag, $1)=unsupported
+ # Tell ltmain to make .lib files, not .a files.
+ libext=lib
+ # Tell ltmain to make .dll files, not .so files.
+ shrext_cmds=".dll"
+ # FIXME: Setting linknames here is a bad hack.
+ _LT_TAGVAR(archive_cmds, $1)='$CC -o $lib $libobjs $compiler_flags `func_echo_all "$deplibs" | $SED '\''s/ -lc$//'\''` -link -dll~linknames='
+ # The linker will automatically build a .lib file if we build a DLL.
+ _LT_TAGVAR(old_archive_from_new_cmds, $1)='true'
+ # FIXME: Should let the user specify the lib program.
+ _LT_TAGVAR(old_archive_cmds, $1)='lib -OUT:$oldlib$oldobjs$old_deplibs'
+ _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=yes
+ ;;
+ esac
+ ;;
+
+ darwin* | rhapsody*)
+ _LT_DARWIN_LINKER_FEATURES($1)
+ ;;
+
+ dgux*)
+ _LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
+ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
+ _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
+ ;;
+
+ # FreeBSD 2.2.[012] allows us to include c++rt0.o to get C++ constructor
+ # support. Future versions do this automatically, but an explicit c++rt0.o
+ # does not break anything, and helps significantly (at the cost of a little
+ # extra space).
+ freebsd2.2*)
+ _LT_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags /usr/lib/c++rt0.o'
+ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir'
+ _LT_TAGVAR(hardcode_direct, $1)=yes
+ _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
+ ;;
+
+ # Unfortunately, older versions of FreeBSD 2 do not have this feature.
+ freebsd2.*)
+ _LT_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags'
+ _LT_TAGVAR(hardcode_direct, $1)=yes
+ _LT_TAGVAR(hardcode_minus_L, $1)=yes
+ _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
+ ;;
+
+ # FreeBSD 3 and greater uses gcc -shared to do shared libraries.
+ freebsd* | dragonfly*)
+ _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags'
+ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir'
+ _LT_TAGVAR(hardcode_direct, $1)=yes
+ _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
+ ;;
+
+ hpux9*)
+ if test "$GCC" = yes; then
+ _LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/$soname~$CC -shared $pic_flag ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $libobjs $deplibs $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib'
+ else
+ _LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/$soname~$LD -b +b $install_libdir -o $output_objdir/$soname $libobjs $deplibs $linker_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib'
+ fi
+ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir'
+ _LT_TAGVAR(hardcode_libdir_separator, $1)=:
+ _LT_TAGVAR(hardcode_direct, $1)=yes
+
+ # hardcode_minus_L: Not really in the search PATH,
+ # but as the default location of the library.
+ _LT_TAGVAR(hardcode_minus_L, $1)=yes
+ _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E'
+ ;;
+
+ hpux10*)
+ if test "$GCC" = yes && test "$with_gnu_ld" = no; then
+ _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags'
+ else
+ _LT_TAGVAR(archive_cmds, $1)='$LD -b +h $soname +b $install_libdir -o $lib $libobjs $deplibs $linker_flags'
+ fi
+ if test "$with_gnu_ld" = no; then
+ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir'
+ _LT_TAGVAR(hardcode_libdir_separator, $1)=:
+ _LT_TAGVAR(hardcode_direct, $1)=yes
+ _LT_TAGVAR(hardcode_direct_absolute, $1)=yes
+ _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E'
+ # hardcode_minus_L: Not really in the search PATH,
+ # but as the default location of the library.
+ _LT_TAGVAR(hardcode_minus_L, $1)=yes
+ fi
+ ;;
+
+ hpux11*)
+ if test "$GCC" = yes && test "$with_gnu_ld" = no; then
+ case $host_cpu in
+ hppa*64*)
+ _LT_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}+h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags'
+ ;;
+ ia64*)
+ _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags'
+ ;;
+ *)
+ _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags'
+ ;;
+ esac
+ else
+ case $host_cpu in
+ hppa*64*)
+ _LT_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags'
+ ;;
+ ia64*)
+ _LT_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags'
+ ;;
+ *)
+ m4_if($1, [], [
+ # Older versions of the 11.00 compiler do not understand -b yet
+ # (HP92453-01 A.11.01.20 doesn't, HP92453-01 B.11.X.35175-35176.GP does)
+ _LT_LINKER_OPTION([if $CC understands -b],
+ _LT_TAGVAR(lt_cv_prog_compiler__b, $1), [-b],
+ [_LT_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags'],
+ [_LT_TAGVAR(archive_cmds, $1)='$LD -b +h $soname +b $install_libdir -o $lib $libobjs $deplibs $linker_flags'])],
+ [_LT_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags'])
+ ;;
+ esac
+ fi
+ if test "$with_gnu_ld" = no; then
+ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir'
+ _LT_TAGVAR(hardcode_libdir_separator, $1)=:
+
+ case $host_cpu in
+ hppa*64*|ia64*)
+ _LT_TAGVAR(hardcode_direct, $1)=no
+ _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
+ ;;
+ *)
+ _LT_TAGVAR(hardcode_direct, $1)=yes
+ _LT_TAGVAR(hardcode_direct_absolute, $1)=yes
+ _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E'
+
+ # hardcode_minus_L: Not really in the search PATH,
+ # but as the default location of the library.
+ _LT_TAGVAR(hardcode_minus_L, $1)=yes
+ ;;
+ esac
+ fi
+ ;;
+
+ irix5* | irix6* | nonstopux*)
+ if test "$GCC" = yes; then
+ _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
+ # Try to use the -exported_symbol ld option, if it does not
+ # work, assume that -exports_file does not work either and
+ # implicitly export all symbols.
+ # This should be the same for all languages, so no per-tag cache variable.
+ AC_CACHE_CHECK([whether the $host_os linker accepts -exported_symbol],
+ [lt_cv_irix_exported_symbol],
+ [save_LDFLAGS="$LDFLAGS"
+ LDFLAGS="$LDFLAGS -shared ${wl}-exported_symbol ${wl}foo ${wl}-update_registry ${wl}/dev/null"
+ AC_LINK_IFELSE(
+ [AC_LANG_SOURCE(
+ [AC_LANG_CASE([C], [[int foo (void) { return 0; }]],
+ [C++], [[int foo (void) { return 0; }]],
+ [Fortran 77], [[
+ subroutine foo
+ end]],
+ [Fortran], [[
+ subroutine foo
+ end]])])],
+ [lt_cv_irix_exported_symbol=yes],
+ [lt_cv_irix_exported_symbol=no])
+ LDFLAGS="$save_LDFLAGS"])
+ if test "$lt_cv_irix_exported_symbol" = yes; then
+ _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations ${wl}-exports_file ${wl}$export_symbols -o $lib'
+ fi
+ else
+ _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib'
+ _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -exports_file $export_symbols -o $lib'
+ fi
+ _LT_TAGVAR(archive_cmds_need_lc, $1)='no'
+ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
+ _LT_TAGVAR(hardcode_libdir_separator, $1)=:
+ _LT_TAGVAR(inherit_rpath, $1)=yes
+ _LT_TAGVAR(link_all_deplibs, $1)=yes
+ ;;
+
+ netbsd*)
+ if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then
+ _LT_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' # a.out
+ else
+ _LT_TAGVAR(archive_cmds, $1)='$LD -shared -o $lib $libobjs $deplibs $linker_flags' # ELF
+ fi
+ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir'
+ _LT_TAGVAR(hardcode_direct, $1)=yes
+ _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
+ ;;
+
+ newsos6)
+ _LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
+ _LT_TAGVAR(hardcode_direct, $1)=yes
+ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
+ _LT_TAGVAR(hardcode_libdir_separator, $1)=:
+ _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
+ ;;
+
+ *nto* | *qnx*)
+ ;;
+
+ openbsd*)
+ if test -f /usr/libexec/ld.so; then
+ _LT_TAGVAR(hardcode_direct, $1)=yes
+ _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
+ _LT_TAGVAR(hardcode_direct_absolute, $1)=yes
+ if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then
+ _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags'
+ _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-retain-symbols-file,$export_symbols'
+ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir'
+ _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E'
+ else
+ case $host_os in
+ openbsd[[01]].* | openbsd2.[[0-7]] | openbsd2.[[0-7]].*)
+ _LT_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags'
+ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir'
+ ;;
+ *)
+ _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags'
+ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir'
+ ;;
+ esac
+ fi
+ else
+ _LT_TAGVAR(ld_shlibs, $1)=no
+ fi
+ ;;
+
+ os2*)
+ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
+ _LT_TAGVAR(hardcode_minus_L, $1)=yes
+ _LT_TAGVAR(allow_undefined_flag, $1)=unsupported
+ _LT_TAGVAR(archive_cmds, $1)='$ECHO "LIBRARY $libname INITINSTANCE" > $output_objdir/$libname.def~$ECHO "DESCRIPTION \"$libname\"" >> $output_objdir/$libname.def~echo DATA >> $output_objdir/$libname.def~echo " SINGLE NONSHARED" >> $output_objdir/$libname.def~echo EXPORTS >> $output_objdir/$libname.def~emxexp $libobjs >> $output_objdir/$libname.def~$CC -Zdll -Zcrtdll -o $lib $libobjs $deplibs $compiler_flags $output_objdir/$libname.def'
+ _LT_TAGVAR(old_archive_from_new_cmds, $1)='emximp -o $output_objdir/$libname.a $output_objdir/$libname.def'
+ ;;
+
+ osf3*)
+ if test "$GCC" = yes; then
+ _LT_TAGVAR(allow_undefined_flag, $1)=' ${wl}-expect_unresolved ${wl}\*'
+ _LT_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
+ else
+ _LT_TAGVAR(allow_undefined_flag, $1)=' -expect_unresolved \*'
+ _LT_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib'
+ fi
+ _LT_TAGVAR(archive_cmds_need_lc, $1)='no'
+ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
+ _LT_TAGVAR(hardcode_libdir_separator, $1)=:
+ ;;
+
+ osf4* | osf5*) # as osf3* with the addition of -msym flag
+ if test "$GCC" = yes; then
+ _LT_TAGVAR(allow_undefined_flag, $1)=' ${wl}-expect_unresolved ${wl}\*'
+ _LT_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $pic_flag $libobjs $deplibs $compiler_flags ${wl}-msym ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
+ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
+ else
+ _LT_TAGVAR(allow_undefined_flag, $1)=' -expect_unresolved \*'
+ _LT_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags -msym -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib'
+ _LT_TAGVAR(archive_expsym_cmds, $1)='for i in `cat $export_symbols`; do printf "%s %s\\n" -exported_symbol "\$i" >> $lib.exp; done; printf "%s\\n" "-hidden">> $lib.exp~
+ $CC -shared${allow_undefined_flag} ${wl}-input ${wl}$lib.exp $compiler_flags $libobjs $deplibs -soname $soname `test -n "$verstring" && $ECHO "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib~$RM $lib.exp'
+
+ # Both c and cxx compiler support -rpath directly
+ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-rpath $libdir'
+ fi
+ _LT_TAGVAR(archive_cmds_need_lc, $1)='no'
+ _LT_TAGVAR(hardcode_libdir_separator, $1)=:
+ ;;
+
+ solaris*)
+ _LT_TAGVAR(no_undefined_flag, $1)=' -z defs'
+ if test "$GCC" = yes; then
+ wlarc='${wl}'
+ _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag ${wl}-z ${wl}text ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags'
+ _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~
+ $CC -shared $pic_flag ${wl}-z ${wl}text ${wl}-M ${wl}$lib.exp ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags~$RM $lib.exp'
+ else
+ case `$CC -V 2>&1` in
+ *"Compilers 5.0"*)
+ wlarc=''
+ _LT_TAGVAR(archive_cmds, $1)='$LD -G${allow_undefined_flag} -h $soname -o $lib $libobjs $deplibs $linker_flags'
+ _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~
+ $LD -G${allow_undefined_flag} -M $lib.exp -h $soname -o $lib $libobjs $deplibs $linker_flags~$RM $lib.exp'
+ ;;
+ *)
+ wlarc='${wl}'
+ _LT_TAGVAR(archive_cmds, $1)='$CC -G${allow_undefined_flag} -h $soname -o $lib $libobjs $deplibs $compiler_flags'
+ _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~
+ $CC -G${allow_undefined_flag} -M $lib.exp -h $soname -o $lib $libobjs $deplibs $compiler_flags~$RM $lib.exp'
+ ;;
+ esac
+ fi
+ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir'
+ _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
+ case $host_os in
+ solaris2.[[0-5]] | solaris2.[[0-5]].*) ;;
+ *)
+ # The compiler driver will combine and reorder linker options,
+ # but understands `-z linker_flag'. GCC discards it without `$wl',
+ # but is careful enough not to reorder.
+ # Supported since Solaris 2.6 (maybe 2.5.1?)
+ if test "$GCC" = yes; then
+ _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}-z ${wl}allextract$convenience ${wl}-z ${wl}defaultextract'
+ else
+ _LT_TAGVAR(whole_archive_flag_spec, $1)='-z allextract$convenience -z defaultextract'
+ fi
+ ;;
+ esac
+ _LT_TAGVAR(link_all_deplibs, $1)=yes
+ ;;
+
+ sunos4*)
+ if test "x$host_vendor" = xsequent; then
+ # Use $CC to link under sequent, because it throws in some extra .o
+ # files that make .init and .fini sections work.
+ _LT_TAGVAR(archive_cmds, $1)='$CC -G ${wl}-h $soname -o $lib $libobjs $deplibs $compiler_flags'
+ else
+ _LT_TAGVAR(archive_cmds, $1)='$LD -assert pure-text -Bstatic -o $lib $libobjs $deplibs $linker_flags'
+ fi
+ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
+ _LT_TAGVAR(hardcode_direct, $1)=yes
+ _LT_TAGVAR(hardcode_minus_L, $1)=yes
+ _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
+ ;;
+
+ sysv4)
+ case $host_vendor in
+ sni)
+ _LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
+ _LT_TAGVAR(hardcode_direct, $1)=yes # is this really true???
+ ;;
+ siemens)
+ ## LD is ld it makes a PLAMLIB
+ ## CC just makes a GrossModule.
+ _LT_TAGVAR(archive_cmds, $1)='$LD -G -o $lib $libobjs $deplibs $linker_flags'
+ _LT_TAGVAR(reload_cmds, $1)='$CC -r -o $output$reload_objs'
+ _LT_TAGVAR(hardcode_direct, $1)=no
+ ;;
+ motorola)
+ _LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
+ _LT_TAGVAR(hardcode_direct, $1)=no #Motorola manual says yes, but my tests say they lie
+ ;;
+ esac
+ runpath_var='LD_RUN_PATH'
+ _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
+ ;;
+
+ sysv4.3*)
+ _LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
+ _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
+ _LT_TAGVAR(export_dynamic_flag_spec, $1)='-Bexport'
+ ;;
+
+ sysv4*MP*)
+ if test -d /usr/nec; then
+ _LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
+ _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
+ runpath_var=LD_RUN_PATH
+ hardcode_runpath_var=yes
+ _LT_TAGVAR(ld_shlibs, $1)=yes
+ fi
+ ;;
+
+ sysv4*uw2* | sysv5OpenUNIX* | sysv5UnixWare7.[[01]].[[10]]* | unixware7* | sco3.2v5.0.[[024]]*)
+ _LT_TAGVAR(no_undefined_flag, $1)='${wl}-z,text'
+ _LT_TAGVAR(archive_cmds_need_lc, $1)=no
+ _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
+ runpath_var='LD_RUN_PATH'
+
+ if test "$GCC" = yes; then
+ _LT_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+ _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+ else
+ _LT_TAGVAR(archive_cmds, $1)='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+ _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+ fi
+ ;;
+
+ sysv5* | sco3.2v5* | sco5v6*)
+ # Note: We can NOT use -z defs as we might desire, because we do not
+ # link with -lc, and that would cause any symbols used from libc to
+ # always be unresolved, which means just about no library would
+ # ever link correctly. If we're not using GNU ld we use -z text
+ # though, which does catch some bad symbols but isn't as heavy-handed
+ # as -z defs.
+ _LT_TAGVAR(no_undefined_flag, $1)='${wl}-z,text'
+ _LT_TAGVAR(allow_undefined_flag, $1)='${wl}-z,nodefs'
+ _LT_TAGVAR(archive_cmds_need_lc, $1)=no
+ _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
+ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-R,$libdir'
+ _LT_TAGVAR(hardcode_libdir_separator, $1)=':'
+ _LT_TAGVAR(link_all_deplibs, $1)=yes
+ _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-Bexport'
+ runpath_var='LD_RUN_PATH'
+
+ if test "$GCC" = yes; then
+ _LT_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+ _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+ else
+ _LT_TAGVAR(archive_cmds, $1)='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+ _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+ fi
+ ;;
+
+ uts4*)
+ _LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
+ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
+ _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
+ ;;
+
+ *)
+ _LT_TAGVAR(ld_shlibs, $1)=no
+ ;;
+ esac
+
+ if test x$host_vendor = xsni; then
+ case $host in
+ sysv4 | sysv4.2uw2* | sysv4.3* | sysv5*)
+ _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-Blargedynsym'
+ ;;
+ esac
+ fi
+ fi
+])
+AC_MSG_RESULT([$_LT_TAGVAR(ld_shlibs, $1)])
+test "$_LT_TAGVAR(ld_shlibs, $1)" = no && can_build_shared=no
+
+_LT_TAGVAR(with_gnu_ld, $1)=$with_gnu_ld
+
+_LT_DECL([], [libext], [0], [Old archive suffix (normally "a")])dnl
+_LT_DECL([], [shrext_cmds], [1], [Shared library suffix (normally ".so")])dnl
+_LT_DECL([], [extract_expsyms_cmds], [2],
+ [The commands to extract the exported symbol list from a shared archive])
+
+#
+# Do we need to explicitly link libc?
+#
+case "x$_LT_TAGVAR(archive_cmds_need_lc, $1)" in
+x|xyes)
+ # Assume -lc should be added
+ _LT_TAGVAR(archive_cmds_need_lc, $1)=yes
+
+ if test "$enable_shared" = yes && test "$GCC" = yes; then
+ case $_LT_TAGVAR(archive_cmds, $1) in
+ *'~'*)
+ # FIXME: we may have to deal with multi-command sequences.
+ ;;
+ '$CC '*)
+ # Test whether the compiler implicitly links with -lc since on some
+ # systems, -lgcc has to come before -lc. If gcc already passes -lc
+ # to ld, don't add -lc before -lgcc.
+ AC_CACHE_CHECK([whether -lc should be explicitly linked in],
+ [lt_cv_]_LT_TAGVAR(archive_cmds_need_lc, $1),
+ [$RM conftest*
+ echo "$lt_simple_compile_test_code" > conftest.$ac_ext
+
+ if AC_TRY_EVAL(ac_compile) 2>conftest.err; then
+ soname=conftest
+ lib=conftest
+ libobjs=conftest.$ac_objext
+ deplibs=
+ wl=$_LT_TAGVAR(lt_prog_compiler_wl, $1)
+ pic_flag=$_LT_TAGVAR(lt_prog_compiler_pic, $1)
+ compiler_flags=-v
+ linker_flags=-v
+ verstring=
+ output_objdir=.
+ libname=conftest
+ lt_save_allow_undefined_flag=$_LT_TAGVAR(allow_undefined_flag, $1)
+ _LT_TAGVAR(allow_undefined_flag, $1)=
+ if AC_TRY_EVAL(_LT_TAGVAR(archive_cmds, $1) 2\>\&1 \| $GREP \" -lc \" \>/dev/null 2\>\&1)
+ then
+ lt_cv_[]_LT_TAGVAR(archive_cmds_need_lc, $1)=no
+ else
+ lt_cv_[]_LT_TAGVAR(archive_cmds_need_lc, $1)=yes
+ fi
+ _LT_TAGVAR(allow_undefined_flag, $1)=$lt_save_allow_undefined_flag
+ else
+ cat conftest.err 1>&5
+ fi
+ $RM conftest*
+ ])
+ _LT_TAGVAR(archive_cmds_need_lc, $1)=$lt_cv_[]_LT_TAGVAR(archive_cmds_need_lc, $1)
+ ;;
+ esac
+ fi
+ ;;
+esac
+
+_LT_TAGDECL([build_libtool_need_lc], [archive_cmds_need_lc], [0],
+ [Whether or not to add -lc for building shared libraries])
+_LT_TAGDECL([allow_libtool_libs_with_static_runtimes],
+ [enable_shared_with_static_runtimes], [0],
+ [Whether or not to disallow shared libs when runtime libs are static])
+_LT_TAGDECL([], [export_dynamic_flag_spec], [1],
+ [Compiler flag to allow reflexive dlopens])
+_LT_TAGDECL([], [whole_archive_flag_spec], [1],
+ [Compiler flag to generate shared objects directly from archives])
+_LT_TAGDECL([], [compiler_needs_object], [1],
+ [Whether the compiler copes with passing no objects directly])
+_LT_TAGDECL([], [old_archive_from_new_cmds], [2],
+ [Create an old-style archive from a shared archive])
+_LT_TAGDECL([], [old_archive_from_expsyms_cmds], [2],
+ [Create a temporary old-style archive to link instead of a shared archive])
+_LT_TAGDECL([], [archive_cmds], [2], [Commands used to build a shared archive])
+_LT_TAGDECL([], [archive_expsym_cmds], [2])
+_LT_TAGDECL([], [module_cmds], [2],
+ [Commands used to build a loadable module if different from building
+ a shared archive.])
+_LT_TAGDECL([], [module_expsym_cmds], [2])
+_LT_TAGDECL([], [with_gnu_ld], [1],
+ [Whether we are building with GNU ld or not])
+_LT_TAGDECL([], [allow_undefined_flag], [1],
+ [Flag that allows shared libraries with undefined symbols to be built])
+_LT_TAGDECL([], [no_undefined_flag], [1],
+ [Flag that enforces no undefined symbols])
+_LT_TAGDECL([], [hardcode_libdir_flag_spec], [1],
+ [Flag to hardcode $libdir into a binary during linking.
+ This must work even if $libdir does not exist])
+_LT_TAGDECL([], [hardcode_libdir_separator], [1],
+ [Whether we need a single "-rpath" flag with a separated argument])
+_LT_TAGDECL([], [hardcode_direct], [0],
+ [Set to "yes" if using DIR/libNAME${shared_ext} during linking hardcodes
+ DIR into the resulting binary])
+_LT_TAGDECL([], [hardcode_direct_absolute], [0],
+ [Set to "yes" if using DIR/libNAME${shared_ext} during linking hardcodes
+ DIR into the resulting binary and the resulting library dependency is
+ "absolute", i.e impossible to change by setting ${shlibpath_var} if the
+ library is relocated])
+_LT_TAGDECL([], [hardcode_minus_L], [0],
+ [Set to "yes" if using the -LDIR flag during linking hardcodes DIR
+ into the resulting binary])
+_LT_TAGDECL([], [hardcode_shlibpath_var], [0],
+ [Set to "yes" if using SHLIBPATH_VAR=DIR during linking hardcodes DIR
+ into the resulting binary])
+_LT_TAGDECL([], [hardcode_automatic], [0],
+ [Set to "yes" if building a shared library automatically hardcodes DIR
+ into the library and all subsequent libraries and executables linked
+ against it])
+_LT_TAGDECL([], [inherit_rpath], [0],
+ [Set to yes if linker adds runtime paths of dependent libraries
+ to runtime path list])
+_LT_TAGDECL([], [link_all_deplibs], [0],
+ [Whether libtool must link a program against all its dependency libraries])
+_LT_TAGDECL([], [always_export_symbols], [0],
+ [Set to "yes" if exported symbols are required])
+_LT_TAGDECL([], [export_symbols_cmds], [2],
+ [The commands to list exported symbols])
+_LT_TAGDECL([], [exclude_expsyms], [1],
+ [Symbols that should not be listed in the preloaded symbols])
+_LT_TAGDECL([], [include_expsyms], [1],
+ [Symbols that must always be exported])
+_LT_TAGDECL([], [prelink_cmds], [2],
+ [Commands necessary for linking programs (against libraries) with templates])
+_LT_TAGDECL([], [postlink_cmds], [2],
+ [Commands necessary for finishing linking programs])
+_LT_TAGDECL([], [file_list_spec], [1],
+ [Specify filename containing input files])
+dnl FIXME: Not yet implemented
+dnl _LT_TAGDECL([], [thread_safe_flag_spec], [1],
+dnl [Compiler flag to generate thread safe objects])
+])# _LT_LINKER_SHLIBS
+
+
+# _LT_LANG_C_CONFIG([TAG])
+# ------------------------
+# Ensure that the configuration variables for a C compiler are suitably
+# defined. These variables are subsequently used by _LT_CONFIG to write
+# the compiler configuration to `libtool'.
+m4_defun([_LT_LANG_C_CONFIG],
+[m4_require([_LT_DECL_EGREP])dnl
+lt_save_CC="$CC"
+AC_LANG_PUSH(C)
+
+# Source file extension for C test sources.
+ac_ext=c
+
+# Object file extension for compiled C test sources.
+objext=o
+_LT_TAGVAR(objext, $1)=$objext
+
+# Code to be used in simple compile tests
+lt_simple_compile_test_code="int some_variable = 0;"
+
+# Code to be used in simple link tests
+lt_simple_link_test_code='int main(){return(0);}'
+
+_LT_TAG_COMPILER
+# Save the default compiler, since it gets overwritten when the other
+# tags are being tested, and _LT_TAGVAR(compiler, []) is a NOP.
+compiler_DEFAULT=$CC
+
+# save warnings/boilerplate of simple test code
+_LT_COMPILER_BOILERPLATE
+_LT_LINKER_BOILERPLATE
+
+## CAVEAT EMPTOR:
+## There is no encapsulation within the following macros, do not change
+## the running order or otherwise move them around unless you know exactly
+## what you are doing...
+if test -n "$compiler"; then
+ _LT_COMPILER_NO_RTTI($1)
+ _LT_COMPILER_PIC($1)
+ _LT_COMPILER_C_O($1)
+ _LT_COMPILER_FILE_LOCKS($1)
+ _LT_LINKER_SHLIBS($1)
+ _LT_SYS_DYNAMIC_LINKER($1)
+ _LT_LINKER_HARDCODE_LIBPATH($1)
+ LT_SYS_DLOPEN_SELF
+ _LT_CMD_STRIPLIB
+
+ # Report which library types will actually be built
+ AC_MSG_CHECKING([if libtool supports shared libraries])
+ AC_MSG_RESULT([$can_build_shared])
+
+ AC_MSG_CHECKING([whether to build shared libraries])
+ test "$can_build_shared" = "no" && enable_shared=no
+
+ # On AIX, shared libraries and static libraries use the same namespace, and
+ # are all built from PIC.
+ case $host_os in
+ aix3*)
+ test "$enable_shared" = yes && enable_static=no
+ if test -n "$RANLIB"; then
+ archive_cmds="$archive_cmds~\$RANLIB \$lib"
+ postinstall_cmds='$RANLIB $lib'
+ fi
+ ;;
+
+ aix[[4-9]]*)
+ if test "$host_cpu" != ia64 && test "$aix_use_runtimelinking" = no ; then
+ test "$enable_shared" = yes && enable_static=no
+ fi
+ ;;
+ esac
+ AC_MSG_RESULT([$enable_shared])
+
+ AC_MSG_CHECKING([whether to build static libraries])
+ # Make sure either enable_shared or enable_static is yes.
+ test "$enable_shared" = yes || enable_static=yes
+ AC_MSG_RESULT([$enable_static])
+
+ _LT_CONFIG($1)
+fi
+AC_LANG_POP
+CC="$lt_save_CC"
+])# _LT_LANG_C_CONFIG
+
+
+# _LT_LANG_CXX_CONFIG([TAG])
+# --------------------------
+# Ensure that the configuration variables for a C++ compiler are suitably
+# defined. These variables are subsequently used by _LT_CONFIG to write
+# the compiler configuration to `libtool'.
+m4_defun([_LT_LANG_CXX_CONFIG],
+[m4_require([_LT_FILEUTILS_DEFAULTS])dnl
+m4_require([_LT_DECL_EGREP])dnl
+m4_require([_LT_PATH_MANIFEST_TOOL])dnl
+if test -n "$CXX" && ( test "X$CXX" != "Xno" &&
+ ( (test "X$CXX" = "Xg++" && `g++ -v >/dev/null 2>&1` ) ||
+ (test "X$CXX" != "Xg++"))) ; then
+ AC_PROG_CXXCPP
+else
+ _lt_caught_CXX_error=yes
+fi
+
+AC_LANG_PUSH(C++)
+_LT_TAGVAR(archive_cmds_need_lc, $1)=no
+_LT_TAGVAR(allow_undefined_flag, $1)=
+_LT_TAGVAR(always_export_symbols, $1)=no
+_LT_TAGVAR(archive_expsym_cmds, $1)=
+_LT_TAGVAR(compiler_needs_object, $1)=no
+_LT_TAGVAR(export_dynamic_flag_spec, $1)=
+_LT_TAGVAR(hardcode_direct, $1)=no
+_LT_TAGVAR(hardcode_direct_absolute, $1)=no
+_LT_TAGVAR(hardcode_libdir_flag_spec, $1)=
+_LT_TAGVAR(hardcode_libdir_separator, $1)=
+_LT_TAGVAR(hardcode_minus_L, $1)=no
+_LT_TAGVAR(hardcode_shlibpath_var, $1)=unsupported
+_LT_TAGVAR(hardcode_automatic, $1)=no
+_LT_TAGVAR(inherit_rpath, $1)=no
+_LT_TAGVAR(module_cmds, $1)=
+_LT_TAGVAR(module_expsym_cmds, $1)=
+_LT_TAGVAR(link_all_deplibs, $1)=unknown
+_LT_TAGVAR(old_archive_cmds, $1)=$old_archive_cmds
+_LT_TAGVAR(reload_flag, $1)=$reload_flag
+_LT_TAGVAR(reload_cmds, $1)=$reload_cmds
+_LT_TAGVAR(no_undefined_flag, $1)=
+_LT_TAGVAR(whole_archive_flag_spec, $1)=
+_LT_TAGVAR(enable_shared_with_static_runtimes, $1)=no
+
+# Source file extension for C++ test sources.
+ac_ext=cpp
+
+# Object file extension for compiled C++ test sources.
+objext=o
+_LT_TAGVAR(objext, $1)=$objext
+
+# No sense in running all these tests if we already determined that
+# the CXX compiler isn't working. Some variables (like enable_shared)
+# are currently assumed to apply to all compilers on this platform,
+# and will be corrupted by setting them based on a non-working compiler.
+if test "$_lt_caught_CXX_error" != yes; then
+ # Code to be used in simple compile tests
+ lt_simple_compile_test_code="int some_variable = 0;"
+
+ # Code to be used in simple link tests
+ lt_simple_link_test_code='int main(int, char *[[]]) { return(0); }'
+
+ # ltmain only uses $CC for tagged configurations so make sure $CC is set.
+ _LT_TAG_COMPILER
+
+ # save warnings/boilerplate of simple test code
+ _LT_COMPILER_BOILERPLATE
+ _LT_LINKER_BOILERPLATE
+
+ # Allow CC to be a program name with arguments.
+ lt_save_CC=$CC
+ lt_save_CFLAGS=$CFLAGS
+ lt_save_LD=$LD
+ lt_save_GCC=$GCC
+ GCC=$GXX
+ lt_save_with_gnu_ld=$with_gnu_ld
+ lt_save_path_LD=$lt_cv_path_LD
+ if test -n "${lt_cv_prog_gnu_ldcxx+set}"; then
+ lt_cv_prog_gnu_ld=$lt_cv_prog_gnu_ldcxx
+ else
+ $as_unset lt_cv_prog_gnu_ld
+ fi
+ if test -n "${lt_cv_path_LDCXX+set}"; then
+ lt_cv_path_LD=$lt_cv_path_LDCXX
+ else
+ $as_unset lt_cv_path_LD
+ fi
+ test -z "${LDCXX+set}" || LD=$LDCXX
+ CC=${CXX-"c++"}
+ CFLAGS=$CXXFLAGS
+ compiler=$CC
+ _LT_TAGVAR(compiler, $1)=$CC
+ _LT_CC_BASENAME([$compiler])
+
+ if test -n "$compiler"; then
+ # We don't want -fno-exception when compiling C++ code, so set the
+ # no_builtin_flag separately
+ if test "$GXX" = yes; then
+ _LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)=' -fno-builtin'
+ else
+ _LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)=
+ fi
+
+ if test "$GXX" = yes; then
+ # Set up default GNU C++ configuration
+
+ LT_PATH_LD
+
+ # Check if GNU C++ uses GNU ld as the underlying linker, since the
+ # archiving commands below assume that GNU ld is being used.
+ if test "$with_gnu_ld" = yes; then
+ _LT_TAGVAR(archive_cmds, $1)='$CC $pic_flag -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib'
+ _LT_TAGVAR(archive_expsym_cmds, $1)='$CC $pic_flag -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
+
+ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
+ _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic'
+
+ # If archive_cmds runs LD, not CC, wlarc should be empty
+ # XXX I think wlarc can be eliminated in ltcf-cxx, but I need to
+ # investigate it a little bit more. (MM)
+ wlarc='${wl}'
+
+ # ancient GNU ld didn't support --whole-archive et. al.
+ if eval "`$CC -print-prog-name=ld` --help 2>&1" |
+ $GREP 'no-whole-archive' > /dev/null; then
+ _LT_TAGVAR(whole_archive_flag_spec, $1)="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive'
+ else
+ _LT_TAGVAR(whole_archive_flag_spec, $1)=
+ fi
+ else
+ with_gnu_ld=no
+ wlarc=
+
+ # A generic and very simple default shared library creation
+ # command for GNU C++ for the case where it uses the native
+ # linker, instead of GNU ld. If possible, this setting should
+ # overridden to take advantage of the native linker features on
+ # the platform it is being used on.
+ _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $lib'
+ fi
+
+ # Commands to make compiler produce verbose output that lists
+ # what "hidden" libraries, object files and flags are used when
+ # linking a shared library.
+ output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP -v "^Configured with:" | $GREP "\-L"'
+
+ else
+ GXX=no
+ with_gnu_ld=no
+ wlarc=
+ fi
+
+ # PORTME: fill in a description of your system's C++ link characteristics
+ AC_MSG_CHECKING([whether the $compiler linker ($LD) supports shared libraries])
+ _LT_TAGVAR(ld_shlibs, $1)=yes
+ case $host_os in
+ aix3*)
+ # FIXME: insert proper C++ library support
+ _LT_TAGVAR(ld_shlibs, $1)=no
+ ;;
+ aix[[4-9]]*)
+ if test "$host_cpu" = ia64; then
+ # On IA64, the linker does run time linking by default, so we don't
+ # have to do anything special.
+ aix_use_runtimelinking=no
+ exp_sym_flag='-Bexport'
+ no_entry_flag=""
+ else
+ aix_use_runtimelinking=no
+
+ # Test if we are trying to use run time linking or normal
+ # AIX style linking. If -brtl is somewhere in LDFLAGS, we
+ # need to do runtime linking.
+ case $host_os in aix4.[[23]]|aix4.[[23]].*|aix[[5-9]]*)
+ for ld_flag in $LDFLAGS; do
+ case $ld_flag in
+ *-brtl*)
+ aix_use_runtimelinking=yes
+ break
+ ;;
+ esac
+ done
+ ;;
+ esac
+
+ exp_sym_flag='-bexport'
+ no_entry_flag='-bnoentry'
+ fi
+
+ # When large executables or shared objects are built, AIX ld can
+ # have problems creating the table of contents. If linking a library
+ # or program results in "error TOC overflow" add -mminimal-toc to
+ # CXXFLAGS/CFLAGS for g++/gcc. In the cases where that is not
+ # enough to fix the problem, add -Wl,-bbigtoc to LDFLAGS.
+
+ _LT_TAGVAR(archive_cmds, $1)=''
+ _LT_TAGVAR(hardcode_direct, $1)=yes
+ _LT_TAGVAR(hardcode_direct_absolute, $1)=yes
+ _LT_TAGVAR(hardcode_libdir_separator, $1)=':'
+ _LT_TAGVAR(link_all_deplibs, $1)=yes
+ _LT_TAGVAR(file_list_spec, $1)='${wl}-f,'
+
+ if test "$GXX" = yes; then
+ case $host_os in aix4.[[012]]|aix4.[[012]].*)
+ # We only want to do this on AIX 4.2 and lower, the check
+ # below for broken collect2 doesn't work under 4.3+
+ collect2name=`${CC} -print-prog-name=collect2`
+ if test -f "$collect2name" &&
+ strings "$collect2name" | $GREP resolve_lib_name >/dev/null
+ then
+ # We have reworked collect2
+ :
+ else
+ # We have old collect2
+ _LT_TAGVAR(hardcode_direct, $1)=unsupported
+ # It fails to find uninstalled libraries when the uninstalled
+ # path is not listed in the libpath. Setting hardcode_minus_L
+ # to unsupported forces relinking
+ _LT_TAGVAR(hardcode_minus_L, $1)=yes
+ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
+ _LT_TAGVAR(hardcode_libdir_separator, $1)=
+ fi
+ esac
+ shared_flag='-shared'
+ if test "$aix_use_runtimelinking" = yes; then
+ shared_flag="$shared_flag "'${wl}-G'
+ fi
+ else
+ # not using gcc
+ if test "$host_cpu" = ia64; then
+ # VisualAge C++, Version 5.5 for AIX 5L for IA-64, Beta 3 Release
+ # chokes on -Wl,-G. The following line is correct:
+ shared_flag='-G'
+ else
+ if test "$aix_use_runtimelinking" = yes; then
+ shared_flag='${wl}-G'
+ else
+ shared_flag='${wl}-bM:SRE'
+ fi
+ fi
+ fi
+
+ _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-bexpall'
+ # It seems that -bexpall does not export symbols beginning with
+ # underscore (_), so it is better to generate a list of symbols to
+ # export.
+ _LT_TAGVAR(always_export_symbols, $1)=yes
+ if test "$aix_use_runtimelinking" = yes; then
+ # Warning - without using the other runtime loading flags (-brtl),
+ # -berok will link without error, but may produce a broken library.
+ _LT_TAGVAR(allow_undefined_flag, $1)='-berok'
+ # Determine the default libpath from the value encoded in an empty
+ # executable.
+ _LT_SYS_MODULE_PATH_AIX([$1])
+ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-blibpath:$libdir:'"$aix_libpath"
+
+ _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags `if test "x${allow_undefined_flag}" != "x"; then func_echo_all "${wl}${allow_undefined_flag}"; else :; fi` '"\${wl}$exp_sym_flag:\$export_symbols $shared_flag"
+ else
+ if test "$host_cpu" = ia64; then
+ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-R $libdir:/usr/lib:/lib'
+ _LT_TAGVAR(allow_undefined_flag, $1)="-z nodefs"
+ _LT_TAGVAR(archive_expsym_cmds, $1)="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags ${wl}${allow_undefined_flag} '"\${wl}$exp_sym_flag:\$export_symbols"
+ else
+ # Determine the default libpath from the value encoded in an
+ # empty executable.
+ _LT_SYS_MODULE_PATH_AIX([$1])
+ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-blibpath:$libdir:'"$aix_libpath"
+ # Warning - without using the other run time loading flags,
+ # -berok will link without error, but may produce a broken library.
+ _LT_TAGVAR(no_undefined_flag, $1)=' ${wl}-bernotok'
+ _LT_TAGVAR(allow_undefined_flag, $1)=' ${wl}-berok'
+ if test "$with_gnu_ld" = yes; then
+ # We only use this code for GNU lds that support --whole-archive.
+ _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive$convenience ${wl}--no-whole-archive'
+ else
+ # Exported symbols can be pulled into shared objects from archives
+ _LT_TAGVAR(whole_archive_flag_spec, $1)='$convenience'
+ fi
+ _LT_TAGVAR(archive_cmds_need_lc, $1)=yes
+ # This is similar to how AIX traditionally builds its shared
+ # libraries.
+ _LT_TAGVAR(archive_expsym_cmds, $1)="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs ${wl}-bnoentry $compiler_flags ${wl}-bE:$export_symbols${allow_undefined_flag}~$AR $AR_FLAGS $output_objdir/$libname$release.a $output_objdir/$soname'
+ fi
+ fi
+ ;;
+
+ beos*)
+ if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then
+ _LT_TAGVAR(allow_undefined_flag, $1)=unsupported
+ # Joseph Beckenbach <jrb3@best.com> says some releases of gcc
+ # support --undefined. This deserves some investigation. FIXME
+ _LT_TAGVAR(archive_cmds, $1)='$CC -nostart $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+ else
+ _LT_TAGVAR(ld_shlibs, $1)=no
+ fi
+ ;;
+
+ chorus*)
+ case $cc_basename in
+ *)
+ # FIXME: insert proper C++ library support
+ _LT_TAGVAR(ld_shlibs, $1)=no
+ ;;
+ esac
+ ;;
+
+ cygwin* | mingw* | pw32* | cegcc*)
+ case $GXX,$cc_basename in
+ ,cl* | no,cl*)
+ # Native MSVC
+ # hardcode_libdir_flag_spec is actually meaningless, as there is
+ # no search path for DLLs.
+ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)=' '
+ _LT_TAGVAR(allow_undefined_flag, $1)=unsupported
+ _LT_TAGVAR(always_export_symbols, $1)=yes
+ _LT_TAGVAR(file_list_spec, $1)='@'
+ # Tell ltmain to make .lib files, not .a files.
+ libext=lib
+ # Tell ltmain to make .dll files, not .so files.
+ shrext_cmds=".dll"
+ # FIXME: Setting linknames here is a bad hack.
+ _LT_TAGVAR(archive_cmds, $1)='$CC -o $output_objdir/$soname $libobjs $compiler_flags $deplibs -Wl,-dll~linknames='
+ _LT_TAGVAR(archive_expsym_cmds, $1)='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then
+ $SED -n -e 's/\\\\\\\(.*\\\\\\\)/-link\\\ -EXPORT:\\\\\\\1/' -e '1\\\!p' < $export_symbols > $output_objdir/$soname.exp;
+ else
+ $SED -e 's/\\\\\\\(.*\\\\\\\)/-link\\\ -EXPORT:\\\\\\\1/' < $export_symbols > $output_objdir/$soname.exp;
+ fi~
+ $CC -o $tool_output_objdir$soname $libobjs $compiler_flags $deplibs "@$tool_output_objdir$soname.exp" -Wl,-DLL,-IMPLIB:"$tool_output_objdir$libname.dll.lib"~
+ linknames='
+ # The linker will not automatically build a static lib if we build a DLL.
+ # _LT_TAGVAR(old_archive_from_new_cmds, $1)='true'
+ _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=yes
+ # Don't use ranlib
+ _LT_TAGVAR(old_postinstall_cmds, $1)='chmod 644 $oldlib'
+ _LT_TAGVAR(postlink_cmds, $1)='lt_outputfile="@OUTPUT@"~
+ lt_tool_outputfile="@TOOL_OUTPUT@"~
+ case $lt_outputfile in
+ *.exe|*.EXE) ;;
+ *)
+ lt_outputfile="$lt_outputfile.exe"
+ lt_tool_outputfile="$lt_tool_outputfile.exe"
+ ;;
+ esac~
+ func_to_tool_file "$lt_outputfile"~
+ if test "$MANIFEST_TOOL" != ":" && test -f "$lt_outputfile.manifest"; then
+ $MANIFEST_TOOL -manifest "$lt_tool_outputfile.manifest" -outputresource:"$lt_tool_outputfile" || exit 1;
+ $RM "$lt_outputfile.manifest";
+ fi'
+ ;;
+ *)
+ # g++
+ # _LT_TAGVAR(hardcode_libdir_flag_spec, $1) is actually meaningless,
+ # as there is no search path for DLLs.
+ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
+ _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-all-symbols'
+ _LT_TAGVAR(allow_undefined_flag, $1)=unsupported
+ _LT_TAGVAR(always_export_symbols, $1)=no
+ _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=yes
+
+ if $LD --help 2>&1 | $GREP 'auto-import' > /dev/null; then
+ _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib'
+ # If the export-symbols file already is a .def file (1st line
+ # is EXPORTS), use it as is; otherwise, prepend...
+ _LT_TAGVAR(archive_expsym_cmds, $1)='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then
+ cp $export_symbols $output_objdir/$soname.def;
+ else
+ echo EXPORTS > $output_objdir/$soname.def;
+ cat $export_symbols >> $output_objdir/$soname.def;
+ fi~
+ $CC -shared -nostdlib $output_objdir/$soname.def $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib'
+ else
+ _LT_TAGVAR(ld_shlibs, $1)=no
+ fi
+ ;;
+ esac
+ ;;
+ darwin* | rhapsody*)
+ _LT_DARWIN_LINKER_FEATURES($1)
+ ;;
+
+ dgux*)
+ case $cc_basename in
+ ec++*)
+ # FIXME: insert proper C++ library support
+ _LT_TAGVAR(ld_shlibs, $1)=no
+ ;;
+ ghcx*)
+ # Green Hills C++ Compiler
+ # FIXME: insert proper C++ library support
+ _LT_TAGVAR(ld_shlibs, $1)=no
+ ;;
+ *)
+ # FIXME: insert proper C++ library support
+ _LT_TAGVAR(ld_shlibs, $1)=no
+ ;;
+ esac
+ ;;
+
+ freebsd2.*)
+ # C++ shared libraries reported to be fairly broken before
+ # switch to ELF
+ _LT_TAGVAR(ld_shlibs, $1)=no
+ ;;
+
+ freebsd-elf*)
+ _LT_TAGVAR(archive_cmds_need_lc, $1)=no
+ ;;
+
+ freebsd* | dragonfly*)
+ # FreeBSD 3 and later use GNU C++ and GNU ld with standard ELF
+ # conventions
+ _LT_TAGVAR(ld_shlibs, $1)=yes
+ ;;
+
+ gnu*)
+ ;;
+
+ haiku*)
+ _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+ _LT_TAGVAR(link_all_deplibs, $1)=yes
+ ;;
+
+ hpux9*)
+ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir'
+ _LT_TAGVAR(hardcode_libdir_separator, $1)=:
+ _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E'
+ _LT_TAGVAR(hardcode_direct, $1)=yes
+ _LT_TAGVAR(hardcode_minus_L, $1)=yes # Not in the search PATH,
+ # but as the default
+ # location of the library.
+
+ case $cc_basename in
+ CC*)
+ # FIXME: insert proper C++ library support
+ _LT_TAGVAR(ld_shlibs, $1)=no
+ ;;
+ aCC*)
+ _LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/$soname~$CC -b ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib'
+ # Commands to make compiler produce verbose output that lists
+ # what "hidden" libraries, object files and flags are used when
+ # linking a shared library.
+ #
+ # There doesn't appear to be a way to prevent this compiler from
+ # explicitly linking system object files so we need to strip them
+ # from the output so that they don't get included in the library
+ # dependencies.
+ output_verbose_link_cmd='templist=`($CC -b $CFLAGS -v conftest.$objext 2>&1) | $EGREP "\-L"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "$list"'
+ ;;
+ *)
+ if test "$GXX" = yes; then
+ _LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/$soname~$CC -shared -nostdlib $pic_flag ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib'
+ else
+ # FIXME: insert proper C++ library support
+ _LT_TAGVAR(ld_shlibs, $1)=no
+ fi
+ ;;
+ esac
+ ;;
+
+ hpux10*|hpux11*)
+ if test $with_gnu_ld = no; then
+ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir'
+ _LT_TAGVAR(hardcode_libdir_separator, $1)=:
+
+ case $host_cpu in
+ hppa*64*|ia64*)
+ ;;
+ *)
+ _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E'
+ ;;
+ esac
+ fi
+ case $host_cpu in
+ hppa*64*|ia64*)
+ _LT_TAGVAR(hardcode_direct, $1)=no
+ _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
+ ;;
+ *)
+ _LT_TAGVAR(hardcode_direct, $1)=yes
+ _LT_TAGVAR(hardcode_direct_absolute, $1)=yes
+ _LT_TAGVAR(hardcode_minus_L, $1)=yes # Not in the search PATH,
+ # but as the default
+ # location of the library.
+ ;;
+ esac
+
+ case $cc_basename in
+ CC*)
+ # FIXME: insert proper C++ library support
+ _LT_TAGVAR(ld_shlibs, $1)=no
+ ;;
+ aCC*)
+ case $host_cpu in
+ hppa*64*)
+ _LT_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
+ ;;
+ ia64*)
+ _LT_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
+ ;;
+ *)
+ _LT_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
+ ;;
+ esac
+ # Commands to make compiler produce verbose output that lists
+ # what "hidden" libraries, object files and flags are used when
+ # linking a shared library.
+ #
+ # There doesn't appear to be a way to prevent this compiler from
+ # explicitly linking system object files so we need to strip them
+ # from the output so that they don't get included in the library
+ # dependencies.
+ output_verbose_link_cmd='templist=`($CC -b $CFLAGS -v conftest.$objext 2>&1) | $GREP "\-L"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "$list"'
+ ;;
+ *)
+ if test "$GXX" = yes; then
+ if test $with_gnu_ld = no; then
+ case $host_cpu in
+ hppa*64*)
+ _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib -fPIC ${wl}+h ${wl}$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
+ ;;
+ ia64*)
+ _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $pic_flag ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
+ ;;
+ *)
+ _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $pic_flag ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
+ ;;
+ esac
+ fi
+ else
+ # FIXME: insert proper C++ library support
+ _LT_TAGVAR(ld_shlibs, $1)=no
+ fi
+ ;;
+ esac
+ ;;
+
+ interix[[3-9]]*)
+ _LT_TAGVAR(hardcode_direct, $1)=no
+ _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
+ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir'
+ _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E'
+ # Hack: On Interix 3.x, we cannot compile PIC because of a broken gcc.
+ # Instead, shared libraries are loaded at an image base (0x10000000 by
+ # default) and relocated if they conflict, which is a slow very memory
+ # consuming and fragmenting process. To avoid this, we pick a random,
+ # 256 KiB-aligned image base between 0x50000000 and 0x6FFC0000 at link
+ # time. Moving up from 0x10000000 also allows more sbrk(2) space.
+ _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib'
+ _LT_TAGVAR(archive_expsym_cmds, $1)='sed "s,^,_," $export_symbols >$output_objdir/$soname.expsym~$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--retain-symbols-file,$output_objdir/$soname.expsym ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib'
+ ;;
+ irix5* | irix6*)
+ case $cc_basename in
+ CC*)
+ # SGI C++
+ _LT_TAGVAR(archive_cmds, $1)='$CC -shared -all -multigot $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib'
+
+ # Archives containing C++ object files must be created using
+ # "CC -ar", where "CC" is the IRIX C++ compiler. This is
+ # necessary to make sure instantiated templates are included
+ # in the archive.
+ _LT_TAGVAR(old_archive_cmds, $1)='$CC -ar -WR,-u -o $oldlib $oldobjs'
+ ;;
+ *)
+ if test "$GXX" = yes; then
+ if test "$with_gnu_ld" = no; then
+ _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
+ else
+ _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` -o $lib'
+ fi
+ fi
+ _LT_TAGVAR(link_all_deplibs, $1)=yes
+ ;;
+ esac
+ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
+ _LT_TAGVAR(hardcode_libdir_separator, $1)=:
+ _LT_TAGVAR(inherit_rpath, $1)=yes
+ ;;
+
+ linux* | k*bsd*-gnu | kopensolaris*-gnu)
+ case $cc_basename in
+ KCC*)
+ # Kuck and Associates, Inc. (KAI) C++ Compiler
+
+ # KCC will only create a shared library if the output file
+ # ends with ".so" (or ".sl" for HP-UX), so rename the library
+ # to its proper name (with version) after linking.
+ _LT_TAGVAR(archive_cmds, $1)='tempext=`echo $shared_ext | $SED -e '\''s/\([[^()0-9A-Za-z{}]]\)/\\\\\1/g'\''`; templib=`echo $lib | $SED -e "s/\${tempext}\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib; mv \$templib $lib'
+ _LT_TAGVAR(archive_expsym_cmds, $1)='tempext=`echo $shared_ext | $SED -e '\''s/\([[^()0-9A-Za-z{}]]\)/\\\\\1/g'\''`; templib=`echo $lib | $SED -e "s/\${tempext}\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib ${wl}-retain-symbols-file,$export_symbols; mv \$templib $lib'
+ # Commands to make compiler produce verbose output that lists
+ # what "hidden" libraries, object files and flags are used when
+ # linking a shared library.
+ #
+ # There doesn't appear to be a way to prevent this compiler from
+ # explicitly linking system object files so we need to strip them
+ # from the output so that they don't get included in the library
+ # dependencies.
+ output_verbose_link_cmd='templist=`$CC $CFLAGS -v conftest.$objext -o libconftest$shared_ext 2>&1 | $GREP "ld"`; rm -f libconftest$shared_ext; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "$list"'
+
+ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir'
+ _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic'
+
+ # Archives containing C++ object files must be created using
+ # "CC -Bstatic", where "CC" is the KAI C++ compiler.
+ _LT_TAGVAR(old_archive_cmds, $1)='$CC -Bstatic -o $oldlib $oldobjs'
+ ;;
+ icpc* | ecpc* )
+ # Intel C++
+ with_gnu_ld=yes
+ # version 8.0 and above of icpc choke on multiply defined symbols
+ # if we add $predep_objects and $postdep_objects, however 7.1 and
+ # earlier do not add the objects themselves.
+ case `$CC -V 2>&1` in
+ *"Version 7."*)
+ _LT_TAGVAR(archive_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib'
+ _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
+ ;;
+ *) # Version 8.0 or newer
+ tmp_idyn=
+ case $host_cpu in
+ ia64*) tmp_idyn=' -i_dynamic';;
+ esac
+ _LT_TAGVAR(archive_cmds, $1)='$CC -shared'"$tmp_idyn"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+ _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared'"$tmp_idyn"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
+ ;;
+ esac
+ _LT_TAGVAR(archive_cmds_need_lc, $1)=no
+ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir'
+ _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic'
+ _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive$convenience ${wl}--no-whole-archive'
+ ;;
+ pgCC* | pgcpp*)
+ # Portland Group C++ compiler
+ case `$CC -V` in
+ *pgCC\ [[1-5]].* | *pgcpp\ [[1-5]].*)
+ _LT_TAGVAR(prelink_cmds, $1)='tpldir=Template.dir~
+ rm -rf $tpldir~
+ $CC --prelink_objects --instantiation_dir $tpldir $objs $libobjs $compile_deplibs~
+ compile_command="$compile_command `find $tpldir -name \*.o | sort | $NL2SP`"'
+ _LT_TAGVAR(old_archive_cmds, $1)='tpldir=Template.dir~
+ rm -rf $tpldir~
+ $CC --prelink_objects --instantiation_dir $tpldir $oldobjs$old_deplibs~
+ $AR $AR_FLAGS $oldlib$oldobjs$old_deplibs `find $tpldir -name \*.o | sort | $NL2SP`~
+ $RANLIB $oldlib'
+ _LT_TAGVAR(archive_cmds, $1)='tpldir=Template.dir~
+ rm -rf $tpldir~
+ $CC --prelink_objects --instantiation_dir $tpldir $predep_objects $libobjs $deplibs $convenience $postdep_objects~
+ $CC -shared $pic_flag $predep_objects $libobjs $deplibs `find $tpldir -name \*.o | sort | $NL2SP` $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname -o $lib'
+ _LT_TAGVAR(archive_expsym_cmds, $1)='tpldir=Template.dir~
+ rm -rf $tpldir~
+ $CC --prelink_objects --instantiation_dir $tpldir $predep_objects $libobjs $deplibs $convenience $postdep_objects~
+ $CC -shared $pic_flag $predep_objects $libobjs $deplibs `find $tpldir -name \*.o | sort | $NL2SP` $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname ${wl}-retain-symbols-file ${wl}$export_symbols -o $lib'
+ ;;
+ *) # Version 6 and above use weak symbols
+ _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname -o $lib'
+ _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname ${wl}-retain-symbols-file ${wl}$export_symbols -o $lib'
+ ;;
+ esac
+
+ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}--rpath ${wl}$libdir'
+ _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic'
+ _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` ${wl}--no-whole-archive'
+ ;;
+ cxx*)
+ # Compaq C++
+ _LT_TAGVAR(archive_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib'
+ _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib ${wl}-retain-symbols-file $wl$export_symbols'
+
+ runpath_var=LD_RUN_PATH
+ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-rpath $libdir'
+ _LT_TAGVAR(hardcode_libdir_separator, $1)=:
+
+ # Commands to make compiler produce verbose output that lists
+ # what "hidden" libraries, object files and flags are used when
+ # linking a shared library.
+ #
+ # There doesn't appear to be a way to prevent this compiler from
+ # explicitly linking system object files so we need to strip them
+ # from the output so that they don't get included in the library
+ # dependencies.
+ output_verbose_link_cmd='templist=`$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP "ld"`; templist=`func_echo_all "$templist" | $SED "s/\(^.*ld.*\)\( .*ld .*$\)/\1/"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "X$list" | $Xsed'
+ ;;
+ xl* | mpixl* | bgxl*)
+ # IBM XL 8.0 on PPC, with GNU ld
+ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
+ _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic'
+ _LT_TAGVAR(archive_cmds, $1)='$CC -qmkshrobj $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+ if test "x$supports_anon_versioning" = xyes; then
+ _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $output_objdir/$libname.ver~
+ cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~
+ echo "local: *; };" >> $output_objdir/$libname.ver~
+ $CC -qmkshrobj $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-version-script ${wl}$output_objdir/$libname.ver -o $lib'
+ fi
+ ;;
+ *)
+ case `$CC -V 2>&1 | sed 5q` in
+ *Sun\ C*)
+ # Sun C++ 5.9
+ _LT_TAGVAR(no_undefined_flag, $1)=' -zdefs'
+ _LT_TAGVAR(archive_cmds, $1)='$CC -G${allow_undefined_flag} -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
+ _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -G${allow_undefined_flag} -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-retain-symbols-file ${wl}$export_symbols'
+ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir'
+ _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive`new_convenience=; for conv in $convenience\"\"; do test -z \"$conv\" || new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` ${wl}--no-whole-archive'
+ _LT_TAGVAR(compiler_needs_object, $1)=yes
+
+ # Not sure whether something based on
+ # $CC $CFLAGS -v conftest.$objext -o libconftest$shared_ext 2>&1
+ # would be better.
+ output_verbose_link_cmd='func_echo_all'
+
+ # Archives containing C++ object files must be created using
+ # "CC -xar", where "CC" is the Sun C++ compiler. This is
+ # necessary to make sure instantiated templates are included
+ # in the archive.
+ _LT_TAGVAR(old_archive_cmds, $1)='$CC -xar -o $oldlib $oldobjs'
+ ;;
+ esac
+ ;;
+ esac
+ ;;
+
+ lynxos*)
+ # FIXME: insert proper C++ library support
+ _LT_TAGVAR(ld_shlibs, $1)=no
+ ;;
+
+ m88k*)
+ # FIXME: insert proper C++ library support
+ _LT_TAGVAR(ld_shlibs, $1)=no
+ ;;
+
+ mvs*)
+ case $cc_basename in
+ cxx*)
+ # FIXME: insert proper C++ library support
+ _LT_TAGVAR(ld_shlibs, $1)=no
+ ;;
+ *)
+ # FIXME: insert proper C++ library support
+ _LT_TAGVAR(ld_shlibs, $1)=no
+ ;;
+ esac
+ ;;
+
+ netbsd*)
+ if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then
+ _LT_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $predep_objects $libobjs $deplibs $postdep_objects $linker_flags'
+ wlarc=
+ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir'
+ _LT_TAGVAR(hardcode_direct, $1)=yes
+ _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
+ fi
+ # Workaround some broken pre-1.5 toolchains
+ output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP conftest.$objext | $SED -e "s:-lgcc -lc -lgcc::"'
+ ;;
+
+ *nto* | *qnx*)
+ _LT_TAGVAR(ld_shlibs, $1)=yes
+ ;;
+
+ openbsd2*)
+ # C++ shared libraries are fairly broken
+ _LT_TAGVAR(ld_shlibs, $1)=no
+ ;;
+
+ openbsd*)
+ if test -f /usr/libexec/ld.so; then
+ _LT_TAGVAR(hardcode_direct, $1)=yes
+ _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
+ _LT_TAGVAR(hardcode_direct_absolute, $1)=yes
+ _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $lib'
+ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir'
+ if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then
+ _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-retain-symbols-file,$export_symbols -o $lib'
+ _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E'
+ _LT_TAGVAR(whole_archive_flag_spec, $1)="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive'
+ fi
+ output_verbose_link_cmd=func_echo_all
+ else
+ _LT_TAGVAR(ld_shlibs, $1)=no
+ fi
+ ;;
+
+ osf3* | osf4* | osf5*)
+ case $cc_basename in
+ KCC*)
+ # Kuck and Associates, Inc. (KAI) C++ Compiler
+
+ # KCC will only create a shared library if the output file
+ # ends with ".so" (or ".sl" for HP-UX), so rename the library
+ # to its proper name (with version) after linking.
+ _LT_TAGVAR(archive_cmds, $1)='tempext=`echo $shared_ext | $SED -e '\''s/\([[^()0-9A-Za-z{}]]\)/\\\\\1/g'\''`; templib=`echo "$lib" | $SED -e "s/\${tempext}\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib; mv \$templib $lib'
+
+ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir'
+ _LT_TAGVAR(hardcode_libdir_separator, $1)=:
+
+ # Archives containing C++ object files must be created using
+ # the KAI C++ compiler.
+ case $host in
+ osf3*) _LT_TAGVAR(old_archive_cmds, $1)='$CC -Bstatic -o $oldlib $oldobjs' ;;
+ *) _LT_TAGVAR(old_archive_cmds, $1)='$CC -o $oldlib $oldobjs' ;;
+ esac
+ ;;
+ RCC*)
+ # Rational C++ 2.4.1
+ # FIXME: insert proper C++ library support
+ _LT_TAGVAR(ld_shlibs, $1)=no
+ ;;
+ cxx*)
+ case $host in
+ osf3*)
+ _LT_TAGVAR(allow_undefined_flag, $1)=' ${wl}-expect_unresolved ${wl}\*'
+ _LT_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $soname `test -n "$verstring" && func_echo_all "${wl}-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib'
+ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
+ ;;
+ *)
+ _LT_TAGVAR(allow_undefined_flag, $1)=' -expect_unresolved \*'
+ _LT_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -msym -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib'
+ _LT_TAGVAR(archive_expsym_cmds, $1)='for i in `cat $export_symbols`; do printf "%s %s\\n" -exported_symbol "\$i" >> $lib.exp; done~
+ echo "-hidden">> $lib.exp~
+ $CC -shared$allow_undefined_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -msym -soname $soname ${wl}-input ${wl}$lib.exp `test -n "$verstring" && $ECHO "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib~
+ $RM $lib.exp'
+ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-rpath $libdir'
+ ;;
+ esac
+
+ _LT_TAGVAR(hardcode_libdir_separator, $1)=:
+
+ # Commands to make compiler produce verbose output that lists
+ # what "hidden" libraries, object files and flags are used when
+ # linking a shared library.
+ #
+ # There doesn't appear to be a way to prevent this compiler from
+ # explicitly linking system object files so we need to strip them
+ # from the output so that they don't get included in the library
+ # dependencies.
+ output_verbose_link_cmd='templist=`$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP "ld" | $GREP -v "ld:"`; templist=`func_echo_all "$templist" | $SED "s/\(^.*ld.*\)\( .*ld.*$\)/\1/"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "$list"'
+ ;;
+ *)
+ if test "$GXX" = yes && test "$with_gnu_ld" = no; then
+ _LT_TAGVAR(allow_undefined_flag, $1)=' ${wl}-expect_unresolved ${wl}\*'
+ case $host in
+ osf3*)
+ _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib ${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
+ ;;
+ *)
+ _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -nostdlib ${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-msym ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
+ ;;
+ esac
+
+ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
+ _LT_TAGVAR(hardcode_libdir_separator, $1)=:
+
+ # Commands to make compiler produce verbose output that lists
+ # what "hidden" libraries, object files and flags are used when
+ # linking a shared library.
+ output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP -v "^Configured with:" | $GREP "\-L"'
+
+ else
+ # FIXME: insert proper C++ library support
+ _LT_TAGVAR(ld_shlibs, $1)=no
+ fi
+ ;;
+ esac
+ ;;
+
+ psos*)
+ # FIXME: insert proper C++ library support
+ _LT_TAGVAR(ld_shlibs, $1)=no
+ ;;
+
+ sunos4*)
+ case $cc_basename in
+ CC*)
+ # Sun C++ 4.x
+ # FIXME: insert proper C++ library support
+ _LT_TAGVAR(ld_shlibs, $1)=no
+ ;;
+ lcc*)
+ # Lucid
+ # FIXME: insert proper C++ library support
+ _LT_TAGVAR(ld_shlibs, $1)=no
+ ;;
+ *)
+ # FIXME: insert proper C++ library support
+ _LT_TAGVAR(ld_shlibs, $1)=no
+ ;;
+ esac
+ ;;
+
+ solaris*)
+ case $cc_basename in
+ CC* | sunCC*)
+ # Sun C++ 4.2, 5.x and Centerline C++
+ _LT_TAGVAR(archive_cmds_need_lc,$1)=yes
+ _LT_TAGVAR(no_undefined_flag, $1)=' -zdefs'
+ _LT_TAGVAR(archive_cmds, $1)='$CC -G${allow_undefined_flag} -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
+ _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~
+ $CC -G${allow_undefined_flag} ${wl}-M ${wl}$lib.exp -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$RM $lib.exp'
+
+ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir'
+ _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
+ case $host_os in
+ solaris2.[[0-5]] | solaris2.[[0-5]].*) ;;
+ *)
+ # The compiler driver will combine and reorder linker options,
+ # but understands `-z linker_flag'.
+ # Supported since Solaris 2.6 (maybe 2.5.1?)
+ _LT_TAGVAR(whole_archive_flag_spec, $1)='-z allextract$convenience -z defaultextract'
+ ;;
+ esac
+ _LT_TAGVAR(link_all_deplibs, $1)=yes
+
+ output_verbose_link_cmd='func_echo_all'
+
+ # Archives containing C++ object files must be created using
+ # "CC -xar", where "CC" is the Sun C++ compiler. This is
+ # necessary to make sure instantiated templates are included
+ # in the archive.
+ _LT_TAGVAR(old_archive_cmds, $1)='$CC -xar -o $oldlib $oldobjs'
+ ;;
+ gcx*)
+ # Green Hills C++ Compiler
+ _LT_TAGVAR(archive_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-h $wl$soname -o $lib'
+
+ # The C++ compiler must be used to create the archive.
+ _LT_TAGVAR(old_archive_cmds, $1)='$CC $LDFLAGS -archive -o $oldlib $oldobjs'
+ ;;
+ *)
+ # GNU C++ compiler with Solaris linker
+ if test "$GXX" = yes && test "$with_gnu_ld" = no; then
+ _LT_TAGVAR(no_undefined_flag, $1)=' ${wl}-z ${wl}defs'
+ if $CC --version | $GREP -v '^2\.7' > /dev/null; then
+ _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -nostdlib $LDFLAGS $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-h $wl$soname -o $lib'
+ _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~
+ $CC -shared $pic_flag -nostdlib ${wl}-M $wl$lib.exp -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$RM $lib.exp'
+
+ # Commands to make compiler produce verbose output that lists
+ # what "hidden" libraries, object files and flags are used when
+ # linking a shared library.
+ output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP -v "^Configured with:" | $GREP "\-L"'
+ else
+ # g++ 2.7 appears to require `-G' NOT `-shared' on this
+ # platform.
+ _LT_TAGVAR(archive_cmds, $1)='$CC -G -nostdlib $LDFLAGS $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-h $wl$soname -o $lib'
+ _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~
+ $CC -G -nostdlib ${wl}-M $wl$lib.exp -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$RM $lib.exp'
+
+ # Commands to make compiler produce verbose output that lists
+ # what "hidden" libraries, object files and flags are used when
+ # linking a shared library.
+ output_verbose_link_cmd='$CC -G $CFLAGS -v conftest.$objext 2>&1 | $GREP -v "^Configured with:" | $GREP "\-L"'
+ fi
+
+ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-R $wl$libdir'
+ case $host_os in
+ solaris2.[[0-5]] | solaris2.[[0-5]].*) ;;
+ *)
+ _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}-z ${wl}allextract$convenience ${wl}-z ${wl}defaultextract'
+ ;;
+ esac
+ fi
+ ;;
+ esac
+ ;;
+
+ sysv4*uw2* | sysv5OpenUNIX* | sysv5UnixWare7.[[01]].[[10]]* | unixware7* | sco3.2v5.0.[[024]]*)
+ _LT_TAGVAR(no_undefined_flag, $1)='${wl}-z,text'
+ _LT_TAGVAR(archive_cmds_need_lc, $1)=no
+ _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
+ runpath_var='LD_RUN_PATH'
+
+ case $cc_basename in
+ CC*)
+ _LT_TAGVAR(archive_cmds, $1)='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+ _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+ ;;
+ *)
+ _LT_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+ _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+ ;;
+ esac
+ ;;
+
+ sysv5* | sco3.2v5* | sco5v6*)
+ # Note: We can NOT use -z defs as we might desire, because we do not
+ # link with -lc, and that would cause any symbols used from libc to
+ # always be unresolved, which means just about no library would
+ # ever link correctly. If we're not using GNU ld we use -z text
+ # though, which does catch some bad symbols but isn't as heavy-handed
+ # as -z defs.
+ _LT_TAGVAR(no_undefined_flag, $1)='${wl}-z,text'
+ _LT_TAGVAR(allow_undefined_flag, $1)='${wl}-z,nodefs'
+ _LT_TAGVAR(archive_cmds_need_lc, $1)=no
+ _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
+ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-R,$libdir'
+ _LT_TAGVAR(hardcode_libdir_separator, $1)=':'
+ _LT_TAGVAR(link_all_deplibs, $1)=yes
+ _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-Bexport'
+ runpath_var='LD_RUN_PATH'
+
+ case $cc_basename in
+ CC*)
+ _LT_TAGVAR(archive_cmds, $1)='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+ _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+ _LT_TAGVAR(old_archive_cmds, $1)='$CC -Tprelink_objects $oldobjs~
+ '"$_LT_TAGVAR(old_archive_cmds, $1)"
+ _LT_TAGVAR(reload_cmds, $1)='$CC -Tprelink_objects $reload_objs~
+ '"$_LT_TAGVAR(reload_cmds, $1)"
+ ;;
+ *)
+ _LT_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+ _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+ ;;
+ esac
+ ;;
+
+ tandem*)
+ case $cc_basename in
+ NCC*)
+ # NonStop-UX NCC 3.20
+ # FIXME: insert proper C++ library support
+ _LT_TAGVAR(ld_shlibs, $1)=no
+ ;;
+ *)
+ # FIXME: insert proper C++ library support
+ _LT_TAGVAR(ld_shlibs, $1)=no
+ ;;
+ esac
+ ;;
+
+ vxworks*)
+ # FIXME: insert proper C++ library support
+ _LT_TAGVAR(ld_shlibs, $1)=no
+ ;;
+
+ *)
+ # FIXME: insert proper C++ library support
+ _LT_TAGVAR(ld_shlibs, $1)=no
+ ;;
+ esac
+
+ AC_MSG_RESULT([$_LT_TAGVAR(ld_shlibs, $1)])
+ test "$_LT_TAGVAR(ld_shlibs, $1)" = no && can_build_shared=no
+
+ _LT_TAGVAR(GCC, $1)="$GXX"
+ _LT_TAGVAR(LD, $1)="$LD"
+
+ ## CAVEAT EMPTOR:
+ ## There is no encapsulation within the following macros, do not change
+ ## the running order or otherwise move them around unless you know exactly
+ ## what you are doing...
+ _LT_SYS_HIDDEN_LIBDEPS($1)
+ _LT_COMPILER_PIC($1)
+ _LT_COMPILER_C_O($1)
+ _LT_COMPILER_FILE_LOCKS($1)
+ _LT_LINKER_SHLIBS($1)
+ _LT_SYS_DYNAMIC_LINKER($1)
+ _LT_LINKER_HARDCODE_LIBPATH($1)
+
+ _LT_CONFIG($1)
+ fi # test -n "$compiler"
+
+ CC=$lt_save_CC
+ CFLAGS=$lt_save_CFLAGS
+ LDCXX=$LD
+ LD=$lt_save_LD
+ GCC=$lt_save_GCC
+ with_gnu_ld=$lt_save_with_gnu_ld
+ lt_cv_path_LDCXX=$lt_cv_path_LD
+ lt_cv_path_LD=$lt_save_path_LD
+ lt_cv_prog_gnu_ldcxx=$lt_cv_prog_gnu_ld
+ lt_cv_prog_gnu_ld=$lt_save_with_gnu_ld
+fi # test "$_lt_caught_CXX_error" != yes
+
+AC_LANG_POP
+])# _LT_LANG_CXX_CONFIG
+
+
+# _LT_FUNC_STRIPNAME_CNF
+# ----------------------
+# func_stripname_cnf prefix suffix name
+# strip PREFIX and SUFFIX off of NAME.
+# PREFIX and SUFFIX must not contain globbing or regex special
+# characters, hashes, percent signs, but SUFFIX may contain a leading
+# dot (in which case that matches only a dot).
+#
+# This function is identical to the (non-XSI) version of func_stripname,
+# except this one can be used by m4 code that may be executed by configure,
+# rather than the libtool script.
+m4_defun([_LT_FUNC_STRIPNAME_CNF],[dnl
+AC_REQUIRE([_LT_DECL_SED])
+AC_REQUIRE([_LT_PROG_ECHO_BACKSLASH])
+func_stripname_cnf ()
+{
+ case ${2} in
+ .*) func_stripname_result=`$ECHO "${3}" | $SED "s%^${1}%%; s%\\\\${2}\$%%"`;;
+ *) func_stripname_result=`$ECHO "${3}" | $SED "s%^${1}%%; s%${2}\$%%"`;;
+ esac
+} # func_stripname_cnf
+])# _LT_FUNC_STRIPNAME_CNF
+
+# _LT_SYS_HIDDEN_LIBDEPS([TAGNAME])
+# ---------------------------------
+# Figure out "hidden" library dependencies from verbose
+# compiler output when linking a shared library.
+# Parse the compiler output and extract the necessary
+# objects, libraries and library flags.
+m4_defun([_LT_SYS_HIDDEN_LIBDEPS],
+[m4_require([_LT_FILEUTILS_DEFAULTS])dnl
+AC_REQUIRE([_LT_FUNC_STRIPNAME_CNF])dnl
+# Dependencies to place before and after the object being linked:
+_LT_TAGVAR(predep_objects, $1)=
+_LT_TAGVAR(postdep_objects, $1)=
+_LT_TAGVAR(predeps, $1)=
+_LT_TAGVAR(postdeps, $1)=
+_LT_TAGVAR(compiler_lib_search_path, $1)=
+
+dnl we can't use the lt_simple_compile_test_code here,
+dnl because it contains code intended for an executable,
+dnl not a library. It's possible we should let each
+dnl tag define a new lt_????_link_test_code variable,
+dnl but it's only used here...
+m4_if([$1], [], [cat > conftest.$ac_ext <<_LT_EOF
+int a;
+void foo (void) { a = 0; }
+_LT_EOF
+], [$1], [CXX], [cat > conftest.$ac_ext <<_LT_EOF
+class Foo
+{
+public:
+ Foo (void) { a = 0; }
+private:
+ int a;
+};
+_LT_EOF
+], [$1], [F77], [cat > conftest.$ac_ext <<_LT_EOF
+ subroutine foo
+ implicit none
+ integer*4 a
+ a=0
+ return
+ end
+_LT_EOF
+], [$1], [FC], [cat > conftest.$ac_ext <<_LT_EOF
+ subroutine foo
+ implicit none
+ integer a
+ a=0
+ return
+ end
+_LT_EOF
+], [$1], [GCJ], [cat > conftest.$ac_ext <<_LT_EOF
+public class foo {
+ private int a;
+ public void bar (void) {
+ a = 0;
+ }
+};
+_LT_EOF
+], [$1], [GO], [cat > conftest.$ac_ext <<_LT_EOF
+package foo
+func foo() {
+}
+_LT_EOF
+])
+
+_lt_libdeps_save_CFLAGS=$CFLAGS
+case "$CC $CFLAGS " in #(
+*\ -flto*\ *) CFLAGS="$CFLAGS -fno-lto" ;;
+*\ -fwhopr*\ *) CFLAGS="$CFLAGS -fno-whopr" ;;
+*\ -fuse-linker-plugin*\ *) CFLAGS="$CFLAGS -fno-use-linker-plugin" ;;
+esac
+
+dnl Parse the compiler output and extract the necessary
+dnl objects, libraries and library flags.
+if AC_TRY_EVAL(ac_compile); then
+ # Parse the compiler output and extract the necessary
+ # objects, libraries and library flags.
+
+ # Sentinel used to keep track of whether or not we are before
+ # the conftest object file.
+ pre_test_object_deps_done=no
+
+ for p in `eval "$output_verbose_link_cmd"`; do
+ case ${prev}${p} in
+
+ -L* | -R* | -l*)
+ # Some compilers place space between "-{L,R}" and the path.
+ # Remove the space.
+ if test $p = "-L" ||
+ test $p = "-R"; then
+ prev=$p
+ continue
+ fi
+
+ # Expand the sysroot to ease extracting the directories later.
+ if test -z "$prev"; then
+ case $p in
+ -L*) func_stripname_cnf '-L' '' "$p"; prev=-L; p=$func_stripname_result ;;
+ -R*) func_stripname_cnf '-R' '' "$p"; prev=-R; p=$func_stripname_result ;;
+ -l*) func_stripname_cnf '-l' '' "$p"; prev=-l; p=$func_stripname_result ;;
+ esac
+ fi
+ case $p in
+ =*) func_stripname_cnf '=' '' "$p"; p=$lt_sysroot$func_stripname_result ;;
+ esac
+ if test "$pre_test_object_deps_done" = no; then
+ case ${prev} in
+ -L | -R)
+ # Internal compiler library paths should come after those
+ # provided the user. The postdeps already come after the
+ # user supplied libs so there is no need to process them.
+ if test -z "$_LT_TAGVAR(compiler_lib_search_path, $1)"; then
+ _LT_TAGVAR(compiler_lib_search_path, $1)="${prev}${p}"
+ else
+ _LT_TAGVAR(compiler_lib_search_path, $1)="${_LT_TAGVAR(compiler_lib_search_path, $1)} ${prev}${p}"
+ fi
+ ;;
+ # The "-l" case would never come before the object being
+ # linked, so don't bother handling this case.
+ esac
+ else
+ if test -z "$_LT_TAGVAR(postdeps, $1)"; then
+ _LT_TAGVAR(postdeps, $1)="${prev}${p}"
+ else
+ _LT_TAGVAR(postdeps, $1)="${_LT_TAGVAR(postdeps, $1)} ${prev}${p}"
+ fi
+ fi
+ prev=
+ ;;
+
+ *.lto.$objext) ;; # Ignore GCC LTO objects
+ *.$objext)
+ # This assumes that the test object file only shows up
+ # once in the compiler output.
+ if test "$p" = "conftest.$objext"; then
+ pre_test_object_deps_done=yes
+ continue
+ fi
+
+ if test "$pre_test_object_deps_done" = no; then
+ if test -z "$_LT_TAGVAR(predep_objects, $1)"; then
+ _LT_TAGVAR(predep_objects, $1)="$p"
+ else
+ _LT_TAGVAR(predep_objects, $1)="$_LT_TAGVAR(predep_objects, $1) $p"
+ fi
+ else
+ if test -z "$_LT_TAGVAR(postdep_objects, $1)"; then
+ _LT_TAGVAR(postdep_objects, $1)="$p"
+ else
+ _LT_TAGVAR(postdep_objects, $1)="$_LT_TAGVAR(postdep_objects, $1) $p"
+ fi
+ fi
+ ;;
+
+ *) ;; # Ignore the rest.
+
+ esac
+ done
+
+ # Clean up.
+ rm -f a.out a.exe
+else
+ echo "libtool.m4: error: problem compiling $1 test program"
+fi
+
+$RM -f confest.$objext
+CFLAGS=$_lt_libdeps_save_CFLAGS
+
+# PORTME: override above test on systems where it is broken
+m4_if([$1], [CXX],
+[case $host_os in
+interix[[3-9]]*)
+ # Interix 3.5 installs completely hosed .la files for C++, so rather than
+ # hack all around it, let's just trust "g++" to DTRT.
+ _LT_TAGVAR(predep_objects,$1)=
+ _LT_TAGVAR(postdep_objects,$1)=
+ _LT_TAGVAR(postdeps,$1)=
+ ;;
+
+linux*)
+ case `$CC -V 2>&1 | sed 5q` in
+ *Sun\ C*)
+ # Sun C++ 5.9
+
+ # The more standards-conforming stlport4 library is
+ # incompatible with the Cstd library. Avoid specifying
+ # it if it's in CXXFLAGS. Ignore libCrun as
+ # -library=stlport4 depends on it.
+ case " $CXX $CXXFLAGS " in
+ *" -library=stlport4 "*)
+ solaris_use_stlport4=yes
+ ;;
+ esac
+
+ if test "$solaris_use_stlport4" != yes; then
+ _LT_TAGVAR(postdeps,$1)='-library=Cstd -library=Crun'
+ fi
+ ;;
+ esac
+ ;;
+
+solaris*)
+ case $cc_basename in
+ CC* | sunCC*)
+ # The more standards-conforming stlport4 library is
+ # incompatible with the Cstd library. Avoid specifying
+ # it if it's in CXXFLAGS. Ignore libCrun as
+ # -library=stlport4 depends on it.
+ case " $CXX $CXXFLAGS " in
+ *" -library=stlport4 "*)
+ solaris_use_stlport4=yes
+ ;;
+ esac
+
+ # Adding this requires a known-good setup of shared libraries for
+ # Sun compiler versions before 5.6, else PIC objects from an old
+ # archive will be linked into the output, leading to subtle bugs.
+ if test "$solaris_use_stlport4" != yes; then
+ _LT_TAGVAR(postdeps,$1)='-library=Cstd -library=Crun'
+ fi
+ ;;
+ esac
+ ;;
+esac
+])
+
+case " $_LT_TAGVAR(postdeps, $1) " in
+*" -lc "*) _LT_TAGVAR(archive_cmds_need_lc, $1)=no ;;
+esac
+ _LT_TAGVAR(compiler_lib_search_dirs, $1)=
+if test -n "${_LT_TAGVAR(compiler_lib_search_path, $1)}"; then
+ _LT_TAGVAR(compiler_lib_search_dirs, $1)=`echo " ${_LT_TAGVAR(compiler_lib_search_path, $1)}" | ${SED} -e 's! -L! !g' -e 's!^ !!'`
+fi
+_LT_TAGDECL([], [compiler_lib_search_dirs], [1],
+ [The directories searched by this compiler when creating a shared library])
+_LT_TAGDECL([], [predep_objects], [1],
+ [Dependencies to place before and after the objects being linked to
+ create a shared library])
+_LT_TAGDECL([], [postdep_objects], [1])
+_LT_TAGDECL([], [predeps], [1])
+_LT_TAGDECL([], [postdeps], [1])
+_LT_TAGDECL([], [compiler_lib_search_path], [1],
+ [The library search path used internally by the compiler when linking
+ a shared library])
+])# _LT_SYS_HIDDEN_LIBDEPS
+
+
+# _LT_LANG_F77_CONFIG([TAG])
+# --------------------------
+# Ensure that the configuration variables for a Fortran 77 compiler are
+# suitably defined. These variables are subsequently used by _LT_CONFIG
+# to write the compiler configuration to `libtool'.
+m4_defun([_LT_LANG_F77_CONFIG],
+[AC_LANG_PUSH(Fortran 77)
+if test -z "$F77" || test "X$F77" = "Xno"; then
+ _lt_disable_F77=yes
+fi
+
+_LT_TAGVAR(archive_cmds_need_lc, $1)=no
+_LT_TAGVAR(allow_undefined_flag, $1)=
+_LT_TAGVAR(always_export_symbols, $1)=no
+_LT_TAGVAR(archive_expsym_cmds, $1)=
+_LT_TAGVAR(export_dynamic_flag_spec, $1)=
+_LT_TAGVAR(hardcode_direct, $1)=no
+_LT_TAGVAR(hardcode_direct_absolute, $1)=no
+_LT_TAGVAR(hardcode_libdir_flag_spec, $1)=
+_LT_TAGVAR(hardcode_libdir_separator, $1)=
+_LT_TAGVAR(hardcode_minus_L, $1)=no
+_LT_TAGVAR(hardcode_automatic, $1)=no
+_LT_TAGVAR(inherit_rpath, $1)=no
+_LT_TAGVAR(module_cmds, $1)=
+_LT_TAGVAR(module_expsym_cmds, $1)=
+_LT_TAGVAR(link_all_deplibs, $1)=unknown
+_LT_TAGVAR(old_archive_cmds, $1)=$old_archive_cmds
+_LT_TAGVAR(reload_flag, $1)=$reload_flag
+_LT_TAGVAR(reload_cmds, $1)=$reload_cmds
+_LT_TAGVAR(no_undefined_flag, $1)=
+_LT_TAGVAR(whole_archive_flag_spec, $1)=
+_LT_TAGVAR(enable_shared_with_static_runtimes, $1)=no
+
+# Source file extension for f77 test sources.
+ac_ext=f
+
+# Object file extension for compiled f77 test sources.
+objext=o
+_LT_TAGVAR(objext, $1)=$objext
+
+# No sense in running all these tests if we already determined that
+# the F77 compiler isn't working. Some variables (like enable_shared)
+# are currently assumed to apply to all compilers on this platform,
+# and will be corrupted by setting them based on a non-working compiler.
+if test "$_lt_disable_F77" != yes; then
+ # Code to be used in simple compile tests
+ lt_simple_compile_test_code="\
+ subroutine t
+ return
+ end
+"
+
+ # Code to be used in simple link tests
+ lt_simple_link_test_code="\
+ program t
+ end
+"
+
+ # ltmain only uses $CC for tagged configurations so make sure $CC is set.
+ _LT_TAG_COMPILER
+
+ # save warnings/boilerplate of simple test code
+ _LT_COMPILER_BOILERPLATE
+ _LT_LINKER_BOILERPLATE
+
+ # Allow CC to be a program name with arguments.
+ lt_save_CC="$CC"
+ lt_save_GCC=$GCC
+ lt_save_CFLAGS=$CFLAGS
+ CC=${F77-"f77"}
+ CFLAGS=$FFLAGS
+ compiler=$CC
+ _LT_TAGVAR(compiler, $1)=$CC
+ _LT_CC_BASENAME([$compiler])
+ GCC=$G77
+ if test -n "$compiler"; then
+ AC_MSG_CHECKING([if libtool supports shared libraries])
+ AC_MSG_RESULT([$can_build_shared])
+
+ AC_MSG_CHECKING([whether to build shared libraries])
+ test "$can_build_shared" = "no" && enable_shared=no
+
+ # On AIX, shared libraries and static libraries use the same namespace, and
+ # are all built from PIC.
+ case $host_os in
+ aix3*)
+ test "$enable_shared" = yes && enable_static=no
+ if test -n "$RANLIB"; then
+ archive_cmds="$archive_cmds~\$RANLIB \$lib"
+ postinstall_cmds='$RANLIB $lib'
+ fi
+ ;;
+ aix[[4-9]]*)
+ if test "$host_cpu" != ia64 && test "$aix_use_runtimelinking" = no ; then
+ test "$enable_shared" = yes && enable_static=no
+ fi
+ ;;
+ esac
+ AC_MSG_RESULT([$enable_shared])
+
+ AC_MSG_CHECKING([whether to build static libraries])
+ # Make sure either enable_shared or enable_static is yes.
+ test "$enable_shared" = yes || enable_static=yes
+ AC_MSG_RESULT([$enable_static])
+
+ _LT_TAGVAR(GCC, $1)="$G77"
+ _LT_TAGVAR(LD, $1)="$LD"
+
+ ## CAVEAT EMPTOR:
+ ## There is no encapsulation within the following macros, do not change
+ ## the running order or otherwise move them around unless you know exactly
+ ## what you are doing...
+ _LT_COMPILER_PIC($1)
+ _LT_COMPILER_C_O($1)
+ _LT_COMPILER_FILE_LOCKS($1)
+ _LT_LINKER_SHLIBS($1)
+ _LT_SYS_DYNAMIC_LINKER($1)
+ _LT_LINKER_HARDCODE_LIBPATH($1)
+
+ _LT_CONFIG($1)
+ fi # test -n "$compiler"
+
+ GCC=$lt_save_GCC
+ CC="$lt_save_CC"
+ CFLAGS="$lt_save_CFLAGS"
+fi # test "$_lt_disable_F77" != yes
+
+AC_LANG_POP
+])# _LT_LANG_F77_CONFIG
+
+
+# _LT_LANG_FC_CONFIG([TAG])
+# -------------------------
+# Ensure that the configuration variables for a Fortran compiler are
+# suitably defined. These variables are subsequently used by _LT_CONFIG
+# to write the compiler configuration to `libtool'.
+m4_defun([_LT_LANG_FC_CONFIG],
+[AC_LANG_PUSH(Fortran)
+
+if test -z "$FC" || test "X$FC" = "Xno"; then
+ _lt_disable_FC=yes
+fi
+
+_LT_TAGVAR(archive_cmds_need_lc, $1)=no
+_LT_TAGVAR(allow_undefined_flag, $1)=
+_LT_TAGVAR(always_export_symbols, $1)=no
+_LT_TAGVAR(archive_expsym_cmds, $1)=
+_LT_TAGVAR(export_dynamic_flag_spec, $1)=
+_LT_TAGVAR(hardcode_direct, $1)=no
+_LT_TAGVAR(hardcode_direct_absolute, $1)=no
+_LT_TAGVAR(hardcode_libdir_flag_spec, $1)=
+_LT_TAGVAR(hardcode_libdir_separator, $1)=
+_LT_TAGVAR(hardcode_minus_L, $1)=no
+_LT_TAGVAR(hardcode_automatic, $1)=no
+_LT_TAGVAR(inherit_rpath, $1)=no
+_LT_TAGVAR(module_cmds, $1)=
+_LT_TAGVAR(module_expsym_cmds, $1)=
+_LT_TAGVAR(link_all_deplibs, $1)=unknown
+_LT_TAGVAR(old_archive_cmds, $1)=$old_archive_cmds
+_LT_TAGVAR(reload_flag, $1)=$reload_flag
+_LT_TAGVAR(reload_cmds, $1)=$reload_cmds
+_LT_TAGVAR(no_undefined_flag, $1)=
+_LT_TAGVAR(whole_archive_flag_spec, $1)=
+_LT_TAGVAR(enable_shared_with_static_runtimes, $1)=no
+
+# Source file extension for fc test sources.
+ac_ext=${ac_fc_srcext-f}
+
+# Object file extension for compiled fc test sources.
+objext=o
+_LT_TAGVAR(objext, $1)=$objext
+
+# No sense in running all these tests if we already determined that
+# the FC compiler isn't working. Some variables (like enable_shared)
+# are currently assumed to apply to all compilers on this platform,
+# and will be corrupted by setting them based on a non-working compiler.
+if test "$_lt_disable_FC" != yes; then
+ # Code to be used in simple compile tests
+ lt_simple_compile_test_code="\
+ subroutine t
+ return
+ end
+"
+
+ # Code to be used in simple link tests
+ lt_simple_link_test_code="\
+ program t
+ end
+"
+
+ # ltmain only uses $CC for tagged configurations so make sure $CC is set.
+ _LT_TAG_COMPILER
+
+ # save warnings/boilerplate of simple test code
+ _LT_COMPILER_BOILERPLATE
+ _LT_LINKER_BOILERPLATE
+
+ # Allow CC to be a program name with arguments.
+ lt_save_CC="$CC"
+ lt_save_GCC=$GCC
+ lt_save_CFLAGS=$CFLAGS
+ CC=${FC-"f95"}
+ CFLAGS=$FCFLAGS
+ compiler=$CC
+ GCC=$ac_cv_fc_compiler_gnu
+
+ _LT_TAGVAR(compiler, $1)=$CC
+ _LT_CC_BASENAME([$compiler])
+
+ if test -n "$compiler"; then
+ AC_MSG_CHECKING([if libtool supports shared libraries])
+ AC_MSG_RESULT([$can_build_shared])
+
+ AC_MSG_CHECKING([whether to build shared libraries])
+ test "$can_build_shared" = "no" && enable_shared=no
+
+ # On AIX, shared libraries and static libraries use the same namespace, and
+ # are all built from PIC.
+ case $host_os in
+ aix3*)
+ test "$enable_shared" = yes && enable_static=no
+ if test -n "$RANLIB"; then
+ archive_cmds="$archive_cmds~\$RANLIB \$lib"
+ postinstall_cmds='$RANLIB $lib'
+ fi
+ ;;
+ aix[[4-9]]*)
+ if test "$host_cpu" != ia64 && test "$aix_use_runtimelinking" = no ; then
+ test "$enable_shared" = yes && enable_static=no
+ fi
+ ;;
+ esac
+ AC_MSG_RESULT([$enable_shared])
+
+ AC_MSG_CHECKING([whether to build static libraries])
+ # Make sure either enable_shared or enable_static is yes.
+ test "$enable_shared" = yes || enable_static=yes
+ AC_MSG_RESULT([$enable_static])
+
+ _LT_TAGVAR(GCC, $1)="$ac_cv_fc_compiler_gnu"
+ _LT_TAGVAR(LD, $1)="$LD"
+
+ ## CAVEAT EMPTOR:
+ ## There is no encapsulation within the following macros, do not change
+ ## the running order or otherwise move them around unless you know exactly
+ ## what you are doing...
+ _LT_SYS_HIDDEN_LIBDEPS($1)
+ _LT_COMPILER_PIC($1)
+ _LT_COMPILER_C_O($1)
+ _LT_COMPILER_FILE_LOCKS($1)
+ _LT_LINKER_SHLIBS($1)
+ _LT_SYS_DYNAMIC_LINKER($1)
+ _LT_LINKER_HARDCODE_LIBPATH($1)
+
+ _LT_CONFIG($1)
+ fi # test -n "$compiler"
+
+ GCC=$lt_save_GCC
+ CC=$lt_save_CC
+ CFLAGS=$lt_save_CFLAGS
+fi # test "$_lt_disable_FC" != yes
+
+AC_LANG_POP
+])# _LT_LANG_FC_CONFIG
+
+
+# _LT_LANG_GCJ_CONFIG([TAG])
+# --------------------------
+# Ensure that the configuration variables for the GNU Java Compiler compiler
+# are suitably defined. These variables are subsequently used by _LT_CONFIG
+# to write the compiler configuration to `libtool'.
+m4_defun([_LT_LANG_GCJ_CONFIG],
+[AC_REQUIRE([LT_PROG_GCJ])dnl
+AC_LANG_SAVE
+
+# Source file extension for Java test sources.
+ac_ext=java
+
+# Object file extension for compiled Java test sources.
+objext=o
+_LT_TAGVAR(objext, $1)=$objext
+
+# Code to be used in simple compile tests
+lt_simple_compile_test_code="class foo {}"
+
+# Code to be used in simple link tests
+lt_simple_link_test_code='public class conftest { public static void main(String[[]] argv) {}; }'
+
+# ltmain only uses $CC for tagged configurations so make sure $CC is set.
+_LT_TAG_COMPILER
+
+# save warnings/boilerplate of simple test code
+_LT_COMPILER_BOILERPLATE
+_LT_LINKER_BOILERPLATE
+
+# Allow CC to be a program name with arguments.
+lt_save_CC=$CC
+lt_save_CFLAGS=$CFLAGS
+lt_save_GCC=$GCC
+GCC=yes
+CC=${GCJ-"gcj"}
+CFLAGS=$GCJFLAGS
+compiler=$CC
+_LT_TAGVAR(compiler, $1)=$CC
+_LT_TAGVAR(LD, $1)="$LD"
+_LT_CC_BASENAME([$compiler])
+
+# GCJ did not exist at the time GCC didn't implicitly link libc in.
+_LT_TAGVAR(archive_cmds_need_lc, $1)=no
+
+_LT_TAGVAR(old_archive_cmds, $1)=$old_archive_cmds
+_LT_TAGVAR(reload_flag, $1)=$reload_flag
+_LT_TAGVAR(reload_cmds, $1)=$reload_cmds
+
+## CAVEAT EMPTOR:
+## There is no encapsulation within the following macros, do not change
+## the running order or otherwise move them around unless you know exactly
+## what you are doing...
+if test -n "$compiler"; then
+ _LT_COMPILER_NO_RTTI($1)
+ _LT_COMPILER_PIC($1)
+ _LT_COMPILER_C_O($1)
+ _LT_COMPILER_FILE_LOCKS($1)
+ _LT_LINKER_SHLIBS($1)
+ _LT_LINKER_HARDCODE_LIBPATH($1)
+
+ _LT_CONFIG($1)
+fi
+
+AC_LANG_RESTORE
+
+GCC=$lt_save_GCC
+CC=$lt_save_CC
+CFLAGS=$lt_save_CFLAGS
+])# _LT_LANG_GCJ_CONFIG
+
+
+# _LT_LANG_GO_CONFIG([TAG])
+# --------------------------
+# Ensure that the configuration variables for the GNU Go compiler
+# are suitably defined. These variables are subsequently used by _LT_CONFIG
+# to write the compiler configuration to `libtool'.
+m4_defun([_LT_LANG_GO_CONFIG],
+[AC_REQUIRE([LT_PROG_GO])dnl
+AC_LANG_SAVE
+
+# Source file extension for Go test sources.
+ac_ext=go
+
+# Object file extension for compiled Go test sources.
+objext=o
+_LT_TAGVAR(objext, $1)=$objext
+
+# Code to be used in simple compile tests
+lt_simple_compile_test_code="package main; func main() { }"
+
+# Code to be used in simple link tests
+lt_simple_link_test_code='package main; func main() { }'
+
+# ltmain only uses $CC for tagged configurations so make sure $CC is set.
+_LT_TAG_COMPILER
+
+# save warnings/boilerplate of simple test code
+_LT_COMPILER_BOILERPLATE
+_LT_LINKER_BOILERPLATE
+
+# Allow CC to be a program name with arguments.
+lt_save_CC=$CC
+lt_save_CFLAGS=$CFLAGS
+lt_save_GCC=$GCC
+GCC=yes
+CC=${GOC-"gccgo"}
+CFLAGS=$GOFLAGS
+compiler=$CC
+_LT_TAGVAR(compiler, $1)=$CC
+_LT_TAGVAR(LD, $1)="$LD"
+_LT_CC_BASENAME([$compiler])
+
+# Go did not exist at the time GCC didn't implicitly link libc in.
+_LT_TAGVAR(archive_cmds_need_lc, $1)=no
+
+_LT_TAGVAR(old_archive_cmds, $1)=$old_archive_cmds
+_LT_TAGVAR(reload_flag, $1)=$reload_flag
+_LT_TAGVAR(reload_cmds, $1)=$reload_cmds
+
+## CAVEAT EMPTOR:
+## There is no encapsulation within the following macros, do not change
+## the running order or otherwise move them around unless you know exactly
+## what you are doing...
+if test -n "$compiler"; then
+ _LT_COMPILER_NO_RTTI($1)
+ _LT_COMPILER_PIC($1)
+ _LT_COMPILER_C_O($1)
+ _LT_COMPILER_FILE_LOCKS($1)
+ _LT_LINKER_SHLIBS($1)
+ _LT_LINKER_HARDCODE_LIBPATH($1)
+
+ _LT_CONFIG($1)
+fi
+
+AC_LANG_RESTORE
+
+GCC=$lt_save_GCC
+CC=$lt_save_CC
+CFLAGS=$lt_save_CFLAGS
+])# _LT_LANG_GO_CONFIG
+
+
+# _LT_LANG_RC_CONFIG([TAG])
+# -------------------------
+# Ensure that the configuration variables for the Windows resource compiler
+# are suitably defined. These variables are subsequently used by _LT_CONFIG
+# to write the compiler configuration to `libtool'.
+m4_defun([_LT_LANG_RC_CONFIG],
+[AC_REQUIRE([LT_PROG_RC])dnl
+AC_LANG_SAVE
+
+# Source file extension for RC test sources.
+ac_ext=rc
+
+# Object file extension for compiled RC test sources.
+objext=o
+_LT_TAGVAR(objext, $1)=$objext
+
+# Code to be used in simple compile tests
+lt_simple_compile_test_code='sample MENU { MENUITEM "&Soup", 100, CHECKED }'
+
+# Code to be used in simple link tests
+lt_simple_link_test_code="$lt_simple_compile_test_code"
+
+# ltmain only uses $CC for tagged configurations so make sure $CC is set.
+_LT_TAG_COMPILER
+
+# save warnings/boilerplate of simple test code
+_LT_COMPILER_BOILERPLATE
+_LT_LINKER_BOILERPLATE
+
+# Allow CC to be a program name with arguments.
+lt_save_CC="$CC"
+lt_save_CFLAGS=$CFLAGS
+lt_save_GCC=$GCC
+GCC=
+CC=${RC-"windres"}
+CFLAGS=
+compiler=$CC
+_LT_TAGVAR(compiler, $1)=$CC
+_LT_CC_BASENAME([$compiler])
+_LT_TAGVAR(lt_cv_prog_compiler_c_o, $1)=yes
+
+if test -n "$compiler"; then
+ :
+ _LT_CONFIG($1)
+fi
+
+GCC=$lt_save_GCC
+AC_LANG_RESTORE
+CC=$lt_save_CC
+CFLAGS=$lt_save_CFLAGS
+])# _LT_LANG_RC_CONFIG
+
+
+# LT_PROG_GCJ
+# -----------
+AC_DEFUN([LT_PROG_GCJ],
+[m4_ifdef([AC_PROG_GCJ], [AC_PROG_GCJ],
+ [m4_ifdef([A][M_PROG_GCJ], [A][M_PROG_GCJ],
+ [AC_CHECK_TOOL(GCJ, gcj,)
+ test "x${GCJFLAGS+set}" = xset || GCJFLAGS="-g -O2"
+ AC_SUBST(GCJFLAGS)])])[]dnl
+])
+
+# Old name:
+AU_ALIAS([LT_AC_PROG_GCJ], [LT_PROG_GCJ])
+dnl aclocal-1.4 backwards compatibility:
+dnl AC_DEFUN([LT_AC_PROG_GCJ], [])
+
+
+# LT_PROG_GO
+# ----------
+AC_DEFUN([LT_PROG_GO],
+[AC_CHECK_TOOL(GOC, gccgo,)
+])
+
+
+# LT_PROG_RC
+# ----------
+AC_DEFUN([LT_PROG_RC],
+[AC_CHECK_TOOL(RC, windres,)
+])
+
+# Old name:
+AU_ALIAS([LT_AC_PROG_RC], [LT_PROG_RC])
+dnl aclocal-1.4 backwards compatibility:
+dnl AC_DEFUN([LT_AC_PROG_RC], [])
+
+
+# _LT_DECL_EGREP
+# --------------
+# If we don't have a new enough Autoconf to choose the best grep
+# available, choose the one first in the user's PATH.
+m4_defun([_LT_DECL_EGREP],
+[AC_REQUIRE([AC_PROG_EGREP])dnl
+AC_REQUIRE([AC_PROG_FGREP])dnl
+test -z "$GREP" && GREP=grep
+_LT_DECL([], [GREP], [1], [A grep program that handles long lines])
+_LT_DECL([], [EGREP], [1], [An ERE matcher])
+_LT_DECL([], [FGREP], [1], [A literal string matcher])
+dnl Non-bleeding-edge autoconf doesn't subst GREP, so do it here too
+AC_SUBST([GREP])
+])
+
+
+# _LT_DECL_OBJDUMP
+# --------------
+# If we don't have a new enough Autoconf to choose the best objdump
+# available, choose the one first in the user's PATH.
+m4_defun([_LT_DECL_OBJDUMP],
+[AC_CHECK_TOOL(OBJDUMP, objdump, false)
+test -z "$OBJDUMP" && OBJDUMP=objdump
+_LT_DECL([], [OBJDUMP], [1], [An object symbol dumper])
+AC_SUBST([OBJDUMP])
+])
+
+# _LT_DECL_DLLTOOL
+# ----------------
+# Ensure DLLTOOL variable is set.
+m4_defun([_LT_DECL_DLLTOOL],
+[AC_CHECK_TOOL(DLLTOOL, dlltool, false)
+test -z "$DLLTOOL" && DLLTOOL=dlltool
+_LT_DECL([], [DLLTOOL], [1], [DLL creation program])
+AC_SUBST([DLLTOOL])
+])
+
+# _LT_DECL_SED
+# ------------
+# Check for a fully-functional sed program, that truncates
+# as few characters as possible. Prefer GNU sed if found.
+m4_defun([_LT_DECL_SED],
+[AC_PROG_SED
+test -z "$SED" && SED=sed
+Xsed="$SED -e 1s/^X//"
+_LT_DECL([], [SED], [1], [A sed program that does not truncate output])
+_LT_DECL([], [Xsed], ["\$SED -e 1s/^X//"],
+ [Sed that helps us avoid accidentally triggering echo(1) options like -n])
+])# _LT_DECL_SED
+
+m4_ifndef([AC_PROG_SED], [
+############################################################
+# NOTE: This macro has been submitted for inclusion into #
+# GNU Autoconf as AC_PROG_SED. When it is available in #
+# a released version of Autoconf we should remove this #
+# macro and use it instead. #
+############################################################
+
+m4_defun([AC_PROG_SED],
+[AC_MSG_CHECKING([for a sed that does not truncate output])
+AC_CACHE_VAL(lt_cv_path_SED,
+[# Loop through the user's path and test for sed and gsed.
+# Then use that list of sed's as ones to test for truncation.
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ for lt_ac_prog in sed gsed; do
+ for ac_exec_ext in '' $ac_executable_extensions; do
+ if $as_executable_p "$as_dir/$lt_ac_prog$ac_exec_ext"; then
+ lt_ac_sed_list="$lt_ac_sed_list $as_dir/$lt_ac_prog$ac_exec_ext"
+ fi
+ done
+ done
+done
+IFS=$as_save_IFS
+lt_ac_max=0
+lt_ac_count=0
+# Add /usr/xpg4/bin/sed as it is typically found on Solaris
+# along with /bin/sed that truncates output.
+for lt_ac_sed in $lt_ac_sed_list /usr/xpg4/bin/sed; do
+ test ! -f $lt_ac_sed && continue
+ cat /dev/null > conftest.in
+ lt_ac_count=0
+ echo $ECHO_N "0123456789$ECHO_C" >conftest.in
+ # Check for GNU sed and select it if it is found.
+ if "$lt_ac_sed" --version 2>&1 < /dev/null | grep 'GNU' > /dev/null; then
+ lt_cv_path_SED=$lt_ac_sed
+ break
+ fi
+ while true; do
+ cat conftest.in conftest.in >conftest.tmp
+ mv conftest.tmp conftest.in
+ cp conftest.in conftest.nl
+ echo >>conftest.nl
+ $lt_ac_sed -e 's/a$//' < conftest.nl >conftest.out || break
+ cmp -s conftest.out conftest.nl || break
+ # 10000 chars as input seems more than enough
+ test $lt_ac_count -gt 10 && break
+ lt_ac_count=`expr $lt_ac_count + 1`
+ if test $lt_ac_count -gt $lt_ac_max; then
+ lt_ac_max=$lt_ac_count
+ lt_cv_path_SED=$lt_ac_sed
+ fi
+ done
+done
+])
+SED=$lt_cv_path_SED
+AC_SUBST([SED])
+AC_MSG_RESULT([$SED])
+])#AC_PROG_SED
+])#m4_ifndef
+
+# Old name:
+AU_ALIAS([LT_AC_PROG_SED], [AC_PROG_SED])
+dnl aclocal-1.4 backwards compatibility:
+dnl AC_DEFUN([LT_AC_PROG_SED], [])
+
+
+# _LT_CHECK_SHELL_FEATURES
+# ------------------------
+# Find out whether the shell is Bourne or XSI compatible,
+# or has some other useful features.
+m4_defun([_LT_CHECK_SHELL_FEATURES],
+[AC_MSG_CHECKING([whether the shell understands some XSI constructs])
+# Try some XSI features
+xsi_shell=no
+( _lt_dummy="a/b/c"
+ test "${_lt_dummy##*/},${_lt_dummy%/*},${_lt_dummy#??}"${_lt_dummy%"$_lt_dummy"}, \
+ = c,a/b,b/c, \
+ && eval 'test $(( 1 + 1 )) -eq 2 \
+ && test "${#_lt_dummy}" -eq 5' ) >/dev/null 2>&1 \
+ && xsi_shell=yes
+AC_MSG_RESULT([$xsi_shell])
+_LT_CONFIG_LIBTOOL_INIT([xsi_shell='$xsi_shell'])
+
+AC_MSG_CHECKING([whether the shell understands "+="])
+lt_shell_append=no
+( foo=bar; set foo baz; eval "$[1]+=\$[2]" && test "$foo" = barbaz ) \
+ >/dev/null 2>&1 \
+ && lt_shell_append=yes
+AC_MSG_RESULT([$lt_shell_append])
+_LT_CONFIG_LIBTOOL_INIT([lt_shell_append='$lt_shell_append'])
+
+if ( (MAIL=60; unset MAIL) || exit) >/dev/null 2>&1; then
+ lt_unset=unset
+else
+ lt_unset=false
+fi
+_LT_DECL([], [lt_unset], [0], [whether the shell understands "unset"])dnl
+
+# test EBCDIC or ASCII
+case `echo X|tr X '\101'` in
+ A) # ASCII based system
+ # \n is not interpreted correctly by Solaris 8 /usr/ucb/tr
+ lt_SP2NL='tr \040 \012'
+ lt_NL2SP='tr \015\012 \040\040'
+ ;;
+ *) # EBCDIC based system
+ lt_SP2NL='tr \100 \n'
+ lt_NL2SP='tr \r\n \100\100'
+ ;;
+esac
+_LT_DECL([SP2NL], [lt_SP2NL], [1], [turn spaces into newlines])dnl
+_LT_DECL([NL2SP], [lt_NL2SP], [1], [turn newlines into spaces])dnl
+])# _LT_CHECK_SHELL_FEATURES
+
+
+# _LT_PROG_FUNCTION_REPLACE (FUNCNAME, REPLACEMENT-BODY)
+# ------------------------------------------------------
+# In `$cfgfile', look for function FUNCNAME delimited by `^FUNCNAME ()$' and
+# '^} FUNCNAME ', and replace its body with REPLACEMENT-BODY.
+m4_defun([_LT_PROG_FUNCTION_REPLACE],
+[dnl {
+sed -e '/^$1 ()$/,/^} # $1 /c\
+$1 ()\
+{\
+m4_bpatsubsts([$2], [$], [\\], [^\([ ]\)], [\\\1])
+} # Extended-shell $1 implementation' "$cfgfile" > $cfgfile.tmp \
+ && mv -f "$cfgfile.tmp" "$cfgfile" \
+ || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp")
+test 0 -eq $? || _lt_function_replace_fail=:
+])
+
+
+# _LT_PROG_REPLACE_SHELLFNS
+# -------------------------
+# Replace existing portable implementations of several shell functions with
+# equivalent extended shell implementations where those features are available..
+m4_defun([_LT_PROG_REPLACE_SHELLFNS],
+[if test x"$xsi_shell" = xyes; then
+ _LT_PROG_FUNCTION_REPLACE([func_dirname], [dnl
+ case ${1} in
+ */*) func_dirname_result="${1%/*}${2}" ;;
+ * ) func_dirname_result="${3}" ;;
+ esac])
+
+ _LT_PROG_FUNCTION_REPLACE([func_basename], [dnl
+ func_basename_result="${1##*/}"])
+
+ _LT_PROG_FUNCTION_REPLACE([func_dirname_and_basename], [dnl
+ case ${1} in
+ */*) func_dirname_result="${1%/*}${2}" ;;
+ * ) func_dirname_result="${3}" ;;
+ esac
+ func_basename_result="${1##*/}"])
+
+ _LT_PROG_FUNCTION_REPLACE([func_stripname], [dnl
+ # pdksh 5.2.14 does not do ${X%$Y} correctly if both X and Y are
+ # positional parameters, so assign one to ordinary parameter first.
+ func_stripname_result=${3}
+ func_stripname_result=${func_stripname_result#"${1}"}
+ func_stripname_result=${func_stripname_result%"${2}"}])
+
+ _LT_PROG_FUNCTION_REPLACE([func_split_long_opt], [dnl
+ func_split_long_opt_name=${1%%=*}
+ func_split_long_opt_arg=${1#*=}])
+
+ _LT_PROG_FUNCTION_REPLACE([func_split_short_opt], [dnl
+ func_split_short_opt_arg=${1#??}
+ func_split_short_opt_name=${1%"$func_split_short_opt_arg"}])
+
+ _LT_PROG_FUNCTION_REPLACE([func_lo2o], [dnl
+ case ${1} in
+ *.lo) func_lo2o_result=${1%.lo}.${objext} ;;
+ *) func_lo2o_result=${1} ;;
+ esac])
+
+ _LT_PROG_FUNCTION_REPLACE([func_xform], [ func_xform_result=${1%.*}.lo])
+
+ _LT_PROG_FUNCTION_REPLACE([func_arith], [ func_arith_result=$(( $[*] ))])
+
+ _LT_PROG_FUNCTION_REPLACE([func_len], [ func_len_result=${#1}])
+fi
+
+if test x"$lt_shell_append" = xyes; then
+ _LT_PROG_FUNCTION_REPLACE([func_append], [ eval "${1}+=\\${2}"])
+
+ _LT_PROG_FUNCTION_REPLACE([func_append_quoted], [dnl
+ func_quote_for_eval "${2}"
+dnl m4 expansion turns \\\\ into \\, and then the shell eval turns that into \
+ eval "${1}+=\\\\ \\$func_quote_for_eval_result"])
+
+ # Save a `func_append' function call where possible by direct use of '+='
+ sed -e 's%func_append \([[a-zA-Z_]]\{1,\}\) "%\1+="%g' $cfgfile > $cfgfile.tmp \
+ && mv -f "$cfgfile.tmp" "$cfgfile" \
+ || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp")
+ test 0 -eq $? || _lt_function_replace_fail=:
+else
+ # Save a `func_append' function call even when '+=' is not available
+ sed -e 's%func_append \([[a-zA-Z_]]\{1,\}\) "%\1="$\1%g' $cfgfile > $cfgfile.tmp \
+ && mv -f "$cfgfile.tmp" "$cfgfile" \
+ || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp")
+ test 0 -eq $? || _lt_function_replace_fail=:
+fi
+
+if test x"$_lt_function_replace_fail" = x":"; then
+ AC_MSG_WARN([Unable to substitute extended shell functions in $ofile])
+fi
+])
+
+# _LT_PATH_CONVERSION_FUNCTIONS
+# -----------------------------
+# Determine which file name conversion functions should be used by
+# func_to_host_file (and, implicitly, by func_to_host_path). These are needed
+# for certain cross-compile configurations and native mingw.
+m4_defun([_LT_PATH_CONVERSION_FUNCTIONS],
+[AC_REQUIRE([AC_CANONICAL_HOST])dnl
+AC_REQUIRE([AC_CANONICAL_BUILD])dnl
+AC_MSG_CHECKING([how to convert $build file names to $host format])
+AC_CACHE_VAL(lt_cv_to_host_file_cmd,
+[case $host in
+ *-*-mingw* )
+ case $build in
+ *-*-mingw* ) # actually msys
+ lt_cv_to_host_file_cmd=func_convert_file_msys_to_w32
+ ;;
+ *-*-cygwin* )
+ lt_cv_to_host_file_cmd=func_convert_file_cygwin_to_w32
+ ;;
+ * ) # otherwise, assume *nix
+ lt_cv_to_host_file_cmd=func_convert_file_nix_to_w32
+ ;;
+ esac
+ ;;
+ *-*-cygwin* )
+ case $build in
+ *-*-mingw* ) # actually msys
+ lt_cv_to_host_file_cmd=func_convert_file_msys_to_cygwin
+ ;;
+ *-*-cygwin* )
+ lt_cv_to_host_file_cmd=func_convert_file_noop
+ ;;
+ * ) # otherwise, assume *nix
+ lt_cv_to_host_file_cmd=func_convert_file_nix_to_cygwin
+ ;;
+ esac
+ ;;
+ * ) # unhandled hosts (and "normal" native builds)
+ lt_cv_to_host_file_cmd=func_convert_file_noop
+ ;;
+esac
+])
+to_host_file_cmd=$lt_cv_to_host_file_cmd
+AC_MSG_RESULT([$lt_cv_to_host_file_cmd])
+_LT_DECL([to_host_file_cmd], [lt_cv_to_host_file_cmd],
+ [0], [convert $build file names to $host format])dnl
+
+AC_MSG_CHECKING([how to convert $build file names to toolchain format])
+AC_CACHE_VAL(lt_cv_to_tool_file_cmd,
+[#assume ordinary cross tools, or native build.
+lt_cv_to_tool_file_cmd=func_convert_file_noop
+case $host in
+ *-*-mingw* )
+ case $build in
+ *-*-mingw* ) # actually msys
+ lt_cv_to_tool_file_cmd=func_convert_file_msys_to_w32
+ ;;
+ esac
+ ;;
+esac
+])
+to_tool_file_cmd=$lt_cv_to_tool_file_cmd
+AC_MSG_RESULT([$lt_cv_to_tool_file_cmd])
+_LT_DECL([to_tool_file_cmd], [lt_cv_to_tool_file_cmd],
+ [0], [convert $build files to toolchain format])dnl
+])# _LT_PATH_CONVERSION_FUNCTIONS
diff --git a/jni/ruby/ext/fiddle/libffi-3.2.1/m4/ltoptions.m4 b/jni/ruby/ext/fiddle/libffi-3.2.1/m4/ltoptions.m4
new file mode 100644
index 0000000..5d9acd8
--- /dev/null
+++ b/jni/ruby/ext/fiddle/libffi-3.2.1/m4/ltoptions.m4
@@ -0,0 +1,384 @@
+# Helper functions for option handling. -*- Autoconf -*-
+#
+# Copyright (C) 2004, 2005, 2007, 2008, 2009 Free Software Foundation,
+# Inc.
+# Written by Gary V. Vaughan, 2004
+#
+# This file is free software; the Free Software Foundation gives
+# unlimited permission to copy and/or distribute it, with or without
+# modifications, as long as this notice is preserved.
+
+# serial 7 ltoptions.m4
+
+# This is to help aclocal find these macros, as it can't see m4_define.
+AC_DEFUN([LTOPTIONS_VERSION], [m4_if([1])])
+
+
+# _LT_MANGLE_OPTION(MACRO-NAME, OPTION-NAME)
+# ------------------------------------------
+m4_define([_LT_MANGLE_OPTION],
+[[_LT_OPTION_]m4_bpatsubst($1__$2, [[^a-zA-Z0-9_]], [_])])
+
+
+# _LT_SET_OPTION(MACRO-NAME, OPTION-NAME)
+# ---------------------------------------
+# Set option OPTION-NAME for macro MACRO-NAME, and if there is a
+# matching handler defined, dispatch to it. Other OPTION-NAMEs are
+# saved as a flag.
+m4_define([_LT_SET_OPTION],
+[m4_define(_LT_MANGLE_OPTION([$1], [$2]))dnl
+m4_ifdef(_LT_MANGLE_DEFUN([$1], [$2]),
+ _LT_MANGLE_DEFUN([$1], [$2]),
+ [m4_warning([Unknown $1 option `$2'])])[]dnl
+])
+
+
+# _LT_IF_OPTION(MACRO-NAME, OPTION-NAME, IF-SET, [IF-NOT-SET])
+# ------------------------------------------------------------
+# Execute IF-SET if OPTION is set, IF-NOT-SET otherwise.
+m4_define([_LT_IF_OPTION],
+[m4_ifdef(_LT_MANGLE_OPTION([$1], [$2]), [$3], [$4])])
+
+
+# _LT_UNLESS_OPTIONS(MACRO-NAME, OPTION-LIST, IF-NOT-SET)
+# -------------------------------------------------------
+# Execute IF-NOT-SET unless all options in OPTION-LIST for MACRO-NAME
+# are set.
+m4_define([_LT_UNLESS_OPTIONS],
+[m4_foreach([_LT_Option], m4_split(m4_normalize([$2])),
+ [m4_ifdef(_LT_MANGLE_OPTION([$1], _LT_Option),
+ [m4_define([$0_found])])])[]dnl
+m4_ifdef([$0_found], [m4_undefine([$0_found])], [$3
+])[]dnl
+])
+
+
+# _LT_SET_OPTIONS(MACRO-NAME, OPTION-LIST)
+# ----------------------------------------
+# OPTION-LIST is a space-separated list of Libtool options associated
+# with MACRO-NAME. If any OPTION has a matching handler declared with
+# LT_OPTION_DEFINE, dispatch to that macro; otherwise complain about
+# the unknown option and exit.
+m4_defun([_LT_SET_OPTIONS],
+[# Set options
+m4_foreach([_LT_Option], m4_split(m4_normalize([$2])),
+ [_LT_SET_OPTION([$1], _LT_Option)])
+
+m4_if([$1],[LT_INIT],[
+ dnl
+ dnl Simply set some default values (i.e off) if boolean options were not
+ dnl specified:
+ _LT_UNLESS_OPTIONS([LT_INIT], [dlopen], [enable_dlopen=no
+ ])
+ _LT_UNLESS_OPTIONS([LT_INIT], [win32-dll], [enable_win32_dll=no
+ ])
+ dnl
+ dnl If no reference was made to various pairs of opposing options, then
+ dnl we run the default mode handler for the pair. For example, if neither
+ dnl `shared' nor `disable-shared' was passed, we enable building of shared
+ dnl archives by default:
+ _LT_UNLESS_OPTIONS([LT_INIT], [shared disable-shared], [_LT_ENABLE_SHARED])
+ _LT_UNLESS_OPTIONS([LT_INIT], [static disable-static], [_LT_ENABLE_STATIC])
+ _LT_UNLESS_OPTIONS([LT_INIT], [pic-only no-pic], [_LT_WITH_PIC])
+ _LT_UNLESS_OPTIONS([LT_INIT], [fast-install disable-fast-install],
+ [_LT_ENABLE_FAST_INSTALL])
+ ])
+])# _LT_SET_OPTIONS
+
+
+## --------------------------------- ##
+## Macros to handle LT_INIT options. ##
+## --------------------------------- ##
+
+# _LT_MANGLE_DEFUN(MACRO-NAME, OPTION-NAME)
+# -----------------------------------------
+m4_define([_LT_MANGLE_DEFUN],
+[[_LT_OPTION_DEFUN_]m4_bpatsubst(m4_toupper([$1__$2]), [[^A-Z0-9_]], [_])])
+
+
+# LT_OPTION_DEFINE(MACRO-NAME, OPTION-NAME, CODE)
+# -----------------------------------------------
+m4_define([LT_OPTION_DEFINE],
+[m4_define(_LT_MANGLE_DEFUN([$1], [$2]), [$3])[]dnl
+])# LT_OPTION_DEFINE
+
+
+# dlopen
+# ------
+LT_OPTION_DEFINE([LT_INIT], [dlopen], [enable_dlopen=yes
+])
+
+AU_DEFUN([AC_LIBTOOL_DLOPEN],
+[_LT_SET_OPTION([LT_INIT], [dlopen])
+AC_DIAGNOSE([obsolete],
+[$0: Remove this warning and the call to _LT_SET_OPTION when you
+put the `dlopen' option into LT_INIT's first parameter.])
+])
+
+dnl aclocal-1.4 backwards compatibility:
+dnl AC_DEFUN([AC_LIBTOOL_DLOPEN], [])
+
+
+# win32-dll
+# ---------
+# Declare package support for building win32 dll's.
+LT_OPTION_DEFINE([LT_INIT], [win32-dll],
+[enable_win32_dll=yes
+
+case $host in
+*-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-cegcc*)
+ AC_CHECK_TOOL(AS, as, false)
+ AC_CHECK_TOOL(DLLTOOL, dlltool, false)
+ AC_CHECK_TOOL(OBJDUMP, objdump, false)
+ ;;
+esac
+
+test -z "$AS" && AS=as
+_LT_DECL([], [AS], [1], [Assembler program])dnl
+
+test -z "$DLLTOOL" && DLLTOOL=dlltool
+_LT_DECL([], [DLLTOOL], [1], [DLL creation program])dnl
+
+test -z "$OBJDUMP" && OBJDUMP=objdump
+_LT_DECL([], [OBJDUMP], [1], [Object dumper program])dnl
+])# win32-dll
+
+AU_DEFUN([AC_LIBTOOL_WIN32_DLL],
+[AC_REQUIRE([AC_CANONICAL_HOST])dnl
+_LT_SET_OPTION([LT_INIT], [win32-dll])
+AC_DIAGNOSE([obsolete],
+[$0: Remove this warning and the call to _LT_SET_OPTION when you
+put the `win32-dll' option into LT_INIT's first parameter.])
+])
+
+dnl aclocal-1.4 backwards compatibility:
+dnl AC_DEFUN([AC_LIBTOOL_WIN32_DLL], [])
+
+
+# _LT_ENABLE_SHARED([DEFAULT])
+# ----------------------------
+# implement the --enable-shared flag, and supports the `shared' and
+# `disable-shared' LT_INIT options.
+# DEFAULT is either `yes' or `no'. If omitted, it defaults to `yes'.
+m4_define([_LT_ENABLE_SHARED],
+[m4_define([_LT_ENABLE_SHARED_DEFAULT], [m4_if($1, no, no, yes)])dnl
+AC_ARG_ENABLE([shared],
+ [AS_HELP_STRING([--enable-shared@<:@=PKGS@:>@],
+ [build shared libraries @<:@default=]_LT_ENABLE_SHARED_DEFAULT[@:>@])],
+ [p=${PACKAGE-default}
+ case $enableval in
+ yes) enable_shared=yes ;;
+ no) enable_shared=no ;;
+ *)
+ enable_shared=no
+ # Look at the argument we got. We use all the common list separators.
+ lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR,"
+ for pkg in $enableval; do
+ IFS="$lt_save_ifs"
+ if test "X$pkg" = "X$p"; then
+ enable_shared=yes
+ fi
+ done
+ IFS="$lt_save_ifs"
+ ;;
+ esac],
+ [enable_shared=]_LT_ENABLE_SHARED_DEFAULT)
+
+ _LT_DECL([build_libtool_libs], [enable_shared], [0],
+ [Whether or not to build shared libraries])
+])# _LT_ENABLE_SHARED
+
+LT_OPTION_DEFINE([LT_INIT], [shared], [_LT_ENABLE_SHARED([yes])])
+LT_OPTION_DEFINE([LT_INIT], [disable-shared], [_LT_ENABLE_SHARED([no])])
+
+# Old names:
+AC_DEFUN([AC_ENABLE_SHARED],
+[_LT_SET_OPTION([LT_INIT], m4_if([$1], [no], [disable-])[shared])
+])
+
+AC_DEFUN([AC_DISABLE_SHARED],
+[_LT_SET_OPTION([LT_INIT], [disable-shared])
+])
+
+AU_DEFUN([AM_ENABLE_SHARED], [AC_ENABLE_SHARED($@)])
+AU_DEFUN([AM_DISABLE_SHARED], [AC_DISABLE_SHARED($@)])
+
+dnl aclocal-1.4 backwards compatibility:
+dnl AC_DEFUN([AM_ENABLE_SHARED], [])
+dnl AC_DEFUN([AM_DISABLE_SHARED], [])
+
+
+
+# _LT_ENABLE_STATIC([DEFAULT])
+# ----------------------------
+# implement the --enable-static flag, and support the `static' and
+# `disable-static' LT_INIT options.
+# DEFAULT is either `yes' or `no'. If omitted, it defaults to `yes'.
+m4_define([_LT_ENABLE_STATIC],
+[m4_define([_LT_ENABLE_STATIC_DEFAULT], [m4_if($1, no, no, yes)])dnl
+AC_ARG_ENABLE([static],
+ [AS_HELP_STRING([--enable-static@<:@=PKGS@:>@],
+ [build static libraries @<:@default=]_LT_ENABLE_STATIC_DEFAULT[@:>@])],
+ [p=${PACKAGE-default}
+ case $enableval in
+ yes) enable_static=yes ;;
+ no) enable_static=no ;;
+ *)
+ enable_static=no
+ # Look at the argument we got. We use all the common list separators.
+ lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR,"
+ for pkg in $enableval; do
+ IFS="$lt_save_ifs"
+ if test "X$pkg" = "X$p"; then
+ enable_static=yes
+ fi
+ done
+ IFS="$lt_save_ifs"
+ ;;
+ esac],
+ [enable_static=]_LT_ENABLE_STATIC_DEFAULT)
+
+ _LT_DECL([build_old_libs], [enable_static], [0],
+ [Whether or not to build static libraries])
+])# _LT_ENABLE_STATIC
+
+LT_OPTION_DEFINE([LT_INIT], [static], [_LT_ENABLE_STATIC([yes])])
+LT_OPTION_DEFINE([LT_INIT], [disable-static], [_LT_ENABLE_STATIC([no])])
+
+# Old names:
+AC_DEFUN([AC_ENABLE_STATIC],
+[_LT_SET_OPTION([LT_INIT], m4_if([$1], [no], [disable-])[static])
+])
+
+AC_DEFUN([AC_DISABLE_STATIC],
+[_LT_SET_OPTION([LT_INIT], [disable-static])
+])
+
+AU_DEFUN([AM_ENABLE_STATIC], [AC_ENABLE_STATIC($@)])
+AU_DEFUN([AM_DISABLE_STATIC], [AC_DISABLE_STATIC($@)])
+
+dnl aclocal-1.4 backwards compatibility:
+dnl AC_DEFUN([AM_ENABLE_STATIC], [])
+dnl AC_DEFUN([AM_DISABLE_STATIC], [])
+
+
+
+# _LT_ENABLE_FAST_INSTALL([DEFAULT])
+# ----------------------------------
+# implement the --enable-fast-install flag, and support the `fast-install'
+# and `disable-fast-install' LT_INIT options.
+# DEFAULT is either `yes' or `no'. If omitted, it defaults to `yes'.
+m4_define([_LT_ENABLE_FAST_INSTALL],
+[m4_define([_LT_ENABLE_FAST_INSTALL_DEFAULT], [m4_if($1, no, no, yes)])dnl
+AC_ARG_ENABLE([fast-install],
+ [AS_HELP_STRING([--enable-fast-install@<:@=PKGS@:>@],
+ [optimize for fast installation @<:@default=]_LT_ENABLE_FAST_INSTALL_DEFAULT[@:>@])],
+ [p=${PACKAGE-default}
+ case $enableval in
+ yes) enable_fast_install=yes ;;
+ no) enable_fast_install=no ;;
+ *)
+ enable_fast_install=no
+ # Look at the argument we got. We use all the common list separators.
+ lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR,"
+ for pkg in $enableval; do
+ IFS="$lt_save_ifs"
+ if test "X$pkg" = "X$p"; then
+ enable_fast_install=yes
+ fi
+ done
+ IFS="$lt_save_ifs"
+ ;;
+ esac],
+ [enable_fast_install=]_LT_ENABLE_FAST_INSTALL_DEFAULT)
+
+_LT_DECL([fast_install], [enable_fast_install], [0],
+ [Whether or not to optimize for fast installation])dnl
+])# _LT_ENABLE_FAST_INSTALL
+
+LT_OPTION_DEFINE([LT_INIT], [fast-install], [_LT_ENABLE_FAST_INSTALL([yes])])
+LT_OPTION_DEFINE([LT_INIT], [disable-fast-install], [_LT_ENABLE_FAST_INSTALL([no])])
+
+# Old names:
+AU_DEFUN([AC_ENABLE_FAST_INSTALL],
+[_LT_SET_OPTION([LT_INIT], m4_if([$1], [no], [disable-])[fast-install])
+AC_DIAGNOSE([obsolete],
+[$0: Remove this warning and the call to _LT_SET_OPTION when you put
+the `fast-install' option into LT_INIT's first parameter.])
+])
+
+AU_DEFUN([AC_DISABLE_FAST_INSTALL],
+[_LT_SET_OPTION([LT_INIT], [disable-fast-install])
+AC_DIAGNOSE([obsolete],
+[$0: Remove this warning and the call to _LT_SET_OPTION when you put
+the `disable-fast-install' option into LT_INIT's first parameter.])
+])
+
+dnl aclocal-1.4 backwards compatibility:
+dnl AC_DEFUN([AC_ENABLE_FAST_INSTALL], [])
+dnl AC_DEFUN([AM_DISABLE_FAST_INSTALL], [])
+
+
+# _LT_WITH_PIC([MODE])
+# --------------------
+# implement the --with-pic flag, and support the `pic-only' and `no-pic'
+# LT_INIT options.
+# MODE is either `yes' or `no'. If omitted, it defaults to `both'.
+m4_define([_LT_WITH_PIC],
+[AC_ARG_WITH([pic],
+ [AS_HELP_STRING([--with-pic@<:@=PKGS@:>@],
+ [try to use only PIC/non-PIC objects @<:@default=use both@:>@])],
+ [lt_p=${PACKAGE-default}
+ case $withval in
+ yes|no) pic_mode=$withval ;;
+ *)
+ pic_mode=default
+ # Look at the argument we got. We use all the common list separators.
+ lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR,"
+ for lt_pkg in $withval; do
+ IFS="$lt_save_ifs"
+ if test "X$lt_pkg" = "X$lt_p"; then
+ pic_mode=yes
+ fi
+ done
+ IFS="$lt_save_ifs"
+ ;;
+ esac],
+ [pic_mode=default])
+
+test -z "$pic_mode" && pic_mode=m4_default([$1], [default])
+
+_LT_DECL([], [pic_mode], [0], [What type of objects to build])dnl
+])# _LT_WITH_PIC
+
+LT_OPTION_DEFINE([LT_INIT], [pic-only], [_LT_WITH_PIC([yes])])
+LT_OPTION_DEFINE([LT_INIT], [no-pic], [_LT_WITH_PIC([no])])
+
+# Old name:
+AU_DEFUN([AC_LIBTOOL_PICMODE],
+[_LT_SET_OPTION([LT_INIT], [pic-only])
+AC_DIAGNOSE([obsolete],
+[$0: Remove this warning and the call to _LT_SET_OPTION when you
+put the `pic-only' option into LT_INIT's first parameter.])
+])
+
+dnl aclocal-1.4 backwards compatibility:
+dnl AC_DEFUN([AC_LIBTOOL_PICMODE], [])
+
+## ----------------- ##
+## LTDL_INIT Options ##
+## ----------------- ##
+
+m4_define([_LTDL_MODE], [])
+LT_OPTION_DEFINE([LTDL_INIT], [nonrecursive],
+ [m4_define([_LTDL_MODE], [nonrecursive])])
+LT_OPTION_DEFINE([LTDL_INIT], [recursive],
+ [m4_define([_LTDL_MODE], [recursive])])
+LT_OPTION_DEFINE([LTDL_INIT], [subproject],
+ [m4_define([_LTDL_MODE], [subproject])])
+
+m4_define([_LTDL_TYPE], [])
+LT_OPTION_DEFINE([LTDL_INIT], [installable],
+ [m4_define([_LTDL_TYPE], [installable])])
+LT_OPTION_DEFINE([LTDL_INIT], [convenience],
+ [m4_define([_LTDL_TYPE], [convenience])])
diff --git a/jni/ruby/ext/fiddle/libffi-3.2.1/m4/ltsugar.m4 b/jni/ruby/ext/fiddle/libffi-3.2.1/m4/ltsugar.m4
new file mode 100644
index 0000000..9000a05
--- /dev/null
+++ b/jni/ruby/ext/fiddle/libffi-3.2.1/m4/ltsugar.m4
@@ -0,0 +1,123 @@
+# ltsugar.m4 -- libtool m4 base layer. -*-Autoconf-*-
+#
+# Copyright (C) 2004, 2005, 2007, 2008 Free Software Foundation, Inc.
+# Written by Gary V. Vaughan, 2004
+#
+# This file is free software; the Free Software Foundation gives
+# unlimited permission to copy and/or distribute it, with or without
+# modifications, as long as this notice is preserved.
+
+# serial 6 ltsugar.m4
+
+# This is to help aclocal find these macros, as it can't see m4_define.
+AC_DEFUN([LTSUGAR_VERSION], [m4_if([0.1])])
+
+
+# lt_join(SEP, ARG1, [ARG2...])
+# -----------------------------
+# Produce ARG1SEPARG2...SEPARGn, omitting [] arguments and their
+# associated separator.
+# Needed until we can rely on m4_join from Autoconf 2.62, since all earlier
+# versions in m4sugar had bugs.
+m4_define([lt_join],
+[m4_if([$#], [1], [],
+ [$#], [2], [[$2]],
+ [m4_if([$2], [], [], [[$2]_])$0([$1], m4_shift(m4_shift($@)))])])
+m4_define([_lt_join],
+[m4_if([$#$2], [2], [],
+ [m4_if([$2], [], [], [[$1$2]])$0([$1], m4_shift(m4_shift($@)))])])
+
+
+# lt_car(LIST)
+# lt_cdr(LIST)
+# ------------
+# Manipulate m4 lists.
+# These macros are necessary as long as will still need to support
+# Autoconf-2.59 which quotes differently.
+m4_define([lt_car], [[$1]])
+m4_define([lt_cdr],
+[m4_if([$#], 0, [m4_fatal([$0: cannot be called without arguments])],
+ [$#], 1, [],
+ [m4_dquote(m4_shift($@))])])
+m4_define([lt_unquote], $1)
+
+
+# lt_append(MACRO-NAME, STRING, [SEPARATOR])
+# ------------------------------------------
+# Redefine MACRO-NAME to hold its former content plus `SEPARATOR'`STRING'.
+# Note that neither SEPARATOR nor STRING are expanded; they are appended
+# to MACRO-NAME as is (leaving the expansion for when MACRO-NAME is invoked).
+# No SEPARATOR is output if MACRO-NAME was previously undefined (different
+# than defined and empty).
+#
+# This macro is needed until we can rely on Autoconf 2.62, since earlier
+# versions of m4sugar mistakenly expanded SEPARATOR but not STRING.
+m4_define([lt_append],
+[m4_define([$1],
+ m4_ifdef([$1], [m4_defn([$1])[$3]])[$2])])
+
+
+
+# lt_combine(SEP, PREFIX-LIST, INFIX, SUFFIX1, [SUFFIX2...])
+# ----------------------------------------------------------
+# Produce a SEP delimited list of all paired combinations of elements of
+# PREFIX-LIST with SUFFIX1 through SUFFIXn. Each element of the list
+# has the form PREFIXmINFIXSUFFIXn.
+# Needed until we can rely on m4_combine added in Autoconf 2.62.
+m4_define([lt_combine],
+[m4_if(m4_eval([$# > 3]), [1],
+ [m4_pushdef([_Lt_sep], [m4_define([_Lt_sep], m4_defn([lt_car]))])]]dnl
+[[m4_foreach([_Lt_prefix], [$2],
+ [m4_foreach([_Lt_suffix],
+ ]m4_dquote(m4_dquote(m4_shift(m4_shift(m4_shift($@)))))[,
+ [_Lt_sep([$1])[]m4_defn([_Lt_prefix])[$3]m4_defn([_Lt_suffix])])])])])
+
+
+# lt_if_append_uniq(MACRO-NAME, VARNAME, [SEPARATOR], [UNIQ], [NOT-UNIQ])
+# -----------------------------------------------------------------------
+# Iff MACRO-NAME does not yet contain VARNAME, then append it (delimited
+# by SEPARATOR if supplied) and expand UNIQ, else NOT-UNIQ.
+m4_define([lt_if_append_uniq],
+[m4_ifdef([$1],
+ [m4_if(m4_index([$3]m4_defn([$1])[$3], [$3$2$3]), [-1],
+ [lt_append([$1], [$2], [$3])$4],
+ [$5])],
+ [lt_append([$1], [$2], [$3])$4])])
+
+
+# lt_dict_add(DICT, KEY, VALUE)
+# -----------------------------
+m4_define([lt_dict_add],
+[m4_define([$1($2)], [$3])])
+
+
+# lt_dict_add_subkey(DICT, KEY, SUBKEY, VALUE)
+# --------------------------------------------
+m4_define([lt_dict_add_subkey],
+[m4_define([$1($2:$3)], [$4])])
+
+
+# lt_dict_fetch(DICT, KEY, [SUBKEY])
+# ----------------------------------
+m4_define([lt_dict_fetch],
+[m4_ifval([$3],
+ m4_ifdef([$1($2:$3)], [m4_defn([$1($2:$3)])]),
+ m4_ifdef([$1($2)], [m4_defn([$1($2)])]))])
+
+
+# lt_if_dict_fetch(DICT, KEY, [SUBKEY], VALUE, IF-TRUE, [IF-FALSE])
+# -----------------------------------------------------------------
+m4_define([lt_if_dict_fetch],
+[m4_if(lt_dict_fetch([$1], [$2], [$3]), [$4],
+ [$5],
+ [$6])])
+
+
+# lt_dict_filter(DICT, [SUBKEY], VALUE, [SEPARATOR], KEY, [...])
+# --------------------------------------------------------------
+m4_define([lt_dict_filter],
+[m4_if([$5], [], [],
+ [lt_join(m4_quote(m4_default([$4], [[, ]])),
+ lt_unquote(m4_split(m4_normalize(m4_foreach(_Lt_key, lt_car([m4_shiftn(4, $@)]),
+ [lt_if_dict_fetch([$1], _Lt_key, [$2], [$3], [_Lt_key ])])))))])[]dnl
+])
diff --git a/jni/ruby/ext/fiddle/libffi-3.2.1/m4/ltversion.m4 b/jni/ruby/ext/fiddle/libffi-3.2.1/m4/ltversion.m4
new file mode 100644
index 0000000..07a8602
--- /dev/null
+++ b/jni/ruby/ext/fiddle/libffi-3.2.1/m4/ltversion.m4
@@ -0,0 +1,23 @@
+# ltversion.m4 -- version numbers -*- Autoconf -*-
+#
+# Copyright (C) 2004 Free Software Foundation, Inc.
+# Written by Scott James Remnant, 2004
+#
+# This file is free software; the Free Software Foundation gives
+# unlimited permission to copy and/or distribute it, with or without
+# modifications, as long as this notice is preserved.
+
+# @configure_input@
+
+# serial 3337 ltversion.m4
+# This file is part of GNU Libtool
+
+m4_define([LT_PACKAGE_VERSION], [2.4.2])
+m4_define([LT_PACKAGE_REVISION], [1.3337])
+
+AC_DEFUN([LTVERSION_VERSION],
+[macro_version='2.4.2'
+macro_revision='1.3337'
+_LT_DECL(, macro_version, 0, [Which release of libtool.m4 was used?])
+_LT_DECL(, macro_revision, 0)
+])
diff --git a/jni/ruby/ext/fiddle/libffi-3.2.1/m4/lt~obsolete.m4 b/jni/ruby/ext/fiddle/libffi-3.2.1/m4/lt~obsolete.m4
new file mode 100644
index 0000000..c573da9
--- /dev/null
+++ b/jni/ruby/ext/fiddle/libffi-3.2.1/m4/lt~obsolete.m4
@@ -0,0 +1,98 @@
+# lt~obsolete.m4 -- aclocal satisfying obsolete definitions. -*-Autoconf-*-
+#
+# Copyright (C) 2004, 2005, 2007, 2009 Free Software Foundation, Inc.
+# Written by Scott James Remnant, 2004.
+#
+# This file is free software; the Free Software Foundation gives
+# unlimited permission to copy and/or distribute it, with or without
+# modifications, as long as this notice is preserved.
+
+# serial 5 lt~obsolete.m4
+
+# These exist entirely to fool aclocal when bootstrapping libtool.
+#
+# In the past libtool.m4 has provided macros via AC_DEFUN (or AU_DEFUN)
+# which have later been changed to m4_define as they aren't part of the
+# exported API, or moved to Autoconf or Automake where they belong.
+#
+# The trouble is, aclocal is a bit thick. It'll see the old AC_DEFUN
+# in /usr/share/aclocal/libtool.m4 and remember it, then when it sees us
+# using a macro with the same name in our local m4/libtool.m4 it'll
+# pull the old libtool.m4 in (it doesn't see our shiny new m4_define
+# and doesn't know about Autoconf macros at all.)
+#
+# So we provide this file, which has a silly filename so it's always
+# included after everything else. This provides aclocal with the
+# AC_DEFUNs it wants, but when m4 processes it, it doesn't do anything
+# because those macros already exist, or will be overwritten later.
+# We use AC_DEFUN over AU_DEFUN for compatibility with aclocal-1.6.
+#
+# Anytime we withdraw an AC_DEFUN or AU_DEFUN, remember to add it here.
+# Yes, that means every name once taken will need to remain here until
+# we give up compatibility with versions before 1.7, at which point
+# we need to keep only those names which we still refer to.
+
+# This is to help aclocal find these macros, as it can't see m4_define.
+AC_DEFUN([LTOBSOLETE_VERSION], [m4_if([1])])
+
+m4_ifndef([AC_LIBTOOL_LINKER_OPTION], [AC_DEFUN([AC_LIBTOOL_LINKER_OPTION])])
+m4_ifndef([AC_PROG_EGREP], [AC_DEFUN([AC_PROG_EGREP])])
+m4_ifndef([_LT_AC_PROG_ECHO_BACKSLASH], [AC_DEFUN([_LT_AC_PROG_ECHO_BACKSLASH])])
+m4_ifndef([_LT_AC_SHELL_INIT], [AC_DEFUN([_LT_AC_SHELL_INIT])])
+m4_ifndef([_LT_AC_SYS_LIBPATH_AIX], [AC_DEFUN([_LT_AC_SYS_LIBPATH_AIX])])
+m4_ifndef([_LT_PROG_LTMAIN], [AC_DEFUN([_LT_PROG_LTMAIN])])
+m4_ifndef([_LT_AC_TAGVAR], [AC_DEFUN([_LT_AC_TAGVAR])])
+m4_ifndef([AC_LTDL_ENABLE_INSTALL], [AC_DEFUN([AC_LTDL_ENABLE_INSTALL])])
+m4_ifndef([AC_LTDL_PREOPEN], [AC_DEFUN([AC_LTDL_PREOPEN])])
+m4_ifndef([_LT_AC_SYS_COMPILER], [AC_DEFUN([_LT_AC_SYS_COMPILER])])
+m4_ifndef([_LT_AC_LOCK], [AC_DEFUN([_LT_AC_LOCK])])
+m4_ifndef([AC_LIBTOOL_SYS_OLD_ARCHIVE], [AC_DEFUN([AC_LIBTOOL_SYS_OLD_ARCHIVE])])
+m4_ifndef([_LT_AC_TRY_DLOPEN_SELF], [AC_DEFUN([_LT_AC_TRY_DLOPEN_SELF])])
+m4_ifndef([AC_LIBTOOL_PROG_CC_C_O], [AC_DEFUN([AC_LIBTOOL_PROG_CC_C_O])])
+m4_ifndef([AC_LIBTOOL_SYS_HARD_LINK_LOCKS], [AC_DEFUN([AC_LIBTOOL_SYS_HARD_LINK_LOCKS])])
+m4_ifndef([AC_LIBTOOL_OBJDIR], [AC_DEFUN([AC_LIBTOOL_OBJDIR])])
+m4_ifndef([AC_LTDL_OBJDIR], [AC_DEFUN([AC_LTDL_OBJDIR])])
+m4_ifndef([AC_LIBTOOL_PROG_LD_HARDCODE_LIBPATH], [AC_DEFUN([AC_LIBTOOL_PROG_LD_HARDCODE_LIBPATH])])
+m4_ifndef([AC_LIBTOOL_SYS_LIB_STRIP], [AC_DEFUN([AC_LIBTOOL_SYS_LIB_STRIP])])
+m4_ifndef([AC_PATH_MAGIC], [AC_DEFUN([AC_PATH_MAGIC])])
+m4_ifndef([AC_PROG_LD_GNU], [AC_DEFUN([AC_PROG_LD_GNU])])
+m4_ifndef([AC_PROG_LD_RELOAD_FLAG], [AC_DEFUN([AC_PROG_LD_RELOAD_FLAG])])
+m4_ifndef([AC_DEPLIBS_CHECK_METHOD], [AC_DEFUN([AC_DEPLIBS_CHECK_METHOD])])
+m4_ifndef([AC_LIBTOOL_PROG_COMPILER_NO_RTTI], [AC_DEFUN([AC_LIBTOOL_PROG_COMPILER_NO_RTTI])])
+m4_ifndef([AC_LIBTOOL_SYS_GLOBAL_SYMBOL_PIPE], [AC_DEFUN([AC_LIBTOOL_SYS_GLOBAL_SYMBOL_PIPE])])
+m4_ifndef([AC_LIBTOOL_PROG_COMPILER_PIC], [AC_DEFUN([AC_LIBTOOL_PROG_COMPILER_PIC])])
+m4_ifndef([AC_LIBTOOL_PROG_LD_SHLIBS], [AC_DEFUN([AC_LIBTOOL_PROG_LD_SHLIBS])])
+m4_ifndef([AC_LIBTOOL_POSTDEP_PREDEP], [AC_DEFUN([AC_LIBTOOL_POSTDEP_PREDEP])])
+m4_ifndef([LT_AC_PROG_EGREP], [AC_DEFUN([LT_AC_PROG_EGREP])])
+m4_ifndef([LT_AC_PROG_SED], [AC_DEFUN([LT_AC_PROG_SED])])
+m4_ifndef([_LT_CC_BASENAME], [AC_DEFUN([_LT_CC_BASENAME])])
+m4_ifndef([_LT_COMPILER_BOILERPLATE], [AC_DEFUN([_LT_COMPILER_BOILERPLATE])])
+m4_ifndef([_LT_LINKER_BOILERPLATE], [AC_DEFUN([_LT_LINKER_BOILERPLATE])])
+m4_ifndef([_AC_PROG_LIBTOOL], [AC_DEFUN([_AC_PROG_LIBTOOL])])
+m4_ifndef([AC_LIBTOOL_SETUP], [AC_DEFUN([AC_LIBTOOL_SETUP])])
+m4_ifndef([_LT_AC_CHECK_DLFCN], [AC_DEFUN([_LT_AC_CHECK_DLFCN])])
+m4_ifndef([AC_LIBTOOL_SYS_DYNAMIC_LINKER], [AC_DEFUN([AC_LIBTOOL_SYS_DYNAMIC_LINKER])])
+m4_ifndef([_LT_AC_TAGCONFIG], [AC_DEFUN([_LT_AC_TAGCONFIG])])
+m4_ifndef([AC_DISABLE_FAST_INSTALL], [AC_DEFUN([AC_DISABLE_FAST_INSTALL])])
+m4_ifndef([_LT_AC_LANG_CXX], [AC_DEFUN([_LT_AC_LANG_CXX])])
+m4_ifndef([_LT_AC_LANG_F77], [AC_DEFUN([_LT_AC_LANG_F77])])
+m4_ifndef([_LT_AC_LANG_GCJ], [AC_DEFUN([_LT_AC_LANG_GCJ])])
+m4_ifndef([AC_LIBTOOL_LANG_C_CONFIG], [AC_DEFUN([AC_LIBTOOL_LANG_C_CONFIG])])
+m4_ifndef([_LT_AC_LANG_C_CONFIG], [AC_DEFUN([_LT_AC_LANG_C_CONFIG])])
+m4_ifndef([AC_LIBTOOL_LANG_CXX_CONFIG], [AC_DEFUN([AC_LIBTOOL_LANG_CXX_CONFIG])])
+m4_ifndef([_LT_AC_LANG_CXX_CONFIG], [AC_DEFUN([_LT_AC_LANG_CXX_CONFIG])])
+m4_ifndef([AC_LIBTOOL_LANG_F77_CONFIG], [AC_DEFUN([AC_LIBTOOL_LANG_F77_CONFIG])])
+m4_ifndef([_LT_AC_LANG_F77_CONFIG], [AC_DEFUN([_LT_AC_LANG_F77_CONFIG])])
+m4_ifndef([AC_LIBTOOL_LANG_GCJ_CONFIG], [AC_DEFUN([AC_LIBTOOL_LANG_GCJ_CONFIG])])
+m4_ifndef([_LT_AC_LANG_GCJ_CONFIG], [AC_DEFUN([_LT_AC_LANG_GCJ_CONFIG])])
+m4_ifndef([AC_LIBTOOL_LANG_RC_CONFIG], [AC_DEFUN([AC_LIBTOOL_LANG_RC_CONFIG])])
+m4_ifndef([_LT_AC_LANG_RC_CONFIG], [AC_DEFUN([_LT_AC_LANG_RC_CONFIG])])
+m4_ifndef([AC_LIBTOOL_CONFIG], [AC_DEFUN([AC_LIBTOOL_CONFIG])])
+m4_ifndef([_LT_AC_FILE_LTDLL_C], [AC_DEFUN([_LT_AC_FILE_LTDLL_C])])
+m4_ifndef([_LT_REQUIRED_DARWIN_CHECKS], [AC_DEFUN([_LT_REQUIRED_DARWIN_CHECKS])])
+m4_ifndef([_LT_AC_PROG_CXXCPP], [AC_DEFUN([_LT_AC_PROG_CXXCPP])])
+m4_ifndef([_LT_PREPARE_SED_QUOTE_VARS], [AC_DEFUN([_LT_PREPARE_SED_QUOTE_VARS])])
+m4_ifndef([_LT_PROG_ECHO_BACKSLASH], [AC_DEFUN([_LT_PROG_ECHO_BACKSLASH])])
+m4_ifndef([_LT_PROG_F77], [AC_DEFUN([_LT_PROG_F77])])
+m4_ifndef([_LT_PROG_FC], [AC_DEFUN([_LT_PROG_FC])])
+m4_ifndef([_LT_PROG_CXX], [AC_DEFUN([_LT_PROG_CXX])])
diff --git a/jni/ruby/ext/fiddle/libffi-3.2.1/man/Makefile.am b/jni/ruby/ext/fiddle/libffi-3.2.1/man/Makefile.am
new file mode 100644
index 0000000..afcbfb6
--- /dev/null
+++ b/jni/ruby/ext/fiddle/libffi-3.2.1/man/Makefile.am
@@ -0,0 +1,8 @@
+## Process this with automake to create Makefile.in
+
+AUTOMAKE_OPTIONS=foreign
+
+EXTRA_DIST = ffi.3 ffi_call.3 ffi_prep_cif.3 ffi_prep_cif_var.3
+
+man_MANS = ffi.3 ffi_call.3 ffi_prep_cif.3 ffi_prep_cif_var.3
+
diff --git a/jni/ruby/ext/fiddle/libffi-3.2.1/man/Makefile.in b/jni/ruby/ext/fiddle/libffi-3.2.1/man/Makefile.in
new file mode 100644
index 0000000..d92af74
--- /dev/null
+++ b/jni/ruby/ext/fiddle/libffi-3.2.1/man/Makefile.in
@@ -0,0 +1,541 @@
+# Makefile.in generated by automake 1.13.4 from Makefile.am.
+# @configure_input@
+
+# Copyright (C) 1994-2013 Free Software Foundation, Inc.
+
+# This Makefile.in is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
+# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE.
+
+@SET_MAKE@
+VPATH = @srcdir@
+am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)'
+am__make_running_with_option = \
+ case $${target_option-} in \
+ ?) ;; \
+ *) echo "am__make_running_with_option: internal error: invalid" \
+ "target option '$${target_option-}' specified" >&2; \
+ exit 1;; \
+ esac; \
+ has_opt=no; \
+ sane_makeflags=$$MAKEFLAGS; \
+ if $(am__is_gnu_make); then \
+ sane_makeflags=$$MFLAGS; \
+ else \
+ case $$MAKEFLAGS in \
+ *\\[\ \ ]*) \
+ bs=\\; \
+ sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \
+ | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \
+ esac; \
+ fi; \
+ skip_next=no; \
+ strip_trailopt () \
+ { \
+ flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \
+ }; \
+ for flg in $$sane_makeflags; do \
+ test $$skip_next = yes && { skip_next=no; continue; }; \
+ case $$flg in \
+ *=*|--*) continue;; \
+ -*I) strip_trailopt 'I'; skip_next=yes;; \
+ -*I?*) strip_trailopt 'I';; \
+ -*O) strip_trailopt 'O'; skip_next=yes;; \
+ -*O?*) strip_trailopt 'O';; \
+ -*l) strip_trailopt 'l'; skip_next=yes;; \
+ -*l?*) strip_trailopt 'l';; \
+ -[dEDm]) skip_next=yes;; \
+ -[JT]) skip_next=yes;; \
+ esac; \
+ case $$flg in \
+ *$$target_option*) has_opt=yes; break;; \
+ esac; \
+ done; \
+ test $$has_opt = yes
+am__make_dryrun = (target_option=n; $(am__make_running_with_option))
+am__make_keepgoing = (target_option=k; $(am__make_running_with_option))
+pkgdatadir = $(datadir)/@PACKAGE@
+pkgincludedir = $(includedir)/@PACKAGE@
+pkglibdir = $(libdir)/@PACKAGE@
+pkglibexecdir = $(libexecdir)/@PACKAGE@
+am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
+install_sh_DATA = $(install_sh) -c -m 644
+install_sh_PROGRAM = $(install_sh) -c
+install_sh_SCRIPT = $(install_sh) -c
+INSTALL_HEADER = $(INSTALL_DATA)
+transform = $(program_transform_name)
+NORMAL_INSTALL = :
+PRE_INSTALL = :
+POST_INSTALL = :
+NORMAL_UNINSTALL = :
+PRE_UNINSTALL = :
+POST_UNINSTALL = :
+build_triplet = @build@
+host_triplet = @host@
+target_triplet = @target@
+subdir = man
+DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am
+ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
+am__aclocal_m4_deps = $(top_srcdir)/m4/asmcfi.m4 \
+ $(top_srcdir)/m4/ax_append_flag.m4 \
+ $(top_srcdir)/m4/ax_cc_maxopt.m4 \
+ $(top_srcdir)/m4/ax_cflags_warn_all.m4 \
+ $(top_srcdir)/m4/ax_check_compile_flag.m4 \
+ $(top_srcdir)/m4/ax_compiler_vendor.m4 \
+ $(top_srcdir)/m4/ax_configure_args.m4 \
+ $(top_srcdir)/m4/ax_enable_builddir.m4 \
+ $(top_srcdir)/m4/ax_gcc_archflag.m4 \
+ $(top_srcdir)/m4/ax_gcc_x86_cpuid.m4 \
+ $(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \
+ $(top_srcdir)/m4/ltsugar.m4 $(top_srcdir)/m4/ltversion.m4 \
+ $(top_srcdir)/m4/lt~obsolete.m4 $(top_srcdir)/acinclude.m4 \
+ $(top_srcdir)/configure.ac
+am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
+ $(ACLOCAL_M4)
+mkinstalldirs = $(install_sh) -d
+CONFIG_HEADER = $(top_builddir)/fficonfig.h
+CONFIG_CLEAN_FILES =
+CONFIG_CLEAN_VPATH_FILES =
+AM_V_P = $(am__v_P_@AM_V@)
+am__v_P_ = $(am__v_P_@AM_DEFAULT_V@)
+am__v_P_0 = false
+am__v_P_1 = :
+AM_V_GEN = $(am__v_GEN_@AM_V@)
+am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@)
+am__v_GEN_0 = @echo " GEN " $@;
+am__v_GEN_1 =
+AM_V_at = $(am__v_at_@AM_V@)
+am__v_at_ = $(am__v_at_@AM_DEFAULT_V@)
+am__v_at_0 = @
+am__v_at_1 =
+SOURCES =
+DIST_SOURCES =
+am__can_run_installinfo = \
+ case $$AM_UPDATE_INFO_DIR in \
+ n|no|NO) false;; \
+ *) (install-info --version) >/dev/null 2>&1;; \
+ esac
+am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`;
+am__vpath_adj = case $$p in \
+ $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \
+ *) f=$$p;; \
+ esac;
+am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`;
+am__install_max = 40
+am__nobase_strip_setup = \
+ srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'`
+am__nobase_strip = \
+ for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||"
+am__nobase_list = $(am__nobase_strip_setup); \
+ for p in $$list; do echo "$$p $$p"; done | \
+ sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \
+ $(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \
+ if (++n[$$2] == $(am__install_max)) \
+ { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \
+ END { for (dir in files) print dir, files[dir] }'
+am__base_list = \
+ sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \
+ sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g'
+am__uninstall_files_from_dir = { \
+ test -z "$$files" \
+ || { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \
+ || { echo " ( cd '$$dir' && rm -f" $$files ")"; \
+ $(am__cd) "$$dir" && rm -f $$files; }; \
+ }
+man3dir = $(mandir)/man3
+am__installdirs = "$(DESTDIR)$(man3dir)"
+NROFF = nroff
+MANS = $(man_MANS)
+am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP)
+DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
+ACLOCAL = @ACLOCAL@
+ALLOCA = @ALLOCA@
+AMTAR = @AMTAR@
+AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@
+AM_LTLDFLAGS = @AM_LTLDFLAGS@
+AM_RUNTESTFLAGS = @AM_RUNTESTFLAGS@
+AR = @AR@
+AUTOCONF = @AUTOCONF@
+AUTOHEADER = @AUTOHEADER@
+AUTOMAKE = @AUTOMAKE@
+AWK = @AWK@
+CC = @CC@
+CCAS = @CCAS@
+CCASDEPMODE = @CCASDEPMODE@
+CCASFLAGS = @CCASFLAGS@
+CCDEPMODE = @CCDEPMODE@
+CFLAGS = @CFLAGS@
+CPP = @CPP@
+CPPFLAGS = @CPPFLAGS@
+CXX = @CXX@
+CXXCPP = @CXXCPP@
+CXXDEPMODE = @CXXDEPMODE@
+CXXFLAGS = @CXXFLAGS@
+CYGPATH_W = @CYGPATH_W@
+DEFS = @DEFS@
+DEPDIR = @DEPDIR@
+DLLTOOL = @DLLTOOL@
+DSYMUTIL = @DSYMUTIL@
+DUMPBIN = @DUMPBIN@
+ECHO_C = @ECHO_C@
+ECHO_N = @ECHO_N@
+ECHO_T = @ECHO_T@
+EGREP = @EGREP@
+EXEEXT = @EXEEXT@
+FFI_EXEC_TRAMPOLINE_TABLE = @FFI_EXEC_TRAMPOLINE_TABLE@
+FGREP = @FGREP@
+GREP = @GREP@
+HAVE_LONG_DOUBLE = @HAVE_LONG_DOUBLE@
+HAVE_LONG_DOUBLE_VARIANT = @HAVE_LONG_DOUBLE_VARIANT@
+INSTALL = @INSTALL@
+INSTALL_DATA = @INSTALL_DATA@
+INSTALL_PROGRAM = @INSTALL_PROGRAM@
+INSTALL_SCRIPT = @INSTALL_SCRIPT@
+INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
+LD = @LD@
+LDFLAGS = @LDFLAGS@
+LIBOBJS = @LIBOBJS@
+LIBS = @LIBS@
+LIBTOOL = @LIBTOOL@
+LIPO = @LIPO@
+LN_S = @LN_S@
+LTLIBOBJS = @LTLIBOBJS@
+MAINT = @MAINT@
+MAKEINFO = @MAKEINFO@
+MANIFEST_TOOL = @MANIFEST_TOOL@
+MKDIR_P = @MKDIR_P@
+NM = @NM@
+NMEDIT = @NMEDIT@
+OBJDUMP = @OBJDUMP@
+OBJEXT = @OBJEXT@
+OTOOL = @OTOOL@
+OTOOL64 = @OTOOL64@
+PACKAGE = @PACKAGE@
+PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
+PACKAGE_NAME = @PACKAGE_NAME@
+PACKAGE_STRING = @PACKAGE_STRING@
+PACKAGE_TARNAME = @PACKAGE_TARNAME@
+PACKAGE_URL = @PACKAGE_URL@
+PACKAGE_VERSION = @PACKAGE_VERSION@
+PATH_SEPARATOR = @PATH_SEPARATOR@
+PRTDIAG = @PRTDIAG@
+RANLIB = @RANLIB@
+SED = @SED@
+SET_MAKE = @SET_MAKE@
+SHELL = @SHELL@
+STRIP = @STRIP@
+TARGET = @TARGET@
+TARGETDIR = @TARGETDIR@
+VERSION = @VERSION@
+abs_builddir = @abs_builddir@
+abs_srcdir = @abs_srcdir@
+abs_top_builddir = @abs_top_builddir@
+abs_top_srcdir = @abs_top_srcdir@
+ac_ct_AR = @ac_ct_AR@
+ac_ct_CC = @ac_ct_CC@
+ac_ct_CXX = @ac_ct_CXX@
+ac_ct_DUMPBIN = @ac_ct_DUMPBIN@
+am__include = @am__include@
+am__leading_dot = @am__leading_dot@
+am__quote = @am__quote@
+am__tar = @am__tar@
+am__untar = @am__untar@
+ax_enable_builddir_sed = @ax_enable_builddir_sed@
+bindir = @bindir@
+build = @build@
+build_alias = @build_alias@
+build_cpu = @build_cpu@
+build_os = @build_os@
+build_vendor = @build_vendor@
+builddir = @builddir@
+datadir = @datadir@
+datarootdir = @datarootdir@
+docdir = @docdir@
+dvidir = @dvidir@
+exec_prefix = @exec_prefix@
+host = @host@
+host_alias = @host_alias@
+host_cpu = @host_cpu@
+host_os = @host_os@
+host_vendor = @host_vendor@
+htmldir = @htmldir@
+includedir = @includedir@
+infodir = @infodir@
+install_sh = @install_sh@
+libdir = @libdir@
+libexecdir = @libexecdir@
+localedir = @localedir@
+localstatedir = @localstatedir@
+mandir = @mandir@
+mkdir_p = @mkdir_p@
+oldincludedir = @oldincludedir@
+pdfdir = @pdfdir@
+prefix = @prefix@
+program_transform_name = @program_transform_name@
+psdir = @psdir@
+sbindir = @sbindir@
+sharedstatedir = @sharedstatedir@
+srcdir = @srcdir@
+sys_symbol_underscore = @sys_symbol_underscore@
+sysconfdir = @sysconfdir@
+target = @target@
+target_alias = @target_alias@
+target_cpu = @target_cpu@
+target_os = @target_os@
+target_vendor = @target_vendor@
+toolexecdir = @toolexecdir@
+toolexeclibdir = @toolexeclibdir@
+top_build_prefix = @top_build_prefix@
+top_builddir = @top_builddir@
+top_srcdir = @top_srcdir@
+AUTOMAKE_OPTIONS = foreign
+EXTRA_DIST = ffi.3 ffi_call.3 ffi_prep_cif.3 ffi_prep_cif_var.3
+man_MANS = ffi.3 ffi_call.3 ffi_prep_cif.3 ffi_prep_cif_var.3
+all: all-am
+
+.SUFFIXES:
+$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps)
+ @for dep in $?; do \
+ case '$(am__configure_deps)' in \
+ *$$dep*) \
+ ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \
+ && { if test -f $@; then exit 0; else break; fi; }; \
+ exit 1;; \
+ esac; \
+ done; \
+ echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign man/Makefile'; \
+ $(am__cd) $(top_srcdir) && \
+ $(AUTOMAKE) --foreign man/Makefile
+.PRECIOUS: Makefile
+Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
+ @case '$?' in \
+ *config.status*) \
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
+ *) \
+ echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
+ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
+ esac;
+
+$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+
+$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(am__aclocal_m4_deps):
+
+mostlyclean-libtool:
+ -rm -f *.lo
+
+clean-libtool:
+ -rm -rf .libs _libs
+install-man3: $(man_MANS)
+ @$(NORMAL_INSTALL)
+ @list1=''; \
+ list2='$(man_MANS)'; \
+ test -n "$(man3dir)" \
+ && test -n "`echo $$list1$$list2`" \
+ || exit 0; \
+ echo " $(MKDIR_P) '$(DESTDIR)$(man3dir)'"; \
+ $(MKDIR_P) "$(DESTDIR)$(man3dir)" || exit 1; \
+ { for i in $$list1; do echo "$$i"; done; \
+ if test -n "$$list2"; then \
+ for i in $$list2; do echo "$$i"; done \
+ | sed -n '/\.3[a-z]*$$/p'; \
+ fi; \
+ } | while read p; do \
+ if test -f $$p; then d=; else d="$(srcdir)/"; fi; \
+ echo "$$d$$p"; echo "$$p"; \
+ done | \
+ sed -e 'n;s,.*/,,;p;h;s,.*\.,,;s,^[^3][0-9a-z]*$$,3,;x' \
+ -e 's,\.[0-9a-z]*$$,,;$(transform);G;s,\n,.,' | \
+ sed 'N;N;s,\n, ,g' | { \
+ list=; while read file base inst; do \
+ if test "$$base" = "$$inst"; then list="$$list $$file"; else \
+ echo " $(INSTALL_DATA) '$$file' '$(DESTDIR)$(man3dir)/$$inst'"; \
+ $(INSTALL_DATA) "$$file" "$(DESTDIR)$(man3dir)/$$inst" || exit $$?; \
+ fi; \
+ done; \
+ for i in $$list; do echo "$$i"; done | $(am__base_list) | \
+ while read files; do \
+ test -z "$$files" || { \
+ echo " $(INSTALL_DATA) $$files '$(DESTDIR)$(man3dir)'"; \
+ $(INSTALL_DATA) $$files "$(DESTDIR)$(man3dir)" || exit $$?; }; \
+ done; }
+
+uninstall-man3:
+ @$(NORMAL_UNINSTALL)
+ @list=''; test -n "$(man3dir)" || exit 0; \
+ files=`{ for i in $$list; do echo "$$i"; done; \
+ l2='$(man_MANS)'; for i in $$l2; do echo "$$i"; done | \
+ sed -n '/\.3[a-z]*$$/p'; \
+ } | sed -e 's,.*/,,;h;s,.*\.,,;s,^[^3][0-9a-z]*$$,3,;x' \
+ -e 's,\.[0-9a-z]*$$,,;$(transform);G;s,\n,.,'`; \
+ dir='$(DESTDIR)$(man3dir)'; $(am__uninstall_files_from_dir)
+tags TAGS:
+
+ctags CTAGS:
+
+cscope cscopelist:
+
+
+distdir: $(DISTFILES)
+ @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+ list='$(DISTFILES)'; \
+ dist_files=`for file in $$list; do echo $$file; done | \
+ sed -e "s|^$$srcdirstrip/||;t" \
+ -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
+ case $$dist_files in \
+ */*) $(MKDIR_P) `echo "$$dist_files" | \
+ sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
+ sort -u` ;; \
+ esac; \
+ for file in $$dist_files; do \
+ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
+ if test -d $$d/$$file; then \
+ dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
+ if test -d "$(distdir)/$$file"; then \
+ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
+ fi; \
+ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
+ cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \
+ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
+ fi; \
+ cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \
+ else \
+ test -f "$(distdir)/$$file" \
+ || cp -p $$d/$$file "$(distdir)/$$file" \
+ || exit 1; \
+ fi; \
+ done
+check-am: all-am
+check: check-am
+all-am: Makefile $(MANS)
+installdirs:
+ for dir in "$(DESTDIR)$(man3dir)"; do \
+ test -z "$$dir" || $(MKDIR_P) "$$dir"; \
+ done
+install: install-am
+install-exec: install-exec-am
+install-data: install-data-am
+uninstall: uninstall-am
+
+install-am: all-am
+ @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
+
+installcheck: installcheck-am
+install-strip:
+ if test -z '$(STRIP)'; then \
+ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
+ install; \
+ else \
+ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
+ "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \
+ fi
+mostlyclean-generic:
+
+clean-generic:
+
+distclean-generic:
+ -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
+ -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES)
+
+maintainer-clean-generic:
+ @echo "This command is intended for maintainers to use"
+ @echo "it deletes files that may require special tools to rebuild."
+clean: clean-am
+
+clean-am: clean-generic clean-libtool mostlyclean-am
+
+distclean: distclean-am
+ -rm -f Makefile
+distclean-am: clean-am distclean-generic
+
+dvi: dvi-am
+
+dvi-am:
+
+html: html-am
+
+html-am:
+
+info: info-am
+
+info-am:
+
+install-data-am: install-man
+
+install-dvi: install-dvi-am
+
+install-dvi-am:
+
+install-exec-am:
+
+install-html: install-html-am
+
+install-html-am:
+
+install-info: install-info-am
+
+install-info-am:
+
+install-man: install-man3
+
+install-pdf: install-pdf-am
+
+install-pdf-am:
+
+install-ps: install-ps-am
+
+install-ps-am:
+
+installcheck-am:
+
+maintainer-clean: maintainer-clean-am
+ -rm -f Makefile
+maintainer-clean-am: distclean-am maintainer-clean-generic
+
+mostlyclean: mostlyclean-am
+
+mostlyclean-am: mostlyclean-generic mostlyclean-libtool
+
+pdf: pdf-am
+
+pdf-am:
+
+ps: ps-am
+
+ps-am:
+
+uninstall-am: uninstall-man
+
+uninstall-man: uninstall-man3
+
+.MAKE: install-am install-strip
+
+.PHONY: all all-am check check-am clean clean-generic clean-libtool \
+ cscopelist-am ctags-am distclean distclean-generic \
+ distclean-libtool distdir dvi dvi-am html html-am info info-am \
+ install install-am install-data install-data-am install-dvi \
+ install-dvi-am install-exec install-exec-am install-html \
+ install-html-am install-info install-info-am install-man \
+ install-man3 install-pdf install-pdf-am install-ps \
+ install-ps-am install-strip installcheck installcheck-am \
+ installdirs maintainer-clean maintainer-clean-generic \
+ mostlyclean mostlyclean-generic mostlyclean-libtool pdf pdf-am \
+ ps ps-am tags-am uninstall uninstall-am uninstall-man \
+ uninstall-man3
+
+
+# Tell versions [3.59,3.63) of GNU make to not export all variables.
+# Otherwise a system limit (for SysV at least) may be exceeded.
+.NOEXPORT:
diff --git a/jni/ruby/ext/fiddle/libffi-3.2.1/man/ffi.3 b/jni/ruby/ext/fiddle/libffi-3.2.1/man/ffi.3
new file mode 100644
index 0000000..1f1d303
--- /dev/null
+++ b/jni/ruby/ext/fiddle/libffi-3.2.1/man/ffi.3
@@ -0,0 +1,41 @@
+.Dd February 15, 2008
+.Dt FFI 3
+.Sh NAME
+.Nm FFI
+.Nd Foreign Function Interface
+.Sh LIBRARY
+libffi, -lffi
+.Sh SYNOPSIS
+.In ffi.h
+.Ft ffi_status
+.Fo ffi_prep_cif
+.Fa "ffi_cif *cif"
+.Fa "ffi_abi abi"
+.Fa "unsigned int nargs"
+.Fa "ffi_type *rtype"
+.Fa "ffi_type **atypes"
+.Fc
+.Ft void
+.Fo ffi_prep_cif_var
+.Fa "ffi_cif *cif"
+.Fa "ffi_abi abi"
+.Fa "unsigned int nfixedargs"
+.Fa "unsigned int ntotalargs"
+.Fa "ffi_type *rtype"
+.Fa "ffi_type **atypes"
+.Fc
+.Ft void
+.Fo ffi_call
+.Fa "ffi_cif *cif"
+.Fa "void (*fn)(void)"
+.Fa "void *rvalue"
+.Fa "void **avalue"
+.Fc
+.Sh DESCRIPTION
+The foreign function interface provides a mechanism by which a function can
+generate a call to another function at runtime without requiring knowledge of
+the called function's interface at compile time.
+.Sh SEE ALSO
+.Xr ffi_prep_cif 3 ,
+.Xr ffi_prep_cif_var 3 ,
+.Xr ffi_call 3
diff --git a/jni/ruby/ext/fiddle/libffi-3.2.1/man/ffi_call.3 b/jni/ruby/ext/fiddle/libffi-3.2.1/man/ffi_call.3
new file mode 100644
index 0000000..5351513
--- /dev/null
+++ b/jni/ruby/ext/fiddle/libffi-3.2.1/man/ffi_call.3
@@ -0,0 +1,103 @@
+.Dd February 15, 2008
+.Dt ffi_call 3
+.Sh NAME
+.Nm ffi_call
+.Nd Invoke a foreign function.
+.Sh SYNOPSIS
+.In ffi.h
+.Ft void
+.Fo ffi_call
+.Fa "ffi_cif *cif"
+.Fa "void (*fn)(void)"
+.Fa "void *rvalue"
+.Fa "void **avalue"
+.Fc
+.Sh DESCRIPTION
+The
+.Nm ffi_call
+function provides a simple mechanism for invoking a function without
+requiring knowledge of the function's interface at compile time.
+.Fa fn
+is called with the values retrieved from the pointers in the
+.Fa avalue
+array. The return value from
+.Fa fn
+is placed in storage pointed to by
+.Fa rvalue .
+.Fa cif
+contains information describing the data types, sizes and alignments of the
+arguments to and return value from
+.Fa fn ,
+and must be initialized with
+.Nm ffi_prep_cif
+before it is used with
+.Nm ffi_call .
+.Pp
+.Fa rvalue
+must point to storage that is sizeof(ffi_arg) or larger for non-floating point
+types. For smaller-sized return value types, the
+.Nm ffi_arg
+or
+.Nm ffi_sarg
+integral type must be used to hold
+the return value.
+.Sh EXAMPLES
+.Bd -literal
+#include <ffi.h>
+#include <stdio.h>
+
+unsigned char
+foo(unsigned int, float);
+
+int
+main(int argc, const char **argv)
+{
+ ffi_cif cif;
+ ffi_type *arg_types[2];
+ void *arg_values[2];
+ ffi_status status;
+
+ // Because the return value from foo() is smaller than sizeof(long), it
+ // must be passed as ffi_arg or ffi_sarg.
+ ffi_arg result;
+
+ // Specify the data type of each argument. Available types are defined
+ // in <ffi/ffi.h>.
+ arg_types[0] = &ffi_type_uint;
+ arg_types[1] = &ffi_type_float;
+
+ // Prepare the ffi_cif structure.
+ if ((status = ffi_prep_cif(&cif, FFI_DEFAULT_ABI,
+ 2, &ffi_type_uint8, arg_types)) != FFI_OK)
+ {
+ // Handle the ffi_status error.
+ }
+
+ // Specify the values of each argument.
+ unsigned int arg1 = 42;
+ float arg2 = 5.1;
+
+ arg_values[0] = &arg1;
+ arg_values[1] = &arg2;
+
+ // Invoke the function.
+ ffi_call(&cif, FFI_FN(foo), &result, arg_values);
+
+ // The ffi_arg 'result' now contains the unsigned char returned from foo(),
+ // which can be accessed by a typecast.
+ printf("result is %hhu", (unsigned char)result);
+
+ return 0;
+}
+
+// The target function.
+unsigned char
+foo(unsigned int x, float y)
+{
+ unsigned char result = x - y;
+ return result;
+}
+.Ed
+.Sh SEE ALSO
+.Xr ffi 3 ,
+.Xr ffi_prep_cif 3
diff --git a/jni/ruby/ext/fiddle/libffi-3.2.1/man/ffi_prep_cif.3 b/jni/ruby/ext/fiddle/libffi-3.2.1/man/ffi_prep_cif.3
new file mode 100644
index 0000000..ab2be8a
--- /dev/null
+++ b/jni/ruby/ext/fiddle/libffi-3.2.1/man/ffi_prep_cif.3
@@ -0,0 +1,68 @@
+.Dd February 15, 2008
+.Dt ffi_prep_cif 3
+.Sh NAME
+.Nm ffi_prep_cif
+.Nd Prepare a
+.Nm ffi_cif
+structure for use with
+.Nm ffi_call
+.
+.Sh SYNOPSIS
+.In ffi.h
+.Ft ffi_status
+.Fo ffi_prep_cif
+.Fa "ffi_cif *cif"
+.Fa "ffi_abi abi"
+.Fa "unsigned int nargs"
+.Fa "ffi_type *rtype"
+.Fa "ffi_type **atypes"
+.Fc
+.Sh DESCRIPTION
+The
+.Nm ffi_prep_cif
+function prepares a
+.Nm ffi_cif
+structure for use with
+.Nm ffi_call
+.
+.Fa abi
+specifies a set of calling conventions to use.
+.Fa atypes
+is an array of
+.Fa nargs
+pointers to
+.Nm ffi_type
+structs that describe the data type, size and alignment of each argument.
+.Fa rtype
+points to an
+.Nm ffi_type
+that describes the data type, size and alignment of the
+return value. Note that to call a variadic function
+.Nm ffi_prep_cif_var
+must be used instead.
+.Sh RETURN VALUES
+Upon successful completion,
+.Nm ffi_prep_cif
+returns
+.Nm FFI_OK .
+It will return
+.Nm FFI_BAD_TYPEDEF
+if
+.Fa cif
+is
+.Nm NULL
+or
+.Fa atypes
+or
+.Fa rtype
+is malformed. If
+.Fa abi
+does not refer to a valid ABI,
+.Nm FFI_BAD_ABI
+will be returned. Available ABIs are
+defined in
+.Nm <ffitarget.h> .
+.Sh SEE ALSO
+.Xr ffi 3 ,
+.Xr ffi_call 3 ,
+.Xr ffi_prep_cif_var 3
diff --git a/jni/ruby/ext/fiddle/libffi-3.2.1/man/ffi_prep_cif_var.3 b/jni/ruby/ext/fiddle/libffi-3.2.1/man/ffi_prep_cif_var.3
new file mode 100644
index 0000000..7e19d0b
--- /dev/null
+++ b/jni/ruby/ext/fiddle/libffi-3.2.1/man/ffi_prep_cif_var.3
@@ -0,0 +1,73 @@
+.Dd January 25, 2011
+.Dt ffi_prep_cif_var 3
+.Sh NAME
+.Nm ffi_prep_cif_var
+.Nd Prepare a
+.Nm ffi_cif
+structure for use with
+.Nm ffi_call
+for variadic functions.
+.Sh SYNOPSIS
+.In ffi.h
+.Ft ffi_status
+.Fo ffi_prep_cif_var
+.Fa "ffi_cif *cif"
+.Fa "ffi_abi abi"
+.Fa "unsigned int nfixedargs"
+.Fa "unsigned int ntotalargs"
+.Fa "ffi_type *rtype"
+.Fa "ffi_type **atypes"
+.Fc
+.Sh DESCRIPTION
+The
+.Nm ffi_prep_cif_var
+function prepares a
+.Nm ffi_cif
+structure for use with
+.Nm ffi_call
+for variadic functions.
+.Fa abi
+specifies a set of calling conventions to use.
+.Fa atypes
+is an array of
+.Fa ntotalargs
+pointers to
+.Nm ffi_type
+structs that describe the data type, size and alignment of each argument.
+.Fa rtype
+points to an
+.Nm ffi_type
+that describes the data type, size and alignment of the
+return value.
+.Fa nfixedargs
+must contain the number of fixed (non-variadic) arguments.
+Note that to call a non-variadic function
+.Nm ffi_prep_cif
+must be used.
+.Sh RETURN VALUES
+Upon successful completion,
+.Nm ffi_prep_cif_var
+returns
+.Nm FFI_OK .
+It will return
+.Nm FFI_BAD_TYPEDEF
+if
+.Fa cif
+is
+.Nm NULL
+or
+.Fa atypes
+or
+.Fa rtype
+is malformed. If
+.Fa abi
+does not refer to a valid ABI,
+.Nm FFI_BAD_ABI
+will be returned. Available ABIs are
+defined in
+.Nm <ffitarget.h>
+.
+.Sh SEE ALSO
+.Xr ffi 3 ,
+.Xr ffi_call 3 ,
+.Xr ffi_prep_cif 3
diff --git a/jni/ruby/ext/fiddle/libffi-3.2.1/mdate-sh b/jni/ruby/ext/fiddle/libffi-3.2.1/mdate-sh
new file mode 100755
index 0000000..b3719cf
--- /dev/null
+++ b/jni/ruby/ext/fiddle/libffi-3.2.1/mdate-sh
@@ -0,0 +1,224 @@
+#!/bin/sh
+# Get modification time of a file or directory and pretty-print it.
+
+scriptversion=2010-08-21.06; # UTC
+
+# Copyright (C) 1995-2013 Free Software Foundation, Inc.
+# written by Ulrich Drepper <drepper@gnu.ai.mit.edu>, June 1995
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+# As a special exception to the GNU General Public License, if you
+# distribute this file as part of a program that contains a
+# configuration script generated by Autoconf, you may include it under
+# the same distribution terms that you use for the rest of that program.
+
+# This file is maintained in Automake, please report
+# bugs to <bug-automake@gnu.org> or send patches to
+# <automake-patches@gnu.org>.
+
+if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then
+ emulate sh
+ NULLCMD=:
+ # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which
+ # is contrary to our usage. Disable this feature.
+ alias -g '${1+"$@"}'='"$@"'
+ setopt NO_GLOB_SUBST
+fi
+
+case $1 in
+ '')
+ echo "$0: No file. Try '$0 --help' for more information." 1>&2
+ exit 1;
+ ;;
+ -h | --h*)
+ cat <<\EOF
+Usage: mdate-sh [--help] [--version] FILE
+
+Pretty-print the modification day of FILE, in the format:
+1 January 1970
+
+Report bugs to <bug-automake@gnu.org>.
+EOF
+ exit $?
+ ;;
+ -v | --v*)
+ echo "mdate-sh $scriptversion"
+ exit $?
+ ;;
+esac
+
+error ()
+{
+ echo "$0: $1" >&2
+ exit 1
+}
+
+
+# Prevent date giving response in another language.
+LANG=C
+export LANG
+LC_ALL=C
+export LC_ALL
+LC_TIME=C
+export LC_TIME
+
+# GNU ls changes its time format in response to the TIME_STYLE
+# variable. Since we cannot assume 'unset' works, revert this
+# variable to its documented default.
+if test "${TIME_STYLE+set}" = set; then
+ TIME_STYLE=posix-long-iso
+ export TIME_STYLE
+fi
+
+save_arg1=$1
+
+# Find out how to get the extended ls output of a file or directory.
+if ls -L /dev/null 1>/dev/null 2>&1; then
+ ls_command='ls -L -l -d'
+else
+ ls_command='ls -l -d'
+fi
+# Avoid user/group names that might have spaces, when possible.
+if ls -n /dev/null 1>/dev/null 2>&1; then
+ ls_command="$ls_command -n"
+fi
+
+# A 'ls -l' line looks as follows on OS/2.
+# drwxrwx--- 0 Aug 11 2001 foo
+# This differs from Unix, which adds ownership information.
+# drwxrwx--- 2 root root 4096 Aug 11 2001 foo
+#
+# To find the date, we split the line on spaces and iterate on words
+# until we find a month. This cannot work with files whose owner is a
+# user named "Jan", or "Feb", etc. However, it's unlikely that '/'
+# will be owned by a user whose name is a month. So we first look at
+# the extended ls output of the root directory to decide how many
+# words should be skipped to get the date.
+
+# On HPUX /bin/sh, "set" interprets "-rw-r--r--" as options, so the "x" below.
+set x`$ls_command /`
+
+# Find which argument is the month.
+month=
+command=
+until test $month
+do
+ test $# -gt 0 || error "failed parsing '$ls_command /' output"
+ shift
+ # Add another shift to the command.
+ command="$command shift;"
+ case $1 in
+ Jan) month=January; nummonth=1;;
+ Feb) month=February; nummonth=2;;
+ Mar) month=March; nummonth=3;;
+ Apr) month=April; nummonth=4;;
+ May) month=May; nummonth=5;;
+ Jun) month=June; nummonth=6;;
+ Jul) month=July; nummonth=7;;
+ Aug) month=August; nummonth=8;;
+ Sep) month=September; nummonth=9;;
+ Oct) month=October; nummonth=10;;
+ Nov) month=November; nummonth=11;;
+ Dec) month=December; nummonth=12;;
+ esac
+done
+
+test -n "$month" || error "failed parsing '$ls_command /' output"
+
+# Get the extended ls output of the file or directory.
+set dummy x`eval "$ls_command \"\\\$save_arg1\""`
+
+# Remove all preceding arguments
+eval $command
+
+# Because of the dummy argument above, month is in $2.
+#
+# On a POSIX system, we should have
+#
+# $# = 5
+# $1 = file size
+# $2 = month
+# $3 = day
+# $4 = year or time
+# $5 = filename
+#
+# On Darwin 7.7.0 and 7.6.0, we have
+#
+# $# = 4
+# $1 = day
+# $2 = month
+# $3 = year or time
+# $4 = filename
+
+# Get the month.
+case $2 in
+ Jan) month=January; nummonth=1;;
+ Feb) month=February; nummonth=2;;
+ Mar) month=March; nummonth=3;;
+ Apr) month=April; nummonth=4;;
+ May) month=May; nummonth=5;;
+ Jun) month=June; nummonth=6;;
+ Jul) month=July; nummonth=7;;
+ Aug) month=August; nummonth=8;;
+ Sep) month=September; nummonth=9;;
+ Oct) month=October; nummonth=10;;
+ Nov) month=November; nummonth=11;;
+ Dec) month=December; nummonth=12;;
+esac
+
+case $3 in
+ ???*) day=$1;;
+ *) day=$3; shift;;
+esac
+
+# Here we have to deal with the problem that the ls output gives either
+# the time of day or the year.
+case $3 in
+ *:*) set `date`; eval year=\$$#
+ case $2 in
+ Jan) nummonthtod=1;;
+ Feb) nummonthtod=2;;
+ Mar) nummonthtod=3;;
+ Apr) nummonthtod=4;;
+ May) nummonthtod=5;;
+ Jun) nummonthtod=6;;
+ Jul) nummonthtod=7;;
+ Aug) nummonthtod=8;;
+ Sep) nummonthtod=9;;
+ Oct) nummonthtod=10;;
+ Nov) nummonthtod=11;;
+ Dec) nummonthtod=12;;
+ esac
+ # For the first six month of the year the time notation can also
+ # be used for files modified in the last year.
+ if (expr $nummonth \> $nummonthtod) > /dev/null;
+ then
+ year=`expr $year - 1`
+ fi;;
+ *) year=$3;;
+esac
+
+# The result.
+echo $day $month $year
+
+# Local Variables:
+# mode: shell-script
+# sh-indentation: 2
+# eval: (add-hook 'write-file-hooks 'time-stamp)
+# time-stamp-start: "scriptversion="
+# time-stamp-format: "%:y-%02m-%02d.%02H"
+# time-stamp-time-zone: "UTC"
+# time-stamp-end: "; # UTC"
+# End:
diff --git a/jni/ruby/ext/fiddle/libffi-3.2.1/missing b/jni/ruby/ext/fiddle/libffi-3.2.1/missing
new file mode 100755
index 0000000..cdea514
--- /dev/null
+++ b/jni/ruby/ext/fiddle/libffi-3.2.1/missing
@@ -0,0 +1,215 @@
+#! /bin/sh
+# Common wrapper for a few potentially missing GNU programs.
+
+scriptversion=2012-06-26.16; # UTC
+
+# Copyright (C) 1996-2013 Free Software Foundation, Inc.
+# Originally written by Fran,cois Pinard <pinard@iro.umontreal.ca>, 1996.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+# As a special exception to the GNU General Public License, if you
+# distribute this file as part of a program that contains a
+# configuration script generated by Autoconf, you may include it under
+# the same distribution terms that you use for the rest of that program.
+
+if test $# -eq 0; then
+ echo 1>&2 "Try '$0 --help' for more information"
+ exit 1
+fi
+
+case $1 in
+
+ --is-lightweight)
+ # Used by our autoconf macros to check whether the available missing
+ # script is modern enough.
+ exit 0
+ ;;
+
+ --run)
+ # Back-compat with the calling convention used by older automake.
+ shift
+ ;;
+
+ -h|--h|--he|--hel|--help)
+ echo "\
+$0 [OPTION]... PROGRAM [ARGUMENT]...
+
+Run 'PROGRAM [ARGUMENT]...', returning a proper advice when this fails due
+to PROGRAM being missing or too old.
+
+Options:
+ -h, --help display this help and exit
+ -v, --version output version information and exit
+
+Supported PROGRAM values:
+ aclocal autoconf autoheader autom4te automake makeinfo
+ bison yacc flex lex help2man
+
+Version suffixes to PROGRAM as well as the prefixes 'gnu-', 'gnu', and
+'g' are ignored when checking the name.
+
+Send bug reports to <bug-automake@gnu.org>."
+ exit $?
+ ;;
+
+ -v|--v|--ve|--ver|--vers|--versi|--versio|--version)
+ echo "missing $scriptversion (GNU Automake)"
+ exit $?
+ ;;
+
+ -*)
+ echo 1>&2 "$0: unknown '$1' option"
+ echo 1>&2 "Try '$0 --help' for more information"
+ exit 1
+ ;;
+
+esac
+
+# Run the given program, remember its exit status.
+"$@"; st=$?
+
+# If it succeeded, we are done.
+test $st -eq 0 && exit 0
+
+# Also exit now if we it failed (or wasn't found), and '--version' was
+# passed; such an option is passed most likely to detect whether the
+# program is present and works.
+case $2 in --version|--help) exit $st;; esac
+
+# Exit code 63 means version mismatch. This often happens when the user
+# tries to use an ancient version of a tool on a file that requires a
+# minimum version.
+if test $st -eq 63; then
+ msg="probably too old"
+elif test $st -eq 127; then
+ # Program was missing.
+ msg="missing on your system"
+else
+ # Program was found and executed, but failed. Give up.
+ exit $st
+fi
+
+perl_URL=http://www.perl.org/
+flex_URL=http://flex.sourceforge.net/
+gnu_software_URL=http://www.gnu.org/software
+
+program_details ()
+{
+ case $1 in
+ aclocal|automake)
+ echo "The '$1' program is part of the GNU Automake package:"
+ echo "<$gnu_software_URL/automake>"
+ echo "It also requires GNU Autoconf, GNU m4 and Perl in order to run:"
+ echo "<$gnu_software_URL/autoconf>"
+ echo "<$gnu_software_URL/m4/>"
+ echo "<$perl_URL>"
+ ;;
+ autoconf|autom4te|autoheader)
+ echo "The '$1' program is part of the GNU Autoconf package:"
+ echo "<$gnu_software_URL/autoconf/>"
+ echo "It also requires GNU m4 and Perl in order to run:"
+ echo "<$gnu_software_URL/m4/>"
+ echo "<$perl_URL>"
+ ;;
+ esac
+}
+
+give_advice ()
+{
+ # Normalize program name to check for.
+ normalized_program=`echo "$1" | sed '
+ s/^gnu-//; t
+ s/^gnu//; t
+ s/^g//; t'`
+
+ printf '%s\n' "'$1' is $msg."
+
+ configure_deps="'configure.ac' or m4 files included by 'configure.ac'"
+ case $normalized_program in
+ autoconf*)
+ echo "You should only need it if you modified 'configure.ac',"
+ echo "or m4 files included by it."
+ program_details 'autoconf'
+ ;;
+ autoheader*)
+ echo "You should only need it if you modified 'acconfig.h' or"
+ echo "$configure_deps."
+ program_details 'autoheader'
+ ;;
+ automake*)
+ echo "You should only need it if you modified 'Makefile.am' or"
+ echo "$configure_deps."
+ program_details 'automake'
+ ;;
+ aclocal*)
+ echo "You should only need it if you modified 'acinclude.m4' or"
+ echo "$configure_deps."
+ program_details 'aclocal'
+ ;;
+ autom4te*)
+ echo "You might have modified some maintainer files that require"
+ echo "the 'automa4te' program to be rebuilt."
+ program_details 'autom4te'
+ ;;
+ bison*|yacc*)
+ echo "You should only need it if you modified a '.y' file."
+ echo "You may want to install the GNU Bison package:"
+ echo "<$gnu_software_URL/bison/>"
+ ;;
+ lex*|flex*)
+ echo "You should only need it if you modified a '.l' file."
+ echo "You may want to install the Fast Lexical Analyzer package:"
+ echo "<$flex_URL>"
+ ;;
+ help2man*)
+ echo "You should only need it if you modified a dependency" \
+ "of a man page."
+ echo "You may want to install the GNU Help2man package:"
+ echo "<$gnu_software_URL/help2man/>"
+ ;;
+ makeinfo*)
+ echo "You should only need it if you modified a '.texi' file, or"
+ echo "any other file indirectly affecting the aspect of the manual."
+ echo "You might want to install the Texinfo package:"
+ echo "<$gnu_software_URL/texinfo/>"
+ echo "The spurious makeinfo call might also be the consequence of"
+ echo "using a buggy 'make' (AIX, DU, IRIX), in which case you might"
+ echo "want to install GNU make:"
+ echo "<$gnu_software_URL/make/>"
+ ;;
+ *)
+ echo "You might have modified some files without having the proper"
+ echo "tools for further handling them. Check the 'README' file, it"
+ echo "often tells you about the needed prerequisites for installing"
+ echo "this package. You may also peek at any GNU archive site, in"
+ echo "case some other package contains this missing '$1' program."
+ ;;
+ esac
+}
+
+give_advice "$1" | sed -e '1s/^/WARNING: /' \
+ -e '2,$s/^/ /' >&2
+
+# Propagate the correct exit status (expected to be 127 for a program
+# not found, 63 for a program that failed due to version mismatch).
+exit $st
+
+# Local variables:
+# eval: (add-hook 'write-file-hooks 'time-stamp)
+# time-stamp-start: "scriptversion="
+# time-stamp-format: "%:y-%02m-%02d.%02H"
+# time-stamp-time-zone: "UTC"
+# time-stamp-end: "; # UTC"
+# End:
diff --git a/jni/ruby/ext/fiddle/libffi-3.2.1/msvcc.sh b/jni/ruby/ext/fiddle/libffi-3.2.1/msvcc.sh
new file mode 100755
index 0000000..65fbfef
--- /dev/null
+++ b/jni/ruby/ext/fiddle/libffi-3.2.1/msvcc.sh
@@ -0,0 +1,257 @@
+#!/bin/sh
+
+# ***** BEGIN LICENSE BLOCK *****
+# Version: MPL 1.1/GPL 2.0/LGPL 2.1
+#
+# The contents of this file are subject to the Mozilla Public License Version
+# 1.1 (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+# http://www.mozilla.org/MPL/
+#
+# Software distributed under the License is distributed on an "AS IS" basis,
+# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+# for the specific language governing rights and limitations under the
+# License.
+#
+# The Original Code is the MSVC wrappificator.
+#
+# The Initial Developer of the Original Code is
+# Timothy Wall <twalljava@dev.java.net>.
+# Portions created by the Initial Developer are Copyright (C) 2009
+# the Initial Developer. All Rights Reserved.
+#
+# Contributor(s):
+# Daniel Witte <dwitte@mozilla.com>
+#
+# Alternatively, the contents of this file may be used under the terms of
+# either the GNU General Public License Version 2 or later (the "GPL"), or
+# the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+# in which case the provisions of the GPL or the LGPL are applicable instead
+# of those above. If you wish to allow use of your version of this file only
+# under the terms of either the GPL or the LGPL, and not to allow others to
+# use your version of this file under the terms of the MPL, indicate your
+# decision by deleting the provisions above and replace them with the notice
+# and other provisions required by the GPL or the LGPL. If you do not delete
+# the provisions above, a recipient may use your version of this file under
+# the terms of any one of the MPL, the GPL or the LGPL.
+#
+# ***** END LICENSE BLOCK *****
+
+#
+# GCC-compatible wrapper for cl.exe and ml.exe. Arguments are given in GCC
+# format and translated into something sensible for cl or ml.
+#
+
+args_orig=$@
+args="-nologo -W3"
+static_crt=
+debug_crt=
+cl="cl"
+ml="ml"
+safeseh="-safeseh"
+output=
+
+while [ $# -gt 0 ]
+do
+ case $1
+ in
+ -fexceptions)
+ # Don't enable exceptions for now.
+ #args="$args -EHac"
+ shift 1
+ ;;
+ -m32)
+ shift 1
+ ;;
+ -m64)
+ ml="ml64" # "$MSVC/x86_amd64/ml64"
+ safeseh=
+ shift 1
+ ;;
+ -clang-cl)
+ cl="clang-cl"
+ safeseh=
+ shift 1
+ ;;
+ -O0)
+ args="$args -Od"
+ shift 1
+ ;;
+ -O*)
+ # Runtime error checks (enabled by setting -RTC1 in the -DFFI_DEBUG
+ # case below) are not compatible with optimization flags and will
+ # cause the build to fail. Therefore, drop the optimization flag if
+ # -DFFI_DEBUG is also set.
+ case $args_orig in
+ *-DFFI_DEBUG*)
+ args="$args"
+ ;;
+ *)
+ # The ax_cc_maxopt.m4 macro from the upstream autoconf-archive
+ # project doesn't support MSVC and therefore ends up trying to
+ # use -O3. Use the equivalent "max optimization" flag for MSVC
+ # instead of erroring out.
+ case $1 in
+ -O3)
+ args="$args -O2"
+ ;;
+ *)
+ args="$args $1"
+ ;;
+ esac
+ opt="true"
+ ;;
+ esac
+ shift 1
+ ;;
+ -g)
+ # Enable debug symbol generation.
+ args="$args -Zi"
+ shift 1
+ ;;
+ -DFFI_DEBUG)
+ # Enable runtime error checks.
+ args="$args -RTC1"
+ defines="$defines $1"
+ shift 1
+ ;;
+ -DUSE_STATIC_RTL)
+ # Link against static CRT.
+ static_crt=1
+ shift 1
+ ;;
+ -DUSE_DEBUG_RTL)
+ # Link against debug CRT.
+ debug_crt=1
+ shift 1
+ ;;
+ -c)
+ args="$args -c"
+ args="$(echo $args | sed 's%/Fe%/Fo%g')"
+ single="-c"
+ shift 1
+ ;;
+ -D*=*)
+ name="$(echo $1|sed 's/-D\([^=][^=]*\)=.*/\1/g')"
+ value="$(echo $1|sed 's/-D[^=][^=]*=//g')"
+ args="$args -D${name}='$value'"
+ defines="$defines -D${name}='$value'"
+ shift 1
+ ;;
+ -D*)
+ args="$args $1"
+ defines="$defines $1"
+ shift 1
+ ;;
+ -I)
+ args="$args -I$2"
+ includes="$includes -I$2"
+ shift 2
+ ;;
+ -I*)
+ args="$args $1"
+ includes="$includes $1"
+ shift 1
+ ;;
+ -W|-Wextra)
+ # TODO map extra warnings
+ shift 1
+ ;;
+ -Wall)
+ # -Wall on MSVC is overzealous, and we already build with -W3. Nothing
+ # to do here.
+ shift 1
+ ;;
+ -pedantic)
+ # libffi tests -pedantic with -Wall, so drop it also.
+ shift 1
+ ;;
+ -Werror)
+ args="$args -WX"
+ shift 1
+ ;;
+ -W*)
+ # TODO map specific warnings
+ shift 1
+ ;;
+ -S)
+ args="$args -FAs"
+ shift 1
+ ;;
+ -o)
+ outdir="$(dirname $2)"
+ base="$(basename $2|sed 's/\.[^.]*//g')"
+ if [ -n "$single" ]; then
+ output="-Fo$2"
+ else
+ output="-Fe$2"
+ fi
+ if [ -n "$assembly" ]; then
+ args="$args $output"
+ else
+ args="$args $output -Fd$outdir/$base -Fp$outdir/$base -Fa$outdir/$base"
+ fi
+ shift 2
+ ;;
+ *.S)
+ src=$1
+ assembly="true"
+ shift 1
+ ;;
+ *.c)
+ args="$args $1"
+ shift 1
+ ;;
+ *)
+ # Assume it's an MSVC argument, and pass it through.
+ args="$args $1"
+ shift 1
+ ;;
+ esac
+done
+
+# If -Zi is specified, certain optimizations are implicitly disabled
+# by MSVC. Add back those optimizations if this is an optimized build.
+# NOTE: These arguments must come after all others.
+if [ -n "$opt" ]; then
+ args="$args -link -OPT:REF -OPT:ICF -INCREMENTAL:NO"
+fi
+
+if [ -n "$static_crt" ]; then
+ md=-MT
+else
+ md=-MD
+fi
+
+if [ -n "$debug_crt" ]; then
+ md="${md}d"
+fi
+
+if [ -n "$assembly" ]; then
+ if [ -z "$outdir" ]; then
+ outdir="."
+ fi
+ ppsrc="$outdir/$(basename $src|sed 's/.S$/.asm/g')"
+ echo "$cl -nologo -EP $includes $defines $src > $ppsrc"
+ "$cl" -nologo -EP $includes $defines $src > $ppsrc || exit $?
+ output="$(echo $output | sed 's%/F[dpa][^ ]*%%g')"
+ args="-nologo $safeseh $single $output $ppsrc"
+
+ echo "$ml $args"
+ eval "\"$ml\" $args"
+ result=$?
+
+ # required to fix ml64 broken output?
+ #mv *.obj $outdir
+else
+ args="$md $args"
+ echo "$cl $args"
+ # Return an error code of 1 if an invalid command line parameter is passed
+ # instead of just ignoring it.
+ eval "(\"$cl\" $args 2>&1 1>&3 | \
+ awk '{print \$0} /D9002/ {error=1} END{exit error}' >&2) 3>&1"
+ result=$?
+fi
+
+exit $result
+
diff --git a/jni/ruby/ext/fiddle/libffi-3.2.1/src/aarch64/ffi.c b/jni/ruby/ext/fiddle/libffi-3.2.1/src/aarch64/ffi.c
new file mode 100644
index 0000000..cdb7816
--- /dev/null
+++ b/jni/ruby/ext/fiddle/libffi-3.2.1/src/aarch64/ffi.c
@@ -0,0 +1,1179 @@
+/* Copyright (c) 2009, 2010, 2011, 2012 ARM Ltd.
+
+Permission is hereby granted, free of charge, to any person obtaining
+a copy of this software and associated documentation files (the
+``Software''), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sublicense, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice shall be
+included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
+
+#include <stdio.h>
+
+#include <ffi.h>
+#include <ffi_common.h>
+
+#include <stdlib.h>
+
+/* Stack alignment requirement in bytes */
+#if defined (__APPLE__)
+#define AARCH64_STACK_ALIGN 1
+#else
+#define AARCH64_STACK_ALIGN 16
+#endif
+
+#define N_X_ARG_REG 8
+#define N_V_ARG_REG 8
+
+#define AARCH64_FFI_WITH_V (1 << AARCH64_FFI_WITH_V_BIT)
+
+union _d
+{
+ UINT64 d;
+ UINT32 s[2];
+};
+
+struct call_context
+{
+ UINT64 x [AARCH64_N_XREG];
+ struct
+ {
+ union _d d[2];
+ } v [AARCH64_N_VREG];
+};
+
+#if defined (__clang__) && defined (__APPLE__)
+extern void
+sys_icache_invalidate (void *start, size_t len);
+#endif
+
+static inline void
+ffi_clear_cache (void *start, void *end)
+{
+#if defined (__clang__) && defined (__APPLE__)
+ sys_icache_invalidate (start, (char *)end - (char *)start);
+#elif defined (__GNUC__)
+ __builtin___clear_cache (start, end);
+#else
+#error "Missing builtin to flush instruction cache"
+#endif
+}
+
+static void *
+get_x_addr (struct call_context *context, unsigned n)
+{
+ return &context->x[n];
+}
+
+static void *
+get_s_addr (struct call_context *context, unsigned n)
+{
+#if defined __AARCH64EB__
+ return &context->v[n].d[1].s[1];
+#else
+ return &context->v[n].d[0].s[0];
+#endif
+}
+
+static void *
+get_d_addr (struct call_context *context, unsigned n)
+{
+#if defined __AARCH64EB__
+ return &context->v[n].d[1];
+#else
+ return &context->v[n].d[0];
+#endif
+}
+
+static void *
+get_v_addr (struct call_context *context, unsigned n)
+{
+ return &context->v[n];
+}
+
+/* Return the memory location at which a basic type would reside
+ were it to have been stored in register n. */
+
+static void *
+get_basic_type_addr (unsigned short type, struct call_context *context,
+ unsigned n)
+{
+ switch (type)
+ {
+ case FFI_TYPE_FLOAT:
+ return get_s_addr (context, n);
+ case FFI_TYPE_DOUBLE:
+ return get_d_addr (context, n);
+#if FFI_TYPE_DOUBLE != FFI_TYPE_LONGDOUBLE
+ case FFI_TYPE_LONGDOUBLE:
+ return get_v_addr (context, n);
+#endif
+ case FFI_TYPE_UINT8:
+ case FFI_TYPE_SINT8:
+ case FFI_TYPE_UINT16:
+ case FFI_TYPE_SINT16:
+ case FFI_TYPE_UINT32:
+ case FFI_TYPE_SINT32:
+ case FFI_TYPE_INT:
+ case FFI_TYPE_POINTER:
+ case FFI_TYPE_UINT64:
+ case FFI_TYPE_SINT64:
+ return get_x_addr (context, n);
+ case FFI_TYPE_VOID:
+ return NULL;
+ default:
+ FFI_ASSERT (0);
+ return NULL;
+ }
+}
+
+/* Return the alignment width for each of the basic types. */
+
+static size_t
+get_basic_type_alignment (unsigned short type)
+{
+ switch (type)
+ {
+ case FFI_TYPE_FLOAT:
+#if defined (__APPLE__)
+ return sizeof (UINT32);
+#endif
+ case FFI_TYPE_DOUBLE:
+ return sizeof (UINT64);
+#if FFI_TYPE_DOUBLE != FFI_TYPE_LONGDOUBLE
+ case FFI_TYPE_LONGDOUBLE:
+ return sizeof (long double);
+#endif
+ case FFI_TYPE_UINT8:
+ case FFI_TYPE_SINT8:
+#if defined (__APPLE__)
+ return sizeof (UINT8);
+#endif
+ case FFI_TYPE_UINT16:
+ case FFI_TYPE_SINT16:
+#if defined (__APPLE__)
+ return sizeof (UINT16);
+#endif
+ case FFI_TYPE_UINT32:
+ case FFI_TYPE_INT:
+ case FFI_TYPE_SINT32:
+#if defined (__APPLE__)
+ return sizeof (UINT32);
+#endif
+ case FFI_TYPE_POINTER:
+ case FFI_TYPE_UINT64:
+ case FFI_TYPE_SINT64:
+ return sizeof (UINT64);
+
+ default:
+ FFI_ASSERT (0);
+ return 0;
+ }
+}
+
+/* Return the size in bytes for each of the basic types. */
+
+static size_t
+get_basic_type_size (unsigned short type)
+{
+ switch (type)
+ {
+ case FFI_TYPE_FLOAT:
+ return sizeof (UINT32);
+ case FFI_TYPE_DOUBLE:
+ return sizeof (UINT64);
+#if FFI_TYPE_DOUBLE != FFI_TYPE_LONGDOUBLE
+ case FFI_TYPE_LONGDOUBLE:
+ return sizeof (long double);
+#endif
+ case FFI_TYPE_UINT8:
+ return sizeof (UINT8);
+ case FFI_TYPE_SINT8:
+ return sizeof (SINT8);
+ case FFI_TYPE_UINT16:
+ return sizeof (UINT16);
+ case FFI_TYPE_SINT16:
+ return sizeof (SINT16);
+ case FFI_TYPE_UINT32:
+ return sizeof (UINT32);
+ case FFI_TYPE_INT:
+ case FFI_TYPE_SINT32:
+ return sizeof (SINT32);
+ case FFI_TYPE_POINTER:
+ case FFI_TYPE_UINT64:
+ return sizeof (UINT64);
+ case FFI_TYPE_SINT64:
+ return sizeof (SINT64);
+
+ default:
+ FFI_ASSERT (0);
+ return 0;
+ }
+}
+
+extern void
+ffi_call_SYSV (unsigned (*)(struct call_context *context, unsigned char *,
+ extended_cif *),
+ struct call_context *context,
+ extended_cif *,
+ size_t,
+ void (*fn)(void));
+
+extern void
+ffi_closure_SYSV (ffi_closure *);
+
+/* Test for an FFI floating point representation. */
+
+static unsigned
+is_floating_type (unsigned short type)
+{
+ return (type == FFI_TYPE_FLOAT || type == FFI_TYPE_DOUBLE
+ || type == FFI_TYPE_LONGDOUBLE);
+}
+
+/* Test for a homogeneous structure. */
+
+static unsigned short
+get_homogeneous_type (ffi_type *ty)
+{
+ if (ty->type == FFI_TYPE_STRUCT && ty->elements)
+ {
+ unsigned i;
+ unsigned short candidate_type
+ = get_homogeneous_type (ty->elements[0]);
+ for (i =1; ty->elements[i]; i++)
+ {
+ unsigned short iteration_type = 0;
+ /* If we have a nested struct, we must find its homogeneous type.
+ If that fits with our candidate type, we are still
+ homogeneous. */
+ if (ty->elements[i]->type == FFI_TYPE_STRUCT
+ && ty->elements[i]->elements)
+ {
+ iteration_type = get_homogeneous_type (ty->elements[i]);
+ }
+ else
+ {
+ iteration_type = ty->elements[i]->type;
+ }
+
+ /* If we are not homogeneous, return FFI_TYPE_STRUCT. */
+ if (candidate_type != iteration_type)
+ return FFI_TYPE_STRUCT;
+ }
+ return candidate_type;
+ }
+
+ /* Base case, we have no more levels of nesting, so we
+ are a basic type, and so, trivially homogeneous in that type. */
+ return ty->type;
+}
+
+/* Determine the number of elements within a STRUCT.
+
+ Note, we must handle nested structs.
+
+ If ty is not a STRUCT this function will return 0. */
+
+static unsigned
+element_count (ffi_type *ty)
+{
+ if (ty->type == FFI_TYPE_STRUCT && ty->elements)
+ {
+ unsigned n;
+ unsigned elems = 0;
+ for (n = 0; ty->elements[n]; n++)
+ {
+ if (ty->elements[n]->type == FFI_TYPE_STRUCT
+ && ty->elements[n]->elements)
+ elems += element_count (ty->elements[n]);
+ else
+ elems++;
+ }
+ return elems;
+ }
+ return 0;
+}
+
+/* Test for a homogeneous floating point aggregate.
+
+ A homogeneous floating point aggregate is a homogeneous aggregate of
+ a half- single- or double- precision floating point type with one
+ to four elements. Note that this includes nested structs of the
+ basic type. */
+
+static int
+is_hfa (ffi_type *ty)
+{
+ if (ty->type == FFI_TYPE_STRUCT
+ && ty->elements[0]
+ && is_floating_type (get_homogeneous_type (ty)))
+ {
+ unsigned n = element_count (ty);
+ return n >= 1 && n <= 4;
+ }
+ return 0;
+}
+
+/* Test if an ffi_type is a candidate for passing in a register.
+
+ This test does not check that sufficient registers of the
+ appropriate class are actually available, merely that IFF
+ sufficient registers are available then the argument will be passed
+ in register(s).
+
+ Note that an ffi_type that is deemed to be a register candidate
+ will always be returned in registers.
+
+ Returns 1 if a register candidate else 0. */
+
+static int
+is_register_candidate (ffi_type *ty)
+{
+ switch (ty->type)
+ {
+ case FFI_TYPE_VOID:
+ case FFI_TYPE_FLOAT:
+ case FFI_TYPE_DOUBLE:
+#if FFI_TYPE_DOUBLE != FFI_TYPE_LONGDOUBLE
+ case FFI_TYPE_LONGDOUBLE:
+#endif
+ case FFI_TYPE_UINT8:
+ case FFI_TYPE_UINT16:
+ case FFI_TYPE_UINT32:
+ case FFI_TYPE_UINT64:
+ case FFI_TYPE_POINTER:
+ case FFI_TYPE_SINT8:
+ case FFI_TYPE_SINT16:
+ case FFI_TYPE_SINT32:
+ case FFI_TYPE_INT:
+ case FFI_TYPE_SINT64:
+ return 1;
+
+ case FFI_TYPE_STRUCT:
+ if (is_hfa (ty))
+ {
+ return 1;
+ }
+ else if (ty->size > 16)
+ {
+ /* Too large. Will be replaced with a pointer to memory. The
+ pointer MAY be passed in a register, but the value will
+ not. This test specifically fails since the argument will
+ never be passed by value in registers. */
+ return 0;
+ }
+ else
+ {
+ /* Might be passed in registers depending on the number of
+ registers required. */
+ return (ty->size + 7) / 8 < N_X_ARG_REG;
+ }
+ break;
+
+ default:
+ FFI_ASSERT (0);
+ break;
+ }
+
+ return 0;
+}
+
+/* Test if an ffi_type argument or result is a candidate for a vector
+ register. */
+
+static int
+is_v_register_candidate (ffi_type *ty)
+{
+ return is_floating_type (ty->type)
+ || (ty->type == FFI_TYPE_STRUCT && is_hfa (ty));
+}
+
+/* Representation of the procedure call argument marshalling
+ state.
+
+ The terse state variable names match the names used in the AARCH64
+ PCS. */
+
+struct arg_state
+{
+ unsigned ngrn; /* Next general-purpose register number. */
+ unsigned nsrn; /* Next vector register number. */
+ size_t nsaa; /* Next stack offset. */
+
+#if defined (__APPLE__)
+ unsigned allocating_variadic;
+#endif
+};
+
+/* Initialize a procedure call argument marshalling state. */
+static void
+arg_init (struct arg_state *state, size_t call_frame_size)
+{
+ state->ngrn = 0;
+ state->nsrn = 0;
+ state->nsaa = 0;
+
+#if defined (__APPLE__)
+ state->allocating_variadic = 0;
+#endif
+}
+
+/* Return the number of available consecutive core argument
+ registers. */
+
+static unsigned
+available_x (struct arg_state *state)
+{
+ return N_X_ARG_REG - state->ngrn;
+}
+
+/* Return the number of available consecutive vector argument
+ registers. */
+
+static unsigned
+available_v (struct arg_state *state)
+{
+ return N_V_ARG_REG - state->nsrn;
+}
+
+static void *
+allocate_to_x (struct call_context *context, struct arg_state *state)
+{
+ FFI_ASSERT (state->ngrn < N_X_ARG_REG);
+ return get_x_addr (context, (state->ngrn)++);
+}
+
+static void *
+allocate_to_s (struct call_context *context, struct arg_state *state)
+{
+ FFI_ASSERT (state->nsrn < N_V_ARG_REG);
+ return get_s_addr (context, (state->nsrn)++);
+}
+
+static void *
+allocate_to_d (struct call_context *context, struct arg_state *state)
+{
+ FFI_ASSERT (state->nsrn < N_V_ARG_REG);
+ return get_d_addr (context, (state->nsrn)++);
+}
+
+static void *
+allocate_to_v (struct call_context *context, struct arg_state *state)
+{
+ FFI_ASSERT (state->nsrn < N_V_ARG_REG);
+ return get_v_addr (context, (state->nsrn)++);
+}
+
+/* Allocate an aligned slot on the stack and return a pointer to it. */
+static void *
+allocate_to_stack (struct arg_state *state, void *stack, size_t alignment,
+ size_t size)
+{
+ void *allocation;
+
+ /* Round up the NSAA to the larger of 8 or the natural
+ alignment of the argument's type. */
+ state->nsaa = ALIGN (state->nsaa, alignment);
+ state->nsaa = ALIGN (state->nsaa, alignment);
+#if defined (__APPLE__)
+ if (state->allocating_variadic)
+ state->nsaa = ALIGN (state->nsaa, 8);
+#else
+ state->nsaa = ALIGN (state->nsaa, 8);
+#endif
+
+ allocation = stack + state->nsaa;
+
+ state->nsaa += size;
+ return allocation;
+}
+
+static void
+copy_basic_type (void *dest, void *source, unsigned short type)
+{
+ /* This is necessary to ensure that basic types are copied
+ sign extended to 64-bits as libffi expects. */
+ switch (type)
+ {
+ case FFI_TYPE_FLOAT:
+ *(float *) dest = *(float *) source;
+ break;
+ case FFI_TYPE_DOUBLE:
+ *(double *) dest = *(double *) source;
+ break;
+#if FFI_TYPE_DOUBLE != FFI_TYPE_LONGDOUBLE
+ case FFI_TYPE_LONGDOUBLE:
+ *(long double *) dest = *(long double *) source;
+ break;
+#endif
+ case FFI_TYPE_UINT8:
+ *(ffi_arg *) dest = *(UINT8 *) source;
+ break;
+ case FFI_TYPE_SINT8:
+ *(ffi_sarg *) dest = *(SINT8 *) source;
+ break;
+ case FFI_TYPE_UINT16:
+ *(ffi_arg *) dest = *(UINT16 *) source;
+ break;
+ case FFI_TYPE_SINT16:
+ *(ffi_sarg *) dest = *(SINT16 *) source;
+ break;
+ case FFI_TYPE_UINT32:
+ *(ffi_arg *) dest = *(UINT32 *) source;
+ break;
+ case FFI_TYPE_INT:
+ case FFI_TYPE_SINT32:
+ *(ffi_sarg *) dest = *(SINT32 *) source;
+ break;
+ case FFI_TYPE_POINTER:
+ case FFI_TYPE_UINT64:
+ *(ffi_arg *) dest = *(UINT64 *) source;
+ break;
+ case FFI_TYPE_SINT64:
+ *(ffi_sarg *) dest = *(SINT64 *) source;
+ break;
+ case FFI_TYPE_VOID:
+ break;
+
+ default:
+ FFI_ASSERT (0);
+ }
+}
+
+static void
+copy_hfa_to_reg_or_stack (void *memory,
+ ffi_type *ty,
+ struct call_context *context,
+ unsigned char *stack,
+ struct arg_state *state)
+{
+ unsigned elems = element_count (ty);
+ if (available_v (state) < elems)
+ {
+ /* There are insufficient V registers. Further V register allocations
+ are prevented, the NSAA is adjusted (by allocate_to_stack ())
+ and the argument is copied to memory at the adjusted NSAA. */
+ state->nsrn = N_V_ARG_REG;
+ memcpy (allocate_to_stack (state, stack, ty->alignment, ty->size),
+ memory,
+ ty->size);
+ }
+ else
+ {
+ int i;
+ unsigned short type = get_homogeneous_type (ty);
+ for (i = 0; i < elems; i++)
+ {
+ void *reg = allocate_to_v (context, state);
+ copy_basic_type (reg, memory, type);
+ memory += get_basic_type_size (type);
+ }
+ }
+}
+
+/* Either allocate an appropriate register for the argument type, or if
+ none are available, allocate a stack slot and return a pointer
+ to the allocated space. */
+
+static void *
+allocate_to_register_or_stack (struct call_context *context,
+ unsigned char *stack,
+ struct arg_state *state,
+ unsigned short type)
+{
+ size_t alignment = get_basic_type_alignment (type);
+ size_t size = alignment;
+ switch (type)
+ {
+ case FFI_TYPE_FLOAT:
+ /* This is the only case for which the allocated stack size
+ should not match the alignment of the type. */
+ size = sizeof (UINT32);
+ /* Fall through. */
+ case FFI_TYPE_DOUBLE:
+ if (state->nsrn < N_V_ARG_REG)
+ return allocate_to_d (context, state);
+ state->nsrn = N_V_ARG_REG;
+ break;
+#if FFI_TYPE_DOUBLE != FFI_TYPE_LONGDOUBLE
+ case FFI_TYPE_LONGDOUBLE:
+ if (state->nsrn < N_V_ARG_REG)
+ return allocate_to_v (context, state);
+ state->nsrn = N_V_ARG_REG;
+ break;
+#endif
+ case FFI_TYPE_UINT8:
+ case FFI_TYPE_SINT8:
+ case FFI_TYPE_UINT16:
+ case FFI_TYPE_SINT16:
+ case FFI_TYPE_UINT32:
+ case FFI_TYPE_SINT32:
+ case FFI_TYPE_INT:
+ case FFI_TYPE_POINTER:
+ case FFI_TYPE_UINT64:
+ case FFI_TYPE_SINT64:
+ if (state->ngrn < N_X_ARG_REG)
+ return allocate_to_x (context, state);
+ state->ngrn = N_X_ARG_REG;
+ break;
+ default:
+ FFI_ASSERT (0);
+ }
+
+ return allocate_to_stack (state, stack, alignment, size);
+}
+
+/* Copy a value to an appropriate register, or if none are
+ available, to the stack. */
+
+static void
+copy_to_register_or_stack (struct call_context *context,
+ unsigned char *stack,
+ struct arg_state *state,
+ void *value,
+ unsigned short type)
+{
+ copy_basic_type (
+ allocate_to_register_or_stack (context, stack, state, type),
+ value,
+ type);
+}
+
+/* Marshall the arguments from FFI representation to procedure call
+ context and stack. */
+
+static unsigned
+aarch64_prep_args (struct call_context *context, unsigned char *stack,
+ extended_cif *ecif)
+{
+ int i;
+ struct arg_state state;
+
+ arg_init (&state, ALIGN(ecif->cif->bytes, 16));
+
+ for (i = 0; i < ecif->cif->nargs; i++)
+ {
+ ffi_type *ty = ecif->cif->arg_types[i];
+ switch (ty->type)
+ {
+ case FFI_TYPE_VOID:
+ FFI_ASSERT (0);
+ break;
+
+ /* If the argument is a basic type the argument is allocated to an
+ appropriate register, or if none are available, to the stack. */
+ case FFI_TYPE_FLOAT:
+ case FFI_TYPE_DOUBLE:
+#if FFI_TYPE_DOUBLE != FFI_TYPE_LONGDOUBLE
+ case FFI_TYPE_LONGDOUBLE:
+#endif
+ case FFI_TYPE_UINT8:
+ case FFI_TYPE_SINT8:
+ case FFI_TYPE_UINT16:
+ case FFI_TYPE_SINT16:
+ case FFI_TYPE_UINT32:
+ case FFI_TYPE_INT:
+ case FFI_TYPE_SINT32:
+ case FFI_TYPE_POINTER:
+ case FFI_TYPE_UINT64:
+ case FFI_TYPE_SINT64:
+ copy_to_register_or_stack (context, stack, &state,
+ ecif->avalue[i], ty->type);
+ break;
+
+ case FFI_TYPE_STRUCT:
+ if (is_hfa (ty))
+ {
+ copy_hfa_to_reg_or_stack (ecif->avalue[i], ty, context,
+ stack, &state);
+ }
+ else if (ty->size > 16)
+ {
+ /* If the argument is a composite type that is larger than 16
+ bytes, then the argument has been copied to memory, and
+ the argument is replaced by a pointer to the copy. */
+
+ copy_to_register_or_stack (context, stack, &state,
+ &(ecif->avalue[i]), FFI_TYPE_POINTER);
+ }
+ else if (available_x (&state) >= (ty->size + 7) / 8)
+ {
+ /* If the argument is a composite type and the size in
+ double-words is not more than the number of available
+ X registers, then the argument is copied into consecutive
+ X registers. */
+ int j;
+ for (j = 0; j < (ty->size + 7) / 8; j++)
+ {
+ memcpy (allocate_to_x (context, &state),
+ &(((UINT64 *) ecif->avalue[i])[j]),
+ sizeof (UINT64));
+ }
+ }
+ else
+ {
+ /* Otherwise, there are insufficient X registers. Further X
+ register allocations are prevented, the NSAA is adjusted
+ (by allocate_to_stack ()) and the argument is copied to
+ memory at the adjusted NSAA. */
+ state.ngrn = N_X_ARG_REG;
+
+ memcpy (allocate_to_stack (&state, stack, ty->alignment,
+ ty->size), ecif->avalue + i, ty->size);
+ }
+ break;
+
+ default:
+ FFI_ASSERT (0);
+ break;
+ }
+
+#if defined (__APPLE__)
+ if (i + 1 == ecif->cif->aarch64_nfixedargs)
+ {
+ state.ngrn = N_X_ARG_REG;
+ state.nsrn = N_V_ARG_REG;
+
+ state.allocating_variadic = 1;
+ }
+#endif
+ }
+
+ return ecif->cif->aarch64_flags;
+}
+
+ffi_status
+ffi_prep_cif_machdep (ffi_cif *cif)
+{
+ /* Round the stack up to a multiple of the stack alignment requirement. */
+ cif->bytes =
+ (cif->bytes + (AARCH64_STACK_ALIGN - 1)) & ~ (AARCH64_STACK_ALIGN - 1);
+
+ /* Initialize our flags. We are interested if this CIF will touch a
+ vector register, if so we will enable context save and load to
+ those registers, otherwise not. This is intended to be friendly
+ to lazy float context switching in the kernel. */
+ cif->aarch64_flags = 0;
+
+ if (is_v_register_candidate (cif->rtype))
+ {
+ cif->aarch64_flags |= AARCH64_FFI_WITH_V;
+ }
+ else
+ {
+ int i;
+ for (i = 0; i < cif->nargs; i++)
+ if (is_v_register_candidate (cif->arg_types[i]))
+ {
+ cif->aarch64_flags |= AARCH64_FFI_WITH_V;
+ break;
+ }
+ }
+
+#if defined (__APPLE__)
+ cif->aarch64_nfixedargs = 0;
+#endif
+
+ return FFI_OK;
+}
+
+#if defined (__APPLE__)
+
+/* Perform Apple-specific cif processing for variadic calls */
+ffi_status ffi_prep_cif_machdep_var(ffi_cif *cif,
+ unsigned int nfixedargs,
+ unsigned int ntotalargs)
+{
+ ffi_status status;
+
+ status = ffi_prep_cif_machdep (cif);
+
+ cif->aarch64_nfixedargs = nfixedargs;
+
+ return status;
+}
+
+#endif
+
+/* Call a function with the provided arguments and capture the return
+ value. */
+void
+ffi_call (ffi_cif *cif, void (*fn)(void), void *rvalue, void **avalue)
+{
+ extended_cif ecif;
+
+ ecif.cif = cif;
+ ecif.avalue = avalue;
+ ecif.rvalue = rvalue;
+
+ switch (cif->abi)
+ {
+ case FFI_SYSV:
+ {
+ struct call_context context;
+ size_t stack_bytes;
+
+ /* Figure out the total amount of stack space we need, the
+ above call frame space needs to be 16 bytes aligned to
+ ensure correct alignment of the first object inserted in
+ that space hence the ALIGN applied to cif->bytes.*/
+ stack_bytes = ALIGN(cif->bytes, 16);
+
+ memset (&context, 0, sizeof (context));
+ if (is_register_candidate (cif->rtype))
+ {
+ ffi_call_SYSV (aarch64_prep_args, &context, &ecif, stack_bytes, fn);
+ switch (cif->rtype->type)
+ {
+ case FFI_TYPE_VOID:
+ case FFI_TYPE_FLOAT:
+ case FFI_TYPE_DOUBLE:
+#if FFI_TYPE_DOUBLE != FFI_TYPE_LONGDOUBLE
+ case FFI_TYPE_LONGDOUBLE:
+#endif
+ case FFI_TYPE_UINT8:
+ case FFI_TYPE_SINT8:
+ case FFI_TYPE_UINT16:
+ case FFI_TYPE_SINT16:
+ case FFI_TYPE_UINT32:
+ case FFI_TYPE_SINT32:
+ case FFI_TYPE_POINTER:
+ case FFI_TYPE_UINT64:
+ case FFI_TYPE_INT:
+ case FFI_TYPE_SINT64:
+ {
+ void *addr = get_basic_type_addr (cif->rtype->type,
+ &context, 0);
+ copy_basic_type (rvalue, addr, cif->rtype->type);
+ break;
+ }
+
+ case FFI_TYPE_STRUCT:
+ if (is_hfa (cif->rtype))
+ {
+ int j;
+ unsigned short type = get_homogeneous_type (cif->rtype);
+ unsigned elems = element_count (cif->rtype);
+ for (j = 0; j < elems; j++)
+ {
+ void *reg = get_basic_type_addr (type, &context, j);
+ copy_basic_type (rvalue, reg, type);
+ rvalue += get_basic_type_size (type);
+ }
+ }
+ else if ((cif->rtype->size + 7) / 8 < N_X_ARG_REG)
+ {
+ size_t size = ALIGN (cif->rtype->size, sizeof (UINT64));
+ memcpy (rvalue, get_x_addr (&context, 0), size);
+ }
+ else
+ {
+ FFI_ASSERT (0);
+ }
+ break;
+
+ default:
+ FFI_ASSERT (0);
+ break;
+ }
+ }
+ else
+ {
+ memcpy (get_x_addr (&context, 8), &rvalue, sizeof (UINT64));
+ ffi_call_SYSV (aarch64_prep_args, &context, &ecif,
+ stack_bytes, fn);
+ }
+ break;
+ }
+
+ default:
+ FFI_ASSERT (0);
+ break;
+ }
+}
+
+static unsigned char trampoline [] =
+{ 0x70, 0x00, 0x00, 0x58, /* ldr x16, 1f */
+ 0x91, 0x00, 0x00, 0x10, /* adr x17, 2f */
+ 0x00, 0x02, 0x1f, 0xd6 /* br x16 */
+};
+
+/* Build a trampoline. */
+
+#define FFI_INIT_TRAMPOLINE(TRAMP,FUN,CTX,FLAGS) \
+ ({unsigned char *__tramp = (unsigned char*)(TRAMP); \
+ UINT64 __fun = (UINT64)(FUN); \
+ UINT64 __ctx = (UINT64)(CTX); \
+ UINT64 __flags = (UINT64)(FLAGS); \
+ memcpy (__tramp, trampoline, sizeof (trampoline)); \
+ memcpy (__tramp + 12, &__fun, sizeof (__fun)); \
+ memcpy (__tramp + 20, &__ctx, sizeof (__ctx)); \
+ memcpy (__tramp + 28, &__flags, sizeof (__flags)); \
+ ffi_clear_cache(__tramp, __tramp + FFI_TRAMPOLINE_SIZE); \
+ })
+
+ffi_status
+ffi_prep_closure_loc (ffi_closure* closure,
+ ffi_cif* cif,
+ void (*fun)(ffi_cif*,void*,void**,void*),
+ void *user_data,
+ void *codeloc)
+{
+ if (cif->abi != FFI_SYSV)
+ return FFI_BAD_ABI;
+
+ FFI_INIT_TRAMPOLINE (&closure->tramp[0], &ffi_closure_SYSV, codeloc,
+ cif->aarch64_flags);
+
+ closure->cif = cif;
+ closure->user_data = user_data;
+ closure->fun = fun;
+
+ return FFI_OK;
+}
+
+/* Primary handler to setup and invoke a function within a closure.
+
+ A closure when invoked enters via the assembler wrapper
+ ffi_closure_SYSV(). The wrapper allocates a call context on the
+ stack, saves the interesting registers (from the perspective of
+ the calling convention) into the context then passes control to
+ ffi_closure_SYSV_inner() passing the saved context and a pointer to
+ the stack at the point ffi_closure_SYSV() was invoked.
+
+ On the return path the assembler wrapper will reload call context
+ registers.
+
+ ffi_closure_SYSV_inner() marshalls the call context into ffi value
+ descriptors, invokes the wrapped function, then marshalls the return
+ value back into the call context. */
+
+void FFI_HIDDEN
+ffi_closure_SYSV_inner (ffi_closure *closure, struct call_context *context,
+ void *stack)
+{
+ ffi_cif *cif = closure->cif;
+ void **avalue = (void**) alloca (cif->nargs * sizeof (void*));
+ void *rvalue = NULL;
+ int i;
+ struct arg_state state;
+
+ arg_init (&state, ALIGN(cif->bytes, 16));
+
+ for (i = 0; i < cif->nargs; i++)
+ {
+ ffi_type *ty = cif->arg_types[i];
+
+ switch (ty->type)
+ {
+ case FFI_TYPE_VOID:
+ FFI_ASSERT (0);
+ break;
+
+ case FFI_TYPE_UINT8:
+ case FFI_TYPE_SINT8:
+ case FFI_TYPE_UINT16:
+ case FFI_TYPE_SINT16:
+ case FFI_TYPE_UINT32:
+ case FFI_TYPE_SINT32:
+ case FFI_TYPE_INT:
+ case FFI_TYPE_POINTER:
+ case FFI_TYPE_UINT64:
+ case FFI_TYPE_SINT64:
+ case FFI_TYPE_FLOAT:
+ case FFI_TYPE_DOUBLE:
+#if FFI_TYPE_DOUBLE != FFI_TYPE_LONGDOUBLE
+ case FFI_TYPE_LONGDOUBLE:
+ avalue[i] = allocate_to_register_or_stack (context, stack,
+ &state, ty->type);
+ break;
+#endif
+
+ case FFI_TYPE_STRUCT:
+ if (is_hfa (ty))
+ {
+ unsigned n = element_count (ty);
+ if (available_v (&state) < n)
+ {
+ state.nsrn = N_V_ARG_REG;
+ avalue[i] = allocate_to_stack (&state, stack, ty->alignment,
+ ty->size);
+ }
+ else
+ {
+ switch (get_homogeneous_type (ty))
+ {
+ case FFI_TYPE_FLOAT:
+ {
+ /* Eeek! We need a pointer to the structure,
+ however the homogeneous float elements are
+ being passed in individual S registers,
+ therefore the structure is not represented as
+ a contiguous sequence of bytes in our saved
+ register context. We need to fake up a copy
+ of the structure laid out in memory
+ correctly. The fake can be tossed once the
+ closure function has returned hence alloca()
+ is sufficient. */
+ int j;
+ UINT32 *p = avalue[i] = alloca (ty->size);
+ for (j = 0; j < element_count (ty); j++)
+ memcpy (&p[j],
+ allocate_to_s (context, &state),
+ sizeof (*p));
+ break;
+ }
+
+ case FFI_TYPE_DOUBLE:
+ {
+ /* Eeek! We need a pointer to the structure,
+ however the homogeneous float elements are
+ being passed in individual S registers,
+ therefore the structure is not represented as
+ a contiguous sequence of bytes in our saved
+ register context. We need to fake up a copy
+ of the structure laid out in memory
+ correctly. The fake can be tossed once the
+ closure function has returned hence alloca()
+ is sufficient. */
+ int j;
+ UINT64 *p = avalue[i] = alloca (ty->size);
+ for (j = 0; j < element_count (ty); j++)
+ memcpy (&p[j],
+ allocate_to_d (context, &state),
+ sizeof (*p));
+ break;
+ }
+
+#if FFI_TYPE_DOUBLE != FFI_TYPE_LONGDOUBLE
+ case FFI_TYPE_LONGDOUBLE:
+ memcpy (&avalue[i],
+ allocate_to_v (context, &state),
+ sizeof (*avalue));
+ break;
+#endif
+
+ default:
+ FFI_ASSERT (0);
+ break;
+ }
+ }
+ }
+ else if (ty->size > 16)
+ {
+ /* Replace Composite type of size greater than 16 with a
+ pointer. */
+ memcpy (&avalue[i],
+ allocate_to_register_or_stack (context, stack,
+ &state, FFI_TYPE_POINTER),
+ sizeof (avalue[i]));
+ }
+ else if (available_x (&state) >= (ty->size + 7) / 8)
+ {
+ avalue[i] = get_x_addr (context, state.ngrn);
+ state.ngrn += (ty->size + 7) / 8;
+ }
+ else
+ {
+ state.ngrn = N_X_ARG_REG;
+
+ avalue[i] = allocate_to_stack (&state, stack, ty->alignment,
+ ty->size);
+ }
+ break;
+
+ default:
+ FFI_ASSERT (0);
+ break;
+ }
+ }
+
+ /* Figure out where the return value will be passed, either in
+ registers or in a memory block allocated by the caller and passed
+ in x8. */
+
+ if (is_register_candidate (cif->rtype))
+ {
+ /* Register candidates are *always* returned in registers. */
+
+ /* Allocate a scratchpad for the return value, we will let the
+ callee scrible the result into the scratch pad then move the
+ contents into the appropriate return value location for the
+ call convention. */
+ rvalue = alloca (cif->rtype->size);
+ (closure->fun) (cif, rvalue, avalue, closure->user_data);
+
+ /* Copy the return value into the call context so that it is returned
+ as expected to our caller. */
+ switch (cif->rtype->type)
+ {
+ case FFI_TYPE_VOID:
+ break;
+
+ case FFI_TYPE_UINT8:
+ case FFI_TYPE_UINT16:
+ case FFI_TYPE_UINT32:
+ case FFI_TYPE_POINTER:
+ case FFI_TYPE_UINT64:
+ case FFI_TYPE_SINT8:
+ case FFI_TYPE_SINT16:
+ case FFI_TYPE_INT:
+ case FFI_TYPE_SINT32:
+ case FFI_TYPE_SINT64:
+ case FFI_TYPE_FLOAT:
+ case FFI_TYPE_DOUBLE:
+#if FFI_TYPE_DOUBLE != FFI_TYPE_LONGDOUBLE
+ case FFI_TYPE_LONGDOUBLE:
+#endif
+ {
+ void *addr = get_basic_type_addr (cif->rtype->type, context, 0);
+ copy_basic_type (addr, rvalue, cif->rtype->type);
+ break;
+ }
+ case FFI_TYPE_STRUCT:
+ if (is_hfa (cif->rtype))
+ {
+ int j;
+ unsigned short type = get_homogeneous_type (cif->rtype);
+ unsigned elems = element_count (cif->rtype);
+ for (j = 0; j < elems; j++)
+ {
+ void *reg = get_basic_type_addr (type, context, j);
+ copy_basic_type (reg, rvalue, type);
+ rvalue += get_basic_type_size (type);
+ }
+ }
+ else if ((cif->rtype->size + 7) / 8 < N_X_ARG_REG)
+ {
+ size_t size = ALIGN (cif->rtype->size, sizeof (UINT64)) ;
+ memcpy (get_x_addr (context, 0), rvalue, size);
+ }
+ else
+ {
+ FFI_ASSERT (0);
+ }
+ break;
+ default:
+ FFI_ASSERT (0);
+ break;
+ }
+ }
+ else
+ {
+ memcpy (&rvalue, get_x_addr (context, 8), sizeof (UINT64));
+ (closure->fun) (cif, rvalue, avalue, closure->user_data);
+ }
+}
+
diff --git a/jni/ruby/ext/fiddle/libffi-3.2.1/src/aarch64/ffitarget.h b/jni/ruby/ext/fiddle/libffi-3.2.1/src/aarch64/ffitarget.h
new file mode 100644
index 0000000..4bbced2
--- /dev/null
+++ b/jni/ruby/ext/fiddle/libffi-3.2.1/src/aarch64/ffitarget.h
@@ -0,0 +1,63 @@
+/* Copyright (c) 2009, 2010, 2011, 2012 ARM Ltd.
+
+Permission is hereby granted, free of charge, to any person obtaining
+a copy of this software and associated documentation files (the
+``Software''), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sublicense, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice shall be
+included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
+
+#ifndef LIBFFI_TARGET_H
+#define LIBFFI_TARGET_H
+
+#ifndef LIBFFI_H
+#error "Please do not include ffitarget.h directly into your source. Use ffi.h instead."
+#endif
+
+#ifndef LIBFFI_ASM
+typedef unsigned long ffi_arg;
+typedef signed long ffi_sarg;
+
+typedef enum ffi_abi
+ {
+ FFI_FIRST_ABI = 0,
+ FFI_SYSV,
+ FFI_LAST_ABI,
+ FFI_DEFAULT_ABI = FFI_SYSV
+ } ffi_abi;
+#endif
+
+/* ---- Definitions for closures ----------------------------------------- */
+
+#define FFI_CLOSURES 1
+#define FFI_TRAMPOLINE_SIZE 36
+#define FFI_NATIVE_RAW_API 0
+
+/* ---- Internal ---- */
+
+#if defined (__APPLE__)
+#define FFI_TARGET_SPECIFIC_VARIADIC
+#define FFI_EXTRA_CIF_FIELDS unsigned aarch64_flags; unsigned aarch64_nfixedargs
+#else
+#define FFI_EXTRA_CIF_FIELDS unsigned aarch64_flags
+#endif
+
+#define AARCH64_FFI_WITH_V_BIT 0
+
+#define AARCH64_N_XREG 32
+#define AARCH64_N_VREG 32
+#define AARCH64_CALL_CONTEXT_SIZE (AARCH64_N_XREG * 8 + AARCH64_N_VREG * 16)
+
+#endif
diff --git a/jni/ruby/ext/fiddle/libffi-3.2.1/src/aarch64/sysv.S b/jni/ruby/ext/fiddle/libffi-3.2.1/src/aarch64/sysv.S
new file mode 100644
index 0000000..169eab8
--- /dev/null
+++ b/jni/ruby/ext/fiddle/libffi-3.2.1/src/aarch64/sysv.S
@@ -0,0 +1,333 @@
+/* Copyright (c) 2009, 2010, 2011, 2012 ARM Ltd.
+
+Permission is hereby granted, free of charge, to any person obtaining
+a copy of this software and associated documentation files (the
+``Software''), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sublicense, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice shall be
+included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
+
+#define LIBFFI_ASM
+#include <fficonfig.h>
+#include <ffi.h>
+
+#ifdef HAVE_MACHINE_ASM_H
+#include <machine/asm.h>
+#else
+#ifdef __USER_LABEL_PREFIX__
+#define CONCAT1(a, b) CONCAT2(a, b)
+#define CONCAT2(a, b) a ## b
+
+/* Use the right prefix for global labels. */
+#define CNAME(x) CONCAT1 (__USER_LABEL_PREFIX__, x)
+#else
+#define CNAME(x) x
+#endif
+#endif
+
+#define cfi_adjust_cfa_offset(off) .cfi_adjust_cfa_offset off
+#define cfi_rel_offset(reg, off) .cfi_rel_offset reg, off
+#define cfi_restore(reg) .cfi_restore reg
+#define cfi_def_cfa_register(reg) .cfi_def_cfa_register reg
+
+ .text
+ .globl CNAME(ffi_call_SYSV)
+#ifdef __ELF__
+ .type CNAME(ffi_call_SYSV), #function
+#endif
+#ifdef __APPLE__
+ .align 2
+#endif
+
+/* ffi_call_SYSV()
+
+ Create a stack frame, setup an argument context, call the callee
+ and extract the result.
+
+ The maximum required argument stack size is provided,
+ ffi_call_SYSV() allocates that stack space then calls the
+ prepare_fn to populate register context and stack. The
+ argument passing registers are loaded from the register
+ context and the callee called, on return the register passing
+ register are saved back to the context. Our caller will
+ extract the return value from the final state of the saved
+ register context.
+
+ Prototype:
+
+ extern unsigned
+ ffi_call_SYSV (void (*)(struct call_context *context, unsigned char *,
+ extended_cif *),
+ struct call_context *context,
+ extended_cif *,
+ size_t required_stack_size,
+ void (*fn)(void));
+
+ Therefore on entry we have:
+
+ x0 prepare_fn
+ x1 &context
+ x2 &ecif
+ x3 bytes
+ x4 fn
+
+ This function uses the following stack frame layout:
+
+ ==
+ saved x30(lr)
+ x29(fp)-> saved x29(fp)
+ saved x24
+ saved x23
+ saved x22
+ sp' -> saved x21
+ ...
+ sp -> (constructed callee stack arguments)
+ ==
+
+ Voila! */
+
+#define ffi_call_SYSV_FS (8 * 4)
+
+ .cfi_startproc
+CNAME(ffi_call_SYSV):
+ stp x29, x30, [sp, #-16]!
+ cfi_adjust_cfa_offset (16)
+ cfi_rel_offset (x29, 0)
+ cfi_rel_offset (x30, 8)
+
+ mov x29, sp
+ cfi_def_cfa_register (x29)
+ sub sp, sp, #ffi_call_SYSV_FS
+
+ stp x21, x22, [sp, #0]
+ cfi_rel_offset (x21, 0 - ffi_call_SYSV_FS)
+ cfi_rel_offset (x22, 8 - ffi_call_SYSV_FS)
+
+ stp x23, x24, [sp, #16]
+ cfi_rel_offset (x23, 16 - ffi_call_SYSV_FS)
+ cfi_rel_offset (x24, 24 - ffi_call_SYSV_FS)
+
+ mov x21, x1
+ mov x22, x2
+ mov x24, x4
+
+ /* Allocate the stack space for the actual arguments, many
+ arguments will be passed in registers, but we assume
+ worst case and allocate sufficient stack for ALL of
+ the arguments. */
+ sub sp, sp, x3
+
+ /* unsigned (*prepare_fn) (struct call_context *context,
+ unsigned char *stack, extended_cif *ecif);
+ */
+ mov x23, x0
+ mov x0, x1
+ mov x1, sp
+ /* x2 already in place */
+ blr x23
+
+ /* Preserve the flags returned. */
+ mov x23, x0
+
+ /* Figure out if we should touch the vector registers. */
+ tbz x23, #AARCH64_FFI_WITH_V_BIT, 1f
+
+ /* Load the vector argument passing registers. */
+ ldp q0, q1, [x21, #8*32 + 0]
+ ldp q2, q3, [x21, #8*32 + 32]
+ ldp q4, q5, [x21, #8*32 + 64]
+ ldp q6, q7, [x21, #8*32 + 96]
+1:
+ /* Load the core argument passing registers. */
+ ldp x0, x1, [x21, #0]
+ ldp x2, x3, [x21, #16]
+ ldp x4, x5, [x21, #32]
+ ldp x6, x7, [x21, #48]
+
+ /* Don't forget x8 which may be holding the address of a return buffer.
+ */
+ ldr x8, [x21, #8*8]
+
+ blr x24
+
+ /* Save the core argument passing registers. */
+ stp x0, x1, [x21, #0]
+ stp x2, x3, [x21, #16]
+ stp x4, x5, [x21, #32]
+ stp x6, x7, [x21, #48]
+
+ /* Note nothing useful ever comes back in x8! */
+
+ /* Figure out if we should touch the vector registers. */
+ tbz x23, #AARCH64_FFI_WITH_V_BIT, 1f
+
+ /* Save the vector argument passing registers. */
+ stp q0, q1, [x21, #8*32 + 0]
+ stp q2, q3, [x21, #8*32 + 32]
+ stp q4, q5, [x21, #8*32 + 64]
+ stp q6, q7, [x21, #8*32 + 96]
+1:
+ /* All done, unwind our stack frame. */
+ ldp x21, x22, [x29, # - ffi_call_SYSV_FS]
+ cfi_restore (x21)
+ cfi_restore (x22)
+
+ ldp x23, x24, [x29, # - ffi_call_SYSV_FS + 16]
+ cfi_restore (x23)
+ cfi_restore (x24)
+
+ mov sp, x29
+ cfi_def_cfa_register (sp)
+
+ ldp x29, x30, [sp], #16
+ cfi_adjust_cfa_offset (-16)
+ cfi_restore (x29)
+ cfi_restore (x30)
+
+ ret
+
+ .cfi_endproc
+#ifdef __ELF__
+ .size CNAME(ffi_call_SYSV), .-CNAME(ffi_call_SYSV)
+#endif
+
+#define ffi_closure_SYSV_FS (8 * 2 + AARCH64_CALL_CONTEXT_SIZE)
+
+/* ffi_closure_SYSV
+
+ Closure invocation glue. This is the low level code invoked directly by
+ the closure trampoline to setup and call a closure.
+
+ On entry x17 points to a struct trampoline_data, x16 has been clobbered
+ all other registers are preserved.
+
+ We allocate a call context and save the argument passing registers,
+ then invoked the generic C ffi_closure_SYSV_inner() function to do all
+ the real work, on return we load the result passing registers back from
+ the call context.
+
+ On entry
+
+ extern void
+ ffi_closure_SYSV (struct trampoline_data *);
+
+ struct trampoline_data
+ {
+ UINT64 *ffi_closure;
+ UINT64 flags;
+ };
+
+ This function uses the following stack frame layout:
+
+ ==
+ saved x30(lr)
+ x29(fp)-> saved x29(fp)
+ saved x22
+ saved x21
+ ...
+ sp -> call_context
+ ==
+
+ Voila! */
+
+ .text
+ .globl CNAME(ffi_closure_SYSV)
+#ifdef __APPLE__
+ .align 2
+#endif
+ .cfi_startproc
+CNAME(ffi_closure_SYSV):
+ stp x29, x30, [sp, #-16]!
+ cfi_adjust_cfa_offset (16)
+ cfi_rel_offset (x29, 0)
+ cfi_rel_offset (x30, 8)
+
+ mov x29, sp
+ cfi_def_cfa_register (x29)
+
+ sub sp, sp, #ffi_closure_SYSV_FS
+
+ stp x21, x22, [x29, #-16]
+ cfi_rel_offset (x21, -16)
+ cfi_rel_offset (x22, -8)
+
+ /* Load x21 with &call_context. */
+ mov x21, sp
+ /* Preserve our struct trampoline_data * */
+ mov x22, x17
+
+ /* Save the rest of the argument passing registers. */
+ stp x0, x1, [x21, #0]
+ stp x2, x3, [x21, #16]
+ stp x4, x5, [x21, #32]
+ stp x6, x7, [x21, #48]
+ /* Don't forget we may have been given a result scratch pad address.
+ */
+ str x8, [x21, #64]
+
+ /* Figure out if we should touch the vector registers. */
+ ldr x0, [x22, #8]
+ tbz x0, #AARCH64_FFI_WITH_V_BIT, 1f
+
+ /* Save the argument passing vector registers. */
+ stp q0, q1, [x21, #8*32 + 0]
+ stp q2, q3, [x21, #8*32 + 32]
+ stp q4, q5, [x21, #8*32 + 64]
+ stp q6, q7, [x21, #8*32 + 96]
+1:
+ /* Load &ffi_closure.. */
+ ldr x0, [x22, #0]
+ mov x1, x21
+ /* Compute the location of the stack at the point that the
+ trampoline was called. */
+ add x2, x29, #16
+
+ bl CNAME(ffi_closure_SYSV_inner)
+
+ /* Figure out if we should touch the vector registers. */
+ ldr x0, [x22, #8]
+ tbz x0, #AARCH64_FFI_WITH_V_BIT, 1f
+
+ /* Load the result passing vector registers. */
+ ldp q0, q1, [x21, #8*32 + 0]
+ ldp q2, q3, [x21, #8*32 + 32]
+ ldp q4, q5, [x21, #8*32 + 64]
+ ldp q6, q7, [x21, #8*32 + 96]
+1:
+ /* Load the result passing core registers. */
+ ldp x0, x1, [x21, #0]
+ ldp x2, x3, [x21, #16]
+ ldp x4, x5, [x21, #32]
+ ldp x6, x7, [x21, #48]
+ /* Note nothing useful is returned in x8. */
+
+ /* We are done, unwind our frame. */
+ ldp x21, x22, [x29, #-16]
+ cfi_restore (x21)
+ cfi_restore (x22)
+
+ mov sp, x29
+ cfi_def_cfa_register (sp)
+
+ ldp x29, x30, [sp], #16
+ cfi_adjust_cfa_offset (-16)
+ cfi_restore (x29)
+ cfi_restore (x30)
+
+ ret
+ .cfi_endproc
+#ifdef __ELF__
+ .size CNAME(ffi_closure_SYSV), .-CNAME(ffi_closure_SYSV)
+#endif
diff --git a/jni/ruby/ext/fiddle/libffi-3.2.1/src/alpha/ffi.c b/jni/ruby/ext/fiddle/libffi-3.2.1/src/alpha/ffi.c
new file mode 100644
index 0000000..192f691
--- /dev/null
+++ b/jni/ruby/ext/fiddle/libffi-3.2.1/src/alpha/ffi.c
@@ -0,0 +1,288 @@
+/* -----------------------------------------------------------------------
+ ffi.c - Copyright (c) 2012 Anthony Green
+ Copyright (c) 1998, 2001, 2007, 2008 Red Hat, Inc.
+
+ Alpha Foreign Function Interface
+
+ Permission is hereby granted, free of charge, to any person obtaining
+ a copy of this software and associated documentation files (the
+ ``Software''), to deal in the Software without restriction, including
+ without limitation the rights to use, copy, modify, merge, publish,
+ distribute, sublicense, and/or sell copies of the Software, and to
+ permit persons to whom the Software is furnished to do so, subject to
+ the following conditions:
+
+ The above copyright notice and this permission notice shall be included
+ in all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND,
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+ HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ DEALINGS IN THE SOFTWARE.
+ ----------------------------------------------------------------------- */
+
+#include <ffi.h>
+#include <ffi_common.h>
+#include <stdlib.h>
+
+/* Force FFI_TYPE_LONGDOUBLE to be different than FFI_TYPE_DOUBLE;
+ all further uses in this file will refer to the 128-bit type. */
+#if defined(__LONG_DOUBLE_128__)
+# if FFI_TYPE_LONGDOUBLE != 4
+# error FFI_TYPE_LONGDOUBLE out of date
+# endif
+#else
+# undef FFI_TYPE_LONGDOUBLE
+# define FFI_TYPE_LONGDOUBLE 4
+#endif
+
+extern void ffi_call_osf(void *, unsigned long, unsigned, void *, void (*)(void))
+ FFI_HIDDEN;
+extern void ffi_closure_osf(void) FFI_HIDDEN;
+
+
+ffi_status
+ffi_prep_cif_machdep(ffi_cif *cif)
+{
+ /* Adjust cif->bytes to represent a minimum 6 words for the temporary
+ register argument loading area. */
+ if (cif->bytes < 6*FFI_SIZEOF_ARG)
+ cif->bytes = 6*FFI_SIZEOF_ARG;
+
+ /* Set the return type flag */
+ switch (cif->rtype->type)
+ {
+ case FFI_TYPE_STRUCT:
+ case FFI_TYPE_FLOAT:
+ case FFI_TYPE_DOUBLE:
+ cif->flags = cif->rtype->type;
+ break;
+
+ case FFI_TYPE_LONGDOUBLE:
+ /* 128-bit long double is returned in memory, like a struct. */
+ cif->flags = FFI_TYPE_STRUCT;
+ break;
+
+ default:
+ cif->flags = FFI_TYPE_INT;
+ break;
+ }
+
+ return FFI_OK;
+}
+
+
+void
+ffi_call(ffi_cif *cif, void (*fn)(void), void *rvalue, void **avalue)
+{
+ unsigned long *stack, *argp;
+ long i, avn;
+ ffi_type **arg_types;
+
+ /* If the return value is a struct and we don't have a return
+ value address then we need to make one. */
+ if (rvalue == NULL && cif->flags == FFI_TYPE_STRUCT)
+ rvalue = alloca(cif->rtype->size);
+
+ /* Allocate the space for the arguments, plus 4 words of temp
+ space for ffi_call_osf. */
+ argp = stack = alloca(cif->bytes + 4*FFI_SIZEOF_ARG);
+
+ if (cif->flags == FFI_TYPE_STRUCT)
+ *(void **) argp++ = rvalue;
+
+ i = 0;
+ avn = cif->nargs;
+ arg_types = cif->arg_types;
+
+ while (i < avn)
+ {
+ size_t size = (*arg_types)->size;
+
+ switch ((*arg_types)->type)
+ {
+ case FFI_TYPE_SINT8:
+ *(SINT64 *) argp = *(SINT8 *)(* avalue);
+ break;
+
+ case FFI_TYPE_UINT8:
+ *(SINT64 *) argp = *(UINT8 *)(* avalue);
+ break;
+
+ case FFI_TYPE_SINT16:
+ *(SINT64 *) argp = *(SINT16 *)(* avalue);
+ break;
+
+ case FFI_TYPE_UINT16:
+ *(SINT64 *) argp = *(UINT16 *)(* avalue);
+ break;
+
+ case FFI_TYPE_SINT32:
+ case FFI_TYPE_UINT32:
+ /* Note that unsigned 32-bit quantities are sign extended. */
+ *(SINT64 *) argp = *(SINT32 *)(* avalue);
+ break;
+
+ case FFI_TYPE_SINT64:
+ case FFI_TYPE_UINT64:
+ case FFI_TYPE_POINTER:
+ *(UINT64 *) argp = *(UINT64 *)(* avalue);
+ break;
+
+ case FFI_TYPE_FLOAT:
+ if (argp - stack < 6)
+ {
+ /* Note the conversion -- all the fp regs are loaded as
+ doubles. The in-register format is the same. */
+ *(double *) argp = *(float *)(* avalue);
+ }
+ else
+ *(float *) argp = *(float *)(* avalue);
+ break;
+
+ case FFI_TYPE_DOUBLE:
+ *(double *) argp = *(double *)(* avalue);
+ break;
+
+ case FFI_TYPE_LONGDOUBLE:
+ /* 128-bit long double is passed by reference. */
+ *(long double **) argp = (long double *)(* avalue);
+ size = sizeof (long double *);
+ break;
+
+ case FFI_TYPE_STRUCT:
+ memcpy(argp, *avalue, (*arg_types)->size);
+ break;
+
+ default:
+ FFI_ASSERT(0);
+ }
+
+ argp += ALIGN(size, FFI_SIZEOF_ARG) / FFI_SIZEOF_ARG;
+ i++, arg_types++, avalue++;
+ }
+
+ ffi_call_osf(stack, cif->bytes, cif->flags, rvalue, fn);
+}
+
+
+ffi_status
+ffi_prep_closure_loc (ffi_closure* closure,
+ ffi_cif* cif,
+ void (*fun)(ffi_cif*, void*, void**, void*),
+ void *user_data,
+ void *codeloc)
+{
+ unsigned int *tramp;
+
+ if (cif->abi != FFI_OSF)
+ return FFI_BAD_ABI;
+
+ tramp = (unsigned int *) &closure->tramp[0];
+ tramp[0] = 0x47fb0401; /* mov $27,$1 */
+ tramp[1] = 0xa77b0010; /* ldq $27,16($27) */
+ tramp[2] = 0x6bfb0000; /* jmp $31,($27),0 */
+ tramp[3] = 0x47ff041f; /* nop */
+ *(void **) &tramp[4] = ffi_closure_osf;
+
+ closure->cif = cif;
+ closure->fun = fun;
+ closure->user_data = user_data;
+
+ /* Flush the Icache.
+
+ Tru64 UNIX as doesn't understand the imb mnemonic, so use call_pal
+ instead, since both Compaq as and gas can handle it.
+
+ 0x86 is PAL_imb in Tru64 UNIX <alpha/pal.h>. */
+ asm volatile ("call_pal 0x86" : : : "memory");
+
+ return FFI_OK;
+}
+
+
+long FFI_HIDDEN
+ffi_closure_osf_inner(ffi_closure *closure, void *rvalue, unsigned long *argp)
+{
+ ffi_cif *cif;
+ void **avalue;
+ ffi_type **arg_types;
+ long i, avn, argn;
+
+ cif = closure->cif;
+ avalue = alloca(cif->nargs * sizeof(void *));
+
+ argn = 0;
+
+ /* Copy the caller's structure return address to that the closure
+ returns the data directly to the caller. */
+ if (cif->flags == FFI_TYPE_STRUCT)
+ {
+ rvalue = (void *) argp[0];
+ argn = 1;
+ }
+
+ i = 0;
+ avn = cif->nargs;
+ arg_types = cif->arg_types;
+
+ /* Grab the addresses of the arguments from the stack frame. */
+ while (i < avn)
+ {
+ size_t size = arg_types[i]->size;
+
+ switch (arg_types[i]->type)
+ {
+ case FFI_TYPE_SINT8:
+ case FFI_TYPE_UINT8:
+ case FFI_TYPE_SINT16:
+ case FFI_TYPE_UINT16:
+ case FFI_TYPE_SINT32:
+ case FFI_TYPE_UINT32:
+ case FFI_TYPE_SINT64:
+ case FFI_TYPE_UINT64:
+ case FFI_TYPE_POINTER:
+ case FFI_TYPE_STRUCT:
+ avalue[i] = &argp[argn];
+ break;
+
+ case FFI_TYPE_FLOAT:
+ if (argn < 6)
+ {
+ /* Floats coming from registers need conversion from double
+ back to float format. */
+ *(float *)&argp[argn - 6] = *(double *)&argp[argn - 6];
+ avalue[i] = &argp[argn - 6];
+ }
+ else
+ avalue[i] = &argp[argn];
+ break;
+
+ case FFI_TYPE_DOUBLE:
+ avalue[i] = &argp[argn - (argn < 6 ? 6 : 0)];
+ break;
+
+ case FFI_TYPE_LONGDOUBLE:
+ /* 128-bit long double is passed by reference. */
+ avalue[i] = (long double *) argp[argn];
+ size = sizeof (long double *);
+ break;
+
+ default:
+ abort ();
+ }
+
+ argn += ALIGN(size, FFI_SIZEOF_ARG) / FFI_SIZEOF_ARG;
+ i++;
+ }
+
+ /* Invoke the closure. */
+ closure->fun (cif, rvalue, avalue, closure->user_data);
+
+ /* Tell ffi_closure_osf how to perform return type promotions. */
+ return cif->rtype->type;
+}
diff --git a/jni/ruby/ext/fiddle/libffi-3.2.1/src/alpha/ffitarget.h b/jni/ruby/ext/fiddle/libffi-3.2.1/src/alpha/ffitarget.h
new file mode 100644
index 0000000..af145bc
--- /dev/null
+++ b/jni/ruby/ext/fiddle/libffi-3.2.1/src/alpha/ffitarget.h
@@ -0,0 +1,53 @@
+/* -----------------------------------------------------------------*-C-*-
+ ffitarget.h - Copyright (c) 2012 Anthony Green
+ Copyright (c) 1996-2003 Red Hat, Inc.
+ Target configuration macros for Alpha.
+
+ Permission is hereby granted, free of charge, to any person obtaining
+ a copy of this software and associated documentation files (the
+ ``Software''), to deal in the Software without restriction, including
+ without limitation the rights to use, copy, modify, merge, publish,
+ distribute, sublicense, and/or sell copies of the Software, and to
+ permit persons to whom the Software is furnished to do so, subject to
+ the following conditions:
+
+ The above copyright notice and this permission notice shall be included
+ in all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND,
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+ HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ DEALINGS IN THE SOFTWARE.
+
+ ----------------------------------------------------------------------- */
+
+#ifndef LIBFFI_TARGET_H
+#define LIBFFI_TARGET_H
+
+#ifndef LIBFFI_H
+#error "Please do not include ffitarget.h directly into your source. Use ffi.h instead."
+#endif
+
+#ifndef LIBFFI_ASM
+typedef unsigned long ffi_arg;
+typedef signed long ffi_sarg;
+
+typedef enum ffi_abi {
+ FFI_FIRST_ABI = 0,
+ FFI_OSF,
+ FFI_LAST_ABI,
+ FFI_DEFAULT_ABI = FFI_OSF
+} ffi_abi;
+#endif
+
+/* ---- Definitions for closures ----------------------------------------- */
+
+#define FFI_CLOSURES 1
+#define FFI_TRAMPOLINE_SIZE 24
+#define FFI_NATIVE_RAW_API 0
+
+#endif
diff --git a/jni/ruby/ext/fiddle/libffi-3.2.1/src/alpha/osf.S b/jni/ruby/ext/fiddle/libffi-3.2.1/src/alpha/osf.S
new file mode 100644
index 0000000..6b9f4df
--- /dev/null
+++ b/jni/ruby/ext/fiddle/libffi-3.2.1/src/alpha/osf.S
@@ -0,0 +1,387 @@
+/* -----------------------------------------------------------------------
+ osf.S - Copyright (c) 1998, 2001, 2007, 2008, 2011 Red Hat
+
+ Alpha/OSF Foreign Function Interface
+
+ Permission is hereby granted, free of charge, to any person obtaining
+ a copy of this software and associated documentation files (the
+ ``Software''), to deal in the Software without restriction, including
+ without limitation the rights to use, copy, modify, merge, publish,
+ distribute, sublicense, and/or sell copies of the Software, and to
+ permit persons to whom the Software is furnished to do so, subject to
+ the following conditions:
+
+ The above copyright notice and this permission notice shall be included
+ in all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND,
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+ HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ DEALINGS IN THE SOFTWARE.
+ ----------------------------------------------------------------------- */
+
+#define LIBFFI_ASM
+#include <fficonfig.h>
+#include <ffi.h>
+
+ .arch ev6
+ .text
+
+/* ffi_call_osf (void *args, unsigned long bytes, unsigned flags,
+ void *raddr, void (*fnaddr)(void));
+
+ Bit o trickiness here -- ARGS+BYTES is the base of the stack frame
+ for this function. This has been allocated by ffi_call. We also
+ deallocate some of the stack that has been alloca'd. */
+
+ .align 3
+ .globl ffi_call_osf
+ .ent ffi_call_osf
+ FFI_HIDDEN(ffi_call_osf)
+
+ffi_call_osf:
+ .frame $15, 32, $26, 0
+ .mask 0x4008000, -32
+$LFB1:
+ addq $16,$17,$1
+ mov $16, $30
+ stq $26, 0($1)
+ stq $15, 8($1)
+ stq $18, 16($1)
+ mov $1, $15
+$LCFI1:
+ .prologue 0
+
+ stq $19, 24($1)
+ mov $20, $27
+
+ # Load up all of the (potential) argument registers.
+ ldq $16, 0($30)
+ ldt $f16, 0($30)
+ ldt $f17, 8($30)
+ ldq $17, 8($30)
+ ldt $f18, 16($30)
+ ldq $18, 16($30)
+ ldt $f19, 24($30)
+ ldq $19, 24($30)
+ ldt $f20, 32($30)
+ ldq $20, 32($30)
+ ldt $f21, 40($30)
+ ldq $21, 40($30)
+
+ # Deallocate the register argument area.
+ lda $30, 48($30)
+
+ jsr $26, ($27), 0
+ ldgp $29, 0($26)
+
+ # If the return value pointer is NULL, assume no return value.
+ ldq $19, 24($15)
+ ldq $18, 16($15)
+ ldq $26, 0($15)
+$LCFI2:
+ beq $19, $noretval
+
+ # Store the return value out in the proper type.
+ cmpeq $18, FFI_TYPE_INT, $1
+ bne $1, $retint
+ cmpeq $18, FFI_TYPE_FLOAT, $2
+ bne $2, $retfloat
+ cmpeq $18, FFI_TYPE_DOUBLE, $3
+ bne $3, $retdouble
+
+ .align 3
+$noretval:
+ ldq $15, 8($15)
+ ret
+
+ .align 4
+$retint:
+ stq $0, 0($19)
+ nop
+ ldq $15, 8($15)
+ ret
+
+ .align 4
+$retfloat:
+ sts $f0, 0($19)
+ nop
+ ldq $15, 8($15)
+ ret
+
+ .align 4
+$retdouble:
+ stt $f0, 0($19)
+ nop
+ ldq $15, 8($15)
+ ret
+$LFE1:
+
+ .end ffi_call_osf
+
+/* ffi_closure_osf(...)
+
+ Receives the closure argument in $1. */
+
+ .align 3
+ .globl ffi_closure_osf
+ .ent ffi_closure_osf
+ FFI_HIDDEN(ffi_closure_osf)
+
+ffi_closure_osf:
+ .frame $30, 16*8, $26, 0
+ .mask 0x4000000, -16*8
+$LFB2:
+ ldgp $29, 0($27)
+ subq $30, 16*8, $30
+$LCFI5:
+ stq $26, 0($30)
+$LCFI6:
+ .prologue 1
+
+ # Store all of the potential argument registers in va_list format.
+ stt $f16, 4*8($30)
+ stt $f17, 5*8($30)
+ stt $f18, 6*8($30)
+ stt $f19, 7*8($30)
+ stt $f20, 8*8($30)
+ stt $f21, 9*8($30)
+ stq $16, 10*8($30)
+ stq $17, 11*8($30)
+ stq $18, 12*8($30)
+ stq $19, 13*8($30)
+ stq $20, 14*8($30)
+ stq $21, 15*8($30)
+
+ # Call ffi_closure_osf_inner to do the bulk of the work.
+ mov $1, $16
+ lda $17, 2*8($30)
+ lda $18, 10*8($30)
+ jsr $26, ffi_closure_osf_inner
+ ldgp $29, 0($26)
+ ldq $26, 0($30)
+
+ # Load up the return value in the proper type.
+ lda $1, $load_table
+ s4addq $0, $1, $1
+ ldl $1, 0($1)
+ addq $1, $29, $1
+ jmp $31, ($1), $load_32
+
+ .align 4
+$load_none:
+ addq $30, 16*8, $30
+ ret
+
+ .align 4
+$load_float:
+ lds $f0, 16($30)
+ nop
+ addq $30, 16*8, $30
+ ret
+
+ .align 4
+$load_double:
+ ldt $f0, 16($30)
+ nop
+ addq $30, 16*8, $30
+ ret
+
+ .align 4
+$load_u8:
+#ifdef __alpha_bwx__
+ ldbu $0, 16($30)
+ nop
+#else
+ ldq $0, 16($30)
+ and $0, 255, $0
+#endif
+ addq $30, 16*8, $30
+ ret
+
+ .align 4
+$load_s8:
+#ifdef __alpha_bwx__
+ ldbu $0, 16($30)
+ sextb $0, $0
+#else
+ ldq $0, 16($30)
+ sll $0, 56, $0
+ sra $0, 56, $0
+#endif
+ addq $30, 16*8, $30
+ ret
+
+ .align 4
+$load_u16:
+#ifdef __alpha_bwx__
+ ldwu $0, 16($30)
+ nop
+#else
+ ldq $0, 16($30)
+ zapnot $0, 3, $0
+#endif
+ addq $30, 16*8, $30
+ ret
+
+ .align 4
+$load_s16:
+#ifdef __alpha_bwx__
+ ldwu $0, 16($30)
+ sextw $0, $0
+#else
+ ldq $0, 16($30)
+ sll $0, 48, $0
+ sra $0, 48, $0
+#endif
+ addq $30, 16*8, $30
+ ret
+
+ .align 4
+$load_32:
+ ldl $0, 16($30)
+ nop
+ addq $30, 16*8, $30
+ ret
+
+ .align 4
+$load_64:
+ ldq $0, 16($30)
+ nop
+ addq $30, 16*8, $30
+ ret
+$LFE2:
+
+ .end ffi_closure_osf
+
+#ifdef __ELF__
+.section .rodata
+#else
+.rdata
+#endif
+$load_table:
+ .gprel32 $load_none # FFI_TYPE_VOID
+ .gprel32 $load_32 # FFI_TYPE_INT
+ .gprel32 $load_float # FFI_TYPE_FLOAT
+ .gprel32 $load_double # FFI_TYPE_DOUBLE
+ .gprel32 $load_none # FFI_TYPE_LONGDOUBLE
+ .gprel32 $load_u8 # FFI_TYPE_UINT8
+ .gprel32 $load_s8 # FFI_TYPE_SINT8
+ .gprel32 $load_u16 # FFI_TYPE_UINT16
+ .gprel32 $load_s16 # FFI_TYPE_SINT16
+ .gprel32 $load_32 # FFI_TYPE_UINT32
+ .gprel32 $load_32 # FFI_TYPE_SINT32
+ .gprel32 $load_64 # FFI_TYPE_UINT64
+ .gprel32 $load_64 # FFI_TYPE_SINT64
+ .gprel32 $load_none # FFI_TYPE_STRUCT
+ .gprel32 $load_64 # FFI_TYPE_POINTER
+
+/* Assert that the table above is in sync with ffi.h. */
+
+#if FFI_TYPE_FLOAT != 2 \
+ || FFI_TYPE_DOUBLE != 3 \
+ || FFI_TYPE_UINT8 != 5 \
+ || FFI_TYPE_SINT8 != 6 \
+ || FFI_TYPE_UINT16 != 7 \
+ || FFI_TYPE_SINT16 != 8 \
+ || FFI_TYPE_UINT32 != 9 \
+ || FFI_TYPE_SINT32 != 10 \
+ || FFI_TYPE_UINT64 != 11 \
+ || FFI_TYPE_SINT64 != 12 \
+ || FFI_TYPE_STRUCT != 13 \
+ || FFI_TYPE_POINTER != 14 \
+ || FFI_TYPE_LAST != 14
+#error "osf.S out of sync with ffi.h"
+#endif
+
+#ifdef __ELF__
+# define UA_SI .4byte
+# define FDE_ENCODING 0x1b /* pcrel sdata4 */
+# define FDE_ENCODE(X) .4byte X-.
+# define FDE_ARANGE(X) .4byte X
+#elif defined __osf__
+# define UA_SI .align 0; .long
+# define FDE_ENCODING 0x50 /* aligned absolute */
+# define FDE_ENCODE(X) .align 3; .quad X
+# define FDE_ARANGE(X) .align 0; .quad X
+#endif
+
+#ifdef __ELF__
+ .section .eh_frame,EH_FRAME_FLAGS,@progbits
+#elif defined __osf__
+ .data
+ .align 3
+ .globl _GLOBAL__F_ffi_call_osf
+_GLOBAL__F_ffi_call_osf:
+#endif
+__FRAME_BEGIN__:
+ UA_SI $LECIE1-$LSCIE1 # Length of Common Information Entry
+$LSCIE1:
+ UA_SI 0x0 # CIE Identifier Tag
+ .byte 0x1 # CIE Version
+ .ascii "zR\0" # CIE Augmentation
+ .byte 0x1 # uleb128 0x1; CIE Code Alignment Factor
+ .byte 0x78 # sleb128 -8; CIE Data Alignment Factor
+ .byte 26 # CIE RA Column
+ .byte 0x1 # uleb128 0x1; Augmentation size
+ .byte FDE_ENCODING # FDE Encoding
+ .byte 0xc # DW_CFA_def_cfa
+ .byte 30 # uleb128 column 30
+ .byte 0 # uleb128 offset 0
+ .align 3
+$LECIE1:
+$LSFDE1:
+ UA_SI $LEFDE1-$LASFDE1 # FDE Length
+$LASFDE1:
+ UA_SI $LASFDE1-__FRAME_BEGIN__ # FDE CIE offset
+ FDE_ENCODE($LFB1) # FDE initial location
+ FDE_ARANGE($LFE1-$LFB1) # FDE address range
+ .byte 0x0 # uleb128 0x0; Augmentation size
+
+ .byte 0x4 # DW_CFA_advance_loc4
+ UA_SI $LCFI1-$LFB1
+ .byte 0x9a # DW_CFA_offset, column 26
+ .byte 4 # uleb128 4*-8
+ .byte 0x8f # DW_CFA_offset, column 15
+ .byte 0x3 # uleb128 3*-8
+ .byte 0xc # DW_CFA_def_cfa
+ .byte 15 # uleb128 column 15
+ .byte 32 # uleb128 offset 32
+
+ .byte 0x4 # DW_CFA_advance_loc4
+ UA_SI $LCFI2-$LCFI1
+ .byte 0xda # DW_CFA_restore, column 26
+ .align 3
+$LEFDE1:
+
+$LSFDE3:
+ UA_SI $LEFDE3-$LASFDE3 # FDE Length
+$LASFDE3:
+ UA_SI $LASFDE3-__FRAME_BEGIN__ # FDE CIE offset
+ FDE_ENCODE($LFB2) # FDE initial location
+ FDE_ARANGE($LFE2-$LFB2) # FDE address range
+ .byte 0x0 # uleb128 0x0; Augmentation size
+
+ .byte 0x4 # DW_CFA_advance_loc4
+ UA_SI $LCFI5-$LFB2
+ .byte 0xe # DW_CFA_def_cfa_offset
+ .byte 0x80,0x1 # uleb128 128
+
+ .byte 0x4 # DW_CFA_advance_loc4
+ UA_SI $LCFI6-$LCFI5
+ .byte 0x9a # DW_CFA_offset, column 26
+ .byte 16 # uleb128 offset 16*-8
+ .align 3
+$LEFDE3:
+#if defined __osf__
+ .align 0
+ .long 0 # End of Table
+#endif
+
+#if defined __ELF__ && defined __linux__
+ .section .note.GNU-stack,"",@progbits
+#endif
diff --git a/jni/ruby/ext/fiddle/libffi-3.2.1/src/arc/arcompact.S b/jni/ruby/ext/fiddle/libffi-3.2.1/src/arc/arcompact.S
new file mode 100644
index 0000000..03715fd
--- /dev/null
+++ b/jni/ruby/ext/fiddle/libffi-3.2.1/src/arc/arcompact.S
@@ -0,0 +1,135 @@
+/* -----------------------------------------------------------------------
+ arcompact.S - Copyright (c) 2013 Synposys, Inc. (www.synopsys.com)
+
+ ARCompact Foreign Function Interface
+
+ Permission is hereby granted, free of charge, to any person obtaining
+ a copy of this software and associated documentation files (the
+ ``Software''), to deal in the Software without restriction, including
+ without limitation the rights to use, copy, modify, merge, publish,
+ distribute, sublicense, and/or sell copies of the Software, and to
+ permit persons to whom the Software is furnished to do so, subject to
+ the following conditions:
+
+ The above copyright notice and this permission notice shall be included
+ in all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ IN NO EVENT SHALL RENESAS TECHNOLOGY BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ OTHER DEALINGS IN THE SOFTWARE.
+ ----------------------------------------------------------------------- */
+
+#define LIBFFI_ASM
+#include <fficonfig.h>
+#include <ffi.h>
+#ifdef HAVE_MACHINE_ASM_H
+#include <machine/asm.h>
+#else
+#define CNAME(x) x
+#define ENTRY(x) .globl CNAME(x)` .type CNAME(x),%function` CNAME(x):
+#endif
+
+.text
+
+ /* R0: ffi_prep_args */
+ /* R1: &ecif */
+ /* R2: cif->bytes */
+ /* R3: fig->flags */
+ /* R4: ecif.rvalue */
+ /* R5: fn */
+ENTRY(ffi_call_ARCompact)
+ /* Save registers. */
+ st.a fp, [sp, -4] /* fp + 20, fp */
+ push_s blink /* fp + 16, blink */
+ st.a r4, [sp, -4] /* fp + 12, ecif.rvalue */
+ push_s r3 /* fp + 8, fig->flags */
+ st.a r5, [sp, -4] /* fp + 4, fn */
+ push_s r2 /* fp + 0, cif->bytes */
+ mov fp, sp
+
+ /* Make room for all of the new args. */
+ sub sp, sp, r2
+
+ /* Place all of the ffi_prep_args in position. */
+ /* ffi_prep_args(char *stack, extended_cif *ecif) */
+ /* R1 already set. */
+
+ /* And call. */
+ jl_s.d [r0]
+ mov_s r0, sp
+
+ ld.ab r12, [fp, 4] /* cif->bytes */
+ ld.ab r11, [fp, 4] /* fn */
+
+ /* Move first 8 parameters in registers... */
+ ld_s r0, [sp]
+ ld_s r1, [sp, 4]
+ ld_s r2, [sp, 8]
+ ld_s r3, [sp, 12]
+ ld r4, [sp, 16]
+ ld r5, [sp, 20]
+ ld r6, [sp, 24]
+ ld r7, [sp, 28]
+
+ /* ...and adjust the stack. */
+ min r12, r12, 32
+
+ /* Call the function. */
+ jl.d [r11]
+ add sp, sp, r12
+
+ mov sp, fp
+ pop_s r3 /* fig->flags, return type */
+ pop_s r2 /* ecif.rvalue, pointer for return value */
+
+ /* If the return value pointer is NULL, assume no return value. */
+ breq.d r2, 0, epilogue
+ pop_s blink
+
+ /* Return INT. */
+ brne r3, FFI_TYPE_INT, return_double
+ b.d epilogue
+ st_s r0, [r2]
+
+return_double:
+ brne r3, FFI_TYPE_DOUBLE, epilogue
+ st_s r0, [r2]
+ st_s r1, [r2,4]
+
+epilogue:
+ j_s.d [blink]
+ ld.ab fp, [sp, 4]
+
+ENTRY(ffi_closure_ARCompact)
+ st.a r0, [sp, -32]
+ st_s r1, [sp, 4]
+ st_s r2, [sp, 8]
+ st_s r3, [sp, 12]
+ st r4, [sp, 16]
+ st r5, [sp, 20]
+ st r6, [sp, 24]
+ st r7, [sp, 28]
+
+ /* pointer to arguments */
+ mov_s r2, sp
+
+ /* return value goes here */
+ sub sp, sp, 8
+ mov_s r1, sp
+
+ push_s blink
+
+ bl.d ffi_closure_inner_ARCompact
+ mov_s r0, r8 /* codeloc, set by trampoline */
+
+ pop_s blink
+
+ /* set return value to r1:r0 */
+ pop_s r0
+ pop_s r1
+ j_s.d [blink]
+ add_s sp, sp, 32
diff --git a/jni/ruby/ext/fiddle/libffi-3.2.1/src/arc/ffi.c b/jni/ruby/ext/fiddle/libffi-3.2.1/src/arc/ffi.c
new file mode 100644
index 0000000..32f82a7
--- /dev/null
+++ b/jni/ruby/ext/fiddle/libffi-3.2.1/src/arc/ffi.c
@@ -0,0 +1,268 @@
+/* -----------------------------------------------------------------------
+ ffi.c - Copyright (c) 2013 Synopsys, Inc. (www.synopsys.com)
+
+ ARC Foreign Function Interface
+
+ Permission is hereby granted, free of charge, to any person obtaining
+ a copy of this software and associated documentation files (the
+ ``Software''), to deal in the Software without restriction, including
+ without limitation the rights to use, copy, modify, merge, publish,
+ distribute, sublicense, and/or sell copies of the Software, and to
+ permit persons to whom the Software is furnished to do so, subject to
+ the following conditions:
+
+ The above copyright notice and this permission notice shall be included
+ in all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ IN NO EVENT SHALL RENESAS TECHNOLOGY BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ OTHER DEALINGS IN THE SOFTWARE.
+ ----------------------------------------------------------------------- */
+
+#include <ffi.h>
+#include <ffi_common.h>
+
+#include <stdlib.h>
+#include <stdint.h>
+
+#include <sys/cachectl.h>
+
+/* for little endian ARC, the code is in fact stored as mixed endian for
+ performance reasons */
+#if __BIG_ENDIAN__
+#define CODE_ENDIAN(x) (x)
+#else
+#define CODE_ENDIAN(x) ( (((uint32_t) (x)) << 16) | (((uint32_t) (x)) >> 16))
+#endif
+
+/* ffi_prep_args is called by the assembly routine once stack
+ space has been allocated for the function's arguments. */
+
+void
+ffi_prep_args (char *stack, extended_cif * ecif)
+{
+ unsigned int i;
+ int tmp;
+ void **p_argv;
+ char *argp;
+ ffi_type **p_arg;
+
+ tmp = 0;
+ argp = stack;
+
+ if (ecif->cif->rtype->type == FFI_TYPE_STRUCT)
+ {
+ *(void **) argp = ecif->rvalue;
+ argp += 4;
+ }
+
+ p_argv = ecif->avalue;
+
+ for (i = ecif->cif->nargs, p_arg = ecif->cif->arg_types;
+ (i != 0); i--, p_arg++)
+ {
+ size_t z;
+ int alignment;
+
+ /* align alignment to 4 */
+ alignment = (((*p_arg)->alignment - 1) | 3) + 1;
+
+ /* Align if necessary. */
+ if ((alignment - 1) & (unsigned) argp)
+ argp = (char *) ALIGN (argp, alignment);
+
+ z = (*p_arg)->size;
+ if (z < sizeof (int))
+ {
+ z = sizeof (int);
+
+ switch ((*p_arg)->type)
+ {
+ case FFI_TYPE_SINT8:
+ *(signed int *) argp = (signed int) *(SINT8 *) (*p_argv);
+ break;
+
+ case FFI_TYPE_UINT8:
+ *(unsigned int *) argp = (unsigned int) *(UINT8 *) (*p_argv);
+ break;
+
+ case FFI_TYPE_SINT16:
+ *(signed int *) argp = (signed int) *(SINT16 *) (*p_argv);
+ break;
+
+ case FFI_TYPE_UINT16:
+ *(unsigned int *) argp = (unsigned int) *(UINT16 *) (*p_argv);
+ break;
+
+ case FFI_TYPE_STRUCT:
+ memcpy (argp, *p_argv, (*p_arg)->size);
+ break;
+
+ default:
+ FFI_ASSERT (0);
+ }
+ }
+ else if (z == sizeof (int))
+ {
+ *(unsigned int *) argp = (unsigned int) *(UINT32 *) (*p_argv);
+ }
+ else
+ {
+ if ((*p_arg)->type == FFI_TYPE_STRUCT)
+ {
+ memcpy (argp, *p_argv, z);
+ }
+ else
+ {
+ /* Double or long long 64bit. */
+ memcpy (argp, *p_argv, z);
+ }
+ }
+ p_argv++;
+ argp += z;
+ }
+
+ return;
+}
+
+/* Perform machine dependent cif processing. */
+ffi_status
+ffi_prep_cif_machdep (ffi_cif * cif)
+{
+ /* Set the return type flag. */
+ switch (cif->rtype->type)
+ {
+ case FFI_TYPE_VOID:
+ cif->flags = (unsigned) cif->rtype->type;
+ break;
+
+ case FFI_TYPE_STRUCT:
+ cif->flags = (unsigned) cif->rtype->type;
+ break;
+
+ case FFI_TYPE_SINT64:
+ case FFI_TYPE_UINT64:
+ case FFI_TYPE_DOUBLE:
+ cif->flags = FFI_TYPE_DOUBLE;
+ break;
+
+ case FFI_TYPE_FLOAT:
+ default:
+ cif->flags = FFI_TYPE_INT;
+ break;
+ }
+
+ return FFI_OK;
+}
+
+extern void ffi_call_ARCompact (void (*)(char *, extended_cif *),
+ extended_cif *, unsigned, unsigned,
+ unsigned *, void (*fn) (void));
+
+void
+ffi_call (ffi_cif * cif, void (*fn) (void), void *rvalue, void **avalue)
+{
+ extended_cif ecif;
+
+ ecif.cif = cif;
+ ecif.avalue = avalue;
+
+ /* If the return value is a struct and we don't have
+ a return value address then we need to make one. */
+ if ((rvalue == NULL) && (cif->rtype->type == FFI_TYPE_STRUCT))
+ {
+ ecif.rvalue = alloca (cif->rtype->size);
+ }
+ else
+ ecif.rvalue = rvalue;
+
+ switch (cif->abi)
+ {
+ case FFI_ARCOMPACT:
+ ffi_call_ARCompact (ffi_prep_args, &ecif, cif->bytes,
+ cif->flags, ecif.rvalue, fn);
+ break;
+
+ default:
+ FFI_ASSERT (0);
+ break;
+ }
+}
+
+int
+ffi_closure_inner_ARCompact (ffi_closure * closure, void *rvalue,
+ ffi_arg * args)
+{
+ void **arg_area, **p_argv;
+ ffi_cif *cif = closure->cif;
+ char *argp = (char *) args;
+ ffi_type **p_argt;
+ int i;
+
+ arg_area = (void **) alloca (cif->nargs * sizeof (void *));
+
+ /* handle hidden argument */
+ if (cif->flags == FFI_TYPE_STRUCT)
+ {
+ rvalue = *(void **) argp;
+ argp += 4;
+ }
+
+ p_argv = arg_area;
+
+ for (i = 0, p_argt = cif->arg_types; i < cif->nargs;
+ i++, p_argt++, p_argv++)
+ {
+ size_t z;
+ int alignment;
+
+ /* align alignment to 4 */
+ alignment = (((*p_argt)->alignment - 1) | 3) + 1;
+
+ /* Align if necessary. */
+ if ((alignment - 1) & (unsigned) argp)
+ argp = (char *) ALIGN (argp, alignment);
+
+ z = (*p_argt)->size;
+ *p_argv = (void *) argp;
+ argp += z;
+ }
+
+ (closure->fun) (cif, rvalue, arg_area, closure->user_data);
+
+ return cif->flags;
+}
+
+extern void ffi_closure_ARCompact (void);
+
+ffi_status
+ffi_prep_closure_loc (ffi_closure * closure, ffi_cif * cif,
+ void (*fun) (ffi_cif *, void *, void **, void *),
+ void *user_data, void *codeloc)
+{
+ uint32_t *tramp = (uint32_t *) & (closure->tramp[0]);
+
+ switch (cif->abi)
+ {
+ case FFI_ARCOMPACT:
+ FFI_ASSERT (tramp == codeloc);
+ tramp[0] = CODE_ENDIAN (0x200a1fc0); /* mov r8, pcl */
+ tramp[1] = CODE_ENDIAN (0x20200f80); /* j [long imm] */
+ tramp[2] = CODE_ENDIAN (ffi_closure_ARCompact);
+ break;
+
+ default:
+ return FFI_BAD_ABI;
+ }
+
+ closure->cif = cif;
+ closure->fun = fun;
+ closure->user_data = user_data;
+ cacheflush (codeloc, FFI_TRAMPOLINE_SIZE, BCACHE);
+
+ return FFI_OK;
+}
diff --git a/jni/ruby/ext/fiddle/libffi-3.2.1/src/arc/ffitarget.h b/jni/ruby/ext/fiddle/libffi-3.2.1/src/arc/ffitarget.h
new file mode 100644
index 0000000..bf8311b
--- /dev/null
+++ b/jni/ruby/ext/fiddle/libffi-3.2.1/src/arc/ffitarget.h
@@ -0,0 +1,53 @@
+/* -----------------------------------------------------------------------
+ ffitarget.h - Copyright (c) 2012 Anthony Green
+ Copyright (c) 2013 Synopsys, Inc. (www.synopsys.com)
+ Target configuration macros for ARC.
+
+ Permission is hereby granted, free of charge, to any person obtaining
+ a copy of this software and associated documentation files (the
+ ``Software''), to deal in the Software without restriction, including
+ without limitation the rights to use, copy, modify, merge, publish,
+ distribute, sublicense, and/or sell copies of the Software, and to
+ permit persons to whom the Software is furnished to do so, subject to
+ the following conditions:
+
+ The above copyright notice and this permission notice shall be included
+ in all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ IN NO EVENT SHALL RENESAS TECHNOLOGY BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ OTHER DEALINGS IN THE SOFTWARE.
+
+ ----------------------------------------------------------------------- */
+
+#ifndef LIBFFI_TARGET_H
+#define LIBFFI_TARGET_H
+
+#ifndef LIBFFI_H
+#error "Please do not include ffitarget.h directly into your source. Use ffi.h instead."
+#endif
+
+/* ---- Generic type definitions ----------------------------------------- */
+
+#ifndef LIBFFI_ASM
+typedef unsigned long ffi_arg;
+typedef signed long ffi_sarg;
+
+typedef enum ffi_abi
+{
+ FFI_FIRST_ABI = 0,
+ FFI_ARCOMPACT,
+ FFI_LAST_ABI,
+ FFI_DEFAULT_ABI = FFI_ARCOMPACT
+} ffi_abi;
+#endif
+
+#define FFI_CLOSURES 1
+#define FFI_TRAMPOLINE_SIZE 12
+#define FFI_NATIVE_RAW_API 0
+
+#endif
diff --git a/jni/ruby/ext/fiddle/libffi-3.2.1/src/arm/ffi.c b/jni/ruby/ext/fiddle/libffi-3.2.1/src/arm/ffi.c
new file mode 100644
index 0000000..6691ab5
--- /dev/null
+++ b/jni/ruby/ext/fiddle/libffi-3.2.1/src/arm/ffi.c
@@ -0,0 +1,931 @@
+/* -----------------------------------------------------------------------
+ ffi.c - Copyright (c) 2011 Timothy Wall
+ Copyright (c) 2011 Plausible Labs Cooperative, Inc.
+ Copyright (c) 2011 Anthony Green
+ Copyright (c) 2011 Free Software Foundation
+ Copyright (c) 1998, 2008, 2011 Red Hat, Inc.
+
+ ARM Foreign Function Interface
+
+ Permission is hereby granted, free of charge, to any person obtaining
+ a copy of this software and associated documentation files (the
+ ``Software''), to deal in the Software without restriction, including
+ without limitation the rights to use, copy, modify, merge, publish,
+ distribute, sublicense, and/or sell copies of the Software, and to
+ permit persons to whom the Software is furnished to do so, subject to
+ the following conditions:
+
+ The above copyright notice and this permission notice shall be included
+ in all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND,
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+ HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ DEALINGS IN THE SOFTWARE.
+ ----------------------------------------------------------------------- */
+
+#include <ffi.h>
+#include <ffi_common.h>
+
+#include <stdlib.h>
+
+/* Forward declares. */
+static int vfp_type_p (ffi_type *);
+static void layout_vfp_args (ffi_cif *);
+
+int ffi_prep_args_SYSV(char *stack, extended_cif *ecif, float *vfp_space);
+int ffi_prep_args_VFP(char *stack, extended_cif *ecif, float *vfp_space);
+
+static char* ffi_align(ffi_type **p_arg, char *argp)
+{
+ /* Align if necessary */
+ register size_t alignment = (*p_arg)->alignment;
+ if (alignment < 4)
+ {
+ alignment = 4;
+ }
+#ifdef _WIN32_WCE
+ if (alignment > 4)
+ {
+ alignment = 4;
+ }
+#endif
+ if ((alignment - 1) & (unsigned) argp)
+ {
+ argp = (char *) ALIGN(argp, alignment);
+ }
+
+ if ((*p_arg)->type == FFI_TYPE_STRUCT)
+ {
+ argp = (char *) ALIGN(argp, 4);
+ }
+ return argp;
+}
+
+static size_t ffi_put_arg(ffi_type **arg_type, void **arg, char *stack)
+{
+ register char* argp = stack;
+ register ffi_type **p_arg = arg_type;
+ register void **p_argv = arg;
+ register size_t z = (*p_arg)->size;
+ if (z < sizeof(int))
+ {
+ z = sizeof(int);
+ switch ((*p_arg)->type)
+ {
+ case FFI_TYPE_SINT8:
+ *(signed int *) argp = (signed int)*(SINT8 *)(* p_argv);
+ break;
+
+ case FFI_TYPE_UINT8:
+ *(unsigned int *) argp = (unsigned int)*(UINT8 *)(* p_argv);
+ break;
+
+ case FFI_TYPE_SINT16:
+ *(signed int *) argp = (signed int)*(SINT16 *)(* p_argv);
+ break;
+
+ case FFI_TYPE_UINT16:
+ *(unsigned int *) argp = (unsigned int)*(UINT16 *)(* p_argv);
+ break;
+
+ case FFI_TYPE_STRUCT:
+ memcpy(argp, *p_argv, (*p_arg)->size);
+ break;
+
+ default:
+ FFI_ASSERT(0);
+ }
+ }
+ else if (z == sizeof(int))
+ {
+ if ((*p_arg)->type == FFI_TYPE_FLOAT)
+ *(float *) argp = *(float *)(* p_argv);
+ else
+ *(unsigned int *) argp = (unsigned int)*(UINT32 *)(* p_argv);
+ }
+ else if (z == sizeof(double) && (*p_arg)->type == FFI_TYPE_DOUBLE)
+ {
+ *(double *) argp = *(double *)(* p_argv);
+ }
+ else
+ {
+ memcpy(argp, *p_argv, z);
+ }
+ return z;
+}
+/* ffi_prep_args is called by the assembly routine once stack space
+ has been allocated for the function's arguments
+
+ The vfp_space parameter is the load area for VFP regs, the return
+ value is cif->vfp_used (word bitset of VFP regs used for passing
+ arguments). These are only used for the VFP hard-float ABI.
+*/
+int ffi_prep_args_SYSV(char *stack, extended_cif *ecif, float *vfp_space)
+{
+ register unsigned int i;
+ register void **p_argv;
+ register char *argp;
+ register ffi_type **p_arg;
+ argp = stack;
+
+
+ if ( ecif->cif->flags == FFI_TYPE_STRUCT ) {
+ *(void **) argp = ecif->rvalue;
+ argp += 4;
+ }
+
+ p_argv = ecif->avalue;
+
+ for (i = ecif->cif->nargs, p_arg = ecif->cif->arg_types;
+ (i != 0);
+ i--, p_arg++, p_argv++)
+ {
+ argp = ffi_align(p_arg, argp);
+ argp += ffi_put_arg(p_arg, p_argv, argp);
+ }
+
+ return 0;
+}
+
+int ffi_prep_args_VFP(char *stack, extended_cif *ecif, float *vfp_space)
+{
+ register unsigned int i, vi = 0;
+ register void **p_argv;
+ register char *argp, *regp, *eo_regp;
+ register ffi_type **p_arg;
+ char stack_used = 0;
+ char done_with_regs = 0;
+ char is_vfp_type;
+
+ // make sure we are using FFI_VFP
+ FFI_ASSERT(ecif->cif->abi == FFI_VFP);
+
+ /* the first 4 words on the stack are used for values passed in core
+ * registers. */
+ regp = stack;
+ eo_regp = argp = regp + 16;
+
+
+ /* if the function returns an FFI_TYPE_STRUCT in memory, that address is
+ * passed in r0 to the function */
+ if ( ecif->cif->flags == FFI_TYPE_STRUCT ) {
+ *(void **) regp = ecif->rvalue;
+ regp += 4;
+ }
+
+ p_argv = ecif->avalue;
+
+ for (i = ecif->cif->nargs, p_arg = ecif->cif->arg_types;
+ (i != 0);
+ i--, p_arg++, p_argv++)
+ {
+ is_vfp_type = vfp_type_p (*p_arg);
+
+ /* Allocated in VFP registers. */
+ if(vi < ecif->cif->vfp_nargs && is_vfp_type)
+ {
+ char *vfp_slot = (char *)(vfp_space + ecif->cif->vfp_args[vi++]);
+ ffi_put_arg(p_arg, p_argv, vfp_slot);
+ continue;
+ }
+ /* Try allocating in core registers. */
+ else if (!done_with_regs && !is_vfp_type)
+ {
+ char *tregp = ffi_align(p_arg, regp);
+ size_t size = (*p_arg)->size;
+ size = (size < 4)? 4 : size; // pad
+ /* Check if there is space left in the aligned register area to place
+ * the argument */
+ if(tregp + size <= eo_regp)
+ {
+ regp = tregp + ffi_put_arg(p_arg, p_argv, tregp);
+ done_with_regs = (regp == argp);
+ // ensure we did not write into the stack area
+ FFI_ASSERT(regp <= argp);
+ continue;
+ }
+ /* In case there are no arguments in the stack area yet,
+ the argument is passed in the remaining core registers and on the
+ stack. */
+ else if (!stack_used)
+ {
+ stack_used = 1;
+ done_with_regs = 1;
+ argp = tregp + ffi_put_arg(p_arg, p_argv, tregp);
+ FFI_ASSERT(eo_regp < argp);
+ continue;
+ }
+ }
+ /* Base case, arguments are passed on the stack */
+ stack_used = 1;
+ argp = ffi_align(p_arg, argp);
+ argp += ffi_put_arg(p_arg, p_argv, argp);
+ }
+ /* Indicate the VFP registers used. */
+ return ecif->cif->vfp_used;
+}
+
+/* Perform machine dependent cif processing */
+ffi_status ffi_prep_cif_machdep(ffi_cif *cif)
+{
+ int type_code;
+ /* Round the stack up to a multiple of 8 bytes. This isn't needed
+ everywhere, but it is on some platforms, and it doesn't harm anything
+ when it isn't needed. */
+ cif->bytes = (cif->bytes + 7) & ~7;
+
+ /* Set the return type flag */
+ switch (cif->rtype->type)
+ {
+ case FFI_TYPE_VOID:
+ case FFI_TYPE_FLOAT:
+ case FFI_TYPE_DOUBLE:
+ cif->flags = (unsigned) cif->rtype->type;
+ break;
+
+ case FFI_TYPE_SINT64:
+ case FFI_TYPE_UINT64:
+ cif->flags = (unsigned) FFI_TYPE_SINT64;
+ break;
+
+ case FFI_TYPE_STRUCT:
+ if (cif->abi == FFI_VFP
+ && (type_code = vfp_type_p (cif->rtype)) != 0)
+ {
+ /* A Composite Type passed in VFP registers, either
+ FFI_TYPE_STRUCT_VFP_FLOAT or FFI_TYPE_STRUCT_VFP_DOUBLE. */
+ cif->flags = (unsigned) type_code;
+ }
+ else if (cif->rtype->size <= 4)
+ /* A Composite Type not larger than 4 bytes is returned in r0. */
+ cif->flags = (unsigned)FFI_TYPE_INT;
+ else
+ /* A Composite Type larger than 4 bytes, or whose size cannot
+ be determined statically ... is stored in memory at an
+ address passed [in r0]. */
+ cif->flags = (unsigned)FFI_TYPE_STRUCT;
+ break;
+
+ default:
+ cif->flags = FFI_TYPE_INT;
+ break;
+ }
+
+ /* Map out the register placements of VFP register args.
+ The VFP hard-float calling conventions are slightly more sophisticated than
+ the base calling conventions, so we do it here instead of in ffi_prep_args(). */
+ if (cif->abi == FFI_VFP)
+ layout_vfp_args (cif);
+
+ return FFI_OK;
+}
+
+/* Perform machine dependent cif processing for variadic calls */
+ffi_status ffi_prep_cif_machdep_var(ffi_cif *cif,
+ unsigned int nfixedargs,
+ unsigned int ntotalargs)
+{
+ /* VFP variadic calls actually use the SYSV ABI */
+ if (cif->abi == FFI_VFP)
+ cif->abi = FFI_SYSV;
+
+ return ffi_prep_cif_machdep(cif);
+}
+
+/* Prototypes for assembly functions, in sysv.S */
+extern void ffi_call_SYSV (void (*fn)(void), extended_cif *, unsigned, unsigned, unsigned *);
+extern void ffi_call_VFP (void (*fn)(void), extended_cif *, unsigned, unsigned, unsigned *);
+
+void ffi_call(ffi_cif *cif, void (*fn)(void), void *rvalue, void **avalue)
+{
+ extended_cif ecif;
+
+ int small_struct = (cif->flags == FFI_TYPE_INT
+ && cif->rtype->type == FFI_TYPE_STRUCT);
+ int vfp_struct = (cif->flags == FFI_TYPE_STRUCT_VFP_FLOAT
+ || cif->flags == FFI_TYPE_STRUCT_VFP_DOUBLE);
+
+ unsigned int temp;
+
+ ecif.cif = cif;
+ ecif.avalue = avalue;
+
+ /* If the return value is a struct and we don't have a return */
+ /* value address then we need to make one */
+
+ if ((rvalue == NULL) &&
+ (cif->flags == FFI_TYPE_STRUCT))
+ {
+ ecif.rvalue = alloca(cif->rtype->size);
+ }
+ else if (small_struct)
+ ecif.rvalue = &temp;
+ else if (vfp_struct)
+ {
+ /* Largest case is double x 4. */
+ ecif.rvalue = alloca(32);
+ }
+ else
+ ecif.rvalue = rvalue;
+
+ switch (cif->abi)
+ {
+ case FFI_SYSV:
+ ffi_call_SYSV (fn, &ecif, cif->bytes, cif->flags, ecif.rvalue);
+ break;
+
+ case FFI_VFP:
+#ifdef __ARM_EABI__
+ ffi_call_VFP (fn, &ecif, cif->bytes, cif->flags, ecif.rvalue);
+ break;
+#endif
+
+ default:
+ FFI_ASSERT(0);
+ break;
+ }
+ if (small_struct)
+ {
+ FFI_ASSERT(rvalue != NULL);
+ memcpy (rvalue, &temp, cif->rtype->size);
+ }
+
+ else if (vfp_struct)
+ {
+ FFI_ASSERT(rvalue != NULL);
+ memcpy (rvalue, ecif.rvalue, cif->rtype->size);
+ }
+
+}
+
+/** private members **/
+
+static void ffi_prep_incoming_args_SYSV (char *stack, void **ret,
+ void** args, ffi_cif* cif, float *vfp_stack);
+
+static void ffi_prep_incoming_args_VFP (char *stack, void **ret,
+ void** args, ffi_cif* cif, float *vfp_stack);
+
+void ffi_closure_SYSV (ffi_closure *);
+
+void ffi_closure_VFP (ffi_closure *);
+
+/* This function is jumped to by the trampoline */
+
+unsigned int FFI_HIDDEN
+ffi_closure_inner (ffi_closure *closure,
+ void **respp, void *args, void *vfp_args)
+{
+ // our various things...
+ ffi_cif *cif;
+ void **arg_area;
+
+ cif = closure->cif;
+ arg_area = (void**) alloca (cif->nargs * sizeof (void*));
+
+ /* this call will initialize ARG_AREA, such that each
+ * element in that array points to the corresponding
+ * value on the stack; and if the function returns
+ * a structure, it will re-set RESP to point to the
+ * structure return address. */
+ if (cif->abi == FFI_VFP)
+ ffi_prep_incoming_args_VFP(args, respp, arg_area, cif, vfp_args);
+ else
+ ffi_prep_incoming_args_SYSV(args, respp, arg_area, cif, vfp_args);
+
+ (closure->fun) (cif, *respp, arg_area, closure->user_data);
+
+ return cif->flags;
+}
+
+/*@-exportheader@*/
+static void
+ffi_prep_incoming_args_SYSV(char *stack, void **rvalue,
+ void **avalue, ffi_cif *cif,
+ /* Used only under VFP hard-float ABI. */
+ float *vfp_stack)
+/*@=exportheader@*/
+{
+ register unsigned int i;
+ register void **p_argv;
+ register char *argp;
+ register ffi_type **p_arg;
+
+ argp = stack;
+
+ if ( cif->flags == FFI_TYPE_STRUCT ) {
+ *rvalue = *(void **) argp;
+ argp += 4;
+ }
+
+ p_argv = avalue;
+
+ for (i = cif->nargs, p_arg = cif->arg_types; (i != 0); i--, p_arg++)
+ {
+ size_t z;
+
+ argp = ffi_align(p_arg, argp);
+
+ z = (*p_arg)->size;
+
+ /* because we're little endian, this is what it turns into. */
+
+ *p_argv = (void*) argp;
+
+ p_argv++;
+ argp += z;
+ }
+
+ return;
+}
+
+/*@-exportheader@*/
+static void
+ffi_prep_incoming_args_VFP(char *stack, void **rvalue,
+ void **avalue, ffi_cif *cif,
+ /* Used only under VFP hard-float ABI. */
+ float *vfp_stack)
+/*@=exportheader@*/
+{
+ register unsigned int i, vi = 0;
+ register void **p_argv;
+ register char *argp, *regp, *eo_regp;
+ register ffi_type **p_arg;
+ char done_with_regs = 0;
+ char stack_used = 0;
+ char is_vfp_type;
+
+ FFI_ASSERT(cif->abi == FFI_VFP);
+ regp = stack;
+ eo_regp = argp = regp + 16;
+
+ if ( cif->flags == FFI_TYPE_STRUCT ) {
+ *rvalue = *(void **) regp;
+ regp += 4;
+ }
+
+ p_argv = avalue;
+
+ for (i = cif->nargs, p_arg = cif->arg_types; (i != 0); i--, p_arg++)
+ {
+ size_t z;
+ is_vfp_type = vfp_type_p (*p_arg);
+
+ if(vi < cif->vfp_nargs && is_vfp_type)
+ {
+ *p_argv++ = (void*)(vfp_stack + cif->vfp_args[vi++]);
+ continue;
+ }
+ else if (!done_with_regs && !is_vfp_type)
+ {
+ char* tregp = ffi_align(p_arg, regp);
+
+ z = (*p_arg)->size;
+ z = (z < 4)? 4 : z; // pad
+
+ /* if the arguments either fits into the registers or uses registers
+ * and stack, while we haven't read other things from the stack */
+ if(tregp + z <= eo_regp || !stack_used)
+ {
+ /* because we're little endian, this is what it turns into. */
+ *p_argv = (void*) tregp;
+
+ p_argv++;
+ regp = tregp + z;
+ // if we read past the last core register, make sure we have not read
+ // from the stack before and continue reading after regp
+ if(regp > eo_regp)
+ {
+ if(stack_used)
+ {
+ abort(); // we should never read past the end of the register
+ // are if the stack is already in use
+ }
+ argp = regp;
+ }
+ if(regp >= eo_regp)
+ {
+ done_with_regs = 1;
+ stack_used = 1;
+ }
+ continue;
+ }
+ }
+ stack_used = 1;
+
+ argp = ffi_align(p_arg, argp);
+
+ z = (*p_arg)->size;
+
+ /* because we're little endian, this is what it turns into. */
+
+ *p_argv = (void*) argp;
+
+ p_argv++;
+ argp += z;
+ }
+
+ return;
+}
+
+/* How to make a trampoline. */
+
+extern unsigned int ffi_arm_trampoline[3];
+
+#if FFI_EXEC_TRAMPOLINE_TABLE
+
+#include <mach/mach.h>
+#include <pthread.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+extern void *ffi_closure_trampoline_table_page;
+
+typedef struct ffi_trampoline_table ffi_trampoline_table;
+typedef struct ffi_trampoline_table_entry ffi_trampoline_table_entry;
+
+struct ffi_trampoline_table {
+ /* contiguous writable and executable pages */
+ vm_address_t config_page;
+ vm_address_t trampoline_page;
+
+ /* free list tracking */
+ uint16_t free_count;
+ ffi_trampoline_table_entry *free_list;
+ ffi_trampoline_table_entry *free_list_pool;
+
+ ffi_trampoline_table *prev;
+ ffi_trampoline_table *next;
+};
+
+struct ffi_trampoline_table_entry {
+ void *(*trampoline)();
+ ffi_trampoline_table_entry *next;
+};
+
+/* Override the standard architecture trampoline size */
+// XXX TODO - Fix
+#undef FFI_TRAMPOLINE_SIZE
+#define FFI_TRAMPOLINE_SIZE 12
+
+/* The trampoline configuration is placed at 4080 bytes prior to the trampoline's entry point */
+#define FFI_TRAMPOLINE_CODELOC_CONFIG(codeloc) ((void **) (((uint8_t *) codeloc) - 4080));
+
+/* The first 16 bytes of the config page are unused, as they are unaddressable from the trampoline page. */
+#define FFI_TRAMPOLINE_CONFIG_PAGE_OFFSET 16
+
+/* Total number of trampolines that fit in one trampoline table */
+#define FFI_TRAMPOLINE_COUNT ((PAGE_SIZE - FFI_TRAMPOLINE_CONFIG_PAGE_OFFSET) / FFI_TRAMPOLINE_SIZE)
+
+static pthread_mutex_t ffi_trampoline_lock = PTHREAD_MUTEX_INITIALIZER;
+static ffi_trampoline_table *ffi_trampoline_tables = NULL;
+
+static ffi_trampoline_table *
+ffi_trampoline_table_alloc ()
+{
+ ffi_trampoline_table *table = NULL;
+
+ /* Loop until we can allocate two contiguous pages */
+ while (table == NULL) {
+ vm_address_t config_page = 0x0;
+ kern_return_t kt;
+
+ /* Try to allocate two pages */
+ kt = vm_allocate (mach_task_self (), &config_page, PAGE_SIZE*2, VM_FLAGS_ANYWHERE);
+ if (kt != KERN_SUCCESS) {
+ fprintf(stderr, "vm_allocate() failure: %d at %s:%d\n", kt, __FILE__, __LINE__);
+ break;
+ }
+
+ /* Now drop the second half of the allocation to make room for the trampoline table */
+ vm_address_t trampoline_page = config_page+PAGE_SIZE;
+ kt = vm_deallocate (mach_task_self (), trampoline_page, PAGE_SIZE);
+ if (kt != KERN_SUCCESS) {
+ fprintf(stderr, "vm_deallocate() failure: %d at %s:%d\n", kt, __FILE__, __LINE__);
+ break;
+ }
+
+ /* Remap the trampoline table to directly follow the config page */
+ vm_prot_t cur_prot;
+ vm_prot_t max_prot;
+
+ kt = vm_remap (mach_task_self (), &trampoline_page, PAGE_SIZE, 0x0, FALSE, mach_task_self (), (vm_address_t) &ffi_closure_trampoline_table_page, FALSE, &cur_prot, &max_prot, VM_INHERIT_SHARE);
+
+ /* If we lost access to the destination trampoline page, drop our config allocation mapping and retry */
+ if (kt != KERN_SUCCESS) {
+ /* Log unexpected failures */
+ if (kt != KERN_NO_SPACE) {
+ fprintf(stderr, "vm_remap() failure: %d at %s:%d\n", kt, __FILE__, __LINE__);
+ }
+
+ vm_deallocate (mach_task_self (), config_page, PAGE_SIZE);
+ continue;
+ }
+
+ /* We have valid trampoline and config pages */
+ table = calloc (1, sizeof(ffi_trampoline_table));
+ table->free_count = FFI_TRAMPOLINE_COUNT;
+ table->config_page = config_page;
+ table->trampoline_page = trampoline_page;
+
+ /* Create and initialize the free list */
+ table->free_list_pool = calloc(FFI_TRAMPOLINE_COUNT, sizeof(ffi_trampoline_table_entry));
+
+ uint16_t i;
+ for (i = 0; i < table->free_count; i++) {
+ ffi_trampoline_table_entry *entry = &table->free_list_pool[i];
+ entry->trampoline = (void *) (table->trampoline_page + (i * FFI_TRAMPOLINE_SIZE));
+
+ if (i < table->free_count - 1)
+ entry->next = &table->free_list_pool[i+1];
+ }
+
+ table->free_list = table->free_list_pool;
+ }
+
+ return table;
+}
+
+void *
+ffi_closure_alloc (size_t size, void **code)
+{
+ /* Create the closure */
+ ffi_closure *closure = malloc(size);
+ if (closure == NULL)
+ return NULL;
+
+ pthread_mutex_lock(&ffi_trampoline_lock);
+
+ /* Check for an active trampoline table with available entries. */
+ ffi_trampoline_table *table = ffi_trampoline_tables;
+ if (table == NULL || table->free_list == NULL) {
+ table = ffi_trampoline_table_alloc ();
+ if (table == NULL) {
+ free(closure);
+ return NULL;
+ }
+
+ /* Insert the new table at the top of the list */
+ table->next = ffi_trampoline_tables;
+ if (table->next != NULL)
+ table->next->prev = table;
+
+ ffi_trampoline_tables = table;
+ }
+
+ /* Claim the free entry */
+ ffi_trampoline_table_entry *entry = ffi_trampoline_tables->free_list;
+ ffi_trampoline_tables->free_list = entry->next;
+ ffi_trampoline_tables->free_count--;
+ entry->next = NULL;
+
+ pthread_mutex_unlock(&ffi_trampoline_lock);
+
+ /* Initialize the return values */
+ *code = entry->trampoline;
+ closure->trampoline_table = table;
+ closure->trampoline_table_entry = entry;
+
+ return closure;
+}
+
+void
+ffi_closure_free (void *ptr)
+{
+ ffi_closure *closure = ptr;
+
+ pthread_mutex_lock(&ffi_trampoline_lock);
+
+ /* Fetch the table and entry references */
+ ffi_trampoline_table *table = closure->trampoline_table;
+ ffi_trampoline_table_entry *entry = closure->trampoline_table_entry;
+
+ /* Return the entry to the free list */
+ entry->next = table->free_list;
+ table->free_list = entry;
+ table->free_count++;
+
+ /* If all trampolines within this table are free, and at least one other table exists, deallocate
+ * the table */
+ if (table->free_count == FFI_TRAMPOLINE_COUNT && ffi_trampoline_tables != table) {
+ /* Remove from the list */
+ if (table->prev != NULL)
+ table->prev->next = table->next;
+
+ if (table->next != NULL)
+ table->next->prev = table->prev;
+
+ /* Deallocate pages */
+ kern_return_t kt;
+ kt = vm_deallocate (mach_task_self (), table->config_page, PAGE_SIZE);
+ if (kt != KERN_SUCCESS)
+ fprintf(stderr, "vm_deallocate() failure: %d at %s:%d\n", kt, __FILE__, __LINE__);
+
+ kt = vm_deallocate (mach_task_self (), table->trampoline_page, PAGE_SIZE);
+ if (kt != KERN_SUCCESS)
+ fprintf(stderr, "vm_deallocate() failure: %d at %s:%d\n", kt, __FILE__, __LINE__);
+
+ /* Deallocate free list */
+ free (table->free_list_pool);
+ free (table);
+ } else if (ffi_trampoline_tables != table) {
+ /* Otherwise, bump this table to the top of the list */
+ table->prev = NULL;
+ table->next = ffi_trampoline_tables;
+ if (ffi_trampoline_tables != NULL)
+ ffi_trampoline_tables->prev = table;
+
+ ffi_trampoline_tables = table;
+ }
+
+ pthread_mutex_unlock (&ffi_trampoline_lock);
+
+ /* Free the closure */
+ free (closure);
+}
+
+#else
+
+#define FFI_INIT_TRAMPOLINE(TRAMP,FUN,CTX) \
+({ unsigned char *__tramp = (unsigned char*)(TRAMP); \
+ unsigned int __fun = (unsigned int)(FUN); \
+ unsigned int __ctx = (unsigned int)(CTX); \
+ unsigned char *insns = (unsigned char *)(CTX); \
+ memcpy (__tramp, ffi_arm_trampoline, sizeof ffi_arm_trampoline); \
+ *(unsigned int*) &__tramp[12] = __ctx; \
+ *(unsigned int*) &__tramp[16] = __fun; \
+ __clear_cache((&__tramp[0]), (&__tramp[19])); /* Clear data mapping. */ \
+ __clear_cache(insns, insns + 3 * sizeof (unsigned int)); \
+ /* Clear instruction \
+ mapping. */ \
+ })
+
+#endif
+
+/* the cif must already be prep'ed */
+
+ffi_status
+ffi_prep_closure_loc (ffi_closure* closure,
+ ffi_cif* cif,
+ void (*fun)(ffi_cif*,void*,void**,void*),
+ void *user_data,
+ void *codeloc)
+{
+ void (*closure_func)(ffi_closure*) = NULL;
+
+ if (cif->abi == FFI_SYSV)
+ closure_func = &ffi_closure_SYSV;
+#ifdef __ARM_EABI__
+ else if (cif->abi == FFI_VFP)
+ closure_func = &ffi_closure_VFP;
+#endif
+ else
+ return FFI_BAD_ABI;
+
+#if FFI_EXEC_TRAMPOLINE_TABLE
+ void **config = FFI_TRAMPOLINE_CODELOC_CONFIG(codeloc);
+ config[0] = closure;
+ config[1] = closure_func;
+#else
+ FFI_INIT_TRAMPOLINE (&closure->tramp[0], \
+ closure_func, \
+ codeloc);
+#endif
+
+ closure->cif = cif;
+ closure->user_data = user_data;
+ closure->fun = fun;
+
+ return FFI_OK;
+}
+
+/* Below are routines for VFP hard-float support. */
+
+static int rec_vfp_type_p (ffi_type *t, int *elt, int *elnum)
+{
+ switch (t->type)
+ {
+ case FFI_TYPE_FLOAT:
+ case FFI_TYPE_DOUBLE:
+ *elt = (int) t->type;
+ *elnum = 1;
+ return 1;
+
+ case FFI_TYPE_STRUCT_VFP_FLOAT:
+ *elt = FFI_TYPE_FLOAT;
+ *elnum = t->size / sizeof (float);
+ return 1;
+
+ case FFI_TYPE_STRUCT_VFP_DOUBLE:
+ *elt = FFI_TYPE_DOUBLE;
+ *elnum = t->size / sizeof (double);
+ return 1;
+
+ case FFI_TYPE_STRUCT:;
+ {
+ int base_elt = 0, total_elnum = 0;
+ ffi_type **el = t->elements;
+ while (*el)
+ {
+ int el_elt = 0, el_elnum = 0;
+ if (! rec_vfp_type_p (*el, &el_elt, &el_elnum)
+ || (base_elt && base_elt != el_elt)
+ || total_elnum + el_elnum > 4)
+ return 0;
+ base_elt = el_elt;
+ total_elnum += el_elnum;
+ el++;
+ }
+ *elnum = total_elnum;
+ *elt = base_elt;
+ return 1;
+ }
+ default: ;
+ }
+ return 0;
+}
+
+static int vfp_type_p (ffi_type *t)
+{
+ int elt, elnum;
+ if (rec_vfp_type_p (t, &elt, &elnum))
+ {
+ if (t->type == FFI_TYPE_STRUCT)
+ {
+ if (elnum == 1)
+ t->type = elt;
+ else
+ t->type = (elt == FFI_TYPE_FLOAT
+ ? FFI_TYPE_STRUCT_VFP_FLOAT
+ : FFI_TYPE_STRUCT_VFP_DOUBLE);
+ }
+ return (int) t->type;
+ }
+ return 0;
+}
+
+static int place_vfp_arg (ffi_cif *cif, ffi_type *t)
+{
+ short reg = cif->vfp_reg_free;
+ int nregs = t->size / sizeof (float);
+ int align = ((t->type == FFI_TYPE_STRUCT_VFP_FLOAT
+ || t->type == FFI_TYPE_FLOAT) ? 1 : 2);
+ /* Align register number. */
+ if ((reg & 1) && align == 2)
+ reg++;
+ while (reg + nregs <= 16)
+ {
+ int s, new_used = 0;
+ for (s = reg; s < reg + nregs; s++)
+ {
+ new_used |= (1 << s);
+ if (cif->vfp_used & (1 << s))
+ {
+ reg += align;
+ goto next_reg;
+ }
+ }
+ /* Found regs to allocate. */
+ cif->vfp_used |= new_used;
+ cif->vfp_args[cif->vfp_nargs++] = reg;
+
+ /* Update vfp_reg_free. */
+ if (cif->vfp_used & (1 << cif->vfp_reg_free))
+ {
+ reg += nregs;
+ while (cif->vfp_used & (1 << reg))
+ reg += 1;
+ cif->vfp_reg_free = reg;
+ }
+ return 0;
+ next_reg: ;
+ }
+ // done, mark all regs as used
+ cif->vfp_reg_free = 16;
+ cif->vfp_used = 0xFFFF;
+ return 1;
+}
+
+static void layout_vfp_args (ffi_cif *cif)
+{
+ int i;
+ /* Init VFP fields */
+ cif->vfp_used = 0;
+ cif->vfp_nargs = 0;
+ cif->vfp_reg_free = 0;
+ memset (cif->vfp_args, -1, 16); /* Init to -1. */
+
+ for (i = 0; i < cif->nargs; i++)
+ {
+ ffi_type *t = cif->arg_types[i];
+ if (vfp_type_p (t) && place_vfp_arg (cif, t) == 1)
+ {
+ break;
+ }
+ }
+}
diff --git a/jni/ruby/ext/fiddle/libffi-3.2.1/src/arm/ffitarget.h b/jni/ruby/ext/fiddle/libffi-3.2.1/src/arm/ffitarget.h
new file mode 100644
index 0000000..26d494d
--- /dev/null
+++ b/jni/ruby/ext/fiddle/libffi-3.2.1/src/arm/ffitarget.h
@@ -0,0 +1,71 @@
+/* -----------------------------------------------------------------*-C-*-
+ ffitarget.h - Copyright (c) 2012 Anthony Green
+ Copyright (c) 2010 CodeSourcery
+ Copyright (c) 1996-2003 Red Hat, Inc.
+
+ Target configuration macros for ARM.
+
+ Permission is hereby granted, free of charge, to any person obtaining
+ a copy of this software and associated documentation files (the
+ ``Software''), to deal in the Software without restriction, including
+ without limitation the rights to use, copy, modify, merge, publish,
+ distribute, sublicense, and/or sell copies of the Software, and to
+ permit persons to whom the Software is furnished to do so, subject to
+ the following conditions:
+
+ The above copyright notice and this permission notice shall be included
+ in all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND,
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+ HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ DEALINGS IN THE SOFTWARE.
+
+ ----------------------------------------------------------------------- */
+
+#ifndef LIBFFI_TARGET_H
+#define LIBFFI_TARGET_H
+
+#ifndef LIBFFI_H
+#error "Please do not include ffitarget.h directly into your source. Use ffi.h instead."
+#endif
+
+#ifndef LIBFFI_ASM
+typedef unsigned long ffi_arg;
+typedef signed long ffi_sarg;
+
+typedef enum ffi_abi {
+ FFI_FIRST_ABI = 0,
+ FFI_SYSV,
+ FFI_VFP,
+ FFI_LAST_ABI,
+#ifdef __ARM_PCS_VFP
+ FFI_DEFAULT_ABI = FFI_VFP,
+#else
+ FFI_DEFAULT_ABI = FFI_SYSV,
+#endif
+} ffi_abi;
+#endif
+
+#define FFI_EXTRA_CIF_FIELDS \
+ int vfp_used; \
+ short vfp_reg_free, vfp_nargs; \
+ signed char vfp_args[16] \
+
+/* Internally used. */
+#define FFI_TYPE_STRUCT_VFP_FLOAT (FFI_TYPE_LAST + 1)
+#define FFI_TYPE_STRUCT_VFP_DOUBLE (FFI_TYPE_LAST + 2)
+
+#define FFI_TARGET_SPECIFIC_VARIADIC
+
+/* ---- Definitions for closures ----------------------------------------- */
+
+#define FFI_CLOSURES 1
+#define FFI_TRAMPOLINE_SIZE 20
+#define FFI_NATIVE_RAW_API 0
+
+#endif
diff --git a/jni/ruby/ext/fiddle/libffi-3.2.1/src/arm/gentramp.sh b/jni/ruby/ext/fiddle/libffi-3.2.1/src/arm/gentramp.sh
new file mode 100755
index 0000000..05c43a3
--- /dev/null
+++ b/jni/ruby/ext/fiddle/libffi-3.2.1/src/arm/gentramp.sh
@@ -0,0 +1,118 @@
+#!/bin/sh
+
+# -----------------------------------------------------------------------
+# gentramp.sh - Copyright (c) 2010, Plausible Labs Cooperative, Inc.
+#
+# ARM Trampoline Page Generator
+#
+# Permission is hereby granted, free of charge, to any person obtaining
+# a copy of this software and associated documentation files (the
+# ``Software''), to deal in the Software without restriction, including
+# without limitation the rights to use, copy, modify, merge, publish,
+# distribute, sublicense, and/or sell copies of the Software, and to
+# permit persons to whom the Software is furnished to do so, subject to
+# the following conditions:
+#
+# The above copyright notice and this permission notice shall be included
+# in all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND,
+# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+# HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+# WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+# DEALINGS IN THE SOFTWARE.
+# -----------------------------------------------------------------------
+
+PROGNAME=$0
+
+# Each trampoline is exactly 3 instructions, or 12 bytes. If any of these values change,
+# the entire arm trampoline implementation must be updated to match, too.
+
+# Size of an individual trampoline, in bytes
+TRAMPOLINE_SIZE=12
+
+# Page size, in bytes
+PAGE_SIZE=4096
+
+# Compute the size of the reachable config page; The first 16 bytes of the config page
+# are unreachable due to our maximum pc-relative ldr offset.
+PAGE_AVAIL=`expr $PAGE_SIZE - 16`
+
+# Compute the number of of available trampolines.
+TRAMPOLINE_COUNT=`expr $PAGE_AVAIL / $TRAMPOLINE_SIZE`
+
+header () {
+ echo "# GENERATED CODE - DO NOT EDIT"
+ echo "# This file was generated by $PROGNAME"
+ echo ""
+
+ # Write out the license header
+cat << EOF
+# Copyright (c) 2010, Plausible Labs Cooperative, Inc.
+#
+# Permission is hereby granted, free of charge, to any person obtaining
+# a copy of this software and associated documentation files (the
+# ``Software''), to deal in the Software without restriction, including
+# without limitation the rights to use, copy, modify, merge, publish,
+# distribute, sublicense, and/or sell copies of the Software, and to
+# permit persons to whom the Software is furnished to do so, subject to
+# the following conditions:
+#
+# The above copyright notice and this permission notice shall be included
+# in all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND,
+# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+# HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+# WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+# DEALINGS IN THE SOFTWARE.
+# -----------------------------------------------------------------------
+
+EOF
+
+ # Write out the trampoline table, aligned to the page boundary
+ echo ".text"
+ echo ".align 12"
+ echo ".globl _ffi_closure_trampoline_table_page"
+ echo "_ffi_closure_trampoline_table_page:"
+}
+
+
+# WARNING - Don't modify the trampoline code size without also updating the relevant libffi code
+trampoline () {
+ cat << END
+
+ // trampoline
+ // Save to stack
+ stmfd sp!, {r0-r3}
+
+ // Load the context argument from the config page.
+ // This places the first usable config value at _ffi_closure_trampoline_table-4080
+ // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc.
+ ldr r0, [pc, #-4092]
+
+ // Load the jump address from the config page.
+ ldr pc, [pc, #-4092]
+
+END
+}
+
+main () {
+ # Write out the header
+ header
+
+ # Write out the trampolines
+ local i=0
+ while [ $i -lt ${TRAMPOLINE_COUNT} ]; do
+ trampoline
+ local i=`expr $i + 1`
+ done
+}
+
+main
diff --git a/jni/ruby/ext/fiddle/libffi-3.2.1/src/arm/sysv.S b/jni/ruby/ext/fiddle/libffi-3.2.1/src/arm/sysv.S
new file mode 100644
index 0000000..541bbe9
--- /dev/null
+++ b/jni/ruby/ext/fiddle/libffi-3.2.1/src/arm/sysv.S
@@ -0,0 +1,491 @@
+/* -----------------------------------------------------------------------
+ sysv.S - Copyright (c) 1998, 2008, 2011 Red Hat, Inc.
+ Copyright (c) 2011 Plausible Labs Cooperative, Inc.
+
+ ARM Foreign Function Interface
+
+ Permission is hereby granted, free of charge, to any person obtaining
+ a copy of this software and associated documentation files (the
+ ``Software''), to deal in the Software without restriction, including
+ without limitation the rights to use, copy, modify, merge, publish,
+ distribute, sublicense, and/or sell copies of the Software, and to
+ permit persons to whom the Software is furnished to do so, subject to
+ the following conditions:
+
+ The above copyright notice and this permission notice shall be included
+ in all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND,
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+ HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ DEALINGS IN THE SOFTWARE.
+ ----------------------------------------------------------------------- */
+
+#define LIBFFI_ASM
+#include <fficonfig.h>
+#include <ffi.h>
+#ifdef HAVE_MACHINE_ASM_H
+#include <machine/asm.h>
+#else
+#ifdef __USER_LABEL_PREFIX__
+#define CONCAT1(a, b) CONCAT2(a, b)
+#define CONCAT2(a, b) a ## b
+
+/* Use the right prefix for global labels. */
+#define CNAME(x) CONCAT1 (__USER_LABEL_PREFIX__, x)
+#else
+#define CNAME(x) x
+#endif
+#ifdef __APPLE__
+#define ENTRY(x) .globl _##x; _##x:
+#else
+#define ENTRY(x) .globl CNAME(x); .type CNAME(x),%function; CNAME(x):
+#endif /* __APPLE__ */
+#endif
+
+#ifdef __ELF__
+#define LSYM(x) .x
+#else
+#define LSYM(x) x
+#endif
+
+/* Use the SOFTFP return value ABI on Mac OS X, as per the iOS ABI
+ Function Call Guide */
+#ifdef __APPLE__
+#define __SOFTFP__
+#endif
+
+/* We need a better way of testing for this, but for now, this is all
+ we can do. */
+@ This selects the minimum architecture level required.
+#define __ARM_ARCH__ 3
+
+#if defined(__ARM_ARCH_4__) || defined(__ARM_ARCH_4T__)
+# undef __ARM_ARCH__
+# define __ARM_ARCH__ 4
+#endif
+
+#if defined(__ARM_ARCH_5__) || defined(__ARM_ARCH_5T__) \
+ || defined(__ARM_ARCH_5E__) || defined(__ARM_ARCH_5TE__) \
+ || defined(__ARM_ARCH_5TEJ__)
+# undef __ARM_ARCH__
+# define __ARM_ARCH__ 5
+#endif
+
+#if defined(__ARM_ARCH_6__) || defined(__ARM_ARCH_6J__) \
+ || defined(__ARM_ARCH_6K__) || defined(__ARM_ARCH_6Z__) \
+ || defined(__ARM_ARCH_6ZK__) || defined(__ARM_ARCH_6T2__) \
+ || defined(__ARM_ARCH_6M__)
+# undef __ARM_ARCH__
+# define __ARM_ARCH__ 6
+#endif
+
+#if defined(__ARM_ARCH_7__) || defined(__ARM_ARCH_7A__) \
+ || defined(__ARM_ARCH_7R__) || defined(__ARM_ARCH_7M__) \
+ || defined(__ARM_ARCH_7EM__)
+# undef __ARM_ARCH__
+# define __ARM_ARCH__ 7
+#endif
+
+#if __ARM_ARCH__ >= 5
+# define call_reg(x) blx x
+#elif defined (__ARM_ARCH_4T__)
+# define call_reg(x) mov lr, pc ; bx x
+# if defined(__thumb__) || defined(__THUMB_INTERWORK__)
+# define __INTERWORKING__
+# endif
+#else
+# define call_reg(x) mov lr, pc ; mov pc, x
+#endif
+
+/* Conditionally compile unwinder directives. */
+#ifdef __ARM_EABI__
+#define UNWIND
+#else
+#define UNWIND @
+#endif
+
+.syntax unified
+
+#if defined(__thumb__) && !defined(__THUMB_INTERWORK__)
+#define ARM_FUNC_START(name) \
+ .text; \
+ .align 2; \
+ .thumb; \
+ .thumb_func; \
+ ENTRY(name); \
+ bx pc; \
+ nop; \
+ .arm; \
+ UNWIND .fnstart; \
+_L__##name:
+#else
+#define ARM_FUNC_START(name) \
+ .text; \
+ .align 2; \
+ .arm; \
+ ENTRY(name); \
+ UNWIND .fnstart
+#endif
+
+.macro RETLDM regs=, cond=, dirn=ia
+#if defined (__INTERWORKING__)
+ .ifc "\regs",""
+ ldr\cond lr, [sp], #4
+ .else
+ ldm\cond\dirn sp!, {\regs, lr}
+ .endif
+ bx\cond lr
+#else
+ .ifc "\regs",""
+ ldr\cond pc, [sp], #4
+ .else
+ ldm\cond\dirn sp!, {\regs, pc}
+ .endif
+#endif
+.endm
+
+ @ r0: ffi_prep_args
+ @ r1: &ecif
+ @ r2: cif->bytes
+ @ r3: fig->flags
+ @ sp+0: ecif.rvalue
+
+ @ This assumes we are using gas.
+ARM_FUNC_START(ffi_call_SYSV)
+ @ Save registers
+ stmfd sp!, {r0-r3, fp, lr}
+ UNWIND .save {r0-r3, fp, lr}
+ mov fp, sp
+
+ UNWIND .setfp fp, sp
+
+ @ Make room for all of the new args.
+ sub sp, fp, r2
+
+ @ Place all of the ffi_prep_args in position
+ mov r0, sp
+ @ r1 already set
+
+ @ Call ffi_prep_args(stack, &ecif)
+ bl CNAME(ffi_prep_args_SYSV)
+
+ @ move first 4 parameters in registers
+ ldmia sp, {r0-r3}
+
+ @ and adjust stack
+ sub lr, fp, sp @ cif->bytes == fp - sp
+ ldr ip, [fp] @ load fn() in advance
+ cmp lr, #16
+ movhs lr, #16
+ add sp, sp, lr
+
+ @ call (fn) (...)
+ call_reg(ip)
+
+ @ Remove the space we pushed for the args
+ mov sp, fp
+
+ @ Load r2 with the pointer to storage for the return value
+ ldr r2, [sp, #24]
+
+ @ Load r3 with the return type code
+ ldr r3, [sp, #12]
+
+ @ If the return value pointer is NULL, assume no return value.
+ cmp r2, #0
+ beq LSYM(Lepilogue)
+
+@ return INT
+ cmp r3, #FFI_TYPE_INT
+#if defined(__SOFTFP__) || defined(__ARM_EABI__)
+ cmpne r3, #FFI_TYPE_FLOAT
+#endif
+ streq r0, [r2]
+ beq LSYM(Lepilogue)
+
+ @ return INT64
+ cmp r3, #FFI_TYPE_SINT64
+#if defined(__SOFTFP__) || defined(__ARM_EABI__)
+ cmpne r3, #FFI_TYPE_DOUBLE
+#endif
+ stmiaeq r2, {r0, r1}
+
+#if !defined(__SOFTFP__) && !defined(__ARM_EABI__)
+ beq LSYM(Lepilogue)
+
+@ return FLOAT
+ cmp r3, #FFI_TYPE_FLOAT
+ stfeqs f0, [r2]
+ beq LSYM(Lepilogue)
+
+@ return DOUBLE or LONGDOUBLE
+ cmp r3, #FFI_TYPE_DOUBLE
+ stfeqd f0, [r2]
+#endif
+
+LSYM(Lepilogue):
+#if defined (__INTERWORKING__)
+ ldmia sp!, {r0-r3,fp, lr}
+ bx lr
+#else
+ ldmia sp!, {r0-r3,fp, pc}
+#endif
+
+.ffi_call_SYSV_end:
+ UNWIND .fnend
+#ifdef __ELF__
+ .size CNAME(ffi_call_SYSV),.ffi_call_SYSV_end-CNAME(ffi_call_SYSV)
+#endif
+
+
+/*
+ unsigned int FFI_HIDDEN
+ ffi_closure_inner (closure, respp, args)
+ ffi_closure *closure;
+ void **respp;
+ void *args;
+*/
+
+ARM_FUNC_START(ffi_closure_SYSV)
+ UNWIND .pad #16
+ add ip, sp, #16
+ stmfd sp!, {ip, lr}
+ UNWIND .save {r0, lr}
+ add r2, sp, #8
+ UNWIND .pad #16
+ sub sp, sp, #16
+ str sp, [sp, #8]
+ add r1, sp, #8
+ bl CNAME(ffi_closure_inner)
+ cmp r0, #FFI_TYPE_INT
+ beq .Lretint
+
+ cmp r0, #FFI_TYPE_FLOAT
+#if defined(__SOFTFP__) || defined(__ARM_EABI__)
+ beq .Lretint
+#else
+ beq .Lretfloat
+#endif
+
+ cmp r0, #FFI_TYPE_DOUBLE
+#if defined(__SOFTFP__) || defined(__ARM_EABI__)
+ beq .Lretlonglong
+#else
+ beq .Lretdouble
+#endif
+
+ cmp r0, #FFI_TYPE_LONGDOUBLE
+#if defined(__SOFTFP__) || defined(__ARM_EABI__)
+ beq .Lretlonglong
+#else
+ beq .Lretlongdouble
+#endif
+
+ cmp r0, #FFI_TYPE_SINT64
+ beq .Lretlonglong
+.Lclosure_epilogue:
+ add sp, sp, #16
+ ldmfd sp, {sp, pc}
+.Lretint:
+ ldr r0, [sp]
+ b .Lclosure_epilogue
+.Lretlonglong:
+ ldr r0, [sp]
+ ldr r1, [sp, #4]
+ b .Lclosure_epilogue
+
+#if !defined(__SOFTFP__) && !defined(__ARM_EABI__)
+.Lretfloat:
+ ldfs f0, [sp]
+ b .Lclosure_epilogue
+.Lretdouble:
+ ldfd f0, [sp]
+ b .Lclosure_epilogue
+.Lretlongdouble:
+ ldfd f0, [sp]
+ b .Lclosure_epilogue
+#endif
+
+.ffi_closure_SYSV_end:
+ UNWIND .fnend
+#ifdef __ELF__
+ .size CNAME(ffi_closure_SYSV),.ffi_closure_SYSV_end-CNAME(ffi_closure_SYSV)
+#endif
+
+
+/* Below are VFP hard-float ABI call and closure implementations.
+ Add VFP FPU directive here. This is only compiled into the library
+ under EABI. */
+#ifdef __ARM_EABI__
+ .fpu vfp
+
+ @ r0: fn
+ @ r1: &ecif
+ @ r2: cif->bytes
+ @ r3: fig->flags
+ @ sp+0: ecif.rvalue
+
+ARM_FUNC_START(ffi_call_VFP)
+ @ Save registers
+ stmfd sp!, {r0-r3, fp, lr}
+ UNWIND .save {r0-r3, fp, lr}
+ mov fp, sp
+ UNWIND .setfp fp, sp
+
+ @ Make room for all of the new args.
+ sub sp, sp, r2
+
+ @ Make room for loading VFP args
+ sub sp, sp, #64
+
+ @ Place all of the ffi_prep_args in position
+ mov r0, sp
+ @ r1 already set
+ sub r2, fp, #64 @ VFP scratch space
+
+ @ Call ffi_prep_args(stack, &ecif, vfp_space)
+ bl CNAME(ffi_prep_args_VFP)
+
+ @ Load VFP register args if needed
+ cmp r0, #0
+ mov ip, fp
+ beq LSYM(Lbase_args)
+
+ @ Load only d0 if possible
+ cmp r0, #3
+ sub ip, fp, #64
+ flddle d0, [ip]
+ fldmiadgt ip, {d0-d7}
+
+LSYM(Lbase_args):
+ @ move first 4 parameters in registers
+ ldmia sp, {r0-r3}
+
+ @ and adjust stack
+ sub lr, ip, sp @ cif->bytes == (fp - 64) - sp
+ ldr ip, [fp] @ load fn() in advance
+ cmp lr, #16
+ movhs lr, #16
+ add sp, sp, lr
+
+ @ call (fn) (...)
+ call_reg(ip)
+
+ @ Remove the space we pushed for the args
+ mov sp, fp
+
+ @ Load r2 with the pointer to storage for
+ @ the return value
+ ldr r2, [sp, #24]
+
+ @ Load r3 with the return type code
+ ldr r3, [sp, #12]
+
+ @ If the return value pointer is NULL,
+ @ assume no return value.
+ cmp r2, #0
+ beq LSYM(Lepilogue_vfp)
+
+ cmp r3, #FFI_TYPE_INT
+ streq r0, [r2]
+ beq LSYM(Lepilogue_vfp)
+
+ cmp r3, #FFI_TYPE_SINT64
+ stmeqia r2, {r0, r1}
+ beq LSYM(Lepilogue_vfp)
+
+ cmp r3, #FFI_TYPE_FLOAT
+ fstseq s0, [r2]
+ beq LSYM(Lepilogue_vfp)
+
+ cmp r3, #FFI_TYPE_DOUBLE
+ fstdeq d0, [r2]
+ beq LSYM(Lepilogue_vfp)
+
+ cmp r3, #FFI_TYPE_STRUCT_VFP_FLOAT
+ cmpne r3, #FFI_TYPE_STRUCT_VFP_DOUBLE
+ fstmiadeq r2, {d0-d3}
+
+LSYM(Lepilogue_vfp):
+ RETLDM "r0-r3,fp"
+
+.ffi_call_VFP_end:
+ UNWIND .fnend
+ .size CNAME(ffi_call_VFP),.ffi_call_VFP_end-CNAME(ffi_call_VFP)
+
+
+ARM_FUNC_START(ffi_closure_VFP)
+ fstmfdd sp!, {d0-d7}
+ @ r0-r3, then d0-d7
+ UNWIND .pad #80
+ add ip, sp, #80
+ stmfd sp!, {ip, lr}
+ UNWIND .save {r0, lr}
+ add r2, sp, #72
+ add r3, sp, #8
+ UNWIND .pad #72
+ sub sp, sp, #72
+ str sp, [sp, #64]
+ add r1, sp, #64
+ bl CNAME(ffi_closure_inner)
+
+ cmp r0, #FFI_TYPE_INT
+ beq .Lretint_vfp
+
+ cmp r0, #FFI_TYPE_FLOAT
+ beq .Lretfloat_vfp
+
+ cmp r0, #FFI_TYPE_DOUBLE
+ cmpne r0, #FFI_TYPE_LONGDOUBLE
+ beq .Lretdouble_vfp
+
+ cmp r0, #FFI_TYPE_SINT64
+ beq .Lretlonglong_vfp
+
+ cmp r0, #FFI_TYPE_STRUCT_VFP_FLOAT
+ beq .Lretfloat_struct_vfp
+
+ cmp r0, #FFI_TYPE_STRUCT_VFP_DOUBLE
+ beq .Lretdouble_struct_vfp
+
+.Lclosure_epilogue_vfp:
+ add sp, sp, #72
+ ldmfd sp, {sp, pc}
+
+.Lretfloat_vfp:
+ flds s0, [sp]
+ b .Lclosure_epilogue_vfp
+.Lretdouble_vfp:
+ fldd d0, [sp]
+ b .Lclosure_epilogue_vfp
+.Lretint_vfp:
+ ldr r0, [sp]
+ b .Lclosure_epilogue_vfp
+.Lretlonglong_vfp:
+ ldmia sp, {r0, r1}
+ b .Lclosure_epilogue_vfp
+.Lretfloat_struct_vfp:
+ fldmiad sp, {d0-d1}
+ b .Lclosure_epilogue_vfp
+.Lretdouble_struct_vfp:
+ fldmiad sp, {d0-d3}
+ b .Lclosure_epilogue_vfp
+
+.ffi_closure_VFP_end:
+ UNWIND .fnend
+ .size CNAME(ffi_closure_VFP),.ffi_closure_VFP_end-CNAME(ffi_closure_VFP)
+#endif
+
+ENTRY(ffi_arm_trampoline)
+ stmfd sp!, {r0-r3}
+ ldr r0, [pc]
+ ldr pc, [pc]
+
+#if defined __ELF__ && defined __linux__
+ .section .note.GNU-stack,"",%progbits
+#endif
diff --git a/jni/ruby/ext/fiddle/libffi-3.2.1/src/arm/trampoline.S b/jni/ruby/ext/fiddle/libffi-3.2.1/src/arm/trampoline.S
new file mode 100644
index 0000000..935e8de
--- /dev/null
+++ b/jni/ruby/ext/fiddle/libffi-3.2.1/src/arm/trampoline.S
@@ -0,0 +1,4450 @@
+# GENERATED CODE - DO NOT EDIT
+# This file was generated by src/arm/gentramp.sh
+
+# Copyright (c) 2010, Plausible Labs Cooperative, Inc.
+#
+# Permission is hereby granted, free of charge, to any person obtaining
+# a copy of this software and associated documentation files (the
+# Software''), to deal in the Software without restriction, including
+# without limitation the rights to use, copy, modify, merge, publish,
+# distribute, sublicense, and/or sell copies of the Software, and to
+# permit persons to whom the Software is furnished to do so, subject to
+# the following conditions:
+#
+# The above copyright notice and this permission notice shall be included
+# in all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED AS IS'', WITHOUT WARRANTY OF ANY KIND,
+# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+# HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+# WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+# DEALINGS IN THE SOFTWARE.
+# -----------------------------------------------------------------------
+
+.text
+.align 12
+.globl _ffi_closure_trampoline_table_page
+_ffi_closure_trampoline_table_page:
+
+ // trampoline
+ // Save to stack
+ stmfd sp!, {r0-r3}
+
+ // Load the context argument from the config page.
+ // This places the first usable config value at _ffi_closure_trampoline_table-4080
+ // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc.
+ ldr r0, [pc, #-4092]
+
+ // Load the jump address from the config page.
+ ldr pc, [pc, #-4092]
+
+
+ // trampoline
+ // Save to stack
+ stmfd sp!, {r0-r3}
+
+ // Load the context argument from the config page.
+ // This places the first usable config value at _ffi_closure_trampoline_table-4080
+ // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc.
+ ldr r0, [pc, #-4092]
+
+ // Load the jump address from the config page.
+ ldr pc, [pc, #-4092]
+
+
+ // trampoline
+ // Save to stack
+ stmfd sp!, {r0-r3}
+
+ // Load the context argument from the config page.
+ // This places the first usable config value at _ffi_closure_trampoline_table-4080
+ // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc.
+ ldr r0, [pc, #-4092]
+
+ // Load the jump address from the config page.
+ ldr pc, [pc, #-4092]
+
+
+ // trampoline
+ // Save to stack
+ stmfd sp!, {r0-r3}
+
+ // Load the context argument from the config page.
+ // This places the first usable config value at _ffi_closure_trampoline_table-4080
+ // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc.
+ ldr r0, [pc, #-4092]
+
+ // Load the jump address from the config page.
+ ldr pc, [pc, #-4092]
+
+
+ // trampoline
+ // Save to stack
+ stmfd sp!, {r0-r3}
+
+ // Load the context argument from the config page.
+ // This places the first usable config value at _ffi_closure_trampoline_table-4080
+ // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc.
+ ldr r0, [pc, #-4092]
+
+ // Load the jump address from the config page.
+ ldr pc, [pc, #-4092]
+
+
+ // trampoline
+ // Save to stack
+ stmfd sp!, {r0-r3}
+
+ // Load the context argument from the config page.
+ // This places the first usable config value at _ffi_closure_trampoline_table-4080
+ // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc.
+ ldr r0, [pc, #-4092]
+
+ // Load the jump address from the config page.
+ ldr pc, [pc, #-4092]
+
+
+ // trampoline
+ // Save to stack
+ stmfd sp!, {r0-r3}
+
+ // Load the context argument from the config page.
+ // This places the first usable config value at _ffi_closure_trampoline_table-4080
+ // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc.
+ ldr r0, [pc, #-4092]
+
+ // Load the jump address from the config page.
+ ldr pc, [pc, #-4092]
+
+
+ // trampoline
+ // Save to stack
+ stmfd sp!, {r0-r3}
+
+ // Load the context argument from the config page.
+ // This places the first usable config value at _ffi_closure_trampoline_table-4080
+ // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc.
+ ldr r0, [pc, #-4092]
+
+ // Load the jump address from the config page.
+ ldr pc, [pc, #-4092]
+
+
+ // trampoline
+ // Save to stack
+ stmfd sp!, {r0-r3}
+
+ // Load the context argument from the config page.
+ // This places the first usable config value at _ffi_closure_trampoline_table-4080
+ // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc.
+ ldr r0, [pc, #-4092]
+
+ // Load the jump address from the config page.
+ ldr pc, [pc, #-4092]
+
+
+ // trampoline
+ // Save to stack
+ stmfd sp!, {r0-r3}
+
+ // Load the context argument from the config page.
+ // This places the first usable config value at _ffi_closure_trampoline_table-4080
+ // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc.
+ ldr r0, [pc, #-4092]
+
+ // Load the jump address from the config page.
+ ldr pc, [pc, #-4092]
+
+
+ // trampoline
+ // Save to stack
+ stmfd sp!, {r0-r3}
+
+ // Load the context argument from the config page.
+ // This places the first usable config value at _ffi_closure_trampoline_table-4080
+ // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc.
+ ldr r0, [pc, #-4092]
+
+ // Load the jump address from the config page.
+ ldr pc, [pc, #-4092]
+
+
+ // trampoline
+ // Save to stack
+ stmfd sp!, {r0-r3}
+
+ // Load the context argument from the config page.
+ // This places the first usable config value at _ffi_closure_trampoline_table-4080
+ // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc.
+ ldr r0, [pc, #-4092]
+
+ // Load the jump address from the config page.
+ ldr pc, [pc, #-4092]
+
+
+ // trampoline
+ // Save to stack
+ stmfd sp!, {r0-r3}
+
+ // Load the context argument from the config page.
+ // This places the first usable config value at _ffi_closure_trampoline_table-4080
+ // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc.
+ ldr r0, [pc, #-4092]
+
+ // Load the jump address from the config page.
+ ldr pc, [pc, #-4092]
+
+
+ // trampoline
+ // Save to stack
+ stmfd sp!, {r0-r3}
+
+ // Load the context argument from the config page.
+ // This places the first usable config value at _ffi_closure_trampoline_table-4080
+ // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc.
+ ldr r0, [pc, #-4092]
+
+ // Load the jump address from the config page.
+ ldr pc, [pc, #-4092]
+
+
+ // trampoline
+ // Save to stack
+ stmfd sp!, {r0-r3}
+
+ // Load the context argument from the config page.
+ // This places the first usable config value at _ffi_closure_trampoline_table-4080
+ // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc.
+ ldr r0, [pc, #-4092]
+
+ // Load the jump address from the config page.
+ ldr pc, [pc, #-4092]
+
+
+ // trampoline
+ // Save to stack
+ stmfd sp!, {r0-r3}
+
+ // Load the context argument from the config page.
+ // This places the first usable config value at _ffi_closure_trampoline_table-4080
+ // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc.
+ ldr r0, [pc, #-4092]
+
+ // Load the jump address from the config page.
+ ldr pc, [pc, #-4092]
+
+
+ // trampoline
+ // Save to stack
+ stmfd sp!, {r0-r3}
+
+ // Load the context argument from the config page.
+ // This places the first usable config value at _ffi_closure_trampoline_table-4080
+ // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc.
+ ldr r0, [pc, #-4092]
+
+ // Load the jump address from the config page.
+ ldr pc, [pc, #-4092]
+
+
+ // trampoline
+ // Save to stack
+ stmfd sp!, {r0-r3}
+
+ // Load the context argument from the config page.
+ // This places the first usable config value at _ffi_closure_trampoline_table-4080
+ // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc.
+ ldr r0, [pc, #-4092]
+
+ // Load the jump address from the config page.
+ ldr pc, [pc, #-4092]
+
+
+ // trampoline
+ // Save to stack
+ stmfd sp!, {r0-r3}
+
+ // Load the context argument from the config page.
+ // This places the first usable config value at _ffi_closure_trampoline_table-4080
+ // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc.
+ ldr r0, [pc, #-4092]
+
+ // Load the jump address from the config page.
+ ldr pc, [pc, #-4092]
+
+
+ // trampoline
+ // Save to stack
+ stmfd sp!, {r0-r3}
+
+ // Load the context argument from the config page.
+ // This places the first usable config value at _ffi_closure_trampoline_table-4080
+ // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc.
+ ldr r0, [pc, #-4092]
+
+ // Load the jump address from the config page.
+ ldr pc, [pc, #-4092]
+
+
+ // trampoline
+ // Save to stack
+ stmfd sp!, {r0-r3}
+
+ // Load the context argument from the config page.
+ // This places the first usable config value at _ffi_closure_trampoline_table-4080
+ // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc.
+ ldr r0, [pc, #-4092]
+
+ // Load the jump address from the config page.
+ ldr pc, [pc, #-4092]
+
+
+ // trampoline
+ // Save to stack
+ stmfd sp!, {r0-r3}
+
+ // Load the context argument from the config page.
+ // This places the first usable config value at _ffi_closure_trampoline_table-4080
+ // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc.
+ ldr r0, [pc, #-4092]
+
+ // Load the jump address from the config page.
+ ldr pc, [pc, #-4092]
+
+
+ // trampoline
+ // Save to stack
+ stmfd sp!, {r0-r3}
+
+ // Load the context argument from the config page.
+ // This places the first usable config value at _ffi_closure_trampoline_table-4080
+ // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc.
+ ldr r0, [pc, #-4092]
+
+ // Load the jump address from the config page.
+ ldr pc, [pc, #-4092]
+
+
+ // trampoline
+ // Save to stack
+ stmfd sp!, {r0-r3}
+
+ // Load the context argument from the config page.
+ // This places the first usable config value at _ffi_closure_trampoline_table-4080
+ // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc.
+ ldr r0, [pc, #-4092]
+
+ // Load the jump address from the config page.
+ ldr pc, [pc, #-4092]
+
+
+ // trampoline
+ // Save to stack
+ stmfd sp!, {r0-r3}
+
+ // Load the context argument from the config page.
+ // This places the first usable config value at _ffi_closure_trampoline_table-4080
+ // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc.
+ ldr r0, [pc, #-4092]
+
+ // Load the jump address from the config page.
+ ldr pc, [pc, #-4092]
+
+
+ // trampoline
+ // Save to stack
+ stmfd sp!, {r0-r3}
+
+ // Load the context argument from the config page.
+ // This places the first usable config value at _ffi_closure_trampoline_table-4080
+ // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc.
+ ldr r0, [pc, #-4092]
+
+ // Load the jump address from the config page.
+ ldr pc, [pc, #-4092]
+
+
+ // trampoline
+ // Save to stack
+ stmfd sp!, {r0-r3}
+
+ // Load the context argument from the config page.
+ // This places the first usable config value at _ffi_closure_trampoline_table-4080
+ // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc.
+ ldr r0, [pc, #-4092]
+
+ // Load the jump address from the config page.
+ ldr pc, [pc, #-4092]
+
+
+ // trampoline
+ // Save to stack
+ stmfd sp!, {r0-r3}
+
+ // Load the context argument from the config page.
+ // This places the first usable config value at _ffi_closure_trampoline_table-4080
+ // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc.
+ ldr r0, [pc, #-4092]
+
+ // Load the jump address from the config page.
+ ldr pc, [pc, #-4092]
+
+
+ // trampoline
+ // Save to stack
+ stmfd sp!, {r0-r3}
+
+ // Load the context argument from the config page.
+ // This places the first usable config value at _ffi_closure_trampoline_table-4080
+ // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc.
+ ldr r0, [pc, #-4092]
+
+ // Load the jump address from the config page.
+ ldr pc, [pc, #-4092]
+
+
+ // trampoline
+ // Save to stack
+ stmfd sp!, {r0-r3}
+
+ // Load the context argument from the config page.
+ // This places the first usable config value at _ffi_closure_trampoline_table-4080
+ // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc.
+ ldr r0, [pc, #-4092]
+
+ // Load the jump address from the config page.
+ ldr pc, [pc, #-4092]
+
+
+ // trampoline
+ // Save to stack
+ stmfd sp!, {r0-r3}
+
+ // Load the context argument from the config page.
+ // This places the first usable config value at _ffi_closure_trampoline_table-4080
+ // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc.
+ ldr r0, [pc, #-4092]
+
+ // Load the jump address from the config page.
+ ldr pc, [pc, #-4092]
+
+
+ // trampoline
+ // Save to stack
+ stmfd sp!, {r0-r3}
+
+ // Load the context argument from the config page.
+ // This places the first usable config value at _ffi_closure_trampoline_table-4080
+ // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc.
+ ldr r0, [pc, #-4092]
+
+ // Load the jump address from the config page.
+ ldr pc, [pc, #-4092]
+
+
+ // trampoline
+ // Save to stack
+ stmfd sp!, {r0-r3}
+
+ // Load the context argument from the config page.
+ // This places the first usable config value at _ffi_closure_trampoline_table-4080
+ // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc.
+ ldr r0, [pc, #-4092]
+
+ // Load the jump address from the config page.
+ ldr pc, [pc, #-4092]
+
+
+ // trampoline
+ // Save to stack
+ stmfd sp!, {r0-r3}
+
+ // Load the context argument from the config page.
+ // This places the first usable config value at _ffi_closure_trampoline_table-4080
+ // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc.
+ ldr r0, [pc, #-4092]
+
+ // Load the jump address from the config page.
+ ldr pc, [pc, #-4092]
+
+
+ // trampoline
+ // Save to stack
+ stmfd sp!, {r0-r3}
+
+ // Load the context argument from the config page.
+ // This places the first usable config value at _ffi_closure_trampoline_table-4080
+ // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc.
+ ldr r0, [pc, #-4092]
+
+ // Load the jump address from the config page.
+ ldr pc, [pc, #-4092]
+
+
+ // trampoline
+ // Save to stack
+ stmfd sp!, {r0-r3}
+
+ // Load the context argument from the config page.
+ // This places the first usable config value at _ffi_closure_trampoline_table-4080
+ // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc.
+ ldr r0, [pc, #-4092]
+
+ // Load the jump address from the config page.
+ ldr pc, [pc, #-4092]
+
+
+ // trampoline
+ // Save to stack
+ stmfd sp!, {r0-r3}
+
+ // Load the context argument from the config page.
+ // This places the first usable config value at _ffi_closure_trampoline_table-4080
+ // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc.
+ ldr r0, [pc, #-4092]
+
+ // Load the jump address from the config page.
+ ldr pc, [pc, #-4092]
+
+
+ // trampoline
+ // Save to stack
+ stmfd sp!, {r0-r3}
+
+ // Load the context argument from the config page.
+ // This places the first usable config value at _ffi_closure_trampoline_table-4080
+ // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc.
+ ldr r0, [pc, #-4092]
+
+ // Load the jump address from the config page.
+ ldr pc, [pc, #-4092]
+
+
+ // trampoline
+ // Save to stack
+ stmfd sp!, {r0-r3}
+
+ // Load the context argument from the config page.
+ // This places the first usable config value at _ffi_closure_trampoline_table-4080
+ // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc.
+ ldr r0, [pc, #-4092]
+
+ // Load the jump address from the config page.
+ ldr pc, [pc, #-4092]
+
+
+ // trampoline
+ // Save to stack
+ stmfd sp!, {r0-r3}
+
+ // Load the context argument from the config page.
+ // This places the first usable config value at _ffi_closure_trampoline_table-4080
+ // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc.
+ ldr r0, [pc, #-4092]
+
+ // Load the jump address from the config page.
+ ldr pc, [pc, #-4092]
+
+
+ // trampoline
+ // Save to stack
+ stmfd sp!, {r0-r3}
+
+ // Load the context argument from the config page.
+ // This places the first usable config value at _ffi_closure_trampoline_table-4080
+ // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc.
+ ldr r0, [pc, #-4092]
+
+ // Load the jump address from the config page.
+ ldr pc, [pc, #-4092]
+
+
+ // trampoline
+ // Save to stack
+ stmfd sp!, {r0-r3}
+
+ // Load the context argument from the config page.
+ // This places the first usable config value at _ffi_closure_trampoline_table-4080
+ // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc.
+ ldr r0, [pc, #-4092]
+
+ // Load the jump address from the config page.
+ ldr pc, [pc, #-4092]
+
+
+ // trampoline
+ // Save to stack
+ stmfd sp!, {r0-r3}
+
+ // Load the context argument from the config page.
+ // This places the first usable config value at _ffi_closure_trampoline_table-4080
+ // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc.
+ ldr r0, [pc, #-4092]
+
+ // Load the jump address from the config page.
+ ldr pc, [pc, #-4092]
+
+
+ // trampoline
+ // Save to stack
+ stmfd sp!, {r0-r3}
+
+ // Load the context argument from the config page.
+ // This places the first usable config value at _ffi_closure_trampoline_table-4080
+ // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc.
+ ldr r0, [pc, #-4092]
+
+ // Load the jump address from the config page.
+ ldr pc, [pc, #-4092]
+
+
+ // trampoline
+ // Save to stack
+ stmfd sp!, {r0-r3}
+
+ // Load the context argument from the config page.
+ // This places the first usable config value at _ffi_closure_trampoline_table-4080
+ // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc.
+ ldr r0, [pc, #-4092]
+
+ // Load the jump address from the config page.
+ ldr pc, [pc, #-4092]
+
+
+ // trampoline
+ // Save to stack
+ stmfd sp!, {r0-r3}
+
+ // Load the context argument from the config page.
+ // This places the first usable config value at _ffi_closure_trampoline_table-4080
+ // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc.
+ ldr r0, [pc, #-4092]
+
+ // Load the jump address from the config page.
+ ldr pc, [pc, #-4092]
+
+
+ // trampoline
+ // Save to stack
+ stmfd sp!, {r0-r3}
+
+ // Load the context argument from the config page.
+ // This places the first usable config value at _ffi_closure_trampoline_table-4080
+ // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc.
+ ldr r0, [pc, #-4092]
+
+ // Load the jump address from the config page.
+ ldr pc, [pc, #-4092]
+
+
+ // trampoline
+ // Save to stack
+ stmfd sp!, {r0-r3}
+
+ // Load the context argument from the config page.
+ // This places the first usable config value at _ffi_closure_trampoline_table-4080
+ // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc.
+ ldr r0, [pc, #-4092]
+
+ // Load the jump address from the config page.
+ ldr pc, [pc, #-4092]
+
+
+ // trampoline
+ // Save to stack
+ stmfd sp!, {r0-r3}
+
+ // Load the context argument from the config page.
+ // This places the first usable config value at _ffi_closure_trampoline_table-4080
+ // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc.
+ ldr r0, [pc, #-4092]
+
+ // Load the jump address from the config page.
+ ldr pc, [pc, #-4092]
+
+
+ // trampoline
+ // Save to stack
+ stmfd sp!, {r0-r3}
+
+ // Load the context argument from the config page.
+ // This places the first usable config value at _ffi_closure_trampoline_table-4080
+ // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc.
+ ldr r0, [pc, #-4092]
+
+ // Load the jump address from the config page.
+ ldr pc, [pc, #-4092]
+
+
+ // trampoline
+ // Save to stack
+ stmfd sp!, {r0-r3}
+
+ // Load the context argument from the config page.
+ // This places the first usable config value at _ffi_closure_trampoline_table-4080
+ // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc.
+ ldr r0, [pc, #-4092]
+
+ // Load the jump address from the config page.
+ ldr pc, [pc, #-4092]
+
+
+ // trampoline
+ // Save to stack
+ stmfd sp!, {r0-r3}
+
+ // Load the context argument from the config page.
+ // This places the first usable config value at _ffi_closure_trampoline_table-4080
+ // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc.
+ ldr r0, [pc, #-4092]
+
+ // Load the jump address from the config page.
+ ldr pc, [pc, #-4092]
+
+
+ // trampoline
+ // Save to stack
+ stmfd sp!, {r0-r3}
+
+ // Load the context argument from the config page.
+ // This places the first usable config value at _ffi_closure_trampoline_table-4080
+ // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc.
+ ldr r0, [pc, #-4092]
+
+ // Load the jump address from the config page.
+ ldr pc, [pc, #-4092]
+
+
+ // trampoline
+ // Save to stack
+ stmfd sp!, {r0-r3}
+
+ // Load the context argument from the config page.
+ // This places the first usable config value at _ffi_closure_trampoline_table-4080
+ // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc.
+ ldr r0, [pc, #-4092]
+
+ // Load the jump address from the config page.
+ ldr pc, [pc, #-4092]
+
+
+ // trampoline
+ // Save to stack
+ stmfd sp!, {r0-r3}
+
+ // Load the context argument from the config page.
+ // This places the first usable config value at _ffi_closure_trampoline_table-4080
+ // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc.
+ ldr r0, [pc, #-4092]
+
+ // Load the jump address from the config page.
+ ldr pc, [pc, #-4092]
+
+
+ // trampoline
+ // Save to stack
+ stmfd sp!, {r0-r3}
+
+ // Load the context argument from the config page.
+ // This places the first usable config value at _ffi_closure_trampoline_table-4080
+ // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc.
+ ldr r0, [pc, #-4092]
+
+ // Load the jump address from the config page.
+ ldr pc, [pc, #-4092]
+
+
+ // trampoline
+ // Save to stack
+ stmfd sp!, {r0-r3}
+
+ // Load the context argument from the config page.
+ // This places the first usable config value at _ffi_closure_trampoline_table-4080
+ // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc.
+ ldr r0, [pc, #-4092]
+
+ // Load the jump address from the config page.
+ ldr pc, [pc, #-4092]
+
+
+ // trampoline
+ // Save to stack
+ stmfd sp!, {r0-r3}
+
+ // Load the context argument from the config page.
+ // This places the first usable config value at _ffi_closure_trampoline_table-4080
+ // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc.
+ ldr r0, [pc, #-4092]
+
+ // Load the jump address from the config page.
+ ldr pc, [pc, #-4092]
+
+
+ // trampoline
+ // Save to stack
+ stmfd sp!, {r0-r3}
+
+ // Load the context argument from the config page.
+ // This places the first usable config value at _ffi_closure_trampoline_table-4080
+ // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc.
+ ldr r0, [pc, #-4092]
+
+ // Load the jump address from the config page.
+ ldr pc, [pc, #-4092]
+
+
+ // trampoline
+ // Save to stack
+ stmfd sp!, {r0-r3}
+
+ // Load the context argument from the config page.
+ // This places the first usable config value at _ffi_closure_trampoline_table-4080
+ // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc.
+ ldr r0, [pc, #-4092]
+
+ // Load the jump address from the config page.
+ ldr pc, [pc, #-4092]
+
+
+ // trampoline
+ // Save to stack
+ stmfd sp!, {r0-r3}
+
+ // Load the context argument from the config page.
+ // This places the first usable config value at _ffi_closure_trampoline_table-4080
+ // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc.
+ ldr r0, [pc, #-4092]
+
+ // Load the jump address from the config page.
+ ldr pc, [pc, #-4092]
+
+
+ // trampoline
+ // Save to stack
+ stmfd sp!, {r0-r3}
+
+ // Load the context argument from the config page.
+ // This places the first usable config value at _ffi_closure_trampoline_table-4080
+ // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc.
+ ldr r0, [pc, #-4092]
+
+ // Load the jump address from the config page.
+ ldr pc, [pc, #-4092]
+
+
+ // trampoline
+ // Save to stack
+ stmfd sp!, {r0-r3}
+
+ // Load the context argument from the config page.
+ // This places the first usable config value at _ffi_closure_trampoline_table-4080
+ // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc.
+ ldr r0, [pc, #-4092]
+
+ // Load the jump address from the config page.
+ ldr pc, [pc, #-4092]
+
+
+ // trampoline
+ // Save to stack
+ stmfd sp!, {r0-r3}
+
+ // Load the context argument from the config page.
+ // This places the first usable config value at _ffi_closure_trampoline_table-4080
+ // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc.
+ ldr r0, [pc, #-4092]
+
+ // Load the jump address from the config page.
+ ldr pc, [pc, #-4092]
+
+
+ // trampoline
+ // Save to stack
+ stmfd sp!, {r0-r3}
+
+ // Load the context argument from the config page.
+ // This places the first usable config value at _ffi_closure_trampoline_table-4080
+ // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc.
+ ldr r0, [pc, #-4092]
+
+ // Load the jump address from the config page.
+ ldr pc, [pc, #-4092]
+
+
+ // trampoline
+ // Save to stack
+ stmfd sp!, {r0-r3}
+
+ // Load the context argument from the config page.
+ // This places the first usable config value at _ffi_closure_trampoline_table-4080
+ // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc.
+ ldr r0, [pc, #-4092]
+
+ // Load the jump address from the config page.
+ ldr pc, [pc, #-4092]
+
+
+ // trampoline
+ // Save to stack
+ stmfd sp!, {r0-r3}
+
+ // Load the context argument from the config page.
+ // This places the first usable config value at _ffi_closure_trampoline_table-4080
+ // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc.
+ ldr r0, [pc, #-4092]
+
+ // Load the jump address from the config page.
+ ldr pc, [pc, #-4092]
+
+
+ // trampoline
+ // Save to stack
+ stmfd sp!, {r0-r3}
+
+ // Load the context argument from the config page.
+ // This places the first usable config value at _ffi_closure_trampoline_table-4080
+ // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc.
+ ldr r0, [pc, #-4092]
+
+ // Load the jump address from the config page.
+ ldr pc, [pc, #-4092]
+
+
+ // trampoline
+ // Save to stack
+ stmfd sp!, {r0-r3}
+
+ // Load the context argument from the config page.
+ // This places the first usable config value at _ffi_closure_trampoline_table-4080
+ // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc.
+ ldr r0, [pc, #-4092]
+
+ // Load the jump address from the config page.
+ ldr pc, [pc, #-4092]
+
+
+ // trampoline
+ // Save to stack
+ stmfd sp!, {r0-r3}
+
+ // Load the context argument from the config page.
+ // This places the first usable config value at _ffi_closure_trampoline_table-4080
+ // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc.
+ ldr r0, [pc, #-4092]
+
+ // Load the jump address from the config page.
+ ldr pc, [pc, #-4092]
+
+
+ // trampoline
+ // Save to stack
+ stmfd sp!, {r0-r3}
+
+ // Load the context argument from the config page.
+ // This places the first usable config value at _ffi_closure_trampoline_table-4080
+ // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc.
+ ldr r0, [pc, #-4092]
+
+ // Load the jump address from the config page.
+ ldr pc, [pc, #-4092]
+
+
+ // trampoline
+ // Save to stack
+ stmfd sp!, {r0-r3}
+
+ // Load the context argument from the config page.
+ // This places the first usable config value at _ffi_closure_trampoline_table-4080
+ // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc.
+ ldr r0, [pc, #-4092]
+
+ // Load the jump address from the config page.
+ ldr pc, [pc, #-4092]
+
+
+ // trampoline
+ // Save to stack
+ stmfd sp!, {r0-r3}
+
+ // Load the context argument from the config page.
+ // This places the first usable config value at _ffi_closure_trampoline_table-4080
+ // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc.
+ ldr r0, [pc, #-4092]
+
+ // Load the jump address from the config page.
+ ldr pc, [pc, #-4092]
+
+
+ // trampoline
+ // Save to stack
+ stmfd sp!, {r0-r3}
+
+ // Load the context argument from the config page.
+ // This places the first usable config value at _ffi_closure_trampoline_table-4080
+ // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc.
+ ldr r0, [pc, #-4092]
+
+ // Load the jump address from the config page.
+ ldr pc, [pc, #-4092]
+
+
+ // trampoline
+ // Save to stack
+ stmfd sp!, {r0-r3}
+
+ // Load the context argument from the config page.
+ // This places the first usable config value at _ffi_closure_trampoline_table-4080
+ // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc.
+ ldr r0, [pc, #-4092]
+
+ // Load the jump address from the config page.
+ ldr pc, [pc, #-4092]
+
+
+ // trampoline
+ // Save to stack
+ stmfd sp!, {r0-r3}
+
+ // Load the context argument from the config page.
+ // This places the first usable config value at _ffi_closure_trampoline_table-4080
+ // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc.
+ ldr r0, [pc, #-4092]
+
+ // Load the jump address from the config page.
+ ldr pc, [pc, #-4092]
+
+
+ // trampoline
+ // Save to stack
+ stmfd sp!, {r0-r3}
+
+ // Load the context argument from the config page.
+ // This places the first usable config value at _ffi_closure_trampoline_table-4080
+ // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc.
+ ldr r0, [pc, #-4092]
+
+ // Load the jump address from the config page.
+ ldr pc, [pc, #-4092]
+
+
+ // trampoline
+ // Save to stack
+ stmfd sp!, {r0-r3}
+
+ // Load the context argument from the config page.
+ // This places the first usable config value at _ffi_closure_trampoline_table-4080
+ // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc.
+ ldr r0, [pc, #-4092]
+
+ // Load the jump address from the config page.
+ ldr pc, [pc, #-4092]
+
+
+ // trampoline
+ // Save to stack
+ stmfd sp!, {r0-r3}
+
+ // Load the context argument from the config page.
+ // This places the first usable config value at _ffi_closure_trampoline_table-4080
+ // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc.
+ ldr r0, [pc, #-4092]
+
+ // Load the jump address from the config page.
+ ldr pc, [pc, #-4092]
+
+
+ // trampoline
+ // Save to stack
+ stmfd sp!, {r0-r3}
+
+ // Load the context argument from the config page.
+ // This places the first usable config value at _ffi_closure_trampoline_table-4080
+ // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc.
+ ldr r0, [pc, #-4092]
+
+ // Load the jump address from the config page.
+ ldr pc, [pc, #-4092]
+
+
+ // trampoline
+ // Save to stack
+ stmfd sp!, {r0-r3}
+
+ // Load the context argument from the config page.
+ // This places the first usable config value at _ffi_closure_trampoline_table-4080
+ // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc.
+ ldr r0, [pc, #-4092]
+
+ // Load the jump address from the config page.
+ ldr pc, [pc, #-4092]
+
+
+ // trampoline
+ // Save to stack
+ stmfd sp!, {r0-r3}
+
+ // Load the context argument from the config page.
+ // This places the first usable config value at _ffi_closure_trampoline_table-4080
+ // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc.
+ ldr r0, [pc, #-4092]
+
+ // Load the jump address from the config page.
+ ldr pc, [pc, #-4092]
+
+
+ // trampoline
+ // Save to stack
+ stmfd sp!, {r0-r3}
+
+ // Load the context argument from the config page.
+ // This places the first usable config value at _ffi_closure_trampoline_table-4080
+ // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc.
+ ldr r0, [pc, #-4092]
+
+ // Load the jump address from the config page.
+ ldr pc, [pc, #-4092]
+
+
+ // trampoline
+ // Save to stack
+ stmfd sp!, {r0-r3}
+
+ // Load the context argument from the config page.
+ // This places the first usable config value at _ffi_closure_trampoline_table-4080
+ // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc.
+ ldr r0, [pc, #-4092]
+
+ // Load the jump address from the config page.
+ ldr pc, [pc, #-4092]
+
+
+ // trampoline
+ // Save to stack
+ stmfd sp!, {r0-r3}
+
+ // Load the context argument from the config page.
+ // This places the first usable config value at _ffi_closure_trampoline_table-4080
+ // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc.
+ ldr r0, [pc, #-4092]
+
+ // Load the jump address from the config page.
+ ldr pc, [pc, #-4092]
+
+
+ // trampoline
+ // Save to stack
+ stmfd sp!, {r0-r3}
+
+ // Load the context argument from the config page.
+ // This places the first usable config value at _ffi_closure_trampoline_table-4080
+ // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc.
+ ldr r0, [pc, #-4092]
+
+ // Load the jump address from the config page.
+ ldr pc, [pc, #-4092]
+
+
+ // trampoline
+ // Save to stack
+ stmfd sp!, {r0-r3}
+
+ // Load the context argument from the config page.
+ // This places the first usable config value at _ffi_closure_trampoline_table-4080
+ // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc.
+ ldr r0, [pc, #-4092]
+
+ // Load the jump address from the config page.
+ ldr pc, [pc, #-4092]
+
+
+ // trampoline
+ // Save to stack
+ stmfd sp!, {r0-r3}
+
+ // Load the context argument from the config page.
+ // This places the first usable config value at _ffi_closure_trampoline_table-4080
+ // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc.
+ ldr r0, [pc, #-4092]
+
+ // Load the jump address from the config page.
+ ldr pc, [pc, #-4092]
+
+
+ // trampoline
+ // Save to stack
+ stmfd sp!, {r0-r3}
+
+ // Load the context argument from the config page.
+ // This places the first usable config value at _ffi_closure_trampoline_table-4080
+ // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc.
+ ldr r0, [pc, #-4092]
+
+ // Load the jump address from the config page.
+ ldr pc, [pc, #-4092]
+
+
+ // trampoline
+ // Save to stack
+ stmfd sp!, {r0-r3}
+
+ // Load the context argument from the config page.
+ // This places the first usable config value at _ffi_closure_trampoline_table-4080
+ // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc.
+ ldr r0, [pc, #-4092]
+
+ // Load the jump address from the config page.
+ ldr pc, [pc, #-4092]
+
+
+ // trampoline
+ // Save to stack
+ stmfd sp!, {r0-r3}
+
+ // Load the context argument from the config page.
+ // This places the first usable config value at _ffi_closure_trampoline_table-4080
+ // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc.
+ ldr r0, [pc, #-4092]
+
+ // Load the jump address from the config page.
+ ldr pc, [pc, #-4092]
+
+
+ // trampoline
+ // Save to stack
+ stmfd sp!, {r0-r3}
+
+ // Load the context argument from the config page.
+ // This places the first usable config value at _ffi_closure_trampoline_table-4080
+ // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc.
+ ldr r0, [pc, #-4092]
+
+ // Load the jump address from the config page.
+ ldr pc, [pc, #-4092]
+
+
+ // trampoline
+ // Save to stack
+ stmfd sp!, {r0-r3}
+
+ // Load the context argument from the config page.
+ // This places the first usable config value at _ffi_closure_trampoline_table-4080
+ // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc.
+ ldr r0, [pc, #-4092]
+
+ // Load the jump address from the config page.
+ ldr pc, [pc, #-4092]
+
+
+ // trampoline
+ // Save to stack
+ stmfd sp!, {r0-r3}
+
+ // Load the context argument from the config page.
+ // This places the first usable config value at _ffi_closure_trampoline_table-4080
+ // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc.
+ ldr r0, [pc, #-4092]
+
+ // Load the jump address from the config page.
+ ldr pc, [pc, #-4092]
+
+
+ // trampoline
+ // Save to stack
+ stmfd sp!, {r0-r3}
+
+ // Load the context argument from the config page.
+ // This places the first usable config value at _ffi_closure_trampoline_table-4080
+ // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc.
+ ldr r0, [pc, #-4092]
+
+ // Load the jump address from the config page.
+ ldr pc, [pc, #-4092]
+
+
+ // trampoline
+ // Save to stack
+ stmfd sp!, {r0-r3}
+
+ // Load the context argument from the config page.
+ // This places the first usable config value at _ffi_closure_trampoline_table-4080
+ // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc.
+ ldr r0, [pc, #-4092]
+
+ // Load the jump address from the config page.
+ ldr pc, [pc, #-4092]
+
+
+ // trampoline
+ // Save to stack
+ stmfd sp!, {r0-r3}
+
+ // Load the context argument from the config page.
+ // This places the first usable config value at _ffi_closure_trampoline_table-4080
+ // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc.
+ ldr r0, [pc, #-4092]
+
+ // Load the jump address from the config page.
+ ldr pc, [pc, #-4092]
+
+
+ // trampoline
+ // Save to stack
+ stmfd sp!, {r0-r3}
+
+ // Load the context argument from the config page.
+ // This places the first usable config value at _ffi_closure_trampoline_table-4080
+ // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc.
+ ldr r0, [pc, #-4092]
+
+ // Load the jump address from the config page.
+ ldr pc, [pc, #-4092]
+
+
+ // trampoline
+ // Save to stack
+ stmfd sp!, {r0-r3}
+
+ // Load the context argument from the config page.
+ // This places the first usable config value at _ffi_closure_trampoline_table-4080
+ // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc.
+ ldr r0, [pc, #-4092]
+
+ // Load the jump address from the config page.
+ ldr pc, [pc, #-4092]
+
+
+ // trampoline
+ // Save to stack
+ stmfd sp!, {r0-r3}
+
+ // Load the context argument from the config page.
+ // This places the first usable config value at _ffi_closure_trampoline_table-4080
+ // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc.
+ ldr r0, [pc, #-4092]
+
+ // Load the jump address from the config page.
+ ldr pc, [pc, #-4092]
+
+
+ // trampoline
+ // Save to stack
+ stmfd sp!, {r0-r3}
+
+ // Load the context argument from the config page.
+ // This places the first usable config value at _ffi_closure_trampoline_table-4080
+ // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc.
+ ldr r0, [pc, #-4092]
+
+ // Load the jump address from the config page.
+ ldr pc, [pc, #-4092]
+
+
+ // trampoline
+ // Save to stack
+ stmfd sp!, {r0-r3}
+
+ // Load the context argument from the config page.
+ // This places the first usable config value at _ffi_closure_trampoline_table-4080
+ // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc.
+ ldr r0, [pc, #-4092]
+
+ // Load the jump address from the config page.
+ ldr pc, [pc, #-4092]
+
+
+ // trampoline
+ // Save to stack
+ stmfd sp!, {r0-r3}
+
+ // Load the context argument from the config page.
+ // This places the first usable config value at _ffi_closure_trampoline_table-4080
+ // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc.
+ ldr r0, [pc, #-4092]
+
+ // Load the jump address from the config page.
+ ldr pc, [pc, #-4092]
+
+
+ // trampoline
+ // Save to stack
+ stmfd sp!, {r0-r3}
+
+ // Load the context argument from the config page.
+ // This places the first usable config value at _ffi_closure_trampoline_table-4080
+ // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc.
+ ldr r0, [pc, #-4092]
+
+ // Load the jump address from the config page.
+ ldr pc, [pc, #-4092]
+
+
+ // trampoline
+ // Save to stack
+ stmfd sp!, {r0-r3}
+
+ // Load the context argument from the config page.
+ // This places the first usable config value at _ffi_closure_trampoline_table-4080
+ // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc.
+ ldr r0, [pc, #-4092]
+
+ // Load the jump address from the config page.
+ ldr pc, [pc, #-4092]
+
+
+ // trampoline
+ // Save to stack
+ stmfd sp!, {r0-r3}
+
+ // Load the context argument from the config page.
+ // This places the first usable config value at _ffi_closure_trampoline_table-4080
+ // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc.
+ ldr r0, [pc, #-4092]
+
+ // Load the jump address from the config page.
+ ldr pc, [pc, #-4092]
+
+
+ // trampoline
+ // Save to stack
+ stmfd sp!, {r0-r3}
+
+ // Load the context argument from the config page.
+ // This places the first usable config value at _ffi_closure_trampoline_table-4080
+ // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc.
+ ldr r0, [pc, #-4092]
+
+ // Load the jump address from the config page.
+ ldr pc, [pc, #-4092]
+
+
+ // trampoline
+ // Save to stack
+ stmfd sp!, {r0-r3}
+
+ // Load the context argument from the config page.
+ // This places the first usable config value at _ffi_closure_trampoline_table-4080
+ // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc.
+ ldr r0, [pc, #-4092]
+
+ // Load the jump address from the config page.
+ ldr pc, [pc, #-4092]
+
+
+ // trampoline
+ // Save to stack
+ stmfd sp!, {r0-r3}
+
+ // Load the context argument from the config page.
+ // This places the first usable config value at _ffi_closure_trampoline_table-4080
+ // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc.
+ ldr r0, [pc, #-4092]
+
+ // Load the jump address from the config page.
+ ldr pc, [pc, #-4092]
+
+
+ // trampoline
+ // Save to stack
+ stmfd sp!, {r0-r3}
+
+ // Load the context argument from the config page.
+ // This places the first usable config value at _ffi_closure_trampoline_table-4080
+ // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc.
+ ldr r0, [pc, #-4092]
+
+ // Load the jump address from the config page.
+ ldr pc, [pc, #-4092]
+
+
+ // trampoline
+ // Save to stack
+ stmfd sp!, {r0-r3}
+
+ // Load the context argument from the config page.
+ // This places the first usable config value at _ffi_closure_trampoline_table-4080
+ // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc.
+ ldr r0, [pc, #-4092]
+
+ // Load the jump address from the config page.
+ ldr pc, [pc, #-4092]
+
+
+ // trampoline
+ // Save to stack
+ stmfd sp!, {r0-r3}
+
+ // Load the context argument from the config page.
+ // This places the first usable config value at _ffi_closure_trampoline_table-4080
+ // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc.
+ ldr r0, [pc, #-4092]
+
+ // Load the jump address from the config page.
+ ldr pc, [pc, #-4092]
+
+
+ // trampoline
+ // Save to stack
+ stmfd sp!, {r0-r3}
+
+ // Load the context argument from the config page.
+ // This places the first usable config value at _ffi_closure_trampoline_table-4080
+ // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc.
+ ldr r0, [pc, #-4092]
+
+ // Load the jump address from the config page.
+ ldr pc, [pc, #-4092]
+
+
+ // trampoline
+ // Save to stack
+ stmfd sp!, {r0-r3}
+
+ // Load the context argument from the config page.
+ // This places the first usable config value at _ffi_closure_trampoline_table-4080
+ // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc.
+ ldr r0, [pc, #-4092]
+
+ // Load the jump address from the config page.
+ ldr pc, [pc, #-4092]
+
+
+ // trampoline
+ // Save to stack
+ stmfd sp!, {r0-r3}
+
+ // Load the context argument from the config page.
+ // This places the first usable config value at _ffi_closure_trampoline_table-4080
+ // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc.
+ ldr r0, [pc, #-4092]
+
+ // Load the jump address from the config page.
+ ldr pc, [pc, #-4092]
+
+
+ // trampoline
+ // Save to stack
+ stmfd sp!, {r0-r3}
+
+ // Load the context argument from the config page.
+ // This places the first usable config value at _ffi_closure_trampoline_table-4080
+ // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc.
+ ldr r0, [pc, #-4092]
+
+ // Load the jump address from the config page.
+ ldr pc, [pc, #-4092]
+
+
+ // trampoline
+ // Save to stack
+ stmfd sp!, {r0-r3}
+
+ // Load the context argument from the config page.
+ // This places the first usable config value at _ffi_closure_trampoline_table-4080
+ // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc.
+ ldr r0, [pc, #-4092]
+
+ // Load the jump address from the config page.
+ ldr pc, [pc, #-4092]
+
+
+ // trampoline
+ // Save to stack
+ stmfd sp!, {r0-r3}
+
+ // Load the context argument from the config page.
+ // This places the first usable config value at _ffi_closure_trampoline_table-4080
+ // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc.
+ ldr r0, [pc, #-4092]
+
+ // Load the jump address from the config page.
+ ldr pc, [pc, #-4092]
+
+
+ // trampoline
+ // Save to stack
+ stmfd sp!, {r0-r3}
+
+ // Load the context argument from the config page.
+ // This places the first usable config value at _ffi_closure_trampoline_table-4080
+ // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc.
+ ldr r0, [pc, #-4092]
+
+ // Load the jump address from the config page.
+ ldr pc, [pc, #-4092]
+
+
+ // trampoline
+ // Save to stack
+ stmfd sp!, {r0-r3}
+
+ // Load the context argument from the config page.
+ // This places the first usable config value at _ffi_closure_trampoline_table-4080
+ // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc.
+ ldr r0, [pc, #-4092]
+
+ // Load the jump address from the config page.
+ ldr pc, [pc, #-4092]
+
+
+ // trampoline
+ // Save to stack
+ stmfd sp!, {r0-r3}
+
+ // Load the context argument from the config page.
+ // This places the first usable config value at _ffi_closure_trampoline_table-4080
+ // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc.
+ ldr r0, [pc, #-4092]
+
+ // Load the jump address from the config page.
+ ldr pc, [pc, #-4092]
+
+
+ // trampoline
+ // Save to stack
+ stmfd sp!, {r0-r3}
+
+ // Load the context argument from the config page.
+ // This places the first usable config value at _ffi_closure_trampoline_table-4080
+ // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc.
+ ldr r0, [pc, #-4092]
+
+ // Load the jump address from the config page.
+ ldr pc, [pc, #-4092]
+
+
+ // trampoline
+ // Save to stack
+ stmfd sp!, {r0-r3}
+
+ // Load the context argument from the config page.
+ // This places the first usable config value at _ffi_closure_trampoline_table-4080
+ // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc.
+ ldr r0, [pc, #-4092]
+
+ // Load the jump address from the config page.
+ ldr pc, [pc, #-4092]
+
+
+ // trampoline
+ // Save to stack
+ stmfd sp!, {r0-r3}
+
+ // Load the context argument from the config page.
+ // This places the first usable config value at _ffi_closure_trampoline_table-4080
+ // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc.
+ ldr r0, [pc, #-4092]
+
+ // Load the jump address from the config page.
+ ldr pc, [pc, #-4092]
+
+
+ // trampoline
+ // Save to stack
+ stmfd sp!, {r0-r3}
+
+ // Load the context argument from the config page.
+ // This places the first usable config value at _ffi_closure_trampoline_table-4080
+ // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc.
+ ldr r0, [pc, #-4092]
+
+ // Load the jump address from the config page.
+ ldr pc, [pc, #-4092]
+
+
+ // trampoline
+ // Save to stack
+ stmfd sp!, {r0-r3}
+
+ // Load the context argument from the config page.
+ // This places the first usable config value at _ffi_closure_trampoline_table-4080
+ // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc.
+ ldr r0, [pc, #-4092]
+
+ // Load the jump address from the config page.
+ ldr pc, [pc, #-4092]
+
+
+ // trampoline
+ // Save to stack
+ stmfd sp!, {r0-r3}
+
+ // Load the context argument from the config page.
+ // This places the first usable config value at _ffi_closure_trampoline_table-4080
+ // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc.
+ ldr r0, [pc, #-4092]
+
+ // Load the jump address from the config page.
+ ldr pc, [pc, #-4092]
+
+
+ // trampoline
+ // Save to stack
+ stmfd sp!, {r0-r3}
+
+ // Load the context argument from the config page.
+ // This places the first usable config value at _ffi_closure_trampoline_table-4080
+ // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc.
+ ldr r0, [pc, #-4092]
+
+ // Load the jump address from the config page.
+ ldr pc, [pc, #-4092]
+
+
+ // trampoline
+ // Save to stack
+ stmfd sp!, {r0-r3}
+
+ // Load the context argument from the config page.
+ // This places the first usable config value at _ffi_closure_trampoline_table-4080
+ // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc.
+ ldr r0, [pc, #-4092]
+
+ // Load the jump address from the config page.
+ ldr pc, [pc, #-4092]
+
+
+ // trampoline
+ // Save to stack
+ stmfd sp!, {r0-r3}
+
+ // Load the context argument from the config page.
+ // This places the first usable config value at _ffi_closure_trampoline_table-4080
+ // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc.
+ ldr r0, [pc, #-4092]
+
+ // Load the jump address from the config page.
+ ldr pc, [pc, #-4092]
+
+
+ // trampoline
+ // Save to stack
+ stmfd sp!, {r0-r3}
+
+ // Load the context argument from the config page.
+ // This places the first usable config value at _ffi_closure_trampoline_table-4080
+ // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc.
+ ldr r0, [pc, #-4092]
+
+ // Load the jump address from the config page.
+ ldr pc, [pc, #-4092]
+
+
+ // trampoline
+ // Save to stack
+ stmfd sp!, {r0-r3}
+
+ // Load the context argument from the config page.
+ // This places the first usable config value at _ffi_closure_trampoline_table-4080
+ // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc.
+ ldr r0, [pc, #-4092]
+
+ // Load the jump address from the config page.
+ ldr pc, [pc, #-4092]
+
+
+ // trampoline
+ // Save to stack
+ stmfd sp!, {r0-r3}
+
+ // Load the context argument from the config page.
+ // This places the first usable config value at _ffi_closure_trampoline_table-4080
+ // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc.
+ ldr r0, [pc, #-4092]
+
+ // Load the jump address from the config page.
+ ldr pc, [pc, #-4092]
+
+
+ // trampoline
+ // Save to stack
+ stmfd sp!, {r0-r3}
+
+ // Load the context argument from the config page.
+ // This places the first usable config value at _ffi_closure_trampoline_table-4080
+ // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc.
+ ldr r0, [pc, #-4092]
+
+ // Load the jump address from the config page.
+ ldr pc, [pc, #-4092]
+
+
+ // trampoline
+ // Save to stack
+ stmfd sp!, {r0-r3}
+
+ // Load the context argument from the config page.
+ // This places the first usable config value at _ffi_closure_trampoline_table-4080
+ // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc.
+ ldr r0, [pc, #-4092]
+
+ // Load the jump address from the config page.
+ ldr pc, [pc, #-4092]
+
+
+ // trampoline
+ // Save to stack
+ stmfd sp!, {r0-r3}
+
+ // Load the context argument from the config page.
+ // This places the first usable config value at _ffi_closure_trampoline_table-4080
+ // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc.
+ ldr r0, [pc, #-4092]
+
+ // Load the jump address from the config page.
+ ldr pc, [pc, #-4092]
+
+
+ // trampoline
+ // Save to stack
+ stmfd sp!, {r0-r3}
+
+ // Load the context argument from the config page.
+ // This places the first usable config value at _ffi_closure_trampoline_table-4080
+ // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc.
+ ldr r0, [pc, #-4092]
+
+ // Load the jump address from the config page.
+ ldr pc, [pc, #-4092]
+
+
+ // trampoline
+ // Save to stack
+ stmfd sp!, {r0-r3}
+
+ // Load the context argument from the config page.
+ // This places the first usable config value at _ffi_closure_trampoline_table-4080
+ // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc.
+ ldr r0, [pc, #-4092]
+
+ // Load the jump address from the config page.
+ ldr pc, [pc, #-4092]
+
+
+ // trampoline
+ // Save to stack
+ stmfd sp!, {r0-r3}
+
+ // Load the context argument from the config page.
+ // This places the first usable config value at _ffi_closure_trampoline_table-4080
+ // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc.
+ ldr r0, [pc, #-4092]
+
+ // Load the jump address from the config page.
+ ldr pc, [pc, #-4092]
+
+
+ // trampoline
+ // Save to stack
+ stmfd sp!, {r0-r3}
+
+ // Load the context argument from the config page.
+ // This places the first usable config value at _ffi_closure_trampoline_table-4080
+ // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc.
+ ldr r0, [pc, #-4092]
+
+ // Load the jump address from the config page.
+ ldr pc, [pc, #-4092]
+
+
+ // trampoline
+ // Save to stack
+ stmfd sp!, {r0-r3}
+
+ // Load the context argument from the config page.
+ // This places the first usable config value at _ffi_closure_trampoline_table-4080
+ // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc.
+ ldr r0, [pc, #-4092]
+
+ // Load the jump address from the config page.
+ ldr pc, [pc, #-4092]
+
+
+ // trampoline
+ // Save to stack
+ stmfd sp!, {r0-r3}
+
+ // Load the context argument from the config page.
+ // This places the first usable config value at _ffi_closure_trampoline_table-4080
+ // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc.
+ ldr r0, [pc, #-4092]
+
+ // Load the jump address from the config page.
+ ldr pc, [pc, #-4092]
+
+
+ // trampoline
+ // Save to stack
+ stmfd sp!, {r0-r3}
+
+ // Load the context argument from the config page.
+ // This places the first usable config value at _ffi_closure_trampoline_table-4080
+ // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc.
+ ldr r0, [pc, #-4092]
+
+ // Load the jump address from the config page.
+ ldr pc, [pc, #-4092]
+
+
+ // trampoline
+ // Save to stack
+ stmfd sp!, {r0-r3}
+
+ // Load the context argument from the config page.
+ // This places the first usable config value at _ffi_closure_trampoline_table-4080
+ // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc.
+ ldr r0, [pc, #-4092]
+
+ // Load the jump address from the config page.
+ ldr pc, [pc, #-4092]
+
+
+ // trampoline
+ // Save to stack
+ stmfd sp!, {r0-r3}
+
+ // Load the context argument from the config page.
+ // This places the first usable config value at _ffi_closure_trampoline_table-4080
+ // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc.
+ ldr r0, [pc, #-4092]
+
+ // Load the jump address from the config page.
+ ldr pc, [pc, #-4092]
+
+
+ // trampoline
+ // Save to stack
+ stmfd sp!, {r0-r3}
+
+ // Load the context argument from the config page.
+ // This places the first usable config value at _ffi_closure_trampoline_table-4080
+ // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc.
+ ldr r0, [pc, #-4092]
+
+ // Load the jump address from the config page.
+ ldr pc, [pc, #-4092]
+
+
+ // trampoline
+ // Save to stack
+ stmfd sp!, {r0-r3}
+
+ // Load the context argument from the config page.
+ // This places the first usable config value at _ffi_closure_trampoline_table-4080
+ // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc.
+ ldr r0, [pc, #-4092]
+
+ // Load the jump address from the config page.
+ ldr pc, [pc, #-4092]
+
+
+ // trampoline
+ // Save to stack
+ stmfd sp!, {r0-r3}
+
+ // Load the context argument from the config page.
+ // This places the first usable config value at _ffi_closure_trampoline_table-4080
+ // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc.
+ ldr r0, [pc, #-4092]
+
+ // Load the jump address from the config page.
+ ldr pc, [pc, #-4092]
+
+
+ // trampoline
+ // Save to stack
+ stmfd sp!, {r0-r3}
+
+ // Load the context argument from the config page.
+ // This places the first usable config value at _ffi_closure_trampoline_table-4080
+ // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc.
+ ldr r0, [pc, #-4092]
+
+ // Load the jump address from the config page.
+ ldr pc, [pc, #-4092]
+
+
+ // trampoline
+ // Save to stack
+ stmfd sp!, {r0-r3}
+
+ // Load the context argument from the config page.
+ // This places the first usable config value at _ffi_closure_trampoline_table-4080
+ // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc.
+ ldr r0, [pc, #-4092]
+
+ // Load the jump address from the config page.
+ ldr pc, [pc, #-4092]
+
+
+ // trampoline
+ // Save to stack
+ stmfd sp!, {r0-r3}
+
+ // Load the context argument from the config page.
+ // This places the first usable config value at _ffi_closure_trampoline_table-4080
+ // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc.
+ ldr r0, [pc, #-4092]
+
+ // Load the jump address from the config page.
+ ldr pc, [pc, #-4092]
+
+
+ // trampoline
+ // Save to stack
+ stmfd sp!, {r0-r3}
+
+ // Load the context argument from the config page.
+ // This places the first usable config value at _ffi_closure_trampoline_table-4080
+ // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc.
+ ldr r0, [pc, #-4092]
+
+ // Load the jump address from the config page.
+ ldr pc, [pc, #-4092]
+
+
+ // trampoline
+ // Save to stack
+ stmfd sp!, {r0-r3}
+
+ // Load the context argument from the config page.
+ // This places the first usable config value at _ffi_closure_trampoline_table-4080
+ // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc.
+ ldr r0, [pc, #-4092]
+
+ // Load the jump address from the config page.
+ ldr pc, [pc, #-4092]
+
+
+ // trampoline
+ // Save to stack
+ stmfd sp!, {r0-r3}
+
+ // Load the context argument from the config page.
+ // This places the first usable config value at _ffi_closure_trampoline_table-4080
+ // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc.
+ ldr r0, [pc, #-4092]
+
+ // Load the jump address from the config page.
+ ldr pc, [pc, #-4092]
+
+
+ // trampoline
+ // Save to stack
+ stmfd sp!, {r0-r3}
+
+ // Load the context argument from the config page.
+ // This places the first usable config value at _ffi_closure_trampoline_table-4080
+ // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc.
+ ldr r0, [pc, #-4092]
+
+ // Load the jump address from the config page.
+ ldr pc, [pc, #-4092]
+
+
+ // trampoline
+ // Save to stack
+ stmfd sp!, {r0-r3}
+
+ // Load the context argument from the config page.
+ // This places the first usable config value at _ffi_closure_trampoline_table-4080
+ // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc.
+ ldr r0, [pc, #-4092]
+
+ // Load the jump address from the config page.
+ ldr pc, [pc, #-4092]
+
+
+ // trampoline
+ // Save to stack
+ stmfd sp!, {r0-r3}
+
+ // Load the context argument from the config page.
+ // This places the first usable config value at _ffi_closure_trampoline_table-4080
+ // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc.
+ ldr r0, [pc, #-4092]
+
+ // Load the jump address from the config page.
+ ldr pc, [pc, #-4092]
+
+
+ // trampoline
+ // Save to stack
+ stmfd sp!, {r0-r3}
+
+ // Load the context argument from the config page.
+ // This places the first usable config value at _ffi_closure_trampoline_table-4080
+ // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc.
+ ldr r0, [pc, #-4092]
+
+ // Load the jump address from the config page.
+ ldr pc, [pc, #-4092]
+
+
+ // trampoline
+ // Save to stack
+ stmfd sp!, {r0-r3}
+
+ // Load the context argument from the config page.
+ // This places the first usable config value at _ffi_closure_trampoline_table-4080
+ // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc.
+ ldr r0, [pc, #-4092]
+
+ // Load the jump address from the config page.
+ ldr pc, [pc, #-4092]
+
+
+ // trampoline
+ // Save to stack
+ stmfd sp!, {r0-r3}
+
+ // Load the context argument from the config page.
+ // This places the first usable config value at _ffi_closure_trampoline_table-4080
+ // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc.
+ ldr r0, [pc, #-4092]
+
+ // Load the jump address from the config page.
+ ldr pc, [pc, #-4092]
+
+
+ // trampoline
+ // Save to stack
+ stmfd sp!, {r0-r3}
+
+ // Load the context argument from the config page.
+ // This places the first usable config value at _ffi_closure_trampoline_table-4080
+ // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc.
+ ldr r0, [pc, #-4092]
+
+ // Load the jump address from the config page.
+ ldr pc, [pc, #-4092]
+
+
+ // trampoline
+ // Save to stack
+ stmfd sp!, {r0-r3}
+
+ // Load the context argument from the config page.
+ // This places the first usable config value at _ffi_closure_trampoline_table-4080
+ // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc.
+ ldr r0, [pc, #-4092]
+
+ // Load the jump address from the config page.
+ ldr pc, [pc, #-4092]
+
+
+ // trampoline
+ // Save to stack
+ stmfd sp!, {r0-r3}
+
+ // Load the context argument from the config page.
+ // This places the first usable config value at _ffi_closure_trampoline_table-4080
+ // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc.
+ ldr r0, [pc, #-4092]
+
+ // Load the jump address from the config page.
+ ldr pc, [pc, #-4092]
+
+
+ // trampoline
+ // Save to stack
+ stmfd sp!, {r0-r3}
+
+ // Load the context argument from the config page.
+ // This places the first usable config value at _ffi_closure_trampoline_table-4080
+ // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc.
+ ldr r0, [pc, #-4092]
+
+ // Load the jump address from the config page.
+ ldr pc, [pc, #-4092]
+
+
+ // trampoline
+ // Save to stack
+ stmfd sp!, {r0-r3}
+
+ // Load the context argument from the config page.
+ // This places the first usable config value at _ffi_closure_trampoline_table-4080
+ // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc.
+ ldr r0, [pc, #-4092]
+
+ // Load the jump address from the config page.
+ ldr pc, [pc, #-4092]
+
+
+ // trampoline
+ // Save to stack
+ stmfd sp!, {r0-r3}
+
+ // Load the context argument from the config page.
+ // This places the first usable config value at _ffi_closure_trampoline_table-4080
+ // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc.
+ ldr r0, [pc, #-4092]
+
+ // Load the jump address from the config page.
+ ldr pc, [pc, #-4092]
+
+
+ // trampoline
+ // Save to stack
+ stmfd sp!, {r0-r3}
+
+ // Load the context argument from the config page.
+ // This places the first usable config value at _ffi_closure_trampoline_table-4080
+ // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc.
+ ldr r0, [pc, #-4092]
+
+ // Load the jump address from the config page.
+ ldr pc, [pc, #-4092]
+
+
+ // trampoline
+ // Save to stack
+ stmfd sp!, {r0-r3}
+
+ // Load the context argument from the config page.
+ // This places the first usable config value at _ffi_closure_trampoline_table-4080
+ // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc.
+ ldr r0, [pc, #-4092]
+
+ // Load the jump address from the config page.
+ ldr pc, [pc, #-4092]
+
+
+ // trampoline
+ // Save to stack
+ stmfd sp!, {r0-r3}
+
+ // Load the context argument from the config page.
+ // This places the first usable config value at _ffi_closure_trampoline_table-4080
+ // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc.
+ ldr r0, [pc, #-4092]
+
+ // Load the jump address from the config page.
+ ldr pc, [pc, #-4092]
+
+
+ // trampoline
+ // Save to stack
+ stmfd sp!, {r0-r3}
+
+ // Load the context argument from the config page.
+ // This places the first usable config value at _ffi_closure_trampoline_table-4080
+ // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc.
+ ldr r0, [pc, #-4092]
+
+ // Load the jump address from the config page.
+ ldr pc, [pc, #-4092]
+
+
+ // trampoline
+ // Save to stack
+ stmfd sp!, {r0-r3}
+
+ // Load the context argument from the config page.
+ // This places the first usable config value at _ffi_closure_trampoline_table-4080
+ // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc.
+ ldr r0, [pc, #-4092]
+
+ // Load the jump address from the config page.
+ ldr pc, [pc, #-4092]
+
+
+ // trampoline
+ // Save to stack
+ stmfd sp!, {r0-r3}
+
+ // Load the context argument from the config page.
+ // This places the first usable config value at _ffi_closure_trampoline_table-4080
+ // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc.
+ ldr r0, [pc, #-4092]
+
+ // Load the jump address from the config page.
+ ldr pc, [pc, #-4092]
+
+
+ // trampoline
+ // Save to stack
+ stmfd sp!, {r0-r3}
+
+ // Load the context argument from the config page.
+ // This places the first usable config value at _ffi_closure_trampoline_table-4080
+ // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc.
+ ldr r0, [pc, #-4092]
+
+ // Load the jump address from the config page.
+ ldr pc, [pc, #-4092]
+
+
+ // trampoline
+ // Save to stack
+ stmfd sp!, {r0-r3}
+
+ // Load the context argument from the config page.
+ // This places the first usable config value at _ffi_closure_trampoline_table-4080
+ // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc.
+ ldr r0, [pc, #-4092]
+
+ // Load the jump address from the config page.
+ ldr pc, [pc, #-4092]
+
+
+ // trampoline
+ // Save to stack
+ stmfd sp!, {r0-r3}
+
+ // Load the context argument from the config page.
+ // This places the first usable config value at _ffi_closure_trampoline_table-4080
+ // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc.
+ ldr r0, [pc, #-4092]
+
+ // Load the jump address from the config page.
+ ldr pc, [pc, #-4092]
+
+
+ // trampoline
+ // Save to stack
+ stmfd sp!, {r0-r3}
+
+ // Load the context argument from the config page.
+ // This places the first usable config value at _ffi_closure_trampoline_table-4080
+ // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc.
+ ldr r0, [pc, #-4092]
+
+ // Load the jump address from the config page.
+ ldr pc, [pc, #-4092]
+
+
+ // trampoline
+ // Save to stack
+ stmfd sp!, {r0-r3}
+
+ // Load the context argument from the config page.
+ // This places the first usable config value at _ffi_closure_trampoline_table-4080
+ // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc.
+ ldr r0, [pc, #-4092]
+
+ // Load the jump address from the config page.
+ ldr pc, [pc, #-4092]
+
+
+ // trampoline
+ // Save to stack
+ stmfd sp!, {r0-r3}
+
+ // Load the context argument from the config page.
+ // This places the first usable config value at _ffi_closure_trampoline_table-4080
+ // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc.
+ ldr r0, [pc, #-4092]
+
+ // Load the jump address from the config page.
+ ldr pc, [pc, #-4092]
+
+
+ // trampoline
+ // Save to stack
+ stmfd sp!, {r0-r3}
+
+ // Load the context argument from the config page.
+ // This places the first usable config value at _ffi_closure_trampoline_table-4080
+ // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc.
+ ldr r0, [pc, #-4092]
+
+ // Load the jump address from the config page.
+ ldr pc, [pc, #-4092]
+
+
+ // trampoline
+ // Save to stack
+ stmfd sp!, {r0-r3}
+
+ // Load the context argument from the config page.
+ // This places the first usable config value at _ffi_closure_trampoline_table-4080
+ // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc.
+ ldr r0, [pc, #-4092]
+
+ // Load the jump address from the config page.
+ ldr pc, [pc, #-4092]
+
+
+ // trampoline
+ // Save to stack
+ stmfd sp!, {r0-r3}
+
+ // Load the context argument from the config page.
+ // This places the first usable config value at _ffi_closure_trampoline_table-4080
+ // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc.
+ ldr r0, [pc, #-4092]
+
+ // Load the jump address from the config page.
+ ldr pc, [pc, #-4092]
+
+
+ // trampoline
+ // Save to stack
+ stmfd sp!, {r0-r3}
+
+ // Load the context argument from the config page.
+ // This places the first usable config value at _ffi_closure_trampoline_table-4080
+ // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc.
+ ldr r0, [pc, #-4092]
+
+ // Load the jump address from the config page.
+ ldr pc, [pc, #-4092]
+
+
+ // trampoline
+ // Save to stack
+ stmfd sp!, {r0-r3}
+
+ // Load the context argument from the config page.
+ // This places the first usable config value at _ffi_closure_trampoline_table-4080
+ // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc.
+ ldr r0, [pc, #-4092]
+
+ // Load the jump address from the config page.
+ ldr pc, [pc, #-4092]
+
+
+ // trampoline
+ // Save to stack
+ stmfd sp!, {r0-r3}
+
+ // Load the context argument from the config page.
+ // This places the first usable config value at _ffi_closure_trampoline_table-4080
+ // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc.
+ ldr r0, [pc, #-4092]
+
+ // Load the jump address from the config page.
+ ldr pc, [pc, #-4092]
+
+
+ // trampoline
+ // Save to stack
+ stmfd sp!, {r0-r3}
+
+ // Load the context argument from the config page.
+ // This places the first usable config value at _ffi_closure_trampoline_table-4080
+ // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc.
+ ldr r0, [pc, #-4092]
+
+ // Load the jump address from the config page.
+ ldr pc, [pc, #-4092]
+
+
+ // trampoline
+ // Save to stack
+ stmfd sp!, {r0-r3}
+
+ // Load the context argument from the config page.
+ // This places the first usable config value at _ffi_closure_trampoline_table-4080
+ // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc.
+ ldr r0, [pc, #-4092]
+
+ // Load the jump address from the config page.
+ ldr pc, [pc, #-4092]
+
+
+ // trampoline
+ // Save to stack
+ stmfd sp!, {r0-r3}
+
+ // Load the context argument from the config page.
+ // This places the first usable config value at _ffi_closure_trampoline_table-4080
+ // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc.
+ ldr r0, [pc, #-4092]
+
+ // Load the jump address from the config page.
+ ldr pc, [pc, #-4092]
+
+
+ // trampoline
+ // Save to stack
+ stmfd sp!, {r0-r3}
+
+ // Load the context argument from the config page.
+ // This places the first usable config value at _ffi_closure_trampoline_table-4080
+ // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc.
+ ldr r0, [pc, #-4092]
+
+ // Load the jump address from the config page.
+ ldr pc, [pc, #-4092]
+
+
+ // trampoline
+ // Save to stack
+ stmfd sp!, {r0-r3}
+
+ // Load the context argument from the config page.
+ // This places the first usable config value at _ffi_closure_trampoline_table-4080
+ // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc.
+ ldr r0, [pc, #-4092]
+
+ // Load the jump address from the config page.
+ ldr pc, [pc, #-4092]
+
+
+ // trampoline
+ // Save to stack
+ stmfd sp!, {r0-r3}
+
+ // Load the context argument from the config page.
+ // This places the first usable config value at _ffi_closure_trampoline_table-4080
+ // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc.
+ ldr r0, [pc, #-4092]
+
+ // Load the jump address from the config page.
+ ldr pc, [pc, #-4092]
+
+
+ // trampoline
+ // Save to stack
+ stmfd sp!, {r0-r3}
+
+ // Load the context argument from the config page.
+ // This places the first usable config value at _ffi_closure_trampoline_table-4080
+ // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc.
+ ldr r0, [pc, #-4092]
+
+ // Load the jump address from the config page.
+ ldr pc, [pc, #-4092]
+
+
+ // trampoline
+ // Save to stack
+ stmfd sp!, {r0-r3}
+
+ // Load the context argument from the config page.
+ // This places the first usable config value at _ffi_closure_trampoline_table-4080
+ // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc.
+ ldr r0, [pc, #-4092]
+
+ // Load the jump address from the config page.
+ ldr pc, [pc, #-4092]
+
+
+ // trampoline
+ // Save to stack
+ stmfd sp!, {r0-r3}
+
+ // Load the context argument from the config page.
+ // This places the first usable config value at _ffi_closure_trampoline_table-4080
+ // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc.
+ ldr r0, [pc, #-4092]
+
+ // Load the jump address from the config page.
+ ldr pc, [pc, #-4092]
+
+
+ // trampoline
+ // Save to stack
+ stmfd sp!, {r0-r3}
+
+ // Load the context argument from the config page.
+ // This places the first usable config value at _ffi_closure_trampoline_table-4080
+ // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc.
+ ldr r0, [pc, #-4092]
+
+ // Load the jump address from the config page.
+ ldr pc, [pc, #-4092]
+
+
+ // trampoline
+ // Save to stack
+ stmfd sp!, {r0-r3}
+
+ // Load the context argument from the config page.
+ // This places the first usable config value at _ffi_closure_trampoline_table-4080
+ // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc.
+ ldr r0, [pc, #-4092]
+
+ // Load the jump address from the config page.
+ ldr pc, [pc, #-4092]
+
+
+ // trampoline
+ // Save to stack
+ stmfd sp!, {r0-r3}
+
+ // Load the context argument from the config page.
+ // This places the first usable config value at _ffi_closure_trampoline_table-4080
+ // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc.
+ ldr r0, [pc, #-4092]
+
+ // Load the jump address from the config page.
+ ldr pc, [pc, #-4092]
+
+
+ // trampoline
+ // Save to stack
+ stmfd sp!, {r0-r3}
+
+ // Load the context argument from the config page.
+ // This places the first usable config value at _ffi_closure_trampoline_table-4080
+ // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc.
+ ldr r0, [pc, #-4092]
+
+ // Load the jump address from the config page.
+ ldr pc, [pc, #-4092]
+
+
+ // trampoline
+ // Save to stack
+ stmfd sp!, {r0-r3}
+
+ // Load the context argument from the config page.
+ // This places the first usable config value at _ffi_closure_trampoline_table-4080
+ // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc.
+ ldr r0, [pc, #-4092]
+
+ // Load the jump address from the config page.
+ ldr pc, [pc, #-4092]
+
+
+ // trampoline
+ // Save to stack
+ stmfd sp!, {r0-r3}
+
+ // Load the context argument from the config page.
+ // This places the first usable config value at _ffi_closure_trampoline_table-4080
+ // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc.
+ ldr r0, [pc, #-4092]
+
+ // Load the jump address from the config page.
+ ldr pc, [pc, #-4092]
+
+
+ // trampoline
+ // Save to stack
+ stmfd sp!, {r0-r3}
+
+ // Load the context argument from the config page.
+ // This places the first usable config value at _ffi_closure_trampoline_table-4080
+ // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc.
+ ldr r0, [pc, #-4092]
+
+ // Load the jump address from the config page.
+ ldr pc, [pc, #-4092]
+
+
+ // trampoline
+ // Save to stack
+ stmfd sp!, {r0-r3}
+
+ // Load the context argument from the config page.
+ // This places the first usable config value at _ffi_closure_trampoline_table-4080
+ // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc.
+ ldr r0, [pc, #-4092]
+
+ // Load the jump address from the config page.
+ ldr pc, [pc, #-4092]
+
+
+ // trampoline
+ // Save to stack
+ stmfd sp!, {r0-r3}
+
+ // Load the context argument from the config page.
+ // This places the first usable config value at _ffi_closure_trampoline_table-4080
+ // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc.
+ ldr r0, [pc, #-4092]
+
+ // Load the jump address from the config page.
+ ldr pc, [pc, #-4092]
+
+
+ // trampoline
+ // Save to stack
+ stmfd sp!, {r0-r3}
+
+ // Load the context argument from the config page.
+ // This places the first usable config value at _ffi_closure_trampoline_table-4080
+ // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc.
+ ldr r0, [pc, #-4092]
+
+ // Load the jump address from the config page.
+ ldr pc, [pc, #-4092]
+
+
+ // trampoline
+ // Save to stack
+ stmfd sp!, {r0-r3}
+
+ // Load the context argument from the config page.
+ // This places the first usable config value at _ffi_closure_trampoline_table-4080
+ // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc.
+ ldr r0, [pc, #-4092]
+
+ // Load the jump address from the config page.
+ ldr pc, [pc, #-4092]
+
+
+ // trampoline
+ // Save to stack
+ stmfd sp!, {r0-r3}
+
+ // Load the context argument from the config page.
+ // This places the first usable config value at _ffi_closure_trampoline_table-4080
+ // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc.
+ ldr r0, [pc, #-4092]
+
+ // Load the jump address from the config page.
+ ldr pc, [pc, #-4092]
+
+
+ // trampoline
+ // Save to stack
+ stmfd sp!, {r0-r3}
+
+ // Load the context argument from the config page.
+ // This places the first usable config value at _ffi_closure_trampoline_table-4080
+ // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc.
+ ldr r0, [pc, #-4092]
+
+ // Load the jump address from the config page.
+ ldr pc, [pc, #-4092]
+
+
+ // trampoline
+ // Save to stack
+ stmfd sp!, {r0-r3}
+
+ // Load the context argument from the config page.
+ // This places the first usable config value at _ffi_closure_trampoline_table-4080
+ // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc.
+ ldr r0, [pc, #-4092]
+
+ // Load the jump address from the config page.
+ ldr pc, [pc, #-4092]
+
+
+ // trampoline
+ // Save to stack
+ stmfd sp!, {r0-r3}
+
+ // Load the context argument from the config page.
+ // This places the first usable config value at _ffi_closure_trampoline_table-4080
+ // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc.
+ ldr r0, [pc, #-4092]
+
+ // Load the jump address from the config page.
+ ldr pc, [pc, #-4092]
+
+
+ // trampoline
+ // Save to stack
+ stmfd sp!, {r0-r3}
+
+ // Load the context argument from the config page.
+ // This places the first usable config value at _ffi_closure_trampoline_table-4080
+ // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc.
+ ldr r0, [pc, #-4092]
+
+ // Load the jump address from the config page.
+ ldr pc, [pc, #-4092]
+
+
+ // trampoline
+ // Save to stack
+ stmfd sp!, {r0-r3}
+
+ // Load the context argument from the config page.
+ // This places the first usable config value at _ffi_closure_trampoline_table-4080
+ // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc.
+ ldr r0, [pc, #-4092]
+
+ // Load the jump address from the config page.
+ ldr pc, [pc, #-4092]
+
+
+ // trampoline
+ // Save to stack
+ stmfd sp!, {r0-r3}
+
+ // Load the context argument from the config page.
+ // This places the first usable config value at _ffi_closure_trampoline_table-4080
+ // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc.
+ ldr r0, [pc, #-4092]
+
+ // Load the jump address from the config page.
+ ldr pc, [pc, #-4092]
+
+
+ // trampoline
+ // Save to stack
+ stmfd sp!, {r0-r3}
+
+ // Load the context argument from the config page.
+ // This places the first usable config value at _ffi_closure_trampoline_table-4080
+ // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc.
+ ldr r0, [pc, #-4092]
+
+ // Load the jump address from the config page.
+ ldr pc, [pc, #-4092]
+
+
+ // trampoline
+ // Save to stack
+ stmfd sp!, {r0-r3}
+
+ // Load the context argument from the config page.
+ // This places the first usable config value at _ffi_closure_trampoline_table-4080
+ // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc.
+ ldr r0, [pc, #-4092]
+
+ // Load the jump address from the config page.
+ ldr pc, [pc, #-4092]
+
+
+ // trampoline
+ // Save to stack
+ stmfd sp!, {r0-r3}
+
+ // Load the context argument from the config page.
+ // This places the first usable config value at _ffi_closure_trampoline_table-4080
+ // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc.
+ ldr r0, [pc, #-4092]
+
+ // Load the jump address from the config page.
+ ldr pc, [pc, #-4092]
+
+
+ // trampoline
+ // Save to stack
+ stmfd sp!, {r0-r3}
+
+ // Load the context argument from the config page.
+ // This places the first usable config value at _ffi_closure_trampoline_table-4080
+ // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc.
+ ldr r0, [pc, #-4092]
+
+ // Load the jump address from the config page.
+ ldr pc, [pc, #-4092]
+
+
+ // trampoline
+ // Save to stack
+ stmfd sp!, {r0-r3}
+
+ // Load the context argument from the config page.
+ // This places the first usable config value at _ffi_closure_trampoline_table-4080
+ // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc.
+ ldr r0, [pc, #-4092]
+
+ // Load the jump address from the config page.
+ ldr pc, [pc, #-4092]
+
+
+ // trampoline
+ // Save to stack
+ stmfd sp!, {r0-r3}
+
+ // Load the context argument from the config page.
+ // This places the first usable config value at _ffi_closure_trampoline_table-4080
+ // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc.
+ ldr r0, [pc, #-4092]
+
+ // Load the jump address from the config page.
+ ldr pc, [pc, #-4092]
+
+
+ // trampoline
+ // Save to stack
+ stmfd sp!, {r0-r3}
+
+ // Load the context argument from the config page.
+ // This places the first usable config value at _ffi_closure_trampoline_table-4080
+ // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc.
+ ldr r0, [pc, #-4092]
+
+ // Load the jump address from the config page.
+ ldr pc, [pc, #-4092]
+
+
+ // trampoline
+ // Save to stack
+ stmfd sp!, {r0-r3}
+
+ // Load the context argument from the config page.
+ // This places the first usable config value at _ffi_closure_trampoline_table-4080
+ // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc.
+ ldr r0, [pc, #-4092]
+
+ // Load the jump address from the config page.
+ ldr pc, [pc, #-4092]
+
+
+ // trampoline
+ // Save to stack
+ stmfd sp!, {r0-r3}
+
+ // Load the context argument from the config page.
+ // This places the first usable config value at _ffi_closure_trampoline_table-4080
+ // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc.
+ ldr r0, [pc, #-4092]
+
+ // Load the jump address from the config page.
+ ldr pc, [pc, #-4092]
+
+
+ // trampoline
+ // Save to stack
+ stmfd sp!, {r0-r3}
+
+ // Load the context argument from the config page.
+ // This places the first usable config value at _ffi_closure_trampoline_table-4080
+ // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc.
+ ldr r0, [pc, #-4092]
+
+ // Load the jump address from the config page.
+ ldr pc, [pc, #-4092]
+
+
+ // trampoline
+ // Save to stack
+ stmfd sp!, {r0-r3}
+
+ // Load the context argument from the config page.
+ // This places the first usable config value at _ffi_closure_trampoline_table-4080
+ // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc.
+ ldr r0, [pc, #-4092]
+
+ // Load the jump address from the config page.
+ ldr pc, [pc, #-4092]
+
+
+ // trampoline
+ // Save to stack
+ stmfd sp!, {r0-r3}
+
+ // Load the context argument from the config page.
+ // This places the first usable config value at _ffi_closure_trampoline_table-4080
+ // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc.
+ ldr r0, [pc, #-4092]
+
+ // Load the jump address from the config page.
+ ldr pc, [pc, #-4092]
+
+
+ // trampoline
+ // Save to stack
+ stmfd sp!, {r0-r3}
+
+ // Load the context argument from the config page.
+ // This places the first usable config value at _ffi_closure_trampoline_table-4080
+ // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc.
+ ldr r0, [pc, #-4092]
+
+ // Load the jump address from the config page.
+ ldr pc, [pc, #-4092]
+
+
+ // trampoline
+ // Save to stack
+ stmfd sp!, {r0-r3}
+
+ // Load the context argument from the config page.
+ // This places the first usable config value at _ffi_closure_trampoline_table-4080
+ // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc.
+ ldr r0, [pc, #-4092]
+
+ // Load the jump address from the config page.
+ ldr pc, [pc, #-4092]
+
+
+ // trampoline
+ // Save to stack
+ stmfd sp!, {r0-r3}
+
+ // Load the context argument from the config page.
+ // This places the first usable config value at _ffi_closure_trampoline_table-4080
+ // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc.
+ ldr r0, [pc, #-4092]
+
+ // Load the jump address from the config page.
+ ldr pc, [pc, #-4092]
+
+
+ // trampoline
+ // Save to stack
+ stmfd sp!, {r0-r3}
+
+ // Load the context argument from the config page.
+ // This places the first usable config value at _ffi_closure_trampoline_table-4080
+ // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc.
+ ldr r0, [pc, #-4092]
+
+ // Load the jump address from the config page.
+ ldr pc, [pc, #-4092]
+
+
+ // trampoline
+ // Save to stack
+ stmfd sp!, {r0-r3}
+
+ // Load the context argument from the config page.
+ // This places the first usable config value at _ffi_closure_trampoline_table-4080
+ // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc.
+ ldr r0, [pc, #-4092]
+
+ // Load the jump address from the config page.
+ ldr pc, [pc, #-4092]
+
+
+ // trampoline
+ // Save to stack
+ stmfd sp!, {r0-r3}
+
+ // Load the context argument from the config page.
+ // This places the first usable config value at _ffi_closure_trampoline_table-4080
+ // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc.
+ ldr r0, [pc, #-4092]
+
+ // Load the jump address from the config page.
+ ldr pc, [pc, #-4092]
+
+
+ // trampoline
+ // Save to stack
+ stmfd sp!, {r0-r3}
+
+ // Load the context argument from the config page.
+ // This places the first usable config value at _ffi_closure_trampoline_table-4080
+ // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc.
+ ldr r0, [pc, #-4092]
+
+ // Load the jump address from the config page.
+ ldr pc, [pc, #-4092]
+
+
+ // trampoline
+ // Save to stack
+ stmfd sp!, {r0-r3}
+
+ // Load the context argument from the config page.
+ // This places the first usable config value at _ffi_closure_trampoline_table-4080
+ // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc.
+ ldr r0, [pc, #-4092]
+
+ // Load the jump address from the config page.
+ ldr pc, [pc, #-4092]
+
+
+ // trampoline
+ // Save to stack
+ stmfd sp!, {r0-r3}
+
+ // Load the context argument from the config page.
+ // This places the first usable config value at _ffi_closure_trampoline_table-4080
+ // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc.
+ ldr r0, [pc, #-4092]
+
+ // Load the jump address from the config page.
+ ldr pc, [pc, #-4092]
+
+
+ // trampoline
+ // Save to stack
+ stmfd sp!, {r0-r3}
+
+ // Load the context argument from the config page.
+ // This places the first usable config value at _ffi_closure_trampoline_table-4080
+ // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc.
+ ldr r0, [pc, #-4092]
+
+ // Load the jump address from the config page.
+ ldr pc, [pc, #-4092]
+
+
+ // trampoline
+ // Save to stack
+ stmfd sp!, {r0-r3}
+
+ // Load the context argument from the config page.
+ // This places the first usable config value at _ffi_closure_trampoline_table-4080
+ // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc.
+ ldr r0, [pc, #-4092]
+
+ // Load the jump address from the config page.
+ ldr pc, [pc, #-4092]
+
+
+ // trampoline
+ // Save to stack
+ stmfd sp!, {r0-r3}
+
+ // Load the context argument from the config page.
+ // This places the first usable config value at _ffi_closure_trampoline_table-4080
+ // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc.
+ ldr r0, [pc, #-4092]
+
+ // Load the jump address from the config page.
+ ldr pc, [pc, #-4092]
+
+
+ // trampoline
+ // Save to stack
+ stmfd sp!, {r0-r3}
+
+ // Load the context argument from the config page.
+ // This places the first usable config value at _ffi_closure_trampoline_table-4080
+ // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc.
+ ldr r0, [pc, #-4092]
+
+ // Load the jump address from the config page.
+ ldr pc, [pc, #-4092]
+
+
+ // trampoline
+ // Save to stack
+ stmfd sp!, {r0-r3}
+
+ // Load the context argument from the config page.
+ // This places the first usable config value at _ffi_closure_trampoline_table-4080
+ // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc.
+ ldr r0, [pc, #-4092]
+
+ // Load the jump address from the config page.
+ ldr pc, [pc, #-4092]
+
+
+ // trampoline
+ // Save to stack
+ stmfd sp!, {r0-r3}
+
+ // Load the context argument from the config page.
+ // This places the first usable config value at _ffi_closure_trampoline_table-4080
+ // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc.
+ ldr r0, [pc, #-4092]
+
+ // Load the jump address from the config page.
+ ldr pc, [pc, #-4092]
+
+
+ // trampoline
+ // Save to stack
+ stmfd sp!, {r0-r3}
+
+ // Load the context argument from the config page.
+ // This places the first usable config value at _ffi_closure_trampoline_table-4080
+ // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc.
+ ldr r0, [pc, #-4092]
+
+ // Load the jump address from the config page.
+ ldr pc, [pc, #-4092]
+
+
+ // trampoline
+ // Save to stack
+ stmfd sp!, {r0-r3}
+
+ // Load the context argument from the config page.
+ // This places the first usable config value at _ffi_closure_trampoline_table-4080
+ // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc.
+ ldr r0, [pc, #-4092]
+
+ // Load the jump address from the config page.
+ ldr pc, [pc, #-4092]
+
+
+ // trampoline
+ // Save to stack
+ stmfd sp!, {r0-r3}
+
+ // Load the context argument from the config page.
+ // This places the first usable config value at _ffi_closure_trampoline_table-4080
+ // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc.
+ ldr r0, [pc, #-4092]
+
+ // Load the jump address from the config page.
+ ldr pc, [pc, #-4092]
+
+
+ // trampoline
+ // Save to stack
+ stmfd sp!, {r0-r3}
+
+ // Load the context argument from the config page.
+ // This places the first usable config value at _ffi_closure_trampoline_table-4080
+ // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc.
+ ldr r0, [pc, #-4092]
+
+ // Load the jump address from the config page.
+ ldr pc, [pc, #-4092]
+
+
+ // trampoline
+ // Save to stack
+ stmfd sp!, {r0-r3}
+
+ // Load the context argument from the config page.
+ // This places the first usable config value at _ffi_closure_trampoline_table-4080
+ // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc.
+ ldr r0, [pc, #-4092]
+
+ // Load the jump address from the config page.
+ ldr pc, [pc, #-4092]
+
+
+ // trampoline
+ // Save to stack
+ stmfd sp!, {r0-r3}
+
+ // Load the context argument from the config page.
+ // This places the first usable config value at _ffi_closure_trampoline_table-4080
+ // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc.
+ ldr r0, [pc, #-4092]
+
+ // Load the jump address from the config page.
+ ldr pc, [pc, #-4092]
+
+
+ // trampoline
+ // Save to stack
+ stmfd sp!, {r0-r3}
+
+ // Load the context argument from the config page.
+ // This places the first usable config value at _ffi_closure_trampoline_table-4080
+ // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc.
+ ldr r0, [pc, #-4092]
+
+ // Load the jump address from the config page.
+ ldr pc, [pc, #-4092]
+
+
+ // trampoline
+ // Save to stack
+ stmfd sp!, {r0-r3}
+
+ // Load the context argument from the config page.
+ // This places the first usable config value at _ffi_closure_trampoline_table-4080
+ // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc.
+ ldr r0, [pc, #-4092]
+
+ // Load the jump address from the config page.
+ ldr pc, [pc, #-4092]
+
+
+ // trampoline
+ // Save to stack
+ stmfd sp!, {r0-r3}
+
+ // Load the context argument from the config page.
+ // This places the first usable config value at _ffi_closure_trampoline_table-4080
+ // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc.
+ ldr r0, [pc, #-4092]
+
+ // Load the jump address from the config page.
+ ldr pc, [pc, #-4092]
+
+
+ // trampoline
+ // Save to stack
+ stmfd sp!, {r0-r3}
+
+ // Load the context argument from the config page.
+ // This places the first usable config value at _ffi_closure_trampoline_table-4080
+ // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc.
+ ldr r0, [pc, #-4092]
+
+ // Load the jump address from the config page.
+ ldr pc, [pc, #-4092]
+
+
+ // trampoline
+ // Save to stack
+ stmfd sp!, {r0-r3}
+
+ // Load the context argument from the config page.
+ // This places the first usable config value at _ffi_closure_trampoline_table-4080
+ // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc.
+ ldr r0, [pc, #-4092]
+
+ // Load the jump address from the config page.
+ ldr pc, [pc, #-4092]
+
+
+ // trampoline
+ // Save to stack
+ stmfd sp!, {r0-r3}
+
+ // Load the context argument from the config page.
+ // This places the first usable config value at _ffi_closure_trampoline_table-4080
+ // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc.
+ ldr r0, [pc, #-4092]
+
+ // Load the jump address from the config page.
+ ldr pc, [pc, #-4092]
+
+
+ // trampoline
+ // Save to stack
+ stmfd sp!, {r0-r3}
+
+ // Load the context argument from the config page.
+ // This places the first usable config value at _ffi_closure_trampoline_table-4080
+ // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc.
+ ldr r0, [pc, #-4092]
+
+ // Load the jump address from the config page.
+ ldr pc, [pc, #-4092]
+
+
+ // trampoline
+ // Save to stack
+ stmfd sp!, {r0-r3}
+
+ // Load the context argument from the config page.
+ // This places the first usable config value at _ffi_closure_trampoline_table-4080
+ // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc.
+ ldr r0, [pc, #-4092]
+
+ // Load the jump address from the config page.
+ ldr pc, [pc, #-4092]
+
+
+ // trampoline
+ // Save to stack
+ stmfd sp!, {r0-r3}
+
+ // Load the context argument from the config page.
+ // This places the first usable config value at _ffi_closure_trampoline_table-4080
+ // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc.
+ ldr r0, [pc, #-4092]
+
+ // Load the jump address from the config page.
+ ldr pc, [pc, #-4092]
+
+
+ // trampoline
+ // Save to stack
+ stmfd sp!, {r0-r3}
+
+ // Load the context argument from the config page.
+ // This places the first usable config value at _ffi_closure_trampoline_table-4080
+ // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc.
+ ldr r0, [pc, #-4092]
+
+ // Load the jump address from the config page.
+ ldr pc, [pc, #-4092]
+
+
+ // trampoline
+ // Save to stack
+ stmfd sp!, {r0-r3}
+
+ // Load the context argument from the config page.
+ // This places the first usable config value at _ffi_closure_trampoline_table-4080
+ // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc.
+ ldr r0, [pc, #-4092]
+
+ // Load the jump address from the config page.
+ ldr pc, [pc, #-4092]
+
+
+ // trampoline
+ // Save to stack
+ stmfd sp!, {r0-r3}
+
+ // Load the context argument from the config page.
+ // This places the first usable config value at _ffi_closure_trampoline_table-4080
+ // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc.
+ ldr r0, [pc, #-4092]
+
+ // Load the jump address from the config page.
+ ldr pc, [pc, #-4092]
+
+
+ // trampoline
+ // Save to stack
+ stmfd sp!, {r0-r3}
+
+ // Load the context argument from the config page.
+ // This places the first usable config value at _ffi_closure_trampoline_table-4080
+ // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc.
+ ldr r0, [pc, #-4092]
+
+ // Load the jump address from the config page.
+ ldr pc, [pc, #-4092]
+
+
+ // trampoline
+ // Save to stack
+ stmfd sp!, {r0-r3}
+
+ // Load the context argument from the config page.
+ // This places the first usable config value at _ffi_closure_trampoline_table-4080
+ // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc.
+ ldr r0, [pc, #-4092]
+
+ // Load the jump address from the config page.
+ ldr pc, [pc, #-4092]
+
+
+ // trampoline
+ // Save to stack
+ stmfd sp!, {r0-r3}
+
+ // Load the context argument from the config page.
+ // This places the first usable config value at _ffi_closure_trampoline_table-4080
+ // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc.
+ ldr r0, [pc, #-4092]
+
+ // Load the jump address from the config page.
+ ldr pc, [pc, #-4092]
+
+
+ // trampoline
+ // Save to stack
+ stmfd sp!, {r0-r3}
+
+ // Load the context argument from the config page.
+ // This places the first usable config value at _ffi_closure_trampoline_table-4080
+ // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc.
+ ldr r0, [pc, #-4092]
+
+ // Load the jump address from the config page.
+ ldr pc, [pc, #-4092]
+
+
+ // trampoline
+ // Save to stack
+ stmfd sp!, {r0-r3}
+
+ // Load the context argument from the config page.
+ // This places the first usable config value at _ffi_closure_trampoline_table-4080
+ // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc.
+ ldr r0, [pc, #-4092]
+
+ // Load the jump address from the config page.
+ ldr pc, [pc, #-4092]
+
+
+ // trampoline
+ // Save to stack
+ stmfd sp!, {r0-r3}
+
+ // Load the context argument from the config page.
+ // This places the first usable config value at _ffi_closure_trampoline_table-4080
+ // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc.
+ ldr r0, [pc, #-4092]
+
+ // Load the jump address from the config page.
+ ldr pc, [pc, #-4092]
+
+
+ // trampoline
+ // Save to stack
+ stmfd sp!, {r0-r3}
+
+ // Load the context argument from the config page.
+ // This places the first usable config value at _ffi_closure_trampoline_table-4080
+ // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc.
+ ldr r0, [pc, #-4092]
+
+ // Load the jump address from the config page.
+ ldr pc, [pc, #-4092]
+
+
+ // trampoline
+ // Save to stack
+ stmfd sp!, {r0-r3}
+
+ // Load the context argument from the config page.
+ // This places the first usable config value at _ffi_closure_trampoline_table-4080
+ // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc.
+ ldr r0, [pc, #-4092]
+
+ // Load the jump address from the config page.
+ ldr pc, [pc, #-4092]
+
+
+ // trampoline
+ // Save to stack
+ stmfd sp!, {r0-r3}
+
+ // Load the context argument from the config page.
+ // This places the first usable config value at _ffi_closure_trampoline_table-4080
+ // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc.
+ ldr r0, [pc, #-4092]
+
+ // Load the jump address from the config page.
+ ldr pc, [pc, #-4092]
+
+
+ // trampoline
+ // Save to stack
+ stmfd sp!, {r0-r3}
+
+ // Load the context argument from the config page.
+ // This places the first usable config value at _ffi_closure_trampoline_table-4080
+ // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc.
+ ldr r0, [pc, #-4092]
+
+ // Load the jump address from the config page.
+ ldr pc, [pc, #-4092]
+
+
+ // trampoline
+ // Save to stack
+ stmfd sp!, {r0-r3}
+
+ // Load the context argument from the config page.
+ // This places the first usable config value at _ffi_closure_trampoline_table-4080
+ // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc.
+ ldr r0, [pc, #-4092]
+
+ // Load the jump address from the config page.
+ ldr pc, [pc, #-4092]
+
+
+ // trampoline
+ // Save to stack
+ stmfd sp!, {r0-r3}
+
+ // Load the context argument from the config page.
+ // This places the first usable config value at _ffi_closure_trampoline_table-4080
+ // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc.
+ ldr r0, [pc, #-4092]
+
+ // Load the jump address from the config page.
+ ldr pc, [pc, #-4092]
+
+
+ // trampoline
+ // Save to stack
+ stmfd sp!, {r0-r3}
+
+ // Load the context argument from the config page.
+ // This places the first usable config value at _ffi_closure_trampoline_table-4080
+ // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc.
+ ldr r0, [pc, #-4092]
+
+ // Load the jump address from the config page.
+ ldr pc, [pc, #-4092]
+
+
+ // trampoline
+ // Save to stack
+ stmfd sp!, {r0-r3}
+
+ // Load the context argument from the config page.
+ // This places the first usable config value at _ffi_closure_trampoline_table-4080
+ // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc.
+ ldr r0, [pc, #-4092]
+
+ // Load the jump address from the config page.
+ ldr pc, [pc, #-4092]
+
+
+ // trampoline
+ // Save to stack
+ stmfd sp!, {r0-r3}
+
+ // Load the context argument from the config page.
+ // This places the first usable config value at _ffi_closure_trampoline_table-4080
+ // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc.
+ ldr r0, [pc, #-4092]
+
+ // Load the jump address from the config page.
+ ldr pc, [pc, #-4092]
+
+
+ // trampoline
+ // Save to stack
+ stmfd sp!, {r0-r3}
+
+ // Load the context argument from the config page.
+ // This places the first usable config value at _ffi_closure_trampoline_table-4080
+ // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc.
+ ldr r0, [pc, #-4092]
+
+ // Load the jump address from the config page.
+ ldr pc, [pc, #-4092]
+
+
+ // trampoline
+ // Save to stack
+ stmfd sp!, {r0-r3}
+
+ // Load the context argument from the config page.
+ // This places the first usable config value at _ffi_closure_trampoline_table-4080
+ // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc.
+ ldr r0, [pc, #-4092]
+
+ // Load the jump address from the config page.
+ ldr pc, [pc, #-4092]
+
+
+ // trampoline
+ // Save to stack
+ stmfd sp!, {r0-r3}
+
+ // Load the context argument from the config page.
+ // This places the first usable config value at _ffi_closure_trampoline_table-4080
+ // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc.
+ ldr r0, [pc, #-4092]
+
+ // Load the jump address from the config page.
+ ldr pc, [pc, #-4092]
+
+
+ // trampoline
+ // Save to stack
+ stmfd sp!, {r0-r3}
+
+ // Load the context argument from the config page.
+ // This places the first usable config value at _ffi_closure_trampoline_table-4080
+ // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc.
+ ldr r0, [pc, #-4092]
+
+ // Load the jump address from the config page.
+ ldr pc, [pc, #-4092]
+
+
+ // trampoline
+ // Save to stack
+ stmfd sp!, {r0-r3}
+
+ // Load the context argument from the config page.
+ // This places the first usable config value at _ffi_closure_trampoline_table-4080
+ // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc.
+ ldr r0, [pc, #-4092]
+
+ // Load the jump address from the config page.
+ ldr pc, [pc, #-4092]
+
+
+ // trampoline
+ // Save to stack
+ stmfd sp!, {r0-r3}
+
+ // Load the context argument from the config page.
+ // This places the first usable config value at _ffi_closure_trampoline_table-4080
+ // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc.
+ ldr r0, [pc, #-4092]
+
+ // Load the jump address from the config page.
+ ldr pc, [pc, #-4092]
+
+
+ // trampoline
+ // Save to stack
+ stmfd sp!, {r0-r3}
+
+ // Load the context argument from the config page.
+ // This places the first usable config value at _ffi_closure_trampoline_table-4080
+ // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc.
+ ldr r0, [pc, #-4092]
+
+ // Load the jump address from the config page.
+ ldr pc, [pc, #-4092]
+
+
+ // trampoline
+ // Save to stack
+ stmfd sp!, {r0-r3}
+
+ // Load the context argument from the config page.
+ // This places the first usable config value at _ffi_closure_trampoline_table-4080
+ // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc.
+ ldr r0, [pc, #-4092]
+
+ // Load the jump address from the config page.
+ ldr pc, [pc, #-4092]
+
+
+ // trampoline
+ // Save to stack
+ stmfd sp!, {r0-r3}
+
+ // Load the context argument from the config page.
+ // This places the first usable config value at _ffi_closure_trampoline_table-4080
+ // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc.
+ ldr r0, [pc, #-4092]
+
+ // Load the jump address from the config page.
+ ldr pc, [pc, #-4092]
+
+
+ // trampoline
+ // Save to stack
+ stmfd sp!, {r0-r3}
+
+ // Load the context argument from the config page.
+ // This places the first usable config value at _ffi_closure_trampoline_table-4080
+ // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc.
+ ldr r0, [pc, #-4092]
+
+ // Load the jump address from the config page.
+ ldr pc, [pc, #-4092]
+
+
+ // trampoline
+ // Save to stack
+ stmfd sp!, {r0-r3}
+
+ // Load the context argument from the config page.
+ // This places the first usable config value at _ffi_closure_trampoline_table-4080
+ // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc.
+ ldr r0, [pc, #-4092]
+
+ // Load the jump address from the config page.
+ ldr pc, [pc, #-4092]
+
+
+ // trampoline
+ // Save to stack
+ stmfd sp!, {r0-r3}
+
+ // Load the context argument from the config page.
+ // This places the first usable config value at _ffi_closure_trampoline_table-4080
+ // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc.
+ ldr r0, [pc, #-4092]
+
+ // Load the jump address from the config page.
+ ldr pc, [pc, #-4092]
+
+
+ // trampoline
+ // Save to stack
+ stmfd sp!, {r0-r3}
+
+ // Load the context argument from the config page.
+ // This places the first usable config value at _ffi_closure_trampoline_table-4080
+ // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc.
+ ldr r0, [pc, #-4092]
+
+ // Load the jump address from the config page.
+ ldr pc, [pc, #-4092]
+
+
+ // trampoline
+ // Save to stack
+ stmfd sp!, {r0-r3}
+
+ // Load the context argument from the config page.
+ // This places the first usable config value at _ffi_closure_trampoline_table-4080
+ // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc.
+ ldr r0, [pc, #-4092]
+
+ // Load the jump address from the config page.
+ ldr pc, [pc, #-4092]
+
+
+ // trampoline
+ // Save to stack
+ stmfd sp!, {r0-r3}
+
+ // Load the context argument from the config page.
+ // This places the first usable config value at _ffi_closure_trampoline_table-4080
+ // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc.
+ ldr r0, [pc, #-4092]
+
+ // Load the jump address from the config page.
+ ldr pc, [pc, #-4092]
+
+
+ // trampoline
+ // Save to stack
+ stmfd sp!, {r0-r3}
+
+ // Load the context argument from the config page.
+ // This places the first usable config value at _ffi_closure_trampoline_table-4080
+ // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc.
+ ldr r0, [pc, #-4092]
+
+ // Load the jump address from the config page.
+ ldr pc, [pc, #-4092]
+
+
+ // trampoline
+ // Save to stack
+ stmfd sp!, {r0-r3}
+
+ // Load the context argument from the config page.
+ // This places the first usable config value at _ffi_closure_trampoline_table-4080
+ // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc.
+ ldr r0, [pc, #-4092]
+
+ // Load the jump address from the config page.
+ ldr pc, [pc, #-4092]
+
+
+ // trampoline
+ // Save to stack
+ stmfd sp!, {r0-r3}
+
+ // Load the context argument from the config page.
+ // This places the first usable config value at _ffi_closure_trampoline_table-4080
+ // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc.
+ ldr r0, [pc, #-4092]
+
+ // Load the jump address from the config page.
+ ldr pc, [pc, #-4092]
+
+
+ // trampoline
+ // Save to stack
+ stmfd sp!, {r0-r3}
+
+ // Load the context argument from the config page.
+ // This places the first usable config value at _ffi_closure_trampoline_table-4080
+ // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc.
+ ldr r0, [pc, #-4092]
+
+ // Load the jump address from the config page.
+ ldr pc, [pc, #-4092]
+
+
+ // trampoline
+ // Save to stack
+ stmfd sp!, {r0-r3}
+
+ // Load the context argument from the config page.
+ // This places the first usable config value at _ffi_closure_trampoline_table-4080
+ // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc.
+ ldr r0, [pc, #-4092]
+
+ // Load the jump address from the config page.
+ ldr pc, [pc, #-4092]
+
+
+ // trampoline
+ // Save to stack
+ stmfd sp!, {r0-r3}
+
+ // Load the context argument from the config page.
+ // This places the first usable config value at _ffi_closure_trampoline_table-4080
+ // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc.
+ ldr r0, [pc, #-4092]
+
+ // Load the jump address from the config page.
+ ldr pc, [pc, #-4092]
+
+
+ // trampoline
+ // Save to stack
+ stmfd sp!, {r0-r3}
+
+ // Load the context argument from the config page.
+ // This places the first usable config value at _ffi_closure_trampoline_table-4080
+ // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc.
+ ldr r0, [pc, #-4092]
+
+ // Load the jump address from the config page.
+ ldr pc, [pc, #-4092]
+
+
+ // trampoline
+ // Save to stack
+ stmfd sp!, {r0-r3}
+
+ // Load the context argument from the config page.
+ // This places the first usable config value at _ffi_closure_trampoline_table-4080
+ // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc.
+ ldr r0, [pc, #-4092]
+
+ // Load the jump address from the config page.
+ ldr pc, [pc, #-4092]
+
+
+ // trampoline
+ // Save to stack
+ stmfd sp!, {r0-r3}
+
+ // Load the context argument from the config page.
+ // This places the first usable config value at _ffi_closure_trampoline_table-4080
+ // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc.
+ ldr r0, [pc, #-4092]
+
+ // Load the jump address from the config page.
+ ldr pc, [pc, #-4092]
+
+
+ // trampoline
+ // Save to stack
+ stmfd sp!, {r0-r3}
+
+ // Load the context argument from the config page.
+ // This places the first usable config value at _ffi_closure_trampoline_table-4080
+ // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc.
+ ldr r0, [pc, #-4092]
+
+ // Load the jump address from the config page.
+ ldr pc, [pc, #-4092]
+
+
+ // trampoline
+ // Save to stack
+ stmfd sp!, {r0-r3}
+
+ // Load the context argument from the config page.
+ // This places the first usable config value at _ffi_closure_trampoline_table-4080
+ // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc.
+ ldr r0, [pc, #-4092]
+
+ // Load the jump address from the config page.
+ ldr pc, [pc, #-4092]
+
+
+ // trampoline
+ // Save to stack
+ stmfd sp!, {r0-r3}
+
+ // Load the context argument from the config page.
+ // This places the first usable config value at _ffi_closure_trampoline_table-4080
+ // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc.
+ ldr r0, [pc, #-4092]
+
+ // Load the jump address from the config page.
+ ldr pc, [pc, #-4092]
+
+
+ // trampoline
+ // Save to stack
+ stmfd sp!, {r0-r3}
+
+ // Load the context argument from the config page.
+ // This places the first usable config value at _ffi_closure_trampoline_table-4080
+ // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc.
+ ldr r0, [pc, #-4092]
+
+ // Load the jump address from the config page.
+ ldr pc, [pc, #-4092]
+
+
+ // trampoline
+ // Save to stack
+ stmfd sp!, {r0-r3}
+
+ // Load the context argument from the config page.
+ // This places the first usable config value at _ffi_closure_trampoline_table-4080
+ // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc.
+ ldr r0, [pc, #-4092]
+
+ // Load the jump address from the config page.
+ ldr pc, [pc, #-4092]
+
+
+ // trampoline
+ // Save to stack
+ stmfd sp!, {r0-r3}
+
+ // Load the context argument from the config page.
+ // This places the first usable config value at _ffi_closure_trampoline_table-4080
+ // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc.
+ ldr r0, [pc, #-4092]
+
+ // Load the jump address from the config page.
+ ldr pc, [pc, #-4092]
+
+
+ // trampoline
+ // Save to stack
+ stmfd sp!, {r0-r3}
+
+ // Load the context argument from the config page.
+ // This places the first usable config value at _ffi_closure_trampoline_table-4080
+ // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc.
+ ldr r0, [pc, #-4092]
+
+ // Load the jump address from the config page.
+ ldr pc, [pc, #-4092]
+
+
+ // trampoline
+ // Save to stack
+ stmfd sp!, {r0-r3}
+
+ // Load the context argument from the config page.
+ // This places the first usable config value at _ffi_closure_trampoline_table-4080
+ // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc.
+ ldr r0, [pc, #-4092]
+
+ // Load the jump address from the config page.
+ ldr pc, [pc, #-4092]
+
+
+ // trampoline
+ // Save to stack
+ stmfd sp!, {r0-r3}
+
+ // Load the context argument from the config page.
+ // This places the first usable config value at _ffi_closure_trampoline_table-4080
+ // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc.
+ ldr r0, [pc, #-4092]
+
+ // Load the jump address from the config page.
+ ldr pc, [pc, #-4092]
+
+
+ // trampoline
+ // Save to stack
+ stmfd sp!, {r0-r3}
+
+ // Load the context argument from the config page.
+ // This places the first usable config value at _ffi_closure_trampoline_table-4080
+ // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc.
+ ldr r0, [pc, #-4092]
+
+ // Load the jump address from the config page.
+ ldr pc, [pc, #-4092]
+
+
+ // trampoline
+ // Save to stack
+ stmfd sp!, {r0-r3}
+
+ // Load the context argument from the config page.
+ // This places the first usable config value at _ffi_closure_trampoline_table-4080
+ // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc.
+ ldr r0, [pc, #-4092]
+
+ // Load the jump address from the config page.
+ ldr pc, [pc, #-4092]
+
+
+ // trampoline
+ // Save to stack
+ stmfd sp!, {r0-r3}
+
+ // Load the context argument from the config page.
+ // This places the first usable config value at _ffi_closure_trampoline_table-4080
+ // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc.
+ ldr r0, [pc, #-4092]
+
+ // Load the jump address from the config page.
+ ldr pc, [pc, #-4092]
+
+
+ // trampoline
+ // Save to stack
+ stmfd sp!, {r0-r3}
+
+ // Load the context argument from the config page.
+ // This places the first usable config value at _ffi_closure_trampoline_table-4080
+ // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc.
+ ldr r0, [pc, #-4092]
+
+ // Load the jump address from the config page.
+ ldr pc, [pc, #-4092]
+
+
+ // trampoline
+ // Save to stack
+ stmfd sp!, {r0-r3}
+
+ // Load the context argument from the config page.
+ // This places the first usable config value at _ffi_closure_trampoline_table-4080
+ // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc.
+ ldr r0, [pc, #-4092]
+
+ // Load the jump address from the config page.
+ ldr pc, [pc, #-4092]
+
+
+ // trampoline
+ // Save to stack
+ stmfd sp!, {r0-r3}
+
+ // Load the context argument from the config page.
+ // This places the first usable config value at _ffi_closure_trampoline_table-4080
+ // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc.
+ ldr r0, [pc, #-4092]
+
+ // Load the jump address from the config page.
+ ldr pc, [pc, #-4092]
+
+
+ // trampoline
+ // Save to stack
+ stmfd sp!, {r0-r3}
+
+ // Load the context argument from the config page.
+ // This places the first usable config value at _ffi_closure_trampoline_table-4080
+ // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc.
+ ldr r0, [pc, #-4092]
+
+ // Load the jump address from the config page.
+ ldr pc, [pc, #-4092]
+
+
+ // trampoline
+ // Save to stack
+ stmfd sp!, {r0-r3}
+
+ // Load the context argument from the config page.
+ // This places the first usable config value at _ffi_closure_trampoline_table-4080
+ // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc.
+ ldr r0, [pc, #-4092]
+
+ // Load the jump address from the config page.
+ ldr pc, [pc, #-4092]
+
+
+ // trampoline
+ // Save to stack
+ stmfd sp!, {r0-r3}
+
+ // Load the context argument from the config page.
+ // This places the first usable config value at _ffi_closure_trampoline_table-4080
+ // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc.
+ ldr r0, [pc, #-4092]
+
+ // Load the jump address from the config page.
+ ldr pc, [pc, #-4092]
+
+
+ // trampoline
+ // Save to stack
+ stmfd sp!, {r0-r3}
+
+ // Load the context argument from the config page.
+ // This places the first usable config value at _ffi_closure_trampoline_table-4080
+ // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc.
+ ldr r0, [pc, #-4092]
+
+ // Load the jump address from the config page.
+ ldr pc, [pc, #-4092]
+
+
+ // trampoline
+ // Save to stack
+ stmfd sp!, {r0-r3}
+
+ // Load the context argument from the config page.
+ // This places the first usable config value at _ffi_closure_trampoline_table-4080
+ // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc.
+ ldr r0, [pc, #-4092]
+
+ // Load the jump address from the config page.
+ ldr pc, [pc, #-4092]
+
+
+ // trampoline
+ // Save to stack
+ stmfd sp!, {r0-r3}
+
+ // Load the context argument from the config page.
+ // This places the first usable config value at _ffi_closure_trampoline_table-4080
+ // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc.
+ ldr r0, [pc, #-4092]
+
+ // Load the jump address from the config page.
+ ldr pc, [pc, #-4092]
+
+
+ // trampoline
+ // Save to stack
+ stmfd sp!, {r0-r3}
+
+ // Load the context argument from the config page.
+ // This places the first usable config value at _ffi_closure_trampoline_table-4080
+ // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc.
+ ldr r0, [pc, #-4092]
+
+ // Load the jump address from the config page.
+ ldr pc, [pc, #-4092]
+
+
+ // trampoline
+ // Save to stack
+ stmfd sp!, {r0-r3}
+
+ // Load the context argument from the config page.
+ // This places the first usable config value at _ffi_closure_trampoline_table-4080
+ // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc.
+ ldr r0, [pc, #-4092]
+
+ // Load the jump address from the config page.
+ ldr pc, [pc, #-4092]
+
+
+ // trampoline
+ // Save to stack
+ stmfd sp!, {r0-r3}
+
+ // Load the context argument from the config page.
+ // This places the first usable config value at _ffi_closure_trampoline_table-4080
+ // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc.
+ ldr r0, [pc, #-4092]
+
+ // Load the jump address from the config page.
+ ldr pc, [pc, #-4092]
+
+
+ // trampoline
+ // Save to stack
+ stmfd sp!, {r0-r3}
+
+ // Load the context argument from the config page.
+ // This places the first usable config value at _ffi_closure_trampoline_table-4080
+ // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc.
+ ldr r0, [pc, #-4092]
+
+ // Load the jump address from the config page.
+ ldr pc, [pc, #-4092]
+
+
+ // trampoline
+ // Save to stack
+ stmfd sp!, {r0-r3}
+
+ // Load the context argument from the config page.
+ // This places the first usable config value at _ffi_closure_trampoline_table-4080
+ // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc.
+ ldr r0, [pc, #-4092]
+
+ // Load the jump address from the config page.
+ ldr pc, [pc, #-4092]
+
+
+ // trampoline
+ // Save to stack
+ stmfd sp!, {r0-r3}
+
+ // Load the context argument from the config page.
+ // This places the first usable config value at _ffi_closure_trampoline_table-4080
+ // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc.
+ ldr r0, [pc, #-4092]
+
+ // Load the jump address from the config page.
+ ldr pc, [pc, #-4092]
+
+
+ // trampoline
+ // Save to stack
+ stmfd sp!, {r0-r3}
+
+ // Load the context argument from the config page.
+ // This places the first usable config value at _ffi_closure_trampoline_table-4080
+ // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc.
+ ldr r0, [pc, #-4092]
+
+ // Load the jump address from the config page.
+ ldr pc, [pc, #-4092]
+
+
+ // trampoline
+ // Save to stack
+ stmfd sp!, {r0-r3}
+
+ // Load the context argument from the config page.
+ // This places the first usable config value at _ffi_closure_trampoline_table-4080
+ // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc.
+ ldr r0, [pc, #-4092]
+
+ // Load the jump address from the config page.
+ ldr pc, [pc, #-4092]
+
+
+ // trampoline
+ // Save to stack
+ stmfd sp!, {r0-r3}
+
+ // Load the context argument from the config page.
+ // This places the first usable config value at _ffi_closure_trampoline_table-4080
+ // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc.
+ ldr r0, [pc, #-4092]
+
+ // Load the jump address from the config page.
+ ldr pc, [pc, #-4092]
+
+
+ // trampoline
+ // Save to stack
+ stmfd sp!, {r0-r3}
+
+ // Load the context argument from the config page.
+ // This places the first usable config value at _ffi_closure_trampoline_table-4080
+ // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc.
+ ldr r0, [pc, #-4092]
+
+ // Load the jump address from the config page.
+ ldr pc, [pc, #-4092]
+
+
+ // trampoline
+ // Save to stack
+ stmfd sp!, {r0-r3}
+
+ // Load the context argument from the config page.
+ // This places the first usable config value at _ffi_closure_trampoline_table-4080
+ // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc.
+ ldr r0, [pc, #-4092]
+
+ // Load the jump address from the config page.
+ ldr pc, [pc, #-4092]
+
+
+ // trampoline
+ // Save to stack
+ stmfd sp!, {r0-r3}
+
+ // Load the context argument from the config page.
+ // This places the first usable config value at _ffi_closure_trampoline_table-4080
+ // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc.
+ ldr r0, [pc, #-4092]
+
+ // Load the jump address from the config page.
+ ldr pc, [pc, #-4092]
+
+
+ // trampoline
+ // Save to stack
+ stmfd sp!, {r0-r3}
+
+ // Load the context argument from the config page.
+ // This places the first usable config value at _ffi_closure_trampoline_table-4080
+ // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc.
+ ldr r0, [pc, #-4092]
+
+ // Load the jump address from the config page.
+ ldr pc, [pc, #-4092]
+
+
+ // trampoline
+ // Save to stack
+ stmfd sp!, {r0-r3}
+
+ // Load the context argument from the config page.
+ // This places the first usable config value at _ffi_closure_trampoline_table-4080
+ // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc.
+ ldr r0, [pc, #-4092]
+
+ // Load the jump address from the config page.
+ ldr pc, [pc, #-4092]
+
+
+ // trampoline
+ // Save to stack
+ stmfd sp!, {r0-r3}
+
+ // Load the context argument from the config page.
+ // This places the first usable config value at _ffi_closure_trampoline_table-4080
+ // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc.
+ ldr r0, [pc, #-4092]
+
+ // Load the jump address from the config page.
+ ldr pc, [pc, #-4092]
+
+
+ // trampoline
+ // Save to stack
+ stmfd sp!, {r0-r3}
+
+ // Load the context argument from the config page.
+ // This places the first usable config value at _ffi_closure_trampoline_table-4080
+ // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc.
+ ldr r0, [pc, #-4092]
+
+ // Load the jump address from the config page.
+ ldr pc, [pc, #-4092]
+
+
+ // trampoline
+ // Save to stack
+ stmfd sp!, {r0-r3}
+
+ // Load the context argument from the config page.
+ // This places the first usable config value at _ffi_closure_trampoline_table-4080
+ // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc.
+ ldr r0, [pc, #-4092]
+
+ // Load the jump address from the config page.
+ ldr pc, [pc, #-4092]
+
+
+ // trampoline
+ // Save to stack
+ stmfd sp!, {r0-r3}
+
+ // Load the context argument from the config page.
+ // This places the first usable config value at _ffi_closure_trampoline_table-4080
+ // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc.
+ ldr r0, [pc, #-4092]
+
+ // Load the jump address from the config page.
+ ldr pc, [pc, #-4092]
+
+
+ // trampoline
+ // Save to stack
+ stmfd sp!, {r0-r3}
+
+ // Load the context argument from the config page.
+ // This places the first usable config value at _ffi_closure_trampoline_table-4080
+ // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc.
+ ldr r0, [pc, #-4092]
+
+ // Load the jump address from the config page.
+ ldr pc, [pc, #-4092]
+
+
+ // trampoline
+ // Save to stack
+ stmfd sp!, {r0-r3}
+
+ // Load the context argument from the config page.
+ // This places the first usable config value at _ffi_closure_trampoline_table-4080
+ // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc.
+ ldr r0, [pc, #-4092]
+
+ // Load the jump address from the config page.
+ ldr pc, [pc, #-4092]
+
+
+ // trampoline
+ // Save to stack
+ stmfd sp!, {r0-r3}
+
+ // Load the context argument from the config page.
+ // This places the first usable config value at _ffi_closure_trampoline_table-4080
+ // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc.
+ ldr r0, [pc, #-4092]
+
+ // Load the jump address from the config page.
+ ldr pc, [pc, #-4092]
+
+
+ // trampoline
+ // Save to stack
+ stmfd sp!, {r0-r3}
+
+ // Load the context argument from the config page.
+ // This places the first usable config value at _ffi_closure_trampoline_table-4080
+ // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc.
+ ldr r0, [pc, #-4092]
+
+ // Load the jump address from the config page.
+ ldr pc, [pc, #-4092]
+
+
+ // trampoline
+ // Save to stack
+ stmfd sp!, {r0-r3}
+
+ // Load the context argument from the config page.
+ // This places the first usable config value at _ffi_closure_trampoline_table-4080
+ // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc.
+ ldr r0, [pc, #-4092]
+
+ // Load the jump address from the config page.
+ ldr pc, [pc, #-4092]
+
+
+ // trampoline
+ // Save to stack
+ stmfd sp!, {r0-r3}
+
+ // Load the context argument from the config page.
+ // This places the first usable config value at _ffi_closure_trampoline_table-4080
+ // This accounts for the above 4-byte stmfd instruction, plus 8 bytes constant when loading from pc.
+ ldr r0, [pc, #-4092]
+
+ // Load the jump address from the config page.
+ ldr pc, [pc, #-4092]
+
diff --git a/jni/ruby/ext/fiddle/libffi-3.2.1/src/avr32/ffi.c b/jni/ruby/ext/fiddle/libffi-3.2.1/src/avr32/ffi.c
new file mode 100644
index 0000000..3d43397
--- /dev/null
+++ b/jni/ruby/ext/fiddle/libffi-3.2.1/src/avr32/ffi.c
@@ -0,0 +1,423 @@
+/* -----------------------------------------------------------------------
+ ffi.c - Copyright (c) 2011 Anthony Green
+ Copyright (c) 2009 Bradley Smith <brad@brad-smith.co.uk>
+
+ AVR32 Foreign Function Interface
+
+ Permission is hereby granted, free of charge, to any person obtaining
+ a copy of this software and associated documentation files (the
+ ``Software''), to deal in the Software without restriction, including
+ without limitation the rights to use, copy, modify, merge, publish,
+ distribute, sublicense, and/or sell copies of the Software, and to
+ permit persons to whom the Software is furnished to do so, subject to
+ the following conditions:
+
+ The above copyright notice and this permission notice shall be included
+ in all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND,
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+ HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ DEALINGS IN THE SOFTWARE.
+ ----------------------------------------------------------------------- */
+
+#include <ffi.h>
+#include <ffi_common.h>
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <unistd.h>
+#include <asm/unistd.h>
+
+/* #define DEBUG */
+
+extern void ffi_call_SYSV(void (*)(char *, extended_cif *), extended_cif *,
+ unsigned int, unsigned int, unsigned int*, unsigned int,
+ void (*fn)(void));
+extern void ffi_closure_SYSV (ffi_closure *);
+
+unsigned int pass_struct_on_stack(ffi_type *type)
+{
+ if(type->type != FFI_TYPE_STRUCT)
+ return 0;
+
+ if(type->alignment < type->size &&
+ !(type->size == 4 || type->size == 8) &&
+ !(type->size == 8 && type->alignment >= 4))
+ return 1;
+
+ if(type->size == 3 || type->size == 5 || type->size == 6 ||
+ type->size == 7)
+ return 1;
+
+ return 0;
+}
+
+/* ffi_prep_args is called by the assembly routine once stack space
+ * has been allocated for the function's arguments
+ *
+ * This is annoyingly complex since we need to keep track of used
+ * registers.
+ */
+
+void ffi_prep_args(char *stack, extended_cif *ecif)
+{
+ unsigned int i;
+ void **p_argv;
+ ffi_type **p_arg;
+ char *reg_base = stack;
+ char *stack_base = stack + 20;
+ unsigned int stack_offset = 0;
+ unsigned int reg_mask = 0;
+
+ p_argv = ecif->avalue;
+
+ /* If cif->flags is struct then we know it's not passed in registers */
+ if(ecif->cif->flags == FFI_TYPE_STRUCT)
+ {
+ *(void**)reg_base = ecif->rvalue;
+ reg_mask |= 1;
+ }
+
+ for(i = 0, p_arg = ecif->cif->arg_types; i < ecif->cif->nargs;
+ i++, p_arg++)
+ {
+ size_t z = (*p_arg)->size;
+ int alignment = (*p_arg)->alignment;
+ int type = (*p_arg)->type;
+ char *addr = 0;
+
+ if(z % 4 != 0)
+ z += (4 - z % 4);
+
+ if(reg_mask != 0x1f)
+ {
+ if(pass_struct_on_stack(*p_arg))
+ {
+ addr = stack_base + stack_offset;
+ stack_offset += z;
+ }
+ else if(z == sizeof(int))
+ {
+ char index = 0;
+
+ while((reg_mask >> index) & 1)
+ index++;
+
+ addr = reg_base + (index * 4);
+ reg_mask |= (1 << index);
+ }
+ else if(z == 2 * sizeof(int))
+ {
+ if(!((reg_mask >> 1) & 1))
+ {
+ addr = reg_base + 4;
+ reg_mask |= (3 << 1);
+ }
+ else if(!((reg_mask >> 3) & 1))
+ {
+ addr = reg_base + 12;
+ reg_mask |= (3 << 3);
+ }
+ }
+ }
+
+ if(!addr)
+ {
+ addr = stack_base + stack_offset;
+ stack_offset += z;
+ }
+
+ if(type == FFI_TYPE_STRUCT && (*p_arg)->elements[1] == NULL)
+ type = (*p_arg)->elements[0]->type;
+
+ switch(type)
+ {
+ case FFI_TYPE_UINT8:
+ *(unsigned int *)addr = (unsigned int)*(UINT8 *)(*p_argv);
+ break;
+ case FFI_TYPE_SINT8:
+ *(signed int *)addr = (signed int)*(SINT8 *)(*p_argv);
+ break;
+ case FFI_TYPE_UINT16:
+ *(unsigned int *)addr = (unsigned int)*(UINT16 *)(*p_argv);
+ break;
+ case FFI_TYPE_SINT16:
+ *(signed int *)addr = (signed int)*(SINT16 *)(*p_argv);
+ break;
+ default:
+ memcpy(addr, *p_argv, z);
+ }
+
+ p_argv++;
+ }
+
+#ifdef DEBUG
+ /* Debugging */
+ for(i = 0; i < 5; i++)
+ {
+ if((reg_mask & (1 << i)) == 0)
+ printf("r%d: (unused)\n", 12 - i);
+ else
+ printf("r%d: 0x%08x\n", 12 - i, ((unsigned int*)reg_base)[i]);
+ }
+
+ for(i = 0; i < stack_offset / 4; i++)
+ {
+ printf("sp+%d: 0x%08x\n", i*4, ((unsigned int*)stack_base)[i]);
+ }
+#endif
+}
+
+/* Perform machine dependent cif processing */
+ffi_status ffi_prep_cif_machdep(ffi_cif *cif)
+{
+ /* Round the stack up to a multiple of 8 bytes. This isn't needed
+ * everywhere, but it is on some platforms, and it doesn't harm
+ * anything when it isn't needed. */
+ cif->bytes = (cif->bytes + 7) & ~7;
+
+ /* Flag to indicate that he return value is in fact a struct */
+ cif->rstruct_flag = 0;
+
+ /* Set the return type flag */
+ switch(cif->rtype->type)
+ {
+ case FFI_TYPE_SINT8:
+ case FFI_TYPE_UINT8:
+ cif->flags = (unsigned)FFI_TYPE_UINT8;
+ break;
+ case FFI_TYPE_SINT16:
+ case FFI_TYPE_UINT16:
+ cif->flags = (unsigned)FFI_TYPE_UINT16;
+ break;
+ case FFI_TYPE_FLOAT:
+ case FFI_TYPE_SINT32:
+ case FFI_TYPE_UINT32:
+ case FFI_TYPE_POINTER:
+ cif->flags = (unsigned)FFI_TYPE_UINT32;
+ break;
+ case FFI_TYPE_DOUBLE:
+ case FFI_TYPE_SINT64:
+ case FFI_TYPE_UINT64:
+ cif->flags = (unsigned)FFI_TYPE_UINT64;
+ break;
+ case FFI_TYPE_STRUCT:
+ cif->rstruct_flag = 1;
+ if(!pass_struct_on_stack(cif->rtype))
+ {
+ if(cif->rtype->size <= 1)
+ cif->flags = (unsigned)FFI_TYPE_UINT8;
+ else if(cif->rtype->size <= 2)
+ cif->flags = (unsigned)FFI_TYPE_UINT16;
+ else if(cif->rtype->size <= 4)
+ cif->flags = (unsigned)FFI_TYPE_UINT32;
+ else if(cif->rtype->size <= 8)
+ cif->flags = (unsigned)FFI_TYPE_UINT64;
+ else
+ cif->flags = (unsigned)cif->rtype->type;
+ }
+ else
+ cif->flags = (unsigned)cif->rtype->type;
+ break;
+ default:
+ cif->flags = (unsigned)cif->rtype->type;
+ break;
+ }
+
+ return FFI_OK;
+}
+
+void ffi_call(ffi_cif *cif, void (*fn)(void), void *rvalue, void **avalue)
+{
+ extended_cif ecif;
+
+ unsigned int size = 0, i = 0;
+ ffi_type **p_arg;
+
+ ecif.cif = cif;
+ ecif.avalue = avalue;
+
+ for(i = 0, p_arg = cif->arg_types; i < cif->nargs; i++, p_arg++)
+ size += (*p_arg)->size + (4 - (*p_arg)->size % 4);
+
+ /* If the return value is a struct and we don't have a return value
+ * address then we need to make one */
+
+ /* If cif->flags is struct then it's not suitable for registers */
+ if((rvalue == NULL) && (cif->flags == FFI_TYPE_STRUCT))
+ ecif.rvalue = alloca(cif->rtype->size);
+ else
+ ecif.rvalue = rvalue;
+
+ switch(cif->abi)
+ {
+ case FFI_SYSV:
+ ffi_call_SYSV(ffi_prep_args, &ecif, size, cif->flags,
+ ecif.rvalue, cif->rstruct_flag, fn);
+ break;
+ default:
+ FFI_ASSERT(0);
+ break;
+ }
+}
+
+static void ffi_prep_incoming_args_SYSV(char *stack, void **rvalue,
+ void **avalue, ffi_cif *cif)
+{
+ register unsigned int i, reg_mask = 0;
+ register void **p_argv;
+ register ffi_type **p_arg;
+ register char *reg_base = stack;
+ register char *stack_base = stack + 20;
+ register unsigned int stack_offset = 0;
+
+#ifdef DEBUG
+ /* Debugging */
+ for(i = 0; i < cif->nargs + 7; i++)
+ {
+ printf("sp+%d: 0x%08x\n", i*4, ((unsigned int*)stack)[i]);
+ }
+#endif
+
+ /* If cif->flags is struct then we know it's not passed in registers */
+ if(cif->flags == FFI_TYPE_STRUCT)
+ {
+ *rvalue = *(void **)reg_base;
+ reg_mask |= 1;
+ }
+
+ p_argv = avalue;
+
+ for(i = 0, p_arg = cif->arg_types; i < cif->nargs; i++, p_arg++)
+ {
+ size_t z = (*p_arg)->size;
+ int alignment = (*p_arg)->alignment;
+
+ *p_argv = 0;
+
+ if(z % 4 != 0)
+ z += (4 - z % 4);
+
+ if(reg_mask != 0x1f)
+ {
+ if(pass_struct_on_stack(*p_arg))
+ {
+ *p_argv = (void*)stack_base + stack_offset;
+ stack_offset += z;
+ }
+ else if(z <= sizeof(int))
+ {
+ char index = 0;
+
+ while((reg_mask >> index) & 1)
+ index++;
+
+ *p_argv = (void*)reg_base + (index * 4);
+ reg_mask |= (1 << index);
+ }
+ else if(z == 2 * sizeof(int))
+ {
+ if(!((reg_mask >> 1) & 1))
+ {
+ *p_argv = (void*)reg_base + 4;
+ reg_mask |= (3 << 1);
+ }
+ else if(!((reg_mask >> 3) & 1))
+ {
+ *p_argv = (void*)reg_base + 12;
+ reg_mask |= (3 << 3);
+ }
+ }
+ }
+
+ if(!*p_argv)
+ {
+ *p_argv = (void*)stack_base + stack_offset;
+ stack_offset += z;
+ }
+
+ if((*p_arg)->type != FFI_TYPE_STRUCT ||
+ (*p_arg)->elements[1] == NULL)
+ {
+ if(alignment == 1)
+ **(unsigned int**)p_argv <<= 24;
+ else if(alignment == 2)
+ **(unsigned int**)p_argv <<= 16;
+ }
+
+ p_argv++;
+ }
+
+#ifdef DEBUG
+ /* Debugging */
+ for(i = 0; i < cif->nargs; i++)
+ {
+ printf("sp+%d: 0x%08x\n", i*4, *(((unsigned int**)avalue)[i]));
+ }
+#endif
+}
+
+/* This function is jumped to by the trampoline */
+
+unsigned int ffi_closure_SYSV_inner(ffi_closure *closure, void **respp,
+ void *args)
+{
+ ffi_cif *cif;
+ void **arg_area;
+ unsigned int i, size = 0;
+ ffi_type **p_arg;
+
+ cif = closure->cif;
+
+ for(i = 0, p_arg = cif->arg_types; i < cif->nargs; i++, p_arg++)
+ size += (*p_arg)->size + (4 - (*p_arg)->size % 4);
+
+ arg_area = (void **)alloca(size);
+
+ /* this call will initialize ARG_AREA, such that each element in that
+ * array points to the corresponding value on the stack; and if the
+ * function returns a structure, it will re-set RESP to point to the
+ * structure return address. */
+
+ ffi_prep_incoming_args_SYSV(args, respp, arg_area, cif);
+
+ (closure->fun)(cif, *respp, arg_area, closure->user_data);
+
+ return cif->flags;
+}
+
+ffi_status ffi_prep_closure_loc(ffi_closure* closure, ffi_cif* cif,
+ void (*fun)(ffi_cif*, void*, void**, void*), void *user_data,
+ void *codeloc)
+{
+ if (cif->abi != FFI_SYSV)
+ return FFI_BAD_ABI;
+
+ unsigned char *__tramp = (unsigned char*)(&closure->tramp[0]);
+ unsigned int __fun = (unsigned int)(&ffi_closure_SYSV);
+ unsigned int __ctx = (unsigned int)(codeloc);
+ unsigned int __rstruct_flag = (unsigned int)(cif->rstruct_flag);
+ unsigned int __inner = (unsigned int)(&ffi_closure_SYSV_inner);
+ *(unsigned int*) &__tramp[0] = 0xebcd1f00; /* pushm r8-r12 */
+ *(unsigned int*) &__tramp[4] = 0xfefc0010; /* ld.w r12, pc[16] */
+ *(unsigned int*) &__tramp[8] = 0xfefb0010; /* ld.w r11, pc[16] */
+ *(unsigned int*) &__tramp[12] = 0xfefa0010; /* ld.w r10, pc[16] */
+ *(unsigned int*) &__tramp[16] = 0xfeff0010; /* ld.w pc, pc[16] */
+ *(unsigned int*) &__tramp[20] = __ctx;
+ *(unsigned int*) &__tramp[24] = __rstruct_flag;
+ *(unsigned int*) &__tramp[28] = __inner;
+ *(unsigned int*) &__tramp[32] = __fun;
+ syscall(__NR_cacheflush, 0, (&__tramp[0]), 36);
+
+ closure->cif = cif;
+ closure->user_data = user_data;
+ closure->fun = fun;
+
+ return FFI_OK;
+}
+
diff --git a/jni/ruby/ext/fiddle/libffi-3.2.1/src/avr32/ffitarget.h b/jni/ruby/ext/fiddle/libffi-3.2.1/src/avr32/ffitarget.h
new file mode 100644
index 0000000..d0c7586
--- /dev/null
+++ b/jni/ruby/ext/fiddle/libffi-3.2.1/src/avr32/ffitarget.h
@@ -0,0 +1,55 @@
+/* -----------------------------------------------------------------*-C-*-
+ ffitarget.h - Copyright (c) 2012 Anthony Green
+ Copyright (c) 2009 Bradley Smith <brad@brad-smith.co.uk>
+ Target configuration macros for AVR32.
+
+ Permission is hereby granted, free of charge, to any person obtaining
+ a copy of this software and associated documentation files (the
+ ``Software''), to deal in the Software without restriction, including
+ without limitation the rights to use, copy, modify, merge, publish,
+ distribute, sublicense, and/or sell copies of the Software, and to
+ permit persons to whom the Software is furnished to do so, subject to
+ the following conditions:
+
+ The above copyright notice and this permission notice shall be included
+ in all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND,
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+ HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ DEALINGS IN THE SOFTWARE.
+
+ ----------------------------------------------------------------------- */
+
+#ifndef LIBFFI_TARGET_H
+#define LIBFFI_TARGET_H
+
+#ifndef LIBFFI_H
+#error "Please do not include ffitarget.h directly into your source. Use ffi.h instead."
+#endif
+
+#ifndef LIBFFI_ASM
+typedef unsigned long ffi_arg;
+typedef signed long ffi_sarg;
+
+typedef enum ffi_abi {
+ FFI_FIRST_ABI = 0,
+ FFI_SYSV,
+ FFI_LAST_ABI,
+ FFI_DEFAULT_ABI = FFI_SYSV
+} ffi_abi;
+#endif
+
+#define FFI_EXTRA_CIF_FIELDS unsigned int rstruct_flag
+
+/* Definitions for closures */
+
+#define FFI_CLOSURES 1
+#define FFI_TRAMPOLINE_SIZE 36
+#define FFI_NATIVE_RAW_API 0
+
+#endif
diff --git a/jni/ruby/ext/fiddle/libffi-3.2.1/src/avr32/sysv.S b/jni/ruby/ext/fiddle/libffi-3.2.1/src/avr32/sysv.S
new file mode 100644
index 0000000..a984b3c
--- /dev/null
+++ b/jni/ruby/ext/fiddle/libffi-3.2.1/src/avr32/sysv.S
@@ -0,0 +1,208 @@
+/* -----------------------------------------------------------------------
+ sysv.S - Copyright (c) 2009 Bradley Smith <brad@brad-smith.co.uk>
+
+ AVR32 Foreign Function Interface
+
+ Permission is hereby granted, free of charge, to any person obtaining
+ a copy of this software and associated documentation files (the
+ ``Software''), to deal in the Software without restriction, including
+ without limitation the rights to use, copy, modify, merge, publish,
+ distribute, sublicense, and/or sell copies of the Software, and to
+ permit persons to whom the Software is furnished to do so, subject to
+ the following conditions:
+
+ The above copyright notice and this permission notice shall be included
+ in all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND,
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ --------------------------------------------------------------------- */
+
+#define LIBFFI_ASM
+#include <fficonfig.h>
+#include <ffi.h>
+
+ /* r12: ffi_prep_args
+ * r11: &ecif
+ * r10: size
+ * r9: cif->flags
+ * r8: ecif.rvalue
+ * sp+0: cif->rstruct_flag
+ * sp+4: fn */
+
+ .text
+ .align 1
+ .globl ffi_call_SYSV
+ .type ffi_call_SYSV, @function
+ffi_call_SYSV:
+ stm --sp, r0,r1,lr
+ stm --sp, r8-r12
+ mov r0, sp
+
+ /* Make room for all of the new args. */
+ sub sp, r10
+ /* Pad to make way for potential skipped registers */
+ sub sp, 20
+
+ /* Call ffi_prep_args(stack, &ecif). */
+ /* r11 already set */
+ mov r1, r12
+ mov r12, sp
+ icall r1
+
+ /* Save new argument size */
+ mov r1, r12
+
+ /* Move first 5 parameters in registers. */
+ ldm sp++, r8-r12
+
+ /* call (fn) (...). */
+ ld.w r1, r0[36]
+ icall r1
+
+ /* Remove the space we pushed for the args. */
+ mov sp, r0
+
+ /* Load r1 with the rstruct flag. */
+ ld.w r1, sp[32]
+
+ /* Load r9 with the return type code. */
+ ld.w r9, sp[12]
+
+ /* Load r8 with the return value pointer. */
+ ld.w r8, sp[16]
+
+ /* If the return value pointer is NULL, assume no return value. */
+ cp.w r8, 0
+ breq .Lend
+
+ /* Check if return type is actually a struct */
+ cp.w r1, 0
+ breq 1f
+
+ /* Return 8bit */
+ cp.w r9, FFI_TYPE_UINT8
+ breq .Lstore8
+
+ /* Return 16bit */
+ cp.w r9, FFI_TYPE_UINT16
+ breq .Lstore16
+
+1:
+ /* Return 32bit */
+ cp.w r9, FFI_TYPE_UINT32
+ breq .Lstore32
+ cp.w r9, FFI_TYPE_UINT16
+ breq .Lstore32
+ cp.w r9, FFI_TYPE_UINT8
+ breq .Lstore32
+
+ /* Return 64bit */
+ cp.w r9, FFI_TYPE_UINT64
+ breq .Lstore64
+
+ /* Didn't match anything */
+ bral .Lend
+
+.Lstore64:
+ st.w r8[0], r11
+ st.w r8[4], r10
+ bral .Lend
+
+.Lstore32:
+ st.w r8[0], r12
+ bral .Lend
+
+.Lstore16:
+ st.h r8[0], r12
+ bral .Lend
+
+.Lstore8:
+ st.b r8[0], r12
+ bral .Lend
+
+.Lend:
+ sub sp, -20
+ ldm sp++, r0,r1,pc
+
+ .size ffi_call_SYSV, . - ffi_call_SYSV
+
+
+ /* r12: __ctx
+ * r11: __rstruct_flag
+ * r10: __inner */
+
+ .align 1
+ .globl ffi_closure_SYSV
+ .type ffi_closure_SYSV, @function
+ffi_closure_SYSV:
+ stm --sp, r0,lr
+ mov r0, r11
+ mov r8, r10
+ sub r10, sp, -8
+ sub sp, 12
+ st.w sp[8], sp
+ sub r11, sp, -8
+ icall r8
+
+ /* Check if return type is actually a struct */
+ cp.w r0, 0
+ breq 1f
+
+ /* Return 8bit */
+ cp.w r12, FFI_TYPE_UINT8
+ breq .Lget8
+
+ /* Return 16bit */
+ cp.w r12, FFI_TYPE_UINT16
+ breq .Lget16
+
+1:
+ /* Return 32bit */
+ cp.w r12, FFI_TYPE_UINT32
+ breq .Lget32
+ cp.w r12, FFI_TYPE_UINT16
+ breq .Lget32
+ cp.w r12, FFI_TYPE_UINT8
+ breq .Lget32
+
+ /* Return 64bit */
+ cp.w r12, FFI_TYPE_UINT64
+ breq .Lget64
+
+ /* Didn't match anything */
+ bral .Lclend
+
+.Lget64:
+ ld.w r11, sp[0]
+ ld.w r10, sp[4]
+ bral .Lclend
+
+.Lget32:
+ ld.w r12, sp[0]
+ bral .Lclend
+
+.Lget16:
+ ld.uh r12, sp[0]
+ bral .Lclend
+
+.Lget8:
+ ld.ub r12, sp[0]
+ bral .Lclend
+
+.Lclend:
+ sub sp, -12
+ ldm sp++, r0,lr
+ sub sp, -20
+ mov pc, lr
+
+ .size ffi_closure_SYSV, . - ffi_closure_SYSV
+
+#if defined __ELF__ && defined __linux__
+ .section .note.GNU-stack,"",@progbits
+#endif
diff --git a/jni/ruby/ext/fiddle/libffi-3.2.1/src/bfin/ffi.c b/jni/ruby/ext/fiddle/libffi-3.2.1/src/bfin/ffi.c
new file mode 100644
index 0000000..22a2acd
--- /dev/null
+++ b/jni/ruby/ext/fiddle/libffi-3.2.1/src/bfin/ffi.c
@@ -0,0 +1,196 @@
+/* -----------------------------------------------------------------------
+ ffi.c - Copyright (c) 2012 Alexandre K. I. de Mendonca <alexandre.keunecke@gmail.com>,
+ Paulo Pizarro <paulo.pizarro@gmail.com>
+
+ Blackfin Foreign Function Interface
+
+ Permission is hereby granted, free of charge, to any person obtaining
+ a copy of this software and associated documentation files (the
+ ``Software''), to deal in the Software without restriction, including
+ without limitation the rights to use, copy, modify, merge, publish,
+ distribute, sublicense, and/or sell copies of the Software, and to
+ permit persons to whom the Software is furnished to do so, subject to
+ the following conditions:
+
+ The above copyright notice and this permission notice shall be included
+ in all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND,
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+ HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ DEALINGS IN THE SOFTWARE.
+ ----------------------------------------------------------------------- */
+#include <ffi.h>
+#include <ffi_common.h>
+
+#include <stdlib.h>
+#include <stdio.h>
+
+/* Maximum number of GPRs available for argument passing. */
+#define MAX_GPRARGS 3
+
+/*
+ * Return types
+ */
+#define FFIBFIN_RET_VOID 0
+#define FFIBFIN_RET_BYTE 1
+#define FFIBFIN_RET_HALFWORD 2
+#define FFIBFIN_RET_INT64 3
+#define FFIBFIN_RET_INT32 4
+
+/*====================================================================*/
+/* PROTOTYPE *
+ /*====================================================================*/
+void ffi_prep_args(unsigned char *, extended_cif *);
+
+/*====================================================================*/
+/* Externals */
+/* (Assembly) */
+/*====================================================================*/
+
+extern void ffi_call_SYSV(unsigned, extended_cif *, void(*)(unsigned char *, extended_cif *), unsigned, void *, void(*fn)(void));
+
+/*====================================================================*/
+/* Implementation */
+/* */
+/*====================================================================*/
+
+
+/*
+ * This function calculates the return type (size) based on type.
+ */
+
+ffi_status ffi_prep_cif_machdep(ffi_cif *cif)
+{
+ /* --------------------------------------*
+ * Return handling *
+ * --------------------------------------*/
+ switch (cif->rtype->type) {
+ case FFI_TYPE_VOID:
+ cif->flags = FFIBFIN_RET_VOID;
+ break;
+ case FFI_TYPE_UINT16:
+ case FFI_TYPE_SINT16:
+ cif->flags = FFIBFIN_RET_HALFWORD;
+ break;
+ case FFI_TYPE_UINT8:
+ cif->flags = FFIBFIN_RET_BYTE;
+ break;
+ case FFI_TYPE_INT:
+ case FFI_TYPE_UINT32:
+ case FFI_TYPE_SINT32:
+ case FFI_TYPE_FLOAT:
+ case FFI_TYPE_POINTER:
+ case FFI_TYPE_SINT8:
+ cif->flags = FFIBFIN_RET_INT32;
+ break;
+ case FFI_TYPE_SINT64:
+ case FFI_TYPE_UINT64:
+ case FFI_TYPE_DOUBLE:
+ cif->flags = FFIBFIN_RET_INT64;
+ break;
+ case FFI_TYPE_STRUCT:
+ if (cif->rtype->size <= 4){
+ cif->flags = FFIBFIN_RET_INT32;
+ }else if (cif->rtype->size == 8){
+ cif->flags = FFIBFIN_RET_INT64;
+ }else{
+ //it will return via a hidden pointer in P0
+ cif->flags = FFIBFIN_RET_VOID;
+ }
+ break;
+ default:
+ FFI_ASSERT(0);
+ break;
+ }
+ return FFI_OK;
+}
+
+/*
+ * This will prepare the arguments and will call the assembly routine
+ * cif = the call interface
+ * fn = the function to be called
+ * rvalue = the return value
+ * avalue = the arguments
+ */
+void ffi_call(ffi_cif *cif, void(*fn)(void), void *rvalue, void **avalue)
+{
+ int ret_type = cif->flags;
+ extended_cif ecif;
+ ecif.cif = cif;
+ ecif.avalue = avalue;
+ ecif.rvalue = rvalue;
+
+ switch (cif->abi) {
+ case FFI_SYSV:
+ ffi_call_SYSV(cif->bytes, &ecif, ffi_prep_args, ret_type, ecif.rvalue, fn);
+ break;
+ default:
+ FFI_ASSERT(0);
+ break;
+ }
+}
+
+
+/*
+* This function prepares the parameters (copies them from the ecif to the stack)
+* to call the function (ffi_prep_args is called by the assembly routine in file
+* sysv.S, which also calls the actual function)
+*/
+void ffi_prep_args(unsigned char *stack, extended_cif *ecif)
+{
+ register unsigned int i = 0;
+ void **p_argv;
+ unsigned char *argp;
+ ffi_type **p_arg;
+ argp = stack;
+ p_argv = ecif->avalue;
+ for (i = ecif->cif->nargs, p_arg = ecif->cif->arg_types;
+ (i != 0);
+ i--, p_arg++) {
+ size_t z;
+ z = (*p_arg)->size;
+ if (z < sizeof(int)) {
+ z = sizeof(int);
+ switch ((*p_arg)->type) {
+ case FFI_TYPE_SINT8: {
+ signed char v = *(SINT8 *)(* p_argv);
+ signed int t = v;
+ *(signed int *) argp = t;
+ }
+ break;
+ case FFI_TYPE_UINT8: {
+ unsigned char v = *(UINT8 *)(* p_argv);
+ unsigned int t = v;
+ *(unsigned int *) argp = t;
+ }
+ break;
+ case FFI_TYPE_SINT16:
+ *(signed int *) argp = (signed int) * (SINT16 *)(* p_argv);
+ break;
+ case FFI_TYPE_UINT16:
+ *(unsigned int *) argp = (unsigned int) * (UINT16 *)(* p_argv);
+ break;
+ case FFI_TYPE_STRUCT:
+ memcpy(argp, *p_argv, (*p_arg)->size);
+ break;
+ default:
+ FFI_ASSERT(0);
+ break;
+ }
+ } else if (z == sizeof(int)) {
+ *(unsigned int *) argp = (unsigned int) * (UINT32 *)(* p_argv);
+ } else {
+ memcpy(argp, *p_argv, z);
+ }
+ p_argv++;
+ argp += z;
+ }
+}
+
+
+
diff --git a/jni/ruby/ext/fiddle/libffi-3.2.1/src/bfin/ffitarget.h b/jni/ruby/ext/fiddle/libffi-3.2.1/src/bfin/ffitarget.h
new file mode 100644
index 0000000..2175c01
--- /dev/null
+++ b/jni/ruby/ext/fiddle/libffi-3.2.1/src/bfin/ffitarget.h
@@ -0,0 +1,43 @@
+/* -----------------------------------------------------------------------
+ ffitarget.h - Copyright (c) 2012 Alexandre K. I. de Mendonca <alexandre.keunecke@gmail.com>
+
+ Blackfin Foreign Function Interface
+
+ Permission is hereby granted, free of charge, to any person obtaining
+ a copy of this software and associated documentation files (the
+ ``Software''), to deal in the Software without restriction, including
+ without limitation the rights to use, copy, modify, merge, publish,
+ distribute, sublicense, and/or sell copies of the Software, and to
+ permit persons to whom the Software is furnished to do so, subject to
+ the following conditions:
+
+ The above copyright notice and this permission notice shall be included
+ in all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND,
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+ HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ DEALINGS IN THE SOFTWARE.
+ ----------------------------------------------------------------------- */
+
+#ifndef LIBFFI_TARGET_H
+#define LIBFFI_TARGET_H
+
+#ifndef LIBFFI_ASM
+typedef unsigned long ffi_arg;
+typedef signed long ffi_sarg;
+
+typedef enum ffi_abi {
+ FFI_FIRST_ABI = 0,
+ FFI_SYSV,
+ FFI_LAST_ABI,
+ FFI_DEFAULT_ABI = FFI_SYSV
+} ffi_abi;
+#endif
+
+#endif
+
diff --git a/jni/ruby/ext/fiddle/libffi-3.2.1/src/bfin/sysv.S b/jni/ruby/ext/fiddle/libffi-3.2.1/src/bfin/sysv.S
new file mode 100644
index 0000000..f4278be
--- /dev/null
+++ b/jni/ruby/ext/fiddle/libffi-3.2.1/src/bfin/sysv.S
@@ -0,0 +1,179 @@
+/* -----------------------------------------------------------------------
+ sysv.S - Copyright (c) 2012 Alexandre K. I. de Mendonca <alexandre.keunecke@gmail.com>,
+ Paulo Pizarro <paulo.pizarro@gmail.com>
+
+ Blackfin Foreign Function Interface
+
+ Permission is hereby granted, free of charge, to any person obtaining
+ a copy of this software and associated documentation files (the
+ ``Software''), to deal in the Software without restriction, including
+ without limitation the rights to use, copy, modify, merge, publish,
+ distribute, sublicense, and/or sell copies of the Software, and to
+ permit persons to whom the Software is furnished to do so, subject to
+ the following conditions:
+
+ The above copyright notice and this permission notice shall be included
+ in all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND,
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+ HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ DEALINGS IN THE SOFTWARE.
+ ----------------------------------------------------------------------- */
+
+#define LIBFFI_ASM
+#include <fficonfig.h>
+#include <ffi.h>
+
+.text
+.align 4
+
+ /*
+ There is a "feature" in the bfin toolchain that it puts a _ before function names
+ that's why the function here it's called _ffi_call_SYSV and not ffi_call_SYSV
+ */
+ .global _ffi_call_SYSV;
+ .type _ffi_call_SYSV, STT_FUNC;
+ .func ffi_call_SYSV
+
+ /*
+ cif->bytes = R0 (fp+8)
+ &ecif = R1 (fp+12)
+ ffi_prep_args = R2 (fp+16)
+ ret_type = stack (fp+20)
+ ecif.rvalue = stack (fp+24)
+ fn = stack (fp+28)
+ got (fp+32)
+
+ There is room for improvement here (we can use temporary registers
+ instead of saving the values in the memory)
+ REGS:
+ P5 => Stack pointer (function arguments)
+ R5 => cif->bytes
+ R4 => ret->type
+
+ FP-20 = P3
+ FP-16 = SP (parameters area)
+ FP-12 = SP (temp)
+ FP-08 = function return part 1 [R0]
+ FP-04 = function return part 2 [R1]
+ */
+
+_ffi_call_SYSV:
+.prologue:
+ LINK 20;
+ [FP-20] = P3;
+ [FP+8] = R0;
+ [FP+12] = R1;
+ [FP+16] = R2;
+
+.allocate_stack:
+ //alocate cif->bytes into the stack
+ R1 = [FP+8];
+ R0 = SP;
+ R0 = R0 - R1;
+ R1 = 4;
+ R0 = R0 - R1;
+ [FP-12] = SP;
+ SP = R0;
+ [FP-16] = SP;
+
+.call_prep_args:
+ //get the addr of prep_args
+ P0 = [P3 + _ffi_prep_args@FUNCDESC_GOT17M4];
+ P1 = [P0];
+ P3 = [P0+4];
+ R0 = [FP-16];//SP (parameter area)
+ R1 = [FP+12];//ecif
+ call (P1);
+
+.call_user_function:
+ //ajust SP so as to allow the user function access the parameters on the stack
+ SP = [FP-16]; //point to function parameters
+ R0 = [SP];
+ R1 = [SP+4];
+ R2 = [SP+8];
+ //load user function address
+ P0 = FP;
+ P0 +=28;
+ P1 = [P0];
+ P1 = [P1];
+ P3 = [P0+4];
+ /*
+ For functions returning aggregate values (struct) occupying more than 8 bytes,
+ the caller allocates the return value object on the stack and the address
+ of this object is passed to the callee as a hidden argument in register P0.
+ */
+ P0 = [FP+24];
+
+ call (P1);
+ SP = [FP-12];
+.compute_return:
+ P2 = [FP-20];
+ [FP-8] = R0;
+ [FP-4] = R1;
+
+ R0 = [FP+20];
+ R1 = R0 << 2;
+
+ R0 = [P2+.rettable@GOT17M4];
+ R0 = R1 + R0;
+ P2 = R0;
+ R1 = [P2];
+
+ P2 = [FP+-20];
+ R0 = [P2+.rettable@GOT17M4];
+ R0 = R1 + R0;
+ P2 = R0;
+ R0 = [FP-8];
+ R1 = [FP-4];
+ jump (P2);
+
+/*
+#define FFIBFIN_RET_VOID 0
+#define FFIBFIN_RET_BYTE 1
+#define FFIBFIN_RET_HALFWORD 2
+#define FFIBFIN_RET_INT64 3
+#define FFIBFIN_RET_INT32 4
+*/
+.align 4
+.align 4
+.rettable:
+ .dd .epilogue - .rettable
+ .dd .rbyte - .rettable;
+ .dd .rhalfword - .rettable;
+ .dd .rint64 - .rettable;
+ .dd .rint32 - .rettable;
+
+.rbyte:
+ P0 = [FP+24];
+ R0 = R0.B (Z);
+ [P0] = R0;
+ JUMP .epilogue
+.rhalfword:
+ P0 = [FP+24];
+ R0 = R0.L;
+ [P0] = R0;
+ JUMP .epilogue
+.rint64:
+ P0 = [FP+24];// &rvalue
+ [P0] = R0;
+ [P0+4] = R1;
+ JUMP .epilogue
+.rint32:
+ P0 = [FP+24];
+ [P0] = R0;
+.epilogue:
+ R0 = [FP+8];
+ R1 = [FP+12];
+ R2 = [FP+16];
+ P3 = [FP-20];
+ UNLINK;
+ RTS;
+
+.size _ffi_call_SYSV,.-_ffi_call_SYSV;
+.endfunc
diff --git a/jni/ruby/ext/fiddle/libffi-3.2.1/src/closures.c b/jni/ruby/ext/fiddle/libffi-3.2.1/src/closures.c
new file mode 100644
index 0000000..721ff00
--- /dev/null
+++ b/jni/ruby/ext/fiddle/libffi-3.2.1/src/closures.c
@@ -0,0 +1,688 @@
+/* -----------------------------------------------------------------------
+ closures.c - Copyright (c) 2007, 2009, 2010 Red Hat, Inc.
+ Copyright (C) 2007, 2009, 2010 Free Software Foundation, Inc
+ Copyright (c) 2011 Plausible Labs Cooperative, Inc.
+
+ Code to allocate and deallocate memory for closures.
+
+ Permission is hereby granted, free of charge, to any person obtaining
+ a copy of this software and associated documentation files (the
+ ``Software''), to deal in the Software without restriction, including
+ without limitation the rights to use, copy, modify, merge, publish,
+ distribute, sublicense, and/or sell copies of the Software, and to
+ permit persons to whom the Software is furnished to do so, subject to
+ the following conditions:
+
+ The above copyright notice and this permission notice shall be included
+ in all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND,
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+ HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ DEALINGS IN THE SOFTWARE.
+ ----------------------------------------------------------------------- */
+
+#if defined __linux__ && !defined _GNU_SOURCE
+#define _GNU_SOURCE 1
+#endif
+
+#include <ffi.h>
+#include <ffi_common.h>
+
+#if !FFI_MMAP_EXEC_WRIT && !FFI_EXEC_TRAMPOLINE_TABLE
+# if __gnu_linux__ && !defined(__ANDROID__)
+/* This macro indicates it may be forbidden to map anonymous memory
+ with both write and execute permission. Code compiled when this
+ option is defined will attempt to map such pages once, but if it
+ fails, it falls back to creating a temporary file in a writable and
+ executable filesystem and mapping pages from it into separate
+ locations in the virtual memory space, one location writable and
+ another executable. */
+# define FFI_MMAP_EXEC_WRIT 1
+# define HAVE_MNTENT 1
+# endif
+# if defined(X86_WIN32) || defined(X86_WIN64) || defined(__OS2__)
+/* Windows systems may have Data Execution Protection (DEP) enabled,
+ which requires the use of VirtualMalloc/VirtualFree to alloc/free
+ executable memory. */
+# define FFI_MMAP_EXEC_WRIT 1
+# endif
+#endif
+
+#if FFI_MMAP_EXEC_WRIT && !defined FFI_MMAP_EXEC_SELINUX
+# ifdef __linux__
+/* When defined to 1 check for SELinux and if SELinux is active,
+ don't attempt PROT_EXEC|PROT_WRITE mapping at all, as that
+ might cause audit messages. */
+# define FFI_MMAP_EXEC_SELINUX 1
+# endif
+#endif
+
+#if FFI_CLOSURES
+
+# if FFI_EXEC_TRAMPOLINE_TABLE
+
+// Per-target implementation; It's unclear what can reasonable be shared between two OS/architecture implementations.
+
+# elif FFI_MMAP_EXEC_WRIT /* !FFI_EXEC_TRAMPOLINE_TABLE */
+
+#define USE_LOCKS 1
+#define USE_DL_PREFIX 1
+#ifdef __GNUC__
+#ifndef USE_BUILTIN_FFS
+#define USE_BUILTIN_FFS 1
+#endif
+#endif
+
+/* We need to use mmap, not sbrk. */
+#define HAVE_MORECORE 0
+
+/* We could, in theory, support mremap, but it wouldn't buy us anything. */
+#define HAVE_MREMAP 0
+
+/* We have no use for this, so save some code and data. */
+#define NO_MALLINFO 1
+
+/* We need all allocations to be in regular segments, otherwise we
+ lose track of the corresponding code address. */
+#define DEFAULT_MMAP_THRESHOLD MAX_SIZE_T
+
+/* Don't allocate more than a page unless needed. */
+#define DEFAULT_GRANULARITY ((size_t)malloc_getpagesize)
+
+#if FFI_CLOSURE_TEST
+/* Don't release single pages, to avoid a worst-case scenario of
+ continuously allocating and releasing single pages, but release
+ pairs of pages, which should do just as well given that allocations
+ are likely to be small. */
+#define DEFAULT_TRIM_THRESHOLD ((size_t)malloc_getpagesize)
+#endif
+
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <errno.h>
+#ifndef _MSC_VER
+#include <unistd.h>
+#endif
+#include <string.h>
+#include <stdio.h>
+#if !defined(X86_WIN32) && !defined(X86_WIN64)
+#ifdef HAVE_MNTENT
+#include <mntent.h>
+#endif /* HAVE_MNTENT */
+#include <sys/param.h>
+#include <pthread.h>
+
+/* We don't want sys/mman.h to be included after we redefine mmap and
+ dlmunmap. */
+#include <sys/mman.h>
+#define LACKS_SYS_MMAN_H 1
+
+#if FFI_MMAP_EXEC_SELINUX
+#include <sys/statfs.h>
+#include <stdlib.h>
+
+static int selinux_enabled = -1;
+
+static int
+selinux_enabled_check (void)
+{
+ struct statfs sfs;
+ FILE *f;
+ char *buf = NULL;
+ size_t len = 0;
+
+ if (statfs ("/selinux", &sfs) >= 0
+ && (unsigned int) sfs.f_type == 0xf97cff8cU)
+ return 1;
+ f = fopen ("/proc/mounts", "r");
+ if (f == NULL)
+ return 0;
+ while (getline (&buf, &len, f) >= 0)
+ {
+ char *p = strchr (buf, ' ');
+ if (p == NULL)
+ break;
+ p = strchr (p + 1, ' ');
+ if (p == NULL)
+ break;
+ if (strncmp (p + 1, "selinuxfs ", 10) == 0)
+ {
+ free (buf);
+ fclose (f);
+ return 1;
+ }
+ }
+ free (buf);
+ fclose (f);
+ return 0;
+}
+
+#define is_selinux_enabled() (selinux_enabled >= 0 ? selinux_enabled \
+ : (selinux_enabled = selinux_enabled_check ()))
+
+#else
+
+#define is_selinux_enabled() 0
+
+#endif /* !FFI_MMAP_EXEC_SELINUX */
+
+/* On PaX enable kernels that have MPROTECT enable we can't use PROT_EXEC. */
+#ifdef FFI_MMAP_EXEC_EMUTRAMP_PAX
+#include <stdlib.h>
+
+static int emutramp_enabled = -1;
+
+static int
+emutramp_enabled_check (void)
+{
+ char *buf = NULL;
+ size_t len = 0;
+ FILE *f;
+ int ret;
+ f = fopen ("/proc/self/status", "r");
+ if (f == NULL)
+ return 0;
+ ret = 0;
+
+ while (getline (&buf, &len, f) != -1)
+ if (!strncmp (buf, "PaX:", 4))
+ {
+ char emutramp;
+ if (sscanf (buf, "%*s %*c%c", &emutramp) == 1)
+ ret = (emutramp == 'E');
+ break;
+ }
+ free (buf);
+ fclose (f);
+ return ret;
+}
+
+#define is_emutramp_enabled() (emutramp_enabled >= 0 ? emutramp_enabled \
+ : (emutramp_enabled = emutramp_enabled_check ()))
+#endif /* FFI_MMAP_EXEC_EMUTRAMP_PAX */
+
+#elif defined (__CYGWIN__) || defined(__INTERIX)
+
+#include <sys/mman.h>
+
+/* Cygwin is Linux-like, but not quite that Linux-like. */
+#define is_selinux_enabled() 0
+
+#endif /* !defined(X86_WIN32) && !defined(X86_WIN64) */
+
+#ifndef FFI_MMAP_EXEC_EMUTRAMP_PAX
+#define is_emutramp_enabled() 0
+#endif /* FFI_MMAP_EXEC_EMUTRAMP_PAX */
+
+/* Declare all functions defined in dlmalloc.c as static. */
+static void *dlmalloc(size_t);
+static void dlfree(void*);
+static void *dlcalloc(size_t, size_t) MAYBE_UNUSED;
+static void *dlrealloc(void *, size_t) MAYBE_UNUSED;
+static void *dlmemalign(size_t, size_t) MAYBE_UNUSED;
+static void *dlvalloc(size_t) MAYBE_UNUSED;
+static int dlmallopt(int, int) MAYBE_UNUSED;
+static size_t dlmalloc_footprint(void) MAYBE_UNUSED;
+static size_t dlmalloc_max_footprint(void) MAYBE_UNUSED;
+static void** dlindependent_calloc(size_t, size_t, void**) MAYBE_UNUSED;
+static void** dlindependent_comalloc(size_t, size_t*, void**) MAYBE_UNUSED;
+static void *dlpvalloc(size_t) MAYBE_UNUSED;
+static int dlmalloc_trim(size_t) MAYBE_UNUSED;
+static size_t dlmalloc_usable_size(void*) MAYBE_UNUSED;
+static void dlmalloc_stats(void) MAYBE_UNUSED;
+
+#if !(defined(X86_WIN32) || defined(X86_WIN64) || defined(__OS2__)) || defined (__CYGWIN__) || defined(__INTERIX)
+/* Use these for mmap and munmap within dlmalloc.c. */
+static void *dlmmap(void *, size_t, int, int, int, off_t);
+static int dlmunmap(void *, size_t);
+#endif /* !(defined(X86_WIN32) || defined(X86_WIN64) || defined(__OS2__)) || defined (__CYGWIN__) || defined(__INTERIX) */
+
+#define mmap dlmmap
+#define munmap dlmunmap
+
+#include "dlmalloc.c"
+
+#undef mmap
+#undef munmap
+
+#if !(defined(X86_WIN32) || defined(X86_WIN64) || defined(__OS2__)) || defined (__CYGWIN__) || defined(__INTERIX)
+
+/* A mutex used to synchronize access to *exec* variables in this file. */
+static pthread_mutex_t open_temp_exec_file_mutex = PTHREAD_MUTEX_INITIALIZER;
+
+/* A file descriptor of a temporary file from which we'll map
+ executable pages. */
+static int execfd = -1;
+
+/* The amount of space already allocated from the temporary file. */
+static size_t execsize = 0;
+
+/* Open a temporary file name, and immediately unlink it. */
+static int
+open_temp_exec_file_name (char *name, int flags)
+{
+ int fd;
+
+#ifdef HAVE_MKOSTEMP
+ fd = mkostemp (name, flags);
+#else
+ fd = mkstemp (name);
+#endif
+
+ if (fd != -1)
+ unlink (name);
+
+ return fd;
+}
+
+/* Open a temporary file in the named directory. */
+static int
+open_temp_exec_file_dir (const char *dir)
+{
+ static const char suffix[] = "/ffiXXXXXX";
+ int lendir, flags;
+ char *tempname;
+#ifdef O_TMPFILE
+ int fd;
+#endif
+
+#ifdef O_CLOEXEC
+ flags = O_CLOEXEC;
+#else
+ flags = 0;
+#endif
+
+#ifdef O_TMPFILE
+ fd = open (dir, flags | O_RDWR | O_EXCL | O_TMPFILE, 0700);
+ /* If the running system does not support the O_TMPFILE flag then retry without it. */
+ if (fd != -1 || (errno != EINVAL && errno != EISDIR && errno != EOPNOTSUPP)) {
+ return fd;
+ } else {
+ errno = 0;
+ }
+#endif
+
+ lendir = strlen (dir);
+ tempname = __builtin_alloca (lendir + sizeof (suffix));
+
+ if (!tempname)
+ return -1;
+
+ memcpy (tempname, dir, lendir);
+ memcpy (tempname + lendir, suffix, sizeof (suffix));
+
+ return open_temp_exec_file_name (tempname, flags);
+}
+
+/* Open a temporary file in the directory in the named environment
+ variable. */
+static int
+open_temp_exec_file_env (const char *envvar)
+{
+ const char *value = getenv (envvar);
+
+ if (!value)
+ return -1;
+
+ return open_temp_exec_file_dir (value);
+}
+
+#ifdef HAVE_MNTENT
+/* Open a temporary file in an executable and writable mount point
+ listed in the mounts file. Subsequent calls with the same mounts
+ keep searching for mount points in the same file. Providing NULL
+ as the mounts file closes the file. */
+static int
+open_temp_exec_file_mnt (const char *mounts)
+{
+ static const char *last_mounts;
+ static FILE *last_mntent;
+
+ if (mounts != last_mounts)
+ {
+ if (last_mntent)
+ endmntent (last_mntent);
+
+ last_mounts = mounts;
+
+ if (mounts)
+ last_mntent = setmntent (mounts, "r");
+ else
+ last_mntent = NULL;
+ }
+
+ if (!last_mntent)
+ return -1;
+
+ for (;;)
+ {
+ int fd;
+ struct mntent mnt;
+ char buf[MAXPATHLEN * 3];
+
+ if (getmntent_r (last_mntent, &mnt, buf, sizeof (buf)) == NULL)
+ return -1;
+
+ if (hasmntopt (&mnt, "ro")
+ || hasmntopt (&mnt, "noexec")
+ || access (mnt.mnt_dir, W_OK))
+ continue;
+
+ fd = open_temp_exec_file_dir (mnt.mnt_dir);
+
+ if (fd != -1)
+ return fd;
+ }
+}
+#endif /* HAVE_MNTENT */
+
+/* Instructions to look for a location to hold a temporary file that
+ can be mapped in for execution. */
+static struct
+{
+ int (*func)(const char *);
+ const char *arg;
+ int repeat;
+} open_temp_exec_file_opts[] = {
+ { open_temp_exec_file_env, "TMPDIR", 0 },
+ { open_temp_exec_file_dir, "/tmp", 0 },
+ { open_temp_exec_file_dir, "/var/tmp", 0 },
+ { open_temp_exec_file_dir, "/dev/shm", 0 },
+ { open_temp_exec_file_env, "HOME", 0 },
+#ifdef HAVE_MNTENT
+ { open_temp_exec_file_mnt, "/etc/mtab", 1 },
+ { open_temp_exec_file_mnt, "/proc/mounts", 1 },
+#endif /* HAVE_MNTENT */
+};
+
+/* Current index into open_temp_exec_file_opts. */
+static int open_temp_exec_file_opts_idx = 0;
+
+/* Reset a current multi-call func, then advances to the next entry.
+ If we're at the last, go back to the first and return nonzero,
+ otherwise return zero. */
+static int
+open_temp_exec_file_opts_next (void)
+{
+ if (open_temp_exec_file_opts[open_temp_exec_file_opts_idx].repeat)
+ open_temp_exec_file_opts[open_temp_exec_file_opts_idx].func (NULL);
+
+ open_temp_exec_file_opts_idx++;
+ if (open_temp_exec_file_opts_idx
+ == (sizeof (open_temp_exec_file_opts)
+ / sizeof (*open_temp_exec_file_opts)))
+ {
+ open_temp_exec_file_opts_idx = 0;
+ return 1;
+ }
+
+ return 0;
+}
+
+/* Return a file descriptor of a temporary zero-sized file in a
+ writable and executable filesystem. */
+static int
+open_temp_exec_file (void)
+{
+ int fd;
+
+ do
+ {
+ fd = open_temp_exec_file_opts[open_temp_exec_file_opts_idx].func
+ (open_temp_exec_file_opts[open_temp_exec_file_opts_idx].arg);
+
+ if (!open_temp_exec_file_opts[open_temp_exec_file_opts_idx].repeat
+ || fd == -1)
+ {
+ if (open_temp_exec_file_opts_next ())
+ break;
+ }
+ }
+ while (fd == -1);
+
+ return fd;
+}
+
+/* Map in a chunk of memory from the temporary exec file into separate
+ locations in the virtual memory address space, one writable and one
+ executable. Returns the address of the writable portion, after
+ storing an offset to the corresponding executable portion at the
+ last word of the requested chunk. */
+static void *
+dlmmap_locked (void *start, size_t length, int prot, int flags, off_t offset)
+{
+ void *ptr;
+
+ if (execfd == -1)
+ {
+ open_temp_exec_file_opts_idx = 0;
+ retry_open:
+ execfd = open_temp_exec_file ();
+ if (execfd == -1)
+ return MFAIL;
+ }
+
+ offset = execsize;
+
+ if (ftruncate (execfd, offset + length))
+ return MFAIL;
+
+ flags &= ~(MAP_PRIVATE | MAP_ANONYMOUS);
+ flags |= MAP_SHARED;
+
+ ptr = mmap (NULL, length, (prot & ~PROT_WRITE) | PROT_EXEC,
+ flags, execfd, offset);
+ if (ptr == MFAIL)
+ {
+ if (!offset)
+ {
+ close (execfd);
+ goto retry_open;
+ }
+ ftruncate (execfd, offset);
+ return MFAIL;
+ }
+ else if (!offset
+ && open_temp_exec_file_opts[open_temp_exec_file_opts_idx].repeat)
+ open_temp_exec_file_opts_next ();
+
+ start = mmap (start, length, prot, flags, execfd, offset);
+
+ if (start == MFAIL)
+ {
+ munmap (ptr, length);
+ ftruncate (execfd, offset);
+ return start;
+ }
+
+ mmap_exec_offset ((char *)start, length) = (char*)ptr - (char*)start;
+
+ execsize += length;
+
+ return start;
+}
+
+/* Map in a writable and executable chunk of memory if possible.
+ Failing that, fall back to dlmmap_locked. */
+static void *
+dlmmap (void *start, size_t length, int prot,
+ int flags, int fd, off_t offset)
+{
+ void *ptr;
+
+ assert (start == NULL && length % malloc_getpagesize == 0
+ && prot == (PROT_READ | PROT_WRITE)
+ && flags == (MAP_PRIVATE | MAP_ANONYMOUS)
+ && fd == -1 && offset == 0);
+
+#if FFI_CLOSURE_TEST
+ printf ("mapping in %zi\n", length);
+#endif
+
+ if (execfd == -1 && is_emutramp_enabled ())
+ {
+ ptr = mmap (start, length, prot & ~PROT_EXEC, flags, fd, offset);
+ return ptr;
+ }
+
+ if (execfd == -1 && !is_selinux_enabled ())
+ {
+ ptr = mmap (start, length, prot | PROT_EXEC, flags, fd, offset);
+
+ if (ptr != MFAIL || (errno != EPERM && errno != EACCES))
+ /* Cool, no need to mess with separate segments. */
+ return ptr;
+
+ /* If MREMAP_DUP is ever introduced and implemented, try mmap
+ with ((prot & ~PROT_WRITE) | PROT_EXEC) and mremap with
+ MREMAP_DUP and prot at this point. */
+ }
+
+ if (execsize == 0 || execfd == -1)
+ {
+ pthread_mutex_lock (&open_temp_exec_file_mutex);
+ ptr = dlmmap_locked (start, length, prot, flags, offset);
+ pthread_mutex_unlock (&open_temp_exec_file_mutex);
+
+ return ptr;
+ }
+
+ return dlmmap_locked (start, length, prot, flags, offset);
+}
+
+/* Release memory at the given address, as well as the corresponding
+ executable page if it's separate. */
+static int
+dlmunmap (void *start, size_t length)
+{
+ /* We don't bother decreasing execsize or truncating the file, since
+ we can't quite tell whether we're unmapping the end of the file.
+ We don't expect frequent deallocation anyway. If we did, we
+ could locate pages in the file by writing to the pages being
+ deallocated and checking that the file contents change.
+ Yuck. */
+ msegmentptr seg = segment_holding (gm, start);
+ void *code;
+
+#if FFI_CLOSURE_TEST
+ printf ("unmapping %zi\n", length);
+#endif
+
+ if (seg && (code = add_segment_exec_offset (start, seg)) != start)
+ {
+ int ret = munmap (code, length);
+ if (ret)
+ return ret;
+ }
+
+ return munmap (start, length);
+}
+
+#if FFI_CLOSURE_FREE_CODE
+/* Return segment holding given code address. */
+static msegmentptr
+segment_holding_code (mstate m, char* addr)
+{
+ msegmentptr sp = &m->seg;
+ for (;;) {
+ if (addr >= add_segment_exec_offset (sp->base, sp)
+ && addr < add_segment_exec_offset (sp->base, sp) + sp->size)
+ return sp;
+ if ((sp = sp->next) == 0)
+ return 0;
+ }
+}
+#endif
+
+#endif /* !(defined(X86_WIN32) || defined(X86_WIN64) || defined(__OS2__)) || defined (__CYGWIN__) || defined(__INTERIX) */
+
+/* Allocate a chunk of memory with the given size. Returns a pointer
+ to the writable address, and sets *CODE to the executable
+ corresponding virtual address. */
+void *
+ffi_closure_alloc (size_t size, void **code)
+{
+ void *ptr;
+
+ if (!code)
+ return NULL;
+
+ ptr = dlmalloc (size);
+
+ if (ptr)
+ {
+ msegmentptr seg = segment_holding (gm, ptr);
+
+ *code = add_segment_exec_offset (ptr, seg);
+ }
+
+ return ptr;
+}
+
+/* Release a chunk of memory allocated with ffi_closure_alloc. If
+ FFI_CLOSURE_FREE_CODE is nonzero, the given address can be the
+ writable or the executable address given. Otherwise, only the
+ writable address can be provided here. */
+void
+ffi_closure_free (void *ptr)
+{
+#if FFI_CLOSURE_FREE_CODE
+ msegmentptr seg = segment_holding_code (gm, ptr);
+
+ if (seg)
+ ptr = sub_segment_exec_offset (ptr, seg);
+#endif
+
+ dlfree (ptr);
+}
+
+
+#if FFI_CLOSURE_TEST
+/* Do some internal sanity testing to make sure allocation and
+ deallocation of pages are working as intended. */
+int main ()
+{
+ void *p[3];
+#define GET(idx, len) do { p[idx] = dlmalloc (len); printf ("allocated %zi for p[%i]\n", (len), (idx)); } while (0)
+#define PUT(idx) do { printf ("freeing p[%i]\n", (idx)); dlfree (p[idx]); } while (0)
+ GET (0, malloc_getpagesize / 2);
+ GET (1, 2 * malloc_getpagesize - 64 * sizeof (void*));
+ PUT (1);
+ GET (1, 2 * malloc_getpagesize);
+ GET (2, malloc_getpagesize / 2);
+ PUT (1);
+ PUT (0);
+ PUT (2);
+ return 0;
+}
+#endif /* FFI_CLOSURE_TEST */
+# else /* ! FFI_MMAP_EXEC_WRIT */
+
+/* On many systems, memory returned by malloc is writable and
+ executable, so just use it. */
+
+#include <stdlib.h>
+
+void *
+ffi_closure_alloc (size_t size, void **code)
+{
+ if (!code)
+ return NULL;
+
+ return *code = malloc (size);
+}
+
+void
+ffi_closure_free (void *ptr)
+{
+ free (ptr);
+}
+
+# endif /* ! FFI_MMAP_EXEC_WRIT */
+#endif /* FFI_CLOSURES */
diff --git a/jni/ruby/ext/fiddle/libffi-3.2.1/src/cris/ffi.c b/jni/ruby/ext/fiddle/libffi-3.2.1/src/cris/ffi.c
new file mode 100644
index 0000000..aaca5b1
--- /dev/null
+++ b/jni/ruby/ext/fiddle/libffi-3.2.1/src/cris/ffi.c
@@ -0,0 +1,386 @@
+/* -----------------------------------------------------------------------
+ ffi.c - Copyright (c) 1998 Cygnus Solutions
+ Copyright (c) 2004 Simon Posnjak
+ Copyright (c) 2005 Axis Communications AB
+ Copyright (C) 2007 Free Software Foundation, Inc.
+
+ CRIS Foreign Function Interface
+
+ Permission is hereby granted, free of charge, to any person obtaining
+ a copy of this software and associated documentation files (the
+ ``Software''), to deal in the Software without restriction, including
+ without limitation the rights to use, copy, modify, merge, publish,
+ distribute, sublicense, and/or sell copies of the Software, and to
+ permit persons to whom the Software is furnished to do so, subject to
+ the following conditions:
+
+ The above copyright notice and this permission notice shall be included
+ in all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ IN NO EVENT SHALL SIMON POSNJAK BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ OTHER DEALINGS IN THE SOFTWARE.
+ ----------------------------------------------------------------------- */
+
+#include <ffi.h>
+#include <ffi_common.h>
+
+#define STACK_ARG_SIZE(x) ALIGN(x, FFI_SIZEOF_ARG)
+
+static ffi_status
+initialize_aggregate_packed_struct (ffi_type * arg)
+{
+ ffi_type **ptr;
+
+ FFI_ASSERT (arg != NULL);
+
+ FFI_ASSERT (arg->elements != NULL);
+ FFI_ASSERT (arg->size == 0);
+ FFI_ASSERT (arg->alignment == 0);
+
+ ptr = &(arg->elements[0]);
+
+ while ((*ptr) != NULL)
+ {
+ if (((*ptr)->size == 0)
+ && (initialize_aggregate_packed_struct ((*ptr)) != FFI_OK))
+ return FFI_BAD_TYPEDEF;
+
+ FFI_ASSERT (ffi_type_test ((*ptr)));
+
+ arg->size += (*ptr)->size;
+
+ arg->alignment = (arg->alignment > (*ptr)->alignment) ?
+ arg->alignment : (*ptr)->alignment;
+
+ ptr++;
+ }
+
+ if (arg->size == 0)
+ return FFI_BAD_TYPEDEF;
+ else
+ return FFI_OK;
+}
+
+int
+ffi_prep_args (char *stack, extended_cif * ecif)
+{
+ unsigned int i;
+ unsigned int struct_count = 0;
+ void **p_argv;
+ char *argp;
+ ffi_type **p_arg;
+
+ argp = stack;
+
+ p_argv = ecif->avalue;
+
+ for (i = ecif->cif->nargs, p_arg = ecif->cif->arg_types;
+ (i != 0); i--, p_arg++)
+ {
+ size_t z;
+
+ switch ((*p_arg)->type)
+ {
+ case FFI_TYPE_STRUCT:
+ {
+ z = (*p_arg)->size;
+ if (z <= 4)
+ {
+ memcpy (argp, *p_argv, z);
+ z = 4;
+ }
+ else if (z <= 8)
+ {
+ memcpy (argp, *p_argv, z);
+ z = 8;
+ }
+ else
+ {
+ unsigned int uiLocOnStack;
+ z = sizeof (void *);
+ uiLocOnStack = 4 * ecif->cif->nargs + struct_count;
+ struct_count = struct_count + (*p_arg)->size;
+ *(unsigned int *) argp =
+ (unsigned int) (UINT32 *) (stack + uiLocOnStack);
+ memcpy ((stack + uiLocOnStack), *p_argv, (*p_arg)->size);
+ }
+ break;
+ }
+ default:
+ z = (*p_arg)->size;
+ if (z < sizeof (int))
+ {
+ switch ((*p_arg)->type)
+ {
+ case FFI_TYPE_SINT8:
+ *(signed int *) argp = (signed int) *(SINT8 *) (*p_argv);
+ break;
+
+ case FFI_TYPE_UINT8:
+ *(unsigned int *) argp =
+ (unsigned int) *(UINT8 *) (*p_argv);
+ break;
+
+ case FFI_TYPE_SINT16:
+ *(signed int *) argp = (signed int) *(SINT16 *) (*p_argv);
+ break;
+
+ case FFI_TYPE_UINT16:
+ *(unsigned int *) argp =
+ (unsigned int) *(UINT16 *) (*p_argv);
+ break;
+
+ default:
+ FFI_ASSERT (0);
+ }
+ z = sizeof (int);
+ }
+ else if (z == sizeof (int))
+ *(unsigned int *) argp = (unsigned int) *(UINT32 *) (*p_argv);
+ else
+ memcpy (argp, *p_argv, z);
+ break;
+ }
+ p_argv++;
+ argp += z;
+ }
+
+ return (struct_count);
+}
+
+ffi_status FFI_HIDDEN
+ffi_prep_cif_core (ffi_cif * cif,
+ ffi_abi abi, unsigned int isvariadic,
+ unsigned int nfixedargs, unsigned int ntotalargs,
+ ffi_type * rtype, ffi_type ** atypes)
+{
+ unsigned bytes = 0;
+ unsigned int i;
+ ffi_type **ptr;
+
+ FFI_ASSERT (cif != NULL);
+ FFI_ASSERT((!isvariadic) || (nfixedargs >= 1));
+ FFI_ASSERT(nfixedargs <= ntotalargs);
+ FFI_ASSERT (abi > FFI_FIRST_ABI && abi < FFI_LAST_ABI);
+
+ cif->abi = abi;
+ cif->arg_types = atypes;
+ cif->nargs = ntotalargs;
+ cif->rtype = rtype;
+
+ cif->flags = 0;
+
+ if ((cif->rtype->size == 0)
+ && (initialize_aggregate_packed_struct (cif->rtype) != FFI_OK))
+ return FFI_BAD_TYPEDEF;
+
+ FFI_ASSERT_VALID_TYPE (cif->rtype);
+
+ for (ptr = cif->arg_types, i = cif->nargs; i > 0; i--, ptr++)
+ {
+ if (((*ptr)->size == 0)
+ && (initialize_aggregate_packed_struct ((*ptr)) != FFI_OK))
+ return FFI_BAD_TYPEDEF;
+
+ FFI_ASSERT_VALID_TYPE (*ptr);
+
+ if (((*ptr)->alignment - 1) & bytes)
+ bytes = ALIGN (bytes, (*ptr)->alignment);
+ if ((*ptr)->type == FFI_TYPE_STRUCT)
+ {
+ if ((*ptr)->size > 8)
+ {
+ bytes += (*ptr)->size;
+ bytes += sizeof (void *);
+ }
+ else
+ {
+ if ((*ptr)->size > 4)
+ bytes += 8;
+ else
+ bytes += 4;
+ }
+ }
+ else
+ bytes += STACK_ARG_SIZE ((*ptr)->size);
+ }
+
+ cif->bytes = bytes;
+
+ return ffi_prep_cif_machdep (cif);
+}
+
+ffi_status
+ffi_prep_cif_machdep (ffi_cif * cif)
+{
+ switch (cif->rtype->type)
+ {
+ case FFI_TYPE_VOID:
+ case FFI_TYPE_STRUCT:
+ case FFI_TYPE_FLOAT:
+ case FFI_TYPE_DOUBLE:
+ case FFI_TYPE_SINT64:
+ case FFI_TYPE_UINT64:
+ cif->flags = (unsigned) cif->rtype->type;
+ break;
+
+ default:
+ cif->flags = FFI_TYPE_INT;
+ break;
+ }
+
+ return FFI_OK;
+}
+
+extern void ffi_call_SYSV (int (*)(char *, extended_cif *),
+ extended_cif *,
+ unsigned, unsigned, unsigned *, void (*fn) ())
+ __attribute__ ((__visibility__ ("hidden")));
+
+void
+ffi_call (ffi_cif * cif, void (*fn) (), void *rvalue, void **avalue)
+{
+ extended_cif ecif;
+
+ ecif.cif = cif;
+ ecif.avalue = avalue;
+
+ if ((rvalue == NULL) && (cif->rtype->type == FFI_TYPE_STRUCT))
+ {
+ ecif.rvalue = alloca (cif->rtype->size);
+ }
+ else
+ ecif.rvalue = rvalue;
+
+ switch (cif->abi)
+ {
+ case FFI_SYSV:
+ ffi_call_SYSV (ffi_prep_args, &ecif, cif->bytes,
+ cif->flags, ecif.rvalue, fn);
+ break;
+ default:
+ FFI_ASSERT (0);
+ break;
+ }
+}
+
+/* Because the following variables are not exported outside libffi, we
+ mark them hidden. */
+
+/* Assembly code for the jump stub. */
+extern const char ffi_cris_trampoline_template[]
+ __attribute__ ((__visibility__ ("hidden")));
+
+/* Offset into ffi_cris_trampoline_template of where to put the
+ ffi_prep_closure_inner function. */
+extern const int ffi_cris_trampoline_fn_offset
+ __attribute__ ((__visibility__ ("hidden")));
+
+/* Offset into ffi_cris_trampoline_template of where to put the
+ closure data. */
+extern const int ffi_cris_trampoline_closure_offset
+ __attribute__ ((__visibility__ ("hidden")));
+
+/* This function is sibling-called (jumped to) by the closure
+ trampoline. We get R10..R13 at PARAMS[0..3] and a copy of [SP] at
+ PARAMS[4] to simplify handling of a straddling parameter. A copy
+ of R9 is at PARAMS[5] and SP at PARAMS[6]. These parameters are
+ put at the appropriate place in CLOSURE which is then executed and
+ the return value is passed back to the caller. */
+
+static unsigned long long
+ffi_prep_closure_inner (void **params, ffi_closure* closure)
+{
+ char *register_args = (char *) params;
+ void *struct_ret = params[5];
+ char *stack_args = params[6];
+ char *ptr = register_args;
+ ffi_cif *cif = closure->cif;
+ ffi_type **arg_types = cif->arg_types;
+
+ /* Max room needed is number of arguments as 64-bit values. */
+ void **avalue = alloca (closure->cif->nargs * sizeof(void *));
+ int i;
+ int doing_regs;
+ long long llret = 0;
+
+ /* Find the address of each argument. */
+ for (i = 0, doing_regs = 1; i < cif->nargs; i++)
+ {
+ /* Types up to and including 8 bytes go by-value. */
+ if (arg_types[i]->size <= 4)
+ {
+ avalue[i] = ptr;
+ ptr += 4;
+ }
+ else if (arg_types[i]->size <= 8)
+ {
+ avalue[i] = ptr;
+ ptr += 8;
+ }
+ else
+ {
+ FFI_ASSERT (arg_types[i]->type == FFI_TYPE_STRUCT);
+
+ /* Passed by-reference, so copy the pointer. */
+ avalue[i] = *(void **) ptr;
+ ptr += 4;
+ }
+
+ /* If we've handled more arguments than fit in registers, start
+ looking at the those passed on the stack. Step over the
+ first one if we had a straddling parameter. */
+ if (doing_regs && ptr >= register_args + 4*4)
+ {
+ ptr = stack_args + ((ptr > register_args + 4*4) ? 4 : 0);
+ doing_regs = 0;
+ }
+ }
+
+ /* Invoke the closure. */
+ (closure->fun) (cif,
+
+ cif->rtype->type == FFI_TYPE_STRUCT
+ /* The caller allocated space for the return
+ structure, and passed a pointer to this space in
+ R9. */
+ ? struct_ret
+
+ /* We take advantage of being able to ignore that
+ the high part isn't set if the return value is
+ not in R10:R11, but in R10 only. */
+ : (void *) &llret,
+
+ avalue, closure->user_data);
+
+ return llret;
+}
+
+/* API function: Prepare the trampoline. */
+
+ffi_status
+ffi_prep_closure_loc (ffi_closure* closure,
+ ffi_cif* cif,
+ void (*fun)(ffi_cif *, void *, void **, void*),
+ void *user_data,
+ void *codeloc)
+{
+ void *innerfn = ffi_prep_closure_inner;
+ FFI_ASSERT (cif->abi == FFI_SYSV);
+ closure->cif = cif;
+ closure->user_data = user_data;
+ closure->fun = fun;
+ memcpy (closure->tramp, ffi_cris_trampoline_template,
+ FFI_CRIS_TRAMPOLINE_CODE_PART_SIZE);
+ memcpy (closure->tramp + ffi_cris_trampoline_fn_offset,
+ &innerfn, sizeof (void *));
+ memcpy (closure->tramp + ffi_cris_trampoline_closure_offset,
+ &codeloc, sizeof (void *));
+
+ return FFI_OK;
+}
diff --git a/jni/ruby/ext/fiddle/libffi-3.2.1/src/cris/ffitarget.h b/jni/ruby/ext/fiddle/libffi-3.2.1/src/cris/ffitarget.h
new file mode 100644
index 0000000..b837e97
--- /dev/null
+++ b/jni/ruby/ext/fiddle/libffi-3.2.1/src/cris/ffitarget.h
@@ -0,0 +1,56 @@
+/* -----------------------------------------------------------------*-C-*-
+ ffitarget.h - Copyright (c) 2012 Anthony Green
+ Copyright (c) 1996-2003 Red Hat, Inc.
+ Target configuration macros for CRIS.
+
+ Permission is hereby granted, free of charge, to any person obtaining
+ a copy of this software and associated documentation files (the
+ ``Software''), to deal in the Software without restriction, including
+ without limitation the rights to use, copy, modify, merge, publish,
+ distribute, sublicense, and/or sell copies of the Software, and to
+ permit persons to whom the Software is furnished to do so, subject to
+ the following conditions:
+
+ The above copyright notice and this permission notice shall be included
+ in all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND,
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+ HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ DEALINGS IN THE SOFTWARE.
+
+ ----------------------------------------------------------------------- */
+
+#ifndef LIBFFI_TARGET_H
+#define LIBFFI_TARGET_H
+
+#ifndef LIBFFI_H
+#error "Please do not include ffitarget.h directly into your source. Use ffi.h instead."
+#endif
+
+#ifndef LIBFFI_ASM
+typedef unsigned long ffi_arg;
+typedef signed long ffi_sarg;
+
+typedef enum ffi_abi {
+ FFI_FIRST_ABI = 0,
+ FFI_SYSV,
+ FFI_LAST_ABI,
+ FFI_DEFAULT_ABI = FFI_SYSV
+} ffi_abi;
+#endif
+
+/* ---- Definitions for closures ----------------------------------------- */
+
+#define FFI_CLOSURES 1
+#define FFI_CRIS_TRAMPOLINE_CODE_PART_SIZE 36
+#define FFI_CRIS_TRAMPOLINE_DATA_PART_SIZE (7*4)
+#define FFI_TRAMPOLINE_SIZE \
+ (FFI_CRIS_TRAMPOLINE_CODE_PART_SIZE + FFI_CRIS_TRAMPOLINE_DATA_PART_SIZE)
+#define FFI_NATIVE_RAW_API 0
+
+#endif
diff --git a/jni/ruby/ext/fiddle/libffi-3.2.1/src/cris/sysv.S b/jni/ruby/ext/fiddle/libffi-3.2.1/src/cris/sysv.S
new file mode 100644
index 0000000..79abaee
--- /dev/null
+++ b/jni/ruby/ext/fiddle/libffi-3.2.1/src/cris/sysv.S
@@ -0,0 +1,215 @@
+/* -----------------------------------------------------------------------
+ sysv.S - Copyright (c) 2004 Simon Posnjak
+ Copyright (c) 2005 Axis Communications AB
+
+ CRIS Foreign Function Interface
+
+ Permission is hereby granted, free of charge, to any person obtaining
+ a copy of this software and associated documentation files (the
+ ``Software''), to deal in the Software without restriction, including
+ without limitation the rights to use, copy, modify, merge, publish,
+ distribute, sublicense, and/or sell copies of the Software, and to
+ permit persons to whom the Software is furnished to do so, subject to
+ the following conditions:
+
+ The above copyright notice and this permission notice shall be included
+ in all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ IN NO EVENT SHALL SIMON POSNJAK BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ OTHER DEALINGS IN THE SOFTWARE.
+ ----------------------------------------------------------------------- */
+
+#define LIBFFI_ASM
+#include <ffi.h>
+#define CONCAT(x,y) x ## y
+#define XCONCAT(x,y) CONCAT (x, y)
+#define L(x) XCONCAT (__USER_LABEL_PREFIX__, x)
+
+ .text
+
+ ;; OK, when we get called we should have this (according to
+ ;; AXIS ETRAX 100LX Programmer's Manual chapter 6.3).
+ ;;
+ ;; R10: ffi_prep_args (func. pointer)
+ ;; R11: &ecif
+ ;; R12: cif->bytes
+ ;; R13: fig->flags
+ ;; sp+0: ecif.rvalue
+ ;; sp+4: fn (function pointer to the function that we need to call)
+
+ .globl L(ffi_call_SYSV)
+ .type L(ffi_call_SYSV),@function
+ .hidden L(ffi_call_SYSV)
+
+L(ffi_call_SYSV):
+ ;; Save the regs to the stack.
+ push $srp
+ ;; Used for stack pointer saving.
+ push $r6
+ ;; Used for function address pointer.
+ push $r7
+ ;; Used for stack pointer saving.
+ push $r8
+ ;; We save fig->flags to stack we will need them after we
+ ;; call The Function.
+ push $r13
+
+ ;; Saving current stack pointer.
+ move.d $sp,$r8
+ move.d $sp,$r6
+
+ ;; Move address of ffi_prep_args to r13.
+ move.d $r10,$r13
+
+ ;; Make room on the stack for the args of fn.
+ sub.d $r12,$sp
+
+ ;; Function void ffi_prep_args(char *stack, extended_cif *ecif) parameters are:
+ ;; r10 <-- stack pointer
+ ;; r11 <-- &ecif (already there)
+ move.d $sp,$r10
+
+ ;; Call the function.
+ jsr $r13
+
+ ;; Save the size of the structures which are passed on stack.
+ move.d $r10,$r7
+
+ ;; Move first four args in to r10..r13.
+ move.d [$sp+0],$r10
+ move.d [$sp+4],$r11
+ move.d [$sp+8],$r12
+ move.d [$sp+12],$r13
+
+ ;; Adjust the stack and check if any parameters are given on stack.
+ addq 16,$sp
+ sub.d $r7,$r6
+ cmp.d $sp,$r6
+
+ bpl go_on
+ nop
+
+go_on_no_params_on_stack:
+ move.d $r6,$sp
+
+go_on:
+ ;; Discover if we need to put rval address in to r9.
+ move.d [$r8+0],$r7
+ cmpq FFI_TYPE_STRUCT,$r7
+ bne call_now
+ nop
+
+ ;; Move rval address to $r9.
+ move.d [$r8+20],$r9
+
+call_now:
+ ;; Move address of The Function in to r7.
+ move.d [$r8+24],$r7
+
+ ;; Call The Function.
+ jsr $r7
+
+ ;; Reset stack.
+ move.d $r8,$sp
+
+ ;; Load rval type (fig->flags) in to r13.
+ pop $r13
+
+ ;; Detect rval type.
+ cmpq FFI_TYPE_VOID,$r13
+ beq epilogue
+
+ cmpq FFI_TYPE_STRUCT,$r13
+ beq epilogue
+
+ cmpq FFI_TYPE_DOUBLE,$r13
+ beq return_double_or_longlong
+
+ cmpq FFI_TYPE_UINT64,$r13
+ beq return_double_or_longlong
+
+ cmpq FFI_TYPE_SINT64,$r13
+ beq return_double_or_longlong
+ nop
+
+ ;; Just return the 32 bit value.
+ ba return
+ nop
+
+return_double_or_longlong:
+ ;; Load half of the rval to r10 and the other half to r11.
+ move.d [$sp+16],$r13
+ move.d $r10,[$r13]
+ addq 4,$r13
+ move.d $r11,[$r13]
+ ba epilogue
+ nop
+
+return:
+ ;; Load the rval to r10.
+ move.d [$sp+16],$r13
+ move.d $r10,[$r13]
+
+epilogue:
+ pop $r8
+ pop $r7
+ pop $r6
+ Jump [$sp+]
+
+ .size ffi_call_SYSV,.-ffi_call_SYSV
+
+/* Save R10..R13 into an array, somewhat like varargs. Copy the next
+ argument too, to simplify handling of any straddling parameter.
+ Save R9 and SP after those. Jump to function handling the rest.
+ Since this is a template, copied and the main function filled in by
+ the user. */
+
+ .globl L(ffi_cris_trampoline_template)
+ .type L(ffi_cris_trampoline_template),@function
+ .hidden L(ffi_cris_trampoline_template)
+
+L(ffi_cris_trampoline_template):
+0:
+ /* The value we get for "PC" is right after the prefix instruction,
+ two bytes from the beginning, i.e. 0b+2. */
+ move.d $r10,[$pc+2f-(0b+2)]
+ move.d $pc,$r10
+1:
+ addq 2f-1b+4,$r10
+ move.d $r11,[$r10+]
+ move.d $r12,[$r10+]
+ move.d $r13,[$r10+]
+ move.d [$sp],$r11
+ move.d $r11,[$r10+]
+ move.d $r9,[$r10+]
+ move.d $sp,[$r10+]
+ subq FFI_CRIS_TRAMPOLINE_DATA_PART_SIZE,$r10
+ move.d 0,$r11
+3:
+ jump 0
+2:
+ .size ffi_cris_trampoline_template,.-0b
+
+/* This macro create a constant usable as "extern const int \name" in
+ C from within libffi, when \name has no prefix decoration. */
+
+ .macro const name,value
+ .globl \name
+ .type \name,@object
+ .hidden \name
+\name:
+ .dword \value
+ .size \name,4
+ .endm
+
+/* Constants for offsets within the trampoline. We could do this with
+ just symbols, avoiding memory contents and memory accesses, but the
+ C usage code would look a bit stranger. */
+
+ const L(ffi_cris_trampoline_fn_offset),2b-4-0b
+ const L(ffi_cris_trampoline_closure_offset),3b-4-0b
diff --git a/jni/ruby/ext/fiddle/libffi-3.2.1/src/debug.c b/jni/ruby/ext/fiddle/libffi-3.2.1/src/debug.c
new file mode 100644
index 0000000..f3172b1
--- /dev/null
+++ b/jni/ruby/ext/fiddle/libffi-3.2.1/src/debug.c
@@ -0,0 +1,64 @@
+/* -----------------------------------------------------------------------
+ debug.c - Copyright (c) 1996 Red Hat, Inc.
+
+ Permission is hereby granted, free of charge, to any person obtaining
+ a copy of this software and associated documentation files (the
+ ``Software''), to deal in the Software without restriction, including
+ without limitation the rights to use, copy, modify, merge, publish,
+ distribute, sublicense, and/or sell copies of the Software, and to
+ permit persons to whom the Software is furnished to do so, subject to
+ the following conditions:
+
+ The above copyright notice and this permission notice shall be included
+ in all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND,
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+ HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ DEALINGS IN THE SOFTWARE.
+ ----------------------------------------------------------------------- */
+
+#include <ffi.h>
+#include <ffi_common.h>
+#include <stdlib.h>
+#include <stdio.h>
+
+/* General debugging routines */
+
+void ffi_stop_here(void)
+{
+ /* This function is only useful for debugging purposes.
+ Place a breakpoint on ffi_stop_here to be notified of
+ significant events. */
+}
+
+/* This function should only be called via the FFI_ASSERT() macro */
+
+void ffi_assert(char *expr, char *file, int line)
+{
+ fprintf(stderr, "ASSERTION FAILURE: %s at %s:%d\n", expr, file, line);
+ ffi_stop_here();
+ abort();
+}
+
+/* Perform a sanity check on an ffi_type structure */
+
+void ffi_type_test(ffi_type *a, char *file, int line)
+{
+ FFI_ASSERT_AT(a != NULL, file, line);
+
+ FFI_ASSERT_AT(a->type <= FFI_TYPE_LAST, file, line);
+ FFI_ASSERT_AT(a->type == FFI_TYPE_VOID || a->size > 0, file, line);
+ FFI_ASSERT_AT(a->type == FFI_TYPE_VOID || a->alignment > 0, file, line);
+ FFI_ASSERT_AT((a->type != FFI_TYPE_STRUCT && a->type != FFI_TYPE_COMPLEX)
+ || a->elements != NULL, file, line);
+ FFI_ASSERT_AT(a->type != FFI_TYPE_COMPLEX
+ || (a->elements != NULL
+ && a->elements[0] != NULL && a->elements[1] == NULL),
+ file, line);
+
+}
diff --git a/jni/ruby/ext/fiddle/libffi-3.2.1/src/dlmalloc.c b/jni/ruby/ext/fiddle/libffi-3.2.1/src/dlmalloc.c
new file mode 100644
index 0000000..8725b4f
--- /dev/null
+++ b/jni/ruby/ext/fiddle/libffi-3.2.1/src/dlmalloc.c
@@ -0,0 +1,5161 @@
+/*
+ This is a version (aka dlmalloc) of malloc/free/realloc written by
+ Doug Lea and released to the public domain, as explained at
+ http://creativecommons.org/licenses/publicdomain. Send questions,
+ comments, complaints, performance data, etc to dl@cs.oswego.edu
+
+* Version 2.8.3 Thu Sep 22 11:16:15 2005 Doug Lea (dl at gee)
+
+ Note: There may be an updated version of this malloc obtainable at
+ ftp://gee.cs.oswego.edu/pub/misc/malloc.c
+ Check before installing!
+
+* Quickstart
+
+ This library is all in one file to simplify the most common usage:
+ ftp it, compile it (-O3), and link it into another program. All of
+ the compile-time options default to reasonable values for use on
+ most platforms. You might later want to step through various
+ compile-time and dynamic tuning options.
+
+ For convenience, an include file for code using this malloc is at:
+ ftp://gee.cs.oswego.edu/pub/misc/malloc-2.8.3.h
+ You don't really need this .h file unless you call functions not
+ defined in your system include files. The .h file contains only the
+ excerpts from this file needed for using this malloc on ANSI C/C++
+ systems, so long as you haven't changed compile-time options about
+ naming and tuning parameters. If you do, then you can create your
+ own malloc.h that does include all settings by cutting at the point
+ indicated below. Note that you may already by default be using a C
+ library containing a malloc that is based on some version of this
+ malloc (for example in linux). You might still want to use the one
+ in this file to customize settings or to avoid overheads associated
+ with library versions.
+
+* Vital statistics:
+
+ Supported pointer/size_t representation: 4 or 8 bytes
+ size_t MUST be an unsigned type of the same width as
+ pointers. (If you are using an ancient system that declares
+ size_t as a signed type, or need it to be a different width
+ than pointers, you can use a previous release of this malloc
+ (e.g. 2.7.2) supporting these.)
+
+ Alignment: 8 bytes (default)
+ This suffices for nearly all current machines and C compilers.
+ However, you can define MALLOC_ALIGNMENT to be wider than this
+ if necessary (up to 128bytes), at the expense of using more space.
+
+ Minimum overhead per allocated chunk: 4 or 8 bytes (if 4byte sizes)
+ 8 or 16 bytes (if 8byte sizes)
+ Each malloced chunk has a hidden word of overhead holding size
+ and status information, and additional cross-check word
+ if FOOTERS is defined.
+
+ Minimum allocated size: 4-byte ptrs: 16 bytes (including overhead)
+ 8-byte ptrs: 32 bytes (including overhead)
+
+ Even a request for zero bytes (i.e., malloc(0)) returns a
+ pointer to something of the minimum allocatable size.
+ The maximum overhead wastage (i.e., number of extra bytes
+ allocated than were requested in malloc) is less than or equal
+ to the minimum size, except for requests >= mmap_threshold that
+ are serviced via mmap(), where the worst case wastage is about
+ 32 bytes plus the remainder from a system page (the minimal
+ mmap unit); typically 4096 or 8192 bytes.
+
+ Security: static-safe; optionally more or less
+ The "security" of malloc refers to the ability of malicious
+ code to accentuate the effects of errors (for example, freeing
+ space that is not currently malloc'ed or overwriting past the
+ ends of chunks) in code that calls malloc. This malloc
+ guarantees not to modify any memory locations below the base of
+ heap, i.e., static variables, even in the presence of usage
+ errors. The routines additionally detect most improper frees
+ and reallocs. All this holds as long as the static bookkeeping
+ for malloc itself is not corrupted by some other means. This
+ is only one aspect of security -- these checks do not, and
+ cannot, detect all possible programming errors.
+
+ If FOOTERS is defined nonzero, then each allocated chunk
+ carries an additional check word to verify that it was malloced
+ from its space. These check words are the same within each
+ execution of a program using malloc, but differ across
+ executions, so externally crafted fake chunks cannot be
+ freed. This improves security by rejecting frees/reallocs that
+ could corrupt heap memory, in addition to the checks preventing
+ writes to statics that are always on. This may further improve
+ security at the expense of time and space overhead. (Note that
+ FOOTERS may also be worth using with MSPACES.)
+
+ By default detected errors cause the program to abort (calling
+ "abort()"). You can override this to instead proceed past
+ errors by defining PROCEED_ON_ERROR. In this case, a bad free
+ has no effect, and a malloc that encounters a bad address
+ caused by user overwrites will ignore the bad address by
+ dropping pointers and indices to all known memory. This may
+ be appropriate for programs that should continue if at all
+ possible in the face of programming errors, although they may
+ run out of memory because dropped memory is never reclaimed.
+
+ If you don't like either of these options, you can define
+ CORRUPTION_ERROR_ACTION and USAGE_ERROR_ACTION to do anything
+ else. And if if you are sure that your program using malloc has
+ no errors or vulnerabilities, you can define INSECURE to 1,
+ which might (or might not) provide a small performance improvement.
+
+ Thread-safety: NOT thread-safe unless USE_LOCKS defined
+ When USE_LOCKS is defined, each public call to malloc, free,
+ etc is surrounded with either a pthread mutex or a win32
+ spinlock (depending on WIN32). This is not especially fast, and
+ can be a major bottleneck. It is designed only to provide
+ minimal protection in concurrent environments, and to provide a
+ basis for extensions. If you are using malloc in a concurrent
+ program, consider instead using ptmalloc, which is derived from
+ a version of this malloc. (See http://www.malloc.de).
+
+ System requirements: Any combination of MORECORE and/or MMAP/MUNMAP
+ This malloc can use unix sbrk or any emulation (invoked using
+ the CALL_MORECORE macro) and/or mmap/munmap or any emulation
+ (invoked using CALL_MMAP/CALL_MUNMAP) to get and release system
+ memory. On most unix systems, it tends to work best if both
+ MORECORE and MMAP are enabled. On Win32, it uses emulations
+ based on VirtualAlloc. It also uses common C library functions
+ like memset.
+
+ Compliance: I believe it is compliant with the Single Unix Specification
+ (See http://www.unix.org). Also SVID/XPG, ANSI C, and probably
+ others as well.
+
+* Overview of algorithms
+
+ This is not the fastest, most space-conserving, most portable, or
+ most tunable malloc ever written. However it is among the fastest
+ while also being among the most space-conserving, portable and
+ tunable. Consistent balance across these factors results in a good
+ general-purpose allocator for malloc-intensive programs.
+
+ In most ways, this malloc is a best-fit allocator. Generally, it
+ chooses the best-fitting existing chunk for a request, with ties
+ broken in approximately least-recently-used order. (This strategy
+ normally maintains low fragmentation.) However, for requests less
+ than 256bytes, it deviates from best-fit when there is not an
+ exactly fitting available chunk by preferring to use space adjacent
+ to that used for the previous small request, as well as by breaking
+ ties in approximately most-recently-used order. (These enhance
+ locality of series of small allocations.) And for very large requests
+ (>= 256Kb by default), it relies on system memory mapping
+ facilities, if supported. (This helps avoid carrying around and
+ possibly fragmenting memory used only for large chunks.)
+
+ All operations (except malloc_stats and mallinfo) have execution
+ times that are bounded by a constant factor of the number of bits in
+ a size_t, not counting any clearing in calloc or copying in realloc,
+ or actions surrounding MORECORE and MMAP that have times
+ proportional to the number of non-contiguous regions returned by
+ system allocation routines, which is often just 1.
+
+ The implementation is not very modular and seriously overuses
+ macros. Perhaps someday all C compilers will do as good a job
+ inlining modular code as can now be done by brute-force expansion,
+ but now, enough of them seem not to.
+
+ Some compilers issue a lot of warnings about code that is
+ dead/unreachable only on some platforms, and also about intentional
+ uses of negation on unsigned types. All known cases of each can be
+ ignored.
+
+ For a longer but out of date high-level description, see
+ http://gee.cs.oswego.edu/dl/html/malloc.html
+
+* MSPACES
+ If MSPACES is defined, then in addition to malloc, free, etc.,
+ this file also defines mspace_malloc, mspace_free, etc. These
+ are versions of malloc routines that take an "mspace" argument
+ obtained using create_mspace, to control all internal bookkeeping.
+ If ONLY_MSPACES is defined, only these versions are compiled.
+ So if you would like to use this allocator for only some allocations,
+ and your system malloc for others, you can compile with
+ ONLY_MSPACES and then do something like...
+ static mspace mymspace = create_mspace(0,0); // for example
+ #define mymalloc(bytes) mspace_malloc(mymspace, bytes)
+
+ (Note: If you only need one instance of an mspace, you can instead
+ use "USE_DL_PREFIX" to relabel the global malloc.)
+
+ You can similarly create thread-local allocators by storing
+ mspaces as thread-locals. For example:
+ static __thread mspace tlms = 0;
+ void* tlmalloc(size_t bytes) {
+ if (tlms == 0) tlms = create_mspace(0, 0);
+ return mspace_malloc(tlms, bytes);
+ }
+ void tlfree(void* mem) { mspace_free(tlms, mem); }
+
+ Unless FOOTERS is defined, each mspace is completely independent.
+ You cannot allocate from one and free to another (although
+ conformance is only weakly checked, so usage errors are not always
+ caught). If FOOTERS is defined, then each chunk carries around a tag
+ indicating its originating mspace, and frees are directed to their
+ originating spaces.
+
+ ------------------------- Compile-time options ---------------------------
+
+Be careful in setting #define values for numerical constants of type
+size_t. On some systems, literal values are not automatically extended
+to size_t precision unless they are explicitly casted.
+
+WIN32 default: defined if _WIN32 defined
+ Defining WIN32 sets up defaults for MS environment and compilers.
+ Otherwise defaults are for unix.
+
+MALLOC_ALIGNMENT default: (size_t)8
+ Controls the minimum alignment for malloc'ed chunks. It must be a
+ power of two and at least 8, even on machines for which smaller
+ alignments would suffice. It may be defined as larger than this
+ though. Note however that code and data structures are optimized for
+ the case of 8-byte alignment.
+
+MSPACES default: 0 (false)
+ If true, compile in support for independent allocation spaces.
+ This is only supported if HAVE_MMAP is true.
+
+ONLY_MSPACES default: 0 (false)
+ If true, only compile in mspace versions, not regular versions.
+
+USE_LOCKS default: 0 (false)
+ Causes each call to each public routine to be surrounded with
+ pthread or WIN32 mutex lock/unlock. (If set true, this can be
+ overridden on a per-mspace basis for mspace versions.)
+
+FOOTERS default: 0
+ If true, provide extra checking and dispatching by placing
+ information in the footers of allocated chunks. This adds
+ space and time overhead.
+
+INSECURE default: 0
+ If true, omit checks for usage errors and heap space overwrites.
+
+USE_DL_PREFIX default: NOT defined
+ Causes compiler to prefix all public routines with the string 'dl'.
+ This can be useful when you only want to use this malloc in one part
+ of a program, using your regular system malloc elsewhere.
+
+ABORT default: defined as abort()
+ Defines how to abort on failed checks. On most systems, a failed
+ check cannot die with an "assert" or even print an informative
+ message, because the underlying print routines in turn call malloc,
+ which will fail again. Generally, the best policy is to simply call
+ abort(). It's not very useful to do more than this because many
+ errors due to overwriting will show up as address faults (null, odd
+ addresses etc) rather than malloc-triggered checks, so will also
+ abort. Also, most compilers know that abort() does not return, so
+ can better optimize code conditionally calling it.
+
+PROCEED_ON_ERROR default: defined as 0 (false)
+ Controls whether detected bad addresses cause them to bypassed
+ rather than aborting. If set, detected bad arguments to free and
+ realloc are ignored. And all bookkeeping information is zeroed out
+ upon a detected overwrite of freed heap space, thus losing the
+ ability to ever return it from malloc again, but enabling the
+ application to proceed. If PROCEED_ON_ERROR is defined, the
+ static variable malloc_corruption_error_count is compiled in
+ and can be examined to see if errors have occurred. This option
+ generates slower code than the default abort policy.
+
+DEBUG default: NOT defined
+ The DEBUG setting is mainly intended for people trying to modify
+ this code or diagnose problems when porting to new platforms.
+ However, it may also be able to better isolate user errors than just
+ using runtime checks. The assertions in the check routines spell
+ out in more detail the assumptions and invariants underlying the
+ algorithms. The checking is fairly extensive, and will slow down
+ execution noticeably. Calling malloc_stats or mallinfo with DEBUG
+ set will attempt to check every non-mmapped allocated and free chunk
+ in the course of computing the summaries.
+
+ABORT_ON_ASSERT_FAILURE default: defined as 1 (true)
+ Debugging assertion failures can be nearly impossible if your
+ version of the assert macro causes malloc to be called, which will
+ lead to a cascade of further failures, blowing the runtime stack.
+ ABORT_ON_ASSERT_FAILURE cause assertions failures to call abort(),
+ which will usually make debugging easier.
+
+MALLOC_FAILURE_ACTION default: sets errno to ENOMEM, or no-op on win32
+ The action to take before "return 0" when malloc fails to be able to
+ return memory because there is none available.
+
+HAVE_MORECORE default: 1 (true) unless win32 or ONLY_MSPACES
+ True if this system supports sbrk or an emulation of it.
+
+MORECORE default: sbrk
+ The name of the sbrk-style system routine to call to obtain more
+ memory. See below for guidance on writing custom MORECORE
+ functions. The type of the argument to sbrk/MORECORE varies across
+ systems. It cannot be size_t, because it supports negative
+ arguments, so it is normally the signed type of the same width as
+ size_t (sometimes declared as "intptr_t"). It doesn't much matter
+ though. Internally, we only call it with arguments less than half
+ the max value of a size_t, which should work across all reasonable
+ possibilities, although sometimes generating compiler warnings. See
+ near the end of this file for guidelines for creating a custom
+ version of MORECORE.
+
+MORECORE_CONTIGUOUS default: 1 (true)
+ If true, take advantage of fact that consecutive calls to MORECORE
+ with positive arguments always return contiguous increasing
+ addresses. This is true of unix sbrk. It does not hurt too much to
+ set it true anyway, since malloc copes with non-contiguities.
+ Setting it false when definitely non-contiguous saves time
+ and possibly wasted space it would take to discover this though.
+
+MORECORE_CANNOT_TRIM default: NOT defined
+ True if MORECORE cannot release space back to the system when given
+ negative arguments. This is generally necessary only if you are
+ using a hand-crafted MORECORE function that cannot handle negative
+ arguments.
+
+HAVE_MMAP default: 1 (true)
+ True if this system supports mmap or an emulation of it. If so, and
+ HAVE_MORECORE is not true, MMAP is used for all system
+ allocation. If set and HAVE_MORECORE is true as well, MMAP is
+ primarily used to directly allocate very large blocks. It is also
+ used as a backup strategy in cases where MORECORE fails to provide
+ space from system. Note: A single call to MUNMAP is assumed to be
+ able to unmap memory that may have be allocated using multiple calls
+ to MMAP, so long as they are adjacent.
+
+HAVE_MREMAP default: 1 on linux, else 0
+ If true realloc() uses mremap() to re-allocate large blocks and
+ extend or shrink allocation spaces.
+
+MMAP_CLEARS default: 1 on unix
+ True if mmap clears memory so calloc doesn't need to. This is true
+ for standard unix mmap using /dev/zero.
+
+USE_BUILTIN_FFS default: 0 (i.e., not used)
+ Causes malloc to use the builtin ffs() function to compute indices.
+ Some compilers may recognize and intrinsify ffs to be faster than the
+ supplied C version. Also, the case of x86 using gcc is special-cased
+ to an asm instruction, so is already as fast as it can be, and so
+ this setting has no effect. (On most x86s, the asm version is only
+ slightly faster than the C version.)
+
+malloc_getpagesize default: derive from system includes, or 4096.
+ The system page size. To the extent possible, this malloc manages
+ memory from the system in page-size units. This may be (and
+ usually is) a function rather than a constant. This is ignored
+ if WIN32, where page size is determined using getSystemInfo during
+ initialization.
+
+USE_DEV_RANDOM default: 0 (i.e., not used)
+ Causes malloc to use /dev/random to initialize secure magic seed for
+ stamping footers. Otherwise, the current time is used.
+
+NO_MALLINFO default: 0
+ If defined, don't compile "mallinfo". This can be a simple way
+ of dealing with mismatches between system declarations and
+ those in this file.
+
+MALLINFO_FIELD_TYPE default: size_t
+ The type of the fields in the mallinfo struct. This was originally
+ defined as "int" in SVID etc, but is more usefully defined as
+ size_t. The value is used only if HAVE_USR_INCLUDE_MALLOC_H is not set
+
+REALLOC_ZERO_BYTES_FREES default: not defined
+ This should be set if a call to realloc with zero bytes should
+ be the same as a call to free. Some people think it should. Otherwise,
+ since this malloc returns a unique pointer for malloc(0), so does
+ realloc(p, 0).
+
+LACKS_UNISTD_H, LACKS_FCNTL_H, LACKS_SYS_PARAM_H, LACKS_SYS_MMAN_H
+LACKS_STRINGS_H, LACKS_STRING_H, LACKS_SYS_TYPES_H, LACKS_ERRNO_H
+LACKS_STDLIB_H default: NOT defined unless on WIN32
+ Define these if your system does not have these header files.
+ You might need to manually insert some of the declarations they provide.
+
+DEFAULT_GRANULARITY default: page size if MORECORE_CONTIGUOUS,
+ system_info.dwAllocationGranularity in WIN32,
+ otherwise 64K.
+ Also settable using mallopt(M_GRANULARITY, x)
+ The unit for allocating and deallocating memory from the system. On
+ most systems with contiguous MORECORE, there is no reason to
+ make this more than a page. However, systems with MMAP tend to
+ either require or encourage larger granularities. You can increase
+ this value to prevent system allocation functions to be called so
+ often, especially if they are slow. The value must be at least one
+ page and must be a power of two. Setting to 0 causes initialization
+ to either page size or win32 region size. (Note: In previous
+ versions of malloc, the equivalent of this option was called
+ "TOP_PAD")
+
+DEFAULT_TRIM_THRESHOLD default: 2MB
+ Also settable using mallopt(M_TRIM_THRESHOLD, x)
+ The maximum amount of unused top-most memory to keep before
+ releasing via malloc_trim in free(). Automatic trimming is mainly
+ useful in long-lived programs using contiguous MORECORE. Because
+ trimming via sbrk can be slow on some systems, and can sometimes be
+ wasteful (in cases where programs immediately afterward allocate
+ more large chunks) the value should be high enough so that your
+ overall system performance would improve by releasing this much
+ memory. As a rough guide, you might set to a value close to the
+ average size of a process (program) running on your system.
+ Releasing this much memory would allow such a process to run in
+ memory. Generally, it is worth tuning trim thresholds when a
+ program undergoes phases where several large chunks are allocated
+ and released in ways that can reuse each other's storage, perhaps
+ mixed with phases where there are no such chunks at all. The trim
+ value must be greater than page size to have any useful effect. To
+ disable trimming completely, you can set to MAX_SIZE_T. Note that the trick
+ some people use of mallocing a huge space and then freeing it at
+ program startup, in an attempt to reserve system memory, doesn't
+ have the intended effect under automatic trimming, since that memory
+ will immediately be returned to the system.
+
+DEFAULT_MMAP_THRESHOLD default: 256K
+ Also settable using mallopt(M_MMAP_THRESHOLD, x)
+ The request size threshold for using MMAP to directly service a
+ request. Requests of at least this size that cannot be allocated
+ using already-existing space will be serviced via mmap. (If enough
+ normal freed space already exists it is used instead.) Using mmap
+ segregates relatively large chunks of memory so that they can be
+ individually obtained and released from the host system. A request
+ serviced through mmap is never reused by any other request (at least
+ not directly; the system may just so happen to remap successive
+ requests to the same locations). Segregating space in this way has
+ the benefits that: Mmapped space can always be individually released
+ back to the system, which helps keep the system level memory demands
+ of a long-lived program low. Also, mapped memory doesn't become
+ `locked' between other chunks, as can happen with normally allocated
+ chunks, which means that even trimming via malloc_trim would not
+ release them. However, it has the disadvantage that the space
+ cannot be reclaimed, consolidated, and then used to service later
+ requests, as happens with normal chunks. The advantages of mmap
+ nearly always outweigh disadvantages for "large" chunks, but the
+ value of "large" may vary across systems. The default is an
+ empirically derived value that works well in most systems. You can
+ disable mmap by setting to MAX_SIZE_T.
+
+*/
+
+#ifndef WIN32
+#ifdef _WIN32
+#define WIN32 1
+#endif /* _WIN32 */
+#endif /* WIN32 */
+#ifdef WIN32
+#define WIN32_LEAN_AND_MEAN
+#include <windows.h>
+#define HAVE_MMAP 1
+#define HAVE_MORECORE 0
+#define LACKS_UNISTD_H
+#define LACKS_SYS_PARAM_H
+#define LACKS_SYS_MMAN_H
+#define LACKS_STRING_H
+#define LACKS_STRINGS_H
+#define LACKS_SYS_TYPES_H
+#define LACKS_ERRNO_H
+#define MALLOC_FAILURE_ACTION
+#define MMAP_CLEARS 0 /* WINCE and some others apparently don't clear */
+#endif /* WIN32 */
+
+#ifdef __OS2__
+#define INCL_DOS
+#include <os2.h>
+#define HAVE_MMAP 1
+#define HAVE_MORECORE 0
+#define LACKS_SYS_MMAN_H
+#endif /* __OS2__ */
+
+#if defined(DARWIN) || defined(_DARWIN)
+/* Mac OSX docs advise not to use sbrk; it seems better to use mmap */
+#ifndef HAVE_MORECORE
+#define HAVE_MORECORE 0
+#define HAVE_MMAP 1
+#endif /* HAVE_MORECORE */
+#endif /* DARWIN */
+
+#ifndef LACKS_SYS_TYPES_H
+#include <sys/types.h> /* For size_t */
+#endif /* LACKS_SYS_TYPES_H */
+
+/* The maximum possible size_t value has all bits set */
+#define MAX_SIZE_T (~(size_t)0)
+
+#ifndef ONLY_MSPACES
+#define ONLY_MSPACES 0
+#endif /* ONLY_MSPACES */
+#ifndef MSPACES
+#if ONLY_MSPACES
+#define MSPACES 1
+#else /* ONLY_MSPACES */
+#define MSPACES 0
+#endif /* ONLY_MSPACES */
+#endif /* MSPACES */
+#ifndef MALLOC_ALIGNMENT
+#define MALLOC_ALIGNMENT ((size_t)8U)
+#endif /* MALLOC_ALIGNMENT */
+#ifndef FOOTERS
+#define FOOTERS 0
+#endif /* FOOTERS */
+#ifndef ABORT
+#define ABORT abort()
+#endif /* ABORT */
+#ifndef ABORT_ON_ASSERT_FAILURE
+#define ABORT_ON_ASSERT_FAILURE 1
+#endif /* ABORT_ON_ASSERT_FAILURE */
+#ifndef PROCEED_ON_ERROR
+#define PROCEED_ON_ERROR 0
+#endif /* PROCEED_ON_ERROR */
+#ifndef USE_LOCKS
+#define USE_LOCKS 0
+#endif /* USE_LOCKS */
+#ifndef INSECURE
+#define INSECURE 0
+#endif /* INSECURE */
+#ifndef HAVE_MMAP
+#define HAVE_MMAP 1
+#endif /* HAVE_MMAP */
+#ifndef MMAP_CLEARS
+#define MMAP_CLEARS 1
+#endif /* MMAP_CLEARS */
+#ifndef HAVE_MREMAP
+#ifdef linux
+#define HAVE_MREMAP 1
+#else /* linux */
+#define HAVE_MREMAP 0
+#endif /* linux */
+#endif /* HAVE_MREMAP */
+#ifndef MALLOC_FAILURE_ACTION
+#define MALLOC_FAILURE_ACTION errno = ENOMEM;
+#endif /* MALLOC_FAILURE_ACTION */
+#ifndef HAVE_MORECORE
+#if ONLY_MSPACES
+#define HAVE_MORECORE 0
+#else /* ONLY_MSPACES */
+#define HAVE_MORECORE 1
+#endif /* ONLY_MSPACES */
+#endif /* HAVE_MORECORE */
+#if !HAVE_MORECORE
+#define MORECORE_CONTIGUOUS 0
+#else /* !HAVE_MORECORE */
+#ifndef MORECORE
+#define MORECORE sbrk
+#endif /* MORECORE */
+#ifndef MORECORE_CONTIGUOUS
+#define MORECORE_CONTIGUOUS 1
+#endif /* MORECORE_CONTIGUOUS */
+#endif /* HAVE_MORECORE */
+#ifndef DEFAULT_GRANULARITY
+#if MORECORE_CONTIGUOUS
+#define DEFAULT_GRANULARITY (0) /* 0 means to compute in init_mparams */
+#else /* MORECORE_CONTIGUOUS */
+#define DEFAULT_GRANULARITY ((size_t)64U * (size_t)1024U)
+#endif /* MORECORE_CONTIGUOUS */
+#endif /* DEFAULT_GRANULARITY */
+#ifndef DEFAULT_TRIM_THRESHOLD
+#ifndef MORECORE_CANNOT_TRIM
+#define DEFAULT_TRIM_THRESHOLD ((size_t)2U * (size_t)1024U * (size_t)1024U)
+#else /* MORECORE_CANNOT_TRIM */
+#define DEFAULT_TRIM_THRESHOLD MAX_SIZE_T
+#endif /* MORECORE_CANNOT_TRIM */
+#endif /* DEFAULT_TRIM_THRESHOLD */
+#ifndef DEFAULT_MMAP_THRESHOLD
+#if HAVE_MMAP
+#define DEFAULT_MMAP_THRESHOLD ((size_t)256U * (size_t)1024U)
+#else /* HAVE_MMAP */
+#define DEFAULT_MMAP_THRESHOLD MAX_SIZE_T
+#endif /* HAVE_MMAP */
+#endif /* DEFAULT_MMAP_THRESHOLD */
+#ifndef USE_BUILTIN_FFS
+#define USE_BUILTIN_FFS 0
+#endif /* USE_BUILTIN_FFS */
+#ifndef USE_DEV_RANDOM
+#define USE_DEV_RANDOM 0
+#endif /* USE_DEV_RANDOM */
+#ifndef NO_MALLINFO
+#define NO_MALLINFO 0
+#endif /* NO_MALLINFO */
+#ifndef MALLINFO_FIELD_TYPE
+#define MALLINFO_FIELD_TYPE size_t
+#endif /* MALLINFO_FIELD_TYPE */
+
+/*
+ mallopt tuning options. SVID/XPG defines four standard parameter
+ numbers for mallopt, normally defined in malloc.h. None of these
+ are used in this malloc, so setting them has no effect. But this
+ malloc does support the following options.
+*/
+
+#define M_TRIM_THRESHOLD (-1)
+#define M_GRANULARITY (-2)
+#define M_MMAP_THRESHOLD (-3)
+
+/* ------------------------ Mallinfo declarations ------------------------ */
+
+#if !NO_MALLINFO
+/*
+ This version of malloc supports the standard SVID/XPG mallinfo
+ routine that returns a struct containing usage properties and
+ statistics. It should work on any system that has a
+ /usr/include/malloc.h defining struct mallinfo. The main
+ declaration needed is the mallinfo struct that is returned (by-copy)
+ by mallinfo(). The malloinfo struct contains a bunch of fields that
+ are not even meaningful in this version of malloc. These fields are
+ are instead filled by mallinfo() with other numbers that might be of
+ interest.
+
+ HAVE_USR_INCLUDE_MALLOC_H should be set if you have a
+ /usr/include/malloc.h file that includes a declaration of struct
+ mallinfo. If so, it is included; else a compliant version is
+ declared below. These must be precisely the same for mallinfo() to
+ work. The original SVID version of this struct, defined on most
+ systems with mallinfo, declares all fields as ints. But some others
+ define as unsigned long. If your system defines the fields using a
+ type of different width than listed here, you MUST #include your
+ system version and #define HAVE_USR_INCLUDE_MALLOC_H.
+*/
+
+/* #define HAVE_USR_INCLUDE_MALLOC_H */
+
+#ifdef HAVE_USR_INCLUDE_MALLOC_H
+#include "/usr/include/malloc.h"
+#else /* HAVE_USR_INCLUDE_MALLOC_H */
+
+/* HP-UX's stdlib.h redefines mallinfo unless _STRUCT_MALLINFO is defined */
+#define _STRUCT_MALLINFO
+
+struct mallinfo {
+ MALLINFO_FIELD_TYPE arena; /* non-mmapped space allocated from system */
+ MALLINFO_FIELD_TYPE ordblks; /* number of free chunks */
+ MALLINFO_FIELD_TYPE smblks; /* always 0 */
+ MALLINFO_FIELD_TYPE hblks; /* always 0 */
+ MALLINFO_FIELD_TYPE hblkhd; /* space in mmapped regions */
+ MALLINFO_FIELD_TYPE usmblks; /* maximum total allocated space */
+ MALLINFO_FIELD_TYPE fsmblks; /* always 0 */
+ MALLINFO_FIELD_TYPE uordblks; /* total allocated space */
+ MALLINFO_FIELD_TYPE fordblks; /* total free space */
+ MALLINFO_FIELD_TYPE keepcost; /* releasable (via malloc_trim) space */
+};
+
+#endif /* HAVE_USR_INCLUDE_MALLOC_H */
+#endif /* NO_MALLINFO */
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+#if !ONLY_MSPACES
+
+/* ------------------- Declarations of public routines ------------------- */
+
+#ifndef USE_DL_PREFIX
+#define dlcalloc calloc
+#define dlfree free
+#define dlmalloc malloc
+#define dlmemalign memalign
+#define dlrealloc realloc
+#define dlvalloc valloc
+#define dlpvalloc pvalloc
+#define dlmallinfo mallinfo
+#define dlmallopt mallopt
+#define dlmalloc_trim malloc_trim
+#define dlmalloc_stats malloc_stats
+#define dlmalloc_usable_size malloc_usable_size
+#define dlmalloc_footprint malloc_footprint
+#define dlmalloc_max_footprint malloc_max_footprint
+#define dlindependent_calloc independent_calloc
+#define dlindependent_comalloc independent_comalloc
+#endif /* USE_DL_PREFIX */
+
+
+/*
+ malloc(size_t n)
+ Returns a pointer to a newly allocated chunk of at least n bytes, or
+ null if no space is available, in which case errno is set to ENOMEM
+ on ANSI C systems.
+
+ If n is zero, malloc returns a minimum-sized chunk. (The minimum
+ size is 16 bytes on most 32bit systems, and 32 bytes on 64bit
+ systems.) Note that size_t is an unsigned type, so calls with
+ arguments that would be negative if signed are interpreted as
+ requests for huge amounts of space, which will often fail. The
+ maximum supported value of n differs across systems, but is in all
+ cases less than the maximum representable value of a size_t.
+*/
+void* dlmalloc(size_t);
+
+/*
+ free(void* p)
+ Releases the chunk of memory pointed to by p, that had been previously
+ allocated using malloc or a related routine such as realloc.
+ It has no effect if p is null. If p was not malloced or already
+ freed, free(p) will by default cause the current program to abort.
+*/
+void dlfree(void*);
+
+/*
+ calloc(size_t n_elements, size_t element_size);
+ Returns a pointer to n_elements * element_size bytes, with all locations
+ set to zero.
+*/
+void* dlcalloc(size_t, size_t);
+
+/*
+ realloc(void* p, size_t n)
+ Returns a pointer to a chunk of size n that contains the same data
+ as does chunk p up to the minimum of (n, p's size) bytes, or null
+ if no space is available.
+
+ The returned pointer may or may not be the same as p. The algorithm
+ prefers extending p in most cases when possible, otherwise it
+ employs the equivalent of a malloc-copy-free sequence.
+
+ If p is null, realloc is equivalent to malloc.
+
+ If space is not available, realloc returns null, errno is set (if on
+ ANSI) and p is NOT freed.
+
+ if n is for fewer bytes than already held by p, the newly unused
+ space is lopped off and freed if possible. realloc with a size
+ argument of zero (re)allocates a minimum-sized chunk.
+
+ The old unix realloc convention of allowing the last-free'd chunk
+ to be used as an argument to realloc is not supported.
+*/
+
+void* dlrealloc(void*, size_t);
+
+/*
+ memalign(size_t alignment, size_t n);
+ Returns a pointer to a newly allocated chunk of n bytes, aligned
+ in accord with the alignment argument.
+
+ The alignment argument should be a power of two. If the argument is
+ not a power of two, the nearest greater power is used.
+ 8-byte alignment is guaranteed by normal malloc calls, so don't
+ bother calling memalign with an argument of 8 or less.
+
+ Overreliance on memalign is a sure way to fragment space.
+*/
+void* dlmemalign(size_t, size_t);
+
+/*
+ valloc(size_t n);
+ Equivalent to memalign(pagesize, n), where pagesize is the page
+ size of the system. If the pagesize is unknown, 4096 is used.
+*/
+void* dlvalloc(size_t);
+
+/*
+ mallopt(int parameter_number, int parameter_value)
+ Sets tunable parameters The format is to provide a
+ (parameter-number, parameter-value) pair. mallopt then sets the
+ corresponding parameter to the argument value if it can (i.e., so
+ long as the value is meaningful), and returns 1 if successful else
+ 0. SVID/XPG/ANSI defines four standard param numbers for mallopt,
+ normally defined in malloc.h. None of these are use in this malloc,
+ so setting them has no effect. But this malloc also supports other
+ options in mallopt. See below for details. Briefly, supported
+ parameters are as follows (listed defaults are for "typical"
+ configurations).
+
+ Symbol param # default allowed param values
+ M_TRIM_THRESHOLD -1 2*1024*1024 any (MAX_SIZE_T disables)
+ M_GRANULARITY -2 page size any power of 2 >= page size
+ M_MMAP_THRESHOLD -3 256*1024 any (or 0 if no MMAP support)
+*/
+int dlmallopt(int, int);
+
+/*
+ malloc_footprint();
+ Returns the number of bytes obtained from the system. The total
+ number of bytes allocated by malloc, realloc etc., is less than this
+ value. Unlike mallinfo, this function returns only a precomputed
+ result, so can be called frequently to monitor memory consumption.
+ Even if locks are otherwise defined, this function does not use them,
+ so results might not be up to date.
+*/
+size_t dlmalloc_footprint(void);
+
+/*
+ malloc_max_footprint();
+ Returns the maximum number of bytes obtained from the system. This
+ value will be greater than current footprint if deallocated space
+ has been reclaimed by the system. The peak number of bytes allocated
+ by malloc, realloc etc., is less than this value. Unlike mallinfo,
+ this function returns only a precomputed result, so can be called
+ frequently to monitor memory consumption. Even if locks are
+ otherwise defined, this function does not use them, so results might
+ not be up to date.
+*/
+size_t dlmalloc_max_footprint(void);
+
+#if !NO_MALLINFO
+/*
+ mallinfo()
+ Returns (by copy) a struct containing various summary statistics:
+
+ arena: current total non-mmapped bytes allocated from system
+ ordblks: the number of free chunks
+ smblks: always zero.
+ hblks: current number of mmapped regions
+ hblkhd: total bytes held in mmapped regions
+ usmblks: the maximum total allocated space. This will be greater
+ than current total if trimming has occurred.
+ fsmblks: always zero
+ uordblks: current total allocated space (normal or mmapped)
+ fordblks: total free space
+ keepcost: the maximum number of bytes that could ideally be released
+ back to system via malloc_trim. ("ideally" means that
+ it ignores page restrictions etc.)
+
+ Because these fields are ints, but internal bookkeeping may
+ be kept as longs, the reported values may wrap around zero and
+ thus be inaccurate.
+*/
+struct mallinfo dlmallinfo(void);
+#endif /* NO_MALLINFO */
+
+/*
+ independent_calloc(size_t n_elements, size_t element_size, void* chunks[]);
+
+ independent_calloc is similar to calloc, but instead of returning a
+ single cleared space, it returns an array of pointers to n_elements
+ independent elements that can hold contents of size elem_size, each
+ of which starts out cleared, and can be independently freed,
+ realloc'ed etc. The elements are guaranteed to be adjacently
+ allocated (this is not guaranteed to occur with multiple callocs or
+ mallocs), which may also improve cache locality in some
+ applications.
+
+ The "chunks" argument is optional (i.e., may be null, which is
+ probably the most typical usage). If it is null, the returned array
+ is itself dynamically allocated and should also be freed when it is
+ no longer needed. Otherwise, the chunks array must be of at least
+ n_elements in length. It is filled in with the pointers to the
+ chunks.
+
+ In either case, independent_calloc returns this pointer array, or
+ null if the allocation failed. If n_elements is zero and "chunks"
+ is null, it returns a chunk representing an array with zero elements
+ (which should be freed if not wanted).
+
+ Each element must be individually freed when it is no longer
+ needed. If you'd like to instead be able to free all at once, you
+ should instead use regular calloc and assign pointers into this
+ space to represent elements. (In this case though, you cannot
+ independently free elements.)
+
+ independent_calloc simplifies and speeds up implementations of many
+ kinds of pools. It may also be useful when constructing large data
+ structures that initially have a fixed number of fixed-sized nodes,
+ but the number is not known at compile time, and some of the nodes
+ may later need to be freed. For example:
+
+ struct Node { int item; struct Node* next; };
+
+ struct Node* build_list() {
+ struct Node** pool;
+ int n = read_number_of_nodes_needed();
+ if (n <= 0) return 0;
+ pool = (struct Node**)(independent_calloc(n, sizeof(struct Node), 0);
+ if (pool == 0) die();
+ // organize into a linked list...
+ struct Node* first = pool[0];
+ for (i = 0; i < n-1; ++i)
+ pool[i]->next = pool[i+1];
+ free(pool); // Can now free the array (or not, if it is needed later)
+ return first;
+ }
+*/
+void** dlindependent_calloc(size_t, size_t, void**);
+
+/*
+ independent_comalloc(size_t n_elements, size_t sizes[], void* chunks[]);
+
+ independent_comalloc allocates, all at once, a set of n_elements
+ chunks with sizes indicated in the "sizes" array. It returns
+ an array of pointers to these elements, each of which can be
+ independently freed, realloc'ed etc. The elements are guaranteed to
+ be adjacently allocated (this is not guaranteed to occur with
+ multiple callocs or mallocs), which may also improve cache locality
+ in some applications.
+
+ The "chunks" argument is optional (i.e., may be null). If it is null
+ the returned array is itself dynamically allocated and should also
+ be freed when it is no longer needed. Otherwise, the chunks array
+ must be of at least n_elements in length. It is filled in with the
+ pointers to the chunks.
+
+ In either case, independent_comalloc returns this pointer array, or
+ null if the allocation failed. If n_elements is zero and chunks is
+ null, it returns a chunk representing an array with zero elements
+ (which should be freed if not wanted).
+
+ Each element must be individually freed when it is no longer
+ needed. If you'd like to instead be able to free all at once, you
+ should instead use a single regular malloc, and assign pointers at
+ particular offsets in the aggregate space. (In this case though, you
+ cannot independently free elements.)
+
+ independent_comallac differs from independent_calloc in that each
+ element may have a different size, and also that it does not
+ automatically clear elements.
+
+ independent_comalloc can be used to speed up allocation in cases
+ where several structs or objects must always be allocated at the
+ same time. For example:
+
+ struct Head { ... }
+ struct Foot { ... }
+
+ void send_message(char* msg) {
+ int msglen = strlen(msg);
+ size_t sizes[3] = { sizeof(struct Head), msglen, sizeof(struct Foot) };
+ void* chunks[3];
+ if (independent_comalloc(3, sizes, chunks) == 0)
+ die();
+ struct Head* head = (struct Head*)(chunks[0]);
+ char* body = (char*)(chunks[1]);
+ struct Foot* foot = (struct Foot*)(chunks[2]);
+ // ...
+ }
+
+ In general though, independent_comalloc is worth using only for
+ larger values of n_elements. For small values, you probably won't
+ detect enough difference from series of malloc calls to bother.
+
+ Overuse of independent_comalloc can increase overall memory usage,
+ since it cannot reuse existing noncontiguous small chunks that
+ might be available for some of the elements.
+*/
+void** dlindependent_comalloc(size_t, size_t*, void**);
+
+
+/*
+ pvalloc(size_t n);
+ Equivalent to valloc(minimum-page-that-holds(n)), that is,
+ round up n to nearest pagesize.
+ */
+void* dlpvalloc(size_t);
+
+/*
+ malloc_trim(size_t pad);
+
+ If possible, gives memory back to the system (via negative arguments
+ to sbrk) if there is unused memory at the `high' end of the malloc
+ pool or in unused MMAP segments. You can call this after freeing
+ large blocks of memory to potentially reduce the system-level memory
+ requirements of a program. However, it cannot guarantee to reduce
+ memory. Under some allocation patterns, some large free blocks of
+ memory will be locked between two used chunks, so they cannot be
+ given back to the system.
+
+ The `pad' argument to malloc_trim represents the amount of free
+ trailing space to leave untrimmed. If this argument is zero, only
+ the minimum amount of memory to maintain internal data structures
+ will be left. Non-zero arguments can be supplied to maintain enough
+ trailing space to service future expected allocations without having
+ to re-obtain memory from the system.
+
+ Malloc_trim returns 1 if it actually released any memory, else 0.
+*/
+int dlmalloc_trim(size_t);
+
+/*
+ malloc_usable_size(void* p);
+
+ Returns the number of bytes you can actually use in
+ an allocated chunk, which may be more than you requested (although
+ often not) due to alignment and minimum size constraints.
+ You can use this many bytes without worrying about
+ overwriting other allocated objects. This is not a particularly great
+ programming practice. malloc_usable_size can be more useful in
+ debugging and assertions, for example:
+
+ p = malloc(n);
+ assert(malloc_usable_size(p) >= 256);
+*/
+size_t dlmalloc_usable_size(void*);
+
+/*
+ malloc_stats();
+ Prints on stderr the amount of space obtained from the system (both
+ via sbrk and mmap), the maximum amount (which may be more than
+ current if malloc_trim and/or munmap got called), and the current
+ number of bytes allocated via malloc (or realloc, etc) but not yet
+ freed. Note that this is the number of bytes allocated, not the
+ number requested. It will be larger than the number requested
+ because of alignment and bookkeeping overhead. Because it includes
+ alignment wastage as being in use, this figure may be greater than
+ zero even when no user-level chunks are allocated.
+
+ The reported current and maximum system memory can be inaccurate if
+ a program makes other calls to system memory allocation functions
+ (normally sbrk) outside of malloc.
+
+ malloc_stats prints only the most commonly interesting statistics.
+ More information can be obtained by calling mallinfo.
+*/
+void dlmalloc_stats(void);
+
+#endif /* ONLY_MSPACES */
+
+#if MSPACES
+
+/*
+ mspace is an opaque type representing an independent
+ region of space that supports mspace_malloc, etc.
+*/
+typedef void* mspace;
+
+/*
+ create_mspace creates and returns a new independent space with the
+ given initial capacity, or, if 0, the default granularity size. It
+ returns null if there is no system memory available to create the
+ space. If argument locked is non-zero, the space uses a separate
+ lock to control access. The capacity of the space will grow
+ dynamically as needed to service mspace_malloc requests. You can
+ control the sizes of incremental increases of this space by
+ compiling with a different DEFAULT_GRANULARITY or dynamically
+ setting with mallopt(M_GRANULARITY, value).
+*/
+mspace create_mspace(size_t capacity, int locked);
+
+/*
+ destroy_mspace destroys the given space, and attempts to return all
+ of its memory back to the system, returning the total number of
+ bytes freed. After destruction, the results of access to all memory
+ used by the space become undefined.
+*/
+size_t destroy_mspace(mspace msp);
+
+/*
+ create_mspace_with_base uses the memory supplied as the initial base
+ of a new mspace. Part (less than 128*sizeof(size_t) bytes) of this
+ space is used for bookkeeping, so the capacity must be at least this
+ large. (Otherwise 0 is returned.) When this initial space is
+ exhausted, additional memory will be obtained from the system.
+ Destroying this space will deallocate all additionally allocated
+ space (if possible) but not the initial base.
+*/
+mspace create_mspace_with_base(void* base, size_t capacity, int locked);
+
+/*
+ mspace_malloc behaves as malloc, but operates within
+ the given space.
+*/
+void* mspace_malloc(mspace msp, size_t bytes);
+
+/*
+ mspace_free behaves as free, but operates within
+ the given space.
+
+ If compiled with FOOTERS==1, mspace_free is not actually needed.
+ free may be called instead of mspace_free because freed chunks from
+ any space are handled by their originating spaces.
+*/
+void mspace_free(mspace msp, void* mem);
+
+/*
+ mspace_realloc behaves as realloc, but operates within
+ the given space.
+
+ If compiled with FOOTERS==1, mspace_realloc is not actually
+ needed. realloc may be called instead of mspace_realloc because
+ realloced chunks from any space are handled by their originating
+ spaces.
+*/
+void* mspace_realloc(mspace msp, void* mem, size_t newsize);
+
+/*
+ mspace_calloc behaves as calloc, but operates within
+ the given space.
+*/
+void* mspace_calloc(mspace msp, size_t n_elements, size_t elem_size);
+
+/*
+ mspace_memalign behaves as memalign, but operates within
+ the given space.
+*/
+void* mspace_memalign(mspace msp, size_t alignment, size_t bytes);
+
+/*
+ mspace_independent_calloc behaves as independent_calloc, but
+ operates within the given space.
+*/
+void** mspace_independent_calloc(mspace msp, size_t n_elements,
+ size_t elem_size, void* chunks[]);
+
+/*
+ mspace_independent_comalloc behaves as independent_comalloc, but
+ operates within the given space.
+*/
+void** mspace_independent_comalloc(mspace msp, size_t n_elements,
+ size_t sizes[], void* chunks[]);
+
+/*
+ mspace_footprint() returns the number of bytes obtained from the
+ system for this space.
+*/
+size_t mspace_footprint(mspace msp);
+
+/*
+ mspace_max_footprint() returns the peak number of bytes obtained from the
+ system for this space.
+*/
+size_t mspace_max_footprint(mspace msp);
+
+
+#if !NO_MALLINFO
+/*
+ mspace_mallinfo behaves as mallinfo, but reports properties of
+ the given space.
+*/
+struct mallinfo mspace_mallinfo(mspace msp);
+#endif /* NO_MALLINFO */
+
+/*
+ mspace_malloc_stats behaves as malloc_stats, but reports
+ properties of the given space.
+*/
+void mspace_malloc_stats(mspace msp);
+
+/*
+ mspace_trim behaves as malloc_trim, but
+ operates within the given space.
+*/
+int mspace_trim(mspace msp, size_t pad);
+
+/*
+ An alias for mallopt.
+*/
+int mspace_mallopt(int, int);
+
+#endif /* MSPACES */
+
+#ifdef __cplusplus
+}; /* end of extern "C" */
+#endif /* __cplusplus */
+
+/*
+ ========================================================================
+ To make a fully customizable malloc.h header file, cut everything
+ above this line, put into file malloc.h, edit to suit, and #include it
+ on the next line, as well as in programs that use this malloc.
+ ========================================================================
+*/
+
+/* #include "malloc.h" */
+
+/*------------------------------ internal #includes ---------------------- */
+
+#ifdef _MSC_VER
+#pragma warning( disable : 4146 ) /* no "unsigned" warnings */
+#endif /* _MSC_VER */
+
+#include <stdio.h> /* for printing in malloc_stats */
+
+#ifndef LACKS_ERRNO_H
+#include <errno.h> /* for MALLOC_FAILURE_ACTION */
+#endif /* LACKS_ERRNO_H */
+#if FOOTERS
+#include <time.h> /* for magic initialization */
+#endif /* FOOTERS */
+#ifndef LACKS_STDLIB_H
+#include <stdlib.h> /* for abort() */
+#endif /* LACKS_STDLIB_H */
+#ifdef DEBUG
+#if ABORT_ON_ASSERT_FAILURE
+#define assert(x) if(!(x)) ABORT
+#else /* ABORT_ON_ASSERT_FAILURE */
+#include <assert.h>
+#endif /* ABORT_ON_ASSERT_FAILURE */
+#else /* DEBUG */
+#define assert(x)
+#endif /* DEBUG */
+#ifndef LACKS_STRING_H
+#include <string.h> /* for memset etc */
+#endif /* LACKS_STRING_H */
+#if USE_BUILTIN_FFS
+#ifndef LACKS_STRINGS_H
+#include <strings.h> /* for ffs */
+#endif /* LACKS_STRINGS_H */
+#endif /* USE_BUILTIN_FFS */
+#if HAVE_MMAP
+#ifndef LACKS_SYS_MMAN_H
+#include <sys/mman.h> /* for mmap */
+#endif /* LACKS_SYS_MMAN_H */
+#ifndef LACKS_FCNTL_H
+#include <fcntl.h>
+#endif /* LACKS_FCNTL_H */
+#endif /* HAVE_MMAP */
+#if HAVE_MORECORE
+#ifndef LACKS_UNISTD_H
+#include <unistd.h> /* for sbrk */
+#else /* LACKS_UNISTD_H */
+#if !defined(__FreeBSD__) && !defined(__OpenBSD__) && !defined(__NetBSD__)
+extern void* sbrk(ptrdiff_t);
+#endif /* FreeBSD etc */
+#endif /* LACKS_UNISTD_H */
+#endif /* HAVE_MMAP */
+
+#ifndef WIN32
+#ifndef malloc_getpagesize
+# ifdef _SC_PAGESIZE /* some SVR4 systems omit an underscore */
+# ifndef _SC_PAGE_SIZE
+# define _SC_PAGE_SIZE _SC_PAGESIZE
+# endif
+# endif
+# ifdef _SC_PAGE_SIZE
+# define malloc_getpagesize sysconf(_SC_PAGE_SIZE)
+# else
+# if defined(BSD) || defined(DGUX) || defined(HAVE_GETPAGESIZE)
+ extern size_t getpagesize();
+# define malloc_getpagesize getpagesize()
+# else
+# ifdef WIN32 /* use supplied emulation of getpagesize */
+# define malloc_getpagesize getpagesize()
+# else
+# ifndef LACKS_SYS_PARAM_H
+# include <sys/param.h>
+# endif
+# ifdef EXEC_PAGESIZE
+# define malloc_getpagesize EXEC_PAGESIZE
+# else
+# ifdef NBPG
+# ifndef CLSIZE
+# define malloc_getpagesize NBPG
+# else
+# define malloc_getpagesize (NBPG * CLSIZE)
+# endif
+# else
+# ifdef NBPC
+# define malloc_getpagesize NBPC
+# else
+# ifdef PAGESIZE
+# define malloc_getpagesize PAGESIZE
+# else /* just guess */
+# define malloc_getpagesize ((size_t)4096U)
+# endif
+# endif
+# endif
+# endif
+# endif
+# endif
+# endif
+#endif
+#endif
+
+/* ------------------- size_t and alignment properties -------------------- */
+
+/* The byte and bit size of a size_t */
+#define SIZE_T_SIZE (sizeof(size_t))
+#define SIZE_T_BITSIZE (sizeof(size_t) << 3)
+
+/* Some constants coerced to size_t */
+/* Annoying but necessary to avoid errors on some platforms */
+#define SIZE_T_ZERO ((size_t)0)
+#define SIZE_T_ONE ((size_t)1)
+#define SIZE_T_TWO ((size_t)2)
+#define TWO_SIZE_T_SIZES (SIZE_T_SIZE<<1)
+#define FOUR_SIZE_T_SIZES (SIZE_T_SIZE<<2)
+#define SIX_SIZE_T_SIZES (FOUR_SIZE_T_SIZES+TWO_SIZE_T_SIZES)
+#define HALF_MAX_SIZE_T (MAX_SIZE_T / 2U)
+
+/* The bit mask value corresponding to MALLOC_ALIGNMENT */
+#define CHUNK_ALIGN_MASK (MALLOC_ALIGNMENT - SIZE_T_ONE)
+
+/* True if address a has acceptable alignment */
+#define is_aligned(A) (((size_t)((A)) & (CHUNK_ALIGN_MASK)) == 0)
+
+/* the number of bytes to offset an address to align it */
+#define align_offset(A)\
+ ((((size_t)(A) & CHUNK_ALIGN_MASK) == 0)? 0 :\
+ ((MALLOC_ALIGNMENT - ((size_t)(A) & CHUNK_ALIGN_MASK)) & CHUNK_ALIGN_MASK))
+
+/* -------------------------- MMAP preliminaries ------------------------- */
+
+/*
+ If HAVE_MORECORE or HAVE_MMAP are false, we just define calls and
+ checks to fail so compiler optimizer can delete code rather than
+ using so many "#if"s.
+*/
+
+
+/* MORECORE and MMAP must return MFAIL on failure */
+#define MFAIL ((void*)(MAX_SIZE_T))
+#define CMFAIL ((char*)(MFAIL)) /* defined for convenience */
+
+#if !HAVE_MMAP
+#define IS_MMAPPED_BIT (SIZE_T_ZERO)
+#define USE_MMAP_BIT (SIZE_T_ZERO)
+#define CALL_MMAP(s) MFAIL
+#define CALL_MUNMAP(a, s) (-1)
+#define DIRECT_MMAP(s) MFAIL
+
+#else /* HAVE_MMAP */
+#define IS_MMAPPED_BIT (SIZE_T_ONE)
+#define USE_MMAP_BIT (SIZE_T_ONE)
+
+#if !defined(WIN32) && !defined (__OS2__)
+#define CALL_MUNMAP(a, s) munmap((a), (s))
+#define MMAP_PROT (PROT_READ|PROT_WRITE)
+#if !defined(MAP_ANONYMOUS) && defined(MAP_ANON)
+#define MAP_ANONYMOUS MAP_ANON
+#endif /* MAP_ANON */
+#ifdef MAP_ANONYMOUS
+#define MMAP_FLAGS (MAP_PRIVATE|MAP_ANONYMOUS)
+#define CALL_MMAP(s) mmap(0, (s), MMAP_PROT, MMAP_FLAGS, -1, 0)
+#else /* MAP_ANONYMOUS */
+/*
+ Nearly all versions of mmap support MAP_ANONYMOUS, so the following
+ is unlikely to be needed, but is supplied just in case.
+*/
+#define MMAP_FLAGS (MAP_PRIVATE)
+static int dev_zero_fd = -1; /* Cached file descriptor for /dev/zero. */
+#define CALL_MMAP(s) ((dev_zero_fd < 0) ? \
+ (dev_zero_fd = open("/dev/zero", O_RDWR), \
+ mmap(0, (s), MMAP_PROT, MMAP_FLAGS, dev_zero_fd, 0)) : \
+ mmap(0, (s), MMAP_PROT, MMAP_FLAGS, dev_zero_fd, 0))
+#endif /* MAP_ANONYMOUS */
+
+#define DIRECT_MMAP(s) CALL_MMAP(s)
+
+#elif defined(__OS2__)
+
+/* OS/2 MMAP via DosAllocMem */
+static void* os2mmap(size_t size) {
+ void* ptr;
+ if (DosAllocMem(&ptr, size, OBJ_ANY|PAG_COMMIT|PAG_READ|PAG_WRITE) &&
+ DosAllocMem(&ptr, size, PAG_COMMIT|PAG_READ|PAG_WRITE))
+ return MFAIL;
+ return ptr;
+}
+
+#define os2direct_mmap(n) os2mmap(n)
+
+/* This function supports releasing coalesed segments */
+static int os2munmap(void* ptr, size_t size) {
+ while (size) {
+ ULONG ulSize = size;
+ ULONG ulFlags = 0;
+ if (DosQueryMem(ptr, &ulSize, &ulFlags) != 0)
+ return -1;
+ if ((ulFlags & PAG_BASE) == 0 ||(ulFlags & PAG_COMMIT) == 0 ||
+ ulSize > size)
+ return -1;
+ if (DosFreeMem(ptr) != 0)
+ return -1;
+ ptr = ( void * ) ( ( char * ) ptr + ulSize );
+ size -= ulSize;
+ }
+ return 0;
+}
+
+#define CALL_MMAP(s) os2mmap(s)
+#define CALL_MUNMAP(a, s) os2munmap((a), (s))
+#define DIRECT_MMAP(s) os2direct_mmap(s)
+
+#else /* WIN32 */
+
+/* Win32 MMAP via VirtualAlloc */
+static void* win32mmap(size_t size) {
+ void* ptr = VirtualAlloc(0, size, MEM_RESERVE|MEM_COMMIT, PAGE_EXECUTE_READWRITE);
+ return (ptr != 0)? ptr: MFAIL;
+}
+
+/* For direct MMAP, use MEM_TOP_DOWN to minimize interference */
+static void* win32direct_mmap(size_t size) {
+ void* ptr = VirtualAlloc(0, size, MEM_RESERVE|MEM_COMMIT|MEM_TOP_DOWN,
+ PAGE_EXECUTE_READWRITE);
+ return (ptr != 0)? ptr: MFAIL;
+}
+
+/* This function supports releasing coalesed segments */
+static int win32munmap(void* ptr, size_t size) {
+ MEMORY_BASIC_INFORMATION minfo;
+ char* cptr = ptr;
+ while (size) {
+ if (VirtualQuery(cptr, &minfo, sizeof(minfo)) == 0)
+ return -1;
+ if (minfo.BaseAddress != cptr || minfo.AllocationBase != cptr ||
+ minfo.State != MEM_COMMIT || minfo.RegionSize > size)
+ return -1;
+ if (VirtualFree(cptr, 0, MEM_RELEASE) == 0)
+ return -1;
+ cptr += minfo.RegionSize;
+ size -= minfo.RegionSize;
+ }
+ return 0;
+}
+
+#define CALL_MMAP(s) win32mmap(s)
+#define CALL_MUNMAP(a, s) win32munmap((a), (s))
+#define DIRECT_MMAP(s) win32direct_mmap(s)
+#endif /* WIN32 */
+#endif /* HAVE_MMAP */
+
+#if HAVE_MMAP && HAVE_MREMAP
+#define CALL_MREMAP(addr, osz, nsz, mv) mremap((addr), (osz), (nsz), (mv))
+#else /* HAVE_MMAP && HAVE_MREMAP */
+#define CALL_MREMAP(addr, osz, nsz, mv) MFAIL
+#endif /* HAVE_MMAP && HAVE_MREMAP */
+
+#if HAVE_MORECORE
+#define CALL_MORECORE(S) MORECORE(S)
+#else /* HAVE_MORECORE */
+#define CALL_MORECORE(S) MFAIL
+#endif /* HAVE_MORECORE */
+
+/* mstate bit set if contiguous morecore disabled or failed */
+#define USE_NONCONTIGUOUS_BIT (4U)
+
+/* segment bit set in create_mspace_with_base */
+#define EXTERN_BIT (8U)
+
+
+/* --------------------------- Lock preliminaries ------------------------ */
+
+#if USE_LOCKS
+
+/*
+ When locks are defined, there are up to two global locks:
+
+ * If HAVE_MORECORE, morecore_mutex protects sequences of calls to
+ MORECORE. In many cases sys_alloc requires two calls, that should
+ not be interleaved with calls by other threads. This does not
+ protect against direct calls to MORECORE by other threads not
+ using this lock, so there is still code to cope the best we can on
+ interference.
+
+ * magic_init_mutex ensures that mparams.magic and other
+ unique mparams values are initialized only once.
+*/
+
+#if !defined(WIN32) && !defined(__OS2__)
+/* By default use posix locks */
+#include <pthread.h>
+#define MLOCK_T pthread_mutex_t
+#define INITIAL_LOCK(l) pthread_mutex_init(l, NULL)
+#define ACQUIRE_LOCK(l) pthread_mutex_lock(l)
+#define RELEASE_LOCK(l) pthread_mutex_unlock(l)
+
+#if HAVE_MORECORE
+static MLOCK_T morecore_mutex = PTHREAD_MUTEX_INITIALIZER;
+#endif /* HAVE_MORECORE */
+
+static MLOCK_T magic_init_mutex = PTHREAD_MUTEX_INITIALIZER;
+
+#elif defined(__OS2__)
+#define MLOCK_T HMTX
+#define INITIAL_LOCK(l) DosCreateMutexSem(0, l, 0, FALSE)
+#define ACQUIRE_LOCK(l) DosRequestMutexSem(*l, SEM_INDEFINITE_WAIT)
+#define RELEASE_LOCK(l) DosReleaseMutexSem(*l)
+#if HAVE_MORECORE
+static MLOCK_T morecore_mutex;
+#endif /* HAVE_MORECORE */
+static MLOCK_T magic_init_mutex;
+
+#else /* WIN32 */
+/*
+ Because lock-protected regions have bounded times, and there
+ are no recursive lock calls, we can use simple spinlocks.
+*/
+
+#define MLOCK_T long
+static int win32_acquire_lock (MLOCK_T *sl) {
+ for (;;) {
+#ifdef InterlockedCompareExchangePointer
+ if (!InterlockedCompareExchange(sl, 1, 0))
+ return 0;
+#else /* Use older void* version */
+ if (!InterlockedCompareExchange((void**)sl, (void*)1, (void*)0))
+ return 0;
+#endif /* InterlockedCompareExchangePointer */
+ Sleep (0);
+ }
+}
+
+static void win32_release_lock (MLOCK_T *sl) {
+ InterlockedExchange (sl, 0);
+}
+
+#define INITIAL_LOCK(l) *(l)=0
+#define ACQUIRE_LOCK(l) win32_acquire_lock(l)
+#define RELEASE_LOCK(l) win32_release_lock(l)
+#if HAVE_MORECORE
+static MLOCK_T morecore_mutex;
+#endif /* HAVE_MORECORE */
+static MLOCK_T magic_init_mutex;
+#endif /* WIN32 */
+
+#define USE_LOCK_BIT (2U)
+#else /* USE_LOCKS */
+#define USE_LOCK_BIT (0U)
+#define INITIAL_LOCK(l)
+#endif /* USE_LOCKS */
+
+#if USE_LOCKS && HAVE_MORECORE
+#define ACQUIRE_MORECORE_LOCK() ACQUIRE_LOCK(&morecore_mutex);
+#define RELEASE_MORECORE_LOCK() RELEASE_LOCK(&morecore_mutex);
+#else /* USE_LOCKS && HAVE_MORECORE */
+#define ACQUIRE_MORECORE_LOCK()
+#define RELEASE_MORECORE_LOCK()
+#endif /* USE_LOCKS && HAVE_MORECORE */
+
+#if USE_LOCKS
+#define ACQUIRE_MAGIC_INIT_LOCK() ACQUIRE_LOCK(&magic_init_mutex);
+#define RELEASE_MAGIC_INIT_LOCK() RELEASE_LOCK(&magic_init_mutex);
+#else /* USE_LOCKS */
+#define ACQUIRE_MAGIC_INIT_LOCK()
+#define RELEASE_MAGIC_INIT_LOCK()
+#endif /* USE_LOCKS */
+
+
+/* ----------------------- Chunk representations ------------------------ */
+
+/*
+ (The following includes lightly edited explanations by Colin Plumb.)
+
+ The malloc_chunk declaration below is misleading (but accurate and
+ necessary). It declares a "view" into memory allowing access to
+ necessary fields at known offsets from a given base.
+
+ Chunks of memory are maintained using a `boundary tag' method as
+ originally described by Knuth. (See the paper by Paul Wilson
+ ftp://ftp.cs.utexas.edu/pub/garbage/allocsrv.ps for a survey of such
+ techniques.) Sizes of free chunks are stored both in the front of
+ each chunk and at the end. This makes consolidating fragmented
+ chunks into bigger chunks fast. The head fields also hold bits
+ representing whether chunks are free or in use.
+
+ Here are some pictures to make it clearer. They are "exploded" to
+ show that the state of a chunk can be thought of as extending from
+ the high 31 bits of the head field of its header through the
+ prev_foot and PINUSE_BIT bit of the following chunk header.
+
+ A chunk that's in use looks like:
+
+ chunk-> +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ | Size of previous chunk (if P = 1) |
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |P|
+ | Size of this chunk 1| +-+
+ mem-> +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ | |
+ +- -+
+ | |
+ +- -+
+ | :
+ +- size - sizeof(size_t) available payload bytes -+
+ : |
+ chunk-> +- -+
+ | |
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |1|
+ | Size of next chunk (may or may not be in use) | +-+
+ mem-> +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+
+ And if it's free, it looks like this:
+
+ chunk-> +- -+
+ | User payload (must be in use, or we would have merged!) |
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |P|
+ | Size of this chunk 0| +-+
+ mem-> +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ | Next pointer |
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ | Prev pointer |
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ | :
+ +- size - sizeof(struct chunk) unused bytes -+
+ : |
+ chunk-> +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ | Size of this chunk |
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |0|
+ | Size of next chunk (must be in use, or we would have merged)| +-+
+ mem-> +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ | :
+ +- User payload -+
+ : |
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ |0|
+ +-+
+ Note that since we always merge adjacent free chunks, the chunks
+ adjacent to a free chunk must be in use.
+
+ Given a pointer to a chunk (which can be derived trivially from the
+ payload pointer) we can, in O(1) time, find out whether the adjacent
+ chunks are free, and if so, unlink them from the lists that they
+ are on and merge them with the current chunk.
+
+ Chunks always begin on even word boundaries, so the mem portion
+ (which is returned to the user) is also on an even word boundary, and
+ thus at least double-word aligned.
+
+ The P (PINUSE_BIT) bit, stored in the unused low-order bit of the
+ chunk size (which is always a multiple of two words), is an in-use
+ bit for the *previous* chunk. If that bit is *clear*, then the
+ word before the current chunk size contains the previous chunk
+ size, and can be used to find the front of the previous chunk.
+ The very first chunk allocated always has this bit set, preventing
+ access to non-existent (or non-owned) memory. If pinuse is set for
+ any given chunk, then you CANNOT determine the size of the
+ previous chunk, and might even get a memory addressing fault when
+ trying to do so.
+
+ The C (CINUSE_BIT) bit, stored in the unused second-lowest bit of
+ the chunk size redundantly records whether the current chunk is
+ inuse. This redundancy enables usage checks within free and realloc,
+ and reduces indirection when freeing and consolidating chunks.
+
+ Each freshly allocated chunk must have both cinuse and pinuse set.
+ That is, each allocated chunk borders either a previously allocated
+ and still in-use chunk, or the base of its memory arena. This is
+ ensured by making all allocations from the the `lowest' part of any
+ found chunk. Further, no free chunk physically borders another one,
+ so each free chunk is known to be preceded and followed by either
+ inuse chunks or the ends of memory.
+
+ Note that the `foot' of the current chunk is actually represented
+ as the prev_foot of the NEXT chunk. This makes it easier to
+ deal with alignments etc but can be very confusing when trying
+ to extend or adapt this code.
+
+ The exceptions to all this are
+
+ 1. The special chunk `top' is the top-most available chunk (i.e.,
+ the one bordering the end of available memory). It is treated
+ specially. Top is never included in any bin, is used only if
+ no other chunk is available, and is released back to the
+ system if it is very large (see M_TRIM_THRESHOLD). In effect,
+ the top chunk is treated as larger (and thus less well
+ fitting) than any other available chunk. The top chunk
+ doesn't update its trailing size field since there is no next
+ contiguous chunk that would have to index off it. However,
+ space is still allocated for it (TOP_FOOT_SIZE) to enable
+ separation or merging when space is extended.
+
+ 3. Chunks allocated via mmap, which have the lowest-order bit
+ (IS_MMAPPED_BIT) set in their prev_foot fields, and do not set
+ PINUSE_BIT in their head fields. Because they are allocated
+ one-by-one, each must carry its own prev_foot field, which is
+ also used to hold the offset this chunk has within its mmapped
+ region, which is needed to preserve alignment. Each mmapped
+ chunk is trailed by the first two fields of a fake next-chunk
+ for sake of usage checks.
+
+*/
+
+struct malloc_chunk {
+ size_t prev_foot; /* Size of previous chunk (if free). */
+ size_t head; /* Size and inuse bits. */
+ struct malloc_chunk* fd; /* double links -- used only if free. */
+ struct malloc_chunk* bk;
+};
+
+typedef struct malloc_chunk mchunk;
+typedef struct malloc_chunk* mchunkptr;
+typedef struct malloc_chunk* sbinptr; /* The type of bins of chunks */
+typedef size_t bindex_t; /* Described below */
+typedef unsigned int binmap_t; /* Described below */
+typedef unsigned int flag_t; /* The type of various bit flag sets */
+
+/* ------------------- Chunks sizes and alignments ----------------------- */
+
+#define MCHUNK_SIZE (sizeof(mchunk))
+
+#if FOOTERS
+#define CHUNK_OVERHEAD (TWO_SIZE_T_SIZES)
+#else /* FOOTERS */
+#define CHUNK_OVERHEAD (SIZE_T_SIZE)
+#endif /* FOOTERS */
+
+/* MMapped chunks need a second word of overhead ... */
+#define MMAP_CHUNK_OVERHEAD (TWO_SIZE_T_SIZES)
+/* ... and additional padding for fake next-chunk at foot */
+#define MMAP_FOOT_PAD (FOUR_SIZE_T_SIZES)
+
+/* The smallest size we can malloc is an aligned minimal chunk */
+#define MIN_CHUNK_SIZE\
+ ((MCHUNK_SIZE + CHUNK_ALIGN_MASK) & ~CHUNK_ALIGN_MASK)
+
+/* conversion from malloc headers to user pointers, and back */
+#define chunk2mem(p) ((void*)((char*)(p) + TWO_SIZE_T_SIZES))
+#define mem2chunk(mem) ((mchunkptr)((char*)(mem) - TWO_SIZE_T_SIZES))
+/* chunk associated with aligned address A */
+#define align_as_chunk(A) (mchunkptr)((A) + align_offset(chunk2mem(A)))
+
+/* Bounds on request (not chunk) sizes. */
+#define MAX_REQUEST ((-MIN_CHUNK_SIZE) << 2)
+#define MIN_REQUEST (MIN_CHUNK_SIZE - CHUNK_OVERHEAD - SIZE_T_ONE)
+
+/* pad request bytes into a usable size */
+#define pad_request(req) \
+ (((req) + CHUNK_OVERHEAD + CHUNK_ALIGN_MASK) & ~CHUNK_ALIGN_MASK)
+
+/* pad request, checking for minimum (but not maximum) */
+#define request2size(req) \
+ (((req) < MIN_REQUEST)? MIN_CHUNK_SIZE : pad_request(req))
+
+
+/* ------------------ Operations on head and foot fields ----------------- */
+
+/*
+ The head field of a chunk is or'ed with PINUSE_BIT when previous
+ adjacent chunk in use, and or'ed with CINUSE_BIT if this chunk is in
+ use. If the chunk was obtained with mmap, the prev_foot field has
+ IS_MMAPPED_BIT set, otherwise holding the offset of the base of the
+ mmapped region to the base of the chunk.
+*/
+
+#define PINUSE_BIT (SIZE_T_ONE)
+#define CINUSE_BIT (SIZE_T_TWO)
+#define INUSE_BITS (PINUSE_BIT|CINUSE_BIT)
+
+/* Head value for fenceposts */
+#define FENCEPOST_HEAD (INUSE_BITS|SIZE_T_SIZE)
+
+/* extraction of fields from head words */
+#define cinuse(p) ((p)->head & CINUSE_BIT)
+#define pinuse(p) ((p)->head & PINUSE_BIT)
+#define chunksize(p) ((p)->head & ~(INUSE_BITS))
+
+#define clear_pinuse(p) ((p)->head &= ~PINUSE_BIT)
+#define clear_cinuse(p) ((p)->head &= ~CINUSE_BIT)
+
+/* Treat space at ptr +/- offset as a chunk */
+#define chunk_plus_offset(p, s) ((mchunkptr)(((char*)(p)) + (s)))
+#define chunk_minus_offset(p, s) ((mchunkptr)(((char*)(p)) - (s)))
+
+/* Ptr to next or previous physical malloc_chunk. */
+#define next_chunk(p) ((mchunkptr)( ((char*)(p)) + ((p)->head & ~INUSE_BITS)))
+#define prev_chunk(p) ((mchunkptr)( ((char*)(p)) - ((p)->prev_foot) ))
+
+/* extract next chunk's pinuse bit */
+#define next_pinuse(p) ((next_chunk(p)->head) & PINUSE_BIT)
+
+/* Get/set size at footer */
+#define get_foot(p, s) (((mchunkptr)((char*)(p) + (s)))->prev_foot)
+#define set_foot(p, s) (((mchunkptr)((char*)(p) + (s)))->prev_foot = (s))
+
+/* Set size, pinuse bit, and foot */
+#define set_size_and_pinuse_of_free_chunk(p, s)\
+ ((p)->head = (s|PINUSE_BIT), set_foot(p, s))
+
+/* Set size, pinuse bit, foot, and clear next pinuse */
+#define set_free_with_pinuse(p, s, n)\
+ (clear_pinuse(n), set_size_and_pinuse_of_free_chunk(p, s))
+
+#define is_mmapped(p)\
+ (!((p)->head & PINUSE_BIT) && ((p)->prev_foot & IS_MMAPPED_BIT))
+
+/* Get the internal overhead associated with chunk p */
+#define overhead_for(p)\
+ (is_mmapped(p)? MMAP_CHUNK_OVERHEAD : CHUNK_OVERHEAD)
+
+/* Return true if malloced space is not necessarily cleared */
+#if MMAP_CLEARS
+#define calloc_must_clear(p) (!is_mmapped(p))
+#else /* MMAP_CLEARS */
+#define calloc_must_clear(p) (1)
+#endif /* MMAP_CLEARS */
+
+/* ---------------------- Overlaid data structures ----------------------- */
+
+/*
+ When chunks are not in use, they are treated as nodes of either
+ lists or trees.
+
+ "Small" chunks are stored in circular doubly-linked lists, and look
+ like this:
+
+ chunk-> +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ | Size of previous chunk |
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ `head:' | Size of chunk, in bytes |P|
+ mem-> +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ | Forward pointer to next chunk in list |
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ | Back pointer to previous chunk in list |
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ | Unused space (may be 0 bytes long) .
+ . .
+ . |
+nextchunk-> +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ `foot:' | Size of chunk, in bytes |
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+
+ Larger chunks are kept in a form of bitwise digital trees (aka
+ tries) keyed on chunksizes. Because malloc_tree_chunks are only for
+ free chunks greater than 256 bytes, their size doesn't impose any
+ constraints on user chunk sizes. Each node looks like:
+
+ chunk-> +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ | Size of previous chunk |
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ `head:' | Size of chunk, in bytes |P|
+ mem-> +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ | Forward pointer to next chunk of same size |
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ | Back pointer to previous chunk of same size |
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ | Pointer to left child (child[0]) |
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ | Pointer to right child (child[1]) |
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ | Pointer to parent |
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ | bin index of this chunk |
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ | Unused space .
+ . |
+nextchunk-> +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ `foot:' | Size of chunk, in bytes |
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+
+ Each tree holding treenodes is a tree of unique chunk sizes. Chunks
+ of the same size are arranged in a circularly-linked list, with only
+ the oldest chunk (the next to be used, in our FIFO ordering)
+ actually in the tree. (Tree members are distinguished by a non-null
+ parent pointer.) If a chunk with the same size an an existing node
+ is inserted, it is linked off the existing node using pointers that
+ work in the same way as fd/bk pointers of small chunks.
+
+ Each tree contains a power of 2 sized range of chunk sizes (the
+ smallest is 0x100 <= x < 0x180), which is is divided in half at each
+ tree level, with the chunks in the smaller half of the range (0x100
+ <= x < 0x140 for the top nose) in the left subtree and the larger
+ half (0x140 <= x < 0x180) in the right subtree. This is, of course,
+ done by inspecting individual bits.
+
+ Using these rules, each node's left subtree contains all smaller
+ sizes than its right subtree. However, the node at the root of each
+ subtree has no particular ordering relationship to either. (The
+ dividing line between the subtree sizes is based on trie relation.)
+ If we remove the last chunk of a given size from the interior of the
+ tree, we need to replace it with a leaf node. The tree ordering
+ rules permit a node to be replaced by any leaf below it.
+
+ The smallest chunk in a tree (a common operation in a best-fit
+ allocator) can be found by walking a path to the leftmost leaf in
+ the tree. Unlike a usual binary tree, where we follow left child
+ pointers until we reach a null, here we follow the right child
+ pointer any time the left one is null, until we reach a leaf with
+ both child pointers null. The smallest chunk in the tree will be
+ somewhere along that path.
+
+ The worst case number of steps to add, find, or remove a node is
+ bounded by the number of bits differentiating chunks within
+ bins. Under current bin calculations, this ranges from 6 up to 21
+ (for 32 bit sizes) or up to 53 (for 64 bit sizes). The typical case
+ is of course much better.
+*/
+
+struct malloc_tree_chunk {
+ /* The first four fields must be compatible with malloc_chunk */
+ size_t prev_foot;
+ size_t head;
+ struct malloc_tree_chunk* fd;
+ struct malloc_tree_chunk* bk;
+
+ struct malloc_tree_chunk* child[2];
+ struct malloc_tree_chunk* parent;
+ bindex_t index;
+};
+
+typedef struct malloc_tree_chunk tchunk;
+typedef struct malloc_tree_chunk* tchunkptr;
+typedef struct malloc_tree_chunk* tbinptr; /* The type of bins of trees */
+
+/* A little helper macro for trees */
+#define leftmost_child(t) ((t)->child[0] != 0? (t)->child[0] : (t)->child[1])
+
+/* ----------------------------- Segments -------------------------------- */
+
+/*
+ Each malloc space may include non-contiguous segments, held in a
+ list headed by an embedded malloc_segment record representing the
+ top-most space. Segments also include flags holding properties of
+ the space. Large chunks that are directly allocated by mmap are not
+ included in this list. They are instead independently created and
+ destroyed without otherwise keeping track of them.
+
+ Segment management mainly comes into play for spaces allocated by
+ MMAP. Any call to MMAP might or might not return memory that is
+ adjacent to an existing segment. MORECORE normally contiguously
+ extends the current space, so this space is almost always adjacent,
+ which is simpler and faster to deal with. (This is why MORECORE is
+ used preferentially to MMAP when both are available -- see
+ sys_alloc.) When allocating using MMAP, we don't use any of the
+ hinting mechanisms (inconsistently) supported in various
+ implementations of unix mmap, or distinguish reserving from
+ committing memory. Instead, we just ask for space, and exploit
+ contiguity when we get it. It is probably possible to do
+ better than this on some systems, but no general scheme seems
+ to be significantly better.
+
+ Management entails a simpler variant of the consolidation scheme
+ used for chunks to reduce fragmentation -- new adjacent memory is
+ normally prepended or appended to an existing segment. However,
+ there are limitations compared to chunk consolidation that mostly
+ reflect the fact that segment processing is relatively infrequent
+ (occurring only when getting memory from system) and that we
+ don't expect to have huge numbers of segments:
+
+ * Segments are not indexed, so traversal requires linear scans. (It
+ would be possible to index these, but is not worth the extra
+ overhead and complexity for most programs on most platforms.)
+ * New segments are only appended to old ones when holding top-most
+ memory; if they cannot be prepended to others, they are held in
+ different segments.
+
+ Except for the top-most segment of an mstate, each segment record
+ is kept at the tail of its segment. Segments are added by pushing
+ segment records onto the list headed by &mstate.seg for the
+ containing mstate.
+
+ Segment flags control allocation/merge/deallocation policies:
+ * If EXTERN_BIT set, then we did not allocate this segment,
+ and so should not try to deallocate or merge with others.
+ (This currently holds only for the initial segment passed
+ into create_mspace_with_base.)
+ * If IS_MMAPPED_BIT set, the segment may be merged with
+ other surrounding mmapped segments and trimmed/de-allocated
+ using munmap.
+ * If neither bit is set, then the segment was obtained using
+ MORECORE so can be merged with surrounding MORECORE'd segments
+ and deallocated/trimmed using MORECORE with negative arguments.
+*/
+
+struct malloc_segment {
+ char* base; /* base address */
+ size_t size; /* allocated size */
+ struct malloc_segment* next; /* ptr to next segment */
+#if FFI_MMAP_EXEC_WRIT
+ /* The mmap magic is supposed to store the address of the executable
+ segment at the very end of the requested block. */
+
+# define mmap_exec_offset(b,s) (*(ptrdiff_t*)((b)+(s)-sizeof(ptrdiff_t)))
+
+ /* We can only merge segments if their corresponding executable
+ segments are at identical offsets. */
+# define check_segment_merge(S,b,s) \
+ (mmap_exec_offset((b),(s)) == (S)->exec_offset)
+
+# define add_segment_exec_offset(p,S) ((char*)(p) + (S)->exec_offset)
+# define sub_segment_exec_offset(p,S) ((char*)(p) - (S)->exec_offset)
+
+ /* The removal of sflags only works with HAVE_MORECORE == 0. */
+
+# define get_segment_flags(S) (IS_MMAPPED_BIT)
+# define set_segment_flags(S,v) \
+ (((v) != IS_MMAPPED_BIT) ? (ABORT, (v)) : \
+ (((S)->exec_offset = \
+ mmap_exec_offset((S)->base, (S)->size)), \
+ (mmap_exec_offset((S)->base + (S)->exec_offset, (S)->size) != \
+ (S)->exec_offset) ? (ABORT, (v)) : \
+ (mmap_exec_offset((S)->base, (S)->size) = 0), (v)))
+
+ /* We use an offset here, instead of a pointer, because then, when
+ base changes, we don't have to modify this. On architectures
+ with segmented addresses, this might not work. */
+ ptrdiff_t exec_offset;
+#else
+
+# define get_segment_flags(S) ((S)->sflags)
+# define set_segment_flags(S,v) ((S)->sflags = (v))
+# define check_segment_merge(S,b,s) (1)
+
+ flag_t sflags; /* mmap and extern flag */
+#endif
+};
+
+#define is_mmapped_segment(S) (get_segment_flags(S) & IS_MMAPPED_BIT)
+#define is_extern_segment(S) (get_segment_flags(S) & EXTERN_BIT)
+
+typedef struct malloc_segment msegment;
+typedef struct malloc_segment* msegmentptr;
+
+/* ---------------------------- malloc_state ----------------------------- */
+
+/*
+ A malloc_state holds all of the bookkeeping for a space.
+ The main fields are:
+
+ Top
+ The topmost chunk of the currently active segment. Its size is
+ cached in topsize. The actual size of topmost space is
+ topsize+TOP_FOOT_SIZE, which includes space reserved for adding
+ fenceposts and segment records if necessary when getting more
+ space from the system. The size at which to autotrim top is
+ cached from mparams in trim_check, except that it is disabled if
+ an autotrim fails.
+
+ Designated victim (dv)
+ This is the preferred chunk for servicing small requests that
+ don't have exact fits. It is normally the chunk split off most
+ recently to service another small request. Its size is cached in
+ dvsize. The link fields of this chunk are not maintained since it
+ is not kept in a bin.
+
+ SmallBins
+ An array of bin headers for free chunks. These bins hold chunks
+ with sizes less than MIN_LARGE_SIZE bytes. Each bin contains
+ chunks of all the same size, spaced 8 bytes apart. To simplify
+ use in double-linked lists, each bin header acts as a malloc_chunk
+ pointing to the real first node, if it exists (else pointing to
+ itself). This avoids special-casing for headers. But to avoid
+ waste, we allocate only the fd/bk pointers of bins, and then use
+ repositioning tricks to treat these as the fields of a chunk.
+
+ TreeBins
+ Treebins are pointers to the roots of trees holding a range of
+ sizes. There are 2 equally spaced treebins for each power of two
+ from TREE_SHIFT to TREE_SHIFT+16. The last bin holds anything
+ larger.
+
+ Bin maps
+ There is one bit map for small bins ("smallmap") and one for
+ treebins ("treemap). Each bin sets its bit when non-empty, and
+ clears the bit when empty. Bit operations are then used to avoid
+ bin-by-bin searching -- nearly all "search" is done without ever
+ looking at bins that won't be selected. The bit maps
+ conservatively use 32 bits per map word, even if on 64bit system.
+ For a good description of some of the bit-based techniques used
+ here, see Henry S. Warren Jr's book "Hacker's Delight" (and
+ supplement at http://hackersdelight.org/). Many of these are
+ intended to reduce the branchiness of paths through malloc etc, as
+ well as to reduce the number of memory locations read or written.
+
+ Segments
+ A list of segments headed by an embedded malloc_segment record
+ representing the initial space.
+
+ Address check support
+ The least_addr field is the least address ever obtained from
+ MORECORE or MMAP. Attempted frees and reallocs of any address less
+ than this are trapped (unless INSECURE is defined).
+
+ Magic tag
+ A cross-check field that should always hold same value as mparams.magic.
+
+ Flags
+ Bits recording whether to use MMAP, locks, or contiguous MORECORE
+
+ Statistics
+ Each space keeps track of current and maximum system memory
+ obtained via MORECORE or MMAP.
+
+ Locking
+ If USE_LOCKS is defined, the "mutex" lock is acquired and released
+ around every public call using this mspace.
+*/
+
+/* Bin types, widths and sizes */
+#define NSMALLBINS (32U)
+#define NTREEBINS (32U)
+#define SMALLBIN_SHIFT (3U)
+#define SMALLBIN_WIDTH (SIZE_T_ONE << SMALLBIN_SHIFT)
+#define TREEBIN_SHIFT (8U)
+#define MIN_LARGE_SIZE (SIZE_T_ONE << TREEBIN_SHIFT)
+#define MAX_SMALL_SIZE (MIN_LARGE_SIZE - SIZE_T_ONE)
+#define MAX_SMALL_REQUEST (MAX_SMALL_SIZE - CHUNK_ALIGN_MASK - CHUNK_OVERHEAD)
+
+struct malloc_state {
+ binmap_t smallmap;
+ binmap_t treemap;
+ size_t dvsize;
+ size_t topsize;
+ char* least_addr;
+ mchunkptr dv;
+ mchunkptr top;
+ size_t trim_check;
+ size_t magic;
+ mchunkptr smallbins[(NSMALLBINS+1)*2];
+ tbinptr treebins[NTREEBINS];
+ size_t footprint;
+ size_t max_footprint;
+ flag_t mflags;
+#if USE_LOCKS
+ MLOCK_T mutex; /* locate lock among fields that rarely change */
+#endif /* USE_LOCKS */
+ msegment seg;
+};
+
+typedef struct malloc_state* mstate;
+
+/* ------------- Global malloc_state and malloc_params ------------------- */
+
+/*
+ malloc_params holds global properties, including those that can be
+ dynamically set using mallopt. There is a single instance, mparams,
+ initialized in init_mparams.
+*/
+
+struct malloc_params {
+ size_t magic;
+ size_t page_size;
+ size_t granularity;
+ size_t mmap_threshold;
+ size_t trim_threshold;
+ flag_t default_mflags;
+};
+
+static struct malloc_params mparams;
+
+/* The global malloc_state used for all non-"mspace" calls */
+static struct malloc_state _gm_;
+#define gm (&_gm_)
+#define is_global(M) ((M) == &_gm_)
+#define is_initialized(M) ((M)->top != 0)
+
+/* -------------------------- system alloc setup ------------------------- */
+
+/* Operations on mflags */
+
+#define use_lock(M) ((M)->mflags & USE_LOCK_BIT)
+#define enable_lock(M) ((M)->mflags |= USE_LOCK_BIT)
+#define disable_lock(M) ((M)->mflags &= ~USE_LOCK_BIT)
+
+#define use_mmap(M) ((M)->mflags & USE_MMAP_BIT)
+#define enable_mmap(M) ((M)->mflags |= USE_MMAP_BIT)
+#define disable_mmap(M) ((M)->mflags &= ~USE_MMAP_BIT)
+
+#define use_noncontiguous(M) ((M)->mflags & USE_NONCONTIGUOUS_BIT)
+#define disable_contiguous(M) ((M)->mflags |= USE_NONCONTIGUOUS_BIT)
+
+#define set_lock(M,L)\
+ ((M)->mflags = (L)?\
+ ((M)->mflags | USE_LOCK_BIT) :\
+ ((M)->mflags & ~USE_LOCK_BIT))
+
+/* page-align a size */
+#define page_align(S)\
+ (((S) + (mparams.page_size)) & ~(mparams.page_size - SIZE_T_ONE))
+
+/* granularity-align a size */
+#define granularity_align(S)\
+ (((S) + (mparams.granularity)) & ~(mparams.granularity - SIZE_T_ONE))
+
+#define is_page_aligned(S)\
+ (((size_t)(S) & (mparams.page_size - SIZE_T_ONE)) == 0)
+#define is_granularity_aligned(S)\
+ (((size_t)(S) & (mparams.granularity - SIZE_T_ONE)) == 0)
+
+/* True if segment S holds address A */
+#define segment_holds(S, A)\
+ ((char*)(A) >= S->base && (char*)(A) < S->base + S->size)
+
+/* Return segment holding given address */
+static msegmentptr segment_holding(mstate m, char* addr) {
+ msegmentptr sp = &m->seg;
+ for (;;) {
+ if (addr >= sp->base && addr < sp->base + sp->size)
+ return sp;
+ if ((sp = sp->next) == 0)
+ return 0;
+ }
+}
+
+/* Return true if segment contains a segment link */
+static int has_segment_link(mstate m, msegmentptr ss) {
+ msegmentptr sp = &m->seg;
+ for (;;) {
+ if ((char*)sp >= ss->base && (char*)sp < ss->base + ss->size)
+ return 1;
+ if ((sp = sp->next) == 0)
+ return 0;
+ }
+}
+
+#ifndef MORECORE_CANNOT_TRIM
+#define should_trim(M,s) ((s) > (M)->trim_check)
+#else /* MORECORE_CANNOT_TRIM */
+#define should_trim(M,s) (0)
+#endif /* MORECORE_CANNOT_TRIM */
+
+/*
+ TOP_FOOT_SIZE is padding at the end of a segment, including space
+ that may be needed to place segment records and fenceposts when new
+ noncontiguous segments are added.
+*/
+#define TOP_FOOT_SIZE\
+ (align_offset(chunk2mem(0))+pad_request(sizeof(struct malloc_segment))+MIN_CHUNK_SIZE)
+
+
+/* ------------------------------- Hooks -------------------------------- */
+
+/*
+ PREACTION should be defined to return 0 on success, and nonzero on
+ failure. If you are not using locking, you can redefine these to do
+ anything you like.
+*/
+
+#if USE_LOCKS
+
+/* Ensure locks are initialized */
+#define GLOBALLY_INITIALIZE() (mparams.page_size == 0 && init_mparams())
+
+#define PREACTION(M) ((GLOBALLY_INITIALIZE() || use_lock(M))? ACQUIRE_LOCK(&(M)->mutex) : 0)
+#define POSTACTION(M) { if (use_lock(M)) RELEASE_LOCK(&(M)->mutex); }
+#else /* USE_LOCKS */
+
+#ifndef PREACTION
+#define PREACTION(M) (0)
+#endif /* PREACTION */
+
+#ifndef POSTACTION
+#define POSTACTION(M)
+#endif /* POSTACTION */
+
+#endif /* USE_LOCKS */
+
+/*
+ CORRUPTION_ERROR_ACTION is triggered upon detected bad addresses.
+ USAGE_ERROR_ACTION is triggered on detected bad frees and
+ reallocs. The argument p is an address that might have triggered the
+ fault. It is ignored by the two predefined actions, but might be
+ useful in custom actions that try to help diagnose errors.
+*/
+
+#if PROCEED_ON_ERROR
+
+/* A count of the number of corruption errors causing resets */
+int malloc_corruption_error_count;
+
+/* default corruption action */
+static void reset_on_error(mstate m);
+
+#define CORRUPTION_ERROR_ACTION(m) reset_on_error(m)
+#define USAGE_ERROR_ACTION(m, p)
+
+#else /* PROCEED_ON_ERROR */
+
+#ifndef CORRUPTION_ERROR_ACTION
+#define CORRUPTION_ERROR_ACTION(m) ABORT
+#endif /* CORRUPTION_ERROR_ACTION */
+
+#ifndef USAGE_ERROR_ACTION
+#define USAGE_ERROR_ACTION(m,p) ABORT
+#endif /* USAGE_ERROR_ACTION */
+
+#endif /* PROCEED_ON_ERROR */
+
+/* -------------------------- Debugging setup ---------------------------- */
+
+#if ! DEBUG
+
+#define check_free_chunk(M,P)
+#define check_inuse_chunk(M,P)
+#define check_malloced_chunk(M,P,N)
+#define check_mmapped_chunk(M,P)
+#define check_malloc_state(M)
+#define check_top_chunk(M,P)
+
+#else /* DEBUG */
+#define check_free_chunk(M,P) do_check_free_chunk(M,P)
+#define check_inuse_chunk(M,P) do_check_inuse_chunk(M,P)
+#define check_top_chunk(M,P) do_check_top_chunk(M,P)
+#define check_malloced_chunk(M,P,N) do_check_malloced_chunk(M,P,N)
+#define check_mmapped_chunk(M,P) do_check_mmapped_chunk(M,P)
+#define check_malloc_state(M) do_check_malloc_state(M)
+
+static void do_check_any_chunk(mstate m, mchunkptr p);
+static void do_check_top_chunk(mstate m, mchunkptr p);
+static void do_check_mmapped_chunk(mstate m, mchunkptr p);
+static void do_check_inuse_chunk(mstate m, mchunkptr p);
+static void do_check_free_chunk(mstate m, mchunkptr p);
+static void do_check_malloced_chunk(mstate m, void* mem, size_t s);
+static void do_check_tree(mstate m, tchunkptr t);
+static void do_check_treebin(mstate m, bindex_t i);
+static void do_check_smallbin(mstate m, bindex_t i);
+static void do_check_malloc_state(mstate m);
+static int bin_find(mstate m, mchunkptr x);
+static size_t traverse_and_check(mstate m);
+#endif /* DEBUG */
+
+/* ---------------------------- Indexing Bins ---------------------------- */
+
+#define is_small(s) (((s) >> SMALLBIN_SHIFT) < NSMALLBINS)
+#define small_index(s) ((s) >> SMALLBIN_SHIFT)
+#define small_index2size(i) ((i) << SMALLBIN_SHIFT)
+#define MIN_SMALL_INDEX (small_index(MIN_CHUNK_SIZE))
+
+/* addressing by index. See above about smallbin repositioning */
+#define smallbin_at(M, i) ((sbinptr)((char*)&((M)->smallbins[(i)<<1])))
+#define treebin_at(M,i) (&((M)->treebins[i]))
+
+/* assign tree index for size S to variable I */
+#if defined(__GNUC__) && defined(i386)
+#define compute_tree_index(S, I)\
+{\
+ size_t X = S >> TREEBIN_SHIFT;\
+ if (X == 0)\
+ I = 0;\
+ else if (X > 0xFFFF)\
+ I = NTREEBINS-1;\
+ else {\
+ unsigned int K;\
+ __asm__("bsrl %1,%0\n\t" : "=r" (K) : "rm" (X));\
+ I = (bindex_t)((K << 1) + ((S >> (K + (TREEBIN_SHIFT-1)) & 1)));\
+ }\
+}
+#else /* GNUC */
+#define compute_tree_index(S, I)\
+{\
+ size_t X = S >> TREEBIN_SHIFT;\
+ if (X == 0)\
+ I = 0;\
+ else if (X > 0xFFFF)\
+ I = NTREEBINS-1;\
+ else {\
+ unsigned int Y = (unsigned int)X;\
+ unsigned int N = ((Y - 0x100) >> 16) & 8;\
+ unsigned int K = (((Y <<= N) - 0x1000) >> 16) & 4;\
+ N += K;\
+ N += K = (((Y <<= K) - 0x4000) >> 16) & 2;\
+ K = 14 - N + ((Y <<= K) >> 15);\
+ I = (K << 1) + ((S >> (K + (TREEBIN_SHIFT-1)) & 1));\
+ }\
+}
+#endif /* GNUC */
+
+/* Bit representing maximum resolved size in a treebin at i */
+#define bit_for_tree_index(i) \
+ (i == NTREEBINS-1)? (SIZE_T_BITSIZE-1) : (((i) >> 1) + TREEBIN_SHIFT - 2)
+
+/* Shift placing maximum resolved bit in a treebin at i as sign bit */
+#define leftshift_for_tree_index(i) \
+ ((i == NTREEBINS-1)? 0 : \
+ ((SIZE_T_BITSIZE-SIZE_T_ONE) - (((i) >> 1) + TREEBIN_SHIFT - 2)))
+
+/* The size of the smallest chunk held in bin with index i */
+#define minsize_for_tree_index(i) \
+ ((SIZE_T_ONE << (((i) >> 1) + TREEBIN_SHIFT)) | \
+ (((size_t)((i) & SIZE_T_ONE)) << (((i) >> 1) + TREEBIN_SHIFT - 1)))
+
+
+/* ------------------------ Operations on bin maps ----------------------- */
+
+/* bit corresponding to given index */
+#define idx2bit(i) ((binmap_t)(1) << (i))
+
+/* Mark/Clear bits with given index */
+#define mark_smallmap(M,i) ((M)->smallmap |= idx2bit(i))
+#define clear_smallmap(M,i) ((M)->smallmap &= ~idx2bit(i))
+#define smallmap_is_marked(M,i) ((M)->smallmap & idx2bit(i))
+
+#define mark_treemap(M,i) ((M)->treemap |= idx2bit(i))
+#define clear_treemap(M,i) ((M)->treemap &= ~idx2bit(i))
+#define treemap_is_marked(M,i) ((M)->treemap & idx2bit(i))
+
+/* index corresponding to given bit */
+
+#if defined(__GNUC__) && defined(i386)
+#define compute_bit2idx(X, I)\
+{\
+ unsigned int J;\
+ __asm__("bsfl %1,%0\n\t" : "=r" (J) : "rm" (X));\
+ I = (bindex_t)J;\
+}
+
+#else /* GNUC */
+#if USE_BUILTIN_FFS
+#define compute_bit2idx(X, I) I = ffs(X)-1
+
+#else /* USE_BUILTIN_FFS */
+#define compute_bit2idx(X, I)\
+{\
+ unsigned int Y = X - 1;\
+ unsigned int K = Y >> (16-4) & 16;\
+ unsigned int N = K; Y >>= K;\
+ N += K = Y >> (8-3) & 8; Y >>= K;\
+ N += K = Y >> (4-2) & 4; Y >>= K;\
+ N += K = Y >> (2-1) & 2; Y >>= K;\
+ N += K = Y >> (1-0) & 1; Y >>= K;\
+ I = (bindex_t)(N + Y);\
+}
+#endif /* USE_BUILTIN_FFS */
+#endif /* GNUC */
+
+/* isolate the least set bit of a bitmap */
+#define least_bit(x) ((x) & -(x))
+
+/* mask with all bits to left of least bit of x on */
+#define left_bits(x) ((x<<1) | -(x<<1))
+
+/* mask with all bits to left of or equal to least bit of x on */
+#define same_or_left_bits(x) ((x) | -(x))
+
+
+/* ----------------------- Runtime Check Support ------------------------- */
+
+/*
+ For security, the main invariant is that malloc/free/etc never
+ writes to a static address other than malloc_state, unless static
+ malloc_state itself has been corrupted, which cannot occur via
+ malloc (because of these checks). In essence this means that we
+ believe all pointers, sizes, maps etc held in malloc_state, but
+ check all of those linked or offsetted from other embedded data
+ structures. These checks are interspersed with main code in a way
+ that tends to minimize their run-time cost.
+
+ When FOOTERS is defined, in addition to range checking, we also
+ verify footer fields of inuse chunks, which can be used guarantee
+ that the mstate controlling malloc/free is intact. This is a
+ streamlined version of the approach described by William Robertson
+ et al in "Run-time Detection of Heap-based Overflows" LISA'03
+ http://www.usenix.org/events/lisa03/tech/robertson.html The footer
+ of an inuse chunk holds the xor of its mstate and a random seed,
+ that is checked upon calls to free() and realloc(). This is
+ (probablistically) unguessable from outside the program, but can be
+ computed by any code successfully malloc'ing any chunk, so does not
+ itself provide protection against code that has already broken
+ security through some other means. Unlike Robertson et al, we
+ always dynamically check addresses of all offset chunks (previous,
+ next, etc). This turns out to be cheaper than relying on hashes.
+*/
+
+#if !INSECURE
+/* Check if address a is at least as high as any from MORECORE or MMAP */
+#define ok_address(M, a) ((char*)(a) >= (M)->least_addr)
+/* Check if address of next chunk n is higher than base chunk p */
+#define ok_next(p, n) ((char*)(p) < (char*)(n))
+/* Check if p has its cinuse bit on */
+#define ok_cinuse(p) cinuse(p)
+/* Check if p has its pinuse bit on */
+#define ok_pinuse(p) pinuse(p)
+
+#else /* !INSECURE */
+#define ok_address(M, a) (1)
+#define ok_next(b, n) (1)
+#define ok_cinuse(p) (1)
+#define ok_pinuse(p) (1)
+#endif /* !INSECURE */
+
+#if (FOOTERS && !INSECURE)
+/* Check if (alleged) mstate m has expected magic field */
+#define ok_magic(M) ((M)->magic == mparams.magic)
+#else /* (FOOTERS && !INSECURE) */
+#define ok_magic(M) (1)
+#endif /* (FOOTERS && !INSECURE) */
+
+
+/* In gcc, use __builtin_expect to minimize impact of checks */
+#if !INSECURE
+#if defined(__GNUC__) && __GNUC__ >= 3
+#define RTCHECK(e) __builtin_expect(e, 1)
+#else /* GNUC */
+#define RTCHECK(e) (e)
+#endif /* GNUC */
+#else /* !INSECURE */
+#define RTCHECK(e) (1)
+#endif /* !INSECURE */
+
+/* macros to set up inuse chunks with or without footers */
+
+#if !FOOTERS
+
+#define mark_inuse_foot(M,p,s)
+
+/* Set cinuse bit and pinuse bit of next chunk */
+#define set_inuse(M,p,s)\
+ ((p)->head = (((p)->head & PINUSE_BIT)|s|CINUSE_BIT),\
+ ((mchunkptr)(((char*)(p)) + (s)))->head |= PINUSE_BIT)
+
+/* Set cinuse and pinuse of this chunk and pinuse of next chunk */
+#define set_inuse_and_pinuse(M,p,s)\
+ ((p)->head = (s|PINUSE_BIT|CINUSE_BIT),\
+ ((mchunkptr)(((char*)(p)) + (s)))->head |= PINUSE_BIT)
+
+/* Set size, cinuse and pinuse bit of this chunk */
+#define set_size_and_pinuse_of_inuse_chunk(M, p, s)\
+ ((p)->head = (s|PINUSE_BIT|CINUSE_BIT))
+
+#else /* FOOTERS */
+
+/* Set foot of inuse chunk to be xor of mstate and seed */
+#define mark_inuse_foot(M,p,s)\
+ (((mchunkptr)((char*)(p) + (s)))->prev_foot = ((size_t)(M) ^ mparams.magic))
+
+#define get_mstate_for(p)\
+ ((mstate)(((mchunkptr)((char*)(p) +\
+ (chunksize(p))))->prev_foot ^ mparams.magic))
+
+#define set_inuse(M,p,s)\
+ ((p)->head = (((p)->head & PINUSE_BIT)|s|CINUSE_BIT),\
+ (((mchunkptr)(((char*)(p)) + (s)))->head |= PINUSE_BIT), \
+ mark_inuse_foot(M,p,s))
+
+#define set_inuse_and_pinuse(M,p,s)\
+ ((p)->head = (s|PINUSE_BIT|CINUSE_BIT),\
+ (((mchunkptr)(((char*)(p)) + (s)))->head |= PINUSE_BIT),\
+ mark_inuse_foot(M,p,s))
+
+#define set_size_and_pinuse_of_inuse_chunk(M, p, s)\
+ ((p)->head = (s|PINUSE_BIT|CINUSE_BIT),\
+ mark_inuse_foot(M, p, s))
+
+#endif /* !FOOTERS */
+
+/* ---------------------------- setting mparams -------------------------- */
+
+/* Initialize mparams */
+static int init_mparams(void) {
+ if (mparams.page_size == 0) {
+ size_t s;
+
+ mparams.mmap_threshold = DEFAULT_MMAP_THRESHOLD;
+ mparams.trim_threshold = DEFAULT_TRIM_THRESHOLD;
+#if MORECORE_CONTIGUOUS
+ mparams.default_mflags = USE_LOCK_BIT|USE_MMAP_BIT;
+#else /* MORECORE_CONTIGUOUS */
+ mparams.default_mflags = USE_LOCK_BIT|USE_MMAP_BIT|USE_NONCONTIGUOUS_BIT;
+#endif /* MORECORE_CONTIGUOUS */
+
+#if (FOOTERS && !INSECURE)
+ {
+#if USE_DEV_RANDOM
+ int fd;
+ unsigned char buf[sizeof(size_t)];
+ /* Try to use /dev/urandom, else fall back on using time */
+ if ((fd = open("/dev/urandom", O_RDONLY)) >= 0 &&
+ read(fd, buf, sizeof(buf)) == sizeof(buf)) {
+ s = *((size_t *) buf);
+ close(fd);
+ }
+ else
+#endif /* USE_DEV_RANDOM */
+ s = (size_t)(time(0) ^ (size_t)0x55555555U);
+
+ s |= (size_t)8U; /* ensure nonzero */
+ s &= ~(size_t)7U; /* improve chances of fault for bad values */
+
+ }
+#else /* (FOOTERS && !INSECURE) */
+ s = (size_t)0x58585858U;
+#endif /* (FOOTERS && !INSECURE) */
+ ACQUIRE_MAGIC_INIT_LOCK();
+ if (mparams.magic == 0) {
+ mparams.magic = s;
+ /* Set up lock for main malloc area */
+ INITIAL_LOCK(&gm->mutex);
+ gm->mflags = mparams.default_mflags;
+ }
+ RELEASE_MAGIC_INIT_LOCK();
+
+#if !defined(WIN32) && !defined(__OS2__)
+ mparams.page_size = malloc_getpagesize;
+ mparams.granularity = ((DEFAULT_GRANULARITY != 0)?
+ DEFAULT_GRANULARITY : mparams.page_size);
+#elif defined (__OS2__)
+ /* if low-memory is used, os2munmap() would break
+ if it were anything other than 64k */
+ mparams.page_size = 4096u;
+ mparams.granularity = 65536u;
+#else /* WIN32 */
+ {
+ SYSTEM_INFO system_info;
+ GetSystemInfo(&system_info);
+ mparams.page_size = system_info.dwPageSize;
+ mparams.granularity = system_info.dwAllocationGranularity;
+ }
+#endif /* WIN32 */
+
+ /* Sanity-check configuration:
+ size_t must be unsigned and as wide as pointer type.
+ ints must be at least 4 bytes.
+ alignment must be at least 8.
+ Alignment, min chunk size, and page size must all be powers of 2.
+ */
+ if ((sizeof(size_t) != sizeof(char*)) ||
+ (MAX_SIZE_T < MIN_CHUNK_SIZE) ||
+ (sizeof(int) < 4) ||
+ (MALLOC_ALIGNMENT < (size_t)8U) ||
+ ((MALLOC_ALIGNMENT & (MALLOC_ALIGNMENT-SIZE_T_ONE)) != 0) ||
+ ((MCHUNK_SIZE & (MCHUNK_SIZE-SIZE_T_ONE)) != 0) ||
+ ((mparams.granularity & (mparams.granularity-SIZE_T_ONE)) != 0) ||
+ ((mparams.page_size & (mparams.page_size-SIZE_T_ONE)) != 0))
+ ABORT;
+ }
+ return 0;
+}
+
+/* support for mallopt */
+static int change_mparam(int param_number, int value) {
+ size_t val = (size_t)value;
+ init_mparams();
+ switch(param_number) {
+ case M_TRIM_THRESHOLD:
+ mparams.trim_threshold = val;
+ return 1;
+ case M_GRANULARITY:
+ if (val >= mparams.page_size && ((val & (val-1)) == 0)) {
+ mparams.granularity = val;
+ return 1;
+ }
+ else
+ return 0;
+ case M_MMAP_THRESHOLD:
+ mparams.mmap_threshold = val;
+ return 1;
+ default:
+ return 0;
+ }
+}
+
+#if DEBUG
+/* ------------------------- Debugging Support --------------------------- */
+
+/* Check properties of any chunk, whether free, inuse, mmapped etc */
+static void do_check_any_chunk(mstate m, mchunkptr p) {
+ assert((is_aligned(chunk2mem(p))) || (p->head == FENCEPOST_HEAD));
+ assert(ok_address(m, p));
+}
+
+/* Check properties of top chunk */
+static void do_check_top_chunk(mstate m, mchunkptr p) {
+ msegmentptr sp = segment_holding(m, (char*)p);
+ size_t sz = chunksize(p);
+ assert(sp != 0);
+ assert((is_aligned(chunk2mem(p))) || (p->head == FENCEPOST_HEAD));
+ assert(ok_address(m, p));
+ assert(sz == m->topsize);
+ assert(sz > 0);
+ assert(sz == ((sp->base + sp->size) - (char*)p) - TOP_FOOT_SIZE);
+ assert(pinuse(p));
+ assert(!next_pinuse(p));
+}
+
+/* Check properties of (inuse) mmapped chunks */
+static void do_check_mmapped_chunk(mstate m, mchunkptr p) {
+ size_t sz = chunksize(p);
+ size_t len = (sz + (p->prev_foot & ~IS_MMAPPED_BIT) + MMAP_FOOT_PAD);
+ assert(is_mmapped(p));
+ assert(use_mmap(m));
+ assert((is_aligned(chunk2mem(p))) || (p->head == FENCEPOST_HEAD));
+ assert(ok_address(m, p));
+ assert(!is_small(sz));
+ assert((len & (mparams.page_size-SIZE_T_ONE)) == 0);
+ assert(chunk_plus_offset(p, sz)->head == FENCEPOST_HEAD);
+ assert(chunk_plus_offset(p, sz+SIZE_T_SIZE)->head == 0);
+}
+
+/* Check properties of inuse chunks */
+static void do_check_inuse_chunk(mstate m, mchunkptr p) {
+ do_check_any_chunk(m, p);
+ assert(cinuse(p));
+ assert(next_pinuse(p));
+ /* If not pinuse and not mmapped, previous chunk has OK offset */
+ assert(is_mmapped(p) || pinuse(p) || next_chunk(prev_chunk(p)) == p);
+ if (is_mmapped(p))
+ do_check_mmapped_chunk(m, p);
+}
+
+/* Check properties of free chunks */
+static void do_check_free_chunk(mstate m, mchunkptr p) {
+ size_t sz = p->head & ~(PINUSE_BIT|CINUSE_BIT);
+ mchunkptr next = chunk_plus_offset(p, sz);
+ do_check_any_chunk(m, p);
+ assert(!cinuse(p));
+ assert(!next_pinuse(p));
+ assert (!is_mmapped(p));
+ if (p != m->dv && p != m->top) {
+ if (sz >= MIN_CHUNK_SIZE) {
+ assert((sz & CHUNK_ALIGN_MASK) == 0);
+ assert(is_aligned(chunk2mem(p)));
+ assert(next->prev_foot == sz);
+ assert(pinuse(p));
+ assert (next == m->top || cinuse(next));
+ assert(p->fd->bk == p);
+ assert(p->bk->fd == p);
+ }
+ else /* markers are always of size SIZE_T_SIZE */
+ assert(sz == SIZE_T_SIZE);
+ }
+}
+
+/* Check properties of malloced chunks at the point they are malloced */
+static void do_check_malloced_chunk(mstate m, void* mem, size_t s) {
+ if (mem != 0) {
+ mchunkptr p = mem2chunk(mem);
+ size_t sz = p->head & ~(PINUSE_BIT|CINUSE_BIT);
+ do_check_inuse_chunk(m, p);
+ assert((sz & CHUNK_ALIGN_MASK) == 0);
+ assert(sz >= MIN_CHUNK_SIZE);
+ assert(sz >= s);
+ /* unless mmapped, size is less than MIN_CHUNK_SIZE more than request */
+ assert(is_mmapped(p) || sz < (s + MIN_CHUNK_SIZE));
+ }
+}
+
+/* Check a tree and its subtrees. */
+static void do_check_tree(mstate m, tchunkptr t) {
+ tchunkptr head = 0;
+ tchunkptr u = t;
+ bindex_t tindex = t->index;
+ size_t tsize = chunksize(t);
+ bindex_t idx;
+ compute_tree_index(tsize, idx);
+ assert(tindex == idx);
+ assert(tsize >= MIN_LARGE_SIZE);
+ assert(tsize >= minsize_for_tree_index(idx));
+ assert((idx == NTREEBINS-1) || (tsize < minsize_for_tree_index((idx+1))));
+
+ do { /* traverse through chain of same-sized nodes */
+ do_check_any_chunk(m, ((mchunkptr)u));
+ assert(u->index == tindex);
+ assert(chunksize(u) == tsize);
+ assert(!cinuse(u));
+ assert(!next_pinuse(u));
+ assert(u->fd->bk == u);
+ assert(u->bk->fd == u);
+ if (u->parent == 0) {
+ assert(u->child[0] == 0);
+ assert(u->child[1] == 0);
+ }
+ else {
+ assert(head == 0); /* only one node on chain has parent */
+ head = u;
+ assert(u->parent != u);
+ assert (u->parent->child[0] == u ||
+ u->parent->child[1] == u ||
+ *((tbinptr*)(u->parent)) == u);
+ if (u->child[0] != 0) {
+ assert(u->child[0]->parent == u);
+ assert(u->child[0] != u);
+ do_check_tree(m, u->child[0]);
+ }
+ if (u->child[1] != 0) {
+ assert(u->child[1]->parent == u);
+ assert(u->child[1] != u);
+ do_check_tree(m, u->child[1]);
+ }
+ if (u->child[0] != 0 && u->child[1] != 0) {
+ assert(chunksize(u->child[0]) < chunksize(u->child[1]));
+ }
+ }
+ u = u->fd;
+ } while (u != t);
+ assert(head != 0);
+}
+
+/* Check all the chunks in a treebin. */
+static void do_check_treebin(mstate m, bindex_t i) {
+ tbinptr* tb = treebin_at(m, i);
+ tchunkptr t = *tb;
+ int empty = (m->treemap & (1U << i)) == 0;
+ if (t == 0)
+ assert(empty);
+ if (!empty)
+ do_check_tree(m, t);
+}
+
+/* Check all the chunks in a smallbin. */
+static void do_check_smallbin(mstate m, bindex_t i) {
+ sbinptr b = smallbin_at(m, i);
+ mchunkptr p = b->bk;
+ unsigned int empty = (m->smallmap & (1U << i)) == 0;
+ if (p == b)
+ assert(empty);
+ if (!empty) {
+ for (; p != b; p = p->bk) {
+ size_t size = chunksize(p);
+ mchunkptr q;
+ /* each chunk claims to be free */
+ do_check_free_chunk(m, p);
+ /* chunk belongs in bin */
+ assert(small_index(size) == i);
+ assert(p->bk == b || chunksize(p->bk) == chunksize(p));
+ /* chunk is followed by an inuse chunk */
+ q = next_chunk(p);
+ if (q->head != FENCEPOST_HEAD)
+ do_check_inuse_chunk(m, q);
+ }
+ }
+}
+
+/* Find x in a bin. Used in other check functions. */
+static int bin_find(mstate m, mchunkptr x) {
+ size_t size = chunksize(x);
+ if (is_small(size)) {
+ bindex_t sidx = small_index(size);
+ sbinptr b = smallbin_at(m, sidx);
+ if (smallmap_is_marked(m, sidx)) {
+ mchunkptr p = b;
+ do {
+ if (p == x)
+ return 1;
+ } while ((p = p->fd) != b);
+ }
+ }
+ else {
+ bindex_t tidx;
+ compute_tree_index(size, tidx);
+ if (treemap_is_marked(m, tidx)) {
+ tchunkptr t = *treebin_at(m, tidx);
+ size_t sizebits = size << leftshift_for_tree_index(tidx);
+ while (t != 0 && chunksize(t) != size) {
+ t = t->child[(sizebits >> (SIZE_T_BITSIZE-SIZE_T_ONE)) & 1];
+ sizebits <<= 1;
+ }
+ if (t != 0) {
+ tchunkptr u = t;
+ do {
+ if (u == (tchunkptr)x)
+ return 1;
+ } while ((u = u->fd) != t);
+ }
+ }
+ }
+ return 0;
+}
+
+/* Traverse each chunk and check it; return total */
+static size_t traverse_and_check(mstate m) {
+ size_t sum = 0;
+ if (is_initialized(m)) {
+ msegmentptr s = &m->seg;
+ sum += m->topsize + TOP_FOOT_SIZE;
+ while (s != 0) {
+ mchunkptr q = align_as_chunk(s->base);
+ mchunkptr lastq = 0;
+ assert(pinuse(q));
+ while (segment_holds(s, q) &&
+ q != m->top && q->head != FENCEPOST_HEAD) {
+ sum += chunksize(q);
+ if (cinuse(q)) {
+ assert(!bin_find(m, q));
+ do_check_inuse_chunk(m, q);
+ }
+ else {
+ assert(q == m->dv || bin_find(m, q));
+ assert(lastq == 0 || cinuse(lastq)); /* Not 2 consecutive free */
+ do_check_free_chunk(m, q);
+ }
+ lastq = q;
+ q = next_chunk(q);
+ }
+ s = s->next;
+ }
+ }
+ return sum;
+}
+
+/* Check all properties of malloc_state. */
+static void do_check_malloc_state(mstate m) {
+ bindex_t i;
+ size_t total;
+ /* check bins */
+ for (i = 0; i < NSMALLBINS; ++i)
+ do_check_smallbin(m, i);
+ for (i = 0; i < NTREEBINS; ++i)
+ do_check_treebin(m, i);
+
+ if (m->dvsize != 0) { /* check dv chunk */
+ do_check_any_chunk(m, m->dv);
+ assert(m->dvsize == chunksize(m->dv));
+ assert(m->dvsize >= MIN_CHUNK_SIZE);
+ assert(bin_find(m, m->dv) == 0);
+ }
+
+ if (m->top != 0) { /* check top chunk */
+ do_check_top_chunk(m, m->top);
+ assert(m->topsize == chunksize(m->top));
+ assert(m->topsize > 0);
+ assert(bin_find(m, m->top) == 0);
+ }
+
+ total = traverse_and_check(m);
+ assert(total <= m->footprint);
+ assert(m->footprint <= m->max_footprint);
+}
+#endif /* DEBUG */
+
+/* ----------------------------- statistics ------------------------------ */
+
+#if !NO_MALLINFO
+static struct mallinfo internal_mallinfo(mstate m) {
+ struct mallinfo nm = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
+ if (!PREACTION(m)) {
+ check_malloc_state(m);
+ if (is_initialized(m)) {
+ size_t nfree = SIZE_T_ONE; /* top always free */
+ size_t mfree = m->topsize + TOP_FOOT_SIZE;
+ size_t sum = mfree;
+ msegmentptr s = &m->seg;
+ while (s != 0) {
+ mchunkptr q = align_as_chunk(s->base);
+ while (segment_holds(s, q) &&
+ q != m->top && q->head != FENCEPOST_HEAD) {
+ size_t sz = chunksize(q);
+ sum += sz;
+ if (!cinuse(q)) {
+ mfree += sz;
+ ++nfree;
+ }
+ q = next_chunk(q);
+ }
+ s = s->next;
+ }
+
+ nm.arena = sum;
+ nm.ordblks = nfree;
+ nm.hblkhd = m->footprint - sum;
+ nm.usmblks = m->max_footprint;
+ nm.uordblks = m->footprint - mfree;
+ nm.fordblks = mfree;
+ nm.keepcost = m->topsize;
+ }
+
+ POSTACTION(m);
+ }
+ return nm;
+}
+#endif /* !NO_MALLINFO */
+
+static void internal_malloc_stats(mstate m) {
+ if (!PREACTION(m)) {
+ size_t maxfp = 0;
+ size_t fp = 0;
+ size_t used = 0;
+ check_malloc_state(m);
+ if (is_initialized(m)) {
+ msegmentptr s = &m->seg;
+ maxfp = m->max_footprint;
+ fp = m->footprint;
+ used = fp - (m->topsize + TOP_FOOT_SIZE);
+
+ while (s != 0) {
+ mchunkptr q = align_as_chunk(s->base);
+ while (segment_holds(s, q) &&
+ q != m->top && q->head != FENCEPOST_HEAD) {
+ if (!cinuse(q))
+ used -= chunksize(q);
+ q = next_chunk(q);
+ }
+ s = s->next;
+ }
+ }
+
+ fprintf(stderr, "max system bytes = %10lu\n", (unsigned long)(maxfp));
+ fprintf(stderr, "system bytes = %10lu\n", (unsigned long)(fp));
+ fprintf(stderr, "in use bytes = %10lu\n", (unsigned long)(used));
+
+ POSTACTION(m);
+ }
+}
+
+/* ----------------------- Operations on smallbins ----------------------- */
+
+/*
+ Various forms of linking and unlinking are defined as macros. Even
+ the ones for trees, which are very long but have very short typical
+ paths. This is ugly but reduces reliance on inlining support of
+ compilers.
+*/
+
+/* Link a free chunk into a smallbin */
+#define insert_small_chunk(M, P, S) {\
+ bindex_t I = small_index(S);\
+ mchunkptr B = smallbin_at(M, I);\
+ mchunkptr F = B;\
+ assert(S >= MIN_CHUNK_SIZE);\
+ if (!smallmap_is_marked(M, I))\
+ mark_smallmap(M, I);\
+ else if (RTCHECK(ok_address(M, B->fd)))\
+ F = B->fd;\
+ else {\
+ CORRUPTION_ERROR_ACTION(M);\
+ }\
+ B->fd = P;\
+ F->bk = P;\
+ P->fd = F;\
+ P->bk = B;\
+}
+
+/* Unlink a chunk from a smallbin */
+#define unlink_small_chunk(M, P, S) {\
+ mchunkptr F = P->fd;\
+ mchunkptr B = P->bk;\
+ bindex_t I = small_index(S);\
+ assert(P != B);\
+ assert(P != F);\
+ assert(chunksize(P) == small_index2size(I));\
+ if (F == B)\
+ clear_smallmap(M, I);\
+ else if (RTCHECK((F == smallbin_at(M,I) || ok_address(M, F)) &&\
+ (B == smallbin_at(M,I) || ok_address(M, B)))) {\
+ F->bk = B;\
+ B->fd = F;\
+ }\
+ else {\
+ CORRUPTION_ERROR_ACTION(M);\
+ }\
+}
+
+/* Unlink the first chunk from a smallbin */
+#define unlink_first_small_chunk(M, B, P, I) {\
+ mchunkptr F = P->fd;\
+ assert(P != B);\
+ assert(P != F);\
+ assert(chunksize(P) == small_index2size(I));\
+ if (B == F)\
+ clear_smallmap(M, I);\
+ else if (RTCHECK(ok_address(M, F))) {\
+ B->fd = F;\
+ F->bk = B;\
+ }\
+ else {\
+ CORRUPTION_ERROR_ACTION(M);\
+ }\
+}
+
+/* Replace dv node, binning the old one */
+/* Used only when dvsize known to be small */
+#define replace_dv(M, P, S) {\
+ size_t DVS = M->dvsize;\
+ if (DVS != 0) {\
+ mchunkptr DV = M->dv;\
+ assert(is_small(DVS));\
+ insert_small_chunk(M, DV, DVS);\
+ }\
+ M->dvsize = S;\
+ M->dv = P;\
+}
+
+/* ------------------------- Operations on trees ------------------------- */
+
+/* Insert chunk into tree */
+#define insert_large_chunk(M, X, S) {\
+ tbinptr* H;\
+ bindex_t I;\
+ compute_tree_index(S, I);\
+ H = treebin_at(M, I);\
+ X->index = I;\
+ X->child[0] = X->child[1] = 0;\
+ if (!treemap_is_marked(M, I)) {\
+ mark_treemap(M, I);\
+ *H = X;\
+ X->parent = (tchunkptr)H;\
+ X->fd = X->bk = X;\
+ }\
+ else {\
+ tchunkptr T = *H;\
+ size_t K = S << leftshift_for_tree_index(I);\
+ for (;;) {\
+ if (chunksize(T) != S) {\
+ tchunkptr* C = &(T->child[(K >> (SIZE_T_BITSIZE-SIZE_T_ONE)) & 1]);\
+ K <<= 1;\
+ if (*C != 0)\
+ T = *C;\
+ else if (RTCHECK(ok_address(M, C))) {\
+ *C = X;\
+ X->parent = T;\
+ X->fd = X->bk = X;\
+ break;\
+ }\
+ else {\
+ CORRUPTION_ERROR_ACTION(M);\
+ break;\
+ }\
+ }\
+ else {\
+ tchunkptr F = T->fd;\
+ if (RTCHECK(ok_address(M, T) && ok_address(M, F))) {\
+ T->fd = F->bk = X;\
+ X->fd = F;\
+ X->bk = T;\
+ X->parent = 0;\
+ break;\
+ }\
+ else {\
+ CORRUPTION_ERROR_ACTION(M);\
+ break;\
+ }\
+ }\
+ }\
+ }\
+}
+
+/*
+ Unlink steps:
+
+ 1. If x is a chained node, unlink it from its same-sized fd/bk links
+ and choose its bk node as its replacement.
+ 2. If x was the last node of its size, but not a leaf node, it must
+ be replaced with a leaf node (not merely one with an open left or
+ right), to make sure that lefts and rights of descendants
+ correspond properly to bit masks. We use the rightmost descendant
+ of x. We could use any other leaf, but this is easy to locate and
+ tends to counteract removal of leftmosts elsewhere, and so keeps
+ paths shorter than minimally guaranteed. This doesn't loop much
+ because on average a node in a tree is near the bottom.
+ 3. If x is the base of a chain (i.e., has parent links) relink
+ x's parent and children to x's replacement (or null if none).
+*/
+
+#define unlink_large_chunk(M, X) {\
+ tchunkptr XP = X->parent;\
+ tchunkptr R;\
+ if (X->bk != X) {\
+ tchunkptr F = X->fd;\
+ R = X->bk;\
+ if (RTCHECK(ok_address(M, F))) {\
+ F->bk = R;\
+ R->fd = F;\
+ }\
+ else {\
+ CORRUPTION_ERROR_ACTION(M);\
+ }\
+ }\
+ else {\
+ tchunkptr* RP;\
+ if (((R = *(RP = &(X->child[1]))) != 0) ||\
+ ((R = *(RP = &(X->child[0]))) != 0)) {\
+ tchunkptr* CP;\
+ while ((*(CP = &(R->child[1])) != 0) ||\
+ (*(CP = &(R->child[0])) != 0)) {\
+ R = *(RP = CP);\
+ }\
+ if (RTCHECK(ok_address(M, RP)))\
+ *RP = 0;\
+ else {\
+ CORRUPTION_ERROR_ACTION(M);\
+ }\
+ }\
+ }\
+ if (XP != 0) {\
+ tbinptr* H = treebin_at(M, X->index);\
+ if (X == *H) {\
+ if ((*H = R) == 0) \
+ clear_treemap(M, X->index);\
+ }\
+ else if (RTCHECK(ok_address(M, XP))) {\
+ if (XP->child[0] == X) \
+ XP->child[0] = R;\
+ else \
+ XP->child[1] = R;\
+ }\
+ else\
+ CORRUPTION_ERROR_ACTION(M);\
+ if (R != 0) {\
+ if (RTCHECK(ok_address(M, R))) {\
+ tchunkptr C0, C1;\
+ R->parent = XP;\
+ if ((C0 = X->child[0]) != 0) {\
+ if (RTCHECK(ok_address(M, C0))) {\
+ R->child[0] = C0;\
+ C0->parent = R;\
+ }\
+ else\
+ CORRUPTION_ERROR_ACTION(M);\
+ }\
+ if ((C1 = X->child[1]) != 0) {\
+ if (RTCHECK(ok_address(M, C1))) {\
+ R->child[1] = C1;\
+ C1->parent = R;\
+ }\
+ else\
+ CORRUPTION_ERROR_ACTION(M);\
+ }\
+ }\
+ else\
+ CORRUPTION_ERROR_ACTION(M);\
+ }\
+ }\
+}
+
+/* Relays to large vs small bin operations */
+
+#define insert_chunk(M, P, S)\
+ if (is_small(S)) insert_small_chunk(M, P, S)\
+ else { tchunkptr TP = (tchunkptr)(P); insert_large_chunk(M, TP, S); }
+
+#define unlink_chunk(M, P, S)\
+ if (is_small(S)) unlink_small_chunk(M, P, S)\
+ else { tchunkptr TP = (tchunkptr)(P); unlink_large_chunk(M, TP); }
+
+
+/* Relays to internal calls to malloc/free from realloc, memalign etc */
+
+#if ONLY_MSPACES
+#define internal_malloc(m, b) mspace_malloc(m, b)
+#define internal_free(m, mem) mspace_free(m,mem);
+#else /* ONLY_MSPACES */
+#if MSPACES
+#define internal_malloc(m, b)\
+ (m == gm)? dlmalloc(b) : mspace_malloc(m, b)
+#define internal_free(m, mem)\
+ if (m == gm) dlfree(mem); else mspace_free(m,mem);
+#else /* MSPACES */
+#define internal_malloc(m, b) dlmalloc(b)
+#define internal_free(m, mem) dlfree(mem)
+#endif /* MSPACES */
+#endif /* ONLY_MSPACES */
+
+/* ----------------------- Direct-mmapping chunks ----------------------- */
+
+/*
+ Directly mmapped chunks are set up with an offset to the start of
+ the mmapped region stored in the prev_foot field of the chunk. This
+ allows reconstruction of the required argument to MUNMAP when freed,
+ and also allows adjustment of the returned chunk to meet alignment
+ requirements (especially in memalign). There is also enough space
+ allocated to hold a fake next chunk of size SIZE_T_SIZE to maintain
+ the PINUSE bit so frees can be checked.
+*/
+
+/* Malloc using mmap */
+static void* mmap_alloc(mstate m, size_t nb) {
+ size_t mmsize = granularity_align(nb + SIX_SIZE_T_SIZES + CHUNK_ALIGN_MASK);
+ if (mmsize > nb) { /* Check for wrap around 0 */
+ char* mm = (char*)(DIRECT_MMAP(mmsize));
+ if (mm != CMFAIL) {
+ size_t offset = align_offset(chunk2mem(mm));
+ size_t psize = mmsize - offset - MMAP_FOOT_PAD;
+ mchunkptr p = (mchunkptr)(mm + offset);
+ p->prev_foot = offset | IS_MMAPPED_BIT;
+ (p)->head = (psize|CINUSE_BIT);
+ mark_inuse_foot(m, p, psize);
+ chunk_plus_offset(p, psize)->head = FENCEPOST_HEAD;
+ chunk_plus_offset(p, psize+SIZE_T_SIZE)->head = 0;
+
+ if (mm < m->least_addr)
+ m->least_addr = mm;
+ if ((m->footprint += mmsize) > m->max_footprint)
+ m->max_footprint = m->footprint;
+ assert(is_aligned(chunk2mem(p)));
+ check_mmapped_chunk(m, p);
+ return chunk2mem(p);
+ }
+ }
+ return 0;
+}
+
+/* Realloc using mmap */
+static mchunkptr mmap_resize(mstate m, mchunkptr oldp, size_t nb) {
+ size_t oldsize = chunksize(oldp);
+ if (is_small(nb)) /* Can't shrink mmap regions below small size */
+ return 0;
+ /* Keep old chunk if big enough but not too big */
+ if (oldsize >= nb + SIZE_T_SIZE &&
+ (oldsize - nb) <= (mparams.granularity << 1))
+ return oldp;
+ else {
+ size_t offset = oldp->prev_foot & ~IS_MMAPPED_BIT;
+ size_t oldmmsize = oldsize + offset + MMAP_FOOT_PAD;
+ size_t newmmsize = granularity_align(nb + SIX_SIZE_T_SIZES +
+ CHUNK_ALIGN_MASK);
+ char* cp = (char*)CALL_MREMAP((char*)oldp - offset,
+ oldmmsize, newmmsize, 1);
+ if (cp != CMFAIL) {
+ mchunkptr newp = (mchunkptr)(cp + offset);
+ size_t psize = newmmsize - offset - MMAP_FOOT_PAD;
+ newp->head = (psize|CINUSE_BIT);
+ mark_inuse_foot(m, newp, psize);
+ chunk_plus_offset(newp, psize)->head = FENCEPOST_HEAD;
+ chunk_plus_offset(newp, psize+SIZE_T_SIZE)->head = 0;
+
+ if (cp < m->least_addr)
+ m->least_addr = cp;
+ if ((m->footprint += newmmsize - oldmmsize) > m->max_footprint)
+ m->max_footprint = m->footprint;
+ check_mmapped_chunk(m, newp);
+ return newp;
+ }
+ }
+ return 0;
+}
+
+/* -------------------------- mspace management -------------------------- */
+
+/* Initialize top chunk and its size */
+static void init_top(mstate m, mchunkptr p, size_t psize) {
+ /* Ensure alignment */
+ size_t offset = align_offset(chunk2mem(p));
+ p = (mchunkptr)((char*)p + offset);
+ psize -= offset;
+
+ m->top = p;
+ m->topsize = psize;
+ p->head = psize | PINUSE_BIT;
+ /* set size of fake trailing chunk holding overhead space only once */
+ chunk_plus_offset(p, psize)->head = TOP_FOOT_SIZE;
+ m->trim_check = mparams.trim_threshold; /* reset on each update */
+}
+
+/* Initialize bins for a new mstate that is otherwise zeroed out */
+static void init_bins(mstate m) {
+ /* Establish circular links for smallbins */
+ bindex_t i;
+ for (i = 0; i < NSMALLBINS; ++i) {
+ sbinptr bin = smallbin_at(m,i);
+ bin->fd = bin->bk = bin;
+ }
+}
+
+#if PROCEED_ON_ERROR
+
+/* default corruption action */
+static void reset_on_error(mstate m) {
+ int i;
+ ++malloc_corruption_error_count;
+ /* Reinitialize fields to forget about all memory */
+ m->smallbins = m->treebins = 0;
+ m->dvsize = m->topsize = 0;
+ m->seg.base = 0;
+ m->seg.size = 0;
+ m->seg.next = 0;
+ m->top = m->dv = 0;
+ for (i = 0; i < NTREEBINS; ++i)
+ *treebin_at(m, i) = 0;
+ init_bins(m);
+}
+#endif /* PROCEED_ON_ERROR */
+
+/* Allocate chunk and prepend remainder with chunk in successor base. */
+static void* prepend_alloc(mstate m, char* newbase, char* oldbase,
+ size_t nb) {
+ mchunkptr p = align_as_chunk(newbase);
+ mchunkptr oldfirst = align_as_chunk(oldbase);
+ size_t psize = (char*)oldfirst - (char*)p;
+ mchunkptr q = chunk_plus_offset(p, nb);
+ size_t qsize = psize - nb;
+ set_size_and_pinuse_of_inuse_chunk(m, p, nb);
+
+ assert((char*)oldfirst > (char*)q);
+ assert(pinuse(oldfirst));
+ assert(qsize >= MIN_CHUNK_SIZE);
+
+ /* consolidate remainder with first chunk of old base */
+ if (oldfirst == m->top) {
+ size_t tsize = m->topsize += qsize;
+ m->top = q;
+ q->head = tsize | PINUSE_BIT;
+ check_top_chunk(m, q);
+ }
+ else if (oldfirst == m->dv) {
+ size_t dsize = m->dvsize += qsize;
+ m->dv = q;
+ set_size_and_pinuse_of_free_chunk(q, dsize);
+ }
+ else {
+ if (!cinuse(oldfirst)) {
+ size_t nsize = chunksize(oldfirst);
+ unlink_chunk(m, oldfirst, nsize);
+ oldfirst = chunk_plus_offset(oldfirst, nsize);
+ qsize += nsize;
+ }
+ set_free_with_pinuse(q, qsize, oldfirst);
+ insert_chunk(m, q, qsize);
+ check_free_chunk(m, q);
+ }
+
+ check_malloced_chunk(m, chunk2mem(p), nb);
+ return chunk2mem(p);
+}
+
+
+/* Add a segment to hold a new noncontiguous region */
+static void add_segment(mstate m, char* tbase, size_t tsize, flag_t mmapped) {
+ /* Determine locations and sizes of segment, fenceposts, old top */
+ char* old_top = (char*)m->top;
+ msegmentptr oldsp = segment_holding(m, old_top);
+ char* old_end = oldsp->base + oldsp->size;
+ size_t ssize = pad_request(sizeof(struct malloc_segment));
+ char* rawsp = old_end - (ssize + FOUR_SIZE_T_SIZES + CHUNK_ALIGN_MASK);
+ size_t offset = align_offset(chunk2mem(rawsp));
+ char* asp = rawsp + offset;
+ char* csp = (asp < (old_top + MIN_CHUNK_SIZE))? old_top : asp;
+ mchunkptr sp = (mchunkptr)csp;
+ msegmentptr ss = (msegmentptr)(chunk2mem(sp));
+ mchunkptr tnext = chunk_plus_offset(sp, ssize);
+ mchunkptr p = tnext;
+ int nfences = 0;
+
+ /* reset top to new space */
+ init_top(m, (mchunkptr)tbase, tsize - TOP_FOOT_SIZE);
+
+ /* Set up segment record */
+ assert(is_aligned(ss));
+ set_size_and_pinuse_of_inuse_chunk(m, sp, ssize);
+ *ss = m->seg; /* Push current record */
+ m->seg.base = tbase;
+ m->seg.size = tsize;
+ (void)set_segment_flags(&m->seg, mmapped);
+ m->seg.next = ss;
+
+ /* Insert trailing fenceposts */
+ for (;;) {
+ mchunkptr nextp = chunk_plus_offset(p, SIZE_T_SIZE);
+ p->head = FENCEPOST_HEAD;
+ ++nfences;
+ if ((char*)(&(nextp->head)) < old_end)
+ p = nextp;
+ else
+ break;
+ }
+ assert(nfences >= 2);
+
+ /* Insert the rest of old top into a bin as an ordinary free chunk */
+ if (csp != old_top) {
+ mchunkptr q = (mchunkptr)old_top;
+ size_t psize = csp - old_top;
+ mchunkptr tn = chunk_plus_offset(q, psize);
+ set_free_with_pinuse(q, psize, tn);
+ insert_chunk(m, q, psize);
+ }
+
+ check_top_chunk(m, m->top);
+}
+
+/* -------------------------- System allocation -------------------------- */
+
+/* Get memory from system using MORECORE or MMAP */
+static void* sys_alloc(mstate m, size_t nb) {
+ char* tbase = CMFAIL;
+ size_t tsize = 0;
+ flag_t mmap_flag = 0;
+
+ init_mparams();
+
+ /* Directly map large chunks */
+ if (use_mmap(m) && nb >= mparams.mmap_threshold) {
+ void* mem = mmap_alloc(m, nb);
+ if (mem != 0)
+ return mem;
+ }
+
+ /*
+ Try getting memory in any of three ways (in most-preferred to
+ least-preferred order):
+ 1. A call to MORECORE that can normally contiguously extend memory.
+ (disabled if not MORECORE_CONTIGUOUS or not HAVE_MORECORE or
+ or main space is mmapped or a previous contiguous call failed)
+ 2. A call to MMAP new space (disabled if not HAVE_MMAP).
+ Note that under the default settings, if MORECORE is unable to
+ fulfill a request, and HAVE_MMAP is true, then mmap is
+ used as a noncontiguous system allocator. This is a useful backup
+ strategy for systems with holes in address spaces -- in this case
+ sbrk cannot contiguously expand the heap, but mmap may be able to
+ find space.
+ 3. A call to MORECORE that cannot usually contiguously extend memory.
+ (disabled if not HAVE_MORECORE)
+ */
+
+ if (MORECORE_CONTIGUOUS && !use_noncontiguous(m)) {
+ char* br = CMFAIL;
+ msegmentptr ss = (m->top == 0)? 0 : segment_holding(m, (char*)m->top);
+ size_t asize = 0;
+ ACQUIRE_MORECORE_LOCK();
+
+ if (ss == 0) { /* First time through or recovery */
+ char* base = (char*)CALL_MORECORE(0);
+ if (base != CMFAIL) {
+ asize = granularity_align(nb + TOP_FOOT_SIZE + SIZE_T_ONE);
+ /* Adjust to end on a page boundary */
+ if (!is_page_aligned(base))
+ asize += (page_align((size_t)base) - (size_t)base);
+ /* Can't call MORECORE if size is negative when treated as signed */
+ if (asize < HALF_MAX_SIZE_T &&
+ (br = (char*)(CALL_MORECORE(asize))) == base) {
+ tbase = base;
+ tsize = asize;
+ }
+ }
+ }
+ else {
+ /* Subtract out existing available top space from MORECORE request. */
+ asize = granularity_align(nb - m->topsize + TOP_FOOT_SIZE + SIZE_T_ONE);
+ /* Use mem here only if it did continuously extend old space */
+ if (asize < HALF_MAX_SIZE_T &&
+ (br = (char*)(CALL_MORECORE(asize))) == ss->base+ss->size) {
+ tbase = br;
+ tsize = asize;
+ }
+ }
+
+ if (tbase == CMFAIL) { /* Cope with partial failure */
+ if (br != CMFAIL) { /* Try to use/extend the space we did get */
+ if (asize < HALF_MAX_SIZE_T &&
+ asize < nb + TOP_FOOT_SIZE + SIZE_T_ONE) {
+ size_t esize = granularity_align(nb + TOP_FOOT_SIZE + SIZE_T_ONE - asize);
+ if (esize < HALF_MAX_SIZE_T) {
+ char* end = (char*)CALL_MORECORE(esize);
+ if (end != CMFAIL)
+ asize += esize;
+ else { /* Can't use; try to release */
+ (void)CALL_MORECORE(-asize);
+ br = CMFAIL;
+ }
+ }
+ }
+ }
+ if (br != CMFAIL) { /* Use the space we did get */
+ tbase = br;
+ tsize = asize;
+ }
+ else
+ disable_contiguous(m); /* Don't try contiguous path in the future */
+ }
+
+ RELEASE_MORECORE_LOCK();
+ }
+
+ if (HAVE_MMAP && tbase == CMFAIL) { /* Try MMAP */
+ size_t req = nb + TOP_FOOT_SIZE + SIZE_T_ONE;
+ size_t rsize = granularity_align(req);
+ if (rsize > nb) { /* Fail if wraps around zero */
+ char* mp = (char*)(CALL_MMAP(rsize));
+ if (mp != CMFAIL) {
+ tbase = mp;
+ tsize = rsize;
+ mmap_flag = IS_MMAPPED_BIT;
+ }
+ }
+ }
+
+ if (HAVE_MORECORE && tbase == CMFAIL) { /* Try noncontiguous MORECORE */
+ size_t asize = granularity_align(nb + TOP_FOOT_SIZE + SIZE_T_ONE);
+ if (asize < HALF_MAX_SIZE_T) {
+ char* br = CMFAIL;
+ char* end = CMFAIL;
+ ACQUIRE_MORECORE_LOCK();
+ br = (char*)(CALL_MORECORE(asize));
+ end = (char*)(CALL_MORECORE(0));
+ RELEASE_MORECORE_LOCK();
+ if (br != CMFAIL && end != CMFAIL && br < end) {
+ size_t ssize = end - br;
+ if (ssize > nb + TOP_FOOT_SIZE) {
+ tbase = br;
+ tsize = ssize;
+ }
+ }
+ }
+ }
+
+ if (tbase != CMFAIL) {
+
+ if ((m->footprint += tsize) > m->max_footprint)
+ m->max_footprint = m->footprint;
+
+ if (!is_initialized(m)) { /* first-time initialization */
+ m->seg.base = m->least_addr = tbase;
+ m->seg.size = tsize;
+ (void)set_segment_flags(&m->seg, mmap_flag);
+ m->magic = mparams.magic;
+ init_bins(m);
+ if (is_global(m))
+ init_top(m, (mchunkptr)tbase, tsize - TOP_FOOT_SIZE);
+ else {
+ /* Offset top by embedded malloc_state */
+ mchunkptr mn = next_chunk(mem2chunk(m));
+ init_top(m, mn, (size_t)((tbase + tsize) - (char*)mn) -TOP_FOOT_SIZE);
+ }
+ }
+
+ else {
+ /* Try to merge with an existing segment */
+ msegmentptr sp = &m->seg;
+ while (sp != 0 && tbase != sp->base + sp->size)
+ sp = sp->next;
+ if (sp != 0 &&
+ !is_extern_segment(sp) &&
+ check_segment_merge(sp, tbase, tsize) &&
+ (get_segment_flags(sp) & IS_MMAPPED_BIT) == mmap_flag &&
+ segment_holds(sp, m->top)) { /* append */
+ sp->size += tsize;
+ init_top(m, m->top, m->topsize + tsize);
+ }
+ else {
+ if (tbase < m->least_addr)
+ m->least_addr = tbase;
+ sp = &m->seg;
+ while (sp != 0 && sp->base != tbase + tsize)
+ sp = sp->next;
+ if (sp != 0 &&
+ !is_extern_segment(sp) &&
+ check_segment_merge(sp, tbase, tsize) &&
+ (get_segment_flags(sp) & IS_MMAPPED_BIT) == mmap_flag) {
+ char* oldbase = sp->base;
+ sp->base = tbase;
+ sp->size += tsize;
+ return prepend_alloc(m, tbase, oldbase, nb);
+ }
+ else
+ add_segment(m, tbase, tsize, mmap_flag);
+ }
+ }
+
+ if (nb < m->topsize) { /* Allocate from new or extended top space */
+ size_t rsize = m->topsize -= nb;
+ mchunkptr p = m->top;
+ mchunkptr r = m->top = chunk_plus_offset(p, nb);
+ r->head = rsize | PINUSE_BIT;
+ set_size_and_pinuse_of_inuse_chunk(m, p, nb);
+ check_top_chunk(m, m->top);
+ check_malloced_chunk(m, chunk2mem(p), nb);
+ return chunk2mem(p);
+ }
+ }
+
+ MALLOC_FAILURE_ACTION;
+ return 0;
+}
+
+/* ----------------------- system deallocation -------------------------- */
+
+/* Unmap and unlink any mmapped segments that don't contain used chunks */
+static size_t release_unused_segments(mstate m) {
+ size_t released = 0;
+ msegmentptr pred = &m->seg;
+ msegmentptr sp = pred->next;
+ while (sp != 0) {
+ char* base = sp->base;
+ size_t size = sp->size;
+ msegmentptr next = sp->next;
+ if (is_mmapped_segment(sp) && !is_extern_segment(sp)) {
+ mchunkptr p = align_as_chunk(base);
+ size_t psize = chunksize(p);
+ /* Can unmap if first chunk holds entire segment and not pinned */
+ if (!cinuse(p) && (char*)p + psize >= base + size - TOP_FOOT_SIZE) {
+ tchunkptr tp = (tchunkptr)p;
+ assert(segment_holds(sp, (char*)sp));
+ if (p == m->dv) {
+ m->dv = 0;
+ m->dvsize = 0;
+ }
+ else {
+ unlink_large_chunk(m, tp);
+ }
+ if (CALL_MUNMAP(base, size) == 0) {
+ released += size;
+ m->footprint -= size;
+ /* unlink obsoleted record */
+ sp = pred;
+ sp->next = next;
+ }
+ else { /* back out if cannot unmap */
+ insert_large_chunk(m, tp, psize);
+ }
+ }
+ }
+ pred = sp;
+ sp = next;
+ }
+ return released;
+}
+
+static int sys_trim(mstate m, size_t pad) {
+ size_t released = 0;
+ if (pad < MAX_REQUEST && is_initialized(m)) {
+ pad += TOP_FOOT_SIZE; /* ensure enough room for segment overhead */
+
+ if (m->topsize > pad) {
+ /* Shrink top space in granularity-size units, keeping at least one */
+ size_t unit = mparams.granularity;
+ size_t extra = ((m->topsize - pad + (unit - SIZE_T_ONE)) / unit -
+ SIZE_T_ONE) * unit;
+ msegmentptr sp = segment_holding(m, (char*)m->top);
+
+ if (!is_extern_segment(sp)) {
+ if (is_mmapped_segment(sp)) {
+ if (HAVE_MMAP &&
+ sp->size >= extra &&
+ !has_segment_link(m, sp)) { /* can't shrink if pinned */
+ size_t newsize = sp->size - extra;
+ /* Prefer mremap, fall back to munmap */
+ if ((CALL_MREMAP(sp->base, sp->size, newsize, 0) != MFAIL) ||
+ (CALL_MUNMAP(sp->base + newsize, extra) == 0)) {
+ released = extra;
+ }
+ }
+ }
+ else if (HAVE_MORECORE) {
+ if (extra >= HALF_MAX_SIZE_T) /* Avoid wrapping negative */
+ extra = (HALF_MAX_SIZE_T) + SIZE_T_ONE - unit;
+ ACQUIRE_MORECORE_LOCK();
+ {
+ /* Make sure end of memory is where we last set it. */
+ char* old_br = (char*)(CALL_MORECORE(0));
+ if (old_br == sp->base + sp->size) {
+ char* rel_br = (char*)(CALL_MORECORE(-extra));
+ char* new_br = (char*)(CALL_MORECORE(0));
+ if (rel_br != CMFAIL && new_br < old_br)
+ released = old_br - new_br;
+ }
+ }
+ RELEASE_MORECORE_LOCK();
+ }
+ }
+
+ if (released != 0) {
+ sp->size -= released;
+ m->footprint -= released;
+ init_top(m, m->top, m->topsize - released);
+ check_top_chunk(m, m->top);
+ }
+ }
+
+ /* Unmap any unused mmapped segments */
+ if (HAVE_MMAP)
+ released += release_unused_segments(m);
+
+ /* On failure, disable autotrim to avoid repeated failed future calls */
+ if (released == 0)
+ m->trim_check = MAX_SIZE_T;
+ }
+
+ return (released != 0)? 1 : 0;
+}
+
+/* ---------------------------- malloc support --------------------------- */
+
+/* allocate a large request from the best fitting chunk in a treebin */
+static void* tmalloc_large(mstate m, size_t nb) {
+ tchunkptr v = 0;
+ size_t rsize = -nb; /* Unsigned negation */
+ tchunkptr t;
+ bindex_t idx;
+ compute_tree_index(nb, idx);
+
+ if ((t = *treebin_at(m, idx)) != 0) {
+ /* Traverse tree for this bin looking for node with size == nb */
+ size_t sizebits = nb << leftshift_for_tree_index(idx);
+ tchunkptr rst = 0; /* The deepest untaken right subtree */
+ for (;;) {
+ tchunkptr rt;
+ size_t trem = chunksize(t) - nb;
+ if (trem < rsize) {
+ v = t;
+ if ((rsize = trem) == 0)
+ break;
+ }
+ rt = t->child[1];
+ t = t->child[(sizebits >> (SIZE_T_BITSIZE-SIZE_T_ONE)) & 1];
+ if (rt != 0 && rt != t)
+ rst = rt;
+ if (t == 0) {
+ t = rst; /* set t to least subtree holding sizes > nb */
+ break;
+ }
+ sizebits <<= 1;
+ }
+ }
+
+ if (t == 0 && v == 0) { /* set t to root of next non-empty treebin */
+ binmap_t leftbits = left_bits(idx2bit(idx)) & m->treemap;
+ if (leftbits != 0) {
+ bindex_t i;
+ binmap_t leastbit = least_bit(leftbits);
+ compute_bit2idx(leastbit, i);
+ t = *treebin_at(m, i);
+ }
+ }
+
+ while (t != 0) { /* find smallest of tree or subtree */
+ size_t trem = chunksize(t) - nb;
+ if (trem < rsize) {
+ rsize = trem;
+ v = t;
+ }
+ t = leftmost_child(t);
+ }
+
+ /* If dv is a better fit, return 0 so malloc will use it */
+ if (v != 0 && rsize < (size_t)(m->dvsize - nb)) {
+ if (RTCHECK(ok_address(m, v))) { /* split */
+ mchunkptr r = chunk_plus_offset(v, nb);
+ assert(chunksize(v) == rsize + nb);
+ if (RTCHECK(ok_next(v, r))) {
+ unlink_large_chunk(m, v);
+ if (rsize < MIN_CHUNK_SIZE)
+ set_inuse_and_pinuse(m, v, (rsize + nb));
+ else {
+ set_size_and_pinuse_of_inuse_chunk(m, v, nb);
+ set_size_and_pinuse_of_free_chunk(r, rsize);
+ insert_chunk(m, r, rsize);
+ }
+ return chunk2mem(v);
+ }
+ }
+ CORRUPTION_ERROR_ACTION(m);
+ }
+ return 0;
+}
+
+/* allocate a small request from the best fitting chunk in a treebin */
+static void* tmalloc_small(mstate m, size_t nb) {
+ tchunkptr t, v;
+ size_t rsize;
+ bindex_t i;
+ binmap_t leastbit = least_bit(m->treemap);
+ compute_bit2idx(leastbit, i);
+
+ v = t = *treebin_at(m, i);
+ rsize = chunksize(t) - nb;
+
+ while ((t = leftmost_child(t)) != 0) {
+ size_t trem = chunksize(t) - nb;
+ if (trem < rsize) {
+ rsize = trem;
+ v = t;
+ }
+ }
+
+ if (RTCHECK(ok_address(m, v))) {
+ mchunkptr r = chunk_plus_offset(v, nb);
+ assert(chunksize(v) == rsize + nb);
+ if (RTCHECK(ok_next(v, r))) {
+ unlink_large_chunk(m, v);
+ if (rsize < MIN_CHUNK_SIZE)
+ set_inuse_and_pinuse(m, v, (rsize + nb));
+ else {
+ set_size_and_pinuse_of_inuse_chunk(m, v, nb);
+ set_size_and_pinuse_of_free_chunk(r, rsize);
+ replace_dv(m, r, rsize);
+ }
+ return chunk2mem(v);
+ }
+ }
+
+ CORRUPTION_ERROR_ACTION(m);
+ return 0;
+}
+
+/* --------------------------- realloc support --------------------------- */
+
+static void* internal_realloc(mstate m, void* oldmem, size_t bytes) {
+ if (bytes >= MAX_REQUEST) {
+ MALLOC_FAILURE_ACTION;
+ return 0;
+ }
+ if (!PREACTION(m)) {
+ mchunkptr oldp = mem2chunk(oldmem);
+ size_t oldsize = chunksize(oldp);
+ mchunkptr next = chunk_plus_offset(oldp, oldsize);
+ mchunkptr newp = 0;
+ void* extra = 0;
+
+ /* Try to either shrink or extend into top. Else malloc-copy-free */
+
+ if (RTCHECK(ok_address(m, oldp) && ok_cinuse(oldp) &&
+ ok_next(oldp, next) && ok_pinuse(next))) {
+ size_t nb = request2size(bytes);
+ if (is_mmapped(oldp))
+ newp = mmap_resize(m, oldp, nb);
+ else if (oldsize >= nb) { /* already big enough */
+ size_t rsize = oldsize - nb;
+ newp = oldp;
+ if (rsize >= MIN_CHUNK_SIZE) {
+ mchunkptr remainder = chunk_plus_offset(newp, nb);
+ set_inuse(m, newp, nb);
+ set_inuse(m, remainder, rsize);
+ extra = chunk2mem(remainder);
+ }
+ }
+ else if (next == m->top && oldsize + m->topsize > nb) {
+ /* Expand into top */
+ size_t newsize = oldsize + m->topsize;
+ size_t newtopsize = newsize - nb;
+ mchunkptr newtop = chunk_plus_offset(oldp, nb);
+ set_inuse(m, oldp, nb);
+ newtop->head = newtopsize |PINUSE_BIT;
+ m->top = newtop;
+ m->topsize = newtopsize;
+ newp = oldp;
+ }
+ }
+ else {
+ USAGE_ERROR_ACTION(m, oldmem);
+ POSTACTION(m);
+ return 0;
+ }
+
+ POSTACTION(m);
+
+ if (newp != 0) {
+ if (extra != 0) {
+ internal_free(m, extra);
+ }
+ check_inuse_chunk(m, newp);
+ return chunk2mem(newp);
+ }
+ else {
+ void* newmem = internal_malloc(m, bytes);
+ if (newmem != 0) {
+ size_t oc = oldsize - overhead_for(oldp);
+ memcpy(newmem, oldmem, (oc < bytes)? oc : bytes);
+ internal_free(m, oldmem);
+ }
+ return newmem;
+ }
+ }
+ return 0;
+}
+
+/* --------------------------- memalign support -------------------------- */
+
+static void* internal_memalign(mstate m, size_t alignment, size_t bytes) {
+ if (alignment <= MALLOC_ALIGNMENT) /* Can just use malloc */
+ return internal_malloc(m, bytes);
+ if (alignment < MIN_CHUNK_SIZE) /* must be at least a minimum chunk size */
+ alignment = MIN_CHUNK_SIZE;
+ if ((alignment & (alignment-SIZE_T_ONE)) != 0) {/* Ensure a power of 2 */
+ size_t a = MALLOC_ALIGNMENT << 1;
+ while (a < alignment) a <<= 1;
+ alignment = a;
+ }
+
+ if (bytes >= MAX_REQUEST - alignment) {
+ if (m != 0) { /* Test isn't needed but avoids compiler warning */
+ MALLOC_FAILURE_ACTION;
+ }
+ }
+ else {
+ size_t nb = request2size(bytes);
+ size_t req = nb + alignment + MIN_CHUNK_SIZE - CHUNK_OVERHEAD;
+ char* mem = (char*)internal_malloc(m, req);
+ if (mem != 0) {
+ void* leader = 0;
+ void* trailer = 0;
+ mchunkptr p = mem2chunk(mem);
+
+ if (PREACTION(m)) return 0;
+ if ((((size_t)(mem)) % alignment) != 0) { /* misaligned */
+ /*
+ Find an aligned spot inside chunk. Since we need to give
+ back leading space in a chunk of at least MIN_CHUNK_SIZE, if
+ the first calculation places us at a spot with less than
+ MIN_CHUNK_SIZE leader, we can move to the next aligned spot.
+ We've allocated enough total room so that this is always
+ possible.
+ */
+ char* br = (char*)mem2chunk((size_t)(((size_t)(mem +
+ alignment -
+ SIZE_T_ONE)) &
+ -alignment));
+ char* pos = ((size_t)(br - (char*)(p)) >= MIN_CHUNK_SIZE)?
+ br : br+alignment;
+ mchunkptr newp = (mchunkptr)pos;
+ size_t leadsize = pos - (char*)(p);
+ size_t newsize = chunksize(p) - leadsize;
+
+ if (is_mmapped(p)) { /* For mmapped chunks, just adjust offset */
+ newp->prev_foot = p->prev_foot + leadsize;
+ newp->head = (newsize|CINUSE_BIT);
+ }
+ else { /* Otherwise, give back leader, use the rest */
+ set_inuse(m, newp, newsize);
+ set_inuse(m, p, leadsize);
+ leader = chunk2mem(p);
+ }
+ p = newp;
+ }
+
+ /* Give back spare room at the end */
+ if (!is_mmapped(p)) {
+ size_t size = chunksize(p);
+ if (size > nb + MIN_CHUNK_SIZE) {
+ size_t remainder_size = size - nb;
+ mchunkptr remainder = chunk_plus_offset(p, nb);
+ set_inuse(m, p, nb);
+ set_inuse(m, remainder, remainder_size);
+ trailer = chunk2mem(remainder);
+ }
+ }
+
+ assert (chunksize(p) >= nb);
+ assert((((size_t)(chunk2mem(p))) % alignment) == 0);
+ check_inuse_chunk(m, p);
+ POSTACTION(m);
+ if (leader != 0) {
+ internal_free(m, leader);
+ }
+ if (trailer != 0) {
+ internal_free(m, trailer);
+ }
+ return chunk2mem(p);
+ }
+ }
+ return 0;
+}
+
+/* ------------------------ comalloc/coalloc support --------------------- */
+
+static void** ialloc(mstate m,
+ size_t n_elements,
+ size_t* sizes,
+ int opts,
+ void* chunks[]) {
+ /*
+ This provides common support for independent_X routines, handling
+ all of the combinations that can result.
+
+ The opts arg has:
+ bit 0 set if all elements are same size (using sizes[0])
+ bit 1 set if elements should be zeroed
+ */
+
+ size_t element_size; /* chunksize of each element, if all same */
+ size_t contents_size; /* total size of elements */
+ size_t array_size; /* request size of pointer array */
+ void* mem; /* malloced aggregate space */
+ mchunkptr p; /* corresponding chunk */
+ size_t remainder_size; /* remaining bytes while splitting */
+ void** marray; /* either "chunks" or malloced ptr array */
+ mchunkptr array_chunk; /* chunk for malloced ptr array */
+ flag_t was_enabled; /* to disable mmap */
+ size_t size;
+ size_t i;
+
+ /* compute array length, if needed */
+ if (chunks != 0) {
+ if (n_elements == 0)
+ return chunks; /* nothing to do */
+ marray = chunks;
+ array_size = 0;
+ }
+ else {
+ /* if empty req, must still return chunk representing empty array */
+ if (n_elements == 0)
+ return (void**)internal_malloc(m, 0);
+ marray = 0;
+ array_size = request2size(n_elements * (sizeof(void*)));
+ }
+
+ /* compute total element size */
+ if (opts & 0x1) { /* all-same-size */
+ element_size = request2size(*sizes);
+ contents_size = n_elements * element_size;
+ }
+ else { /* add up all the sizes */
+ element_size = 0;
+ contents_size = 0;
+ for (i = 0; i != n_elements; ++i)
+ contents_size += request2size(sizes[i]);
+ }
+
+ size = contents_size + array_size;
+
+ /*
+ Allocate the aggregate chunk. First disable direct-mmapping so
+ malloc won't use it, since we would not be able to later
+ free/realloc space internal to a segregated mmap region.
+ */
+ was_enabled = use_mmap(m);
+ disable_mmap(m);
+ mem = internal_malloc(m, size - CHUNK_OVERHEAD);
+ if (was_enabled)
+ enable_mmap(m);
+ if (mem == 0)
+ return 0;
+
+ if (PREACTION(m)) return 0;
+ p = mem2chunk(mem);
+ remainder_size = chunksize(p);
+
+ assert(!is_mmapped(p));
+
+ if (opts & 0x2) { /* optionally clear the elements */
+ memset((size_t*)mem, 0, remainder_size - SIZE_T_SIZE - array_size);
+ }
+
+ /* If not provided, allocate the pointer array as final part of chunk */
+ if (marray == 0) {
+ size_t array_chunk_size;
+ array_chunk = chunk_plus_offset(p, contents_size);
+ array_chunk_size = remainder_size - contents_size;
+ marray = (void**) (chunk2mem(array_chunk));
+ set_size_and_pinuse_of_inuse_chunk(m, array_chunk, array_chunk_size);
+ remainder_size = contents_size;
+ }
+
+ /* split out elements */
+ for (i = 0; ; ++i) {
+ marray[i] = chunk2mem(p);
+ if (i != n_elements-1) {
+ if (element_size != 0)
+ size = element_size;
+ else
+ size = request2size(sizes[i]);
+ remainder_size -= size;
+ set_size_and_pinuse_of_inuse_chunk(m, p, size);
+ p = chunk_plus_offset(p, size);
+ }
+ else { /* the final element absorbs any overallocation slop */
+ set_size_and_pinuse_of_inuse_chunk(m, p, remainder_size);
+ break;
+ }
+ }
+
+#if DEBUG
+ if (marray != chunks) {
+ /* final element must have exactly exhausted chunk */
+ if (element_size != 0) {
+ assert(remainder_size == element_size);
+ }
+ else {
+ assert(remainder_size == request2size(sizes[i]));
+ }
+ check_inuse_chunk(m, mem2chunk(marray));
+ }
+ for (i = 0; i != n_elements; ++i)
+ check_inuse_chunk(m, mem2chunk(marray[i]));
+
+#endif /* DEBUG */
+
+ POSTACTION(m);
+ return marray;
+}
+
+
+/* -------------------------- public routines ---------------------------- */
+
+#if !ONLY_MSPACES
+
+void* dlmalloc(size_t bytes) {
+ /*
+ Basic algorithm:
+ If a small request (< 256 bytes minus per-chunk overhead):
+ 1. If one exists, use a remainderless chunk in associated smallbin.
+ (Remainderless means that there are too few excess bytes to
+ represent as a chunk.)
+ 2. If it is big enough, use the dv chunk, which is normally the
+ chunk adjacent to the one used for the most recent small request.
+ 3. If one exists, split the smallest available chunk in a bin,
+ saving remainder in dv.
+ 4. If it is big enough, use the top chunk.
+ 5. If available, get memory from system and use it
+ Otherwise, for a large request:
+ 1. Find the smallest available binned chunk that fits, and use it
+ if it is better fitting than dv chunk, splitting if necessary.
+ 2. If better fitting than any binned chunk, use the dv chunk.
+ 3. If it is big enough, use the top chunk.
+ 4. If request size >= mmap threshold, try to directly mmap this chunk.
+ 5. If available, get memory from system and use it
+
+ The ugly goto's here ensure that postaction occurs along all paths.
+ */
+
+ if (!PREACTION(gm)) {
+ void* mem;
+ size_t nb;
+ if (bytes <= MAX_SMALL_REQUEST) {
+ bindex_t idx;
+ binmap_t smallbits;
+ nb = (bytes < MIN_REQUEST)? MIN_CHUNK_SIZE : pad_request(bytes);
+ idx = small_index(nb);
+ smallbits = gm->smallmap >> idx;
+
+ if ((smallbits & 0x3U) != 0) { /* Remainderless fit to a smallbin. */
+ mchunkptr b, p;
+ idx += ~smallbits & 1; /* Uses next bin if idx empty */
+ b = smallbin_at(gm, idx);
+ p = b->fd;
+ assert(chunksize(p) == small_index2size(idx));
+ unlink_first_small_chunk(gm, b, p, idx);
+ set_inuse_and_pinuse(gm, p, small_index2size(idx));
+ mem = chunk2mem(p);
+ check_malloced_chunk(gm, mem, nb);
+ goto postaction;
+ }
+
+ else if (nb > gm->dvsize) {
+ if (smallbits != 0) { /* Use chunk in next nonempty smallbin */
+ mchunkptr b, p, r;
+ size_t rsize;
+ bindex_t i;
+ binmap_t leftbits = (smallbits << idx) & left_bits(idx2bit(idx));
+ binmap_t leastbit = least_bit(leftbits);
+ compute_bit2idx(leastbit, i);
+ b = smallbin_at(gm, i);
+ p = b->fd;
+ assert(chunksize(p) == small_index2size(i));
+ unlink_first_small_chunk(gm, b, p, i);
+ rsize = small_index2size(i) - nb;
+ /* Fit here cannot be remainderless if 4byte sizes */
+ if (SIZE_T_SIZE != 4 && rsize < MIN_CHUNK_SIZE)
+ set_inuse_and_pinuse(gm, p, small_index2size(i));
+ else {
+ set_size_and_pinuse_of_inuse_chunk(gm, p, nb);
+ r = chunk_plus_offset(p, nb);
+ set_size_and_pinuse_of_free_chunk(r, rsize);
+ replace_dv(gm, r, rsize);
+ }
+ mem = chunk2mem(p);
+ check_malloced_chunk(gm, mem, nb);
+ goto postaction;
+ }
+
+ else if (gm->treemap != 0 && (mem = tmalloc_small(gm, nb)) != 0) {
+ check_malloced_chunk(gm, mem, nb);
+ goto postaction;
+ }
+ }
+ }
+ else if (bytes >= MAX_REQUEST)
+ nb = MAX_SIZE_T; /* Too big to allocate. Force failure (in sys alloc) */
+ else {
+ nb = pad_request(bytes);
+ if (gm->treemap != 0 && (mem = tmalloc_large(gm, nb)) != 0) {
+ check_malloced_chunk(gm, mem, nb);
+ goto postaction;
+ }
+ }
+
+ if (nb <= gm->dvsize) {
+ size_t rsize = gm->dvsize - nb;
+ mchunkptr p = gm->dv;
+ if (rsize >= MIN_CHUNK_SIZE) { /* split dv */
+ mchunkptr r = gm->dv = chunk_plus_offset(p, nb);
+ gm->dvsize = rsize;
+ set_size_and_pinuse_of_free_chunk(r, rsize);
+ set_size_and_pinuse_of_inuse_chunk(gm, p, nb);
+ }
+ else { /* exhaust dv */
+ size_t dvs = gm->dvsize;
+ gm->dvsize = 0;
+ gm->dv = 0;
+ set_inuse_and_pinuse(gm, p, dvs);
+ }
+ mem = chunk2mem(p);
+ check_malloced_chunk(gm, mem, nb);
+ goto postaction;
+ }
+
+ else if (nb < gm->topsize) { /* Split top */
+ size_t rsize = gm->topsize -= nb;
+ mchunkptr p = gm->top;
+ mchunkptr r = gm->top = chunk_plus_offset(p, nb);
+ r->head = rsize | PINUSE_BIT;
+ set_size_and_pinuse_of_inuse_chunk(gm, p, nb);
+ mem = chunk2mem(p);
+ check_top_chunk(gm, gm->top);
+ check_malloced_chunk(gm, mem, nb);
+ goto postaction;
+ }
+
+ mem = sys_alloc(gm, nb);
+
+ postaction:
+ POSTACTION(gm);
+ return mem;
+ }
+
+ return 0;
+}
+
+void dlfree(void* mem) {
+ /*
+ Consolidate freed chunks with preceding or succeeding bordering
+ free chunks, if they exist, and then place in a bin. Intermixed
+ with special cases for top, dv, mmapped chunks, and usage errors.
+ */
+
+ if (mem != 0) {
+ mchunkptr p = mem2chunk(mem);
+#if FOOTERS
+ mstate fm = get_mstate_for(p);
+ if (!ok_magic(fm)) {
+ USAGE_ERROR_ACTION(fm, p);
+ return;
+ }
+#else /* FOOTERS */
+#define fm gm
+#endif /* FOOTERS */
+ if (!PREACTION(fm)) {
+ check_inuse_chunk(fm, p);
+ if (RTCHECK(ok_address(fm, p) && ok_cinuse(p))) {
+ size_t psize = chunksize(p);
+ mchunkptr next = chunk_plus_offset(p, psize);
+ if (!pinuse(p)) {
+ size_t prevsize = p->prev_foot;
+ if ((prevsize & IS_MMAPPED_BIT) != 0) {
+ prevsize &= ~IS_MMAPPED_BIT;
+ psize += prevsize + MMAP_FOOT_PAD;
+ if (CALL_MUNMAP((char*)p - prevsize, psize) == 0)
+ fm->footprint -= psize;
+ goto postaction;
+ }
+ else {
+ mchunkptr prev = chunk_minus_offset(p, prevsize);
+ psize += prevsize;
+ p = prev;
+ if (RTCHECK(ok_address(fm, prev))) { /* consolidate backward */
+ if (p != fm->dv) {
+ unlink_chunk(fm, p, prevsize);
+ }
+ else if ((next->head & INUSE_BITS) == INUSE_BITS) {
+ fm->dvsize = psize;
+ set_free_with_pinuse(p, psize, next);
+ goto postaction;
+ }
+ }
+ else
+ goto erroraction;
+ }
+ }
+
+ if (RTCHECK(ok_next(p, next) && ok_pinuse(next))) {
+ if (!cinuse(next)) { /* consolidate forward */
+ if (next == fm->top) {
+ size_t tsize = fm->topsize += psize;
+ fm->top = p;
+ p->head = tsize | PINUSE_BIT;
+ if (p == fm->dv) {
+ fm->dv = 0;
+ fm->dvsize = 0;
+ }
+ if (should_trim(fm, tsize))
+ sys_trim(fm, 0);
+ goto postaction;
+ }
+ else if (next == fm->dv) {
+ size_t dsize = fm->dvsize += psize;
+ fm->dv = p;
+ set_size_and_pinuse_of_free_chunk(p, dsize);
+ goto postaction;
+ }
+ else {
+ size_t nsize = chunksize(next);
+ psize += nsize;
+ unlink_chunk(fm, next, nsize);
+ set_size_and_pinuse_of_free_chunk(p, psize);
+ if (p == fm->dv) {
+ fm->dvsize = psize;
+ goto postaction;
+ }
+ }
+ }
+ else
+ set_free_with_pinuse(p, psize, next);
+ insert_chunk(fm, p, psize);
+ check_free_chunk(fm, p);
+ goto postaction;
+ }
+ }
+ erroraction:
+ USAGE_ERROR_ACTION(fm, p);
+ postaction:
+ POSTACTION(fm);
+ }
+ }
+#if !FOOTERS
+#undef fm
+#endif /* FOOTERS */
+}
+
+void* dlcalloc(size_t n_elements, size_t elem_size) {
+ void* mem;
+ size_t req = 0;
+ if (n_elements != 0) {
+ req = n_elements * elem_size;
+ if (((n_elements | elem_size) & ~(size_t)0xffff) &&
+ (req / n_elements != elem_size))
+ req = MAX_SIZE_T; /* force downstream failure on overflow */
+ }
+ mem = dlmalloc(req);
+ if (mem != 0 && calloc_must_clear(mem2chunk(mem)))
+ memset(mem, 0, req);
+ return mem;
+}
+
+void* dlrealloc(void* oldmem, size_t bytes) {
+ if (oldmem == 0)
+ return dlmalloc(bytes);
+#ifdef REALLOC_ZERO_BYTES_FREES
+ if (bytes == 0) {
+ dlfree(oldmem);
+ return 0;
+ }
+#endif /* REALLOC_ZERO_BYTES_FREES */
+ else {
+#if ! FOOTERS
+ mstate m = gm;
+#else /* FOOTERS */
+ mstate m = get_mstate_for(mem2chunk(oldmem));
+ if (!ok_magic(m)) {
+ USAGE_ERROR_ACTION(m, oldmem);
+ return 0;
+ }
+#endif /* FOOTERS */
+ return internal_realloc(m, oldmem, bytes);
+ }
+}
+
+void* dlmemalign(size_t alignment, size_t bytes) {
+ return internal_memalign(gm, alignment, bytes);
+}
+
+void** dlindependent_calloc(size_t n_elements, size_t elem_size,
+ void* chunks[]) {
+ size_t sz = elem_size; /* serves as 1-element array */
+ return ialloc(gm, n_elements, &sz, 3, chunks);
+}
+
+void** dlindependent_comalloc(size_t n_elements, size_t sizes[],
+ void* chunks[]) {
+ return ialloc(gm, n_elements, sizes, 0, chunks);
+}
+
+void* dlvalloc(size_t bytes) {
+ size_t pagesz;
+ init_mparams();
+ pagesz = mparams.page_size;
+ return dlmemalign(pagesz, bytes);
+}
+
+void* dlpvalloc(size_t bytes) {
+ size_t pagesz;
+ init_mparams();
+ pagesz = mparams.page_size;
+ return dlmemalign(pagesz, (bytes + pagesz - SIZE_T_ONE) & ~(pagesz - SIZE_T_ONE));
+}
+
+int dlmalloc_trim(size_t pad) {
+ int result = 0;
+ if (!PREACTION(gm)) {
+ result = sys_trim(gm, pad);
+ POSTACTION(gm);
+ }
+ return result;
+}
+
+size_t dlmalloc_footprint(void) {
+ return gm->footprint;
+}
+
+size_t dlmalloc_max_footprint(void) {
+ return gm->max_footprint;
+}
+
+#if !NO_MALLINFO
+struct mallinfo dlmallinfo(void) {
+ return internal_mallinfo(gm);
+}
+#endif /* NO_MALLINFO */
+
+void dlmalloc_stats() {
+ internal_malloc_stats(gm);
+}
+
+size_t dlmalloc_usable_size(void* mem) {
+ if (mem != 0) {
+ mchunkptr p = mem2chunk(mem);
+ if (cinuse(p))
+ return chunksize(p) - overhead_for(p);
+ }
+ return 0;
+}
+
+int dlmallopt(int param_number, int value) {
+ return change_mparam(param_number, value);
+}
+
+#endif /* !ONLY_MSPACES */
+
+/* ----------------------------- user mspaces ---------------------------- */
+
+#if MSPACES
+
+static mstate init_user_mstate(char* tbase, size_t tsize) {
+ size_t msize = pad_request(sizeof(struct malloc_state));
+ mchunkptr mn;
+ mchunkptr msp = align_as_chunk(tbase);
+ mstate m = (mstate)(chunk2mem(msp));
+ memset(m, 0, msize);
+ INITIAL_LOCK(&m->mutex);
+ msp->head = (msize|PINUSE_BIT|CINUSE_BIT);
+ m->seg.base = m->least_addr = tbase;
+ m->seg.size = m->footprint = m->max_footprint = tsize;
+ m->magic = mparams.magic;
+ m->mflags = mparams.default_mflags;
+ disable_contiguous(m);
+ init_bins(m);
+ mn = next_chunk(mem2chunk(m));
+ init_top(m, mn, (size_t)((tbase + tsize) - (char*)mn) - TOP_FOOT_SIZE);
+ check_top_chunk(m, m->top);
+ return m;
+}
+
+mspace create_mspace(size_t capacity, int locked) {
+ mstate m = 0;
+ size_t msize = pad_request(sizeof(struct malloc_state));
+ init_mparams(); /* Ensure pagesize etc initialized */
+
+ if (capacity < (size_t) -(msize + TOP_FOOT_SIZE + mparams.page_size)) {
+ size_t rs = ((capacity == 0)? mparams.granularity :
+ (capacity + TOP_FOOT_SIZE + msize));
+ size_t tsize = granularity_align(rs);
+ char* tbase = (char*)(CALL_MMAP(tsize));
+ if (tbase != CMFAIL) {
+ m = init_user_mstate(tbase, tsize);
+ set_segment_flags(&m->seg, IS_MMAPPED_BIT);
+ set_lock(m, locked);
+ }
+ }
+ return (mspace)m;
+}
+
+mspace create_mspace_with_base(void* base, size_t capacity, int locked) {
+ mstate m = 0;
+ size_t msize = pad_request(sizeof(struct malloc_state));
+ init_mparams(); /* Ensure pagesize etc initialized */
+
+ if (capacity > msize + TOP_FOOT_SIZE &&
+ capacity < (size_t) -(msize + TOP_FOOT_SIZE + mparams.page_size)) {
+ m = init_user_mstate((char*)base, capacity);
+ set_segment_flags(&m->seg, EXTERN_BIT);
+ set_lock(m, locked);
+ }
+ return (mspace)m;
+}
+
+size_t destroy_mspace(mspace msp) {
+ size_t freed = 0;
+ mstate ms = (mstate)msp;
+ if (ok_magic(ms)) {
+ msegmentptr sp = &ms->seg;
+ while (sp != 0) {
+ char* base = sp->base;
+ size_t size = sp->size;
+ flag_t flag = get_segment_flags(sp);
+ sp = sp->next;
+ if ((flag & IS_MMAPPED_BIT) && !(flag & EXTERN_BIT) &&
+ CALL_MUNMAP(base, size) == 0)
+ freed += size;
+ }
+ }
+ else {
+ USAGE_ERROR_ACTION(ms,ms);
+ }
+ return freed;
+}
+
+/*
+ mspace versions of routines are near-clones of the global
+ versions. This is not so nice but better than the alternatives.
+*/
+
+
+void* mspace_malloc(mspace msp, size_t bytes) {
+ mstate ms = (mstate)msp;
+ if (!ok_magic(ms)) {
+ USAGE_ERROR_ACTION(ms,ms);
+ return 0;
+ }
+ if (!PREACTION(ms)) {
+ void* mem;
+ size_t nb;
+ if (bytes <= MAX_SMALL_REQUEST) {
+ bindex_t idx;
+ binmap_t smallbits;
+ nb = (bytes < MIN_REQUEST)? MIN_CHUNK_SIZE : pad_request(bytes);
+ idx = small_index(nb);
+ smallbits = ms->smallmap >> idx;
+
+ if ((smallbits & 0x3U) != 0) { /* Remainderless fit to a smallbin. */
+ mchunkptr b, p;
+ idx += ~smallbits & 1; /* Uses next bin if idx empty */
+ b = smallbin_at(ms, idx);
+ p = b->fd;
+ assert(chunksize(p) == small_index2size(idx));
+ unlink_first_small_chunk(ms, b, p, idx);
+ set_inuse_and_pinuse(ms, p, small_index2size(idx));
+ mem = chunk2mem(p);
+ check_malloced_chunk(ms, mem, nb);
+ goto postaction;
+ }
+
+ else if (nb > ms->dvsize) {
+ if (smallbits != 0) { /* Use chunk in next nonempty smallbin */
+ mchunkptr b, p, r;
+ size_t rsize;
+ bindex_t i;
+ binmap_t leftbits = (smallbits << idx) & left_bits(idx2bit(idx));
+ binmap_t leastbit = least_bit(leftbits);
+ compute_bit2idx(leastbit, i);
+ b = smallbin_at(ms, i);
+ p = b->fd;
+ assert(chunksize(p) == small_index2size(i));
+ unlink_first_small_chunk(ms, b, p, i);
+ rsize = small_index2size(i) - nb;
+ /* Fit here cannot be remainderless if 4byte sizes */
+ if (SIZE_T_SIZE != 4 && rsize < MIN_CHUNK_SIZE)
+ set_inuse_and_pinuse(ms, p, small_index2size(i));
+ else {
+ set_size_and_pinuse_of_inuse_chunk(ms, p, nb);
+ r = chunk_plus_offset(p, nb);
+ set_size_and_pinuse_of_free_chunk(r, rsize);
+ replace_dv(ms, r, rsize);
+ }
+ mem = chunk2mem(p);
+ check_malloced_chunk(ms, mem, nb);
+ goto postaction;
+ }
+
+ else if (ms->treemap != 0 && (mem = tmalloc_small(ms, nb)) != 0) {
+ check_malloced_chunk(ms, mem, nb);
+ goto postaction;
+ }
+ }
+ }
+ else if (bytes >= MAX_REQUEST)
+ nb = MAX_SIZE_T; /* Too big to allocate. Force failure (in sys alloc) */
+ else {
+ nb = pad_request(bytes);
+ if (ms->treemap != 0 && (mem = tmalloc_large(ms, nb)) != 0) {
+ check_malloced_chunk(ms, mem, nb);
+ goto postaction;
+ }
+ }
+
+ if (nb <= ms->dvsize) {
+ size_t rsize = ms->dvsize - nb;
+ mchunkptr p = ms->dv;
+ if (rsize >= MIN_CHUNK_SIZE) { /* split dv */
+ mchunkptr r = ms->dv = chunk_plus_offset(p, nb);
+ ms->dvsize = rsize;
+ set_size_and_pinuse_of_free_chunk(r, rsize);
+ set_size_and_pinuse_of_inuse_chunk(ms, p, nb);
+ }
+ else { /* exhaust dv */
+ size_t dvs = ms->dvsize;
+ ms->dvsize = 0;
+ ms->dv = 0;
+ set_inuse_and_pinuse(ms, p, dvs);
+ }
+ mem = chunk2mem(p);
+ check_malloced_chunk(ms, mem, nb);
+ goto postaction;
+ }
+
+ else if (nb < ms->topsize) { /* Split top */
+ size_t rsize = ms->topsize -= nb;
+ mchunkptr p = ms->top;
+ mchunkptr r = ms->top = chunk_plus_offset(p, nb);
+ r->head = rsize | PINUSE_BIT;
+ set_size_and_pinuse_of_inuse_chunk(ms, p, nb);
+ mem = chunk2mem(p);
+ check_top_chunk(ms, ms->top);
+ check_malloced_chunk(ms, mem, nb);
+ goto postaction;
+ }
+
+ mem = sys_alloc(ms, nb);
+
+ postaction:
+ POSTACTION(ms);
+ return mem;
+ }
+
+ return 0;
+}
+
+void mspace_free(mspace msp, void* mem) {
+ if (mem != 0) {
+ mchunkptr p = mem2chunk(mem);
+#if FOOTERS
+ mstate fm = get_mstate_for(p);
+#else /* FOOTERS */
+ mstate fm = (mstate)msp;
+#endif /* FOOTERS */
+ if (!ok_magic(fm)) {
+ USAGE_ERROR_ACTION(fm, p);
+ return;
+ }
+ if (!PREACTION(fm)) {
+ check_inuse_chunk(fm, p);
+ if (RTCHECK(ok_address(fm, p) && ok_cinuse(p))) {
+ size_t psize = chunksize(p);
+ mchunkptr next = chunk_plus_offset(p, psize);
+ if (!pinuse(p)) {
+ size_t prevsize = p->prev_foot;
+ if ((prevsize & IS_MMAPPED_BIT) != 0) {
+ prevsize &= ~IS_MMAPPED_BIT;
+ psize += prevsize + MMAP_FOOT_PAD;
+ if (CALL_MUNMAP((char*)p - prevsize, psize) == 0)
+ fm->footprint -= psize;
+ goto postaction;
+ }
+ else {
+ mchunkptr prev = chunk_minus_offset(p, prevsize);
+ psize += prevsize;
+ p = prev;
+ if (RTCHECK(ok_address(fm, prev))) { /* consolidate backward */
+ if (p != fm->dv) {
+ unlink_chunk(fm, p, prevsize);
+ }
+ else if ((next->head & INUSE_BITS) == INUSE_BITS) {
+ fm->dvsize = psize;
+ set_free_with_pinuse(p, psize, next);
+ goto postaction;
+ }
+ }
+ else
+ goto erroraction;
+ }
+ }
+
+ if (RTCHECK(ok_next(p, next) && ok_pinuse(next))) {
+ if (!cinuse(next)) { /* consolidate forward */
+ if (next == fm->top) {
+ size_t tsize = fm->topsize += psize;
+ fm->top = p;
+ p->head = tsize | PINUSE_BIT;
+ if (p == fm->dv) {
+ fm->dv = 0;
+ fm->dvsize = 0;
+ }
+ if (should_trim(fm, tsize))
+ sys_trim(fm, 0);
+ goto postaction;
+ }
+ else if (next == fm->dv) {
+ size_t dsize = fm->dvsize += psize;
+ fm->dv = p;
+ set_size_and_pinuse_of_free_chunk(p, dsize);
+ goto postaction;
+ }
+ else {
+ size_t nsize = chunksize(next);
+ psize += nsize;
+ unlink_chunk(fm, next, nsize);
+ set_size_and_pinuse_of_free_chunk(p, psize);
+ if (p == fm->dv) {
+ fm->dvsize = psize;
+ goto postaction;
+ }
+ }
+ }
+ else
+ set_free_with_pinuse(p, psize, next);
+ insert_chunk(fm, p, psize);
+ check_free_chunk(fm, p);
+ goto postaction;
+ }
+ }
+ erroraction:
+ USAGE_ERROR_ACTION(fm, p);
+ postaction:
+ POSTACTION(fm);
+ }
+ }
+}
+
+void* mspace_calloc(mspace msp, size_t n_elements, size_t elem_size) {
+ void* mem;
+ size_t req = 0;
+ mstate ms = (mstate)msp;
+ if (!ok_magic(ms)) {
+ USAGE_ERROR_ACTION(ms,ms);
+ return 0;
+ }
+ if (n_elements != 0) {
+ req = n_elements * elem_size;
+ if (((n_elements | elem_size) & ~(size_t)0xffff) &&
+ (req / n_elements != elem_size))
+ req = MAX_SIZE_T; /* force downstream failure on overflow */
+ }
+ mem = internal_malloc(ms, req);
+ if (mem != 0 && calloc_must_clear(mem2chunk(mem)))
+ memset(mem, 0, req);
+ return mem;
+}
+
+void* mspace_realloc(mspace msp, void* oldmem, size_t bytes) {
+ if (oldmem == 0)
+ return mspace_malloc(msp, bytes);
+#ifdef REALLOC_ZERO_BYTES_FREES
+ if (bytes == 0) {
+ mspace_free(msp, oldmem);
+ return 0;
+ }
+#endif /* REALLOC_ZERO_BYTES_FREES */
+ else {
+#if FOOTERS
+ mchunkptr p = mem2chunk(oldmem);
+ mstate ms = get_mstate_for(p);
+#else /* FOOTERS */
+ mstate ms = (mstate)msp;
+#endif /* FOOTERS */
+ if (!ok_magic(ms)) {
+ USAGE_ERROR_ACTION(ms,ms);
+ return 0;
+ }
+ return internal_realloc(ms, oldmem, bytes);
+ }
+}
+
+void* mspace_memalign(mspace msp, size_t alignment, size_t bytes) {
+ mstate ms = (mstate)msp;
+ if (!ok_magic(ms)) {
+ USAGE_ERROR_ACTION(ms,ms);
+ return 0;
+ }
+ return internal_memalign(ms, alignment, bytes);
+}
+
+void** mspace_independent_calloc(mspace msp, size_t n_elements,
+ size_t elem_size, void* chunks[]) {
+ size_t sz = elem_size; /* serves as 1-element array */
+ mstate ms = (mstate)msp;
+ if (!ok_magic(ms)) {
+ USAGE_ERROR_ACTION(ms,ms);
+ return 0;
+ }
+ return ialloc(ms, n_elements, &sz, 3, chunks);
+}
+
+void** mspace_independent_comalloc(mspace msp, size_t n_elements,
+ size_t sizes[], void* chunks[]) {
+ mstate ms = (mstate)msp;
+ if (!ok_magic(ms)) {
+ USAGE_ERROR_ACTION(ms,ms);
+ return 0;
+ }
+ return ialloc(ms, n_elements, sizes, 0, chunks);
+}
+
+int mspace_trim(mspace msp, size_t pad) {
+ int result = 0;
+ mstate ms = (mstate)msp;
+ if (ok_magic(ms)) {
+ if (!PREACTION(ms)) {
+ result = sys_trim(ms, pad);
+ POSTACTION(ms);
+ }
+ }
+ else {
+ USAGE_ERROR_ACTION(ms,ms);
+ }
+ return result;
+}
+
+void mspace_malloc_stats(mspace msp) {
+ mstate ms = (mstate)msp;
+ if (ok_magic(ms)) {
+ internal_malloc_stats(ms);
+ }
+ else {
+ USAGE_ERROR_ACTION(ms,ms);
+ }
+}
+
+size_t mspace_footprint(mspace msp) {
+ size_t result;
+ mstate ms = (mstate)msp;
+ if (ok_magic(ms)) {
+ result = ms->footprint;
+ }
+ USAGE_ERROR_ACTION(ms,ms);
+ return result;
+}
+
+
+size_t mspace_max_footprint(mspace msp) {
+ size_t result;
+ mstate ms = (mstate)msp;
+ if (ok_magic(ms)) {
+ result = ms->max_footprint;
+ }
+ USAGE_ERROR_ACTION(ms,ms);
+ return result;
+}
+
+
+#if !NO_MALLINFO
+struct mallinfo mspace_mallinfo(mspace msp) {
+ mstate ms = (mstate)msp;
+ if (!ok_magic(ms)) {
+ USAGE_ERROR_ACTION(ms,ms);
+ }
+ return internal_mallinfo(ms);
+}
+#endif /* NO_MALLINFO */
+
+int mspace_mallopt(int param_number, int value) {
+ return change_mparam(param_number, value);
+}
+
+#endif /* MSPACES */
+
+/* -------------------- Alternative MORECORE functions ------------------- */
+
+/*
+ Guidelines for creating a custom version of MORECORE:
+
+ * For best performance, MORECORE should allocate in multiples of pagesize.
+ * MORECORE may allocate more memory than requested. (Or even less,
+ but this will usually result in a malloc failure.)
+ * MORECORE must not allocate memory when given argument zero, but
+ instead return one past the end address of memory from previous
+ nonzero call.
+ * For best performance, consecutive calls to MORECORE with positive
+ arguments should return increasing addresses, indicating that
+ space has been contiguously extended.
+ * Even though consecutive calls to MORECORE need not return contiguous
+ addresses, it must be OK for malloc'ed chunks to span multiple
+ regions in those cases where they do happen to be contiguous.
+ * MORECORE need not handle negative arguments -- it may instead
+ just return MFAIL when given negative arguments.
+ Negative arguments are always multiples of pagesize. MORECORE
+ must not misinterpret negative args as large positive unsigned
+ args. You can suppress all such calls from even occurring by defining
+ MORECORE_CANNOT_TRIM,
+
+ As an example alternative MORECORE, here is a custom allocator
+ kindly contributed for pre-OSX macOS. It uses virtually but not
+ necessarily physically contiguous non-paged memory (locked in,
+ present and won't get swapped out). You can use it by uncommenting
+ this section, adding some #includes, and setting up the appropriate
+ defines above:
+
+ #define MORECORE osMoreCore
+
+ There is also a shutdown routine that should somehow be called for
+ cleanup upon program exit.
+
+ #define MAX_POOL_ENTRIES 100
+ #define MINIMUM_MORECORE_SIZE (64 * 1024U)
+ static int next_os_pool;
+ void *our_os_pools[MAX_POOL_ENTRIES];
+
+ void *osMoreCore(int size)
+ {
+ void *ptr = 0;
+ static void *sbrk_top = 0;
+
+ if (size > 0)
+ {
+ if (size < MINIMUM_MORECORE_SIZE)
+ size = MINIMUM_MORECORE_SIZE;
+ if (CurrentExecutionLevel() == kTaskLevel)
+ ptr = PoolAllocateResident(size + RM_PAGE_SIZE, 0);
+ if (ptr == 0)
+ {
+ return (void *) MFAIL;
+ }
+ // save ptrs so they can be freed during cleanup
+ our_os_pools[next_os_pool] = ptr;
+ next_os_pool++;
+ ptr = (void *) ((((size_t) ptr) + RM_PAGE_MASK) & ~RM_PAGE_MASK);
+ sbrk_top = (char *) ptr + size;
+ return ptr;
+ }
+ else if (size < 0)
+ {
+ // we don't currently support shrink behavior
+ return (void *) MFAIL;
+ }
+ else
+ {
+ return sbrk_top;
+ }
+ }
+
+ // cleanup any allocated memory pools
+ // called as last thing before shutting down driver
+
+ void osCleanupMem(void)
+ {
+ void **ptr;
+
+ for (ptr = our_os_pools; ptr < &our_os_pools[MAX_POOL_ENTRIES]; ptr++)
+ if (*ptr)
+ {
+ PoolDeallocate(*ptr);
+ *ptr = 0;
+ }
+ }
+
+*/
+
+
+/* -----------------------------------------------------------------------
+History:
+ V2.8.3 Thu Sep 22 11:16:32 2005 Doug Lea (dl at gee)
+ * Add max_footprint functions
+ * Ensure all appropriate literals are size_t
+ * Fix conditional compilation problem for some #define settings
+ * Avoid concatenating segments with the one provided
+ in create_mspace_with_base
+ * Rename some variables to avoid compiler shadowing warnings
+ * Use explicit lock initialization.
+ * Better handling of sbrk interference.
+ * Simplify and fix segment insertion, trimming and mspace_destroy
+ * Reinstate REALLOC_ZERO_BYTES_FREES option from 2.7.x
+ * Thanks especially to Dennis Flanagan for help on these.
+
+ V2.8.2 Sun Jun 12 16:01:10 2005 Doug Lea (dl at gee)
+ * Fix memalign brace error.
+
+ V2.8.1 Wed Jun 8 16:11:46 2005 Doug Lea (dl at gee)
+ * Fix improper #endif nesting in C++
+ * Add explicit casts needed for C++
+
+ V2.8.0 Mon May 30 14:09:02 2005 Doug Lea (dl at gee)
+ * Use trees for large bins
+ * Support mspaces
+ * Use segments to unify sbrk-based and mmap-based system allocation,
+ removing need for emulation on most platforms without sbrk.
+ * Default safety checks
+ * Optional footer checks. Thanks to William Robertson for the idea.
+ * Internal code refactoring
+ * Incorporate suggestions and platform-specific changes.
+ Thanks to Dennis Flanagan, Colin Plumb, Niall Douglas,
+ Aaron Bachmann, Emery Berger, and others.
+ * Speed up non-fastbin processing enough to remove fastbins.
+ * Remove useless cfree() to avoid conflicts with other apps.
+ * Remove internal memcpy, memset. Compilers handle builtins better.
+ * Remove some options that no one ever used and rename others.
+
+ V2.7.2 Sat Aug 17 09:07:30 2002 Doug Lea (dl at gee)
+ * Fix malloc_state bitmap array misdeclaration
+
+ V2.7.1 Thu Jul 25 10:58:03 2002 Doug Lea (dl at gee)
+ * Allow tuning of FIRST_SORTED_BIN_SIZE
+ * Use PTR_UINT as type for all ptr->int casts. Thanks to John Belmonte.
+ * Better detection and support for non-contiguousness of MORECORE.
+ Thanks to Andreas Mueller, Conal Walsh, and Wolfram Gloger
+ * Bypass most of malloc if no frees. Thanks To Emery Berger.
+ * Fix freeing of old top non-contiguous chunk im sysmalloc.
+ * Raised default trim and map thresholds to 256K.
+ * Fix mmap-related #defines. Thanks to Lubos Lunak.
+ * Fix copy macros; added LACKS_FCNTL_H. Thanks to Neal Walfield.
+ * Branch-free bin calculation
+ * Default trim and mmap thresholds now 256K.
+
+ V2.7.0 Sun Mar 11 14:14:06 2001 Doug Lea (dl at gee)
+ * Introduce independent_comalloc and independent_calloc.
+ Thanks to Michael Pachos for motivation and help.
+ * Make optional .h file available
+ * Allow > 2GB requests on 32bit systems.
+ * new WIN32 sbrk, mmap, munmap, lock code from <Walter@GeNeSys-e.de>.
+ Thanks also to Andreas Mueller <a.mueller at paradatec.de>,
+ and Anonymous.
+ * Allow override of MALLOC_ALIGNMENT (Thanks to Ruud Waij for
+ helping test this.)
+ * memalign: check alignment arg
+ * realloc: don't try to shift chunks backwards, since this
+ leads to more fragmentation in some programs and doesn't
+ seem to help in any others.
+ * Collect all cases in malloc requiring system memory into sysmalloc
+ * Use mmap as backup to sbrk
+ * Place all internal state in malloc_state
+ * Introduce fastbins (although similar to 2.5.1)
+ * Many minor tunings and cosmetic improvements
+ * Introduce USE_PUBLIC_MALLOC_WRAPPERS, USE_MALLOC_LOCK
+ * Introduce MALLOC_FAILURE_ACTION, MORECORE_CONTIGUOUS
+ Thanks to Tony E. Bennett <tbennett@nvidia.com> and others.
+ * Include errno.h to support default failure action.
+
+ V2.6.6 Sun Dec 5 07:42:19 1999 Doug Lea (dl at gee)
+ * return null for negative arguments
+ * Added Several WIN32 cleanups from Martin C. Fong <mcfong at yahoo.com>
+ * Add 'LACKS_SYS_PARAM_H' for those systems without 'sys/param.h'
+ (e.g. WIN32 platforms)
+ * Cleanup header file inclusion for WIN32 platforms
+ * Cleanup code to avoid Microsoft Visual C++ compiler complaints
+ * Add 'USE_DL_PREFIX' to quickly allow co-existence with existing
+ memory allocation routines
+ * Set 'malloc_getpagesize' for WIN32 platforms (needs more work)
+ * Use 'assert' rather than 'ASSERT' in WIN32 code to conform to
+ usage of 'assert' in non-WIN32 code
+ * Improve WIN32 'sbrk()' emulation's 'findRegion()' routine to
+ avoid infinite loop
+ * Always call 'fREe()' rather than 'free()'
+
+ V2.6.5 Wed Jun 17 15:57:31 1998 Doug Lea (dl at gee)
+ * Fixed ordering problem with boundary-stamping
+
+ V2.6.3 Sun May 19 08:17:58 1996 Doug Lea (dl at gee)
+ * Added pvalloc, as recommended by H.J. Liu
+ * Added 64bit pointer support mainly from Wolfram Gloger
+ * Added anonymously donated WIN32 sbrk emulation
+ * Malloc, calloc, getpagesize: add optimizations from Raymond Nijssen
+ * malloc_extend_top: fix mask error that caused wastage after
+ foreign sbrks
+ * Add linux mremap support code from HJ Liu
+
+ V2.6.2 Tue Dec 5 06:52:55 1995 Doug Lea (dl at gee)
+ * Integrated most documentation with the code.
+ * Add support for mmap, with help from
+ Wolfram Gloger (Gloger@lrz.uni-muenchen.de).
+ * Use last_remainder in more cases.
+ * Pack bins using idea from colin@nyx10.cs.du.edu
+ * Use ordered bins instead of best-fit threshold
+ * Eliminate block-local decls to simplify tracing and debugging.
+ * Support another case of realloc via move into top
+ * Fix error occurring when initial sbrk_base not word-aligned.
+ * Rely on page size for units instead of SBRK_UNIT to
+ avoid surprises about sbrk alignment conventions.
+ * Add mallinfo, mallopt. Thanks to Raymond Nijssen
+ (raymond@es.ele.tue.nl) for the suggestion.
+ * Add `pad' argument to malloc_trim and top_pad mallopt parameter.
+ * More precautions for cases where other routines call sbrk,
+ courtesy of Wolfram Gloger (Gloger@lrz.uni-muenchen.de).
+ * Added macros etc., allowing use in linux libc from
+ H.J. Lu (hjl@gnu.ai.mit.edu)
+ * Inverted this history list
+
+ V2.6.1 Sat Dec 2 14:10:57 1995 Doug Lea (dl at gee)
+ * Re-tuned and fixed to behave more nicely with V2.6.0 changes.
+ * Removed all preallocation code since under current scheme
+ the work required to undo bad preallocations exceeds
+ the work saved in good cases for most test programs.
+ * No longer use return list or unconsolidated bins since
+ no scheme using them consistently outperforms those that don't
+ given above changes.
+ * Use best fit for very large chunks to prevent some worst-cases.
+ * Added some support for debugging
+
+ V2.6.0 Sat Nov 4 07:05:23 1995 Doug Lea (dl at gee)
+ * Removed footers when chunks are in use. Thanks to
+ Paul Wilson (wilson@cs.texas.edu) for the suggestion.
+
+ V2.5.4 Wed Nov 1 07:54:51 1995 Doug Lea (dl at gee)
+ * Added malloc_trim, with help from Wolfram Gloger
+ (wmglo@Dent.MED.Uni-Muenchen.DE).
+
+ V2.5.3 Tue Apr 26 10:16:01 1994 Doug Lea (dl at g)
+
+ V2.5.2 Tue Apr 5 16:20:40 1994 Doug Lea (dl at g)
+ * realloc: try to expand in both directions
+ * malloc: swap order of clean-bin strategy;
+ * realloc: only conditionally expand backwards
+ * Try not to scavenge used bins
+ * Use bin counts as a guide to preallocation
+ * Occasionally bin return list chunks in first scan
+ * Add a few optimizations from colin@nyx10.cs.du.edu
+
+ V2.5.1 Sat Aug 14 15:40:43 1993 Doug Lea (dl at g)
+ * faster bin computation & slightly different binning
+ * merged all consolidations to one part of malloc proper
+ (eliminating old malloc_find_space & malloc_clean_bin)
+ * Scan 2 returns chunks (not just 1)
+ * Propagate failure in realloc if malloc returns 0
+ * Add stuff to allow compilation on non-ANSI compilers
+ from kpv@research.att.com
+
+ V2.5 Sat Aug 7 07:41:59 1993 Doug Lea (dl at g.oswego.edu)
+ * removed potential for odd address access in prev_chunk
+ * removed dependency on getpagesize.h
+ * misc cosmetics and a bit more internal documentation
+ * anticosmetics: mangled names in macros to evade debugger strangeness
+ * tested on sparc, hp-700, dec-mips, rs6000
+ with gcc & native cc (hp, dec only) allowing
+ Detlefs & Zorn comparison study (in SIGPLAN Notices.)
+
+ Trial version Fri Aug 28 13:14:29 1992 Doug Lea (dl at g.oswego.edu)
+ * Based loosely on libg++-1.2X malloc. (It retains some of the overall
+ structure of old version, but most details differ.)
+
+*/
diff --git a/jni/ruby/ext/fiddle/libffi-3.2.1/src/frv/eabi.S b/jni/ruby/ext/fiddle/libffi-3.2.1/src/frv/eabi.S
new file mode 100644
index 0000000..379ea4b
--- /dev/null
+++ b/jni/ruby/ext/fiddle/libffi-3.2.1/src/frv/eabi.S
@@ -0,0 +1,128 @@
+/* -----------------------------------------------------------------------
+ eabi.S - Copyright (c) 2004 Anthony Green
+
+ FR-V Assembly glue.
+
+ Permission is hereby granted, free of charge, to any person obtaining
+ a copy of this software and associated documentation files (the
+ ``Software''), to deal in the Software without restriction, including
+ without limitation the rights to use, copy, modify, merge, publish,
+ distribute, sublicense, and/or sell copies of the Software, and to
+ permit persons to whom the Software is furnished to do so, subject to
+ the following conditions:
+
+ The above copyright notice and this permission notice shall be included
+ in all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ OTHER DEALINGS IN THE SOFTWARE.
+ ----------------------------------------------------------------------- */
+
+#define LIBFFI_ASM
+#include <fficonfig.h>
+#include <ffi.h>
+
+ .globl ffi_prep_args_EABI
+
+ .text
+ .p2align 4
+ .globl ffi_call_EABI
+ .type ffi_call_EABI, @function
+
+ # gr8 : ffi_prep_args
+ # gr9 : &ecif
+ # gr10: cif->bytes
+ # gr11: fig->flags
+ # gr12: ecif.rvalue
+ # gr13: fn
+
+ffi_call_EABI:
+ addi sp, #-80, sp
+ sti fp, @(sp, #24)
+ addi sp, #24, fp
+ movsg lr, gr5
+
+ /* Make room for the new arguments. */
+ /* subi sp, fp, gr10 */
+
+ /* Store return address and incoming args on stack. */
+ sti gr5, @(fp, #8)
+ sti gr8, @(fp, #-4)
+ sti gr9, @(fp, #-8)
+ sti gr10, @(fp, #-12)
+ sti gr11, @(fp, #-16)
+ sti gr12, @(fp, #-20)
+ sti gr13, @(fp, #-24)
+
+ sub sp, gr10, sp
+
+ /* Call ffi_prep_args. */
+ ldi @(fp, #-4), gr4
+ addi sp, #0, gr8
+ ldi @(fp, #-8), gr9
+#ifdef __FRV_FDPIC__
+ ldd @(gr4, gr0), gr14
+ calll @(gr14, gr0)
+#else
+ calll @(gr4, gr0)
+#endif
+
+ /* ffi_prep_args returns the new stack pointer. */
+ mov gr8, gr4
+
+ ldi @(sp, #0), gr8
+ ldi @(sp, #4), gr9
+ ldi @(sp, #8), gr10
+ ldi @(sp, #12), gr11
+ ldi @(sp, #16), gr12
+ ldi @(sp, #20), gr13
+
+ /* Always copy the return value pointer into the hidden
+ parameter register. This is only strictly necessary
+ when we're returning an aggregate type, but it doesn't
+ hurt to do this all the time, and it saves a branch. */
+ ldi @(fp, #-20), gr3
+
+ /* Use the ffi_prep_args return value for the new sp. */
+ mov gr4, sp
+
+ /* Call the target function. */
+ ldi @(fp, -24), gr4
+#ifdef __FRV_FDPIC__
+ ldd @(gr4, gr0), gr14
+ calll @(gr14, gr0)
+#else
+ calll @(gr4, gr0)
+#endif
+
+ /* Store the result. */
+ ldi @(fp, #-16), gr10 /* fig->flags */
+ ldi @(fp, #-20), gr4 /* ecif.rvalue */
+
+ /* Is the return value stored in two registers? */
+ cmpi gr10, #8, icc0
+ bne icc0, 0, .L2
+ /* Yes, save them. */
+ sti gr8, @(gr4, #0)
+ sti gr9, @(gr4, #4)
+ bra .L3
+.L2:
+ /* Is the return value a structure? */
+ cmpi gr10, #-1, icc0
+ beq icc0, 0, .L3
+ /* No, save a 4 byte return value. */
+ sti gr8, @(gr4, #0)
+.L3:
+
+ /* Restore the stack, and return. */
+ ldi @(fp, 8), gr5
+ ld @(fp, gr0), fp
+ addi sp,#80,sp
+ jmpl @(gr5,gr0)
+ .size ffi_call_EABI, .-ffi_call_EABI
+
diff --git a/jni/ruby/ext/fiddle/libffi-3.2.1/src/frv/ffi.c b/jni/ruby/ext/fiddle/libffi-3.2.1/src/frv/ffi.c
new file mode 100644
index 0000000..5698c89
--- /dev/null
+++ b/jni/ruby/ext/fiddle/libffi-3.2.1/src/frv/ffi.c
@@ -0,0 +1,292 @@
+/* -----------------------------------------------------------------------
+ ffi.c - Copyright (C) 2004 Anthony Green
+ Copyright (C) 2007 Free Software Foundation, Inc.
+ Copyright (C) 2008 Red Hat, Inc.
+
+ FR-V Foreign Function Interface
+
+ Permission is hereby granted, free of charge, to any person obtaining
+ a copy of this software and associated documentation files (the
+ ``Software''), to deal in the Software without restriction, including
+ without limitation the rights to use, copy, modify, merge, publish,
+ distribute, sublicense, and/or sell copies of the Software, and to
+ permit persons to whom the Software is furnished to do so, subject to
+ the following conditions:
+
+ The above copyright notice and this permission notice shall be included
+ in all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND,
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+ HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ DEALINGS IN THE SOFTWARE.
+ ----------------------------------------------------------------------- */
+
+#include <ffi.h>
+#include <ffi_common.h>
+
+#include <stdlib.h>
+
+/* ffi_prep_args is called by the assembly routine once stack space
+ has been allocated for the function's arguments */
+
+void *ffi_prep_args(char *stack, extended_cif *ecif)
+{
+ register unsigned int i;
+ register void **p_argv;
+ register char *argp;
+ register ffi_type **p_arg;
+ register int count = 0;
+
+ p_argv = ecif->avalue;
+ argp = stack;
+
+ for (i = ecif->cif->nargs, p_arg = ecif->cif->arg_types;
+ (i != 0);
+ i--, p_arg++)
+ {
+ size_t z;
+
+ z = (*p_arg)->size;
+
+ if ((*p_arg)->type == FFI_TYPE_STRUCT)
+ {
+ z = sizeof(void*);
+ *(void **) argp = *p_argv;
+ }
+ /* if ((*p_arg)->type == FFI_TYPE_FLOAT)
+ {
+ if (count > 24)
+ {
+ // This is going on the stack. Turn it into a double.
+ *(double *) argp = (double) *(float*)(* p_argv);
+ z = sizeof(double);
+ }
+ else
+ *(void **) argp = *(void **)(* p_argv);
+ } */
+ else if (z < sizeof(int))
+ {
+ z = sizeof(int);
+ switch ((*p_arg)->type)
+ {
+ case FFI_TYPE_SINT8:
+ *(signed int *) argp = (signed int)*(SINT8 *)(* p_argv);
+ break;
+
+ case FFI_TYPE_UINT8:
+ *(unsigned int *) argp = (unsigned int)*(UINT8 *)(* p_argv);
+ break;
+
+ case FFI_TYPE_SINT16:
+ *(signed int *) argp = (signed int)*(SINT16 *)(* p_argv);
+ break;
+
+ case FFI_TYPE_UINT16:
+ *(unsigned int *) argp = (unsigned int)*(UINT16 *)(* p_argv);
+ break;
+
+ default:
+ FFI_ASSERT(0);
+ }
+ }
+ else if (z == sizeof(int))
+ {
+ *(unsigned int *) argp = (unsigned int)*(UINT32 *)(* p_argv);
+ }
+ else
+ {
+ memcpy(argp, *p_argv, z);
+ }
+ p_argv++;
+ argp += z;
+ count += z;
+ }
+
+ return (stack + ((count > 24) ? 24 : ALIGN_DOWN(count, 8)));
+}
+
+/* Perform machine dependent cif processing */
+ffi_status ffi_prep_cif_machdep(ffi_cif *cif)
+{
+ if (cif->rtype->type == FFI_TYPE_STRUCT)
+ cif->flags = -1;
+ else
+ cif->flags = cif->rtype->size;
+
+ cif->bytes = ALIGN (cif->bytes, 8);
+
+ return FFI_OK;
+}
+
+extern void ffi_call_EABI(void *(*)(char *, extended_cif *),
+ extended_cif *,
+ unsigned, unsigned,
+ unsigned *,
+ void (*fn)(void));
+
+void ffi_call(ffi_cif *cif,
+ void (*fn)(void),
+ void *rvalue,
+ void **avalue)
+{
+ extended_cif ecif;
+
+ ecif.cif = cif;
+ ecif.avalue = avalue;
+
+ /* If the return value is a struct and we don't have a return */
+ /* value address then we need to make one */
+
+ if ((rvalue == NULL) &&
+ (cif->rtype->type == FFI_TYPE_STRUCT))
+ {
+ ecif.rvalue = alloca(cif->rtype->size);
+ }
+ else
+ ecif.rvalue = rvalue;
+
+
+ switch (cif->abi)
+ {
+ case FFI_EABI:
+ ffi_call_EABI(ffi_prep_args, &ecif, cif->bytes,
+ cif->flags, ecif.rvalue, fn);
+ break;
+ default:
+ FFI_ASSERT(0);
+ break;
+ }
+}
+
+void ffi_closure_eabi (unsigned arg1, unsigned arg2, unsigned arg3,
+ unsigned arg4, unsigned arg5, unsigned arg6)
+{
+ /* This function is called by a trampoline. The trampoline stows a
+ pointer to the ffi_closure object in gr7. We must save this
+ pointer in a place that will persist while we do our work. */
+ register ffi_closure *creg __asm__ ("gr7");
+ ffi_closure *closure = creg;
+
+ /* Arguments that don't fit in registers are found on the stack
+ at a fixed offset above the current frame pointer. */
+ register char *frame_pointer __asm__ ("fp");
+ char *stack_args = frame_pointer + 16;
+
+ /* Lay the register arguments down in a continuous chunk of memory. */
+ unsigned register_args[6] =
+ { arg1, arg2, arg3, arg4, arg5, arg6 };
+
+ ffi_cif *cif = closure->cif;
+ ffi_type **arg_types = cif->arg_types;
+ void **avalue = alloca (cif->nargs * sizeof(void *));
+ char *ptr = (char *) register_args;
+ int i;
+
+ /* Find the address of each argument. */
+ for (i = 0; i < cif->nargs; i++)
+ {
+ switch (arg_types[i]->type)
+ {
+ case FFI_TYPE_SINT8:
+ case FFI_TYPE_UINT8:
+ avalue[i] = ptr + 3;
+ break;
+ case FFI_TYPE_SINT16:
+ case FFI_TYPE_UINT16:
+ avalue[i] = ptr + 2;
+ break;
+ case FFI_TYPE_SINT32:
+ case FFI_TYPE_UINT32:
+ case FFI_TYPE_FLOAT:
+ avalue[i] = ptr;
+ break;
+ case FFI_TYPE_STRUCT:
+ avalue[i] = *(void**)ptr;
+ break;
+ default:
+ /* This is an 8-byte value. */
+ avalue[i] = ptr;
+ ptr += 4;
+ break;
+ }
+ ptr += 4;
+
+ /* If we've handled more arguments than fit in registers,
+ start looking at the those passed on the stack. */
+ if (ptr == ((char *)register_args + (6*4)))
+ ptr = stack_args;
+ }
+
+ /* Invoke the closure. */
+ if (cif->rtype->type == FFI_TYPE_STRUCT)
+ {
+ /* The caller allocates space for the return structure, and
+ passes a pointer to this space in gr3. Use this value directly
+ as the return value. */
+ register void *return_struct_ptr __asm__("gr3");
+ (closure->fun) (cif, return_struct_ptr, avalue, closure->user_data);
+ }
+ else
+ {
+ /* Allocate space for the return value and call the function. */
+ long long rvalue;
+ (closure->fun) (cif, &rvalue, avalue, closure->user_data);
+
+ /* Functions return 4-byte or smaller results in gr8. 8-byte
+ values also use gr9. We fill the both, even for small return
+ values, just to avoid a branch. */
+ asm ("ldi @(%0, #0), gr8" : : "r" (&rvalue));
+ asm ("ldi @(%0, #0), gr9" : : "r" (&((int *) &rvalue)[1]));
+ }
+}
+
+ffi_status
+ffi_prep_closure_loc (ffi_closure* closure,
+ ffi_cif* cif,
+ void (*fun)(ffi_cif*, void*, void**, void*),
+ void *user_data,
+ void *codeloc)
+{
+ unsigned int *tramp = (unsigned int *) &closure->tramp[0];
+ unsigned long fn = (long) ffi_closure_eabi;
+ unsigned long cls = (long) codeloc;
+#ifdef __FRV_FDPIC__
+ register void *got __asm__("gr15");
+#endif
+ int i;
+
+ fn = (unsigned long) ffi_closure_eabi;
+
+#ifdef __FRV_FDPIC__
+ tramp[0] = &((unsigned int *)codeloc)[2];
+ tramp[1] = got;
+ tramp[2] = 0x8cfc0000 + (fn & 0xffff); /* setlos lo(fn), gr6 */
+ tramp[3] = 0x8efc0000 + (cls & 0xffff); /* setlos lo(cls), gr7 */
+ tramp[4] = 0x8cf80000 + (fn >> 16); /* sethi hi(fn), gr6 */
+ tramp[5] = 0x8ef80000 + (cls >> 16); /* sethi hi(cls), gr7 */
+ tramp[6] = 0x9cc86000; /* ldi @(gr6, #0), gr14 */
+ tramp[7] = 0x8030e000; /* jmpl @(gr14, gr0) */
+#else
+ tramp[0] = 0x8cfc0000 + (fn & 0xffff); /* setlos lo(fn), gr6 */
+ tramp[1] = 0x8efc0000 + (cls & 0xffff); /* setlos lo(cls), gr7 */
+ tramp[2] = 0x8cf80000 + (fn >> 16); /* sethi hi(fn), gr6 */
+ tramp[3] = 0x8ef80000 + (cls >> 16); /* sethi hi(cls), gr7 */
+ tramp[4] = 0x80300006; /* jmpl @(gr0, gr6) */
+#endif
+
+ closure->cif = cif;
+ closure->fun = fun;
+ closure->user_data = user_data;
+
+ /* Cache flushing. */
+ for (i = 0; i < FFI_TRAMPOLINE_SIZE; i++)
+ __asm__ volatile ("dcf @(%0,%1)\n\tici @(%2,%1)" :: "r" (tramp), "r" (i),
+ "r" (codeloc));
+
+ return FFI_OK;
+}
diff --git a/jni/ruby/ext/fiddle/libffi-3.2.1/src/frv/ffitarget.h b/jni/ruby/ext/fiddle/libffi-3.2.1/src/frv/ffitarget.h
new file mode 100644
index 0000000..d42540e
--- /dev/null
+++ b/jni/ruby/ext/fiddle/libffi-3.2.1/src/frv/ffitarget.h
@@ -0,0 +1,62 @@
+/* -----------------------------------------------------------------*-C-*-
+ ffitarget.h - Copyright (c) 2012 Anthony Green
+ Copyright (c) 1996-2004 Red Hat, Inc.
+ Target configuration macros for FR-V
+
+ Permission is hereby granted, free of charge, to any person obtaining
+ a copy of this software and associated documentation files (the
+ ``Software''), to deal in the Software without restriction, including
+ without limitation the rights to use, copy, modify, merge, publish,
+ distribute, sublicense, and/or sell copies of the Software, and to
+ permit persons to whom the Software is furnished to do so, subject to
+ the following conditions:
+
+ The above copyright notice and this permission notice shall be included
+ in all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND,
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+ HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ DEALINGS IN THE SOFTWARE.
+
+ ----------------------------------------------------------------------- */
+
+#ifndef LIBFFI_TARGET_H
+#define LIBFFI_TARGET_H
+
+#ifndef LIBFFI_H
+#error "Please do not include ffitarget.h directly into your source. Use ffi.h instead."
+#endif
+
+/* ---- System specific configurations ----------------------------------- */
+
+#ifndef LIBFFI_ASM
+typedef unsigned long ffi_arg;
+typedef signed long ffi_sarg;
+
+typedef enum ffi_abi {
+ FFI_FIRST_ABI = 0,
+ FFI_EABI,
+ FFI_LAST_ABI,
+ FFI_DEFAULT_ABI = FFI_EABI
+} ffi_abi;
+#endif
+
+/* ---- Definitions for closures ----------------------------------------- */
+
+#define FFI_CLOSURES 1
+#define FFI_NATIVE_RAW_API 0
+
+#ifdef __FRV_FDPIC__
+/* Trampolines are 8 4-byte instructions long. */
+#define FFI_TRAMPOLINE_SIZE (8*4)
+#else
+/* Trampolines are 5 4-byte instructions long. */
+#define FFI_TRAMPOLINE_SIZE (5*4)
+#endif
+
+#endif
diff --git a/jni/ruby/ext/fiddle/libffi-3.2.1/src/ia64/ffi.c b/jni/ruby/ext/fiddle/libffi-3.2.1/src/ia64/ffi.c
new file mode 100644
index 0000000..b77a836
--- /dev/null
+++ b/jni/ruby/ext/fiddle/libffi-3.2.1/src/ia64/ffi.c
@@ -0,0 +1,586 @@
+/* -----------------------------------------------------------------------
+ ffi.c - Copyright (c) 1998, 2007, 2008, 2012 Red Hat, Inc.
+ Copyright (c) 2000 Hewlett Packard Company
+ Copyright (c) 2011 Anthony Green
+
+ IA64 Foreign Function Interface
+
+ Permission is hereby granted, free of charge, to any person obtaining
+ a copy of this software and associated documentation files (the
+ ``Software''), to deal in the Software without restriction, including
+ without limitation the rights to use, copy, modify, merge, publish,
+ distribute, sublicense, and/or sell copies of the Software, and to
+ permit persons to whom the Software is furnished to do so, subject to
+ the following conditions:
+
+ The above copyright notice and this permission notice shall be included
+ in all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND,
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+ HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ DEALINGS IN THE SOFTWARE.
+ ----------------------------------------------------------------------- */
+
+#include <ffi.h>
+#include <ffi_common.h>
+
+#include <stdlib.h>
+#include <stdbool.h>
+#include <float.h>
+
+#include "ia64_flags.h"
+
+/* A 64-bit pointer value. In LP64 mode, this is effectively a plain
+ pointer. In ILP32 mode, it's a pointer that's been extended to
+ 64 bits by "addp4". */
+typedef void *PTR64 __attribute__((mode(DI)));
+
+/* Memory image of fp register contents. This is the implementation
+ specific format used by ldf.fill/stf.spill. All we care about is
+ that it wants a 16 byte aligned slot. */
+typedef struct
+{
+ UINT64 x[2] __attribute__((aligned(16)));
+} fpreg;
+
+
+/* The stack layout given to ffi_call_unix and ffi_closure_unix_inner. */
+
+struct ia64_args
+{
+ fpreg fp_regs[8]; /* Contents of 8 fp arg registers. */
+ UINT64 gp_regs[8]; /* Contents of 8 gp arg registers. */
+ UINT64 other_args[]; /* Arguments passed on stack, variable size. */
+};
+
+
+/* Adjust ADDR, a pointer to an 8 byte slot, to point to the low LEN bytes. */
+
+static inline void *
+endian_adjust (void *addr, size_t len)
+{
+#ifdef __BIG_ENDIAN__
+ return addr + (8 - len);
+#else
+ return addr;
+#endif
+}
+
+/* Store VALUE to ADDR in the current cpu implementation's fp spill format.
+ This is a macro instead of a function, so that it works for all 3 floating
+ point types without type conversions. Type conversion to long double breaks
+ the denorm support. */
+
+#define stf_spill(addr, value) \
+ asm ("stf.spill %0 = %1%P0" : "=m" (*addr) : "f"(value));
+
+/* Load a value from ADDR, which is in the current cpu implementation's
+ fp spill format. As above, this must also be a macro. */
+
+#define ldf_fill(result, addr) \
+ asm ("ldf.fill %0 = %1%P1" : "=f"(result) : "m"(*addr));
+
+/* Return the size of the C type associated with with TYPE. Which will
+ be one of the FFI_IA64_TYPE_HFA_* values. */
+
+static size_t
+hfa_type_size (int type)
+{
+ switch (type)
+ {
+ case FFI_IA64_TYPE_HFA_FLOAT:
+ return sizeof(float);
+ case FFI_IA64_TYPE_HFA_DOUBLE:
+ return sizeof(double);
+ case FFI_IA64_TYPE_HFA_LDOUBLE:
+ return sizeof(__float80);
+ default:
+ abort ();
+ }
+}
+
+/* Load from ADDR a value indicated by TYPE. Which will be one of
+ the FFI_IA64_TYPE_HFA_* values. */
+
+static void
+hfa_type_load (fpreg *fpaddr, int type, void *addr)
+{
+ switch (type)
+ {
+ case FFI_IA64_TYPE_HFA_FLOAT:
+ stf_spill (fpaddr, *(float *) addr);
+ return;
+ case FFI_IA64_TYPE_HFA_DOUBLE:
+ stf_spill (fpaddr, *(double *) addr);
+ return;
+ case FFI_IA64_TYPE_HFA_LDOUBLE:
+ stf_spill (fpaddr, *(__float80 *) addr);
+ return;
+ default:
+ abort ();
+ }
+}
+
+/* Load VALUE into ADDR as indicated by TYPE. Which will be one of
+ the FFI_IA64_TYPE_HFA_* values. */
+
+static void
+hfa_type_store (int type, void *addr, fpreg *fpaddr)
+{
+ switch (type)
+ {
+ case FFI_IA64_TYPE_HFA_FLOAT:
+ {
+ float result;
+ ldf_fill (result, fpaddr);
+ *(float *) addr = result;
+ break;
+ }
+ case FFI_IA64_TYPE_HFA_DOUBLE:
+ {
+ double result;
+ ldf_fill (result, fpaddr);
+ *(double *) addr = result;
+ break;
+ }
+ case FFI_IA64_TYPE_HFA_LDOUBLE:
+ {
+ __float80 result;
+ ldf_fill (result, fpaddr);
+ *(__float80 *) addr = result;
+ break;
+ }
+ default:
+ abort ();
+ }
+}
+
+/* Is TYPE a struct containing floats, doubles, or extended doubles,
+ all of the same fp type? If so, return the element type. Return
+ FFI_TYPE_VOID if not. */
+
+static int
+hfa_element_type (ffi_type *type, int nested)
+{
+ int element = FFI_TYPE_VOID;
+
+ switch (type->type)
+ {
+ case FFI_TYPE_FLOAT:
+ /* We want to return VOID for raw floating-point types, but the
+ synthetic HFA type if we're nested within an aggregate. */
+ if (nested)
+ element = FFI_IA64_TYPE_HFA_FLOAT;
+ break;
+
+ case FFI_TYPE_DOUBLE:
+ /* Similarly. */
+ if (nested)
+ element = FFI_IA64_TYPE_HFA_DOUBLE;
+ break;
+
+ case FFI_TYPE_LONGDOUBLE:
+ /* Similarly, except that that HFA is true for double extended,
+ but not quad precision. Both have sizeof == 16, so tell the
+ difference based on the precision. */
+ if (LDBL_MANT_DIG == 64 && nested)
+ element = FFI_IA64_TYPE_HFA_LDOUBLE;
+ break;
+
+ case FFI_TYPE_STRUCT:
+ {
+ ffi_type **ptr = &type->elements[0];
+
+ for (ptr = &type->elements[0]; *ptr ; ptr++)
+ {
+ int sub_element = hfa_element_type (*ptr, 1);
+ if (sub_element == FFI_TYPE_VOID)
+ return FFI_TYPE_VOID;
+
+ if (element == FFI_TYPE_VOID)
+ element = sub_element;
+ else if (element != sub_element)
+ return FFI_TYPE_VOID;
+ }
+ }
+ break;
+
+ default:
+ return FFI_TYPE_VOID;
+ }
+
+ return element;
+}
+
+
+/* Perform machine dependent cif processing. */
+
+ffi_status
+ffi_prep_cif_machdep(ffi_cif *cif)
+{
+ int flags;
+
+ /* Adjust cif->bytes to include space for the bits of the ia64_args frame
+ that precedes the integer register portion. The estimate that the
+ generic bits did for the argument space required is good enough for the
+ integer component. */
+ cif->bytes += offsetof(struct ia64_args, gp_regs[0]);
+ if (cif->bytes < sizeof(struct ia64_args))
+ cif->bytes = sizeof(struct ia64_args);
+
+ /* Set the return type flag. */
+ flags = cif->rtype->type;
+ switch (cif->rtype->type)
+ {
+ case FFI_TYPE_LONGDOUBLE:
+ /* Leave FFI_TYPE_LONGDOUBLE as meaning double extended precision,
+ and encode quad precision as a two-word integer structure. */
+ if (LDBL_MANT_DIG != 64)
+ flags = FFI_IA64_TYPE_SMALL_STRUCT | (16 << 8);
+ break;
+
+ case FFI_TYPE_STRUCT:
+ {
+ size_t size = cif->rtype->size;
+ int hfa_type = hfa_element_type (cif->rtype, 0);
+
+ if (hfa_type != FFI_TYPE_VOID)
+ {
+ size_t nelts = size / hfa_type_size (hfa_type);
+ if (nelts <= 8)
+ flags = hfa_type | (size << 8);
+ }
+ else
+ {
+ if (size <= 32)
+ flags = FFI_IA64_TYPE_SMALL_STRUCT | (size << 8);
+ }
+ }
+ break;
+
+ default:
+ break;
+ }
+ cif->flags = flags;
+
+ return FFI_OK;
+}
+
+extern int ffi_call_unix (struct ia64_args *, PTR64, void (*)(void), UINT64);
+
+void
+ffi_call(ffi_cif *cif, void (*fn)(void), void *rvalue, void **avalue)
+{
+ struct ia64_args *stack;
+ long i, avn, gpcount, fpcount;
+ ffi_type **p_arg;
+
+ FFI_ASSERT (cif->abi == FFI_UNIX);
+
+ /* If we have no spot for a return value, make one. */
+ if (rvalue == NULL && cif->rtype->type != FFI_TYPE_VOID)
+ rvalue = alloca (cif->rtype->size);
+
+ /* Allocate the stack frame. */
+ stack = alloca (cif->bytes);
+
+ gpcount = fpcount = 0;
+ avn = cif->nargs;
+ for (i = 0, p_arg = cif->arg_types; i < avn; i++, p_arg++)
+ {
+ switch ((*p_arg)->type)
+ {
+ case FFI_TYPE_SINT8:
+ stack->gp_regs[gpcount++] = *(SINT8 *)avalue[i];
+ break;
+ case FFI_TYPE_UINT8:
+ stack->gp_regs[gpcount++] = *(UINT8 *)avalue[i];
+ break;
+ case FFI_TYPE_SINT16:
+ stack->gp_regs[gpcount++] = *(SINT16 *)avalue[i];
+ break;
+ case FFI_TYPE_UINT16:
+ stack->gp_regs[gpcount++] = *(UINT16 *)avalue[i];
+ break;
+ case FFI_TYPE_SINT32:
+ stack->gp_regs[gpcount++] = *(SINT32 *)avalue[i];
+ break;
+ case FFI_TYPE_UINT32:
+ stack->gp_regs[gpcount++] = *(UINT32 *)avalue[i];
+ break;
+ case FFI_TYPE_SINT64:
+ case FFI_TYPE_UINT64:
+ stack->gp_regs[gpcount++] = *(UINT64 *)avalue[i];
+ break;
+
+ case FFI_TYPE_POINTER:
+ stack->gp_regs[gpcount++] = (UINT64)(PTR64) *(void **)avalue[i];
+ break;
+
+ case FFI_TYPE_FLOAT:
+ if (gpcount < 8 && fpcount < 8)
+ stf_spill (&stack->fp_regs[fpcount++], *(float *)avalue[i]);
+ {
+ UINT32 tmp;
+ memcpy (&tmp, avalue[i], sizeof (UINT32));
+ stack->gp_regs[gpcount++] = tmp;
+ }
+ break;
+
+ case FFI_TYPE_DOUBLE:
+ if (gpcount < 8 && fpcount < 8)
+ stf_spill (&stack->fp_regs[fpcount++], *(double *)avalue[i]);
+ memcpy (&stack->gp_regs[gpcount++], avalue[i], sizeof (UINT64));
+ break;
+
+ case FFI_TYPE_LONGDOUBLE:
+ if (gpcount & 1)
+ gpcount++;
+ if (LDBL_MANT_DIG == 64 && gpcount < 8 && fpcount < 8)
+ stf_spill (&stack->fp_regs[fpcount++], *(__float80 *)avalue[i]);
+ memcpy (&stack->gp_regs[gpcount], avalue[i], 16);
+ gpcount += 2;
+ break;
+
+ case FFI_TYPE_STRUCT:
+ {
+ size_t size = (*p_arg)->size;
+ size_t align = (*p_arg)->alignment;
+ int hfa_type = hfa_element_type (*p_arg, 0);
+
+ FFI_ASSERT (align <= 16);
+ if (align == 16 && (gpcount & 1))
+ gpcount++;
+
+ if (hfa_type != FFI_TYPE_VOID)
+ {
+ size_t hfa_size = hfa_type_size (hfa_type);
+ size_t offset = 0;
+ size_t gp_offset = gpcount * 8;
+
+ while (fpcount < 8
+ && offset < size
+ && gp_offset < 8 * 8)
+ {
+ hfa_type_load (&stack->fp_regs[fpcount], hfa_type,
+ avalue[i] + offset);
+ offset += hfa_size;
+ gp_offset += hfa_size;
+ fpcount += 1;
+ }
+ }
+
+ memcpy (&stack->gp_regs[gpcount], avalue[i], size);
+ gpcount += (size + 7) / 8;
+ }
+ break;
+
+ default:
+ abort ();
+ }
+ }
+
+ ffi_call_unix (stack, rvalue, fn, cif->flags);
+}
+
+/* Closures represent a pair consisting of a function pointer, and
+ some user data. A closure is invoked by reinterpreting the closure
+ as a function pointer, and branching to it. Thus we can make an
+ interpreted function callable as a C function: We turn the
+ interpreter itself, together with a pointer specifying the
+ interpreted procedure, into a closure.
+
+ For IA64, function pointer are already pairs consisting of a code
+ pointer, and a gp pointer. The latter is needed to access global
+ variables. Here we set up such a pair as the first two words of
+ the closure (in the "trampoline" area), but we replace the gp
+ pointer with a pointer to the closure itself. We also add the real
+ gp pointer to the closure. This allows the function entry code to
+ both retrieve the user data, and to restore the correct gp pointer. */
+
+extern void ffi_closure_unix ();
+
+ffi_status
+ffi_prep_closure_loc (ffi_closure* closure,
+ ffi_cif* cif,
+ void (*fun)(ffi_cif*,void*,void**,void*),
+ void *user_data,
+ void *codeloc)
+{
+ /* The layout of a function descriptor. A C function pointer really
+ points to one of these. */
+ struct ia64_fd
+ {
+ UINT64 code_pointer;
+ UINT64 gp;
+ };
+
+ struct ffi_ia64_trampoline_struct
+ {
+ UINT64 code_pointer; /* Pointer to ffi_closure_unix. */
+ UINT64 fake_gp; /* Pointer to closure, installed as gp. */
+ UINT64 real_gp; /* Real gp value. */
+ };
+
+ struct ffi_ia64_trampoline_struct *tramp;
+ struct ia64_fd *fd;
+
+ if (cif->abi != FFI_UNIX)
+ return FFI_BAD_ABI;
+
+ tramp = (struct ffi_ia64_trampoline_struct *)closure->tramp;
+ fd = (struct ia64_fd *)(void *)ffi_closure_unix;
+
+ tramp->code_pointer = fd->code_pointer;
+ tramp->real_gp = fd->gp;
+ tramp->fake_gp = (UINT64)(PTR64)codeloc;
+ closure->cif = cif;
+ closure->user_data = user_data;
+ closure->fun = fun;
+
+ return FFI_OK;
+}
+
+
+UINT64
+ffi_closure_unix_inner (ffi_closure *closure, struct ia64_args *stack,
+ void *rvalue, void *r8)
+{
+ ffi_cif *cif;
+ void **avalue;
+ ffi_type **p_arg;
+ long i, avn, gpcount, fpcount;
+
+ cif = closure->cif;
+ avn = cif->nargs;
+ avalue = alloca (avn * sizeof (void *));
+
+ /* If the structure return value is passed in memory get that location
+ from r8 so as to pass the value directly back to the caller. */
+ if (cif->flags == FFI_TYPE_STRUCT)
+ rvalue = r8;
+
+ gpcount = fpcount = 0;
+ for (i = 0, p_arg = cif->arg_types; i < avn; i++, p_arg++)
+ {
+ switch ((*p_arg)->type)
+ {
+ case FFI_TYPE_SINT8:
+ case FFI_TYPE_UINT8:
+ avalue[i] = endian_adjust(&stack->gp_regs[gpcount++], 1);
+ break;
+ case FFI_TYPE_SINT16:
+ case FFI_TYPE_UINT16:
+ avalue[i] = endian_adjust(&stack->gp_regs[gpcount++], 2);
+ break;
+ case FFI_TYPE_SINT32:
+ case FFI_TYPE_UINT32:
+ avalue[i] = endian_adjust(&stack->gp_regs[gpcount++], 4);
+ break;
+ case FFI_TYPE_SINT64:
+ case FFI_TYPE_UINT64:
+ avalue[i] = &stack->gp_regs[gpcount++];
+ break;
+ case FFI_TYPE_POINTER:
+ avalue[i] = endian_adjust(&stack->gp_regs[gpcount++], sizeof(void*));
+ break;
+
+ case FFI_TYPE_FLOAT:
+ if (gpcount < 8 && fpcount < 8)
+ {
+ fpreg *addr = &stack->fp_regs[fpcount++];
+ float result;
+ avalue[i] = addr;
+ ldf_fill (result, addr);
+ *(float *)addr = result;
+ }
+ else
+ avalue[i] = endian_adjust(&stack->gp_regs[gpcount], 4);
+ gpcount++;
+ break;
+
+ case FFI_TYPE_DOUBLE:
+ if (gpcount < 8 && fpcount < 8)
+ {
+ fpreg *addr = &stack->fp_regs[fpcount++];
+ double result;
+ avalue[i] = addr;
+ ldf_fill (result, addr);
+ *(double *)addr = result;
+ }
+ else
+ avalue[i] = &stack->gp_regs[gpcount];
+ gpcount++;
+ break;
+
+ case FFI_TYPE_LONGDOUBLE:
+ if (gpcount & 1)
+ gpcount++;
+ if (LDBL_MANT_DIG == 64 && gpcount < 8 && fpcount < 8)
+ {
+ fpreg *addr = &stack->fp_regs[fpcount++];
+ __float80 result;
+ avalue[i] = addr;
+ ldf_fill (result, addr);
+ *(__float80 *)addr = result;
+ }
+ else
+ avalue[i] = &stack->gp_regs[gpcount];
+ gpcount += 2;
+ break;
+
+ case FFI_TYPE_STRUCT:
+ {
+ size_t size = (*p_arg)->size;
+ size_t align = (*p_arg)->alignment;
+ int hfa_type = hfa_element_type (*p_arg, 0);
+
+ FFI_ASSERT (align <= 16);
+ if (align == 16 && (gpcount & 1))
+ gpcount++;
+
+ if (hfa_type != FFI_TYPE_VOID)
+ {
+ size_t hfa_size = hfa_type_size (hfa_type);
+ size_t offset = 0;
+ size_t gp_offset = gpcount * 8;
+ void *addr = alloca (size);
+
+ avalue[i] = addr;
+
+ while (fpcount < 8
+ && offset < size
+ && gp_offset < 8 * 8)
+ {
+ hfa_type_store (hfa_type, addr + offset,
+ &stack->fp_regs[fpcount]);
+ offset += hfa_size;
+ gp_offset += hfa_size;
+ fpcount += 1;
+ }
+
+ if (offset < size)
+ memcpy (addr + offset, (char *)stack->gp_regs + gp_offset,
+ size - offset);
+ }
+ else
+ avalue[i] = &stack->gp_regs[gpcount];
+
+ gpcount += (size + 7) / 8;
+ }
+ break;
+
+ default:
+ abort ();
+ }
+ }
+
+ closure->fun (cif, rvalue, avalue, closure->user_data);
+
+ return cif->flags;
+}
diff --git a/jni/ruby/ext/fiddle/libffi-3.2.1/src/ia64/ffitarget.h b/jni/ruby/ext/fiddle/libffi-3.2.1/src/ia64/ffitarget.h
new file mode 100644
index 0000000..e68cea6
--- /dev/null
+++ b/jni/ruby/ext/fiddle/libffi-3.2.1/src/ia64/ffitarget.h
@@ -0,0 +1,55 @@
+/* -----------------------------------------------------------------*-C-*-
+ ffitarget.h - Copyright (c) 2012 Anthony Green
+ Copyright (c) 1996-2003 Red Hat, Inc.
+ Target configuration macros for IA-64.
+
+ Permission is hereby granted, free of charge, to any person obtaining
+ a copy of this software and associated documentation files (the
+ ``Software''), to deal in the Software without restriction, including
+ without limitation the rights to use, copy, modify, merge, publish,
+ distribute, sublicense, and/or sell copies of the Software, and to
+ permit persons to whom the Software is furnished to do so, subject to
+ the following conditions:
+
+ The above copyright notice and this permission notice shall be included
+ in all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND,
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+ HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ DEALINGS IN THE SOFTWARE.
+
+ ----------------------------------------------------------------------- */
+
+#ifndef LIBFFI_TARGET_H
+#define LIBFFI_TARGET_H
+
+#ifndef LIBFFI_H
+#error "Please do not include ffitarget.h directly into your source. Use ffi.h instead."
+#endif
+
+#ifndef LIBFFI_ASM
+typedef unsigned long long ffi_arg;
+typedef signed long long ffi_sarg;
+
+typedef enum ffi_abi {
+ FFI_FIRST_ABI = 0,
+ FFI_UNIX, /* Linux and all Unix variants use the same conventions */
+ FFI_LAST_ABI,
+ FFI_DEFAULT_ABI = FFI_UNIX
+} ffi_abi;
+#endif
+
+/* ---- Definitions for closures ----------------------------------------- */
+
+#define FFI_CLOSURES 1
+#define FFI_TRAMPOLINE_SIZE 24 /* Really the following struct, which */
+ /* can be interpreted as a C function */
+ /* descriptor: */
+
+#endif
+
diff --git a/jni/ruby/ext/fiddle/libffi-3.2.1/src/ia64/ia64_flags.h b/jni/ruby/ext/fiddle/libffi-3.2.1/src/ia64/ia64_flags.h
new file mode 100644
index 0000000..9d652ce
--- /dev/null
+++ b/jni/ruby/ext/fiddle/libffi-3.2.1/src/ia64/ia64_flags.h
@@ -0,0 +1,40 @@
+/* -----------------------------------------------------------------------
+ ia64_flags.h - Copyright (c) 2000 Hewlett Packard Company
+
+ IA64/unix Foreign Function Interface
+
+ Original author: Hans Boehm, HP Labs
+
+ Permission is hereby granted, free of charge, to any person obtaining
+ a copy of this software and associated documentation files (the
+ ``Software''), to deal in the Software without restriction, including
+ without limitation the rights to use, copy, modify, merge, publish,
+ distribute, sublicense, and/or sell copies of the Software, and to
+ permit persons to whom the Software is furnished to do so, subject to
+ the following conditions:
+
+ The above copyright notice and this permission notice shall be included
+ in all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND,
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+ HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ DEALINGS IN THE SOFTWARE.
+ ----------------------------------------------------------------------- */
+
+/* "Type" codes used between assembly and C. When used as a part of
+ a cfi->flags value, the low byte will be these extra type codes,
+ and bits 8-31 will be the actual size of the type. */
+
+/* Small structures containing N words in integer registers. */
+#define FFI_IA64_TYPE_SMALL_STRUCT (FFI_TYPE_LAST + 1)
+
+/* Homogeneous Floating Point Aggregates (HFAs) which are returned
+ in FP registers. */
+#define FFI_IA64_TYPE_HFA_FLOAT (FFI_TYPE_LAST + 2)
+#define FFI_IA64_TYPE_HFA_DOUBLE (FFI_TYPE_LAST + 3)
+#define FFI_IA64_TYPE_HFA_LDOUBLE (FFI_TYPE_LAST + 4)
diff --git a/jni/ruby/ext/fiddle/libffi-3.2.1/src/ia64/unix.S b/jni/ruby/ext/fiddle/libffi-3.2.1/src/ia64/unix.S
new file mode 100644
index 0000000..4d2a86d
--- /dev/null
+++ b/jni/ruby/ext/fiddle/libffi-3.2.1/src/ia64/unix.S
@@ -0,0 +1,560 @@
+/* -----------------------------------------------------------------------
+ unix.S - Copyright (c) 1998, 2008 Red Hat, Inc.
+ Copyright (c) 2000 Hewlett Packard Company
+
+ IA64/unix Foreign Function Interface
+
+ Primary author: Hans Boehm, HP Labs
+
+ Loosely modeled on Cygnus code for other platforms.
+
+ Permission is hereby granted, free of charge, to any person obtaining
+ a copy of this software and associated documentation files (the
+ ``Software''), to deal in the Software without restriction, including
+ without limitation the rights to use, copy, modify, merge, publish,
+ distribute, sublicense, and/or sell copies of the Software, and to
+ permit persons to whom the Software is furnished to do so, subject to
+ the following conditions:
+
+ The above copyright notice and this permission notice shall be included
+ in all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND,
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+ HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ DEALINGS IN THE SOFTWARE.
+ ----------------------------------------------------------------------- */
+
+#define LIBFFI_ASM
+#include <fficonfig.h>
+#include <ffi.h>
+#include "ia64_flags.h"
+
+ .pred.safe_across_calls p1-p5,p16-p63
+.text
+
+/* int ffi_call_unix (struct ia64_args *stack, PTR64 rvalue,
+ void (*fn)(void), int flags);
+ */
+
+ .align 16
+ .global ffi_call_unix
+ .proc ffi_call_unix
+ffi_call_unix:
+ .prologue
+ /* Bit o trickiness. We actually share a stack frame with ffi_call.
+ Rely on the fact that ffi_call uses a vframe and don't bother
+ tracking one here at all. */
+ .fframe 0
+ .save ar.pfs, r36 // loc0
+ alloc loc0 = ar.pfs, 4, 3, 8, 0
+ .save rp, loc1
+ mov loc1 = b0
+ .body
+ add r16 = 16, in0
+ mov loc2 = gp
+ mov r8 = in1
+ ;;
+
+ /* Load up all of the argument registers. */
+ ldf.fill f8 = [in0], 32
+ ldf.fill f9 = [r16], 32
+ ;;
+ ldf.fill f10 = [in0], 32
+ ldf.fill f11 = [r16], 32
+ ;;
+ ldf.fill f12 = [in0], 32
+ ldf.fill f13 = [r16], 32
+ ;;
+ ldf.fill f14 = [in0], 32
+ ldf.fill f15 = [r16], 24
+ ;;
+ ld8 out0 = [in0], 16
+ ld8 out1 = [r16], 16
+ ;;
+ ld8 out2 = [in0], 16
+ ld8 out3 = [r16], 16
+ ;;
+ ld8 out4 = [in0], 16
+ ld8 out5 = [r16], 16
+ ;;
+ ld8 out6 = [in0]
+ ld8 out7 = [r16]
+ ;;
+
+ /* Deallocate the register save area from the stack frame. */
+ mov sp = in0
+
+ /* Call the target function. */
+ ld8 r16 = [in2], 8
+ ;;
+ ld8 gp = [in2]
+ mov b6 = r16
+ br.call.sptk.many b0 = b6
+ ;;
+
+ /* Dispatch to handle return value. */
+ mov gp = loc2
+ zxt1 r16 = in3
+ ;;
+ mov ar.pfs = loc0
+ addl r18 = @ltoffx(.Lst_table), gp
+ ;;
+ ld8.mov r18 = [r18], .Lst_table
+ mov b0 = loc1
+ ;;
+ shladd r18 = r16, 3, r18
+ ;;
+ ld8 r17 = [r18]
+ shr in3 = in3, 8
+ ;;
+ add r17 = r17, r18
+ ;;
+ mov b6 = r17
+ br b6
+ ;;
+
+.Lst_void:
+ br.ret.sptk.many b0
+ ;;
+.Lst_uint8:
+ zxt1 r8 = r8
+ ;;
+ st8 [in1] = r8
+ br.ret.sptk.many b0
+ ;;
+.Lst_sint8:
+ sxt1 r8 = r8
+ ;;
+ st8 [in1] = r8
+ br.ret.sptk.many b0
+ ;;
+.Lst_uint16:
+ zxt2 r8 = r8
+ ;;
+ st8 [in1] = r8
+ br.ret.sptk.many b0
+ ;;
+.Lst_sint16:
+ sxt2 r8 = r8
+ ;;
+ st8 [in1] = r8
+ br.ret.sptk.many b0
+ ;;
+.Lst_uint32:
+ zxt4 r8 = r8
+ ;;
+ st8 [in1] = r8
+ br.ret.sptk.many b0
+ ;;
+.Lst_sint32:
+ sxt4 r8 = r8
+ ;;
+ st8 [in1] = r8
+ br.ret.sptk.many b0
+ ;;
+.Lst_int64:
+ st8 [in1] = r8
+ br.ret.sptk.many b0
+ ;;
+.Lst_float:
+ stfs [in1] = f8
+ br.ret.sptk.many b0
+ ;;
+.Lst_double:
+ stfd [in1] = f8
+ br.ret.sptk.many b0
+ ;;
+.Lst_ldouble:
+ stfe [in1] = f8
+ br.ret.sptk.many b0
+ ;;
+
+.Lst_small_struct:
+ add sp = -16, sp
+ cmp.lt p6, p0 = 8, in3
+ cmp.lt p7, p0 = 16, in3
+ cmp.lt p8, p0 = 24, in3
+ ;;
+ add r16 = 8, sp
+ add r17 = 16, sp
+ add r18 = 24, sp
+ ;;
+ st8 [sp] = r8
+(p6) st8 [r16] = r9
+ mov out0 = in1
+(p7) st8 [r17] = r10
+(p8) st8 [r18] = r11
+ mov out1 = sp
+ mov out2 = in3
+ br.call.sptk.many b0 = memcpy#
+ ;;
+ mov ar.pfs = loc0
+ mov b0 = loc1
+ mov gp = loc2
+ br.ret.sptk.many b0
+
+.Lst_hfa_float:
+ add r16 = 4, in1
+ cmp.lt p6, p0 = 4, in3
+ ;;
+ stfs [in1] = f8, 8
+(p6) stfs [r16] = f9, 8
+ cmp.lt p7, p0 = 8, in3
+ cmp.lt p8, p0 = 12, in3
+ ;;
+(p7) stfs [in1] = f10, 8
+(p8) stfs [r16] = f11, 8
+ cmp.lt p9, p0 = 16, in3
+ cmp.lt p10, p0 = 20, in3
+ ;;
+(p9) stfs [in1] = f12, 8
+(p10) stfs [r16] = f13, 8
+ cmp.lt p6, p0 = 24, in3
+ cmp.lt p7, p0 = 28, in3
+ ;;
+(p6) stfs [in1] = f14
+(p7) stfs [r16] = f15
+ br.ret.sptk.many b0
+ ;;
+
+.Lst_hfa_double:
+ add r16 = 8, in1
+ cmp.lt p6, p0 = 8, in3
+ ;;
+ stfd [in1] = f8, 16
+(p6) stfd [r16] = f9, 16
+ cmp.lt p7, p0 = 16, in3
+ cmp.lt p8, p0 = 24, in3
+ ;;
+(p7) stfd [in1] = f10, 16
+(p8) stfd [r16] = f11, 16
+ cmp.lt p9, p0 = 32, in3
+ cmp.lt p10, p0 = 40, in3
+ ;;
+(p9) stfd [in1] = f12, 16
+(p10) stfd [r16] = f13, 16
+ cmp.lt p6, p0 = 48, in3
+ cmp.lt p7, p0 = 56, in3
+ ;;
+(p6) stfd [in1] = f14
+(p7) stfd [r16] = f15
+ br.ret.sptk.many b0
+ ;;
+
+.Lst_hfa_ldouble:
+ add r16 = 16, in1
+ cmp.lt p6, p0 = 16, in3
+ ;;
+ stfe [in1] = f8, 32
+(p6) stfe [r16] = f9, 32
+ cmp.lt p7, p0 = 32, in3
+ cmp.lt p8, p0 = 48, in3
+ ;;
+(p7) stfe [in1] = f10, 32
+(p8) stfe [r16] = f11, 32
+ cmp.lt p9, p0 = 64, in3
+ cmp.lt p10, p0 = 80, in3
+ ;;
+(p9) stfe [in1] = f12, 32
+(p10) stfe [r16] = f13, 32
+ cmp.lt p6, p0 = 96, in3
+ cmp.lt p7, p0 = 112, in3
+ ;;
+(p6) stfe [in1] = f14
+(p7) stfe [r16] = f15
+ br.ret.sptk.many b0
+ ;;
+
+ .endp ffi_call_unix
+
+ .align 16
+ .global ffi_closure_unix
+ .proc ffi_closure_unix
+
+#define FRAME_SIZE (8*16 + 8*8 + 8*16)
+
+ffi_closure_unix:
+ .prologue
+ .save ar.pfs, r40 // loc0
+ alloc loc0 = ar.pfs, 8, 4, 4, 0
+ .fframe FRAME_SIZE
+ add r12 = -FRAME_SIZE, r12
+ .save rp, loc1
+ mov loc1 = b0
+ .save ar.unat, loc2
+ mov loc2 = ar.unat
+ .body
+
+ /* Retrieve closure pointer and real gp. */
+#ifdef _ILP32
+ addp4 out0 = 0, gp
+ addp4 gp = 16, gp
+#else
+ mov out0 = gp
+ add gp = 16, gp
+#endif
+ ;;
+ ld8 gp = [gp]
+
+ /* Spill all of the possible argument registers. */
+ add r16 = 16 + 8*16, sp
+ add r17 = 16 + 8*16 + 16, sp
+ ;;
+ stf.spill [r16] = f8, 32
+ stf.spill [r17] = f9, 32
+ mov loc3 = gp
+ ;;
+ stf.spill [r16] = f10, 32
+ stf.spill [r17] = f11, 32
+ ;;
+ stf.spill [r16] = f12, 32
+ stf.spill [r17] = f13, 32
+ ;;
+ stf.spill [r16] = f14, 32
+ stf.spill [r17] = f15, 24
+ ;;
+ .mem.offset 0, 0
+ st8.spill [r16] = in0, 16
+ .mem.offset 8, 0
+ st8.spill [r17] = in1, 16
+ add out1 = 16 + 8*16, sp
+ ;;
+ .mem.offset 0, 0
+ st8.spill [r16] = in2, 16
+ .mem.offset 8, 0
+ st8.spill [r17] = in3, 16
+ add out2 = 16, sp
+ ;;
+ .mem.offset 0, 0
+ st8.spill [r16] = in4, 16
+ .mem.offset 8, 0
+ st8.spill [r17] = in5, 16
+ mov out3 = r8
+ ;;
+ .mem.offset 0, 0
+ st8.spill [r16] = in6
+ .mem.offset 8, 0
+ st8.spill [r17] = in7
+
+ /* Invoke ffi_closure_unix_inner for the hard work. */
+ br.call.sptk.many b0 = ffi_closure_unix_inner
+ ;;
+
+ /* Dispatch to handle return value. */
+ mov gp = loc3
+ zxt1 r16 = r8
+ ;;
+ addl r18 = @ltoffx(.Lld_table), gp
+ mov ar.pfs = loc0
+ ;;
+ ld8.mov r18 = [r18], .Lld_table
+ mov b0 = loc1
+ ;;
+ shladd r18 = r16, 3, r18
+ mov ar.unat = loc2
+ ;;
+ ld8 r17 = [r18]
+ shr r8 = r8, 8
+ ;;
+ add r17 = r17, r18
+ add r16 = 16, sp
+ ;;
+ mov b6 = r17
+ br b6
+ ;;
+ .label_state 1
+
+.Lld_void:
+ .restore sp
+ add sp = FRAME_SIZE, sp
+ br.ret.sptk.many b0
+ ;;
+.Lld_int:
+ .body
+ .copy_state 1
+ ld8 r8 = [r16]
+ .restore sp
+ add sp = FRAME_SIZE, sp
+ br.ret.sptk.many b0
+ ;;
+.Lld_float:
+ .body
+ .copy_state 1
+ ldfs f8 = [r16]
+ .restore sp
+ add sp = FRAME_SIZE, sp
+ br.ret.sptk.many b0
+ ;;
+.Lld_double:
+ .body
+ .copy_state 1
+ ldfd f8 = [r16]
+ .restore sp
+ add sp = FRAME_SIZE, sp
+ br.ret.sptk.many b0
+ ;;
+.Lld_ldouble:
+ .body
+ .copy_state 1
+ ldfe f8 = [r16]
+ .restore sp
+ add sp = FRAME_SIZE, sp
+ br.ret.sptk.many b0
+ ;;
+
+.Lld_small_struct:
+ .body
+ .copy_state 1
+ add r17 = 8, r16
+ cmp.lt p6, p0 = 8, r8
+ cmp.lt p7, p0 = 16, r8
+ cmp.lt p8, p0 = 24, r8
+ ;;
+ ld8 r8 = [r16], 16
+(p6) ld8 r9 = [r17], 16
+ ;;
+(p7) ld8 r10 = [r16]
+(p8) ld8 r11 = [r17]
+ .restore sp
+ add sp = FRAME_SIZE, sp
+ br.ret.sptk.many b0
+ ;;
+
+.Lld_hfa_float:
+ .body
+ .copy_state 1
+ add r17 = 4, r16
+ cmp.lt p6, p0 = 4, r8
+ ;;
+ ldfs f8 = [r16], 8
+(p6) ldfs f9 = [r17], 8
+ cmp.lt p7, p0 = 8, r8
+ cmp.lt p8, p0 = 12, r8
+ ;;
+(p7) ldfs f10 = [r16], 8
+(p8) ldfs f11 = [r17], 8
+ cmp.lt p9, p0 = 16, r8
+ cmp.lt p10, p0 = 20, r8
+ ;;
+(p9) ldfs f12 = [r16], 8
+(p10) ldfs f13 = [r17], 8
+ cmp.lt p6, p0 = 24, r8
+ cmp.lt p7, p0 = 28, r8
+ ;;
+(p6) ldfs f14 = [r16]
+(p7) ldfs f15 = [r17]
+ .restore sp
+ add sp = FRAME_SIZE, sp
+ br.ret.sptk.many b0
+ ;;
+
+.Lld_hfa_double:
+ .body
+ .copy_state 1
+ add r17 = 8, r16
+ cmp.lt p6, p0 = 8, r8
+ ;;
+ ldfd f8 = [r16], 16
+(p6) ldfd f9 = [r17], 16
+ cmp.lt p7, p0 = 16, r8
+ cmp.lt p8, p0 = 24, r8
+ ;;
+(p7) ldfd f10 = [r16], 16
+(p8) ldfd f11 = [r17], 16
+ cmp.lt p9, p0 = 32, r8
+ cmp.lt p10, p0 = 40, r8
+ ;;
+(p9) ldfd f12 = [r16], 16
+(p10) ldfd f13 = [r17], 16
+ cmp.lt p6, p0 = 48, r8
+ cmp.lt p7, p0 = 56, r8
+ ;;
+(p6) ldfd f14 = [r16]
+(p7) ldfd f15 = [r17]
+ .restore sp
+ add sp = FRAME_SIZE, sp
+ br.ret.sptk.many b0
+ ;;
+
+.Lld_hfa_ldouble:
+ .body
+ .copy_state 1
+ add r17 = 16, r16
+ cmp.lt p6, p0 = 16, r8
+ ;;
+ ldfe f8 = [r16], 32
+(p6) ldfe f9 = [r17], 32
+ cmp.lt p7, p0 = 32, r8
+ cmp.lt p8, p0 = 48, r8
+ ;;
+(p7) ldfe f10 = [r16], 32
+(p8) ldfe f11 = [r17], 32
+ cmp.lt p9, p0 = 64, r8
+ cmp.lt p10, p0 = 80, r8
+ ;;
+(p9) ldfe f12 = [r16], 32
+(p10) ldfe f13 = [r17], 32
+ cmp.lt p6, p0 = 96, r8
+ cmp.lt p7, p0 = 112, r8
+ ;;
+(p6) ldfe f14 = [r16]
+(p7) ldfe f15 = [r17]
+ .restore sp
+ add sp = FRAME_SIZE, sp
+ br.ret.sptk.many b0
+ ;;
+
+ .endp ffi_closure_unix
+
+ .section .rodata
+ .align 8
+.Lst_table:
+ data8 @pcrel(.Lst_void) // FFI_TYPE_VOID
+ data8 @pcrel(.Lst_sint32) // FFI_TYPE_INT
+ data8 @pcrel(.Lst_float) // FFI_TYPE_FLOAT
+ data8 @pcrel(.Lst_double) // FFI_TYPE_DOUBLE
+ data8 @pcrel(.Lst_ldouble) // FFI_TYPE_LONGDOUBLE
+ data8 @pcrel(.Lst_uint8) // FFI_TYPE_UINT8
+ data8 @pcrel(.Lst_sint8) // FFI_TYPE_SINT8
+ data8 @pcrel(.Lst_uint16) // FFI_TYPE_UINT16
+ data8 @pcrel(.Lst_sint16) // FFI_TYPE_SINT16
+ data8 @pcrel(.Lst_uint32) // FFI_TYPE_UINT32
+ data8 @pcrel(.Lst_sint32) // FFI_TYPE_SINT32
+ data8 @pcrel(.Lst_int64) // FFI_TYPE_UINT64
+ data8 @pcrel(.Lst_int64) // FFI_TYPE_SINT64
+ data8 @pcrel(.Lst_void) // FFI_TYPE_STRUCT
+ data8 @pcrel(.Lst_int64) // FFI_TYPE_POINTER
+ data8 @pcrel(.Lst_small_struct) // FFI_IA64_TYPE_SMALL_STRUCT
+ data8 @pcrel(.Lst_hfa_float) // FFI_IA64_TYPE_HFA_FLOAT
+ data8 @pcrel(.Lst_hfa_double) // FFI_IA64_TYPE_HFA_DOUBLE
+ data8 @pcrel(.Lst_hfa_ldouble) // FFI_IA64_TYPE_HFA_LDOUBLE
+
+.Lld_table:
+ data8 @pcrel(.Lld_void) // FFI_TYPE_VOID
+ data8 @pcrel(.Lld_int) // FFI_TYPE_INT
+ data8 @pcrel(.Lld_float) // FFI_TYPE_FLOAT
+ data8 @pcrel(.Lld_double) // FFI_TYPE_DOUBLE
+ data8 @pcrel(.Lld_ldouble) // FFI_TYPE_LONGDOUBLE
+ data8 @pcrel(.Lld_int) // FFI_TYPE_UINT8
+ data8 @pcrel(.Lld_int) // FFI_TYPE_SINT8
+ data8 @pcrel(.Lld_int) // FFI_TYPE_UINT16
+ data8 @pcrel(.Lld_int) // FFI_TYPE_SINT16
+ data8 @pcrel(.Lld_int) // FFI_TYPE_UINT32
+ data8 @pcrel(.Lld_int) // FFI_TYPE_SINT32
+ data8 @pcrel(.Lld_int) // FFI_TYPE_UINT64
+ data8 @pcrel(.Lld_int) // FFI_TYPE_SINT64
+ data8 @pcrel(.Lld_void) // FFI_TYPE_STRUCT
+ data8 @pcrel(.Lld_int) // FFI_TYPE_POINTER
+ data8 @pcrel(.Lld_small_struct) // FFI_IA64_TYPE_SMALL_STRUCT
+ data8 @pcrel(.Lld_hfa_float) // FFI_IA64_TYPE_HFA_FLOAT
+ data8 @pcrel(.Lld_hfa_double) // FFI_IA64_TYPE_HFA_DOUBLE
+ data8 @pcrel(.Lld_hfa_ldouble) // FFI_IA64_TYPE_HFA_LDOUBLE
+
+#if defined __ELF__ && defined __linux__
+ .section .note.GNU-stack,"",@progbits
+#endif
diff --git a/jni/ruby/ext/fiddle/libffi-3.2.1/src/java_raw_api.c b/jni/ruby/ext/fiddle/libffi-3.2.1/src/java_raw_api.c
new file mode 100644
index 0000000..127123d
--- /dev/null
+++ b/jni/ruby/ext/fiddle/libffi-3.2.1/src/java_raw_api.c
@@ -0,0 +1,374 @@
+/* -----------------------------------------------------------------------
+ java_raw_api.c - Copyright (c) 1999, 2007, 2008 Red Hat, Inc.
+
+ Cloned from raw_api.c
+
+ Raw_api.c author: Kresten Krab Thorup <krab@gnu.org>
+ Java_raw_api.c author: Hans-J. Boehm <hboehm@hpl.hp.com>
+
+ $Id $
+
+ Permission is hereby granted, free of charge, to any person obtaining
+ a copy of this software and associated documentation files (the
+ ``Software''), to deal in the Software without restriction, including
+ without limitation the rights to use, copy, modify, merge, publish,
+ distribute, sublicense, and/or sell copies of the Software, and to
+ permit persons to whom the Software is furnished to do so, subject to
+ the following conditions:
+
+ The above copyright notice and this permission notice shall be included
+ in all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND,
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+ HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ DEALINGS IN THE SOFTWARE.
+ ----------------------------------------------------------------------- */
+
+/* This defines a Java- and 64-bit specific variant of the raw API. */
+/* It assumes that "raw" argument blocks look like Java stacks on a */
+/* 64-bit machine. Arguments that can be stored in a single stack */
+/* stack slots (longs, doubles) occupy 128 bits, but only the first */
+/* 64 bits are actually used. */
+
+#include <ffi.h>
+#include <ffi_common.h>
+#include <stdlib.h>
+
+#if !defined(NO_JAVA_RAW_API)
+
+size_t
+ffi_java_raw_size (ffi_cif *cif)
+{
+ size_t result = 0;
+ int i;
+
+ ffi_type **at = cif->arg_types;
+
+ for (i = cif->nargs-1; i >= 0; i--, at++)
+ {
+ switch((*at) -> type) {
+ case FFI_TYPE_UINT64:
+ case FFI_TYPE_SINT64:
+ case FFI_TYPE_DOUBLE:
+ result += 2 * FFI_SIZEOF_JAVA_RAW;
+ break;
+ case FFI_TYPE_STRUCT:
+ /* No structure parameters in Java. */
+ abort();
+ case FFI_TYPE_COMPLEX:
+ /* Not supported yet. */
+ abort();
+ default:
+ result += FFI_SIZEOF_JAVA_RAW;
+ }
+ }
+
+ return result;
+}
+
+
+void
+ffi_java_raw_to_ptrarray (ffi_cif *cif, ffi_java_raw *raw, void **args)
+{
+ unsigned i;
+ ffi_type **tp = cif->arg_types;
+
+#if WORDS_BIGENDIAN
+
+ for (i = 0; i < cif->nargs; i++, tp++, args++)
+ {
+ switch ((*tp)->type)
+ {
+ case FFI_TYPE_UINT8:
+ case FFI_TYPE_SINT8:
+ *args = (void*) ((char*)(raw++) + 3);
+ break;
+
+ case FFI_TYPE_UINT16:
+ case FFI_TYPE_SINT16:
+ *args = (void*) ((char*)(raw++) + 2);
+ break;
+
+#if FFI_SIZEOF_JAVA_RAW == 8
+ case FFI_TYPE_UINT64:
+ case FFI_TYPE_SINT64:
+ case FFI_TYPE_DOUBLE:
+ *args = (void *)raw;
+ raw += 2;
+ break;
+#endif
+
+ case FFI_TYPE_POINTER:
+ *args = (void*) &(raw++)->ptr;
+ break;
+
+ case FFI_TYPE_COMPLEX:
+ /* Not supported yet. */
+ abort();
+
+ default:
+ *args = raw;
+ raw +=
+ ALIGN ((*tp)->size, sizeof(ffi_java_raw)) / sizeof(ffi_java_raw);
+ }
+ }
+
+#else /* WORDS_BIGENDIAN */
+
+#if !PDP
+
+ /* then assume little endian */
+ for (i = 0; i < cif->nargs; i++, tp++, args++)
+ {
+#if FFI_SIZEOF_JAVA_RAW == 8
+ switch((*tp)->type) {
+ case FFI_TYPE_UINT64:
+ case FFI_TYPE_SINT64:
+ case FFI_TYPE_DOUBLE:
+ *args = (void*) raw;
+ raw += 2;
+ break;
+ case FFI_TYPE_COMPLEX:
+ /* Not supported yet. */
+ abort();
+ default:
+ *args = (void*) raw++;
+ }
+#else /* FFI_SIZEOF_JAVA_RAW != 8 */
+ *args = (void*) raw;
+ raw +=
+ ALIGN ((*tp)->size, sizeof(ffi_java_raw)) / sizeof(ffi_java_raw);
+#endif /* FFI_SIZEOF_JAVA_RAW == 8 */
+ }
+
+#else
+#error "pdp endian not supported"
+#endif /* ! PDP */
+
+#endif /* WORDS_BIGENDIAN */
+}
+
+void
+ffi_java_ptrarray_to_raw (ffi_cif *cif, void **args, ffi_java_raw *raw)
+{
+ unsigned i;
+ ffi_type **tp = cif->arg_types;
+
+ for (i = 0; i < cif->nargs; i++, tp++, args++)
+ {
+ switch ((*tp)->type)
+ {
+ case FFI_TYPE_UINT8:
+#if WORDS_BIGENDIAN
+ *(UINT32*)(raw++) = *(UINT8*) (*args);
+#else
+ (raw++)->uint = *(UINT8*) (*args);
+#endif
+ break;
+
+ case FFI_TYPE_SINT8:
+#if WORDS_BIGENDIAN
+ *(SINT32*)(raw++) = *(SINT8*) (*args);
+#else
+ (raw++)->sint = *(SINT8*) (*args);
+#endif
+ break;
+
+ case FFI_TYPE_UINT16:
+#if WORDS_BIGENDIAN
+ *(UINT32*)(raw++) = *(UINT16*) (*args);
+#else
+ (raw++)->uint = *(UINT16*) (*args);
+#endif
+ break;
+
+ case FFI_TYPE_SINT16:
+#if WORDS_BIGENDIAN
+ *(SINT32*)(raw++) = *(SINT16*) (*args);
+#else
+ (raw++)->sint = *(SINT16*) (*args);
+#endif
+ break;
+
+ case FFI_TYPE_UINT32:
+#if WORDS_BIGENDIAN
+ *(UINT32*)(raw++) = *(UINT32*) (*args);
+#else
+ (raw++)->uint = *(UINT32*) (*args);
+#endif
+ break;
+
+ case FFI_TYPE_SINT32:
+#if WORDS_BIGENDIAN
+ *(SINT32*)(raw++) = *(SINT32*) (*args);
+#else
+ (raw++)->sint = *(SINT32*) (*args);
+#endif
+ break;
+
+ case FFI_TYPE_FLOAT:
+ (raw++)->flt = *(FLOAT32*) (*args);
+ break;
+
+#if FFI_SIZEOF_JAVA_RAW == 8
+ case FFI_TYPE_UINT64:
+ case FFI_TYPE_SINT64:
+ case FFI_TYPE_DOUBLE:
+ raw->uint = *(UINT64*) (*args);
+ raw += 2;
+ break;
+#endif
+
+ case FFI_TYPE_POINTER:
+ (raw++)->ptr = **(void***) args;
+ break;
+
+ default:
+#if FFI_SIZEOF_JAVA_RAW == 8
+ FFI_ASSERT(0); /* Should have covered all cases */
+#else
+ memcpy ((void*) raw->data, (void*)*args, (*tp)->size);
+ raw +=
+ ALIGN ((*tp)->size, sizeof(ffi_java_raw)) / sizeof(ffi_java_raw);
+#endif
+ }
+ }
+}
+
+#if !FFI_NATIVE_RAW_API
+
+static void
+ffi_java_rvalue_to_raw (ffi_cif *cif, void *rvalue)
+{
+#if WORDS_BIGENDIAN && FFI_SIZEOF_ARG == 8
+ switch (cif->rtype->type)
+ {
+ case FFI_TYPE_UINT8:
+ case FFI_TYPE_UINT16:
+ case FFI_TYPE_UINT32:
+ *(UINT64 *)rvalue <<= 32;
+ break;
+
+ case FFI_TYPE_SINT8:
+ case FFI_TYPE_SINT16:
+ case FFI_TYPE_SINT32:
+ case FFI_TYPE_INT:
+#if FFI_SIZEOF_JAVA_RAW == 4
+ case FFI_TYPE_POINTER:
+#endif
+ *(SINT64 *)rvalue <<= 32;
+ break;
+
+ case FFI_TYPE_COMPLEX:
+ /* Not supported yet. */
+ abort();
+
+ default:
+ break;
+ }
+#endif
+}
+
+static void
+ffi_java_raw_to_rvalue (ffi_cif *cif, void *rvalue)
+{
+#if WORDS_BIGENDIAN && FFI_SIZEOF_ARG == 8
+ switch (cif->rtype->type)
+ {
+ case FFI_TYPE_UINT8:
+ case FFI_TYPE_UINT16:
+ case FFI_TYPE_UINT32:
+ *(UINT64 *)rvalue >>= 32;
+ break;
+
+ case FFI_TYPE_SINT8:
+ case FFI_TYPE_SINT16:
+ case FFI_TYPE_SINT32:
+ case FFI_TYPE_INT:
+ *(SINT64 *)rvalue >>= 32;
+ break;
+
+ case FFI_TYPE_COMPLEX:
+ /* Not supported yet. */
+ abort();
+
+ default:
+ break;
+ }
+#endif
+}
+
+/* This is a generic definition of ffi_raw_call, to be used if the
+ * native system does not provide a machine-specific implementation.
+ * Having this, allows code to be written for the raw API, without
+ * the need for system-specific code to handle input in that format;
+ * these following couple of functions will handle the translation forth
+ * and back automatically. */
+
+void ffi_java_raw_call (ffi_cif *cif, void (*fn)(void), void *rvalue,
+ ffi_java_raw *raw)
+{
+ void **avalue = (void**) alloca (cif->nargs * sizeof (void*));
+ ffi_java_raw_to_ptrarray (cif, raw, avalue);
+ ffi_call (cif, fn, rvalue, avalue);
+ ffi_java_rvalue_to_raw (cif, rvalue);
+}
+
+#if FFI_CLOSURES /* base system provides closures */
+
+static void
+ffi_java_translate_args (ffi_cif *cif, void *rvalue,
+ void **avalue, void *user_data)
+{
+ ffi_java_raw *raw = (ffi_java_raw*)alloca (ffi_java_raw_size (cif));
+ ffi_raw_closure *cl = (ffi_raw_closure*)user_data;
+
+ ffi_java_ptrarray_to_raw (cif, avalue, raw);
+ (*cl->fun) (cif, rvalue, (ffi_raw*)raw, cl->user_data);
+ ffi_java_raw_to_rvalue (cif, rvalue);
+}
+
+ffi_status
+ffi_prep_java_raw_closure_loc (ffi_java_raw_closure* cl,
+ ffi_cif *cif,
+ void (*fun)(ffi_cif*,void*,ffi_java_raw*,void*),
+ void *user_data,
+ void *codeloc)
+{
+ ffi_status status;
+
+ status = ffi_prep_closure_loc ((ffi_closure*) cl,
+ cif,
+ &ffi_java_translate_args,
+ codeloc,
+ codeloc);
+ if (status == FFI_OK)
+ {
+ cl->fun = fun;
+ cl->user_data = user_data;
+ }
+
+ return status;
+}
+
+/* Again, here is the generic version of ffi_prep_raw_closure, which
+ * will install an intermediate "hub" for translation of arguments from
+ * the pointer-array format, to the raw format */
+
+ffi_status
+ffi_prep_java_raw_closure (ffi_java_raw_closure* cl,
+ ffi_cif *cif,
+ void (*fun)(ffi_cif*,void*,ffi_java_raw*,void*),
+ void *user_data)
+{
+ return ffi_prep_java_raw_closure_loc (cl, cif, fun, user_data, cl);
+}
+
+#endif /* FFI_CLOSURES */
+#endif /* !FFI_NATIVE_RAW_API */
+#endif /* !NO_JAVA_RAW_API */
diff --git a/jni/ruby/ext/fiddle/libffi-3.2.1/src/m32r/ffi.c b/jni/ruby/ext/fiddle/libffi-3.2.1/src/m32r/ffi.c
new file mode 100644
index 0000000..3000063
--- /dev/null
+++ b/jni/ruby/ext/fiddle/libffi-3.2.1/src/m32r/ffi.c
@@ -0,0 +1,232 @@
+/* -----------------------------------------------------------------------
+ ffi.c - Copyright (c) 2004 Renesas Technology
+ Copyright (c) 2008 Red Hat, Inc.
+
+ M32R Foreign Function Interface
+
+ Permission is hereby granted, free of charge, to any person obtaining
+ a copy of this software and associated documentation files (the
+ ``Software''), to deal in the Software without restriction, including
+ without limitation the rights to use, copy, modify, merge, publish,
+ distribute, sublicense, and/or sell copies of the Software, and to
+ permit persons to whom the Software is furnished to do so, subject to
+ the following conditions:
+
+ The above copyright notice and this permission notice shall be included
+ in all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ IN NO EVENT SHALL RENESAS TECHNOLOGY BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ OTHER DEALINGS IN THE SOFTWARE.
+ ----------------------------------------------------------------------- */
+
+#include <ffi.h>
+#include <ffi_common.h>
+
+#include <stdlib.h>
+
+/* ffi_prep_args is called by the assembly routine once stack
+ space has been allocated for the function's arguments. */
+
+void ffi_prep_args(char *stack, extended_cif *ecif)
+{
+ unsigned int i;
+ int tmp;
+ unsigned int avn;
+ void **p_argv;
+ char *argp;
+ ffi_type **p_arg;
+
+ tmp = 0;
+ argp = stack;
+
+ if (ecif->cif->rtype->type == FFI_TYPE_STRUCT && ecif->cif->rtype->size > 8)
+ {
+ *(void **) argp = ecif->rvalue;
+ argp += 4;
+ }
+
+ avn = ecif->cif->nargs;
+ p_argv = ecif->avalue;
+
+ for (i = ecif->cif->nargs, p_arg = ecif->cif->arg_types;
+ (i != 0) && (avn != 0);
+ i--, p_arg++)
+ {
+ size_t z;
+
+ /* Align if necessary. */
+ if (((*p_arg)->alignment - 1) & (unsigned) argp)
+ argp = (char *) ALIGN (argp, (*p_arg)->alignment);
+
+ if (avn != 0)
+ {
+ avn--;
+ z = (*p_arg)->size;
+ if (z < sizeof (int))
+ {
+ z = sizeof (int);
+
+ switch ((*p_arg)->type)
+ {
+ case FFI_TYPE_SINT8:
+ *(signed int *) argp = (signed int)*(SINT8 *)(* p_argv);
+ break;
+
+ case FFI_TYPE_UINT8:
+ *(unsigned int *) argp = (unsigned int)*(UINT8 *)(* p_argv);
+ break;
+
+ case FFI_TYPE_SINT16:
+ *(signed int *) argp = (signed int)*(SINT16 *)(* p_argv);
+ break;
+
+ case FFI_TYPE_UINT16:
+ *(unsigned int *) argp = (unsigned int)*(UINT16 *)(* p_argv);
+ break;
+
+ case FFI_TYPE_STRUCT:
+ z = (*p_arg)->size;
+ if ((*p_arg)->alignment != 1)
+ memcpy (argp, *p_argv, z);
+ else
+ memcpy (argp + 4 - z, *p_argv, z);
+ z = sizeof (int);
+ break;
+
+ default:
+ FFI_ASSERT(0);
+ }
+ }
+ else if (z == sizeof (int))
+ {
+ *(unsigned int *) argp = (unsigned int)*(UINT32 *)(* p_argv);
+ }
+ else
+ {
+ if ((*p_arg)->type == FFI_TYPE_STRUCT)
+ {
+ if (z > 8)
+ {
+ *(unsigned int *) argp = (unsigned int)(void *)(* p_argv);
+ z = sizeof(void *);
+ }
+ else
+ {
+ memcpy(argp, *p_argv, z);
+ z = 8;
+ }
+ }
+ else
+ {
+ /* Double or long long 64bit. */
+ memcpy (argp, *p_argv, z);
+ }
+ }
+ p_argv++;
+ argp += z;
+ }
+ }
+
+ return;
+}
+
+/* Perform machine dependent cif processing. */
+ffi_status
+ffi_prep_cif_machdep(ffi_cif *cif)
+{
+ /* Set the return type flag. */
+ switch (cif->rtype->type)
+ {
+ case FFI_TYPE_VOID:
+ cif->flags = (unsigned) cif->rtype->type;
+ break;
+
+ case FFI_TYPE_STRUCT:
+ if (cif->rtype->size <= 4)
+ cif->flags = FFI_TYPE_INT;
+
+ else if (cif->rtype->size <= 8)
+ cif->flags = FFI_TYPE_DOUBLE;
+
+ else
+ cif->flags = (unsigned) cif->rtype->type;
+ break;
+
+ case FFI_TYPE_SINT64:
+ case FFI_TYPE_UINT64:
+ case FFI_TYPE_DOUBLE:
+ cif->flags = FFI_TYPE_DOUBLE;
+ break;
+
+ case FFI_TYPE_FLOAT:
+ default:
+ cif->flags = FFI_TYPE_INT;
+ break;
+ }
+
+ return FFI_OK;
+}
+
+extern void ffi_call_SYSV(void (*)(char *, extended_cif *), extended_cif *,
+ unsigned, unsigned, unsigned *, void (*fn)(void));
+
+void ffi_call(ffi_cif *cif, void (*fn)(void), void *rvalue, void **avalue)
+{
+ extended_cif ecif;
+
+ ecif.cif = cif;
+ ecif.avalue = avalue;
+
+ /* If the return value is a struct and we don't have
+ a return value address then we need to make one. */
+ if ((rvalue == NULL) &&
+ (cif->rtype->type == FFI_TYPE_STRUCT))
+ {
+ ecif.rvalue = alloca (cif->rtype->size);
+ }
+ else
+ ecif.rvalue = rvalue;
+
+ switch (cif->abi)
+ {
+ case FFI_SYSV:
+ ffi_call_SYSV(ffi_prep_args, &ecif, cif->bytes,
+ cif->flags, ecif.rvalue, fn);
+ if (cif->rtype->type == FFI_TYPE_STRUCT)
+ {
+ int size = cif->rtype->size;
+ int align = cif->rtype->alignment;
+
+ if (size < 4)
+ {
+ if (align == 1)
+ *(unsigned long *)(ecif.rvalue) <<= (4 - size) * 8;
+ }
+ else if (4 < size && size < 8)
+ {
+ if (align == 1)
+ {
+ memcpy (ecif.rvalue, ecif.rvalue + 8-size, size);
+ }
+ else if (align == 2)
+ {
+ if (size & 1)
+ size += 1;
+
+ if (size != 8)
+ memcpy (ecif.rvalue, ecif.rvalue + 8-size, size);
+ }
+ }
+ }
+ break;
+
+ default:
+ FFI_ASSERT(0);
+ break;
+ }
+}
diff --git a/jni/ruby/ext/fiddle/libffi-3.2.1/src/m32r/ffitarget.h b/jni/ruby/ext/fiddle/libffi-3.2.1/src/m32r/ffitarget.h
new file mode 100644
index 0000000..6c34801
--- /dev/null
+++ b/jni/ruby/ext/fiddle/libffi-3.2.1/src/m32r/ffitarget.h
@@ -0,0 +1,53 @@
+/* -----------------------------------------------------------------*-C-*-
+ ffitarget.h - Copyright (c) 2012 Anthony Green
+ Copyright (c) 2004 Renesas Technology.
+ Target configuration macros for M32R.
+
+ Permission is hereby granted, free of charge, to any person obtaining
+ a copy of this software and associated documentation files (the
+ ``Software''), to deal in the Software without restriction, including
+ without limitation the rights to use, copy, modify, merge, publish,
+ distribute, sublicense, and/or sell copies of the Software, and to
+ permit persons to whom the Software is furnished to do so, subject to
+ the following conditions:
+
+ The above copyright notice and this permission notice shall be included
+ in all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ IN NO EVENT SHALL RENESAS TECHNOLOGY BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ OTHER DEALINGS IN THE SOFTWARE.
+
+ ----------------------------------------------------------------------- */
+
+#ifndef LIBFFI_TARGET_H
+#define LIBFFI_TARGET_H
+
+#ifndef LIBFFI_H
+#error "Please do not include ffitarget.h directly into your source. Use ffi.h instead."
+#endif
+
+/* ---- Generic type definitions ----------------------------------------- */
+
+#ifndef LIBFFI_ASM
+typedef unsigned long ffi_arg;
+typedef signed long ffi_sarg;
+
+typedef enum ffi_abi
+ {
+ FFI_FIRST_ABI = 0,
+ FFI_SYSV,
+ FFI_LAST_ABI,
+ FFI_DEFAULT_ABI = FFI_SYSV
+ } ffi_abi;
+#endif
+
+#define FFI_CLOSURES 0
+#define FFI_TRAMPOLINE_SIZE 24
+#define FFI_NATIVE_RAW_API 0
+
+#endif
diff --git a/jni/ruby/ext/fiddle/libffi-3.2.1/src/m32r/sysv.S b/jni/ruby/ext/fiddle/libffi-3.2.1/src/m32r/sysv.S
new file mode 100644
index 0000000..06b75c2
--- /dev/null
+++ b/jni/ruby/ext/fiddle/libffi-3.2.1/src/m32r/sysv.S
@@ -0,0 +1,121 @@
+/* -----------------------------------------------------------------------
+ sysv.S - Copyright (c) 2004 Renesas Technology
+
+ M32R Foreign Function Interface
+
+ Permission is hereby granted, free of charge, to any person obtaining
+ a copy of this software and associated documentation files (the
+ ``Software''), to deal in the Software without restriction, including
+ without limitation the rights to use, copy, modify, merge, publish,
+ distribute, sublicense, and/or sell copies of the Software, and to
+ permit persons to whom the Software is furnished to do so, subject to
+ the following conditions:
+
+ The above copyright notice and this permission notice shall be included
+ in all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ IN NO EVENT SHALL RENESAS TECHNOLOGY BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ OTHER DEALINGS IN THE SOFTWARE.
+ ----------------------------------------------------------------------- */
+
+#define LIBFFI_ASM
+#include <fficonfig.h>
+#include <ffi.h>
+#ifdef HAVE_MACHINE_ASM_H
+#include <machine/asm.h>
+#else
+/* XXX these lose for some platforms, I'm sure. */
+#define CNAME(x) x
+#define ENTRY(x) .globl CNAME(x)! .type CNAME(x),%function! CNAME(x):
+#endif
+
+.text
+
+ /* R0: ffi_prep_args */
+ /* R1: &ecif */
+ /* R2: cif->bytes */
+ /* R3: fig->flags */
+ /* sp+0: ecif.rvalue */
+ /* sp+4: fn */
+
+ /* This assumes we are using gas. */
+ENTRY(ffi_call_SYSV)
+ /* Save registers. */
+ push fp
+ push lr
+ push r3
+ push r2
+ push r1
+ push r0
+ mv fp, sp
+
+ /* Make room for all of the new args. */
+ sub sp, r2
+
+ /* Place all of the ffi_prep_args in position. */
+ mv lr, r0
+ mv r0, sp
+ /* R1 already set. */
+
+ /* And call. */
+ jl lr
+
+ /* Move first 4 parameters in registers... */
+ ld r0, @(0,sp)
+ ld r1, @(4,sp)
+ ld r2, @(8,sp)
+ ld r3, @(12,sp)
+
+ /* ...and adjust the stack. */
+ ld lr, @(8,fp)
+ cmpi lr, #16
+ bc adjust_stack
+ ldi lr, #16
+adjust_stack:
+ add sp, lr
+
+ /* Call the function. */
+ ld lr, @(28,fp)
+ jl lr
+
+ /* Remove the space we pushed for the args. */
+ mv sp, fp
+
+ /* Load R2 with the pointer to storage for the return value. */
+ ld r2, @(24,sp)
+
+ /* Load R3 with the return type code. */
+ ld r3, @(12,sp)
+
+ /* If the return value pointer is NULL, assume no return value. */
+ beqz r2, epilogue
+
+ /* Return INT. */
+ ldi r4, #FFI_TYPE_INT
+ bne r3, r4, return_double
+ st r0, @r2
+ bra epilogue
+
+return_double:
+ /* Return DOUBLE or LONGDOUBLE. */
+ ldi r4, #FFI_TYPE_DOUBLE
+ bne r3, r4, epilogue
+ st r0, @r2
+ st r1, @(4,r2)
+
+epilogue:
+ pop r0
+ pop r1
+ pop r2
+ pop r3
+ pop lr
+ pop fp
+ jmp lr
+
+.ffi_call_SYSV_end:
+ .size CNAME(ffi_call_SYSV),.ffi_call_SYSV_end-CNAME(ffi_call_SYSV)
diff --git a/jni/ruby/ext/fiddle/libffi-3.2.1/src/m68k/ffi.c b/jni/ruby/ext/fiddle/libffi-3.2.1/src/m68k/ffi.c
new file mode 100644
index 0000000..0dee938
--- /dev/null
+++ b/jni/ruby/ext/fiddle/libffi-3.2.1/src/m68k/ffi.c
@@ -0,0 +1,362 @@
+/* -----------------------------------------------------------------------
+ ffi.c
+
+ m68k Foreign Function Interface
+ ----------------------------------------------------------------------- */
+
+#include <ffi.h>
+#include <ffi_common.h>
+
+#include <stdlib.h>
+#include <unistd.h>
+#ifdef __rtems__
+void rtems_cache_flush_multiple_data_lines( const void *, size_t );
+#else
+#include <sys/syscall.h>
+#ifdef __MINT__
+#include <mint/mintbind.h>
+#include <mint/ssystem.h>
+#else
+#include <asm/cachectl.h>
+#endif
+#endif
+
+void ffi_call_SYSV (extended_cif *,
+ unsigned, unsigned,
+ void *, void (*fn) ());
+void *ffi_prep_args (void *stack, extended_cif *ecif);
+void ffi_closure_SYSV (ffi_closure *);
+void ffi_closure_struct_SYSV (ffi_closure *);
+unsigned int ffi_closure_SYSV_inner (ffi_closure *closure,
+ void *resp, void *args);
+
+/* ffi_prep_args is called by the assembly routine once stack space has
+ been allocated for the function's arguments. */
+
+void *
+ffi_prep_args (void *stack, extended_cif *ecif)
+{
+ unsigned int i;
+ void **p_argv;
+ char *argp;
+ ffi_type **p_arg;
+ void *struct_value_ptr;
+
+ argp = stack;
+
+ if (
+#ifdef __MINT__
+ (ecif->cif->rtype->type == FFI_TYPE_LONGDOUBLE) ||
+#endif
+ (((ecif->cif->rtype->type == FFI_TYPE_STRUCT)
+ && !ecif->cif->flags)))
+ struct_value_ptr = ecif->rvalue;
+ else
+ struct_value_ptr = NULL;
+
+ p_argv = ecif->avalue;
+
+ for (i = ecif->cif->nargs, p_arg = ecif->cif->arg_types;
+ i != 0;
+ i--, p_arg++)
+ {
+ size_t z = (*p_arg)->size;
+ int type = (*p_arg)->type;
+
+ if (z < sizeof (int))
+ {
+ switch (type)
+ {
+ case FFI_TYPE_SINT8:
+ *(signed int *) argp = (signed int) *(SINT8 *) *p_argv;
+ break;
+
+ case FFI_TYPE_UINT8:
+ *(unsigned int *) argp = (unsigned int) *(UINT8 *) *p_argv;
+ break;
+
+ case FFI_TYPE_SINT16:
+ *(signed int *) argp = (signed int) *(SINT16 *) *p_argv;
+ break;
+
+ case FFI_TYPE_UINT16:
+ *(unsigned int *) argp = (unsigned int) *(UINT16 *) *p_argv;
+ break;
+
+ case FFI_TYPE_STRUCT:
+#ifdef __MINT__
+ if (z == 1 || z == 2)
+ memcpy (argp + 2, *p_argv, z);
+ else
+ memcpy (argp, *p_argv, z);
+#else
+ memcpy (argp + sizeof (int) - z, *p_argv, z);
+#endif
+ break;
+
+ default:
+ FFI_ASSERT (0);
+ }
+ z = sizeof (int);
+ }
+ else
+ {
+ memcpy (argp, *p_argv, z);
+
+ /* Align if necessary. */
+ if ((sizeof(int) - 1) & z)
+ z = ALIGN(z, sizeof(int));
+ }
+
+ p_argv++;
+ argp += z;
+ }
+
+ return struct_value_ptr;
+}
+
+#define CIF_FLAGS_INT 1
+#define CIF_FLAGS_DINT 2
+#define CIF_FLAGS_FLOAT 4
+#define CIF_FLAGS_DOUBLE 8
+#define CIF_FLAGS_LDOUBLE 16
+#define CIF_FLAGS_POINTER 32
+#define CIF_FLAGS_STRUCT1 64
+#define CIF_FLAGS_STRUCT2 128
+#define CIF_FLAGS_SINT8 256
+#define CIF_FLAGS_SINT16 512
+
+/* Perform machine dependent cif processing */
+ffi_status
+ffi_prep_cif_machdep (ffi_cif *cif)
+{
+ /* Set the return type flag */
+ switch (cif->rtype->type)
+ {
+ case FFI_TYPE_VOID:
+ cif->flags = 0;
+ break;
+
+ case FFI_TYPE_STRUCT:
+ if (cif->rtype->elements[0]->type == FFI_TYPE_STRUCT &&
+ cif->rtype->elements[1])
+ {
+ cif->flags = 0;
+ break;
+ }
+
+ switch (cif->rtype->size)
+ {
+ case 1:
+#ifdef __MINT__
+ cif->flags = CIF_FLAGS_STRUCT2;
+#else
+ cif->flags = CIF_FLAGS_STRUCT1;
+#endif
+ break;
+ case 2:
+ cif->flags = CIF_FLAGS_STRUCT2;
+ break;
+#ifdef __MINT__
+ case 3:
+#endif
+ case 4:
+ cif->flags = CIF_FLAGS_INT;
+ break;
+#ifdef __MINT__
+ case 7:
+#endif
+ case 8:
+ cif->flags = CIF_FLAGS_DINT;
+ break;
+ default:
+ cif->flags = 0;
+ break;
+ }
+ break;
+
+ case FFI_TYPE_FLOAT:
+ cif->flags = CIF_FLAGS_FLOAT;
+ break;
+
+ case FFI_TYPE_DOUBLE:
+ cif->flags = CIF_FLAGS_DOUBLE;
+ break;
+
+#if (FFI_TYPE_LONGDOUBLE != FFI_TYPE_DOUBLE)
+ case FFI_TYPE_LONGDOUBLE:
+#ifdef __MINT__
+ cif->flags = 0;
+#else
+ cif->flags = CIF_FLAGS_LDOUBLE;
+#endif
+ break;
+#endif
+
+ case FFI_TYPE_POINTER:
+ cif->flags = CIF_FLAGS_POINTER;
+ break;
+
+ case FFI_TYPE_SINT64:
+ case FFI_TYPE_UINT64:
+ cif->flags = CIF_FLAGS_DINT;
+ break;
+
+ case FFI_TYPE_SINT16:
+ cif->flags = CIF_FLAGS_SINT16;
+ break;
+
+ case FFI_TYPE_SINT8:
+ cif->flags = CIF_FLAGS_SINT8;
+ break;
+
+ default:
+ cif->flags = CIF_FLAGS_INT;
+ break;
+ }
+
+ return FFI_OK;
+}
+
+void
+ffi_call (ffi_cif *cif, void (*fn) (), void *rvalue, void **avalue)
+{
+ extended_cif ecif;
+
+ ecif.cif = cif;
+ ecif.avalue = avalue;
+
+ /* If the return value is a struct and we don't have a return value
+ address then we need to make one. */
+
+ if (rvalue == NULL
+ && cif->rtype->type == FFI_TYPE_STRUCT
+ && cif->rtype->size > 8)
+ ecif.rvalue = alloca (cif->rtype->size);
+ else
+ ecif.rvalue = rvalue;
+
+ switch (cif->abi)
+ {
+ case FFI_SYSV:
+ ffi_call_SYSV (&ecif, cif->bytes, cif->flags,
+ ecif.rvalue, fn);
+ break;
+
+ default:
+ FFI_ASSERT (0);
+ break;
+ }
+}
+
+static void
+ffi_prep_incoming_args_SYSV (char *stack, void **avalue, ffi_cif *cif)
+{
+ unsigned int i;
+ void **p_argv;
+ char *argp;
+ ffi_type **p_arg;
+
+ argp = stack;
+ p_argv = avalue;
+
+ for (i = cif->nargs, p_arg = cif->arg_types; (i != 0); i--, p_arg++)
+ {
+ size_t z;
+
+ z = (*p_arg)->size;
+#ifdef __MINT__
+ if (cif->flags &&
+ cif->rtype->type == FFI_TYPE_STRUCT &&
+ (z == 1 || z == 2))
+ {
+ *p_argv = (void *) (argp + 2);
+
+ z = 4;
+ }
+ else
+ if (cif->flags &&
+ cif->rtype->type == FFI_TYPE_STRUCT &&
+ (z == 3 || z == 4))
+ {
+ *p_argv = (void *) (argp);
+
+ z = 4;
+ }
+ else
+#endif
+ if (z <= 4)
+ {
+ *p_argv = (void *) (argp + 4 - z);
+
+ z = 4;
+ }
+ else
+ {
+ *p_argv = (void *) argp;
+
+ /* Align if necessary */
+ if ((sizeof(int) - 1) & z)
+ z = ALIGN(z, sizeof(int));
+ }
+
+ p_argv++;
+ argp += z;
+ }
+}
+
+unsigned int
+ffi_closure_SYSV_inner (ffi_closure *closure, void *resp, void *args)
+{
+ ffi_cif *cif;
+ void **arg_area;
+
+ cif = closure->cif;
+ arg_area = (void**) alloca (cif->nargs * sizeof (void *));
+
+ ffi_prep_incoming_args_SYSV(args, arg_area, cif);
+
+ (closure->fun) (cif, resp, arg_area, closure->user_data);
+
+ return cif->flags;
+}
+
+ffi_status
+ffi_prep_closure_loc (ffi_closure* closure,
+ ffi_cif* cif,
+ void (*fun)(ffi_cif*,void*,void**,void*),
+ void *user_data,
+ void *codeloc)
+{
+ if (cif->abi != FFI_SYSV)
+ return FFI_BAD_ABI;
+
+ *(unsigned short *)closure->tramp = 0x207c;
+ *(void **)(closure->tramp + 2) = codeloc;
+ *(unsigned short *)(closure->tramp + 6) = 0x4ef9;
+
+ if (
+#ifdef __MINT__
+ (cif->rtype->type == FFI_TYPE_LONGDOUBLE) ||
+#endif
+ (((cif->rtype->type == FFI_TYPE_STRUCT)
+ && !cif->flags)))
+ *(void **)(closure->tramp + 8) = ffi_closure_struct_SYSV;
+ else
+ *(void **)(closure->tramp + 8) = ffi_closure_SYSV;
+
+#ifdef __rtems__
+ rtems_cache_flush_multiple_data_lines( codeloc, FFI_TRAMPOLINE_SIZE );
+#elif defined(__MINT__)
+ Ssystem(S_FLUSHCACHE, codeloc, FFI_TRAMPOLINE_SIZE);
+#else
+ syscall(SYS_cacheflush, codeloc, FLUSH_SCOPE_LINE,
+ FLUSH_CACHE_BOTH, FFI_TRAMPOLINE_SIZE);
+#endif
+
+ closure->cif = cif;
+ closure->user_data = user_data;
+ closure->fun = fun;
+
+ return FFI_OK;
+}
diff --git a/jni/ruby/ext/fiddle/libffi-3.2.1/src/m68k/ffitarget.h b/jni/ruby/ext/fiddle/libffi-3.2.1/src/m68k/ffitarget.h
new file mode 100644
index 0000000..e81dde2
--- /dev/null
+++ b/jni/ruby/ext/fiddle/libffi-3.2.1/src/m68k/ffitarget.h
@@ -0,0 +1,54 @@
+/* -----------------------------------------------------------------*-C-*-
+ ffitarget.h - Copyright (c) 2012 Anthony Green
+ Copyright (c) 1996-2003 Red Hat, Inc.
+ Target configuration macros for Motorola 68K.
+
+ Permission is hereby granted, free of charge, to any person obtaining
+ a copy of this software and associated documentation files (the
+ ``Software''), to deal in the Software without restriction, including
+ without limitation the rights to use, copy, modify, merge, publish,
+ distribute, sublicense, and/or sell copies of the Software, and to
+ permit persons to whom the Software is furnished to do so, subject to
+ the following conditions:
+
+ The above copyright notice and this permission notice shall be included
+ in all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND,
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+ HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ DEALINGS IN THE SOFTWARE.
+
+ ----------------------------------------------------------------------- */
+
+#ifndef LIBFFI_TARGET_H
+#define LIBFFI_TARGET_H
+
+#ifndef LIBFFI_H
+#error "Please do not include ffitarget.h directly into your source. Use ffi.h instead."
+#endif
+
+#ifndef LIBFFI_ASM
+typedef unsigned long ffi_arg;
+typedef signed long ffi_sarg;
+
+typedef enum ffi_abi {
+ FFI_FIRST_ABI = 0,
+ FFI_SYSV,
+ FFI_LAST_ABI,
+ FFI_DEFAULT_ABI = FFI_SYSV
+} ffi_abi;
+#endif
+
+/* ---- Definitions for closures ----------------------------------------- */
+
+#define FFI_CLOSURES 1
+#define FFI_TRAMPOLINE_SIZE 16
+#define FFI_NATIVE_RAW_API 0
+
+#endif
+
diff --git a/jni/ruby/ext/fiddle/libffi-3.2.1/src/m68k/sysv.S b/jni/ruby/ext/fiddle/libffi-3.2.1/src/m68k/sysv.S
new file mode 100644
index 0000000..ec2b14f
--- /dev/null
+++ b/jni/ruby/ext/fiddle/libffi-3.2.1/src/m68k/sysv.S
@@ -0,0 +1,330 @@
+/* -----------------------------------------------------------------------
+
+ sysv.S - Copyright (c) 2012 Alan Hourihane
+ Copyright (c) 1998, 2012 Andreas Schwab
+ Copyright (c) 2008 Red Hat, Inc.
+ Copyright (c) 2012 Thorsten Glaser
+
+ m68k Foreign Function Interface
+
+ Permission is hereby granted, free of charge, to any person obtaining
+ a copy of this software and associated documentation files (the
+ ``Software''), to deal in the Software without restriction, including
+ without limitation the rights to use, copy, modify, merge, publish,
+ distribute, sublicense, and/or sell copies of the Software, and to
+ permit persons to whom the Software is furnished to do so, subject to
+ the following conditions:
+
+ The above copyright notice and this permission notice shall be included
+ in all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND,
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+ HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ DEALINGS IN THE SOFTWARE.
+ ----------------------------------------------------------------------- */
+
+#define LIBFFI_ASM
+#include <fficonfig.h>
+#include <ffi.h>
+
+#ifdef HAVE_AS_CFI_PSEUDO_OP
+#define CFI_STARTPROC() .cfi_startproc
+#define CFI_OFFSET(reg,off) .cfi_offset reg,off
+#define CFI_DEF_CFA(reg,off) .cfi_def_cfa reg,off
+#define CFI_ENDPROC() .cfi_endproc
+#else
+#define CFI_STARTPROC()
+#define CFI_OFFSET(reg,off)
+#define CFI_DEF_CFA(reg,off)
+#define CFI_ENDPROC()
+#endif
+
+#ifdef __MINT__
+#define CALLFUNC(funcname) _ ## funcname
+#else
+#define CALLFUNC(funcname) funcname
+#endif
+
+ .text
+
+ .globl CALLFUNC(ffi_call_SYSV)
+ .type CALLFUNC(ffi_call_SYSV),@function
+ .align 4
+
+CALLFUNC(ffi_call_SYSV):
+ CFI_STARTPROC()
+ link %fp,#0
+ CFI_OFFSET(14,-8)
+ CFI_DEF_CFA(14,8)
+ move.l %d2,-(%sp)
+ CFI_OFFSET(2,-12)
+
+ | Make room for all of the new args.
+ sub.l 12(%fp),%sp
+
+ | Call ffi_prep_args
+ move.l 8(%fp),-(%sp)
+ pea 4(%sp)
+#if !defined __PIC__
+ jsr CALLFUNC(ffi_prep_args)
+#else
+ bsr.l CALLFUNC(ffi_prep_args@PLTPC)
+#endif
+ addq.l #8,%sp
+
+ | Pass pointer to struct value, if any
+#ifdef __MINT__
+ move.l %d0,%a1
+#else
+ move.l %a0,%a1
+#endif
+
+ | Call the function
+ move.l 24(%fp),%a0
+ jsr (%a0)
+
+ | Remove the space we pushed for the args
+ add.l 12(%fp),%sp
+
+ | Load the pointer to storage for the return value
+ move.l 20(%fp),%a1
+
+ | Load the return type code
+ move.l 16(%fp),%d2
+
+ | If the return value pointer is NULL, assume no return value.
+ | NOTE: On the mc68000, tst on an address register is not supported.
+#if !defined(__mc68020__) && !defined(__mc68030__) && !defined(__mc68040__) && !defined(__mc68060__) && !defined(__mcoldfire__)
+ cmp.w #0, %a1
+#else
+ tst.l %a1
+#endif
+ jbeq noretval
+
+ btst #0,%d2
+ jbeq retlongint
+ move.l %d0,(%a1)
+ jbra epilogue
+
+retlongint:
+ btst #1,%d2
+ jbeq retfloat
+ move.l %d0,(%a1)
+ move.l %d1,4(%a1)
+ jbra epilogue
+
+retfloat:
+ btst #2,%d2
+ jbeq retdouble
+#if defined(__MC68881__) || defined(__HAVE_68881__)
+ fmove.s %fp0,(%a1)
+#else
+ move.l %d0,(%a1)
+#endif
+ jbra epilogue
+
+retdouble:
+ btst #3,%d2
+ jbeq retlongdouble
+#if defined(__MC68881__) || defined(__HAVE_68881__)
+ fmove.d %fp0,(%a1)
+#else
+ move.l %d0,(%a1)+
+ move.l %d1,(%a1)
+#endif
+ jbra epilogue
+
+retlongdouble:
+ btst #4,%d2
+ jbeq retpointer
+#if defined(__MC68881__) || defined(__HAVE_68881__)
+ fmove.x %fp0,(%a1)
+#else
+ move.l %d0,(%a1)+
+ move.l %d1,(%a1)+
+ move.l %d2,(%a1)
+#endif
+ jbra epilogue
+
+retpointer:
+ btst #5,%d2
+ jbeq retstruct1
+#ifdef __MINT__
+ move.l %d0,(%a1)
+#else
+ move.l %a0,(%a1)
+#endif
+ jbra epilogue
+
+retstruct1:
+ btst #6,%d2
+ jbeq retstruct2
+ move.b %d0,(%a1)
+ jbra epilogue
+
+retstruct2:
+ btst #7,%d2
+ jbeq retsint8
+ move.w %d0,(%a1)
+ jbra epilogue
+
+retsint8:
+ btst #8,%d2
+ jbeq retsint16
+ | NOTE: On the mc68000, extb is not supported. 8->16, then 16->32.
+#if !defined(__mc68020__) && !defined(__mc68030__) && !defined(__mc68040__) && !defined(__mc68060__) && !defined(__mcoldfire__)
+ ext.w %d0
+ ext.l %d0
+#else
+ extb.l %d0
+#endif
+ move.l %d0,(%a1)
+ jbra epilogue
+
+retsint16:
+ btst #9,%d2
+ jbeq noretval
+ ext.l %d0
+ move.l %d0,(%a1)
+
+noretval:
+epilogue:
+ move.l (%sp)+,%d2
+ unlk %fp
+ rts
+ CFI_ENDPROC()
+ .size CALLFUNC(ffi_call_SYSV),.-CALLFUNC(ffi_call_SYSV)
+
+ .globl CALLFUNC(ffi_closure_SYSV)
+ .type CALLFUNC(ffi_closure_SYSV), @function
+ .align 4
+
+CALLFUNC(ffi_closure_SYSV):
+ CFI_STARTPROC()
+ link %fp,#-12
+ CFI_OFFSET(14,-8)
+ CFI_DEF_CFA(14,8)
+ move.l %sp,-12(%fp)
+ pea 8(%fp)
+ pea -12(%fp)
+ move.l %a0,-(%sp)
+#if !defined __PIC__
+ jsr CALLFUNC(ffi_closure_SYSV_inner)
+#else
+ bsr.l CALLFUNC(ffi_closure_SYSV_inner@PLTPC)
+#endif
+
+ lsr.l #1,%d0
+ jne 1f
+ jcc .Lcls_epilogue
+ | CIF_FLAGS_INT
+ move.l -12(%fp),%d0
+.Lcls_epilogue:
+ | no CIF_FLAGS_*
+ unlk %fp
+ rts
+1:
+ lea -12(%fp),%a0
+ lsr.l #2,%d0
+ jne 1f
+ jcs .Lcls_ret_float
+ | CIF_FLAGS_DINT
+ move.l (%a0)+,%d0
+ move.l (%a0),%d1
+ jra .Lcls_epilogue
+.Lcls_ret_float:
+#if defined(__MC68881__) || defined(__HAVE_68881__)
+ fmove.s (%a0),%fp0
+#else
+ move.l (%a0),%d0
+#endif
+ jra .Lcls_epilogue
+1:
+ lsr.l #2,%d0
+ jne 1f
+ jcs .Lcls_ret_ldouble
+ | CIF_FLAGS_DOUBLE
+#if defined(__MC68881__) || defined(__HAVE_68881__)
+ fmove.d (%a0),%fp0
+#else
+ move.l (%a0)+,%d0
+ move.l (%a0),%d1
+#endif
+ jra .Lcls_epilogue
+.Lcls_ret_ldouble:
+#if defined(__MC68881__) || defined(__HAVE_68881__)
+ fmove.x (%a0),%fp0
+#else
+ move.l (%a0)+,%d0
+ move.l (%a0)+,%d1
+ move.l (%a0),%d2
+#endif
+ jra .Lcls_epilogue
+1:
+ lsr.l #2,%d0
+ jne 1f
+ jcs .Lcls_ret_struct1
+ | CIF_FLAGS_POINTER
+ move.l (%a0),%a0
+ move.l %a0,%d0
+ jra .Lcls_epilogue
+.Lcls_ret_struct1:
+ move.b (%a0),%d0
+ jra .Lcls_epilogue
+1:
+ lsr.l #2,%d0
+ jne 1f
+ jcs .Lcls_ret_sint8
+ | CIF_FLAGS_STRUCT2
+ move.w (%a0),%d0
+ jra .Lcls_epilogue
+.Lcls_ret_sint8:
+ move.l (%a0),%d0
+ | NOTE: On the mc68000, extb is not supported. 8->16, then 16->32.
+#if !defined(__mc68020__) && !defined(__mc68030__) && !defined(__mc68040__) && !defined(__mc68060__) && !defined(__mcoldfire__)
+ ext.w %d0
+ ext.l %d0
+#else
+ extb.l %d0
+#endif
+ jra .Lcls_epilogue
+1:
+ | CIF_FLAGS_SINT16
+ move.l (%a0),%d0
+ ext.l %d0
+ jra .Lcls_epilogue
+ CFI_ENDPROC()
+
+ .size CALLFUNC(ffi_closure_SYSV),.-CALLFUNC(ffi_closure_SYSV)
+
+ .globl CALLFUNC(ffi_closure_struct_SYSV)
+ .type CALLFUNC(ffi_closure_struct_SYSV), @function
+ .align 4
+
+CALLFUNC(ffi_closure_struct_SYSV):
+ CFI_STARTPROC()
+ link %fp,#0
+ CFI_OFFSET(14,-8)
+ CFI_DEF_CFA(14,8)
+ move.l %sp,-12(%fp)
+ pea 8(%fp)
+ move.l %a1,-(%sp)
+ move.l %a0,-(%sp)
+#if !defined __PIC__
+ jsr CALLFUNC(ffi_closure_SYSV_inner)
+#else
+ bsr.l CALLFUNC(ffi_closure_SYSV_inner@PLTPC)
+#endif
+ unlk %fp
+ rts
+ CFI_ENDPROC()
+ .size CALLFUNC(ffi_closure_struct_SYSV),.-CALLFUNC(ffi_closure_struct_SYSV)
+
+#if defined __ELF__ && defined __linux__
+ .section .note.GNU-stack,"",@progbits
+#endif
diff --git a/jni/ruby/ext/fiddle/libffi-3.2.1/src/m88k/ffi.c b/jni/ruby/ext/fiddle/libffi-3.2.1/src/m88k/ffi.c
new file mode 100644
index 0000000..68df494
--- /dev/null
+++ b/jni/ruby/ext/fiddle/libffi-3.2.1/src/m88k/ffi.c
@@ -0,0 +1,400 @@
+/*
+ * Copyright (c) 2013 Miodrag Vallat. <miod@openbsd.org>
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * ``Software''), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+ * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+/*
+ * m88k Foreign Function Interface
+ *
+ * This file attempts to provide all the FFI entry points which can reliably
+ * be implemented in C.
+ *
+ * Only OpenBSD/m88k is currently supported; other platforms (such as
+ * Motorola's SysV/m88k) could be supported with the following tweaks:
+ *
+ * - non-OpenBSD systems use an `outgoing parameter area' as part of the
+ * 88BCS calling convention, which is not supported under OpenBSD from
+ * release 3.6 onwards. Supporting it should be as easy as taking it
+ * into account when adjusting the stack, in the assembly code.
+ *
+ * - the logic deciding whether a function argument gets passed through
+ * registers, or on the stack, has changed several times in OpenBSD in
+ * edge cases (especially for structs larger than 32 bytes being passed
+ * by value). The code below attemps to match the logic used by the
+ * system compiler of OpenBSD 5.3, i.e. gcc 3.3.6 with many m88k backend
+ * fixes.
+ */
+
+#include <ffi.h>
+#include <ffi_common.h>
+
+#include <stdlib.h>
+#include <unistd.h>
+
+void ffi_call_OBSD (unsigned int, extended_cif *, unsigned int, void *,
+ void (*fn) ());
+void *ffi_prep_args (void *, extended_cif *);
+void ffi_closure_OBSD (ffi_closure *);
+void ffi_closure_struct_OBSD (ffi_closure *);
+unsigned int ffi_closure_OBSD_inner (ffi_closure *, void *, unsigned int *,
+ char *);
+void ffi_cacheflush_OBSD (unsigned int, unsigned int);
+
+#define CIF_FLAGS_INT (1 << 0)
+#define CIF_FLAGS_DINT (1 << 1)
+
+/*
+ * Foreign Function Interface API
+ */
+
+/* ffi_prep_args is called by the assembly routine once stack space has
+ been allocated for the function's arguments. */
+
+void *
+ffi_prep_args (void *stack, extended_cif *ecif)
+{
+ unsigned int i;
+ void **p_argv;
+ char *argp, *stackp;
+ unsigned int *regp;
+ unsigned int regused;
+ ffi_type **p_arg;
+ void *struct_value_ptr;
+
+ regp = (unsigned int *)stack;
+ stackp = (char *)(regp + 8);
+ regused = 0;
+
+ if (ecif->cif->rtype->type == FFI_TYPE_STRUCT
+ && !ecif->cif->flags)
+ struct_value_ptr = ecif->rvalue;
+ else
+ struct_value_ptr = NULL;
+
+ p_argv = ecif->avalue;
+
+ for (i = ecif->cif->nargs, p_arg = ecif->cif->arg_types; i != 0; i--, p_arg++)
+ {
+ size_t z;
+ unsigned short t, a;
+
+ z = (*p_arg)->size;
+ t = (*p_arg)->type;
+ a = (*p_arg)->alignment;
+
+ /*
+ * Figure out whether the argument can be passed through registers
+ * or on the stack.
+ * The rule is that registers can only receive simple types not larger
+ * than 64 bits, or structs the exact size of a register and aligned to
+ * the size of a register.
+ */
+ if (t == FFI_TYPE_STRUCT)
+ {
+ if (z == sizeof (int) && a == sizeof (int) && regused < 8)
+ argp = (char *)regp;
+ else
+ argp = stackp;
+ }
+ else
+ {
+ if (z > sizeof (int) && regused < 8 - 1)
+ {
+ /* align to an even register pair */
+ if (regused & 1)
+ {
+ regp++;
+ regused++;
+ }
+ }
+ if (regused < 8)
+ argp = (char *)regp;
+ else
+ argp = stackp;
+ }
+
+ /* Enforce proper stack alignment of 64-bit types */
+ if (argp == stackp && a > sizeof (int))
+ {
+ stackp = (char *) ALIGN(stackp, a);
+ argp = stackp;
+ }
+
+ switch (t)
+ {
+ case FFI_TYPE_SINT8:
+ *(signed int *) argp = (signed int) *(SINT8 *) *p_argv;
+ break;
+
+ case FFI_TYPE_UINT8:
+ *(unsigned int *) argp = (unsigned int) *(UINT8 *) *p_argv;
+ break;
+
+ case FFI_TYPE_SINT16:
+ *(signed int *) argp = (signed int) *(SINT16 *) *p_argv;
+ break;
+
+ case FFI_TYPE_UINT16:
+ *(unsigned int *) argp = (unsigned int) *(UINT16 *) *p_argv;
+ break;
+
+ case FFI_TYPE_INT:
+ case FFI_TYPE_FLOAT:
+ case FFI_TYPE_UINT32:
+ case FFI_TYPE_SINT32:
+ case FFI_TYPE_POINTER:
+ *(unsigned int *) argp = *(unsigned int *) *p_argv;
+ break;
+
+ case FFI_TYPE_DOUBLE:
+ case FFI_TYPE_UINT64:
+ case FFI_TYPE_SINT64:
+ case FFI_TYPE_STRUCT:
+ memcpy (argp, *p_argv, z);
+ break;
+
+ default:
+ FFI_ASSERT (0);
+ }
+
+ /* Align if necessary. */
+ if ((sizeof (int) - 1) & z)
+ z = ALIGN(z, sizeof (int));
+
+ p_argv++;
+
+ /* Be careful, once all registers are filled, and about to continue
+ on stack, regp == stackp. Therefore the check for regused as well. */
+ if (argp == (char *)regp && regused < 8)
+ {
+ regp += z / sizeof (int);
+ regused += z / sizeof (int);
+ }
+ else
+ stackp += z;
+ }
+
+ return struct_value_ptr;
+}
+
+/* Perform machine dependent cif processing */
+ffi_status
+ffi_prep_cif_machdep (ffi_cif *cif)
+{
+ /* Set the return type flag */
+ switch (cif->rtype->type)
+ {
+ case FFI_TYPE_VOID:
+ cif->flags = 0;
+ break;
+
+ case FFI_TYPE_STRUCT:
+ if (cif->rtype->size == sizeof (int) &&
+ cif->rtype->alignment == sizeof (int))
+ cif->flags = CIF_FLAGS_INT;
+ else
+ cif->flags = 0;
+ break;
+
+ case FFI_TYPE_DOUBLE:
+ case FFI_TYPE_SINT64:
+ case FFI_TYPE_UINT64:
+ cif->flags = CIF_FLAGS_DINT;
+ break;
+
+ default:
+ cif->flags = CIF_FLAGS_INT;
+ break;
+ }
+
+ return FFI_OK;
+}
+
+void
+ffi_call (ffi_cif *cif, void (*fn) (), void *rvalue, void **avalue)
+{
+ extended_cif ecif;
+
+ ecif.cif = cif;
+ ecif.avalue = avalue;
+
+ /* If the return value is a struct and we don't have a return value
+ address then we need to make one. */
+
+ if (rvalue == NULL
+ && cif->rtype->type == FFI_TYPE_STRUCT
+ && (cif->rtype->size != sizeof (int)
+ || cif->rtype->alignment != sizeof (int)))
+ ecif.rvalue = alloca (cif->rtype->size);
+ else
+ ecif.rvalue = rvalue;
+
+ switch (cif->abi)
+ {
+ case FFI_OBSD:
+ ffi_call_OBSD (cif->bytes, &ecif, cif->flags, ecif.rvalue, fn);
+ break;
+
+ default:
+ FFI_ASSERT (0);
+ break;
+ }
+}
+
+/*
+ * Closure API
+ */
+
+static void
+ffi_prep_closure_args_OBSD (ffi_cif *cif, void **avalue, unsigned int *regp,
+ char *stackp)
+{
+ unsigned int i;
+ void **p_argv;
+ char *argp;
+ unsigned int regused;
+ ffi_type **p_arg;
+
+ regused = 0;
+
+ p_argv = avalue;
+
+ for (i = cif->nargs, p_arg = cif->arg_types; i != 0; i--, p_arg++)
+ {
+ size_t z;
+ unsigned short t, a;
+
+ z = (*p_arg)->size;
+ t = (*p_arg)->type;
+ a = (*p_arg)->alignment;
+
+ /*
+ * Figure out whether the argument has been passed through registers
+ * or on the stack.
+ * The rule is that registers can only receive simple types not larger
+ * than 64 bits, or structs the exact size of a register and aligned to
+ * the size of a register.
+ */
+ if (t == FFI_TYPE_STRUCT)
+ {
+ if (z == sizeof (int) && a == sizeof (int) && regused < 8)
+ argp = (char *)regp;
+ else
+ argp = stackp;
+ }
+ else
+ {
+ if (z > sizeof (int) && regused < 8 - 1)
+ {
+ /* align to an even register pair */
+ if (regused & 1)
+ {
+ regp++;
+ regused++;
+ }
+ }
+ if (regused < 8)
+ argp = (char *)regp;
+ else
+ argp = stackp;
+ }
+
+ /* Enforce proper stack alignment of 64-bit types */
+ if (argp == stackp && a > sizeof (int))
+ {
+ stackp = (char *) ALIGN(stackp, a);
+ argp = stackp;
+ }
+
+ if (z < sizeof (int) && t != FFI_TYPE_STRUCT)
+ *p_argv = (void *) (argp + sizeof (int) - z);
+ else
+ *p_argv = (void *) argp;
+
+ /* Align if necessary */
+ if ((sizeof (int) - 1) & z)
+ z = ALIGN(z, sizeof (int));
+
+ p_argv++;
+
+ /* Be careful, once all registers are exhausted, and about to fetch from
+ stack, regp == stackp. Therefore the check for regused as well. */
+ if (argp == (char *)regp && regused < 8)
+ {
+ regp += z / sizeof (int);
+ regused += z / sizeof (int);
+ }
+ else
+ stackp += z;
+ }
+}
+
+unsigned int
+ffi_closure_OBSD_inner (ffi_closure *closure, void *resp, unsigned int *regp,
+ char *stackp)
+{
+ ffi_cif *cif;
+ void **arg_area;
+
+ cif = closure->cif;
+ arg_area = (void**) alloca (cif->nargs * sizeof (void *));
+
+ ffi_prep_closure_args_OBSD(cif, arg_area, regp, stackp);
+
+ (closure->fun) (cif, resp, arg_area, closure->user_data);
+
+ return cif->flags;
+}
+
+ffi_status
+ffi_prep_closure_loc (ffi_closure* closure, ffi_cif* cif,
+ void (*fun)(ffi_cif*,void*,void**,void*),
+ void *user_data, void *codeloc)
+{
+ unsigned int *tramp = (unsigned int *) codeloc;
+ void *fn;
+
+ FFI_ASSERT (cif->abi == FFI_OBSD);
+
+ if (cif->rtype->type == FFI_TYPE_STRUCT && !cif->flags)
+ fn = &ffi_closure_struct_OBSD;
+ else
+ fn = &ffi_closure_OBSD;
+
+ /* or.u %r10, %r0, %hi16(fn) */
+ tramp[0] = 0x5d400000 | (((unsigned int)fn) >> 16);
+ /* or.u %r13, %r0, %hi16(closure) */
+ tramp[1] = 0x5da00000 | ((unsigned int)closure >> 16);
+ /* or %r10, %r10, %lo16(fn) */
+ tramp[2] = 0x594a0000 | (((unsigned int)fn) & 0xffff);
+ /* jmp.n %r10 */
+ tramp[3] = 0xf400c40a;
+ /* or %r13, %r13, %lo16(closure) */
+ tramp[4] = 0x59ad0000 | ((unsigned int)closure & 0xffff);
+
+ ffi_cacheflush_OBSD((unsigned int)codeloc, FFI_TRAMPOLINE_SIZE);
+
+ closure->cif = cif;
+ closure->user_data = user_data;
+ closure->fun = fun;
+
+ return FFI_OK;
+}
diff --git a/jni/ruby/ext/fiddle/libffi-3.2.1/src/m88k/ffitarget.h b/jni/ruby/ext/fiddle/libffi-3.2.1/src/m88k/ffitarget.h
new file mode 100644
index 0000000..e52bf9f
--- /dev/null
+++ b/jni/ruby/ext/fiddle/libffi-3.2.1/src/m88k/ffitarget.h
@@ -0,0 +1,49 @@
+/*
+ * Copyright (c) 2013 Miodrag Vallat. <miod@openbsd.org>
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * ``Software''), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+ * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+/*
+ * m88k Foreign Function Interface
+ */
+
+#ifndef LIBFFI_TARGET_H
+#define LIBFFI_TARGET_H
+
+#ifndef LIBFFI_ASM
+typedef unsigned long ffi_arg;
+typedef signed long ffi_sarg;
+
+typedef enum ffi_abi {
+ FFI_FIRST_ABI = 0,
+ FFI_OBSD,
+ FFI_DEFAULT_ABI = FFI_OBSD,
+ FFI_LAST_ABI = FFI_DEFAULT_ABI + 1
+} ffi_abi;
+#endif
+
+/* ---- Definitions for closures ----------------------------------------- */
+
+#define FFI_CLOSURES 1
+#define FFI_TRAMPOLINE_SIZE 0x14
+#define FFI_NATIVE_RAW_API 0
+
+#endif
diff --git a/jni/ruby/ext/fiddle/libffi-3.2.1/src/m88k/obsd.S b/jni/ruby/ext/fiddle/libffi-3.2.1/src/m88k/obsd.S
new file mode 100644
index 0000000..1944a23
--- /dev/null
+++ b/jni/ruby/ext/fiddle/libffi-3.2.1/src/m88k/obsd.S
@@ -0,0 +1,209 @@
+/*
+ * Copyright (c) 2013 Miodrag Vallat. <miod@openbsd.org>
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * ``Software''), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+ * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+/*
+ * m88k Foreign Function Interface
+ */
+
+#define LIBFFI_ASM
+#include <fficonfig.h>
+#include <ffi.h>
+
+ .text
+
+/*
+ * ffi_cacheflush_OBSD(unsigned int addr, %r2
+ * unsigned int size); %r3
+ */
+ .align 4
+ .globl ffi_cacheflush_OBSD
+ .type ffi_cacheflush_OBSD,@function
+ffi_cacheflush_OBSD:
+ tb0 0, %r0, 451
+ or %r0, %r0, %r0
+ jmp %r1
+ .size ffi_cacheflush_OBSD, . - ffi_cacheflush_OBSD
+
+/*
+ * ffi_call_OBSD(unsigned bytes, %r2
+ * extended_cif *ecif, %r3
+ * unsigned flags, %r4
+ * void *rvalue, %r5
+ * void (*fn)()); %r6
+ */
+ .align 4
+ .globl ffi_call_OBSD
+ .type ffi_call_OBSD,@function
+ffi_call_OBSD:
+ subu %r31, %r31, 32
+ st %r30, %r31, 4
+ st %r1, %r31, 0
+ addu %r30, %r31, 32
+
+ | Save the few arguments we'll need after ffi_prep_args()
+ st.d %r4, %r31, 8
+ st %r6, %r31, 16
+
+ | Allocate room for the image of r2-r9, and the stack space for
+ | the args (rounded to a 16-byte boundary)
+ addu %r2, %r2, (8 * 4) + 15
+ clr %r2, %r2, 4<0>
+ subu %r31, %r31, %r2
+
+ | Fill register and stack image
+ or %r2, %r31, %r0
+#ifdef PIC
+ bsr ffi_prep_args#plt
+#else
+ bsr ffi_prep_args
+#endif
+
+ | Save pointer to return struct address, if any
+ or %r12, %r2, %r0
+
+ | Get function pointer
+ subu %r4, %r30, 32
+ ld %r1, %r4, 16
+
+ | Fetch the register arguments
+ ld.d %r2, %r31, (0 * 4)
+ ld.d %r4, %r31, (2 * 4)
+ ld.d %r6, %r31, (4 * 4)
+ ld.d %r8, %r31, (6 * 4)
+ addu %r31, %r31, (8 * 4)
+
+ | Invoke the function
+ jsr %r1
+
+ | Restore stack now that we don't need the args anymore
+ subu %r31, %r30, 32
+
+ | Figure out what to return as the function's return value
+ ld %r5, %r31, 12 | rvalue
+ ld %r4, %r31, 8 | flags
+
+ bcnd eq0, %r5, 9f
+
+ bb0 0, %r4, 1f | CIF_FLAGS_INT
+ st %r2, %r5, 0
+ br 9f
+
+1:
+ bb0 1, %r4, 1f | CIF_FLAGS_DINT
+ st.d %r2, %r5, 0
+ br 9f
+
+1:
+9:
+ ld %r1, %r31, 0
+ ld %r30, %r31, 4
+ jmp.n %r1
+ addu %r31, %r31, 32
+ .size ffi_call_OBSD, . - ffi_call_OBSD
+
+/*
+ * ffi_closure_OBSD(ffi_closure *closure); %r13
+ */
+ .align 4
+ .globl ffi_closure_OBSD
+ .type ffi_closure_OBSD, @function
+ffi_closure_OBSD:
+ subu %r31, %r31, 16
+ st %r30, %r31, 4
+ st %r1, %r31, 0
+ addu %r30, %r31, 16
+
+ | Make room on the stack for saved register arguments and return
+ | value
+ subu %r31, %r31, (8 * 4) + (2 * 4)
+ st.d %r2, %r31, (0 * 4)
+ st.d %r4, %r31, (2 * 4)
+ st.d %r6, %r31, (4 * 4)
+ st.d %r8, %r31, (6 * 4)
+
+ | Invoke the closure function
+ or %r5, %r30, 0 | calling stack
+ addu %r4, %r31, 0 | saved registers
+ addu %r3, %r31, (8 * 4) | return value
+ or %r2, %r13, %r0 | closure
+#ifdef PIC
+ bsr ffi_closure_OBSD_inner#plt
+#else
+ bsr ffi_closure_OBSD_inner
+#endif
+
+ | Figure out what to return as the function's return value
+ bb0 0, %r2, 1f | CIF_FLAGS_INT
+ ld %r2, %r31, (8 * 4)
+ br 9f
+
+1:
+ bb0 1, %r2, 1f | CIF_FLAGS_DINT
+ ld.d %r2, %r31, (8 * 4)
+ br 9f
+
+1:
+9:
+ subu %r31, %r30, 16
+ ld %r1, %r31, 0
+ ld %r30, %r31, 4
+ jmp.n %r1
+ addu %r31, %r31, 16
+ .size ffi_closure_OBSD,.-ffi_closure_OBSD
+
+/*
+ * ffi_closure_struct_OBSD(ffi_closure *closure); %r13
+ */
+ .align 4
+ .globl ffi_closure_struct_OBSD
+ .type ffi_closure_struct_OBSD, @function
+ffi_closure_struct_OBSD:
+ subu %r31, %r31, 16
+ st %r30, %r31, 4
+ st %r1, %r31, 0
+ addu %r30, %r31, 16
+
+ | Make room on the stack for saved register arguments
+ subu %r31, %r31, (8 * 4)
+ st.d %r2, %r31, (0 * 4)
+ st.d %r4, %r31, (2 * 4)
+ st.d %r6, %r31, (4 * 4)
+ st.d %r8, %r31, (6 * 4)
+
+ | Invoke the closure function
+ or %r5, %r30, 0 | calling stack
+ addu %r4, %r31, 0 | saved registers
+ or %r3, %r12, 0 | return value
+ or %r2, %r13, %r0 | closure
+#ifdef PIC
+ bsr ffi_closure_OBSD_inner#plt
+#else
+ bsr ffi_closure_OBSD_inner
+#endif
+
+ subu %r31, %r30, 16
+ ld %r1, %r31, 0
+ ld %r30, %r31, 4
+ jmp.n %r1
+ addu %r31, %r31, 16
+ .size ffi_closure_struct_OBSD,.-ffi_closure_struct_OBSD
diff --git a/jni/ruby/ext/fiddle/libffi-3.2.1/src/metag/ffi.c b/jni/ruby/ext/fiddle/libffi-3.2.1/src/metag/ffi.c
new file mode 100644
index 0000000..46b383e
--- /dev/null
+++ b/jni/ruby/ext/fiddle/libffi-3.2.1/src/metag/ffi.c
@@ -0,0 +1,330 @@
+/* ----------------------------------------------------------------------
+ ffi.c - Copyright (c) 2013 Imagination Technologies
+
+ Meta Foreign Function Interface
+ Permission is hereby granted, free of charge, to any person obtaining
+ a copy of this software and associated documentation files (the
+ `Software''), to deal in the Software without restriction, including
+ without limitation the rights to use, copy, modify, merge, publish,
+ distribute, sublicense, and/or sell copies of the Software, and to
+ permit persons to whom the Software is furnished to do so, subject to
+ the following conditions:
+
+ The above copyright notice and this permission notice shall be included
+ in all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED `AS IS'', WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ IN NO EVENT SHALL SIMON POSNJAK BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ OTHER DEALINGS IN THE SOFTWARE.
+----------------------------------------------------------------------- */
+
+#include <ffi.h>
+#include <ffi_common.h>
+
+#include <stdlib.h>
+
+#define MIN(a,b) (((a) < (b)) ? (a) : (b))
+
+/*
+ * ffi_prep_args is called by the assembly routine once stack space has been
+ * allocated for the function's arguments
+ */
+
+unsigned int ffi_prep_args(char *stack, extended_cif *ecif)
+{
+ register unsigned int i;
+ register void **p_argv;
+ register char *argp;
+ register ffi_type **p_arg;
+
+ argp = stack;
+
+ /* Store return value */
+ if ( ecif->cif->flags == FFI_TYPE_STRUCT ) {
+ argp -= 4;
+ *(void **) argp = ecif->rvalue;
+ }
+
+ p_argv = ecif->avalue;
+
+ /* point to next location */
+ for (i = ecif->cif->nargs, p_arg = ecif->cif->arg_types; (i != 0); i--, p_arg++, p_argv++)
+ {
+ size_t z;
+
+ /* Move argp to address of argument */
+ z = (*p_arg)->size;
+ argp -= z;
+
+ /* Align if necessary */
+ argp = (char *) ALIGN_DOWN(ALIGN_DOWN(argp, (*p_arg)->alignment), 4);
+
+ if (z < sizeof(int)) {
+ z = sizeof(int);
+ switch ((*p_arg)->type)
+ {
+ case FFI_TYPE_SINT8:
+ *(signed int *) argp = (signed int)*(SINT8 *)(* p_argv);
+ break;
+ case FFI_TYPE_UINT8:
+ *(unsigned int *) argp = (unsigned int)*(UINT8 *)(* p_argv);
+ break;
+ case FFI_TYPE_SINT16:
+ *(signed int *) argp = (signed int)*(SINT16 *)(* p_argv);
+ break;
+ case FFI_TYPE_UINT16:
+ *(unsigned int *) argp = (unsigned int)*(UINT16 *)(* p_argv);
+ case FFI_TYPE_STRUCT:
+ memcpy(argp, *p_argv, (*p_arg)->size);
+ break;
+ default:
+ FFI_ASSERT(0);
+ }
+ } else if ( z == sizeof(int)) {
+ *(unsigned int *) argp = (unsigned int)*(UINT32 *)(* p_argv);
+ } else {
+ memcpy(argp, *p_argv, z);
+ }
+ }
+
+ /* return the size of the arguments to be passed in registers,
+ padded to an 8 byte boundary to preserve stack alignment */
+ return ALIGN(MIN(stack - argp, 6*4), 8);
+}
+
+/* Perform machine dependent cif processing */
+ffi_status ffi_prep_cif_machdep(ffi_cif *cif)
+{
+ ffi_type **ptr;
+ unsigned i, bytes = 0;
+
+ for (ptr = cif->arg_types, i = cif->nargs; i > 0; i--, ptr++) {
+ if ((*ptr)->size == 0)
+ return FFI_BAD_TYPEDEF;
+
+ /* Perform a sanity check on the argument type, do this
+ check after the initialization. */
+ FFI_ASSERT_VALID_TYPE(*ptr);
+
+ /* Add any padding if necessary */
+ if (((*ptr)->alignment - 1) & bytes)
+ bytes = ALIGN(bytes, (*ptr)->alignment);
+
+ bytes += ALIGN((*ptr)->size, 4);
+ }
+
+ /* Ensure arg space is aligned to an 8-byte boundary */
+ bytes = ALIGN(bytes, 8);
+
+ /* Make space for the return structure pointer */
+ if (cif->rtype->type == FFI_TYPE_STRUCT) {
+ bytes += sizeof(void*);
+
+ /* Ensure stack is aligned to an 8-byte boundary */
+ bytes = ALIGN(bytes, 8);
+ }
+
+ cif->bytes = bytes;
+
+ /* Set the return type flag */
+ switch (cif->rtype->type) {
+ case FFI_TYPE_VOID:
+ case FFI_TYPE_FLOAT:
+ case FFI_TYPE_DOUBLE:
+ cif->flags = (unsigned) cif->rtype->type;
+ break;
+ case FFI_TYPE_SINT64:
+ case FFI_TYPE_UINT64:
+ cif->flags = (unsigned) FFI_TYPE_SINT64;
+ break;
+ case FFI_TYPE_STRUCT:
+ /* Meta can store return values which are <= 64 bits */
+ if (cif->rtype->size <= 4)
+ /* Returned to D0Re0 as 32-bit value */
+ cif->flags = (unsigned)FFI_TYPE_INT;
+ else if ((cif->rtype->size > 4) && (cif->rtype->size <= 8))
+ /* Returned valued is stored to D1Re0|R0Re0 */
+ cif->flags = (unsigned)FFI_TYPE_DOUBLE;
+ else
+ /* value stored in memory */
+ cif->flags = (unsigned)FFI_TYPE_STRUCT;
+ break;
+ default:
+ cif->flags = (unsigned)FFI_TYPE_INT;
+ break;
+ }
+ return FFI_OK;
+}
+
+extern void ffi_call_SYSV(void (*fn)(void), extended_cif *, unsigned, unsigned, double *);
+
+/*
+ * Exported in API. Entry point
+ * cif -> ffi_cif object
+ * fn -> function pointer
+ * rvalue -> pointer to return value
+ * avalue -> vector of void * pointers pointing to memory locations holding the
+ * arguments
+ */
+void ffi_call(ffi_cif *cif, void (*fn)(void), void *rvalue, void **avalue)
+{
+ extended_cif ecif;
+
+ int small_struct = (((cif->flags == FFI_TYPE_INT) || (cif->flags == FFI_TYPE_DOUBLE)) && (cif->rtype->type == FFI_TYPE_STRUCT));
+ ecif.cif = cif;
+ ecif.avalue = avalue;
+
+ double temp;
+
+ /*
+ * If the return value is a struct and we don't have a return value address
+ * then we need to make one
+ */
+
+ if ((rvalue == NULL ) && (cif->flags == FFI_TYPE_STRUCT))
+ ecif.rvalue = alloca(cif->rtype->size);
+ else if (small_struct)
+ ecif.rvalue = &temp;
+ else
+ ecif.rvalue = rvalue;
+
+ switch (cif->abi) {
+ case FFI_SYSV:
+ ffi_call_SYSV(fn, &ecif, cif->bytes, cif->flags, ecif.rvalue);
+ break;
+ default:
+ FFI_ASSERT(0);
+ break;
+ }
+
+ if (small_struct)
+ memcpy (rvalue, &temp, cif->rtype->size);
+}
+
+/* private members */
+
+static void ffi_prep_incoming_args_SYSV (char *, void **, void **,
+ ffi_cif*, float *);
+
+void ffi_closure_SYSV (ffi_closure *);
+
+/* Do NOT change that without changing the FFI_TRAMPOLINE_SIZE */
+extern unsigned int ffi_metag_trampoline[10]; /* 10 instructions */
+
+/* end of private members */
+
+/*
+ * __tramp: trampoline memory location
+ * __fun: assembly routine
+ * __ctx: memory location for wrapper
+ *
+ * At this point, tramp[0] == __ctx !
+ */
+void ffi_init_trampoline(unsigned char *__tramp, unsigned int __fun, unsigned int __ctx) {
+ memcpy (__tramp, ffi_metag_trampoline, sizeof(ffi_metag_trampoline));
+ *(unsigned int*) &__tramp[40] = __ctx;
+ *(unsigned int*) &__tramp[44] = __fun;
+ /* This will flush the instruction cache */
+ __builtin_meta2_cachewd(&__tramp[0], 1);
+ __builtin_meta2_cachewd(&__tramp[47], 1);
+}
+
+
+
+/* the cif must already be prepared */
+
+ffi_status
+ffi_prep_closure_loc (ffi_closure *closure,
+ ffi_cif* cif,
+ void (*fun)(ffi_cif*,void*,void**,void*),
+ void *user_data,
+ void *codeloc)
+{
+ void (*closure_func)(ffi_closure*) = NULL;
+
+ if (cif->abi == FFI_SYSV)
+ closure_func = &ffi_closure_SYSV;
+ else
+ return FFI_BAD_ABI;
+
+ ffi_init_trampoline(
+ (unsigned char*)&closure->tramp[0],
+ (unsigned int)closure_func,
+ (unsigned int)codeloc);
+
+ closure->cif = cif;
+ closure->user_data = user_data;
+ closure->fun = fun;
+
+ return FFI_OK;
+}
+
+
+/* This function is jumped to by the trampoline */
+unsigned int ffi_closure_SYSV_inner (closure, respp, args, vfp_args)
+ ffi_closure *closure;
+ void **respp;
+ void *args;
+ void *vfp_args;
+{
+ ffi_cif *cif;
+ void **arg_area;
+
+ cif = closure->cif;
+ arg_area = (void**) alloca (cif->nargs * sizeof (void*));
+
+ /*
+ * This call will initialize ARG_AREA, such that each
+ * element in that array points to the corresponding
+ * value on the stack; and if the function returns
+ * a structure, it will re-set RESP to point to the
+ * structure return address.
+ */
+ ffi_prep_incoming_args_SYSV(args, respp, arg_area, cif, vfp_args);
+
+ (closure->fun) ( cif, *respp, arg_area, closure->user_data);
+
+ return cif->flags;
+}
+
+static void ffi_prep_incoming_args_SYSV(char *stack, void **rvalue,
+ void **avalue, ffi_cif *cif,
+ float *vfp_stack)
+{
+ register unsigned int i;
+ register void **p_argv;
+ register char *argp;
+ register ffi_type **p_arg;
+
+ /* stack points to original arguments */
+ argp = stack;
+
+ /* Store return value */
+ if ( cif->flags == FFI_TYPE_STRUCT ) {
+ argp -= 4;
+ *rvalue = *(void **) argp;
+ }
+
+ p_argv = avalue;
+
+ for (i = cif->nargs, p_arg = cif->arg_types; (i != 0); i--, p_arg++) {
+ size_t z;
+ size_t alignment;
+
+ alignment = (*p_arg)->alignment;
+ if (alignment < 4)
+ alignment = 4;
+ if ((alignment - 1) & (unsigned)argp)
+ argp = (char *) ALIGN(argp, alignment);
+
+ z = (*p_arg)->size;
+ *p_argv = (void*) argp;
+ p_argv++;
+ argp -= z;
+ }
+ return;
+}
diff --git a/jni/ruby/ext/fiddle/libffi-3.2.1/src/metag/ffitarget.h b/jni/ruby/ext/fiddle/libffi-3.2.1/src/metag/ffitarget.h
new file mode 100644
index 0000000..7b9dbeb
--- /dev/null
+++ b/jni/ruby/ext/fiddle/libffi-3.2.1/src/metag/ffitarget.h
@@ -0,0 +1,53 @@
+/* -----------------------------------------------------------------*-C-*-
+ ffitarget.h - Copyright (c) 2013 Imagination Technologies Ltd.
+ Target configuration macros for Meta
+
+ Permission is hereby granted, free of charge, to any person obtaining
+ a copy of this software and associated documentation files (the
+ ``Software''), to deal in the Software without restriction, including
+ without limitation the rights to use, copy, modify, merge, publish,
+ distribute, sublicense, and/or sell copies of the Software, and to
+ permit persons to whom the Software is furnished to do so, subject to
+ the following conditions:
+
+ The above copyright notice and this permission notice shall be included
+ in all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND,
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+ HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ DEALINGS IN THE SOFTWARE.
+
+ ----------------------------------------------------------------------- */
+
+#ifndef LIBFFI_TARGET_H
+#define LIBFFI_TARGET_H
+
+#ifndef LIBFFI_H
+#error "Please do not include ffitarget.h directly into your source. Use ffi.h instead."
+#endif
+
+#ifndef LIBFFI_ASM
+typedef unsigned long ffi_arg;
+typedef signed long ffi_sarg;
+
+typedef enum ffi_abi {
+ FFI_FIRST_ABI = 0,
+ FFI_SYSV,
+ FFI_DEFAULT_ABI = FFI_SYSV,
+ FFI_LAST_ABI = FFI_DEFAULT_ABI + 1,
+} ffi_abi;
+#endif
+
+/* ---- Definitions for closures ----------------------------------------- */
+
+#define FFI_CLOSURES 1
+#define FFI_TRAMPOLINE_SIZE 48
+#define FFI_NATIVE_RAW_API 0
+
+#endif
+
diff --git a/jni/ruby/ext/fiddle/libffi-3.2.1/src/metag/sysv.S b/jni/ruby/ext/fiddle/libffi-3.2.1/src/metag/sysv.S
new file mode 100644
index 0000000..b4b2a3b
--- /dev/null
+++ b/jni/ruby/ext/fiddle/libffi-3.2.1/src/metag/sysv.S
@@ -0,0 +1,311 @@
+/* -----------------------------------------------------------------------
+ sysv.S - Copyright (c) 2013 Imagination Technologies Ltd.
+
+ Meta Foreign Function Interface
+
+ Permission is hereby granted, free of charge, to any person obtaining
+ a copy of this software and associated documentation files (the
+ ``Software''), to deal in the Software without restriction, including
+ without limitation the rights to use, copy, modify, merge, publish,
+ distribute, sublicense, and/or sell copies of the Software, and to
+ permit persons to whom the Software is furnished to do so, subject to
+ the following conditions:
+
+ The above copyright notice and this permission notice shall be included
+ in all copies or substantial portions of the Software.
+
+
+ THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND,
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+ HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ DEALINGS IN THE SOFTWARE.
+ ----------------------------------------------------------------------- */
+
+#define LIBFFI_ASM
+#include <fficonfig.h>
+#include <ffi.h>
+#ifdef HAVE_MACHINE_ASM_H
+#include <machine/asm.h>
+#else
+#ifdef __USER_LABEL_PREFIX__
+#define CONCAT1(a, b) CONCAT2(a, b)
+#define CONCAT2(a, b) a ## b
+
+/* Use the right prefix for global labels. */
+#define CNAME(x) CONCAT1 (__USER_LABEL_PREFIX__, x)
+#else
+#define CNAME(x) x
+#endif
+#define ENTRY(x) .globl CNAME(x); .type CNAME(x), %function; CNAME(x):
+#endif
+
+#ifdef __ELF__
+#define LSYM(x) .x
+#else
+#define LSYM(x) x
+#endif
+
+.macro call_reg x=
+ .text
+ .balign 4
+ mov D1RtP, \x
+ swap D1RtP, PC
+.endm
+
+! Save register arguments
+.macro SAVE_ARGS
+ .text
+ .balign 4
+ setl [A0StP++], D0Ar6, D1Ar5
+ setl [A0StP++], D0Ar4, D1Ar3
+ setl [A0StP++], D0Ar2, D1Ar1
+.endm
+
+! Save retrun, frame pointer and other regs
+.macro SAVE_REGS regs=
+ .text
+ .balign 4
+ setl [A0StP++], D0FrT, D1RtP
+ ! Needs to be a pair of regs
+ .ifnc "\regs",""
+ setl [A0StP++], \regs
+ .endif
+.endm
+
+! Declare a global function
+.macro METAG_FUNC_START name
+ .text
+ .balign 4
+ ENTRY(\name)
+.endm
+
+! Return registers from the stack. Reverse SAVE_REGS operation
+.macro RET_REGS regs=, cond=
+ .ifnc "\regs", ""
+ getl \regs, [--A0StP]
+ .endif
+ getl D0FrT, D1RtP, [--A0StP]
+.endm
+
+! Return arguments
+.macro RET_ARGS
+ getl D0Ar2, D1Ar1, [--A0StP]
+ getl D0Ar4, D1Ar3, [--A0StP]
+ getl D0Ar6, D1Ar5, [--A0StP]
+.endm
+
+
+ ! D1Ar1: fn
+ ! D0Ar2: &ecif
+ ! D1Ar3: cif->bytes
+ ! D0Ar4: fig->flags
+ ! D1Ar5: ecif.rvalue
+
+ ! This assumes we are using GNU as
+METAG_FUNC_START ffi_call_SYSV
+ ! Save argument registers
+
+ SAVE_ARGS
+
+ ! new frame
+ mov D0FrT, A0FrP
+ add A0FrP, A0StP, #0
+
+ ! Preserve the old frame pointer
+ SAVE_REGS "D1.5, D0.5"
+
+ ! Make room for new args. cifs->bytes is the total space for input
+ ! and return arguments
+
+ add A0StP, A0StP, D1Ar3
+
+ ! Preserve cifs->bytes & fn
+ mov D0.5, D1Ar3
+ mov D1.5, D1Ar1
+
+ ! Place all of the ffi_prep_args in position
+ mov D1Ar1, A0StP
+
+ ! Call ffi_prep_args(stack, &ecif)
+#ifdef __PIC__
+ callr D1RtP, CNAME(ffi_prep_args@PLT)
+#else
+ callr D1RtP, CNAME(ffi_prep_args)
+#endif
+
+ ! Restore fn pointer
+
+ ! The foreign stack should look like this
+ ! XXXXX XXXXXX <--- stack pointer
+ ! FnArgN rvalue
+ ! FnArgN+2 FnArgN+1
+ ! FnArgN+4 FnArgN+3
+ ! ....
+ !
+
+ ! A0StP now points to the first (or return) argument + 4
+
+ ! Preserve cif->bytes
+ getl D0Ar2, D1Ar1, [--A0StP]
+ getl D0Ar4, D1Ar3, [--A0StP]
+ getl D0Ar6, D1Ar5, [--A0StP]
+
+ ! Place A0StP to the first argument again
+ add A0StP, A0StP, #24 ! That's because we loaded 6 regs x 4 byte each
+
+ ! A0FrP points to the initial stack without the reserved space for the
+ ! cifs->bytes, whilst A0StP points to the stack after the space allocation
+
+ ! fn was the first argument of ffi_call_SYSV.
+ ! The stack at this point looks like this:
+ !
+ ! A0StP(on entry to _SYSV) -> Arg6 Arg5 | low
+ ! Arg4 Arg3 |
+ ! Arg2 Arg1 |
+ ! A0FrP ----> D0FrtP D1RtP |
+ ! D1.5 D0.5 |
+ ! A0StP(bf prep_args) -> FnArgn FnArgn-1 |
+ ! FnArgn-2FnArgn-3 |
+ ! ................ | <= cifs->bytes
+ ! FnArg4 FnArg3 |
+ ! A0StP (prv_A0StP+cifs->bytes) FnArg2 FnArg1 | high
+ !
+ ! fn was in Arg1 so it's located in in A0FrP+#-0xC
+ !
+
+ ! D0Re0 contains the size of arguments stored in registers
+ sub A0StP, A0StP, D0Re0
+
+ ! Arg1 is the function pointer for the foreign call. This has been
+ ! preserved in D1.5
+
+ ! Time to call (fn). Arguments should be like this:
+ ! Arg1-Arg6 are loaded to regs
+ ! The rest of the arguments are stored in stack pointed by A0StP
+
+ call_reg D1.5
+
+ ! Reset stack.
+
+ mov A0StP, A0FrP
+
+ ! Load Arg1 with the pointer to storage for the return type
+ ! This was stored in Arg5
+
+ getd D1Ar1, [A0FrP+#-20]
+
+ ! Load D0Ar2 with the return type code. This was stored in Arg4 (flags)
+
+ getd D0Ar2, [A0FrP+#-16]
+
+ ! We are ready to start processing the return value
+ ! D0Re0 (and D1Re0) hold the return value
+
+ ! If the return value is NULL, assume no return value
+ cmp D1Ar1, #0
+ beq LSYM(Lepilogue)
+
+ ! return INT
+ cmp D0Ar2, #FFI_TYPE_INT
+ ! Sadly, there is no setd{cc} instruction so we need to workaround that
+ bne .INT64
+ setd [D1Ar1], D0Re0
+ b LSYM(Lepilogue)
+
+ ! return INT64
+.INT64:
+ cmp D0Ar2, #FFI_TYPE_SINT64
+ setleq [D1Ar1], D0Re0, D1Re0
+
+ ! return DOUBLE
+ cmp D0Ar2, #FFI_TYPE_DOUBLE
+ setl [D1AR1++], D0Re0, D1Re0
+
+LSYM(Lepilogue):
+ ! At this point, the stack pointer points right after the argument
+ ! saved area. We need to restore 4 regs, therefore we need to move
+ ! 16 bytes ahead.
+ add A0StP, A0StP, #16
+ RET_REGS "D1.5, D0.5"
+ RET_ARGS
+ getd D0Re0, [A0StP]
+ mov A0FrP, D0FrT
+ swap D1RtP, PC
+
+.ffi_call_SYSV_end:
+ .size CNAME(ffi_call_SYSV),.ffi_call_SYSV_end-CNAME(ffi_call_SYSV)
+
+
+/*
+ (called by ffi_metag_trampoline)
+ void ffi_closure_SYSV (ffi_closure*)
+
+ (called by ffi_closure_SYSV)
+ unsigned int FFI_HIDDEN
+ ffi_closure_SYSV_inner (closure,respp, args)
+ ffi_closure *closure;
+ void **respp;
+ void *args;
+*/
+
+METAG_FUNC_START ffi_closure_SYSV
+ ! We assume that D1Ar1 holds the address of the
+ ! ffi_closure struct. We will use that to fetch the
+ ! arguments. The stack pointer points to an empty space
+ ! and it is ready to store more data.
+
+ ! D1Ar1 is ready
+ ! Allocate stack space for return value
+ add A0StP, A0StP, #8
+ ! Store it to D0Ar2
+ sub D0Ar2, A0StP, #8
+
+ sub D1Ar3, A0FrP, #4
+
+ ! D1Ar3 contains the address of the original D1Ar1 argument
+ ! We need to subtract #4 later on
+
+ ! Preverve D0Ar2
+ mov D0.5, D0Ar2
+
+#ifdef __PIC__
+ callr D1RtP, CNAME(ffi_closure_SYSV_inner@PLT)
+#else
+ callr D1RtP, CNAME(ffi_closure_SYSV_inner)
+#endif
+
+ ! Check the return value and store it to D0.5
+ cmp D0Re0, #FFI_TYPE_INT
+ beq .Lretint
+ cmp D0Re0, #FFI_TYPE_DOUBLE
+ beq .Lretdouble
+.Lclosure_epilogue:
+ sub A0StP, A0StP, #8
+ RET_REGS "D1.5, D0.5"
+ RET_ARGS
+ swap D1RtP, PC
+
+.Lretint:
+ setd [D0.5], D0Re0
+ b .Lclosure_epilogue
+.Lretdouble:
+ setl [D0.5++], D0Re0, D1Re0
+ b .Lclosure_epilogue
+.ffi_closure_SYSV_end:
+.size CNAME(ffi_closure_SYSV),.ffi_closure_SYSV_end-CNAME(ffi_closure_SYSV)
+
+
+ENTRY(ffi_metag_trampoline)
+ SAVE_ARGS
+ ! New frame
+ mov A0FrP, A0StP
+ SAVE_REGS "D1.5, D0.5"
+ mov D0.5, PC
+ ! Load D1Ar1 the value of ffi_metag_trampoline
+ getd D1Ar1, [D0.5 + #8]
+ ! Jump to ffi_closure_SYSV
+ getd PC, [D0.5 + #12]
diff --git a/jni/ruby/ext/fiddle/libffi-3.2.1/src/microblaze/ffi.c b/jni/ruby/ext/fiddle/libffi-3.2.1/src/microblaze/ffi.c
new file mode 100644
index 0000000..ea962ea
--- /dev/null
+++ b/jni/ruby/ext/fiddle/libffi-3.2.1/src/microblaze/ffi.c
@@ -0,0 +1,321 @@
+/* -----------------------------------------------------------------------
+ ffi.c - Copyright (c) 2012, 2013 Xilinx, Inc
+
+ MicroBlaze Foreign Function Interface
+
+ Permission is hereby granted, free of charge, to any person obtaining
+ a copy of this software and associated documentation files (the
+ ``Software''), to deal in the Software without restriction, including
+ without limitation the rights to use, copy, modify, merge, publish,
+ distribute, sublicense, and/or sell copies of the Software, and to
+ permit persons to whom the Software is furnished to do so, subject to
+ the following conditions:
+
+ The above copyright notice and this permission notice shall be included
+ in all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND,
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+ HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ DEALINGS IN THE SOFTWARE.
+ ----------------------------------------------------------------------- */
+
+#include <ffi.h>
+#include <ffi_common.h>
+
+extern void ffi_call_SYSV(void (*)(void*, extended_cif*), extended_cif*,
+ unsigned int, unsigned int, unsigned int*, void (*fn)(void),
+ unsigned int, unsigned int);
+
+extern void ffi_closure_SYSV(void);
+
+#define WORD_SIZE sizeof(unsigned int)
+#define ARGS_REGISTER_SIZE (WORD_SIZE * 6)
+#define WORD_ALIGN(x) ALIGN(x, WORD_SIZE)
+
+/* ffi_prep_args is called by the assembly routine once stack space
+ has been allocated for the function's arguments */
+void ffi_prep_args(void* stack, extended_cif* ecif)
+{
+ unsigned int i;
+ ffi_type** p_arg;
+ void** p_argv;
+ void* stack_args_p = stack;
+
+ p_argv = ecif->avalue;
+
+ if (ecif == NULL || ecif->cif == NULL) {
+ return; /* no description to prepare */
+ }
+
+ if ((ecif->cif->rtype != NULL) &&
+ (ecif->cif->rtype->type == FFI_TYPE_STRUCT))
+ {
+ /* if return type is a struct which is referenced on the stack/reg5,
+ * by a pointer. Stored the return value pointer in r5.
+ */
+ char* addr = stack_args_p;
+ memcpy(addr, &(ecif->rvalue), WORD_SIZE);
+ stack_args_p += WORD_SIZE;
+ }
+
+ if (ecif->avalue == NULL) {
+ return; /* no arguments to prepare */
+ }
+
+ for (i = 0, p_arg = ecif->cif->arg_types; i < ecif->cif->nargs;
+ i++, p_arg++)
+ {
+ size_t size = (*p_arg)->size;
+ int type = (*p_arg)->type;
+ void* value = p_argv[i];
+ char* addr = stack_args_p;
+ int aligned_size = WORD_ALIGN(size);
+
+ /* force word alignment on the stack */
+ stack_args_p += aligned_size;
+
+ switch (type)
+ {
+ case FFI_TYPE_UINT8:
+ *(unsigned int *)addr = (unsigned int)*(UINT8*)(value);
+ break;
+ case FFI_TYPE_SINT8:
+ *(signed int *)addr = (signed int)*(SINT8*)(value);
+ break;
+ case FFI_TYPE_UINT16:
+ *(unsigned int *)addr = (unsigned int)*(UINT16*)(value);
+ break;
+ case FFI_TYPE_SINT16:
+ *(signed int *)addr = (signed int)*(SINT16*)(value);
+ break;
+ case FFI_TYPE_STRUCT:
+#if __BIG_ENDIAN__
+ /*
+ * MicroBlaze toolchain appears to emit:
+ * bsrli r5, r5, 8 (caller)
+ * ...
+ * <branch to callee>
+ * ...
+ * bslli r5, r5, 8 (callee)
+ *
+ * For structs like "struct a { uint8_t a[3]; };", when passed
+ * by value.
+ *
+ * Structs like "struct b { uint16_t a; };" are also expected
+ * to be packed strangely in registers.
+ *
+ * This appears to be because the microblaze toolchain expects
+ * "struct b == uint16_t", which is only any issue for big
+ * endian.
+ *
+ * The following is a work around for big-endian only, for the
+ * above mentioned case, it will re-align the contents of a
+ * <= 3-byte struct value.
+ */
+ if (size < WORD_SIZE)
+ {
+ memcpy (addr + (WORD_SIZE - size), value, size);
+ break;
+ }
+#endif
+ case FFI_TYPE_SINT32:
+ case FFI_TYPE_UINT32:
+ case FFI_TYPE_FLOAT:
+ case FFI_TYPE_SINT64:
+ case FFI_TYPE_UINT64:
+ case FFI_TYPE_DOUBLE:
+ default:
+ memcpy(addr, value, aligned_size);
+ }
+ }
+}
+
+ffi_status ffi_prep_cif_machdep(ffi_cif* cif)
+{
+ /* check ABI */
+ switch (cif->abi)
+ {
+ case FFI_SYSV:
+ break;
+ default:
+ return FFI_BAD_ABI;
+ }
+ return FFI_OK;
+}
+
+void ffi_call(ffi_cif* cif, void (*fn)(void), void* rvalue, void** avalue)
+{
+ extended_cif ecif;
+ ecif.cif = cif;
+ ecif.avalue = avalue;
+
+ /* If the return value is a struct and we don't have a return */
+ /* value address then we need to make one */
+ if ((rvalue == NULL) && (cif->rtype->type == FFI_TYPE_STRUCT)) {
+ ecif.rvalue = alloca(cif->rtype->size);
+ } else {
+ ecif.rvalue = rvalue;
+ }
+
+ switch (cif->abi)
+ {
+ case FFI_SYSV:
+ ffi_call_SYSV(ffi_prep_args, &ecif, cif->bytes, cif->flags,
+ ecif.rvalue, fn, cif->rtype->type, cif->rtype->size);
+ break;
+ default:
+ FFI_ASSERT(0);
+ break;
+ }
+}
+
+void ffi_closure_call_SYSV(void* register_args, void* stack_args,
+ ffi_closure* closure, void* rvalue,
+ unsigned int* rtype, unsigned int* rsize)
+{
+ /* prepare arguments for closure call */
+ ffi_cif* cif = closure->cif;
+ ffi_type** arg_types = cif->arg_types;
+
+ /* re-allocate data for the args. This needs to be done in order to keep
+ * multi-word objects (e.g. structs) in contiguous memory. Callers are not
+ * required to store the value of args in the lower 6 words in the stack
+ * (although they are allocated in the stack).
+ */
+ char* stackclone = alloca(cif->bytes);
+ void** avalue = alloca(cif->nargs * sizeof(void*));
+ void* struct_rvalue = NULL;
+ char* ptr = stackclone;
+ int i;
+
+ /* copy registers into stack clone */
+ int registers_used = cif->bytes;
+ if (registers_used > ARGS_REGISTER_SIZE) {
+ registers_used = ARGS_REGISTER_SIZE;
+ }
+ memcpy(stackclone, register_args, registers_used);
+
+ /* copy stack allocated args into stack clone */
+ if (cif->bytes > ARGS_REGISTER_SIZE) {
+ int stack_used = cif->bytes - ARGS_REGISTER_SIZE;
+ memcpy(stackclone + ARGS_REGISTER_SIZE, stack_args, stack_used);
+ }
+
+ /* preserve struct type return pointer passing */
+ if ((cif->rtype != NULL) && (cif->rtype->type == FFI_TYPE_STRUCT)) {
+ struct_rvalue = *((void**)ptr);
+ ptr += WORD_SIZE;
+ }
+
+ /* populate arg pointer list */
+ for (i = 0; i < cif->nargs; i++)
+ {
+ switch (arg_types[i]->type)
+ {
+ case FFI_TYPE_SINT8:
+ case FFI_TYPE_UINT8:
+#ifdef __BIG_ENDIAN__
+ avalue[i] = ptr + 3;
+#else
+ avalue[i] = ptr;
+#endif
+ break;
+ case FFI_TYPE_SINT16:
+ case FFI_TYPE_UINT16:
+#ifdef __BIG_ENDIAN__
+ avalue[i] = ptr + 2;
+#else
+ avalue[i] = ptr;
+#endif
+ break;
+ case FFI_TYPE_STRUCT:
+#if __BIG_ENDIAN__
+ /*
+ * Work around strange ABI behaviour.
+ * (see info in ffi_prep_args)
+ */
+ if (arg_types[i]->size < WORD_SIZE)
+ {
+ memcpy (ptr, ptr + (WORD_SIZE - arg_types[i]->size), arg_types[i]->size);
+ }
+#endif
+ avalue[i] = (void*)ptr;
+ break;
+ case FFI_TYPE_UINT64:
+ case FFI_TYPE_SINT64:
+ case FFI_TYPE_DOUBLE:
+ avalue[i] = ptr;
+ break;
+ case FFI_TYPE_SINT32:
+ case FFI_TYPE_UINT32:
+ case FFI_TYPE_FLOAT:
+ default:
+ /* default 4-byte argument */
+ avalue[i] = ptr;
+ break;
+ }
+ ptr += WORD_ALIGN(arg_types[i]->size);
+ }
+
+ /* set the return type info passed back to the wrapper */
+ *rsize = cif->rtype->size;
+ *rtype = cif->rtype->type;
+ if (struct_rvalue != NULL) {
+ closure->fun(cif, struct_rvalue, avalue, closure->user_data);
+ /* copy struct return pointer value into function return value */
+ *((void**)rvalue) = struct_rvalue;
+ } else {
+ closure->fun(cif, rvalue, avalue, closure->user_data);
+ }
+}
+
+ffi_status ffi_prep_closure_loc(
+ ffi_closure* closure, ffi_cif* cif,
+ void (*fun)(ffi_cif*, void*, void**, void*),
+ void* user_data, void* codeloc)
+{
+ unsigned long* tramp = (unsigned long*)&(closure->tramp[0]);
+ unsigned long cls = (unsigned long)codeloc;
+ unsigned long fn = 0;
+ unsigned long fn_closure_call_sysv = (unsigned long)ffi_closure_call_SYSV;
+
+ closure->cif = cif;
+ closure->fun = fun;
+ closure->user_data = user_data;
+
+ switch (cif->abi)
+ {
+ case FFI_SYSV:
+ fn = (unsigned long)ffi_closure_SYSV;
+
+ /* load r11 (temp) with fn */
+ /* imm fn(upper) */
+ tramp[0] = 0xb0000000 | ((fn >> 16) & 0xffff);
+ /* addik r11, r0, fn(lower) */
+ tramp[1] = 0x31600000 | (fn & 0xffff);
+
+ /* load r12 (temp) with cls */
+ /* imm cls(upper) */
+ tramp[2] = 0xb0000000 | ((cls >> 16) & 0xffff);
+ /* addik r12, r0, cls(lower) */
+ tramp[3] = 0x31800000 | (cls & 0xffff);
+
+ /* load r3 (temp) with ffi_closure_call_SYSV */
+ /* imm fn_closure_call_sysv(upper) */
+ tramp[4] = 0xb0000000 | ((fn_closure_call_sysv >> 16) & 0xffff);
+ /* addik r3, r0, fn_closure_call_sysv(lower) */
+ tramp[5] = 0x30600000 | (fn_closure_call_sysv & 0xffff);
+ /* branch/jump to address stored in r11 (fn) */
+ tramp[6] = 0x98085800; /* bra r11 */
+
+ break;
+ default:
+ return FFI_BAD_ABI;
+ }
+ return FFI_OK;
+}
diff --git a/jni/ruby/ext/fiddle/libffi-3.2.1/src/microblaze/ffitarget.h b/jni/ruby/ext/fiddle/libffi-3.2.1/src/microblaze/ffitarget.h
new file mode 100644
index 0000000..c6fa5a4
--- /dev/null
+++ b/jni/ruby/ext/fiddle/libffi-3.2.1/src/microblaze/ffitarget.h
@@ -0,0 +1,53 @@
+/* -----------------------------------------------------------------------
+ ffitarget.h - Copyright (c) 2012, 2013 Xilinx, Inc
+
+ Target configuration macros for MicroBlaze.
+
+ Permission is hereby granted, free of charge, to any person obtaining
+ a copy of this software and associated documentation files (the
+ ``Software''), to deal in the Software without restriction, including
+ without limitation the rights to use, copy, modify, merge, publish,
+ distribute, sublicense, and/or sell copies of the Software, and to
+ permit persons to whom the Software is furnished to do so, subject to
+ the following conditions:
+
+ The above copyright notice and this permission notice shall be included
+ in all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND,
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+ HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ DEALINGS IN THE SOFTWARE.
+ ----------------------------------------------------------------------- */
+
+#ifndef LIBFFI_TARGET_H
+#define LIBFFI_TARGET_H
+
+#ifndef LIBFFI_H
+#error "Please do not include ffitarget.h directly into your source. Use ffi.h instead."
+#endif
+
+#ifndef LIBFFI_ASM
+typedef unsigned long ffi_arg;
+typedef signed long ffi_sarg;
+
+typedef enum ffi_abi {
+ FFI_FIRST_ABI = 0,
+ FFI_SYSV,
+ FFI_LAST_ABI,
+ FFI_DEFAULT_ABI = FFI_SYSV
+} ffi_abi;
+#endif
+
+/* Definitions for closures */
+
+#define FFI_CLOSURES 1
+#define FFI_NATIVE_RAW_API 0
+
+#define FFI_TRAMPOLINE_SIZE (4*8)
+
+#endif
diff --git a/jni/ruby/ext/fiddle/libffi-3.2.1/src/microblaze/sysv.S b/jni/ruby/ext/fiddle/libffi-3.2.1/src/microblaze/sysv.S
new file mode 100644
index 0000000..ea43e9d
--- /dev/null
+++ b/jni/ruby/ext/fiddle/libffi-3.2.1/src/microblaze/sysv.S
@@ -0,0 +1,302 @@
+/* -----------------------------------------------------------------------
+ sysv.S - Copyright (c) 2012, 2013 Xilinx, Inc
+
+ MicroBlaze Foreign Function Interface
+
+ Permission is hereby granted, free of charge, to any person obtaining
+ a copy of this software and associated documentation files (the
+ ``Software''), to deal in the Software without restriction, including
+ without limitation the rights to use, copy, modify, merge, publish,
+ distribute, sublicense, and/or sell copies of the Software, and to
+ permit persons to whom the Software is furnished to do so, subject to
+ the following conditions:
+
+ The above copyright notice and this permission notice shall be included
+ in all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND,
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+ HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ DEALINGS IN THE SOFTWARE.
+ ----------------------------------------------------------------------- */
+
+#define LIBFFI_ASM
+#include <fficonfig.h>
+#include <ffi.h>
+
+ /*
+ * arg[0] (r5) = ffi_prep_args,
+ * arg[1] (r6) = &ecif,
+ * arg[2] (r7) = cif->bytes,
+ * arg[3] (r8) = cif->flags,
+ * arg[4] (r9) = ecif.rvalue,
+ * arg[5] (r10) = fn
+ * arg[6] (sp[0]) = cif->rtype->type
+ * arg[7] (sp[4]) = cif->rtype->size
+ */
+ .text
+ .globl ffi_call_SYSV
+ .type ffi_call_SYSV, @function
+ffi_call_SYSV:
+ /* push callee saves */
+ addik r1, r1, -20
+ swi r19, r1, 0 /* Frame Pointer */
+ swi r20, r1, 4 /* PIC register */
+ swi r21, r1, 8 /* PIC register */
+ swi r22, r1, 12 /* save for locals */
+ swi r23, r1, 16 /* save for locals */
+
+ /* save the r5-r10 registers in the stack */
+ addik r1, r1, -24 /* increment sp to store 6x 32-bit words */
+ swi r5, r1, 0
+ swi r6, r1, 4
+ swi r7, r1, 8
+ swi r8, r1, 12
+ swi r9, r1, 16
+ swi r10, r1, 20
+
+ /* save function pointer */
+ addik r3, r5, 0 /* copy ffi_prep_args into r3 */
+ addik r22, r1, 0 /* save sp for unallocated args into r22 (callee-saved) */
+ addik r23, r10, 0 /* save function address into r23 (callee-saved) */
+
+ /* prepare stack with allocation for n (bytes = r7) args */
+ rsub r1, r7, r1 /* subtract bytes from sp */
+
+ /* prep args for ffi_prep_args call */
+ addik r5, r1, 0 /* store stack pointer into arg[0] */
+ /* r6 still holds ecif for arg[1] */
+
+ /* Call ffi_prep_args(stack, &ecif). */
+ addik r1, r1, -4
+ swi r15, r1, 0 /* store the link register in the frame */
+ brald r15, r3
+ nop /* branch has delay slot */
+ lwi r15, r1, 0
+ addik r1, r1, 4 /* restore the link register from the frame */
+ /* returns calling stack pointer location */
+
+ /* prepare args for fn call, prep_args populates them onto the stack */
+ lwi r5, r1, 0 /* arg[0] */
+ lwi r6, r1, 4 /* arg[1] */
+ lwi r7, r1, 8 /* arg[2] */
+ lwi r8, r1, 12 /* arg[3] */
+ lwi r9, r1, 16 /* arg[4] */
+ lwi r10, r1, 20 /* arg[5] */
+
+ /* call (fn) (...). */
+ addik r1, r1, -4
+ swi r15, r1, 0 /* store the link register in the frame */
+ brald r15, r23
+ nop /* branch has delay slot */
+ lwi r15, r1, 0
+ addik r1, r1, 4 /* restore the link register from the frame */
+
+ /* Remove the space we pushed for the args. */
+ addik r1, r22, 0 /* restore old SP */
+
+ /* restore this functions parameters */
+ lwi r5, r1, 0 /* arg[0] */
+ lwi r6, r1, 4 /* arg[1] */
+ lwi r7, r1, 8 /* arg[2] */
+ lwi r8, r1, 12 /* arg[3] */
+ lwi r9, r1, 16 /* arg[4] */
+ lwi r10, r1, 20 /* arg[5] */
+ addik r1, r1, 24 /* decrement sp to de-allocate 6x 32-bit words */
+
+ /* If the return value pointer is NULL, assume no return value. */
+ beqi r9, ffi_call_SYSV_end
+
+ lwi r22, r1, 48 /* get return type (20 for locals + 28 for arg[6]) */
+ lwi r23, r1, 52 /* get return size (20 for locals + 32 for arg[7]) */
+
+ /* Check if return type is actually a struct, do nothing */
+ rsubi r11, r22, FFI_TYPE_STRUCT
+ beqi r11, ffi_call_SYSV_end
+
+ /* Return 8bit */
+ rsubi r11, r23, 1
+ beqi r11, ffi_call_SYSV_store8
+
+ /* Return 16bit */
+ rsubi r11, r23, 2
+ beqi r11, ffi_call_SYSV_store16
+
+ /* Return 32bit */
+ rsubi r11, r23, 4
+ beqi r11, ffi_call_SYSV_store32
+
+ /* Return 64bit */
+ rsubi r11, r23, 8
+ beqi r11, ffi_call_SYSV_store64
+
+ /* Didn't match anything */
+ bri ffi_call_SYSV_end
+
+ffi_call_SYSV_store64:
+ swi r3, r9, 0 /* store word r3 into return value */
+ swi r4, r9, 4 /* store word r4 into return value */
+ bri ffi_call_SYSV_end
+
+ffi_call_SYSV_store32:
+ swi r3, r9, 0 /* store word r3 into return value */
+ bri ffi_call_SYSV_end
+
+ffi_call_SYSV_store16:
+#ifdef __BIG_ENDIAN__
+ shi r3, r9, 2 /* store half-word r3 into return value */
+#else
+ shi r3, r9, 0 /* store half-word r3 into return value */
+#endif
+ bri ffi_call_SYSV_end
+
+ffi_call_SYSV_store8:
+#ifdef __BIG_ENDIAN__
+ sbi r3, r9, 3 /* store byte r3 into return value */
+#else
+ sbi r3, r9, 0 /* store byte r3 into return value */
+#endif
+ bri ffi_call_SYSV_end
+
+ffi_call_SYSV_end:
+ /* callee restores */
+ lwi r19, r1, 0 /* frame pointer */
+ lwi r20, r1, 4 /* PIC register */
+ lwi r21, r1, 8 /* PIC register */
+ lwi r22, r1, 12
+ lwi r23, r1, 16
+ addik r1, r1, 20
+
+ /* return from sub-routine (with delay slot) */
+ rtsd r15, 8
+ nop
+
+ .size ffi_call_SYSV, . - ffi_call_SYSV
+
+/* ------------------------------------------------------------------------- */
+
+ /*
+ * args passed into this function, are passed down to the callee.
+ * this function is the target of the closure trampoline, as such r12 is
+ * a pointer to the closure object.
+ */
+ .text
+ .globl ffi_closure_SYSV
+ .type ffi_closure_SYSV, @function
+ffi_closure_SYSV:
+ /* push callee saves */
+ addik r11, r1, 28 /* save stack args start location (excluding regs/link) */
+ addik r1, r1, -12
+ swi r19, r1, 0 /* Frame Pointer */
+ swi r20, r1, 4 /* PIC register */
+ swi r21, r1, 8 /* PIC register */
+
+ /* store register args on stack */
+ addik r1, r1, -24
+ swi r5, r1, 0
+ swi r6, r1, 4
+ swi r7, r1, 8
+ swi r8, r1, 12
+ swi r9, r1, 16
+ swi r10, r1, 20
+
+ /* setup args */
+ addik r5, r1, 0 /* register_args */
+ addik r6, r11, 0 /* stack_args */
+ addik r7, r12, 0 /* closure object */
+ addik r1, r1, -8 /* allocate return value */
+ addik r8, r1, 0 /* void* rvalue */
+ addik r1, r1, -8 /* allocate for return type/size values */
+ addik r9, r1, 0 /* void* rtype */
+ addik r10, r1, 4 /* void* rsize */
+
+ /* call the wrap_call function */
+ addik r1, r1, -28 /* allocate args + link reg */
+ swi r15, r1, 0 /* store the link register in the frame */
+ brald r15, r3
+ nop /* branch has delay slot */
+ lwi r15, r1, 0
+ addik r1, r1, 28 /* restore the link register from the frame */
+
+ffi_closure_SYSV_prepare_return:
+ lwi r9, r1, 0 /* rtype */
+ lwi r10, r1, 4 /* rsize */
+ addik r1, r1, 8 /* de-allocate return info values */
+
+ /* Check if return type is actually a struct, store 4 bytes */
+ rsubi r11, r9, FFI_TYPE_STRUCT
+ beqi r11, ffi_closure_SYSV_store32
+
+ /* Return 8bit */
+ rsubi r11, r10, 1
+ beqi r11, ffi_closure_SYSV_store8
+
+ /* Return 16bit */
+ rsubi r11, r10, 2
+ beqi r11, ffi_closure_SYSV_store16
+
+ /* Return 32bit */
+ rsubi r11, r10, 4
+ beqi r11, ffi_closure_SYSV_store32
+
+ /* Return 64bit */
+ rsubi r11, r10, 8
+ beqi r11, ffi_closure_SYSV_store64
+
+ /* Didn't match anything */
+ bri ffi_closure_SYSV_end
+
+ffi_closure_SYSV_store64:
+ lwi r3, r1, 0 /* store word r3 into return value */
+ lwi r4, r1, 4 /* store word r4 into return value */
+ /* 64 bits == 2 words, no sign extend occurs */
+ bri ffi_closure_SYSV_end
+
+ffi_closure_SYSV_store32:
+ lwi r3, r1, 0 /* store word r3 into return value */
+ /* 32 bits == 1 word, no sign extend occurs */
+ bri ffi_closure_SYSV_end
+
+ffi_closure_SYSV_store16:
+#ifdef __BIG_ENDIAN__
+ lhui r3, r1, 2 /* store half-word r3 into return value */
+#else
+ lhui r3, r1, 0 /* store half-word r3 into return value */
+#endif
+ rsubi r11, r9, FFI_TYPE_SINT16
+ bnei r11, ffi_closure_SYSV_end
+ sext16 r3, r3 /* fix sign extend of sint8 */
+ bri ffi_closure_SYSV_end
+
+ffi_closure_SYSV_store8:
+#ifdef __BIG_ENDIAN__
+ lbui r3, r1, 3 /* store byte r3 into return value */
+#else
+ lbui r3, r1, 0 /* store byte r3 into return value */
+#endif
+ rsubi r11, r9, FFI_TYPE_SINT8
+ bnei r11, ffi_closure_SYSV_end
+ sext8 r3, r3 /* fix sign extend of sint8 */
+ bri ffi_closure_SYSV_end
+
+ffi_closure_SYSV_end:
+ addik r1, r1, 8 /* de-allocate return value */
+
+ /* de-allocate stored args */
+ addik r1, r1, 24
+
+ /* callee restores */
+ lwi r19, r1, 0 /* frame pointer */
+ lwi r20, r1, 4 /* PIC register */
+ lwi r21, r1, 8 /* PIC register */
+ addik r1, r1, 12
+
+ /* return from sub-routine (with delay slot) */
+ rtsd r15, 8
+ nop
+
+ .size ffi_closure_SYSV, . - ffi_closure_SYSV
diff --git a/jni/ruby/ext/fiddle/libffi-3.2.1/src/mips/ffi.c b/jni/ruby/ext/fiddle/libffi-3.2.1/src/mips/ffi.c
new file mode 100644
index 0000000..5d0dd70
--- /dev/null
+++ b/jni/ruby/ext/fiddle/libffi-3.2.1/src/mips/ffi.c
@@ -0,0 +1,1050 @@
+/* -----------------------------------------------------------------------
+ ffi.c - Copyright (c) 2011 Anthony Green
+ Copyright (c) 2008 David Daney
+ Copyright (c) 1996, 2007, 2008, 2011 Red Hat, Inc.
+
+ MIPS Foreign Function Interface
+
+ Permission is hereby granted, free of charge, to any person obtaining
+ a copy of this software and associated documentation files (the
+ ``Software''), to deal in the Software without restriction, including
+ without limitation the rights to use, copy, modify, merge, publish,
+ distribute, sublicense, and/or sell copies of the Software, and to
+ permit persons to whom the Software is furnished to do so, subject to
+ the following conditions:
+
+ The above copyright notice and this permission notice shall be included
+ in all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND,
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+ HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ DEALINGS IN THE SOFTWARE.
+ ----------------------------------------------------------------------- */
+
+#include <ffi.h>
+#include <ffi_common.h>
+
+#include <stdlib.h>
+
+#ifdef __GNUC__
+# if (__GNUC__ > 4) || ((__GNUC__ == 4) && (__GNUC_MINOR__ >= 3))
+# define USE__BUILTIN___CLEAR_CACHE 1
+# endif
+#endif
+
+#ifndef USE__BUILTIN___CLEAR_CACHE
+# if defined(__OpenBSD__)
+# include <mips64/sysarch.h>
+# else
+# include <sys/cachectl.h>
+# endif
+#endif
+
+#ifdef FFI_DEBUG
+# define FFI_MIPS_STOP_HERE() ffi_stop_here()
+#else
+# define FFI_MIPS_STOP_HERE() do {} while(0)
+#endif
+
+#ifdef FFI_MIPS_N32
+#define FIX_ARGP \
+FFI_ASSERT(argp <= &stack[bytes]); \
+if (argp == &stack[bytes]) \
+{ \
+ argp = stack; \
+ FFI_MIPS_STOP_HERE(); \
+}
+#else
+#define FIX_ARGP
+#endif
+
+
+/* ffi_prep_args is called by the assembly routine once stack space
+ has been allocated for the function's arguments */
+
+static void ffi_prep_args(char *stack,
+ extended_cif *ecif,
+ int bytes,
+ int flags)
+{
+ int i;
+ void **p_argv;
+ char *argp;
+ ffi_type **p_arg;
+
+#ifdef FFI_MIPS_N32
+ /* If more than 8 double words are used, the remainder go
+ on the stack. We reorder stuff on the stack here to
+ support this easily. */
+ if (bytes > 8 * sizeof(ffi_arg))
+ argp = &stack[bytes - (8 * sizeof(ffi_arg))];
+ else
+ argp = stack;
+#else
+ argp = stack;
+#endif
+
+ memset(stack, 0, bytes);
+
+#ifdef FFI_MIPS_N32
+ if ( ecif->cif->rstruct_flag != 0 )
+#else
+ if ( ecif->cif->rtype->type == FFI_TYPE_STRUCT )
+#endif
+ {
+ *(ffi_arg *) argp = (ffi_arg) ecif->rvalue;
+ argp += sizeof(ffi_arg);
+ FIX_ARGP;
+ }
+
+ p_argv = ecif->avalue;
+
+ for (i = 0, p_arg = ecif->cif->arg_types; i < ecif->cif->nargs; i++, p_arg++)
+ {
+ size_t z;
+ unsigned int a;
+
+ /* Align if necessary. */
+ a = (*p_arg)->alignment;
+ if (a < sizeof(ffi_arg))
+ a = sizeof(ffi_arg);
+
+ if ((a - 1) & (unsigned long) argp)
+ {
+ argp = (char *) ALIGN(argp, a);
+ FIX_ARGP;
+ }
+
+ z = (*p_arg)->size;
+ if (z <= sizeof(ffi_arg))
+ {
+ int type = (*p_arg)->type;
+ z = sizeof(ffi_arg);
+
+ /* The size of a pointer depends on the ABI */
+ if (type == FFI_TYPE_POINTER)
+ type = (ecif->cif->abi == FFI_N64
+ || ecif->cif->abi == FFI_N64_SOFT_FLOAT)
+ ? FFI_TYPE_SINT64 : FFI_TYPE_SINT32;
+
+ if (i < 8 && (ecif->cif->abi == FFI_N32_SOFT_FLOAT
+ || ecif->cif->abi == FFI_N64_SOFT_FLOAT))
+ {
+ switch (type)
+ {
+ case FFI_TYPE_FLOAT:
+ type = FFI_TYPE_UINT32;
+ break;
+ case FFI_TYPE_DOUBLE:
+ type = FFI_TYPE_UINT64;
+ break;
+ default:
+ break;
+ }
+ }
+ switch (type)
+ {
+ case FFI_TYPE_SINT8:
+ *(ffi_arg *)argp = *(SINT8 *)(* p_argv);
+ break;
+
+ case FFI_TYPE_UINT8:
+ *(ffi_arg *)argp = *(UINT8 *)(* p_argv);
+ break;
+
+ case FFI_TYPE_SINT16:
+ *(ffi_arg *)argp = *(SINT16 *)(* p_argv);
+ break;
+
+ case FFI_TYPE_UINT16:
+ *(ffi_arg *)argp = *(UINT16 *)(* p_argv);
+ break;
+
+ case FFI_TYPE_SINT32:
+ *(ffi_arg *)argp = *(SINT32 *)(* p_argv);
+ break;
+
+ case FFI_TYPE_UINT32:
+#ifdef FFI_MIPS_N32
+ /* The N32 ABI requires that 32-bit integers
+ be sign-extended to 64-bits, regardless of
+ whether they are signed or unsigned. */
+ *(ffi_arg *)argp = *(SINT32 *)(* p_argv);
+#else
+ *(ffi_arg *)argp = *(UINT32 *)(* p_argv);
+#endif
+ break;
+
+ /* This can only happen with 64bit slots. */
+ case FFI_TYPE_FLOAT:
+ *(float *) argp = *(float *)(* p_argv);
+ break;
+
+ /* Handle structures. */
+ default:
+ memcpy(argp, *p_argv, (*p_arg)->size);
+ break;
+ }
+ }
+ else
+ {
+#ifdef FFI_MIPS_O32
+ memcpy(argp, *p_argv, z);
+#else
+ {
+ unsigned long end = (unsigned long) argp + z;
+ unsigned long cap = (unsigned long) stack + bytes;
+
+ /* Check if the data will fit within the register space.
+ Handle it if it doesn't. */
+
+ if (end <= cap)
+ memcpy(argp, *p_argv, z);
+ else
+ {
+ unsigned long portion = cap - (unsigned long)argp;
+
+ memcpy(argp, *p_argv, portion);
+ argp = stack;
+ z -= portion;
+ memcpy(argp, (void*)((unsigned long)(*p_argv) + portion),
+ z);
+ }
+ }
+#endif
+ }
+ p_argv++;
+ argp += z;
+ FIX_ARGP;
+ }
+}
+
+#ifdef FFI_MIPS_N32
+
+/* The n32 spec says that if "a chunk consists solely of a double
+ float field (but not a double, which is part of a union), it
+ is passed in a floating point register. Any other chunk is
+ passed in an integer register". This code traverses structure
+ definitions and generates the appropriate flags. */
+
+static unsigned
+calc_n32_struct_flags(int soft_float, ffi_type *arg,
+ unsigned *loc, unsigned *arg_reg)
+{
+ unsigned flags = 0;
+ unsigned index = 0;
+
+ ffi_type *e;
+
+ if (soft_float)
+ return 0;
+
+ while ((e = arg->elements[index]))
+ {
+ /* Align this object. */
+ *loc = ALIGN(*loc, e->alignment);
+ if (e->type == FFI_TYPE_DOUBLE)
+ {
+ /* Already aligned to FFI_SIZEOF_ARG. */
+ *arg_reg = *loc / FFI_SIZEOF_ARG;
+ if (*arg_reg > 7)
+ break;
+ flags += (FFI_TYPE_DOUBLE << (*arg_reg * FFI_FLAG_BITS));
+ *loc += e->size;
+ }
+ else
+ *loc += e->size;
+ index++;
+ }
+ /* Next Argument register at alignment of FFI_SIZEOF_ARG. */
+ *arg_reg = ALIGN(*loc, FFI_SIZEOF_ARG) / FFI_SIZEOF_ARG;
+
+ return flags;
+}
+
+static unsigned
+calc_n32_return_struct_flags(int soft_float, ffi_type *arg)
+{
+ unsigned flags = 0;
+ unsigned small = FFI_TYPE_SMALLSTRUCT;
+ ffi_type *e;
+
+ /* Returning structures under n32 is a tricky thing.
+ A struct with only one or two floating point fields
+ is returned in $f0 (and $f2 if necessary). Any other
+ struct results at most 128 bits are returned in $2
+ (the first 64 bits) and $3 (remainder, if necessary).
+ Larger structs are handled normally. */
+
+ if (arg->size > 16)
+ return 0;
+
+ if (arg->size > 8)
+ small = FFI_TYPE_SMALLSTRUCT2;
+
+ e = arg->elements[0];
+
+ if (e->type == FFI_TYPE_DOUBLE)
+ flags = FFI_TYPE_DOUBLE;
+ else if (e->type == FFI_TYPE_FLOAT)
+ flags = FFI_TYPE_FLOAT;
+
+ if (flags && (e = arg->elements[1]))
+ {
+ if (e->type == FFI_TYPE_DOUBLE)
+ flags += FFI_TYPE_DOUBLE << FFI_FLAG_BITS;
+ else if (e->type == FFI_TYPE_FLOAT)
+ flags += FFI_TYPE_FLOAT << FFI_FLAG_BITS;
+ else
+ return small;
+
+ if (flags && (arg->elements[2]))
+ {
+ /* There are three arguments and the first two are
+ floats! This must be passed the old way. */
+ return small;
+ }
+ if (soft_float)
+ flags += FFI_TYPE_STRUCT_SOFT;
+ }
+ else
+ if (!flags)
+ return small;
+
+ return flags;
+}
+
+#endif
+
+/* Perform machine dependent cif processing */
+ffi_status ffi_prep_cif_machdep(ffi_cif *cif)
+{
+ cif->flags = 0;
+
+#ifdef FFI_MIPS_O32
+ /* Set the flags necessary for O32 processing. FFI_O32_SOFT_FLOAT
+ * does not have special handling for floating point args.
+ */
+
+ if (cif->rtype->type != FFI_TYPE_STRUCT && cif->abi == FFI_O32)
+ {
+ if (cif->nargs > 0)
+ {
+ switch ((cif->arg_types)[0]->type)
+ {
+ case FFI_TYPE_FLOAT:
+ case FFI_TYPE_DOUBLE:
+ cif->flags += (cif->arg_types)[0]->type;
+ break;
+
+ default:
+ break;
+ }
+
+ if (cif->nargs > 1)
+ {
+ /* Only handle the second argument if the first
+ is a float or double. */
+ if (cif->flags)
+ {
+ switch ((cif->arg_types)[1]->type)
+ {
+ case FFI_TYPE_FLOAT:
+ case FFI_TYPE_DOUBLE:
+ cif->flags += (cif->arg_types)[1]->type << FFI_FLAG_BITS;
+ break;
+
+ default:
+ break;
+ }
+ }
+ }
+ }
+ }
+
+ /* Set the return type flag */
+
+ if (cif->abi == FFI_O32_SOFT_FLOAT)
+ {
+ switch (cif->rtype->type)
+ {
+ case FFI_TYPE_VOID:
+ case FFI_TYPE_STRUCT:
+ cif->flags += cif->rtype->type << (FFI_FLAG_BITS * 2);
+ break;
+
+ case FFI_TYPE_SINT64:
+ case FFI_TYPE_UINT64:
+ case FFI_TYPE_DOUBLE:
+ cif->flags += FFI_TYPE_UINT64 << (FFI_FLAG_BITS * 2);
+ break;
+
+ case FFI_TYPE_FLOAT:
+ default:
+ cif->flags += FFI_TYPE_INT << (FFI_FLAG_BITS * 2);
+ break;
+ }
+ }
+ else
+ {
+ /* FFI_O32 */
+ switch (cif->rtype->type)
+ {
+ case FFI_TYPE_VOID:
+ case FFI_TYPE_STRUCT:
+ case FFI_TYPE_FLOAT:
+ case FFI_TYPE_DOUBLE:
+ cif->flags += cif->rtype->type << (FFI_FLAG_BITS * 2);
+ break;
+
+ case FFI_TYPE_SINT64:
+ case FFI_TYPE_UINT64:
+ cif->flags += FFI_TYPE_UINT64 << (FFI_FLAG_BITS * 2);
+ break;
+
+ default:
+ cif->flags += FFI_TYPE_INT << (FFI_FLAG_BITS * 2);
+ break;
+ }
+ }
+#endif
+
+#ifdef FFI_MIPS_N32
+ /* Set the flags necessary for N32 processing */
+ {
+ int type;
+ unsigned arg_reg = 0;
+ unsigned loc = 0;
+ unsigned count = (cif->nargs < 8) ? cif->nargs : 8;
+ unsigned index = 0;
+
+ unsigned struct_flags = 0;
+ int soft_float = (cif->abi == FFI_N32_SOFT_FLOAT
+ || cif->abi == FFI_N64_SOFT_FLOAT);
+
+ if (cif->rtype->type == FFI_TYPE_STRUCT)
+ {
+ struct_flags = calc_n32_return_struct_flags(soft_float, cif->rtype);
+
+ if (struct_flags == 0)
+ {
+ /* This means that the structure is being passed as
+ a hidden argument */
+
+ arg_reg = 1;
+ count = (cif->nargs < 7) ? cif->nargs : 7;
+
+ cif->rstruct_flag = !0;
+ }
+ else
+ cif->rstruct_flag = 0;
+ }
+ else
+ cif->rstruct_flag = 0;
+
+ while (count-- > 0 && arg_reg < 8)
+ {
+ type = (cif->arg_types)[index]->type;
+ if (soft_float)
+ {
+ switch (type)
+ {
+ case FFI_TYPE_FLOAT:
+ type = FFI_TYPE_UINT32;
+ break;
+ case FFI_TYPE_DOUBLE:
+ type = FFI_TYPE_UINT64;
+ break;
+ default:
+ break;
+ }
+ }
+ switch (type)
+ {
+ case FFI_TYPE_FLOAT:
+ case FFI_TYPE_DOUBLE:
+ cif->flags +=
+ ((cif->arg_types)[index]->type << (arg_reg * FFI_FLAG_BITS));
+ arg_reg++;
+ break;
+ case FFI_TYPE_LONGDOUBLE:
+ /* Align it. */
+ arg_reg = ALIGN(arg_reg, 2);
+ /* Treat it as two adjacent doubles. */
+ if (soft_float)
+ {
+ arg_reg += 2;
+ }
+ else
+ {
+ cif->flags +=
+ (FFI_TYPE_DOUBLE << (arg_reg * FFI_FLAG_BITS));
+ arg_reg++;
+ cif->flags +=
+ (FFI_TYPE_DOUBLE << (arg_reg * FFI_FLAG_BITS));
+ arg_reg++;
+ }
+ break;
+
+ case FFI_TYPE_STRUCT:
+ loc = arg_reg * FFI_SIZEOF_ARG;
+ cif->flags += calc_n32_struct_flags(soft_float,
+ (cif->arg_types)[index],
+ &loc, &arg_reg);
+ break;
+
+ default:
+ arg_reg++;
+ break;
+ }
+
+ index++;
+ }
+
+ /* Set the return type flag */
+ switch (cif->rtype->type)
+ {
+ case FFI_TYPE_STRUCT:
+ {
+ if (struct_flags == 0)
+ {
+ /* The structure is returned through a hidden
+ first argument. Do nothing, 'cause FFI_TYPE_VOID
+ is 0 */
+ }
+ else
+ {
+ /* The structure is returned via some tricky
+ mechanism */
+ cif->flags += FFI_TYPE_STRUCT << (FFI_FLAG_BITS * 8);
+ cif->flags += struct_flags << (4 + (FFI_FLAG_BITS * 8));
+ }
+ break;
+ }
+
+ case FFI_TYPE_VOID:
+ /* Do nothing, 'cause FFI_TYPE_VOID is 0 */
+ break;
+
+ case FFI_TYPE_POINTER:
+ if (cif->abi == FFI_N32_SOFT_FLOAT || cif->abi == FFI_N32)
+ cif->flags += FFI_TYPE_SINT32 << (FFI_FLAG_BITS * 8);
+ else
+ cif->flags += FFI_TYPE_INT << (FFI_FLAG_BITS * 8);
+ break;
+
+ case FFI_TYPE_FLOAT:
+ if (soft_float)
+ {
+ cif->flags += FFI_TYPE_SINT32 << (FFI_FLAG_BITS * 8);
+ break;
+ }
+ /* else fall through */
+ case FFI_TYPE_DOUBLE:
+ if (soft_float)
+ cif->flags += FFI_TYPE_INT << (FFI_FLAG_BITS * 8);
+ else
+ cif->flags += cif->rtype->type << (FFI_FLAG_BITS * 8);
+ break;
+
+ case FFI_TYPE_LONGDOUBLE:
+ /* Long double is returned as if it were a struct containing
+ two doubles. */
+ if (soft_float)
+ {
+ cif->flags += FFI_TYPE_STRUCT << (FFI_FLAG_BITS * 8);
+ cif->flags += FFI_TYPE_SMALLSTRUCT2 << (4 + (FFI_FLAG_BITS * 8));
+ }
+ else
+ {
+ cif->flags += FFI_TYPE_STRUCT << (FFI_FLAG_BITS * 8);
+ cif->flags += (FFI_TYPE_DOUBLE
+ + (FFI_TYPE_DOUBLE << FFI_FLAG_BITS))
+ << (4 + (FFI_FLAG_BITS * 8));
+ }
+ break;
+ default:
+ cif->flags += FFI_TYPE_INT << (FFI_FLAG_BITS * 8);
+ break;
+ }
+ }
+#endif
+
+ return FFI_OK;
+}
+
+/* Low level routine for calling O32 functions */
+extern int ffi_call_O32(void (*)(char *, extended_cif *, int, int),
+ extended_cif *, unsigned,
+ unsigned, unsigned *, void (*)(void));
+
+/* Low level routine for calling N32 functions */
+extern int ffi_call_N32(void (*)(char *, extended_cif *, int, int),
+ extended_cif *, unsigned,
+ unsigned, void *, void (*)(void));
+
+void ffi_call(ffi_cif *cif, void (*fn)(void), void *rvalue, void **avalue)
+{
+ extended_cif ecif;
+
+ ecif.cif = cif;
+ ecif.avalue = avalue;
+
+ /* If the return value is a struct and we don't have a return */
+ /* value address then we need to make one */
+
+ if ((rvalue == NULL) &&
+ (cif->rtype->type == FFI_TYPE_STRUCT))
+ ecif.rvalue = alloca(cif->rtype->size);
+ else
+ ecif.rvalue = rvalue;
+
+ switch (cif->abi)
+ {
+#ifdef FFI_MIPS_O32
+ case FFI_O32:
+ case FFI_O32_SOFT_FLOAT:
+ ffi_call_O32(ffi_prep_args, &ecif, cif->bytes,
+ cif->flags, ecif.rvalue, fn);
+ break;
+#endif
+
+#ifdef FFI_MIPS_N32
+ case FFI_N32:
+ case FFI_N32_SOFT_FLOAT:
+ case FFI_N64:
+ case FFI_N64_SOFT_FLOAT:
+ {
+ int copy_rvalue = 0;
+ int copy_offset = 0;
+ char *rvalue_copy = ecif.rvalue;
+ if (cif->rtype->type == FFI_TYPE_STRUCT && cif->rtype->size < 16)
+ {
+ /* For structures smaller than 16 bytes we clobber memory
+ in 8 byte increments. Make a copy so we don't clobber
+ the callers memory outside of the struct bounds. */
+ rvalue_copy = alloca(16);
+ copy_rvalue = 1;
+ }
+ else if (cif->rtype->type == FFI_TYPE_FLOAT
+ && (cif->abi == FFI_N64_SOFT_FLOAT
+ || cif->abi == FFI_N32_SOFT_FLOAT))
+ {
+ rvalue_copy = alloca (8);
+ copy_rvalue = 1;
+#if defined(__MIPSEB__) || defined(_MIPSEB)
+ copy_offset = 4;
+#endif
+ }
+ ffi_call_N32(ffi_prep_args, &ecif, cif->bytes,
+ cif->flags, rvalue_copy, fn);
+ if (copy_rvalue)
+ memcpy(ecif.rvalue, rvalue_copy + copy_offset, cif->rtype->size);
+ }
+ break;
+#endif
+
+ default:
+ FFI_ASSERT(0);
+ break;
+ }
+}
+
+#if FFI_CLOSURES
+#if defined(FFI_MIPS_O32)
+extern void ffi_closure_O32(void);
+#else
+extern void ffi_closure_N32(void);
+#endif /* FFI_MIPS_O32 */
+
+ffi_status
+ffi_prep_closure_loc (ffi_closure *closure,
+ ffi_cif *cif,
+ void (*fun)(ffi_cif*,void*,void**,void*),
+ void *user_data,
+ void *codeloc)
+{
+ unsigned int *tramp = (unsigned int *) &closure->tramp[0];
+ void * fn;
+ char *clear_location = (char *) codeloc;
+
+#if defined(FFI_MIPS_O32)
+ if (cif->abi != FFI_O32 && cif->abi != FFI_O32_SOFT_FLOAT)
+ return FFI_BAD_ABI;
+ fn = ffi_closure_O32;
+#else
+#if _MIPS_SIM ==_ABIN32
+ if (cif->abi != FFI_N32
+ && cif->abi != FFI_N32_SOFT_FLOAT)
+ return FFI_BAD_ABI;
+#else
+ if (cif->abi != FFI_N64
+ && cif->abi != FFI_N64_SOFT_FLOAT)
+ return FFI_BAD_ABI;
+#endif
+ fn = ffi_closure_N32;
+#endif /* FFI_MIPS_O32 */
+
+#if defined(FFI_MIPS_O32) || (_MIPS_SIM ==_ABIN32)
+ /* lui $25,high(fn) */
+ tramp[0] = 0x3c190000 | ((unsigned)fn >> 16);
+ /* ori $25,low(fn) */
+ tramp[1] = 0x37390000 | ((unsigned)fn & 0xffff);
+ /* lui $12,high(codeloc) */
+ tramp[2] = 0x3c0c0000 | ((unsigned)codeloc >> 16);
+ /* jr $25 */
+ tramp[3] = 0x03200008;
+ /* ori $12,low(codeloc) */
+ tramp[4] = 0x358c0000 | ((unsigned)codeloc & 0xffff);
+#else
+ /* N64 has a somewhat larger trampoline. */
+ /* lui $25,high(fn) */
+ tramp[0] = 0x3c190000 | ((unsigned long)fn >> 48);
+ /* lui $12,high(codeloc) */
+ tramp[1] = 0x3c0c0000 | ((unsigned long)codeloc >> 48);
+ /* ori $25,mid-high(fn) */
+ tramp[2] = 0x37390000 | (((unsigned long)fn >> 32 ) & 0xffff);
+ /* ori $12,mid-high(codeloc) */
+ tramp[3] = 0x358c0000 | (((unsigned long)codeloc >> 32) & 0xffff);
+ /* dsll $25,$25,16 */
+ tramp[4] = 0x0019cc38;
+ /* dsll $12,$12,16 */
+ tramp[5] = 0x000c6438;
+ /* ori $25,mid-low(fn) */
+ tramp[6] = 0x37390000 | (((unsigned long)fn >> 16 ) & 0xffff);
+ /* ori $12,mid-low(codeloc) */
+ tramp[7] = 0x358c0000 | (((unsigned long)codeloc >> 16) & 0xffff);
+ /* dsll $25,$25,16 */
+ tramp[8] = 0x0019cc38;
+ /* dsll $12,$12,16 */
+ tramp[9] = 0x000c6438;
+ /* ori $25,low(fn) */
+ tramp[10] = 0x37390000 | ((unsigned long)fn & 0xffff);
+ /* jr $25 */
+ tramp[11] = 0x03200008;
+ /* ori $12,low(codeloc) */
+ tramp[12] = 0x358c0000 | ((unsigned long)codeloc & 0xffff);
+
+#endif
+
+ closure->cif = cif;
+ closure->fun = fun;
+ closure->user_data = user_data;
+
+#ifdef USE__BUILTIN___CLEAR_CACHE
+ __builtin___clear_cache(clear_location, clear_location + FFI_TRAMPOLINE_SIZE);
+#else
+ cacheflush (clear_location, FFI_TRAMPOLINE_SIZE, ICACHE);
+#endif
+ return FFI_OK;
+}
+
+/*
+ * Decodes the arguments to a function, which will be stored on the
+ * stack. AR is the pointer to the beginning of the integer arguments
+ * (and, depending upon the arguments, some floating-point arguments
+ * as well). FPR is a pointer to the area where floating point
+ * registers have been saved, if any.
+ *
+ * RVALUE is the location where the function return value will be
+ * stored. CLOSURE is the prepared closure to invoke.
+ *
+ * This function should only be called from assembly, which is in
+ * turn called from a trampoline.
+ *
+ * Returns the function return type.
+ *
+ * Based on the similar routine for sparc.
+ */
+int
+ffi_closure_mips_inner_O32 (ffi_closure *closure,
+ void *rvalue, ffi_arg *ar,
+ double *fpr)
+{
+ ffi_cif *cif;
+ void **avaluep;
+ ffi_arg *avalue;
+ ffi_type **arg_types;
+ int i, avn, argn, seen_int;
+
+ cif = closure->cif;
+ avalue = alloca (cif->nargs * sizeof (ffi_arg));
+ avaluep = alloca (cif->nargs * sizeof (ffi_arg));
+
+ seen_int = (cif->abi == FFI_O32_SOFT_FLOAT);
+ argn = 0;
+
+ if ((cif->flags >> (FFI_FLAG_BITS * 2)) == FFI_TYPE_STRUCT)
+ {
+ rvalue = (void *)(UINT32)ar[0];
+ argn = 1;
+ }
+
+ i = 0;
+ avn = cif->nargs;
+ arg_types = cif->arg_types;
+
+ while (i < avn)
+ {
+ if (i < 2 && !seen_int &&
+ (arg_types[i]->type == FFI_TYPE_FLOAT ||
+ arg_types[i]->type == FFI_TYPE_DOUBLE ||
+ arg_types[i]->type == FFI_TYPE_LONGDOUBLE))
+ {
+#if defined(__MIPSEB__) || defined(_MIPSEB)
+ if (arg_types[i]->type == FFI_TYPE_FLOAT)
+ avaluep[i] = ((char *) &fpr[i]) + sizeof (float);
+ else
+#endif
+ avaluep[i] = (char *) &fpr[i];
+ }
+ else
+ {
+ if (arg_types[i]->alignment == 8 && (argn & 0x1))
+ argn++;
+ switch (arg_types[i]->type)
+ {
+ case FFI_TYPE_SINT8:
+ avaluep[i] = &avalue[i];
+ *(SINT8 *) &avalue[i] = (SINT8) ar[argn];
+ break;
+
+ case FFI_TYPE_UINT8:
+ avaluep[i] = &avalue[i];
+ *(UINT8 *) &avalue[i] = (UINT8) ar[argn];
+ break;
+
+ case FFI_TYPE_SINT16:
+ avaluep[i] = &avalue[i];
+ *(SINT16 *) &avalue[i] = (SINT16) ar[argn];
+ break;
+
+ case FFI_TYPE_UINT16:
+ avaluep[i] = &avalue[i];
+ *(UINT16 *) &avalue[i] = (UINT16) ar[argn];
+ break;
+
+ default:
+ avaluep[i] = (char *) &ar[argn];
+ break;
+ }
+ seen_int = 1;
+ }
+ argn += ALIGN(arg_types[i]->size, FFI_SIZEOF_ARG) / FFI_SIZEOF_ARG;
+ i++;
+ }
+
+ /* Invoke the closure. */
+ (closure->fun) (cif, rvalue, avaluep, closure->user_data);
+
+ if (cif->abi == FFI_O32_SOFT_FLOAT)
+ {
+ switch (cif->rtype->type)
+ {
+ case FFI_TYPE_FLOAT:
+ return FFI_TYPE_INT;
+ case FFI_TYPE_DOUBLE:
+ return FFI_TYPE_UINT64;
+ default:
+ return cif->rtype->type;
+ }
+ }
+ else
+ {
+ return cif->rtype->type;
+ }
+}
+
+#if defined(FFI_MIPS_N32)
+
+static void
+copy_struct_N32(char *target, unsigned offset, ffi_abi abi, ffi_type *type,
+ int argn, unsigned arg_offset, ffi_arg *ar,
+ ffi_arg *fpr, int soft_float)
+{
+ ffi_type **elt_typep = type->elements;
+ while(*elt_typep)
+ {
+ ffi_type *elt_type = *elt_typep;
+ unsigned o;
+ char *tp;
+ char *argp;
+ char *fpp;
+
+ o = ALIGN(offset, elt_type->alignment);
+ arg_offset += o - offset;
+ offset = o;
+ argn += arg_offset / sizeof(ffi_arg);
+ arg_offset = arg_offset % sizeof(ffi_arg);
+
+ argp = (char *)(ar + argn);
+ fpp = (char *)(argn >= 8 ? ar + argn : fpr + argn);
+
+ tp = target + offset;
+
+ if (elt_type->type == FFI_TYPE_DOUBLE && !soft_float)
+ *(double *)tp = *(double *)fpp;
+ else
+ memcpy(tp, argp + arg_offset, elt_type->size);
+
+ offset += elt_type->size;
+ arg_offset += elt_type->size;
+ elt_typep++;
+ argn += arg_offset / sizeof(ffi_arg);
+ arg_offset = arg_offset % sizeof(ffi_arg);
+ }
+}
+
+/*
+ * Decodes the arguments to a function, which will be stored on the
+ * stack. AR is the pointer to the beginning of the integer
+ * arguments. FPR is a pointer to the area where floating point
+ * registers have been saved.
+ *
+ * RVALUE is the location where the function return value will be
+ * stored. CLOSURE is the prepared closure to invoke.
+ *
+ * This function should only be called from assembly, which is in
+ * turn called from a trampoline.
+ *
+ * Returns the function return flags.
+ *
+ */
+int
+ffi_closure_mips_inner_N32 (ffi_closure *closure,
+ void *rvalue, ffi_arg *ar,
+ ffi_arg *fpr)
+{
+ ffi_cif *cif;
+ void **avaluep;
+ ffi_arg *avalue;
+ ffi_type **arg_types;
+ int i, avn, argn;
+ int soft_float;
+ ffi_arg *argp;
+
+ cif = closure->cif;
+ soft_float = cif->abi == FFI_N64_SOFT_FLOAT
+ || cif->abi == FFI_N32_SOFT_FLOAT;
+ avalue = alloca (cif->nargs * sizeof (ffi_arg));
+ avaluep = alloca (cif->nargs * sizeof (ffi_arg));
+
+ argn = 0;
+
+ if (cif->rstruct_flag)
+ {
+#if _MIPS_SIM==_ABIN32
+ rvalue = (void *)(UINT32)ar[0];
+#else /* N64 */
+ rvalue = (void *)ar[0];
+#endif
+ argn = 1;
+ }
+
+ i = 0;
+ avn = cif->nargs;
+ arg_types = cif->arg_types;
+
+ while (i < avn)
+ {
+ if (arg_types[i]->type == FFI_TYPE_FLOAT
+ || arg_types[i]->type == FFI_TYPE_DOUBLE
+ || arg_types[i]->type == FFI_TYPE_LONGDOUBLE)
+ {
+ argp = (argn >= 8 || soft_float) ? ar + argn : fpr + argn;
+ if ((arg_types[i]->type == FFI_TYPE_LONGDOUBLE) && ((unsigned)argp & (arg_types[i]->alignment-1)))
+ {
+ argp=(ffi_arg*)ALIGN(argp,arg_types[i]->alignment);
+ argn++;
+ }
+#if defined(__MIPSEB__) || defined(_MIPSEB)
+ if (arg_types[i]->type == FFI_TYPE_FLOAT && argn < 8)
+ avaluep[i] = ((char *) argp) + sizeof (float);
+ else
+#endif
+ avaluep[i] = (char *) argp;
+ }
+ else
+ {
+ unsigned type = arg_types[i]->type;
+
+ if (arg_types[i]->alignment > sizeof(ffi_arg))
+ argn = ALIGN(argn, arg_types[i]->alignment / sizeof(ffi_arg));
+
+ argp = ar + argn;
+
+ /* The size of a pointer depends on the ABI */
+ if (type == FFI_TYPE_POINTER)
+ type = (cif->abi == FFI_N64 || cif->abi == FFI_N64_SOFT_FLOAT)
+ ? FFI_TYPE_SINT64 : FFI_TYPE_SINT32;
+
+ if (soft_float && type == FFI_TYPE_FLOAT)
+ type = FFI_TYPE_UINT32;
+
+ switch (type)
+ {
+ case FFI_TYPE_SINT8:
+ avaluep[i] = &avalue[i];
+ *(SINT8 *) &avalue[i] = (SINT8) *argp;
+ break;
+
+ case FFI_TYPE_UINT8:
+ avaluep[i] = &avalue[i];
+ *(UINT8 *) &avalue[i] = (UINT8) *argp;
+ break;
+
+ case FFI_TYPE_SINT16:
+ avaluep[i] = &avalue[i];
+ *(SINT16 *) &avalue[i] = (SINT16) *argp;
+ break;
+
+ case FFI_TYPE_UINT16:
+ avaluep[i] = &avalue[i];
+ *(UINT16 *) &avalue[i] = (UINT16) *argp;
+ break;
+
+ case FFI_TYPE_SINT32:
+ avaluep[i] = &avalue[i];
+ *(SINT32 *) &avalue[i] = (SINT32) *argp;
+ break;
+
+ case FFI_TYPE_UINT32:
+ avaluep[i] = &avalue[i];
+ *(UINT32 *) &avalue[i] = (UINT32) *argp;
+ break;
+
+ case FFI_TYPE_STRUCT:
+ if (argn < 8)
+ {
+ /* Allocate space for the struct as at least part of
+ it was passed in registers. */
+ avaluep[i] = alloca(arg_types[i]->size);
+ copy_struct_N32(avaluep[i], 0, cif->abi, arg_types[i],
+ argn, 0, ar, fpr, soft_float);
+
+ break;
+ }
+ /* Else fall through. */
+ default:
+ avaluep[i] = (char *) argp;
+ break;
+ }
+ }
+ argn += ALIGN(arg_types[i]->size, sizeof(ffi_arg)) / sizeof(ffi_arg);
+ i++;
+ }
+
+ /* Invoke the closure. */
+ (closure->fun) (cif, rvalue, avaluep, closure->user_data);
+
+ return cif->flags >> (FFI_FLAG_BITS * 8);
+}
+
+#endif /* FFI_MIPS_N32 */
+
+#endif /* FFI_CLOSURES */
diff --git a/jni/ruby/ext/fiddle/libffi-3.2.1/src/mips/ffitarget.h b/jni/ruby/ext/fiddle/libffi-3.2.1/src/mips/ffitarget.h
new file mode 100644
index 0000000..717d659
--- /dev/null
+++ b/jni/ruby/ext/fiddle/libffi-3.2.1/src/mips/ffitarget.h
@@ -0,0 +1,247 @@
+/* -----------------------------------------------------------------*-C-*-
+ ffitarget.h - Copyright (c) 2012 Anthony Green
+ Copyright (c) 1996-2003 Red Hat, Inc.
+ Target configuration macros for MIPS.
+
+ Permission is hereby granted, free of charge, to any person obtaining
+ a copy of this software and associated documentation files (the
+ ``Software''), to deal in the Software without restriction, including
+ without limitation the rights to use, copy, modify, merge, publish,
+ distribute, sublicense, and/or sell copies of the Software, and to
+ permit persons to whom the Software is furnished to do so, subject to
+ the following conditions:
+
+ The above copyright notice and this permission notice shall be included
+ in all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND,
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+ HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ DEALINGS IN THE SOFTWARE.
+
+ ----------------------------------------------------------------------- */
+
+#ifndef LIBFFI_TARGET_H
+#define LIBFFI_TARGET_H
+
+#ifndef LIBFFI_H
+#error "Please do not include ffitarget.h directly into your source. Use ffi.h instead."
+#endif
+
+#ifdef linux
+# include <asm/sgidefs.h>
+#elif defined(__rtems__)
+/*
+ * Subprogram calling convention - copied from sgidefs.h
+ */
+#define _MIPS_SIM_ABI32 1
+#define _MIPS_SIM_NABI32 2
+#define _MIPS_SIM_ABI64 3
+#elif !defined(__OpenBSD__)
+# include <sgidefs.h>
+#endif
+
+# ifndef _ABIN32
+# define _ABIN32 _MIPS_SIM_NABI32
+# endif
+# ifndef _ABI64
+# define _ABI64 _MIPS_SIM_ABI64
+# endif
+# ifndef _ABIO32
+# define _ABIO32 _MIPS_SIM_ABI32
+# endif
+
+#if !defined(_MIPS_SIM)
+# error -- something is very wrong --
+#else
+# if (_MIPS_SIM==_ABIN32 && defined(_ABIN32)) || (_MIPS_SIM==_ABI64 && defined(_ABI64))
+# define FFI_MIPS_N32
+# else
+# if (_MIPS_SIM==_ABIO32 && defined(_ABIO32))
+# define FFI_MIPS_O32
+# else
+# error -- this is an unsupported platform --
+# endif
+# endif
+#endif
+
+#ifdef FFI_MIPS_O32
+/* O32 stack frames have 32bit integer args */
+# define FFI_SIZEOF_ARG 4
+#else
+/* N32 and N64 frames have 64bit integer args */
+# define FFI_SIZEOF_ARG 8
+# if _MIPS_SIM == _ABIN32
+# define FFI_SIZEOF_JAVA_RAW 4
+# endif
+#endif
+
+#define FFI_FLAG_BITS 2
+
+/* SGI's strange assembler requires that we multiply by 4 rather
+ than shift left by FFI_FLAG_BITS */
+
+#define FFI_ARGS_D FFI_TYPE_DOUBLE
+#define FFI_ARGS_F FFI_TYPE_FLOAT
+#define FFI_ARGS_DD FFI_TYPE_DOUBLE * 4 + FFI_TYPE_DOUBLE
+#define FFI_ARGS_FF FFI_TYPE_FLOAT * 4 + FFI_TYPE_FLOAT
+#define FFI_ARGS_FD FFI_TYPE_DOUBLE * 4 + FFI_TYPE_FLOAT
+#define FFI_ARGS_DF FFI_TYPE_FLOAT * 4 + FFI_TYPE_DOUBLE
+
+/* Needed for N32 structure returns */
+#define FFI_TYPE_SMALLSTRUCT FFI_TYPE_UINT8
+#define FFI_TYPE_SMALLSTRUCT2 FFI_TYPE_SINT8
+
+#if 0
+/* The SGI assembler can't handle this.. */
+#define FFI_TYPE_STRUCT_DD (( FFI_ARGS_DD ) << 4) + FFI_TYPE_STRUCT
+/* (and so on) */
+#else
+/* ...so we calculate these by hand! */
+#define FFI_TYPE_STRUCT_D 61
+#define FFI_TYPE_STRUCT_F 45
+#define FFI_TYPE_STRUCT_DD 253
+#define FFI_TYPE_STRUCT_FF 173
+#define FFI_TYPE_STRUCT_FD 237
+#define FFI_TYPE_STRUCT_DF 189
+#define FFI_TYPE_STRUCT_SMALL 93
+#define FFI_TYPE_STRUCT_SMALL2 109
+
+/* and for n32 soft float, add 16 * 2^4 */
+#define FFI_TYPE_STRUCT_D_SOFT 317
+#define FFI_TYPE_STRUCT_F_SOFT 301
+#define FFI_TYPE_STRUCT_DD_SOFT 509
+#define FFI_TYPE_STRUCT_FF_SOFT 429
+#define FFI_TYPE_STRUCT_FD_SOFT 493
+#define FFI_TYPE_STRUCT_DF_SOFT 445
+#define FFI_TYPE_STRUCT_SOFT 16
+#endif
+
+#ifdef LIBFFI_ASM
+#define v0 $2
+#define v1 $3
+#define a0 $4
+#define a1 $5
+#define a2 $6
+#define a3 $7
+#define a4 $8
+#define a5 $9
+#define a6 $10
+#define a7 $11
+#define t0 $8
+#define t1 $9
+#define t2 $10
+#define t3 $11
+#define t4 $12
+#define t5 $13
+#define t6 $14
+#define t7 $15
+#define t8 $24
+#define t9 $25
+#define ra $31
+
+#ifdef FFI_MIPS_O32
+# define REG_L lw
+# define REG_S sw
+# define SUBU subu
+# define ADDU addu
+# define SRL srl
+# define LI li
+#else /* !FFI_MIPS_O32 */
+# define REG_L ld
+# define REG_S sd
+# define SUBU dsubu
+# define ADDU daddu
+# define SRL dsrl
+# define LI dli
+# if (_MIPS_SIM==_ABI64)
+# define LA dla
+# define EH_FRAME_ALIGN 3
+# define FDE_ADDR_BYTES .8byte
+# else
+# define LA la
+# define EH_FRAME_ALIGN 2
+# define FDE_ADDR_BYTES .4byte
+# endif /* _MIPS_SIM==_ABI64 */
+#endif /* !FFI_MIPS_O32 */
+#else /* !LIBFFI_ASM */
+# ifdef __GNUC__
+# ifdef FFI_MIPS_O32
+/* O32 stack frames have 32bit integer args */
+typedef unsigned int ffi_arg __attribute__((__mode__(__SI__)));
+typedef signed int ffi_sarg __attribute__((__mode__(__SI__)));
+#else
+/* N32 and N64 frames have 64bit integer args */
+typedef unsigned int ffi_arg __attribute__((__mode__(__DI__)));
+typedef signed int ffi_sarg __attribute__((__mode__(__DI__)));
+# endif
+# else
+# ifdef FFI_MIPS_O32
+/* O32 stack frames have 32bit integer args */
+typedef __uint32_t ffi_arg;
+typedef __int32_t ffi_sarg;
+# else
+/* N32 and N64 frames have 64bit integer args */
+typedef __uint64_t ffi_arg;
+typedef __int64_t ffi_sarg;
+# endif
+# endif /* __GNUC__ */
+
+typedef enum ffi_abi {
+ FFI_FIRST_ABI = 0,
+ FFI_O32,
+ FFI_N32,
+ FFI_N64,
+ FFI_O32_SOFT_FLOAT,
+ FFI_N32_SOFT_FLOAT,
+ FFI_N64_SOFT_FLOAT,
+ FFI_LAST_ABI,
+
+#ifdef FFI_MIPS_O32
+#ifdef __mips_soft_float
+ FFI_DEFAULT_ABI = FFI_O32_SOFT_FLOAT
+#else
+ FFI_DEFAULT_ABI = FFI_O32
+#endif
+#else
+# if _MIPS_SIM==_ABI64
+# ifdef __mips_soft_float
+ FFI_DEFAULT_ABI = FFI_N64_SOFT_FLOAT
+# else
+ FFI_DEFAULT_ABI = FFI_N64
+# endif
+# else
+# ifdef __mips_soft_float
+ FFI_DEFAULT_ABI = FFI_N32_SOFT_FLOAT
+# else
+ FFI_DEFAULT_ABI = FFI_N32
+# endif
+# endif
+#endif
+} ffi_abi;
+
+#define FFI_EXTRA_CIF_FIELDS unsigned rstruct_flag
+#endif /* !LIBFFI_ASM */
+
+/* ---- Definitions for closures ----------------------------------------- */
+
+#if defined(FFI_MIPS_O32)
+#define FFI_CLOSURES 1
+#define FFI_TRAMPOLINE_SIZE 20
+#else
+/* N32/N64. */
+# define FFI_CLOSURES 1
+#if _MIPS_SIM==_ABI64
+#define FFI_TRAMPOLINE_SIZE 52
+#else
+#define FFI_TRAMPOLINE_SIZE 20
+#endif
+#endif /* FFI_MIPS_O32 */
+#define FFI_NATIVE_RAW_API 0
+
+#endif
+
diff --git a/jni/ruby/ext/fiddle/libffi-3.2.1/src/mips/n32.S b/jni/ruby/ext/fiddle/libffi-3.2.1/src/mips/n32.S
new file mode 100644
index 0000000..c6985d3
--- /dev/null
+++ b/jni/ruby/ext/fiddle/libffi-3.2.1/src/mips/n32.S
@@ -0,0 +1,576 @@
+/* -----------------------------------------------------------------------
+ n32.S - Copyright (c) 1996, 1998, 2005, 2007, 2009, 2010 Red Hat, Inc.
+
+ MIPS Foreign Function Interface
+
+ Permission is hereby granted, free of charge, to any person obtaining
+ a copy of this software and associated documentation files (the
+ ``Software''), to deal in the Software without restriction, including
+ without limitation the rights to use, copy, modify, merge, publish,
+ distribute, sublicense, and/or sell copies of the Software, and to
+ permit persons to whom the Software is furnished to do so, subject to
+ the following conditions:
+
+ The above copyright notice and this permission notice shall be included
+ in all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND,
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+ HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ DEALINGS IN THE SOFTWARE.
+ ----------------------------------------------------------------------- */
+
+#define LIBFFI_ASM
+#include <fficonfig.h>
+#include <ffi.h>
+
+/* Only build this code if we are compiling for n32 */
+
+#if defined(FFI_MIPS_N32)
+
+#define callback a0
+#define bytes a2
+#define flags a3
+#define raddr a4
+#define fn a5
+
+#define SIZEOF_FRAME ( 8 * FFI_SIZEOF_ARG )
+
+#ifdef __GNUC__
+ .abicalls
+#endif
+ .set mips4
+ .text
+ .align 2
+ .globl ffi_call_N32
+ .ent ffi_call_N32
+ffi_call_N32:
+.LFB3:
+ .frame $fp, SIZEOF_FRAME, ra
+ .mask 0xc0000000,-FFI_SIZEOF_ARG
+ .fmask 0x00000000,0
+
+ # Prologue
+ SUBU $sp, SIZEOF_FRAME # Frame size
+.LCFI0:
+ REG_S $fp, SIZEOF_FRAME - 2*FFI_SIZEOF_ARG($sp) # Save frame pointer
+ REG_S ra, SIZEOF_FRAME - 1*FFI_SIZEOF_ARG($sp) # Save return address
+.LCFI1:
+ move $fp, $sp
+.LCFI3:
+ move t9, callback # callback function pointer
+ REG_S bytes, 2*FFI_SIZEOF_ARG($fp) # bytes
+ REG_S flags, 3*FFI_SIZEOF_ARG($fp) # flags
+ REG_S raddr, 4*FFI_SIZEOF_ARG($fp) # raddr
+ REG_S fn, 5*FFI_SIZEOF_ARG($fp) # fn
+
+ # Allocate at least 4 words in the argstack
+ move v0, bytes
+ bge bytes, 4 * FFI_SIZEOF_ARG, bigger
+ LI v0, 4 * FFI_SIZEOF_ARG
+ b sixteen
+
+ bigger:
+ ADDU t4, v0, 2 * FFI_SIZEOF_ARG -1 # make sure it is aligned
+ and v0, t4, -2 * FFI_SIZEOF_ARG # to a proper boundry.
+
+sixteen:
+ SUBU $sp, $sp, v0 # move the stack pointer to reflect the
+ # arg space
+
+ move a0, $sp # 4 * FFI_SIZEOF_ARG
+ ADDU a3, $fp, 3 * FFI_SIZEOF_ARG
+
+ # Call ffi_prep_args
+ jal t9
+
+ # Copy the stack pointer to t9
+ move t9, $sp
+
+ # Fix the stack if there are more than 8 64bit slots worth
+ # of arguments.
+
+ # Load the number of bytes
+ REG_L t6, 2*FFI_SIZEOF_ARG($fp)
+
+ # Is it bigger than 8 * FFI_SIZEOF_ARG?
+ daddiu t8, t6, -(8 * FFI_SIZEOF_ARG)
+ bltz t8, loadregs
+
+ ADDU t9, t9, t8
+
+loadregs:
+
+ REG_L t6, 3*FFI_SIZEOF_ARG($fp) # load the flags word into t6.
+
+ and t4, t6, ((1<<FFI_FLAG_BITS)-1)
+ REG_L a0, 0*FFI_SIZEOF_ARG(t9)
+ beqz t4, arg1_next
+ bne t4, FFI_TYPE_FLOAT, arg1_doublep
+ l.s $f12, 0*FFI_SIZEOF_ARG(t9)
+ b arg1_next
+arg1_doublep:
+ l.d $f12, 0*FFI_SIZEOF_ARG(t9)
+arg1_next:
+
+ SRL t4, t6, 1*FFI_FLAG_BITS
+ and t4, ((1<<FFI_FLAG_BITS)-1)
+ REG_L a1, 1*FFI_SIZEOF_ARG(t9)
+ beqz t4, arg2_next
+ bne t4, FFI_TYPE_FLOAT, arg2_doublep
+ l.s $f13, 1*FFI_SIZEOF_ARG(t9)
+ b arg2_next
+arg2_doublep:
+ l.d $f13, 1*FFI_SIZEOF_ARG(t9)
+arg2_next:
+
+ SRL t4, t6, 2*FFI_FLAG_BITS
+ and t4, ((1<<FFI_FLAG_BITS)-1)
+ REG_L a2, 2*FFI_SIZEOF_ARG(t9)
+ beqz t4, arg3_next
+ bne t4, FFI_TYPE_FLOAT, arg3_doublep
+ l.s $f14, 2*FFI_SIZEOF_ARG(t9)
+ b arg3_next
+arg3_doublep:
+ l.d $f14, 2*FFI_SIZEOF_ARG(t9)
+arg3_next:
+
+ SRL t4, t6, 3*FFI_FLAG_BITS
+ and t4, ((1<<FFI_FLAG_BITS)-1)
+ REG_L a3, 3*FFI_SIZEOF_ARG(t9)
+ beqz t4, arg4_next
+ bne t4, FFI_TYPE_FLOAT, arg4_doublep
+ l.s $f15, 3*FFI_SIZEOF_ARG(t9)
+ b arg4_next
+arg4_doublep:
+ l.d $f15, 3*FFI_SIZEOF_ARG(t9)
+arg4_next:
+
+ SRL t4, t6, 4*FFI_FLAG_BITS
+ and t4, ((1<<FFI_FLAG_BITS)-1)
+ REG_L a4, 4*FFI_SIZEOF_ARG(t9)
+ beqz t4, arg5_next
+ bne t4, FFI_TYPE_FLOAT, arg5_doublep
+ l.s $f16, 4*FFI_SIZEOF_ARG(t9)
+ b arg5_next
+arg5_doublep:
+ l.d $f16, 4*FFI_SIZEOF_ARG(t9)
+arg5_next:
+
+ SRL t4, t6, 5*FFI_FLAG_BITS
+ and t4, ((1<<FFI_FLAG_BITS)-1)
+ REG_L a5, 5*FFI_SIZEOF_ARG(t9)
+ beqz t4, arg6_next
+ bne t4, FFI_TYPE_FLOAT, arg6_doublep
+ l.s $f17, 5*FFI_SIZEOF_ARG(t9)
+ b arg6_next
+arg6_doublep:
+ l.d $f17, 5*FFI_SIZEOF_ARG(t9)
+arg6_next:
+
+ SRL t4, t6, 6*FFI_FLAG_BITS
+ and t4, ((1<<FFI_FLAG_BITS)-1)
+ REG_L a6, 6*FFI_SIZEOF_ARG(t9)
+ beqz t4, arg7_next
+ bne t4, FFI_TYPE_FLOAT, arg7_doublep
+ l.s $f18, 6*FFI_SIZEOF_ARG(t9)
+ b arg7_next
+arg7_doublep:
+ l.d $f18, 6*FFI_SIZEOF_ARG(t9)
+arg7_next:
+
+ SRL t4, t6, 7*FFI_FLAG_BITS
+ and t4, ((1<<FFI_FLAG_BITS)-1)
+ REG_L a7, 7*FFI_SIZEOF_ARG(t9)
+ beqz t4, arg8_next
+ bne t4, FFI_TYPE_FLOAT, arg8_doublep
+ l.s $f19, 7*FFI_SIZEOF_ARG(t9)
+ b arg8_next
+arg8_doublep:
+ l.d $f19, 7*FFI_SIZEOF_ARG(t9)
+arg8_next:
+
+callit:
+ # Load the function pointer
+ REG_L t9, 5*FFI_SIZEOF_ARG($fp)
+
+ # If the return value pointer is NULL, assume no return value.
+ REG_L t5, 4*FFI_SIZEOF_ARG($fp)
+ beqz t5, noretval
+
+ # Shift the return type flag over
+ SRL t6, 8*FFI_FLAG_BITS
+
+ beq t6, FFI_TYPE_SINT32, retint
+ bne t6, FFI_TYPE_INT, retfloat
+retint:
+ jal t9
+ REG_L t4, 4*FFI_SIZEOF_ARG($fp)
+ REG_S v0, 0(t4)
+ b epilogue
+
+retfloat:
+ bne t6, FFI_TYPE_FLOAT, retdouble
+ jal t9
+ REG_L t4, 4*FFI_SIZEOF_ARG($fp)
+ s.s $f0, 0(t4)
+ b epilogue
+
+retdouble:
+ bne t6, FFI_TYPE_DOUBLE, retstruct_d
+ jal t9
+ REG_L t4, 4*FFI_SIZEOF_ARG($fp)
+ s.d $f0, 0(t4)
+ b epilogue
+
+retstruct_d:
+ bne t6, FFI_TYPE_STRUCT_D, retstruct_f
+ jal t9
+ REG_L t4, 4*FFI_SIZEOF_ARG($fp)
+ s.d $f0, 0(t4)
+ b epilogue
+
+retstruct_f:
+ bne t6, FFI_TYPE_STRUCT_F, retstruct_d_d
+ jal t9
+ REG_L t4, 4*FFI_SIZEOF_ARG($fp)
+ s.s $f0, 0(t4)
+ b epilogue
+
+retstruct_d_d:
+ bne t6, FFI_TYPE_STRUCT_DD, retstruct_f_f
+ jal t9
+ REG_L t4, 4*FFI_SIZEOF_ARG($fp)
+ s.d $f0, 0(t4)
+ s.d $f2, 8(t4)
+ b epilogue
+
+retstruct_f_f:
+ bne t6, FFI_TYPE_STRUCT_FF, retstruct_d_f
+ jal t9
+ REG_L t4, 4*FFI_SIZEOF_ARG($fp)
+ s.s $f0, 0(t4)
+ s.s $f2, 4(t4)
+ b epilogue
+
+retstruct_d_f:
+ bne t6, FFI_TYPE_STRUCT_DF, retstruct_f_d
+ jal t9
+ REG_L t4, 4*FFI_SIZEOF_ARG($fp)
+ s.d $f0, 0(t4)
+ s.s $f2, 8(t4)
+ b epilogue
+
+retstruct_f_d:
+ bne t6, FFI_TYPE_STRUCT_FD, retstruct_d_soft
+ jal t9
+ REG_L t4, 4*FFI_SIZEOF_ARG($fp)
+ s.s $f0, 0(t4)
+ s.d $f2, 8(t4)
+ b epilogue
+
+retstruct_d_soft:
+ bne t6, FFI_TYPE_STRUCT_D_SOFT, retstruct_f_soft
+ jal t9
+ REG_L t4, 4*FFI_SIZEOF_ARG($fp)
+ sd v0, 0(t4)
+ b epilogue
+
+retstruct_f_soft:
+ bne t6, FFI_TYPE_STRUCT_F_SOFT, retstruct_d_d_soft
+ jal t9
+ REG_L t4, 4*FFI_SIZEOF_ARG($fp)
+ sw v0, 0(t4)
+ b epilogue
+
+retstruct_d_d_soft:
+ bne t6, FFI_TYPE_STRUCT_DD_SOFT, retstruct_f_f_soft
+ jal t9
+ REG_L t4, 4*FFI_SIZEOF_ARG($fp)
+ sd v0, 0(t4)
+ sd v1, 8(t4)
+ b epilogue
+
+retstruct_f_f_soft:
+ bne t6, FFI_TYPE_STRUCT_FF_SOFT, retstruct_d_f_soft
+ jal t9
+ REG_L t4, 4*FFI_SIZEOF_ARG($fp)
+ sw v0, 0(t4)
+ sw v1, 4(t4)
+ b epilogue
+
+retstruct_d_f_soft:
+ bne t6, FFI_TYPE_STRUCT_DF_SOFT, retstruct_f_d_soft
+ jal t9
+ REG_L t4, 4*FFI_SIZEOF_ARG($fp)
+ sd v0, 0(t4)
+ sw v1, 8(t4)
+ b epilogue
+
+retstruct_f_d_soft:
+ bne t6, FFI_TYPE_STRUCT_FD_SOFT, retstruct_small
+ jal t9
+ REG_L t4, 4*FFI_SIZEOF_ARG($fp)
+ sw v0, 0(t4)
+ sd v1, 8(t4)
+ b epilogue
+
+retstruct_small:
+ bne t6, FFI_TYPE_STRUCT_SMALL, retstruct_small2
+ jal t9
+ REG_L t4, 4*FFI_SIZEOF_ARG($fp)
+ REG_S v0, 0(t4)
+ b epilogue
+
+retstruct_small2:
+ bne t6, FFI_TYPE_STRUCT_SMALL2, retstruct
+ jal t9
+ REG_L t4, 4*FFI_SIZEOF_ARG($fp)
+ REG_S v0, 0(t4)
+ REG_S v1, 8(t4)
+ b epilogue
+
+retstruct:
+noretval:
+ jal t9
+
+ # Epilogue
+epilogue:
+ move $sp, $fp
+ REG_L $fp, SIZEOF_FRAME - 2*FFI_SIZEOF_ARG($sp) # Restore frame pointer
+ REG_L ra, SIZEOF_FRAME - 1*FFI_SIZEOF_ARG($sp) # Restore return address
+ ADDU $sp, SIZEOF_FRAME # Fix stack pointer
+ j ra
+
+.LFE3:
+ .end ffi_call_N32
+
+/* ffi_closure_N32. Expects address of the passed-in ffi_closure in t0
+ ($12). Stores any arguments passed in registers onto the stack,
+ then calls ffi_closure_mips_inner_N32, which then decodes
+ them.
+
+ Stack layout:
+
+ 20 - Start of parameters, original sp
+ 19 - Called function a7 save
+ 18 - Called function a6 save
+ 17 - Called function a5 save
+ 16 - Called function a4 save
+ 15 - Called function a3 save
+ 14 - Called function a2 save
+ 13 - Called function a1 save
+ 12 - Called function a0 save
+ 11 - Called function f19
+ 10 - Called function f18
+ 9 - Called function f17
+ 8 - Called function f16
+ 7 - Called function f15
+ 6 - Called function f14
+ 5 - Called function f13
+ 4 - Called function f12
+ 3 - return value high (v1 or $f2)
+ 2 - return value low (v0 or $f0)
+ 1 - ra save
+ 0 - gp save our sp points here
+ */
+
+#define SIZEOF_FRAME2 (20 * FFI_SIZEOF_ARG)
+
+#define A7_OFF2 (19 * FFI_SIZEOF_ARG)
+#define A6_OFF2 (18 * FFI_SIZEOF_ARG)
+#define A5_OFF2 (17 * FFI_SIZEOF_ARG)
+#define A4_OFF2 (16 * FFI_SIZEOF_ARG)
+#define A3_OFF2 (15 * FFI_SIZEOF_ARG)
+#define A2_OFF2 (14 * FFI_SIZEOF_ARG)
+#define A1_OFF2 (13 * FFI_SIZEOF_ARG)
+#define A0_OFF2 (12 * FFI_SIZEOF_ARG)
+
+#define F19_OFF2 (11 * FFI_SIZEOF_ARG)
+#define F18_OFF2 (10 * FFI_SIZEOF_ARG)
+#define F17_OFF2 (9 * FFI_SIZEOF_ARG)
+#define F16_OFF2 (8 * FFI_SIZEOF_ARG)
+#define F15_OFF2 (7 * FFI_SIZEOF_ARG)
+#define F14_OFF2 (6 * FFI_SIZEOF_ARG)
+#define F13_OFF2 (5 * FFI_SIZEOF_ARG)
+#define F12_OFF2 (4 * FFI_SIZEOF_ARG)
+
+#define V1_OFF2 (3 * FFI_SIZEOF_ARG)
+#define V0_OFF2 (2 * FFI_SIZEOF_ARG)
+
+#define RA_OFF2 (1 * FFI_SIZEOF_ARG)
+#define GP_OFF2 (0 * FFI_SIZEOF_ARG)
+
+ .align 2
+ .globl ffi_closure_N32
+ .ent ffi_closure_N32
+ffi_closure_N32:
+.LFB2:
+ .frame $sp, SIZEOF_FRAME2, ra
+ .mask 0x90000000,-(SIZEOF_FRAME2 - RA_OFF2)
+ .fmask 0x00000000,0
+ SUBU $sp, SIZEOF_FRAME2
+.LCFI5:
+ .cpsetup t9, GP_OFF2, ffi_closure_N32
+ REG_S ra, RA_OFF2($sp) # Save return address
+.LCFI6:
+ # Store all possible argument registers. If there are more than
+ # fit in registers, then they were stored on the stack.
+ REG_S a0, A0_OFF2($sp)
+ REG_S a1, A1_OFF2($sp)
+ REG_S a2, A2_OFF2($sp)
+ REG_S a3, A3_OFF2($sp)
+ REG_S a4, A4_OFF2($sp)
+ REG_S a5, A5_OFF2($sp)
+ REG_S a6, A6_OFF2($sp)
+ REG_S a7, A7_OFF2($sp)
+
+ # Store all possible float/double registers.
+ s.d $f12, F12_OFF2($sp)
+ s.d $f13, F13_OFF2($sp)
+ s.d $f14, F14_OFF2($sp)
+ s.d $f15, F15_OFF2($sp)
+ s.d $f16, F16_OFF2($sp)
+ s.d $f17, F17_OFF2($sp)
+ s.d $f18, F18_OFF2($sp)
+ s.d $f19, F19_OFF2($sp)
+
+ # Call ffi_closure_mips_inner_N32 to do the real work.
+ LA t9, ffi_closure_mips_inner_N32
+ move a0, $12 # Pointer to the ffi_closure
+ ADDU a1, $sp, V0_OFF2
+ ADDU a2, $sp, A0_OFF2
+ ADDU a3, $sp, F12_OFF2
+ jalr t9
+
+ # Return flags are in v0
+ bne v0, FFI_TYPE_SINT32, cls_retint
+ lw v0, V0_OFF2($sp)
+ b cls_epilogue
+
+cls_retint:
+ bne v0, FFI_TYPE_INT, cls_retfloat
+ REG_L v0, V0_OFF2($sp)
+ b cls_epilogue
+
+cls_retfloat:
+ bne v0, FFI_TYPE_FLOAT, cls_retdouble
+ l.s $f0, V0_OFF2($sp)
+ b cls_epilogue
+
+cls_retdouble:
+ bne v0, FFI_TYPE_DOUBLE, cls_retstruct_d
+ l.d $f0, V0_OFF2($sp)
+ b cls_epilogue
+
+cls_retstruct_d:
+ bne v0, FFI_TYPE_STRUCT_D, cls_retstruct_f
+ l.d $f0, V0_OFF2($sp)
+ b cls_epilogue
+
+cls_retstruct_f:
+ bne v0, FFI_TYPE_STRUCT_F, cls_retstruct_d_d
+ l.s $f0, V0_OFF2($sp)
+ b cls_epilogue
+
+cls_retstruct_d_d:
+ bne v0, FFI_TYPE_STRUCT_DD, cls_retstruct_f_f
+ l.d $f0, V0_OFF2($sp)
+ l.d $f2, V1_OFF2($sp)
+ b cls_epilogue
+
+cls_retstruct_f_f:
+ bne v0, FFI_TYPE_STRUCT_FF, cls_retstruct_d_f
+ l.s $f0, V0_OFF2($sp)
+ l.s $f2, V1_OFF2($sp)
+ b cls_epilogue
+
+cls_retstruct_d_f:
+ bne v0, FFI_TYPE_STRUCT_DF, cls_retstruct_f_d
+ l.d $f0, V0_OFF2($sp)
+ l.s $f2, V1_OFF2($sp)
+ b cls_epilogue
+
+cls_retstruct_f_d:
+ bne v0, FFI_TYPE_STRUCT_FD, cls_retstruct_small2
+ l.s $f0, V0_OFF2($sp)
+ l.d $f2, V1_OFF2($sp)
+ b cls_epilogue
+
+cls_retstruct_small2:
+ REG_L v0, V0_OFF2($sp)
+ REG_L v1, V1_OFF2($sp)
+
+ # Epilogue
+cls_epilogue:
+ REG_L ra, RA_OFF2($sp) # Restore return address
+ .cpreturn
+ ADDU $sp, SIZEOF_FRAME2
+ j ra
+.LFE2:
+ .end ffi_closure_N32
+
+#ifdef __GNUC__
+ .section .eh_frame,"aw",@progbits
+.Lframe1:
+ .4byte .LECIE1-.LSCIE1 # length
+.LSCIE1:
+ .4byte 0x0 # CIE
+ .byte 0x1 # Version 1
+ .ascii "\000" # Augmentation
+ .uleb128 0x1 # Code alignment 1
+ .sleb128 -4 # Data alignment -4
+ .byte 0x1f # Return Address $31
+ .byte 0xc # DW_CFA_def_cfa
+ .uleb128 0x1d # in $sp
+ .uleb128 0x0 # offset 0
+ .align EH_FRAME_ALIGN
+.LECIE1:
+
+.LSFDE1:
+ .4byte .LEFDE1-.LASFDE1 # length.
+.LASFDE1:
+ .4byte .LASFDE1-.Lframe1 # CIE_pointer.
+ FDE_ADDR_BYTES .LFB3 # initial_location.
+ FDE_ADDR_BYTES .LFE3-.LFB3 # address_range.
+ .byte 0x4 # DW_CFA_advance_loc4
+ .4byte .LCFI0-.LFB3 # to .LCFI0
+ .byte 0xe # DW_CFA_def_cfa_offset
+ .uleb128 SIZEOF_FRAME # adjust stack.by SIZEOF_FRAME
+ .byte 0x4 # DW_CFA_advance_loc4
+ .4byte .LCFI1-.LCFI0 # to .LCFI1
+ .byte 0x9e # DW_CFA_offset of $fp
+ .uleb128 2*FFI_SIZEOF_ARG/4 #
+ .byte 0x9f # DW_CFA_offset of ra
+ .uleb128 1*FFI_SIZEOF_ARG/4 #
+ .byte 0x4 # DW_CFA_advance_loc4
+ .4byte .LCFI3-.LCFI1 # to .LCFI3
+ .byte 0xd # DW_CFA_def_cfa_register
+ .uleb128 0x1e # in $fp
+ .align EH_FRAME_ALIGN
+.LEFDE1:
+.LSFDE3:
+ .4byte .LEFDE3-.LASFDE3 # length
+.LASFDE3:
+ .4byte .LASFDE3-.Lframe1 # CIE_pointer.
+ FDE_ADDR_BYTES .LFB2 # initial_location.
+ FDE_ADDR_BYTES .LFE2-.LFB2 # address_range.
+ .byte 0x4 # DW_CFA_advance_loc4
+ .4byte .LCFI5-.LFB2 # to .LCFI5
+ .byte 0xe # DW_CFA_def_cfa_offset
+ .uleb128 SIZEOF_FRAME2 # adjust stack.by SIZEOF_FRAME
+ .byte 0x4 # DW_CFA_advance_loc4
+ .4byte .LCFI6-.LCFI5 # to .LCFI6
+ .byte 0x9c # DW_CFA_offset of $gp ($28)
+ .uleb128 (SIZEOF_FRAME2 - GP_OFF2)/4
+ .byte 0x9f # DW_CFA_offset of ra ($31)
+ .uleb128 (SIZEOF_FRAME2 - RA_OFF2)/4
+ .align EH_FRAME_ALIGN
+.LEFDE3:
+#endif /* __GNUC__ */
+
+#endif
diff --git a/jni/ruby/ext/fiddle/libffi-3.2.1/src/mips/o32.S b/jni/ruby/ext/fiddle/libffi-3.2.1/src/mips/o32.S
new file mode 100644
index 0000000..eb27981
--- /dev/null
+++ b/jni/ruby/ext/fiddle/libffi-3.2.1/src/mips/o32.S
@@ -0,0 +1,381 @@
+/* -----------------------------------------------------------------------
+ o32.S - Copyright (c) 1996, 1998, 2005 Red Hat, Inc.
+
+ MIPS Foreign Function Interface
+
+ Permission is hereby granted, free of charge, to any person obtaining
+ a copy of this software and associated documentation files (the
+ ``Software''), to deal in the Software without restriction, including
+ without limitation the rights to use, copy, modify, merge, publish,
+ distribute, sublicense, and/or sell copies of the Software, and to
+ permit persons to whom the Software is furnished to do so, subject to
+ the following conditions:
+
+ The above copyright notice and this permission notice shall be included
+ in all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND,
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+ HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ DEALINGS IN THE SOFTWARE.
+ ----------------------------------------------------------------------- */
+
+#define LIBFFI_ASM
+#include <fficonfig.h>
+#include <ffi.h>
+
+/* Only build this code if we are compiling for o32 */
+
+#if defined(FFI_MIPS_O32)
+
+#define callback a0
+#define bytes a2
+#define flags a3
+
+#define SIZEOF_FRAME (4 * FFI_SIZEOF_ARG + 2 * FFI_SIZEOF_ARG)
+#define A3_OFF (SIZEOF_FRAME + 3 * FFI_SIZEOF_ARG)
+#define FP_OFF (SIZEOF_FRAME - 2 * FFI_SIZEOF_ARG)
+#define RA_OFF (SIZEOF_FRAME - 1 * FFI_SIZEOF_ARG)
+
+ .abicalls
+ .text
+ .align 2
+ .globl ffi_call_O32
+ .ent ffi_call_O32
+ffi_call_O32:
+$LFB0:
+ # Prologue
+ SUBU $sp, SIZEOF_FRAME # Frame size
+$LCFI0:
+ REG_S $fp, FP_OFF($sp) # Save frame pointer
+$LCFI1:
+ REG_S ra, RA_OFF($sp) # Save return address
+$LCFI2:
+ move $fp, $sp
+
+$LCFI3:
+ move t9, callback # callback function pointer
+ REG_S flags, A3_OFF($fp) # flags
+
+ # Allocate at least 4 words in the argstack
+ LI v0, 4 * FFI_SIZEOF_ARG
+ blt bytes, v0, sixteen
+
+ ADDU v0, bytes, 7 # make sure it is aligned
+ and v0, -8 # to an 8 byte boundry
+
+sixteen:
+ SUBU $sp, v0 # move the stack pointer to reflect the
+ # arg space
+
+ ADDU a0, $sp, 4 * FFI_SIZEOF_ARG
+
+ jalr t9
+
+ REG_L t0, A3_OFF($fp) # load the flags word
+ SRL t2, t0, 4 # shift our arg info
+ and t0, ((1<<4)-1) # mask out the return type
+
+ ADDU $sp, 4 * FFI_SIZEOF_ARG # adjust $sp to new args
+
+ bnez t0, pass_d # make it quick for int
+ REG_L a0, 0*FFI_SIZEOF_ARG($sp) # just go ahead and load the
+ REG_L a1, 1*FFI_SIZEOF_ARG($sp) # four regs.
+ REG_L a2, 2*FFI_SIZEOF_ARG($sp)
+ REG_L a3, 3*FFI_SIZEOF_ARG($sp)
+ b call_it
+
+pass_d:
+ bne t0, FFI_ARGS_D, pass_f
+ l.d $f12, 0*FFI_SIZEOF_ARG($sp) # load $fp regs from args
+ REG_L a2, 2*FFI_SIZEOF_ARG($sp) # passing a double
+ REG_L a3, 3*FFI_SIZEOF_ARG($sp)
+ b call_it
+
+pass_f:
+ bne t0, FFI_ARGS_F, pass_d_d
+ l.s $f12, 0*FFI_SIZEOF_ARG($sp) # load $fp regs from args
+ REG_L a1, 1*FFI_SIZEOF_ARG($sp) # passing a float
+ REG_L a2, 2*FFI_SIZEOF_ARG($sp)
+ REG_L a3, 3*FFI_SIZEOF_ARG($sp)
+ b call_it
+
+pass_d_d:
+ bne t0, FFI_ARGS_DD, pass_f_f
+ l.d $f12, 0*FFI_SIZEOF_ARG($sp) # load $fp regs from args
+ l.d $f14, 2*FFI_SIZEOF_ARG($sp) # passing two doubles
+ b call_it
+
+pass_f_f:
+ bne t0, FFI_ARGS_FF, pass_d_f
+ l.s $f12, 0*FFI_SIZEOF_ARG($sp) # load $fp regs from args
+ l.s $f14, 1*FFI_SIZEOF_ARG($sp) # passing two floats
+ REG_L a2, 2*FFI_SIZEOF_ARG($sp)
+ REG_L a3, 3*FFI_SIZEOF_ARG($sp)
+ b call_it
+
+pass_d_f:
+ bne t0, FFI_ARGS_DF, pass_f_d
+ l.d $f12, 0*FFI_SIZEOF_ARG($sp) # load $fp regs from args
+ l.s $f14, 2*FFI_SIZEOF_ARG($sp) # passing double and float
+ REG_L a3, 3*FFI_SIZEOF_ARG($sp)
+ b call_it
+
+pass_f_d:
+ # assume that the only other combination must be float then double
+ # bne t0, FFI_ARGS_F_D, call_it
+ l.s $f12, 0*FFI_SIZEOF_ARG($sp) # load $fp regs from args
+ l.d $f14, 2*FFI_SIZEOF_ARG($sp) # passing double and float
+
+call_it:
+ # Load the function pointer
+ REG_L t9, SIZEOF_FRAME + 5*FFI_SIZEOF_ARG($fp)
+
+ # If the return value pointer is NULL, assume no return value.
+ REG_L t1, SIZEOF_FRAME + 4*FFI_SIZEOF_ARG($fp)
+ beqz t1, noretval
+
+ bne t2, FFI_TYPE_INT, retlonglong
+ jalr t9
+ REG_L t0, SIZEOF_FRAME + 4*FFI_SIZEOF_ARG($fp)
+ REG_S v0, 0(t0)
+ b epilogue
+
+retlonglong:
+ # Really any 64-bit int, signed or not.
+ bne t2, FFI_TYPE_UINT64, retfloat
+ jalr t9
+ REG_L t0, SIZEOF_FRAME + 4*FFI_SIZEOF_ARG($fp)
+ REG_S v1, 4(t0)
+ REG_S v0, 0(t0)
+ b epilogue
+
+retfloat:
+ bne t2, FFI_TYPE_FLOAT, retdouble
+ jalr t9
+ REG_L t0, SIZEOF_FRAME + 4*FFI_SIZEOF_ARG($fp)
+ s.s $f0, 0(t0)
+ b epilogue
+
+retdouble:
+ bne t2, FFI_TYPE_DOUBLE, noretval
+ jalr t9
+ REG_L t0, SIZEOF_FRAME + 4*FFI_SIZEOF_ARG($fp)
+ s.d $f0, 0(t0)
+ b epilogue
+
+noretval:
+ jalr t9
+
+ # Epilogue
+epilogue:
+ move $sp, $fp
+ REG_L $fp, FP_OFF($sp) # Restore frame pointer
+ REG_L ra, RA_OFF($sp) # Restore return address
+ ADDU $sp, SIZEOF_FRAME # Fix stack pointer
+ j ra
+
+$LFE0:
+ .end ffi_call_O32
+
+
+/* ffi_closure_O32. Expects address of the passed-in ffi_closure
+ in t4 ($12). Stores any arguments passed in registers onto the
+ stack, then calls ffi_closure_mips_inner_O32, which
+ then decodes them.
+
+ Stack layout:
+
+ 3 - a3 save
+ 2 - a2 save
+ 1 - a1 save
+ 0 - a0 save, original sp
+ -1 - ra save
+ -2 - fp save
+ -3 - $16 (s0) save
+ -4 - cprestore
+ -5 - return value high (v1)
+ -6 - return value low (v0)
+ -7 - f14 (le high, be low)
+ -8 - f14 (le low, be high)
+ -9 - f12 (le high, be low)
+ -10 - f12 (le low, be high)
+ -11 - Called function a3 save
+ -12 - Called function a2 save
+ -13 - Called function a1 save
+ -14 - Called function a0 save, our sp and fp point here
+ */
+
+#define SIZEOF_FRAME2 (14 * FFI_SIZEOF_ARG)
+#define A3_OFF2 (SIZEOF_FRAME2 + 3 * FFI_SIZEOF_ARG)
+#define A2_OFF2 (SIZEOF_FRAME2 + 2 * FFI_SIZEOF_ARG)
+#define A1_OFF2 (SIZEOF_FRAME2 + 1 * FFI_SIZEOF_ARG)
+#define A0_OFF2 (SIZEOF_FRAME2 + 0 * FFI_SIZEOF_ARG)
+#define RA_OFF2 (SIZEOF_FRAME2 - 1 * FFI_SIZEOF_ARG)
+#define FP_OFF2 (SIZEOF_FRAME2 - 2 * FFI_SIZEOF_ARG)
+#define S0_OFF2 (SIZEOF_FRAME2 - 3 * FFI_SIZEOF_ARG)
+#define GP_OFF2 (SIZEOF_FRAME2 - 4 * FFI_SIZEOF_ARG)
+#define V1_OFF2 (SIZEOF_FRAME2 - 5 * FFI_SIZEOF_ARG)
+#define V0_OFF2 (SIZEOF_FRAME2 - 6 * FFI_SIZEOF_ARG)
+#define FA_1_1_OFF2 (SIZEOF_FRAME2 - 7 * FFI_SIZEOF_ARG)
+#define FA_1_0_OFF2 (SIZEOF_FRAME2 - 8 * FFI_SIZEOF_ARG)
+#define FA_0_1_OFF2 (SIZEOF_FRAME2 - 9 * FFI_SIZEOF_ARG)
+#define FA_0_0_OFF2 (SIZEOF_FRAME2 - 10 * FFI_SIZEOF_ARG)
+
+ .text
+ .align 2
+ .globl ffi_closure_O32
+ .ent ffi_closure_O32
+ffi_closure_O32:
+$LFB1:
+ # Prologue
+ .frame $fp, SIZEOF_FRAME2, ra
+ .set noreorder
+ .cpload t9
+ .set reorder
+ SUBU $sp, SIZEOF_FRAME2
+ .cprestore GP_OFF2
+$LCFI4:
+ REG_S $16, S0_OFF2($sp) # Save s0
+ REG_S $fp, FP_OFF2($sp) # Save frame pointer
+ REG_S ra, RA_OFF2($sp) # Save return address
+$LCFI6:
+ move $fp, $sp
+
+$LCFI7:
+ # Store all possible argument registers. If there are more than
+ # four arguments, then they are stored above where we put a3.
+ REG_S a0, A0_OFF2($fp)
+ REG_S a1, A1_OFF2($fp)
+ REG_S a2, A2_OFF2($fp)
+ REG_S a3, A3_OFF2($fp)
+
+ # Load ABI enum to s0
+ REG_L $16, 20($12) # cif pointer follows tramp.
+ REG_L $16, 0($16) # abi is first member.
+
+ li $13, 1 # FFI_O32
+ bne $16, $13, 1f # Skip fp save if FFI_O32_SOFT_FLOAT
+
+ # Store all possible float/double registers.
+ s.d $f12, FA_0_0_OFF2($fp)
+ s.d $f14, FA_1_0_OFF2($fp)
+1:
+ # Call ffi_closure_mips_inner_O32 to do the work.
+ la t9, ffi_closure_mips_inner_O32
+ move a0, $12 # Pointer to the ffi_closure
+ addu a1, $fp, V0_OFF2
+ addu a2, $fp, A0_OFF2
+ addu a3, $fp, FA_0_0_OFF2
+ jalr t9
+
+ # Load the return value into the appropriate register.
+ move $8, $2
+ li $9, FFI_TYPE_VOID
+ beq $8, $9, closure_done
+
+ li $13, 1 # FFI_O32
+ bne $16, $13, 1f # Skip fp restore if FFI_O32_SOFT_FLOAT
+
+ li $9, FFI_TYPE_FLOAT
+ l.s $f0, V0_OFF2($fp)
+ beq $8, $9, closure_done
+
+ li $9, FFI_TYPE_DOUBLE
+ l.d $f0, V0_OFF2($fp)
+ beq $8, $9, closure_done
+1:
+ REG_L $3, V1_OFF2($fp)
+ REG_L $2, V0_OFF2($fp)
+
+closure_done:
+ # Epilogue
+ move $sp, $fp
+ REG_L $16, S0_OFF2($sp) # Restore s0
+ REG_L $fp, FP_OFF2($sp) # Restore frame pointer
+ REG_L ra, RA_OFF2($sp) # Restore return address
+ ADDU $sp, SIZEOF_FRAME2
+ j ra
+$LFE1:
+ .end ffi_closure_O32
+
+/* DWARF-2 unwind info. */
+
+ .section .eh_frame,"a",@progbits
+$Lframe0:
+ .4byte $LECIE0-$LSCIE0 # Length of Common Information Entry
+$LSCIE0:
+ .4byte 0x0 # CIE Identifier Tag
+ .byte 0x1 # CIE Version
+ .ascii "zR\0" # CIE Augmentation
+ .uleb128 0x1 # CIE Code Alignment Factor
+ .sleb128 4 # CIE Data Alignment Factor
+ .byte 0x1f # CIE RA Column
+ .uleb128 0x1 # Augmentation size
+ .byte 0x00 # FDE Encoding (absptr)
+ .byte 0xc # DW_CFA_def_cfa
+ .uleb128 0x1d
+ .uleb128 0x0
+ .align 2
+$LECIE0:
+$LSFDE0:
+ .4byte $LEFDE0-$LASFDE0 # FDE Length
+$LASFDE0:
+ .4byte $LASFDE0-$Lframe0 # FDE CIE offset
+ .4byte $LFB0 # FDE initial location
+ .4byte $LFE0-$LFB0 # FDE address range
+ .uleb128 0x0 # Augmentation size
+ .byte 0x4 # DW_CFA_advance_loc4
+ .4byte $LCFI0-$LFB0
+ .byte 0xe # DW_CFA_def_cfa_offset
+ .uleb128 0x18
+ .byte 0x4 # DW_CFA_advance_loc4
+ .4byte $LCFI2-$LCFI0
+ .byte 0x11 # DW_CFA_offset_extended_sf
+ .uleb128 0x1e # $fp
+ .sleb128 -2 # SIZEOF_FRAME2 - 2*FFI_SIZEOF_ARG($sp)
+ .byte 0x11 # DW_CFA_offset_extended_sf
+ .uleb128 0x1f # $ra
+ .sleb128 -1 # SIZEOF_FRAME2 - 1*FFI_SIZEOF_ARG($sp)
+ .byte 0x4 # DW_CFA_advance_loc4
+ .4byte $LCFI3-$LCFI2
+ .byte 0xc # DW_CFA_def_cfa
+ .uleb128 0x1e
+ .uleb128 0x18
+ .align 2
+$LEFDE0:
+$LSFDE1:
+ .4byte $LEFDE1-$LASFDE1 # FDE Length
+$LASFDE1:
+ .4byte $LASFDE1-$Lframe0 # FDE CIE offset
+ .4byte $LFB1 # FDE initial location
+ .4byte $LFE1-$LFB1 # FDE address range
+ .uleb128 0x0 # Augmentation size
+ .byte 0x4 # DW_CFA_advance_loc4
+ .4byte $LCFI4-$LFB1
+ .byte 0xe # DW_CFA_def_cfa_offset
+ .uleb128 0x38
+ .byte 0x4 # DW_CFA_advance_loc4
+ .4byte $LCFI6-$LCFI4
+ .byte 0x11 # DW_CFA_offset_extended_sf
+ .uleb128 0x10 # $16
+ .sleb128 -3 # SIZEOF_FRAME2 - 3*FFI_SIZEOF_ARG($sp)
+ .byte 0x11 # DW_CFA_offset_extended_sf
+ .uleb128 0x1e # $fp
+ .sleb128 -2 # SIZEOF_FRAME2 - 2*FFI_SIZEOF_ARG($sp)
+ .byte 0x11 # DW_CFA_offset_extended_sf
+ .uleb128 0x1f # $ra
+ .sleb128 -1 # SIZEOF_FRAME2 - 1*FFI_SIZEOF_ARG($sp)
+ .byte 0x4 # DW_CFA_advance_loc4
+ .4byte $LCFI7-$LCFI6
+ .byte 0xc # DW_CFA_def_cfa
+ .uleb128 0x1e
+ .uleb128 0x38
+ .align 2
+$LEFDE1:
+
+#endif
diff --git a/jni/ruby/ext/fiddle/libffi-3.2.1/src/moxie/eabi.S b/jni/ruby/ext/fiddle/libffi-3.2.1/src/moxie/eabi.S
new file mode 100644
index 0000000..ac7aceb
--- /dev/null
+++ b/jni/ruby/ext/fiddle/libffi-3.2.1/src/moxie/eabi.S
@@ -0,0 +1,101 @@
+/* -----------------------------------------------------------------------
+ eabi.S - Copyright (c) 2012, 2013 Anthony Green
+
+ Moxie Assembly glue.
+
+ Permission is hereby granted, free of charge, to any person obtaining
+ a copy of this software and associated documentation files (the
+ ``Software''), to deal in the Software without restriction, including
+ without limitation the rights to use, copy, modify, merge, publish,
+ distribute, sublicense, and/or sell copies of the Software, and to
+ permit persons to whom the Software is furnished to do so, subject to
+ the following conditions:
+
+ The above copyright notice and this permission notice shall be included
+ in all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ OTHER DEALINGS IN THE SOFTWARE.
+ ----------------------------------------------------------------------- */
+
+#define LIBFFI_ASM
+#include <fficonfig.h>
+#include <ffi.h>
+
+ .globl ffi_prep_args_EABI
+
+ .text
+ .p2align 4
+ .globl ffi_call_EABI
+ .type ffi_call_EABI, @function
+
+ # $r0 : ffi_prep_args
+ # $r1 : &ecif
+ # $r2 : cif->bytes
+ # $r3 : fig->flags
+ # $r4 : ecif.rvalue
+ # $r5 : fn
+
+ffi_call_EABI:
+ push $sp, $r6
+ push $sp, $r7
+ push $sp, $r8
+ dec $sp, 24
+
+ /* Store incoming args on stack. */
+ sto.l 0($sp), $r0 /* ffi_prep_args */
+ sto.l 4($sp), $r1 /* ecif */
+ sto.l 8($sp), $r2 /* bytes */
+ sto.l 12($sp), $r3 /* flags */
+ sto.l 16($sp), $r4 /* &rvalue */
+ sto.l 20($sp), $r5 /* fn */
+
+ /* Call ffi_prep_args. */
+ mov $r6, $r4 /* Save result buffer */
+ mov $r7, $r5 /* Save the target fn */
+ mov $r8, $r3 /* Save the flags */
+ sub.l $sp, $r2 /* Allocate stack space */
+ mov $r0, $sp /* We can stomp over $r0 */
+ /* $r1 is already set up */
+ jsra ffi_prep_args
+
+ /* Load register arguments. */
+ ldo.l $r0, 0($sp)
+ ldo.l $r1, 4($sp)
+ ldo.l $r2, 8($sp)
+ ldo.l $r3, 12($sp)
+ ldo.l $r4, 16($sp)
+ ldo.l $r5, 20($sp)
+
+ /* Call the target function. */
+ jsr $r7
+
+ ldi.l $r7, 0xffffffff
+ cmp $r8, $r7
+ beq retstruct
+
+ ldi.l $r7, 4
+ cmp $r8, $r7
+ bgt ret2reg
+
+ st.l ($r6), $r0
+ jmpa retdone
+
+ret2reg:
+ st.l ($r6), $r0
+ sto.l 4($r6), $r1
+
+retstruct:
+retdone:
+ /* Return. */
+ ldo.l $r6, -4($fp)
+ ldo.l $r7, -8($fp)
+ ldo.l $r8, -12($fp)
+ ret
+ .size ffi_call_EABI, .-ffi_call_EABI
+
diff --git a/jni/ruby/ext/fiddle/libffi-3.2.1/src/moxie/ffi.c b/jni/ruby/ext/fiddle/libffi-3.2.1/src/moxie/ffi.c
new file mode 100644
index 0000000..540a042
--- /dev/null
+++ b/jni/ruby/ext/fiddle/libffi-3.2.1/src/moxie/ffi.c
@@ -0,0 +1,272 @@
+/* -----------------------------------------------------------------------
+ ffi.c - Copyright (C) 2012, 2013 Anthony Green
+
+ Moxie Foreign Function Interface
+
+ Permission is hereby granted, free of charge, to any person obtaining
+ a copy of this software and associated documentation files (the
+ ``Software''), to deal in the Software without restriction, including
+ without limitation the rights to use, copy, modify, merge, publish,
+ distribute, sublicense, and/or sell copies of the Software, and to
+ permit persons to whom the Software is furnished to do so, subject to
+ the following conditions:
+
+ The above copyright notice and this permission notice shall be included
+ in all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND,
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+ HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ DEALINGS IN THE SOFTWARE.
+ ----------------------------------------------------------------------- */
+
+#include <ffi.h>
+#include <ffi_common.h>
+
+#include <stdlib.h>
+
+/* ffi_prep_args is called by the assembly routine once stack space
+ has been allocated for the function's arguments */
+
+void *ffi_prep_args(char *stack, extended_cif *ecif)
+{
+ register unsigned int i;
+ register void **p_argv;
+ register char *argp;
+ register ffi_type **p_arg;
+ register int count = 0;
+
+ p_argv = ecif->avalue;
+ argp = stack;
+
+ if (ecif->cif->rtype->type == FFI_TYPE_STRUCT)
+ {
+ *(void **) argp = ecif->rvalue;
+ argp += 4;
+ }
+
+ for (i = ecif->cif->nargs, p_arg = ecif->cif->arg_types;
+ (i != 0);
+ i--, p_arg++)
+ {
+ size_t z;
+
+ z = (*p_arg)->size;
+
+ if ((*p_arg)->type == FFI_TYPE_STRUCT)
+ {
+ z = sizeof(void*);
+ *(void **) argp = *p_argv;
+ }
+ else if (z < sizeof(int))
+ {
+ z = sizeof(int);
+ switch ((*p_arg)->type)
+ {
+ case FFI_TYPE_SINT8:
+ *(signed int *) argp = (signed int)*(SINT8 *)(* p_argv);
+ break;
+
+ case FFI_TYPE_UINT8:
+ *(unsigned int *) argp = (unsigned int)*(UINT8 *)(* p_argv);
+ break;
+
+ case FFI_TYPE_SINT16:
+ *(signed int *) argp = (signed int)*(SINT16 *)(* p_argv);
+ break;
+
+ case FFI_TYPE_UINT16:
+ *(unsigned int *) argp = (unsigned int)*(UINT16 *)(* p_argv);
+ break;
+
+ default:
+ FFI_ASSERT(0);
+ }
+ }
+ else if (z == sizeof(int))
+ {
+ *(unsigned int *) argp = (unsigned int)*(UINT32 *)(* p_argv);
+ }
+ else
+ {
+ memcpy(argp, *p_argv, z);
+ }
+ p_argv++;
+ argp += z;
+ count += z;
+ }
+
+ return (stack + ((count > 24) ? 24 : ALIGN_DOWN(count, 8)));
+}
+
+/* Perform machine dependent cif processing */
+ffi_status ffi_prep_cif_machdep(ffi_cif *cif)
+{
+ if (cif->rtype->type == FFI_TYPE_STRUCT)
+ cif->flags = -1;
+ else
+ cif->flags = cif->rtype->size;
+
+ cif->bytes = ALIGN (cif->bytes, 8);
+
+ return FFI_OK;
+}
+
+extern void ffi_call_EABI(void *(*)(char *, extended_cif *),
+ extended_cif *,
+ unsigned, unsigned,
+ unsigned *,
+ void (*fn)(void));
+
+void ffi_call(ffi_cif *cif,
+ void (*fn)(void),
+ void *rvalue,
+ void **avalue)
+{
+ extended_cif ecif;
+
+ ecif.cif = cif;
+ ecif.avalue = avalue;
+
+ /* If the return value is a struct and we don't have a return */
+ /* value address then we need to make one */
+
+ if ((rvalue == NULL) &&
+ (cif->rtype->type == FFI_TYPE_STRUCT))
+ {
+ ecif.rvalue = alloca(cif->rtype->size);
+ }
+ else
+ ecif.rvalue = rvalue;
+
+ switch (cif->abi)
+ {
+ case FFI_EABI:
+ ffi_call_EABI(ffi_prep_args, &ecif, cif->bytes,
+ cif->flags, ecif.rvalue, fn);
+ break;
+ default:
+ FFI_ASSERT(0);
+ break;
+ }
+}
+
+void ffi_closure_eabi (unsigned arg1, unsigned arg2, unsigned arg3,
+ unsigned arg4, unsigned arg5, unsigned arg6)
+{
+ /* This function is called by a trampoline. The trampoline stows a
+ pointer to the ffi_closure object in $r7. We must save this
+ pointer in a place that will persist while we do our work. */
+ register ffi_closure *creg __asm__ ("$r12");
+ ffi_closure *closure = creg;
+
+ /* Arguments that don't fit in registers are found on the stack
+ at a fixed offset above the current frame pointer. */
+ register char *frame_pointer __asm__ ("$fp");
+
+ /* Pointer to a struct return value. */
+ void *struct_rvalue = (void *) arg1;
+
+ /* 6 words reserved for register args + 3 words from jsr */
+ char *stack_args = frame_pointer + 9*4;
+
+ /* Lay the register arguments down in a continuous chunk of memory. */
+ unsigned register_args[6] =
+ { arg1, arg2, arg3, arg4, arg5, arg6 };
+ char *register_args_ptr = (char *) register_args;
+
+ ffi_cif *cif = closure->cif;
+ ffi_type **arg_types = cif->arg_types;
+ void **avalue = alloca (cif->nargs * sizeof(void *));
+ char *ptr = (char *) register_args;
+ int i;
+
+ /* preserve struct type return pointer passing */
+ if ((cif->rtype != NULL) && (cif->rtype->type == FFI_TYPE_STRUCT)) {
+ ptr += 4;
+ register_args_ptr = (char *)&register_args[1];
+ }
+
+ /* Find the address of each argument. */
+ for (i = 0; i < cif->nargs; i++)
+ {
+ switch (arg_types[i]->type)
+ {
+ case FFI_TYPE_SINT8:
+ case FFI_TYPE_UINT8:
+ avalue[i] = ptr + 3;
+ break;
+ case FFI_TYPE_SINT16:
+ case FFI_TYPE_UINT16:
+ avalue[i] = ptr + 2;
+ break;
+ case FFI_TYPE_SINT32:
+ case FFI_TYPE_UINT32:
+ case FFI_TYPE_FLOAT:
+ case FFI_TYPE_POINTER:
+ avalue[i] = ptr;
+ break;
+ case FFI_TYPE_STRUCT:
+ avalue[i] = *(void**)ptr;
+ break;
+ default:
+ /* This is an 8-byte value. */
+ avalue[i] = ptr;
+ ptr += 4;
+ break;
+ }
+ ptr += 4;
+
+ /* If we've handled more arguments than fit in registers,
+ start looking at the those passed on the stack. */
+ if (ptr == &register_args[6])
+ ptr = stack_args;
+ }
+
+ /* Invoke the closure. */
+ if (cif->rtype && (cif->rtype->type == FFI_TYPE_STRUCT))
+ {
+ (closure->fun) (cif, struct_rvalue, avalue, closure->user_data);
+ }
+ else
+ {
+ /* Allocate space for the return value and call the function. */
+ long long rvalue;
+ (closure->fun) (cif, &rvalue, avalue, closure->user_data);
+ asm ("mov $r12, %0\n ld.l $r0, ($r12)\n ldo.l $r1, 4($r12)" : : "r" (&rvalue));
+ }
+}
+
+ffi_status
+ffi_prep_closure_loc (ffi_closure* closure,
+ ffi_cif* cif,
+ void (*fun)(ffi_cif*, void*, void**, void*),
+ void *user_data,
+ void *codeloc)
+{
+ unsigned short *tramp = (unsigned short *) &closure->tramp[0];
+ unsigned long fn = (long) ffi_closure_eabi;
+ unsigned long cls = (long) codeloc;
+
+ if (cif->abi != FFI_EABI)
+ return FFI_BAD_ABI;
+
+ fn = (unsigned long) ffi_closure_eabi;
+
+ tramp[0] = 0x01e0; /* ldi.l $r7, .... */
+ tramp[1] = cls >> 16;
+ tramp[2] = cls & 0xffff;
+ tramp[3] = 0x1a00; /* jmpa .... */
+ tramp[4] = fn >> 16;
+ tramp[5] = fn & 0xffff;
+
+ closure->cif = cif;
+ closure->fun = fun;
+ closure->user_data = user_data;
+
+ return FFI_OK;
+}
diff --git a/jni/ruby/ext/fiddle/libffi-3.2.1/src/moxie/ffitarget.h b/jni/ruby/ext/fiddle/libffi-3.2.1/src/moxie/ffitarget.h
new file mode 100644
index 0000000..623e3ec
--- /dev/null
+++ b/jni/ruby/ext/fiddle/libffi-3.2.1/src/moxie/ffitarget.h
@@ -0,0 +1,52 @@
+/* -----------------------------------------------------------------*-C-*-
+ ffitarget.h - Copyright (c) 2012, 2013 Anthony Green
+ Target configuration macros for Moxie
+
+ Permission is hereby granted, free of charge, to any person obtaining
+ a copy of this software and associated documentation files (the
+ ``Software''), to deal in the Software without restriction, including
+ without limitation the rights to use, copy, modify, merge, publish,
+ distribute, sublicense, and/or sell copies of the Software, and to
+ permit persons to whom the Software is furnished to do so, subject to
+ the following conditions:
+
+ The above copyright notice and this permission notice shall be included
+ in all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND,
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+ HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ DEALINGS IN THE SOFTWARE.
+
+ ----------------------------------------------------------------------- */
+
+#ifndef LIBFFI_TARGET_H
+#define LIBFFI_TARGET_H
+
+/* ---- System specific configurations ----------------------------------- */
+
+#ifndef LIBFFI_ASM
+typedef unsigned long ffi_arg;
+typedef signed long ffi_sarg;
+
+typedef enum ffi_abi {
+ FFI_FIRST_ABI = 0,
+ FFI_EABI,
+ FFI_DEFAULT_ABI = FFI_EABI,
+ FFI_LAST_ABI = FFI_DEFAULT_ABI + 1
+} ffi_abi;
+#endif
+
+/* ---- Definitions for closures ----------------------------------------- */
+
+#define FFI_CLOSURES 1
+#define FFI_NATIVE_RAW_API 0
+
+/* Trampolines are 12-bytes long. See ffi_prep_closure_loc. */
+#define FFI_TRAMPOLINE_SIZE (12)
+
+#endif
diff --git a/jni/ruby/ext/fiddle/libffi-3.2.1/src/nios2/ffi.c b/jni/ruby/ext/fiddle/libffi-3.2.1/src/nios2/ffi.c
new file mode 100644
index 0000000..2efa033
--- /dev/null
+++ b/jni/ruby/ext/fiddle/libffi-3.2.1/src/nios2/ffi.c
@@ -0,0 +1,304 @@
+/* libffi support for Altera Nios II.
+
+ Copyright (c) 2013 Mentor Graphics.
+
+ Permission is hereby granted, free of charge, to any person obtaining
+ a copy of this software and associated documentation files (the
+ ``Software''), to deal in the Software without restriction, including
+ without limitation the rights to use, copy, modify, merge, publish,
+ distribute, sublicense, and/or sell copies of the Software, and to
+ permit persons to whom the Software is furnished to do so, subject to
+ the following conditions:
+
+ The above copyright notice and this permission notice shall be
+ included in all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND,
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
+
+
+#include <ffi.h>
+#include <ffi_common.h>
+
+#include <stdlib.h>
+
+/* The Nios II Processor Reference Handbook defines the procedure call
+ ABI as follows.
+
+ Arguments are passed as if a structure containing the types of
+ the arguments were constructed. The first 16 bytes are passed in r4
+ through r7, the remainder on the stack. The first 16 bytes of a function
+ taking variable arguments are passed in r4-r7 in the same way.
+
+ Return values of types up to 8 bytes are returned in r2 and r3. For
+ return values greater than 8 bytes, the caller must allocate memory for
+ the result and pass the address as if it were argument 0.
+
+ While this isn't specified explicitly in the ABI documentation, GCC
+ promotes integral arguments smaller than int size to 32 bits.
+
+ Also of note, the ABI specifies that all structure objects are
+ aligned to 32 bits even if all their fields have a smaller natural
+ alignment. See FFI_AGGREGATE_ALIGNMENT. */
+
+
+/* Declare the assembly language hooks. */
+
+extern UINT64 ffi_call_sysv (void (*) (char *, extended_cif *),
+ extended_cif *,
+ unsigned,
+ void (*fn) (void));
+extern void ffi_closure_sysv (void);
+
+/* Perform machine-dependent cif processing. */
+
+ffi_status ffi_prep_cif_machdep (ffi_cif *cif)
+{
+ /* We always want at least 16 bytes in the parameter block since it
+ simplifies the low-level call function. Also round the parameter
+ block size up to a multiple of 4 bytes to preserve
+ 32-bit alignment of the stack pointer. */
+ if (cif->bytes < 16)
+ cif->bytes = 16;
+ else
+ cif->bytes = (cif->bytes + 3) & ~3;
+
+ return FFI_OK;
+}
+
+
+/* ffi_prep_args is called by the assembly routine to transfer arguments
+ to the stack using the pointers in the ecif array.
+ Note that the stack buffer is big enough to fit all the arguments,
+ but the first 16 bytes will be copied to registers for the actual
+ call. */
+
+void ffi_prep_args (char *stack, extended_cif *ecif)
+{
+ char *argp = stack;
+ unsigned int i;
+
+ /* The implicit return value pointer is passed as if it were a hidden
+ first argument. */
+ if (ecif->cif->rtype->type == FFI_TYPE_STRUCT
+ && ecif->cif->rtype->size > 8)
+ {
+ (*(void **) argp) = ecif->rvalue;
+ argp += 4;
+ }
+
+ for (i = 0; i < ecif->cif->nargs; i++)
+ {
+ void *avalue = ecif->avalue[i];
+ ffi_type *atype = ecif->cif->arg_types[i];
+ size_t size = atype->size;
+ size_t alignment = atype->alignment;
+
+ /* Align argp as appropriate for the argument type. */
+ if ((alignment - 1) & (unsigned) argp)
+ argp = (char *) ALIGN (argp, alignment);
+
+ /* Copy the argument, promoting integral types smaller than a
+ word to word size. */
+ if (size < sizeof (int))
+ {
+ size = sizeof (int);
+ switch (atype->type)
+ {
+ case FFI_TYPE_SINT8:
+ *(signed int *) argp = (signed int) *(SINT8 *) avalue;
+ break;
+
+ case FFI_TYPE_UINT8:
+ *(unsigned int *) argp = (unsigned int) *(UINT8 *) avalue;
+ break;
+
+ case FFI_TYPE_SINT16:
+ *(signed int *) argp = (signed int) *(SINT16 *) avalue;
+ break;
+
+ case FFI_TYPE_UINT16:
+ *(unsigned int *) argp = (unsigned int) *(UINT16 *) avalue;
+ break;
+
+ case FFI_TYPE_STRUCT:
+ memcpy (argp, avalue, atype->size);
+ break;
+
+ default:
+ FFI_ASSERT(0);
+ }
+ }
+ else if (size == sizeof (int))
+ *(unsigned int *) argp = (unsigned int) *(UINT32 *) avalue;
+ else
+ memcpy (argp, avalue, size);
+ argp += size;
+ }
+}
+
+
+/* Call FN using the prepared CIF. RVALUE points to space allocated by
+ the caller for the return value, and AVALUE is an array of argument
+ pointers. */
+
+void ffi_call (ffi_cif *cif, void (*fn) (void), void *rvalue, void **avalue)
+{
+
+ extended_cif ecif;
+ UINT64 result;
+
+ /* If bigret is true, this is the case where a return value of larger
+ than 8 bytes is handled by being passed by reference as an implicit
+ argument. */
+ int bigret = (cif->rtype->type == FFI_TYPE_STRUCT
+ && cif->rtype->size > 8);
+
+ ecif.cif = cif;
+ ecif.avalue = avalue;
+
+ /* Allocate space for return value if this is the pass-by-reference case
+ and the caller did not provide a buffer. */
+ if (rvalue == NULL && bigret)
+ ecif.rvalue = alloca (cif->rtype->size);
+ else
+ ecif.rvalue = rvalue;
+
+ result = ffi_call_sysv (ffi_prep_args, &ecif, cif->bytes, fn);
+
+ /* Now result contains the 64 bit contents returned from fn in
+ r2 and r3. Copy the value of the appropriate size to the user-provided
+ rvalue buffer. */
+ if (rvalue && !bigret)
+ switch (cif->rtype->size)
+ {
+ case 1:
+ *(UINT8 *)rvalue = (UINT8) result;
+ break;
+ case 2:
+ *(UINT16 *)rvalue = (UINT16) result;
+ break;
+ case 4:
+ *(UINT32 *)rvalue = (UINT32) result;
+ break;
+ case 8:
+ *(UINT64 *)rvalue = (UINT64) result;
+ break;
+ default:
+ memcpy (rvalue, (void *)&result, cif->rtype->size);
+ break;
+ }
+}
+
+/* This function is invoked from the closure trampoline to invoke
+ CLOSURE with argument block ARGS. Parse ARGS according to
+ CLOSURE->cfi and invoke CLOSURE->fun. */
+
+static UINT64
+ffi_closure_helper (unsigned char *args,
+ ffi_closure *closure)
+{
+ ffi_cif *cif = closure->cif;
+ unsigned char *argp = args;
+ void **parsed_args = alloca (cif->nargs * sizeof (void *));
+ UINT64 result;
+ void *retptr;
+ unsigned int i;
+
+ /* First figure out what to do about the return type. If this is the
+ big-structure-return case, the first arg is the hidden return buffer
+ allocated by the caller. */
+ if (cif->rtype->type == FFI_TYPE_STRUCT
+ && cif->rtype->size > 8)
+ {
+ retptr = *((void **) argp);
+ argp += 4;
+ }
+ else
+ retptr = (void *) &result;
+
+ /* Fill in the array of argument pointers. */
+ for (i = 0; i < cif->nargs; i++)
+ {
+ size_t size = cif->arg_types[i]->size;
+ size_t alignment = cif->arg_types[i]->alignment;
+
+ /* Align argp as appropriate for the argument type. */
+ if ((alignment - 1) & (unsigned) argp)
+ argp = (char *) ALIGN (argp, alignment);
+
+ /* Arguments smaller than an int are promoted to int. */
+ if (size < sizeof (int))
+ size = sizeof (int);
+
+ /* Store the pointer. */
+ parsed_args[i] = argp;
+ argp += size;
+ }
+
+ /* Call the user-supplied function. */
+ (closure->fun) (cif, retptr, parsed_args, closure->user_data);
+ return result;
+}
+
+
+/* Initialize CLOSURE with a trampoline to call FUN with
+ CIF and USER_DATA. */
+ffi_status
+ffi_prep_closure_loc (ffi_closure* closure,
+ ffi_cif* cif,
+ void (*fun) (ffi_cif*, void*, void**, void*),
+ void *user_data,
+ void *codeloc)
+{
+ unsigned int *tramp = (unsigned int *) &closure->tramp[0];
+ int i;
+
+ if (cif->abi != FFI_SYSV)
+ return FFI_BAD_ABI;
+
+ /* The trampoline looks like:
+ movhi r8, %hi(ffi_closure_sysv)
+ ori r8, r8, %lo(ffi_closure_sysv)
+ movhi r9, %hi(ffi_closure_helper)
+ ori r0, r9, %lo(ffi_closure_helper)
+ movhi r10, %hi(closure)
+ ori r10, r10, %lo(closure)
+ jmp r8
+ and then ffi_closure_sysv retrieves the closure pointer out of r10
+ in addition to the arguments passed in the normal way for the call,
+ and invokes ffi_closure_helper. We encode the pointer to
+ ffi_closure_helper in the trampoline because making a PIC call
+ to it in ffi_closure_sysv would be messy (it would have to indirect
+ through the GOT). */
+
+#define HI(x) ((((unsigned int) (x)) >> 16) & 0xffff)
+#define LO(x) (((unsigned int) (x)) & 0xffff)
+ tramp[0] = (0 << 27) | (8 << 22) | (HI (ffi_closure_sysv) << 6) | 0x34;
+ tramp[1] = (8 << 27) | (8 << 22) | (LO (ffi_closure_sysv) << 6) | 0x14;
+ tramp[2] = (0 << 27) | (9 << 22) | (HI (ffi_closure_helper) << 6) | 0x34;
+ tramp[3] = (9 << 27) | (9 << 22) | (LO (ffi_closure_helper) << 6) | 0x14;
+ tramp[4] = (0 << 27) | (10 << 22) | (HI (closure) << 6) | 0x34;
+ tramp[5] = (10 << 27) | (10 << 22) | (LO (closure) << 6) | 0x14;
+ tramp[6] = (8 << 27) | (0x0d << 11) | 0x3a;
+#undef HI
+#undef LO
+
+ /* Flush the caches.
+ See Example 9-4 in the Nios II Software Developer's Handbook. */
+ for (i = 0; i < 7; i++)
+ asm volatile ("flushd 0(%0); flushi %0" :: "r"(tramp + i) : "memory");
+ asm volatile ("flushp" ::: "memory");
+
+ closure->cif = cif;
+ closure->fun = fun;
+ closure->user_data = user_data;
+
+ return FFI_OK;
+}
+
diff --git a/jni/ruby/ext/fiddle/libffi-3.2.1/src/nios2/ffitarget.h b/jni/ruby/ext/fiddle/libffi-3.2.1/src/nios2/ffitarget.h
new file mode 100644
index 0000000..134d118
--- /dev/null
+++ b/jni/ruby/ext/fiddle/libffi-3.2.1/src/nios2/ffitarget.h
@@ -0,0 +1,52 @@
+/* libffi target includes for Altera Nios II.
+
+ Copyright (c) 2013 Mentor Graphics.
+
+ Permission is hereby granted, free of charge, to any person obtaining
+ a copy of this software and associated documentation files (the
+ ``Software''), to deal in the Software without restriction, including
+ without limitation the rights to use, copy, modify, merge, publish,
+ distribute, sublicense, and/or sell copies of the Software, and to
+ permit persons to whom the Software is furnished to do so, subject to
+ the following conditions:
+
+ The above copyright notice and this permission notice shall be
+ included in all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND,
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
+
+
+#ifndef LIBFFI_TARGET_H
+#define LIBFFI_TARGET_H
+
+#ifndef LIBFFI_H
+#error "Please do not include ffitarget.h directly into your source. Use ffi.h instead."
+#endif
+
+#ifndef LIBFFI_ASM
+typedef unsigned long ffi_arg;
+typedef signed long ffi_sarg;
+
+typedef enum ffi_abi {
+ FFI_FIRST_ABI = 0,
+ FFI_SYSV,
+ FFI_LAST_ABI,
+ FFI_DEFAULT_ABI = FFI_SYSV
+} ffi_abi;
+#endif
+
+/* Structures have a 4-byte alignment even if all the fields have lesser
+ alignment requirements. */
+#define FFI_AGGREGATE_ALIGNMENT 4
+
+#define FFI_CLOSURES 1
+#define FFI_TRAMPOLINE_SIZE 28 /* 7 instructions */
+#define FFI_NATIVE_RAW_API 0
+
+#endif
diff --git a/jni/ruby/ext/fiddle/libffi-3.2.1/src/nios2/sysv.S b/jni/ruby/ext/fiddle/libffi-3.2.1/src/nios2/sysv.S
new file mode 100644
index 0000000..75f442b
--- /dev/null
+++ b/jni/ruby/ext/fiddle/libffi-3.2.1/src/nios2/sysv.S
@@ -0,0 +1,136 @@
+/* Low-level libffi support for Altera Nios II.
+
+ Copyright (c) 2013 Mentor Graphics.
+
+ Permission is hereby granted, free of charge, to any person obtaining
+ a copy of this software and associated documentation files (the
+ ``Software''), to deal in the Software without restriction, including
+ without limitation the rights to use, copy, modify, merge, publish,
+ distribute, sublicense, and/or sell copies of the Software, and to
+ permit persons to whom the Software is furnished to do so, subject to
+ the following conditions:
+
+ The above copyright notice and this permission notice shall be
+ included in all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND,
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
+
+/* This function is declared on the C side as
+
+ extern UINT64 ffi_call_sysv (void (*arghook) (char *, extended_cif *),
+ extended_cif *ecif,
+ unsigned nbytes,
+ void (*fn) (void));
+
+ On input, the arguments appear as
+ r4 = arghook
+ r5 = ecif
+ r6 = nbytes
+ r7 = fn
+*/
+
+ .section .text
+ .align 2
+ .global ffi_call_sysv
+ .type ffi_call_sysv, @function
+
+ffi_call_sysv:
+ .cfi_startproc
+
+ /* Create the stack frame, saving r16 so we can use it locally. */
+ addi sp, sp, -12
+ .cfi_def_cfa_offset 12
+ stw ra, 8(sp)
+ stw fp, 4(sp)
+ stw r16, 0(sp)
+ .cfi_offset 31, -4
+ .cfi_offset 28, -8
+ .cfi_offset 16, -12
+ mov fp, sp
+ .cfi_def_cfa_register 28
+ mov r16, r7
+
+ /* Adjust the stack pointer to create the argument buffer
+ nbytes long. */
+ sub sp, sp, r6
+
+ /* Call the arghook function. */
+ mov r2, r4 /* fn */
+ mov r4, sp /* argbuffer */
+ callr r2 /* r5 already contains ecif */
+
+ /* Pop off the first 16 bytes of the argument buffer on the stack,
+ transferring the contents to the argument registers. */
+ ldw r4, 0(sp)
+ ldw r5, 4(sp)
+ ldw r6, 8(sp)
+ ldw r7, 12(sp)
+ addi sp, sp, 16
+
+ /* Call the user function, which leaves its result in r2 and r3. */
+ callr r16
+
+ /* Pop off the stack frame. */
+ mov sp, fp
+ ldw ra, 8(sp)
+ ldw fp, 4(sp)
+ ldw r16, 0(sp)
+ addi sp, sp, 12
+ ret
+ .cfi_endproc
+ .size ffi_call_sysv, .-ffi_call_sysv
+
+
+/* Closure trampolines jump here after putting the C helper address
+ in r9 and the closure pointer in r10. The user-supplied arguments
+ to the closure are in the normal places, in r4-r7 and on the
+ stack. Push the register arguments on the stack too and then call the
+ C helper function to deal with them. */
+
+ .section .text
+ .align 2
+ .global ffi_closure_sysv
+ .type ffi_closure_sysv, @function
+
+ffi_closure_sysv:
+ .cfi_startproc
+
+ /* Create the stack frame, pushing the register args on the stack
+ just below the stack args. This is the same trick illustrated
+ in Figure 7-3 in the Nios II Processor Reference Handbook, used
+ for variable arguments and structures passed by value. */
+ addi sp, sp, -20
+ .cfi_def_cfa_offset 20
+ stw ra, 0(sp)
+ .cfi_offset 31, -20
+ stw r4, 4(sp)
+ .cfi_offset 4, -16
+ stw r5, 8(sp)
+ .cfi_offset 5, -12
+ stw r6, 12(sp)
+ .cfi_offset 6, -8
+ stw r7, 16(sp)
+ .cfi_offset 7, -4
+
+ /* Call the helper.
+ r4 = pointer to arguments on stack
+ r5 = closure pointer (loaded in r10 by the trampoline)
+ r9 = address of helper function (loaded by trampoline) */
+ addi r4, sp, 4
+ mov r5, r10
+ callr r9
+
+ /* Pop the stack and return. */
+ ldw ra, 0(sp)
+ addi sp, sp, 20
+ .cfi_def_cfa_offset -20
+ ret
+ .cfi_endproc
+ .size ffi_closure_sysv, .-ffi_closure_sysv
+
diff --git a/jni/ruby/ext/fiddle/libffi-3.2.1/src/or1k/ffi.c b/jni/ruby/ext/fiddle/libffi-3.2.1/src/or1k/ffi.c
new file mode 100644
index 0000000..2bad938
--- /dev/null
+++ b/jni/ruby/ext/fiddle/libffi-3.2.1/src/or1k/ffi.c
@@ -0,0 +1,328 @@
+/* -----------------------------------------------------------------------
+ ffi.c - Copyright (c) 2014 Sebastian Macke <sebastian@macke.de>
+
+ OpenRISC Foreign Function Interface
+
+ Permission is hereby granted, free of charge, to any person obtaining
+ a copy of this software and associated documentation files (the
+ ``Software''), to deal in the Software without restriction, including
+ without limitation the rights to use, copy, modify, merge, publish,
+ distribute, sublicense, and/or sell copies of the Software, and to
+ permit persons to whom the Software is furnished to do so, subject to
+ the following conditions:
+
+ The above copyright notice and this permission notice shall be included
+ in all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND,
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+ HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ DEALINGS IN THE SOFTWARE.
+ ----------------------------------------------------------------------- */
+
+#include <ffi.h>
+#include "ffi_common.h"
+
+/* ffi_prep_args is called by the assembly routine once stack space
+ has been allocated for the function's arguments */
+
+void* ffi_prep_args(char *stack, extended_cif *ecif)
+{
+ char *stacktemp = stack;
+ int i, s;
+ ffi_type **arg;
+ int count = 0;
+ int nfixedargs;
+
+ nfixedargs = ecif->cif->nfixedargs;
+ arg = ecif->cif->arg_types;
+ void **argv = ecif->avalue;
+
+ if (ecif->cif->rtype->type == FFI_TYPE_STRUCT)
+ {
+ *(void **) stack = ecif->rvalue;
+ stack += 4;
+ count = 4;
+ }
+ for(i=0; i<ecif->cif->nargs; i++)
+ {
+
+ /* variadic args are saved on stack */
+ if ((nfixedargs == 0) && (count < 24))
+ {
+ count = 24;
+ stack = stacktemp + 24;
+ }
+ nfixedargs--;
+
+ s = 4;
+ switch((*arg)->type)
+ {
+ case FFI_TYPE_STRUCT:
+ *(void **)stack = *argv;
+ break;
+
+ case FFI_TYPE_SINT8:
+ *(signed int *) stack = (signed int)*(SINT8 *)(* argv);
+ break;
+
+ case FFI_TYPE_UINT8:
+ *(unsigned int *) stack = (unsigned int)*(UINT8 *)(* argv);
+ break;
+
+ case FFI_TYPE_SINT16:
+ *(signed int *) stack = (signed int)*(SINT16 *)(* argv);
+ break;
+
+ case FFI_TYPE_UINT16:
+ *(unsigned int *) stack = (unsigned int)*(UINT16 *)(* argv);
+ break;
+
+ case FFI_TYPE_SINT32:
+ case FFI_TYPE_UINT32:
+ case FFI_TYPE_FLOAT:
+ case FFI_TYPE_POINTER:
+ *(int *)stack = *(int*)(*argv);
+ break;
+
+ default: /* 8 byte types */
+ if (count == 20) /* never split arguments */
+ {
+ stack += 4;
+ count += 4;
+ }
+ s = (*arg)->size;
+ memcpy(stack, *argv, s);
+ break;
+ }
+
+ stack += s;
+ count += s;
+ argv++;
+ arg++;
+ }
+ return stacktemp + ((count>24)?24:0);
+}
+
+extern void ffi_call_SYSV(unsigned,
+ extended_cif *,
+ void *(*)(int *, extended_cif *),
+ unsigned *,
+ void (*fn)(void),
+ unsigned);
+
+
+void ffi_call(ffi_cif *cif, void (*fn)(void), void *rvalue, void **avalue)
+{
+ int i;
+ int size;
+ ffi_type **arg;
+
+ /* Calculate size to allocate on stack */
+
+ for(i = 0, arg = cif->arg_types, size=0; i < cif->nargs; i++, arg++)
+ {
+ if ((*arg)->type == FFI_TYPE_STRUCT)
+ size += 4;
+ else
+ if ((*arg)->size <= 4)
+ size += 4;
+ else
+ size += 8;
+ }
+
+ /* for variadic functions more space is needed on the stack */
+ if (cif->nargs != cif->nfixedargs)
+ size += 24;
+
+ if (cif->rtype->type == FFI_TYPE_STRUCT)
+ size += 4;
+
+
+ extended_cif ecif;
+ ecif.cif = cif;
+ ecif.avalue = avalue;
+ ecif.rvalue = rvalue;
+
+ switch (cif->abi)
+ {
+ case FFI_SYSV:
+ ffi_call_SYSV(size, &ecif, ffi_prep_args, rvalue, fn, cif->flags);
+ break;
+ default:
+ FFI_ASSERT(0);
+ break;
+ }
+}
+
+
+void ffi_closure_SYSV(unsigned long r3, unsigned long r4, unsigned long r5,
+ unsigned long r6, unsigned long r7, unsigned long r8)
+{
+ register int *sp __asm__ ("r17");
+ register int *r13 __asm__ ("r13");
+
+ ffi_closure* closure = (ffi_closure*) r13;
+ char *stack_args = sp;
+
+ /* Lay the register arguments down in a continuous chunk of memory. */
+ unsigned register_args[6] =
+ { r3, r4, r5, r6, r7, r8 };
+
+ /* Pointer to a struct return value. */
+ void *struct_rvalue = (void *) r3;
+
+ ffi_cif *cif = closure->cif;
+ ffi_type **arg_types = cif->arg_types;
+ void **avalue = alloca (cif->nargs * sizeof(void *));
+ char *ptr = (char *) register_args;
+ int count = 0;
+ int nfixedargs = cif->nfixedargs;
+ int i;
+
+ /* preserve struct type return pointer passing */
+
+ if ((cif->rtype != NULL) && (cif->rtype->type == FFI_TYPE_STRUCT))
+ {
+ ptr += 4;
+ count = 4;
+ }
+
+ /* Find the address of each argument. */
+ for (i = 0; i < cif->nargs; i++)
+ {
+
+ /* variadic args are saved on stack */
+ if ((nfixedargs == 0) && (count < 24))
+ {
+ ptr = stack_args;
+ count = 24;
+ }
+ nfixedargs--;
+
+ switch (arg_types[i]->type)
+ {
+ case FFI_TYPE_SINT8:
+ case FFI_TYPE_UINT8:
+ avalue[i] = ptr + 3;
+ break;
+
+ case FFI_TYPE_SINT16:
+ case FFI_TYPE_UINT16:
+ avalue[i] = ptr + 2;
+ break;
+
+ case FFI_TYPE_SINT32:
+ case FFI_TYPE_UINT32:
+ case FFI_TYPE_FLOAT:
+ case FFI_TYPE_POINTER:
+ avalue[i] = ptr;
+ break;
+
+ case FFI_TYPE_STRUCT:
+ avalue[i] = *(void**)ptr;
+ break;
+
+ default:
+ /* 8-byte values */
+
+ /* arguments are never splitted */
+ if (ptr == &register_args[5])
+ ptr = stack_args;
+ avalue[i] = ptr;
+ ptr += 4;
+ count += 4;
+ break;
+ }
+ ptr += 4;
+ count += 4;
+
+ /* If we've handled more arguments than fit in registers,
+ start looking at the those passed on the stack. */
+
+ if (count == 24)
+ ptr = stack_args;
+ }
+
+ if (cif->rtype && (cif->rtype->type == FFI_TYPE_STRUCT))
+ {
+ (closure->fun) (cif, struct_rvalue, avalue, closure->user_data);
+ } else
+ {
+ long long rvalue;
+ (closure->fun) (cif, &rvalue, avalue, closure->user_data);
+ if (cif->rtype)
+ asm ("l.ori r12, %0, 0x0\n l.lwz r11, 0(r12)\n l.lwz r12, 4(r12)" : : "r" (&rvalue));
+ }
+}
+
+
+ffi_status
+ffi_prep_closure_loc (ffi_closure* closure,
+ ffi_cif* cif,
+ void (*fun)(ffi_cif*,void*,void**,void*),
+ void *user_data,
+ void *codeloc)
+{
+ unsigned short *tramp = (unsigned short *) closure->tramp;
+ unsigned long fn = (unsigned long) ffi_closure_SYSV;
+ unsigned long cls = (unsigned long) codeloc;
+
+ if (cif->abi != FFI_SYSV)
+ return FFI_BAD_ABI;
+
+ closure->cif = cif;
+ closure->user_data = user_data;
+ closure->fun = fun;
+
+ /* write pointers to temporary registers */
+ tramp[0] = (0x6 << 10) | (13 << 5); /* l.movhi r13, ... */
+ tramp[1] = cls >> 16;
+ tramp[2] = (0x2a << 10) | (13 << 5) | 13; /* l.ori r13, r13, ... */
+ tramp[3] = cls & 0xFFFF;
+
+ tramp[4] = (0x6 << 10) | (15 << 5); /* l.movhi r15, ... */
+ tramp[5] = fn >> 16;
+ tramp[6] = (0x2a << 10) | (15 << 5) | 15; /* l.ori r15, r15 ... */
+ tramp[7] = fn & 0xFFFF;
+
+ tramp[8] = (0x11 << 10); /* l.jr r15 */
+ tramp[9] = 15 << 11;
+
+ tramp[10] = (0x2a << 10) | (17 << 5) | 1; /* l.ori r17, r1, ... */
+ tramp[11] = 0x0;
+
+ return FFI_OK;
+}
+
+
+ffi_status ffi_prep_cif_machdep (ffi_cif *cif)
+{
+ cif->flags = 0;
+
+ /* structures are returned as pointers */
+ if (cif->rtype->type == FFI_TYPE_STRUCT)
+ cif->flags = FFI_TYPE_STRUCT;
+ else
+ if (cif->rtype->size > 4)
+ cif->flags = FFI_TYPE_UINT64;
+
+ cif->nfixedargs = cif->nargs;
+
+ return FFI_OK;
+}
+
+
+ffi_status ffi_prep_cif_machdep_var(ffi_cif *cif,
+ unsigned int nfixedargs, unsigned int ntotalargs)
+{
+ ffi_status status;
+
+ status = ffi_prep_cif_machdep (cif);
+ cif->nfixedargs = nfixedargs;
+ return status;
+}
diff --git a/jni/ruby/ext/fiddle/libffi-3.2.1/src/or1k/ffitarget.h b/jni/ruby/ext/fiddle/libffi-3.2.1/src/or1k/ffitarget.h
new file mode 100644
index 0000000..e55da28
--- /dev/null
+++ b/jni/ruby/ext/fiddle/libffi-3.2.1/src/or1k/ffitarget.h
@@ -0,0 +1,58 @@
+/* -----------------------------------------------------------------------
+ ffitarget.h - Copyright (c) 2014 Sebastian Macke <sebastian@macke.de>
+
+ OpenRISC Target configuration macros
+
+ Permission is hereby granted, free of charge, to any person obtaining
+ a copy of this software and associated documentation files (the
+ ``Software''), to deal in the Software without restriction, including
+ without limitation the rights to use, copy, modify, merge, publish,
+ distribute, sublicense, and/or sell copies of the Software, and to
+ permit persons to whom the Software is furnished to do so, subject to
+ the following conditions:
+
+ The above copyright notice and this permission notice shall be included
+ in all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND,
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+ HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ DEALINGS IN THE SOFTWARE.
+ ----------------------------------------------------------------------- */
+
+#ifndef LIBFFI_TARGET_H
+#define LIBFFI_TARGET_H
+
+#ifndef LIBFFI_H
+#error "Please do not include ffitarget.h directly into your source. Use ffi.h instead."
+#endif
+
+/* ---- System specific configurations ----------------------------------- */
+
+#ifndef LIBFFI_ASM
+typedef unsigned long ffi_arg;
+typedef signed long ffi_sarg;
+
+typedef enum ffi_abi {
+ FFI_FIRST_ABI = 0,
+ FFI_SYSV,
+ FFI_LAST_ABI,
+ FFI_DEFAULT_ABI = FFI_SYSV
+} ffi_abi;
+#endif
+
+/* ---- Definitions for closures ----------------------------------------- */
+
+#define FFI_CLOSURES 1
+#define FFI_NATIVE_RAW_API 0
+#define FFI_TRAMPOLINE_SIZE (24)
+
+#define FFI_TARGET_SPECIFIC_VARIADIC 1
+#define FFI_EXTRA_CIF_FIELDS unsigned nfixedargs;
+
+#endif
+
diff --git a/jni/ruby/ext/fiddle/libffi-3.2.1/src/or1k/sysv.S b/jni/ruby/ext/fiddle/libffi-3.2.1/src/or1k/sysv.S
new file mode 100644
index 0000000..df6570b
--- /dev/null
+++ b/jni/ruby/ext/fiddle/libffi-3.2.1/src/or1k/sysv.S
@@ -0,0 +1,107 @@
+/* -----------------------------------------------------------------------
+ sysv.S - Copyright (c) 2014 Sebastian Macke <sebastian@macke.de>
+
+ OpenRISC Foreign Function Interface
+
+ Permission is hereby granted, free of charge, to any person obtaining
+ a copy of this software and associated documentation files (the
+ ``Software''), to deal in the Software without restriction, including
+ without limitation the rights to use, copy, modify, merge, publish,
+ distribute, sublicense, and/or sell copies of the Software, and to
+ permit persons to whom the Software is furnished to do so, subject to
+ the following conditions:
+
+ The above copyright notice and this permission notice shall be included
+ in all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND,
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+ HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ DEALINGS IN THE SOFTWARE.
+ ----------------------------------------------------------------------- */
+
+#define LIBFFI_ASM
+#include <fficonfig.h>
+#include <ffi.h>
+
+.text
+ .globl ffi_call_SYSV
+ .type ffi_call_SYSV, @function
+/*
+ r3: size to allocate on stack
+ r4: extended cif structure
+ r5: function pointer ffi_prep_args
+ r6: ret address
+ r7: function to call
+ r8: flag for return type
+*/
+
+ffi_call_SYSV:
+ /* Store registers used on stack */
+ l.sw -4(r1), r9 /* return address */
+ l.sw -8(r1), r1 /* stack address */
+ l.sw -12(r1), r14 /* callee saved registers */
+ l.sw -16(r1), r16
+ l.sw -20(r1), r18
+ l.sw -24(r1), r20
+
+ l.ori r14, r1, 0x0 /* save stack pointer */
+ l.addi r1, r1, -24
+
+ l.ori r16, r7, 0x0 /* save function address */
+ l.ori r18, r6, 0x0 /* save ret address */
+ l.ori r20, r8, 0x0 /* save flag */
+
+ l.sub r1, r1, r3 /* reserve space on stack */
+
+ /* Call ffi_prep_args */
+ l.ori r3, r1, 0x0 /* first argument stack address, second already ecif */
+ l.jalr r5
+ l.nop
+
+ /* Load register arguments and call*/
+
+ l.lwz r3, 0(r1)
+ l.lwz r4, 4(r1)
+ l.lwz r5, 8(r1)
+ l.lwz r6, 12(r1)
+ l.lwz r7, 16(r1)
+ l.lwz r8, 20(r1)
+ l.ori r1, r11, 0x0 /* new stack pointer */
+ l.jalr r16
+ l.nop
+
+ /* handle return values */
+
+ l.sfeqi r20, FFI_TYPE_STRUCT
+ l.bf ret /* structs don't return an rvalue */
+ l.nop
+
+ /* copy ret address */
+
+ l.sfeqi r20, FFI_TYPE_UINT64
+ l.bnf four_byte_ret /* 8 byte value is returned */
+ l.nop
+
+ l.sw 4(r18), r12
+
+four_byte_ret:
+ l.sw 0(r18), r11
+
+ret:
+ /* return */
+ l.ori r1, r14, 0x0 /* reset stack pointer */
+ l.lwz r9, -4(r1)
+ l.lwz r1, -8(r1)
+ l.lwz r14, -12(r1)
+ l.lwz r16, -16(r1)
+ l.lwz r18, -20(r1)
+ l.lwz r20, -24(r1)
+ l.jr r9
+ l.nop
+
+.size ffi_call_SYSV, .-ffi_call_SYSV
diff --git a/jni/ruby/ext/fiddle/libffi-3.2.1/src/pa/ffi.c b/jni/ruby/ext/fiddle/libffi-3.2.1/src/pa/ffi.c
new file mode 100644
index 0000000..4ce2bc6
--- /dev/null
+++ b/jni/ruby/ext/fiddle/libffi-3.2.1/src/pa/ffi.c
@@ -0,0 +1,719 @@
+/* -----------------------------------------------------------------------
+ ffi.c - (c) 2011 Anthony Green
+ (c) 2008 Red Hat, Inc.
+ (c) 2006 Free Software Foundation, Inc.
+ (c) 2003-2004 Randolph Chung <tausq@debian.org>
+
+ HPPA Foreign Function Interface
+ HP-UX PA ABI support
+
+ Permission is hereby granted, free of charge, to any person obtaining
+ a copy of this software and associated documentation files (the
+ ``Software''), to deal in the Software without restriction, including
+ without limitation the rights to use, copy, modify, merge, publish,
+ distribute, sublicense, and/or sell copies of the Software, and to
+ permit persons to whom the Software is furnished to do so, subject to
+ the following conditions:
+
+ The above copyright notice and this permission notice shall be included
+ in all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND,
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+ HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ DEALINGS IN THE SOFTWARE.
+ ----------------------------------------------------------------------- */
+
+#include <ffi.h>
+#include <ffi_common.h>
+
+#include <stdlib.h>
+#include <stdio.h>
+
+#define ROUND_UP(v, a) (((size_t)(v) + (a) - 1) & ~((a) - 1))
+
+#define MIN_STACK_SIZE 64
+#define FIRST_ARG_SLOT 9
+#define DEBUG_LEVEL 0
+
+#define fldw(addr, fpreg) \
+ __asm__ volatile ("fldw 0(%0), %%" #fpreg "L" : : "r"(addr) : #fpreg)
+#define fstw(fpreg, addr) \
+ __asm__ volatile ("fstw %%" #fpreg "L, 0(%0)" : : "r"(addr))
+#define fldd(addr, fpreg) \
+ __asm__ volatile ("fldd 0(%0), %%" #fpreg : : "r"(addr) : #fpreg)
+#define fstd(fpreg, addr) \
+ __asm__ volatile ("fstd %%" #fpreg "L, 0(%0)" : : "r"(addr))
+
+#define debug(lvl, x...) do { if (lvl <= DEBUG_LEVEL) { printf(x); } } while (0)
+
+static inline int ffi_struct_type(ffi_type *t)
+{
+ size_t sz = t->size;
+
+ /* Small structure results are passed in registers,
+ larger ones are passed by pointer. Note that
+ small structures of size 2, 4 and 8 differ from
+ the corresponding integer types in that they have
+ different alignment requirements. */
+
+ if (sz <= 1)
+ return FFI_TYPE_UINT8;
+ else if (sz == 2)
+ return FFI_TYPE_SMALL_STRUCT2;
+ else if (sz == 3)
+ return FFI_TYPE_SMALL_STRUCT3;
+ else if (sz == 4)
+ return FFI_TYPE_SMALL_STRUCT4;
+ else if (sz == 5)
+ return FFI_TYPE_SMALL_STRUCT5;
+ else if (sz == 6)
+ return FFI_TYPE_SMALL_STRUCT6;
+ else if (sz == 7)
+ return FFI_TYPE_SMALL_STRUCT7;
+ else if (sz <= 8)
+ return FFI_TYPE_SMALL_STRUCT8;
+ else
+ return FFI_TYPE_STRUCT; /* else, we pass it by pointer. */
+}
+
+/* PA has a downward growing stack, which looks like this:
+
+ Offset
+ [ Variable args ]
+ SP = (4*(n+9)) arg word N
+ ...
+ SP-52 arg word 4
+ [ Fixed args ]
+ SP-48 arg word 3
+ SP-44 arg word 2
+ SP-40 arg word 1
+ SP-36 arg word 0
+ [ Frame marker ]
+ ...
+ SP-20 RP
+ SP-4 previous SP
+
+ The first four argument words on the stack are reserved for use by
+ the callee. Instead, the general and floating registers replace
+ the first four argument slots. Non FP arguments are passed solely
+ in the general registers. FP arguments are passed in both general
+ and floating registers when using libffi.
+
+ Non-FP 32-bit args are passed in gr26, gr25, gr24 and gr23.
+ Non-FP 64-bit args are passed in register pairs, starting
+ on an odd numbered register (i.e. r25+r26 and r23+r24).
+ FP 32-bit arguments are passed in fr4L, fr5L, fr6L and fr7L.
+ FP 64-bit arguments are passed in fr5 and fr7.
+
+ The registers are allocated in the same manner as stack slots.
+ This allows the callee to save its arguments on the stack if
+ necessary:
+
+ arg word 3 -> gr23 or fr7L
+ arg word 2 -> gr24 or fr6L or fr7R
+ arg word 1 -> gr25 or fr5L
+ arg word 0 -> gr26 or fr4L or fr5R
+
+ Note that fr4R and fr6R are never used for arguments (i.e.,
+ doubles are not passed in fr4 or fr6).
+
+ The rest of the arguments are passed on the stack starting at SP-52,
+ but 64-bit arguments need to be aligned to an 8-byte boundary
+
+ This means we can have holes either in the register allocation,
+ or in the stack. */
+
+/* ffi_prep_args is called by the assembly routine once stack space
+ has been allocated for the function's arguments
+
+ The following code will put everything into the stack frame
+ (which was allocated by the asm routine), and on return
+ the asm routine will load the arguments that should be
+ passed by register into the appropriate registers
+
+ NOTE: We load floating point args in this function... that means we
+ assume gcc will not mess with fp regs in here. */
+
+void ffi_prep_args_pa32(UINT32 *stack, extended_cif *ecif, unsigned bytes)
+{
+ register unsigned int i;
+ register ffi_type **p_arg;
+ register void **p_argv;
+ unsigned int slot = FIRST_ARG_SLOT;
+ char *dest_cpy;
+ size_t len;
+
+ debug(1, "%s: stack = %p, ecif = %p, bytes = %u\n", __FUNCTION__, stack,
+ ecif, bytes);
+
+ p_arg = ecif->cif->arg_types;
+ p_argv = ecif->avalue;
+
+ for (i = 0; i < ecif->cif->nargs; i++)
+ {
+ int type = (*p_arg)->type;
+
+ switch (type)
+ {
+ case FFI_TYPE_SINT8:
+ *(SINT32 *)(stack - slot) = *(SINT8 *)(*p_argv);
+ break;
+
+ case FFI_TYPE_UINT8:
+ *(UINT32 *)(stack - slot) = *(UINT8 *)(*p_argv);
+ break;
+
+ case FFI_TYPE_SINT16:
+ *(SINT32 *)(stack - slot) = *(SINT16 *)(*p_argv);
+ break;
+
+ case FFI_TYPE_UINT16:
+ *(UINT32 *)(stack - slot) = *(UINT16 *)(*p_argv);
+ break;
+
+ case FFI_TYPE_UINT32:
+ case FFI_TYPE_SINT32:
+ case FFI_TYPE_POINTER:
+ debug(3, "Storing UINT32 %u in slot %u\n", *(UINT32 *)(*p_argv),
+ slot);
+ *(UINT32 *)(stack - slot) = *(UINT32 *)(*p_argv);
+ break;
+
+ case FFI_TYPE_UINT64:
+ case FFI_TYPE_SINT64:
+ /* Align slot for 64-bit type. */
+ slot += (slot & 1) ? 1 : 2;
+ *(UINT64 *)(stack - slot) = *(UINT64 *)(*p_argv);
+ break;
+
+ case FFI_TYPE_FLOAT:
+ /* First 4 args go in fr4L - fr7L. */
+ debug(3, "Storing UINT32(float) in slot %u\n", slot);
+ *(UINT32 *)(stack - slot) = *(UINT32 *)(*p_argv);
+ switch (slot - FIRST_ARG_SLOT)
+ {
+ /* First 4 args go in fr4L - fr7L. */
+ case 0: fldw(stack - slot, fr4); break;
+ case 1: fldw(stack - slot, fr5); break;
+ case 2: fldw(stack - slot, fr6); break;
+ case 3: fldw(stack - slot, fr7); break;
+ }
+ break;
+
+ case FFI_TYPE_DOUBLE:
+ /* Align slot for 64-bit type. */
+ slot += (slot & 1) ? 1 : 2;
+ debug(3, "Storing UINT64(double) at slot %u\n", slot);
+ *(UINT64 *)(stack - slot) = *(UINT64 *)(*p_argv);
+ switch (slot - FIRST_ARG_SLOT)
+ {
+ /* First 2 args go in fr5, fr7. */
+ case 1: fldd(stack - slot, fr5); break;
+ case 3: fldd(stack - slot, fr7); break;
+ }
+ break;
+
+#ifdef PA_HPUX
+ case FFI_TYPE_LONGDOUBLE:
+ /* Long doubles are passed in the same manner as structures
+ larger than 8 bytes. */
+ *(UINT32 *)(stack - slot) = (UINT32)(*p_argv);
+ break;
+#endif
+
+ case FFI_TYPE_STRUCT:
+
+ /* Structs smaller or equal than 4 bytes are passed in one
+ register. Structs smaller or equal 8 bytes are passed in two
+ registers. Larger structures are passed by pointer. */
+
+ len = (*p_arg)->size;
+ if (len <= 4)
+ {
+ dest_cpy = (char *)(stack - slot) + 4 - len;
+ memcpy(dest_cpy, (char *)*p_argv, len);
+ }
+ else if (len <= 8)
+ {
+ slot += (slot & 1) ? 1 : 2;
+ dest_cpy = (char *)(stack - slot) + 8 - len;
+ memcpy(dest_cpy, (char *)*p_argv, len);
+ }
+ else
+ *(UINT32 *)(stack - slot) = (UINT32)(*p_argv);
+ break;
+
+ default:
+ FFI_ASSERT(0);
+ }
+
+ slot++;
+ p_arg++;
+ p_argv++;
+ }
+
+ /* Make sure we didn't mess up and scribble on the stack. */
+ {
+ unsigned int n;
+
+ debug(5, "Stack setup:\n");
+ for (n = 0; n < (bytes + 3) / 4; n++)
+ {
+ if ((n%4) == 0) { debug(5, "\n%08x: ", (unsigned int)(stack - n)); }
+ debug(5, "%08x ", *(stack - n));
+ }
+ debug(5, "\n");
+ }
+
+ FFI_ASSERT(slot * 4 <= bytes);
+
+ return;
+}
+
+static void ffi_size_stack_pa32(ffi_cif *cif)
+{
+ ffi_type **ptr;
+ int i;
+ int z = 0; /* # stack slots */
+
+ for (ptr = cif->arg_types, i = 0; i < cif->nargs; ptr++, i++)
+ {
+ int type = (*ptr)->type;
+
+ switch (type)
+ {
+ case FFI_TYPE_DOUBLE:
+ case FFI_TYPE_UINT64:
+ case FFI_TYPE_SINT64:
+ z += 2 + (z & 1); /* must start on even regs, so we may waste one */
+ break;
+
+#ifdef PA_HPUX
+ case FFI_TYPE_LONGDOUBLE:
+#endif
+ case FFI_TYPE_STRUCT:
+ z += 1; /* pass by ptr, callee will copy */
+ break;
+
+ default: /* <= 32-bit values */
+ z++;
+ }
+ }
+
+ /* We can fit up to 6 args in the default 64-byte stack frame,
+ if we need more, we need more stack. */
+ if (z <= 6)
+ cif->bytes = MIN_STACK_SIZE; /* min stack size */
+ else
+ cif->bytes = 64 + ROUND_UP((z - 6) * sizeof(UINT32), MIN_STACK_SIZE);
+
+ debug(3, "Calculated stack size is %u bytes\n", cif->bytes);
+}
+
+/* Perform machine dependent cif processing. */
+ffi_status ffi_prep_cif_machdep(ffi_cif *cif)
+{
+ /* Set the return type flag */
+ switch (cif->rtype->type)
+ {
+ case FFI_TYPE_VOID:
+ case FFI_TYPE_FLOAT:
+ case FFI_TYPE_DOUBLE:
+ cif->flags = (unsigned) cif->rtype->type;
+ break;
+
+#ifdef PA_HPUX
+ case FFI_TYPE_LONGDOUBLE:
+ /* Long doubles are treated like a structure. */
+ cif->flags = FFI_TYPE_STRUCT;
+ break;
+#endif
+
+ case FFI_TYPE_STRUCT:
+ /* For the return type we have to check the size of the structures.
+ If the size is smaller or equal 4 bytes, the result is given back
+ in one register. If the size is smaller or equal 8 bytes than we
+ return the result in two registers. But if the size is bigger than
+ 8 bytes, we work with pointers. */
+ cif->flags = ffi_struct_type(cif->rtype);
+ break;
+
+ case FFI_TYPE_UINT64:
+ case FFI_TYPE_SINT64:
+ cif->flags = FFI_TYPE_UINT64;
+ break;
+
+ default:
+ cif->flags = FFI_TYPE_INT;
+ break;
+ }
+
+ /* Lucky us, because of the unique PA ABI we get to do our
+ own stack sizing. */
+ switch (cif->abi)
+ {
+ case FFI_PA32:
+ ffi_size_stack_pa32(cif);
+ break;
+
+ default:
+ FFI_ASSERT(0);
+ break;
+ }
+
+ return FFI_OK;
+}
+
+extern void ffi_call_pa32(void (*)(UINT32 *, extended_cif *, unsigned),
+ extended_cif *, unsigned, unsigned, unsigned *,
+ void (*fn)(void));
+
+void ffi_call(ffi_cif *cif, void (*fn)(void), void *rvalue, void **avalue)
+{
+ extended_cif ecif;
+
+ ecif.cif = cif;
+ ecif.avalue = avalue;
+
+ /* If the return value is a struct and we don't have a return
+ value address then we need to make one. */
+
+ if (rvalue == NULL
+#ifdef PA_HPUX
+ && (cif->rtype->type == FFI_TYPE_STRUCT
+ || cif->rtype->type == FFI_TYPE_LONGDOUBLE))
+#else
+ && cif->rtype->type == FFI_TYPE_STRUCT)
+#endif
+ {
+ ecif.rvalue = alloca(cif->rtype->size);
+ }
+ else
+ ecif.rvalue = rvalue;
+
+
+ switch (cif->abi)
+ {
+ case FFI_PA32:
+ debug(3, "Calling ffi_call_pa32: ecif=%p, bytes=%u, flags=%u, rvalue=%p, fn=%p\n", &ecif, cif->bytes, cif->flags, ecif.rvalue, (void *)fn);
+ ffi_call_pa32(ffi_prep_args_pa32, &ecif, cif->bytes,
+ cif->flags, ecif.rvalue, fn);
+ break;
+
+ default:
+ FFI_ASSERT(0);
+ break;
+ }
+}
+
+#if FFI_CLOSURES
+/* This is more-or-less an inverse of ffi_call -- we have arguments on
+ the stack, and we need to fill them into a cif structure and invoke
+ the user function. This really ought to be in asm to make sure
+ the compiler doesn't do things we don't expect. */
+ffi_status ffi_closure_inner_pa32(ffi_closure *closure, UINT32 *stack)
+{
+ ffi_cif *cif;
+ void **avalue;
+ void *rvalue;
+ UINT32 ret[2]; /* function can return up to 64-bits in registers */
+ ffi_type **p_arg;
+ char *tmp;
+ int i, avn;
+ unsigned int slot = FIRST_ARG_SLOT;
+ register UINT32 r28 asm("r28");
+
+ cif = closure->cif;
+
+ /* If returning via structure, callee will write to our pointer. */
+ if (cif->flags == FFI_TYPE_STRUCT)
+ rvalue = (void *)r28;
+ else
+ rvalue = &ret[0];
+
+ avalue = (void **)alloca(cif->nargs * FFI_SIZEOF_ARG);
+ avn = cif->nargs;
+ p_arg = cif->arg_types;
+
+ for (i = 0; i < avn; i++)
+ {
+ int type = (*p_arg)->type;
+
+ switch (type)
+ {
+ case FFI_TYPE_SINT8:
+ case FFI_TYPE_UINT8:
+ case FFI_TYPE_SINT16:
+ case FFI_TYPE_UINT16:
+ case FFI_TYPE_SINT32:
+ case FFI_TYPE_UINT32:
+ case FFI_TYPE_POINTER:
+ avalue[i] = (char *)(stack - slot) + sizeof(UINT32) - (*p_arg)->size;
+ break;
+
+ case FFI_TYPE_SINT64:
+ case FFI_TYPE_UINT64:
+ slot += (slot & 1) ? 1 : 2;
+ avalue[i] = (void *)(stack - slot);
+ break;
+
+ case FFI_TYPE_FLOAT:
+#ifdef PA_LINUX
+ /* The closure call is indirect. In Linux, floating point
+ arguments in indirect calls with a prototype are passed
+ in the floating point registers instead of the general
+ registers. So, we need to replace what was previously
+ stored in the current slot with the value in the
+ corresponding floating point register. */
+ switch (slot - FIRST_ARG_SLOT)
+ {
+ case 0: fstw(fr4, (void *)(stack - slot)); break;
+ case 1: fstw(fr5, (void *)(stack - slot)); break;
+ case 2: fstw(fr6, (void *)(stack - slot)); break;
+ case 3: fstw(fr7, (void *)(stack - slot)); break;
+ }
+#endif
+ avalue[i] = (void *)(stack - slot);
+ break;
+
+ case FFI_TYPE_DOUBLE:
+ slot += (slot & 1) ? 1 : 2;
+#ifdef PA_LINUX
+ /* See previous comment for FFI_TYPE_FLOAT. */
+ switch (slot - FIRST_ARG_SLOT)
+ {
+ case 1: fstd(fr5, (void *)(stack - slot)); break;
+ case 3: fstd(fr7, (void *)(stack - slot)); break;
+ }
+#endif
+ avalue[i] = (void *)(stack - slot);
+ break;
+
+#ifdef PA_HPUX
+ case FFI_TYPE_LONGDOUBLE:
+ /* Long doubles are treated like a big structure. */
+ avalue[i] = (void *) *(stack - slot);
+ break;
+#endif
+
+ case FFI_TYPE_STRUCT:
+ /* Structs smaller or equal than 4 bytes are passed in one
+ register. Structs smaller or equal 8 bytes are passed in two
+ registers. Larger structures are passed by pointer. */
+ if((*p_arg)->size <= 4)
+ {
+ avalue[i] = (void *)(stack - slot) + sizeof(UINT32) -
+ (*p_arg)->size;
+ }
+ else if ((*p_arg)->size <= 8)
+ {
+ slot += (slot & 1) ? 1 : 2;
+ avalue[i] = (void *)(stack - slot) + sizeof(UINT64) -
+ (*p_arg)->size;
+ }
+ else
+ avalue[i] = (void *) *(stack - slot);
+ break;
+
+ default:
+ FFI_ASSERT(0);
+ }
+
+ slot++;
+ p_arg++;
+ }
+
+ /* Invoke the closure. */
+ (closure->fun) (cif, rvalue, avalue, closure->user_data);
+
+ debug(3, "after calling function, ret[0] = %08x, ret[1] = %08x\n", ret[0],
+ ret[1]);
+
+ /* Store the result using the lower 2 bytes of the flags. */
+ switch (cif->flags)
+ {
+ case FFI_TYPE_UINT8:
+ *(stack - FIRST_ARG_SLOT) = (UINT8)(ret[0] >> 24);
+ break;
+ case FFI_TYPE_SINT8:
+ *(stack - FIRST_ARG_SLOT) = (SINT8)(ret[0] >> 24);
+ break;
+ case FFI_TYPE_UINT16:
+ *(stack - FIRST_ARG_SLOT) = (UINT16)(ret[0] >> 16);
+ break;
+ case FFI_TYPE_SINT16:
+ *(stack - FIRST_ARG_SLOT) = (SINT16)(ret[0] >> 16);
+ break;
+ case FFI_TYPE_INT:
+ case FFI_TYPE_SINT32:
+ case FFI_TYPE_UINT32:
+ *(stack - FIRST_ARG_SLOT) = ret[0];
+ break;
+ case FFI_TYPE_SINT64:
+ case FFI_TYPE_UINT64:
+ *(stack - FIRST_ARG_SLOT) = ret[0];
+ *(stack - FIRST_ARG_SLOT - 1) = ret[1];
+ break;
+
+ case FFI_TYPE_DOUBLE:
+ fldd(rvalue, fr4);
+ break;
+
+ case FFI_TYPE_FLOAT:
+ fldw(rvalue, fr4);
+ break;
+
+ case FFI_TYPE_STRUCT:
+ /* Don't need a return value, done by caller. */
+ break;
+
+ case FFI_TYPE_SMALL_STRUCT2:
+ case FFI_TYPE_SMALL_STRUCT3:
+ case FFI_TYPE_SMALL_STRUCT4:
+ tmp = (void*)(stack - FIRST_ARG_SLOT);
+ tmp += 4 - cif->rtype->size;
+ memcpy((void*)tmp, &ret[0], cif->rtype->size);
+ break;
+
+ case FFI_TYPE_SMALL_STRUCT5:
+ case FFI_TYPE_SMALL_STRUCT6:
+ case FFI_TYPE_SMALL_STRUCT7:
+ case FFI_TYPE_SMALL_STRUCT8:
+ {
+ unsigned int ret2[2];
+ int off;
+
+ /* Right justify ret[0] and ret[1] */
+ switch (cif->flags)
+ {
+ case FFI_TYPE_SMALL_STRUCT5: off = 3; break;
+ case FFI_TYPE_SMALL_STRUCT6: off = 2; break;
+ case FFI_TYPE_SMALL_STRUCT7: off = 1; break;
+ default: off = 0; break;
+ }
+
+ memset (ret2, 0, sizeof (ret2));
+ memcpy ((char *)ret2 + off, ret, 8 - off);
+
+ *(stack - FIRST_ARG_SLOT) = ret2[0];
+ *(stack - FIRST_ARG_SLOT - 1) = ret2[1];
+ }
+ break;
+
+ case FFI_TYPE_POINTER:
+ case FFI_TYPE_VOID:
+ break;
+
+ default:
+ debug(0, "assert with cif->flags: %d\n",cif->flags);
+ FFI_ASSERT(0);
+ break;
+ }
+ return FFI_OK;
+}
+
+/* Fill in a closure to refer to the specified fun and user_data.
+ cif specifies the argument and result types for fun.
+ The cif must already be prep'ed. */
+
+extern void ffi_closure_pa32(void);
+
+ffi_status
+ffi_prep_closure_loc (ffi_closure* closure,
+ ffi_cif* cif,
+ void (*fun)(ffi_cif*,void*,void**,void*),
+ void *user_data,
+ void *codeloc)
+{
+ UINT32 *tramp = (UINT32 *)(closure->tramp);
+#ifdef PA_HPUX
+ UINT32 *tmp;
+#endif
+
+ if (cif->abi != FFI_PA32)
+ return FFI_BAD_ABI;
+
+ /* Make a small trampoline that will branch to our
+ handler function. Use PC-relative addressing. */
+
+#ifdef PA_LINUX
+ tramp[0] = 0xeaa00000; /* b,l .+8,%r21 ; %r21 <- pc+8 */
+ tramp[1] = 0xd6a01c1e; /* depi 0,31,2,%r21 ; mask priv bits */
+ tramp[2] = 0x4aa10028; /* ldw 20(%r21),%r1 ; load plabel */
+ tramp[3] = 0x36b53ff1; /* ldo -8(%r21),%r21 ; get closure addr */
+ tramp[4] = 0x0c201096; /* ldw 0(%r1),%r22 ; address of handler */
+ tramp[5] = 0xeac0c000; /* bv%r0(%r22) ; branch to handler */
+ tramp[6] = 0x0c281093; /* ldw 4(%r1),%r19 ; GP of handler */
+ tramp[7] = ((UINT32)(ffi_closure_pa32) & ~2);
+
+ /* Flush d/icache -- have to flush up 2 two lines because of
+ alignment. */
+ __asm__ volatile(
+ "fdc 0(%0)\n\t"
+ "fdc %1(%0)\n\t"
+ "fic 0(%%sr4, %0)\n\t"
+ "fic %1(%%sr4, %0)\n\t"
+ "sync\n\t"
+ "nop\n\t"
+ "nop\n\t"
+ "nop\n\t"
+ "nop\n\t"
+ "nop\n\t"
+ "nop\n\t"
+ "nop\n"
+ :
+ : "r"((unsigned long)tramp & ~31),
+ "r"(32 /* stride */)
+ : "memory");
+#endif
+
+#ifdef PA_HPUX
+ tramp[0] = 0xeaa00000; /* b,l .+8,%r21 ; %r21 <- pc+8 */
+ tramp[1] = 0xd6a01c1e; /* depi 0,31,2,%r21 ; mask priv bits */
+ tramp[2] = 0x4aa10038; /* ldw 28(%r21),%r1 ; load plabel */
+ tramp[3] = 0x36b53ff1; /* ldo -8(%r21),%r21 ; get closure addr */
+ tramp[4] = 0x0c201096; /* ldw 0(%r1),%r22 ; address of handler */
+ tramp[5] = 0x02c010b4; /* ldsid (%r22),%r20 ; load space id */
+ tramp[6] = 0x00141820; /* mtsp %r20,%sr0 ; into %sr0 */
+ tramp[7] = 0xe2c00000; /* be 0(%sr0,%r22) ; branch to handler */
+ tramp[8] = 0x0c281093; /* ldw 4(%r1),%r19 ; GP of handler */
+ tramp[9] = ((UINT32)(ffi_closure_pa32) & ~2);
+
+ /* Flush d/icache -- have to flush three lines because of alignment. */
+ __asm__ volatile(
+ "copy %1,%0\n\t"
+ "fdc,m %2(%0)\n\t"
+ "fdc,m %2(%0)\n\t"
+ "fdc,m %2(%0)\n\t"
+ "ldsid (%1),%0\n\t"
+ "mtsp %0,%%sr0\n\t"
+ "copy %1,%0\n\t"
+ "fic,m %2(%%sr0,%0)\n\t"
+ "fic,m %2(%%sr0,%0)\n\t"
+ "fic,m %2(%%sr0,%0)\n\t"
+ "sync\n\t"
+ "nop\n\t"
+ "nop\n\t"
+ "nop\n\t"
+ "nop\n\t"
+ "nop\n\t"
+ "nop\n\t"
+ "nop\n"
+ : "=&r" ((unsigned long)tmp)
+ : "r" ((unsigned long)tramp & ~31),
+ "r" (32/* stride */)
+ : "memory");
+#endif
+
+ closure->cif = cif;
+ closure->user_data = user_data;
+ closure->fun = fun;
+
+ return FFI_OK;
+}
+#endif
diff --git a/jni/ruby/ext/fiddle/libffi-3.2.1/src/pa/ffitarget.h b/jni/ruby/ext/fiddle/libffi-3.2.1/src/pa/ffitarget.h
new file mode 100644
index 0000000..fff4c6b
--- /dev/null
+++ b/jni/ruby/ext/fiddle/libffi-3.2.1/src/pa/ffitarget.h
@@ -0,0 +1,85 @@
+/* -----------------------------------------------------------------*-C-*-
+ ffitarget.h - Copyright (c) 2012 Anthony Green
+ Copyright (c) 1996-2003 Red Hat, Inc.
+ Target configuration macros for hppa.
+
+ Permission is hereby granted, free of charge, to any person obtaining
+ a copy of this software and associated documentation files (the
+ ``Software''), to deal in the Software without restriction, including
+ without limitation the rights to use, copy, modify, merge, publish,
+ distribute, sublicense, and/or sell copies of the Software, and to
+ permit persons to whom the Software is furnished to do so, subject to
+ the following conditions:
+
+ The above copyright notice and this permission notice shall be included
+ in all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND,
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+ HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ DEALINGS IN THE SOFTWARE.
+
+ ----------------------------------------------------------------------- */
+
+#ifndef LIBFFI_TARGET_H
+#define LIBFFI_TARGET_H
+
+#ifndef LIBFFI_H
+#error "Please do not include ffitarget.h directly into your source. Use ffi.h instead."
+#endif
+
+/* ---- System specific configurations ----------------------------------- */
+
+#ifndef LIBFFI_ASM
+typedef unsigned long ffi_arg;
+typedef signed long ffi_sarg;
+
+typedef enum ffi_abi {
+ FFI_FIRST_ABI = 0,
+
+#ifdef PA_LINUX
+ FFI_PA32,
+ FFI_LAST_ABI,
+ FFI_DEFAULT_ABI = FFI_PA32
+#endif
+
+#ifdef PA_HPUX
+ FFI_PA32,
+ FFI_LAST_ABI,
+ FFI_DEFAULT_ABI = FFI_PA32
+#endif
+
+#ifdef PA64_HPUX
+#error "PA64_HPUX FFI is not yet implemented"
+ FFI_PA64,
+ FFI_LAST_ABI,
+ FFI_DEFAULT_ABI = FFI_PA64
+#endif
+} ffi_abi;
+#endif
+
+#define FFI_TARGET_SPECIFIC_STACK_SPACE_ALLOCATION
+
+/* ---- Definitions for closures ----------------------------------------- */
+
+#define FFI_CLOSURES 1
+#define FFI_NATIVE_RAW_API 0
+
+#ifdef PA_LINUX
+#define FFI_TRAMPOLINE_SIZE 32
+#else
+#define FFI_TRAMPOLINE_SIZE 40
+#endif
+
+#define FFI_TYPE_SMALL_STRUCT2 -1
+#define FFI_TYPE_SMALL_STRUCT3 -2
+#define FFI_TYPE_SMALL_STRUCT4 -3
+#define FFI_TYPE_SMALL_STRUCT5 -4
+#define FFI_TYPE_SMALL_STRUCT6 -5
+#define FFI_TYPE_SMALL_STRUCT7 -6
+#define FFI_TYPE_SMALL_STRUCT8 -7
+#endif
diff --git a/jni/ruby/ext/fiddle/libffi-3.2.1/src/pa/hpux32.S b/jni/ruby/ext/fiddle/libffi-3.2.1/src/pa/hpux32.S
new file mode 100644
index 0000000..40528ba
--- /dev/null
+++ b/jni/ruby/ext/fiddle/libffi-3.2.1/src/pa/hpux32.S
@@ -0,0 +1,368 @@
+/* -----------------------------------------------------------------------
+ hpux32.S - Copyright (c) 2006 Free Software Foundation, Inc.
+ (c) 2008 Red Hat, Inc.
+ based on src/pa/linux.S
+
+ HP-UX PA Foreign Function Interface
+
+ Permission is hereby granted, free of charge, to any person obtaining
+ a copy of this software and associated documentation files (the
+ ``Software''), to deal in the Software without restriction, including
+ without limitation the rights to use, copy, modify, merge, publish,
+ distribute, sublicense, and/or sell copies of the Software, and to
+ permit persons to whom the Software is furnished to do so, subject to
+ the following conditions:
+
+ The above copyright notice and this permission notice shall be included
+ in all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ OTHER DEALINGS IN THE SOFTWARE.
+ ----------------------------------------------------------------------- */
+
+#define LIBFFI_ASM
+#include <fficonfig.h>
+#include <ffi.h>
+
+ .LEVEL 1.1
+ .SPACE $PRIVATE$
+ .IMPORT $global$,DATA
+ .IMPORT $$dyncall,MILLICODE
+ .SUBSPA $DATA$
+ .align 4
+
+ /* void ffi_call_pa32(void (*)(char *, extended_cif *),
+ extended_cif *ecif,
+ unsigned bytes,
+ unsigned flags,
+ unsigned *rvalue,
+ void (*fn)(void));
+ */
+
+ .export ffi_call_pa32,ENTRY,PRIV_LEV=3
+ .import ffi_prep_args_pa32,CODE
+
+ .SPACE $TEXT$
+ .SUBSPA $CODE$
+ .align 4
+
+L$FB1
+ffi_call_pa32
+ .proc
+ .callinfo FRAME=64,CALLS,SAVE_RP,SAVE_SP,ENTRY_GR=4
+ .entry
+ stw %rp, -20(%sp)
+ copy %r3, %r1
+L$CFI11
+ copy %sp, %r3
+L$CFI12
+
+ /* Setup the stack for calling prep_args...
+ We want the stack to look like this:
+
+ [ Previous stack ] <- %r3
+
+ [ 64-bytes register save area ] <- %r4
+
+ [ Stack space for actual call, passed as ] <- %arg0
+ [ arg0 to ffi_prep_args_pa32 ]
+
+ [ Stack for calling prep_args ] <- %sp
+ */
+
+ stwm %r1, 64(%sp)
+ stw %r4, 12(%r3)
+L$CFI13
+ copy %sp, %r4
+
+ addl %arg2, %r4, %arg0 ; arg stack
+ stw %arg3, -48(%r3) ; save flags we need it later
+
+ /* Call prep_args:
+ %arg0(stack) -- set up above
+ %arg1(ecif) -- same as incoming param
+ %arg2(bytes) -- same as incoming param */
+ bl ffi_prep_args_pa32,%r2
+ ldo 64(%arg0), %sp
+ ldo -64(%sp), %sp
+
+ /* now %sp should point where %arg0 was pointing. */
+
+ /* Load the arguments that should be passed in registers
+ The fp args are loaded by the prep_args function. */
+ ldw -36(%sp), %arg0
+ ldw -40(%sp), %arg1
+ ldw -44(%sp), %arg2
+ ldw -48(%sp), %arg3
+
+ /* in case the function is going to return a structure
+ we need to give it a place to put the result. */
+ ldw -52(%r3), %ret0 ; %ret0 <- rvalue
+ ldw -56(%r3), %r22 ; %r22 <- function to call
+ bl $$dyncall, %r31 ; Call the user function
+ copy %r31, %rp
+
+ /* Prepare to store the result; we need to recover flags and rvalue. */
+ ldw -48(%r3), %r21 ; r21 <- flags
+ ldw -52(%r3), %r20 ; r20 <- rvalue
+
+ /* Store the result according to the return type. The most
+ likely types should come first. */
+
+L$checkint
+ comib,<>,n FFI_TYPE_INT, %r21, L$checkint8
+ b L$done
+ stw %ret0, 0(%r20)
+
+L$checkint8
+ comib,<>,n FFI_TYPE_UINT8, %r21, L$checkint16
+ b L$done
+ stb %ret0, 0(%r20)
+
+L$checkint16
+ comib,<>,n FFI_TYPE_UINT16, %r21, L$checkdbl
+ b L$done
+ sth %ret0, 0(%r20)
+
+L$checkdbl
+ comib,<>,n FFI_TYPE_DOUBLE, %r21, L$checkfloat
+ b L$done
+ fstd %fr4,0(%r20)
+
+L$checkfloat
+ comib,<>,n FFI_TYPE_FLOAT, %r21, L$checkll
+ b L$done
+ fstw %fr4L,0(%r20)
+
+L$checkll
+ comib,<>,n FFI_TYPE_UINT64, %r21, L$checksmst2
+ stw %ret0, 0(%r20)
+ b L$done
+ stw %ret1, 4(%r20)
+
+L$checksmst2
+ comib,<>,n FFI_TYPE_SMALL_STRUCT2, %r21, L$checksmst3
+ /* 2-byte structs are returned in ret0 as ????xxyy. */
+ extru %ret0, 23, 8, %r22
+ stbs,ma %r22, 1(%r20)
+ b L$done
+ stb %ret0, 0(%r20)
+
+L$checksmst3
+ comib,<>,n FFI_TYPE_SMALL_STRUCT3, %r21, L$checksmst4
+ /* 3-byte structs are returned in ret0 as ??xxyyzz. */
+ extru %ret0, 15, 8, %r22
+ stbs,ma %r22, 1(%r20)
+ extru %ret0, 23, 8, %r22
+ stbs,ma %r22, 1(%r20)
+ b L$done
+ stb %ret0, 0(%r20)
+
+L$checksmst4
+ comib,<>,n FFI_TYPE_SMALL_STRUCT4, %r21, L$checksmst5
+ /* 4-byte structs are returned in ret0 as wwxxyyzz. */
+ extru %ret0, 7, 8, %r22
+ stbs,ma %r22, 1(%r20)
+ extru %ret0, 15, 8, %r22
+ stbs,ma %r22, 1(%r20)
+ extru %ret0, 23, 8, %r22
+ stbs,ma %r22, 1(%r20)
+ b L$done
+ stb %ret0, 0(%r20)
+
+L$checksmst5
+ comib,<>,n FFI_TYPE_SMALL_STRUCT5, %r21, L$checksmst6
+ /* 5 byte values are returned right justified:
+ ret0 ret1
+ 5: ??????aa bbccddee */
+ stbs,ma %ret0, 1(%r20)
+ extru %ret1, 7, 8, %r22
+ stbs,ma %r22, 1(%r20)
+ extru %ret1, 15, 8, %r22
+ stbs,ma %r22, 1(%r20)
+ extru %ret1, 23, 8, %r22
+ stbs,ma %r22, 1(%r20)
+ b L$done
+ stb %ret1, 0(%r20)
+
+L$checksmst6
+ comib,<>,n FFI_TYPE_SMALL_STRUCT6, %r21, L$checksmst7
+ /* 6 byte values are returned right justified:
+ ret0 ret1
+ 6: ????aabb ccddeeff */
+ extru %ret0, 23, 8, %r22
+ stbs,ma %r22, 1(%r20)
+ stbs,ma %ret0, 1(%r20)
+ extru %ret1, 7, 8, %r22
+ stbs,ma %r22, 1(%r20)
+ extru %ret1, 15, 8, %r22
+ stbs,ma %r22, 1(%r20)
+ extru %ret1, 23, 8, %r22
+ stbs,ma %r22, 1(%r20)
+ b L$done
+ stb %ret1, 0(%r20)
+
+L$checksmst7
+ comib,<>,n FFI_TYPE_SMALL_STRUCT7, %r21, L$checksmst8
+ /* 7 byte values are returned right justified:
+ ret0 ret1
+ 7: ??aabbcc ddeeffgg */
+ extru %ret0, 15, 8, %r22
+ stbs,ma %r22, 1(%r20)
+ extru %ret0, 23, 8, %r22
+ stbs,ma %r22, 1(%r20)
+ stbs,ma %ret0, 1(%r20)
+ extru %ret1, 7, 8, %r22
+ stbs,ma %r22, 1(%r20)
+ extru %ret1, 15, 8, %r22
+ stbs,ma %r22, 1(%r20)
+ extru %ret1, 23, 8, %r22
+ stbs,ma %r22, 1(%r20)
+ b L$done
+ stb %ret1, 0(%r20)
+
+L$checksmst8
+ comib,<>,n FFI_TYPE_SMALL_STRUCT8, %r21, L$done
+ /* 8 byte values are returned right justified:
+ ret0 ret1
+ 8: aabbccdd eeffgghh */
+ extru %ret0, 7, 8, %r22
+ stbs,ma %r22, 1(%r20)
+ extru %ret0, 15, 8, %r22
+ stbs,ma %r22, 1(%r20)
+ extru %ret0, 23, 8, %r22
+ stbs,ma %r22, 1(%r20)
+ stbs,ma %ret0, 1(%r20)
+ extru %ret1, 7, 8, %r22
+ stbs,ma %r22, 1(%r20)
+ extru %ret1, 15, 8, %r22
+ stbs,ma %r22, 1(%r20)
+ extru %ret1, 23, 8, %r22
+ stbs,ma %r22, 1(%r20)
+ stb %ret1, 0(%r20)
+
+L$done
+ /* all done, return */
+ copy %r4, %sp ; pop arg stack
+ ldw 12(%r3), %r4
+ ldwm -64(%sp), %r3 ; .. and pop stack
+ ldw -20(%sp), %rp
+ bv %r0(%rp)
+ nop
+ .exit
+ .procend
+L$FE1
+
+ /* void ffi_closure_pa32(void);
+ Called with closure argument in %r21 */
+
+ .SPACE $TEXT$
+ .SUBSPA $CODE$
+ .export ffi_closure_pa32,ENTRY,PRIV_LEV=3,RTNVAL=GR
+ .import ffi_closure_inner_pa32,CODE
+ .align 4
+L$FB2
+ffi_closure_pa32
+ .proc
+ .callinfo FRAME=64,CALLS,SAVE_RP,SAVE_SP,ENTRY_GR=3
+ .entry
+
+ stw %rp, -20(%sp)
+ copy %r3, %r1
+L$CFI21
+ copy %sp, %r3
+L$CFI22
+ stwm %r1, 64(%sp)
+
+ /* Put arguments onto the stack and call ffi_closure_inner. */
+ stw %arg0, -36(%r3)
+ stw %arg1, -40(%r3)
+ stw %arg2, -44(%r3)
+ stw %arg3, -48(%r3)
+
+ copy %r21, %arg0
+ bl ffi_closure_inner_pa32, %r2
+ copy %r3, %arg1
+ ldwm -64(%sp), %r3
+ ldw -20(%sp), %rp
+ ldw -36(%sp), %ret0
+ bv %r0(%rp)
+ ldw -40(%sp), %ret1
+ .exit
+ .procend
+L$FE2:
+
+ .SPACE $PRIVATE$
+ .SUBSPA $DATA$
+
+ .align 4
+ .EXPORT _GLOBAL__F_ffi_call_pa32,DATA
+_GLOBAL__F_ffi_call_pa32
+L$frame1:
+ .word L$ECIE1-L$SCIE1 ;# Length of Common Information Entry
+L$SCIE1:
+ .word 0x0 ;# CIE Identifier Tag
+ .byte 0x1 ;# CIE Version
+ .ascii "\0" ;# CIE Augmentation
+ .uleb128 0x1 ;# CIE Code Alignment Factor
+ .sleb128 4 ;# CIE Data Alignment Factor
+ .byte 0x2 ;# CIE RA Column
+ .byte 0xc ;# DW_CFA_def_cfa
+ .uleb128 0x1e
+ .uleb128 0x0
+ .align 4
+L$ECIE1:
+L$SFDE1:
+ .word L$EFDE1-L$ASFDE1 ;# FDE Length
+L$ASFDE1:
+ .word L$ASFDE1-L$frame1 ;# FDE CIE offset
+ .word L$FB1 ;# FDE initial location
+ .word L$FE1-L$FB1 ;# FDE address range
+
+ .byte 0x4 ;# DW_CFA_advance_loc4
+ .word L$CFI11-L$FB1
+ .byte 0x83 ;# DW_CFA_offset, column 0x3
+ .uleb128 0x0
+ .byte 0x11 ;# DW_CFA_offset_extended_sf; save r2 at [r30-20]
+ .uleb128 0x2
+ .sleb128 -5
+
+ .byte 0x4 ;# DW_CFA_advance_loc4
+ .word L$CFI12-L$CFI11
+ .byte 0xd ;# DW_CFA_def_cfa_register = r3
+ .uleb128 0x3
+
+ .byte 0x4 ;# DW_CFA_advance_loc4
+ .word L$CFI13-L$CFI12
+ .byte 0x84 ;# DW_CFA_offset, column 0x4
+ .uleb128 0x3
+
+ .align 4
+L$EFDE1:
+
+L$SFDE2:
+ .word L$EFDE2-L$ASFDE2 ;# FDE Length
+L$ASFDE2:
+ .word L$ASFDE2-L$frame1 ;# FDE CIE offset
+ .word L$FB2 ;# FDE initial location
+ .word L$FE2-L$FB2 ;# FDE address range
+ .byte 0x4 ;# DW_CFA_advance_loc4
+ .word L$CFI21-L$FB2
+ .byte 0x83 ;# DW_CFA_offset, column 0x3
+ .uleb128 0x0
+ .byte 0x11 ;# DW_CFA_offset_extended_sf
+ .uleb128 0x2
+ .sleb128 -5
+
+ .byte 0x4 ;# DW_CFA_advance_loc4
+ .word L$CFI22-L$CFI21
+ .byte 0xd ;# DW_CFA_def_cfa_register = r3
+ .uleb128 0x3
+
+ .align 4
+L$EFDE2:
diff --git a/jni/ruby/ext/fiddle/libffi-3.2.1/src/pa/linux.S b/jni/ruby/ext/fiddle/libffi-3.2.1/src/pa/linux.S
new file mode 100644
index 0000000..f11ae76
--- /dev/null
+++ b/jni/ruby/ext/fiddle/libffi-3.2.1/src/pa/linux.S
@@ -0,0 +1,357 @@
+/* -----------------------------------------------------------------------
+ linux.S - (c) 2003-2004 Randolph Chung <tausq@debian.org>
+ (c) 2008 Red Hat, Inc.
+
+ HPPA Foreign Function Interface
+
+ Permission is hereby granted, free of charge, to any person obtaining
+ a copy of this software and associated documentation files (the
+ ``Software''), to deal in the Software without restriction, including
+ without limitation the rights to use, copy, modify, merge, publish,
+ distribute, sublicense, and/or sell copies of the Software, and to
+ permit persons to whom the Software is furnished to do so, subject to
+ the following conditions:
+
+ The above copyright notice and this permission notice shall be included
+ in all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ IN NO EVENT SHALL RENESAS TECHNOLOGY BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ OTHER DEALINGS IN THE SOFTWARE.
+ ----------------------------------------------------------------------- */
+
+#define LIBFFI_ASM
+#include <fficonfig.h>
+#include <ffi.h>
+
+ .text
+ .level 1.1
+ .align 4
+
+ /* void ffi_call_pa32(void (*)(char *, extended_cif *),
+ extended_cif *ecif,
+ unsigned bytes,
+ unsigned flags,
+ unsigned *rvalue,
+ void (*fn)(void));
+ */
+
+ .export ffi_call_pa32,code
+ .import ffi_prep_args_pa32,code
+
+ .type ffi_call_pa32, @function
+.LFB1:
+ffi_call_pa32:
+ .proc
+ .callinfo FRAME=64,CALLS,SAVE_RP,SAVE_SP,ENTRY_GR=4
+ .entry
+ stw %rp, -20(%sp)
+ copy %r3, %r1
+.LCFI11:
+
+ copy %sp, %r3
+.LCFI12:
+
+ /* Setup the stack for calling prep_args...
+ We want the stack to look like this:
+
+ [ Previous stack ] <- %r3
+
+ [ 64-bytes register save area ] <- %r4
+
+ [ Stack space for actual call, passed as ] <- %arg0
+ [ arg0 to ffi_prep_args_pa32 ]
+
+ [ Stack for calling prep_args ] <- %sp
+ */
+
+ stwm %r1, 64(%sp)
+ stw %r4, 12(%r3)
+.LCFI13:
+ copy %sp, %r4
+
+ addl %arg2, %r4, %arg0 /* arg stack */
+ stw %arg3, -48(%r3) /* save flags; we need it later */
+
+ /* Call prep_args:
+ %arg0(stack) -- set up above
+ %arg1(ecif) -- same as incoming param
+ %arg2(bytes) -- same as incoming param */
+ bl ffi_prep_args_pa32,%r2
+ ldo 64(%arg0), %sp
+ ldo -64(%sp), %sp
+
+ /* now %sp should point where %arg0 was pointing. */
+
+ /* Load the arguments that should be passed in registers
+ The fp args were loaded by the prep_args function. */
+ ldw -36(%sp), %arg0
+ ldw -40(%sp), %arg1
+ ldw -44(%sp), %arg2
+ ldw -48(%sp), %arg3
+
+ /* in case the function is going to return a structure
+ we need to give it a place to put the result. */
+ ldw -52(%r3), %ret0 /* %ret0 <- rvalue */
+ ldw -56(%r3), %r22 /* %r22 <- function to call */
+ bl $$dyncall, %r31 /* Call the user function */
+ copy %r31, %rp
+
+ /* Prepare to store the result; we need to recover flags and rvalue. */
+ ldw -48(%r3), %r21 /* r21 <- flags */
+ ldw -52(%r3), %r20 /* r20 <- rvalue */
+
+ /* Store the result according to the return type. */
+
+.Lcheckint:
+ comib,<>,n FFI_TYPE_INT, %r21, .Lcheckint8
+ b .Ldone
+ stw %ret0, 0(%r20)
+
+.Lcheckint8:
+ comib,<>,n FFI_TYPE_UINT8, %r21, .Lcheckint16
+ b .Ldone
+ stb %ret0, 0(%r20)
+
+.Lcheckint16:
+ comib,<>,n FFI_TYPE_UINT16, %r21, .Lcheckdbl
+ b .Ldone
+ sth %ret0, 0(%r20)
+
+.Lcheckdbl:
+ comib,<>,n FFI_TYPE_DOUBLE, %r21, .Lcheckfloat
+ b .Ldone
+ fstd %fr4,0(%r20)
+
+.Lcheckfloat:
+ comib,<>,n FFI_TYPE_FLOAT, %r21, .Lcheckll
+ b .Ldone
+ fstw %fr4L,0(%r20)
+
+.Lcheckll:
+ comib,<>,n FFI_TYPE_UINT64, %r21, .Lchecksmst2
+ stw %ret0, 0(%r20)
+ b .Ldone
+ stw %ret1, 4(%r20)
+
+.Lchecksmst2:
+ comib,<>,n FFI_TYPE_SMALL_STRUCT2, %r21, .Lchecksmst3
+ /* 2-byte structs are returned in ret0 as ????xxyy. */
+ extru %ret0, 23, 8, %r22
+ stbs,ma %r22, 1(%r20)
+ b .Ldone
+ stb %ret0, 0(%r20)
+
+.Lchecksmst3:
+ comib,<>,n FFI_TYPE_SMALL_STRUCT3, %r21, .Lchecksmst4
+ /* 3-byte structs are returned in ret0 as ??xxyyzz. */
+ extru %ret0, 15, 8, %r22
+ stbs,ma %r22, 1(%r20)
+ extru %ret0, 23, 8, %r22
+ stbs,ma %r22, 1(%r20)
+ b .Ldone
+ stb %ret0, 0(%r20)
+
+.Lchecksmst4:
+ comib,<>,n FFI_TYPE_SMALL_STRUCT4, %r21, .Lchecksmst5
+ /* 4-byte structs are returned in ret0 as wwxxyyzz. */
+ extru %ret0, 7, 8, %r22
+ stbs,ma %r22, 1(%r20)
+ extru %ret0, 15, 8, %r22
+ stbs,ma %r22, 1(%r20)
+ extru %ret0, 23, 8, %r22
+ stbs,ma %r22, 1(%r20)
+ b .Ldone
+ stb %ret0, 0(%r20)
+
+.Lchecksmst5:
+ comib,<>,n FFI_TYPE_SMALL_STRUCT5, %r21, .Lchecksmst6
+ /* 5 byte values are returned right justified:
+ ret0 ret1
+ 5: ??????aa bbccddee */
+ stbs,ma %ret0, 1(%r20)
+ extru %ret1, 7, 8, %r22
+ stbs,ma %r22, 1(%r20)
+ extru %ret1, 15, 8, %r22
+ stbs,ma %r22, 1(%r20)
+ extru %ret1, 23, 8, %r22
+ stbs,ma %r22, 1(%r20)
+ b .Ldone
+ stb %ret1, 0(%r20)
+
+.Lchecksmst6:
+ comib,<>,n FFI_TYPE_SMALL_STRUCT6, %r21, .Lchecksmst7
+ /* 6 byte values are returned right justified:
+ ret0 ret1
+ 6: ????aabb ccddeeff */
+ extru %ret0, 23, 8, %r22
+ stbs,ma %r22, 1(%r20)
+ stbs,ma %ret0, 1(%r20)
+ extru %ret1, 7, 8, %r22
+ stbs,ma %r22, 1(%r20)
+ extru %ret1, 15, 8, %r22
+ stbs,ma %r22, 1(%r20)
+ extru %ret1, 23, 8, %r22
+ stbs,ma %r22, 1(%r20)
+ b .Ldone
+ stb %ret1, 0(%r20)
+
+.Lchecksmst7:
+ comib,<>,n FFI_TYPE_SMALL_STRUCT7, %r21, .Lchecksmst8
+ /* 7 byte values are returned right justified:
+ ret0 ret1
+ 7: ??aabbcc ddeeffgg */
+ extru %ret0, 15, 8, %r22
+ stbs,ma %r22, 1(%r20)
+ extru %ret0, 23, 8, %r22
+ stbs,ma %r22, 1(%r20)
+ stbs,ma %ret0, 1(%r20)
+ extru %ret1, 7, 8, %r22
+ stbs,ma %r22, 1(%r20)
+ extru %ret1, 15, 8, %r22
+ stbs,ma %r22, 1(%r20)
+ extru %ret1, 23, 8, %r22
+ stbs,ma %r22, 1(%r20)
+ b .Ldone
+ stb %ret1, 0(%r20)
+
+.Lchecksmst8:
+ comib,<>,n FFI_TYPE_SMALL_STRUCT8, %r21, .Ldone
+ /* 8 byte values are returned right justified:
+ ret0 ret1
+ 8: aabbccdd eeffgghh */
+ extru %ret0, 7, 8, %r22
+ stbs,ma %r22, 1(%r20)
+ extru %ret0, 15, 8, %r22
+ stbs,ma %r22, 1(%r20)
+ extru %ret0, 23, 8, %r22
+ stbs,ma %r22, 1(%r20)
+ stbs,ma %ret0, 1(%r20)
+ extru %ret1, 7, 8, %r22
+ stbs,ma %r22, 1(%r20)
+ extru %ret1, 15, 8, %r22
+ stbs,ma %r22, 1(%r20)
+ extru %ret1, 23, 8, %r22
+ stbs,ma %r22, 1(%r20)
+ stb %ret1, 0(%r20)
+
+.Ldone:
+ /* all done, return */
+ copy %r4, %sp /* pop arg stack */
+ ldw 12(%r3), %r4
+ ldwm -64(%sp), %r3 /* .. and pop stack */
+ ldw -20(%sp), %rp
+ bv %r0(%rp)
+ nop
+ .exit
+ .procend
+.LFE1:
+
+ /* void ffi_closure_pa32(void);
+ Called with closure argument in %r21 */
+ .export ffi_closure_pa32,code
+ .import ffi_closure_inner_pa32,code
+
+ .type ffi_closure_pa32, @function
+.LFB2:
+ffi_closure_pa32:
+ .proc
+ .callinfo FRAME=64,CALLS,SAVE_RP,SAVE_SP,ENTRY_GR=3
+ .entry
+
+ stw %rp, -20(%sp)
+.LCFI20:
+ copy %r3, %r1
+.LCFI21:
+ copy %sp, %r3
+.LCFI22:
+ stwm %r1, 64(%sp)
+
+ /* Put arguments onto the stack and call ffi_closure_inner. */
+ stw %arg0, -36(%r3)
+ stw %arg1, -40(%r3)
+ stw %arg2, -44(%r3)
+ stw %arg3, -48(%r3)
+
+ copy %r21, %arg0
+ bl ffi_closure_inner_pa32, %r2
+ copy %r3, %arg1
+
+ ldwm -64(%sp), %r3
+ ldw -20(%sp), %rp
+ ldw -36(%sp), %ret0
+ bv %r0(%r2)
+ ldw -40(%sp), %ret1
+
+ .exit
+ .procend
+.LFE2:
+
+ .section ".eh_frame",EH_FRAME_FLAGS,@progbits
+.Lframe1:
+ .word .LECIE1-.LSCIE1 ;# Length of Common Information Entry
+.LSCIE1:
+ .word 0x0 ;# CIE Identifier Tag
+ .byte 0x1 ;# CIE Version
+ .ascii "\0" ;# CIE Augmentation
+ .uleb128 0x1 ;# CIE Code Alignment Factor
+ .sleb128 4 ;# CIE Data Alignment Factor
+ .byte 0x2 ;# CIE RA Column
+ .byte 0xc ;# DW_CFA_def_cfa
+ .uleb128 0x1e
+ .uleb128 0x0
+ .align 4
+.LECIE1:
+.LSFDE1:
+ .word .LEFDE1-.LASFDE1 ;# FDE Length
+.LASFDE1:
+ .word .LASFDE1-.Lframe1 ;# FDE CIE offset
+ .word .LFB1 ;# FDE initial location
+ .word .LFE1-.LFB1 ;# FDE address range
+
+ .byte 0x4 ;# DW_CFA_advance_loc4
+ .word .LCFI11-.LFB1
+ .byte 0x83 ;# DW_CFA_offset, column 0x3
+ .uleb128 0x0
+ .byte 0x11 ;# DW_CFA_offset_extended_sf; save r2 at [r30-20]
+ .uleb128 0x2
+ .sleb128 -5
+
+ .byte 0x4 ;# DW_CFA_advance_loc4
+ .word .LCFI12-.LCFI11
+ .byte 0xd ;# DW_CFA_def_cfa_register = r3
+ .uleb128 0x3
+
+ .byte 0x4 ;# DW_CFA_advance_loc4
+ .word .LCFI13-.LCFI12
+ .byte 0x84 ;# DW_CFA_offset, column 0x4
+ .uleb128 0x3
+
+ .align 4
+.LEFDE1:
+
+.LSFDE2:
+ .word .LEFDE2-.LASFDE2 ;# FDE Length
+.LASFDE2:
+ .word .LASFDE2-.Lframe1 ;# FDE CIE offset
+ .word .LFB2 ;# FDE initial location
+ .word .LFE2-.LFB2 ;# FDE address range
+ .byte 0x4 ;# DW_CFA_advance_loc4
+ .word .LCFI21-.LFB2
+ .byte 0x83 ;# DW_CFA_offset, column 0x3
+ .uleb128 0x0
+ .byte 0x11 ;# DW_CFA_offset_extended_sf
+ .uleb128 0x2
+ .sleb128 -5
+
+ .byte 0x4 ;# DW_CFA_advance_loc4
+ .word .LCFI22-.LCFI21
+ .byte 0xd ;# DW_CFA_def_cfa_register = r3
+ .uleb128 0x3
+
+ .align 4
+.LEFDE2:
diff --git a/jni/ruby/ext/fiddle/libffi-3.2.1/src/powerpc/aix.S b/jni/ruby/ext/fiddle/libffi-3.2.1/src/powerpc/aix.S
new file mode 100644
index 0000000..349e78c
--- /dev/null
+++ b/jni/ruby/ext/fiddle/libffi-3.2.1/src/powerpc/aix.S
@@ -0,0 +1,328 @@
+/* -----------------------------------------------------------------------
+ aix.S - Copyright (c) 2002, 2009 Free Software Foundation, Inc.
+ based on darwin.S by John Hornkvist
+
+ PowerPC Assembly glue.
+
+ Permission is hereby granted, free of charge, to any person obtaining
+ a copy of this software and associated documentation files (the
+ ``Software''), to deal in the Software without restriction, including
+ without limitation the rights to use, copy, modify, merge, publish,
+ distribute, sublicense, and/or sell copies of the Software, and to
+ permit persons to whom the Software is furnished to do so, subject to
+ the following conditions:
+
+ The above copyright notice and this permission notice shall be included
+ in all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ OTHER DEALINGS IN THE SOFTWARE.
+ ----------------------------------------------------------------------- */
+
+ .set r0,0
+ .set r1,1
+ .set r2,2
+ .set r3,3
+ .set r4,4
+ .set r5,5
+ .set r6,6
+ .set r7,7
+ .set r8,8
+ .set r9,9
+ .set r10,10
+ .set r11,11
+ .set r12,12
+ .set r13,13
+ .set r14,14
+ .set r15,15
+ .set r16,16
+ .set r17,17
+ .set r18,18
+ .set r19,19
+ .set r20,20
+ .set r21,21
+ .set r22,22
+ .set r23,23
+ .set r24,24
+ .set r25,25
+ .set r26,26
+ .set r27,27
+ .set r28,28
+ .set r29,29
+ .set r30,30
+ .set r31,31
+ .set f0,0
+ .set f1,1
+ .set f2,2
+ .set f3,3
+ .set f4,4
+ .set f5,5
+ .set f6,6
+ .set f7,7
+ .set f8,8
+ .set f9,9
+ .set f10,10
+ .set f11,11
+ .set f12,12
+ .set f13,13
+ .set f14,14
+ .set f15,15
+ .set f16,16
+ .set f17,17
+ .set f18,18
+ .set f19,19
+ .set f20,20
+ .set f21,21
+
+ .extern .ffi_prep_args
+
+#define LIBFFI_ASM
+#include <fficonfig.h>
+#include <ffi.h>
+#define JUMPTARGET(name) name
+#define L(x) x
+ .file "aix.S"
+ .toc
+
+ /* void ffi_call_AIX(extended_cif *ecif, unsigned long bytes,
+ * unsigned int flags, unsigned int *rvalue,
+ * void (*fn)(),
+ * void (*prep_args)(extended_cif*, unsigned *const));
+ * r3=ecif, r4=bytes, r5=flags, r6=rvalue, r7=fn, r8=prep_args
+ */
+
+.csect .text[PR]
+ .align 2
+ .globl ffi_call_AIX
+ .globl .ffi_call_AIX
+.csect ffi_call_AIX[DS]
+ffi_call_AIX:
+#ifdef __64BIT__
+ .llong .ffi_call_AIX, TOC[tc0], 0
+ .csect .text[PR]
+.ffi_call_AIX:
+ /* Save registers we use. */
+ mflr r0
+
+ std r28,-32(r1)
+ std r29,-24(r1)
+ std r30,-16(r1)
+ std r31, -8(r1)
+
+ std r0, 16(r1)
+ mr r28, r1 /* our AP. */
+ stdux r1, r1, r4
+
+ /* Save arguments over call... */
+ mr r31, r5 /* flags, */
+ mr r30, r6 /* rvalue, */
+ mr r29, r7 /* function address. */
+ std r2, 40(r1)
+
+ /* Call ffi_prep_args. */
+ mr r4, r1
+ bl .ffi_prep_args
+ nop
+
+ /* Now do the call. */
+ ld r0, 0(r29)
+ ld r2, 8(r29)
+ ld r11, 16(r29)
+ /* Set up cr1 with bits 4-7 of the flags. */
+ mtcrf 0x40, r31
+ mtctr r0
+ /* Load all those argument registers. */
+ /* We have set up a nice stack frame, just load it into registers. */
+ ld r3, 40+(1*8)(r1)
+ ld r4, 40+(2*8)(r1)
+ ld r5, 40+(3*8)(r1)
+ ld r6, 40+(4*8)(r1)
+ nop
+ ld r7, 40+(5*8)(r1)
+ ld r8, 40+(6*8)(r1)
+ ld r9, 40+(7*8)(r1)
+ ld r10,40+(8*8)(r1)
+
+L1:
+ /* Load all the FP registers. */
+ bf 6,L2 /* 2f + 0x18 */
+ lfd f1,-32-(13*8)(r28)
+ lfd f2,-32-(12*8)(r28)
+ lfd f3,-32-(11*8)(r28)
+ lfd f4,-32-(10*8)(r28)
+ nop
+ lfd f5,-32-(9*8)(r28)
+ lfd f6,-32-(8*8)(r28)
+ lfd f7,-32-(7*8)(r28)
+ lfd f8,-32-(6*8)(r28)
+ nop
+ lfd f9,-32-(5*8)(r28)
+ lfd f10,-32-(4*8)(r28)
+ lfd f11,-32-(3*8)(r28)
+ lfd f12,-32-(2*8)(r28)
+ nop
+ lfd f13,-32-(1*8)(r28)
+
+L2:
+ /* Make the call. */
+ bctrl
+ ld r2, 40(r1)
+
+ /* Now, deal with the return value. */
+ mtcrf 0x01, r31
+
+ bt 30, L(done_return_value)
+ bt 29, L(fp_return_value)
+ std r3, 0(r30)
+
+ /* Fall through... */
+
+L(done_return_value):
+ /* Restore the registers we used and return. */
+ mr r1, r28
+ ld r0, 16(r28)
+ ld r28, -32(r1)
+ mtlr r0
+ ld r29, -24(r1)
+ ld r30, -16(r1)
+ ld r31, -8(r1)
+ blr
+
+L(fp_return_value):
+ bf 28, L(float_return_value)
+ stfd f1, 0(r30)
+ bf 31, L(done_return_value)
+ stfd f2, 8(r30)
+ b L(done_return_value)
+L(float_return_value):
+ stfs f1, 0(r30)
+ b L(done_return_value)
+
+#else /* ! __64BIT__ */
+
+ .long .ffi_call_AIX, TOC[tc0], 0
+ .csect .text[PR]
+.ffi_call_AIX:
+ /* Save registers we use. */
+ mflr r0
+
+ stw r28,-16(r1)
+ stw r29,-12(r1)
+ stw r30, -8(r1)
+ stw r31, -4(r1)
+
+ stw r0, 8(r1)
+ mr r28, r1 /* out AP. */
+ stwux r1, r1, r4
+
+ /* Save arguments over call... */
+ mr r31, r5 /* flags, */
+ mr r30, r6 /* rvalue, */
+ mr r29, r7 /* function address, */
+ stw r2, 20(r1)
+
+ /* Call ffi_prep_args. */
+ mr r4, r1
+ bl .ffi_prep_args
+ nop
+
+ /* Now do the call. */
+ lwz r0, 0(r29)
+ lwz r2, 4(r29)
+ lwz r11, 8(r29)
+ /* Set up cr1 with bits 4-7 of the flags. */
+ mtcrf 0x40, r31
+ mtctr r0
+ /* Load all those argument registers. */
+ /* We have set up a nice stack frame, just load it into registers. */
+ lwz r3, 20+(1*4)(r1)
+ lwz r4, 20+(2*4)(r1)
+ lwz r5, 20+(3*4)(r1)
+ lwz r6, 20+(4*4)(r1)
+ nop
+ lwz r7, 20+(5*4)(r1)
+ lwz r8, 20+(6*4)(r1)
+ lwz r9, 20+(7*4)(r1)
+ lwz r10,20+(8*4)(r1)
+
+L1:
+ /* Load all the FP registers. */
+ bf 6,L2 /* 2f + 0x18 */
+ lfd f1,-16-(13*8)(r28)
+ lfd f2,-16-(12*8)(r28)
+ lfd f3,-16-(11*8)(r28)
+ lfd f4,-16-(10*8)(r28)
+ nop
+ lfd f5,-16-(9*8)(r28)
+ lfd f6,-16-(8*8)(r28)
+ lfd f7,-16-(7*8)(r28)
+ lfd f8,-16-(6*8)(r28)
+ nop
+ lfd f9,-16-(5*8)(r28)
+ lfd f10,-16-(4*8)(r28)
+ lfd f11,-16-(3*8)(r28)
+ lfd f12,-16-(2*8)(r28)
+ nop
+ lfd f13,-16-(1*8)(r28)
+
+L2:
+ /* Make the call. */
+ bctrl
+ lwz r2, 20(r1)
+
+ /* Now, deal with the return value. */
+ mtcrf 0x01, r31
+
+ bt 30, L(done_return_value)
+ bt 29, L(fp_return_value)
+ stw r3, 0(r30)
+ bf 28, L(done_return_value)
+ stw r4, 4(r30)
+
+ /* Fall through... */
+
+L(done_return_value):
+ /* Restore the registers we used and return. */
+ mr r1, r28
+ lwz r0, 8(r28)
+ lwz r28,-16(r1)
+ mtlr r0
+ lwz r29,-12(r1)
+ lwz r30, -8(r1)
+ lwz r31, -4(r1)
+ blr
+
+L(fp_return_value):
+ bf 28, L(float_return_value)
+ stfd f1, 0(r30)
+ b L(done_return_value)
+L(float_return_value):
+ stfs f1, 0(r30)
+ b L(done_return_value)
+#endif
+ .long 0
+ .byte 0,0,0,1,128,4,0,0
+/* END(ffi_call_AIX) */
+
+.csect .text[PR]
+ .align 2
+ .globl ffi_call_DARWIN
+ .globl .ffi_call_DARWIN
+.csect ffi_call_DARWIN[DS]
+ffi_call_DARWIN:
+#ifdef __64BIT__
+ .llong .ffi_call_DARWIN, TOC[tc0], 0
+#else
+ .long .ffi_call_DARWIN, TOC[tc0], 0
+#endif
+ .csect .text[PR]
+.ffi_call_DARWIN:
+ blr
+ .long 0
+ .byte 0,0,0,0,0,0,0,0
+/* END(ffi_call_DARWIN) */
diff --git a/jni/ruby/ext/fiddle/libffi-3.2.1/src/powerpc/aix_closure.S b/jni/ruby/ext/fiddle/libffi-3.2.1/src/powerpc/aix_closure.S
new file mode 100644
index 0000000..aabd3c3
--- /dev/null
+++ b/jni/ruby/ext/fiddle/libffi-3.2.1/src/powerpc/aix_closure.S
@@ -0,0 +1,447 @@
+/* -----------------------------------------------------------------------
+ aix_closure.S - Copyright (c) 2002, 2003, 2009 Free Software Foundation, Inc.
+ based on darwin_closure.S
+
+ PowerPC Assembly glue.
+
+ Permission is hereby granted, free of charge, to any person obtaining
+ a copy of this software and associated documentation files (the
+ ``Software''), to deal in the Software without restriction, including
+ without limitation the rights to use, copy, modify, merge, publish,
+ distribute, sublicense, and/or sell copies of the Software, and to
+ permit persons to whom the Software is furnished to do so, subject to
+ the following conditions:
+
+ The above copyright notice and this permission notice shall be included
+ in all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ OTHER DEALINGS IN THE SOFTWARE.
+ ----------------------------------------------------------------------- */
+
+ .set r0,0
+ .set r1,1
+ .set r2,2
+ .set r3,3
+ .set r4,4
+ .set r5,5
+ .set r6,6
+ .set r7,7
+ .set r8,8
+ .set r9,9
+ .set r10,10
+ .set r11,11
+ .set r12,12
+ .set r13,13
+ .set r14,14
+ .set r15,15
+ .set r16,16
+ .set r17,17
+ .set r18,18
+ .set r19,19
+ .set r20,20
+ .set r21,21
+ .set r22,22
+ .set r23,23
+ .set r24,24
+ .set r25,25
+ .set r26,26
+ .set r27,27
+ .set r28,28
+ .set r29,29
+ .set r30,30
+ .set r31,31
+ .set f0,0
+ .set f1,1
+ .set f2,2
+ .set f3,3
+ .set f4,4
+ .set f5,5
+ .set f6,6
+ .set f7,7
+ .set f8,8
+ .set f9,9
+ .set f10,10
+ .set f11,11
+ .set f12,12
+ .set f13,13
+ .set f14,14
+ .set f15,15
+ .set f16,16
+ .set f17,17
+ .set f18,18
+ .set f19,19
+ .set f20,20
+ .set f21,21
+
+ .extern .ffi_closure_helper_DARWIN
+
+#define LIBFFI_ASM
+#define JUMPTARGET(name) name
+#define L(x) x
+ .file "aix_closure.S"
+ .toc
+LC..60:
+ .tc L..60[TC],L..60
+ .csect .text[PR]
+ .align 2
+
+.csect .text[PR]
+ .align 2
+ .globl ffi_closure_ASM
+ .globl .ffi_closure_ASM
+.csect ffi_closure_ASM[DS]
+ffi_closure_ASM:
+#ifdef __64BIT__
+ .llong .ffi_closure_ASM, TOC[tc0], 0
+ .csect .text[PR]
+.ffi_closure_ASM:
+/* we want to build up an area for the parameters passed */
+/* in registers (both floating point and integer) */
+
+ /* we store gpr 3 to gpr 10 (aligned to 4)
+ in the parents outgoing area */
+ std r3, 48+(0*8)(r1)
+ std r4, 48+(1*8)(r1)
+ std r5, 48+(2*8)(r1)
+ std r6, 48+(3*8)(r1)
+ mflr r0
+
+ std r7, 48+(4*8)(r1)
+ std r8, 48+(5*8)(r1)
+ std r9, 48+(6*8)(r1)
+ std r10, 48+(7*8)(r1)
+ std r0, 16(r1) /* save the return address */
+
+
+ /* 48 Bytes (Linkage Area) */
+ /* 64 Bytes (params) */
+ /* 16 Bytes (result) */
+ /* 104 Bytes (13*8 from FPR) */
+ /* 8 Bytes (alignment) */
+ /* 240 Bytes */
+
+ stdu r1, -240(r1) /* skip over caller save area
+ keep stack aligned to 16 */
+
+ /* next save fpr 1 to fpr 13 (aligned to 8) */
+ stfd f1, 128+(0*8)(r1)
+ stfd f2, 128+(1*8)(r1)
+ stfd f3, 128+(2*8)(r1)
+ stfd f4, 128+(3*8)(r1)
+ stfd f5, 128+(4*8)(r1)
+ stfd f6, 128+(5*8)(r1)
+ stfd f7, 128+(6*8)(r1)
+ stfd f8, 128+(7*8)(r1)
+ stfd f9, 128+(8*8)(r1)
+ stfd f10, 128+(9*8)(r1)
+ stfd f11, 128+(10*8)(r1)
+ stfd f12, 128+(11*8)(r1)
+ stfd f13, 128+(12*8)(r1)
+
+ /* set up registers for the routine that actually does the work */
+ /* get the context pointer from the trampoline */
+ mr r3, r11
+
+ /* now load up the pointer to the result storage */
+ addi r4, r1, 112
+
+ /* now load up the pointer to the saved gpr registers */
+ addi r5, r1, 288
+
+ /* now load up the pointer to the saved fpr registers */
+ addi r6, r1, 128
+
+ /* make the call */
+ bl .ffi_closure_helper_DARWIN
+ nop
+
+ /* now r3 contains the return type */
+ /* so use it to look up in a table */
+ /* so we know how to deal with each type */
+
+ /* look up the proper starting point in table */
+ /* by using return type as offset */
+ lhz r3, 10(r3) /* load type from return type */
+ ld r4, LC..60(2) /* get address of jump table */
+ sldi r3, r3, 4 /* now multiply return type by 16 */
+ ld r0, 240+16(r1) /* load return address */
+ add r3, r3, r4 /* add contents of table to table address */
+ mtctr r3
+ bctr /* jump to it */
+
+/* Each fragment must be exactly 16 bytes long (4 instructions).
+ Align to 16 byte boundary for cache and dispatch efficiency. */
+ .align 4
+
+L..60:
+/* case FFI_TYPE_VOID */
+ mtlr r0
+ addi r1, r1, 240
+ blr
+ nop
+
+/* case FFI_TYPE_INT */
+ lwa r3, 112+4(r1)
+ mtlr r0
+ addi r1, r1, 240
+ blr
+
+/* case FFI_TYPE_FLOAT */
+ lfs f1, 112+0(r1)
+ mtlr r0
+ addi r1, r1, 240
+ blr
+
+/* case FFI_TYPE_DOUBLE */
+ lfd f1, 112+0(r1)
+ mtlr r0
+ addi r1, r1, 240
+ blr
+
+/* case FFI_TYPE_LONGDOUBLE */
+ lfd f1, 112+0(r1)
+ mtlr r0
+ lfd f2, 112+8(r1)
+ b L..finish
+
+/* case FFI_TYPE_UINT8 */
+ lbz r3, 112+7(r1)
+ mtlr r0
+ addi r1, r1, 240
+ blr
+
+/* case FFI_TYPE_SINT8 */
+ lbz r3, 112+7(r1)
+ mtlr r0
+ extsb r3, r3
+ b L..finish
+
+/* case FFI_TYPE_UINT16 */
+ lhz r3, 112+6(r1)
+ mtlr r0
+L..finish:
+ addi r1, r1, 240
+ blr
+
+/* case FFI_TYPE_SINT16 */
+ lha r3, 112+6(r1)
+ mtlr r0
+ addi r1, r1, 240
+ blr
+
+/* case FFI_TYPE_UINT32 */
+ lwz r3, 112+4(r1)
+ mtlr r0
+ addi r1, r1, 240
+ blr
+
+/* case FFI_TYPE_SINT32 */
+ lwa r3, 112+4(r1)
+ mtlr r0
+ addi r1, r1, 240
+ blr
+
+/* case FFI_TYPE_UINT64 */
+ ld r3, 112+0(r1)
+ mtlr r0
+ addi r1, r1, 240
+ blr
+
+/* case FFI_TYPE_SINT64 */
+ ld r3, 112+0(r1)
+ mtlr r0
+ addi r1, r1, 240
+ blr
+
+/* case FFI_TYPE_STRUCT */
+ mtlr r0
+ addi r1, r1, 240
+ blr
+ nop
+
+/* case FFI_TYPE_POINTER */
+ ld r3, 112+0(r1)
+ mtlr r0
+ addi r1, r1, 240
+ blr
+
+#else /* ! __64BIT__ */
+
+ .long .ffi_closure_ASM, TOC[tc0], 0
+ .csect .text[PR]
+.ffi_closure_ASM:
+/* we want to build up an area for the parameters passed */
+/* in registers (both floating point and integer) */
+
+ /* we store gpr 3 to gpr 10 (aligned to 4)
+ in the parents outgoing area */
+ stw r3, 24+(0*4)(r1)
+ stw r4, 24+(1*4)(r1)
+ stw r5, 24+(2*4)(r1)
+ stw r6, 24+(3*4)(r1)
+ mflr r0
+
+ stw r7, 24+(4*4)(r1)
+ stw r8, 24+(5*4)(r1)
+ stw r9, 24+(6*4)(r1)
+ stw r10, 24+(7*4)(r1)
+ stw r0, 8(r1)
+
+ /* 24 Bytes (Linkage Area) */
+ /* 32 Bytes (params) */
+ /* 16 Bytes (result) */
+ /* 104 Bytes (13*8 from FPR) */
+ /* 176 Bytes */
+
+ stwu r1, -176(r1) /* skip over caller save area
+ keep stack aligned to 16 */
+
+ /* next save fpr 1 to fpr 13 (aligned to 8) */
+ stfd f1, 72+(0*8)(r1)
+ stfd f2, 72+(1*8)(r1)
+ stfd f3, 72+(2*8)(r1)
+ stfd f4, 72+(3*8)(r1)
+ stfd f5, 72+(4*8)(r1)
+ stfd f6, 72+(5*8)(r1)
+ stfd f7, 72+(6*8)(r1)
+ stfd f8, 72+(7*8)(r1)
+ stfd f9, 72+(8*8)(r1)
+ stfd f10, 72+(9*8)(r1)
+ stfd f11, 72+(10*8)(r1)
+ stfd f12, 72+(11*8)(r1)
+ stfd f13, 72+(12*8)(r1)
+
+ /* set up registers for the routine that actually does the work */
+ /* get the context pointer from the trampoline */
+ mr r3, r11
+
+ /* now load up the pointer to the result storage */
+ addi r4, r1, 56
+
+ /* now load up the pointer to the saved gpr registers */
+ addi r5, r1, 200
+
+ /* now load up the pointer to the saved fpr registers */
+ addi r6, r1, 72
+
+ /* make the call */
+ bl .ffi_closure_helper_DARWIN
+ nop
+
+ /* now r3 contains the return type */
+ /* so use it to look up in a table */
+ /* so we know how to deal with each type */
+
+ /* look up the proper starting point in table */
+ /* by using return type as offset */
+ lhz r3, 6(r3) /* load type from return type */
+ lwz r4, LC..60(2) /* get address of jump table */
+ slwi r3, r3, 4 /* now multiply return type by 16 */
+ lwz r0, 176+8(r1) /* load return address */
+ add r3, r3, r4 /* add contents of table to table address */
+ mtctr r3
+ bctr /* jump to it */
+
+/* Each fragment must be exactly 16 bytes long (4 instructions).
+ Align to 16 byte boundary for cache and dispatch efficiency. */
+ .align 4
+
+L..60:
+/* case FFI_TYPE_VOID */
+ mtlr r0
+ addi r1, r1, 176
+ blr
+ nop
+
+/* case FFI_TYPE_INT */
+ lwz r3, 56+0(r1)
+ mtlr r0
+ addi r1, r1, 176
+ blr
+
+/* case FFI_TYPE_FLOAT */
+ lfs f1, 56+0(r1)
+ mtlr r0
+ addi r1, r1, 176
+ blr
+
+/* case FFI_TYPE_DOUBLE */
+ lfd f1, 56+0(r1)
+ mtlr r0
+ addi r1, r1, 176
+ blr
+
+/* case FFI_TYPE_LONGDOUBLE */
+ lfd f1, 56+0(r1)
+ mtlr r0
+ lfd f2, 56+8(r1)
+ b L..finish
+
+/* case FFI_TYPE_UINT8 */
+ lbz r3, 56+3(r1)
+ mtlr r0
+ addi r1, r1, 176
+ blr
+
+/* case FFI_TYPE_SINT8 */
+ lbz r3, 56+3(r1)
+ mtlr r0
+ extsb r3, r3
+ b L..finish
+
+/* case FFI_TYPE_UINT16 */
+ lhz r3, 56+2(r1)
+ mtlr r0
+ addi r1, r1, 176
+ blr
+
+/* case FFI_TYPE_SINT16 */
+ lha r3, 56+2(r1)
+ mtlr r0
+ addi r1, r1, 176
+ blr
+
+/* case FFI_TYPE_UINT32 */
+ lwz r3, 56+0(r1)
+ mtlr r0
+ addi r1, r1, 176
+ blr
+
+/* case FFI_TYPE_SINT32 */
+ lwz r3, 56+0(r1)
+ mtlr r0
+ addi r1, r1, 176
+ blr
+
+/* case FFI_TYPE_UINT64 */
+ lwz r3, 56+0(r1)
+ mtlr r0
+ lwz r4, 56+4(r1)
+ b L..finish
+
+/* case FFI_TYPE_SINT64 */
+ lwz r3, 56+0(r1)
+ mtlr r0
+ lwz r4, 56+4(r1)
+ b L..finish
+
+/* case FFI_TYPE_STRUCT */
+ mtlr r0
+ addi r1, r1, 176
+ blr
+ nop
+
+/* case FFI_TYPE_POINTER */
+ lwz r3, 56+0(r1)
+ mtlr r0
+L..finish:
+ addi r1, r1, 176
+ blr
+#endif
+/* END(ffi_closure_ASM) */
diff --git a/jni/ruby/ext/fiddle/libffi-3.2.1/src/powerpc/asm.h b/jni/ruby/ext/fiddle/libffi-3.2.1/src/powerpc/asm.h
new file mode 100644
index 0000000..994f62d
--- /dev/null
+++ b/jni/ruby/ext/fiddle/libffi-3.2.1/src/powerpc/asm.h
@@ -0,0 +1,125 @@
+/* -----------------------------------------------------------------------
+ asm.h - Copyright (c) 1998 Geoffrey Keating
+
+ PowerPC Assembly glue.
+
+ Permission is hereby granted, free of charge, to any person obtaining
+ a copy of this software and associated documentation files (the
+ ``Software''), to deal in the Software without restriction, including
+ without limitation the rights to use, copy, modify, merge, publish,
+ distribute, sublicense, and/or sell copies of the Software, and to
+ permit persons to whom the Software is furnished to do so, subject to
+ the following conditions:
+
+ The above copyright notice and this permission notice shall be included
+ in all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ OTHER DEALINGS IN THE SOFTWARE.
+ ----------------------------------------------------------------------- */
+
+#define ASM_GLOBAL_DIRECTIVE .globl
+
+
+#define C_SYMBOL_NAME(name) name
+/* Macro for a label. */
+#ifdef __STDC__
+#define C_LABEL(name) name##:
+#else
+#define C_LABEL(name) name/**/:
+#endif
+
+/* This seems to always be the case on PPC. */
+#define ALIGNARG(log2) log2
+/* For ELF we need the `.type' directive to make shared libs work right. */
+#define ASM_TYPE_DIRECTIVE(name,typearg) .type name,typearg;
+#define ASM_SIZE_DIRECTIVE(name) .size name,.-name
+
+/* If compiled for profiling, call `_mcount' at the start of each function. */
+#ifdef PROF
+/* The mcount code relies on the return address being on the stack
+ to locate our caller and so it can restore it; so store one just
+ for its benefit. */
+#ifdef PIC
+#define CALL_MCOUNT \
+ .pushsection; \
+ .section ".data"; \
+ .align ALIGNARG(2); \
+0:.long 0; \
+ .previous; \
+ mflr %r0; \
+ stw %r0,4(%r1); \
+ bl _GLOBAL_OFFSET_TABLE_@local-4; \
+ mflr %r11; \
+ lwz %r0,0b@got(%r11); \
+ bl JUMPTARGET(_mcount);
+#else /* PIC */
+#define CALL_MCOUNT \
+ .section ".data"; \
+ .align ALIGNARG(2); \
+0:.long 0; \
+ .previous; \
+ mflr %r0; \
+ lis %r11,0b@ha; \
+ stw %r0,4(%r1); \
+ addi %r0,%r11,0b@l; \
+ bl JUMPTARGET(_mcount);
+#endif /* PIC */
+#else /* PROF */
+#define CALL_MCOUNT /* Do nothing. */
+#endif /* PROF */
+
+#define ENTRY(name) \
+ ASM_GLOBAL_DIRECTIVE C_SYMBOL_NAME(name); \
+ ASM_TYPE_DIRECTIVE (C_SYMBOL_NAME(name),@function) \
+ .align ALIGNARG(2); \
+ C_LABEL(name) \
+ CALL_MCOUNT
+
+#define EALIGN_W_0 /* No words to insert. */
+#define EALIGN_W_1 nop
+#define EALIGN_W_2 nop;nop
+#define EALIGN_W_3 nop;nop;nop
+#define EALIGN_W_4 EALIGN_W_3;nop
+#define EALIGN_W_5 EALIGN_W_4;nop
+#define EALIGN_W_6 EALIGN_W_5;nop
+#define EALIGN_W_7 EALIGN_W_6;nop
+
+/* EALIGN is like ENTRY, but does alignment to 'words'*4 bytes
+ past a 2^align boundary. */
+#ifdef PROF
+#define EALIGN(name, alignt, words) \
+ ASM_GLOBAL_DIRECTIVE C_SYMBOL_NAME(name); \
+ ASM_TYPE_DIRECTIVE (C_SYMBOL_NAME(name),@function) \
+ .align ALIGNARG(2); \
+ C_LABEL(name) \
+ CALL_MCOUNT \
+ b 0f; \
+ .align ALIGNARG(alignt); \
+ EALIGN_W_##words; \
+ 0:
+#else /* PROF */
+#define EALIGN(name, alignt, words) \
+ ASM_GLOBAL_DIRECTIVE C_SYMBOL_NAME(name); \
+ ASM_TYPE_DIRECTIVE (C_SYMBOL_NAME(name),@function) \
+ .align ALIGNARG(alignt); \
+ EALIGN_W_##words; \
+ C_LABEL(name)
+#endif
+
+#define END(name) \
+ ASM_SIZE_DIRECTIVE(name)
+
+#ifdef PIC
+#define JUMPTARGET(name) name##@plt
+#else
+#define JUMPTARGET(name) name
+#endif
+
+/* Local labels stripped out by the linker. */
+#define L(x) .L##x
diff --git a/jni/ruby/ext/fiddle/libffi-3.2.1/src/powerpc/darwin.S b/jni/ruby/ext/fiddle/libffi-3.2.1/src/powerpc/darwin.S
new file mode 100644
index 0000000..066eb82
--- /dev/null
+++ b/jni/ruby/ext/fiddle/libffi-3.2.1/src/powerpc/darwin.S
@@ -0,0 +1,378 @@
+/* -----------------------------------------------------------------------
+ darwin.S - Copyright (c) 2000 John Hornkvist
+ Copyright (c) 2004, 2010 Free Software Foundation, Inc.
+
+ PowerPC Assembly glue.
+
+ Permission is hereby granted, free of charge, to any person obtaining
+ a copy of this software and associated documentation files (the
+ ``Software''), to deal in the Software without restriction, including
+ without limitation the rights to use, copy, modify, merge, publish,
+ distribute, sublicense, and/or sell copies of the Software, and to
+ permit persons to whom the Software is furnished to do so, subject to
+ the following conditions:
+
+ The above copyright notice and this permission notice shall be included
+ in all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ OTHER DEALINGS IN THE SOFTWARE.
+ ----------------------------------------------------------------------- */
+
+#define LIBFFI_ASM
+#if defined(__ppc64__)
+#define MODE_CHOICE(x, y) y
+#else
+#define MODE_CHOICE(x, y) x
+#endif
+
+#define machine_choice MODE_CHOICE(ppc7400,ppc64)
+
+; Define some pseudo-opcodes for size-independent load & store of GPRs ...
+#define lgu MODE_CHOICE(lwzu, ldu)
+#define lg MODE_CHOICE(lwz,ld)
+#define sg MODE_CHOICE(stw,std)
+#define sgu MODE_CHOICE(stwu,stdu)
+#define sgux MODE_CHOICE(stwux,stdux)
+
+; ... and the size of GPRs and their storage indicator.
+#define GPR_BYTES MODE_CHOICE(4,8)
+#define LOG2_GPR_BYTES MODE_CHOICE(2,3) /* log2(GPR_BYTES) */
+#define g_long MODE_CHOICE(long, quad) /* usage is ".g_long" */
+
+; From the ABI doc: "Mac OS X ABI Function Call Guide" Version 2009-02-04.
+#define LINKAGE_SIZE MODE_CHOICE(24,48)
+#define PARAM_AREA MODE_CHOICE(32,64)
+#define SAVED_LR_OFFSET MODE_CHOICE(8,16) /* save position for lr */
+
+/* If there is any FP stuff we make space for all of the regs. */
+#define SAVED_FPR_COUNT 13
+#define FPR_SIZE 8
+#define RESULT_BYTES 16
+
+/* This should be kept in step with the same value in ffi_darwin.c. */
+#define ASM_NEEDS_REGISTERS 4
+#define SAVE_REGS_SIZE (ASM_NEEDS_REGISTERS * GPR_BYTES)
+
+#include <fficonfig.h>
+#include <ffi.h>
+
+#define JUMPTARGET(name) name
+#define L(x) x
+
+ .text
+ .align 2
+ .globl _ffi_prep_args
+
+ .align 2
+ .globl _ffi_call_DARWIN
+
+ /* We arrive here with:
+ r3 = ptr to extended cif.
+ r4 = -bytes.
+ r5 = cif flags.
+ r6 = ptr to return value.
+ r7 = fn pointer (user func).
+ r8 = fn pointer (ffi_prep_args).
+ r9 = ffi_type* for the ret val. */
+
+_ffi_call_DARWIN:
+Lstartcode:
+ mr r12,r8 /* We only need r12 until the call,
+ so it does not have to be saved. */
+LFB1:
+ /* Save the old stack pointer as AP. */
+ mr r8,r1
+LCFI0:
+
+ /* Save the retval type in parents frame. */
+ sg r9,(LINKAGE_SIZE+6*GPR_BYTES)(r8)
+
+ /* Allocate the stack space we need. */
+ sgux r1,r1,r4
+
+ /* Save registers we use. */
+ mflr r9
+ sg r9,SAVED_LR_OFFSET(r8)
+
+ sg r28,-(4 * GPR_BYTES)(r8)
+ sg r29,-(3 * GPR_BYTES)(r8)
+ sg r30,-(2 * GPR_BYTES)(r8)
+ sg r31,-( GPR_BYTES)(r8)
+
+#if !defined(POWERPC_DARWIN)
+ /* The TOC slot is reserved in the Darwin ABI and r2 is volatile. */
+ sg r2,(5 * GPR_BYTES)(r1)
+#endif
+
+LCFI1:
+
+ /* Save arguments over call. */
+ mr r31,r5 /* flags, */
+ mr r30,r6 /* rvalue, */
+ mr r29,r7 /* function address, */
+ mr r28,r8 /* our AP. */
+LCFI2:
+ /* Call ffi_prep_args. r3 = extended cif, r4 = stack ptr copy. */
+ mr r4,r1
+ li r9,0
+
+ mtctr r12 /* r12 holds address of _ffi_prep_args. */
+ bctrl
+
+#if !defined(POWERPC_DARWIN)
+ /* The TOC slot is reserved in the Darwin ABI and r2 is volatile. */
+ lg r2,(5 * GPR_BYTES)(r1)
+#endif
+ /* Now do the call.
+ Set up cr1 with bits 4-7 of the flags. */
+ mtcrf 0x40,r31
+ /* Get the address to call into CTR. */
+ mtctr r29
+ /* Load all those argument registers.
+ We have set up a nice stack frame, just load it into registers. */
+ lg r3, (LINKAGE_SIZE )(r1)
+ lg r4, (LINKAGE_SIZE + GPR_BYTES)(r1)
+ lg r5, (LINKAGE_SIZE + 2 * GPR_BYTES)(r1)
+ lg r6, (LINKAGE_SIZE + 3 * GPR_BYTES)(r1)
+ nop
+ lg r7, (LINKAGE_SIZE + 4 * GPR_BYTES)(r1)
+ lg r8, (LINKAGE_SIZE + 5 * GPR_BYTES)(r1)
+ lg r9, (LINKAGE_SIZE + 6 * GPR_BYTES)(r1)
+ lg r10,(LINKAGE_SIZE + 7 * GPR_BYTES)(r1)
+
+L1:
+ /* ... Load all the FP registers. */
+ bf 6,L2 /* No floats to load. */
+ lfd f1, -SAVE_REGS_SIZE-(13*FPR_SIZE)(r28)
+ lfd f2, -SAVE_REGS_SIZE-(12*FPR_SIZE)(r28)
+ lfd f3, -SAVE_REGS_SIZE-(11*FPR_SIZE)(r28)
+ lfd f4, -SAVE_REGS_SIZE-(10*FPR_SIZE)(r28)
+ nop
+ lfd f5, -SAVE_REGS_SIZE-( 9*FPR_SIZE)(r28)
+ lfd f6, -SAVE_REGS_SIZE-( 8*FPR_SIZE)(r28)
+ lfd f7, -SAVE_REGS_SIZE-( 7*FPR_SIZE)(r28)
+ lfd f8, -SAVE_REGS_SIZE-( 6*FPR_SIZE)(r28)
+ nop
+ lfd f9, -SAVE_REGS_SIZE-( 5*FPR_SIZE)(r28)
+ lfd f10,-SAVE_REGS_SIZE-( 4*FPR_SIZE)(r28)
+ lfd f11,-SAVE_REGS_SIZE-( 3*FPR_SIZE)(r28)
+ lfd f12,-SAVE_REGS_SIZE-( 2*FPR_SIZE)(r28)
+ nop
+ lfd f13,-SAVE_REGS_SIZE-( 1*FPR_SIZE)(r28)
+
+L2:
+ mr r12,r29 /* Put the target address in r12 as specified. */
+ mtctr r12
+ nop
+ nop
+
+ /* Make the call. */
+ bctrl
+
+ /* Now, deal with the return value. */
+
+ /* m64 structure returns can occupy the same set of registers as
+ would be used to pass such a structure as arg0 - so take care
+ not to step on any possibly hot regs. */
+
+ /* Get the flags.. */
+ mtcrf 0x03,r31 ; we need c6 & cr7 now.
+ ; FLAG_RETURNS_NOTHING also covers struct ret-by-ref.
+ bt 30,L(done_return_value) ; FLAG_RETURNS_NOTHING
+ bf 27,L(scalar_return_value) ; not FLAG_RETURNS_STRUCT
+
+ /* OK, so we have a struct. */
+#if defined(__ppc64__)
+ bt 31,L(maybe_return_128) ; FLAG_RETURNS_128BITS, special case
+
+ /* OK, we have to map the return back to a mem struct.
+ We are about to trample the parents param area, so recover the
+ return type. r29 is free, since the call is done. */
+ lg r29,(LINKAGE_SIZE + 6 * GPR_BYTES)(r28)
+
+ sg r3, (LINKAGE_SIZE )(r28)
+ sg r4, (LINKAGE_SIZE + GPR_BYTES)(r28)
+ sg r5, (LINKAGE_SIZE + 2 * GPR_BYTES)(r28)
+ sg r6, (LINKAGE_SIZE + 3 * GPR_BYTES)(r28)
+ nop
+ sg r7, (LINKAGE_SIZE + 4 * GPR_BYTES)(r28)
+ sg r8, (LINKAGE_SIZE + 5 * GPR_BYTES)(r28)
+ sg r9, (LINKAGE_SIZE + 6 * GPR_BYTES)(r28)
+ sg r10,(LINKAGE_SIZE + 7 * GPR_BYTES)(r28)
+ /* OK, so do the block move - we trust that memcpy will not trample
+ the fprs... */
+ mr r3,r30 ; dest
+ addi r4,r28,LINKAGE_SIZE ; source
+ /* The size is a size_t, should be long. */
+ lg r5,0(r29)
+ /* Figure out small structs */
+ cmpi 0,r5,4
+ bgt L3 ; 1, 2 and 4 bytes have special rules.
+ cmpi 0,r5,3
+ beq L3 ; not 3
+ addi r4,r4,8
+ subf r4,r5,r4
+L3:
+ bl _memcpy
+
+ /* ... do we need the FP registers? - recover the flags.. */
+ mtcrf 0x03,r31 ; we need c6 & cr7 now.
+ bf 29,L(done_return_value) /* No floats in the struct. */
+ stfd f1, -SAVE_REGS_SIZE-(13*FPR_SIZE)(r28)
+ stfd f2, -SAVE_REGS_SIZE-(12*FPR_SIZE)(r28)
+ stfd f3, -SAVE_REGS_SIZE-(11*FPR_SIZE)(r28)
+ stfd f4, -SAVE_REGS_SIZE-(10*FPR_SIZE)(r28)
+ nop
+ stfd f5, -SAVE_REGS_SIZE-( 9*FPR_SIZE)(r28)
+ stfd f6, -SAVE_REGS_SIZE-( 8*FPR_SIZE)(r28)
+ stfd f7, -SAVE_REGS_SIZE-( 7*FPR_SIZE)(r28)
+ stfd f8, -SAVE_REGS_SIZE-( 6*FPR_SIZE)(r28)
+ nop
+ stfd f9, -SAVE_REGS_SIZE-( 5*FPR_SIZE)(r28)
+ stfd f10,-SAVE_REGS_SIZE-( 4*FPR_SIZE)(r28)
+ stfd f11,-SAVE_REGS_SIZE-( 3*FPR_SIZE)(r28)
+ stfd f12,-SAVE_REGS_SIZE-( 2*FPR_SIZE)(r28)
+ nop
+ stfd f13,-SAVE_REGS_SIZE-( 1*FPR_SIZE)(r28)
+
+ mr r3,r29 ; ffi_type *
+ mr r4,r30 ; dest
+ addi r5,r28,-SAVE_REGS_SIZE-(13*FPR_SIZE) ; fprs
+ xor r6,r6,r6
+ sg r6,(LINKAGE_SIZE + 7 * GPR_BYTES)(r28)
+ addi r6,r28,(LINKAGE_SIZE + 7 * GPR_BYTES) ; point to a zeroed counter.
+ bl _darwin64_struct_floats_to_mem
+
+ b L(done_return_value)
+#else
+ stw r3,0(r30) ; m32 the only struct return in reg is 4 bytes.
+#endif
+ b L(done_return_value)
+
+L(fp_return_value):
+ /* Do we have long double to store? */
+ bf 31,L(fd_return_value) ; FLAG_RETURNS_128BITS
+ stfd f1,0(r30)
+ stfd f2,FPR_SIZE(r30)
+ b L(done_return_value)
+
+L(fd_return_value):
+ /* Do we have double to store? */
+ bf 28,L(float_return_value)
+ stfd f1,0(r30)
+ b L(done_return_value)
+
+L(float_return_value):
+ /* We only have a float to store. */
+ stfs f1,0(r30)
+ b L(done_return_value)
+
+L(scalar_return_value):
+ bt 29,L(fp_return_value) ; FLAG_RETURNS_FP
+ ; ffi_arg is defined as unsigned long.
+ sg r3,0(r30) ; Save the reg.
+ bf 28,L(done_return_value) ; not FLAG_RETURNS_64BITS
+
+#if defined(__ppc64__)
+L(maybe_return_128):
+ std r3,0(r30)
+ bf 31,L(done_return_value) ; not FLAG_RETURNS_128BITS
+ std r4,8(r30)
+#else
+ stw r4,4(r30)
+#endif
+
+ /* Fall through. */
+ /* We want this at the end to simplify eh epilog computation. */
+
+L(done_return_value):
+ /* Restore the registers we used and return. */
+ lg r29,SAVED_LR_OFFSET(r28)
+ ; epilog
+ lg r31,-(1 * GPR_BYTES)(r28)
+ mtlr r29
+ lg r30,-(2 * GPR_BYTES)(r28)
+ lg r29,-(3 * GPR_BYTES)(r28)
+ lg r28,-(4 * GPR_BYTES)(r28)
+ lg r1,0(r1)
+ blr
+LFE1:
+ .align 1
+/* END(_ffi_call_DARWIN) */
+
+/* Provide a null definition of _ffi_call_AIX. */
+ .text
+ .globl _ffi_call_AIX
+ .align 2
+_ffi_call_AIX:
+ blr
+/* END(_ffi_call_AIX) */
+
+/* EH stuff. */
+
+#define EH_DATA_ALIGN_FACT MODE_CHOICE(0x7c,0x78)
+
+ .section __TEXT,__eh_frame,coalesced,no_toc+strip_static_syms+live_support
+EH_frame1:
+ .set L$set$0,LECIE1-LSCIE1
+ .long L$set$0 ; Length of Common Information Entry
+LSCIE1:
+ .long 0x0 ; CIE Identifier Tag
+ .byte 0x1 ; CIE Version
+ .ascii "zR\0" ; CIE Augmentation
+ .byte 0x1 ; uleb128 0x1; CIE Code Alignment Factor
+ .byte EH_DATA_ALIGN_FACT ; sleb128 -4; CIE Data Alignment Factor
+ .byte 0x41 ; CIE RA Column
+ .byte 0x1 ; uleb128 0x1; Augmentation size
+ .byte 0x10 ; FDE Encoding (pcrel)
+ .byte 0xc ; DW_CFA_def_cfa
+ .byte 0x1 ; uleb128 0x1
+ .byte 0x0 ; uleb128 0x0
+ .align LOG2_GPR_BYTES
+LECIE1:
+
+ .globl _ffi_call_DARWIN.eh
+_ffi_call_DARWIN.eh:
+LSFDE1:
+ .set L$set$1,LEFDE1-LASFDE1
+ .long L$set$1 ; FDE Length
+LASFDE1:
+ .long LASFDE1-EH_frame1 ; FDE CIE offset
+ .g_long Lstartcode-. ; FDE initial location
+ .set L$set$3,LFE1-Lstartcode
+ .g_long L$set$3 ; FDE address range
+ .byte 0x0 ; uleb128 0x0; Augmentation size
+ .byte 0x4 ; DW_CFA_advance_loc4
+ .set L$set$4,LCFI0-Lstartcode
+ .long L$set$4
+ .byte 0xd ; DW_CFA_def_cfa_register
+ .byte 0x08 ; uleb128 0x08
+ .byte 0x4 ; DW_CFA_advance_loc4
+ .set L$set$5,LCFI1-LCFI0
+ .long L$set$5
+ .byte 0x11 ; DW_CFA_offset_extended_sf
+ .byte 0x41 ; uleb128 0x41
+ .byte 0x7e ; sleb128 -2
+ .byte 0x9f ; DW_CFA_offset, column 0x1f
+ .byte 0x1 ; uleb128 0x1
+ .byte 0x9e ; DW_CFA_offset, column 0x1e
+ .byte 0x2 ; uleb128 0x2
+ .byte 0x9d ; DW_CFA_offset, column 0x1d
+ .byte 0x3 ; uleb128 0x3
+ .byte 0x9c ; DW_CFA_offset, column 0x1c
+ .byte 0x4 ; uleb128 0x4
+ .byte 0x4 ; DW_CFA_advance_loc4
+ .set L$set$6,LCFI2-LCFI1
+ .long L$set$6
+ .byte 0xd ; DW_CFA_def_cfa_register
+ .byte 0x1c ; uleb128 0x1c
+ .align LOG2_GPR_BYTES
+LEFDE1:
+ .align 1
+
diff --git a/jni/ruby/ext/fiddle/libffi-3.2.1/src/powerpc/darwin_closure.S b/jni/ruby/ext/fiddle/libffi-3.2.1/src/powerpc/darwin_closure.S
new file mode 100644
index 0000000..c7734d4
--- /dev/null
+++ b/jni/ruby/ext/fiddle/libffi-3.2.1/src/powerpc/darwin_closure.S
@@ -0,0 +1,571 @@
+/* -----------------------------------------------------------------------
+ darwin_closure.S - Copyright (c) 2002, 2003, 2004, 2010,
+ Free Software Foundation, Inc.
+ based on ppc_closure.S
+
+ PowerPC Assembly glue.
+
+ Permission is hereby granted, free of charge, to any person obtaining
+ a copy of this software and associated documentation files (the
+ ``Software''), to deal in the Software without restriction, including
+ without limitation the rights to use, copy, modify, merge, publish,
+ distribute, sublicense, and/or sell copies of the Software, and to
+ permit persons to whom the Software is furnished to do so, subject to
+ the following conditions:
+
+ The above copyright notice and this permission notice shall be included
+ in all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ OTHER DEALINGS IN THE SOFTWARE.
+ ----------------------------------------------------------------------- */
+
+#define LIBFFI_ASM
+#define L(x) x
+
+#if defined(__ppc64__)
+#define MODE_CHOICE(x, y) y
+#else
+#define MODE_CHOICE(x, y) x
+#endif
+
+#define machine_choice MODE_CHOICE(ppc7400,ppc64)
+
+; Define some pseudo-opcodes for size-independent load & store of GPRs ...
+#define lgu MODE_CHOICE(lwzu, ldu)
+#define lg MODE_CHOICE(lwz,ld)
+#define sg MODE_CHOICE(stw,std)
+#define sgu MODE_CHOICE(stwu,stdu)
+
+; ... and the size of GPRs and their storage indicator.
+#define GPR_BYTES MODE_CHOICE(4,8)
+#define LOG2_GPR_BYTES MODE_CHOICE(2,3) /* log2(GPR_BYTES) */
+#define g_long MODE_CHOICE(long, quad) /* usage is ".g_long" */
+
+; From the ABI doc: "Mac OS X ABI Function Call Guide" Version 2009-02-04.
+#define LINKAGE_SIZE MODE_CHOICE(24,48)
+#define PARAM_AREA MODE_CHOICE(32,64)
+
+#define SAVED_CR_OFFSET MODE_CHOICE(4,8) /* save position for CR */
+#define SAVED_LR_OFFSET MODE_CHOICE(8,16) /* save position for lr */
+
+/* WARNING: if ffi_type is changed... here be monsters.
+ Offsets of items within the result type. */
+#define FFI_TYPE_TYPE MODE_CHOICE(6,10)
+#define FFI_TYPE_ELEM MODE_CHOICE(8,16)
+
+#define SAVED_FPR_COUNT 13
+#define FPR_SIZE 8
+/* biggest m64 struct ret is 8GPRS + 13FPRS = 168 bytes - rounded to 16bytes = 176. */
+#define RESULT_BYTES MODE_CHOICE(16,176)
+
+; The whole stack frame **MUST** be 16byte-aligned.
+#define SAVE_SIZE (((LINKAGE_SIZE+PARAM_AREA+SAVED_FPR_COUNT*FPR_SIZE+RESULT_BYTES)+15) & -16LL)
+#define PAD_SIZE (SAVE_SIZE-(LINKAGE_SIZE+PARAM_AREA+SAVED_FPR_COUNT*FPR_SIZE+RESULT_BYTES))
+
+#define PARENT_PARM_BASE (SAVE_SIZE+LINKAGE_SIZE)
+#define FP_SAVE_BASE (LINKAGE_SIZE+PARAM_AREA)
+
+#if defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ >= 1050
+; We no longer need the pic symbol stub for Darwin >= 9.
+#define BLCLS_HELP _ffi_closure_helper_DARWIN
+#define STRUCT_RETVALUE_P _darwin64_struct_ret_by_value_p
+#define PASS_STR_FLOATS _darwin64_pass_struct_floats
+#undef WANT_STUB
+#else
+#define BLCLS_HELP L_ffi_closure_helper_DARWIN$stub
+#define STRUCT_RETVALUE_P L_darwin64_struct_ret_by_value_p$stub
+#define PASS_STR_FLOATS L_darwin64_pass_struct_floats$stub
+#define WANT_STUB
+#endif
+
+/* m32/m64
+
+ The stack layout looks like this:
+
+ | Additional params... | | Higher address
+ ~ ~ ~
+ | Parameters (at least 8*4/8=32/64) | | NUM_GPR_ARG_REGISTERS
+ |--------------------------------------------| |
+ | TOC=R2 (AIX) Reserved (Darwin) 4/8 | |
+ |--------------------------------------------| |
+ | Reserved 2*4/8 | |
+ |--------------------------------------------| |
+ | Space for callee`s LR 4/8 | |
+ |--------------------------------------------| |
+ | Saved CR [low word for m64] 4/8 | |
+ |--------------------------------------------| |
+ | Current backchain pointer 4/8 |-/ Parent`s frame.
+ |--------------------------------------------| <+ <<< on entry to
+ | Result Bytes 16/176 | |
+ |--------------------------------------------| |
+ ~ padding to 16-byte alignment ~ ~
+ |--------------------------------------------| |
+ | NUM_FPR_ARG_REGISTERS slots | |
+ | here fp13 .. fp1 13*8 | |
+ |--------------------------------------------| |
+ | R3..R10 8*4/8=32/64 | | NUM_GPR_ARG_REGISTERS
+ |--------------------------------------------| |
+ | TOC=R2 (AIX) Reserved (Darwin) 4/8 | |
+ |--------------------------------------------| | stack |
+ | Reserved [compiler,binder] 2*4/8 | | grows |
+ |--------------------------------------------| | down V
+ | Space for callees LR 4/8 | |
+ |--------------------------------------------| | lower addresses
+ | Saved CR [low word for m64] 4/8 | |
+ |--------------------------------------------| | stack pointer here
+ | Current backchain pointer 4/8 |-/ during
+ |--------------------------------------------| <<< call.
+
+*/
+
+ .file "darwin_closure.S"
+
+ .machine machine_choice
+
+ .text
+ .globl _ffi_closure_ASM
+ .align LOG2_GPR_BYTES
+_ffi_closure_ASM:
+LFB1:
+Lstartcode:
+ mflr r0 /* extract return address */
+ sg r0,SAVED_LR_OFFSET(r1) /* save the return address */
+LCFI0:
+ sgu r1,-SAVE_SIZE(r1) /* skip over caller save area
+ keep stack aligned to 16. */
+LCFI1:
+ /* We want to build up an area for the parameters passed
+ in registers. (both floating point and integer) */
+
+ /* Put gpr 3 to gpr 10 in the parents outgoing area...
+ ... the remainder of any params that overflowed the regs will
+ follow here. */
+ sg r3, (PARENT_PARM_BASE )(r1)
+ sg r4, (PARENT_PARM_BASE + GPR_BYTES )(r1)
+ sg r5, (PARENT_PARM_BASE + GPR_BYTES * 2)(r1)
+ sg r6, (PARENT_PARM_BASE + GPR_BYTES * 3)(r1)
+ sg r7, (PARENT_PARM_BASE + GPR_BYTES * 4)(r1)
+ sg r8, (PARENT_PARM_BASE + GPR_BYTES * 5)(r1)
+ sg r9, (PARENT_PARM_BASE + GPR_BYTES * 6)(r1)
+ sg r10,(PARENT_PARM_BASE + GPR_BYTES * 7)(r1)
+
+ /* We save fpr 1 to fpr 14 in our own save frame. */
+ stfd f1, (FP_SAVE_BASE )(r1)
+ stfd f2, (FP_SAVE_BASE + FPR_SIZE )(r1)
+ stfd f3, (FP_SAVE_BASE + FPR_SIZE * 2 )(r1)
+ stfd f4, (FP_SAVE_BASE + FPR_SIZE * 3 )(r1)
+ stfd f5, (FP_SAVE_BASE + FPR_SIZE * 4 )(r1)
+ stfd f6, (FP_SAVE_BASE + FPR_SIZE * 5 )(r1)
+ stfd f7, (FP_SAVE_BASE + FPR_SIZE * 6 )(r1)
+ stfd f8, (FP_SAVE_BASE + FPR_SIZE * 7 )(r1)
+ stfd f9, (FP_SAVE_BASE + FPR_SIZE * 8 )(r1)
+ stfd f10,(FP_SAVE_BASE + FPR_SIZE * 9 )(r1)
+ stfd f11,(FP_SAVE_BASE + FPR_SIZE * 10)(r1)
+ stfd f12,(FP_SAVE_BASE + FPR_SIZE * 11)(r1)
+ stfd f13,(FP_SAVE_BASE + FPR_SIZE * 12)(r1)
+
+ /* Set up registers for the routine that actually does the work
+ get the context pointer from the trampoline. */
+ mr r3,r11
+
+ /* Now load up the pointer to the result storage. */
+ addi r4,r1,(SAVE_SIZE-RESULT_BYTES)
+
+ /* Now load up the pointer to the saved gpr registers. */
+ addi r5,r1,PARENT_PARM_BASE
+
+ /* Now load up the pointer to the saved fpr registers. */
+ addi r6,r1,FP_SAVE_BASE
+
+ /* Make the call. */
+ bl BLCLS_HELP
+
+ /* r3 contains the rtype pointer... save it since we will need
+ it later. */
+ sg r3,LINKAGE_SIZE(r1) ; ffi_type * result_type
+ lg r0,0(r3) ; size => r0
+ lhz r3,FFI_TYPE_TYPE(r3) ; type => r3
+
+ /* The helper will have intercepted structure returns and inserted
+ the caller`s destination address for structs returned by ref. */
+
+ /* r3 contains the return type so use it to look up in a table
+ so we know how to deal with each type. */
+
+ addi r5,r1,(SAVE_SIZE-RESULT_BYTES) /* Otherwise, our return is here. */
+ bl Lget_ret_type0_addr /* Get pointer to Lret_type0 into LR. */
+ mflr r4 /* Move to r4. */
+ slwi r3,r3,4 /* Now multiply return type by 16. */
+ add r3,r3,r4 /* Add contents of table to table address. */
+ mtctr r3
+ bctr /* Jump to it. */
+LFE1:
+/* Each of the ret_typeX code fragments has to be exactly 16 bytes long
+ (4 instructions). For cache effectiveness we align to a 16 byte boundary
+ first. */
+
+ .align 4
+
+ nop
+ nop
+ nop
+Lget_ret_type0_addr:
+ blrl
+
+/* case FFI_TYPE_VOID */
+Lret_type0:
+ b Lfinish
+ nop
+ nop
+ nop
+
+/* case FFI_TYPE_INT */
+Lret_type1:
+ lg r3,0(r5)
+ b Lfinish
+ nop
+ nop
+
+/* case FFI_TYPE_FLOAT */
+Lret_type2:
+ lfs f1,0(r5)
+ b Lfinish
+ nop
+ nop
+
+/* case FFI_TYPE_DOUBLE */
+Lret_type3:
+ lfd f1,0(r5)
+ b Lfinish
+ nop
+ nop
+
+/* case FFI_TYPE_LONGDOUBLE */
+Lret_type4:
+ lfd f1,0(r5)
+ lfd f2,8(r5)
+ b Lfinish
+ nop
+
+/* case FFI_TYPE_UINT8 */
+Lret_type5:
+#if defined(__ppc64__)
+ lbz r3,7(r5)
+#else
+ lbz r3,3(r5)
+#endif
+ b Lfinish
+ nop
+ nop
+
+/* case FFI_TYPE_SINT8 */
+Lret_type6:
+#if defined(__ppc64__)
+ lbz r3,7(r5)
+#else
+ lbz r3,3(r5)
+#endif
+ extsb r3,r3
+ b Lfinish
+ nop
+
+/* case FFI_TYPE_UINT16 */
+Lret_type7:
+#if defined(__ppc64__)
+ lhz r3,6(r5)
+#else
+ lhz r3,2(r5)
+#endif
+ b Lfinish
+ nop
+ nop
+
+/* case FFI_TYPE_SINT16 */
+Lret_type8:
+#if defined(__ppc64__)
+ lha r3,6(r5)
+#else
+ lha r3,2(r5)
+#endif
+ b Lfinish
+ nop
+ nop
+
+/* case FFI_TYPE_UINT32 */
+Lret_type9:
+#if defined(__ppc64__)
+ lwz r3,4(r5)
+#else
+ lwz r3,0(r5)
+#endif
+ b Lfinish
+ nop
+ nop
+
+/* case FFI_TYPE_SINT32 */
+Lret_type10:
+#if defined(__ppc64__)
+ lwz r3,4(r5)
+#else
+ lwz r3,0(r5)
+#endif
+ b Lfinish
+ nop
+ nop
+
+/* case FFI_TYPE_UINT64 */
+Lret_type11:
+#if defined(__ppc64__)
+ lg r3,0(r5)
+ b Lfinish
+ nop
+#else
+ lwz r3,0(r5)
+ lwz r4,4(r5)
+ b Lfinish
+#endif
+ nop
+
+/* case FFI_TYPE_SINT64 */
+Lret_type12:
+#if defined(__ppc64__)
+ lg r3,0(r5)
+ b Lfinish
+ nop
+#else
+ lwz r3,0(r5)
+ lwz r4,4(r5)
+ b Lfinish
+#endif
+ nop
+
+/* case FFI_TYPE_STRUCT */
+Lret_type13:
+#if defined(__ppc64__)
+ lg r3,0(r5) ; we need at least this...
+ cmpi 0,r0,4
+ bgt Lstructend ; not a special small case
+ b Lsmallstruct ; see if we need more.
+#else
+ cmpi 0,r0,4
+ bgt Lfinish ; not by value
+ lg r3,0(r5)
+ b Lfinish
+#endif
+/* case FFI_TYPE_POINTER */
+Lret_type14:
+ lg r3,0(r5)
+ b Lfinish
+ nop
+ nop
+
+#if defined(__ppc64__)
+Lsmallstruct:
+ beq Lfour ; continuation of Lret13.
+ cmpi 0,r0,3
+ beq Lfinish ; don`t adjust this - can`t be any floats here...
+ srdi r3,r3,48
+ cmpi 0,r0,2
+ beq Lfinish ; .. or here ..
+ srdi r3,r3,8
+ b Lfinish ; .. or here.
+
+Lfour:
+ lg r6,LINKAGE_SIZE(r1) ; get the result type
+ lg r6,FFI_TYPE_ELEM(r6) ; elements array pointer
+ lg r6,0(r6) ; first element
+ lhz r0,FFI_TYPE_TYPE(r6) ; OK go the type
+ cmpi 0,r0,2 ; FFI_TYPE_FLOAT
+ bne Lfourint
+ lfs f1,0(r5) ; just one float in the struct.
+ b Lfinish
+
+Lfourint:
+ srdi r3,r3,32 ; four bytes.
+ b Lfinish
+
+Lstructend:
+ lg r3,LINKAGE_SIZE(r1) ; get the result type
+ bl STRUCT_RETVALUE_P
+ cmpi 0,r3,0
+ beq Lfinish ; nope.
+ /* Recover a pointer to the results. */
+ addi r11,r1,(SAVE_SIZE-RESULT_BYTES)
+ lg r3,0(r11) ; we need at least this...
+ lg r4,8(r11)
+ cmpi 0,r0,16
+ beq Lfinish ; special case 16 bytes we don't consider floats.
+
+ /* OK, frustratingly, the process of saving the struct to mem might have
+ messed with the FPRs, so we have to re-load them :(.
+ We`ll use our FPRs space again - calling:
+ void darwin64_pass_struct_floats (ffi_type *s, char *src,
+ unsigned *nfpr, double **fprs)
+ We`ll temporarily pinch the first two slots of the param area for local
+ vars used by the routine. */
+ xor r6,r6,r6
+ addi r5,r1,PARENT_PARM_BASE ; some space
+ sg r6,0(r5) ; *nfpr zeroed.
+ addi r6,r5,8 ; **fprs
+ addi r3,r1,FP_SAVE_BASE ; pointer to FPRs space
+ sg r3,0(r6)
+ mr r4,r11 ; the struct is here...
+ lg r3,LINKAGE_SIZE(r1) ; ffi_type * result_type.
+ bl PASS_STR_FLOATS ; get struct floats into FPR save space.
+ /* See if we used any floats */
+ lwz r0,(SAVE_SIZE-RESULT_BYTES)(r1)
+ cmpi 0,r0,0
+ beq Lstructints ; nope.
+ /* OK load `em up... */
+ lfd f1, (FP_SAVE_BASE )(r1)
+ lfd f2, (FP_SAVE_BASE + FPR_SIZE )(r1)
+ lfd f3, (FP_SAVE_BASE + FPR_SIZE * 2 )(r1)
+ lfd f4, (FP_SAVE_BASE + FPR_SIZE * 3 )(r1)
+ lfd f5, (FP_SAVE_BASE + FPR_SIZE * 4 )(r1)
+ lfd f6, (FP_SAVE_BASE + FPR_SIZE * 5 )(r1)
+ lfd f7, (FP_SAVE_BASE + FPR_SIZE * 6 )(r1)
+ lfd f8, (FP_SAVE_BASE + FPR_SIZE * 7 )(r1)
+ lfd f9, (FP_SAVE_BASE + FPR_SIZE * 8 )(r1)
+ lfd f10,(FP_SAVE_BASE + FPR_SIZE * 9 )(r1)
+ lfd f11,(FP_SAVE_BASE + FPR_SIZE * 10)(r1)
+ lfd f12,(FP_SAVE_BASE + FPR_SIZE * 11)(r1)
+ lfd f13,(FP_SAVE_BASE + FPR_SIZE * 12)(r1)
+
+ /* point back at our saved struct. */
+Lstructints:
+ addi r11,r1,(SAVE_SIZE-RESULT_BYTES)
+ lg r3,0(r11) ; we end up picking the
+ lg r4,8(r11) ; first two again.
+ lg r5,16(r11)
+ lg r6,24(r11)
+ lg r7,32(r11)
+ lg r8,40(r11)
+ lg r9,48(r11)
+ lg r10,56(r11)
+#endif
+
+/* case done */
+Lfinish:
+ addi r1,r1,SAVE_SIZE /* Restore stack pointer. */
+ lg r0,SAVED_LR_OFFSET(r1) /* Get return address. */
+ mtlr r0 /* Reset link register. */
+ blr
+Lendcode:
+ .align 1
+
+/* END(ffi_closure_ASM) */
+
+/* EH frame stuff. */
+#define EH_DATA_ALIGN_FACT MODE_CHOICE(0x7c,0x78)
+/* 176, 400 */
+#define EH_FRAME_OFFSETA MODE_CHOICE(176,0x90)
+#define EH_FRAME_OFFSETB MODE_CHOICE(1,3)
+
+ .section __TEXT,__eh_frame,coalesced,no_toc+strip_static_syms+live_support
+EH_frame1:
+ .set L$set$0,LECIE1-LSCIE1
+ .long L$set$0 ; Length of Common Information Entry
+LSCIE1:
+ .long 0x0 ; CIE Identifier Tag
+ .byte 0x1 ; CIE Version
+ .ascii "zR\0" ; CIE Augmentation
+ .byte 0x1 ; uleb128 0x1; CIE Code Alignment Factor
+ .byte EH_DATA_ALIGN_FACT ; sleb128 -4; CIE Data Alignment Factor
+ .byte 0x41 ; CIE RA Column
+ .byte 0x1 ; uleb128 0x1; Augmentation size
+ .byte 0x10 ; FDE Encoding (pcrel)
+ .byte 0xc ; DW_CFA_def_cfa
+ .byte 0x1 ; uleb128 0x1
+ .byte 0x0 ; uleb128 0x0
+ .align LOG2_GPR_BYTES
+LECIE1:
+ .globl _ffi_closure_ASM.eh
+_ffi_closure_ASM.eh:
+LSFDE1:
+ .set L$set$1,LEFDE1-LASFDE1
+ .long L$set$1 ; FDE Length
+
+LASFDE1:
+ .long LASFDE1-EH_frame1 ; FDE CIE offset
+ .g_long Lstartcode-. ; FDE initial location
+ .set L$set$3,LFE1-Lstartcode
+ .g_long L$set$3 ; FDE address range
+ .byte 0x0 ; uleb128 0x0; Augmentation size
+ .byte 0x4 ; DW_CFA_advance_loc4
+ .set L$set$3,LCFI1-LCFI0
+ .long L$set$3
+ .byte 0xe ; DW_CFA_def_cfa_offset
+ .byte EH_FRAME_OFFSETA,EH_FRAME_OFFSETB ; uleb128 176,1/190,3
+ .byte 0x4 ; DW_CFA_advance_loc4
+ .set L$set$4,LCFI0-Lstartcode
+ .long L$set$4
+ .byte 0x11 ; DW_CFA_offset_extended_sf
+ .byte 0x41 ; uleb128 0x41
+ .byte 0x7e ; sleb128 -2
+ .align LOG2_GPR_BYTES
+LEFDE1:
+ .align 1
+
+#ifdef WANT_STUB
+ .section __TEXT,__picsymbolstub1,symbol_stubs,pure_instructions,32
+ .align 5
+L_ffi_closure_helper_DARWIN$stub:
+ .indirect_symbol _ffi_closure_helper_DARWIN
+ mflr r0
+ bcl 20,31,"L1$spb"
+"L1$spb":
+ mflr r11
+ addis r11,r11,ha16(L_ffi_closure_helper_DARWIN$lazy_ptr-"L1$spb")
+ mtlr r0
+ lwzu r12,lo16(L_ffi_closure_helper_DARWIN$lazy_ptr-"L1$spb")(r11)
+ mtctr r12
+ bctr
+ .lazy_symbol_pointer
+L_ffi_closure_helper_DARWIN$lazy_ptr:
+ .indirect_symbol _ffi_closure_helper_DARWIN
+ .g_long dyld_stub_binding_helper
+
+#if defined(__ppc64__)
+ .section __TEXT,__picsymbolstub1,symbol_stubs,pure_instructions,32
+ .align 5
+L_darwin64_struct_ret_by_value_p$stub:
+ .indirect_symbol _darwin64_struct_ret_by_value_p
+ mflr r0
+ bcl 20,31,"L2$spb"
+"L2$spb":
+ mflr r11
+ addis r11,r11,ha16(L_darwin64_struct_ret_by_value_p$lazy_ptr-"L2$spb")
+ mtlr r0
+ lwzu r12,lo16(L_darwin64_struct_ret_by_value_p$lazy_ptr-"L2$spb")(r11)
+ mtctr r12
+ bctr
+ .lazy_symbol_pointer
+L_darwin64_struct_ret_by_value_p$lazy_ptr:
+ .indirect_symbol _darwin64_struct_ret_by_value_p
+ .g_long dyld_stub_binding_helper
+
+ .section __TEXT,__picsymbolstub1,symbol_stubs,pure_instructions,32
+ .align 5
+L_darwin64_pass_struct_floats$stub:
+ .indirect_symbol _darwin64_pass_struct_floats
+ mflr r0
+ bcl 20,31,"L3$spb"
+"L3$spb":
+ mflr r11
+ addis r11,r11,ha16(L_darwin64_pass_struct_floats$lazy_ptr-"L3$spb")
+ mtlr r0
+ lwzu r12,lo16(L_darwin64_pass_struct_floats$lazy_ptr-"L3$spb")(r11)
+ mtctr r12
+ bctr
+ .lazy_symbol_pointer
+L_darwin64_pass_struct_floats$lazy_ptr:
+ .indirect_symbol _darwin64_pass_struct_floats
+ .g_long dyld_stub_binding_helper
+# endif
+#endif
diff --git a/jni/ruby/ext/fiddle/libffi-3.2.1/src/powerpc/ffi.c b/jni/ruby/ext/fiddle/libffi-3.2.1/src/powerpc/ffi.c
new file mode 100644
index 0000000..efb441b
--- /dev/null
+++ b/jni/ruby/ext/fiddle/libffi-3.2.1/src/powerpc/ffi.c
@@ -0,0 +1,141 @@
+/* -----------------------------------------------------------------------
+ ffi.c - Copyright (C) 2013 IBM
+ Copyright (C) 2011 Anthony Green
+ Copyright (C) 2011 Kyle Moffett
+ Copyright (C) 2008 Red Hat, Inc
+ Copyright (C) 2007, 2008 Free Software Foundation, Inc
+ Copyright (c) 1998 Geoffrey Keating
+
+ PowerPC Foreign Function Interface
+
+ Permission is hereby granted, free of charge, to any person obtaining
+ a copy of this software and associated documentation files (the
+ ``Software''), to deal in the Software without restriction, including
+ without limitation the rights to use, copy, modify, merge, publish,
+ distribute, sublicense, and/or sell copies of the Software, and to
+ permit persons to whom the Software is furnished to do so, subject to
+ the following conditions:
+
+ The above copyright notice and this permission notice shall be included
+ in all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ OTHER DEALINGS IN THE SOFTWARE.
+ ----------------------------------------------------------------------- */
+
+#include "ffi.h"
+#include "ffi_common.h"
+#include "ffi_powerpc.h"
+
+#if HAVE_LONG_DOUBLE_VARIANT
+/* Adjust ffi_type_longdouble. */
+void FFI_HIDDEN
+ffi_prep_types (ffi_abi abi)
+{
+# if FFI_TYPE_LONGDOUBLE != FFI_TYPE_DOUBLE
+# ifdef POWERPC64
+ ffi_prep_types_linux64 (abi);
+# else
+ ffi_prep_types_sysv (abi);
+# endif
+# endif
+}
+#endif
+
+/* Perform machine dependent cif processing */
+ffi_status FFI_HIDDEN
+ffi_prep_cif_machdep (ffi_cif *cif)
+{
+#ifdef POWERPC64
+ return ffi_prep_cif_linux64 (cif);
+#else
+ return ffi_prep_cif_sysv (cif);
+#endif
+}
+
+ffi_status FFI_HIDDEN
+ffi_prep_cif_machdep_var (ffi_cif *cif,
+ unsigned int nfixedargs MAYBE_UNUSED,
+ unsigned int ntotalargs MAYBE_UNUSED)
+{
+#ifdef POWERPC64
+ return ffi_prep_cif_linux64_var (cif, nfixedargs, ntotalargs);
+#else
+ return ffi_prep_cif_sysv (cif);
+#endif
+}
+
+void
+ffi_call(ffi_cif *cif, void (*fn)(void), void *rvalue, void **avalue)
+{
+ /* The final SYSV ABI says that structures smaller or equal 8 bytes
+ are returned in r3/r4. A draft ABI used by linux instead returns
+ them in memory.
+
+ We bounce-buffer SYSV small struct return values so that sysv.S
+ can write r3 and r4 to memory without worrying about struct size.
+
+ For ELFv2 ABI, use a bounce buffer for homogeneous structs too,
+ for similar reasons. */
+ unsigned long smst_buffer[8];
+ extended_cif ecif;
+
+ ecif.cif = cif;
+ ecif.avalue = avalue;
+
+ ecif.rvalue = rvalue;
+ if ((cif->flags & FLAG_RETURNS_SMST) != 0)
+ ecif.rvalue = smst_buffer;
+ /* Ensure that we have a valid struct return value.
+ FIXME: Isn't this just papering over a user problem? */
+ else if (!rvalue && cif->rtype->type == FFI_TYPE_STRUCT)
+ ecif.rvalue = alloca (cif->rtype->size);
+
+#ifdef POWERPC64
+ ffi_call_LINUX64 (&ecif, -(long) cif->bytes, cif->flags, ecif.rvalue, fn);
+#else
+ ffi_call_SYSV (&ecif, -cif->bytes, cif->flags, ecif.rvalue, fn);
+#endif
+
+ /* Check for a bounce-buffered return value */
+ if (rvalue && ecif.rvalue == smst_buffer)
+ {
+ unsigned int rsize = cif->rtype->size;
+#ifndef __LITTLE_ENDIAN__
+ /* The SYSV ABI returns a structure of up to 4 bytes in size
+ left-padded in r3. */
+# ifndef POWERPC64
+ if (rsize <= 4)
+ memcpy (rvalue, (char *) smst_buffer + 4 - rsize, rsize);
+ else
+# endif
+ /* The SYSV ABI returns a structure of up to 8 bytes in size
+ left-padded in r3/r4, and the ELFv2 ABI similarly returns a
+ structure of up to 8 bytes in size left-padded in r3. */
+ if (rsize <= 8)
+ memcpy (rvalue, (char *) smst_buffer + 8 - rsize, rsize);
+ else
+#endif
+ memcpy (rvalue, smst_buffer, rsize);
+ }
+}
+
+
+ffi_status
+ffi_prep_closure_loc (ffi_closure *closure,
+ ffi_cif *cif,
+ void (*fun) (ffi_cif *, void *, void **, void *),
+ void *user_data,
+ void *codeloc)
+{
+#ifdef POWERPC64
+ return ffi_prep_closure_loc_linux64 (closure, cif, fun, user_data, codeloc);
+#else
+ return ffi_prep_closure_loc_sysv (closure, cif, fun, user_data, codeloc);
+#endif
+}
diff --git a/jni/ruby/ext/fiddle/libffi-3.2.1/src/powerpc/ffi_darwin.c b/jni/ruby/ext/fiddle/libffi-3.2.1/src/powerpc/ffi_darwin.c
new file mode 100644
index 0000000..cf6fb6d
--- /dev/null
+++ b/jni/ruby/ext/fiddle/libffi-3.2.1/src/powerpc/ffi_darwin.c
@@ -0,0 +1,1359 @@
+/* -----------------------------------------------------------------------
+ ffi_darwin.c
+
+ Copyright (C) 1998 Geoffrey Keating
+ Copyright (C) 2001 John Hornkvist
+ Copyright (C) 2002, 2006, 2007, 2009, 2010 Free Software Foundation, Inc.
+
+ FFI support for Darwin and AIX.
+
+ Permission is hereby granted, free of charge, to any person obtaining
+ a copy of this software and associated documentation files (the
+ ``Software''), to deal in the Software without restriction, including
+ without limitation the rights to use, copy, modify, merge, publish,
+ distribute, sublicense, and/or sell copies of the Software, and to
+ permit persons to whom the Software is furnished to do so, subject to
+ the following conditions:
+
+ The above copyright notice and this permission notice shall be included
+ in all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ OTHER DEALINGS IN THE SOFTWARE.
+ ----------------------------------------------------------------------- */
+
+#include <ffi.h>
+#include <ffi_common.h>
+
+#include <stdlib.h>
+
+extern void ffi_closure_ASM (void);
+
+enum {
+ /* The assembly depends on these exact flags.
+ For Darwin64 (when FLAG_RETURNS_STRUCT is set):
+ FLAG_RETURNS_FP indicates that the structure embeds FP data.
+ FLAG_RETURNS_128BITS signals a special struct size that is not
+ expanded for float content. */
+ FLAG_RETURNS_128BITS = 1 << (31-31), /* These go in cr7 */
+ FLAG_RETURNS_NOTHING = 1 << (31-30),
+ FLAG_RETURNS_FP = 1 << (31-29),
+ FLAG_RETURNS_64BITS = 1 << (31-28),
+
+ FLAG_RETURNS_STRUCT = 1 << (31-27), /* This goes in cr6 */
+
+ FLAG_ARG_NEEDS_COPY = 1 << (31- 7),
+ FLAG_FP_ARGUMENTS = 1 << (31- 6), /* cr1.eq; specified by ABI */
+ FLAG_4_GPR_ARGUMENTS = 1 << (31- 5),
+ FLAG_RETVAL_REFERENCE = 1 << (31- 4)
+};
+
+/* About the DARWIN ABI. */
+enum {
+ NUM_GPR_ARG_REGISTERS = 8,
+ NUM_FPR_ARG_REGISTERS = 13,
+ LINKAGE_AREA_GPRS = 6
+};
+
+enum { ASM_NEEDS_REGISTERS = 4 }; /* r28-r31 */
+
+/* ffi_prep_args is called by the assembly routine once stack space
+ has been allocated for the function's arguments.
+
+ m32/m64
+
+ The stack layout we want looks like this:
+
+ | Return address from ffi_call_DARWIN | higher addresses
+ |--------------------------------------------|
+ | Previous backchain pointer 4/8 | stack pointer here
+ |--------------------------------------------|<+ <<< on entry to
+ | ASM_NEEDS_REGISTERS=r28-r31 4*(4/8) | | ffi_call_DARWIN
+ |--------------------------------------------| |
+ | When we have any FP activity... the | |
+ | FPRs occupy NUM_FPR_ARG_REGISTERS slots | |
+ | here fp13 .. fp1 from high to low addr. | |
+ ~ ~ ~
+ | Parameters (at least 8*4/8=32/64) | | NUM_GPR_ARG_REGISTERS
+ |--------------------------------------------| |
+ | TOC=R2 (AIX) Reserved (Darwin) 4/8 | |
+ |--------------------------------------------| | stack |
+ | Reserved 2*4/8 | | grows |
+ |--------------------------------------------| | down V
+ | Space for callee's LR 4/8 | |
+ |--------------------------------------------| | lower addresses
+ | Saved CR [low word for m64] 4/8 | |
+ |--------------------------------------------| | stack pointer here
+ | Current backchain pointer 4/8 |-/ during
+ |--------------------------------------------| <<< ffi_call_DARWIN
+
+ */
+
+#if defined(POWERPC_DARWIN64)
+static void
+darwin64_pass_struct_by_value
+ (ffi_type *, char *, unsigned, unsigned *, double **, unsigned long **);
+#endif
+
+/* This depends on GPR_SIZE = sizeof (unsigned long) */
+
+void
+ffi_prep_args (extended_cif *ecif, unsigned long *const stack)
+{
+ const unsigned bytes = ecif->cif->bytes;
+ const unsigned flags = ecif->cif->flags;
+ const unsigned nargs = ecif->cif->nargs;
+#if !defined(POWERPC_DARWIN64)
+ const ffi_abi abi = ecif->cif->abi;
+#endif
+
+ /* 'stacktop' points at the previous backchain pointer. */
+ unsigned long *const stacktop = stack + (bytes / sizeof(unsigned long));
+
+ /* 'fpr_base' points at the space for fpr1, and grows upwards as
+ we use FPR registers. */
+ double *fpr_base = (double *) (stacktop - ASM_NEEDS_REGISTERS) - NUM_FPR_ARG_REGISTERS;
+ int gp_count = 0, fparg_count = 0;
+
+ /* 'next_arg' grows up as we put parameters in it. */
+ unsigned long *next_arg = stack + LINKAGE_AREA_GPRS; /* 6 reserved positions. */
+
+ int i;
+ double double_tmp;
+ void **p_argv = ecif->avalue;
+ unsigned long gprvalue;
+ ffi_type** ptr = ecif->cif->arg_types;
+#if !defined(POWERPC_DARWIN64)
+ char *dest_cpy;
+#endif
+ unsigned size_al = 0;
+
+ /* Check that everything starts aligned properly. */
+ FFI_ASSERT(((unsigned) (char *) stack & 0xF) == 0);
+ FFI_ASSERT(((unsigned) (char *) stacktop & 0xF) == 0);
+ FFI_ASSERT((bytes & 0xF) == 0);
+
+ /* Deal with return values that are actually pass-by-reference.
+ Rule:
+ Return values are referenced by r3, so r4 is the first parameter. */
+
+ if (flags & FLAG_RETVAL_REFERENCE)
+ *next_arg++ = (unsigned long) (char *) ecif->rvalue;
+
+ /* Now for the arguments. */
+ for (i = nargs; i > 0; i--, ptr++, p_argv++)
+ {
+ switch ((*ptr)->type)
+ {
+ /* If a floating-point parameter appears before all of the general-
+ purpose registers are filled, the corresponding GPRs that match
+ the size of the floating-point parameter are skipped. */
+ case FFI_TYPE_FLOAT:
+ double_tmp = *(float *) *p_argv;
+ if (fparg_count < NUM_FPR_ARG_REGISTERS)
+ *fpr_base++ = double_tmp;
+#if defined(POWERPC_DARWIN)
+ *(float *)next_arg = *(float *) *p_argv;
+#else
+ *(double *)next_arg = double_tmp;
+#endif
+ next_arg++;
+ gp_count++;
+ fparg_count++;
+ FFI_ASSERT(flags & FLAG_FP_ARGUMENTS);
+ break;
+
+ case FFI_TYPE_DOUBLE:
+ double_tmp = *(double *) *p_argv;
+ if (fparg_count < NUM_FPR_ARG_REGISTERS)
+ *fpr_base++ = double_tmp;
+ *(double *)next_arg = double_tmp;
+#ifdef POWERPC64
+ next_arg++;
+ gp_count++;
+#else
+ next_arg += 2;
+ gp_count += 2;
+#endif
+ fparg_count++;
+ FFI_ASSERT(flags & FLAG_FP_ARGUMENTS);
+ break;
+
+#if FFI_TYPE_LONGDOUBLE != FFI_TYPE_DOUBLE
+
+ case FFI_TYPE_LONGDOUBLE:
+# if defined(POWERPC64) && !defined(POWERPC_DARWIN64)
+ /* ??? This will exceed the regs count when the value starts at fp13
+ and it will not put the extra bit on the stack. */
+ if (fparg_count < NUM_FPR_ARG_REGISTERS)
+ *(long double *) fpr_base++ = *(long double *) *p_argv;
+ else
+ *(long double *) next_arg = *(long double *) *p_argv;
+ next_arg += 2;
+ fparg_count += 2;
+# else
+ double_tmp = ((double *) *p_argv)[0];
+ if (fparg_count < NUM_FPR_ARG_REGISTERS)
+ *fpr_base++ = double_tmp;
+ *(double *) next_arg = double_tmp;
+# if defined(POWERPC_DARWIN64)
+ next_arg++;
+ gp_count++;
+# else
+ next_arg += 2;
+ gp_count += 2;
+# endif
+ fparg_count++;
+ double_tmp = ((double *) *p_argv)[1];
+ if (fparg_count < NUM_FPR_ARG_REGISTERS)
+ *fpr_base++ = double_tmp;
+ *(double *) next_arg = double_tmp;
+# if defined(POWERPC_DARWIN64)
+ next_arg++;
+ gp_count++;
+# else
+ next_arg += 2;
+ gp_count += 2;
+# endif
+ fparg_count++;
+# endif
+ FFI_ASSERT(flags & FLAG_FP_ARGUMENTS);
+ break;
+#endif
+ case FFI_TYPE_UINT64:
+ case FFI_TYPE_SINT64:
+#ifdef POWERPC64
+ gprvalue = *(long long *) *p_argv;
+ goto putgpr;
+#else
+ *(long long *) next_arg = *(long long *) *p_argv;
+ next_arg += 2;
+ gp_count += 2;
+#endif
+ break;
+ case FFI_TYPE_POINTER:
+ gprvalue = *(unsigned long *) *p_argv;
+ goto putgpr;
+ case FFI_TYPE_UINT8:
+ gprvalue = *(unsigned char *) *p_argv;
+ goto putgpr;
+ case FFI_TYPE_SINT8:
+ gprvalue = *(signed char *) *p_argv;
+ goto putgpr;
+ case FFI_TYPE_UINT16:
+ gprvalue = *(unsigned short *) *p_argv;
+ goto putgpr;
+ case FFI_TYPE_SINT16:
+ gprvalue = *(signed short *) *p_argv;
+ goto putgpr;
+
+ case FFI_TYPE_STRUCT:
+ size_al = (*ptr)->size;
+#if defined(POWERPC_DARWIN64)
+ next_arg = (unsigned long *)ALIGN((char *)next_arg, (*ptr)->alignment);
+ darwin64_pass_struct_by_value (*ptr, (char *) *p_argv,
+ (unsigned) size_al,
+ (unsigned int *) &fparg_count,
+ &fpr_base, &next_arg);
+#else
+ dest_cpy = (char *) next_arg;
+
+ /* If the first member of the struct is a double, then include enough
+ padding in the struct size to align it to double-word. */
+ if ((*ptr)->elements[0]->type == FFI_TYPE_DOUBLE)
+ size_al = ALIGN((*ptr)->size, 8);
+
+# if defined(POWERPC64)
+ FFI_ASSERT (abi != FFI_DARWIN);
+ memcpy ((char *) dest_cpy, (char *) *p_argv, size_al);
+ next_arg += (size_al + 7) / 8;
+# else
+ /* Structures that match the basic modes (QI 1 byte, HI 2 bytes,
+ SI 4 bytes) are aligned as if they were those modes.
+ Structures with 3 byte in size are padded upwards. */
+ if (size_al < 3 && abi == FFI_DARWIN)
+ dest_cpy += 4 - size_al;
+
+ memcpy((char *) dest_cpy, (char *) *p_argv, size_al);
+ next_arg += (size_al + 3) / 4;
+# endif
+#endif
+ break;
+
+ case FFI_TYPE_INT:
+ case FFI_TYPE_SINT32:
+ gprvalue = *(signed int *) *p_argv;
+ goto putgpr;
+
+ case FFI_TYPE_UINT32:
+ gprvalue = *(unsigned int *) *p_argv;
+ putgpr:
+ *next_arg++ = gprvalue;
+ gp_count++;
+ break;
+ default:
+ break;
+ }
+ }
+
+ /* Check that we didn't overrun the stack... */
+ /* FFI_ASSERT(gpr_base <= stacktop - ASM_NEEDS_REGISTERS);
+ FFI_ASSERT((unsigned *)fpr_base
+ <= stacktop - ASM_NEEDS_REGISTERS - NUM_GPR_ARG_REGISTERS);
+ FFI_ASSERT(flags & FLAG_4_GPR_ARGUMENTS || intarg_count <= 4); */
+}
+
+#if defined(POWERPC_DARWIN64)
+
+/* See if we can put some of the struct into fprs.
+ This should not be called for structures of size 16 bytes, since these are not
+ broken out this way. */
+static void
+darwin64_scan_struct_for_floats (ffi_type *s, unsigned *nfpr)
+{
+ int i;
+
+ FFI_ASSERT (s->type == FFI_TYPE_STRUCT)
+
+ for (i = 0; s->elements[i] != NULL; i++)
+ {
+ ffi_type *p = s->elements[i];
+ switch (p->type)
+ {
+ case FFI_TYPE_STRUCT:
+ darwin64_scan_struct_for_floats (p, nfpr);
+ break;
+ case FFI_TYPE_LONGDOUBLE:
+ (*nfpr) += 2;
+ break;
+ case FFI_TYPE_DOUBLE:
+ case FFI_TYPE_FLOAT:
+ (*nfpr) += 1;
+ break;
+ default:
+ break;
+ }
+ }
+}
+
+static int
+darwin64_struct_size_exceeds_gprs_p (ffi_type *s, char *src, unsigned *nfpr)
+{
+ unsigned struct_offset=0, i;
+
+ for (i = 0; s->elements[i] != NULL; i++)
+ {
+ char *item_base;
+ ffi_type *p = s->elements[i];
+ /* Find the start of this item (0 for the first one). */
+ if (i > 0)
+ struct_offset = ALIGN(struct_offset, p->alignment);
+
+ item_base = src + struct_offset;
+
+ switch (p->type)
+ {
+ case FFI_TYPE_STRUCT:
+ if (darwin64_struct_size_exceeds_gprs_p (p, item_base, nfpr))
+ return 1;
+ break;
+ case FFI_TYPE_LONGDOUBLE:
+ if (*nfpr >= NUM_FPR_ARG_REGISTERS)
+ return 1;
+ (*nfpr) += 1;
+ item_base += 8;
+ /* FALL THROUGH */
+ case FFI_TYPE_DOUBLE:
+ if (*nfpr >= NUM_FPR_ARG_REGISTERS)
+ return 1;
+ (*nfpr) += 1;
+ break;
+ case FFI_TYPE_FLOAT:
+ if (*nfpr >= NUM_FPR_ARG_REGISTERS)
+ return 1;
+ (*nfpr) += 1;
+ break;
+ default:
+ /* If we try and place any item, that is non-float, once we've
+ exceeded the 8 GPR mark, then we can't fit the struct. */
+ if ((unsigned long)item_base >= 8*8)
+ return 1;
+ break;
+ }
+ /* now count the size of what we just used. */
+ struct_offset += p->size;
+ }
+ return 0;
+}
+
+/* Can this struct be returned by value? */
+int
+darwin64_struct_ret_by_value_p (ffi_type *s)
+{
+ unsigned nfp = 0;
+
+ FFI_ASSERT (s && s->type == FFI_TYPE_STRUCT);
+
+ /* The largest structure we can return is 8long + 13 doubles. */
+ if (s->size > 168)
+ return 0;
+
+ /* We can't pass more than 13 floats. */
+ darwin64_scan_struct_for_floats (s, &nfp);
+ if (nfp > 13)
+ return 0;
+
+ /* If there are not too many floats, and the struct is
+ small enough to accommodate in the GPRs, then it must be OK. */
+ if (s->size <= 64)
+ return 1;
+
+ /* Well, we have to look harder. */
+ nfp = 0;
+ if (darwin64_struct_size_exceeds_gprs_p (s, NULL, &nfp))
+ return 0;
+
+ return 1;
+}
+
+void
+darwin64_pass_struct_floats (ffi_type *s, char *src,
+ unsigned *nfpr, double **fprs)
+{
+ int i;
+ double *fpr_base = *fprs;
+ unsigned struct_offset = 0;
+
+ /* We don't assume anything about the alignment of the source. */
+ for (i = 0; s->elements[i] != NULL; i++)
+ {
+ char *item_base;
+ ffi_type *p = s->elements[i];
+ /* Find the start of this item (0 for the first one). */
+ if (i > 0)
+ struct_offset = ALIGN(struct_offset, p->alignment);
+ item_base = src + struct_offset;
+
+ switch (p->type)
+ {
+ case FFI_TYPE_STRUCT:
+ darwin64_pass_struct_floats (p, item_base, nfpr,
+ &fpr_base);
+ break;
+ case FFI_TYPE_LONGDOUBLE:
+ if (*nfpr < NUM_FPR_ARG_REGISTERS)
+ *fpr_base++ = *(double *)item_base;
+ (*nfpr) += 1;
+ item_base += 8;
+ /* FALL THROUGH */
+ case FFI_TYPE_DOUBLE:
+ if (*nfpr < NUM_FPR_ARG_REGISTERS)
+ *fpr_base++ = *(double *)item_base;
+ (*nfpr) += 1;
+ break;
+ case FFI_TYPE_FLOAT:
+ if (*nfpr < NUM_FPR_ARG_REGISTERS)
+ *fpr_base++ = (double) *(float *)item_base;
+ (*nfpr) += 1;
+ break;
+ default:
+ break;
+ }
+ /* now count the size of what we just used. */
+ struct_offset += p->size;
+ }
+ /* Update the scores. */
+ *fprs = fpr_base;
+}
+
+/* Darwin64 special rules.
+ Break out a struct into params and float registers. */
+static void
+darwin64_pass_struct_by_value (ffi_type *s, char *src, unsigned size,
+ unsigned *nfpr, double **fprs, unsigned long **arg)
+{
+ unsigned long *next_arg = *arg;
+ char *dest_cpy = (char *)next_arg;
+
+ FFI_ASSERT (s->type == FFI_TYPE_STRUCT)
+
+ if (!size)
+ return;
+
+ /* First... special cases. */
+ if (size < 3
+ || (size == 4
+ && s->elements[0]
+ && s->elements[0]->type != FFI_TYPE_FLOAT))
+ {
+ /* Must be at least one GPR, padding is unspecified in value,
+ let's make it zero. */
+ *next_arg = 0UL;
+ dest_cpy += 8 - size;
+ memcpy ((char *) dest_cpy, src, size);
+ next_arg++;
+ }
+ else if (size == 16)
+ {
+ memcpy ((char *) dest_cpy, src, size);
+ next_arg += 2;
+ }
+ else
+ {
+ /* now the general case, we consider embedded floats. */
+ memcpy ((char *) dest_cpy, src, size);
+ darwin64_pass_struct_floats (s, src, nfpr, fprs);
+ next_arg += (size+7)/8;
+ }
+
+ *arg = next_arg;
+}
+
+double *
+darwin64_struct_floats_to_mem (ffi_type *s, char *dest, double *fprs, unsigned *nf)
+{
+ int i;
+ unsigned struct_offset = 0;
+
+ /* We don't assume anything about the alignment of the source. */
+ for (i = 0; s->elements[i] != NULL; i++)
+ {
+ char *item_base;
+ ffi_type *p = s->elements[i];
+ /* Find the start of this item (0 for the first one). */
+ if (i > 0)
+ struct_offset = ALIGN(struct_offset, p->alignment);
+ item_base = dest + struct_offset;
+
+ switch (p->type)
+ {
+ case FFI_TYPE_STRUCT:
+ fprs = darwin64_struct_floats_to_mem (p, item_base, fprs, nf);
+ break;
+ case FFI_TYPE_LONGDOUBLE:
+ if (*nf < NUM_FPR_ARG_REGISTERS)
+ {
+ *(double *)item_base = *fprs++ ;
+ (*nf) += 1;
+ }
+ item_base += 8;
+ /* FALL THROUGH */
+ case FFI_TYPE_DOUBLE:
+ if (*nf < NUM_FPR_ARG_REGISTERS)
+ {
+ *(double *)item_base = *fprs++ ;
+ (*nf) += 1;
+ }
+ break;
+ case FFI_TYPE_FLOAT:
+ if (*nf < NUM_FPR_ARG_REGISTERS)
+ {
+ *(float *)item_base = (float) *fprs++ ;
+ (*nf) += 1;
+ }
+ break;
+ default:
+ break;
+ }
+ /* now count the size of what we just used. */
+ struct_offset += p->size;
+ }
+ return fprs;
+}
+
+#endif
+
+/* Adjust the size of S to be correct for Darwin.
+ On Darwin m32, the first field of a structure has natural alignment.
+ On Darwin m64, all fields have natural alignment. */
+
+static void
+darwin_adjust_aggregate_sizes (ffi_type *s)
+{
+ int i;
+
+ if (s->type != FFI_TYPE_STRUCT)
+ return;
+
+ s->size = 0;
+ for (i = 0; s->elements[i] != NULL; i++)
+ {
+ ffi_type *p;
+ int align;
+
+ p = s->elements[i];
+ if (p->type == FFI_TYPE_STRUCT)
+ darwin_adjust_aggregate_sizes (p);
+#if defined(POWERPC_DARWIN64)
+ /* Natural alignment for all items. */
+ align = p->alignment;
+#else
+ /* Natural alignment for the first item... */
+ if (i == 0)
+ align = p->alignment;
+ else if (p->alignment == 16 || p->alignment < 4)
+ /* .. subsequent items with vector or align < 4 have natural align. */
+ align = p->alignment;
+ else
+ /* .. or align is 4. */
+ align = 4;
+#endif
+ /* Pad, if necessary, before adding the current item. */
+ s->size = ALIGN(s->size, align) + p->size;
+ }
+
+ s->size = ALIGN(s->size, s->alignment);
+
+ /* This should not be necessary on m64, but harmless. */
+ if (s->elements[0]->type == FFI_TYPE_UINT64
+ || s->elements[0]->type == FFI_TYPE_SINT64
+ || s->elements[0]->type == FFI_TYPE_DOUBLE
+ || s->elements[0]->alignment == 8)
+ s->alignment = s->alignment > 8 ? s->alignment : 8;
+ /* Do not add additional tail padding. */
+}
+
+/* Adjust the size of S to be correct for AIX.
+ Word-align double unless it is the first member of a structure. */
+
+static void
+aix_adjust_aggregate_sizes (ffi_type *s)
+{
+ int i;
+
+ if (s->type != FFI_TYPE_STRUCT)
+ return;
+
+ s->size = 0;
+ for (i = 0; s->elements[i] != NULL; i++)
+ {
+ ffi_type *p;
+ int align;
+
+ p = s->elements[i];
+ aix_adjust_aggregate_sizes (p);
+ align = p->alignment;
+ if (i != 0 && p->type == FFI_TYPE_DOUBLE)
+ align = 4;
+ s->size = ALIGN(s->size, align) + p->size;
+ }
+
+ s->size = ALIGN(s->size, s->alignment);
+
+ if (s->elements[0]->type == FFI_TYPE_UINT64
+ || s->elements[0]->type == FFI_TYPE_SINT64
+ || s->elements[0]->type == FFI_TYPE_DOUBLE
+ || s->elements[0]->alignment == 8)
+ s->alignment = s->alignment > 8 ? s->alignment : 8;
+ /* Do not add additional tail padding. */
+}
+
+/* Perform machine dependent cif processing. */
+ffi_status
+ffi_prep_cif_machdep (ffi_cif *cif)
+{
+ /* All this is for the DARWIN ABI. */
+ unsigned i;
+ ffi_type **ptr;
+ unsigned bytes;
+ unsigned fparg_count = 0, intarg_count = 0;
+ unsigned flags = 0;
+ unsigned size_al = 0;
+
+ /* All the machine-independent calculation of cif->bytes will be wrong.
+ All the calculation of structure sizes will also be wrong.
+ Redo the calculation for DARWIN. */
+
+ if (cif->abi == FFI_DARWIN)
+ {
+ darwin_adjust_aggregate_sizes (cif->rtype);
+ for (i = 0; i < cif->nargs; i++)
+ darwin_adjust_aggregate_sizes (cif->arg_types[i]);
+ }
+
+ if (cif->abi == FFI_AIX)
+ {
+ aix_adjust_aggregate_sizes (cif->rtype);
+ for (i = 0; i < cif->nargs; i++)
+ aix_adjust_aggregate_sizes (cif->arg_types[i]);
+ }
+
+ /* Space for the frame pointer, callee's LR, CR, etc, and for
+ the asm's temp regs. */
+
+ bytes = (LINKAGE_AREA_GPRS + ASM_NEEDS_REGISTERS) * sizeof(unsigned long);
+
+ /* Return value handling.
+ The rules m32 are as follows:
+ - 32-bit (or less) integer values are returned in gpr3;
+ - structures of size <= 4 bytes also returned in gpr3;
+ - 64-bit integer values [??? and structures between 5 and 8 bytes] are
+ returned in gpr3 and gpr4;
+ - Single/double FP values are returned in fpr1;
+ - Long double FP (if not equivalent to double) values are returned in
+ fpr1 and fpr2;
+ m64:
+ - 64-bit or smaller integral values are returned in GPR3
+ - Single/double FP values are returned in fpr1;
+ - Long double FP values are returned in fpr1 and fpr2;
+ m64 Structures:
+ - If the structure could be accommodated in registers were it to be the
+ first argument to a routine, then it is returned in those registers.
+ m32/m64 structures otherwise:
+ - Larger structures values are allocated space and a pointer is passed
+ as the first argument. */
+ switch (cif->rtype->type)
+ {
+
+#if FFI_TYPE_LONGDOUBLE != FFI_TYPE_DOUBLE
+ case FFI_TYPE_LONGDOUBLE:
+ flags |= FLAG_RETURNS_128BITS;
+ flags |= FLAG_RETURNS_FP;
+ break;
+#endif
+
+ case FFI_TYPE_DOUBLE:
+ flags |= FLAG_RETURNS_64BITS;
+ /* Fall through. */
+ case FFI_TYPE_FLOAT:
+ flags |= FLAG_RETURNS_FP;
+ break;
+
+ case FFI_TYPE_UINT64:
+ case FFI_TYPE_SINT64:
+#ifdef POWERPC64
+ case FFI_TYPE_POINTER:
+#endif
+ flags |= FLAG_RETURNS_64BITS;
+ break;
+
+ case FFI_TYPE_STRUCT:
+#if defined(POWERPC_DARWIN64)
+ {
+ /* Can we fit the struct into regs? */
+ if (darwin64_struct_ret_by_value_p (cif->rtype))
+ {
+ unsigned nfpr = 0;
+ flags |= FLAG_RETURNS_STRUCT;
+ if (cif->rtype->size != 16)
+ darwin64_scan_struct_for_floats (cif->rtype, &nfpr) ;
+ else
+ flags |= FLAG_RETURNS_128BITS;
+ /* Will be 0 for 16byte struct. */
+ if (nfpr)
+ flags |= FLAG_RETURNS_FP;
+ }
+ else /* By ref. */
+ {
+ flags |= FLAG_RETVAL_REFERENCE;
+ flags |= FLAG_RETURNS_NOTHING;
+ intarg_count++;
+ }
+ }
+#elif defined(DARWIN_PPC)
+ if (cif->rtype->size <= 4)
+ flags |= FLAG_RETURNS_STRUCT;
+ else /* else by reference. */
+ {
+ flags |= FLAG_RETVAL_REFERENCE;
+ flags |= FLAG_RETURNS_NOTHING;
+ intarg_count++;
+ }
+#else /* assume we pass by ref. */
+ flags |= FLAG_RETVAL_REFERENCE;
+ flags |= FLAG_RETURNS_NOTHING;
+ intarg_count++;
+#endif
+ break;
+ case FFI_TYPE_VOID:
+ flags |= FLAG_RETURNS_NOTHING;
+ break;
+
+ default:
+ /* Returns 32-bit integer, or similar. Nothing to do here. */
+ break;
+ }
+
+ /* The first NUM_GPR_ARG_REGISTERS words of integer arguments, and the
+ first NUM_FPR_ARG_REGISTERS fp arguments, go in registers; the rest
+ goes on the stack.
+ ??? Structures are passed as a pointer to a copy of the structure.
+ Stuff on the stack needs to keep proper alignment.
+ For m64 the count is effectively of half-GPRs. */
+ for (ptr = cif->arg_types, i = cif->nargs; i > 0; i--, ptr++)
+ {
+ unsigned align_words;
+ switch ((*ptr)->type)
+ {
+ case FFI_TYPE_FLOAT:
+ case FFI_TYPE_DOUBLE:
+ fparg_count++;
+#if !defined(POWERPC_DARWIN64)
+ /* If this FP arg is going on the stack, it must be
+ 8-byte-aligned. */
+ if (fparg_count > NUM_FPR_ARG_REGISTERS
+ && (intarg_count & 0x01) != 0)
+ intarg_count++;
+#endif
+ break;
+
+#if FFI_TYPE_LONGDOUBLE != FFI_TYPE_DOUBLE
+ case FFI_TYPE_LONGDOUBLE:
+ fparg_count += 2;
+ /* If this FP arg is going on the stack, it must be
+ 16-byte-aligned. */
+ if (fparg_count >= NUM_FPR_ARG_REGISTERS)
+#if defined (POWERPC64)
+ intarg_count = ALIGN(intarg_count, 2);
+#else
+ intarg_count = ALIGN(intarg_count, 4);
+#endif
+ break;
+#endif
+
+ case FFI_TYPE_UINT64:
+ case FFI_TYPE_SINT64:
+#if defined(POWERPC64)
+ intarg_count++;
+#else
+ /* 'long long' arguments are passed as two words, but
+ either both words must fit in registers or both go
+ on the stack. If they go on the stack, they must
+ be 8-byte-aligned. */
+ if (intarg_count == NUM_GPR_ARG_REGISTERS-1
+ || (intarg_count >= NUM_GPR_ARG_REGISTERS
+ && (intarg_count & 0x01) != 0))
+ intarg_count++;
+ intarg_count += 2;
+#endif
+ break;
+
+ case FFI_TYPE_STRUCT:
+ size_al = (*ptr)->size;
+#if defined(POWERPC_DARWIN64)
+ align_words = (*ptr)->alignment >> 3;
+ if (align_words)
+ intarg_count = ALIGN(intarg_count, align_words);
+ /* Base size of the struct. */
+ intarg_count += (size_al + 7) / 8;
+ /* If 16 bytes then don't worry about floats. */
+ if (size_al != 16)
+ /* Scan through for floats to be placed in regs. */
+ darwin64_scan_struct_for_floats (*ptr, &fparg_count) ;
+#else
+ align_words = (*ptr)->alignment >> 2;
+ if (align_words)
+ intarg_count = ALIGN(intarg_count, align_words);
+ /* If the first member of the struct is a double, then align
+ the struct to double-word.
+ if ((*ptr)->elements[0]->type == FFI_TYPE_DOUBLE)
+ size_al = ALIGN((*ptr)->size, 8); */
+# ifdef POWERPC64
+ intarg_count += (size_al + 7) / 8;
+# else
+ intarg_count += (size_al + 3) / 4;
+# endif
+#endif
+ break;
+
+ default:
+ /* Everything else is passed as a 4-byte word in a GPR, either
+ the object itself or a pointer to it. */
+ intarg_count++;
+ break;
+ }
+ }
+
+ if (fparg_count != 0)
+ flags |= FLAG_FP_ARGUMENTS;
+
+#if defined(POWERPC_DARWIN64)
+ /* Space to image the FPR registers, if needed - which includes when they might be
+ used in a struct return. */
+ if (fparg_count != 0
+ || ((flags & FLAG_RETURNS_STRUCT)
+ && (flags & FLAG_RETURNS_FP)))
+ bytes += NUM_FPR_ARG_REGISTERS * sizeof(double);
+#else
+ /* Space for the FPR registers, if needed. */
+ if (fparg_count != 0)
+ bytes += NUM_FPR_ARG_REGISTERS * sizeof(double);
+#endif
+
+ /* Stack space. */
+#ifdef POWERPC64
+ if ((intarg_count + fparg_count) > NUM_GPR_ARG_REGISTERS)
+ bytes += (intarg_count + fparg_count) * sizeof(long);
+#else
+ if ((intarg_count + 2 * fparg_count) > NUM_GPR_ARG_REGISTERS)
+ bytes += (intarg_count + 2 * fparg_count) * sizeof(long);
+#endif
+ else
+ bytes += NUM_GPR_ARG_REGISTERS * sizeof(long);
+
+ /* The stack space allocated needs to be a multiple of 16 bytes. */
+ bytes = ALIGN(bytes, 16) ;
+
+ cif->flags = flags;
+ cif->bytes = bytes;
+
+ return FFI_OK;
+}
+
+extern void ffi_call_AIX(extended_cif *, long, unsigned, unsigned *,
+ void (*fn)(void), void (*fn2)(void));
+
+extern void ffi_call_DARWIN(extended_cif *, long, unsigned, unsigned *,
+ void (*fn)(void), void (*fn2)(void), ffi_type*);
+
+void
+ffi_call (ffi_cif *cif, void (*fn)(void), void *rvalue, void **avalue)
+{
+ extended_cif ecif;
+
+ ecif.cif = cif;
+ ecif.avalue = avalue;
+
+ /* If the return value is a struct and we don't have a return
+ value address then we need to make one. */
+
+ if ((rvalue == NULL) &&
+ (cif->rtype->type == FFI_TYPE_STRUCT))
+ {
+ ecif.rvalue = alloca (cif->rtype->size);
+ }
+ else
+ ecif.rvalue = rvalue;
+
+ switch (cif->abi)
+ {
+ case FFI_AIX:
+ ffi_call_AIX(&ecif, -(long)cif->bytes, cif->flags, ecif.rvalue, fn,
+ FFI_FN(ffi_prep_args));
+ break;
+ case FFI_DARWIN:
+ ffi_call_DARWIN(&ecif, -(long)cif->bytes, cif->flags, ecif.rvalue, fn,
+ FFI_FN(ffi_prep_args), cif->rtype);
+ break;
+ default:
+ FFI_ASSERT(0);
+ break;
+ }
+}
+
+static void flush_icache(char *);
+static void flush_range(char *, int);
+
+/* The layout of a function descriptor. A C function pointer really
+ points to one of these. */
+
+typedef struct aix_fd_struct {
+ void *code_pointer;
+ void *toc;
+} aix_fd;
+
+/* here I'd like to add the stack frame layout we use in darwin_closure.S
+ and aix_closure.S
+
+ m32/m64
+
+ The stack layout looks like this:
+
+ | Additional params... | | Higher address
+ ~ ~ ~
+ | Parameters (at least 8*4/8=32/64) | | NUM_GPR_ARG_REGISTERS
+ |--------------------------------------------| |
+ | TOC=R2 (AIX) Reserved (Darwin) 4/8 | |
+ |--------------------------------------------| |
+ | Reserved 2*4/8 | |
+ |--------------------------------------------| |
+ | Space for callee's LR 4/8 | |
+ |--------------------------------------------| |
+ | Saved CR [low word for m64] 4/8 | |
+ |--------------------------------------------| |
+ | Current backchain pointer 4/8 |-/ Parent's frame.
+ |--------------------------------------------| <+ <<< on entry to ffi_closure_ASM
+ | Result Bytes 16 | |
+ |--------------------------------------------| |
+ ~ padding to 16-byte alignment ~ ~
+ |--------------------------------------------| |
+ | NUM_FPR_ARG_REGISTERS slots | |
+ | here fp13 .. fp1 13*8 | |
+ |--------------------------------------------| |
+ | R3..R10 8*4/8=32/64 | | NUM_GPR_ARG_REGISTERS
+ |--------------------------------------------| |
+ | TOC=R2 (AIX) Reserved (Darwin) 4/8 | |
+ |--------------------------------------------| | stack |
+ | Reserved [compiler,binder] 2*4/8 | | grows |
+ |--------------------------------------------| | down V
+ | Space for callee's LR 4/8 | |
+ |--------------------------------------------| | lower addresses
+ | Saved CR [low word for m64] 4/8 | |
+ |--------------------------------------------| | stack pointer here
+ | Current backchain pointer 4/8 |-/ during
+ |--------------------------------------------| <<< ffi_closure_ASM.
+
+*/
+
+ffi_status
+ffi_prep_closure_loc (ffi_closure* closure,
+ ffi_cif* cif,
+ void (*fun)(ffi_cif*, void*, void**, void*),
+ void *user_data,
+ void *codeloc)
+{
+ unsigned int *tramp;
+ struct ffi_aix_trampoline_struct *tramp_aix;
+ aix_fd *fd;
+
+ switch (cif->abi)
+ {
+ case FFI_DARWIN:
+
+ FFI_ASSERT (cif->abi == FFI_DARWIN);
+
+ tramp = (unsigned int *) &closure->tramp[0];
+#if defined(POWERPC_DARWIN64)
+ tramp[0] = 0x7c0802a6; /* mflr r0 */
+ tramp[1] = 0x429f0015; /* bcl- 20,4*cr7+so, +0x18 (L1) */
+ /* We put the addresses here. */
+ tramp[6] = 0x7d6802a6; /*L1: mflr r11 */
+ tramp[7] = 0xe98b0000; /* ld r12,0(r11) function address */
+ tramp[8] = 0x7c0803a6; /* mtlr r0 */
+ tramp[9] = 0x7d8903a6; /* mtctr r12 */
+ tramp[10] = 0xe96b0008; /* lwz r11,8(r11) static chain */
+ tramp[11] = 0x4e800420; /* bctr */
+
+ *((unsigned long *)&tramp[2]) = (unsigned long) ffi_closure_ASM; /* function */
+ *((unsigned long *)&tramp[4]) = (unsigned long) codeloc; /* context */
+#else
+ tramp[0] = 0x7c0802a6; /* mflr r0 */
+ tramp[1] = 0x429f000d; /* bcl- 20,4*cr7+so,0x10 */
+ tramp[4] = 0x7d6802a6; /* mflr r11 */
+ tramp[5] = 0x818b0000; /* lwz r12,0(r11) function address */
+ tramp[6] = 0x7c0803a6; /* mtlr r0 */
+ tramp[7] = 0x7d8903a6; /* mtctr r12 */
+ tramp[8] = 0x816b0004; /* lwz r11,4(r11) static chain */
+ tramp[9] = 0x4e800420; /* bctr */
+ tramp[2] = (unsigned long) ffi_closure_ASM; /* function */
+ tramp[3] = (unsigned long) codeloc; /* context */
+#endif
+ closure->cif = cif;
+ closure->fun = fun;
+ closure->user_data = user_data;
+
+ /* Flush the icache. Only necessary on Darwin. */
+ flush_range(codeloc, FFI_TRAMPOLINE_SIZE);
+
+ break;
+
+ case FFI_AIX:
+
+ tramp_aix = (struct ffi_aix_trampoline_struct *) (closure->tramp);
+ fd = (aix_fd *)(void *)ffi_closure_ASM;
+
+ FFI_ASSERT (cif->abi == FFI_AIX);
+
+ tramp_aix->code_pointer = fd->code_pointer;
+ tramp_aix->toc = fd->toc;
+ tramp_aix->static_chain = codeloc;
+ closure->cif = cif;
+ closure->fun = fun;
+ closure->user_data = user_data;
+ break;
+
+ default:
+ return FFI_BAD_ABI;
+ break;
+ }
+ return FFI_OK;
+}
+
+static void
+flush_icache(char *addr)
+{
+#ifndef _AIX
+ __asm__ volatile (
+ "dcbf 0,%0\n"
+ "\tsync\n"
+ "\ticbi 0,%0\n"
+ "\tsync\n"
+ "\tisync"
+ : : "r"(addr) : "memory");
+#endif
+}
+
+static void
+flush_range(char * addr1, int size)
+{
+#define MIN_LINE_SIZE 32
+ int i;
+ for (i = 0; i < size; i += MIN_LINE_SIZE)
+ flush_icache(addr1+i);
+ flush_icache(addr1+size-1);
+}
+
+typedef union
+{
+ float f;
+ double d;
+} ffi_dblfl;
+
+ffi_type *
+ffi_closure_helper_DARWIN (ffi_closure *, void *,
+ unsigned long *, ffi_dblfl *);
+
+/* Basically the trampoline invokes ffi_closure_ASM, and on
+ entry, r11 holds the address of the closure.
+ After storing the registers that could possibly contain
+ parameters to be passed into the stack frame and setting
+ up space for a return value, ffi_closure_ASM invokes the
+ following helper function to do most of the work. */
+
+ffi_type *
+ffi_closure_helper_DARWIN (ffi_closure *closure, void *rvalue,
+ unsigned long *pgr, ffi_dblfl *pfr)
+{
+ /* rvalue is the pointer to space for return value in closure assembly
+ pgr is the pointer to where r3-r10 are stored in ffi_closure_ASM
+ pfr is the pointer to where f1-f13 are stored in ffi_closure_ASM. */
+
+ typedef double ldbits[2];
+
+ union ldu
+ {
+ ldbits lb;
+ long double ld;
+ };
+
+ void ** avalue;
+ ffi_type ** arg_types;
+ long i, avn;
+ ffi_cif * cif;
+ ffi_dblfl * end_pfr = pfr + NUM_FPR_ARG_REGISTERS;
+ unsigned size_al;
+#if defined(POWERPC_DARWIN64)
+ unsigned fpsused = 0;
+#endif
+
+ cif = closure->cif;
+ avalue = alloca (cif->nargs * sizeof(void *));
+
+ if (cif->rtype->type == FFI_TYPE_STRUCT)
+ {
+#if defined(POWERPC_DARWIN64)
+ if (!darwin64_struct_ret_by_value_p (cif->rtype))
+ {
+ /* Won't fit into the regs - return by ref. */
+ rvalue = (void *) *pgr;
+ pgr++;
+ }
+#elif defined(DARWIN_PPC)
+ if (cif->rtype->size > 4)
+ {
+ rvalue = (void *) *pgr;
+ pgr++;
+ }
+#else /* assume we return by ref. */
+ rvalue = (void *) *pgr;
+ pgr++;
+#endif
+ }
+
+ i = 0;
+ avn = cif->nargs;
+ arg_types = cif->arg_types;
+
+ /* Grab the addresses of the arguments from the stack frame. */
+ while (i < avn)
+ {
+ switch (arg_types[i]->type)
+ {
+ case FFI_TYPE_SINT8:
+ case FFI_TYPE_UINT8:
+#if defined(POWERPC64)
+ avalue[i] = (char *) pgr + 7;
+#else
+ avalue[i] = (char *) pgr + 3;
+#endif
+ pgr++;
+ break;
+
+ case FFI_TYPE_SINT16:
+ case FFI_TYPE_UINT16:
+#if defined(POWERPC64)
+ avalue[i] = (char *) pgr + 6;
+#else
+ avalue[i] = (char *) pgr + 2;
+#endif
+ pgr++;
+ break;
+
+ case FFI_TYPE_SINT32:
+ case FFI_TYPE_UINT32:
+#if defined(POWERPC64)
+ avalue[i] = (char *) pgr + 4;
+#else
+ case FFI_TYPE_POINTER:
+ avalue[i] = pgr;
+#endif
+ pgr++;
+ break;
+
+ case FFI_TYPE_STRUCT:
+ size_al = arg_types[i]->size;
+#if defined(POWERPC_DARWIN64)
+ pgr = (unsigned long *)ALIGN((char *)pgr, arg_types[i]->alignment);
+ if (size_al < 3 || size_al == 4)
+ {
+ avalue[i] = ((char *)pgr)+8-size_al;
+ if (arg_types[i]->elements[0]->type == FFI_TYPE_FLOAT
+ && fpsused < NUM_FPR_ARG_REGISTERS)
+ {
+ *(float *)pgr = (float) *(double *)pfr;
+ pfr++;
+ fpsused++;
+ }
+ }
+ else
+ {
+ if (size_al != 16)
+ pfr = (ffi_dblfl *)
+ darwin64_struct_floats_to_mem (arg_types[i], (char *)pgr,
+ (double *)pfr, &fpsused);
+ avalue[i] = pgr;
+ }
+ pgr += (size_al + 7) / 8;
+#else
+ /* If the first member of the struct is a double, then align
+ the struct to double-word. */
+ if (arg_types[i]->elements[0]->type == FFI_TYPE_DOUBLE)
+ size_al = ALIGN(arg_types[i]->size, 8);
+# if defined(POWERPC64)
+ FFI_ASSERT (cif->abi != FFI_DARWIN);
+ avalue[i] = pgr;
+ pgr += (size_al + 7) / 8;
+# else
+ /* Structures that match the basic modes (QI 1 byte, HI 2 bytes,
+ SI 4 bytes) are aligned as if they were those modes. */
+ if (size_al < 3 && cif->abi == FFI_DARWIN)
+ avalue[i] = (char*) pgr + 4 - size_al;
+ else
+ avalue[i] = pgr;
+ pgr += (size_al + 3) / 4;
+# endif
+#endif
+ break;
+
+ case FFI_TYPE_SINT64:
+ case FFI_TYPE_UINT64:
+#if defined(POWERPC64)
+ case FFI_TYPE_POINTER:
+ avalue[i] = pgr;
+ pgr++;
+ break;
+#else
+ /* Long long ints are passed in two gpr's. */
+ avalue[i] = pgr;
+ pgr += 2;
+ break;
+#endif
+
+ case FFI_TYPE_FLOAT:
+ /* A float value consumes a GPR.
+ There are 13 64bit floating point registers. */
+ if (pfr < end_pfr)
+ {
+ double temp = pfr->d;
+ pfr->f = (float) temp;
+ avalue[i] = pfr;
+ pfr++;
+ }
+ else
+ {
+ avalue[i] = pgr;
+ }
+ pgr++;
+ break;
+
+ case FFI_TYPE_DOUBLE:
+ /* A double value consumes two GPRs.
+ There are 13 64bit floating point registers. */
+ if (pfr < end_pfr)
+ {
+ avalue[i] = pfr;
+ pfr++;
+ }
+ else
+ {
+ avalue[i] = pgr;
+ }
+#ifdef POWERPC64
+ pgr++;
+#else
+ pgr += 2;
+#endif
+ break;
+
+#if FFI_TYPE_LONGDOUBLE != FFI_TYPE_DOUBLE
+
+ case FFI_TYPE_LONGDOUBLE:
+#ifdef POWERPC64
+ if (pfr + 1 < end_pfr)
+ {
+ avalue[i] = pfr;
+ pfr += 2;
+ }
+ else
+ {
+ if (pfr < end_pfr)
+ {
+ *pgr = *(unsigned long *) pfr;
+ pfr++;
+ }
+ avalue[i] = pgr;
+ }
+ pgr += 2;
+#else /* POWERPC64 */
+ /* A long double value consumes four GPRs and two FPRs.
+ There are 13 64bit floating point registers. */
+ if (pfr + 1 < end_pfr)
+ {
+ avalue[i] = pfr;
+ pfr += 2;
+ }
+ /* Here we have the situation where one part of the long double
+ is stored in fpr13 and the other part is already on the stack.
+ We use a union to pass the long double to avalue[i]. */
+ else if (pfr + 1 == end_pfr)
+ {
+ union ldu temp_ld;
+ memcpy (&temp_ld.lb[0], pfr, sizeof(ldbits));
+ memcpy (&temp_ld.lb[1], pgr + 2, sizeof(ldbits));
+ avalue[i] = &temp_ld.ld;
+ pfr++;
+ }
+ else
+ {
+ avalue[i] = pgr;
+ }
+ pgr += 4;
+#endif /* POWERPC64 */
+ break;
+#endif
+ default:
+ FFI_ASSERT(0);
+ }
+ i++;
+ }
+
+ (closure->fun) (cif, rvalue, avalue, closure->user_data);
+
+ /* Tell ffi_closure_ASM to perform return type promotions. */
+ return cif->rtype;
+}
diff --git a/jni/ruby/ext/fiddle/libffi-3.2.1/src/powerpc/ffi_linux64.c b/jni/ruby/ext/fiddle/libffi-3.2.1/src/powerpc/ffi_linux64.c
new file mode 100644
index 0000000..b087af8
--- /dev/null
+++ b/jni/ruby/ext/fiddle/libffi-3.2.1/src/powerpc/ffi_linux64.c
@@ -0,0 +1,943 @@
+/* -----------------------------------------------------------------------
+ ffi_linux64.c - Copyright (C) 2013 IBM
+ Copyright (C) 2011 Anthony Green
+ Copyright (C) 2011 Kyle Moffett
+ Copyright (C) 2008 Red Hat, Inc
+ Copyright (C) 2007, 2008 Free Software Foundation, Inc
+ Copyright (c) 1998 Geoffrey Keating
+
+ PowerPC Foreign Function Interface
+
+ Permission is hereby granted, free of charge, to any person obtaining
+ a copy of this software and associated documentation files (the
+ ``Software''), to deal in the Software without restriction, including
+ without limitation the rights to use, copy, modify, merge, publish,
+ distribute, sublicense, and/or sell copies of the Software, and to
+ permit persons to whom the Software is furnished to do so, subject to
+ the following conditions:
+
+ The above copyright notice and this permission notice shall be included
+ in all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ OTHER DEALINGS IN THE SOFTWARE.
+ ----------------------------------------------------------------------- */
+
+#include "ffi.h"
+
+#ifdef POWERPC64
+#include "ffi_common.h"
+#include "ffi_powerpc.h"
+
+
+/* About the LINUX64 ABI. */
+enum {
+ NUM_GPR_ARG_REGISTERS64 = 8,
+ NUM_FPR_ARG_REGISTERS64 = 13
+};
+enum { ASM_NEEDS_REGISTERS64 = 4 };
+
+
+#if HAVE_LONG_DOUBLE_VARIANT && FFI_TYPE_LONGDOUBLE != FFI_TYPE_DOUBLE
+/* Adjust size of ffi_type_longdouble. */
+void FFI_HIDDEN
+ffi_prep_types_linux64 (ffi_abi abi)
+{
+ if ((abi & (FFI_LINUX | FFI_LINUX_LONG_DOUBLE_128)) == FFI_LINUX)
+ {
+ ffi_type_longdouble.size = 8;
+ ffi_type_longdouble.alignment = 8;
+ }
+ else
+ {
+ ffi_type_longdouble.size = 16;
+ ffi_type_longdouble.alignment = 16;
+ }
+}
+#endif
+
+
+#if _CALL_ELF == 2
+static unsigned int
+discover_homogeneous_aggregate (const ffi_type *t, unsigned int *elnum)
+{
+ switch (t->type)
+ {
+ case FFI_TYPE_FLOAT:
+ case FFI_TYPE_DOUBLE:
+ *elnum = 1;
+ return (int) t->type;
+
+ case FFI_TYPE_STRUCT:;
+ {
+ unsigned int base_elt = 0, total_elnum = 0;
+ ffi_type **el = t->elements;
+ while (*el)
+ {
+ unsigned int el_elt, el_elnum = 0;
+ el_elt = discover_homogeneous_aggregate (*el, &el_elnum);
+ if (el_elt == 0
+ || (base_elt && base_elt != el_elt))
+ return 0;
+ base_elt = el_elt;
+ total_elnum += el_elnum;
+ if (total_elnum > 8)
+ return 0;
+ el++;
+ }
+ *elnum = total_elnum;
+ return base_elt;
+ }
+
+ default:
+ return 0;
+ }
+}
+#endif
+
+
+/* Perform machine dependent cif processing */
+static ffi_status
+ffi_prep_cif_linux64_core (ffi_cif *cif)
+{
+ ffi_type **ptr;
+ unsigned bytes;
+ unsigned i, fparg_count = 0, intarg_count = 0;
+ unsigned flags = cif->flags;
+#if _CALL_ELF == 2
+ unsigned int elt, elnum;
+#endif
+
+#if FFI_TYPE_LONGDOUBLE == FFI_TYPE_DOUBLE
+ /* If compiled without long double support.. */
+ if ((cif->abi & FFI_LINUX_LONG_DOUBLE_128) != 0)
+ return FFI_BAD_ABI;
+#endif
+
+ /* The machine-independent calculation of cif->bytes doesn't work
+ for us. Redo the calculation. */
+#if _CALL_ELF == 2
+ /* Space for backchain, CR, LR, TOC and the asm's temp regs. */
+ bytes = (4 + ASM_NEEDS_REGISTERS64) * sizeof (long);
+
+ /* Space for the general registers. */
+ bytes += NUM_GPR_ARG_REGISTERS64 * sizeof (long);
+#else
+ /* Space for backchain, CR, LR, cc/ld doubleword, TOC and the asm's temp
+ regs. */
+ bytes = (6 + ASM_NEEDS_REGISTERS64) * sizeof (long);
+
+ /* Space for the mandatory parm save area and general registers. */
+ bytes += 2 * NUM_GPR_ARG_REGISTERS64 * sizeof (long);
+#endif
+
+ /* Return value handling. */
+ switch (cif->rtype->type)
+ {
+#if FFI_TYPE_LONGDOUBLE != FFI_TYPE_DOUBLE
+ case FFI_TYPE_LONGDOUBLE:
+ if ((cif->abi & FFI_LINUX_LONG_DOUBLE_128) != 0)
+ flags |= FLAG_RETURNS_128BITS;
+ /* Fall through. */
+#endif
+ case FFI_TYPE_DOUBLE:
+ flags |= FLAG_RETURNS_64BITS;
+ /* Fall through. */
+ case FFI_TYPE_FLOAT:
+ flags |= FLAG_RETURNS_FP;
+ break;
+
+ case FFI_TYPE_UINT128:
+ flags |= FLAG_RETURNS_128BITS;
+ /* Fall through. */
+ case FFI_TYPE_UINT64:
+ case FFI_TYPE_SINT64:
+ flags |= FLAG_RETURNS_64BITS;
+ break;
+
+ case FFI_TYPE_STRUCT:
+#if _CALL_ELF == 2
+ elt = discover_homogeneous_aggregate (cif->rtype, &elnum);
+ if (elt)
+ {
+ if (elt == FFI_TYPE_DOUBLE)
+ flags |= FLAG_RETURNS_64BITS;
+ flags |= FLAG_RETURNS_FP | FLAG_RETURNS_SMST;
+ break;
+ }
+ if (cif->rtype->size <= 16)
+ {
+ flags |= FLAG_RETURNS_SMST;
+ break;
+ }
+#endif
+ intarg_count++;
+ flags |= FLAG_RETVAL_REFERENCE;
+ /* Fall through. */
+ case FFI_TYPE_VOID:
+ flags |= FLAG_RETURNS_NOTHING;
+ break;
+
+ default:
+ /* Returns 32-bit integer, or similar. Nothing to do here. */
+ break;
+ }
+
+ for (ptr = cif->arg_types, i = cif->nargs; i > 0; i--, ptr++)
+ {
+ unsigned int align;
+
+ switch ((*ptr)->type)
+ {
+#if FFI_TYPE_LONGDOUBLE != FFI_TYPE_DOUBLE
+ case FFI_TYPE_LONGDOUBLE:
+ if ((cif->abi & FFI_LINUX_LONG_DOUBLE_128) != 0)
+ {
+ fparg_count++;
+ intarg_count++;
+ }
+ /* Fall through. */
+#endif
+ case FFI_TYPE_DOUBLE:
+ case FFI_TYPE_FLOAT:
+ fparg_count++;
+ intarg_count++;
+ if (fparg_count > NUM_FPR_ARG_REGISTERS64)
+ flags |= FLAG_ARG_NEEDS_PSAVE;
+ break;
+
+ case FFI_TYPE_STRUCT:
+ if ((cif->abi & FFI_LINUX_STRUCT_ALIGN) != 0)
+ {
+ align = (*ptr)->alignment;
+ if (align > 16)
+ align = 16;
+ align = align / 8;
+ if (align > 1)
+ intarg_count = ALIGN (intarg_count, align);
+ }
+ intarg_count += ((*ptr)->size + 7) / 8;
+#if _CALL_ELF == 2
+ elt = discover_homogeneous_aggregate (*ptr, &elnum);
+ if (elt)
+ {
+ fparg_count += elnum;
+ if (fparg_count > NUM_FPR_ARG_REGISTERS64)
+ flags |= FLAG_ARG_NEEDS_PSAVE;
+ }
+ else
+#endif
+ {
+ if (intarg_count > NUM_GPR_ARG_REGISTERS64)
+ flags |= FLAG_ARG_NEEDS_PSAVE;
+ }
+ break;
+
+ case FFI_TYPE_POINTER:
+ case FFI_TYPE_UINT64:
+ case FFI_TYPE_SINT64:
+ case FFI_TYPE_INT:
+ case FFI_TYPE_UINT32:
+ case FFI_TYPE_SINT32:
+ case FFI_TYPE_UINT16:
+ case FFI_TYPE_SINT16:
+ case FFI_TYPE_UINT8:
+ case FFI_TYPE_SINT8:
+ /* Everything else is passed as a 8-byte word in a GPR, either
+ the object itself or a pointer to it. */
+ intarg_count++;
+ if (intarg_count > NUM_GPR_ARG_REGISTERS64)
+ flags |= FLAG_ARG_NEEDS_PSAVE;
+ break;
+ default:
+ FFI_ASSERT (0);
+ }
+ }
+
+ if (fparg_count != 0)
+ flags |= FLAG_FP_ARGUMENTS;
+ if (intarg_count > 4)
+ flags |= FLAG_4_GPR_ARGUMENTS;
+
+ /* Space for the FPR registers, if needed. */
+ if (fparg_count != 0)
+ bytes += NUM_FPR_ARG_REGISTERS64 * sizeof (double);
+
+ /* Stack space. */
+#if _CALL_ELF == 2
+ if ((flags & FLAG_ARG_NEEDS_PSAVE) != 0)
+ bytes += intarg_count * sizeof (long);
+#else
+ if (intarg_count > NUM_GPR_ARG_REGISTERS64)
+ bytes += (intarg_count - NUM_GPR_ARG_REGISTERS64) * sizeof (long);
+#endif
+
+ /* The stack space allocated needs to be a multiple of 16 bytes. */
+ bytes = (bytes + 15) & ~0xF;
+
+ cif->flags = flags;
+ cif->bytes = bytes;
+
+ return FFI_OK;
+}
+
+ffi_status FFI_HIDDEN
+ffi_prep_cif_linux64 (ffi_cif *cif)
+{
+ if ((cif->abi & FFI_LINUX) != 0)
+ cif->nfixedargs = cif->nargs;
+#if _CALL_ELF != 2
+ else if (cif->abi == FFI_COMPAT_LINUX64)
+ {
+ /* This call is from old code. Don't touch cif->nfixedargs
+ since old code will be using a smaller cif. */
+ cif->flags |= FLAG_COMPAT;
+ /* Translate to new abi value. */
+ cif->abi = FFI_LINUX | FFI_LINUX_LONG_DOUBLE_128;
+ }
+#endif
+ else
+ return FFI_BAD_ABI;
+ return ffi_prep_cif_linux64_core (cif);
+}
+
+ffi_status FFI_HIDDEN
+ffi_prep_cif_linux64_var (ffi_cif *cif,
+ unsigned int nfixedargs,
+ unsigned int ntotalargs MAYBE_UNUSED)
+{
+ if ((cif->abi & FFI_LINUX) != 0)
+ cif->nfixedargs = nfixedargs;
+#if _CALL_ELF != 2
+ else if (cif->abi == FFI_COMPAT_LINUX64)
+ {
+ /* This call is from old code. Don't touch cif->nfixedargs
+ since old code will be using a smaller cif. */
+ cif->flags |= FLAG_COMPAT;
+ /* Translate to new abi value. */
+ cif->abi = FFI_LINUX | FFI_LINUX_LONG_DOUBLE_128;
+ }
+#endif
+ else
+ return FFI_BAD_ABI;
+#if _CALL_ELF == 2
+ cif->flags |= FLAG_ARG_NEEDS_PSAVE;
+#endif
+ return ffi_prep_cif_linux64_core (cif);
+}
+
+
+/* ffi_prep_args64 is called by the assembly routine once stack space
+ has been allocated for the function's arguments.
+
+ The stack layout we want looks like this:
+
+ | Ret addr from ffi_call_LINUX64 8bytes | higher addresses
+ |--------------------------------------------|
+ | CR save area 8bytes |
+ |--------------------------------------------|
+ | Previous backchain pointer 8 | stack pointer here
+ |--------------------------------------------|<+ <<< on entry to
+ | Saved r28-r31 4*8 | | ffi_call_LINUX64
+ |--------------------------------------------| |
+ | GPR registers r3-r10 8*8 | |
+ |--------------------------------------------| |
+ | FPR registers f1-f13 (optional) 13*8 | |
+ |--------------------------------------------| |
+ | Parameter save area | |
+ |--------------------------------------------| |
+ | TOC save area 8 | |
+ |--------------------------------------------| | stack |
+ | Linker doubleword 8 | | grows |
+ |--------------------------------------------| | down V
+ | Compiler doubleword 8 | |
+ |--------------------------------------------| | lower addresses
+ | Space for callee's LR 8 | |
+ |--------------------------------------------| |
+ | CR save area 8 | |
+ |--------------------------------------------| | stack pointer here
+ | Current backchain pointer 8 |-/ during
+ |--------------------------------------------| <<< ffi_call_LINUX64
+
+*/
+
+void FFI_HIDDEN
+ffi_prep_args64 (extended_cif *ecif, unsigned long *const stack)
+{
+ const unsigned long bytes = ecif->cif->bytes;
+ const unsigned long flags = ecif->cif->flags;
+
+ typedef union
+ {
+ char *c;
+ unsigned long *ul;
+ float *f;
+ double *d;
+ size_t p;
+ } valp;
+
+ /* 'stacktop' points at the previous backchain pointer. */
+ valp stacktop;
+
+ /* 'next_arg' points at the space for gpr3, and grows upwards as
+ we use GPR registers, then continues at rest. */
+ valp gpr_base;
+ valp gpr_end;
+ valp rest;
+ valp next_arg;
+
+ /* 'fpr_base' points at the space for fpr3, and grows upwards as
+ we use FPR registers. */
+ valp fpr_base;
+ unsigned int fparg_count;
+
+ unsigned int i, words, nargs, nfixedargs;
+ ffi_type **ptr;
+ double double_tmp;
+ union
+ {
+ void **v;
+ char **c;
+ signed char **sc;
+ unsigned char **uc;
+ signed short **ss;
+ unsigned short **us;
+ signed int **si;
+ unsigned int **ui;
+ unsigned long **ul;
+ float **f;
+ double **d;
+ } p_argv;
+ unsigned long gprvalue;
+ unsigned long align;
+
+ stacktop.c = (char *) stack + bytes;
+ gpr_base.ul = stacktop.ul - ASM_NEEDS_REGISTERS64 - NUM_GPR_ARG_REGISTERS64;
+ gpr_end.ul = gpr_base.ul + NUM_GPR_ARG_REGISTERS64;
+#if _CALL_ELF == 2
+ rest.ul = stack + 4 + NUM_GPR_ARG_REGISTERS64;
+#else
+ rest.ul = stack + 6 + NUM_GPR_ARG_REGISTERS64;
+#endif
+ fpr_base.d = gpr_base.d - NUM_FPR_ARG_REGISTERS64;
+ fparg_count = 0;
+ next_arg.ul = gpr_base.ul;
+
+ /* Check that everything starts aligned properly. */
+ FFI_ASSERT (((unsigned long) (char *) stack & 0xF) == 0);
+ FFI_ASSERT (((unsigned long) stacktop.c & 0xF) == 0);
+ FFI_ASSERT ((bytes & 0xF) == 0);
+
+ /* Deal with return values that are actually pass-by-reference. */
+ if (flags & FLAG_RETVAL_REFERENCE)
+ *next_arg.ul++ = (unsigned long) (char *) ecif->rvalue;
+
+ /* Now for the arguments. */
+ p_argv.v = ecif->avalue;
+ nargs = ecif->cif->nargs;
+#if _CALL_ELF != 2
+ nfixedargs = (unsigned) -1;
+ if ((flags & FLAG_COMPAT) == 0)
+#endif
+ nfixedargs = ecif->cif->nfixedargs;
+ for (ptr = ecif->cif->arg_types, i = 0;
+ i < nargs;
+ i++, ptr++, p_argv.v++)
+ {
+#if _CALL_ELF == 2
+ unsigned int elt, elnum;
+#endif
+
+ switch ((*ptr)->type)
+ {
+#if FFI_TYPE_LONGDOUBLE != FFI_TYPE_DOUBLE
+ case FFI_TYPE_LONGDOUBLE:
+ if ((ecif->cif->abi & FFI_LINUX_LONG_DOUBLE_128) != 0)
+ {
+ double_tmp = (*p_argv.d)[0];
+ if (fparg_count < NUM_FPR_ARG_REGISTERS64 && i < nfixedargs)
+ {
+ *fpr_base.d++ = double_tmp;
+# if _CALL_ELF != 2
+ if ((flags & FLAG_COMPAT) != 0)
+ *next_arg.d = double_tmp;
+# endif
+ }
+ else
+ *next_arg.d = double_tmp;
+ if (++next_arg.ul == gpr_end.ul)
+ next_arg.ul = rest.ul;
+ fparg_count++;
+ double_tmp = (*p_argv.d)[1];
+ if (fparg_count < NUM_FPR_ARG_REGISTERS64 && i < nfixedargs)
+ {
+ *fpr_base.d++ = double_tmp;
+# if _CALL_ELF != 2
+ if ((flags & FLAG_COMPAT) != 0)
+ *next_arg.d = double_tmp;
+# endif
+ }
+ else
+ *next_arg.d = double_tmp;
+ if (++next_arg.ul == gpr_end.ul)
+ next_arg.ul = rest.ul;
+ fparg_count++;
+ FFI_ASSERT (__LDBL_MANT_DIG__ == 106);
+ FFI_ASSERT (flags & FLAG_FP_ARGUMENTS);
+ break;
+ }
+ /* Fall through. */
+#endif
+ case FFI_TYPE_DOUBLE:
+ double_tmp = **p_argv.d;
+ if (fparg_count < NUM_FPR_ARG_REGISTERS64 && i < nfixedargs)
+ {
+ *fpr_base.d++ = double_tmp;
+#if _CALL_ELF != 2
+ if ((flags & FLAG_COMPAT) != 0)
+ *next_arg.d = double_tmp;
+#endif
+ }
+ else
+ *next_arg.d = double_tmp;
+ if (++next_arg.ul == gpr_end.ul)
+ next_arg.ul = rest.ul;
+ fparg_count++;
+ FFI_ASSERT (flags & FLAG_FP_ARGUMENTS);
+ break;
+
+ case FFI_TYPE_FLOAT:
+ double_tmp = **p_argv.f;
+ if (fparg_count < NUM_FPR_ARG_REGISTERS64 && i < nfixedargs)
+ {
+ *fpr_base.d++ = double_tmp;
+#if _CALL_ELF != 2
+ if ((flags & FLAG_COMPAT) != 0)
+ *next_arg.f = (float) double_tmp;
+#endif
+ }
+ else
+ *next_arg.f = (float) double_tmp;
+ if (++next_arg.ul == gpr_end.ul)
+ next_arg.ul = rest.ul;
+ fparg_count++;
+ FFI_ASSERT (flags & FLAG_FP_ARGUMENTS);
+ break;
+
+ case FFI_TYPE_STRUCT:
+ if ((ecif->cif->abi & FFI_LINUX_STRUCT_ALIGN) != 0)
+ {
+ align = (*ptr)->alignment;
+ if (align > 16)
+ align = 16;
+ if (align > 1)
+ next_arg.p = ALIGN (next_arg.p, align);
+ }
+#if _CALL_ELF == 2
+ elt = discover_homogeneous_aggregate (*ptr, &elnum);
+ if (elt)
+ {
+ union {
+ void *v;
+ float *f;
+ double *d;
+ } arg;
+
+ arg.v = *p_argv.v;
+ if (elt == FFI_TYPE_FLOAT)
+ {
+ do
+ {
+ double_tmp = *arg.f++;
+ if (fparg_count < NUM_FPR_ARG_REGISTERS64
+ && i < nfixedargs)
+ *fpr_base.d++ = double_tmp;
+ else
+ *next_arg.f = (float) double_tmp;
+ if (++next_arg.f == gpr_end.f)
+ next_arg.f = rest.f;
+ fparg_count++;
+ }
+ while (--elnum != 0);
+ if ((next_arg.p & 3) != 0)
+ {
+ if (++next_arg.f == gpr_end.f)
+ next_arg.f = rest.f;
+ }
+ }
+ else
+ do
+ {
+ double_tmp = *arg.d++;
+ if (fparg_count < NUM_FPR_ARG_REGISTERS64 && i < nfixedargs)
+ *fpr_base.d++ = double_tmp;
+ else
+ *next_arg.d = double_tmp;
+ if (++next_arg.d == gpr_end.d)
+ next_arg.d = rest.d;
+ fparg_count++;
+ }
+ while (--elnum != 0);
+ }
+ else
+#endif
+ {
+ words = ((*ptr)->size + 7) / 8;
+ if (next_arg.ul >= gpr_base.ul && next_arg.ul + words > gpr_end.ul)
+ {
+ size_t first = gpr_end.c - next_arg.c;
+ memcpy (next_arg.c, *p_argv.c, first);
+ memcpy (rest.c, *p_argv.c + first, (*ptr)->size - first);
+ next_arg.c = rest.c + words * 8 - first;
+ }
+ else
+ {
+ char *where = next_arg.c;
+
+#ifndef __LITTLE_ENDIAN__
+ /* Structures with size less than eight bytes are passed
+ left-padded. */
+ if ((*ptr)->size < 8)
+ where += 8 - (*ptr)->size;
+#endif
+ memcpy (where, *p_argv.c, (*ptr)->size);
+ next_arg.ul += words;
+ if (next_arg.ul == gpr_end.ul)
+ next_arg.ul = rest.ul;
+ }
+ }
+ break;
+
+ case FFI_TYPE_UINT8:
+ gprvalue = **p_argv.uc;
+ goto putgpr;
+ case FFI_TYPE_SINT8:
+ gprvalue = **p_argv.sc;
+ goto putgpr;
+ case FFI_TYPE_UINT16:
+ gprvalue = **p_argv.us;
+ goto putgpr;
+ case FFI_TYPE_SINT16:
+ gprvalue = **p_argv.ss;
+ goto putgpr;
+ case FFI_TYPE_UINT32:
+ gprvalue = **p_argv.ui;
+ goto putgpr;
+ case FFI_TYPE_INT:
+ case FFI_TYPE_SINT32:
+ gprvalue = **p_argv.si;
+ goto putgpr;
+
+ case FFI_TYPE_UINT64:
+ case FFI_TYPE_SINT64:
+ case FFI_TYPE_POINTER:
+ gprvalue = **p_argv.ul;
+ putgpr:
+ *next_arg.ul++ = gprvalue;
+ if (next_arg.ul == gpr_end.ul)
+ next_arg.ul = rest.ul;
+ break;
+ }
+ }
+
+ FFI_ASSERT (flags & FLAG_4_GPR_ARGUMENTS
+ || (next_arg.ul >= gpr_base.ul
+ && next_arg.ul <= gpr_base.ul + 4));
+}
+
+
+#if _CALL_ELF == 2
+#define MIN_CACHE_LINE_SIZE 8
+
+static void
+flush_icache (char *wraddr, char *xaddr, int size)
+{
+ int i;
+ for (i = 0; i < size; i += MIN_CACHE_LINE_SIZE)
+ __asm__ volatile ("icbi 0,%0;" "dcbf 0,%1;"
+ : : "r" (xaddr + i), "r" (wraddr + i) : "memory");
+ __asm__ volatile ("icbi 0,%0;" "dcbf 0,%1;" "sync;" "isync;"
+ : : "r"(xaddr + size - 1), "r"(wraddr + size - 1)
+ : "memory");
+}
+#endif
+
+ffi_status
+ffi_prep_closure_loc_linux64 (ffi_closure *closure,
+ ffi_cif *cif,
+ void (*fun) (ffi_cif *, void *, void **, void *),
+ void *user_data,
+ void *codeloc)
+{
+#if _CALL_ELF == 2
+ unsigned int *tramp = (unsigned int *) &closure->tramp[0];
+
+ if (cif->abi < FFI_LINUX || cif->abi >= FFI_LAST_ABI)
+ return FFI_BAD_ABI;
+
+ tramp[0] = 0xe96c0018; /* 0: ld 11,2f-0b(12) */
+ tramp[1] = 0xe98c0010; /* ld 12,1f-0b(12) */
+ tramp[2] = 0x7d8903a6; /* mtctr 12 */
+ tramp[3] = 0x4e800420; /* bctr */
+ /* 1: .quad function_addr */
+ /* 2: .quad context */
+ *(void **) &tramp[4] = (void *) ffi_closure_LINUX64;
+ *(void **) &tramp[6] = codeloc;
+ flush_icache ((char *)tramp, (char *)codeloc, FFI_TRAMPOLINE_SIZE);
+#else
+ void **tramp = (void **) &closure->tramp[0];
+
+ if (cif->abi < FFI_LINUX || cif->abi >= FFI_LAST_ABI)
+ return FFI_BAD_ABI;
+
+ /* Copy function address and TOC from ffi_closure_LINUX64. */
+ memcpy (tramp, (char *) ffi_closure_LINUX64, 16);
+ tramp[2] = tramp[1];
+ tramp[1] = codeloc;
+#endif
+
+ closure->cif = cif;
+ closure->fun = fun;
+ closure->user_data = user_data;
+
+ return FFI_OK;
+}
+
+
+int FFI_HIDDEN
+ffi_closure_helper_LINUX64 (ffi_closure *closure, void *rvalue,
+ unsigned long *pst, ffi_dblfl *pfr)
+{
+ /* rvalue is the pointer to space for return value in closure assembly */
+ /* pst is the pointer to parameter save area
+ (r3-r10 are stored into its first 8 slots by ffi_closure_LINUX64) */
+ /* pfr is the pointer to where f1-f13 are stored in ffi_closure_LINUX64 */
+
+ void **avalue;
+ ffi_type **arg_types;
+ unsigned long i, avn, nfixedargs;
+ ffi_cif *cif;
+ ffi_dblfl *end_pfr = pfr + NUM_FPR_ARG_REGISTERS64;
+ unsigned long align;
+
+ cif = closure->cif;
+ avalue = alloca (cif->nargs * sizeof (void *));
+
+ /* Copy the caller's structure return value address so that the
+ closure returns the data directly to the caller. */
+ if (cif->rtype->type == FFI_TYPE_STRUCT
+ && (cif->flags & FLAG_RETURNS_SMST) == 0)
+ {
+ rvalue = (void *) *pst;
+ pst++;
+ }
+
+ i = 0;
+ avn = cif->nargs;
+#if _CALL_ELF != 2
+ nfixedargs = (unsigned) -1;
+ if ((cif->flags & FLAG_COMPAT) == 0)
+#endif
+ nfixedargs = cif->nfixedargs;
+ arg_types = cif->arg_types;
+
+ /* Grab the addresses of the arguments from the stack frame. */
+ while (i < avn)
+ {
+ unsigned int elt, elnum;
+
+ switch (arg_types[i]->type)
+ {
+ case FFI_TYPE_SINT8:
+ case FFI_TYPE_UINT8:
+#ifndef __LITTLE_ENDIAN__
+ avalue[i] = (char *) pst + 7;
+ pst++;
+ break;
+#endif
+
+ case FFI_TYPE_SINT16:
+ case FFI_TYPE_UINT16:
+#ifndef __LITTLE_ENDIAN__
+ avalue[i] = (char *) pst + 6;
+ pst++;
+ break;
+#endif
+
+ case FFI_TYPE_SINT32:
+ case FFI_TYPE_UINT32:
+#ifndef __LITTLE_ENDIAN__
+ avalue[i] = (char *) pst + 4;
+ pst++;
+ break;
+#endif
+
+ case FFI_TYPE_SINT64:
+ case FFI_TYPE_UINT64:
+ case FFI_TYPE_POINTER:
+ avalue[i] = pst;
+ pst++;
+ break;
+
+ case FFI_TYPE_STRUCT:
+ if ((cif->abi & FFI_LINUX_STRUCT_ALIGN) != 0)
+ {
+ align = arg_types[i]->alignment;
+ if (align > 16)
+ align = 16;
+ if (align > 1)
+ pst = (unsigned long *) ALIGN ((size_t) pst, align);
+ }
+ elt = 0;
+#if _CALL_ELF == 2
+ elt = discover_homogeneous_aggregate (arg_types[i], &elnum);
+#endif
+ if (elt)
+ {
+ union {
+ void *v;
+ unsigned long *ul;
+ float *f;
+ double *d;
+ size_t p;
+ } to, from;
+
+ /* Repackage the aggregate from its parts. The
+ aggregate size is not greater than the space taken by
+ the registers so store back to the register/parameter
+ save arrays. */
+ if (pfr + elnum <= end_pfr)
+ to.v = pfr;
+ else
+ to.v = pst;
+
+ avalue[i] = to.v;
+ from.ul = pst;
+ if (elt == FFI_TYPE_FLOAT)
+ {
+ do
+ {
+ if (pfr < end_pfr && i < nfixedargs)
+ {
+ *to.f = (float) pfr->d;
+ pfr++;
+ }
+ else
+ *to.f = *from.f;
+ to.f++;
+ from.f++;
+ }
+ while (--elnum != 0);
+ }
+ else
+ {
+ do
+ {
+ if (pfr < end_pfr && i < nfixedargs)
+ {
+ *to.d = pfr->d;
+ pfr++;
+ }
+ else
+ *to.d = *from.d;
+ to.d++;
+ from.d++;
+ }
+ while (--elnum != 0);
+ }
+ }
+ else
+ {
+#ifndef __LITTLE_ENDIAN__
+ /* Structures with size less than eight bytes are passed
+ left-padded. */
+ if (arg_types[i]->size < 8)
+ avalue[i] = (char *) pst + 8 - arg_types[i]->size;
+ else
+#endif
+ avalue[i] = pst;
+ }
+ pst += (arg_types[i]->size + 7) / 8;
+ break;
+
+#if FFI_TYPE_LONGDOUBLE != FFI_TYPE_DOUBLE
+ case FFI_TYPE_LONGDOUBLE:
+ if ((cif->abi & FFI_LINUX_LONG_DOUBLE_128) != 0)
+ {
+ if (pfr + 1 < end_pfr && i + 1 < nfixedargs)
+ {
+ avalue[i] = pfr;
+ pfr += 2;
+ }
+ else
+ {
+ if (pfr < end_pfr && i < nfixedargs)
+ {
+ /* Passed partly in f13 and partly on the stack.
+ Move it all to the stack. */
+ *pst = *(unsigned long *) pfr;
+ pfr++;
+ }
+ avalue[i] = pst;
+ }
+ pst += 2;
+ break;
+ }
+ /* Fall through. */
+#endif
+ case FFI_TYPE_DOUBLE:
+ /* On the outgoing stack all values are aligned to 8 */
+ /* there are 13 64bit floating point registers */
+
+ if (pfr < end_pfr && i < nfixedargs)
+ {
+ avalue[i] = pfr;
+ pfr++;
+ }
+ else
+ avalue[i] = pst;
+ pst++;
+ break;
+
+ case FFI_TYPE_FLOAT:
+ if (pfr < end_pfr && i < nfixedargs)
+ {
+ /* Float values are stored as doubles in the
+ ffi_closure_LINUX64 code. Fix them here. */
+ pfr->f = (float) pfr->d;
+ avalue[i] = pfr;
+ pfr++;
+ }
+ else
+ avalue[i] = pst;
+ pst++;
+ break;
+
+ default:
+ FFI_ASSERT (0);
+ }
+
+ i++;
+ }
+
+
+ (closure->fun) (cif, rvalue, avalue, closure->user_data);
+
+ /* Tell ffi_closure_LINUX64 how to perform return type promotions. */
+ if ((cif->flags & FLAG_RETURNS_SMST) != 0)
+ {
+ if ((cif->flags & FLAG_RETURNS_FP) == 0)
+ return FFI_V2_TYPE_SMALL_STRUCT + cif->rtype->size - 1;
+ else if ((cif->flags & FLAG_RETURNS_64BITS) != 0)
+ return FFI_V2_TYPE_DOUBLE_HOMOG;
+ else
+ return FFI_V2_TYPE_FLOAT_HOMOG;
+ }
+ return cif->rtype->type;
+}
+#endif
diff --git a/jni/ruby/ext/fiddle/libffi-3.2.1/src/powerpc/ffi_powerpc.h b/jni/ruby/ext/fiddle/libffi-3.2.1/src/powerpc/ffi_powerpc.h
new file mode 100644
index 0000000..2e61653
--- /dev/null
+++ b/jni/ruby/ext/fiddle/libffi-3.2.1/src/powerpc/ffi_powerpc.h
@@ -0,0 +1,77 @@
+/* -----------------------------------------------------------------------
+ ffi_powerpc.h - Copyright (C) 2013 IBM
+ Copyright (C) 2011 Anthony Green
+ Copyright (C) 2011 Kyle Moffett
+ Copyright (C) 2008 Red Hat, Inc
+ Copyright (C) 2007, 2008 Free Software Foundation, Inc
+ Copyright (c) 1998 Geoffrey Keating
+
+ PowerPC Foreign Function Interface
+
+ Permission is hereby granted, free of charge, to any person obtaining
+ a copy of this software and associated documentation files (the
+ ``Software''), to deal in the Software without restriction, including
+ without limitation the rights to use, copy, modify, merge, publish,
+ distribute, sublicense, and/or sell copies of the Software, and to
+ permit persons to whom the Software is furnished to do so, subject to
+ the following conditions:
+
+ The above copyright notice and this permission notice shall be included
+ in all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ OTHER DEALINGS IN THE SOFTWARE.
+ ----------------------------------------------------------------------- */
+
+enum {
+ /* The assembly depends on these exact flags. */
+ /* These go in cr7 */
+ FLAG_RETURNS_SMST = 1 << (31-31), /* Used for FFI_SYSV small structs. */
+ FLAG_RETURNS_NOTHING = 1 << (31-30),
+ FLAG_RETURNS_FP = 1 << (31-29),
+ FLAG_RETURNS_64BITS = 1 << (31-28),
+
+ /* This goes in cr6 */
+ FLAG_RETURNS_128BITS = 1 << (31-27),
+
+ FLAG_COMPAT = 1 << (31- 8), /* Not used by assembly */
+
+ /* These go in cr1 */
+ FLAG_ARG_NEEDS_COPY = 1 << (31- 7), /* Used by sysv code */
+ FLAG_ARG_NEEDS_PSAVE = FLAG_ARG_NEEDS_COPY, /* Used by linux64 code */
+ FLAG_FP_ARGUMENTS = 1 << (31- 6), /* cr1.eq; specified by ABI */
+ FLAG_4_GPR_ARGUMENTS = 1 << (31- 5),
+ FLAG_RETVAL_REFERENCE = 1 << (31- 4)
+};
+
+typedef union
+{
+ float f;
+ double d;
+} ffi_dblfl;
+
+void FFI_HIDDEN ffi_closure_SYSV (void);
+void FFI_HIDDEN ffi_call_SYSV(extended_cif *, unsigned, unsigned, unsigned *,
+ void (*)(void));
+
+void FFI_HIDDEN ffi_prep_types_sysv (ffi_abi);
+ffi_status FFI_HIDDEN ffi_prep_cif_sysv (ffi_cif *);
+int FFI_HIDDEN ffi_closure_helper_SYSV (ffi_closure *, void *, unsigned long *,
+ ffi_dblfl *, unsigned long *);
+
+void FFI_HIDDEN ffi_call_LINUX64(extended_cif *, unsigned long, unsigned long,
+ unsigned long *, void (*)(void));
+void FFI_HIDDEN ffi_closure_LINUX64 (void);
+
+void FFI_HIDDEN ffi_prep_types_linux64 (ffi_abi);
+ffi_status FFI_HIDDEN ffi_prep_cif_linux64 (ffi_cif *);
+ffi_status FFI_HIDDEN ffi_prep_cif_linux64_var (ffi_cif *, unsigned int,
+ unsigned int);
+void FFI_HIDDEN ffi_prep_args64 (extended_cif *, unsigned long *const);
+int FFI_HIDDEN ffi_closure_helper_LINUX64 (ffi_closure *, void *,
+ unsigned long *, ffi_dblfl *);
diff --git a/jni/ruby/ext/fiddle/libffi-3.2.1/src/powerpc/ffi_sysv.c b/jni/ruby/ext/fiddle/libffi-3.2.1/src/powerpc/ffi_sysv.c
new file mode 100644
index 0000000..fbe85fe
--- /dev/null
+++ b/jni/ruby/ext/fiddle/libffi-3.2.1/src/powerpc/ffi_sysv.c
@@ -0,0 +1,931 @@
+/* -----------------------------------------------------------------------
+ ffi_sysv.c - Copyright (C) 2013 IBM
+ Copyright (C) 2011 Anthony Green
+ Copyright (C) 2011 Kyle Moffett
+ Copyright (C) 2008 Red Hat, Inc
+ Copyright (C) 2007, 2008 Free Software Foundation, Inc
+ Copyright (c) 1998 Geoffrey Keating
+
+ PowerPC Foreign Function Interface
+
+ Permission is hereby granted, free of charge, to any person obtaining
+ a copy of this software and associated documentation files (the
+ ``Software''), to deal in the Software without restriction, including
+ without limitation the rights to use, copy, modify, merge, publish,
+ distribute, sublicense, and/or sell copies of the Software, and to
+ permit persons to whom the Software is furnished to do so, subject to
+ the following conditions:
+
+ The above copyright notice and this permission notice shall be included
+ in all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ OTHER DEALINGS IN THE SOFTWARE.
+ ----------------------------------------------------------------------- */
+
+#include "ffi.h"
+
+#ifndef POWERPC64
+#include "ffi_common.h"
+#include "ffi_powerpc.h"
+
+
+/* About the SYSV ABI. */
+#define ASM_NEEDS_REGISTERS 4
+#define NUM_GPR_ARG_REGISTERS 8
+#define NUM_FPR_ARG_REGISTERS 8
+
+
+#if HAVE_LONG_DOUBLE_VARIANT && FFI_TYPE_LONGDOUBLE != FFI_TYPE_DOUBLE
+/* Adjust size of ffi_type_longdouble. */
+void FFI_HIDDEN
+ffi_prep_types_sysv (ffi_abi abi)
+{
+ if ((abi & (FFI_SYSV | FFI_SYSV_LONG_DOUBLE_128)) == FFI_SYSV)
+ {
+ ffi_type_longdouble.size = 8;
+ ffi_type_longdouble.alignment = 8;
+ }
+ else
+ {
+ ffi_type_longdouble.size = 16;
+ ffi_type_longdouble.alignment = 16;
+ }
+}
+#endif
+
+/* Transform long double, double and float to other types as per abi. */
+static int
+translate_float (int abi, int type)
+{
+#if FFI_TYPE_LONGDOUBLE != FFI_TYPE_DOUBLE
+ if (type == FFI_TYPE_LONGDOUBLE
+ && (abi & FFI_SYSV_LONG_DOUBLE_128) == 0)
+ type = FFI_TYPE_DOUBLE;
+#endif
+ if ((abi & FFI_SYSV_SOFT_FLOAT) != 0)
+ {
+ if (type == FFI_TYPE_FLOAT)
+ type = FFI_TYPE_UINT32;
+ else if (type == FFI_TYPE_DOUBLE)
+ type = FFI_TYPE_UINT64;
+#if FFI_TYPE_LONGDOUBLE != FFI_TYPE_DOUBLE
+ else if (type == FFI_TYPE_LONGDOUBLE)
+ type = FFI_TYPE_UINT128;
+ }
+ else if ((abi & FFI_SYSV_IBM_LONG_DOUBLE) == 0)
+ {
+ if (type == FFI_TYPE_LONGDOUBLE)
+ type = FFI_TYPE_STRUCT;
+#endif
+ }
+ return type;
+}
+
+/* Perform machine dependent cif processing */
+static ffi_status
+ffi_prep_cif_sysv_core (ffi_cif *cif)
+{
+ ffi_type **ptr;
+ unsigned bytes;
+ unsigned i, fparg_count = 0, intarg_count = 0;
+ unsigned flags = cif->flags;
+ unsigned struct_copy_size = 0;
+ unsigned type = cif->rtype->type;
+ unsigned size = cif->rtype->size;
+
+ /* The machine-independent calculation of cif->bytes doesn't work
+ for us. Redo the calculation. */
+
+ /* Space for the frame pointer, callee's LR, and the asm's temp regs. */
+ bytes = (2 + ASM_NEEDS_REGISTERS) * sizeof (int);
+
+ /* Space for the GPR registers. */
+ bytes += NUM_GPR_ARG_REGISTERS * sizeof (int);
+
+ /* Return value handling. The rules for SYSV are as follows:
+ - 32-bit (or less) integer values are returned in gpr3;
+ - Structures of size <= 4 bytes also returned in gpr3;
+ - 64-bit integer values and structures between 5 and 8 bytes are returned
+ in gpr3 and gpr4;
+ - Larger structures are allocated space and a pointer is passed as
+ the first argument.
+ - Single/double FP values are returned in fpr1;
+ - long doubles (if not equivalent to double) are returned in
+ fpr1,fpr2 for Linux and as for large structs for SysV. */
+
+ type = translate_float (cif->abi, type);
+
+ switch (type)
+ {
+#if FFI_TYPE_LONGDOUBLE != FFI_TYPE_DOUBLE
+ case FFI_TYPE_LONGDOUBLE:
+ flags |= FLAG_RETURNS_128BITS;
+ /* Fall through. */
+#endif
+ case FFI_TYPE_DOUBLE:
+ flags |= FLAG_RETURNS_64BITS;
+ /* Fall through. */
+ case FFI_TYPE_FLOAT:
+ flags |= FLAG_RETURNS_FP;
+#ifdef __NO_FPRS__
+ return FFI_BAD_ABI;
+#endif
+ break;
+
+ case FFI_TYPE_UINT128:
+ flags |= FLAG_RETURNS_128BITS;
+ /* Fall through. */
+ case FFI_TYPE_UINT64:
+ case FFI_TYPE_SINT64:
+ flags |= FLAG_RETURNS_64BITS;
+ break;
+
+ case FFI_TYPE_STRUCT:
+ /* The final SYSV ABI says that structures smaller or equal 8 bytes
+ are returned in r3/r4. A draft ABI used by linux instead
+ returns them in memory. */
+ if ((cif->abi & FFI_SYSV_STRUCT_RET) != 0 && size <= 8)
+ {
+ flags |= FLAG_RETURNS_SMST;
+ break;
+ }
+ intarg_count++;
+ flags |= FLAG_RETVAL_REFERENCE;
+ /* Fall through. */
+ case FFI_TYPE_VOID:
+ flags |= FLAG_RETURNS_NOTHING;
+ break;
+
+ default:
+ /* Returns 32-bit integer, or similar. Nothing to do here. */
+ break;
+ }
+
+ /* The first NUM_GPR_ARG_REGISTERS words of integer arguments, and the
+ first NUM_FPR_ARG_REGISTERS fp arguments, go in registers; the rest
+ goes on the stack. Structures and long doubles (if not equivalent
+ to double) are passed as a pointer to a copy of the structure.
+ Stuff on the stack needs to keep proper alignment. */
+ for (ptr = cif->arg_types, i = cif->nargs; i > 0; i--, ptr++)
+ {
+ unsigned short typenum = (*ptr)->type;
+
+ typenum = translate_float (cif->abi, typenum);
+
+ switch (typenum)
+ {
+#if FFI_TYPE_LONGDOUBLE != FFI_TYPE_DOUBLE
+ case FFI_TYPE_LONGDOUBLE:
+ fparg_count++;
+ /* Fall thru */
+#endif
+ case FFI_TYPE_DOUBLE:
+ fparg_count++;
+ /* If this FP arg is going on the stack, it must be
+ 8-byte-aligned. */
+ if (fparg_count > NUM_FPR_ARG_REGISTERS
+ && intarg_count >= NUM_GPR_ARG_REGISTERS
+ && intarg_count % 2 != 0)
+ intarg_count++;
+#ifdef __NO_FPRS__
+ return FFI_BAD_ABI;
+#endif
+ break;
+
+ case FFI_TYPE_FLOAT:
+ fparg_count++;
+#ifdef __NO_FPRS__
+ return FFI_BAD_ABI;
+#endif
+ break;
+
+ case FFI_TYPE_UINT128:
+ /* A long double in FFI_LINUX_SOFT_FLOAT can use only a set
+ of four consecutive gprs. If we do not have enough, we
+ have to adjust the intarg_count value. */
+ if (intarg_count >= NUM_GPR_ARG_REGISTERS - 3
+ && intarg_count < NUM_GPR_ARG_REGISTERS)
+ intarg_count = NUM_GPR_ARG_REGISTERS;
+ intarg_count += 4;
+ break;
+
+ case FFI_TYPE_UINT64:
+ case FFI_TYPE_SINT64:
+ /* 'long long' arguments are passed as two words, but
+ either both words must fit in registers or both go
+ on the stack. If they go on the stack, they must
+ be 8-byte-aligned.
+
+ Also, only certain register pairs can be used for
+ passing long long int -- specifically (r3,r4), (r5,r6),
+ (r7,r8), (r9,r10). */
+ if (intarg_count == NUM_GPR_ARG_REGISTERS-1
+ || intarg_count % 2 != 0)
+ intarg_count++;
+ intarg_count += 2;
+ break;
+
+ case FFI_TYPE_STRUCT:
+ /* We must allocate space for a copy of these to enforce
+ pass-by-value. Pad the space up to a multiple of 16
+ bytes (the maximum alignment required for anything under
+ the SYSV ABI). */
+ struct_copy_size += ((*ptr)->size + 15) & ~0xF;
+ /* Fall through (allocate space for the pointer). */
+
+ case FFI_TYPE_POINTER:
+ case FFI_TYPE_INT:
+ case FFI_TYPE_UINT32:
+ case FFI_TYPE_SINT32:
+ case FFI_TYPE_UINT16:
+ case FFI_TYPE_SINT16:
+ case FFI_TYPE_UINT8:
+ case FFI_TYPE_SINT8:
+ /* Everything else is passed as a 4-byte word in a GPR, either
+ the object itself or a pointer to it. */
+ intarg_count++;
+ break;
+
+ default:
+ FFI_ASSERT (0);
+ }
+ }
+
+ if (fparg_count != 0)
+ flags |= FLAG_FP_ARGUMENTS;
+ if (intarg_count > 4)
+ flags |= FLAG_4_GPR_ARGUMENTS;
+ if (struct_copy_size != 0)
+ flags |= FLAG_ARG_NEEDS_COPY;
+
+ /* Space for the FPR registers, if needed. */
+ if (fparg_count != 0)
+ bytes += NUM_FPR_ARG_REGISTERS * sizeof (double);
+
+ /* Stack space. */
+ if (intarg_count > NUM_GPR_ARG_REGISTERS)
+ bytes += (intarg_count - NUM_GPR_ARG_REGISTERS) * sizeof (int);
+ if (fparg_count > NUM_FPR_ARG_REGISTERS)
+ bytes += (fparg_count - NUM_FPR_ARG_REGISTERS) * sizeof (double);
+
+ /* The stack space allocated needs to be a multiple of 16 bytes. */
+ bytes = (bytes + 15) & ~0xF;
+
+ /* Add in the space for the copied structures. */
+ bytes += struct_copy_size;
+
+ cif->flags = flags;
+ cif->bytes = bytes;
+
+ return FFI_OK;
+}
+
+ffi_status FFI_HIDDEN
+ffi_prep_cif_sysv (ffi_cif *cif)
+{
+ if ((cif->abi & FFI_SYSV) == 0)
+ {
+ /* This call is from old code. Translate to new ABI values. */
+ cif->flags |= FLAG_COMPAT;
+ switch (cif->abi)
+ {
+ default:
+ return FFI_BAD_ABI;
+
+ case FFI_COMPAT_SYSV:
+ cif->abi = FFI_SYSV | FFI_SYSV_STRUCT_RET | FFI_SYSV_LONG_DOUBLE_128;
+ break;
+
+ case FFI_COMPAT_GCC_SYSV:
+ cif->abi = FFI_SYSV | FFI_SYSV_LONG_DOUBLE_128;
+ break;
+
+ case FFI_COMPAT_LINUX:
+ cif->abi = (FFI_SYSV | FFI_SYSV_IBM_LONG_DOUBLE
+ | FFI_SYSV_LONG_DOUBLE_128);
+ break;
+
+ case FFI_COMPAT_LINUX_SOFT_FLOAT:
+ cif->abi = (FFI_SYSV | FFI_SYSV_SOFT_FLOAT | FFI_SYSV_IBM_LONG_DOUBLE
+ | FFI_SYSV_LONG_DOUBLE_128);
+ break;
+ }
+ }
+ return ffi_prep_cif_sysv_core (cif);
+}
+
+/* ffi_prep_args_SYSV is called by the assembly routine once stack space
+ has been allocated for the function's arguments.
+
+ The stack layout we want looks like this:
+
+ | Return address from ffi_call_SYSV 4bytes | higher addresses
+ |--------------------------------------------|
+ | Previous backchain pointer 4 | stack pointer here
+ |--------------------------------------------|<+ <<< on entry to
+ | Saved r28-r31 4*4 | | ffi_call_SYSV
+ |--------------------------------------------| |
+ | GPR registers r3-r10 8*4 | | ffi_call_SYSV
+ |--------------------------------------------| |
+ | FPR registers f1-f8 (optional) 8*8 | |
+ |--------------------------------------------| | stack |
+ | Space for copied structures | | grows |
+ |--------------------------------------------| | down V
+ | Parameters that didn't fit in registers | |
+ |--------------------------------------------| | lower addresses
+ | Space for callee's LR 4 | |
+ |--------------------------------------------| | stack pointer here
+ | Current backchain pointer 4 |-/ during
+ |--------------------------------------------| <<< ffi_call_SYSV
+
+*/
+
+void FFI_HIDDEN
+ffi_prep_args_SYSV (extended_cif *ecif, unsigned *const stack)
+{
+ const unsigned bytes = ecif->cif->bytes;
+ const unsigned flags = ecif->cif->flags;
+
+ typedef union
+ {
+ char *c;
+ unsigned *u;
+ long long *ll;
+ float *f;
+ double *d;
+ } valp;
+
+ /* 'stacktop' points at the previous backchain pointer. */
+ valp stacktop;
+
+ /* 'gpr_base' points at the space for gpr3, and grows upwards as
+ we use GPR registers. */
+ valp gpr_base;
+ int intarg_count;
+
+#ifndef __NO_FPRS__
+ /* 'fpr_base' points at the space for fpr1, and grows upwards as
+ we use FPR registers. */
+ valp fpr_base;
+ int fparg_count;
+#endif
+
+ /* 'copy_space' grows down as we put structures in it. It should
+ stay 16-byte aligned. */
+ valp copy_space;
+
+ /* 'next_arg' grows up as we put parameters in it. */
+ valp next_arg;
+
+ int i;
+ ffi_type **ptr;
+#ifndef __NO_FPRS__
+ double double_tmp;
+#endif
+ union
+ {
+ void **v;
+ char **c;
+ signed char **sc;
+ unsigned char **uc;
+ signed short **ss;
+ unsigned short **us;
+ unsigned int **ui;
+ long long **ll;
+ float **f;
+ double **d;
+ } p_argv;
+ size_t struct_copy_size;
+ unsigned gprvalue;
+
+ stacktop.c = (char *) stack + bytes;
+ gpr_base.u = stacktop.u - ASM_NEEDS_REGISTERS - NUM_GPR_ARG_REGISTERS;
+ intarg_count = 0;
+#ifndef __NO_FPRS__
+ fpr_base.d = gpr_base.d - NUM_FPR_ARG_REGISTERS;
+ fparg_count = 0;
+ copy_space.c = ((flags & FLAG_FP_ARGUMENTS) ? fpr_base.c : gpr_base.c);
+#else
+ copy_space.c = gpr_base.c;
+#endif
+ next_arg.u = stack + 2;
+
+ /* Check that everything starts aligned properly. */
+ FFI_ASSERT (((unsigned long) (char *) stack & 0xF) == 0);
+ FFI_ASSERT (((unsigned long) copy_space.c & 0xF) == 0);
+ FFI_ASSERT (((unsigned long) stacktop.c & 0xF) == 0);
+ FFI_ASSERT ((bytes & 0xF) == 0);
+ FFI_ASSERT (copy_space.c >= next_arg.c);
+
+ /* Deal with return values that are actually pass-by-reference. */
+ if (flags & FLAG_RETVAL_REFERENCE)
+ {
+ *gpr_base.u++ = (unsigned long) (char *) ecif->rvalue;
+ intarg_count++;
+ }
+
+ /* Now for the arguments. */
+ p_argv.v = ecif->avalue;
+ for (ptr = ecif->cif->arg_types, i = ecif->cif->nargs;
+ i > 0;
+ i--, ptr++, p_argv.v++)
+ {
+ unsigned int typenum = (*ptr)->type;
+
+ typenum = translate_float (ecif->cif->abi, typenum);
+
+ /* Now test the translated value */
+ switch (typenum)
+ {
+#ifndef __NO_FPRS__
+# if FFI_TYPE_LONGDOUBLE != FFI_TYPE_DOUBLE
+ case FFI_TYPE_LONGDOUBLE:
+ double_tmp = (*p_argv.d)[0];
+
+ if (fparg_count >= NUM_FPR_ARG_REGISTERS - 1)
+ {
+ if (intarg_count >= NUM_GPR_ARG_REGISTERS
+ && intarg_count % 2 != 0)
+ {
+ intarg_count++;
+ next_arg.u++;
+ }
+ *next_arg.d = double_tmp;
+ next_arg.u += 2;
+ double_tmp = (*p_argv.d)[1];
+ *next_arg.d = double_tmp;
+ next_arg.u += 2;
+ }
+ else
+ {
+ *fpr_base.d++ = double_tmp;
+ double_tmp = (*p_argv.d)[1];
+ *fpr_base.d++ = double_tmp;
+ }
+
+ fparg_count += 2;
+ FFI_ASSERT (flags & FLAG_FP_ARGUMENTS);
+ break;
+# endif
+ case FFI_TYPE_DOUBLE:
+ double_tmp = **p_argv.d;
+
+ if (fparg_count >= NUM_FPR_ARG_REGISTERS)
+ {
+ if (intarg_count >= NUM_GPR_ARG_REGISTERS
+ && intarg_count % 2 != 0)
+ {
+ intarg_count++;
+ next_arg.u++;
+ }
+ *next_arg.d = double_tmp;
+ next_arg.u += 2;
+ }
+ else
+ *fpr_base.d++ = double_tmp;
+ fparg_count++;
+ FFI_ASSERT (flags & FLAG_FP_ARGUMENTS);
+ break;
+
+ case FFI_TYPE_FLOAT:
+ double_tmp = **p_argv.f;
+ if (fparg_count >= NUM_FPR_ARG_REGISTERS)
+ {
+ *next_arg.f = (float) double_tmp;
+ next_arg.u += 1;
+ intarg_count++;
+ }
+ else
+ *fpr_base.d++ = double_tmp;
+ fparg_count++;
+ FFI_ASSERT (flags & FLAG_FP_ARGUMENTS);
+ break;
+#endif /* have FPRs */
+
+ case FFI_TYPE_UINT128:
+ /* The soft float ABI for long doubles works like this, a long double
+ is passed in four consecutive GPRs if available. A maximum of 2
+ long doubles can be passed in gprs. If we do not have 4 GPRs
+ left, the long double is passed on the stack, 4-byte aligned. */
+ {
+ unsigned int int_tmp;
+ unsigned int ii;
+ if (intarg_count >= NUM_GPR_ARG_REGISTERS - 3)
+ {
+ if (intarg_count < NUM_GPR_ARG_REGISTERS)
+ intarg_count = NUM_GPR_ARG_REGISTERS;
+ for (ii = 0; ii < 4; ii++)
+ {
+ int_tmp = (*p_argv.ui)[ii];
+ *next_arg.u++ = int_tmp;
+ }
+ }
+ else
+ {
+ for (ii = 0; ii < 4; ii++)
+ {
+ int_tmp = (*p_argv.ui)[ii];
+ *gpr_base.u++ = int_tmp;
+ }
+ }
+ intarg_count += 4;
+ break;
+ }
+
+ case FFI_TYPE_UINT64:
+ case FFI_TYPE_SINT64:
+ if (intarg_count == NUM_GPR_ARG_REGISTERS-1)
+ intarg_count++;
+ if (intarg_count >= NUM_GPR_ARG_REGISTERS)
+ {
+ if (intarg_count % 2 != 0)
+ {
+ intarg_count++;
+ next_arg.u++;
+ }
+ *next_arg.ll = **p_argv.ll;
+ next_arg.u += 2;
+ }
+ else
+ {
+ /* The abi states only certain register pairs can be
+ used for passing long long int specifically (r3,r4),
+ (r5,r6), (r7,r8), (r9,r10). If next arg is long long
+ but not correct starting register of pair then skip
+ until the proper starting register. */
+ if (intarg_count % 2 != 0)
+ {
+ intarg_count ++;
+ gpr_base.u++;
+ }
+ *gpr_base.ll++ = **p_argv.ll;
+ }
+ intarg_count += 2;
+ break;
+
+ case FFI_TYPE_STRUCT:
+ struct_copy_size = ((*ptr)->size + 15) & ~0xF;
+ copy_space.c -= struct_copy_size;
+ memcpy (copy_space.c, *p_argv.c, (*ptr)->size);
+
+ gprvalue = (unsigned long) copy_space.c;
+
+ FFI_ASSERT (copy_space.c > next_arg.c);
+ FFI_ASSERT (flags & FLAG_ARG_NEEDS_COPY);
+ goto putgpr;
+
+ case FFI_TYPE_UINT8:
+ gprvalue = **p_argv.uc;
+ goto putgpr;
+ case FFI_TYPE_SINT8:
+ gprvalue = **p_argv.sc;
+ goto putgpr;
+ case FFI_TYPE_UINT16:
+ gprvalue = **p_argv.us;
+ goto putgpr;
+ case FFI_TYPE_SINT16:
+ gprvalue = **p_argv.ss;
+ goto putgpr;
+
+ case FFI_TYPE_INT:
+ case FFI_TYPE_UINT32:
+ case FFI_TYPE_SINT32:
+ case FFI_TYPE_POINTER:
+
+ gprvalue = **p_argv.ui;
+
+ putgpr:
+ if (intarg_count >= NUM_GPR_ARG_REGISTERS)
+ *next_arg.u++ = gprvalue;
+ else
+ *gpr_base.u++ = gprvalue;
+ intarg_count++;
+ break;
+ }
+ }
+
+ /* Check that we didn't overrun the stack... */
+ FFI_ASSERT (copy_space.c >= next_arg.c);
+ FFI_ASSERT (gpr_base.u <= stacktop.u - ASM_NEEDS_REGISTERS);
+ /* The assert below is testing that the number of integer arguments agrees
+ with the number found in ffi_prep_cif_machdep(). However, intarg_count
+ is incremented whenever we place an FP arg on the stack, so account for
+ that before our assert test. */
+#ifndef __NO_FPRS__
+ if (fparg_count > NUM_FPR_ARG_REGISTERS)
+ intarg_count -= fparg_count - NUM_FPR_ARG_REGISTERS;
+ FFI_ASSERT (fpr_base.u
+ <= stacktop.u - ASM_NEEDS_REGISTERS - NUM_GPR_ARG_REGISTERS);
+#endif
+ FFI_ASSERT (flags & FLAG_4_GPR_ARGUMENTS || intarg_count <= 4);
+}
+
+#define MIN_CACHE_LINE_SIZE 8
+
+static void
+flush_icache (char *wraddr, char *xaddr, int size)
+{
+ int i;
+ for (i = 0; i < size; i += MIN_CACHE_LINE_SIZE)
+ __asm__ volatile ("icbi 0,%0;" "dcbf 0,%1;"
+ : : "r" (xaddr + i), "r" (wraddr + i) : "memory");
+ __asm__ volatile ("icbi 0,%0;" "dcbf 0,%1;" "sync;" "isync;"
+ : : "r"(xaddr + size - 1), "r"(wraddr + size - 1)
+ : "memory");
+}
+
+ffi_status FFI_HIDDEN
+ffi_prep_closure_loc_sysv (ffi_closure *closure,
+ ffi_cif *cif,
+ void (*fun) (ffi_cif *, void *, void **, void *),
+ void *user_data,
+ void *codeloc)
+{
+ unsigned int *tramp;
+
+ if (cif->abi < FFI_SYSV || cif->abi >= FFI_LAST_ABI)
+ return FFI_BAD_ABI;
+
+ tramp = (unsigned int *) &closure->tramp[0];
+ tramp[0] = 0x7c0802a6; /* mflr r0 */
+ tramp[1] = 0x4800000d; /* bl 10 <trampoline_initial+0x10> */
+ tramp[4] = 0x7d6802a6; /* mflr r11 */
+ tramp[5] = 0x7c0803a6; /* mtlr r0 */
+ tramp[6] = 0x800b0000; /* lwz r0,0(r11) */
+ tramp[7] = 0x816b0004; /* lwz r11,4(r11) */
+ tramp[8] = 0x7c0903a6; /* mtctr r0 */
+ tramp[9] = 0x4e800420; /* bctr */
+ *(void **) &tramp[2] = (void *) ffi_closure_SYSV; /* function */
+ *(void **) &tramp[3] = codeloc; /* context */
+
+ /* Flush the icache. */
+ flush_icache ((char *)tramp, (char *)codeloc, FFI_TRAMPOLINE_SIZE);
+
+ closure->cif = cif;
+ closure->fun = fun;
+ closure->user_data = user_data;
+
+ return FFI_OK;
+}
+
+/* Basically the trampoline invokes ffi_closure_SYSV, and on
+ entry, r11 holds the address of the closure.
+ After storing the registers that could possibly contain
+ parameters to be passed into the stack frame and setting
+ up space for a return value, ffi_closure_SYSV invokes the
+ following helper function to do most of the work. */
+
+int
+ffi_closure_helper_SYSV (ffi_closure *closure, void *rvalue,
+ unsigned long *pgr, ffi_dblfl *pfr,
+ unsigned long *pst)
+{
+ /* rvalue is the pointer to space for return value in closure assembly */
+ /* pgr is the pointer to where r3-r10 are stored in ffi_closure_SYSV */
+ /* pfr is the pointer to where f1-f8 are stored in ffi_closure_SYSV */
+ /* pst is the pointer to outgoing parameter stack in original caller */
+
+ void ** avalue;
+ ffi_type ** arg_types;
+ long i, avn;
+#ifndef __NO_FPRS__
+ long nf = 0; /* number of floating registers already used */
+#endif
+ long ng = 0; /* number of general registers already used */
+
+ ffi_cif *cif = closure->cif;
+ unsigned size = cif->rtype->size;
+ unsigned short rtypenum = cif->rtype->type;
+
+ avalue = alloca (cif->nargs * sizeof (void *));
+
+ /* First translate for softfloat/nonlinux */
+ rtypenum = translate_float (cif->abi, rtypenum);
+
+ /* Copy the caller's structure return value address so that the closure
+ returns the data directly to the caller.
+ For FFI_SYSV the result is passed in r3/r4 if the struct size is less
+ or equal 8 bytes. */
+ if (rtypenum == FFI_TYPE_STRUCT
+ && !((cif->abi & FFI_SYSV_STRUCT_RET) != 0 && size <= 8))
+ {
+ rvalue = (void *) *pgr;
+ ng++;
+ pgr++;
+ }
+
+ i = 0;
+ avn = cif->nargs;
+ arg_types = cif->arg_types;
+
+ /* Grab the addresses of the arguments from the stack frame. */
+ while (i < avn) {
+ unsigned short typenum = arg_types[i]->type;
+
+ /* We may need to handle some values depending on ABI. */
+ typenum = translate_float (cif->abi, typenum);
+
+ switch (typenum)
+ {
+#ifndef __NO_FPRS__
+ case FFI_TYPE_FLOAT:
+ /* Unfortunately float values are stored as doubles
+ in the ffi_closure_SYSV code (since we don't check
+ the type in that routine). */
+ if (nf < NUM_FPR_ARG_REGISTERS)
+ {
+ /* FIXME? here we are really changing the values
+ stored in the original calling routines outgoing
+ parameter stack. This is probably a really
+ naughty thing to do but... */
+ double temp = pfr->d;
+ pfr->f = (float) temp;
+ avalue[i] = pfr;
+ nf++;
+ pfr++;
+ }
+ else
+ {
+ avalue[i] = pst;
+ pst += 1;
+ }
+ break;
+
+ case FFI_TYPE_DOUBLE:
+ if (nf < NUM_FPR_ARG_REGISTERS)
+ {
+ avalue[i] = pfr;
+ nf++;
+ pfr++;
+ }
+ else
+ {
+ if (((long) pst) & 4)
+ pst++;
+ avalue[i] = pst;
+ pst += 2;
+ }
+ break;
+
+# if FFI_TYPE_LONGDOUBLE != FFI_TYPE_DOUBLE
+ case FFI_TYPE_LONGDOUBLE:
+ if (nf < NUM_FPR_ARG_REGISTERS - 1)
+ {
+ avalue[i] = pfr;
+ pfr += 2;
+ nf += 2;
+ }
+ else
+ {
+ if (((long) pst) & 4)
+ pst++;
+ avalue[i] = pst;
+ pst += 4;
+ nf = 8;
+ }
+ break;
+# endif
+#endif
+
+ case FFI_TYPE_UINT128:
+ /* Test if for the whole long double, 4 gprs are available.
+ otherwise the stuff ends up on the stack. */
+ if (ng < NUM_GPR_ARG_REGISTERS - 3)
+ {
+ avalue[i] = pgr;
+ pgr += 4;
+ ng += 4;
+ }
+ else
+ {
+ avalue[i] = pst;
+ pst += 4;
+ ng = 8+4;
+ }
+ break;
+
+ case FFI_TYPE_SINT8:
+ case FFI_TYPE_UINT8:
+#ifndef __LITTLE_ENDIAN__
+ if (ng < NUM_GPR_ARG_REGISTERS)
+ {
+ avalue[i] = (char *) pgr + 3;
+ ng++;
+ pgr++;
+ }
+ else
+ {
+ avalue[i] = (char *) pst + 3;
+ pst++;
+ }
+ break;
+#endif
+
+ case FFI_TYPE_SINT16:
+ case FFI_TYPE_UINT16:
+#ifndef __LITTLE_ENDIAN__
+ if (ng < NUM_GPR_ARG_REGISTERS)
+ {
+ avalue[i] = (char *) pgr + 2;
+ ng++;
+ pgr++;
+ }
+ else
+ {
+ avalue[i] = (char *) pst + 2;
+ pst++;
+ }
+ break;
+#endif
+
+ case FFI_TYPE_SINT32:
+ case FFI_TYPE_UINT32:
+ case FFI_TYPE_POINTER:
+ if (ng < NUM_GPR_ARG_REGISTERS)
+ {
+ avalue[i] = pgr;
+ ng++;
+ pgr++;
+ }
+ else
+ {
+ avalue[i] = pst;
+ pst++;
+ }
+ break;
+
+ case FFI_TYPE_STRUCT:
+ /* Structs are passed by reference. The address will appear in a
+ gpr if it is one of the first 8 arguments. */
+ if (ng < NUM_GPR_ARG_REGISTERS)
+ {
+ avalue[i] = (void *) *pgr;
+ ng++;
+ pgr++;
+ }
+ else
+ {
+ avalue[i] = (void *) *pst;
+ pst++;
+ }
+ break;
+
+ case FFI_TYPE_SINT64:
+ case FFI_TYPE_UINT64:
+ /* Passing long long ints are complex, they must
+ be passed in suitable register pairs such as
+ (r3,r4) or (r5,r6) or (r6,r7), or (r7,r8) or (r9,r10)
+ and if the entire pair aren't available then the outgoing
+ parameter stack is used for both but an alignment of 8
+ must will be kept. So we must either look in pgr
+ or pst to find the correct address for this type
+ of parameter. */
+ if (ng < NUM_GPR_ARG_REGISTERS - 1)
+ {
+ if (ng & 1)
+ {
+ /* skip r4, r6, r8 as starting points */
+ ng++;
+ pgr++;
+ }
+ avalue[i] = pgr;
+ ng += 2;
+ pgr += 2;
+ }
+ else
+ {
+ if (((long) pst) & 4)
+ pst++;
+ avalue[i] = pst;
+ pst += 2;
+ ng = NUM_GPR_ARG_REGISTERS;
+ }
+ break;
+
+ default:
+ FFI_ASSERT (0);
+ }
+
+ i++;
+ }
+
+ (closure->fun) (cif, rvalue, avalue, closure->user_data);
+
+ /* Tell ffi_closure_SYSV how to perform return type promotions.
+ Because the FFI_SYSV ABI returns the structures <= 8 bytes in
+ r3/r4 we have to tell ffi_closure_SYSV how to treat them. We
+ combine the base type FFI_SYSV_TYPE_SMALL_STRUCT with the size of
+ the struct less one. We never have a struct with size zero.
+ See the comment in ffitarget.h about ordering. */
+ if (rtypenum == FFI_TYPE_STRUCT
+ && (cif->abi & FFI_SYSV_STRUCT_RET) != 0 && size <= 8)
+ return FFI_SYSV_TYPE_SMALL_STRUCT - 1 + size;
+ return rtypenum;
+}
+#endif
diff --git a/jni/ruby/ext/fiddle/libffi-3.2.1/src/powerpc/ffitarget.h b/jni/ruby/ext/fiddle/libffi-3.2.1/src/powerpc/ffitarget.h
new file mode 100644
index 0000000..b47b0f5
--- /dev/null
+++ b/jni/ruby/ext/fiddle/libffi-3.2.1/src/powerpc/ffitarget.h
@@ -0,0 +1,183 @@
+/* -----------------------------------------------------------------*-C-*-
+ ffitarget.h - Copyright (c) 2012 Anthony Green
+ Copyright (C) 2007, 2008, 2010 Free Software Foundation, Inc
+ Copyright (c) 1996-2003 Red Hat, Inc.
+
+ Target configuration macros for PowerPC.
+
+ Permission is hereby granted, free of charge, to any person obtaining
+ a copy of this software and associated documentation files (the
+ ``Software''), to deal in the Software without restriction, including
+ without limitation the rights to use, copy, modify, merge, publish,
+ distribute, sublicense, and/or sell copies of the Software, and to
+ permit persons to whom the Software is furnished to do so, subject to
+ the following conditions:
+
+ The above copyright notice and this permission notice shall be included
+ in all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND,
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+ HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ DEALINGS IN THE SOFTWARE.
+
+ ----------------------------------------------------------------------- */
+
+#ifndef LIBFFI_TARGET_H
+#define LIBFFI_TARGET_H
+
+#ifndef LIBFFI_H
+#error "Please do not include ffitarget.h directly into your source. Use ffi.h instead."
+#endif
+
+/* ---- System specific configurations ----------------------------------- */
+
+#if defined (POWERPC) && defined (__powerpc64__) /* linux64 */
+#ifndef POWERPC64
+#define POWERPC64
+#endif
+#elif defined (POWERPC_DARWIN) && defined (__ppc64__) /* Darwin64 */
+#ifndef POWERPC64
+#define POWERPC64
+#endif
+#ifndef POWERPC_DARWIN64
+#define POWERPC_DARWIN64
+#endif
+#elif defined (POWERPC_AIX) && defined (__64BIT__) /* AIX64 */
+#ifndef POWERPC64
+#define POWERPC64
+#endif
+#endif
+
+#ifndef LIBFFI_ASM
+typedef unsigned long ffi_arg;
+typedef signed long ffi_sarg;
+
+typedef enum ffi_abi {
+ FFI_FIRST_ABI = 0,
+
+#if defined (POWERPC_AIX)
+ FFI_AIX,
+ FFI_DARWIN,
+ FFI_DEFAULT_ABI = FFI_AIX,
+ FFI_LAST_ABI
+
+#elif defined (POWERPC_DARWIN)
+ FFI_AIX,
+ FFI_DARWIN,
+ FFI_DEFAULT_ABI = FFI_DARWIN,
+ FFI_LAST_ABI
+
+#else
+ /* The FFI_COMPAT values are used by old code. Since libffi may be
+ a shared library we have to support old values for backwards
+ compatibility. */
+ FFI_COMPAT_SYSV,
+ FFI_COMPAT_GCC_SYSV,
+ FFI_COMPAT_LINUX64,
+ FFI_COMPAT_LINUX,
+ FFI_COMPAT_LINUX_SOFT_FLOAT,
+
+# if defined (POWERPC64)
+ /* This bit, always set in new code, must not be set in any of the
+ old FFI_COMPAT values that might be used for 64-bit linux. We
+ only need worry about FFI_COMPAT_LINUX64, but to be safe avoid
+ all old values. */
+ FFI_LINUX = 8,
+ /* This and following bits can reuse FFI_COMPAT values. */
+ FFI_LINUX_STRUCT_ALIGN = 1,
+ FFI_LINUX_LONG_DOUBLE_128 = 2,
+ FFI_DEFAULT_ABI = (FFI_LINUX
+# ifdef __STRUCT_PARM_ALIGN__
+ | FFI_LINUX_STRUCT_ALIGN
+# endif
+# ifdef __LONG_DOUBLE_128__
+ | FFI_LINUX_LONG_DOUBLE_128
+# endif
+ ),
+ FFI_LAST_ABI = 12
+
+# else
+ /* This bit, always set in new code, must not be set in any of the
+ old FFI_COMPAT values that might be used for 32-bit linux/sysv/bsd. */
+ FFI_SYSV = 8,
+ /* This and following bits can reuse FFI_COMPAT values. */
+ FFI_SYSV_SOFT_FLOAT = 1,
+ FFI_SYSV_STRUCT_RET = 2,
+ FFI_SYSV_IBM_LONG_DOUBLE = 4,
+ FFI_SYSV_LONG_DOUBLE_128 = 16,
+
+ FFI_DEFAULT_ABI = (FFI_SYSV
+# ifdef __NO_FPRS__
+ | FFI_SYSV_SOFT_FLOAT
+# endif
+# if (defined (__SVR4_STRUCT_RETURN) \
+ || defined (POWERPC_FREEBSD) && !defined (__AIX_STRUCT_RETURN))
+ | FFI_SYSV_STRUCT_RET
+# endif
+# if __LDBL_MANT_DIG__ == 106
+ | FFI_SYSV_IBM_LONG_DOUBLE
+# endif
+# ifdef __LONG_DOUBLE_128__
+ | FFI_SYSV_LONG_DOUBLE_128
+# endif
+ ),
+ FFI_LAST_ABI = 32
+# endif
+#endif
+
+} ffi_abi;
+#endif
+
+/* ---- Definitions for closures ----------------------------------------- */
+
+#define FFI_CLOSURES 1
+#define FFI_NATIVE_RAW_API 0
+#if defined (POWERPC) || defined (POWERPC_FREEBSD)
+# define FFI_TARGET_SPECIFIC_VARIADIC 1
+# define FFI_EXTRA_CIF_FIELDS unsigned nfixedargs
+#endif
+
+/* For additional types like the below, take care about the order in
+ ppc_closures.S. They must follow after the FFI_TYPE_LAST. */
+
+/* Needed for soft-float long-double-128 support. */
+#define FFI_TYPE_UINT128 (FFI_TYPE_LAST + 1)
+
+/* Needed for FFI_SYSV small structure returns. */
+#define FFI_SYSV_TYPE_SMALL_STRUCT (FFI_TYPE_LAST + 2)
+
+/* Used by ELFv2 for homogenous structure returns. */
+#define FFI_V2_TYPE_FLOAT_HOMOG (FFI_TYPE_LAST + 1)
+#define FFI_V2_TYPE_DOUBLE_HOMOG (FFI_TYPE_LAST + 2)
+#define FFI_V2_TYPE_SMALL_STRUCT (FFI_TYPE_LAST + 3)
+
+#if _CALL_ELF == 2
+# define FFI_TRAMPOLINE_SIZE 32
+#else
+# if defined(POWERPC64) || defined(POWERPC_AIX)
+# if defined(POWERPC_DARWIN64)
+# define FFI_TRAMPOLINE_SIZE 48
+# else
+# define FFI_TRAMPOLINE_SIZE 24
+# endif
+# else /* POWERPC || POWERPC_AIX */
+# define FFI_TRAMPOLINE_SIZE 40
+# endif
+#endif
+
+#ifndef LIBFFI_ASM
+#if defined(POWERPC_DARWIN) || defined(POWERPC_AIX)
+struct ffi_aix_trampoline_struct {
+ void * code_pointer; /* Pointer to ffi_closure_ASM */
+ void * toc; /* TOC */
+ void * static_chain; /* Pointer to closure */
+};
+#endif
+#endif
+
+#endif
diff --git a/jni/ruby/ext/fiddle/libffi-3.2.1/src/powerpc/linux64.S b/jni/ruby/ext/fiddle/libffi-3.2.1/src/powerpc/linux64.S
new file mode 100644
index 0000000..d2acb70
--- /dev/null
+++ b/jni/ruby/ext/fiddle/libffi-3.2.1/src/powerpc/linux64.S
@@ -0,0 +1,261 @@
+/* -----------------------------------------------------------------------
+ sysv.h - Copyright (c) 2003 Jakub Jelinek <jakub@redhat.com>
+ Copyright (c) 2008 Red Hat, Inc.
+
+ PowerPC64 Assembly glue.
+
+ Permission is hereby granted, free of charge, to any person obtaining
+ a copy of this software and associated documentation files (the
+ ``Software''), to deal in the Software without restriction, including
+ without limitation the rights to use, copy, modify, merge, publish,
+ distribute, sublicense, and/or sell copies of the Software, and to
+ permit persons to whom the Software is furnished to do so, subject to
+ the following conditions:
+
+ The above copyright notice and this permission notice shall be included
+ in all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND,
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+ HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ DEALINGS IN THE SOFTWARE.
+ ----------------------------------------------------------------------- */
+
+#define LIBFFI_ASM
+#include <fficonfig.h>
+#include <ffi.h>
+
+#ifdef POWERPC64
+ .hidden ffi_call_LINUX64
+ .globl ffi_call_LINUX64
+# if _CALL_ELF == 2
+ .text
+ffi_call_LINUX64:
+ addis %r2, %r12, .TOC.-ffi_call_LINUX64@ha
+ addi %r2, %r2, .TOC.-ffi_call_LINUX64@l
+ .localentry ffi_call_LINUX64, . - ffi_call_LINUX64
+# else
+ .section ".opd","aw"
+ .align 3
+ffi_call_LINUX64:
+# ifdef _CALL_LINUX
+ .quad .L.ffi_call_LINUX64,.TOC.@tocbase,0
+ .type ffi_call_LINUX64,@function
+ .text
+.L.ffi_call_LINUX64:
+# else
+ .hidden .ffi_call_LINUX64
+ .globl .ffi_call_LINUX64
+ .quad .ffi_call_LINUX64,.TOC.@tocbase,0
+ .size ffi_call_LINUX64,24
+ .type .ffi_call_LINUX64,@function
+ .text
+.ffi_call_LINUX64:
+# endif
+# endif
+.LFB1:
+ mflr %r0
+ std %r28, -32(%r1)
+ std %r29, -24(%r1)
+ std %r30, -16(%r1)
+ std %r31, -8(%r1)
+ std %r0, 16(%r1)
+
+ mr %r28, %r1 /* our AP. */
+.LCFI0:
+ stdux %r1, %r1, %r4
+ mr %r31, %r5 /* flags, */
+ mr %r30, %r6 /* rvalue, */
+ mr %r29, %r7 /* function address. */
+/* Save toc pointer, not for the ffi_prep_args64 call, but for the later
+ bctrl function call. */
+# if _CALL_ELF == 2
+ std %r2, 24(%r1)
+# else
+ std %r2, 40(%r1)
+# endif
+
+ /* Call ffi_prep_args64. */
+ mr %r4, %r1
+# if defined _CALL_LINUX || _CALL_ELF == 2
+ bl ffi_prep_args64
+# else
+ bl .ffi_prep_args64
+# endif
+
+# if _CALL_ELF == 2
+ mr %r12, %r29
+# else
+ ld %r12, 0(%r29)
+ ld %r2, 8(%r29)
+ ld %r11, 16(%r29)
+# endif
+ /* Now do the call. */
+ /* Set up cr1 with bits 4-7 of the flags. */
+ mtcrf 0x40, %r31
+
+ /* Get the address to call into CTR. */
+ mtctr %r12
+ /* Load all those argument registers. */
+ ld %r3, -32-(8*8)(%r28)
+ ld %r4, -32-(7*8)(%r28)
+ ld %r5, -32-(6*8)(%r28)
+ ld %r6, -32-(5*8)(%r28)
+ bf- 5, 1f
+ ld %r7, -32-(4*8)(%r28)
+ ld %r8, -32-(3*8)(%r28)
+ ld %r9, -32-(2*8)(%r28)
+ ld %r10, -32-(1*8)(%r28)
+1:
+
+ /* Load all the FP registers. */
+ bf- 6, 2f
+ lfd %f1, -32-(21*8)(%r28)
+ lfd %f2, -32-(20*8)(%r28)
+ lfd %f3, -32-(19*8)(%r28)
+ lfd %f4, -32-(18*8)(%r28)
+ lfd %f5, -32-(17*8)(%r28)
+ lfd %f6, -32-(16*8)(%r28)
+ lfd %f7, -32-(15*8)(%r28)
+ lfd %f8, -32-(14*8)(%r28)
+ lfd %f9, -32-(13*8)(%r28)
+ lfd %f10, -32-(12*8)(%r28)
+ lfd %f11, -32-(11*8)(%r28)
+ lfd %f12, -32-(10*8)(%r28)
+ lfd %f13, -32-(9*8)(%r28)
+2:
+
+ /* Make the call. */
+ bctrl
+
+ /* This must follow the call immediately, the unwinder
+ uses this to find out if r2 has been saved or not. */
+# if _CALL_ELF == 2
+ ld %r2, 24(%r1)
+# else
+ ld %r2, 40(%r1)
+# endif
+
+ /* Now, deal with the return value. */
+ mtcrf 0x01, %r31
+ bt 31, .Lstruct_return_value
+ bt 30, .Ldone_return_value
+ bt 29, .Lfp_return_value
+ std %r3, 0(%r30)
+ /* Fall through... */
+
+.Ldone_return_value:
+ /* Restore the registers we used and return. */
+ mr %r1, %r28
+ ld %r0, 16(%r28)
+ ld %r28, -32(%r28)
+ mtlr %r0
+ ld %r29, -24(%r1)
+ ld %r30, -16(%r1)
+ ld %r31, -8(%r1)
+ blr
+
+.Lfp_return_value:
+ bf 28, .Lfloat_return_value
+ stfd %f1, 0(%r30)
+ mtcrf 0x02, %r31 /* cr6 */
+ bf 27, .Ldone_return_value
+ stfd %f2, 8(%r30)
+ b .Ldone_return_value
+.Lfloat_return_value:
+ stfs %f1, 0(%r30)
+ b .Ldone_return_value
+
+.Lstruct_return_value:
+ bf 29, .Lsmall_struct
+ bf 28, .Lfloat_homog_return_value
+ stfd %f1, 0(%r30)
+ stfd %f2, 8(%r30)
+ stfd %f3, 16(%r30)
+ stfd %f4, 24(%r30)
+ stfd %f5, 32(%r30)
+ stfd %f6, 40(%r30)
+ stfd %f7, 48(%r30)
+ stfd %f8, 56(%r30)
+ b .Ldone_return_value
+
+.Lfloat_homog_return_value:
+ stfs %f1, 0(%r30)
+ stfs %f2, 4(%r30)
+ stfs %f3, 8(%r30)
+ stfs %f4, 12(%r30)
+ stfs %f5, 16(%r30)
+ stfs %f6, 20(%r30)
+ stfs %f7, 24(%r30)
+ stfs %f8, 28(%r30)
+ b .Ldone_return_value
+
+.Lsmall_struct:
+ std %r3, 0(%r30)
+ std %r4, 8(%r30)
+ b .Ldone_return_value
+
+.LFE1:
+ .long 0
+ .byte 0,12,0,1,128,4,0,0
+# if _CALL_ELF == 2
+ .size ffi_call_LINUX64,.-ffi_call_LINUX64
+# else
+# ifdef _CALL_LINUX
+ .size ffi_call_LINUX64,.-.L.ffi_call_LINUX64
+# else
+ .size .ffi_call_LINUX64,.-.ffi_call_LINUX64
+# endif
+# endif
+
+ .section .eh_frame,EH_FRAME_FLAGS,@progbits
+.Lframe1:
+ .4byte .LECIE1-.LSCIE1 # Length of Common Information Entry
+.LSCIE1:
+ .4byte 0x0 # CIE Identifier Tag
+ .byte 0x1 # CIE Version
+ .ascii "zR\0" # CIE Augmentation
+ .uleb128 0x1 # CIE Code Alignment Factor
+ .sleb128 -8 # CIE Data Alignment Factor
+ .byte 0x41 # CIE RA Column
+ .uleb128 0x1 # Augmentation size
+ .byte 0x14 # FDE Encoding (pcrel udata8)
+ .byte 0xc # DW_CFA_def_cfa
+ .uleb128 0x1
+ .uleb128 0x0
+ .align 3
+.LECIE1:
+.LSFDE1:
+ .4byte .LEFDE1-.LASFDE1 # FDE Length
+.LASFDE1:
+ .4byte .LASFDE1-.Lframe1 # FDE CIE offset
+ .8byte .LFB1-. # FDE initial location
+ .8byte .LFE1-.LFB1 # FDE address range
+ .uleb128 0x0 # Augmentation size
+ .byte 0x2 # DW_CFA_advance_loc1
+ .byte .LCFI0-.LFB1
+ .byte 0xd # DW_CFA_def_cfa_register
+ .uleb128 0x1c
+ .byte 0x11 # DW_CFA_offset_extended_sf
+ .uleb128 0x41
+ .sleb128 -2
+ .byte 0x9f # DW_CFA_offset, column 0x1f
+ .uleb128 0x1
+ .byte 0x9e # DW_CFA_offset, column 0x1e
+ .uleb128 0x2
+ .byte 0x9d # DW_CFA_offset, column 0x1d
+ .uleb128 0x3
+ .byte 0x9c # DW_CFA_offset, column 0x1c
+ .uleb128 0x4
+ .align 3
+.LEFDE1:
+
+#endif
+
+#if (defined __ELF__ && defined __linux__) || _CALL_ELF == 2
+ .section .note.GNU-stack,"",@progbits
+#endif
diff --git a/jni/ruby/ext/fiddle/libffi-3.2.1/src/powerpc/linux64_closure.S b/jni/ruby/ext/fiddle/libffi-3.2.1/src/powerpc/linux64_closure.S
new file mode 100644
index 0000000..97421a4
--- /dev/null
+++ b/jni/ruby/ext/fiddle/libffi-3.2.1/src/powerpc/linux64_closure.S
@@ -0,0 +1,392 @@
+/* -----------------------------------------------------------------------
+ sysv.h - Copyright (c) 2003 Jakub Jelinek <jakub@redhat.com>
+ Copyright (c) 2008 Red Hat, Inc.
+
+ PowerPC64 Assembly glue.
+
+ Permission is hereby granted, free of charge, to any person obtaining
+ a copy of this software and associated documentation files (the
+ ``Software''), to deal in the Software without restriction, including
+ without limitation the rights to use, copy, modify, merge, publish,
+ distribute, sublicense, and/or sell copies of the Software, and to
+ permit persons to whom the Software is furnished to do so, subject to
+ the following conditions:
+
+ The above copyright notice and this permission notice shall be included
+ in all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND,
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+ HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ DEALINGS IN THE SOFTWARE.
+ ----------------------------------------------------------------------- */
+#define LIBFFI_ASM
+#include <fficonfig.h>
+#include <ffi.h>
+
+ .file "linux64_closure.S"
+
+#ifdef POWERPC64
+ FFI_HIDDEN (ffi_closure_LINUX64)
+ .globl ffi_closure_LINUX64
+# if _CALL_ELF == 2
+ .text
+ffi_closure_LINUX64:
+ addis %r2, %r12, .TOC.-ffi_closure_LINUX64@ha
+ addi %r2, %r2, .TOC.-ffi_closure_LINUX64@l
+ .localentry ffi_closure_LINUX64, . - ffi_closure_LINUX64
+# else
+ .section ".opd","aw"
+ .align 3
+ffi_closure_LINUX64:
+# ifdef _CALL_LINUX
+ .quad .L.ffi_closure_LINUX64,.TOC.@tocbase,0
+ .type ffi_closure_LINUX64,@function
+ .text
+.L.ffi_closure_LINUX64:
+# else
+ FFI_HIDDEN (.ffi_closure_LINUX64)
+ .globl .ffi_closure_LINUX64
+ .quad .ffi_closure_LINUX64,.TOC.@tocbase,0
+ .size ffi_closure_LINUX64,24
+ .type .ffi_closure_LINUX64,@function
+ .text
+.ffi_closure_LINUX64:
+# endif
+# endif
+
+# if _CALL_ELF == 2
+# 32 byte special reg save area + 64 byte parm save area
+# + 64 byte retval area + 13*8 fpr save area + round to 16
+# define STACKFRAME 272
+# define PARMSAVE 32
+# define RETVAL PARMSAVE+64
+# else
+# 48 bytes special reg save area + 64 bytes parm save area
+# + 16 bytes retval area + 13*8 bytes fpr save area + round to 16
+# define STACKFRAME 240
+# define PARMSAVE 48
+# define RETVAL PARMSAVE+64
+# endif
+
+.LFB1:
+# if _CALL_ELF == 2
+ ld %r12, FFI_TRAMPOLINE_SIZE(%r11) # closure->cif
+ mflr %r0
+ lwz %r12, 28(%r12) # cif->flags
+ mtcrf 0x40, %r12
+ addi %r12, %r1, PARMSAVE
+ bt 7, .Lparmsave
+ # Our caller has not allocated a parameter save area.
+ # We need to allocate one here and use it to pass gprs to
+ # ffi_closure_helper_LINUX64.
+ addi %r12, %r1, -STACKFRAME+PARMSAVE
+.Lparmsave:
+ std %r0, 16(%r1)
+ # Save general regs into parm save area
+ std %r3, 0(%r12)
+ std %r4, 8(%r12)
+ std %r5, 16(%r12)
+ std %r6, 24(%r12)
+ std %r7, 32(%r12)
+ std %r8, 40(%r12)
+ std %r9, 48(%r12)
+ std %r10, 56(%r12)
+
+ # load up the pointer to the parm save area
+ mr %r5, %r12
+# else
+ # copy r2 to r11 and load TOC into r2
+ mr %r11, %r2
+ ld %r2, 16(%r11)
+
+ mflr %r0
+ # Save general regs into parm save area
+ # This is the parameter save area set up by our caller.
+ std %r3, PARMSAVE+0(%r1)
+ std %r4, PARMSAVE+8(%r1)
+ std %r5, PARMSAVE+16(%r1)
+ std %r6, PARMSAVE+24(%r1)
+ std %r7, PARMSAVE+32(%r1)
+ std %r8, PARMSAVE+40(%r1)
+ std %r9, PARMSAVE+48(%r1)
+ std %r10, PARMSAVE+56(%r1)
+
+ std %r0, 16(%r1)
+
+ # load up the pointer to the parm save area
+ addi %r5, %r1, PARMSAVE
+# endif
+
+ # next save fpr 1 to fpr 13
+ stfd %f1, -104+(0*8)(%r1)
+ stfd %f2, -104+(1*8)(%r1)
+ stfd %f3, -104+(2*8)(%r1)
+ stfd %f4, -104+(3*8)(%r1)
+ stfd %f5, -104+(4*8)(%r1)
+ stfd %f6, -104+(5*8)(%r1)
+ stfd %f7, -104+(6*8)(%r1)
+ stfd %f8, -104+(7*8)(%r1)
+ stfd %f9, -104+(8*8)(%r1)
+ stfd %f10, -104+(9*8)(%r1)
+ stfd %f11, -104+(10*8)(%r1)
+ stfd %f12, -104+(11*8)(%r1)
+ stfd %f13, -104+(12*8)(%r1)
+
+ # load up the pointer to the saved fpr registers */
+ addi %r6, %r1, -104
+
+ # load up the pointer to the result storage
+ addi %r4, %r1, -STACKFRAME+RETVAL
+
+ stdu %r1, -STACKFRAME(%r1)
+.LCFI0:
+
+ # get the context pointer from the trampoline
+ mr %r3, %r11
+
+ # make the call
+# if defined _CALL_LINUX || _CALL_ELF == 2
+ bl ffi_closure_helper_LINUX64
+# else
+ bl .ffi_closure_helper_LINUX64
+# endif
+.Lret:
+
+ # now r3 contains the return type
+ # so use it to look up in a table
+ # so we know how to deal with each type
+
+ # look up the proper starting point in table
+ # by using return type as offset
+ ld %r0, STACKFRAME+16(%r1)
+ cmpldi %r3, FFI_V2_TYPE_SMALL_STRUCT
+ bge .Lsmall
+ mflr %r4 # move address of .Lret to r4
+ sldi %r3, %r3, 4 # now multiply return type by 16
+ addi %r4, %r4, .Lret_type0 - .Lret
+ add %r3, %r3, %r4 # add contents of table to table address
+ mtctr %r3
+ bctr # jump to it
+
+# Each of the ret_typeX code fragments has to be exactly 16 bytes long
+# (4 instructions). For cache effectiveness we align to a 16 byte boundary
+# first.
+ .align 4
+
+.Lret_type0:
+# case FFI_TYPE_VOID
+ mtlr %r0
+ addi %r1, %r1, STACKFRAME
+ blr
+ nop
+# case FFI_TYPE_INT
+# ifdef __LITTLE_ENDIAN__
+ lwa %r3, RETVAL+0(%r1)
+# else
+ lwa %r3, RETVAL+4(%r1)
+# endif
+ mtlr %r0
+ addi %r1, %r1, STACKFRAME
+ blr
+# case FFI_TYPE_FLOAT
+ lfs %f1, RETVAL+0(%r1)
+ mtlr %r0
+ addi %r1, %r1, STACKFRAME
+ blr
+# case FFI_TYPE_DOUBLE
+ lfd %f1, RETVAL+0(%r1)
+ mtlr %r0
+ addi %r1, %r1, STACKFRAME
+ blr
+# case FFI_TYPE_LONGDOUBLE
+ lfd %f1, RETVAL+0(%r1)
+ mtlr %r0
+ lfd %f2, RETVAL+8(%r1)
+ b .Lfinish
+# case FFI_TYPE_UINT8
+# ifdef __LITTLE_ENDIAN__
+ lbz %r3, RETVAL+0(%r1)
+# else
+ lbz %r3, RETVAL+7(%r1)
+# endif
+ mtlr %r0
+ addi %r1, %r1, STACKFRAME
+ blr
+# case FFI_TYPE_SINT8
+# ifdef __LITTLE_ENDIAN__
+ lbz %r3, RETVAL+0(%r1)
+# else
+ lbz %r3, RETVAL+7(%r1)
+# endif
+ extsb %r3,%r3
+ mtlr %r0
+ b .Lfinish
+# case FFI_TYPE_UINT16
+# ifdef __LITTLE_ENDIAN__
+ lhz %r3, RETVAL+0(%r1)
+# else
+ lhz %r3, RETVAL+6(%r1)
+# endif
+ mtlr %r0
+.Lfinish:
+ addi %r1, %r1, STACKFRAME
+ blr
+# case FFI_TYPE_SINT16
+# ifdef __LITTLE_ENDIAN__
+ lha %r3, RETVAL+0(%r1)
+# else
+ lha %r3, RETVAL+6(%r1)
+# endif
+ mtlr %r0
+ addi %r1, %r1, STACKFRAME
+ blr
+# case FFI_TYPE_UINT32
+# ifdef __LITTLE_ENDIAN__
+ lwz %r3, RETVAL+0(%r1)
+# else
+ lwz %r3, RETVAL+4(%r1)
+# endif
+ mtlr %r0
+ addi %r1, %r1, STACKFRAME
+ blr
+# case FFI_TYPE_SINT32
+# ifdef __LITTLE_ENDIAN__
+ lwa %r3, RETVAL+0(%r1)
+# else
+ lwa %r3, RETVAL+4(%r1)
+# endif
+ mtlr %r0
+ addi %r1, %r1, STACKFRAME
+ blr
+# case FFI_TYPE_UINT64
+ ld %r3, RETVAL+0(%r1)
+ mtlr %r0
+ addi %r1, %r1, STACKFRAME
+ blr
+# case FFI_TYPE_SINT64
+ ld %r3, RETVAL+0(%r1)
+ mtlr %r0
+ addi %r1, %r1, STACKFRAME
+ blr
+# case FFI_TYPE_STRUCT
+ mtlr %r0
+ addi %r1, %r1, STACKFRAME
+ blr
+ nop
+# case FFI_TYPE_POINTER
+ ld %r3, RETVAL+0(%r1)
+ mtlr %r0
+ addi %r1, %r1, STACKFRAME
+ blr
+# case FFI_V2_TYPE_FLOAT_HOMOG
+ lfs %f1, RETVAL+0(%r1)
+ lfs %f2, RETVAL+4(%r1)
+ lfs %f3, RETVAL+8(%r1)
+ b .Lmorefloat
+# case FFI_V2_TYPE_DOUBLE_HOMOG
+ lfd %f1, RETVAL+0(%r1)
+ lfd %f2, RETVAL+8(%r1)
+ lfd %f3, RETVAL+16(%r1)
+ lfd %f4, RETVAL+24(%r1)
+ mtlr %r0
+ lfd %f5, RETVAL+32(%r1)
+ lfd %f6, RETVAL+40(%r1)
+ lfd %f7, RETVAL+48(%r1)
+ lfd %f8, RETVAL+56(%r1)
+ addi %r1, %r1, STACKFRAME
+ blr
+.Lmorefloat:
+ lfs %f4, RETVAL+12(%r1)
+ mtlr %r0
+ lfs %f5, RETVAL+16(%r1)
+ lfs %f6, RETVAL+20(%r1)
+ lfs %f7, RETVAL+24(%r1)
+ lfs %f8, RETVAL+28(%r1)
+ addi %r1, %r1, STACKFRAME
+ blr
+.Lsmall:
+# ifdef __LITTLE_ENDIAN__
+ ld %r3,RETVAL+0(%r1)
+ mtlr %r0
+ ld %r4,RETVAL+8(%r1)
+ addi %r1, %r1, STACKFRAME
+ blr
+# else
+ # A struct smaller than a dword is returned in the low bits of r3
+ # ie. right justified. Larger structs are passed left justified
+ # in r3 and r4. The return value area on the stack will have
+ # the structs as they are usually stored in memory.
+ cmpldi %r3, FFI_V2_TYPE_SMALL_STRUCT + 7 # size 8 bytes?
+ neg %r5, %r3
+ ld %r3,RETVAL+0(%r1)
+ blt .Lsmalldown
+ mtlr %r0
+ ld %r4,RETVAL+8(%r1)
+ addi %r1, %r1, STACKFRAME
+ blr
+.Lsmalldown:
+ addi %r5, %r5, FFI_V2_TYPE_SMALL_STRUCT + 7
+ mtlr %r0
+ sldi %r5, %r5, 3
+ addi %r1, %r1, STACKFRAME
+ srd %r3, %r3, %r5
+ blr
+# endif
+
+.LFE1:
+ .long 0
+ .byte 0,12,0,1,128,0,0,0
+# if _CALL_ELF == 2
+ .size ffi_closure_LINUX64,.-ffi_closure_LINUX64
+# else
+# ifdef _CALL_LINUX
+ .size ffi_closure_LINUX64,.-.L.ffi_closure_LINUX64
+# else
+ .size .ffi_closure_LINUX64,.-.ffi_closure_LINUX64
+# endif
+# endif
+
+ .section .eh_frame,EH_FRAME_FLAGS,@progbits
+.Lframe1:
+ .4byte .LECIE1-.LSCIE1 # Length of Common Information Entry
+.LSCIE1:
+ .4byte 0x0 # CIE Identifier Tag
+ .byte 0x1 # CIE Version
+ .ascii "zR\0" # CIE Augmentation
+ .uleb128 0x1 # CIE Code Alignment Factor
+ .sleb128 -8 # CIE Data Alignment Factor
+ .byte 0x41 # CIE RA Column
+ .uleb128 0x1 # Augmentation size
+ .byte 0x14 # FDE Encoding (pcrel udata8)
+ .byte 0xc # DW_CFA_def_cfa
+ .uleb128 0x1
+ .uleb128 0x0
+ .align 3
+.LECIE1:
+.LSFDE1:
+ .4byte .LEFDE1-.LASFDE1 # FDE Length
+.LASFDE1:
+ .4byte .LASFDE1-.Lframe1 # FDE CIE offset
+ .8byte .LFB1-. # FDE initial location
+ .8byte .LFE1-.LFB1 # FDE address range
+ .uleb128 0x0 # Augmentation size
+ .byte 0x2 # DW_CFA_advance_loc1
+ .byte .LCFI0-.LFB1
+ .byte 0xe # DW_CFA_def_cfa_offset
+ .uleb128 STACKFRAME
+ .byte 0x11 # DW_CFA_offset_extended_sf
+ .uleb128 0x41
+ .sleb128 -2
+ .align 3
+.LEFDE1:
+
+#endif
+
+#if (defined __ELF__ && defined __linux__) || _CALL_ELF == 2
+ .section .note.GNU-stack,"",@progbits
+#endif
diff --git a/jni/ruby/ext/fiddle/libffi-3.2.1/src/powerpc/ppc_closure.S b/jni/ruby/ext/fiddle/libffi-3.2.1/src/powerpc/ppc_closure.S
new file mode 100644
index 0000000..075922c
--- /dev/null
+++ b/jni/ruby/ext/fiddle/libffi-3.2.1/src/powerpc/ppc_closure.S
@@ -0,0 +1,384 @@
+/* -----------------------------------------------------------------------
+ sysv.h - Copyright (c) 2003 Jakub Jelinek <jakub@redhat.com>
+ Copyright (c) 2008 Red Hat, Inc.
+
+ PowerPC Assembly glue.
+
+ Permission is hereby granted, free of charge, to any person obtaining
+ a copy of this software and associated documentation files (the
+ ``Software''), to deal in the Software without restriction, including
+ without limitation the rights to use, copy, modify, merge, publish,
+ distribute, sublicense, and/or sell copies of the Software, and to
+ permit persons to whom the Software is furnished to do so, subject to
+ the following conditions:
+
+ The above copyright notice and this permission notice shall be included
+ in all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND,
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+ HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ DEALINGS IN THE SOFTWARE.
+ ----------------------------------------------------------------------- */
+#define LIBFFI_ASM
+#include <fficonfig.h>
+#include <ffi.h>
+#include <powerpc/asm.h>
+
+ .file "ppc_closure.S"
+
+#ifndef POWERPC64
+
+ENTRY(ffi_closure_SYSV)
+.LFB1:
+ stwu %r1,-144(%r1)
+.LCFI0:
+ mflr %r0
+.LCFI1:
+ stw %r0,148(%r1)
+
+# we want to build up an areas for the parameters passed
+# in registers (both floating point and integer)
+
+ # so first save gpr 3 to gpr 10 (aligned to 4)
+ stw %r3, 16(%r1)
+ stw %r4, 20(%r1)
+ stw %r5, 24(%r1)
+ stw %r6, 28(%r1)
+ stw %r7, 32(%r1)
+ stw %r8, 36(%r1)
+ stw %r9, 40(%r1)
+ stw %r10,44(%r1)
+
+#ifndef __NO_FPRS__
+ # next save fpr 1 to fpr 8 (aligned to 8)
+ stfd %f1, 48(%r1)
+ stfd %f2, 56(%r1)
+ stfd %f3, 64(%r1)
+ stfd %f4, 72(%r1)
+ stfd %f5, 80(%r1)
+ stfd %f6, 88(%r1)
+ stfd %f7, 96(%r1)
+ stfd %f8, 104(%r1)
+#endif
+
+ # set up registers for the routine that actually does the work
+ # get the context pointer from the trampoline
+ mr %r3,%r11
+
+ # now load up the pointer to the result storage
+ addi %r4,%r1,112
+
+ # now load up the pointer to the saved gpr registers
+ addi %r5,%r1,16
+
+ # now load up the pointer to the saved fpr registers */
+ addi %r6,%r1,48
+
+ # now load up the pointer to the outgoing parameter
+ # stack in the previous frame
+ # i.e. the previous frame pointer + 8
+ addi %r7,%r1,152
+
+ # make the call
+ bl ffi_closure_helper_SYSV@local
+.Lret:
+ # now r3 contains the return type
+ # so use it to look up in a table
+ # so we know how to deal with each type
+
+ # look up the proper starting point in table
+ # by using return type as offset
+
+ mflr %r4 # move address of .Lret to r4
+ slwi %r3,%r3,4 # now multiply return type by 16
+ addi %r4, %r4, .Lret_type0 - .Lret
+ lwz %r0,148(%r1)
+ add %r3,%r3,%r4 # add contents of table to table address
+ mtctr %r3
+ bctr # jump to it
+.LFE1:
+
+# Each of the ret_typeX code fragments has to be exactly 16 bytes long
+# (4 instructions). For cache effectiveness we align to a 16 byte boundary
+# first.
+ .align 4
+# case FFI_TYPE_VOID
+.Lret_type0:
+ mtlr %r0
+ addi %r1,%r1,144
+ blr
+ nop
+
+# case FFI_TYPE_INT
+ lwz %r3,112+0(%r1)
+ mtlr %r0
+.Lfinish:
+ addi %r1,%r1,144
+ blr
+
+# case FFI_TYPE_FLOAT
+#ifndef __NO_FPRS__
+ lfs %f1,112+0(%r1)
+ mtlr %r0
+ addi %r1,%r1,144
+#else
+ nop
+ nop
+ nop
+#endif
+ blr
+
+# case FFI_TYPE_DOUBLE
+#ifndef __NO_FPRS__
+ lfd %f1,112+0(%r1)
+ mtlr %r0
+ addi %r1,%r1,144
+#else
+ nop
+ nop
+ nop
+#endif
+ blr
+
+# case FFI_TYPE_LONGDOUBLE
+#ifndef __NO_FPRS__
+ lfd %f1,112+0(%r1)
+ lfd %f2,112+8(%r1)
+ mtlr %r0
+ b .Lfinish
+#else
+ nop
+ nop
+ nop
+ blr
+#endif
+
+# case FFI_TYPE_UINT8
+#ifdef __LITTLE_ENDIAN__
+ lbz %r3,112+0(%r1)
+#else
+ lbz %r3,112+3(%r1)
+#endif
+ mtlr %r0
+ addi %r1,%r1,144
+ blr
+
+# case FFI_TYPE_SINT8
+#ifdef __LITTLE_ENDIAN__
+ lbz %r3,112+0(%r1)
+#else
+ lbz %r3,112+3(%r1)
+#endif
+ extsb %r3,%r3
+ mtlr %r0
+ b .Lfinish
+
+# case FFI_TYPE_UINT16
+#ifdef __LITTLE_ENDIAN__
+ lhz %r3,112+0(%r1)
+#else
+ lhz %r3,112+2(%r1)
+#endif
+ mtlr %r0
+ addi %r1,%r1,144
+ blr
+
+# case FFI_TYPE_SINT16
+#ifdef __LITTLE_ENDIAN__
+ lha %r3,112+0(%r1)
+#else
+ lha %r3,112+2(%r1)
+#endif
+ mtlr %r0
+ addi %r1,%r1,144
+ blr
+
+# case FFI_TYPE_UINT32
+ lwz %r3,112+0(%r1)
+ mtlr %r0
+ addi %r1,%r1,144
+ blr
+
+# case FFI_TYPE_SINT32
+ lwz %r3,112+0(%r1)
+ mtlr %r0
+ addi %r1,%r1,144
+ blr
+
+# case FFI_TYPE_UINT64
+ lwz %r3,112+0(%r1)
+ lwz %r4,112+4(%r1)
+ mtlr %r0
+ b .Lfinish
+
+# case FFI_TYPE_SINT64
+ lwz %r3,112+0(%r1)
+ lwz %r4,112+4(%r1)
+ mtlr %r0
+ b .Lfinish
+
+# case FFI_TYPE_STRUCT
+ mtlr %r0
+ addi %r1,%r1,144
+ blr
+ nop
+
+# case FFI_TYPE_POINTER
+ lwz %r3,112+0(%r1)
+ mtlr %r0
+ addi %r1,%r1,144
+ blr
+
+# case FFI_TYPE_UINT128
+ lwz %r3,112+0(%r1)
+ lwz %r4,112+4(%r1)
+ lwz %r5,112+8(%r1)
+ b .Luint128
+
+# The return types below are only used when the ABI type is FFI_SYSV.
+# case FFI_SYSV_TYPE_SMALL_STRUCT + 1. One byte struct.
+ lbz %r3,112+0(%r1)
+ mtlr %r0
+ addi %r1,%r1,144
+ blr
+
+# case FFI_SYSV_TYPE_SMALL_STRUCT + 2. Two byte struct.
+ lhz %r3,112+0(%r1)
+ mtlr %r0
+ addi %r1,%r1,144
+ blr
+
+# case FFI_SYSV_TYPE_SMALL_STRUCT + 3. Three byte struct.
+ lwz %r3,112+0(%r1)
+#ifdef __LITTLE_ENDIAN__
+ mtlr %r0
+ addi %r1,%r1,144
+ blr
+#else
+ srwi %r3,%r3,8
+ mtlr %r0
+ b .Lfinish
+#endif
+
+# case FFI_SYSV_TYPE_SMALL_STRUCT + 4. Four byte struct.
+ lwz %r3,112+0(%r1)
+ mtlr %r0
+ addi %r1,%r1,144
+ blr
+
+# case FFI_SYSV_TYPE_SMALL_STRUCT + 5. Five byte struct.
+ lwz %r3,112+0(%r1)
+ lwz %r4,112+4(%r1)
+#ifdef __LITTLE_ENDIAN__
+ mtlr %r0
+ b .Lfinish
+#else
+ li %r5,24
+ b .Lstruct567
+#endif
+
+# case FFI_SYSV_TYPE_SMALL_STRUCT + 6. Six byte struct.
+ lwz %r3,112+0(%r1)
+ lwz %r4,112+4(%r1)
+#ifdef __LITTLE_ENDIAN__
+ mtlr %r0
+ b .Lfinish
+#else
+ li %r5,16
+ b .Lstruct567
+#endif
+
+# case FFI_SYSV_TYPE_SMALL_STRUCT + 7. Seven byte struct.
+ lwz %r3,112+0(%r1)
+ lwz %r4,112+4(%r1)
+#ifdef __LITTLE_ENDIAN__
+ mtlr %r0
+ b .Lfinish
+#else
+ li %r5,8
+ b .Lstruct567
+#endif
+
+# case FFI_SYSV_TYPE_SMALL_STRUCT + 8. Eight byte struct.
+ lwz %r3,112+0(%r1)
+ lwz %r4,112+4(%r1)
+ mtlr %r0
+ b .Lfinish
+
+#ifndef __LITTLE_ENDIAN__
+.Lstruct567:
+ subfic %r6,%r5,32
+ srw %r4,%r4,%r5
+ slw %r6,%r3,%r6
+ srw %r3,%r3,%r5
+ or %r4,%r6,%r4
+ mtlr %r0
+ addi %r1,%r1,144
+ blr
+#endif
+
+.Luint128:
+ lwz %r6,112+12(%r1)
+ mtlr %r0
+ addi %r1,%r1,144
+ blr
+
+END(ffi_closure_SYSV)
+
+ .section ".eh_frame",EH_FRAME_FLAGS,@progbits
+.Lframe1:
+ .4byte .LECIE1-.LSCIE1 # Length of Common Information Entry
+.LSCIE1:
+ .4byte 0x0 # CIE Identifier Tag
+ .byte 0x1 # CIE Version
+#if defined _RELOCATABLE || defined __PIC__
+ .ascii "zR\0" # CIE Augmentation
+#else
+ .ascii "\0" # CIE Augmentation
+#endif
+ .uleb128 0x1 # CIE Code Alignment Factor
+ .sleb128 -4 # CIE Data Alignment Factor
+ .byte 0x41 # CIE RA Column
+#if defined _RELOCATABLE || defined __PIC__
+ .uleb128 0x1 # Augmentation size
+ .byte 0x1b # FDE Encoding (pcrel sdata4)
+#endif
+ .byte 0xc # DW_CFA_def_cfa
+ .uleb128 0x1
+ .uleb128 0x0
+ .align 2
+.LECIE1:
+.LSFDE1:
+ .4byte .LEFDE1-.LASFDE1 # FDE Length
+.LASFDE1:
+ .4byte .LASFDE1-.Lframe1 # FDE CIE offset
+#if defined _RELOCATABLE || defined __PIC__
+ .4byte .LFB1-. # FDE initial location
+#else
+ .4byte .LFB1 # FDE initial location
+#endif
+ .4byte .LFE1-.LFB1 # FDE address range
+#if defined _RELOCATABLE || defined __PIC__
+ .uleb128 0x0 # Augmentation size
+#endif
+ .byte 0x4 # DW_CFA_advance_loc4
+ .4byte .LCFI0-.LFB1
+ .byte 0xe # DW_CFA_def_cfa_offset
+ .uleb128 144
+ .byte 0x4 # DW_CFA_advance_loc4
+ .4byte .LCFI1-.LCFI0
+ .byte 0x11 # DW_CFA_offset_extended_sf
+ .uleb128 0x41
+ .sleb128 -1
+ .align 2
+.LEFDE1:
+
+#if defined __ELF__ && defined __linux__
+ .section .note.GNU-stack,"",@progbits
+#endif
+#endif
diff --git a/jni/ruby/ext/fiddle/libffi-3.2.1/src/powerpc/sysv.S b/jni/ruby/ext/fiddle/libffi-3.2.1/src/powerpc/sysv.S
new file mode 100644
index 0000000..fed2380
--- /dev/null
+++ b/jni/ruby/ext/fiddle/libffi-3.2.1/src/powerpc/sysv.S
@@ -0,0 +1,220 @@
+/* -----------------------------------------------------------------------
+ sysv.S - Copyright (c) 1998 Geoffrey Keating
+ Copyright (C) 2007 Free Software Foundation, Inc
+
+ PowerPC Assembly glue.
+
+ Permission is hereby granted, free of charge, to any person obtaining
+ a copy of this software and associated documentation files (the
+ ``Software''), to deal in the Software without restriction, including
+ without limitation the rights to use, copy, modify, merge, publish,
+ distribute, sublicense, and/or sell copies of the Software, and to
+ permit persons to whom the Software is furnished to do so, subject to
+ the following conditions:
+
+ The above copyright notice and this permission notice shall be included
+ in all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND,
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+ HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ DEALINGS IN THE SOFTWARE.
+ ----------------------------------------------------------------------- */
+
+#define LIBFFI_ASM
+#include <fficonfig.h>
+#include <ffi.h>
+#include <powerpc/asm.h>
+
+#ifndef POWERPC64
+ .globl ffi_prep_args_SYSV
+ENTRY(ffi_call_SYSV)
+.LFB1:
+ /* Save the old stack pointer as AP. */
+ mr %r8,%r1
+
+.LCFI0:
+ /* Allocate the stack space we need. */
+ stwux %r1,%r1,%r4
+ /* Save registers we use. */
+ mflr %r9
+ stw %r28,-16(%r8)
+.LCFI1:
+ stw %r29,-12(%r8)
+.LCFI2:
+ stw %r30, -8(%r8)
+.LCFI3:
+ stw %r31, -4(%r8)
+.LCFI4:
+ stw %r9, 4(%r8)
+.LCFI5:
+
+ /* Save arguments over call... */
+ mr %r31,%r5 /* flags, */
+ mr %r30,%r6 /* rvalue, */
+ mr %r29,%r7 /* function address, */
+ mr %r28,%r8 /* our AP. */
+.LCFI6:
+
+ /* Call ffi_prep_args_SYSV. */
+ mr %r4,%r1
+ bl ffi_prep_args_SYSV@local
+
+ /* Now do the call. */
+ /* Set up cr1 with bits 4-7 of the flags. */
+ mtcrf 0x40,%r31
+ /* Get the address to call into CTR. */
+ mtctr %r29
+ /* Load all those argument registers. */
+ lwz %r3,-16-(8*4)(%r28)
+ lwz %r4,-16-(7*4)(%r28)
+ lwz %r5,-16-(6*4)(%r28)
+ lwz %r6,-16-(5*4)(%r28)
+ bf- 5,1f
+ nop
+ lwz %r7,-16-(4*4)(%r28)
+ lwz %r8,-16-(3*4)(%r28)
+ lwz %r9,-16-(2*4)(%r28)
+ lwz %r10,-16-(1*4)(%r28)
+ nop
+1:
+
+#ifndef __NO_FPRS__
+ /* Load all the FP registers. */
+ bf- 6,2f
+ lfd %f1,-16-(8*4)-(8*8)(%r28)
+ lfd %f2,-16-(8*4)-(7*8)(%r28)
+ lfd %f3,-16-(8*4)-(6*8)(%r28)
+ lfd %f4,-16-(8*4)-(5*8)(%r28)
+ nop
+ lfd %f5,-16-(8*4)-(4*8)(%r28)
+ lfd %f6,-16-(8*4)-(3*8)(%r28)
+ lfd %f7,-16-(8*4)-(2*8)(%r28)
+ lfd %f8,-16-(8*4)-(1*8)(%r28)
+#endif
+2:
+
+ /* Make the call. */
+ bctrl
+
+ /* Now, deal with the return value. */
+ mtcrf 0x01,%r31 /* cr7 */
+ bt- 31,L(small_struct_return_value)
+ bt- 30,L(done_return_value)
+#ifndef __NO_FPRS__
+ bt- 29,L(fp_return_value)
+#endif
+ stw %r3,0(%r30)
+ bf+ 28,L(done_return_value)
+ stw %r4,4(%r30)
+ mtcrf 0x02,%r31 /* cr6 */
+ bf 27,L(done_return_value)
+ stw %r5,8(%r30)
+ stw %r6,12(%r30)
+ /* Fall through... */
+
+L(done_return_value):
+ /* Restore the registers we used and return. */
+ lwz %r9, 4(%r28)
+ lwz %r31, -4(%r28)
+ mtlr %r9
+ lwz %r30, -8(%r28)
+ lwz %r29,-12(%r28)
+ lwz %r28,-16(%r28)
+ lwz %r1,0(%r1)
+ blr
+
+#ifndef __NO_FPRS__
+L(fp_return_value):
+ bf 28,L(float_return_value)
+ stfd %f1,0(%r30)
+ mtcrf 0x02,%r31 /* cr6 */
+ bf 27,L(done_return_value)
+ stfd %f2,8(%r30)
+ b L(done_return_value)
+L(float_return_value):
+ stfs %f1,0(%r30)
+ b L(done_return_value)
+#endif
+
+L(small_struct_return_value):
+ /*
+ * The C code always allocates a properly-aligned 8-byte bounce
+ * buffer to make this assembly code very simple. Just write out
+ * r3 and r4 to the buffer to allow the C code to handle the rest.
+ */
+ stw %r3, 0(%r30)
+ stw %r4, 4(%r30)
+ b L(done_return_value)
+
+.LFE1:
+END(ffi_call_SYSV)
+
+ .section ".eh_frame",EH_FRAME_FLAGS,@progbits
+.Lframe1:
+ .4byte .LECIE1-.LSCIE1 /* Length of Common Information Entry */
+.LSCIE1:
+ .4byte 0x0 /* CIE Identifier Tag */
+ .byte 0x1 /* CIE Version */
+#if defined _RELOCATABLE || defined __PIC__
+ .ascii "zR\0" /* CIE Augmentation */
+#else
+ .ascii "\0" /* CIE Augmentation */
+#endif
+ .uleb128 0x1 /* CIE Code Alignment Factor */
+ .sleb128 -4 /* CIE Data Alignment Factor */
+ .byte 0x41 /* CIE RA Column */
+#if defined _RELOCATABLE || defined __PIC__
+ .uleb128 0x1 /* Augmentation size */
+ .byte 0x1b /* FDE Encoding (pcrel sdata4) */
+#endif
+ .byte 0xc /* DW_CFA_def_cfa */
+ .uleb128 0x1
+ .uleb128 0x0
+ .align 2
+.LECIE1:
+.LSFDE1:
+ .4byte .LEFDE1-.LASFDE1 /* FDE Length */
+.LASFDE1:
+ .4byte .LASFDE1-.Lframe1 /* FDE CIE offset */
+#if defined _RELOCATABLE || defined __PIC__
+ .4byte .LFB1-. /* FDE initial location */
+#else
+ .4byte .LFB1 /* FDE initial location */
+#endif
+ .4byte .LFE1-.LFB1 /* FDE address range */
+#if defined _RELOCATABLE || defined __PIC__
+ .uleb128 0x0 /* Augmentation size */
+#endif
+ .byte 0x4 /* DW_CFA_advance_loc4 */
+ .4byte .LCFI0-.LFB1
+ .byte 0xd /* DW_CFA_def_cfa_register */
+ .uleb128 0x08
+ .byte 0x4 /* DW_CFA_advance_loc4 */
+ .4byte .LCFI5-.LCFI0
+ .byte 0x11 /* DW_CFA_offset_extended_sf */
+ .uleb128 0x41
+ .sleb128 -1
+ .byte 0x9f /* DW_CFA_offset, column 0x1f */
+ .uleb128 0x1
+ .byte 0x9e /* DW_CFA_offset, column 0x1e */
+ .uleb128 0x2
+ .byte 0x9d /* DW_CFA_offset, column 0x1d */
+ .uleb128 0x3
+ .byte 0x9c /* DW_CFA_offset, column 0x1c */
+ .uleb128 0x4
+ .byte 0x4 /* DW_CFA_advance_loc4 */
+ .4byte .LCFI6-.LCFI5
+ .byte 0xd /* DW_CFA_def_cfa_register */
+ .uleb128 0x1c
+ .align 2
+.LEFDE1:
+
+#if defined __ELF__ && defined __linux__
+ .section .note.GNU-stack,"",@progbits
+#endif
+#endif
diff --git a/jni/ruby/ext/fiddle/libffi-3.2.1/src/prep_cif.c b/jni/ruby/ext/fiddle/libffi-3.2.1/src/prep_cif.c
new file mode 100644
index 0000000..be5eae3
--- /dev/null
+++ b/jni/ruby/ext/fiddle/libffi-3.2.1/src/prep_cif.c
@@ -0,0 +1,253 @@
+/* -----------------------------------------------------------------------
+ prep_cif.c - Copyright (c) 2011, 2012 Anthony Green
+ Copyright (c) 1996, 1998, 2007 Red Hat, Inc.
+
+ Permission is hereby granted, free of charge, to any person obtaining
+ a copy of this software and associated documentation files (the
+ ``Software''), to deal in the Software without restriction, including
+ without limitation the rights to use, copy, modify, merge, publish,
+ distribute, sublicense, and/or sell copies of the Software, and to
+ permit persons to whom the Software is furnished to do so, subject to
+ the following conditions:
+
+ The above copyright notice and this permission notice shall be included
+ in all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND,
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+ HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ DEALINGS IN THE SOFTWARE.
+ ----------------------------------------------------------------------- */
+
+#include <ffi.h>
+#include <ffi_common.h>
+#include <stdlib.h>
+
+/* Round up to FFI_SIZEOF_ARG. */
+
+#define STACK_ARG_SIZE(x) ALIGN(x, FFI_SIZEOF_ARG)
+
+/* Perform machine independent initialization of aggregate type
+ specifications. */
+
+static ffi_status initialize_aggregate(ffi_type *arg)
+{
+ ffi_type **ptr;
+
+ if (UNLIKELY(arg == NULL || arg->elements == NULL))
+ return FFI_BAD_TYPEDEF;
+
+ arg->size = 0;
+ arg->alignment = 0;
+
+ ptr = &(arg->elements[0]);
+
+ if (UNLIKELY(ptr == 0))
+ return FFI_BAD_TYPEDEF;
+
+ while ((*ptr) != NULL)
+ {
+ if (UNLIKELY(((*ptr)->size == 0)
+ && (initialize_aggregate((*ptr)) != FFI_OK)))
+ return FFI_BAD_TYPEDEF;
+
+ /* Perform a sanity check on the argument type */
+ FFI_ASSERT_VALID_TYPE(*ptr);
+
+ arg->size = ALIGN(arg->size, (*ptr)->alignment);
+ arg->size += (*ptr)->size;
+
+ arg->alignment = (arg->alignment > (*ptr)->alignment) ?
+ arg->alignment : (*ptr)->alignment;
+
+ ptr++;
+ }
+
+ /* Structure size includes tail padding. This is important for
+ structures that fit in one register on ABIs like the PowerPC64
+ Linux ABI that right justify small structs in a register.
+ It's also needed for nested structure layout, for example
+ struct A { long a; char b; }; struct B { struct A x; char y; };
+ should find y at an offset of 2*sizeof(long) and result in a
+ total size of 3*sizeof(long). */
+ arg->size = ALIGN (arg->size, arg->alignment);
+
+ /* On some targets, the ABI defines that structures have an additional
+ alignment beyond the "natural" one based on their elements. */
+#ifdef FFI_AGGREGATE_ALIGNMENT
+ if (FFI_AGGREGATE_ALIGNMENT > arg->alignment)
+ arg->alignment = FFI_AGGREGATE_ALIGNMENT;
+#endif
+
+ if (arg->size == 0)
+ return FFI_BAD_TYPEDEF;
+ else
+ return FFI_OK;
+}
+
+#ifndef __CRIS__
+/* The CRIS ABI specifies structure elements to have byte
+ alignment only, so it completely overrides this functions,
+ which assumes "natural" alignment and padding. */
+
+/* Perform machine independent ffi_cif preparation, then call
+ machine dependent routine. */
+
+/* For non variadic functions isvariadic should be 0 and
+ nfixedargs==ntotalargs.
+
+ For variadic calls, isvariadic should be 1 and nfixedargs
+ and ntotalargs set as appropriate. nfixedargs must always be >=1 */
+
+
+ffi_status FFI_HIDDEN ffi_prep_cif_core(ffi_cif *cif, ffi_abi abi,
+ unsigned int isvariadic,
+ unsigned int nfixedargs,
+ unsigned int ntotalargs,
+ ffi_type *rtype, ffi_type **atypes)
+{
+ unsigned bytes = 0;
+ unsigned int i;
+ ffi_type **ptr;
+
+ FFI_ASSERT(cif != NULL);
+ FFI_ASSERT((!isvariadic) || (nfixedargs >= 1));
+ FFI_ASSERT(nfixedargs <= ntotalargs);
+
+ if (! (abi > FFI_FIRST_ABI && abi < FFI_LAST_ABI))
+ return FFI_BAD_ABI;
+
+ cif->abi = abi;
+ cif->arg_types = atypes;
+ cif->nargs = ntotalargs;
+ cif->rtype = rtype;
+
+ cif->flags = 0;
+
+#if HAVE_LONG_DOUBLE_VARIANT
+ ffi_prep_types (abi);
+#endif
+
+ /* Initialize the return type if necessary */
+ if ((cif->rtype->size == 0) && (initialize_aggregate(cif->rtype) != FFI_OK))
+ return FFI_BAD_TYPEDEF;
+
+#ifndef FFI_TARGET_HAS_COMPLEX_TYPE
+ if (rtype->type == FFI_TYPE_COMPLEX)
+ abort();
+#endif
+ /* Perform a sanity check on the return type */
+ FFI_ASSERT_VALID_TYPE(cif->rtype);
+
+ /* x86, x86-64 and s390 stack space allocation is handled in prep_machdep. */
+#if !defined FFI_TARGET_SPECIFIC_STACK_SPACE_ALLOCATION
+ /* Make space for the return structure pointer */
+ if (cif->rtype->type == FFI_TYPE_STRUCT
+#ifdef SPARC
+ && (cif->abi != FFI_V9 || cif->rtype->size > 32)
+#endif
+#ifdef TILE
+ && (cif->rtype->size > 10 * FFI_SIZEOF_ARG)
+#endif
+#ifdef XTENSA
+ && (cif->rtype->size > 16)
+#endif
+#ifdef NIOS2
+ && (cif->rtype->size > 8)
+#endif
+ )
+ bytes = STACK_ARG_SIZE(sizeof(void*));
+#endif
+
+ for (ptr = cif->arg_types, i = cif->nargs; i > 0; i--, ptr++)
+ {
+
+ /* Initialize any uninitialized aggregate type definitions */
+ if (((*ptr)->size == 0) && (initialize_aggregate((*ptr)) != FFI_OK))
+ return FFI_BAD_TYPEDEF;
+
+#ifndef FFI_TARGET_HAS_COMPLEX_TYPE
+ if ((*ptr)->type == FFI_TYPE_COMPLEX)
+ abort();
+#endif
+ /* Perform a sanity check on the argument type, do this
+ check after the initialization. */
+ FFI_ASSERT_VALID_TYPE(*ptr);
+
+#if !defined FFI_TARGET_SPECIFIC_STACK_SPACE_ALLOCATION
+#ifdef SPARC
+ if (((*ptr)->type == FFI_TYPE_STRUCT
+ && ((*ptr)->size > 16 || cif->abi != FFI_V9))
+ || ((*ptr)->type == FFI_TYPE_LONGDOUBLE
+ && cif->abi != FFI_V9))
+ bytes += sizeof(void*);
+ else
+#endif
+ {
+ /* Add any padding if necessary */
+ if (((*ptr)->alignment - 1) & bytes)
+ bytes = (unsigned)ALIGN(bytes, (*ptr)->alignment);
+
+#ifdef TILE
+ if (bytes < 10 * FFI_SIZEOF_ARG &&
+ bytes + STACK_ARG_SIZE((*ptr)->size) > 10 * FFI_SIZEOF_ARG)
+ {
+ /* An argument is never split between the 10 parameter
+ registers and the stack. */
+ bytes = 10 * FFI_SIZEOF_ARG;
+ }
+#endif
+#ifdef XTENSA
+ if (bytes <= 6*4 && bytes + STACK_ARG_SIZE((*ptr)->size) > 6*4)
+ bytes = 6*4;
+#endif
+
+ bytes += STACK_ARG_SIZE((*ptr)->size);
+ }
+#endif
+ }
+
+ cif->bytes = bytes;
+
+ /* Perform machine dependent cif processing */
+#ifdef FFI_TARGET_SPECIFIC_VARIADIC
+ if (isvariadic)
+ return ffi_prep_cif_machdep_var(cif, nfixedargs, ntotalargs);
+#endif
+
+ return ffi_prep_cif_machdep(cif);
+}
+#endif /* not __CRIS__ */
+
+ffi_status ffi_prep_cif(ffi_cif *cif, ffi_abi abi, unsigned int nargs,
+ ffi_type *rtype, ffi_type **atypes)
+{
+ return ffi_prep_cif_core(cif, abi, 0, nargs, nargs, rtype, atypes);
+}
+
+ffi_status ffi_prep_cif_var(ffi_cif *cif,
+ ffi_abi abi,
+ unsigned int nfixedargs,
+ unsigned int ntotalargs,
+ ffi_type *rtype,
+ ffi_type **atypes)
+{
+ return ffi_prep_cif_core(cif, abi, 1, nfixedargs, ntotalargs, rtype, atypes);
+}
+
+#if FFI_CLOSURES
+
+ffi_status
+ffi_prep_closure (ffi_closure* closure,
+ ffi_cif* cif,
+ void (*fun)(ffi_cif*,void*,void**,void*),
+ void *user_data)
+{
+ return ffi_prep_closure_loc (closure, cif, fun, user_data, closure);
+}
+
+#endif
diff --git a/jni/ruby/ext/fiddle/libffi-3.2.1/src/raw_api.c b/jni/ruby/ext/fiddle/libffi-3.2.1/src/raw_api.c
new file mode 100644
index 0000000..276cb22
--- /dev/null
+++ b/jni/ruby/ext/fiddle/libffi-3.2.1/src/raw_api.c
@@ -0,0 +1,267 @@
+/* -----------------------------------------------------------------------
+ raw_api.c - Copyright (c) 1999, 2008 Red Hat, Inc.
+
+ Author: Kresten Krab Thorup <krab@gnu.org>
+
+ Permission is hereby granted, free of charge, to any person obtaining
+ a copy of this software and associated documentation files (the
+ ``Software''), to deal in the Software without restriction, including
+ without limitation the rights to use, copy, modify, merge, publish,
+ distribute, sublicense, and/or sell copies of the Software, and to
+ permit persons to whom the Software is furnished to do so, subject to
+ the following conditions:
+
+ The above copyright notice and this permission notice shall be included
+ in all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND,
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+ HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ DEALINGS IN THE SOFTWARE.
+ ----------------------------------------------------------------------- */
+
+/* This file defines generic functions for use with the raw api. */
+
+#include <ffi.h>
+#include <ffi_common.h>
+
+#if !FFI_NO_RAW_API
+
+size_t
+ffi_raw_size (ffi_cif *cif)
+{
+ size_t result = 0;
+ int i;
+
+ ffi_type **at = cif->arg_types;
+
+ for (i = cif->nargs-1; i >= 0; i--, at++)
+ {
+#if !FFI_NO_STRUCTS
+ if ((*at)->type == FFI_TYPE_STRUCT)
+ result += ALIGN (sizeof (void*), FFI_SIZEOF_ARG);
+ else
+#endif
+ result += ALIGN ((*at)->size, FFI_SIZEOF_ARG);
+ }
+
+ return result;
+}
+
+
+void
+ffi_raw_to_ptrarray (ffi_cif *cif, ffi_raw *raw, void **args)
+{
+ unsigned i;
+ ffi_type **tp = cif->arg_types;
+
+#if WORDS_BIGENDIAN
+
+ for (i = 0; i < cif->nargs; i++, tp++, args++)
+ {
+ switch ((*tp)->type)
+ {
+ case FFI_TYPE_UINT8:
+ case FFI_TYPE_SINT8:
+ *args = (void*) ((char*)(raw++) + FFI_SIZEOF_ARG - 1);
+ break;
+
+ case FFI_TYPE_UINT16:
+ case FFI_TYPE_SINT16:
+ *args = (void*) ((char*)(raw++) + FFI_SIZEOF_ARG - 2);
+ break;
+
+#if FFI_SIZEOF_ARG >= 4
+ case FFI_TYPE_UINT32:
+ case FFI_TYPE_SINT32:
+ *args = (void*) ((char*)(raw++) + FFI_SIZEOF_ARG - 4);
+ break;
+#endif
+
+#if !FFI_NO_STRUCTS
+ case FFI_TYPE_STRUCT:
+ *args = (raw++)->ptr;
+ break;
+#endif
+
+ case FFI_TYPE_COMPLEX:
+ *args = (raw++)->ptr;
+ break;
+
+ case FFI_TYPE_POINTER:
+ *args = (void*) &(raw++)->ptr;
+ break;
+
+ default:
+ *args = raw;
+ raw += ALIGN ((*tp)->size, FFI_SIZEOF_ARG) / FFI_SIZEOF_ARG;
+ }
+ }
+
+#else /* WORDS_BIGENDIAN */
+
+#if !PDP
+
+ /* then assume little endian */
+ for (i = 0; i < cif->nargs; i++, tp++, args++)
+ {
+#if !FFI_NO_STRUCTS
+ if ((*tp)->type == FFI_TYPE_STRUCT)
+ {
+ *args = (raw++)->ptr;
+ }
+ else
+#endif
+ if ((*tp)->type == FFI_TYPE_COMPLEX)
+ {
+ *args = (raw++)->ptr;
+ }
+ else
+ {
+ *args = (void*) raw;
+ raw += ALIGN ((*tp)->size, sizeof (void*)) / sizeof (void*);
+ }
+ }
+
+#else
+#error "pdp endian not supported"
+#endif /* ! PDP */
+
+#endif /* WORDS_BIGENDIAN */
+}
+
+void
+ffi_ptrarray_to_raw (ffi_cif *cif, void **args, ffi_raw *raw)
+{
+ unsigned i;
+ ffi_type **tp = cif->arg_types;
+
+ for (i = 0; i < cif->nargs; i++, tp++, args++)
+ {
+ switch ((*tp)->type)
+ {
+ case FFI_TYPE_UINT8:
+ (raw++)->uint = *(UINT8*) (*args);
+ break;
+
+ case FFI_TYPE_SINT8:
+ (raw++)->sint = *(SINT8*) (*args);
+ break;
+
+ case FFI_TYPE_UINT16:
+ (raw++)->uint = *(UINT16*) (*args);
+ break;
+
+ case FFI_TYPE_SINT16:
+ (raw++)->sint = *(SINT16*) (*args);
+ break;
+
+#if FFI_SIZEOF_ARG >= 4
+ case FFI_TYPE_UINT32:
+ (raw++)->uint = *(UINT32*) (*args);
+ break;
+
+ case FFI_TYPE_SINT32:
+ (raw++)->sint = *(SINT32*) (*args);
+ break;
+#endif
+
+#if !FFI_NO_STRUCTS
+ case FFI_TYPE_STRUCT:
+ (raw++)->ptr = *args;
+ break;
+#endif
+
+ case FFI_TYPE_COMPLEX:
+ (raw++)->ptr = *args;
+ break;
+
+ case FFI_TYPE_POINTER:
+ (raw++)->ptr = **(void***) args;
+ break;
+
+ default:
+ memcpy ((void*) raw->data, (void*)*args, (*tp)->size);
+ raw += ALIGN ((*tp)->size, FFI_SIZEOF_ARG) / FFI_SIZEOF_ARG;
+ }
+ }
+}
+
+#if !FFI_NATIVE_RAW_API
+
+
+/* This is a generic definition of ffi_raw_call, to be used if the
+ * native system does not provide a machine-specific implementation.
+ * Having this, allows code to be written for the raw API, without
+ * the need for system-specific code to handle input in that format;
+ * these following couple of functions will handle the translation forth
+ * and back automatically. */
+
+void ffi_raw_call (ffi_cif *cif, void (*fn)(void), void *rvalue, ffi_raw *raw)
+{
+ void **avalue = (void**) alloca (cif->nargs * sizeof (void*));
+ ffi_raw_to_ptrarray (cif, raw, avalue);
+ ffi_call (cif, fn, rvalue, avalue);
+}
+
+#if FFI_CLOSURES /* base system provides closures */
+
+static void
+ffi_translate_args (ffi_cif *cif, void *rvalue,
+ void **avalue, void *user_data)
+{
+ ffi_raw *raw = (ffi_raw*)alloca (ffi_raw_size (cif));
+ ffi_raw_closure *cl = (ffi_raw_closure*)user_data;
+
+ ffi_ptrarray_to_raw (cif, avalue, raw);
+ (*cl->fun) (cif, rvalue, raw, cl->user_data);
+}
+
+ffi_status
+ffi_prep_raw_closure_loc (ffi_raw_closure* cl,
+ ffi_cif *cif,
+ void (*fun)(ffi_cif*,void*,ffi_raw*,void*),
+ void *user_data,
+ void *codeloc)
+{
+ ffi_status status;
+
+ status = ffi_prep_closure_loc ((ffi_closure*) cl,
+ cif,
+ &ffi_translate_args,
+ codeloc,
+ codeloc);
+ if (status == FFI_OK)
+ {
+ cl->fun = fun;
+ cl->user_data = user_data;
+ }
+
+ return status;
+}
+
+#endif /* FFI_CLOSURES */
+#endif /* !FFI_NATIVE_RAW_API */
+
+#if FFI_CLOSURES
+
+/* Again, here is the generic version of ffi_prep_raw_closure, which
+ * will install an intermediate "hub" for translation of arguments from
+ * the pointer-array format, to the raw format */
+
+ffi_status
+ffi_prep_raw_closure (ffi_raw_closure* cl,
+ ffi_cif *cif,
+ void (*fun)(ffi_cif*,void*,ffi_raw*,void*),
+ void *user_data)
+{
+ return ffi_prep_raw_closure_loc (cl, cif, fun, user_data, cl);
+}
+
+#endif /* FFI_CLOSURES */
+
+#endif /* !FFI_NO_RAW_API */
diff --git a/jni/ruby/ext/fiddle/libffi-3.2.1/src/s390/ffi.c b/jni/ruby/ext/fiddle/libffi-3.2.1/src/s390/ffi.c
new file mode 100644
index 0000000..520ec7c
--- /dev/null
+++ b/jni/ruby/ext/fiddle/libffi-3.2.1/src/s390/ffi.c
@@ -0,0 +1,792 @@
+/* -----------------------------------------------------------------------
+ ffi.c - Copyright (c) 2000, 2007 Software AG
+ Copyright (c) 2008 Red Hat, Inc
+
+ S390 Foreign Function Interface
+
+ Permission is hereby granted, free of charge, to any person obtaining
+ a copy of this software and associated documentation files (the
+ ``Software''), to deal in the Software without restriction, including
+ without limitation the rights to use, copy, modify, merge, publish,
+ distribute, sublicense, and/or sell copies of the Software, and to
+ permit persons to whom the Software is furnished to do so, subject to
+ the following conditions:
+
+ The above copyright notice and this permission notice shall be included
+ in all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ OTHER DEALINGS IN THE SOFTWARE.
+ ----------------------------------------------------------------------- */
+/*====================================================================*/
+/* Includes */
+/* -------- */
+/*====================================================================*/
+
+#include <ffi.h>
+#include <ffi_common.h>
+
+#include <stdlib.h>
+#include <stdio.h>
+
+/*====================== End of Includes =============================*/
+
+/*====================================================================*/
+/* Defines */
+/* ------- */
+/*====================================================================*/
+
+/* Maximum number of GPRs available for argument passing. */
+#define MAX_GPRARGS 5
+
+/* Maximum number of FPRs available for argument passing. */
+#ifdef __s390x__
+#define MAX_FPRARGS 4
+#else
+#define MAX_FPRARGS 2
+#endif
+
+/* Round to multiple of 16. */
+#define ROUND_SIZE(size) (((size) + 15) & ~15)
+
+/* If these values change, sysv.S must be adapted! */
+#define FFI390_RET_VOID 0
+#define FFI390_RET_STRUCT 1
+#define FFI390_RET_FLOAT 2
+#define FFI390_RET_DOUBLE 3
+#define FFI390_RET_INT32 4
+#define FFI390_RET_INT64 5
+
+/*===================== End of Defines ===============================*/
+
+/*====================================================================*/
+/* Prototypes */
+/* ---------- */
+/*====================================================================*/
+
+static void ffi_prep_args (unsigned char *, extended_cif *);
+void
+#if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ > 2)
+__attribute__ ((visibility ("hidden")))
+#endif
+ffi_closure_helper_SYSV (ffi_closure *, unsigned long *,
+ unsigned long long *, unsigned long *);
+
+/*====================== End of Prototypes ===========================*/
+
+/*====================================================================*/
+/* Externals */
+/* --------- */
+/*====================================================================*/
+
+extern void ffi_call_SYSV(unsigned,
+ extended_cif *,
+ void (*)(unsigned char *, extended_cif *),
+ unsigned,
+ void *,
+ void (*fn)(void));
+
+extern void ffi_closure_SYSV(void);
+
+/*====================== End of Externals ============================*/
+
+/*====================================================================*/
+/* */
+/* Name - ffi_check_struct_type. */
+/* */
+/* Function - Determine if a structure can be passed within a */
+/* general purpose or floating point register. */
+/* */
+/*====================================================================*/
+
+static int
+ffi_check_struct_type (ffi_type *arg)
+{
+ size_t size = arg->size;
+
+ /* If the struct has just one element, look at that element
+ to find out whether to consider the struct as floating point. */
+ while (arg->type == FFI_TYPE_STRUCT
+ && arg->elements[0] && !arg->elements[1])
+ arg = arg->elements[0];
+
+ /* Structs of size 1, 2, 4, and 8 are passed in registers,
+ just like the corresponding int/float types. */
+ switch (size)
+ {
+ case 1:
+ return FFI_TYPE_UINT8;
+
+ case 2:
+ return FFI_TYPE_UINT16;
+
+ case 4:
+ if (arg->type == FFI_TYPE_FLOAT)
+ return FFI_TYPE_FLOAT;
+ else
+ return FFI_TYPE_UINT32;
+
+ case 8:
+ if (arg->type == FFI_TYPE_DOUBLE)
+ return FFI_TYPE_DOUBLE;
+ else
+ return FFI_TYPE_UINT64;
+
+ default:
+ break;
+ }
+
+ /* Other structs are passed via a pointer to the data. */
+ return FFI_TYPE_POINTER;
+}
+
+/*======================== End of Routine ============================*/
+
+/*====================================================================*/
+/* */
+/* Name - ffi_prep_args. */
+/* */
+/* Function - Prepare parameters for call to function. */
+/* */
+/* ffi_prep_args is called by the assembly routine once stack space */
+/* has been allocated for the function's arguments. */
+/* */
+/*====================================================================*/
+
+static void
+ffi_prep_args (unsigned char *stack, extended_cif *ecif)
+{
+ /* The stack space will be filled with those areas:
+
+ FPR argument register save area (highest addresses)
+ GPR argument register save area
+ temporary struct copies
+ overflow argument area (lowest addresses)
+
+ We set up the following pointers:
+
+ p_fpr: bottom of the FPR area (growing upwards)
+ p_gpr: bottom of the GPR area (growing upwards)
+ p_ov: bottom of the overflow area (growing upwards)
+ p_struct: top of the struct copy area (growing downwards)
+
+ All areas are kept aligned to twice the word size. */
+
+ int gpr_off = ecif->cif->bytes;
+ int fpr_off = gpr_off + ROUND_SIZE (MAX_GPRARGS * sizeof (long));
+
+ unsigned long long *p_fpr = (unsigned long long *)(stack + fpr_off);
+ unsigned long *p_gpr = (unsigned long *)(stack + gpr_off);
+ unsigned char *p_struct = (unsigned char *)p_gpr;
+ unsigned long *p_ov = (unsigned long *)stack;
+
+ int n_fpr = 0;
+ int n_gpr = 0;
+ int n_ov = 0;
+
+ ffi_type **ptr;
+ void **p_argv = ecif->avalue;
+ int i;
+
+ /* If we returning a structure then we set the first parameter register
+ to the address of where we are returning this structure. */
+
+ if (ecif->cif->flags == FFI390_RET_STRUCT)
+ p_gpr[n_gpr++] = (unsigned long) ecif->rvalue;
+
+ /* Now for the arguments. */
+
+ for (ptr = ecif->cif->arg_types, i = ecif->cif->nargs;
+ i > 0;
+ i--, ptr++, p_argv++)
+ {
+ void *arg = *p_argv;
+ int type = (*ptr)->type;
+
+#if FFI_TYPE_LONGDOUBLE != FFI_TYPE_DOUBLE
+ /* 16-byte long double is passed like a struct. */
+ if (type == FFI_TYPE_LONGDOUBLE)
+ type = FFI_TYPE_STRUCT;
+#endif
+
+ /* Check how a structure type is passed. */
+ if (type == FFI_TYPE_STRUCT || type == FFI_TYPE_COMPLEX)
+ {
+ if (type == FFI_TYPE_COMPLEX)
+ type = FFI_TYPE_POINTER;
+ else
+ type = ffi_check_struct_type (*ptr);
+
+ /* If we pass the struct via pointer, copy the data. */
+ if (type == FFI_TYPE_POINTER)
+ {
+ p_struct -= ROUND_SIZE ((*ptr)->size);
+ memcpy (p_struct, (char *)arg, (*ptr)->size);
+ arg = &p_struct;
+ }
+ }
+
+ /* Now handle all primitive int/pointer/float data types. */
+ switch (type)
+ {
+ case FFI_TYPE_DOUBLE:
+ if (n_fpr < MAX_FPRARGS)
+ p_fpr[n_fpr++] = *(unsigned long long *) arg;
+ else
+#ifdef __s390x__
+ p_ov[n_ov++] = *(unsigned long *) arg;
+#else
+ p_ov[n_ov++] = ((unsigned long *) arg)[0],
+ p_ov[n_ov++] = ((unsigned long *) arg)[1];
+#endif
+ break;
+
+ case FFI_TYPE_FLOAT:
+ if (n_fpr < MAX_FPRARGS)
+ p_fpr[n_fpr++] = (long long) *(unsigned int *) arg << 32;
+ else
+ p_ov[n_ov++] = *(unsigned int *) arg;
+ break;
+
+ case FFI_TYPE_POINTER:
+ if (n_gpr < MAX_GPRARGS)
+ p_gpr[n_gpr++] = (unsigned long)*(unsigned char **) arg;
+ else
+ p_ov[n_ov++] = (unsigned long)*(unsigned char **) arg;
+ break;
+
+ case FFI_TYPE_UINT64:
+ case FFI_TYPE_SINT64:
+#ifdef __s390x__
+ if (n_gpr < MAX_GPRARGS)
+ p_gpr[n_gpr++] = *(unsigned long *) arg;
+ else
+ p_ov[n_ov++] = *(unsigned long *) arg;
+#else
+ if (n_gpr == MAX_GPRARGS-1)
+ n_gpr = MAX_GPRARGS;
+ if (n_gpr < MAX_GPRARGS)
+ p_gpr[n_gpr++] = ((unsigned long *) arg)[0],
+ p_gpr[n_gpr++] = ((unsigned long *) arg)[1];
+ else
+ p_ov[n_ov++] = ((unsigned long *) arg)[0],
+ p_ov[n_ov++] = ((unsigned long *) arg)[1];
+#endif
+ break;
+
+ case FFI_TYPE_UINT32:
+ if (n_gpr < MAX_GPRARGS)
+ p_gpr[n_gpr++] = *(unsigned int *) arg;
+ else
+ p_ov[n_ov++] = *(unsigned int *) arg;
+ break;
+
+ case FFI_TYPE_INT:
+ case FFI_TYPE_SINT32:
+ if (n_gpr < MAX_GPRARGS)
+ p_gpr[n_gpr++] = *(signed int *) arg;
+ else
+ p_ov[n_ov++] = *(signed int *) arg;
+ break;
+
+ case FFI_TYPE_UINT16:
+ if (n_gpr < MAX_GPRARGS)
+ p_gpr[n_gpr++] = *(unsigned short *) arg;
+ else
+ p_ov[n_ov++] = *(unsigned short *) arg;
+ break;
+
+ case FFI_TYPE_SINT16:
+ if (n_gpr < MAX_GPRARGS)
+ p_gpr[n_gpr++] = *(signed short *) arg;
+ else
+ p_ov[n_ov++] = *(signed short *) arg;
+ break;
+
+ case FFI_TYPE_UINT8:
+ if (n_gpr < MAX_GPRARGS)
+ p_gpr[n_gpr++] = *(unsigned char *) arg;
+ else
+ p_ov[n_ov++] = *(unsigned char *) arg;
+ break;
+
+ case FFI_TYPE_SINT8:
+ if (n_gpr < MAX_GPRARGS)
+ p_gpr[n_gpr++] = *(signed char *) arg;
+ else
+ p_ov[n_ov++] = *(signed char *) arg;
+ break;
+
+ default:
+ FFI_ASSERT (0);
+ break;
+ }
+ }
+}
+
+/*======================== End of Routine ============================*/
+
+/*====================================================================*/
+/* */
+/* Name - ffi_prep_cif_machdep. */
+/* */
+/* Function - Perform machine dependent CIF processing. */
+/* */
+/*====================================================================*/
+
+ffi_status
+ffi_prep_cif_machdep(ffi_cif *cif)
+{
+ size_t struct_size = 0;
+ int n_gpr = 0;
+ int n_fpr = 0;
+ int n_ov = 0;
+
+ ffi_type **ptr;
+ int i;
+
+ /* Determine return value handling. */
+
+ switch (cif->rtype->type)
+ {
+ /* Void is easy. */
+ case FFI_TYPE_VOID:
+ cif->flags = FFI390_RET_VOID;
+ break;
+
+ /* Structures and complex are returned via a hidden pointer. */
+ case FFI_TYPE_STRUCT:
+ case FFI_TYPE_COMPLEX:
+ cif->flags = FFI390_RET_STRUCT;
+ n_gpr++; /* We need one GPR to pass the pointer. */
+ break;
+
+ /* Floating point values are returned in fpr 0. */
+ case FFI_TYPE_FLOAT:
+ cif->flags = FFI390_RET_FLOAT;
+ break;
+
+ case FFI_TYPE_DOUBLE:
+ cif->flags = FFI390_RET_DOUBLE;
+ break;
+
+#if FFI_TYPE_LONGDOUBLE != FFI_TYPE_DOUBLE
+ case FFI_TYPE_LONGDOUBLE:
+ cif->flags = FFI390_RET_STRUCT;
+ n_gpr++;
+ break;
+#endif
+ /* Integer values are returned in gpr 2 (and gpr 3
+ for 64-bit values on 31-bit machines). */
+ case FFI_TYPE_UINT64:
+ case FFI_TYPE_SINT64:
+ cif->flags = FFI390_RET_INT64;
+ break;
+
+ case FFI_TYPE_POINTER:
+ case FFI_TYPE_INT:
+ case FFI_TYPE_UINT32:
+ case FFI_TYPE_SINT32:
+ case FFI_TYPE_UINT16:
+ case FFI_TYPE_SINT16:
+ case FFI_TYPE_UINT8:
+ case FFI_TYPE_SINT8:
+ /* These are to be extended to word size. */
+#ifdef __s390x__
+ cif->flags = FFI390_RET_INT64;
+#else
+ cif->flags = FFI390_RET_INT32;
+#endif
+ break;
+
+ default:
+ FFI_ASSERT (0);
+ break;
+ }
+
+ /* Now for the arguments. */
+
+ for (ptr = cif->arg_types, i = cif->nargs;
+ i > 0;
+ i--, ptr++)
+ {
+ int type = (*ptr)->type;
+
+#if FFI_TYPE_LONGDOUBLE != FFI_TYPE_DOUBLE
+ /* 16-byte long double is passed like a struct. */
+ if (type == FFI_TYPE_LONGDOUBLE)
+ type = FFI_TYPE_STRUCT;
+#endif
+
+ /* Check how a structure type is passed. */
+ if (type == FFI_TYPE_STRUCT || type == FFI_TYPE_COMPLEX)
+ {
+ if (type == FFI_TYPE_COMPLEX)
+ type = FFI_TYPE_POINTER;
+ else
+ type = ffi_check_struct_type (*ptr);
+
+ /* If we pass the struct via pointer, we must reserve space
+ to copy its data for proper call-by-value semantics. */
+ if (type == FFI_TYPE_POINTER)
+ struct_size += ROUND_SIZE ((*ptr)->size);
+ }
+
+ /* Now handle all primitive int/float data types. */
+ switch (type)
+ {
+ /* The first MAX_FPRARGS floating point arguments
+ go in FPRs, the rest overflow to the stack. */
+
+ case FFI_TYPE_DOUBLE:
+ if (n_fpr < MAX_FPRARGS)
+ n_fpr++;
+ else
+ n_ov += sizeof (double) / sizeof (long);
+ break;
+
+ case FFI_TYPE_FLOAT:
+ if (n_fpr < MAX_FPRARGS)
+ n_fpr++;
+ else
+ n_ov++;
+ break;
+
+ /* On 31-bit machines, 64-bit integers are passed in GPR pairs,
+ if one is still available, or else on the stack. If only one
+ register is free, skip the register (it won't be used for any
+ subsequent argument either). */
+
+#ifndef __s390x__
+ case FFI_TYPE_UINT64:
+ case FFI_TYPE_SINT64:
+ if (n_gpr == MAX_GPRARGS-1)
+ n_gpr = MAX_GPRARGS;
+ if (n_gpr < MAX_GPRARGS)
+ n_gpr += 2;
+ else
+ n_ov += 2;
+ break;
+#endif
+
+ /* Everything else is passed in GPRs (until MAX_GPRARGS
+ have been used) or overflows to the stack. */
+
+ default:
+ if (n_gpr < MAX_GPRARGS)
+ n_gpr++;
+ else
+ n_ov++;
+ break;
+ }
+ }
+
+ /* Total stack space as required for overflow arguments
+ and temporary structure copies. */
+
+ cif->bytes = ROUND_SIZE (n_ov * sizeof (long)) + struct_size;
+
+ return FFI_OK;
+}
+
+/*======================== End of Routine ============================*/
+
+/*====================================================================*/
+/* */
+/* Name - ffi_call. */
+/* */
+/* Function - Call the FFI routine. */
+/* */
+/*====================================================================*/
+
+void
+ffi_call(ffi_cif *cif,
+ void (*fn)(void),
+ void *rvalue,
+ void **avalue)
+{
+ int ret_type = cif->flags;
+ extended_cif ecif;
+
+ ecif.cif = cif;
+ ecif.avalue = avalue;
+ ecif.rvalue = rvalue;
+
+ /* If we don't have a return value, we need to fake one. */
+ if (rvalue == NULL)
+ {
+ if (ret_type == FFI390_RET_STRUCT)
+ ecif.rvalue = alloca (cif->rtype->size);
+ else
+ ret_type = FFI390_RET_VOID;
+ }
+
+ switch (cif->abi)
+ {
+ case FFI_SYSV:
+ ffi_call_SYSV (cif->bytes, &ecif, ffi_prep_args,
+ ret_type, ecif.rvalue, fn);
+ break;
+
+ default:
+ FFI_ASSERT (0);
+ break;
+ }
+}
+
+/*======================== End of Routine ============================*/
+
+/*====================================================================*/
+/* */
+/* Name - ffi_closure_helper_SYSV. */
+/* */
+/* Function - Call a FFI closure target function. */
+/* */
+/*====================================================================*/
+
+void
+ffi_closure_helper_SYSV (ffi_closure *closure,
+ unsigned long *p_gpr,
+ unsigned long long *p_fpr,
+ unsigned long *p_ov)
+{
+ unsigned long long ret_buffer;
+
+ void *rvalue = &ret_buffer;
+ void **avalue;
+ void **p_arg;
+
+ int n_gpr = 0;
+ int n_fpr = 0;
+ int n_ov = 0;
+
+ ffi_type **ptr;
+ int i;
+
+ /* Allocate buffer for argument list pointers. */
+
+ p_arg = avalue = alloca (closure->cif->nargs * sizeof (void *));
+
+ /* If we returning a structure, pass the structure address
+ directly to the target function. Otherwise, have the target
+ function store the return value to the GPR save area. */
+
+ if (closure->cif->flags == FFI390_RET_STRUCT)
+ rvalue = (void *) p_gpr[n_gpr++];
+
+ /* Now for the arguments. */
+
+ for (ptr = closure->cif->arg_types, i = closure->cif->nargs;
+ i > 0;
+ i--, p_arg++, ptr++)
+ {
+ int deref_struct_pointer = 0;
+ int type = (*ptr)->type;
+
+#if FFI_TYPE_LONGDOUBLE != FFI_TYPE_DOUBLE
+ /* 16-byte long double is passed like a struct. */
+ if (type == FFI_TYPE_LONGDOUBLE)
+ type = FFI_TYPE_STRUCT;
+#endif
+
+ /* Check how a structure type is passed. */
+ if (type == FFI_TYPE_STRUCT || type == FFI_TYPE_COMPLEX)
+ {
+ if (type == FFI_TYPE_COMPLEX)
+ type = FFI_TYPE_POINTER;
+ else
+ type = ffi_check_struct_type (*ptr);
+
+ /* If we pass the struct via pointer, remember to
+ retrieve the pointer later. */
+ if (type == FFI_TYPE_POINTER)
+ deref_struct_pointer = 1;
+ }
+
+ /* Pointers are passed like UINTs of the same size. */
+ if (type == FFI_TYPE_POINTER)
+#ifdef __s390x__
+ type = FFI_TYPE_UINT64;
+#else
+ type = FFI_TYPE_UINT32;
+#endif
+
+ /* Now handle all primitive int/float data types. */
+ switch (type)
+ {
+ case FFI_TYPE_DOUBLE:
+ if (n_fpr < MAX_FPRARGS)
+ *p_arg = &p_fpr[n_fpr++];
+ else
+ *p_arg = &p_ov[n_ov],
+ n_ov += sizeof (double) / sizeof (long);
+ break;
+
+ case FFI_TYPE_FLOAT:
+ if (n_fpr < MAX_FPRARGS)
+ *p_arg = &p_fpr[n_fpr++];
+ else
+ *p_arg = (char *)&p_ov[n_ov++] + sizeof (long) - 4;
+ break;
+
+ case FFI_TYPE_UINT64:
+ case FFI_TYPE_SINT64:
+#ifdef __s390x__
+ if (n_gpr < MAX_GPRARGS)
+ *p_arg = &p_gpr[n_gpr++];
+ else
+ *p_arg = &p_ov[n_ov++];
+#else
+ if (n_gpr == MAX_GPRARGS-1)
+ n_gpr = MAX_GPRARGS;
+ if (n_gpr < MAX_GPRARGS)
+ *p_arg = &p_gpr[n_gpr], n_gpr += 2;
+ else
+ *p_arg = &p_ov[n_ov], n_ov += 2;
+#endif
+ break;
+
+ case FFI_TYPE_INT:
+ case FFI_TYPE_UINT32:
+ case FFI_TYPE_SINT32:
+ if (n_gpr < MAX_GPRARGS)
+ *p_arg = (char *)&p_gpr[n_gpr++] + sizeof (long) - 4;
+ else
+ *p_arg = (char *)&p_ov[n_ov++] + sizeof (long) - 4;
+ break;
+
+ case FFI_TYPE_UINT16:
+ case FFI_TYPE_SINT16:
+ if (n_gpr < MAX_GPRARGS)
+ *p_arg = (char *)&p_gpr[n_gpr++] + sizeof (long) - 2;
+ else
+ *p_arg = (char *)&p_ov[n_ov++] + sizeof (long) - 2;
+ break;
+
+ case FFI_TYPE_UINT8:
+ case FFI_TYPE_SINT8:
+ if (n_gpr < MAX_GPRARGS)
+ *p_arg = (char *)&p_gpr[n_gpr++] + sizeof (long) - 1;
+ else
+ *p_arg = (char *)&p_ov[n_ov++] + sizeof (long) - 1;
+ break;
+
+ default:
+ FFI_ASSERT (0);
+ break;
+ }
+
+ /* If this is a struct passed via pointer, we need to
+ actually retrieve that pointer. */
+ if (deref_struct_pointer)
+ *p_arg = *(void **)*p_arg;
+ }
+
+
+ /* Call the target function. */
+ (closure->fun) (closure->cif, rvalue, avalue, closure->user_data);
+
+ /* Convert the return value. */
+ switch (closure->cif->rtype->type)
+ {
+ /* Void is easy, and so is struct. */
+ case FFI_TYPE_VOID:
+ case FFI_TYPE_STRUCT:
+ case FFI_TYPE_COMPLEX:
+#if FFI_TYPE_LONGDOUBLE != FFI_TYPE_DOUBLE
+ case FFI_TYPE_LONGDOUBLE:
+#endif
+ break;
+
+ /* Floating point values are returned in fpr 0. */
+ case FFI_TYPE_FLOAT:
+ p_fpr[0] = (long long) *(unsigned int *) rvalue << 32;
+ break;
+
+ case FFI_TYPE_DOUBLE:
+ p_fpr[0] = *(unsigned long long *) rvalue;
+ break;
+
+ /* Integer values are returned in gpr 2 (and gpr 3
+ for 64-bit values on 31-bit machines). */
+ case FFI_TYPE_UINT64:
+ case FFI_TYPE_SINT64:
+#ifdef __s390x__
+ p_gpr[0] = *(unsigned long *) rvalue;
+#else
+ p_gpr[0] = ((unsigned long *) rvalue)[0],
+ p_gpr[1] = ((unsigned long *) rvalue)[1];
+#endif
+ break;
+
+ case FFI_TYPE_POINTER:
+ case FFI_TYPE_UINT32:
+ case FFI_TYPE_UINT16:
+ case FFI_TYPE_UINT8:
+ p_gpr[0] = *(unsigned long *) rvalue;
+ break;
+
+ case FFI_TYPE_INT:
+ case FFI_TYPE_SINT32:
+ case FFI_TYPE_SINT16:
+ case FFI_TYPE_SINT8:
+ p_gpr[0] = *(signed long *) rvalue;
+ break;
+
+ default:
+ FFI_ASSERT (0);
+ break;
+ }
+}
+
+/*======================== End of Routine ============================*/
+
+/*====================================================================*/
+/* */
+/* Name - ffi_prep_closure_loc. */
+/* */
+/* Function - Prepare a FFI closure. */
+/* */
+/*====================================================================*/
+
+ffi_status
+ffi_prep_closure_loc (ffi_closure *closure,
+ ffi_cif *cif,
+ void (*fun) (ffi_cif *, void *, void **, void *),
+ void *user_data,
+ void *codeloc)
+{
+ if (cif->abi != FFI_SYSV)
+ return FFI_BAD_ABI;
+
+#ifndef __s390x__
+ *(short *)&closure->tramp [0] = 0x0d10; /* basr %r1,0 */
+ *(short *)&closure->tramp [2] = 0x9801; /* lm %r0,%r1,6(%r1) */
+ *(short *)&closure->tramp [4] = 0x1006;
+ *(short *)&closure->tramp [6] = 0x07f1; /* br %r1 */
+ *(long *)&closure->tramp [8] = (long)codeloc;
+ *(long *)&closure->tramp[12] = (long)&ffi_closure_SYSV;
+#else
+ *(short *)&closure->tramp [0] = 0x0d10; /* basr %r1,0 */
+ *(short *)&closure->tramp [2] = 0xeb01; /* lmg %r0,%r1,14(%r1) */
+ *(short *)&closure->tramp [4] = 0x100e;
+ *(short *)&closure->tramp [6] = 0x0004;
+ *(short *)&closure->tramp [8] = 0x07f1; /* br %r1 */
+ *(long *)&closure->tramp[16] = (long)codeloc;
+ *(long *)&closure->tramp[24] = (long)&ffi_closure_SYSV;
+#endif
+
+ closure->cif = cif;
+ closure->user_data = user_data;
+ closure->fun = fun;
+
+ return FFI_OK;
+}
+
+/*======================== End of Routine ============================*/
+
diff --git a/jni/ruby/ext/fiddle/libffi-3.2.1/src/s390/ffitarget.h b/jni/ruby/ext/fiddle/libffi-3.2.1/src/s390/ffitarget.h
new file mode 100644
index 0000000..0e4868a
--- /dev/null
+++ b/jni/ruby/ext/fiddle/libffi-3.2.1/src/s390/ffitarget.h
@@ -0,0 +1,69 @@
+/* -----------------------------------------------------------------*-C-*-
+ ffitarget.h - Copyright (c) 2012 Anthony Green
+ Copyright (c) 1996-2003 Red Hat, Inc.
+ Target configuration macros for S390.
+
+ Permission is hereby granted, free of charge, to any person obtaining
+ a copy of this software and associated documentation files (the
+ ``Software''), to deal in the Software without restriction, including
+ without limitation the rights to use, copy, modify, merge, publish,
+ distribute, sublicense, and/or sell copies of the Software, and to
+ permit persons to whom the Software is furnished to do so, subject to
+ the following conditions:
+
+ The above copyright notice and this permission notice shall be included
+ in all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND,
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+ HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ DEALINGS IN THE SOFTWARE.
+
+ ----------------------------------------------------------------------- */
+
+#ifndef LIBFFI_TARGET_H
+#define LIBFFI_TARGET_H
+
+#ifndef LIBFFI_H
+#error "Please do not include ffitarget.h directly into your source. Use ffi.h instead."
+#endif
+
+#if defined (__s390x__)
+#ifndef S390X
+#define S390X
+#endif
+#endif
+
+/* ---- System specific configurations ----------------------------------- */
+
+#ifndef LIBFFI_ASM
+typedef unsigned long ffi_arg;
+typedef signed long ffi_sarg;
+
+typedef enum ffi_abi {
+ FFI_FIRST_ABI = 0,
+ FFI_SYSV,
+ FFI_LAST_ABI,
+ FFI_DEFAULT_ABI = FFI_SYSV
+} ffi_abi;
+#endif
+
+#define FFI_TARGET_SPECIFIC_STACK_SPACE_ALLOCATION
+#define FFI_TARGET_HAS_COMPLEX_TYPE
+
+/* ---- Definitions for closures ----------------------------------------- */
+
+#define FFI_CLOSURES 1
+#ifdef S390X
+#define FFI_TRAMPOLINE_SIZE 32
+#else
+#define FFI_TRAMPOLINE_SIZE 16
+#endif
+#define FFI_NATIVE_RAW_API 0
+
+#endif
+
diff --git a/jni/ruby/ext/fiddle/libffi-3.2.1/src/s390/sysv.S b/jni/ruby/ext/fiddle/libffi-3.2.1/src/s390/sysv.S
new file mode 100644
index 0000000..4731a31
--- /dev/null
+++ b/jni/ruby/ext/fiddle/libffi-3.2.1/src/s390/sysv.S
@@ -0,0 +1,434 @@
+/* -----------------------------------------------------------------------
+ sysv.S - Copyright (c) 2000 Software AG
+ Copyright (c) 2008 Red Hat, Inc.
+
+ S390 Foreign Function Interface
+
+ Permission is hereby granted, free of charge, to any person obtaining
+ a copy of this software and associated documentation files (the
+ ``Software''), to deal in the Software without restriction, including
+ without limitation the rights to use, copy, modify, merge, publish,
+ distribute, sublicense, and/or sell copies of the Software, and to
+ permit persons to whom the Software is furnished to do so, subject to
+ the following conditions:
+
+ The above copyright notice and this permission notice shall be included
+ in all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND,
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+ HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ DEALINGS IN THE SOFTWARE.
+ ----------------------------------------------------------------------- */
+
+#define LIBFFI_ASM
+#include <fficonfig.h>
+#include <ffi.h>
+
+#ifndef __s390x__
+
+.text
+
+ # r2: cif->bytes
+ # r3: &ecif
+ # r4: ffi_prep_args
+ # r5: ret_type
+ # r6: ecif.rvalue
+ # ov: fn
+
+ # This assumes we are using gas.
+ .globl ffi_call_SYSV
+ .type ffi_call_SYSV,%function
+ffi_call_SYSV:
+.LFB1:
+ stm %r6,%r15,24(%r15) # Save registers
+.LCFI0:
+ basr %r13,0 # Set up base register
+.Lbase:
+ lr %r11,%r15 # Set up frame pointer
+.LCFI1:
+ sr %r15,%r2
+ ahi %r15,-96-48 # Allocate stack
+ lr %r8,%r6 # Save ecif.rvalue
+ sr %r9,%r9
+ ic %r9,.Ltable-.Lbase(%r13,%r5) # Load epilog address
+ l %r7,96(%r11) # Load function address
+ st %r11,0(%r15) # Set up back chain
+ ahi %r11,-48 # Register save area
+.LCFI2:
+
+ la %r2,96(%r15) # Save area
+ # r3 already holds &ecif
+ basr %r14,%r4 # Call ffi_prep_args
+
+ lm %r2,%r6,0(%r11) # Load arguments
+ ld %f0,32(%r11)
+ ld %f2,40(%r11)
+ la %r14,0(%r13,%r9) # Set return address
+ br %r7 # ... and call function
+
+.LretNone: # Return void
+ l %r4,48+56(%r11)
+ lm %r6,%r15,48+24(%r11)
+ br %r4
+
+.LretFloat:
+ l %r4,48+56(%r11)
+ ste %f0,0(%r8) # Return float
+ lm %r6,%r15,48+24(%r11)
+ br %r4
+
+.LretDouble:
+ l %r4,48+56(%r11)
+ std %f0,0(%r8) # Return double
+ lm %r6,%r15,48+24(%r11)
+ br %r4
+
+.LretInt32:
+ l %r4,48+56(%r11)
+ st %r2,0(%r8) # Return int
+ lm %r6,%r15,48+24(%r11)
+ br %r4
+
+.LretInt64:
+ l %r4,48+56(%r11)
+ stm %r2,%r3,0(%r8) # Return long long
+ lm %r6,%r15,48+24(%r11)
+ br %r4
+
+.Ltable:
+ .byte .LretNone-.Lbase # FFI390_RET_VOID
+ .byte .LretNone-.Lbase # FFI390_RET_STRUCT
+ .byte .LretFloat-.Lbase # FFI390_RET_FLOAT
+ .byte .LretDouble-.Lbase # FFI390_RET_DOUBLE
+ .byte .LretInt32-.Lbase # FFI390_RET_INT32
+ .byte .LretInt64-.Lbase # FFI390_RET_INT64
+
+.LFE1:
+.ffi_call_SYSV_end:
+ .size ffi_call_SYSV,.ffi_call_SYSV_end-ffi_call_SYSV
+
+
+ .globl ffi_closure_SYSV
+ .type ffi_closure_SYSV,%function
+ffi_closure_SYSV:
+.LFB2:
+ stm %r12,%r15,48(%r15) # Save registers
+.LCFI10:
+ basr %r13,0 # Set up base register
+.Lcbase:
+ stm %r2,%r6,8(%r15) # Save arguments
+ std %f0,64(%r15)
+ std %f2,72(%r15)
+ lr %r1,%r15 # Set up stack frame
+ ahi %r15,-96
+.LCFI11:
+ l %r12,.Lchelper-.Lcbase(%r13) # Get helper function
+ lr %r2,%r0 # Closure
+ la %r3,8(%r1) # GPRs
+ la %r4,64(%r1) # FPRs
+ la %r5,96(%r1) # Overflow
+ st %r1,0(%r15) # Set up back chain
+
+ bas %r14,0(%r12,%r13) # Call helper
+
+ l %r4,96+56(%r15)
+ ld %f0,96+64(%r15) # Load return registers
+ lm %r2,%r3,96+8(%r15)
+ lm %r12,%r15,96+48(%r15)
+ br %r4
+
+ .align 4
+.Lchelper:
+ .long ffi_closure_helper_SYSV-.Lcbase
+
+.LFE2:
+
+.ffi_closure_SYSV_end:
+ .size ffi_closure_SYSV,.ffi_closure_SYSV_end-ffi_closure_SYSV
+
+
+ .section .eh_frame,EH_FRAME_FLAGS,@progbits
+.Lframe1:
+ .4byte .LECIE1-.LSCIE1 # Length of Common Information Entry
+.LSCIE1:
+ .4byte 0x0 # CIE Identifier Tag
+ .byte 0x1 # CIE Version
+ .ascii "zR\0" # CIE Augmentation
+ .uleb128 0x1 # CIE Code Alignment Factor
+ .sleb128 -4 # CIE Data Alignment Factor
+ .byte 0xe # CIE RA Column
+ .uleb128 0x1 # Augmentation size
+ .byte 0x1b # FDE Encoding (pcrel sdata4)
+ .byte 0xc # DW_CFA_def_cfa
+ .uleb128 0xf
+ .uleb128 0x60
+ .align 4
+.LECIE1:
+.LSFDE1:
+ .4byte .LEFDE1-.LASFDE1 # FDE Length
+.LASFDE1:
+ .4byte .LASFDE1-.Lframe1 # FDE CIE offset
+ .4byte .LFB1-. # FDE initial location
+ .4byte .LFE1-.LFB1 # FDE address range
+ .uleb128 0x0 # Augmentation size
+ .byte 0x4 # DW_CFA_advance_loc4
+ .4byte .LCFI0-.LFB1
+ .byte 0x8f # DW_CFA_offset, column 0xf
+ .uleb128 0x9
+ .byte 0x8e # DW_CFA_offset, column 0xe
+ .uleb128 0xa
+ .byte 0x8d # DW_CFA_offset, column 0xd
+ .uleb128 0xb
+ .byte 0x8c # DW_CFA_offset, column 0xc
+ .uleb128 0xc
+ .byte 0x8b # DW_CFA_offset, column 0xb
+ .uleb128 0xd
+ .byte 0x8a # DW_CFA_offset, column 0xa
+ .uleb128 0xe
+ .byte 0x89 # DW_CFA_offset, column 0x9
+ .uleb128 0xf
+ .byte 0x88 # DW_CFA_offset, column 0x8
+ .uleb128 0x10
+ .byte 0x87 # DW_CFA_offset, column 0x7
+ .uleb128 0x11
+ .byte 0x86 # DW_CFA_offset, column 0x6
+ .uleb128 0x12
+ .byte 0x4 # DW_CFA_advance_loc4
+ .4byte .LCFI1-.LCFI0
+ .byte 0xd # DW_CFA_def_cfa_register
+ .uleb128 0xb
+ .byte 0x4 # DW_CFA_advance_loc4
+ .4byte .LCFI2-.LCFI1
+ .byte 0xe # DW_CFA_def_cfa_offset
+ .uleb128 0x90
+ .align 4
+.LEFDE1:
+.LSFDE2:
+ .4byte .LEFDE2-.LASFDE2 # FDE Length
+.LASFDE2:
+ .4byte .LASFDE2-.Lframe1 # FDE CIE offset
+ .4byte .LFB2-. # FDE initial location
+ .4byte .LFE2-.LFB2 # FDE address range
+ .uleb128 0x0 # Augmentation size
+ .byte 0x4 # DW_CFA_advance_loc4
+ .4byte .LCFI10-.LFB2
+ .byte 0x8f # DW_CFA_offset, column 0xf
+ .uleb128 0x9
+ .byte 0x8e # DW_CFA_offset, column 0xe
+ .uleb128 0xa
+ .byte 0x8d # DW_CFA_offset, column 0xd
+ .uleb128 0xb
+ .byte 0x8c # DW_CFA_offset, column 0xc
+ .uleb128 0xc
+ .byte 0x4 # DW_CFA_advance_loc4
+ .4byte .LCFI11-.LCFI10
+ .byte 0xe # DW_CFA_def_cfa_offset
+ .uleb128 0xc0
+ .align 4
+.LEFDE2:
+
+#else
+
+.text
+
+ # r2: cif->bytes
+ # r3: &ecif
+ # r4: ffi_prep_args
+ # r5: ret_type
+ # r6: ecif.rvalue
+ # ov: fn
+
+ # This assumes we are using gas.
+ .globl ffi_call_SYSV
+ .type ffi_call_SYSV,%function
+ffi_call_SYSV:
+.LFB1:
+ stmg %r6,%r15,48(%r15) # Save registers
+.LCFI0:
+ larl %r13,.Lbase # Set up base register
+ lgr %r11,%r15 # Set up frame pointer
+.LCFI1:
+ sgr %r15,%r2
+ aghi %r15,-160-80 # Allocate stack
+ lgr %r8,%r6 # Save ecif.rvalue
+ llgc %r9,.Ltable-.Lbase(%r13,%r5) # Load epilog address
+ lg %r7,160(%r11) # Load function address
+ stg %r11,0(%r15) # Set up back chain
+ aghi %r11,-80 # Register save area
+.LCFI2:
+
+ la %r2,160(%r15) # Save area
+ # r3 already holds &ecif
+ basr %r14,%r4 # Call ffi_prep_args
+
+ lmg %r2,%r6,0(%r11) # Load arguments
+ ld %f0,48(%r11)
+ ld %f2,56(%r11)
+ ld %f4,64(%r11)
+ ld %f6,72(%r11)
+ la %r14,0(%r13,%r9) # Set return address
+ br %r7 # ... and call function
+
+.Lbase:
+.LretNone: # Return void
+ lg %r4,80+112(%r11)
+ lmg %r6,%r15,80+48(%r11)
+ br %r4
+
+.LretFloat:
+ lg %r4,80+112(%r11)
+ ste %f0,0(%r8) # Return float
+ lmg %r6,%r15,80+48(%r11)
+ br %r4
+
+.LretDouble:
+ lg %r4,80+112(%r11)
+ std %f0,0(%r8) # Return double
+ lmg %r6,%r15,80+48(%r11)
+ br %r4
+
+.LretInt32:
+ lg %r4,80+112(%r11)
+ st %r2,0(%r8) # Return int
+ lmg %r6,%r15,80+48(%r11)
+ br %r4
+
+.LretInt64:
+ lg %r4,80+112(%r11)
+ stg %r2,0(%r8) # Return long
+ lmg %r6,%r15,80+48(%r11)
+ br %r4
+
+.Ltable:
+ .byte .LretNone-.Lbase # FFI390_RET_VOID
+ .byte .LretNone-.Lbase # FFI390_RET_STRUCT
+ .byte .LretFloat-.Lbase # FFI390_RET_FLOAT
+ .byte .LretDouble-.Lbase # FFI390_RET_DOUBLE
+ .byte .LretInt32-.Lbase # FFI390_RET_INT32
+ .byte .LretInt64-.Lbase # FFI390_RET_INT64
+
+.LFE1:
+.ffi_call_SYSV_end:
+ .size ffi_call_SYSV,.ffi_call_SYSV_end-ffi_call_SYSV
+
+
+ .globl ffi_closure_SYSV
+ .type ffi_closure_SYSV,%function
+ffi_closure_SYSV:
+.LFB2:
+ stmg %r14,%r15,112(%r15) # Save registers
+.LCFI10:
+ stmg %r2,%r6,16(%r15) # Save arguments
+ std %f0,128(%r15)
+ std %f2,136(%r15)
+ std %f4,144(%r15)
+ std %f6,152(%r15)
+ lgr %r1,%r15 # Set up stack frame
+ aghi %r15,-160
+.LCFI11:
+ lgr %r2,%r0 # Closure
+ la %r3,16(%r1) # GPRs
+ la %r4,128(%r1) # FPRs
+ la %r5,160(%r1) # Overflow
+ stg %r1,0(%r15) # Set up back chain
+
+ brasl %r14,ffi_closure_helper_SYSV # Call helper
+
+ lg %r14,160+112(%r15)
+ ld %f0,160+128(%r15) # Load return registers
+ lg %r2,160+16(%r15)
+ la %r15,160(%r15)
+ br %r14
+.LFE2:
+
+.ffi_closure_SYSV_end:
+ .size ffi_closure_SYSV,.ffi_closure_SYSV_end-ffi_closure_SYSV
+
+
+
+ .section .eh_frame,EH_FRAME_FLAGS,@progbits
+.Lframe1:
+ .4byte .LECIE1-.LSCIE1 # Length of Common Information Entry
+.LSCIE1:
+ .4byte 0x0 # CIE Identifier Tag
+ .byte 0x1 # CIE Version
+ .ascii "zR\0" # CIE Augmentation
+ .uleb128 0x1 # CIE Code Alignment Factor
+ .sleb128 -8 # CIE Data Alignment Factor
+ .byte 0xe # CIE RA Column
+ .uleb128 0x1 # Augmentation size
+ .byte 0x1b # FDE Encoding (pcrel sdata4)
+ .byte 0xc # DW_CFA_def_cfa
+ .uleb128 0xf
+ .uleb128 0xa0
+ .align 8
+.LECIE1:
+.LSFDE1:
+ .4byte .LEFDE1-.LASFDE1 # FDE Length
+.LASFDE1:
+ .4byte .LASFDE1-.Lframe1 # FDE CIE offset
+ .4byte .LFB1-. # FDE initial location
+ .4byte .LFE1-.LFB1 # FDE address range
+ .uleb128 0x0 # Augmentation size
+ .byte 0x4 # DW_CFA_advance_loc4
+ .4byte .LCFI0-.LFB1
+ .byte 0x8f # DW_CFA_offset, column 0xf
+ .uleb128 0x5
+ .byte 0x8e # DW_CFA_offset, column 0xe
+ .uleb128 0x6
+ .byte 0x8d # DW_CFA_offset, column 0xd
+ .uleb128 0x7
+ .byte 0x8c # DW_CFA_offset, column 0xc
+ .uleb128 0x8
+ .byte 0x8b # DW_CFA_offset, column 0xb
+ .uleb128 0x9
+ .byte 0x8a # DW_CFA_offset, column 0xa
+ .uleb128 0xa
+ .byte 0x89 # DW_CFA_offset, column 0x9
+ .uleb128 0xb
+ .byte 0x88 # DW_CFA_offset, column 0x8
+ .uleb128 0xc
+ .byte 0x87 # DW_CFA_offset, column 0x7
+ .uleb128 0xd
+ .byte 0x86 # DW_CFA_offset, column 0x6
+ .uleb128 0xe
+ .byte 0x4 # DW_CFA_advance_loc4
+ .4byte .LCFI1-.LCFI0
+ .byte 0xd # DW_CFA_def_cfa_register
+ .uleb128 0xb
+ .byte 0x4 # DW_CFA_advance_loc4
+ .4byte .LCFI2-.LCFI1
+ .byte 0xe # DW_CFA_def_cfa_offset
+ .uleb128 0xf0
+ .align 8
+.LEFDE1:
+.LSFDE2:
+ .4byte .LEFDE2-.LASFDE2 # FDE Length
+.LASFDE2:
+ .4byte .LASFDE2-.Lframe1 # FDE CIE offset
+ .4byte .LFB2-. # FDE initial location
+ .4byte .LFE2-.LFB2 # FDE address range
+ .uleb128 0x0 # Augmentation size
+ .byte 0x4 # DW_CFA_advance_loc4
+ .4byte .LCFI10-.LFB2
+ .byte 0x8f # DW_CFA_offset, column 0xf
+ .uleb128 0x5
+ .byte 0x8e # DW_CFA_offset, column 0xe
+ .uleb128 0x6
+ .byte 0x4 # DW_CFA_advance_loc4
+ .4byte .LCFI11-.LCFI10
+ .byte 0xe # DW_CFA_def_cfa_offset
+ .uleb128 0x140
+ .align 8
+.LEFDE2:
+
+#endif
+
+#if defined __ELF__ && defined __linux__
+ .section .note.GNU-stack,"",@progbits
+#endif
diff --git a/jni/ruby/ext/fiddle/libffi-3.2.1/src/sh/ffi.c b/jni/ruby/ext/fiddle/libffi-3.2.1/src/sh/ffi.c
new file mode 100644
index 0000000..9ec86bf
--- /dev/null
+++ b/jni/ruby/ext/fiddle/libffi-3.2.1/src/sh/ffi.c
@@ -0,0 +1,717 @@
+/* -----------------------------------------------------------------------
+ ffi.c - Copyright (c) 2002-2008, 2012 Kaz Kojima
+ Copyright (c) 2008 Red Hat, Inc.
+
+ SuperH Foreign Function Interface
+
+ Permission is hereby granted, free of charge, to any person obtaining
+ a copy of this software and associated documentation files (the
+ ``Software''), to deal in the Software without restriction, including
+ without limitation the rights to use, copy, modify, merge, publish,
+ distribute, sublicense, and/or sell copies of the Software, and to
+ permit persons to whom the Software is furnished to do so, subject to
+ the following conditions:
+
+ The above copyright notice and this permission notice shall be included
+ in all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND,
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+ HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ DEALINGS IN THE SOFTWARE.
+ ----------------------------------------------------------------------- */
+
+#include <ffi.h>
+#include <ffi_common.h>
+
+#include <stdlib.h>
+
+#define NGREGARG 4
+#if defined(__SH4__)
+#define NFREGARG 8
+#endif
+
+#if defined(__HITACHI__)
+#define STRUCT_VALUE_ADDRESS_WITH_ARG 1
+#else
+#define STRUCT_VALUE_ADDRESS_WITH_ARG 0
+#endif
+
+/* If the structure has essentially an unique element, return its type. */
+static int
+simple_type (ffi_type *arg)
+{
+ if (arg->type != FFI_TYPE_STRUCT)
+ return arg->type;
+ else if (arg->elements[1])
+ return FFI_TYPE_STRUCT;
+
+ return simple_type (arg->elements[0]);
+}
+
+static int
+return_type (ffi_type *arg)
+{
+ unsigned short type;
+
+ if (arg->type != FFI_TYPE_STRUCT)
+ return arg->type;
+
+ type = simple_type (arg->elements[0]);
+ if (! arg->elements[1])
+ {
+ switch (type)
+ {
+ case FFI_TYPE_SINT8:
+ case FFI_TYPE_UINT8:
+ case FFI_TYPE_SINT16:
+ case FFI_TYPE_UINT16:
+ case FFI_TYPE_SINT32:
+ case FFI_TYPE_UINT32:
+ return FFI_TYPE_INT;
+
+ default:
+ return type;
+ }
+ }
+
+ /* gcc uses r0/r1 pair for some kind of structures. */
+ if (arg->size <= 2 * sizeof (int))
+ {
+ int i = 0;
+ ffi_type *e;
+
+ while ((e = arg->elements[i++]))
+ {
+ type = simple_type (e);
+ switch (type)
+ {
+ case FFI_TYPE_SINT32:
+ case FFI_TYPE_UINT32:
+ case FFI_TYPE_INT:
+ case FFI_TYPE_FLOAT:
+ return FFI_TYPE_UINT64;
+
+ default:
+ break;
+ }
+ }
+ }
+
+ return FFI_TYPE_STRUCT;
+}
+
+/* ffi_prep_args is called by the assembly routine once stack space
+ has been allocated for the function's arguments */
+
+void ffi_prep_args(char *stack, extended_cif *ecif)
+{
+ register unsigned int i;
+ register int tmp;
+ register unsigned int avn;
+ register void **p_argv;
+ register char *argp;
+ register ffi_type **p_arg;
+ int greg, ireg;
+#if defined(__SH4__)
+ int freg = 0;
+#endif
+
+ tmp = 0;
+ argp = stack;
+
+ if (return_type (ecif->cif->rtype) == FFI_TYPE_STRUCT)
+ {
+ *(void **) argp = ecif->rvalue;
+ argp += 4;
+ ireg = STRUCT_VALUE_ADDRESS_WITH_ARG ? 1 : 0;
+ }
+ else
+ ireg = 0;
+
+ /* Set arguments for registers. */
+ greg = ireg;
+ avn = ecif->cif->nargs;
+ p_argv = ecif->avalue;
+
+ for (i = 0, p_arg = ecif->cif->arg_types; i < avn; i++, p_arg++, p_argv++)
+ {
+ size_t z;
+
+ z = (*p_arg)->size;
+ if (z < sizeof(int))
+ {
+ if (greg++ >= NGREGARG)
+ continue;
+
+ z = sizeof(int);
+ switch ((*p_arg)->type)
+ {
+ case FFI_TYPE_SINT8:
+ *(signed int *) argp = (signed int)*(SINT8 *)(* p_argv);
+ break;
+
+ case FFI_TYPE_UINT8:
+ *(unsigned int *) argp = (unsigned int)*(UINT8 *)(* p_argv);
+ break;
+
+ case FFI_TYPE_SINT16:
+ *(signed int *) argp = (signed int)*(SINT16 *)(* p_argv);
+ break;
+
+ case FFI_TYPE_UINT16:
+ *(unsigned int *) argp = (unsigned int)*(UINT16 *)(* p_argv);
+ break;
+
+ case FFI_TYPE_STRUCT:
+ *(unsigned int *) argp = (unsigned int)*(UINT32 *)(* p_argv);
+ break;
+
+ default:
+ FFI_ASSERT(0);
+ }
+ argp += z;
+ }
+ else if (z == sizeof(int))
+ {
+#if defined(__SH4__)
+ if ((*p_arg)->type == FFI_TYPE_FLOAT)
+ {
+ if (freg++ >= NFREGARG)
+ continue;
+ }
+ else
+#endif
+ {
+ if (greg++ >= NGREGARG)
+ continue;
+ }
+ *(unsigned int *) argp = (unsigned int)*(UINT32 *)(* p_argv);
+ argp += z;
+ }
+#if defined(__SH4__)
+ else if ((*p_arg)->type == FFI_TYPE_DOUBLE)
+ {
+ if (freg + 1 >= NFREGARG)
+ continue;
+ freg = (freg + 1) & ~1;
+ freg += 2;
+ memcpy (argp, *p_argv, z);
+ argp += z;
+ }
+#endif
+ else
+ {
+ int n = (z + sizeof (int) - 1) / sizeof (int);
+#if defined(__SH4__)
+ if (greg + n - 1 >= NGREGARG)
+ continue;
+#else
+ if (greg >= NGREGARG)
+ continue;
+#endif
+ greg += n;
+ memcpy (argp, *p_argv, z);
+ argp += n * sizeof (int);
+ }
+ }
+
+ /* Set arguments on stack. */
+ greg = ireg;
+#if defined(__SH4__)
+ freg = 0;
+#endif
+ p_argv = ecif->avalue;
+
+ for (i = 0, p_arg = ecif->cif->arg_types; i < avn; i++, p_arg++, p_argv++)
+ {
+ size_t z;
+
+ z = (*p_arg)->size;
+ if (z < sizeof(int))
+ {
+ if (greg++ < NGREGARG)
+ continue;
+
+ z = sizeof(int);
+ switch ((*p_arg)->type)
+ {
+ case FFI_TYPE_SINT8:
+ *(signed int *) argp = (signed int)*(SINT8 *)(* p_argv);
+ break;
+
+ case FFI_TYPE_UINT8:
+ *(unsigned int *) argp = (unsigned int)*(UINT8 *)(* p_argv);
+ break;
+
+ case FFI_TYPE_SINT16:
+ *(signed int *) argp = (signed int)*(SINT16 *)(* p_argv);
+ break;
+
+ case FFI_TYPE_UINT16:
+ *(unsigned int *) argp = (unsigned int)*(UINT16 *)(* p_argv);
+ break;
+
+ case FFI_TYPE_STRUCT:
+ *(unsigned int *) argp = (unsigned int)*(UINT32 *)(* p_argv);
+ break;
+
+ default:
+ FFI_ASSERT(0);
+ }
+ argp += z;
+ }
+ else if (z == sizeof(int))
+ {
+#if defined(__SH4__)
+ if ((*p_arg)->type == FFI_TYPE_FLOAT)
+ {
+ if (freg++ < NFREGARG)
+ continue;
+ }
+ else
+#endif
+ {
+ if (greg++ < NGREGARG)
+ continue;
+ }
+ *(unsigned int *) argp = (unsigned int)*(UINT32 *)(* p_argv);
+ argp += z;
+ }
+#if defined(__SH4__)
+ else if ((*p_arg)->type == FFI_TYPE_DOUBLE)
+ {
+ if (freg + 1 < NFREGARG)
+ {
+ freg = (freg + 1) & ~1;
+ freg += 2;
+ continue;
+ }
+ memcpy (argp, *p_argv, z);
+ argp += z;
+ }
+#endif
+ else
+ {
+ int n = (z + sizeof (int) - 1) / sizeof (int);
+ if (greg + n - 1 < NGREGARG)
+ {
+ greg += n;
+ continue;
+ }
+#if (! defined(__SH4__))
+ else if (greg < NGREGARG)
+ {
+ greg = NGREGARG;
+ continue;
+ }
+#endif
+ memcpy (argp, *p_argv, z);
+ argp += n * sizeof (int);
+ }
+ }
+
+ return;
+}
+
+/* Perform machine dependent cif processing */
+ffi_status ffi_prep_cif_machdep(ffi_cif *cif)
+{
+ int i, j;
+ int size, type;
+ int n, m;
+ int greg;
+#if defined(__SH4__)
+ int freg = 0;
+#endif
+
+ cif->flags = 0;
+
+ greg = ((return_type (cif->rtype) == FFI_TYPE_STRUCT) &&
+ STRUCT_VALUE_ADDRESS_WITH_ARG) ? 1 : 0;
+
+#if defined(__SH4__)
+ for (i = j = 0; i < cif->nargs && j < 12; i++)
+ {
+ type = (cif->arg_types)[i]->type;
+ switch (type)
+ {
+ case FFI_TYPE_FLOAT:
+ if (freg >= NFREGARG)
+ continue;
+ freg++;
+ cif->flags += ((cif->arg_types)[i]->type) << (2 * j);
+ j++;
+ break;
+
+ case FFI_TYPE_DOUBLE:
+ if ((freg + 1) >= NFREGARG)
+ continue;
+ freg = (freg + 1) & ~1;
+ freg += 2;
+ cif->flags += ((cif->arg_types)[i]->type) << (2 * j);
+ j++;
+ break;
+
+ default:
+ size = (cif->arg_types)[i]->size;
+ n = (size + sizeof (int) - 1) / sizeof (int);
+ if (greg + n - 1 >= NGREGARG)
+ continue;
+ greg += n;
+ for (m = 0; m < n; m++)
+ cif->flags += FFI_TYPE_INT << (2 * j++);
+ break;
+ }
+ }
+#else
+ for (i = j = 0; i < cif->nargs && j < 4; i++)
+ {
+ size = (cif->arg_types)[i]->size;
+ n = (size + sizeof (int) - 1) / sizeof (int);
+ if (greg >= NGREGARG)
+ continue;
+ else if (greg + n - 1 >= NGREGARG)
+ n = NGREGARG - greg;
+ greg += n;
+ for (m = 0; m < n; m++)
+ cif->flags += FFI_TYPE_INT << (2 * j++);
+ }
+#endif
+
+ /* Set the return type flag */
+ switch (cif->rtype->type)
+ {
+ case FFI_TYPE_STRUCT:
+ cif->flags += (unsigned) (return_type (cif->rtype)) << 24;
+ break;
+
+ case FFI_TYPE_VOID:
+ case FFI_TYPE_FLOAT:
+ case FFI_TYPE_DOUBLE:
+ case FFI_TYPE_SINT64:
+ case FFI_TYPE_UINT64:
+ cif->flags += (unsigned) cif->rtype->type << 24;
+ break;
+
+ default:
+ cif->flags += FFI_TYPE_INT << 24;
+ break;
+ }
+
+ return FFI_OK;
+}
+
+extern void ffi_call_SYSV(void (*)(char *, extended_cif *), extended_cif *,
+ unsigned, unsigned, unsigned *, void (*fn)(void));
+
+void ffi_call(ffi_cif *cif, void (*fn)(void), void *rvalue, void **avalue)
+{
+ extended_cif ecif;
+ UINT64 trvalue;
+
+ ecif.cif = cif;
+ ecif.avalue = avalue;
+
+ /* If the return value is a struct and we don't have a return */
+ /* value address then we need to make one */
+
+ if (cif->rtype->type == FFI_TYPE_STRUCT
+ && return_type (cif->rtype) != FFI_TYPE_STRUCT)
+ ecif.rvalue = &trvalue;
+ else if ((rvalue == NULL) &&
+ (cif->rtype->type == FFI_TYPE_STRUCT))
+ {
+ ecif.rvalue = alloca(cif->rtype->size);
+ }
+ else
+ ecif.rvalue = rvalue;
+
+ switch (cif->abi)
+ {
+ case FFI_SYSV:
+ ffi_call_SYSV(ffi_prep_args, &ecif, cif->bytes, cif->flags, ecif.rvalue,
+ fn);
+ break;
+ default:
+ FFI_ASSERT(0);
+ break;
+ }
+
+ if (rvalue
+ && cif->rtype->type == FFI_TYPE_STRUCT
+ && return_type (cif->rtype) != FFI_TYPE_STRUCT)
+ memcpy (rvalue, &trvalue, cif->rtype->size);
+}
+
+extern void ffi_closure_SYSV (void);
+#if defined(__SH4__)
+extern void __ic_invalidate (void *line);
+#endif
+
+ffi_status
+ffi_prep_closure_loc (ffi_closure* closure,
+ ffi_cif* cif,
+ void (*fun)(ffi_cif*, void*, void**, void*),
+ void *user_data,
+ void *codeloc)
+{
+ unsigned int *tramp;
+ unsigned int insn;
+
+ if (cif->abi != FFI_SYSV)
+ return FFI_BAD_ABI;
+
+ tramp = (unsigned int *) &closure->tramp[0];
+ /* Set T bit if the function returns a struct pointed with R2. */
+ insn = (return_type (cif->rtype) == FFI_TYPE_STRUCT
+ ? 0x0018 /* sett */
+ : 0x0008 /* clrt */);
+
+#ifdef __LITTLE_ENDIAN__
+ tramp[0] = 0xd301d102;
+ tramp[1] = 0x0000412b | (insn << 16);
+#else
+ tramp[0] = 0xd102d301;
+ tramp[1] = 0x412b0000 | insn;
+#endif
+ *(void **) &tramp[2] = (void *)codeloc; /* ctx */
+ *(void **) &tramp[3] = (void *)ffi_closure_SYSV; /* funaddr */
+
+ closure->cif = cif;
+ closure->fun = fun;
+ closure->user_data = user_data;
+
+#if defined(__SH4__)
+ /* Flush the icache. */
+ __ic_invalidate(codeloc);
+#endif
+
+ return FFI_OK;
+}
+
+/* Basically the trampoline invokes ffi_closure_SYSV, and on
+ * entry, r3 holds the address of the closure.
+ * After storing the registers that could possibly contain
+ * parameters to be passed into the stack frame and setting
+ * up space for a return value, ffi_closure_SYSV invokes the
+ * following helper function to do most of the work.
+ */
+
+#ifdef __LITTLE_ENDIAN__
+#define OFS_INT8 0
+#define OFS_INT16 0
+#else
+#define OFS_INT8 3
+#define OFS_INT16 2
+#endif
+
+int
+ffi_closure_helper_SYSV (ffi_closure *closure, void *rvalue,
+ unsigned long *pgr, unsigned long *pfr,
+ unsigned long *pst)
+{
+ void **avalue;
+ ffi_type **p_arg;
+ int i, avn;
+ int ireg, greg = 0;
+#if defined(__SH4__)
+ int freg = 0;
+#endif
+ ffi_cif *cif;
+
+ cif = closure->cif;
+ avalue = alloca(cif->nargs * sizeof(void *));
+
+ /* Copy the caller's structure return value address so that the closure
+ returns the data directly to the caller. */
+ if (cif->rtype->type == FFI_TYPE_STRUCT && STRUCT_VALUE_ADDRESS_WITH_ARG)
+ {
+ rvalue = (void *) *pgr++;
+ ireg = 1;
+ }
+ else
+ ireg = 0;
+
+ cif = closure->cif;
+ greg = ireg;
+ avn = cif->nargs;
+
+ /* Grab the addresses of the arguments from the stack frame. */
+ for (i = 0, p_arg = cif->arg_types; i < avn; i++, p_arg++)
+ {
+ size_t z;
+
+ z = (*p_arg)->size;
+ if (z < sizeof(int))
+ {
+ if (greg++ >= NGREGARG)
+ continue;
+
+ z = sizeof(int);
+ switch ((*p_arg)->type)
+ {
+ case FFI_TYPE_SINT8:
+ case FFI_TYPE_UINT8:
+ avalue[i] = (((char *)pgr) + OFS_INT8);
+ break;
+
+ case FFI_TYPE_SINT16:
+ case FFI_TYPE_UINT16:
+ avalue[i] = (((char *)pgr) + OFS_INT16);
+ break;
+
+ case FFI_TYPE_STRUCT:
+ avalue[i] = pgr;
+ break;
+
+ default:
+ FFI_ASSERT(0);
+ }
+ pgr++;
+ }
+ else if (z == sizeof(int))
+ {
+#if defined(__SH4__)
+ if ((*p_arg)->type == FFI_TYPE_FLOAT)
+ {
+ if (freg++ >= NFREGARG)
+ continue;
+ avalue[i] = pfr;
+ pfr++;
+ }
+ else
+#endif
+ {
+ if (greg++ >= NGREGARG)
+ continue;
+ avalue[i] = pgr;
+ pgr++;
+ }
+ }
+#if defined(__SH4__)
+ else if ((*p_arg)->type == FFI_TYPE_DOUBLE)
+ {
+ if (freg + 1 >= NFREGARG)
+ continue;
+ if (freg & 1)
+ pfr++;
+ freg = (freg + 1) & ~1;
+ freg += 2;
+ avalue[i] = pfr;
+ pfr += 2;
+ }
+#endif
+ else
+ {
+ int n = (z + sizeof (int) - 1) / sizeof (int);
+#if defined(__SH4__)
+ if (greg + n - 1 >= NGREGARG)
+ continue;
+#else
+ if (greg >= NGREGARG)
+ continue;
+#endif
+ greg += n;
+ avalue[i] = pgr;
+ pgr += n;
+ }
+ }
+
+ greg = ireg;
+#if defined(__SH4__)
+ freg = 0;
+#endif
+
+ for (i = 0, p_arg = cif->arg_types; i < avn; i++, p_arg++)
+ {
+ size_t z;
+
+ z = (*p_arg)->size;
+ if (z < sizeof(int))
+ {
+ if (greg++ < NGREGARG)
+ continue;
+
+ z = sizeof(int);
+ switch ((*p_arg)->type)
+ {
+ case FFI_TYPE_SINT8:
+ case FFI_TYPE_UINT8:
+ avalue[i] = (((char *)pst) + OFS_INT8);
+ break;
+
+ case FFI_TYPE_SINT16:
+ case FFI_TYPE_UINT16:
+ avalue[i] = (((char *)pst) + OFS_INT16);
+ break;
+
+ case FFI_TYPE_STRUCT:
+ avalue[i] = pst;
+ break;
+
+ default:
+ FFI_ASSERT(0);
+ }
+ pst++;
+ }
+ else if (z == sizeof(int))
+ {
+#if defined(__SH4__)
+ if ((*p_arg)->type == FFI_TYPE_FLOAT)
+ {
+ if (freg++ < NFREGARG)
+ continue;
+ }
+ else
+#endif
+ {
+ if (greg++ < NGREGARG)
+ continue;
+ }
+ avalue[i] = pst;
+ pst++;
+ }
+#if defined(__SH4__)
+ else if ((*p_arg)->type == FFI_TYPE_DOUBLE)
+ {
+ if (freg + 1 < NFREGARG)
+ {
+ freg = (freg + 1) & ~1;
+ freg += 2;
+ continue;
+ }
+ avalue[i] = pst;
+ pst += 2;
+ }
+#endif
+ else
+ {
+ int n = (z + sizeof (int) - 1) / sizeof (int);
+ if (greg + n - 1 < NGREGARG)
+ {
+ greg += n;
+ continue;
+ }
+#if (! defined(__SH4__))
+ else if (greg < NGREGARG)
+ {
+ greg += n;
+ pst += greg - NGREGARG;
+ continue;
+ }
+#endif
+ avalue[i] = pst;
+ pst += n;
+ }
+ }
+
+ (closure->fun) (cif, rvalue, avalue, closure->user_data);
+
+ /* Tell ffi_closure_SYSV how to perform return type promotions. */
+ return return_type (cif->rtype);
+}
diff --git a/jni/ruby/ext/fiddle/libffi-3.2.1/src/sh/ffitarget.h b/jni/ruby/ext/fiddle/libffi-3.2.1/src/sh/ffitarget.h
new file mode 100644
index 0000000..a36bf42
--- /dev/null
+++ b/jni/ruby/ext/fiddle/libffi-3.2.1/src/sh/ffitarget.h
@@ -0,0 +1,54 @@
+/* -----------------------------------------------------------------*-C-*-
+ ffitarget.h - Copyright (c) 2012 Anthony Green
+ Copyright (c) 1996-2003 Red Hat, Inc.
+ Target configuration macros for SuperH.
+
+ Permission is hereby granted, free of charge, to any person obtaining
+ a copy of this software and associated documentation files (the
+ ``Software''), to deal in the Software without restriction, including
+ without limitation the rights to use, copy, modify, merge, publish,
+ distribute, sublicense, and/or sell copies of the Software, and to
+ permit persons to whom the Software is furnished to do so, subject to
+ the following conditions:
+
+ The above copyright notice and this permission notice shall be included
+ in all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND,
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+ HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ DEALINGS IN THE SOFTWARE.
+
+ ----------------------------------------------------------------------- */
+
+#ifndef LIBFFI_TARGET_H
+#define LIBFFI_TARGET_H
+
+#ifndef LIBFFI_H
+#error "Please do not include ffitarget.h directly into your source. Use ffi.h instead."
+#endif
+
+/* ---- Generic type definitions ----------------------------------------- */
+
+#ifndef LIBFFI_ASM
+typedef unsigned long ffi_arg;
+typedef signed long ffi_sarg;
+
+typedef enum ffi_abi {
+ FFI_FIRST_ABI = 0,
+ FFI_SYSV,
+ FFI_LAST_ABI,
+ FFI_DEFAULT_ABI = FFI_SYSV
+} ffi_abi;
+#endif
+
+#define FFI_CLOSURES 1
+#define FFI_TRAMPOLINE_SIZE 16
+#define FFI_NATIVE_RAW_API 0
+
+#endif
+
diff --git a/jni/ruby/ext/fiddle/libffi-3.2.1/src/sh/sysv.S b/jni/ruby/ext/fiddle/libffi-3.2.1/src/sh/sysv.S
new file mode 100644
index 0000000..5be7516
--- /dev/null
+++ b/jni/ruby/ext/fiddle/libffi-3.2.1/src/sh/sysv.S
@@ -0,0 +1,850 @@
+/* -----------------------------------------------------------------------
+ sysv.S - Copyright (c) 2002, 2003, 2004, 2006, 2008 Kaz Kojima
+
+ SuperH Foreign Function Interface
+
+ Permission is hereby granted, free of charge, to any person obtaining
+ a copy of this software and associated documentation files (the
+ ``Software''), to deal in the Software without restriction, including
+ without limitation the rights to use, copy, modify, merge, publish,
+ distribute, sublicense, and/or sell copies of the Software, and to
+ permit persons to whom the Software is furnished to do so, subject to
+ the following conditions:
+
+ The above copyright notice and this permission notice shall be included
+ in all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND,
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+ HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ DEALINGS IN THE SOFTWARE.
+ ----------------------------------------------------------------------- */
+
+#define LIBFFI_ASM
+#include <fficonfig.h>
+#include <ffi.h>
+#ifdef HAVE_MACHINE_ASM_H
+#include <machine/asm.h>
+#else
+/* XXX these lose for some platforms, I'm sure. */
+#define CNAME(x) x
+#define ENTRY(x) .globl CNAME(x); .type CNAME(x),%function; CNAME(x):
+#endif
+
+#if defined(__HITACHI__)
+#define STRUCT_VALUE_ADDRESS_WITH_ARG 1
+#else
+#define STRUCT_VALUE_ADDRESS_WITH_ARG 0
+#endif
+
+.text
+
+ # r4: ffi_prep_args
+ # r5: &ecif
+ # r6: bytes
+ # r7: flags
+ # sp+0: rvalue
+ # sp+4: fn
+
+ # This assumes we are using gas.
+ENTRY(ffi_call_SYSV)
+ # Save registers
+.LFB1:
+ mov.l r8,@-r15
+.LCFI0:
+ mov.l r9,@-r15
+.LCFI1:
+ mov.l r10,@-r15
+.LCFI2:
+ mov.l r12,@-r15
+.LCFI3:
+ mov.l r14,@-r15
+.LCFI4:
+ sts.l pr,@-r15
+.LCFI5:
+ mov r15,r14
+.LCFI6:
+#if defined(__SH4__)
+ mov r6,r8
+ mov r7,r9
+
+ sub r6,r15
+ add #-16,r15
+ mov #~7,r0
+ and r0,r15
+
+ mov r4,r0
+ jsr @r0
+ mov r15,r4
+
+ mov r9,r1
+ shlr8 r9
+ shlr8 r9
+ shlr8 r9
+
+ mov #FFI_TYPE_STRUCT,r2
+ cmp/eq r2,r9
+ bf 1f
+#if STRUCT_VALUE_ADDRESS_WITH_ARG
+ mov.l @r15+,r4
+ bra 2f
+ mov #5,r2
+#else
+ mov.l @r15+,r10
+#endif
+1:
+ mov #4,r2
+2:
+ mov #4,r3
+
+L_pass:
+ cmp/pl r8
+ bf L_call_it
+
+ mov r1,r0
+ and #3,r0
+
+L_pass_d:
+ cmp/eq #FFI_TYPE_DOUBLE,r0
+ bf L_pass_f
+
+ mov r3,r0
+ and #1,r0
+ tst r0,r0
+ bt 1f
+ add #1,r3
+1:
+ mov #12,r0
+ cmp/hs r0,r3
+ bt/s 3f
+ shlr2 r1
+ bsr L_pop_d
+ nop
+3:
+ add #2,r3
+ bra L_pass
+ add #-8,r8
+
+L_pop_d:
+ mov r3,r0
+ add r0,r0
+ add r3,r0
+ add #-12,r0
+ braf r0
+ nop
+#ifdef __LITTLE_ENDIAN__
+ fmov.s @r15+,fr5
+ rts
+ fmov.s @r15+,fr4
+ fmov.s @r15+,fr7
+ rts
+ fmov.s @r15+,fr6
+ fmov.s @r15+,fr9
+ rts
+ fmov.s @r15+,fr8
+ fmov.s @r15+,fr11
+ rts
+ fmov.s @r15+,fr10
+#else
+ fmov.s @r15+,fr4
+ rts
+ fmov.s @r15+,fr5
+ fmov.s @r15+,fr6
+ rts
+ fmov.s @r15+,fr7
+ fmov.s @r15+,fr8
+ rts
+ fmov.s @r15+,fr9
+ fmov.s @r15+,fr10
+ rts
+ fmov.s @r15+,fr11
+#endif
+
+L_pass_f:
+ cmp/eq #FFI_TYPE_FLOAT,r0
+ bf L_pass_i
+
+ mov #12,r0
+ cmp/hs r0,r3
+ bt/s 2f
+ shlr2 r1
+ bsr L_pop_f
+ nop
+2:
+ add #1,r3
+ bra L_pass
+ add #-4,r8
+
+L_pop_f:
+ mov r3,r0
+ shll2 r0
+ add #-16,r0
+ braf r0
+ nop
+#ifdef __LITTLE_ENDIAN__
+ rts
+ fmov.s @r15+,fr5
+ rts
+ fmov.s @r15+,fr4
+ rts
+ fmov.s @r15+,fr7
+ rts
+ fmov.s @r15+,fr6
+ rts
+ fmov.s @r15+,fr9
+ rts
+ fmov.s @r15+,fr8
+ rts
+ fmov.s @r15+,fr11
+ rts
+ fmov.s @r15+,fr10
+#else
+ rts
+ fmov.s @r15+,fr4
+ rts
+ fmov.s @r15+,fr5
+ rts
+ fmov.s @r15+,fr6
+ rts
+ fmov.s @r15+,fr7
+ rts
+ fmov.s @r15+,fr8
+ rts
+ fmov.s @r15+,fr9
+ rts
+ fmov.s @r15+,fr10
+ rts
+ fmov.s @r15+,fr11
+#endif
+
+L_pass_i:
+ cmp/eq #FFI_TYPE_INT,r0
+ bf L_call_it
+
+ mov #8,r0
+ cmp/hs r0,r2
+ bt/s 2f
+ shlr2 r1
+ bsr L_pop_i
+ nop
+2:
+ add #1,r2
+ bra L_pass
+ add #-4,r8
+
+L_pop_i:
+ mov r2,r0
+ shll2 r0
+ add #-16,r0
+ braf r0
+ nop
+ rts
+ mov.l @r15+,r4
+ rts
+ mov.l @r15+,r5
+ rts
+ mov.l @r15+,r6
+ rts
+ mov.l @r15+,r7
+
+L_call_it:
+ # call function
+#if (! STRUCT_VALUE_ADDRESS_WITH_ARG)
+ mov r10, r2
+#endif
+ mov.l @(28,r14),r1
+ jsr @r1
+ nop
+
+L_ret_d:
+ mov #FFI_TYPE_DOUBLE,r2
+ cmp/eq r2,r9
+ bf L_ret_ll
+
+ mov.l @(24,r14),r1
+#ifdef __LITTLE_ENDIAN__
+ fmov.s fr1,@r1
+ add #4,r1
+ bra L_epilogue
+ fmov.s fr0,@r1
+#else
+ fmov.s fr0,@r1
+ add #4,r1
+ bra L_epilogue
+ fmov.s fr1,@r1
+#endif
+
+L_ret_ll:
+ mov #FFI_TYPE_SINT64,r2
+ cmp/eq r2,r9
+ bt/s 1f
+ mov #FFI_TYPE_UINT64,r2
+ cmp/eq r2,r9
+ bf L_ret_f
+
+1:
+ mov.l @(24,r14),r2
+ mov.l r0,@r2
+ bra L_epilogue
+ mov.l r1,@(4,r2)
+
+L_ret_f:
+ mov #FFI_TYPE_FLOAT,r2
+ cmp/eq r2,r9
+ bf L_ret_i
+
+ mov.l @(24,r14),r1
+ bra L_epilogue
+ fmov.s fr0,@r1
+
+L_ret_i:
+ mov #FFI_TYPE_INT,r2
+ cmp/eq r2,r9
+ bf L_epilogue
+
+ mov.l @(24,r14),r1
+ bra L_epilogue
+ mov.l r0,@r1
+
+L_epilogue:
+ # Remove the space we pushed for the args
+ mov r14,r15
+
+ lds.l @r15+,pr
+ mov.l @r15+,r14
+ mov.l @r15+,r12
+ mov.l @r15+,r10
+ mov.l @r15+,r9
+ rts
+ mov.l @r15+,r8
+#else
+ mov r6,r8
+ mov r7,r9
+
+ sub r6,r15
+ add #-16,r15
+ mov #~7,r0
+ and r0,r15
+
+ mov r4,r0
+ jsr @r0
+ mov r15,r4
+
+ mov r9,r3
+ shlr8 r9
+ shlr8 r9
+ shlr8 r9
+
+ mov #FFI_TYPE_STRUCT,r2
+ cmp/eq r2,r9
+ bf 1f
+#if STRUCT_VALUE_ADDRESS_WITH_ARG
+ mov.l @r15+,r4
+ bra 2f
+ mov #5,r2
+#else
+ mov.l @r15+,r10
+#endif
+1:
+ mov #4,r2
+2:
+
+L_pass:
+ cmp/pl r8
+ bf L_call_it
+
+ mov r3,r0
+ and #3,r0
+
+L_pass_d:
+ cmp/eq #FFI_TYPE_DOUBLE,r0
+ bf L_pass_i
+
+ mov r15,r0
+ and #7,r0
+ tst r0,r0
+ bt 1f
+ add #4,r15
+1:
+ mov #8,r0
+ cmp/hs r0,r2
+ bt/s 2f
+ shlr2 r3
+ bsr L_pop_d
+ nop
+2:
+ add #2,r2
+ bra L_pass
+ add #-8,r8
+
+L_pop_d:
+ mov r2,r0
+ add r0,r0
+ add r2,r0
+ add #-12,r0
+ add r0,r0
+ braf r0
+ nop
+ mov.l @r15+,r4
+ rts
+ mov.l @r15+,r5
+ mov.l @r15+,r5
+ rts
+ mov.l @r15+,r6
+ mov.l @r15+,r6
+ rts
+ mov.l @r15+,r7
+ rts
+ mov.l @r15+,r7
+
+L_pass_i:
+ cmp/eq #FFI_TYPE_INT,r0
+ bf L_call_it
+
+ mov #8,r0
+ cmp/hs r0,r2
+ bt/s 2f
+ shlr2 r3
+ bsr L_pop_i
+ nop
+2:
+ add #1,r2
+ bra L_pass
+ add #-4,r8
+
+L_pop_i:
+ mov r2,r0
+ shll2 r0
+ add #-16,r0
+ braf r0
+ nop
+ rts
+ mov.l @r15+,r4
+ rts
+ mov.l @r15+,r5
+ rts
+ mov.l @r15+,r6
+ rts
+ mov.l @r15+,r7
+
+L_call_it:
+ # call function
+#if (! STRUCT_VALUE_ADDRESS_WITH_ARG)
+ mov r10, r2
+#endif
+ mov.l @(28,r14),r1
+ jsr @r1
+ nop
+
+L_ret_d:
+ mov #FFI_TYPE_DOUBLE,r2
+ cmp/eq r2,r9
+ bf L_ret_ll
+
+ mov.l @(24,r14),r2
+ mov.l r0,@r2
+ bra L_epilogue
+ mov.l r1,@(4,r2)
+
+L_ret_ll:
+ mov #FFI_TYPE_SINT64,r2
+ cmp/eq r2,r9
+ bt/s 1f
+ mov #FFI_TYPE_UINT64,r2
+ cmp/eq r2,r9
+ bf L_ret_i
+
+1:
+ mov.l @(24,r14),r2
+ mov.l r0,@r2
+ bra L_epilogue
+ mov.l r1,@(4,r2)
+
+L_ret_i:
+ mov #FFI_TYPE_FLOAT,r2
+ cmp/eq r2,r9
+ bt 1f
+ mov #FFI_TYPE_INT,r2
+ cmp/eq r2,r9
+ bf L_epilogue
+1:
+ mov.l @(24,r14),r1
+ bra L_epilogue
+ mov.l r0,@r1
+
+L_epilogue:
+ # Remove the space we pushed for the args
+ mov r14,r15
+
+ lds.l @r15+,pr
+ mov.l @r15+,r14
+ mov.l @r15+,r12
+ mov.l @r15+,r10
+ mov.l @r15+,r9
+ rts
+ mov.l @r15+,r8
+#endif
+.LFE1:
+.ffi_call_SYSV_end:
+ .size CNAME(ffi_call_SYSV),.ffi_call_SYSV_end-CNAME(ffi_call_SYSV)
+
+.globl ffi_closure_helper_SYSV
+
+ENTRY(ffi_closure_SYSV)
+.LFB2:
+ mov.l r7,@-r15
+.LCFI7:
+ mov.l r6,@-r15
+.LCFI8:
+ mov.l r5,@-r15
+.LCFI9:
+ mov.l r4,@-r15
+.LCFIA:
+ mov.l r14,@-r15
+.LCFIB:
+ sts.l pr,@-r15
+
+ /* Stack layout:
+ xx bytes (on stack parameters)
+ 16 bytes (register parameters)
+ 4 bytes (saved frame pointer)
+ 4 bytes (saved return address)
+ 32 bytes (floating register parameters, SH-4 only)
+ 8 bytes (result)
+ 4 bytes (pad)
+ 4 bytes (5th arg)
+ <- new stack pointer
+ */
+.LCFIC:
+#if defined(__SH4__)
+ add #-48,r15
+#else
+ add #-16,r15
+#endif
+.LCFID:
+ mov r15,r14
+.LCFIE:
+
+#if defined(__SH4__)
+ mov r14,r1
+ add #48,r1
+#ifdef __LITTLE_ENDIAN__
+ fmov.s fr10,@-r1
+ fmov.s fr11,@-r1
+ fmov.s fr8,@-r1
+ fmov.s fr9,@-r1
+ fmov.s fr6,@-r1
+ fmov.s fr7,@-r1
+ fmov.s fr4,@-r1
+ fmov.s fr5,@-r1
+#else
+ fmov.s fr11,@-r1
+ fmov.s fr10,@-r1
+ fmov.s fr9,@-r1
+ fmov.s fr8,@-r1
+ fmov.s fr7,@-r1
+ fmov.s fr6,@-r1
+ fmov.s fr5,@-r1
+ fmov.s fr4,@-r1
+#endif
+ mov r1,r7
+ mov r14,r6
+ add #56,r6
+#else
+ mov r14,r6
+ add #24,r6
+#endif
+
+ bt/s 10f
+ mov r2, r5
+ mov r14,r1
+ add #8,r1
+ mov r1,r5
+10:
+
+ mov r14,r1
+#if defined(__SH4__)
+ add #72,r1
+#else
+ add #40,r1
+#endif
+ mov.l r1,@r14
+
+#ifdef PIC
+ mov.l L_got,r1
+ mova L_got,r0
+ add r0,r1
+ mov.l L_helper,r0
+ add r1,r0
+#else
+ mov.l L_helper,r0
+#endif
+ jsr @r0
+ mov r3,r4
+
+ shll r0
+ mov r0,r1
+ mova L_table,r0
+ add r1,r0
+ mov.w @r0,r0
+ mov r14,r2
+ braf r0
+ add #8,r2
+0:
+ .align 2
+#ifdef PIC
+L_got:
+ .long _GLOBAL_OFFSET_TABLE_
+L_helper:
+ .long ffi_closure_helper_SYSV@GOTOFF
+#else
+L_helper:
+ .long ffi_closure_helper_SYSV
+#endif
+L_table:
+ .short L_case_v - 0b /* FFI_TYPE_VOID */
+ .short L_case_i - 0b /* FFI_TYPE_INT */
+#if defined(__SH4__)
+ .short L_case_f - 0b /* FFI_TYPE_FLOAT */
+ .short L_case_d - 0b /* FFI_TYPE_DOUBLE */
+ .short L_case_d - 0b /* FFI_TYPE_LONGDOUBLE */
+#else
+ .short L_case_i - 0b /* FFI_TYPE_FLOAT */
+ .short L_case_ll - 0b /* FFI_TYPE_DOUBLE */
+ .short L_case_ll - 0b /* FFI_TYPE_LONGDOUBLE */
+#endif
+ .short L_case_uq - 0b /* FFI_TYPE_UINT8 */
+ .short L_case_q - 0b /* FFI_TYPE_SINT8 */
+ .short L_case_uh - 0b /* FFI_TYPE_UINT16 */
+ .short L_case_h - 0b /* FFI_TYPE_SINT16 */
+ .short L_case_i - 0b /* FFI_TYPE_UINT32 */
+ .short L_case_i - 0b /* FFI_TYPE_SINT32 */
+ .short L_case_ll - 0b /* FFI_TYPE_UINT64 */
+ .short L_case_ll - 0b /* FFI_TYPE_SINT64 */
+ .short L_case_v - 0b /* FFI_TYPE_STRUCT */
+ .short L_case_i - 0b /* FFI_TYPE_POINTER */
+
+#if defined(__SH4__)
+L_case_d:
+#ifdef __LITTLE_ENDIAN__
+ fmov.s @r2+,fr1
+ bra L_case_v
+ fmov.s @r2,fr0
+#else
+ fmov.s @r2+,fr0
+ bra L_case_v
+ fmov.s @r2,fr1
+#endif
+
+L_case_f:
+ bra L_case_v
+ fmov.s @r2,fr0
+#endif
+
+L_case_ll:
+ mov.l @r2+,r0
+ bra L_case_v
+ mov.l @r2,r1
+
+L_case_i:
+ bra L_case_v
+ mov.l @r2,r0
+
+L_case_q:
+#ifdef __LITTLE_ENDIAN__
+#else
+ add #3,r2
+#endif
+ bra L_case_v
+ mov.b @r2,r0
+
+L_case_uq:
+#ifdef __LITTLE_ENDIAN__
+#else
+ add #3,r2
+#endif
+ mov.b @r2,r0
+ bra L_case_v
+ extu.b r0,r0
+
+L_case_h:
+#ifdef __LITTLE_ENDIAN__
+#else
+ add #2,r2
+#endif
+ bra L_case_v
+ mov.w @r2,r0
+
+L_case_uh:
+#ifdef __LITTLE_ENDIAN__
+#else
+ add #2,r2
+#endif
+ mov.w @r2,r0
+ extu.w r0,r0
+ /* fall through */
+
+L_case_v:
+#if defined(__SH4__)
+ add #48,r15
+#else
+ add #16,r15
+#endif
+ lds.l @r15+,pr
+ mov.l @r15+,r14
+ rts
+ add #16,r15
+.LFE2:
+.ffi_closure_SYSV_end:
+ .size CNAME(ffi_closure_SYSV),.ffi_closure_SYSV_end-CNAME(ffi_closure_SYSV)
+
+#if defined __ELF__ && defined __linux__
+ .section .note.GNU-stack,"",@progbits
+#endif
+
+ .section ".eh_frame","aw",@progbits
+__FRAME_BEGIN__:
+ .4byte .LECIE1-.LSCIE1 /* Length of Common Information Entry */
+.LSCIE1:
+ .4byte 0x0 /* CIE Identifier Tag */
+ .byte 0x1 /* CIE Version */
+#ifdef PIC
+ .ascii "zR\0" /* CIE Augmentation */
+#else
+ .byte 0x0 /* CIE Augmentation */
+#endif
+ .byte 0x1 /* uleb128 0x1; CIE Code Alignment Factor */
+ .byte 0x7c /* sleb128 -4; CIE Data Alignment Factor */
+ .byte 0x11 /* CIE RA Column */
+#ifdef PIC
+ .uleb128 0x1 /* Augmentation size */
+ .byte 0x10 /* FDE Encoding (pcrel) */
+#endif
+ .byte 0xc /* DW_CFA_def_cfa */
+ .byte 0xf /* uleb128 0xf */
+ .byte 0x0 /* uleb128 0x0 */
+ .align 2
+.LECIE1:
+.LSFDE1:
+ .4byte .LEFDE1-.LASFDE1 /* FDE Length */
+.LASFDE1:
+ .4byte .LASFDE1-__FRAME_BEGIN__ /* FDE CIE offset */
+#ifdef PIC
+ .4byte .LFB1-. /* FDE initial location */
+#else
+ .4byte .LFB1 /* FDE initial location */
+#endif
+ .4byte .LFE1-.LFB1 /* FDE address range */
+#ifdef PIC
+ .uleb128 0x0 /* Augmentation size */
+#endif
+ .byte 0x4 /* DW_CFA_advance_loc4 */
+ .4byte .LCFI0-.LFB1
+ .byte 0xe /* DW_CFA_def_cfa_offset */
+ .byte 0x4 /* uleb128 0x4 */
+ .byte 0x4 /* DW_CFA_advance_loc4 */
+ .4byte .LCFI1-.LCFI0
+ .byte 0xe /* DW_CFA_def_cfa_offset */
+ .byte 0x8 /* uleb128 0x4 */
+ .byte 0x4 /* DW_CFA_advance_loc4 */
+ .4byte .LCFI2-.LCFI1
+ .byte 0xe /* DW_CFA_def_cfa_offset */
+ .byte 0xc /* uleb128 0x4 */
+ .byte 0x4 /* DW_CFA_advance_loc4 */
+ .4byte .LCFI3-.LCFI2
+ .byte 0xe /* DW_CFA_def_cfa_offset */
+ .byte 0x10 /* uleb128 0x4 */
+ .byte 0x4 /* DW_CFA_advance_loc4 */
+ .4byte .LCFI4-.LCFI3
+ .byte 0xe /* DW_CFA_def_cfa_offset */
+ .byte 0x14 /* uleb128 0x4 */
+ .byte 0x4 /* DW_CFA_advance_loc4 */
+ .4byte .LCFI5-.LCFI4
+ .byte 0xe /* DW_CFA_def_cfa_offset */
+ .byte 0x18 /* uleb128 0x4 */
+ .byte 0x91 /* DW_CFA_offset, column 0x11 */
+ .byte 0x6 /* uleb128 0x6 */
+ .byte 0x8e /* DW_CFA_offset, column 0xe */
+ .byte 0x5 /* uleb128 0x5 */
+ .byte 0x8c /* DW_CFA_offset, column 0xc */
+ .byte 0x4 /* uleb128 0x4 */
+ .byte 0x8a /* DW_CFA_offset, column 0xa */
+ .byte 0x3 /* uleb128 0x3 */
+ .byte 0x89 /* DW_CFA_offset, column 0x9 */
+ .byte 0x2 /* uleb128 0x2 */
+ .byte 0x88 /* DW_CFA_offset, column 0x8 */
+ .byte 0x1 /* uleb128 0x1 */
+ .byte 0x4 /* DW_CFA_advance_loc4 */
+ .4byte .LCFI6-.LCFI5
+ .byte 0xd /* DW_CFA_def_cfa_register */
+ .byte 0xe /* uleb128 0xe */
+ .align 2
+.LEFDE1:
+
+.LSFDE3:
+ .4byte .LEFDE3-.LASFDE3 /* FDE Length */
+.LASFDE3:
+ .4byte .LASFDE3-__FRAME_BEGIN__ /* FDE CIE offset */
+#ifdef PIC
+ .4byte .LFB2-. /* FDE initial location */
+#else
+ .4byte .LFB2 /* FDE initial location */
+#endif
+ .4byte .LFE2-.LFB2 /* FDE address range */
+#ifdef PIC
+ .uleb128 0x0 /* Augmentation size */
+#endif
+ .byte 0x4 /* DW_CFA_advance_loc4 */
+ .4byte .LCFI7-.LFB2
+ .byte 0xe /* DW_CFA_def_cfa_offset */
+ .byte 0x4 /* uleb128 0x4 */
+ .byte 0x4 /* DW_CFA_advance_loc4 */
+ .4byte .LCFI8-.LCFI7
+ .byte 0xe /* DW_CFA_def_cfa_offset */
+ .byte 0x8 /* uleb128 0x4 */
+ .byte 0x4 /* DW_CFA_advance_loc4 */
+ .4byte .LCFI9-.LCFI8
+ .byte 0xe /* DW_CFA_def_cfa_offset */
+ .byte 0xc /* uleb128 0x4 */
+ .byte 0x4 /* DW_CFA_advance_loc4 */
+ .4byte .LCFIA-.LCFI9
+ .byte 0xe /* DW_CFA_def_cfa_offset */
+ .byte 0x10 /* uleb128 0x4 */
+ .byte 0x4 /* DW_CFA_advance_loc4 */
+ .4byte .LCFIB-.LCFIA
+ .byte 0xe /* DW_CFA_def_cfa_offset */
+ .byte 0x14 /* uleb128 0x4 */
+ .byte 0x4 /* DW_CFA_advance_loc4 */
+ .4byte .LCFIC-.LCFIB
+ .byte 0xe /* DW_CFA_def_cfa_offset */
+ .byte 0x18 /* uleb128 0x4 */
+ .byte 0x4 /* DW_CFA_advance_loc4 */
+ .4byte .LCFID-.LCFIC
+ .byte 0xe /* DW_CFA_def_cfa_offset */
+#if defined(__SH4__)
+ .byte 24+48 /* uleb128 24+48 */
+#else
+ .byte 24+16 /* uleb128 24+16 */
+#endif
+ .byte 0x91 /* DW_CFA_offset, column 0x11 */
+ .byte 0x6 /* uleb128 0x6 */
+ .byte 0x8e /* DW_CFA_offset, column 0xe */
+ .byte 0x5 /* uleb128 0x5 */
+ .byte 0x84 /* DW_CFA_offset, column 0x4 */
+ .byte 0x4 /* uleb128 0x4 */
+ .byte 0x85 /* DW_CFA_offset, column 0x5 */
+ .byte 0x3 /* uleb128 0x3 */
+ .byte 0x86 /* DW_CFA_offset, column 0x6 */
+ .byte 0x2 /* uleb128 0x2 */
+ .byte 0x87 /* DW_CFA_offset, column 0x7 */
+ .byte 0x1 /* uleb128 0x1 */
+ .byte 0x4 /* DW_CFA_advance_loc4 */
+ .4byte .LCFIE-.LCFID
+ .byte 0xd /* DW_CFA_def_cfa_register */
+ .byte 0xe /* uleb128 0xe */
+ .align 2
+.LEFDE3:
diff --git a/jni/ruby/ext/fiddle/libffi-3.2.1/src/sh64/ffi.c b/jni/ruby/ext/fiddle/libffi-3.2.1/src/sh64/ffi.c
new file mode 100644
index 0000000..123b87a
--- /dev/null
+++ b/jni/ruby/ext/fiddle/libffi-3.2.1/src/sh64/ffi.c
@@ -0,0 +1,469 @@
+/* -----------------------------------------------------------------------
+ ffi.c - Copyright (c) 2003, 2004, 2006, 2007, 2012 Kaz Kojima
+ Copyright (c) 2008 Anthony Green
+
+ SuperH SHmedia Foreign Function Interface
+
+ Permission is hereby granted, free of charge, to any person obtaining
+ a copy of this software and associated documentation files (the
+ ``Software''), to deal in the Software without restriction, including
+ without limitation the rights to use, copy, modify, merge, publish,
+ distribute, sublicense, and/or sell copies of the Software, and to
+ permit persons to whom the Software is furnished to do so, subject to
+ the following conditions:
+
+ The above copyright notice and this permission notice shall be included
+ in all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND,
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+ HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ DEALINGS IN THE SOFTWARE.
+ ----------------------------------------------------------------------- */
+
+#include <ffi.h>
+#include <ffi_common.h>
+
+#include <stdlib.h>
+
+#define NGREGARG 8
+#define NFREGARG 12
+
+static int
+return_type (ffi_type *arg)
+{
+
+ if (arg->type != FFI_TYPE_STRUCT)
+ return arg->type;
+
+ /* gcc uses r2 if the result can be packed in on register. */
+ if (arg->size <= sizeof (UINT8))
+ return FFI_TYPE_UINT8;
+ else if (arg->size <= sizeof (UINT16))
+ return FFI_TYPE_UINT16;
+ else if (arg->size <= sizeof (UINT32))
+ return FFI_TYPE_UINT32;
+ else if (arg->size <= sizeof (UINT64))
+ return FFI_TYPE_UINT64;
+
+ return FFI_TYPE_STRUCT;
+}
+
+/* ffi_prep_args is called by the assembly routine once stack space
+ has been allocated for the function's arguments */
+
+void ffi_prep_args(char *stack, extended_cif *ecif)
+{
+ register unsigned int i;
+ register unsigned int avn;
+ register void **p_argv;
+ register char *argp;
+ register ffi_type **p_arg;
+
+ argp = stack;
+
+ if (return_type (ecif->cif->rtype) == FFI_TYPE_STRUCT)
+ {
+ *(void **) argp = ecif->rvalue;
+ argp += sizeof (UINT64);
+ }
+
+ avn = ecif->cif->nargs;
+ p_argv = ecif->avalue;
+
+ for (i = 0, p_arg = ecif->cif->arg_types; i < avn; i++, p_arg++, p_argv++)
+ {
+ size_t z;
+ int align;
+
+ z = (*p_arg)->size;
+ align = (*p_arg)->alignment;
+ if (z < sizeof (UINT32))
+ {
+ switch ((*p_arg)->type)
+ {
+ case FFI_TYPE_SINT8:
+ *(SINT64 *) argp = (SINT64) *(SINT8 *)(*p_argv);
+ break;
+
+ case FFI_TYPE_UINT8:
+ *(UINT64 *) argp = (UINT64) *(UINT8 *)(*p_argv);
+ break;
+
+ case FFI_TYPE_SINT16:
+ *(SINT64 *) argp = (SINT64) *(SINT16 *)(*p_argv);
+ break;
+
+ case FFI_TYPE_UINT16:
+ *(UINT64 *) argp = (UINT64) *(UINT16 *)(*p_argv);
+ break;
+
+ case FFI_TYPE_STRUCT:
+ memcpy (argp, *p_argv, z);
+ break;
+
+ default:
+ FFI_ASSERT(0);
+ }
+ argp += sizeof (UINT64);
+ }
+ else if (z == sizeof (UINT32) && align == sizeof (UINT32))
+ {
+ switch ((*p_arg)->type)
+ {
+ case FFI_TYPE_INT:
+ case FFI_TYPE_SINT32:
+ *(SINT64 *) argp = (SINT64) *(SINT32 *) (*p_argv);
+ break;
+
+ case FFI_TYPE_FLOAT:
+ case FFI_TYPE_POINTER:
+ case FFI_TYPE_UINT32:
+ case FFI_TYPE_STRUCT:
+ *(UINT64 *) argp = (UINT64) *(UINT32 *) (*p_argv);
+ break;
+
+ default:
+ FFI_ASSERT(0);
+ break;
+ }
+ argp += sizeof (UINT64);
+ }
+ else if (z == sizeof (UINT64)
+ && align == sizeof (UINT64)
+ && ((int) *p_argv & (sizeof (UINT64) - 1)) == 0)
+ {
+ *(UINT64 *) argp = *(UINT64 *) (*p_argv);
+ argp += sizeof (UINT64);
+ }
+ else
+ {
+ int n = (z + sizeof (UINT64) - 1) / sizeof (UINT64);
+
+ memcpy (argp, *p_argv, z);
+ argp += n * sizeof (UINT64);
+ }
+ }
+
+ return;
+}
+
+/* Perform machine dependent cif processing */
+ffi_status ffi_prep_cif_machdep(ffi_cif *cif)
+{
+ int i, j;
+ int size, type;
+ int n, m;
+ int greg;
+ int freg;
+ int fpair = -1;
+
+ greg = (return_type (cif->rtype) == FFI_TYPE_STRUCT ? 1 : 0);
+ freg = 0;
+ cif->flags2 = 0;
+
+ for (i = j = 0; i < cif->nargs; i++)
+ {
+ type = (cif->arg_types)[i]->type;
+ switch (type)
+ {
+ case FFI_TYPE_FLOAT:
+ greg++;
+ cif->bytes += sizeof (UINT64) - sizeof (float);
+ if (freg >= NFREGARG - 1)
+ continue;
+ if (fpair < 0)
+ {
+ fpair = freg;
+ freg += 2;
+ }
+ else
+ fpair = -1;
+ cif->flags2 += ((cif->arg_types)[i]->type) << (2 * j++);
+ break;
+
+ case FFI_TYPE_DOUBLE:
+ if (greg++ >= NGREGARG && (freg + 1) >= NFREGARG)
+ continue;
+ if ((freg + 1) < NFREGARG)
+ {
+ freg += 2;
+ cif->flags2 += ((cif->arg_types)[i]->type) << (2 * j++);
+ }
+ else
+ cif->flags2 += FFI_TYPE_INT << (2 * j++);
+ break;
+
+ default:
+ size = (cif->arg_types)[i]->size;
+ if (size < sizeof (UINT64))
+ cif->bytes += sizeof (UINT64) - size;
+ n = (size + sizeof (UINT64) - 1) / sizeof (UINT64);
+ if (greg >= NGREGARG)
+ continue;
+ else if (greg + n - 1 >= NGREGARG)
+ greg = NGREGARG;
+ else
+ greg += n;
+ for (m = 0; m < n; m++)
+ cif->flags2 += FFI_TYPE_INT << (2 * j++);
+ break;
+ }
+ }
+
+ /* Set the return type flag */
+ switch (cif->rtype->type)
+ {
+ case FFI_TYPE_STRUCT:
+ cif->flags = return_type (cif->rtype);
+ break;
+
+ case FFI_TYPE_VOID:
+ case FFI_TYPE_FLOAT:
+ case FFI_TYPE_DOUBLE:
+ case FFI_TYPE_SINT64:
+ case FFI_TYPE_UINT64:
+ cif->flags = cif->rtype->type;
+ break;
+
+ default:
+ cif->flags = FFI_TYPE_INT;
+ break;
+ }
+
+ return FFI_OK;
+}
+
+/*@-declundef@*/
+/*@-exportheader@*/
+extern void ffi_call_SYSV(void (*)(char *, extended_cif *),
+ /*@out@*/ extended_cif *,
+ unsigned, unsigned, long long,
+ /*@out@*/ unsigned *,
+ void (*fn)(void));
+/*@=declundef@*/
+/*@=exportheader@*/
+
+void ffi_call(/*@dependent@*/ ffi_cif *cif,
+ void (*fn)(void),
+ /*@out@*/ void *rvalue,
+ /*@dependent@*/ void **avalue)
+{
+ extended_cif ecif;
+ UINT64 trvalue;
+
+ ecif.cif = cif;
+ ecif.avalue = avalue;
+
+ /* If the return value is a struct and we don't have a return */
+ /* value address then we need to make one */
+
+ if (cif->rtype->type == FFI_TYPE_STRUCT
+ && return_type (cif->rtype) != FFI_TYPE_STRUCT)
+ ecif.rvalue = &trvalue;
+ else if ((rvalue == NULL) &&
+ (cif->rtype->type == FFI_TYPE_STRUCT))
+ {
+ ecif.rvalue = alloca(cif->rtype->size);
+ }
+ else
+ ecif.rvalue = rvalue;
+
+ switch (cif->abi)
+ {
+ case FFI_SYSV:
+ ffi_call_SYSV(ffi_prep_args, &ecif, cif->bytes, cif->flags, cif->flags2,
+ ecif.rvalue, fn);
+ break;
+ default:
+ FFI_ASSERT(0);
+ break;
+ }
+
+ if (rvalue
+ && cif->rtype->type == FFI_TYPE_STRUCT
+ && return_type (cif->rtype) != FFI_TYPE_STRUCT)
+ memcpy (rvalue, &trvalue, cif->rtype->size);
+}
+
+extern void ffi_closure_SYSV (void);
+extern void __ic_invalidate (void *line);
+
+ffi_status
+ffi_prep_closure_loc (ffi_closure *closure,
+ ffi_cif *cif,
+ void (*fun)(ffi_cif*, void*, void**, void*),
+ void *user_data,
+ void *codeloc)
+{
+ unsigned int *tramp;
+
+ if (cif->abi != FFI_SYSV)
+ return FFI_BAD_ABI;
+
+ tramp = (unsigned int *) &closure->tramp[0];
+ /* Since ffi_closure is an aligned object, the ffi trampoline is
+ called as an SHcompact code. Sigh.
+ SHcompact part:
+ mova @(1,pc),r0; add #1,r0; jmp @r0; nop;
+ SHmedia part:
+ movi fnaddr >> 16,r1; shori fnaddr,r1; ptabs/l r1,tr0
+ movi cxt >> 16,r1; shori cxt,r1; blink tr0,r63 */
+#ifdef __LITTLE_ENDIAN__
+ tramp[0] = 0x7001c701;
+ tramp[1] = 0x0009402b;
+#else
+ tramp[0] = 0xc7017001;
+ tramp[1] = 0x402b0009;
+#endif
+ tramp[2] = 0xcc000010 | (((UINT32) ffi_closure_SYSV) >> 16) << 10;
+ tramp[3] = 0xc8000010 | (((UINT32) ffi_closure_SYSV) & 0xffff) << 10;
+ tramp[4] = 0x6bf10600;
+ tramp[5] = 0xcc000010 | (((UINT32) codeloc) >> 16) << 10;
+ tramp[6] = 0xc8000010 | (((UINT32) codeloc) & 0xffff) << 10;
+ tramp[7] = 0x4401fff0;
+
+ closure->cif = cif;
+ closure->fun = fun;
+ closure->user_data = user_data;
+
+ /* Flush the icache. */
+ asm volatile ("ocbwb %0,0; synco; icbi %1,0; synci" : : "r" (tramp),
+ "r"(codeloc));
+
+ return FFI_OK;
+}
+
+/* Basically the trampoline invokes ffi_closure_SYSV, and on
+ * entry, r3 holds the address of the closure.
+ * After storing the registers that could possibly contain
+ * parameters to be passed into the stack frame and setting
+ * up space for a return value, ffi_closure_SYSV invokes the
+ * following helper function to do most of the work.
+ */
+
+int
+ffi_closure_helper_SYSV (ffi_closure *closure, UINT64 *rvalue,
+ UINT64 *pgr, UINT64 *pfr, UINT64 *pst)
+{
+ void **avalue;
+ ffi_type **p_arg;
+ int i, avn;
+ int greg, freg;
+ ffi_cif *cif;
+ int fpair = -1;
+
+ cif = closure->cif;
+ avalue = alloca (cif->nargs * sizeof (void *));
+
+ /* Copy the caller's structure return value address so that the closure
+ returns the data directly to the caller. */
+ if (return_type (cif->rtype) == FFI_TYPE_STRUCT)
+ {
+ rvalue = (UINT64 *) *pgr;
+ greg = 1;
+ }
+ else
+ greg = 0;
+
+ freg = 0;
+ cif = closure->cif;
+ avn = cif->nargs;
+
+ /* Grab the addresses of the arguments from the stack frame. */
+ for (i = 0, p_arg = cif->arg_types; i < avn; i++, p_arg++)
+ {
+ size_t z;
+ void *p;
+
+ z = (*p_arg)->size;
+ if (z < sizeof (UINT32))
+ {
+ p = pgr + greg++;
+
+ switch ((*p_arg)->type)
+ {
+ case FFI_TYPE_SINT8:
+ case FFI_TYPE_UINT8:
+ case FFI_TYPE_SINT16:
+ case FFI_TYPE_UINT16:
+ case FFI_TYPE_STRUCT:
+#ifdef __LITTLE_ENDIAN__
+ avalue[i] = p;
+#else
+ avalue[i] = ((char *) p) + sizeof (UINT32) - z;
+#endif
+ break;
+
+ default:
+ FFI_ASSERT(0);
+ }
+ }
+ else if (z == sizeof (UINT32))
+ {
+ if ((*p_arg)->type == FFI_TYPE_FLOAT)
+ {
+ if (freg < NFREGARG - 1)
+ {
+ if (fpair >= 0)
+ {
+ avalue[i] = (UINT32 *) pfr + fpair;
+ fpair = -1;
+ }
+ else
+ {
+#ifdef __LITTLE_ENDIAN__
+ fpair = freg;
+ avalue[i] = (UINT32 *) pfr + (1 ^ freg);
+#else
+ fpair = 1 ^ freg;
+ avalue[i] = (UINT32 *) pfr + freg;
+#endif
+ freg += 2;
+ }
+ }
+ else
+#ifdef __LITTLE_ENDIAN__
+ avalue[i] = pgr + greg;
+#else
+ avalue[i] = (UINT32 *) (pgr + greg) + 1;
+#endif
+ }
+ else
+#ifdef __LITTLE_ENDIAN__
+ avalue[i] = pgr + greg;
+#else
+ avalue[i] = (UINT32 *) (pgr + greg) + 1;
+#endif
+ greg++;
+ }
+ else if ((*p_arg)->type == FFI_TYPE_DOUBLE)
+ {
+ if (freg + 1 >= NFREGARG)
+ avalue[i] = pgr + greg;
+ else
+ {
+ avalue[i] = pfr + (freg >> 1);
+ freg += 2;
+ }
+ greg++;
+ }
+ else
+ {
+ int n = (z + sizeof (UINT64) - 1) / sizeof (UINT64);
+
+ avalue[i] = pgr + greg;
+ greg += n;
+ }
+ }
+
+ (closure->fun) (cif, rvalue, avalue, closure->user_data);
+
+ /* Tell ffi_closure_SYSV how to perform return type promotions. */
+ return return_type (cif->rtype);
+}
+
diff --git a/jni/ruby/ext/fiddle/libffi-3.2.1/src/sh64/ffitarget.h b/jni/ruby/ext/fiddle/libffi-3.2.1/src/sh64/ffitarget.h
new file mode 100644
index 0000000..08a6fe9
--- /dev/null
+++ b/jni/ruby/ext/fiddle/libffi-3.2.1/src/sh64/ffitarget.h
@@ -0,0 +1,58 @@
+/* -----------------------------------------------------------------*-C-*-
+ ffitarget.h - Copyright (c) 2012 Anthony Green
+ Copyright (c) 1996-2003 Red Hat, Inc.
+ Target configuration macros for SuperH - SHmedia.
+
+ Permission is hereby granted, free of charge, to any person obtaining
+ a copy of this software and associated documentation files (the
+ ``Software''), to deal in the Software without restriction, including
+ without limitation the rights to use, copy, modify, merge, publish,
+ distribute, sublicense, and/or sell copies of the Software, and to
+ permit persons to whom the Software is furnished to do so, subject to
+ the following conditions:
+
+ The above copyright notice and this permission notice shall be included
+ in all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND,
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+ HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ DEALINGS IN THE SOFTWARE.
+
+ ----------------------------------------------------------------------- */
+
+#ifndef LIBFFI_TARGET_H
+#define LIBFFI_TARGET_H
+
+#ifndef LIBFFI_H
+#error "Please do not include ffitarget.h directly into your source. Use ffi.h instead."
+#endif
+
+/* ---- Generic type definitions ----------------------------------------- */
+
+#ifndef LIBFFI_ASM
+typedef unsigned long ffi_arg;
+typedef signed long ffi_sarg;
+
+typedef enum ffi_abi {
+ FFI_FIRST_ABI = 0,
+ FFI_SYSV,
+ FFI_LAST_ABI,
+ FFI_DEFAULT_ABI = FFI_SYSV
+} ffi_abi;
+
+#define FFI_EXTRA_CIF_FIELDS long long flags2
+#endif
+
+/* ---- Definitions for closures ----------------------------------------- */
+
+#define FFI_CLOSURES 1
+#define FFI_TRAMPOLINE_SIZE 32
+#define FFI_NATIVE_RAW_API 0
+
+#endif
+
diff --git a/jni/ruby/ext/fiddle/libffi-3.2.1/src/sh64/sysv.S b/jni/ruby/ext/fiddle/libffi-3.2.1/src/sh64/sysv.S
new file mode 100644
index 0000000..c4587d5
--- /dev/null
+++ b/jni/ruby/ext/fiddle/libffi-3.2.1/src/sh64/sysv.S
@@ -0,0 +1,539 @@
+/* -----------------------------------------------------------------------
+ sysv.S - Copyright (c) 2003, 2004, 2006, 2008 Kaz Kojima
+
+ SuperH SHmedia Foreign Function Interface
+
+ Permission is hereby granted, free of charge, to any person obtaining
+ a copy of this software and associated documentation files (the
+ ``Software''), to deal in the Software without restriction, including
+ without limitation the rights to use, copy, modify, merge, publish,
+ distribute, sublicense, and/or sell copies of the Software, and to
+ permit persons to whom the Software is furnished to do so, subject to
+ the following conditions:
+
+ The above copyright notice and this permission notice shall be included
+ in all copies or substantial portions of the Software.
+
+
+ THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND,
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+ HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ DEALINGS IN THE SOFTWARE.
+ ----------------------------------------------------------------------- */
+
+#define LIBFFI_ASM
+#include <fficonfig.h>
+#include <ffi.h>
+#ifdef HAVE_MACHINE_ASM_H
+#include <machine/asm.h>
+#else
+/* XXX these lose for some platforms, I'm sure. */
+#define CNAME(x) x
+#define ENTRY(x) .globl CNAME(x); .type CNAME(x),%function; CNAME(x):
+#endif
+
+#ifdef __LITTLE_ENDIAN__
+#define OFS_FLT 0
+#else
+#define OFS_FLT 4
+#endif
+
+ .section .text..SHmedia32,"ax"
+
+ # r2: ffi_prep_args
+ # r3: &ecif
+ # r4: bytes
+ # r5: flags
+ # r6: flags2
+ # r7: rvalue
+ # r8: fn
+
+ # This assumes we are using gas.
+ .align 5
+ENTRY(ffi_call_SYSV)
+ # Save registers
+.LFB1:
+ addi.l r15, -48, r15
+.LCFI0:
+ st.q r15, 40, r32
+ st.q r15, 32, r31
+ st.q r15, 24, r30
+ st.q r15, 16, r29
+ st.q r15, 8, r28
+ st.l r15, 4, r18
+ st.l r15, 0, r14
+.LCFI1:
+ add.l r15, r63, r14
+.LCFI2:
+# add r4, r63, r28
+ add r5, r63, r29
+ add r6, r63, r30
+ add r7, r63, r31
+ add r8, r63, r32
+
+ addi r4, (64 + 7), r4
+ andi r4, ~7, r4
+ sub.l r15, r4, r15
+
+ ptabs/l r2, tr0
+ add r15, r63, r2
+ blink tr0, r18
+
+ addi r15, 64, r22
+ movi 0, r0
+ movi 0, r1
+ movi -1, r23
+
+ pt/l 1f, tr1
+ bnei/l r29, FFI_TYPE_STRUCT, tr1
+ ld.l r15, 0, r19
+ addi r15, 8, r15
+ addi r0, 1, r0
+1:
+
+.L_pass:
+ andi r30, 3, r20
+ shlri r30, 2, r30
+
+ pt/l .L_call_it, tr0
+ pt/l .L_pass_i, tr1
+ pt/l .L_pass_f, tr2
+
+ beqi/l r20, FFI_TYPE_VOID, tr0
+ beqi/l r20, FFI_TYPE_INT, tr1
+ beqi/l r20, FFI_TYPE_FLOAT, tr2
+
+.L_pass_d:
+ addi r0, 1, r0
+ pt/l 3f, tr0
+ movi 12, r20
+ bge/l r1, r20, tr0
+
+ pt/l .L_pop_d, tr1
+ pt/l 2f, tr0
+ blink tr1, r63
+2:
+ addi.l r15, 8, r15
+3:
+ pt/l .L_pass, tr0
+ addi r1, 2, r1
+ blink tr0, r63
+
+.L_pop_d:
+ pt/l .L_pop_d_tbl, tr1
+ gettr tr1, r20
+ shlli r1, 2, r21
+ add r20, r21, r20
+ ptabs/l r20, tr1
+ blink tr1, r63
+
+.L_pop_d_tbl:
+ fld.d r15, 0, dr0
+ blink tr0, r63
+ fld.d r15, 0, dr2
+ blink tr0, r63
+ fld.d r15, 0, dr4
+ blink tr0, r63
+ fld.d r15, 0, dr6
+ blink tr0, r63
+ fld.d r15, 0, dr8
+ blink tr0, r63
+ fld.d r15, 0, dr10
+ blink tr0, r63
+
+.L_pass_f:
+ addi r0, 1, r0
+ pt/l 3f, tr0
+ movi 12, r20
+ bge/l r1, r20, tr0
+
+ pt/l .L_pop_f, tr1
+ pt/l 2f, tr0
+ blink tr1, r63
+2:
+ addi.l r15, 8, r15
+3:
+ pt/l .L_pass, tr0
+ blink tr0, r63
+
+.L_pop_f:
+ pt/l .L_pop_f_tbl, tr1
+ pt/l 5f, tr2
+ gettr tr1, r20
+ bge/l r23, r63, tr2
+ add r1, r63, r23
+ shlli r1, 3, r21
+ addi r1, 2, r1
+ add r20, r21, r20
+ ptabs/l r20, tr1
+ blink tr1, r63
+5:
+ addi r23, 1, r21
+ movi -1, r23
+ shlli r21, 3, r21
+ add r20, r21, r20
+ ptabs/l r20, tr1
+ blink tr1, r63
+
+.L_pop_f_tbl:
+ fld.s r15, OFS_FLT, fr0
+ blink tr0, r63
+ fld.s r15, OFS_FLT, fr1
+ blink tr0, r63
+ fld.s r15, OFS_FLT, fr2
+ blink tr0, r63
+ fld.s r15, OFS_FLT, fr3
+ blink tr0, r63
+ fld.s r15, OFS_FLT, fr4
+ blink tr0, r63
+ fld.s r15, OFS_FLT, fr5
+ blink tr0, r63
+ fld.s r15, OFS_FLT, fr6
+ blink tr0, r63
+ fld.s r15, OFS_FLT, fr7
+ blink tr0, r63
+ fld.s r15, OFS_FLT, fr8
+ blink tr0, r63
+ fld.s r15, OFS_FLT, fr9
+ blink tr0, r63
+ fld.s r15, OFS_FLT, fr10
+ blink tr0, r63
+ fld.s r15, OFS_FLT, fr11
+ blink tr0, r63
+
+.L_pass_i:
+ pt/l 3f, tr0
+ movi 8, r20
+ bge/l r0, r20, tr0
+
+ pt/l .L_pop_i, tr1
+ pt/l 2f, tr0
+ blink tr1, r63
+2:
+ addi.l r15, 8, r15
+3:
+ pt/l .L_pass, tr0
+ addi r0, 1, r0
+ blink tr0, r63
+
+.L_pop_i:
+ pt/l .L_pop_i_tbl, tr1
+ gettr tr1, r20
+ shlli r0, 3, r21
+ add r20, r21, r20
+ ptabs/l r20, tr1
+ blink tr1, r63
+
+.L_pop_i_tbl:
+ ld.q r15, 0, r2
+ blink tr0, r63
+ ld.q r15, 0, r3
+ blink tr0, r63
+ ld.q r15, 0, r4
+ blink tr0, r63
+ ld.q r15, 0, r5
+ blink tr0, r63
+ ld.q r15, 0, r6
+ blink tr0, r63
+ ld.q r15, 0, r7
+ blink tr0, r63
+ ld.q r15, 0, r8
+ blink tr0, r63
+ ld.q r15, 0, r9
+ blink tr0, r63
+
+.L_call_it:
+ # call function
+ pt/l 1f, tr1
+ bnei/l r29, FFI_TYPE_STRUCT, tr1
+ add r19, r63, r2
+1:
+ add r22, r63, r15
+ ptabs/l r32, tr0
+ blink tr0, r18
+
+ pt/l .L_ret_i, tr0
+ pt/l .L_ret_ll, tr1
+ pt/l .L_ret_d, tr2
+ pt/l .L_ret_f, tr3
+ pt/l .L_epilogue, tr4
+
+ beqi/l r29, FFI_TYPE_INT, tr0
+ beqi/l r29, FFI_TYPE_UINT32, tr0
+ beqi/l r29, FFI_TYPE_SINT64, tr1
+ beqi/l r29, FFI_TYPE_UINT64, tr1
+ beqi/l r29, FFI_TYPE_DOUBLE, tr2
+ beqi/l r29, FFI_TYPE_FLOAT, tr3
+
+ pt/l .L_ret_q, tr0
+ pt/l .L_ret_h, tr1
+
+ beqi/l r29, FFI_TYPE_UINT8, tr0
+ beqi/l r29, FFI_TYPE_UINT16, tr1
+ blink tr4, r63
+
+.L_ret_d:
+ fst.d r31, 0, dr0
+ blink tr4, r63
+
+.L_ret_ll:
+ st.q r31, 0, r2
+ blink tr4, r63
+
+.L_ret_f:
+ fst.s r31, OFS_FLT, fr0
+ blink tr4, r63
+
+.L_ret_q:
+ st.b r31, 0, r2
+ blink tr4, r63
+
+.L_ret_h:
+ st.w r31, 0, r2
+ blink tr4, r63
+
+.L_ret_i:
+ st.l r31, 0, r2
+ # Fall
+
+.L_epilogue:
+ # Remove the space we pushed for the args
+ add r14, r63, r15
+
+ ld.l r15, 0, r14
+ ld.l r15, 4, r18
+ ld.q r15, 8, r28
+ ld.q r15, 16, r29
+ ld.q r15, 24, r30
+ ld.q r15, 32, r31
+ ld.q r15, 40, r32
+ addi.l r15, 48, r15
+ ptabs r18, tr0
+ blink tr0, r63
+
+.LFE1:
+.ffi_call_SYSV_end:
+ .size CNAME(ffi_call_SYSV),.ffi_call_SYSV_end-CNAME(ffi_call_SYSV)
+
+ .align 5
+ENTRY(ffi_closure_SYSV)
+.LFB2:
+ addi.l r15, -136, r15
+.LCFI3:
+ st.l r15, 12, r18
+ st.l r15, 8, r14
+ st.l r15, 4, r12
+.LCFI4:
+ add r15, r63, r14
+.LCFI5:
+ /* Stack layout:
+ ...
+ 64 bytes (register parameters)
+ 48 bytes (floating register parameters)
+ 8 bytes (result)
+ 4 bytes (r18)
+ 4 bytes (r14)
+ 4 bytes (r12)
+ 4 bytes (for align)
+ <- new stack pointer
+ */
+ fst.d r14, 24, dr0
+ fst.d r14, 32, dr2
+ fst.d r14, 40, dr4
+ fst.d r14, 48, dr6
+ fst.d r14, 56, dr8
+ fst.d r14, 64, dr10
+ st.q r14, 72, r2
+ st.q r14, 80, r3
+ st.q r14, 88, r4
+ st.q r14, 96, r5
+ st.q r14, 104, r6
+ st.q r14, 112, r7
+ st.q r14, 120, r8
+ st.q r14, 128, r9
+
+ add r1, r63, r2
+ addi r14, 16, r3
+ addi r14, 72, r4
+ addi r14, 24, r5
+ addi r14, 136, r6
+#ifdef PIC
+ movi (((datalabel _GLOBAL_OFFSET_TABLE_-(.LPCS0-.)) >> 16) & 65535), r12
+ shori ((datalabel _GLOBAL_OFFSET_TABLE_-(.LPCS0-.)) & 65535), r12
+.LPCS0: ptrel/u r12, tr0
+ movi ((ffi_closure_helper_SYSV@GOTPLT) & 65535), r1
+ gettr tr0, r12
+ ldx.l r1, r12, r1
+ ptabs r1, tr0
+#else
+ pt/l ffi_closure_helper_SYSV, tr0
+#endif
+ blink tr0, r18
+
+ shlli r2, 1, r1
+ movi (((datalabel .L_table) >> 16) & 65535), r2
+ shori ((datalabel .L_table) & 65535), r2
+ ldx.w r2, r1, r1
+ add r1, r2, r1
+ pt/l .L_case_v, tr1
+ ptabs r1, tr0
+ blink tr0, r63
+
+ .align 2
+.L_table:
+ .word .L_case_v - datalabel .L_table /* FFI_TYPE_VOID */
+ .word .L_case_i - datalabel .L_table /* FFI_TYPE_INT */
+ .word .L_case_f - datalabel .L_table /* FFI_TYPE_FLOAT */
+ .word .L_case_d - datalabel .L_table /* FFI_TYPE_DOUBLE */
+ .word .L_case_d - datalabel .L_table /* FFI_TYPE_LONGDOUBLE */
+ .word .L_case_uq - datalabel .L_table /* FFI_TYPE_UINT8 */
+ .word .L_case_q - datalabel .L_table /* FFI_TYPE_SINT8 */
+ .word .L_case_uh - datalabel .L_table /* FFI_TYPE_UINT16 */
+ .word .L_case_h - datalabel .L_table /* FFI_TYPE_SINT16 */
+ .word .L_case_i - datalabel .L_table /* FFI_TYPE_UINT32 */
+ .word .L_case_i - datalabel .L_table /* FFI_TYPE_SINT32 */
+ .word .L_case_ll - datalabel .L_table /* FFI_TYPE_UINT64 */
+ .word .L_case_ll - datalabel .L_table /* FFI_TYPE_SINT64 */
+ .word .L_case_v - datalabel .L_table /* FFI_TYPE_STRUCT */
+ .word .L_case_i - datalabel .L_table /* FFI_TYPE_POINTER */
+
+ .align 2
+.L_case_d:
+ fld.d r14, 16, dr0
+ blink tr1, r63
+.L_case_f:
+ fld.s r14, 16, fr0
+ blink tr1, r63
+.L_case_ll:
+ ld.q r14, 16, r2
+ blink tr1, r63
+.L_case_i:
+ ld.l r14, 16, r2
+ blink tr1, r63
+.L_case_q:
+ ld.b r14, 16, r2
+ blink tr1, r63
+.L_case_uq:
+ ld.ub r14, 16, r2
+ blink tr1, r63
+.L_case_h:
+ ld.w r14, 16, r2
+ blink tr1, r63
+.L_case_uh:
+ ld.uw r14, 16, r2
+ blink tr1, r63
+.L_case_v:
+ add.l r14, r63, r15
+ ld.l r15, 4, r12
+ ld.l r15, 8, r14
+ ld.l r15, 12, r18
+ addi.l r15, 136, r15
+ ptabs r18, tr0
+ blink tr0, r63
+
+.LFE2:
+.ffi_closure_SYSV_end:
+ .size CNAME(ffi_closure_SYSV),.ffi_closure_SYSV_end-CNAME(ffi_closure_SYSV)
+
+#if defined __ELF__ && defined __linux__
+ .section .note.GNU-stack,"",@progbits
+#endif
+
+ .section ".eh_frame","aw",@progbits
+__FRAME_BEGIN__:
+ .4byte .LECIE1-.LSCIE1 /* Length of Common Information Entry */
+.LSCIE1:
+ .4byte 0x0 /* CIE Identifier Tag */
+ .byte 0x1 /* CIE Version */
+#ifdef PIC
+ .ascii "zR\0" /* CIE Augmentation */
+#else
+ .byte 0x0 /* CIE Augmentation */
+#endif
+ .uleb128 0x1 /* CIE Code Alignment Factor */
+ .sleb128 -4 /* CIE Data Alignment Factor */
+ .byte 0x12 /* CIE RA Column */
+#ifdef PIC
+ .uleb128 0x1 /* Augmentation size */
+ .byte 0x10 /* FDE Encoding (pcrel) */
+#endif
+ .byte 0xc /* DW_CFA_def_cfa */
+ .uleb128 0xf
+ .uleb128 0x0
+ .align 2
+.LECIE1:
+.LSFDE1:
+ .4byte datalabel .LEFDE1-datalabel .LASFDE1 /* FDE Length */
+.LASFDE1:
+ .4byte datalabel .LASFDE1-datalabel __FRAME_BEGIN__
+#ifdef PIC
+ .4byte .LFB1-. /* FDE initial location */
+#else
+ .4byte .LFB1 /* FDE initial location */
+#endif
+ .4byte datalabel .LFE1-datalabel .LFB1 /* FDE address range */
+#ifdef PIC
+ .uleb128 0x0 /* Augmentation size */
+#endif
+ .byte 0x4 /* DW_CFA_advance_loc4 */
+ .4byte datalabel .LCFI0-datalabel .LFB1
+ .byte 0xe /* DW_CFA_def_cfa_offset */
+ .uleb128 0x30
+ .byte 0x4 /* DW_CFA_advance_loc4 */
+ .4byte datalabel .LCFI1-datalabel .LCFI0
+ .byte 0x8e /* DW_CFA_offset, column 0xe */
+ .uleb128 0xc
+ .byte 0x92 /* DW_CFA_offset, column 0x12 */
+ .uleb128 0xb
+ .byte 0x9c /* DW_CFA_offset, column 0x1c */
+ .uleb128 0xa
+ .byte 0x9d /* DW_CFA_offset, column 0x1d */
+ .uleb128 0x8
+ .byte 0x9e /* DW_CFA_offset, column 0x1e */
+ .uleb128 0x6
+ .byte 0x9f /* DW_CFA_offset, column 0x1f */
+ .uleb128 0x4
+ .byte 0xa0 /* DW_CFA_offset, column 0x20 */
+ .uleb128 0x2
+ .byte 0x4 /* DW_CFA_advance_loc4 */
+ .4byte datalabel .LCFI2-datalabel .LCFI1
+ .byte 0xd /* DW_CFA_def_cfa_register */
+ .uleb128 0xe
+ .align 2
+.LEFDE1:
+
+.LSFDE3:
+ .4byte datalabel .LEFDE3-datalabel .LASFDE3 /* FDE Length */
+.LASFDE3:
+ .4byte datalabel .LASFDE3-datalabel __FRAME_BEGIN__
+#ifdef PIC
+ .4byte .LFB2-. /* FDE initial location */
+#else
+ .4byte .LFB2 /* FDE initial location */
+#endif
+ .4byte datalabel .LFE2-datalabel .LFB2 /* FDE address range */
+#ifdef PIC
+ .uleb128 0x0 /* Augmentation size */
+#endif
+ .byte 0x4 /* DW_CFA_advance_loc4 */
+ .4byte datalabel .LCFI3-datalabel .LFB2
+ .byte 0xe /* DW_CFA_def_cfa_offset */
+ .uleb128 0x88
+ .byte 0x4 /* DW_CFA_advance_loc4 */
+ .4byte datalabel .LCFI4-datalabel .LCFI3
+ .byte 0x8c /* DW_CFA_offset, column 0xc */
+ .uleb128 0x21
+ .byte 0x8e /* DW_CFA_offset, column 0xe */
+ .uleb128 0x20
+ .byte 0x92 /* DW_CFA_offset, column 0x12 */
+ .uleb128 0x1f
+ .byte 0x4 /* DW_CFA_advance_loc4 */
+ .4byte datalabel .LCFI5-datalabel .LCFI4
+ .byte 0xd /* DW_CFA_def_cfa_register */
+ .uleb128 0xe
+ .align 2
+.LEFDE3:
diff --git a/jni/ruby/ext/fiddle/libffi-3.2.1/src/sparc/ffi.c b/jni/ruby/ext/fiddle/libffi-3.2.1/src/sparc/ffi.c
new file mode 100644
index 0000000..9f0fded
--- /dev/null
+++ b/jni/ruby/ext/fiddle/libffi-3.2.1/src/sparc/ffi.c
@@ -0,0 +1,681 @@
+/* -----------------------------------------------------------------------
+ ffi.c - Copyright (c) 2011, 2013 Anthony Green
+ Copyright (c) 1996, 2003-2004, 2007-2008 Red Hat, Inc.
+
+ SPARC Foreign Function Interface
+
+ Permission is hereby granted, free of charge, to any person obtaining
+ a copy of this software and associated documentation files (the
+ ``Software''), to deal in the Software without restriction, including
+ without limitation the rights to use, copy, modify, merge, publish,
+ distribute, sublicense, and/or sell copies of the Software, and to
+ permit persons to whom the Software is furnished to do so, subject to
+ the following conditions:
+
+ The above copyright notice and this permission notice shall be included
+ in all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND,
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+ HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ DEALINGS IN THE SOFTWARE.
+ ----------------------------------------------------------------------- */
+
+#include <ffi.h>
+#include <ffi_common.h>
+
+#include <stdlib.h>
+
+
+/* ffi_prep_args is called by the assembly routine once stack space
+ has been allocated for the function's arguments */
+
+void ffi_prep_args_v8(char *stack, extended_cif *ecif)
+{
+ int i;
+ void **p_argv;
+ char *argp;
+ ffi_type **p_arg;
+
+ /* Skip 16 words for the window save area */
+ argp = stack + 16*sizeof(int);
+
+ /* This should only really be done when we are returning a structure,
+ however, it's faster just to do it all the time...
+
+ if ( ecif->cif->rtype->type == FFI_TYPE_STRUCT ) */
+ *(int *) argp = (long)ecif->rvalue;
+
+ /* And 1 word for the structure return value. */
+ argp += sizeof(int);
+
+#ifdef USING_PURIFY
+ /* Purify will probably complain in our assembly routine, unless we
+ zero out this memory. */
+
+ ((int*)argp)[0] = 0;
+ ((int*)argp)[1] = 0;
+ ((int*)argp)[2] = 0;
+ ((int*)argp)[3] = 0;
+ ((int*)argp)[4] = 0;
+ ((int*)argp)[5] = 0;
+#endif
+
+ p_argv = ecif->avalue;
+
+ for (i = ecif->cif->nargs, p_arg = ecif->cif->arg_types; i; i--, p_arg++)
+ {
+ size_t z;
+
+ if ((*p_arg)->type == FFI_TYPE_STRUCT
+#if FFI_TYPE_LONGDOUBLE != FFI_TYPE_DOUBLE
+ || (*p_arg)->type == FFI_TYPE_LONGDOUBLE
+#endif
+ )
+ {
+ *(unsigned int *) argp = (unsigned long)(* p_argv);
+ z = sizeof(int);
+ }
+ else
+ {
+ z = (*p_arg)->size;
+ if (z < sizeof(int))
+ {
+ z = sizeof(int);
+ switch ((*p_arg)->type)
+ {
+ case FFI_TYPE_SINT8:
+ *(signed int *) argp = *(SINT8 *)(* p_argv);
+ break;
+
+ case FFI_TYPE_UINT8:
+ *(unsigned int *) argp = *(UINT8 *)(* p_argv);
+ break;
+
+ case FFI_TYPE_SINT16:
+ *(signed int *) argp = *(SINT16 *)(* p_argv);
+ break;
+
+ case FFI_TYPE_UINT16:
+ *(unsigned int *) argp = *(UINT16 *)(* p_argv);
+ break;
+
+ default:
+ FFI_ASSERT(0);
+ }
+ }
+ else
+ {
+ memcpy(argp, *p_argv, z);
+ }
+ }
+ p_argv++;
+ argp += z;
+ }
+
+ return;
+}
+
+int ffi_prep_args_v9(char *stack, extended_cif *ecif)
+{
+ int i, ret = 0;
+ int tmp;
+ void **p_argv;
+ char *argp;
+ ffi_type **p_arg;
+
+ tmp = 0;
+
+ /* Skip 16 words for the window save area */
+ argp = stack + 16*sizeof(long long);
+
+#ifdef USING_PURIFY
+ /* Purify will probably complain in our assembly routine, unless we
+ zero out this memory. */
+
+ ((long long*)argp)[0] = 0;
+ ((long long*)argp)[1] = 0;
+ ((long long*)argp)[2] = 0;
+ ((long long*)argp)[3] = 0;
+ ((long long*)argp)[4] = 0;
+ ((long long*)argp)[5] = 0;
+#endif
+
+ p_argv = ecif->avalue;
+
+ if (ecif->cif->rtype->type == FFI_TYPE_STRUCT &&
+ ecif->cif->rtype->size > 32)
+ {
+ *(unsigned long long *) argp = (unsigned long)ecif->rvalue;
+ argp += sizeof(long long);
+ tmp = 1;
+ }
+
+ for (i = 0, p_arg = ecif->cif->arg_types; i < ecif->cif->nargs;
+ i++, p_arg++)
+ {
+ size_t z;
+
+ z = (*p_arg)->size;
+ switch ((*p_arg)->type)
+ {
+ case FFI_TYPE_STRUCT:
+ if (z > 16)
+ {
+ /* For structures larger than 16 bytes we pass reference. */
+ *(unsigned long long *) argp = (unsigned long)* p_argv;
+ argp += sizeof(long long);
+ tmp++;
+ p_argv++;
+ continue;
+ }
+ /* FALLTHROUGH */
+ case FFI_TYPE_FLOAT:
+ case FFI_TYPE_DOUBLE:
+#if FFI_TYPE_LONGDOUBLE != FFI_TYPE_DOUBLE
+ case FFI_TYPE_LONGDOUBLE:
+#endif
+ ret = 1; /* We should promote into FP regs as well as integer. */
+ break;
+ }
+ if (z < sizeof(long long))
+ {
+ switch ((*p_arg)->type)
+ {
+ case FFI_TYPE_SINT8:
+ *(signed long long *) argp = *(SINT8 *)(* p_argv);
+ break;
+
+ case FFI_TYPE_UINT8:
+ *(unsigned long long *) argp = *(UINT8 *)(* p_argv);
+ break;
+
+ case FFI_TYPE_SINT16:
+ *(signed long long *) argp = *(SINT16 *)(* p_argv);
+ break;
+
+ case FFI_TYPE_UINT16:
+ *(unsigned long long *) argp = *(UINT16 *)(* p_argv);
+ break;
+
+ case FFI_TYPE_SINT32:
+ *(signed long long *) argp = *(SINT32 *)(* p_argv);
+ break;
+
+ case FFI_TYPE_UINT32:
+ *(unsigned long long *) argp = *(UINT32 *)(* p_argv);
+ break;
+
+ case FFI_TYPE_FLOAT:
+ *(float *) (argp + 4) = *(FLOAT32 *)(* p_argv); /* Right justify */
+ break;
+
+ case FFI_TYPE_STRUCT:
+ memcpy(argp, *p_argv, z);
+ break;
+
+ default:
+ FFI_ASSERT(0);
+ }
+ z = sizeof(long long);
+ tmp++;
+ }
+ else if (z == sizeof(long long))
+ {
+ memcpy(argp, *p_argv, z);
+ z = sizeof(long long);
+ tmp++;
+ }
+ else
+ {
+ if ((tmp & 1) && (*p_arg)->alignment > 8)
+ {
+ tmp++;
+ argp += sizeof(long long);
+ }
+ memcpy(argp, *p_argv, z);
+ z = 2 * sizeof(long long);
+ tmp += 2;
+ }
+ p_argv++;
+ argp += z;
+ }
+
+ return ret;
+}
+
+/* Perform machine dependent cif processing */
+ffi_status ffi_prep_cif_machdep(ffi_cif *cif)
+{
+ int wordsize;
+
+ if (cif->abi != FFI_V9)
+ {
+ wordsize = 4;
+
+ /* If we are returning a struct, this will already have been added.
+ Otherwise we need to add it because it's always got to be there! */
+
+ if (cif->rtype->type != FFI_TYPE_STRUCT)
+ cif->bytes += wordsize;
+
+ /* sparc call frames require that space is allocated for 6 args,
+ even if they aren't used. Make that space if necessary. */
+
+ if (cif->bytes < 4*6+4)
+ cif->bytes = 4*6+4;
+ }
+ else
+ {
+ wordsize = 8;
+
+ /* sparc call frames require that space is allocated for 6 args,
+ even if they aren't used. Make that space if necessary. */
+
+ if (cif->bytes < 8*6)
+ cif->bytes = 8*6;
+ }
+
+ /* Adjust cif->bytes. to include 16 words for the window save area,
+ and maybe the struct/union return pointer area, */
+
+ cif->bytes += 16 * wordsize;
+
+ /* The stack must be 2 word aligned, so round bytes up
+ appropriately. */
+
+ cif->bytes = ALIGN(cif->bytes, 2 * wordsize);
+
+ /* Set the return type flag */
+ switch (cif->rtype->type)
+ {
+ case FFI_TYPE_VOID:
+ case FFI_TYPE_FLOAT:
+ case FFI_TYPE_DOUBLE:
+#if FFI_TYPE_LONGDOUBLE != FFI_TYPE_DOUBLE
+ case FFI_TYPE_LONGDOUBLE:
+#endif
+ cif->flags = cif->rtype->type;
+ break;
+
+ case FFI_TYPE_STRUCT:
+ if (cif->abi == FFI_V9 && cif->rtype->size > 32)
+ cif->flags = FFI_TYPE_VOID;
+ else
+ cif->flags = FFI_TYPE_STRUCT;
+ break;
+
+ case FFI_TYPE_SINT8:
+ case FFI_TYPE_UINT8:
+ case FFI_TYPE_SINT16:
+ case FFI_TYPE_UINT16:
+ if (cif->abi == FFI_V9)
+ cif->flags = FFI_TYPE_INT;
+ else
+ cif->flags = cif->rtype->type;
+ break;
+
+ case FFI_TYPE_SINT64:
+ case FFI_TYPE_UINT64:
+ if (cif->abi == FFI_V9)
+ cif->flags = FFI_TYPE_INT;
+ else
+ cif->flags = FFI_TYPE_SINT64;
+ break;
+
+ default:
+ cif->flags = FFI_TYPE_INT;
+ break;
+ }
+ return FFI_OK;
+}
+
+int ffi_v9_layout_struct(ffi_type *arg, int off, char *ret, char *intg, char *flt)
+{
+ ffi_type **ptr = &arg->elements[0];
+
+ while (*ptr != NULL)
+ {
+ if (off & ((*ptr)->alignment - 1))
+ off = ALIGN(off, (*ptr)->alignment);
+
+ switch ((*ptr)->type)
+ {
+ case FFI_TYPE_STRUCT:
+ off = ffi_v9_layout_struct(*ptr, off, ret, intg, flt);
+ off = ALIGN(off, FFI_SIZEOF_ARG);
+ break;
+ case FFI_TYPE_FLOAT:
+ case FFI_TYPE_DOUBLE:
+#if FFI_TYPE_LONGDOUBLE != FFI_TYPE_DOUBLE
+ case FFI_TYPE_LONGDOUBLE:
+#endif
+ memmove(ret + off, flt + off, (*ptr)->size);
+ off += (*ptr)->size;
+ break;
+ default:
+ memmove(ret + off, intg + off, (*ptr)->size);
+ off += (*ptr)->size;
+ break;
+ }
+ ptr++;
+ }
+ return off;
+}
+
+
+#ifdef SPARC64
+extern int ffi_call_v9(void *, extended_cif *, unsigned,
+ unsigned, unsigned *, void (*fn)(void));
+#else
+extern int ffi_call_v8(void *, extended_cif *, unsigned,
+ unsigned, unsigned *, void (*fn)(void));
+#endif
+
+#ifndef __GNUC__
+void ffi_flush_icache (void *, size_t);
+#endif
+
+void ffi_call(ffi_cif *cif, void (*fn)(void), void *rvalue, void **avalue)
+{
+ extended_cif ecif;
+ void *rval = rvalue;
+
+ ecif.cif = cif;
+ ecif.avalue = avalue;
+
+ /* If the return value is a struct and we don't have a return */
+ /* value address then we need to make one */
+
+ ecif.rvalue = rvalue;
+ if (cif->rtype->type == FFI_TYPE_STRUCT)
+ {
+ if (cif->rtype->size <= 32)
+ rval = alloca(64);
+ else
+ {
+ rval = NULL;
+ if (rvalue == NULL)
+ ecif.rvalue = alloca(cif->rtype->size);
+ }
+ }
+
+ switch (cif->abi)
+ {
+ case FFI_V8:
+#ifdef SPARC64
+ /* We don't yet support calling 32bit code from 64bit */
+ FFI_ASSERT(0);
+#else
+ if (rvalue && (cif->rtype->type == FFI_TYPE_STRUCT
+#if FFI_TYPE_LONGDOUBLE != FFI_TYPE_DOUBLE
+ || cif->flags == FFI_TYPE_LONGDOUBLE
+#endif
+ ))
+ {
+ /* For v8, we need an "unimp" with size of returning struct */
+ /* behind "call", so we alloc some executable space for it. */
+ /* l7 is used, we need to make sure v8.S doesn't use %l7. */
+ unsigned int *call_struct = NULL;
+ ffi_closure_alloc(32, (void **)&call_struct);
+ if (call_struct)
+ {
+ unsigned long f = (unsigned long)fn;
+ call_struct[0] = 0xae10001f; /* mov %i7, %l7 */
+ call_struct[1] = 0xbe10000f; /* mov %o7, %i7 */
+ call_struct[2] = 0x03000000 | f >> 10; /* sethi %hi(fn), %g1 */
+ call_struct[3] = 0x9fc06000 | (f & 0x3ff); /* jmp %g1+%lo(fn), %o7 */
+ call_struct[4] = 0x01000000; /* nop */
+ if (cif->rtype->size < 0x7f)
+ call_struct[5] = cif->rtype->size; /* unimp */
+ else
+ call_struct[5] = 0x01000000; /* nop */
+ call_struct[6] = 0x81c7e008; /* ret */
+ call_struct[7] = 0xbe100017; /* mov %l7, %i7 */
+#ifdef __GNUC__
+ asm volatile ("iflush %0; iflush %0+8; iflush %0+16; iflush %0+24" : :
+ "r" (call_struct) : "memory");
+ /* SPARC v8 requires 5 instructions for flush to be visible */
+ asm volatile ("nop; nop; nop; nop; nop");
+#else
+ ffi_flush_icache (call_struct, 32);
+#endif
+ ffi_call_v8(ffi_prep_args_v8, &ecif, cif->bytes,
+ cif->flags, rvalue, call_struct);
+ ffi_closure_free(call_struct);
+ }
+ else
+ {
+ ffi_call_v8(ffi_prep_args_v8, &ecif, cif->bytes,
+ cif->flags, rvalue, fn);
+ }
+ }
+ else
+ {
+ ffi_call_v8(ffi_prep_args_v8, &ecif, cif->bytes,
+ cif->flags, rvalue, fn);
+ }
+#endif
+ break;
+ case FFI_V9:
+#ifdef SPARC64
+ ffi_call_v9(ffi_prep_args_v9, &ecif, cif->bytes,
+ cif->flags, rval, fn);
+ if (rvalue && rval && cif->rtype->type == FFI_TYPE_STRUCT)
+ ffi_v9_layout_struct(cif->rtype, 0, (char *)rvalue, (char *)rval, ((char *)rval)+32);
+#else
+ /* And vice versa */
+ FFI_ASSERT(0);
+#endif
+ break;
+ default:
+ FFI_ASSERT(0);
+ break;
+ }
+}
+
+
+#ifdef SPARC64
+extern void ffi_closure_v9(void);
+#else
+extern void ffi_closure_v8(void);
+#endif
+
+ffi_status
+ffi_prep_closure_loc (ffi_closure* closure,
+ ffi_cif* cif,
+ void (*fun)(ffi_cif*, void*, void**, void*),
+ void *user_data,
+ void *codeloc)
+{
+ unsigned int *tramp = (unsigned int *) &closure->tramp[0];
+ unsigned long fn;
+#ifdef SPARC64
+ /* Trampoline address is equal to the closure address. We take advantage
+ of that to reduce the trampoline size by 8 bytes. */
+ if (cif->abi != FFI_V9)
+ return FFI_BAD_ABI;
+ fn = (unsigned long) ffi_closure_v9;
+ tramp[0] = 0x83414000; /* rd %pc, %g1 */
+ tramp[1] = 0xca586010; /* ldx [%g1+16], %g5 */
+ tramp[2] = 0x81c14000; /* jmp %g5 */
+ tramp[3] = 0x01000000; /* nop */
+ *((unsigned long *) &tramp[4]) = fn;
+#else
+ unsigned long ctx = (unsigned long) codeloc;
+ if (cif->abi != FFI_V8)
+ return FFI_BAD_ABI;
+ fn = (unsigned long) ffi_closure_v8;
+ tramp[0] = 0x03000000 | fn >> 10; /* sethi %hi(fn), %g1 */
+ tramp[1] = 0x05000000 | ctx >> 10; /* sethi %hi(ctx), %g2 */
+ tramp[2] = 0x81c06000 | (fn & 0x3ff); /* jmp %g1+%lo(fn) */
+ tramp[3] = 0x8410a000 | (ctx & 0x3ff);/* or %g2, %lo(ctx) */
+#endif
+
+ closure->cif = cif;
+ closure->fun = fun;
+ closure->user_data = user_data;
+
+ /* Flush the Icache. closure is 8 bytes aligned. */
+#ifdef __GNUC__
+#ifdef SPARC64
+ asm volatile ("flush %0; flush %0+8" : : "r" (closure) : "memory");
+#else
+ asm volatile ("iflush %0; iflush %0+8" : : "r" (closure) : "memory");
+ /* SPARC v8 requires 5 instructions for flush to be visible */
+ asm volatile ("nop; nop; nop; nop; nop");
+#endif
+#else
+ ffi_flush_icache (closure, 16);
+#endif
+
+ return FFI_OK;
+}
+
+int
+ffi_closure_sparc_inner_v8(ffi_closure *closure,
+ void *rvalue, unsigned long *gpr, unsigned long *scratch)
+{
+ ffi_cif *cif;
+ ffi_type **arg_types;
+ void **avalue;
+ int i, argn;
+
+ cif = closure->cif;
+ arg_types = cif->arg_types;
+ avalue = alloca(cif->nargs * sizeof(void *));
+
+ /* Copy the caller's structure return address so that the closure
+ returns the data directly to the caller. */
+ if (cif->flags == FFI_TYPE_STRUCT
+#if FFI_TYPE_LONGDOUBLE != FFI_TYPE_DOUBLE
+ || cif->flags == FFI_TYPE_LONGDOUBLE
+#endif
+ )
+ rvalue = (void *) gpr[0];
+
+ /* Always skip the structure return address. */
+ argn = 1;
+
+ /* Grab the addresses of the arguments from the stack frame. */
+ for (i = 0; i < cif->nargs; i++)
+ {
+ if (arg_types[i]->type == FFI_TYPE_STRUCT
+#if FFI_TYPE_LONGDOUBLE != FFI_TYPE_DOUBLE
+ || arg_types[i]->type == FFI_TYPE_LONGDOUBLE
+#endif
+ )
+ {
+ /* Straight copy of invisible reference. */
+ avalue[i] = (void *)gpr[argn++];
+ }
+ else if ((arg_types[i]->type == FFI_TYPE_DOUBLE
+ || arg_types[i]->type == FFI_TYPE_SINT64
+ || arg_types[i]->type == FFI_TYPE_UINT64)
+ /* gpr is 8-byte aligned. */
+ && (argn % 2) != 0)
+ {
+ /* Align on a 8-byte boundary. */
+ scratch[0] = gpr[argn];
+ scratch[1] = gpr[argn+1];
+ avalue[i] = scratch;
+ scratch -= 2;
+ argn += 2;
+ }
+ else
+ {
+ /* Always right-justify. */
+ argn += ALIGN(arg_types[i]->size, FFI_SIZEOF_ARG) / FFI_SIZEOF_ARG;
+ avalue[i] = ((char *) &gpr[argn]) - arg_types[i]->size;
+ }
+ }
+
+ /* Invoke the closure. */
+ (closure->fun) (cif, rvalue, avalue, closure->user_data);
+
+ /* Tell ffi_closure_sparc how to perform return type promotions. */
+ return cif->rtype->type;
+}
+
+int
+ffi_closure_sparc_inner_v9(ffi_closure *closure,
+ void *rvalue, unsigned long *gpr, double *fpr)
+{
+ ffi_cif *cif;
+ ffi_type **arg_types;
+ void **avalue;
+ int i, argn, fp_slot_max;
+
+ cif = closure->cif;
+ arg_types = cif->arg_types;
+ avalue = alloca(cif->nargs * sizeof(void *));
+
+ /* Copy the caller's structure return address so that the closure
+ returns the data directly to the caller. */
+ if (cif->flags == FFI_TYPE_VOID
+ && cif->rtype->type == FFI_TYPE_STRUCT)
+ {
+ rvalue = (void *) gpr[0];
+ /* Skip the structure return address. */
+ argn = 1;
+ }
+ else
+ argn = 0;
+
+ fp_slot_max = 16 - argn;
+
+ /* Grab the addresses of the arguments from the stack frame. */
+ for (i = 0; i < cif->nargs; i++)
+ {
+ if (arg_types[i]->type == FFI_TYPE_STRUCT)
+ {
+ if (arg_types[i]->size > 16)
+ {
+ /* Straight copy of invisible reference. */
+ avalue[i] = (void *)gpr[argn++];
+ }
+ else
+ {
+ /* Left-justify. */
+ ffi_v9_layout_struct(arg_types[i],
+ 0,
+ (char *) &gpr[argn],
+ (char *) &gpr[argn],
+ (char *) &fpr[argn]);
+ avalue[i] = &gpr[argn];
+ argn += ALIGN(arg_types[i]->size, FFI_SIZEOF_ARG) / FFI_SIZEOF_ARG;
+ }
+ }
+ else
+ {
+ /* Right-justify. */
+ argn += ALIGN(arg_types[i]->size, FFI_SIZEOF_ARG) / FFI_SIZEOF_ARG;
+
+ /* Align on a 16-byte boundary. */
+#if FFI_TYPE_LONGDOUBLE != FFI_TYPE_DOUBLE
+ if (arg_types[i]->type == FFI_TYPE_LONGDOUBLE && (argn % 2) != 0)
+ argn++;
+#endif
+ if (i < fp_slot_max
+ && (arg_types[i]->type == FFI_TYPE_FLOAT
+ || arg_types[i]->type == FFI_TYPE_DOUBLE
+#if FFI_TYPE_LONGDOUBLE != FFI_TYPE_DOUBLE
+ || arg_types[i]->type == FFI_TYPE_LONGDOUBLE
+#endif
+ ))
+ avalue[i] = ((char *) &fpr[argn]) - arg_types[i]->size;
+ else
+ avalue[i] = ((char *) &gpr[argn]) - arg_types[i]->size;
+ }
+ }
+
+ /* Invoke the closure. */
+ (closure->fun) (cif, rvalue, avalue, closure->user_data);
+
+ /* Tell ffi_closure_sparc how to perform return type promotions. */
+ return cif->rtype->type;
+}
diff --git a/jni/ruby/ext/fiddle/libffi-3.2.1/src/sparc/ffitarget.h b/jni/ruby/ext/fiddle/libffi-3.2.1/src/sparc/ffitarget.h
new file mode 100644
index 0000000..d89f787
--- /dev/null
+++ b/jni/ruby/ext/fiddle/libffi-3.2.1/src/sparc/ffitarget.h
@@ -0,0 +1,73 @@
+/* -----------------------------------------------------------------*-C-*-
+ ffitarget.h - Copyright (c) 2012 Anthony Green
+ Copyright (c) 1996-2003 Red Hat, Inc.
+ Target configuration macros for SPARC.
+
+ Permission is hereby granted, free of charge, to any person obtaining
+ a copy of this software and associated documentation files (the
+ ``Software''), to deal in the Software without restriction, including
+ without limitation the rights to use, copy, modify, merge, publish,
+ distribute, sublicense, and/or sell copies of the Software, and to
+ permit persons to whom the Software is furnished to do so, subject to
+ the following conditions:
+
+ The above copyright notice and this permission notice shall be included
+ in all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND,
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+ HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ DEALINGS IN THE SOFTWARE.
+
+ ----------------------------------------------------------------------- */
+
+#ifndef LIBFFI_TARGET_H
+#define LIBFFI_TARGET_H
+
+#ifndef LIBFFI_H
+#error "Please do not include ffitarget.h directly into your source. Use ffi.h instead."
+#endif
+
+/* ---- System specific configurations ----------------------------------- */
+
+#if defined(__arch64__) || defined(__sparcv9)
+#ifndef SPARC64
+#define SPARC64
+#endif
+#endif
+
+#ifndef LIBFFI_ASM
+typedef unsigned long ffi_arg;
+typedef signed long ffi_sarg;
+
+typedef enum ffi_abi {
+ FFI_FIRST_ABI = 0,
+ FFI_V8,
+ FFI_V8PLUS,
+ FFI_V9,
+ FFI_LAST_ABI,
+#ifdef SPARC64
+ FFI_DEFAULT_ABI = FFI_V9
+#else
+ FFI_DEFAULT_ABI = FFI_V8
+#endif
+} ffi_abi;
+#endif
+
+/* ---- Definitions for closures ----------------------------------------- */
+
+#define FFI_CLOSURES 1
+#define FFI_NATIVE_RAW_API 0
+
+#ifdef SPARC64
+#define FFI_TRAMPOLINE_SIZE 24
+#else
+#define FFI_TRAMPOLINE_SIZE 16
+#endif
+
+#endif
+
diff --git a/jni/ruby/ext/fiddle/libffi-3.2.1/src/sparc/v8.S b/jni/ruby/ext/fiddle/libffi-3.2.1/src/sparc/v8.S
new file mode 100644
index 0000000..6bf7ac0
--- /dev/null
+++ b/jni/ruby/ext/fiddle/libffi-3.2.1/src/sparc/v8.S
@@ -0,0 +1,346 @@
+/* -----------------------------------------------------------------------
+ v8.S - Copyright (c) 2013 The Written Word, Inc.
+ Copyright (c) 1996, 1997, 2003, 2004, 2008 Red Hat, Inc.
+
+ SPARC Foreign Function Interface
+
+ Permission is hereby granted, free of charge, to any person obtaining
+ a copy of this software and associated documentation files (the
+ ``Software''), to deal in the Software without restriction, including
+ without limitation the rights to use, copy, modify, merge, publish,
+ distribute, sublicense, and/or sell copies of the Software, and to
+ permit persons to whom the Software is furnished to do so, subject to
+ the following conditions:
+
+ The above copyright notice and this permission notice shall be included
+ in all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND,
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+ HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ DEALINGS IN THE SOFTWARE.
+ ----------------------------------------------------------------------- */
+
+#define LIBFFI_ASM
+#include <fficonfig.h>
+#include <ffi.h>
+
+#define STACKFRAME 96 /* Minimum stack framesize for SPARC */
+#define ARGS (64+4) /* Offset of register area in frame */
+
+#ifndef __GNUC__
+ .text
+ .align 8
+.globl ffi_flush_icache
+.globl _ffi_flush_icache
+
+ffi_flush_icache:
+_ffi_flush_icache:
+ add %o0, %o1, %o2
+#ifdef SPARC64
+1: flush %o0
+#else
+1: iflush %o0
+#endif
+ add %o0, 8, %o0
+ cmp %o0, %o2
+ blt 1b
+ nop
+ nop
+ nop
+ nop
+ nop
+ retl
+ nop
+.ffi_flush_icache_end:
+ .size ffi_flush_icache,.ffi_flush_icache_end-ffi_flush_icache
+#endif
+
+ .text
+ .align 8
+.globl ffi_call_v8
+.globl _ffi_call_v8
+
+ffi_call_v8:
+_ffi_call_v8:
+.LLFB1:
+ save %sp, -STACKFRAME, %sp
+.LLCFI0:
+
+ sub %sp, %i2, %sp ! alloca() space in stack for frame to set up
+ add %sp, STACKFRAME, %l0 ! %l0 has start of
+ ! frame to set up
+
+ mov %l0, %o0 ! call routine to set up frame
+ call %i0
+ mov %i1, %o1 ! (delay)
+
+ ld [%l0+ARGS], %o0 ! call foreign function
+ ld [%l0+ARGS+4], %o1
+ ld [%l0+ARGS+8], %o2
+ ld [%l0+ARGS+12], %o3
+ ld [%l0+ARGS+16], %o4
+ ld [%l0+ARGS+20], %o5
+ call %i5
+ mov %l0, %sp ! (delay) switch to frame
+ nop ! STRUCT returning functions skip 12 instead of 8 bytes
+
+ ! If the return value pointer is NULL, assume no return value.
+ tst %i4
+ bz done
+ nop
+
+ cmp %i3, FFI_TYPE_INT
+ be,a done
+ st %o0, [%i4] ! (delay)
+
+ cmp %i3, FFI_TYPE_FLOAT
+ be,a done
+ st %f0, [%i4+0] ! (delay)
+
+ cmp %i3, FFI_TYPE_DOUBLE
+ be,a double
+ st %f0, [%i4+0] ! (delay)
+
+ cmp %i3, FFI_TYPE_SINT8
+ be,a sint8
+ sll %o0, 24, %o0 ! (delay)
+
+ cmp %i3, FFI_TYPE_UINT8
+ be,a uint8
+ sll %o0, 24, %o0 ! (delay)
+
+ cmp %i3, FFI_TYPE_SINT16
+ be,a sint16
+ sll %o0, 16, %o0 ! (delay)
+
+ cmp %i3, FFI_TYPE_UINT16
+ be,a uint16
+ sll %o0, 16, %o0 ! (delay)
+
+ cmp %i3, FFI_TYPE_SINT64
+ be,a longlong
+ st %o0, [%i4+0] ! (delay)
+done:
+ ret
+ restore
+
+double:
+ st %f1, [%i4+4]
+ ret
+ restore
+
+sint8:
+ sra %o0, 24, %o0
+ st %o0, [%i4+0]
+ ret
+ restore
+
+uint8:
+ srl %o0, 24, %o0
+ st %o0, [%i4+0]
+ ret
+ restore
+
+sint16:
+ sra %o0, 16, %o0
+ st %o0, [%i4+0]
+ ret
+ restore
+
+uint16:
+ srl %o0, 16, %o0
+ st %o0, [%i4+0]
+ ret
+ restore
+
+longlong:
+ st %o1, [%i4+4]
+ ret
+ restore
+.LLFE1:
+
+.ffi_call_v8_end:
+ .size ffi_call_v8,.ffi_call_v8_end-ffi_call_v8
+
+
+#undef STACKFRAME
+#define STACKFRAME 104 /* 16*4 register window +
+ 1*4 struct return +
+ 6*4 args backing store +
+ 3*4 locals */
+
+/* ffi_closure_v8(...)
+
+ Receives the closure argument in %g2. */
+
+ .text
+ .align 8
+ .globl ffi_closure_v8
+
+ffi_closure_v8:
+#ifdef HAVE_AS_REGISTER_PSEUDO_OP
+ .register %g2, #scratch
+#endif
+.LLFB2:
+ ! Reserve frame space for all arguments in case
+ ! we need to align them on a 8-byte boundary.
+ ld [%g2+FFI_TRAMPOLINE_SIZE], %g1
+ ld [%g1+4], %g1
+ sll %g1, 3, %g1
+ add %g1, STACKFRAME, %g1
+ ! %g1 == STACKFRAME + 8*nargs
+ neg %g1
+ save %sp, %g1, %sp
+.LLCFI1:
+
+ ! Store all of the potential argument registers in va_list format.
+ st %i0, [%fp+68+0]
+ st %i1, [%fp+68+4]
+ st %i2, [%fp+68+8]
+ st %i3, [%fp+68+12]
+ st %i4, [%fp+68+16]
+ st %i5, [%fp+68+20]
+
+ ! Call ffi_closure_sparc_inner to do the bulk of the work.
+ mov %g2, %o0
+ add %fp, -8, %o1
+ add %fp, 64, %o2
+ call ffi_closure_sparc_inner_v8
+ add %fp, -16, %o3
+
+ ! Load up the return value in the proper type.
+ ! See ffi_prep_cif_machdep for the list of cases.
+ cmp %o0, FFI_TYPE_VOID
+ be done1
+
+ cmp %o0, FFI_TYPE_INT
+ be done1
+ ld [%fp-8], %i0
+
+ cmp %o0, FFI_TYPE_FLOAT
+ be,a done1
+ ld [%fp-8], %f0
+
+ cmp %o0, FFI_TYPE_DOUBLE
+ be,a done1
+ ldd [%fp-8], %f0
+
+#if FFI_TYPE_LONGDOUBLE != FFI_TYPE_DOUBLE
+ cmp %o0, FFI_TYPE_LONGDOUBLE
+ be done2
+#endif
+
+ cmp %o0, FFI_TYPE_STRUCT
+ be done2
+
+ cmp %o0, FFI_TYPE_SINT64
+ be,a done1
+ ldd [%fp-8], %i0
+
+ cmp %o0, FFI_TYPE_UINT64
+ be,a done1
+ ldd [%fp-8], %i0
+
+ ld [%fp-8], %i0
+done1:
+ jmp %i7+8
+ restore
+done2:
+ ! Skip 'unimp'.
+ jmp %i7+12
+ restore
+.LLFE2:
+
+.ffi_closure_v8_end:
+ .size ffi_closure_v8,.ffi_closure_v8_end-ffi_closure_v8
+
+#ifdef SPARC64
+#define WS 8
+#define nword xword
+#define uanword uaxword
+#else
+#define WS 4
+#define nword long
+#define uanword uaword
+#endif
+
+#ifdef HAVE_RO_EH_FRAME
+ .section ".eh_frame",#alloc
+#else
+ .section ".eh_frame",#alloc,#write
+#endif
+.LLframe1:
+ .uaword .LLECIE1-.LLSCIE1 ! Length of Common Information Entry
+.LLSCIE1:
+ .uaword 0x0 ! CIE Identifier Tag
+ .byte 0x1 ! CIE Version
+ .ascii "zR\0" ! CIE Augmentation
+ .byte 0x1 ! uleb128 0x1; CIE Code Alignment Factor
+ .byte 0x80-WS ! sleb128 -WS; CIE Data Alignment Factor
+ .byte 0xf ! CIE RA Column
+ .byte 0x1 ! uleb128 0x1; Augmentation size
+#ifdef HAVE_AS_SPARC_UA_PCREL
+ .byte 0x1b ! FDE Encoding (pcrel sdata4)
+#else
+ .byte 0x50 ! FDE Encoding (aligned absolute)
+#endif
+ .byte 0xc ! DW_CFA_def_cfa
+ .byte 0xe ! uleb128 0xe
+ .byte 0x0 ! uleb128 0x0
+ .align WS
+.LLECIE1:
+.LLSFDE1:
+ .uaword .LLEFDE1-.LLASFDE1 ! FDE Length
+.LLASFDE1:
+ .uaword .LLASFDE1-.LLframe1 ! FDE CIE offset
+#ifdef HAVE_AS_SPARC_UA_PCREL
+ .uaword %r_disp32(.LLFB1)
+ .uaword .LLFE1-.LLFB1 ! FDE address range
+#else
+ .align WS
+ .nword .LLFB1
+ .uanword .LLFE1-.LLFB1 ! FDE address range
+#endif
+ .byte 0x0 ! uleb128 0x0; Augmentation size
+ .byte 0x4 ! DW_CFA_advance_loc4
+ .uaword .LLCFI0-.LLFB1
+ .byte 0xd ! DW_CFA_def_cfa_register
+ .byte 0x1e ! uleb128 0x1e
+ .byte 0x2d ! DW_CFA_GNU_window_save
+ .byte 0x9 ! DW_CFA_register
+ .byte 0xf ! uleb128 0xf
+ .byte 0x1f ! uleb128 0x1f
+ .align WS
+.LLEFDE1:
+.LLSFDE2:
+ .uaword .LLEFDE2-.LLASFDE2 ! FDE Length
+.LLASFDE2:
+ .uaword .LLASFDE2-.LLframe1 ! FDE CIE offset
+#ifdef HAVE_AS_SPARC_UA_PCREL
+ .uaword %r_disp32(.LLFB2)
+ .uaword .LLFE2-.LLFB2 ! FDE address range
+#else
+ .align WS
+ .nword .LLFB2
+ .uanword .LLFE2-.LLFB2 ! FDE address range
+#endif
+ .byte 0x0 ! uleb128 0x0; Augmentation size
+ .byte 0x4 ! DW_CFA_advance_loc4
+ .uaword .LLCFI1-.LLFB2
+ .byte 0xd ! DW_CFA_def_cfa_register
+ .byte 0x1e ! uleb128 0x1e
+ .byte 0x2d ! DW_CFA_GNU_window_save
+ .byte 0x9 ! DW_CFA_register
+ .byte 0xf ! uleb128 0xf
+ .byte 0x1f ! uleb128 0x1f
+ .align WS
+.LLEFDE2:
+
+#if defined __ELF__ && defined __linux__
+ .section .note.GNU-stack,"",@progbits
+#endif
diff --git a/jni/ruby/ext/fiddle/libffi-3.2.1/src/sparc/v9.S b/jni/ruby/ext/fiddle/libffi-3.2.1/src/sparc/v9.S
new file mode 100644
index 0000000..bf31a2b
--- /dev/null
+++ b/jni/ruby/ext/fiddle/libffi-3.2.1/src/sparc/v9.S
@@ -0,0 +1,307 @@
+/* -----------------------------------------------------------------------
+ v9.S - Copyright (c) 2000, 2003, 2004, 2008 Red Hat, Inc.
+
+ SPARC 64-bit Foreign Function Interface
+
+ Permission is hereby granted, free of charge, to any person obtaining
+ a copy of this software and associated documentation files (the
+ ``Software''), to deal in the Software without restriction, including
+ without limitation the rights to use, copy, modify, merge, publish,
+ distribute, sublicense, and/or sell copies of the Software, and to
+ permit persons to whom the Software is furnished to do so, subject to
+ the following conditions:
+
+ The above copyright notice and this permission notice shall be included
+ in all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND,
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+ HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ DEALINGS IN THE SOFTWARE.
+ ----------------------------------------------------------------------- */
+
+#define LIBFFI_ASM
+#include <fficonfig.h>
+#include <ffi.h>
+
+#ifdef SPARC64
+/* Only compile this in for 64bit builds, because otherwise the object file
+ will have inproper architecture due to used instructions. */
+
+#define STACKFRAME 176 /* Minimum stack framesize for SPARC 64-bit */
+#define STACK_BIAS 2047
+#define ARGS (128) /* Offset of register area in frame */
+
+.text
+ .align 8
+.globl ffi_call_v9
+.globl _ffi_call_v9
+
+ffi_call_v9:
+_ffi_call_v9:
+.LLFB1:
+ save %sp, -STACKFRAME, %sp
+.LLCFI0:
+
+ sub %sp, %i2, %sp ! alloca() space in stack for frame to set up
+ add %sp, STACKFRAME+STACK_BIAS, %l0 ! %l0 has start of
+ ! frame to set up
+
+ mov %l0, %o0 ! call routine to set up frame
+ call %i0
+ mov %i1, %o1 ! (delay)
+ brz,pt %o0, 1f
+ ldx [%l0+ARGS], %o0 ! call foreign function
+
+ ldd [%l0+ARGS], %f0
+ ldd [%l0+ARGS+8], %f2
+ ldd [%l0+ARGS+16], %f4
+ ldd [%l0+ARGS+24], %f6
+ ldd [%l0+ARGS+32], %f8
+ ldd [%l0+ARGS+40], %f10
+ ldd [%l0+ARGS+48], %f12
+ ldd [%l0+ARGS+56], %f14
+ ldd [%l0+ARGS+64], %f16
+ ldd [%l0+ARGS+72], %f18
+ ldd [%l0+ARGS+80], %f20
+ ldd [%l0+ARGS+88], %f22
+ ldd [%l0+ARGS+96], %f24
+ ldd [%l0+ARGS+104], %f26
+ ldd [%l0+ARGS+112], %f28
+ ldd [%l0+ARGS+120], %f30
+
+1: ldx [%l0+ARGS+8], %o1
+ ldx [%l0+ARGS+16], %o2
+ ldx [%l0+ARGS+24], %o3
+ ldx [%l0+ARGS+32], %o4
+ ldx [%l0+ARGS+40], %o5
+ call %i5
+ sub %l0, STACK_BIAS, %sp ! (delay) switch to frame
+
+ ! If the return value pointer is NULL, assume no return value.
+ brz,pn %i4, done
+ nop
+
+ cmp %i3, FFI_TYPE_INT
+ be,a,pt %icc, done
+ stx %o0, [%i4+0] ! (delay)
+
+ cmp %i3, FFI_TYPE_FLOAT
+ be,a,pn %icc, done
+ st %f0, [%i4+0] ! (delay)
+
+ cmp %i3, FFI_TYPE_DOUBLE
+ be,a,pn %icc, done
+ std %f0, [%i4+0] ! (delay)
+
+ cmp %i3, FFI_TYPE_STRUCT
+ be,pn %icc, dostruct
+
+ cmp %i3, FFI_TYPE_LONGDOUBLE
+ bne,pt %icc, done
+ nop
+ std %f0, [%i4+0]
+ std %f2, [%i4+8]
+
+done: ret
+ restore
+
+dostruct:
+ /* This will not work correctly for unions. */
+ stx %o0, [%i4+0]
+ stx %o1, [%i4+8]
+ stx %o2, [%i4+16]
+ stx %o3, [%i4+24]
+ std %f0, [%i4+32]
+ std %f2, [%i4+40]
+ std %f4, [%i4+48]
+ std %f6, [%i4+56]
+ ret
+ restore
+.LLFE1:
+
+.ffi_call_v9_end:
+ .size ffi_call_v9,.ffi_call_v9_end-ffi_call_v9
+
+
+#undef STACKFRAME
+#define STACKFRAME 336 /* 16*8 register window +
+ 6*8 args backing store +
+ 20*8 locals */
+#define FP %fp+STACK_BIAS
+
+/* ffi_closure_v9(...)
+
+ Receives the closure argument in %g1. */
+
+ .text
+ .align 8
+ .globl ffi_closure_v9
+
+ffi_closure_v9:
+.LLFB2:
+ save %sp, -STACKFRAME, %sp
+.LLCFI1:
+
+ ! Store all of the potential argument registers in va_list format.
+ stx %i0, [FP+128+0]
+ stx %i1, [FP+128+8]
+ stx %i2, [FP+128+16]
+ stx %i3, [FP+128+24]
+ stx %i4, [FP+128+32]
+ stx %i5, [FP+128+40]
+
+ ! Store possible floating point argument registers too.
+ std %f0, [FP-128]
+ std %f2, [FP-120]
+ std %f4, [FP-112]
+ std %f6, [FP-104]
+ std %f8, [FP-96]
+ std %f10, [FP-88]
+ std %f12, [FP-80]
+ std %f14, [FP-72]
+ std %f16, [FP-64]
+ std %f18, [FP-56]
+ std %f20, [FP-48]
+ std %f22, [FP-40]
+ std %f24, [FP-32]
+ std %f26, [FP-24]
+ std %f28, [FP-16]
+ std %f30, [FP-8]
+
+ ! Call ffi_closure_sparc_inner to do the bulk of the work.
+ mov %g1, %o0
+ add %fp, STACK_BIAS-160, %o1
+ add %fp, STACK_BIAS+128, %o2
+ call ffi_closure_sparc_inner_v9
+ add %fp, STACK_BIAS-128, %o3
+
+ ! Load up the return value in the proper type.
+ ! See ffi_prep_cif_machdep for the list of cases.
+ cmp %o0, FFI_TYPE_VOID
+ be,pn %icc, done1
+
+ cmp %o0, FFI_TYPE_INT
+ be,pn %icc, integer
+
+ cmp %o0, FFI_TYPE_FLOAT
+ be,a,pn %icc, done1
+ ld [FP-160], %f0
+
+ cmp %o0, FFI_TYPE_DOUBLE
+ be,a,pn %icc, done1
+ ldd [FP-160], %f0
+
+#if FFI_TYPE_LONGDOUBLE != FFI_TYPE_DOUBLE
+ cmp %o0, FFI_TYPE_LONGDOUBLE
+ be,a,pn %icc, longdouble1
+ ldd [FP-160], %f0
+#endif
+
+ ! FFI_TYPE_STRUCT
+ ldx [FP-152], %i1
+ ldx [FP-144], %i2
+ ldx [FP-136], %i3
+ ldd [FP-160], %f0
+ ldd [FP-152], %f2
+ ldd [FP-144], %f4
+ ldd [FP-136], %f6
+
+integer:
+ ldx [FP-160], %i0
+
+done1:
+ ret
+ restore
+
+#if FFI_TYPE_LONGDOUBLE != FFI_TYPE_DOUBLE
+longdouble1:
+ ldd [FP-152], %f2
+ ret
+ restore
+#endif
+.LLFE2:
+
+.ffi_closure_v9_end:
+ .size ffi_closure_v9,.ffi_closure_v9_end-ffi_closure_v9
+
+#ifdef HAVE_RO_EH_FRAME
+ .section ".eh_frame",#alloc
+#else
+ .section ".eh_frame",#alloc,#write
+#endif
+.LLframe1:
+ .uaword .LLECIE1-.LLSCIE1 ! Length of Common Information Entry
+.LLSCIE1:
+ .uaword 0x0 ! CIE Identifier Tag
+ .byte 0x1 ! CIE Version
+ .ascii "zR\0" ! CIE Augmentation
+ .byte 0x1 ! uleb128 0x1; CIE Code Alignment Factor
+ .byte 0x78 ! sleb128 -8; CIE Data Alignment Factor
+ .byte 0xf ! CIE RA Column
+ .byte 0x1 ! uleb128 0x1; Augmentation size
+#ifdef HAVE_AS_SPARC_UA_PCREL
+ .byte 0x1b ! FDE Encoding (pcrel sdata4)
+#else
+ .byte 0x50 ! FDE Encoding (aligned absolute)
+#endif
+ .byte 0xc ! DW_CFA_def_cfa
+ .byte 0xe ! uleb128 0xe
+ .byte 0xff,0xf ! uleb128 0x7ff
+ .align 8
+.LLECIE1:
+.LLSFDE1:
+ .uaword .LLEFDE1-.LLASFDE1 ! FDE Length
+.LLASFDE1:
+ .uaword .LLASFDE1-.LLframe1 ! FDE CIE offset
+#ifdef HAVE_AS_SPARC_UA_PCREL
+ .uaword %r_disp32(.LLFB1)
+ .uaword .LLFE1-.LLFB1 ! FDE address range
+#else
+ .align 8
+ .xword .LLFB1
+ .uaxword .LLFE1-.LLFB1 ! FDE address range
+#endif
+ .byte 0x0 ! uleb128 0x0; Augmentation size
+ .byte 0x4 ! DW_CFA_advance_loc4
+ .uaword .LLCFI0-.LLFB1
+ .byte 0xd ! DW_CFA_def_cfa_register
+ .byte 0x1e ! uleb128 0x1e
+ .byte 0x2d ! DW_CFA_GNU_window_save
+ .byte 0x9 ! DW_CFA_register
+ .byte 0xf ! uleb128 0xf
+ .byte 0x1f ! uleb128 0x1f
+ .align 8
+.LLEFDE1:
+.LLSFDE2:
+ .uaword .LLEFDE2-.LLASFDE2 ! FDE Length
+.LLASFDE2:
+ .uaword .LLASFDE2-.LLframe1 ! FDE CIE offset
+#ifdef HAVE_AS_SPARC_UA_PCREL
+ .uaword %r_disp32(.LLFB2)
+ .uaword .LLFE2-.LLFB2 ! FDE address range
+#else
+ .align 8
+ .xword .LLFB2
+ .uaxword .LLFE2-.LLFB2 ! FDE address range
+#endif
+ .byte 0x0 ! uleb128 0x0; Augmentation size
+ .byte 0x4 ! DW_CFA_advance_loc4
+ .uaword .LLCFI1-.LLFB2
+ .byte 0xd ! DW_CFA_def_cfa_register
+ .byte 0x1e ! uleb128 0x1e
+ .byte 0x2d ! DW_CFA_GNU_window_save
+ .byte 0x9 ! DW_CFA_register
+ .byte 0xf ! uleb128 0xf
+ .byte 0x1f ! uleb128 0x1f
+ .align 8
+.LLEFDE2:
+#endif
+
+#ifdef __linux__
+ .section .note.GNU-stack,"",@progbits
+#endif
diff --git a/jni/ruby/ext/fiddle/libffi-3.2.1/src/tile/ffi.c b/jni/ruby/ext/fiddle/libffi-3.2.1/src/tile/ffi.c
new file mode 100644
index 0000000..3a94469
--- /dev/null
+++ b/jni/ruby/ext/fiddle/libffi-3.2.1/src/tile/ffi.c
@@ -0,0 +1,355 @@
+/* -----------------------------------------------------------------------
+ ffi.c - Copyright (c) 2012 Tilera Corp.
+
+ TILE Foreign Function Interface
+
+ Permission is hereby granted, free of charge, to any person obtaining
+ a copy of this software and associated documentation files (the
+ ``Software''), to deal in the Software without restriction, including
+ without limitation the rights to use, copy, modify, merge, publish,
+ distribute, sublicense, and/or sell copies of the Software, and to
+ permit persons to whom the Software is furnished to do so, subject to
+ the following conditions:
+
+ The above copyright notice and this permission notice shall be included
+ in all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND,
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+ HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ DEALINGS IN THE SOFTWARE.
+ ----------------------------------------------------------------------- */
+
+#include <ffi.h>
+#include <ffi_common.h>
+#include <stdlib.h>
+#include <stdint.h>
+#include <unistd.h>
+#include <arch/abi.h>
+#include <arch/icache.h>
+#include <arch/opcode.h>
+
+
+/* The first 10 registers are used to pass arguments and return values. */
+#define NUM_ARG_REGS 10
+
+/* Performs a raw function call with the given NUM_ARG_REGS register arguments
+ and the specified additional stack arguments (if any). */
+extern void ffi_call_tile(ffi_sarg reg_args[NUM_ARG_REGS],
+ const ffi_sarg *stack_args,
+ size_t stack_args_bytes,
+ void (*fnaddr)(void))
+ FFI_HIDDEN;
+
+/* This handles the raw call from the closure stub, cleaning up the
+ parameters and delegating to ffi_closure_tile_inner. */
+extern void ffi_closure_tile(void) FFI_HIDDEN;
+
+
+ffi_status
+ffi_prep_cif_machdep(ffi_cif *cif)
+{
+ /* We always allocate room for all registers. Even if we don't
+ use them as parameters, they get returned in the same array
+ as struct return values so we need to make room. */
+ if (cif->bytes < NUM_ARG_REGS * FFI_SIZEOF_ARG)
+ cif->bytes = NUM_ARG_REGS * FFI_SIZEOF_ARG;
+
+ if (cif->rtype->size > NUM_ARG_REGS * FFI_SIZEOF_ARG)
+ cif->flags = FFI_TYPE_STRUCT;
+ else
+ cif->flags = FFI_TYPE_INT;
+
+ /* Nothing to do. */
+ return FFI_OK;
+}
+
+
+static long
+assign_to_ffi_arg(ffi_sarg *out, void *in, const ffi_type *type,
+ int write_to_reg)
+{
+ switch (type->type)
+ {
+ case FFI_TYPE_SINT8:
+ *out = *(SINT8 *)in;
+ return 1;
+
+ case FFI_TYPE_UINT8:
+ *out = *(UINT8 *)in;
+ return 1;
+
+ case FFI_TYPE_SINT16:
+ *out = *(SINT16 *)in;
+ return 1;
+
+ case FFI_TYPE_UINT16:
+ *out = *(UINT16 *)in;
+ return 1;
+
+ case FFI_TYPE_SINT32:
+ case FFI_TYPE_UINT32:
+#ifndef __LP64__
+ case FFI_TYPE_POINTER:
+#endif
+ /* Note that even unsigned 32-bit quantities are sign extended
+ on tilegx when stored in a register. */
+ *out = *(SINT32 *)in;
+ return 1;
+
+ case FFI_TYPE_FLOAT:
+#ifdef __tilegx__
+ if (write_to_reg)
+ {
+ /* Properly sign extend the value. */
+ union { float f; SINT32 s32; } val;
+ val.f = *(float *)in;
+ *out = val.s32;
+ }
+ else
+#endif
+ {
+ *(float *)out = *(float *)in;
+ }
+ return 1;
+
+ case FFI_TYPE_SINT64:
+ case FFI_TYPE_UINT64:
+ case FFI_TYPE_DOUBLE:
+#ifdef __LP64__
+ case FFI_TYPE_POINTER:
+#endif
+ *(UINT64 *)out = *(UINT64 *)in;
+ return sizeof(UINT64) / FFI_SIZEOF_ARG;
+
+ case FFI_TYPE_STRUCT:
+ memcpy(out, in, type->size);
+ return (type->size + FFI_SIZEOF_ARG - 1) / FFI_SIZEOF_ARG;
+
+ case FFI_TYPE_VOID:
+ /* Must be a return type. Nothing to do. */
+ return 0;
+
+ default:
+ FFI_ASSERT(0);
+ return -1;
+ }
+}
+
+
+void
+ffi_call(ffi_cif *cif, void (*fn)(void), void *rvalue, void **avalue)
+{
+ ffi_sarg * const arg_mem = alloca(cif->bytes);
+ ffi_sarg * const reg_args = arg_mem;
+ ffi_sarg * const stack_args = &reg_args[NUM_ARG_REGS];
+ ffi_sarg *argp = arg_mem;
+ ffi_type ** const arg_types = cif->arg_types;
+ const long num_args = cif->nargs;
+ long i;
+
+ if (cif->flags == FFI_TYPE_STRUCT)
+ {
+ /* Pass a hidden pointer to the return value. We make sure there
+ is scratch space for the callee to store the return value even if
+ our caller doesn't care about it. */
+ *argp++ = (intptr_t)(rvalue ? rvalue : alloca(cif->rtype->size));
+
+ /* No more work needed to return anything. */
+ rvalue = NULL;
+ }
+
+ for (i = 0; i < num_args; i++)
+ {
+ ffi_type *type = arg_types[i];
+ void * const arg_in = avalue[i];
+ ptrdiff_t arg_word = argp - arg_mem;
+
+#ifndef __tilegx__
+ /* Doubleword-aligned values are always in an even-number register
+ pair, or doubleword-aligned stack slot if out of registers. */
+ long align = arg_word & (type->alignment > FFI_SIZEOF_ARG);
+ argp += align;
+ arg_word += align;
+#endif
+
+ if (type->type == FFI_TYPE_STRUCT)
+ {
+ const size_t arg_size_in_words =
+ (type->size + FFI_SIZEOF_ARG - 1) / FFI_SIZEOF_ARG;
+
+ if (arg_word < NUM_ARG_REGS &&
+ arg_word + arg_size_in_words > NUM_ARG_REGS)
+ {
+ /* Args are not allowed to span registers and the stack. */
+ argp = stack_args;
+ }
+
+ memcpy(argp, arg_in, type->size);
+ argp += arg_size_in_words;
+ }
+ else
+ {
+ argp += assign_to_ffi_arg(argp, arg_in, arg_types[i], 1);
+ }
+ }
+
+ /* Actually do the call. */
+ ffi_call_tile(reg_args, stack_args,
+ cif->bytes - (NUM_ARG_REGS * FFI_SIZEOF_ARG), fn);
+
+ if (rvalue != NULL)
+ assign_to_ffi_arg(rvalue, reg_args, cif->rtype, 0);
+}
+
+
+/* Template code for closure. */
+extern const UINT64 ffi_template_tramp_tile[] FFI_HIDDEN;
+
+
+ffi_status
+ffi_prep_closure_loc (ffi_closure *closure,
+ ffi_cif *cif,
+ void (*fun)(ffi_cif*, void*, void**, void*),
+ void *user_data,
+ void *codeloc)
+{
+#ifdef __tilegx__
+ /* TILE-Gx */
+ SINT64 c;
+ SINT64 h;
+ int s;
+ UINT64 *out;
+
+ if (cif->abi != FFI_UNIX)
+ return FFI_BAD_ABI;
+
+ out = (UINT64 *)closure->tramp;
+
+ c = (intptr_t)closure;
+ h = (intptr_t)ffi_closure_tile;
+ s = 0;
+
+ /* Find the smallest shift count that doesn't lose information
+ (i.e. no need to explicitly insert high bits of the address that
+ are just the sign extension of the low bits). */
+ while ((c >> s) != (SINT16)(c >> s) || (h >> s) != (SINT16)(h >> s))
+ s += 16;
+
+#define OPS(a, b, shift) \
+ (create_Imm16_X0((a) >> (shift)) | create_Imm16_X1((b) >> (shift)))
+
+ /* Emit the moveli. */
+ *out++ = ffi_template_tramp_tile[0] | OPS(c, h, s);
+ for (s -= 16; s >= 0; s -= 16)
+ *out++ = ffi_template_tramp_tile[1] | OPS(c, h, s);
+
+#undef OPS
+
+ *out++ = ffi_template_tramp_tile[2];
+
+#else
+ /* TILEPro */
+ UINT64 *out;
+ intptr_t delta;
+
+ if (cif->abi != FFI_UNIX)
+ return FFI_BAD_ABI;
+
+ out = (UINT64 *)closure->tramp;
+ delta = (intptr_t)ffi_closure_tile - (intptr_t)codeloc;
+
+ *out++ = ffi_template_tramp_tile[0] | create_JOffLong_X1(delta >> 3);
+#endif
+
+ closure->cif = cif;
+ closure->fun = fun;
+ closure->user_data = user_data;
+
+ invalidate_icache(closure->tramp, (char *)out - closure->tramp,
+ getpagesize());
+
+ return FFI_OK;
+}
+
+
+/* This is called by the assembly wrapper for closures. This does
+ all of the work. On entry reg_args[0] holds the values the registers
+ had when the closure was invoked. On return reg_args[1] holds the register
+ values to be returned to the caller (many of which may be garbage). */
+void FFI_HIDDEN
+ffi_closure_tile_inner(ffi_closure *closure,
+ ffi_sarg reg_args[2][NUM_ARG_REGS],
+ ffi_sarg *stack_args)
+{
+ ffi_cif * const cif = closure->cif;
+ void ** const avalue = alloca(cif->nargs * sizeof(void *));
+ void *rvalue;
+ ffi_type ** const arg_types = cif->arg_types;
+ ffi_sarg * const reg_args_in = reg_args[0];
+ ffi_sarg * const reg_args_out = reg_args[1];
+ ffi_sarg * argp;
+ long i, arg_word, nargs = cif->nargs;
+ /* Use a union to guarantee proper alignment for double. */
+ union { ffi_sarg arg[NUM_ARG_REGS]; double d; UINT64 u64; } closure_ret;
+
+ /* Start out reading register arguments. */
+ argp = reg_args_in;
+
+ /* Copy the caller's structure return address to that the closure
+ returns the data directly to the caller. */
+ if (cif->flags == FFI_TYPE_STRUCT)
+ {
+ /* Return by reference via hidden pointer. */
+ rvalue = (void *)(intptr_t)*argp++;
+ arg_word = 1;
+ }
+ else
+ {
+ /* Return the value in registers. */
+ rvalue = &closure_ret;
+ arg_word = 0;
+ }
+
+ /* Grab the addresses of the arguments. */
+ for (i = 0; i < nargs; i++)
+ {
+ ffi_type * const type = arg_types[i];
+ const size_t arg_size_in_words =
+ (type->size + FFI_SIZEOF_ARG - 1) / FFI_SIZEOF_ARG;
+
+#ifndef __tilegx__
+ /* Doubleword-aligned values are always in an even-number register
+ pair, or doubleword-aligned stack slot if out of registers. */
+ long align = arg_word & (type->alignment > FFI_SIZEOF_ARG);
+ argp += align;
+ arg_word += align;
+#endif
+
+ if (arg_word == NUM_ARG_REGS ||
+ (arg_word < NUM_ARG_REGS &&
+ arg_word + arg_size_in_words > NUM_ARG_REGS))
+ {
+ /* Switch to reading arguments from the stack. */
+ argp = stack_args;
+ arg_word = NUM_ARG_REGS;
+ }
+
+ avalue[i] = argp;
+ argp += arg_size_in_words;
+ arg_word += arg_size_in_words;
+ }
+
+ /* Invoke the closure. */
+ closure->fun(cif, rvalue, avalue, closure->user_data);
+
+ if (cif->flags != FFI_TYPE_STRUCT)
+ {
+ /* Canonicalize for register representation. */
+ assign_to_ffi_arg(reg_args_out, &closure_ret, cif->rtype, 1);
+ }
+}
diff --git a/jni/ruby/ext/fiddle/libffi-3.2.1/src/tile/ffitarget.h b/jni/ruby/ext/fiddle/libffi-3.2.1/src/tile/ffitarget.h
new file mode 100644
index 0000000..679fb5d
--- /dev/null
+++ b/jni/ruby/ext/fiddle/libffi-3.2.1/src/tile/ffitarget.h
@@ -0,0 +1,65 @@
+/* -----------------------------------------------------------------*-C-*-
+ ffitarget.h - Copyright (c) 2012 Tilera Corp.
+ Target configuration macros for TILE.
+
+ Permission is hereby granted, free of charge, to any person obtaining
+ a copy of this software and associated documentation files (the
+ ``Software''), to deal in the Software without restriction, including
+ without limitation the rights to use, copy, modify, merge, publish,
+ distribute, sublicense, and/or sell copies of the Software, and to
+ permit persons to whom the Software is furnished to do so, subject to
+ the following conditions:
+
+ The above copyright notice and this permission notice shall be included
+ in all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND,
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+ HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ DEALINGS IN THE SOFTWARE.
+ ----------------------------------------------------------------------- */
+
+#ifndef LIBFFI_TARGET_H
+#define LIBFFI_TARGET_H
+
+#ifndef LIBFFI_H
+#error "Please do not include ffitarget.h directly into your source. Use ffi.h instead."
+#endif
+
+#ifndef LIBFFI_ASM
+
+#include <arch/abi.h>
+
+typedef uint_reg_t ffi_arg;
+typedef int_reg_t ffi_sarg;
+
+typedef enum ffi_abi {
+ FFI_FIRST_ABI = 0,
+ FFI_UNIX,
+ FFI_LAST_ABI,
+ FFI_DEFAULT_ABI = FFI_UNIX
+} ffi_abi;
+#endif
+
+/* ---- Definitions for closures ----------------------------------------- */
+#define FFI_CLOSURES 1
+
+#ifdef __tilegx__
+/* We always pass 8-byte values, even in -m32 mode. */
+# define FFI_SIZEOF_ARG 8
+# ifdef __LP64__
+# define FFI_TRAMPOLINE_SIZE (8 * 5) /* 5 bundles */
+# else
+# define FFI_TRAMPOLINE_SIZE (8 * 3) /* 3 bundles */
+# endif
+#else
+# define FFI_SIZEOF_ARG 4
+# define FFI_TRAMPOLINE_SIZE 8 /* 1 bundle */
+#endif
+#define FFI_NATIVE_RAW_API 0
+
+#endif
diff --git a/jni/ruby/ext/fiddle/libffi-3.2.1/src/tile/tile.S b/jni/ruby/ext/fiddle/libffi-3.2.1/src/tile/tile.S
new file mode 100644
index 0000000..d1f82cb
--- /dev/null
+++ b/jni/ruby/ext/fiddle/libffi-3.2.1/src/tile/tile.S
@@ -0,0 +1,360 @@
+/* -----------------------------------------------------------------------
+ tile.S - Copyright (c) 2011 Tilera Corp.
+
+ Tilera TILEPro and TILE-Gx Foreign Function Interface
+
+ Permission is hereby granted, free of charge, to any person obtaining
+ a copy of this software and associated documentation files (the
+ ``Software''), to deal in the Software without restriction, including
+ without limitation the rights to use, copy, modify, merge, publish,
+ distribute, sublicense, and/or sell copies of the Software, and to
+ permit persons to whom the Software is furnished to do so, subject to
+ the following conditions:
+
+ The above copyright notice and this permission notice shall be included
+ in all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND,
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+ HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ DEALINGS IN THE SOFTWARE.
+ ----------------------------------------------------------------------- */
+
+#define LIBFFI_ASM
+#include <fficonfig.h>
+#include <ffi.h>
+
+/* Number of bytes in a register. */
+#define REG_SIZE FFI_SIZEOF_ARG
+
+/* Number of bytes in stack linkage area for backtracing.
+
+ A note about the ABI: on entry to a procedure, sp points to a stack
+ slot where it must spill the return address if it's not a leaf.
+ REG_SIZE bytes beyond that is a slot owned by the caller which
+ contains the sp value that the caller had when it was originally
+ entered (i.e. the caller's frame pointer). */
+#define LINKAGE_SIZE (2 * REG_SIZE)
+
+/* The first 10 registers are used to pass arguments and return values. */
+#define NUM_ARG_REGS 10
+
+#ifdef __tilegx__
+#define SW st
+#define LW ld
+#define BGZT bgtzt
+#else
+#define SW sw
+#define LW lw
+#define BGZT bgzt
+#endif
+
+
+/* void ffi_call_tile (int_reg_t reg_args[NUM_ARG_REGS],
+ const int_reg_t *stack_args,
+ unsigned long stack_args_bytes,
+ void (*fnaddr)(void));
+
+ On entry, REG_ARGS contain the outgoing register values,
+ and STACK_ARGS contains STACK_ARG_BYTES of additional values
+ to be passed on the stack. If STACK_ARG_BYTES is zero, then
+ STACK_ARGS is ignored.
+
+ When the invoked function returns, the values of r0-r9 are
+ blindly stored back into REG_ARGS for the caller to examine. */
+
+ .section .text.ffi_call_tile, "ax", @progbits
+ .align 8
+ .globl ffi_call_tile
+ FFI_HIDDEN(ffi_call_tile)
+ffi_call_tile:
+
+/* Incoming arguments. */
+#define REG_ARGS r0
+#define INCOMING_STACK_ARGS r1
+#define STACK_ARG_BYTES r2
+#define ORIG_FNADDR r3
+
+/* Temporary values. */
+#define FRAME_SIZE r10
+#define TMP r11
+#define TMP2 r12
+#define OUTGOING_STACK_ARGS r13
+#define REG_ADDR_PTR r14
+#define RETURN_REG_ADDR r15
+#define FNADDR r16
+
+ .cfi_startproc
+ {
+ /* Save return address. */
+ SW sp, lr
+ .cfi_offset lr, 0
+ /* Prepare to spill incoming r52. */
+ addi TMP, sp, -REG_SIZE
+ /* Increase frame size to have room to spill r52 and REG_ARGS.
+ The +7 is to round up mod 8. */
+ addi FRAME_SIZE, STACK_ARG_BYTES, \
+ REG_SIZE + REG_SIZE + LINKAGE_SIZE + 7
+ }
+ {
+ /* Round stack frame size to a multiple of 8 to satisfy ABI. */
+ andi FRAME_SIZE, FRAME_SIZE, -8
+ /* Compute where to spill REG_ARGS value. */
+ addi TMP2, sp, -(REG_SIZE * 2)
+ }
+ {
+ /* Spill incoming r52. */
+ SW TMP, r52
+ .cfi_offset r52, -REG_SIZE
+ /* Set up our frame pointer. */
+ move r52, sp
+ .cfi_def_cfa_register r52
+ /* Push stack frame. */
+ sub sp, sp, FRAME_SIZE
+ }
+ {
+ /* Prepare to set up stack linkage. */
+ addi TMP, sp, REG_SIZE
+ /* Prepare to memcpy stack args. */
+ addi OUTGOING_STACK_ARGS, sp, LINKAGE_SIZE
+ /* Save REG_ARGS which we will need after we call the subroutine. */
+ SW TMP2, REG_ARGS
+ }
+ {
+ /* Set up linkage info to hold incoming stack pointer. */
+ SW TMP, r52
+ }
+ {
+ /* Skip stack args memcpy if we don't have any stack args (common). */
+ blezt STACK_ARG_BYTES, .Ldone_stack_args_memcpy
+ }
+
+.Lmemcpy_stack_args:
+ {
+ /* Load incoming argument from stack_args. */
+ LW TMP, INCOMING_STACK_ARGS
+ addi INCOMING_STACK_ARGS, INCOMING_STACK_ARGS, REG_SIZE
+ }
+ {
+ /* Store stack argument into outgoing stack argument area. */
+ SW OUTGOING_STACK_ARGS, TMP
+ addi OUTGOING_STACK_ARGS, OUTGOING_STACK_ARGS, REG_SIZE
+ addi STACK_ARG_BYTES, STACK_ARG_BYTES, -REG_SIZE
+ }
+ {
+ BGZT STACK_ARG_BYTES, .Lmemcpy_stack_args
+ }
+.Ldone_stack_args_memcpy:
+
+ {
+ /* Copy aside ORIG_FNADDR so we can overwrite its register. */
+ move FNADDR, ORIG_FNADDR
+ /* Prepare to load argument registers. */
+ addi REG_ADDR_PTR, r0, REG_SIZE
+ /* Load outgoing r0. */
+ LW r0, r0
+ }
+
+ /* Load up argument registers from the REG_ARGS array. */
+#define LOAD_REG(REG, PTR) \
+ { \
+ LW REG, PTR ; \
+ addi PTR, PTR, REG_SIZE \
+ }
+
+ LOAD_REG(r1, REG_ADDR_PTR)
+ LOAD_REG(r2, REG_ADDR_PTR)
+ LOAD_REG(r3, REG_ADDR_PTR)
+ LOAD_REG(r4, REG_ADDR_PTR)
+ LOAD_REG(r5, REG_ADDR_PTR)
+ LOAD_REG(r6, REG_ADDR_PTR)
+ LOAD_REG(r7, REG_ADDR_PTR)
+ LOAD_REG(r8, REG_ADDR_PTR)
+ LOAD_REG(r9, REG_ADDR_PTR)
+
+ {
+ /* Call the subroutine. */
+ jalr FNADDR
+ }
+
+ {
+ /* Restore original lr. */
+ LW lr, r52
+ /* Prepare to recover ARGS, which we spilled earlier. */
+ addi TMP, r52, -(2 * REG_SIZE)
+ }
+ {
+ /* Restore ARGS, so we can fill it in with the return regs r0-r9. */
+ LW RETURN_REG_ADDR, TMP
+ /* Prepare to restore original r52. */
+ addi TMP, r52, -REG_SIZE
+ }
+
+ {
+ /* Pop stack frame. */
+ move sp, r52
+ /* Restore original r52. */
+ LW r52, TMP
+ }
+
+#define STORE_REG(REG, PTR) \
+ { \
+ SW PTR, REG ; \
+ addi PTR, PTR, REG_SIZE \
+ }
+
+ /* Return all register values by reference. */
+ STORE_REG(r0, RETURN_REG_ADDR)
+ STORE_REG(r1, RETURN_REG_ADDR)
+ STORE_REG(r2, RETURN_REG_ADDR)
+ STORE_REG(r3, RETURN_REG_ADDR)
+ STORE_REG(r4, RETURN_REG_ADDR)
+ STORE_REG(r5, RETURN_REG_ADDR)
+ STORE_REG(r6, RETURN_REG_ADDR)
+ STORE_REG(r7, RETURN_REG_ADDR)
+ STORE_REG(r8, RETURN_REG_ADDR)
+ STORE_REG(r9, RETURN_REG_ADDR)
+
+ {
+ jrp lr
+ }
+
+ .cfi_endproc
+ .size ffi_call_tile, .-ffi_call_tile
+
+/* ffi_closure_tile(...)
+
+ On entry, lr points to the closure plus 8 bytes, and r10
+ contains the actual return address.
+
+ This function simply dumps all register parameters into a stack array
+ and passes the closure, the registers array, and the stack arguments
+ to C code that does all of the actual closure processing. */
+
+ .section .text.ffi_closure_tile, "ax", @progbits
+ .align 8
+ .globl ffi_closure_tile
+ FFI_HIDDEN(ffi_closure_tile)
+
+ .cfi_startproc
+/* Room to spill all NUM_ARG_REGS incoming registers, plus frame linkage. */
+#define CLOSURE_FRAME_SIZE (((NUM_ARG_REGS * REG_SIZE * 2 + LINKAGE_SIZE) + 7) & -8)
+ffi_closure_tile:
+ {
+#ifdef __tilegx__
+ st sp, lr
+ .cfi_offset lr, 0
+#else
+ /* Save return address (in r10 due to closure stub wrapper). */
+ SW sp, r10
+ .cfi_return_column r10
+ .cfi_offset r10, 0
+#endif
+ /* Compute address for stack frame linkage. */
+ addli r10, sp, -(CLOSURE_FRAME_SIZE - REG_SIZE)
+ }
+ {
+ /* Save incoming stack pointer in linkage area. */
+ SW r10, sp
+ .cfi_offset sp, -(CLOSURE_FRAME_SIZE - REG_SIZE)
+ /* Push a new stack frame. */
+ addli sp, sp, -CLOSURE_FRAME_SIZE
+ .cfi_adjust_cfa_offset CLOSURE_FRAME_SIZE
+ }
+
+ {
+ /* Create pointer to where to start spilling registers. */
+ addi r10, sp, LINKAGE_SIZE
+ }
+
+ /* Spill all the incoming registers. */
+ STORE_REG(r0, r10)
+ STORE_REG(r1, r10)
+ STORE_REG(r2, r10)
+ STORE_REG(r3, r10)
+ STORE_REG(r4, r10)
+ STORE_REG(r5, r10)
+ STORE_REG(r6, r10)
+ STORE_REG(r7, r10)
+ STORE_REG(r8, r10)
+ {
+ /* Save r9. */
+ SW r10, r9
+#ifdef __tilegx__
+ /* Pointer to closure is passed in r11. */
+ move r0, r11
+#else
+ /* Compute pointer to the closure object. Because the closure
+ starts with a "jal ffi_closure_tile", we can just take the
+ value of lr (a phony return address pointing into the closure)
+ and subtract 8. */
+ addi r0, lr, -8
+#endif
+ /* Compute a pointer to the register arguments we just spilled. */
+ addi r1, sp, LINKAGE_SIZE
+ }
+ {
+ /* Compute a pointer to the extra stack arguments (if any). */
+ addli r2, sp, CLOSURE_FRAME_SIZE + LINKAGE_SIZE
+ /* Call C code to deal with all of the grotty details. */
+ jal ffi_closure_tile_inner
+ }
+ {
+ addli r10, sp, CLOSURE_FRAME_SIZE
+ }
+ {
+ /* Restore the return address. */
+ LW lr, r10
+ /* Compute pointer to registers array. */
+ addli r10, sp, LINKAGE_SIZE + (NUM_ARG_REGS * REG_SIZE)
+ }
+ /* Return all the register values, which C code may have set. */
+ LOAD_REG(r0, r10)
+ LOAD_REG(r1, r10)
+ LOAD_REG(r2, r10)
+ LOAD_REG(r3, r10)
+ LOAD_REG(r4, r10)
+ LOAD_REG(r5, r10)
+ LOAD_REG(r6, r10)
+ LOAD_REG(r7, r10)
+ LOAD_REG(r8, r10)
+ LOAD_REG(r9, r10)
+ {
+ /* Pop the frame. */
+ addli sp, sp, CLOSURE_FRAME_SIZE
+ jrp lr
+ }
+
+ .cfi_endproc
+ .size ffi_closure_tile, . - ffi_closure_tile
+
+
+/* What follows are code template instructions that get copied to the
+ closure trampoline by ffi_prep_closure_loc. The zeroed operands
+ get replaced by their proper values at runtime. */
+
+ .section .text.ffi_template_tramp_tile, "ax", @progbits
+ .align 8
+ .globl ffi_template_tramp_tile
+ FFI_HIDDEN(ffi_template_tramp_tile)
+ffi_template_tramp_tile:
+#ifdef __tilegx__
+ {
+ moveli r11, 0 /* backpatched to address of containing closure. */
+ moveli r10, 0 /* backpatched to ffi_closure_tile. */
+ }
+ /* Note: the following bundle gets generated multiple times
+ depending on the pointer value (esp. useful for -m32 mode). */
+ { shl16insli r11, r11, 0 ; shl16insli r10, r10, 0 }
+ { info 2+8 /* for backtracer: -> pc in lr, frame size 0 */ ; jr r10 }
+#else
+ /* 'jal .' yields a PC-relative offset of zero so we can OR in the
+ right offset at runtime. */
+ { move r10, lr ; jal . /* ffi_closure_tile */ }
+#endif
+
+ .size ffi_template_tramp_tile, . - ffi_template_tramp_tile
diff --git a/jni/ruby/ext/fiddle/libffi-3.2.1/src/types.c b/jni/ruby/ext/fiddle/libffi-3.2.1/src/types.c
new file mode 100644
index 0000000..7e80aec
--- /dev/null
+++ b/jni/ruby/ext/fiddle/libffi-3.2.1/src/types.c
@@ -0,0 +1,106 @@
+/* -----------------------------------------------------------------------
+ types.c - Copyright (c) 1996, 1998 Red Hat, Inc.
+
+ Predefined ffi_types needed by libffi.
+
+ Permission is hereby granted, free of charge, to any person obtaining
+ a copy of this software and associated documentation files (the
+ ``Software''), to deal in the Software without restriction, including
+ without limitation the rights to use, copy, modify, merge, publish,
+ distribute, sublicense, and/or sell copies of the Software, and to
+ permit persons to whom the Software is furnished to do so, subject to
+ the following conditions:
+
+ The above copyright notice and this permission notice shall be included
+ in all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND,
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+ HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ DEALINGS IN THE SOFTWARE.
+ ----------------------------------------------------------------------- */
+
+/* Hide the basic type definitions from the header file, so that we
+ can redefine them here as "const". */
+#define LIBFFI_HIDE_BASIC_TYPES
+
+#include <ffi.h>
+#include <ffi_common.h>
+
+/* Type definitions */
+
+#define FFI_TYPEDEF(name, type, id, maybe_const)\
+struct struct_align_##name { \
+ char c; \
+ type x; \
+}; \
+maybe_const ffi_type ffi_type_##name = { \
+ sizeof(type), \
+ offsetof(struct struct_align_##name, x), \
+ id, NULL \
+}
+
+#define FFI_COMPLEX_TYPEDEF(name, type, maybe_const) \
+static ffi_type *ffi_elements_complex_##name [2] = { \
+ (ffi_type *)(&ffi_type_##name), NULL \
+}; \
+struct struct_align_complex_##name { \
+ char c; \
+ _Complex type x; \
+}; \
+maybe_const ffi_type ffi_type_complex_##name = { \
+ sizeof(_Complex type), \
+ offsetof(struct struct_align_complex_##name, x), \
+ FFI_TYPE_COMPLEX, \
+ (ffi_type **)ffi_elements_complex_##name \
+}
+
+/* Size and alignment are fake here. They must not be 0. */
+const ffi_type ffi_type_void = {
+ 1, 1, FFI_TYPE_VOID, NULL
+};
+
+FFI_TYPEDEF(uint8, UINT8, FFI_TYPE_UINT8, const);
+FFI_TYPEDEF(sint8, SINT8, FFI_TYPE_SINT8, const);
+FFI_TYPEDEF(uint16, UINT16, FFI_TYPE_UINT16, const);
+FFI_TYPEDEF(sint16, SINT16, FFI_TYPE_SINT16, const);
+FFI_TYPEDEF(uint32, UINT32, FFI_TYPE_UINT32, const);
+FFI_TYPEDEF(sint32, SINT32, FFI_TYPE_SINT32, const);
+FFI_TYPEDEF(uint64, UINT64, FFI_TYPE_UINT64, const);
+FFI_TYPEDEF(sint64, SINT64, FFI_TYPE_SINT64, const);
+
+FFI_TYPEDEF(pointer, void*, FFI_TYPE_POINTER, const);
+
+FFI_TYPEDEF(float, float, FFI_TYPE_FLOAT, const);
+FFI_TYPEDEF(double, double, FFI_TYPE_DOUBLE, const);
+
+#if !defined HAVE_LONG_DOUBLE_VARIANT || defined __alpha__
+#define FFI_LDBL_CONST const
+#else
+#define FFI_LDBL_CONST
+#endif
+
+#ifdef __alpha__
+/* Even if we're not configured to default to 128-bit long double,
+ maintain binary compatibility, as -mlong-double-128 can be used
+ at any time. */
+/* Validate the hard-coded number below. */
+# if defined(__LONG_DOUBLE_128__) && FFI_TYPE_LONGDOUBLE != 4
+# error FFI_TYPE_LONGDOUBLE out of date
+# endif
+const ffi_type ffi_type_longdouble = { 16, 16, 4, NULL };
+#elif FFI_TYPE_LONGDOUBLE != FFI_TYPE_DOUBLE
+FFI_TYPEDEF(longdouble, long double, FFI_TYPE_LONGDOUBLE, FFI_LDBL_CONST);
+#endif
+
+#ifdef FFI_TARGET_HAS_COMPLEX_TYPE
+FFI_COMPLEX_TYPEDEF(float, float, const);
+FFI_COMPLEX_TYPEDEF(double, double, const);
+#if FFI_TYPE_LONGDOUBLE != FFI_TYPE_DOUBLE
+FFI_COMPLEX_TYPEDEF(longdouble, long double, FFI_LDBL_CONST);
+#endif
+#endif
diff --git a/jni/ruby/ext/fiddle/libffi-3.2.1/src/vax/elfbsd.S b/jni/ruby/ext/fiddle/libffi-3.2.1/src/vax/elfbsd.S
new file mode 100644
index 0000000..01ca313
--- /dev/null
+++ b/jni/ruby/ext/fiddle/libffi-3.2.1/src/vax/elfbsd.S
@@ -0,0 +1,195 @@
+/*
+ * Copyright (c) 2013 Miodrag Vallat. <miod@openbsd.org>
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * ``Software''), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+ * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+/*
+ * vax Foreign Function Interface
+ */
+
+#define LIBFFI_ASM
+#include <fficonfig.h>
+#include <ffi.h>
+
+ .text
+
+/*
+ * void * %r0
+ * ffi_call_elfbsd(extended_cif *ecif, 4(%ap)
+ * unsigned bytes, 8(%ap)
+ * unsigned flags, 12(%ap)
+ * void *rvalue, 16(%ap)
+ * void (*fn)()); 20(%ap)
+ */
+ .globl ffi_call_elfbsd
+ .type ffi_call_elfbsd,@function
+ .align 2
+ffi_call_elfbsd:
+ .word 0x00c # save R2 and R3
+
+ # Allocate stack space for the args
+ subl2 8(%ap), %sp
+
+ # Call ffi_prep_args
+ pushl %sp
+ pushl 4(%ap)
+ calls $2, ffi_prep_args
+
+ # Get function pointer
+ movl 20(%ap), %r1
+
+ # Build a CALLS frame
+ ashl $-2, 8(%ap), %r0
+ pushl %r0 # argument stack usage
+ movl %sp, %r0 # future %ap
+ # saved registers
+ bbc $11, 0(%r1), 1f
+ pushl %r11
+1: bbc $10, 0(%r1), 1f
+ pushl %r10
+1: bbc $9, 0(%r1), 1f
+ pushl %r9
+1: bbc $8, 0(%r1), 1f
+ pushl %r8
+1: bbc $7, 0(%r1), 1f
+ pushl %r7
+1: bbc $6, 0(%r1), 1f
+ pushl %r6
+1: bbc $5, 0(%r1), 1f
+ pushl %r5
+1: bbc $4, 0(%r1), 1f
+ pushl %r4
+1: bbc $3, 0(%r1), 1f
+ pushl %r3
+1: bbc $2, 0(%r1), 1f
+ pushl %r2
+1:
+ pushal 9f
+ pushl %fp
+ pushl %ap
+ movl 16(%ap), %r3 # struct return address, if needed
+ movl %r0, %ap
+ movzwl 4(%fp), %r0 # previous PSW, without the saved registers mask
+ bisl2 $0x20000000, %r0 # calls frame
+ movzwl 0(%r1), %r2
+ bicw2 $0xf003, %r2 # only keep R11-R2
+ ashl $16, %r2, %r2
+ bisl2 %r2, %r0 # saved register mask of the called function
+ pushl %r0
+ pushl $0
+ movl %sp, %fp
+
+ # Invoke the function
+ pushal 2(%r1) # skip procedure entry mask
+ movl %r3, %r1
+ bicpsw $0x000f
+ rsb
+
+9:
+ # Copy return value if necessary
+ tstl 16(%ap)
+ jeql 9f
+ movl 16(%ap), %r2
+
+ bbc $0, 12(%ap), 1f # CIF_FLAGS_CHAR
+ movb %r0, 0(%r2)
+ brb 9f
+1:
+ bbc $1, 12(%ap), 1f # CIF_FLAGS_SHORT
+ movw %r0, 0(%r2)
+ brb 9f
+1:
+ bbc $2, 12(%ap), 1f # CIF_FLAGS_INT
+ movl %r0, 0(%r2)
+ brb 9f
+1:
+ bbc $3, 12(%ap), 1f # CIF_FLAGS_DINT
+ movq %r0, 0(%r2)
+ brb 9f
+1:
+ movl %r1, %r0 # might have been a struct
+ #brb 9f
+
+9:
+ ret
+
+/*
+ * ffi_closure_elfbsd(void);
+ * invoked with %r0: ffi_closure *closure
+ */
+ .globl ffi_closure_elfbsd
+ .type ffi_closure_elfbsd, @function
+ .align 2
+ffi_closure_elfbsd:
+ .word 0
+
+ # Allocate room on stack for return value
+ subl2 $8, %sp
+
+ # Invoke the closure function
+ pushal 4(%ap) # calling stack
+ pushal 4(%sp) # return value
+ pushl %r0 # closure
+ calls $3, ffi_closure_elfbsd_inner
+
+ # Copy return value if necessary
+ bitb $1, %r0 # CIF_FLAGS_CHAR
+ beql 1f
+ movb 0(%sp), %r0
+ brb 9f
+1:
+ bitb $2, %r0 # CIF_FLAGS_SHORT
+ beql 1f
+ movw 0(%sp), %r0
+ brb 9f
+1:
+ bitb $4, %r0 # CIF_FLAGS_INT
+ beql 1f
+ movl 0(%sp), %r0
+ brb 9f
+1:
+ bitb $8, %r0 # CIF_FLAGS_DINT
+ beql 1f
+ movq 0(%sp), %r0
+ #brb 9f
+1:
+
+9:
+ ret
+
+/*
+ * ffi_closure_struct_elfbsd(void);
+ * invoked with %r0: ffi_closure *closure
+ * %r1: struct return address
+ */
+ .globl ffi_closure_struct_elfbsd
+ .type ffi_closure_struct_elfbsd, @function
+ .align 2
+ffi_closure_struct_elfbsd:
+ .word 0
+
+ # Invoke the closure function
+ pushal 4(%ap) # calling stack
+ pushl %r1 # return value
+ pushl %r0 # closure
+ calls $3, ffi_closure_elfbsd_inner
+
+ ret
diff --git a/jni/ruby/ext/fiddle/libffi-3.2.1/src/vax/ffi.c b/jni/ruby/ext/fiddle/libffi-3.2.1/src/vax/ffi.c
new file mode 100644
index 0000000..f4d6bbb
--- /dev/null
+++ b/jni/ruby/ext/fiddle/libffi-3.2.1/src/vax/ffi.c
@@ -0,0 +1,276 @@
+/*
+ * Copyright (c) 2013 Miodrag Vallat. <miod@openbsd.org>
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * ``Software''), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+ * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+/*
+ * vax Foreign Function Interface
+ *
+ * This file attempts to provide all the FFI entry points which can reliably
+ * be implemented in C.
+ */
+
+#include <ffi.h>
+#include <ffi_common.h>
+
+#include <stdlib.h>
+#include <unistd.h>
+
+#define CIF_FLAGS_CHAR 1 /* for struct only */
+#define CIF_FLAGS_SHORT 2 /* for struct only */
+#define CIF_FLAGS_INT 4
+#define CIF_FLAGS_DINT 8
+
+/*
+ * Foreign Function Interface API
+ */
+
+void ffi_call_elfbsd (extended_cif *, unsigned, unsigned, void *,
+ void (*) ());
+void *ffi_prep_args (extended_cif *ecif, void *stack);
+
+void *
+ffi_prep_args (extended_cif *ecif, void *stack)
+{
+ unsigned int i;
+ void **p_argv;
+ char *argp;
+ ffi_type **p_arg;
+ void *struct_value_ptr;
+
+ argp = stack;
+
+ if (ecif->cif->rtype->type == FFI_TYPE_STRUCT
+ && !ecif->cif->flags)
+ struct_value_ptr = ecif->rvalue;
+ else
+ struct_value_ptr = NULL;
+
+ p_argv = ecif->avalue;
+
+ for (i = ecif->cif->nargs, p_arg = ecif->cif->arg_types;
+ i != 0;
+ i--, p_arg++)
+ {
+ size_t z;
+
+ z = (*p_arg)->size;
+ if (z < sizeof (int))
+ {
+ switch ((*p_arg)->type)
+ {
+ case FFI_TYPE_SINT8:
+ *(signed int *) argp = (signed int) *(SINT8 *) *p_argv;
+ break;
+
+ case FFI_TYPE_UINT8:
+ *(unsigned int *) argp = (unsigned int) *(UINT8 *) *p_argv;
+ break;
+
+ case FFI_TYPE_SINT16:
+ *(signed int *) argp = (signed int) *(SINT16 *) *p_argv;
+ break;
+
+ case FFI_TYPE_UINT16:
+ *(unsigned int *) argp = (unsigned int) *(UINT16 *) *p_argv;
+ break;
+
+ case FFI_TYPE_STRUCT:
+ memcpy (argp, *p_argv, z);
+ break;
+
+ default:
+ FFI_ASSERT (0);
+ }
+ z = sizeof (int);
+ }
+ else
+ {
+ memcpy (argp, *p_argv, z);
+
+ /* Align if necessary. */
+ if ((sizeof(int) - 1) & z)
+ z = ALIGN(z, sizeof(int));
+ }
+
+ p_argv++;
+ argp += z;
+ }
+
+ return struct_value_ptr;
+}
+
+ffi_status
+ffi_prep_cif_machdep (ffi_cif *cif)
+{
+ /* Set the return type flag */
+ switch (cif->rtype->type)
+ {
+ case FFI_TYPE_VOID:
+ cif->flags = 0;
+ break;
+
+ case FFI_TYPE_STRUCT:
+ if (cif->rtype->elements[0]->type == FFI_TYPE_STRUCT &&
+ cif->rtype->elements[1])
+ {
+ cif->flags = 0;
+ break;
+ }
+
+ if (cif->rtype->size == sizeof (char))
+ cif->flags = CIF_FLAGS_CHAR;
+ else if (cif->rtype->size == sizeof (short))
+ cif->flags = CIF_FLAGS_SHORT;
+ else if (cif->rtype->size == sizeof (int))
+ cif->flags = CIF_FLAGS_INT;
+ else if (cif->rtype->size == 2 * sizeof (int))
+ cif->flags = CIF_FLAGS_DINT;
+ else
+ cif->flags = 0;
+ break;
+
+ default:
+ if (cif->rtype->size <= sizeof (int))
+ cif->flags = CIF_FLAGS_INT;
+ else
+ cif->flags = CIF_FLAGS_DINT;
+ break;
+ }
+
+ return FFI_OK;
+}
+
+void
+ffi_call (ffi_cif *cif, void (*fn) (), void *rvalue, void **avalue)
+{
+ extended_cif ecif;
+
+ ecif.cif = cif;
+ ecif.avalue = avalue;
+
+ /* If the return value is a struct and we don't have a return value
+ address then we need to make one. */
+
+ if (rvalue == NULL
+ && cif->rtype->type == FFI_TYPE_STRUCT
+ && cif->flags == 0)
+ ecif.rvalue = alloca (cif->rtype->size);
+ else
+ ecif.rvalue = rvalue;
+
+ switch (cif->abi)
+ {
+ case FFI_ELFBSD:
+ ffi_call_elfbsd (&ecif, cif->bytes, cif->flags, ecif.rvalue, fn);
+ break;
+
+ default:
+ FFI_ASSERT (0);
+ break;
+ }
+}
+
+/*
+ * Closure API
+ */
+
+void ffi_closure_elfbsd (void);
+void ffi_closure_struct_elfbsd (void);
+unsigned int ffi_closure_elfbsd_inner (ffi_closure *, void *, char *);
+
+static void
+ffi_prep_closure_elfbsd (ffi_cif *cif, void **avalue, char *stackp)
+{
+ unsigned int i;
+ void **p_argv;
+ ffi_type **p_arg;
+
+ p_argv = avalue;
+
+ for (i = cif->nargs, p_arg = cif->arg_types; i != 0; i--, p_arg++)
+ {
+ size_t z;
+
+ z = (*p_arg)->size;
+ *p_argv = stackp;
+
+ /* Align if necessary */
+ if ((sizeof (int) - 1) & z)
+ z = ALIGN(z, sizeof (int));
+
+ p_argv++;
+ stackp += z;
+ }
+}
+
+unsigned int
+ffi_closure_elfbsd_inner (ffi_closure *closure, void *resp, char *stack)
+{
+ ffi_cif *cif;
+ void **arg_area;
+
+ cif = closure->cif;
+ arg_area = (void **) alloca (cif->nargs * sizeof (void *));
+
+ ffi_prep_closure_elfbsd (cif, arg_area, stack);
+
+ (closure->fun) (cif, resp, arg_area, closure->user_data);
+
+ return cif->flags;
+}
+
+ffi_status
+ffi_prep_closure_loc (ffi_closure *closure, ffi_cif *cif,
+ void (*fun)(ffi_cif *, void *, void **, void *),
+ void *user_data, void *codeloc)
+{
+ char *tramp = (char *) codeloc;
+ void *fn;
+
+ FFI_ASSERT (cif->abi == FFI_ELFBSD);
+
+ /* entry mask */
+ *(unsigned short *)(tramp + 0) = 0x0000;
+ /* movl #closure, r0 */
+ tramp[2] = 0xd0;
+ tramp[3] = 0x8f;
+ *(unsigned int *)(tramp + 4) = (unsigned int) closure;
+ tramp[8] = 0x50;
+
+ if (cif->rtype->type == FFI_TYPE_STRUCT
+ && !cif->flags)
+ fn = &ffi_closure_struct_elfbsd;
+ else
+ fn = &ffi_closure_elfbsd;
+
+ /* jmpl #fn */
+ tramp[9] = 0x17;
+ tramp[10] = 0xef;
+ *(unsigned int *)(tramp + 11) = (unsigned int)fn + 2 -
+ (unsigned int)tramp - 9 - 6;
+
+ closure->cif = cif;
+ closure->user_data = user_data;
+ closure->fun = fun;
+
+ return FFI_OK;
+}
diff --git a/jni/ruby/ext/fiddle/libffi-3.2.1/src/vax/ffitarget.h b/jni/ruby/ext/fiddle/libffi-3.2.1/src/vax/ffitarget.h
new file mode 100644
index 0000000..2fc9488
--- /dev/null
+++ b/jni/ruby/ext/fiddle/libffi-3.2.1/src/vax/ffitarget.h
@@ -0,0 +1,49 @@
+/*
+ * Copyright (c) 2013 Miodrag Vallat. <miod@openbsd.org>
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * ``Software''), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+ * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+/*
+ * vax Foreign Function Interface
+ */
+
+#ifndef LIBFFI_TARGET_H
+#define LIBFFI_TARGET_H
+
+#ifndef LIBFFI_ASM
+typedef unsigned long ffi_arg;
+typedef signed long ffi_sarg;
+
+typedef enum ffi_abi {
+ FFI_FIRST_ABI = 0,
+ FFI_ELFBSD,
+ FFI_DEFAULT_ABI = FFI_ELFBSD,
+ FFI_LAST_ABI = FFI_DEFAULT_ABI + 1
+} ffi_abi;
+#endif
+
+/* ---- Definitions for closures ----------------------------------------- */
+
+#define FFI_CLOSURES 1
+#define FFI_TRAMPOLINE_SIZE 15
+#define FFI_NATIVE_RAW_API 0
+
+#endif
diff --git a/jni/ruby/ext/fiddle/libffi-3.2.1/src/x86/darwin.S b/jni/ruby/ext/fiddle/libffi-3.2.1/src/x86/darwin.S
new file mode 100644
index 0000000..8f0f070
--- /dev/null
+++ b/jni/ruby/ext/fiddle/libffi-3.2.1/src/x86/darwin.S
@@ -0,0 +1,444 @@
+/* -----------------------------------------------------------------------
+ darwin.S - Copyright (c) 1996, 1998, 2001, 2002, 2003, 2005 Red Hat, Inc.
+ Copyright (C) 2008 Free Software Foundation, Inc.
+
+ X86 Foreign Function Interface
+
+ Permission is hereby granted, free of charge, to any person obtaining
+ a copy of this software and associated documentation files (the
+ ``Software''), to deal in the Software without restriction, including
+ without limitation the rights to use, copy, modify, merge, publish,
+ distribute, sublicense, and/or sell copies of the Software, and to
+ permit persons to whom the Software is furnished to do so, subject to
+ the following conditions:
+
+ The above copyright notice and this permission notice shall be included
+ in all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND,
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+ HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ DEALINGS IN THE SOFTWARE.
+ -----------------------------------------------------------------------
+ */
+
+#ifndef __x86_64__
+
+#define LIBFFI_ASM
+#include <fficonfig.h>
+#include <ffi.h>
+
+.text
+
+.globl _ffi_prep_args
+
+ .align 4
+.globl _ffi_call_SYSV
+
+_ffi_call_SYSV:
+.LFB1:
+ pushl %ebp
+.LCFI0:
+ movl %esp,%ebp
+.LCFI1:
+ subl $8,%esp
+ /* Make room for all of the new args. */
+ movl 16(%ebp),%ecx
+ subl %ecx,%esp
+
+ movl %esp,%eax
+
+ /* Place all of the ffi_prep_args in position */
+ subl $8,%esp
+ pushl 12(%ebp)
+ pushl %eax
+ call *8(%ebp)
+
+ /* Return stack to previous state and call the function */
+ addl $16,%esp
+
+ call *28(%ebp)
+
+ /* Load %ecx with the return type code */
+ movl 20(%ebp),%ecx
+
+ /* Protect %esi. We're going to pop it in the epilogue. */
+ pushl %esi
+
+ /* If the return value pointer is NULL, assume no return value. */
+ cmpl $0,24(%ebp)
+ jne 0f
+
+ /* Even if there is no space for the return value, we are
+ obliged to handle floating-point values. */
+ cmpl $FFI_TYPE_FLOAT,%ecx
+ jne noretval
+ fstp %st(0)
+
+ jmp epilogue
+0:
+ .align 4
+ call 1f
+.Lstore_table:
+ .long noretval-.Lstore_table /* FFI_TYPE_VOID */
+ .long retint-.Lstore_table /* FFI_TYPE_INT */
+ .long retfloat-.Lstore_table /* FFI_TYPE_FLOAT */
+ .long retdouble-.Lstore_table /* FFI_TYPE_DOUBLE */
+ .long retlongdouble-.Lstore_table /* FFI_TYPE_LONGDOUBLE */
+ .long retuint8-.Lstore_table /* FFI_TYPE_UINT8 */
+ .long retsint8-.Lstore_table /* FFI_TYPE_SINT8 */
+ .long retuint16-.Lstore_table /* FFI_TYPE_UINT16 */
+ .long retsint16-.Lstore_table /* FFI_TYPE_SINT16 */
+ .long retint-.Lstore_table /* FFI_TYPE_UINT32 */
+ .long retint-.Lstore_table /* FFI_TYPE_SINT32 */
+ .long retint64-.Lstore_table /* FFI_TYPE_UINT64 */
+ .long retint64-.Lstore_table /* FFI_TYPE_SINT64 */
+ .long retstruct-.Lstore_table /* FFI_TYPE_STRUCT */
+ .long retint-.Lstore_table /* FFI_TYPE_POINTER */
+ .long retstruct1b-.Lstore_table /* FFI_TYPE_SMALL_STRUCT_1B */
+ .long retstruct2b-.Lstore_table /* FFI_TYPE_SMALL_STRUCT_2B */
+1:
+ pop %esi
+ add (%esi, %ecx, 4), %esi
+ jmp *%esi
+
+ /* Sign/zero extend as appropriate. */
+retsint8:
+ movsbl %al, %eax
+ jmp retint
+
+retsint16:
+ movswl %ax, %eax
+ jmp retint
+
+retuint8:
+ movzbl %al, %eax
+ jmp retint
+
+retuint16:
+ movzwl %ax, %eax
+ jmp retint
+
+retfloat:
+ /* Load %ecx with the pointer to storage for the return value */
+ movl 24(%ebp),%ecx
+ fstps (%ecx)
+ jmp epilogue
+
+retdouble:
+ /* Load %ecx with the pointer to storage for the return value */
+ movl 24(%ebp),%ecx
+ fstpl (%ecx)
+ jmp epilogue
+
+retlongdouble:
+ /* Load %ecx with the pointer to storage for the return value */
+ movl 24(%ebp),%ecx
+ fstpt (%ecx)
+ jmp epilogue
+
+retint64:
+ /* Load %ecx with the pointer to storage for the return value */
+ movl 24(%ebp),%ecx
+ movl %eax,0(%ecx)
+ movl %edx,4(%ecx)
+ jmp epilogue
+
+retstruct1b:
+ /* Load %ecx with the pointer to storage for the return value */
+ movl 24(%ebp),%ecx
+ movb %al,0(%ecx)
+ jmp epilogue
+
+retstruct2b:
+ /* Load %ecx with the pointer to storage for the return value */
+ movl 24(%ebp),%ecx
+ movw %ax,0(%ecx)
+ jmp epilogue
+
+retint:
+ /* Load %ecx with the pointer to storage for the return value */
+ movl 24(%ebp),%ecx
+ movl %eax,0(%ecx)
+
+retstruct:
+ /* Nothing to do! */
+
+noretval:
+epilogue:
+ popl %esi
+ movl %ebp,%esp
+ popl %ebp
+ ret
+
+.LFE1:
+.ffi_call_SYSV_end:
+
+ .align 4
+FFI_HIDDEN (ffi_closure_SYSV)
+.globl _ffi_closure_SYSV
+
+_ffi_closure_SYSV:
+.LFB2:
+ pushl %ebp
+.LCFI2:
+ movl %esp, %ebp
+.LCFI3:
+ subl $40, %esp
+ leal -24(%ebp), %edx
+ movl %edx, -12(%ebp) /* resp */
+ leal 8(%ebp), %edx
+ movl %edx, 4(%esp) /* args = __builtin_dwarf_cfa () */
+ leal -12(%ebp), %edx
+ movl %edx, (%esp) /* &resp */
+ movl %ebx, 8(%esp)
+.LCFI7:
+ call L_ffi_closure_SYSV_inner$stub
+ movl 8(%esp), %ebx
+ movl -12(%ebp), %ecx
+ cmpl $FFI_TYPE_INT, %eax
+ je .Lcls_retint
+
+ /* Handle FFI_TYPE_UINT8, FFI_TYPE_SINT8, FFI_TYPE_UINT16,
+ FFI_TYPE_SINT16, FFI_TYPE_UINT32, FFI_TYPE_SINT32. */
+ cmpl $FFI_TYPE_UINT64, %eax
+ jge 0f
+ cmpl $FFI_TYPE_UINT8, %eax
+ jge .Lcls_retint
+
+0: cmpl $FFI_TYPE_FLOAT, %eax
+ je .Lcls_retfloat
+ cmpl $FFI_TYPE_DOUBLE, %eax
+ je .Lcls_retdouble
+ cmpl $FFI_TYPE_LONGDOUBLE, %eax
+ je .Lcls_retldouble
+ cmpl $FFI_TYPE_SINT64, %eax
+ je .Lcls_retllong
+ cmpl $FFI_TYPE_SMALL_STRUCT_1B, %eax
+ je .Lcls_retstruct1b
+ cmpl $FFI_TYPE_SMALL_STRUCT_2B, %eax
+ je .Lcls_retstruct2b
+ cmpl $FFI_TYPE_STRUCT, %eax
+ je .Lcls_retstruct
+.Lcls_epilogue:
+ movl %ebp, %esp
+ popl %ebp
+ ret
+.Lcls_retint:
+ movl (%ecx), %eax
+ jmp .Lcls_epilogue
+.Lcls_retfloat:
+ flds (%ecx)
+ jmp .Lcls_epilogue
+.Lcls_retdouble:
+ fldl (%ecx)
+ jmp .Lcls_epilogue
+.Lcls_retldouble:
+ fldt (%ecx)
+ jmp .Lcls_epilogue
+.Lcls_retllong:
+ movl (%ecx), %eax
+ movl 4(%ecx), %edx
+ jmp .Lcls_epilogue
+.Lcls_retstruct1b:
+ movsbl (%ecx), %eax
+ jmp .Lcls_epilogue
+.Lcls_retstruct2b:
+ movswl (%ecx), %eax
+ jmp .Lcls_epilogue
+.Lcls_retstruct:
+ lea -8(%ebp),%esp
+ movl %ebp, %esp
+ popl %ebp
+ ret $4
+.LFE2:
+
+#if !FFI_NO_RAW_API
+
+#define RAW_CLOSURE_CIF_OFFSET ((FFI_TRAMPOLINE_SIZE + 3) & ~3)
+#define RAW_CLOSURE_FUN_OFFSET (RAW_CLOSURE_CIF_OFFSET + 4)
+#define RAW_CLOSURE_USER_DATA_OFFSET (RAW_CLOSURE_FUN_OFFSET + 4)
+#define CIF_FLAGS_OFFSET 20
+
+ .align 4
+FFI_HIDDEN (ffi_closure_raw_SYSV)
+.globl _ffi_closure_raw_SYSV
+
+_ffi_closure_raw_SYSV:
+.LFB3:
+ pushl %ebp
+.LCFI4:
+ movl %esp, %ebp
+.LCFI5:
+ pushl %esi
+.LCFI6:
+ subl $36, %esp
+ movl RAW_CLOSURE_CIF_OFFSET(%eax), %esi /* closure->cif */
+ movl RAW_CLOSURE_USER_DATA_OFFSET(%eax), %edx /* closure->user_data */
+ movl %edx, 12(%esp) /* user_data */
+ leal 8(%ebp), %edx /* __builtin_dwarf_cfa () */
+ movl %edx, 8(%esp) /* raw_args */
+ leal -24(%ebp), %edx
+ movl %edx, 4(%esp) /* &res */
+ movl %esi, (%esp) /* cif */
+ call *RAW_CLOSURE_FUN_OFFSET(%eax) /* closure->fun */
+ movl CIF_FLAGS_OFFSET(%esi), %eax /* rtype */
+ cmpl $FFI_TYPE_INT, %eax
+ je .Lrcls_retint
+
+ /* Handle FFI_TYPE_UINT8, FFI_TYPE_SINT8, FFI_TYPE_UINT16,
+ FFI_TYPE_SINT16, FFI_TYPE_UINT32, FFI_TYPE_SINT32. */
+ cmpl $FFI_TYPE_UINT64, %eax
+ jge 0f
+ cmpl $FFI_TYPE_UINT8, %eax
+ jge .Lrcls_retint
+0:
+ cmpl $FFI_TYPE_FLOAT, %eax
+ je .Lrcls_retfloat
+ cmpl $FFI_TYPE_DOUBLE, %eax
+ je .Lrcls_retdouble
+ cmpl $FFI_TYPE_LONGDOUBLE, %eax
+ je .Lrcls_retldouble
+ cmpl $FFI_TYPE_SINT64, %eax
+ je .Lrcls_retllong
+.Lrcls_epilogue:
+ addl $36, %esp
+ popl %esi
+ popl %ebp
+ ret
+.Lrcls_retint:
+ movl -24(%ebp), %eax
+ jmp .Lrcls_epilogue
+.Lrcls_retfloat:
+ flds -24(%ebp)
+ jmp .Lrcls_epilogue
+.Lrcls_retdouble:
+ fldl -24(%ebp)
+ jmp .Lrcls_epilogue
+.Lrcls_retldouble:
+ fldt -24(%ebp)
+ jmp .Lrcls_epilogue
+.Lrcls_retllong:
+ movl -24(%ebp), %eax
+ movl -20(%ebp), %edx
+ jmp .Lrcls_epilogue
+.LFE3:
+#endif
+
+.section __IMPORT,__jump_table,symbol_stubs,self_modifying_code+pure_instructions,5
+L_ffi_closure_SYSV_inner$stub:
+ .indirect_symbol _ffi_closure_SYSV_inner
+ hlt ; hlt ; hlt ; hlt ; hlt
+
+
+.section __TEXT,__eh_frame,coalesced,no_toc+strip_static_syms+live_support
+EH_frame1:
+ .set L$set$0,LECIE1-LSCIE1
+ .long L$set$0
+LSCIE1:
+ .long 0x0
+ .byte 0x1
+ .ascii "zR\0"
+ .byte 0x1
+ .byte 0x7c
+ .byte 0x8
+ .byte 0x1
+ .byte 0x10
+ .byte 0xc
+ .byte 0x5
+ .byte 0x4
+ .byte 0x88
+ .byte 0x1
+ .align 2
+LECIE1:
+.globl _ffi_call_SYSV.eh
+_ffi_call_SYSV.eh:
+LSFDE1:
+ .set L$set$1,LEFDE1-LASFDE1
+ .long L$set$1
+LASFDE1:
+ .long LASFDE1-EH_frame1
+ .long .LFB1-.
+ .set L$set$2,.LFE1-.LFB1
+ .long L$set$2
+ .byte 0x0
+ .byte 0x4
+ .set L$set$3,.LCFI0-.LFB1
+ .long L$set$3
+ .byte 0xe
+ .byte 0x8
+ .byte 0x84
+ .byte 0x2
+ .byte 0x4
+ .set L$set$4,.LCFI1-.LCFI0
+ .long L$set$4
+ .byte 0xd
+ .byte 0x4
+ .align 2
+LEFDE1:
+.globl _ffi_closure_SYSV.eh
+_ffi_closure_SYSV.eh:
+LSFDE2:
+ .set L$set$5,LEFDE2-LASFDE2
+ .long L$set$5
+LASFDE2:
+ .long LASFDE2-EH_frame1
+ .long .LFB2-.
+ .set L$set$6,.LFE2-.LFB2
+ .long L$set$6
+ .byte 0x0
+ .byte 0x4
+ .set L$set$7,.LCFI2-.LFB2
+ .long L$set$7
+ .byte 0xe
+ .byte 0x8
+ .byte 0x84
+ .byte 0x2
+ .byte 0x4
+ .set L$set$8,.LCFI3-.LCFI2
+ .long L$set$8
+ .byte 0xd
+ .byte 0x4
+ .align 2
+LEFDE2:
+
+#if !FFI_NO_RAW_API
+
+.globl _ffi_closure_raw_SYSV.eh
+_ffi_closure_raw_SYSV.eh:
+LSFDE3:
+ .set L$set$10,LEFDE3-LASFDE3
+ .long L$set$10
+LASFDE3:
+ .long LASFDE3-EH_frame1
+ .long .LFB3-.
+ .set L$set$11,.LFE3-.LFB3
+ .long L$set$11
+ .byte 0x0
+ .byte 0x4
+ .set L$set$12,.LCFI4-.LFB3
+ .long L$set$12
+ .byte 0xe
+ .byte 0x8
+ .byte 0x84
+ .byte 0x2
+ .byte 0x4
+ .set L$set$13,.LCFI5-.LCFI4
+ .long L$set$13
+ .byte 0xd
+ .byte 0x4
+ .byte 0x4
+ .set L$set$14,.LCFI6-.LCFI5
+ .long L$set$14
+ .byte 0x85
+ .byte 0x3
+ .align 2
+LEFDE3:
+
+#endif
+
+#endif /* ifndef __x86_64__ */
diff --git a/jni/ruby/ext/fiddle/libffi-3.2.1/src/x86/darwin64.S b/jni/ruby/ext/fiddle/libffi-3.2.1/src/x86/darwin64.S
new file mode 100644
index 0000000..2f7394e
--- /dev/null
+++ b/jni/ruby/ext/fiddle/libffi-3.2.1/src/x86/darwin64.S
@@ -0,0 +1,416 @@
+/* -----------------------------------------------------------------------
+ darwin64.S - Copyright (c) 2006 Free Software Foundation, Inc.
+ Copyright (c) 2008 Red Hat, Inc.
+ derived from unix64.S
+
+ x86-64 Foreign Function Interface for Darwin.
+
+ Permission is hereby granted, free of charge, to any person obtaining
+ a copy of this software and associated documentation files (the
+ ``Software''), to deal in the Software without restriction, including
+ without limitation the rights to use, copy, modify, merge, publish,
+ distribute, sublicense, and/or sell copies of the Software, and to
+ permit persons to whom the Software is furnished to do so, subject to
+ the following conditions:
+
+ The above copyright notice and this permission notice shall be included
+ in all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ OTHER DEALINGS IN THE SOFTWARE.
+ ----------------------------------------------------------------------- */
+
+#ifdef __x86_64__
+#define LIBFFI_ASM
+#include <fficonfig.h>
+#include <ffi.h>
+
+ .file "darwin64.S"
+.text
+
+/* ffi_call_unix64 (void *args, unsigned long bytes, unsigned flags,
+ void *raddr, void (*fnaddr)(void));
+
+ Bit o trickiness here -- ARGS+BYTES is the base of the stack frame
+ for this function. This has been allocated by ffi_call. We also
+ deallocate some of the stack that has been alloca'd. */
+
+ .align 3
+ .globl _ffi_call_unix64
+
+_ffi_call_unix64:
+LUW0:
+ movq (%rsp), %r10 /* Load return address. */
+ leaq (%rdi, %rsi), %rax /* Find local stack base. */
+ movq %rdx, (%rax) /* Save flags. */
+ movq %rcx, 8(%rax) /* Save raddr. */
+ movq %rbp, 16(%rax) /* Save old frame pointer. */
+ movq %r10, 24(%rax) /* Relocate return address. */
+ movq %rax, %rbp /* Finalize local stack frame. */
+LUW1:
+ movq %rdi, %r10 /* Save a copy of the register area. */
+ movq %r8, %r11 /* Save a copy of the target fn. */
+ movl %r9d, %eax /* Set number of SSE registers. */
+
+ /* Load up all argument registers. */
+ movq (%r10), %rdi
+ movq 8(%r10), %rsi
+ movq 16(%r10), %rdx
+ movq 24(%r10), %rcx
+ movq 32(%r10), %r8
+ movq 40(%r10), %r9
+ testl %eax, %eax
+ jnz Lload_sse
+Lret_from_load_sse:
+
+ /* Deallocate the reg arg area. */
+ leaq 176(%r10), %rsp
+
+ /* Call the user function. */
+ call *%r11
+
+ /* Deallocate stack arg area; local stack frame in redzone. */
+ leaq 24(%rbp), %rsp
+
+ movq 0(%rbp), %rcx /* Reload flags. */
+ movq 8(%rbp), %rdi /* Reload raddr. */
+ movq 16(%rbp), %rbp /* Reload old frame pointer. */
+LUW2:
+
+ /* The first byte of the flags contains the FFI_TYPE. */
+ movzbl %cl, %r10d
+ leaq Lstore_table(%rip), %r11
+ movslq (%r11, %r10, 4), %r10
+ addq %r11, %r10
+ jmp *%r10
+
+Lstore_table:
+ .long Lst_void-Lstore_table /* FFI_TYPE_VOID */
+ .long Lst_sint32-Lstore_table /* FFI_TYPE_INT */
+ .long Lst_float-Lstore_table /* FFI_TYPE_FLOAT */
+ .long Lst_double-Lstore_table /* FFI_TYPE_DOUBLE */
+ .long Lst_ldouble-Lstore_table /* FFI_TYPE_LONGDOUBLE */
+ .long Lst_uint8-Lstore_table /* FFI_TYPE_UINT8 */
+ .long Lst_sint8-Lstore_table /* FFI_TYPE_SINT8 */
+ .long Lst_uint16-Lstore_table /* FFI_TYPE_UINT16 */
+ .long Lst_sint16-Lstore_table /* FFI_TYPE_SINT16 */
+ .long Lst_uint32-Lstore_table /* FFI_TYPE_UINT32 */
+ .long Lst_sint32-Lstore_table /* FFI_TYPE_SINT32 */
+ .long Lst_int64-Lstore_table /* FFI_TYPE_UINT64 */
+ .long Lst_int64-Lstore_table /* FFI_TYPE_SINT64 */
+ .long Lst_struct-Lstore_table /* FFI_TYPE_STRUCT */
+ .long Lst_int64-Lstore_table /* FFI_TYPE_POINTER */
+
+ .text
+ .align 3
+Lst_void:
+ ret
+ .align 3
+Lst_uint8:
+ movzbq %al, %rax
+ movq %rax, (%rdi)
+ ret
+ .align 3
+Lst_sint8:
+ movsbq %al, %rax
+ movq %rax, (%rdi)
+ ret
+ .align 3
+Lst_uint16:
+ movzwq %ax, %rax
+ movq %rax, (%rdi)
+ .align 3
+Lst_sint16:
+ movswq %ax, %rax
+ movq %rax, (%rdi)
+ ret
+ .align 3
+Lst_uint32:
+ movl %eax, %eax
+ movq %rax, (%rdi)
+ .align 3
+Lst_sint32:
+ cltq
+ movq %rax, (%rdi)
+ ret
+ .align 3
+Lst_int64:
+ movq %rax, (%rdi)
+ ret
+ .align 3
+Lst_float:
+ movss %xmm0, (%rdi)
+ ret
+ .align 3
+Lst_double:
+ movsd %xmm0, (%rdi)
+ ret
+Lst_ldouble:
+ fstpt (%rdi)
+ ret
+ .align 3
+Lst_struct:
+ leaq -20(%rsp), %rsi /* Scratch area in redzone. */
+
+ /* We have to locate the values now, and since we don't want to
+ write too much data into the user's return value, we spill the
+ value to a 16 byte scratch area first. Bits 8, 9, and 10
+ control where the values are located. Only one of the three
+ bits will be set; see ffi_prep_cif_machdep for the pattern. */
+ movd %xmm0, %r10
+ movd %xmm1, %r11
+ testl $0x100, %ecx
+ cmovnz %rax, %rdx
+ cmovnz %r10, %rax
+ testl $0x200, %ecx
+ cmovnz %r10, %rdx
+ testl $0x400, %ecx
+ cmovnz %r10, %rax
+ cmovnz %r11, %rdx
+ movq %rax, (%rsi)
+ movq %rdx, 8(%rsi)
+
+ /* Bits 12-31 contain the true size of the structure. Copy from
+ the scratch area to the true destination. */
+ shrl $12, %ecx
+ rep movsb
+ ret
+
+ /* Many times we can avoid loading any SSE registers at all.
+ It's not worth an indirect jump to load the exact set of
+ SSE registers needed; zero or all is a good compromise. */
+ .align 3
+LUW3:
+Lload_sse:
+ movdqa 48(%r10), %xmm0
+ movdqa 64(%r10), %xmm1
+ movdqa 80(%r10), %xmm2
+ movdqa 96(%r10), %xmm3
+ movdqa 112(%r10), %xmm4
+ movdqa 128(%r10), %xmm5
+ movdqa 144(%r10), %xmm6
+ movdqa 160(%r10), %xmm7
+ jmp Lret_from_load_sse
+
+LUW4:
+ .align 3
+ .globl _ffi_closure_unix64
+
+_ffi_closure_unix64:
+LUW5:
+ /* The carry flag is set by the trampoline iff SSE registers
+ are used. Don't clobber it before the branch instruction. */
+ leaq -200(%rsp), %rsp
+LUW6:
+ movq %rdi, (%rsp)
+ movq %rsi, 8(%rsp)
+ movq %rdx, 16(%rsp)
+ movq %rcx, 24(%rsp)
+ movq %r8, 32(%rsp)
+ movq %r9, 40(%rsp)
+ jc Lsave_sse
+Lret_from_save_sse:
+
+ movq %r10, %rdi
+ leaq 176(%rsp), %rsi
+ movq %rsp, %rdx
+ leaq 208(%rsp), %rcx
+ call _ffi_closure_unix64_inner
+
+ /* Deallocate stack frame early; return value is now in redzone. */
+ addq $200, %rsp
+LUW7:
+
+ /* The first byte of the return value contains the FFI_TYPE. */
+ movzbl %al, %r10d
+ leaq Lload_table(%rip), %r11
+ movslq (%r11, %r10, 4), %r10
+ addq %r11, %r10
+ jmp *%r10
+
+Lload_table:
+ .long Lld_void-Lload_table /* FFI_TYPE_VOID */
+ .long Lld_int32-Lload_table /* FFI_TYPE_INT */
+ .long Lld_float-Lload_table /* FFI_TYPE_FLOAT */
+ .long Lld_double-Lload_table /* FFI_TYPE_DOUBLE */
+ .long Lld_ldouble-Lload_table /* FFI_TYPE_LONGDOUBLE */
+ .long Lld_int8-Lload_table /* FFI_TYPE_UINT8 */
+ .long Lld_int8-Lload_table /* FFI_TYPE_SINT8 */
+ .long Lld_int16-Lload_table /* FFI_TYPE_UINT16 */
+ .long Lld_int16-Lload_table /* FFI_TYPE_SINT16 */
+ .long Lld_int32-Lload_table /* FFI_TYPE_UINT32 */
+ .long Lld_int32-Lload_table /* FFI_TYPE_SINT32 */
+ .long Lld_int64-Lload_table /* FFI_TYPE_UINT64 */
+ .long Lld_int64-Lload_table /* FFI_TYPE_SINT64 */
+ .long Lld_struct-Lload_table /* FFI_TYPE_STRUCT */
+ .long Lld_int64-Lload_table /* FFI_TYPE_POINTER */
+
+ .text
+ .align 3
+Lld_void:
+ ret
+ .align 3
+Lld_int8:
+ movzbl -24(%rsp), %eax
+ ret
+ .align 3
+Lld_int16:
+ movzwl -24(%rsp), %eax
+ ret
+ .align 3
+Lld_int32:
+ movl -24(%rsp), %eax
+ ret
+ .align 3
+Lld_int64:
+ movq -24(%rsp), %rax
+ ret
+ .align 3
+Lld_float:
+ movss -24(%rsp), %xmm0
+ ret
+ .align 3
+Lld_double:
+ movsd -24(%rsp), %xmm0
+ ret
+ .align 3
+Lld_ldouble:
+ fldt -24(%rsp)
+ ret
+ .align 3
+Lld_struct:
+ /* There are four possibilities here, %rax/%rdx, %xmm0/%rax,
+ %rax/%xmm0, %xmm0/%xmm1. We collapse two by always loading
+ both rdx and xmm1 with the second word. For the remaining,
+ bit 8 set means xmm0 gets the second word, and bit 9 means
+ that rax gets the second word. */
+ movq -24(%rsp), %rcx
+ movq -16(%rsp), %rdx
+ movq -16(%rsp), %xmm1
+ testl $0x100, %eax
+ cmovnz %rdx, %rcx
+ movd %rcx, %xmm0
+ testl $0x200, %eax
+ movq -24(%rsp), %rax
+ cmovnz %rdx, %rax
+ ret
+
+ /* See the comment above Lload_sse; the same logic applies here. */
+ .align 3
+LUW8:
+Lsave_sse:
+ movdqa %xmm0, 48(%rsp)
+ movdqa %xmm1, 64(%rsp)
+ movdqa %xmm2, 80(%rsp)
+ movdqa %xmm3, 96(%rsp)
+ movdqa %xmm4, 112(%rsp)
+ movdqa %xmm5, 128(%rsp)
+ movdqa %xmm6, 144(%rsp)
+ movdqa %xmm7, 160(%rsp)
+ jmp Lret_from_save_sse
+
+LUW9:
+.section __TEXT,__eh_frame,coalesced,no_toc+strip_static_syms+live_support
+EH_frame1:
+ .set L$set$0,LECIE1-LSCIE1 /* CIE Length */
+ .long L$set$0
+LSCIE1:
+ .long 0x0 /* CIE Identifier Tag */
+ .byte 0x1 /* CIE Version */
+ .ascii "zR\0" /* CIE Augmentation */
+ .byte 0x1 /* uleb128 0x1; CIE Code Alignment Factor */
+ .byte 0x78 /* sleb128 -8; CIE Data Alignment Factor */
+ .byte 0x10 /* CIE RA Column */
+ .byte 0x1 /* uleb128 0x1; Augmentation size */
+ .byte 0x10 /* FDE Encoding (pcrel sdata4) */
+ .byte 0xc /* DW_CFA_def_cfa, %rsp offset 8 */
+ .byte 0x7 /* uleb128 0x7 */
+ .byte 0x8 /* uleb128 0x8 */
+ .byte 0x90 /* DW_CFA_offset, column 0x10 */
+ .byte 0x1
+ .align 3
+LECIE1:
+ .globl _ffi_call_unix64.eh
+_ffi_call_unix64.eh:
+LSFDE1:
+ .set L$set$1,LEFDE1-LASFDE1 /* FDE Length */
+ .long L$set$1
+LASFDE1:
+ .long LASFDE1-EH_frame1 /* FDE CIE offset */
+ .quad LUW0-. /* FDE initial location */
+ .set L$set$2,LUW4-LUW0 /* FDE address range */
+ .quad L$set$2
+ .byte 0x0 /* Augmentation size */
+ .byte 0x4 /* DW_CFA_advance_loc4 */
+ .set L$set$3,LUW1-LUW0
+ .long L$set$3
+
+ /* New stack frame based off rbp. This is a itty bit of unwind
+ trickery in that the CFA *has* changed. There is no easy way
+ to describe it correctly on entry to the function. Fortunately,
+ it doesn't matter too much since at all points we can correctly
+ unwind back to ffi_call. Note that the location to which we
+ moved the return address is (the new) CFA-8, so from the
+ perspective of the unwind info, it hasn't moved. */
+ .byte 0xc /* DW_CFA_def_cfa, %rbp offset 32 */
+ .byte 0x6
+ .byte 0x20
+ .byte 0x80+6 /* DW_CFA_offset, %rbp offset 2*-8 */
+ .byte 0x2
+ .byte 0xa /* DW_CFA_remember_state */
+
+ .byte 0x4 /* DW_CFA_advance_loc4 */
+ .set L$set$4,LUW2-LUW1
+ .long L$set$4
+ .byte 0xc /* DW_CFA_def_cfa, %rsp offset 8 */
+ .byte 0x7
+ .byte 0x8
+ .byte 0xc0+6 /* DW_CFA_restore, %rbp */
+
+ .byte 0x4 /* DW_CFA_advance_loc4 */
+ .set L$set$5,LUW3-LUW2
+ .long L$set$5
+ .byte 0xb /* DW_CFA_restore_state */
+
+ .align 3
+LEFDE1:
+ .globl _ffi_closure_unix64.eh
+_ffi_closure_unix64.eh:
+LSFDE3:
+ .set L$set$6,LEFDE3-LASFDE3 /* FDE Length */
+ .long L$set$6
+LASFDE3:
+ .long LASFDE3-EH_frame1 /* FDE CIE offset */
+ .quad LUW5-. /* FDE initial location */
+ .set L$set$7,LUW9-LUW5 /* FDE address range */
+ .quad L$set$7
+ .byte 0x0 /* Augmentation size */
+
+ .byte 0x4 /* DW_CFA_advance_loc4 */
+ .set L$set$8,LUW6-LUW5
+ .long L$set$8
+ .byte 0xe /* DW_CFA_def_cfa_offset */
+ .byte 208,1 /* uleb128 208 */
+ .byte 0xa /* DW_CFA_remember_state */
+
+ .byte 0x4 /* DW_CFA_advance_loc4 */
+ .set L$set$9,LUW7-LUW6
+ .long L$set$9
+ .byte 0xe /* DW_CFA_def_cfa_offset */
+ .byte 0x8
+
+ .byte 0x4 /* DW_CFA_advance_loc4 */
+ .set L$set$10,LUW8-LUW7
+ .long L$set$10
+ .byte 0xb /* DW_CFA_restore_state */
+
+ .align 3
+LEFDE3:
+ .subsections_via_symbols
+
+#endif /* __x86_64__ */
diff --git a/jni/ruby/ext/fiddle/libffi-3.2.1/src/x86/ffi.c b/jni/ruby/ext/fiddle/libffi-3.2.1/src/x86/ffi.c
new file mode 100644
index 0000000..4c68dd5
--- /dev/null
+++ b/jni/ruby/ext/fiddle/libffi-3.2.1/src/x86/ffi.c
@@ -0,0 +1,935 @@
+/* -----------------------------------------------------------------------
+ ffi.c - Copyright (c) 1996, 1998, 1999, 2001, 2007, 2008 Red Hat, Inc.
+ Copyright (c) 2002 Ranjit Mathew
+ Copyright (c) 2002 Bo Thorsen
+ Copyright (c) 2002 Roger Sayle
+ Copyright (C) 2008, 2010 Free Software Foundation, Inc.
+
+ x86 Foreign Function Interface
+
+ Permission is hereby granted, free of charge, to any person obtaining
+ a copy of this software and associated documentation files (the
+ ``Software''), to deal in the Software without restriction, including
+ without limitation the rights to use, copy, modify, merge, publish,
+ distribute, sublicense, and/or sell copies of the Software, and to
+ permit persons to whom the Software is furnished to do so, subject to
+ the following conditions:
+
+ The above copyright notice and this permission notice shall be included
+ in all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND,
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+ HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ DEALINGS IN THE SOFTWARE.
+ ----------------------------------------------------------------------- */
+
+#if !defined(__x86_64__) || defined(_WIN64) || defined(__CYGWIN__)
+
+#ifdef _WIN64
+#include <windows.h>
+#endif
+
+#include <ffi.h>
+#include <ffi_common.h>
+
+#include <stdlib.h>
+
+
+/* ffi_prep_args is called by the assembly routine once stack space
+ has been allocated for the function's arguments */
+
+unsigned int ffi_prep_args(char *stack, extended_cif *ecif);
+unsigned int ffi_prep_args(char *stack, extended_cif *ecif)
+{
+ register unsigned int i;
+ register void **p_argv;
+ register char *argp;
+ register ffi_type **p_arg;
+#ifndef X86_WIN64
+ const int cabi = ecif->cif->abi;
+ const int dir = (cabi == FFI_PASCAL || cabi == FFI_REGISTER) ? -1 : +1;
+ unsigned int stack_args_count = 0;
+ void *p_stack_data[3];
+ char *argp2 = stack;
+#else
+ #define dir 1
+#endif
+
+ argp = stack;
+
+ if ((ecif->cif->flags == FFI_TYPE_STRUCT
+ || ecif->cif->flags == FFI_TYPE_MS_STRUCT)
+#ifdef X86_WIN64
+ && ((ecif->cif->rtype->size & (1 | 2 | 4 | 8)) == 0)
+#endif
+ )
+ {
+#ifndef X86_WIN64
+ /* For fastcall/thiscall/register this is first register-passed
+ argument. */
+ if (cabi == FFI_THISCALL || cabi == FFI_FASTCALL || cabi == FFI_REGISTER)
+ {
+ p_stack_data[stack_args_count] = argp;
+ ++stack_args_count;
+ }
+#endif
+
+ *(void **) argp = ecif->rvalue;
+ argp += sizeof(void*);
+ }
+
+ p_arg = ecif->cif->arg_types;
+ p_argv = ecif->avalue;
+ if (dir < 0)
+ {
+ const int nargs = ecif->cif->nargs - 1;
+ if (nargs > 0)
+ {
+ p_arg += nargs;
+ p_argv += nargs;
+ }
+ }
+
+ for (i = ecif->cif->nargs;
+ i != 0;
+ i--, p_arg += dir, p_argv += dir)
+ {
+ size_t z;
+
+ /* Align if necessary */
+ if ((sizeof(void*) - 1) & (size_t) argp)
+ argp = (char *) ALIGN(argp, sizeof(void*));
+
+ z = (*p_arg)->size;
+
+#ifdef X86_WIN64
+ if (z > FFI_SIZEOF_ARG
+ || ((*p_arg)->type == FFI_TYPE_STRUCT
+ && (z & (1 | 2 | 4 | 8)) == 0)
+#if FFI_TYPE_DOUBLE != FFI_TYPE_LONGDOUBLE
+ || ((*p_arg)->type == FFI_TYPE_LONGDOUBLE)
+#endif
+ )
+ {
+ z = FFI_SIZEOF_ARG;
+ *(void **)argp = *p_argv;
+ }
+ else if ((*p_arg)->type == FFI_TYPE_FLOAT)
+ {
+ memcpy(argp, *p_argv, z);
+ }
+ else
+#endif
+ if (z < FFI_SIZEOF_ARG)
+ {
+ z = FFI_SIZEOF_ARG;
+ switch ((*p_arg)->type)
+ {
+ case FFI_TYPE_SINT8:
+ *(ffi_sarg *) argp = (ffi_sarg)*(SINT8 *)(* p_argv);
+ break;
+
+ case FFI_TYPE_UINT8:
+ *(ffi_arg *) argp = (ffi_arg)*(UINT8 *)(* p_argv);
+ break;
+
+ case FFI_TYPE_SINT16:
+ *(ffi_sarg *) argp = (ffi_sarg)*(SINT16 *)(* p_argv);
+ break;
+
+ case FFI_TYPE_UINT16:
+ *(ffi_arg *) argp = (ffi_arg)*(UINT16 *)(* p_argv);
+ break;
+
+ case FFI_TYPE_SINT32:
+ *(ffi_sarg *) argp = (ffi_sarg)*(SINT32 *)(* p_argv);
+ break;
+
+ case FFI_TYPE_UINT32:
+ *(ffi_arg *) argp = (ffi_arg)*(UINT32 *)(* p_argv);
+ break;
+
+ case FFI_TYPE_STRUCT:
+ *(ffi_arg *) argp = *(ffi_arg *)(* p_argv);
+ break;
+
+ default:
+ FFI_ASSERT(0);
+ }
+ }
+ else
+ {
+ memcpy(argp, *p_argv, z);
+ }
+
+#ifndef X86_WIN64
+ /* For thiscall/fastcall/register convention register-passed arguments
+ are the first two none-floating-point arguments with a size
+ smaller or equal to sizeof (void*). */
+ if ((z == FFI_SIZEOF_ARG)
+ && ((cabi == FFI_REGISTER)
+ || (cabi == FFI_THISCALL && stack_args_count < 1)
+ || (cabi == FFI_FASTCALL && stack_args_count < 2))
+ && ((*p_arg)->type != FFI_TYPE_FLOAT && (*p_arg)->type != FFI_TYPE_STRUCT)
+ )
+ {
+ if (dir < 0 && stack_args_count > 2)
+ {
+ /* Iterating arguments backwards, so first register-passed argument
+ will be passed last. Shift temporary values to make place. */
+ p_stack_data[0] = p_stack_data[1];
+ p_stack_data[1] = p_stack_data[2];
+ stack_args_count = 2;
+ }
+
+ p_stack_data[stack_args_count] = argp;
+ ++stack_args_count;
+ }
+#endif
+
+#ifdef X86_WIN64
+ argp += (z + sizeof(void*) - 1) & ~(sizeof(void*) - 1);
+#else
+ argp += z;
+#endif
+ }
+
+#ifndef X86_WIN64
+ /* We need to move the register-passed arguments for thiscall/fastcall/register
+ on top of stack, so that those can be moved to registers by call-handler. */
+ if (stack_args_count > 0)
+ {
+ if (dir < 0 && stack_args_count > 1)
+ {
+ /* Reverse order if iterating arguments backwards */
+ ffi_arg tmp = *(ffi_arg*) p_stack_data[0];
+ *(ffi_arg*) p_stack_data[0] = *(ffi_arg*) p_stack_data[stack_args_count - 1];
+ *(ffi_arg*) p_stack_data[stack_args_count - 1] = tmp;
+ }
+
+ int i;
+ for (i = 0; i < stack_args_count; i++)
+ {
+ if (p_stack_data[i] != argp2)
+ {
+ ffi_arg tmp = *(ffi_arg*) p_stack_data[i];
+ memmove (argp2 + FFI_SIZEOF_ARG, argp2, (size_t) ((char*) p_stack_data[i] - (char*)argp2));
+ *(ffi_arg *) argp2 = tmp;
+ }
+
+ argp2 += FFI_SIZEOF_ARG;
+ }
+ }
+
+ return stack_args_count;
+#endif
+ return 0;
+}
+
+/* Perform machine dependent cif processing */
+ffi_status ffi_prep_cif_machdep(ffi_cif *cif)
+{
+ unsigned int i;
+ ffi_type **ptr;
+
+ /* Set the return type flag */
+ switch (cif->rtype->type)
+ {
+ case FFI_TYPE_VOID:
+ case FFI_TYPE_UINT8:
+ case FFI_TYPE_UINT16:
+ case FFI_TYPE_SINT8:
+ case FFI_TYPE_SINT16:
+#ifdef X86_WIN64
+ case FFI_TYPE_UINT32:
+ case FFI_TYPE_SINT32:
+#endif
+ case FFI_TYPE_SINT64:
+ case FFI_TYPE_FLOAT:
+ case FFI_TYPE_DOUBLE:
+#ifndef X86_WIN64
+#if FFI_TYPE_DOUBLE != FFI_TYPE_LONGDOUBLE
+ case FFI_TYPE_LONGDOUBLE:
+#endif
+#endif
+ cif->flags = (unsigned) cif->rtype->type;
+ break;
+
+ case FFI_TYPE_UINT64:
+#ifdef X86_WIN64
+ case FFI_TYPE_POINTER:
+#endif
+ cif->flags = FFI_TYPE_SINT64;
+ break;
+
+ case FFI_TYPE_STRUCT:
+#ifndef X86
+ if (cif->rtype->size == 1)
+ {
+ cif->flags = FFI_TYPE_SMALL_STRUCT_1B; /* same as char size */
+ }
+ else if (cif->rtype->size == 2)
+ {
+ cif->flags = FFI_TYPE_SMALL_STRUCT_2B; /* same as short size */
+ }
+ else if (cif->rtype->size == 4)
+ {
+#ifdef X86_WIN64
+ cif->flags = FFI_TYPE_SMALL_STRUCT_4B;
+#else
+ cif->flags = FFI_TYPE_INT; /* same as int type */
+#endif
+ }
+ else if (cif->rtype->size == 8)
+ {
+ cif->flags = FFI_TYPE_SINT64; /* same as int64 type */
+ }
+ else
+#endif
+ {
+#ifdef X86_WIN32
+ if (cif->abi == FFI_MS_CDECL)
+ cif->flags = FFI_TYPE_MS_STRUCT;
+ else
+#endif
+ cif->flags = FFI_TYPE_STRUCT;
+ /* allocate space for return value pointer */
+ cif->bytes += ALIGN(sizeof(void*), FFI_SIZEOF_ARG);
+ }
+ break;
+
+ default:
+#ifdef X86_WIN64
+ cif->flags = FFI_TYPE_SINT64;
+ break;
+ case FFI_TYPE_INT:
+ cif->flags = FFI_TYPE_SINT32;
+#else
+ cif->flags = FFI_TYPE_INT;
+#endif
+ break;
+ }
+
+ for (ptr = cif->arg_types, i = cif->nargs; i > 0; i--, ptr++)
+ {
+ if (((*ptr)->alignment - 1) & cif->bytes)
+ cif->bytes = ALIGN(cif->bytes, (*ptr)->alignment);
+ cif->bytes += (unsigned)ALIGN((*ptr)->size, FFI_SIZEOF_ARG);
+ }
+
+#ifdef X86_WIN64
+ /* ensure space for storing four registers */
+ cif->bytes += 4 * FFI_SIZEOF_ARG;
+#endif
+
+#ifndef X86_WIN32
+#ifndef X86_WIN64
+ if (cif->abi == FFI_SYSV || cif->abi == FFI_UNIX64)
+#endif
+ cif->bytes = (cif->bytes + 15) & ~0xF;
+#endif
+
+ return FFI_OK;
+}
+
+#ifdef X86_WIN64
+extern int
+ffi_call_win64(unsigned int (*)(char *, extended_cif *), extended_cif *,
+ unsigned, unsigned, unsigned *, void (*fn)(void));
+#else
+extern void
+ffi_call_win32(unsigned int (*)(char *, extended_cif *), extended_cif *,
+ unsigned, unsigned, unsigned, unsigned *, void (*fn)(void));
+extern void ffi_call_SYSV(void (*)(char *, extended_cif *), extended_cif *,
+ unsigned, unsigned, unsigned *, void (*fn)(void));
+#endif
+
+void ffi_call(ffi_cif *cif, void (*fn)(void), void *rvalue, void **avalue)
+{
+ extended_cif ecif;
+
+ ecif.cif = cif;
+ ecif.avalue = avalue;
+
+ /* If the return value is a struct and we don't have a return */
+ /* value address then we need to make one */
+
+#ifdef X86_WIN64
+ if (rvalue == NULL
+ && cif->flags == FFI_TYPE_STRUCT
+ && ((cif->rtype->size & (1 | 2 | 4 | 8)) == 0))
+ {
+ ecif.rvalue = alloca((cif->rtype->size + 0xF) & ~0xF);
+ }
+#else
+ if (rvalue == NULL
+ && (cif->flags == FFI_TYPE_STRUCT
+ || cif->flags == FFI_TYPE_MS_STRUCT))
+ {
+ ecif.rvalue = alloca(cif->rtype->size);
+ }
+#endif
+ else
+ ecif.rvalue = rvalue;
+
+
+ switch (cif->abi)
+ {
+#ifdef X86_WIN64
+ case FFI_WIN64:
+ ffi_call_win64(ffi_prep_args, &ecif, cif->bytes,
+ cif->flags, ecif.rvalue, fn);
+ break;
+#else
+#ifndef X86_WIN32
+ case FFI_SYSV:
+ ffi_call_SYSV(ffi_prep_args, &ecif, cif->bytes, cif->flags, ecif.rvalue,
+ fn);
+ break;
+#else
+ case FFI_SYSV:
+ case FFI_MS_CDECL:
+#endif
+ case FFI_STDCALL:
+ case FFI_THISCALL:
+ case FFI_FASTCALL:
+ case FFI_PASCAL:
+ case FFI_REGISTER:
+ ffi_call_win32(ffi_prep_args, &ecif, cif->abi, cif->bytes, cif->flags,
+ ecif.rvalue, fn);
+ break;
+#endif
+ default:
+ FFI_ASSERT(0);
+ break;
+ }
+}
+
+
+/** private members **/
+
+/* The following __attribute__((regparm(1))) decorations will have no effect
+ on MSVC or SUNPRO_C -- standard conventions apply. */
+static unsigned int ffi_prep_incoming_args (char *stack, void **ret,
+ void** args, ffi_cif* cif);
+void FFI_HIDDEN ffi_closure_SYSV (ffi_closure *)
+ __attribute__ ((regparm(1)));
+unsigned int FFI_HIDDEN ffi_closure_SYSV_inner (ffi_closure *, void **, void *)
+ __attribute__ ((regparm(1)));
+unsigned int FFI_HIDDEN ffi_closure_WIN32_inner (ffi_closure *, void **, void *)
+ __attribute__ ((regparm(1)));
+void FFI_HIDDEN ffi_closure_raw_SYSV (ffi_raw_closure *)
+ __attribute__ ((regparm(1)));
+#ifdef X86_WIN32
+void FFI_HIDDEN ffi_closure_raw_THISCALL (ffi_raw_closure *)
+ __attribute__ ((regparm(1)));
+#endif
+#ifndef X86_WIN64
+void FFI_HIDDEN ffi_closure_STDCALL (ffi_closure *);
+void FFI_HIDDEN ffi_closure_THISCALL (ffi_closure *);
+void FFI_HIDDEN ffi_closure_FASTCALL (ffi_closure *);
+void FFI_HIDDEN ffi_closure_REGISTER (ffi_closure *);
+#else
+void FFI_HIDDEN ffi_closure_win64 (ffi_closure *);
+#endif
+
+/* This function is jumped to by the trampoline */
+
+#ifdef X86_WIN64
+void * FFI_HIDDEN
+ffi_closure_win64_inner (ffi_closure *closure, void *args) {
+ ffi_cif *cif;
+ void **arg_area;
+ void *result;
+ void *resp = &result;
+
+ cif = closure->cif;
+ arg_area = (void**) alloca (cif->nargs * sizeof (void*));
+
+ /* this call will initialize ARG_AREA, such that each
+ * element in that array points to the corresponding
+ * value on the stack; and if the function returns
+ * a structure, it will change RESP to point to the
+ * structure return address. */
+
+ ffi_prep_incoming_args(args, &resp, arg_area, cif);
+
+ (closure->fun) (cif, resp, arg_area, closure->user_data);
+
+ /* The result is returned in rax. This does the right thing for
+ result types except for floats; we have to 'mov xmm0, rax' in the
+ caller to correct this.
+ TODO: structure sizes of 3 5 6 7 are returned by reference, too!!!
+ */
+ return cif->rtype->size > sizeof(void *) ? resp : *(void **)resp;
+}
+
+#else
+unsigned int FFI_HIDDEN __attribute__ ((regparm(1)))
+ffi_closure_SYSV_inner (ffi_closure *closure, void **respp, void *args)
+{
+ /* our various things... */
+ ffi_cif *cif;
+ void **arg_area;
+
+ cif = closure->cif;
+ arg_area = (void**) alloca (cif->nargs * sizeof (void*));
+
+ /* this call will initialize ARG_AREA, such that each
+ * element in that array points to the corresponding
+ * value on the stack; and if the function returns
+ * a structure, it will change RESP to point to the
+ * structure return address. */
+
+ ffi_prep_incoming_args(args, respp, arg_area, cif);
+
+ (closure->fun) (cif, *respp, arg_area, closure->user_data);
+
+ return cif->flags;
+}
+
+unsigned int FFI_HIDDEN __attribute__ ((regparm(1)))
+ffi_closure_WIN32_inner (ffi_closure *closure, void **respp, void *args)
+{
+ /* our various things... */
+ ffi_cif *cif;
+ void **arg_area;
+ unsigned int ret;
+
+ cif = closure->cif;
+ arg_area = (void**) alloca (cif->nargs * sizeof (void*));
+
+ /* this call will initialize ARG_AREA, such that each
+ * element in that array points to the corresponding
+ * value on the stack; and if the function returns
+ * a structure, it will change RESP to point to the
+ * structure return address. */
+
+ ret = ffi_prep_incoming_args(args, respp, arg_area, cif);
+
+ (closure->fun) (cif, *respp, arg_area, closure->user_data);
+
+ return ret;
+}
+#endif /* !X86_WIN64 */
+
+static unsigned int
+ffi_prep_incoming_args(char *stack, void **rvalue, void **avalue,
+ ffi_cif *cif)
+{
+ register unsigned int i;
+ register void **p_argv;
+ register char *argp;
+ register ffi_type **p_arg;
+#ifndef X86_WIN64
+ const int cabi = cif->abi;
+ const int dir = (cabi == FFI_PASCAL || cabi == FFI_REGISTER) ? -1 : +1;
+ const unsigned int max_stack_count = (cabi == FFI_THISCALL) ? 1
+ : (cabi == FFI_FASTCALL) ? 2
+ : (cabi == FFI_REGISTER) ? 3
+ : 0;
+ unsigned int passed_regs = 0;
+ void *p_stack_data[3] = { stack - 1 };
+#else
+ #define dir 1
+#endif
+
+ argp = stack;
+#ifndef X86_WIN64
+ argp += max_stack_count * FFI_SIZEOF_ARG;
+#endif
+
+ if ((cif->flags == FFI_TYPE_STRUCT
+ || cif->flags == FFI_TYPE_MS_STRUCT)
+#ifdef X86_WIN64
+ && ((cif->rtype->size & (1 | 2 | 4 | 8)) == 0)
+#endif
+ )
+ {
+#ifndef X86_WIN64
+ if (passed_regs < max_stack_count)
+ {
+ *rvalue = *(void**) (stack + (passed_regs*FFI_SIZEOF_ARG));
+ ++passed_regs;
+ }
+ else
+#endif
+ {
+ *rvalue = *(void **) argp;
+ argp += sizeof(void *);
+ }
+ }
+
+#ifndef X86_WIN64
+ /* Do register arguments first */
+ for (i = 0, p_arg = cif->arg_types;
+ i < cif->nargs && passed_regs < max_stack_count;
+ i++, p_arg++)
+ {
+ if ((*p_arg)->type == FFI_TYPE_FLOAT
+ || (*p_arg)->type == FFI_TYPE_STRUCT)
+ continue;
+
+ size_t sz = (*p_arg)->size;
+ if(sz == 0 || sz > FFI_SIZEOF_ARG)
+ continue;
+
+ p_stack_data[passed_regs] = avalue + i;
+ avalue[i] = stack + (passed_regs*FFI_SIZEOF_ARG);
+ ++passed_regs;
+ }
+#endif
+
+ p_arg = cif->arg_types;
+ p_argv = avalue;
+ if (dir < 0)
+ {
+ const int nargs = cif->nargs - 1;
+ if (nargs > 0)
+ {
+ p_arg += nargs;
+ p_argv += nargs;
+ }
+ }
+
+ for (i = cif->nargs;
+ i != 0;
+ i--, p_arg += dir, p_argv += dir)
+ {
+ size_t z;
+
+ /* Align if necessary */
+ if ((sizeof(void*) - 1) & (size_t) argp)
+ argp = (char *) ALIGN(argp, sizeof(void*));
+
+ z = (*p_arg)->size;
+
+#ifdef X86_WIN64
+ if (z > FFI_SIZEOF_ARG
+ || ((*p_arg)->type == FFI_TYPE_STRUCT
+ && (z & (1 | 2 | 4 | 8)) == 0)
+#if FFI_TYPE_DOUBLE != FFI_TYPE_LONGDOUBLE
+ || ((*p_arg)->type == FFI_TYPE_LONGDOUBLE)
+#endif
+ )
+ {
+ z = FFI_SIZEOF_ARG;
+ *p_argv = *(void **)argp;
+ }
+ else
+#else
+ if (passed_regs > 0
+ && z <= FFI_SIZEOF_ARG
+ && (p_argv == p_stack_data[0]
+ || p_argv == p_stack_data[1]
+ || p_argv == p_stack_data[2]))
+ {
+ /* Already assigned a register value */
+ continue;
+ }
+ else
+#endif
+ {
+ /* because we're little endian, this is what it turns into. */
+ *p_argv = (void*) argp;
+ }
+
+#ifdef X86_WIN64
+ argp += (z + sizeof(void*) - 1) & ~(sizeof(void*) - 1);
+#else
+ argp += z;
+#endif
+ }
+
+ return (int)((size_t)argp - (size_t)stack);
+}
+
+#define FFI_INIT_TRAMPOLINE_WIN64(TRAMP,FUN,CTX,MASK) \
+{ unsigned char *__tramp = (unsigned char*)(TRAMP); \
+ void* __fun = (void*)(FUN); \
+ void* __ctx = (void*)(CTX); \
+ *(unsigned char*) &__tramp[0] = 0x41; \
+ *(unsigned char*) &__tramp[1] = 0xbb; \
+ *(unsigned int*) &__tramp[2] = MASK; /* mov $mask, %r11 */ \
+ *(unsigned char*) &__tramp[6] = 0x48; \
+ *(unsigned char*) &__tramp[7] = 0xb8; \
+ *(void**) &__tramp[8] = __ctx; /* mov __ctx, %rax */ \
+ *(unsigned char *) &__tramp[16] = 0x49; \
+ *(unsigned char *) &__tramp[17] = 0xba; \
+ *(void**) &__tramp[18] = __fun; /* mov __fun, %r10 */ \
+ *(unsigned char *) &__tramp[26] = 0x41; \
+ *(unsigned char *) &__tramp[27] = 0xff; \
+ *(unsigned char *) &__tramp[28] = 0xe2; /* jmp %r10 */ \
+ }
+
+/* How to make a trampoline. Derived from gcc/config/i386/i386.c. */
+
+#define FFI_INIT_TRAMPOLINE(TRAMP,FUN,CTX) \
+{ unsigned char *__tramp = (unsigned char*)(TRAMP); \
+ unsigned int __fun = (unsigned int)(FUN); \
+ unsigned int __ctx = (unsigned int)(CTX); \
+ unsigned int __dis = __fun - (__ctx + 10); \
+ *(unsigned char*) &__tramp[0] = 0xb8; \
+ *(unsigned int*) &__tramp[1] = __ctx; /* movl __ctx, %eax */ \
+ *(unsigned char*) &__tramp[5] = 0xe9; \
+ *(unsigned int*) &__tramp[6] = __dis; /* jmp __fun */ \
+ }
+
+#define FFI_INIT_TRAMPOLINE_RAW_THISCALL(TRAMP,FUN,CTX,SIZE) \
+{ unsigned char *__tramp = (unsigned char*)(TRAMP); \
+ unsigned int __fun = (unsigned int)(FUN); \
+ unsigned int __ctx = (unsigned int)(CTX); \
+ unsigned int __dis = __fun - (__ctx + 49); \
+ unsigned short __size = (unsigned short)(SIZE); \
+ *(unsigned int *) &__tramp[0] = 0x8324048b; /* mov (%esp), %eax */ \
+ *(unsigned int *) &__tramp[4] = 0x4c890cec; /* sub $12, %esp */ \
+ *(unsigned int *) &__tramp[8] = 0x04890424; /* mov %ecx, 4(%esp) */ \
+ *(unsigned char*) &__tramp[12] = 0x24; /* mov %eax, (%esp) */ \
+ *(unsigned char*) &__tramp[13] = 0xb8; \
+ *(unsigned int *) &__tramp[14] = __size; /* mov __size, %eax */ \
+ *(unsigned int *) &__tramp[18] = 0x08244c8d; /* lea 8(%esp), %ecx */ \
+ *(unsigned int *) &__tramp[22] = 0x4802e8c1; /* shr $2, %eax ; dec %eax */ \
+ *(unsigned short*) &__tramp[26] = 0x0b74; /* jz 1f */ \
+ *(unsigned int *) &__tramp[28] = 0x8908518b; /* 2b: mov 8(%ecx), %edx */ \
+ *(unsigned int *) &__tramp[32] = 0x04c18311; /* mov %edx, (%ecx) ; add $4, %ecx */ \
+ *(unsigned char*) &__tramp[36] = 0x48; /* dec %eax */ \
+ *(unsigned short*) &__tramp[37] = 0xf575; /* jnz 2b ; 1f: */ \
+ *(unsigned char*) &__tramp[39] = 0xb8; \
+ *(unsigned int*) &__tramp[40] = __ctx; /* movl __ctx, %eax */ \
+ *(unsigned char *) &__tramp[44] = 0xe8; \
+ *(unsigned int*) &__tramp[45] = __dis; /* call __fun */ \
+ *(unsigned char*) &__tramp[49] = 0xc2; /* ret */ \
+ *(unsigned short*) &__tramp[50] = (__size + 8); /* ret (__size + 8) */ \
+ }
+
+#define FFI_INIT_TRAMPOLINE_WIN32(TRAMP,FUN,CTX) \
+{ unsigned char *__tramp = (unsigned char*)(TRAMP); \
+ unsigned int __fun = (unsigned int)(FUN); \
+ unsigned int __ctx = (unsigned int)(CTX); \
+ unsigned int __dis = __fun - (__ctx + 10); \
+ *(unsigned char*) &__tramp[0] = 0x68; \
+ *(unsigned int*) &__tramp[1] = __ctx; /* push __ctx */ \
+ *(unsigned char*) &__tramp[5] = 0xe9; \
+ *(unsigned int*) &__tramp[6] = __dis; /* jmp __fun */ \
+ }
+
+/* the cif must already be prep'ed */
+
+ffi_status
+ffi_prep_closure_loc (ffi_closure* closure,
+ ffi_cif* cif,
+ void (*fun)(ffi_cif*,void*,void**,void*),
+ void *user_data,
+ void *codeloc)
+{
+#ifdef X86_WIN64
+#define ISFLOAT(IDX) (cif->arg_types[IDX]->type == FFI_TYPE_FLOAT || cif->arg_types[IDX]->type == FFI_TYPE_DOUBLE)
+#define FLAG(IDX) (cif->nargs>(IDX)&&ISFLOAT(IDX)?(1<<(IDX)):0)
+ if (cif->abi == FFI_WIN64)
+ {
+ int mask = FLAG(0)|FLAG(1)|FLAG(2)|FLAG(3);
+ FFI_INIT_TRAMPOLINE_WIN64 (&closure->tramp[0],
+ &ffi_closure_win64,
+ codeloc, mask);
+ /* make sure we can execute here */
+ }
+#else
+ if (cif->abi == FFI_SYSV)
+ {
+ FFI_INIT_TRAMPOLINE (&closure->tramp[0],
+ &ffi_closure_SYSV,
+ (void*)codeloc);
+ }
+ else if (cif->abi == FFI_REGISTER)
+ {
+ FFI_INIT_TRAMPOLINE_WIN32 (&closure->tramp[0],
+ &ffi_closure_REGISTER,
+ (void*)codeloc);
+ }
+ else if (cif->abi == FFI_FASTCALL)
+ {
+ FFI_INIT_TRAMPOLINE_WIN32 (&closure->tramp[0],
+ &ffi_closure_FASTCALL,
+ (void*)codeloc);
+ }
+ else if (cif->abi == FFI_THISCALL)
+ {
+ FFI_INIT_TRAMPOLINE_WIN32 (&closure->tramp[0],
+ &ffi_closure_THISCALL,
+ (void*)codeloc);
+ }
+ else if (cif->abi == FFI_STDCALL || cif->abi == FFI_PASCAL)
+ {
+ FFI_INIT_TRAMPOLINE_WIN32 (&closure->tramp[0],
+ &ffi_closure_STDCALL,
+ (void*)codeloc);
+ }
+#ifdef X86_WIN32
+ else if (cif->abi == FFI_MS_CDECL)
+ {
+ FFI_INIT_TRAMPOLINE (&closure->tramp[0],
+ &ffi_closure_SYSV,
+ (void*)codeloc);
+ }
+#endif /* X86_WIN32 */
+#endif /* !X86_WIN64 */
+ else
+ {
+ return FFI_BAD_ABI;
+ }
+
+ closure->cif = cif;
+ closure->user_data = user_data;
+ closure->fun = fun;
+
+ return FFI_OK;
+}
+
+/* ------- Native raw API support -------------------------------- */
+
+#if !FFI_NO_RAW_API
+
+ffi_status
+ffi_prep_raw_closure_loc (ffi_raw_closure* closure,
+ ffi_cif* cif,
+ void (*fun)(ffi_cif*,void*,ffi_raw*,void*),
+ void *user_data,
+ void *codeloc)
+{
+ int i;
+
+ if (cif->abi != FFI_SYSV
+#ifdef X86_WIN32
+ && cif->abi != FFI_THISCALL
+#endif
+ )
+ return FFI_BAD_ABI;
+
+ /* we currently don't support certain kinds of arguments for raw
+ closures. This should be implemented by a separate assembly
+ language routine, since it would require argument processing,
+ something we don't do now for performance. */
+
+ for (i = cif->nargs-1; i >= 0; i--)
+ {
+ FFI_ASSERT (cif->arg_types[i]->type != FFI_TYPE_STRUCT);
+ FFI_ASSERT (cif->arg_types[i]->type != FFI_TYPE_LONGDOUBLE);
+ }
+
+#ifdef X86_WIN32
+ if (cif->abi == FFI_SYSV)
+ {
+#endif
+ FFI_INIT_TRAMPOLINE (&closure->tramp[0], &ffi_closure_raw_SYSV,
+ codeloc);
+#ifdef X86_WIN32
+ }
+ else if (cif->abi == FFI_THISCALL)
+ {
+ FFI_INIT_TRAMPOLINE_RAW_THISCALL (&closure->tramp[0], &ffi_closure_raw_THISCALL, codeloc, cif->bytes);
+ }
+#endif
+ closure->cif = cif;
+ closure->user_data = user_data;
+ closure->fun = fun;
+
+ return FFI_OK;
+}
+
+static unsigned int
+ffi_prep_args_raw(char *stack, extended_cif *ecif)
+{
+ const ffi_cif *cif = ecif->cif;
+ unsigned int i, passed_regs = 0;
+
+#ifndef X86_WIN64
+ const unsigned int abi = cif->abi;
+ const unsigned int max_regs = (abi == FFI_THISCALL) ? 1
+ : (abi == FFI_FASTCALL) ? 2
+ : (abi == FFI_REGISTER) ? 3
+ : 0;
+
+ if (cif->flags == FFI_TYPE_STRUCT)
+ ++passed_regs;
+
+ for (i = 0; i < cif->nargs && passed_regs <= max_regs; i++)
+ {
+ if (cif->arg_types[i]->type == FFI_TYPE_FLOAT
+ || cif->arg_types[i]->type == FFI_TYPE_STRUCT)
+ continue;
+
+ size_t sz = cif->arg_types[i]->size;
+ if (sz == 0 || sz > FFI_SIZEOF_ARG)
+ continue;
+
+ ++passed_regs;
+ }
+#endif
+
+ memcpy (stack, ecif->avalue, cif->bytes);
+ return passed_regs;
+}
+
+/* we borrow this routine from libffi (it must be changed, though, to
+ * actually call the function passed in the first argument. as of
+ * libffi-1.20, this is not the case.)
+ */
+
+void
+ffi_raw_call(ffi_cif *cif, void (*fn)(void), void *rvalue, ffi_raw *fake_avalue)
+{
+ extended_cif ecif;
+ void **avalue = (void **)fake_avalue;
+
+ ecif.cif = cif;
+ ecif.avalue = avalue;
+
+ /* If the return value is a struct and we don't have a return */
+ /* value address then we need to make one */
+
+ if (rvalue == NULL
+ && (cif->flags == FFI_TYPE_STRUCT
+ || cif->flags == FFI_TYPE_MS_STRUCT))
+ {
+ ecif.rvalue = alloca(cif->rtype->size);
+ }
+ else
+ ecif.rvalue = rvalue;
+
+
+ switch (cif->abi)
+ {
+#ifndef X86_WIN32
+ case FFI_SYSV:
+ ffi_call_SYSV(ffi_prep_args_raw, &ecif, cif->bytes, cif->flags,
+ ecif.rvalue, fn);
+ break;
+#else
+ case FFI_SYSV:
+ case FFI_MS_CDECL:
+#endif
+#ifndef X86_WIN64
+ case FFI_STDCALL:
+ case FFI_THISCALL:
+ case FFI_FASTCALL:
+ case FFI_PASCAL:
+ case FFI_REGISTER:
+ ffi_call_win32(ffi_prep_args_raw, &ecif, cif->abi, cif->bytes, cif->flags,
+ ecif.rvalue, fn);
+ break;
+#endif
+ default:
+ FFI_ASSERT(0);
+ break;
+ }
+}
+
+#endif
+
+#endif /* !__x86_64__ || X86_WIN64 */
+
diff --git a/jni/ruby/ext/fiddle/libffi-3.2.1/src/x86/ffi64.c b/jni/ruby/ext/fiddle/libffi-3.2.1/src/x86/ffi64.c
new file mode 100644
index 0000000..5a5e043
--- /dev/null
+++ b/jni/ruby/ext/fiddle/libffi-3.2.1/src/x86/ffi64.c
@@ -0,0 +1,676 @@
+/* -----------------------------------------------------------------------
+ ffi64.c - Copyright (c) 2013 The Written Word, Inc.
+ Copyright (c) 2011 Anthony Green
+ Copyright (c) 2008, 2010 Red Hat, Inc.
+ Copyright (c) 2002, 2007 Bo Thorsen <bo@suse.de>
+
+ x86-64 Foreign Function Interface
+
+ Permission is hereby granted, free of charge, to any person obtaining
+ a copy of this software and associated documentation files (the
+ ``Software''), to deal in the Software without restriction, including
+ without limitation the rights to use, copy, modify, merge, publish,
+ distribute, sublicense, and/or sell copies of the Software, and to
+ permit persons to whom the Software is furnished to do so, subject to
+ the following conditions:
+
+ The above copyright notice and this permission notice shall be included
+ in all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND,
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+ HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ DEALINGS IN THE SOFTWARE.
+ ----------------------------------------------------------------------- */
+
+#include <ffi.h>
+#include <ffi_common.h>
+
+#include <stdlib.h>
+#include <stdarg.h>
+
+#ifdef __x86_64__
+
+#define MAX_GPR_REGS 6
+#define MAX_SSE_REGS 8
+
+#if defined(__INTEL_COMPILER)
+#include "xmmintrin.h"
+#define UINT128 __m128
+#else
+#if defined(__SUNPRO_C)
+#include <sunmedia_types.h>
+#define UINT128 __m128i
+#else
+#define UINT128 __int128_t
+#endif
+#endif
+
+union big_int_union
+{
+ UINT32 i32;
+ UINT64 i64;
+ UINT128 i128;
+};
+
+struct register_args
+{
+ /* Registers for argument passing. */
+ UINT64 gpr[MAX_GPR_REGS];
+ union big_int_union sse[MAX_SSE_REGS];
+};
+
+extern void ffi_call_unix64 (void *args, unsigned long bytes, unsigned flags,
+ void *raddr, void (*fnaddr)(void), unsigned ssecount);
+
+/* All reference to register classes here is identical to the code in
+ gcc/config/i386/i386.c. Do *not* change one without the other. */
+
+/* Register class used for passing given 64bit part of the argument.
+ These represent classes as documented by the PS ABI, with the
+ exception of SSESF, SSEDF classes, that are basically SSE class,
+ just gcc will use SF or DFmode move instead of DImode to avoid
+ reformatting penalties.
+
+ Similary we play games with INTEGERSI_CLASS to use cheaper SImode moves
+ whenever possible (upper half does contain padding). */
+enum x86_64_reg_class
+ {
+ X86_64_NO_CLASS,
+ X86_64_INTEGER_CLASS,
+ X86_64_INTEGERSI_CLASS,
+ X86_64_SSE_CLASS,
+ X86_64_SSESF_CLASS,
+ X86_64_SSEDF_CLASS,
+ X86_64_SSEUP_CLASS,
+ X86_64_X87_CLASS,
+ X86_64_X87UP_CLASS,
+ X86_64_COMPLEX_X87_CLASS,
+ X86_64_MEMORY_CLASS
+ };
+
+#define MAX_CLASSES 4
+
+#define SSE_CLASS_P(X) ((X) >= X86_64_SSE_CLASS && X <= X86_64_SSEUP_CLASS)
+
+/* x86-64 register passing implementation. See x86-64 ABI for details. Goal
+ of this code is to classify each 8bytes of incoming argument by the register
+ class and assign registers accordingly. */
+
+/* Return the union class of CLASS1 and CLASS2.
+ See the x86-64 PS ABI for details. */
+
+static enum x86_64_reg_class
+merge_classes (enum x86_64_reg_class class1, enum x86_64_reg_class class2)
+{
+ /* Rule #1: If both classes are equal, this is the resulting class. */
+ if (class1 == class2)
+ return class1;
+
+ /* Rule #2: If one of the classes is NO_CLASS, the resulting class is
+ the other class. */
+ if (class1 == X86_64_NO_CLASS)
+ return class2;
+ if (class2 == X86_64_NO_CLASS)
+ return class1;
+
+ /* Rule #3: If one of the classes is MEMORY, the result is MEMORY. */
+ if (class1 == X86_64_MEMORY_CLASS || class2 == X86_64_MEMORY_CLASS)
+ return X86_64_MEMORY_CLASS;
+
+ /* Rule #4: If one of the classes is INTEGER, the result is INTEGER. */
+ if ((class1 == X86_64_INTEGERSI_CLASS && class2 == X86_64_SSESF_CLASS)
+ || (class2 == X86_64_INTEGERSI_CLASS && class1 == X86_64_SSESF_CLASS))
+ return X86_64_INTEGERSI_CLASS;
+ if (class1 == X86_64_INTEGER_CLASS || class1 == X86_64_INTEGERSI_CLASS
+ || class2 == X86_64_INTEGER_CLASS || class2 == X86_64_INTEGERSI_CLASS)
+ return X86_64_INTEGER_CLASS;
+
+ /* Rule #5: If one of the classes is X87, X87UP, or COMPLEX_X87 class,
+ MEMORY is used. */
+ if (class1 == X86_64_X87_CLASS
+ || class1 == X86_64_X87UP_CLASS
+ || class1 == X86_64_COMPLEX_X87_CLASS
+ || class2 == X86_64_X87_CLASS
+ || class2 == X86_64_X87UP_CLASS
+ || class2 == X86_64_COMPLEX_X87_CLASS)
+ return X86_64_MEMORY_CLASS;
+
+ /* Rule #6: Otherwise class SSE is used. */
+ return X86_64_SSE_CLASS;
+}
+
+/* Classify the argument of type TYPE and mode MODE.
+ CLASSES will be filled by the register class used to pass each word
+ of the operand. The number of words is returned. In case the parameter
+ should be passed in memory, 0 is returned. As a special case for zero
+ sized containers, classes[0] will be NO_CLASS and 1 is returned.
+
+ See the x86-64 PS ABI for details.
+*/
+static size_t
+classify_argument (ffi_type *type, enum x86_64_reg_class classes[],
+ size_t byte_offset)
+{
+ switch (type->type)
+ {
+ case FFI_TYPE_UINT8:
+ case FFI_TYPE_SINT8:
+ case FFI_TYPE_UINT16:
+ case FFI_TYPE_SINT16:
+ case FFI_TYPE_UINT32:
+ case FFI_TYPE_SINT32:
+ case FFI_TYPE_UINT64:
+ case FFI_TYPE_SINT64:
+ case FFI_TYPE_POINTER:
+ {
+ size_t size = byte_offset + type->size;
+
+ if (size <= 4)
+ {
+ classes[0] = X86_64_INTEGERSI_CLASS;
+ return 1;
+ }
+ else if (size <= 8)
+ {
+ classes[0] = X86_64_INTEGER_CLASS;
+ return 1;
+ }
+ else if (size <= 12)
+ {
+ classes[0] = X86_64_INTEGER_CLASS;
+ classes[1] = X86_64_INTEGERSI_CLASS;
+ return 2;
+ }
+ else if (size <= 16)
+ {
+ classes[0] = classes[1] = X86_64_INTEGERSI_CLASS;
+ return 2;
+ }
+ else
+ FFI_ASSERT (0);
+ }
+ case FFI_TYPE_FLOAT:
+ if (!(byte_offset % 8))
+ classes[0] = X86_64_SSESF_CLASS;
+ else
+ classes[0] = X86_64_SSE_CLASS;
+ return 1;
+ case FFI_TYPE_DOUBLE:
+ classes[0] = X86_64_SSEDF_CLASS;
+ return 1;
+#if FFI_TYPE_LONGDOUBLE != FFI_TYPE_DOUBLE
+ case FFI_TYPE_LONGDOUBLE:
+ classes[0] = X86_64_X87_CLASS;
+ classes[1] = X86_64_X87UP_CLASS;
+ return 2;
+#endif
+ case FFI_TYPE_STRUCT:
+ {
+ const size_t UNITS_PER_WORD = 8;
+ size_t words = (type->size + UNITS_PER_WORD - 1) / UNITS_PER_WORD;
+ ffi_type **ptr;
+ int i;
+ enum x86_64_reg_class subclasses[MAX_CLASSES];
+
+ /* If the struct is larger than 32 bytes, pass it on the stack. */
+ if (type->size > 32)
+ return 0;
+
+ for (i = 0; i < words; i++)
+ classes[i] = X86_64_NO_CLASS;
+
+ /* Zero sized arrays or structures are NO_CLASS. We return 0 to
+ signalize memory class, so handle it as special case. */
+ if (!words)
+ {
+ classes[0] = X86_64_NO_CLASS;
+ return 1;
+ }
+
+ /* Merge the fields of structure. */
+ for (ptr = type->elements; *ptr != NULL; ptr++)
+ {
+ size_t num;
+
+ byte_offset = ALIGN (byte_offset, (*ptr)->alignment);
+
+ num = classify_argument (*ptr, subclasses, byte_offset % 8);
+ if (num == 0)
+ return 0;
+ for (i = 0; i < num; i++)
+ {
+ size_t pos = byte_offset / 8;
+ classes[i + pos] =
+ merge_classes (subclasses[i], classes[i + pos]);
+ }
+
+ byte_offset += (*ptr)->size;
+ }
+
+ if (words > 2)
+ {
+ /* When size > 16 bytes, if the first one isn't
+ X86_64_SSE_CLASS or any other ones aren't
+ X86_64_SSEUP_CLASS, everything should be passed in
+ memory. */
+ if (classes[0] != X86_64_SSE_CLASS)
+ return 0;
+
+ for (i = 1; i < words; i++)
+ if (classes[i] != X86_64_SSEUP_CLASS)
+ return 0;
+ }
+
+ /* Final merger cleanup. */
+ for (i = 0; i < words; i++)
+ {
+ /* If one class is MEMORY, everything should be passed in
+ memory. */
+ if (classes[i] == X86_64_MEMORY_CLASS)
+ return 0;
+
+ /* The X86_64_SSEUP_CLASS should be always preceded by
+ X86_64_SSE_CLASS or X86_64_SSEUP_CLASS. */
+ if (classes[i] == X86_64_SSEUP_CLASS
+ && classes[i - 1] != X86_64_SSE_CLASS
+ && classes[i - 1] != X86_64_SSEUP_CLASS)
+ {
+ /* The first one should never be X86_64_SSEUP_CLASS. */
+ FFI_ASSERT (i != 0);
+ classes[i] = X86_64_SSE_CLASS;
+ }
+
+ /* If X86_64_X87UP_CLASS isn't preceded by X86_64_X87_CLASS,
+ everything should be passed in memory. */
+ if (classes[i] == X86_64_X87UP_CLASS
+ && (classes[i - 1] != X86_64_X87_CLASS))
+ {
+ /* The first one should never be X86_64_X87UP_CLASS. */
+ FFI_ASSERT (i != 0);
+ return 0;
+ }
+ }
+ return words;
+ }
+
+ default:
+ FFI_ASSERT(0);
+ }
+ return 0; /* Never reached. */
+}
+
+/* Examine the argument and return set number of register required in each
+ class. Return zero iff parameter should be passed in memory, otherwise
+ the number of registers. */
+
+static size_t
+examine_argument (ffi_type *type, enum x86_64_reg_class classes[MAX_CLASSES],
+ _Bool in_return, int *pngpr, int *pnsse)
+{
+ size_t n;
+ int i, ngpr, nsse;
+
+ n = classify_argument (type, classes, 0);
+ if (n == 0)
+ return 0;
+
+ ngpr = nsse = 0;
+ for (i = 0; i < n; ++i)
+ switch (classes[i])
+ {
+ case X86_64_INTEGER_CLASS:
+ case X86_64_INTEGERSI_CLASS:
+ ngpr++;
+ break;
+ case X86_64_SSE_CLASS:
+ case X86_64_SSESF_CLASS:
+ case X86_64_SSEDF_CLASS:
+ nsse++;
+ break;
+ case X86_64_NO_CLASS:
+ case X86_64_SSEUP_CLASS:
+ break;
+ case X86_64_X87_CLASS:
+ case X86_64_X87UP_CLASS:
+ case X86_64_COMPLEX_X87_CLASS:
+ return in_return != 0;
+ default:
+ abort ();
+ }
+
+ *pngpr = ngpr;
+ *pnsse = nsse;
+
+ return n;
+}
+
+/* Perform machine dependent cif processing. */
+
+ffi_status
+ffi_prep_cif_machdep (ffi_cif *cif)
+{
+ int gprcount, ssecount, i, avn, ngpr, nsse, flags;
+ enum x86_64_reg_class classes[MAX_CLASSES];
+ size_t bytes, n;
+
+ gprcount = ssecount = 0;
+
+ flags = cif->rtype->type;
+ if (flags != FFI_TYPE_VOID)
+ {
+ n = examine_argument (cif->rtype, classes, 1, &ngpr, &nsse);
+ if (n == 0)
+ {
+ /* The return value is passed in memory. A pointer to that
+ memory is the first argument. Allocate a register for it. */
+ gprcount++;
+ /* We don't have to do anything in asm for the return. */
+ flags = FFI_TYPE_VOID;
+ }
+ else if (flags == FFI_TYPE_STRUCT)
+ {
+ /* Mark which registers the result appears in. */
+ _Bool sse0 = SSE_CLASS_P (classes[0]);
+ _Bool sse1 = n == 2 && SSE_CLASS_P (classes[1]);
+ if (sse0 && !sse1)
+ flags |= 1 << 8;
+ else if (!sse0 && sse1)
+ flags |= 1 << 9;
+ else if (sse0 && sse1)
+ flags |= 1 << 10;
+ /* Mark the true size of the structure. */
+ flags |= cif->rtype->size << 12;
+ }
+ }
+
+ /* Go over all arguments and determine the way they should be passed.
+ If it's in a register and there is space for it, let that be so. If
+ not, add it's size to the stack byte count. */
+ for (bytes = 0, i = 0, avn = cif->nargs; i < avn; i++)
+ {
+ if (examine_argument (cif->arg_types[i], classes, 0, &ngpr, &nsse) == 0
+ || gprcount + ngpr > MAX_GPR_REGS
+ || ssecount + nsse > MAX_SSE_REGS)
+ {
+ long align = cif->arg_types[i]->alignment;
+
+ if (align < 8)
+ align = 8;
+
+ bytes = ALIGN (bytes, align);
+ bytes += cif->arg_types[i]->size;
+ }
+ else
+ {
+ gprcount += ngpr;
+ ssecount += nsse;
+ }
+ }
+ if (ssecount)
+ flags |= 1 << 11;
+ cif->flags = flags;
+ cif->bytes = (unsigned)ALIGN (bytes, 8);
+
+ return FFI_OK;
+}
+
+void
+ffi_call (ffi_cif *cif, void (*fn)(void), void *rvalue, void **avalue)
+{
+ enum x86_64_reg_class classes[MAX_CLASSES];
+ char *stack, *argp;
+ ffi_type **arg_types;
+ int gprcount, ssecount, ngpr, nsse, i, avn;
+ _Bool ret_in_memory;
+ struct register_args *reg_args;
+
+ /* Can't call 32-bit mode from 64-bit mode. */
+ FFI_ASSERT (cif->abi == FFI_UNIX64);
+
+ /* If the return value is a struct and we don't have a return value
+ address then we need to make one. Note the setting of flags to
+ VOID above in ffi_prep_cif_machdep. */
+ ret_in_memory = (cif->rtype->type == FFI_TYPE_STRUCT
+ && (cif->flags & 0xff) == FFI_TYPE_VOID);
+ if (rvalue == NULL && ret_in_memory)
+ rvalue = alloca (cif->rtype->size);
+
+ /* Allocate the space for the arguments, plus 4 words of temp space. */
+ stack = alloca (sizeof (struct register_args) + cif->bytes + 4*8);
+ reg_args = (struct register_args *) stack;
+ argp = stack + sizeof (struct register_args);
+
+ gprcount = ssecount = 0;
+
+ /* If the return value is passed in memory, add the pointer as the
+ first integer argument. */
+ if (ret_in_memory)
+ reg_args->gpr[gprcount++] = (unsigned long) rvalue;
+
+ avn = cif->nargs;
+ arg_types = cif->arg_types;
+
+ for (i = 0; i < avn; ++i)
+ {
+ size_t n, size = arg_types[i]->size;
+
+ n = examine_argument (arg_types[i], classes, 0, &ngpr, &nsse);
+ if (n == 0
+ || gprcount + ngpr > MAX_GPR_REGS
+ || ssecount + nsse > MAX_SSE_REGS)
+ {
+ long align = arg_types[i]->alignment;
+
+ /* Stack arguments are *always* at least 8 byte aligned. */
+ if (align < 8)
+ align = 8;
+
+ /* Pass this argument in memory. */
+ argp = (void *) ALIGN (argp, align);
+ memcpy (argp, avalue[i], size);
+ argp += size;
+ }
+ else
+ {
+ /* The argument is passed entirely in registers. */
+ char *a = (char *) avalue[i];
+ int j;
+
+ for (j = 0; j < n; j++, a += 8, size -= 8)
+ {
+ switch (classes[j])
+ {
+ case X86_64_INTEGER_CLASS:
+ case X86_64_INTEGERSI_CLASS:
+ /* Sign-extend integer arguments passed in general
+ purpose registers, to cope with the fact that
+ LLVM incorrectly assumes that this will be done
+ (the x86-64 PS ABI does not specify this). */
+ switch (arg_types[i]->type)
+ {
+ case FFI_TYPE_SINT8:
+ *(SINT64 *)&reg_args->gpr[gprcount] = (SINT64) *((SINT8 *) a);
+ break;
+ case FFI_TYPE_SINT16:
+ *(SINT64 *)&reg_args->gpr[gprcount] = (SINT64) *((SINT16 *) a);
+ break;
+ case FFI_TYPE_SINT32:
+ *(SINT64 *)&reg_args->gpr[gprcount] = (SINT64) *((SINT32 *) a);
+ break;
+ default:
+ reg_args->gpr[gprcount] = 0;
+ memcpy (&reg_args->gpr[gprcount], a, size < 8 ? size : 8);
+ }
+ gprcount++;
+ break;
+ case X86_64_SSE_CLASS:
+ case X86_64_SSEDF_CLASS:
+ reg_args->sse[ssecount++].i64 = *(UINT64 *) a;
+ break;
+ case X86_64_SSESF_CLASS:
+ reg_args->sse[ssecount++].i32 = *(UINT32 *) a;
+ break;
+ default:
+ abort();
+ }
+ }
+ }
+ }
+
+ ffi_call_unix64 (stack, cif->bytes + sizeof (struct register_args),
+ cif->flags, rvalue, fn, ssecount);
+}
+
+
+extern void ffi_closure_unix64(void);
+
+ffi_status
+ffi_prep_closure_loc (ffi_closure* closure,
+ ffi_cif* cif,
+ void (*fun)(ffi_cif*, void*, void**, void*),
+ void *user_data,
+ void *codeloc)
+{
+ volatile unsigned short *tramp;
+
+ /* Sanity check on the cif ABI. */
+ {
+ int abi = cif->abi;
+ if (UNLIKELY (! (abi > FFI_FIRST_ABI && abi < FFI_LAST_ABI)))
+ return FFI_BAD_ABI;
+ }
+
+ tramp = (volatile unsigned short *) &closure->tramp[0];
+
+ tramp[0] = 0xbb49; /* mov <code>, %r11 */
+ *((unsigned long long * volatile) &tramp[1])
+ = (unsigned long) ffi_closure_unix64;
+ tramp[5] = 0xba49; /* mov <data>, %r10 */
+ *((unsigned long long * volatile) &tramp[6])
+ = (unsigned long) codeloc;
+
+ /* Set the carry bit iff the function uses any sse registers.
+ This is clc or stc, together with the first byte of the jmp. */
+ tramp[10] = cif->flags & (1 << 11) ? 0x49f9 : 0x49f8;
+
+ tramp[11] = 0xe3ff; /* jmp *%r11 */
+
+ closure->cif = cif;
+ closure->fun = fun;
+ closure->user_data = user_data;
+
+ return FFI_OK;
+}
+
+int
+ffi_closure_unix64_inner(ffi_closure *closure, void *rvalue,
+ struct register_args *reg_args, char *argp)
+{
+ ffi_cif *cif;
+ void **avalue;
+ ffi_type **arg_types;
+ long i, avn;
+ int gprcount, ssecount, ngpr, nsse;
+ int ret;
+
+ cif = closure->cif;
+ avalue = alloca(cif->nargs * sizeof(void *));
+ gprcount = ssecount = 0;
+
+ ret = cif->rtype->type;
+ if (ret != FFI_TYPE_VOID)
+ {
+ enum x86_64_reg_class classes[MAX_CLASSES];
+ size_t n = examine_argument (cif->rtype, classes, 1, &ngpr, &nsse);
+ if (n == 0)
+ {
+ /* The return value goes in memory. Arrange for the closure
+ return value to go directly back to the original caller. */
+ rvalue = (void *) (unsigned long) reg_args->gpr[gprcount++];
+ /* We don't have to do anything in asm for the return. */
+ ret = FFI_TYPE_VOID;
+ }
+ else if (ret == FFI_TYPE_STRUCT && n == 2)
+ {
+ /* Mark which register the second word of the structure goes in. */
+ _Bool sse0 = SSE_CLASS_P (classes[0]);
+ _Bool sse1 = SSE_CLASS_P (classes[1]);
+ if (!sse0 && sse1)
+ ret |= 1 << 8;
+ else if (sse0 && !sse1)
+ ret |= 1 << 9;
+ }
+ }
+
+ avn = cif->nargs;
+ arg_types = cif->arg_types;
+
+ for (i = 0; i < avn; ++i)
+ {
+ enum x86_64_reg_class classes[MAX_CLASSES];
+ size_t n;
+
+ n = examine_argument (arg_types[i], classes, 0, &ngpr, &nsse);
+ if (n == 0
+ || gprcount + ngpr > MAX_GPR_REGS
+ || ssecount + nsse > MAX_SSE_REGS)
+ {
+ long align = arg_types[i]->alignment;
+
+ /* Stack arguments are *always* at least 8 byte aligned. */
+ if (align < 8)
+ align = 8;
+
+ /* Pass this argument in memory. */
+ argp = (void *) ALIGN (argp, align);
+ avalue[i] = argp;
+ argp += arg_types[i]->size;
+ }
+ /* If the argument is in a single register, or two consecutive
+ integer registers, then we can use that address directly. */
+ else if (n == 1
+ || (n == 2 && !(SSE_CLASS_P (classes[0])
+ || SSE_CLASS_P (classes[1]))))
+ {
+ /* The argument is in a single register. */
+ if (SSE_CLASS_P (classes[0]))
+ {
+ avalue[i] = &reg_args->sse[ssecount];
+ ssecount += n;
+ }
+ else
+ {
+ avalue[i] = &reg_args->gpr[gprcount];
+ gprcount += n;
+ }
+ }
+ /* Otherwise, allocate space to make them consecutive. */
+ else
+ {
+ char *a = alloca (16);
+ int j;
+
+ avalue[i] = a;
+ for (j = 0; j < n; j++, a += 8)
+ {
+ if (SSE_CLASS_P (classes[j]))
+ memcpy (a, &reg_args->sse[ssecount++], 8);
+ else
+ memcpy (a, &reg_args->gpr[gprcount++], 8);
+ }
+ }
+ }
+
+ /* Invoke the closure. */
+ closure->fun (cif, rvalue, avalue, closure->user_data);
+
+ /* Tell assembly how to perform return type promotions. */
+ return ret;
+}
+
+#endif /* __x86_64__ */
diff --git a/jni/ruby/ext/fiddle/libffi-3.2.1/src/x86/ffitarget.h b/jni/ruby/ext/fiddle/libffi-3.2.1/src/x86/ffitarget.h
new file mode 100644
index 0000000..ff0f718
--- /dev/null
+++ b/jni/ruby/ext/fiddle/libffi-3.2.1/src/x86/ffitarget.h
@@ -0,0 +1,152 @@
+/* -----------------------------------------------------------------*-C-*-
+ ffitarget.h - Copyright (c) 2012, 2014 Anthony Green
+ Copyright (c) 1996-2003, 2010 Red Hat, Inc.
+ Copyright (C) 2008 Free Software Foundation, Inc.
+
+ Target configuration macros for x86 and x86-64.
+
+ Permission is hereby granted, free of charge, to any person obtaining
+ a copy of this software and associated documentation files (the
+ ``Software''), to deal in the Software without restriction, including
+ without limitation the rights to use, copy, modify, merge, publish,
+ distribute, sublicense, and/or sell copies of the Software, and to
+ permit persons to whom the Software is furnished to do so, subject to
+ the following conditions:
+
+ The above copyright notice and this permission notice shall be included
+ in all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND,
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+ HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ DEALINGS IN THE SOFTWARE.
+
+ ----------------------------------------------------------------------- */
+
+#ifndef LIBFFI_TARGET_H
+#define LIBFFI_TARGET_H
+
+#ifndef LIBFFI_H
+#error "Please do not include ffitarget.h directly into your source. Use ffi.h instead."
+#endif
+
+/* ---- System specific configurations ----------------------------------- */
+
+/* For code common to all platforms on x86 and x86_64. */
+#define X86_ANY
+
+#if defined (X86_64) && defined (__i386__)
+#undef X86_64
+#define X86
+#endif
+
+#ifdef X86_WIN64
+#define FFI_SIZEOF_ARG 8
+#define USE_BUILTIN_FFS 0 /* not yet implemented in mingw-64 */
+#endif
+
+#define FFI_TARGET_SPECIFIC_STACK_SPACE_ALLOCATION
+#ifndef _MSC_VER
+#define FFI_TARGET_HAS_COMPLEX_TYPE
+#endif
+
+/* ---- Generic type definitions ----------------------------------------- */
+
+#ifndef LIBFFI_ASM
+#ifdef X86_WIN64
+#ifdef _MSC_VER
+typedef unsigned __int64 ffi_arg;
+typedef __int64 ffi_sarg;
+#else
+typedef unsigned long long ffi_arg;
+typedef long long ffi_sarg;
+#endif
+#else
+#if defined __x86_64__ && defined __ILP32__
+#define FFI_SIZEOF_ARG 8
+#define FFI_SIZEOF_JAVA_RAW 4
+typedef unsigned long long ffi_arg;
+typedef long long ffi_sarg;
+#else
+typedef unsigned long ffi_arg;
+typedef signed long ffi_sarg;
+#endif
+#endif
+
+typedef enum ffi_abi {
+ FFI_FIRST_ABI = 0,
+
+ /* ---- Intel x86 Win32 ---------- */
+#ifdef X86_WIN32
+ FFI_SYSV,
+ FFI_STDCALL,
+ FFI_THISCALL,
+ FFI_FASTCALL,
+ FFI_MS_CDECL,
+ FFI_PASCAL,
+ FFI_REGISTER,
+ FFI_LAST_ABI,
+#ifdef _MSC_VER
+ FFI_DEFAULT_ABI = FFI_MS_CDECL
+#else
+ FFI_DEFAULT_ABI = FFI_SYSV
+#endif
+
+#elif defined(X86_WIN64)
+ FFI_WIN64,
+ FFI_LAST_ABI,
+ FFI_DEFAULT_ABI = FFI_WIN64
+
+#else
+ /* ---- Intel x86 and AMD x86-64 - */
+ FFI_SYSV,
+ FFI_UNIX64, /* Unix variants all use the same ABI for x86-64 */
+ FFI_THISCALL,
+ FFI_FASTCALL,
+ FFI_STDCALL,
+ FFI_PASCAL,
+ FFI_REGISTER,
+ FFI_LAST_ABI,
+#if defined(__i386__) || defined(__i386)
+ FFI_DEFAULT_ABI = FFI_SYSV
+#else
+ FFI_DEFAULT_ABI = FFI_UNIX64
+#endif
+#endif
+} ffi_abi;
+#endif
+
+/* ---- Definitions for closures ----------------------------------------- */
+
+#define FFI_CLOSURES 1
+#define FFI_TYPE_SMALL_STRUCT_1B (FFI_TYPE_LAST + 1)
+#define FFI_TYPE_SMALL_STRUCT_2B (FFI_TYPE_LAST + 2)
+#define FFI_TYPE_SMALL_STRUCT_4B (FFI_TYPE_LAST + 3)
+#define FFI_TYPE_MS_STRUCT (FFI_TYPE_LAST + 4)
+
+#if defined (X86_64) || (defined (__x86_64__) && defined (X86_DARWIN))
+#define FFI_TRAMPOLINE_SIZE 24
+#define FFI_NATIVE_RAW_API 0
+#else
+#ifdef X86_WIN32
+#define FFI_TRAMPOLINE_SIZE 52
+#else
+#ifdef X86_WIN64
+#define FFI_TRAMPOLINE_SIZE 29
+#define FFI_NATIVE_RAW_API 0
+#define FFI_NO_RAW_API 1
+#else
+#define FFI_TRAMPOLINE_SIZE 10
+#endif
+#endif
+#ifndef X86_WIN64
+#define FFI_NATIVE_RAW_API 1 /* x86 has native raw api support */
+#endif
+#endif
+
+#endif
+
diff --git a/jni/ruby/ext/fiddle/libffi-3.2.1/src/x86/freebsd.S b/jni/ruby/ext/fiddle/libffi-3.2.1/src/x86/freebsd.S
new file mode 100644
index 0000000..97e0b4e
--- /dev/null
+++ b/jni/ruby/ext/fiddle/libffi-3.2.1/src/x86/freebsd.S
@@ -0,0 +1,463 @@
+/* -----------------------------------------------------------------------
+ freebsd.S - Copyright (c) 1996, 1998, 2001, 2002, 2003, 2005 Red Hat, Inc.
+ Copyright (c) 2008 Björn König
+
+ X86 Foreign Function Interface for FreeBSD
+
+ Permission is hereby granted, free of charge, to any person obtaining
+ a copy of this software and associated documentation files (the
+ ``Software''), to deal in the Software without restriction, including
+ without limitation the rights to use, copy, modify, merge, publish,
+ distribute, sublicense, and/or sell copies of the Software, and to
+ permit persons to whom the Software is furnished to do so, subject to
+ the following conditions:
+
+ The above copyright notice and this permission notice shall be included
+ in all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND,
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+ HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ DEALINGS IN THE SOFTWARE.
+----------------------------------------------------------------------- */
+
+#ifndef __x86_64__
+
+#define LIBFFI_ASM
+#include <fficonfig.h>
+#include <ffi.h>
+
+.text
+
+.globl ffi_prep_args
+
+ .align 4
+.globl ffi_call_SYSV
+ .type ffi_call_SYSV,@function
+
+ffi_call_SYSV:
+.LFB1:
+ pushl %ebp
+.LCFI0:
+ movl %esp,%ebp
+.LCFI1:
+ /* Make room for all of the new args. */
+ movl 16(%ebp),%ecx
+ subl %ecx,%esp
+
+ /* Align the stack pointer to 16-bytes */
+ andl $0xfffffff0, %esp
+
+ movl %esp,%eax
+
+ /* Place all of the ffi_prep_args in position */
+ pushl 12(%ebp)
+ pushl %eax
+ call *8(%ebp)
+
+ /* Return stack to previous state and call the function */
+ addl $8,%esp
+
+ call *28(%ebp)
+
+ /* Load %ecx with the return type code */
+ movl 20(%ebp),%ecx
+
+ /* Protect %esi. We're going to pop it in the epilogue. */
+ pushl %esi
+
+ /* If the return value pointer is NULL, assume no return value. */
+ cmpl $0,24(%ebp)
+ jne 0f
+
+ /* Even if there is no space for the return value, we are
+ obliged to handle floating-point values. */
+ cmpl $FFI_TYPE_FLOAT,%ecx
+ jne noretval
+ fstp %st(0)
+
+ jmp epilogue
+
+0:
+ call 1f
+
+.Lstore_table:
+ .long noretval-.Lstore_table /* FFI_TYPE_VOID */
+ .long retint-.Lstore_table /* FFI_TYPE_INT */
+ .long retfloat-.Lstore_table /* FFI_TYPE_FLOAT */
+ .long retdouble-.Lstore_table /* FFI_TYPE_DOUBLE */
+ .long retlongdouble-.Lstore_table /* FFI_TYPE_LONGDOUBLE */
+ .long retuint8-.Lstore_table /* FFI_TYPE_UINT8 */
+ .long retsint8-.Lstore_table /* FFI_TYPE_SINT8 */
+ .long retuint16-.Lstore_table /* FFI_TYPE_UINT16 */
+ .long retsint16-.Lstore_table /* FFI_TYPE_SINT16 */
+ .long retint-.Lstore_table /* FFI_TYPE_UINT32 */
+ .long retint-.Lstore_table /* FFI_TYPE_SINT32 */
+ .long retint64-.Lstore_table /* FFI_TYPE_UINT64 */
+ .long retint64-.Lstore_table /* FFI_TYPE_SINT64 */
+ .long retstruct-.Lstore_table /* FFI_TYPE_STRUCT */
+ .long retint-.Lstore_table /* FFI_TYPE_POINTER */
+ .long retstruct1b-.Lstore_table /* FFI_TYPE_SMALL_STRUCT_1B */
+ .long retstruct2b-.Lstore_table /* FFI_TYPE_SMALL_STRUCT_2B */
+
+1:
+ pop %esi
+ add (%esi, %ecx, 4), %esi
+ jmp *%esi
+
+ /* Sign/zero extend as appropriate. */
+retsint8:
+ movsbl %al, %eax
+ jmp retint
+
+retsint16:
+ movswl %ax, %eax
+ jmp retint
+
+retuint8:
+ movzbl %al, %eax
+ jmp retint
+
+retuint16:
+ movzwl %ax, %eax
+ jmp retint
+
+retfloat:
+ /* Load %ecx with the pointer to storage for the return value */
+ movl 24(%ebp),%ecx
+ fstps (%ecx)
+ jmp epilogue
+
+retdouble:
+ /* Load %ecx with the pointer to storage for the return value */
+ movl 24(%ebp),%ecx
+ fstpl (%ecx)
+ jmp epilogue
+
+retlongdouble:
+ /* Load %ecx with the pointer to storage for the return value */
+ movl 24(%ebp),%ecx
+ fstpt (%ecx)
+ jmp epilogue
+
+retint64:
+ /* Load %ecx with the pointer to storage for the return value */
+ movl 24(%ebp),%ecx
+ movl %eax,0(%ecx)
+ movl %edx,4(%ecx)
+ jmp epilogue
+
+retstruct1b:
+ /* Load %ecx with the pointer to storage for the return value */
+ movl 24(%ebp),%ecx
+ movb %al,0(%ecx)
+ jmp epilogue
+
+retstruct2b:
+ /* Load %ecx with the pointer to storage for the return value */
+ movl 24(%ebp),%ecx
+ movw %ax,0(%ecx)
+ jmp epilogue
+
+retint:
+ /* Load %ecx with the pointer to storage for the return value */
+ movl 24(%ebp),%ecx
+ movl %eax,0(%ecx)
+
+retstruct:
+ /* Nothing to do! */
+
+noretval:
+epilogue:
+ popl %esi
+ movl %ebp,%esp
+ popl %ebp
+ ret
+.LFE1:
+.ffi_call_SYSV_end:
+ .size ffi_call_SYSV,.ffi_call_SYSV_end-ffi_call_SYSV
+
+ .align 4
+FFI_HIDDEN (ffi_closure_SYSV)
+.globl ffi_closure_SYSV
+ .type ffi_closure_SYSV, @function
+
+ffi_closure_SYSV:
+.LFB2:
+ pushl %ebp
+.LCFI2:
+ movl %esp, %ebp
+.LCFI3:
+ subl $40, %esp
+ leal -24(%ebp), %edx
+ movl %edx, -12(%ebp) /* resp */
+ leal 8(%ebp), %edx
+ movl %edx, 4(%esp) /* args = __builtin_dwarf_cfa () */
+ leal -12(%ebp), %edx
+ movl %edx, (%esp) /* &resp */
+#if defined HAVE_HIDDEN_VISIBILITY_ATTRIBUTE || !defined __PIC__
+ call ffi_closure_SYSV_inner
+#else
+ movl %ebx, 8(%esp)
+.LCFI7:
+ call 1f
+1: popl %ebx
+ addl $_GLOBAL_OFFSET_TABLE_+[.-1b], %ebx
+ call ffi_closure_SYSV_inner@PLT
+ movl 8(%esp), %ebx
+#endif
+ movl -12(%ebp), %ecx
+ cmpl $FFI_TYPE_INT, %eax
+ je .Lcls_retint
+
+ /* Handle FFI_TYPE_UINT8, FFI_TYPE_SINT8, FFI_TYPE_UINT16,
+ FFI_TYPE_SINT16, FFI_TYPE_UINT32, FFI_TYPE_SINT32. */
+ cmpl $FFI_TYPE_UINT64, %eax
+ jge 0f
+ cmpl $FFI_TYPE_UINT8, %eax
+ jge .Lcls_retint
+
+0: cmpl $FFI_TYPE_FLOAT, %eax
+ je .Lcls_retfloat
+ cmpl $FFI_TYPE_DOUBLE, %eax
+ je .Lcls_retdouble
+ cmpl $FFI_TYPE_LONGDOUBLE, %eax
+ je .Lcls_retldouble
+ cmpl $FFI_TYPE_SINT64, %eax
+ je .Lcls_retllong
+ cmpl $FFI_TYPE_SMALL_STRUCT_1B, %eax
+ je .Lcls_retstruct1b
+ cmpl $FFI_TYPE_SMALL_STRUCT_2B, %eax
+ je .Lcls_retstruct2b
+ cmpl $FFI_TYPE_STRUCT, %eax
+ je .Lcls_retstruct
+.Lcls_epilogue:
+ movl %ebp, %esp
+ popl %ebp
+ ret
+.Lcls_retint:
+ movl (%ecx), %eax
+ jmp .Lcls_epilogue
+.Lcls_retfloat:
+ flds (%ecx)
+ jmp .Lcls_epilogue
+.Lcls_retdouble:
+ fldl (%ecx)
+ jmp .Lcls_epilogue
+.Lcls_retldouble:
+ fldt (%ecx)
+ jmp .Lcls_epilogue
+.Lcls_retllong:
+ movl (%ecx), %eax
+ movl 4(%ecx), %edx
+ jmp .Lcls_epilogue
+.Lcls_retstruct1b:
+ movsbl (%ecx), %eax
+ jmp .Lcls_epilogue
+.Lcls_retstruct2b:
+ movswl (%ecx), %eax
+ jmp .Lcls_epilogue
+.Lcls_retstruct:
+ movl %ebp, %esp
+ popl %ebp
+ ret $4
+.LFE2:
+ .size ffi_closure_SYSV, .-ffi_closure_SYSV
+
+#if !FFI_NO_RAW_API
+
+#define RAW_CLOSURE_CIF_OFFSET ((FFI_TRAMPOLINE_SIZE + 3) & ~3)
+#define RAW_CLOSURE_FUN_OFFSET (RAW_CLOSURE_CIF_OFFSET + 4)
+#define RAW_CLOSURE_USER_DATA_OFFSET (RAW_CLOSURE_FUN_OFFSET + 4)
+#define CIF_FLAGS_OFFSET 20
+
+ .align 4
+FFI_HIDDEN (ffi_closure_raw_SYSV)
+.globl ffi_closure_raw_SYSV
+ .type ffi_closure_raw_SYSV, @function
+
+ffi_closure_raw_SYSV:
+.LFB3:
+ pushl %ebp
+.LCFI4:
+ movl %esp, %ebp
+.LCFI5:
+ pushl %esi
+.LCFI6:
+ subl $36, %esp
+ movl RAW_CLOSURE_CIF_OFFSET(%eax), %esi /* closure->cif */
+ movl RAW_CLOSURE_USER_DATA_OFFSET(%eax), %edx /* closure->user_data */
+ movl %edx, 12(%esp) /* user_data */
+ leal 8(%ebp), %edx /* __builtin_dwarf_cfa () */
+ movl %edx, 8(%esp) /* raw_args */
+ leal -24(%ebp), %edx
+ movl %edx, 4(%esp) /* &res */
+ movl %esi, (%esp) /* cif */
+ call *RAW_CLOSURE_FUN_OFFSET(%eax) /* closure->fun */
+ movl CIF_FLAGS_OFFSET(%esi), %eax /* rtype */
+ cmpl $FFI_TYPE_INT, %eax
+ je .Lrcls_retint
+
+ /* Handle FFI_TYPE_UINT8, FFI_TYPE_SINT8, FFI_TYPE_UINT16,
+ FFI_TYPE_SINT16, FFI_TYPE_UINT32, FFI_TYPE_SINT32. */
+ cmpl $FFI_TYPE_UINT64, %eax
+ jge 0f
+ cmpl $FFI_TYPE_UINT8, %eax
+ jge .Lrcls_retint
+0:
+ cmpl $FFI_TYPE_FLOAT, %eax
+ je .Lrcls_retfloat
+ cmpl $FFI_TYPE_DOUBLE, %eax
+ je .Lrcls_retdouble
+ cmpl $FFI_TYPE_LONGDOUBLE, %eax
+ je .Lrcls_retldouble
+ cmpl $FFI_TYPE_SINT64, %eax
+ je .Lrcls_retllong
+.Lrcls_epilogue:
+ addl $36, %esp
+ popl %esi
+ popl %ebp
+ ret
+.Lrcls_retint:
+ movl -24(%ebp), %eax
+ jmp .Lrcls_epilogue
+.Lrcls_retfloat:
+ flds -24(%ebp)
+ jmp .Lrcls_epilogue
+.Lrcls_retdouble:
+ fldl -24(%ebp)
+ jmp .Lrcls_epilogue
+.Lrcls_retldouble:
+ fldt -24(%ebp)
+ jmp .Lrcls_epilogue
+.Lrcls_retllong:
+ movl -24(%ebp), %eax
+ movl -20(%ebp), %edx
+ jmp .Lrcls_epilogue
+.LFE3:
+ .size ffi_closure_raw_SYSV, .-ffi_closure_raw_SYSV
+#endif
+
+ .section .eh_frame,EH_FRAME_FLAGS,@progbits
+.Lframe1:
+ .long .LECIE1-.LSCIE1 /* Length of Common Information Entry */
+.LSCIE1:
+ .long 0x0 /* CIE Identifier Tag */
+ .byte 0x1 /* CIE Version */
+#ifdef __PIC__
+ .ascii "zR\0" /* CIE Augmentation */
+#else
+ .ascii "\0" /* CIE Augmentation */
+#endif
+ .byte 0x1 /* .uleb128 0x1; CIE Code Alignment Factor */
+ .byte 0x7c /* .sleb128 -4; CIE Data Alignment Factor */
+ .byte 0x8 /* CIE RA Column */
+#ifdef __PIC__
+ .byte 0x1 /* .uleb128 0x1; Augmentation size */
+ .byte 0x1b /* FDE Encoding (pcrel sdata4) */
+#endif
+ .byte 0xc /* DW_CFA_def_cfa */
+ .byte 0x4 /* .uleb128 0x4 */
+ .byte 0x4 /* .uleb128 0x4 */
+ .byte 0x88 /* DW_CFA_offset, column 0x8 */
+ .byte 0x1 /* .uleb128 0x1 */
+ .align 4
+.LECIE1:
+.LSFDE1:
+ .long .LEFDE1-.LASFDE1 /* FDE Length */
+.LASFDE1:
+ .long .LASFDE1-.Lframe1 /* FDE CIE offset */
+#ifdef __PIC__
+ .long .LFB1-. /* FDE initial location */
+#else
+ .long .LFB1 /* FDE initial location */
+#endif
+ .long .LFE1-.LFB1 /* FDE address range */
+#ifdef __PIC__
+ .byte 0x0 /* .uleb128 0x0; Augmentation size */
+#endif
+ .byte 0x4 /* DW_CFA_advance_loc4 */
+ .long .LCFI0-.LFB1
+ .byte 0xe /* DW_CFA_def_cfa_offset */
+ .byte 0x8 /* .uleb128 0x8 */
+ .byte 0x85 /* DW_CFA_offset, column 0x5 */
+ .byte 0x2 /* .uleb128 0x2 */
+ .byte 0x4 /* DW_CFA_advance_loc4 */
+ .long .LCFI1-.LCFI0
+ .byte 0xd /* DW_CFA_def_cfa_register */
+ .byte 0x5 /* .uleb128 0x5 */
+ .align 4
+.LEFDE1:
+.LSFDE2:
+ .long .LEFDE2-.LASFDE2 /* FDE Length */
+.LASFDE2:
+ .long .LASFDE2-.Lframe1 /* FDE CIE offset */
+#ifdef __PIC__
+ .long .LFB2-. /* FDE initial location */
+#else
+ .long .LFB2
+#endif
+ .long .LFE2-.LFB2 /* FDE address range */
+#ifdef __PIC__
+ .byte 0x0 /* .uleb128 0x0; Augmentation size */
+#endif
+ .byte 0x4 /* DW_CFA_advance_loc4 */
+ .long .LCFI2-.LFB2
+ .byte 0xe /* DW_CFA_def_cfa_offset */
+ .byte 0x8 /* .uleb128 0x8 */
+ .byte 0x85 /* DW_CFA_offset, column 0x5 */
+ .byte 0x2 /* .uleb128 0x2 */
+ .byte 0x4 /* DW_CFA_advance_loc4 */
+ .long .LCFI3-.LCFI2
+ .byte 0xd /* DW_CFA_def_cfa_register */
+ .byte 0x5 /* .uleb128 0x5 */
+#if !defined HAVE_HIDDEN_VISIBILITY_ATTRIBUTE && defined __PIC__
+ .byte 0x4 /* DW_CFA_advance_loc4 */
+ .long .LCFI7-.LCFI3
+ .byte 0x83 /* DW_CFA_offset, column 0x3 */
+ .byte 0xa /* .uleb128 0xa */
+#endif
+ .align 4
+.LEFDE2:
+
+#if !FFI_NO_RAW_API
+
+.LSFDE3:
+ .long .LEFDE3-.LASFDE3 /* FDE Length */
+.LASFDE3:
+ .long .LASFDE3-.Lframe1 /* FDE CIE offset */
+#ifdef __PIC__
+ .long .LFB3-. /* FDE initial location */
+#else
+ .long .LFB3
+#endif
+ .long .LFE3-.LFB3 /* FDE address range */
+#ifdef __PIC__
+ .byte 0x0 /* .uleb128 0x0; Augmentation size */
+#endif
+ .byte 0x4 /* DW_CFA_advance_loc4 */
+ .long .LCFI4-.LFB3
+ .byte 0xe /* DW_CFA_def_cfa_offset */
+ .byte 0x8 /* .uleb128 0x8 */
+ .byte 0x85 /* DW_CFA_offset, column 0x5 */
+ .byte 0x2 /* .uleb128 0x2 */
+ .byte 0x4 /* DW_CFA_advance_loc4 */
+ .long .LCFI5-.LCFI4
+ .byte 0xd /* DW_CFA_def_cfa_register */
+ .byte 0x5 /* .uleb128 0x5 */
+ .byte 0x4 /* DW_CFA_advance_loc4 */
+ .long .LCFI6-.LCFI5
+ .byte 0x86 /* DW_CFA_offset, column 0x6 */
+ .byte 0x3 /* .uleb128 0x3 */
+ .align 4
+.LEFDE3:
+
+#endif
+
+#endif /* ifndef __x86_64__ */
+
+ .section .note.GNU-stack,"",%progbits
diff --git a/jni/ruby/ext/fiddle/libffi-3.2.1/src/x86/sysv.S b/jni/ruby/ext/fiddle/libffi-3.2.1/src/x86/sysv.S
new file mode 100644
index 0000000..3bd5477
--- /dev/null
+++ b/jni/ruby/ext/fiddle/libffi-3.2.1/src/x86/sysv.S
@@ -0,0 +1,483 @@
+/* -----------------------------------------------------------------------
+ sysv.S - Copyright (c) 2013 The Written Word, Inc.
+ - Copyright (c) 1996,1998,2001-2003,2005,2008,2010 Red Hat, Inc.
+
+ X86 Foreign Function Interface
+
+ Permission is hereby granted, free of charge, to any person obtaining
+ a copy of this software and associated documentation files (the
+ ``Software''), to deal in the Software without restriction, including
+ without limitation the rights to use, copy, modify, merge, publish,
+ distribute, sublicense, and/or sell copies of the Software, and to
+ permit persons to whom the Software is furnished to do so, subject to
+ the following conditions:
+
+ The above copyright notice and this permission notice shall be included
+ in all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND,
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+ HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ DEALINGS IN THE SOFTWARE.
+ ----------------------------------------------------------------------- */
+
+#ifndef __x86_64__
+
+#define LIBFFI_ASM
+#include <fficonfig.h>
+#include <ffi.h>
+
+.text
+
+.globl ffi_prep_args
+
+ .align 4
+.globl ffi_call_SYSV
+ .type ffi_call_SYSV,@function
+
+ffi_call_SYSV:
+.LFB1:
+ pushl %ebp
+.LCFI0:
+ movl %esp,%ebp
+.LCFI1:
+ /* Make room for all of the new args. */
+ movl 16(%ebp),%ecx
+ subl %ecx,%esp
+
+ /* Align the stack pointer to 16-bytes */
+ andl $0xfffffff0, %esp
+
+ movl %esp,%eax
+
+ /* Place all of the ffi_prep_args in position */
+ pushl 12(%ebp)
+ pushl %eax
+ call *8(%ebp)
+
+ /* Return stack to previous state and call the function */
+ addl $8,%esp
+
+ call *28(%ebp)
+
+ /* Load %ecx with the return type code */
+ movl 20(%ebp),%ecx
+
+ /* Protect %esi. We're going to pop it in the epilogue. */
+ pushl %esi
+
+ /* If the return value pointer is NULL, assume no return value. */
+ cmpl $0,24(%ebp)
+ jne 0f
+
+ /* Even if there is no space for the return value, we are
+ obliged to handle floating-point values. */
+ cmpl $FFI_TYPE_FLOAT,%ecx
+ jne noretval
+ fstp %st(0)
+
+ jmp epilogue
+
+0:
+ call 1f
+
+.Lstore_table:
+ .long noretval-.Lstore_table /* FFI_TYPE_VOID */
+ .long retint-.Lstore_table /* FFI_TYPE_INT */
+ .long retfloat-.Lstore_table /* FFI_TYPE_FLOAT */
+ .long retdouble-.Lstore_table /* FFI_TYPE_DOUBLE */
+ .long retlongdouble-.Lstore_table /* FFI_TYPE_LONGDOUBLE */
+ .long retuint8-.Lstore_table /* FFI_TYPE_UINT8 */
+ .long retsint8-.Lstore_table /* FFI_TYPE_SINT8 */
+ .long retuint16-.Lstore_table /* FFI_TYPE_UINT16 */
+ .long retsint16-.Lstore_table /* FFI_TYPE_SINT16 */
+ .long retint-.Lstore_table /* FFI_TYPE_UINT32 */
+ .long retint-.Lstore_table /* FFI_TYPE_SINT32 */
+ .long retint64-.Lstore_table /* FFI_TYPE_UINT64 */
+ .long retint64-.Lstore_table /* FFI_TYPE_SINT64 */
+ .long retstruct-.Lstore_table /* FFI_TYPE_STRUCT */
+ .long retint-.Lstore_table /* FFI_TYPE_POINTER */
+
+1:
+ pop %esi
+ add (%esi, %ecx, 4), %esi
+ jmp *%esi
+
+ /* Sign/zero extend as appropriate. */
+retsint8:
+ movsbl %al, %eax
+ jmp retint
+
+retsint16:
+ movswl %ax, %eax
+ jmp retint
+
+retuint8:
+ movzbl %al, %eax
+ jmp retint
+
+retuint16:
+ movzwl %ax, %eax
+ jmp retint
+
+retfloat:
+ /* Load %ecx with the pointer to storage for the return value */
+ movl 24(%ebp),%ecx
+ fstps (%ecx)
+ jmp epilogue
+
+retdouble:
+ /* Load %ecx with the pointer to storage for the return value */
+ movl 24(%ebp),%ecx
+ fstpl (%ecx)
+ jmp epilogue
+
+retlongdouble:
+ /* Load %ecx with the pointer to storage for the return value */
+ movl 24(%ebp),%ecx
+ fstpt (%ecx)
+ jmp epilogue
+
+retint64:
+ /* Load %ecx with the pointer to storage for the return value */
+ movl 24(%ebp),%ecx
+ movl %eax,0(%ecx)
+ movl %edx,4(%ecx)
+ jmp epilogue
+
+retint:
+ /* Load %ecx with the pointer to storage for the return value */
+ movl 24(%ebp),%ecx
+ movl %eax,0(%ecx)
+
+retstruct:
+ /* Nothing to do! */
+
+noretval:
+epilogue:
+ popl %esi
+ movl %ebp,%esp
+ popl %ebp
+ ret
+.LFE1:
+.ffi_call_SYSV_end:
+ .size ffi_call_SYSV,.ffi_call_SYSV_end-ffi_call_SYSV
+
+ .align 4
+FFI_HIDDEN (ffi_closure_SYSV)
+.globl ffi_closure_SYSV
+ .type ffi_closure_SYSV, @function
+
+ffi_closure_SYSV:
+.LFB2:
+ pushl %ebp
+.LCFI2:
+ movl %esp, %ebp
+.LCFI3:
+ subl $40, %esp
+ leal -24(%ebp), %edx
+ movl %edx, -12(%ebp) /* resp */
+ leal 8(%ebp), %edx
+#ifdef __SUNPRO_C
+ /* The SUNPRO compiler doesn't support GCC's regparm function
+ attribute, so we have to pass all three arguments to
+ ffi_closure_SYSV_inner on the stack. */
+ movl %edx, 8(%esp) /* args = __builtin_dwarf_cfa () */
+ leal -12(%ebp), %edx
+ movl %edx, 4(%esp) /* &resp */
+ movl %eax, (%esp) /* closure */
+#else
+ movl %edx, 4(%esp) /* args = __builtin_dwarf_cfa () */
+ leal -12(%ebp), %edx
+ movl %edx, (%esp) /* &resp */
+#endif
+#if defined HAVE_HIDDEN_VISIBILITY_ATTRIBUTE || !defined __PIC__
+ call ffi_closure_SYSV_inner
+#else
+ movl %ebx, 8(%esp)
+.LCFI7:
+ call 1f
+1: popl %ebx
+ addl $_GLOBAL_OFFSET_TABLE_+[.-1b], %ebx
+ call ffi_closure_SYSV_inner@PLT
+ movl 8(%esp), %ebx
+#endif
+ movl -12(%ebp), %ecx
+ cmpl $FFI_TYPE_INT, %eax
+ je .Lcls_retint
+
+ /* Handle FFI_TYPE_UINT8, FFI_TYPE_SINT8, FFI_TYPE_UINT16,
+ FFI_TYPE_SINT16, FFI_TYPE_UINT32, FFI_TYPE_SINT32. */
+ cmpl $FFI_TYPE_UINT64, %eax
+ jge 0f
+ cmpl $FFI_TYPE_UINT8, %eax
+ jge .Lcls_retint
+
+0: cmpl $FFI_TYPE_FLOAT, %eax
+ je .Lcls_retfloat
+ cmpl $FFI_TYPE_DOUBLE, %eax
+ je .Lcls_retdouble
+ cmpl $FFI_TYPE_LONGDOUBLE, %eax
+ je .Lcls_retldouble
+ cmpl $FFI_TYPE_SINT64, %eax
+ je .Lcls_retllong
+ cmpl $FFI_TYPE_STRUCT, %eax
+ je .Lcls_retstruct
+.Lcls_epilogue:
+ movl %ebp, %esp
+ popl %ebp
+ ret
+.Lcls_retint:
+ movl (%ecx), %eax
+ jmp .Lcls_epilogue
+.Lcls_retfloat:
+ flds (%ecx)
+ jmp .Lcls_epilogue
+.Lcls_retdouble:
+ fldl (%ecx)
+ jmp .Lcls_epilogue
+.Lcls_retldouble:
+ fldt (%ecx)
+ jmp .Lcls_epilogue
+.Lcls_retllong:
+ movl (%ecx), %eax
+ movl 4(%ecx), %edx
+ jmp .Lcls_epilogue
+.Lcls_retstruct:
+ movl %ebp, %esp
+ popl %ebp
+ ret $4
+.LFE2:
+ .size ffi_closure_SYSV, .-ffi_closure_SYSV
+
+#if !FFI_NO_RAW_API
+
+/* Precalculate for e.g. the Solaris 10/x86 assembler. */
+#if FFI_TRAMPOLINE_SIZE == 10
+#define RAW_CLOSURE_CIF_OFFSET 12
+#define RAW_CLOSURE_FUN_OFFSET 16
+#define RAW_CLOSURE_USER_DATA_OFFSET 20
+#elif FFI_TRAMPOLINE_SIZE == 24
+#define RAW_CLOSURE_CIF_OFFSET 24
+#define RAW_CLOSURE_FUN_OFFSET 28
+#define RAW_CLOSURE_USER_DATA_OFFSET 32
+#else
+#define RAW_CLOSURE_CIF_OFFSET ((FFI_TRAMPOLINE_SIZE + 3) & ~3)
+#define RAW_CLOSURE_FUN_OFFSET (RAW_CLOSURE_CIF_OFFSET + 4)
+#define RAW_CLOSURE_USER_DATA_OFFSET (RAW_CLOSURE_FUN_OFFSET + 4)
+#endif
+#define CIF_FLAGS_OFFSET 20
+
+ .align 4
+FFI_HIDDEN (ffi_closure_raw_SYSV)
+.globl ffi_closure_raw_SYSV
+ .type ffi_closure_raw_SYSV, @function
+
+ffi_closure_raw_SYSV:
+.LFB3:
+ pushl %ebp
+.LCFI4:
+ movl %esp, %ebp
+.LCFI5:
+ pushl %esi
+.LCFI6:
+ subl $36, %esp
+ movl RAW_CLOSURE_CIF_OFFSET(%eax), %esi /* closure->cif */
+ movl RAW_CLOSURE_USER_DATA_OFFSET(%eax), %edx /* closure->user_data */
+ movl %edx, 12(%esp) /* user_data */
+ leal 8(%ebp), %edx /* __builtin_dwarf_cfa () */
+ movl %edx, 8(%esp) /* raw_args */
+ leal -24(%ebp), %edx
+ movl %edx, 4(%esp) /* &res */
+ movl %esi, (%esp) /* cif */
+ call *RAW_CLOSURE_FUN_OFFSET(%eax) /* closure->fun */
+ movl CIF_FLAGS_OFFSET(%esi), %eax /* rtype */
+ cmpl $FFI_TYPE_INT, %eax
+ je .Lrcls_retint
+
+ /* Handle FFI_TYPE_UINT8, FFI_TYPE_SINT8, FFI_TYPE_UINT16,
+ FFI_TYPE_SINT16, FFI_TYPE_UINT32, FFI_TYPE_SINT32. */
+ cmpl $FFI_TYPE_UINT64, %eax
+ jge 0f
+ cmpl $FFI_TYPE_UINT8, %eax
+ jge .Lrcls_retint
+0:
+ cmpl $FFI_TYPE_FLOAT, %eax
+ je .Lrcls_retfloat
+ cmpl $FFI_TYPE_DOUBLE, %eax
+ je .Lrcls_retdouble
+ cmpl $FFI_TYPE_LONGDOUBLE, %eax
+ je .Lrcls_retldouble
+ cmpl $FFI_TYPE_SINT64, %eax
+ je .Lrcls_retllong
+.Lrcls_epilogue:
+ addl $36, %esp
+ popl %esi
+ popl %ebp
+ ret
+.Lrcls_retint:
+ movl -24(%ebp), %eax
+ jmp .Lrcls_epilogue
+.Lrcls_retfloat:
+ flds -24(%ebp)
+ jmp .Lrcls_epilogue
+.Lrcls_retdouble:
+ fldl -24(%ebp)
+ jmp .Lrcls_epilogue
+.Lrcls_retldouble:
+ fldt -24(%ebp)
+ jmp .Lrcls_epilogue
+.Lrcls_retllong:
+ movl -24(%ebp), %eax
+ movl -20(%ebp), %edx
+ jmp .Lrcls_epilogue
+.LFE3:
+ .size ffi_closure_raw_SYSV, .-ffi_closure_raw_SYSV
+#endif
+
+#if defined __GNUC__
+/* Only emit dwarf unwind info when building with GNU toolchain. */
+
+#if defined __PIC__
+# if defined __sun__ && defined __svr4__
+/* 32-bit Solaris 2/x86 uses datarel encoding for PIC. GNU ld before 2.22
+ doesn't correctly sort .eh_frame_hdr with mixed encodings, so match this. */
+# define FDE_ENCODING 0x30 /* datarel */
+# define FDE_ENCODE(X) X@GOTOFF
+# else
+# define FDE_ENCODING 0x1b /* pcrel sdata4 */
+# if defined HAVE_AS_X86_PCREL
+# define FDE_ENCODE(X) X-.
+# else
+# define FDE_ENCODE(X) X@rel
+# endif
+# endif
+#else
+# define FDE_ENCODING 0 /* absolute */
+# define FDE_ENCODE(X) X
+#endif
+
+ .section .eh_frame,EH_FRAME_FLAGS,@progbits
+.Lframe1:
+ .long .LECIE1-.LSCIE1 /* Length of Common Information Entry */
+.LSCIE1:
+ .long 0x0 /* CIE Identifier Tag */
+ .byte 0x1 /* CIE Version */
+#ifdef HAVE_AS_ASCII_PSEUDO_OP
+#ifdef __PIC__
+ .ascii "zR\0" /* CIE Augmentation */
+#else
+ .ascii "\0" /* CIE Augmentation */
+#endif
+#elif defined HAVE_AS_STRING_PSEUDO_OP
+#ifdef __PIC__
+ .string "zR" /* CIE Augmentation */
+#else
+ .string "" /* CIE Augmentation */
+#endif
+#else
+#error missing .ascii/.string
+#endif
+ .byte 0x1 /* .uleb128 0x1; CIE Code Alignment Factor */
+ .byte 0x7c /* .sleb128 -4; CIE Data Alignment Factor */
+ .byte 0x8 /* CIE RA Column */
+#ifdef __PIC__
+ .byte 0x1 /* .uleb128 0x1; Augmentation size */
+ .byte FDE_ENCODING
+#endif
+ .byte 0xc /* DW_CFA_def_cfa */
+ .byte 0x4 /* .uleb128 0x4 */
+ .byte 0x4 /* .uleb128 0x4 */
+ .byte 0x88 /* DW_CFA_offset, column 0x8 */
+ .byte 0x1 /* .uleb128 0x1 */
+ .align 4
+.LECIE1:
+.LSFDE1:
+ .long .LEFDE1-.LASFDE1 /* FDE Length */
+.LASFDE1:
+ .long .LASFDE1-.Lframe1 /* FDE CIE offset */
+ .long FDE_ENCODE(.LFB1) /* FDE initial location */
+ .long .LFE1-.LFB1 /* FDE address range */
+#ifdef __PIC__
+ .byte 0x0 /* .uleb128 0x0; Augmentation size */
+#endif
+ .byte 0x4 /* DW_CFA_advance_loc4 */
+ .long .LCFI0-.LFB1
+ .byte 0xe /* DW_CFA_def_cfa_offset */
+ .byte 0x8 /* .uleb128 0x8 */
+ .byte 0x85 /* DW_CFA_offset, column 0x5 */
+ .byte 0x2 /* .uleb128 0x2 */
+ .byte 0x4 /* DW_CFA_advance_loc4 */
+ .long .LCFI1-.LCFI0
+ .byte 0xd /* DW_CFA_def_cfa_register */
+ .byte 0x5 /* .uleb128 0x5 */
+ .align 4
+.LEFDE1:
+.LSFDE2:
+ .long .LEFDE2-.LASFDE2 /* FDE Length */
+.LASFDE2:
+ .long .LASFDE2-.Lframe1 /* FDE CIE offset */
+ .long FDE_ENCODE(.LFB2) /* FDE initial location */
+ .long .LFE2-.LFB2 /* FDE address range */
+#ifdef __PIC__
+ .byte 0x0 /* .uleb128 0x0; Augmentation size */
+#endif
+ .byte 0x4 /* DW_CFA_advance_loc4 */
+ .long .LCFI2-.LFB2
+ .byte 0xe /* DW_CFA_def_cfa_offset */
+ .byte 0x8 /* .uleb128 0x8 */
+ .byte 0x85 /* DW_CFA_offset, column 0x5 */
+ .byte 0x2 /* .uleb128 0x2 */
+ .byte 0x4 /* DW_CFA_advance_loc4 */
+ .long .LCFI3-.LCFI2
+ .byte 0xd /* DW_CFA_def_cfa_register */
+ .byte 0x5 /* .uleb128 0x5 */
+#if !defined HAVE_HIDDEN_VISIBILITY_ATTRIBUTE && defined __PIC__
+ .byte 0x4 /* DW_CFA_advance_loc4 */
+ .long .LCFI7-.LCFI3
+ .byte 0x83 /* DW_CFA_offset, column 0x3 */
+ .byte 0xa /* .uleb128 0xa */
+#endif
+ .align 4
+.LEFDE2:
+
+#if !FFI_NO_RAW_API
+
+.LSFDE3:
+ .long .LEFDE3-.LASFDE3 /* FDE Length */
+.LASFDE3:
+ .long .LASFDE3-.Lframe1 /* FDE CIE offset */
+ .long FDE_ENCODE(.LFB3) /* FDE initial location */
+ .long .LFE3-.LFB3 /* FDE address range */
+#ifdef __PIC__
+ .byte 0x0 /* .uleb128 0x0; Augmentation size */
+#endif
+ .byte 0x4 /* DW_CFA_advance_loc4 */
+ .long .LCFI4-.LFB3
+ .byte 0xe /* DW_CFA_def_cfa_offset */
+ .byte 0x8 /* .uleb128 0x8 */
+ .byte 0x85 /* DW_CFA_offset, column 0x5 */
+ .byte 0x2 /* .uleb128 0x2 */
+ .byte 0x4 /* DW_CFA_advance_loc4 */
+ .long .LCFI5-.LCFI4
+ .byte 0xd /* DW_CFA_def_cfa_register */
+ .byte 0x5 /* .uleb128 0x5 */
+ .byte 0x4 /* DW_CFA_advance_loc4 */
+ .long .LCFI6-.LCFI5
+ .byte 0x86 /* DW_CFA_offset, column 0x6 */
+ .byte 0x3 /* .uleb128 0x3 */
+ .align 4
+.LEFDE3:
+
+#endif
+#endif
+
+#endif /* ifndef __x86_64__ */
+
+#if defined __ELF__ && defined __linux__
+ .section .note.GNU-stack,"",@progbits
+#endif
diff --git a/jni/ruby/ext/fiddle/libffi-3.2.1/src/x86/unix64.S b/jni/ruby/ext/fiddle/libffi-3.2.1/src/x86/unix64.S
new file mode 100644
index 0000000..dcd6bc7
--- /dev/null
+++ b/jni/ruby/ext/fiddle/libffi-3.2.1/src/x86/unix64.S
@@ -0,0 +1,432 @@
+/* -----------------------------------------------------------------------
+ unix64.S - Copyright (c) 2013 The Written Word, Inc.
+ - Copyright (c) 2008 Red Hat, Inc
+ - Copyright (c) 2002 Bo Thorsen <bo@suse.de>
+
+ x86-64 Foreign Function Interface
+
+ Permission is hereby granted, free of charge, to any person obtaining
+ a copy of this software and associated documentation files (the
+ ``Software''), to deal in the Software without restriction, including
+ without limitation the rights to use, copy, modify, merge, publish,
+ distribute, sublicense, and/or sell copies of the Software, and to
+ permit persons to whom the Software is furnished to do so, subject to
+ the following conditions:
+
+ The above copyright notice and this permission notice shall be included
+ in all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND,
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+ HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ DEALINGS IN THE SOFTWARE.
+ ----------------------------------------------------------------------- */
+
+#ifdef __x86_64__
+#define LIBFFI_ASM
+#include <fficonfig.h>
+#include <ffi.h>
+
+.text
+
+/* ffi_call_unix64 (void *args, unsigned long bytes, unsigned flags,
+ void *raddr, void (*fnaddr)(void));
+
+ Bit o trickiness here -- ARGS+BYTES is the base of the stack frame
+ for this function. This has been allocated by ffi_call. We also
+ deallocate some of the stack that has been alloca'd. */
+
+ .align 2
+ .globl ffi_call_unix64
+ .type ffi_call_unix64,@function
+
+ffi_call_unix64:
+.LUW0:
+ movq (%rsp), %r10 /* Load return address. */
+ leaq (%rdi, %rsi), %rax /* Find local stack base. */
+ movq %rdx, (%rax) /* Save flags. */
+ movq %rcx, 8(%rax) /* Save raddr. */
+ movq %rbp, 16(%rax) /* Save old frame pointer. */
+ movq %r10, 24(%rax) /* Relocate return address. */
+ movq %rax, %rbp /* Finalize local stack frame. */
+.LUW1:
+ movq %rdi, %r10 /* Save a copy of the register area. */
+ movq %r8, %r11 /* Save a copy of the target fn. */
+ movl %r9d, %eax /* Set number of SSE registers. */
+
+ /* Load up all argument registers. */
+ movq (%r10), %rdi
+ movq 8(%r10), %rsi
+ movq 16(%r10), %rdx
+ movq 24(%r10), %rcx
+ movq 32(%r10), %r8
+ movq 40(%r10), %r9
+ testl %eax, %eax
+ jnz .Lload_sse
+.Lret_from_load_sse:
+
+ /* Deallocate the reg arg area. */
+ leaq 176(%r10), %rsp
+
+ /* Call the user function. */
+ call *%r11
+
+ /* Deallocate stack arg area; local stack frame in redzone. */
+ leaq 24(%rbp), %rsp
+
+ movq 0(%rbp), %rcx /* Reload flags. */
+ movq 8(%rbp), %rdi /* Reload raddr. */
+ movq 16(%rbp), %rbp /* Reload old frame pointer. */
+.LUW2:
+
+ /* The first byte of the flags contains the FFI_TYPE. */
+ movzbl %cl, %r10d
+ leaq .Lstore_table(%rip), %r11
+ movslq (%r11, %r10, 4), %r10
+ addq %r11, %r10
+ jmp *%r10
+
+.Lstore_table:
+ .long .Lst_void-.Lstore_table /* FFI_TYPE_VOID */
+ .long .Lst_sint32-.Lstore_table /* FFI_TYPE_INT */
+ .long .Lst_float-.Lstore_table /* FFI_TYPE_FLOAT */
+ .long .Lst_double-.Lstore_table /* FFI_TYPE_DOUBLE */
+ .long .Lst_ldouble-.Lstore_table /* FFI_TYPE_LONGDOUBLE */
+ .long .Lst_uint8-.Lstore_table /* FFI_TYPE_UINT8 */
+ .long .Lst_sint8-.Lstore_table /* FFI_TYPE_SINT8 */
+ .long .Lst_uint16-.Lstore_table /* FFI_TYPE_UINT16 */
+ .long .Lst_sint16-.Lstore_table /* FFI_TYPE_SINT16 */
+ .long .Lst_uint32-.Lstore_table /* FFI_TYPE_UINT32 */
+ .long .Lst_sint32-.Lstore_table /* FFI_TYPE_SINT32 */
+ .long .Lst_int64-.Lstore_table /* FFI_TYPE_UINT64 */
+ .long .Lst_int64-.Lstore_table /* FFI_TYPE_SINT64 */
+ .long .Lst_struct-.Lstore_table /* FFI_TYPE_STRUCT */
+ .long .Lst_int64-.Lstore_table /* FFI_TYPE_POINTER */
+
+ .align 2
+.Lst_void:
+ ret
+ .align 2
+
+.Lst_uint8:
+ movzbq %al, %rax
+ movq %rax, (%rdi)
+ ret
+ .align 2
+.Lst_sint8:
+ movsbq %al, %rax
+ movq %rax, (%rdi)
+ ret
+ .align 2
+.Lst_uint16:
+ movzwq %ax, %rax
+ movq %rax, (%rdi)
+ .align 2
+.Lst_sint16:
+ movswq %ax, %rax
+ movq %rax, (%rdi)
+ ret
+ .align 2
+.Lst_uint32:
+ movl %eax, %eax
+ movq %rax, (%rdi)
+ .align 2
+.Lst_sint32:
+ cltq
+ movq %rax, (%rdi)
+ ret
+ .align 2
+.Lst_int64:
+ movq %rax, (%rdi)
+ ret
+
+ .align 2
+.Lst_float:
+ movss %xmm0, (%rdi)
+ ret
+ .align 2
+.Lst_double:
+ movsd %xmm0, (%rdi)
+ ret
+.Lst_ldouble:
+ fstpt (%rdi)
+ ret
+
+ .align 2
+.Lst_struct:
+ leaq -20(%rsp), %rsi /* Scratch area in redzone. */
+
+ /* We have to locate the values now, and since we don't want to
+ write too much data into the user's return value, we spill the
+ value to a 16 byte scratch area first. Bits 8, 9, and 10
+ control where the values are located. Only one of the three
+ bits will be set; see ffi_prep_cif_machdep for the pattern. */
+ movd %xmm0, %r10
+ movd %xmm1, %r11
+ testl $0x100, %ecx
+ cmovnz %rax, %rdx
+ cmovnz %r10, %rax
+ testl $0x200, %ecx
+ cmovnz %r10, %rdx
+ testl $0x400, %ecx
+ cmovnz %r10, %rax
+ cmovnz %r11, %rdx
+ movq %rax, (%rsi)
+ movq %rdx, 8(%rsi)
+
+ /* Bits 12-31 contain the true size of the structure. Copy from
+ the scratch area to the true destination. */
+ shrl $12, %ecx
+ rep movsb
+ ret
+
+ /* Many times we can avoid loading any SSE registers at all.
+ It's not worth an indirect jump to load the exact set of
+ SSE registers needed; zero or all is a good compromise. */
+ .align 2
+.LUW3:
+.Lload_sse:
+ movdqa 48(%r10), %xmm0
+ movdqa 64(%r10), %xmm1
+ movdqa 80(%r10), %xmm2
+ movdqa 96(%r10), %xmm3
+ movdqa 112(%r10), %xmm4
+ movdqa 128(%r10), %xmm5
+ movdqa 144(%r10), %xmm6
+ movdqa 160(%r10), %xmm7
+ jmp .Lret_from_load_sse
+
+.LUW4:
+ .size ffi_call_unix64,.-ffi_call_unix64
+
+ .align 2
+ .globl ffi_closure_unix64
+ .type ffi_closure_unix64,@function
+
+ffi_closure_unix64:
+.LUW5:
+ /* The carry flag is set by the trampoline iff SSE registers
+ are used. Don't clobber it before the branch instruction. */
+ leaq -200(%rsp), %rsp
+.LUW6:
+ movq %rdi, (%rsp)
+ movq %rsi, 8(%rsp)
+ movq %rdx, 16(%rsp)
+ movq %rcx, 24(%rsp)
+ movq %r8, 32(%rsp)
+ movq %r9, 40(%rsp)
+ jc .Lsave_sse
+.Lret_from_save_sse:
+
+ movq %r10, %rdi
+ leaq 176(%rsp), %rsi
+ movq %rsp, %rdx
+ leaq 208(%rsp), %rcx
+ call ffi_closure_unix64_inner@PLT
+
+ /* Deallocate stack frame early; return value is now in redzone. */
+ addq $200, %rsp
+.LUW7:
+
+ /* The first byte of the return value contains the FFI_TYPE. */
+ movzbl %al, %r10d
+ leaq .Lload_table(%rip), %r11
+ movslq (%r11, %r10, 4), %r10
+ addq %r11, %r10
+ jmp *%r10
+
+.Lload_table:
+ .long .Lld_void-.Lload_table /* FFI_TYPE_VOID */
+ .long .Lld_int32-.Lload_table /* FFI_TYPE_INT */
+ .long .Lld_float-.Lload_table /* FFI_TYPE_FLOAT */
+ .long .Lld_double-.Lload_table /* FFI_TYPE_DOUBLE */
+ .long .Lld_ldouble-.Lload_table /* FFI_TYPE_LONGDOUBLE */
+ .long .Lld_int8-.Lload_table /* FFI_TYPE_UINT8 */
+ .long .Lld_int8-.Lload_table /* FFI_TYPE_SINT8 */
+ .long .Lld_int16-.Lload_table /* FFI_TYPE_UINT16 */
+ .long .Lld_int16-.Lload_table /* FFI_TYPE_SINT16 */
+ .long .Lld_int32-.Lload_table /* FFI_TYPE_UINT32 */
+ .long .Lld_int32-.Lload_table /* FFI_TYPE_SINT32 */
+ .long .Lld_int64-.Lload_table /* FFI_TYPE_UINT64 */
+ .long .Lld_int64-.Lload_table /* FFI_TYPE_SINT64 */
+ .long .Lld_struct-.Lload_table /* FFI_TYPE_STRUCT */
+ .long .Lld_int64-.Lload_table /* FFI_TYPE_POINTER */
+
+ .align 2
+.Lld_void:
+ ret
+
+ .align 2
+.Lld_int8:
+ movzbl -24(%rsp), %eax
+ ret
+ .align 2
+.Lld_int16:
+ movzwl -24(%rsp), %eax
+ ret
+ .align 2
+.Lld_int32:
+ movl -24(%rsp), %eax
+ ret
+ .align 2
+.Lld_int64:
+ movq -24(%rsp), %rax
+ ret
+
+ .align 2
+.Lld_float:
+ movss -24(%rsp), %xmm0
+ ret
+ .align 2
+.Lld_double:
+ movsd -24(%rsp), %xmm0
+ ret
+ .align 2
+.Lld_ldouble:
+ fldt -24(%rsp)
+ ret
+
+ .align 2
+.Lld_struct:
+ /* There are four possibilities here, %rax/%rdx, %xmm0/%rax,
+ %rax/%xmm0, %xmm0/%xmm1. We collapse two by always loading
+ both rdx and xmm1 with the second word. For the remaining,
+ bit 8 set means xmm0 gets the second word, and bit 9 means
+ that rax gets the second word. */
+ movq -24(%rsp), %rcx
+ movq -16(%rsp), %rdx
+ movq -16(%rsp), %xmm1
+ testl $0x100, %eax
+ cmovnz %rdx, %rcx
+ movd %rcx, %xmm0
+ testl $0x200, %eax
+ movq -24(%rsp), %rax
+ cmovnz %rdx, %rax
+ ret
+
+ /* See the comment above .Lload_sse; the same logic applies here. */
+ .align 2
+.LUW8:
+.Lsave_sse:
+ movdqa %xmm0, 48(%rsp)
+ movdqa %xmm1, 64(%rsp)
+ movdqa %xmm2, 80(%rsp)
+ movdqa %xmm3, 96(%rsp)
+ movdqa %xmm4, 112(%rsp)
+ movdqa %xmm5, 128(%rsp)
+ movdqa %xmm6, 144(%rsp)
+ movdqa %xmm7, 160(%rsp)
+ jmp .Lret_from_save_sse
+
+.LUW9:
+ .size ffi_closure_unix64,.-ffi_closure_unix64
+
+#ifdef __GNUC__
+/* Only emit DWARF unwind info when building with the GNU toolchain. */
+
+#ifdef HAVE_AS_X86_64_UNWIND_SECTION_TYPE
+ .section .eh_frame,"a",@unwind
+#else
+ .section .eh_frame,"a",@progbits
+#endif
+.Lframe1:
+ .long .LECIE1-.LSCIE1 /* CIE Length */
+.LSCIE1:
+ .long 0 /* CIE Identifier Tag */
+ .byte 1 /* CIE Version */
+ .ascii "zR\0" /* CIE Augmentation */
+ .uleb128 1 /* CIE Code Alignment Factor */
+ .sleb128 -8 /* CIE Data Alignment Factor */
+ .byte 0x10 /* CIE RA Column */
+ .uleb128 1 /* Augmentation size */
+ .byte 0x1b /* FDE Encoding (pcrel sdata4) */
+ .byte 0xc /* DW_CFA_def_cfa, %rsp offset 8 */
+ .uleb128 7
+ .uleb128 8
+ .byte 0x80+16 /* DW_CFA_offset, %rip offset 1*-8 */
+ .uleb128 1
+ .align 8
+.LECIE1:
+.LSFDE1:
+ .long .LEFDE1-.LASFDE1 /* FDE Length */
+.LASFDE1:
+ .long .LASFDE1-.Lframe1 /* FDE CIE offset */
+#if HAVE_AS_X86_PCREL
+ .long .LUW0-. /* FDE initial location */
+#else
+ .long .LUW0@rel
+#endif
+ .long .LUW4-.LUW0 /* FDE address range */
+ .uleb128 0x0 /* Augmentation size */
+
+ .byte 0x4 /* DW_CFA_advance_loc4 */
+ .long .LUW1-.LUW0
+
+ /* New stack frame based off rbp. This is a itty bit of unwind
+ trickery in that the CFA *has* changed. There is no easy way
+ to describe it correctly on entry to the function. Fortunately,
+ it doesn't matter too much since at all points we can correctly
+ unwind back to ffi_call. Note that the location to which we
+ moved the return address is (the new) CFA-8, so from the
+ perspective of the unwind info, it hasn't moved. */
+ .byte 0xc /* DW_CFA_def_cfa, %rbp offset 32 */
+ .uleb128 6
+ .uleb128 32
+ .byte 0x80+6 /* DW_CFA_offset, %rbp offset 2*-8 */
+ .uleb128 2
+ .byte 0xa /* DW_CFA_remember_state */
+
+ .byte 0x4 /* DW_CFA_advance_loc4 */
+ .long .LUW2-.LUW1
+ .byte 0xc /* DW_CFA_def_cfa, %rsp offset 8 */
+ .uleb128 7
+ .uleb128 8
+ .byte 0xc0+6 /* DW_CFA_restore, %rbp */
+
+ .byte 0x4 /* DW_CFA_advance_loc4 */
+ .long .LUW3-.LUW2
+ .byte 0xb /* DW_CFA_restore_state */
+
+ .align 8
+.LEFDE1:
+.LSFDE3:
+ .long .LEFDE3-.LASFDE3 /* FDE Length */
+.LASFDE3:
+ .long .LASFDE3-.Lframe1 /* FDE CIE offset */
+#if HAVE_AS_X86_PCREL
+ .long .LUW5-. /* FDE initial location */
+#else
+ .long .LUW5@rel
+#endif
+ .long .LUW9-.LUW5 /* FDE address range */
+ .uleb128 0x0 /* Augmentation size */
+
+ .byte 0x4 /* DW_CFA_advance_loc4 */
+ .long .LUW6-.LUW5
+ .byte 0xe /* DW_CFA_def_cfa_offset */
+ .uleb128 208
+ .byte 0xa /* DW_CFA_remember_state */
+
+ .byte 0x4 /* DW_CFA_advance_loc4 */
+ .long .LUW7-.LUW6
+ .byte 0xe /* DW_CFA_def_cfa_offset */
+ .uleb128 8
+
+ .byte 0x4 /* DW_CFA_advance_loc4 */
+ .long .LUW8-.LUW7
+ .byte 0xb /* DW_CFA_restore_state */
+
+ .align 8
+.LEFDE3:
+
+#endif /* __GNUC__ */
+
+#endif /* __x86_64__ */
+
+#if defined __ELF__ && defined __linux__
+ .section .note.GNU-stack,"",@progbits
+#endif
diff --git a/jni/ruby/ext/fiddle/libffi-3.2.1/src/x86/win32.S b/jni/ruby/ext/fiddle/libffi-3.2.1/src/x86/win32.S
new file mode 100644
index 0000000..3680bf5
--- /dev/null
+++ b/jni/ruby/ext/fiddle/libffi-3.2.1/src/x86/win32.S
@@ -0,0 +1,1351 @@
+/* -----------------------------------------------------------------------
+ win32.S - Copyright (c) 2014 Anthony Green
+ Copyright (c) 1996, 1998, 2001, 2002, 2009 Red Hat, Inc.
+ Copyright (c) 2001 John Beniton
+ Copyright (c) 2002 Ranjit Mathew
+ Copyright (c) 2009 Daniel Witte
+
+
+ X86 Foreign Function Interface
+
+ Permission is hereby granted, free of charge, to any person obtaining
+ a copy of this software and associated documentation files (the
+ ``Software''), to deal in the Software without restriction, including
+ without limitation the rights to use, copy, modify, merge, publish,
+ distribute, sublicense, and/or sell copies of the Software, and to
+ permit persons to whom the Software is furnished to do so, subject to
+ the following conditions:
+
+ The above copyright notice and this permission notice shall be included
+ in all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND,
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+ HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ DEALINGS IN THE SOFTWARE.
+ -----------------------------------------------------------------------
+ */
+
+#define LIBFFI_ASM
+#include <fficonfig.h>
+#include <ffi.h>
+
+#define CIF_BYTES_OFFSET 16
+#define CIF_FLAGS_OFFSET 20
+
+#ifdef _MSC_VER
+
+#define CLOSURE_CIF_OFFSET ((FFI_TRAMPOLINE_SIZE + 3) AND NOT 3)
+
+.386
+.MODEL FLAT, C
+
+EXTRN ffi_closure_SYSV_inner:NEAR
+EXTRN ffi_closure_WIN32_inner:NEAR
+
+_TEXT SEGMENT
+
+ffi_call_win32 PROC NEAR,
+ ffi_prep_args : NEAR PTR DWORD,
+ ecif : NEAR PTR DWORD,
+ cif_abi : DWORD,
+ cif_bytes : DWORD,
+ cif_flags : DWORD,
+ rvalue : NEAR PTR DWORD,
+ fn : NEAR PTR DWORD
+
+ ;; Make room for all of the new args.
+ mov ecx, cif_bytes
+ sub esp, ecx
+
+ mov eax, esp
+
+ ;; Call ffi_prep_args
+ push ecif
+ push eax
+ call ffi_prep_args
+ add esp, 8
+
+ ;; Prepare registers
+ ;; EAX stores the number of register arguments
+ cmp eax, 0
+ je fun
+ cmp eax, 3
+ jl prepr_two_cmp
+
+ mov ecx, esp
+ add esp, 12
+ mov eax, DWORD PTR [ecx+8]
+ jmp prepr_two
+prepr_two_cmp:
+ cmp eax, 2
+ jl prepr_one_prep
+ mov ecx, esp
+ add esp, 8
+prepr_two:
+ mov edx, DWORD PTR [ecx+4]
+ jmp prepr_one
+prepr_one_prep:
+ mov ecx, esp
+ add esp, 4
+prepr_one:
+ mov ecx, DWORD PTR [ecx]
+ cmp cif_abi, 7 ;; FFI_REGISTER
+ jne fun
+
+ xchg ecx, eax
+
+fun:
+ ;; Call function
+ call fn
+
+ ;; Load ecx with the return type code
+ mov ecx, cif_flags
+
+ ;; If the return value pointer is NULL, assume no return value.
+ cmp rvalue, 0
+ jne ca_jumptable
+
+ ;; Even if there is no space for the return value, we are
+ ;; obliged to handle floating-point values.
+ cmp ecx, FFI_TYPE_FLOAT
+ jne ca_epilogue
+ fstp st(0)
+
+ jmp ca_epilogue
+
+ca_jumptable:
+ jmp [ca_jumpdata + 4 * ecx]
+ca_jumpdata:
+ ;; Do not insert anything here between label and jump table.
+ dd offset ca_epilogue ;; FFI_TYPE_VOID
+ dd offset ca_retint ;; FFI_TYPE_INT
+ dd offset ca_retfloat ;; FFI_TYPE_FLOAT
+ dd offset ca_retdouble ;; FFI_TYPE_DOUBLE
+ dd offset ca_retlongdouble ;; FFI_TYPE_LONGDOUBLE
+ dd offset ca_retuint8 ;; FFI_TYPE_UINT8
+ dd offset ca_retsint8 ;; FFI_TYPE_SINT8
+ dd offset ca_retuint16 ;; FFI_TYPE_UINT16
+ dd offset ca_retsint16 ;; FFI_TYPE_SINT16
+ dd offset ca_retint ;; FFI_TYPE_UINT32
+ dd offset ca_retint ;; FFI_TYPE_SINT32
+ dd offset ca_retint64 ;; FFI_TYPE_UINT64
+ dd offset ca_retint64 ;; FFI_TYPE_SINT64
+ dd offset ca_epilogue ;; FFI_TYPE_STRUCT
+ dd offset ca_retint ;; FFI_TYPE_POINTER
+ dd offset ca_retstruct1b ;; FFI_TYPE_SMALL_STRUCT_1B
+ dd offset ca_retstruct2b ;; FFI_TYPE_SMALL_STRUCT_2B
+ dd offset ca_retint ;; FFI_TYPE_SMALL_STRUCT_4B
+ dd offset ca_epilogue ;; FFI_TYPE_MS_STRUCT
+
+ /* Sign/zero extend as appropriate. */
+ca_retuint8:
+ movzx eax, al
+ jmp ca_retint
+
+ca_retsint8:
+ movsx eax, al
+ jmp ca_retint
+
+ca_retuint16:
+ movzx eax, ax
+ jmp ca_retint
+
+ca_retsint16:
+ movsx eax, ax
+ jmp ca_retint
+
+ca_retint:
+ ;; Load %ecx with the pointer to storage for the return value
+ mov ecx, rvalue
+ mov [ecx + 0], eax
+ jmp ca_epilogue
+
+ca_retint64:
+ ;; Load %ecx with the pointer to storage for the return value
+ mov ecx, rvalue
+ mov [ecx + 0], eax
+ mov [ecx + 4], edx
+ jmp ca_epilogue
+
+ca_retfloat:
+ ;; Load %ecx with the pointer to storage for the return value
+ mov ecx, rvalue
+ fstp DWORD PTR [ecx]
+ jmp ca_epilogue
+
+ca_retdouble:
+ ;; Load %ecx with the pointer to storage for the return value
+ mov ecx, rvalue
+ fstp QWORD PTR [ecx]
+ jmp ca_epilogue
+
+ca_retlongdouble:
+ ;; Load %ecx with the pointer to storage for the return value
+ mov ecx, rvalue
+ fstp TBYTE PTR [ecx]
+ jmp ca_epilogue
+
+ca_retstruct1b:
+ ;; Load %ecx with the pointer to storage for the return value
+ mov ecx, rvalue
+ mov [ecx + 0], al
+ jmp ca_epilogue
+
+ca_retstruct2b:
+ ;; Load %ecx with the pointer to storage for the return value
+ mov ecx, rvalue
+ mov [ecx + 0], ax
+ jmp ca_epilogue
+
+ca_epilogue:
+ ;; Epilogue code is autogenerated.
+ ret
+ffi_call_win32 ENDP
+
+ffi_closure_THISCALL PROC NEAR
+ ;; Insert the register argument on the stack as the first argument
+ xchg DWORD PTR [esp+4], ecx
+ xchg DWORD PTR [esp], ecx
+ push ecx
+ jmp ffi_closure_STDCALL
+ffi_closure_THISCALL ENDP
+
+ffi_closure_FASTCALL PROC NEAR
+ ;; Insert the 2 register arguments on the stack as the first argument
+ xchg DWORD PTR [esp+4], edx
+ xchg DWORD PTR [esp], ecx
+ push edx
+ push ecx
+ jmp ffi_closure_STDCALL
+ffi_closure_FASTCALL ENDP
+
+ffi_closure_REGISTER PROC NEAR
+ ;; Insert the 3 register arguments on the stack as the first argument
+ push eax
+ xchg DWORD PTR [esp+8], ecx
+ xchg DWORD PTR [esp+4], edx
+ push ecx
+ push edx
+ jmp ffi_closure_STDCALL
+ffi_closure_REGISTER ENDP
+
+ffi_closure_SYSV PROC NEAR FORCEFRAME
+ ;; the ffi_closure ctx is passed in eax by the trampoline.
+
+ sub esp, 40
+ lea edx, [ebp - 24]
+ mov [ebp - 12], edx ;; resp
+ lea edx, [ebp + 8]
+stub::
+ mov [esp + 8], edx ;; args
+ lea edx, [ebp - 12]
+ mov [esp + 4], edx ;; &resp
+ mov [esp], eax ;; closure
+ call ffi_closure_SYSV_inner
+ mov ecx, [ebp - 12]
+
+cs_jumptable:
+ jmp [cs_jumpdata + 4 * eax]
+cs_jumpdata:
+ ;; Do not insert anything here between the label and jump table.
+ dd offset cs_epilogue ;; FFI_TYPE_VOID
+ dd offset cs_retint ;; FFI_TYPE_INT
+ dd offset cs_retfloat ;; FFI_TYPE_FLOAT
+ dd offset cs_retdouble ;; FFI_TYPE_DOUBLE
+ dd offset cs_retlongdouble ;; FFI_TYPE_LONGDOUBLE
+ dd offset cs_retuint8 ;; FFI_TYPE_UINT8
+ dd offset cs_retsint8 ;; FFI_TYPE_SINT8
+ dd offset cs_retuint16 ;; FFI_TYPE_UINT16
+ dd offset cs_retsint16 ;; FFI_TYPE_SINT16
+ dd offset cs_retint ;; FFI_TYPE_UINT32
+ dd offset cs_retint ;; FFI_TYPE_SINT32
+ dd offset cs_retint64 ;; FFI_TYPE_UINT64
+ dd offset cs_retint64 ;; FFI_TYPE_SINT64
+ dd offset cs_retstruct ;; FFI_TYPE_STRUCT
+ dd offset cs_retint ;; FFI_TYPE_POINTER
+ dd offset cs_retsint8 ;; FFI_TYPE_SMALL_STRUCT_1B
+ dd offset cs_retsint16 ;; FFI_TYPE_SMALL_STRUCT_2B
+ dd offset cs_retint ;; FFI_TYPE_SMALL_STRUCT_4B
+ dd offset cs_retmsstruct ;; FFI_TYPE_MS_STRUCT
+
+cs_retuint8:
+ movzx eax, BYTE PTR [ecx]
+ jmp cs_epilogue
+
+cs_retsint8:
+ movsx eax, BYTE PTR [ecx]
+ jmp cs_epilogue
+
+cs_retuint16:
+ movzx eax, WORD PTR [ecx]
+ jmp cs_epilogue
+
+cs_retsint16:
+ movsx eax, WORD PTR [ecx]
+ jmp cs_epilogue
+
+cs_retint:
+ mov eax, [ecx]
+ jmp cs_epilogue
+
+cs_retint64:
+ mov eax, [ecx + 0]
+ mov edx, [ecx + 4]
+ jmp cs_epilogue
+
+cs_retfloat:
+ fld DWORD PTR [ecx]
+ jmp cs_epilogue
+
+cs_retdouble:
+ fld QWORD PTR [ecx]
+ jmp cs_epilogue
+
+cs_retlongdouble:
+ fld TBYTE PTR [ecx]
+ jmp cs_epilogue
+
+cs_retstruct:
+ ;; Caller expects us to pop struct return value pointer hidden arg.
+ ;; Epilogue code is autogenerated.
+ ret 4
+
+cs_retmsstruct:
+ ;; Caller expects us to return a pointer to the real return value.
+ mov eax, ecx
+ ;; Caller doesn't expects us to pop struct return value pointer hidden arg.
+ jmp cs_epilogue
+
+cs_epilogue:
+ ;; Epilogue code is autogenerated.
+ ret
+ffi_closure_SYSV ENDP
+
+#if !FFI_NO_RAW_API
+
+#define RAW_CLOSURE_CIF_OFFSET ((FFI_TRAMPOLINE_SIZE + 3) AND NOT 3)
+#define RAW_CLOSURE_FUN_OFFSET (RAW_CLOSURE_CIF_OFFSET + 4)
+#define RAW_CLOSURE_USER_DATA_OFFSET (RAW_CLOSURE_FUN_OFFSET + 4)
+
+ffi_closure_raw_THISCALL PROC NEAR USES esi FORCEFRAME
+ sub esp, 36
+ mov esi, [eax + RAW_CLOSURE_CIF_OFFSET] ;; closure->cif
+ mov edx, [eax + RAW_CLOSURE_USER_DATA_OFFSET] ;; closure->user_data
+ mov [esp + 12], edx
+ lea edx, [ebp + 12]
+ jmp stubraw
+ffi_closure_raw_THISCALL ENDP
+
+ffi_closure_raw_SYSV PROC NEAR USES esi FORCEFRAME
+ ;; the ffi_closure ctx is passed in eax by the trampoline.
+
+ sub esp, 40
+ mov esi, [eax + RAW_CLOSURE_CIF_OFFSET] ;; closure->cif
+ mov edx, [eax + RAW_CLOSURE_USER_DATA_OFFSET] ;; closure->user_data
+ mov [esp + 12], edx ;; user_data
+ lea edx, [ebp + 8]
+stubraw::
+ mov [esp + 8], edx ;; raw_args
+ lea edx, [ebp - 24]
+ mov [esp + 4], edx ;; &res
+ mov [esp], esi ;; cif
+ call DWORD PTR [eax + RAW_CLOSURE_FUN_OFFSET] ;; closure->fun
+ mov eax, [esi + CIF_FLAGS_OFFSET] ;; cif->flags
+ lea ecx, [ebp - 24]
+
+cr_jumptable:
+ jmp [cr_jumpdata + 4 * eax]
+cr_jumpdata:
+ ;; Do not insert anything here between the label and jump table.
+ dd offset cr_epilogue ;; FFI_TYPE_VOID
+ dd offset cr_retint ;; FFI_TYPE_INT
+ dd offset cr_retfloat ;; FFI_TYPE_FLOAT
+ dd offset cr_retdouble ;; FFI_TYPE_DOUBLE
+ dd offset cr_retlongdouble ;; FFI_TYPE_LONGDOUBLE
+ dd offset cr_retuint8 ;; FFI_TYPE_UINT8
+ dd offset cr_retsint8 ;; FFI_TYPE_SINT8
+ dd offset cr_retuint16 ;; FFI_TYPE_UINT16
+ dd offset cr_retsint16 ;; FFI_TYPE_SINT16
+ dd offset cr_retint ;; FFI_TYPE_UINT32
+ dd offset cr_retint ;; FFI_TYPE_SINT32
+ dd offset cr_retint64 ;; FFI_TYPE_UINT64
+ dd offset cr_retint64 ;; FFI_TYPE_SINT64
+ dd offset cr_epilogue ;; FFI_TYPE_STRUCT
+ dd offset cr_retint ;; FFI_TYPE_POINTER
+ dd offset cr_retsint8 ;; FFI_TYPE_SMALL_STRUCT_1B
+ dd offset cr_retsint16 ;; FFI_TYPE_SMALL_STRUCT_2B
+ dd offset cr_retint ;; FFI_TYPE_SMALL_STRUCT_4B
+ dd offset cr_epilogue ;; FFI_TYPE_MS_STRUCT
+
+cr_retuint8:
+ movzx eax, BYTE PTR [ecx]
+ jmp cr_epilogue
+
+cr_retsint8:
+ movsx eax, BYTE PTR [ecx]
+ jmp cr_epilogue
+
+cr_retuint16:
+ movzx eax, WORD PTR [ecx]
+ jmp cr_epilogue
+
+cr_retsint16:
+ movsx eax, WORD PTR [ecx]
+ jmp cr_epilogue
+
+cr_retint:
+ mov eax, [ecx]
+ jmp cr_epilogue
+
+cr_retint64:
+ mov eax, [ecx + 0]
+ mov edx, [ecx + 4]
+ jmp cr_epilogue
+
+cr_retfloat:
+ fld DWORD PTR [ecx]
+ jmp cr_epilogue
+
+cr_retdouble:
+ fld QWORD PTR [ecx]
+ jmp cr_epilogue
+
+cr_retlongdouble:
+ fld TBYTE PTR [ecx]
+ jmp cr_epilogue
+
+cr_epilogue:
+ ;; Epilogue code is autogenerated.
+ ret
+ffi_closure_raw_SYSV ENDP
+
+#endif /* !FFI_NO_RAW_API */
+
+ffi_closure_STDCALL PROC NEAR FORCEFRAME
+ mov eax, [esp] ;; the ffi_closure ctx passed by the trampoline.
+
+ sub esp, 40
+ lea edx, [ebp - 24]
+ mov [ebp - 12], edx ;; resp
+ lea edx, [ebp + 12] ;; account for stub return address on stack
+ mov [esp + 8], edx ;; args
+ lea edx, [ebp - 12]
+ mov [esp + 4], edx ;; &resp
+ mov [esp], eax ;; closure
+ call ffi_closure_WIN32_inner
+ mov ecx, [ebp - 12]
+
+ xchg [ebp + 4], eax ;;xchg size of stack parameters and ffi_closure ctx
+ mov eax, DWORD PTR [eax + CLOSURE_CIF_OFFSET]
+ mov eax, DWORD PTR [eax + CIF_FLAGS_OFFSET]
+
+cd_jumptable:
+ jmp [cd_jumpdata + 4 * eax]
+cd_jumpdata:
+ ;; Do not insert anything here between the label and jump table.
+ dd offset cd_epilogue ;; FFI_TYPE_VOID
+ dd offset cd_retint ;; FFI_TYPE_INT
+ dd offset cd_retfloat ;; FFI_TYPE_FLOAT
+ dd offset cd_retdouble ;; FFI_TYPE_DOUBLE
+ dd offset cd_retlongdouble ;; FFI_TYPE_LONGDOUBLE
+ dd offset cd_retuint8 ;; FFI_TYPE_UINT8
+ dd offset cd_retsint8 ;; FFI_TYPE_SINT8
+ dd offset cd_retuint16 ;; FFI_TYPE_UINT16
+ dd offset cd_retsint16 ;; FFI_TYPE_SINT16
+ dd offset cd_retint ;; FFI_TYPE_UINT32
+ dd offset cd_retint ;; FFI_TYPE_SINT32
+ dd offset cd_retint64 ;; FFI_TYPE_UINT64
+ dd offset cd_retint64 ;; FFI_TYPE_SINT64
+ dd offset cd_epilogue ;; FFI_TYPE_STRUCT
+ dd offset cd_retint ;; FFI_TYPE_POINTER
+ dd offset cd_retsint8 ;; FFI_TYPE_SMALL_STRUCT_1B
+ dd offset cd_retsint16 ;; FFI_TYPE_SMALL_STRUCT_2B
+ dd offset cd_retint ;; FFI_TYPE_SMALL_STRUCT_4B
+
+cd_retuint8:
+ movzx eax, BYTE PTR [ecx]
+ jmp cd_epilogue
+
+cd_retsint8:
+ movsx eax, BYTE PTR [ecx]
+ jmp cd_epilogue
+
+cd_retuint16:
+ movzx eax, WORD PTR [ecx]
+ jmp cd_epilogue
+
+cd_retsint16:
+ movsx eax, WORD PTR [ecx]
+ jmp cd_epilogue
+
+cd_retint:
+ mov eax, [ecx]
+ jmp cd_epilogue
+
+cd_retint64:
+ mov eax, [ecx + 0]
+ mov edx, [ecx + 4]
+ jmp cd_epilogue
+
+cd_retfloat:
+ fld DWORD PTR [ecx]
+ jmp cd_epilogue
+
+cd_retdouble:
+ fld QWORD PTR [ecx]
+ jmp cd_epilogue
+
+cd_retlongdouble:
+ fld TBYTE PTR [ecx]
+ jmp cd_epilogue
+
+cd_epilogue:
+ mov esp, ebp
+ pop ebp
+ mov ecx, [esp + 4] ;; Return address
+ add esp, [esp] ;; Parameters stack size
+ add esp, 8
+ jmp ecx
+ffi_closure_STDCALL ENDP
+
+_TEXT ENDS
+END
+
+#else
+
+#define CLOSURE_CIF_OFFSET ((FFI_TRAMPOLINE_SIZE + 3) & ~3)
+
+#if defined(SYMBOL_UNDERSCORE)
+#define USCORE_SYMBOL(x) _##x
+#else
+#define USCORE_SYMBOL(x) x
+#endif
+ .text
+
+ # This assumes we are using gas.
+ .balign 16
+FFI_HIDDEN(ffi_call_win32)
+ .globl USCORE_SYMBOL(ffi_call_win32)
+#if defined(X86_WIN32) && !defined(__OS2__)
+ .def _ffi_call_win32; .scl 2; .type 32; .endef
+#endif
+USCORE_SYMBOL(ffi_call_win32):
+.LFB1:
+ pushl %ebp
+.LCFI0:
+ movl %esp,%ebp
+.LCFI1:
+ # Make room for all of the new args.
+ movl 20(%ebp),%ecx
+ subl %ecx,%esp
+
+ movl %esp,%eax
+
+ # Call ffi_prep_args
+ pushl 12(%ebp)
+ pushl %eax
+ call *8(%ebp)
+ addl $8,%esp
+
+ # Prepare registers
+ # EAX stores the number of register arguments
+ cmpl $0, %eax
+ je .fun
+ cmpl $3, %eax
+ jl .prepr_two_cmp
+
+ movl %esp, %ecx
+ addl $12, %esp
+ movl 8(%ecx), %eax
+ jmp .prepr_two
+.prepr_two_cmp:
+ cmpl $2, %eax
+ jl .prepr_one_prep
+ movl %esp, %ecx
+ addl $8, %esp
+.prepr_two:
+ movl 4(%ecx), %edx
+ jmp .prepr_one
+.prepr_one_prep:
+ movl %esp, %ecx
+ addl $4, %esp
+.prepr_one:
+ movl (%ecx), %ecx
+ cmpl $7, 16(%ebp) # FFI_REGISTER
+ jne .fun
+
+ xchgl %eax, %ecx
+
+.fun:
+ # FIXME: Align the stack to a 128-bit boundary to avoid
+ # potential performance hits.
+
+ # Call function
+ call *32(%ebp)
+
+ # stdcall functions pop arguments off the stack themselves
+
+ # Load %ecx with the return type code
+ movl 24(%ebp),%ecx
+
+ # If the return value pointer is NULL, assume no return value.
+ cmpl $0,28(%ebp)
+ jne 0f
+
+ # Even if there is no space for the return value, we are
+ # obliged to handle floating-point values.
+ cmpl $FFI_TYPE_FLOAT,%ecx
+ jne .Lnoretval
+ fstp %st(0)
+
+ jmp .Lepilogue
+
+0:
+ call 1f
+ # Do not insert anything here between the call and the jump table.
+.Lstore_table:
+ .long .Lnoretval-.Lstore_table /* FFI_TYPE_VOID */
+ .long .Lretint-.Lstore_table /* FFI_TYPE_INT */
+ .long .Lretfloat-.Lstore_table /* FFI_TYPE_FLOAT */
+ .long .Lretdouble-.Lstore_table /* FFI_TYPE_DOUBLE */
+ .long .Lretlongdouble-.Lstore_table /* FFI_TYPE_LONGDOUBLE */
+ .long .Lretuint8-.Lstore_table /* FFI_TYPE_UINT8 */
+ .long .Lretsint8-.Lstore_table /* FFI_TYPE_SINT8 */
+ .long .Lretuint16-.Lstore_table /* FFI_TYPE_UINT16 */
+ .long .Lretsint16-.Lstore_table /* FFI_TYPE_SINT16 */
+ .long .Lretint-.Lstore_table /* FFI_TYPE_UINT32 */
+ .long .Lretint-.Lstore_table /* FFI_TYPE_SINT32 */
+ .long .Lretint64-.Lstore_table /* FFI_TYPE_UINT64 */
+ .long .Lretint64-.Lstore_table /* FFI_TYPE_SINT64 */
+ .long .Lretstruct-.Lstore_table /* FFI_TYPE_STRUCT */
+ .long .Lretint-.Lstore_table /* FFI_TYPE_POINTER */
+ .long .Lretstruct1b-.Lstore_table /* FFI_TYPE_SMALL_STRUCT_1B */
+ .long .Lretstruct2b-.Lstore_table /* FFI_TYPE_SMALL_STRUCT_2B */
+ .long .Lretstruct4b-.Lstore_table /* FFI_TYPE_SMALL_STRUCT_4B */
+ .long .Lretstruct-.Lstore_table /* FFI_TYPE_MS_STRUCT */
+1:
+ shl $2, %ecx
+ add (%esp),%ecx
+ mov (%ecx),%ecx
+ add (%esp),%ecx
+ add $4, %esp
+ jmp *%ecx
+
+ /* Sign/zero extend as appropriate. */
+.Lretsint8:
+ movsbl %al, %eax
+ jmp .Lretint
+
+.Lretsint16:
+ movswl %ax, %eax
+ jmp .Lretint
+
+.Lretuint8:
+ movzbl %al, %eax
+ jmp .Lretint
+
+.Lretuint16:
+ movzwl %ax, %eax
+ jmp .Lretint
+
+.Lretint:
+ # Load %ecx with the pointer to storage for the return value
+ movl 28(%ebp),%ecx
+ movl %eax,0(%ecx)
+ jmp .Lepilogue
+
+.Lretfloat:
+ # Load %ecx with the pointer to storage for the return value
+ movl 28(%ebp),%ecx
+ fstps (%ecx)
+ jmp .Lepilogue
+
+.Lretdouble:
+ # Load %ecx with the pointer to storage for the return value
+ movl 28(%ebp),%ecx
+ fstpl (%ecx)
+ jmp .Lepilogue
+
+.Lretlongdouble:
+ # Load %ecx with the pointer to storage for the return value
+ movl 28(%ebp),%ecx
+ fstpt (%ecx)
+ jmp .Lepilogue
+
+.Lretint64:
+ # Load %ecx with the pointer to storage for the return value
+ movl 28(%ebp),%ecx
+ movl %eax,0(%ecx)
+ movl %edx,4(%ecx)
+ jmp .Lepilogue
+
+.Lretstruct1b:
+ # Load %ecx with the pointer to storage for the return value
+ movl 28(%ebp),%ecx
+ movb %al,0(%ecx)
+ jmp .Lepilogue
+
+.Lretstruct2b:
+ # Load %ecx with the pointer to storage for the return value
+ movl 28(%ebp),%ecx
+ movw %ax,0(%ecx)
+ jmp .Lepilogue
+
+.Lretstruct4b:
+ # Load %ecx with the pointer to storage for the return value
+ movl 28(%ebp),%ecx
+ movl %eax,0(%ecx)
+ jmp .Lepilogue
+
+.Lretstruct:
+ # Nothing to do!
+
+.Lnoretval:
+.Lepilogue:
+ movl %ebp,%esp
+ popl %ebp
+ ret
+.ffi_call_win32_end:
+ .balign 16
+FFI_HIDDEN(ffi_closure_THISCALL)
+ .globl USCORE_SYMBOL(ffi_closure_THISCALL)
+#if defined(X86_WIN32) && !defined(__OS2__)
+ .def _ffi_closure_THISCALL; .scl 2; .type 32; .endef
+#endif
+USCORE_SYMBOL(ffi_closure_THISCALL):
+ /* Insert the register argument on the stack as the first argument */
+ xchg %ecx, 4(%esp)
+ xchg %ecx, (%esp)
+ push %ecx
+ jmp .ffi_closure_STDCALL_internal
+
+ .balign 16
+FFI_HIDDEN(ffi_closure_FASTCALL)
+ .globl USCORE_SYMBOL(ffi_closure_FASTCALL)
+#if defined(X86_WIN32) && !defined(__OS2__)
+ .def _ffi_closure_FASTCALL; .scl 2; .type 32; .endef
+#endif
+USCORE_SYMBOL(ffi_closure_FASTCALL):
+ /* Insert the 2 register arguments on the stack as the first two arguments */
+ xchg %edx, 4(%esp)
+ xchg %ecx, (%esp)
+ push %edx
+ push %ecx
+ jmp .ffi_closure_STDCALL_internal
+FFI_HIDDEN(ffi_closure_REGISTER)
+ .globl USCORE_SYMBOL(ffi_closure_REGISTER)
+#if defined(X86_WIN32) && !defined(__OS2__)
+ .def _ffi_closure_REGISTER; .scl 2; .type 32; .endef
+#endif
+USCORE_SYMBOL(ffi_closure_REGISTER):
+ /* Insert the 3 register arguments on the stack as the first two arguments */
+ push %eax
+ xchg %ecx, 8(%esp)
+ xchg %edx, 4(%esp)
+ push %ecx
+ push %edx
+ jmp .ffi_closure_STDCALL_internal
+
+.LFE1:
+ # This assumes we are using gas.
+ .balign 16
+FFI_HIDDEN(ffi_closure_SYSV)
+#if defined(X86_WIN32)
+ .globl USCORE_SYMBOL(ffi_closure_SYSV)
+#if defined(X86_WIN32) && !defined(__OS2__)
+ .def _ffi_closure_SYSV; .scl 2; .type 32; .endef
+#endif
+USCORE_SYMBOL(ffi_closure_SYSV):
+#endif
+.LFB3:
+ pushl %ebp
+.LCFI4:
+ movl %esp, %ebp
+.LCFI5:
+ subl $40, %esp
+ leal -24(%ebp), %edx
+ movl %edx, -12(%ebp) /* resp */
+ leal 8(%ebp), %edx
+ movl %edx, 4(%esp) /* args = __builtin_dwarf_cfa () */
+ leal -12(%ebp), %edx
+ movl %edx, (%esp) /* &resp */
+#if defined(HAVE_HIDDEN_VISIBILITY_ATTRIBUTE) || !defined(__PIC__)
+ call USCORE_SYMBOL(ffi_closure_SYSV_inner)
+#elif defined(X86_DARWIN)
+ calll L_ffi_closure_SYSV_inner$stub
+#else
+ movl %ebx, 8(%esp)
+ call 1f
+1: popl %ebx
+ addl $_GLOBAL_OFFSET_TABLE_+[.-1b], %ebx
+ call ffi_closure_SYSV_inner@PLT
+ movl 8(%esp), %ebx
+#endif
+ movl -12(%ebp), %ecx
+
+0:
+ call 1f
+ # Do not insert anything here between the call and the jump table.
+.Lcls_store_table:
+ .long .Lcls_noretval-.Lcls_store_table /* FFI_TYPE_VOID */
+ .long .Lcls_retint-.Lcls_store_table /* FFI_TYPE_INT */
+ .long .Lcls_retfloat-.Lcls_store_table /* FFI_TYPE_FLOAT */
+ .long .Lcls_retdouble-.Lcls_store_table /* FFI_TYPE_DOUBLE */
+ .long .Lcls_retldouble-.Lcls_store_table /* FFI_TYPE_LONGDOUBLE */
+ .long .Lcls_retuint8-.Lcls_store_table /* FFI_TYPE_UINT8 */
+ .long .Lcls_retsint8-.Lcls_store_table /* FFI_TYPE_SINT8 */
+ .long .Lcls_retuint16-.Lcls_store_table /* FFI_TYPE_UINT16 */
+ .long .Lcls_retsint16-.Lcls_store_table /* FFI_TYPE_SINT16 */
+ .long .Lcls_retint-.Lcls_store_table /* FFI_TYPE_UINT32 */
+ .long .Lcls_retint-.Lcls_store_table /* FFI_TYPE_SINT32 */
+ .long .Lcls_retllong-.Lcls_store_table /* FFI_TYPE_UINT64 */
+ .long .Lcls_retllong-.Lcls_store_table /* FFI_TYPE_SINT64 */
+ .long .Lcls_retstruct-.Lcls_store_table /* FFI_TYPE_STRUCT */
+ .long .Lcls_retint-.Lcls_store_table /* FFI_TYPE_POINTER */
+ .long .Lcls_retstruct1-.Lcls_store_table /* FFI_TYPE_SMALL_STRUCT_1B */
+ .long .Lcls_retstruct2-.Lcls_store_table /* FFI_TYPE_SMALL_STRUCT_2B */
+ .long .Lcls_retstruct4-.Lcls_store_table /* FFI_TYPE_SMALL_STRUCT_4B */
+ .long .Lcls_retmsstruct-.Lcls_store_table /* FFI_TYPE_MS_STRUCT */
+
+1:
+ shl $2, %eax
+ add (%esp),%eax
+ mov (%eax),%eax
+ add (%esp),%eax
+ add $4, %esp
+ jmp *%eax
+
+ /* Sign/zero extend as appropriate. */
+.Lcls_retsint8:
+ movsbl (%ecx), %eax
+ jmp .Lcls_epilogue
+
+.Lcls_retsint16:
+ movswl (%ecx), %eax
+ jmp .Lcls_epilogue
+
+.Lcls_retuint8:
+ movzbl (%ecx), %eax
+ jmp .Lcls_epilogue
+
+.Lcls_retuint16:
+ movzwl (%ecx), %eax
+ jmp .Lcls_epilogue
+
+.Lcls_retint:
+ movl (%ecx), %eax
+ jmp .Lcls_epilogue
+
+.Lcls_retfloat:
+ flds (%ecx)
+ jmp .Lcls_epilogue
+
+.Lcls_retdouble:
+ fldl (%ecx)
+ jmp .Lcls_epilogue
+
+.Lcls_retldouble:
+ fldt (%ecx)
+ jmp .Lcls_epilogue
+
+.Lcls_retllong:
+ movl (%ecx), %eax
+ movl 4(%ecx), %edx
+ jmp .Lcls_epilogue
+
+.Lcls_retstruct1:
+ movsbl (%ecx), %eax
+ jmp .Lcls_epilogue
+
+.Lcls_retstruct2:
+ movswl (%ecx), %eax
+ jmp .Lcls_epilogue
+
+.Lcls_retstruct4:
+ movl (%ecx), %eax
+ jmp .Lcls_epilogue
+
+.Lcls_retstruct:
+ # Caller expects us to pop struct return value pointer hidden arg.
+ movl %ebp, %esp
+ popl %ebp
+ ret $0x4
+
+.Lcls_retmsstruct:
+ # Caller expects us to return a pointer to the real return value.
+ mov %ecx, %eax
+ # Caller doesn't expects us to pop struct return value pointer hidden arg.
+ jmp .Lcls_epilogue
+
+.Lcls_noretval:
+.Lcls_epilogue:
+ movl %ebp, %esp
+ popl %ebp
+ ret
+.ffi_closure_SYSV_end:
+.LFE3:
+
+#if !FFI_NO_RAW_API
+
+#define RAW_CLOSURE_CIF_OFFSET ((FFI_TRAMPOLINE_SIZE + 3) & ~3)
+#define RAW_CLOSURE_FUN_OFFSET (RAW_CLOSURE_CIF_OFFSET + 4)
+#define RAW_CLOSURE_USER_DATA_OFFSET (RAW_CLOSURE_FUN_OFFSET + 4)
+
+#ifdef X86_WIN32
+ .balign 16
+FFI_HIDDEN(ffi_closure_raw_THISCALL)
+ .globl USCORE_SYMBOL(ffi_closure_raw_THISCALL)
+#if defined(X86_WIN32) && !defined(__OS2__)
+ .def _ffi_closure_raw_THISCALL; .scl 2; .type 32; .endef
+#endif
+USCORE_SYMBOL(ffi_closure_raw_THISCALL):
+ pushl %ebp
+ movl %esp, %ebp
+ pushl %esi
+ subl $36, %esp
+ movl RAW_CLOSURE_CIF_OFFSET(%eax), %esi /* closure->cif */
+ movl RAW_CLOSURE_USER_DATA_OFFSET(%eax), %edx /* closure->user_data */
+ movl %edx, 12(%esp) /* user_data */
+ leal 12(%ebp), %edx /* __builtin_dwarf_cfa () */
+ jmp .stubraw
+#endif /* X86_WIN32 */
+
+ # This assumes we are using gas.
+ .balign 16
+#if defined(X86_WIN32)
+ .globl USCORE_SYMBOL(ffi_closure_raw_SYSV)
+#if defined(X86_WIN32) && !defined(__OS2__)
+ .def _ffi_closure_raw_SYSV; .scl 2; .type 32; .endef
+#endif
+USCORE_SYMBOL(ffi_closure_raw_SYSV):
+#endif /* defined(X86_WIN32) */
+.LFB4:
+ pushl %ebp
+.LCFI6:
+ movl %esp, %ebp
+.LCFI7:
+ pushl %esi
+.LCFI8:
+ subl $36, %esp
+ movl RAW_CLOSURE_CIF_OFFSET(%eax), %esi /* closure->cif */
+ movl RAW_CLOSURE_USER_DATA_OFFSET(%eax), %edx /* closure->user_data */
+ movl %edx, 12(%esp) /* user_data */
+ leal 8(%ebp), %edx /* __builtin_dwarf_cfa () */
+.stubraw:
+ movl %edx, 8(%esp) /* raw_args */
+ leal -24(%ebp), %edx
+ movl %edx, 4(%esp) /* &res */
+ movl %esi, (%esp) /* cif */
+ call *RAW_CLOSURE_FUN_OFFSET(%eax) /* closure->fun */
+ movl CIF_FLAGS_OFFSET(%esi), %eax /* rtype */
+0:
+ call 1f
+ # Do not insert anything here between the call and the jump table.
+.Lrcls_store_table:
+ .long .Lrcls_noretval-.Lrcls_store_table /* FFI_TYPE_VOID */
+ .long .Lrcls_retint-.Lrcls_store_table /* FFI_TYPE_INT */
+ .long .Lrcls_retfloat-.Lrcls_store_table /* FFI_TYPE_FLOAT */
+ .long .Lrcls_retdouble-.Lrcls_store_table /* FFI_TYPE_DOUBLE */
+ .long .Lrcls_retldouble-.Lrcls_store_table /* FFI_TYPE_LONGDOUBLE */
+ .long .Lrcls_retuint8-.Lrcls_store_table /* FFI_TYPE_UINT8 */
+ .long .Lrcls_retsint8-.Lrcls_store_table /* FFI_TYPE_SINT8 */
+ .long .Lrcls_retuint16-.Lrcls_store_table /* FFI_TYPE_UINT16 */
+ .long .Lrcls_retsint16-.Lrcls_store_table /* FFI_TYPE_SINT16 */
+ .long .Lrcls_retint-.Lrcls_store_table /* FFI_TYPE_UINT32 */
+ .long .Lrcls_retint-.Lrcls_store_table /* FFI_TYPE_SINT32 */
+ .long .Lrcls_retllong-.Lrcls_store_table /* FFI_TYPE_UINT64 */
+ .long .Lrcls_retllong-.Lrcls_store_table /* FFI_TYPE_SINT64 */
+ .long .Lrcls_retstruct-.Lrcls_store_table /* FFI_TYPE_STRUCT */
+ .long .Lrcls_retint-.Lrcls_store_table /* FFI_TYPE_POINTER */
+ .long .Lrcls_retstruct1-.Lrcls_store_table /* FFI_TYPE_SMALL_STRUCT_1B */
+ .long .Lrcls_retstruct2-.Lrcls_store_table /* FFI_TYPE_SMALL_STRUCT_2B */
+ .long .Lrcls_retstruct4-.Lrcls_store_table /* FFI_TYPE_SMALL_STRUCT_4B */
+ .long .Lrcls_retstruct-.Lrcls_store_table /* FFI_TYPE_MS_STRUCT */
+1:
+ shl $2, %eax
+ add (%esp),%eax
+ mov (%eax),%eax
+ add (%esp),%eax
+ add $4, %esp
+ jmp *%eax
+
+ /* Sign/zero extend as appropriate. */
+.Lrcls_retsint8:
+ movsbl -24(%ebp), %eax
+ jmp .Lrcls_epilogue
+
+.Lrcls_retsint16:
+ movswl -24(%ebp), %eax
+ jmp .Lrcls_epilogue
+
+.Lrcls_retuint8:
+ movzbl -24(%ebp), %eax
+ jmp .Lrcls_epilogue
+
+.Lrcls_retuint16:
+ movzwl -24(%ebp), %eax
+ jmp .Lrcls_epilogue
+
+.Lrcls_retint:
+ movl -24(%ebp), %eax
+ jmp .Lrcls_epilogue
+
+.Lrcls_retfloat:
+ flds -24(%ebp)
+ jmp .Lrcls_epilogue
+
+.Lrcls_retdouble:
+ fldl -24(%ebp)
+ jmp .Lrcls_epilogue
+
+.Lrcls_retldouble:
+ fldt -24(%ebp)
+ jmp .Lrcls_epilogue
+
+.Lrcls_retllong:
+ movl -24(%ebp), %eax
+ movl -20(%ebp), %edx
+ jmp .Lrcls_epilogue
+
+.Lrcls_retstruct1:
+ movsbl -24(%ebp), %eax
+ jmp .Lrcls_epilogue
+
+.Lrcls_retstruct2:
+ movswl -24(%ebp), %eax
+ jmp .Lrcls_epilogue
+
+.Lrcls_retstruct4:
+ movl -24(%ebp), %eax
+ jmp .Lrcls_epilogue
+
+.Lrcls_retstruct:
+ # Nothing to do!
+
+.Lrcls_noretval:
+.Lrcls_epilogue:
+ addl $36, %esp
+ popl %esi
+ popl %ebp
+ ret
+.ffi_closure_raw_SYSV_end:
+.LFE4:
+
+#endif /* !FFI_NO_RAW_API */
+
+ # This assumes we are using gas.
+ .balign 16
+FFI_HIDDEN(ffi_closure_STDCALL)
+ .globl USCORE_SYMBOL(ffi_closure_STDCALL)
+#if defined(X86_WIN32) && !defined(__OS2__)
+ .def _ffi_closure_STDCALL; .scl 2; .type 32; .endef
+#endif
+USCORE_SYMBOL(ffi_closure_STDCALL):
+.ffi_closure_STDCALL_internal:
+ /* ffi_closure ctx is at top of the stack */
+ movl (%esp), %eax
+.LFB5:
+ pushl %ebp
+.LCFI9:
+ movl %esp, %ebp
+.LCFI10:
+ subl $40, %esp
+ leal -24(%ebp), %edx
+ movl %edx, -12(%ebp) /* resp */
+ leal 12(%ebp), %edx /* account for stub return address on stack */
+ movl %edx, 4(%esp) /* args */
+ leal -12(%ebp), %edx
+ movl %edx, (%esp) /* &resp */
+#if defined(HAVE_HIDDEN_VISIBILITY_ATTRIBUTE) || !defined(__PIC__)
+ call USCORE_SYMBOL(ffi_closure_WIN32_inner)
+#elif defined(X86_DARWIN)
+ calll L_ffi_closure_WIN32_inner$stub
+#else
+ movl %ebx, 8(%esp)
+ call 1f
+1: popl %ebx
+ addl $_GLOBAL_OFFSET_TABLE_+[.-1b], %ebx
+ call ffi_closure_WIN32_inner@PLT
+ movl 8(%esp), %ebx
+#endif
+ movl -12(%ebp), %ecx
+0:
+ xchgl 4(%ebp), %eax /* xchg size of stack parameters and ffi_closure ctx */
+ movl CLOSURE_CIF_OFFSET(%eax), %eax
+ movl CIF_FLAGS_OFFSET(%eax), %eax
+
+ call 1f
+ # Do not insert anything here between the call and the jump table.
+.Lscls_store_table:
+ .long .Lscls_noretval-.Lscls_store_table /* FFI_TYPE_VOID */
+ .long .Lscls_retint-.Lscls_store_table /* FFI_TYPE_INT */
+ .long .Lscls_retfloat-.Lscls_store_table /* FFI_TYPE_FLOAT */
+ .long .Lscls_retdouble-.Lscls_store_table /* FFI_TYPE_DOUBLE */
+ .long .Lscls_retldouble-.Lscls_store_table /* FFI_TYPE_LONGDOUBLE */
+ .long .Lscls_retuint8-.Lscls_store_table /* FFI_TYPE_UINT8 */
+ .long .Lscls_retsint8-.Lscls_store_table /* FFI_TYPE_SINT8 */
+ .long .Lscls_retuint16-.Lscls_store_table /* FFI_TYPE_UINT16 */
+ .long .Lscls_retsint16-.Lscls_store_table /* FFI_TYPE_SINT16 */
+ .long .Lscls_retint-.Lscls_store_table /* FFI_TYPE_UINT32 */
+ .long .Lscls_retint-.Lscls_store_table /* FFI_TYPE_SINT32 */
+ .long .Lscls_retllong-.Lscls_store_table /* FFI_TYPE_UINT64 */
+ .long .Lscls_retllong-.Lscls_store_table /* FFI_TYPE_SINT64 */
+ .long .Lscls_retstruct-.Lscls_store_table /* FFI_TYPE_STRUCT */
+ .long .Lscls_retint-.Lscls_store_table /* FFI_TYPE_POINTER */
+ .long .Lscls_retstruct1-.Lscls_store_table /* FFI_TYPE_SMALL_STRUCT_1B */
+ .long .Lscls_retstruct2-.Lscls_store_table /* FFI_TYPE_SMALL_STRUCT_2B */
+ .long .Lscls_retstruct4-.Lscls_store_table /* FFI_TYPE_SMALL_STRUCT_4B */
+1:
+ shl $2, %eax
+ add (%esp),%eax
+ mov (%eax),%eax
+ add (%esp),%eax
+ add $4, %esp
+ jmp *%eax
+
+ /* Sign/zero extend as appropriate. */
+.Lscls_retsint8:
+ movsbl (%ecx), %eax
+ jmp .Lscls_epilogue
+
+.Lscls_retsint16:
+ movswl (%ecx), %eax
+ jmp .Lscls_epilogue
+
+.Lscls_retuint8:
+ movzbl (%ecx), %eax
+ jmp .Lscls_epilogue
+
+.Lscls_retuint16:
+ movzwl (%ecx), %eax
+ jmp .Lscls_epilogue
+
+.Lscls_retint:
+ movl (%ecx), %eax
+ jmp .Lscls_epilogue
+
+.Lscls_retfloat:
+ flds (%ecx)
+ jmp .Lscls_epilogue
+
+.Lscls_retdouble:
+ fldl (%ecx)
+ jmp .Lscls_epilogue
+
+.Lscls_retldouble:
+ fldt (%ecx)
+ jmp .Lscls_epilogue
+
+.Lscls_retllong:
+ movl (%ecx), %eax
+ movl 4(%ecx), %edx
+ jmp .Lscls_epilogue
+
+.Lscls_retstruct1:
+ movsbl (%ecx), %eax
+ jmp .Lscls_epilogue
+
+.Lscls_retstruct2:
+ movswl (%ecx), %eax
+ jmp .Lscls_epilogue
+
+.Lscls_retstruct4:
+ movl (%ecx), %eax
+ jmp .Lscls_epilogue
+
+.Lscls_retstruct:
+ # Nothing to do!
+
+.Lscls_noretval:
+.Lscls_epilogue:
+ movl %ebp, %esp
+ popl %ebp
+ movl 4(%esp), %ecx /* Return address */
+ addl (%esp), %esp /* Parameters stack size */
+ addl $8, %esp
+ jmp *%ecx
+.ffi_closure_STDCALL_end:
+.LFE5:
+
+#if defined(X86_DARWIN)
+.section __IMPORT,__jump_table,symbol_stubs,self_modifying_code+pure_instructions,5
+L_ffi_closure_SYSV_inner$stub:
+ .indirect_symbol _ffi_closure_SYSV_inner
+ hlt ; hlt ; hlt ; hlt ; hlt
+L_ffi_closure_WIN32_inner$stub:
+ .indirect_symbol _ffi_closure_WIN32_inner
+ hlt ; hlt ; hlt ; hlt ; hlt
+#endif
+
+#if defined(X86_WIN32) && !defined(__OS2__)
+ .section .eh_frame,"w"
+#endif
+.Lframe1:
+.LSCIE1:
+ .long .LECIE1-.LASCIE1 /* Length of Common Information Entry */
+.LASCIE1:
+ .long 0x0 /* CIE Identifier Tag */
+ .byte 0x1 /* CIE Version */
+#ifdef __PIC__
+ .ascii "zR\0" /* CIE Augmentation */
+#else
+ .ascii "\0" /* CIE Augmentation */
+#endif
+ .byte 0x1 /* .uleb128 0x1; CIE Code Alignment Factor */
+ .byte 0x7c /* .sleb128 -4; CIE Data Alignment Factor */
+ .byte 0x8 /* CIE RA Column */
+#ifdef __PIC__
+ .byte 0x1 /* .uleb128 0x1; Augmentation size */
+ .byte 0x1b /* FDE Encoding (pcrel sdata4) */
+#endif
+ .byte 0xc /* DW_CFA_def_cfa CFA = r4 + 4 = 4(%esp) */
+ .byte 0x4 /* .uleb128 0x4 */
+ .byte 0x4 /* .uleb128 0x4 */
+ .byte 0x88 /* DW_CFA_offset, column 0x8 %eip at CFA + 1 * -4 */
+ .byte 0x1 /* .uleb128 0x1 */
+ .align 4
+.LECIE1:
+
+.LSFDE1:
+ .long .LEFDE1-.LASFDE1 /* FDE Length */
+.LASFDE1:
+ .long .LASFDE1-.Lframe1 /* FDE CIE offset */
+#if defined __PIC__ && defined HAVE_AS_X86_PCREL
+ .long .LFB1-. /* FDE initial location */
+#else
+ .long .LFB1
+#endif
+ .long .LFE1-.LFB1 /* FDE address range */
+#ifdef __PIC__
+ .byte 0x0 /* .uleb128 0x0; Augmentation size */
+#endif
+ /* DW_CFA_xxx CFI instructions go here. */
+
+ .byte 0x4 /* DW_CFA_advance_loc4 */
+ .long .LCFI0-.LFB1
+ .byte 0xe /* DW_CFA_def_cfa_offset CFA = r4 + 8 = 8(%esp) */
+ .byte 0x8 /* .uleb128 0x8 */
+ .byte 0x85 /* DW_CFA_offset, column 0x5 %ebp at CFA + 2 * -4 */
+ .byte 0x2 /* .uleb128 0x2 */
+
+ .byte 0x4 /* DW_CFA_advance_loc4 */
+ .long .LCFI1-.LCFI0
+ .byte 0xd /* DW_CFA_def_cfa_register CFA = r5 = %ebp */
+ .byte 0x5 /* .uleb128 0x5 */
+
+ /* End of DW_CFA_xxx CFI instructions. */
+ .align 4
+.LEFDE1:
+
+.LSFDE3:
+ .long .LEFDE3-.LASFDE3 /* FDE Length */
+.LASFDE3:
+ .long .LASFDE3-.Lframe1 /* FDE CIE offset */
+#if defined __PIC__ && defined HAVE_AS_X86_PCREL
+ .long .LFB3-. /* FDE initial location */
+#else
+ .long .LFB3
+#endif
+ .long .LFE3-.LFB3 /* FDE address range */
+#ifdef __PIC__
+ .byte 0x0 /* .uleb128 0x0; Augmentation size */
+#endif
+ /* DW_CFA_xxx CFI instructions go here. */
+
+ .byte 0x4 /* DW_CFA_advance_loc4 */
+ .long .LCFI4-.LFB3
+ .byte 0xe /* DW_CFA_def_cfa_offset CFA = r4 + 8 = 8(%esp) */
+ .byte 0x8 /* .uleb128 0x8 */
+ .byte 0x85 /* DW_CFA_offset, column 0x5 %ebp at CFA + 2 * -4 */
+ .byte 0x2 /* .uleb128 0x2 */
+
+ .byte 0x4 /* DW_CFA_advance_loc4 */
+ .long .LCFI5-.LCFI4
+ .byte 0xd /* DW_CFA_def_cfa_register CFA = r5 = %ebp */
+ .byte 0x5 /* .uleb128 0x5 */
+
+ /* End of DW_CFA_xxx CFI instructions. */
+ .align 4
+.LEFDE3:
+
+#if !FFI_NO_RAW_API
+
+.LSFDE4:
+ .long .LEFDE4-.LASFDE4 /* FDE Length */
+.LASFDE4:
+ .long .LASFDE4-.Lframe1 /* FDE CIE offset */
+#if defined __PIC__ && defined HAVE_AS_X86_PCREL
+ .long .LFB4-. /* FDE initial location */
+#else
+ .long .LFB4
+#endif
+ .long .LFE4-.LFB4 /* FDE address range */
+#ifdef __PIC__
+ .byte 0x0 /* .uleb128 0x0; Augmentation size */
+#endif
+ /* DW_CFA_xxx CFI instructions go here. */
+
+ .byte 0x4 /* DW_CFA_advance_loc4 */
+ .long .LCFI6-.LFB4
+ .byte 0xe /* DW_CFA_def_cfa_offset CFA = r4 + 8 = 8(%esp) */
+ .byte 0x8 /* .uleb128 0x8 */
+ .byte 0x85 /* DW_CFA_offset, column 0x5 %ebp at CFA + 2 * -4 */
+ .byte 0x2 /* .uleb128 0x2 */
+
+ .byte 0x4 /* DW_CFA_advance_loc4 */
+ .long .LCFI7-.LCFI6
+ .byte 0xd /* DW_CFA_def_cfa_register CFA = r5 = %ebp */
+ .byte 0x5 /* .uleb128 0x5 */
+
+ .byte 0x4 /* DW_CFA_advance_loc4 */
+ .long .LCFI8-.LCFI7
+ .byte 0x86 /* DW_CFA_offset, column 0x6 %esi at CFA + 3 * -4 */
+ .byte 0x3 /* .uleb128 0x3 */
+
+ /* End of DW_CFA_xxx CFI instructions. */
+ .align 4
+.LEFDE4:
+
+#endif /* !FFI_NO_RAW_API */
+
+.LSFDE5:
+ .long .LEFDE5-.LASFDE5 /* FDE Length */
+.LASFDE5:
+ .long .LASFDE5-.Lframe1 /* FDE CIE offset */
+#if defined __PIC__ && defined HAVE_AS_X86_PCREL
+ .long .LFB5-. /* FDE initial location */
+#else
+ .long .LFB5
+#endif
+ .long .LFE5-.LFB5 /* FDE address range */
+#ifdef __PIC__
+ .byte 0x0 /* .uleb128 0x0; Augmentation size */
+#endif
+ /* DW_CFA_xxx CFI instructions go here. */
+
+ .byte 0x4 /* DW_CFA_advance_loc4 */
+ .long .LCFI9-.LFB5
+ .byte 0xe /* DW_CFA_def_cfa_offset CFA = r4 + 8 = 8(%esp) */
+ .byte 0x8 /* .uleb128 0x8 */
+ .byte 0x85 /* DW_CFA_offset, column 0x5 %ebp at CFA + 2 * -4 */
+ .byte 0x2 /* .uleb128 0x2 */
+
+ .byte 0x4 /* DW_CFA_advance_loc4 */
+ .long .LCFI10-.LCFI9
+ .byte 0xd /* DW_CFA_def_cfa_register CFA = r5 = %ebp */
+ .byte 0x5 /* .uleb128 0x5 */
+
+ /* End of DW_CFA_xxx CFI instructions. */
+ .align 4
+.LEFDE5:
+
+#endif /* !_MSC_VER */
+
+#if defined __ELF__ && defined __linux__
+ .section .note.GNU-stack,"",@progbits
+#endif
diff --git a/jni/ruby/ext/fiddle/libffi-3.2.1/src/x86/win64.S b/jni/ruby/ext/fiddle/libffi-3.2.1/src/x86/win64.S
new file mode 100644
index 0000000..347a26a
--- /dev/null
+++ b/jni/ruby/ext/fiddle/libffi-3.2.1/src/x86/win64.S
@@ -0,0 +1,519 @@
+#define LIBFFI_ASM
+#include <fficonfig.h>
+#include <ffi.h>
+
+/* Constants for ffi_call_win64 */
+#define STACK 0
+#define PREP_ARGS_FN 32
+#define ECIF 40
+#define CIF_BYTES 48
+#define CIF_FLAGS 56
+#define RVALUE 64
+#define FN 72
+
+/* ffi_call_win64 (void (*prep_args_fn)(char *, extended_cif *),
+ extended_cif *ecif, unsigned bytes, unsigned flags,
+ unsigned *rvalue, void (*fn)());
+ */
+
+#ifdef _MSC_VER
+PUBLIC ffi_call_win64
+
+EXTRN __chkstk:NEAR
+EXTRN ffi_closure_win64_inner:NEAR
+
+_TEXT SEGMENT
+
+;;; ffi_closure_win64 will be called with these registers set:
+;;; rax points to 'closure'
+;;; r11 contains a bit mask that specifies which of the
+;;; first four parameters are float or double
+;;;
+;;; It must move the parameters passed in registers to their stack location,
+;;; call ffi_closure_win64_inner for the actual work, then return the result.
+;;;
+ffi_closure_win64 PROC FRAME
+ ;; copy register arguments onto stack
+ test r11, 1
+ jne first_is_float
+ mov QWORD PTR [rsp+8], rcx
+ jmp second
+first_is_float:
+ movlpd QWORD PTR [rsp+8], xmm0
+
+second:
+ test r11, 2
+ jne second_is_float
+ mov QWORD PTR [rsp+16], rdx
+ jmp third
+second_is_float:
+ movlpd QWORD PTR [rsp+16], xmm1
+
+third:
+ test r11, 4
+ jne third_is_float
+ mov QWORD PTR [rsp+24], r8
+ jmp fourth
+third_is_float:
+ movlpd QWORD PTR [rsp+24], xmm2
+
+fourth:
+ test r11, 8
+ jne fourth_is_float
+ mov QWORD PTR [rsp+32], r9
+ jmp done
+fourth_is_float:
+ movlpd QWORD PTR [rsp+32], xmm3
+
+done:
+ .ALLOCSTACK 40
+ sub rsp, 40
+ .ENDPROLOG
+ mov rcx, rax ; context is first parameter
+ mov rdx, rsp ; stack is second parameter
+ add rdx, 48 ; point to start of arguments
+ mov rax, ffi_closure_win64_inner
+ call rax ; call the real closure function
+ add rsp, 40
+ movd xmm0, rax ; If the closure returned a float,
+ ; ffi_closure_win64_inner wrote it to rax
+ ret 0
+ffi_closure_win64 ENDP
+
+ffi_call_win64 PROC FRAME
+ ;; copy registers onto stack
+ mov QWORD PTR [rsp+32], r9
+ mov QWORD PTR [rsp+24], r8
+ mov QWORD PTR [rsp+16], rdx
+ mov QWORD PTR [rsp+8], rcx
+ .PUSHREG rbp
+ push rbp
+ .ALLOCSTACK 48
+ sub rsp, 48 ; 00000030H
+ .SETFRAME rbp, 32
+ lea rbp, QWORD PTR [rsp+32]
+ .ENDPROLOG
+
+ mov eax, DWORD PTR CIF_BYTES[rbp]
+ add rax, 15
+ and rax, -16
+ call __chkstk
+ sub rsp, rax
+ lea rax, QWORD PTR [rsp+32]
+ mov QWORD PTR STACK[rbp], rax
+
+ mov rdx, QWORD PTR ECIF[rbp]
+ mov rcx, QWORD PTR STACK[rbp]
+ call QWORD PTR PREP_ARGS_FN[rbp]
+
+ mov rsp, QWORD PTR STACK[rbp]
+
+ movlpd xmm3, QWORD PTR [rsp+24]
+ movd r9, xmm3
+
+ movlpd xmm2, QWORD PTR [rsp+16]
+ movd r8, xmm2
+
+ movlpd xmm1, QWORD PTR [rsp+8]
+ movd rdx, xmm1
+
+ movlpd xmm0, QWORD PTR [rsp]
+ movd rcx, xmm0
+
+ call QWORD PTR FN[rbp]
+ret_struct4b$:
+ cmp DWORD PTR CIF_FLAGS[rbp], FFI_TYPE_SMALL_STRUCT_4B
+ jne ret_struct2b$
+
+ mov rcx, QWORD PTR RVALUE[rbp]
+ mov DWORD PTR [rcx], eax
+ jmp SHORT ret_void$
+
+ret_struct2b$:
+ cmp DWORD PTR CIF_FLAGS[rbp], FFI_TYPE_SMALL_STRUCT_2B
+ jne ret_struct1b$
+
+ mov rcx, QWORD PTR RVALUE[rbp]
+ mov WORD PTR [rcx], ax
+ jmp SHORT ret_void$
+
+ret_struct1b$:
+ cmp DWORD PTR CIF_FLAGS[rbp], FFI_TYPE_SMALL_STRUCT_1B
+ jne ret_uint8$
+
+ mov rcx, QWORD PTR RVALUE[rbp]
+ mov BYTE PTR [rcx], al
+ jmp SHORT ret_void$
+
+ret_uint8$:
+ cmp DWORD PTR CIF_FLAGS[rbp], FFI_TYPE_UINT8
+ jne ret_sint8$
+
+ mov rcx, QWORD PTR RVALUE[rbp]
+ movzx rax, al
+ mov QWORD PTR [rcx], rax
+ jmp SHORT ret_void$
+
+ret_sint8$:
+ cmp DWORD PTR CIF_FLAGS[rbp], FFI_TYPE_SINT8
+ jne ret_uint16$
+
+ mov rcx, QWORD PTR RVALUE[rbp]
+ movsx rax, al
+ mov QWORD PTR [rcx], rax
+ jmp SHORT ret_void$
+
+ret_uint16$:
+ cmp DWORD PTR CIF_FLAGS[rbp], FFI_TYPE_UINT16
+ jne ret_sint16$
+
+ mov rcx, QWORD PTR RVALUE[rbp]
+ movzx rax, ax
+ mov QWORD PTR [rcx], rax
+ jmp SHORT ret_void$
+
+ret_sint16$:
+ cmp DWORD PTR CIF_FLAGS[rbp], FFI_TYPE_SINT16
+ jne ret_uint32$
+
+ mov rcx, QWORD PTR RVALUE[rbp]
+ movsx rax, ax
+ mov QWORD PTR [rcx], rax
+ jmp SHORT ret_void$
+
+ret_uint32$:
+ cmp DWORD PTR CIF_FLAGS[rbp], FFI_TYPE_UINT32
+ jne ret_sint32$
+
+ mov rcx, QWORD PTR RVALUE[rbp]
+ mov eax, eax
+ mov QWORD PTR [rcx], rax
+
+ret_void$:
+ xor rax, rax
+
+ lea rsp, QWORD PTR [rbp+16]
+ pop rbp
+ ret 0
+
+ret_sint32$:
+ cmp DWORD PTR CIF_FLAGS[rbp], FFI_TYPE_SINT32
+ jne ret_float$
+
+ mov rcx, QWORD PTR RVALUE[rbp]
+ cdqe
+ mov QWORD PTR [rcx], rax
+ jmp SHORT ret_void$
+
+ret_float$:
+ cmp DWORD PTR CIF_FLAGS[rbp], FFI_TYPE_FLOAT
+ jne SHORT ret_double$
+
+ mov rax, QWORD PTR RVALUE[rbp]
+ movss DWORD PTR [rax], xmm0
+ jmp SHORT ret_void$
+
+ret_double$:
+ cmp DWORD PTR CIF_FLAGS[rbp], FFI_TYPE_DOUBLE
+ jne SHORT ret_uint64$
+
+ mov rax, QWORD PTR RVALUE[rbp]
+ movlpd QWORD PTR [rax], xmm0
+ jmp SHORT ret_void$
+
+ret_uint64$:
+ cmp DWORD PTR CIF_FLAGS[rbp], FFI_TYPE_UINT64
+ jne SHORT ret_sint64$
+
+ mov rcx, QWORD PTR RVALUE[rbp]
+ mov QWORD PTR [rcx], rax
+ jmp SHORT ret_void$
+
+ret_sint64$:
+ cmp DWORD PTR CIF_FLAGS[rbp], FFI_TYPE_SINT64
+ jne SHORT ret_pointer$
+
+ mov rcx, QWORD PTR RVALUE[rbp]
+ mov QWORD PTR [rcx], rax
+ jmp SHORT ret_void$
+
+ret_pointer$:
+ cmp DWORD PTR CIF_FLAGS[rbp], FFI_TYPE_POINTER
+ jne SHORT ret_int$
+
+ mov rcx, QWORD PTR RVALUE[rbp]
+ mov QWORD PTR [rcx], rax
+ jmp SHORT ret_void$
+
+ret_int$:
+ cmp DWORD PTR CIF_FLAGS[rbp], FFI_TYPE_INT
+ jne SHORT ret_void$
+
+ mov rcx, QWORD PTR RVALUE[rbp]
+ cdqe
+ mov QWORD PTR [rcx], rax
+ jmp SHORT ret_void$
+ffi_call_win64 ENDP
+_TEXT ENDS
+END
+
+#else
+
+#ifdef SYMBOL_UNDERSCORE
+#define SYMBOL_NAME(name) _##name
+#else
+#define SYMBOL_NAME(name) name
+#endif
+
+.text
+
+.extern SYMBOL_NAME(ffi_closure_win64_inner)
+
+# ffi_closure_win64 will be called with these registers set:
+# rax points to 'closure'
+# r11 contains a bit mask that specifies which of the
+# first four parameters are float or double
+#
+# It must move the parameters passed in registers to their stack location,
+# call ffi_closure_win64_inner for the actual work, then return the result.
+#
+ .balign 16
+ .globl SYMBOL_NAME(ffi_closure_win64)
+ .seh_proc SYMBOL_NAME(ffi_closure_win64)
+SYMBOL_NAME(ffi_closure_win64):
+ # copy register arguments onto stack
+ test $1,%r11
+ jne .Lfirst_is_float
+ mov %rcx, 8(%rsp)
+ jmp .Lsecond
+.Lfirst_is_float:
+ movlpd %xmm0, 8(%rsp)
+
+.Lsecond:
+ test $2, %r11
+ jne .Lsecond_is_float
+ mov %rdx, 16(%rsp)
+ jmp .Lthird
+.Lsecond_is_float:
+ movlpd %xmm1, 16(%rsp)
+
+.Lthird:
+ test $4, %r11
+ jne .Lthird_is_float
+ mov %r8,24(%rsp)
+ jmp .Lfourth
+.Lthird_is_float:
+ movlpd %xmm2, 24(%rsp)
+
+.Lfourth:
+ test $8, %r11
+ jne .Lfourth_is_float
+ mov %r9, 32(%rsp)
+ jmp .Ldone
+.Lfourth_is_float:
+ movlpd %xmm3, 32(%rsp)
+
+.Ldone:
+ .seh_stackalloc 40
+ sub $40, %rsp
+ .seh_endprologue
+ mov %rax, %rcx # context is first parameter
+ mov %rsp, %rdx # stack is second parameter
+ add $48, %rdx # point to start of arguments
+ leaq SYMBOL_NAME(ffi_closure_win64_inner)(%rip), %rax
+ callq *%rax # call the real closure function
+ add $40, %rsp
+ movq %rax, %xmm0 # If the closure returned a float,
+ # ffi_closure_win64_inner wrote it to rax
+ retq
+ .seh_endproc
+
+ .balign 16
+ .globl SYMBOL_NAME(ffi_call_win64)
+ .seh_proc SYMBOL_NAME(ffi_call_win64)
+SYMBOL_NAME(ffi_call_win64):
+ # copy registers onto stack
+ mov %r9,32(%rsp)
+ mov %r8,24(%rsp)
+ mov %rdx,16(%rsp)
+ mov %rcx,8(%rsp)
+ .seh_pushreg rbp
+ push %rbp
+ .seh_stackalloc 48
+ sub $48,%rsp
+ .seh_setframe rbp, 32
+ lea 32(%rsp),%rbp
+ .seh_endprologue
+
+ mov CIF_BYTES(%rbp),%eax
+ add $15, %rax
+ and $-16, %rax
+ cmpq $0x1000, %rax
+ jb Lch_done
+Lch_probe:
+ subq $0x1000,%rsp
+ orl $0x0, (%rsp)
+ subq $0x1000,%rax
+ cmpq $0x1000,%rax
+ ja Lch_probe
+Lch_done:
+ subq %rax, %rsp
+ orl $0x0, (%rsp)
+ lea 32(%rsp), %rax
+ mov %rax, STACK(%rbp)
+
+ mov ECIF(%rbp), %rdx
+ mov STACK(%rbp), %rcx
+ callq *PREP_ARGS_FN(%rbp)
+
+ mov STACK(%rbp), %rsp
+
+ movlpd 24(%rsp), %xmm3
+ movd %xmm3, %r9
+
+ movlpd 16(%rsp), %xmm2
+ movd %xmm2, %r8
+
+ movlpd 8(%rsp), %xmm1
+ movd %xmm1, %rdx
+
+ movlpd (%rsp), %xmm0
+ movd %xmm0, %rcx
+
+ callq *FN(%rbp)
+.Lret_struct4b:
+ cmpl $FFI_TYPE_SMALL_STRUCT_4B, CIF_FLAGS(%rbp)
+ jne .Lret_struct2b
+
+ mov RVALUE(%rbp), %rcx
+ mov %eax, (%rcx)
+ jmp .Lret_void
+
+.Lret_struct2b:
+ cmpl $FFI_TYPE_SMALL_STRUCT_2B, CIF_FLAGS(%rbp)
+ jne .Lret_struct1b
+
+ mov RVALUE(%rbp), %rcx
+ mov %ax, (%rcx)
+ jmp .Lret_void
+
+.Lret_struct1b:
+ cmpl $FFI_TYPE_SMALL_STRUCT_1B, CIF_FLAGS(%rbp)
+ jne .Lret_uint8
+
+ mov RVALUE(%rbp), %rcx
+ mov %al, (%rcx)
+ jmp .Lret_void
+
+.Lret_uint8:
+ cmpl $FFI_TYPE_UINT8, CIF_FLAGS(%rbp)
+ jne .Lret_sint8
+
+ mov RVALUE(%rbp), %rcx
+ movzbq %al, %rax
+ movq %rax, (%rcx)
+ jmp .Lret_void
+
+.Lret_sint8:
+ cmpl $FFI_TYPE_SINT8, CIF_FLAGS(%rbp)
+ jne .Lret_uint16
+
+ mov RVALUE(%rbp), %rcx
+ movsbq %al, %rax
+ movq %rax, (%rcx)
+ jmp .Lret_void
+
+.Lret_uint16:
+ cmpl $FFI_TYPE_UINT16, CIF_FLAGS(%rbp)
+ jne .Lret_sint16
+
+ mov RVALUE(%rbp), %rcx
+ movzwq %ax, %rax
+ movq %rax, (%rcx)
+ jmp .Lret_void
+
+.Lret_sint16:
+ cmpl $FFI_TYPE_SINT16, CIF_FLAGS(%rbp)
+ jne .Lret_uint32
+
+ mov RVALUE(%rbp), %rcx
+ movswq %ax, %rax
+ movq %rax, (%rcx)
+ jmp .Lret_void
+
+.Lret_uint32:
+ cmpl $FFI_TYPE_UINT32, CIF_FLAGS(%rbp)
+ jne .Lret_sint32
+
+ mov RVALUE(%rbp), %rcx
+ movl %eax, %eax
+ movq %rax, (%rcx)
+ jmp .Lret_void
+
+.Lret_sint32:
+ cmpl $FFI_TYPE_SINT32, CIF_FLAGS(%rbp)
+ jne .Lret_float
+
+ mov RVALUE(%rbp), %rcx
+ cltq
+ movq %rax, (%rcx)
+ jmp .Lret_void
+
+.Lret_float:
+ cmpl $FFI_TYPE_FLOAT, CIF_FLAGS(%rbp)
+ jne .Lret_double
+
+ mov RVALUE(%rbp), %rax
+ movss %xmm0, (%rax)
+ jmp .Lret_void
+
+.Lret_double:
+ cmpl $FFI_TYPE_DOUBLE, CIF_FLAGS(%rbp)
+ jne .Lret_uint64
+
+ mov RVALUE(%rbp), %rax
+ movlpd %xmm0, (%rax)
+ jmp .Lret_void
+
+.Lret_uint64:
+ cmpl $FFI_TYPE_UINT64, CIF_FLAGS(%rbp)
+ jne .Lret_sint64
+
+ mov RVALUE(%rbp), %rcx
+ mov %rax, (%rcx)
+ jmp .Lret_void
+
+.Lret_sint64:
+ cmpl $FFI_TYPE_SINT64, CIF_FLAGS(%rbp)
+ jne .Lret_pointer
+
+ mov RVALUE(%rbp), %rcx
+ mov %rax, (%rcx)
+ jmp .Lret_void
+
+.Lret_pointer:
+ cmpl $FFI_TYPE_POINTER, CIF_FLAGS(%rbp)
+ jne .Lret_int
+
+ mov RVALUE(%rbp), %rcx
+ mov %rax, (%rcx)
+ jmp .Lret_void
+
+.Lret_int:
+ cmpl $FFI_TYPE_INT, CIF_FLAGS(%rbp)
+ jne .Lret_void
+
+ mov RVALUE(%rbp), %rcx
+ cltq
+ movq %rax, (%rcx)
+ jmp .Lret_void
+
+.Lret_void:
+ xor %rax, %rax
+
+ lea 16(%rbp), %rsp
+ pop %rbp
+ retq
+ .seh_endproc
+#endif /* !_MSC_VER */
+
diff --git a/jni/ruby/ext/fiddle/libffi-3.2.1/src/xtensa/ffi.c b/jni/ruby/ext/fiddle/libffi-3.2.1/src/xtensa/ffi.c
new file mode 100644
index 0000000..fd94daf
--- /dev/null
+++ b/jni/ruby/ext/fiddle/libffi-3.2.1/src/xtensa/ffi.c
@@ -0,0 +1,298 @@
+/* -----------------------------------------------------------------------
+ ffi.c - Copyright (c) 2013 Tensilica, Inc.
+
+ XTENSA Foreign Function Interface
+
+ Permission is hereby granted, free of charge, to any person obtaining
+ a copy of this software and associated documentation files (the
+ ``Software''), to deal in the Software without restriction, including
+ without limitation the rights to use, copy, modify, merge, publish,
+ distribute, sublicense, and/or sell copies of the Software, and to
+ permit persons to whom the Software is furnished to do so, subject to
+ the following conditions:
+
+ The above copyright notice and this permission notice shall be included
+ in all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND,
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+ HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ DEALINGS IN THE SOFTWARE.
+ ----------------------------------------------------------------------- */
+
+#include <ffi.h>
+#include <ffi_common.h>
+
+/*
+ |----------------------------------------|
+ | |
+ on entry to ffi_call ----> |----------------------------------------|
+ | caller stack frame for registers a0-a3 |
+ |----------------------------------------|
+ | |
+ | additional arguments |
+ entry of the function ---> |----------------------------------------|
+ | copy of function arguments a2-a7 |
+ | - - - - - - - - - - - - - |
+ | |
+
+ The area below the entry line becomes the new stack frame for the function.
+
+*/
+
+
+#define FFI_TYPE_STRUCT_REGS FFI_TYPE_LAST
+
+
+extern void ffi_call_SYSV(void *rvalue, unsigned rsize, unsigned flags,
+ void(*fn)(void), unsigned nbytes, extended_cif*);
+extern void ffi_closure_SYSV(void) FFI_HIDDEN;
+
+ffi_status ffi_prep_cif_machdep(ffi_cif *cif)
+{
+ switch(cif->rtype->type) {
+ case FFI_TYPE_SINT8:
+ case FFI_TYPE_UINT8:
+ case FFI_TYPE_SINT16:
+ case FFI_TYPE_UINT16:
+ cif->flags = cif->rtype->type;
+ break;
+ case FFI_TYPE_VOID:
+ case FFI_TYPE_FLOAT:
+ cif->flags = FFI_TYPE_UINT32;
+ break;
+ case FFI_TYPE_DOUBLE:
+ case FFI_TYPE_UINT64:
+ case FFI_TYPE_SINT64:
+ cif->flags = FFI_TYPE_UINT64; // cif->rtype->type;
+ break;
+ case FFI_TYPE_STRUCT:
+ cif->flags = FFI_TYPE_STRUCT; //_REGS;
+ /* Up to 16 bytes are returned in registers */
+ if (cif->rtype->size > 4 * 4) {
+ /* returned structure is referenced by a register; use 8 bytes
+ (including 4 bytes for potential additional alignment) */
+ cif->flags = FFI_TYPE_STRUCT;
+ cif->bytes += 8;
+ }
+ break;
+
+ default:
+ cif->flags = FFI_TYPE_UINT32;
+ break;
+ }
+
+ /* Round the stack up to a full 4 register frame, just in case
+ (we use this size in movsp). This way, it's also a multiple of
+ 8 bytes for 64-bit arguments. */
+ cif->bytes = ALIGN(cif->bytes, 16);
+
+ return FFI_OK;
+}
+
+void ffi_prep_args(extended_cif *ecif, unsigned char* stack)
+{
+ unsigned int i;
+ unsigned long *addr;
+ ffi_type **ptr;
+
+ union {
+ void **v;
+ char **c;
+ signed char **sc;
+ unsigned char **uc;
+ signed short **ss;
+ unsigned short **us;
+ unsigned int **i;
+ long long **ll;
+ float **f;
+ double **d;
+ } p_argv;
+
+ /* Verify that everything is aligned up properly */
+ FFI_ASSERT (((unsigned long) stack & 0x7) == 0);
+
+ p_argv.v = ecif->avalue;
+ addr = (unsigned long*)stack;
+
+ /* structures with a size greater than 16 bytes are passed in memory */
+ if (ecif->cif->rtype->type == FFI_TYPE_STRUCT && ecif->cif->rtype->size > 16)
+ {
+ *addr++ = (unsigned long)ecif->rvalue;
+ }
+
+ for (i = ecif->cif->nargs, ptr = ecif->cif->arg_types;
+ i > 0;
+ i--, ptr++, p_argv.v++)
+ {
+ switch ((*ptr)->type)
+ {
+ case FFI_TYPE_SINT8:
+ *addr++ = **p_argv.sc;
+ break;
+ case FFI_TYPE_UINT8:
+ *addr++ = **p_argv.uc;
+ break;
+ case FFI_TYPE_SINT16:
+ *addr++ = **p_argv.ss;
+ break;
+ case FFI_TYPE_UINT16:
+ *addr++ = **p_argv.us;
+ break;
+ case FFI_TYPE_FLOAT:
+ case FFI_TYPE_INT:
+ case FFI_TYPE_UINT32:
+ case FFI_TYPE_SINT32:
+ case FFI_TYPE_POINTER:
+ *addr++ = **p_argv.i;
+ break;
+ case FFI_TYPE_DOUBLE:
+ case FFI_TYPE_UINT64:
+ case FFI_TYPE_SINT64:
+ if (((unsigned long)addr & 4) != 0)
+ addr++;
+ *(unsigned long long*)addr = **p_argv.ll;
+ addr += sizeof(unsigned long long) / sizeof (addr);
+ break;
+
+ case FFI_TYPE_STRUCT:
+ {
+ unsigned long offs;
+ unsigned long size;
+
+ if (((unsigned long)addr & 4) != 0 && (*ptr)->alignment > 4)
+ addr++;
+
+ offs = (unsigned long) addr - (unsigned long) stack;
+ size = (*ptr)->size;
+
+ /* Entire structure must fit the argument registers or referenced */
+ if (offs < FFI_REGISTER_NARGS * 4
+ && offs + size > FFI_REGISTER_NARGS * 4)
+ addr = (unsigned long*) (stack + FFI_REGISTER_NARGS * 4);
+
+ memcpy((char*) addr, *p_argv.c, size);
+ addr += (size + 3) / 4;
+ break;
+ }
+
+ default:
+ FFI_ASSERT(0);
+ }
+ }
+}
+
+
+void ffi_call(ffi_cif* cif, void(*fn)(void), void *rvalue, void **avalue)
+{
+ extended_cif ecif;
+ unsigned long rsize = cif->rtype->size;
+ int flags = cif->flags;
+ void *alloc = NULL;
+
+ ecif.cif = cif;
+ ecif.avalue = avalue;
+
+ /* Note that for structures that are returned in registers (size <= 16 bytes)
+ we allocate a temporary buffer and use memcpy to copy it to the final
+ destination. The reason is that the target address might be misaligned or
+ the length not a multiple of 4 bytes. Handling all those cases would be
+ very complex. */
+
+ if (flags == FFI_TYPE_STRUCT && (rsize <= 16 || rvalue == NULL))
+ {
+ alloc = alloca(ALIGN(rsize, 4));
+ ecif.rvalue = alloc;
+ }
+ else
+ {
+ ecif.rvalue = rvalue;
+ }
+
+ if (cif->abi != FFI_SYSV)
+ FFI_ASSERT(0);
+
+ ffi_call_SYSV (ecif.rvalue, rsize, cif->flags, fn, cif->bytes, &ecif);
+
+ if (alloc != NULL && rvalue != NULL)
+ memcpy(rvalue, alloc, rsize);
+}
+
+extern void ffi_trampoline();
+extern void ffi_cacheflush(void* start, void* end);
+
+ffi_status
+ffi_prep_closure_loc (ffi_closure* closure,
+ ffi_cif* cif,
+ void (*fun)(ffi_cif*, void*, void**, void*),
+ void *user_data,
+ void *codeloc)
+{
+ /* copye trampoline to stack and patch 'ffi_closure_SYSV' pointer */
+ memcpy(closure->tramp, ffi_trampoline, FFI_TRAMPOLINE_SIZE);
+ *(unsigned int*)(&closure->tramp[8]) = (unsigned int)ffi_closure_SYSV;
+
+ // Do we have this function?
+ // __builtin___clear_cache(closer->tramp, closer->tramp + FFI_TRAMPOLINE_SIZE)
+ ffi_cacheflush(closure->tramp, closure->tramp + FFI_TRAMPOLINE_SIZE);
+
+ closure->cif = cif;
+ closure->fun = fun;
+ closure->user_data = user_data;
+ return FFI_OK;
+}
+
+
+long FFI_HIDDEN
+ffi_closure_SYSV_inner(ffi_closure *closure, void **values, void *rvalue)
+{
+ ffi_cif *cif;
+ ffi_type **arg_types;
+ void **avalue;
+ int i, areg;
+
+ cif = closure->cif;
+ if (cif->abi != FFI_SYSV)
+ return FFI_BAD_ABI;
+
+ areg = 0;
+
+ int rtype = cif->rtype->type;
+ if (rtype == FFI_TYPE_STRUCT && cif->rtype->size > 4 * 4)
+ {
+ rvalue = *values;
+ areg++;
+ }
+
+ cif = closure->cif;
+ arg_types = cif->arg_types;
+ avalue = alloca(cif->nargs * sizeof(void *));
+
+ for (i = 0; i < cif->nargs; i++)
+ {
+ if (arg_types[i]->alignment == 8 && (areg & 1) != 0)
+ areg++;
+
+ // skip the entry 16,a1 framework, add 16 bytes (4 registers)
+ if (areg == FFI_REGISTER_NARGS)
+ areg += 4;
+
+ if (arg_types[i]->type == FFI_TYPE_STRUCT)
+ {
+ int numregs = ((arg_types[i]->size + 3) & ~3) / 4;
+ if (areg < FFI_REGISTER_NARGS && areg + numregs > FFI_REGISTER_NARGS)
+ areg = FFI_REGISTER_NARGS + 4;
+ }
+
+ avalue[i] = &values[areg];
+ areg += (arg_types[i]->size + 3) / 4;
+ }
+
+ (closure->fun)(cif, rvalue, avalue, closure->user_data);
+
+ return rtype;
+}
diff --git a/jni/ruby/ext/fiddle/libffi-3.2.1/src/xtensa/ffitarget.h b/jni/ruby/ext/fiddle/libffi-3.2.1/src/xtensa/ffitarget.h
new file mode 100644
index 0000000..0ba728b
--- /dev/null
+++ b/jni/ruby/ext/fiddle/libffi-3.2.1/src/xtensa/ffitarget.h
@@ -0,0 +1,53 @@
+/* -----------------------------------------------------------------*-C-*-
+ ffitarget.h - Copyright (c) 2013 Tensilica, Inc.
+ Target configuration macros for XTENSA.
+
+ Permission is hereby granted, free of charge, to any person obtaining
+ a copy of this software and associated documentation files (the
+ ``Software''), to deal in the Software without restriction, including
+ without limitation the rights to use, copy, modify, merge, publish,
+ distribute, sublicense, and/or sell copies of the Software, and to
+ permit persons to whom the Software is furnished to do so, subject to
+ the following conditions:
+
+ The above copyright notice and this permission notice shall be included
+ in all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND,
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+ HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ DEALINGS IN THE SOFTWARE.
+ ----------------------------------------------------------------------- */
+
+#ifndef LIBFFI_TARGET_H
+#define LIBFFI_TARGET_H
+
+#ifndef LIBFFI_H
+#error "Please do not include ffitarget.h directly into your source. Use ffi.h instead."
+#endif
+
+#ifndef LIBFFI_ASM
+typedef unsigned long ffi_arg;
+typedef signed long ffi_sarg;
+
+typedef enum ffi_abi {
+ FFI_FIRST_ABI = 0,
+ FFI_SYSV,
+ FFI_LAST_ABI,
+ FFI_DEFAULT_ABI = FFI_SYSV
+} ffi_abi;
+#endif
+
+#define FFI_REGISTER_NARGS 6
+
+/* ---- Definitions for closures ----------------------------------------- */
+
+#define FFI_CLOSURES 1
+#define FFI_NATIVE_RAW_API 0
+#define FFI_TRAMPOLINE_SIZE 24
+
+#endif
diff --git a/jni/ruby/ext/fiddle/libffi-3.2.1/src/xtensa/sysv.S b/jni/ruby/ext/fiddle/libffi-3.2.1/src/xtensa/sysv.S
new file mode 100644
index 0000000..64e6a09
--- /dev/null
+++ b/jni/ruby/ext/fiddle/libffi-3.2.1/src/xtensa/sysv.S
@@ -0,0 +1,253 @@
+/* -----------------------------------------------------------------------
+ sysv.S - Copyright (c) 2013 Tensilica, Inc.
+
+ XTENSA Foreign Function Interface
+
+ Permission is hereby granted, free of charge, to any person obtaining
+ a copy of this software and associated documentation files (the
+ ``Software''), to deal in the Software without restriction, including
+ without limitation the rights to use, copy, modify, merge, publish,
+ distribute, sublicense, and/or sell copies of the Software, and to
+ permit persons to whom the Software is furnished to do so, subject to
+ the following conditions:
+
+ The above copyright notice and this permission notice shall be included
+ in all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND,
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+ HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ DEALINGS IN THE SOFTWARE.
+ ----------------------------------------------------------------------- */
+
+#define LIBFFI_ASM
+#include <fficonfig.h>
+#include <ffi.h>
+
+#define ENTRY(name) .text; .globl name; .type name,@function; .align 4; name:
+#define END(name) .size name , . - name
+
+/* Assert that the table below is in sync with ffi.h. */
+
+#if FFI_TYPE_UINT8 != 5 \
+ || FFI_TYPE_SINT8 != 6 \
+ || FFI_TYPE_UINT16 != 7 \
+ || FFI_TYPE_SINT16 != 8 \
+ || FFI_TYPE_UINT32 != 9 \
+ || FFI_TYPE_SINT32 != 10 \
+ || FFI_TYPE_UINT64 != 11
+#error "xtensa/sysv.S out of sync with ffi.h"
+#endif
+
+
+/* ffi_call_SYSV (rvalue, rbytes, flags, (*fnaddr)(), bytes, ecif)
+ void *rvalue; a2
+ unsigned long rbytes; a3
+ unsigned flags; a4
+ void (*fnaddr)(); a5
+ unsigned long bytes; a6
+ extended_cif* ecif) a7
+*/
+
+ENTRY(ffi_call_SYSV)
+
+ entry a1, 32 # 32 byte frame for using call8 below
+
+ mov a10, a7 # a10(->arg0): ecif
+ sub a11, a1, a6 # a11(->arg1): stack pointer
+ mov a7, a1 # fp
+ movsp a1, a11 # set new sp = old_sp - bytes
+
+ movi a8, ffi_prep_args
+ callx8 a8 # ffi_prep_args(ecif, stack)
+
+ # prepare to move stack pointer back up to 6 arguments
+ # note that 'bytes' is already aligned
+
+ movi a10, 6*4
+ sub a11, a6, a10
+ movgez a6, a10, a11
+ add a6, a1, a6
+
+
+ # we can pass up to 6 arguments in registers
+ # for simplicity, just load 6 arguments
+ # (the stack size is at least 32 bytes, so no risk to cross boundaries)
+
+ l32i a10, a1, 0
+ l32i a11, a1, 4
+ l32i a12, a1, 8
+ l32i a13, a1, 12
+ l32i a14, a1, 16
+ l32i a15, a1, 20
+
+ # move stack pointer
+
+ movsp a1, a6
+
+ callx8 a5 # (*fn)(args...)
+
+ # Handle return value(s)
+
+ beqz a2, .Lexit
+
+ movi a5, FFI_TYPE_STRUCT
+ bne a4, a5, .Lstore
+ movi a5, 16
+ blt a5, a3, .Lexit
+
+ s32i a10, a2, 0
+ blti a3, 5, .Lexit
+ addi a3, a3, -1
+ s32i a11, a2, 4
+ blti a3, 8, .Lexit
+ s32i a12, a2, 8
+ blti a3, 12, .Lexit
+ s32i a13, a2, 12
+
+.Lexit: retw
+
+.Lstore:
+ addi a4, a4, -FFI_TYPE_UINT8
+ bgei a4, 7, .Lexit # should never happen
+ movi a6, store_calls
+ add a4, a4, a4
+ addx4 a6, a4, a6 # store_table + idx * 8
+ jx a6
+
+ .align 8
+store_calls:
+ # UINT8
+ s8i a10, a2, 0
+ retw
+
+ # SINT8
+ .align 8
+ s8i a10, a2, 0
+ retw
+
+ # UINT16
+ .align 8
+ s16i a10, a2, 0
+ retw
+
+ # SINT16
+ .align 8
+ s16i a10, a2, 0
+ retw
+
+ # UINT32
+ .align 8
+ s32i a10, a2, 0
+ retw
+
+ # SINT32
+ .align 8
+ s32i a10, a2, 0
+ retw
+
+ # UINT64
+ .align 8
+ s32i a10, a2, 0
+ s32i a11, a2, 4
+ retw
+
+END(ffi_call_SYSV)
+
+
+/*
+ * void ffi_cacheflush (unsigned long start, unsigned long end)
+ */
+
+#define EXTRA_ARGS_SIZE 24
+
+ENTRY(ffi_cacheflush)
+
+ entry a1, 16
+
+1: dhwbi a2, 0
+ ihi a2, 0
+ addi a2, a2, 4
+ blt a2, a3, 1b
+
+ retw
+
+END(ffi_cacheflush)
+
+/* ffi_trampoline is copied to the stack */
+
+ENTRY(ffi_trampoline)
+
+ entry a1, 16 + (FFI_REGISTER_NARGS * 4) + (4 * 4) # [ 0]
+ j 2f # [ 3]
+ .align 4 # [ 6]
+1: .long 0 # [ 8]
+2: l32r a15, 1b # [12]
+ _mov a14, a0 # [15]
+ callx0 a15 # [18]
+ # [21]
+END(ffi_trampoline)
+
+/*
+ * ffi_closure()
+ *
+ * a0: closure + 21
+ * a14: return address (a0)
+ */
+
+ENTRY(ffi_closure_SYSV)
+
+ /* intentionally omitting entry here */
+
+ # restore return address (a0) and move pointer to closure to a10
+ addi a10, a0, -21
+ mov a0, a14
+
+ # allow up to 4 arguments as return values
+ addi a11, a1, 4 * 4
+
+ # save up to 6 arguments to stack (allocated by entry below)
+ s32i a2, a11, 0
+ s32i a3, a11, 4
+ s32i a4, a11, 8
+ s32i a5, a11, 12
+ s32i a6, a11, 16
+ s32i a7, a11, 20
+
+ movi a8, ffi_closure_SYSV_inner
+ mov a12, a1
+ callx8 a8 # .._inner(*closure, **avalue, *rvalue)
+
+ # load up to four return arguments
+ l32i a2, a1, 0
+ l32i a3, a1, 4
+ l32i a4, a1, 8
+ l32i a5, a1, 12
+
+ # (sign-)extend return value
+ movi a11, FFI_TYPE_UINT8
+ bne a10, a11, 1f
+ extui a2, a2, 0, 8
+ retw
+
+1: movi a11, FFI_TYPE_SINT8
+ bne a10, a11, 1f
+ sext a2, a2, 7
+ retw
+
+1: movi a11, FFI_TYPE_UINT16
+ bne a10, a11, 1f
+ extui a2, a2, 0, 16
+ retw
+
+1: movi a11, FFI_TYPE_SINT16
+ bne a10, a11, 1f
+ sext a2, a2, 15
+
+1: retw
+
+END(ffi_closure_SYSV)
diff --git a/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/Makefile.am b/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/Makefile.am
new file mode 100644
index 0000000..da10465
--- /dev/null
+++ b/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/Makefile.am
@@ -0,0 +1,85 @@
+## Process this file with automake to produce Makefile.in.
+
+AUTOMAKE_OPTIONS = foreign dejagnu
+
+EXTRA_DEJAGNU_SITE_CONFIG=../local.exp
+
+CLEANFILES = *.exe core* *.log *.sum
+
+EXTRA_DIST = config/default.exp libffi.call/cls_19byte.c \
+libffi.call/cls_align_longdouble_split.c \
+libffi.call/closure_loc_fn0.c libffi.call/cls_schar.c \
+libffi.call/closure_fn1.c \
+libffi.call/return_ul.c libffi.call/cls_align_double.c \
+libffi.call/return_fl2.c libffi.call/cls_1_1byte.c \
+libffi.call/cls_64byte.c libffi.call/nested_struct7.c \
+libffi.call/cls_align_sint32.c libffi.call/nested_struct2.c \
+libffi.call/ffitest.h libffi.call/nested_struct4.c \
+libffi.call/cls_multi_ushort.c libffi.call/struct3.c \
+libffi.call/cls_3byte1.c libffi.call/cls_16byte.c \
+libffi.call/struct8.c libffi.call/nested_struct8.c \
+libffi.call/cls_multi_sshort.c libffi.call/cls_3byte2.c \
+libffi.call/cls_pointer.c \
+libffi.call/err_bad_typedef.c libffi.call/cls_4_1byte.c \
+libffi.call/cls_9byte2.c libffi.call/cls_multi_schar.c \
+libffi.call/stret_medium2.c libffi.call/cls_5_1_byte.c \
+libffi.call/call.exp libffi.call/cls_double.c \
+libffi.call/cls_align_sint16.c libffi.call/cls_uint.c \
+libffi.call/return_ll1.c libffi.call/nested_struct3.c \
+libffi.call/cls_20byte1.c libffi.call/closure_fn4.c \
+libffi.call/cls_uchar.c libffi.call/struct2.c libffi.call/cls_7byte.c \
+libffi.call/strlen.c libffi.call/many.c libffi.call/testclosure.c \
+libffi.call/return_fl.c libffi.call/struct5.c \
+libffi.call/cls_12byte.c libffi.call/cls_multi_sshortchar.c \
+libffi.call/cls_align_longdouble_split2.c libffi.call/return_dbl2.c \
+libffi.call/return_fl3.c libffi.call/stret_medium.c \
+libffi.call/nested_struct6.c libffi.call/closure_fn3.c \
+libffi.call/float3.c libffi.call/many2.c \
+libffi.call/closure_simple.c libffi.call/cls_align_uint16.c \
+libffi.call/cls_9byte1.c libffi.call/closure_fn6.c \
+libffi.call/cls_double_va.c libffi.call/cls_align_pointer.c \
+libffi.call/cls_align_longdouble.c libffi.call/closure_fn2.c \
+libffi.call/cls_sshort.c \
+libffi.call/nested_struct.c libffi.call/cls_20byte.c \
+libffi.call/cls_longdouble.c libffi.call/cls_multi_uchar.c \
+libffi.call/return_uc.c \
+libffi.call/cls_18byte.c libffi.call/cls_8byte.c \
+libffi.call/promotion.c \
+libffi.call/return_dbl.c libffi.call/cls_24byte.c \
+libffi.call/struct4.c libffi.call/cls_6byte.c \
+libffi.call/cls_align_uint32.c libffi.call/float.c \
+libffi.call/float1.c libffi.call/float_va.c libffi.call/negint.c \
+libffi.call/return_dbl1.c libffi.call/cls_3_1byte.c \
+libffi.call/cls_align_float.c libffi.call/return_fl1.c \
+libffi.call/nested_struct10.c libffi.call/nested_struct5.c \
+libffi.call/cls_align_sint64.c \
+libffi.call/stret_large2.c libffi.call/return_sl.c \
+libffi.call/closure_fn0.c libffi.call/cls_5byte.c \
+libffi.call/cls_2byte.c libffi.call/float2.c \
+libffi.call/cls_dbls_struct.c libffi.call/cls_sint.c \
+libffi.call/stret_large.c libffi.call/cls_ulonglong.c \
+libffi.call/cls_ushort.c libffi.call/nested_struct1.c \
+libffi.call/err_bad_abi.c libffi.call/cls_longdouble_va.c \
+libffi.call/cls_float.c libffi.call/cls_pointer_stack.c \
+libffi.call/pyobjc-tc.c libffi.call/cls_multi_ushortchar.c \
+libffi.call/struct1.c libffi.call/nested_struct9.c \
+libffi.call/huge_struct.c libffi.call/problem1.c \
+libffi.call/float4.c \
+libffi.call/return_ldl.c \
+libffi.call/closure_fn5.c \
+libffi.call/struct6.c libffi.call/return_ll.c libffi.call/struct9.c \
+libffi.call/return_sc.c libffi.call/struct7.c \
+libffi.call/cls_align_uint64.c libffi.call/cls_4byte.c \
+libffi.call/cls_6_1_byte.c \
+libffi.call/cls_7_1_byte.c libffi.call/unwindtest.cc \
+libffi.call/unwindtest_ffi_call.cc \
+lib/wrapper.exp lib/target-libpath.exp \
+lib/libffi.exp libffi.call/cls_struct_va1.c \
+libffi.call/cls_uchar_va.c libffi.call/cls_uint_va.c \
+libffi.call/cls_ulong_va.c libffi.call/cls_ushort_va.c \
+libffi.call/nested_struct11.c libffi.call/uninitialized.c \
+libffi.call/va_1.c libffi.call/va_struct1.c libffi.call/va_struct2.c \
+libffi.call/va_struct3.c \
+libffi.call/strlen2.c \
+libffi.call/strlen3.c \
+libffi.call/strlen4.c
diff --git a/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/Makefile.in b/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/Makefile.in
new file mode 100644
index 0000000..99e226c
--- /dev/null
+++ b/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/Makefile.in
@@ -0,0 +1,590 @@
+# Makefile.in generated by automake 1.13.4 from Makefile.am.
+# @configure_input@
+
+# Copyright (C) 1994-2013 Free Software Foundation, Inc.
+
+# This Makefile.in is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
+# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE.
+
+@SET_MAKE@
+VPATH = @srcdir@
+am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)'
+am__make_running_with_option = \
+ case $${target_option-} in \
+ ?) ;; \
+ *) echo "am__make_running_with_option: internal error: invalid" \
+ "target option '$${target_option-}' specified" >&2; \
+ exit 1;; \
+ esac; \
+ has_opt=no; \
+ sane_makeflags=$$MAKEFLAGS; \
+ if $(am__is_gnu_make); then \
+ sane_makeflags=$$MFLAGS; \
+ else \
+ case $$MAKEFLAGS in \
+ *\\[\ \ ]*) \
+ bs=\\; \
+ sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \
+ | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \
+ esac; \
+ fi; \
+ skip_next=no; \
+ strip_trailopt () \
+ { \
+ flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \
+ }; \
+ for flg in $$sane_makeflags; do \
+ test $$skip_next = yes && { skip_next=no; continue; }; \
+ case $$flg in \
+ *=*|--*) continue;; \
+ -*I) strip_trailopt 'I'; skip_next=yes;; \
+ -*I?*) strip_trailopt 'I';; \
+ -*O) strip_trailopt 'O'; skip_next=yes;; \
+ -*O?*) strip_trailopt 'O';; \
+ -*l) strip_trailopt 'l'; skip_next=yes;; \
+ -*l?*) strip_trailopt 'l';; \
+ -[dEDm]) skip_next=yes;; \
+ -[JT]) skip_next=yes;; \
+ esac; \
+ case $$flg in \
+ *$$target_option*) has_opt=yes; break;; \
+ esac; \
+ done; \
+ test $$has_opt = yes
+am__make_dryrun = (target_option=n; $(am__make_running_with_option))
+am__make_keepgoing = (target_option=k; $(am__make_running_with_option))
+pkgdatadir = $(datadir)/@PACKAGE@
+pkgincludedir = $(includedir)/@PACKAGE@
+pkglibdir = $(libdir)/@PACKAGE@
+pkglibexecdir = $(libexecdir)/@PACKAGE@
+am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
+install_sh_DATA = $(install_sh) -c -m 644
+install_sh_PROGRAM = $(install_sh) -c
+install_sh_SCRIPT = $(install_sh) -c
+INSTALL_HEADER = $(INSTALL_DATA)
+transform = $(program_transform_name)
+NORMAL_INSTALL = :
+PRE_INSTALL = :
+POST_INSTALL = :
+NORMAL_UNINSTALL = :
+PRE_UNINSTALL = :
+POST_UNINSTALL = :
+build_triplet = @build@
+host_triplet = @host@
+target_triplet = @target@
+subdir = testsuite
+DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am
+ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
+am__aclocal_m4_deps = $(top_srcdir)/m4/asmcfi.m4 \
+ $(top_srcdir)/m4/ax_append_flag.m4 \
+ $(top_srcdir)/m4/ax_cc_maxopt.m4 \
+ $(top_srcdir)/m4/ax_cflags_warn_all.m4 \
+ $(top_srcdir)/m4/ax_check_compile_flag.m4 \
+ $(top_srcdir)/m4/ax_compiler_vendor.m4 \
+ $(top_srcdir)/m4/ax_configure_args.m4 \
+ $(top_srcdir)/m4/ax_enable_builddir.m4 \
+ $(top_srcdir)/m4/ax_gcc_archflag.m4 \
+ $(top_srcdir)/m4/ax_gcc_x86_cpuid.m4 \
+ $(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \
+ $(top_srcdir)/m4/ltsugar.m4 $(top_srcdir)/m4/ltversion.m4 \
+ $(top_srcdir)/m4/lt~obsolete.m4 $(top_srcdir)/acinclude.m4 \
+ $(top_srcdir)/configure.ac
+am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
+ $(ACLOCAL_M4)
+mkinstalldirs = $(install_sh) -d
+CONFIG_HEADER = $(top_builddir)/fficonfig.h
+CONFIG_CLEAN_FILES =
+CONFIG_CLEAN_VPATH_FILES =
+AM_V_P = $(am__v_P_@AM_V@)
+am__v_P_ = $(am__v_P_@AM_DEFAULT_V@)
+am__v_P_0 = false
+am__v_P_1 = :
+AM_V_GEN = $(am__v_GEN_@AM_V@)
+am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@)
+am__v_GEN_0 = @echo " GEN " $@;
+am__v_GEN_1 =
+AM_V_at = $(am__v_at_@AM_V@)
+am__v_at_ = $(am__v_at_@AM_DEFAULT_V@)
+am__v_at_0 = @
+am__v_at_1 =
+SOURCES =
+DIST_SOURCES =
+am__can_run_installinfo = \
+ case $$AM_UPDATE_INFO_DIR in \
+ n|no|NO) false;; \
+ *) (install-info --version) >/dev/null 2>&1;; \
+ esac
+am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP)
+DEJATOOL = $(PACKAGE)
+RUNTESTDEFAULTFLAGS = --tool $$tool --srcdir $$srcdir
+EXPECT = expect
+RUNTEST = runtest
+DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
+ACLOCAL = @ACLOCAL@
+ALLOCA = @ALLOCA@
+AMTAR = @AMTAR@
+AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@
+AM_LTLDFLAGS = @AM_LTLDFLAGS@
+AM_RUNTESTFLAGS = @AM_RUNTESTFLAGS@
+AR = @AR@
+AUTOCONF = @AUTOCONF@
+AUTOHEADER = @AUTOHEADER@
+AUTOMAKE = @AUTOMAKE@
+AWK = @AWK@
+CC = @CC@
+CCAS = @CCAS@
+CCASDEPMODE = @CCASDEPMODE@
+CCASFLAGS = @CCASFLAGS@
+CCDEPMODE = @CCDEPMODE@
+CFLAGS = @CFLAGS@
+CPP = @CPP@
+CPPFLAGS = @CPPFLAGS@
+CXX = @CXX@
+CXXCPP = @CXXCPP@
+CXXDEPMODE = @CXXDEPMODE@
+CXXFLAGS = @CXXFLAGS@
+CYGPATH_W = @CYGPATH_W@
+DEFS = @DEFS@
+DEPDIR = @DEPDIR@
+DLLTOOL = @DLLTOOL@
+DSYMUTIL = @DSYMUTIL@
+DUMPBIN = @DUMPBIN@
+ECHO_C = @ECHO_C@
+ECHO_N = @ECHO_N@
+ECHO_T = @ECHO_T@
+EGREP = @EGREP@
+EXEEXT = @EXEEXT@
+FFI_EXEC_TRAMPOLINE_TABLE = @FFI_EXEC_TRAMPOLINE_TABLE@
+FGREP = @FGREP@
+GREP = @GREP@
+HAVE_LONG_DOUBLE = @HAVE_LONG_DOUBLE@
+HAVE_LONG_DOUBLE_VARIANT = @HAVE_LONG_DOUBLE_VARIANT@
+INSTALL = @INSTALL@
+INSTALL_DATA = @INSTALL_DATA@
+INSTALL_PROGRAM = @INSTALL_PROGRAM@
+INSTALL_SCRIPT = @INSTALL_SCRIPT@
+INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
+LD = @LD@
+LDFLAGS = @LDFLAGS@
+LIBOBJS = @LIBOBJS@
+LIBS = @LIBS@
+LIBTOOL = @LIBTOOL@
+LIPO = @LIPO@
+LN_S = @LN_S@
+LTLIBOBJS = @LTLIBOBJS@
+MAINT = @MAINT@
+MAKEINFO = @MAKEINFO@
+MANIFEST_TOOL = @MANIFEST_TOOL@
+MKDIR_P = @MKDIR_P@
+NM = @NM@
+NMEDIT = @NMEDIT@
+OBJDUMP = @OBJDUMP@
+OBJEXT = @OBJEXT@
+OTOOL = @OTOOL@
+OTOOL64 = @OTOOL64@
+PACKAGE = @PACKAGE@
+PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
+PACKAGE_NAME = @PACKAGE_NAME@
+PACKAGE_STRING = @PACKAGE_STRING@
+PACKAGE_TARNAME = @PACKAGE_TARNAME@
+PACKAGE_URL = @PACKAGE_URL@
+PACKAGE_VERSION = @PACKAGE_VERSION@
+PATH_SEPARATOR = @PATH_SEPARATOR@
+PRTDIAG = @PRTDIAG@
+RANLIB = @RANLIB@
+SED = @SED@
+SET_MAKE = @SET_MAKE@
+SHELL = @SHELL@
+STRIP = @STRIP@
+TARGET = @TARGET@
+TARGETDIR = @TARGETDIR@
+VERSION = @VERSION@
+abs_builddir = @abs_builddir@
+abs_srcdir = @abs_srcdir@
+abs_top_builddir = @abs_top_builddir@
+abs_top_srcdir = @abs_top_srcdir@
+ac_ct_AR = @ac_ct_AR@
+ac_ct_CC = @ac_ct_CC@
+ac_ct_CXX = @ac_ct_CXX@
+ac_ct_DUMPBIN = @ac_ct_DUMPBIN@
+am__include = @am__include@
+am__leading_dot = @am__leading_dot@
+am__quote = @am__quote@
+am__tar = @am__tar@
+am__untar = @am__untar@
+ax_enable_builddir_sed = @ax_enable_builddir_sed@
+bindir = @bindir@
+build = @build@
+build_alias = @build_alias@
+build_cpu = @build_cpu@
+build_os = @build_os@
+build_vendor = @build_vendor@
+builddir = @builddir@
+datadir = @datadir@
+datarootdir = @datarootdir@
+docdir = @docdir@
+dvidir = @dvidir@
+exec_prefix = @exec_prefix@
+host = @host@
+host_alias = @host_alias@
+host_cpu = @host_cpu@
+host_os = @host_os@
+host_vendor = @host_vendor@
+htmldir = @htmldir@
+includedir = @includedir@
+infodir = @infodir@
+install_sh = @install_sh@
+libdir = @libdir@
+libexecdir = @libexecdir@
+localedir = @localedir@
+localstatedir = @localstatedir@
+mandir = @mandir@
+mkdir_p = @mkdir_p@
+oldincludedir = @oldincludedir@
+pdfdir = @pdfdir@
+prefix = @prefix@
+program_transform_name = @program_transform_name@
+psdir = @psdir@
+sbindir = @sbindir@
+sharedstatedir = @sharedstatedir@
+srcdir = @srcdir@
+sys_symbol_underscore = @sys_symbol_underscore@
+sysconfdir = @sysconfdir@
+target = @target@
+target_alias = @target_alias@
+target_cpu = @target_cpu@
+target_os = @target_os@
+target_vendor = @target_vendor@
+toolexecdir = @toolexecdir@
+toolexeclibdir = @toolexeclibdir@
+top_build_prefix = @top_build_prefix@
+top_builddir = @top_builddir@
+top_srcdir = @top_srcdir@
+AUTOMAKE_OPTIONS = foreign dejagnu
+EXTRA_DEJAGNU_SITE_CONFIG = ../local.exp
+CLEANFILES = *.exe core* *.log *.sum
+EXTRA_DIST = config/default.exp libffi.call/cls_19byte.c \
+libffi.call/cls_align_longdouble_split.c \
+libffi.call/closure_loc_fn0.c libffi.call/cls_schar.c \
+libffi.call/closure_fn1.c \
+libffi.call/return_ul.c libffi.call/cls_align_double.c \
+libffi.call/return_fl2.c libffi.call/cls_1_1byte.c \
+libffi.call/cls_64byte.c libffi.call/nested_struct7.c \
+libffi.call/cls_align_sint32.c libffi.call/nested_struct2.c \
+libffi.call/ffitest.h libffi.call/nested_struct4.c \
+libffi.call/cls_multi_ushort.c libffi.call/struct3.c \
+libffi.call/cls_3byte1.c libffi.call/cls_16byte.c \
+libffi.call/struct8.c libffi.call/nested_struct8.c \
+libffi.call/cls_multi_sshort.c libffi.call/cls_3byte2.c \
+libffi.call/cls_pointer.c \
+libffi.call/err_bad_typedef.c libffi.call/cls_4_1byte.c \
+libffi.call/cls_9byte2.c libffi.call/cls_multi_schar.c \
+libffi.call/stret_medium2.c libffi.call/cls_5_1_byte.c \
+libffi.call/call.exp libffi.call/cls_double.c \
+libffi.call/cls_align_sint16.c libffi.call/cls_uint.c \
+libffi.call/return_ll1.c libffi.call/nested_struct3.c \
+libffi.call/cls_20byte1.c libffi.call/closure_fn4.c \
+libffi.call/cls_uchar.c libffi.call/struct2.c libffi.call/cls_7byte.c \
+libffi.call/strlen.c libffi.call/many.c libffi.call/testclosure.c \
+libffi.call/return_fl.c libffi.call/struct5.c \
+libffi.call/cls_12byte.c libffi.call/cls_multi_sshortchar.c \
+libffi.call/cls_align_longdouble_split2.c libffi.call/return_dbl2.c \
+libffi.call/return_fl3.c libffi.call/stret_medium.c \
+libffi.call/nested_struct6.c libffi.call/closure_fn3.c \
+libffi.call/float3.c libffi.call/many2.c \
+libffi.call/closure_simple.c libffi.call/cls_align_uint16.c \
+libffi.call/cls_9byte1.c libffi.call/closure_fn6.c \
+libffi.call/cls_double_va.c libffi.call/cls_align_pointer.c \
+libffi.call/cls_align_longdouble.c libffi.call/closure_fn2.c \
+libffi.call/cls_sshort.c \
+libffi.call/nested_struct.c libffi.call/cls_20byte.c \
+libffi.call/cls_longdouble.c libffi.call/cls_multi_uchar.c \
+libffi.call/return_uc.c \
+libffi.call/cls_18byte.c libffi.call/cls_8byte.c \
+libffi.call/promotion.c \
+libffi.call/return_dbl.c libffi.call/cls_24byte.c \
+libffi.call/struct4.c libffi.call/cls_6byte.c \
+libffi.call/cls_align_uint32.c libffi.call/float.c \
+libffi.call/float1.c libffi.call/float_va.c libffi.call/negint.c \
+libffi.call/return_dbl1.c libffi.call/cls_3_1byte.c \
+libffi.call/cls_align_float.c libffi.call/return_fl1.c \
+libffi.call/nested_struct10.c libffi.call/nested_struct5.c \
+libffi.call/cls_align_sint64.c \
+libffi.call/stret_large2.c libffi.call/return_sl.c \
+libffi.call/closure_fn0.c libffi.call/cls_5byte.c \
+libffi.call/cls_2byte.c libffi.call/float2.c \
+libffi.call/cls_dbls_struct.c libffi.call/cls_sint.c \
+libffi.call/stret_large.c libffi.call/cls_ulonglong.c \
+libffi.call/cls_ushort.c libffi.call/nested_struct1.c \
+libffi.call/err_bad_abi.c libffi.call/cls_longdouble_va.c \
+libffi.call/cls_float.c libffi.call/cls_pointer_stack.c \
+libffi.call/pyobjc-tc.c libffi.call/cls_multi_ushortchar.c \
+libffi.call/struct1.c libffi.call/nested_struct9.c \
+libffi.call/huge_struct.c libffi.call/problem1.c \
+libffi.call/float4.c \
+libffi.call/return_ldl.c \
+libffi.call/closure_fn5.c \
+libffi.call/struct6.c libffi.call/return_ll.c libffi.call/struct9.c \
+libffi.call/return_sc.c libffi.call/struct7.c \
+libffi.call/cls_align_uint64.c libffi.call/cls_4byte.c \
+libffi.call/cls_6_1_byte.c \
+libffi.call/cls_7_1_byte.c libffi.call/unwindtest.cc \
+libffi.call/unwindtest_ffi_call.cc \
+lib/wrapper.exp lib/target-libpath.exp \
+lib/libffi.exp libffi.call/cls_struct_va1.c \
+libffi.call/cls_uchar_va.c libffi.call/cls_uint_va.c \
+libffi.call/cls_ulong_va.c libffi.call/cls_ushort_va.c \
+libffi.call/nested_struct11.c libffi.call/uninitialized.c \
+libffi.call/va_1.c libffi.call/va_struct1.c libffi.call/va_struct2.c \
+libffi.call/va_struct3.c \
+libffi.call/strlen2.c \
+libffi.call/strlen3.c \
+libffi.call/strlen4.c
+
+all: all-am
+
+.SUFFIXES:
+$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps)
+ @for dep in $?; do \
+ case '$(am__configure_deps)' in \
+ *$$dep*) \
+ ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \
+ && { if test -f $@; then exit 0; else break; fi; }; \
+ exit 1;; \
+ esac; \
+ done; \
+ echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign testsuite/Makefile'; \
+ $(am__cd) $(top_srcdir) && \
+ $(AUTOMAKE) --foreign testsuite/Makefile
+.PRECIOUS: Makefile
+Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
+ @case '$?' in \
+ *config.status*) \
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
+ *) \
+ echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
+ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
+ esac;
+
+$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+
+$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(am__aclocal_m4_deps):
+
+mostlyclean-libtool:
+ -rm -f *.lo
+
+clean-libtool:
+ -rm -rf .libs _libs
+tags TAGS:
+
+ctags CTAGS:
+
+cscope cscopelist:
+
+
+check-DEJAGNU: site.exp
+ srcdir='$(srcdir)'; export srcdir; \
+ EXPECT=$(EXPECT); export EXPECT; \
+ if $(SHELL) -c "$(RUNTEST) --version" > /dev/null 2>&1; then \
+ exit_status=0; l='$(DEJATOOL)'; for tool in $$l; do \
+ if $(RUNTEST) $(AM_RUNTESTFLAGS) $(RUNTESTDEFAULTFLAGS) $(RUNTESTFLAGS); \
+ then :; else exit_status=1; fi; \
+ done; \
+ else echo "WARNING: could not find '$(RUNTEST)'" 1>&2; :;\
+ fi; \
+ exit $$exit_status
+site.exp: Makefile $(EXTRA_DEJAGNU_SITE_CONFIG)
+ @echo 'Making a new site.exp file ...'
+ @echo '## these variables are automatically generated by make ##' >site.tmp
+ @echo '# Do not edit here. If you wish to override these values' >>site.tmp
+ @echo '# edit the last section' >>site.tmp
+ @echo 'set srcdir "$(srcdir)"' >>site.tmp
+ @echo "set objdir `pwd`" >>site.tmp
+ @echo 'set build_alias "$(build_alias)"' >>site.tmp
+ @echo 'set build_triplet $(build_triplet)' >>site.tmp
+ @echo 'set host_alias "$(host_alias)"' >>site.tmp
+ @echo 'set host_triplet $(host_triplet)' >>site.tmp
+ @echo 'set target_alias "$(target_alias)"' >>site.tmp
+ @echo 'set target_triplet $(target_triplet)' >>site.tmp
+ @list='$(EXTRA_DEJAGNU_SITE_CONFIG)'; for f in $$list; do \
+ echo "## Begin content included from file $$f. Do not modify. ##" \
+ && cat `test -f "$$f" || echo '$(srcdir)/'`$$f \
+ && echo "## End content included from file $$f. ##" \
+ || exit 1; \
+ done >> site.tmp
+ @echo "## End of auto-generated content; you can edit from here. ##" >> site.tmp
+ @if test -f site.exp; then \
+ sed -e '1,/^## End of auto-generated content.*##/d' site.exp >> site.tmp; \
+ fi
+ @-rm -f site.bak
+ @test ! -f site.exp || mv site.exp site.bak
+ @mv site.tmp site.exp
+
+distclean-DEJAGNU:
+ -rm -f site.exp site.bak
+ -l='$(DEJATOOL)'; for tool in $$l; do \
+ rm -f $$tool.sum $$tool.log; \
+ done
+
+distdir: $(DISTFILES)
+ @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+ list='$(DISTFILES)'; \
+ dist_files=`for file in $$list; do echo $$file; done | \
+ sed -e "s|^$$srcdirstrip/||;t" \
+ -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
+ case $$dist_files in \
+ */*) $(MKDIR_P) `echo "$$dist_files" | \
+ sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
+ sort -u` ;; \
+ esac; \
+ for file in $$dist_files; do \
+ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
+ if test -d $$d/$$file; then \
+ dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
+ if test -d "$(distdir)/$$file"; then \
+ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
+ fi; \
+ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
+ cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \
+ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
+ fi; \
+ cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \
+ else \
+ test -f "$(distdir)/$$file" \
+ || cp -p $$d/$$file "$(distdir)/$$file" \
+ || exit 1; \
+ fi; \
+ done
+check-am: all-am
+ $(MAKE) $(AM_MAKEFLAGS) check-DEJAGNU
+check: check-am
+all-am: Makefile
+installdirs:
+install: install-am
+install-exec: install-exec-am
+install-data: install-data-am
+uninstall: uninstall-am
+
+install-am: all-am
+ @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
+
+installcheck: installcheck-am
+install-strip:
+ if test -z '$(STRIP)'; then \
+ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
+ install; \
+ else \
+ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
+ "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \
+ fi
+mostlyclean-generic:
+
+clean-generic:
+ -test -z "$(CLEANFILES)" || rm -f $(CLEANFILES)
+
+distclean-generic:
+ -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
+ -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES)
+
+maintainer-clean-generic:
+ @echo "This command is intended for maintainers to use"
+ @echo "it deletes files that may require special tools to rebuild."
+clean: clean-am
+
+clean-am: clean-generic clean-libtool mostlyclean-am
+
+distclean: distclean-am
+ -rm -f Makefile
+distclean-am: clean-am distclean-DEJAGNU distclean-generic
+
+dvi: dvi-am
+
+dvi-am:
+
+html: html-am
+
+html-am:
+
+info: info-am
+
+info-am:
+
+install-data-am:
+
+install-dvi: install-dvi-am
+
+install-dvi-am:
+
+install-exec-am:
+
+install-html: install-html-am
+
+install-html-am:
+
+install-info: install-info-am
+
+install-info-am:
+
+install-man:
+
+install-pdf: install-pdf-am
+
+install-pdf-am:
+
+install-ps: install-ps-am
+
+install-ps-am:
+
+installcheck-am:
+
+maintainer-clean: maintainer-clean-am
+ -rm -f Makefile
+maintainer-clean-am: distclean-am maintainer-clean-generic
+
+mostlyclean: mostlyclean-am
+
+mostlyclean-am: mostlyclean-generic mostlyclean-libtool
+
+pdf: pdf-am
+
+pdf-am:
+
+ps: ps-am
+
+ps-am:
+
+uninstall-am:
+
+.MAKE: check-am install-am install-strip
+
+.PHONY: all all-am check check-DEJAGNU check-am clean clean-generic \
+ clean-libtool cscopelist-am ctags-am distclean \
+ distclean-DEJAGNU distclean-generic distclean-libtool distdir \
+ dvi dvi-am html html-am info info-am install install-am \
+ install-data install-data-am install-dvi install-dvi-am \
+ install-exec install-exec-am install-html install-html-am \
+ install-info install-info-am install-man install-pdf \
+ install-pdf-am install-ps install-ps-am install-strip \
+ installcheck installcheck-am installdirs maintainer-clean \
+ maintainer-clean-generic mostlyclean mostlyclean-generic \
+ mostlyclean-libtool pdf pdf-am ps ps-am tags-am uninstall \
+ uninstall-am
+
+
+# Tell versions [3.59,3.63) of GNU make to not export all variables.
+# Otherwise a system limit (for SysV at least) may be exceeded.
+.NOEXPORT:
diff --git a/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/config/default.exp b/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/config/default.exp
new file mode 100644
index 0000000..90967cc
--- /dev/null
+++ b/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/config/default.exp
@@ -0,0 +1 @@
+load_lib "standard.exp"
diff --git a/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/lib/libffi.exp b/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/lib/libffi.exp
new file mode 100644
index 0000000..5051d31
--- /dev/null
+++ b/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/lib/libffi.exp
@@ -0,0 +1,413 @@
+# Copyright (C) 2003, 2005, 2008, 2009, 2010, 2011, 2014 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 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; see the file COPYING3. If not see
+# <http://www.gnu.org/licenses/>.
+
+proc load_gcc_lib { filename } {
+ global srcdir
+ load_file $srcdir/lib/$filename
+}
+
+load_lib dg.exp
+load_lib libgloss.exp
+load_gcc_lib target-libpath.exp
+load_gcc_lib wrapper.exp
+
+
+# Define libffi callbacks for dg.exp.
+
+proc libffi-dg-test-1 { target_compile prog do_what extra_tool_flags } {
+
+ # To get all \n in dg-output test strings to match printf output
+ # in a system that outputs it as \015\012 (i.e. not just \012), we
+ # need to change all \n into \r?\n. As there is no dejagnu flag
+ # or hook to do that, we simply change the text being tested.
+ # Unfortunately, we have to know that the variable is called
+ # dg-output-text and lives in the caller of libffi-dg-test, which
+ # is two calls up. Overriding proc dg-output would be longer and
+ # would necessarily have the same assumption.
+ upvar 2 dg-output-text output_match
+
+ if { [llength $output_match] > 1 } {
+ regsub -all "\n" [lindex $output_match 1] "\r?\n" x
+ set output_match [lreplace $output_match 1 1 $x]
+ }
+
+ # Set up the compiler flags, based on what we're going to do.
+
+ set options [list]
+ switch $do_what {
+ "compile" {
+ set compile_type "assembly"
+ set output_file "[file rootname [file tail $prog]].s"
+ }
+ "link" {
+ set compile_type "executable"
+ set output_file "[file rootname [file tail $prog]].exe"
+ # The following line is needed for targets like the i960 where
+ # the default output file is b.out. Sigh.
+ }
+ "run" {
+ set compile_type "executable"
+ # FIXME: "./" is to cope with "." not being in $PATH.
+ # Should this be handled elsewhere?
+ # YES.
+ set output_file "./[file rootname [file tail $prog]].exe"
+ # This is the only place where we care if an executable was
+ # created or not. If it was, dg.exp will try to run it.
+ remote_file build delete $output_file;
+ }
+ default {
+ perror "$do_what: not a valid dg-do keyword"
+ return ""
+ }
+ }
+
+ if { $extra_tool_flags != "" } {
+ lappend options "additional_flags=$extra_tool_flags"
+ }
+
+ set comp_output [libffi_target_compile "$prog" "$output_file" "$compile_type" $options];
+
+
+ return [list $comp_output $output_file]
+}
+
+
+proc libffi-dg-test { prog do_what extra_tool_flags } {
+ return [libffi-dg-test-1 target_compile $prog $do_what $extra_tool_flags]
+}
+
+proc libffi-init { args } {
+ global gluefile wrap_flags;
+ global srcdir
+ global blddirffi
+ global objdir
+ global TOOL_OPTIONS
+ global tool
+ global libffi_include
+ global libffi_link_flags
+ global tool_root_dir
+ global ld_library_path
+
+ global using_gcc
+
+ set blddirffi [pwd]/..
+ verbose "libffi $blddirffi"
+
+ # Are we building with GCC?
+ set tmp [grep ../config.status "GCC='yes'"]
+ if { [string match $tmp "GCC='yes'"] } {
+
+ set using_gcc "yes"
+
+ set gccdir [lookfor_file $tool_root_dir gcc/libgcc.a]
+ if {$gccdir != ""} {
+ set gccdir [file dirname $gccdir]
+ }
+ verbose "gccdir $gccdir"
+
+ set ld_library_path "."
+ append ld_library_path ":${gccdir}"
+
+ set compiler "${gccdir}/xgcc"
+ if { [is_remote host] == 0 && [which $compiler] != 0 } {
+ foreach i "[exec $compiler --print-multi-lib]" {
+ set mldir ""
+ regexp -- "\[a-z0-9=_/\.-\]*;" $i mldir
+ set mldir [string trimright $mldir "\;@"]
+ if { "$mldir" == "." } {
+ continue
+ }
+ if { [llength [glob -nocomplain ${gccdir}/${mldir}/libgcc_s*.so.*]] >= 1 } {
+ append ld_library_path ":${gccdir}/${mldir}"
+ }
+ }
+ }
+
+ } else {
+
+ set using_gcc "no"
+
+ }
+
+ # add the library path for libffi.
+ append ld_library_path ":${blddirffi}/.libs"
+
+ verbose "ld_library_path: $ld_library_path"
+
+ # Point to the Libffi headers in libffi.
+ set libffi_include "${blddirffi}/include"
+ verbose "libffi_include $libffi_include"
+
+ set libffi_dir "${blddirffi}/.libs"
+ verbose "libffi_dir $libffi_dir"
+ if { $libffi_dir != "" } {
+ set libffi_dir [file dirname ${libffi_dir}]
+ set libffi_link_flags "-L${libffi_dir}/.libs"
+ }
+
+ set_ld_library_path_env_vars
+ libffi_maybe_build_wrapper "${objdir}/testglue.o"
+}
+
+proc libffi_exit { } {
+ global gluefile;
+
+ if [info exists gluefile] {
+ file_on_build delete $gluefile;
+ unset gluefile;
+ }
+}
+
+proc libffi_target_compile { source dest type options } {
+ global gluefile wrap_flags;
+ global srcdir
+ global blddirffi
+ global TOOL_OPTIONS
+ global libffi_link_flags
+ global libffi_include
+ global target_triplet
+
+
+ if { [target_info needs_status_wrapper]!="" && [info exists gluefile] } {
+ lappend options "libs=${gluefile}"
+ lappend options "ldflags=$wrap_flags"
+ }
+
+ # TOOL_OPTIONS must come first, so that it doesn't override testcase
+ # specific options.
+ if [info exists TOOL_OPTIONS] {
+ lappend options [concat "additional_flags=$TOOL_OPTIONS" $options];
+ }
+
+ # search for ffi_mips.h in srcdir, too
+ lappend options "additional_flags=-I${libffi_include} -I${srcdir}/../include -I${libffi_include}/.."
+ lappend options "additional_flags=${libffi_link_flags}"
+
+ # Darwin needs a stack execution allowed flag.
+
+ if { [istarget "*-*-darwin9*"] || [istarget "*-*-darwin1*"]
+ || [istarget "*-*-darwin2*"] } {
+ lappend options "additional_flags=-Wl,-allow_stack_execute"
+ }
+
+ # If you're building the compiler with --prefix set to a place
+ # where it's not yet installed, then the linker won't be able to
+ # find the libgcc used by libffi.dylib. We could pass the
+ # -dylib_file option, but that's complicated, and it's much easier
+ # to just make the linker find libgcc using -L options.
+ if { [string match "*-*-darwin*" $target_triplet] } {
+ lappend options "libs= -shared-libgcc"
+ }
+
+ if { [string match "*-*-openbsd*" $target_triplet] } {
+ lappend options "libs= -lpthread"
+ }
+
+ lappend options "libs= -lffi"
+
+ if { [string match "aarch64*-*-linux*" $target_triplet] } {
+ lappend options "libs= -lpthread"
+ }
+
+ if { [string match "*.cc" $source] } {
+ lappend options "c++"
+ }
+
+ verbose "options: $options"
+ return [target_compile $source $dest $type $options]
+}
+
+# Utility routines.
+
+#
+# search_for -- looks for a string match in a file
+#
+proc search_for { file pattern } {
+ set fd [open $file r]
+ while { [gets $fd cur_line]>=0 } {
+ if [string match "*$pattern*" $cur_line] then {
+ close $fd
+ return 1
+ }
+ }
+ close $fd
+ return 0
+}
+
+# Modified dg-runtest that can cycle through a list of optimization options
+# as c-torture does.
+proc libffi-dg-runtest { testcases default-extra-flags } {
+ global runtests
+
+ foreach test $testcases {
+ # If we're only testing specific files and this isn't one of
+ # them, skip it.
+ if ![runtest_file_p $runtests $test] {
+ continue
+ }
+
+ # Look for a loop within the source code - if we don't find one,
+ # don't pass -funroll[-all]-loops.
+ global torture_with_loops torture_without_loops
+ if [expr [search_for $test "for*("]+[search_for $test "while*("]] {
+ set option_list $torture_with_loops
+ } else {
+ set option_list $torture_without_loops
+ }
+
+ set nshort [file tail [file dirname $test]]/[file tail $test]
+
+ foreach flags $option_list {
+ verbose "Testing $nshort, $flags" 1
+ dg-test $test $flags ${default-extra-flags}
+ }
+ }
+}
+
+proc run-many-tests { testcases extra_flags } {
+ global using_gcc
+ if { [string match $using_gcc "yes"] } {
+ set common "-W -Wall -Wno-psabi"
+ set optimizations { "-O0" "-O2" "-O3" "-Os" "-O2 -fomit-frame-pointer" }
+ } else {
+ # Assume we are using the vendor compiler.
+ set common ""
+ set optimizations { "" }
+ }
+
+ set targetabis { "" }
+ if [string match $using_gcc "yes"] {
+ if [istarget "i?86-*-*"] {
+ set targetabis {
+ ""
+ "-DABI_NUM=FFI_STDCALL -DABI_ATTR=__STDCALL__"
+ "-DABI_NUM=FFI_THISCALL -DABI_ATTR=__THISCALL__"
+ "-DABI_NUM=FFI_FASTCALL -DABI_ATTR=__FASTCALL__"
+ }
+ }
+ }
+
+ set common [ concat $common $extra_flags ]
+ foreach test $testcases {
+ set testname [file tail $test]
+ if [search_for $test "ABI_NUM"] {
+ set abis $targetabis
+ } else {
+ set abis { "" }
+ }
+ foreach opt $optimizations {
+ foreach abi $abis {
+ set options [concat $common $opt $abi]
+ verbose "Testing $testname, $options" 1
+ dg-test $test $options ""
+ }
+ }
+ }
+}
+
+# Like check_conditional_xfail, but callable from a dg test.
+
+proc dg-xfail-if { args } {
+ set args [lreplace $args 0 0]
+ set selector "target [join [lindex $args 1]]"
+ if { [dg-process-target $selector] == "S" } {
+ global compiler_conditional_xfail_data
+ set compiler_conditional_xfail_data $args
+ }
+}
+
+proc check-flags { args } {
+
+ # The args are within another list; pull them out.
+ set args [lindex $args 0]
+
+ # The next two arguments are optional. If they were not specified,
+ # use the defaults.
+ if { [llength $args] == 2 } {
+ lappend $args [list "*"]
+ }
+ if { [llength $args] == 3 } {
+ lappend $args [list ""]
+ }
+
+ # If the option strings are the defaults, or the same as the
+ # defaults, there is no need to call check_conditional_xfail to
+ # compare them to the actual options.
+ if { [string compare [lindex $args 2] "*"] == 0
+ && [string compare [lindex $args 3] "" ] == 0 } {
+ set result 1
+ } else {
+ # The target list might be an effective-target keyword, so replace
+ # the original list with "*-*-*", since we already know it matches.
+ set result [check_conditional_xfail [lreplace $args 1 1 "*-*-*"]]
+ }
+
+ return $result
+}
+
+proc dg-skip-if { args } {
+ # Verify the number of arguments. The last two are optional.
+ set args [lreplace $args 0 0]
+ if { [llength $args] < 2 || [llength $args] > 4 } {
+ error "dg-skip-if 2: need 2, 3, or 4 arguments"
+ }
+
+ # Don't bother if we're already skipping the test.
+ upvar dg-do-what dg-do-what
+ if { [lindex ${dg-do-what} 1] == "N" } {
+ return
+ }
+
+ set selector [list target [lindex $args 1]]
+ if { [dg-process-target $selector] == "S" } {
+ if [check-flags $args] {
+ upvar dg-do-what dg-do-what
+ set dg-do-what [list [lindex ${dg-do-what} 0] "N" "P"]
+ }
+ }
+}
+
+# We need to make sure that additional_files and additional_sources
+# are both cleared out after every test. It is not enough to clear
+# them out *before* the next test run because gcc-target-compile gets
+# run directly from some .exp files (outside of any test). (Those
+# uses should eventually be eliminated.)
+
+# Because the DG framework doesn't provide a hook that is run at the
+# end of a test, we must replace dg-test with a wrapper.
+
+if { [info procs saved-dg-test] == [list] } {
+ rename dg-test saved-dg-test
+
+ proc dg-test { args } {
+ global additional_files
+ global additional_sources
+ global errorInfo
+
+ if { [ catch { eval saved-dg-test $args } errmsg ] } {
+ set saved_info $errorInfo
+ set additional_files ""
+ set additional_sources ""
+ error $errmsg $saved_info
+ }
+ set additional_files ""
+ set additional_sources ""
+ }
+}
+
+# Local Variables:
+# tcl-indent-level:4
+# End:
diff --git a/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/lib/target-libpath.exp b/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/lib/target-libpath.exp
new file mode 100644
index 0000000..6b7beba
--- /dev/null
+++ b/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/lib/target-libpath.exp
@@ -0,0 +1,283 @@
+# Copyright (C) 2004, 2005, 2007 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 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 GCC; see the file COPYING3. If not see
+# <http://www.gnu.org/licenses/>.
+
+# This file was contributed by John David Anglin (dave.anglin@nrc-cnrc.gc.ca)
+
+set orig_environment_saved 0
+set orig_ld_library_path_saved 0
+set orig_ld_run_path_saved 0
+set orig_shlib_path_saved 0
+set orig_ld_libraryn32_path_saved 0
+set orig_ld_library64_path_saved 0
+set orig_ld_library_path_32_saved 0
+set orig_ld_library_path_64_saved 0
+set orig_dyld_library_path_saved 0
+set orig_path_saved 0
+
+#######################################
+# proc set_ld_library_path_env_vars { }
+#######################################
+
+proc set_ld_library_path_env_vars { } {
+ global ld_library_path
+ global orig_environment_saved
+ global orig_ld_library_path_saved
+ global orig_ld_run_path_saved
+ global orig_shlib_path_saved
+ global orig_ld_libraryn32_path_saved
+ global orig_ld_library64_path_saved
+ global orig_ld_library_path_32_saved
+ global orig_ld_library_path_64_saved
+ global orig_dyld_library_path_saved
+ global orig_path_saved
+ global orig_ld_library_path
+ global orig_ld_run_path
+ global orig_shlib_path
+ global orig_ld_libraryn32_path
+ global orig_ld_library64_path
+ global orig_ld_library_path_32
+ global orig_ld_library_path_64
+ global orig_dyld_library_path
+ global orig_path
+ global GCC_EXEC_PREFIX
+
+ # Set the relocated compiler prefix, but only if the user hasn't specified one.
+ if { [info exists GCC_EXEC_PREFIX] && ![info exists env(GCC_EXEC_PREFIX)] } {
+ setenv GCC_EXEC_PREFIX "$GCC_EXEC_PREFIX"
+ }
+
+ # Setting the ld library path causes trouble when testing cross-compilers.
+ if { [is_remote target] } {
+ return
+ }
+
+ if { $orig_environment_saved == 0 } {
+ global env
+
+ set orig_environment_saved 1
+
+ # Save the original environment.
+ if [info exists env(LD_LIBRARY_PATH)] {
+ set orig_ld_library_path "$env(LD_LIBRARY_PATH)"
+ set orig_ld_library_path_saved 1
+ }
+ if [info exists env(LD_RUN_PATH)] {
+ set orig_ld_run_path "$env(LD_RUN_PATH)"
+ set orig_ld_run_path_saved 1
+ }
+ if [info exists env(SHLIB_PATH)] {
+ set orig_shlib_path "$env(SHLIB_PATH)"
+ set orig_shlib_path_saved 1
+ }
+ if [info exists env(LD_LIBRARYN32_PATH)] {
+ set orig_ld_libraryn32_path "$env(LD_LIBRARYN32_PATH)"
+ set orig_ld_libraryn32_path_saved 1
+ }
+ if [info exists env(LD_LIBRARY64_PATH)] {
+ set orig_ld_library64_path "$env(LD_LIBRARY64_PATH)"
+ set orig_ld_library64_path_saved 1
+ }
+ if [info exists env(LD_LIBRARY_PATH_32)] {
+ set orig_ld_library_path_32 "$env(LD_LIBRARY_PATH_32)"
+ set orig_ld_library_path_32_saved 1
+ }
+ if [info exists env(LD_LIBRARY_PATH_64)] {
+ set orig_ld_library_path_64 "$env(LD_LIBRARY_PATH_64)"
+ set orig_ld_library_path_64_saved 1
+ }
+ if [info exists env(DYLD_LIBRARY_PATH)] {
+ set orig_dyld_library_path "$env(DYLD_LIBRARY_PATH)"
+ set orig_dyld_library_path_saved 1
+ }
+ if [info exists env(PATH)] {
+ set orig_path "$env(PATH)"
+ set orig_path_saved 1
+ }
+ }
+
+ # We need to set ld library path in the environment. Currently,
+ # unix.exp doesn't set the environment correctly for all systems.
+ # It only sets SHLIB_PATH and LD_LIBRARY_PATH when it executes a
+ # program. We also need the environment set for compilations, etc.
+ #
+ # On IRIX 6, we have to set variables akin to LD_LIBRARY_PATH, but
+ # called LD_LIBRARYN32_PATH (for the N32 ABI) and LD_LIBRARY64_PATH
+ # (for the 64-bit ABI). The same applies to Darwin (DYLD_LIBRARY_PATH),
+ # Solaris 32 bit (LD_LIBRARY_PATH_32), Solaris 64 bit (LD_LIBRARY_PATH_64),
+ # and HP-UX (SHLIB_PATH). In some cases, the variables are independent
+ # of LD_LIBRARY_PATH, and in other cases LD_LIBRARY_PATH is used if the
+ # variable is not defined.
+ #
+ # Doing this is somewhat of a hack as ld_library_path gets repeated in
+ # SHLIB_PATH and LD_LIBRARY_PATH when unix_load sets these variables.
+ if { $orig_ld_library_path_saved } {
+ setenv LD_LIBRARY_PATH "$ld_library_path:$orig_ld_library_path"
+ } else {
+ setenv LD_LIBRARY_PATH "$ld_library_path"
+ }
+ if { $orig_ld_run_path_saved } {
+ setenv LD_RUN_PATH "$ld_library_path:$orig_ld_run_path"
+ } else {
+ setenv LD_RUN_PATH "$ld_library_path"
+ }
+ # The default shared library dynamic path search for 64-bit
+ # HP-UX executables searches LD_LIBRARY_PATH before SHLIB_PATH.
+ # LD_LIBRARY_PATH isn't used for 32-bit executables. Thus, we
+ # set LD_LIBRARY_PATH and SHLIB_PATH as if they were independent.
+ if { $orig_shlib_path_saved } {
+ setenv SHLIB_PATH "$ld_library_path:$orig_shlib_path"
+ } else {
+ setenv SHLIB_PATH "$ld_library_path"
+ }
+ if { $orig_ld_libraryn32_path_saved } {
+ setenv LD_LIBRARYN32_PATH "$ld_library_path:$orig_ld_libraryn32_path"
+ } elseif { $orig_ld_library_path_saved } {
+ setenv LD_LIBRARYN32_PATH "$ld_library_path:$orig_ld_library_path"
+ } else {
+ setenv LD_LIBRARYN32_PATH "$ld_library_path"
+ }
+ if { $orig_ld_library64_path_saved } {
+ setenv LD_LIBRARY64_PATH "$ld_library_path:$orig_ld_library64_path"
+ } elseif { $orig_ld_library_path_saved } {
+ setenv LD_LIBRARY64_PATH "$ld_library_path:$orig_ld_library_path"
+ } else {
+ setenv LD_LIBRARY64_PATH "$ld_library_path"
+ }
+ if { $orig_ld_library_path_32_saved } {
+ setenv LD_LIBRARY_PATH_32 "$ld_library_path:$orig_ld_library_path_32"
+ } elseif { $orig_ld_library_path_saved } {
+ setenv LD_LIBRARY_PATH_32 "$ld_library_path:$orig_ld_library_path"
+ } else {
+ setenv LD_LIBRARY_PATH_32 "$ld_library_path"
+ }
+ if { $orig_ld_library_path_64_saved } {
+ setenv LD_LIBRARY_PATH_64 "$ld_library_path:$orig_ld_library_path_64"
+ } elseif { $orig_ld_library_path_saved } {
+ setenv LD_LIBRARY_PATH_64 "$ld_library_path:$orig_ld_library_path"
+ } else {
+ setenv LD_LIBRARY_PATH_64 "$ld_library_path"
+ }
+ if { $orig_dyld_library_path_saved } {
+ setenv DYLD_LIBRARY_PATH "$ld_library_path:$orig_dyld_library_path"
+ } else {
+ setenv DYLD_LIBRARY_PATH "$ld_library_path"
+ }
+ if { [istarget *-*-cygwin*] || [istarget *-*-mingw*] } {
+ if { $orig_path_saved } {
+ setenv PATH "$ld_library_path:$orig_path"
+ } else {
+ setenv PATH "$ld_library_path"
+ }
+ }
+
+ verbose -log "set_ld_library_path_env_vars: ld_library_path=$ld_library_path"
+}
+
+#######################################
+# proc restore_ld_library_path_env_vars { }
+#######################################
+
+proc restore_ld_library_path_env_vars { } {
+ global orig_environment_saved
+ global orig_ld_library_path_saved
+ global orig_ld_run_path_saved
+ global orig_shlib_path_saved
+ global orig_ld_libraryn32_path_saved
+ global orig_ld_library64_path_saved
+ global orig_ld_library_path_32_saved
+ global orig_ld_library_path_64_saved
+ global orig_dyld_library_path_saved
+ global orig_path_saved
+ global orig_ld_library_path
+ global orig_ld_run_path
+ global orig_shlib_path
+ global orig_ld_libraryn32_path
+ global orig_ld_library64_path
+ global orig_ld_library_path_32
+ global orig_ld_library_path_64
+ global orig_dyld_library_path
+ global orig_path
+
+ if { $orig_environment_saved == 0 } {
+ return
+ }
+
+ if { $orig_ld_library_path_saved } {
+ setenv LD_LIBRARY_PATH "$orig_ld_library_path"
+ } elseif [info exists env(LD_LIBRARY_PATH)] {
+ unsetenv LD_LIBRARY_PATH
+ }
+ if { $orig_ld_run_path_saved } {
+ setenv LD_RUN_PATH "$orig_ld_run_path"
+ } elseif [info exists env(LD_RUN_PATH)] {
+ unsetenv LD_RUN_PATH
+ }
+ if { $orig_shlib_path_saved } {
+ setenv SHLIB_PATH "$orig_shlib_path"
+ } elseif [info exists env(SHLIB_PATH)] {
+ unsetenv SHLIB_PATH
+ }
+ if { $orig_ld_libraryn32_path_saved } {
+ setenv LD_LIBRARYN32_PATH "$orig_ld_libraryn32_path"
+ } elseif [info exists env(LD_LIBRARYN32_PATH)] {
+ unsetenv LD_LIBRARYN32_PATH
+ }
+ if { $orig_ld_library64_path_saved } {
+ setenv LD_LIBRARY64_PATH "$orig_ld_library64_path"
+ } elseif [info exists env(LD_LIBRARY64_PATH)] {
+ unsetenv LD_LIBRARY64_PATH
+ }
+ if { $orig_ld_library_path_32_saved } {
+ setenv LD_LIBRARY_PATH_32 "$orig_ld_library_path_32"
+ } elseif [info exists env(LD_LIBRARY_PATH_32)] {
+ unsetenv LD_LIBRARY_PATH_32
+ }
+ if { $orig_ld_library_path_64_saved } {
+ setenv LD_LIBRARY_PATH_64 "$orig_ld_library_path_64"
+ } elseif [info exists env(LD_LIBRARY_PATH_64)] {
+ unsetenv LD_LIBRARY_PATH_64
+ }
+ if { $orig_dyld_library_path_saved } {
+ setenv DYLD_LIBRARY_PATH "$orig_dyld_library_path"
+ } elseif [info exists env(DYLD_LIBRARY_PATH)] {
+ unsetenv DYLD_LIBRARY_PATH
+ }
+ if { $orig_path_saved } {
+ setenv PATH "$orig_path"
+ } elseif [info exists env(PATH)] {
+ unsetenv PATH
+ }
+}
+
+#######################################
+# proc get_shlib_extension { }
+#######################################
+
+proc get_shlib_extension { } {
+ global shlib_ext
+
+ if { [ istarget *-*-darwin* ] } {
+ set shlib_ext "dylib"
+ } elseif { [ istarget *-*-cygwin* ] || [ istarget *-*-mingw* ] } {
+ set shlib_ext "dll"
+ } elseif { [ istarget hppa*-*-hpux* ] } {
+ set shlib_ext "sl"
+ } else {
+ set shlib_ext "so"
+ }
+ return $shlib_ext
+}
+
diff --git a/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/lib/wrapper.exp b/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/lib/wrapper.exp
new file mode 100644
index 0000000..4e5ae43
--- /dev/null
+++ b/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/lib/wrapper.exp
@@ -0,0 +1,45 @@
+# Copyright (C) 2004, 2007 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 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 GCC; see the file COPYING3. If not see
+# <http://www.gnu.org/licenses/>.
+
+# This file contains GCC-specifics for status wrappers for test programs.
+
+# ${tool}_maybe_build_wrapper -- Build wrapper object if the target
+# needs it. FILENAME is the path to the wrapper file. If there are
+# additional arguments, they are command-line options to provide to
+# the compiler when compiling FILENAME.
+
+proc ${tool}_maybe_build_wrapper { filename args } {
+ global gluefile wrap_flags
+
+ if { [target_info needs_status_wrapper] != "" \
+ && [target_info needs_status_wrapper] != "0" \
+ && ![info exists gluefile] } {
+ set saved_wrap_compile_flags [target_info wrap_compile_flags]
+ set flags [join $args " "]
+ # The wrapper code may contain code that gcc objects on. This
+ # became true for dejagnu-1.4.4. The set of warnings and code
+ # that gcc objects on may change, so just make sure -w is always
+ # passed to turn off all warnings.
+ set_currtarget_info wrap_compile_flags \
+ "$saved_wrap_compile_flags -w $flags"
+ set result [build_wrapper $filename]
+ set_currtarget_info wrap_compile_flags "$saved_wrap_compile_flags"
+ if { $result != "" } {
+ set gluefile [lindex $result 0]
+ set wrap_flags [lindex $result 1]
+ }
+ }
+}
diff --git a/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/call.exp b/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/call.exp
new file mode 100644
index 0000000..5177f07
--- /dev/null
+++ b/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/call.exp
@@ -0,0 +1,43 @@
+# Copyright (C) 2003, 2006, 2009, 2010, 2014 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 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; see the file COPYING3. If not see
+# <http://www.gnu.org/licenses/>.
+
+dg-init
+libffi-init
+
+global srcdir subdir
+
+set tlist [lsearch -inline -all -not -glob [lsort [glob -nocomplain -- $srcdir/$subdir/*.{c,cc}]] *complex*]
+set ctlist [lsearch -inline -all -glob [lsort [glob -nocomplain -- $srcdir/$subdir/*.{c,cc}]] *complex*]
+
+run-many-tests $tlist ""
+
+if { ![istarget s390*] } {
+
+ foreach test $ctlist {
+ unsupported "$test"
+ }
+
+} else {
+
+ run-many-tests $ctlist ""
+
+}
+
+dg-finish
+
+# Local Variables:
+# tcl-indent-level:4
+# End:
diff --git a/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/closure_fn0.c b/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/closure_fn0.c
new file mode 100644
index 0000000..a579ff6
--- /dev/null
+++ b/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/closure_fn0.c
@@ -0,0 +1,89 @@
+/* Area: closure_call
+ Purpose: Check multiple values passing from different type.
+ Also, exceed the limit of gpr and fpr registers on PowerPC
+ Darwin.
+ Limitations: none.
+ PR: none.
+ Originator: <andreast@gcc.gnu.org> 20030828 */
+
+
+
+
+/* { dg-do run } */
+#include "ffitest.h"
+
+static void
+closure_test_fn0(ffi_cif* cif __UNUSED__, void* resp, void** args,
+ void* userdata)
+{
+ *(ffi_arg*)resp =
+ (int)*(unsigned long long *)args[0] + (int)(*(int *)args[1]) +
+ (int)(*(unsigned long long *)args[2]) + (int)*(int *)args[3] +
+ (int)(*(signed short *)args[4]) +
+ (int)(*(unsigned long long *)args[5]) +
+ (int)*(int *)args[6] + (int)(*(int *)args[7]) +
+ (int)(*(double *)args[8]) + (int)*(int *)args[9] +
+ (int)(*(int *)args[10]) + (int)(*(float *)args[11]) +
+ (int)*(int *)args[12] + (int)(*(int *)args[13]) +
+ (int)(*(int *)args[14]) + *(int *)args[15] + (intptr_t)userdata;
+
+ printf("%d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d: %d\n",
+ (int)*(unsigned long long *)args[0], (int)(*(int *)args[1]),
+ (int)(*(unsigned long long *)args[2]),
+ (int)*(int *)args[3], (int)(*(signed short *)args[4]),
+ (int)(*(unsigned long long *)args[5]),
+ (int)*(int *)args[6], (int)(*(int *)args[7]),
+ (int)(*(double *)args[8]), (int)*(int *)args[9],
+ (int)(*(int *)args[10]), (int)(*(float *)args[11]),
+ (int)*(int *)args[12], (int)(*(int *)args[13]),
+ (int)(*(int *)args[14]),*(int *)args[15],
+ (int)(intptr_t)userdata, (int)*(ffi_arg *)resp);
+
+}
+
+typedef int (*closure_test_type0)(unsigned long long, int, unsigned long long,
+ int, signed short, unsigned long long, int,
+ int, double, int, int, float, int, int,
+ int, int);
+
+int main (void)
+{
+ ffi_cif cif;
+ void * code;
+ ffi_closure *pcl = ffi_closure_alloc(sizeof(ffi_closure), &code);
+ ffi_type * cl_arg_types[17];
+ int res;
+
+ cl_arg_types[0] = &ffi_type_uint64;
+ cl_arg_types[1] = &ffi_type_sint;
+ cl_arg_types[2] = &ffi_type_uint64;
+ cl_arg_types[3] = &ffi_type_sint;
+ cl_arg_types[4] = &ffi_type_sshort;
+ cl_arg_types[5] = &ffi_type_uint64;
+ cl_arg_types[6] = &ffi_type_sint;
+ cl_arg_types[7] = &ffi_type_sint;
+ cl_arg_types[8] = &ffi_type_double;
+ cl_arg_types[9] = &ffi_type_sint;
+ cl_arg_types[10] = &ffi_type_sint;
+ cl_arg_types[11] = &ffi_type_float;
+ cl_arg_types[12] = &ffi_type_sint;
+ cl_arg_types[13] = &ffi_type_sint;
+ cl_arg_types[14] = &ffi_type_sint;
+ cl_arg_types[15] = &ffi_type_sint;
+ cl_arg_types[16] = NULL;
+
+ /* Initialize the cif */
+ CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 16,
+ &ffi_type_sint, cl_arg_types) == FFI_OK);
+
+ CHECK(ffi_prep_closure_loc(pcl, &cif, closure_test_fn0,
+ (void *) 3 /* userdata */, code) == FFI_OK);
+
+ res = (*((closure_test_type0)code))
+ (1LL, 2, 3LL, 4, 127, 429LL, 7, 8, 9.5, 10, 11, 12, 13,
+ 19, 21, 1);
+ /* { dg-output "1 2 3 4 127 429 7 8 9 10 11 12 13 19 21 1 3: 680" } */
+ printf("res: %d\n",res);
+ /* { dg-output "\nres: 680" } */
+ exit(0);
+}
diff --git a/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/closure_fn1.c b/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/closure_fn1.c
new file mode 100644
index 0000000..9123173
--- /dev/null
+++ b/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/closure_fn1.c
@@ -0,0 +1,81 @@
+/* Area: closure_call.
+ Purpose: Check multiple values passing from different type.
+ Also, exceed the limit of gpr and fpr registers on PowerPC
+ Darwin.
+ Limitations: none.
+ PR: none.
+ Originator: <andreast@gcc.gnu.org> 20030828 */
+
+/* { dg-do run } */
+#include "ffitest.h"
+
+
+static void closure_test_fn1(ffi_cif* cif __UNUSED__, void* resp, void** args,
+ void* userdata)
+{
+ *(ffi_arg*)resp =
+ (int)*(float *)args[0] +(int)(*(float *)args[1]) +
+ (int)(*(float *)args[2]) + (int)*(float *)args[3] +
+ (int)(*(signed short *)args[4]) + (int)(*(float *)args[5]) +
+ (int)*(float *)args[6] + (int)(*(int *)args[7]) +
+ (int)(*(double*)args[8]) + (int)*(int *)args[9] +
+ (int)(*(int *)args[10]) + (int)(*(float *)args[11]) +
+ (int)*(int *)args[12] + (int)(*(int *)args[13]) +
+ (int)(*(int *)args[14]) + *(int *)args[15] + (intptr_t)userdata;
+
+ printf("%d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d: %d\n",
+ (int)*(float *)args[0], (int)(*(float *)args[1]),
+ (int)(*(float *)args[2]), (int)*(float *)args[3],
+ (int)(*(signed short *)args[4]), (int)(*(float *)args[5]),
+ (int)*(float *)args[6], (int)(*(int *)args[7]),
+ (int)(*(double *)args[8]), (int)*(int *)args[9],
+ (int)(*(int *)args[10]), (int)(*(float *)args[11]),
+ (int)*(int *)args[12], (int)(*(int *)args[13]),
+ (int)(*(int *)args[14]), *(int *)args[15],
+ (int)(intptr_t)userdata, (int)*(ffi_arg *)resp);
+}
+
+typedef int (*closure_test_type1)(float, float, float, float, signed short,
+ float, float, int, double, int, int, float,
+ int, int, int, int);
+int main (void)
+{
+ ffi_cif cif;
+ void *code;
+ ffi_closure *pcl = ffi_closure_alloc(sizeof(ffi_closure), &code);
+ ffi_type * cl_arg_types[17];
+ int res;
+
+ cl_arg_types[0] = &ffi_type_float;
+ cl_arg_types[1] = &ffi_type_float;
+ cl_arg_types[2] = &ffi_type_float;
+ cl_arg_types[3] = &ffi_type_float;
+ cl_arg_types[4] = &ffi_type_sshort;
+ cl_arg_types[5] = &ffi_type_float;
+ cl_arg_types[6] = &ffi_type_float;
+ cl_arg_types[7] = &ffi_type_sint;
+ cl_arg_types[8] = &ffi_type_double;
+ cl_arg_types[9] = &ffi_type_sint;
+ cl_arg_types[10] = &ffi_type_sint;
+ cl_arg_types[11] = &ffi_type_float;
+ cl_arg_types[12] = &ffi_type_sint;
+ cl_arg_types[13] = &ffi_type_sint;
+ cl_arg_types[14] = &ffi_type_sint;
+ cl_arg_types[15] = &ffi_type_sint;
+ cl_arg_types[16] = NULL;
+
+ /* Initialize the cif */
+ CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 16,
+ &ffi_type_sint, cl_arg_types) == FFI_OK);
+
+ CHECK(ffi_prep_closure_loc(pcl, &cif, closure_test_fn1,
+ (void *) 3 /* userdata */, code) == FFI_OK);
+
+ res = (*((closure_test_type1)code))
+ (1.1, 2.2, 3.3, 4.4, 127, 5.5, 6.6, 8, 9, 10, 11, 12.0, 13,
+ 19, 21, 1);
+ /* { dg-output "1 2 3 4 127 5 6 8 9 10 11 12 13 19 21 1 3: 255" } */
+ printf("res: %d\n",res);
+ /* { dg-output "\nres: 255" } */
+ exit(0);
+}
diff --git a/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/closure_fn2.c b/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/closure_fn2.c
new file mode 100644
index 0000000..08ff9d9
--- /dev/null
+++ b/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/closure_fn2.c
@@ -0,0 +1,81 @@
+/* Area: closure_call
+ Purpose: Check multiple values passing from different type.
+ Also, exceed the limit of gpr and fpr registers on PowerPC
+ Darwin.
+ Limitations: none.
+ PR: none.
+ Originator: <andreast@gcc.gnu.org> 20030828 */
+
+/* { dg-do run } */
+#include "ffitest.h"
+
+static void closure_test_fn2(ffi_cif* cif __UNUSED__, void* resp, void** args,
+ void* userdata)
+{
+ *(ffi_arg*)resp =
+ (int)*(double *)args[0] +(int)(*(double *)args[1]) +
+ (int)(*(double *)args[2]) + (int)*(double *)args[3] +
+ (int)(*(signed short *)args[4]) + (int)(*(double *)args[5]) +
+ (int)*(double *)args[6] + (int)(*(int *)args[7]) +
+ (int)(*(double *)args[8]) + (int)*(int *)args[9] +
+ (int)(*(int *)args[10]) + (int)(*(float *)args[11]) +
+ (int)*(int *)args[12] + (int)(*(float *)args[13]) +
+ (int)(*(int *)args[14]) + *(int *)args[15] + (intptr_t)userdata;
+
+ printf("%d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d: %d\n",
+ (int)*(double *)args[0], (int)(*(double *)args[1]),
+ (int)(*(double *)args[2]), (int)*(double *)args[3],
+ (int)(*(signed short *)args[4]), (int)(*(double *)args[5]),
+ (int)*(double *)args[6], (int)(*(int *)args[7]),
+ (int)(*(double*)args[8]), (int)*(int *)args[9],
+ (int)(*(int *)args[10]), (int)(*(float *)args[11]),
+ (int)*(int *)args[12], (int)(*(float *)args[13]),
+ (int)(*(int *)args[14]), *(int *)args[15], (int)(intptr_t)userdata,
+ (int)*(ffi_arg *)resp);
+}
+
+typedef int (*closure_test_type2)(double, double, double, double, signed short,
+ double, double, int, double, int, int, float,
+ int, float, int, int);
+
+int main (void)
+{
+ ffi_cif cif;
+ void *code;
+ ffi_closure *pcl = ffi_closure_alloc(sizeof(ffi_closure), &code);
+ ffi_type * cl_arg_types[17];
+ int res;
+
+ cl_arg_types[0] = &ffi_type_double;
+ cl_arg_types[1] = &ffi_type_double;
+ cl_arg_types[2] = &ffi_type_double;
+ cl_arg_types[3] = &ffi_type_double;
+ cl_arg_types[4] = &ffi_type_sshort;
+ cl_arg_types[5] = &ffi_type_double;
+ cl_arg_types[6] = &ffi_type_double;
+ cl_arg_types[7] = &ffi_type_sint;
+ cl_arg_types[8] = &ffi_type_double;
+ cl_arg_types[9] = &ffi_type_sint;
+ cl_arg_types[10] = &ffi_type_sint;
+ cl_arg_types[11] = &ffi_type_float;
+ cl_arg_types[12] = &ffi_type_sint;
+ cl_arg_types[13] = &ffi_type_float;
+ cl_arg_types[14] = &ffi_type_sint;
+ cl_arg_types[15] = &ffi_type_sint;
+ cl_arg_types[16] = NULL;
+
+ /* Initialize the cif */
+ CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 16,
+ &ffi_type_sint, cl_arg_types) == FFI_OK);
+
+ CHECK(ffi_prep_closure_loc(pcl, &cif, closure_test_fn2,
+ (void *) 3 /* userdata */, code) == FFI_OK);
+
+ res = (*((closure_test_type2)code))
+ (1, 2, 3, 4, 127, 5, 6, 8, 9, 10, 11, 12.0, 13,
+ 19.0, 21, 1);
+ /* { dg-output "1 2 3 4 127 5 6 8 9 10 11 12 13 19 21 1 3: 255" } */
+ printf("res: %d\n",res);
+ /* { dg-output "\nres: 255" } */
+ exit(0);
+}
diff --git a/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/closure_fn3.c b/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/closure_fn3.c
new file mode 100644
index 0000000..9b54d80
--- /dev/null
+++ b/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/closure_fn3.c
@@ -0,0 +1,82 @@
+/* Area: closure_call
+ Purpose: Check multiple values passing from different type.
+ Also, exceed the limit of gpr and fpr registers on PowerPC
+ Darwin.
+ Limitations: none.
+ PR: none.
+ Originator: <andreast@gcc.gnu.org> 20030828 */
+
+/* { dg-do run } */
+#include "ffitest.h"
+
+static void closure_test_fn3(ffi_cif* cif __UNUSED__, void* resp, void** args,
+ void* userdata)
+ {
+ *(ffi_arg*)resp =
+ (int)*(float *)args[0] +(int)(*(float *)args[1]) +
+ (int)(*(float *)args[2]) + (int)*(float *)args[3] +
+ (int)(*(float *)args[4]) + (int)(*(float *)args[5]) +
+ (int)*(float *)args[6] + (int)(*(float *)args[7]) +
+ (int)(*(double *)args[8]) + (int)*(int *)args[9] +
+ (int)(*(float *)args[10]) + (int)(*(float *)args[11]) +
+ (int)*(int *)args[12] + (int)(*(float *)args[13]) +
+ (int)(*(float *)args[14]) + *(int *)args[15] + (intptr_t)userdata;
+
+ printf("%d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d: %d\n",
+ (int)*(float *)args[0], (int)(*(float *)args[1]),
+ (int)(*(float *)args[2]), (int)*(float *)args[3],
+ (int)(*(float *)args[4]), (int)(*(float *)args[5]),
+ (int)*(float *)args[6], (int)(*(float *)args[7]),
+ (int)(*(double *)args[8]), (int)*(int *)args[9],
+ (int)(*(float *)args[10]), (int)(*(float *)args[11]),
+ (int)*(int *)args[12], (int)(*(float *)args[13]),
+ (int)(*(float *)args[14]), *(int *)args[15], (int)(intptr_t)userdata,
+ (int)*(ffi_arg *)resp);
+
+ }
+
+typedef int (*closure_test_type3)(float, float, float, float, float, float,
+ float, float, double, int, float, float, int,
+ float, float, int);
+
+int main (void)
+{
+ ffi_cif cif;
+ void *code;
+ ffi_closure *pcl = ffi_closure_alloc(sizeof(ffi_closure), &code);
+ ffi_type * cl_arg_types[17];
+ int res;
+
+ cl_arg_types[0] = &ffi_type_float;
+ cl_arg_types[1] = &ffi_type_float;
+ cl_arg_types[2] = &ffi_type_float;
+ cl_arg_types[3] = &ffi_type_float;
+ cl_arg_types[4] = &ffi_type_float;
+ cl_arg_types[5] = &ffi_type_float;
+ cl_arg_types[6] = &ffi_type_float;
+ cl_arg_types[7] = &ffi_type_float;
+ cl_arg_types[8] = &ffi_type_double;
+ cl_arg_types[9] = &ffi_type_sint;
+ cl_arg_types[10] = &ffi_type_float;
+ cl_arg_types[11] = &ffi_type_float;
+ cl_arg_types[12] = &ffi_type_sint;
+ cl_arg_types[13] = &ffi_type_float;
+ cl_arg_types[14] = &ffi_type_float;
+ cl_arg_types[15] = &ffi_type_sint;
+ cl_arg_types[16] = NULL;
+
+ /* Initialize the cif */
+ CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 16,
+ &ffi_type_sint, cl_arg_types) == FFI_OK);
+
+ CHECK(ffi_prep_closure_loc(pcl, &cif, closure_test_fn3,
+ (void *) 3 /* userdata */, code) == FFI_OK);
+
+ res = (*((closure_test_type3)code))
+ (1.1, 2.2, 3.3, 4.4, 5.5, 6.6, 7.7, 8.8, 9, 10, 11.11, 12.0, 13,
+ 19.19, 21.21, 1);
+ /* { dg-output "1 2 3 4 5 6 7 8 9 10 11 12 13 19 21 1 3: 135" } */
+ printf("res: %d\n",res);
+ /* { dg-output "\nres: 135" } */
+ exit(0);
+}
diff --git a/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/closure_fn4.c b/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/closure_fn4.c
new file mode 100644
index 0000000..d4a1530
--- /dev/null
+++ b/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/closure_fn4.c
@@ -0,0 +1,89 @@
+/* Area: closure_call
+ Purpose: Check multiple long long values passing.
+ Also, exceed the limit of gpr and fpr registers on PowerPC
+ Darwin.
+ Limitations: none.
+ PR: none.
+ Originator: <andreast@gcc.gnu.org> 20031026 */
+
+/* { dg-do run } */
+
+#include "ffitest.h"
+
+static void
+closure_test_fn0(ffi_cif* cif __UNUSED__, void* resp, void** args,
+ void* userdata)
+{
+ *(ffi_arg*)resp =
+ (int)*(unsigned long long *)args[0] + (int)*(unsigned long long *)args[1] +
+ (int)*(unsigned long long *)args[2] + (int)*(unsigned long long *)args[3] +
+ (int)*(unsigned long long *)args[4] + (int)*(unsigned long long *)args[5] +
+ (int)*(unsigned long long *)args[6] + (int)*(unsigned long long *)args[7] +
+ (int)*(unsigned long long *)args[8] + (int)*(unsigned long long *)args[9] +
+ (int)*(unsigned long long *)args[10] +
+ (int)*(unsigned long long *)args[11] +
+ (int)*(unsigned long long *)args[12] +
+ (int)*(unsigned long long *)args[13] +
+ (int)*(unsigned long long *)args[14] +
+ *(int *)args[15] + (intptr_t)userdata;
+
+ printf("%d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d: %d\n",
+ (int)*(unsigned long long *)args[0],
+ (int)*(unsigned long long *)args[1],
+ (int)*(unsigned long long *)args[2],
+ (int)*(unsigned long long *)args[3],
+ (int)*(unsigned long long *)args[4],
+ (int)*(unsigned long long *)args[5],
+ (int)*(unsigned long long *)args[6],
+ (int)*(unsigned long long *)args[7],
+ (int)*(unsigned long long *)args[8],
+ (int)*(unsigned long long *)args[9],
+ (int)*(unsigned long long *)args[10],
+ (int)*(unsigned long long *)args[11],
+ (int)*(unsigned long long *)args[12],
+ (int)*(unsigned long long *)args[13],
+ (int)*(unsigned long long *)args[14],
+ *(int *)args[15],
+ (int)(intptr_t)userdata, (int)*(ffi_arg *)resp);
+
+}
+
+typedef int (*closure_test_type0)(unsigned long long, unsigned long long,
+ unsigned long long, unsigned long long,
+ unsigned long long, unsigned long long,
+ unsigned long long, unsigned long long,
+ unsigned long long, unsigned long long,
+ unsigned long long, unsigned long long,
+ unsigned long long, unsigned long long,
+ unsigned long long, int);
+
+int main (void)
+{
+ ffi_cif cif;
+ void *code;
+ ffi_closure *pcl = ffi_closure_alloc(sizeof(ffi_closure), &code);
+ ffi_type * cl_arg_types[17];
+ int i, res;
+
+ for (i = 0; i < 15; i++) {
+ cl_arg_types[i] = &ffi_type_uint64;
+ }
+ cl_arg_types[15] = &ffi_type_sint;
+ cl_arg_types[16] = NULL;
+
+ /* Initialize the cif */
+ CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 16,
+ &ffi_type_sint, cl_arg_types) == FFI_OK);
+
+ CHECK(ffi_prep_closure_loc(pcl, &cif, closure_test_fn0,
+ (void *) 3 /* userdata */, code) == FFI_OK);
+
+ res = (*((closure_test_type0)code))
+ (1LL, 2LL, 3LL, 4LL, 127LL, 429LL, 7LL, 8LL, 9LL, 10LL, 11LL, 12LL,
+ 13LL, 19LL, 21LL, 1);
+ /* { dg-output "1 2 3 4 127 429 7 8 9 10 11 12 13 19 21 1 3: 680" } */
+ printf("res: %d\n",res);
+ /* { dg-output "\nres: 680" } */
+
+ exit(0);
+}
diff --git a/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/closure_fn5.c b/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/closure_fn5.c
new file mode 100644
index 0000000..9907442
--- /dev/null
+++ b/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/closure_fn5.c
@@ -0,0 +1,92 @@
+/* Area: closure_call
+ Purpose: Check multiple long long values passing.
+ Exceed the limit of gpr registers on PowerPC
+ Darwin.
+ Limitations: none.
+ PR: none.
+ Originator: <andreast@gcc.gnu.org> 20031026 */
+
+/* { dg-do run } */
+#include "ffitest.h"
+
+static void
+closure_test_fn5(ffi_cif* cif __UNUSED__, void* resp, void** args,
+ void* userdata)
+{
+ *(ffi_arg*)resp =
+ (int)*(unsigned long long *)args[0] + (int)*(unsigned long long *)args[1] +
+ (int)*(unsigned long long *)args[2] + (int)*(unsigned long long *)args[3] +
+ (int)*(unsigned long long *)args[4] + (int)*(unsigned long long *)args[5] +
+ (int)*(unsigned long long *)args[6] + (int)*(unsigned long long *)args[7] +
+ (int)*(unsigned long long *)args[8] + (int)*(unsigned long long *)args[9] +
+ (int)*(int *)args[10] +
+ (int)*(unsigned long long *)args[11] +
+ (int)*(unsigned long long *)args[12] +
+ (int)*(unsigned long long *)args[13] +
+ (int)*(unsigned long long *)args[14] +
+ *(int *)args[15] + (intptr_t)userdata;
+
+ printf("%d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d: %d\n",
+ (int)*(unsigned long long *)args[0],
+ (int)*(unsigned long long *)args[1],
+ (int)*(unsigned long long *)args[2],
+ (int)*(unsigned long long *)args[3],
+ (int)*(unsigned long long *)args[4],
+ (int)*(unsigned long long *)args[5],
+ (int)*(unsigned long long *)args[6],
+ (int)*(unsigned long long *)args[7],
+ (int)*(unsigned long long *)args[8],
+ (int)*(unsigned long long *)args[9],
+ (int)*(int *)args[10],
+ (int)*(unsigned long long *)args[11],
+ (int)*(unsigned long long *)args[12],
+ (int)*(unsigned long long *)args[13],
+ (int)*(unsigned long long *)args[14],
+ *(int *)args[15],
+ (int)(intptr_t)userdata, (int)*(ffi_arg *)resp);
+
+}
+
+typedef int (*closure_test_type0)(unsigned long long, unsigned long long,
+ unsigned long long, unsigned long long,
+ unsigned long long, unsigned long long,
+ unsigned long long, unsigned long long,
+ unsigned long long, unsigned long long,
+ int, unsigned long long,
+ unsigned long long, unsigned long long,
+ unsigned long long, int);
+
+int main (void)
+{
+ ffi_cif cif;
+ void *code;
+ ffi_closure *pcl = ffi_closure_alloc(sizeof(ffi_closure), &code);
+ ffi_type * cl_arg_types[17];
+ int i, res;
+
+ for (i = 0; i < 10; i++) {
+ cl_arg_types[i] = &ffi_type_uint64;
+ }
+ cl_arg_types[10] = &ffi_type_sint;
+ for (i = 11; i < 15; i++) {
+ cl_arg_types[i] = &ffi_type_uint64;
+ }
+ cl_arg_types[15] = &ffi_type_sint;
+ cl_arg_types[16] = NULL;
+
+ /* Initialize the cif */
+ CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 16,
+ &ffi_type_sint, cl_arg_types) == FFI_OK);
+
+ CHECK(ffi_prep_closure_loc(pcl, &cif, closure_test_fn5,
+ (void *) 3 /* userdata */, code) == FFI_OK);
+
+ res = (*((closure_test_type0)code))
+ (1LL, 2LL, 3LL, 4LL, 127LL, 429LL, 7LL, 8LL, 9LL, 10LL, 11, 12LL,
+ 13LL, 19LL, 21LL, 1);
+ /* { dg-output "1 2 3 4 127 429 7 8 9 10 11 12 13 19 21 1 3: 680" } */
+ printf("res: %d\n",res);
+ /* { dg-output "\nres: 680" } */
+
+ exit(0);
+}
diff --git a/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/closure_fn6.c b/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/closure_fn6.c
new file mode 100644
index 0000000..73c54fd
--- /dev/null
+++ b/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/closure_fn6.c
@@ -0,0 +1,90 @@
+/* Area: closure_call
+ Purpose: Check multiple values passing from different type.
+ Also, exceed the limit of gpr and fpr registers on PowerPC.
+ Limitations: none.
+ PR: PR23404
+ Originator: <andreast@gcc.gnu.org> 20050830 */
+
+/* { dg-do run } */
+#include "ffitest.h"
+
+static void
+closure_test_fn0(ffi_cif* cif __UNUSED__, void* resp, void** args,
+ void* userdata)
+{
+ *(ffi_arg*)resp =
+ (int)*(unsigned long long *)args[0] +
+ (int)(*(unsigned long long *)args[1]) +
+ (int)(*(unsigned long long *)args[2]) +
+ (int)*(unsigned long long *)args[3] +
+ (int)(*(int *)args[4]) + (int)(*(double *)args[5]) +
+ (int)*(double *)args[6] + (int)(*(float *)args[7]) +
+ (int)(*(double *)args[8]) + (int)*(double *)args[9] +
+ (int)(*(int *)args[10]) + (int)(*(float *)args[11]) +
+ (int)*(int *)args[12] + (int)(*(int *)args[13]) +
+ (int)(*(double *)args[14]) + (int)*(double *)args[15] +
+ (intptr_t)userdata;
+
+ printf("%d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d: %d\n",
+ (int)*(unsigned long long *)args[0],
+ (int)(*(unsigned long long *)args[1]),
+ (int)(*(unsigned long long *)args[2]),
+ (int)*(unsigned long long *)args[3],
+ (int)(*(int *)args[4]), (int)(*(double *)args[5]),
+ (int)*(double *)args[6], (int)(*(float *)args[7]),
+ (int)(*(double *)args[8]), (int)*(double *)args[9],
+ (int)(*(int *)args[10]), (int)(*(float *)args[11]),
+ (int)*(int *)args[12], (int)(*(int *)args[13]),
+ (int)(*(double *)args[14]), (int)(*(double *)args[15]),
+ (int)(intptr_t)userdata, (int)*(ffi_arg *)resp);
+
+}
+
+typedef int (*closure_test_type0)(unsigned long long,
+ unsigned long long,
+ unsigned long long,
+ unsigned long long,
+ int, double, double, float, double, double,
+ int, float, int, int, double, double);
+
+int main (void)
+{
+ ffi_cif cif;
+ void *code;
+ ffi_closure *pcl = ffi_closure_alloc(sizeof(ffi_closure), &code);
+ ffi_type * cl_arg_types[17];
+ int res;
+
+ cl_arg_types[0] = &ffi_type_uint64;
+ cl_arg_types[1] = &ffi_type_uint64;
+ cl_arg_types[2] = &ffi_type_uint64;
+ cl_arg_types[3] = &ffi_type_uint64;
+ cl_arg_types[4] = &ffi_type_sint;
+ cl_arg_types[5] = &ffi_type_double;
+ cl_arg_types[6] = &ffi_type_double;
+ cl_arg_types[7] = &ffi_type_float;
+ cl_arg_types[8] = &ffi_type_double;
+ cl_arg_types[9] = &ffi_type_double;
+ cl_arg_types[10] = &ffi_type_sint;
+ cl_arg_types[11] = &ffi_type_float;
+ cl_arg_types[12] = &ffi_type_sint;
+ cl_arg_types[13] = &ffi_type_sint;
+ cl_arg_types[14] = &ffi_type_double;
+ cl_arg_types[15] = &ffi_type_double;
+ cl_arg_types[16] = NULL;
+
+ /* Initialize the cif */
+ CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 16,
+ &ffi_type_sint, cl_arg_types) == FFI_OK);
+
+ CHECK(ffi_prep_closure_loc(pcl, &cif, closure_test_fn0,
+ (void *) 3 /* userdata */, code) == FFI_OK);
+
+ res = (*((closure_test_type0)code))
+ (1, 2, 3, 4, 127, 429., 7., 8., 9.5, 10., 11, 12., 13,
+ 19, 21., 1.);
+ /* { dg-output "1 2 3 4 127 429 7 8 9 10 11 12 13 19 21 1 3: 680" } */
+ printf("res: %d\n",res);
+ /* { dg-output "\nres: 680" } */
+ exit(0);
+}
diff --git a/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/closure_loc_fn0.c b/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/closure_loc_fn0.c
new file mode 100644
index 0000000..b3afa0b
--- /dev/null
+++ b/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/closure_loc_fn0.c
@@ -0,0 +1,95 @@
+/* Area: closure_call
+ Purpose: Check multiple values passing from different type.
+ Also, exceed the limit of gpr and fpr registers on PowerPC
+ Darwin.
+ Limitations: none.
+ PR: none.
+ Originator: <andreast@gcc.gnu.org> 20030828 */
+
+
+
+
+/* { dg-do run } */
+#include "ffitest.h"
+
+static void
+closure_loc_test_fn0(ffi_cif* cif __UNUSED__, void* resp, void** args,
+ void* userdata)
+{
+ *(ffi_arg*)resp =
+ (int)*(unsigned long long *)args[0] + (int)(*(int *)args[1]) +
+ (int)(*(unsigned long long *)args[2]) + (int)*(int *)args[3] +
+ (int)(*(signed short *)args[4]) +
+ (int)(*(unsigned long long *)args[5]) +
+ (int)*(int *)args[6] + (int)(*(int *)args[7]) +
+ (int)(*(double *)args[8]) + (int)*(int *)args[9] +
+ (int)(*(int *)args[10]) + (int)(*(float *)args[11]) +
+ (int)*(int *)args[12] + (int)(*(int *)args[13]) +
+ (int)(*(int *)args[14]) + *(int *)args[15] + (intptr_t)userdata;
+
+ printf("%d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d: %d\n",
+ (int)*(unsigned long long *)args[0], (int)(*(int *)args[1]),
+ (int)(*(unsigned long long *)args[2]),
+ (int)*(int *)args[3], (int)(*(signed short *)args[4]),
+ (int)(*(unsigned long long *)args[5]),
+ (int)*(int *)args[6], (int)(*(int *)args[7]),
+ (int)(*(double *)args[8]), (int)*(int *)args[9],
+ (int)(*(int *)args[10]), (int)(*(float *)args[11]),
+ (int)*(int *)args[12], (int)(*(int *)args[13]),
+ (int)(*(int *)args[14]),*(int *)args[15],
+ (int)(intptr_t)userdata, (int)*(ffi_arg *)resp);
+
+}
+
+typedef int (*closure_loc_test_type0)(unsigned long long, int, unsigned long long,
+ int, signed short, unsigned long long, int,
+ int, double, int, int, float, int, int,
+ int, int);
+
+int main (void)
+{
+ ffi_cif cif;
+ ffi_closure *pcl;
+ ffi_type * cl_arg_types[17];
+ int res;
+ void *codeloc;
+
+ cl_arg_types[0] = &ffi_type_uint64;
+ cl_arg_types[1] = &ffi_type_sint;
+ cl_arg_types[2] = &ffi_type_uint64;
+ cl_arg_types[3] = &ffi_type_sint;
+ cl_arg_types[4] = &ffi_type_sshort;
+ cl_arg_types[5] = &ffi_type_uint64;
+ cl_arg_types[6] = &ffi_type_sint;
+ cl_arg_types[7] = &ffi_type_sint;
+ cl_arg_types[8] = &ffi_type_double;
+ cl_arg_types[9] = &ffi_type_sint;
+ cl_arg_types[10] = &ffi_type_sint;
+ cl_arg_types[11] = &ffi_type_float;
+ cl_arg_types[12] = &ffi_type_sint;
+ cl_arg_types[13] = &ffi_type_sint;
+ cl_arg_types[14] = &ffi_type_sint;
+ cl_arg_types[15] = &ffi_type_sint;
+ cl_arg_types[16] = NULL;
+
+ /* Initialize the cif */
+ CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 16,
+ &ffi_type_sint, cl_arg_types) == FFI_OK);
+
+ pcl = ffi_closure_alloc(sizeof(ffi_closure), &codeloc);
+ CHECK(pcl != NULL);
+ CHECK(codeloc != NULL);
+
+ CHECK(ffi_prep_closure_loc(pcl, &cif, closure_loc_test_fn0,
+ (void *) 3 /* userdata */, codeloc) == FFI_OK);
+
+ CHECK(memcmp(pcl, codeloc, sizeof(*pcl)) == 0);
+
+ res = (*((closure_loc_test_type0)codeloc))
+ (1LL, 2, 3LL, 4, 127, 429LL, 7, 8, 9.5, 10, 11, 12, 13,
+ 19, 21, 1);
+ /* { dg-output "1 2 3 4 127 429 7 8 9 10 11 12 13 19 21 1 3: 680" } */
+ printf("res: %d\n",res);
+ /* { dg-output "\nres: 680" } */
+ exit(0);
+}
diff --git a/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/closure_simple.c b/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/closure_simple.c
new file mode 100644
index 0000000..5a4e728
--- /dev/null
+++ b/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/closure_simple.c
@@ -0,0 +1,55 @@
+/* Area: closure_call
+ Purpose: Check simple closure handling with all ABIs
+ Limitations: none.
+ PR: none.
+ Originator: <twalljava@dev.java.net> */
+
+/* { dg-do run } */
+#include "ffitest.h"
+
+static void
+closure_test(ffi_cif* cif __UNUSED__, void* resp, void** args, void* userdata)
+{
+ *(ffi_arg*)resp =
+ (int)*(int *)args[0] + (int)(*(int *)args[1])
+ + (int)(*(int *)args[2]) + (int)(*(int *)args[3])
+ + (int)(intptr_t)userdata;
+
+ printf("%d %d %d %d: %d\n",
+ (int)*(int *)args[0], (int)(*(int *)args[1]),
+ (int)(*(int *)args[2]), (int)(*(int *)args[3]),
+ (int)*(ffi_arg *)resp);
+
+}
+
+typedef int (ABI_ATTR *closure_test_type0)(int, int, int, int);
+
+int main (void)
+{
+ ffi_cif cif;
+ void *code;
+ ffi_closure *pcl = ffi_closure_alloc(sizeof(ffi_closure), &code);
+ ffi_type * cl_arg_types[17];
+ int res;
+
+ cl_arg_types[0] = &ffi_type_uint;
+ cl_arg_types[1] = &ffi_type_uint;
+ cl_arg_types[2] = &ffi_type_uint;
+ cl_arg_types[3] = &ffi_type_uint;
+ cl_arg_types[4] = NULL;
+
+ /* Initialize the cif */
+ CHECK(ffi_prep_cif(&cif, ABI_NUM, 4,
+ &ffi_type_sint, cl_arg_types) == FFI_OK);
+
+ CHECK(ffi_prep_closure_loc(pcl, &cif, closure_test,
+ (void *) 3 /* userdata */, code) == FFI_OK);
+
+ res = (*(closure_test_type0)code)(0, 1, 2, 3);
+ /* { dg-output "0 1 2 3: 9" } */
+
+ printf("res: %d\n",res);
+ /* { dg-output "\nres: 9" } */
+
+ exit(0);
+}
diff --git a/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/cls_12byte.c b/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/cls_12byte.c
new file mode 100644
index 0000000..ea0825d
--- /dev/null
+++ b/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/cls_12byte.c
@@ -0,0 +1,94 @@
+/* Area: ffi_call, closure_call
+ Purpose: Check structure passing with different structure size.
+ Limitations: none.
+ PR: none.
+ Originator: <andreast@gcc.gnu.org> 20030828 */
+
+/* { dg-do run } */
+#include "ffitest.h"
+
+typedef struct cls_struct_12byte {
+ int a;
+ int b;
+ int c;
+} cls_struct_12byte;
+
+cls_struct_12byte cls_struct_12byte_fn(struct cls_struct_12byte b1,
+ struct cls_struct_12byte b2)
+{
+ struct cls_struct_12byte result;
+
+ result.a = b1.a + b2.a;
+ result.b = b1.b + b2.b;
+ result.c = b1.c + b2.c;
+
+ printf("%d %d %d %d %d %d: %d %d %d\n", b1.a, b1.b, b1.c, b2.a, b2.b, b2.c,
+ result.a, result.b, result.c);
+
+ return result;
+}
+
+static void cls_struct_12byte_gn(ffi_cif* cif __UNUSED__, void* resp,
+ void** args , void* userdata __UNUSED__)
+{
+ struct cls_struct_12byte b1, b2;
+
+ b1 = *(struct cls_struct_12byte*)(args[0]);
+ b2 = *(struct cls_struct_12byte*)(args[1]);
+
+ *(cls_struct_12byte*)resp = cls_struct_12byte_fn(b1, b2);
+}
+
+int main (void)
+{
+ ffi_cif cif;
+ void *code;
+ ffi_closure *pcl = ffi_closure_alloc(sizeof(ffi_closure), &code);
+ void* args_dbl[5];
+ ffi_type* cls_struct_fields[4];
+ ffi_type cls_struct_type;
+ ffi_type* dbl_arg_types[5];
+
+ struct cls_struct_12byte h_dbl = { 7, 4, 9 };
+ struct cls_struct_12byte j_dbl = { 1, 5, 3 };
+ struct cls_struct_12byte res_dbl;
+
+ cls_struct_type.size = 0;
+ cls_struct_type.alignment = 0;
+ cls_struct_type.type = FFI_TYPE_STRUCT;
+ cls_struct_type.elements = cls_struct_fields;
+
+ cls_struct_fields[0] = &ffi_type_sint;
+ cls_struct_fields[1] = &ffi_type_sint;
+ cls_struct_fields[2] = &ffi_type_sint;
+ cls_struct_fields[3] = NULL;
+
+ dbl_arg_types[0] = &cls_struct_type;
+ dbl_arg_types[1] = &cls_struct_type;
+ dbl_arg_types[2] = NULL;
+
+ CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 2, &cls_struct_type,
+ dbl_arg_types) == FFI_OK);
+
+ args_dbl[0] = &h_dbl;
+ args_dbl[1] = &j_dbl;
+ args_dbl[2] = NULL;
+
+ ffi_call(&cif, FFI_FN(cls_struct_12byte_fn), &res_dbl, args_dbl);
+ /* { dg-output "7 4 9 1 5 3: 8 9 12" } */
+ printf("res: %d %d %d\n", res_dbl.a, res_dbl.b, res_dbl.c);
+ /* { dg-output "\nres: 8 9 12" } */
+
+ CHECK(ffi_prep_closure_loc(pcl, &cif, cls_struct_12byte_gn, NULL, code) == FFI_OK);
+
+ res_dbl.a = 0;
+ res_dbl.b = 0;
+ res_dbl.c = 0;
+
+ res_dbl = ((cls_struct_12byte(*)(cls_struct_12byte, cls_struct_12byte))(code))(h_dbl, j_dbl);
+ /* { dg-output "\n7 4 9 1 5 3: 8 9 12" } */
+ printf("res: %d %d %d\n", res_dbl.a, res_dbl.b, res_dbl.c);
+ /* { dg-output "\nres: 8 9 12" } */
+
+ exit(0);
+}
diff --git a/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/cls_16byte.c b/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/cls_16byte.c
new file mode 100644
index 0000000..89a08a2
--- /dev/null
+++ b/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/cls_16byte.c
@@ -0,0 +1,95 @@
+/* Area: ffi_call, closure_call
+ Purpose: Check structure passing with different structure size.
+ Depending on the ABI. Check overlapping.
+ Limitations: none.
+ PR: none.
+ Originator: <andreast@gcc.gnu.org> 20030828 */
+
+/* { dg-do run } */
+#include "ffitest.h"
+
+typedef struct cls_struct_16byte {
+ int a;
+ double b;
+ int c;
+} cls_struct_16byte;
+
+cls_struct_16byte cls_struct_16byte_fn(struct cls_struct_16byte b1,
+ struct cls_struct_16byte b2)
+{
+ struct cls_struct_16byte result;
+
+ result.a = b1.a + b2.a;
+ result.b = b1.b + b2.b;
+ result.c = b1.c + b2.c;
+
+ printf("%d %g %d %d %g %d: %d %g %d\n", b1.a, b1.b, b1.c, b2.a, b2.b, b2.c,
+ result.a, result.b, result.c);
+
+ return result;
+}
+
+static void cls_struct_16byte_gn(ffi_cif* cif __UNUSED__, void* resp,
+ void** args, void* userdata __UNUSED__)
+{
+ struct cls_struct_16byte b1, b2;
+
+ b1 = *(struct cls_struct_16byte*)(args[0]);
+ b2 = *(struct cls_struct_16byte*)(args[1]);
+
+ *(cls_struct_16byte*)resp = cls_struct_16byte_fn(b1, b2);
+}
+
+int main (void)
+{
+ ffi_cif cif;
+ void *code;
+ ffi_closure *pcl = ffi_closure_alloc(sizeof(ffi_closure), &code);
+ void* args_dbl[5];
+ ffi_type* cls_struct_fields[4];
+ ffi_type cls_struct_type;
+ ffi_type* dbl_arg_types[5];
+
+ struct cls_struct_16byte h_dbl = { 7, 8.0, 9 };
+ struct cls_struct_16byte j_dbl = { 1, 9.0, 3 };
+ struct cls_struct_16byte res_dbl;
+
+ cls_struct_type.size = 0;
+ cls_struct_type.alignment = 0;
+ cls_struct_type.type = FFI_TYPE_STRUCT;
+ cls_struct_type.elements = cls_struct_fields;
+
+ cls_struct_fields[0] = &ffi_type_sint;
+ cls_struct_fields[1] = &ffi_type_double;
+ cls_struct_fields[2] = &ffi_type_sint;
+ cls_struct_fields[3] = NULL;
+
+ dbl_arg_types[0] = &cls_struct_type;
+ dbl_arg_types[1] = &cls_struct_type;
+ dbl_arg_types[2] = NULL;
+
+ CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 2, &cls_struct_type,
+ dbl_arg_types) == FFI_OK);
+
+ args_dbl[0] = &h_dbl;
+ args_dbl[1] = &j_dbl;
+ args_dbl[2] = NULL;
+
+ ffi_call(&cif, FFI_FN(cls_struct_16byte_fn), &res_dbl, args_dbl);
+ /* { dg-output "7 8 9 1 9 3: 8 17 12" } */
+ printf("res: %d %g %d\n", res_dbl.a, res_dbl.b, res_dbl.c);
+ /* { dg-output "\nres: 8 17 12" } */
+
+ res_dbl.a = 0;
+ res_dbl.b = 0.0;
+ res_dbl.c = 0;
+
+ CHECK(ffi_prep_closure_loc(pcl, &cif, cls_struct_16byte_gn, NULL, code) == FFI_OK);
+
+ res_dbl = ((cls_struct_16byte(*)(cls_struct_16byte, cls_struct_16byte))(code))(h_dbl, j_dbl);
+ /* { dg-output "\n7 8 9 1 9 3: 8 17 12" } */
+ printf("res: %d %g %d\n", res_dbl.a, res_dbl.b, res_dbl.c);
+ /* { dg-output "\nres: 8 17 12" } */
+
+ exit(0);
+}
diff --git a/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/cls_18byte.c b/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/cls_18byte.c
new file mode 100644
index 0000000..9f75da8
--- /dev/null
+++ b/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/cls_18byte.c
@@ -0,0 +1,96 @@
+/* Area: ffi_call, closure_call
+ Purpose: Check structure passing with different structure size.
+ Depending on the ABI. Double alignment check on darwin.
+ Limitations: none.
+ PR: none.
+ Originator: <andreast@gcc.gnu.org> 20030915 */
+
+/* { dg-do run } */
+#include "ffitest.h"
+
+typedef struct cls_struct_18byte {
+ double a;
+ unsigned char b;
+ unsigned char c;
+ double d;
+} cls_struct_18byte;
+
+cls_struct_18byte cls_struct_18byte_fn(struct cls_struct_18byte a1,
+ struct cls_struct_18byte a2)
+{
+ struct cls_struct_18byte result;
+
+ result.a = a1.a + a2.a;
+ result.b = a1.b + a2.b;
+ result.c = a1.c + a2.c;
+ result.d = a1.d + a2.d;
+
+
+ printf("%g %d %d %g %g %d %d %g: %g %d %d %g\n", a1.a, a1.b, a1.c, a1.d,
+ a2.a, a2.b, a2.c, a2.d,
+ result.a, result.b, result.c, result.d);
+ return result;
+}
+
+static void
+cls_struct_18byte_gn(ffi_cif* cif __UNUSED__, void* resp, void** args,
+ void* userdata __UNUSED__)
+{
+ struct cls_struct_18byte a1, a2;
+
+ a1 = *(struct cls_struct_18byte*)(args[0]);
+ a2 = *(struct cls_struct_18byte*)(args[1]);
+
+ *(cls_struct_18byte*)resp = cls_struct_18byte_fn(a1, a2);
+}
+
+int main (void)
+{
+ ffi_cif cif;
+ void *code;
+ ffi_closure *pcl = ffi_closure_alloc(sizeof(ffi_closure), &code);
+ void* args_dbl[3];
+ ffi_type* cls_struct_fields[5];
+ ffi_type cls_struct_type;
+ ffi_type* dbl_arg_types[3];
+
+ struct cls_struct_18byte g_dbl = { 1.0, 127, 126, 3.0 };
+ struct cls_struct_18byte f_dbl = { 4.0, 125, 124, 5.0 };
+ struct cls_struct_18byte res_dbl;
+
+ cls_struct_type.size = 0;
+ cls_struct_type.alignment = 0;
+ cls_struct_type.type = FFI_TYPE_STRUCT;
+ cls_struct_type.elements = cls_struct_fields;
+
+ cls_struct_fields[0] = &ffi_type_double;
+ cls_struct_fields[1] = &ffi_type_uchar;
+ cls_struct_fields[2] = &ffi_type_uchar;
+ cls_struct_fields[3] = &ffi_type_double;
+ cls_struct_fields[4] = NULL;
+
+ dbl_arg_types[0] = &cls_struct_type;
+ dbl_arg_types[1] = &cls_struct_type;
+ dbl_arg_types[2] = NULL;
+
+ CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 2, &cls_struct_type,
+ dbl_arg_types) == FFI_OK);
+
+ args_dbl[0] = &g_dbl;
+ args_dbl[1] = &f_dbl;
+ args_dbl[2] = NULL;
+
+ ffi_call(&cif, FFI_FN(cls_struct_18byte_fn), &res_dbl, args_dbl);
+ /* { dg-output "1 127 126 3 4 125 124 5: 5 252 250 8" } */
+ printf("res: %g %d %d %g\n", res_dbl.a, res_dbl.b, res_dbl.c, res_dbl.d);
+ /* { dg-output "\nres: 5 252 250 8" } */
+
+ CHECK(ffi_prep_closure_loc(pcl, &cif, cls_struct_18byte_gn, NULL, code) == FFI_OK);
+
+ res_dbl = ((cls_struct_18byte(*)(cls_struct_18byte, cls_struct_18byte))(code))(g_dbl, f_dbl);
+ /* { dg-output "\n1 127 126 3 4 125 124 5: 5 252 250 8" } */
+ printf("res: %g %d %d %g\n", res_dbl.a, res_dbl.b, res_dbl.c, res_dbl.d);
+ /* { dg-output "\nres: 5 252 250 8" } */
+
+ exit(0);
+}
diff --git a/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/cls_19byte.c b/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/cls_19byte.c
new file mode 100644
index 0000000..278794b
--- /dev/null
+++ b/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/cls_19byte.c
@@ -0,0 +1,102 @@
+/* Area: ffi_call, closure_call
+ Purpose: Check structure passing with different structure size.
+ Depending on the ABI. Double alignment check on darwin.
+ Limitations: none.
+ PR: none.
+ Originator: <andreast@gcc.gnu.org> 20030915 */
+
+/* { dg-do run } */
+#include "ffitest.h"
+
+typedef struct cls_struct_19byte {
+ double a;
+ unsigned char b;
+ unsigned char c;
+ double d;
+ unsigned char e;
+} cls_struct_19byte;
+
+cls_struct_19byte cls_struct_19byte_fn(struct cls_struct_19byte a1,
+ struct cls_struct_19byte a2)
+{
+ struct cls_struct_19byte result;
+
+ result.a = a1.a + a2.a;
+ result.b = a1.b + a2.b;
+ result.c = a1.c + a2.c;
+ result.d = a1.d + a2.d;
+ result.e = a1.e + a2.e;
+
+
+ printf("%g %d %d %g %d %g %d %d %g %d: %g %d %d %g %d\n",
+ a1.a, a1.b, a1.c, a1.d, a1.e,
+ a2.a, a2.b, a2.c, a2.d, a2.e,
+ result.a, result.b, result.c, result.d, result.e);
+ return result;
+}
+
+static void
+cls_struct_19byte_gn(ffi_cif* cif __UNUSED__, void* resp, void** args,
+ void* userdata __UNUSED__)
+{
+ struct cls_struct_19byte a1, a2;
+
+ a1 = *(struct cls_struct_19byte*)(args[0]);
+ a2 = *(struct cls_struct_19byte*)(args[1]);
+
+ *(cls_struct_19byte*)resp = cls_struct_19byte_fn(a1, a2);
+}
+
+int main (void)
+{
+ ffi_cif cif;
+ void *code;
+ ffi_closure *pcl = ffi_closure_alloc(sizeof(ffi_closure), &code);
+ void* args_dbl[3];
+ ffi_type* cls_struct_fields[6];
+ ffi_type cls_struct_type;
+ ffi_type* dbl_arg_types[3];
+
+ struct cls_struct_19byte g_dbl = { 1.0, 127, 126, 3.0, 120 };
+ struct cls_struct_19byte f_dbl = { 4.0, 125, 124, 5.0, 119 };
+ struct cls_struct_19byte res_dbl;
+
+ cls_struct_type.size = 0;
+ cls_struct_type.alignment = 0;
+ cls_struct_type.type = FFI_TYPE_STRUCT;
+ cls_struct_type.elements = cls_struct_fields;
+
+ cls_struct_fields[0] = &ffi_type_double;
+ cls_struct_fields[1] = &ffi_type_uchar;
+ cls_struct_fields[2] = &ffi_type_uchar;
+ cls_struct_fields[3] = &ffi_type_double;
+ cls_struct_fields[4] = &ffi_type_uchar;
+ cls_struct_fields[5] = NULL;
+
+ dbl_arg_types[0] = &cls_struct_type;
+ dbl_arg_types[1] = &cls_struct_type;
+ dbl_arg_types[2] = NULL;
+
+ CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 2, &cls_struct_type,
+ dbl_arg_types) == FFI_OK);
+
+ args_dbl[0] = &g_dbl;
+ args_dbl[1] = &f_dbl;
+ args_dbl[2] = NULL;
+
+ ffi_call(&cif, FFI_FN(cls_struct_19byte_fn), &res_dbl, args_dbl);
+ /* { dg-output "1 127 126 3 120 4 125 124 5 119: 5 252 250 8 239" } */
+ printf("res: %g %d %d %g %d\n", res_dbl.a, res_dbl.b, res_dbl.c,
+ res_dbl.d, res_dbl.e);
+ /* { dg-output "\nres: 5 252 250 8 239" } */
+
+ CHECK(ffi_prep_closure_loc(pcl, &cif, cls_struct_19byte_gn, NULL, code) == FFI_OK);
+
+ res_dbl = ((cls_struct_19byte(*)(cls_struct_19byte, cls_struct_19byte))(code))(g_dbl, f_dbl);
+ /* { dg-output "\n1 127 126 3 120 4 125 124 5 119: 5 252 250 8 239" } */
+ printf("res: %g %d %d %g %d\n", res_dbl.a, res_dbl.b, res_dbl.c,
+ res_dbl.d, res_dbl.e);
+ /* { dg-output "\nres: 5 252 250 8 239" } */
+
+ exit(0);
+}
diff --git a/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/cls_1_1byte.c b/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/cls_1_1byte.c
new file mode 100644
index 0000000..82492c0
--- /dev/null
+++ b/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/cls_1_1byte.c
@@ -0,0 +1,89 @@
+/* Area: ffi_call, closure_call
+ Purpose: Check structure passing with different structure size.
+ Especially with small structures which may fit in one
+ register. Depending on the ABI.
+ Limitations: none.
+ PR: none.
+ Originator: <andreast@gcc.gnu.org> 20030902 */
+
+
+
+/* { dg-do run } */
+#include "ffitest.h"
+
+typedef struct cls_struct_1_1byte {
+ unsigned char a;
+} cls_struct_1_1byte;
+
+cls_struct_1_1byte cls_struct_1_1byte_fn(struct cls_struct_1_1byte a1,
+ struct cls_struct_1_1byte a2)
+{
+ struct cls_struct_1_1byte result;
+
+ result.a = a1.a + a2.a;
+
+ printf("%d %d: %d\n", a1.a, a2.a, result.a);
+
+ return result;
+}
+
+static void
+cls_struct_1_1byte_gn(ffi_cif* cif __UNUSED__, void* resp, void** args,
+ void* userdata __UNUSED__)
+{
+
+ struct cls_struct_1_1byte a1, a2;
+
+ a1 = *(struct cls_struct_1_1byte*)(args[0]);
+ a2 = *(struct cls_struct_1_1byte*)(args[1]);
+
+ *(cls_struct_1_1byte*)resp = cls_struct_1_1byte_fn(a1, a2);
+}
+
+int main (void)
+{
+ ffi_cif cif;
+ void *code;
+ ffi_closure *pcl = ffi_closure_alloc(sizeof(ffi_closure), &code);
+ void* args_dbl[5];
+ ffi_type* cls_struct_fields[2];
+ ffi_type cls_struct_type;
+ ffi_type* dbl_arg_types[5];
+
+ struct cls_struct_1_1byte g_dbl = { 12 };
+ struct cls_struct_1_1byte f_dbl = { 178 };
+ struct cls_struct_1_1byte res_dbl;
+
+ cls_struct_type.size = 0;
+ cls_struct_type.alignment = 0;
+ cls_struct_type.type = FFI_TYPE_STRUCT;
+ cls_struct_type.elements = cls_struct_fields;
+
+ cls_struct_fields[0] = &ffi_type_uchar;
+ cls_struct_fields[1] = NULL;
+
+ dbl_arg_types[0] = &cls_struct_type;
+ dbl_arg_types[1] = &cls_struct_type;
+ dbl_arg_types[2] = NULL;
+
+ CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 2, &cls_struct_type,
+ dbl_arg_types) == FFI_OK);
+
+ args_dbl[0] = &g_dbl;
+ args_dbl[1] = &f_dbl;
+ args_dbl[2] = NULL;
+
+ ffi_call(&cif, FFI_FN(cls_struct_1_1byte_fn), &res_dbl, args_dbl);
+ /* { dg-output "12 178: 190" } */
+ printf("res: %d\n", res_dbl.a);
+ /* { dg-output "\nres: 190" } */
+
+ CHECK(ffi_prep_closure_loc(pcl, &cif, cls_struct_1_1byte_gn, NULL, code) == FFI_OK);
+
+ res_dbl = ((cls_struct_1_1byte(*)(cls_struct_1_1byte, cls_struct_1_1byte))(code))(g_dbl, f_dbl);
+ /* { dg-output "\n12 178: 190" } */
+ printf("res: %d\n", res_dbl.a);
+ /* { dg-output "\nres: 190" } */
+
+ exit(0);
+}
diff --git a/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/cls_20byte.c b/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/cls_20byte.c
new file mode 100644
index 0000000..3f8bb28
--- /dev/null
+++ b/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/cls_20byte.c
@@ -0,0 +1,91 @@
+/* Area: ffi_call, closure_call
+ Purpose: Check structure passing with different structure size.
+ Depending on the ABI. Check overlapping.
+ Limitations: none.
+ PR: none.
+ Originator: <andreast@gcc.gnu.org> 20030828 */
+
+/* { dg-do run } */
+#include "ffitest.h"
+
+typedef struct cls_struct_20byte {
+ double a;
+ double b;
+ int c;
+} cls_struct_20byte;
+
+cls_struct_20byte cls_struct_20byte_fn(struct cls_struct_20byte a1,
+ struct cls_struct_20byte a2)
+{
+ struct cls_struct_20byte result;
+
+ result.a = a1.a + a2.a;
+ result.b = a1.b + a2.b;
+ result.c = a1.c + a2.c;
+
+ printf("%g %g %d %g %g %d: %g %g %d\n", a1.a, a1.b, a1.c, a2.a, a2.b, a2.c,
+ result.a, result.b, result.c);
+ return result;
+}
+
+static void
+cls_struct_20byte_gn(ffi_cif* cif __UNUSED__, void* resp, void** args,
+ void* userdata __UNUSED__)
+{
+ struct cls_struct_20byte a1, a2;
+
+ a1 = *(struct cls_struct_20byte*)(args[0]);
+ a2 = *(struct cls_struct_20byte*)(args[1]);
+
+ *(cls_struct_20byte*)resp = cls_struct_20byte_fn(a1, a2);
+}
+
+int main (void)
+{
+ ffi_cif cif;
+ void *code;
+ ffi_closure *pcl = ffi_closure_alloc(sizeof(ffi_closure), &code);
+ void* args_dbl[5];
+ ffi_type* cls_struct_fields[4];
+ ffi_type cls_struct_type;
+ ffi_type* dbl_arg_types[5];
+
+ struct cls_struct_20byte g_dbl = { 1.0, 2.0, 3 };
+ struct cls_struct_20byte f_dbl = { 4.0, 5.0, 7 };
+ struct cls_struct_20byte res_dbl;
+
+ cls_struct_type.size = 0;
+ cls_struct_type.alignment = 0;
+ cls_struct_type.type = FFI_TYPE_STRUCT;
+ cls_struct_type.elements = cls_struct_fields;
+
+ cls_struct_fields[0] = &ffi_type_double;
+ cls_struct_fields[1] = &ffi_type_double;
+ cls_struct_fields[2] = &ffi_type_sint;
+ cls_struct_fields[3] = NULL;
+
+ dbl_arg_types[0] = &cls_struct_type;
+ dbl_arg_types[1] = &cls_struct_type;
+ dbl_arg_types[2] = NULL;
+
+ CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 2, &cls_struct_type,
+ dbl_arg_types) == FFI_OK);
+
+ args_dbl[0] = &g_dbl;
+ args_dbl[1] = &f_dbl;
+ args_dbl[2] = NULL;
+
+ ffi_call(&cif, FFI_FN(cls_struct_20byte_fn), &res_dbl, args_dbl);
+ /* { dg-output "1 2 3 4 5 7: 5 7 10" } */
+ printf("res: %g %g %d\n", res_dbl.a, res_dbl.b, res_dbl.c);
+ /* { dg-output "\nres: 5 7 10" } */
+
+ CHECK(ffi_prep_closure_loc(pcl, &cif, cls_struct_20byte_gn, NULL, code) == FFI_OK);
+
+ res_dbl = ((cls_struct_20byte(*)(cls_struct_20byte, cls_struct_20byte))(code))(g_dbl, f_dbl);
+ /* { dg-output "\n1 2 3 4 5 7: 5 7 10" } */
+ printf("res: %g %g %d\n", res_dbl.a, res_dbl.b, res_dbl.c);
+ /* { dg-output "\nres: 5 7 10" } */
+
+ exit(0);
+}
diff --git a/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/cls_20byte1.c b/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/cls_20byte1.c
new file mode 100644
index 0000000..6562727
--- /dev/null
+++ b/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/cls_20byte1.c
@@ -0,0 +1,93 @@
+/* Area: ffi_call, closure_call
+ Purpose: Check structure passing with different structure size.
+ Depending on the ABI. Check overlapping.
+ Limitations: none.
+ PR: none.
+ Originator: <andreast@gcc.gnu.org> 20030828 */
+
+
+
+/* { dg-do run } */
+#include "ffitest.h"
+
+typedef struct cls_struct_20byte {
+ int a;
+ double b;
+ double c;
+} cls_struct_20byte;
+
+cls_struct_20byte cls_struct_20byte_fn(struct cls_struct_20byte a1,
+ struct cls_struct_20byte a2)
+{
+ struct cls_struct_20byte result;
+
+ result.a = a1.a + a2.a;
+ result.b = a1.b + a2.b;
+ result.c = a1.c + a2.c;
+
+ printf("%d %g %g %d %g %g: %d %g %g\n", a1.a, a1.b, a1.c, a2.a, a2.b, a2.c,
+ result.a, result.b, result.c);
+ return result;
+}
+
+static void
+cls_struct_20byte_gn(ffi_cif* cif __UNUSED__, void* resp, void** args,
+ void* userdata __UNUSED__)
+{
+ struct cls_struct_20byte a1, a2;
+
+ a1 = *(struct cls_struct_20byte*)(args[0]);
+ a2 = *(struct cls_struct_20byte*)(args[1]);
+
+ *(cls_struct_20byte*)resp = cls_struct_20byte_fn(a1, a2);
+}
+
+int main (void)
+{
+ ffi_cif cif;
+ void *code;
+ ffi_closure *pcl = ffi_closure_alloc(sizeof(ffi_closure), &code);
+ void* args_dbl[3];
+ ffi_type* cls_struct_fields[4];
+ ffi_type cls_struct_type;
+ ffi_type* dbl_arg_types[3];
+
+ struct cls_struct_20byte g_dbl = { 1, 2.0, 3.0 };
+ struct cls_struct_20byte f_dbl = { 4, 5.0, 7.0 };
+ struct cls_struct_20byte res_dbl;
+
+ cls_struct_type.size = 0;
+ cls_struct_type.alignment = 0;
+ cls_struct_type.type = FFI_TYPE_STRUCT;
+ cls_struct_type.elements = cls_struct_fields;
+
+ cls_struct_fields[0] = &ffi_type_sint;
+ cls_struct_fields[1] = &ffi_type_double;
+ cls_struct_fields[2] = &ffi_type_double;
+ cls_struct_fields[3] = NULL;
+
+ dbl_arg_types[0] = &cls_struct_type;
+ dbl_arg_types[1] = &cls_struct_type;
+ dbl_arg_types[2] = NULL;
+
+ CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 2, &cls_struct_type,
+ dbl_arg_types) == FFI_OK);
+
+ args_dbl[0] = &g_dbl;
+ args_dbl[1] = &f_dbl;
+ args_dbl[2] = NULL;
+
+ ffi_call(&cif, FFI_FN(cls_struct_20byte_fn), &res_dbl, args_dbl);
+ /* { dg-output "1 2 3 4 5 7: 5 7 10" } */
+ printf("res: %d %g %g\n", res_dbl.a, res_dbl.b, res_dbl.c);
+ /* { dg-output "\nres: 5 7 10" } */
+
+ CHECK(ffi_prep_closure_loc(pcl, &cif, cls_struct_20byte_gn, NULL, code) == FFI_OK);
+
+ res_dbl = ((cls_struct_20byte(*)(cls_struct_20byte, cls_struct_20byte))(code))(g_dbl, f_dbl);
+ /* { dg-output "\n1 2 3 4 5 7: 5 7 10" } */
+ printf("res: %d %g %g\n", res_dbl.a, res_dbl.b, res_dbl.c);
+ /* { dg-output "\nres: 5 7 10" } */
+
+ exit(0);
+}
diff --git a/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/cls_24byte.c b/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/cls_24byte.c
new file mode 100644
index 0000000..1d82f6e
--- /dev/null
+++ b/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/cls_24byte.c
@@ -0,0 +1,113 @@
+/* Area: ffi_call, closure_call
+ Purpose: Check structure passing with different structure size.
+ Depending on the ABI. Check overlapping.
+ Limitations: none.
+ PR: none.
+ Originator: <andreast@gcc.gnu.org> 20030828 */
+
+/* { dg-do run } */
+#include "ffitest.h"
+
+typedef struct cls_struct_24byte {
+ double a;
+ double b;
+ int c;
+ float d;
+} cls_struct_24byte;
+
+cls_struct_24byte cls_struct_24byte_fn(struct cls_struct_24byte b0,
+ struct cls_struct_24byte b1,
+ struct cls_struct_24byte b2,
+ struct cls_struct_24byte b3)
+{
+ struct cls_struct_24byte result;
+
+ result.a = b0.a + b1.a + b2.a + b3.a;
+ result.b = b0.b + b1.b + b2.b + b3.b;
+ result.c = b0.c + b1.c + b2.c + b3.c;
+ result.d = b0.d + b1.d + b2.d + b3.d;
+
+ printf("%g %g %d %g %g %g %d %g %g %g %d %g %g %g %d %g: %g %g %d %g\n",
+ b0.a, b0.b, b0.c, b0.d,
+ b1.a, b1.b, b1.c, b1.d,
+ b2.a, b2.b, b2.c, b2.d,
+ b3.a, b3.b, b3.c, b2.d,
+ result.a, result.b, result.c, result.d);
+
+ return result;
+}
+
+static void
+cls_struct_24byte_gn(ffi_cif* cif __UNUSED__, void* resp, void** args,
+ void* userdata __UNUSED__)
+{
+ struct cls_struct_24byte b0, b1, b2, b3;
+
+ b0 = *(struct cls_struct_24byte*)(args[0]);
+ b1 = *(struct cls_struct_24byte*)(args[1]);
+ b2 = *(struct cls_struct_24byte*)(args[2]);
+ b3 = *(struct cls_struct_24byte*)(args[3]);
+
+ *(cls_struct_24byte*)resp = cls_struct_24byte_fn(b0, b1, b2, b3);
+}
+
+int main (void)
+{
+ ffi_cif cif;
+ void *code;
+ ffi_closure *pcl = ffi_closure_alloc(sizeof(ffi_closure), &code);
+ void* args_dbl[5];
+ ffi_type* cls_struct_fields[5];
+ ffi_type cls_struct_type;
+ ffi_type* dbl_arg_types[5];
+
+ struct cls_struct_24byte e_dbl = { 9.0, 2.0, 6, 5.0 };
+ struct cls_struct_24byte f_dbl = { 1.0, 2.0, 3, 7.0 };
+ struct cls_struct_24byte g_dbl = { 4.0, 5.0, 7, 9.0 };
+ struct cls_struct_24byte h_dbl = { 8.0, 6.0, 1, 4.0 };
+ struct cls_struct_24byte res_dbl;
+
+ cls_struct_type.size = 0;
+ cls_struct_type.alignment = 0;
+ cls_struct_type.type = FFI_TYPE_STRUCT;
+ cls_struct_type.elements = cls_struct_fields;
+
+ cls_struct_fields[0] = &ffi_type_double;
+ cls_struct_fields[1] = &ffi_type_double;
+ cls_struct_fields[2] = &ffi_type_sint;
+ cls_struct_fields[3] = &ffi_type_float;
+ cls_struct_fields[4] = NULL;
+
+ dbl_arg_types[0] = &cls_struct_type;
+ dbl_arg_types[1] = &cls_struct_type;
+ dbl_arg_types[2] = &cls_struct_type;
+ dbl_arg_types[3] = &cls_struct_type;
+ dbl_arg_types[4] = NULL;
+
+ CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 4, &cls_struct_type,
+ dbl_arg_types) == FFI_OK);
+
+ args_dbl[0] = &e_dbl;
+ args_dbl[1] = &f_dbl;
+ args_dbl[2] = &g_dbl;
+ args_dbl[3] = &h_dbl;
+ args_dbl[4] = NULL;
+
+ ffi_call(&cif, FFI_FN(cls_struct_24byte_fn), &res_dbl, args_dbl);
+ /* { dg-output "9 2 6 5 1 2 3 7 4 5 7 9 8 6 1 9: 22 15 17 25" } */
+ printf("res: %g %g %d %g\n", res_dbl.a, res_dbl.b, res_dbl.c, res_dbl.d);
+ /* { dg-output "\nres: 22 15 17 25" } */
+
+ CHECK(ffi_prep_closure_loc(pcl, &cif, cls_struct_24byte_gn, NULL, code) == FFI_OK);
+
+ res_dbl = ((cls_struct_24byte(*)(cls_struct_24byte,
+ cls_struct_24byte,
+ cls_struct_24byte,
+ cls_struct_24byte))
+ (code))(e_dbl, f_dbl, g_dbl, h_dbl);
+ /* { dg-output "\n9 2 6 5 1 2 3 7 4 5 7 9 8 6 1 9: 22 15 17 25" } */
+ printf("res: %g %g %d %g\n", res_dbl.a, res_dbl.b, res_dbl.c, res_dbl.d);
+ /* { dg-output "\nres: 22 15 17 25" } */
+
+ exit(0);
+}
diff --git a/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/cls_2byte.c b/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/cls_2byte.c
new file mode 100644
index 0000000..81bb0a6
--- /dev/null
+++ b/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/cls_2byte.c
@@ -0,0 +1,90 @@
+/* Area: ffi_call, closure_call
+ Purpose: Check structure passing with different structure size.
+ Especially with small structures which may fit in one
+ register. Depending on the ABI.
+ Limitations: none.
+ PR: none.
+ Originator: <andreast@gcc.gnu.org> 20030828 */
+
+/* { dg-do run } */
+#include "ffitest.h"
+
+typedef struct cls_struct_2byte {
+ unsigned char a;
+ unsigned char b;
+} cls_struct_2byte;
+
+cls_struct_2byte cls_struct_2byte_fn(struct cls_struct_2byte a1,
+ struct cls_struct_2byte a2)
+{
+ struct cls_struct_2byte result;
+
+ result.a = a1.a + a2.a;
+ result.b = a1.b + a2.b;
+
+ printf("%d %d %d %d: %d %d\n", a1.a, a1.b, a2.a, a2.b, result.a, result.b);
+
+ return result;
+}
+
+static void
+cls_struct_2byte_gn(ffi_cif* cif __UNUSED__, void* resp, void** args,
+ void* userdata __UNUSED__)
+{
+
+ struct cls_struct_2byte a1, a2;
+
+ a1 = *(struct cls_struct_2byte*)(args[0]);
+ a2 = *(struct cls_struct_2byte*)(args[1]);
+
+ *(cls_struct_2byte*)resp = cls_struct_2byte_fn(a1, a2);
+}
+
+int main (void)
+{
+ ffi_cif cif;
+ void *code;
+ ffi_closure *pcl = ffi_closure_alloc(sizeof(ffi_closure), &code);
+ void* args_dbl[5];
+ ffi_type* cls_struct_fields[4];
+ ffi_type cls_struct_type;
+ ffi_type* dbl_arg_types[5];
+
+ struct cls_struct_2byte g_dbl = { 12, 127 };
+ struct cls_struct_2byte f_dbl = { 1, 13 };
+ struct cls_struct_2byte res_dbl;
+
+ cls_struct_type.size = 0;
+ cls_struct_type.alignment = 0;
+ cls_struct_type.type = FFI_TYPE_STRUCT;
+ cls_struct_type.elements = cls_struct_fields;
+
+ cls_struct_fields[0] = &ffi_type_uchar;
+ cls_struct_fields[1] = &ffi_type_uchar;
+ cls_struct_fields[2] = NULL;
+
+ dbl_arg_types[0] = &cls_struct_type;
+ dbl_arg_types[1] = &cls_struct_type;
+ dbl_arg_types[2] = NULL;
+
+ CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 2, &cls_struct_type,
+ dbl_arg_types) == FFI_OK);
+
+ args_dbl[0] = &g_dbl;
+ args_dbl[1] = &f_dbl;
+ args_dbl[2] = NULL;
+
+ ffi_call(&cif, FFI_FN(cls_struct_2byte_fn), &res_dbl, args_dbl);
+ /* { dg-output "12 127 1 13: 13 140" } */
+ printf("res: %d %d\n", res_dbl.a, res_dbl.b);
+ /* { dg-output "\nres: 13 140" } */
+
+ CHECK(ffi_prep_closure_loc(pcl, &cif, cls_struct_2byte_gn, NULL, code) == FFI_OK);
+
+ res_dbl = ((cls_struct_2byte(*)(cls_struct_2byte, cls_struct_2byte))(code))(g_dbl, f_dbl);
+ /* { dg-output "\n12 127 1 13: 13 140" } */
+ printf("res: %d %d\n", res_dbl.a, res_dbl.b);
+ /* { dg-output "\nres: 13 140" } */
+
+ exit(0);
+}
diff --git a/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/cls_3_1byte.c b/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/cls_3_1byte.c
new file mode 100644
index 0000000..b782746
--- /dev/null
+++ b/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/cls_3_1byte.c
@@ -0,0 +1,95 @@
+/* Area: ffi_call, closure_call
+ Purpose: Check structure passing with different structure size.
+ Especially with small structures which may fit in one
+ register. Depending on the ABI.
+ Limitations: none.
+ PR: none.
+ Originator: <andreast@gcc.gnu.org> 20030902 */
+
+/* { dg-do run } */
+#include "ffitest.h"
+
+typedef struct cls_struct_3_1byte {
+ unsigned char a;
+ unsigned char b;
+ unsigned char c;
+} cls_struct_3_1byte;
+
+cls_struct_3_1byte cls_struct_3_1byte_fn(struct cls_struct_3_1byte a1,
+ struct cls_struct_3_1byte a2)
+{
+ struct cls_struct_3_1byte result;
+
+ result.a = a1.a + a2.a;
+ result.b = a1.b + a2.b;
+ result.c = a1.c + a2.c;
+
+ printf("%d %d %d %d %d %d: %d %d %d\n", a1.a, a1.b, a1.c,
+ a2.a, a2.b, a2.c,
+ result.a, result.b, result.c);
+
+ return result;
+}
+
+static void
+cls_struct_3_1byte_gn(ffi_cif* cif __UNUSED__, void* resp, void** args,
+ void* userdata __UNUSED__)
+{
+
+ struct cls_struct_3_1byte a1, a2;
+
+ a1 = *(struct cls_struct_3_1byte*)(args[0]);
+ a2 = *(struct cls_struct_3_1byte*)(args[1]);
+
+ *(cls_struct_3_1byte*)resp = cls_struct_3_1byte_fn(a1, a2);
+}
+
+int main (void)
+{
+ ffi_cif cif;
+ void *code;
+ ffi_closure *pcl = ffi_closure_alloc(sizeof(ffi_closure), &code);
+ void* args_dbl[5];
+ ffi_type* cls_struct_fields[4];
+ ffi_type cls_struct_type;
+ ffi_type* dbl_arg_types[5];
+
+ struct cls_struct_3_1byte g_dbl = { 12, 13, 14 };
+ struct cls_struct_3_1byte f_dbl = { 178, 179, 180 };
+ struct cls_struct_3_1byte res_dbl;
+
+ cls_struct_type.size = 0;
+ cls_struct_type.alignment = 0;
+ cls_struct_type.type = FFI_TYPE_STRUCT;
+ cls_struct_type.elements = cls_struct_fields;
+
+ cls_struct_fields[0] = &ffi_type_uchar;
+ cls_struct_fields[1] = &ffi_type_uchar;
+ cls_struct_fields[2] = &ffi_type_uchar;
+ cls_struct_fields[3] = NULL;
+
+ dbl_arg_types[0] = &cls_struct_type;
+ dbl_arg_types[1] = &cls_struct_type;
+ dbl_arg_types[2] = NULL;
+
+ CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 2, &cls_struct_type,
+ dbl_arg_types) == FFI_OK);
+
+ args_dbl[0] = &g_dbl;
+ args_dbl[1] = &f_dbl;
+ args_dbl[2] = NULL;
+
+ ffi_call(&cif, FFI_FN(cls_struct_3_1byte_fn), &res_dbl, args_dbl);
+ /* { dg-output "12 13 14 178 179 180: 190 192 194" } */
+ printf("res: %d %d %d\n", res_dbl.a, res_dbl.b, res_dbl.c);
+ /* { dg-output "\nres: 190 192 194" } */
+
+ CHECK(ffi_prep_closure_loc(pcl, &cif, cls_struct_3_1byte_gn, NULL, code) == FFI_OK);
+
+ res_dbl = ((cls_struct_3_1byte(*)(cls_struct_3_1byte, cls_struct_3_1byte))(code))(g_dbl, f_dbl);
+ /* { dg-output "\n12 13 14 178 179 180: 190 192 194" } */
+ printf("res: %d %d %d\n", res_dbl.a, res_dbl.b, res_dbl.c);
+ /* { dg-output "\nres: 190 192 194" } */
+
+ exit(0);
+}
diff --git a/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/cls_3byte1.c b/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/cls_3byte1.c
new file mode 100644
index 0000000..a02c463
--- /dev/null
+++ b/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/cls_3byte1.c
@@ -0,0 +1,90 @@
+/* Area: ffi_call, closure_call
+ Purpose: Check structure passing with different structure size.
+ Especially with small structures which may fit in one
+ register. Depending on the ABI. Check overlapping.
+ Limitations: none.
+ PR: none.
+ Originator: <andreast@gcc.gnu.org> 20030828 */
+
+/* { dg-do run } */
+#include "ffitest.h"
+
+typedef struct cls_struct_3byte {
+ unsigned short a;
+ unsigned char b;
+} cls_struct_3byte;
+
+cls_struct_3byte cls_struct_3byte_fn(struct cls_struct_3byte a1,
+ struct cls_struct_3byte a2)
+{
+ struct cls_struct_3byte result;
+
+ result.a = a1.a + a2.a;
+ result.b = a1.b + a2.b;
+
+ printf("%d %d %d %d: %d %d\n", a1.a, a1.b, a2.a, a2.b, result.a, result.b);
+
+ return result;
+}
+
+static void
+cls_struct_3byte_gn(ffi_cif* cif __UNUSED__, void* resp, void** args,
+ void* userdata __UNUSED__)
+{
+
+ struct cls_struct_3byte a1, a2;
+
+ a1 = *(struct cls_struct_3byte*)(args[0]);
+ a2 = *(struct cls_struct_3byte*)(args[1]);
+
+ *(cls_struct_3byte*)resp = cls_struct_3byte_fn(a1, a2);
+}
+
+int main (void)
+{
+ ffi_cif cif;
+ void *code;
+ ffi_closure *pcl = ffi_closure_alloc(sizeof(ffi_closure), &code);
+ void* args_dbl[5];
+ ffi_type* cls_struct_fields[4];
+ ffi_type cls_struct_type;
+ ffi_type* dbl_arg_types[5];
+
+ struct cls_struct_3byte g_dbl = { 12, 119 };
+ struct cls_struct_3byte f_dbl = { 1, 15 };
+ struct cls_struct_3byte res_dbl;
+
+ cls_struct_type.size = 0;
+ cls_struct_type.alignment = 0;
+ cls_struct_type.type = FFI_TYPE_STRUCT;
+ cls_struct_type.elements = cls_struct_fields;
+
+ cls_struct_fields[0] = &ffi_type_ushort;
+ cls_struct_fields[1] = &ffi_type_uchar;
+ cls_struct_fields[2] = NULL;
+
+ dbl_arg_types[0] = &cls_struct_type;
+ dbl_arg_types[1] = &cls_struct_type;
+ dbl_arg_types[2] = NULL;
+
+ CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 2, &cls_struct_type,
+ dbl_arg_types) == FFI_OK);
+
+ args_dbl[0] = &g_dbl;
+ args_dbl[1] = &f_dbl;
+ args_dbl[2] = NULL;
+
+ ffi_call(&cif, FFI_FN(cls_struct_3byte_fn), &res_dbl, args_dbl);
+ /* { dg-output "12 119 1 15: 13 134" } */
+ printf("res: %d %d\n", res_dbl.a, res_dbl.b);
+ /* { dg-output "\nres: 13 134" } */
+
+ CHECK(ffi_prep_closure_loc(pcl, &cif, cls_struct_3byte_gn, NULL, code) == FFI_OK);
+
+ res_dbl = ((cls_struct_3byte(*)(cls_struct_3byte, cls_struct_3byte))(code))(g_dbl, f_dbl);
+ /* { dg-output "\n12 119 1 15: 13 134" } */
+ printf("res: %d %d\n", res_dbl.a, res_dbl.b);
+ /* { dg-output "\nres: 13 134" } */
+
+ exit(0);
+}
diff --git a/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/cls_3byte2.c b/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/cls_3byte2.c
new file mode 100644
index 0000000..c7251ce
--- /dev/null
+++ b/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/cls_3byte2.c
@@ -0,0 +1,90 @@
+/* Area: ffi_call, closure_call
+ Purpose: Check structure passing with different structure size.
+ Especially with small structures which may fit in one
+ register. Depending on the ABI. Check overlapping.
+ Limitations: none.
+ PR: none.
+ Originator: <andreast@gcc.gnu.org> 20030828 */
+
+/* { dg-do run } */
+#include "ffitest.h"
+
+typedef struct cls_struct_3byte_1 {
+ unsigned char a;
+ unsigned short b;
+} cls_struct_3byte_1;
+
+cls_struct_3byte_1 cls_struct_3byte_fn1(struct cls_struct_3byte_1 a1,
+ struct cls_struct_3byte_1 a2)
+{
+ struct cls_struct_3byte_1 result;
+
+ result.a = a1.a + a2.a;
+ result.b = a1.b + a2.b;
+
+ printf("%d %d %d %d: %d %d\n", a1.a, a1.b, a2.a, a2.b, result.a, result.b);
+
+ return result;
+}
+
+static void
+cls_struct_3byte_gn1(ffi_cif* cif __UNUSED__, void* resp, void** args,
+ void* userdata __UNUSED__)
+{
+
+ struct cls_struct_3byte_1 a1, a2;
+
+ a1 = *(struct cls_struct_3byte_1*)(args[0]);
+ a2 = *(struct cls_struct_3byte_1*)(args[1]);
+
+ *(cls_struct_3byte_1*)resp = cls_struct_3byte_fn1(a1, a2);
+}
+
+int main (void)
+{
+ ffi_cif cif;
+ void *code;
+ ffi_closure *pcl = ffi_closure_alloc(sizeof(ffi_closure), &code);
+ void* args_dbl[5];
+ ffi_type* cls_struct_fields[4];
+ ffi_type cls_struct_type;
+ ffi_type* dbl_arg_types[5];
+
+ struct cls_struct_3byte_1 g_dbl = { 15, 125 };
+ struct cls_struct_3byte_1 f_dbl = { 9, 19 };
+ struct cls_struct_3byte_1 res_dbl;
+
+ cls_struct_type.size = 0;
+ cls_struct_type.alignment = 0;
+ cls_struct_type.type = FFI_TYPE_STRUCT;
+ cls_struct_type.elements = cls_struct_fields;
+
+ cls_struct_fields[0] = &ffi_type_uchar;
+ cls_struct_fields[1] = &ffi_type_ushort;
+ cls_struct_fields[2] = NULL;
+
+ dbl_arg_types[0] = &cls_struct_type;
+ dbl_arg_types[1] = &cls_struct_type;
+ dbl_arg_types[2] = NULL;
+
+ CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 2, &cls_struct_type,
+ dbl_arg_types) == FFI_OK);
+
+ args_dbl[0] = &g_dbl;
+ args_dbl[1] = &f_dbl;
+ args_dbl[2] = NULL;
+
+ ffi_call(&cif, FFI_FN(cls_struct_3byte_fn1), &res_dbl, args_dbl);
+ /* { dg-output "15 125 9 19: 24 144" } */
+ printf("res: %d %d\n", res_dbl.a, res_dbl.b);
+ /* { dg-output "\nres: 24 144" } */
+
+ CHECK(ffi_prep_closure_loc(pcl, &cif, cls_struct_3byte_gn1, NULL, code) == FFI_OK);
+
+ res_dbl = ((cls_struct_3byte_1(*)(cls_struct_3byte_1, cls_struct_3byte_1))(code))(g_dbl, f_dbl);
+ /* { dg-output "\n15 125 9 19: 24 144" } */
+ printf("res: %d %d\n", res_dbl.a, res_dbl.b);
+ /* { dg-output "\nres: 24 144" } */
+
+ exit(0);
+}
diff --git a/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/cls_4_1byte.c b/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/cls_4_1byte.c
new file mode 100644
index 0000000..2d6d8b6
--- /dev/null
+++ b/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/cls_4_1byte.c
@@ -0,0 +1,98 @@
+/* Area: ffi_call, closure_call
+ Purpose: Check structure passing with different structure size.
+ Especially with small structures which may fit in one
+ register. Depending on the ABI.
+ Limitations: none.
+ PR: none.
+ Originator: <andreast@gcc.gnu.org> 20030902 */
+
+/* { dg-do run } */
+#include "ffitest.h"
+
+typedef struct cls_struct_4_1byte {
+ unsigned char a;
+ unsigned char b;
+ unsigned char c;
+ unsigned char d;
+} cls_struct_4_1byte;
+
+cls_struct_4_1byte cls_struct_4_1byte_fn(struct cls_struct_4_1byte a1,
+ struct cls_struct_4_1byte a2)
+{
+ struct cls_struct_4_1byte result;
+
+ result.a = a1.a + a2.a;
+ result.b = a1.b + a2.b;
+ result.c = a1.c + a2.c;
+ result.d = a1.d + a2.d;
+
+ printf("%d %d %d %d %d %d %d %d: %d %d %d %d\n", a1.a, a1.b, a1.c, a1.d,
+ a2.a, a2.b, a2.c, a2.d,
+ result.a, result.b, result.c, result.d);
+
+ return result;
+}
+
+static void
+cls_struct_4_1byte_gn(ffi_cif* cif __UNUSED__, void* resp, void** args,
+ void* userdata __UNUSED__)
+{
+
+ struct cls_struct_4_1byte a1, a2;
+
+ a1 = *(struct cls_struct_4_1byte*)(args[0]);
+ a2 = *(struct cls_struct_4_1byte*)(args[1]);
+
+ *(cls_struct_4_1byte*)resp = cls_struct_4_1byte_fn(a1, a2);
+}
+
+int main (void)
+{
+ ffi_cif cif;
+ void *code;
+ ffi_closure *pcl = ffi_closure_alloc(sizeof(ffi_closure), &code);
+ void* args_dbl[5];
+ ffi_type* cls_struct_fields[5];
+ ffi_type cls_struct_type;
+ ffi_type* dbl_arg_types[5];
+
+ struct cls_struct_4_1byte g_dbl = { 12, 13, 14, 15 };
+ struct cls_struct_4_1byte f_dbl = { 178, 179, 180, 181 };
+ struct cls_struct_4_1byte res_dbl;
+
+ cls_struct_type.size = 0;
+ cls_struct_type.alignment = 0;
+ cls_struct_type.type = FFI_TYPE_STRUCT;
+ cls_struct_type.elements = cls_struct_fields;
+
+ cls_struct_fields[0] = &ffi_type_uchar;
+ cls_struct_fields[1] = &ffi_type_uchar;
+ cls_struct_fields[2] = &ffi_type_uchar;
+ cls_struct_fields[3] = &ffi_type_uchar;
+ cls_struct_fields[4] = NULL;
+
+ dbl_arg_types[0] = &cls_struct_type;
+ dbl_arg_types[1] = &cls_struct_type;
+ dbl_arg_types[2] = NULL;
+
+ CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 2, &cls_struct_type,
+ dbl_arg_types) == FFI_OK);
+
+ args_dbl[0] = &g_dbl;
+ args_dbl[1] = &f_dbl;
+ args_dbl[2] = NULL;
+
+ ffi_call(&cif, FFI_FN(cls_struct_4_1byte_fn), &res_dbl, args_dbl);
+ /* { dg-output "12 13 14 15 178 179 180 181: 190 192 194 196" } */
+ printf("res: %d %d %d %d\n", res_dbl.a, res_dbl.b, res_dbl.c, res_dbl.d);
+ /* { dg-output "\nres: 190 192 194 196" } */
+
+ CHECK(ffi_prep_closure_loc(pcl, &cif, cls_struct_4_1byte_gn, NULL, code) == FFI_OK);
+
+ res_dbl = ((cls_struct_4_1byte(*)(cls_struct_4_1byte, cls_struct_4_1byte))(code))(g_dbl, f_dbl);
+ /* { dg-output "\n12 13 14 15 178 179 180 181: 190 192 194 196" } */
+ printf("res: %d %d %d %d\n", res_dbl.a, res_dbl.b, res_dbl.c, res_dbl.d);
+ /* { dg-output "\nres: 190 192 194 196" } */
+
+ exit(0);
+}
diff --git a/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/cls_4byte.c b/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/cls_4byte.c
new file mode 100644
index 0000000..4ac3787
--- /dev/null
+++ b/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/cls_4byte.c
@@ -0,0 +1,90 @@
+/* Area: ffi_call, closure_call
+ Purpose: Check structure passing with different structure size.
+ Depending on the ABI. Check overlapping.
+ Limitations: none.
+ PR: none.
+ Originator: <andreast@gcc.gnu.org> 20030828 */
+
+/* { dg-do run } */
+
+#include "ffitest.h"
+
+typedef struct cls_struct_4byte {
+ unsigned short a;
+ unsigned short b;
+} cls_struct_4byte;
+
+cls_struct_4byte cls_struct_4byte_fn(struct cls_struct_4byte a1,
+ struct cls_struct_4byte a2)
+{
+ struct cls_struct_4byte result;
+
+ result.a = a1.a + a2.a;
+ result.b = a1.b + a2.b;
+
+ printf("%d %d %d %d: %d %d\n", a1.a, a1.b, a2.a, a2.b, result.a, result.b);
+
+ return result;
+}
+
+static void
+cls_struct_4byte_gn(ffi_cif* cif __UNUSED__, void* resp, void** args,
+ void* userdata __UNUSED__)
+{
+
+ struct cls_struct_4byte a1, a2;
+
+ a1 = *(struct cls_struct_4byte*)(args[0]);
+ a2 = *(struct cls_struct_4byte*)(args[1]);
+
+ *(cls_struct_4byte*)resp = cls_struct_4byte_fn(a1, a2);
+}
+
+int main (void)
+{
+ ffi_cif cif;
+ void *code;
+ ffi_closure *pcl = ffi_closure_alloc(sizeof(ffi_closure), &code);
+ void* args_dbl[5];
+ ffi_type* cls_struct_fields[4];
+ ffi_type cls_struct_type;
+ ffi_type* dbl_arg_types[5];
+
+ struct cls_struct_4byte g_dbl = { 127, 120 };
+ struct cls_struct_4byte f_dbl = { 12, 128 };
+ struct cls_struct_4byte res_dbl;
+
+ cls_struct_type.size = 0;
+ cls_struct_type.alignment = 0;
+ cls_struct_type.type = FFI_TYPE_STRUCT;
+ cls_struct_type.elements = cls_struct_fields;
+
+ cls_struct_fields[0] = &ffi_type_ushort;
+ cls_struct_fields[1] = &ffi_type_ushort;
+ cls_struct_fields[2] = NULL;
+
+ dbl_arg_types[0] = &cls_struct_type;
+ dbl_arg_types[1] = &cls_struct_type;
+ dbl_arg_types[2] = NULL;
+
+ CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 2, &cls_struct_type,
+ dbl_arg_types) == FFI_OK);
+
+ args_dbl[0] = &g_dbl;
+ args_dbl[1] = &f_dbl;
+ args_dbl[2] = NULL;
+
+ ffi_call(&cif, FFI_FN(cls_struct_4byte_fn), &res_dbl, args_dbl);
+ /* { dg-output "127 120 12 128: 139 248" } */
+ printf("res: %d %d\n", res_dbl.a, res_dbl.b);
+ /* { dg-output "\nres: 139 248" } */
+
+ CHECK(ffi_prep_closure_loc(pcl, &cif, cls_struct_4byte_gn, NULL, code) == FFI_OK);
+
+ res_dbl = ((cls_struct_4byte(*)(cls_struct_4byte, cls_struct_4byte))(code))(g_dbl, f_dbl);
+ /* { dg-output "\n127 120 12 128: 139 248" } */
+ printf("res: %d %d\n", res_dbl.a, res_dbl.b);
+ /* { dg-output "\nres: 139 248" } */
+
+ exit(0);
+}
diff --git a/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/cls_5_1_byte.c b/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/cls_5_1_byte.c
new file mode 100644
index 0000000..ad9d51c
--- /dev/null
+++ b/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/cls_5_1_byte.c
@@ -0,0 +1,109 @@
+/* Area: ffi_call, closure_call
+ Purpose: Check structure passing with different structure size.
+ Depending on the ABI. Check overlapping.
+ Limitations: none.
+ PR: none.
+ Originator: <andreast@gcc.gnu.org> 20050708 */
+
+/* { dg-do run } */
+#include "ffitest.h"
+
+typedef struct cls_struct_5byte {
+ unsigned char a;
+ unsigned char b;
+ unsigned char c;
+ unsigned char d;
+ unsigned char e;
+} cls_struct_5byte;
+
+cls_struct_5byte cls_struct_5byte_fn(struct cls_struct_5byte a1,
+ struct cls_struct_5byte a2)
+{
+ struct cls_struct_5byte result;
+
+ result.a = a1.a + a2.a;
+ result.b = a1.b + a2.b;
+ result.c = a1.c + a2.c;
+ result.d = a1.d + a2.d;
+ result.e = a1.e + a2.e;
+
+ printf("%d %d %d %d %d %d %d %d %d %d: %d %d %d %d %d\n",
+ a1.a, a1.b, a1.c, a1.d, a1.e,
+ a2.a, a2.b, a2.c, a2.d, a2.e,
+ result.a, result.b, result.c, result.d, result.e);
+
+ return result;
+}
+
+static void
+cls_struct_5byte_gn(ffi_cif* cif __UNUSED__, void* resp, void** args,
+ void* userdata __UNUSED__)
+{
+
+ struct cls_struct_5byte a1, a2;
+
+ a1 = *(struct cls_struct_5byte*)(args[0]);
+ a2 = *(struct cls_struct_5byte*)(args[1]);
+
+ *(cls_struct_5byte*)resp = cls_struct_5byte_fn(a1, a2);
+}
+
+int main (void)
+{
+ ffi_cif cif;
+ void *code;
+ ffi_closure *pcl = ffi_closure_alloc(sizeof(ffi_closure), &code);
+ void* args_dbl[5];
+ ffi_type* cls_struct_fields[6];
+ ffi_type cls_struct_type;
+ ffi_type* dbl_arg_types[5];
+
+ struct cls_struct_5byte g_dbl = { 127, 120, 1, 3, 4 };
+ struct cls_struct_5byte f_dbl = { 12, 128, 9, 3, 4 };
+ struct cls_struct_5byte res_dbl = { 0, 0, 0, 0, 0 };
+
+ cls_struct_type.size = 0;
+ cls_struct_type.alignment = 0;
+ cls_struct_type.type = FFI_TYPE_STRUCT;
+ cls_struct_type.elements = cls_struct_fields;
+
+ cls_struct_fields[0] = &ffi_type_uchar;
+ cls_struct_fields[1] = &ffi_type_uchar;
+ cls_struct_fields[2] = &ffi_type_uchar;
+ cls_struct_fields[3] = &ffi_type_uchar;
+ cls_struct_fields[4] = &ffi_type_uchar;
+ cls_struct_fields[5] = NULL;
+
+ dbl_arg_types[0] = &cls_struct_type;
+ dbl_arg_types[1] = &cls_struct_type;
+ dbl_arg_types[2] = NULL;
+
+ CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 2, &cls_struct_type,
+ dbl_arg_types) == FFI_OK);
+
+ args_dbl[0] = &g_dbl;
+ args_dbl[1] = &f_dbl;
+ args_dbl[2] = NULL;
+
+ ffi_call(&cif, FFI_FN(cls_struct_5byte_fn), &res_dbl, args_dbl);
+ /* { dg-output "127 120 1 3 4 12 128 9 3 4: 139 248 10 6 8" } */
+ printf("res: %d %d %d %d %d\n", res_dbl.a, res_dbl.b, res_dbl.c,
+ res_dbl.d, res_dbl.e);
+ /* { dg-output "\nres: 139 248 10 6 8" } */
+
+ res_dbl.a = 0;
+ res_dbl.b = 0;
+ res_dbl.c = 0;
+ res_dbl.d = 0;
+ res_dbl.e = 0;
+
+ CHECK(ffi_prep_closure_loc(pcl, &cif, cls_struct_5byte_gn, NULL, code) == FFI_OK);
+
+ res_dbl = ((cls_struct_5byte(*)(cls_struct_5byte, cls_struct_5byte))(code))(g_dbl, f_dbl);
+ /* { dg-output "\n127 120 1 3 4 12 128 9 3 4: 139 248 10 6 8" } */
+ printf("res: %d %d %d %d %d\n", res_dbl.a, res_dbl.b, res_dbl.c,
+ res_dbl.d, res_dbl.e);
+ /* { dg-output "\nres: 139 248 10 6 8" } */
+
+ exit(0);
+}
diff --git a/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/cls_5byte.c b/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/cls_5byte.c
new file mode 100644
index 0000000..4e0c000
--- /dev/null
+++ b/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/cls_5byte.c
@@ -0,0 +1,98 @@
+/* Area: ffi_call, closure_call
+ Purpose: Check structure passing with different structure size.
+ Depending on the ABI. Check overlapping.
+ Limitations: none.
+ PR: none.
+ Originator: <andreast@gcc.gnu.org> 20030828 */
+
+/* { dg-do run } */
+#include "ffitest.h"
+
+typedef struct cls_struct_5byte {
+ unsigned short a;
+ unsigned short b;
+ unsigned char c;
+} cls_struct_5byte;
+
+cls_struct_5byte cls_struct_5byte_fn(struct cls_struct_5byte a1,
+ struct cls_struct_5byte a2)
+{
+ struct cls_struct_5byte result;
+
+ result.a = a1.a + a2.a;
+ result.b = a1.b + a2.b;
+ result.c = a1.c + a2.c;
+
+ printf("%d %d %d %d %d %d: %d %d %d\n", a1.a, a1.b, a1.c,
+ a2.a, a2.b, a2.c,
+ result.a, result.b, result.c);
+
+ return result;
+}
+
+static void
+cls_struct_5byte_gn(ffi_cif* cif __UNUSED__, void* resp, void** args,
+ void* userdata __UNUSED__)
+{
+
+ struct cls_struct_5byte a1, a2;
+
+ a1 = *(struct cls_struct_5byte*)(args[0]);
+ a2 = *(struct cls_struct_5byte*)(args[1]);
+
+ *(cls_struct_5byte*)resp = cls_struct_5byte_fn(a1, a2);
+}
+
+int main (void)
+{
+ ffi_cif cif;
+ void *code;
+ ffi_closure *pcl = ffi_closure_alloc(sizeof(ffi_closure), &code);
+ void* args_dbl[5];
+ ffi_type* cls_struct_fields[4];
+ ffi_type cls_struct_type;
+ ffi_type* dbl_arg_types[5];
+
+ struct cls_struct_5byte g_dbl = { 127, 120, 1 };
+ struct cls_struct_5byte f_dbl = { 12, 128, 9 };
+ struct cls_struct_5byte res_dbl = { 0, 0, 0 };
+
+ cls_struct_type.size = 0;
+ cls_struct_type.alignment = 0;
+ cls_struct_type.type = FFI_TYPE_STRUCT;
+ cls_struct_type.elements = cls_struct_fields;
+
+ cls_struct_fields[0] = &ffi_type_ushort;
+ cls_struct_fields[1] = &ffi_type_ushort;
+ cls_struct_fields[2] = &ffi_type_uchar;
+ cls_struct_fields[3] = NULL;
+
+ dbl_arg_types[0] = &cls_struct_type;
+ dbl_arg_types[1] = &cls_struct_type;
+ dbl_arg_types[2] = NULL;
+
+ CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 2, &cls_struct_type,
+ dbl_arg_types) == FFI_OK);
+
+ args_dbl[0] = &g_dbl;
+ args_dbl[1] = &f_dbl;
+ args_dbl[2] = NULL;
+
+ ffi_call(&cif, FFI_FN(cls_struct_5byte_fn), &res_dbl, args_dbl);
+ /* { dg-output "127 120 1 12 128 9: 139 248 10" } */
+ printf("res: %d %d %d\n", res_dbl.a, res_dbl.b, res_dbl.c);
+ /* { dg-output "\nres: 139 248 10" } */
+
+ res_dbl.a = 0;
+ res_dbl.b = 0;
+ res_dbl.c = 0;
+
+ CHECK(ffi_prep_closure_loc(pcl, &cif, cls_struct_5byte_gn, NULL, code) == FFI_OK);
+
+ res_dbl = ((cls_struct_5byte(*)(cls_struct_5byte, cls_struct_5byte))(code))(g_dbl, f_dbl);
+ /* { dg-output "\n127 120 1 12 128 9: 139 248 10" } */
+ printf("res: %d %d %d\n", res_dbl.a, res_dbl.b, res_dbl.c);
+ /* { dg-output "\nres: 139 248 10" } */
+
+ exit(0);
+}
diff --git a/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/cls_64byte.c b/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/cls_64byte.c
new file mode 100644
index 0000000..a55edc2
--- /dev/null
+++ b/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/cls_64byte.c
@@ -0,0 +1,124 @@
+/* Area: ffi_call, closure_call
+ Purpose: Check structure passing with different structure size.
+ Depending on the ABI. Check bigger struct which overlaps
+ the gp and fp register count on Darwin/AIX/ppc64.
+ Limitations: none.
+ PR: none.
+ Originator: <andreast@gcc.gnu.org> 20030828 */
+
+/* { dg-do run } */
+#include "ffitest.h"
+
+typedef struct cls_struct_64byte {
+ double a;
+ double b;
+ double c;
+ double d;
+ double e;
+ double f;
+ double g;
+ double h;
+} cls_struct_64byte;
+
+cls_struct_64byte cls_struct_64byte_fn(struct cls_struct_64byte b0,
+ struct cls_struct_64byte b1,
+ struct cls_struct_64byte b2,
+ struct cls_struct_64byte b3)
+{
+ struct cls_struct_64byte result;
+
+ result.a = b0.a + b1.a + b2.a + b3.a;
+ result.b = b0.b + b1.b + b2.b + b3.b;
+ result.c = b0.c + b1.c + b2.c + b3.c;
+ result.d = b0.d + b1.d + b2.d + b3.d;
+ result.e = b0.e + b1.e + b2.e + b3.e;
+ result.f = b0.f + b1.f + b2.f + b3.f;
+ result.g = b0.g + b1.g + b2.g + b3.g;
+ result.h = b0.h + b1.h + b2.h + b3.h;
+
+ printf("%g %g %g %g %g %g %g %g\n", result.a, result.b, result.c,
+ result.d, result.e, result.f, result.g, result.h);
+
+ return result;
+}
+
+static void
+cls_struct_64byte_gn(ffi_cif* cif __UNUSED__, void* resp, void** args,
+ void* userdata __UNUSED__)
+{
+ struct cls_struct_64byte b0, b1, b2, b3;
+
+ b0 = *(struct cls_struct_64byte*)(args[0]);
+ b1 = *(struct cls_struct_64byte*)(args[1]);
+ b2 = *(struct cls_struct_64byte*)(args[2]);
+ b3 = *(struct cls_struct_64byte*)(args[3]);
+
+ *(cls_struct_64byte*)resp = cls_struct_64byte_fn(b0, b1, b2, b3);
+}
+
+int main (void)
+{
+ ffi_cif cif;
+ void *code;
+ ffi_closure *pcl = ffi_closure_alloc(sizeof(ffi_closure), &code);
+ void* args_dbl[5];
+ ffi_type* cls_struct_fields[9];
+ ffi_type cls_struct_type;
+ ffi_type* dbl_arg_types[5];
+
+ struct cls_struct_64byte e_dbl = { 9.0, 2.0, 6.0, 5.0, 3.0, 4.0, 8.0, 1.0 };
+ struct cls_struct_64byte f_dbl = { 1.0, 2.0, 3.0, 7.0, 2.0, 5.0, 6.0, 7.0 };
+ struct cls_struct_64byte g_dbl = { 4.0, 5.0, 7.0, 9.0, 1.0, 1.0, 2.0, 9.0 };
+ struct cls_struct_64byte h_dbl = { 8.0, 6.0, 1.0, 4.0, 0.0, 3.0, 3.0, 1.0 };
+ struct cls_struct_64byte res_dbl;
+
+ cls_struct_type.size = 0;
+ cls_struct_type.alignment = 0;
+ cls_struct_type.type = FFI_TYPE_STRUCT;
+ cls_struct_type.elements = cls_struct_fields;
+
+ cls_struct_fields[0] = &ffi_type_double;
+ cls_struct_fields[1] = &ffi_type_double;
+ cls_struct_fields[2] = &ffi_type_double;
+ cls_struct_fields[3] = &ffi_type_double;
+ cls_struct_fields[4] = &ffi_type_double;
+ cls_struct_fields[5] = &ffi_type_double;
+ cls_struct_fields[6] = &ffi_type_double;
+ cls_struct_fields[7] = &ffi_type_double;
+ cls_struct_fields[8] = NULL;
+
+ dbl_arg_types[0] = &cls_struct_type;
+ dbl_arg_types[1] = &cls_struct_type;
+ dbl_arg_types[2] = &cls_struct_type;
+ dbl_arg_types[3] = &cls_struct_type;
+ dbl_arg_types[4] = NULL;
+
+ CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 4, &cls_struct_type,
+ dbl_arg_types) == FFI_OK);
+
+ args_dbl[0] = &e_dbl;
+ args_dbl[1] = &f_dbl;
+ args_dbl[2] = &g_dbl;
+ args_dbl[3] = &h_dbl;
+ args_dbl[4] = NULL;
+
+ ffi_call(&cif, FFI_FN(cls_struct_64byte_fn), &res_dbl, args_dbl);
+ /* { dg-output "22 15 17 25 6 13 19 18" } */
+ printf("res: %g %g %g %g %g %g %g %g\n", res_dbl.a, res_dbl.b, res_dbl.c,
+ res_dbl.d, res_dbl.e, res_dbl.f, res_dbl.g, res_dbl.h);
+ /* { dg-output "\nres: 22 15 17 25 6 13 19 18" } */
+
+ CHECK(ffi_prep_closure_loc(pcl, &cif, cls_struct_64byte_gn, NULL, code) == FFI_OK);
+
+ res_dbl = ((cls_struct_64byte(*)(cls_struct_64byte,
+ cls_struct_64byte,
+ cls_struct_64byte,
+ cls_struct_64byte))
+ (code))(e_dbl, f_dbl, g_dbl, h_dbl);
+ /* { dg-output "\n22 15 17 25 6 13 19 18" } */
+ printf("res: %g %g %g %g %g %g %g %g\n", res_dbl.a, res_dbl.b, res_dbl.c,
+ res_dbl.d, res_dbl.e, res_dbl.f, res_dbl.g, res_dbl.h);
+ /* { dg-output "\nres: 22 15 17 25 6 13 19 18" } */
+
+ exit(0);
+}
diff --git a/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/cls_6_1_byte.c b/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/cls_6_1_byte.c
new file mode 100644
index 0000000..b4dcdba
--- /dev/null
+++ b/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/cls_6_1_byte.c
@@ -0,0 +1,113 @@
+/* Area: ffi_call, closure_call
+ Purpose: Check structure passing with different structure size.
+ Depending on the ABI. Check overlapping.
+ Limitations: none.
+ PR: none.
+ Originator: <andreast@gcc.gnu.org> 20050708 */
+
+/* { dg-do run } */
+#include "ffitest.h"
+
+typedef struct cls_struct_6byte {
+ unsigned char a;
+ unsigned char b;
+ unsigned char c;
+ unsigned char d;
+ unsigned char e;
+ unsigned char f;
+} cls_struct_6byte;
+
+cls_struct_6byte cls_struct_6byte_fn(struct cls_struct_6byte a1,
+ struct cls_struct_6byte a2)
+{
+ struct cls_struct_6byte result;
+
+ result.a = a1.a + a2.a;
+ result.b = a1.b + a2.b;
+ result.c = a1.c + a2.c;
+ result.d = a1.d + a2.d;
+ result.e = a1.e + a2.e;
+ result.f = a1.f + a2.f;
+
+ printf("%d %d %d %d %d %d %d %d %d %d %d %d: %d %d %d %d %d %d\n",
+ a1.a, a1.b, a1.c, a1.d, a1.e, a1.f,
+ a2.a, a2.b, a2.c, a2.d, a2.e, a2.f,
+ result.a, result.b, result.c, result.d, result.e, result.f);
+
+ return result;
+}
+
+static void
+cls_struct_6byte_gn(ffi_cif* cif __UNUSED__, void* resp, void** args,
+ void* userdata __UNUSED__)
+{
+
+ struct cls_struct_6byte a1, a2;
+
+ a1 = *(struct cls_struct_6byte*)(args[0]);
+ a2 = *(struct cls_struct_6byte*)(args[1]);
+
+ *(cls_struct_6byte*)resp = cls_struct_6byte_fn(a1, a2);
+}
+
+int main (void)
+{
+ ffi_cif cif;
+ void *code;
+ ffi_closure *pcl = ffi_closure_alloc(sizeof(ffi_closure), &code);
+ void* args_dbl[5];
+ ffi_type* cls_struct_fields[7];
+ ffi_type cls_struct_type;
+ ffi_type* dbl_arg_types[5];
+
+ struct cls_struct_6byte g_dbl = { 127, 120, 1, 3, 4, 5 };
+ struct cls_struct_6byte f_dbl = { 12, 128, 9, 3, 4, 5 };
+ struct cls_struct_6byte res_dbl = { 0, 0, 0, 0, 0, 0 };
+
+ cls_struct_type.size = 0;
+ cls_struct_type.alignment = 0;
+ cls_struct_type.type = FFI_TYPE_STRUCT;
+ cls_struct_type.elements = cls_struct_fields;
+
+ cls_struct_fields[0] = &ffi_type_uchar;
+ cls_struct_fields[1] = &ffi_type_uchar;
+ cls_struct_fields[2] = &ffi_type_uchar;
+ cls_struct_fields[3] = &ffi_type_uchar;
+ cls_struct_fields[4] = &ffi_type_uchar;
+ cls_struct_fields[5] = &ffi_type_uchar;
+ cls_struct_fields[6] = NULL;
+
+ dbl_arg_types[0] = &cls_struct_type;
+ dbl_arg_types[1] = &cls_struct_type;
+ dbl_arg_types[2] = NULL;
+
+ CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 2, &cls_struct_type,
+ dbl_arg_types) == FFI_OK);
+
+ args_dbl[0] = &g_dbl;
+ args_dbl[1] = &f_dbl;
+ args_dbl[2] = NULL;
+
+ ffi_call(&cif, FFI_FN(cls_struct_6byte_fn), &res_dbl, args_dbl);
+ /* { dg-output "127 120 1 3 4 5 12 128 9 3 4 5: 139 248 10 6 8 10" } */
+ printf("res: %d %d %d %d %d %d\n", res_dbl.a, res_dbl.b, res_dbl.c,
+ res_dbl.d, res_dbl.e, res_dbl.f);
+ /* { dg-output "\nres: 139 248 10 6 8 10" } */
+
+ res_dbl.a = 0;
+ res_dbl.b = 0;
+ res_dbl.c = 0;
+ res_dbl.d = 0;
+ res_dbl.e = 0;
+ res_dbl.f = 0;
+
+ CHECK(ffi_prep_closure_loc(pcl, &cif, cls_struct_6byte_gn, NULL, code) == FFI_OK);
+
+ res_dbl = ((cls_struct_6byte(*)(cls_struct_6byte, cls_struct_6byte))(code))(g_dbl, f_dbl);
+ /* { dg-output "\n127 120 1 3 4 5 12 128 9 3 4 5: 139 248 10 6 8 10" } */
+ printf("res: %d %d %d %d %d %d\n", res_dbl.a, res_dbl.b, res_dbl.c,
+ res_dbl.d, res_dbl.e, res_dbl.f);
+ /* { dg-output "\nres: 139 248 10 6 8 10" } */
+
+ exit(0);
+}
diff --git a/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/cls_6byte.c b/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/cls_6byte.c
new file mode 100644
index 0000000..7406780
--- /dev/null
+++ b/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/cls_6byte.c
@@ -0,0 +1,99 @@
+/* Area: ffi_call, closure_call
+ Purpose: Check structure passing with different structure size.
+ Depending on the ABI. Check overlapping.
+ Limitations: none.
+ PR: none.
+ Originator: <andreast@gcc.gnu.org> 20030828 */
+
+
+/* { dg-do run } */
+#include "ffitest.h"
+
+typedef struct cls_struct_6byte {
+ unsigned short a;
+ unsigned short b;
+ unsigned char c;
+ unsigned char d;
+} cls_struct_6byte;
+
+cls_struct_6byte cls_struct_6byte_fn(struct cls_struct_6byte a1,
+ struct cls_struct_6byte a2)
+{
+ struct cls_struct_6byte result;
+
+ result.a = a1.a + a2.a;
+ result.b = a1.b + a2.b;
+ result.c = a1.c + a2.c;
+ result.d = a1.d + a2.d;
+
+ printf("%d %d %d %d %d %d %d %d: %d %d %d %d\n", a1.a, a1.b, a1.c, a1.d,
+ a2.a, a2.b, a2.c, a2.d,
+ result.a, result.b, result.c, result.d);
+
+ return result;
+}
+
+static void
+cls_struct_6byte_gn(ffi_cif* cif __UNUSED__, void* resp, void** args,
+ void* userdata __UNUSED__)
+{
+
+ struct cls_struct_6byte a1, a2;
+
+ a1 = *(struct cls_struct_6byte*)(args[0]);
+ a2 = *(struct cls_struct_6byte*)(args[1]);
+
+ *(cls_struct_6byte*)resp = cls_struct_6byte_fn(a1, a2);
+}
+
+int main (void)
+{
+ ffi_cif cif;
+ void *code;
+ ffi_closure *pcl = ffi_closure_alloc(sizeof(ffi_closure), &code);
+ void* args_dbl[5];
+ ffi_type* cls_struct_fields[5];
+ ffi_type cls_struct_type;
+ ffi_type* dbl_arg_types[5];
+
+ struct cls_struct_6byte g_dbl = { 127, 120, 1, 128 };
+ struct cls_struct_6byte f_dbl = { 12, 128, 9, 127 };
+ struct cls_struct_6byte res_dbl;
+
+ cls_struct_type.size = 0;
+ cls_struct_type.alignment = 0;
+ cls_struct_type.type = FFI_TYPE_STRUCT;
+ cls_struct_type.elements = cls_struct_fields;
+
+ cls_struct_fields[0] = &ffi_type_ushort;
+ cls_struct_fields[1] = &ffi_type_ushort;
+ cls_struct_fields[2] = &ffi_type_uchar;
+ cls_struct_fields[3] = &ffi_type_uchar;
+ cls_struct_fields[4] = NULL;
+
+ dbl_arg_types[0] = &cls_struct_type;
+ dbl_arg_types[1] = &cls_struct_type;
+ dbl_arg_types[2] = NULL;
+
+ CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 2, &cls_struct_type,
+ dbl_arg_types) == FFI_OK);
+
+ args_dbl[0] = &g_dbl;
+ args_dbl[1] = &f_dbl;
+ args_dbl[2] = NULL;
+
+ ffi_call(&cif, FFI_FN(cls_struct_6byte_fn), &res_dbl, args_dbl);
+ /* { dg-output "127 120 1 128 12 128 9 127: 139 248 10 255" } */
+ printf("res: %d %d %d %d\n", res_dbl.a, res_dbl.b, res_dbl.c, res_dbl.d);
+ /* { dg-output "\nres: 139 248 10 255" } */
+
+ CHECK(ffi_prep_closure_loc(pcl, &cif, cls_struct_6byte_gn, NULL, code) == FFI_OK);
+
+ res_dbl = ((cls_struct_6byte(*)(cls_struct_6byte, cls_struct_6byte))(code))(g_dbl, f_dbl);
+ /* { dg-output "\n127 120 1 128 12 128 9 127: 139 248 10 255" } */
+ printf("res: %d %d %d %d\n", res_dbl.a, res_dbl.b, res_dbl.c, res_dbl.d);
+ /* { dg-output "\nres: 139 248 10 255" } */
+
+
+ exit(0);
+}
diff --git a/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/cls_7_1_byte.c b/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/cls_7_1_byte.c
new file mode 100644
index 0000000..14a7e96
--- /dev/null
+++ b/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/cls_7_1_byte.c
@@ -0,0 +1,117 @@
+/* Area: ffi_call, closure_call
+ Purpose: Check structure passing with different structure size.
+ Depending on the ABI. Check overlapping.
+ Limitations: none.
+ PR: none.
+ Originator: <andreast@gcc.gnu.org> 20050708 */
+
+/* { dg-do run } */
+#include "ffitest.h"
+
+typedef struct cls_struct_7byte {
+ unsigned char a;
+ unsigned char b;
+ unsigned char c;
+ unsigned char d;
+ unsigned char e;
+ unsigned char f;
+ unsigned char g;
+} cls_struct_7byte;
+
+cls_struct_7byte cls_struct_7byte_fn(struct cls_struct_7byte a1,
+ struct cls_struct_7byte a2)
+{
+ struct cls_struct_7byte result;
+
+ result.a = a1.a + a2.a;
+ result.b = a1.b + a2.b;
+ result.c = a1.c + a2.c;
+ result.d = a1.d + a2.d;
+ result.e = a1.e + a2.e;
+ result.f = a1.f + a2.f;
+ result.g = a1.g + a2.g;
+
+ printf("%d %d %d %d %d %d %d %d %d %d %d %d %d %d: %d %d %d %d %d %d %d\n",
+ a1.a, a1.b, a1.c, a1.d, a1.e, a1.f, a1.g,
+ a2.a, a2.b, a2.c, a2.d, a2.e, a2.f, a2.g,
+ result.a, result.b, result.c, result.d, result.e, result.f, result.g);
+
+ return result;
+}
+
+static void
+cls_struct_7byte_gn(ffi_cif* cif __UNUSED__, void* resp, void** args,
+ void* userdata __UNUSED__)
+{
+
+ struct cls_struct_7byte a1, a2;
+
+ a1 = *(struct cls_struct_7byte*)(args[0]);
+ a2 = *(struct cls_struct_7byte*)(args[1]);
+
+ *(cls_struct_7byte*)resp = cls_struct_7byte_fn(a1, a2);
+}
+
+int main (void)
+{
+ ffi_cif cif;
+ void *code;
+ ffi_closure *pcl = ffi_closure_alloc(sizeof(ffi_closure), &code);
+ void* args_dbl[5];
+ ffi_type* cls_struct_fields[8];
+ ffi_type cls_struct_type;
+ ffi_type* dbl_arg_types[5];
+
+ struct cls_struct_7byte g_dbl = { 127, 120, 1, 3, 4, 5, 6 };
+ struct cls_struct_7byte f_dbl = { 12, 128, 9, 3, 4, 5, 6 };
+ struct cls_struct_7byte res_dbl = { 0, 0, 0, 0, 0, 0, 0 };
+
+ cls_struct_type.size = 0;
+ cls_struct_type.alignment = 0;
+ cls_struct_type.type = FFI_TYPE_STRUCT;
+ cls_struct_type.elements = cls_struct_fields;
+
+ cls_struct_fields[0] = &ffi_type_uchar;
+ cls_struct_fields[1] = &ffi_type_uchar;
+ cls_struct_fields[2] = &ffi_type_uchar;
+ cls_struct_fields[3] = &ffi_type_uchar;
+ cls_struct_fields[4] = &ffi_type_uchar;
+ cls_struct_fields[5] = &ffi_type_uchar;
+ cls_struct_fields[6] = &ffi_type_uchar;
+ cls_struct_fields[7] = NULL;
+
+ dbl_arg_types[0] = &cls_struct_type;
+ dbl_arg_types[1] = &cls_struct_type;
+ dbl_arg_types[2] = NULL;
+
+ CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 2, &cls_struct_type,
+ dbl_arg_types) == FFI_OK);
+
+ args_dbl[0] = &g_dbl;
+ args_dbl[1] = &f_dbl;
+ args_dbl[2] = NULL;
+
+ ffi_call(&cif, FFI_FN(cls_struct_7byte_fn), &res_dbl, args_dbl);
+ /* { dg-output "127 120 1 3 4 5 6 12 128 9 3 4 5 6: 139 248 10 6 8 10 12" } */
+ printf("res: %d %d %d %d %d %d %d\n", res_dbl.a, res_dbl.b, res_dbl.c,
+ res_dbl.d, res_dbl.e, res_dbl.f, res_dbl.g);
+ /* { dg-output "\nres: 139 248 10 6 8 10 12" } */
+
+ res_dbl.a = 0;
+ res_dbl.b = 0;
+ res_dbl.c = 0;
+ res_dbl.d = 0;
+ res_dbl.e = 0;
+ res_dbl.f = 0;
+ res_dbl.g = 0;
+
+ CHECK(ffi_prep_closure_loc(pcl, &cif, cls_struct_7byte_gn, NULL, code) == FFI_OK);
+
+ res_dbl = ((cls_struct_7byte(*)(cls_struct_7byte, cls_struct_7byte))(code))(g_dbl, f_dbl);
+ /* { dg-output "\n127 120 1 3 4 5 6 12 128 9 3 4 5 6: 139 248 10 6 8 10 12" } */
+ printf("res: %d %d %d %d %d %d %d\n", res_dbl.a, res_dbl.b, res_dbl.c,
+ res_dbl.d, res_dbl.e, res_dbl.f, res_dbl.g);
+ /* { dg-output "\nres: 139 248 10 6 8 10 12" } */
+
+ exit(0);
+}
diff --git a/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/cls_7byte.c b/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/cls_7byte.c
new file mode 100644
index 0000000..1645cc6
--- /dev/null
+++ b/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/cls_7byte.c
@@ -0,0 +1,97 @@
+/* Area: ffi_call, closure_call
+ Purpose: Check structure passing with different structure size.
+ Depending on the ABI. Check overlapping.
+ Limitations: none.
+ PR: none.
+ Originator: <andreast@gcc.gnu.org> 20030828 */
+
+/* { dg-do run } */
+#include "ffitest.h"
+
+typedef struct cls_struct_7byte {
+ unsigned short a;
+ unsigned short b;
+ unsigned char c;
+ unsigned short d;
+} cls_struct_7byte;
+
+cls_struct_7byte cls_struct_7byte_fn(struct cls_struct_7byte a1,
+ struct cls_struct_7byte a2)
+{
+ struct cls_struct_7byte result;
+
+ result.a = a1.a + a2.a;
+ result.b = a1.b + a2.b;
+ result.c = a1.c + a2.c;
+ result.d = a1.d + a2.d;
+
+ printf("%d %d %d %d %d %d %d %d: %d %d %d %d\n", a1.a, a1.b, a1.c, a1.d,
+ a2.a, a2.b, a2.c, a2.d,
+ result.a, result.b, result.c, result.d);
+
+ return result;
+}
+
+static void
+cls_struct_7byte_gn(ffi_cif* cif __UNUSED__, void* resp, void** args,
+ void* userdata __UNUSED__)
+{
+
+ struct cls_struct_7byte a1, a2;
+
+ a1 = *(struct cls_struct_7byte*)(args[0]);
+ a2 = *(struct cls_struct_7byte*)(args[1]);
+
+ *(cls_struct_7byte*)resp = cls_struct_7byte_fn(a1, a2);
+}
+
+int main (void)
+{
+ ffi_cif cif;
+ void *code;
+ ffi_closure *pcl = ffi_closure_alloc(sizeof(ffi_closure), &code);
+ void* args_dbl[5];
+ ffi_type* cls_struct_fields[5];
+ ffi_type cls_struct_type;
+ ffi_type* dbl_arg_types[5];
+
+ struct cls_struct_7byte g_dbl = { 127, 120, 1, 254 };
+ struct cls_struct_7byte f_dbl = { 12, 128, 9, 255 };
+ struct cls_struct_7byte res_dbl;
+
+ cls_struct_type.size = 0;
+ cls_struct_type.alignment = 0;
+ cls_struct_type.type = FFI_TYPE_STRUCT;
+ cls_struct_type.elements = cls_struct_fields;
+
+ cls_struct_fields[0] = &ffi_type_ushort;
+ cls_struct_fields[1] = &ffi_type_ushort;
+ cls_struct_fields[2] = &ffi_type_uchar;
+ cls_struct_fields[3] = &ffi_type_ushort;
+ cls_struct_fields[4] = NULL;
+
+ dbl_arg_types[0] = &cls_struct_type;
+ dbl_arg_types[1] = &cls_struct_type;
+ dbl_arg_types[2] = NULL;
+
+ CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 2, &cls_struct_type,
+ dbl_arg_types) == FFI_OK);
+
+ args_dbl[0] = &g_dbl;
+ args_dbl[1] = &f_dbl;
+ args_dbl[2] = NULL;
+
+ ffi_call(&cif, FFI_FN(cls_struct_7byte_fn), &res_dbl, args_dbl);
+ /* { dg-output "127 120 1 254 12 128 9 255: 139 248 10 509" } */
+ printf("res: %d %d %d %d\n", res_dbl.a, res_dbl.b, res_dbl.c, res_dbl.d);
+ /* { dg-output "\nres: 139 248 10 509" } */
+
+ CHECK(ffi_prep_closure_loc(pcl, &cif, cls_struct_7byte_gn, NULL, code) == FFI_OK);
+
+ res_dbl = ((cls_struct_7byte(*)(cls_struct_7byte, cls_struct_7byte))(code))(g_dbl, f_dbl);
+ /* { dg-output "\n127 120 1 254 12 128 9 255: 139 248 10 509" } */
+ printf("res: %d %d %d %d\n", res_dbl.a, res_dbl.b, res_dbl.c, res_dbl.d);
+ /* { dg-output "\nres: 139 248 10 509" } */
+
+ exit(0);
+}
diff --git a/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/cls_8byte.c b/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/cls_8byte.c
new file mode 100644
index 0000000..f6c1ea5
--- /dev/null
+++ b/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/cls_8byte.c
@@ -0,0 +1,88 @@
+/* Area: ffi_call, closure_call
+ Purpose: Check structure passing with different structure size.
+ Depending on the ABI. Check overlapping.
+ Limitations: none.
+ PR: none.
+ Originator: <andreast@gcc.gnu.org> 20030828 */
+
+/* { dg-do run } */
+#include "ffitest.h"
+
+typedef struct cls_struct_8byte {
+ int a;
+ float b;
+} cls_struct_8byte;
+
+cls_struct_8byte cls_struct_8byte_fn(struct cls_struct_8byte a1,
+ struct cls_struct_8byte a2)
+{
+ struct cls_struct_8byte result;
+
+ result.a = a1.a + a2.a;
+ result.b = a1.b + a2.b;
+
+ printf("%d %g %d %g: %d %g\n", a1.a, a1.b, a2.a, a2.b, result.a, result.b);
+
+ return result;
+}
+
+static void
+cls_struct_8byte_gn(ffi_cif* cif __UNUSED__, void* resp, void** args,
+ void* userdata __UNUSED__)
+{
+
+ struct cls_struct_8byte a1, a2;
+
+ a1 = *(struct cls_struct_8byte*)(args[0]);
+ a2 = *(struct cls_struct_8byte*)(args[1]);
+
+ *(cls_struct_8byte*)resp = cls_struct_8byte_fn(a1, a2);
+}
+
+int main (void)
+{
+ ffi_cif cif;
+ void *code;
+ ffi_closure *pcl = ffi_closure_alloc(sizeof(ffi_closure), &code);
+ void* args_dbl[5];
+ ffi_type* cls_struct_fields[4];
+ ffi_type cls_struct_type;
+ ffi_type* dbl_arg_types[5];
+
+ struct cls_struct_8byte g_dbl = { 1, 2.0 };
+ struct cls_struct_8byte f_dbl = { 4, 5.0 };
+ struct cls_struct_8byte res_dbl;
+
+ cls_struct_type.size = 0;
+ cls_struct_type.alignment = 0;
+ cls_struct_type.type = FFI_TYPE_STRUCT;
+ cls_struct_type.elements = cls_struct_fields;
+
+ cls_struct_fields[0] = &ffi_type_sint;
+ cls_struct_fields[1] = &ffi_type_float;
+ cls_struct_fields[2] = NULL;
+
+ dbl_arg_types[0] = &cls_struct_type;
+ dbl_arg_types[1] = &cls_struct_type;
+ dbl_arg_types[2] = NULL;
+
+ CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 2, &cls_struct_type,
+ dbl_arg_types) == FFI_OK);
+
+ args_dbl[0] = &g_dbl;
+ args_dbl[1] = &f_dbl;
+ args_dbl[2] = NULL;
+
+ ffi_call(&cif, FFI_FN(cls_struct_8byte_fn), &res_dbl, args_dbl);
+ /* { dg-output "1 2 4 5: 5 7" } */
+ printf("res: %d %g\n", res_dbl.a, res_dbl.b);
+ /* { dg-output "\nres: 5 7" } */
+ CHECK(ffi_prep_closure_loc(pcl, &cif, cls_struct_8byte_gn, NULL, code) == FFI_OK);
+
+ res_dbl = ((cls_struct_8byte(*)(cls_struct_8byte, cls_struct_8byte))(code))(g_dbl, f_dbl);
+ /* { dg-output "\n1 2 4 5: 5 7" } */
+ printf("res: %d %g\n", res_dbl.a, res_dbl.b);
+ /* { dg-output "\nres: 5 7" } */
+
+ exit(0);
+}
diff --git a/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/cls_9byte1.c b/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/cls_9byte1.c
new file mode 100644
index 0000000..0b85722
--- /dev/null
+++ b/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/cls_9byte1.c
@@ -0,0 +1,90 @@
+/* Area: ffi_call, closure_call
+ Purpose: Check structure passing with different structure size.
+ Depending on the ABI. Darwin/AIX do double-word
+ alignment of the struct if the first element is a double.
+ Check that it does not here.
+ Limitations: none.
+ PR: none.
+ Originator: <andreast@gcc.gnu.org> 20030914 */
+
+/* { dg-do run } */
+#include "ffitest.h"
+
+typedef struct cls_struct_9byte {
+ int a;
+ double b;
+} cls_struct_9byte;
+
+cls_struct_9byte cls_struct_9byte_fn(struct cls_struct_9byte b1,
+ struct cls_struct_9byte b2)
+{
+ struct cls_struct_9byte result;
+
+ result.a = b1.a + b2.a;
+ result.b = b1.b + b2.b;
+
+ printf("%d %g %d %g: %d %g\n", b1.a, b1.b, b2.a, b2.b,
+ result.a, result.b);
+
+ return result;
+}
+
+static void cls_struct_9byte_gn(ffi_cif* cif __UNUSED__, void* resp,
+ void** args, void* userdata __UNUSED__)
+{
+ struct cls_struct_9byte b1, b2;
+
+ b1 = *(struct cls_struct_9byte*)(args[0]);
+ b2 = *(struct cls_struct_9byte*)(args[1]);
+
+ *(cls_struct_9byte*)resp = cls_struct_9byte_fn(b1, b2);
+}
+
+int main (void)
+{
+ ffi_cif cif;
+ void *code;
+ ffi_closure *pcl = ffi_closure_alloc(sizeof(ffi_closure), &code);
+ void* args_dbl[3];
+ ffi_type* cls_struct_fields[3];
+ ffi_type cls_struct_type;
+ ffi_type* dbl_arg_types[3];
+
+ struct cls_struct_9byte h_dbl = { 7, 8.0};
+ struct cls_struct_9byte j_dbl = { 1, 9.0};
+ struct cls_struct_9byte res_dbl;
+
+ cls_struct_type.size = 0;
+ cls_struct_type.alignment = 0;
+ cls_struct_type.type = FFI_TYPE_STRUCT;
+ cls_struct_type.elements = cls_struct_fields;
+
+ cls_struct_fields[0] = &ffi_type_sint;
+ cls_struct_fields[1] = &ffi_type_double;
+ cls_struct_fields[2] = NULL;
+
+ dbl_arg_types[0] = &cls_struct_type;
+ dbl_arg_types[1] = &cls_struct_type;
+ dbl_arg_types[2] = NULL;
+
+ CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 2, &cls_struct_type,
+ dbl_arg_types) == FFI_OK);
+
+ args_dbl[0] = &h_dbl;
+ args_dbl[1] = &j_dbl;
+ args_dbl[2] = NULL;
+
+ ffi_call(&cif, FFI_FN(cls_struct_9byte_fn), &res_dbl, args_dbl);
+ /* { dg-output "7 8 1 9: 8 17" } */
+ printf("res: %d %g\n", res_dbl.a, res_dbl.b);
+ /* { dg-output "\nres: 8 17" } */
+
+ CHECK(ffi_prep_closure_loc(pcl, &cif, cls_struct_9byte_gn, NULL, code) == FFI_OK);
+
+ res_dbl = ((cls_struct_9byte(*)(cls_struct_9byte, cls_struct_9byte))(code))(h_dbl, j_dbl);
+ /* { dg-output "\n7 8 1 9: 8 17" } */
+ printf("res: %d %g\n", res_dbl.a, res_dbl.b);
+ /* { dg-output "\nres: 8 17" } */
+
+ exit(0);
+}
diff --git a/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/cls_9byte2.c b/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/cls_9byte2.c
new file mode 100644
index 0000000..edf991d
--- /dev/null
+++ b/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/cls_9byte2.c
@@ -0,0 +1,91 @@
+/* Area: ffi_call, closure_call
+ Purpose: Check structure passing with different structure size.
+ Depending on the ABI. Darwin/AIX do double-word
+ alignment of the struct if the first element is a double.
+ Check that it does here.
+ Limitations: none.
+ PR: none.
+ Originator: <andreast@gcc.gnu.org> 20030914 */
+
+/* { dg-do run } */
+#include "ffitest.h"
+
+typedef struct cls_struct_9byte {
+ double a;
+ int b;
+} cls_struct_9byte;
+
+cls_struct_9byte cls_struct_9byte_fn(struct cls_struct_9byte b1,
+ struct cls_struct_9byte b2)
+{
+ struct cls_struct_9byte result;
+
+ result.a = b1.a + b2.a;
+ result.b = b1.b + b2.b;
+
+ printf("%g %d %g %d: %g %d\n", b1.a, b1.b, b2.a, b2.b,
+ result.a, result.b);
+
+ return result;
+}
+
+static void cls_struct_9byte_gn(ffi_cif* cif __UNUSED__, void* resp,
+ void** args, void* userdata __UNUSED__)
+{
+ struct cls_struct_9byte b1, b2;
+
+ b1 = *(struct cls_struct_9byte*)(args[0]);
+ b2 = *(struct cls_struct_9byte*)(args[1]);
+
+ *(cls_struct_9byte*)resp = cls_struct_9byte_fn(b1, b2);
+}
+
+int main (void)
+{
+ ffi_cif cif;
+ void *code;
+ ffi_closure *pcl = ffi_closure_alloc(sizeof(ffi_closure), &code);
+ void* args_dbl[3];
+ ffi_type* cls_struct_fields[3];
+ ffi_type cls_struct_type;
+ ffi_type* dbl_arg_types[3];
+
+ struct cls_struct_9byte h_dbl = { 7.0, 8};
+ struct cls_struct_9byte j_dbl = { 1.0, 9};
+ struct cls_struct_9byte res_dbl;
+
+ cls_struct_type.size = 0;
+ cls_struct_type.alignment = 0;
+ cls_struct_type.type = FFI_TYPE_STRUCT;
+ cls_struct_type.elements = cls_struct_fields;
+
+ cls_struct_fields[0] = &ffi_type_double;
+ cls_struct_fields[1] = &ffi_type_sint;
+ cls_struct_fields[2] = NULL;
+
+ dbl_arg_types[0] = &cls_struct_type;
+ dbl_arg_types[1] = &cls_struct_type;
+ dbl_arg_types[2] = NULL;
+
+ CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 2, &cls_struct_type,
+ dbl_arg_types) == FFI_OK);
+
+ args_dbl[0] = &h_dbl;
+ args_dbl[1] = &j_dbl;
+ args_dbl[2] = NULL;
+
+ ffi_call(&cif, FFI_FN(cls_struct_9byte_fn), &res_dbl, args_dbl);
+ /* { dg-output "7 8 1 9: 8 17" } */
+ printf("res: %g %d\n", res_dbl.a, res_dbl.b);
+ /* { dg-output "\nres: 8 17" } */
+
+
+ CHECK(ffi_prep_closure_loc(pcl, &cif, cls_struct_9byte_gn, NULL, code) == FFI_OK);
+
+ res_dbl = ((cls_struct_9byte(*)(cls_struct_9byte, cls_struct_9byte))(code))(h_dbl, j_dbl);
+ /* { dg-output "\n7 8 1 9: 8 17" } */
+ printf("res: %g %d\n", res_dbl.a, res_dbl.b);
+ /* { dg-output "\nres: 8 17" } */
+
+ exit(0);
+}
diff --git a/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/cls_align_double.c b/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/cls_align_double.c
new file mode 100644
index 0000000..aad5f3c
--- /dev/null
+++ b/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/cls_align_double.c
@@ -0,0 +1,93 @@
+/* Area: ffi_call, closure_call
+ Purpose: Check structure alignment of double.
+ Limitations: none.
+ PR: none.
+ Originator: <hos@tamanegi.org> 20031203 */
+
+
+
+/* { dg-do run } */
+#include "ffitest.h"
+
+typedef struct cls_struct_align {
+ unsigned char a;
+ double b;
+ unsigned char c;
+} cls_struct_align;
+
+cls_struct_align cls_struct_align_fn(struct cls_struct_align a1,
+ struct cls_struct_align a2)
+{
+ struct cls_struct_align result;
+
+ result.a = a1.a + a2.a;
+ result.b = a1.b + a2.b;
+ result.c = a1.c + a2.c;
+
+ printf("%d %g %d %d %g %d: %d %g %d\n", a1.a, a1.b, a1.c, a2.a, a2.b, a2.c, result.a, result.b, result.c);
+
+ return result;
+}
+
+static void
+cls_struct_align_gn(ffi_cif* cif __UNUSED__, void* resp, void** args,
+ void* userdata __UNUSED__)
+{
+
+ struct cls_struct_align a1, a2;
+
+ a1 = *(struct cls_struct_align*)(args[0]);
+ a2 = *(struct cls_struct_align*)(args[1]);
+
+ *(cls_struct_align*)resp = cls_struct_align_fn(a1, a2);
+}
+
+int main (void)
+{
+ ffi_cif cif;
+ void *code;
+ ffi_closure *pcl = ffi_closure_alloc(sizeof(ffi_closure), &code);
+ void* args_dbl[5];
+ ffi_type* cls_struct_fields[4];
+ ffi_type cls_struct_type;
+ ffi_type* dbl_arg_types[5];
+
+ struct cls_struct_align g_dbl = { 12, 4951, 127 };
+ struct cls_struct_align f_dbl = { 1, 9320, 13 };
+ struct cls_struct_align res_dbl;
+
+ cls_struct_type.size = 0;
+ cls_struct_type.alignment = 0;
+ cls_struct_type.type = FFI_TYPE_STRUCT;
+ cls_struct_type.elements = cls_struct_fields;
+
+ cls_struct_fields[0] = &ffi_type_uchar;
+ cls_struct_fields[1] = &ffi_type_double;
+ cls_struct_fields[2] = &ffi_type_uchar;
+ cls_struct_fields[3] = NULL;
+
+ dbl_arg_types[0] = &cls_struct_type;
+ dbl_arg_types[1] = &cls_struct_type;
+ dbl_arg_types[2] = NULL;
+
+ CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 2, &cls_struct_type,
+ dbl_arg_types) == FFI_OK);
+
+ args_dbl[0] = &g_dbl;
+ args_dbl[1] = &f_dbl;
+ args_dbl[2] = NULL;
+
+ ffi_call(&cif, FFI_FN(cls_struct_align_fn), &res_dbl, args_dbl);
+ /* { dg-output "12 4951 127 1 9320 13: 13 14271 140" } */
+ printf("res: %d %g %d\n", res_dbl.a, res_dbl.b, res_dbl.c);
+ /* { dg-output "\nres: 13 14271 140" } */
+
+ CHECK(ffi_prep_closure_loc(pcl, &cif, cls_struct_align_gn, NULL, code) == FFI_OK);
+
+ res_dbl = ((cls_struct_align(*)(cls_struct_align, cls_struct_align))(code))(g_dbl, f_dbl);
+ /* { dg-output "\n12 4951 127 1 9320 13: 13 14271 140" } */
+ printf("res: %d %g %d\n", res_dbl.a, res_dbl.b, res_dbl.c);
+ /* { dg-output "\nres: 13 14271 140" } */
+
+ exit(0);
+}
diff --git a/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/cls_align_float.c b/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/cls_align_float.c
new file mode 100644
index 0000000..37e0855
--- /dev/null
+++ b/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/cls_align_float.c
@@ -0,0 +1,91 @@
+/* Area: ffi_call, closure_call
+ Purpose: Check structure alignment of float.
+ Limitations: none.
+ PR: none.
+ Originator: <hos@tamanegi.org> 20031203 */
+
+/* { dg-do run } */
+#include "ffitest.h"
+
+typedef struct cls_struct_align {
+ unsigned char a;
+ float b;
+ unsigned char c;
+} cls_struct_align;
+
+cls_struct_align cls_struct_align_fn(struct cls_struct_align a1,
+ struct cls_struct_align a2)
+{
+ struct cls_struct_align result;
+
+ result.a = a1.a + a2.a;
+ result.b = a1.b + a2.b;
+ result.c = a1.c + a2.c;
+
+ printf("%d %g %d %d %g %d: %d %g %d\n", a1.a, (double)a1.b, a1.c, a2.a, (double)a2.b, a2.c, result.a, (double)result.b, result.c);
+
+ return result;
+}
+
+static void
+cls_struct_align_gn(ffi_cif* cif __UNUSED__, void* resp, void** args,
+ void* userdata __UNUSED__)
+{
+
+ struct cls_struct_align a1, a2;
+
+ a1 = *(struct cls_struct_align*)(args[0]);
+ a2 = *(struct cls_struct_align*)(args[1]);
+
+ *(cls_struct_align*)resp = cls_struct_align_fn(a1, a2);
+}
+
+int main (void)
+{
+ ffi_cif cif;
+ void *code;
+ ffi_closure *pcl = ffi_closure_alloc(sizeof(ffi_closure), &code);
+ void* args_dbl[5];
+ ffi_type* cls_struct_fields[4];
+ ffi_type cls_struct_type;
+ ffi_type* dbl_arg_types[5];
+
+ struct cls_struct_align g_dbl = { 12, 4951, 127 };
+ struct cls_struct_align f_dbl = { 1, 9320, 13 };
+ struct cls_struct_align res_dbl;
+
+ cls_struct_type.size = 0;
+ cls_struct_type.alignment = 0;
+ cls_struct_type.type = FFI_TYPE_STRUCT;
+ cls_struct_type.elements = cls_struct_fields;
+
+ cls_struct_fields[0] = &ffi_type_uchar;
+ cls_struct_fields[1] = &ffi_type_float;
+ cls_struct_fields[2] = &ffi_type_uchar;
+ cls_struct_fields[3] = NULL;
+
+ dbl_arg_types[0] = &cls_struct_type;
+ dbl_arg_types[1] = &cls_struct_type;
+ dbl_arg_types[2] = NULL;
+
+ CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 2, &cls_struct_type,
+ dbl_arg_types) == FFI_OK);
+
+ args_dbl[0] = &g_dbl;
+ args_dbl[1] = &f_dbl;
+ args_dbl[2] = NULL;
+
+ ffi_call(&cif, FFI_FN(cls_struct_align_fn), &res_dbl, args_dbl);
+ /* { dg-output "12 4951 127 1 9320 13: 13 14271 140" } */
+ printf("res: %d %g %d\n", res_dbl.a, (double)res_dbl.b, res_dbl.c);
+ /* { dg-output "\nres: 13 14271 140" } */
+
+ CHECK(ffi_prep_closure_loc(pcl, &cif, cls_struct_align_gn, NULL, code) == FFI_OK);
+
+ res_dbl = ((cls_struct_align(*)(cls_struct_align, cls_struct_align))(code))(g_dbl, f_dbl);
+ /* { dg-output "\n12 4951 127 1 9320 13: 13 14271 140" } */
+ printf("res: %d %g %d\n", res_dbl.a, (double)res_dbl.b, res_dbl.c);
+ /* { dg-output "\nres: 13 14271 140" } */
+
+ exit(0);
+}
diff --git a/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/cls_align_longdouble.c b/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/cls_align_longdouble.c
new file mode 100644
index 0000000..b3322d8
--- /dev/null
+++ b/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/cls_align_longdouble.c
@@ -0,0 +1,92 @@
+/* Area: ffi_call, closure_call
+ Purpose: Check structure alignment of long double.
+ Limitations: none.
+ PR: none.
+ Originator: <hos@tamanegi.org> 20031203 */
+
+/* { dg-do run } */
+
+#include "ffitest.h"
+
+typedef struct cls_struct_align {
+ unsigned char a;
+ long double b;
+ unsigned char c;
+} cls_struct_align;
+
+cls_struct_align cls_struct_align_fn(struct cls_struct_align a1,
+ struct cls_struct_align a2)
+{
+ struct cls_struct_align result;
+
+ result.a = a1.a + a2.a;
+ result.b = a1.b + a2.b;
+ result.c = a1.c + a2.c;
+
+ printf("%d %g %d %d %g %d: %d %g %d\n", a1.a, (double)a1.b, a1.c, a2.a, (double)a2.b, a2.c, result.a, (double)result.b, result.c);
+
+ return result;
+}
+
+static void
+cls_struct_align_gn(ffi_cif* cif __UNUSED__, void* resp, void** args,
+ void* userdata __UNUSED__)
+{
+
+ struct cls_struct_align a1, a2;
+
+ a1 = *(struct cls_struct_align*)(args[0]);
+ a2 = *(struct cls_struct_align*)(args[1]);
+
+ *(cls_struct_align*)resp = cls_struct_align_fn(a1, a2);
+}
+
+int main (void)
+{
+ ffi_cif cif;
+ void *code;
+ ffi_closure *pcl = ffi_closure_alloc(sizeof(ffi_closure), &code);
+ void* args_dbl[5];
+ ffi_type* cls_struct_fields[4];
+ ffi_type cls_struct_type;
+ ffi_type* dbl_arg_types[5];
+
+ struct cls_struct_align g_dbl = { 12, 4951, 127 };
+ struct cls_struct_align f_dbl = { 1, 9320, 13 };
+ struct cls_struct_align res_dbl;
+
+ cls_struct_type.size = 0;
+ cls_struct_type.alignment = 0;
+ cls_struct_type.type = FFI_TYPE_STRUCT;
+ cls_struct_type.elements = cls_struct_fields;
+
+ cls_struct_fields[0] = &ffi_type_uchar;
+ cls_struct_fields[1] = &ffi_type_longdouble;
+ cls_struct_fields[2] = &ffi_type_uchar;
+ cls_struct_fields[3] = NULL;
+
+ dbl_arg_types[0] = &cls_struct_type;
+ dbl_arg_types[1] = &cls_struct_type;
+ dbl_arg_types[2] = NULL;
+
+ CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 2, &cls_struct_type,
+ dbl_arg_types) == FFI_OK);
+
+ args_dbl[0] = &g_dbl;
+ args_dbl[1] = &f_dbl;
+ args_dbl[2] = NULL;
+
+ ffi_call(&cif, FFI_FN(cls_struct_align_fn), &res_dbl, args_dbl);
+ /* { dg-output "12 4951 127 1 9320 13: 13 14271 140" } */
+ printf("res: %d %g %d\n", res_dbl.a, (double)res_dbl.b, res_dbl.c);
+ /* { dg-output "\nres: 13 14271 140" } */
+
+ CHECK(ffi_prep_closure_loc(pcl, &cif, cls_struct_align_gn, NULL, code) == FFI_OK);
+
+ res_dbl = ((cls_struct_align(*)(cls_struct_align, cls_struct_align))(code))(g_dbl, f_dbl);
+ /* { dg-output "\n12 4951 127 1 9320 13: 13 14271 140" } */
+ printf("res: %d %g %d\n", res_dbl.a, (double)res_dbl.b, res_dbl.c);
+ /* { dg-output "\nres: 13 14271 140" } */
+
+ exit(0);
+}
diff --git a/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/cls_align_longdouble_split.c b/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/cls_align_longdouble_split.c
new file mode 100644
index 0000000..15f9365
--- /dev/null
+++ b/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/cls_align_longdouble_split.c
@@ -0,0 +1,134 @@
+/* Area: ffi_call, closure_call
+ Purpose: Check structure alignment of long double.
+ Limitations: none.
+ PR: none.
+ Originator: <hos@tamanegi.org> 20031203 */
+
+/* { dg-excess-errors "no long double format" { xfail x86_64-*-mingw* x86_64-*-cygwin* } } */
+/* { dg-do run { xfail strongarm*-*-* xscale*-*-* } } */
+/* { dg-options -mlong-double-128 { target powerpc64*-*-linux* } } */
+/* { dg-output "" { xfail x86_64-*-mingw* x86_64-*-cygwin* } } */
+
+#include "ffitest.h"
+
+typedef struct cls_struct_align {
+ long double a;
+ long double b;
+ long double c;
+ long double d;
+ long double e;
+ long double f;
+ long double g;
+} cls_struct_align;
+
+cls_struct_align cls_struct_align_fn(
+ cls_struct_align a1,
+ cls_struct_align a2)
+{
+ struct cls_struct_align r;
+
+ r.a = a1.a + a2.a;
+ r.b = a1.b + a2.b;
+ r.c = a1.c + a2.c;
+ r.d = a1.d + a2.d;
+ r.e = a1.e + a2.e;
+ r.f = a1.f + a2.f;
+ r.g = a1.g + a2.g;
+
+ printf("%Lg %Lg %Lg %Lg %Lg %Lg %Lg %Lg %Lg %Lg %Lg %Lg %Lg %Lg: "
+ "%Lg %Lg %Lg %Lg %Lg %Lg %Lg\n",
+ a1.a, a1.b, a1.c, a1.d, a1.e, a1.f, a1.g,
+ a2.a, a2.b, a2.c, a2.d, a2.e, a2.f, a2.g,
+ r.a, r.b, r.c, r.d, r.e, r.f, r.g);
+
+ return r;
+}
+
+cls_struct_align cls_struct_align_fn2(
+ cls_struct_align a1)
+{
+ struct cls_struct_align r;
+
+ r.a = a1.a + 1;
+ r.b = a1.b + 1;
+ r.c = a1.c + 1;
+ r.d = a1.d + 1;
+ r.e = a1.e + 1;
+ r.f = a1.f + 1;
+ r.g = a1.g + 1;
+
+ printf("%Lg %Lg %Lg %Lg %Lg %Lg %Lg: "
+ "%Lg %Lg %Lg %Lg %Lg %Lg %Lg\n",
+ a1.a, a1.b, a1.c, a1.d, a1.e, a1.f, a1.g,
+ r.a, r.b, r.c, r.d, r.e, r.f, r.g);
+
+ return r;
+}
+
+static void
+cls_struct_align_gn(ffi_cif* cif __UNUSED__, void* resp, void** args,
+ void* userdata __UNUSED__)
+{
+ struct cls_struct_align a1, a2;
+
+ a1 = *(struct cls_struct_align*)(args[0]);
+ a2 = *(struct cls_struct_align*)(args[1]);
+
+ *(cls_struct_align*)resp = cls_struct_align_fn(a1, a2);
+}
+
+int main (void)
+{
+ ffi_cif cif;
+ void *code;
+ ffi_closure *pcl = ffi_closure_alloc(sizeof(ffi_closure), &code);
+ void* args_dbl[3];
+ ffi_type* cls_struct_fields[8];
+ ffi_type cls_struct_type;
+ ffi_type* dbl_arg_types[3];
+
+ struct cls_struct_align g_dbl = { 1, 2, 3, 4, 5, 6, 7 };
+ struct cls_struct_align f_dbl = { 8, 9, 10, 11, 12, 13, 14 };
+ struct cls_struct_align res_dbl;
+
+ cls_struct_type.size = 0;
+ cls_struct_type.alignment = 0;
+ cls_struct_type.type = FFI_TYPE_STRUCT;
+ cls_struct_type.elements = cls_struct_fields;
+
+ cls_struct_fields[0] = &ffi_type_longdouble;
+ cls_struct_fields[1] = &ffi_type_longdouble;
+ cls_struct_fields[2] = &ffi_type_longdouble;
+ cls_struct_fields[3] = &ffi_type_longdouble;
+ cls_struct_fields[4] = &ffi_type_longdouble;
+ cls_struct_fields[5] = &ffi_type_longdouble;
+ cls_struct_fields[6] = &ffi_type_longdouble;
+ cls_struct_fields[7] = NULL;
+
+ dbl_arg_types[0] = &cls_struct_type;
+ dbl_arg_types[1] = &cls_struct_type;
+ dbl_arg_types[2] = NULL;
+
+ CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 2, &cls_struct_type,
+ dbl_arg_types) == FFI_OK);
+
+ args_dbl[0] = &g_dbl;
+ args_dbl[1] = &f_dbl;
+ args_dbl[2] = NULL;
+
+ ffi_call(&cif, FFI_FN(cls_struct_align_fn), &res_dbl, args_dbl);
+ /* { dg-output "1 2 3 4 5 6 7 8 9 10 11 12 13 14: 9 11 13 15 17 19 21" } */
+ printf("res: %Lg %Lg %Lg %Lg %Lg %Lg %Lg\n", res_dbl.a, res_dbl.b,
+ res_dbl.c, res_dbl.d, res_dbl.e, res_dbl.f, res_dbl.g);
+ /* { dg-output "\nres: 9 11 13 15 17 19 21" } */
+
+ CHECK(ffi_prep_closure_loc(pcl, &cif, cls_struct_align_gn, NULL, code) == FFI_OK);
+
+ res_dbl = ((cls_struct_align(*)(cls_struct_align, cls_struct_align))(code))(g_dbl, f_dbl);
+ /* { dg-output "\n1 2 3 4 5 6 7 8 9 10 11 12 13 14: 9 11 13 15 17 19 21" } */
+ printf("res: %Lg %Lg %Lg %Lg %Lg %Lg %Lg\n", res_dbl.a, res_dbl.b,
+ res_dbl.c, res_dbl.d, res_dbl.e, res_dbl.f, res_dbl.g);
+ /* { dg-output "\nres: 9 11 13 15 17 19 21" } */
+
+ exit(0);
+}
diff --git a/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/cls_align_longdouble_split2.c b/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/cls_align_longdouble_split2.c
new file mode 100644
index 0000000..ca1c356
--- /dev/null
+++ b/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/cls_align_longdouble_split2.c
@@ -0,0 +1,117 @@
+/* Area: ffi_call, closure_call
+ Purpose: Check structure alignment of long double.
+ Limitations: none.
+ PR: none.
+ Originator: Blake Chaffin 6/18/2007
+*/
+
+/* { dg-excess-errors "no long double format" { xfail x86_64-*-mingw* x86_64-*-cygwin* } } */
+/* { dg-do run { xfail strongarm*-*-* } } */
+/* { dg-options -mlong-double-128 { target powerpc64*-*-linux* } } */
+/* { dg-output "" { xfail x86_64-*-mingw* x86_64-*-cygwin* } } */
+
+#include "ffitest.h"
+
+typedef struct cls_struct_align {
+ long double a;
+ long double b;
+ long double c;
+ long double d;
+ long double e;
+ double f;
+ long double g;
+} cls_struct_align;
+
+cls_struct_align cls_struct_align_fn(
+ cls_struct_align a1,
+ cls_struct_align a2)
+{
+ struct cls_struct_align r;
+
+ r.a = a1.a + a2.a;
+ r.b = a1.b + a2.b;
+ r.c = a1.c + a2.c;
+ r.d = a1.d + a2.d;
+ r.e = a1.e + a2.e;
+ r.f = a1.f + a2.f;
+ r.g = a1.g + a2.g;
+
+ printf("%Lg %Lg %Lg %Lg %Lg %g %Lg %Lg %Lg %Lg %Lg %Lg %g %Lg: "
+ "%Lg %Lg %Lg %Lg %Lg %g %Lg\n",
+ a1.a, a1.b, a1.c, a1.d, a1.e, a1.f, a1.g,
+ a2.a, a2.b, a2.c, a2.d, a2.e, a2.f, a2.g,
+ r.a, r.b, r.c, r.d, r.e, r.f, r.g);
+
+ return r;
+}
+
+static void
+cls_struct_align_gn(ffi_cif* cif __UNUSED__, void* resp, void** args,
+ void* userdata __UNUSED__)
+{
+ struct cls_struct_align a1, a2;
+
+ a1 = *(struct cls_struct_align*)(args[0]);
+ a2 = *(struct cls_struct_align*)(args[1]);
+
+ *(cls_struct_align*)resp = cls_struct_align_fn(a1, a2);
+}
+
+int main (void)
+{
+ ffi_cif cif;
+ void *code;
+ ffi_closure *pcl = ffi_closure_alloc(sizeof(ffi_closure), &code);
+ void* args_dbl[3];
+ ffi_type* cls_struct_fields[8];
+ ffi_type cls_struct_type;
+ ffi_type* dbl_arg_types[3];
+
+ struct cls_struct_align g_dbl = { 1, 2, 3, 4, 5, 6, 7 };
+ struct cls_struct_align f_dbl = { 8, 9, 10, 11, 12, 13, 14 };
+ struct cls_struct_align res_dbl;
+
+ cls_struct_type.size = 0;
+ cls_struct_type.alignment = 0;
+ cls_struct_type.type = FFI_TYPE_STRUCT;
+ cls_struct_type.elements = cls_struct_fields;
+
+ cls_struct_fields[0] = &ffi_type_longdouble;
+ cls_struct_fields[1] = &ffi_type_longdouble;
+ cls_struct_fields[2] = &ffi_type_longdouble;
+ cls_struct_fields[3] = &ffi_type_longdouble;
+ cls_struct_fields[4] = &ffi_type_longdouble;
+ cls_struct_fields[5] = &ffi_type_double;
+ cls_struct_fields[6] = &ffi_type_longdouble;
+ cls_struct_fields[7] = NULL;
+
+ dbl_arg_types[0] = &cls_struct_type;
+ dbl_arg_types[1] = &cls_struct_type;
+ dbl_arg_types[2] = NULL;
+
+ CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 2, &cls_struct_type,
+ dbl_arg_types) == FFI_OK);
+
+ args_dbl[0] = &g_dbl;
+ args_dbl[1] = &f_dbl;
+ args_dbl[2] = NULL;
+
+ ffi_call(&cif, FFI_FN(cls_struct_align_fn), &res_dbl, args_dbl);
+ /* { dg-output "1 2 3 4 5 6 7 8 9 10 11 12 13 14: 9 11 13 15 17 19 21" } */
+ printf("res: %Lg %Lg %Lg %Lg %Lg %g %Lg\n", res_dbl.a, res_dbl.b,
+ res_dbl.c, res_dbl.d, res_dbl.e, res_dbl.f, res_dbl.g);
+ /* { dg-output "\nres: 9 11 13 15 17 19 21" } */
+
+ CHECK(ffi_prep_closure_loc(pcl, &cif, cls_struct_align_gn, NULL, code) == FFI_OK);
+
+ res_dbl = ((cls_struct_align(*)(cls_struct_align, cls_struct_align))(code))(g_dbl, f_dbl);
+ /* { dg-output "\n1 2 3 4 5 6 7 8 9 10 11 12 13 14: 9 11 13 15 17 19 21" } */
+ printf("res: %Lg %Lg %Lg %Lg %Lg %g %Lg\n", res_dbl.a, res_dbl.b,
+ res_dbl.c, res_dbl.d, res_dbl.e, res_dbl.f, res_dbl.g);
+ /* { dg-output "\nres: 9 11 13 15 17 19 21" } */
+
+ exit(0);
+}
+
+
+
diff --git a/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/cls_align_pointer.c b/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/cls_align_pointer.c
new file mode 100644
index 0000000..8fbf36a
--- /dev/null
+++ b/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/cls_align_pointer.c
@@ -0,0 +1,95 @@
+/* Area: ffi_call, closure_call
+ Purpose: Check structure alignment of pointer.
+ Limitations: none.
+ PR: none.
+ Originator: <hos@tamanegi.org> 20031203 */
+
+/* { dg-do run } */
+#include "ffitest.h"
+
+typedef struct cls_struct_align {
+ unsigned char a;
+ void *b;
+ unsigned char c;
+} cls_struct_align;
+
+cls_struct_align cls_struct_align_fn(struct cls_struct_align a1,
+ struct cls_struct_align a2)
+{
+ struct cls_struct_align result;
+
+ result.a = a1.a + a2.a;
+ result.b = (void *)((uintptr_t)a1.b + (uintptr_t)a2.b);
+ result.c = a1.c + a2.c;
+
+ printf("%d %" PRIuPTR " %d %d %" PRIuPTR " %d: %d %" PRIuPTR " %d\n",
+ a1.a, (uintptr_t)a1.b, a1.c,
+ a2.a, (uintptr_t)a2.b, a2.c,
+ result.a, (uintptr_t)result.b,
+ result.c);
+
+ return result;
+}
+
+static void
+cls_struct_align_gn(ffi_cif* cif __UNUSED__, void* resp, void** args,
+ void* userdata __UNUSED__)
+{
+
+ struct cls_struct_align a1, a2;
+
+ a1 = *(struct cls_struct_align*)(args[0]);
+ a2 = *(struct cls_struct_align*)(args[1]);
+
+ *(cls_struct_align*)resp = cls_struct_align_fn(a1, a2);
+}
+
+int main (void)
+{
+ ffi_cif cif;
+ void *code;
+ ffi_closure *pcl = ffi_closure_alloc(sizeof(ffi_closure), &code);
+ void* args_dbl[5];
+ ffi_type* cls_struct_fields[4];
+ ffi_type cls_struct_type;
+ ffi_type* dbl_arg_types[5];
+
+ struct cls_struct_align g_dbl = { 12, (void *)4951, 127 };
+ struct cls_struct_align f_dbl = { 1, (void *)9320, 13 };
+ struct cls_struct_align res_dbl;
+
+ cls_struct_type.size = 0;
+ cls_struct_type.alignment = 0;
+ cls_struct_type.type = FFI_TYPE_STRUCT;
+ cls_struct_type.elements = cls_struct_fields;
+
+ cls_struct_fields[0] = &ffi_type_uchar;
+ cls_struct_fields[1] = &ffi_type_pointer;
+ cls_struct_fields[2] = &ffi_type_uchar;
+ cls_struct_fields[3] = NULL;
+
+ dbl_arg_types[0] = &cls_struct_type;
+ dbl_arg_types[1] = &cls_struct_type;
+ dbl_arg_types[2] = NULL;
+
+ CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 2, &cls_struct_type,
+ dbl_arg_types) == FFI_OK);
+
+ args_dbl[0] = &g_dbl;
+ args_dbl[1] = &f_dbl;
+ args_dbl[2] = NULL;
+
+ ffi_call(&cif, FFI_FN(cls_struct_align_fn), &res_dbl, args_dbl);
+ /* { dg-output "12 4951 127 1 9320 13: 13 14271 140" } */
+ printf("res: %d %" PRIuPTR " %d\n", res_dbl.a, (uintptr_t)res_dbl.b, res_dbl.c);
+ /* { dg-output "\nres: 13 14271 140" } */
+
+ CHECK(ffi_prep_closure_loc(pcl, &cif, cls_struct_align_gn, NULL, code) == FFI_OK);
+
+ res_dbl = ((cls_struct_align(*)(cls_struct_align, cls_struct_align))(code))(g_dbl, f_dbl);
+ /* { dg-output "\n12 4951 127 1 9320 13: 13 14271 140" } */
+ printf("res: %d %" PRIuPTR " %d\n", res_dbl.a, (uintptr_t)res_dbl.b, res_dbl.c);
+ /* { dg-output "\nres: 13 14271 140" } */
+
+ exit(0);
+}
diff --git a/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/cls_align_sint16.c b/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/cls_align_sint16.c
new file mode 100644
index 0000000..039b874
--- /dev/null
+++ b/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/cls_align_sint16.c
@@ -0,0 +1,91 @@
+/* Area: ffi_call, closure_call
+ Purpose: Check structure alignment of sint16.
+ Limitations: none.
+ PR: none.
+ Originator: <hos@tamanegi.org> 20031203 */
+
+/* { dg-do run } */
+#include "ffitest.h"
+
+typedef struct cls_struct_align {
+ unsigned char a;
+ signed short b;
+ unsigned char c;
+} cls_struct_align;
+
+cls_struct_align cls_struct_align_fn(struct cls_struct_align a1,
+ struct cls_struct_align a2)
+{
+ struct cls_struct_align result;
+
+ result.a = a1.a + a2.a;
+ result.b = a1.b + a2.b;
+ result.c = a1.c + a2.c;
+
+ printf("%d %d %d %d %d %d: %d %d %d\n", a1.a, a1.b, a1.c, a2.a, a2.b, a2.c, result.a, result.b, result.c);
+
+ return result;
+}
+
+static void
+cls_struct_align_gn(ffi_cif* cif __UNUSED__, void* resp, void** args,
+ void* userdata __UNUSED__)
+{
+
+ struct cls_struct_align a1, a2;
+
+ a1 = *(struct cls_struct_align*)(args[0]);
+ a2 = *(struct cls_struct_align*)(args[1]);
+
+ *(cls_struct_align*)resp = cls_struct_align_fn(a1, a2);
+}
+
+int main (void)
+{
+ ffi_cif cif;
+ void *code;
+ ffi_closure *pcl = ffi_closure_alloc(sizeof(ffi_closure), &code);
+ void* args_dbl[5];
+ ffi_type* cls_struct_fields[4];
+ ffi_type cls_struct_type;
+ ffi_type* dbl_arg_types[5];
+
+ struct cls_struct_align g_dbl = { 12, 4951, 127 };
+ struct cls_struct_align f_dbl = { 1, 9320, 13 };
+ struct cls_struct_align res_dbl;
+
+ cls_struct_type.size = 0;
+ cls_struct_type.alignment = 0;
+ cls_struct_type.type = FFI_TYPE_STRUCT;
+ cls_struct_type.elements = cls_struct_fields;
+
+ cls_struct_fields[0] = &ffi_type_uchar;
+ cls_struct_fields[1] = &ffi_type_sshort;
+ cls_struct_fields[2] = &ffi_type_uchar;
+ cls_struct_fields[3] = NULL;
+
+ dbl_arg_types[0] = &cls_struct_type;
+ dbl_arg_types[1] = &cls_struct_type;
+ dbl_arg_types[2] = NULL;
+
+ CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 2, &cls_struct_type,
+ dbl_arg_types) == FFI_OK);
+
+ args_dbl[0] = &g_dbl;
+ args_dbl[1] = &f_dbl;
+ args_dbl[2] = NULL;
+
+ ffi_call(&cif, FFI_FN(cls_struct_align_fn), &res_dbl, args_dbl);
+ /* { dg-output "12 4951 127 1 9320 13: 13 14271 140" } */
+ printf("res: %d %d %d\n", res_dbl.a, res_dbl.b, res_dbl.c);
+ /* { dg-output "\nres: 13 14271 140" } */
+
+ CHECK(ffi_prep_closure_loc(pcl, &cif, cls_struct_align_gn, NULL, code) == FFI_OK);
+
+ res_dbl = ((cls_struct_align(*)(cls_struct_align, cls_struct_align))(code))(g_dbl, f_dbl);
+ /* { dg-output "\n12 4951 127 1 9320 13: 13 14271 140" } */
+ printf("res: %d %d %d\n", res_dbl.a, res_dbl.b, res_dbl.c);
+ /* { dg-output "\nres: 13 14271 140" } */
+
+ exit(0);
+}
diff --git a/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/cls_align_sint32.c b/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/cls_align_sint32.c
new file mode 100644
index 0000000..c96c6d1
--- /dev/null
+++ b/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/cls_align_sint32.c
@@ -0,0 +1,91 @@
+/* Area: ffi_call, closure_call
+ Purpose: Check structure alignment of sint32.
+ Limitations: none.
+ PR: none.
+ Originator: <hos@tamanegi.org> 20031203 */
+
+/* { dg-do run } */
+#include "ffitest.h"
+
+typedef struct cls_struct_align {
+ unsigned char a;
+ signed int b;
+ unsigned char c;
+} cls_struct_align;
+
+cls_struct_align cls_struct_align_fn(struct cls_struct_align a1,
+ struct cls_struct_align a2)
+{
+ struct cls_struct_align result;
+
+ result.a = a1.a + a2.a;
+ result.b = a1.b + a2.b;
+ result.c = a1.c + a2.c;
+
+ printf("%d %d %d %d %d %d: %d %d %d\n", a1.a, a1.b, a1.c, a2.a, a2.b, a2.c, result.a, result.b, result.c);
+
+ return result;
+}
+
+static void
+cls_struct_align_gn(ffi_cif* cif __UNUSED__, void* resp, void** args,
+ void* userdata __UNUSED__)
+{
+
+ struct cls_struct_align a1, a2;
+
+ a1 = *(struct cls_struct_align*)(args[0]);
+ a2 = *(struct cls_struct_align*)(args[1]);
+
+ *(cls_struct_align*)resp = cls_struct_align_fn(a1, a2);
+}
+
+int main (void)
+{
+ ffi_cif cif;
+ void *code;
+ ffi_closure *pcl = ffi_closure_alloc(sizeof(ffi_closure), &code);
+ void* args_dbl[5];
+ ffi_type* cls_struct_fields[4];
+ ffi_type cls_struct_type;
+ ffi_type* dbl_arg_types[5];
+
+ struct cls_struct_align g_dbl = { 12, 4951, 127 };
+ struct cls_struct_align f_dbl = { 1, 9320, 13 };
+ struct cls_struct_align res_dbl;
+
+ cls_struct_type.size = 0;
+ cls_struct_type.alignment = 0;
+ cls_struct_type.type = FFI_TYPE_STRUCT;
+ cls_struct_type.elements = cls_struct_fields;
+
+ cls_struct_fields[0] = &ffi_type_uchar;
+ cls_struct_fields[1] = &ffi_type_sint;
+ cls_struct_fields[2] = &ffi_type_uchar;
+ cls_struct_fields[3] = NULL;
+
+ dbl_arg_types[0] = &cls_struct_type;
+ dbl_arg_types[1] = &cls_struct_type;
+ dbl_arg_types[2] = NULL;
+
+ CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 2, &cls_struct_type,
+ dbl_arg_types) == FFI_OK);
+
+ args_dbl[0] = &g_dbl;
+ args_dbl[1] = &f_dbl;
+ args_dbl[2] = NULL;
+
+ ffi_call(&cif, FFI_FN(cls_struct_align_fn), &res_dbl, args_dbl);
+ /* { dg-output "12 4951 127 1 9320 13: 13 14271 140" } */
+ printf("res: %d %d %d\n", res_dbl.a, res_dbl.b, res_dbl.c);
+ /* { dg-output "\nres: 13 14271 140" } */
+
+ CHECK(ffi_prep_closure_loc(pcl, &cif, cls_struct_align_gn, NULL, code) == FFI_OK);
+
+ res_dbl = ((cls_struct_align(*)(cls_struct_align, cls_struct_align))(code))(g_dbl, f_dbl);
+ /* { dg-output "\n12 4951 127 1 9320 13: 13 14271 140" } */
+ printf("res: %d %d %d\n", res_dbl.a, res_dbl.b, res_dbl.c);
+ /* { dg-output "\nres: 13 14271 140" } */
+
+ exit(0);
+}
diff --git a/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/cls_align_sint64.c b/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/cls_align_sint64.c
new file mode 100644
index 0000000..9aa7bdd
--- /dev/null
+++ b/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/cls_align_sint64.c
@@ -0,0 +1,92 @@
+/* Area: ffi_call, closure_call
+ Purpose: Check structure alignment of sint64.
+ Limitations: none.
+ PR: none.
+ Originator: <hos@tamanegi.org> 20031203 */
+
+/* { dg-do run } */
+/* { dg-options "-Wno-format" { target alpha*-dec-osf* } } */
+#include "ffitest.h"
+
+typedef struct cls_struct_align {
+ unsigned char a;
+ signed long long b;
+ unsigned char c;
+} cls_struct_align;
+
+cls_struct_align cls_struct_align_fn(struct cls_struct_align a1,
+ struct cls_struct_align a2)
+{
+ struct cls_struct_align result;
+
+ result.a = a1.a + a2.a;
+ result.b = a1.b + a2.b;
+ result.c = a1.c + a2.c;
+
+ printf("%d %" PRIdLL " %d %d %" PRIdLL " %d: %d %" PRIdLL " %d\n", a1.a, a1.b, a1.c, a2.a, a2.b, a2.c, result.a, result.b, result.c);
+
+ return result;
+}
+
+static void
+cls_struct_align_gn(ffi_cif* cif __UNUSED__, void* resp, void** args,
+ void* userdata __UNUSED__)
+{
+
+ struct cls_struct_align a1, a2;
+
+ a1 = *(struct cls_struct_align*)(args[0]);
+ a2 = *(struct cls_struct_align*)(args[1]);
+
+ *(cls_struct_align*)resp = cls_struct_align_fn(a1, a2);
+}
+
+int main (void)
+{
+ ffi_cif cif;
+ void *code;
+ ffi_closure *pcl = ffi_closure_alloc(sizeof(ffi_closure), &code);
+ void* args_dbl[5];
+ ffi_type* cls_struct_fields[4];
+ ffi_type cls_struct_type;
+ ffi_type* dbl_arg_types[5];
+
+ struct cls_struct_align g_dbl = { 12, 4951, 127 };
+ struct cls_struct_align f_dbl = { 1, 9320, 13 };
+ struct cls_struct_align res_dbl;
+
+ cls_struct_type.size = 0;
+ cls_struct_type.alignment = 0;
+ cls_struct_type.type = FFI_TYPE_STRUCT;
+ cls_struct_type.elements = cls_struct_fields;
+
+ cls_struct_fields[0] = &ffi_type_uchar;
+ cls_struct_fields[1] = &ffi_type_sint64;
+ cls_struct_fields[2] = &ffi_type_uchar;
+ cls_struct_fields[3] = NULL;
+
+ dbl_arg_types[0] = &cls_struct_type;
+ dbl_arg_types[1] = &cls_struct_type;
+ dbl_arg_types[2] = NULL;
+
+ CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 2, &cls_struct_type,
+ dbl_arg_types) == FFI_OK);
+
+ args_dbl[0] = &g_dbl;
+ args_dbl[1] = &f_dbl;
+ args_dbl[2] = NULL;
+
+ ffi_call(&cif, FFI_FN(cls_struct_align_fn), &res_dbl, args_dbl);
+ /* { dg-output "12 4951 127 1 9320 13: 13 14271 140" } */
+ printf("res: %d %" PRIdLL " %d\n", res_dbl.a, res_dbl.b, res_dbl.c);
+ /* { dg-output "\nres: 13 14271 140" } */
+
+ CHECK(ffi_prep_closure_loc(pcl, &cif, cls_struct_align_gn, NULL, code) == FFI_OK);
+
+ res_dbl = ((cls_struct_align(*)(cls_struct_align, cls_struct_align))(code))(g_dbl, f_dbl);
+ /* { dg-output "\n12 4951 127 1 9320 13: 13 14271 140" } */
+ printf("res: %d %" PRIdLL " %d\n", res_dbl.a, res_dbl.b, res_dbl.c);
+ /* { dg-output "\nres: 13 14271 140" } */
+
+ exit(0);
+}
diff --git a/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/cls_align_uint16.c b/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/cls_align_uint16.c
new file mode 100644
index 0000000..97620b7
--- /dev/null
+++ b/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/cls_align_uint16.c
@@ -0,0 +1,91 @@
+/* Area: ffi_call, closure_call
+ Purpose: Check structure alignment of uint16.
+ Limitations: none.
+ PR: none.
+ Originator: <hos@tamanegi.org> 20031203 */
+
+/* { dg-do run } */
+#include "ffitest.h"
+
+typedef struct cls_struct_align {
+ unsigned char a;
+ unsigned short b;
+ unsigned char c;
+} cls_struct_align;
+
+cls_struct_align cls_struct_align_fn(struct cls_struct_align a1,
+ struct cls_struct_align a2)
+{
+ struct cls_struct_align result;
+
+ result.a = a1.a + a2.a;
+ result.b = a1.b + a2.b;
+ result.c = a1.c + a2.c;
+
+ printf("%d %d %d %d %d %d: %d %d %d\n", a1.a, a1.b, a1.c, a2.a, a2.b, a2.c, result.a, result.b, result.c);
+
+ return result;
+}
+
+static void
+cls_struct_align_gn(ffi_cif* cif __UNUSED__, void* resp, void** args,
+ void* userdata __UNUSED__)
+{
+
+ struct cls_struct_align a1, a2;
+
+ a1 = *(struct cls_struct_align*)(args[0]);
+ a2 = *(struct cls_struct_align*)(args[1]);
+
+ *(cls_struct_align*)resp = cls_struct_align_fn(a1, a2);
+}
+
+int main (void)
+{
+ ffi_cif cif;
+ void *code;
+ ffi_closure *pcl = ffi_closure_alloc(sizeof(ffi_closure), &code);
+ void* args_dbl[5];
+ ffi_type* cls_struct_fields[4];
+ ffi_type cls_struct_type;
+ ffi_type* dbl_arg_types[5];
+
+ struct cls_struct_align g_dbl = { 12, 4951, 127 };
+ struct cls_struct_align f_dbl = { 1, 9320, 13 };
+ struct cls_struct_align res_dbl;
+
+ cls_struct_type.size = 0;
+ cls_struct_type.alignment = 0;
+ cls_struct_type.type = FFI_TYPE_STRUCT;
+ cls_struct_type.elements = cls_struct_fields;
+
+ cls_struct_fields[0] = &ffi_type_uchar;
+ cls_struct_fields[1] = &ffi_type_ushort;
+ cls_struct_fields[2] = &ffi_type_uchar;
+ cls_struct_fields[3] = NULL;
+
+ dbl_arg_types[0] = &cls_struct_type;
+ dbl_arg_types[1] = &cls_struct_type;
+ dbl_arg_types[2] = NULL;
+
+ CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 2, &cls_struct_type,
+ dbl_arg_types) == FFI_OK);
+
+ args_dbl[0] = &g_dbl;
+ args_dbl[1] = &f_dbl;
+ args_dbl[2] = NULL;
+
+ ffi_call(&cif, FFI_FN(cls_struct_align_fn), &res_dbl, args_dbl);
+ /* { dg-output "12 4951 127 1 9320 13: 13 14271 140" } */
+ printf("res: %d %d %d\n", res_dbl.a, res_dbl.b, res_dbl.c);
+ /* { dg-output "\nres: 13 14271 140" } */
+
+ CHECK(ffi_prep_closure_loc(pcl, &cif, cls_struct_align_gn, NULL, code) == FFI_OK);
+
+ res_dbl = ((cls_struct_align(*)(cls_struct_align, cls_struct_align))(code))(g_dbl, f_dbl);
+ /* { dg-output "\n12 4951 127 1 9320 13: 13 14271 140" } */
+ printf("res: %d %d %d\n", res_dbl.a, res_dbl.b, res_dbl.c);
+ /* { dg-output "\nres: 13 14271 140" } */
+
+ exit(0);
+}
diff --git a/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/cls_align_uint32.c b/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/cls_align_uint32.c
new file mode 100644
index 0000000..5766fad
--- /dev/null
+++ b/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/cls_align_uint32.c
@@ -0,0 +1,91 @@
+/* Area: ffi_call, closure_call
+ Purpose: Check structure alignment of uint32.
+ Limitations: none.
+ PR: none.
+ Originator: <hos@tamanegi.org> 20031203 */
+
+/* { dg-do run } */
+#include "ffitest.h"
+
+typedef struct cls_struct_align {
+ unsigned char a;
+ unsigned int b;
+ unsigned char c;
+} cls_struct_align;
+
+cls_struct_align cls_struct_align_fn(struct cls_struct_align a1,
+ struct cls_struct_align a2)
+{
+ struct cls_struct_align result;
+
+ result.a = a1.a + a2.a;
+ result.b = a1.b + a2.b;
+ result.c = a1.c + a2.c;
+
+ printf("%d %d %d %d %d %d: %d %d %d\n", a1.a, a1.b, a1.c, a2.a, a2.b, a2.c, result.a, result.b, result.c);
+
+ return result;
+}
+
+static void
+cls_struct_align_gn(ffi_cif* cif __UNUSED__, void* resp, void** args,
+ void* userdata __UNUSED__)
+{
+
+ struct cls_struct_align a1, a2;
+
+ a1 = *(struct cls_struct_align*)(args[0]);
+ a2 = *(struct cls_struct_align*)(args[1]);
+
+ *(cls_struct_align*)resp = cls_struct_align_fn(a1, a2);
+}
+
+int main (void)
+{
+ ffi_cif cif;
+ void *code;
+ ffi_closure *pcl = ffi_closure_alloc(sizeof(ffi_closure), &code);
+ void* args_dbl[5];
+ ffi_type* cls_struct_fields[4];
+ ffi_type cls_struct_type;
+ ffi_type* dbl_arg_types[5];
+
+ struct cls_struct_align g_dbl = { 12, 4951, 127 };
+ struct cls_struct_align f_dbl = { 1, 9320, 13 };
+ struct cls_struct_align res_dbl;
+
+ cls_struct_type.size = 0;
+ cls_struct_type.alignment = 0;
+ cls_struct_type.type = FFI_TYPE_STRUCT;
+ cls_struct_type.elements = cls_struct_fields;
+
+ cls_struct_fields[0] = &ffi_type_uchar;
+ cls_struct_fields[1] = &ffi_type_uint;
+ cls_struct_fields[2] = &ffi_type_uchar;
+ cls_struct_fields[3] = NULL;
+
+ dbl_arg_types[0] = &cls_struct_type;
+ dbl_arg_types[1] = &cls_struct_type;
+ dbl_arg_types[2] = NULL;
+
+ CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 2, &cls_struct_type,
+ dbl_arg_types) == FFI_OK);
+
+ args_dbl[0] = &g_dbl;
+ args_dbl[1] = &f_dbl;
+ args_dbl[2] = NULL;
+
+ ffi_call(&cif, FFI_FN(cls_struct_align_fn), &res_dbl, args_dbl);
+ /* { dg-output "12 4951 127 1 9320 13: 13 14271 140" } */
+ printf("res: %d %d %d\n", res_dbl.a, res_dbl.b, res_dbl.c);
+ /* { dg-output "\nres: 13 14271 140" } */
+
+ CHECK(ffi_prep_closure_loc(pcl, &cif, cls_struct_align_gn, NULL, code) == FFI_OK);
+
+ res_dbl = ((cls_struct_align(*)(cls_struct_align, cls_struct_align))(code))(g_dbl, f_dbl);
+ /* { dg-output "\n12 4951 127 1 9320 13: 13 14271 140" } */
+ printf("res: %d %d %d\n", res_dbl.a, res_dbl.b, res_dbl.c);
+ /* { dg-output "\nres: 13 14271 140" } */
+
+ exit(0);
+}
diff --git a/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/cls_align_uint64.c b/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/cls_align_uint64.c
new file mode 100644
index 0000000..a52cb89
--- /dev/null
+++ b/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/cls_align_uint64.c
@@ -0,0 +1,93 @@
+/* Area: ffi_call, closure_call
+ Purpose: Check structure alignment of uint64.
+ Limitations: none.
+ PR: none.
+ Originator: <hos@tamanegi.org> 20031203 */
+
+
+/* { dg-do run } */
+/* { dg-options "-Wno-format" { target alpha*-dec-osf* } } */
+#include "ffitest.h"
+
+typedef struct cls_struct_align {
+ unsigned char a;
+ unsigned long long b;
+ unsigned char c;
+} cls_struct_align;
+
+cls_struct_align cls_struct_align_fn(struct cls_struct_align a1,
+ struct cls_struct_align a2)
+{
+ struct cls_struct_align result;
+
+ result.a = a1.a + a2.a;
+ result.b = a1.b + a2.b;
+ result.c = a1.c + a2.c;
+
+ printf("%d %" PRIdLL " %d %d %" PRIdLL " %d: %d %" PRIdLL " %d\n", a1.a, a1.b, a1.c, a2.a, a2.b, a2.c, result.a, result.b, result.c);
+
+ return result;
+}
+
+static void
+cls_struct_align_gn(ffi_cif* cif __UNUSED__, void* resp, void** args,
+ void* userdata __UNUSED__)
+{
+
+ struct cls_struct_align a1, a2;
+
+ a1 = *(struct cls_struct_align*)(args[0]);
+ a2 = *(struct cls_struct_align*)(args[1]);
+
+ *(cls_struct_align*)resp = cls_struct_align_fn(a1, a2);
+}
+
+int main (void)
+{
+ ffi_cif cif;
+ void *code;
+ ffi_closure *pcl = ffi_closure_alloc(sizeof(ffi_closure), &code);
+ void* args_dbl[5];
+ ffi_type* cls_struct_fields[4];
+ ffi_type cls_struct_type;
+ ffi_type* dbl_arg_types[5];
+
+ struct cls_struct_align g_dbl = { 12, 4951, 127 };
+ struct cls_struct_align f_dbl = { 1, 9320, 13 };
+ struct cls_struct_align res_dbl;
+
+ cls_struct_type.size = 0;
+ cls_struct_type.alignment = 0;
+ cls_struct_type.type = FFI_TYPE_STRUCT;
+ cls_struct_type.elements = cls_struct_fields;
+
+ cls_struct_fields[0] = &ffi_type_uchar;
+ cls_struct_fields[1] = &ffi_type_uint64;
+ cls_struct_fields[2] = &ffi_type_uchar;
+ cls_struct_fields[3] = NULL;
+
+ dbl_arg_types[0] = &cls_struct_type;
+ dbl_arg_types[1] = &cls_struct_type;
+ dbl_arg_types[2] = NULL;
+
+ CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 2, &cls_struct_type,
+ dbl_arg_types) == FFI_OK);
+
+ args_dbl[0] = &g_dbl;
+ args_dbl[1] = &f_dbl;
+ args_dbl[2] = NULL;
+
+ ffi_call(&cif, FFI_FN(cls_struct_align_fn), &res_dbl, args_dbl);
+ /* { dg-output "12 4951 127 1 9320 13: 13 14271 140" } */
+ printf("res: %d %" PRIdLL " %d\n", res_dbl.a, res_dbl.b, res_dbl.c);
+ /* { dg-output "\nres: 13 14271 140" } */
+
+ CHECK(ffi_prep_closure_loc(pcl, &cif, cls_struct_align_gn, NULL, code) == FFI_OK);
+
+ res_dbl = ((cls_struct_align(*)(cls_struct_align, cls_struct_align))(code))(g_dbl, f_dbl);
+ /* { dg-output "\n12 4951 127 1 9320 13: 13 14271 140" } */
+ printf("res: %d %" PRIdLL " %d\n", res_dbl.a, res_dbl.b, res_dbl.c);
+ /* { dg-output "\nres: 13 14271 140" } */
+
+ exit(0);
+}
diff --git a/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/cls_dbls_struct.c b/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/cls_dbls_struct.c
new file mode 100644
index 0000000..d663791
--- /dev/null
+++ b/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/cls_dbls_struct.c
@@ -0,0 +1,66 @@
+/* Area: ffi_call, closure_call
+ Purpose: Check double arguments in structs.
+ Limitations: none.
+ PR: none.
+ Originator: Blake Chaffin 6/23/2007 */
+
+/* { dg-do run } */
+
+#include "ffitest.h"
+
+typedef struct Dbls {
+ double x;
+ double y;
+} Dbls;
+
+void
+closure_test_fn(Dbls p)
+{
+ printf("%.1f %.1f\n", p.x, p.y);
+}
+
+void
+closure_test_gn(ffi_cif* cif __UNUSED__, void* resp __UNUSED__,
+ void** args, void* userdata __UNUSED__)
+{
+ closure_test_fn(*(Dbls*)args[0]);
+}
+
+int main(int argc __UNUSED__, char** argv __UNUSED__)
+{
+ ffi_cif cif;
+
+ void *code;
+ ffi_closure* pcl = ffi_closure_alloc(sizeof(ffi_closure), &code);
+ ffi_type* cl_arg_types[1];
+
+ ffi_type ts1_type;
+ ffi_type* ts1_type_elements[4];
+
+ Dbls arg = { 1.0, 2.0 };
+
+ ts1_type.size = 0;
+ ts1_type.alignment = 0;
+ ts1_type.type = FFI_TYPE_STRUCT;
+ ts1_type.elements = ts1_type_elements;
+
+ ts1_type_elements[0] = &ffi_type_double;
+ ts1_type_elements[1] = &ffi_type_double;
+ ts1_type_elements[2] = NULL;
+
+ cl_arg_types[0] = &ts1_type;
+
+ /* Initialize the cif */
+ CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 1,
+ &ffi_type_void, cl_arg_types) == FFI_OK);
+
+ CHECK(ffi_prep_closure_loc(pcl, &cif, closure_test_gn, NULL, code) == FFI_OK);
+
+ ((void*(*)(Dbls))(code))(arg);
+ /* { dg-output "1.0 2.0\n" } */
+
+ closure_test_fn(arg);
+ /* { dg-output "1.0 2.0\n" } */
+
+ return 0;
+}
diff --git a/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/cls_double.c b/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/cls_double.c
new file mode 100644
index 0000000..84ad4cb
--- /dev/null
+++ b/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/cls_double.c
@@ -0,0 +1,43 @@
+/* Area: closure_call
+ Purpose: Check return value double.
+ Limitations: none.
+ PR: none.
+ Originator: <andreast@gcc.gnu.org> 20030828 */
+
+/* { dg-do run } */
+#include "ffitest.h"
+
+static void cls_ret_double_fn(ffi_cif* cif __UNUSED__, void* resp, void** args,
+ void* userdata __UNUSED__)
+ {
+ *(double *)resp = *(double *)args[0];
+
+ printf("%f: %f\n",*(double *)args[0],
+ *(double *)resp);
+ }
+typedef double (*cls_ret_double)(double);
+
+int main (void)
+{
+ ffi_cif cif;
+ void *code;
+ ffi_closure *pcl = ffi_closure_alloc(sizeof(ffi_closure), &code);
+ ffi_type * cl_arg_types[2];
+ double res;
+
+ cl_arg_types[0] = &ffi_type_double;
+ cl_arg_types[1] = NULL;
+
+ /* Initialize the cif */
+ CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 1,
+ &ffi_type_double, cl_arg_types) == FFI_OK);
+
+ CHECK(ffi_prep_closure_loc(pcl, &cif, cls_ret_double_fn, NULL, code) == FFI_OK);
+
+ res = (*((cls_ret_double)code))(21474.789);
+ /* { dg-output "21474.789000: 21474.789000" } */
+ printf("res: %.6f\n", res);
+ /* { dg-output "\nres: 21474.789000" } */
+
+ exit(0);
+}
diff --git a/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/cls_double_va.c b/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/cls_double_va.c
new file mode 100644
index 0000000..e077f92
--- /dev/null
+++ b/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/cls_double_va.c
@@ -0,0 +1,61 @@
+/* Area: ffi_call, closure_call
+ Purpose: Test doubles passed in variable argument lists.
+ Limitations: none.
+ PR: none.
+ Originator: Blake Chaffin 6/6/2007 */
+
+/* { dg-do run { xfail strongarm*-*-* xscale*-*-* } } */
+/* { dg-output "" { xfail avr32*-*-* } } */
+/* { dg-output "" { xfail mips-sgi-irix6* } } PR libffi/46660 */
+
+#include "ffitest.h"
+
+static void
+cls_double_va_fn(ffi_cif* cif __UNUSED__, void* resp,
+ void** args, void* userdata __UNUSED__)
+{
+ char* format = *(char**)args[0];
+ double doubleValue = *(double*)args[1];
+
+ *(ffi_arg*)resp = printf(format, doubleValue);
+}
+
+int main (void)
+{
+ ffi_cif cif;
+ void *code;
+ ffi_closure *pcl = ffi_closure_alloc(sizeof(ffi_closure), &code);
+ void* args[3];
+ ffi_type* arg_types[3];
+
+ char* format = "%.1f\n";
+ double doubleArg = 7;
+ ffi_arg res = 0;
+
+ arg_types[0] = &ffi_type_pointer;
+ arg_types[1] = &ffi_type_double;
+ arg_types[2] = NULL;
+
+ /* This printf call is variadic */
+ CHECK(ffi_prep_cif_var(&cif, FFI_DEFAULT_ABI, 1, 2, &ffi_type_sint,
+ arg_types) == FFI_OK);
+
+ args[0] = &format;
+ args[1] = &doubleArg;
+ args[2] = NULL;
+
+ ffi_call(&cif, FFI_FN(printf), &res, args);
+ /* { dg-output "7.0" } */
+ printf("res: %d\n", (int) res);
+ /* { dg-output "\nres: 4" } */
+
+ CHECK(ffi_prep_closure_loc(pcl, &cif, cls_double_va_fn, NULL,
+ code) == FFI_OK);
+
+ res = ((int(*)(char*, ...))(code))(format, doubleArg);
+ /* { dg-output "\n7.0" } */
+ printf("res: %d\n", (int) res);
+ /* { dg-output "\nres: 4" } */
+
+ exit(0);
+}
diff --git a/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/cls_float.c b/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/cls_float.c
new file mode 100644
index 0000000..0090fed
--- /dev/null
+++ b/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/cls_float.c
@@ -0,0 +1,42 @@
+/* Area: closure_call
+ Purpose: Check return value float.
+ Limitations: none.
+ PR: none.
+ Originator: <andreast@gcc.gnu.org> 20030828 */
+
+/* { dg-do run } */
+#include "ffitest.h"
+
+static void cls_ret_float_fn(ffi_cif* cif __UNUSED__, void* resp, void** args,
+ void* userdata __UNUSED__)
+ {
+ *(float *)resp = *(float *)args[0];
+
+ printf("%g: %g\n",*(float *)args[0],
+ *(float *)resp);
+ }
+
+typedef float (*cls_ret_float)(float);
+
+int main (void)
+{
+ ffi_cif cif;
+ void *code;
+ ffi_closure *pcl = ffi_closure_alloc(sizeof(ffi_closure), &code);
+ ffi_type * cl_arg_types[2];
+ float res;
+
+ cl_arg_types[0] = &ffi_type_float;
+ cl_arg_types[1] = NULL;
+
+ /* Initialize the cif */
+ CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 1,
+ &ffi_type_float, cl_arg_types) == FFI_OK);
+
+ CHECK(ffi_prep_closure_loc(pcl, &cif, cls_ret_float_fn, NULL, code) == FFI_OK);
+ res = ((((cls_ret_float)code)(-2122.12)));
+ /* { dg-output "\\-2122.12: \\-2122.12" } */
+ printf("res: %.6f\n", res);
+ /* { dg-output "\nres: \-2122.120117" } */
+ exit(0);
+}
diff --git a/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/cls_longdouble.c b/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/cls_longdouble.c
new file mode 100644
index 0000000..5dc9ac7
--- /dev/null
+++ b/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/cls_longdouble.c
@@ -0,0 +1,107 @@
+/* Area: ffi_call, closure_call
+ Purpose: Check long double arguments.
+ Limitations: none.
+ PR: none.
+ Originator: Blake Chaffin */
+
+/* { dg-excess-errors "no long double format" { xfail x86_64-*-mingw* x86_64-*-cygwin* } } */
+/* This test is known to PASS on armv7l-unknown-linux-gnueabihf, so I have
+ remove the xfail for arm*-*-* below, until we know more. */
+/* { dg-do run { xfail strongarm*-*-* xscale*-*-* } } */
+/* { dg-options -mlong-double-128 { target powerpc64*-*-linux* } } */
+/* { dg-output "" { xfail x86_64-*-mingw* x86_64-*-cygwin* } } */
+
+#include "ffitest.h"
+
+long double cls_ldouble_fn(
+ long double a1,
+ long double a2,
+ long double a3,
+ long double a4,
+ long double a5,
+ long double a6,
+ long double a7,
+ long double a8)
+{
+ long double r = a1 + a2 + a3 + a4 + a5 + a6 + a7 + a8;
+
+ printf("%Lg %Lg %Lg %Lg %Lg %Lg %Lg %Lg: %Lg\n",
+ a1, a2, a3, a4, a5, a6, a7, a8, r);
+
+ return r;
+}
+
+static void
+cls_ldouble_gn(ffi_cif* cif __UNUSED__, void* resp,
+ void** args, void* userdata __UNUSED__)
+{
+ long double a1 = *(long double*)args[0];
+ long double a2 = *(long double*)args[1];
+ long double a3 = *(long double*)args[2];
+ long double a4 = *(long double*)args[3];
+ long double a5 = *(long double*)args[4];
+ long double a6 = *(long double*)args[5];
+ long double a7 = *(long double*)args[6];
+ long double a8 = *(long double*)args[7];
+
+ *(long double*)resp = cls_ldouble_fn(
+ a1, a2, a3, a4, a5, a6, a7, a8);
+}
+
+int main(void)
+{
+ ffi_cif cif;
+ void* code;
+ ffi_closure* pcl = ffi_closure_alloc(sizeof(ffi_closure), &code);
+ void* args[9];
+ ffi_type* arg_types[9];
+ long double res = 0;
+
+ long double arg1 = 1;
+ long double arg2 = 2;
+ long double arg3 = 3;
+ long double arg4 = 4;
+ long double arg5 = 5;
+ long double arg6 = 6;
+ long double arg7 = 7;
+ long double arg8 = 8;
+
+ arg_types[0] = &ffi_type_longdouble;
+ arg_types[1] = &ffi_type_longdouble;
+ arg_types[2] = &ffi_type_longdouble;
+ arg_types[3] = &ffi_type_longdouble;
+ arg_types[4] = &ffi_type_longdouble;
+ arg_types[5] = &ffi_type_longdouble;
+ arg_types[6] = &ffi_type_longdouble;
+ arg_types[7] = &ffi_type_longdouble;
+ arg_types[8] = NULL;
+
+ CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 8, &ffi_type_longdouble,
+ arg_types) == FFI_OK);
+
+ args[0] = &arg1;
+ args[1] = &arg2;
+ args[2] = &arg3;
+ args[3] = &arg4;
+ args[4] = &arg5;
+ args[5] = &arg6;
+ args[6] = &arg7;
+ args[7] = &arg8;
+ args[8] = NULL;
+
+ ffi_call(&cif, FFI_FN(cls_ldouble_fn), &res, args);
+ /* { dg-output "1 2 3 4 5 6 7 8: 36" } */
+ printf("res: %Lg\n", res);
+ /* { dg-output "\nres: 36" } */
+
+ CHECK(ffi_prep_closure_loc(pcl, &cif, cls_ldouble_gn, NULL, code) == FFI_OK);
+
+ res = ((long double(*)(long double, long double, long double, long double,
+ long double, long double, long double, long double))(code))(arg1, arg2,
+ arg3, arg4, arg5, arg6, arg7, arg8);
+ /* { dg-output "\n1 2 3 4 5 6 7 8: 36" } */
+ printf("res: %Lg\n", res);
+ /* { dg-output "\nres: 36" } */
+
+ return 0;
+}
diff --git a/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/cls_longdouble_va.c b/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/cls_longdouble_va.c
new file mode 100644
index 0000000..39b438b
--- /dev/null
+++ b/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/cls_longdouble_va.c
@@ -0,0 +1,61 @@
+/* Area: ffi_call, closure_call
+ Purpose: Test long doubles passed in variable argument lists.
+ Limitations: none.
+ PR: none.
+ Originator: Blake Chaffin 6/6/2007 */
+
+/* { dg-do run { xfail strongarm*-*-* xscale*-*-* } } */
+/* { dg-output "" { xfail avr32*-*-* x86_64-*-mingw* } } */
+/* { dg-output "" { xfail mips-sgi-irix6* } } PR libffi/46660 */
+
+#include "ffitest.h"
+
+static void
+cls_longdouble_va_fn(ffi_cif* cif __UNUSED__, void* resp,
+ void** args, void* userdata __UNUSED__)
+{
+ char* format = *(char**)args[0];
+ long double ldValue = *(long double*)args[1];
+
+ *(ffi_arg*)resp = printf(format, ldValue);
+}
+
+int main (void)
+{
+ ffi_cif cif;
+ void *code;
+ ffi_closure *pcl = ffi_closure_alloc(sizeof(ffi_closure), &code);
+ void* args[3];
+ ffi_type* arg_types[3];
+
+ char* format = "%.1Lf\n";
+ long double ldArg = 7;
+ ffi_arg res = 0;
+
+ arg_types[0] = &ffi_type_pointer;
+ arg_types[1] = &ffi_type_longdouble;
+ arg_types[2] = NULL;
+
+ /* This printf call is variadic */
+ CHECK(ffi_prep_cif_var(&cif, FFI_DEFAULT_ABI, 1, 2, &ffi_type_sint,
+ arg_types) == FFI_OK);
+
+ args[0] = &format;
+ args[1] = &ldArg;
+ args[2] = NULL;
+
+ ffi_call(&cif, FFI_FN(printf), &res, args);
+ /* { dg-output "7.0" } */
+ printf("res: %d\n", (int) res);
+ /* { dg-output "\nres: 4" } */
+
+ CHECK(ffi_prep_closure_loc(pcl, &cif, cls_longdouble_va_fn, NULL,
+ code) == FFI_OK);
+
+ res = ((int(*)(char*, ...))(code))(format, ldArg);
+ /* { dg-output "\n7.0" } */
+ printf("res: %d\n", (int) res);
+ /* { dg-output "\nres: 4" } */
+
+ exit(0);
+}
diff --git a/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/cls_multi_schar.c b/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/cls_multi_schar.c
new file mode 100644
index 0000000..71df7b6
--- /dev/null
+++ b/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/cls_multi_schar.c
@@ -0,0 +1,74 @@
+/* Area: ffi_call, closure_call
+ Purpose: Check passing of multiple signed char values.
+ Limitations: none.
+ PR: PR13221.
+ Originator: <hos@tamanegi.org> 20031129 */
+
+/* { dg-do run } */
+#include "ffitest.h"
+
+signed char test_func_fn(signed char a1, signed char a2)
+{
+ signed char result;
+
+ result = a1 + a2;
+
+ printf("%d %d: %d\n", a1, a2, result);
+
+ return result;
+
+}
+
+static void test_func_gn(ffi_cif *cif __UNUSED__, void *rval, void **avals,
+ void *data __UNUSED__)
+{
+ signed char a1, a2;
+
+ a1 = *(signed char *)avals[0];
+ a2 = *(signed char *)avals[1];
+
+ *(ffi_arg *)rval = test_func_fn(a1, a2);
+
+}
+
+typedef signed char (*test_type)(signed char, signed char);
+
+int main (void)
+{
+ ffi_cif cif;
+ void *code;
+ ffi_closure *pcl = ffi_closure_alloc(sizeof(ffi_closure), &code);
+ void * args_dbl[3];
+ ffi_type * cl_arg_types[3];
+ ffi_arg res_call;
+ signed char a, b, res_closure;
+
+ a = 2;
+ b = 125;
+
+ args_dbl[0] = &a;
+ args_dbl[1] = &b;
+ args_dbl[2] = NULL;
+
+ cl_arg_types[0] = &ffi_type_schar;
+ cl_arg_types[1] = &ffi_type_schar;
+ cl_arg_types[2] = NULL;
+
+ /* Initialize the cif */
+ CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 2,
+ &ffi_type_schar, cl_arg_types) == FFI_OK);
+
+ ffi_call(&cif, FFI_FN(test_func_fn), &res_call, args_dbl);
+ /* { dg-output "2 125: 127" } */
+ printf("res: %d\n", (signed char)res_call);
+ /* { dg-output "\nres: 127" } */
+
+ CHECK(ffi_prep_closure_loc(pcl, &cif, test_func_gn, NULL, code) == FFI_OK);
+
+ res_closure = (*((test_type)code))(2, 125);
+ /* { dg-output "\n2 125: 127" } */
+ printf("res: %d\n", res_closure);
+ /* { dg-output "\nres: 127" } */
+
+ exit(0);
+}
diff --git a/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/cls_multi_sshort.c b/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/cls_multi_sshort.c
new file mode 100644
index 0000000..4c39153
--- /dev/null
+++ b/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/cls_multi_sshort.c
@@ -0,0 +1,74 @@
+/* Area: ffi_call, closure_call
+ Purpose: Check passing of multiple signed short values.
+ Limitations: none.
+ PR: PR13221.
+ Originator: <andreast@gcc.gnu.org> 20031129 */
+
+/* { dg-do run } */
+#include "ffitest.h"
+
+signed short test_func_fn(signed short a1, signed short a2)
+{
+ signed short result;
+
+ result = a1 + a2;
+
+ printf("%d %d: %d\n", a1, a2, result);
+
+ return result;
+
+}
+
+static void test_func_gn(ffi_cif *cif __UNUSED__, void *rval, void **avals,
+ void *data __UNUSED__)
+{
+ signed short a1, a2;
+
+ a1 = *(signed short *)avals[0];
+ a2 = *(signed short *)avals[1];
+
+ *(ffi_arg *)rval = test_func_fn(a1, a2);
+
+}
+
+typedef signed short (*test_type)(signed short, signed short);
+
+int main (void)
+{
+ ffi_cif cif;
+ void *code;
+ ffi_closure *pcl = ffi_closure_alloc(sizeof(ffi_closure), &code);
+ void * args_dbl[3];
+ ffi_type * cl_arg_types[3];
+ ffi_arg res_call;
+ unsigned short a, b, res_closure;
+
+ a = 2;
+ b = 32765;
+
+ args_dbl[0] = &a;
+ args_dbl[1] = &b;
+ args_dbl[2] = NULL;
+
+ cl_arg_types[0] = &ffi_type_sshort;
+ cl_arg_types[1] = &ffi_type_sshort;
+ cl_arg_types[2] = NULL;
+
+ /* Initialize the cif */
+ CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 2,
+ &ffi_type_sshort, cl_arg_types) == FFI_OK);
+
+ ffi_call(&cif, FFI_FN(test_func_fn), &res_call, args_dbl);
+ /* { dg-output "2 32765: 32767" } */
+ printf("res: %d\n", (unsigned short)res_call);
+ /* { dg-output "\nres: 32767" } */
+
+ CHECK(ffi_prep_closure_loc(pcl, &cif, test_func_gn, NULL, code) == FFI_OK);
+
+ res_closure = (*((test_type)code))(2, 32765);
+ /* { dg-output "\n2 32765: 32767" } */
+ printf("res: %d\n", res_closure);
+ /* { dg-output "\nres: 32767" } */
+
+ exit(0);
+}
diff --git a/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/cls_multi_sshortchar.c b/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/cls_multi_sshortchar.c
new file mode 100644
index 0000000..1c3aeb5
--- /dev/null
+++ b/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/cls_multi_sshortchar.c
@@ -0,0 +1,86 @@
+/* Area: ffi_call, closure_call
+ Purpose: Check passing of multiple signed short/char values.
+ Limitations: none.
+ PR: PR13221.
+ Originator: <andreast@gcc.gnu.org> 20031129 */
+
+/* { dg-do run } */
+#include "ffitest.h"
+
+signed short test_func_fn(signed char a1, signed short a2,
+ signed char a3, signed short a4)
+{
+ signed short result;
+
+ result = a1 + a2 + a3 + a4;
+
+ printf("%d %d %d %d: %d\n", a1, a2, a3, a4, result);
+
+ return result;
+
+}
+
+static void test_func_gn(ffi_cif *cif __UNUSED__, void *rval, void **avals,
+ void *data __UNUSED__)
+{
+ signed char a1, a3;
+ signed short a2, a4;
+
+ a1 = *(signed char *)avals[0];
+ a2 = *(signed short *)avals[1];
+ a3 = *(signed char *)avals[2];
+ a4 = *(signed short *)avals[3];
+
+ *(ffi_arg *)rval = test_func_fn(a1, a2, a3, a4);
+
+}
+
+typedef signed short (*test_type)(signed char, signed short,
+ signed char, signed short);
+
+int main (void)
+{
+ ffi_cif cif;
+ void *code;
+ ffi_closure *pcl = ffi_closure_alloc(sizeof(ffi_closure), &code);
+ void * args_dbl[5];
+ ffi_type * cl_arg_types[5];
+ ffi_arg res_call;
+ signed char a, c;
+ signed short b, d, res_closure;
+
+ a = 1;
+ b = 32765;
+ c = 127;
+ d = -128;
+
+ args_dbl[0] = &a;
+ args_dbl[1] = &b;
+ args_dbl[2] = &c;
+ args_dbl[3] = &d;
+ args_dbl[4] = NULL;
+
+ cl_arg_types[0] = &ffi_type_schar;
+ cl_arg_types[1] = &ffi_type_sshort;
+ cl_arg_types[2] = &ffi_type_schar;
+ cl_arg_types[3] = &ffi_type_sshort;
+ cl_arg_types[4] = NULL;
+
+ /* Initialize the cif */
+ CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 4,
+ &ffi_type_sshort, cl_arg_types) == FFI_OK);
+
+ ffi_call(&cif, FFI_FN(test_func_fn), &res_call, args_dbl);
+ /* { dg-output "1 32765 127 -128: 32765" } */
+ printf("res: %d\n", (signed short)res_call);
+ /* { dg-output "\nres: 32765" } */
+
+ CHECK(ffi_prep_closure_loc(pcl, &cif, test_func_gn, NULL, code) == FFI_OK);
+
+ res_closure = (*((test_type)code))(1, 32765, 127, -128);
+ /* { dg-output "\n1 32765 127 -128: 32765" } */
+ printf("res: %d\n", res_closure);
+ /* { dg-output "\nres: 32765" } */
+
+ exit(0);
+}
diff --git a/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/cls_multi_uchar.c b/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/cls_multi_uchar.c
new file mode 100644
index 0000000..009c02c
--- /dev/null
+++ b/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/cls_multi_uchar.c
@@ -0,0 +1,91 @@
+/* Area: ffi_call, closure_call
+ Purpose: Check passing of multiple unsigned char values.
+ Limitations: none.
+ PR: PR13221.
+ Originator: <andreast@gcc.gnu.org> 20031129 */
+
+/* { dg-do run } */
+#include "ffitest.h"
+
+unsigned char test_func_fn(unsigned char a1, unsigned char a2,
+ unsigned char a3, unsigned char a4)
+{
+ unsigned char result;
+
+ result = a1 + a2 + a3 + a4;
+
+ printf("%d %d %d %d: %d\n", a1, a2, a3, a4, result);
+
+ return result;
+
+}
+
+static void test_func_gn(ffi_cif *cif __UNUSED__, void *rval, void **avals,
+ void *data __UNUSED__)
+{
+ unsigned char a1, a2, a3, a4;
+
+ a1 = *(unsigned char *)avals[0];
+ a2 = *(unsigned char *)avals[1];
+ a3 = *(unsigned char *)avals[2];
+ a4 = *(unsigned char *)avals[3];
+
+ *(ffi_arg *)rval = test_func_fn(a1, a2, a3, a4);
+
+}
+
+typedef unsigned char (*test_type)(unsigned char, unsigned char,
+ unsigned char, unsigned char);
+
+void test_func(ffi_cif *cif __UNUSED__, void *rval __UNUSED__, void **avals,
+ void *data __UNUSED__)
+{
+ printf("%d %d %d %d\n", *(unsigned char *)avals[0],
+ *(unsigned char *)avals[1], *(unsigned char *)avals[2],
+ *(unsigned char *)avals[3]);
+}
+int main (void)
+{
+ ffi_cif cif;
+ void *code;
+ ffi_closure *pcl = ffi_closure_alloc(sizeof(ffi_closure), &code);
+ void * args_dbl[5];
+ ffi_type * cl_arg_types[5];
+ ffi_arg res_call;
+ unsigned char a, b, c, d, res_closure;
+
+ a = 1;
+ b = 2;
+ c = 127;
+ d = 125;
+
+ args_dbl[0] = &a;
+ args_dbl[1] = &b;
+ args_dbl[2] = &c;
+ args_dbl[3] = &d;
+ args_dbl[4] = NULL;
+
+ cl_arg_types[0] = &ffi_type_uchar;
+ cl_arg_types[1] = &ffi_type_uchar;
+ cl_arg_types[2] = &ffi_type_uchar;
+ cl_arg_types[3] = &ffi_type_uchar;
+ cl_arg_types[4] = NULL;
+
+ /* Initialize the cif */
+ CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 4,
+ &ffi_type_uchar, cl_arg_types) == FFI_OK);
+
+ ffi_call(&cif, FFI_FN(test_func_fn), &res_call, args_dbl);
+ /* { dg-output "1 2 127 125: 255" } */
+ printf("res: %d\n", (unsigned char)res_call);
+ /* { dg-output "\nres: 255" } */
+
+ CHECK(ffi_prep_closure_loc(pcl, &cif, test_func_gn, NULL, code) == FFI_OK);
+
+ res_closure = (*((test_type)code))(1, 2, 127, 125);
+ /* { dg-output "\n1 2 127 125: 255" } */
+ printf("res: %d\n", res_closure);
+ /* { dg-output "\nres: 255" } */
+
+ exit(0);
+}
diff --git a/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/cls_multi_ushort.c b/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/cls_multi_ushort.c
new file mode 100644
index 0000000..dd10ca7
--- /dev/null
+++ b/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/cls_multi_ushort.c
@@ -0,0 +1,74 @@
+/* Area: ffi_call, closure_call
+ Purpose: Check passing of multiple unsigned short values.
+ Limitations: none.
+ PR: PR13221.
+ Originator: <andreast@gcc.gnu.org> 20031129 */
+
+/* { dg-do run } */
+#include "ffitest.h"
+
+unsigned short test_func_fn(unsigned short a1, unsigned short a2)
+{
+ unsigned short result;
+
+ result = a1 + a2;
+
+ printf("%d %d: %d\n", a1, a2, result);
+
+ return result;
+
+}
+
+static void test_func_gn(ffi_cif *cif __UNUSED__, void *rval, void **avals,
+ void *data __UNUSED__)
+{
+ unsigned short a1, a2;
+
+ a1 = *(unsigned short *)avals[0];
+ a2 = *(unsigned short *)avals[1];
+
+ *(ffi_arg *)rval = test_func_fn(a1, a2);
+
+}
+
+typedef unsigned short (*test_type)(unsigned short, unsigned short);
+
+int main (void)
+{
+ ffi_cif cif;
+ void *code;
+ ffi_closure *pcl = ffi_closure_alloc(sizeof(ffi_closure), &code);
+ void * args_dbl[3];
+ ffi_type * cl_arg_types[3];
+ ffi_arg res_call;
+ unsigned short a, b, res_closure;
+
+ a = 2;
+ b = 32765;
+
+ args_dbl[0] = &a;
+ args_dbl[1] = &b;
+ args_dbl[2] = NULL;
+
+ cl_arg_types[0] = &ffi_type_ushort;
+ cl_arg_types[1] = &ffi_type_ushort;
+ cl_arg_types[2] = NULL;
+
+ /* Initialize the cif */
+ CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 2,
+ &ffi_type_ushort, cl_arg_types) == FFI_OK);
+
+ ffi_call(&cif, FFI_FN(test_func_fn), &res_call, args_dbl);
+ /* { dg-output "2 32765: 32767" } */
+ printf("res: %d\n", (unsigned short)res_call);
+ /* { dg-output "\nres: 32767" } */
+
+ CHECK(ffi_prep_closure_loc(pcl, &cif, test_func_gn, NULL, code) == FFI_OK);
+
+ res_closure = (*((test_type)code))(2, 32765);
+ /* { dg-output "\n2 32765: 32767" } */
+ printf("res: %d\n", res_closure);
+ /* { dg-output "\nres: 32767" } */
+
+ exit(0);
+}
diff --git a/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/cls_multi_ushortchar.c b/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/cls_multi_ushortchar.c
new file mode 100644
index 0000000..2588e97
--- /dev/null
+++ b/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/cls_multi_ushortchar.c
@@ -0,0 +1,86 @@
+/* Area: ffi_call, closure_call
+ Purpose: Check passing of multiple unsigned short/char values.
+ Limitations: none.
+ PR: PR13221.
+ Originator: <andreast@gcc.gnu.org> 20031129 */
+
+/* { dg-do run } */
+#include "ffitest.h"
+
+unsigned short test_func_fn(unsigned char a1, unsigned short a2,
+ unsigned char a3, unsigned short a4)
+{
+ unsigned short result;
+
+ result = a1 + a2 + a3 + a4;
+
+ printf("%d %d %d %d: %d\n", a1, a2, a3, a4, result);
+
+ return result;
+
+}
+
+static void test_func_gn(ffi_cif *cif __UNUSED__, void *rval, void **avals,
+ void *data __UNUSED__)
+{
+ unsigned char a1, a3;
+ unsigned short a2, a4;
+
+ a1 = *(unsigned char *)avals[0];
+ a2 = *(unsigned short *)avals[1];
+ a3 = *(unsigned char *)avals[2];
+ a4 = *(unsigned short *)avals[3];
+
+ *(ffi_arg *)rval = test_func_fn(a1, a2, a3, a4);
+
+}
+
+typedef unsigned short (*test_type)(unsigned char, unsigned short,
+ unsigned char, unsigned short);
+
+int main (void)
+{
+ ffi_cif cif;
+ void *code;
+ ffi_closure *pcl = ffi_closure_alloc(sizeof(ffi_closure), &code);
+ void * args_dbl[5];
+ ffi_type * cl_arg_types[5];
+ ffi_arg res_call;
+ unsigned char a, c;
+ unsigned short b, d, res_closure;
+
+ a = 1;
+ b = 2;
+ c = 127;
+ d = 128;
+
+ args_dbl[0] = &a;
+ args_dbl[1] = &b;
+ args_dbl[2] = &c;
+ args_dbl[3] = &d;
+ args_dbl[4] = NULL;
+
+ cl_arg_types[0] = &ffi_type_uchar;
+ cl_arg_types[1] = &ffi_type_ushort;
+ cl_arg_types[2] = &ffi_type_uchar;
+ cl_arg_types[3] = &ffi_type_ushort;
+ cl_arg_types[4] = NULL;
+
+ /* Initialize the cif */
+ CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 4,
+ &ffi_type_ushort, cl_arg_types) == FFI_OK);
+
+ ffi_call(&cif, FFI_FN(test_func_fn), &res_call, args_dbl);
+ /* { dg-output "1 2 127 128: 258" } */
+ printf("res: %d\n", (unsigned short)res_call);
+ /* { dg-output "\nres: 258" } */
+
+ CHECK(ffi_prep_closure_loc(pcl, &cif, test_func_gn, NULL, code) == FFI_OK);
+
+ res_closure = (*((test_type)code))(1, 2, 127, 128);
+ /* { dg-output "\n1 2 127 128: 258" } */
+ printf("res: %d\n", res_closure);
+ /* { dg-output "\nres: 258" } */
+
+ exit(0);
+}
diff --git a/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/cls_pointer.c b/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/cls_pointer.c
new file mode 100644
index 0000000..d82a87a
--- /dev/null
+++ b/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/cls_pointer.c
@@ -0,0 +1,74 @@
+/* Area: ffi_call, closure_call
+ Purpose: Check pointer arguments.
+ Limitations: none.
+ PR: none.
+ Originator: Blake Chaffin 6/6/2007 */
+
+/* { dg-do run { xfail strongarm*-*-* xscale*-*-* } } */
+#include "ffitest.h"
+
+void* cls_pointer_fn(void* a1, void* a2)
+{
+ void* result = (void*)((intptr_t)a1 + (intptr_t)a2);
+
+ printf("0x%08x 0x%08x: 0x%08x\n",
+ (unsigned int)(uintptr_t) a1,
+ (unsigned int)(uintptr_t) a2,
+ (unsigned int)(uintptr_t) result);
+
+ return result;
+}
+
+static void
+cls_pointer_gn(ffi_cif* cif __UNUSED__, void* resp,
+ void** args, void* userdata __UNUSED__)
+{
+ void* a1 = *(void**)(args[0]);
+ void* a2 = *(void**)(args[1]);
+
+ *(void**)resp = cls_pointer_fn(a1, a2);
+}
+
+int main (void)
+{
+ ffi_cif cif;
+ void *code;
+ ffi_closure* pcl = ffi_closure_alloc(sizeof(ffi_closure), &code);
+ void* args[3];
+ /* ffi_type cls_pointer_type; */
+ ffi_type* arg_types[3];
+
+/* cls_pointer_type.size = sizeof(void*);
+ cls_pointer_type.alignment = 0;
+ cls_pointer_type.type = FFI_TYPE_POINTER;
+ cls_pointer_type.elements = NULL;*/
+
+ void* arg1 = (void*)0x12345678;
+ void* arg2 = (void*)0x89abcdef;
+ ffi_arg res = 0;
+
+ arg_types[0] = &ffi_type_pointer;
+ arg_types[1] = &ffi_type_pointer;
+ arg_types[2] = NULL;
+
+ CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 2, &ffi_type_pointer,
+ arg_types) == FFI_OK);
+
+ args[0] = &arg1;
+ args[1] = &arg2;
+ args[2] = NULL;
+
+ ffi_call(&cif, FFI_FN(cls_pointer_fn), &res, args);
+ /* { dg-output "0x12345678 0x89abcdef: 0x9be02467" } */
+ printf("res: 0x%08x\n", (unsigned int) res);
+ /* { dg-output "\nres: 0x9be02467" } */
+
+ CHECK(ffi_prep_closure_loc(pcl, &cif, cls_pointer_gn, NULL, code) == FFI_OK);
+
+ res = (ffi_arg)(uintptr_t)((void*(*)(void*, void*))(code))(arg1, arg2);
+ /* { dg-output "\n0x12345678 0x89abcdef: 0x9be02467" } */
+ printf("res: 0x%08x\n", (unsigned int) res);
+ /* { dg-output "\nres: 0x9be02467" } */
+
+ exit(0);
+}
diff --git a/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/cls_pointer_stack.c b/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/cls_pointer_stack.c
new file mode 100644
index 0000000..1f1d915
--- /dev/null
+++ b/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/cls_pointer_stack.c
@@ -0,0 +1,142 @@
+/* Area: ffi_call, closure_call
+ Purpose: Check pointer arguments across multiple hideous stack frames.
+ Limitations: none.
+ PR: none.
+ Originator: Blake Chaffin 6/7/2007 */
+
+/* { dg-do run { xfail strongarm*-*-* xscale*-*-* } } */
+#include "ffitest.h"
+
+static long dummyVar;
+
+long dummy_func(
+ long double a1, char b1,
+ long double a2, char b2,
+ long double a3, char b3,
+ long double a4, char b4)
+{
+ return a1 + b1 + a2 + b2 + a3 + b3 + a4 + b4;
+}
+
+void* cls_pointer_fn2(void* a1, void* a2)
+{
+ long double trample1 = (intptr_t)a1 + (intptr_t)a2;
+ char trample2 = ((char*)&a1)[0] + ((char*)&a2)[0];
+ long double trample3 = (intptr_t)trample1 + (intptr_t)a1;
+ char trample4 = trample2 + ((char*)&a1)[1];
+ long double trample5 = (intptr_t)trample3 + (intptr_t)a2;
+ char trample6 = trample4 + ((char*)&a2)[1];
+ long double trample7 = (intptr_t)trample5 + (intptr_t)trample1;
+ char trample8 = trample6 + trample2;
+ void* result;
+
+ dummyVar = dummy_func(trample1, trample2, trample3, trample4,
+ trample5, trample6, trample7, trample8);
+
+ result = (void*)((intptr_t)a1 + (intptr_t)a2);
+
+ printf("0x%08x 0x%08x: 0x%08x\n",
+ (unsigned int)(uintptr_t) a1,
+ (unsigned int)(uintptr_t) a2,
+ (unsigned int)(uintptr_t) result);
+
+ return result;
+}
+
+void* cls_pointer_fn1(void* a1, void* a2)
+{
+ long double trample1 = (intptr_t)a1 + (intptr_t)a2;
+ char trample2 = ((char*)&a1)[0] + ((char*)&a2)[0];
+ long double trample3 = (intptr_t)trample1 + (intptr_t)a1;
+ char trample4 = trample2 + ((char*)&a1)[1];
+ long double trample5 = (intptr_t)trample3 + (intptr_t)a2;
+ char trample6 = trample4 + ((char*)&a2)[1];
+ long double trample7 = (intptr_t)trample5 + (intptr_t)trample1;
+ char trample8 = trample6 + trample2;
+ void* result;
+
+ dummyVar = dummy_func(trample1, trample2, trample3, trample4,
+ trample5, trample6, trample7, trample8);
+
+ result = (void*)((intptr_t)a1 + (intptr_t)a2);
+
+ printf("0x%08x 0x%08x: 0x%08x\n",
+ (unsigned int)(intptr_t) a1,
+ (unsigned int)(intptr_t) a2,
+ (unsigned int)(intptr_t) result);
+
+ result = cls_pointer_fn2(result, a1);
+
+ return result;
+}
+
+static void
+cls_pointer_gn(ffi_cif* cif __UNUSED__, void* resp,
+ void** args, void* userdata __UNUSED__)
+{
+ void* a1 = *(void**)(args[0]);
+ void* a2 = *(void**)(args[1]);
+
+ long double trample1 = (intptr_t)a1 + (intptr_t)a2;
+ char trample2 = ((char*)&a1)[0] + ((char*)&a2)[0];
+ long double trample3 = (intptr_t)trample1 + (intptr_t)a1;
+ char trample4 = trample2 + ((char*)&a1)[1];
+ long double trample5 = (intptr_t)trample3 + (intptr_t)a2;
+ char trample6 = trample4 + ((char*)&a2)[1];
+ long double trample7 = (intptr_t)trample5 + (intptr_t)trample1;
+ char trample8 = trample6 + trample2;
+
+ dummyVar = dummy_func(trample1, trample2, trample3, trample4,
+ trample5, trample6, trample7, trample8);
+
+ *(void**)resp = cls_pointer_fn1(a1, a2);
+}
+
+int main (void)
+{
+ ffi_cif cif;
+ void *code;
+ ffi_closure* pcl = ffi_closure_alloc(sizeof(ffi_closure), &code);
+ void* args[3];
+ /* ffi_type cls_pointer_type; */
+ ffi_type* arg_types[3];
+
+/* cls_pointer_type.size = sizeof(void*);
+ cls_pointer_type.alignment = 0;
+ cls_pointer_type.type = FFI_TYPE_POINTER;
+ cls_pointer_type.elements = NULL;*/
+
+ void* arg1 = (void*)0x01234567;
+ void* arg2 = (void*)0x89abcdef;
+ ffi_arg res = 0;
+
+ arg_types[0] = &ffi_type_pointer;
+ arg_types[1] = &ffi_type_pointer;
+ arg_types[2] = NULL;
+
+ CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 2, &ffi_type_pointer,
+ arg_types) == FFI_OK);
+
+ args[0] = &arg1;
+ args[1] = &arg2;
+ args[2] = NULL;
+
+ printf("\n");
+ ffi_call(&cif, FFI_FN(cls_pointer_fn1), &res, args);
+
+ printf("res: 0x%08x\n", (unsigned int) res);
+ /* { dg-output "\n0x01234567 0x89abcdef: 0x8acf1356" } */
+ /* { dg-output "\n0x8acf1356 0x01234567: 0x8bf258bd" } */
+ /* { dg-output "\nres: 0x8bf258bd" } */
+
+ CHECK(ffi_prep_closure_loc(pcl, &cif, cls_pointer_gn, NULL, code) == FFI_OK);
+
+ res = (ffi_arg)(uintptr_t)((void*(*)(void*, void*))(code))(arg1, arg2);
+
+ printf("res: 0x%08x\n", (unsigned int) res);
+ /* { dg-output "\n0x01234567 0x89abcdef: 0x8acf1356" } */
+ /* { dg-output "\n0x8acf1356 0x01234567: 0x8bf258bd" } */
+ /* { dg-output "\nres: 0x8bf258bd" } */
+
+ exit(0);
+}
diff --git a/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/cls_schar.c b/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/cls_schar.c
new file mode 100644
index 0000000..82986b1
--- /dev/null
+++ b/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/cls_schar.c
@@ -0,0 +1,44 @@
+/* Area: closure_call
+ Purpose: Check return value schar.
+ Limitations: none.
+ PR: none.
+ Originator: <andreast@gcc.gnu.org> 20031108 */
+
+
+
+/* { dg-do run } */
+#include "ffitest.h"
+
+static void cls_ret_schar_fn(ffi_cif* cif __UNUSED__, void* resp, void** args,
+ void* userdata __UNUSED__)
+{
+ *(ffi_arg*)resp = *(signed char *)args[0];
+ printf("%d: %d\n",*(signed char *)args[0],
+ (int)*(ffi_arg *)(resp));
+}
+typedef signed char (*cls_ret_schar)(signed char);
+
+int main (void)
+{
+ ffi_cif cif;
+ void *code;
+ ffi_closure *pcl = ffi_closure_alloc(sizeof(ffi_closure), &code);
+ ffi_type * cl_arg_types[2];
+ signed char res;
+
+ cl_arg_types[0] = &ffi_type_schar;
+ cl_arg_types[1] = NULL;
+
+ /* Initialize the cif */
+ CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 1,
+ &ffi_type_schar, cl_arg_types) == FFI_OK);
+
+ CHECK(ffi_prep_closure_loc(pcl, &cif, cls_ret_schar_fn, NULL, code) == FFI_OK);
+
+ res = (*((cls_ret_schar)code))(127);
+ /* { dg-output "127: 127" } */
+ printf("res: %d\n", res);
+ /* { dg-output "\nres: 127" } */
+
+ exit(0);
+}
diff --git a/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/cls_sint.c b/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/cls_sint.c
new file mode 100644
index 0000000..c7e13b7
--- /dev/null
+++ b/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/cls_sint.c
@@ -0,0 +1,42 @@
+/* Area: closure_call
+ Purpose: Check return value sint32.
+ Limitations: none.
+ PR: none.
+ Originator: <andreast@gcc.gnu.org> 20031108 */
+
+/* { dg-do run } */
+#include "ffitest.h"
+
+static void cls_ret_sint_fn(ffi_cif* cif __UNUSED__, void* resp, void** args,
+ void* userdata __UNUSED__)
+{
+ *(ffi_arg*)resp = *(signed int *)args[0];
+ printf("%d: %d\n",*(signed int *)args[0],
+ (int)*(ffi_arg *)(resp));
+}
+typedef signed int (*cls_ret_sint)(signed int);
+
+int main (void)
+{
+ ffi_cif cif;
+ void *code;
+ ffi_closure *pcl = ffi_closure_alloc(sizeof(ffi_closure), &code);
+ ffi_type * cl_arg_types[2];
+ signed int res;
+
+ cl_arg_types[0] = &ffi_type_sint;
+ cl_arg_types[1] = NULL;
+
+ /* Initialize the cif */
+ CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 1,
+ &ffi_type_sint, cl_arg_types) == FFI_OK);
+
+ CHECK(ffi_prep_closure_loc(pcl, &cif, cls_ret_sint_fn, NULL, code) == FFI_OK);
+
+ res = (*((cls_ret_sint)code))(65534);
+ /* { dg-output "65534: 65534" } */
+ printf("res: %d\n",res);
+ /* { dg-output "\nres: 65534" } */
+
+ exit(0);
+}
diff --git a/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/cls_sshort.c b/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/cls_sshort.c
new file mode 100644
index 0000000..846d57e
--- /dev/null
+++ b/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/cls_sshort.c
@@ -0,0 +1,42 @@
+/* Area: closure_call
+ Purpose: Check return value sshort.
+ Limitations: none.
+ PR: none.
+ Originator: <andreast@gcc.gnu.org> 20031108 */
+
+/* { dg-do run } */
+#include "ffitest.h"
+
+static void cls_ret_sshort_fn(ffi_cif* cif __UNUSED__, void* resp, void** args,
+ void* userdata __UNUSED__)
+{
+ *(ffi_arg*)resp = *(signed short *)args[0];
+ printf("%d: %d\n",*(signed short *)args[0],
+ (int)*(ffi_arg *)(resp));
+}
+typedef signed short (*cls_ret_sshort)(signed short);
+
+int main (void)
+{
+ ffi_cif cif;
+ void *code;
+ ffi_closure *pcl = ffi_closure_alloc(sizeof(ffi_closure), &code);
+ ffi_type * cl_arg_types[2];
+ signed short res;
+
+ cl_arg_types[0] = &ffi_type_sshort;
+ cl_arg_types[1] = NULL;
+
+ /* Initialize the cif */
+ CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 1,
+ &ffi_type_sshort, cl_arg_types) == FFI_OK);
+
+ CHECK(ffi_prep_closure_loc(pcl, &cif, cls_ret_sshort_fn, NULL, code) == FFI_OK);
+
+ res = (*((cls_ret_sshort)code))(255);
+ /* { dg-output "255: 255" } */
+ printf("res: %d\n",res);
+ /* { dg-output "\nres: 255" } */
+
+ exit(0);
+}
diff --git a/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/cls_struct_va1.c b/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/cls_struct_va1.c
new file mode 100644
index 0000000..6d1fdae
--- /dev/null
+++ b/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/cls_struct_va1.c
@@ -0,0 +1,114 @@
+/* Area: ffi_call, closure_call
+ Purpose: Test doubles passed in variable argument lists.
+ Limitations: none.
+ PR: none.
+ Originator: Blake Chaffin 6/6/2007 */
+
+/* { dg-do run } */
+/* { dg-output "" { xfail avr32*-*-* } } */
+#include "ffitest.h"
+
+struct small_tag
+{
+ unsigned char a;
+ unsigned char b;
+};
+
+struct large_tag
+{
+ unsigned a;
+ unsigned b;
+ unsigned c;
+ unsigned d;
+ unsigned e;
+};
+
+static void
+test_fn (ffi_cif* cif __UNUSED__, void* resp,
+ void** args, void* userdata __UNUSED__)
+{
+ int n = *(int*)args[0];
+ struct small_tag s1 = * (struct small_tag *) args[1];
+ struct large_tag l1 = * (struct large_tag *) args[2];
+ struct small_tag s2 = * (struct small_tag *) args[3];
+
+ printf ("%d %d %d %d %d %d %d %d %d %d\n", n, s1.a, s1.b,
+ l1.a, l1.b, l1.c, l1.d, l1.e,
+ s2.a, s2.b);
+ * (ffi_arg*) resp = 42;
+}
+
+int
+main (void)
+{
+ ffi_cif cif;
+ void *code;
+ ffi_closure *pcl = ffi_closure_alloc (sizeof (ffi_closure), &code);
+ ffi_type* arg_types[5];
+
+ ffi_arg res = 0;
+
+ ffi_type s_type;
+ ffi_type *s_type_elements[3];
+
+ ffi_type l_type;
+ ffi_type *l_type_elements[6];
+
+ struct small_tag s1;
+ struct small_tag s2;
+ struct large_tag l1;
+
+ int si;
+
+ s_type.size = 0;
+ s_type.alignment = 0;
+ s_type.type = FFI_TYPE_STRUCT;
+ s_type.elements = s_type_elements;
+
+ s_type_elements[0] = &ffi_type_uchar;
+ s_type_elements[1] = &ffi_type_uchar;
+ s_type_elements[2] = NULL;
+
+ l_type.size = 0;
+ l_type.alignment = 0;
+ l_type.type = FFI_TYPE_STRUCT;
+ l_type.elements = l_type_elements;
+
+ l_type_elements[0] = &ffi_type_uint;
+ l_type_elements[1] = &ffi_type_uint;
+ l_type_elements[2] = &ffi_type_uint;
+ l_type_elements[3] = &ffi_type_uint;
+ l_type_elements[4] = &ffi_type_uint;
+ l_type_elements[5] = NULL;
+
+ arg_types[0] = &ffi_type_sint;
+ arg_types[1] = &s_type;
+ arg_types[2] = &l_type;
+ arg_types[3] = &s_type;
+ arg_types[4] = NULL;
+
+ CHECK(ffi_prep_cif_var(&cif, FFI_DEFAULT_ABI, 1, 4, &ffi_type_sint,
+ arg_types) == FFI_OK);
+
+ si = 4;
+ s1.a = 5;
+ s1.b = 6;
+
+ s2.a = 20;
+ s2.b = 21;
+
+ l1.a = 10;
+ l1.b = 11;
+ l1.c = 12;
+ l1.d = 13;
+ l1.e = 14;
+
+ CHECK(ffi_prep_closure_loc(pcl, &cif, test_fn, NULL, code) == FFI_OK);
+
+ res = ((int (*)(int, ...))(code))(si, s1, l1, s2);
+ /* { dg-output "4 5 6 10 11 12 13 14 20 21" } */
+ printf("res: %d\n", (int) res);
+ /* { dg-output "\nres: 42" } */
+
+ exit(0);
+}
diff --git a/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/cls_uchar.c b/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/cls_uchar.c
new file mode 100644
index 0000000..c1317e7
--- /dev/null
+++ b/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/cls_uchar.c
@@ -0,0 +1,42 @@
+/* Area: closure_call
+ Purpose: Check return value uchar.
+ Limitations: none.
+ PR: none.
+ Originator: <andreast@gcc.gnu.org> 20030828 */
+
+/* { dg-do run } */
+#include "ffitest.h"
+
+static void cls_ret_uchar_fn(ffi_cif* cif __UNUSED__, void* resp, void** args,
+ void* userdata __UNUSED__)
+{
+ *(ffi_arg*)resp = *(unsigned char *)args[0];
+ printf("%d: %d\n",*(unsigned char *)args[0],
+ (int)*(ffi_arg *)(resp));
+}
+typedef unsigned char (*cls_ret_uchar)(unsigned char);
+
+int main (void)
+{
+ ffi_cif cif;
+ void *code;
+ ffi_closure *pcl = ffi_closure_alloc(sizeof(ffi_closure), &code);
+ ffi_type * cl_arg_types[2];
+ unsigned char res;
+
+ cl_arg_types[0] = &ffi_type_uchar;
+ cl_arg_types[1] = NULL;
+
+ /* Initialize the cif */
+ CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 1,
+ &ffi_type_uchar, cl_arg_types) == FFI_OK);
+
+ CHECK(ffi_prep_closure_loc(pcl, &cif, cls_ret_uchar_fn, NULL, code) == FFI_OK);
+
+ res = (*((cls_ret_uchar)code))(127);
+ /* { dg-output "127: 127" } */
+ printf("res: %d\n",res);
+ /* { dg-output "\nres: 127" } */
+
+ exit(0);
+}
diff --git a/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/cls_uchar_va.c b/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/cls_uchar_va.c
new file mode 100644
index 0000000..6491c5b
--- /dev/null
+++ b/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/cls_uchar_va.c
@@ -0,0 +1,44 @@
+/* Area: closure_call
+ Purpose: Test anonymous unsigned char argument.
+ Limitations: none.
+ PR: none.
+ Originator: ARM Ltd. */
+
+/* { dg-do run } */
+#include "ffitest.h"
+
+typedef unsigned char T;
+
+static void cls_ret_T_fn(ffi_cif* cif __UNUSED__, void* resp, void** args,
+ void* userdata __UNUSED__)
+ {
+ *(ffi_arg *)resp = *(T *)args[0];
+
+ printf("%d: %d %d\n", (int)(*(ffi_arg *)resp), *(T *)args[0], *(T *)args[1]);
+ }
+
+typedef T (*cls_ret_T)(T, ...);
+
+int main (void)
+{
+ ffi_cif cif;
+ void *code;
+ ffi_closure *pcl = ffi_closure_alloc(sizeof(ffi_closure), &code);
+ ffi_type * cl_arg_types[3];
+ T res;
+
+ cl_arg_types[0] = &ffi_type_uchar;
+ cl_arg_types[1] = &ffi_type_uchar;
+ cl_arg_types[2] = NULL;
+
+ /* Initialize the cif */
+ CHECK(ffi_prep_cif_var(&cif, FFI_DEFAULT_ABI, 1, 2,
+ &ffi_type_uchar, cl_arg_types) == FFI_OK);
+
+ CHECK(ffi_prep_closure_loc(pcl, &cif, cls_ret_T_fn, NULL, code) == FFI_OK);
+ res = ((((cls_ret_T)code)(67, 4)));
+ /* { dg-output "67: 67 4" } */
+ printf("res: %d\n", res);
+ /* { dg-output "\nres: 67" } */
+ exit(0);
+}
diff --git a/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/cls_uint.c b/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/cls_uint.c
new file mode 100644
index 0000000..885cff5
--- /dev/null
+++ b/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/cls_uint.c
@@ -0,0 +1,43 @@
+/* Area: closure_call
+ Purpose: Check return value uint.
+ Limitations: none.
+ PR: none.
+ Originator: <andreast@gcc.gnu.org> 20030828 */
+
+/* { dg-do run } */
+#include "ffitest.h"
+
+static void cls_ret_uint_fn(ffi_cif* cif __UNUSED__, void* resp, void** args,
+ void* userdata __UNUSED__)
+{
+ *(ffi_arg *)resp = *(unsigned int *)args[0];
+
+ printf("%d: %d\n",*(unsigned int *)args[0],
+ (int)*(ffi_arg *)(resp));
+}
+typedef unsigned int (*cls_ret_uint)(unsigned int);
+
+int main (void)
+{
+ ffi_cif cif;
+ void *code;
+ ffi_closure *pcl = ffi_closure_alloc(sizeof(ffi_closure), &code);
+ ffi_type * cl_arg_types[2];
+ unsigned int res;
+
+ cl_arg_types[0] = &ffi_type_uint;
+ cl_arg_types[1] = NULL;
+
+ /* Initialize the cif */
+ CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 1,
+ &ffi_type_uint, cl_arg_types) == FFI_OK);
+
+ CHECK(ffi_prep_closure_loc(pcl, &cif, cls_ret_uint_fn, NULL, code) == FFI_OK);
+
+ res = (*((cls_ret_uint)code))(2147483647);
+ /* { dg-output "2147483647: 2147483647" } */
+ printf("res: %d\n",res);
+ /* { dg-output "\nres: 2147483647" } */
+
+ exit(0);
+}
diff --git a/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/cls_uint_va.c b/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/cls_uint_va.c
new file mode 100644
index 0000000..b04cfd1
--- /dev/null
+++ b/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/cls_uint_va.c
@@ -0,0 +1,45 @@
+/* Area: closure_call
+ Purpose: Test anonymous unsigned int argument.
+ Limitations: none.
+ PR: none.
+ Originator: ARM Ltd. */
+
+/* { dg-do run } */
+
+#include "ffitest.h"
+
+typedef unsigned int T;
+
+static void cls_ret_T_fn(ffi_cif* cif __UNUSED__, void* resp, void** args,
+ void* userdata __UNUSED__)
+ {
+ *(ffi_arg *)resp = *(T *)args[0];
+
+ printf("%d: %d %d\n", (int)*(ffi_arg *)resp, *(T *)args[0], *(T *)args[1]);
+ }
+
+typedef T (*cls_ret_T)(T, ...);
+
+int main (void)
+{
+ ffi_cif cif;
+ void *code;
+ ffi_closure *pcl = ffi_closure_alloc(sizeof(ffi_closure), &code);
+ ffi_type * cl_arg_types[3];
+ T res;
+
+ cl_arg_types[0] = &ffi_type_uint;
+ cl_arg_types[1] = &ffi_type_uint;
+ cl_arg_types[2] = NULL;
+
+ /* Initialize the cif */
+ CHECK(ffi_prep_cif_var(&cif, FFI_DEFAULT_ABI, 1, 2,
+ &ffi_type_uint, cl_arg_types) == FFI_OK);
+
+ CHECK(ffi_prep_closure_loc(pcl, &cif, cls_ret_T_fn, NULL, code) == FFI_OK);
+ res = ((((cls_ret_T)code)(67, 4)));
+ /* { dg-output "67: 67 4" } */
+ printf("res: %d\n", res);
+ /* { dg-output "\nres: 67" } */
+ exit(0);
+}
diff --git a/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/cls_ulong_va.c b/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/cls_ulong_va.c
new file mode 100644
index 0000000..0315082
--- /dev/null
+++ b/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/cls_ulong_va.c
@@ -0,0 +1,45 @@
+/* Area: closure_call
+ Purpose: Test anonymous unsigned long argument.
+ Limitations: none.
+ PR: none.
+ Originator: ARM Ltd. */
+
+/* { dg-do run } */
+
+#include "ffitest.h"
+
+typedef unsigned long T;
+
+static void cls_ret_T_fn(ffi_cif* cif __UNUSED__, void* resp, void** args,
+ void* userdata __UNUSED__)
+ {
+ *(T *)resp = *(T *)args[0];
+
+ printf("%ld: %ld %ld\n", *(T *)resp, *(T *)args[0], *(T *)args[1]);
+ }
+
+typedef T (*cls_ret_T)(T, ...);
+
+int main (void)
+{
+ ffi_cif cif;
+ void *code;
+ ffi_closure *pcl = ffi_closure_alloc(sizeof(ffi_closure), &code);
+ ffi_type * cl_arg_types[3];
+ T res;
+
+ cl_arg_types[0] = &ffi_type_ulong;
+ cl_arg_types[1] = &ffi_type_ulong;
+ cl_arg_types[2] = NULL;
+
+ /* Initialize the cif */
+ CHECK(ffi_prep_cif_var(&cif, FFI_DEFAULT_ABI, 1, 2,
+ &ffi_type_ulong, cl_arg_types) == FFI_OK);
+
+ CHECK(ffi_prep_closure_loc(pcl, &cif, cls_ret_T_fn, NULL, code) == FFI_OK);
+ res = ((((cls_ret_T)code)(67, 4)));
+ /* { dg-output "67: 67 4" } */
+ printf("res: %ld\n", res);
+ /* { dg-output "\nres: 67" } */
+ exit(0);
+}
diff --git a/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/cls_ulonglong.c b/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/cls_ulonglong.c
new file mode 100644
index 0000000..62f2cae
--- /dev/null
+++ b/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/cls_ulonglong.c
@@ -0,0 +1,47 @@
+/* Area: closure_call
+ Purpose: Check return value long long.
+ Limitations: none.
+ PR: none.
+ Originator: <andreast@gcc.gnu.org> 20030828 */
+
+/* { dg-do run } */
+/* { dg-options "-Wno-format" { target alpha*-dec-osf* } } */
+#include "ffitest.h"
+
+static void cls_ret_ulonglong_fn(ffi_cif* cif __UNUSED__, void* resp,
+ void** args, void* userdata __UNUSED__)
+{
+ *(unsigned long long *)resp= 0xfffffffffffffffLL ^ *(unsigned long long *)args[0];
+
+ printf("%" PRIuLL ": %" PRIuLL "\n",*(unsigned long long *)args[0],
+ *(unsigned long long *)(resp));
+}
+typedef unsigned long long (*cls_ret_ulonglong)(unsigned long long);
+
+int main (void)
+{
+ ffi_cif cif;
+ void *code;
+ ffi_closure *pcl = ffi_closure_alloc(sizeof(ffi_closure), &code);
+ ffi_type * cl_arg_types[2];
+ unsigned long long res;
+
+ cl_arg_types[0] = &ffi_type_uint64;
+ cl_arg_types[1] = NULL;
+
+ /* Initialize the cif */
+ CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 1,
+ &ffi_type_uint64, cl_arg_types) == FFI_OK);
+ CHECK(ffi_prep_closure_loc(pcl, &cif, cls_ret_ulonglong_fn, NULL, code) == FFI_OK);
+ res = (*((cls_ret_ulonglong)code))(214LL);
+ /* { dg-output "214: 1152921504606846761" } */
+ printf("res: %" PRIdLL "\n", res);
+ /* { dg-output "\nres: 1152921504606846761" } */
+
+ res = (*((cls_ret_ulonglong)code))(9223372035854775808LL);
+ /* { dg-output "\n9223372035854775808: 8070450533247928831" } */
+ printf("res: %" PRIdLL "\n", res);
+ /* { dg-output "\nres: 8070450533247928831" } */
+
+ exit(0);
+}
diff --git a/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/cls_ushort.c b/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/cls_ushort.c
new file mode 100644
index 0000000..a00100e
--- /dev/null
+++ b/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/cls_ushort.c
@@ -0,0 +1,43 @@
+/* Area: closure_call
+ Purpose: Check return value ushort.
+ Limitations: none.
+ PR: none.
+ Originator: <andreast@gcc.gnu.org> 20030828 */
+
+/* { dg-do run } */
+#include "ffitest.h"
+
+static void cls_ret_ushort_fn(ffi_cif* cif __UNUSED__, void* resp, void** args,
+ void* userdata __UNUSED__)
+{
+ *(ffi_arg*)resp = *(unsigned short *)args[0];
+
+ printf("%d: %d\n",*(unsigned short *)args[0],
+ (int)*(ffi_arg *)(resp));
+}
+typedef unsigned short (*cls_ret_ushort)(unsigned short);
+
+int main (void)
+{
+ ffi_cif cif;
+ void *code;
+ ffi_closure *pcl = ffi_closure_alloc(sizeof(ffi_closure), &code);
+ ffi_type * cl_arg_types[2];
+ unsigned short res;
+
+ cl_arg_types[0] = &ffi_type_ushort;
+ cl_arg_types[1] = NULL;
+
+ /* Initialize the cif */
+ CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 1,
+ &ffi_type_ushort, cl_arg_types) == FFI_OK);
+
+ CHECK(ffi_prep_closure_loc(pcl, &cif, cls_ret_ushort_fn, NULL, code) == FFI_OK);
+
+ res = (*((cls_ret_ushort)code))(65535);
+ /* { dg-output "65535: 65535" } */
+ printf("res: %d\n",res);
+ /* { dg-output "\nres: 65535" } */
+
+ exit(0);
+}
diff --git a/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/cls_ushort_va.c b/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/cls_ushort_va.c
new file mode 100644
index 0000000..37aa106
--- /dev/null
+++ b/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/cls_ushort_va.c
@@ -0,0 +1,44 @@
+/* Area: closure_call
+ Purpose: Test anonymous unsigned short argument.
+ Limitations: none.
+ PR: none.
+ Originator: ARM Ltd. */
+
+/* { dg-do run } */
+#include "ffitest.h"
+
+typedef unsigned short T;
+
+static void cls_ret_T_fn(ffi_cif* cif __UNUSED__, void* resp, void** args,
+ void* userdata __UNUSED__)
+ {
+ *(ffi_arg *)resp = *(T *)args[0];
+
+ printf("%d: %d %d\n", (int)(*(ffi_arg *)resp), *(T *)args[0], *(T *)args[1]);
+ }
+
+typedef T (*cls_ret_T)(T, ...);
+
+int main (void)
+{
+ ffi_cif cif;
+ void *code;
+ ffi_closure *pcl = ffi_closure_alloc(sizeof(ffi_closure), &code);
+ ffi_type * cl_arg_types[3];
+ T res;
+
+ cl_arg_types[0] = &ffi_type_ushort;
+ cl_arg_types[1] = &ffi_type_ushort;
+ cl_arg_types[2] = NULL;
+
+ /* Initialize the cif */
+ CHECK(ffi_prep_cif_var(&cif, FFI_DEFAULT_ABI, 1, 2,
+ &ffi_type_ushort, cl_arg_types) == FFI_OK);
+
+ CHECK(ffi_prep_closure_loc(pcl, &cif, cls_ret_T_fn, NULL, code) == FFI_OK);
+ res = ((((cls_ret_T)code)(67, 4)));
+ /* { dg-output "67: 67 4" } */
+ printf("res: %d\n", res);
+ /* { dg-output "\nres: 67" } */
+ exit(0);
+}
diff --git a/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/err_bad_abi.c b/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/err_bad_abi.c
new file mode 100644
index 0000000..f5a7317
--- /dev/null
+++ b/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/err_bad_abi.c
@@ -0,0 +1,36 @@
+/* Area: ffi_prep_cif, ffi_prep_closure
+ Purpose: Test error return for bad ABIs.
+ Limitations: none.
+ PR: none.
+ Originator: Blake Chaffin 6/6/2007 */
+
+/* { dg-do run } */
+
+#include "ffitest.h"
+
+static void
+dummy_fn(ffi_cif* cif __UNUSED__, void* resp __UNUSED__,
+ void** args __UNUSED__, void* userdata __UNUSED__)
+{}
+
+int main (void)
+{
+ ffi_cif cif;
+ void *code;
+ ffi_closure *pcl = ffi_closure_alloc(sizeof(ffi_closure), &code);
+ ffi_type* arg_types[1];
+
+ arg_types[0] = NULL;
+
+ CHECK(ffi_prep_cif(&cif, 255, 0, &ffi_type_void,
+ arg_types) == FFI_BAD_ABI);
+
+ CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 0, &ffi_type_void,
+ arg_types) == FFI_OK);
+
+ cif.abi= 255;
+
+ CHECK(ffi_prep_closure_loc(pcl, &cif, dummy_fn, NULL, code) == FFI_BAD_ABI);
+
+ exit(0);
+}
diff --git a/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/err_bad_typedef.c b/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/err_bad_typedef.c
new file mode 100644
index 0000000..bf60161
--- /dev/null
+++ b/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/err_bad_typedef.c
@@ -0,0 +1,26 @@
+/* Area: ffi_prep_cif
+ Purpose: Test error return for bad typedefs.
+ Limitations: none.
+ PR: none.
+ Originator: Blake Chaffin 6/6/2007 */
+
+/* { dg-do run } */
+
+#include "ffitest.h"
+
+int main (void)
+{
+ ffi_cif cif;
+ ffi_type* arg_types[1];
+
+ ffi_type badType = ffi_type_void;
+
+ arg_types[0] = NULL;
+
+ badType.size = 0;
+
+ CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 0, &badType,
+ arg_types) == FFI_BAD_TYPEDEF);
+
+ exit(0);
+}
diff --git a/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/ffitest.h b/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/ffitest.h
new file mode 100644
index 0000000..15d5e44
--- /dev/null
+++ b/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/ffitest.h
@@ -0,0 +1,135 @@
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include <fcntl.h>
+#include <ffi.h>
+#include "fficonfig.h"
+
+#if defined HAVE_STDINT_H
+#include <stdint.h>
+#endif
+
+#if defined HAVE_INTTYPES_H
+#include <inttypes.h>
+#endif
+
+#define MAX_ARGS 256
+
+#define CHECK(x) (void)(!(x) ? (abort(), 1) : 0)
+
+/* Define macros so that compilers other than gcc can run the tests. */
+#undef __UNUSED__
+#if defined(__GNUC__)
+#define __UNUSED__ __attribute__((__unused__))
+#define __STDCALL__ __attribute__((stdcall))
+#define __THISCALL__ __attribute__((thiscall))
+#define __FASTCALL__ __attribute__((fastcall))
+#else
+#define __UNUSED__
+#define __STDCALL__ __stdcall
+#define __THISCALL__ __thiscall
+#define __FASTCALL__ __fastcall
+#endif
+
+#ifndef ABI_NUM
+#define ABI_NUM FFI_DEFAULT_ABI
+#define ABI_ATTR
+#endif
+
+/* Prefer MAP_ANON(YMOUS) to /dev/zero, since we don't need to keep a
+ file open. */
+#ifdef HAVE_MMAP_ANON
+# undef HAVE_MMAP_DEV_ZERO
+
+# include <sys/mman.h>
+# ifndef MAP_FAILED
+# define MAP_FAILED -1
+# endif
+# if !defined (MAP_ANONYMOUS) && defined (MAP_ANON)
+# define MAP_ANONYMOUS MAP_ANON
+# endif
+# define USING_MMAP
+
+#endif
+
+#ifdef HAVE_MMAP_DEV_ZERO
+
+# include <sys/mman.h>
+# ifndef MAP_FAILED
+# define MAP_FAILED -1
+# endif
+# define USING_MMAP
+
+#endif
+
+/* MinGW kludge. */
+#ifdef _WIN64
+#define PRIdLL "I64d"
+#define PRIuLL "I64u"
+#else
+#define PRIdLL "lld"
+#define PRIuLL "llu"
+#endif
+
+/* Tru64 UNIX kludge. */
+#if defined(__alpha__) && defined(__osf__)
+/* Tru64 UNIX V4.0 doesn't support %lld/%lld, but long is 64-bit. */
+#undef PRIdLL
+#define PRIdLL "ld"
+#undef PRIuLL
+#define PRIuLL "lu"
+#define PRId8 "hd"
+#define PRIu8 "hu"
+#define PRId64 "ld"
+#define PRIu64 "lu"
+#define PRIuPTR "lu"
+#endif
+
+/* PA HP-UX kludge. */
+#if defined(__hppa__) && defined(__hpux__) && !defined(PRIuPTR)
+#define PRIuPTR "lu"
+#endif
+
+/* IRIX kludge. */
+#if defined(__sgi)
+/* IRIX 6.5 <inttypes.h> provides all definitions, but only for C99
+ compilations. */
+#define PRId8 "hhd"
+#define PRIu8 "hhu"
+#if (_MIPS_SZLONG == 32)
+#define PRId64 "lld"
+#define PRIu64 "llu"
+#endif
+/* This doesn't match <inttypes.h>, which always has "lld" here, but the
+ arguments are uint64_t, int64_t, which are unsigned long, long for
+ 64-bit in <sgidefs.h>. */
+#if (_MIPS_SZLONG == 64)
+#define PRId64 "ld"
+#define PRIu64 "lu"
+#endif
+/* This doesn't match <inttypes.h>, which has "u" here, but the arguments
+ are uintptr_t, which is always unsigned long. */
+#define PRIuPTR "lu"
+#endif
+
+/* Solaris < 10 kludge. */
+#if defined(__sun__) && defined(__svr4__) && !defined(PRIuPTR)
+#if defined(__arch64__) || defined (__x86_64__)
+#define PRIuPTR "lu"
+#else
+#define PRIuPTR "u"
+#endif
+#endif
+
+/* MSVC kludge. */
+#if defined _MSC_VER
+#define PRIuPTR "lu"
+#define PRIu8 "u"
+#define PRId8 "d"
+#define PRIu64 "I64u"
+#define PRId64 "I64d"
+#endif
+
+#ifndef PRIuPTR
+#define PRIuPTR "u"
+#endif
diff --git a/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/float.c b/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/float.c
new file mode 100644
index 0000000..fbc272d
--- /dev/null
+++ b/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/float.c
@@ -0,0 +1,59 @@
+/* Area: ffi_call
+ Purpose: Check return value float.
+ Limitations: none.
+ PR: none.
+ Originator: From the original ffitest.c */
+
+/* { dg-do run } */
+
+#include "ffitest.h"
+
+static int floating(int a, float b, double c, long double d)
+{
+ int i;
+
+ i = (int) ((float)a/b + ((float)c/(float)d));
+
+ return i;
+}
+
+int main (void)
+{
+ ffi_cif cif;
+ ffi_type *args[MAX_ARGS];
+ void *values[MAX_ARGS];
+ ffi_arg rint;
+
+ float f;
+ signed int si1;
+ double d;
+ long double ld;
+
+ args[0] = &ffi_type_sint;
+ values[0] = &si1;
+ args[1] = &ffi_type_float;
+ values[1] = &f;
+ args[2] = &ffi_type_double;
+ values[2] = &d;
+ args[3] = &ffi_type_longdouble;
+ values[3] = &ld;
+
+ /* Initialize the cif */
+ CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 4,
+ &ffi_type_sint, args) == FFI_OK);
+
+ si1 = 6;
+ f = 3.14159;
+ d = (double)1.0/(double)3.0;
+ ld = 2.71828182846L;
+
+ floating (si1, f, d, ld);
+
+ ffi_call(&cif, FFI_FN(floating), &rint, values);
+
+ printf ("%d vs %d\n", (int)rint, floating (si1, f, d, ld));
+
+ CHECK((int)rint == floating(si1, f, d, ld));
+
+ exit (0);
+}
diff --git a/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/float1.c b/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/float1.c
new file mode 100644
index 0000000..991d059
--- /dev/null
+++ b/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/float1.c
@@ -0,0 +1,58 @@
+/* Area: ffi_call
+ Purpose: Check return value double.
+ Limitations: none.
+ PR: none.
+ Originator: From the original ffitest.c */
+
+/* { dg-do run } */
+#include "ffitest.h"
+#include "float.h"
+
+typedef union
+{
+ double d;
+ unsigned char c[sizeof (double)];
+} value_type;
+
+#define CANARY 0xba
+
+static double dblit(float f)
+{
+ return f/3.0;
+}
+
+int main (void)
+{
+ ffi_cif cif;
+ ffi_type *args[MAX_ARGS];
+ void *values[MAX_ARGS];
+ float f;
+ value_type result[2];
+ unsigned int i;
+
+ args[0] = &ffi_type_float;
+ values[0] = &f;
+
+ /* Initialize the cif */
+ CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 1,
+ &ffi_type_double, args) == FFI_OK);
+
+ f = 3.14159;
+
+ /* Put a canary in the return array. This is a regression test for
+ a buffer overrun. */
+ memset(result[1].c, CANARY, sizeof (double));
+
+ ffi_call(&cif, FFI_FN(dblit), &result[0].d, values);
+
+ /* These are not always the same!! Check for a reasonable delta */
+
+ CHECK(result[0].d - dblit(f) < DBL_EPSILON);
+
+ /* Check the canary. */
+ for (i = 0; i < sizeof (double); ++i)
+ CHECK(result[1].c[i] == CANARY);
+
+ exit(0);
+
+}
diff --git a/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/float2.c b/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/float2.c
new file mode 100644
index 0000000..a0b296c
--- /dev/null
+++ b/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/float2.c
@@ -0,0 +1,58 @@
+/* Area: ffi_call
+ Purpose: Check return value long double.
+ Limitations: none.
+ PR: none.
+ Originator: From the original ffitest.c */
+
+/* { dg-excess-errors "fails" { target x86_64-*-mingw* x86_64-*-cygwin* } } */
+/* { dg-do run { xfail x86_64-*-mingw* x86_64-*-cygwin* } } */
+
+#include "ffitest.h"
+#include "float.h"
+
+static long double ldblit(float f)
+{
+ return (long double) (((long double) f)/ (long double) 3.0);
+}
+
+int main (void)
+{
+ ffi_cif cif;
+ ffi_type *args[MAX_ARGS];
+ void *values[MAX_ARGS];
+ float f;
+ long double ld;
+
+ args[0] = &ffi_type_float;
+ values[0] = &f;
+
+ /* Initialize the cif */
+ CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 1,
+ &ffi_type_longdouble, args) == FFI_OK);
+
+ f = 3.14159;
+
+#if 1
+ /* This is ifdef'd out for now. long double support under SunOS/gcc
+ is pretty much non-existent. You'll get the odd bus error in library
+ routines like printf(). */
+ printf ("%Lf\n", ldblit(f));
+#endif
+ ld = 666;
+ ffi_call(&cif, FFI_FN(ldblit), &ld, values);
+
+#if 1
+ /* This is ifdef'd out for now. long double support under SunOS/gcc
+ is pretty much non-existent. You'll get the odd bus error in library
+ routines like printf(). */
+ printf ("%Lf, %Lf, %Lf, %Lf\n", ld, ldblit(f), ld - ldblit(f), LDBL_EPSILON);
+#endif
+
+ /* These are not always the same!! Check for a reasonable delta */
+ if (ld - ldblit(f) < LDBL_EPSILON)
+ puts("long double return value tests ok!");
+ else
+ CHECK(0);
+
+ exit(0);
+}
diff --git a/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/float3.c b/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/float3.c
new file mode 100644
index 0000000..76bd5f2
--- /dev/null
+++ b/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/float3.c
@@ -0,0 +1,72 @@
+/* Area: ffi_call
+ Purpose: Check float arguments with different orders.
+ Limitations: none.
+ PR: none.
+ Originator: From the original ffitest.c */
+
+/* { dg-do run } */
+
+#include "ffitest.h"
+#include "float.h"
+
+static double floating_1(float a, double b, long double c)
+{
+ return (double) a + b + (double) c;
+}
+
+static double floating_2(long double a, double b, float c)
+{
+ return (double) a + b + (double) c;
+}
+
+int main (void)
+{
+ ffi_cif cif;
+ ffi_type *args[MAX_ARGS];
+ void *values[MAX_ARGS];
+ double rd;
+
+ float f;
+ double d;
+ long double ld;
+
+ args[0] = &ffi_type_float;
+ values[0] = &f;
+ args[1] = &ffi_type_double;
+ values[1] = &d;
+ args[2] = &ffi_type_longdouble;
+ values[2] = &ld;
+
+ /* Initialize the cif */
+ CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 3,
+ &ffi_type_double, args) == FFI_OK);
+
+ f = 3.14159;
+ d = (double)1.0/(double)3.0;
+ ld = 2.71828182846L;
+
+ floating_1 (f, d, ld);
+
+ ffi_call(&cif, FFI_FN(floating_1), &rd, values);
+
+ CHECK(rd - floating_1(f, d, ld) < DBL_EPSILON);
+
+ args[0] = &ffi_type_longdouble;
+ values[0] = &ld;
+ args[1] = &ffi_type_double;
+ values[1] = &d;
+ args[2] = &ffi_type_float;
+ values[2] = &f;
+
+ /* Initialize the cif */
+ CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 3,
+ &ffi_type_double, args) == FFI_OK);
+
+ floating_2 (ld, d, f);
+
+ ffi_call(&cif, FFI_FN(floating_2), &rd, values);
+
+ CHECK(rd - floating_2(ld, d, f) < DBL_EPSILON);
+
+ exit (0);
+}
diff --git a/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/float4.c b/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/float4.c
new file mode 100644
index 0000000..0dd6d85
--- /dev/null
+++ b/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/float4.c
@@ -0,0 +1,62 @@
+/* Area: ffi_call
+ Purpose: Check denorm double value.
+ Limitations: none.
+ PR: PR26483.
+ Originator: From the original ffitest.c */
+
+/* { dg-do run } */
+/* { dg-options "-mieee" { target alpha*-*-* } } */
+
+#include "ffitest.h"
+#include "float.h"
+
+typedef union
+{
+ double d;
+ unsigned char c[sizeof (double)];
+} value_type;
+
+#define CANARY 0xba
+
+static double dblit(double d)
+{
+ return d;
+}
+
+int main (void)
+{
+ ffi_cif cif;
+ ffi_type *args[MAX_ARGS];
+ void *values[MAX_ARGS];
+ double d;
+ value_type result[2];
+ unsigned int i;
+
+ args[0] = &ffi_type_double;
+ values[0] = &d;
+
+ /* Initialize the cif */
+ CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 1,
+ &ffi_type_double, args) == FFI_OK);
+
+ d = DBL_MIN / 2;
+
+ /* Put a canary in the return array. This is a regression test for
+ a buffer overrun. */
+ memset(result[1].c, CANARY, sizeof (double));
+
+ ffi_call(&cif, FFI_FN(dblit), &result[0].d, values);
+
+ /* The standard delta check doesn't work for denorms. Since we didn't do
+ any arithmetic, we should get the original result back, and hence an
+ exact check should be OK here. */
+
+ CHECK(result[0].d == dblit(d));
+
+ /* Check the canary. */
+ for (i = 0; i < sizeof (double); ++i)
+ CHECK(result[1].c[i] == CANARY);
+
+ exit(0);
+
+}
diff --git a/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/float_va.c b/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/float_va.c
new file mode 100644
index 0000000..5acff91
--- /dev/null
+++ b/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/float_va.c
@@ -0,0 +1,107 @@
+/* Area: fp and variadics
+ Purpose: check fp inputs and returns work on variadics, even the fixed params
+ Limitations: None
+ PR: none
+ Originator: <david.gilbert@linaro.org> 2011-01-25
+
+ Intended to stress the difference in ABI on ARM vfp
+*/
+
+/* { dg-do run } */
+
+#include <stdarg.h>
+
+#include "ffitest.h"
+
+/* prints out all the parameters, and returns the sum of them all.
+ * 'x' is the number of variadic parameters all of which are double in this test
+ */
+double float_va_fn(unsigned int x, double y,...)
+{
+ double total=0.0;
+ va_list ap;
+ unsigned int i;
+
+ total+=(double)x;
+ total+=y;
+
+ printf("%u: %.1f :", x, y);
+
+ va_start(ap, y);
+ for(i=0;i<x;i++)
+ {
+ double arg=va_arg(ap, double);
+ total+=arg;
+ printf(" %d:%.1f ", i, arg);
+ }
+ va_end(ap);
+
+ printf(" total: %.1f\n", total);
+
+ return total;
+}
+
+int main (void)
+{
+ ffi_cif cif;
+
+ ffi_type *arg_types[5];
+ void *values[5];
+ double doubles[5];
+ unsigned int firstarg;
+ double resfp;
+
+ /* First test, pass float_va_fn(0,2.0) - note there are no actual
+ * variadic parameters, but it's declared variadic so the ABI may be
+ * different. */
+ /* Call it statically and then via ffi */
+ resfp=float_va_fn(0,2.0);
+ /* { dg-output "0: 2.0 : total: 2.0" } */
+ printf("compiled: %.1f\n", resfp);
+ /* { dg-output "\ncompiled: 2.0" } */
+
+ arg_types[0] = &ffi_type_uint;
+ arg_types[1] = &ffi_type_double;
+ arg_types[2] = NULL;
+ CHECK(ffi_prep_cif_var(&cif, FFI_DEFAULT_ABI, 2, 2,
+ &ffi_type_double, arg_types) == FFI_OK);
+
+ firstarg = 0;
+ doubles[0] = 2.0;
+ values[0] = &firstarg;
+ values[1] = &doubles[0];
+ ffi_call(&cif, FFI_FN(float_va_fn), &resfp, values);
+ /* { dg-output "\n0: 2.0 : total: 2.0" } */
+ printf("ffi: %.1f\n", resfp);
+ /* { dg-output "\nffi: 2.0" } */
+
+ /* Second test, float_va_fn(2,2.0,3.0,4.0), now with variadic params */
+ /* Call it statically and then via ffi */
+ resfp=float_va_fn(2,2.0,3.0,4.0);
+ /* { dg-output "\n2: 2.0 : 0:3.0 1:4.0 total: 11.0" } */
+ printf("compiled: %.1f\n", resfp);
+ /* { dg-output "\ncompiled: 11.0" } */
+
+ arg_types[0] = &ffi_type_uint;
+ arg_types[1] = &ffi_type_double;
+ arg_types[2] = &ffi_type_double;
+ arg_types[3] = &ffi_type_double;
+ arg_types[4] = NULL;
+ CHECK(ffi_prep_cif_var(&cif, FFI_DEFAULT_ABI, 2, 4,
+ &ffi_type_double, arg_types) == FFI_OK);
+
+ firstarg = 2;
+ doubles[0] = 2.0;
+ doubles[1] = 3.0;
+ doubles[2] = 4.0;
+ values[0] = &firstarg;
+ values[1] = &doubles[0];
+ values[2] = &doubles[1];
+ values[3] = &doubles[2];
+ ffi_call(&cif, FFI_FN(float_va_fn), &resfp, values);
+ /* { dg-output "\n2: 2.0 : 0:3.0 1:4.0 total: 11.0" } */
+ printf("ffi: %.1f\n", resfp);
+ /* { dg-output "\nffi: 11.0" } */
+
+ exit(0);
+}
diff --git a/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/huge_struct.c b/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/huge_struct.c
new file mode 100644
index 0000000..657fe54
--- /dev/null
+++ b/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/huge_struct.c
@@ -0,0 +1,343 @@
+/* Area: ffi_call, closure_call
+ Purpose: Check large structure returns.
+ Limitations: none.
+ PR: none.
+ Originator: Blake Chaffin 6/18/2007
+*/
+
+/* { dg-excess-errors "" { target x86_64-*-mingw* x86_64-*-cygwin* } } */
+/* { dg-do run { xfail strongarm*-*-* xscale*-*-* } } */
+/* { dg-options -mlong-double-128 { target powerpc64*-*-linux* } } */
+/* { dg-options -Wformat=0 { target moxie*-*-elf } } */
+/* { dg-output "" { xfail x86_64-*-mingw* x86_64-*-cygwin* } } */
+
+#include "ffitest.h"
+
+typedef struct BigStruct{
+ uint8_t a;
+ int8_t b;
+ uint16_t c;
+ int16_t d;
+ uint32_t e;
+ int32_t f;
+ uint64_t g;
+ int64_t h;
+ float i;
+ double j;
+ long double k;
+ char* l;
+ uint8_t m;
+ int8_t n;
+ uint16_t o;
+ int16_t p;
+ uint32_t q;
+ int32_t r;
+ uint64_t s;
+ int64_t t;
+ float u;
+ double v;
+ long double w;
+ char* x;
+ uint8_t y;
+ int8_t z;
+ uint16_t aa;
+ int16_t bb;
+ uint32_t cc;
+ int32_t dd;
+ uint64_t ee;
+ int64_t ff;
+ float gg;
+ double hh;
+ long double ii;
+ char* jj;
+ uint8_t kk;
+ int8_t ll;
+ uint16_t mm;
+ int16_t nn;
+ uint32_t oo;
+ int32_t pp;
+ uint64_t qq;
+ int64_t rr;
+ float ss;
+ double tt;
+ long double uu;
+ char* vv;
+ uint8_t ww;
+ int8_t xx;
+} BigStruct;
+
+BigStruct
+test_large_fn(
+ uint8_t ui8_1,
+ int8_t si8_1,
+ uint16_t ui16_1,
+ int16_t si16_1,
+ uint32_t ui32_1,
+ int32_t si32_1,
+ uint64_t ui64_1,
+ int64_t si64_1,
+ float f_1,
+ double d_1,
+ long double ld_1,
+ char* p_1,
+ uint8_t ui8_2,
+ int8_t si8_2,
+ uint16_t ui16_2,
+ int16_t si16_2,
+ uint32_t ui32_2,
+ int32_t si32_2,
+ uint64_t ui64_2,
+ int64_t si64_2,
+ float f_2,
+ double d_2,
+ long double ld_2,
+ char* p_2,
+ uint8_t ui8_3,
+ int8_t si8_3,
+ uint16_t ui16_3,
+ int16_t si16_3,
+ uint32_t ui32_3,
+ int32_t si32_3,
+ uint64_t ui64_3,
+ int64_t si64_3,
+ float f_3,
+ double d_3,
+ long double ld_3,
+ char* p_3,
+ uint8_t ui8_4,
+ int8_t si8_4,
+ uint16_t ui16_4,
+ int16_t si16_4,
+ uint32_t ui32_4,
+ int32_t si32_4,
+ uint64_t ui64_4,
+ int64_t si64_4,
+ float f_4,
+ double d_4,
+ long double ld_4,
+ char* p_4,
+ uint8_t ui8_5,
+ int8_t si8_5)
+{
+ BigStruct retVal = {
+ ui8_1 + 1, si8_1 + 1, ui16_1 + 1, si16_1 + 1, ui32_1 + 1, si32_1 + 1,
+ ui64_1 + 1, si64_1 + 1, f_1 + 1, d_1 + 1, ld_1 + 1, (char*)((intptr_t)p_1 + 1),
+ ui8_2 + 2, si8_2 + 2, ui16_2 + 2, si16_2 + 2, ui32_2 + 2, si32_2 + 2,
+ ui64_2 + 2, si64_2 + 2, f_2 + 2, d_2 + 2, ld_2 + 2, (char*)((intptr_t)p_2 + 2),
+ ui8_3 + 3, si8_3 + 3, ui16_3 + 3, si16_3 + 3, ui32_3 + 3, si32_3 + 3,
+ ui64_3 + 3, si64_3 + 3, f_3 + 3, d_3 + 3, ld_3 + 3, (char*)((intptr_t)p_3 + 3),
+ ui8_4 + 4, si8_4 + 4, ui16_4 + 4, si16_4 + 4, ui32_4 + 4, si32_4 + 4,
+ ui64_4 + 4, si64_4 + 4, f_4 + 4, d_4 + 4, ld_4 + 4, (char*)((intptr_t)p_4 + 4),
+ ui8_5 + 5, si8_5 + 5};
+
+ printf("%" PRIu8 " %" PRId8 " %hu %hd %u %d %" PRIu64 " %" PRId64 " %.0f %.0f %.0Lf %#lx "
+ "%" PRIu8 " %" PRId8 " %hu %hd %u %d %" PRIu64 " %" PRId64 " %.0f %.0f %.0Lf %#lx "
+ "%" PRIu8 " %" PRId8 " %hu %hd %u %d %" PRIu64 " %" PRId64 " %.0f %.0f %.0Lf %#lx "
+ "%" PRIu8 " %" PRId8 " %hu %hd %u %d %" PRIu64 " %" PRId64 " %.0f %.0f %.0Lf %#lx %" PRIu8 " %" PRId8 ": "
+ "%" PRIu8 " %" PRId8 " %hu %hd %u %d %" PRIu64 " %" PRId64 " %.0f %.0f %.0Lf %#lx "
+ "%" PRIu8 " %" PRId8 " %hu %hd %u %d %" PRIu64 " %" PRId64 " %.0f %.0f %.0Lf %#lx "
+ "%" PRIu8 " %" PRId8 " %hu %hd %u %d %" PRIu64 " %" PRId64 " %.0f %.0f %.0Lf %#lx "
+ "%" PRIu8 " %" PRId8 " %hu %hd %u %d %" PRIu64 " %" PRId64 " %.0f %.0f %.0Lf %#lx %" PRIu8 " %" PRId8 "\n",
+ ui8_1, si8_1, ui16_1, si16_1, ui32_1, si32_1, ui64_1, si64_1, f_1, d_1, ld_1, (unsigned long)p_1,
+ ui8_2, si8_2, ui16_2, si16_2, ui32_2, si32_2, ui64_2, si64_2, f_2, d_2, ld_2, (unsigned long)p_2,
+ ui8_3, si8_3, ui16_3, si16_3, ui32_3, si32_3, ui64_3, si64_3, f_3, d_3, ld_3, (unsigned long)p_3,
+ ui8_4, si8_4, ui16_4, si16_4, ui32_4, si32_4, ui64_4, si64_4, f_4, d_4, ld_4, (unsigned long)p_4, ui8_5, si8_5,
+ retVal.a, retVal.b, retVal.c, retVal.d, retVal.e, retVal.f,
+ retVal.g, retVal.h, retVal.i, retVal.j, retVal.k, (unsigned long)retVal.l,
+ retVal.m, retVal.n, retVal.o, retVal.p, retVal.q, retVal.r,
+ retVal.s, retVal.t, retVal.u, retVal.v, retVal.w, (unsigned long)retVal.x,
+ retVal.y, retVal.z, retVal.aa, retVal.bb, retVal.cc, retVal.dd,
+ retVal.ee, retVal.ff, retVal.gg, retVal.hh, retVal.ii, (unsigned long)retVal.jj,
+ retVal.kk, retVal.ll, retVal.mm, retVal.nn, retVal.oo, retVal.pp,
+ retVal.qq, retVal.rr, retVal.ss, retVal.tt, retVal.uu, (unsigned long)retVal.vv, retVal.ww, retVal.xx);
+
+ return retVal;
+}
+
+static void
+cls_large_fn(ffi_cif* cif __UNUSED__, void* resp, void** args, void* userdata __UNUSED__)
+{
+ uint8_t ui8_1 = *(uint8_t*)args[0];
+ int8_t si8_1 = *(int8_t*)args[1];
+ uint16_t ui16_1 = *(uint16_t*)args[2];
+ int16_t si16_1 = *(int16_t*)args[3];
+ uint32_t ui32_1 = *(uint32_t*)args[4];
+ int32_t si32_1 = *(int32_t*)args[5];
+ uint64_t ui64_1 = *(uint64_t*)args[6];
+ int64_t si64_1 = *(int64_t*)args[7];
+ float f_1 = *(float*)args[8];
+ double d_1 = *(double*)args[9];
+ long double ld_1 = *(long double*)args[10];
+ char* p_1 = *(char**)args[11];
+ uint8_t ui8_2 = *(uint8_t*)args[12];
+ int8_t si8_2 = *(int8_t*)args[13];
+ uint16_t ui16_2 = *(uint16_t*)args[14];
+ int16_t si16_2 = *(int16_t*)args[15];
+ uint32_t ui32_2 = *(uint32_t*)args[16];
+ int32_t si32_2 = *(int32_t*)args[17];
+ uint64_t ui64_2 = *(uint64_t*)args[18];
+ int64_t si64_2 = *(int64_t*)args[19];
+ float f_2 = *(float*)args[20];
+ double d_2 = *(double*)args[21];
+ long double ld_2 = *(long double*)args[22];
+ char* p_2 = *(char**)args[23];
+ uint8_t ui8_3 = *(uint8_t*)args[24];
+ int8_t si8_3 = *(int8_t*)args[25];
+ uint16_t ui16_3 = *(uint16_t*)args[26];
+ int16_t si16_3 = *(int16_t*)args[27];
+ uint32_t ui32_3 = *(uint32_t*)args[28];
+ int32_t si32_3 = *(int32_t*)args[29];
+ uint64_t ui64_3 = *(uint64_t*)args[30];
+ int64_t si64_3 = *(int64_t*)args[31];
+ float f_3 = *(float*)args[32];
+ double d_3 = *(double*)args[33];
+ long double ld_3 = *(long double*)args[34];
+ char* p_3 = *(char**)args[35];
+ uint8_t ui8_4 = *(uint8_t*)args[36];
+ int8_t si8_4 = *(int8_t*)args[37];
+ uint16_t ui16_4 = *(uint16_t*)args[38];
+ int16_t si16_4 = *(int16_t*)args[39];
+ uint32_t ui32_4 = *(uint32_t*)args[40];
+ int32_t si32_4 = *(int32_t*)args[41];
+ uint64_t ui64_4 = *(uint64_t*)args[42];
+ int64_t si64_4 = *(int64_t*)args[43];
+ float f_4 = *(float*)args[44];
+ double d_4 = *(double*)args[45];
+ long double ld_4 = *(long double*)args[46];
+ char* p_4 = *(char**)args[47];
+ uint8_t ui8_5 = *(uint8_t*)args[48];
+ int8_t si8_5 = *(int8_t*)args[49];
+
+ *(BigStruct*)resp = test_large_fn(
+ ui8_1, si8_1, ui16_1, si16_1, ui32_1, si32_1, ui64_1, si64_1, f_1, d_1, ld_1, p_1,
+ ui8_2, si8_2, ui16_2, si16_2, ui32_2, si32_2, ui64_2, si64_2, f_2, d_2, ld_2, p_2,
+ ui8_3, si8_3, ui16_3, si16_3, ui32_3, si32_3, ui64_3, si64_3, f_3, d_3, ld_3, p_3,
+ ui8_4, si8_4, ui16_4, si16_4, ui32_4, si32_4, ui64_4, si64_4, f_4, d_4, ld_4, p_4,
+ ui8_5, si8_5);
+}
+
+int
+main(int argc __UNUSED__, const char** argv __UNUSED__)
+{
+ void *code;
+ ffi_closure *pcl = ffi_closure_alloc(sizeof(ffi_closure), &code);
+
+ ffi_cif cif;
+ ffi_type* argTypes[51];
+ void* argValues[51];
+
+ ffi_type ret_struct_type;
+ ffi_type* st_fields[51];
+ BigStruct retVal;
+
+ uint8_t ui8 = 1;
+ int8_t si8 = 2;
+ uint16_t ui16 = 3;
+ int16_t si16 = 4;
+ uint32_t ui32 = 5;
+ int32_t si32 = 6;
+ uint64_t ui64 = 7;
+ int64_t si64 = 8;
+ float f = 9;
+ double d = 10;
+ long double ld = 11;
+ char* p = (char*)0x12345678;
+
+ memset (&retVal, 0, sizeof(retVal));
+
+ ret_struct_type.size = 0;
+ ret_struct_type.alignment = 0;
+ ret_struct_type.type = FFI_TYPE_STRUCT;
+ ret_struct_type.elements = st_fields;
+
+ st_fields[0] = st_fields[12] = st_fields[24] = st_fields[36] = st_fields[48] = &ffi_type_uint8;
+ st_fields[1] = st_fields[13] = st_fields[25] = st_fields[37] = st_fields[49] = &ffi_type_sint8;
+ st_fields[2] = st_fields[14] = st_fields[26] = st_fields[38] = &ffi_type_uint16;
+ st_fields[3] = st_fields[15] = st_fields[27] = st_fields[39] = &ffi_type_sint16;
+ st_fields[4] = st_fields[16] = st_fields[28] = st_fields[40] = &ffi_type_uint32;
+ st_fields[5] = st_fields[17] = st_fields[29] = st_fields[41] = &ffi_type_sint32;
+ st_fields[6] = st_fields[18] = st_fields[30] = st_fields[42] = &ffi_type_uint64;
+ st_fields[7] = st_fields[19] = st_fields[31] = st_fields[43] = &ffi_type_sint64;
+ st_fields[8] = st_fields[20] = st_fields[32] = st_fields[44] = &ffi_type_float;
+ st_fields[9] = st_fields[21] = st_fields[33] = st_fields[45] = &ffi_type_double;
+ st_fields[10] = st_fields[22] = st_fields[34] = st_fields[46] = &ffi_type_longdouble;
+ st_fields[11] = st_fields[23] = st_fields[35] = st_fields[47] = &ffi_type_pointer;
+
+ st_fields[50] = NULL;
+
+ argTypes[0] = argTypes[12] = argTypes[24] = argTypes[36] = argTypes[48] = &ffi_type_uint8;
+ argValues[0] = argValues[12] = argValues[24] = argValues[36] = argValues[48] = &ui8;
+ argTypes[1] = argTypes[13] = argTypes[25] = argTypes[37] = argTypes[49] = &ffi_type_sint8;
+ argValues[1] = argValues[13] = argValues[25] = argValues[37] = argValues[49] = &si8;
+ argTypes[2] = argTypes[14] = argTypes[26] = argTypes[38] = &ffi_type_uint16;
+ argValues[2] = argValues[14] = argValues[26] = argValues[38] = &ui16;
+ argTypes[3] = argTypes[15] = argTypes[27] = argTypes[39] = &ffi_type_sint16;
+ argValues[3] = argValues[15] = argValues[27] = argValues[39] = &si16;
+ argTypes[4] = argTypes[16] = argTypes[28] = argTypes[40] = &ffi_type_uint32;
+ argValues[4] = argValues[16] = argValues[28] = argValues[40] = &ui32;
+ argTypes[5] = argTypes[17] = argTypes[29] = argTypes[41] = &ffi_type_sint32;
+ argValues[5] = argValues[17] = argValues[29] = argValues[41] = &si32;
+ argTypes[6] = argTypes[18] = argTypes[30] = argTypes[42] = &ffi_type_uint64;
+ argValues[6] = argValues[18] = argValues[30] = argValues[42] = &ui64;
+ argTypes[7] = argTypes[19] = argTypes[31] = argTypes[43] = &ffi_type_sint64;
+ argValues[7] = argValues[19] = argValues[31] = argValues[43] = &si64;
+ argTypes[8] = argTypes[20] = argTypes[32] = argTypes[44] = &ffi_type_float;
+ argValues[8] = argValues[20] = argValues[32] = argValues[44] = &f;
+ argTypes[9] = argTypes[21] = argTypes[33] = argTypes[45] = &ffi_type_double;
+ argValues[9] = argValues[21] = argValues[33] = argValues[45] = &d;
+ argTypes[10] = argTypes[22] = argTypes[34] = argTypes[46] = &ffi_type_longdouble;
+ argValues[10] = argValues[22] = argValues[34] = argValues[46] = &ld;
+ argTypes[11] = argTypes[23] = argTypes[35] = argTypes[47] = &ffi_type_pointer;
+ argValues[11] = argValues[23] = argValues[35] = argValues[47] = &p;
+
+ argTypes[50] = NULL;
+ argValues[50] = NULL;
+
+ CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 50, &ret_struct_type, argTypes) == FFI_OK);
+
+ ffi_call(&cif, FFI_FN(test_large_fn), &retVal, argValues);
+ /* { dg-output "1 2 3 4 5 6 7 8 9 10 11 0x12345678 1 2 3 4 5 6 7 8 9 10 11 0x12345678 1 2 3 4 5 6 7 8 9 10 11 0x12345678 1 2 3 4 5 6 7 8 9 10 11 0x12345678 1 2: 2 3 4 5 6 7 8 9 10 11 12 0x12345679 3 4 5 6 7 8 9 10 11 12 13 0x1234567a 4 5 6 7 8 9 10 11 12 13 14 0x1234567b 5 6 7 8 9 10 11 12 13 14 15 0x1234567c 6 7" } */
+ printf("res: %" PRIu8 " %" PRId8 " %hu %hd %u %d %" PRIu64 " %" PRId64 " %.0f %.0f %.0Lf %#lx "
+ "%" PRIu8 " %" PRId8 " %hu %hd %u %d %" PRIu64 " %" PRId64 " %.0f %.0f %.0Lf %#lx "
+ "%" PRIu8 " %" PRId8 " %hu %hd %u %d %" PRIu64 " %" PRId64 " %.0f %.0f %.0Lf %#lx "
+ "%" PRIu8 " %" PRId8 " %hu %hd %u %d %" PRIu64 " %" PRId64 " %.0f %.0f %.0Lf %#lx %" PRIu8 " %" PRId8 "\n",
+ retVal.a, retVal.b, retVal.c, retVal.d, retVal.e, retVal.f,
+ retVal.g, retVal.h, retVal.i, retVal.j, retVal.k, (unsigned long)retVal.l,
+ retVal.m, retVal.n, retVal.o, retVal.p, retVal.q, retVal.r,
+ retVal.s, retVal.t, retVal.u, retVal.v, retVal.w, (unsigned long)retVal.x,
+ retVal.y, retVal.z, retVal.aa, retVal.bb, retVal.cc, retVal.dd,
+ retVal.ee, retVal.ff, retVal.gg, retVal.hh, retVal.ii, (unsigned long)retVal.jj,
+ retVal.kk, retVal.ll, retVal.mm, retVal.nn, retVal.oo, retVal.pp,
+ retVal.qq, retVal.rr, retVal.ss, retVal.tt, retVal.uu, (unsigned long)retVal.vv, retVal.ww, retVal.xx);
+ /* { dg-output "\nres: 2 3 4 5 6 7 8 9 10 11 12 0x12345679 3 4 5 6 7 8 9 10 11 12 13 0x1234567a 4 5 6 7 8 9 10 11 12 13 14 0x1234567b 5 6 7 8 9 10 11 12 13 14 15 0x1234567c 6 7" } */
+
+ CHECK(ffi_prep_closure_loc(pcl, &cif, cls_large_fn, NULL, code) == FFI_OK);
+
+ retVal = ((BigStruct(*)(
+ uint8_t, int8_t, uint16_t, int16_t, uint32_t, int32_t, uint64_t, int64_t, float, double, long double, char*,
+ uint8_t, int8_t, uint16_t, int16_t, uint32_t, int32_t, uint64_t, int64_t, float, double, long double, char*,
+ uint8_t, int8_t, uint16_t, int16_t, uint32_t, int32_t, uint64_t, int64_t, float, double, long double, char*,
+ uint8_t, int8_t, uint16_t, int16_t, uint32_t, int32_t, uint64_t, int64_t, float, double, long double, char*,
+ uint8_t, int8_t))(code))(
+ ui8, si8, ui16, si16, ui32, si32, ui64, si64, f, d, ld, p,
+ ui8, si8, ui16, si16, ui32, si32, ui64, si64, f, d, ld, p,
+ ui8, si8, ui16, si16, ui32, si32, ui64, si64, f, d, ld, p,
+ ui8, si8, ui16, si16, ui32, si32, ui64, si64, f, d, ld, p,
+ ui8, si8);
+ /* { dg-output "\n1 2 3 4 5 6 7 8 9 10 11 0x12345678 1 2 3 4 5 6 7 8 9 10 11 0x12345678 1 2 3 4 5 6 7 8 9 10 11 0x12345678 1 2 3 4 5 6 7 8 9 10 11 0x12345678 1 2: 2 3 4 5 6 7 8 9 10 11 12 0x12345679 3 4 5 6 7 8 9 10 11 12 13 0x1234567a 4 5 6 7 8 9 10 11 12 13 14 0x1234567b 5 6 7 8 9 10 11 12 13 14 15 0x1234567c 6 7" } */
+ printf("res: %" PRIu8 " %" PRId8 " %hu %hd %u %d %" PRIu64 " %" PRId64 " %.0f %.0f %.0Lf %#lx "
+ "%" PRIu8 " %" PRId8 " %hu %hd %u %d %" PRIu64 " %" PRId64 " %.0f %.0f %.0Lf %#lx "
+ "%" PRIu8 " %" PRId8 " %hu %hd %u %d %" PRIu64 " %" PRId64 " %.0f %.0f %.0Lf %#lx "
+ "%" PRIu8 " %" PRId8 " %hu %hd %u %d %" PRIu64 " %" PRId64 " %.0f %.0f %.0Lf %#lx %" PRIu8 " %" PRId8 "\n",
+ retVal.a, retVal.b, retVal.c, retVal.d, retVal.e, retVal.f,
+ retVal.g, retVal.h, retVal.i, retVal.j, retVal.k, (unsigned long)retVal.l,
+ retVal.m, retVal.n, retVal.o, retVal.p, retVal.q, retVal.r,
+ retVal.s, retVal.t, retVal.u, retVal.v, retVal.w, (unsigned long)retVal.x,
+ retVal.y, retVal.z, retVal.aa, retVal.bb, retVal.cc, retVal.dd,
+ retVal.ee, retVal.ff, retVal.gg, retVal.hh, retVal.ii, (unsigned long)retVal.jj,
+ retVal.kk, retVal.ll, retVal.mm, retVal.nn, retVal.oo, retVal.pp,
+ retVal.qq, retVal.rr, retVal.ss, retVal.tt, retVal.uu, (unsigned long)retVal.vv, retVal.ww, retVal.xx);
+ /* { dg-output "\nres: 2 3 4 5 6 7 8 9 10 11 12 0x12345679 3 4 5 6 7 8 9 10 11 12 13 0x1234567a 4 5 6 7 8 9 10 11 12 13 14 0x1234567b 5 6 7 8 9 10 11 12 13 14 15 0x1234567c 6 7" } */
+
+ return 0;
+}
diff --git a/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/many.c b/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/many.c
new file mode 100644
index 0000000..336968c
--- /dev/null
+++ b/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/many.c
@@ -0,0 +1,59 @@
+/* Area: ffi_call
+ Purpose: Check return value float, with many arguments
+ Limitations: none.
+ PR: none.
+ Originator: From the original ffitest.c */
+
+/* { dg-do run } */
+#include "ffitest.h"
+
+#include <stdlib.h>
+#include <float.h>
+#include <math.h>
+
+static float ABI_ATTR many(float f1, float f2, float f3, float f4, float f5, float f6, float f7, float f8, float f9, float f10, float f11, float f12, float f13)
+{
+#if 0
+ printf("%f %f %f %f %f %f %f %f %f %f %f %f %f\n",
+ (double) f1, (double) f2, (double) f3, (double) f4, (double) f5,
+ (double) f6, (double) f7, (double) f8, (double) f9, (double) f10,
+ (double) f11, (double) f12, (double) f13);
+#endif
+
+ return f1+f2+f3+f4+f5+f6+f7+f8+f9+f10+f11+f12+f13;
+}
+
+int main (void)
+{
+ ffi_cif cif;
+ ffi_type *args[13];
+ void *values[13];
+ float fa[13];
+ float f, ff;
+ int i;
+
+ for (i = 0; i < 13; i++)
+ {
+ args[i] = &ffi_type_float;
+ values[i] = &fa[i];
+ fa[i] = (float) i;
+ }
+
+ /* Initialize the cif */
+ CHECK(ffi_prep_cif(&cif, ABI_NUM, 13,
+ &ffi_type_float, args) == FFI_OK);
+
+ ffi_call(&cif, FFI_FN(many), &f, values);
+
+ ff = many(fa[0], fa[1],
+ fa[2], fa[3],
+ fa[4], fa[5],
+ fa[6], fa[7],
+ fa[8], fa[9],
+ fa[10],fa[11],fa[12]);
+
+ if (fabs(f - ff) < FLT_EPSILON)
+ exit(0);
+ else
+ abort();
+}
diff --git a/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/many2.c b/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/many2.c
new file mode 100644
index 0000000..1c85746
--- /dev/null
+++ b/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/many2.c
@@ -0,0 +1,57 @@
+/* Area: ffi_call
+ Purpose: Check uint8_t arguments.
+ Limitations: none.
+ PR: PR45677.
+ Originator: Dan Witte <dwitte@gmail.com> 20100916 */
+
+/* { dg-do run } */
+
+#include "ffitest.h"
+
+#define NARGS 7
+
+typedef unsigned char u8;
+
+#ifdef __GNUC__
+__attribute__((noinline))
+#endif
+uint8_t
+foo (uint8_t a, uint8_t b, uint8_t c, uint8_t d,
+ uint8_t e, uint8_t f, uint8_t g)
+{
+ return a + b + c + d + e + f + g;
+}
+
+uint8_t ABI_ATTR
+bar (uint8_t a, uint8_t b, uint8_t c, uint8_t d,
+ uint8_t e, uint8_t f, uint8_t g)
+{
+ return foo (a, b, c, d, e, f, g);
+}
+
+int
+main (void)
+{
+ ffi_type *ffitypes[NARGS];
+ int i;
+ ffi_cif cif;
+ ffi_arg result = 0;
+ uint8_t args[NARGS];
+ void *argptrs[NARGS];
+
+ for (i = 0; i < NARGS; ++i)
+ ffitypes[i] = &ffi_type_uint8;
+
+ CHECK (ffi_prep_cif (&cif, ABI_NUM, NARGS,
+ &ffi_type_uint8, ffitypes) == FFI_OK);
+
+ for (i = 0; i < NARGS; ++i)
+ {
+ args[i] = i;
+ argptrs[i] = &args[i];
+ }
+ ffi_call (&cif, FFI_FN (bar), &result, argptrs);
+
+ CHECK (result == 21);
+ return 0;
+}
diff --git a/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/negint.c b/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/negint.c
new file mode 100644
index 0000000..6e2f26f
--- /dev/null
+++ b/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/negint.c
@@ -0,0 +1,52 @@
+/* Area: ffi_call
+ Purpose: Check that negative integers are passed correctly.
+ Limitations: none.
+ PR: none.
+ Originator: From the original ffitest.c */
+
+/* { dg-do run } */
+
+#include "ffitest.h"
+
+static int checking(int a, short b, signed char c)
+{
+
+ return (a < 0 && b < 0 && c < 0);
+}
+
+int main (void)
+{
+ ffi_cif cif;
+ ffi_type *args[MAX_ARGS];
+ void *values[MAX_ARGS];
+ ffi_arg rint;
+
+ signed int si;
+ signed short ss;
+ signed char sc;
+
+ args[0] = &ffi_type_sint;
+ values[0] = &si;
+ args[1] = &ffi_type_sshort;
+ values[1] = &ss;
+ args[2] = &ffi_type_schar;
+ values[2] = &sc;
+
+ /* Initialize the cif */
+ CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 3,
+ &ffi_type_sint, args) == FFI_OK);
+
+ si = -6;
+ ss = -12;
+ sc = -1;
+
+ checking (si, ss, sc);
+
+ ffi_call(&cif, FFI_FN(checking), &rint, values);
+
+ printf ("%d vs %d\n", (int)rint, checking (si, ss, sc));
+
+ CHECK(rint != 0);
+
+ exit (0);
+}
diff --git a/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/nested_struct.c b/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/nested_struct.c
new file mode 100644
index 0000000..c15e3a0
--- /dev/null
+++ b/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/nested_struct.c
@@ -0,0 +1,152 @@
+/* Area: ffi_call, closure_call
+ Purpose: Check structure passing with different structure size.
+ Contains structs as parameter of the struct itself.
+ Limitations: none.
+ PR: none.
+ Originator: <andreast@gcc.gnu.org> 20030828 */
+
+/* { dg-do run } */
+#include "ffitest.h"
+
+typedef struct cls_struct_16byte1 {
+ double a;
+ float b;
+ int c;
+} cls_struct_16byte1;
+
+typedef struct cls_struct_16byte2 {
+ int ii;
+ double dd;
+ float ff;
+} cls_struct_16byte2;
+
+typedef struct cls_struct_combined {
+ cls_struct_16byte1 d;
+ cls_struct_16byte2 e;
+} cls_struct_combined;
+
+cls_struct_combined cls_struct_combined_fn(struct cls_struct_16byte1 b0,
+ struct cls_struct_16byte2 b1,
+ struct cls_struct_combined b2)
+{
+ struct cls_struct_combined result;
+
+ result.d.a = b0.a + b1.dd + b2.d.a;
+ result.d.b = b0.b + b1.ff + b2.d.b;
+ result.d.c = b0.c + b1.ii + b2.d.c;
+ result.e.ii = b0.c + b1.ii + b2.e.ii;
+ result.e.dd = b0.a + b1.dd + b2.e.dd;
+ result.e.ff = b0.b + b1.ff + b2.e.ff;
+
+ printf("%g %g %d %d %g %g %g %g %d %d %g %g: %g %g %d %d %g %g\n",
+ b0.a, b0.b, b0.c,
+ b1.ii, b1.dd, b1.ff,
+ b2.d.a, b2.d.b, b2.d.c,
+ b2.e.ii, b2.e.dd, b2.e.ff,
+ result.d.a, result.d.b, result.d.c,
+ result.e.ii, result.e.dd, result.e.ff);
+
+ return result;
+}
+
+static void
+cls_struct_combined_gn(ffi_cif* cif __UNUSED__, void* resp, void** args,
+ void* userdata __UNUSED__)
+{
+ struct cls_struct_16byte1 b0;
+ struct cls_struct_16byte2 b1;
+ struct cls_struct_combined b2;
+
+ b0 = *(struct cls_struct_16byte1*)(args[0]);
+ b1 = *(struct cls_struct_16byte2*)(args[1]);
+ b2 = *(struct cls_struct_combined*)(args[2]);
+
+
+ *(cls_struct_combined*)resp = cls_struct_combined_fn(b0, b1, b2);
+}
+
+int main (void)
+{
+ ffi_cif cif;
+ void *code;
+ ffi_closure *pcl = ffi_closure_alloc(sizeof(ffi_closure), &code);
+ void* args_dbl[5];
+ ffi_type* cls_struct_fields[5];
+ ffi_type* cls_struct_fields1[5];
+ ffi_type* cls_struct_fields2[5];
+ ffi_type cls_struct_type, cls_struct_type1, cls_struct_type2;
+ ffi_type* dbl_arg_types[5];
+
+ struct cls_struct_16byte1 e_dbl = { 9.0, 2.0, 6};
+ struct cls_struct_16byte2 f_dbl = { 1, 2.0, 3.0};
+ struct cls_struct_combined g_dbl = {{4.0, 5.0, 6},
+ {3, 1.0, 8.0}};
+ struct cls_struct_combined res_dbl;
+
+ cls_struct_type.size = 0;
+ cls_struct_type.alignment = 0;
+ cls_struct_type.type = FFI_TYPE_STRUCT;
+ cls_struct_type.elements = cls_struct_fields;
+
+ cls_struct_type1.size = 0;
+ cls_struct_type1.alignment = 0;
+ cls_struct_type1.type = FFI_TYPE_STRUCT;
+ cls_struct_type1.elements = cls_struct_fields1;
+
+ cls_struct_type2.size = 0;
+ cls_struct_type2.alignment = 0;
+ cls_struct_type2.type = FFI_TYPE_STRUCT;
+ cls_struct_type2.elements = cls_struct_fields2;
+
+ cls_struct_fields[0] = &ffi_type_double;
+ cls_struct_fields[1] = &ffi_type_float;
+ cls_struct_fields[2] = &ffi_type_sint;
+ cls_struct_fields[3] = NULL;
+
+ cls_struct_fields1[0] = &ffi_type_sint;
+ cls_struct_fields1[1] = &ffi_type_double;
+ cls_struct_fields1[2] = &ffi_type_float;
+ cls_struct_fields1[3] = NULL;
+
+ cls_struct_fields2[0] = &cls_struct_type;
+ cls_struct_fields2[1] = &cls_struct_type1;
+ cls_struct_fields2[2] = NULL;
+
+
+ dbl_arg_types[0] = &cls_struct_type;
+ dbl_arg_types[1] = &cls_struct_type1;
+ dbl_arg_types[2] = &cls_struct_type2;
+ dbl_arg_types[3] = NULL;
+
+ CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 3, &cls_struct_type2,
+ dbl_arg_types) == FFI_OK);
+
+ args_dbl[0] = &e_dbl;
+ args_dbl[1] = &f_dbl;
+ args_dbl[2] = &g_dbl;
+ args_dbl[3] = NULL;
+
+ ffi_call(&cif, FFI_FN(cls_struct_combined_fn), &res_dbl, args_dbl);
+ /* { dg-output "9 2 6 1 2 3 4 5 6 3 1 8: 15 10 13 10 12 13" } */
+ CHECK( res_dbl.d.a == (e_dbl.a + f_dbl.dd + g_dbl.d.a));
+ CHECK( res_dbl.d.b == (e_dbl.b + f_dbl.ff + g_dbl.d.b));
+ CHECK( res_dbl.d.c == (e_dbl.c + f_dbl.ii + g_dbl.d.c));
+ CHECK( res_dbl.e.ii == (e_dbl.c + f_dbl.ii + g_dbl.e.ii));
+ CHECK( res_dbl.e.dd == (e_dbl.a + f_dbl.dd + g_dbl.e.dd));
+ CHECK( res_dbl.e.ff == (e_dbl.b + f_dbl.ff + g_dbl.e.ff));
+
+ CHECK(ffi_prep_closure_loc(pcl, &cif, cls_struct_combined_gn, NULL, code) == FFI_OK);
+
+ res_dbl = ((cls_struct_combined(*)(cls_struct_16byte1,
+ cls_struct_16byte2,
+ cls_struct_combined))
+ (code))(e_dbl, f_dbl, g_dbl);
+ /* { dg-output "\n9 2 6 1 2 3 4 5 6 3 1 8: 15 10 13 10 12 13" } */
+ CHECK( res_dbl.d.a == (e_dbl.a + f_dbl.dd + g_dbl.d.a));
+ CHECK( res_dbl.d.b == (e_dbl.b + f_dbl.ff + g_dbl.d.b));
+ CHECK( res_dbl.d.c == (e_dbl.c + f_dbl.ii + g_dbl.d.c));
+ CHECK( res_dbl.e.ii == (e_dbl.c + f_dbl.ii + g_dbl.e.ii));
+ CHECK( res_dbl.e.dd == (e_dbl.a + f_dbl.dd + g_dbl.e.dd));
+ CHECK( res_dbl.e.ff == (e_dbl.b + f_dbl.ff + g_dbl.e.ff));
+ exit(0);
+}
diff --git a/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/nested_struct1.c b/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/nested_struct1.c
new file mode 100644
index 0000000..477a6b9
--- /dev/null
+++ b/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/nested_struct1.c
@@ -0,0 +1,161 @@
+/* Area: ffi_call, closure_call
+ Purpose: Check structure passing with different structure size.
+ Contains structs as parameter of the struct itself.
+ Limitations: none.
+ PR: none.
+ Originator: <andreast@gcc.gnu.org> 20030828 */
+
+/* { dg-do run } */
+#include "ffitest.h"
+
+typedef struct cls_struct_16byte1 {
+ double a;
+ float b;
+ int c;
+} cls_struct_16byte1;
+
+typedef struct cls_struct_16byte2 {
+ int ii;
+ double dd;
+ float ff;
+} cls_struct_16byte2;
+
+typedef struct cls_struct_combined {
+ cls_struct_16byte1 d;
+ cls_struct_16byte2 e;
+} cls_struct_combined;
+
+cls_struct_combined cls_struct_combined_fn(struct cls_struct_16byte1 b0,
+ struct cls_struct_16byte2 b1,
+ struct cls_struct_combined b2,
+ struct cls_struct_16byte1 b3)
+{
+ struct cls_struct_combined result;
+
+ result.d.a = b0.a + b1.dd + b2.d.a;
+ result.d.b = b0.b + b1.ff + b2.d.b;
+ result.d.c = b0.c + b1.ii + b2.d.c;
+ result.e.ii = b0.c + b1.ii + b2.e.ii;
+ result.e.dd = b0.a + b1.dd + b2.e.dd;
+ result.e.ff = b0.b + b1.ff + b2.e.ff;
+
+ printf("%g %g %d %d %g %g %g %g %d %d %g %g %g %g %d: %g %g %d %d %g %g\n",
+ b0.a, b0.b, b0.c,
+ b1.ii, b1.dd, b1.ff,
+ b2.d.a, b2.d.b, b2.d.c,
+ b2.e.ii, b2.e.dd, b2.e.ff,
+ b3.a, b3.b, b3.c,
+ result.d.a, result.d.b, result.d.c,
+ result.e.ii, result.e.dd, result.e.ff);
+
+ return result;
+}
+
+static void
+cls_struct_combined_gn(ffi_cif* cif __UNUSED__, void* resp, void** args,
+ void* userdata __UNUSED__)
+{
+ struct cls_struct_16byte1 b0;
+ struct cls_struct_16byte2 b1;
+ struct cls_struct_combined b2;
+ struct cls_struct_16byte1 b3;
+
+ b0 = *(struct cls_struct_16byte1*)(args[0]);
+ b1 = *(struct cls_struct_16byte2*)(args[1]);
+ b2 = *(struct cls_struct_combined*)(args[2]);
+ b3 = *(struct cls_struct_16byte1*)(args[3]);
+
+
+ *(cls_struct_combined*)resp = cls_struct_combined_fn(b0, b1, b2, b3);
+}
+
+int main (void)
+{
+ ffi_cif cif;
+ void *code;
+ ffi_closure *pcl = ffi_closure_alloc(sizeof(ffi_closure), &code);
+ void* args_dbl[5];
+ ffi_type* cls_struct_fields[5];
+ ffi_type* cls_struct_fields1[5];
+ ffi_type* cls_struct_fields2[5];
+ ffi_type cls_struct_type, cls_struct_type1, cls_struct_type2;
+ ffi_type* dbl_arg_types[5];
+
+ struct cls_struct_16byte1 e_dbl = { 9.0, 2.0, 6};
+ struct cls_struct_16byte2 f_dbl = { 1, 2.0, 3.0};
+ struct cls_struct_combined g_dbl = {{4.0, 5.0, 6},
+ {3, 1.0, 8.0}};
+ struct cls_struct_16byte1 h_dbl = { 3.0, 2.0, 4};
+ struct cls_struct_combined res_dbl;
+
+ cls_struct_type.size = 0;
+ cls_struct_type.alignment = 0;
+ cls_struct_type.type = FFI_TYPE_STRUCT;
+ cls_struct_type.elements = cls_struct_fields;
+
+ cls_struct_type1.size = 0;
+ cls_struct_type1.alignment = 0;
+ cls_struct_type1.type = FFI_TYPE_STRUCT;
+ cls_struct_type1.elements = cls_struct_fields1;
+
+ cls_struct_type2.size = 0;
+ cls_struct_type2.alignment = 0;
+ cls_struct_type2.type = FFI_TYPE_STRUCT;
+ cls_struct_type2.elements = cls_struct_fields2;
+
+ cls_struct_fields[0] = &ffi_type_double;
+ cls_struct_fields[1] = &ffi_type_float;
+ cls_struct_fields[2] = &ffi_type_sint;
+ cls_struct_fields[3] = NULL;
+
+ cls_struct_fields1[0] = &ffi_type_sint;
+ cls_struct_fields1[1] = &ffi_type_double;
+ cls_struct_fields1[2] = &ffi_type_float;
+ cls_struct_fields1[3] = NULL;
+
+ cls_struct_fields2[0] = &cls_struct_type;
+ cls_struct_fields2[1] = &cls_struct_type1;
+ cls_struct_fields2[2] = NULL;
+
+
+ dbl_arg_types[0] = &cls_struct_type;
+ dbl_arg_types[1] = &cls_struct_type1;
+ dbl_arg_types[2] = &cls_struct_type2;
+ dbl_arg_types[3] = &cls_struct_type;
+ dbl_arg_types[4] = NULL;
+
+ CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 4, &cls_struct_type2,
+ dbl_arg_types) == FFI_OK);
+
+ args_dbl[0] = &e_dbl;
+ args_dbl[1] = &f_dbl;
+ args_dbl[2] = &g_dbl;
+ args_dbl[3] = &h_dbl;
+ args_dbl[4] = NULL;
+
+ ffi_call(&cif, FFI_FN(cls_struct_combined_fn), &res_dbl, args_dbl);
+ /* { dg-output "9 2 6 1 2 3 4 5 6 3 1 8 3 2 4: 15 10 13 10 12 13" } */
+ CHECK( res_dbl.d.a == (e_dbl.a + f_dbl.dd + g_dbl.d.a));
+ CHECK( res_dbl.d.b == (e_dbl.b + f_dbl.ff + g_dbl.d.b));
+ CHECK( res_dbl.d.c == (e_dbl.c + f_dbl.ii + g_dbl.d.c));
+ CHECK( res_dbl.e.ii == (e_dbl.c + f_dbl.ii + g_dbl.e.ii));
+ CHECK( res_dbl.e.dd == (e_dbl.a + f_dbl.dd + g_dbl.e.dd));
+ CHECK( res_dbl.e.ff == (e_dbl.b + f_dbl.ff + g_dbl.e.ff));
+
+ CHECK(ffi_prep_closure_loc(pcl, &cif, cls_struct_combined_gn, NULL, code) == FFI_OK);
+
+ res_dbl = ((cls_struct_combined(*)(cls_struct_16byte1,
+ cls_struct_16byte2,
+ cls_struct_combined,
+ cls_struct_16byte1))
+ (code))(e_dbl, f_dbl, g_dbl, h_dbl);
+ /* { dg-output "\n9 2 6 1 2 3 4 5 6 3 1 8 3 2 4: 15 10 13 10 12 13" } */
+ CHECK( res_dbl.d.a == (e_dbl.a + f_dbl.dd + g_dbl.d.a));
+ CHECK( res_dbl.d.b == (e_dbl.b + f_dbl.ff + g_dbl.d.b));
+ CHECK( res_dbl.d.c == (e_dbl.c + f_dbl.ii + g_dbl.d.c));
+ CHECK( res_dbl.e.ii == (e_dbl.c + f_dbl.ii + g_dbl.e.ii));
+ CHECK( res_dbl.e.dd == (e_dbl.a + f_dbl.dd + g_dbl.e.dd));
+ CHECK( res_dbl.e.ff == (e_dbl.b + f_dbl.ff + g_dbl.e.ff));
+ /* CHECK( 1 == 0); */
+ exit(0);
+}
diff --git a/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/nested_struct10.c b/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/nested_struct10.c
new file mode 100644
index 0000000..34a74e7
--- /dev/null
+++ b/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/nested_struct10.c
@@ -0,0 +1,133 @@
+/* Area: ffi_call, closure_call
+ Purpose: Check structure passing with different structure size.
+ Contains structs as parameter of the struct itself.
+ Sample taken from Alan Modras patch to src/prep_cif.c.
+ Limitations: none.
+ PR: none.
+ Originator: <andreast@gcc.gnu.org> 20051010 */
+
+/* { dg-do run } */
+#include "ffitest.h"
+
+typedef struct A {
+ unsigned long long a;
+ unsigned char b;
+} A;
+
+typedef struct B {
+ unsigned char y;
+ struct A x;
+ unsigned int z;
+} B;
+
+typedef struct C {
+ unsigned long long d;
+ unsigned char e;
+} C;
+
+static B B_fn(struct A b2, struct B b3, struct C b4)
+{
+ struct B result;
+
+ result.x.a = b2.a + b3.x.a + b3.z + b4.d;
+ result.x.b = b2.b + b3.x.b + b3.y + b4.e;
+ result.y = b2.b + b3.x.b + b4.e;
+
+ printf("%d %d %d %d %d %d %d %d: %d %d %d\n", (int)b2.a, b2.b,
+ (int)b3.x.a, b3.x.b, b3.y, b3.z, (int)b4.d, b4.e,
+ (int)result.x.a, result.x.b, result.y);
+
+ return result;
+}
+
+static void
+B_gn(ffi_cif* cif __UNUSED__, void* resp, void** args,
+ void* userdata __UNUSED__)
+{
+ struct A b0;
+ struct B b1;
+ struct C b2;
+
+ b0 = *(struct A*)(args[0]);
+ b1 = *(struct B*)(args[1]);
+ b2 = *(struct C*)(args[2]);
+
+ *(B*)resp = B_fn(b0, b1, b2);
+}
+
+int main (void)
+{
+ ffi_cif cif;
+ void *code;
+ ffi_closure *pcl = ffi_closure_alloc(sizeof(ffi_closure), &code);
+ void* args_dbl[4];
+ ffi_type* cls_struct_fields[3];
+ ffi_type* cls_struct_fields1[4];
+ ffi_type* cls_struct_fields2[3];
+ ffi_type cls_struct_type, cls_struct_type1, cls_struct_type2;
+ ffi_type* dbl_arg_types[4];
+
+ struct A e_dbl = { 1LL, 7};
+ struct B f_dbl = { 99, {12LL , 127}, 255};
+ struct C g_dbl = { 2LL, 9};
+
+ struct B res_dbl;
+
+ cls_struct_type.size = 0;
+ cls_struct_type.alignment = 0;
+ cls_struct_type.type = FFI_TYPE_STRUCT;
+ cls_struct_type.elements = cls_struct_fields;
+
+ cls_struct_type1.size = 0;
+ cls_struct_type1.alignment = 0;
+ cls_struct_type1.type = FFI_TYPE_STRUCT;
+ cls_struct_type1.elements = cls_struct_fields1;
+
+ cls_struct_type2.size = 0;
+ cls_struct_type2.alignment = 0;
+ cls_struct_type2.type = FFI_TYPE_STRUCT;
+ cls_struct_type2.elements = cls_struct_fields2;
+
+ cls_struct_fields[0] = &ffi_type_uint64;
+ cls_struct_fields[1] = &ffi_type_uchar;
+ cls_struct_fields[2] = NULL;
+
+ cls_struct_fields1[0] = &ffi_type_uchar;
+ cls_struct_fields1[1] = &cls_struct_type;
+ cls_struct_fields1[2] = &ffi_type_uint;
+ cls_struct_fields1[3] = NULL;
+
+ cls_struct_fields2[0] = &ffi_type_uint64;
+ cls_struct_fields2[1] = &ffi_type_uchar;
+ cls_struct_fields2[2] = NULL;
+
+
+ dbl_arg_types[0] = &cls_struct_type;
+ dbl_arg_types[1] = &cls_struct_type1;
+ dbl_arg_types[2] = &cls_struct_type2;
+ dbl_arg_types[3] = NULL;
+
+ CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 3, &cls_struct_type1,
+ dbl_arg_types) == FFI_OK);
+
+ args_dbl[0] = &e_dbl;
+ args_dbl[1] = &f_dbl;
+ args_dbl[2] = &g_dbl;
+ args_dbl[3] = NULL;
+
+ ffi_call(&cif, FFI_FN(B_fn), &res_dbl, args_dbl);
+ /* { dg-output "1 7 12 127 99 255 2 9: 270 242 143" } */
+ CHECK( res_dbl.x.a == (e_dbl.a + f_dbl.x.a + f_dbl.z + g_dbl.d));
+ CHECK( res_dbl.x.b == (e_dbl.b + f_dbl.x.b + f_dbl.y + g_dbl.e));
+ CHECK( res_dbl.y == (e_dbl.b + f_dbl.x.b + g_dbl.e));
+
+ CHECK(ffi_prep_closure_loc(pcl, &cif, B_gn, NULL, code) == FFI_OK);
+
+ res_dbl = ((B(*)(A, B, C))(code))(e_dbl, f_dbl, g_dbl);
+ /* { dg-output "\n1 7 12 127 99 255 2 9: 270 242 143" } */
+ CHECK( res_dbl.x.a == (e_dbl.a + f_dbl.x.a + f_dbl.z + g_dbl.d));
+ CHECK( res_dbl.x.b == (e_dbl.b + f_dbl.x.b + f_dbl.y + g_dbl.e));
+ CHECK( res_dbl.y == (e_dbl.b + f_dbl.x.b + g_dbl.e));
+
+ exit(0);
+}
diff --git a/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/nested_struct11.c b/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/nested_struct11.c
new file mode 100644
index 0000000..3510493
--- /dev/null
+++ b/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/nested_struct11.c
@@ -0,0 +1,121 @@
+/* Area: ffi_call, closure_call
+ Purpose: Check parameter passing with nested structs
+ of a single type. This tests the special cases
+ for homogeneous floating-point aggregates in the
+ AArch64 PCS.
+ Limitations: none.
+ PR: none.
+ Originator: ARM Ltd. */
+
+/* { dg-do run } */
+#include "ffitest.h"
+
+typedef struct A {
+ float a_x;
+ float a_y;
+} A;
+
+typedef struct B {
+ float b_x;
+ float b_y;
+} B;
+
+typedef struct C {
+ A a;
+ B b;
+} C;
+
+static C C_fn (int x, int y, int z, C source, int i, int j, int k)
+{
+ C result;
+ result.a.a_x = source.a.a_x;
+ result.a.a_y = source.a.a_y;
+ result.b.b_x = source.b.b_x;
+ result.b.b_y = source.b.b_y;
+
+ printf ("%d, %d, %d, %d, %d, %d\n", x, y, z, i, j, k);
+
+ printf ("%.1f, %.1f, %.1f, %.1f, "
+ "%.1f, %.1f, %.1f, %.1f\n",
+ source.a.a_x, source.a.a_y,
+ source.b.b_x, source.b.b_y,
+ result.a.a_x, result.a.a_y,
+ result.b.b_x, result.b.b_y);
+
+ return result;
+}
+
+int main (void)
+{
+ ffi_cif cif;
+
+ ffi_type* struct_fields_source_a[3];
+ ffi_type* struct_fields_source_b[3];
+ ffi_type* struct_fields_source_c[3];
+ ffi_type* arg_types[8];
+
+ ffi_type struct_type_a, struct_type_b, struct_type_c;
+
+ struct A source_fld_a = {1.0, 2.0};
+ struct B source_fld_b = {4.0, 8.0};
+ int k = 1;
+
+ struct C result;
+ struct C source = {source_fld_a, source_fld_b};
+
+ struct_type_a.size = 0;
+ struct_type_a.alignment = 0;
+ struct_type_a.type = FFI_TYPE_STRUCT;
+ struct_type_a.elements = struct_fields_source_a;
+
+ struct_type_b.size = 0;
+ struct_type_b.alignment = 0;
+ struct_type_b.type = FFI_TYPE_STRUCT;
+ struct_type_b.elements = struct_fields_source_b;
+
+ struct_type_c.size = 0;
+ struct_type_c.alignment = 0;
+ struct_type_c.type = FFI_TYPE_STRUCT;
+ struct_type_c.elements = struct_fields_source_c;
+
+ struct_fields_source_a[0] = &ffi_type_float;
+ struct_fields_source_a[1] = &ffi_type_float;
+ struct_fields_source_a[2] = NULL;
+
+ struct_fields_source_b[0] = &ffi_type_float;
+ struct_fields_source_b[1] = &ffi_type_float;
+ struct_fields_source_b[2] = NULL;
+
+ struct_fields_source_c[0] = &struct_type_a;
+ struct_fields_source_c[1] = &struct_type_b;
+ struct_fields_source_c[2] = NULL;
+
+ arg_types[0] = &ffi_type_sint32;
+ arg_types[1] = &ffi_type_sint32;
+ arg_types[2] = &ffi_type_sint32;
+ arg_types[3] = &struct_type_c;
+ arg_types[4] = &ffi_type_sint32;
+ arg_types[5] = &ffi_type_sint32;
+ arg_types[6] = &ffi_type_sint32;
+ arg_types[7] = NULL;
+
+ void *args[7];
+ args[0] = &k;
+ args[1] = &k;
+ args[2] = &k;
+ args[3] = &source;
+ args[4] = &k;
+ args[5] = &k;
+ args[6] = &k;
+ CHECK (ffi_prep_cif (&cif, FFI_DEFAULT_ABI, 7, &struct_type_c,
+ arg_types) == FFI_OK);
+
+ ffi_call (&cif, FFI_FN (C_fn), &result, args);
+ /* { dg-output "1, 1, 1, 1, 1, 1\n" } */
+ /* { dg-output "1.0, 2.0, 4.0, 8.0, 1.0, 2.0, 4.0, 8.0" } */
+ CHECK (result.a.a_x == source.a.a_x);
+ CHECK (result.a.a_y == source.a.a_y);
+ CHECK (result.b.b_x == source.b.b_x);
+ CHECK (result.b.b_y == source.b.b_y);
+ exit (0);
+}
diff --git a/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/nested_struct2.c b/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/nested_struct2.c
new file mode 100644
index 0000000..69268cd
--- /dev/null
+++ b/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/nested_struct2.c
@@ -0,0 +1,110 @@
+/* Area: ffi_call, closure_call
+ Purpose: Check structure passing with different structure size.
+ Contains structs as parameter of the struct itself.
+ Sample taken from Alan Modras patch to src/prep_cif.c.
+ Limitations: none.
+ PR: none.
+ Originator: <andreast@gcc.gnu.org> 20030911 */
+
+/* { dg-do run } */
+#include "ffitest.h"
+
+typedef struct A {
+ unsigned long a;
+ unsigned char b;
+} A;
+
+typedef struct B {
+ struct A x;
+ unsigned char y;
+} B;
+
+B B_fn(struct A b0, struct B b1)
+{
+ struct B result;
+
+ result.x.a = b0.a + b1.x.a;
+ result.x.b = b0.b + b1.x.b + b1.y;
+ result.y = b0.b + b1.x.b;
+
+ printf("%lu %d %lu %d %d: %lu %d %d\n", b0.a, b0.b, b1.x.a, b1.x.b, b1.y,
+ result.x.a, result.x.b, result.y);
+
+ return result;
+}
+
+static void
+B_gn(ffi_cif* cif __UNUSED__, void* resp, void** args,
+ void* userdata __UNUSED__)
+{
+ struct A b0;
+ struct B b1;
+
+ b0 = *(struct A*)(args[0]);
+ b1 = *(struct B*)(args[1]);
+
+ *(B*)resp = B_fn(b0, b1);
+}
+
+int main (void)
+{
+ ffi_cif cif;
+ void *code;
+ ffi_closure *pcl = ffi_closure_alloc(sizeof(ffi_closure), &code);
+ void* args_dbl[3];
+ ffi_type* cls_struct_fields[3];
+ ffi_type* cls_struct_fields1[3];
+ ffi_type cls_struct_type, cls_struct_type1;
+ ffi_type* dbl_arg_types[3];
+
+ struct A e_dbl = { 1, 7};
+ struct B f_dbl = {{12 , 127}, 99};
+
+ struct B res_dbl;
+
+ cls_struct_type.size = 0;
+ cls_struct_type.alignment = 0;
+ cls_struct_type.type = FFI_TYPE_STRUCT;
+ cls_struct_type.elements = cls_struct_fields;
+
+ cls_struct_type1.size = 0;
+ cls_struct_type1.alignment = 0;
+ cls_struct_type1.type = FFI_TYPE_STRUCT;
+ cls_struct_type1.elements = cls_struct_fields1;
+
+ cls_struct_fields[0] = &ffi_type_ulong;
+ cls_struct_fields[1] = &ffi_type_uchar;
+ cls_struct_fields[2] = NULL;
+
+ cls_struct_fields1[0] = &cls_struct_type;
+ cls_struct_fields1[1] = &ffi_type_uchar;
+ cls_struct_fields1[2] = NULL;
+
+
+ dbl_arg_types[0] = &cls_struct_type;
+ dbl_arg_types[1] = &cls_struct_type1;
+ dbl_arg_types[2] = NULL;
+
+ CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 2, &cls_struct_type1,
+ dbl_arg_types) == FFI_OK);
+
+ args_dbl[0] = &e_dbl;
+ args_dbl[1] = &f_dbl;
+ args_dbl[2] = NULL;
+
+ ffi_call(&cif, FFI_FN(B_fn), &res_dbl, args_dbl);
+ /* { dg-output "1 7 12 127 99: 13 233 134" } */
+ CHECK( res_dbl.x.a == (e_dbl.a + f_dbl.x.a));
+ CHECK( res_dbl.x.b == (e_dbl.b + f_dbl.x.b + f_dbl.y));
+ CHECK( res_dbl.y == (e_dbl.b + f_dbl.x.b));
+
+ CHECK(ffi_prep_closure_loc(pcl, &cif, B_gn, NULL, code) == FFI_OK);
+
+ res_dbl = ((B(*)(A, B))(code))(e_dbl, f_dbl);
+ /* { dg-output "\n1 7 12 127 99: 13 233 134" } */
+ CHECK( res_dbl.x.a == (e_dbl.a + f_dbl.x.a));
+ CHECK( res_dbl.x.b == (e_dbl.b + f_dbl.x.b + f_dbl.y));
+ CHECK( res_dbl.y == (e_dbl.b + f_dbl.x.b));
+
+ exit(0);
+}
diff --git a/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/nested_struct3.c b/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/nested_struct3.c
new file mode 100644
index 0000000..ab18cad
--- /dev/null
+++ b/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/nested_struct3.c
@@ -0,0 +1,111 @@
+/* Area: ffi_call, closure_call
+ Purpose: Check structure passing with different structure size.
+ Contains structs as parameter of the struct itself.
+ Sample taken from Alan Modras patch to src/prep_cif.c.
+ Limitations: none.
+ PR: none.
+ Originator: <andreast@gcc.gnu.org> 20030911 */
+
+/* { dg-do run } */
+#include "ffitest.h"
+
+typedef struct A {
+ unsigned long long a;
+ unsigned char b;
+} A;
+
+typedef struct B {
+ struct A x;
+ unsigned char y;
+} B;
+
+B B_fn(struct A b0, struct B b1)
+{
+ struct B result;
+
+ result.x.a = b0.a + b1.x.a;
+ result.x.b = b0.b + b1.x.b + b1.y;
+ result.y = b0.b + b1.x.b;
+
+ printf("%d %d %d %d %d: %d %d %d\n", (int)b0.a, b0.b,
+ (int)b1.x.a, b1.x.b, b1.y,
+ (int)result.x.a, result.x.b, result.y);
+
+ return result;
+}
+
+static void
+B_gn(ffi_cif* cif __UNUSED__, void* resp, void** args,
+ void* userdata __UNUSED__)
+{
+ struct A b0;
+ struct B b1;
+
+ b0 = *(struct A*)(args[0]);
+ b1 = *(struct B*)(args[1]);
+
+ *(B*)resp = B_fn(b0, b1);
+}
+
+int main (void)
+{
+ ffi_cif cif;
+ void *code;
+ ffi_closure *pcl = ffi_closure_alloc(sizeof(ffi_closure), &code);
+ void* args_dbl[3];
+ ffi_type* cls_struct_fields[3];
+ ffi_type* cls_struct_fields1[3];
+ ffi_type cls_struct_type, cls_struct_type1;
+ ffi_type* dbl_arg_types[3];
+
+ struct A e_dbl = { 1LL, 7};
+ struct B f_dbl = {{12LL , 127}, 99};
+
+ struct B res_dbl;
+
+ cls_struct_type.size = 0;
+ cls_struct_type.alignment = 0;
+ cls_struct_type.type = FFI_TYPE_STRUCT;
+ cls_struct_type.elements = cls_struct_fields;
+
+ cls_struct_type1.size = 0;
+ cls_struct_type1.alignment = 0;
+ cls_struct_type1.type = FFI_TYPE_STRUCT;
+ cls_struct_type1.elements = cls_struct_fields1;
+
+ cls_struct_fields[0] = &ffi_type_uint64;
+ cls_struct_fields[1] = &ffi_type_uchar;
+ cls_struct_fields[2] = NULL;
+
+ cls_struct_fields1[0] = &cls_struct_type;
+ cls_struct_fields1[1] = &ffi_type_uchar;
+ cls_struct_fields1[2] = NULL;
+
+
+ dbl_arg_types[0] = &cls_struct_type;
+ dbl_arg_types[1] = &cls_struct_type1;
+ dbl_arg_types[2] = NULL;
+
+ CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 2, &cls_struct_type1,
+ dbl_arg_types) == FFI_OK);
+
+ args_dbl[0] = &e_dbl;
+ args_dbl[1] = &f_dbl;
+ args_dbl[2] = NULL;
+
+ ffi_call(&cif, FFI_FN(B_fn), &res_dbl, args_dbl);
+ /* { dg-output "1 7 12 127 99: 13 233 134" } */
+ CHECK( res_dbl.x.a == (e_dbl.a + f_dbl.x.a));
+ CHECK( res_dbl.x.b == (e_dbl.b + f_dbl.x.b + f_dbl.y));
+ CHECK( res_dbl.y == (e_dbl.b + f_dbl.x.b));
+
+
+ CHECK(ffi_prep_closure_loc(pcl, &cif, B_gn, NULL, code) == FFI_OK);
+
+ res_dbl = ((B(*)(A, B))(code))(e_dbl, f_dbl);
+ /* { dg-output "\n1 7 12 127 99: 13 233 134" } */
+ CHECK( res_dbl.x.a == (e_dbl.a + f_dbl.x.a));
+ CHECK( res_dbl.x.b == (e_dbl.b + f_dbl.x.b + f_dbl.y));
+ CHECK( res_dbl.y == (e_dbl.b + f_dbl.x.b));
+ exit(0);
+}
diff --git a/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/nested_struct4.c b/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/nested_struct4.c
new file mode 100644
index 0000000..2ffb4d6
--- /dev/null
+++ b/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/nested_struct4.c
@@ -0,0 +1,111 @@
+/* Area: ffi_call, closure_call
+ Purpose: Check structure passing with different structure size.
+ Contains structs as parameter of the struct itself.
+ Sample taken from Alan Modras patch to src/prep_cif.c.
+ Limitations: none.
+ PR: PR 25630.
+ Originator: <andreast@gcc.gnu.org> 20051010 */
+
+/* { dg-do run } */
+#include "ffitest.h"
+
+typedef struct A {
+ double a;
+ unsigned char b;
+} A;
+
+typedef struct B {
+ struct A x;
+ unsigned char y;
+} B;
+
+static B B_fn(struct A b2, struct B b3)
+{
+ struct B result;
+
+ result.x.a = b2.a + b3.x.a;
+ result.x.b = b2.b + b3.x.b + b3.y;
+ result.y = b2.b + b3.x.b;
+
+ printf("%d %d %d %d %d: %d %d %d\n", (int)b2.a, b2.b,
+ (int)b3.x.a, b3.x.b, b3.y,
+ (int)result.x.a, result.x.b, result.y);
+
+ return result;
+}
+
+static void
+B_gn(ffi_cif* cif __UNUSED__, void* resp, void** args,
+ void* userdata __UNUSED__)
+{
+ struct A b0;
+ struct B b1;
+
+ b0 = *(struct A*)(args[0]);
+ b1 = *(struct B*)(args[1]);
+
+ *(B*)resp = B_fn(b0, b1);
+}
+
+int main (void)
+{
+ ffi_cif cif;
+ void *code;
+ ffi_closure *pcl = ffi_closure_alloc(sizeof(ffi_closure), &code);
+ void* args_dbl[3];
+ ffi_type* cls_struct_fields[3];
+ ffi_type* cls_struct_fields1[3];
+ ffi_type cls_struct_type, cls_struct_type1;
+ ffi_type* dbl_arg_types[3];
+
+ struct A e_dbl = { 1.0, 7};
+ struct B f_dbl = {{12.0 , 127}, 99};
+
+ struct B res_dbl;
+
+ cls_struct_type.size = 0;
+ cls_struct_type.alignment = 0;
+ cls_struct_type.type = FFI_TYPE_STRUCT;
+ cls_struct_type.elements = cls_struct_fields;
+
+ cls_struct_type1.size = 0;
+ cls_struct_type1.alignment = 0;
+ cls_struct_type1.type = FFI_TYPE_STRUCT;
+ cls_struct_type1.elements = cls_struct_fields1;
+
+ cls_struct_fields[0] = &ffi_type_double;
+ cls_struct_fields[1] = &ffi_type_uchar;
+ cls_struct_fields[2] = NULL;
+
+ cls_struct_fields1[0] = &cls_struct_type;
+ cls_struct_fields1[1] = &ffi_type_uchar;
+ cls_struct_fields1[2] = NULL;
+
+
+ dbl_arg_types[0] = &cls_struct_type;
+ dbl_arg_types[1] = &cls_struct_type1;
+ dbl_arg_types[2] = NULL;
+
+ CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 2, &cls_struct_type1,
+ dbl_arg_types) == FFI_OK);
+
+ args_dbl[0] = &e_dbl;
+ args_dbl[1] = &f_dbl;
+ args_dbl[2] = NULL;
+
+ ffi_call(&cif, FFI_FN(B_fn), &res_dbl, args_dbl);
+ /* { dg-output "1 7 12 127 99: 13 233 134" } */
+ CHECK( res_dbl.x.a == (e_dbl.a + f_dbl.x.a));
+ CHECK( res_dbl.x.b == (e_dbl.b + f_dbl.x.b + f_dbl.y));
+ CHECK( res_dbl.y == (e_dbl.b + f_dbl.x.b));
+
+ CHECK(ffi_prep_closure_loc(pcl, &cif, B_gn, NULL, code) == FFI_OK);
+
+ res_dbl = ((B(*)(A, B))(code))(e_dbl, f_dbl);
+ /* { dg-output "\n1 7 12 127 99: 13 233 134" } */
+ CHECK( res_dbl.x.a == (e_dbl.a + f_dbl.x.a));
+ CHECK( res_dbl.x.b == (e_dbl.b + f_dbl.x.b + f_dbl.y));
+ CHECK( res_dbl.y == (e_dbl.b + f_dbl.x.b));
+
+ exit(0);
+}
diff --git a/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/nested_struct5.c b/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/nested_struct5.c
new file mode 100644
index 0000000..6c79845
--- /dev/null
+++ b/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/nested_struct5.c
@@ -0,0 +1,112 @@
+/* Area: ffi_call, closure_call
+ Purpose: Check structure passing with different structure size.
+ Contains structs as parameter of the struct itself.
+ Sample taken from Alan Modras patch to src/prep_cif.c.
+ Limitations: none.
+ PR: none.
+ Originator: <andreast@gcc.gnu.org> 20051010 */
+
+/* { dg-do run } */
+#include "ffitest.h"
+
+typedef struct A {
+ long double a;
+ unsigned char b;
+} A;
+
+typedef struct B {
+ struct A x;
+ unsigned char y;
+} B;
+
+static B B_fn(struct A b2, struct B b3)
+{
+ struct B result;
+
+ result.x.a = b2.a + b3.x.a;
+ result.x.b = b2.b + b3.x.b + b3.y;
+ result.y = b2.b + b3.x.b;
+
+ printf("%d %d %d %d %d: %d %d %d\n", (int)b2.a, b2.b,
+ (int)b3.x.a, b3.x.b, b3.y,
+ (int)result.x.a, result.x.b, result.y);
+
+ return result;
+}
+
+static void
+B_gn(ffi_cif* cif __UNUSED__, void* resp, void** args,
+ void* userdata __UNUSED__)
+{
+ struct A b0;
+ struct B b1;
+
+ b0 = *(struct A*)(args[0]);
+ b1 = *(struct B*)(args[1]);
+
+ *(B*)resp = B_fn(b0, b1);
+}
+
+int main (void)
+{
+ ffi_cif cif;
+ void *code;
+ ffi_closure *pcl = ffi_closure_alloc(sizeof(ffi_closure), &code);
+ void* args_dbl[3];
+ ffi_type* cls_struct_fields[3];
+ ffi_type* cls_struct_fields1[3];
+ ffi_type cls_struct_type, cls_struct_type1;
+ ffi_type* dbl_arg_types[3];
+
+ struct A e_dbl = { 1.0, 7};
+ struct B f_dbl = {{12.0 , 127}, 99};
+
+ struct B res_dbl;
+
+ cls_struct_type.size = 0;
+ cls_struct_type.alignment = 0;
+ cls_struct_type.type = FFI_TYPE_STRUCT;
+ cls_struct_type.elements = cls_struct_fields;
+
+ cls_struct_type1.size = 0;
+ cls_struct_type1.alignment = 0;
+ cls_struct_type1.type = FFI_TYPE_STRUCT;
+ cls_struct_type1.elements = cls_struct_fields1;
+
+ cls_struct_fields[0] = &ffi_type_longdouble;
+ cls_struct_fields[1] = &ffi_type_uchar;
+ cls_struct_fields[2] = NULL;
+
+ cls_struct_fields1[0] = &cls_struct_type;
+ cls_struct_fields1[1] = &ffi_type_uchar;
+ cls_struct_fields1[2] = NULL;
+
+
+ dbl_arg_types[0] = &cls_struct_type;
+ dbl_arg_types[1] = &cls_struct_type1;
+ dbl_arg_types[2] = NULL;
+
+ CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 2, &cls_struct_type1,
+ dbl_arg_types) == FFI_OK);
+
+ args_dbl[0] = &e_dbl;
+ args_dbl[1] = &f_dbl;
+ args_dbl[2] = NULL;
+
+ ffi_call(&cif, FFI_FN(B_fn), &res_dbl, args_dbl);
+ /* { dg-output "1 7 12 127 99: 13 233 134" } */
+ CHECK( res_dbl.x.a == (e_dbl.a + f_dbl.x.a));
+ CHECK( res_dbl.x.b == (e_dbl.b + f_dbl.x.b + f_dbl.y));
+ CHECK( res_dbl.y == (e_dbl.b + f_dbl.x.b));
+
+
+ CHECK(ffi_prep_closure_loc(pcl, &cif, B_gn, NULL, code) == FFI_OK);
+
+ res_dbl = ((B(*)(A, B))(code))(e_dbl, f_dbl);
+ /* { dg-output "\n1 7 12 127 99: 13 233 134" } */
+ CHECK( res_dbl.x.a == (e_dbl.a + f_dbl.x.a));
+ CHECK( res_dbl.x.b == (e_dbl.b + f_dbl.x.b + f_dbl.y));
+ CHECK( res_dbl.y == (e_dbl.b + f_dbl.x.b));
+
+ exit(0);
+}
diff --git a/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/nested_struct6.c b/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/nested_struct6.c
new file mode 100644
index 0000000..59d3579
--- /dev/null
+++ b/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/nested_struct6.c
@@ -0,0 +1,131 @@
+/* Area: ffi_call, closure_call
+ Purpose: Check structure passing with different structure size.
+ Contains structs as parameter of the struct itself.
+ Sample taken from Alan Modras patch to src/prep_cif.c.
+ Limitations: none.
+ PR: PR 25630.
+ Originator: <andreast@gcc.gnu.org> 20051010 */
+
+/* { dg-do run } */
+#include "ffitest.h"
+
+typedef struct A {
+ double a;
+ unsigned char b;
+} A;
+
+typedef struct B {
+ struct A x;
+ unsigned char y;
+} B;
+
+typedef struct C {
+ long d;
+ unsigned char e;
+} C;
+
+static B B_fn(struct A b2, struct B b3, struct C b4)
+{
+ struct B result;
+
+ result.x.a = b2.a + b3.x.a + b4.d;
+ result.x.b = b2.b + b3.x.b + b3.y + b4.e;
+ result.y = b2.b + b3.x.b + b4.e;
+
+ printf("%d %d %d %d %d %d %d: %d %d %d\n", (int)b2.a, b2.b,
+ (int)b3.x.a, b3.x.b, b3.y, (int)b4.d, b4.e,
+ (int)result.x.a, result.x.b, result.y);
+
+ return result;
+}
+
+static void
+B_gn(ffi_cif* cif __UNUSED__, void* resp, void** args,
+ void* userdata __UNUSED__)
+{
+ struct A b0;
+ struct B b1;
+ struct C b2;
+
+ b0 = *(struct A*)(args[0]);
+ b1 = *(struct B*)(args[1]);
+ b2 = *(struct C*)(args[2]);
+
+ *(B*)resp = B_fn(b0, b1, b2);
+}
+
+int main (void)
+{
+ ffi_cif cif;
+ void *code;
+ ffi_closure *pcl = ffi_closure_alloc(sizeof(ffi_closure), &code);
+ void* args_dbl[4];
+ ffi_type* cls_struct_fields[3];
+ ffi_type* cls_struct_fields1[3];
+ ffi_type* cls_struct_fields2[3];
+ ffi_type cls_struct_type, cls_struct_type1, cls_struct_type2;
+ ffi_type* dbl_arg_types[4];
+
+ struct A e_dbl = { 1.0, 7};
+ struct B f_dbl = {{12.0 , 127}, 99};
+ struct C g_dbl = { 2, 9};
+
+ struct B res_dbl;
+
+ cls_struct_type.size = 0;
+ cls_struct_type.alignment = 0;
+ cls_struct_type.type = FFI_TYPE_STRUCT;
+ cls_struct_type.elements = cls_struct_fields;
+
+ cls_struct_type1.size = 0;
+ cls_struct_type1.alignment = 0;
+ cls_struct_type1.type = FFI_TYPE_STRUCT;
+ cls_struct_type1.elements = cls_struct_fields1;
+
+ cls_struct_type2.size = 0;
+ cls_struct_type2.alignment = 0;
+ cls_struct_type2.type = FFI_TYPE_STRUCT;
+ cls_struct_type2.elements = cls_struct_fields2;
+
+ cls_struct_fields[0] = &ffi_type_double;
+ cls_struct_fields[1] = &ffi_type_uchar;
+ cls_struct_fields[2] = NULL;
+
+ cls_struct_fields1[0] = &cls_struct_type;
+ cls_struct_fields1[1] = &ffi_type_uchar;
+ cls_struct_fields1[2] = NULL;
+
+ cls_struct_fields2[0] = &ffi_type_slong;
+ cls_struct_fields2[1] = &ffi_type_uchar;
+ cls_struct_fields2[2] = NULL;
+
+
+ dbl_arg_types[0] = &cls_struct_type;
+ dbl_arg_types[1] = &cls_struct_type1;
+ dbl_arg_types[2] = &cls_struct_type2;
+ dbl_arg_types[3] = NULL;
+
+ CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 3, &cls_struct_type1,
+ dbl_arg_types) == FFI_OK);
+
+ args_dbl[0] = &e_dbl;
+ args_dbl[1] = &f_dbl;
+ args_dbl[2] = &g_dbl;
+ args_dbl[3] = NULL;
+
+ ffi_call(&cif, FFI_FN(B_fn), &res_dbl, args_dbl);
+ /* { dg-output "1 7 12 127 99 2 9: 15 242 143" } */
+ CHECK( res_dbl.x.a == (e_dbl.a + f_dbl.x.a + g_dbl.d));
+ CHECK( res_dbl.x.b == (e_dbl.b + f_dbl.x.b + f_dbl.y + g_dbl.e));
+ CHECK( res_dbl.y == (e_dbl.b + f_dbl.x.b + g_dbl.e));
+
+ CHECK(ffi_prep_closure_loc(pcl, &cif, B_gn, NULL, code) == FFI_OK);
+
+ res_dbl = ((B(*)(A, B, C))(code))(e_dbl, f_dbl, g_dbl);
+ /* { dg-output "\n1 7 12 127 99 2 9: 15 242 143" } */
+ CHECK( res_dbl.x.a == (e_dbl.a + f_dbl.x.a + g_dbl.d));
+ CHECK( res_dbl.x.b == (e_dbl.b + f_dbl.x.b + f_dbl.y + g_dbl.e));
+ CHECK( res_dbl.y == (e_dbl.b + f_dbl.x.b + g_dbl.e));
+
+ exit(0);
+}
diff --git a/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/nested_struct7.c b/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/nested_struct7.c
new file mode 100644
index 0000000..27595e6
--- /dev/null
+++ b/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/nested_struct7.c
@@ -0,0 +1,111 @@
+/* Area: ffi_call, closure_call
+ Purpose: Check structure passing with different structure size.
+ Contains structs as parameter of the struct itself.
+ Sample taken from Alan Modras patch to src/prep_cif.c.
+ Limitations: none.
+ PR: none.
+ Originator: <andreast@gcc.gnu.org> 20051010 */
+
+/* { dg-do run } */
+#include "ffitest.h"
+
+typedef struct A {
+ unsigned long long a;
+ unsigned char b;
+} A;
+
+typedef struct B {
+ struct A x;
+ unsigned char y;
+} B;
+
+static B B_fn(struct A b2, struct B b3)
+{
+ struct B result;
+
+ result.x.a = b2.a + b3.x.a;
+ result.x.b = b2.b + b3.x.b + b3.y;
+ result.y = b2.b + b3.x.b;
+
+ printf("%d %d %d %d %d: %d %d %d\n", (int)b2.a, b2.b,
+ (int)b3.x.a, b3.x.b, b3.y,
+ (int)result.x.a, result.x.b, result.y);
+
+ return result;
+}
+
+static void
+B_gn(ffi_cif* cif __UNUSED__, void* resp, void** args,
+ void* userdata __UNUSED__)
+{
+ struct A b0;
+ struct B b1;
+
+ b0 = *(struct A*)(args[0]);
+ b1 = *(struct B*)(args[1]);
+
+ *(B*)resp = B_fn(b0, b1);
+}
+
+int main (void)
+{
+ ffi_cif cif;
+ void *code;
+ ffi_closure *pcl = ffi_closure_alloc(sizeof(ffi_closure), &code);
+ void* args_dbl[3];
+ ffi_type* cls_struct_fields[3];
+ ffi_type* cls_struct_fields1[3];
+ ffi_type cls_struct_type, cls_struct_type1;
+ ffi_type* dbl_arg_types[3];
+
+ struct A e_dbl = { 1LL, 7};
+ struct B f_dbl = {{12.0 , 127}, 99};
+
+ struct B res_dbl;
+
+ cls_struct_type.size = 0;
+ cls_struct_type.alignment = 0;
+ cls_struct_type.type = FFI_TYPE_STRUCT;
+ cls_struct_type.elements = cls_struct_fields;
+
+ cls_struct_type1.size = 0;
+ cls_struct_type1.alignment = 0;
+ cls_struct_type1.type = FFI_TYPE_STRUCT;
+ cls_struct_type1.elements = cls_struct_fields1;
+
+ cls_struct_fields[0] = &ffi_type_uint64;
+ cls_struct_fields[1] = &ffi_type_uchar;
+ cls_struct_fields[2] = NULL;
+
+ cls_struct_fields1[0] = &cls_struct_type;
+ cls_struct_fields1[1] = &ffi_type_uchar;
+ cls_struct_fields1[2] = NULL;
+
+
+ dbl_arg_types[0] = &cls_struct_type;
+ dbl_arg_types[1] = &cls_struct_type1;
+ dbl_arg_types[2] = NULL;
+
+ CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 2, &cls_struct_type1,
+ dbl_arg_types) == FFI_OK);
+
+ args_dbl[0] = &e_dbl;
+ args_dbl[1] = &f_dbl;
+ args_dbl[2] = NULL;
+
+ ffi_call(&cif, FFI_FN(B_fn), &res_dbl, args_dbl);
+ /* { dg-output "1 7 12 127 99: 13 233 134" } */
+ CHECK( res_dbl.x.a == (e_dbl.a + f_dbl.x.a));
+ CHECK( res_dbl.x.b == (e_dbl.b + f_dbl.x.b + f_dbl.y));
+ CHECK( res_dbl.y == (e_dbl.b + f_dbl.x.b));
+
+ CHECK(ffi_prep_closure_loc(pcl, &cif, B_gn, NULL, code) == FFI_OK);
+
+ res_dbl = ((B(*)(A, B))(code))(e_dbl, f_dbl);
+ /* { dg-output "\n1 7 12 127 99: 13 233 134" } */
+ CHECK( res_dbl.x.a == (e_dbl.a + f_dbl.x.a));
+ CHECK( res_dbl.x.b == (e_dbl.b + f_dbl.x.b + f_dbl.y));
+ CHECK( res_dbl.y == (e_dbl.b + f_dbl.x.b));
+
+ exit(0);
+}
diff --git a/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/nested_struct8.c b/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/nested_struct8.c
new file mode 100644
index 0000000..0e6c682
--- /dev/null
+++ b/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/nested_struct8.c
@@ -0,0 +1,131 @@
+/* Area: ffi_call, closure_call
+ Purpose: Check structure passing with different structure size.
+ Contains structs as parameter of the struct itself.
+ Sample taken from Alan Modras patch to src/prep_cif.c.
+ Limitations: none.
+ PR: none.
+ Originator: <andreast@gcc.gnu.org> 20051010 */
+
+/* { dg-do run } */
+#include "ffitest.h"
+
+typedef struct A {
+ unsigned long long a;
+ unsigned char b;
+} A;
+
+typedef struct B {
+ struct A x;
+ unsigned char y;
+} B;
+
+typedef struct C {
+ unsigned long long d;
+ unsigned char e;
+} C;
+
+static B B_fn(struct A b2, struct B b3, struct C b4)
+{
+ struct B result;
+
+ result.x.a = b2.a + b3.x.a + b4.d;
+ result.x.b = b2.b + b3.x.b + b3.y + b4.e;
+ result.y = b2.b + b3.x.b + b4.e;
+
+ printf("%d %d %d %d %d %d %d: %d %d %d\n", (int)b2.a, b2.b,
+ (int)b3.x.a, b3.x.b, b3.y, (int)b4.d, b4.e,
+ (int)result.x.a, result.x.b, result.y);
+
+ return result;
+}
+
+static void
+B_gn(ffi_cif* cif __UNUSED__, void* resp, void** args,
+ void* userdata __UNUSED__)
+{
+ struct A b0;
+ struct B b1;
+ struct C b2;
+
+ b0 = *(struct A*)(args[0]);
+ b1 = *(struct B*)(args[1]);
+ b2 = *(struct C*)(args[2]);
+
+ *(B*)resp = B_fn(b0, b1, b2);
+}
+
+int main (void)
+{
+ ffi_cif cif;
+ void *code;
+ ffi_closure *pcl = ffi_closure_alloc(sizeof(ffi_closure), &code);
+ void* args_dbl[4];
+ ffi_type* cls_struct_fields[3];
+ ffi_type* cls_struct_fields1[3];
+ ffi_type* cls_struct_fields2[3];
+ ffi_type cls_struct_type, cls_struct_type1, cls_struct_type2;
+ ffi_type* dbl_arg_types[4];
+
+ struct A e_dbl = { 1LL, 7};
+ struct B f_dbl = {{12LL , 127}, 99};
+ struct C g_dbl = { 2LL, 9};
+
+ struct B res_dbl;
+
+ cls_struct_type.size = 0;
+ cls_struct_type.alignment = 0;
+ cls_struct_type.type = FFI_TYPE_STRUCT;
+ cls_struct_type.elements = cls_struct_fields;
+
+ cls_struct_type1.size = 0;
+ cls_struct_type1.alignment = 0;
+ cls_struct_type1.type = FFI_TYPE_STRUCT;
+ cls_struct_type1.elements = cls_struct_fields1;
+
+ cls_struct_type2.size = 0;
+ cls_struct_type2.alignment = 0;
+ cls_struct_type2.type = FFI_TYPE_STRUCT;
+ cls_struct_type2.elements = cls_struct_fields2;
+
+ cls_struct_fields[0] = &ffi_type_uint64;
+ cls_struct_fields[1] = &ffi_type_uchar;
+ cls_struct_fields[2] = NULL;
+
+ cls_struct_fields1[0] = &cls_struct_type;
+ cls_struct_fields1[1] = &ffi_type_uchar;
+ cls_struct_fields1[2] = NULL;
+
+ cls_struct_fields2[0] = &ffi_type_uint64;
+ cls_struct_fields2[1] = &ffi_type_uchar;
+ cls_struct_fields2[2] = NULL;
+
+
+ dbl_arg_types[0] = &cls_struct_type;
+ dbl_arg_types[1] = &cls_struct_type1;
+ dbl_arg_types[2] = &cls_struct_type2;
+ dbl_arg_types[3] = NULL;
+
+ CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 3, &cls_struct_type1,
+ dbl_arg_types) == FFI_OK);
+
+ args_dbl[0] = &e_dbl;
+ args_dbl[1] = &f_dbl;
+ args_dbl[2] = &g_dbl;
+ args_dbl[3] = NULL;
+
+ ffi_call(&cif, FFI_FN(B_fn), &res_dbl, args_dbl);
+ /* { dg-output "1 7 12 127 99 2 9: 15 242 143" } */
+ CHECK( res_dbl.x.a == (e_dbl.a + f_dbl.x.a + g_dbl.d));
+ CHECK( res_dbl.x.b == (e_dbl.b + f_dbl.x.b + f_dbl.y + g_dbl.e));
+ CHECK( res_dbl.y == (e_dbl.b + f_dbl.x.b + g_dbl.e));
+
+ CHECK(ffi_prep_closure_loc(pcl, &cif, B_gn, NULL, code) == FFI_OK);
+
+ res_dbl = ((B(*)(A, B, C))(code))(e_dbl, f_dbl, g_dbl);
+ /* { dg-output "\n1 7 12 127 99 2 9: 15 242 143" } */
+ CHECK( res_dbl.x.a == (e_dbl.a + f_dbl.x.a + g_dbl.d));
+ CHECK( res_dbl.x.b == (e_dbl.b + f_dbl.x.b + f_dbl.y + g_dbl.e));
+ CHECK( res_dbl.y == (e_dbl.b + f_dbl.x.b + g_dbl.e));
+
+ exit(0);
+}
diff --git a/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/nested_struct9.c b/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/nested_struct9.c
new file mode 100644
index 0000000..5f7ac67
--- /dev/null
+++ b/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/nested_struct9.c
@@ -0,0 +1,131 @@
+/* Area: ffi_call, closure_call
+ Purpose: Check structure passing with different structure size.
+ Contains structs as parameter of the struct itself.
+ Sample taken from Alan Modras patch to src/prep_cif.c.
+ Limitations: none.
+ PR: none.
+ Originator: <andreast@gcc.gnu.org> 20051010 */
+
+/* { dg-do run } */
+#include "ffitest.h"
+
+typedef struct A {
+ unsigned char a;
+ unsigned long long b;
+} A;
+
+typedef struct B {
+ struct A x;
+ unsigned char y;
+} B;
+
+typedef struct C {
+ unsigned long d;
+ unsigned char e;
+} C;
+
+static B B_fn(struct A b2, struct B b3, struct C b4)
+{
+ struct B result;
+
+ result.x.a = b2.a + b3.x.a + b4.d;
+ result.x.b = b2.b + b3.x.b + b3.y + b4.e;
+ result.y = b2.b + b3.x.b + b4.e;
+
+ printf("%d %d %d %d %d %d %d: %d %d %d\n", b2.a, (int)b2.b,
+ b3.x.a, (int)b3.x.b, b3.y, (int)b4.d, b4.e,
+ result.x.a, (int)result.x.b, result.y);
+
+ return result;
+}
+
+static void
+B_gn(ffi_cif* cif __UNUSED__, void* resp, void** args,
+ void* userdata __UNUSED__)
+{
+ struct A b0;
+ struct B b1;
+ struct C b2;
+
+ b0 = *(struct A*)(args[0]);
+ b1 = *(struct B*)(args[1]);
+ b2 = *(struct C*)(args[2]);
+
+ *(B*)resp = B_fn(b0, b1, b2);
+}
+
+int main (void)
+{
+ ffi_cif cif;
+ void *code;
+ ffi_closure *pcl = ffi_closure_alloc(sizeof(ffi_closure), &code);
+ void* args_dbl[4];
+ ffi_type* cls_struct_fields[3];
+ ffi_type* cls_struct_fields1[3];
+ ffi_type* cls_struct_fields2[3];
+ ffi_type cls_struct_type, cls_struct_type1, cls_struct_type2;
+ ffi_type* dbl_arg_types[4];
+
+ struct A e_dbl = { 1, 7LL};
+ struct B f_dbl = {{12.0 , 127}, 99};
+ struct C g_dbl = { 2, 9};
+
+ struct B res_dbl;
+
+ cls_struct_type.size = 0;
+ cls_struct_type.alignment = 0;
+ cls_struct_type.type = FFI_TYPE_STRUCT;
+ cls_struct_type.elements = cls_struct_fields;
+
+ cls_struct_type1.size = 0;
+ cls_struct_type1.alignment = 0;
+ cls_struct_type1.type = FFI_TYPE_STRUCT;
+ cls_struct_type1.elements = cls_struct_fields1;
+
+ cls_struct_type2.size = 0;
+ cls_struct_type2.alignment = 0;
+ cls_struct_type2.type = FFI_TYPE_STRUCT;
+ cls_struct_type2.elements = cls_struct_fields2;
+
+ cls_struct_fields[0] = &ffi_type_uchar;
+ cls_struct_fields[1] = &ffi_type_uint64;
+ cls_struct_fields[2] = NULL;
+
+ cls_struct_fields1[0] = &cls_struct_type;
+ cls_struct_fields1[1] = &ffi_type_uchar;
+ cls_struct_fields1[2] = NULL;
+
+ cls_struct_fields2[0] = &ffi_type_ulong;
+ cls_struct_fields2[1] = &ffi_type_uchar;
+ cls_struct_fields2[2] = NULL;
+
+
+ dbl_arg_types[0] = &cls_struct_type;
+ dbl_arg_types[1] = &cls_struct_type1;
+ dbl_arg_types[2] = &cls_struct_type2;
+ dbl_arg_types[3] = NULL;
+
+ CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 3, &cls_struct_type1,
+ dbl_arg_types) == FFI_OK);
+
+ args_dbl[0] = &e_dbl;
+ args_dbl[1] = &f_dbl;
+ args_dbl[2] = &g_dbl;
+ args_dbl[3] = NULL;
+
+ ffi_call(&cif, FFI_FN(B_fn), &res_dbl, args_dbl);
+ /* { dg-output "1 7 12 127 99 2 9: 15 242 143" } */
+ CHECK( res_dbl.x.a == (e_dbl.a + f_dbl.x.a + g_dbl.d));
+ CHECK( res_dbl.x.b == (e_dbl.b + f_dbl.x.b + f_dbl.y + g_dbl.e));
+ CHECK( res_dbl.y == (e_dbl.b + f_dbl.x.b + g_dbl.e));
+
+ CHECK(ffi_prep_closure_loc(pcl, &cif, B_gn, NULL, code) == FFI_OK);
+
+ res_dbl = ((B(*)(A, B, C))(code))(e_dbl, f_dbl, g_dbl);
+ /* { dg-output "\n1 7 12 127 99 2 9: 15 242 143" } */
+ CHECK( res_dbl.x.a == (e_dbl.a + f_dbl.x.a + g_dbl.d));
+ CHECK( res_dbl.x.b == (e_dbl.b + f_dbl.x.b + f_dbl.y + g_dbl.e));
+ CHECK( res_dbl.y == (e_dbl.b + f_dbl.x.b + g_dbl.e));
+
+ exit(0);
+}
diff --git a/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/problem1.c b/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/problem1.c
new file mode 100644
index 0000000..6a91555
--- /dev/null
+++ b/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/problem1.c
@@ -0,0 +1,90 @@
+/* Area: ffi_call, closure_call
+ Purpose: Check structure passing with different structure size.
+ Limitations: none.
+ PR: none.
+ Originator: <andreast@gcc.gnu.org> 20030828 */
+
+/* { dg-do run } */
+#include "ffitest.h"
+
+typedef struct my_ffi_struct {
+ double a;
+ double b;
+ double c;
+} my_ffi_struct;
+
+my_ffi_struct callee(struct my_ffi_struct a1, struct my_ffi_struct a2)
+{
+ struct my_ffi_struct result;
+ result.a = a1.a + a2.a;
+ result.b = a1.b + a2.b;
+ result.c = a1.c + a2.c;
+
+
+ printf("%g %g %g %g %g %g: %g %g %g\n", a1.a, a1.b, a1.c,
+ a2.a, a2.b, a2.c, result.a, result.b, result.c);
+
+ return result;
+}
+
+void stub(ffi_cif* cif __UNUSED__, void* resp, void** args,
+ void* userdata __UNUSED__)
+{
+ struct my_ffi_struct a1;
+ struct my_ffi_struct a2;
+
+ a1 = *(struct my_ffi_struct*)(args[0]);
+ a2 = *(struct my_ffi_struct*)(args[1]);
+
+ *(my_ffi_struct *)resp = callee(a1, a2);
+}
+
+
+int main(void)
+{
+ ffi_type* my_ffi_struct_fields[4];
+ ffi_type my_ffi_struct_type;
+ ffi_cif cif;
+ void *code;
+ ffi_closure *pcl = ffi_closure_alloc(sizeof(ffi_closure), &code);
+ void* args[4];
+ ffi_type* arg_types[3];
+
+ struct my_ffi_struct g = { 1.0, 2.0, 3.0 };
+ struct my_ffi_struct f = { 1.0, 2.0, 3.0 };
+ struct my_ffi_struct res;
+
+ my_ffi_struct_type.size = 0;
+ my_ffi_struct_type.alignment = 0;
+ my_ffi_struct_type.type = FFI_TYPE_STRUCT;
+ my_ffi_struct_type.elements = my_ffi_struct_fields;
+
+ my_ffi_struct_fields[0] = &ffi_type_double;
+ my_ffi_struct_fields[1] = &ffi_type_double;
+ my_ffi_struct_fields[2] = &ffi_type_double;
+ my_ffi_struct_fields[3] = NULL;
+
+ arg_types[0] = &my_ffi_struct_type;
+ arg_types[1] = &my_ffi_struct_type;
+ arg_types[2] = NULL;
+
+ CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 2, &my_ffi_struct_type,
+ arg_types) == FFI_OK);
+
+ args[0] = &g;
+ args[1] = &f;
+ args[2] = NULL;
+ ffi_call(&cif, FFI_FN(callee), &res, args);
+ /* { dg-output "1 2 3 1 2 3: 2 4 6" } */
+ printf("res: %g %g %g\n", res.a, res.b, res.c);
+ /* { dg-output "\nres: 2 4 6" } */
+
+ CHECK(ffi_prep_closure_loc(pcl, &cif, stub, NULL, code) == FFI_OK);
+
+ res = ((my_ffi_struct(*)(struct my_ffi_struct, struct my_ffi_struct))(code))(g, f);
+ /* { dg-output "\n1 2 3 1 2 3: 2 4 6" } */
+ printf("res: %g %g %g\n", res.a, res.b, res.c);
+ /* { dg-output "\nres: 2 4 6" } */
+
+ exit(0);;
+}
diff --git a/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/promotion.c b/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/promotion.c
new file mode 100644
index 0000000..4456161
--- /dev/null
+++ b/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/promotion.c
@@ -0,0 +1,59 @@
+/* Area: ffi_call
+ Purpose: Promotion test.
+ Limitations: none.
+ PR: none.
+ Originator: From the original ffitest.c */
+
+/* { dg-do run } */
+#include "ffitest.h"
+static int promotion(signed char sc, signed short ss,
+ unsigned char uc, unsigned short us)
+{
+ int r = (int) sc + (int) ss + (int) uc + (int) us;
+
+ return r;
+}
+
+int main (void)
+{
+ ffi_cif cif;
+ ffi_type *args[MAX_ARGS];
+ void *values[MAX_ARGS];
+ ffi_arg rint;
+ signed char sc;
+ unsigned char uc;
+ signed short ss;
+ unsigned short us;
+ unsigned long ul;
+
+ args[0] = &ffi_type_schar;
+ args[1] = &ffi_type_sshort;
+ args[2] = &ffi_type_uchar;
+ args[3] = &ffi_type_ushort;
+ values[0] = &sc;
+ values[1] = &ss;
+ values[2] = &uc;
+ values[3] = &us;
+
+ /* Initialize the cif */
+ CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 4,
+ &ffi_type_sint, args) == FFI_OK);
+
+ us = 0;
+ ul = 0;
+
+ for (sc = (signed char) -127;
+ sc <= (signed char) 120; sc += 1)
+ for (ss = -30000; ss <= 30000; ss += 10000)
+ for (uc = (unsigned char) 0;
+ uc <= (unsigned char) 200; uc += 20)
+ for (us = 0; us <= 60000; us += 10000)
+ {
+ ul++;
+ ffi_call(&cif, FFI_FN(promotion), &rint, values);
+ CHECK((int)rint == (signed char) sc + (signed short) ss +
+ (unsigned char) uc + (unsigned short) us);
+ }
+ printf("%lu promotion tests run\n", ul);
+ exit(0);
+}
diff --git a/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/pyobjc-tc.c b/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/pyobjc-tc.c
new file mode 100644
index 0000000..e29bd6c
--- /dev/null
+++ b/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/pyobjc-tc.c
@@ -0,0 +1,114 @@
+/* Area: ffi_call
+ Purpose: Check different structures.
+ Limitations: none.
+ PR: none.
+ Originator: Ronald Oussoren <oussoren@cistron.nl> 20030824 */
+
+/* { dg-do run } */
+#include "ffitest.h"
+
+typedef struct Point {
+ float x;
+ float y;
+} Point;
+
+typedef struct Size {
+ float h;
+ float w;
+} Size;
+
+typedef struct Rect {
+ Point o;
+ Size s;
+} Rect;
+
+int doit(int o, char* s, Point p, Rect r, int last)
+{
+ printf("CALLED WITH %d %s {%f %f} {{%f %f} {%f %f}} %d\n",
+ o, s, p.x, p.y, r.o.x, r.o.y, r.s.h, r.s.w, last);
+ return 42;
+}
+
+
+int main(void)
+{
+ ffi_type point_type;
+ ffi_type size_type;
+ ffi_type rect_type;
+ ffi_cif cif;
+ ffi_type* arglist[6];
+ void* values[6];
+ int r;
+
+ /*
+ * First set up FFI types for the 3 struct types
+ */
+
+ point_type.size = 0; /*sizeof(Point);*/
+ point_type.alignment = 0; /*__alignof__(Point);*/
+ point_type.type = FFI_TYPE_STRUCT;
+ point_type.elements = malloc(3 * sizeof(ffi_type*));
+ point_type.elements[0] = &ffi_type_float;
+ point_type.elements[1] = &ffi_type_float;
+ point_type.elements[2] = NULL;
+
+ size_type.size = 0;/* sizeof(Size);*/
+ size_type.alignment = 0;/* __alignof__(Size);*/
+ size_type.type = FFI_TYPE_STRUCT;
+ size_type.elements = malloc(3 * sizeof(ffi_type*));
+ size_type.elements[0] = &ffi_type_float;
+ size_type.elements[1] = &ffi_type_float;
+ size_type.elements[2] = NULL;
+
+ rect_type.size = 0;/*sizeof(Rect);*/
+ rect_type.alignment =0;/* __alignof__(Rect);*/
+ rect_type.type = FFI_TYPE_STRUCT;
+ rect_type.elements = malloc(3 * sizeof(ffi_type*));
+ rect_type.elements[0] = &point_type;
+ rect_type.elements[1] = &size_type;
+ rect_type.elements[2] = NULL;
+
+ /*
+ * Create a CIF
+ */
+ arglist[0] = &ffi_type_sint;
+ arglist[1] = &ffi_type_pointer;
+ arglist[2] = &point_type;
+ arglist[3] = &rect_type;
+ arglist[4] = &ffi_type_sint;
+ arglist[5] = NULL;
+
+ r = ffi_prep_cif(&cif, FFI_DEFAULT_ABI,
+ 5, &ffi_type_sint, arglist);
+ if (r != FFI_OK) {
+ abort();
+ }
+
+
+ /* And call the function through the CIF */
+
+ {
+ Point p = { 1.0, 2.0 };
+ Rect r = { { 9.0, 10.0}, { -1.0, -2.0 } };
+ int o = 0;
+ int l = 42;
+ char* m = "myMethod";
+ ffi_arg result;
+
+ values[0] = &o;
+ values[1] = &m;
+ values[2] = &p;
+ values[3] = &r;
+ values[4] = &l;
+ values[5] = NULL;
+
+ printf("CALLING WITH %d %s {%f %f} {{%f %f} {%f %f}} %d\n",
+ o, m, p.x, p.y, r.o.x, r.o.y, r.s.h, r.s.w, l);
+
+ ffi_call(&cif, FFI_FN(doit), &result, values);
+
+ printf ("The result is %d\n", (int)result);
+
+ }
+ exit(0);
+}
diff --git a/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/return_dbl.c b/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/return_dbl.c
new file mode 100644
index 0000000..fd07e50
--- /dev/null
+++ b/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/return_dbl.c
@@ -0,0 +1,36 @@
+/* Area: ffi_call
+ Purpose: Check return value double.
+ Limitations: none.
+ PR: none.
+ Originator: <andreast@gcc.gnu.org> 20050212 */
+
+/* { dg-do run } */
+#include "ffitest.h"
+
+static double return_dbl(double dbl)
+{
+ printf ("%f\n", dbl);
+ return 2 * dbl;
+}
+int main (void)
+{
+ ffi_cif cif;
+ ffi_type *args[MAX_ARGS];
+ void *values[MAX_ARGS];
+ double dbl, rdbl;
+
+ args[0] = &ffi_type_double;
+ values[0] = &dbl;
+
+ /* Initialize the cif */
+ CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 1,
+ &ffi_type_double, args) == FFI_OK);
+
+ for (dbl = -127.3; dbl < 127; dbl++)
+ {
+ ffi_call(&cif, FFI_FN(return_dbl), &rdbl, values);
+ printf ("%f vs %f\n", rdbl, return_dbl(dbl));
+ CHECK(rdbl == 2 * dbl);
+ }
+ exit(0);
+}
diff --git a/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/return_dbl1.c b/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/return_dbl1.c
new file mode 100644
index 0000000..0ea5d50
--- /dev/null
+++ b/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/return_dbl1.c
@@ -0,0 +1,43 @@
+/* Area: ffi_call
+ Purpose: Check return value double.
+ Limitations: none.
+ PR: none.
+ Originator: <andreast@gcc.gnu.org> 20050212 */
+
+/* { dg-do run } */
+#include "ffitest.h"
+
+static double return_dbl(double dbl1, float fl2, unsigned int in3, double dbl4)
+{
+ return dbl1 + fl2 + in3 + dbl4;
+}
+int main (void)
+{
+ ffi_cif cif;
+ ffi_type *args[MAX_ARGS];
+ void *values[MAX_ARGS];
+ double dbl1, dbl4, rdbl;
+ float fl2;
+ unsigned int in3;
+ args[0] = &ffi_type_double;
+ args[1] = &ffi_type_float;
+ args[2] = &ffi_type_uint;
+ args[3] = &ffi_type_double;
+ values[0] = &dbl1;
+ values[1] = &fl2;
+ values[2] = &in3;
+ values[3] = &dbl4;
+
+ /* Initialize the cif */
+ CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 4,
+ &ffi_type_double, args) == FFI_OK);
+ dbl1 = 127.0;
+ fl2 = 128.0;
+ in3 = 255;
+ dbl4 = 512.7;
+
+ ffi_call(&cif, FFI_FN(return_dbl), &rdbl, values);
+ printf ("%f vs %f\n", rdbl, return_dbl(dbl1, fl2, in3, dbl4));
+ CHECK(rdbl == dbl1 + fl2 + in3 + dbl4);
+ exit(0);
+}
diff --git a/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/return_dbl2.c b/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/return_dbl2.c
new file mode 100644
index 0000000..b3818f8
--- /dev/null
+++ b/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/return_dbl2.c
@@ -0,0 +1,42 @@
+/* Area: ffi_call
+ Purpose: Check return value double.
+ Limitations: none.
+ PR: none.
+ Originator: <andreast@gcc.gnu.org> 20050212 */
+
+/* { dg-do run } */
+#include "ffitest.h"
+
+static double return_dbl(double dbl1, double dbl2, unsigned int in3, double dbl4)
+{
+ return dbl1 + dbl2 + in3 + dbl4;
+}
+int main (void)
+{
+ ffi_cif cif;
+ ffi_type *args[MAX_ARGS];
+ void *values[MAX_ARGS];
+ double dbl1, dbl2, dbl4, rdbl;
+ unsigned int in3;
+ args[0] = &ffi_type_double;
+ args[1] = &ffi_type_double;
+ args[2] = &ffi_type_uint;
+ args[3] = &ffi_type_double;
+ values[0] = &dbl1;
+ values[1] = &dbl2;
+ values[2] = &in3;
+ values[3] = &dbl4;
+
+ /* Initialize the cif */
+ CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 4,
+ &ffi_type_double, args) == FFI_OK);
+ dbl1 = 127.0;
+ dbl2 = 128.0;
+ in3 = 255;
+ dbl4 = 512.7;
+
+ ffi_call(&cif, FFI_FN(return_dbl), &rdbl, values);
+ printf ("%f vs %f\n", rdbl, return_dbl(dbl1, dbl2, in3, dbl4));
+ CHECK(rdbl == dbl1 + dbl2 + in3 + dbl4);
+ exit(0);
+}
diff --git a/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/return_fl.c b/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/return_fl.c
new file mode 100644
index 0000000..fb8a09e
--- /dev/null
+++ b/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/return_fl.c
@@ -0,0 +1,35 @@
+/* Area: ffi_call
+ Purpose: Check return value float.
+ Limitations: none.
+ PR: none.
+ Originator: <andreast@gcc.gnu.org> 20050212 */
+
+/* { dg-do run } */
+#include "ffitest.h"
+
+static float return_fl(float fl)
+{
+ return 2 * fl;
+}
+int main (void)
+{
+ ffi_cif cif;
+ ffi_type *args[MAX_ARGS];
+ void *values[MAX_ARGS];
+ float fl, rfl;
+
+ args[0] = &ffi_type_float;
+ values[0] = &fl;
+
+ /* Initialize the cif */
+ CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 1,
+ &ffi_type_float, args) == FFI_OK);
+
+ for (fl = -127.0; fl < 127; fl++)
+ {
+ ffi_call(&cif, FFI_FN(return_fl), &rfl, values);
+ printf ("%f vs %f\n", rfl, return_fl(fl));
+ CHECK(rfl == 2 * fl);
+ }
+ exit(0);
+}
diff --git a/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/return_fl1.c b/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/return_fl1.c
new file mode 100644
index 0000000..c3d92c2
--- /dev/null
+++ b/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/return_fl1.c
@@ -0,0 +1,36 @@
+/* Area: ffi_call
+ Purpose: Check return value float.
+ Limitations: none.
+ PR: none.
+ Originator: <andreast@gcc.gnu.org> 20050212 */
+
+/* { dg-do run } */
+#include "ffitest.h"
+
+static float return_fl(float fl1, float fl2)
+{
+ return fl1 + fl2;
+}
+int main (void)
+{
+ ffi_cif cif;
+ ffi_type *args[MAX_ARGS];
+ void *values[MAX_ARGS];
+ float fl1, fl2, rfl;
+
+ args[0] = &ffi_type_float;
+ args[1] = &ffi_type_float;
+ values[0] = &fl1;
+ values[1] = &fl2;
+
+ /* Initialize the cif */
+ CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 2,
+ &ffi_type_float, args) == FFI_OK);
+ fl1 = 127.0;
+ fl2 = 128.0;
+
+ ffi_call(&cif, FFI_FN(return_fl), &rfl, values);
+ printf ("%f vs %f\n", rfl, return_fl(fl1, fl2));
+ CHECK(rfl == fl1 + fl2);
+ exit(0);
+}
diff --git a/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/return_fl2.c b/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/return_fl2.c
new file mode 100644
index 0000000..ddb976c
--- /dev/null
+++ b/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/return_fl2.c
@@ -0,0 +1,49 @@
+/* Area: ffi_call
+ Purpose: Check return value float.
+ Limitations: none.
+ PR: none.
+ Originator: <andreast@gcc.gnu.org> 20050212 */
+
+/* { dg-do run } */
+#include "ffitest.h"
+
+/* Use volatile float to avoid false negative on ix86. See PR target/323. */
+static float return_fl(float fl1, float fl2, float fl3, float fl4)
+{
+ volatile float sum;
+
+ sum = fl1 + fl2 + fl3 + fl4;
+ return sum;
+}
+int main (void)
+{
+ ffi_cif cif;
+ ffi_type *args[MAX_ARGS];
+ void *values[MAX_ARGS];
+ float fl1, fl2, fl3, fl4, rfl;
+ volatile float sum;
+
+ args[0] = &ffi_type_float;
+ args[1] = &ffi_type_float;
+ args[2] = &ffi_type_float;
+ args[3] = &ffi_type_float;
+ values[0] = &fl1;
+ values[1] = &fl2;
+ values[2] = &fl3;
+ values[3] = &fl4;
+
+ /* Initialize the cif */
+ CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 4,
+ &ffi_type_float, args) == FFI_OK);
+ fl1 = 127.0;
+ fl2 = 128.0;
+ fl3 = 255.1;
+ fl4 = 512.7;
+
+ ffi_call(&cif, FFI_FN(return_fl), &rfl, values);
+ printf ("%f vs %f\n", rfl, return_fl(fl1, fl2, fl3, fl4));
+
+ sum = fl1 + fl2 + fl3 + fl4;
+ CHECK(rfl == sum);
+ exit(0);
+}
diff --git a/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/return_fl3.c b/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/return_fl3.c
new file mode 100644
index 0000000..c37877b
--- /dev/null
+++ b/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/return_fl3.c
@@ -0,0 +1,42 @@
+/* Area: ffi_call
+ Purpose: Check return value float.
+ Limitations: none.
+ PR: none.
+ Originator: <andreast@gcc.gnu.org> 20050212 */
+
+/* { dg-do run } */
+#include "ffitest.h"
+
+static float return_fl(float fl1, float fl2, unsigned int in3, float fl4)
+{
+ return fl1 + fl2 + in3 + fl4;
+}
+int main (void)
+{
+ ffi_cif cif;
+ ffi_type *args[MAX_ARGS];
+ void *values[MAX_ARGS];
+ float fl1, fl2, fl4, rfl;
+ unsigned int in3;
+ args[0] = &ffi_type_float;
+ args[1] = &ffi_type_float;
+ args[2] = &ffi_type_uint;
+ args[3] = &ffi_type_float;
+ values[0] = &fl1;
+ values[1] = &fl2;
+ values[2] = &in3;
+ values[3] = &fl4;
+
+ /* Initialize the cif */
+ CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 4,
+ &ffi_type_float, args) == FFI_OK);
+ fl1 = 127.0;
+ fl2 = 128.0;
+ in3 = 255;
+ fl4 = 512.7;
+
+ ffi_call(&cif, FFI_FN(return_fl), &rfl, values);
+ printf ("%f vs %f\n", rfl, return_fl(fl1, fl2, in3, fl4));
+ CHECK(rfl == fl1 + fl2 + in3 + fl4);
+ exit(0);
+}
diff --git a/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/return_ldl.c b/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/return_ldl.c
new file mode 100644
index 0000000..5c2fe65
--- /dev/null
+++ b/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/return_ldl.c
@@ -0,0 +1,34 @@
+/* Area: ffi_call
+ Purpose: Check return value long double.
+ Limitations: none.
+ PR: none.
+ Originator: <andreast@gcc.gnu.org> 20071113 */
+
+/* { dg-do run { xfail x86_64-*-mingw* x86_64-*-cygwin* } } */
+#include "ffitest.h"
+
+static long double return_ldl(long double ldl)
+{
+ return 2*ldl;
+}
+int main (void)
+{
+ ffi_cif cif;
+ ffi_type *args[MAX_ARGS];
+ void *values[MAX_ARGS];
+ long double ldl, rldl;
+
+ args[0] = &ffi_type_longdouble;
+ values[0] = &ldl;
+
+ /* Initialize the cif */
+ CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 1,
+ &ffi_type_longdouble, args) == FFI_OK);
+
+ for (ldl = -127.0; ldl < 127.0; ldl++)
+ {
+ ffi_call(&cif, FFI_FN(return_ldl), &rldl, values);
+ CHECK(rldl == 2 * ldl);
+ }
+ exit(0);
+}
diff --git a/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/return_ll.c b/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/return_ll.c
new file mode 100644
index 0000000..ea4a1e4
--- /dev/null
+++ b/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/return_ll.c
@@ -0,0 +1,41 @@
+/* Area: ffi_call
+ Purpose: Check return value long long.
+ Limitations: none.
+ PR: none.
+ Originator: From the original ffitest.c */
+
+/* { dg-do run } */
+#include "ffitest.h"
+static long long return_ll(long long ll)
+{
+ return ll;
+}
+
+int main (void)
+{
+ ffi_cif cif;
+ ffi_type *args[MAX_ARGS];
+ void *values[MAX_ARGS];
+ long long rlonglong;
+ long long ll;
+
+ args[0] = &ffi_type_sint64;
+ values[0] = &ll;
+
+ /* Initialize the cif */
+ CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 1,
+ &ffi_type_sint64, args) == FFI_OK);
+
+ for (ll = 0LL; ll < 100LL; ll++)
+ {
+ ffi_call(&cif, FFI_FN(return_ll), &rlonglong, values);
+ CHECK(rlonglong == ll);
+ }
+
+ for (ll = 55555555555000LL; ll < 55555555555100LL; ll++)
+ {
+ ffi_call(&cif, FFI_FN(return_ll), &rlonglong, values);
+ CHECK(rlonglong == ll);
+ }
+ exit(0);
+}
diff --git a/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/return_ll1.c b/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/return_ll1.c
new file mode 100644
index 0000000..593e8a3
--- /dev/null
+++ b/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/return_ll1.c
@@ -0,0 +1,43 @@
+/* Area: ffi_call
+ Purpose: Check if long long are passed in the corresponding regs on ppc.
+ Limitations: none.
+ PR: 20104.
+ Originator: <andreast@gcc.gnu.org> 20050222 */
+
+/* { dg-do run } */
+/* { dg-options "-Wno-format" { target alpha*-dec-osf* } } */
+#include "ffitest.h"
+static long long return_ll(int ll0, long long ll1, int ll2)
+{
+ return ll0 + ll1 + ll2;
+}
+
+int main (void)
+{
+ ffi_cif cif;
+ ffi_type *args[MAX_ARGS];
+ void *values[MAX_ARGS];
+ long long rlonglong;
+ long long ll1;
+ unsigned ll0, ll2;
+
+ args[0] = &ffi_type_sint;
+ args[1] = &ffi_type_sint64;
+ args[2] = &ffi_type_sint;
+ values[0] = &ll0;
+ values[1] = &ll1;
+ values[2] = &ll2;
+
+ /* Initialize the cif */
+ CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 3,
+ &ffi_type_sint64, args) == FFI_OK);
+
+ ll0 = 11111111;
+ ll1 = 11111111111000LL;
+ ll2 = 11111111;
+
+ ffi_call(&cif, FFI_FN(return_ll), &rlonglong, values);
+ printf("res: %" PRIdLL ", %" PRIdLL "\n", rlonglong, ll0 + ll1 + ll2);
+ /* { dg-output "res: 11111133333222, 11111133333222" } */
+ exit(0);
+}
diff --git a/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/return_sc.c b/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/return_sc.c
new file mode 100644
index 0000000..a36cf3e
--- /dev/null
+++ b/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/return_sc.c
@@ -0,0 +1,36 @@
+/* Area: ffi_call
+ Purpose: Check return value signed char.
+ Limitations: none.
+ PR: none.
+ Originator: From the original ffitest.c */
+
+/* { dg-do run } */
+#include "ffitest.h"
+
+static signed char return_sc(signed char sc)
+{
+ return sc;
+}
+int main (void)
+{
+ ffi_cif cif;
+ ffi_type *args[MAX_ARGS];
+ void *values[MAX_ARGS];
+ ffi_arg rint;
+ signed char sc;
+
+ args[0] = &ffi_type_schar;
+ values[0] = &sc;
+
+ /* Initialize the cif */
+ CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 1,
+ &ffi_type_schar, args) == FFI_OK);
+
+ for (sc = (signed char) -127;
+ sc < (signed char) 127; sc++)
+ {
+ ffi_call(&cif, FFI_FN(return_sc), &rint, values);
+ CHECK((signed char)rint == sc);
+ }
+ exit(0);
+}
diff --git a/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/return_sl.c b/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/return_sl.c
new file mode 100644
index 0000000..f0fd345
--- /dev/null
+++ b/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/return_sl.c
@@ -0,0 +1,38 @@
+/* Area: ffi_call
+ Purpose: Check if long as return type is handled correctly.
+ Limitations: none.
+ PR: none.
+ */
+
+/* { dg-do run } */
+#include "ffitest.h"
+static long return_sl(long l1, long l2)
+{
+ return l1 - l2;
+}
+
+int main (void)
+{
+ ffi_cif cif;
+ ffi_type *args[MAX_ARGS];
+ void *values[MAX_ARGS];
+ ffi_arg res;
+ unsigned long l1, l2;
+
+ args[0] = &ffi_type_slong;
+ args[1] = &ffi_type_slong;
+ values[0] = &l1;
+ values[1] = &l2;
+
+ CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 2,
+ &ffi_type_slong, args) == FFI_OK);
+
+ l1 = 1073741823L;
+ l2 = 1073741824L;
+
+ ffi_call(&cif, FFI_FN(return_sl), &res, values);
+ printf("res: %ld, %ld\n", (long)res, l1 - l2);
+ /* { dg-output "res: -1, -1" } */
+
+ exit(0);
+}
diff --git a/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/return_uc.c b/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/return_uc.c
new file mode 100644
index 0000000..6fe5546
--- /dev/null
+++ b/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/return_uc.c
@@ -0,0 +1,38 @@
+/* Area: ffi_call
+ Purpose: Check return value unsigned char.
+ Limitations: none.
+ PR: none.
+ Originator: From the original ffitest.c */
+
+/* { dg-do run } */
+#include "ffitest.h"
+
+static unsigned char return_uc(unsigned char uc)
+{
+ return uc;
+}
+
+int main (void)
+{
+ ffi_cif cif;
+ ffi_type *args[MAX_ARGS];
+ void *values[MAX_ARGS];
+ ffi_arg rint;
+
+ unsigned char uc;
+
+ args[0] = &ffi_type_uchar;
+ values[0] = &uc;
+
+ /* Initialize the cif */
+ CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 1,
+ &ffi_type_uchar, args) == FFI_OK);
+
+ for (uc = (unsigned char) '\x00';
+ uc < (unsigned char) '\xff'; uc++)
+ {
+ ffi_call(&cif, FFI_FN(return_uc), &rint, values);
+ CHECK((unsigned char)rint == uc);
+ }
+ exit(0);
+}
diff --git a/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/return_ul.c b/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/return_ul.c
new file mode 100644
index 0000000..12b266f
--- /dev/null
+++ b/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/return_ul.c
@@ -0,0 +1,38 @@
+/* Area: ffi_call
+ Purpose: Check if unsigned long as return type is handled correctly.
+ Limitations: none.
+ PR: none.
+ Originator: <kaffeetisch at gmx dot de> 20060724 */
+
+/* { dg-do run } */
+#include "ffitest.h"
+static unsigned long return_ul(unsigned long ul1, unsigned long ul2)
+{
+ return ul1 + ul2;
+}
+
+int main (void)
+{
+ ffi_cif cif;
+ ffi_type *args[MAX_ARGS];
+ void *values[MAX_ARGS];
+ ffi_arg res;
+ unsigned long ul1, ul2;
+
+ args[0] = &ffi_type_ulong;
+ args[1] = &ffi_type_ulong;
+ values[0] = &ul1;
+ values[1] = &ul2;
+
+ CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 2,
+ &ffi_type_ulong, args) == FFI_OK);
+
+ ul1 = 1073741823L;
+ ul2 = 1073741824L;
+
+ ffi_call(&cif, FFI_FN(return_ul), &res, values);
+ printf("res: %lu, %lu\n", (unsigned long)res, ul1 + ul2);
+ /* { dg-output "res: 2147483647, 2147483647" } */
+
+ exit(0);
+}
diff --git a/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/stret_large.c b/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/stret_large.c
new file mode 100644
index 0000000..71c2469
--- /dev/null
+++ b/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/stret_large.c
@@ -0,0 +1,145 @@
+/* Area: ffi_call, closure_call
+ Purpose: Check structure returning with different structure size.
+ Depending on the ABI. Check bigger struct which overlaps
+ the gp and fp register count on Darwin/AIX/ppc64.
+ Limitations: none.
+ PR: none.
+ Originator: Blake Chaffin 6/21/2007 */
+
+/* { dg-do run { xfail strongarm*-*-* xscale*-*-* } } */
+#include "ffitest.h"
+
+/* 13 FPRs: 104 bytes */
+/* 14 FPRs: 112 bytes */
+
+typedef struct struct_108byte {
+ double a;
+ double b;
+ double c;
+ double d;
+ double e;
+ double f;
+ double g;
+ double h;
+ double i;
+ double j;
+ double k;
+ double l;
+ double m;
+ int n;
+} struct_108byte;
+
+struct_108byte cls_struct_108byte_fn(
+ struct_108byte b0,
+ struct_108byte b1,
+ struct_108byte b2,
+ struct_108byte b3)
+{
+ struct_108byte result;
+
+ result.a = b0.a + b1.a + b2.a + b3.a;
+ result.b = b0.b + b1.b + b2.b + b3.b;
+ result.c = b0.c + b1.c + b2.c + b3.c;
+ result.d = b0.d + b1.d + b2.d + b3.d;
+ result.e = b0.e + b1.e + b2.e + b3.e;
+ result.f = b0.f + b1.f + b2.f + b3.f;
+ result.g = b0.g + b1.g + b2.g + b3.g;
+ result.h = b0.h + b1.h + b2.h + b3.h;
+ result.i = b0.i + b1.i + b2.i + b3.i;
+ result.j = b0.j + b1.j + b2.j + b3.j;
+ result.k = b0.k + b1.k + b2.k + b3.k;
+ result.l = b0.l + b1.l + b2.l + b3.l;
+ result.m = b0.m + b1.m + b2.m + b3.m;
+ result.n = b0.n + b1.n + b2.n + b3.n;
+
+ printf("%g %g %g %g %g %g %g %g %g %g %g %g %g %d\n", result.a, result.b, result.c,
+ result.d, result.e, result.f, result.g, result.h, result.i,
+ result.j, result.k, result.l, result.m, result.n);
+
+ return result;
+}
+
+static void
+cls_struct_108byte_gn(ffi_cif* cif __UNUSED__, void* resp, void** args, void* userdata __UNUSED__)
+{
+ struct_108byte b0, b1, b2, b3;
+
+ b0 = *(struct_108byte*)(args[0]);
+ b1 = *(struct_108byte*)(args[1]);
+ b2 = *(struct_108byte*)(args[2]);
+ b3 = *(struct_108byte*)(args[3]);
+
+ *(struct_108byte*)resp = cls_struct_108byte_fn(b0, b1, b2, b3);
+}
+
+int main (void)
+{
+ ffi_cif cif;
+ void *code;
+ ffi_closure *pcl = ffi_closure_alloc(sizeof(ffi_closure), &code);
+ void* args_dbl[5];
+ ffi_type* cls_struct_fields[15];
+ ffi_type cls_struct_type;
+ ffi_type* dbl_arg_types[5];
+
+ struct_108byte e_dbl = { 9.0, 2.0, 6.0, 5.0, 3.0, 4.0, 8.0, 1.0, 1.0, 2.0, 3.0, 7.0, 2.0, 7 };
+ struct_108byte f_dbl = { 1.0, 2.0, 3.0, 7.0, 2.0, 5.0, 6.0, 7.0, 4.0, 5.0, 7.0, 9.0, 1.0, 4 };
+ struct_108byte g_dbl = { 4.0, 5.0, 7.0, 9.0, 1.0, 1.0, 2.0, 9.0, 8.0, 6.0, 1.0, 4.0, 0.0, 3 };
+ struct_108byte h_dbl = { 8.0, 6.0, 1.0, 4.0, 0.0, 3.0, 3.0, 1.0, 9.0, 2.0, 6.0, 5.0, 3.0, 2 };
+ struct_108byte res_dbl;
+
+ cls_struct_type.size = 0;
+ cls_struct_type.alignment = 0;
+ cls_struct_type.type = FFI_TYPE_STRUCT;
+ cls_struct_type.elements = cls_struct_fields;
+
+ cls_struct_fields[0] = &ffi_type_double;
+ cls_struct_fields[1] = &ffi_type_double;
+ cls_struct_fields[2] = &ffi_type_double;
+ cls_struct_fields[3] = &ffi_type_double;
+ cls_struct_fields[4] = &ffi_type_double;
+ cls_struct_fields[5] = &ffi_type_double;
+ cls_struct_fields[6] = &ffi_type_double;
+ cls_struct_fields[7] = &ffi_type_double;
+ cls_struct_fields[8] = &ffi_type_double;
+ cls_struct_fields[9] = &ffi_type_double;
+ cls_struct_fields[10] = &ffi_type_double;
+ cls_struct_fields[11] = &ffi_type_double;
+ cls_struct_fields[12] = &ffi_type_double;
+ cls_struct_fields[13] = &ffi_type_sint32;
+ cls_struct_fields[14] = NULL;
+
+ dbl_arg_types[0] = &cls_struct_type;
+ dbl_arg_types[1] = &cls_struct_type;
+ dbl_arg_types[2] = &cls_struct_type;
+ dbl_arg_types[3] = &cls_struct_type;
+ dbl_arg_types[4] = NULL;
+
+ CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 4, &cls_struct_type,
+ dbl_arg_types) == FFI_OK);
+
+ args_dbl[0] = &e_dbl;
+ args_dbl[1] = &f_dbl;
+ args_dbl[2] = &g_dbl;
+ args_dbl[3] = &h_dbl;
+ args_dbl[4] = NULL;
+
+ ffi_call(&cif, FFI_FN(cls_struct_108byte_fn), &res_dbl, args_dbl);
+ /* { dg-output "22 15 17 25 6 13 19 18 22 15 17 25 6 16" } */
+ printf("res: %g %g %g %g %g %g %g %g %g %g %g %g %g %d\n", res_dbl.a, res_dbl.b,
+ res_dbl.c, res_dbl.d, res_dbl.e, res_dbl.f, res_dbl.g, res_dbl.h, res_dbl.i,
+ res_dbl.j, res_dbl.k, res_dbl.l, res_dbl.m, res_dbl.n);
+ /* { dg-output "\nres: 22 15 17 25 6 13 19 18 22 15 17 25 6 16" } */
+
+ CHECK(ffi_prep_closure_loc(pcl, &cif, cls_struct_108byte_gn, NULL, code) == FFI_OK);
+
+ res_dbl = ((struct_108byte(*)(struct_108byte, struct_108byte,
+ struct_108byte, struct_108byte))(code))(e_dbl, f_dbl, g_dbl, h_dbl);
+ /* { dg-output "\n22 15 17 25 6 13 19 18 22 15 17 25 6 16" } */
+ printf("res: %g %g %g %g %g %g %g %g %g %g %g %g %g %d\n", res_dbl.a, res_dbl.b,
+ res_dbl.c, res_dbl.d, res_dbl.e, res_dbl.f, res_dbl.g, res_dbl.h, res_dbl.i,
+ res_dbl.j, res_dbl.k, res_dbl.l, res_dbl.m, res_dbl.n);
+ /* { dg-output "\nres: 22 15 17 25 6 13 19 18 22 15 17 25 6 16" } */
+
+ exit(0);
+}
diff --git a/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/stret_large2.c b/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/stret_large2.c
new file mode 100644
index 0000000..d9c750e
--- /dev/null
+++ b/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/stret_large2.c
@@ -0,0 +1,148 @@
+/* Area: ffi_call, closure_call
+ Purpose: Check structure returning with different structure size.
+ Depending on the ABI. Check bigger struct which overlaps
+ the gp and fp register count on Darwin/AIX/ppc64.
+ Limitations: none.
+ PR: none.
+ Originator: Blake Chaffin 6/21/2007 */
+
+/* { dg-do run { xfail strongarm*-*-* xscale*-*-* } } */
+#include "ffitest.h"
+
+/* 13 FPRs: 104 bytes */
+/* 14 FPRs: 112 bytes */
+
+typedef struct struct_116byte {
+ double a;
+ double b;
+ double c;
+ double d;
+ double e;
+ double f;
+ double g;
+ double h;
+ double i;
+ double j;
+ double k;
+ double l;
+ double m;
+ double n;
+ int o;
+} struct_116byte;
+
+struct_116byte cls_struct_116byte_fn(
+ struct_116byte b0,
+ struct_116byte b1,
+ struct_116byte b2,
+ struct_116byte b3)
+{
+ struct_116byte result;
+
+ result.a = b0.a + b1.a + b2.a + b3.a;
+ result.b = b0.b + b1.b + b2.b + b3.b;
+ result.c = b0.c + b1.c + b2.c + b3.c;
+ result.d = b0.d + b1.d + b2.d + b3.d;
+ result.e = b0.e + b1.e + b2.e + b3.e;
+ result.f = b0.f + b1.f + b2.f + b3.f;
+ result.g = b0.g + b1.g + b2.g + b3.g;
+ result.h = b0.h + b1.h + b2.h + b3.h;
+ result.i = b0.i + b1.i + b2.i + b3.i;
+ result.j = b0.j + b1.j + b2.j + b3.j;
+ result.k = b0.k + b1.k + b2.k + b3.k;
+ result.l = b0.l + b1.l + b2.l + b3.l;
+ result.m = b0.m + b1.m + b2.m + b3.m;
+ result.n = b0.n + b1.n + b2.n + b3.n;
+ result.o = b0.o + b1.o + b2.o + b3.o;
+
+ printf("%g %g %g %g %g %g %g %g %g %g %g %g %g %g %d\n", result.a, result.b, result.c,
+ result.d, result.e, result.f, result.g, result.h, result.i,
+ result.j, result.k, result.l, result.m, result.n, result.o);
+
+ return result;
+}
+
+static void
+cls_struct_116byte_gn(ffi_cif* cif __UNUSED__, void* resp, void** args, void* userdata __UNUSED__)
+{
+ struct_116byte b0, b1, b2, b3;
+
+ b0 = *(struct_116byte*)(args[0]);
+ b1 = *(struct_116byte*)(args[1]);
+ b2 = *(struct_116byte*)(args[2]);
+ b3 = *(struct_116byte*)(args[3]);
+
+ *(struct_116byte*)resp = cls_struct_116byte_fn(b0, b1, b2, b3);
+}
+
+int main (void)
+{
+ ffi_cif cif;
+ void *code;
+ ffi_closure *pcl = ffi_closure_alloc(sizeof(ffi_closure), &code);
+ void* args_dbl[5];
+ ffi_type* cls_struct_fields[16];
+ ffi_type cls_struct_type;
+ ffi_type* dbl_arg_types[5];
+
+ struct_116byte e_dbl = { 9.0, 2.0, 6.0, 5.0, 3.0, 4.0, 8.0, 1.0, 1.0, 2.0, 3.0, 7.0, 2.0, 5.0, 7 };
+ struct_116byte f_dbl = { 1.0, 2.0, 3.0, 7.0, 2.0, 5.0, 6.0, 7.0, 4.0, 5.0, 7.0, 9.0, 1.0, 6.0, 4 };
+ struct_116byte g_dbl = { 4.0, 5.0, 7.0, 9.0, 1.0, 1.0, 2.0, 9.0, 8.0, 6.0, 1.0, 4.0, 0.0, 7.0, 3 };
+ struct_116byte h_dbl = { 8.0, 6.0, 1.0, 4.0, 0.0, 3.0, 3.0, 1.0, 9.0, 2.0, 6.0, 5.0, 3.0, 8.0, 2 };
+ struct_116byte res_dbl;
+
+ cls_struct_type.size = 0;
+ cls_struct_type.alignment = 0;
+ cls_struct_type.type = FFI_TYPE_STRUCT;
+ cls_struct_type.elements = cls_struct_fields;
+
+ cls_struct_fields[0] = &ffi_type_double;
+ cls_struct_fields[1] = &ffi_type_double;
+ cls_struct_fields[2] = &ffi_type_double;
+ cls_struct_fields[3] = &ffi_type_double;
+ cls_struct_fields[4] = &ffi_type_double;
+ cls_struct_fields[5] = &ffi_type_double;
+ cls_struct_fields[6] = &ffi_type_double;
+ cls_struct_fields[7] = &ffi_type_double;
+ cls_struct_fields[8] = &ffi_type_double;
+ cls_struct_fields[9] = &ffi_type_double;
+ cls_struct_fields[10] = &ffi_type_double;
+ cls_struct_fields[11] = &ffi_type_double;
+ cls_struct_fields[12] = &ffi_type_double;
+ cls_struct_fields[13] = &ffi_type_double;
+ cls_struct_fields[14] = &ffi_type_sint32;
+ cls_struct_fields[15] = NULL;
+
+ dbl_arg_types[0] = &cls_struct_type;
+ dbl_arg_types[1] = &cls_struct_type;
+ dbl_arg_types[2] = &cls_struct_type;
+ dbl_arg_types[3] = &cls_struct_type;
+ dbl_arg_types[4] = NULL;
+
+ CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 4, &cls_struct_type,
+ dbl_arg_types) == FFI_OK);
+
+ args_dbl[0] = &e_dbl;
+ args_dbl[1] = &f_dbl;
+ args_dbl[2] = &g_dbl;
+ args_dbl[3] = &h_dbl;
+ args_dbl[4] = NULL;
+
+ ffi_call(&cif, FFI_FN(cls_struct_116byte_fn), &res_dbl, args_dbl);
+ /* { dg-output "22 15 17 25 6 13 19 18 22 15 17 25 6 26 16" } */
+ printf("res: %g %g %g %g %g %g %g %g %g %g %g %g %g %g %d\n", res_dbl.a, res_dbl.b,
+ res_dbl.c, res_dbl.d, res_dbl.e, res_dbl.f, res_dbl.g, res_dbl.h, res_dbl.i,
+ res_dbl.j, res_dbl.k, res_dbl.l, res_dbl.m, res_dbl.n, res_dbl.o);
+ /* { dg-output "\nres: 22 15 17 25 6 13 19 18 22 15 17 25 6 26 16" } */
+
+ CHECK(ffi_prep_closure_loc(pcl, &cif, cls_struct_116byte_gn, NULL, code) == FFI_OK);
+
+ res_dbl = ((struct_116byte(*)(struct_116byte, struct_116byte,
+ struct_116byte, struct_116byte))(code))(e_dbl, f_dbl, g_dbl, h_dbl);
+ /* { dg-output "\n22 15 17 25 6 13 19 18 22 15 17 25 6 26 16" } */
+ printf("res: %g %g %g %g %g %g %g %g %g %g %g %g %g %g %d\n", res_dbl.a, res_dbl.b,
+ res_dbl.c, res_dbl.d, res_dbl.e, res_dbl.f, res_dbl.g, res_dbl.h, res_dbl.i,
+ res_dbl.j, res_dbl.k, res_dbl.l, res_dbl.m, res_dbl.n, res_dbl.o);
+ /* { dg-output "\nres: 22 15 17 25 6 13 19 18 22 15 17 25 6 26 16" } */
+
+ exit(0);
+}
diff --git a/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/stret_medium.c b/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/stret_medium.c
new file mode 100644
index 0000000..973ee02
--- /dev/null
+++ b/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/stret_medium.c
@@ -0,0 +1,124 @@
+/* Area: ffi_call, closure_call
+ Purpose: Check structure returning with different structure size.
+ Depending on the ABI. Check bigger struct which overlaps
+ the gp and fp register count on Darwin/AIX/ppc64.
+ Limitations: none.
+ PR: none.
+ Originator: Blake Chaffin 6/21/2007 */
+
+/* { dg-do run { xfail strongarm*-*-* xscale*-*-* } } */
+#include "ffitest.h"
+
+typedef struct struct_72byte {
+ double a;
+ double b;
+ double c;
+ double d;
+ double e;
+ double f;
+ double g;
+ double h;
+ double i;
+} struct_72byte;
+
+struct_72byte cls_struct_72byte_fn(
+ struct_72byte b0,
+ struct_72byte b1,
+ struct_72byte b2,
+ struct_72byte b3)
+{
+ struct_72byte result;
+
+ result.a = b0.a + b1.a + b2.a + b3.a;
+ result.b = b0.b + b1.b + b2.b + b3.b;
+ result.c = b0.c + b1.c + b2.c + b3.c;
+ result.d = b0.d + b1.d + b2.d + b3.d;
+ result.e = b0.e + b1.e + b2.e + b3.e;
+ result.f = b0.f + b1.f + b2.f + b3.f;
+ result.g = b0.g + b1.g + b2.g + b3.g;
+ result.h = b0.h + b1.h + b2.h + b3.h;
+ result.i = b0.i + b1.i + b2.i + b3.i;
+
+ printf("%g %g %g %g %g %g %g %g %g\n", result.a, result.b, result.c,
+ result.d, result.e, result.f, result.g, result.h, result.i);
+
+ return result;
+}
+
+static void
+cls_struct_72byte_gn(ffi_cif* cif __UNUSED__, void* resp, void** args, void* userdata __UNUSED__)
+{
+ struct_72byte b0, b1, b2, b3;
+
+ b0 = *(struct_72byte*)(args[0]);
+ b1 = *(struct_72byte*)(args[1]);
+ b2 = *(struct_72byte*)(args[2]);
+ b3 = *(struct_72byte*)(args[3]);
+
+ *(struct_72byte*)resp = cls_struct_72byte_fn(b0, b1, b2, b3);
+}
+
+int main (void)
+{
+ ffi_cif cif;
+ void *code;
+ ffi_closure *pcl = ffi_closure_alloc(sizeof(ffi_closure), &code);
+ void* args_dbl[5];
+ ffi_type* cls_struct_fields[10];
+ ffi_type cls_struct_type;
+ ffi_type* dbl_arg_types[5];
+
+ struct_72byte e_dbl = { 9.0, 2.0, 6.0, 5.0, 3.0, 4.0, 8.0, 1.0, 7.0 };
+ struct_72byte f_dbl = { 1.0, 2.0, 3.0, 7.0, 2.0, 5.0, 6.0, 7.0, 4.0 };
+ struct_72byte g_dbl = { 4.0, 5.0, 7.0, 9.0, 1.0, 1.0, 2.0, 9.0, 3.0 };
+ struct_72byte h_dbl = { 8.0, 6.0, 1.0, 4.0, 0.0, 3.0, 3.0, 1.0, 2.0 };
+ struct_72byte res_dbl;
+
+ cls_struct_type.size = 0;
+ cls_struct_type.alignment = 0;
+ cls_struct_type.type = FFI_TYPE_STRUCT;
+ cls_struct_type.elements = cls_struct_fields;
+
+ cls_struct_fields[0] = &ffi_type_double;
+ cls_struct_fields[1] = &ffi_type_double;
+ cls_struct_fields[2] = &ffi_type_double;
+ cls_struct_fields[3] = &ffi_type_double;
+ cls_struct_fields[4] = &ffi_type_double;
+ cls_struct_fields[5] = &ffi_type_double;
+ cls_struct_fields[6] = &ffi_type_double;
+ cls_struct_fields[7] = &ffi_type_double;
+ cls_struct_fields[8] = &ffi_type_double;
+ cls_struct_fields[9] = NULL;
+
+ dbl_arg_types[0] = &cls_struct_type;
+ dbl_arg_types[1] = &cls_struct_type;
+ dbl_arg_types[2] = &cls_struct_type;
+ dbl_arg_types[3] = &cls_struct_type;
+ dbl_arg_types[4] = NULL;
+
+ CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 4, &cls_struct_type,
+ dbl_arg_types) == FFI_OK);
+
+ args_dbl[0] = &e_dbl;
+ args_dbl[1] = &f_dbl;
+ args_dbl[2] = &g_dbl;
+ args_dbl[3] = &h_dbl;
+ args_dbl[4] = NULL;
+
+ ffi_call(&cif, FFI_FN(cls_struct_72byte_fn), &res_dbl, args_dbl);
+ /* { dg-output "22 15 17 25 6 13 19 18 16" } */
+ printf("res: %g %g %g %g %g %g %g %g %g\n", res_dbl.a, res_dbl.b, res_dbl.c,
+ res_dbl.d, res_dbl.e, res_dbl.f, res_dbl.g, res_dbl.h, res_dbl.i);
+ /* { dg-output "\nres: 22 15 17 25 6 13 19 18 16" } */
+
+ CHECK(ffi_prep_closure_loc(pcl, &cif, cls_struct_72byte_gn, NULL, code) == FFI_OK);
+
+ res_dbl = ((struct_72byte(*)(struct_72byte, struct_72byte,
+ struct_72byte, struct_72byte))(code))(e_dbl, f_dbl, g_dbl, h_dbl);
+ /* { dg-output "\n22 15 17 25 6 13 19 18 16" } */
+ printf("res: %g %g %g %g %g %g %g %g %g\n", res_dbl.a, res_dbl.b, res_dbl.c,
+ res_dbl.d, res_dbl.e, res_dbl.f, res_dbl.g, res_dbl.h, res_dbl.i);
+ /* { dg-output "\nres: 22 15 17 25 6 13 19 18 16" } */
+
+ exit(0);
+}
diff --git a/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/stret_medium2.c b/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/stret_medium2.c
new file mode 100644
index 0000000..84323d1
--- /dev/null
+++ b/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/stret_medium2.c
@@ -0,0 +1,125 @@
+/* Area: ffi_call, closure_call
+ Purpose: Check structure returning with different structure size.
+ Depending on the ABI. Check bigger struct which overlaps
+ the gp and fp register count on Darwin/AIX/ppc64.
+ Limitations: none.
+ PR: none.
+ Originator: Blake Chaffin 6/21/2007 */
+
+/* { dg-do run { xfail strongarm*-*-* xscale*-*-* } } */
+/* { dg-options "-Wno-format" { target alpha*-dec-osf* } } */
+#include "ffitest.h"
+
+typedef struct struct_72byte {
+ double a;
+ double b;
+ double c;
+ double d;
+ double e;
+ double f;
+ double g;
+ double h;
+ long long i;
+} struct_72byte;
+
+struct_72byte cls_struct_72byte_fn(
+ struct_72byte b0,
+ struct_72byte b1,
+ struct_72byte b2,
+ struct_72byte b3)
+{
+ struct_72byte result;
+
+ result.a = b0.a + b1.a + b2.a + b3.a;
+ result.b = b0.b + b1.b + b2.b + b3.b;
+ result.c = b0.c + b1.c + b2.c + b3.c;
+ result.d = b0.d + b1.d + b2.d + b3.d;
+ result.e = b0.e + b1.e + b2.e + b3.e;
+ result.f = b0.f + b1.f + b2.f + b3.f;
+ result.g = b0.g + b1.g + b2.g + b3.g;
+ result.h = b0.h + b1.h + b2.h + b3.h;
+ result.i = b0.i + b1.i + b2.i + b3.i;
+
+ printf("%g %g %g %g %g %g %g %g %" PRIdLL "\n", result.a, result.b, result.c,
+ result.d, result.e, result.f, result.g, result.h, result.i);
+
+ return result;
+}
+
+static void
+cls_struct_72byte_gn(ffi_cif* cif __UNUSED__, void* resp, void** args, void* userdata __UNUSED__)
+{
+ struct_72byte b0, b1, b2, b3;
+
+ b0 = *(struct_72byte*)(args[0]);
+ b1 = *(struct_72byte*)(args[1]);
+ b2 = *(struct_72byte*)(args[2]);
+ b3 = *(struct_72byte*)(args[3]);
+
+ *(struct_72byte*)resp = cls_struct_72byte_fn(b0, b1, b2, b3);
+}
+
+int main (void)
+{
+ ffi_cif cif;
+ void *code;
+ ffi_closure *pcl = ffi_closure_alloc(sizeof(ffi_closure), &code);
+ void* args_dbl[5];
+ ffi_type* cls_struct_fields[10];
+ ffi_type cls_struct_type;
+ ffi_type* dbl_arg_types[5];
+
+ struct_72byte e_dbl = { 9.0, 2.0, 6.0, 5.0, 3.0, 4.0, 8.0, 1.0, 7 };
+ struct_72byte f_dbl = { 1.0, 2.0, 3.0, 7.0, 2.0, 5.0, 6.0, 7.0, 4 };
+ struct_72byte g_dbl = { 4.0, 5.0, 7.0, 9.0, 1.0, 1.0, 2.0, 9.0, 3 };
+ struct_72byte h_dbl = { 8.0, 6.0, 1.0, 4.0, 0.0, 3.0, 3.0, 1.0, 2 };
+ struct_72byte res_dbl;
+
+ cls_struct_type.size = 0;
+ cls_struct_type.alignment = 0;
+ cls_struct_type.type = FFI_TYPE_STRUCT;
+ cls_struct_type.elements = cls_struct_fields;
+
+ cls_struct_fields[0] = &ffi_type_double;
+ cls_struct_fields[1] = &ffi_type_double;
+ cls_struct_fields[2] = &ffi_type_double;
+ cls_struct_fields[3] = &ffi_type_double;
+ cls_struct_fields[4] = &ffi_type_double;
+ cls_struct_fields[5] = &ffi_type_double;
+ cls_struct_fields[6] = &ffi_type_double;
+ cls_struct_fields[7] = &ffi_type_double;
+ cls_struct_fields[8] = &ffi_type_sint64;
+ cls_struct_fields[9] = NULL;
+
+ dbl_arg_types[0] = &cls_struct_type;
+ dbl_arg_types[1] = &cls_struct_type;
+ dbl_arg_types[2] = &cls_struct_type;
+ dbl_arg_types[3] = &cls_struct_type;
+ dbl_arg_types[4] = NULL;
+
+ CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 4, &cls_struct_type,
+ dbl_arg_types) == FFI_OK);
+
+ args_dbl[0] = &e_dbl;
+ args_dbl[1] = &f_dbl;
+ args_dbl[2] = &g_dbl;
+ args_dbl[3] = &h_dbl;
+ args_dbl[4] = NULL;
+
+ ffi_call(&cif, FFI_FN(cls_struct_72byte_fn), &res_dbl, args_dbl);
+ /* { dg-output "22 15 17 25 6 13 19 18 16" } */
+ printf("res: %g %g %g %g %g %g %g %g %" PRIdLL "\n", res_dbl.a, res_dbl.b, res_dbl.c,
+ res_dbl.d, res_dbl.e, res_dbl.f, res_dbl.g, res_dbl.h, res_dbl.i);
+ /* { dg-output "\nres: 22 15 17 25 6 13 19 18 16" } */
+
+ CHECK(ffi_prep_closure_loc(pcl, &cif, cls_struct_72byte_gn, NULL, code) == FFI_OK);
+
+ res_dbl = ((struct_72byte(*)(struct_72byte, struct_72byte,
+ struct_72byte, struct_72byte))(code))(e_dbl, f_dbl, g_dbl, h_dbl);
+ /* { dg-output "\n22 15 17 25 6 13 19 18 16" } */
+ printf("res: %g %g %g %g %g %g %g %g %" PRIdLL "\n", res_dbl.a, res_dbl.b, res_dbl.c,
+ res_dbl.d, res_dbl.e, res_dbl.f, res_dbl.g, res_dbl.h, res_dbl.i);
+ /* { dg-output "\nres: 22 15 17 25 6 13 19 18 16" } */
+
+ exit(0);
+}
diff --git a/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/strlen.c b/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/strlen.c
new file mode 100644
index 0000000..35b70ea
--- /dev/null
+++ b/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/strlen.c
@@ -0,0 +1,44 @@
+/* Area: ffi_call
+ Purpose: Check strlen function call.
+ Limitations: none.
+ PR: none.
+ Originator: From the original ffitest.c */
+
+/* { dg-do run } */
+#include "ffitest.h"
+
+static size_t ABI_ATTR my_strlen(char *s)
+{
+ return (strlen(s));
+}
+
+int main (void)
+{
+ ffi_cif cif;
+ ffi_type *args[MAX_ARGS];
+ void *values[MAX_ARGS];
+ ffi_arg rint;
+ char *s;
+
+ args[0] = &ffi_type_pointer;
+ values[0] = (void*) &s;
+
+ /* Initialize the cif */
+ CHECK(ffi_prep_cif(&cif, ABI_NUM, 1,
+ &ffi_type_sint, args) == FFI_OK);
+
+ s = "a";
+ ffi_call(&cif, FFI_FN(my_strlen), &rint, values);
+ CHECK(rint == 1);
+
+ s = "1234567";
+ ffi_call(&cif, FFI_FN(my_strlen), &rint, values);
+ CHECK(rint == 7);
+
+ s = "1234567890123456789012345";
+ ffi_call(&cif, FFI_FN(my_strlen), &rint, values);
+ CHECK(rint == 25);
+
+ exit (0);
+}
+
diff --git a/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/strlen2.c b/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/strlen2.c
new file mode 100644
index 0000000..96282bc
--- /dev/null
+++ b/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/strlen2.c
@@ -0,0 +1,49 @@
+/* Area: ffi_call
+ Purpose: Check strlen function call with additional arguments.
+ Limitations: none.
+ PR: none.
+ Originator: From the original ffitest.c */
+
+/* { dg-do run } */
+
+#include "ffitest.h"
+
+static size_t ABI_ATTR my_f(char *s, float a)
+{
+ return (size_t) ((int) strlen(s) + (int) a);
+}
+
+int main (void)
+{
+ ffi_cif cif;
+ ffi_type *args[MAX_ARGS];
+ void *values[MAX_ARGS];
+ ffi_arg rint;
+ char *s;
+ float v2;
+ args[0] = &ffi_type_pointer;
+ args[1] = &ffi_type_float;
+ values[0] = (void*) &s;
+ values[1] = (void*) &v2;
+
+ /* Initialize the cif */
+ CHECK(ffi_prep_cif(&cif, ABI_NUM, 2,
+ &ffi_type_sint, args) == FFI_OK);
+
+ s = "a";
+ v2 = 0.0;
+ ffi_call(&cif, FFI_FN(my_f), &rint, values);
+ CHECK(rint == 1);
+
+ s = "1234567";
+ v2 = -1.0;
+ ffi_call(&cif, FFI_FN(my_f), &rint, values);
+ CHECK(rint == 6);
+
+ s = "1234567890123456789012345";
+ v2 = 1.0;
+ ffi_call(&cif, FFI_FN(my_f), &rint, values);
+ CHECK(rint == 26);
+
+ exit(0);
+}
diff --git a/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/strlen3.c b/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/strlen3.c
new file mode 100644
index 0000000..beba86e
--- /dev/null
+++ b/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/strlen3.c
@@ -0,0 +1,49 @@
+/* Area: ffi_call
+ Purpose: Check strlen function call with additional arguments.
+ Limitations: none.
+ PR: none.
+ Originator: From the original ffitest.c */
+
+/* { dg-do run } */
+
+#include "ffitest.h"
+
+static size_t ABI_ATTR my_f(float a, char *s)
+{
+ return (size_t) ((int) strlen(s) + (int) a);
+}
+
+int main (void)
+{
+ ffi_cif cif;
+ ffi_type *args[MAX_ARGS];
+ void *values[MAX_ARGS];
+ ffi_arg rint;
+ char *s;
+ float v2;
+ args[1] = &ffi_type_pointer;
+ args[0] = &ffi_type_float;
+ values[1] = (void*) &s;
+ values[0] = (void*) &v2;
+
+ /* Initialize the cif */
+ CHECK(ffi_prep_cif(&cif, ABI_NUM, 2,
+ &ffi_type_sint, args) == FFI_OK);
+
+ s = "a";
+ v2 = 0.0;
+ ffi_call(&cif, FFI_FN(my_f), &rint, values);
+ CHECK(rint == 1);
+
+ s = "1234567";
+ v2 = -1.0;
+ ffi_call(&cif, FFI_FN(my_f), &rint, values);
+ CHECK(rint == 6);
+
+ s = "1234567890123456789012345";
+ v2 = 1.0;
+ ffi_call(&cif, FFI_FN(my_f), &rint, values);
+ CHECK(rint == 26);
+
+ exit(0);
+}
diff --git a/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/strlen4.c b/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/strlen4.c
new file mode 100644
index 0000000..d5d42b4
--- /dev/null
+++ b/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/strlen4.c
@@ -0,0 +1,55 @@
+/* Area: ffi_call
+ Purpose: Check strlen function call with additional arguments.
+ Limitations: none.
+ PR: none.
+ Originator: From the original ffitest.c */
+
+/* { dg-do run } */
+
+#include "ffitest.h"
+
+static size_t ABI_ATTR my_f(float a, char *s, int i)
+{
+ return (size_t) ((int) strlen(s) + (int) a + i);
+}
+
+int main (void)
+{
+ ffi_cif cif;
+ ffi_type *args[MAX_ARGS];
+ void *values[MAX_ARGS];
+ ffi_arg rint;
+ char *s;
+ int v1;
+ float v2;
+ args[2] = &ffi_type_sint;
+ args[1] = &ffi_type_pointer;
+ args[0] = &ffi_type_float;
+ values[2] = (void*) &v1;
+ values[1] = (void*) &s;
+ values[0] = (void*) &v2;
+
+ /* Initialize the cif */
+ CHECK(ffi_prep_cif(&cif, ABI_NUM, 3,
+ &ffi_type_sint, args) == FFI_OK);
+
+ s = "a";
+ v1 = 1;
+ v2 = 0.0;
+ ffi_call(&cif, FFI_FN(my_f), &rint, values);
+ CHECK(rint == 2);
+
+ s = "1234567";
+ v2 = -1.0;
+ v1 = -2;
+ ffi_call(&cif, FFI_FN(my_f), &rint, values);
+ CHECK(rint == 4);
+
+ s = "1234567890123456789012345";
+ v2 = 1.0;
+ v1 = 2;
+ ffi_call(&cif, FFI_FN(my_f), &rint, values);
+ CHECK(rint == 28);
+
+ exit(0);
+}
diff --git a/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/struct1.c b/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/struct1.c
new file mode 100644
index 0000000..c13e23f
--- /dev/null
+++ b/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/struct1.c
@@ -0,0 +1,67 @@
+/* Area: ffi_call
+ Purpose: Check structures.
+ Limitations: none.
+ PR: none.
+ Originator: From the original ffitest.c */
+
+/* { dg-do run } */
+#include "ffitest.h"
+
+typedef struct
+{
+ unsigned char uc;
+ double d;
+ unsigned int ui;
+} test_structure_1;
+
+static test_structure_1 ABI_ATTR struct1(test_structure_1 ts)
+{
+ ts.uc++;
+ ts.d--;
+ ts.ui++;
+
+ return ts;
+}
+
+int main (void)
+{
+ ffi_cif cif;
+ ffi_type *args[MAX_ARGS];
+ void *values[MAX_ARGS];
+ ffi_type ts1_type;
+ ffi_type *ts1_type_elements[4];
+
+ test_structure_1 ts1_arg;
+
+ /* This is a hack to get a properly aligned result buffer */
+ test_structure_1 *ts1_result =
+ (test_structure_1 *) malloc (sizeof(test_structure_1));
+
+ ts1_type.size = 0;
+ ts1_type.alignment = 0;
+ ts1_type.type = FFI_TYPE_STRUCT;
+ ts1_type.elements = ts1_type_elements;
+ ts1_type_elements[0] = &ffi_type_uchar;
+ ts1_type_elements[1] = &ffi_type_double;
+ ts1_type_elements[2] = &ffi_type_uint;
+ ts1_type_elements[3] = NULL;
+
+ args[0] = &ts1_type;
+ values[0] = &ts1_arg;
+
+ /* Initialize the cif */
+ CHECK(ffi_prep_cif(&cif, ABI_NUM, 1,
+ &ts1_type, args) == FFI_OK);
+
+ ts1_arg.uc = '\x01';
+ ts1_arg.d = 3.14159;
+ ts1_arg.ui = 555;
+
+ ffi_call(&cif, FFI_FN(struct1), ts1_result, values);
+
+ CHECK(ts1_result->ui == 556);
+ CHECK(ts1_result->d == 3.14159 - 1);
+
+ free (ts1_result);
+ exit(0);
+}
diff --git a/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/struct2.c b/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/struct2.c
new file mode 100644
index 0000000..5077a5e
--- /dev/null
+++ b/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/struct2.c
@@ -0,0 +1,67 @@
+/* Area: ffi_call
+ Purpose: Check structures.
+ Limitations: none.
+ PR: none.
+ Originator: From the original ffitest.c */
+
+/* { dg-do run } */
+#include "ffitest.h"
+
+typedef struct
+{
+ double d1;
+ double d2;
+} test_structure_2;
+
+static test_structure_2 ABI_ATTR struct2(test_structure_2 ts)
+{
+ ts.d1--;
+ ts.d2--;
+
+ return ts;
+}
+
+int main (void)
+{
+ ffi_cif cif;
+ ffi_type *args[MAX_ARGS];
+ void *values[MAX_ARGS];
+ test_structure_2 ts2_arg;
+ ffi_type ts2_type;
+ ffi_type *ts2_type_elements[3];
+
+ /* This is a hack to get a properly aligned result buffer */
+ test_structure_2 *ts2_result =
+ (test_structure_2 *) malloc (sizeof(test_structure_2));
+
+ ts2_type.size = 0;
+ ts2_type.alignment = 0;
+ ts2_type.type = FFI_TYPE_STRUCT;
+ ts2_type.elements = ts2_type_elements;
+ ts2_type_elements[0] = &ffi_type_double;
+ ts2_type_elements[1] = &ffi_type_double;
+ ts2_type_elements[2] = NULL;
+
+ args[0] = &ts2_type;
+ values[0] = &ts2_arg;
+
+ /* Initialize the cif */
+ CHECK(ffi_prep_cif(&cif, ABI_NUM, 1, &ts2_type, args) == FFI_OK);
+
+ ts2_arg.d1 = 5.55;
+ ts2_arg.d2 = 6.66;
+
+ printf ("%g\n", ts2_arg.d1);
+ printf ("%g\n", ts2_arg.d2);
+
+ ffi_call(&cif, FFI_FN(struct2), ts2_result, values);
+
+ printf ("%g\n", ts2_result->d1);
+ printf ("%g\n", ts2_result->d2);
+
+ CHECK(ts2_result->d1 == 5.55 - 1);
+ CHECK(ts2_result->d2 == 6.66 - 1);
+
+ free (ts2_result);
+ exit(0);
+}
diff --git a/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/struct3.c b/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/struct3.c
new file mode 100644
index 0000000..7eba0ea
--- /dev/null
+++ b/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/struct3.c
@@ -0,0 +1,60 @@
+/* Area: ffi_call
+ Purpose: Check structures.
+ Limitations: none.
+ PR: none.
+ Originator: From the original ffitest.c */
+
+/* { dg-do run } */
+#include "ffitest.h"
+
+typedef struct
+{
+ int si;
+} test_structure_3;
+
+static test_structure_3 ABI_ATTR struct3(test_structure_3 ts)
+{
+ ts.si = -(ts.si*2);
+
+ return ts;
+}
+
+int main (void)
+{
+ ffi_cif cif;
+ ffi_type *args[MAX_ARGS];
+ void *values[MAX_ARGS];
+ int compare_value;
+ ffi_type ts3_type;
+ ffi_type *ts3_type_elements[2];
+
+ test_structure_3 ts3_arg;
+ test_structure_3 *ts3_result =
+ (test_structure_3 *) malloc (sizeof(test_structure_3));
+
+ ts3_type.size = 0;
+ ts3_type.alignment = 0;
+ ts3_type.type = FFI_TYPE_STRUCT;
+ ts3_type.elements = ts3_type_elements;
+ ts3_type_elements[0] = &ffi_type_sint;
+ ts3_type_elements[1] = NULL;
+
+ args[0] = &ts3_type;
+ values[0] = &ts3_arg;
+
+ /* Initialize the cif */
+ CHECK(ffi_prep_cif(&cif, ABI_NUM, 1,
+ &ts3_type, args) == FFI_OK);
+
+ ts3_arg.si = -123;
+ compare_value = ts3_arg.si;
+
+ ffi_call(&cif, FFI_FN(struct3), ts3_result, values);
+
+ printf ("%d %d\n", ts3_result->si, -(compare_value*2));
+
+ CHECK(ts3_result->si == -(compare_value*2));
+
+ free (ts3_result);
+ exit(0);
+}
diff --git a/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/struct4.c b/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/struct4.c
new file mode 100644
index 0000000..66a9551
--- /dev/null
+++ b/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/struct4.c
@@ -0,0 +1,64 @@
+/* Area: ffi_call
+ Purpose: Check structures.
+ Limitations: none.
+ PR: none.
+ Originator: From the original ffitest.c */
+
+/* { dg-do run } */
+#include "ffitest.h"
+
+typedef struct
+{
+ unsigned ui1;
+ unsigned ui2;
+ unsigned ui3;
+} test_structure_4;
+
+static test_structure_4 ABI_ATTR struct4(test_structure_4 ts)
+{
+ ts.ui3 = ts.ui1 * ts.ui2 * ts.ui3;
+
+ return ts;
+}
+
+int main (void)
+{
+ ffi_cif cif;
+ ffi_type *args[MAX_ARGS];
+ void *values[MAX_ARGS];
+ ffi_type ts4_type;
+ ffi_type *ts4_type_elements[4];
+
+ test_structure_4 ts4_arg;
+
+ /* This is a hack to get a properly aligned result buffer */
+ test_structure_4 *ts4_result =
+ (test_structure_4 *) malloc (sizeof(test_structure_4));
+
+ ts4_type.size = 0;
+ ts4_type.alignment = 0;
+ ts4_type.type = FFI_TYPE_STRUCT;
+ ts4_type.elements = ts4_type_elements;
+ ts4_type_elements[0] = &ffi_type_uint;
+ ts4_type_elements[1] = &ffi_type_uint;
+ ts4_type_elements[2] = &ffi_type_uint;
+ ts4_type_elements[3] = NULL;
+
+ args[0] = &ts4_type;
+ values[0] = &ts4_arg;
+
+ /* Initialize the cif */
+ CHECK(ffi_prep_cif(&cif, ABI_NUM, 1, &ts4_type, args) == FFI_OK);
+
+ ts4_arg.ui1 = 2;
+ ts4_arg.ui2 = 3;
+ ts4_arg.ui3 = 4;
+
+ ffi_call (&cif, FFI_FN(struct4), ts4_result, values);
+
+ CHECK(ts4_result->ui3 == 2U * 3U * 4U);
+
+
+ free (ts4_result);
+ exit(0);
+}
diff --git a/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/struct5.c b/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/struct5.c
new file mode 100644
index 0000000..23e2a3f
--- /dev/null
+++ b/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/struct5.c
@@ -0,0 +1,66 @@
+/* Area: ffi_call
+ Purpose: Check structures.
+ Limitations: none.
+ PR: none.
+ Originator: From the original ffitest.c */
+
+/* { dg-do run } */
+#include "ffitest.h"
+typedef struct
+{
+ char c1;
+ char c2;
+} test_structure_5;
+
+static test_structure_5 ABI_ATTR struct5(test_structure_5 ts1, test_structure_5 ts2)
+{
+ ts1.c1 += ts2.c1;
+ ts1.c2 -= ts2.c2;
+
+ return ts1;
+}
+
+int main (void)
+{
+ ffi_cif cif;
+ ffi_type *args[MAX_ARGS];
+ void *values[MAX_ARGS];
+ ffi_type ts5_type;
+ ffi_type *ts5_type_elements[3];
+
+ test_structure_5 ts5_arg1, ts5_arg2;
+
+ /* This is a hack to get a properly aligned result buffer */
+ test_structure_5 *ts5_result =
+ (test_structure_5 *) malloc (sizeof(test_structure_5));
+
+ ts5_type.size = 0;
+ ts5_type.alignment = 0;
+ ts5_type.type = FFI_TYPE_STRUCT;
+ ts5_type.elements = ts5_type_elements;
+ ts5_type_elements[0] = &ffi_type_schar;
+ ts5_type_elements[1] = &ffi_type_schar;
+ ts5_type_elements[2] = NULL;
+
+ args[0] = &ts5_type;
+ args[1] = &ts5_type;
+ values[0] = &ts5_arg1;
+ values[1] = &ts5_arg2;
+
+ /* Initialize the cif */
+ CHECK(ffi_prep_cif(&cif, ABI_NUM, 2, &ts5_type, args) == FFI_OK);
+
+ ts5_arg1.c1 = 2;
+ ts5_arg1.c2 = 6;
+ ts5_arg2.c1 = 5;
+ ts5_arg2.c2 = 3;
+
+ ffi_call (&cif, FFI_FN(struct5), ts5_result, values);
+
+ CHECK(ts5_result->c1 == 7);
+ CHECK(ts5_result->c2 == 3);
+
+
+ free (ts5_result);
+ exit(0);
+}
diff --git a/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/struct6.c b/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/struct6.c
new file mode 100644
index 0000000..173c66e
--- /dev/null
+++ b/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/struct6.c
@@ -0,0 +1,64 @@
+/* Area: ffi_call
+ Purpose: Check structures.
+ Limitations: none.
+ PR: none.
+ Originator: From the original ffitest.c */
+
+/* { dg-do run } */
+#include "ffitest.h"
+typedef struct
+{
+ float f;
+ double d;
+} test_structure_6;
+
+static test_structure_6 ABI_ATTR struct6 (test_structure_6 ts)
+{
+ ts.f += 1;
+ ts.d += 1;
+
+ return ts;
+}
+
+int main (void)
+{
+ ffi_cif cif;
+ ffi_type *args[MAX_ARGS];
+ void *values[MAX_ARGS];
+ ffi_type ts6_type;
+ ffi_type *ts6_type_elements[3];
+
+ test_structure_6 ts6_arg;
+
+ /* This is a hack to get a properly aligned result buffer */
+ test_structure_6 *ts6_result =
+ (test_structure_6 *) malloc (sizeof(test_structure_6));
+
+ ts6_type.size = 0;
+ ts6_type.alignment = 0;
+ ts6_type.type = FFI_TYPE_STRUCT;
+ ts6_type.elements = ts6_type_elements;
+ ts6_type_elements[0] = &ffi_type_float;
+ ts6_type_elements[1] = &ffi_type_double;
+ ts6_type_elements[2] = NULL;
+
+ args[0] = &ts6_type;
+ values[0] = &ts6_arg;
+
+ /* Initialize the cif */
+ CHECK(ffi_prep_cif(&cif, ABI_NUM, 1, &ts6_type, args) == FFI_OK);
+
+ ts6_arg.f = 5.55f;
+ ts6_arg.d = 6.66;
+
+ printf ("%g\n", ts6_arg.f);
+ printf ("%g\n", ts6_arg.d);
+
+ ffi_call(&cif, FFI_FN(struct6), ts6_result, values);
+
+ CHECK(ts6_result->f == 5.55f + 1);
+ CHECK(ts6_result->d == 6.66 + 1);
+
+ free (ts6_result);
+ exit(0);
+}
diff --git a/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/struct7.c b/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/struct7.c
new file mode 100644
index 0000000..badc7e0
--- /dev/null
+++ b/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/struct7.c
@@ -0,0 +1,74 @@
+/* Area: ffi_call
+ Purpose: Check structures.
+ Limitations: none.
+ PR: none.
+ Originator: From the original ffitest.c */
+
+/* { dg-do run } */
+#include "ffitest.h"
+typedef struct
+{
+ float f1;
+ float f2;
+ double d;
+} test_structure_7;
+
+static test_structure_7 ABI_ATTR struct7 (test_structure_7 ts)
+{
+ ts.f1 += 1;
+ ts.f2 += 1;
+ ts.d += 1;
+
+ return ts;
+}
+
+int main (void)
+{
+ ffi_cif cif;
+ ffi_type *args[MAX_ARGS];
+ void *values[MAX_ARGS];
+ ffi_type ts7_type;
+ ffi_type *ts7_type_elements[4];
+
+ test_structure_7 ts7_arg;
+
+ /* This is a hack to get a properly aligned result buffer */
+ test_structure_7 *ts7_result =
+ (test_structure_7 *) malloc (sizeof(test_structure_7));
+
+ ts7_type.size = 0;
+ ts7_type.alignment = 0;
+ ts7_type.type = FFI_TYPE_STRUCT;
+ ts7_type.elements = ts7_type_elements;
+ ts7_type_elements[0] = &ffi_type_float;
+ ts7_type_elements[1] = &ffi_type_float;
+ ts7_type_elements[2] = &ffi_type_double;
+ ts7_type_elements[3] = NULL;
+
+ args[0] = &ts7_type;
+ values[0] = &ts7_arg;
+
+ /* Initialize the cif */
+ CHECK(ffi_prep_cif(&cif, ABI_NUM, 1, &ts7_type, args) == FFI_OK);
+
+ ts7_arg.f1 = 5.55f;
+ ts7_arg.f2 = 55.5f;
+ ts7_arg.d = 6.66;
+
+ printf ("%g\n", ts7_arg.f1);
+ printf ("%g\n", ts7_arg.f2);
+ printf ("%g\n", ts7_arg.d);
+
+ ffi_call(&cif, FFI_FN(struct7), ts7_result, values);
+
+ printf ("%g\n", ts7_result->f1);
+ printf ("%g\n", ts7_result->f2);
+ printf ("%g\n", ts7_result->d);
+
+ CHECK(ts7_result->f1 == 5.55f + 1);
+ CHECK(ts7_result->f2 == 55.5f + 1);
+ CHECK(ts7_result->d == 6.66 + 1);
+
+ free (ts7_result);
+ exit(0);
+}
diff --git a/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/struct8.c b/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/struct8.c
new file mode 100644
index 0000000..ef204ec
--- /dev/null
+++ b/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/struct8.c
@@ -0,0 +1,81 @@
+/* Area: ffi_call
+ Purpose: Check structures.
+ Limitations: none.
+ PR: none.
+ Originator: From the original ffitest.c */
+
+/* { dg-do run } */
+#include "ffitest.h"
+typedef struct
+{
+ float f1;
+ float f2;
+ float f3;
+ float f4;
+} test_structure_8;
+
+static test_structure_8 ABI_ATTR struct8 (test_structure_8 ts)
+{
+ ts.f1 += 1;
+ ts.f2 += 1;
+ ts.f3 += 1;
+ ts.f4 += 1;
+
+ return ts;
+}
+
+int main (void)
+{
+ ffi_cif cif;
+ ffi_type *args[MAX_ARGS];
+ void *values[MAX_ARGS];
+ ffi_type ts8_type;
+ ffi_type *ts8_type_elements[5];
+
+ test_structure_8 ts8_arg;
+
+ /* This is a hack to get a properly aligned result buffer */
+ test_structure_8 *ts8_result =
+ (test_structure_8 *) malloc (sizeof(test_structure_8));
+
+ ts8_type.size = 0;
+ ts8_type.alignment = 0;
+ ts8_type.type = FFI_TYPE_STRUCT;
+ ts8_type.elements = ts8_type_elements;
+ ts8_type_elements[0] = &ffi_type_float;
+ ts8_type_elements[1] = &ffi_type_float;
+ ts8_type_elements[2] = &ffi_type_float;
+ ts8_type_elements[3] = &ffi_type_float;
+ ts8_type_elements[4] = NULL;
+
+ args[0] = &ts8_type;
+ values[0] = &ts8_arg;
+
+ /* Initialize the cif */
+ CHECK(ffi_prep_cif(&cif, ABI_NUM, 1, &ts8_type, args) == FFI_OK);
+
+ ts8_arg.f1 = 5.55f;
+ ts8_arg.f2 = 55.5f;
+ ts8_arg.f3 = -5.55f;
+ ts8_arg.f4 = -55.5f;
+
+ printf ("%g\n", ts8_arg.f1);
+ printf ("%g\n", ts8_arg.f2);
+ printf ("%g\n", ts8_arg.f3);
+ printf ("%g\n", ts8_arg.f4);
+
+ ffi_call(&cif, FFI_FN(struct8), ts8_result, values);
+
+ printf ("%g\n", ts8_result->f1);
+ printf ("%g\n", ts8_result->f2);
+ printf ("%g\n", ts8_result->f3);
+ printf ("%g\n", ts8_result->f4);
+
+ CHECK(ts8_result->f1 == 5.55f + 1);
+ CHECK(ts8_result->f2 == 55.5f + 1);
+ CHECK(ts8_result->f3 == -5.55f + 1);
+ CHECK(ts8_result->f4 == -55.5f + 1);
+
+ free (ts8_result);
+ exit(0);
+}
diff --git a/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/struct9.c b/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/struct9.c
new file mode 100644
index 0000000..4a13b81
--- /dev/null
+++ b/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/struct9.c
@@ -0,0 +1,68 @@
+/* Area: ffi_call
+ Purpose: Check structures.
+ Limitations: none.
+ PR: none.
+ Originator: From the original ffitest.c */
+
+/* { dg-do run } */
+#include "ffitest.h"
+
+typedef struct
+{
+ float f;
+ int i;
+} test_structure_9;
+
+static test_structure_9 ABI_ATTR struct9 (test_structure_9 ts)
+{
+ ts.f += 1;
+ ts.i += 1;
+
+ return ts;
+}
+
+int main (void)
+{
+ ffi_cif cif;
+ ffi_type *args[MAX_ARGS];
+ void *values[MAX_ARGS];
+ ffi_type ts9_type;
+ ffi_type *ts9_type_elements[3];
+
+ test_structure_9 ts9_arg;
+
+ /* This is a hack to get a properly aligned result buffer */
+ test_structure_9 *ts9_result =
+ (test_structure_9 *) malloc (sizeof(test_structure_9));
+
+ ts9_type.size = 0;
+ ts9_type.alignment = 0;
+ ts9_type.type = FFI_TYPE_STRUCT;
+ ts9_type.elements = ts9_type_elements;
+ ts9_type_elements[0] = &ffi_type_float;
+ ts9_type_elements[1] = &ffi_type_sint;
+ ts9_type_elements[2] = NULL;
+
+ args[0] = &ts9_type;
+ values[0] = &ts9_arg;
+
+ /* Initialize the cif */
+ CHECK(ffi_prep_cif(&cif, ABI_NUM, 1, &ts9_type, args) == FFI_OK);
+
+ ts9_arg.f = 5.55f;
+ ts9_arg.i = 5;
+
+ printf ("%g\n", ts9_arg.f);
+ printf ("%d\n", ts9_arg.i);
+
+ ffi_call(&cif, FFI_FN(struct9), ts9_result, values);
+
+ printf ("%g\n", ts9_result->f);
+ printf ("%d\n", ts9_result->i);
+
+ CHECK(ts9_result->f == 5.55f + 1);
+ CHECK(ts9_result->i == 5 + 1);
+
+ free (ts9_result);
+ exit(0);
+}
diff --git a/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/testclosure.c b/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/testclosure.c
new file mode 100644
index 0000000..ca31056
--- /dev/null
+++ b/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/testclosure.c
@@ -0,0 +1,70 @@
+/* Area: closure_call
+ Purpose: Check return value float.
+ Limitations: none.
+ PR: 41908.
+ Originator: <rfm@gnu.org> 20091102 */
+
+/* { dg-do run } */
+#include "ffitest.h"
+
+typedef struct cls_struct_combined {
+ float a;
+ float b;
+ float c;
+ float d;
+} cls_struct_combined;
+
+void cls_struct_combined_fn(struct cls_struct_combined arg)
+{
+ printf("%g %g %g %g\n",
+ arg.a, arg.b,
+ arg.c, arg.d);
+ fflush(stdout);
+}
+
+static void
+cls_struct_combined_gn(ffi_cif* cif __UNUSED__, void* resp __UNUSED__,
+ void** args, void* userdata __UNUSED__)
+{
+ struct cls_struct_combined a0;
+
+ a0 = *(struct cls_struct_combined*)(args[0]);
+
+ cls_struct_combined_fn(a0);
+}
+
+
+int main (void)
+{
+ ffi_cif cif;
+ void *code;
+ ffi_closure *pcl = ffi_closure_alloc(sizeof(ffi_closure), &code);
+ ffi_type* cls_struct_fields0[5];
+ ffi_type cls_struct_type0;
+ ffi_type* dbl_arg_types[5];
+
+ struct cls_struct_combined g_dbl = {4.0, 5.0, 1.0, 8.0};
+
+ cls_struct_type0.size = 0;
+ cls_struct_type0.alignment = 0;
+ cls_struct_type0.type = FFI_TYPE_STRUCT;
+ cls_struct_type0.elements = cls_struct_fields0;
+
+ cls_struct_fields0[0] = &ffi_type_float;
+ cls_struct_fields0[1] = &ffi_type_float;
+ cls_struct_fields0[2] = &ffi_type_float;
+ cls_struct_fields0[3] = &ffi_type_float;
+ cls_struct_fields0[4] = NULL;
+
+ dbl_arg_types[0] = &cls_struct_type0;
+ dbl_arg_types[1] = NULL;
+
+ CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 1, &ffi_type_void,
+ dbl_arg_types) == FFI_OK);
+
+ CHECK(ffi_prep_closure_loc(pcl, &cif, cls_struct_combined_gn, NULL, code) == FFI_OK);
+
+ ((void(*)(cls_struct_combined)) (code))(g_dbl);
+ /* { dg-output "4 5 1 8" } */
+ exit(0);
+}
diff --git a/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/uninitialized.c b/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/uninitialized.c
new file mode 100644
index 0000000..f00d830
--- /dev/null
+++ b/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/uninitialized.c
@@ -0,0 +1,61 @@
+/* { dg-do run } */
+#include "ffitest.h"
+
+typedef struct
+{
+ unsigned char uc;
+ double d;
+ unsigned int ui;
+} test_structure_1;
+
+static test_structure_1 struct1(test_structure_1 ts)
+{
+ ts.uc++;
+ ts.d--;
+ ts.ui++;
+
+ return ts;
+}
+
+int main (void)
+{
+ ffi_cif cif;
+ ffi_type *args[MAX_ARGS];
+ void *values[MAX_ARGS];
+ ffi_type ts1_type;
+ ffi_type *ts1_type_elements[4];
+
+ memset(&cif, 1, sizeof(cif));
+ ts1_type.size = 0;
+ ts1_type.alignment = 0;
+ ts1_type.type = FFI_TYPE_STRUCT;
+ ts1_type.elements = ts1_type_elements;
+ ts1_type_elements[0] = &ffi_type_uchar;
+ ts1_type_elements[1] = &ffi_type_double;
+ ts1_type_elements[2] = &ffi_type_uint;
+ ts1_type_elements[3] = NULL;
+
+ test_structure_1 ts1_arg;
+ /* This is a hack to get a properly aligned result buffer */
+ test_structure_1 *ts1_result =
+ (test_structure_1 *) malloc (sizeof(test_structure_1));
+
+ args[0] = &ts1_type;
+ values[0] = &ts1_arg;
+
+ /* Initialize the cif */
+ CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 1,
+ &ts1_type, args) == FFI_OK);
+
+ ts1_arg.uc = '\x01';
+ ts1_arg.d = 3.14159;
+ ts1_arg.ui = 555;
+
+ ffi_call(&cif, FFI_FN(struct1), ts1_result, values);
+
+ CHECK(ts1_result->ui == 556);
+ CHECK(ts1_result->d == 3.14159 - 1);
+
+ free (ts1_result);
+ exit(0);
+}
diff --git a/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/unwindtest.cc b/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/unwindtest.cc
new file mode 100644
index 0000000..67cfefe
--- /dev/null
+++ b/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/unwindtest.cc
@@ -0,0 +1,117 @@
+/* Area: ffi_closure, unwind info
+ Purpose: Check if the unwind information is passed correctly.
+ Limitations: none.
+ PR: none.
+ Originator: Jeff Sturm <jsturm@one-point.com> */
+
+/* { dg-do run } */
+
+#include "ffitest.h"
+
+void ABI_ATTR
+closure_test_fn(ffi_cif* cif __UNUSED__, void* resp __UNUSED__,
+ void** args __UNUSED__, void* userdata __UNUSED__)
+{
+ throw 9;
+}
+
+typedef void (*closure_test_type)();
+
+void closure_test_fn1(ffi_cif* cif __UNUSED__, void* resp,
+ void** args, void* userdata __UNUSED__)
+ {
+ *(ffi_arg*)resp =
+ (int)*(float *)args[0] +(int)(*(float *)args[1]) +
+ (int)(*(float *)args[2]) + (int)*(float *)args[3] +
+ (int)(*(signed short *)args[4]) + (int)(*(float *)args[5]) +
+ (int)*(float *)args[6] + (int)(*(int *)args[7]) +
+ (int)(*(double*)args[8]) + (int)*(int *)args[9] +
+ (int)(*(int *)args[10]) + (int)(*(float *)args[11]) +
+ (int)*(int *)args[12] + (int)(*(int *)args[13]) +
+ (int)(*(int *)args[14]) + *(int *)args[15] + (int)(intptr_t)userdata;
+
+ printf("%d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d: %d\n",
+ (int)*(float *)args[0], (int)(*(float *)args[1]),
+ (int)(*(float *)args[2]), (int)*(float *)args[3],
+ (int)(*(signed short *)args[4]), (int)(*(float *)args[5]),
+ (int)*(float *)args[6], (int)(*(int *)args[7]),
+ (int)(*(double *)args[8]), (int)*(int *)args[9],
+ (int)(*(int *)args[10]), (int)(*(float *)args[11]),
+ (int)*(int *)args[12], (int)(*(int *)args[13]),
+ (int)(*(int *)args[14]), *(int *)args[15],
+ (int)(intptr_t)userdata, (int)*(ffi_arg*)resp);
+
+ throw (int)*(ffi_arg*)resp;
+}
+
+typedef int (*closure_test_type1)(float, float, float, float, signed short,
+ float, float, int, double, int, int, float,
+ int, int, int, int);
+
+int main (void)
+{
+ ffi_cif cif;
+ void *code;
+ ffi_closure *pcl = (ffi_closure *)ffi_closure_alloc(sizeof(ffi_closure), &code);
+ ffi_type * cl_arg_types[17];
+
+ {
+ cl_arg_types[1] = NULL;
+
+ CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 0,
+ &ffi_type_void, cl_arg_types) == FFI_OK);
+ CHECK(ffi_prep_closure_loc(pcl, &cif, closure_test_fn, NULL, code) == FFI_OK);
+
+ try
+ {
+ (*((closure_test_type)(code)))();
+ } catch (int exception_code)
+ {
+ CHECK(exception_code == 9);
+ }
+
+ printf("part one OK\n");
+ /* { dg-output "part one OK" } */
+ }
+
+ {
+
+ cl_arg_types[0] = &ffi_type_float;
+ cl_arg_types[1] = &ffi_type_float;
+ cl_arg_types[2] = &ffi_type_float;
+ cl_arg_types[3] = &ffi_type_float;
+ cl_arg_types[4] = &ffi_type_sshort;
+ cl_arg_types[5] = &ffi_type_float;
+ cl_arg_types[6] = &ffi_type_float;
+ cl_arg_types[7] = &ffi_type_uint;
+ cl_arg_types[8] = &ffi_type_double;
+ cl_arg_types[9] = &ffi_type_uint;
+ cl_arg_types[10] = &ffi_type_uint;
+ cl_arg_types[11] = &ffi_type_float;
+ cl_arg_types[12] = &ffi_type_uint;
+ cl_arg_types[13] = &ffi_type_uint;
+ cl_arg_types[14] = &ffi_type_uint;
+ cl_arg_types[15] = &ffi_type_uint;
+ cl_arg_types[16] = NULL;
+
+ /* Initialize the cif */
+ CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 16,
+ &ffi_type_sint, cl_arg_types) == FFI_OK);
+
+ CHECK(ffi_prep_closure_loc(pcl, &cif, closure_test_fn1,
+ (void *) 3 /* userdata */, code) == FFI_OK);
+ try
+ {
+ (*((closure_test_type1)code))
+ (1.1, 2.2, 3.3, 4.4, 127, 5.5, 6.6, 8, 9, 10, 11, 12.0, 13,
+ 19, 21, 1);
+ /* { dg-output "\n1 2 3 4 127 5 6 8 9 10 11 12 13 19 21 1 3: 255" } */
+ } catch (int exception_code)
+ {
+ CHECK(exception_code == 255);
+ }
+ printf("part two OK\n");
+ /* { dg-output "\npart two OK" } */
+ }
+ exit(0);
+}
diff --git a/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/unwindtest_ffi_call.cc b/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/unwindtest_ffi_call.cc
new file mode 100644
index 0000000..ec61164
--- /dev/null
+++ b/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/unwindtest_ffi_call.cc
@@ -0,0 +1,54 @@
+/* Area: ffi_call, unwind info
+ Purpose: Check if the unwind information is passed correctly.
+ Limitations: none.
+ PR: none.
+ Originator: Andreas Tobler <andreast@gcc.gnu.org> 20061213 */
+
+/* { dg-do run } */
+
+#include "ffitest.h"
+
+static int checking(int a __UNUSED__, short b __UNUSED__,
+ signed char c __UNUSED__)
+{
+ throw 9;
+}
+
+int main (void)
+{
+ ffi_cif cif;
+ ffi_type *args[MAX_ARGS];
+ void *values[MAX_ARGS];
+ ffi_arg rint;
+
+ signed int si;
+ signed short ss;
+ signed char sc;
+
+ args[0] = &ffi_type_sint;
+ values[0] = &si;
+ args[1] = &ffi_type_sshort;
+ values[1] = &ss;
+ args[2] = &ffi_type_schar;
+ values[2] = &sc;
+
+ /* Initialize the cif */
+ CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 3,
+ &ffi_type_sint, args) == FFI_OK);
+
+ si = -6;
+ ss = -12;
+ sc = -1;
+ {
+ try
+ {
+ ffi_call(&cif, FFI_FN(checking), &rint, values);
+ } catch (int exception_code)
+ {
+ CHECK(exception_code == 9);
+ }
+ printf("part one OK\n");
+ /* { dg-output "part one OK" } */
+ }
+ exit(0);
+}
diff --git a/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/va_1.c b/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/va_1.c
new file mode 100644
index 0000000..7f96809
--- /dev/null
+++ b/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/va_1.c
@@ -0,0 +1,196 @@
+/* Area: ffi_call
+ Purpose: Test passing struct in variable argument lists.
+ Limitations: none.
+ PR: none.
+ Originator: ARM Ltd. */
+
+/* { dg-do run } */
+/* { dg-output "" { xfail avr32*-*-* } } */
+
+#include "ffitest.h"
+#include <stdarg.h>
+
+struct small_tag
+{
+ unsigned char a;
+ unsigned char b;
+};
+
+struct large_tag
+{
+ unsigned a;
+ unsigned b;
+ unsigned c;
+ unsigned d;
+ unsigned e;
+};
+
+static int
+test_fn (int n, ...)
+{
+ va_list ap;
+ struct small_tag s1;
+ struct small_tag s2;
+ struct large_tag l;
+ unsigned char uc;
+ signed char sc;
+ unsigned short us;
+ signed short ss;
+ unsigned int ui;
+ signed int si;
+ unsigned long ul;
+ signed long sl;
+ float f;
+ double d;
+
+ va_start (ap, n);
+ s1 = va_arg (ap, struct small_tag);
+ l = va_arg (ap, struct large_tag);
+ s2 = va_arg (ap, struct small_tag);
+
+ uc = va_arg (ap, unsigned);
+ sc = va_arg (ap, signed);
+
+ us = va_arg (ap, unsigned);
+ ss = va_arg (ap, signed);
+
+ ui = va_arg (ap, unsigned int);
+ si = va_arg (ap, signed int);
+
+ ul = va_arg (ap, unsigned long);
+ sl = va_arg (ap, signed long);
+
+ f = va_arg (ap, double); /* C standard promotes float->double
+ when anonymous */
+ d = va_arg (ap, double);
+
+ printf ("%u %u %u %u %u %u %u %u %u uc=%u sc=%d %u %d %u %d %lu %ld %f %f\n",
+ s1.a, s1.b, l.a, l.b, l.c, l.d, l.e,
+ s2.a, s2.b,
+ uc, sc,
+ us, ss,
+ ui, si,
+ ul, sl,
+ f, d);
+ va_end (ap);
+ return n + 1;
+}
+
+int
+main (void)
+{
+ ffi_cif cif;
+ void* args[15];
+ ffi_type* arg_types[15];
+
+ ffi_type s_type;
+ ffi_type *s_type_elements[3];
+
+ ffi_type l_type;
+ ffi_type *l_type_elements[6];
+
+ struct small_tag s1;
+ struct small_tag s2;
+ struct large_tag l1;
+
+ int n;
+ ffi_arg res;
+
+ unsigned char uc;
+ signed char sc;
+ unsigned short us;
+ signed short ss;
+ unsigned int ui;
+ signed int si;
+ unsigned long ul;
+ signed long sl;
+ double d1;
+ double f1;
+
+ s_type.size = 0;
+ s_type.alignment = 0;
+ s_type.type = FFI_TYPE_STRUCT;
+ s_type.elements = s_type_elements;
+
+ s_type_elements[0] = &ffi_type_uchar;
+ s_type_elements[1] = &ffi_type_uchar;
+ s_type_elements[2] = NULL;
+
+ l_type.size = 0;
+ l_type.alignment = 0;
+ l_type.type = FFI_TYPE_STRUCT;
+ l_type.elements = l_type_elements;
+
+ l_type_elements[0] = &ffi_type_uint;
+ l_type_elements[1] = &ffi_type_uint;
+ l_type_elements[2] = &ffi_type_uint;
+ l_type_elements[3] = &ffi_type_uint;
+ l_type_elements[4] = &ffi_type_uint;
+ l_type_elements[5] = NULL;
+
+ arg_types[0] = &ffi_type_sint;
+ arg_types[1] = &s_type;
+ arg_types[2] = &l_type;
+ arg_types[3] = &s_type;
+ arg_types[4] = &ffi_type_uchar;
+ arg_types[5] = &ffi_type_schar;
+ arg_types[6] = &ffi_type_ushort;
+ arg_types[7] = &ffi_type_sshort;
+ arg_types[8] = &ffi_type_uint;
+ arg_types[9] = &ffi_type_sint;
+ arg_types[10] = &ffi_type_ulong;
+ arg_types[11] = &ffi_type_slong;
+ arg_types[12] = &ffi_type_double;
+ arg_types[13] = &ffi_type_double;
+ arg_types[14] = NULL;
+
+ CHECK(ffi_prep_cif_var(&cif, FFI_DEFAULT_ABI, 1, 14, &ffi_type_sint, arg_types) == FFI_OK);
+
+ s1.a = 5;
+ s1.b = 6;
+
+ l1.a = 10;
+ l1.b = 11;
+ l1.c = 12;
+ l1.d = 13;
+ l1.e = 14;
+
+ s2.a = 7;
+ s2.b = 8;
+
+ n = 41;
+
+ uc = 9;
+ sc = 10;
+ us = 11;
+ ss = 12;
+ ui = 13;
+ si = 14;
+ ul = 15;
+ sl = 16;
+ f1 = 2.12;
+ d1 = 3.13;
+
+ args[0] = &n;
+ args[1] = &s1;
+ args[2] = &l1;
+ args[3] = &s2;
+ args[4] = &uc;
+ args[5] = &sc;
+ args[6] = &us;
+ args[7] = &ss;
+ args[8] = &ui;
+ args[9] = &si;
+ args[10] = &ul;
+ args[11] = &sl;
+ args[12] = &f1;
+ args[13] = &d1;
+ args[14] = NULL;
+
+ ffi_call(&cif, FFI_FN(test_fn), &res, args);
+ /* { dg-output "5 6 10 11 12 13 14 7 8 uc=9 sc=10 11 12 13 14 15 16 2.120000 3.130000" } */
+ printf("res: %d\n", (int) res);
+ /* { dg-output "\nres: 42" } */
+
+ return 0;
+}
diff --git a/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/va_struct1.c b/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/va_struct1.c
new file mode 100644
index 0000000..e645206
--- /dev/null
+++ b/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/va_struct1.c
@@ -0,0 +1,121 @@
+/* Area: ffi_call
+ Purpose: Test passing struct in variable argument lists.
+ Limitations: none.
+ PR: none.
+ Originator: ARM Ltd. */
+
+/* { dg-do run } */
+/* { dg-output "" { xfail avr32*-*-* } } */
+
+#include "ffitest.h"
+#include <stdarg.h>
+
+struct small_tag
+{
+ unsigned char a;
+ unsigned char b;
+};
+
+struct large_tag
+{
+ unsigned a;
+ unsigned b;
+ unsigned c;
+ unsigned d;
+ unsigned e;
+};
+
+static int
+test_fn (int n, ...)
+{
+ va_list ap;
+ struct small_tag s1;
+ struct small_tag s2;
+ struct large_tag l;
+
+ va_start (ap, n);
+ s1 = va_arg (ap, struct small_tag);
+ l = va_arg (ap, struct large_tag);
+ s2 = va_arg (ap, struct small_tag);
+ printf ("%u %u %u %u %u %u %u %u %u\n", s1.a, s1.b, l.a, l.b, l.c, l.d, l.e,
+ s2.a, s2.b);
+ va_end (ap);
+ return n + 1;
+}
+
+int
+main (void)
+{
+ ffi_cif cif;
+ void* args[5];
+ ffi_type* arg_types[5];
+
+ ffi_type s_type;
+ ffi_type *s_type_elements[3];
+
+ ffi_type l_type;
+ ffi_type *l_type_elements[6];
+
+ struct small_tag s1;
+ struct small_tag s2;
+ struct large_tag l1;
+
+ int n;
+ ffi_arg res;
+
+ s_type.size = 0;
+ s_type.alignment = 0;
+ s_type.type = FFI_TYPE_STRUCT;
+ s_type.elements = s_type_elements;
+
+ s_type_elements[0] = &ffi_type_uchar;
+ s_type_elements[1] = &ffi_type_uchar;
+ s_type_elements[2] = NULL;
+
+ l_type.size = 0;
+ l_type.alignment = 0;
+ l_type.type = FFI_TYPE_STRUCT;
+ l_type.elements = l_type_elements;
+
+ l_type_elements[0] = &ffi_type_uint;
+ l_type_elements[1] = &ffi_type_uint;
+ l_type_elements[2] = &ffi_type_uint;
+ l_type_elements[3] = &ffi_type_uint;
+ l_type_elements[4] = &ffi_type_uint;
+ l_type_elements[5] = NULL;
+
+ arg_types[0] = &ffi_type_sint;
+ arg_types[1] = &s_type;
+ arg_types[2] = &l_type;
+ arg_types[3] = &s_type;
+ arg_types[4] = NULL;
+
+ CHECK(ffi_prep_cif_var(&cif, FFI_DEFAULT_ABI, 1, 4, &ffi_type_sint, arg_types) == FFI_OK);
+
+ s1.a = 5;
+ s1.b = 6;
+
+ l1.a = 10;
+ l1.b = 11;
+ l1.c = 12;
+ l1.d = 13;
+ l1.e = 14;
+
+ s2.a = 7;
+ s2.b = 8;
+
+ n = 41;
+
+ args[0] = &n;
+ args[1] = &s1;
+ args[2] = &l1;
+ args[3] = &s2;
+ args[4] = NULL;
+
+ ffi_call(&cif, FFI_FN(test_fn), &res, args);
+ /* { dg-output "5 6 10 11 12 13 14 7 8" } */
+ printf("res: %d\n", (int) res);
+ /* { dg-output "\nres: 42" } */
+
+ return 0;
+}
diff --git a/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/va_struct2.c b/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/va_struct2.c
new file mode 100644
index 0000000..56f5b9c
--- /dev/null
+++ b/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/va_struct2.c
@@ -0,0 +1,123 @@
+/* Area: ffi_call
+ Purpose: Test passing struct in variable argument lists.
+ Limitations: none.
+ PR: none.
+ Originator: ARM Ltd. */
+
+/* { dg-do run } */
+/* { dg-output "" { xfail avr32*-*-* } } */
+
+#include "ffitest.h"
+#include <stdarg.h>
+
+struct small_tag
+{
+ unsigned char a;
+ unsigned char b;
+};
+
+struct large_tag
+{
+ unsigned a;
+ unsigned b;
+ unsigned c;
+ unsigned d;
+ unsigned e;
+};
+
+static struct small_tag
+test_fn (int n, ...)
+{
+ va_list ap;
+ struct small_tag s1;
+ struct small_tag s2;
+ struct large_tag l;
+
+ va_start (ap, n);
+ s1 = va_arg (ap, struct small_tag);
+ l = va_arg (ap, struct large_tag);
+ s2 = va_arg (ap, struct small_tag);
+ printf ("%u %u %u %u %u %u %u %u %u\n", s1.a, s1.b, l.a, l.b, l.c, l.d, l.e,
+ s2.a, s2.b);
+ va_end (ap);
+ s1.a += s2.a;
+ s1.b += s2.b;
+ return s1;
+}
+
+int
+main (void)
+{
+ ffi_cif cif;
+ void* args[5];
+ ffi_type* arg_types[5];
+
+ ffi_type s_type;
+ ffi_type *s_type_elements[3];
+
+ ffi_type l_type;
+ ffi_type *l_type_elements[6];
+
+ struct small_tag s1;
+ struct small_tag s2;
+ struct large_tag l1;
+
+ int n;
+ struct small_tag res;
+
+ s_type.size = 0;
+ s_type.alignment = 0;
+ s_type.type = FFI_TYPE_STRUCT;
+ s_type.elements = s_type_elements;
+
+ s_type_elements[0] = &ffi_type_uchar;
+ s_type_elements[1] = &ffi_type_uchar;
+ s_type_elements[2] = NULL;
+
+ l_type.size = 0;
+ l_type.alignment = 0;
+ l_type.type = FFI_TYPE_STRUCT;
+ l_type.elements = l_type_elements;
+
+ l_type_elements[0] = &ffi_type_uint;
+ l_type_elements[1] = &ffi_type_uint;
+ l_type_elements[2] = &ffi_type_uint;
+ l_type_elements[3] = &ffi_type_uint;
+ l_type_elements[4] = &ffi_type_uint;
+ l_type_elements[5] = NULL;
+
+ arg_types[0] = &ffi_type_sint;
+ arg_types[1] = &s_type;
+ arg_types[2] = &l_type;
+ arg_types[3] = &s_type;
+ arg_types[4] = NULL;
+
+ CHECK(ffi_prep_cif_var(&cif, FFI_DEFAULT_ABI, 1, 4, &s_type, arg_types) == FFI_OK);
+
+ s1.a = 5;
+ s1.b = 6;
+
+ l1.a = 10;
+ l1.b = 11;
+ l1.c = 12;
+ l1.d = 13;
+ l1.e = 14;
+
+ s2.a = 7;
+ s2.b = 8;
+
+ n = 41;
+
+ args[0] = &n;
+ args[1] = &s1;
+ args[2] = &l1;
+ args[3] = &s2;
+ args[4] = NULL;
+
+ ffi_call(&cif, FFI_FN(test_fn), &res, args);
+ /* { dg-output "5 6 10 11 12 13 14 7 8" } */
+ printf("res: %d %d\n", res.a, res.b);
+ /* { dg-output "\nres: 12 14" } */
+
+ return 0;
+}
diff --git a/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/va_struct3.c b/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/va_struct3.c
new file mode 100644
index 0000000..9a27e7f
--- /dev/null
+++ b/jni/ruby/ext/fiddle/libffi-3.2.1/testsuite/libffi.call/va_struct3.c
@@ -0,0 +1,125 @@
+/* Area: ffi_call
+ Purpose: Test passing struct in variable argument lists.
+ Limitations: none.
+ PR: none.
+ Originator: ARM Ltd. */
+
+/* { dg-do run } */
+/* { dg-output "" { xfail avr32*-*-* } } */
+
+#include "ffitest.h"
+#include <stdarg.h>
+
+struct small_tag
+{
+ unsigned char a;
+ unsigned char b;
+};
+
+struct large_tag
+{
+ unsigned a;
+ unsigned b;
+ unsigned c;
+ unsigned d;
+ unsigned e;
+};
+
+static struct large_tag
+test_fn (int n, ...)
+{
+ va_list ap;
+ struct small_tag s1;
+ struct small_tag s2;
+ struct large_tag l;
+
+ va_start (ap, n);
+ s1 = va_arg (ap, struct small_tag);
+ l = va_arg (ap, struct large_tag);
+ s2 = va_arg (ap, struct small_tag);
+ printf ("%u %u %u %u %u %u %u %u %u\n", s1.a, s1.b, l.a, l.b, l.c, l.d, l.e,
+ s2.a, s2.b);
+ va_end (ap);
+ l.a += s1.a;
+ l.b += s1.b;
+ l.c += s2.a;
+ l.d += s2.b;
+ return l;
+}
+
+int
+main (void)
+{
+ ffi_cif cif;
+ void* args[5];
+ ffi_type* arg_types[5];
+
+ ffi_type s_type;
+ ffi_type *s_type_elements[3];
+
+ ffi_type l_type;
+ ffi_type *l_type_elements[6];
+
+ struct small_tag s1;
+ struct small_tag s2;
+ struct large_tag l1;
+
+ int n;
+ struct large_tag res;
+
+ s_type.size = 0;
+ s_type.alignment = 0;
+ s_type.type = FFI_TYPE_STRUCT;
+ s_type.elements = s_type_elements;
+
+ s_type_elements[0] = &ffi_type_uchar;
+ s_type_elements[1] = &ffi_type_uchar;
+ s_type_elements[2] = NULL;
+
+ l_type.size = 0;
+ l_type.alignment = 0;
+ l_type.type = FFI_TYPE_STRUCT;
+ l_type.elements = l_type_elements;
+
+ l_type_elements[0] = &ffi_type_uint;
+ l_type_elements[1] = &ffi_type_uint;
+ l_type_elements[2] = &ffi_type_uint;
+ l_type_elements[3] = &ffi_type_uint;
+ l_type_elements[4] = &ffi_type_uint;
+ l_type_elements[5] = NULL;
+
+ arg_types[0] = &ffi_type_sint;
+ arg_types[1] = &s_type;
+ arg_types[2] = &l_type;
+ arg_types[3] = &s_type;
+ arg_types[4] = NULL;
+
+ CHECK(ffi_prep_cif_var(&cif, FFI_DEFAULT_ABI, 1, 4, &l_type, arg_types) == FFI_OK);
+
+ s1.a = 5;
+ s1.b = 6;
+
+ l1.a = 10;
+ l1.b = 11;
+ l1.c = 12;
+ l1.d = 13;
+ l1.e = 14;
+
+ s2.a = 7;
+ s2.b = 8;
+
+ n = 41;
+
+ args[0] = &n;
+ args[1] = &s1;
+ args[2] = &l1;
+ args[3] = &s2;
+ args[4] = NULL;
+
+ ffi_call(&cif, FFI_FN(test_fn), &res, args);
+ /* { dg-output "5 6 10 11 12 13 14 7 8" } */
+ printf("res: %d %d %d %d %d\n", res.a, res.b, res.c, res.d, res.e);
+ /* { dg-output "\nres: 15 17 19 21 14" } */
+
+ return 0;
+}
diff --git a/jni/ruby/ext/fiddle/libffi-3.2.1/texinfo.tex b/jni/ruby/ext/fiddle/libffi-3.2.1/texinfo.tex
new file mode 100644
index 0000000..85f184c
--- /dev/null
+++ b/jni/ruby/ext/fiddle/libffi-3.2.1/texinfo.tex
@@ -0,0 +1,10079 @@
+% texinfo.tex -- TeX macros to handle Texinfo files.
+%
+% Load plain if necessary, i.e., if running under initex.
+\expandafter\ifx\csname fmtname\endcsname\relax\input plain\fi
+%
+\def\texinfoversion{2013-02-01.11}
+%
+% Copyright 1985, 1986, 1988, 1990, 1991, 1992, 1993, 1994, 1995,
+% 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006,
+% 2007, 2008, 2009, 2010, 2011, 2012, 2013 Free Software Foundation, Inc.
+%
+% This texinfo.tex file is free software: you can redistribute it and/or
+% modify it under the terms of the GNU General Public License as
+% published by the Free Software Foundation, either version 3 of the
+% License, or (at your option) any later version.
+%
+% This texinfo.tex file 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, see <http://www.gnu.org/licenses/>.
+%
+% As a special exception, when this file is read by TeX when processing
+% a Texinfo source document, you may use the result without
+% restriction. This Exception is an additional permission under section 7
+% of the GNU General Public License, version 3 ("GPLv3").
+%
+% Please try the latest version of texinfo.tex before submitting bug
+% reports; you can get the latest version from:
+% http://ftp.gnu.org/gnu/texinfo/ (the Texinfo release area), or
+% http://ftpmirror.gnu.org/texinfo/ (same, via a mirror), or
+% http://www.gnu.org/software/texinfo/ (the Texinfo home page)
+% The texinfo.tex in any given distribution could well be out
+% of date, so if that's what you're using, please check.
+%
+% Send bug reports to bug-texinfo@gnu.org. Please include including a
+% complete document in each bug report with which we can reproduce the
+% problem. Patches are, of course, greatly appreciated.
+%
+% To process a Texinfo manual with TeX, it's most reliable to use the
+% texi2dvi shell script that comes with the distribution. For a simple
+% manual foo.texi, however, you can get away with this:
+% tex foo.texi
+% texindex foo.??
+% tex foo.texi
+% tex foo.texi
+% dvips foo.dvi -o # or whatever; this makes foo.ps.
+% The extra TeX runs get the cross-reference information correct.
+% Sometimes one run after texindex suffices, and sometimes you need more
+% than two; texi2dvi does it as many times as necessary.
+%
+% It is possible to adapt texinfo.tex for other languages, to some
+% extent. You can get the existing language-specific files from the
+% full Texinfo distribution.
+%
+% The GNU Texinfo home page is http://www.gnu.org/software/texinfo.
+
+
+\message{Loading texinfo [version \texinfoversion]:}
+
+% If in a .fmt file, print the version number
+% and turn on active characters that we couldn't do earlier because
+% they might have appeared in the input file name.
+\everyjob{\message{[Texinfo version \texinfoversion]}%
+ \catcode`+=\active \catcode`\_=\active}
+
+\chardef\other=12
+
+% We never want plain's \outer definition of \+ in Texinfo.
+% For @tex, we can use \tabalign.
+\let\+ = \relax
+
+% Save some plain tex macros whose names we will redefine.
+\let\ptexb=\b
+\let\ptexbullet=\bullet
+\let\ptexc=\c
+\let\ptexcomma=\,
+\let\ptexdot=\.
+\let\ptexdots=\dots
+\let\ptexend=\end
+\let\ptexequiv=\equiv
+\let\ptexexclam=\!
+\let\ptexfootnote=\footnote
+\let\ptexgtr=>
+\let\ptexhat=^
+\let\ptexi=\i
+\let\ptexindent=\indent
+\let\ptexinsert=\insert
+\let\ptexlbrace=\{
+\let\ptexless=<
+\let\ptexnewwrite\newwrite
+\let\ptexnoindent=\noindent
+\let\ptexplus=+
+\let\ptexraggedright=\raggedright
+\let\ptexrbrace=\}
+\let\ptexslash=\/
+\let\ptexstar=\*
+\let\ptext=\t
+\let\ptextop=\top
+{\catcode`\'=\active \global\let\ptexquoteright'}% active in plain's math mode
+
+% If this character appears in an error message or help string, it
+% starts a new line in the output.
+\newlinechar = `^^J
+
+% Use TeX 3.0's \inputlineno to get the line number, for better error
+% messages, but if we're using an old version of TeX, don't do anything.
+%
+\ifx\inputlineno\thisisundefined
+ \let\linenumber = \empty % Pre-3.0.
+\else
+ \def\linenumber{l.\the\inputlineno:\space}
+\fi
+
+% Set up fixed words for English if not already set.
+\ifx\putwordAppendix\undefined \gdef\putwordAppendix{Appendix}\fi
+\ifx\putwordChapter\undefined \gdef\putwordChapter{Chapter}\fi
+\ifx\putworderror\undefined \gdef\putworderror{error}\fi
+\ifx\putwordfile\undefined \gdef\putwordfile{file}\fi
+\ifx\putwordin\undefined \gdef\putwordin{in}\fi
+\ifx\putwordIndexIsEmpty\undefined \gdef\putwordIndexIsEmpty{(Index is empty)}\fi
+\ifx\putwordIndexNonexistent\undefined \gdef\putwordIndexNonexistent{(Index is nonexistent)}\fi
+\ifx\putwordInfo\undefined \gdef\putwordInfo{Info}\fi
+\ifx\putwordInstanceVariableof\undefined \gdef\putwordInstanceVariableof{Instance Variable of}\fi
+\ifx\putwordMethodon\undefined \gdef\putwordMethodon{Method on}\fi
+\ifx\putwordNoTitle\undefined \gdef\putwordNoTitle{No Title}\fi
+\ifx\putwordof\undefined \gdef\putwordof{of}\fi
+\ifx\putwordon\undefined \gdef\putwordon{on}\fi
+\ifx\putwordpage\undefined \gdef\putwordpage{page}\fi
+\ifx\putwordsection\undefined \gdef\putwordsection{section}\fi
+\ifx\putwordSection\undefined \gdef\putwordSection{Section}\fi
+\ifx\putwordsee\undefined \gdef\putwordsee{see}\fi
+\ifx\putwordSee\undefined \gdef\putwordSee{See}\fi
+\ifx\putwordShortTOC\undefined \gdef\putwordShortTOC{Short Contents}\fi
+\ifx\putwordTOC\undefined \gdef\putwordTOC{Table of Contents}\fi
+%
+\ifx\putwordMJan\undefined \gdef\putwordMJan{January}\fi
+\ifx\putwordMFeb\undefined \gdef\putwordMFeb{February}\fi
+\ifx\putwordMMar\undefined \gdef\putwordMMar{March}\fi
+\ifx\putwordMApr\undefined \gdef\putwordMApr{April}\fi
+\ifx\putwordMMay\undefined \gdef\putwordMMay{May}\fi
+\ifx\putwordMJun\undefined \gdef\putwordMJun{June}\fi
+\ifx\putwordMJul\undefined \gdef\putwordMJul{July}\fi
+\ifx\putwordMAug\undefined \gdef\putwordMAug{August}\fi
+\ifx\putwordMSep\undefined \gdef\putwordMSep{September}\fi
+\ifx\putwordMOct\undefined \gdef\putwordMOct{October}\fi
+\ifx\putwordMNov\undefined \gdef\putwordMNov{November}\fi
+\ifx\putwordMDec\undefined \gdef\putwordMDec{December}\fi
+%
+\ifx\putwordDefmac\undefined \gdef\putwordDefmac{Macro}\fi
+\ifx\putwordDefspec\undefined \gdef\putwordDefspec{Special Form}\fi
+\ifx\putwordDefvar\undefined \gdef\putwordDefvar{Variable}\fi
+\ifx\putwordDefopt\undefined \gdef\putwordDefopt{User Option}\fi
+\ifx\putwordDeffunc\undefined \gdef\putwordDeffunc{Function}\fi
+
+% Since the category of space is not known, we have to be careful.
+\chardef\spacecat = 10
+\def\spaceisspace{\catcode`\ =\spacecat}
+
+% sometimes characters are active, so we need control sequences.
+\chardef\ampChar = `\&
+\chardef\colonChar = `\:
+\chardef\commaChar = `\,
+\chardef\dashChar = `\-
+\chardef\dotChar = `\.
+\chardef\exclamChar= `\!
+\chardef\hashChar = `\#
+\chardef\lquoteChar= `\`
+\chardef\questChar = `\?
+\chardef\rquoteChar= `\'
+\chardef\semiChar = `\;
+\chardef\slashChar = `\/
+\chardef\underChar = `\_
+
+% Ignore a token.
+%
+\def\gobble#1{}
+
+% The following is used inside several \edef's.
+\def\makecsname#1{\expandafter\noexpand\csname#1\endcsname}
+
+% Hyphenation fixes.
+\hyphenation{
+ Flor-i-da Ghost-script Ghost-view Mac-OS Post-Script
+ ap-pen-dix bit-map bit-maps
+ data-base data-bases eshell fall-ing half-way long-est man-u-script
+ man-u-scripts mini-buf-fer mini-buf-fers over-view par-a-digm
+ par-a-digms rath-er rec-tan-gu-lar ro-bot-ics se-vere-ly set-up spa-ces
+ spell-ing spell-ings
+ stand-alone strong-est time-stamp time-stamps which-ever white-space
+ wide-spread wrap-around
+}
+
+% Margin to add to right of even pages, to left of odd pages.
+\newdimen\bindingoffset
+\newdimen\normaloffset
+\newdimen\pagewidth \newdimen\pageheight
+
+% For a final copy, take out the rectangles
+% that mark overfull boxes (in case you have decided
+% that the text looks ok even though it passes the margin).
+%
+\def\finalout{\overfullrule=0pt }
+
+% Sometimes it is convenient to have everything in the transcript file
+% and nothing on the terminal. We don't just call \tracingall here,
+% since that produces some useless output on the terminal. We also make
+% some effort to order the tracing commands to reduce output in the log
+% file; cf. trace.sty in LaTeX.
+%
+\def\gloggingall{\begingroup \globaldefs = 1 \loggingall \endgroup}%
+\def\loggingall{%
+ \tracingstats2
+ \tracingpages1
+ \tracinglostchars2 % 2 gives us more in etex
+ \tracingparagraphs1
+ \tracingoutput1
+ \tracingmacros2
+ \tracingrestores1
+ \showboxbreadth\maxdimen \showboxdepth\maxdimen
+ \ifx\eTeXversion\thisisundefined\else % etex gives us more logging
+ \tracingscantokens1
+ \tracingifs1
+ \tracinggroups1
+ \tracingnesting2
+ \tracingassigns1
+ \fi
+ \tracingcommands3 % 3 gives us more in etex
+ \errorcontextlines16
+}%
+
+% @errormsg{MSG}. Do the index-like expansions on MSG, but if things
+% aren't perfect, it's not the end of the world, being an error message,
+% after all.
+%
+\def\errormsg{\begingroup \indexnofonts \doerrormsg}
+\def\doerrormsg#1{\errmessage{#1}}
+
+% add check for \lastpenalty to plain's definitions. If the last thing
+% we did was a \nobreak, we don't want to insert more space.
+%
+\def\smallbreak{\ifnum\lastpenalty<10000\par\ifdim\lastskip<\smallskipamount
+ \removelastskip\penalty-50\smallskip\fi\fi}
+\def\medbreak{\ifnum\lastpenalty<10000\par\ifdim\lastskip<\medskipamount
+ \removelastskip\penalty-100\medskip\fi\fi}
+\def\bigbreak{\ifnum\lastpenalty<10000\par\ifdim\lastskip<\bigskipamount
+ \removelastskip\penalty-200\bigskip\fi\fi}
+
+% Do @cropmarks to get crop marks.
+%
+\newif\ifcropmarks
+\let\cropmarks = \cropmarkstrue
+%
+% Dimensions to add cropmarks at corners.
+% Added by P. A. MacKay, 12 Nov. 1986
+%
+\newdimen\outerhsize \newdimen\outervsize % set by the paper size routines
+\newdimen\cornerlong \cornerlong=1pc
+\newdimen\cornerthick \cornerthick=.3pt
+\newdimen\topandbottommargin \topandbottommargin=.75in
+
+% Output a mark which sets \thischapter, \thissection and \thiscolor.
+% We dump everything together because we only have one kind of mark.
+% This works because we only use \botmark / \topmark, not \firstmark.
+%
+% A mark contains a subexpression of the \ifcase ... \fi construct.
+% \get*marks macros below extract the needed part using \ifcase.
+%
+% Another complication is to let the user choose whether \thischapter
+% (\thissection) refers to the chapter (section) in effect at the top
+% of a page, or that at the bottom of a page. The solution is
+% described on page 260 of The TeXbook. It involves outputting two
+% marks for the sectioning macros, one before the section break, and
+% one after. I won't pretend I can describe this better than DEK...
+\def\domark{%
+ \toks0=\expandafter{\lastchapterdefs}%
+ \toks2=\expandafter{\lastsectiondefs}%
+ \toks4=\expandafter{\prevchapterdefs}%
+ \toks6=\expandafter{\prevsectiondefs}%
+ \toks8=\expandafter{\lastcolordefs}%
+ \mark{%
+ \the\toks0 \the\toks2
+ \noexpand\or \the\toks4 \the\toks6
+ \noexpand\else \the\toks8
+ }%
+}
+% \topmark doesn't work for the very first chapter (after the title
+% page or the contents), so we use \firstmark there -- this gets us
+% the mark with the chapter defs, unless the user sneaks in, e.g.,
+% @setcolor (or @url, or @link, etc.) between @contents and the very
+% first @chapter.
+\def\gettopheadingmarks{%
+ \ifcase0\topmark\fi
+ \ifx\thischapter\empty \ifcase0\firstmark\fi \fi
+}
+\def\getbottomheadingmarks{\ifcase1\botmark\fi}
+\def\getcolormarks{\ifcase2\topmark\fi}
+
+% Avoid "undefined control sequence" errors.
+\def\lastchapterdefs{}
+\def\lastsectiondefs{}
+\def\prevchapterdefs{}
+\def\prevsectiondefs{}
+\def\lastcolordefs{}
+
+% Main output routine.
+\chardef\PAGE = 255
+\output = {\onepageout{\pagecontents\PAGE}}
+
+\newbox\headlinebox
+\newbox\footlinebox
+
+% \onepageout takes a vbox as an argument. Note that \pagecontents
+% does insertions, but you have to call it yourself.
+\def\onepageout#1{%
+ \ifcropmarks \hoffset=0pt \else \hoffset=\normaloffset \fi
+ %
+ \ifodd\pageno \advance\hoffset by \bindingoffset
+ \else \advance\hoffset by -\bindingoffset\fi
+ %
+ % Do this outside of the \shipout so @code etc. will be expanded in
+ % the headline as they should be, not taken literally (outputting ''code).
+ \ifodd\pageno \getoddheadingmarks \else \getevenheadingmarks \fi
+ \setbox\headlinebox = \vbox{\let\hsize=\pagewidth \makeheadline}%
+ \ifodd\pageno \getoddfootingmarks \else \getevenfootingmarks \fi
+ \setbox\footlinebox = \vbox{\let\hsize=\pagewidth \makefootline}%
+ %
+ {%
+ % Have to do this stuff outside the \shipout because we want it to
+ % take effect in \write's, yet the group defined by the \vbox ends
+ % before the \shipout runs.
+ %
+ \indexdummies % don't expand commands in the output.
+ \normalturnoffactive % \ in index entries must not stay \, e.g., if
+ % the page break happens to be in the middle of an example.
+ % We don't want .vr (or whatever) entries like this:
+ % \entry{{\tt \indexbackslash }acronym}{32}{\code {\acronym}}
+ % "\acronym" won't work when it's read back in;
+ % it needs to be
+ % {\code {{\tt \backslashcurfont }acronym}
+ \shipout\vbox{%
+ % Do this early so pdf references go to the beginning of the page.
+ \ifpdfmakepagedest \pdfdest name{\the\pageno} xyz\fi
+ %
+ \ifcropmarks \vbox to \outervsize\bgroup
+ \hsize = \outerhsize
+ \vskip-\topandbottommargin
+ \vtop to0pt{%
+ \line{\ewtop\hfil\ewtop}%
+ \nointerlineskip
+ \line{%
+ \vbox{\moveleft\cornerthick\nstop}%
+ \hfill
+ \vbox{\moveright\cornerthick\nstop}%
+ }%
+ \vss}%
+ \vskip\topandbottommargin
+ \line\bgroup
+ \hfil % center the page within the outer (page) hsize.
+ \ifodd\pageno\hskip\bindingoffset\fi
+ \vbox\bgroup
+ \fi
+ %
+ \unvbox\headlinebox
+ \pagebody{#1}%
+ \ifdim\ht\footlinebox > 0pt
+ % Only leave this space if the footline is nonempty.
+ % (We lessened \vsize for it in \oddfootingyyy.)
+ % The \baselineskip=24pt in plain's \makefootline has no effect.
+ \vskip 24pt
+ \unvbox\footlinebox
+ \fi
+ %
+ \ifcropmarks
+ \egroup % end of \vbox\bgroup
+ \hfil\egroup % end of (centering) \line\bgroup
+ \vskip\topandbottommargin plus1fill minus1fill
+ \boxmaxdepth = \cornerthick
+ \vbox to0pt{\vss
+ \line{%
+ \vbox{\moveleft\cornerthick\nsbot}%
+ \hfill
+ \vbox{\moveright\cornerthick\nsbot}%
+ }%
+ \nointerlineskip
+ \line{\ewbot\hfil\ewbot}%
+ }%
+ \egroup % \vbox from first cropmarks clause
+ \fi
+ }% end of \shipout\vbox
+ }% end of group with \indexdummies
+ \advancepageno
+ \ifnum\outputpenalty>-20000 \else\dosupereject\fi
+}
+
+\newinsert\margin \dimen\margin=\maxdimen
+
+\def\pagebody#1{\vbox to\pageheight{\boxmaxdepth=\maxdepth #1}}
+{\catcode`\@ =11
+\gdef\pagecontents#1{\ifvoid\topins\else\unvbox\topins\fi
+% marginal hacks, juha@viisa.uucp (Juha Takala)
+\ifvoid\margin\else % marginal info is present
+ \rlap{\kern\hsize\vbox to\z@{\kern1pt\box\margin \vss}}\fi
+\dimen@=\dp#1\relax \unvbox#1\relax
+\ifvoid\footins\else\vskip\skip\footins\footnoterule \unvbox\footins\fi
+\ifr@ggedbottom \kern-\dimen@ \vfil \fi}
+}
+
+% Here are the rules for the cropmarks. Note that they are
+% offset so that the space between them is truly \outerhsize or \outervsize
+% (P. A. MacKay, 12 November, 1986)
+%
+\def\ewtop{\vrule height\cornerthick depth0pt width\cornerlong}
+\def\nstop{\vbox
+ {\hrule height\cornerthick depth\cornerlong width\cornerthick}}
+\def\ewbot{\vrule height0pt depth\cornerthick width\cornerlong}
+\def\nsbot{\vbox
+ {\hrule height\cornerlong depth\cornerthick width\cornerthick}}
+
+% Parse an argument, then pass it to #1. The argument is the rest of
+% the input line (except we remove a trailing comment). #1 should be a
+% macro which expects an ordinary undelimited TeX argument.
+%
+\def\parsearg{\parseargusing{}}
+\def\parseargusing#1#2{%
+ \def\argtorun{#2}%
+ \begingroup
+ \obeylines
+ \spaceisspace
+ #1%
+ \parseargline\empty% Insert the \empty token, see \finishparsearg below.
+}
+
+{\obeylines %
+ \gdef\parseargline#1^^M{%
+ \endgroup % End of the group started in \parsearg.
+ \argremovecomment #1\comment\ArgTerm%
+ }%
+}
+
+% First remove any @comment, then any @c comment.
+\def\argremovecomment#1\comment#2\ArgTerm{\argremovec #1\c\ArgTerm}
+\def\argremovec#1\c#2\ArgTerm{\argcheckspaces#1\^^M\ArgTerm}
+
+% Each occurrence of `\^^M' or `<space>\^^M' is replaced by a single space.
+%
+% \argremovec might leave us with trailing space, e.g.,
+% @end itemize @c foo
+% This space token undergoes the same procedure and is eventually removed
+% by \finishparsearg.
+%
+\def\argcheckspaces#1\^^M{\argcheckspacesX#1\^^M \^^M}
+\def\argcheckspacesX#1 \^^M{\argcheckspacesY#1\^^M}
+\def\argcheckspacesY#1\^^M#2\^^M#3\ArgTerm{%
+ \def\temp{#3}%
+ \ifx\temp\empty
+ % Do not use \next, perhaps the caller of \parsearg uses it; reuse \temp:
+ \let\temp\finishparsearg
+ \else
+ \let\temp\argcheckspaces
+ \fi
+ % Put the space token in:
+ \temp#1 #3\ArgTerm
+}
+
+% If a _delimited_ argument is enclosed in braces, they get stripped; so
+% to get _exactly_ the rest of the line, we had to prevent such situation.
+% We prepended an \empty token at the very beginning and we expand it now,
+% just before passing the control to \argtorun.
+% (Similarly, we have to think about #3 of \argcheckspacesY above: it is
+% either the null string, or it ends with \^^M---thus there is no danger
+% that a pair of braces would be stripped.
+%
+% But first, we have to remove the trailing space token.
+%
+\def\finishparsearg#1 \ArgTerm{\expandafter\argtorun\expandafter{#1}}
+
+% \parseargdef\foo{...}
+% is roughly equivalent to
+% \def\foo{\parsearg\Xfoo}
+% \def\Xfoo#1{...}
+%
+% Actually, I use \csname\string\foo\endcsname, ie. \\foo, as it is my
+% favourite TeX trick. --kasal, 16nov03
+
+\def\parseargdef#1{%
+ \expandafter \doparseargdef \csname\string#1\endcsname #1%
+}
+\def\doparseargdef#1#2{%
+ \def#2{\parsearg#1}%
+ \def#1##1%
+}
+
+% Several utility definitions with active space:
+{
+ \obeyspaces
+ \gdef\obeyedspace{ }
+
+ % Make each space character in the input produce a normal interword
+ % space in the output. Don't allow a line break at this space, as this
+ % is used only in environments like @example, where each line of input
+ % should produce a line of output anyway.
+ %
+ \gdef\sepspaces{\obeyspaces\let =\tie}
+
+ % If an index command is used in an @example environment, any spaces
+ % therein should become regular spaces in the raw index file, not the
+ % expansion of \tie (\leavevmode \penalty \@M \ ).
+ \gdef\unsepspaces{\let =\space}
+}
+
+
+\def\flushcr{\ifx\par\lisppar \def\next##1{}\else \let\next=\relax \fi \next}
+
+% Define the framework for environments in texinfo.tex. It's used like this:
+%
+% \envdef\foo{...}
+% \def\Efoo{...}
+%
+% It's the responsibility of \envdef to insert \begingroup before the
+% actual body; @end closes the group after calling \Efoo. \envdef also
+% defines \thisenv, so the current environment is known; @end checks
+% whether the environment name matches. The \checkenv macro can also be
+% used to check whether the current environment is the one expected.
+%
+% Non-false conditionals (@iftex, @ifset) don't fit into this, so they
+% are not treated as environments; they don't open a group. (The
+% implementation of @end takes care not to call \endgroup in this
+% special case.)
+
+
+% At run-time, environments start with this:
+\def\startenvironment#1{\begingroup\def\thisenv{#1}}
+% initialize
+\let\thisenv\empty
+
+% ... but they get defined via ``\envdef\foo{...}'':
+\long\def\envdef#1#2{\def#1{\startenvironment#1#2}}
+\def\envparseargdef#1#2{\parseargdef#1{\startenvironment#1#2}}
+
+% Check whether we're in the right environment:
+\def\checkenv#1{%
+ \def\temp{#1}%
+ \ifx\thisenv\temp
+ \else
+ \badenverr
+ \fi
+}
+
+% Environment mismatch, #1 expected:
+\def\badenverr{%
+ \errhelp = \EMsimple
+ \errmessage{This command can appear only \inenvironment\temp,
+ not \inenvironment\thisenv}%
+}
+\def\inenvironment#1{%
+ \ifx#1\empty
+ outside of any environment%
+ \else
+ in environment \expandafter\string#1%
+ \fi
+}
+
+% @end foo executes the definition of \Efoo.
+% But first, it executes a specialized version of \checkenv
+%
+\parseargdef\end{%
+ \if 1\csname iscond.#1\endcsname
+ \else
+ % The general wording of \badenverr may not be ideal.
+ \expandafter\checkenv\csname#1\endcsname
+ \csname E#1\endcsname
+ \endgroup
+ \fi
+}
+
+\newhelp\EMsimple{Press RETURN to continue.}
+
+
+% Be sure we're in horizontal mode when doing a tie, since we make space
+% equivalent to this in @example-like environments. Otherwise, a space
+% at the beginning of a line will start with \penalty -- and
+% since \penalty is valid in vertical mode, we'd end up putting the
+% penalty on the vertical list instead of in the new paragraph.
+{\catcode`@ = 11
+ % Avoid using \@M directly, because that causes trouble
+ % if the definition is written into an index file.
+ \global\let\tiepenalty = \@M
+ \gdef\tie{\leavevmode\penalty\tiepenalty\ }
+}
+
+% @: forces normal size whitespace following.
+\def\:{\spacefactor=1000 }
+
+% @* forces a line break.
+\def\*{\unskip\hfil\break\hbox{}\ignorespaces}
+
+% @/ allows a line break.
+\let\/=\allowbreak
+
+% @. is an end-of-sentence period.
+\def\.{.\spacefactor=\endofsentencespacefactor\space}
+
+% @! is an end-of-sentence bang.
+\def\!{!\spacefactor=\endofsentencespacefactor\space}
+
+% @? is an end-of-sentence query.
+\def\?{?\spacefactor=\endofsentencespacefactor\space}
+
+% @frenchspacing on|off says whether to put extra space after punctuation.
+%
+\def\onword{on}
+\def\offword{off}
+%
+\parseargdef\frenchspacing{%
+ \def\temp{#1}%
+ \ifx\temp\onword \plainfrenchspacing
+ \else\ifx\temp\offword \plainnonfrenchspacing
+ \else
+ \errhelp = \EMsimple
+ \errmessage{Unknown @frenchspacing option `\temp', must be on|off}%
+ \fi\fi
+}
+
+% @w prevents a word break. Without the \leavevmode, @w at the
+% beginning of a paragraph, when TeX is still in vertical mode, would
+% produce a whole line of output instead of starting the paragraph.
+\def\w#1{\leavevmode\hbox{#1}}
+
+% @group ... @end group forces ... to be all on one page, by enclosing
+% it in a TeX vbox. We use \vtop instead of \vbox to construct the box
+% to keep its height that of a normal line. According to the rules for
+% \topskip (p.114 of the TeXbook), the glue inserted is
+% max (\topskip - \ht (first item), 0). If that height is large,
+% therefore, no glue is inserted, and the space between the headline and
+% the text is small, which looks bad.
+%
+% Another complication is that the group might be very large. This can
+% cause the glue on the previous page to be unduly stretched, because it
+% does not have much material. In this case, it's better to add an
+% explicit \vfill so that the extra space is at the bottom. The
+% threshold for doing this is if the group is more than \vfilllimit
+% percent of a page (\vfilllimit can be changed inside of @tex).
+%
+\newbox\groupbox
+\def\vfilllimit{0.7}
+%
+\envdef\group{%
+ \ifnum\catcode`\^^M=\active \else
+ \errhelp = \groupinvalidhelp
+ \errmessage{@group invalid in context where filling is enabled}%
+ \fi
+ \startsavinginserts
+ %
+ \setbox\groupbox = \vtop\bgroup
+ % Do @comment since we are called inside an environment such as
+ % @example, where each end-of-line in the input causes an
+ % end-of-line in the output. We don't want the end-of-line after
+ % the `@group' to put extra space in the output. Since @group
+ % should appear on a line by itself (according to the Texinfo
+ % manual), we don't worry about eating any user text.
+ \comment
+}
+%
+% The \vtop produces a box with normal height and large depth; thus, TeX puts
+% \baselineskip glue before it, and (when the next line of text is done)
+% \lineskip glue after it. Thus, space below is not quite equal to space
+% above. But it's pretty close.
+\def\Egroup{%
+ % To get correct interline space between the last line of the group
+ % and the first line afterwards, we have to propagate \prevdepth.
+ \endgraf % Not \par, as it may have been set to \lisppar.
+ \global\dimen1 = \prevdepth
+ \egroup % End the \vtop.
+ % \dimen0 is the vertical size of the group's box.
+ \dimen0 = \ht\groupbox \advance\dimen0 by \dp\groupbox
+ % \dimen2 is how much space is left on the page (more or less).
+ \dimen2 = \pageheight \advance\dimen2 by -\pagetotal
+ % if the group doesn't fit on the current page, and it's a big big
+ % group, force a page break.
+ \ifdim \dimen0 > \dimen2
+ \ifdim \pagetotal < \vfilllimit\pageheight
+ \page
+ \fi
+ \fi
+ \box\groupbox
+ \prevdepth = \dimen1
+ \checkinserts
+}
+%
+% TeX puts in an \escapechar (i.e., `@') at the beginning of the help
+% message, so this ends up printing `@group can only ...'.
+%
+\newhelp\groupinvalidhelp{%
+group can only be used in environments such as @example,^^J%
+where each line of input produces a line of output.}
+
+% @need space-in-mils
+% forces a page break if there is not space-in-mils remaining.
+
+\newdimen\mil \mil=0.001in
+
+\parseargdef\need{%
+ % Ensure vertical mode, so we don't make a big box in the middle of a
+ % paragraph.
+ \par
+ %
+ % If the @need value is less than one line space, it's useless.
+ \dimen0 = #1\mil
+ \dimen2 = \ht\strutbox
+ \advance\dimen2 by \dp\strutbox
+ \ifdim\dimen0 > \dimen2
+ %
+ % Do a \strut just to make the height of this box be normal, so the
+ % normal leading is inserted relative to the preceding line.
+ % And a page break here is fine.
+ \vtop to #1\mil{\strut\vfil}%
+ %
+ % TeX does not even consider page breaks if a penalty added to the
+ % main vertical list is 10000 or more. But in order to see if the
+ % empty box we just added fits on the page, we must make it consider
+ % page breaks. On the other hand, we don't want to actually break the
+ % page after the empty box. So we use a penalty of 9999.
+ %
+ % There is an extremely small chance that TeX will actually break the
+ % page at this \penalty, if there are no other feasible breakpoints in
+ % sight. (If the user is using lots of big @group commands, which
+ % almost-but-not-quite fill up a page, TeX will have a hard time doing
+ % good page breaking, for example.) However, I could not construct an
+ % example where a page broke at this \penalty; if it happens in a real
+ % document, then we can reconsider our strategy.
+ \penalty9999
+ %
+ % Back up by the size of the box, whether we did a page break or not.
+ \kern -#1\mil
+ %
+ % Do not allow a page break right after this kern.
+ \nobreak
+ \fi
+}
+
+% @br forces paragraph break (and is undocumented).
+
+\let\br = \par
+
+% @page forces the start of a new page.
+%
+\def\page{\par\vfill\supereject}
+
+% @exdent text....
+% outputs text on separate line in roman font, starting at standard page margin
+
+% This records the amount of indent in the innermost environment.
+% That's how much \exdent should take out.
+\newskip\exdentamount
+
+% This defn is used inside fill environments such as @defun.
+\parseargdef\exdent{\hfil\break\hbox{\kern -\exdentamount{\rm#1}}\hfil\break}
+
+% This defn is used inside nofill environments such as @example.
+\parseargdef\nofillexdent{{\advance \leftskip by -\exdentamount
+ \leftline{\hskip\leftskip{\rm#1}}}}
+
+% @inmargin{WHICH}{TEXT} puts TEXT in the WHICH margin next to the current
+% paragraph. For more general purposes, use the \margin insertion
+% class. WHICH is `l' or `r'. Not documented, written for gawk manual.
+%
+\newskip\inmarginspacing \inmarginspacing=1cm
+\def\strutdepth{\dp\strutbox}
+%
+\def\doinmargin#1#2{\strut\vadjust{%
+ \nobreak
+ \kern-\strutdepth
+ \vtop to \strutdepth{%
+ \baselineskip=\strutdepth
+ \vss
+ % if you have multiple lines of stuff to put here, you'll need to
+ % make the vbox yourself of the appropriate size.
+ \ifx#1l%
+ \llap{\ignorespaces #2\hskip\inmarginspacing}%
+ \else
+ \rlap{\hskip\hsize \hskip\inmarginspacing \ignorespaces #2}%
+ \fi
+ \null
+ }%
+}}
+\def\inleftmargin{\doinmargin l}
+\def\inrightmargin{\doinmargin r}
+%
+% @inmargin{TEXT [, RIGHT-TEXT]}
+% (if RIGHT-TEXT is given, use TEXT for left page, RIGHT-TEXT for right;
+% else use TEXT for both).
+%
+\def\inmargin#1{\parseinmargin #1,,\finish}
+\def\parseinmargin#1,#2,#3\finish{% not perfect, but better than nothing.
+ \setbox0 = \hbox{\ignorespaces #2}%
+ \ifdim\wd0 > 0pt
+ \def\lefttext{#1}% have both texts
+ \def\righttext{#2}%
+ \else
+ \def\lefttext{#1}% have only one text
+ \def\righttext{#1}%
+ \fi
+ %
+ \ifodd\pageno
+ \def\temp{\inrightmargin\righttext}% odd page -> outside is right margin
+ \else
+ \def\temp{\inleftmargin\lefttext}%
+ \fi
+ \temp
+}
+
+% @| inserts a changebar to the left of the current line. It should
+% surround any changed text. This approach does *not* work if the
+% change spans more than two lines of output. To handle that, we would
+% have adopt a much more difficult approach (putting marks into the main
+% vertical list for the beginning and end of each change). This command
+% is not documented, not supported, and doesn't work.
+%
+\def\|{%
+ % \vadjust can only be used in horizontal mode.
+ \leavevmode
+ %
+ % Append this vertical mode material after the current line in the output.
+ \vadjust{%
+ % We want to insert a rule with the height and depth of the current
+ % leading; that is exactly what \strutbox is supposed to record.
+ \vskip-\baselineskip
+ %
+ % \vadjust-items are inserted at the left edge of the type. So
+ % the \llap here moves out into the left-hand margin.
+ \llap{%
+ %
+ % For a thicker or thinner bar, change the `1pt'.
+ \vrule height\baselineskip width1pt
+ %
+ % This is the space between the bar and the text.
+ \hskip 12pt
+ }%
+ }%
+}
+
+% @include FILE -- \input text of FILE.
+%
+\def\include{\parseargusing\filenamecatcodes\includezzz}
+\def\includezzz#1{%
+ \pushthisfilestack
+ \def\thisfile{#1}%
+ {%
+ \makevalueexpandable % we want to expand any @value in FILE.
+ \turnoffactive % and allow special characters in the expansion
+ \indexnofonts % Allow `@@' and other weird things in file names.
+ \wlog{texinfo.tex: doing @include of #1^^J}%
+ \edef\temp{\noexpand\input #1 }%
+ %
+ % This trickery is to read FILE outside of a group, in case it makes
+ % definitions, etc.
+ \expandafter
+ }\temp
+ \popthisfilestack
+}
+\def\filenamecatcodes{%
+ \catcode`\\=\other
+ \catcode`~=\other
+ \catcode`^=\other
+ \catcode`_=\other
+ \catcode`|=\other
+ \catcode`<=\other
+ \catcode`>=\other
+ \catcode`+=\other
+ \catcode`-=\other
+ \catcode`\`=\other
+ \catcode`\'=\other
+}
+
+\def\pushthisfilestack{%
+ \expandafter\pushthisfilestackX\popthisfilestack\StackTerm
+}
+\def\pushthisfilestackX{%
+ \expandafter\pushthisfilestackY\thisfile\StackTerm
+}
+\def\pushthisfilestackY #1\StackTerm #2\StackTerm {%
+ \gdef\popthisfilestack{\gdef\thisfile{#1}\gdef\popthisfilestack{#2}}%
+}
+
+\def\popthisfilestack{\errthisfilestackempty}
+\def\errthisfilestackempty{\errmessage{Internal error:
+ the stack of filenames is empty.}}
+%
+\def\thisfile{}
+
+% @center line
+% outputs that line, centered.
+%
+\parseargdef\center{%
+ \ifhmode
+ \let\centersub\centerH
+ \else
+ \let\centersub\centerV
+ \fi
+ \centersub{\hfil \ignorespaces#1\unskip \hfil}%
+ \let\centersub\relax % don't let the definition persist, just in case
+}
+\def\centerH#1{{%
+ \hfil\break
+ \advance\hsize by -\leftskip
+ \advance\hsize by -\rightskip
+ \line{#1}%
+ \break
+}}
+%
+\newcount\centerpenalty
+\def\centerV#1{%
+ % The idea here is the same as in \startdefun, \cartouche, etc.: if
+ % @center is the first thing after a section heading, we need to wipe
+ % out the negative parskip inserted by \sectionheading, but still
+ % prevent a page break here.
+ \centerpenalty = \lastpenalty
+ \ifnum\centerpenalty>10000 \vskip\parskip \fi
+ \ifnum\centerpenalty>9999 \penalty\centerpenalty \fi
+ \line{\kern\leftskip #1\kern\rightskip}%
+}
+
+% @sp n outputs n lines of vertical space
+%
+\parseargdef\sp{\vskip #1\baselineskip}
+
+% @comment ...line which is ignored...
+% @c is the same as @comment
+% @ignore ... @end ignore is another way to write a comment
+%
+\def\comment{\begingroup \catcode`\^^M=\other%
+\catcode`\@=\other \catcode`\{=\other \catcode`\}=\other%
+\commentxxx}
+{\catcode`\^^M=\other \gdef\commentxxx#1^^M{\endgroup}}
+%
+\let\c=\comment
+
+% @paragraphindent NCHARS
+% We'll use ems for NCHARS, close enough.
+% NCHARS can also be the word `asis' or `none'.
+% We cannot feasibly implement @paragraphindent asis, though.
+%
+\def\asisword{asis} % no translation, these are keywords
+\def\noneword{none}
+%
+\parseargdef\paragraphindent{%
+ \def\temp{#1}%
+ \ifx\temp\asisword
+ \else
+ \ifx\temp\noneword
+ \defaultparindent = 0pt
+ \else
+ \defaultparindent = #1em
+ \fi
+ \fi
+ \parindent = \defaultparindent
+}
+
+% @exampleindent NCHARS
+% We'll use ems for NCHARS like @paragraphindent.
+% It seems @exampleindent asis isn't necessary, but
+% I preserve it to make it similar to @paragraphindent.
+\parseargdef\exampleindent{%
+ \def\temp{#1}%
+ \ifx\temp\asisword
+ \else
+ \ifx\temp\noneword
+ \lispnarrowing = 0pt
+ \else
+ \lispnarrowing = #1em
+ \fi
+ \fi
+}
+
+% @firstparagraphindent WORD
+% If WORD is `none', then suppress indentation of the first paragraph
+% after a section heading. If WORD is `insert', then do indent at such
+% paragraphs.
+%
+% The paragraph indentation is suppressed or not by calling
+% \suppressfirstparagraphindent, which the sectioning commands do.
+% We switch the definition of this back and forth according to WORD.
+% By default, we suppress indentation.
+%
+\def\suppressfirstparagraphindent{\dosuppressfirstparagraphindent}
+\def\insertword{insert}
+%
+\parseargdef\firstparagraphindent{%
+ \def\temp{#1}%
+ \ifx\temp\noneword
+ \let\suppressfirstparagraphindent = \dosuppressfirstparagraphindent
+ \else\ifx\temp\insertword
+ \let\suppressfirstparagraphindent = \relax
+ \else
+ \errhelp = \EMsimple
+ \errmessage{Unknown @firstparagraphindent option `\temp'}%
+ \fi\fi
+}
+
+% Here is how we actually suppress indentation. Redefine \everypar to
+% \kern backwards by \parindent, and then reset itself to empty.
+%
+% We also make \indent itself not actually do anything until the next
+% paragraph.
+%
+\gdef\dosuppressfirstparagraphindent{%
+ \gdef\indent{%
+ \restorefirstparagraphindent
+ \indent
+ }%
+ \gdef\noindent{%
+ \restorefirstparagraphindent
+ \noindent
+ }%
+ \global\everypar = {%
+ \kern -\parindent
+ \restorefirstparagraphindent
+ }%
+}
+
+\gdef\restorefirstparagraphindent{%
+ \global \let \indent = \ptexindent
+ \global \let \noindent = \ptexnoindent
+ \global \everypar = {}%
+}
+
+
+% @refill is a no-op.
+\let\refill=\relax
+
+% If working on a large document in chapters, it is convenient to
+% be able to disable indexing, cross-referencing, and contents, for test runs.
+% This is done with @novalidate (before @setfilename).
+%
+\newif\iflinks \linkstrue % by default we want the aux files.
+\let\novalidate = \linksfalse
+
+% @setfilename is done at the beginning of every texinfo file.
+% So open here the files we need to have open while reading the input.
+% This makes it possible to make a .fmt file for texinfo.
+\def\setfilename{%
+ \fixbackslash % Turn off hack to swallow `\input texinfo'.
+ \iflinks
+ \tryauxfile
+ % Open the new aux file. TeX will close it automatically at exit.
+ \immediate\openout\auxfile=\jobname.aux
+ \fi % \openindices needs to do some work in any case.
+ \openindices
+ \let\setfilename=\comment % Ignore extra @setfilename cmds.
+ %
+ % If texinfo.cnf is present on the system, read it.
+ % Useful for site-wide @afourpaper, etc.
+ \openin 1 texinfo.cnf
+ \ifeof 1 \else \input texinfo.cnf \fi
+ \closein 1
+ %
+ \comment % Ignore the actual filename.
+}
+
+% Called from \setfilename.
+%
+\def\openindices{%
+ \newindex{cp}%
+ \newcodeindex{fn}%
+ \newcodeindex{vr}%
+ \newcodeindex{tp}%
+ \newcodeindex{ky}%
+ \newcodeindex{pg}%
+}
+
+% @bye.
+\outer\def\bye{\pagealignmacro\tracingstats=1\ptexend}
+
+
+\message{pdf,}
+% adobe `portable' document format
+\newcount\tempnum
+\newcount\lnkcount
+\newtoks\filename
+\newcount\filenamelength
+\newcount\pgn
+\newtoks\toksA
+\newtoks\toksB
+\newtoks\toksC
+\newtoks\toksD
+\newbox\boxA
+\newcount\countA
+\newif\ifpdf
+\newif\ifpdfmakepagedest
+
+% when pdftex is run in dvi mode, \pdfoutput is defined (so \pdfoutput=1
+% can be set). So we test for \relax and 0 as well as being undefined.
+\ifx\pdfoutput\thisisundefined
+\else
+ \ifx\pdfoutput\relax
+ \else
+ \ifcase\pdfoutput
+ \else
+ \pdftrue
+ \fi
+ \fi
+\fi
+
+% PDF uses PostScript string constants for the names of xref targets,
+% for display in the outlines, and in other places. Thus, we have to
+% double any backslashes. Otherwise, a name like "\node" will be
+% interpreted as a newline (\n), followed by o, d, e. Not good.
+%
+% See http://www.ntg.nl/pipermail/ntg-pdftex/2004-July/000654.html and
+% related messages. The final outcome is that it is up to the TeX user
+% to double the backslashes and otherwise make the string valid, so
+% that's what we do. pdftex 1.30.0 (ca.2005) introduced a primitive to
+% do this reliably, so we use it.
+
+% #1 is a control sequence in which to do the replacements,
+% which we \xdef.
+\def\txiescapepdf#1{%
+ \ifx\pdfescapestring\thisisundefined
+ % No primitive available; should we give a warning or log?
+ % Many times it won't matter.
+ \else
+ % The expandable \pdfescapestring primitive escapes parentheses,
+ % backslashes, and other special chars.
+ \xdef#1{\pdfescapestring{#1}}%
+ \fi
+}
+
+\newhelp\nopdfimagehelp{Texinfo supports .png, .jpg, .jpeg, and .pdf images
+with PDF output, and none of those formats could be found. (.eps cannot
+be supported due to the design of the PDF format; use regular TeX (DVI
+output) for that.)}
+
+\ifpdf
+ %
+ % Color manipulation macros based on pdfcolor.tex,
+ % except using rgb instead of cmyk; the latter is said to render as a
+ % very dark gray on-screen and a very dark halftone in print, instead
+ % of actual black.
+ \def\rgbDarkRed{0.50 0.09 0.12}
+ \def\rgbBlack{0 0 0}
+ %
+ % k sets the color for filling (usual text, etc.);
+ % K sets the color for stroking (thin rules, e.g., normal _'s).
+ \def\pdfsetcolor#1{\pdfliteral{#1 rg #1 RG}}
+ %
+ % Set color, and create a mark which defines \thiscolor accordingly,
+ % so that \makeheadline knows which color to restore.
+ \def\setcolor#1{%
+ \xdef\lastcolordefs{\gdef\noexpand\thiscolor{#1}}%
+ \domark
+ \pdfsetcolor{#1}%
+ }
+ %
+ \def\maincolor{\rgbBlack}
+ \pdfsetcolor{\maincolor}
+ \edef\thiscolor{\maincolor}
+ \def\lastcolordefs{}
+ %
+ \def\makefootline{%
+ \baselineskip24pt
+ \line{\pdfsetcolor{\maincolor}\the\footline}%
+ }
+ %
+ \def\makeheadline{%
+ \vbox to 0pt{%
+ \vskip-22.5pt
+ \line{%
+ \vbox to8.5pt{}%
+ % Extract \thiscolor definition from the marks.
+ \getcolormarks
+ % Typeset the headline with \maincolor, then restore the color.
+ \pdfsetcolor{\maincolor}\the\headline\pdfsetcolor{\thiscolor}%
+ }%
+ \vss
+ }%
+ \nointerlineskip
+ }
+ %
+ %
+ \pdfcatalog{/PageMode /UseOutlines}
+ %
+ % #1 is image name, #2 width (might be empty/whitespace), #3 height (ditto).
+ \def\dopdfimage#1#2#3{%
+ \def\pdfimagewidth{#2}\setbox0 = \hbox{\ignorespaces #2}%
+ \def\pdfimageheight{#3}\setbox2 = \hbox{\ignorespaces #3}%
+ %
+ % pdftex (and the PDF format) support .pdf, .png, .jpg (among
+ % others). Let's try in that order, PDF first since if
+ % someone has a scalable image, presumably better to use that than a
+ % bitmap.
+ \let\pdfimgext=\empty
+ \begingroup
+ \openin 1 #1.pdf \ifeof 1
+ \openin 1 #1.PDF \ifeof 1
+ \openin 1 #1.png \ifeof 1
+ \openin 1 #1.jpg \ifeof 1
+ \openin 1 #1.jpeg \ifeof 1
+ \openin 1 #1.JPG \ifeof 1
+ \errhelp = \nopdfimagehelp
+ \errmessage{Could not find image file #1 for pdf}%
+ \else \gdef\pdfimgext{JPG}%
+ \fi
+ \else \gdef\pdfimgext{jpeg}%
+ \fi
+ \else \gdef\pdfimgext{jpg}%
+ \fi
+ \else \gdef\pdfimgext{png}%
+ \fi
+ \else \gdef\pdfimgext{PDF}%
+ \fi
+ \else \gdef\pdfimgext{pdf}%
+ \fi
+ \closein 1
+ \endgroup
+ %
+ % without \immediate, ancient pdftex seg faults when the same image is
+ % included twice. (Version 3.14159-pre-1.0-unofficial-20010704.)
+ \ifnum\pdftexversion < 14
+ \immediate\pdfimage
+ \else
+ \immediate\pdfximage
+ \fi
+ \ifdim \wd0 >0pt width \pdfimagewidth \fi
+ \ifdim \wd2 >0pt height \pdfimageheight \fi
+ \ifnum\pdftexversion<13
+ #1.\pdfimgext
+ \else
+ {#1.\pdfimgext}%
+ \fi
+ \ifnum\pdftexversion < 14 \else
+ \pdfrefximage \pdflastximage
+ \fi}
+ %
+ \def\pdfmkdest#1{{%
+ % We have to set dummies so commands such as @code, and characters
+ % such as \, aren't expanded when present in a section title.
+ \indexnofonts
+ \turnoffactive
+ \makevalueexpandable
+ \def\pdfdestname{#1}%
+ \txiescapepdf\pdfdestname
+ \safewhatsit{\pdfdest name{\pdfdestname} xyz}%
+ }}
+ %
+ % used to mark target names; must be expandable.
+ \def\pdfmkpgn#1{#1}
+ %
+ % by default, use a color that is dark enough to print on paper as
+ % nearly black, but still distinguishable for online viewing.
+ \def\urlcolor{\rgbDarkRed}
+ \def\linkcolor{\rgbDarkRed}
+ \def\endlink{\setcolor{\maincolor}\pdfendlink}
+ %
+ % Adding outlines to PDF; macros for calculating structure of outlines
+ % come from Petr Olsak
+ \def\expnumber#1{\expandafter\ifx\csname#1\endcsname\relax 0%
+ \else \csname#1\endcsname \fi}
+ \def\advancenumber#1{\tempnum=\expnumber{#1}\relax
+ \advance\tempnum by 1
+ \expandafter\xdef\csname#1\endcsname{\the\tempnum}}
+ %
+ % #1 is the section text, which is what will be displayed in the
+ % outline by the pdf viewer. #2 is the pdf expression for the number
+ % of subentries (or empty, for subsubsections). #3 is the node text,
+ % which might be empty if this toc entry had no corresponding node.
+ % #4 is the page number
+ %
+ \def\dopdfoutline#1#2#3#4{%
+ % Generate a link to the node text if that exists; else, use the
+ % page number. We could generate a destination for the section
+ % text in the case where a section has no node, but it doesn't
+ % seem worth the trouble, since most documents are normally structured.
+ \edef\pdfoutlinedest{#3}%
+ \ifx\pdfoutlinedest\empty
+ \def\pdfoutlinedest{#4}%
+ \else
+ \txiescapepdf\pdfoutlinedest
+ \fi
+ %
+ % Also escape PDF chars in the display string.
+ \edef\pdfoutlinetext{#1}%
+ \txiescapepdf\pdfoutlinetext
+ %
+ \pdfoutline goto name{\pdfmkpgn{\pdfoutlinedest}}#2{\pdfoutlinetext}%
+ }
+ %
+ \def\pdfmakeoutlines{%
+ \begingroup
+ % Read toc silently, to get counts of subentries for \pdfoutline.
+ \def\partentry##1##2##3##4{}% ignore parts in the outlines
+ \def\numchapentry##1##2##3##4{%
+ \def\thischapnum{##2}%
+ \def\thissecnum{0}%
+ \def\thissubsecnum{0}%
+ }%
+ \def\numsecentry##1##2##3##4{%
+ \advancenumber{chap\thischapnum}%
+ \def\thissecnum{##2}%
+ \def\thissubsecnum{0}%
+ }%
+ \def\numsubsecentry##1##2##3##4{%
+ \advancenumber{sec\thissecnum}%
+ \def\thissubsecnum{##2}%
+ }%
+ \def\numsubsubsecentry##1##2##3##4{%
+ \advancenumber{subsec\thissubsecnum}%
+ }%
+ \def\thischapnum{0}%
+ \def\thissecnum{0}%
+ \def\thissubsecnum{0}%
+ %
+ % use \def rather than \let here because we redefine \chapentry et
+ % al. a second time, below.
+ \def\appentry{\numchapentry}%
+ \def\appsecentry{\numsecentry}%
+ \def\appsubsecentry{\numsubsecentry}%
+ \def\appsubsubsecentry{\numsubsubsecentry}%
+ \def\unnchapentry{\numchapentry}%
+ \def\unnsecentry{\numsecentry}%
+ \def\unnsubsecentry{\numsubsecentry}%
+ \def\unnsubsubsecentry{\numsubsubsecentry}%
+ \readdatafile{toc}%
+ %
+ % Read toc second time, this time actually producing the outlines.
+ % The `-' means take the \expnumber as the absolute number of
+ % subentries, which we calculated on our first read of the .toc above.
+ %
+ % We use the node names as the destinations.
+ \def\numchapentry##1##2##3##4{%
+ \dopdfoutline{##1}{count-\expnumber{chap##2}}{##3}{##4}}%
+ \def\numsecentry##1##2##3##4{%
+ \dopdfoutline{##1}{count-\expnumber{sec##2}}{##3}{##4}}%
+ \def\numsubsecentry##1##2##3##4{%
+ \dopdfoutline{##1}{count-\expnumber{subsec##2}}{##3}{##4}}%
+ \def\numsubsubsecentry##1##2##3##4{% count is always zero
+ \dopdfoutline{##1}{}{##3}{##4}}%
+ %
+ % PDF outlines are displayed using system fonts, instead of
+ % document fonts. Therefore we cannot use special characters,
+ % since the encoding is unknown. For example, the eogonek from
+ % Latin 2 (0xea) gets translated to a | character. Info from
+ % Staszek Wawrykiewicz, 19 Jan 2004 04:09:24 +0100.
+ %
+ % TODO this right, we have to translate 8-bit characters to
+ % their "best" equivalent, based on the @documentencoding. Too
+ % much work for too little return. Just use the ASCII equivalents
+ % we use for the index sort strings.
+ %
+ \indexnofonts
+ \setupdatafile
+ % We can have normal brace characters in the PDF outlines, unlike
+ % Texinfo index files. So set that up.
+ \def\{{\lbracecharliteral}%
+ \def\}{\rbracecharliteral}%
+ \catcode`\\=\active \otherbackslash
+ \input \tocreadfilename
+ \endgroup
+ }
+ {\catcode`[=1 \catcode`]=2
+ \catcode`{=\other \catcode`}=\other
+ \gdef\lbracecharliteral[{]%
+ \gdef\rbracecharliteral[}]%
+ ]
+ %
+ \def\skipspaces#1{\def\PP{#1}\def\D{|}%
+ \ifx\PP\D\let\nextsp\relax
+ \else\let\nextsp\skipspaces
+ \addtokens{\filename}{\PP}%
+ \advance\filenamelength by 1
+ \fi
+ \nextsp}
+ \def\getfilename#1{%
+ \filenamelength=0
+ % If we don't expand the argument now, \skipspaces will get
+ % snagged on things like "@value{foo}".
+ \edef\temp{#1}%
+ \expandafter\skipspaces\temp|\relax
+ }
+ \ifnum\pdftexversion < 14
+ \let \startlink \pdfannotlink
+ \else
+ \let \startlink \pdfstartlink
+ \fi
+ % make a live url in pdf output.
+ \def\pdfurl#1{%
+ \begingroup
+ % it seems we really need yet another set of dummies; have not
+ % tried to figure out what each command should do in the context
+ % of @url. for now, just make @/ a no-op, that's the only one
+ % people have actually reported a problem with.
+ %
+ \normalturnoffactive
+ \def\@{@}%
+ \let\/=\empty
+ \makevalueexpandable
+ % do we want to go so far as to use \indexnofonts instead of just
+ % special-casing \var here?
+ \def\var##1{##1}%
+ %
+ \leavevmode\setcolor{\urlcolor}%
+ \startlink attr{/Border [0 0 0]}%
+ user{/Subtype /Link /A << /S /URI /URI (#1) >>}%
+ \endgroup}
+ \def\pdfgettoks#1.{\setbox\boxA=\hbox{\toksA={#1.}\toksB={}\maketoks}}
+ \def\addtokens#1#2{\edef\addtoks{\noexpand#1={\the#1#2}}\addtoks}
+ \def\adn#1{\addtokens{\toksC}{#1}\global\countA=1\let\next=\maketoks}
+ \def\poptoks#1#2|ENDTOKS|{\let\first=#1\toksD={#1}\toksA={#2}}
+ \def\maketoks{%
+ \expandafter\poptoks\the\toksA|ENDTOKS|\relax
+ \ifx\first0\adn0
+ \else\ifx\first1\adn1 \else\ifx\first2\adn2 \else\ifx\first3\adn3
+ \else\ifx\first4\adn4 \else\ifx\first5\adn5 \else\ifx\first6\adn6
+ \else\ifx\first7\adn7 \else\ifx\first8\adn8 \else\ifx\first9\adn9
+ \else
+ \ifnum0=\countA\else\makelink\fi
+ \ifx\first.\let\next=\done\else
+ \let\next=\maketoks
+ \addtokens{\toksB}{\the\toksD}
+ \ifx\first,\addtokens{\toksB}{\space}\fi
+ \fi
+ \fi\fi\fi\fi\fi\fi\fi\fi\fi\fi
+ \next}
+ \def\makelink{\addtokens{\toksB}%
+ {\noexpand\pdflink{\the\toksC}}\toksC={}\global\countA=0}
+ \def\pdflink#1{%
+ \startlink attr{/Border [0 0 0]} goto name{\pdfmkpgn{#1}}
+ \setcolor{\linkcolor}#1\endlink}
+ \def\done{\edef\st{\global\noexpand\toksA={\the\toksB}}\st}
+\else
+ % non-pdf mode
+ \let\pdfmkdest = \gobble
+ \let\pdfurl = \gobble
+ \let\endlink = \relax
+ \let\setcolor = \gobble
+ \let\pdfsetcolor = \gobble
+ \let\pdfmakeoutlines = \relax
+\fi % \ifx\pdfoutput
+
+
+\message{fonts,}
+
+% Change the current font style to #1, remembering it in \curfontstyle.
+% For now, we do not accumulate font styles: @b{@i{foo}} prints foo in
+% italics, not bold italics.
+%
+\def\setfontstyle#1{%
+ \def\curfontstyle{#1}% not as a control sequence, because we are \edef'd.
+ \csname ten#1\endcsname % change the current font
+}
+
+% Select #1 fonts with the current style.
+%
+\def\selectfonts#1{\csname #1fonts\endcsname \csname\curfontstyle\endcsname}
+
+\def\rm{\fam=0 \setfontstyle{rm}}
+\def\it{\fam=\itfam \setfontstyle{it}}
+\def\sl{\fam=\slfam \setfontstyle{sl}}
+\def\bf{\fam=\bffam \setfontstyle{bf}}\def\bfstylename{bf}
+\def\tt{\fam=\ttfam \setfontstyle{tt}}
+
+% Unfortunately, we have to override this for titles and the like, since
+% in those cases "rm" is bold. Sigh.
+\def\rmisbold{\rm\def\curfontstyle{bf}}
+
+% Texinfo sort of supports the sans serif font style, which plain TeX does not.
+% So we set up a \sf.
+\newfam\sffam
+\def\sf{\fam=\sffam \setfontstyle{sf}}
+\let\li = \sf % Sometimes we call it \li, not \sf.
+
+% We don't need math for this font style.
+\def\ttsl{\setfontstyle{ttsl}}
+
+
+% Set the baselineskip to #1, and the lineskip and strut size
+% correspondingly. There is no deep meaning behind these magic numbers
+% used as factors; they just match (closely enough) what Knuth defined.
+%
+\def\lineskipfactor{.08333}
+\def\strutheightpercent{.70833}
+\def\strutdepthpercent {.29167}
+%
+% can get a sort of poor man's double spacing by redefining this.
+\def\baselinefactor{1}
+%
+\newdimen\textleading
+\def\setleading#1{%
+ \dimen0 = #1\relax
+ \normalbaselineskip = \baselinefactor\dimen0
+ \normallineskip = \lineskipfactor\normalbaselineskip
+ \normalbaselines
+ \setbox\strutbox =\hbox{%
+ \vrule width0pt height\strutheightpercent\baselineskip
+ depth \strutdepthpercent \baselineskip
+ }%
+}
+
+% PDF CMaps. See also LaTeX's t1.cmap.
+%
+% do nothing with this by default.
+\expandafter\let\csname cmapOT1\endcsname\gobble
+\expandafter\let\csname cmapOT1IT\endcsname\gobble
+\expandafter\let\csname cmapOT1TT\endcsname\gobble
+
+% if we are producing pdf, and we have \pdffontattr, then define cmaps.
+% (\pdffontattr was introduced many years ago, but people still run
+% older pdftex's; it's easy to conditionalize, so we do.)
+\ifpdf \ifx\pdffontattr\thisisundefined \else
+ \begingroup
+ \catcode`\^^M=\active \def^^M{^^J}% Output line endings as the ^^J char.
+ \catcode`\%=12 \immediate\pdfobj stream {%!PS-Adobe-3.0 Resource-CMap
+%%DocumentNeededResources: ProcSet (CIDInit)
+%%IncludeResource: ProcSet (CIDInit)
+%%BeginResource: CMap (TeX-OT1-0)
+%%Title: (TeX-OT1-0 TeX OT1 0)
+%%Version: 1.000
+%%EndComments
+/CIDInit /ProcSet findresource begin
+12 dict begin
+begincmap
+/CIDSystemInfo
+<< /Registry (TeX)
+/Ordering (OT1)
+/Supplement 0
+>> def
+/CMapName /TeX-OT1-0 def
+/CMapType 2 def
+1 begincodespacerange
+<00> <7F>
+endcodespacerange
+8 beginbfrange
+<00> <01> <0393>
+<09> <0A> <03A8>
+<23> <26> <0023>
+<28> <3B> <0028>
+<3F> <5B> <003F>
+<5D> <5E> <005D>
+<61> <7A> <0061>
+<7B> <7C> <2013>
+endbfrange
+40 beginbfchar
+<02> <0398>
+<03> <039B>
+<04> <039E>
+<05> <03A0>
+<06> <03A3>
+<07> <03D2>
+<08> <03A6>
+<0B> <00660066>
+<0C> <00660069>
+<0D> <0066006C>
+<0E> <006600660069>
+<0F> <00660066006C>
+<10> <0131>
+<11> <0237>
+<12> <0060>
+<13> <00B4>
+<14> <02C7>
+<15> <02D8>
+<16> <00AF>
+<17> <02DA>
+<18> <00B8>
+<19> <00DF>
+<1A> <00E6>
+<1B> <0153>
+<1C> <00F8>
+<1D> <00C6>
+<1E> <0152>
+<1F> <00D8>
+<21> <0021>
+<22> <201D>
+<27> <2019>
+<3C> <00A1>
+<3D> <003D>
+<3E> <00BF>
+<5C> <201C>
+<5F> <02D9>
+<60> <2018>
+<7D> <02DD>
+<7E> <007E>
+<7F> <00A8>
+endbfchar
+endcmap
+CMapName currentdict /CMap defineresource pop
+end
+end
+%%EndResource
+%%EOF
+ }\endgroup
+ \expandafter\edef\csname cmapOT1\endcsname#1{%
+ \pdffontattr#1{/ToUnicode \the\pdflastobj\space 0 R}%
+ }%
+%
+% \cmapOT1IT
+ \begingroup
+ \catcode`\^^M=\active \def^^M{^^J}% Output line endings as the ^^J char.
+ \catcode`\%=12 \immediate\pdfobj stream {%!PS-Adobe-3.0 Resource-CMap
+%%DocumentNeededResources: ProcSet (CIDInit)
+%%IncludeResource: ProcSet (CIDInit)
+%%BeginResource: CMap (TeX-OT1IT-0)
+%%Title: (TeX-OT1IT-0 TeX OT1IT 0)
+%%Version: 1.000
+%%EndComments
+/CIDInit /ProcSet findresource begin
+12 dict begin
+begincmap
+/CIDSystemInfo
+<< /Registry (TeX)
+/Ordering (OT1IT)
+/Supplement 0
+>> def
+/CMapName /TeX-OT1IT-0 def
+/CMapType 2 def
+1 begincodespacerange
+<00> <7F>
+endcodespacerange
+8 beginbfrange
+<00> <01> <0393>
+<09> <0A> <03A8>
+<25> <26> <0025>
+<28> <3B> <0028>
+<3F> <5B> <003F>
+<5D> <5E> <005D>
+<61> <7A> <0061>
+<7B> <7C> <2013>
+endbfrange
+42 beginbfchar
+<02> <0398>
+<03> <039B>
+<04> <039E>
+<05> <03A0>
+<06> <03A3>
+<07> <03D2>
+<08> <03A6>
+<0B> <00660066>
+<0C> <00660069>
+<0D> <0066006C>
+<0E> <006600660069>
+<0F> <00660066006C>
+<10> <0131>
+<11> <0237>
+<12> <0060>
+<13> <00B4>
+<14> <02C7>
+<15> <02D8>
+<16> <00AF>
+<17> <02DA>
+<18> <00B8>
+<19> <00DF>
+<1A> <00E6>
+<1B> <0153>
+<1C> <00F8>
+<1D> <00C6>
+<1E> <0152>
+<1F> <00D8>
+<21> <0021>
+<22> <201D>
+<23> <0023>
+<24> <00A3>
+<27> <2019>
+<3C> <00A1>
+<3D> <003D>
+<3E> <00BF>
+<5C> <201C>
+<5F> <02D9>
+<60> <2018>
+<7D> <02DD>
+<7E> <007E>
+<7F> <00A8>
+endbfchar
+endcmap
+CMapName currentdict /CMap defineresource pop
+end
+end
+%%EndResource
+%%EOF
+ }\endgroup
+ \expandafter\edef\csname cmapOT1IT\endcsname#1{%
+ \pdffontattr#1{/ToUnicode \the\pdflastobj\space 0 R}%
+ }%
+%
+% \cmapOT1TT
+ \begingroup
+ \catcode`\^^M=\active \def^^M{^^J}% Output line endings as the ^^J char.
+ \catcode`\%=12 \immediate\pdfobj stream {%!PS-Adobe-3.0 Resource-CMap
+%%DocumentNeededResources: ProcSet (CIDInit)
+%%IncludeResource: ProcSet (CIDInit)
+%%BeginResource: CMap (TeX-OT1TT-0)
+%%Title: (TeX-OT1TT-0 TeX OT1TT 0)
+%%Version: 1.000
+%%EndComments
+/CIDInit /ProcSet findresource begin
+12 dict begin
+begincmap
+/CIDSystemInfo
+<< /Registry (TeX)
+/Ordering (OT1TT)
+/Supplement 0
+>> def
+/CMapName /TeX-OT1TT-0 def
+/CMapType 2 def
+1 begincodespacerange
+<00> <7F>
+endcodespacerange
+5 beginbfrange
+<00> <01> <0393>
+<09> <0A> <03A8>
+<21> <26> <0021>
+<28> <5F> <0028>
+<61> <7E> <0061>
+endbfrange
+32 beginbfchar
+<02> <0398>
+<03> <039B>
+<04> <039E>
+<05> <03A0>
+<06> <03A3>
+<07> <03D2>
+<08> <03A6>
+<0B> <2191>
+<0C> <2193>
+<0D> <0027>
+<0E> <00A1>
+<0F> <00BF>
+<10> <0131>
+<11> <0237>
+<12> <0060>
+<13> <00B4>
+<14> <02C7>
+<15> <02D8>
+<16> <00AF>
+<17> <02DA>
+<18> <00B8>
+<19> <00DF>
+<1A> <00E6>
+<1B> <0153>
+<1C> <00F8>
+<1D> <00C6>
+<1E> <0152>
+<1F> <00D8>
+<20> <2423>
+<27> <2019>
+<60> <2018>
+<7F> <00A8>
+endbfchar
+endcmap
+CMapName currentdict /CMap defineresource pop
+end
+end
+%%EndResource
+%%EOF
+ }\endgroup
+ \expandafter\edef\csname cmapOT1TT\endcsname#1{%
+ \pdffontattr#1{/ToUnicode \the\pdflastobj\space 0 R}%
+ }%
+\fi\fi
+
+
+% Set the font macro #1 to the font named \fontprefix#2.
+% #3 is the font's design size, #4 is a scale factor, #5 is the CMap
+% encoding (only OT1, OT1IT and OT1TT are allowed, or empty to omit).
+% Example:
+% #1 = \textrm
+% #2 = \rmshape
+% #3 = 10
+% #4 = \mainmagstep
+% #5 = OT1
+%
+\def\setfont#1#2#3#4#5{%
+ \font#1=\fontprefix#2#3 scaled #4
+ \csname cmap#5\endcsname#1%
+}
+% This is what gets called when #5 of \setfont is empty.
+\let\cmap\gobble
+%
+% (end of cmaps)
+
+% Use cm as the default font prefix.
+% To specify the font prefix, you must define \fontprefix
+% before you read in texinfo.tex.
+\ifx\fontprefix\thisisundefined
+\def\fontprefix{cm}
+\fi
+% Support font families that don't use the same naming scheme as CM.
+\def\rmshape{r}
+\def\rmbshape{bx} % where the normal face is bold
+\def\bfshape{b}
+\def\bxshape{bx}
+\def\ttshape{tt}
+\def\ttbshape{tt}
+\def\ttslshape{sltt}
+\def\itshape{ti}
+\def\itbshape{bxti}
+\def\slshape{sl}
+\def\slbshape{bxsl}
+\def\sfshape{ss}
+\def\sfbshape{ss}
+\def\scshape{csc}
+\def\scbshape{csc}
+
+% Definitions for a main text size of 11pt. (The default in Texinfo.)
+%
+\def\definetextfontsizexi{%
+% Text fonts (11.2pt, magstep1).
+\def\textnominalsize{11pt}
+\edef\mainmagstep{\magstephalf}
+\setfont\textrm\rmshape{10}{\mainmagstep}{OT1}
+\setfont\texttt\ttshape{10}{\mainmagstep}{OT1TT}
+\setfont\textbf\bfshape{10}{\mainmagstep}{OT1}
+\setfont\textit\itshape{10}{\mainmagstep}{OT1IT}
+\setfont\textsl\slshape{10}{\mainmagstep}{OT1}
+\setfont\textsf\sfshape{10}{\mainmagstep}{OT1}
+\setfont\textsc\scshape{10}{\mainmagstep}{OT1}
+\setfont\textttsl\ttslshape{10}{\mainmagstep}{OT1TT}
+\font\texti=cmmi10 scaled \mainmagstep
+\font\textsy=cmsy10 scaled \mainmagstep
+\def\textecsize{1095}
+
+% A few fonts for @defun names and args.
+\setfont\defbf\bfshape{10}{\magstep1}{OT1}
+\setfont\deftt\ttshape{10}{\magstep1}{OT1TT}
+\setfont\defttsl\ttslshape{10}{\magstep1}{OT1TT}
+\def\df{\let\tentt=\deftt \let\tenbf = \defbf \let\tenttsl=\defttsl \bf}
+
+% Fonts for indices, footnotes, small examples (9pt).
+\def\smallnominalsize{9pt}
+\setfont\smallrm\rmshape{9}{1000}{OT1}
+\setfont\smalltt\ttshape{9}{1000}{OT1TT}
+\setfont\smallbf\bfshape{10}{900}{OT1}
+\setfont\smallit\itshape{9}{1000}{OT1IT}
+\setfont\smallsl\slshape{9}{1000}{OT1}
+\setfont\smallsf\sfshape{9}{1000}{OT1}
+\setfont\smallsc\scshape{10}{900}{OT1}
+\setfont\smallttsl\ttslshape{10}{900}{OT1TT}
+\font\smalli=cmmi9
+\font\smallsy=cmsy9
+\def\smallecsize{0900}
+
+% Fonts for small examples (8pt).
+\def\smallernominalsize{8pt}
+\setfont\smallerrm\rmshape{8}{1000}{OT1}
+\setfont\smallertt\ttshape{8}{1000}{OT1TT}
+\setfont\smallerbf\bfshape{10}{800}{OT1}
+\setfont\smallerit\itshape{8}{1000}{OT1IT}
+\setfont\smallersl\slshape{8}{1000}{OT1}
+\setfont\smallersf\sfshape{8}{1000}{OT1}
+\setfont\smallersc\scshape{10}{800}{OT1}
+\setfont\smallerttsl\ttslshape{10}{800}{OT1TT}
+\font\smalleri=cmmi8
+\font\smallersy=cmsy8
+\def\smallerecsize{0800}
+
+% Fonts for title page (20.4pt):
+\def\titlenominalsize{20pt}
+\setfont\titlerm\rmbshape{12}{\magstep3}{OT1}
+\setfont\titleit\itbshape{10}{\magstep4}{OT1IT}
+\setfont\titlesl\slbshape{10}{\magstep4}{OT1}
+\setfont\titlett\ttbshape{12}{\magstep3}{OT1TT}
+\setfont\titlettsl\ttslshape{10}{\magstep4}{OT1TT}
+\setfont\titlesf\sfbshape{17}{\magstep1}{OT1}
+\let\titlebf=\titlerm
+\setfont\titlesc\scbshape{10}{\magstep4}{OT1}
+\font\titlei=cmmi12 scaled \magstep3
+\font\titlesy=cmsy10 scaled \magstep4
+\def\titleecsize{2074}
+
+% Chapter (and unnumbered) fonts (17.28pt).
+\def\chapnominalsize{17pt}
+\setfont\chaprm\rmbshape{12}{\magstep2}{OT1}
+\setfont\chapit\itbshape{10}{\magstep3}{OT1IT}
+\setfont\chapsl\slbshape{10}{\magstep3}{OT1}
+\setfont\chaptt\ttbshape{12}{\magstep2}{OT1TT}
+\setfont\chapttsl\ttslshape{10}{\magstep3}{OT1TT}
+\setfont\chapsf\sfbshape{17}{1000}{OT1}
+\let\chapbf=\chaprm
+\setfont\chapsc\scbshape{10}{\magstep3}{OT1}
+\font\chapi=cmmi12 scaled \magstep2
+\font\chapsy=cmsy10 scaled \magstep3
+\def\chapecsize{1728}
+
+% Section fonts (14.4pt).
+\def\secnominalsize{14pt}
+\setfont\secrm\rmbshape{12}{\magstep1}{OT1}
+\setfont\secit\itbshape{10}{\magstep2}{OT1IT}
+\setfont\secsl\slbshape{10}{\magstep2}{OT1}
+\setfont\sectt\ttbshape{12}{\magstep1}{OT1TT}
+\setfont\secttsl\ttslshape{10}{\magstep2}{OT1TT}
+\setfont\secsf\sfbshape{12}{\magstep1}{OT1}
+\let\secbf\secrm
+\setfont\secsc\scbshape{10}{\magstep2}{OT1}
+\font\seci=cmmi12 scaled \magstep1
+\font\secsy=cmsy10 scaled \magstep2
+\def\sececsize{1440}
+
+% Subsection fonts (13.15pt).
+\def\ssecnominalsize{13pt}
+\setfont\ssecrm\rmbshape{12}{\magstephalf}{OT1}
+\setfont\ssecit\itbshape{10}{1315}{OT1IT}
+\setfont\ssecsl\slbshape{10}{1315}{OT1}
+\setfont\ssectt\ttbshape{12}{\magstephalf}{OT1TT}
+\setfont\ssecttsl\ttslshape{10}{1315}{OT1TT}
+\setfont\ssecsf\sfbshape{12}{\magstephalf}{OT1}
+\let\ssecbf\ssecrm
+\setfont\ssecsc\scbshape{10}{1315}{OT1}
+\font\sseci=cmmi12 scaled \magstephalf
+\font\ssecsy=cmsy10 scaled 1315
+\def\ssececsize{1200}
+
+% Reduced fonts for @acro in text (10pt).
+\def\reducednominalsize{10pt}
+\setfont\reducedrm\rmshape{10}{1000}{OT1}
+\setfont\reducedtt\ttshape{10}{1000}{OT1TT}
+\setfont\reducedbf\bfshape{10}{1000}{OT1}
+\setfont\reducedit\itshape{10}{1000}{OT1IT}
+\setfont\reducedsl\slshape{10}{1000}{OT1}
+\setfont\reducedsf\sfshape{10}{1000}{OT1}
+\setfont\reducedsc\scshape{10}{1000}{OT1}
+\setfont\reducedttsl\ttslshape{10}{1000}{OT1TT}
+\font\reducedi=cmmi10
+\font\reducedsy=cmsy10
+\def\reducedecsize{1000}
+
+\textleading = 13.2pt % line spacing for 11pt CM
+\textfonts % reset the current fonts
+\rm
+} % end of 11pt text font size definitions, \definetextfontsizexi
+
+
+% Definitions to make the main text be 10pt Computer Modern, with
+% section, chapter, etc., sizes following suit. This is for the GNU
+% Press printing of the Emacs 22 manual. Maybe other manuals in the
+% future. Used with @smallbook, which sets the leading to 12pt.
+%
+\def\definetextfontsizex{%
+% Text fonts (10pt).
+\def\textnominalsize{10pt}
+\edef\mainmagstep{1000}
+\setfont\textrm\rmshape{10}{\mainmagstep}{OT1}
+\setfont\texttt\ttshape{10}{\mainmagstep}{OT1TT}
+\setfont\textbf\bfshape{10}{\mainmagstep}{OT1}
+\setfont\textit\itshape{10}{\mainmagstep}{OT1IT}
+\setfont\textsl\slshape{10}{\mainmagstep}{OT1}
+\setfont\textsf\sfshape{10}{\mainmagstep}{OT1}
+\setfont\textsc\scshape{10}{\mainmagstep}{OT1}
+\setfont\textttsl\ttslshape{10}{\mainmagstep}{OT1TT}
+\font\texti=cmmi10 scaled \mainmagstep
+\font\textsy=cmsy10 scaled \mainmagstep
+\def\textecsize{1000}
+
+% A few fonts for @defun names and args.
+\setfont\defbf\bfshape{10}{\magstephalf}{OT1}
+\setfont\deftt\ttshape{10}{\magstephalf}{OT1TT}
+\setfont\defttsl\ttslshape{10}{\magstephalf}{OT1TT}
+\def\df{\let\tentt=\deftt \let\tenbf = \defbf \let\tenttsl=\defttsl \bf}
+
+% Fonts for indices, footnotes, small examples (9pt).
+\def\smallnominalsize{9pt}
+\setfont\smallrm\rmshape{9}{1000}{OT1}
+\setfont\smalltt\ttshape{9}{1000}{OT1TT}
+\setfont\smallbf\bfshape{10}{900}{OT1}
+\setfont\smallit\itshape{9}{1000}{OT1IT}
+\setfont\smallsl\slshape{9}{1000}{OT1}
+\setfont\smallsf\sfshape{9}{1000}{OT1}
+\setfont\smallsc\scshape{10}{900}{OT1}
+\setfont\smallttsl\ttslshape{10}{900}{OT1TT}
+\font\smalli=cmmi9
+\font\smallsy=cmsy9
+\def\smallecsize{0900}
+
+% Fonts for small examples (8pt).
+\def\smallernominalsize{8pt}
+\setfont\smallerrm\rmshape{8}{1000}{OT1}
+\setfont\smallertt\ttshape{8}{1000}{OT1TT}
+\setfont\smallerbf\bfshape{10}{800}{OT1}
+\setfont\smallerit\itshape{8}{1000}{OT1IT}
+\setfont\smallersl\slshape{8}{1000}{OT1}
+\setfont\smallersf\sfshape{8}{1000}{OT1}
+\setfont\smallersc\scshape{10}{800}{OT1}
+\setfont\smallerttsl\ttslshape{10}{800}{OT1TT}
+\font\smalleri=cmmi8
+\font\smallersy=cmsy8
+\def\smallerecsize{0800}
+
+% Fonts for title page (20.4pt):
+\def\titlenominalsize{20pt}
+\setfont\titlerm\rmbshape{12}{\magstep3}{OT1}
+\setfont\titleit\itbshape{10}{\magstep4}{OT1IT}
+\setfont\titlesl\slbshape{10}{\magstep4}{OT1}
+\setfont\titlett\ttbshape{12}{\magstep3}{OT1TT}
+\setfont\titlettsl\ttslshape{10}{\magstep4}{OT1TT}
+\setfont\titlesf\sfbshape{17}{\magstep1}{OT1}
+\let\titlebf=\titlerm
+\setfont\titlesc\scbshape{10}{\magstep4}{OT1}
+\font\titlei=cmmi12 scaled \magstep3
+\font\titlesy=cmsy10 scaled \magstep4
+\def\titleecsize{2074}
+
+% Chapter fonts (14.4pt).
+\def\chapnominalsize{14pt}
+\setfont\chaprm\rmbshape{12}{\magstep1}{OT1}
+\setfont\chapit\itbshape{10}{\magstep2}{OT1IT}
+\setfont\chapsl\slbshape{10}{\magstep2}{OT1}
+\setfont\chaptt\ttbshape{12}{\magstep1}{OT1TT}
+\setfont\chapttsl\ttslshape{10}{\magstep2}{OT1TT}
+\setfont\chapsf\sfbshape{12}{\magstep1}{OT1}
+\let\chapbf\chaprm
+\setfont\chapsc\scbshape{10}{\magstep2}{OT1}
+\font\chapi=cmmi12 scaled \magstep1
+\font\chapsy=cmsy10 scaled \magstep2
+\def\chapecsize{1440}
+
+% Section fonts (12pt).
+\def\secnominalsize{12pt}
+\setfont\secrm\rmbshape{12}{1000}{OT1}
+\setfont\secit\itbshape{10}{\magstep1}{OT1IT}
+\setfont\secsl\slbshape{10}{\magstep1}{OT1}
+\setfont\sectt\ttbshape{12}{1000}{OT1TT}
+\setfont\secttsl\ttslshape{10}{\magstep1}{OT1TT}
+\setfont\secsf\sfbshape{12}{1000}{OT1}
+\let\secbf\secrm
+\setfont\secsc\scbshape{10}{\magstep1}{OT1}
+\font\seci=cmmi12
+\font\secsy=cmsy10 scaled \magstep1
+\def\sececsize{1200}
+
+% Subsection fonts (10pt).
+\def\ssecnominalsize{10pt}
+\setfont\ssecrm\rmbshape{10}{1000}{OT1}
+\setfont\ssecit\itbshape{10}{1000}{OT1IT}
+\setfont\ssecsl\slbshape{10}{1000}{OT1}
+\setfont\ssectt\ttbshape{10}{1000}{OT1TT}
+\setfont\ssecttsl\ttslshape{10}{1000}{OT1TT}
+\setfont\ssecsf\sfbshape{10}{1000}{OT1}
+\let\ssecbf\ssecrm
+\setfont\ssecsc\scbshape{10}{1000}{OT1}
+\font\sseci=cmmi10
+\font\ssecsy=cmsy10
+\def\ssececsize{1000}
+
+% Reduced fonts for @acro in text (9pt).
+\def\reducednominalsize{9pt}
+\setfont\reducedrm\rmshape{9}{1000}{OT1}
+\setfont\reducedtt\ttshape{9}{1000}{OT1TT}
+\setfont\reducedbf\bfshape{10}{900}{OT1}
+\setfont\reducedit\itshape{9}{1000}{OT1IT}
+\setfont\reducedsl\slshape{9}{1000}{OT1}
+\setfont\reducedsf\sfshape{9}{1000}{OT1}
+\setfont\reducedsc\scshape{10}{900}{OT1}
+\setfont\reducedttsl\ttslshape{10}{900}{OT1TT}
+\font\reducedi=cmmi9
+\font\reducedsy=cmsy9
+\def\reducedecsize{0900}
+
+\divide\parskip by 2 % reduce space between paragraphs
+\textleading = 12pt % line spacing for 10pt CM
+\textfonts % reset the current fonts
+\rm
+} % end of 10pt text font size definitions, \definetextfontsizex
+
+
+% We provide the user-level command
+% @fonttextsize 10
+% (or 11) to redefine the text font size. pt is assumed.
+%
+\def\xiword{11}
+\def\xword{10}
+\def\xwordpt{10pt}
+%
+\parseargdef\fonttextsize{%
+ \def\textsizearg{#1}%
+ %\wlog{doing @fonttextsize \textsizearg}%
+ %
+ % Set \globaldefs so that documents can use this inside @tex, since
+ % makeinfo 4.8 does not support it, but we need it nonetheless.
+ %
+ \begingroup \globaldefs=1
+ \ifx\textsizearg\xword \definetextfontsizex
+ \else \ifx\textsizearg\xiword \definetextfontsizexi
+ \else
+ \errhelp=\EMsimple
+ \errmessage{@fonttextsize only supports `10' or `11', not `\textsizearg'}
+ \fi\fi
+ \endgroup
+}
+
+
+% In order for the font changes to affect most math symbols and letters,
+% we have to define the \textfont of the standard families. Since
+% texinfo doesn't allow for producing subscripts and superscripts except
+% in the main text, we don't bother to reset \scriptfont and
+% \scriptscriptfont (which would also require loading a lot more fonts).
+%
+\def\resetmathfonts{%
+ \textfont0=\tenrm \textfont1=\teni \textfont2=\tensy
+ \textfont\itfam=\tenit \textfont\slfam=\tensl \textfont\bffam=\tenbf
+ \textfont\ttfam=\tentt \textfont\sffam=\tensf
+}
+
+% The font-changing commands redefine the meanings of \tenSTYLE, instead
+% of just \STYLE. We do this because \STYLE needs to also set the
+% current \fam for math mode. Our \STYLE (e.g., \rm) commands hardwire
+% \tenSTYLE to set the current font.
+%
+% Each font-changing command also sets the names \lsize (one size lower)
+% and \lllsize (three sizes lower). These relative commands are used in
+% the LaTeX logo and acronyms.
+%
+% This all needs generalizing, badly.
+%
+\def\textfonts{%
+ \let\tenrm=\textrm \let\tenit=\textit \let\tensl=\textsl
+ \let\tenbf=\textbf \let\tentt=\texttt \let\smallcaps=\textsc
+ \let\tensf=\textsf \let\teni=\texti \let\tensy=\textsy
+ \let\tenttsl=\textttsl
+ \def\curfontsize{text}%
+ \def\lsize{reduced}\def\lllsize{smaller}%
+ \resetmathfonts \setleading{\textleading}}
+\def\titlefonts{%
+ \let\tenrm=\titlerm \let\tenit=\titleit \let\tensl=\titlesl
+ \let\tenbf=\titlebf \let\tentt=\titlett \let\smallcaps=\titlesc
+ \let\tensf=\titlesf \let\teni=\titlei \let\tensy=\titlesy
+ \let\tenttsl=\titlettsl
+ \def\curfontsize{title}%
+ \def\lsize{chap}\def\lllsize{subsec}%
+ \resetmathfonts \setleading{27pt}}
+\def\titlefont#1{{\titlefonts\rmisbold #1}}
+\def\chapfonts{%
+ \let\tenrm=\chaprm \let\tenit=\chapit \let\tensl=\chapsl
+ \let\tenbf=\chapbf \let\tentt=\chaptt \let\smallcaps=\chapsc
+ \let\tensf=\chapsf \let\teni=\chapi \let\tensy=\chapsy
+ \let\tenttsl=\chapttsl
+ \def\curfontsize{chap}%
+ \def\lsize{sec}\def\lllsize{text}%
+ \resetmathfonts \setleading{19pt}}
+\def\secfonts{%
+ \let\tenrm=\secrm \let\tenit=\secit \let\tensl=\secsl
+ \let\tenbf=\secbf \let\tentt=\sectt \let\smallcaps=\secsc
+ \let\tensf=\secsf \let\teni=\seci \let\tensy=\secsy
+ \let\tenttsl=\secttsl
+ \def\curfontsize{sec}%
+ \def\lsize{subsec}\def\lllsize{reduced}%
+ \resetmathfonts \setleading{16pt}}
+\def\subsecfonts{%
+ \let\tenrm=\ssecrm \let\tenit=\ssecit \let\tensl=\ssecsl
+ \let\tenbf=\ssecbf \let\tentt=\ssectt \let\smallcaps=\ssecsc
+ \let\tensf=\ssecsf \let\teni=\sseci \let\tensy=\ssecsy
+ \let\tenttsl=\ssecttsl
+ \def\curfontsize{ssec}%
+ \def\lsize{text}\def\lllsize{small}%
+ \resetmathfonts \setleading{15pt}}
+\let\subsubsecfonts = \subsecfonts
+\def\reducedfonts{%
+ \let\tenrm=\reducedrm \let\tenit=\reducedit \let\tensl=\reducedsl
+ \let\tenbf=\reducedbf \let\tentt=\reducedtt \let\reducedcaps=\reducedsc
+ \let\tensf=\reducedsf \let\teni=\reducedi \let\tensy=\reducedsy
+ \let\tenttsl=\reducedttsl
+ \def\curfontsize{reduced}%
+ \def\lsize{small}\def\lllsize{smaller}%
+ \resetmathfonts \setleading{10.5pt}}
+\def\smallfonts{%
+ \let\tenrm=\smallrm \let\tenit=\smallit \let\tensl=\smallsl
+ \let\tenbf=\smallbf \let\tentt=\smalltt \let\smallcaps=\smallsc
+ \let\tensf=\smallsf \let\teni=\smalli \let\tensy=\smallsy
+ \let\tenttsl=\smallttsl
+ \def\curfontsize{small}%
+ \def\lsize{smaller}\def\lllsize{smaller}%
+ \resetmathfonts \setleading{10.5pt}}
+\def\smallerfonts{%
+ \let\tenrm=\smallerrm \let\tenit=\smallerit \let\tensl=\smallersl
+ \let\tenbf=\smallerbf \let\tentt=\smallertt \let\smallcaps=\smallersc
+ \let\tensf=\smallersf \let\teni=\smalleri \let\tensy=\smallersy
+ \let\tenttsl=\smallerttsl
+ \def\curfontsize{smaller}%
+ \def\lsize{smaller}\def\lllsize{smaller}%
+ \resetmathfonts \setleading{9.5pt}}
+
+% Fonts for short table of contents.
+\setfont\shortcontrm\rmshape{12}{1000}{OT1}
+\setfont\shortcontbf\bfshape{10}{\magstep1}{OT1} % no cmb12
+\setfont\shortcontsl\slshape{12}{1000}{OT1}
+\setfont\shortconttt\ttshape{12}{1000}{OT1TT}
+
+% Define these just so they can be easily changed for other fonts.
+\def\angleleft{$\langle$}
+\def\angleright{$\rangle$}
+
+% Set the fonts to use with the @small... environments.
+\let\smallexamplefonts = \smallfonts
+
+% About \smallexamplefonts. If we use \smallfonts (9pt), @smallexample
+% can fit this many characters:
+% 8.5x11=86 smallbook=72 a4=90 a5=69
+% If we use \scriptfonts (8pt), then we can fit this many characters:
+% 8.5x11=90+ smallbook=80 a4=90+ a5=77
+% For me, subjectively, the few extra characters that fit aren't worth
+% the additional smallness of 8pt. So I'm making the default 9pt.
+%
+% By the way, for comparison, here's what fits with @example (10pt):
+% 8.5x11=71 smallbook=60 a4=75 a5=58
+% --karl, 24jan03.
+
+% Set up the default fonts, so we can use them for creating boxes.
+%
+\definetextfontsizexi
+
+
+\message{markup,}
+
+% Check if we are currently using a typewriter font. Since all the
+% Computer Modern typewriter fonts have zero interword stretch (and
+% shrink), and it is reasonable to expect all typewriter fonts to have
+% this property, we can check that font parameter.
+%
+\def\ifmonospace{\ifdim\fontdimen3\font=0pt }
+
+% Markup style infrastructure. \defmarkupstylesetup\INITMACRO will
+% define and register \INITMACRO to be called on markup style changes.
+% \INITMACRO can check \currentmarkupstyle for the innermost
+% style and the set of \ifmarkupSTYLE switches for all styles
+% currently in effect.
+\newif\ifmarkupvar
+\newif\ifmarkupsamp
+\newif\ifmarkupkey
+%\newif\ifmarkupfile % @file == @samp.
+%\newif\ifmarkupoption % @option == @samp.
+\newif\ifmarkupcode
+\newif\ifmarkupkbd
+%\newif\ifmarkupenv % @env == @code.
+%\newif\ifmarkupcommand % @command == @code.
+\newif\ifmarkuptex % @tex (and part of @math, for now).
+\newif\ifmarkupexample
+\newif\ifmarkupverb
+\newif\ifmarkupverbatim
+
+\let\currentmarkupstyle\empty
+
+\def\setupmarkupstyle#1{%
+ \csname markup#1true\endcsname
+ \def\currentmarkupstyle{#1}%
+ \markupstylesetup
+}
+
+\let\markupstylesetup\empty
+
+\def\defmarkupstylesetup#1{%
+ \expandafter\def\expandafter\markupstylesetup
+ \expandafter{\markupstylesetup #1}%
+ \def#1%
+}
+
+% Markup style setup for left and right quotes.
+\defmarkupstylesetup\markupsetuplq{%
+ \expandafter\let\expandafter \temp
+ \csname markupsetuplq\currentmarkupstyle\endcsname
+ \ifx\temp\relax \markupsetuplqdefault \else \temp \fi
+}
+
+\defmarkupstylesetup\markupsetuprq{%
+ \expandafter\let\expandafter \temp
+ \csname markupsetuprq\currentmarkupstyle\endcsname
+ \ifx\temp\relax \markupsetuprqdefault \else \temp \fi
+}
+
+{
+\catcode`\'=\active
+\catcode`\`=\active
+
+\gdef\markupsetuplqdefault{\let`\lq}
+\gdef\markupsetuprqdefault{\let'\rq}
+
+\gdef\markupsetcodequoteleft{\let`\codequoteleft}
+\gdef\markupsetcodequoteright{\let'\codequoteright}
+}
+
+\let\markupsetuplqcode \markupsetcodequoteleft
+\let\markupsetuprqcode \markupsetcodequoteright
+%
+\let\markupsetuplqexample \markupsetcodequoteleft
+\let\markupsetuprqexample \markupsetcodequoteright
+%
+\let\markupsetuplqkbd \markupsetcodequoteleft
+\let\markupsetuprqkbd \markupsetcodequoteright
+%
+\let\markupsetuplqsamp \markupsetcodequoteleft
+\let\markupsetuprqsamp \markupsetcodequoteright
+%
+\let\markupsetuplqverb \markupsetcodequoteleft
+\let\markupsetuprqverb \markupsetcodequoteright
+%
+\let\markupsetuplqverbatim \markupsetcodequoteleft
+\let\markupsetuprqverbatim \markupsetcodequoteright
+
+% Allow an option to not use regular directed right quote/apostrophe
+% (char 0x27), but instead the undirected quote from cmtt (char 0x0d).
+% The undirected quote is ugly, so don't make it the default, but it
+% works for pasting with more pdf viewers (at least evince), the
+% lilypond developers report. xpdf does work with the regular 0x27.
+%
+\def\codequoteright{%
+ \expandafter\ifx\csname SETtxicodequoteundirected\endcsname\relax
+ \expandafter\ifx\csname SETcodequoteundirected\endcsname\relax
+ '%
+ \else \char'15 \fi
+ \else \char'15 \fi
+}
+%
+% and a similar option for the left quote char vs. a grave accent.
+% Modern fonts display ASCII 0x60 as a grave accent, so some people like
+% the code environments to do likewise.
+%
+\def\codequoteleft{%
+ \expandafter\ifx\csname SETtxicodequotebacktick\endcsname\relax
+ \expandafter\ifx\csname SETcodequotebacktick\endcsname\relax
+ % [Knuth] pp. 380,381,391
+ % \relax disables Spanish ligatures ?` and !` of \tt font.
+ \relax`%
+ \else \char'22 \fi
+ \else \char'22 \fi
+}
+
+% Commands to set the quote options.
+%
+\parseargdef\codequoteundirected{%
+ \def\temp{#1}%
+ \ifx\temp\onword
+ \expandafter\let\csname SETtxicodequoteundirected\endcsname
+ = t%
+ \else\ifx\temp\offword
+ \expandafter\let\csname SETtxicodequoteundirected\endcsname
+ = \relax
+ \else
+ \errhelp = \EMsimple
+ \errmessage{Unknown @codequoteundirected value `\temp', must be on|off}%
+ \fi\fi
+}
+%
+\parseargdef\codequotebacktick{%
+ \def\temp{#1}%
+ \ifx\temp\onword
+ \expandafter\let\csname SETtxicodequotebacktick\endcsname
+ = t%
+ \else\ifx\temp\offword
+ \expandafter\let\csname SETtxicodequotebacktick\endcsname
+ = \relax
+ \else
+ \errhelp = \EMsimple
+ \errmessage{Unknown @codequotebacktick value `\temp', must be on|off}%
+ \fi\fi
+}
+
+% [Knuth] pp. 380,381,391, disable Spanish ligatures ?` and !` of \tt font.
+\def\noligaturesquoteleft{\relax\lq}
+
+% Count depth in font-changes, for error checks
+\newcount\fontdepth \fontdepth=0
+
+% Font commands.
+
+% #1 is the font command (\sl or \it), #2 is the text to slant.
+% If we are in a monospaced environment, however, 1) always use \ttsl,
+% and 2) do not add an italic correction.
+\def\dosmartslant#1#2{%
+ \ifusingtt
+ {{\ttsl #2}\let\next=\relax}%
+ {\def\next{{#1#2}\futurelet\next\smartitaliccorrection}}%
+ \next
+}
+\def\smartslanted{\dosmartslant\sl}
+\def\smartitalic{\dosmartslant\it}
+
+% Output an italic correction unless \next (presumed to be the following
+% character) is such as not to need one.
+\def\smartitaliccorrection{%
+ \ifx\next,%
+ \else\ifx\next-%
+ \else\ifx\next.%
+ \else\ptexslash
+ \fi\fi\fi
+ \aftersmartic
+}
+
+% Unconditional use \ttsl, and no ic. @var is set to this for defuns.
+\def\ttslanted#1{{\ttsl #1}}
+
+% @cite is like \smartslanted except unconditionally use \sl. We never want
+% ttsl for book titles, do we?
+\def\cite#1{{\sl #1}\futurelet\next\smartitaliccorrection}
+
+\def\aftersmartic{}
+\def\var#1{%
+ \let\saveaftersmartic = \aftersmartic
+ \def\aftersmartic{\null\let\aftersmartic=\saveaftersmartic}%
+ \smartslanted{#1}%
+}
+
+\let\i=\smartitalic
+\let\slanted=\smartslanted
+\let\dfn=\smartslanted
+\let\emph=\smartitalic
+
+% Explicit font changes: @r, @sc, undocumented @ii.
+\def\r#1{{\rm #1}} % roman font
+\def\sc#1{{\smallcaps#1}} % smallcaps font
+\def\ii#1{{\it #1}} % italic font
+
+% @b, explicit bold. Also @strong.
+\def\b#1{{\bf #1}}
+\let\strong=\b
+
+% @sansserif, explicit sans.
+\def\sansserif#1{{\sf #1}}
+
+% We can't just use \exhyphenpenalty, because that only has effect at
+% the end of a paragraph. Restore normal hyphenation at the end of the
+% group within which \nohyphenation is presumably called.
+%
+\def\nohyphenation{\hyphenchar\font = -1 \aftergroup\restorehyphenation}
+\def\restorehyphenation{\hyphenchar\font = `- }
+
+% Set sfcode to normal for the chars that usually have another value.
+% Can't use plain's \frenchspacing because it uses the `\x notation, and
+% sometimes \x has an active definition that messes things up.
+%
+\catcode`@=11
+ \def\plainfrenchspacing{%
+ \sfcode\dotChar =\@m \sfcode\questChar=\@m \sfcode\exclamChar=\@m
+ \sfcode\colonChar=\@m \sfcode\semiChar =\@m \sfcode\commaChar =\@m
+ \def\endofsentencespacefactor{1000}% for @. and friends
+ }
+ \def\plainnonfrenchspacing{%
+ \sfcode`\.3000\sfcode`\?3000\sfcode`\!3000
+ \sfcode`\:2000\sfcode`\;1500\sfcode`\,1250
+ \def\endofsentencespacefactor{3000}% for @. and friends
+ }
+\catcode`@=\other
+\def\endofsentencespacefactor{3000}% default
+
+% @t, explicit typewriter.
+\def\t#1{%
+ {\tt \rawbackslash \plainfrenchspacing #1}%
+ \null
+}
+
+% @samp.
+\def\samp#1{{\setupmarkupstyle{samp}\lq\tclose{#1}\rq\null}}
+
+% @indicateurl is \samp, that is, with quotes.
+\let\indicateurl=\samp
+
+% @code (and similar) prints in typewriter, but with spaces the same
+% size as normal in the surrounding text, without hyphenation, etc.
+% This is a subroutine for that.
+\def\tclose#1{%
+ {%
+ % Change normal interword space to be same as for the current font.
+ \spaceskip = \fontdimen2\font
+ %
+ % Switch to typewriter.
+ \tt
+ %
+ % But `\ ' produces the large typewriter interword space.
+ \def\ {{\spaceskip = 0pt{} }}%
+ %
+ % Turn off hyphenation.
+ \nohyphenation
+ %
+ \rawbackslash
+ \plainfrenchspacing
+ #1%
+ }%
+ \null % reset spacefactor to 1000
+}
+
+% We *must* turn on hyphenation at `-' and `_' in @code.
+% Otherwise, it is too hard to avoid overfull hboxes
+% in the Emacs manual, the Library manual, etc.
+%
+% Unfortunately, TeX uses one parameter (\hyphenchar) to control
+% both hyphenation at - and hyphenation within words.
+% We must therefore turn them both off (\tclose does that)
+% and arrange explicitly to hyphenate at a dash.
+% -- rms.
+{
+ \catcode`\-=\active \catcode`\_=\active
+ \catcode`\'=\active \catcode`\`=\active
+ \global\let'=\rq \global\let`=\lq % default definitions
+ %
+ \global\def\code{\begingroup
+ \setupmarkupstyle{code}%
+ % The following should really be moved into \setupmarkupstyle handlers.
+ \catcode\dashChar=\active \catcode\underChar=\active
+ \ifallowcodebreaks
+ \let-\codedash
+ \let_\codeunder
+ \else
+ \let-\normaldash
+ \let_\realunder
+ \fi
+ \codex
+ }
+}
+
+\def\codex #1{\tclose{#1}\endgroup}
+
+\def\normaldash{-}
+\def\codedash{-\discretionary{}{}{}}
+\def\codeunder{%
+ % this is all so @math{@code{var_name}+1} can work. In math mode, _
+ % is "active" (mathcode"8000) and \normalunderscore (or \char95, etc.)
+ % will therefore expand the active definition of _, which is us
+ % (inside @code that is), therefore an endless loop.
+ \ifusingtt{\ifmmode
+ \mathchar"075F % class 0=ordinary, family 7=ttfam, pos 0x5F=_.
+ \else\normalunderscore \fi
+ \discretionary{}{}{}}%
+ {\_}%
+}
+
+% An additional complication: the above will allow breaks after, e.g.,
+% each of the four underscores in __typeof__. This is bad.
+% @allowcodebreaks provides a document-level way to turn breaking at -
+% and _ on and off.
+%
+\newif\ifallowcodebreaks \allowcodebreakstrue
+
+\def\keywordtrue{true}
+\def\keywordfalse{false}
+
+\parseargdef\allowcodebreaks{%
+ \def\txiarg{#1}%
+ \ifx\txiarg\keywordtrue
+ \allowcodebreakstrue
+ \else\ifx\txiarg\keywordfalse
+ \allowcodebreaksfalse
+ \else
+ \errhelp = \EMsimple
+ \errmessage{Unknown @allowcodebreaks option `\txiarg', must be true|false}%
+ \fi\fi
+}
+
+% For @command, @env, @file, @option quotes seem unnecessary,
+% so use \code rather than \samp.
+\let\command=\code
+\let\env=\code
+\let\file=\code
+\let\option=\code
+
+% @uref (abbreviation for `urlref') takes an optional (comma-separated)
+% second argument specifying the text to display and an optional third
+% arg as text to display instead of (rather than in addition to) the url
+% itself. First (mandatory) arg is the url.
+% (This \urefnobreak definition isn't used now, leaving it for a while
+% for comparison.)
+\def\urefnobreak#1{\dourefnobreak #1,,,\finish}
+\def\dourefnobreak#1,#2,#3,#4\finish{\begingroup
+ \unsepspaces
+ \pdfurl{#1}%
+ \setbox0 = \hbox{\ignorespaces #3}%
+ \ifdim\wd0 > 0pt
+ \unhbox0 % third arg given, show only that
+ \else
+ \setbox0 = \hbox{\ignorespaces #2}%
+ \ifdim\wd0 > 0pt
+ \ifpdf
+ \unhbox0 % PDF: 2nd arg given, show only it
+ \else
+ \unhbox0\ (\code{#1})% DVI: 2nd arg given, show both it and url
+ \fi
+ \else
+ \code{#1}% only url given, so show it
+ \fi
+ \fi
+ \endlink
+\endgroup}
+
+% This \urefbreak definition is the active one.
+\def\urefbreak{\begingroup \urefcatcodes \dourefbreak}
+\let\uref=\urefbreak
+\def\dourefbreak#1{\urefbreakfinish #1,,,\finish}
+\def\urefbreakfinish#1,#2,#3,#4\finish{% doesn't work in @example
+ \unsepspaces
+ \pdfurl{#1}%
+ \setbox0 = \hbox{\ignorespaces #3}%
+ \ifdim\wd0 > 0pt
+ \unhbox0 % third arg given, show only that
+ \else
+ \setbox0 = \hbox{\ignorespaces #2}%
+ \ifdim\wd0 > 0pt
+ \ifpdf
+ \unhbox0 % PDF: 2nd arg given, show only it
+ \else
+ \unhbox0\ (\urefcode{#1})% DVI: 2nd arg given, show both it and url
+ \fi
+ \else
+ \urefcode{#1}% only url given, so show it
+ \fi
+ \fi
+ \endlink
+\endgroup}
+
+% Allow line breaks around only a few characters (only).
+\def\urefcatcodes{%
+ \catcode\ampChar=\active \catcode\dotChar=\active
+ \catcode\hashChar=\active \catcode\questChar=\active
+ \catcode\slashChar=\active
+}
+{
+ \urefcatcodes
+ %
+ \global\def\urefcode{\begingroup
+ \setupmarkupstyle{code}%
+ \urefcatcodes
+ \let&\urefcodeamp
+ \let.\urefcodedot
+ \let#\urefcodehash
+ \let?\urefcodequest
+ \let/\urefcodeslash
+ \codex
+ }
+ %
+ % By default, they are just regular characters.
+ \global\def&{\normalamp}
+ \global\def.{\normaldot}
+ \global\def#{\normalhash}
+ \global\def?{\normalquest}
+ \global\def/{\normalslash}
+}
+
+% we put a little stretch before and after the breakable chars, to help
+% line breaking of long url's. The unequal skips make look better in
+% cmtt at least, especially for dots.
+\def\urefprestretch{\urefprebreak \hskip0pt plus.13em }
+\def\urefpoststretch{\urefpostbreak \hskip0pt plus.1em }
+%
+\def\urefcodeamp{\urefprestretch \&\urefpoststretch}
+\def\urefcodedot{\urefprestretch .\urefpoststretch}
+\def\urefcodehash{\urefprestretch \#\urefpoststretch}
+\def\urefcodequest{\urefprestretch ?\urefpoststretch}
+\def\urefcodeslash{\futurelet\next\urefcodeslashfinish}
+{
+ \catcode`\/=\active
+ \global\def\urefcodeslashfinish{%
+ \urefprestretch \slashChar
+ % Allow line break only after the final / in a sequence of
+ % slashes, to avoid line break between the slashes in http://.
+ \ifx\next/\else \urefpoststretch \fi
+ }
+}
+
+% One more complication: by default we'll break after the special
+% characters, but some people like to break before the special chars, so
+% allow that. Also allow no breaking at all, for manual control.
+%
+\parseargdef\urefbreakstyle{%
+ \def\txiarg{#1}%
+ \ifx\txiarg\wordnone
+ \def\urefprebreak{\nobreak}\def\urefpostbreak{\nobreak}
+ \else\ifx\txiarg\wordbefore
+ \def\urefprebreak{\allowbreak}\def\urefpostbreak{\nobreak}
+ \else\ifx\txiarg\wordafter
+ \def\urefprebreak{\nobreak}\def\urefpostbreak{\allowbreak}
+ \else
+ \errhelp = \EMsimple
+ \errmessage{Unknown @urefbreakstyle setting `\txiarg'}%
+ \fi\fi\fi
+}
+\def\wordafter{after}
+\def\wordbefore{before}
+\def\wordnone{none}
+
+\urefbreakstyle after
+
+% @url synonym for @uref, since that's how everyone uses it.
+%
+\let\url=\uref
+
+% rms does not like angle brackets --karl, 17may97.
+% So now @email is just like @uref, unless we are pdf.
+%
+%\def\email#1{\angleleft{\tt #1}\angleright}
+\ifpdf
+ \def\email#1{\doemail#1,,\finish}
+ \def\doemail#1,#2,#3\finish{\begingroup
+ \unsepspaces
+ \pdfurl{mailto:#1}%
+ \setbox0 = \hbox{\ignorespaces #2}%
+ \ifdim\wd0>0pt\unhbox0\else\code{#1}\fi
+ \endlink
+ \endgroup}
+\else
+ \let\email=\uref
+\fi
+
+% @kbdinputstyle -- arg is `distinct' (@kbd uses slanted tty font always),
+% `example' (@kbd uses ttsl only inside of @example and friends),
+% or `code' (@kbd uses normal tty font always).
+\parseargdef\kbdinputstyle{%
+ \def\txiarg{#1}%
+ \ifx\txiarg\worddistinct
+ \gdef\kbdexamplefont{\ttsl}\gdef\kbdfont{\ttsl}%
+ \else\ifx\txiarg\wordexample
+ \gdef\kbdexamplefont{\ttsl}\gdef\kbdfont{\tt}%
+ \else\ifx\txiarg\wordcode
+ \gdef\kbdexamplefont{\tt}\gdef\kbdfont{\tt}%
+ \else
+ \errhelp = \EMsimple
+ \errmessage{Unknown @kbdinputstyle setting `\txiarg'}%
+ \fi\fi\fi
+}
+\def\worddistinct{distinct}
+\def\wordexample{example}
+\def\wordcode{code}
+
+% Default is `distinct'.
+\kbdinputstyle distinct
+
+% @kbd is like @code, except that if the argument is just one @key command,
+% then @kbd has no effect.
+\def\kbd#1{{\def\look{#1}\expandafter\kbdsub\look??\par}}
+
+\def\xkey{\key}
+\def\kbdsub#1#2#3\par{%
+ \def\one{#1}\def\three{#3}\def\threex{??}%
+ \ifx\one\xkey\ifx\threex\three \key{#2}%
+ \else{\tclose{\kbdfont\setupmarkupstyle{kbd}\look}}\fi
+ \else{\tclose{\kbdfont\setupmarkupstyle{kbd}\look}}\fi
+}
+
+% definition of @key that produces a lozenge. Doesn't adjust to text size.
+%\setfont\keyrm\rmshape{8}{1000}{OT1}
+%\font\keysy=cmsy9
+%\def\key#1{{\keyrm\textfont2=\keysy \leavevmode\hbox{%
+% \raise0.4pt\hbox{\angleleft}\kern-.08em\vtop{%
+% \vbox{\hrule\kern-0.4pt
+% \hbox{\raise0.4pt\hbox{\vphantom{\angleleft}}#1}}%
+% \kern-0.4pt\hrule}%
+% \kern-.06em\raise0.4pt\hbox{\angleright}}}}
+
+% definition of @key with no lozenge. If the current font is already
+% monospace, don't change it; that way, we respect @kbdinputstyle. But
+% if it isn't monospace, then use \tt.
+%
+\def\key#1{{\setupmarkupstyle{key}%
+ \nohyphenation
+ \ifmonospace\else\tt\fi
+ #1}\null}
+
+% @clicksequence{File @click{} Open ...}
+\def\clicksequence#1{\begingroup #1\endgroup}
+
+% @clickstyle @arrow (by default)
+\parseargdef\clickstyle{\def\click{#1}}
+\def\click{\arrow}
+
+% Typeset a dimension, e.g., `in' or `pt'. The only reason for the
+% argument is to make the input look right: @dmn{pt} instead of @dmn{}pt.
+%
+\def\dmn#1{\thinspace #1}
+
+% @l was never documented to mean ``switch to the Lisp font'',
+% and it is not used as such in any manual I can find. We need it for
+% Polish suppressed-l. --karl, 22sep96.
+%\def\l#1{{\li #1}\null}
+
+% @acronym for "FBI", "NATO", and the like.
+% We print this one point size smaller, since it's intended for
+% all-uppercase.
+%
+\def\acronym#1{\doacronym #1,,\finish}
+\def\doacronym#1,#2,#3\finish{%
+ {\selectfonts\lsize #1}%
+ \def\temp{#2}%
+ \ifx\temp\empty \else
+ \space ({\unsepspaces \ignorespaces \temp \unskip})%
+ \fi
+ \null % reset \spacefactor=1000
+}
+
+% @abbr for "Comput. J." and the like.
+% No font change, but don't do end-of-sentence spacing.
+%
+\def\abbr#1{\doabbr #1,,\finish}
+\def\doabbr#1,#2,#3\finish{%
+ {\plainfrenchspacing #1}%
+ \def\temp{#2}%
+ \ifx\temp\empty \else
+ \space ({\unsepspaces \ignorespaces \temp \unskip})%
+ \fi
+ \null % reset \spacefactor=1000
+}
+
+% @asis just yields its argument. Used with @table, for example.
+%
+\def\asis#1{#1}
+
+% @math outputs its argument in math mode.
+%
+% One complication: _ usually means subscripts, but it could also mean
+% an actual _ character, as in @math{@var{some_variable} + 1}. So make
+% _ active, and distinguish by seeing if the current family is \slfam,
+% which is what @var uses.
+{
+ \catcode`\_ = \active
+ \gdef\mathunderscore{%
+ \catcode`\_=\active
+ \def_{\ifnum\fam=\slfam \_\else\sb\fi}%
+ }
+}
+% Another complication: we want \\ (and @\) to output a math (or tt) \.
+% FYI, plain.tex uses \\ as a temporary control sequence (for no
+% particular reason), but this is not advertised and we don't care.
+%
+% The \mathchar is class=0=ordinary, family=7=ttfam, position=5C=\.
+\def\mathbackslash{\ifnum\fam=\ttfam \mathchar"075C \else\backslash \fi}
+%
+\def\math{%
+ \tex
+ \mathunderscore
+ \let\\ = \mathbackslash
+ \mathactive
+ % make the texinfo accent commands work in math mode
+ \let\"=\ddot
+ \let\'=\acute
+ \let\==\bar
+ \let\^=\hat
+ \let\`=\grave
+ \let\u=\breve
+ \let\v=\check
+ \let\~=\tilde
+ \let\dotaccent=\dot
+ $\finishmath
+}
+\def\finishmath#1{#1$\endgroup} % Close the group opened by \tex.
+
+% Some active characters (such as <) are spaced differently in math.
+% We have to reset their definitions in case the @math was an argument
+% to a command which sets the catcodes (such as @item or @section).
+%
+{
+ \catcode`^ = \active
+ \catcode`< = \active
+ \catcode`> = \active
+ \catcode`+ = \active
+ \catcode`' = \active
+ \gdef\mathactive{%
+ \let^ = \ptexhat
+ \let< = \ptexless
+ \let> = \ptexgtr
+ \let+ = \ptexplus
+ \let' = \ptexquoteright
+ }
+}
+
+% ctrl is no longer a Texinfo command, but leave this definition for fun.
+\def\ctrl #1{{\tt \rawbackslash \hat}#1}
+
+% @inlinefmt{FMTNAME,PROCESSED-TEXT} and @inlineraw{FMTNAME,RAW-TEXT}.
+% Ignore unless FMTNAME == tex; then it is like @iftex and @tex,
+% except specified as a normal braced arg, so no newlines to worry about.
+%
+\def\outfmtnametex{tex}
+%
+\long\def\inlinefmt#1{\doinlinefmt #1,\finish}
+\long\def\doinlinefmt#1,#2,\finish{%
+ \def\inlinefmtname{#1}%
+ \ifx\inlinefmtname\outfmtnametex \ignorespaces #2\fi
+}
+% For raw, must switch into @tex before parsing the argument, to avoid
+% setting catcodes prematurely. Doing it this way means that, for
+% example, @inlineraw{html, foo{bar} gets a parse error instead of being
+% ignored. But this isn't important because if people want a literal
+% *right* brace they would have to use a command anyway, so they may as
+% well use a command to get a left brace too. We could re-use the
+% delimiter character idea from \verb, but it seems like overkill.
+%
+\long\def\inlineraw{\tex \doinlineraw}
+\long\def\doinlineraw#1{\doinlinerawtwo #1,\finish}
+\def\doinlinerawtwo#1,#2,\finish{%
+ \def\inlinerawname{#1}%
+ \ifx\inlinerawname\outfmtnametex \ignorespaces #2\fi
+ \endgroup % close group opened by \tex.
+}
+
+
+\message{glyphs,}
+% and logos.
+
+% @@ prints an @, as does @atchar{}.
+\def\@{\char64 }
+\let\atchar=\@
+
+% @{ @} @lbracechar{} @rbracechar{} all generate brace characters.
+% Unless we're in typewriter, use \ecfont because the CM text fonts do
+% not have braces, and we don't want to switch into math.
+\def\mylbrace{{\ifmonospace\else\ecfont\fi \char123}}
+\def\myrbrace{{\ifmonospace\else\ecfont\fi \char125}}
+\let\{=\mylbrace \let\lbracechar=\{
+\let\}=\myrbrace \let\rbracechar=\}
+\begingroup
+ % Definitions to produce \{ and \} commands for indices,
+ % and @{ and @} for the aux/toc files.
+ \catcode`\{ = \other \catcode`\} = \other
+ \catcode`\[ = 1 \catcode`\] = 2
+ \catcode`\! = 0 \catcode`\\ = \other
+ !gdef!lbracecmd[\{]%
+ !gdef!rbracecmd[\}]%
+ !gdef!lbraceatcmd[@{]%
+ !gdef!rbraceatcmd[@}]%
+!endgroup
+
+% @comma{} to avoid , parsing problems.
+\let\comma = ,
+
+% Accents: @, @dotaccent @ringaccent @ubaraccent @udotaccent
+% Others are defined by plain TeX: @` @' @" @^ @~ @= @u @v @H.
+\let\, = \ptexc
+\let\dotaccent = \ptexdot
+\def\ringaccent#1{{\accent23 #1}}
+\let\tieaccent = \ptext
+\let\ubaraccent = \ptexb
+\let\udotaccent = \d
+
+% Other special characters: @questiondown @exclamdown @ordf @ordm
+% Plain TeX defines: @AA @AE @O @OE @L (plus lowercase versions) @ss.
+\def\questiondown{?`}
+\def\exclamdown{!`}
+\def\ordf{\leavevmode\raise1ex\hbox{\selectfonts\lllsize \underbar{a}}}
+\def\ordm{\leavevmode\raise1ex\hbox{\selectfonts\lllsize \underbar{o}}}
+
+% Dotless i and dotless j, used for accents.
+\def\imacro{i}
+\def\jmacro{j}
+\def\dotless#1{%
+ \def\temp{#1}%
+ \ifx\temp\imacro \ifmmode\imath \else\ptexi \fi
+ \else\ifx\temp\jmacro \ifmmode\jmath \else\j \fi
+ \else \errmessage{@dotless can be used only with i or j}%
+ \fi\fi
+}
+
+% The \TeX{} logo, as in plain, but resetting the spacing so that a
+% period following counts as ending a sentence. (Idea found in latex.)
+%
+\edef\TeX{\TeX \spacefactor=1000 }
+
+% @LaTeX{} logo. Not quite the same results as the definition in
+% latex.ltx, since we use a different font for the raised A; it's most
+% convenient for us to use an explicitly smaller font, rather than using
+% the \scriptstyle font (since we don't reset \scriptstyle and
+% \scriptscriptstyle).
+%
+\def\LaTeX{%
+ L\kern-.36em
+ {\setbox0=\hbox{T}%
+ \vbox to \ht0{\hbox{%
+ \ifx\textnominalsize\xwordpt
+ % for 10pt running text, \lllsize (8pt) is too small for the A in LaTeX.
+ % Revert to plain's \scriptsize, which is 7pt.
+ \count255=\the\fam $\fam\count255 \scriptstyle A$%
+ \else
+ % For 11pt, we can use our lllsize.
+ \selectfonts\lllsize A%
+ \fi
+ }%
+ \vss
+ }}%
+ \kern-.15em
+ \TeX
+}
+
+% Some math mode symbols.
+\def\bullet{$\ptexbullet$}
+\def\geq{\ifmmode \ge\else $\ge$\fi}
+\def\leq{\ifmmode \le\else $\le$\fi}
+\def\minus{\ifmmode -\else $-$\fi}
+
+% @dots{} outputs an ellipsis using the current font.
+% We do .5em per period so that it has the same spacing in the cm
+% typewriter fonts as three actual period characters; on the other hand,
+% in other typewriter fonts three periods are wider than 1.5em. So do
+% whichever is larger.
+%
+\def\dots{%
+ \leavevmode
+ \setbox0=\hbox{...}% get width of three periods
+ \ifdim\wd0 > 1.5em
+ \dimen0 = \wd0
+ \else
+ \dimen0 = 1.5em
+ \fi
+ \hbox to \dimen0{%
+ \hskip 0pt plus.25fil
+ .\hskip 0pt plus1fil
+ .\hskip 0pt plus1fil
+ .\hskip 0pt plus.5fil
+ }%
+}
+
+% @enddots{} is an end-of-sentence ellipsis.
+%
+\def\enddots{%
+ \dots
+ \spacefactor=\endofsentencespacefactor
+}
+
+% @point{}, @result{}, @expansion{}, @print{}, @equiv{}.
+%
+% Since these characters are used in examples, they should be an even number of
+% \tt widths. Each \tt character is 1en, so two makes it 1em.
+%
+\def\point{$\star$}
+\def\arrow{\leavevmode\raise.05ex\hbox to 1em{\hfil$\rightarrow$\hfil}}
+\def\result{\leavevmode\raise.05ex\hbox to 1em{\hfil$\Rightarrow$\hfil}}
+\def\expansion{\leavevmode\hbox to 1em{\hfil$\mapsto$\hfil}}
+\def\print{\leavevmode\lower.1ex\hbox to 1em{\hfil$\dashv$\hfil}}
+\def\equiv{\leavevmode\hbox to 1em{\hfil$\ptexequiv$\hfil}}
+
+% The @error{} command.
+% Adapted from the TeXbook's \boxit.
+%
+\newbox\errorbox
+%
+{\tentt \global\dimen0 = 3em}% Width of the box.
+\dimen2 = .55pt % Thickness of rules
+% The text. (`r' is open on the right, `e' somewhat less so on the left.)
+\setbox0 = \hbox{\kern-.75pt \reducedsf \putworderror\kern-1.5pt}
+%
+\setbox\errorbox=\hbox to \dimen0{\hfil
+ \hsize = \dimen0 \advance\hsize by -5.8pt % Space to left+right.
+ \advance\hsize by -2\dimen2 % Rules.
+ \vbox{%
+ \hrule height\dimen2
+ \hbox{\vrule width\dimen2 \kern3pt % Space to left of text.
+ \vtop{\kern2.4pt \box0 \kern2.4pt}% Space above/below.
+ \kern3pt\vrule width\dimen2}% Space to right.
+ \hrule height\dimen2}
+ \hfil}
+%
+\def\error{\leavevmode\lower.7ex\copy\errorbox}
+
+% @pounds{} is a sterling sign, which Knuth put in the CM italic font.
+%
+\def\pounds{{\it\$}}
+
+% @euro{} comes from a separate font, depending on the current style.
+% We use the free feym* fonts from the eurosym package by Henrik
+% Theiling, which support regular, slanted, bold and bold slanted (and
+% "outlined" (blackboard board, sort of) versions, which we don't need).
+% It is available from http://www.ctan.org/tex-archive/fonts/eurosym.
+%
+% Although only regular is the truly official Euro symbol, we ignore
+% that. The Euro is designed to be slightly taller than the regular
+% font height.
+%
+% feymr - regular
+% feymo - slanted
+% feybr - bold
+% feybo - bold slanted
+%
+% There is no good (free) typewriter version, to my knowledge.
+% A feymr10 euro is ~7.3pt wide, while a normal cmtt10 char is ~5.25pt wide.
+% Hmm.
+%
+% Also doesn't work in math. Do we need to do math with euro symbols?
+% Hope not.
+%
+%
+\def\euro{{\eurofont e}}
+\def\eurofont{%
+ % We set the font at each command, rather than predefining it in
+ % \textfonts and the other font-switching commands, so that
+ % installations which never need the symbol don't have to have the
+ % font installed.
+ %
+ % There is only one designed size (nominal 10pt), so we always scale
+ % that to the current nominal size.
+ %
+ % By the way, simply using "at 1em" works for cmr10 and the like, but
+ % does not work for cmbx10 and other extended/shrunken fonts.
+ %
+ \def\eurosize{\csname\curfontsize nominalsize\endcsname}%
+ %
+ \ifx\curfontstyle\bfstylename
+ % bold:
+ \font\thiseurofont = \ifusingit{feybo10}{feybr10} at \eurosize
+ \else
+ % regular:
+ \font\thiseurofont = \ifusingit{feymo10}{feymr10} at \eurosize
+ \fi
+ \thiseurofont
+}
+
+% Glyphs from the EC fonts. We don't use \let for the aliases, because
+% sometimes we redefine the original macro, and the alias should reflect
+% the redefinition.
+%
+% Use LaTeX names for the Icelandic letters.
+\def\DH{{\ecfont \char"D0}} % Eth
+\def\dh{{\ecfont \char"F0}} % eth
+\def\TH{{\ecfont \char"DE}} % Thorn
+\def\th{{\ecfont \char"FE}} % thorn
+%
+\def\guillemetleft{{\ecfont \char"13}}
+\def\guillemotleft{\guillemetleft}
+\def\guillemetright{{\ecfont \char"14}}
+\def\guillemotright{\guillemetright}
+\def\guilsinglleft{{\ecfont \char"0E}}
+\def\guilsinglright{{\ecfont \char"0F}}
+\def\quotedblbase{{\ecfont \char"12}}
+\def\quotesinglbase{{\ecfont \char"0D}}
+%
+% This positioning is not perfect (see the ogonek LaTeX package), but
+% we have the precomposed glyphs for the most common cases. We put the
+% tests to use those glyphs in the single \ogonek macro so we have fewer
+% dummy definitions to worry about for index entries, etc.
+%
+% ogonek is also used with other letters in Lithuanian (IOU), but using
+% the precomposed glyphs for those is not so easy since they aren't in
+% the same EC font.
+\def\ogonek#1{{%
+ \def\temp{#1}%
+ \ifx\temp\macrocharA\Aogonek
+ \else\ifx\temp\macrochara\aogonek
+ \else\ifx\temp\macrocharE\Eogonek
+ \else\ifx\temp\macrochare\eogonek
+ \else
+ \ecfont \setbox0=\hbox{#1}%
+ \ifdim\ht0=1ex\accent"0C #1%
+ \else\ooalign{\unhbox0\crcr\hidewidth\char"0C \hidewidth}%
+ \fi
+ \fi\fi\fi\fi
+ }%
+}
+\def\Aogonek{{\ecfont \char"81}}\def\macrocharA{A}
+\def\aogonek{{\ecfont \char"A1}}\def\macrochara{a}
+\def\Eogonek{{\ecfont \char"86}}\def\macrocharE{E}
+\def\eogonek{{\ecfont \char"A6}}\def\macrochare{e}
+%
+% Use the ec* fonts (cm-super in outline format) for non-CM glyphs.
+\def\ecfont{%
+ % We can't distinguish serif/sans and italic/slanted, but this
+ % is used for crude hacks anyway (like adding French and German
+ % quotes to documents typeset with CM, where we lose kerning), so
+ % hopefully nobody will notice/care.
+ \edef\ecsize{\csname\curfontsize ecsize\endcsname}%
+ \edef\nominalsize{\csname\curfontsize nominalsize\endcsname}%
+ \ifmonospace
+ % typewriter:
+ \font\thisecfont = ectt\ecsize \space at \nominalsize
+ \else
+ \ifx\curfontstyle\bfstylename
+ % bold:
+ \font\thisecfont = ecb\ifusingit{i}{x}\ecsize \space at \nominalsize
+ \else
+ % regular:
+ \font\thisecfont = ec\ifusingit{ti}{rm}\ecsize \space at \nominalsize
+ \fi
+ \fi
+ \thisecfont
+}
+
+% @registeredsymbol - R in a circle. The font for the R should really
+% be smaller yet, but lllsize is the best we can do for now.
+% Adapted from the plain.tex definition of \copyright.
+%
+\def\registeredsymbol{%
+ $^{{\ooalign{\hfil\raise.07ex\hbox{\selectfonts\lllsize R}%
+ \hfil\crcr\Orb}}%
+ }$%
+}
+
+% @textdegree - the normal degrees sign.
+%
+\def\textdegree{$^\circ$}
+
+% Laurent Siebenmann reports \Orb undefined with:
+% Textures 1.7.7 (preloaded format=plain 93.10.14) (68K) 16 APR 2004 02:38
+% so we'll define it if necessary.
+%
+\ifx\Orb\thisisundefined
+\def\Orb{\mathhexbox20D}
+\fi
+
+% Quotes.
+\chardef\quotedblleft="5C
+\chardef\quotedblright=`\"
+\chardef\quoteleft=`\`
+\chardef\quoteright=`\'
+
+
+\message{page headings,}
+
+\newskip\titlepagetopglue \titlepagetopglue = 1.5in
+\newskip\titlepagebottomglue \titlepagebottomglue = 2pc
+
+% First the title page. Must do @settitle before @titlepage.
+\newif\ifseenauthor
+\newif\iffinishedtitlepage
+
+% Do an implicit @contents or @shortcontents after @end titlepage if the
+% user says @setcontentsaftertitlepage or @setshortcontentsaftertitlepage.
+%
+\newif\ifsetcontentsaftertitlepage
+ \let\setcontentsaftertitlepage = \setcontentsaftertitlepagetrue
+\newif\ifsetshortcontentsaftertitlepage
+ \let\setshortcontentsaftertitlepage = \setshortcontentsaftertitlepagetrue
+
+\parseargdef\shorttitlepage{%
+ \begingroup \hbox{}\vskip 1.5in \chaprm \centerline{#1}%
+ \endgroup\page\hbox{}\page}
+
+\envdef\titlepage{%
+ % Open one extra group, as we want to close it in the middle of \Etitlepage.
+ \begingroup
+ \parindent=0pt \textfonts
+ % Leave some space at the very top of the page.
+ \vglue\titlepagetopglue
+ % No rule at page bottom unless we print one at the top with @title.
+ \finishedtitlepagetrue
+ %
+ % Most title ``pages'' are actually two pages long, with space
+ % at the top of the second. We don't want the ragged left on the second.
+ \let\oldpage = \page
+ \def\page{%
+ \iffinishedtitlepage\else
+ \finishtitlepage
+ \fi
+ \let\page = \oldpage
+ \page
+ \null
+ }%
+}
+
+\def\Etitlepage{%
+ \iffinishedtitlepage\else
+ \finishtitlepage
+ \fi
+ % It is important to do the page break before ending the group,
+ % because the headline and footline are only empty inside the group.
+ % If we use the new definition of \page, we always get a blank page
+ % after the title page, which we certainly don't want.
+ \oldpage
+ \endgroup
+ %
+ % Need this before the \...aftertitlepage checks so that if they are
+ % in effect the toc pages will come out with page numbers.
+ \HEADINGSon
+ %
+ % If they want short, they certainly want long too.
+ \ifsetshortcontentsaftertitlepage
+ \shortcontents
+ \contents
+ \global\let\shortcontents = \relax
+ \global\let\contents = \relax
+ \fi
+ %
+ \ifsetcontentsaftertitlepage
+ \contents
+ \global\let\contents = \relax
+ \global\let\shortcontents = \relax
+ \fi
+}
+
+\def\finishtitlepage{%
+ \vskip4pt \hrule height 2pt width \hsize
+ \vskip\titlepagebottomglue
+ \finishedtitlepagetrue
+}
+
+% Settings used for typesetting titles: no hyphenation, no indentation,
+% don't worry much about spacing, ragged right. This should be used
+% inside a \vbox, and fonts need to be set appropriately first. Because
+% it is always used for titles, nothing else, we call \rmisbold. \par
+% should be specified before the end of the \vbox, since a vbox is a group.
+%
+\def\raggedtitlesettings{%
+ \rmisbold
+ \hyphenpenalty=10000
+ \parindent=0pt
+ \tolerance=5000
+ \ptexraggedright
+}
+
+% Macros to be used within @titlepage:
+
+\let\subtitlerm=\tenrm
+\def\subtitlefont{\subtitlerm \normalbaselineskip = 13pt \normalbaselines}
+
+\parseargdef\title{%
+ \checkenv\titlepage
+ \vbox{\titlefonts \raggedtitlesettings #1\par}%
+ % print a rule at the page bottom also.
+ \finishedtitlepagefalse
+ \vskip4pt \hrule height 4pt width \hsize \vskip4pt
+}
+
+\parseargdef\subtitle{%
+ \checkenv\titlepage
+ {\subtitlefont \rightline{#1}}%
+}
+
+% @author should come last, but may come many times.
+% It can also be used inside @quotation.
+%
+\parseargdef\author{%
+ \def\temp{\quotation}%
+ \ifx\thisenv\temp
+ \def\quotationauthor{#1}% printed in \Equotation.
+ \else
+ \checkenv\titlepage
+ \ifseenauthor\else \vskip 0pt plus 1filll \seenauthortrue \fi
+ {\secfonts\rmisbold \leftline{#1}}%
+ \fi
+}
+
+
+% Set up page headings and footings.
+
+\let\thispage=\folio
+
+\newtoks\evenheadline % headline on even pages
+\newtoks\oddheadline % headline on odd pages
+\newtoks\evenfootline % footline on even pages
+\newtoks\oddfootline % footline on odd pages
+
+% Now make TeX use those variables
+\headline={{\textfonts\rm \ifodd\pageno \the\oddheadline
+ \else \the\evenheadline \fi}}
+\footline={{\textfonts\rm \ifodd\pageno \the\oddfootline
+ \else \the\evenfootline \fi}\HEADINGShook}
+\let\HEADINGShook=\relax
+
+% Commands to set those variables.
+% For example, this is what @headings on does
+% @evenheading @thistitle|@thispage|@thischapter
+% @oddheading @thischapter|@thispage|@thistitle
+% @evenfooting @thisfile||
+% @oddfooting ||@thisfile
+
+
+\def\evenheading{\parsearg\evenheadingxxx}
+\def\evenheadingxxx #1{\evenheadingyyy #1\|\|\|\|\finish}
+\def\evenheadingyyy #1\|#2\|#3\|#4\finish{%
+\global\evenheadline={\rlap{\centerline{#2}}\line{#1\hfil#3}}}
+
+\def\oddheading{\parsearg\oddheadingxxx}
+\def\oddheadingxxx #1{\oddheadingyyy #1\|\|\|\|\finish}
+\def\oddheadingyyy #1\|#2\|#3\|#4\finish{%
+\global\oddheadline={\rlap{\centerline{#2}}\line{#1\hfil#3}}}
+
+\parseargdef\everyheading{\oddheadingxxx{#1}\evenheadingxxx{#1}}%
+
+\def\evenfooting{\parsearg\evenfootingxxx}
+\def\evenfootingxxx #1{\evenfootingyyy #1\|\|\|\|\finish}
+\def\evenfootingyyy #1\|#2\|#3\|#4\finish{%
+\global\evenfootline={\rlap{\centerline{#2}}\line{#1\hfil#3}}}
+
+\def\oddfooting{\parsearg\oddfootingxxx}
+\def\oddfootingxxx #1{\oddfootingyyy #1\|\|\|\|\finish}
+\def\oddfootingyyy #1\|#2\|#3\|#4\finish{%
+ \global\oddfootline = {\rlap{\centerline{#2}}\line{#1\hfil#3}}%
+ %
+ % Leave some space for the footline. Hopefully ok to assume
+ % @evenfooting will not be used by itself.
+ \global\advance\pageheight by -12pt
+ \global\advance\vsize by -12pt
+}
+
+\parseargdef\everyfooting{\oddfootingxxx{#1}\evenfootingxxx{#1}}
+
+% @evenheadingmarks top \thischapter <- chapter at the top of a page
+% @evenheadingmarks bottom \thischapter <- chapter at the bottom of a page
+%
+% The same set of arguments for:
+%
+% @oddheadingmarks
+% @evenfootingmarks
+% @oddfootingmarks
+% @everyheadingmarks
+% @everyfootingmarks
+
+\def\evenheadingmarks{\headingmarks{even}{heading}}
+\def\oddheadingmarks{\headingmarks{odd}{heading}}
+\def\evenfootingmarks{\headingmarks{even}{footing}}
+\def\oddfootingmarks{\headingmarks{odd}{footing}}
+\def\everyheadingmarks#1 {\headingmarks{even}{heading}{#1}
+ \headingmarks{odd}{heading}{#1} }
+\def\everyfootingmarks#1 {\headingmarks{even}{footing}{#1}
+ \headingmarks{odd}{footing}{#1} }
+% #1 = even/odd, #2 = heading/footing, #3 = top/bottom.
+\def\headingmarks#1#2#3 {%
+ \expandafter\let\expandafter\temp \csname get#3headingmarks\endcsname
+ \global\expandafter\let\csname get#1#2marks\endcsname \temp
+}
+
+\everyheadingmarks bottom
+\everyfootingmarks bottom
+
+% @headings double turns headings on for double-sided printing.
+% @headings single turns headings on for single-sided printing.
+% @headings off turns them off.
+% @headings on same as @headings double, retained for compatibility.
+% @headings after turns on double-sided headings after this page.
+% @headings doubleafter turns on double-sided headings after this page.
+% @headings singleafter turns on single-sided headings after this page.
+% By default, they are off at the start of a document,
+% and turned `on' after @end titlepage.
+
+\def\headings #1 {\csname HEADINGS#1\endcsname}
+
+\def\headingsoff{% non-global headings elimination
+ \evenheadline={\hfil}\evenfootline={\hfil}%
+ \oddheadline={\hfil}\oddfootline={\hfil}%
+}
+
+\def\HEADINGSoff{{\globaldefs=1 \headingsoff}} % global setting
+\HEADINGSoff % it's the default
+
+% When we turn headings on, set the page number to 1.
+% For double-sided printing, put current file name in lower left corner,
+% chapter name on inside top of right hand pages, document
+% title on inside top of left hand pages, and page numbers on outside top
+% edge of all pages.
+\def\HEADINGSdouble{%
+\global\pageno=1
+\global\evenfootline={\hfil}
+\global\oddfootline={\hfil}
+\global\evenheadline={\line{\folio\hfil\thistitle}}
+\global\oddheadline={\line{\thischapter\hfil\folio}}
+\global\let\contentsalignmacro = \chapoddpage
+}
+\let\contentsalignmacro = \chappager
+
+% For single-sided printing, chapter title goes across top left of page,
+% page number on top right.
+\def\HEADINGSsingle{%
+\global\pageno=1
+\global\evenfootline={\hfil}
+\global\oddfootline={\hfil}
+\global\evenheadline={\line{\thischapter\hfil\folio}}
+\global\oddheadline={\line{\thischapter\hfil\folio}}
+\global\let\contentsalignmacro = \chappager
+}
+\def\HEADINGSon{\HEADINGSdouble}
+
+\def\HEADINGSafter{\let\HEADINGShook=\HEADINGSdoublex}
+\let\HEADINGSdoubleafter=\HEADINGSafter
+\def\HEADINGSdoublex{%
+\global\evenfootline={\hfil}
+\global\oddfootline={\hfil}
+\global\evenheadline={\line{\folio\hfil\thistitle}}
+\global\oddheadline={\line{\thischapter\hfil\folio}}
+\global\let\contentsalignmacro = \chapoddpage
+}
+
+\def\HEADINGSsingleafter{\let\HEADINGShook=\HEADINGSsinglex}
+\def\HEADINGSsinglex{%
+\global\evenfootline={\hfil}
+\global\oddfootline={\hfil}
+\global\evenheadline={\line{\thischapter\hfil\folio}}
+\global\oddheadline={\line{\thischapter\hfil\folio}}
+\global\let\contentsalignmacro = \chappager
+}
+
+% Subroutines used in generating headings
+% This produces Day Month Year style of output.
+% Only define if not already defined, in case a txi-??.tex file has set
+% up a different format (e.g., txi-cs.tex does this).
+\ifx\today\thisisundefined
+\def\today{%
+ \number\day\space
+ \ifcase\month
+ \or\putwordMJan\or\putwordMFeb\or\putwordMMar\or\putwordMApr
+ \or\putwordMMay\or\putwordMJun\or\putwordMJul\or\putwordMAug
+ \or\putwordMSep\or\putwordMOct\or\putwordMNov\or\putwordMDec
+ \fi
+ \space\number\year}
+\fi
+
+% @settitle line... specifies the title of the document, for headings.
+% It generates no output of its own.
+\def\thistitle{\putwordNoTitle}
+\def\settitle{\parsearg{\gdef\thistitle}}
+
+
+\message{tables,}
+% Tables -- @table, @ftable, @vtable, @item(x).
+
+% default indentation of table text
+\newdimen\tableindent \tableindent=.8in
+% default indentation of @itemize and @enumerate text
+\newdimen\itemindent \itemindent=.3in
+% margin between end of table item and start of table text.
+\newdimen\itemmargin \itemmargin=.1in
+
+% used internally for \itemindent minus \itemmargin
+\newdimen\itemmax
+
+% Note @table, @ftable, and @vtable define @item, @itemx, etc., with
+% these defs.
+% They also define \itemindex
+% to index the item name in whatever manner is desired (perhaps none).
+
+\newif\ifitemxneedsnegativevskip
+
+\def\itemxpar{\par\ifitemxneedsnegativevskip\nobreak\vskip-\parskip\nobreak\fi}
+
+\def\internalBitem{\smallbreak \parsearg\itemzzz}
+\def\internalBitemx{\itemxpar \parsearg\itemzzz}
+
+\def\itemzzz #1{\begingroup %
+ \advance\hsize by -\rightskip
+ \advance\hsize by -\tableindent
+ \setbox0=\hbox{\itemindicate{#1}}%
+ \itemindex{#1}%
+ \nobreak % This prevents a break before @itemx.
+ %
+ % If the item text does not fit in the space we have, put it on a line
+ % by itself, and do not allow a page break either before or after that
+ % line. We do not start a paragraph here because then if the next
+ % command is, e.g., @kindex, the whatsit would get put into the
+ % horizontal list on a line by itself, resulting in extra blank space.
+ \ifdim \wd0>\itemmax
+ %
+ % Make this a paragraph so we get the \parskip glue and wrapping,
+ % but leave it ragged-right.
+ \begingroup
+ \advance\leftskip by-\tableindent
+ \advance\hsize by\tableindent
+ \advance\rightskip by0pt plus1fil\relax
+ \leavevmode\unhbox0\par
+ \endgroup
+ %
+ % We're going to be starting a paragraph, but we don't want the
+ % \parskip glue -- logically it's part of the @item we just started.
+ \nobreak \vskip-\parskip
+ %
+ % Stop a page break at the \parskip glue coming up. However, if
+ % what follows is an environment such as @example, there will be no
+ % \parskip glue; then the negative vskip we just inserted would
+ % cause the example and the item to crash together. So we use this
+ % bizarre value of 10001 as a signal to \aboveenvbreak to insert
+ % \parskip glue after all. Section titles are handled this way also.
+ %
+ \penalty 10001
+ \endgroup
+ \itemxneedsnegativevskipfalse
+ \else
+ % The item text fits into the space. Start a paragraph, so that the
+ % following text (if any) will end up on the same line.
+ \noindent
+ % Do this with kerns and \unhbox so that if there is a footnote in
+ % the item text, it can migrate to the main vertical list and
+ % eventually be printed.
+ \nobreak\kern-\tableindent
+ \dimen0 = \itemmax \advance\dimen0 by \itemmargin \advance\dimen0 by -\wd0
+ \unhbox0
+ \nobreak\kern\dimen0
+ \endgroup
+ \itemxneedsnegativevskiptrue
+ \fi
+}
+
+\def\item{\errmessage{@item while not in a list environment}}
+\def\itemx{\errmessage{@itemx while not in a list environment}}
+
+% @table, @ftable, @vtable.
+\envdef\table{%
+ \let\itemindex\gobble
+ \tablecheck{table}%
+}
+\envdef\ftable{%
+ \def\itemindex ##1{\doind {fn}{\code{##1}}}%
+ \tablecheck{ftable}%
+}
+\envdef\vtable{%
+ \def\itemindex ##1{\doind {vr}{\code{##1}}}%
+ \tablecheck{vtable}%
+}
+\def\tablecheck#1{%
+ \ifnum \the\catcode`\^^M=\active
+ \endgroup
+ \errmessage{This command won't work in this context; perhaps the problem is
+ that we are \inenvironment\thisenv}%
+ \def\next{\doignore{#1}}%
+ \else
+ \let\next\tablex
+ \fi
+ \next
+}
+\def\tablex#1{%
+ \def\itemindicate{#1}%
+ \parsearg\tabley
+}
+\def\tabley#1{%
+ {%
+ \makevalueexpandable
+ \edef\temp{\noexpand\tablez #1\space\space\space}%
+ \expandafter
+ }\temp \endtablez
+}
+\def\tablez #1 #2 #3 #4\endtablez{%
+ \aboveenvbreak
+ \ifnum 0#1>0 \advance \leftskip by #1\mil \fi
+ \ifnum 0#2>0 \tableindent=#2\mil \fi
+ \ifnum 0#3>0 \advance \rightskip by #3\mil \fi
+ \itemmax=\tableindent
+ \advance \itemmax by -\itemmargin
+ \advance \leftskip by \tableindent
+ \exdentamount=\tableindent
+ \parindent = 0pt
+ \parskip = \smallskipamount
+ \ifdim \parskip=0pt \parskip=2pt \fi
+ \let\item = \internalBitem
+ \let\itemx = \internalBitemx
+}
+\def\Etable{\endgraf\afterenvbreak}
+\let\Eftable\Etable
+\let\Evtable\Etable
+\let\Eitemize\Etable
+\let\Eenumerate\Etable
+
+% This is the counter used by @enumerate, which is really @itemize
+
+\newcount \itemno
+
+\envdef\itemize{\parsearg\doitemize}
+
+\def\doitemize#1{%
+ \aboveenvbreak
+ \itemmax=\itemindent
+ \advance\itemmax by -\itemmargin
+ \advance\leftskip by \itemindent
+ \exdentamount=\itemindent
+ \parindent=0pt
+ \parskip=\smallskipamount
+ \ifdim\parskip=0pt \parskip=2pt \fi
+ %
+ % Try typesetting the item mark that if the document erroneously says
+ % something like @itemize @samp (intending @table), there's an error
+ % right away at the @itemize. It's not the best error message in the
+ % world, but it's better than leaving it to the @item. This means if
+ % the user wants an empty mark, they have to say @w{} not just @w.
+ \def\itemcontents{#1}%
+ \setbox0 = \hbox{\itemcontents}%
+ %
+ % @itemize with no arg is equivalent to @itemize @bullet.
+ \ifx\itemcontents\empty\def\itemcontents{\bullet}\fi
+ %
+ \let\item=\itemizeitem
+}
+
+% Definition of @item while inside @itemize and @enumerate.
+%
+\def\itemizeitem{%
+ \advance\itemno by 1 % for enumerations
+ {\let\par=\endgraf \smallbreak}% reasonable place to break
+ {%
+ % If the document has an @itemize directly after a section title, a
+ % \nobreak will be last on the list, and \sectionheading will have
+ % done a \vskip-\parskip. In that case, we don't want to zero
+ % parskip, or the item text will crash with the heading. On the
+ % other hand, when there is normal text preceding the item (as there
+ % usually is), we do want to zero parskip, or there would be too much
+ % space. In that case, we won't have a \nobreak before. At least
+ % that's the theory.
+ \ifnum\lastpenalty<10000 \parskip=0in \fi
+ \noindent
+ \hbox to 0pt{\hss \itemcontents \kern\itemmargin}%
+ %
+ \vadjust{\penalty 1200}}% not good to break after first line of item.
+ \flushcr
+}
+
+% \splitoff TOKENS\endmark defines \first to be the first token in
+% TOKENS, and \rest to be the remainder.
+%
+\def\splitoff#1#2\endmark{\def\first{#1}\def\rest{#2}}%
+
+% Allow an optional argument of an uppercase letter, lowercase letter,
+% or number, to specify the first label in the enumerated list. No
+% argument is the same as `1'.
+%
+\envparseargdef\enumerate{\enumeratey #1 \endenumeratey}
+\def\enumeratey #1 #2\endenumeratey{%
+ % If we were given no argument, pretend we were given `1'.
+ \def\thearg{#1}%
+ \ifx\thearg\empty \def\thearg{1}\fi
+ %
+ % Detect if the argument is a single token. If so, it might be a
+ % letter. Otherwise, the only valid thing it can be is a number.
+ % (We will always have one token, because of the test we just made.
+ % This is a good thing, since \splitoff doesn't work given nothing at
+ % all -- the first parameter is undelimited.)
+ \expandafter\splitoff\thearg\endmark
+ \ifx\rest\empty
+ % Only one token in the argument. It could still be anything.
+ % A ``lowercase letter'' is one whose \lccode is nonzero.
+ % An ``uppercase letter'' is one whose \lccode is both nonzero, and
+ % not equal to itself.
+ % Otherwise, we assume it's a number.
+ %
+ % We need the \relax at the end of the \ifnum lines to stop TeX from
+ % continuing to look for a <number>.
+ %
+ \ifnum\lccode\expandafter`\thearg=0\relax
+ \numericenumerate % a number (we hope)
+ \else
+ % It's a letter.
+ \ifnum\lccode\expandafter`\thearg=\expandafter`\thearg\relax
+ \lowercaseenumerate % lowercase letter
+ \else
+ \uppercaseenumerate % uppercase letter
+ \fi
+ \fi
+ \else
+ % Multiple tokens in the argument. We hope it's a number.
+ \numericenumerate
+ \fi
+}
+
+% An @enumerate whose labels are integers. The starting integer is
+% given in \thearg.
+%
+\def\numericenumerate{%
+ \itemno = \thearg
+ \startenumeration{\the\itemno}%
+}
+
+% The starting (lowercase) letter is in \thearg.
+\def\lowercaseenumerate{%
+ \itemno = \expandafter`\thearg
+ \startenumeration{%
+ % Be sure we're not beyond the end of the alphabet.
+ \ifnum\itemno=0
+ \errmessage{No more lowercase letters in @enumerate; get a bigger
+ alphabet}%
+ \fi
+ \char\lccode\itemno
+ }%
+}
+
+% The starting (uppercase) letter is in \thearg.
+\def\uppercaseenumerate{%
+ \itemno = \expandafter`\thearg
+ \startenumeration{%
+ % Be sure we're not beyond the end of the alphabet.
+ \ifnum\itemno=0
+ \errmessage{No more uppercase letters in @enumerate; get a bigger
+ alphabet}
+ \fi
+ \char\uccode\itemno
+ }%
+}
+
+% Call \doitemize, adding a period to the first argument and supplying the
+% common last two arguments. Also subtract one from the initial value in
+% \itemno, since @item increments \itemno.
+%
+\def\startenumeration#1{%
+ \advance\itemno by -1
+ \doitemize{#1.}\flushcr
+}
+
+% @alphaenumerate and @capsenumerate are abbreviations for giving an arg
+% to @enumerate.
+%
+\def\alphaenumerate{\enumerate{a}}
+\def\capsenumerate{\enumerate{A}}
+\def\Ealphaenumerate{\Eenumerate}
+\def\Ecapsenumerate{\Eenumerate}
+
+
+% @multitable macros
+% Amy Hendrickson, 8/18/94, 3/6/96
+%
+% @multitable ... @end multitable will make as many columns as desired.
+% Contents of each column will wrap at width given in preamble. Width
+% can be specified either with sample text given in a template line,
+% or in percent of \hsize, the current width of text on page.
+
+% Table can continue over pages but will only break between lines.
+
+% To make preamble:
+%
+% Either define widths of columns in terms of percent of \hsize:
+% @multitable @columnfractions .25 .3 .45
+% @item ...
+%
+% Numbers following @columnfractions are the percent of the total
+% current hsize to be used for each column. You may use as many
+% columns as desired.
+
+
+% Or use a template:
+% @multitable {Column 1 template} {Column 2 template} {Column 3 template}
+% @item ...
+% using the widest term desired in each column.
+
+% Each new table line starts with @item, each subsequent new column
+% starts with @tab. Empty columns may be produced by supplying @tab's
+% with nothing between them for as many times as empty columns are needed,
+% ie, @tab@tab@tab will produce two empty columns.
+
+% @item, @tab do not need to be on their own lines, but it will not hurt
+% if they are.
+
+% Sample multitable:
+
+% @multitable {Column 1 template} {Column 2 template} {Column 3 template}
+% @item first col stuff @tab second col stuff @tab third col
+% @item
+% first col stuff
+% @tab
+% second col stuff
+% @tab
+% third col
+% @item first col stuff @tab second col stuff
+% @tab Many paragraphs of text may be used in any column.
+%
+% They will wrap at the width determined by the template.
+% @item@tab@tab This will be in third column.
+% @end multitable
+
+% Default dimensions may be reset by user.
+% @multitableparskip is vertical space between paragraphs in table.
+% @multitableparindent is paragraph indent in table.
+% @multitablecolmargin is horizontal space to be left between columns.
+% @multitablelinespace is space to leave between table items, baseline
+% to baseline.
+% 0pt means it depends on current normal line spacing.
+%
+\newskip\multitableparskip
+\newskip\multitableparindent
+\newdimen\multitablecolspace
+\newskip\multitablelinespace
+\multitableparskip=0pt
+\multitableparindent=6pt
+\multitablecolspace=12pt
+\multitablelinespace=0pt
+
+% Macros used to set up halign preamble:
+%
+\let\endsetuptable\relax
+\def\xendsetuptable{\endsetuptable}
+\let\columnfractions\relax
+\def\xcolumnfractions{\columnfractions}
+\newif\ifsetpercent
+
+% #1 is the @columnfraction, usually a decimal number like .5, but might
+% be just 1. We just use it, whatever it is.
+%
+\def\pickupwholefraction#1 {%
+ \global\advance\colcount by 1
+ \expandafter\xdef\csname col\the\colcount\endcsname{#1\hsize}%
+ \setuptable
+}
+
+\newcount\colcount
+\def\setuptable#1{%
+ \def\firstarg{#1}%
+ \ifx\firstarg\xendsetuptable
+ \let\go = \relax
+ \else
+ \ifx\firstarg\xcolumnfractions
+ \global\setpercenttrue
+ \else
+ \ifsetpercent
+ \let\go\pickupwholefraction
+ \else
+ \global\advance\colcount by 1
+ \setbox0=\hbox{#1\unskip\space}% Add a normal word space as a
+ % separator; typically that is always in the input, anyway.
+ \expandafter\xdef\csname col\the\colcount\endcsname{\the\wd0}%
+ \fi
+ \fi
+ \ifx\go\pickupwholefraction
+ % Put the argument back for the \pickupwholefraction call, so
+ % we'll always have a period there to be parsed.
+ \def\go{\pickupwholefraction#1}%
+ \else
+ \let\go = \setuptable
+ \fi%
+ \fi
+ \go
+}
+
+% multitable-only commands.
+%
+% @headitem starts a heading row, which we typeset in bold.
+% Assignments have to be global since we are inside the implicit group
+% of an alignment entry. \everycr resets \everytab so we don't have to
+% undo it ourselves.
+\def\headitemfont{\b}% for people to use in the template row; not changeable
+\def\headitem{%
+ \checkenv\multitable
+ \crcr
+ \global\everytab={\bf}% can't use \headitemfont since the parsing differs
+ \the\everytab % for the first item
+}%
+%
+% A \tab used to include \hskip1sp. But then the space in a template
+% line is not enough. That is bad. So let's go back to just `&' until
+% we again encounter the problem the 1sp was intended to solve.
+% --karl, nathan@acm.org, 20apr99.
+\def\tab{\checkenv\multitable &\the\everytab}%
+
+% @multitable ... @end multitable definitions:
+%
+\newtoks\everytab % insert after every tab.
+%
+\envdef\multitable{%
+ \vskip\parskip
+ \startsavinginserts
+ %
+ % @item within a multitable starts a normal row.
+ % We use \def instead of \let so that if one of the multitable entries
+ % contains an @itemize, we don't choke on the \item (seen as \crcr aka
+ % \endtemplate) expanding \doitemize.
+ \def\item{\crcr}%
+ %
+ \tolerance=9500
+ \hbadness=9500
+ \setmultitablespacing
+ \parskip=\multitableparskip
+ \parindent=\multitableparindent
+ \overfullrule=0pt
+ \global\colcount=0
+ %
+ \everycr = {%
+ \noalign{%
+ \global\everytab={}%
+ \global\colcount=0 % Reset the column counter.
+ % Check for saved footnotes, etc.
+ \checkinserts
+ % Keeps underfull box messages off when table breaks over pages.
+ %\filbreak
+ % Maybe so, but it also creates really weird page breaks when the
+ % table breaks over pages. Wouldn't \vfil be better? Wait until the
+ % problem manifests itself, so it can be fixed for real --karl.
+ }%
+ }%
+ %
+ \parsearg\domultitable
+}
+\def\domultitable#1{%
+ % To parse everything between @multitable and @item:
+ \setuptable#1 \endsetuptable
+ %
+ % This preamble sets up a generic column definition, which will
+ % be used as many times as user calls for columns.
+ % \vtop will set a single line and will also let text wrap and
+ % continue for many paragraphs if desired.
+ \halign\bgroup &%
+ \global\advance\colcount by 1
+ \multistrut
+ \vtop{%
+ % Use the current \colcount to find the correct column width:
+ \hsize=\expandafter\csname col\the\colcount\endcsname
+ %
+ % In order to keep entries from bumping into each other
+ % we will add a \leftskip of \multitablecolspace to all columns after
+ % the first one.
+ %
+ % If a template has been used, we will add \multitablecolspace
+ % to the width of each template entry.
+ %
+ % If the user has set preamble in terms of percent of \hsize we will
+ % use that dimension as the width of the column, and the \leftskip
+ % will keep entries from bumping into each other. Table will start at
+ % left margin and final column will justify at right margin.
+ %
+ % Make sure we don't inherit \rightskip from the outer environment.
+ \rightskip=0pt
+ \ifnum\colcount=1
+ % The first column will be indented with the surrounding text.
+ \advance\hsize by\leftskip
+ \else
+ \ifsetpercent \else
+ % If user has not set preamble in terms of percent of \hsize
+ % we will advance \hsize by \multitablecolspace.
+ \advance\hsize by \multitablecolspace
+ \fi
+ % In either case we will make \leftskip=\multitablecolspace:
+ \leftskip=\multitablecolspace
+ \fi
+ % Ignoring space at the beginning and end avoids an occasional spurious
+ % blank line, when TeX decides to break the line at the space before the
+ % box from the multistrut, so the strut ends up on a line by itself.
+ % For example:
+ % @multitable @columnfractions .11 .89
+ % @item @code{#}
+ % @tab Legal holiday which is valid in major parts of the whole country.
+ % Is automatically provided with highlighting sequences respectively
+ % marking characters.
+ \noindent\ignorespaces##\unskip\multistrut
+ }\cr
+}
+\def\Emultitable{%
+ \crcr
+ \egroup % end the \halign
+ \global\setpercentfalse
+}
+
+\def\setmultitablespacing{%
+ \def\multistrut{\strut}% just use the standard line spacing
+ %
+ % Compute \multitablelinespace (if not defined by user) for use in
+ % \multitableparskip calculation. We used define \multistrut based on
+ % this, but (ironically) that caused the spacing to be off.
+ % See bug-texinfo report from Werner Lemberg, 31 Oct 2004 12:52:20 +0100.
+\ifdim\multitablelinespace=0pt
+\setbox0=\vbox{X}\global\multitablelinespace=\the\baselineskip
+\global\advance\multitablelinespace by-\ht0
+\fi
+% Test to see if parskip is larger than space between lines of
+% table. If not, do nothing.
+% If so, set to same dimension as multitablelinespace.
+\ifdim\multitableparskip>\multitablelinespace
+\global\multitableparskip=\multitablelinespace
+\global\advance\multitableparskip-7pt % to keep parskip somewhat smaller
+ % than skip between lines in the table.
+\fi%
+\ifdim\multitableparskip=0pt
+\global\multitableparskip=\multitablelinespace
+\global\advance\multitableparskip-7pt % to keep parskip somewhat smaller
+ % than skip between lines in the table.
+\fi}
+
+
+\message{conditionals,}
+
+% @iftex, @ifnotdocbook, @ifnothtml, @ifnotinfo, @ifnotplaintext,
+% @ifnotxml always succeed. They currently do nothing; we don't
+% attempt to check whether the conditionals are properly nested. But we
+% have to remember that they are conditionals, so that @end doesn't
+% attempt to close an environment group.
+%
+\def\makecond#1{%
+ \expandafter\let\csname #1\endcsname = \relax
+ \expandafter\let\csname iscond.#1\endcsname = 1
+}
+\makecond{iftex}
+\makecond{ifnotdocbook}
+\makecond{ifnothtml}
+\makecond{ifnotinfo}
+\makecond{ifnotplaintext}
+\makecond{ifnotxml}
+
+% Ignore @ignore, @ifhtml, @ifinfo, and the like.
+%
+\def\direntry{\doignore{direntry}}
+\def\documentdescription{\doignore{documentdescription}}
+\def\docbook{\doignore{docbook}}
+\def\html{\doignore{html}}
+\def\ifdocbook{\doignore{ifdocbook}}
+\def\ifhtml{\doignore{ifhtml}}
+\def\ifinfo{\doignore{ifinfo}}
+\def\ifnottex{\doignore{ifnottex}}
+\def\ifplaintext{\doignore{ifplaintext}}
+\def\ifxml{\doignore{ifxml}}
+\def\ignore{\doignore{ignore}}
+\def\menu{\doignore{menu}}
+\def\xml{\doignore{xml}}
+
+% Ignore text until a line `@end #1', keeping track of nested conditionals.
+%
+% A count to remember the depth of nesting.
+\newcount\doignorecount
+
+\def\doignore#1{\begingroup
+ % Scan in ``verbatim'' mode:
+ \obeylines
+ \catcode`\@ = \other
+ \catcode`\{ = \other
+ \catcode`\} = \other
+ %
+ % Make sure that spaces turn into tokens that match what \doignoretext wants.
+ \spaceisspace
+ %
+ % Count number of #1's that we've seen.
+ \doignorecount = 0
+ %
+ % Swallow text until we reach the matching `@end #1'.
+ \dodoignore{#1}%
+}
+
+{ \catcode`_=11 % We want to use \_STOP_ which cannot appear in texinfo source.
+ \obeylines %
+ %
+ \gdef\dodoignore#1{%
+ % #1 contains the command name as a string, e.g., `ifinfo'.
+ %
+ % Define a command to find the next `@end #1'.
+ \long\def\doignoretext##1^^M@end #1{%
+ \doignoretextyyy##1^^M@#1\_STOP_}%
+ %
+ % And this command to find another #1 command, at the beginning of a
+ % line. (Otherwise, we would consider a line `@c @ifset', for
+ % example, to count as an @ifset for nesting.)
+ \long\def\doignoretextyyy##1^^M@#1##2\_STOP_{\doignoreyyy{##2}\_STOP_}%
+ %
+ % And now expand that command.
+ \doignoretext ^^M%
+ }%
+}
+
+\def\doignoreyyy#1{%
+ \def\temp{#1}%
+ \ifx\temp\empty % Nothing found.
+ \let\next\doignoretextzzz
+ \else % Found a nested condition, ...
+ \advance\doignorecount by 1
+ \let\next\doignoretextyyy % ..., look for another.
+ % If we're here, #1 ends with ^^M\ifinfo (for example).
+ \fi
+ \next #1% the token \_STOP_ is present just after this macro.
+}
+
+% We have to swallow the remaining "\_STOP_".
+%
+\def\doignoretextzzz#1{%
+ \ifnum\doignorecount = 0 % We have just found the outermost @end.
+ \let\next\enddoignore
+ \else % Still inside a nested condition.
+ \advance\doignorecount by -1
+ \let\next\doignoretext % Look for the next @end.
+ \fi
+ \next
+}
+
+% Finish off ignored text.
+{ \obeylines%
+ % Ignore anything after the last `@end #1'; this matters in verbatim
+ % environments, where otherwise the newline after an ignored conditional
+ % would result in a blank line in the output.
+ \gdef\enddoignore#1^^M{\endgroup\ignorespaces}%
+}
+
+
+% @set VAR sets the variable VAR to an empty value.
+% @set VAR REST-OF-LINE sets VAR to the value REST-OF-LINE.
+%
+% Since we want to separate VAR from REST-OF-LINE (which might be
+% empty), we can't just use \parsearg; we have to insert a space of our
+% own to delimit the rest of the line, and then take it out again if we
+% didn't need it.
+% We rely on the fact that \parsearg sets \catcode`\ =10.
+%
+\parseargdef\set{\setyyy#1 \endsetyyy}
+\def\setyyy#1 #2\endsetyyy{%
+ {%
+ \makevalueexpandable
+ \def\temp{#2}%
+ \edef\next{\gdef\makecsname{SET#1}}%
+ \ifx\temp\empty
+ \next{}%
+ \else
+ \setzzz#2\endsetzzz
+ \fi
+ }%
+}
+% Remove the trailing space \setxxx inserted.
+\def\setzzz#1 \endsetzzz{\next{#1}}
+
+% @clear VAR clears (i.e., unsets) the variable VAR.
+%
+\parseargdef\clear{%
+ {%
+ \makevalueexpandable
+ \global\expandafter\let\csname SET#1\endcsname=\relax
+ }%
+}
+
+% @value{foo} gets the text saved in variable foo.
+\def\value{\begingroup\makevalueexpandable\valuexxx}
+\def\valuexxx#1{\expandablevalue{#1}\endgroup}
+{
+ \catcode`\- = \active \catcode`\_ = \active
+ %
+ \gdef\makevalueexpandable{%
+ \let\value = \expandablevalue
+ % We don't want these characters active, ...
+ \catcode`\-=\other \catcode`\_=\other
+ % ..., but we might end up with active ones in the argument if
+ % we're called from @code, as @code{@value{foo-bar_}}, though.
+ % So \let them to their normal equivalents.
+ \let-\normaldash \let_\normalunderscore
+ }
+}
+
+% We have this subroutine so that we can handle at least some @value's
+% properly in indexes (we call \makevalueexpandable in \indexdummies).
+% The command has to be fully expandable (if the variable is set), since
+% the result winds up in the index file. This means that if the
+% variable's value contains other Texinfo commands, it's almost certain
+% it will fail (although perhaps we could fix that with sufficient work
+% to do a one-level expansion on the result, instead of complete).
+%
+\def\expandablevalue#1{%
+ \expandafter\ifx\csname SET#1\endcsname\relax
+ {[No value for ``#1'']}%
+ \message{Variable `#1', used in @value, is not set.}%
+ \else
+ \csname SET#1\endcsname
+ \fi
+}
+
+% @ifset VAR ... @end ifset reads the `...' iff VAR has been defined
+% with @set.
+%
+% To get special treatment of `@end ifset,' call \makeond and the redefine.
+%
+\makecond{ifset}
+\def\ifset{\parsearg{\doifset{\let\next=\ifsetfail}}}
+\def\doifset#1#2{%
+ {%
+ \makevalueexpandable
+ \let\next=\empty
+ \expandafter\ifx\csname SET#2\endcsname\relax
+ #1% If not set, redefine \next.
+ \fi
+ \expandafter
+ }\next
+}
+\def\ifsetfail{\doignore{ifset}}
+
+% @ifclear VAR ... @end executes the `...' iff VAR has never been
+% defined with @set, or has been undefined with @clear.
+%
+% The `\else' inside the `\doifset' parameter is a trick to reuse the
+% above code: if the variable is not set, do nothing, if it is set,
+% then redefine \next to \ifclearfail.
+%
+\makecond{ifclear}
+\def\ifclear{\parsearg{\doifset{\else \let\next=\ifclearfail}}}
+\def\ifclearfail{\doignore{ifclear}}
+
+% @ifcommandisdefined CMD ... @end executes the `...' if CMD (written
+% without the @) is in fact defined. We can only feasibly check at the
+% TeX level, so something like `mathcode' is going to considered
+% defined even though it is not a Texinfo command.
+%
+\makecond{ifcommanddefined}
+\def\ifcommanddefined{\parsearg{\doifcmddefined{\let\next=\ifcmddefinedfail}}}
+%
+\def\doifcmddefined#1#2{{%
+ \makevalueexpandable
+ \let\next=\empty
+ \expandafter\ifx\csname #2\endcsname\relax
+ #1% If not defined, \let\next as above.
+ \fi
+ \expandafter
+ }\next
+}
+\def\ifcmddefinedfail{\doignore{ifcommanddefined}}
+
+% @ifcommandnotdefined CMD ... handled similar to @ifclear above.
+\makecond{ifcommandnotdefined}
+\def\ifcommandnotdefined{%
+ \parsearg{\doifcmddefined{\else \let\next=\ifcmdnotdefinedfail}}}
+\def\ifcmdnotdefinedfail{\doignore{ifcommandnotdefined}}
+
+% Set the `txicommandconditionals' variable, so documents have a way to
+% test if the @ifcommand...defined conditionals are available.
+\set txicommandconditionals
+
+% @dircategory CATEGORY -- specify a category of the dir file
+% which this file should belong to. Ignore this in TeX.
+\let\dircategory=\comment
+
+% @defininfoenclose.
+\let\definfoenclose=\comment
+
+
+\message{indexing,}
+% Index generation facilities
+
+% Define \newwrite to be identical to plain tex's \newwrite
+% except not \outer, so it can be used within macros and \if's.
+\edef\newwrite{\makecsname{ptexnewwrite}}
+
+% \newindex {foo} defines an index named foo.
+% It automatically defines \fooindex such that
+% \fooindex ...rest of line... puts an entry in the index foo.
+% It also defines \fooindfile to be the number of the output channel for
+% the file that accumulates this index. The file's extension is foo.
+% The name of an index should be no more than 2 characters long
+% for the sake of vms.
+%
+\def\newindex#1{%
+ \iflinks
+ \expandafter\newwrite \csname#1indfile\endcsname
+ \openout \csname#1indfile\endcsname \jobname.#1 % Open the file
+ \fi
+ \expandafter\xdef\csname#1index\endcsname{% % Define @#1index
+ \noexpand\doindex{#1}}
+}
+
+% @defindex foo == \newindex{foo}
+%
+\def\defindex{\parsearg\newindex}
+
+% Define @defcodeindex, like @defindex except put all entries in @code.
+%
+\def\defcodeindex{\parsearg\newcodeindex}
+%
+\def\newcodeindex#1{%
+ \iflinks
+ \expandafter\newwrite \csname#1indfile\endcsname
+ \openout \csname#1indfile\endcsname \jobname.#1
+ \fi
+ \expandafter\xdef\csname#1index\endcsname{%
+ \noexpand\docodeindex{#1}}%
+}
+
+
+% @synindex foo bar makes index foo feed into index bar.
+% Do this instead of @defindex foo if you don't want it as a separate index.
+%
+% @syncodeindex foo bar similar, but put all entries made for index foo
+% inside @code.
+%
+\def\synindex#1 #2 {\dosynindex\doindex{#1}{#2}}
+\def\syncodeindex#1 #2 {\dosynindex\docodeindex{#1}{#2}}
+
+% #1 is \doindex or \docodeindex, #2 the index getting redefined (foo),
+% #3 the target index (bar).
+\def\dosynindex#1#2#3{%
+ % Only do \closeout if we haven't already done it, else we'll end up
+ % closing the target index.
+ \expandafter \ifx\csname donesynindex#2\endcsname \relax
+ % The \closeout helps reduce unnecessary open files; the limit on the
+ % Acorn RISC OS is a mere 16 files.
+ \expandafter\closeout\csname#2indfile\endcsname
+ \expandafter\let\csname donesynindex#2\endcsname = 1
+ \fi
+ % redefine \fooindfile:
+ \expandafter\let\expandafter\temp\expandafter=\csname#3indfile\endcsname
+ \expandafter\let\csname#2indfile\endcsname=\temp
+ % redefine \fooindex:
+ \expandafter\xdef\csname#2index\endcsname{\noexpand#1{#3}}%
+}
+
+% Define \doindex, the driver for all \fooindex macros.
+% Argument #1 is generated by the calling \fooindex macro,
+% and it is "foo", the name of the index.
+
+% \doindex just uses \parsearg; it calls \doind for the actual work.
+% This is because \doind is more useful to call from other macros.
+
+% There is also \dosubind {index}{topic}{subtopic}
+% which makes an entry in a two-level index such as the operation index.
+
+\def\doindex#1{\edef\indexname{#1}\parsearg\singleindexer}
+\def\singleindexer #1{\doind{\indexname}{#1}}
+
+% like the previous two, but they put @code around the argument.
+\def\docodeindex#1{\edef\indexname{#1}\parsearg\singlecodeindexer}
+\def\singlecodeindexer #1{\doind{\indexname}{\code{#1}}}
+
+% Take care of Texinfo commands that can appear in an index entry.
+% Since there are some commands we want to expand, and others we don't,
+% we have to laboriously prevent expansion for those that we don't.
+%
+\def\indexdummies{%
+ \escapechar = `\\ % use backslash in output files.
+ \def\@{@}% change to @@ when we switch to @ as escape char in index files.
+ \def\ {\realbackslash\space }%
+ %
+ % Need these unexpandable (because we define \tt as a dummy)
+ % definitions when @{ or @} appear in index entry text. Also, more
+ % complicated, when \tex is in effect and \{ is a \delimiter again.
+ % We can't use \lbracecmd and \rbracecmd because texindex assumes
+ % braces and backslashes are used only as delimiters. Perhaps we
+ % should define @lbrace and @rbrace commands a la @comma.
+ \def\{{{\tt\char123}}%
+ \def\}{{\tt\char125}}%
+ %
+ % I don't entirely understand this, but when an index entry is
+ % generated from a macro call, the \endinput which \scanmacro inserts
+ % causes processing to be prematurely terminated. This is,
+ % apparently, because \indexsorttmp is fully expanded, and \endinput
+ % is an expandable command. The redefinition below makes \endinput
+ % disappear altogether for that purpose -- although logging shows that
+ % processing continues to some further point. On the other hand, it
+ % seems \endinput does not hurt in the printed index arg, since that
+ % is still getting written without apparent harm.
+ %
+ % Sample source (mac-idx3.tex, reported by Graham Percival to
+ % help-texinfo, 22may06):
+ % @macro funindex {WORD}
+ % @findex xyz
+ % @end macro
+ % ...
+ % @funindex commtest
+ %
+ % The above is not enough to reproduce the bug, but it gives the flavor.
+ %
+ % Sample whatsit resulting:
+ % .@write3{\entry{xyz}{@folio }{@code {xyz@endinput }}}
+ %
+ % So:
+ \let\endinput = \empty
+ %
+ % Do the redefinitions.
+ \commondummies
+}
+
+% For the aux and toc files, @ is the escape character. So we want to
+% redefine everything using @ as the escape character (instead of
+% \realbackslash, still used for index files). When everything uses @,
+% this will be simpler.
+%
+\def\atdummies{%
+ \def\@{@@}%
+ \def\ {@ }%
+ \let\{ = \lbraceatcmd
+ \let\} = \rbraceatcmd
+ %
+ % Do the redefinitions.
+ \commondummies
+ \otherbackslash
+}
+
+% Called from \indexdummies and \atdummies.
+%
+\def\commondummies{%
+ %
+ % \definedummyword defines \#1 as \string\#1\space, thus effectively
+ % preventing its expansion. This is used only for control words,
+ % not control letters, because the \space would be incorrect for
+ % control characters, but is needed to separate the control word
+ % from whatever follows.
+ %
+ % For control letters, we have \definedummyletter, which omits the
+ % space.
+ %
+ % These can be used both for control words that take an argument and
+ % those that do not. If it is followed by {arg} in the input, then
+ % that will dutifully get written to the index (or wherever).
+ %
+ \def\definedummyword ##1{\def##1{\string##1\space}}%
+ \def\definedummyletter##1{\def##1{\string##1}}%
+ \let\definedummyaccent\definedummyletter
+ %
+ \commondummiesnofonts
+ %
+ \definedummyletter\_%
+ \definedummyletter\-%
+ %
+ % Non-English letters.
+ \definedummyword\AA
+ \definedummyword\AE
+ \definedummyword\DH
+ \definedummyword\L
+ \definedummyword\O
+ \definedummyword\OE
+ \definedummyword\TH
+ \definedummyword\aa
+ \definedummyword\ae
+ \definedummyword\dh
+ \definedummyword\exclamdown
+ \definedummyword\l
+ \definedummyword\o
+ \definedummyword\oe
+ \definedummyword\ordf
+ \definedummyword\ordm
+ \definedummyword\questiondown
+ \definedummyword\ss
+ \definedummyword\th
+ %
+ % Although these internal commands shouldn't show up, sometimes they do.
+ \definedummyword\bf
+ \definedummyword\gtr
+ \definedummyword\hat
+ \definedummyword\less
+ \definedummyword\sf
+ \definedummyword\sl
+ \definedummyword\tclose
+ \definedummyword\tt
+ %
+ \definedummyword\LaTeX
+ \definedummyword\TeX
+ %
+ % Assorted special characters.
+ \definedummyword\arrow
+ \definedummyword\bullet
+ \definedummyword\comma
+ \definedummyword\copyright
+ \definedummyword\registeredsymbol
+ \definedummyword\dots
+ \definedummyword\enddots
+ \definedummyword\entrybreak
+ \definedummyword\equiv
+ \definedummyword\error
+ \definedummyword\euro
+ \definedummyword\expansion
+ \definedummyword\geq
+ \definedummyword\guillemetleft
+ \definedummyword\guillemetright
+ \definedummyword\guilsinglleft
+ \definedummyword\guilsinglright
+ \definedummyword\lbracechar
+ \definedummyword\leq
+ \definedummyword\minus
+ \definedummyword\ogonek
+ \definedummyword\pounds
+ \definedummyword\point
+ \definedummyword\print
+ \definedummyword\quotedblbase
+ \definedummyword\quotedblleft
+ \definedummyword\quotedblright
+ \definedummyword\quoteleft
+ \definedummyword\quoteright
+ \definedummyword\quotesinglbase
+ \definedummyword\rbracechar
+ \definedummyword\result
+ \definedummyword\textdegree
+ %
+ % We want to disable all macros so that they are not expanded by \write.
+ \macrolist
+ %
+ \normalturnoffactive
+ %
+ % Handle some cases of @value -- where it does not contain any
+ % (non-fully-expandable) commands.
+ \makevalueexpandable
+}
+
+% \commondummiesnofonts: common to \commondummies and \indexnofonts.
+%
+\def\commondummiesnofonts{%
+ % Control letters and accents.
+ \definedummyletter\!%
+ \definedummyaccent\"%
+ \definedummyaccent\'%
+ \definedummyletter\*%
+ \definedummyaccent\,%
+ \definedummyletter\.%
+ \definedummyletter\/%
+ \definedummyletter\:%
+ \definedummyaccent\=%
+ \definedummyletter\?%
+ \definedummyaccent\^%
+ \definedummyaccent\`%
+ \definedummyaccent\~%
+ \definedummyword\u
+ \definedummyword\v
+ \definedummyword\H
+ \definedummyword\dotaccent
+ \definedummyword\ogonek
+ \definedummyword\ringaccent
+ \definedummyword\tieaccent
+ \definedummyword\ubaraccent
+ \definedummyword\udotaccent
+ \definedummyword\dotless
+ %
+ % Texinfo font commands.
+ \definedummyword\b
+ \definedummyword\i
+ \definedummyword\r
+ \definedummyword\sansserif
+ \definedummyword\sc
+ \definedummyword\slanted
+ \definedummyword\t
+ %
+ % Commands that take arguments.
+ \definedummyword\abbr
+ \definedummyword\acronym
+ \definedummyword\anchor
+ \definedummyword\cite
+ \definedummyword\code
+ \definedummyword\command
+ \definedummyword\dfn
+ \definedummyword\dmn
+ \definedummyword\email
+ \definedummyword\emph
+ \definedummyword\env
+ \definedummyword\file
+ \definedummyword\image
+ \definedummyword\indicateurl
+ \definedummyword\inforef
+ \definedummyword\kbd
+ \definedummyword\key
+ \definedummyword\math
+ \definedummyword\option
+ \definedummyword\pxref
+ \definedummyword\ref
+ \definedummyword\samp
+ \definedummyword\strong
+ \definedummyword\tie
+ \definedummyword\uref
+ \definedummyword\url
+ \definedummyword\var
+ \definedummyword\verb
+ \definedummyword\w
+ \definedummyword\xref
+}
+
+% \indexnofonts is used when outputting the strings to sort the index
+% by, and when constructing control sequence names. It eliminates all
+% control sequences and just writes whatever the best ASCII sort string
+% would be for a given command (usually its argument).
+%
+\def\indexnofonts{%
+ % Accent commands should become @asis.
+ \def\definedummyaccent##1{\let##1\asis}%
+ % We can just ignore other control letters.
+ \def\definedummyletter##1{\let##1\empty}%
+ % All control words become @asis by default; overrides below.
+ \let\definedummyword\definedummyaccent
+ %
+ \commondummiesnofonts
+ %
+ % Don't no-op \tt, since it isn't a user-level command
+ % and is used in the definitions of the active chars like <, >, |, etc.
+ % Likewise with the other plain tex font commands.
+ %\let\tt=\asis
+ %
+ \def\ { }%
+ \def\@{@}%
+ \def\_{\normalunderscore}%
+ \def\-{}% @- shouldn't affect sorting
+ %
+ % Unfortunately, texindex is not prepared to handle braces in the
+ % content at all. So for index sorting, we map @{ and @} to strings
+ % starting with |, since that ASCII character is between ASCII { and }.
+ \def\{{|a}%
+ \def\lbracechar{|a}%
+ %
+ \def\}{|b}%
+ \def\rbracechar{|b}%
+ %
+ % Non-English letters.
+ \def\AA{AA}%
+ \def\AE{AE}%
+ \def\DH{DZZ}%
+ \def\L{L}%
+ \def\OE{OE}%
+ \def\O{O}%
+ \def\TH{ZZZ}%
+ \def\aa{aa}%
+ \def\ae{ae}%
+ \def\dh{dzz}%
+ \def\exclamdown{!}%
+ \def\l{l}%
+ \def\oe{oe}%
+ \def\ordf{a}%
+ \def\ordm{o}%
+ \def\o{o}%
+ \def\questiondown{?}%
+ \def\ss{ss}%
+ \def\th{zzz}%
+ %
+ \def\LaTeX{LaTeX}%
+ \def\TeX{TeX}%
+ %
+ % Assorted special characters.
+ % (The following {} will end up in the sort string, but that's ok.)
+ \def\arrow{->}%
+ \def\bullet{bullet}%
+ \def\comma{,}%
+ \def\copyright{copyright}%
+ \def\dots{...}%
+ \def\enddots{...}%
+ \def\equiv{==}%
+ \def\error{error}%
+ \def\euro{euro}%
+ \def\expansion{==>}%
+ \def\geq{>=}%
+ \def\guillemetleft{<<}%
+ \def\guillemetright{>>}%
+ \def\guilsinglleft{<}%
+ \def\guilsinglright{>}%
+ \def\leq{<=}%
+ \def\minus{-}%
+ \def\point{.}%
+ \def\pounds{pounds}%
+ \def\print{-|}%
+ \def\quotedblbase{"}%
+ \def\quotedblleft{"}%
+ \def\quotedblright{"}%
+ \def\quoteleft{`}%
+ \def\quoteright{'}%
+ \def\quotesinglbase{,}%
+ \def\registeredsymbol{R}%
+ \def\result{=>}%
+ \def\textdegree{o}%
+ %
+ \expandafter\ifx\csname SETtxiindexlquoteignore\endcsname\relax
+ \else \indexlquoteignore \fi
+ %
+ % We need to get rid of all macros, leaving only the arguments (if present).
+ % Of course this is not nearly correct, but it is the best we can do for now.
+ % makeinfo does not expand macros in the argument to @deffn, which ends up
+ % writing an index entry, and texindex isn't prepared for an index sort entry
+ % that starts with \.
+ %
+ % Since macro invocations are followed by braces, we can just redefine them
+ % to take a single TeX argument. The case of a macro invocation that
+ % goes to end-of-line is not handled.
+ %
+ \macrolist
+}
+
+% Undocumented (for FSFS 2nd ed.): @set txiindexlquoteignore makes us
+% ignore left quotes in the sort term.
+{\catcode`\`=\active
+ \gdef\indexlquoteignore{\let`=\empty}}
+
+\let\indexbackslash=0 %overridden during \printindex.
+\let\SETmarginindex=\relax % put index entries in margin (undocumented)?
+
+% Most index entries go through here, but \dosubind is the general case.
+% #1 is the index name, #2 is the entry text.
+\def\doind#1#2{\dosubind{#1}{#2}{}}
+
+% Workhorse for all \fooindexes.
+% #1 is name of index, #2 is stuff to put there, #3 is subentry --
+% empty if called from \doind, as we usually are (the main exception
+% is with most defuns, which call us directly).
+%
+\def\dosubind#1#2#3{%
+ \iflinks
+ {%
+ % Store the main index entry text (including the third arg).
+ \toks0 = {#2}%
+ % If third arg is present, precede it with a space.
+ \def\thirdarg{#3}%
+ \ifx\thirdarg\empty \else
+ \toks0 = \expandafter{\the\toks0 \space #3}%
+ \fi
+ %
+ \edef\writeto{\csname#1indfile\endcsname}%
+ %
+ \safewhatsit\dosubindwrite
+ }%
+ \fi
+}
+
+% Write the entry in \toks0 to the index file:
+%
+\def\dosubindwrite{%
+ % Put the index entry in the margin if desired.
+ \ifx\SETmarginindex\relax\else
+ \insert\margin{\hbox{\vrule height8pt depth3pt width0pt \the\toks0}}%
+ \fi
+ %
+ % Remember, we are within a group.
+ \indexdummies % Must do this here, since \bf, etc expand at this stage
+ \def\backslashcurfont{\indexbackslash}% \indexbackslash isn't defined now
+ % so it will be output as is; and it will print as backslash.
+ %
+ % Process the index entry with all font commands turned off, to
+ % get the string to sort by.
+ {\indexnofonts
+ \edef\temp{\the\toks0}% need full expansion
+ \xdef\indexsorttmp{\temp}%
+ }%
+ %
+ % Set up the complete index entry, with both the sort key and
+ % the original text, including any font commands. We write
+ % three arguments to \entry to the .?? file (four in the
+ % subentry case), texindex reduces to two when writing the .??s
+ % sorted result.
+ \edef\temp{%
+ \write\writeto{%
+ \string\entry{\indexsorttmp}{\noexpand\folio}{\the\toks0}}%
+ }%
+ \temp
+}
+
+% Take care of unwanted page breaks/skips around a whatsit:
+%
+% If a skip is the last thing on the list now, preserve it
+% by backing up by \lastskip, doing the \write, then inserting
+% the skip again. Otherwise, the whatsit generated by the
+% \write or \pdfdest will make \lastskip zero. The result is that
+% sequences like this:
+% @end defun
+% @tindex whatever
+% @defun ...
+% will have extra space inserted, because the \medbreak in the
+% start of the @defun won't see the skip inserted by the @end of
+% the previous defun.
+%
+% But don't do any of this if we're not in vertical mode. We
+% don't want to do a \vskip and prematurely end a paragraph.
+%
+% Avoid page breaks due to these extra skips, too.
+%
+% But wait, there is a catch there:
+% We'll have to check whether \lastskip is zero skip. \ifdim is not
+% sufficient for this purpose, as it ignores stretch and shrink parts
+% of the skip. The only way seems to be to check the textual
+% representation of the skip.
+%
+% The following is almost like \def\zeroskipmacro{0.0pt} except that
+% the ``p'' and ``t'' characters have catcode \other, not 11 (letter).
+%
+\edef\zeroskipmacro{\expandafter\the\csname z@skip\endcsname}
+%
+\newskip\whatsitskip
+\newcount\whatsitpenalty
+%
+% ..., ready, GO:
+%
+\def\safewhatsit#1{\ifhmode
+ #1%
+ \else
+ % \lastskip and \lastpenalty cannot both be nonzero simultaneously.
+ \whatsitskip = \lastskip
+ \edef\lastskipmacro{\the\lastskip}%
+ \whatsitpenalty = \lastpenalty
+ %
+ % If \lastskip is nonzero, that means the last item was a
+ % skip. And since a skip is discardable, that means this
+ % -\whatsitskip glue we're inserting is preceded by a
+ % non-discardable item, therefore it is not a potential
+ % breakpoint, therefore no \nobreak needed.
+ \ifx\lastskipmacro\zeroskipmacro
+ \else
+ \vskip-\whatsitskip
+ \fi
+ %
+ #1%
+ %
+ \ifx\lastskipmacro\zeroskipmacro
+ % If \lastskip was zero, perhaps the last item was a penalty, and
+ % perhaps it was >=10000, e.g., a \nobreak. In that case, we want
+ % to re-insert the same penalty (values >10000 are used for various
+ % signals); since we just inserted a non-discardable item, any
+ % following glue (such as a \parskip) would be a breakpoint. For example:
+ % @deffn deffn-whatever
+ % @vindex index-whatever
+ % Description.
+ % would allow a break between the index-whatever whatsit
+ % and the "Description." paragraph.
+ \ifnum\whatsitpenalty>9999 \penalty\whatsitpenalty \fi
+ \else
+ % On the other hand, if we had a nonzero \lastskip,
+ % this make-up glue would be preceded by a non-discardable item
+ % (the whatsit from the \write), so we must insert a \nobreak.
+ \nobreak\vskip\whatsitskip
+ \fi
+\fi}
+
+% The index entry written in the file actually looks like
+% \entry {sortstring}{page}{topic}
+% or
+% \entry {sortstring}{page}{topic}{subtopic}
+% The texindex program reads in these files and writes files
+% containing these kinds of lines:
+% \initial {c}
+% before the first topic whose initial is c
+% \entry {topic}{pagelist}
+% for a topic that is used without subtopics
+% \primary {topic}
+% for the beginning of a topic that is used with subtopics
+% \secondary {subtopic}{pagelist}
+% for each subtopic.
+
+% Define the user-accessible indexing commands
+% @findex, @vindex, @kindex, @cindex.
+
+\def\findex {\fnindex}
+\def\kindex {\kyindex}
+\def\cindex {\cpindex}
+\def\vindex {\vrindex}
+\def\tindex {\tpindex}
+\def\pindex {\pgindex}
+
+\def\cindexsub {\begingroup\obeylines\cindexsub}
+{\obeylines %
+\gdef\cindexsub "#1" #2^^M{\endgroup %
+\dosubind{cp}{#2}{#1}}}
+
+% Define the macros used in formatting output of the sorted index material.
+
+% @printindex causes a particular index (the ??s file) to get printed.
+% It does not print any chapter heading (usually an @unnumbered).
+%
+\parseargdef\printindex{\begingroup
+ \dobreak \chapheadingskip{10000}%
+ %
+ \smallfonts \rm
+ \tolerance = 9500
+ \plainfrenchspacing
+ \everypar = {}% don't want the \kern\-parindent from indentation suppression.
+ %
+ % See if the index file exists and is nonempty.
+ % Change catcode of @ here so that if the index file contains
+ % \initial {@}
+ % as its first line, TeX doesn't complain about mismatched braces
+ % (because it thinks @} is a control sequence).
+ \catcode`\@ = 11
+ \openin 1 \jobname.#1s
+ \ifeof 1
+ % \enddoublecolumns gets confused if there is no text in the index,
+ % and it loses the chapter title and the aux file entries for the
+ % index. The easiest way to prevent this problem is to make sure
+ % there is some text.
+ \putwordIndexNonexistent
+ \else
+ %
+ % If the index file exists but is empty, then \openin leaves \ifeof
+ % false. We have to make TeX try to read something from the file, so
+ % it can discover if there is anything in it.
+ \read 1 to \temp
+ \ifeof 1
+ \putwordIndexIsEmpty
+ \else
+ % Index files are almost Texinfo source, but we use \ as the escape
+ % character. It would be better to use @, but that's too big a change
+ % to make right now.
+ \def\indexbackslash{\backslashcurfont}%
+ \catcode`\\ = 0
+ \escapechar = `\\
+ \begindoublecolumns
+ \input \jobname.#1s
+ \enddoublecolumns
+ \fi
+ \fi
+ \closein 1
+\endgroup}
+
+% These macros are used by the sorted index file itself.
+% Change them to control the appearance of the index.
+
+\def\initial#1{{%
+ % Some minor font changes for the special characters.
+ \let\tentt=\sectt \let\tt=\sectt \let\sf=\sectt
+ %
+ % Remove any glue we may have, we'll be inserting our own.
+ \removelastskip
+ %
+ % We like breaks before the index initials, so insert a bonus.
+ \nobreak
+ \vskip 0pt plus 3\baselineskip
+ \penalty 0
+ \vskip 0pt plus -3\baselineskip
+ %
+ % Typeset the initial. Making this add up to a whole number of
+ % baselineskips increases the chance of the dots lining up from column
+ % to column. It still won't often be perfect, because of the stretch
+ % we need before each entry, but it's better.
+ %
+ % No shrink because it confuses \balancecolumns.
+ \vskip 1.67\baselineskip plus .5\baselineskip
+ \leftline{\secbf #1}%
+ % Do our best not to break after the initial.
+ \nobreak
+ \vskip .33\baselineskip plus .1\baselineskip
+}}
+
+% \entry typesets a paragraph consisting of the text (#1), dot leaders, and
+% then page number (#2) flushed to the right margin. It is used for index
+% and table of contents entries. The paragraph is indented by \leftskip.
+%
+% A straightforward implementation would start like this:
+% \def\entry#1#2{...
+% But this freezes the catcodes in the argument, and can cause problems to
+% @code, which sets - active. This problem was fixed by a kludge---
+% ``-'' was active throughout whole index, but this isn't really right.
+% The right solution is to prevent \entry from swallowing the whole text.
+% --kasal, 21nov03
+\def\entry{%
+ \begingroup
+ %
+ % Start a new paragraph if necessary, so our assignments below can't
+ % affect previous text.
+ \par
+ %
+ % Do not fill out the last line with white space.
+ \parfillskip = 0in
+ %
+ % No extra space above this paragraph.
+ \parskip = 0in
+ %
+ % Do not prefer a separate line ending with a hyphen to fewer lines.
+ \finalhyphendemerits = 0
+ %
+ % \hangindent is only relevant when the entry text and page number
+ % don't both fit on one line. In that case, bob suggests starting the
+ % dots pretty far over on the line. Unfortunately, a large
+ % indentation looks wrong when the entry text itself is broken across
+ % lines. So we use a small indentation and put up with long leaders.
+ %
+ % \hangafter is reset to 1 (which is the value we want) at the start
+ % of each paragraph, so we need not do anything with that.
+ \hangindent = 2em
+ %
+ % When the entry text needs to be broken, just fill out the first line
+ % with blank space.
+ \rightskip = 0pt plus1fil
+ %
+ % A bit of stretch before each entry for the benefit of balancing
+ % columns.
+ \vskip 0pt plus1pt
+ %
+ % When reading the text of entry, convert explicit line breaks
+ % from @* into spaces. The user might give these in long section
+ % titles, for instance.
+ \def\*{\unskip\space\ignorespaces}%
+ \def\entrybreak{\hfil\break}%
+ %
+ % Swallow the left brace of the text (first parameter):
+ \afterassignment\doentry
+ \let\temp =
+}
+\def\entrybreak{\unskip\space\ignorespaces}%
+\def\doentry{%
+ \bgroup % Instead of the swallowed brace.
+ \noindent
+ \aftergroup\finishentry
+ % And now comes the text of the entry.
+}
+\def\finishentry#1{%
+ % #1 is the page number.
+ %
+ % The following is kludged to not output a line of dots in the index if
+ % there are no page numbers. The next person who breaks this will be
+ % cursed by a Unix daemon.
+ \setbox\boxA = \hbox{#1}%
+ \ifdim\wd\boxA = 0pt
+ \ %
+ \else
+ %
+ % If we must, put the page number on a line of its own, and fill out
+ % this line with blank space. (The \hfil is overwhelmed with the
+ % fill leaders glue in \indexdotfill if the page number does fit.)
+ \hfil\penalty50
+ \null\nobreak\indexdotfill % Have leaders before the page number.
+ %
+ % The `\ ' here is removed by the implicit \unskip that TeX does as
+ % part of (the primitive) \par. Without it, a spurious underfull
+ % \hbox ensues.
+ \ifpdf
+ \pdfgettoks#1.%
+ \ \the\toksA
+ \else
+ \ #1%
+ \fi
+ \fi
+ \par
+ \endgroup
+}
+
+% Like plain.tex's \dotfill, except uses up at least 1 em.
+\def\indexdotfill{\cleaders
+ \hbox{$\mathsurround=0pt \mkern1.5mu.\mkern1.5mu$}\hskip 1em plus 1fill}
+
+\def\primary #1{\line{#1\hfil}}
+
+\newskip\secondaryindent \secondaryindent=0.5cm
+\def\secondary#1#2{{%
+ \parfillskip=0in
+ \parskip=0in
+ \hangindent=1in
+ \hangafter=1
+ \noindent\hskip\secondaryindent\hbox{#1}\indexdotfill
+ \ifpdf
+ \pdfgettoks#2.\ \the\toksA % The page number ends the paragraph.
+ \else
+ #2
+ \fi
+ \par
+}}
+
+% Define two-column mode, which we use to typeset indexes.
+% Adapted from the TeXbook, page 416, which is to say,
+% the manmac.tex format used to print the TeXbook itself.
+\catcode`\@=11
+
+\newbox\partialpage
+\newdimen\doublecolumnhsize
+
+\def\begindoublecolumns{\begingroup % ended by \enddoublecolumns
+ % Grab any single-column material above us.
+ \output = {%
+ %
+ % Here is a possibility not foreseen in manmac: if we accumulate a
+ % whole lot of material, we might end up calling this \output
+ % routine twice in a row (see the doublecol-lose test, which is
+ % essentially a couple of indexes with @setchapternewpage off). In
+ % that case we just ship out what is in \partialpage with the normal
+ % output routine. Generally, \partialpage will be empty when this
+ % runs and this will be a no-op. See the indexspread.tex test case.
+ \ifvoid\partialpage \else
+ \onepageout{\pagecontents\partialpage}%
+ \fi
+ %
+ \global\setbox\partialpage = \vbox{%
+ % Unvbox the main output page.
+ \unvbox\PAGE
+ \kern-\topskip \kern\baselineskip
+ }%
+ }%
+ \eject % run that output routine to set \partialpage
+ %
+ % Use the double-column output routine for subsequent pages.
+ \output = {\doublecolumnout}%
+ %
+ % Change the page size parameters. We could do this once outside this
+ % routine, in each of @smallbook, @afourpaper, and the default 8.5x11
+ % format, but then we repeat the same computation. Repeating a couple
+ % of assignments once per index is clearly meaningless for the
+ % execution time, so we may as well do it in one place.
+ %
+ % First we halve the line length, less a little for the gutter between
+ % the columns. We compute the gutter based on the line length, so it
+ % changes automatically with the paper format. The magic constant
+ % below is chosen so that the gutter has the same value (well, +-<1pt)
+ % as it did when we hard-coded it.
+ %
+ % We put the result in a separate register, \doublecolumhsize, so we
+ % can restore it in \pagesofar, after \hsize itself has (potentially)
+ % been clobbered.
+ %
+ \doublecolumnhsize = \hsize
+ \advance\doublecolumnhsize by -.04154\hsize
+ \divide\doublecolumnhsize by 2
+ \hsize = \doublecolumnhsize
+ %
+ % Double the \vsize as well. (We don't need a separate register here,
+ % since nobody clobbers \vsize.)
+ \vsize = 2\vsize
+}
+
+% The double-column output routine for all double-column pages except
+% the last.
+%
+\def\doublecolumnout{%
+ \splittopskip=\topskip \splitmaxdepth=\maxdepth
+ % Get the available space for the double columns -- the normal
+ % (undoubled) page height minus any material left over from the
+ % previous page.
+ \dimen@ = \vsize
+ \divide\dimen@ by 2
+ \advance\dimen@ by -\ht\partialpage
+ %
+ % box0 will be the left-hand column, box2 the right.
+ \setbox0=\vsplit255 to\dimen@ \setbox2=\vsplit255 to\dimen@
+ \onepageout\pagesofar
+ \unvbox255
+ \penalty\outputpenalty
+}
+%
+% Re-output the contents of the output page -- any previous material,
+% followed by the two boxes we just split, in box0 and box2.
+\def\pagesofar{%
+ \unvbox\partialpage
+ %
+ \hsize = \doublecolumnhsize
+ \wd0=\hsize \wd2=\hsize
+ \hbox to\pagewidth{\box0\hfil\box2}%
+}
+%
+% All done with double columns.
+\def\enddoublecolumns{%
+ % The following penalty ensures that the page builder is exercised
+ % _before_ we change the output routine. This is necessary in the
+ % following situation:
+ %
+ % The last section of the index consists only of a single entry.
+ % Before this section, \pagetotal is less than \pagegoal, so no
+ % break occurs before the last section starts. However, the last
+ % section, consisting of \initial and the single \entry, does not
+ % fit on the page and has to be broken off. Without the following
+ % penalty the page builder will not be exercised until \eject
+ % below, and by that time we'll already have changed the output
+ % routine to the \balancecolumns version, so the next-to-last
+ % double-column page will be processed with \balancecolumns, which
+ % is wrong: The two columns will go to the main vertical list, with
+ % the broken-off section in the recent contributions. As soon as
+ % the output routine finishes, TeX starts reconsidering the page
+ % break. The two columns and the broken-off section both fit on the
+ % page, because the two columns now take up only half of the page
+ % goal. When TeX sees \eject from below which follows the final
+ % section, it invokes the new output routine that we've set after
+ % \balancecolumns below; \onepageout will try to fit the two columns
+ % and the final section into the vbox of \pageheight (see
+ % \pagebody), causing an overfull box.
+ %
+ % Note that glue won't work here, because glue does not exercise the
+ % page builder, unlike penalties (see The TeXbook, pp. 280-281).
+ \penalty0
+ %
+ \output = {%
+ % Split the last of the double-column material. Leave it on the
+ % current page, no automatic page break.
+ \balancecolumns
+ %
+ % If we end up splitting too much material for the current page,
+ % though, there will be another page break right after this \output
+ % invocation ends. Having called \balancecolumns once, we do not
+ % want to call it again. Therefore, reset \output to its normal
+ % definition right away. (We hope \balancecolumns will never be
+ % called on to balance too much material, but if it is, this makes
+ % the output somewhat more palatable.)
+ \global\output = {\onepageout{\pagecontents\PAGE}}%
+ }%
+ \eject
+ \endgroup % started in \begindoublecolumns
+ %
+ % \pagegoal was set to the doubled \vsize above, since we restarted
+ % the current page. We're now back to normal single-column
+ % typesetting, so reset \pagegoal to the normal \vsize (after the
+ % \endgroup where \vsize got restored).
+ \pagegoal = \vsize
+}
+%
+% Called at the end of the double column material.
+\def\balancecolumns{%
+ \setbox0 = \vbox{\unvbox255}% like \box255 but more efficient, see p.120.
+ \dimen@ = \ht0
+ \advance\dimen@ by \topskip
+ \advance\dimen@ by-\baselineskip
+ \divide\dimen@ by 2 % target to split to
+ %debug\message{final 2-column material height=\the\ht0, target=\the\dimen@.}%
+ \splittopskip = \topskip
+ % Loop until we get a decent breakpoint.
+ {%
+ \vbadness = 10000
+ \loop
+ \global\setbox3 = \copy0
+ \global\setbox1 = \vsplit3 to \dimen@
+ \ifdim\ht3>\dimen@
+ \global\advance\dimen@ by 1pt
+ \repeat
+ }%
+ %debug\message{split to \the\dimen@, column heights: \the\ht1, \the\ht3.}%
+ \setbox0=\vbox to\dimen@{\unvbox1}%
+ \setbox2=\vbox to\dimen@{\unvbox3}%
+ %
+ \pagesofar
+}
+\catcode`\@ = \other
+
+
+\message{sectioning,}
+% Chapters, sections, etc.
+
+% Let's start with @part.
+\outer\parseargdef\part{\partzzz{#1}}
+\def\partzzz#1{%
+ \chapoddpage
+ \null
+ \vskip.3\vsize % move it down on the page a bit
+ \begingroup
+ \noindent \titlefonts\rmisbold #1\par % the text
+ \let\lastnode=\empty % no node to associate with
+ \writetocentry{part}{#1}{}% but put it in the toc
+ \headingsoff % no headline or footline on the part page
+ \chapoddpage
+ \endgroup
+}
+
+% \unnumberedno is an oxymoron. But we count the unnumbered
+% sections so that we can refer to them unambiguously in the pdf
+% outlines by their "section number". We avoid collisions with chapter
+% numbers by starting them at 10000. (If a document ever has 10000
+% chapters, we're in trouble anyway, I'm sure.)
+\newcount\unnumberedno \unnumberedno = 10000
+\newcount\chapno
+\newcount\secno \secno=0
+\newcount\subsecno \subsecno=0
+\newcount\subsubsecno \subsubsecno=0
+
+% This counter is funny since it counts through charcodes of letters A, B, ...
+\newcount\appendixno \appendixno = `\@
+%
+% \def\appendixletter{\char\the\appendixno}
+% We do the following ugly conditional instead of the above simple
+% construct for the sake of pdftex, which needs the actual
+% letter in the expansion, not just typeset.
+%
+\def\appendixletter{%
+ \ifnum\appendixno=`A A%
+ \else\ifnum\appendixno=`B B%
+ \else\ifnum\appendixno=`C C%
+ \else\ifnum\appendixno=`D D%
+ \else\ifnum\appendixno=`E E%
+ \else\ifnum\appendixno=`F F%
+ \else\ifnum\appendixno=`G G%
+ \else\ifnum\appendixno=`H H%
+ \else\ifnum\appendixno=`I I%
+ \else\ifnum\appendixno=`J J%
+ \else\ifnum\appendixno=`K K%
+ \else\ifnum\appendixno=`L L%
+ \else\ifnum\appendixno=`M M%
+ \else\ifnum\appendixno=`N N%
+ \else\ifnum\appendixno=`O O%
+ \else\ifnum\appendixno=`P P%
+ \else\ifnum\appendixno=`Q Q%
+ \else\ifnum\appendixno=`R R%
+ \else\ifnum\appendixno=`S S%
+ \else\ifnum\appendixno=`T T%
+ \else\ifnum\appendixno=`U U%
+ \else\ifnum\appendixno=`V V%
+ \else\ifnum\appendixno=`W W%
+ \else\ifnum\appendixno=`X X%
+ \else\ifnum\appendixno=`Y Y%
+ \else\ifnum\appendixno=`Z Z%
+ % The \the is necessary, despite appearances, because \appendixletter is
+ % expanded while writing the .toc file. \char\appendixno is not
+ % expandable, thus it is written literally, thus all appendixes come out
+ % with the same letter (or @) in the toc without it.
+ \else\char\the\appendixno
+ \fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi
+ \fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi}
+
+% Each @chapter defines these (using marks) as the number+name, number
+% and name of the chapter. Page headings and footings can use
+% these. @section does likewise.
+\def\thischapter{}
+\def\thischapternum{}
+\def\thischaptername{}
+\def\thissection{}
+\def\thissectionnum{}
+\def\thissectionname{}
+
+\newcount\absseclevel % used to calculate proper heading level
+\newcount\secbase\secbase=0 % @raisesections/@lowersections modify this count
+
+% @raisesections: treat @section as chapter, @subsection as section, etc.
+\def\raisesections{\global\advance\secbase by -1}
+\let\up=\raisesections % original BFox name
+
+% @lowersections: treat @chapter as section, @section as subsection, etc.
+\def\lowersections{\global\advance\secbase by 1}
+\let\down=\lowersections % original BFox name
+
+% we only have subsub.
+\chardef\maxseclevel = 3
+%
+% A numbered section within an unnumbered changes to unnumbered too.
+% To achieve this, remember the "biggest" unnum. sec. we are currently in:
+\chardef\unnlevel = \maxseclevel
+%
+% Trace whether the current chapter is an appendix or not:
+% \chapheadtype is "N" or "A", unnumbered chapters are ignored.
+\def\chapheadtype{N}
+
+% Choose a heading macro
+% #1 is heading type
+% #2 is heading level
+% #3 is text for heading
+\def\genhead#1#2#3{%
+ % Compute the abs. sec. level:
+ \absseclevel=#2
+ \advance\absseclevel by \secbase
+ % Make sure \absseclevel doesn't fall outside the range:
+ \ifnum \absseclevel < 0
+ \absseclevel = 0
+ \else
+ \ifnum \absseclevel > 3
+ \absseclevel = 3
+ \fi
+ \fi
+ % The heading type:
+ \def\headtype{#1}%
+ \if \headtype U%
+ \ifnum \absseclevel < \unnlevel
+ \chardef\unnlevel = \absseclevel
+ \fi
+ \else
+ % Check for appendix sections:
+ \ifnum \absseclevel = 0
+ \edef\chapheadtype{\headtype}%
+ \else
+ \if \headtype A\if \chapheadtype N%
+ \errmessage{@appendix... within a non-appendix chapter}%
+ \fi\fi
+ \fi
+ % Check for numbered within unnumbered:
+ \ifnum \absseclevel > \unnlevel
+ \def\headtype{U}%
+ \else
+ \chardef\unnlevel = 3
+ \fi
+ \fi
+ % Now print the heading:
+ \if \headtype U%
+ \ifcase\absseclevel
+ \unnumberedzzz{#3}%
+ \or \unnumberedseczzz{#3}%
+ \or \unnumberedsubseczzz{#3}%
+ \or \unnumberedsubsubseczzz{#3}%
+ \fi
+ \else
+ \if \headtype A%
+ \ifcase\absseclevel
+ \appendixzzz{#3}%
+ \or \appendixsectionzzz{#3}%
+ \or \appendixsubseczzz{#3}%
+ \or \appendixsubsubseczzz{#3}%
+ \fi
+ \else
+ \ifcase\absseclevel
+ \chapterzzz{#3}%
+ \or \seczzz{#3}%
+ \or \numberedsubseczzz{#3}%
+ \or \numberedsubsubseczzz{#3}%
+ \fi
+ \fi
+ \fi
+ \suppressfirstparagraphindent
+}
+
+% an interface:
+\def\numhead{\genhead N}
+\def\apphead{\genhead A}
+\def\unnmhead{\genhead U}
+
+% @chapter, @appendix, @unnumbered. Increment top-level counter, reset
+% all lower-level sectioning counters to zero.
+%
+% Also set \chaplevelprefix, which we prepend to @float sequence numbers
+% (e.g., figures), q.v. By default (before any chapter), that is empty.
+\let\chaplevelprefix = \empty
+%
+\outer\parseargdef\chapter{\numhead0{#1}} % normally numhead0 calls chapterzzz
+\def\chapterzzz#1{%
+ % section resetting is \global in case the chapter is in a group, such
+ % as an @include file.
+ \global\secno=0 \global\subsecno=0 \global\subsubsecno=0
+ \global\advance\chapno by 1
+ %
+ % Used for \float.
+ \gdef\chaplevelprefix{\the\chapno.}%
+ \resetallfloatnos
+ %
+ % \putwordChapter can contain complex things in translations.
+ \toks0=\expandafter{\putwordChapter}%
+ \message{\the\toks0 \space \the\chapno}%
+ %
+ % Write the actual heading.
+ \chapmacro{#1}{Ynumbered}{\the\chapno}%
+ %
+ % So @section and the like are numbered underneath this chapter.
+ \global\let\section = \numberedsec
+ \global\let\subsection = \numberedsubsec
+ \global\let\subsubsection = \numberedsubsubsec
+}
+
+\outer\parseargdef\appendix{\apphead0{#1}} % normally calls appendixzzz
+%
+\def\appendixzzz#1{%
+ \global\secno=0 \global\subsecno=0 \global\subsubsecno=0
+ \global\advance\appendixno by 1
+ \gdef\chaplevelprefix{\appendixletter.}%
+ \resetallfloatnos
+ %
+ % \putwordAppendix can contain complex things in translations.
+ \toks0=\expandafter{\putwordAppendix}%
+ \message{\the\toks0 \space \appendixletter}%
+ %
+ \chapmacro{#1}{Yappendix}{\appendixletter}%
+ %
+ \global\let\section = \appendixsec
+ \global\let\subsection = \appendixsubsec
+ \global\let\subsubsection = \appendixsubsubsec
+}
+
+% normally unnmhead0 calls unnumberedzzz:
+\outer\parseargdef\unnumbered{\unnmhead0{#1}}
+\def\unnumberedzzz#1{%
+ \global\secno=0 \global\subsecno=0 \global\subsubsecno=0
+ \global\advance\unnumberedno by 1
+ %
+ % Since an unnumbered has no number, no prefix for figures.
+ \global\let\chaplevelprefix = \empty
+ \resetallfloatnos
+ %
+ % This used to be simply \message{#1}, but TeX fully expands the
+ % argument to \message. Therefore, if #1 contained @-commands, TeX
+ % expanded them. For example, in `@unnumbered The @cite{Book}', TeX
+ % expanded @cite (which turns out to cause errors because \cite is meant
+ % to be executed, not expanded).
+ %
+ % Anyway, we don't want the fully-expanded definition of @cite to appear
+ % as a result of the \message, we just want `@cite' itself. We use
+ % \the<toks register> to achieve this: TeX expands \the<toks> only once,
+ % simply yielding the contents of <toks register>. (We also do this for
+ % the toc entries.)
+ \toks0 = {#1}%
+ \message{(\the\toks0)}%
+ %
+ \chapmacro{#1}{Ynothing}{\the\unnumberedno}%
+ %
+ \global\let\section = \unnumberedsec
+ \global\let\subsection = \unnumberedsubsec
+ \global\let\subsubsection = \unnumberedsubsubsec
+}
+
+% @centerchap is like @unnumbered, but the heading is centered.
+\outer\parseargdef\centerchap{%
+ % Well, we could do the following in a group, but that would break
+ % an assumption that \chapmacro is called at the outermost level.
+ % Thus we are safer this way: --kasal, 24feb04
+ \let\centerparametersmaybe = \centerparameters
+ \unnmhead0{#1}%
+ \let\centerparametersmaybe = \relax
+}
+
+% @top is like @unnumbered.
+\let\top\unnumbered
+
+% Sections.
+%
+\outer\parseargdef\numberedsec{\numhead1{#1}} % normally calls seczzz
+\def\seczzz#1{%
+ \global\subsecno=0 \global\subsubsecno=0 \global\advance\secno by 1
+ \sectionheading{#1}{sec}{Ynumbered}{\the\chapno.\the\secno}%
+}
+
+% normally calls appendixsectionzzz:
+\outer\parseargdef\appendixsection{\apphead1{#1}}
+\def\appendixsectionzzz#1{%
+ \global\subsecno=0 \global\subsubsecno=0 \global\advance\secno by 1
+ \sectionheading{#1}{sec}{Yappendix}{\appendixletter.\the\secno}%
+}
+\let\appendixsec\appendixsection
+
+% normally calls unnumberedseczzz:
+\outer\parseargdef\unnumberedsec{\unnmhead1{#1}}
+\def\unnumberedseczzz#1{%
+ \global\subsecno=0 \global\subsubsecno=0 \global\advance\secno by 1
+ \sectionheading{#1}{sec}{Ynothing}{\the\unnumberedno.\the\secno}%
+}
+
+% Subsections.
+%
+% normally calls numberedsubseczzz:
+\outer\parseargdef\numberedsubsec{\numhead2{#1}}
+\def\numberedsubseczzz#1{%
+ \global\subsubsecno=0 \global\advance\subsecno by 1
+ \sectionheading{#1}{subsec}{Ynumbered}{\the\chapno.\the\secno.\the\subsecno}%
+}
+
+% normally calls appendixsubseczzz:
+\outer\parseargdef\appendixsubsec{\apphead2{#1}}
+\def\appendixsubseczzz#1{%
+ \global\subsubsecno=0 \global\advance\subsecno by 1
+ \sectionheading{#1}{subsec}{Yappendix}%
+ {\appendixletter.\the\secno.\the\subsecno}%
+}
+
+% normally calls unnumberedsubseczzz:
+\outer\parseargdef\unnumberedsubsec{\unnmhead2{#1}}
+\def\unnumberedsubseczzz#1{%
+ \global\subsubsecno=0 \global\advance\subsecno by 1
+ \sectionheading{#1}{subsec}{Ynothing}%
+ {\the\unnumberedno.\the\secno.\the\subsecno}%
+}
+
+% Subsubsections.
+%
+% normally numberedsubsubseczzz:
+\outer\parseargdef\numberedsubsubsec{\numhead3{#1}}
+\def\numberedsubsubseczzz#1{%
+ \global\advance\subsubsecno by 1
+ \sectionheading{#1}{subsubsec}{Ynumbered}%
+ {\the\chapno.\the\secno.\the\subsecno.\the\subsubsecno}%
+}
+
+% normally appendixsubsubseczzz:
+\outer\parseargdef\appendixsubsubsec{\apphead3{#1}}
+\def\appendixsubsubseczzz#1{%
+ \global\advance\subsubsecno by 1
+ \sectionheading{#1}{subsubsec}{Yappendix}%
+ {\appendixletter.\the\secno.\the\subsecno.\the\subsubsecno}%
+}
+
+% normally unnumberedsubsubseczzz:
+\outer\parseargdef\unnumberedsubsubsec{\unnmhead3{#1}}
+\def\unnumberedsubsubseczzz#1{%
+ \global\advance\subsubsecno by 1
+ \sectionheading{#1}{subsubsec}{Ynothing}%
+ {\the\unnumberedno.\the\secno.\the\subsecno.\the\subsubsecno}%
+}
+
+% These macros control what the section commands do, according
+% to what kind of chapter we are in (ordinary, appendix, or unnumbered).
+% Define them by default for a numbered chapter.
+\let\section = \numberedsec
+\let\subsection = \numberedsubsec
+\let\subsubsection = \numberedsubsubsec
+
+% Define @majorheading, @heading and @subheading
+
+\def\majorheading{%
+ {\advance\chapheadingskip by 10pt \chapbreak }%
+ \parsearg\chapheadingzzz
+}
+
+\def\chapheading{\chapbreak \parsearg\chapheadingzzz}
+\def\chapheadingzzz#1{%
+ \vbox{\chapfonts \raggedtitlesettings #1\par}%
+ \nobreak\bigskip \nobreak
+ \suppressfirstparagraphindent
+}
+
+% @heading, @subheading, @subsubheading.
+\parseargdef\heading{\sectionheading{#1}{sec}{Yomitfromtoc}{}
+ \suppressfirstparagraphindent}
+\parseargdef\subheading{\sectionheading{#1}{subsec}{Yomitfromtoc}{}
+ \suppressfirstparagraphindent}
+\parseargdef\subsubheading{\sectionheading{#1}{subsubsec}{Yomitfromtoc}{}
+ \suppressfirstparagraphindent}
+
+% These macros generate a chapter, section, etc. heading only
+% (including whitespace, linebreaking, etc. around it),
+% given all the information in convenient, parsed form.
+
+% Args are the skip and penalty (usually negative)
+\def\dobreak#1#2{\par\ifdim\lastskip<#1\removelastskip\penalty#2\vskip#1\fi}
+
+% Parameter controlling skip before chapter headings (if needed)
+\newskip\chapheadingskip
+
+% Define plain chapter starts, and page on/off switching for it.
+\def\chapbreak{\dobreak \chapheadingskip {-4000}}
+\def\chappager{\par\vfill\supereject}
+% Because \domark is called before \chapoddpage, the filler page will
+% get the headings for the next chapter, which is wrong. But we don't
+% care -- we just disable all headings on the filler page.
+\def\chapoddpage{%
+ \chappager
+ \ifodd\pageno \else
+ \begingroup
+ \headingsoff
+ \null
+ \chappager
+ \endgroup
+ \fi
+}
+
+\def\setchapternewpage #1 {\csname CHAPPAG#1\endcsname}
+
+\def\CHAPPAGoff{%
+\global\let\contentsalignmacro = \chappager
+\global\let\pchapsepmacro=\chapbreak
+\global\let\pagealignmacro=\chappager}
+
+\def\CHAPPAGon{%
+\global\let\contentsalignmacro = \chappager
+\global\let\pchapsepmacro=\chappager
+\global\let\pagealignmacro=\chappager
+\global\def\HEADINGSon{\HEADINGSsingle}}
+
+\def\CHAPPAGodd{%
+\global\let\contentsalignmacro = \chapoddpage
+\global\let\pchapsepmacro=\chapoddpage
+\global\let\pagealignmacro=\chapoddpage
+\global\def\HEADINGSon{\HEADINGSdouble}}
+
+\CHAPPAGon
+
+% Chapter opening.
+%
+% #1 is the text, #2 is the section type (Ynumbered, Ynothing,
+% Yappendix, Yomitfromtoc), #3 the chapter number.
+%
+% To test against our argument.
+\def\Ynothingkeyword{Ynothing}
+\def\Yomitfromtockeyword{Yomitfromtoc}
+\def\Yappendixkeyword{Yappendix}
+%
+\def\chapmacro#1#2#3{%
+ % Insert the first mark before the heading break (see notes for \domark).
+ \let\prevchapterdefs=\lastchapterdefs
+ \let\prevsectiondefs=\lastsectiondefs
+ \gdef\lastsectiondefs{\gdef\thissectionname{}\gdef\thissectionnum{}%
+ \gdef\thissection{}}%
+ %
+ \def\temptype{#2}%
+ \ifx\temptype\Ynothingkeyword
+ \gdef\lastchapterdefs{\gdef\thischaptername{#1}\gdef\thischapternum{}%
+ \gdef\thischapter{\thischaptername}}%
+ \else\ifx\temptype\Yomitfromtockeyword
+ \gdef\lastchapterdefs{\gdef\thischaptername{#1}\gdef\thischapternum{}%
+ \gdef\thischapter{}}%
+ \else\ifx\temptype\Yappendixkeyword
+ \toks0={#1}%
+ \xdef\lastchapterdefs{%
+ \gdef\noexpand\thischaptername{\the\toks0}%
+ \gdef\noexpand\thischapternum{\appendixletter}%
+ % \noexpand\putwordAppendix avoids expanding indigestible
+ % commands in some of the translations.
+ \gdef\noexpand\thischapter{\noexpand\putwordAppendix{}
+ \noexpand\thischapternum:
+ \noexpand\thischaptername}%
+ }%
+ \else
+ \toks0={#1}%
+ \xdef\lastchapterdefs{%
+ \gdef\noexpand\thischaptername{\the\toks0}%
+ \gdef\noexpand\thischapternum{\the\chapno}%
+ % \noexpand\putwordChapter avoids expanding indigestible
+ % commands in some of the translations.
+ \gdef\noexpand\thischapter{\noexpand\putwordChapter{}
+ \noexpand\thischapternum:
+ \noexpand\thischaptername}%
+ }%
+ \fi\fi\fi
+ %
+ % Output the mark. Pass it through \safewhatsit, to take care of
+ % the preceding space.
+ \safewhatsit\domark
+ %
+ % Insert the chapter heading break.
+ \pchapsepmacro
+ %
+ % Now the second mark, after the heading break. No break points
+ % between here and the heading.
+ \let\prevchapterdefs=\lastchapterdefs
+ \let\prevsectiondefs=\lastsectiondefs
+ \domark
+ %
+ {%
+ \chapfonts \rmisbold
+ %
+ % Have to define \lastsection before calling \donoderef, because the
+ % xref code eventually uses it. On the other hand, it has to be called
+ % after \pchapsepmacro, or the headline will change too soon.
+ \gdef\lastsection{#1}%
+ %
+ % Only insert the separating space if we have a chapter/appendix
+ % number, and don't print the unnumbered ``number''.
+ \ifx\temptype\Ynothingkeyword
+ \setbox0 = \hbox{}%
+ \def\toctype{unnchap}%
+ \else\ifx\temptype\Yomitfromtockeyword
+ \setbox0 = \hbox{}% contents like unnumbered, but no toc entry
+ \def\toctype{omit}%
+ \else\ifx\temptype\Yappendixkeyword
+ \setbox0 = \hbox{\putwordAppendix{} #3\enspace}%
+ \def\toctype{app}%
+ \else
+ \setbox0 = \hbox{#3\enspace}%
+ \def\toctype{numchap}%
+ \fi\fi\fi
+ %
+ % Write the toc entry for this chapter. Must come before the
+ % \donoderef, because we include the current node name in the toc
+ % entry, and \donoderef resets it to empty.
+ \writetocentry{\toctype}{#1}{#3}%
+ %
+ % For pdftex, we have to write out the node definition (aka, make
+ % the pdfdest) after any page break, but before the actual text has
+ % been typeset. If the destination for the pdf outline is after the
+ % text, then jumping from the outline may wind up with the text not
+ % being visible, for instance under high magnification.
+ \donoderef{#2}%
+ %
+ % Typeset the actual heading.
+ \nobreak % Avoid page breaks at the interline glue.
+ \vbox{\raggedtitlesettings \hangindent=\wd0 \centerparametersmaybe
+ \unhbox0 #1\par}%
+ }%
+ \nobreak\bigskip % no page break after a chapter title
+ \nobreak
+}
+
+% @centerchap -- centered and unnumbered.
+\let\centerparametersmaybe = \relax
+\def\centerparameters{%
+ \advance\rightskip by 3\rightskip
+ \leftskip = \rightskip
+ \parfillskip = 0pt
+}
+
+
+% I don't think this chapter style is supported any more, so I'm not
+% updating it with the new noderef stuff. We'll see. --karl, 11aug03.
+%
+\def\setchapterstyle #1 {\csname CHAPF#1\endcsname}
+%
+\def\unnchfopen #1{%
+ \chapoddpage
+ \vbox{\chapfonts \raggedtitlesettings #1\par}%
+ \nobreak\bigskip\nobreak
+}
+\def\chfopen #1#2{\chapoddpage {\chapfonts
+\vbox to 3in{\vfil \hbox to\hsize{\hfil #2} \hbox to\hsize{\hfil #1} \vfil}}%
+\par\penalty 5000 %
+}
+\def\centerchfopen #1{%
+ \chapoddpage
+ \vbox{\chapfonts \raggedtitlesettings \hfill #1\hfill}%
+ \nobreak\bigskip \nobreak
+}
+\def\CHAPFopen{%
+ \global\let\chapmacro=\chfopen
+ \global\let\centerchapmacro=\centerchfopen}
+
+
+% Section titles. These macros combine the section number parts and
+% call the generic \sectionheading to do the printing.
+%
+\newskip\secheadingskip
+\def\secheadingbreak{\dobreak \secheadingskip{-1000}}
+
+% Subsection titles.
+\newskip\subsecheadingskip
+\def\subsecheadingbreak{\dobreak \subsecheadingskip{-500}}
+
+% Subsubsection titles.
+\def\subsubsecheadingskip{\subsecheadingskip}
+\def\subsubsecheadingbreak{\subsecheadingbreak}
+
+
+% Print any size, any type, section title.
+%
+% #1 is the text, #2 is the section level (sec/subsec/subsubsec), #3 is
+% the section type for xrefs (Ynumbered, Ynothing, Yappendix), #4 is the
+% section number.
+%
+\def\seckeyword{sec}
+%
+\def\sectionheading#1#2#3#4{%
+ {%
+ \checkenv{}% should not be in an environment.
+ %
+ % Switch to the right set of fonts.
+ \csname #2fonts\endcsname \rmisbold
+ %
+ \def\sectionlevel{#2}%
+ \def\temptype{#3}%
+ %
+ % Insert first mark before the heading break (see notes for \domark).
+ \let\prevsectiondefs=\lastsectiondefs
+ \ifx\temptype\Ynothingkeyword
+ \ifx\sectionlevel\seckeyword
+ \gdef\lastsectiondefs{\gdef\thissectionname{#1}\gdef\thissectionnum{}%
+ \gdef\thissection{\thissectionname}}%
+ \fi
+ \else\ifx\temptype\Yomitfromtockeyword
+ % Don't redefine \thissection.
+ \else\ifx\temptype\Yappendixkeyword
+ \ifx\sectionlevel\seckeyword
+ \toks0={#1}%
+ \xdef\lastsectiondefs{%
+ \gdef\noexpand\thissectionname{\the\toks0}%
+ \gdef\noexpand\thissectionnum{#4}%
+ % \noexpand\putwordSection avoids expanding indigestible
+ % commands in some of the translations.
+ \gdef\noexpand\thissection{\noexpand\putwordSection{}
+ \noexpand\thissectionnum:
+ \noexpand\thissectionname}%
+ }%
+ \fi
+ \else
+ \ifx\sectionlevel\seckeyword
+ \toks0={#1}%
+ \xdef\lastsectiondefs{%
+ \gdef\noexpand\thissectionname{\the\toks0}%
+ \gdef\noexpand\thissectionnum{#4}%
+ % \noexpand\putwordSection avoids expanding indigestible
+ % commands in some of the translations.
+ \gdef\noexpand\thissection{\noexpand\putwordSection{}
+ \noexpand\thissectionnum:
+ \noexpand\thissectionname}%
+ }%
+ \fi
+ \fi\fi\fi
+ %
+ % Go into vertical mode. Usually we'll already be there, but we
+ % don't want the following whatsit to end up in a preceding paragraph
+ % if the document didn't happen to have a blank line.
+ \par
+ %
+ % Output the mark. Pass it through \safewhatsit, to take care of
+ % the preceding space.
+ \safewhatsit\domark
+ %
+ % Insert space above the heading.
+ \csname #2headingbreak\endcsname
+ %
+ % Now the second mark, after the heading break. No break points
+ % between here and the heading.
+ \let\prevsectiondefs=\lastsectiondefs
+ \domark
+ %
+ % Only insert the space after the number if we have a section number.
+ \ifx\temptype\Ynothingkeyword
+ \setbox0 = \hbox{}%
+ \def\toctype{unn}%
+ \gdef\lastsection{#1}%
+ \else\ifx\temptype\Yomitfromtockeyword
+ % for @headings -- no section number, don't include in toc,
+ % and don't redefine \lastsection.
+ \setbox0 = \hbox{}%
+ \def\toctype{omit}%
+ \let\sectionlevel=\empty
+ \else\ifx\temptype\Yappendixkeyword
+ \setbox0 = \hbox{#4\enspace}%
+ \def\toctype{app}%
+ \gdef\lastsection{#1}%
+ \else
+ \setbox0 = \hbox{#4\enspace}%
+ \def\toctype{num}%
+ \gdef\lastsection{#1}%
+ \fi\fi\fi
+ %
+ % Write the toc entry (before \donoderef). See comments in \chapmacro.
+ \writetocentry{\toctype\sectionlevel}{#1}{#4}%
+ %
+ % Write the node reference (= pdf destination for pdftex).
+ % Again, see comments in \chapmacro.
+ \donoderef{#3}%
+ %
+ % Interline glue will be inserted when the vbox is completed.
+ % That glue will be a valid breakpoint for the page, since it'll be
+ % preceded by a whatsit (usually from the \donoderef, or from the
+ % \writetocentry if there was no node). We don't want to allow that
+ % break, since then the whatsits could end up on page n while the
+ % section is on page n+1, thus toc/etc. are wrong. Debian bug 276000.
+ \nobreak
+ %
+ % Output the actual section heading.
+ \vbox{\hyphenpenalty=10000 \tolerance=5000 \parindent=0pt \ptexraggedright
+ \hangindent=\wd0 % zero if no section number
+ \unhbox0 #1}%
+ }%
+ % Add extra space after the heading -- half of whatever came above it.
+ % Don't allow stretch, though.
+ \kern .5 \csname #2headingskip\endcsname
+ %
+ % Do not let the kern be a potential breakpoint, as it would be if it
+ % was followed by glue.
+ \nobreak
+ %
+ % We'll almost certainly start a paragraph next, so don't let that
+ % glue accumulate. (Not a breakpoint because it's preceded by a
+ % discardable item.) However, when a paragraph is not started next
+ % (\startdefun, \cartouche, \center, etc.), this needs to be wiped out
+ % or the negative glue will cause weirdly wrong output, typically
+ % obscuring the section heading with something else.
+ \vskip-\parskip
+ %
+ % This is so the last item on the main vertical list is a known
+ % \penalty > 10000, so \startdefun, etc., can recognize the situation
+ % and do the needful.
+ \penalty 10001
+}
+
+
+\message{toc,}
+% Table of contents.
+\newwrite\tocfile
+
+% Write an entry to the toc file, opening it if necessary.
+% Called from @chapter, etc.
+%
+% Example usage: \writetocentry{sec}{Section Name}{\the\chapno.\the\secno}
+% We append the current node name (if any) and page number as additional
+% arguments for the \{chap,sec,...}entry macros which will eventually
+% read this. The node name is used in the pdf outlines as the
+% destination to jump to.
+%
+% We open the .toc file for writing here instead of at @setfilename (or
+% any other fixed time) so that @contents can be anywhere in the document.
+% But if #1 is `omit', then we don't do anything. This is used for the
+% table of contents chapter openings themselves.
+%
+\newif\iftocfileopened
+\def\omitkeyword{omit}%
+%
+\def\writetocentry#1#2#3{%
+ \edef\writetoctype{#1}%
+ \ifx\writetoctype\omitkeyword \else
+ \iftocfileopened\else
+ \immediate\openout\tocfile = \jobname.toc
+ \global\tocfileopenedtrue
+ \fi
+ %
+ \iflinks
+ {\atdummies
+ \edef\temp{%
+ \write\tocfile{@#1entry{#2}{#3}{\lastnode}{\noexpand\folio}}}%
+ \temp
+ }%
+ \fi
+ \fi
+ %
+ % Tell \shipout to create a pdf destination on each page, if we're
+ % writing pdf. These are used in the table of contents. We can't
+ % just write one on every page because the title pages are numbered
+ % 1 and 2 (the page numbers aren't printed), and so are the first
+ % two pages of the document. Thus, we'd have two destinations named
+ % `1', and two named `2'.
+ \ifpdf \global\pdfmakepagedesttrue \fi
+}
+
+
+% These characters do not print properly in the Computer Modern roman
+% fonts, so we must take special care. This is more or less redundant
+% with the Texinfo input format setup at the end of this file.
+%
+\def\activecatcodes{%
+ \catcode`\"=\active
+ \catcode`\$=\active
+ \catcode`\<=\active
+ \catcode`\>=\active
+ \catcode`\\=\active
+ \catcode`\^=\active
+ \catcode`\_=\active
+ \catcode`\|=\active
+ \catcode`\~=\active
+}
+
+
+% Read the toc file, which is essentially Texinfo input.
+\def\readtocfile{%
+ \setupdatafile
+ \activecatcodes
+ \input \tocreadfilename
+}
+
+\newskip\contentsrightmargin \contentsrightmargin=1in
+\newcount\savepageno
+\newcount\lastnegativepageno \lastnegativepageno = -1
+
+% Prepare to read what we've written to \tocfile.
+%
+\def\startcontents#1{%
+ % If @setchapternewpage on, and @headings double, the contents should
+ % start on an odd page, unlike chapters. Thus, we maintain
+ % \contentsalignmacro in parallel with \pagealignmacro.
+ % From: Torbjorn Granlund <tege@matematik.su.se>
+ \contentsalignmacro
+ \immediate\closeout\tocfile
+ %
+ % Don't need to put `Contents' or `Short Contents' in the headline.
+ % It is abundantly clear what they are.
+ \chapmacro{#1}{Yomitfromtoc}{}%
+ %
+ \savepageno = \pageno
+ \begingroup % Set up to handle contents files properly.
+ \raggedbottom % Worry more about breakpoints than the bottom.
+ \advance\hsize by -\contentsrightmargin % Don't use the full line length.
+ %
+ % Roman numerals for page numbers.
+ \ifnum \pageno>0 \global\pageno = \lastnegativepageno \fi
+}
+
+% redefined for the two-volume lispref. We always output on
+% \jobname.toc even if this is redefined.
+%
+\def\tocreadfilename{\jobname.toc}
+
+% Normal (long) toc.
+%
+\def\contents{%
+ \startcontents{\putwordTOC}%
+ \openin 1 \tocreadfilename\space
+ \ifeof 1 \else
+ \readtocfile
+ \fi
+ \vfill \eject
+ \contentsalignmacro % in case @setchapternewpage odd is in effect
+ \ifeof 1 \else
+ \pdfmakeoutlines
+ \fi
+ \closein 1
+ \endgroup
+ \lastnegativepageno = \pageno
+ \global\pageno = \savepageno
+}
+
+% And just the chapters.
+\def\summarycontents{%
+ \startcontents{\putwordShortTOC}%
+ %
+ \let\partentry = \shortpartentry
+ \let\numchapentry = \shortchapentry
+ \let\appentry = \shortchapentry
+ \let\unnchapentry = \shortunnchapentry
+ % We want a true roman here for the page numbers.
+ \secfonts
+ \let\rm=\shortcontrm \let\bf=\shortcontbf
+ \let\sl=\shortcontsl \let\tt=\shortconttt
+ \rm
+ \hyphenpenalty = 10000
+ \advance\baselineskip by 1pt % Open it up a little.
+ \def\numsecentry##1##2##3##4{}
+ \let\appsecentry = \numsecentry
+ \let\unnsecentry = \numsecentry
+ \let\numsubsecentry = \numsecentry
+ \let\appsubsecentry = \numsecentry
+ \let\unnsubsecentry = \numsecentry
+ \let\numsubsubsecentry = \numsecentry
+ \let\appsubsubsecentry = \numsecentry
+ \let\unnsubsubsecentry = \numsecentry
+ \openin 1 \tocreadfilename\space
+ \ifeof 1 \else
+ \readtocfile
+ \fi
+ \closein 1
+ \vfill \eject
+ \contentsalignmacro % in case @setchapternewpage odd is in effect
+ \endgroup
+ \lastnegativepageno = \pageno
+ \global\pageno = \savepageno
+}
+\let\shortcontents = \summarycontents
+
+% Typeset the label for a chapter or appendix for the short contents.
+% The arg is, e.g., `A' for an appendix, or `3' for a chapter.
+%
+\def\shortchaplabel#1{%
+ % This space should be enough, since a single number is .5em, and the
+ % widest letter (M) is 1em, at least in the Computer Modern fonts.
+ % But use \hss just in case.
+ % (This space doesn't include the extra space that gets added after
+ % the label; that gets put in by \shortchapentry above.)
+ %
+ % We'd like to right-justify chapter numbers, but that looks strange
+ % with appendix letters. And right-justifying numbers and
+ % left-justifying letters looks strange when there is less than 10
+ % chapters. Have to read the whole toc once to know how many chapters
+ % there are before deciding ...
+ \hbox to 1em{#1\hss}%
+}
+
+% These macros generate individual entries in the table of contents.
+% The first argument is the chapter or section name.
+% The last argument is the page number.
+% The arguments in between are the chapter number, section number, ...
+
+% Parts, in the main contents. Replace the part number, which doesn't
+% exist, with an empty box. Let's hope all the numbers have the same width.
+% Also ignore the page number, which is conventionally not printed.
+\def\numeralbox{\setbox0=\hbox{8}\hbox to \wd0{\hfil}}
+\def\partentry#1#2#3#4{\dochapentry{\numeralbox\labelspace#1}{}}
+%
+% Parts, in the short toc.
+\def\shortpartentry#1#2#3#4{%
+ \penalty-300
+ \vskip.5\baselineskip plus.15\baselineskip minus.1\baselineskip
+ \shortchapentry{{\bf #1}}{\numeralbox}{}{}%
+}
+
+% Chapters, in the main contents.
+\def\numchapentry#1#2#3#4{\dochapentry{#2\labelspace#1}{#4}}
+%
+% Chapters, in the short toc.
+% See comments in \dochapentry re vbox and related settings.
+\def\shortchapentry#1#2#3#4{%
+ \tocentry{\shortchaplabel{#2}\labelspace #1}{\doshortpageno\bgroup#4\egroup}%
+}
+
+% Appendices, in the main contents.
+% Need the word Appendix, and a fixed-size box.
+%
+\def\appendixbox#1{%
+ % We use M since it's probably the widest letter.
+ \setbox0 = \hbox{\putwordAppendix{} M}%
+ \hbox to \wd0{\putwordAppendix{} #1\hss}}
+%
+\def\appentry#1#2#3#4{\dochapentry{\appendixbox{#2}\labelspace#1}{#4}}
+
+% Unnumbered chapters.
+\def\unnchapentry#1#2#3#4{\dochapentry{#1}{#4}}
+\def\shortunnchapentry#1#2#3#4{\tocentry{#1}{\doshortpageno\bgroup#4\egroup}}
+
+% Sections.
+\def\numsecentry#1#2#3#4{\dosecentry{#2\labelspace#1}{#4}}
+\let\appsecentry=\numsecentry
+\def\unnsecentry#1#2#3#4{\dosecentry{#1}{#4}}
+
+% Subsections.
+\def\numsubsecentry#1#2#3#4{\dosubsecentry{#2\labelspace#1}{#4}}
+\let\appsubsecentry=\numsubsecentry
+\def\unnsubsecentry#1#2#3#4{\dosubsecentry{#1}{#4}}
+
+% And subsubsections.
+\def\numsubsubsecentry#1#2#3#4{\dosubsubsecentry{#2\labelspace#1}{#4}}
+\let\appsubsubsecentry=\numsubsubsecentry
+\def\unnsubsubsecentry#1#2#3#4{\dosubsubsecentry{#1}{#4}}
+
+% This parameter controls the indentation of the various levels.
+% Same as \defaultparindent.
+\newdimen\tocindent \tocindent = 15pt
+
+% Now for the actual typesetting. In all these, #1 is the text and #2 is the
+% page number.
+%
+% If the toc has to be broken over pages, we want it to be at chapters
+% if at all possible; hence the \penalty.
+\def\dochapentry#1#2{%
+ \penalty-300 \vskip1\baselineskip plus.33\baselineskip minus.25\baselineskip
+ \begingroup
+ \chapentryfonts
+ \tocentry{#1}{\dopageno\bgroup#2\egroup}%
+ \endgroup
+ \nobreak\vskip .25\baselineskip plus.1\baselineskip
+}
+
+\def\dosecentry#1#2{\begingroup
+ \secentryfonts \leftskip=\tocindent
+ \tocentry{#1}{\dopageno\bgroup#2\egroup}%
+\endgroup}
+
+\def\dosubsecentry#1#2{\begingroup
+ \subsecentryfonts \leftskip=2\tocindent
+ \tocentry{#1}{\dopageno\bgroup#2\egroup}%
+\endgroup}
+
+\def\dosubsubsecentry#1#2{\begingroup
+ \subsubsecentryfonts \leftskip=3\tocindent
+ \tocentry{#1}{\dopageno\bgroup#2\egroup}%
+\endgroup}
+
+% We use the same \entry macro as for the index entries.
+\let\tocentry = \entry
+
+% Space between chapter (or whatever) number and the title.
+\def\labelspace{\hskip1em \relax}
+
+\def\dopageno#1{{\rm #1}}
+\def\doshortpageno#1{{\rm #1}}
+
+\def\chapentryfonts{\secfonts \rm}
+\def\secentryfonts{\textfonts}
+\def\subsecentryfonts{\textfonts}
+\def\subsubsecentryfonts{\textfonts}
+
+
+\message{environments,}
+% @foo ... @end foo.
+
+% @tex ... @end tex escapes into raw TeX temporarily.
+% One exception: @ is still an escape character, so that @end tex works.
+% But \@ or @@ will get a plain @ character.
+
+\envdef\tex{%
+ \setupmarkupstyle{tex}%
+ \catcode `\\=0 \catcode `\{=1 \catcode `\}=2
+ \catcode `\$=3 \catcode `\&=4 \catcode `\#=6
+ \catcode `\^=7 \catcode `\_=8 \catcode `\~=\active \let~=\tie
+ \catcode `\%=14
+ \catcode `\+=\other
+ \catcode `\"=\other
+ \catcode `\|=\other
+ \catcode `\<=\other
+ \catcode `\>=\other
+ \catcode`\`=\other
+ \catcode`\'=\other
+ \escapechar=`\\
+ %
+ % ' is active in math mode (mathcode"8000). So reset it, and all our
+ % other math active characters (just in case), to plain's definitions.
+ \mathactive
+ %
+ \let\b=\ptexb
+ \let\bullet=\ptexbullet
+ \let\c=\ptexc
+ \let\,=\ptexcomma
+ \let\.=\ptexdot
+ \let\dots=\ptexdots
+ \let\equiv=\ptexequiv
+ \let\!=\ptexexclam
+ \let\i=\ptexi
+ \let\indent=\ptexindent
+ \let\noindent=\ptexnoindent
+ \let\{=\ptexlbrace
+ \let\+=\tabalign
+ \let\}=\ptexrbrace
+ \let\/=\ptexslash
+ \let\*=\ptexstar
+ \let\t=\ptext
+ \expandafter \let\csname top\endcsname=\ptextop % outer
+ \let\frenchspacing=\plainfrenchspacing
+ %
+ \def\endldots{\mathinner{\ldots\ldots\ldots\ldots}}%
+ \def\enddots{\relax\ifmmode\endldots\else$\mathsurround=0pt \endldots\,$\fi}%
+ \def\@{@}%
+}
+% There is no need to define \Etex.
+
+% Define @lisp ... @end lisp.
+% @lisp environment forms a group so it can rebind things,
+% including the definition of @end lisp (which normally is erroneous).
+
+% Amount to narrow the margins by for @lisp.
+\newskip\lispnarrowing \lispnarrowing=0.4in
+
+% This is the definition that ^^M gets inside @lisp, @example, and other
+% such environments. \null is better than a space, since it doesn't
+% have any width.
+\def\lisppar{\null\endgraf}
+
+% This space is always present above and below environments.
+\newskip\envskipamount \envskipamount = 0pt
+
+% Make spacing and below environment symmetrical. We use \parskip here
+% to help in doing that, since in @example-like environments \parskip
+% is reset to zero; thus the \afterenvbreak inserts no space -- but the
+% start of the next paragraph will insert \parskip.
+%
+\def\aboveenvbreak{{%
+ % =10000 instead of <10000 because of a special case in \itemzzz and
+ % \sectionheading, q.v.
+ \ifnum \lastpenalty=10000 \else
+ \advance\envskipamount by \parskip
+ \endgraf
+ \ifdim\lastskip<\envskipamount
+ \removelastskip
+ % it's not a good place to break if the last penalty was \nobreak
+ % or better ...
+ \ifnum\lastpenalty<10000 \penalty-50 \fi
+ \vskip\envskipamount
+ \fi
+ \fi
+}}
+
+\let\afterenvbreak = \aboveenvbreak
+
+% \nonarrowing is a flag. If "set", @lisp etc don't narrow margins; it will
+% also clear it, so that its embedded environments do the narrowing again.
+\let\nonarrowing=\relax
+
+% @cartouche ... @end cartouche: draw rectangle w/rounded corners around
+% environment contents.
+\font\circle=lcircle10
+\newdimen\circthick
+\newdimen\cartouter\newdimen\cartinner
+\newskip\normbskip\newskip\normpskip\newskip\normlskip
+\circthick=\fontdimen8\circle
+%
+\def\ctl{{\circle\char'013\hskip -6pt}}% 6pt from pl file: 1/2charwidth
+\def\ctr{{\hskip 6pt\circle\char'010}}
+\def\cbl{{\circle\char'012\hskip -6pt}}
+\def\cbr{{\hskip 6pt\circle\char'011}}
+\def\carttop{\hbox to \cartouter{\hskip\lskip
+ \ctl\leaders\hrule height\circthick\hfil\ctr
+ \hskip\rskip}}
+\def\cartbot{\hbox to \cartouter{\hskip\lskip
+ \cbl\leaders\hrule height\circthick\hfil\cbr
+ \hskip\rskip}}
+%
+\newskip\lskip\newskip\rskip
+
+\envdef\cartouche{%
+ \ifhmode\par\fi % can't be in the midst of a paragraph.
+ \startsavinginserts
+ \lskip=\leftskip \rskip=\rightskip
+ \leftskip=0pt\rightskip=0pt % we want these *outside*.
+ \cartinner=\hsize \advance\cartinner by-\lskip
+ \advance\cartinner by-\rskip
+ \cartouter=\hsize
+ \advance\cartouter by 18.4pt % allow for 3pt kerns on either
+ % side, and for 6pt waste from
+ % each corner char, and rule thickness
+ \normbskip=\baselineskip \normpskip=\parskip \normlskip=\lineskip
+ % Flag to tell @lisp, etc., not to narrow margin.
+ \let\nonarrowing = t%
+ %
+ % If this cartouche directly follows a sectioning command, we need the
+ % \parskip glue (backspaced over by default) or the cartouche can
+ % collide with the section heading.
+ \ifnum\lastpenalty>10000 \vskip\parskip \penalty\lastpenalty \fi
+ %
+ \vbox\bgroup
+ \baselineskip=0pt\parskip=0pt\lineskip=0pt
+ \carttop
+ \hbox\bgroup
+ \hskip\lskip
+ \vrule\kern3pt
+ \vbox\bgroup
+ \kern3pt
+ \hsize=\cartinner
+ \baselineskip=\normbskip
+ \lineskip=\normlskip
+ \parskip=\normpskip
+ \vskip -\parskip
+ \comment % For explanation, see the end of def\group.
+}
+\def\Ecartouche{%
+ \ifhmode\par\fi
+ \kern3pt
+ \egroup
+ \kern3pt\vrule
+ \hskip\rskip
+ \egroup
+ \cartbot
+ \egroup
+ \checkinserts
+}
+
+
+% This macro is called at the beginning of all the @example variants,
+% inside a group.
+\newdimen\nonfillparindent
+\def\nonfillstart{%
+ \aboveenvbreak
+ \hfuzz = 12pt % Don't be fussy
+ \sepspaces % Make spaces be word-separators rather than space tokens.
+ \let\par = \lisppar % don't ignore blank lines
+ \obeylines % each line of input is a line of output
+ \parskip = 0pt
+ % Turn off paragraph indentation but redefine \indent to emulate
+ % the normal \indent.
+ \nonfillparindent=\parindent
+ \parindent = 0pt
+ \let\indent\nonfillindent
+ %
+ \emergencystretch = 0pt % don't try to avoid overfull boxes
+ \ifx\nonarrowing\relax
+ \advance \leftskip by \lispnarrowing
+ \exdentamount=\lispnarrowing
+ \else
+ \let\nonarrowing = \relax
+ \fi
+ \let\exdent=\nofillexdent
+}
+
+\begingroup
+\obeyspaces
+% We want to swallow spaces (but not other tokens) after the fake
+% @indent in our nonfill-environments, where spaces are normally
+% active and set to @tie, resulting in them not being ignored after
+% @indent.
+\gdef\nonfillindent{\futurelet\temp\nonfillindentcheck}%
+\gdef\nonfillindentcheck{%
+\ifx\temp %
+\expandafter\nonfillindentgobble%
+\else%
+\leavevmode\nonfillindentbox%
+\fi%
+}%
+\endgroup
+\def\nonfillindentgobble#1{\nonfillindent}
+\def\nonfillindentbox{\hbox to \nonfillparindent{\hss}}
+
+% If you want all examples etc. small: @set dispenvsize small.
+% If you want even small examples the full size: @set dispenvsize nosmall.
+% This affects the following displayed environments:
+% @example, @display, @format, @lisp
+%
+\def\smallword{small}
+\def\nosmallword{nosmall}
+\let\SETdispenvsize\relax
+\def\setnormaldispenv{%
+ \ifx\SETdispenvsize\smallword
+ % end paragraph for sake of leading, in case document has no blank
+ % line. This is redundant with what happens in \aboveenvbreak, but
+ % we need to do it before changing the fonts, and it's inconvenient
+ % to change the fonts afterward.
+ \ifnum \lastpenalty=10000 \else \endgraf \fi
+ \smallexamplefonts \rm
+ \fi
+}
+\def\setsmalldispenv{%
+ \ifx\SETdispenvsize\nosmallword
+ \else
+ \ifnum \lastpenalty=10000 \else \endgraf \fi
+ \smallexamplefonts \rm
+ \fi
+}
+
+% We often define two environments, @foo and @smallfoo.
+% Let's do it in one command. #1 is the env name, #2 the definition.
+\def\makedispenvdef#1#2{%
+ \expandafter\envdef\csname#1\endcsname {\setnormaldispenv #2}%
+ \expandafter\envdef\csname small#1\endcsname {\setsmalldispenv #2}%
+ \expandafter\let\csname E#1\endcsname \afterenvbreak
+ \expandafter\let\csname Esmall#1\endcsname \afterenvbreak
+}
+
+% Define two environment synonyms (#1 and #2) for an environment.
+\def\maketwodispenvdef#1#2#3{%
+ \makedispenvdef{#1}{#3}%
+ \makedispenvdef{#2}{#3}%
+}
+%
+% @lisp: indented, narrowed, typewriter font;
+% @example: same as @lisp.
+%
+% @smallexample and @smalllisp: use smaller fonts.
+% Originally contributed by Pavel@xerox.
+%
+\maketwodispenvdef{lisp}{example}{%
+ \nonfillstart
+ \tt\setupmarkupstyle{example}%
+ \let\kbdfont = \kbdexamplefont % Allow @kbd to do something special.
+ \gobble % eat return
+}
+% @display/@smalldisplay: same as @lisp except keep current font.
+%
+\makedispenvdef{display}{%
+ \nonfillstart
+ \gobble
+}
+
+% @format/@smallformat: same as @display except don't narrow margins.
+%
+\makedispenvdef{format}{%
+ \let\nonarrowing = t%
+ \nonfillstart
+ \gobble
+}
+
+% @flushleft: same as @format, but doesn't obey \SETdispenvsize.
+\envdef\flushleft{%
+ \let\nonarrowing = t%
+ \nonfillstart
+ \gobble
+}
+\let\Eflushleft = \afterenvbreak
+
+% @flushright.
+%
+\envdef\flushright{%
+ \let\nonarrowing = t%
+ \nonfillstart
+ \advance\leftskip by 0pt plus 1fill\relax
+ \gobble
+}
+\let\Eflushright = \afterenvbreak
+
+
+% @raggedright does more-or-less normal line breaking but no right
+% justification. From plain.tex.
+\envdef\raggedright{%
+ \rightskip0pt plus2em \spaceskip.3333em \xspaceskip.5em\relax
+}
+\let\Eraggedright\par
+
+\envdef\raggedleft{%
+ \parindent=0pt \leftskip0pt plus2em
+ \spaceskip.3333em \xspaceskip.5em \parfillskip=0pt
+ \hbadness=10000 % Last line will usually be underfull, so turn off
+ % badness reporting.
+}
+\let\Eraggedleft\par
+
+\envdef\raggedcenter{%
+ \parindent=0pt \rightskip0pt plus1em \leftskip0pt plus1em
+ \spaceskip.3333em \xspaceskip.5em \parfillskip=0pt
+ \hbadness=10000 % Last line will usually be underfull, so turn off
+ % badness reporting.
+}
+\let\Eraggedcenter\par
+
+
+% @quotation does normal linebreaking (hence we can't use \nonfillstart)
+% and narrows the margins. We keep \parskip nonzero in general, since
+% we're doing normal filling. So, when using \aboveenvbreak and
+% \afterenvbreak, temporarily make \parskip 0.
+%
+\makedispenvdef{quotation}{\quotationstart}
+%
+\def\quotationstart{%
+ \indentedblockstart % same as \indentedblock, but increase right margin too.
+ \ifx\nonarrowing\relax
+ \advance\rightskip by \lispnarrowing
+ \fi
+ \parsearg\quotationlabel
+}
+
+% We have retained a nonzero parskip for the environment, since we're
+% doing normal filling.
+%
+\def\Equotation{%
+ \par
+ \ifx\quotationauthor\thisisundefined\else
+ % indent a bit.
+ \leftline{\kern 2\leftskip \sl ---\quotationauthor}%
+ \fi
+ {\parskip=0pt \afterenvbreak}%
+}
+\def\Esmallquotation{\Equotation}
+
+% If we're given an argument, typeset it in bold with a colon after.
+\def\quotationlabel#1{%
+ \def\temp{#1}%
+ \ifx\temp\empty \else
+ {\bf #1: }%
+ \fi
+}
+
+% @indentedblock is like @quotation, but indents only on the left and
+% has no optional argument.
+%
+\makedispenvdef{indentedblock}{\indentedblockstart}
+%
+\def\indentedblockstart{%
+ {\parskip=0pt \aboveenvbreak}% because \aboveenvbreak inserts \parskip
+ \parindent=0pt
+ %
+ % @cartouche defines \nonarrowing to inhibit narrowing at next level down.
+ \ifx\nonarrowing\relax
+ \advance\leftskip by \lispnarrowing
+ \exdentamount = \lispnarrowing
+ \else
+ \let\nonarrowing = \relax
+ \fi
+}
+
+% Keep a nonzero parskip for the environment, since we're doing normal filling.
+%
+\def\Eindentedblock{%
+ \par
+ {\parskip=0pt \afterenvbreak}%
+}
+\def\Esmallindentedblock{\Eindentedblock}
+
+
+% LaTeX-like @verbatim...@end verbatim and @verb{<char>...<char>}
+% If we want to allow any <char> as delimiter,
+% we need the curly braces so that makeinfo sees the @verb command, eg:
+% `@verbx...x' would look like the '@verbx' command. --janneke@gnu.org
+%
+% [Knuth]: Donald Ervin Knuth, 1996. The TeXbook.
+%
+% [Knuth] p.344; only we need to do the other characters Texinfo sets
+% active too. Otherwise, they get lost as the first character on a
+% verbatim line.
+\def\dospecials{%
+ \do\ \do\\\do\{\do\}\do\$\do\&%
+ \do\#\do\^\do\^^K\do\_\do\^^A\do\%\do\~%
+ \do\<\do\>\do\|\do\@\do+\do\"%
+ % Don't do the quotes -- if we do, @set txicodequoteundirected and
+ % @set txicodequotebacktick will not have effect on @verb and
+ % @verbatim, and ?` and !` ligatures won't get disabled.
+ %\do\`\do\'%
+}
+%
+% [Knuth] p. 380
+\def\uncatcodespecials{%
+ \def\do##1{\catcode`##1=\other}\dospecials}
+%
+% Setup for the @verb command.
+%
+% Eight spaces for a tab
+\begingroup
+ \catcode`\^^I=\active
+ \gdef\tabeightspaces{\catcode`\^^I=\active\def^^I{\ \ \ \ \ \ \ \ }}
+\endgroup
+%
+\def\setupverb{%
+ \tt % easiest (and conventionally used) font for verbatim
+ \def\par{\leavevmode\endgraf}%
+ \setupmarkupstyle{verb}%
+ \tabeightspaces
+ % Respect line breaks,
+ % print special symbols as themselves, and
+ % make each space count
+ % must do in this order:
+ \obeylines \uncatcodespecials \sepspaces
+}
+
+% Setup for the @verbatim environment
+%
+% Real tab expansion.
+\newdimen\tabw \setbox0=\hbox{\tt\space} \tabw=8\wd0 % tab amount
+%
+% We typeset each line of the verbatim in an \hbox, so we can handle
+% tabs. The \global is in case the verbatim line starts with an accent,
+% or some other command that starts with a begin-group. Otherwise, the
+% entire \verbbox would disappear at the corresponding end-group, before
+% it is typeset. Meanwhile, we can't have nested verbatim commands
+% (can we?), so the \global won't be overwriting itself.
+\newbox\verbbox
+\def\starttabbox{\global\setbox\verbbox=\hbox\bgroup}
+%
+\begingroup
+ \catcode`\^^I=\active
+ \gdef\tabexpand{%
+ \catcode`\^^I=\active
+ \def^^I{\leavevmode\egroup
+ \dimen\verbbox=\wd\verbbox % the width so far, or since the previous tab
+ \divide\dimen\verbbox by\tabw
+ \multiply\dimen\verbbox by\tabw % compute previous multiple of \tabw
+ \advance\dimen\verbbox by\tabw % advance to next multiple of \tabw
+ \wd\verbbox=\dimen\verbbox \box\verbbox \starttabbox
+ }%
+ }
+\endgroup
+
+% start the verbatim environment.
+\def\setupverbatim{%
+ \let\nonarrowing = t%
+ \nonfillstart
+ \tt % easiest (and conventionally used) font for verbatim
+ % The \leavevmode here is for blank lines. Otherwise, we would
+ % never \starttabox and the \egroup would end verbatim mode.
+ \def\par{\leavevmode\egroup\box\verbbox\endgraf}%
+ \tabexpand
+ \setupmarkupstyle{verbatim}%
+ % Respect line breaks,
+ % print special symbols as themselves, and
+ % make each space count.
+ % Must do in this order:
+ \obeylines \uncatcodespecials \sepspaces
+ \everypar{\starttabbox}%
+}
+
+% Do the @verb magic: verbatim text is quoted by unique
+% delimiter characters. Before first delimiter expect a
+% right brace, after last delimiter expect closing brace:
+%
+% \def\doverb'{'<char>#1<char>'}'{#1}
+%
+% [Knuth] p. 382; only eat outer {}
+\begingroup
+ \catcode`[=1\catcode`]=2\catcode`\{=\other\catcode`\}=\other
+ \gdef\doverb{#1[\def\next##1#1}[##1\endgroup]\next]
+\endgroup
+%
+\def\verb{\begingroup\setupverb\doverb}
+%
+%
+% Do the @verbatim magic: define the macro \doverbatim so that
+% the (first) argument ends when '@end verbatim' is reached, ie:
+%
+% \def\doverbatim#1@end verbatim{#1}
+%
+% For Texinfo it's a lot easier than for LaTeX,
+% because texinfo's \verbatim doesn't stop at '\end{verbatim}':
+% we need not redefine '\', '{' and '}'.
+%
+% Inspired by LaTeX's verbatim command set [latex.ltx]
+%
+\begingroup
+ \catcode`\ =\active
+ \obeylines %
+ % ignore everything up to the first ^^M, that's the newline at the end
+ % of the @verbatim input line itself. Otherwise we get an extra blank
+ % line in the output.
+ \xdef\doverbatim#1^^M#2@end verbatim{#2\noexpand\end\gobble verbatim}%
+ % We really want {...\end verbatim} in the body of the macro, but
+ % without the active space; thus we have to use \xdef and \gobble.
+\endgroup
+%
+\envdef\verbatim{%
+ \setupverbatim\doverbatim
+}
+\let\Everbatim = \afterenvbreak
+
+
+% @verbatiminclude FILE - insert text of file in verbatim environment.
+%
+\def\verbatiminclude{\parseargusing\filenamecatcodes\doverbatiminclude}
+%
+\def\doverbatiminclude#1{%
+ {%
+ \makevalueexpandable
+ \setupverbatim
+ \indexnofonts % Allow `@@' and other weird things in file names.
+ \wlog{texinfo.tex: doing @verbatiminclude of #1^^J}%
+ \input #1
+ \afterenvbreak
+ }%
+}
+
+% @copying ... @end copying.
+% Save the text away for @insertcopying later.
+%
+% We save the uninterpreted tokens, rather than creating a box.
+% Saving the text in a box would be much easier, but then all the
+% typesetting commands (@smallbook, font changes, etc.) have to be done
+% beforehand -- and a) we want @copying to be done first in the source
+% file; b) letting users define the frontmatter in as flexible order as
+% possible is very desirable.
+%
+\def\copying{\checkenv{}\begingroup\scanargctxt\docopying}
+\def\docopying#1@end copying{\endgroup\def\copyingtext{#1}}
+%
+\def\insertcopying{%
+ \begingroup
+ \parindent = 0pt % paragraph indentation looks wrong on title page
+ \scanexp\copyingtext
+ \endgroup
+}
+
+
+\message{defuns,}
+% @defun etc.
+
+\newskip\defbodyindent \defbodyindent=.4in
+\newskip\defargsindent \defargsindent=50pt
+\newskip\deflastargmargin \deflastargmargin=18pt
+\newcount\defunpenalty
+
+% Start the processing of @deffn:
+\def\startdefun{%
+ \ifnum\lastpenalty<10000
+ \medbreak
+ \defunpenalty=10003 % Will keep this @deffn together with the
+ % following @def command, see below.
+ \else
+ % If there are two @def commands in a row, we'll have a \nobreak,
+ % which is there to keep the function description together with its
+ % header. But if there's nothing but headers, we need to allow a
+ % break somewhere. Check specifically for penalty 10002, inserted
+ % by \printdefunline, instead of 10000, since the sectioning
+ % commands also insert a nobreak penalty, and we don't want to allow
+ % a break between a section heading and a defun.
+ %
+ % As a further refinement, we avoid "club" headers by signalling
+ % with penalty of 10003 after the very first @deffn in the
+ % sequence (see above), and penalty of 10002 after any following
+ % @def command.
+ \ifnum\lastpenalty=10002 \penalty2000 \else \defunpenalty=10002 \fi
+ %
+ % Similarly, after a section heading, do not allow a break.
+ % But do insert the glue.
+ \medskip % preceded by discardable penalty, so not a breakpoint
+ \fi
+ %
+ \parindent=0in
+ \advance\leftskip by \defbodyindent
+ \exdentamount=\defbodyindent
+}
+
+\def\dodefunx#1{%
+ % First, check whether we are in the right environment:
+ \checkenv#1%
+ %
+ % As above, allow line break if we have multiple x headers in a row.
+ % It's not a great place, though.
+ \ifnum\lastpenalty=10002 \penalty3000 \else \defunpenalty=10002 \fi
+ %
+ % And now, it's time to reuse the body of the original defun:
+ \expandafter\gobbledefun#1%
+}
+\def\gobbledefun#1\startdefun{}
+
+% \printdefunline \deffnheader{text}
+%
+\def\printdefunline#1#2{%
+ \begingroup
+ % call \deffnheader:
+ #1#2 \endheader
+ % common ending:
+ \interlinepenalty = 10000
+ \advance\rightskip by 0pt plus 1fil\relax
+ \endgraf
+ \nobreak\vskip -\parskip
+ \penalty\defunpenalty % signal to \startdefun and \dodefunx
+ % Some of the @defun-type tags do not enable magic parentheses,
+ % rendering the following check redundant. But we don't optimize.
+ \checkparencounts
+ \endgroup
+}
+
+\def\Edefun{\endgraf\medbreak}
+
+% \makedefun{deffn} creates \deffn, \deffnx and \Edeffn;
+% the only thing remaining is to define \deffnheader.
+%
+\def\makedefun#1{%
+ \expandafter\let\csname E#1\endcsname = \Edefun
+ \edef\temp{\noexpand\domakedefun
+ \makecsname{#1}\makecsname{#1x}\makecsname{#1header}}%
+ \temp
+}
+
+% \domakedefun \deffn \deffnx \deffnheader
+%
+% Define \deffn and \deffnx, without parameters.
+% \deffnheader has to be defined explicitly.
+%
+\def\domakedefun#1#2#3{%
+ \envdef#1{%
+ \startdefun
+ \doingtypefnfalse % distinguish typed functions from all else
+ \parseargusing\activeparens{\printdefunline#3}%
+ }%
+ \def#2{\dodefunx#1}%
+ \def#3%
+}
+
+\newif\ifdoingtypefn % doing typed function?
+\newif\ifrettypeownline % typeset return type on its own line?
+
+% @deftypefnnewline on|off says whether the return type of typed functions
+% are printed on their own line. This affects @deftypefn, @deftypefun,
+% @deftypeop, and @deftypemethod.
+%
+\parseargdef\deftypefnnewline{%
+ \def\temp{#1}%
+ \ifx\temp\onword
+ \expandafter\let\csname SETtxideftypefnnl\endcsname
+ = \empty
+ \else\ifx\temp\offword
+ \expandafter\let\csname SETtxideftypefnnl\endcsname
+ = \relax
+ \else
+ \errhelp = \EMsimple
+ \errmessage{Unknown @txideftypefnnl value `\temp',
+ must be on|off}%
+ \fi\fi
+}
+
+% Untyped functions:
+
+% @deffn category name args
+\makedefun{deffn}{\deffngeneral{}}
+
+% @deffn category class name args
+\makedefun{defop}#1 {\defopon{#1\ \putwordon}}
+
+% \defopon {category on}class name args
+\def\defopon#1#2 {\deffngeneral{\putwordon\ \code{#2}}{#1\ \code{#2}} }
+
+% \deffngeneral {subind}category name args
+%
+\def\deffngeneral#1#2 #3 #4\endheader{%
+ % Remember that \dosubind{fn}{foo}{} is equivalent to \doind{fn}{foo}.
+ \dosubind{fn}{\code{#3}}{#1}%
+ \defname{#2}{}{#3}\magicamp\defunargs{#4\unskip}%
+}
+
+% Typed functions:
+
+% @deftypefn category type name args
+\makedefun{deftypefn}{\deftypefngeneral{}}
+
+% @deftypeop category class type name args
+\makedefun{deftypeop}#1 {\deftypeopon{#1\ \putwordon}}
+
+% \deftypeopon {category on}class type name args
+\def\deftypeopon#1#2 {\deftypefngeneral{\putwordon\ \code{#2}}{#1\ \code{#2}} }
+
+% \deftypefngeneral {subind}category type name args
+%
+\def\deftypefngeneral#1#2 #3 #4 #5\endheader{%
+ \dosubind{fn}{\code{#4}}{#1}%
+ \doingtypefntrue
+ \defname{#2}{#3}{#4}\defunargs{#5\unskip}%
+}
+
+% Typed variables:
+
+% @deftypevr category type var args
+\makedefun{deftypevr}{\deftypecvgeneral{}}
+
+% @deftypecv category class type var args
+\makedefun{deftypecv}#1 {\deftypecvof{#1\ \putwordof}}
+
+% \deftypecvof {category of}class type var args
+\def\deftypecvof#1#2 {\deftypecvgeneral{\putwordof\ \code{#2}}{#1\ \code{#2}} }
+
+% \deftypecvgeneral {subind}category type var args
+%
+\def\deftypecvgeneral#1#2 #3 #4 #5\endheader{%
+ \dosubind{vr}{\code{#4}}{#1}%
+ \defname{#2}{#3}{#4}\defunargs{#5\unskip}%
+}
+
+% Untyped variables:
+
+% @defvr category var args
+\makedefun{defvr}#1 {\deftypevrheader{#1} {} }
+
+% @defcv category class var args
+\makedefun{defcv}#1 {\defcvof{#1\ \putwordof}}
+
+% \defcvof {category of}class var args
+\def\defcvof#1#2 {\deftypecvof{#1}#2 {} }
+
+% Types:
+
+% @deftp category name args
+\makedefun{deftp}#1 #2 #3\endheader{%
+ \doind{tp}{\code{#2}}%
+ \defname{#1}{}{#2}\defunargs{#3\unskip}%
+}
+
+% Remaining @defun-like shortcuts:
+\makedefun{defun}{\deffnheader{\putwordDeffunc} }
+\makedefun{defmac}{\deffnheader{\putwordDefmac} }
+\makedefun{defspec}{\deffnheader{\putwordDefspec} }
+\makedefun{deftypefun}{\deftypefnheader{\putwordDeffunc} }
+\makedefun{defvar}{\defvrheader{\putwordDefvar} }
+\makedefun{defopt}{\defvrheader{\putwordDefopt} }
+\makedefun{deftypevar}{\deftypevrheader{\putwordDefvar} }
+\makedefun{defmethod}{\defopon\putwordMethodon}
+\makedefun{deftypemethod}{\deftypeopon\putwordMethodon}
+\makedefun{defivar}{\defcvof\putwordInstanceVariableof}
+\makedefun{deftypeivar}{\deftypecvof\putwordInstanceVariableof}
+
+% \defname, which formats the name of the @def (not the args).
+% #1 is the category, such as "Function".
+% #2 is the return type, if any.
+% #3 is the function name.
+%
+% We are followed by (but not passed) the arguments, if any.
+%
+\def\defname#1#2#3{%
+ \par
+ % Get the values of \leftskip and \rightskip as they were outside the @def...
+ \advance\leftskip by -\defbodyindent
+ %
+ % Determine if we are typesetting the return type of a typed function
+ % on a line by itself.
+ \rettypeownlinefalse
+ \ifdoingtypefn % doing a typed function specifically?
+ % then check user option for putting return type on its own line:
+ \expandafter\ifx\csname SETtxideftypefnnl\endcsname\relax \else
+ \rettypeownlinetrue
+ \fi
+ \fi
+ %
+ % How we'll format the category name. Putting it in brackets helps
+ % distinguish it from the body text that may end up on the next line
+ % just below it.
+ \def\temp{#1}%
+ \setbox0=\hbox{\kern\deflastargmargin \ifx\temp\empty\else [\rm\temp]\fi}
+ %
+ % Figure out line sizes for the paragraph shape. We'll always have at
+ % least two.
+ \tempnum = 2
+ %
+ % The first line needs space for \box0; but if \rightskip is nonzero,
+ % we need only space for the part of \box0 which exceeds it:
+ \dimen0=\hsize \advance\dimen0 by -\wd0 \advance\dimen0 by \rightskip
+ %
+ % If doing a return type on its own line, we'll have another line.
+ \ifrettypeownline
+ \advance\tempnum by 1
+ \def\maybeshapeline{0in \hsize}%
+ \else
+ \def\maybeshapeline{}%
+ \fi
+ %
+ % The continuations:
+ \dimen2=\hsize \advance\dimen2 by -\defargsindent
+ %
+ % The final paragraph shape:
+ \parshape \tempnum 0in \dimen0 \maybeshapeline \defargsindent \dimen2
+ %
+ % Put the category name at the right margin.
+ \noindent
+ \hbox to 0pt{%
+ \hfil\box0 \kern-\hsize
+ % \hsize has to be shortened this way:
+ \kern\leftskip
+ % Intentionally do not respect \rightskip, since we need the space.
+ }%
+ %
+ % Allow all lines to be underfull without complaint:
+ \tolerance=10000 \hbadness=10000
+ \exdentamount=\defbodyindent
+ {%
+ % defun fonts. We use typewriter by default (used to be bold) because:
+ % . we're printing identifiers, they should be in tt in principle.
+ % . in languages with many accents, such as Czech or French, it's
+ % common to leave accents off identifiers. The result looks ok in
+ % tt, but exceedingly strange in rm.
+ % . we don't want -- and --- to be treated as ligatures.
+ % . this still does not fix the ?` and !` ligatures, but so far no
+ % one has made identifiers using them :).
+ \df \tt
+ \def\temp{#2}% text of the return type
+ \ifx\temp\empty\else
+ \tclose{\temp}% typeset the return type
+ \ifrettypeownline
+ % put return type on its own line; prohibit line break following:
+ \hfil\vadjust{\nobreak}\break
+ \else
+ \space % type on same line, so just followed by a space
+ \fi
+ \fi % no return type
+ #3% output function name
+ }%
+ {\rm\enskip}% hskip 0.5 em of \tenrm
+ %
+ \boldbrax
+ % arguments will be output next, if any.
+}
+
+% Print arguments in slanted roman (not ttsl), inconsistently with using
+% tt for the name. This is because literal text is sometimes needed in
+% the argument list (groff manual), and ttsl and tt are not very
+% distinguishable. Prevent hyphenation at `-' chars.
+%
+\def\defunargs#1{%
+ % use sl by default (not ttsl),
+ % tt for the names.
+ \df \sl \hyphenchar\font=0
+ %
+ % On the other hand, if an argument has two dashes (for instance), we
+ % want a way to get ttsl. We used to recommend @var for that, so
+ % leave the code in, but it's strange for @var to lead to typewriter.
+ % Nowadays we recommend @code, since the difference between a ttsl hyphen
+ % and a tt hyphen is pretty tiny. @code also disables ?` !`.
+ \def\var##1{{\setupmarkupstyle{var}\ttslanted{##1}}}%
+ #1%
+ \sl\hyphenchar\font=45
+}
+
+% We want ()&[] to print specially on the defun line.
+%
+\def\activeparens{%
+ \catcode`\(=\active \catcode`\)=\active
+ \catcode`\[=\active \catcode`\]=\active
+ \catcode`\&=\active
+}
+
+% Make control sequences which act like normal parenthesis chars.
+\let\lparen = ( \let\rparen = )
+
+% Be sure that we always have a definition for `(', etc. For example,
+% if the fn name has parens in it, \boldbrax will not be in effect yet,
+% so TeX would otherwise complain about undefined control sequence.
+{
+ \activeparens
+ \global\let(=\lparen \global\let)=\rparen
+ \global\let[=\lbrack \global\let]=\rbrack
+ \global\let& = \&
+
+ \gdef\boldbrax{\let(=\opnr\let)=\clnr\let[=\lbrb\let]=\rbrb}
+ \gdef\magicamp{\let&=\amprm}
+}
+
+\newcount\parencount
+
+% If we encounter &foo, then turn on ()-hacking afterwards
+\newif\ifampseen
+\def\amprm#1 {\ampseentrue{\bf\&#1 }}
+
+\def\parenfont{%
+ \ifampseen
+ % At the first level, print parens in roman,
+ % otherwise use the default font.
+ \ifnum \parencount=1 \rm \fi
+ \else
+ % The \sf parens (in \boldbrax) actually are a little bolder than
+ % the contained text. This is especially needed for [ and ] .
+ \sf
+ \fi
+}
+\def\infirstlevel#1{%
+ \ifampseen
+ \ifnum\parencount=1
+ #1%
+ \fi
+ \fi
+}
+\def\bfafterword#1 {#1 \bf}
+
+\def\opnr{%
+ \global\advance\parencount by 1
+ {\parenfont(}%
+ \infirstlevel \bfafterword
+}
+\def\clnr{%
+ {\parenfont)}%
+ \infirstlevel \sl
+ \global\advance\parencount by -1
+}
+
+\newcount\brackcount
+\def\lbrb{%
+ \global\advance\brackcount by 1
+ {\bf[}%
+}
+\def\rbrb{%
+ {\bf]}%
+ \global\advance\brackcount by -1
+}
+
+\def\checkparencounts{%
+ \ifnum\parencount=0 \else \badparencount \fi
+ \ifnum\brackcount=0 \else \badbrackcount \fi
+}
+% these should not use \errmessage; the glibc manual, at least, actually
+% has such constructs (when documenting function pointers).
+\def\badparencount{%
+ \message{Warning: unbalanced parentheses in @def...}%
+ \global\parencount=0
+}
+\def\badbrackcount{%
+ \message{Warning: unbalanced square brackets in @def...}%
+ \global\brackcount=0
+}
+
+
+\message{macros,}
+% @macro.
+
+% To do this right we need a feature of e-TeX, \scantokens,
+% which we arrange to emulate with a temporary file in ordinary TeX.
+\ifx\eTeXversion\thisisundefined
+ \newwrite\macscribble
+ \def\scantokens#1{%
+ \toks0={#1}%
+ \immediate\openout\macscribble=\jobname.tmp
+ \immediate\write\macscribble{\the\toks0}%
+ \immediate\closeout\macscribble
+ \input \jobname.tmp
+ }
+\fi
+
+\def\scanmacro#1{\begingroup
+ \newlinechar`\^^M
+ \let\xeatspaces\eatspaces
+ %
+ % Undo catcode changes of \startcontents and \doprintindex
+ % When called from @insertcopying or (short)caption, we need active
+ % backslash to get it printed correctly. Previously, we had
+ % \catcode`\\=\other instead. We'll see whether a problem appears
+ % with macro expansion. --kasal, 19aug04
+ \catcode`\@=0 \catcode`\\=\active \escapechar=`\@
+ %
+ % ... and for \example:
+ \spaceisspace
+ %
+ % The \empty here causes a following catcode 5 newline to be eaten as
+ % part of reading whitespace after a control sequence. It does not
+ % eat a catcode 13 newline. There's no good way to handle the two
+ % cases (untried: maybe e-TeX's \everyeof could help, though plain TeX
+ % would then have different behavior). See the Macro Details node in
+ % the manual for the workaround we recommend for macros and
+ % line-oriented commands.
+ %
+ \scantokens{#1\empty}%
+\endgroup}
+
+\def\scanexp#1{%
+ \edef\temp{\noexpand\scanmacro{#1}}%
+ \temp
+}
+
+\newcount\paramno % Count of parameters
+\newtoks\macname % Macro name
+\newif\ifrecursive % Is it recursive?
+
+% List of all defined macros in the form
+% \definedummyword\macro1\definedummyword\macro2...
+% Currently is also contains all @aliases; the list can be split
+% if there is a need.
+\def\macrolist{}
+
+% Add the macro to \macrolist
+\def\addtomacrolist#1{\expandafter \addtomacrolistxxx \csname#1\endcsname}
+\def\addtomacrolistxxx#1{%
+ \toks0 = \expandafter{\macrolist\definedummyword#1}%
+ \xdef\macrolist{\the\toks0}%
+}
+
+% Utility routines.
+% This does \let #1 = #2, with \csnames; that is,
+% \let \csname#1\endcsname = \csname#2\endcsname
+% (except of course we have to play expansion games).
+%
+\def\cslet#1#2{%
+ \expandafter\let
+ \csname#1\expandafter\endcsname
+ \csname#2\endcsname
+}
+
+% Trim leading and trailing spaces off a string.
+% Concepts from aro-bend problem 15 (see CTAN).
+{\catcode`\@=11
+\gdef\eatspaces #1{\expandafter\trim@\expandafter{#1 }}
+\gdef\trim@ #1{\trim@@ @#1 @ #1 @ @@}
+\gdef\trim@@ #1@ #2@ #3@@{\trim@@@\empty #2 @}
+\def\unbrace#1{#1}
+\unbrace{\gdef\trim@@@ #1 } #2@{#1}
+}
+
+% Trim a single trailing ^^M off a string.
+{\catcode`\^^M=\other \catcode`\Q=3%
+\gdef\eatcr #1{\eatcra #1Q^^MQ}%
+\gdef\eatcra#1^^MQ{\eatcrb#1Q}%
+\gdef\eatcrb#1Q#2Q{#1}%
+}
+
+% Macro bodies are absorbed as an argument in a context where
+% all characters are catcode 10, 11 or 12, except \ which is active
+% (as in normal texinfo). It is necessary to change the definition of \
+% to recognize macro arguments; this is the job of \mbodybackslash.
+%
+% Non-ASCII encodings make 8-bit characters active, so un-activate
+% them to avoid their expansion. Must do this non-globally, to
+% confine the change to the current group.
+%
+% It's necessary to have hard CRs when the macro is executed. This is
+% done by making ^^M (\endlinechar) catcode 12 when reading the macro
+% body, and then making it the \newlinechar in \scanmacro.
+%
+\def\scanctxt{% used as subroutine
+ \catcode`\"=\other
+ \catcode`\+=\other
+ \catcode`\<=\other
+ \catcode`\>=\other
+ \catcode`\@=\other
+ \catcode`\^=\other
+ \catcode`\_=\other
+ \catcode`\|=\other
+ \catcode`\~=\other
+ \ifx\declaredencoding\ascii \else \setnonasciicharscatcodenonglobal\other \fi
+}
+
+\def\scanargctxt{% used for copying and captions, not macros.
+ \scanctxt
+ \catcode`\\=\other
+ \catcode`\^^M=\other
+}
+
+\def\macrobodyctxt{% used for @macro definitions
+ \scanctxt
+ \catcode`\{=\other
+ \catcode`\}=\other
+ \catcode`\^^M=\other
+ \usembodybackslash
+}
+
+\def\macroargctxt{% used when scanning invocations
+ \scanctxt
+ \catcode`\\=0
+}
+% why catcode 0 for \ in the above? To recognize \\ \{ \} as "escapes"
+% for the single characters \ { }. Thus, we end up with the "commands"
+% that would be written @\ @{ @} in a Texinfo document.
+%
+% We already have @{ and @}. For @\, we define it here, and only for
+% this purpose, to produce a typewriter backslash (so, the @\ that we
+% define for @math can't be used with @macro calls):
+%
+\def\\{\normalbackslash}%
+%
+% We would like to do this for \, too, since that is what makeinfo does.
+% But it is not possible, because Texinfo already has a command @, for a
+% cedilla accent. Documents must use @comma{} instead.
+%
+% \anythingelse will almost certainly be an error of some kind.
+
+
+% \mbodybackslash is the definition of \ in @macro bodies.
+% It maps \foo\ => \csname macarg.foo\endcsname => #N
+% where N is the macro parameter number.
+% We define \csname macarg.\endcsname to be \realbackslash, so
+% \\ in macro replacement text gets you a backslash.
+%
+{\catcode`@=0 @catcode`@\=@active
+ @gdef@usembodybackslash{@let\=@mbodybackslash}
+ @gdef@mbodybackslash#1\{@csname macarg.#1@endcsname}
+}
+\expandafter\def\csname macarg.\endcsname{\realbackslash}
+
+\def\margbackslash#1{\char`\#1 }
+
+\def\macro{\recursivefalse\parsearg\macroxxx}
+\def\rmacro{\recursivetrue\parsearg\macroxxx}
+
+\def\macroxxx#1{%
+ \getargs{#1}% now \macname is the macname and \argl the arglist
+ \ifx\argl\empty % no arguments
+ \paramno=0\relax
+ \else
+ \expandafter\parsemargdef \argl;%
+ \if\paramno>256\relax
+ \ifx\eTeXversion\thisisundefined
+ \errhelp = \EMsimple
+ \errmessage{You need eTeX to compile a file with macros with more than 256 arguments}
+ \fi
+ \fi
+ \fi
+ \if1\csname ismacro.\the\macname\endcsname
+ \message{Warning: redefining \the\macname}%
+ \else
+ \expandafter\ifx\csname \the\macname\endcsname \relax
+ \else \errmessage{Macro name \the\macname\space already defined}\fi
+ \global\cslet{macsave.\the\macname}{\the\macname}%
+ \global\expandafter\let\csname ismacro.\the\macname\endcsname=1%
+ \addtomacrolist{\the\macname}%
+ \fi
+ \begingroup \macrobodyctxt
+ \ifrecursive \expandafter\parsermacbody
+ \else \expandafter\parsemacbody
+ \fi}
+
+\parseargdef\unmacro{%
+ \if1\csname ismacro.#1\endcsname
+ \global\cslet{#1}{macsave.#1}%
+ \global\expandafter\let \csname ismacro.#1\endcsname=0%
+ % Remove the macro name from \macrolist:
+ \begingroup
+ \expandafter\let\csname#1\endcsname \relax
+ \let\definedummyword\unmacrodo
+ \xdef\macrolist{\macrolist}%
+ \endgroup
+ \else
+ \errmessage{Macro #1 not defined}%
+ \fi
+}
+
+% Called by \do from \dounmacro on each macro. The idea is to omit any
+% macro definitions that have been changed to \relax.
+%
+\def\unmacrodo#1{%
+ \ifx #1\relax
+ % remove this
+ \else
+ \noexpand\definedummyword \noexpand#1%
+ \fi
+}
+
+% This makes use of the obscure feature that if the last token of a
+% <parameter list> is #, then the preceding argument is delimited by
+% an opening brace, and that opening brace is not consumed.
+\def\getargs#1{\getargsxxx#1{}}
+\def\getargsxxx#1#{\getmacname #1 \relax\getmacargs}
+\def\getmacname#1 #2\relax{\macname={#1}}
+\def\getmacargs#1{\def\argl{#1}}
+
+% For macro processing make @ a letter so that we can make Texinfo private macro names.
+\edef\texiatcatcode{\the\catcode`\@}
+\catcode `@=11\relax
+
+% Parse the optional {params} list. Set up \paramno and \paramlist
+% so \defmacro knows what to do. Define \macarg.BLAH for each BLAH
+% in the params list to some hook where the argument si to be expanded. If
+% there are less than 10 arguments that hook is to be replaced by ##N where N
+% is the position in that list, that is to say the macro arguments are to be
+% defined `a la TeX in the macro body.
+%
+% That gets used by \mbodybackslash (above).
+%
+% We need to get `macro parameter char #' into several definitions.
+% The technique used is stolen from LaTeX: let \hash be something
+% unexpandable, insert that wherever you need a #, and then redefine
+% it to # just before using the token list produced.
+%
+% The same technique is used to protect \eatspaces till just before
+% the macro is used.
+%
+% If there are 10 or more arguments, a different technique is used, where the
+% hook remains in the body, and when macro is to be expanded the body is
+% processed again to replace the arguments.
+%
+% In that case, the hook is \the\toks N-1, and we simply set \toks N-1 to the
+% argument N value and then \edef the body (nothing else will expand because of
+% the catcode regime underwhich the body was input).
+%
+% If you compile with TeX (not eTeX), and you have macros with 10 or more
+% arguments, you need that no macro has more than 256 arguments, otherwise an
+% error is produced.
+\def\parsemargdef#1;{%
+ \paramno=0\def\paramlist{}%
+ \let\hash\relax
+ \let\xeatspaces\relax
+ \parsemargdefxxx#1,;,%
+ % In case that there are 10 or more arguments we parse again the arguments
+ % list to set new definitions for the \macarg.BLAH macros corresponding to
+ % each BLAH argument. It was anyhow needed to parse already once this list
+ % in order to count the arguments, and as macros with at most 9 arguments
+ % are by far more frequent than macro with 10 or more arguments, defining
+ % twice the \macarg.BLAH macros does not cost too much processing power.
+ \ifnum\paramno<10\relax\else
+ \paramno0\relax
+ \parsemmanyargdef@@#1,;,% 10 or more arguments
+ \fi
+}
+\def\parsemargdefxxx#1,{%
+ \if#1;\let\next=\relax
+ \else \let\next=\parsemargdefxxx
+ \advance\paramno by 1
+ \expandafter\edef\csname macarg.\eatspaces{#1}\endcsname
+ {\xeatspaces{\hash\the\paramno}}%
+ \edef\paramlist{\paramlist\hash\the\paramno,}%
+ \fi\next}
+
+\def\parsemmanyargdef@@#1,{%
+ \if#1;\let\next=\relax
+ \else
+ \let\next=\parsemmanyargdef@@
+ \edef\tempb{\eatspaces{#1}}%
+ \expandafter\def\expandafter\tempa
+ \expandafter{\csname macarg.\tempb\endcsname}%
+ % Note that we need some extra \noexpand\noexpand, this is because we
+ % don't want \the to be expanded in the \parsermacbody as it uses an
+ % \xdef .
+ \expandafter\edef\tempa
+ {\noexpand\noexpand\noexpand\the\toks\the\paramno}%
+ \advance\paramno by 1\relax
+ \fi\next}
+
+% These two commands read recursive and nonrecursive macro bodies.
+% (They're different since rec and nonrec macros end differently.)
+%
+
+\catcode `\@\texiatcatcode
+\long\def\parsemacbody#1@end macro%
+{\xdef\temp{\eatcr{#1}}\endgroup\defmacro}%
+\long\def\parsermacbody#1@end rmacro%
+{\xdef\temp{\eatcr{#1}}\endgroup\defmacro}%
+\catcode `\@=11\relax
+
+\let\endargs@\relax
+\let\nil@\relax
+\def\nilm@{\nil@}%
+\long\def\nillm@{\nil@}%
+
+% This macro is expanded during the Texinfo macro expansion, not during its
+% definition. It gets all the arguments values and assigns them to macros
+% macarg.ARGNAME
+%
+% #1 is the macro name
+% #2 is the list of argument names
+% #3 is the list of argument values
+\def\getargvals@#1#2#3{%
+ \def\macargdeflist@{}%
+ \def\saveparamlist@{#2}% Need to keep a copy for parameter expansion.
+ \def\paramlist{#2,\nil@}%
+ \def\macroname{#1}%
+ \begingroup
+ \macroargctxt
+ \def\argvaluelist{#3,\nil@}%
+ \def\@tempa{#3}%
+ \ifx\@tempa\empty
+ \setemptyargvalues@
+ \else
+ \getargvals@@
+ \fi
+}
+
+%
+\def\getargvals@@{%
+ \ifx\paramlist\nilm@
+ % Some sanity check needed here that \argvaluelist is also empty.
+ \ifx\argvaluelist\nillm@
+ \else
+ \errhelp = \EMsimple
+ \errmessage{Too many arguments in macro `\macroname'!}%
+ \fi
+ \let\next\macargexpandinbody@
+ \else
+ \ifx\argvaluelist\nillm@
+ % No more arguments values passed to macro. Set remaining named-arg
+ % macros to empty.
+ \let\next\setemptyargvalues@
+ \else
+ % pop current arg name into \@tempb
+ \def\@tempa##1{\pop@{\@tempb}{\paramlist}##1\endargs@}%
+ \expandafter\@tempa\expandafter{\paramlist}%
+ % pop current argument value into \@tempc
+ \def\@tempa##1{\longpop@{\@tempc}{\argvaluelist}##1\endargs@}%
+ \expandafter\@tempa\expandafter{\argvaluelist}%
+ % Here \@tempb is the current arg name and \@tempc is the current arg value.
+ % First place the new argument macro definition into \@tempd
+ \expandafter\macname\expandafter{\@tempc}%
+ \expandafter\let\csname macarg.\@tempb\endcsname\relax
+ \expandafter\def\expandafter\@tempe\expandafter{%
+ \csname macarg.\@tempb\endcsname}%
+ \edef\@tempd{\long\def\@tempe{\the\macname}}%
+ \push@\@tempd\macargdeflist@
+ \let\next\getargvals@@
+ \fi
+ \fi
+ \next
+}
+
+\def\push@#1#2{%
+ \expandafter\expandafter\expandafter\def
+ \expandafter\expandafter\expandafter#2%
+ \expandafter\expandafter\expandafter{%
+ \expandafter#1#2}%
+}
+
+% Replace arguments by their values in the macro body, and place the result
+% in macro \@tempa
+\def\macvalstoargs@{%
+ % To do this we use the property that token registers that are \the'ed
+ % within an \edef expand only once. So we are going to place all argument
+ % values into respective token registers.
+ %
+ % First we save the token context, and initialize argument numbering.
+ \begingroup
+ \paramno0\relax
+ % Then, for each argument number #N, we place the corresponding argument
+ % value into a new token list register \toks#N
+ \expandafter\putargsintokens@\saveparamlist@,;,%
+ % Then, we expand the body so that argument are replaced by their
+ % values. The trick for values not to be expanded themselves is that they
+ % are within tokens and that tokens expand only once in an \edef .
+ \edef\@tempc{\csname mac.\macroname .body\endcsname}%
+ % Now we restore the token stack pointer to free the token list registers
+ % which we have used, but we make sure that expanded body is saved after
+ % group.
+ \expandafter
+ \endgroup
+ \expandafter\def\expandafter\@tempa\expandafter{\@tempc}%
+ }
+
+\def\macargexpandinbody@{%
+ %% Define the named-macro outside of this group and then close this group.
+ \expandafter
+ \endgroup
+ \macargdeflist@
+ % First the replace in body the macro arguments by their values, the result
+ % is in \@tempa .
+ \macvalstoargs@
+ % Then we point at the \norecurse or \gobble (for recursive) macro value
+ % with \@tempb .
+ \expandafter\let\expandafter\@tempb\csname mac.\macroname .recurse\endcsname
+ % Depending on whether it is recursive or not, we need some tailing
+ % \egroup .
+ \ifx\@tempb\gobble
+ \let\@tempc\relax
+ \else
+ \let\@tempc\egroup
+ \fi
+ % And now we do the real job:
+ \edef\@tempd{\noexpand\@tempb{\macroname}\noexpand\scanmacro{\@tempa}\@tempc}%
+ \@tempd
+}
+
+\def\putargsintokens@#1,{%
+ \if#1;\let\next\relax
+ \else
+ \let\next\putargsintokens@
+ % First we allocate the new token list register, and give it a temporary
+ % alias \@tempb .
+ \toksdef\@tempb\the\paramno
+ % Then we place the argument value into that token list register.
+ \expandafter\let\expandafter\@tempa\csname macarg.#1\endcsname
+ \expandafter\@tempb\expandafter{\@tempa}%
+ \advance\paramno by 1\relax
+ \fi
+ \next
+}
+
+% Save the token stack pointer into macro #1
+\def\texisavetoksstackpoint#1{\edef#1{\the\@cclvi}}
+% Restore the token stack pointer from number in macro #1
+\def\texirestoretoksstackpoint#1{\expandafter\mathchardef\expandafter\@cclvi#1\relax}
+% newtoks that can be used non \outer .
+\def\texinonouternewtoks{\alloc@ 5\toks \toksdef \@cclvi}
+
+% Tailing missing arguments are set to empty
+\def\setemptyargvalues@{%
+ \ifx\paramlist\nilm@
+ \let\next\macargexpandinbody@
+ \else
+ \expandafter\setemptyargvaluesparser@\paramlist\endargs@
+ \let\next\setemptyargvalues@
+ \fi
+ \next
+}
+
+\def\setemptyargvaluesparser@#1,#2\endargs@{%
+ \expandafter\def\expandafter\@tempa\expandafter{%
+ \expandafter\def\csname macarg.#1\endcsname{}}%
+ \push@\@tempa\macargdeflist@
+ \def\paramlist{#2}%
+}
+
+% #1 is the element target macro
+% #2 is the list macro
+% #3,#4\endargs@ is the list value
+\def\pop@#1#2#3,#4\endargs@{%
+ \def#1{#3}%
+ \def#2{#4}%
+}
+\long\def\longpop@#1#2#3,#4\endargs@{%
+ \long\def#1{#3}%
+ \long\def#2{#4}%
+}
+
+% This defines a Texinfo @macro. There are eight cases: recursive and
+% nonrecursive macros of zero, one, up to nine, and many arguments.
+% Much magic with \expandafter here.
+% \xdef is used so that macro definitions will survive the file
+% they're defined in; @include reads the file inside a group.
+%
+\def\defmacro{%
+ \let\hash=##% convert placeholders to macro parameter chars
+ \ifrecursive
+ \ifcase\paramno
+ % 0
+ \expandafter\xdef\csname\the\macname\endcsname{%
+ \noexpand\scanmacro{\temp}}%
+ \or % 1
+ \expandafter\xdef\csname\the\macname\endcsname{%
+ \bgroup\noexpand\macroargctxt
+ \noexpand\braceorline
+ \expandafter\noexpand\csname\the\macname xxx\endcsname}%
+ \expandafter\xdef\csname\the\macname xxx\endcsname##1{%
+ \egroup\noexpand\scanmacro{\temp}}%
+ \else
+ \ifnum\paramno<10\relax % at most 9
+ \expandafter\xdef\csname\the\macname\endcsname{%
+ \bgroup\noexpand\macroargctxt
+ \noexpand\csname\the\macname xx\endcsname}%
+ \expandafter\xdef\csname\the\macname xx\endcsname##1{%
+ \expandafter\noexpand\csname\the\macname xxx\endcsname ##1,}%
+ \expandafter\expandafter
+ \expandafter\xdef
+ \expandafter\expandafter
+ \csname\the\macname xxx\endcsname
+ \paramlist{\egroup\noexpand\scanmacro{\temp}}%
+ \else % 10 or more
+ \expandafter\xdef\csname\the\macname\endcsname{%
+ \noexpand\getargvals@{\the\macname}{\argl}%
+ }%
+ \global\expandafter\let\csname mac.\the\macname .body\endcsname\temp
+ \global\expandafter\let\csname mac.\the\macname .recurse\endcsname\gobble
+ \fi
+ \fi
+ \else
+ \ifcase\paramno
+ % 0
+ \expandafter\xdef\csname\the\macname\endcsname{%
+ \noexpand\norecurse{\the\macname}%
+ \noexpand\scanmacro{\temp}\egroup}%
+ \or % 1
+ \expandafter\xdef\csname\the\macname\endcsname{%
+ \bgroup\noexpand\macroargctxt
+ \noexpand\braceorline
+ \expandafter\noexpand\csname\the\macname xxx\endcsname}%
+ \expandafter\xdef\csname\the\macname xxx\endcsname##1{%
+ \egroup
+ \noexpand\norecurse{\the\macname}%
+ \noexpand\scanmacro{\temp}\egroup}%
+ \else % at most 9
+ \ifnum\paramno<10\relax
+ \expandafter\xdef\csname\the\macname\endcsname{%
+ \bgroup\noexpand\macroargctxt
+ \expandafter\noexpand\csname\the\macname xx\endcsname}%
+ \expandafter\xdef\csname\the\macname xx\endcsname##1{%
+ \expandafter\noexpand\csname\the\macname xxx\endcsname ##1,}%
+ \expandafter\expandafter
+ \expandafter\xdef
+ \expandafter\expandafter
+ \csname\the\macname xxx\endcsname
+ \paramlist{%
+ \egroup
+ \noexpand\norecurse{\the\macname}%
+ \noexpand\scanmacro{\temp}\egroup}%
+ \else % 10 or more:
+ \expandafter\xdef\csname\the\macname\endcsname{%
+ \noexpand\getargvals@{\the\macname}{\argl}%
+ }%
+ \global\expandafter\let\csname mac.\the\macname .body\endcsname\temp
+ \global\expandafter\let\csname mac.\the\macname .recurse\endcsname\norecurse
+ \fi
+ \fi
+ \fi}
+
+\catcode `\@\texiatcatcode\relax
+
+\def\norecurse#1{\bgroup\cslet{#1}{macsave.#1}}
+
+% \braceorline decides whether the next nonwhitespace character is a
+% {. If so it reads up to the closing }, if not, it reads the whole
+% line. Whatever was read is then fed to the next control sequence
+% as an argument (by \parsebrace or \parsearg).
+%
+\def\braceorline#1{\let\macnamexxx=#1\futurelet\nchar\braceorlinexxx}
+\def\braceorlinexxx{%
+ \ifx\nchar\bgroup\else
+ \expandafter\parsearg
+ \fi \macnamexxx}
+
+
+% @alias.
+% We need some trickery to remove the optional spaces around the equal
+% sign. Make them active and then expand them all to nothing.
+%
+\def\alias{\parseargusing\obeyspaces\aliasxxx}
+\def\aliasxxx #1{\aliasyyy#1\relax}
+\def\aliasyyy #1=#2\relax{%
+ {%
+ \expandafter\let\obeyedspace=\empty
+ \addtomacrolist{#1}%
+ \xdef\next{\global\let\makecsname{#1}=\makecsname{#2}}%
+ }%
+ \next
+}
+
+
+\message{cross references,}
+
+\newwrite\auxfile
+\newif\ifhavexrefs % True if xref values are known.
+\newif\ifwarnedxrefs % True if we warned once that they aren't known.
+
+% @inforef is relatively simple.
+\def\inforef #1{\inforefzzz #1,,,,**}
+\def\inforefzzz #1,#2,#3,#4**{%
+ \putwordSee{} \putwordInfo{} \putwordfile{} \file{\ignorespaces #3{}},
+ node \samp{\ignorespaces#1{}}}
+
+% @node's only job in TeX is to define \lastnode, which is used in
+% cross-references. The @node line might or might not have commas, and
+% might or might not have spaces before the first comma, like:
+% @node foo , bar , ...
+% We don't want such trailing spaces in the node name.
+%
+\parseargdef\node{\checkenv{}\donode #1 ,\finishnodeparse}
+%
+% also remove a trailing comma, in case of something like this:
+% @node Help-Cross, , , Cross-refs
+\def\donode#1 ,#2\finishnodeparse{\dodonode #1,\finishnodeparse}
+\def\dodonode#1,#2\finishnodeparse{\gdef\lastnode{#1}}
+
+\let\nwnode=\node
+\let\lastnode=\empty
+
+% Write a cross-reference definition for the current node. #1 is the
+% type (Ynumbered, Yappendix, Ynothing).
+%
+\def\donoderef#1{%
+ \ifx\lastnode\empty\else
+ \setref{\lastnode}{#1}%
+ \global\let\lastnode=\empty
+ \fi
+}
+
+% @anchor{NAME} -- define xref target at arbitrary point.
+%
+\newcount\savesfregister
+%
+\def\savesf{\relax \ifhmode \savesfregister=\spacefactor \fi}
+\def\restoresf{\relax \ifhmode \spacefactor=\savesfregister \fi}
+\def\anchor#1{\savesf \setref{#1}{Ynothing}\restoresf \ignorespaces}
+
+% \setref{NAME}{SNT} defines a cross-reference point NAME (a node or an
+% anchor), which consists of three parts:
+% 1) NAME-title - the current sectioning name taken from \lastsection,
+% or the anchor name.
+% 2) NAME-snt - section number and type, passed as the SNT arg, or
+% empty for anchors.
+% 3) NAME-pg - the page number.
+%
+% This is called from \donoderef, \anchor, and \dofloat. In the case of
+% floats, there is an additional part, which is not written here:
+% 4) NAME-lof - the text as it should appear in a @listoffloats.
+%
+\def\setref#1#2{%
+ \pdfmkdest{#1}%
+ \iflinks
+ {%
+ \atdummies % preserve commands, but don't expand them
+ \edef\writexrdef##1##2{%
+ \write\auxfile{@xrdef{#1-% #1 of \setref, expanded by the \edef
+ ##1}{##2}}% these are parameters of \writexrdef
+ }%
+ \toks0 = \expandafter{\lastsection}%
+ \immediate \writexrdef{title}{\the\toks0 }%
+ \immediate \writexrdef{snt}{\csname #2\endcsname}% \Ynumbered etc.
+ \safewhatsit{\writexrdef{pg}{\folio}}% will be written later, at \shipout
+ }%
+ \fi
+}
+
+% @xrefautosectiontitle on|off says whether @section(ing) names are used
+% automatically in xrefs, if the third arg is not explicitly specified.
+% This was provided as a "secret" @set xref-automatic-section-title
+% variable, now it's official.
+%
+\parseargdef\xrefautomaticsectiontitle{%
+ \def\temp{#1}%
+ \ifx\temp\onword
+ \expandafter\let\csname SETxref-automatic-section-title\endcsname
+ = \empty
+ \else\ifx\temp\offword
+ \expandafter\let\csname SETxref-automatic-section-title\endcsname
+ = \relax
+ \else
+ \errhelp = \EMsimple
+ \errmessage{Unknown @xrefautomaticsectiontitle value `\temp',
+ must be on|off}%
+ \fi\fi
+}
+
+%
+% @xref, @pxref, and @ref generate cross-references. For \xrefX, #1 is
+% the node name, #2 the name of the Info cross-reference, #3 the printed
+% node name, #4 the name of the Info file, #5 the name of the printed
+% manual. All but the node name can be omitted.
+%
+\def\pxref#1{\putwordsee{} \xrefX[#1,,,,,,,]}
+\def\xref#1{\putwordSee{} \xrefX[#1,,,,,,,]}
+\def\ref#1{\xrefX[#1,,,,,,,]}
+%
+\newbox\toprefbox
+\newbox\printedrefnamebox
+\newbox\infofilenamebox
+\newbox\printedmanualbox
+%
+\def\xrefX[#1,#2,#3,#4,#5,#6]{\begingroup
+ \unsepspaces
+ %
+ % Get args without leading/trailing spaces.
+ \def\printedrefname{\ignorespaces #3}%
+ \setbox\printedrefnamebox = \hbox{\printedrefname\unskip}%
+ %
+ \def\infofilename{\ignorespaces #4}%
+ \setbox\infofilenamebox = \hbox{\infofilename\unskip}%
+ %
+ \def\printedmanual{\ignorespaces #5}%
+ \setbox\printedmanualbox = \hbox{\printedmanual\unskip}%
+ %
+ % If the printed reference name (arg #3) was not explicitly given in
+ % the @xref, figure out what we want to use.
+ \ifdim \wd\printedrefnamebox = 0pt
+ % No printed node name was explicitly given.
+ \expandafter\ifx\csname SETxref-automatic-section-title\endcsname \relax
+ % Not auto section-title: use node name inside the square brackets.
+ \def\printedrefname{\ignorespaces #1}%
+ \else
+ % Auto section-title: use chapter/section title inside
+ % the square brackets if we have it.
+ \ifdim \wd\printedmanualbox > 0pt
+ % It is in another manual, so we don't have it; use node name.
+ \def\printedrefname{\ignorespaces #1}%
+ \else
+ \ifhavexrefs
+ % We (should) know the real title if we have the xref values.
+ \def\printedrefname{\refx{#1-title}{}}%
+ \else
+ % Otherwise just copy the Info node name.
+ \def\printedrefname{\ignorespaces #1}%
+ \fi%
+ \fi
+ \fi
+ \fi
+ %
+ % Make link in pdf output.
+ \ifpdf
+ {\indexnofonts
+ \turnoffactive
+ \makevalueexpandable
+ % This expands tokens, so do it after making catcode changes, so _
+ % etc. don't get their TeX definitions. This ignores all spaces in
+ % #4, including (wrongly) those in the middle of the filename.
+ \getfilename{#4}%
+ %
+ % This (wrongly) does not take account of leading or trailing
+ % spaces in #1, which should be ignored.
+ \edef\pdfxrefdest{#1}%
+ \ifx\pdfxrefdest\empty
+ \def\pdfxrefdest{Top}% no empty targets
+ \else
+ \txiescapepdf\pdfxrefdest % escape PDF special chars
+ \fi
+ %
+ \leavevmode
+ \startlink attr{/Border [0 0 0]}%
+ \ifnum\filenamelength>0
+ goto file{\the\filename.pdf} name{\pdfxrefdest}%
+ \else
+ goto name{\pdfmkpgn{\pdfxrefdest}}%
+ \fi
+ }%
+ \setcolor{\linkcolor}%
+ \fi
+ %
+ % Float references are printed completely differently: "Figure 1.2"
+ % instead of "[somenode], p.3". We distinguish them by the
+ % LABEL-title being set to a magic string.
+ {%
+ % Have to otherify everything special to allow the \csname to
+ % include an _ in the xref name, etc.
+ \indexnofonts
+ \turnoffactive
+ \expandafter\global\expandafter\let\expandafter\Xthisreftitle
+ \csname XR#1-title\endcsname
+ }%
+ \iffloat\Xthisreftitle
+ % If the user specified the print name (third arg) to the ref,
+ % print it instead of our usual "Figure 1.2".
+ \ifdim\wd\printedrefnamebox = 0pt
+ \refx{#1-snt}{}%
+ \else
+ \printedrefname
+ \fi
+ %
+ % If the user also gave the printed manual name (fifth arg), append
+ % "in MANUALNAME".
+ \ifdim \wd\printedmanualbox > 0pt
+ \space \putwordin{} \cite{\printedmanual}%
+ \fi
+ \else
+ % node/anchor (non-float) references.
+ %
+ % If we use \unhbox to print the node names, TeX does not insert
+ % empty discretionaries after hyphens, which means that it will not
+ % find a line break at a hyphen in a node names. Since some manuals
+ % are best written with fairly long node names, containing hyphens,
+ % this is a loss. Therefore, we give the text of the node name
+ % again, so it is as if TeX is seeing it for the first time.
+ %
+ \ifdim \wd\printedmanualbox > 0pt
+ % Cross-manual reference with a printed manual name.
+ %
+ \crossmanualxref{\cite{\printedmanual\unskip}}%
+ %
+ \else\ifdim \wd\infofilenamebox > 0pt
+ % Cross-manual reference with only an info filename (arg 4), no
+ % printed manual name (arg 5). This is essentially the same as
+ % the case above; we output the filename, since we have nothing else.
+ %
+ \crossmanualxref{\code{\infofilename\unskip}}%
+ %
+ \else
+ % Reference within this manual.
+ %
+ % _ (for example) has to be the character _ for the purposes of the
+ % control sequence corresponding to the node, but it has to expand
+ % into the usual \leavevmode...\vrule stuff for purposes of
+ % printing. So we \turnoffactive for the \refx-snt, back on for the
+ % printing, back off for the \refx-pg.
+ {\turnoffactive
+ % Only output a following space if the -snt ref is nonempty; for
+ % @unnumbered and @anchor, it won't be.
+ \setbox2 = \hbox{\ignorespaces \refx{#1-snt}{}}%
+ \ifdim \wd2 > 0pt \refx{#1-snt}\space\fi
+ }%
+ % output the `[mynode]' via the macro below so it can be overridden.
+ \xrefprintnodename\printedrefname
+ %
+ % But we always want a comma and a space:
+ ,\space
+ %
+ % output the `page 3'.
+ \turnoffactive \putwordpage\tie\refx{#1-pg}{}%
+ \fi\fi
+ \fi
+ \endlink
+\endgroup}
+
+% Output a cross-manual xref to #1. Used just above (twice).
+%
+% Only include the text "Section ``foo'' in" if the foo is neither
+% missing or Top. Thus, @xref{,,,foo,The Foo Manual} outputs simply
+% "see The Foo Manual", the idea being to refer to the whole manual.
+%
+% But, this being TeX, we can't easily compare our node name against the
+% string "Top" while ignoring the possible spaces before and after in
+% the input. By adding the arbitrary 7sp below, we make it much less
+% likely that a real node name would have the same width as "Top" (e.g.,
+% in a monospaced font). Hopefully it will never happen in practice.
+%
+% For the same basic reason, we retypeset the "Top" at every
+% reference, since the current font is indeterminate.
+%
+\def\crossmanualxref#1{%
+ \setbox\toprefbox = \hbox{Top\kern7sp}%
+ \setbox2 = \hbox{\ignorespaces \printedrefname \unskip \kern7sp}%
+ \ifdim \wd2 > 7sp % nonempty?
+ \ifdim \wd2 = \wd\toprefbox \else % same as Top?
+ \putwordSection{} ``\printedrefname'' \putwordin{}\space
+ \fi
+ \fi
+ #1%
+}
+
+% This macro is called from \xrefX for the `[nodename]' part of xref
+% output. It's a separate macro only so it can be changed more easily,
+% since square brackets don't work well in some documents. Particularly
+% one that Bob is working on :).
+%
+\def\xrefprintnodename#1{[#1]}
+
+% Things referred to by \setref.
+%
+\def\Ynothing{}
+\def\Yomitfromtoc{}
+\def\Ynumbered{%
+ \ifnum\secno=0
+ \putwordChapter@tie \the\chapno
+ \else \ifnum\subsecno=0
+ \putwordSection@tie \the\chapno.\the\secno
+ \else \ifnum\subsubsecno=0
+ \putwordSection@tie \the\chapno.\the\secno.\the\subsecno
+ \else
+ \putwordSection@tie \the\chapno.\the\secno.\the\subsecno.\the\subsubsecno
+ \fi\fi\fi
+}
+\def\Yappendix{%
+ \ifnum\secno=0
+ \putwordAppendix@tie @char\the\appendixno{}%
+ \else \ifnum\subsecno=0
+ \putwordSection@tie @char\the\appendixno.\the\secno
+ \else \ifnum\subsubsecno=0
+ \putwordSection@tie @char\the\appendixno.\the\secno.\the\subsecno
+ \else
+ \putwordSection@tie
+ @char\the\appendixno.\the\secno.\the\subsecno.\the\subsubsecno
+ \fi\fi\fi
+}
+
+% Define \refx{NAME}{SUFFIX} to reference a cross-reference string named NAME.
+% If its value is nonempty, SUFFIX is output afterward.
+%
+\def\refx#1#2{%
+ {%
+ \indexnofonts
+ \otherbackslash
+ \expandafter\global\expandafter\let\expandafter\thisrefX
+ \csname XR#1\endcsname
+ }%
+ \ifx\thisrefX\relax
+ % If not defined, say something at least.
+ \angleleft un\-de\-fined\angleright
+ \iflinks
+ \ifhavexrefs
+ {\toks0 = {#1}% avoid expansion of possibly-complex value
+ \message{\linenumber Undefined cross reference `\the\toks0'.}}%
+ \else
+ \ifwarnedxrefs\else
+ \global\warnedxrefstrue
+ \message{Cross reference values unknown; you must run TeX again.}%
+ \fi
+ \fi
+ \fi
+ \else
+ % It's defined, so just use it.
+ \thisrefX
+ \fi
+ #2% Output the suffix in any case.
+}
+
+% This is the macro invoked by entries in the aux file. Usually it's
+% just a \def (we prepend XR to the control sequence name to avoid
+% collisions). But if this is a float type, we have more work to do.
+%
+\def\xrdef#1#2{%
+ {% The node name might contain 8-bit characters, which in our current
+ % implementation are changed to commands like @'e. Don't let these
+ % mess up the control sequence name.
+ \indexnofonts
+ \turnoffactive
+ \xdef\safexrefname{#1}%
+ }%
+ %
+ \expandafter\gdef\csname XR\safexrefname\endcsname{#2}% remember this xref
+ %
+ % Was that xref control sequence that we just defined for a float?
+ \expandafter\iffloat\csname XR\safexrefname\endcsname
+ % it was a float, and we have the (safe) float type in \iffloattype.
+ \expandafter\let\expandafter\floatlist
+ \csname floatlist\iffloattype\endcsname
+ %
+ % Is this the first time we've seen this float type?
+ \expandafter\ifx\floatlist\relax
+ \toks0 = {\do}% yes, so just \do
+ \else
+ % had it before, so preserve previous elements in list.
+ \toks0 = \expandafter{\floatlist\do}%
+ \fi
+ %
+ % Remember this xref in the control sequence \floatlistFLOATTYPE,
+ % for later use in \listoffloats.
+ \expandafter\xdef\csname floatlist\iffloattype\endcsname{\the\toks0
+ {\safexrefname}}%
+ \fi
+}
+
+% Read the last existing aux file, if any. No error if none exists.
+%
+\def\tryauxfile{%
+ \openin 1 \jobname.aux
+ \ifeof 1 \else
+ \readdatafile{aux}%
+ \global\havexrefstrue
+ \fi
+ \closein 1
+}
+
+\def\setupdatafile{%
+ \catcode`\^^@=\other
+ \catcode`\^^A=\other
+ \catcode`\^^B=\other
+ \catcode`\^^C=\other
+ \catcode`\^^D=\other
+ \catcode`\^^E=\other
+ \catcode`\^^F=\other
+ \catcode`\^^G=\other
+ \catcode`\^^H=\other
+ \catcode`\^^K=\other
+ \catcode`\^^L=\other
+ \catcode`\^^N=\other
+ \catcode`\^^P=\other
+ \catcode`\^^Q=\other
+ \catcode`\^^R=\other
+ \catcode`\^^S=\other
+ \catcode`\^^T=\other
+ \catcode`\^^U=\other
+ \catcode`\^^V=\other
+ \catcode`\^^W=\other
+ \catcode`\^^X=\other
+ \catcode`\^^Z=\other
+ \catcode`\^^[=\other
+ \catcode`\^^\=\other
+ \catcode`\^^]=\other
+ \catcode`\^^^=\other
+ \catcode`\^^_=\other
+ % It was suggested to set the catcode of ^ to 7, which would allow ^^e4 etc.
+ % in xref tags, i.e., node names. But since ^^e4 notation isn't
+ % supported in the main text, it doesn't seem desirable. Furthermore,
+ % that is not enough: for node names that actually contain a ^
+ % character, we would end up writing a line like this: 'xrdef {'hat
+ % b-title}{'hat b} and \xrdef does a \csname...\endcsname on the first
+ % argument, and \hat is not an expandable control sequence. It could
+ % all be worked out, but why? Either we support ^^ or we don't.
+ %
+ % The other change necessary for this was to define \auxhat:
+ % \def\auxhat{\def^{'hat }}% extra space so ok if followed by letter
+ % and then to call \auxhat in \setq.
+ %
+ \catcode`\^=\other
+ %
+ % Special characters. Should be turned off anyway, but...
+ \catcode`\~=\other
+ \catcode`\[=\other
+ \catcode`\]=\other
+ \catcode`\"=\other
+ \catcode`\_=\other
+ \catcode`\|=\other
+ \catcode`\<=\other
+ \catcode`\>=\other
+ \catcode`\$=\other
+ \catcode`\#=\other
+ \catcode`\&=\other
+ \catcode`\%=\other
+ \catcode`+=\other % avoid \+ for paranoia even though we've turned it off
+ %
+ % This is to support \ in node names and titles, since the \
+ % characters end up in a \csname. It's easier than
+ % leaving it active and making its active definition an actual \
+ % character. What I don't understand is why it works in the *value*
+ % of the xrdef. Seems like it should be a catcode12 \, and that
+ % should not typeset properly. But it works, so I'm moving on for
+ % now. --karl, 15jan04.
+ \catcode`\\=\other
+ %
+ % Make the characters 128-255 be printing characters.
+ {%
+ \count1=128
+ \def\loop{%
+ \catcode\count1=\other
+ \advance\count1 by 1
+ \ifnum \count1<256 \loop \fi
+ }%
+ }%
+ %
+ % @ is our escape character in .aux files, and we need braces.
+ \catcode`\{=1
+ \catcode`\}=2
+ \catcode`\@=0
+}
+
+\def\readdatafile#1{%
+\begingroup
+ \setupdatafile
+ \input\jobname.#1
+\endgroup}
+
+
+\message{insertions,}
+% including footnotes.
+
+\newcount \footnoteno
+
+% The trailing space in the following definition for supereject is
+% vital for proper filling; pages come out unaligned when you do a
+% pagealignmacro call if that space before the closing brace is
+% removed. (Generally, numeric constants should always be followed by a
+% space to prevent strange expansion errors.)
+\def\supereject{\par\penalty -20000\footnoteno =0 }
+
+% @footnotestyle is meaningful for Info output only.
+\let\footnotestyle=\comment
+
+{\catcode `\@=11
+%
+% Auto-number footnotes. Otherwise like plain.
+\gdef\footnote{%
+ \let\indent=\ptexindent
+ \let\noindent=\ptexnoindent
+ \global\advance\footnoteno by \@ne
+ \edef\thisfootno{$^{\the\footnoteno}$}%
+ %
+ % In case the footnote comes at the end of a sentence, preserve the
+ % extra spacing after we do the footnote number.
+ \let\@sf\empty
+ \ifhmode\edef\@sf{\spacefactor\the\spacefactor}\ptexslash\fi
+ %
+ % Remove inadvertent blank space before typesetting the footnote number.
+ \unskip
+ \thisfootno\@sf
+ \dofootnote
+}%
+
+% Don't bother with the trickery in plain.tex to not require the
+% footnote text as a parameter. Our footnotes don't need to be so general.
+%
+% Oh yes, they do; otherwise, @ifset (and anything else that uses
+% \parseargline) fails inside footnotes because the tokens are fixed when
+% the footnote is read. --karl, 16nov96.
+%
+\gdef\dofootnote{%
+ \insert\footins\bgroup
+ % We want to typeset this text as a normal paragraph, even if the
+ % footnote reference occurs in (for example) a display environment.
+ % So reset some parameters.
+ \hsize=\pagewidth
+ \interlinepenalty\interfootnotelinepenalty
+ \splittopskip\ht\strutbox % top baseline for broken footnotes
+ \splitmaxdepth\dp\strutbox
+ \floatingpenalty\@MM
+ \leftskip\z@skip
+ \rightskip\z@skip
+ \spaceskip\z@skip
+ \xspaceskip\z@skip
+ \parindent\defaultparindent
+ %
+ \smallfonts \rm
+ %
+ % Because we use hanging indentation in footnotes, a @noindent appears
+ % to exdent this text, so make it be a no-op. makeinfo does not use
+ % hanging indentation so @noindent can still be needed within footnote
+ % text after an @example or the like (not that this is good style).
+ \let\noindent = \relax
+ %
+ % Hang the footnote text off the number. Use \everypar in case the
+ % footnote extends for more than one paragraph.
+ \everypar = {\hang}%
+ \textindent{\thisfootno}%
+ %
+ % Don't crash into the line above the footnote text. Since this
+ % expands into a box, it must come within the paragraph, lest it
+ % provide a place where TeX can split the footnote.
+ \footstrut
+ %
+ % Invoke rest of plain TeX footnote routine.
+ \futurelet\next\fo@t
+}
+}%end \catcode `\@=11
+
+% In case a @footnote appears in a vbox, save the footnote text and create
+% the real \insert just after the vbox finished. Otherwise, the insertion
+% would be lost.
+% Similarly, if a @footnote appears inside an alignment, save the footnote
+% text to a box and make the \insert when a row of the table is finished.
+% And the same can be done for other insert classes. --kasal, 16nov03.
+
+% Replace the \insert primitive by a cheating macro.
+% Deeper inside, just make sure that the saved insertions are not spilled
+% out prematurely.
+%
+\def\startsavinginserts{%
+ \ifx \insert\ptexinsert
+ \let\insert\saveinsert
+ \else
+ \let\checkinserts\relax
+ \fi
+}
+
+% This \insert replacement works for both \insert\footins{foo} and
+% \insert\footins\bgroup foo\egroup, but it doesn't work for \insert27{foo}.
+%
+\def\saveinsert#1{%
+ \edef\next{\noexpand\savetobox \makeSAVEname#1}%
+ \afterassignment\next
+ % swallow the left brace
+ \let\temp =
+}
+\def\makeSAVEname#1{\makecsname{SAVE\expandafter\gobble\string#1}}
+\def\savetobox#1{\global\setbox#1 = \vbox\bgroup \unvbox#1}
+
+\def\checksaveins#1{\ifvoid#1\else \placesaveins#1\fi}
+
+\def\placesaveins#1{%
+ \ptexinsert \csname\expandafter\gobblesave\string#1\endcsname
+ {\box#1}%
+}
+
+% eat @SAVE -- beware, all of them have catcode \other:
+{
+ \def\dospecials{\do S\do A\do V\do E} \uncatcodespecials % ;-)
+ \gdef\gobblesave @SAVE{}
+}
+
+% initialization:
+\def\newsaveins #1{%
+ \edef\next{\noexpand\newsaveinsX \makeSAVEname#1}%
+ \next
+}
+\def\newsaveinsX #1{%
+ \csname newbox\endcsname #1%
+ \expandafter\def\expandafter\checkinserts\expandafter{\checkinserts
+ \checksaveins #1}%
+}
+
+% initialize:
+\let\checkinserts\empty
+\newsaveins\footins
+\newsaveins\margin
+
+
+% @image. We use the macros from epsf.tex to support this.
+% If epsf.tex is not installed and @image is used, we complain.
+%
+% Check for and read epsf.tex up front. If we read it only at @image
+% time, we might be inside a group, and then its definitions would get
+% undone and the next image would fail.
+\openin 1 = epsf.tex
+\ifeof 1 \else
+ % Do not bother showing banner with epsf.tex v2.7k (available in
+ % doc/epsf.tex and on ctan).
+ \def\epsfannounce{\toks0 = }%
+ \input epsf.tex
+\fi
+\closein 1
+%
+% We will only complain once about lack of epsf.tex.
+\newif\ifwarnednoepsf
+\newhelp\noepsfhelp{epsf.tex must be installed for images to
+ work. It is also included in the Texinfo distribution, or you can get
+ it from ftp://tug.org/tex/epsf.tex.}
+%
+\def\image#1{%
+ \ifx\epsfbox\thisisundefined
+ \ifwarnednoepsf \else
+ \errhelp = \noepsfhelp
+ \errmessage{epsf.tex not found, images will be ignored}%
+ \global\warnednoepsftrue
+ \fi
+ \else
+ \imagexxx #1,,,,,\finish
+ \fi
+}
+%
+% Arguments to @image:
+% #1 is (mandatory) image filename; we tack on .eps extension.
+% #2 is (optional) width, #3 is (optional) height.
+% #4 is (ignored optional) html alt text.
+% #5 is (ignored optional) extension.
+% #6 is just the usual extra ignored arg for parsing stuff.
+\newif\ifimagevmode
+\def\imagexxx#1,#2,#3,#4,#5,#6\finish{\begingroup
+ \catcode`\^^M = 5 % in case we're inside an example
+ \normalturnoffactive % allow _ et al. in names
+ % If the image is by itself, center it.
+ \ifvmode
+ \imagevmodetrue
+ \else \ifx\centersub\centerV
+ % for @center @image, we need a vbox so we can have our vertical space
+ \imagevmodetrue
+ \vbox\bgroup % vbox has better behavior than vtop herev
+ \fi\fi
+ %
+ \ifimagevmode
+ \nobreak\medskip
+ % Usually we'll have text after the image which will insert
+ % \parskip glue, so insert it here too to equalize the space
+ % above and below.
+ \nobreak\vskip\parskip
+ \nobreak
+ \fi
+ %
+ % Leave vertical mode so that indentation from an enclosing
+ % environment such as @quotation is respected.
+ % However, if we're at the top level, we don't want the
+ % normal paragraph indentation.
+ % On the other hand, if we are in the case of @center @image, we don't
+ % want to start a paragraph, which will create a hsize-width box and
+ % eradicate the centering.
+ \ifx\centersub\centerV\else \noindent \fi
+ %
+ % Output the image.
+ \ifpdf
+ \dopdfimage{#1}{#2}{#3}%
+ \else
+ % \epsfbox itself resets \epsf?size at each figure.
+ \setbox0 = \hbox{\ignorespaces #2}\ifdim\wd0 > 0pt \epsfxsize=#2\relax \fi
+ \setbox0 = \hbox{\ignorespaces #3}\ifdim\wd0 > 0pt \epsfysize=#3\relax \fi
+ \epsfbox{#1.eps}%
+ \fi
+ %
+ \ifimagevmode
+ \medskip % space after a standalone image
+ \fi
+ \ifx\centersub\centerV \egroup \fi
+\endgroup}
+
+
+% @float FLOATTYPE,LABEL,LOC ... @end float for displayed figures, tables,
+% etc. We don't actually implement floating yet, we always include the
+% float "here". But it seemed the best name for the future.
+%
+\envparseargdef\float{\eatcommaspace\eatcommaspace\dofloat#1, , ,\finish}
+
+% There may be a space before second and/or third parameter; delete it.
+\def\eatcommaspace#1, {#1,}
+
+% #1 is the optional FLOATTYPE, the text label for this float, typically
+% "Figure", "Table", "Example", etc. Can't contain commas. If omitted,
+% this float will not be numbered and cannot be referred to.
+%
+% #2 is the optional xref label. Also must be present for the float to
+% be referable.
+%
+% #3 is the optional positioning argument; for now, it is ignored. It
+% will somehow specify the positions allowed to float to (here, top, bottom).
+%
+% We keep a separate counter for each FLOATTYPE, which we reset at each
+% chapter-level command.
+\let\resetallfloatnos=\empty
+%
+\def\dofloat#1,#2,#3,#4\finish{%
+ \let\thiscaption=\empty
+ \let\thisshortcaption=\empty
+ %
+ % don't lose footnotes inside @float.
+ %
+ % BEWARE: when the floats start float, we have to issue warning whenever an
+ % insert appears inside a float which could possibly float. --kasal, 26may04
+ %
+ \startsavinginserts
+ %
+ % We can't be used inside a paragraph.
+ \par
+ %
+ \vtop\bgroup
+ \def\floattype{#1}%
+ \def\floatlabel{#2}%
+ \def\floatloc{#3}% we do nothing with this yet.
+ %
+ \ifx\floattype\empty
+ \let\safefloattype=\empty
+ \else
+ {%
+ % the floattype might have accents or other special characters,
+ % but we need to use it in a control sequence name.
+ \indexnofonts
+ \turnoffactive
+ \xdef\safefloattype{\floattype}%
+ }%
+ \fi
+ %
+ % If label is given but no type, we handle that as the empty type.
+ \ifx\floatlabel\empty \else
+ % We want each FLOATTYPE to be numbered separately (Figure 1,
+ % Table 1, Figure 2, ...). (And if no label, no number.)
+ %
+ \expandafter\getfloatno\csname\safefloattype floatno\endcsname
+ \global\advance\floatno by 1
+ %
+ {%
+ % This magic value for \lastsection is output by \setref as the
+ % XREFLABEL-title value. \xrefX uses it to distinguish float
+ % labels (which have a completely different output format) from
+ % node and anchor labels. And \xrdef uses it to construct the
+ % lists of floats.
+ %
+ \edef\lastsection{\floatmagic=\safefloattype}%
+ \setref{\floatlabel}{Yfloat}%
+ }%
+ \fi
+ %
+ % start with \parskip glue, I guess.
+ \vskip\parskip
+ %
+ % Don't suppress indentation if a float happens to start a section.
+ \restorefirstparagraphindent
+}
+
+% we have these possibilities:
+% @float Foo,lbl & @caption{Cap}: Foo 1.1: Cap
+% @float Foo,lbl & no caption: Foo 1.1
+% @float Foo & @caption{Cap}: Foo: Cap
+% @float Foo & no caption: Foo
+% @float ,lbl & Caption{Cap}: 1.1: Cap
+% @float ,lbl & no caption: 1.1
+% @float & @caption{Cap}: Cap
+% @float & no caption:
+%
+\def\Efloat{%
+ \let\floatident = \empty
+ %
+ % In all cases, if we have a float type, it comes first.
+ \ifx\floattype\empty \else \def\floatident{\floattype}\fi
+ %
+ % If we have an xref label, the number comes next.
+ \ifx\floatlabel\empty \else
+ \ifx\floattype\empty \else % if also had float type, need tie first.
+ \appendtomacro\floatident{\tie}%
+ \fi
+ % the number.
+ \appendtomacro\floatident{\chaplevelprefix\the\floatno}%
+ \fi
+ %
+ % Start the printed caption with what we've constructed in
+ % \floatident, but keep it separate; we need \floatident again.
+ \let\captionline = \floatident
+ %
+ \ifx\thiscaption\empty \else
+ \ifx\floatident\empty \else
+ \appendtomacro\captionline{: }% had ident, so need a colon between
+ \fi
+ %
+ % caption text.
+ \appendtomacro\captionline{\scanexp\thiscaption}%
+ \fi
+ %
+ % If we have anything to print, print it, with space before.
+ % Eventually this needs to become an \insert.
+ \ifx\captionline\empty \else
+ \vskip.5\parskip
+ \captionline
+ %
+ % Space below caption.
+ \vskip\parskip
+ \fi
+ %
+ % If have an xref label, write the list of floats info. Do this
+ % after the caption, to avoid chance of it being a breakpoint.
+ \ifx\floatlabel\empty \else
+ % Write the text that goes in the lof to the aux file as
+ % \floatlabel-lof. Besides \floatident, we include the short
+ % caption if specified, else the full caption if specified, else nothing.
+ {%
+ \atdummies
+ %
+ % since we read the caption text in the macro world, where ^^M
+ % is turned into a normal character, we have to scan it back, so
+ % we don't write the literal three characters "^^M" into the aux file.
+ \scanexp{%
+ \xdef\noexpand\gtemp{%
+ \ifx\thisshortcaption\empty
+ \thiscaption
+ \else
+ \thisshortcaption
+ \fi
+ }%
+ }%
+ \immediate\write\auxfile{@xrdef{\floatlabel-lof}{\floatident
+ \ifx\gtemp\empty \else : \gtemp \fi}}%
+ }%
+ \fi
+ \egroup % end of \vtop
+ %
+ % place the captured inserts
+ %
+ % BEWARE: when the floats start floating, we have to issue warning
+ % whenever an insert appears inside a float which could possibly
+ % float. --kasal, 26may04
+ %
+ \checkinserts
+}
+
+% Append the tokens #2 to the definition of macro #1, not expanding either.
+%
+\def\appendtomacro#1#2{%
+ \expandafter\def\expandafter#1\expandafter{#1#2}%
+}
+
+% @caption, @shortcaption
+%
+\def\caption{\docaption\thiscaption}
+\def\shortcaption{\docaption\thisshortcaption}
+\def\docaption{\checkenv\float \bgroup\scanargctxt\defcaption}
+\def\defcaption#1#2{\egroup \def#1{#2}}
+
+% The parameter is the control sequence identifying the counter we are
+% going to use. Create it if it doesn't exist and assign it to \floatno.
+\def\getfloatno#1{%
+ \ifx#1\relax
+ % Haven't seen this figure type before.
+ \csname newcount\endcsname #1%
+ %
+ % Remember to reset this floatno at the next chap.
+ \expandafter\gdef\expandafter\resetallfloatnos
+ \expandafter{\resetallfloatnos #1=0 }%
+ \fi
+ \let\floatno#1%
+}
+
+% \setref calls this to get the XREFLABEL-snt value. We want an @xref
+% to the FLOATLABEL to expand to "Figure 3.1". We call \setref when we
+% first read the @float command.
+%
+\def\Yfloat{\floattype@tie \chaplevelprefix\the\floatno}%
+
+% Magic string used for the XREFLABEL-title value, so \xrefX can
+% distinguish floats from other xref types.
+\def\floatmagic{!!float!!}
+
+% #1 is the control sequence we are passed; we expand into a conditional
+% which is true if #1 represents a float ref. That is, the magic
+% \lastsection value which we \setref above.
+%
+\def\iffloat#1{\expandafter\doiffloat#1==\finish}
+%
+% #1 is (maybe) the \floatmagic string. If so, #2 will be the
+% (safe) float type for this float. We set \iffloattype to #2.
+%
+\def\doiffloat#1=#2=#3\finish{%
+ \def\temp{#1}%
+ \def\iffloattype{#2}%
+ \ifx\temp\floatmagic
+}
+
+% @listoffloats FLOATTYPE - print a list of floats like a table of contents.
+%
+\parseargdef\listoffloats{%
+ \def\floattype{#1}% floattype
+ {%
+ % the floattype might have accents or other special characters,
+ % but we need to use it in a control sequence name.
+ \indexnofonts
+ \turnoffactive
+ \xdef\safefloattype{\floattype}%
+ }%
+ %
+ % \xrdef saves the floats as a \do-list in \floatlistSAFEFLOATTYPE.
+ \expandafter\ifx\csname floatlist\safefloattype\endcsname \relax
+ \ifhavexrefs
+ % if the user said @listoffloats foo but never @float foo.
+ \message{\linenumber No `\safefloattype' floats to list.}%
+ \fi
+ \else
+ \begingroup
+ \leftskip=\tocindent % indent these entries like a toc
+ \let\do=\listoffloatsdo
+ \csname floatlist\safefloattype\endcsname
+ \endgroup
+ \fi
+}
+
+% This is called on each entry in a list of floats. We're passed the
+% xref label, in the form LABEL-title, which is how we save it in the
+% aux file. We strip off the -title and look up \XRLABEL-lof, which
+% has the text we're supposed to typeset here.
+%
+% Figures without xref labels will not be included in the list (since
+% they won't appear in the aux file).
+%
+\def\listoffloatsdo#1{\listoffloatsdoentry#1\finish}
+\def\listoffloatsdoentry#1-title\finish{{%
+ % Can't fully expand XR#1-lof because it can contain anything. Just
+ % pass the control sequence. On the other hand, XR#1-pg is just the
+ % page number, and we want to fully expand that so we can get a link
+ % in pdf output.
+ \toksA = \expandafter{\csname XR#1-lof\endcsname}%
+ %
+ % use the same \entry macro we use to generate the TOC and index.
+ \edef\writeentry{\noexpand\entry{\the\toksA}{\csname XR#1-pg\endcsname}}%
+ \writeentry
+}}
+
+
+\message{localization,}
+
+% For single-language documents, @documentlanguage is usually given very
+% early, just after @documentencoding. Single argument is the language
+% (de) or locale (de_DE) abbreviation.
+%
+{
+ \catcode`\_ = \active
+ \globaldefs=1
+\parseargdef\documentlanguage{\begingroup
+ \let_=\normalunderscore % normal _ character for filenames
+ \tex % read txi-??.tex file in plain TeX.
+ % Read the file by the name they passed if it exists.
+ \openin 1 txi-#1.tex
+ \ifeof 1
+ \documentlanguagetrywithoutunderscore{#1_\finish}%
+ \else
+ \globaldefs = 1 % everything in the txi-LL files needs to persist
+ \input txi-#1.tex
+ \fi
+ \closein 1
+ \endgroup % end raw TeX
+\endgroup}
+%
+% If they passed de_DE, and txi-de_DE.tex doesn't exist,
+% try txi-de.tex.
+%
+\gdef\documentlanguagetrywithoutunderscore#1_#2\finish{%
+ \openin 1 txi-#1.tex
+ \ifeof 1
+ \errhelp = \nolanghelp
+ \errmessage{Cannot read language file txi-#1.tex}%
+ \else
+ \globaldefs = 1 % everything in the txi-LL files needs to persist
+ \input txi-#1.tex
+ \fi
+ \closein 1
+}
+}% end of special _ catcode
+%
+\newhelp\nolanghelp{The given language definition file cannot be found or
+is empty. Maybe you need to install it? Putting it in the current
+directory should work if nowhere else does.}
+
+% This macro is called from txi-??.tex files; the first argument is the
+% \language name to set (without the "\lang@" prefix), the second and
+% third args are \{left,right}hyphenmin.
+%
+% The language names to pass are determined when the format is built.
+% See the etex.log file created at that time, e.g.,
+% /usr/local/texlive/2008/texmf-var/web2c/pdftex/etex.log.
+%
+% With TeX Live 2008, etex now includes hyphenation patterns for all
+% available languages. This means we can support hyphenation in
+% Texinfo, at least to some extent. (This still doesn't solve the
+% accented characters problem.)
+%
+\catcode`@=11
+\def\txisetlanguage#1#2#3{%
+ % do not set the language if the name is undefined in the current TeX.
+ \expandafter\ifx\csname lang@#1\endcsname \relax
+ \message{no patterns for #1}%
+ \else
+ \global\language = \csname lang@#1\endcsname
+ \fi
+ % but there is no harm in adjusting the hyphenmin values regardless.
+ \global\lefthyphenmin = #2\relax
+ \global\righthyphenmin = #3\relax
+}
+
+% Helpers for encodings.
+% Set the catcode of characters 128 through 255 to the specified number.
+%
+\def\setnonasciicharscatcode#1{%
+ \count255=128
+ \loop\ifnum\count255<256
+ \global\catcode\count255=#1\relax
+ \advance\count255 by 1
+ \repeat
+}
+
+\def\setnonasciicharscatcodenonglobal#1{%
+ \count255=128
+ \loop\ifnum\count255<256
+ \catcode\count255=#1\relax
+ \advance\count255 by 1
+ \repeat
+}
+
+% @documentencoding sets the definition of non-ASCII characters
+% according to the specified encoding.
+%
+\parseargdef\documentencoding{%
+ % Encoding being declared for the document.
+ \def\declaredencoding{\csname #1.enc\endcsname}%
+ %
+ % Supported encodings: names converted to tokens in order to be able
+ % to compare them with \ifx.
+ \def\ascii{\csname US-ASCII.enc\endcsname}%
+ \def\latnine{\csname ISO-8859-15.enc\endcsname}%
+ \def\latone{\csname ISO-8859-1.enc\endcsname}%
+ \def\lattwo{\csname ISO-8859-2.enc\endcsname}%
+ \def\utfeight{\csname UTF-8.enc\endcsname}%
+ %
+ \ifx \declaredencoding \ascii
+ \asciichardefs
+ %
+ \else \ifx \declaredencoding \lattwo
+ \setnonasciicharscatcode\active
+ \lattwochardefs
+ %
+ \else \ifx \declaredencoding \latone
+ \setnonasciicharscatcode\active
+ \latonechardefs
+ %
+ \else \ifx \declaredencoding \latnine
+ \setnonasciicharscatcode\active
+ \latninechardefs
+ %
+ \else \ifx \declaredencoding \utfeight
+ \setnonasciicharscatcode\active
+ \utfeightchardefs
+ %
+ \else
+ \message{Unknown document encoding #1, ignoring.}%
+ %
+ \fi % utfeight
+ \fi % latnine
+ \fi % latone
+ \fi % lattwo
+ \fi % ascii
+}
+
+% A message to be logged when using a character that isn't available
+% the default font encoding (OT1).
+%
+\def\missingcharmsg#1{\message{Character missing in OT1 encoding: #1.}}
+
+% Take account of \c (plain) vs. \, (Texinfo) difference.
+\def\cedilla#1{\ifx\c\ptexc\c{#1}\else\,{#1}\fi}
+
+% First, make active non-ASCII characters in order for them to be
+% correctly categorized when TeX reads the replacement text of
+% macros containing the character definitions.
+\setnonasciicharscatcode\active
+%
+% Latin1 (ISO-8859-1) character definitions.
+\def\latonechardefs{%
+ \gdef^^a0{\tie}
+ \gdef^^a1{\exclamdown}
+ \gdef^^a2{\missingcharmsg{CENT SIGN}}
+ \gdef^^a3{{\pounds}}
+ \gdef^^a4{\missingcharmsg{CURRENCY SIGN}}
+ \gdef^^a5{\missingcharmsg{YEN SIGN}}
+ \gdef^^a6{\missingcharmsg{BROKEN BAR}}
+ \gdef^^a7{\S}
+ \gdef^^a8{\"{}}
+ \gdef^^a9{\copyright}
+ \gdef^^aa{\ordf}
+ \gdef^^ab{\guillemetleft}
+ \gdef^^ac{$\lnot$}
+ \gdef^^ad{\-}
+ \gdef^^ae{\registeredsymbol}
+ \gdef^^af{\={}}
+ %
+ \gdef^^b0{\textdegree}
+ \gdef^^b1{$\pm$}
+ \gdef^^b2{$^2$}
+ \gdef^^b3{$^3$}
+ \gdef^^b4{\'{}}
+ \gdef^^b5{$\mu$}
+ \gdef^^b6{\P}
+ %
+ \gdef^^b7{$^.$}
+ \gdef^^b8{\cedilla\ }
+ \gdef^^b9{$^1$}
+ \gdef^^ba{\ordm}
+ %
+ \gdef^^bb{\guillemetright}
+ \gdef^^bc{$1\over4$}
+ \gdef^^bd{$1\over2$}
+ \gdef^^be{$3\over4$}
+ \gdef^^bf{\questiondown}
+ %
+ \gdef^^c0{\`A}
+ \gdef^^c1{\'A}
+ \gdef^^c2{\^A}
+ \gdef^^c3{\~A}
+ \gdef^^c4{\"A}
+ \gdef^^c5{\ringaccent A}
+ \gdef^^c6{\AE}
+ \gdef^^c7{\cedilla C}
+ \gdef^^c8{\`E}
+ \gdef^^c9{\'E}
+ \gdef^^ca{\^E}
+ \gdef^^cb{\"E}
+ \gdef^^cc{\`I}
+ \gdef^^cd{\'I}
+ \gdef^^ce{\^I}
+ \gdef^^cf{\"I}
+ %
+ \gdef^^d0{\DH}
+ \gdef^^d1{\~N}
+ \gdef^^d2{\`O}
+ \gdef^^d3{\'O}
+ \gdef^^d4{\^O}
+ \gdef^^d5{\~O}
+ \gdef^^d6{\"O}
+ \gdef^^d7{$\times$}
+ \gdef^^d8{\O}
+ \gdef^^d9{\`U}
+ \gdef^^da{\'U}
+ \gdef^^db{\^U}
+ \gdef^^dc{\"U}
+ \gdef^^dd{\'Y}
+ \gdef^^de{\TH}
+ \gdef^^df{\ss}
+ %
+ \gdef^^e0{\`a}
+ \gdef^^e1{\'a}
+ \gdef^^e2{\^a}
+ \gdef^^e3{\~a}
+ \gdef^^e4{\"a}
+ \gdef^^e5{\ringaccent a}
+ \gdef^^e6{\ae}
+ \gdef^^e7{\cedilla c}
+ \gdef^^e8{\`e}
+ \gdef^^e9{\'e}
+ \gdef^^ea{\^e}
+ \gdef^^eb{\"e}
+ \gdef^^ec{\`{\dotless i}}
+ \gdef^^ed{\'{\dotless i}}
+ \gdef^^ee{\^{\dotless i}}
+ \gdef^^ef{\"{\dotless i}}
+ %
+ \gdef^^f0{\dh}
+ \gdef^^f1{\~n}
+ \gdef^^f2{\`o}
+ \gdef^^f3{\'o}
+ \gdef^^f4{\^o}
+ \gdef^^f5{\~o}
+ \gdef^^f6{\"o}
+ \gdef^^f7{$\div$}
+ \gdef^^f8{\o}
+ \gdef^^f9{\`u}
+ \gdef^^fa{\'u}
+ \gdef^^fb{\^u}
+ \gdef^^fc{\"u}
+ \gdef^^fd{\'y}
+ \gdef^^fe{\th}
+ \gdef^^ff{\"y}
+}
+
+% Latin9 (ISO-8859-15) encoding character definitions.
+\def\latninechardefs{%
+ % Encoding is almost identical to Latin1.
+ \latonechardefs
+ %
+ \gdef^^a4{\euro}
+ \gdef^^a6{\v S}
+ \gdef^^a8{\v s}
+ \gdef^^b4{\v Z}
+ \gdef^^b8{\v z}
+ \gdef^^bc{\OE}
+ \gdef^^bd{\oe}
+ \gdef^^be{\"Y}
+}
+
+% Latin2 (ISO-8859-2) character definitions.
+\def\lattwochardefs{%
+ \gdef^^a0{\tie}
+ \gdef^^a1{\ogonek{A}}
+ \gdef^^a2{\u{}}
+ \gdef^^a3{\L}
+ \gdef^^a4{\missingcharmsg{CURRENCY SIGN}}
+ \gdef^^a5{\v L}
+ \gdef^^a6{\'S}
+ \gdef^^a7{\S}
+ \gdef^^a8{\"{}}
+ \gdef^^a9{\v S}
+ \gdef^^aa{\cedilla S}
+ \gdef^^ab{\v T}
+ \gdef^^ac{\'Z}
+ \gdef^^ad{\-}
+ \gdef^^ae{\v Z}
+ \gdef^^af{\dotaccent Z}
+ %
+ \gdef^^b0{\textdegree}
+ \gdef^^b1{\ogonek{a}}
+ \gdef^^b2{\ogonek{ }}
+ \gdef^^b3{\l}
+ \gdef^^b4{\'{}}
+ \gdef^^b5{\v l}
+ \gdef^^b6{\'s}
+ \gdef^^b7{\v{}}
+ \gdef^^b8{\cedilla\ }
+ \gdef^^b9{\v s}
+ \gdef^^ba{\cedilla s}
+ \gdef^^bb{\v t}
+ \gdef^^bc{\'z}
+ \gdef^^bd{\H{}}
+ \gdef^^be{\v z}
+ \gdef^^bf{\dotaccent z}
+ %
+ \gdef^^c0{\'R}
+ \gdef^^c1{\'A}
+ \gdef^^c2{\^A}
+ \gdef^^c3{\u A}
+ \gdef^^c4{\"A}
+ \gdef^^c5{\'L}
+ \gdef^^c6{\'C}
+ \gdef^^c7{\cedilla C}
+ \gdef^^c8{\v C}
+ \gdef^^c9{\'E}
+ \gdef^^ca{\ogonek{E}}
+ \gdef^^cb{\"E}
+ \gdef^^cc{\v E}
+ \gdef^^cd{\'I}
+ \gdef^^ce{\^I}
+ \gdef^^cf{\v D}
+ %
+ \gdef^^d0{\DH}
+ \gdef^^d1{\'N}
+ \gdef^^d2{\v N}
+ \gdef^^d3{\'O}
+ \gdef^^d4{\^O}
+ \gdef^^d5{\H O}
+ \gdef^^d6{\"O}
+ \gdef^^d7{$\times$}
+ \gdef^^d8{\v R}
+ \gdef^^d9{\ringaccent U}
+ \gdef^^da{\'U}
+ \gdef^^db{\H U}
+ \gdef^^dc{\"U}
+ \gdef^^dd{\'Y}
+ \gdef^^de{\cedilla T}
+ \gdef^^df{\ss}
+ %
+ \gdef^^e0{\'r}
+ \gdef^^e1{\'a}
+ \gdef^^e2{\^a}
+ \gdef^^e3{\u a}
+ \gdef^^e4{\"a}
+ \gdef^^e5{\'l}
+ \gdef^^e6{\'c}
+ \gdef^^e7{\cedilla c}
+ \gdef^^e8{\v c}
+ \gdef^^e9{\'e}
+ \gdef^^ea{\ogonek{e}}
+ \gdef^^eb{\"e}
+ \gdef^^ec{\v e}
+ \gdef^^ed{\'{\dotless{i}}}
+ \gdef^^ee{\^{\dotless{i}}}
+ \gdef^^ef{\v d}
+ %
+ \gdef^^f0{\dh}
+ \gdef^^f1{\'n}
+ \gdef^^f2{\v n}
+ \gdef^^f3{\'o}
+ \gdef^^f4{\^o}
+ \gdef^^f5{\H o}
+ \gdef^^f6{\"o}
+ \gdef^^f7{$\div$}
+ \gdef^^f8{\v r}
+ \gdef^^f9{\ringaccent u}
+ \gdef^^fa{\'u}
+ \gdef^^fb{\H u}
+ \gdef^^fc{\"u}
+ \gdef^^fd{\'y}
+ \gdef^^fe{\cedilla t}
+ \gdef^^ff{\dotaccent{}}
+}
+
+% UTF-8 character definitions.
+%
+% This code to support UTF-8 is based on LaTeX's utf8.def, with some
+% changes for Texinfo conventions. It is included here under the GPL by
+% permission from Frank Mittelbach and the LaTeX team.
+%
+\newcount\countUTFx
+\newcount\countUTFy
+\newcount\countUTFz
+
+\gdef\UTFviiiTwoOctets#1#2{\expandafter
+ \UTFviiiDefined\csname u8:#1\string #2\endcsname}
+%
+\gdef\UTFviiiThreeOctets#1#2#3{\expandafter
+ \UTFviiiDefined\csname u8:#1\string #2\string #3\endcsname}
+%
+\gdef\UTFviiiFourOctets#1#2#3#4{\expandafter
+ \UTFviiiDefined\csname u8:#1\string #2\string #3\string #4\endcsname}
+
+\gdef\UTFviiiDefined#1{%
+ \ifx #1\relax
+ \message{\linenumber Unicode char \string #1 not defined for Texinfo}%
+ \else
+ \expandafter #1%
+ \fi
+}
+
+\begingroup
+ \catcode`\~13
+ \catcode`\"12
+
+ \def\UTFviiiLoop{%
+ \global\catcode\countUTFx\active
+ \uccode`\~\countUTFx
+ \uppercase\expandafter{\UTFviiiTmp}%
+ \advance\countUTFx by 1
+ \ifnum\countUTFx < \countUTFy
+ \expandafter\UTFviiiLoop
+ \fi}
+
+ \countUTFx = "C2
+ \countUTFy = "E0
+ \def\UTFviiiTmp{%
+ \xdef~{\noexpand\UTFviiiTwoOctets\string~}}
+ \UTFviiiLoop
+
+ \countUTFx = "E0
+ \countUTFy = "F0
+ \def\UTFviiiTmp{%
+ \xdef~{\noexpand\UTFviiiThreeOctets\string~}}
+ \UTFviiiLoop
+
+ \countUTFx = "F0
+ \countUTFy = "F4
+ \def\UTFviiiTmp{%
+ \xdef~{\noexpand\UTFviiiFourOctets\string~}}
+ \UTFviiiLoop
+\endgroup
+
+\begingroup
+ \catcode`\"=12
+ \catcode`\<=12
+ \catcode`\.=12
+ \catcode`\,=12
+ \catcode`\;=12
+ \catcode`\!=12
+ \catcode`\~=13
+
+ \gdef\DeclareUnicodeCharacter#1#2{%
+ \countUTFz = "#1\relax
+ %\wlog{\space\space defining Unicode char U+#1 (decimal \the\countUTFz)}%
+ \begingroup
+ \parseXMLCharref
+ \def\UTFviiiTwoOctets##1##2{%
+ \csname u8:##1\string ##2\endcsname}%
+ \def\UTFviiiThreeOctets##1##2##3{%
+ \csname u8:##1\string ##2\string ##3\endcsname}%
+ \def\UTFviiiFourOctets##1##2##3##4{%
+ \csname u8:##1\string ##2\string ##3\string ##4\endcsname}%
+ \expandafter\expandafter\expandafter\expandafter
+ \expandafter\expandafter\expandafter
+ \gdef\UTFviiiTmp{#2}%
+ \endgroup}
+
+ \gdef\parseXMLCharref{%
+ \ifnum\countUTFz < "A0\relax
+ \errhelp = \EMsimple
+ \errmessage{Cannot define Unicode char value < 00A0}%
+ \else\ifnum\countUTFz < "800\relax
+ \parseUTFviiiA,%
+ \parseUTFviiiB C\UTFviiiTwoOctets.,%
+ \else\ifnum\countUTFz < "10000\relax
+ \parseUTFviiiA;%
+ \parseUTFviiiA,%
+ \parseUTFviiiB E\UTFviiiThreeOctets.{,;}%
+ \else
+ \parseUTFviiiA;%
+ \parseUTFviiiA,%
+ \parseUTFviiiA!%
+ \parseUTFviiiB F\UTFviiiFourOctets.{!,;}%
+ \fi\fi\fi
+ }
+
+ \gdef\parseUTFviiiA#1{%
+ \countUTFx = \countUTFz
+ \divide\countUTFz by 64
+ \countUTFy = \countUTFz
+ \multiply\countUTFz by 64
+ \advance\countUTFx by -\countUTFz
+ \advance\countUTFx by 128
+ \uccode `#1\countUTFx
+ \countUTFz = \countUTFy}
+
+ \gdef\parseUTFviiiB#1#2#3#4{%
+ \advance\countUTFz by "#10\relax
+ \uccode `#3\countUTFz
+ \uppercase{\gdef\UTFviiiTmp{#2#3#4}}}
+\endgroup
+
+\def\utfeightchardefs{%
+ \DeclareUnicodeCharacter{00A0}{\tie}
+ \DeclareUnicodeCharacter{00A1}{\exclamdown}
+ \DeclareUnicodeCharacter{00A3}{\pounds}
+ \DeclareUnicodeCharacter{00A8}{\"{ }}
+ \DeclareUnicodeCharacter{00A9}{\copyright}
+ \DeclareUnicodeCharacter{00AA}{\ordf}
+ \DeclareUnicodeCharacter{00AB}{\guillemetleft}
+ \DeclareUnicodeCharacter{00AD}{\-}
+ \DeclareUnicodeCharacter{00AE}{\registeredsymbol}
+ \DeclareUnicodeCharacter{00AF}{\={ }}
+
+ \DeclareUnicodeCharacter{00B0}{\ringaccent{ }}
+ \DeclareUnicodeCharacter{00B4}{\'{ }}
+ \DeclareUnicodeCharacter{00B8}{\cedilla{ }}
+ \DeclareUnicodeCharacter{00BA}{\ordm}
+ \DeclareUnicodeCharacter{00BB}{\guillemetright}
+ \DeclareUnicodeCharacter{00BF}{\questiondown}
+
+ \DeclareUnicodeCharacter{00C0}{\`A}
+ \DeclareUnicodeCharacter{00C1}{\'A}
+ \DeclareUnicodeCharacter{00C2}{\^A}
+ \DeclareUnicodeCharacter{00C3}{\~A}
+ \DeclareUnicodeCharacter{00C4}{\"A}
+ \DeclareUnicodeCharacter{00C5}{\AA}
+ \DeclareUnicodeCharacter{00C6}{\AE}
+ \DeclareUnicodeCharacter{00C7}{\cedilla{C}}
+ \DeclareUnicodeCharacter{00C8}{\`E}
+ \DeclareUnicodeCharacter{00C9}{\'E}
+ \DeclareUnicodeCharacter{00CA}{\^E}
+ \DeclareUnicodeCharacter{00CB}{\"E}
+ \DeclareUnicodeCharacter{00CC}{\`I}
+ \DeclareUnicodeCharacter{00CD}{\'I}
+ \DeclareUnicodeCharacter{00CE}{\^I}
+ \DeclareUnicodeCharacter{00CF}{\"I}
+
+ \DeclareUnicodeCharacter{00D0}{\DH}
+ \DeclareUnicodeCharacter{00D1}{\~N}
+ \DeclareUnicodeCharacter{00D2}{\`O}
+ \DeclareUnicodeCharacter{00D3}{\'O}
+ \DeclareUnicodeCharacter{00D4}{\^O}
+ \DeclareUnicodeCharacter{00D5}{\~O}
+ \DeclareUnicodeCharacter{00D6}{\"O}
+ \DeclareUnicodeCharacter{00D8}{\O}
+ \DeclareUnicodeCharacter{00D9}{\`U}
+ \DeclareUnicodeCharacter{00DA}{\'U}
+ \DeclareUnicodeCharacter{00DB}{\^U}
+ \DeclareUnicodeCharacter{00DC}{\"U}
+ \DeclareUnicodeCharacter{00DD}{\'Y}
+ \DeclareUnicodeCharacter{00DE}{\TH}
+ \DeclareUnicodeCharacter{00DF}{\ss}
+
+ \DeclareUnicodeCharacter{00E0}{\`a}
+ \DeclareUnicodeCharacter{00E1}{\'a}
+ \DeclareUnicodeCharacter{00E2}{\^a}
+ \DeclareUnicodeCharacter{00E3}{\~a}
+ \DeclareUnicodeCharacter{00E4}{\"a}
+ \DeclareUnicodeCharacter{00E5}{\aa}
+ \DeclareUnicodeCharacter{00E6}{\ae}
+ \DeclareUnicodeCharacter{00E7}{\cedilla{c}}
+ \DeclareUnicodeCharacter{00E8}{\`e}
+ \DeclareUnicodeCharacter{00E9}{\'e}
+ \DeclareUnicodeCharacter{00EA}{\^e}
+ \DeclareUnicodeCharacter{00EB}{\"e}
+ \DeclareUnicodeCharacter{00EC}{\`{\dotless{i}}}
+ \DeclareUnicodeCharacter{00ED}{\'{\dotless{i}}}
+ \DeclareUnicodeCharacter{00EE}{\^{\dotless{i}}}
+ \DeclareUnicodeCharacter{00EF}{\"{\dotless{i}}}
+
+ \DeclareUnicodeCharacter{00F0}{\dh}
+ \DeclareUnicodeCharacter{00F1}{\~n}
+ \DeclareUnicodeCharacter{00F2}{\`o}
+ \DeclareUnicodeCharacter{00F3}{\'o}
+ \DeclareUnicodeCharacter{00F4}{\^o}
+ \DeclareUnicodeCharacter{00F5}{\~o}
+ \DeclareUnicodeCharacter{00F6}{\"o}
+ \DeclareUnicodeCharacter{00F8}{\o}
+ \DeclareUnicodeCharacter{00F9}{\`u}
+ \DeclareUnicodeCharacter{00FA}{\'u}
+ \DeclareUnicodeCharacter{00FB}{\^u}
+ \DeclareUnicodeCharacter{00FC}{\"u}
+ \DeclareUnicodeCharacter{00FD}{\'y}
+ \DeclareUnicodeCharacter{00FE}{\th}
+ \DeclareUnicodeCharacter{00FF}{\"y}
+
+ \DeclareUnicodeCharacter{0100}{\=A}
+ \DeclareUnicodeCharacter{0101}{\=a}
+ \DeclareUnicodeCharacter{0102}{\u{A}}
+ \DeclareUnicodeCharacter{0103}{\u{a}}
+ \DeclareUnicodeCharacter{0104}{\ogonek{A}}
+ \DeclareUnicodeCharacter{0105}{\ogonek{a}}
+ \DeclareUnicodeCharacter{0106}{\'C}
+ \DeclareUnicodeCharacter{0107}{\'c}
+ \DeclareUnicodeCharacter{0108}{\^C}
+ \DeclareUnicodeCharacter{0109}{\^c}
+ \DeclareUnicodeCharacter{0118}{\ogonek{E}}
+ \DeclareUnicodeCharacter{0119}{\ogonek{e}}
+ \DeclareUnicodeCharacter{010A}{\dotaccent{C}}
+ \DeclareUnicodeCharacter{010B}{\dotaccent{c}}
+ \DeclareUnicodeCharacter{010C}{\v{C}}
+ \DeclareUnicodeCharacter{010D}{\v{c}}
+ \DeclareUnicodeCharacter{010E}{\v{D}}
+
+ \DeclareUnicodeCharacter{0112}{\=E}
+ \DeclareUnicodeCharacter{0113}{\=e}
+ \DeclareUnicodeCharacter{0114}{\u{E}}
+ \DeclareUnicodeCharacter{0115}{\u{e}}
+ \DeclareUnicodeCharacter{0116}{\dotaccent{E}}
+ \DeclareUnicodeCharacter{0117}{\dotaccent{e}}
+ \DeclareUnicodeCharacter{011A}{\v{E}}
+ \DeclareUnicodeCharacter{011B}{\v{e}}
+ \DeclareUnicodeCharacter{011C}{\^G}
+ \DeclareUnicodeCharacter{011D}{\^g}
+ \DeclareUnicodeCharacter{011E}{\u{G}}
+ \DeclareUnicodeCharacter{011F}{\u{g}}
+
+ \DeclareUnicodeCharacter{0120}{\dotaccent{G}}
+ \DeclareUnicodeCharacter{0121}{\dotaccent{g}}
+ \DeclareUnicodeCharacter{0124}{\^H}
+ \DeclareUnicodeCharacter{0125}{\^h}
+ \DeclareUnicodeCharacter{0128}{\~I}
+ \DeclareUnicodeCharacter{0129}{\~{\dotless{i}}}
+ \DeclareUnicodeCharacter{012A}{\=I}
+ \DeclareUnicodeCharacter{012B}{\={\dotless{i}}}
+ \DeclareUnicodeCharacter{012C}{\u{I}}
+ \DeclareUnicodeCharacter{012D}{\u{\dotless{i}}}
+
+ \DeclareUnicodeCharacter{0130}{\dotaccent{I}}
+ \DeclareUnicodeCharacter{0131}{\dotless{i}}
+ \DeclareUnicodeCharacter{0132}{IJ}
+ \DeclareUnicodeCharacter{0133}{ij}
+ \DeclareUnicodeCharacter{0134}{\^J}
+ \DeclareUnicodeCharacter{0135}{\^{\dotless{j}}}
+ \DeclareUnicodeCharacter{0139}{\'L}
+ \DeclareUnicodeCharacter{013A}{\'l}
+
+ \DeclareUnicodeCharacter{0141}{\L}
+ \DeclareUnicodeCharacter{0142}{\l}
+ \DeclareUnicodeCharacter{0143}{\'N}
+ \DeclareUnicodeCharacter{0144}{\'n}
+ \DeclareUnicodeCharacter{0147}{\v{N}}
+ \DeclareUnicodeCharacter{0148}{\v{n}}
+ \DeclareUnicodeCharacter{014C}{\=O}
+ \DeclareUnicodeCharacter{014D}{\=o}
+ \DeclareUnicodeCharacter{014E}{\u{O}}
+ \DeclareUnicodeCharacter{014F}{\u{o}}
+
+ \DeclareUnicodeCharacter{0150}{\H{O}}
+ \DeclareUnicodeCharacter{0151}{\H{o}}
+ \DeclareUnicodeCharacter{0152}{\OE}
+ \DeclareUnicodeCharacter{0153}{\oe}
+ \DeclareUnicodeCharacter{0154}{\'R}
+ \DeclareUnicodeCharacter{0155}{\'r}
+ \DeclareUnicodeCharacter{0158}{\v{R}}
+ \DeclareUnicodeCharacter{0159}{\v{r}}
+ \DeclareUnicodeCharacter{015A}{\'S}
+ \DeclareUnicodeCharacter{015B}{\'s}
+ \DeclareUnicodeCharacter{015C}{\^S}
+ \DeclareUnicodeCharacter{015D}{\^s}
+ \DeclareUnicodeCharacter{015E}{\cedilla{S}}
+ \DeclareUnicodeCharacter{015F}{\cedilla{s}}
+
+ \DeclareUnicodeCharacter{0160}{\v{S}}
+ \DeclareUnicodeCharacter{0161}{\v{s}}
+ \DeclareUnicodeCharacter{0162}{\cedilla{t}}
+ \DeclareUnicodeCharacter{0163}{\cedilla{T}}
+ \DeclareUnicodeCharacter{0164}{\v{T}}
+
+ \DeclareUnicodeCharacter{0168}{\~U}
+ \DeclareUnicodeCharacter{0169}{\~u}
+ \DeclareUnicodeCharacter{016A}{\=U}
+ \DeclareUnicodeCharacter{016B}{\=u}
+ \DeclareUnicodeCharacter{016C}{\u{U}}
+ \DeclareUnicodeCharacter{016D}{\u{u}}
+ \DeclareUnicodeCharacter{016E}{\ringaccent{U}}
+ \DeclareUnicodeCharacter{016F}{\ringaccent{u}}
+
+ \DeclareUnicodeCharacter{0170}{\H{U}}
+ \DeclareUnicodeCharacter{0171}{\H{u}}
+ \DeclareUnicodeCharacter{0174}{\^W}
+ \DeclareUnicodeCharacter{0175}{\^w}
+ \DeclareUnicodeCharacter{0176}{\^Y}
+ \DeclareUnicodeCharacter{0177}{\^y}
+ \DeclareUnicodeCharacter{0178}{\"Y}
+ \DeclareUnicodeCharacter{0179}{\'Z}
+ \DeclareUnicodeCharacter{017A}{\'z}
+ \DeclareUnicodeCharacter{017B}{\dotaccent{Z}}
+ \DeclareUnicodeCharacter{017C}{\dotaccent{z}}
+ \DeclareUnicodeCharacter{017D}{\v{Z}}
+ \DeclareUnicodeCharacter{017E}{\v{z}}
+
+ \DeclareUnicodeCharacter{01C4}{D\v{Z}}
+ \DeclareUnicodeCharacter{01C5}{D\v{z}}
+ \DeclareUnicodeCharacter{01C6}{d\v{z}}
+ \DeclareUnicodeCharacter{01C7}{LJ}
+ \DeclareUnicodeCharacter{01C8}{Lj}
+ \DeclareUnicodeCharacter{01C9}{lj}
+ \DeclareUnicodeCharacter{01CA}{NJ}
+ \DeclareUnicodeCharacter{01CB}{Nj}
+ \DeclareUnicodeCharacter{01CC}{nj}
+ \DeclareUnicodeCharacter{01CD}{\v{A}}
+ \DeclareUnicodeCharacter{01CE}{\v{a}}
+ \DeclareUnicodeCharacter{01CF}{\v{I}}
+
+ \DeclareUnicodeCharacter{01D0}{\v{\dotless{i}}}
+ \DeclareUnicodeCharacter{01D1}{\v{O}}
+ \DeclareUnicodeCharacter{01D2}{\v{o}}
+ \DeclareUnicodeCharacter{01D3}{\v{U}}
+ \DeclareUnicodeCharacter{01D4}{\v{u}}
+
+ \DeclareUnicodeCharacter{01E2}{\={\AE}}
+ \DeclareUnicodeCharacter{01E3}{\={\ae}}
+ \DeclareUnicodeCharacter{01E6}{\v{G}}
+ \DeclareUnicodeCharacter{01E7}{\v{g}}
+ \DeclareUnicodeCharacter{01E8}{\v{K}}
+ \DeclareUnicodeCharacter{01E9}{\v{k}}
+
+ \DeclareUnicodeCharacter{01F0}{\v{\dotless{j}}}
+ \DeclareUnicodeCharacter{01F1}{DZ}
+ \DeclareUnicodeCharacter{01F2}{Dz}
+ \DeclareUnicodeCharacter{01F3}{dz}
+ \DeclareUnicodeCharacter{01F4}{\'G}
+ \DeclareUnicodeCharacter{01F5}{\'g}
+ \DeclareUnicodeCharacter{01F8}{\`N}
+ \DeclareUnicodeCharacter{01F9}{\`n}
+ \DeclareUnicodeCharacter{01FC}{\'{\AE}}
+ \DeclareUnicodeCharacter{01FD}{\'{\ae}}
+ \DeclareUnicodeCharacter{01FE}{\'{\O}}
+ \DeclareUnicodeCharacter{01FF}{\'{\o}}
+
+ \DeclareUnicodeCharacter{021E}{\v{H}}
+ \DeclareUnicodeCharacter{021F}{\v{h}}
+
+ \DeclareUnicodeCharacter{0226}{\dotaccent{A}}
+ \DeclareUnicodeCharacter{0227}{\dotaccent{a}}
+ \DeclareUnicodeCharacter{0228}{\cedilla{E}}
+ \DeclareUnicodeCharacter{0229}{\cedilla{e}}
+ \DeclareUnicodeCharacter{022E}{\dotaccent{O}}
+ \DeclareUnicodeCharacter{022F}{\dotaccent{o}}
+
+ \DeclareUnicodeCharacter{0232}{\=Y}
+ \DeclareUnicodeCharacter{0233}{\=y}
+ \DeclareUnicodeCharacter{0237}{\dotless{j}}
+
+ \DeclareUnicodeCharacter{02DB}{\ogonek{ }}
+
+ \DeclareUnicodeCharacter{1E02}{\dotaccent{B}}
+ \DeclareUnicodeCharacter{1E03}{\dotaccent{b}}
+ \DeclareUnicodeCharacter{1E04}{\udotaccent{B}}
+ \DeclareUnicodeCharacter{1E05}{\udotaccent{b}}
+ \DeclareUnicodeCharacter{1E06}{\ubaraccent{B}}
+ \DeclareUnicodeCharacter{1E07}{\ubaraccent{b}}
+ \DeclareUnicodeCharacter{1E0A}{\dotaccent{D}}
+ \DeclareUnicodeCharacter{1E0B}{\dotaccent{d}}
+ \DeclareUnicodeCharacter{1E0C}{\udotaccent{D}}
+ \DeclareUnicodeCharacter{1E0D}{\udotaccent{d}}
+ \DeclareUnicodeCharacter{1E0E}{\ubaraccent{D}}
+ \DeclareUnicodeCharacter{1E0F}{\ubaraccent{d}}
+
+ \DeclareUnicodeCharacter{1E1E}{\dotaccent{F}}
+ \DeclareUnicodeCharacter{1E1F}{\dotaccent{f}}
+
+ \DeclareUnicodeCharacter{1E20}{\=G}
+ \DeclareUnicodeCharacter{1E21}{\=g}
+ \DeclareUnicodeCharacter{1E22}{\dotaccent{H}}
+ \DeclareUnicodeCharacter{1E23}{\dotaccent{h}}
+ \DeclareUnicodeCharacter{1E24}{\udotaccent{H}}
+ \DeclareUnicodeCharacter{1E25}{\udotaccent{h}}
+ \DeclareUnicodeCharacter{1E26}{\"H}
+ \DeclareUnicodeCharacter{1E27}{\"h}
+
+ \DeclareUnicodeCharacter{1E30}{\'K}
+ \DeclareUnicodeCharacter{1E31}{\'k}
+ \DeclareUnicodeCharacter{1E32}{\udotaccent{K}}
+ \DeclareUnicodeCharacter{1E33}{\udotaccent{k}}
+ \DeclareUnicodeCharacter{1E34}{\ubaraccent{K}}
+ \DeclareUnicodeCharacter{1E35}{\ubaraccent{k}}
+ \DeclareUnicodeCharacter{1E36}{\udotaccent{L}}
+ \DeclareUnicodeCharacter{1E37}{\udotaccent{l}}
+ \DeclareUnicodeCharacter{1E3A}{\ubaraccent{L}}
+ \DeclareUnicodeCharacter{1E3B}{\ubaraccent{l}}
+ \DeclareUnicodeCharacter{1E3E}{\'M}
+ \DeclareUnicodeCharacter{1E3F}{\'m}
+
+ \DeclareUnicodeCharacter{1E40}{\dotaccent{M}}
+ \DeclareUnicodeCharacter{1E41}{\dotaccent{m}}
+ \DeclareUnicodeCharacter{1E42}{\udotaccent{M}}
+ \DeclareUnicodeCharacter{1E43}{\udotaccent{m}}
+ \DeclareUnicodeCharacter{1E44}{\dotaccent{N}}
+ \DeclareUnicodeCharacter{1E45}{\dotaccent{n}}
+ \DeclareUnicodeCharacter{1E46}{\udotaccent{N}}
+ \DeclareUnicodeCharacter{1E47}{\udotaccent{n}}
+ \DeclareUnicodeCharacter{1E48}{\ubaraccent{N}}
+ \DeclareUnicodeCharacter{1E49}{\ubaraccent{n}}
+
+ \DeclareUnicodeCharacter{1E54}{\'P}
+ \DeclareUnicodeCharacter{1E55}{\'p}
+ \DeclareUnicodeCharacter{1E56}{\dotaccent{P}}
+ \DeclareUnicodeCharacter{1E57}{\dotaccent{p}}
+ \DeclareUnicodeCharacter{1E58}{\dotaccent{R}}
+ \DeclareUnicodeCharacter{1E59}{\dotaccent{r}}
+ \DeclareUnicodeCharacter{1E5A}{\udotaccent{R}}
+ \DeclareUnicodeCharacter{1E5B}{\udotaccent{r}}
+ \DeclareUnicodeCharacter{1E5E}{\ubaraccent{R}}
+ \DeclareUnicodeCharacter{1E5F}{\ubaraccent{r}}
+
+ \DeclareUnicodeCharacter{1E60}{\dotaccent{S}}
+ \DeclareUnicodeCharacter{1E61}{\dotaccent{s}}
+ \DeclareUnicodeCharacter{1E62}{\udotaccent{S}}
+ \DeclareUnicodeCharacter{1E63}{\udotaccent{s}}
+ \DeclareUnicodeCharacter{1E6A}{\dotaccent{T}}
+ \DeclareUnicodeCharacter{1E6B}{\dotaccent{t}}
+ \DeclareUnicodeCharacter{1E6C}{\udotaccent{T}}
+ \DeclareUnicodeCharacter{1E6D}{\udotaccent{t}}
+ \DeclareUnicodeCharacter{1E6E}{\ubaraccent{T}}
+ \DeclareUnicodeCharacter{1E6F}{\ubaraccent{t}}
+
+ \DeclareUnicodeCharacter{1E7C}{\~V}
+ \DeclareUnicodeCharacter{1E7D}{\~v}
+ \DeclareUnicodeCharacter{1E7E}{\udotaccent{V}}
+ \DeclareUnicodeCharacter{1E7F}{\udotaccent{v}}
+
+ \DeclareUnicodeCharacter{1E80}{\`W}
+ \DeclareUnicodeCharacter{1E81}{\`w}
+ \DeclareUnicodeCharacter{1E82}{\'W}
+ \DeclareUnicodeCharacter{1E83}{\'w}
+ \DeclareUnicodeCharacter{1E84}{\"W}
+ \DeclareUnicodeCharacter{1E85}{\"w}
+ \DeclareUnicodeCharacter{1E86}{\dotaccent{W}}
+ \DeclareUnicodeCharacter{1E87}{\dotaccent{w}}
+ \DeclareUnicodeCharacter{1E88}{\udotaccent{W}}
+ \DeclareUnicodeCharacter{1E89}{\udotaccent{w}}
+ \DeclareUnicodeCharacter{1E8A}{\dotaccent{X}}
+ \DeclareUnicodeCharacter{1E8B}{\dotaccent{x}}
+ \DeclareUnicodeCharacter{1E8C}{\"X}
+ \DeclareUnicodeCharacter{1E8D}{\"x}
+ \DeclareUnicodeCharacter{1E8E}{\dotaccent{Y}}
+ \DeclareUnicodeCharacter{1E8F}{\dotaccent{y}}
+
+ \DeclareUnicodeCharacter{1E90}{\^Z}
+ \DeclareUnicodeCharacter{1E91}{\^z}
+ \DeclareUnicodeCharacter{1E92}{\udotaccent{Z}}
+ \DeclareUnicodeCharacter{1E93}{\udotaccent{z}}
+ \DeclareUnicodeCharacter{1E94}{\ubaraccent{Z}}
+ \DeclareUnicodeCharacter{1E95}{\ubaraccent{z}}
+ \DeclareUnicodeCharacter{1E96}{\ubaraccent{h}}
+ \DeclareUnicodeCharacter{1E97}{\"t}
+ \DeclareUnicodeCharacter{1E98}{\ringaccent{w}}
+ \DeclareUnicodeCharacter{1E99}{\ringaccent{y}}
+
+ \DeclareUnicodeCharacter{1EA0}{\udotaccent{A}}
+ \DeclareUnicodeCharacter{1EA1}{\udotaccent{a}}
+
+ \DeclareUnicodeCharacter{1EB8}{\udotaccent{E}}
+ \DeclareUnicodeCharacter{1EB9}{\udotaccent{e}}
+ \DeclareUnicodeCharacter{1EBC}{\~E}
+ \DeclareUnicodeCharacter{1EBD}{\~e}
+
+ \DeclareUnicodeCharacter{1ECA}{\udotaccent{I}}
+ \DeclareUnicodeCharacter{1ECB}{\udotaccent{i}}
+ \DeclareUnicodeCharacter{1ECC}{\udotaccent{O}}
+ \DeclareUnicodeCharacter{1ECD}{\udotaccent{o}}
+
+ \DeclareUnicodeCharacter{1EE4}{\udotaccent{U}}
+ \DeclareUnicodeCharacter{1EE5}{\udotaccent{u}}
+
+ \DeclareUnicodeCharacter{1EF2}{\`Y}
+ \DeclareUnicodeCharacter{1EF3}{\`y}
+ \DeclareUnicodeCharacter{1EF4}{\udotaccent{Y}}
+
+ \DeclareUnicodeCharacter{1EF8}{\~Y}
+ \DeclareUnicodeCharacter{1EF9}{\~y}
+
+ \DeclareUnicodeCharacter{2013}{--}
+ \DeclareUnicodeCharacter{2014}{---}
+ \DeclareUnicodeCharacter{2018}{\quoteleft}
+ \DeclareUnicodeCharacter{2019}{\quoteright}
+ \DeclareUnicodeCharacter{201A}{\quotesinglbase}
+ \DeclareUnicodeCharacter{201C}{\quotedblleft}
+ \DeclareUnicodeCharacter{201D}{\quotedblright}
+ \DeclareUnicodeCharacter{201E}{\quotedblbase}
+ \DeclareUnicodeCharacter{2022}{\bullet}
+ \DeclareUnicodeCharacter{2026}{\dots}
+ \DeclareUnicodeCharacter{2039}{\guilsinglleft}
+ \DeclareUnicodeCharacter{203A}{\guilsinglright}
+ \DeclareUnicodeCharacter{20AC}{\euro}
+
+ \DeclareUnicodeCharacter{2192}{\expansion}
+ \DeclareUnicodeCharacter{21D2}{\result}
+
+ \DeclareUnicodeCharacter{2212}{\minus}
+ \DeclareUnicodeCharacter{2217}{\point}
+ \DeclareUnicodeCharacter{2261}{\equiv}
+}% end of \utfeightchardefs
+
+
+% US-ASCII character definitions.
+\def\asciichardefs{% nothing need be done
+ \relax
+}
+
+% Make non-ASCII characters printable again for compatibility with
+% existing Texinfo documents that may use them, even without declaring a
+% document encoding.
+%
+\setnonasciicharscatcode \other
+
+
+\message{formatting,}
+
+\newdimen\defaultparindent \defaultparindent = 15pt
+
+\chapheadingskip = 15pt plus 4pt minus 2pt
+\secheadingskip = 12pt plus 3pt minus 2pt
+\subsecheadingskip = 9pt plus 2pt minus 2pt
+
+% Prevent underfull vbox error messages.
+\vbadness = 10000
+
+% Don't be very finicky about underfull hboxes, either.
+\hbadness = 6666
+
+% Following George Bush, get rid of widows and orphans.
+\widowpenalty=10000
+\clubpenalty=10000
+
+% Use TeX 3.0's \emergencystretch to help line breaking, but if we're
+% using an old version of TeX, don't do anything. We want the amount of
+% stretch added to depend on the line length, hence the dependence on
+% \hsize. We call this whenever the paper size is set.
+%
+\def\setemergencystretch{%
+ \ifx\emergencystretch\thisisundefined
+ % Allow us to assign to \emergencystretch anyway.
+ \def\emergencystretch{\dimen0}%
+ \else
+ \emergencystretch = .15\hsize
+ \fi
+}
+
+% Parameters in order: 1) textheight; 2) textwidth;
+% 3) voffset; 4) hoffset; 5) binding offset; 6) topskip;
+% 7) physical page height; 8) physical page width.
+%
+% We also call \setleading{\textleading}, so the caller should define
+% \textleading. The caller should also set \parskip.
+%
+\def\internalpagesizes#1#2#3#4#5#6#7#8{%
+ \voffset = #3\relax
+ \topskip = #6\relax
+ \splittopskip = \topskip
+ %
+ \vsize = #1\relax
+ \advance\vsize by \topskip
+ \outervsize = \vsize
+ \advance\outervsize by 2\topandbottommargin
+ \pageheight = \vsize
+ %
+ \hsize = #2\relax
+ \outerhsize = \hsize
+ \advance\outerhsize by 0.5in
+ \pagewidth = \hsize
+ %
+ \normaloffset = #4\relax
+ \bindingoffset = #5\relax
+ %
+ \ifpdf
+ \pdfpageheight #7\relax
+ \pdfpagewidth #8\relax
+ % if we don't reset these, they will remain at "1 true in" of
+ % whatever layout pdftex was dumped with.
+ \pdfhorigin = 1 true in
+ \pdfvorigin = 1 true in
+ \fi
+ %
+ \setleading{\textleading}
+ %
+ \parindent = \defaultparindent
+ \setemergencystretch
+}
+
+% @letterpaper (the default).
+\def\letterpaper{{\globaldefs = 1
+ \parskip = 3pt plus 2pt minus 1pt
+ \textleading = 13.2pt
+ %
+ % If page is nothing but text, make it come out even.
+ \internalpagesizes{607.2pt}{6in}% that's 46 lines
+ {\voffset}{.25in}%
+ {\bindingoffset}{36pt}%
+ {11in}{8.5in}%
+}}
+
+% Use @smallbook to reset parameters for 7x9.25 trim size.
+\def\smallbook{{\globaldefs = 1
+ \parskip = 2pt plus 1pt
+ \textleading = 12pt
+ %
+ \internalpagesizes{7.5in}{5in}%
+ {-.2in}{0in}%
+ {\bindingoffset}{16pt}%
+ {9.25in}{7in}%
+ %
+ \lispnarrowing = 0.3in
+ \tolerance = 700
+ \hfuzz = 1pt
+ \contentsrightmargin = 0pt
+ \defbodyindent = .5cm
+}}
+
+% Use @smallerbook to reset parameters for 6x9 trim size.
+% (Just testing, parameters still in flux.)
+\def\smallerbook{{\globaldefs = 1
+ \parskip = 1.5pt plus 1pt
+ \textleading = 12pt
+ %
+ \internalpagesizes{7.4in}{4.8in}%
+ {-.2in}{-.4in}%
+ {0pt}{14pt}%
+ {9in}{6in}%
+ %
+ \lispnarrowing = 0.25in
+ \tolerance = 700
+ \hfuzz = 1pt
+ \contentsrightmargin = 0pt
+ \defbodyindent = .4cm
+}}
+
+% Use @afourpaper to print on European A4 paper.
+\def\afourpaper{{\globaldefs = 1
+ \parskip = 3pt plus 2pt minus 1pt
+ \textleading = 13.2pt
+ %
+ % Double-side printing via postscript on Laserjet 4050
+ % prints double-sided nicely when \bindingoffset=10mm and \hoffset=-6mm.
+ % To change the settings for a different printer or situation, adjust
+ % \normaloffset until the front-side and back-side texts align. Then
+ % do the same for \bindingoffset. You can set these for testing in
+ % your texinfo source file like this:
+ % @tex
+ % \global\normaloffset = -6mm
+ % \global\bindingoffset = 10mm
+ % @end tex
+ \internalpagesizes{673.2pt}{160mm}% that's 51 lines
+ {\voffset}{\hoffset}%
+ {\bindingoffset}{44pt}%
+ {297mm}{210mm}%
+ %
+ \tolerance = 700
+ \hfuzz = 1pt
+ \contentsrightmargin = 0pt
+ \defbodyindent = 5mm
+}}
+
+% Use @afivepaper to print on European A5 paper.
+% From romildo@urano.iceb.ufop.br, 2 July 2000.
+% He also recommends making @example and @lisp be small.
+\def\afivepaper{{\globaldefs = 1
+ \parskip = 2pt plus 1pt minus 0.1pt
+ \textleading = 12.5pt
+ %
+ \internalpagesizes{160mm}{120mm}%
+ {\voffset}{\hoffset}%
+ {\bindingoffset}{8pt}%
+ {210mm}{148mm}%
+ %
+ \lispnarrowing = 0.2in
+ \tolerance = 800
+ \hfuzz = 1.2pt
+ \contentsrightmargin = 0pt
+ \defbodyindent = 2mm
+ \tableindent = 12mm
+}}
+
+% A specific text layout, 24x15cm overall, intended for A4 paper.
+\def\afourlatex{{\globaldefs = 1
+ \afourpaper
+ \internalpagesizes{237mm}{150mm}%
+ {\voffset}{4.6mm}%
+ {\bindingoffset}{7mm}%
+ {297mm}{210mm}%
+ %
+ % Must explicitly reset to 0 because we call \afourpaper.
+ \globaldefs = 0
+}}
+
+% Use @afourwide to print on A4 paper in landscape format.
+\def\afourwide{{\globaldefs = 1
+ \afourpaper
+ \internalpagesizes{241mm}{165mm}%
+ {\voffset}{-2.95mm}%
+ {\bindingoffset}{7mm}%
+ {297mm}{210mm}%
+ \globaldefs = 0
+}}
+
+% @pagesizes TEXTHEIGHT[,TEXTWIDTH]
+% Perhaps we should allow setting the margins, \topskip, \parskip,
+% and/or leading, also. Or perhaps we should compute them somehow.
+%
+\parseargdef\pagesizes{\pagesizesyyy #1,,\finish}
+\def\pagesizesyyy#1,#2,#3\finish{{%
+ \setbox0 = \hbox{\ignorespaces #2}\ifdim\wd0 > 0pt \hsize=#2\relax \fi
+ \globaldefs = 1
+ %
+ \parskip = 3pt plus 2pt minus 1pt
+ \setleading{\textleading}%
+ %
+ \dimen0 = #1\relax
+ \advance\dimen0 by \voffset
+ %
+ \dimen2 = \hsize
+ \advance\dimen2 by \normaloffset
+ %
+ \internalpagesizes{#1}{\hsize}%
+ {\voffset}{\normaloffset}%
+ {\bindingoffset}{44pt}%
+ {\dimen0}{\dimen2}%
+}}
+
+% Set default to letter.
+%
+\letterpaper
+
+
+\message{and turning on texinfo input format.}
+
+\def^^L{\par} % remove \outer, so ^L can appear in an @comment
+
+% DEL is a comment character, in case @c does not suffice.
+\catcode`\^^? = 14
+
+% Define macros to output various characters with catcode for normal text.
+\catcode`\"=\other \def\normaldoublequote{"}
+\catcode`\$=\other \def\normaldollar{$}%$ font-lock fix
+\catcode`\+=\other \def\normalplus{+}
+\catcode`\<=\other \def\normalless{<}
+\catcode`\>=\other \def\normalgreater{>}
+\catcode`\^=\other \def\normalcaret{^}
+\catcode`\_=\other \def\normalunderscore{_}
+\catcode`\|=\other \def\normalverticalbar{|}
+\catcode`\~=\other \def\normaltilde{~}
+
+% This macro is used to make a character print one way in \tt
+% (where it can probably be output as-is), and another way in other fonts,
+% where something hairier probably needs to be done.
+%
+% #1 is what to print if we are indeed using \tt; #2 is what to print
+% otherwise. Since all the Computer Modern typewriter fonts have zero
+% interword stretch (and shrink), and it is reasonable to expect all
+% typewriter fonts to have this, we can check that font parameter.
+%
+\def\ifusingtt#1#2{\ifdim \fontdimen3\font=0pt #1\else #2\fi}
+
+% Same as above, but check for italic font. Actually this also catches
+% non-italic slanted fonts since it is impossible to distinguish them from
+% italic fonts. But since this is only used by $ and it uses \sl anyway
+% this is not a problem.
+\def\ifusingit#1#2{\ifdim \fontdimen1\font>0pt #1\else #2\fi}
+
+% Turn off all special characters except @
+% (and those which the user can use as if they were ordinary).
+% Most of these we simply print from the \tt font, but for some, we can
+% use math or other variants that look better in normal text.
+
+\catcode`\"=\active
+\def\activedoublequote{{\tt\char34}}
+\let"=\activedoublequote
+\catcode`\~=\active
+\def~{{\tt\char126}}
+\chardef\hat=`\^
+\catcode`\^=\active
+\def^{{\tt \hat}}
+
+\catcode`\_=\active
+\def_{\ifusingtt\normalunderscore\_}
+\let\realunder=_
+% Subroutine for the previous macro.
+\def\_{\leavevmode \kern.07em \vbox{\hrule width.3em height.1ex}\kern .07em }
+
+\catcode`\|=\active
+\def|{{\tt\char124}}
+\chardef \less=`\<
+\catcode`\<=\active
+\def<{{\tt \less}}
+\chardef \gtr=`\>
+\catcode`\>=\active
+\def>{{\tt \gtr}}
+\catcode`\+=\active
+\def+{{\tt \char 43}}
+\catcode`\$=\active
+\def${\ifusingit{{\sl\$}}\normaldollar}%$ font-lock fix
+
+% If a .fmt file is being used, characters that might appear in a file
+% name cannot be active until we have parsed the command line.
+% So turn them off again, and have \everyjob (or @setfilename) turn them on.
+% \otherifyactive is called near the end of this file.
+\def\otherifyactive{\catcode`+=\other \catcode`\_=\other}
+
+% Used sometimes to turn off (effectively) the active characters even after
+% parsing them.
+\def\turnoffactive{%
+ \normalturnoffactive
+ \otherbackslash
+}
+
+\catcode`\@=0
+
+% \backslashcurfont outputs one backslash character in current font,
+% as in \char`\\.
+\global\chardef\backslashcurfont=`\\
+\global\let\rawbackslashxx=\backslashcurfont % let existing .??s files work
+
+% \realbackslash is an actual character `\' with catcode other, and
+% \doublebackslash is two of them (for the pdf outlines).
+{\catcode`\\=\other @gdef@realbackslash{\} @gdef@doublebackslash{\\}}
+
+% In texinfo, backslash is an active character; it prints the backslash
+% in fixed width font.
+\catcode`\\=\active % @ for escape char from now on.
+
+% The story here is that in math mode, the \char of \backslashcurfont
+% ends up printing the roman \ from the math symbol font (because \char
+% in math mode uses the \mathcode, and plain.tex sets
+% \mathcode`\\="026E). It seems better for @backslashchar{} to always
+% print a typewriter backslash, hence we use an explicit \mathchar,
+% which is the decimal equivalent of "715c (class 7, e.g., use \fam;
+% ignored family value; char position "5C). We can't use " for the
+% usual hex value because it has already been made active.
+@def@normalbackslash{{@tt @ifmmode @mathchar29020 @else @backslashcurfont @fi}}
+@let@backslashchar = @normalbackslash % @backslashchar{} is for user documents.
+
+% On startup, @fixbackslash assigns:
+% @let \ = @normalbackslash
+% \rawbackslash defines an active \ to do \backslashcurfont.
+% \otherbackslash defines an active \ to be a literal `\' character with
+% catcode other. We switch back and forth between these.
+@gdef@rawbackslash{@let\=@backslashcurfont}
+@gdef@otherbackslash{@let\=@realbackslash}
+
+% Same as @turnoffactive except outputs \ as {\tt\char`\\} instead of
+% the literal character `\'. Also revert - to its normal character, in
+% case the active - from code has slipped in.
+%
+{@catcode`- = @active
+ @gdef@normalturnoffactive{%
+ @let-=@normaldash
+ @let"=@normaldoublequote
+ @let$=@normaldollar %$ font-lock fix
+ @let+=@normalplus
+ @let<=@normalless
+ @let>=@normalgreater
+ @let\=@normalbackslash
+ @let^=@normalcaret
+ @let_=@normalunderscore
+ @let|=@normalverticalbar
+ @let~=@normaltilde
+ @markupsetuplqdefault
+ @markupsetuprqdefault
+ @unsepspaces
+ }
+}
+
+% Make _ and + \other characters, temporarily.
+% This is canceled by @fixbackslash.
+@otherifyactive
+
+% If a .fmt file is being used, we don't want the `\input texinfo' to show up.
+% That is what \eatinput is for; after that, the `\' should revert to printing
+% a backslash.
+%
+@gdef@eatinput input texinfo{@fixbackslash}
+@global@let\ = @eatinput
+
+% On the other hand, perhaps the file did not have a `\input texinfo'. Then
+% the first `\' in the file would cause an error. This macro tries to fix
+% that, assuming it is called before the first `\' could plausibly occur.
+% Also turn back on active characters that might appear in the input
+% file name, in case not using a pre-dumped format.
+%
+@gdef@fixbackslash{%
+ @ifx\@eatinput @let\ = @normalbackslash @fi
+ @catcode`+=@active
+ @catcode`@_=@active
+}
+
+% Say @foo, not \foo, in error messages.
+@escapechar = `@@
+
+% These (along with & and #) are made active for url-breaking, so need
+% active definitions as the normal characters.
+@def@normaldot{.}
+@def@normalquest{?}
+@def@normalslash{/}
+
+% These look ok in all fonts, so just make them not special.
+% @hashchar{} gets its own user-level command, because of #line.
+@catcode`@& = @other @def@normalamp{&}
+@catcode`@# = @other @def@normalhash{#}
+@catcode`@% = @other @def@normalpercent{%}
+
+@let @hashchar = @normalhash
+
+@c Finally, make ` and ' active, so that txicodequoteundirected and
+@c txicodequotebacktick work right in, e.g., @w{@code{`foo'}}. If we
+@c don't make ` and ' active, @code will not get them as active chars.
+@c Do this last of all since we use ` in the previous @catcode assignments.
+@catcode`@'=@active
+@catcode`@`=@active
+@markupsetuplqdefault
+@markupsetuprqdefault
+
+@c Local variables:
+@c eval: (add-hook 'write-file-hooks 'time-stamp)
+@c page-delimiter: "^\\\\message"
+@c time-stamp-start: "def\\\\texinfoversion{"
+@c time-stamp-format: "%:y-%02m-%02d.%02H"
+@c time-stamp-end: "}"
+@c End:
+
+@c vim:sw=2:
+
+@ignore
+ arch-tag: e1b36e32-c96e-4135-a41a-0b2efa2ea115
+@end ignore
diff --git a/jni/ruby/ext/fiddle/pointer.c b/jni/ruby/ext/fiddle/pointer.c
new file mode 100644
index 0000000..a09daf7
--- /dev/null
+++ b/jni/ruby/ext/fiddle/pointer.c
@@ -0,0 +1,721 @@
+/* -*- C -*-
+ * $Id$
+ */
+
+#include <ruby/ruby.h>
+#include <ruby/io.h>
+#include <ctype.h>
+#include <fiddle.h>
+
+#ifdef PRIsVALUE
+# define RB_OBJ_CLASSNAME(obj) rb_obj_class(obj)
+# define RB_OBJ_STRING(obj) (obj)
+#else
+# define PRIsVALUE "s"
+# define RB_OBJ_CLASSNAME(obj) rb_obj_classname(obj)
+# define RB_OBJ_STRING(obj) StringValueCStr(obj)
+#endif
+
+VALUE rb_cPointer;
+
+typedef void (*freefunc_t)(void*);
+
+struct ptr_data {
+ void *ptr;
+ long size;
+ freefunc_t free;
+ VALUE wrap[2];
+};
+
+#define RPTR_DATA(obj) ((struct ptr_data *)(DATA_PTR(obj)))
+
+static inline freefunc_t
+get_freefunc(VALUE func, volatile VALUE *wrap)
+{
+ VALUE addrnum;
+ if (NIL_P(func)) {
+ *wrap = 0;
+ return NULL;
+ }
+ addrnum = rb_Integer(func);
+ *wrap = (addrnum != func) ? func : 0;
+ return (freefunc_t)(VALUE)NUM2PTR(addrnum);
+}
+
+static ID id_to_ptr;
+
+static void
+fiddle_ptr_mark(void *ptr)
+{
+ struct ptr_data *data = ptr;
+ if (data->wrap[0]) {
+ rb_gc_mark(data->wrap[0]);
+ }
+ if (data->wrap[1]) {
+ rb_gc_mark(data->wrap[1]);
+ }
+}
+
+static void
+fiddle_ptr_free(void *ptr)
+{
+ struct ptr_data *data = ptr;
+ if (data->ptr) {
+ if (data->free) {
+ (*(data->free))(data->ptr);
+ }
+ }
+ xfree(ptr);
+}
+
+static size_t
+fiddle_ptr_memsize(const void *ptr)
+{
+ const struct ptr_data *data = ptr;
+ return data ? sizeof(*data) + data->size : 0;
+}
+
+static const rb_data_type_t fiddle_ptr_data_type = {
+ "fiddle/pointer",
+ {fiddle_ptr_mark, fiddle_ptr_free, fiddle_ptr_memsize,},
+};
+
+static VALUE
+rb_fiddle_ptr_new2(VALUE klass, void *ptr, long size, freefunc_t func)
+{
+ struct ptr_data *data;
+ VALUE val;
+
+ val = TypedData_Make_Struct(klass, struct ptr_data, &fiddle_ptr_data_type, data);
+ data->ptr = ptr;
+ data->free = func;
+ data->size = size;
+ OBJ_TAINT(val);
+
+ return val;
+}
+
+static VALUE
+rb_fiddle_ptr_new(void *ptr, long size, freefunc_t func)
+{
+ return rb_fiddle_ptr_new2(rb_cPointer, ptr, size, func);
+}
+
+static VALUE
+rb_fiddle_ptr_malloc(long size, freefunc_t func)
+{
+ void *ptr;
+
+ ptr = ruby_xmalloc((size_t)size);
+ memset(ptr,0,(size_t)size);
+ return rb_fiddle_ptr_new(ptr, size, func);
+}
+
+static void *
+rb_fiddle_ptr2cptr(VALUE val)
+{
+ struct ptr_data *data;
+ void *ptr;
+
+ if (rb_obj_is_kind_of(val, rb_cPointer)) {
+ TypedData_Get_Struct(val, struct ptr_data, &fiddle_ptr_data_type, data);
+ ptr = data->ptr;
+ }
+ else if (val == Qnil) {
+ ptr = NULL;
+ }
+ else{
+ rb_raise(rb_eTypeError, "Fiddle::Pointer was expected");
+ }
+
+ return ptr;
+}
+
+static VALUE
+rb_fiddle_ptr_s_allocate(VALUE klass)
+{
+ VALUE obj;
+ struct ptr_data *data;
+
+ obj = TypedData_Make_Struct(klass, struct ptr_data, &fiddle_ptr_data_type, data);
+ data->ptr = 0;
+ data->size = 0;
+ data->free = 0;
+
+ return obj;
+}
+
+/*
+ * call-seq:
+ * Fiddle::Pointer.new(address) => fiddle_cptr
+ * new(address, size) => fiddle_cptr
+ * new(address, size, freefunc) => fiddle_cptr
+ *
+ * Create a new pointer to +address+ with an optional +size+ and +freefunc+.
+ *
+ * +freefunc+ will be called when the instance is garbage collected.
+ */
+static VALUE
+rb_fiddle_ptr_initialize(int argc, VALUE argv[], VALUE self)
+{
+ VALUE ptr, sym, size, wrap = 0, funcwrap = 0;
+ struct ptr_data *data;
+ void *p = NULL;
+ freefunc_t f = NULL;
+ long s = 0;
+
+ if (rb_scan_args(argc, argv, "12", &ptr, &size, &sym) >= 1) {
+ VALUE addrnum = rb_Integer(ptr);
+ if (addrnum != ptr) wrap = ptr;
+ p = NUM2PTR(addrnum);
+ }
+ if (argc >= 2) {
+ s = NUM2LONG(size);
+ }
+ if (argc >= 3) {
+ f = get_freefunc(sym, &funcwrap);
+ }
+
+ if (p) {
+ TypedData_Get_Struct(self, struct ptr_data, &fiddle_ptr_data_type, data);
+ if (data->ptr && data->free) {
+ /* Free previous memory. Use of inappropriate initialize may cause SEGV. */
+ (*(data->free))(data->ptr);
+ }
+ data->wrap[0] = wrap;
+ data->wrap[1] = funcwrap;
+ data->ptr = p;
+ data->size = s;
+ data->free = f;
+ }
+
+ return Qnil;
+}
+
+/*
+ * call-seq:
+ *
+ * Fiddle::Pointer.malloc(size, freefunc = nil) => fiddle pointer instance
+ *
+ * Allocate +size+ bytes of memory and associate it with an optional
+ * +freefunc+ that will be called when the pointer is garbage collected.
+ *
+ * +freefunc+ must be an address pointing to a function or an instance of
+ * Fiddle::Function
+ */
+static VALUE
+rb_fiddle_ptr_s_malloc(int argc, VALUE argv[], VALUE klass)
+{
+ VALUE size, sym, obj, wrap = 0;
+ long s;
+ freefunc_t f;
+
+ switch (rb_scan_args(argc, argv, "11", &size, &sym)) {
+ case 1:
+ s = NUM2LONG(size);
+ f = NULL;
+ break;
+ case 2:
+ s = NUM2LONG(size);
+ f = get_freefunc(sym, &wrap);
+ break;
+ default:
+ rb_bug("rb_fiddle_ptr_s_malloc");
+ }
+
+ obj = rb_fiddle_ptr_malloc(s,f);
+ if (wrap) RPTR_DATA(obj)->wrap[1] = wrap;
+
+ return obj;
+}
+
+/*
+ * call-seq: to_i
+ *
+ * Returns the integer memory location of this pointer.
+ */
+static VALUE
+rb_fiddle_ptr_to_i(VALUE self)
+{
+ struct ptr_data *data;
+
+ TypedData_Get_Struct(self, struct ptr_data, &fiddle_ptr_data_type, data);
+ return PTR2NUM(data->ptr);
+}
+
+/*
+ * call-seq: to_value
+ *
+ * Cast this pointer to a ruby object.
+ */
+static VALUE
+rb_fiddle_ptr_to_value(VALUE self)
+{
+ struct ptr_data *data;
+ TypedData_Get_Struct(self, struct ptr_data, &fiddle_ptr_data_type, data);
+ return (VALUE)(data->ptr);
+}
+
+/*
+ * call-seq: ptr
+ *
+ * Returns a new Fiddle::Pointer instance that is a dereferenced pointer for
+ * this pointer.
+ *
+ * Analogous to the star operator in C.
+ */
+static VALUE
+rb_fiddle_ptr_ptr(VALUE self)
+{
+ struct ptr_data *data;
+
+ TypedData_Get_Struct(self, struct ptr_data, &fiddle_ptr_data_type, data);
+ return rb_fiddle_ptr_new(*((void**)(data->ptr)),0,0);
+}
+
+/*
+ * call-seq: ref
+ *
+ * Returns a new Fiddle::Pointer instance that is a reference pointer for this
+ * pointer.
+ *
+ * Analogous to the ampersand operator in C.
+ */
+static VALUE
+rb_fiddle_ptr_ref(VALUE self)
+{
+ struct ptr_data *data;
+
+ TypedData_Get_Struct(self, struct ptr_data, &fiddle_ptr_data_type, data);
+ return rb_fiddle_ptr_new(&(data->ptr),0,0);
+}
+
+/*
+ * call-seq: null?
+ *
+ * Returns +true+ if this is a null pointer.
+ */
+static VALUE
+rb_fiddle_ptr_null_p(VALUE self)
+{
+ struct ptr_data *data;
+
+ TypedData_Get_Struct(self, struct ptr_data, &fiddle_ptr_data_type, data);
+ return data->ptr ? Qfalse : Qtrue;
+}
+
+/*
+ * call-seq: free=(function)
+ *
+ * Set the free function for this pointer to +function+ in the given
+ * Fiddle::Function.
+ */
+static VALUE
+rb_fiddle_ptr_free_set(VALUE self, VALUE val)
+{
+ struct ptr_data *data;
+
+ TypedData_Get_Struct(self, struct ptr_data, &fiddle_ptr_data_type, data);
+ data->free = get_freefunc(val, &data->wrap[1]);
+
+ return Qnil;
+}
+
+/*
+ * call-seq: free => Fiddle::Function
+ *
+ * Get the free function for this pointer.
+ *
+ * Returns a new instance of Fiddle::Function.
+ *
+ * See Fiddle::Function.new
+ */
+static VALUE
+rb_fiddle_ptr_free_get(VALUE self)
+{
+ struct ptr_data *pdata;
+ VALUE address;
+ VALUE arg_types;
+ VALUE ret_type;
+
+ TypedData_Get_Struct(self, struct ptr_data, &fiddle_ptr_data_type, pdata);
+
+ if (!pdata->free)
+ return Qnil;
+
+ address = PTR2NUM(pdata->free);
+ ret_type = INT2NUM(TYPE_VOID);
+ arg_types = rb_ary_new();
+ rb_ary_push(arg_types, INT2NUM(TYPE_VOIDP));
+
+ return rb_fiddle_new_function(address, arg_types, ret_type);
+}
+
+/*
+ * call-seq:
+ *
+ * ptr.to_s => string
+ * ptr.to_s(len) => string
+ *
+ * Returns the pointer contents as a string.
+ *
+ * When called with no arguments, this method will return the contents until
+ * the first NULL byte.
+ *
+ * When called with +len+, a string of +len+ bytes will be returned.
+ *
+ * See to_str
+ */
+static VALUE
+rb_fiddle_ptr_to_s(int argc, VALUE argv[], VALUE self)
+{
+ struct ptr_data *data;
+ VALUE arg1, val;
+ int len;
+
+ TypedData_Get_Struct(self, struct ptr_data, &fiddle_ptr_data_type, data);
+ switch (rb_scan_args(argc, argv, "01", &arg1)) {
+ case 0:
+ val = rb_tainted_str_new2((char*)(data->ptr));
+ break;
+ case 1:
+ len = NUM2INT(arg1);
+ val = rb_tainted_str_new((char*)(data->ptr), len);
+ break;
+ default:
+ rb_bug("rb_fiddle_ptr_to_s");
+ }
+
+ return val;
+}
+
+/*
+ * call-seq:
+ *
+ * ptr.to_str => string
+ * ptr.to_str(len) => string
+ *
+ * Returns the pointer contents as a string.
+ *
+ * When called with no arguments, this method will return the contents with the
+ * length of this pointer's +size+.
+ *
+ * When called with +len+, a string of +len+ bytes will be returned.
+ *
+ * See to_s
+ */
+static VALUE
+rb_fiddle_ptr_to_str(int argc, VALUE argv[], VALUE self)
+{
+ struct ptr_data *data;
+ VALUE arg1, val;
+ int len;
+
+ TypedData_Get_Struct(self, struct ptr_data, &fiddle_ptr_data_type, data);
+ switch (rb_scan_args(argc, argv, "01", &arg1)) {
+ case 0:
+ val = rb_tainted_str_new((char*)(data->ptr),data->size);
+ break;
+ case 1:
+ len = NUM2INT(arg1);
+ val = rb_tainted_str_new((char*)(data->ptr), len);
+ break;
+ default:
+ rb_bug("rb_fiddle_ptr_to_str");
+ }
+
+ return val;
+}
+
+/*
+ * call-seq: inspect
+ *
+ * Returns a string formatted with an easily readable representation of the
+ * internal state of the pointer.
+ */
+static VALUE
+rb_fiddle_ptr_inspect(VALUE self)
+{
+ struct ptr_data *data;
+
+ TypedData_Get_Struct(self, struct ptr_data, &fiddle_ptr_data_type, data);
+ return rb_sprintf("#<%"PRIsVALUE":%p ptr=%p size=%ld free=%p>",
+ RB_OBJ_CLASSNAME(self), data, data->ptr, data->size, data->free);
+}
+
+/*
+ * call-seq:
+ * ptr == other => true or false
+ * ptr.eql?(other) => true or false
+ *
+ * Returns true if +other+ wraps the same pointer, otherwise returns
+ * false.
+ */
+static VALUE
+rb_fiddle_ptr_eql(VALUE self, VALUE other)
+{
+ void *ptr1, *ptr2;
+
+ if(!rb_obj_is_kind_of(other, rb_cPointer)) return Qfalse;
+
+ ptr1 = rb_fiddle_ptr2cptr(self);
+ ptr2 = rb_fiddle_ptr2cptr(other);
+
+ return ptr1 == ptr2 ? Qtrue : Qfalse;
+}
+
+/*
+ * call-seq:
+ * ptr <=> other => -1, 0, 1, or nil
+ *
+ * Returns -1 if less than, 0 if equal to, 1 if greater than +other+.
+ *
+ * Returns nil if +ptr+ cannot be compared to +other+.
+ */
+static VALUE
+rb_fiddle_ptr_cmp(VALUE self, VALUE other)
+{
+ void *ptr1, *ptr2;
+ SIGNED_VALUE diff;
+
+ if(!rb_obj_is_kind_of(other, rb_cPointer)) return Qnil;
+
+ ptr1 = rb_fiddle_ptr2cptr(self);
+ ptr2 = rb_fiddle_ptr2cptr(other);
+ diff = (SIGNED_VALUE)ptr1 - (SIGNED_VALUE)ptr2;
+ if (!diff) return INT2FIX(0);
+ return diff > 0 ? INT2NUM(1) : INT2NUM(-1);
+}
+
+/*
+ * call-seq:
+ * ptr + n => new cptr
+ *
+ * Returns a new pointer instance that has been advanced +n+ bytes.
+ */
+static VALUE
+rb_fiddle_ptr_plus(VALUE self, VALUE other)
+{
+ void *ptr;
+ long num, size;
+
+ ptr = rb_fiddle_ptr2cptr(self);
+ size = RPTR_DATA(self)->size;
+ num = NUM2LONG(other);
+ return rb_fiddle_ptr_new((char *)ptr + num, size - num, 0);
+}
+
+/*
+ * call-seq:
+ * ptr - n => new cptr
+ *
+ * Returns a new pointer instance that has been moved back +n+ bytes.
+ */
+static VALUE
+rb_fiddle_ptr_minus(VALUE self, VALUE other)
+{
+ void *ptr;
+ long num, size;
+
+ ptr = rb_fiddle_ptr2cptr(self);
+ size = RPTR_DATA(self)->size;
+ num = NUM2LONG(other);
+ return rb_fiddle_ptr_new((char *)ptr - num, size + num, 0);
+}
+
+/*
+ * call-seq:
+ * ptr[index] -> an_integer
+ * ptr[start, length] -> a_string
+ *
+ * Returns integer stored at _index_.
+ *
+ * If _start_ and _length_ are given, a string containing the bytes from
+ * _start_ of _length_ will be returned.
+ */
+static VALUE
+rb_fiddle_ptr_aref(int argc, VALUE argv[], VALUE self)
+{
+ VALUE arg0, arg1;
+ VALUE retval = Qnil;
+ size_t offset, len;
+ struct ptr_data *data;
+
+ TypedData_Get_Struct(self, struct ptr_data, &fiddle_ptr_data_type, data);
+ if (!data->ptr) rb_raise(rb_eFiddleError, "NULL pointer dereference");
+ switch( rb_scan_args(argc, argv, "11", &arg0, &arg1) ){
+ case 1:
+ offset = NUM2ULONG(arg0);
+ retval = INT2NUM(*((char *)data->ptr + offset));
+ break;
+ case 2:
+ offset = NUM2ULONG(arg0);
+ len = NUM2ULONG(arg1);
+ retval = rb_tainted_str_new((char *)data->ptr + offset, len);
+ break;
+ default:
+ rb_bug("rb_fiddle_ptr_aref()");
+ }
+ return retval;
+}
+
+/*
+ * call-seq:
+ * ptr[index] = int -> int
+ * ptr[start, length] = string or cptr or addr -> string or dl_cptr or addr
+ *
+ * Set the value at +index+ to +int+.
+ *
+ * Or, set the memory at +start+ until +length+ with the contents of +string+,
+ * the memory from +dl_cptr+, or the memory pointed at by the memory address
+ * +addr+.
+ */
+static VALUE
+rb_fiddle_ptr_aset(int argc, VALUE argv[], VALUE self)
+{
+ VALUE arg0, arg1, arg2;
+ VALUE retval = Qnil;
+ size_t offset, len;
+ void *mem;
+ struct ptr_data *data;
+
+ TypedData_Get_Struct(self, struct ptr_data, &fiddle_ptr_data_type, data);
+ if (!data->ptr) rb_raise(rb_eFiddleError, "NULL pointer dereference");
+ switch( rb_scan_args(argc, argv, "21", &arg0, &arg1, &arg2) ){
+ case 2:
+ offset = NUM2ULONG(arg0);
+ ((char*)data->ptr)[offset] = NUM2UINT(arg1);
+ retval = arg1;
+ break;
+ case 3:
+ offset = NUM2ULONG(arg0);
+ len = NUM2ULONG(arg1);
+ if (RB_TYPE_P(arg2, T_STRING)) {
+ mem = StringValuePtr(arg2);
+ }
+ else if( rb_obj_is_kind_of(arg2, rb_cPointer) ){
+ mem = rb_fiddle_ptr2cptr(arg2);
+ }
+ else{
+ mem = NUM2PTR(arg2);
+ }
+ memcpy((char *)data->ptr + offset, mem, len);
+ retval = arg2;
+ break;
+ default:
+ rb_bug("rb_fiddle_ptr_aset()");
+ }
+ return retval;
+}
+
+/*
+ * call-seq: size=(size)
+ *
+ * Set the size of this pointer to +size+
+ */
+static VALUE
+rb_fiddle_ptr_size_set(VALUE self, VALUE size)
+{
+ RPTR_DATA(self)->size = NUM2LONG(size);
+ return size;
+}
+
+/*
+ * call-seq: size
+ *
+ * Get the size of this pointer.
+ */
+static VALUE
+rb_fiddle_ptr_size_get(VALUE self)
+{
+ return LONG2NUM(RPTR_DATA(self)->size);
+}
+
+/*
+ * call-seq:
+ * Fiddle::Pointer[val] => cptr
+ * to_ptr(val) => cptr
+ *
+ * Get the underlying pointer for ruby object +val+ and return it as a
+ * Fiddle::Pointer object.
+ */
+static VALUE
+rb_fiddle_ptr_s_to_ptr(VALUE self, VALUE val)
+{
+ VALUE ptr, wrap = val, vptr;
+
+ if (RTEST(rb_obj_is_kind_of(val, rb_cIO))){
+ rb_io_t *fptr;
+ FILE *fp;
+ GetOpenFile(val, fptr);
+ fp = rb_io_stdio_file(fptr);
+ ptr = rb_fiddle_ptr_new(fp, 0, NULL);
+ }
+ else if (RTEST(rb_obj_is_kind_of(val, rb_cString))){
+ char *str = StringValuePtr(val);
+ ptr = rb_fiddle_ptr_new(str, RSTRING_LEN(val), NULL);
+ }
+ else if ((vptr = rb_check_funcall(val, id_to_ptr, 0, 0)) != Qundef){
+ if (rb_obj_is_kind_of(vptr, rb_cPointer)){
+ ptr = vptr;
+ wrap = 0;
+ }
+ else{
+ rb_raise(rb_eFiddleError, "to_ptr should return a Fiddle::Pointer object");
+ }
+ }
+ else{
+ VALUE num = rb_Integer(val);
+ if (num == val) wrap = 0;
+ ptr = rb_fiddle_ptr_new(NUM2PTR(num), 0, NULL);
+ }
+ OBJ_INFECT(ptr, val);
+ if (wrap) RPTR_DATA(ptr)->wrap[0] = wrap;
+ return ptr;
+}
+
+void
+Init_fiddle_pointer(void)
+{
+ id_to_ptr = rb_intern("to_ptr");
+
+ /* Document-class: Fiddle::Pointer
+ *
+ * Fiddle::Pointer is a class to handle C pointers
+ *
+ */
+ rb_cPointer = rb_define_class_under(mFiddle, "Pointer", rb_cObject);
+ rb_define_alloc_func(rb_cPointer, rb_fiddle_ptr_s_allocate);
+ rb_define_singleton_method(rb_cPointer, "malloc", rb_fiddle_ptr_s_malloc, -1);
+ rb_define_singleton_method(rb_cPointer, "to_ptr", rb_fiddle_ptr_s_to_ptr, 1);
+ rb_define_singleton_method(rb_cPointer, "[]", rb_fiddle_ptr_s_to_ptr, 1);
+ rb_define_method(rb_cPointer, "initialize", rb_fiddle_ptr_initialize, -1);
+ rb_define_method(rb_cPointer, "free=", rb_fiddle_ptr_free_set, 1);
+ rb_define_method(rb_cPointer, "free", rb_fiddle_ptr_free_get, 0);
+ rb_define_method(rb_cPointer, "to_i", rb_fiddle_ptr_to_i, 0);
+ rb_define_method(rb_cPointer, "to_int", rb_fiddle_ptr_to_i, 0);
+ rb_define_method(rb_cPointer, "to_value", rb_fiddle_ptr_to_value, 0);
+ rb_define_method(rb_cPointer, "ptr", rb_fiddle_ptr_ptr, 0);
+ rb_define_method(rb_cPointer, "+@", rb_fiddle_ptr_ptr, 0);
+ rb_define_method(rb_cPointer, "ref", rb_fiddle_ptr_ref, 0);
+ rb_define_method(rb_cPointer, "-@", rb_fiddle_ptr_ref, 0);
+ rb_define_method(rb_cPointer, "null?", rb_fiddle_ptr_null_p, 0);
+ rb_define_method(rb_cPointer, "to_s", rb_fiddle_ptr_to_s, -1);
+ rb_define_method(rb_cPointer, "to_str", rb_fiddle_ptr_to_str, -1);
+ rb_define_method(rb_cPointer, "inspect", rb_fiddle_ptr_inspect, 0);
+ rb_define_method(rb_cPointer, "<=>", rb_fiddle_ptr_cmp, 1);
+ rb_define_method(rb_cPointer, "==", rb_fiddle_ptr_eql, 1);
+ rb_define_method(rb_cPointer, "eql?", rb_fiddle_ptr_eql, 1);
+ rb_define_method(rb_cPointer, "+", rb_fiddle_ptr_plus, 1);
+ rb_define_method(rb_cPointer, "-", rb_fiddle_ptr_minus, 1);
+ rb_define_method(rb_cPointer, "[]", rb_fiddle_ptr_aref, -1);
+ rb_define_method(rb_cPointer, "[]=", rb_fiddle_ptr_aset, -1);
+ rb_define_method(rb_cPointer, "size", rb_fiddle_ptr_size_get, 0);
+ rb_define_method(rb_cPointer, "size=", rb_fiddle_ptr_size_set, 1);
+
+ /* Document-const: NULL
+ *
+ * A NULL pointer
+ */
+ rb_define_const(mFiddle, "NULL", rb_fiddle_ptr_new(0, 0, 0));
+}
diff --git a/jni/ruby/ext/fiddle/win32/fficonfig.h b/jni/ruby/ext/fiddle/win32/fficonfig.h
new file mode 100755
index 0000000..7768081
--- /dev/null
+++ b/jni/ruby/ext/fiddle/win32/fficonfig.h
@@ -0,0 +1,29 @@
+#define HAVE_ALLOCA 1
+#define HAVE_MEMCPY 1
+#define HAVE_MEMORY_H 1
+#define HAVE_STDLIB_H 1
+#define HAVE_STRING_H 1
+#define HAVE_SYS_STAT_H 1
+#define HAVE_SYS_TYPES_H 1
+#if _MSC_VER >= 1600
+#define HAVE_INTTYPES_H 1
+#define HAVE_STDINT_H 1
+#endif
+
+#define SIZEOF_DOUBLE 8
+#if defined(X86_WIN64)
+#define SIZEOF_SIZE_T 8
+#else
+#define SIZEOF_SIZE_T 4
+#endif
+
+#define STACK_DIRECTION -1
+
+#define STDC_HEADERS 1
+
+#ifdef LIBFFI_ASM
+#define FFI_HIDDEN(name)
+#else
+#define FFI_HIDDEN
+#endif
+
diff --git a/jni/ruby/ext/fiddle/win32/libffi-3.2.1-mswin.patch b/jni/ruby/ext/fiddle/win32/libffi-3.2.1-mswin.patch
new file mode 100644
index 0000000..782cf41
--- /dev/null
+++ b/jni/ruby/ext/fiddle/win32/libffi-3.2.1-mswin.patch
@@ -0,0 +1,132 @@
+diff -ru libffi-3.2.1/src/x86/ffi.c libffi-3.2.1/src/x86/ffi.c
+--- libffi-3.2.1/src/x86/ffi.c 2014-11-08 21:47:24.000000000 +0900
++++ libffi-3.2.1/src/x86/ffi.c 2014-12-22 16:00:42.000000000 +0900
+@@ -99,11 +99,13 @@
+ i != 0;
+ i--, p_arg += dir, p_argv += dir)
+ {
++ size_t z;
++
+ /* Align if necessary */
+ if ((sizeof(void*) - 1) & (size_t) argp)
+ argp = (char *) ALIGN(argp, sizeof(void*));
+
+- size_t z = (*p_arg)->size;
++ z = (*p_arg)->size;
+
+ #ifdef X86_WIN64
+ if (z > FFI_SIZEOF_ARG
+@@ -599,11 +601,13 @@
+ i != 0;
+ i--, p_arg += dir, p_argv += dir)
+ {
++ size_t z;
++
+ /* Align if necessary */
+ if ((sizeof(void*) - 1) & (size_t) argp)
+ argp = (char *) ALIGN(argp, sizeof(void*));
+
+- size_t z = (*p_arg)->size;
++ z = (*p_arg)->size;
+
+ #ifdef X86_WIN64
+ if (z > FFI_SIZEOF_ARG
+@@ -642,7 +646,7 @@
+ #endif
+ }
+
+- return (size_t)argp - (size_t)stack;
++ return (int)((size_t)argp - (size_t)stack);
+ }
+
+ #define FFI_INIT_TRAMPOLINE_WIN64(TRAMP,FUN,CTX,MASK) \
+diff -ru libffi-3.2.1/src/x86/ffitarget.h libffi-3.2.1/src/x86/ffitarget.h
+--- libffi-3.2.1/src/x86/ffitarget.h 2014-11-08 21:47:24.000000000 +0900
++++ libffi-3.2.1/src/x86/ffitarget.h 2014-12-22 15:45:54.000000000 +0900
+@@ -50,7 +50,9 @@
+ #endif
+
+ #define FFI_TARGET_SPECIFIC_STACK_SPACE_ALLOCATION
++#ifndef _MSC_VER
+ #define FFI_TARGET_HAS_COMPLEX_TYPE
++#endif
+
+ /* ---- Generic type definitions ----------------------------------------- */
+
+diff -ru libffi-3.2.1/src/x86/win64.S libffi-3.2.1/src/x86/win64.S
+--- libffi-3.2.1/src/x86/win64.S 2014-11-08 21:47:24.000000000 +0900
++++ libffi-3.2.1/src/x86/win64.S 2014-12-22 16:14:40.000000000 +0900
+@@ -127,7 +127,7 @@
+
+ mov rcx, QWORD PTR RVALUE[rbp]
+ mov DWORD PTR [rcx], eax
+- jmp ret_void$
++ jmp SHORT ret_void$
+
+ ret_struct2b$:
+ cmp DWORD PTR CIF_FLAGS[rbp], FFI_TYPE_SMALL_STRUCT_2B
+@@ -135,7 +135,7 @@
+
+ mov rcx, QWORD PTR RVALUE[rbp]
+ mov WORD PTR [rcx], ax
+- jmp ret_void$
++ jmp SHORT ret_void$
+
+ ret_struct1b$:
+ cmp DWORD PTR CIF_FLAGS[rbp], FFI_TYPE_SMALL_STRUCT_1B
+@@ -143,7 +143,7 @@
+
+ mov rcx, QWORD PTR RVALUE[rbp]
+ mov BYTE PTR [rcx], al
+- jmp ret_void$
++ jmp SHORT ret_void$
+
+ ret_uint8$:
+ cmp DWORD PTR CIF_FLAGS[rbp], FFI_TYPE_UINT8
+@@ -152,7 +152,7 @@
+ mov rcx, QWORD PTR RVALUE[rbp]
+ movzx rax, al
+ mov QWORD PTR [rcx], rax
+- jmp ret_void$
++ jmp SHORT ret_void$
+
+ ret_sint8$:
+ cmp DWORD PTR CIF_FLAGS[rbp], FFI_TYPE_SINT8
+@@ -161,7 +161,7 @@
+ mov rcx, QWORD PTR RVALUE[rbp]
+ movsx rax, al
+ mov QWORD PTR [rcx], rax
+- jmp ret_void$
++ jmp SHORT ret_void$
+
+ ret_uint16$:
+ cmp DWORD PTR CIF_FLAGS[rbp], FFI_TYPE_UINT16
+@@ -188,7 +188,13 @@
+ mov rcx, QWORD PTR RVALUE[rbp]
+ mov eax, eax
+ mov QWORD PTR [rcx], rax
+- jmp SHORT ret_void$
++
++ret_void$:
++ xor rax, rax
++
++ lea rsp, QWORD PTR [rbp+16]
++ pop rbp
++ ret 0
+
+ ret_sint32$:
+ cmp DWORD PTR CIF_FLAGS[rbp], FFI_TYPE_SINT32
+@@ -247,13 +253,6 @@
+ cdqe
+ mov QWORD PTR [rcx], rax
+ jmp SHORT ret_void$
+-
+-ret_void$:
+- xor rax, rax
+-
+- lea rsp, QWORD PTR [rbp+16]
+- pop rbp
+- ret 0
+ ffi_call_win64 ENDP
+ _TEXT ENDS
+ END
diff --git a/jni/ruby/ext/fiddle/win32/libffi-config.rb b/jni/ruby/ext/fiddle/win32/libffi-config.rb
new file mode 100755
index 0000000..ecd3b08
--- /dev/null
+++ b/jni/ruby/ext/fiddle/win32/libffi-config.rb
@@ -0,0 +1,47 @@
+#!/usr/bin/ruby
+require 'fileutils'
+
+basedir = File.dirname(__FILE__)
+conf = {}
+enable = {}
+until ARGV.empty?
+ arg = ARGV.shift
+ case arg
+ when '-C'
+ # ignore
+ when /\A--srcdir=(.*)/
+ conf['SRCDIR'] = srcdir = $1
+ when /\A(CC|CFLAGS|CXX|CXXFLAGS|LD|LDFLAGS)=(.*)/
+ conf[$1] = $2
+ when /\A--host=(.*)/
+ host = $1
+ when /\A--enable-([^=]+)(?:=(.*))?/
+ enable[$1] = $2 || true
+ when /\A--disable-([^=]+)/
+ enable[$1] = false
+ end
+end
+
+IO.foreach("#{srcdir}/configure.ac") do |line|
+ if /^AC_INIT\((.*)\)/ =~ line
+ version = $1.split(/,\s*/)[1]
+ version.gsub!(/\A\[|\]\z/, '')
+ conf['VERSION'] = version
+ break
+ end
+end
+
+builddir = srcdir == "." ? enable['builddir'] : "."
+conf['TARGET'] = /^x64/ =~ host ? "X86_WIN64" : "X86_WIN32"
+
+FileUtils.mkdir_p([builddir, "#{builddir}/include", "#{builddir}/src/x86"])
+FileUtils.cp("#{basedir}/fficonfig.h", ".", preserve: true)
+
+hdr = IO.binread("#{srcdir}/include/ffi.h.in")
+hdr.gsub!(/@(\w+)@/) {conf[$1] || $&}
+hdr.gsub!(/^(#if\s+)@\w+@/, '\10')
+IO.binwrite("#{builddir}/include/ffi.h", hdr)
+
+mk = IO.binread("#{basedir}/libffi.mk.tmpl")
+mk.gsub!(/@(\w+)@/) {conf[$1] || $&}
+IO.binwrite("Makefile", mk)
diff --git a/jni/ruby/ext/fiddle/win32/libffi.mk.tmpl b/jni/ruby/ext/fiddle/win32/libffi.mk.tmpl
new file mode 100755
index 0000000..2a16e8e
--- /dev/null
+++ b/jni/ruby/ext/fiddle/win32/libffi.mk.tmpl
@@ -0,0 +1,96 @@
+# -*- makefile -*-
+# ====================================================================
+#
+# libffi Windows Makefile
+#
+#
+# ====================================================================
+#
+NAME = ffi
+TARGET = @TARGET@
+CC = cl
+!if "$(TARGET)" == "X86_WIN64"
+AS = ml64
+!else
+AS = ml
+!endif
+AR = link
+DLEXT = dll
+OBJEXT = obj
+LIBEXT = lib
+TOPDIR = @SRCDIR@
+CPP = $(CC) -EP
+CFLAGS = @CFLAGS@
+ARFLAGS = -lib
+ASFLAGS = -coff -W3 -Cx
+INCLUDES= -I. -I./include -I./src/x86 \
+ -I$(TOPDIR)/include -I$(TOPDIR)/include/src/x86
+
+SRCDIR = $(TOPDIR)/src
+WORKDIR = ./.libs
+BUILDDIR= ./src
+LIBNAME = lib$(NAME)
+STATICLIB= $(WORKDIR)/$(LIBNAME)_convenience.$(LIBEXT)
+
+HEADERS = \
+ ./fficonfig.h
+FFI_HEADERS = \
+ ./include/ffi.h \
+ ./include/ffitarget.h
+
+!if "$(TARGET)" == "X86_WIN32"
+OSSRC = win32
+!else if "$(TARGET)" == "X86_WIN64"
+OSSRC = win64
+!else
+! error unknown target: $(TARGET)
+!endif
+
+OBJECTS = \
+ $(BUILDDIR)/closures.$(OBJEXT) \
+ $(BUILDDIR)/debug.$(OBJEXT) \
+ $(BUILDDIR)/java_raw_api.$(OBJEXT) \
+ $(BUILDDIR)/prep_cif.$(OBJEXT) \
+ $(BUILDDIR)/raw_api.$(OBJEXT) \
+ $(BUILDDIR)/types.$(OBJEXT) \
+ $(BUILDDIR)/x86/ffi.$(OBJEXT) \
+ $(BUILDDIR)/x86/$(OSSRC).$(OBJEXT)
+ASMSRCS = \
+ $(BUILDDIR)/x86/$(OSSRC).asm
+
+.SUFFIXES : .S .asm
+
+all: $(WORKDIR) $(STATICLIB)
+
+{$(SRCDIR)}.c{$(BUILDDIR)}.$(OBJEXT):
+ $(CC) -c $(CFLAGS) $(INCLUDES) -Fo$(@:\=/) -Fd$(WORKDIR)/$(NAME)-src $(<:\=/)
+
+{$(SRCDIR)/x86}.c{$(BUILDDIR)/x86}.$(OBJEXT):
+ $(CC) -c $(CFLAGS) $(INCLUDES) -Fo$(@:\=/) -Fd$(WORKDIR)/$(NAME)-src $(<:\=/)
+
+{$(SRCDIR)/x86}.S{$(BUILDDIR)/x86}.asm:
+ $(CPP) $(CFLAGS) $(INCLUDES) $(<:\=/) >$(@:\=/)
+
+{$(BUILDDIR)/x86}.asm{$(BUILDDIR)/x86}.$(OBJEXT):
+ cd $(@D) && $(AS) -c $(ASFLAGS) -Fo $(@F) $(<F)
+
+$(BUILDDIR)/x86/$(OSSRC).asm: $(SRCDIR)/x86/$(OSSRC).S
+
+$(OBJECTS): $(FFI_HEADERS) $(HEADERS)
+
+$(WORKDIR):
+ -@if not exist "$(WORKDIR:/=\)\$(NULL)" mkdir $(WORKDIR:/=\)
+
+$(STATICLIB): $(WORKDIR) $(OBJECTS)
+ $(AR) $(ARFLAGS) -out:$(STATICLIB) @<<
+ $(OBJECTS)
+<<
+
+clean:
+ -@del /Q $(OBJECTS:/=\) 2>NUL
+ -@del /Q $(ASMSRCS:/=\) 2>NUL
+ -@del /Q /S $(WORKDIR:/=\) 2>NUL
+
+distclean: clean
+ -@del /Q $(HEADERS:/=\) $(FFI_HEADERS:/=\) 2>NUL
+ -@del /Q Makefile 2>NUL
diff --git a/jni/ruby/ext/gdbm/Makefile b/jni/ruby/ext/gdbm/Makefile
new file mode 100644
index 0000000..bc15fa4
--- /dev/null
+++ b/jni/ruby/ext/gdbm/Makefile
@@ -0,0 +1,150 @@
+# ***DUMMY MAKEFILE***
+
+SHELL = /bin/sh
+
+# V=0 quiet, V=1 verbose. other values don't work.
+V = 0
+Q1 = $(V:1=)
+Q = $(Q1:0=@)
+ECHO1 = $(V:1=@:)
+ECHO = $(ECHO1:0=@echo)
+NULLCMD = :
+
+#### Start of system configuration section. ####
+top_srcdir = $(topdir)/.
+srcdir = $(top_srcdir)/ext/gdbm
+topdir = ../..
+hdrdir = $(top_srcdir)/include
+arch_hdrdir = $(extout)/include/$(arch)
+PATH_SEPARATOR = :
+VPATH = $(srcdir):$(arch_hdrdir)/ruby:$(hdrdir)/ruby
+RUBYLIB =
+RUBYOPT = -
+prefix = $(DESTDIR)/usr/local
+rubysitearchprefix = $(rubylibprefix)/$(sitearch)
+rubyarchprefix = $(rubylibprefix)/$(arch)
+rubylibprefix = $(libdir)/$(RUBY_BASE_NAME)
+exec_prefix = $(prefix)
+vendorarchhdrdir = $(vendorhdrdir)/$(sitearch)
+sitearchhdrdir = $(sitehdrdir)/$(sitearch)
+rubyarchhdrdir = $(rubyhdrdir)/$(arch)
+vendorhdrdir = $(rubyhdrdir)/vendor_ruby
+sitehdrdir = $(rubyhdrdir)/site_ruby
+rubyhdrdir = $(includedir)/$(RUBY_VERSION_NAME)
+vendorarchdir = $(vendorlibdir)/$(sitearch)
+vendorlibdir = $(vendordir)/$(ruby_version)
+vendordir = $(rubylibprefix)/vendor_ruby
+sitearchdir = $(sitelibdir)/$(sitearch)
+sitelibdir = $(sitedir)/$(ruby_version)
+sitedir = $(rubylibprefix)/site_ruby
+rubyarchdir = $(rubylibdir)/$(arch)
+rubylibdir = $(rubylibprefix)/$(ruby_version)
+sitearchincludedir = $(includedir)/$(sitearch)
+archincludedir = $(includedir)/$(arch)
+sitearchlibdir = $(libdir)/$(sitearch)
+archlibdir = $(libdir)/$(arch)
+ridir = $(datarootdir)/$(RI_BASE_NAME)
+mandir = $(datarootdir)/man
+localedir = $(datarootdir)/locale
+libdir = $(exec_prefix)/lib
+psdir = $(docdir)
+pdfdir = $(docdir)
+dvidir = $(docdir)
+htmldir = $(docdir)
+infodir = $(datarootdir)/info
+docdir = $(datarootdir)/doc/$(PACKAGE)
+oldincludedir = $(DESTDIR)/usr/include
+includedir = $(prefix)/include
+localstatedir = $(prefix)/var
+sharedstatedir = $(prefix)/com
+sysconfdir = $(prefix)/etc
+datadir = $(datarootdir)
+datarootdir = $(prefix)/share
+libexecdir = $(exec_prefix)/libexec
+sbindir = $(exec_prefix)/sbin
+bindir = $(exec_prefix)/bin
+archdir = $(rubyarchdir)
+
+
+CC = gcc
+CXX = g++
+LIBRUBY = $(LIBRUBY_SO)
+LIBRUBY_A = lib$(RUBY_SO_NAME)-static.a
+LIBRUBYARG_SHARED = -Wl,-R$(libdir) -L$(libdir) -l$(RUBY_SO_NAME)
+LIBRUBYARG_STATIC = -Wl,-R$(libdir) -L$(libdir) -l$(RUBY_SO_NAME)-static
+empty =
+OUTFLAG = -o $(empty)
+COUTFLAG = -o $(empty)
+
+RUBY_EXTCONF_H =
+cflags = $(optflags) $(debugflags) $(warnflags)
+optflags = -O3 -fno-fast-math
+debugflags = -ggdb3
+warnflags = -Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wunused-variable -Wpointer-arith -Wwrite-strings -Wdeclaration-after-statement -Wimplicit-function-declaration -Wdeprecated-declarations -Wno-packed-bitfield-compat
+CCDLFLAGS = -fPIC
+CFLAGS = $(CCDLFLAGS) $(cflags) -fPIC $(ARCH_FLAG)
+INCFLAGS = -I. -I$(arch_hdrdir) -I$(hdrdir) -I$(srcdir)
+DEFS =
+CPPFLAGS = $(DEFS) $(cppflags)
+CXXFLAGS = $(CCDLFLAGS) $(cxxflags) $(ARCH_FLAG)
+ldflags = -L. -fstack-protector -rdynamic -Wl,-export-dynamic
+dldflags =
+ARCH_FLAG =
+DLDFLAGS = $(ldflags) $(dldflags) $(ARCH_FLAG)
+LDSHARED = $(CC) -shared
+LDSHAREDXX = $(CXX) -shared
+AR = ar
+EXEEXT =
+
+RUBY_INSTALL_NAME = $(RUBY_BASE_NAME)
+RUBY_SO_NAME = ruby
+RUBYW_INSTALL_NAME =
+RUBY_VERSION_NAME = $(RUBY_BASE_NAME)-$(ruby_version)
+RUBYW_BASE_NAME = rubyw
+RUBY_BASE_NAME = ruby
+
+arch = x86_64-linux
+sitearch = $(arch)
+ruby_version = 2.2.0
+ruby = $(topdir)/miniruby -I'$(topdir)' -I'$(top_srcdir)/lib' -I'$(extout)/$(arch)' -I'$(extout)/common'
+RUBY = $(ruby)
+ruby_headers = $(hdrdir)/ruby.h $(hdrdir)/ruby/ruby.h $(hdrdir)/ruby/defines.h $(hdrdir)/ruby/missing.h $(hdrdir)/ruby/intern.h $(hdrdir)/ruby/st.h $(hdrdir)/ruby/subst.h $(arch_hdrdir)/ruby/config.h
+
+RM = rm -f
+RM_RF = $(RUBY) -run -e rm -- -rf
+RMDIRS = rmdir --ignore-fail-on-non-empty -p
+MAKEDIRS = /bin/mkdir -p
+INSTALL = /usr/bin/install -c
+INSTALL_PROG = $(INSTALL) -m 0755
+INSTALL_DATA = $(INSTALL) -m 644
+COPY = cp
+TOUCH = exit >
+
+#### End of system configuration section. ####
+
+preload =
+CLEANFILES = mkmf.log
+DISTCLEANFILES =
+
+all install static install-so install-rb: Makefile
+.PHONY: all install static install-so install-rb
+.PHONY: clean clean-so clean-static clean-rb
+
+
+clean-static::
+clean-rb-default::
+clean-rb::
+clean-so::
+clean: clean-so clean-static clean-rb-default clean-rb
+ -$(Q)$(RM) $(CLEANLIBS) $(CLEANOBJS) $(CLEANFILES) .*.time
+
+distclean-rb-default::
+distclean-rb::
+distclean-so::
+distclean-static::
+distclean: clean distclean-so distclean-static distclean-rb-default distclean-rb
+ -$(Q)$(RM) Makefile $(RUBY_EXTCONF_H) conftest.* mkmf.log
+ -$(Q)$(RM) core ruby$(EXEEXT) *~ $(DISTCLEANFILES)
+ -$(Q)$(RMDIRS) $(DISTCLEANDIRS) 2> /dev/null || true
+
+realclean: distclean
diff --git a/jni/ruby/ext/gdbm/README b/jni/ruby/ext/gdbm/README
new file mode 100644
index 0000000..df7a261
--- /dev/null
+++ b/jni/ruby/ext/gdbm/README
@@ -0,0 +1 @@
+gdbm ext-library for Ruby 1.3 or later
diff --git a/jni/ruby/ext/gdbm/extconf.rb b/jni/ruby/ext/gdbm/extconf.rb
new file mode 100644
index 0000000..389bfb6
--- /dev/null
+++ b/jni/ruby/ext/gdbm/extconf.rb
@@ -0,0 +1,18 @@
+require 'mkmf'
+
+dir_config("gdbm")
+if have_library("gdbm", "gdbm_open") and
+ have_header("gdbm.h")
+ checking_for("sizeof(DBM) is available") {
+ if try_compile(<<SRC)
+#include <gdbm.h>
+
+const int sizeof_DBM = (int)sizeof(DBM);
+SRC
+ $defs << '-DDBM_SIZEOF_DBM=sizeof(DBM)'
+ else
+ $defs << '-DDBM_SIZEOF_DBM=0'
+ end
+ }
+ create_makefile("gdbm")
+end
diff --git a/jni/ruby/ext/gdbm/gdbm.c b/jni/ruby/ext/gdbm/gdbm.c
new file mode 100644
index 0000000..ccbfe89
--- /dev/null
+++ b/jni/ruby/ext/gdbm/gdbm.c
@@ -0,0 +1,1306 @@
+/************************************************
+
+ gdbm.c -
+
+ $Author: nobu $
+ modified at: Mon Jan 24 15:59:52 JST 1994
+
+ Documentation by Peter Adolphs < futzilogik at users dot sourceforge dot net >
+
+************************************************/
+
+#include "ruby.h"
+
+#include <gdbm.h>
+#include <fcntl.h>
+#include <errno.h>
+
+/*
+ * Document-class: GDBM
+ *
+ * == Summary
+ *
+ * Ruby extension for GNU dbm (gdbm) -- a simple database engine for storing
+ * key-value pairs on disk.
+ *
+ * == Description
+ *
+ * GNU dbm is a library for simple databases. A database is a file that stores
+ * key-value pairs. Gdbm allows the user to store, retrieve, and delete data by
+ * key. It furthermore allows a non-sorted traversal of all key-value pairs.
+ * A gdbm database thus provides the same functionality as a hash. As
+ * with objects of the Hash class, elements can be accessed with <tt>[]</tt>.
+ * Furthermore, GDBM mixes in the Enumerable module, thus providing convenient
+ * methods such as #find, #collect, #map, etc.
+ *
+ * A process is allowed to open several different databases at the same time.
+ * A process can open a database as a "reader" or a "writer". Whereas a reader
+ * has only read-access to the database, a writer has read- and write-access.
+ * A database can be accessed either by any number of readers or by exactly one
+ * writer at the same time.
+ *
+ * == Examples
+ *
+ * 1. Opening/creating a database, and filling it with some entries:
+ *
+ * require 'gdbm'
+ *
+ * gdbm = GDBM.new("fruitstore.db")
+ * gdbm["ananas"] = "3"
+ * gdbm["banana"] = "8"
+ * gdbm["cranberry"] = "4909"
+ * gdbm.close
+ *
+ * 2. Reading out a database:
+ *
+ * require 'gdbm'
+ *
+ * gdbm = GDBM.new("fruitstore.db")
+ * gdbm.each_pair do |key, value|
+ * print "#{key}: #{value}\n"
+ * end
+ * gdbm.close
+ *
+ * produces
+ *
+ * banana: 8
+ * ananas: 3
+ * cranberry: 4909
+ *
+ * == Links
+ *
+ * * http://www.gnu.org/software/gdbm/
+ */
+static VALUE rb_cGDBM, rb_eGDBMError, rb_eGDBMFatalError;
+
+#if SIZEOF_LONG > SIZEOF_INT
+#define TOO_LONG(n) ((long)(+(int)(n)) != (long)(n))
+#else
+#define TOO_LONG(n) 0
+#endif
+
+#define RUBY_GDBM_RW_BIT 0x20000000
+
+#define MY_BLOCK_SIZE (2048)
+#define MY_FATAL_FUNC rb_gdbm_fatal
+static void
+rb_gdbm_fatal(const char *msg)
+{
+ rb_raise(rb_eGDBMFatalError, "%s", msg);
+}
+
+struct dbmdata {
+ int di_size;
+ GDBM_FILE di_dbm;
+};
+
+static void
+closed_dbm(void)
+{
+ rb_raise(rb_eRuntimeError, "closed GDBM file");
+}
+
+#define GetDBM(obj, dbmp) do {\
+ TypedData_Get_Struct((obj), struct dbmdata, &dbm_type, (dbmp));\
+ if ((dbmp) == 0) closed_dbm();\
+ if ((dbmp)->di_dbm == 0) closed_dbm();\
+} while (0)
+
+#define GetDBM2(obj, dbmp, dbm) do {\
+ GetDBM((obj), (dbmp));\
+ (dbm) = (dbmp)->di_dbm;\
+} while (0)
+
+static void
+free_dbm(void *ptr)
+{
+ struct dbmdata *dbmp = ptr;
+ if (dbmp) {
+ if (dbmp->di_dbm) gdbm_close(dbmp->di_dbm);
+ xfree(dbmp);
+ }
+}
+
+static size_t
+memsize_dbm(const void *ptr)
+{
+ size_t size = 0;
+ const struct dbmdata *dbmp = ptr;
+ if (dbmp) {
+ size += sizeof(*dbmp);
+ if (dbmp->di_dbm) size += DBM_SIZEOF_DBM;
+ }
+ return size;
+}
+
+static const rb_data_type_t dbm_type = {
+ "gdbm",
+ {0, free_dbm, memsize_dbm,},
+ 0, 0,
+ RUBY_TYPED_FREE_IMMEDIATELY,
+};
+
+/*
+ * call-seq:
+ * gdbm.close -> nil
+ *
+ * Closes the associated database file.
+ */
+static VALUE
+fgdbm_close(VALUE obj)
+{
+ struct dbmdata *dbmp;
+
+ GetDBM(obj, dbmp);
+ gdbm_close(dbmp->di_dbm);
+ dbmp->di_dbm = 0;
+
+ return Qnil;
+}
+
+/*
+ * call-seq:
+ * gdbm.closed? -> true or false
+ *
+ * Returns true if the associated database file has been closed.
+ */
+static VALUE
+fgdbm_closed(VALUE obj)
+{
+ struct dbmdata *dbmp;
+
+ TypedData_Get_Struct(obj, struct dbmdata, &dbm_type, dbmp);
+ if (dbmp == 0)
+ return Qtrue;
+ if (dbmp->di_dbm == 0)
+ return Qtrue;
+
+ return Qfalse;
+}
+
+static VALUE
+fgdbm_s_alloc(VALUE klass)
+{
+ return TypedData_Wrap_Struct(klass, &dbm_type, 0);
+}
+
+/*
+ * call-seq:
+ * GDBM.new(filename, mode = 0666, flags = nil)
+ *
+ * Creates a new GDBM instance by opening a gdbm file named _filename_.
+ * If the file does not exist, a new file with file mode _mode_ will be
+ * created. _flags_ may be one of the following:
+ * * *READER* - open as a reader
+ * * *WRITER* - open as a writer
+ * * *WRCREAT* - open as a writer; if the database does not exist, create a new one
+ * * *NEWDB* - open as a writer; overwrite any existing databases
+ *
+ * The values *WRITER*, *WRCREAT* and *NEWDB* may be combined with the following
+ * values by bitwise or:
+ * * *SYNC* - cause all database operations to be synchronized to the disk
+ * * *NOLOCK* - do not lock the database file
+ *
+ * If no _flags_ are specified, the GDBM object will try to open the database
+ * file as a writer and will create it if it does not already exist
+ * (cf. flag <tt>WRCREAT</tt>). If this fails (for instance, if another process
+ * has already opened the database as a reader), it will try to open the
+ * database file as a reader (cf. flag <tt>READER</tt>).
+ */
+static VALUE
+fgdbm_initialize(int argc, VALUE *argv, VALUE obj)
+{
+ VALUE file, vmode, vflags;
+ GDBM_FILE dbm;
+ struct dbmdata *dbmp;
+ int mode, flags = 0;
+
+ if (rb_scan_args(argc, argv, "12", &file, &vmode, &vflags) == 1) {
+ mode = 0666; /* default value */
+ }
+ else if (NIL_P(vmode)) {
+ mode = -1; /* return nil if DB does not exist */
+ }
+ else {
+ mode = NUM2INT(vmode);
+ }
+
+ if (!NIL_P(vflags))
+ flags = NUM2INT(vflags);
+
+ SafeStringValue(file);
+
+#ifdef GDBM_CLOEXEC
+ /* GDBM_CLOEXEC is available since gdbm 1.10. */
+ flags |= GDBM_CLOEXEC;
+#endif
+
+ if (flags & RUBY_GDBM_RW_BIT) {
+ flags &= ~RUBY_GDBM_RW_BIT;
+ dbm = gdbm_open(RSTRING_PTR(file), MY_BLOCK_SIZE,
+ flags, mode, MY_FATAL_FUNC);
+ }
+ else {
+ dbm = 0;
+ if (mode >= 0)
+ dbm = gdbm_open(RSTRING_PTR(file), MY_BLOCK_SIZE,
+ GDBM_WRCREAT|flags, mode, MY_FATAL_FUNC);
+ if (!dbm)
+ dbm = gdbm_open(RSTRING_PTR(file), MY_BLOCK_SIZE,
+ GDBM_WRITER|flags, 0, MY_FATAL_FUNC);
+ if (!dbm)
+ dbm = gdbm_open(RSTRING_PTR(file), MY_BLOCK_SIZE,
+ GDBM_READER|flags, 0, MY_FATAL_FUNC);
+ }
+
+ if (dbm) {
+ rb_fd_fix_cloexec(gdbm_fdesc(dbm));
+ }
+
+ if (!dbm) {
+ if (mode == -1) return Qnil;
+
+ if (gdbm_errno == GDBM_FILE_OPEN_ERROR ||
+ gdbm_errno == GDBM_CANT_BE_READER ||
+ gdbm_errno == GDBM_CANT_BE_WRITER)
+ rb_sys_fail_str(file);
+ else
+ rb_raise(rb_eGDBMError, "%s", gdbm_strerror(gdbm_errno));
+ }
+
+ dbmp = ALLOC(struct dbmdata);
+ free_dbm(DATA_PTR(obj));
+ DATA_PTR(obj) = dbmp;
+ dbmp->di_dbm = dbm;
+ dbmp->di_size = -1;
+
+ return obj;
+}
+
+/*
+ * call-seq:
+ * GDBM.open(filename, mode = 0666, flags = nil)
+ * GDBM.open(filename, mode = 0666, flags = nil) { |gdbm| ... }
+ *
+ * If called without a block, this is synonymous to GDBM::new.
+ * If a block is given, the new GDBM instance will be passed to the block
+ * as a parameter, and the corresponding database file will be closed
+ * after the execution of the block code has been finished.
+ *
+ * Example for an open call with a block:
+ *
+ * require 'gdbm'
+ * GDBM.open("fruitstore.db") do |gdbm|
+ * gdbm.each_pair do |key, value|
+ * print "#{key}: #{value}\n"
+ * end
+ * end
+ */
+static VALUE
+fgdbm_s_open(int argc, VALUE *argv, VALUE klass)
+{
+ VALUE obj = fgdbm_s_alloc(klass);
+
+ if (NIL_P(fgdbm_initialize(argc, argv, obj))) {
+ return Qnil;
+ }
+
+ if (rb_block_given_p()) {
+ return rb_ensure(rb_yield, obj, fgdbm_close, obj);
+ }
+
+ return obj;
+}
+
+static VALUE
+rb_gdbm_fetch(GDBM_FILE dbm, datum key)
+{
+ datum val;
+ VALUE str;
+
+ val = gdbm_fetch(dbm, key);
+ if (val.dptr == 0)
+ return Qnil;
+
+ str = rb_str_new(val.dptr, val.dsize);
+ free(val.dptr);
+ OBJ_TAINT(str);
+ return str;
+}
+
+static VALUE
+rb_gdbm_fetch2(GDBM_FILE dbm, VALUE keystr)
+{
+ datum key;
+ long len;
+
+ StringValue(keystr);
+ len = RSTRING_LEN(keystr);
+ if (TOO_LONG(len)) return Qnil;
+ key.dptr = RSTRING_PTR(keystr);
+ key.dsize = (int)len;
+
+ return rb_gdbm_fetch(dbm, key);
+}
+
+static VALUE
+rb_gdbm_fetch3(VALUE obj, VALUE keystr)
+{
+ struct dbmdata *dbmp;
+ GDBM_FILE dbm;
+
+ GetDBM2(obj, dbmp, dbm);
+ return rb_gdbm_fetch2(dbm, keystr);
+}
+
+static VALUE
+rb_gdbm_firstkey(GDBM_FILE dbm)
+{
+ datum key;
+ VALUE str;
+
+ key = gdbm_firstkey(dbm);
+ if (key.dptr == 0)
+ return Qnil;
+
+ str = rb_str_new(key.dptr, key.dsize);
+ free(key.dptr);
+ OBJ_TAINT(str);
+ return str;
+}
+
+static VALUE
+rb_gdbm_nextkey(GDBM_FILE dbm, VALUE keystr)
+{
+ datum key, key2;
+ VALUE str;
+ long len;
+
+ len = RSTRING_LEN(keystr);
+ if (TOO_LONG(len)) return Qnil;
+ key.dptr = RSTRING_PTR(keystr);
+ key.dsize = (int)len;
+ key2 = gdbm_nextkey(dbm, key);
+ if (key2.dptr == 0)
+ return Qnil;
+
+ str = rb_str_new(key2.dptr, key2.dsize);
+ free(key2.dptr);
+ OBJ_TAINT(str);
+ return str;
+}
+
+static VALUE
+fgdbm_fetch(VALUE obj, VALUE keystr, VALUE ifnone)
+{
+ VALUE valstr;
+
+ valstr = rb_gdbm_fetch3(obj, keystr);
+ if (NIL_P(valstr)) {
+ if (ifnone == Qnil && rb_block_given_p())
+ return rb_yield(keystr);
+ return ifnone;
+ }
+ return valstr;
+}
+
+/*
+ * call-seq:
+ * gdbm[key] -> value
+ *
+ * Retrieves the _value_ corresponding to _key_.
+ */
+static VALUE
+fgdbm_aref(VALUE obj, VALUE keystr)
+{
+ return rb_gdbm_fetch3(obj, keystr);
+}
+
+/*
+ * call-seq:
+ * gdbm.fetch(key [, default]) -> value
+ *
+ * Retrieves the _value_ corresponding to _key_. If there is no value
+ * associated with _key_, _default_ will be returned instead.
+ */
+static VALUE
+fgdbm_fetch_m(int argc, VALUE *argv, VALUE obj)
+{
+ VALUE keystr, valstr, ifnone;
+
+ rb_scan_args(argc, argv, "11", &keystr, &ifnone);
+ valstr = fgdbm_fetch(obj, keystr, ifnone);
+ if (argc == 1 && !rb_block_given_p() && NIL_P(valstr))
+ rb_raise(rb_eIndexError, "key not found");
+
+ return valstr;
+}
+
+/*
+ * call-seq:
+ * gdbm.key(value) -> key
+ *
+ * Returns the _key_ for a given _value_. If several keys may map to the
+ * same value, the key that is found first will be returned.
+ */
+static VALUE
+fgdbm_key(VALUE obj, VALUE valstr)
+{
+ struct dbmdata *dbmp;
+ GDBM_FILE dbm;
+ VALUE keystr, valstr2;
+
+ StringValue(valstr);
+ GetDBM2(obj, dbmp, dbm);
+ for (keystr = rb_gdbm_firstkey(dbm); RTEST(keystr);
+ keystr = rb_gdbm_nextkey(dbm, keystr)) {
+
+ valstr2 = rb_gdbm_fetch2(dbm, keystr);
+ if (!NIL_P(valstr2) &&
+ (int)RSTRING_LEN(valstr) == (int)RSTRING_LEN(valstr2) &&
+ memcmp(RSTRING_PTR(valstr), RSTRING_PTR(valstr2),
+ (int)RSTRING_LEN(valstr)) == 0) {
+ return keystr;
+ }
+ }
+ return Qnil;
+}
+
+/* :nodoc: */
+static VALUE
+fgdbm_index(VALUE obj, VALUE value)
+{
+ rb_warn("GDBM#index is deprecated; use GDBM#key");
+ return fgdbm_key(obj, value);
+}
+
+/*
+ * call-seq:
+ * gdbm.select { |key, value| block } -> array
+ *
+ * Returns a new array of all key-value pairs of the database for which _block_
+ * evaluates to true.
+ */
+static VALUE
+fgdbm_select(VALUE obj)
+{
+ VALUE new = rb_ary_new();
+ GDBM_FILE dbm;
+ struct dbmdata *dbmp;
+ VALUE keystr;
+
+ GetDBM2(obj, dbmp, dbm);
+ for (keystr = rb_gdbm_firstkey(dbm); RTEST(keystr);
+ keystr = rb_gdbm_nextkey(dbm, keystr)) {
+ VALUE assoc = rb_assoc_new(keystr, rb_gdbm_fetch2(dbm, keystr));
+ VALUE v = rb_yield(assoc);
+
+ if (RTEST(v)) {
+ rb_ary_push(new, assoc);
+ }
+ GetDBM2(obj, dbmp, dbm);
+ }
+
+ return new;
+}
+
+/*
+ * call-seq:
+ * gdbm.values_at(key, ...) -> array
+ *
+ * Returns an array of the values associated with each specified _key_.
+ */
+static VALUE
+fgdbm_values_at(int argc, VALUE *argv, VALUE obj)
+{
+ VALUE new = rb_ary_new2(argc);
+ int i;
+
+ for (i=0; i<argc; i++) {
+ rb_ary_push(new, rb_gdbm_fetch3(obj, argv[i]));
+ }
+
+ return new;
+}
+
+static void
+rb_gdbm_modify(VALUE obj)
+{
+ if (OBJ_FROZEN(obj)) rb_error_frozen("GDBM");
+}
+
+static VALUE
+rb_gdbm_delete(VALUE obj, VALUE keystr)
+{
+ datum key;
+ struct dbmdata *dbmp;
+ GDBM_FILE dbm;
+ long len;
+
+ rb_gdbm_modify(obj);
+ StringValue(keystr);
+ len = RSTRING_LEN(keystr);
+ if (TOO_LONG(len)) return Qnil;
+ key.dptr = RSTRING_PTR(keystr);
+ key.dsize = (int)len;
+
+ GetDBM2(obj, dbmp, dbm);
+ if (!gdbm_exists(dbm, key)) {
+ return Qnil;
+ }
+
+ if (gdbm_delete(dbm, key)) {
+ dbmp->di_size = -1;
+ rb_raise(rb_eGDBMError, "%s", gdbm_strerror(gdbm_errno));
+ }
+ else if (dbmp->di_size >= 0) {
+ dbmp->di_size--;
+ }
+ return obj;
+}
+
+/*
+ * call-seq:
+ * gdbm.delete(key) -> value or nil
+ *
+ * Removes the key-value-pair with the specified _key_ from this database and
+ * returns the corresponding _value_. Returns nil if the database is empty.
+ */
+static VALUE
+fgdbm_delete(VALUE obj, VALUE keystr)
+{
+ VALUE valstr;
+
+ valstr = fgdbm_fetch(obj, keystr, Qnil);
+ rb_gdbm_delete(obj, keystr);
+ return valstr;
+}
+
+/*
+ * call-seq:
+ * gdbm.shift -> (key, value) or nil
+ *
+ * Removes a key-value-pair from this database and returns it as a
+ * two-item array [ _key_, _value_ ]. Returns nil if the database is empty.
+ */
+static VALUE
+fgdbm_shift(VALUE obj)
+{
+ struct dbmdata *dbmp;
+ GDBM_FILE dbm;
+ VALUE keystr, valstr;
+
+ rb_gdbm_modify(obj);
+ GetDBM2(obj, dbmp, dbm);
+ keystr = rb_gdbm_firstkey(dbm);
+ if (NIL_P(keystr)) return Qnil;
+ valstr = rb_gdbm_fetch2(dbm, keystr);
+ rb_gdbm_delete(obj, keystr);
+
+ return rb_assoc_new(keystr, valstr);
+}
+
+/*
+ * call-seq:
+ * gdbm.delete_if { |key, value| block } -> gdbm
+ * gdbm.reject! { |key, value| block } -> gdbm
+ *
+ * Deletes every key-value pair from _gdbm_ for which _block_ evaluates to true.
+ */
+static VALUE
+fgdbm_delete_if(VALUE obj)
+{
+ struct dbmdata *dbmp;
+ GDBM_FILE dbm;
+ VALUE keystr, valstr;
+ VALUE ret, ary = rb_ary_tmp_new(0);
+ int i, status = 0, n;
+
+ rb_gdbm_modify(obj);
+ GetDBM2(obj, dbmp, dbm);
+ n = dbmp->di_size;
+ dbmp->di_size = -1;
+
+ for (keystr = rb_gdbm_firstkey(dbm); RTEST(keystr);
+ keystr = rb_gdbm_nextkey(dbm, keystr)) {
+
+ OBJ_FREEZE(keystr);
+ valstr = rb_gdbm_fetch2(dbm, keystr);
+ ret = rb_protect(rb_yield, rb_assoc_new(rb_str_dup(keystr), valstr), &status);
+ if (status != 0) break;
+ if (RTEST(ret)) rb_ary_push(ary, keystr);
+ GetDBM2(obj, dbmp, dbm);
+ }
+
+ for (i = 0; i < RARRAY_LEN(ary); i++)
+ rb_gdbm_delete(obj, RARRAY_PTR(ary)[i]);
+ if (status) rb_jump_tag(status);
+ if (n > 0) dbmp->di_size = n - (int)RARRAY_LEN(ary);
+ rb_ary_clear(ary);
+
+ return obj;
+}
+
+/*
+ * call-seq:
+ * gdbm.clear -> gdbm
+ *
+ * Removes all the key-value pairs within _gdbm_.
+ */
+static VALUE
+fgdbm_clear(VALUE obj)
+{
+ datum key, nextkey;
+ struct dbmdata *dbmp;
+ GDBM_FILE dbm;
+
+ rb_gdbm_modify(obj);
+ GetDBM2(obj, dbmp, dbm);
+ dbmp->di_size = -1;
+
+#if 0
+ while (key = gdbm_firstkey(dbm), key.dptr) {
+ if (gdbm_delete(dbm, key)) {
+ free(key.dptr);
+ rb_raise(rb_eGDBMError, "%s", gdbm_strerror(gdbm_errno));
+ }
+ free(key.dptr);
+ }
+#else
+ while (key = gdbm_firstkey(dbm), key.dptr) {
+ for (; key.dptr; key = nextkey) {
+ nextkey = gdbm_nextkey(dbm, key);
+ if (gdbm_delete(dbm, key)) {
+ free(key.dptr);
+ if (nextkey.dptr) free(nextkey.dptr);
+ rb_raise(rb_eGDBMError, "%s", gdbm_strerror(gdbm_errno));
+ }
+ free(key.dptr);
+ }
+ }
+#endif
+ dbmp->di_size = 0;
+
+ return obj;
+}
+
+/*
+ * call-seq:
+ * gdbm.invert -> hash
+ *
+ * Returns a hash created by using _gdbm_'s values as keys, and the keys
+ * as values.
+ */
+static VALUE
+fgdbm_invert(VALUE obj)
+{
+ struct dbmdata *dbmp;
+ GDBM_FILE dbm;
+ VALUE keystr, valstr;
+ VALUE hash = rb_hash_new();
+
+ GetDBM2(obj, dbmp, dbm);
+ for (keystr = rb_gdbm_firstkey(dbm); RTEST(keystr);
+ keystr = rb_gdbm_nextkey(dbm, keystr)) {
+ valstr = rb_gdbm_fetch2(dbm, keystr);
+
+ rb_hash_aset(hash, valstr, keystr);
+ }
+ return hash;
+}
+
+/*
+ * call-seq:
+ * gdbm[key]= value -> value
+ * gdbm.store(key, value) -> value
+ *
+ * Associates the value _value_ with the specified _key_.
+ */
+static VALUE
+fgdbm_store(VALUE obj, VALUE keystr, VALUE valstr)
+{
+ datum key, val;
+ struct dbmdata *dbmp;
+ GDBM_FILE dbm;
+
+ rb_gdbm_modify(obj);
+ StringValue(keystr);
+ StringValue(valstr);
+
+ key.dptr = RSTRING_PTR(keystr);
+ key.dsize = RSTRING_LENINT(keystr);
+
+ val.dptr = RSTRING_PTR(valstr);
+ val.dsize = RSTRING_LENINT(valstr);
+
+ GetDBM2(obj, dbmp, dbm);
+ dbmp->di_size = -1;
+ if (gdbm_store(dbm, key, val, GDBM_REPLACE)) {
+ if (errno == EPERM) rb_sys_fail(0);
+ rb_raise(rb_eGDBMError, "%s", gdbm_strerror(gdbm_errno));
+ }
+
+ return valstr;
+}
+
+static VALUE
+update_i(RB_BLOCK_CALL_FUNC_ARGLIST(pair, dbm))
+{
+ Check_Type(pair, T_ARRAY);
+ if (RARRAY_LEN(pair) < 2) {
+ rb_raise(rb_eArgError, "pair must be [key, value]");
+ }
+ fgdbm_store(dbm, RARRAY_PTR(pair)[0], RARRAY_PTR(pair)[1]);
+ return Qnil;
+}
+
+/*
+ * call-seq:
+ * gdbm.update(other) -> gdbm
+ *
+ * Adds the key-value pairs of _other_ to _gdbm_, overwriting entries with
+ * duplicate keys with those from _other_. _other_ must have an each_pair
+ * method.
+ */
+static VALUE
+fgdbm_update(VALUE obj, VALUE other)
+{
+ rb_block_call(other, rb_intern("each_pair"), 0, 0, update_i, obj);
+ return obj;
+}
+
+/*
+ * call-seq:
+ * gdbm.replace(other) -> gdbm
+ *
+ * Replaces the content of _gdbm_ with the key-value pairs of _other_.
+ * _other_ must have an each_pair method.
+ */
+static VALUE
+fgdbm_replace(VALUE obj, VALUE other)
+{
+ fgdbm_clear(obj);
+ rb_block_call(other, rb_intern("each_pair"), 0, 0, update_i, obj);
+ return obj;
+}
+
+/*
+ * call-seq:
+ * gdbm.length -> fixnum
+ * gdbm.size -> fixnum
+ *
+ * Returns the number of key-value pairs in this database.
+ */
+static VALUE
+fgdbm_length(VALUE obj)
+{
+ datum key, nextkey;
+ struct dbmdata *dbmp;
+ GDBM_FILE dbm;
+ int i = 0;
+
+ GetDBM2(obj, dbmp, dbm);
+ if (dbmp->di_size > 0) return INT2FIX(dbmp->di_size);
+
+ for (key = gdbm_firstkey(dbm); key.dptr; key = nextkey) {
+ nextkey = gdbm_nextkey(dbm, key);
+ free(key.dptr);
+ i++;
+ }
+ dbmp->di_size = i;
+
+ return INT2FIX(i);
+}
+
+/*
+ * call-seq:
+ * gdbm.empty? -> true or false
+ *
+ * Returns true if the database is empty.
+ */
+static VALUE
+fgdbm_empty_p(VALUE obj)
+{
+ datum key;
+ struct dbmdata *dbmp;
+ GDBM_FILE dbm;
+
+ GetDBM(obj, dbmp);
+ if (dbmp->di_size < 0) {
+ dbm = dbmp->di_dbm;
+
+ key = gdbm_firstkey(dbm);
+ if (key.dptr) {
+ free(key.dptr);
+ return Qfalse;
+ }
+ return Qtrue;
+ }
+
+ if (dbmp->di_size == 0) return Qtrue;
+ return Qfalse;
+}
+
+/*
+ * call-seq:
+ * gdbm.each_value { |value| block } -> gdbm
+ *
+ * Executes _block_ for each key in the database, passing the corresponding
+ * _value_ as a parameter.
+ */
+static VALUE
+fgdbm_each_value(VALUE obj)
+{
+ struct dbmdata *dbmp;
+ GDBM_FILE dbm;
+ VALUE keystr;
+
+ RETURN_ENUMERATOR(obj, 0, 0);
+
+ GetDBM2(obj, dbmp, dbm);
+ for (keystr = rb_gdbm_firstkey(dbm); RTEST(keystr);
+ keystr = rb_gdbm_nextkey(dbm, keystr)) {
+
+ rb_yield(rb_gdbm_fetch2(dbm, keystr));
+ GetDBM2(obj, dbmp, dbm);
+ }
+ return obj;
+}
+
+/*
+ * call-seq:
+ * gdbm.each_key { |key| block } -> gdbm
+ *
+ * Executes _block_ for each key in the database, passing the
+ * _key_ as a parameter.
+ */
+static VALUE
+fgdbm_each_key(VALUE obj)
+{
+ struct dbmdata *dbmp;
+ GDBM_FILE dbm;
+ VALUE keystr;
+
+ RETURN_ENUMERATOR(obj, 0, 0);
+
+ GetDBM2(obj, dbmp, dbm);
+ for (keystr = rb_gdbm_firstkey(dbm); RTEST(keystr);
+ keystr = rb_gdbm_nextkey(dbm, keystr)) {
+
+ rb_yield(keystr);
+ GetDBM2(obj, dbmp, dbm);
+ }
+ return obj;
+}
+
+/*
+ * call-seq:
+ * gdbm.each_pair { |key, value| block } -> gdbm
+ *
+ * Executes _block_ for each key in the database, passing the _key_ and the
+ * corresponding _value_ as a parameter.
+ */
+static VALUE
+fgdbm_each_pair(VALUE obj)
+{
+ GDBM_FILE dbm;
+ struct dbmdata *dbmp;
+ VALUE keystr;
+
+ RETURN_ENUMERATOR(obj, 0, 0);
+
+ GetDBM2(obj, dbmp, dbm);
+ for (keystr = rb_gdbm_firstkey(dbm); RTEST(keystr);
+ keystr = rb_gdbm_nextkey(dbm, keystr)) {
+
+ rb_yield(rb_assoc_new(keystr, rb_gdbm_fetch2(dbm, keystr)));
+ GetDBM2(obj, dbmp, dbm);
+ }
+
+ return obj;
+}
+
+/*
+ * call-seq:
+ * gdbm.keys -> array
+ *
+ * Returns an array of all keys of this database.
+ */
+static VALUE
+fgdbm_keys(VALUE obj)
+{
+ struct dbmdata *dbmp;
+ GDBM_FILE dbm;
+ VALUE keystr, ary;
+
+ GetDBM2(obj, dbmp, dbm);
+ ary = rb_ary_new();
+ for (keystr = rb_gdbm_firstkey(dbm); RTEST(keystr);
+ keystr = rb_gdbm_nextkey(dbm, keystr)) {
+
+ rb_ary_push(ary, keystr);
+ }
+
+ return ary;
+}
+
+/*
+ * call-seq:
+ * gdbm.values -> array
+ *
+ * Returns an array of all values of this database.
+ */
+static VALUE
+fgdbm_values(VALUE obj)
+{
+ datum key, nextkey;
+ struct dbmdata *dbmp;
+ GDBM_FILE dbm;
+ VALUE valstr, ary;
+
+ GetDBM2(obj, dbmp, dbm);
+ ary = rb_ary_new();
+ for (key = gdbm_firstkey(dbm); key.dptr; key = nextkey) {
+ nextkey = gdbm_nextkey(dbm, key);
+ valstr = rb_gdbm_fetch(dbm, key);
+ free(key.dptr);
+ rb_ary_push(ary, valstr);
+ }
+
+ return ary;
+}
+
+/*
+ * call-seq:
+ * gdbm.include?(k) -> true or false
+ * gdbm.has_key?(k) -> true or false
+ * gdbm.member?(k) -> true or false
+ * gdbm.key?(k) -> true or false
+ *
+ * Returns true if the given key _k_ exists within the database.
+ * Returns false otherwise.
+ */
+static VALUE
+fgdbm_has_key(VALUE obj, VALUE keystr)
+{
+ datum key;
+ struct dbmdata *dbmp;
+ GDBM_FILE dbm;
+ long len;
+
+ StringValue(keystr);
+ len = RSTRING_LENINT(keystr);
+ if (TOO_LONG(len)) return Qfalse;
+ key.dptr = RSTRING_PTR(keystr);
+ key.dsize = (int)len;
+
+ GetDBM2(obj, dbmp, dbm);
+ if (gdbm_exists(dbm, key))
+ return Qtrue;
+ return Qfalse;
+}
+
+/*
+ * call-seq:
+ * gdbm.has_value?(v) -> true or false
+ * gdbm.value?(v) -> true or false
+ *
+ * Returns true if the given value _v_ exists within the database.
+ * Returns false otherwise.
+ */
+static VALUE
+fgdbm_has_value(VALUE obj, VALUE valstr)
+{
+ struct dbmdata *dbmp;
+ GDBM_FILE dbm;
+ VALUE keystr, valstr2;
+
+ StringValue(valstr);
+ GetDBM2(obj, dbmp, dbm);
+ for (keystr = rb_gdbm_firstkey(dbm); RTEST(keystr);
+ keystr = rb_gdbm_nextkey(dbm, keystr)) {
+
+ valstr2 = rb_gdbm_fetch2(dbm, keystr);
+
+ if (!NIL_P(valstr2) &&
+ (int)RSTRING_LEN(valstr) == (int)RSTRING_LEN(valstr2) &&
+ memcmp(RSTRING_PTR(valstr), RSTRING_PTR(valstr2),
+ (int)RSTRING_LEN(valstr)) == 0) {
+ return Qtrue;
+ }
+ }
+ return Qfalse;
+}
+
+/*
+ * call-seq:
+ * gdbm.to_a -> array
+ *
+ * Returns an array of all key-value pairs contained in the database.
+ */
+static VALUE
+fgdbm_to_a(VALUE obj)
+{
+ struct dbmdata *dbmp;
+ GDBM_FILE dbm;
+ VALUE keystr, ary;
+
+ GetDBM2(obj, dbmp, dbm);
+ ary = rb_ary_new();
+ for (keystr = rb_gdbm_firstkey(dbm); RTEST(keystr);
+ keystr = rb_gdbm_nextkey(dbm, keystr)) {
+
+ rb_ary_push(ary, rb_assoc_new(keystr, rb_gdbm_fetch2(dbm, keystr)));
+ }
+
+ return ary;
+}
+
+/*
+ * call-seq:
+ * gdbm.reorganize -> gdbm
+ *
+ * Reorganizes the database file. This operation removes reserved space of
+ * elements that have already been deleted. It is only useful after a lot of
+ * deletions in the database.
+ */
+static VALUE
+fgdbm_reorganize(VALUE obj)
+{
+ struct dbmdata *dbmp;
+ GDBM_FILE dbm;
+
+ rb_gdbm_modify(obj);
+ GetDBM2(obj, dbmp, dbm);
+ gdbm_reorganize(dbm);
+ rb_fd_fix_cloexec(gdbm_fdesc(dbm));
+ return obj;
+}
+
+/*
+ * call-seq:
+ * gdbm.sync -> gdbm
+ *
+ * Unless the _gdbm_ object has been opened with the *SYNC* flag, it is not
+ * guaranteed that database modification operations are immediately applied to
+ * the database file. This method ensures that all recent modifications
+ * to the database are written to the file. Blocks until all writing operations
+ * to the disk have been finished.
+ */
+static VALUE
+fgdbm_sync(VALUE obj)
+{
+ struct dbmdata *dbmp;
+ GDBM_FILE dbm;
+
+ rb_gdbm_modify(obj);
+ GetDBM2(obj, dbmp, dbm);
+ gdbm_sync(dbm);
+ return obj;
+}
+
+/*
+ * call-seq:
+ * gdbm.cachesize = size -> size
+ *
+ * Sets the size of the internal bucket cache to _size_.
+ */
+static VALUE
+fgdbm_set_cachesize(VALUE obj, VALUE val)
+{
+ struct dbmdata *dbmp;
+ GDBM_FILE dbm;
+ int optval;
+
+ GetDBM2(obj, dbmp, dbm);
+ optval = FIX2INT(val);
+ if (gdbm_setopt(dbm, GDBM_CACHESIZE, &optval, sizeof(optval)) == -1) {
+ rb_raise(rb_eGDBMError, "%s", gdbm_strerror(gdbm_errno));
+ }
+ return val;
+}
+
+/*
+ * call-seq:
+ * gdbm.fastmode = boolean -> boolean
+ *
+ * Turns the database's fast mode on or off. If fast mode is turned on, gdbm
+ * does not wait for writes to be flushed to the disk before continuing.
+ *
+ * This option is obsolete for gdbm >= 1.8 since fast mode is turned on by
+ * default. See also: #syncmode=
+ */
+static VALUE
+fgdbm_set_fastmode(VALUE obj, VALUE val)
+{
+ struct dbmdata *dbmp;
+ GDBM_FILE dbm;
+ int optval;
+
+ GetDBM2(obj, dbmp, dbm);
+ optval = 0;
+ if (RTEST(val))
+ optval = 1;
+
+ if (gdbm_setopt(dbm, GDBM_FASTMODE, &optval, sizeof(optval)) == -1) {
+ rb_raise(rb_eGDBMError, "%s", gdbm_strerror(gdbm_errno));
+ }
+ return val;
+}
+
+/*
+ * call-seq:
+ * gdbm.syncmode = boolean -> boolean
+ *
+ * Turns the database's synchronization mode on or off. If the synchronization
+ * mode is turned on, the database's in-memory state will be synchronized to
+ * disk after every database modification operation. If the synchronization
+ * mode is turned off, GDBM does not wait for writes to be flushed to the disk
+ * before continuing.
+ *
+ * This option is only available for gdbm >= 1.8 where syncmode is turned off
+ * by default. See also: #fastmode=
+ */
+static VALUE
+fgdbm_set_syncmode(VALUE obj, VALUE val)
+{
+#if !defined(GDBM_SYNCMODE)
+ fgdbm_set_fastmode(obj, RTEST(val) ? Qfalse : Qtrue);
+ return val;
+#else
+ struct dbmdata *dbmp;
+ GDBM_FILE dbm;
+ int optval;
+
+ GetDBM2(obj, dbmp, dbm);
+ optval = 0;
+ if (RTEST(val))
+ optval = 1;
+
+ if (gdbm_setopt(dbm, GDBM_FASTMODE, &optval, sizeof(optval)) == -1) {
+ rb_raise(rb_eGDBMError, "%s", gdbm_strerror(gdbm_errno));
+ }
+ return val;
+#endif
+}
+
+/*
+ * call-seq:
+ * gdbm.to_hash -> hash
+ *
+ * Returns a hash of all key-value pairs contained in the database.
+ */
+static VALUE
+fgdbm_to_hash(VALUE obj)
+{
+ struct dbmdata *dbmp;
+ GDBM_FILE dbm;
+ VALUE keystr, hash;
+
+ GetDBM2(obj, dbmp, dbm);
+ hash = rb_hash_new();
+ for (keystr = rb_gdbm_firstkey(dbm); RTEST(keystr);
+ keystr = rb_gdbm_nextkey(dbm, keystr)) {
+
+ rb_hash_aset(hash, keystr, rb_gdbm_fetch2(dbm, keystr));
+ }
+
+ return hash;
+}
+
+/*
+ * call-seq:
+ * gdbm.reject { |key, value| block } -> hash
+ *
+ * Returns a hash copy of _gdbm_ where all key-value pairs from _gdbm_ for
+ * which _block_ evaluates to true are removed. See also: #delete_if
+ */
+static VALUE
+fgdbm_reject(VALUE obj)
+{
+ return rb_hash_delete_if(fgdbm_to_hash(obj));
+}
+
+void
+Init_gdbm(void)
+{
+ rb_cGDBM = rb_define_class("GDBM", rb_cObject);
+ rb_eGDBMError = rb_define_class("GDBMError", rb_eStandardError);
+ rb_eGDBMFatalError = rb_define_class("GDBMFatalError", rb_eException);
+ rb_include_module(rb_cGDBM, rb_mEnumerable);
+
+ rb_define_alloc_func(rb_cGDBM, fgdbm_s_alloc);
+ rb_define_singleton_method(rb_cGDBM, "open", fgdbm_s_open, -1);
+
+ rb_define_method(rb_cGDBM, "initialize", fgdbm_initialize, -1);
+ rb_define_method(rb_cGDBM, "close", fgdbm_close, 0);
+ rb_define_method(rb_cGDBM, "closed?", fgdbm_closed, 0);
+ rb_define_method(rb_cGDBM, "[]", fgdbm_aref, 1);
+ rb_define_method(rb_cGDBM, "fetch", fgdbm_fetch_m, -1);
+ rb_define_method(rb_cGDBM, "[]=", fgdbm_store, 2);
+ rb_define_method(rb_cGDBM, "store", fgdbm_store, 2);
+ rb_define_method(rb_cGDBM, "index", fgdbm_index, 1);
+ rb_define_method(rb_cGDBM, "key", fgdbm_key, 1);
+ rb_define_method(rb_cGDBM, "select", fgdbm_select, 0);
+ rb_define_method(rb_cGDBM, "values_at", fgdbm_values_at, -1);
+ rb_define_method(rb_cGDBM, "length", fgdbm_length, 0);
+ rb_define_method(rb_cGDBM, "size", fgdbm_length, 0);
+ rb_define_method(rb_cGDBM, "empty?", fgdbm_empty_p, 0);
+ rb_define_method(rb_cGDBM, "each", fgdbm_each_pair, 0);
+ rb_define_method(rb_cGDBM, "each_value", fgdbm_each_value, 0);
+ rb_define_method(rb_cGDBM, "each_key", fgdbm_each_key, 0);
+ rb_define_method(rb_cGDBM, "each_pair", fgdbm_each_pair, 0);
+ rb_define_method(rb_cGDBM, "keys", fgdbm_keys, 0);
+ rb_define_method(rb_cGDBM, "values", fgdbm_values, 0);
+ rb_define_method(rb_cGDBM, "shift", fgdbm_shift, 0);
+ rb_define_method(rb_cGDBM, "delete", fgdbm_delete, 1);
+ rb_define_method(rb_cGDBM, "delete_if", fgdbm_delete_if, 0);
+ rb_define_method(rb_cGDBM, "reject!", fgdbm_delete_if, 0);
+ rb_define_method(rb_cGDBM, "reject", fgdbm_reject, 0);
+ rb_define_method(rb_cGDBM, "clear", fgdbm_clear, 0);
+ rb_define_method(rb_cGDBM, "invert", fgdbm_invert, 0);
+ rb_define_method(rb_cGDBM, "update", fgdbm_update, 1);
+ rb_define_method(rb_cGDBM, "replace", fgdbm_replace, 1);
+ rb_define_method(rb_cGDBM, "reorganize", fgdbm_reorganize, 0);
+ rb_define_method(rb_cGDBM, "sync", fgdbm_sync, 0);
+ /* rb_define_method(rb_cGDBM, "setopt", fgdbm_setopt, 2); */
+ rb_define_method(rb_cGDBM, "cachesize=", fgdbm_set_cachesize, 1);
+ rb_define_method(rb_cGDBM, "fastmode=", fgdbm_set_fastmode, 1);
+ rb_define_method(rb_cGDBM, "syncmode=", fgdbm_set_syncmode, 1);
+
+ rb_define_method(rb_cGDBM, "include?", fgdbm_has_key, 1);
+ rb_define_method(rb_cGDBM, "has_key?", fgdbm_has_key, 1);
+ rb_define_method(rb_cGDBM, "member?", fgdbm_has_key, 1);
+ rb_define_method(rb_cGDBM, "has_value?", fgdbm_has_value, 1);
+ rb_define_method(rb_cGDBM, "key?", fgdbm_has_key, 1);
+ rb_define_method(rb_cGDBM, "value?", fgdbm_has_value, 1);
+
+ rb_define_method(rb_cGDBM, "to_a", fgdbm_to_a, 0);
+ rb_define_method(rb_cGDBM, "to_hash", fgdbm_to_hash, 0);
+
+ /* flag for #new and #open: open database as a reader */
+ rb_define_const(rb_cGDBM, "READER", INT2FIX(GDBM_READER|RUBY_GDBM_RW_BIT));
+ /* flag for #new and #open: open database as a writer */
+ rb_define_const(rb_cGDBM, "WRITER", INT2FIX(GDBM_WRITER|RUBY_GDBM_RW_BIT));
+ /* flag for #new and #open: open database as a writer; if the database does not exist, create a new one */
+ rb_define_const(rb_cGDBM, "WRCREAT", INT2FIX(GDBM_WRCREAT|RUBY_GDBM_RW_BIT));
+ /* flag for #new and #open: open database as a writer; overwrite any existing databases */
+ rb_define_const(rb_cGDBM, "NEWDB", INT2FIX(GDBM_NEWDB|RUBY_GDBM_RW_BIT));
+
+ /* flag for #new and #open. this flag is obsolete for gdbm >= 1.8 */
+ rb_define_const(rb_cGDBM, "FAST", INT2FIX(GDBM_FAST));
+ /* this flag is obsolete in gdbm 1.8.
+ On gdbm 1.8, fast mode is default behavior. */
+
+ /* gdbm version 1.8 specific */
+#if defined(GDBM_SYNC)
+ /* flag for #new and #open. only for gdbm >= 1.8 */
+ rb_define_const(rb_cGDBM, "SYNC", INT2FIX(GDBM_SYNC));
+#endif
+#if defined(GDBM_NOLOCK)
+ /* flag for #new and #open */
+ rb_define_const(rb_cGDBM, "NOLOCK", INT2FIX(GDBM_NOLOCK));
+#endif
+ /* version of the gdbm library*/
+ rb_define_const(rb_cGDBM, "VERSION", rb_str_new2(gdbm_version));
+}
diff --git a/jni/ruby/ext/io/console/Makefile b/jni/ruby/ext/io/console/Makefile
new file mode 100644
index 0000000..fad3282
--- /dev/null
+++ b/jni/ruby/ext/io/console/Makefile
@@ -0,0 +1,284 @@
+
+SHELL = /bin/sh
+
+# V=0 quiet, V=1 verbose. other values don't work.
+V = 0
+Q1 = $(V:1=)
+Q = $(Q1:0=@)
+ECHO1 = $(V:1=@:)
+ECHO = $(ECHO1:0=@echo)
+NULLCMD = :
+
+#### Start of system configuration section. ####
+top_srcdir = $(topdir)/.
+srcdir = $(top_srcdir)/ext/io/console
+topdir = ../../..
+hdrdir = $(top_srcdir)/include
+arch_hdrdir = $(extout)/include/$(arch)
+PATH_SEPARATOR = :
+VPATH = $(srcdir):$(arch_hdrdir)/ruby:$(hdrdir)/ruby
+RUBYLIB =
+RUBYOPT = -
+prefix = $(DESTDIR)/usr/local
+rubysitearchprefix = $(rubylibprefix)/$(sitearch)
+rubyarchprefix = $(rubylibprefix)/$(arch)
+rubylibprefix = $(libdir)/$(RUBY_BASE_NAME)
+exec_prefix = $(prefix)
+vendorarchhdrdir = $(vendorhdrdir)/$(sitearch)
+sitearchhdrdir = $(sitehdrdir)/$(sitearch)
+rubyarchhdrdir = $(rubyhdrdir)/$(arch)
+vendorhdrdir = $(rubyhdrdir)/vendor_ruby
+sitehdrdir = $(rubyhdrdir)/site_ruby
+rubyhdrdir = $(includedir)/$(RUBY_VERSION_NAME)
+vendorarchdir = $(vendorlibdir)/$(sitearch)
+vendorlibdir = $(vendordir)/$(ruby_version)
+vendordir = $(rubylibprefix)/vendor_ruby
+sitearchdir = $(sitelibdir)/$(sitearch)
+sitelibdir = $(sitedir)/$(ruby_version)
+sitedir = $(rubylibprefix)/site_ruby
+rubyarchdir = $(rubylibdir)/$(arch)
+rubylibdir = $(rubylibprefix)/$(ruby_version)
+sitearchincludedir = $(includedir)/$(sitearch)
+archincludedir = $(includedir)/$(arch)
+sitearchlibdir = $(libdir)/$(sitearch)
+archlibdir = $(libdir)/$(arch)
+ridir = $(datarootdir)/$(RI_BASE_NAME)
+mandir = $(datarootdir)/man
+localedir = $(datarootdir)/locale
+libdir = $(exec_prefix)/lib
+psdir = $(docdir)
+pdfdir = $(docdir)
+dvidir = $(docdir)
+htmldir = $(docdir)
+infodir = $(datarootdir)/info
+docdir = $(datarootdir)/doc/$(PACKAGE)
+oldincludedir = $(DESTDIR)/usr/include
+includedir = $(prefix)/include
+localstatedir = $(prefix)/var
+sharedstatedir = $(prefix)/com
+sysconfdir = $(prefix)/etc
+datadir = $(datarootdir)
+datarootdir = $(prefix)/share
+libexecdir = $(exec_prefix)/libexec
+sbindir = $(exec_prefix)/sbin
+bindir = $(exec_prefix)/bin
+archdir = $(rubyarchdir)
+
+
+CC = gcc
+CXX = g++
+LIBRUBY = $(LIBRUBY_SO)
+LIBRUBY_A = lib$(RUBY_SO_NAME)-static.a
+LIBRUBYARG_SHARED = -Wl,-R$(libdir) -L$(libdir) -l$(RUBY_SO_NAME)
+LIBRUBYARG_STATIC = -Wl,-R$(libdir) -L$(libdir) -l$(RUBY_SO_NAME)-static
+empty =
+OUTFLAG = -o $(empty)
+COUTFLAG = -o $(empty)
+
+RUBY_EXTCONF_H = extconf.h
+cflags = $(optflags) $(debugflags) $(warnflags)
+optflags = -O3 -fno-fast-math
+debugflags = -ggdb3
+warnflags = -Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wunused-variable -Wpointer-arith -Wwrite-strings -Wdeclaration-after-statement -Wimplicit-function-declaration -Wdeprecated-declarations -Wno-packed-bitfield-compat
+CCDLFLAGS = -fPIC
+CFLAGS = $(CCDLFLAGS) $(cflags) -fPIC $(ARCH_FLAG)
+INCFLAGS = -I. -I$(arch_hdrdir) -I$(hdrdir) -I$(srcdir)
+DEFS =
+CPPFLAGS = -DRUBY_EXTCONF_H=\"$(RUBY_EXTCONF_H)\" $(DEFS) $(cppflags)
+CXXFLAGS = $(CCDLFLAGS) $(cxxflags) $(ARCH_FLAG)
+ldflags = -L. -fstack-protector -rdynamic -Wl,-export-dynamic
+dldflags =
+ARCH_FLAG =
+DLDFLAGS = $(ldflags) $(dldflags) $(ARCH_FLAG)
+LDSHARED = $(CC) -shared
+LDSHAREDXX = $(CXX) -shared
+AR = ar
+EXEEXT =
+
+RUBY_INSTALL_NAME = $(RUBY_BASE_NAME)
+RUBY_SO_NAME = ruby
+RUBYW_INSTALL_NAME =
+RUBY_VERSION_NAME = $(RUBY_BASE_NAME)-$(ruby_version)
+RUBYW_BASE_NAME = rubyw
+RUBY_BASE_NAME = ruby
+
+arch = x86_64-linux
+sitearch = $(arch)
+ruby_version = 2.2.0
+ruby = $(topdir)/miniruby -I'$(topdir)' -I'$(top_srcdir)/lib' -I'$(extout)/$(arch)' -I'$(extout)/common'
+RUBY = $(ruby)
+ruby_headers = $(hdrdir)/ruby.h $(hdrdir)/ruby/ruby.h $(hdrdir)/ruby/defines.h $(hdrdir)/ruby/missing.h $(hdrdir)/ruby/intern.h $(hdrdir)/ruby/st.h $(hdrdir)/ruby/subst.h $(arch_hdrdir)/ruby/config.h $(RUBY_EXTCONF_H)
+
+RM = rm -f
+RM_RF = $(RUBY) -run -e rm -- -rf
+RMDIRS = rmdir --ignore-fail-on-non-empty -p
+MAKEDIRS = /bin/mkdir -p
+INSTALL = /usr/bin/install -c
+INSTALL_PROG = $(INSTALL) -m 0755
+INSTALL_DATA = $(INSTALL) -m 644
+COPY = cp
+TOUCH = exit >
+
+#### End of system configuration section. ####
+
+preload =
+
+libpath = . $(topdir)
+LIBPATH = -L. -L$(topdir)
+DEFFILE =
+
+CLEANFILES = mkmf.log
+DISTCLEANFILES =
+DISTCLEANDIRS =
+
+extout = $(topdir)/.ext
+extout_prefix = $(extout)$(target_prefix)/
+target_prefix = /io
+LOCAL_LIBS =
+LIBS = $(LIBRUBYARG_SHARED) -lpthread -lgmp -ldl -lcrypt -lm -lc
+ORIG_SRCS = console.c
+SRCS = $(ORIG_SRCS)
+OBJS = console.o
+HDRS = $(srcdir)/extconf.h
+TARGET = console
+TARGET_NAME = console
+TARGET_ENTRY = Init_$(TARGET_NAME)
+DLLIB = $(TARGET).so
+EXTSTATIC =
+STATIC_LIB = $(TARGET).a
+
+TIMESTAMP_DIR = $(extout)/.timestamp
+BINDIR = $(extout)/bin
+RUBYCOMMONDIR = $(extout)/common
+RUBYLIBDIR = $(RUBYCOMMONDIR)$(target_prefix)
+RUBYARCHDIR = $(extout)/$(arch)$(target_prefix)
+HDRDIR = $(extout)/include/ruby$(target_prefix)
+ARCHHDRDIR = $(extout)/include/$(arch)/ruby$(target_prefix)
+
+TARGET_SO = $(RUBYARCHDIR)/$(DLLIB)
+CLEANLIBS = $(RUBYARCHDIR)/$(TARGET).so
+CLEANOBJS = *.o *.bak
+
+all: install
+static: all
+.PHONY: all install static install-so install-rb
+.PHONY: clean clean-so clean-static clean-rb
+
+clean-static::
+clean-rb-default::
+clean-rb::
+clean-so::
+clean: clean-so clean-static clean-rb-default clean-rb
+ -$(Q)$(RM) $(CLEANLIBS) $(CLEANOBJS) $(CLEANFILES) .*.time
+
+distclean-rb-default::
+distclean-rb::
+distclean-so::
+distclean-static::
+distclean: clean distclean-so distclean-static distclean-rb-default distclean-rb
+ -$(Q)$(RM) Makefile $(RUBY_EXTCONF_H) conftest.* mkmf.log
+ -$(Q)$(RM) core ruby$(EXEEXT) *~ $(DISTCLEANFILES)
+ -$(Q)$(RMDIRS) $(DISTCLEANDIRS) 2> /dev/null || true
+
+realclean: distclean
+install: install-so install-rb
+
+install-so: $(RUBYARCHDIR)/$(DLLIB)
+clean-so::
+ -$(Q)$(RM) $(RUBYARCHDIR)/$(DLLIB)
+ -$(Q)$(RMDIRS) $(RUBYARCHDIR) 2> /dev/null || true
+clean-static::
+ -$(Q)$(RM) $(STATIC_LIB)
+install-rb: pre-install-rb install-rb-default
+install-rb-default: pre-install-rb-default
+pre-install-rb: Makefile
+pre-install-rb-default: Makefile
+pre-install-rb-default: $(TIMESTAMP_DIR)/.RUBYLIBDIR.-.io.-.console.time
+install-rb-default: $(RUBYLIBDIR)/console/size.rb
+$(RUBYLIBDIR)/console/size.rb: $(srcdir)/lib/console/size.rb $(TIMESTAMP_DIR)/.RUBYLIBDIR.-.io.-.console.time
+ $(Q) $(COPY) $(srcdir)/lib/console/size.rb $(@D)
+clean-rb-default::
+ -$(Q)$(RM) $(RUBYLIBDIR)/console/size.rb
+pre-install-rb-default:
+ $(ECHO) installing default console libraries
+clean-rb-default::
+ -$(Q)$(RMDIRS) $(RUBYLIBDIR)/console 2> /dev/null || true
+$(TIMESTAMP_DIR)/.RUBYARCHDIR.-.io.time:
+ $(Q) $(MAKEDIRS) $(@D) $(RUBYARCHDIR)
+ $(Q) $(TOUCH) $@
+$(TIMESTAMP_DIR)/.RUBYLIBDIR.-.io.-.console.time:
+ $(Q) $(MAKEDIRS) $(@D) $(RUBYLIBDIR)/console
+ $(Q) $(TOUCH) $@
+
+site-install: site-install-so site-install-rb
+site-install-so: install-so
+site-install-rb: install-rb
+
+.SUFFIXES: .c .m .cc .mm .cxx .cpp .o .S
+
+.cc.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<
+
+.cc.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -S $<
+
+.mm.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<
+
+.mm.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -S $<
+
+.cxx.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<
+
+.cxx.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -S $<
+
+.cpp.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<
+
+.cpp.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -S $<
+
+.c.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -c $<
+
+.c.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -S $<
+
+.m.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -c $<
+
+.m.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -S $<
+
+$(RUBYARCHDIR)/$(DLLIB): $(OBJS) Makefile $(TIMESTAMP_DIR)/.RUBYARCHDIR.-.io.time
+ $(ECHO) linking shared-object io/$(DLLIB)
+ -$(Q)$(RM) $(@)
+ $(Q) $(LDSHARED) -o $@ $(OBJS) $(LIBPATH) $(DLDFLAGS) $(LOCAL_LIBS) $(LIBS)
+
+$(STATIC_LIB): $(OBJS)
+ -$(Q)$(RM) $(@)
+ $(ECHO) linking static-library $(@)
+ $(Q) $(AR) cru $@ $(OBJS)
+ -$(Q)ranlib $(@) 2> /dev/null || true
+
+###
+$(OBJS): $(RUBY_EXTCONF_H)
+
+$(OBJS): $(HDRS) $(ruby_headers) \
+ $(hdrdir)/ruby/io.h \
+ $(hdrdir)/ruby/encoding.h \
+ $(hdrdir)/ruby/oniguruma.h
diff --git a/jni/ruby/ext/io/console/console.c b/jni/ruby/ext/io/console/console.c
new file mode 100644
index 0000000..e846450
--- /dev/null
+++ b/jni/ruby/ext/io/console/console.c
@@ -0,0 +1,774 @@
+/* -*- c-file-style: "ruby" -*- */
+/*
+ * console IO module
+ */
+#include "ruby.h"
+#include "ruby/io.h"
+
+#ifdef HAVE_UNISTD_H
+#include <unistd.h>
+#endif
+#ifdef HAVE_FCNTL_H
+#include <fcntl.h>
+#endif
+#ifdef HAVE_SYS_IOCTL_H
+#include <sys/ioctl.h>
+#endif
+
+#if defined HAVE_TERMIOS_H
+# include <termios.h>
+typedef struct termios conmode;
+
+static int
+setattr(int fd, conmode *t)
+{
+ while (tcsetattr(fd, TCSAFLUSH, t)) {
+ if (errno != EINTR) return 0;
+ }
+ return 1;
+}
+# define getattr(fd, t) (tcgetattr(fd, t) == 0)
+#elif defined HAVE_TERMIO_H
+# include <termio.h>
+typedef struct termio conmode;
+# define setattr(fd, t) (ioctl(fd, TCSETAF, t) == 0)
+# define getattr(fd, t) (ioctl(fd, TCGETA, t) == 0)
+#elif defined HAVE_SGTTY_H
+# include <sgtty.h>
+typedef struct sgttyb conmode;
+# ifdef HAVE_STTY
+# define setattr(fd, t) (stty(fd, t) == 0)
+# else
+# define setattr(fd, t) (ioctl((fd), TIOCSETP, (t)) == 0)
+# endif
+# ifdef HAVE_GTTY
+# define getattr(fd, t) (gtty(fd, t) == 0)
+# else
+# define getattr(fd, t) (ioctl((fd), TIOCGETP, (t)) == 0)
+# endif
+#elif defined _WIN32
+#include <winioctl.h>
+typedef DWORD conmode;
+
+#ifdef HAVE_RB_W32_MAP_ERRNO
+#define LAST_ERROR rb_w32_map_errno(GetLastError())
+#else
+#define LAST_ERROR EBADF
+#endif
+#define SET_LAST_ERROR (errno = LAST_ERROR, 0)
+
+static int
+setattr(int fd, conmode *t)
+{
+ int x = SetConsoleMode((HANDLE)rb_w32_get_osfhandle(fd), *t);
+ if (!x) errno = LAST_ERROR;
+ return x;
+}
+
+static int
+getattr(int fd, conmode *t)
+{
+ int x = GetConsoleMode((HANDLE)rb_w32_get_osfhandle(fd), t);
+ if (!x) errno = LAST_ERROR;
+ return x;
+}
+#endif
+#ifndef SET_LAST_ERROR
+#define SET_LAST_ERROR (0)
+#endif
+
+static ID id_getc, id_console, id_close;
+
+typedef struct {
+ int vmin;
+ int vtime;
+} rawmode_arg_t;
+
+static rawmode_arg_t *
+rawmode_opt(int argc, VALUE *argv, rawmode_arg_t *opts)
+{
+ rawmode_arg_t *optp = NULL;
+ VALUE vopts;
+ rb_scan_args(argc, argv, "0:", &vopts);
+ if (!NIL_P(vopts)) {
+ VALUE vmin = rb_hash_aref(vopts, ID2SYM(rb_intern("min")));
+ VALUE vtime = rb_hash_aref(vopts, ID2SYM(rb_intern("time")));
+ /* default values by `stty raw` */
+ opts->vmin = 1;
+ opts->vtime = 0;
+ if (!NIL_P(vmin)) {
+ opts->vmin = NUM2INT(vmin);
+ optp = opts;
+ }
+ if (!NIL_P(vtime)) {
+ VALUE v10 = INT2FIX(10);
+ vtime = rb_funcall3(vtime, '*', 1, &v10);
+ opts->vtime = NUM2INT(vtime);
+ optp = opts;
+ }
+ }
+ return optp;
+}
+
+static void
+set_rawmode(conmode *t, void *arg)
+{
+#ifdef HAVE_CFMAKERAW
+ cfmakeraw(t);
+ t->c_lflag &= ~(ECHOE|ECHOK);
+#elif defined HAVE_TERMIOS_H || defined HAVE_TERMIO_H
+ t->c_iflag &= ~(IGNBRK|BRKINT|PARMRK|ISTRIP|INLCR|IGNCR|ICRNL|IXON);
+ t->c_oflag &= ~OPOST;
+ t->c_lflag &= ~(ECHO|ECHOE|ECHOK|ECHONL|ICANON|ISIG|IEXTEN);
+ t->c_cflag &= ~(CSIZE|PARENB);
+ t->c_cflag |= CS8;
+#elif defined HAVE_SGTTY_H
+ t->sg_flags &= ~ECHO;
+ t->sg_flags |= RAW;
+#elif defined _WIN32
+ *t = 0;
+#endif
+#if defined HAVE_TERMIOS_H || defined HAVE_TERMIO_H
+ if (arg) {
+ const rawmode_arg_t *r = arg;
+ if (r->vmin >= 0) t->c_cc[VMIN] = r->vmin;
+ if (r->vtime >= 0) t->c_cc[VTIME] = r->vtime;
+ }
+#endif
+}
+
+static void
+set_cookedmode(conmode *t, void *arg)
+{
+#if defined HAVE_TERMIOS_H || defined HAVE_TERMIO_H
+ t->c_iflag |= (BRKINT|ISTRIP|ICRNL|IXON);
+ t->c_oflag |= OPOST;
+ t->c_lflag |= (ECHO|ECHOE|ECHOK|ECHONL|ICANON|ISIG|IEXTEN);
+#elif defined HAVE_SGTTY_H
+ t->sg_flags |= ECHO;
+ t->sg_flags &= ~RAW;
+#elif defined _WIN32
+ *t |= ENABLE_ECHO_INPUT|ENABLE_LINE_INPUT|ENABLE_PROCESSED_INPUT;
+#endif
+}
+
+static void
+set_noecho(conmode *t, void *arg)
+{
+#if defined HAVE_TERMIOS_H || defined HAVE_TERMIO_H
+ t->c_lflag &= ~(ECHO | ECHOE | ECHOK | ECHONL);
+#elif defined HAVE_SGTTY_H
+ t->sg_flags &= ~ECHO;
+#elif defined _WIN32
+ *t &= ~ENABLE_ECHO_INPUT;
+#endif
+}
+
+static void
+set_echo(conmode *t, void *arg)
+{
+#if defined HAVE_TERMIOS_H || defined HAVE_TERMIO_H
+ t->c_lflag |= (ECHO | ECHOE | ECHOK | ECHONL);
+#elif defined HAVE_SGTTY_H
+ t->sg_flags |= ECHO;
+#elif defined _WIN32
+ *t |= ENABLE_ECHO_INPUT;
+#endif
+}
+
+static int
+echo_p(conmode *t)
+{
+#if defined HAVE_TERMIOS_H || defined HAVE_TERMIO_H
+ return (t->c_lflag & (ECHO | ECHONL)) != 0;
+#elif defined HAVE_SGTTY_H
+ return (t->sg_flags & ECHO) != 0;
+#elif defined _WIN32
+ return (*t & ENABLE_ECHO_INPUT) != 0;
+#endif
+}
+
+static int
+set_ttymode(int fd, conmode *t, void (*setter)(conmode *, void *), void *arg)
+{
+ conmode r;
+ if (!getattr(fd, t)) return 0;
+ r = *t;
+ setter(&r, arg);
+ return setattr(fd, &r);
+}
+
+#define GetReadFD(fptr) ((fptr)->fd)
+
+static inline int
+get_write_fd(const rb_io_t *fptr)
+{
+ VALUE wio = fptr->tied_io_for_writing;
+ rb_io_t *ofptr;
+ if (!wio) return fptr->fd;
+ GetOpenFile(wio, ofptr);
+ return ofptr->fd;
+}
+#define GetWriteFD(fptr) get_write_fd(fptr)
+
+#define FD_PER_IO 2
+
+static VALUE
+ttymode(VALUE io, VALUE (*func)(VALUE), void (*setter)(conmode *, void *), void *arg)
+{
+ rb_io_t *fptr;
+ int status = -1;
+ int error = 0;
+ int fd[FD_PER_IO];
+ conmode t[FD_PER_IO];
+ VALUE result = Qnil;
+
+ GetOpenFile(io, fptr);
+ fd[0] = GetReadFD(fptr);
+ if (fd[0] != -1) {
+ if (set_ttymode(fd[0], t+0, setter, arg)) {
+ status = 0;
+ }
+ else {
+ error = errno;
+ fd[0] = -1;
+ }
+ }
+ fd[1] = GetWriteFD(fptr);
+ if (fd[1] != -1 && fd[1] != fd[0]) {
+ if (set_ttymode(fd[1], t+1, setter, arg)) {
+ status = 0;
+ }
+ else {
+ error = errno;
+ fd[1] = -1;
+ }
+ }
+ if (status == 0) {
+ result = rb_protect(func, io, &status);
+ }
+ GetOpenFile(io, fptr);
+ if (fd[0] != -1 && fd[0] == GetReadFD(fptr)) {
+ if (!setattr(fd[0], t+0)) {
+ error = errno;
+ status = -1;
+ }
+ }
+ if (fd[1] != -1 && fd[1] != fd[0] && fd[1] == GetWriteFD(fptr)) {
+ if (!setattr(fd[1], t+1)) {
+ error = errno;
+ status = -1;
+ }
+ }
+ if (status) {
+ if (status == -1) {
+ errno = error;
+ rb_sys_fail(0);
+ }
+ rb_jump_tag(status);
+ }
+ return result;
+}
+
+/*
+ * call-seq:
+ * io.raw(min: nil, time: nil) {|io| }
+ *
+ * Yields +self+ within raw mode.
+ *
+ * STDIN.raw(&:gets)
+ *
+ * will read and return a line without echo back and line editing.
+ *
+ * You must require 'io/console' to use this method.
+ */
+static VALUE
+console_raw(int argc, VALUE *argv, VALUE io)
+{
+ rawmode_arg_t opts, *optp = rawmode_opt(argc, argv, &opts);
+ return ttymode(io, rb_yield, set_rawmode, optp);
+}
+
+/*
+ * call-seq:
+ * io.raw!(min: nil, time: nil)
+ *
+ * Enables raw mode.
+ *
+ * If the terminal mode needs to be back, use io.raw { ... }.
+ *
+ * You must require 'io/console' to use this method.
+ */
+static VALUE
+console_set_raw(int argc, VALUE *argv, VALUE io)
+{
+ conmode t;
+ rb_io_t *fptr;
+ int fd;
+ rawmode_arg_t opts, *optp = rawmode_opt(argc, argv, &opts);
+
+ GetOpenFile(io, fptr);
+ fd = GetReadFD(fptr);
+ if (!getattr(fd, &t)) rb_sys_fail(0);
+ set_rawmode(&t, optp);
+ if (!setattr(fd, &t)) rb_sys_fail(0);
+ return io;
+}
+
+/*
+ * call-seq:
+ * io.cooked {|io| }
+ *
+ * Yields +self+ within cooked mode.
+ *
+ * STDIN.cooked(&:gets)
+ *
+ * will read and return a line with echo back and line editing.
+ *
+ * You must require 'io/console' to use this method.
+ */
+static VALUE
+console_cooked(VALUE io)
+{
+ return ttymode(io, rb_yield, set_cookedmode, NULL);
+}
+
+/*
+ * call-seq:
+ * io.cooked!
+ *
+ * Enables cooked mode.
+ *
+ * If the terminal mode needs to be back, use io.cooked { ... }.
+ *
+ * You must require 'io/console' to use this method.
+ */
+static VALUE
+console_set_cooked(VALUE io)
+{
+ conmode t;
+ rb_io_t *fptr;
+ int fd;
+
+ GetOpenFile(io, fptr);
+ fd = GetReadFD(fptr);
+ if (!getattr(fd, &t)) rb_sys_fail(0);
+ set_cookedmode(&t, NULL);
+ if (!setattr(fd, &t)) rb_sys_fail(0);
+ return io;
+}
+
+static VALUE
+getc_call(VALUE io)
+{
+ return rb_funcall2(io, id_getc, 0, 0);
+}
+
+/*
+ * call-seq:
+ * io.getch(min: nil, time: nil) -> char
+ *
+ * Reads and returns a character in raw mode.
+ *
+ * You must require 'io/console' to use this method.
+ */
+static VALUE
+console_getch(int argc, VALUE *argv, VALUE io)
+{
+ rawmode_arg_t opts, *optp = rawmode_opt(argc, argv, &opts);
+ return ttymode(io, getc_call, set_rawmode, optp);
+}
+
+/*
+ * call-seq:
+ * io.noecho {|io| }
+ *
+ * Yields +self+ with disabling echo back.
+ *
+ * STDIN.noecho(&:gets)
+ *
+ * will read and return a line without echo back.
+ *
+ * You must require 'io/console' to use this method.
+ */
+static VALUE
+console_noecho(VALUE io)
+{
+ return ttymode(io, rb_yield, set_noecho, NULL);
+}
+
+/*
+ * call-seq:
+ * io.echo = flag
+ *
+ * Enables/disables echo back.
+ * On some platforms, all combinations of this flags and raw/cooked
+ * mode may not be valid.
+ *
+ * You must require 'io/console' to use this method.
+ */
+static VALUE
+console_set_echo(VALUE io, VALUE f)
+{
+ conmode t;
+ rb_io_t *fptr;
+ int fd;
+
+ GetOpenFile(io, fptr);
+ fd = GetReadFD(fptr);
+ if (!getattr(fd, &t)) rb_sys_fail(0);
+ if (RTEST(f))
+ set_echo(&t, NULL);
+ else
+ set_noecho(&t, NULL);
+ if (!setattr(fd, &t)) rb_sys_fail(0);
+ return io;
+}
+
+/*
+ * call-seq:
+ * io.echo? -> true or false
+ *
+ * Returns +true+ if echo back is enabled.
+ *
+ * You must require 'io/console' to use this method.
+ */
+static VALUE
+console_echo_p(VALUE io)
+{
+ conmode t;
+ rb_io_t *fptr;
+ int fd;
+
+ GetOpenFile(io, fptr);
+ fd = GetReadFD(fptr);
+ if (!getattr(fd, &t)) rb_sys_fail(0);
+ return echo_p(&t) ? Qtrue : Qfalse;
+}
+
+#if defined TIOCGWINSZ
+typedef struct winsize rb_console_size_t;
+#define getwinsize(fd, buf) (ioctl((fd), TIOCGWINSZ, (buf)) == 0)
+#define setwinsize(fd, buf) (ioctl((fd), TIOCSWINSZ, (buf)) == 0)
+#define winsize_row(buf) (buf)->ws_row
+#define winsize_col(buf) (buf)->ws_col
+#elif defined _WIN32
+typedef CONSOLE_SCREEN_BUFFER_INFO rb_console_size_t;
+#define getwinsize(fd, buf) ( \
+ GetConsoleScreenBufferInfo((HANDLE)rb_w32_get_osfhandle(fd), (buf)) || \
+ SET_LAST_ERROR)
+#define winsize_row(buf) ((buf)->srWindow.Bottom - (buf)->srWindow.Top + 1)
+#define winsize_col(buf) (buf)->dwSize.X
+#endif
+
+#if defined TIOCGWINSZ || defined _WIN32
+#define USE_CONSOLE_GETSIZE 1
+#endif
+
+#ifdef USE_CONSOLE_GETSIZE
+/*
+ * call-seq:
+ * io.winsize -> [rows, columns]
+ *
+ * Returns console size.
+ *
+ * You must require 'io/console' to use this method.
+ */
+static VALUE
+console_winsize(VALUE io)
+{
+ rb_io_t *fptr;
+ int fd;
+ rb_console_size_t ws;
+
+ GetOpenFile(io, fptr);
+ fd = GetWriteFD(fptr);
+ if (!getwinsize(fd, &ws)) rb_sys_fail(0);
+ return rb_assoc_new(INT2NUM(winsize_row(&ws)), INT2NUM(winsize_col(&ws)));
+}
+
+/*
+ * call-seq:
+ * io.winsize = [rows, columns]
+ *
+ * Tries to set console size. The effect depends on the platform and
+ * the running environment.
+ *
+ * You must require 'io/console' to use this method.
+ */
+static VALUE
+console_set_winsize(VALUE io, VALUE size)
+{
+ rb_io_t *fptr;
+ rb_console_size_t ws;
+#if defined _WIN32
+ HANDLE wh;
+ int newrow, newcol;
+#endif
+ VALUE row, col, xpixel, ypixel;
+#if defined TIOCSWINSZ
+ int fd;
+#endif
+
+ GetOpenFile(io, fptr);
+ size = rb_Array(size);
+ rb_scan_args((int)RARRAY_LEN(size), RARRAY_PTR(size), "22",
+ &row, &col, &xpixel, &ypixel);
+#if defined TIOCSWINSZ
+ fd = GetWriteFD(fptr);
+ ws.ws_row = ws.ws_col = ws.ws_xpixel = ws.ws_ypixel = 0;
+#define SET(m) ws.ws_##m = NIL_P(m) ? 0 : (unsigned short)NUM2UINT(m)
+ SET(row);
+ SET(col);
+ SET(xpixel);
+ SET(ypixel);
+#undef SET
+ if (!setwinsize(fd, &ws)) rb_sys_fail(0);
+#elif defined _WIN32
+ wh = (HANDLE)rb_w32_get_osfhandle(GetReadFD(fptr));
+ newrow = (SHORT)NUM2UINT(row);
+ newcol = (SHORT)NUM2UINT(col);
+ if (!getwinsize(GetReadFD(fptr), &ws)) {
+ rb_sys_fail("GetConsoleScreenBufferInfo");
+ }
+ if ((ws.dwSize.X < newcol && (ws.dwSize.X = newcol, 1)) ||
+ (ws.dwSize.Y < newrow && (ws.dwSize.Y = newrow, 1))) {
+ if (!(SetConsoleScreenBufferSize(wh, ws.dwSize) || SET_LAST_ERROR)) {
+ rb_sys_fail("SetConsoleScreenBufferInfo");
+ }
+ }
+ ws.srWindow.Left = 0;
+ ws.srWindow.Top = 0;
+ ws.srWindow.Right = newcol;
+ ws.srWindow.Bottom = newrow;
+ if (!(SetConsoleWindowInfo(wh, FALSE, &ws.srWindow) || SET_LAST_ERROR)) {
+ rb_sys_fail("SetConsoleWindowInfo");
+ }
+#endif
+ return io;
+}
+#endif
+
+/*
+ * call-seq:
+ * io.iflush
+ *
+ * Flushes input buffer in kernel.
+ *
+ * You must require 'io/console' to use this method.
+ */
+static VALUE
+console_iflush(VALUE io)
+{
+ rb_io_t *fptr;
+ int fd;
+
+ GetOpenFile(io, fptr);
+ fd = GetReadFD(fptr);
+#if defined HAVE_TERMIOS_H || defined HAVE_TERMIO_H
+ if (tcflush(fd, TCIFLUSH)) rb_sys_fail(0);
+#endif
+ (void)fd;
+ return io;
+}
+
+/*
+ * call-seq:
+ * io.oflush
+ *
+ * Flushes output buffer in kernel.
+ *
+ * You must require 'io/console' to use this method.
+ */
+static VALUE
+console_oflush(VALUE io)
+{
+ rb_io_t *fptr;
+ int fd;
+
+ GetOpenFile(io, fptr);
+ fd = GetWriteFD(fptr);
+#if defined HAVE_TERMIOS_H || defined HAVE_TERMIO_H
+ if (tcflush(fd, TCOFLUSH)) rb_sys_fail(0);
+#endif
+ (void)fd;
+ return io;
+}
+
+/*
+ * call-seq:
+ * io.ioflush
+ *
+ * Flushes input and output buffers in kernel.
+ *
+ * You must require 'io/console' to use this method.
+ */
+static VALUE
+console_ioflush(VALUE io)
+{
+ rb_io_t *fptr;
+#if defined HAVE_TERMIOS_H || defined HAVE_TERMIO_H
+ int fd1, fd2;
+#endif
+
+ GetOpenFile(io, fptr);
+#if defined HAVE_TERMIOS_H || defined HAVE_TERMIO_H
+ fd1 = GetReadFD(fptr);
+ fd2 = GetWriteFD(fptr);
+ if (fd2 != -1 && fd1 != fd2) {
+ if (tcflush(fd1, TCIFLUSH)) rb_sys_fail(0);
+ if (tcflush(fd2, TCOFLUSH)) rb_sys_fail(0);
+ }
+ else {
+ if (tcflush(fd1, TCIOFLUSH)) rb_sys_fail(0);
+ }
+#endif
+ return io;
+}
+
+/*
+ * call-seq:
+ * IO.console -> #<File:/dev/tty>
+ * IO.console(sym, *args)
+ *
+ * Returns an File instance opened console.
+ *
+ * If +sym+ is given, it will be sent to the opened console with
+ * +args+ and the result will be returned instead of the console IO
+ * itself.
+ *
+ * You must require 'io/console' to use this method.
+ */
+static VALUE
+console_dev(int argc, VALUE *argv, VALUE klass)
+{
+ VALUE con = 0;
+ rb_io_t *fptr;
+ VALUE sym = 0;
+
+ rb_check_arity(argc, 0, 1);
+ if (argc) {
+ Check_Type(sym = argv[0], T_SYMBOL);
+ --argc;
+ ++argv;
+ }
+ if (klass == rb_cIO) klass = rb_cFile;
+ if (rb_const_defined(klass, id_console)) {
+ con = rb_const_get(klass, id_console);
+ if (!RB_TYPE_P(con, T_FILE) ||
+ (!(fptr = RFILE(con)->fptr) || GetReadFD(fptr) == -1)) {
+ rb_const_remove(klass, id_console);
+ con = 0;
+ }
+ }
+ if (sym) {
+ if (sym == ID2SYM(id_close) && !argc) {
+ if (con) {
+ rb_io_close(con);
+ rb_const_remove(klass, id_console);
+ con = 0;
+ }
+ return Qnil;
+ }
+ }
+ if (!con) {
+ VALUE args[2];
+#if defined HAVE_TERMIOS_H || defined HAVE_TERMIO_H || defined HAVE_SGTTY_H
+# define CONSOLE_DEVICE "/dev/tty"
+#elif defined _WIN32
+# define CONSOLE_DEVICE "con$"
+# define CONSOLE_DEVICE_FOR_READING "conin$"
+# define CONSOLE_DEVICE_FOR_WRITING "conout$"
+#endif
+#ifndef CONSOLE_DEVICE_FOR_READING
+# define CONSOLE_DEVICE_FOR_READING CONSOLE_DEVICE
+#endif
+#ifdef CONSOLE_DEVICE_FOR_WRITING
+ VALUE out;
+ rb_io_t *ofptr;
+#endif
+ int fd;
+
+#ifdef CONSOLE_DEVICE_FOR_WRITING
+ fd = rb_cloexec_open(CONSOLE_DEVICE_FOR_WRITING, O_RDWR, 0);
+ if (fd < 0) return Qnil;
+ rb_update_max_fd(fd);
+ args[1] = INT2FIX(O_WRONLY);
+ args[0] = INT2NUM(fd);
+ out = rb_class_new_instance(2, args, klass);
+#endif
+ fd = rb_cloexec_open(CONSOLE_DEVICE_FOR_READING, O_RDWR, 0);
+ if (fd < 0) {
+#ifdef CONSOLE_DEVICE_FOR_WRITING
+ rb_io_close(out);
+#endif
+ return Qnil;
+ }
+ rb_update_max_fd(fd);
+ args[1] = INT2FIX(O_RDWR);
+ args[0] = INT2NUM(fd);
+ con = rb_class_new_instance(2, args, klass);
+ GetOpenFile(con, fptr);
+ fptr->pathv = rb_obj_freeze(rb_str_new2(CONSOLE_DEVICE));
+#ifdef CONSOLE_DEVICE_FOR_WRITING
+ GetOpenFile(out, ofptr);
+ ofptr->pathv = fptr->pathv;
+ fptr->tied_io_for_writing = out;
+ ofptr->mode |= FMODE_SYNC;
+#endif
+ fptr->mode |= FMODE_SYNC;
+ rb_const_set(klass, id_console, con);
+ }
+ if (sym) {
+ /* TODO: avoid inadvertent pindown */
+ return rb_funcall(con, SYM2ID(sym), argc, argv);
+ }
+ return con;
+}
+
+/*
+ * call-seq:
+ * io.getch(min: nil, time: nil) -> char
+ *
+ * See IO#getch.
+ */
+static VALUE
+io_getch(int argc, VALUE *argv, VALUE io)
+{
+ return rb_funcall2(io, rb_intern("getc"), argc, argv);
+}
+
+/*
+ * IO console methods
+ */
+void
+Init_console(void)
+{
+ id_getc = rb_intern("getc");
+ id_console = rb_intern("console");
+ id_close = rb_intern("close");
+ InitVM(console);
+}
+
+void
+InitVM_console(void)
+{
+ rb_define_method(rb_cIO, "raw", console_raw, -1);
+ rb_define_method(rb_cIO, "raw!", console_set_raw, -1);
+ rb_define_method(rb_cIO, "cooked", console_cooked, 0);
+ rb_define_method(rb_cIO, "cooked!", console_set_cooked, 0);
+ rb_define_method(rb_cIO, "getch", console_getch, -1);
+ rb_define_method(rb_cIO, "echo=", console_set_echo, 1);
+ rb_define_method(rb_cIO, "echo?", console_echo_p, 0);
+ rb_define_method(rb_cIO, "noecho", console_noecho, 0);
+ rb_define_method(rb_cIO, "winsize", console_winsize, 0);
+ rb_define_method(rb_cIO, "winsize=", console_set_winsize, 1);
+ rb_define_method(rb_cIO, "iflush", console_iflush, 0);
+ rb_define_method(rb_cIO, "oflush", console_oflush, 0);
+ rb_define_method(rb_cIO, "ioflush", console_ioflush, 0);
+ rb_define_singleton_method(rb_cIO, "console", console_dev, -1);
+ {
+ VALUE mReadable = rb_define_module_under(rb_cIO, "generic_readable");
+ rb_define_method(mReadable, "getch", io_getch, -1);
+ }
+}
diff --git a/jni/ruby/ext/io/console/depend b/jni/ruby/ext/io/console/depend
new file mode 100644
index 0000000..e786dc7
--- /dev/null
+++ b/jni/ruby/ext/io/console/depend
@@ -0,0 +1,4 @@
+$(OBJS): $(HDRS) $(ruby_headers) \
+ $(hdrdir)/ruby/io.h \
+ $(hdrdir)/ruby/encoding.h \
+ $(hdrdir)/ruby/oniguruma.h
diff --git a/jni/ruby/ext/io/console/extconf.h b/jni/ruby/ext/io/console/extconf.h
new file mode 100644
index 0000000..693d523
--- /dev/null
+++ b/jni/ruby/ext/io/console/extconf.h
@@ -0,0 +1,6 @@
+#ifndef EXTCONF_H
+#define EXTCONF_H
+#define HAVE_TERMIOS_H 1
+#define HAVE_CFMAKERAW 1
+#define HAVE_SYS_IOCTL_H 1
+#endif
diff --git a/jni/ruby/ext/io/console/extconf.rb b/jni/ruby/ext/io/console/extconf.rb
new file mode 100644
index 0000000..eb431b0
--- /dev/null
+++ b/jni/ruby/ext/io/console/extconf.rb
@@ -0,0 +1,21 @@
+require 'mkmf'
+
+ok = true
+hdr = nil
+case
+when macro_defined?("_WIN32", "")
+ # rb_w32_map_errno: 1.8.7
+when hdr = %w"termios.h termio.h".find {|h| have_header(h)}
+ have_func("cfmakeraw", hdr)
+when have_header(hdr = "sgtty.h")
+ %w"stty gtty".each {|f| have_func(f, hdr)}
+else
+ ok = false
+end
+if ok
+ have_header("sys/ioctl.h")
+ # rb_check_hash_type: 1.9.3
+ # rb_io_get_write_io: 1.9.1
+ # rb_cloexec_open: 2.0.0
+ create_makefile("io/console")
+end
diff --git a/jni/ruby/ext/io/console/io-console.gemspec b/jni/ruby/ext/io/console/io-console.gemspec
new file mode 100644
index 0000000..79a2843
--- /dev/null
+++ b/jni/ruby/ext/io/console/io-console.gemspec
@@ -0,0 +1,21 @@
+# -*- ruby -*-
+_VERSION = "0.4.3"
+date = %w$Date:: 2015-07-01 04:17:07 +0900#$[1]
+
+Gem::Specification.new do |s|
+ s.name = "io-console"
+ s.version = _VERSION
+ s.date = date
+ s.summary = "Console interface"
+ s.email = "nobu@ruby-lang.org"
+ s.description = "add console capabilities to IO instances."
+ s.required_ruby_version = ">= 2.0.0"
+ s.homepage = "http://www.ruby-lang.org"
+ s.authors = ["Nobu Nakada"]
+ s.require_path = %[lib]
+ s.files = %w[console.c extconf.rb lib/console/size.rb]
+ s.extensions = %w[extconf.rb]
+ s.licenses = "ruby"
+ s.cert_chain = %w[certs/nobu.pem]
+ s.signing_key = File.expand_path("~/.ssh/gem-private_key.pem") if $0 =~ /gem\z/
+end
diff --git a/jni/ruby/ext/io/console/lib/console/size.rb b/jni/ruby/ext/io/console/lib/console/size.rb
new file mode 100644
index 0000000..519bc3b
--- /dev/null
+++ b/jni/ruby/ext/io/console/lib/console/size.rb
@@ -0,0 +1,22 @@
+# fallback to console window size
+def IO.default_console_size
+ [
+ ENV["LINES"].to_i.nonzero? || 25,
+ ENV["COLUMNS"].to_i.nonzero? || 80,
+ ]
+end
+
+begin
+ require 'io/console'
+rescue LoadError
+ class IO
+ alias console_size default_console_size
+ end
+else
+ # returns console window size
+ def IO.console_size
+ console.winsize
+ rescue NoMethodError
+ default_console_size
+ end
+end
diff --git a/jni/ruby/ext/io/nonblock/Makefile b/jni/ruby/ext/io/nonblock/Makefile
new file mode 100644
index 0000000..1b79b89
--- /dev/null
+++ b/jni/ruby/ext/io/nonblock/Makefile
@@ -0,0 +1,273 @@
+
+SHELL = /bin/sh
+
+# V=0 quiet, V=1 verbose. other values don't work.
+V = 0
+Q1 = $(V:1=)
+Q = $(Q1:0=@)
+ECHO1 = $(V:1=@:)
+ECHO = $(ECHO1:0=@echo)
+NULLCMD = :
+
+#### Start of system configuration section. ####
+top_srcdir = $(topdir)/.
+srcdir = $(top_srcdir)/ext/io/nonblock
+topdir = ../../..
+hdrdir = $(top_srcdir)/include
+arch_hdrdir = $(extout)/include/$(arch)
+PATH_SEPARATOR = :
+VPATH = $(srcdir):$(arch_hdrdir)/ruby:$(hdrdir)/ruby
+RUBYLIB =
+RUBYOPT = -
+prefix = $(DESTDIR)/usr/local
+rubysitearchprefix = $(rubylibprefix)/$(sitearch)
+rubyarchprefix = $(rubylibprefix)/$(arch)
+rubylibprefix = $(libdir)/$(RUBY_BASE_NAME)
+exec_prefix = $(prefix)
+vendorarchhdrdir = $(vendorhdrdir)/$(sitearch)
+sitearchhdrdir = $(sitehdrdir)/$(sitearch)
+rubyarchhdrdir = $(rubyhdrdir)/$(arch)
+vendorhdrdir = $(rubyhdrdir)/vendor_ruby
+sitehdrdir = $(rubyhdrdir)/site_ruby
+rubyhdrdir = $(includedir)/$(RUBY_VERSION_NAME)
+vendorarchdir = $(vendorlibdir)/$(sitearch)
+vendorlibdir = $(vendordir)/$(ruby_version)
+vendordir = $(rubylibprefix)/vendor_ruby
+sitearchdir = $(sitelibdir)/$(sitearch)
+sitelibdir = $(sitedir)/$(ruby_version)
+sitedir = $(rubylibprefix)/site_ruby
+rubyarchdir = $(rubylibdir)/$(arch)
+rubylibdir = $(rubylibprefix)/$(ruby_version)
+sitearchincludedir = $(includedir)/$(sitearch)
+archincludedir = $(includedir)/$(arch)
+sitearchlibdir = $(libdir)/$(sitearch)
+archlibdir = $(libdir)/$(arch)
+ridir = $(datarootdir)/$(RI_BASE_NAME)
+mandir = $(datarootdir)/man
+localedir = $(datarootdir)/locale
+libdir = $(exec_prefix)/lib
+psdir = $(docdir)
+pdfdir = $(docdir)
+dvidir = $(docdir)
+htmldir = $(docdir)
+infodir = $(datarootdir)/info
+docdir = $(datarootdir)/doc/$(PACKAGE)
+oldincludedir = $(DESTDIR)/usr/include
+includedir = $(prefix)/include
+localstatedir = $(prefix)/var
+sharedstatedir = $(prefix)/com
+sysconfdir = $(prefix)/etc
+datadir = $(datarootdir)
+datarootdir = $(prefix)/share
+libexecdir = $(exec_prefix)/libexec
+sbindir = $(exec_prefix)/sbin
+bindir = $(exec_prefix)/bin
+archdir = $(rubyarchdir)
+
+
+CC = gcc
+CXX = g++
+LIBRUBY = $(LIBRUBY_SO)
+LIBRUBY_A = lib$(RUBY_SO_NAME)-static.a
+LIBRUBYARG_SHARED = -Wl,-R$(libdir) -L$(libdir) -l$(RUBY_SO_NAME)
+LIBRUBYARG_STATIC = -Wl,-R$(libdir) -L$(libdir) -l$(RUBY_SO_NAME)-static
+empty =
+OUTFLAG = -o $(empty)
+COUTFLAG = -o $(empty)
+
+RUBY_EXTCONF_H = extconf.h
+cflags = $(optflags) $(debugflags) $(warnflags)
+optflags = -O3 -fno-fast-math
+debugflags = -ggdb3
+warnflags = -Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wunused-variable -Wpointer-arith -Wwrite-strings -Wdeclaration-after-statement -Wimplicit-function-declaration -Wdeprecated-declarations -Wno-packed-bitfield-compat
+CCDLFLAGS = -fPIC
+CFLAGS = $(CCDLFLAGS) $(cflags) -fPIC $(ARCH_FLAG)
+INCFLAGS = -I. -I$(arch_hdrdir) -I$(hdrdir) -I$(srcdir)
+DEFS =
+CPPFLAGS = -DRUBY_EXTCONF_H=\"$(RUBY_EXTCONF_H)\" $(DEFS) $(cppflags)
+CXXFLAGS = $(CCDLFLAGS) $(cxxflags) $(ARCH_FLAG)
+ldflags = -L. -fstack-protector -rdynamic -Wl,-export-dynamic
+dldflags =
+ARCH_FLAG =
+DLDFLAGS = $(ldflags) $(dldflags) $(ARCH_FLAG)
+LDSHARED = $(CC) -shared
+LDSHAREDXX = $(CXX) -shared
+AR = ar
+EXEEXT =
+
+RUBY_INSTALL_NAME = $(RUBY_BASE_NAME)
+RUBY_SO_NAME = ruby
+RUBYW_INSTALL_NAME =
+RUBY_VERSION_NAME = $(RUBY_BASE_NAME)-$(ruby_version)
+RUBYW_BASE_NAME = rubyw
+RUBY_BASE_NAME = ruby
+
+arch = x86_64-linux
+sitearch = $(arch)
+ruby_version = 2.2.0
+ruby = $(topdir)/miniruby -I'$(topdir)' -I'$(top_srcdir)/lib' -I'$(extout)/$(arch)' -I'$(extout)/common'
+RUBY = $(ruby)
+ruby_headers = $(hdrdir)/ruby.h $(hdrdir)/ruby/ruby.h $(hdrdir)/ruby/defines.h $(hdrdir)/ruby/missing.h $(hdrdir)/ruby/intern.h $(hdrdir)/ruby/st.h $(hdrdir)/ruby/subst.h $(arch_hdrdir)/ruby/config.h $(RUBY_EXTCONF_H)
+
+RM = rm -f
+RM_RF = $(RUBY) -run -e rm -- -rf
+RMDIRS = rmdir --ignore-fail-on-non-empty -p
+MAKEDIRS = /bin/mkdir -p
+INSTALL = /usr/bin/install -c
+INSTALL_PROG = $(INSTALL) -m 0755
+INSTALL_DATA = $(INSTALL) -m 644
+COPY = cp
+TOUCH = exit >
+
+#### End of system configuration section. ####
+
+preload =
+
+libpath = . $(topdir)
+LIBPATH = -L. -L$(topdir)
+DEFFILE =
+
+CLEANFILES = mkmf.log
+DISTCLEANFILES =
+DISTCLEANDIRS =
+
+extout = $(topdir)/.ext
+extout_prefix = $(extout)$(target_prefix)/
+target_prefix = /io
+LOCAL_LIBS =
+LIBS = $(LIBRUBYARG_SHARED) -lpthread -lgmp -ldl -lcrypt -lm -lc
+ORIG_SRCS = nonblock.c
+SRCS = $(ORIG_SRCS)
+OBJS = nonblock.o
+HDRS = $(srcdir)/extconf.h
+TARGET = nonblock
+TARGET_NAME = nonblock
+TARGET_ENTRY = Init_$(TARGET_NAME)
+DLLIB = $(TARGET).so
+EXTSTATIC =
+STATIC_LIB = $(TARGET).a
+
+TIMESTAMP_DIR = $(extout)/.timestamp
+BINDIR = $(extout)/bin
+RUBYCOMMONDIR = $(extout)/common
+RUBYLIBDIR = $(RUBYCOMMONDIR)$(target_prefix)
+RUBYARCHDIR = $(extout)/$(arch)$(target_prefix)
+HDRDIR = $(extout)/include/ruby$(target_prefix)
+ARCHHDRDIR = $(extout)/include/$(arch)/ruby$(target_prefix)
+
+TARGET_SO = $(RUBYARCHDIR)/$(DLLIB)
+CLEANLIBS = $(RUBYARCHDIR)/$(TARGET).so
+CLEANOBJS = *.o *.bak
+
+all: install
+static: all
+.PHONY: all install static install-so install-rb
+.PHONY: clean clean-so clean-static clean-rb
+
+clean-static::
+clean-rb-default::
+clean-rb::
+clean-so::
+clean: clean-so clean-static clean-rb-default clean-rb
+ -$(Q)$(RM) $(CLEANLIBS) $(CLEANOBJS) $(CLEANFILES) .*.time
+
+distclean-rb-default::
+distclean-rb::
+distclean-so::
+distclean-static::
+distclean: clean distclean-so distclean-static distclean-rb-default distclean-rb
+ -$(Q)$(RM) Makefile $(RUBY_EXTCONF_H) conftest.* mkmf.log
+ -$(Q)$(RM) core ruby$(EXEEXT) *~ $(DISTCLEANFILES)
+ -$(Q)$(RMDIRS) $(DISTCLEANDIRS) 2> /dev/null || true
+
+realclean: distclean
+install: install-so install-rb
+
+install-so: $(RUBYARCHDIR)/$(DLLIB)
+clean-so::
+ -$(Q)$(RM) $(RUBYARCHDIR)/$(DLLIB)
+ -$(Q)$(RMDIRS) $(RUBYARCHDIR) 2> /dev/null || true
+clean-static::
+ -$(Q)$(RM) $(STATIC_LIB)
+install-rb: pre-install-rb install-rb-default
+install-rb-default: pre-install-rb-default
+pre-install-rb: Makefile
+pre-install-rb-default: Makefile
+pre-install-rb-default:
+ @$(NULLCMD)
+$(TIMESTAMP_DIR)/.RUBYARCHDIR.-.io.time:
+ $(Q) $(MAKEDIRS) $(@D) $(RUBYARCHDIR)
+ $(Q) $(TOUCH) $@
+
+site-install: site-install-so site-install-rb
+site-install-so: install-so
+site-install-rb: install-rb
+
+.SUFFIXES: .c .m .cc .mm .cxx .cpp .o .S
+
+.cc.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<
+
+.cc.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -S $<
+
+.mm.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<
+
+.mm.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -S $<
+
+.cxx.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<
+
+.cxx.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -S $<
+
+.cpp.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<
+
+.cpp.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -S $<
+
+.c.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -c $<
+
+.c.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -S $<
+
+.m.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -c $<
+
+.m.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -S $<
+
+$(RUBYARCHDIR)/$(DLLIB): $(OBJS) Makefile $(TIMESTAMP_DIR)/.RUBYARCHDIR.-.io.time
+ $(ECHO) linking shared-object io/$(DLLIB)
+ -$(Q)$(RM) $(@)
+ $(Q) $(LDSHARED) -o $@ $(OBJS) $(LIBPATH) $(DLDFLAGS) $(LOCAL_LIBS) $(LIBS)
+
+$(STATIC_LIB): $(OBJS)
+ -$(Q)$(RM) $(@)
+ $(ECHO) linking static-library $(@)
+ $(Q) $(AR) cru $@ $(OBJS)
+ -$(Q)ranlib $(@) 2> /dev/null || true
+
+###
+$(OBJS): $(RUBY_EXTCONF_H)
+
+$(OBJS): $(HDRS) $(ruby_headers) \
+ $(hdrdir)/ruby/io.h \
+ $(hdrdir)/ruby/encoding.h \
+ $(hdrdir)/ruby/oniguruma.h
diff --git a/jni/ruby/ext/io/nonblock/depend b/jni/ruby/ext/io/nonblock/depend
new file mode 100644
index 0000000..e786dc7
--- /dev/null
+++ b/jni/ruby/ext/io/nonblock/depend
@@ -0,0 +1,4 @@
+$(OBJS): $(HDRS) $(ruby_headers) \
+ $(hdrdir)/ruby/io.h \
+ $(hdrdir)/ruby/encoding.h \
+ $(hdrdir)/ruby/oniguruma.h
diff --git a/jni/ruby/ext/io/nonblock/extconf.h b/jni/ruby/ext/io/nonblock/extconf.h
new file mode 100644
index 0000000..cda0cc8
--- /dev/null
+++ b/jni/ruby/ext/io/nonblock/extconf.h
@@ -0,0 +1,3 @@
+#ifndef EXTCONF_H
+#define EXTCONF_H
+#endif
diff --git a/jni/ruby/ext/io/nonblock/extconf.rb b/jni/ruby/ext/io/nonblock/extconf.rb
new file mode 100644
index 0000000..aecdc16
--- /dev/null
+++ b/jni/ruby/ext/io/nonblock/extconf.rb
@@ -0,0 +1,8 @@
+require 'mkmf'
+target = "io/nonblock"
+
+hdr = %w"fcntl.h"
+if have_macro("O_NONBLOCK", hdr) and
+ (have_macro("F_GETFL", hdr) or have_macro("F_SETFL", hdr))
+ create_makefile(target)
+end
diff --git a/jni/ruby/ext/io/nonblock/nonblock.c b/jni/ruby/ext/io/nonblock/nonblock.c
new file mode 100644
index 0000000..792b6f0
--- /dev/null
+++ b/jni/ruby/ext/io/nonblock/nonblock.c
@@ -0,0 +1,138 @@
+/**********************************************************************
+
+ io/wait.c -
+
+ $Author: usa $
+ created at: Tue Jul 14 21:53:18 2009
+
+ All the files in this distribution are covered under the Ruby's
+ license (see the file COPYING).
+
+**********************************************************************/
+
+#include "ruby.h"
+#include "ruby/io.h"
+#ifdef HAVE_UNISTD_H
+#include <unistd.h>
+#endif
+#include <fcntl.h>
+
+#ifdef F_GETFL
+static int
+io_nonblock_mode(int fd)
+{
+ int f = fcntl(fd, F_GETFL);
+ if (f == -1) rb_sys_fail(0);
+ return f;
+}
+#else
+#define io_nonblock_mode(fd) ((void)(fd), 0)
+#endif
+
+#ifdef F_GETFL
+/*
+ * call-seq:
+ * io.nonblock? -> boolean
+ *
+ * Returns +true+ if an IO object is in non-blocking mode.
+ */
+static VALUE
+rb_io_nonblock_p(VALUE io)
+{
+ rb_io_t *fptr;
+ GetOpenFile(io, fptr);
+ if (io_nonblock_mode(fptr->fd) & O_NONBLOCK)
+ return Qtrue;
+ return Qfalse;
+}
+#else
+#define rb_io_nonblock_p rb_f_notimplement
+#endif
+
+#ifdef F_SETFL
+static void
+io_nonblock_set(int fd, int f, int nb)
+{
+ if (nb) {
+ if ((f & O_NONBLOCK) != 0)
+ return;
+ f |= O_NONBLOCK;
+ }
+ else {
+ if ((f & O_NONBLOCK) == 0)
+ return;
+ f &= ~O_NONBLOCK;
+ }
+ if (fcntl(fd, F_SETFL, f) == -1)
+ rb_sys_fail(0);
+}
+
+/*
+ * call-seq:
+ * io.nonblock = boolean -> boolean
+ *
+ * Enables non-blocking mode on a stream when set to
+ * +true+, and blocking mode when set to +false+.
+ */
+static VALUE
+rb_io_nonblock_set(VALUE io, VALUE nb)
+{
+ rb_io_t *fptr;
+ GetOpenFile(io, fptr);
+ if (RTEST(nb))
+ rb_io_set_nonblock(fptr);
+ else
+ io_nonblock_set(fptr->fd, io_nonblock_mode(fptr->fd), RTEST(nb));
+ return io;
+}
+
+static VALUE
+io_nonblock_restore(VALUE arg)
+{
+ int *restore = (int *)arg;
+ if (fcntl(restore[0], F_SETFL, restore[1]) == -1)
+ rb_sys_fail(0);
+ return Qnil;
+}
+
+/*
+ * call-seq:
+ * io.nonblock {|io| } -> io
+ * io.nonblock(boolean) {|io| } -> io
+ *
+ * Yields +self+ in non-blocking mode.
+ *
+ * When +false+ is given as an argument, +self+ is yielded in blocking mode.
+ * The original mode is restored after the block is executed.
+ */
+static VALUE
+rb_io_nonblock_block(int argc, VALUE *argv, VALUE io)
+{
+ int nb = 1;
+ rb_io_t *fptr;
+ int f, restore[2];
+
+ GetOpenFile(io, fptr);
+ if (argc > 0) {
+ VALUE v;
+ rb_scan_args(argc, argv, "01", &v);
+ nb = RTEST(v);
+ }
+ f = io_nonblock_mode(fptr->fd);
+ restore[0] = fptr->fd;
+ restore[1] = f;
+ io_nonblock_set(fptr->fd, f, nb);
+ return rb_ensure(rb_yield, io, io_nonblock_restore, (VALUE)restore);
+}
+#else
+#define rb_io_nonblock_set rb_f_notimplement
+#define rb_io_nonblock_block rb_f_notimplement
+#endif
+
+void
+Init_nonblock(void)
+{
+ rb_define_method(rb_cIO, "nonblock?", rb_io_nonblock_p, 0);
+ rb_define_method(rb_cIO, "nonblock=", rb_io_nonblock_set, 1);
+ rb_define_method(rb_cIO, "nonblock", rb_io_nonblock_block, -1);
+}
diff --git a/jni/ruby/ext/io/wait/Makefile b/jni/ruby/ext/io/wait/Makefile
new file mode 100644
index 0000000..b1bf69a
--- /dev/null
+++ b/jni/ruby/ext/io/wait/Makefile
@@ -0,0 +1,273 @@
+
+SHELL = /bin/sh
+
+# V=0 quiet, V=1 verbose. other values don't work.
+V = 0
+Q1 = $(V:1=)
+Q = $(Q1:0=@)
+ECHO1 = $(V:1=@:)
+ECHO = $(ECHO1:0=@echo)
+NULLCMD = :
+
+#### Start of system configuration section. ####
+top_srcdir = $(topdir)/.
+srcdir = $(top_srcdir)/ext/io/wait
+topdir = ../../..
+hdrdir = $(top_srcdir)/include
+arch_hdrdir = $(extout)/include/$(arch)
+PATH_SEPARATOR = :
+VPATH = $(srcdir):$(arch_hdrdir)/ruby:$(hdrdir)/ruby
+RUBYLIB =
+RUBYOPT = -
+prefix = $(DESTDIR)/usr/local
+rubysitearchprefix = $(rubylibprefix)/$(sitearch)
+rubyarchprefix = $(rubylibprefix)/$(arch)
+rubylibprefix = $(libdir)/$(RUBY_BASE_NAME)
+exec_prefix = $(prefix)
+vendorarchhdrdir = $(vendorhdrdir)/$(sitearch)
+sitearchhdrdir = $(sitehdrdir)/$(sitearch)
+rubyarchhdrdir = $(rubyhdrdir)/$(arch)
+vendorhdrdir = $(rubyhdrdir)/vendor_ruby
+sitehdrdir = $(rubyhdrdir)/site_ruby
+rubyhdrdir = $(includedir)/$(RUBY_VERSION_NAME)
+vendorarchdir = $(vendorlibdir)/$(sitearch)
+vendorlibdir = $(vendordir)/$(ruby_version)
+vendordir = $(rubylibprefix)/vendor_ruby
+sitearchdir = $(sitelibdir)/$(sitearch)
+sitelibdir = $(sitedir)/$(ruby_version)
+sitedir = $(rubylibprefix)/site_ruby
+rubyarchdir = $(rubylibdir)/$(arch)
+rubylibdir = $(rubylibprefix)/$(ruby_version)
+sitearchincludedir = $(includedir)/$(sitearch)
+archincludedir = $(includedir)/$(arch)
+sitearchlibdir = $(libdir)/$(sitearch)
+archlibdir = $(libdir)/$(arch)
+ridir = $(datarootdir)/$(RI_BASE_NAME)
+mandir = $(datarootdir)/man
+localedir = $(datarootdir)/locale
+libdir = $(exec_prefix)/lib
+psdir = $(docdir)
+pdfdir = $(docdir)
+dvidir = $(docdir)
+htmldir = $(docdir)
+infodir = $(datarootdir)/info
+docdir = $(datarootdir)/doc/$(PACKAGE)
+oldincludedir = $(DESTDIR)/usr/include
+includedir = $(prefix)/include
+localstatedir = $(prefix)/var
+sharedstatedir = $(prefix)/com
+sysconfdir = $(prefix)/etc
+datadir = $(datarootdir)
+datarootdir = $(prefix)/share
+libexecdir = $(exec_prefix)/libexec
+sbindir = $(exec_prefix)/sbin
+bindir = $(exec_prefix)/bin
+archdir = $(rubyarchdir)
+
+
+CC = gcc
+CXX = g++
+LIBRUBY = $(LIBRUBY_SO)
+LIBRUBY_A = lib$(RUBY_SO_NAME)-static.a
+LIBRUBYARG_SHARED = -Wl,-R$(libdir) -L$(libdir) -l$(RUBY_SO_NAME)
+LIBRUBYARG_STATIC = -Wl,-R$(libdir) -L$(libdir) -l$(RUBY_SO_NAME)-static
+empty =
+OUTFLAG = -o $(empty)
+COUTFLAG = -o $(empty)
+
+RUBY_EXTCONF_H = extconf.h
+cflags = $(optflags) $(debugflags) $(warnflags)
+optflags = -O3 -fno-fast-math
+debugflags = -ggdb3
+warnflags = -Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wunused-variable -Wpointer-arith -Wwrite-strings -Wdeclaration-after-statement -Wimplicit-function-declaration -Wdeprecated-declarations -Wno-packed-bitfield-compat
+CCDLFLAGS = -fPIC
+CFLAGS = $(CCDLFLAGS) $(cflags) -fPIC $(ARCH_FLAG)
+INCFLAGS = -I. -I$(arch_hdrdir) -I$(hdrdir) -I$(srcdir)
+DEFS =
+CPPFLAGS = -DRUBY_EXTCONF_H=\"$(RUBY_EXTCONF_H)\" $(DEFS) $(cppflags)
+CXXFLAGS = $(CCDLFLAGS) $(cxxflags) $(ARCH_FLAG)
+ldflags = -L. -fstack-protector -rdynamic -Wl,-export-dynamic
+dldflags =
+ARCH_FLAG =
+DLDFLAGS = $(ldflags) $(dldflags) $(ARCH_FLAG)
+LDSHARED = $(CC) -shared
+LDSHAREDXX = $(CXX) -shared
+AR = ar
+EXEEXT =
+
+RUBY_INSTALL_NAME = $(RUBY_BASE_NAME)
+RUBY_SO_NAME = ruby
+RUBYW_INSTALL_NAME =
+RUBY_VERSION_NAME = $(RUBY_BASE_NAME)-$(ruby_version)
+RUBYW_BASE_NAME = rubyw
+RUBY_BASE_NAME = ruby
+
+arch = x86_64-linux
+sitearch = $(arch)
+ruby_version = 2.2.0
+ruby = $(topdir)/miniruby -I'$(topdir)' -I'$(top_srcdir)/lib' -I'$(extout)/$(arch)' -I'$(extout)/common'
+RUBY = $(ruby)
+ruby_headers = $(hdrdir)/ruby.h $(hdrdir)/ruby/ruby.h $(hdrdir)/ruby/defines.h $(hdrdir)/ruby/missing.h $(hdrdir)/ruby/intern.h $(hdrdir)/ruby/st.h $(hdrdir)/ruby/subst.h $(arch_hdrdir)/ruby/config.h $(RUBY_EXTCONF_H)
+
+RM = rm -f
+RM_RF = $(RUBY) -run -e rm -- -rf
+RMDIRS = rmdir --ignore-fail-on-non-empty -p
+MAKEDIRS = /bin/mkdir -p
+INSTALL = /usr/bin/install -c
+INSTALL_PROG = $(INSTALL) -m 0755
+INSTALL_DATA = $(INSTALL) -m 644
+COPY = cp
+TOUCH = exit >
+
+#### End of system configuration section. ####
+
+preload =
+
+libpath = . $(topdir)
+LIBPATH = -L. -L$(topdir)
+DEFFILE =
+
+CLEANFILES = mkmf.log
+DISTCLEANFILES =
+DISTCLEANDIRS =
+
+extout = $(topdir)/.ext
+extout_prefix = $(extout)$(target_prefix)/
+target_prefix = /io
+LOCAL_LIBS =
+LIBS = $(LIBRUBYARG_SHARED) -lpthread -lgmp -ldl -lcrypt -lm -lc
+ORIG_SRCS = wait.c
+SRCS = $(ORIG_SRCS)
+OBJS = wait.o
+HDRS = $(srcdir)/extconf.h
+TARGET = wait
+TARGET_NAME = wait
+TARGET_ENTRY = Init_$(TARGET_NAME)
+DLLIB = $(TARGET).so
+EXTSTATIC =
+STATIC_LIB = $(TARGET).a
+
+TIMESTAMP_DIR = $(extout)/.timestamp
+BINDIR = $(extout)/bin
+RUBYCOMMONDIR = $(extout)/common
+RUBYLIBDIR = $(RUBYCOMMONDIR)$(target_prefix)
+RUBYARCHDIR = $(extout)/$(arch)$(target_prefix)
+HDRDIR = $(extout)/include/ruby$(target_prefix)
+ARCHHDRDIR = $(extout)/include/$(arch)/ruby$(target_prefix)
+
+TARGET_SO = $(RUBYARCHDIR)/$(DLLIB)
+CLEANLIBS = $(RUBYARCHDIR)/$(TARGET).so
+CLEANOBJS = *.o *.bak
+
+all: install
+static: all
+.PHONY: all install static install-so install-rb
+.PHONY: clean clean-so clean-static clean-rb
+
+clean-static::
+clean-rb-default::
+clean-rb::
+clean-so::
+clean: clean-so clean-static clean-rb-default clean-rb
+ -$(Q)$(RM) $(CLEANLIBS) $(CLEANOBJS) $(CLEANFILES) .*.time
+
+distclean-rb-default::
+distclean-rb::
+distclean-so::
+distclean-static::
+distclean: clean distclean-so distclean-static distclean-rb-default distclean-rb
+ -$(Q)$(RM) Makefile $(RUBY_EXTCONF_H) conftest.* mkmf.log
+ -$(Q)$(RM) core ruby$(EXEEXT) *~ $(DISTCLEANFILES)
+ -$(Q)$(RMDIRS) $(DISTCLEANDIRS) 2> /dev/null || true
+
+realclean: distclean
+install: install-so install-rb
+
+install-so: $(RUBYARCHDIR)/$(DLLIB)
+clean-so::
+ -$(Q)$(RM) $(RUBYARCHDIR)/$(DLLIB)
+ -$(Q)$(RMDIRS) $(RUBYARCHDIR) 2> /dev/null || true
+clean-static::
+ -$(Q)$(RM) $(STATIC_LIB)
+install-rb: pre-install-rb install-rb-default
+install-rb-default: pre-install-rb-default
+pre-install-rb: Makefile
+pre-install-rb-default: Makefile
+pre-install-rb-default:
+ @$(NULLCMD)
+$(TIMESTAMP_DIR)/.RUBYARCHDIR.-.io.time:
+ $(Q) $(MAKEDIRS) $(@D) $(RUBYARCHDIR)
+ $(Q) $(TOUCH) $@
+
+site-install: site-install-so site-install-rb
+site-install-so: install-so
+site-install-rb: install-rb
+
+.SUFFIXES: .c .m .cc .mm .cxx .cpp .o .S
+
+.cc.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<
+
+.cc.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -S $<
+
+.mm.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<
+
+.mm.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -S $<
+
+.cxx.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<
+
+.cxx.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -S $<
+
+.cpp.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<
+
+.cpp.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -S $<
+
+.c.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -c $<
+
+.c.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -S $<
+
+.m.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -c $<
+
+.m.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -S $<
+
+$(RUBYARCHDIR)/$(DLLIB): $(OBJS) Makefile $(TIMESTAMP_DIR)/.RUBYARCHDIR.-.io.time
+ $(ECHO) linking shared-object io/$(DLLIB)
+ -$(Q)$(RM) $(@)
+ $(Q) $(LDSHARED) -o $@ $(OBJS) $(LIBPATH) $(DLDFLAGS) $(LOCAL_LIBS) $(LIBS)
+
+$(STATIC_LIB): $(OBJS)
+ -$(Q)$(RM) $(@)
+ $(ECHO) linking static-library $(@)
+ $(Q) $(AR) cru $@ $(OBJS)
+ -$(Q)ranlib $(@) 2> /dev/null || true
+
+###
+$(OBJS): $(RUBY_EXTCONF_H)
+
+$(OBJS): $(HDRS) $(ruby_headers) \
+ $(hdrdir)/ruby/io.h \
+ $(hdrdir)/ruby/encoding.h \
+ $(hdrdir)/ruby/oniguruma.h
diff --git a/jni/ruby/ext/io/wait/depend b/jni/ruby/ext/io/wait/depend
new file mode 100644
index 0000000..e786dc7
--- /dev/null
+++ b/jni/ruby/ext/io/wait/depend
@@ -0,0 +1,4 @@
+$(OBJS): $(HDRS) $(ruby_headers) \
+ $(hdrdir)/ruby/io.h \
+ $(hdrdir)/ruby/encoding.h \
+ $(hdrdir)/ruby/oniguruma.h
diff --git a/jni/ruby/ext/io/wait/extconf.h b/jni/ruby/ext/io/wait/extconf.h
new file mode 100644
index 0000000..27a457f
--- /dev/null
+++ b/jni/ruby/ext/io/wait/extconf.h
@@ -0,0 +1,5 @@
+#ifndef EXTCONF_H
+#define EXTCONF_H
+#define HAVE_SYS_IOCTL_H 1
+#define FIONREAD_HEADER <sys/ioctl.h>
+#endif
diff --git a/jni/ruby/ext/io/wait/extconf.rb b/jni/ruby/ext/io/wait/extconf.rb
new file mode 100644
index 0000000..eed3543
--- /dev/null
+++ b/jni/ruby/ext/io/wait/extconf.rb
@@ -0,0 +1,18 @@
+require 'mkmf'
+target = "io/wait"
+
+unless macro_defined?("DOSISH", "#include <ruby.h>")
+ have_header(ioctl_h = "sys/ioctl.h") or ioctl_h = nil
+ fionread = %w[sys/ioctl.h sys/filio.h sys/socket.h].find do |h|
+ have_macro("FIONREAD", [h, ioctl_h].compact)
+ end
+ if fionread
+ $defs << "-DFIONREAD_HEADER=\"<#{fionread}>\""
+ create_makefile(target)
+ end
+else
+ if have_func("rb_w32_ioctlsocket", "ruby.h")
+ have_func("rb_w32_is_socket", "ruby.h")
+ create_makefile(target)
+ end
+end
diff --git a/jni/ruby/ext/io/wait/wait.c b/jni/ruby/ext/io/wait/wait.c
new file mode 100644
index 0000000..8104397
--- /dev/null
+++ b/jni/ruby/ext/io/wait/wait.c
@@ -0,0 +1,187 @@
+/**********************************************************************
+
+ io/wait.c -
+
+ $Author: nagachika $
+ created at: Tue Aug 28 09:08:06 JST 2001
+
+ All the files in this distribution are covered under the Ruby's
+ license (see the file COPYING).
+
+**********************************************************************/
+
+#include "ruby.h"
+#include "ruby/io.h"
+
+#include <sys/types.h>
+#if defined(HAVE_UNISTD_H) && (defined(__sun))
+#include <unistd.h>
+#endif
+#if defined(HAVE_SYS_IOCTL_H)
+#include <sys/ioctl.h>
+#endif
+#if defined(FIONREAD_HEADER)
+#include FIONREAD_HEADER
+#endif
+
+#ifdef HAVE_RB_W32_IOCTLSOCKET
+#define ioctl ioctlsocket
+#define ioctl_arg u_long
+#define ioctl_arg2num(i) ULONG2NUM(i)
+#else
+#define ioctl_arg int
+#define ioctl_arg2num(i) INT2NUM(i)
+#endif
+
+#ifdef HAVE_RB_W32_IS_SOCKET
+#define FIONREAD_POSSIBLE_P(fd) rb_w32_is_socket(fd)
+#else
+#define FIONREAD_POSSIBLE_P(fd) ((void)(fd),Qtrue)
+#endif
+
+static VALUE io_ready_p _((VALUE io));
+static VALUE io_wait_readable _((int argc, VALUE *argv, VALUE io));
+static VALUE io_wait_writable _((int argc, VALUE *argv, VALUE io));
+void Init_wait _((void));
+
+/*
+ * call-seq:
+ * io.nread -> int
+ *
+ * Returns number of bytes that can be read without blocking.
+ * Returns zero if no information available.
+ */
+
+static VALUE
+io_nread(VALUE io)
+{
+ rb_io_t *fptr;
+ int len;
+ ioctl_arg n;
+
+ GetOpenFile(io, fptr);
+ rb_io_check_readable(fptr);
+ len = rb_io_read_pending(fptr);
+ if (len > 0) return INT2FIX(len);
+ if (!FIONREAD_POSSIBLE_P(fptr->fd)) return INT2FIX(0);
+ if (ioctl(fptr->fd, FIONREAD, &n)) return INT2FIX(0);
+ if (n > 0) return ioctl_arg2num(n);
+ return INT2FIX(0);
+}
+
+/*
+ * call-seq:
+ * io.ready? -> true, false or nil
+ *
+ * Returns true if input available without blocking, or false.
+ * Returns nil if no information available.
+ */
+
+static VALUE
+io_ready_p(VALUE io)
+{
+ rb_io_t *fptr;
+ ioctl_arg n;
+
+ GetOpenFile(io, fptr);
+ rb_io_check_readable(fptr);
+ if (rb_io_read_pending(fptr)) return Qtrue;
+ if (!FIONREAD_POSSIBLE_P(fptr->fd)) return Qnil;
+ if (ioctl(fptr->fd, FIONREAD, &n)) return Qnil;
+ if (n > 0) return Qtrue;
+ return Qfalse;
+}
+
+/*
+ * call-seq:
+ * io.wait -> IO, true, false or nil
+ * io.wait(timeout) -> IO, true, false or nil
+ * io.wait_readable -> IO, true, false or nil
+ * io.wait_readable(timeout) -> IO, true, false or nil
+ *
+ * Waits until input is available or times out and returns self or nil when
+ * EOF is reached.
+ */
+
+static VALUE
+io_wait_readable(int argc, VALUE *argv, VALUE io)
+{
+ rb_io_t *fptr;
+ int i;
+ ioctl_arg n;
+ VALUE timeout;
+ struct timeval timerec;
+ struct timeval *tv;
+
+ GetOpenFile(io, fptr);
+ rb_io_check_readable(fptr);
+ rb_scan_args(argc, argv, "01", &timeout);
+ if (NIL_P(timeout)) {
+ tv = NULL;
+ }
+ else {
+ timerec = rb_time_interval(timeout);
+ tv = &timerec;
+ }
+
+ if (rb_io_read_pending(fptr)) return Qtrue;
+ if (!FIONREAD_POSSIBLE_P(fptr->fd)) return Qfalse;
+ i = rb_wait_for_single_fd(fptr->fd, RB_WAITFD_IN, tv);
+ if (i < 0)
+ rb_sys_fail(0);
+ rb_io_check_closed(fptr);
+ if (ioctl(fptr->fd, FIONREAD, &n)) rb_sys_fail(0);
+ if (n > 0) return io;
+ return Qnil;
+}
+
+/*
+ * call-seq:
+ * io.wait_writable -> IO
+ * io.wait_writable(timeout) -> IO or nil
+ *
+ * Waits until IO writable is available or times out and returns self or
+ * nil when EOF is reached.
+ */
+static VALUE
+io_wait_writable(int argc, VALUE *argv, VALUE io)
+{
+ rb_io_t *fptr;
+ int i;
+ VALUE timeout;
+ struct timeval timerec;
+ struct timeval *tv;
+
+ GetOpenFile(io, fptr);
+ rb_io_check_writable(fptr);
+ rb_scan_args(argc, argv, "01", &timeout);
+ if (NIL_P(timeout)) {
+ tv = NULL;
+ }
+ else {
+ timerec = rb_time_interval(timeout);
+ tv = &timerec;
+ }
+
+ i = rb_wait_for_single_fd(fptr->fd, RB_WAITFD_OUT, tv);
+ if (i < 0)
+ rb_sys_fail(0);
+ rb_io_check_closed(fptr);
+ if (i & RB_WAITFD_OUT)
+ return io;
+ return Qnil;
+}
+
+/*
+ * IO wait methods
+ */
+
+void
+Init_wait(void)
+{
+ rb_define_method(rb_cIO, "nread", io_nread, 0);
+ rb_define_method(rb_cIO, "ready?", io_ready_p, 0);
+ rb_define_method(rb_cIO, "wait", io_wait_readable, -1);
+ rb_define_method(rb_cIO, "wait_readable", io_wait_readable, -1);
+ rb_define_method(rb_cIO, "wait_writable", io_wait_writable, -1);
+}
diff --git a/jni/ruby/ext/json/Makefile b/jni/ruby/ext/json/Makefile
new file mode 100644
index 0000000..fb3cd87
--- /dev/null
+++ b/jni/ruby/ext/json/Makefile
@@ -0,0 +1,303 @@
+
+SHELL = /bin/sh
+
+# V=0 quiet, V=1 verbose. other values don't work.
+V = 0
+Q1 = $(V:1=)
+Q = $(Q1:0=@)
+ECHO1 = $(V:1=@:)
+ECHO = $(ECHO1:0=@echo)
+NULLCMD = :
+
+#### Start of system configuration section. ####
+top_srcdir = $(topdir)/.
+srcdir = $(top_srcdir)/ext/json
+topdir = ../..
+hdrdir = $(top_srcdir)/include
+arch_hdrdir = $(extout)/include/$(arch)
+PATH_SEPARATOR = :
+VPATH = $(srcdir):$(arch_hdrdir)/ruby:$(hdrdir)/ruby
+RUBYLIB =
+RUBYOPT = -
+prefix = $(DESTDIR)/usr/local
+rubysitearchprefix = $(rubylibprefix)/$(sitearch)
+rubyarchprefix = $(rubylibprefix)/$(arch)
+rubylibprefix = $(libdir)/$(RUBY_BASE_NAME)
+exec_prefix = $(prefix)
+vendorarchhdrdir = $(vendorhdrdir)/$(sitearch)
+sitearchhdrdir = $(sitehdrdir)/$(sitearch)
+rubyarchhdrdir = $(rubyhdrdir)/$(arch)
+vendorhdrdir = $(rubyhdrdir)/vendor_ruby
+sitehdrdir = $(rubyhdrdir)/site_ruby
+rubyhdrdir = $(includedir)/$(RUBY_VERSION_NAME)
+vendorarchdir = $(vendorlibdir)/$(sitearch)
+vendorlibdir = $(vendordir)/$(ruby_version)
+vendordir = $(rubylibprefix)/vendor_ruby
+sitearchdir = $(sitelibdir)/$(sitearch)
+sitelibdir = $(sitedir)/$(ruby_version)
+sitedir = $(rubylibprefix)/site_ruby
+rubyarchdir = $(rubylibdir)/$(arch)
+rubylibdir = $(rubylibprefix)/$(ruby_version)
+sitearchincludedir = $(includedir)/$(sitearch)
+archincludedir = $(includedir)/$(arch)
+sitearchlibdir = $(libdir)/$(sitearch)
+archlibdir = $(libdir)/$(arch)
+ridir = $(datarootdir)/$(RI_BASE_NAME)
+mandir = $(datarootdir)/man
+localedir = $(datarootdir)/locale
+libdir = $(exec_prefix)/lib
+psdir = $(docdir)
+pdfdir = $(docdir)
+dvidir = $(docdir)
+htmldir = $(docdir)
+infodir = $(datarootdir)/info
+docdir = $(datarootdir)/doc/$(PACKAGE)
+oldincludedir = $(DESTDIR)/usr/include
+includedir = $(prefix)/include
+localstatedir = $(prefix)/var
+sharedstatedir = $(prefix)/com
+sysconfdir = $(prefix)/etc
+datadir = $(datarootdir)
+datarootdir = $(prefix)/share
+libexecdir = $(exec_prefix)/libexec
+sbindir = $(exec_prefix)/sbin
+bindir = $(exec_prefix)/bin
+archdir = $(rubyarchdir)
+
+
+CC = gcc
+CXX = g++
+LIBRUBY = $(LIBRUBY_SO)
+LIBRUBY_A = lib$(RUBY_SO_NAME)-static.a
+LIBRUBYARG_SHARED = -Wl,-R$(libdir) -L$(libdir) -l$(RUBY_SO_NAME)
+LIBRUBYARG_STATIC = -Wl,-R$(libdir) -L$(libdir) -l$(RUBY_SO_NAME)-static
+empty =
+OUTFLAG = -o $(empty)
+COUTFLAG = -o $(empty)
+
+RUBY_EXTCONF_H = extconf.h
+cflags = $(optflags) $(debugflags) $(warnflags)
+optflags = -O3 -fno-fast-math
+debugflags = -ggdb3
+warnflags = -Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wunused-variable -Wpointer-arith -Wwrite-strings -Wdeclaration-after-statement -Wimplicit-function-declaration -Wdeprecated-declarations -Wno-packed-bitfield-compat
+CCDLFLAGS = -fPIC
+CFLAGS = $(CCDLFLAGS) $(cflags) -fPIC $(ARCH_FLAG)
+INCFLAGS = -I. -I$(arch_hdrdir) -I$(hdrdir) -I$(srcdir)
+DEFS =
+CPPFLAGS = -DRUBY_EXTCONF_H=\"$(RUBY_EXTCONF_H)\" $(DEFS) $(cppflags)
+CXXFLAGS = $(CCDLFLAGS) $(cxxflags) $(ARCH_FLAG)
+ldflags = -L. -fstack-protector -rdynamic -Wl,-export-dynamic
+dldflags =
+ARCH_FLAG =
+DLDFLAGS = $(ldflags) $(dldflags) $(ARCH_FLAG)
+LDSHARED = $(CC) -shared
+LDSHAREDXX = $(CXX) -shared
+AR = ar
+EXEEXT =
+
+RUBY_INSTALL_NAME = $(RUBY_BASE_NAME)
+RUBY_SO_NAME = ruby
+RUBYW_INSTALL_NAME =
+RUBY_VERSION_NAME = $(RUBY_BASE_NAME)-$(ruby_version)
+RUBYW_BASE_NAME = rubyw
+RUBY_BASE_NAME = ruby
+
+arch = x86_64-linux
+sitearch = $(arch)
+ruby_version = 2.2.0
+ruby = $(topdir)/miniruby -I'$(topdir)' -I'$(top_srcdir)/lib' -I'$(extout)/$(arch)' -I'$(extout)/common'
+RUBY = $(ruby)
+ruby_headers = $(hdrdir)/ruby.h $(hdrdir)/ruby/ruby.h $(hdrdir)/ruby/defines.h $(hdrdir)/ruby/missing.h $(hdrdir)/ruby/intern.h $(hdrdir)/ruby/st.h $(hdrdir)/ruby/subst.h $(arch_hdrdir)/ruby/config.h $(RUBY_EXTCONF_H)
+
+RM = rm -f
+RM_RF = $(RUBY) -run -e rm -- -rf
+RMDIRS = rmdir --ignore-fail-on-non-empty -p
+MAKEDIRS = /bin/mkdir -p
+INSTALL = /usr/bin/install -c
+INSTALL_PROG = $(INSTALL) -m 0755
+INSTALL_DATA = $(INSTALL) -m 644
+COPY = cp
+TOUCH = exit >
+
+#### End of system configuration section. ####
+
+preload =
+
+libpath = . $(topdir)
+LIBPATH = -L. -L$(topdir)
+DEFFILE =
+
+CLEANFILES = mkmf.log
+DISTCLEANFILES =
+DISTCLEANDIRS =
+
+extout = $(topdir)/.ext
+extout_prefix = $(extout)$(target_prefix)/
+target_prefix =
+LOCAL_LIBS =
+LIBS = $(LIBRUBYARG_SHARED) -lpthread -lgmp -ldl -lcrypt -lm -lc
+ORIG_SRCS =
+SRCS = $(ORIG_SRCS)
+OBJS =
+HDRS = $(srcdir)/extconf.h
+TARGET =
+TARGET_NAME =
+TARGET_ENTRY = Init_$(TARGET_NAME)
+DLLIB =
+EXTSTATIC =
+STATIC_LIB =
+
+TIMESTAMP_DIR = $(extout)/.timestamp
+BINDIR = $(extout)/bin
+RUBYCOMMONDIR = $(extout)/common
+RUBYLIBDIR = $(RUBYCOMMONDIR)$(target_prefix)
+RUBYARCHDIR = $(extout)/$(arch)$(target_prefix)
+HDRDIR = $(extout)/include/ruby$(target_prefix)
+ARCHHDRDIR = $(extout)/include/$(arch)/ruby$(target_prefix)
+
+TARGET_SO = $(RUBYARCHDIR)/$(DLLIB)
+CLEANLIBS = $(RUBYARCHDIR)/$(TARGET).so
+CLEANOBJS = *.o *.bak
+
+all: install
+static: all
+.PHONY: all install static install-so install-rb
+.PHONY: clean clean-so clean-static clean-rb
+
+clean-static::
+clean-rb-default::
+clean-rb::
+clean-so::
+clean: clean-so clean-static clean-rb-default clean-rb
+ -$(Q)$(RM) $(CLEANLIBS) $(CLEANOBJS) $(CLEANFILES) .*.time
+
+distclean-rb-default::
+distclean-rb::
+distclean-so::
+distclean-static::
+distclean: clean distclean-so distclean-static distclean-rb-default distclean-rb
+ -$(Q)$(RM) Makefile $(RUBY_EXTCONF_H) conftest.* mkmf.log
+ -$(Q)$(RM) core ruby$(EXEEXT) *~ $(DISTCLEANFILES)
+ -$(Q)$(RMDIRS) $(DISTCLEANDIRS) 2> /dev/null || true
+
+realclean: distclean
+install: install-so install-rb
+
+install-so: Makefile
+install-rb: pre-install-rb install-rb-default
+install-rb-default: pre-install-rb-default
+pre-install-rb: Makefile
+pre-install-rb-default: Makefile
+pre-install-rb-default: $(TIMESTAMP_DIR)/.RUBYLIBDIR.-.json.time
+install-rb-default: $(RUBYLIBDIR)/json/ext.rb
+$(RUBYLIBDIR)/json/ext.rb: $(srcdir)/lib/json/ext.rb $(TIMESTAMP_DIR)/.RUBYLIBDIR.-.json.time
+ $(Q) $(COPY) $(srcdir)/lib/json/ext.rb $(@D)
+clean-rb-default::
+ -$(Q)$(RM) $(RUBYLIBDIR)/json/ext.rb
+install-rb-default: $(RUBYLIBDIR)/json/generic_object.rb
+$(RUBYLIBDIR)/json/generic_object.rb: $(srcdir)/lib/json/generic_object.rb $(TIMESTAMP_DIR)/.RUBYLIBDIR.-.json.time
+ $(Q) $(COPY) $(srcdir)/lib/json/generic_object.rb $(@D)
+clean-rb-default::
+ -$(Q)$(RM) $(RUBYLIBDIR)/json/generic_object.rb
+install-rb-default: $(RUBYLIBDIR)/json/common.rb
+$(RUBYLIBDIR)/json/common.rb: $(srcdir)/lib/json/common.rb $(TIMESTAMP_DIR)/.RUBYLIBDIR.-.json.time
+ $(Q) $(COPY) $(srcdir)/lib/json/common.rb $(@D)
+clean-rb-default::
+ -$(Q)$(RM) $(RUBYLIBDIR)/json/common.rb
+install-rb-default: $(RUBYLIBDIR)/json/version.rb
+$(RUBYLIBDIR)/json/version.rb: $(srcdir)/lib/json/version.rb $(TIMESTAMP_DIR)/.RUBYLIBDIR.-.json.time
+ $(Q) $(COPY) $(srcdir)/lib/json/version.rb $(@D)
+clean-rb-default::
+ -$(Q)$(RM) $(RUBYLIBDIR)/json/version.rb
+pre-install-rb-default: $(TIMESTAMP_DIR)/.RUBYLIBDIR.-.json.-.add.time
+install-rb-default: $(RUBYLIBDIR)/json/add/date.rb
+$(RUBYLIBDIR)/json/add/date.rb: $(srcdir)/lib/json/add/date.rb $(TIMESTAMP_DIR)/.RUBYLIBDIR.-.json.-.add.time
+ $(Q) $(COPY) $(srcdir)/lib/json/add/date.rb $(@D)
+clean-rb-default::
+ -$(Q)$(RM) $(RUBYLIBDIR)/json/add/date.rb
+install-rb-default: $(RUBYLIBDIR)/json/add/core.rb
+$(RUBYLIBDIR)/json/add/core.rb: $(srcdir)/lib/json/add/core.rb $(TIMESTAMP_DIR)/.RUBYLIBDIR.-.json.-.add.time
+ $(Q) $(COPY) $(srcdir)/lib/json/add/core.rb $(@D)
+clean-rb-default::
+ -$(Q)$(RM) $(RUBYLIBDIR)/json/add/core.rb
+install-rb-default: $(RUBYLIBDIR)/json/add/symbol.rb
+$(RUBYLIBDIR)/json/add/symbol.rb: $(srcdir)/lib/json/add/symbol.rb $(TIMESTAMP_DIR)/.RUBYLIBDIR.-.json.-.add.time
+ $(Q) $(COPY) $(srcdir)/lib/json/add/symbol.rb $(@D)
+clean-rb-default::
+ -$(Q)$(RM) $(RUBYLIBDIR)/json/add/symbol.rb
+install-rb-default: $(RUBYLIBDIR)/json/add/bigdecimal.rb
+$(RUBYLIBDIR)/json/add/bigdecimal.rb: $(srcdir)/lib/json/add/bigdecimal.rb $(TIMESTAMP_DIR)/.RUBYLIBDIR.-.json.-.add.time
+ $(Q) $(COPY) $(srcdir)/lib/json/add/bigdecimal.rb $(@D)
+clean-rb-default::
+ -$(Q)$(RM) $(RUBYLIBDIR)/json/add/bigdecimal.rb
+install-rb-default: $(RUBYLIBDIR)/json/add/rational.rb
+$(RUBYLIBDIR)/json/add/rational.rb: $(srcdir)/lib/json/add/rational.rb $(TIMESTAMP_DIR)/.RUBYLIBDIR.-.json.-.add.time
+ $(Q) $(COPY) $(srcdir)/lib/json/add/rational.rb $(@D)
+clean-rb-default::
+ -$(Q)$(RM) $(RUBYLIBDIR)/json/add/rational.rb
+install-rb-default: $(RUBYLIBDIR)/json/add/range.rb
+$(RUBYLIBDIR)/json/add/range.rb: $(srcdir)/lib/json/add/range.rb $(TIMESTAMP_DIR)/.RUBYLIBDIR.-.json.-.add.time
+ $(Q) $(COPY) $(srcdir)/lib/json/add/range.rb $(@D)
+clean-rb-default::
+ -$(Q)$(RM) $(RUBYLIBDIR)/json/add/range.rb
+install-rb-default: $(RUBYLIBDIR)/json/add/struct.rb
+$(RUBYLIBDIR)/json/add/struct.rb: $(srcdir)/lib/json/add/struct.rb $(TIMESTAMP_DIR)/.RUBYLIBDIR.-.json.-.add.time
+ $(Q) $(COPY) $(srcdir)/lib/json/add/struct.rb $(@D)
+clean-rb-default::
+ -$(Q)$(RM) $(RUBYLIBDIR)/json/add/struct.rb
+install-rb-default: $(RUBYLIBDIR)/json/add/date_time.rb
+$(RUBYLIBDIR)/json/add/date_time.rb: $(srcdir)/lib/json/add/date_time.rb $(TIMESTAMP_DIR)/.RUBYLIBDIR.-.json.-.add.time
+ $(Q) $(COPY) $(srcdir)/lib/json/add/date_time.rb $(@D)
+clean-rb-default::
+ -$(Q)$(RM) $(RUBYLIBDIR)/json/add/date_time.rb
+install-rb-default: $(RUBYLIBDIR)/json/add/ostruct.rb
+$(RUBYLIBDIR)/json/add/ostruct.rb: $(srcdir)/lib/json/add/ostruct.rb $(TIMESTAMP_DIR)/.RUBYLIBDIR.-.json.-.add.time
+ $(Q) $(COPY) $(srcdir)/lib/json/add/ostruct.rb $(@D)
+clean-rb-default::
+ -$(Q)$(RM) $(RUBYLIBDIR)/json/add/ostruct.rb
+install-rb-default: $(RUBYLIBDIR)/json/add/exception.rb
+$(RUBYLIBDIR)/json/add/exception.rb: $(srcdir)/lib/json/add/exception.rb $(TIMESTAMP_DIR)/.RUBYLIBDIR.-.json.-.add.time
+ $(Q) $(COPY) $(srcdir)/lib/json/add/exception.rb $(@D)
+clean-rb-default::
+ -$(Q)$(RM) $(RUBYLIBDIR)/json/add/exception.rb
+install-rb-default: $(RUBYLIBDIR)/json/add/regexp.rb
+$(RUBYLIBDIR)/json/add/regexp.rb: $(srcdir)/lib/json/add/regexp.rb $(TIMESTAMP_DIR)/.RUBYLIBDIR.-.json.-.add.time
+ $(Q) $(COPY) $(srcdir)/lib/json/add/regexp.rb $(@D)
+clean-rb-default::
+ -$(Q)$(RM) $(RUBYLIBDIR)/json/add/regexp.rb
+install-rb-default: $(RUBYLIBDIR)/json/add/time.rb
+$(RUBYLIBDIR)/json/add/time.rb: $(srcdir)/lib/json/add/time.rb $(TIMESTAMP_DIR)/.RUBYLIBDIR.-.json.-.add.time
+ $(Q) $(COPY) $(srcdir)/lib/json/add/time.rb $(@D)
+clean-rb-default::
+ -$(Q)$(RM) $(RUBYLIBDIR)/json/add/time.rb
+install-rb-default: $(RUBYLIBDIR)/json/add/complex.rb
+$(RUBYLIBDIR)/json/add/complex.rb: $(srcdir)/lib/json/add/complex.rb $(TIMESTAMP_DIR)/.RUBYLIBDIR.-.json.-.add.time
+ $(Q) $(COPY) $(srcdir)/lib/json/add/complex.rb $(@D)
+clean-rb-default::
+ -$(Q)$(RM) $(RUBYLIBDIR)/json/add/complex.rb
+pre-install-rb-default: $(TIMESTAMP_DIR)/.RUBYLIBDIR.time
+install-rb-default: $(RUBYLIBDIR)/json.rb
+$(RUBYLIBDIR)/json.rb: $(srcdir)/lib/json.rb $(TIMESTAMP_DIR)/.RUBYLIBDIR.time
+ $(Q) $(COPY) $(srcdir)/lib/json.rb $(@D)
+clean-rb-default::
+ -$(Q)$(RM) $(RUBYLIBDIR)/json.rb
+pre-install-rb-default:
+ $(ECHO) installing default libraries
+clean-rb-default::
+ -$(Q)$(RMDIRS) $(RUBYLIBDIR)/json/add 2> /dev/null || true
+ -$(Q)$(RMDIRS) $(RUBYLIBDIR)/json 2> /dev/null || true
+ -$(Q)$(RMDIRS) $(RUBYLIBDIR) 2> /dev/null || true
+$(TIMESTAMP_DIR)/.RUBYLIBDIR.-.json.time:
+ $(Q) $(MAKEDIRS) $(@D) $(RUBYLIBDIR)/json
+ $(Q) $(TOUCH) $@
+$(TIMESTAMP_DIR)/.RUBYLIBDIR.-.json.-.add.time:
+ $(Q) $(MAKEDIRS) $(@D) $(RUBYLIBDIR)/json/add
+ $(Q) $(TOUCH) $@
+$(TIMESTAMP_DIR)/.RUBYLIBDIR.time:
+ $(Q) $(MAKEDIRS) $(@D) $(RUBYLIBDIR)
+ $(Q) $(TOUCH) $@
+
+site-install: site-install-so site-install-rb
+site-install-so: install-so
+site-install-rb: install-rb
+
diff --git a/jni/ruby/ext/json/extconf.h b/jni/ruby/ext/json/extconf.h
new file mode 100644
index 0000000..cda0cc8
--- /dev/null
+++ b/jni/ruby/ext/json/extconf.h
@@ -0,0 +1,3 @@
+#ifndef EXTCONF_H
+#define EXTCONF_H
+#endif
diff --git a/jni/ruby/ext/json/extconf.rb b/jni/ruby/ext/json/extconf.rb
new file mode 100644
index 0000000..850798c
--- /dev/null
+++ b/jni/ruby/ext/json/extconf.rb
@@ -0,0 +1,3 @@
+require 'mkmf'
+create_makefile('json')
+
diff --git a/jni/ruby/ext/json/fbuffer/fbuffer.h b/jni/ruby/ext/json/fbuffer/fbuffer.h
new file mode 100644
index 0000000..5a0a27c
--- /dev/null
+++ b/jni/ruby/ext/json/fbuffer/fbuffer.h
@@ -0,0 +1,190 @@
+
+#ifndef _FBUFFER_H_
+#define _FBUFFER_H_
+
+#include "ruby.h"
+
+#ifndef RHASH_SIZE
+#define RHASH_SIZE(hsh) (RHASH(hsh)->tbl->num_entries)
+#endif
+
+#ifndef RFLOAT_VALUE
+#define RFLOAT_VALUE(val) (RFLOAT(val)->value)
+#endif
+
+#ifndef RARRAY_PTR
+#define RARRAY_PTR(ARRAY) RARRAY(ARRAY)->ptr
+#endif
+#ifndef RARRAY_LEN
+#define RARRAY_LEN(ARRAY) RARRAY(ARRAY)->len
+#endif
+#ifndef RSTRING_PTR
+#define RSTRING_PTR(string) RSTRING(string)->ptr
+#endif
+#ifndef RSTRING_LEN
+#define RSTRING_LEN(string) RSTRING(string)->len
+#endif
+
+#ifdef PRIsVALUE
+# define RB_OBJ_CLASSNAME(obj) rb_obj_class(obj)
+# define RB_OBJ_STRING(obj) (obj)
+#else
+# define PRIsVALUE "s"
+# define RB_OBJ_CLASSNAME(obj) rb_obj_classname(obj)
+# define RB_OBJ_STRING(obj) StringValueCStr(obj)
+#endif
+
+#ifdef HAVE_RUBY_ENCODING_H
+#include "ruby/encoding.h"
+#define FORCE_UTF8(obj) rb_enc_associate((obj), rb_utf8_encoding())
+#else
+#define FORCE_UTF8(obj)
+#endif
+
+/* We don't need to guard objects for rbx, so let's do nothing at all. */
+#ifndef RB_GC_GUARD
+#define RB_GC_GUARD(object)
+#endif
+
+typedef struct FBufferStruct {
+ unsigned long initial_length;
+ char *ptr;
+ unsigned long len;
+ unsigned long capa;
+} FBuffer;
+
+#define FBUFFER_INITIAL_LENGTH_DEFAULT 1024
+
+#define FBUFFER_PTR(fb) (fb->ptr)
+#define FBUFFER_LEN(fb) (fb->len)
+#define FBUFFER_CAPA(fb) (fb->capa)
+#define FBUFFER_PAIR(fb) FBUFFER_PTR(fb), FBUFFER_LEN(fb)
+
+static FBuffer *fbuffer_alloc(unsigned long initial_length);
+static void fbuffer_free(FBuffer *fb);
+static void fbuffer_clear(FBuffer *fb);
+static void fbuffer_append(FBuffer *fb, const char *newstr, unsigned long len);
+#ifdef JSON_GENERATOR
+static void fbuffer_append_long(FBuffer *fb, long number);
+#endif
+static void fbuffer_append_char(FBuffer *fb, char newchr);
+#ifdef JSON_GENERATOR
+static FBuffer *fbuffer_dup(FBuffer *fb);
+static VALUE fbuffer_to_s(FBuffer *fb);
+#endif
+
+static FBuffer *fbuffer_alloc(unsigned long initial_length)
+{
+ FBuffer *fb;
+ if (initial_length <= 0) initial_length = FBUFFER_INITIAL_LENGTH_DEFAULT;
+ fb = ALLOC(FBuffer);
+ memset((void *) fb, 0, sizeof(FBuffer));
+ fb->initial_length = initial_length;
+ return fb;
+}
+
+static void fbuffer_free(FBuffer *fb)
+{
+ if (fb->ptr) ruby_xfree(fb->ptr);
+ ruby_xfree(fb);
+}
+
+static void fbuffer_clear(FBuffer *fb)
+{
+ fb->len = 0;
+}
+
+static void fbuffer_inc_capa(FBuffer *fb, unsigned long requested)
+{
+ unsigned long required;
+
+ if (!fb->ptr) {
+ fb->ptr = ALLOC_N(char, fb->initial_length);
+ fb->capa = fb->initial_length;
+ }
+
+ for (required = fb->capa; requested > required - fb->len; required <<= 1);
+
+ if (required > fb->capa) {
+ REALLOC_N(fb->ptr, char, required);
+ fb->capa = required;
+ }
+}
+
+static void fbuffer_append(FBuffer *fb, const char *newstr, unsigned long len)
+{
+ if (len > 0) {
+ fbuffer_inc_capa(fb, len);
+ MEMCPY(fb->ptr + fb->len, newstr, char, len);
+ fb->len += len;
+ }
+}
+
+#ifdef JSON_GENERATOR
+static void fbuffer_append_str(FBuffer *fb, VALUE str)
+{
+ const char *newstr = StringValuePtr(str);
+ unsigned long len = RSTRING_LEN(str);
+
+ RB_GC_GUARD(str);
+
+ fbuffer_append(fb, newstr, len);
+}
+#endif
+
+static void fbuffer_append_char(FBuffer *fb, char newchr)
+{
+ fbuffer_inc_capa(fb, 1);
+ *(fb->ptr + fb->len) = newchr;
+ fb->len++;
+}
+
+#ifdef JSON_GENERATOR
+static void freverse(char *start, char *end)
+{
+ char c;
+
+ while (end > start) {
+ c = *end, *end-- = *start, *start++ = c;
+ }
+}
+
+static long fltoa(long number, char *buf)
+{
+ static char digits[] = "0123456789";
+ long sign = number;
+ char* tmp = buf;
+
+ if (sign < 0) number = -number;
+ do *tmp++ = digits[number % 10]; while (number /= 10);
+ if (sign < 0) *tmp++ = '-';
+ freverse(buf, tmp - 1);
+ return tmp - buf;
+}
+
+static void fbuffer_append_long(FBuffer *fb, long number)
+{
+ char buf[20];
+ unsigned long len = fltoa(number, buf);
+ fbuffer_append(fb, buf, len);
+}
+
+static FBuffer *fbuffer_dup(FBuffer *fb)
+{
+ unsigned long len = fb->len;
+ FBuffer *result;
+
+ result = fbuffer_alloc(len);
+ fbuffer_append(result, FBUFFER_PAIR(fb));
+ return result;
+}
+
+static VALUE fbuffer_to_s(FBuffer *fb)
+{
+ VALUE result = rb_str_new(FBUFFER_PTR(fb), FBUFFER_LEN(fb));
+ fbuffer_free(fb);
+ FORCE_UTF8(result);
+ return result;
+}
+#endif
+#endif
diff --git a/jni/ruby/ext/json/generator/Makefile b/jni/ruby/ext/json/generator/Makefile
new file mode 100644
index 0000000..4e39169
--- /dev/null
+++ b/jni/ruby/ext/json/generator/Makefile
@@ -0,0 +1,290 @@
+
+SHELL = /bin/sh
+
+# V=0 quiet, V=1 verbose. other values don't work.
+V = 0
+Q1 = $(V:1=)
+Q = $(Q1:0=@)
+ECHO1 = $(V:1=@:)
+ECHO = $(ECHO1:0=@echo)
+NULLCMD = :
+
+#### Start of system configuration section. ####
+top_srcdir = $(topdir)/.
+srcdir = $(top_srcdir)/ext/json/generator
+topdir = ../../..
+hdrdir = $(top_srcdir)/include
+arch_hdrdir = $(extout)/include/$(arch)
+PATH_SEPARATOR = :
+VPATH = $(srcdir):$(arch_hdrdir)/ruby:$(hdrdir)/ruby
+RUBYLIB =
+RUBYOPT = -
+prefix = $(DESTDIR)/usr/local
+rubysitearchprefix = $(rubylibprefix)/$(sitearch)
+rubyarchprefix = $(rubylibprefix)/$(arch)
+rubylibprefix = $(libdir)/$(RUBY_BASE_NAME)
+exec_prefix = $(prefix)
+vendorarchhdrdir = $(vendorhdrdir)/$(sitearch)
+sitearchhdrdir = $(sitehdrdir)/$(sitearch)
+rubyarchhdrdir = $(rubyhdrdir)/$(arch)
+vendorhdrdir = $(rubyhdrdir)/vendor_ruby
+sitehdrdir = $(rubyhdrdir)/site_ruby
+rubyhdrdir = $(includedir)/$(RUBY_VERSION_NAME)
+vendorarchdir = $(vendorlibdir)/$(sitearch)
+vendorlibdir = $(vendordir)/$(ruby_version)
+vendordir = $(rubylibprefix)/vendor_ruby
+sitearchdir = $(sitelibdir)/$(sitearch)
+sitelibdir = $(sitedir)/$(ruby_version)
+sitedir = $(rubylibprefix)/site_ruby
+rubyarchdir = $(rubylibdir)/$(arch)
+rubylibdir = $(rubylibprefix)/$(ruby_version)
+sitearchincludedir = $(includedir)/$(sitearch)
+archincludedir = $(includedir)/$(arch)
+sitearchlibdir = $(libdir)/$(sitearch)
+archlibdir = $(libdir)/$(arch)
+ridir = $(datarootdir)/$(RI_BASE_NAME)
+mandir = $(datarootdir)/man
+localedir = $(datarootdir)/locale
+libdir = $(exec_prefix)/lib
+psdir = $(docdir)
+pdfdir = $(docdir)
+dvidir = $(docdir)
+htmldir = $(docdir)
+infodir = $(datarootdir)/info
+docdir = $(datarootdir)/doc/$(PACKAGE)
+oldincludedir = $(DESTDIR)/usr/include
+includedir = $(prefix)/include
+localstatedir = $(prefix)/var
+sharedstatedir = $(prefix)/com
+sysconfdir = $(prefix)/etc
+datadir = $(datarootdir)
+datarootdir = $(prefix)/share
+libexecdir = $(exec_prefix)/libexec
+sbindir = $(exec_prefix)/sbin
+bindir = $(exec_prefix)/bin
+archdir = $(rubyarchdir)
+
+
+CC = gcc
+CXX = g++
+LIBRUBY = $(LIBRUBY_SO)
+LIBRUBY_A = lib$(RUBY_SO_NAME)-static.a
+LIBRUBYARG_SHARED = -Wl,-R$(libdir) -L$(libdir) -l$(RUBY_SO_NAME)
+LIBRUBYARG_STATIC = -Wl,-R$(libdir) -L$(libdir) -l$(RUBY_SO_NAME)-static
+empty =
+OUTFLAG = -o $(empty)
+COUTFLAG = -o $(empty)
+
+RUBY_EXTCONF_H = extconf.h
+cflags = $(optflags) $(debugflags) $(warnflags)
+optflags = -O3 -fno-fast-math
+debugflags = -ggdb3
+warnflags = -Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wunused-variable -Wpointer-arith -Wwrite-strings -Wdeclaration-after-statement -Wimplicit-function-declaration -Wdeprecated-declarations -Wno-packed-bitfield-compat
+CCDLFLAGS = -fPIC
+CFLAGS = $(CCDLFLAGS) $(cflags) -fPIC $(ARCH_FLAG)
+INCFLAGS = -I. -I$(arch_hdrdir) -I$(hdrdir) -I$(srcdir)
+DEFS =
+CPPFLAGS = -DRUBY_EXTCONF_H=\"$(RUBY_EXTCONF_H)\" $(DEFS) $(cppflags)
+CXXFLAGS = $(CCDLFLAGS) $(cxxflags) $(ARCH_FLAG)
+ldflags = -L. -fstack-protector -rdynamic -Wl,-export-dynamic
+dldflags =
+ARCH_FLAG =
+DLDFLAGS = $(ldflags) $(dldflags) $(ARCH_FLAG)
+LDSHARED = $(CC) -shared
+LDSHAREDXX = $(CXX) -shared
+AR = ar
+EXEEXT =
+
+RUBY_INSTALL_NAME = $(RUBY_BASE_NAME)
+RUBY_SO_NAME = ruby
+RUBYW_INSTALL_NAME =
+RUBY_VERSION_NAME = $(RUBY_BASE_NAME)-$(ruby_version)
+RUBYW_BASE_NAME = rubyw
+RUBY_BASE_NAME = ruby
+
+arch = x86_64-linux
+sitearch = $(arch)
+ruby_version = 2.2.0
+ruby = $(topdir)/miniruby -I'$(topdir)' -I'$(top_srcdir)/lib' -I'$(extout)/$(arch)' -I'$(extout)/common'
+RUBY = $(ruby)
+ruby_headers = $(hdrdir)/ruby.h $(hdrdir)/ruby/ruby.h $(hdrdir)/ruby/defines.h $(hdrdir)/ruby/missing.h $(hdrdir)/ruby/intern.h $(hdrdir)/ruby/st.h $(hdrdir)/ruby/subst.h $(arch_hdrdir)/ruby/config.h $(RUBY_EXTCONF_H)
+
+RM = rm -f
+RM_RF = $(RUBY) -run -e rm -- -rf
+RMDIRS = rmdir --ignore-fail-on-non-empty -p
+MAKEDIRS = /bin/mkdir -p
+INSTALL = /usr/bin/install -c
+INSTALL_PROG = $(INSTALL) -m 0755
+INSTALL_DATA = $(INSTALL) -m 644
+COPY = cp
+TOUCH = exit >
+
+#### End of system configuration section. ####
+
+preload =
+
+libpath = . $(topdir)
+LIBPATH = -L. -L$(topdir)
+DEFFILE =
+
+CLEANFILES = mkmf.log
+DISTCLEANFILES =
+DISTCLEANDIRS =
+
+extout = $(topdir)/.ext
+extout_prefix = $(extout)$(target_prefix)/
+target_prefix = /json/ext
+LOCAL_LIBS =
+LIBS = $(LIBRUBYARG_SHARED) -lpthread -lgmp -ldl -lcrypt -lm -lc
+ORIG_SRCS = generator.c
+SRCS = $(ORIG_SRCS)
+OBJS = generator.o
+HDRS = $(srcdir)/extconf.h $(srcdir)/generator.h
+TARGET = generator
+TARGET_NAME = generator
+TARGET_ENTRY = Init_$(TARGET_NAME)
+DLLIB = $(TARGET).so
+EXTSTATIC =
+STATIC_LIB = $(TARGET).a
+
+TIMESTAMP_DIR = $(extout)/.timestamp
+BINDIR = $(extout)/bin
+RUBYCOMMONDIR = $(extout)/common
+RUBYLIBDIR = $(RUBYCOMMONDIR)$(target_prefix)
+RUBYARCHDIR = $(extout)/$(arch)$(target_prefix)
+HDRDIR = $(extout)/include/ruby$(target_prefix)
+ARCHHDRDIR = $(extout)/include/$(arch)/ruby$(target_prefix)
+
+TARGET_SO = $(RUBYARCHDIR)/$(DLLIB)
+CLEANLIBS = $(RUBYARCHDIR)/$(TARGET).so
+CLEANOBJS = *.o *.bak
+
+all: install
+static: all
+.PHONY: all install static install-so install-rb
+.PHONY: clean clean-so clean-static clean-rb
+
+clean-static::
+clean-rb-default::
+clean-rb::
+clean-so::
+clean: clean-so clean-static clean-rb-default clean-rb
+ -$(Q)$(RM) $(CLEANLIBS) $(CLEANOBJS) $(CLEANFILES) .*.time
+
+distclean-rb-default::
+distclean-rb::
+distclean-so::
+distclean-static::
+distclean: clean distclean-so distclean-static distclean-rb-default distclean-rb
+ -$(Q)$(RM) Makefile $(RUBY_EXTCONF_H) conftest.* mkmf.log
+ -$(Q)$(RM) core ruby$(EXEEXT) *~ $(DISTCLEANFILES)
+ -$(Q)$(RMDIRS) $(DISTCLEANDIRS) 2> /dev/null || true
+
+realclean: distclean
+install: install-so install-rb
+
+install-so: $(RUBYARCHDIR)/$(DLLIB)
+clean-so::
+ -$(Q)$(RM) $(RUBYARCHDIR)/$(DLLIB)
+ -$(Q)$(RMDIRS) $(RUBYARCHDIR) 2> /dev/null || true
+clean-static::
+ -$(Q)$(RM) $(STATIC_LIB)
+install-rb: pre-install-rb install-rb-default
+install-rb-default: pre-install-rb-default
+pre-install-rb: Makefile
+pre-install-rb-default: Makefile
+pre-install-rb-default:
+ @$(NULLCMD)
+$(TIMESTAMP_DIR)/.RUBYARCHDIR.-.json.-.ext.time:
+ $(Q) $(MAKEDIRS) $(@D) $(RUBYARCHDIR)
+ $(Q) $(TOUCH) $@
+
+site-install: site-install-so site-install-rb
+site-install-so: install-so
+site-install-rb: install-rb
+
+.SUFFIXES: .c .m .cc .mm .cxx .cpp .o .S
+
+.cc.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<
+
+.cc.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -S $<
+
+.mm.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<
+
+.mm.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -S $<
+
+.cxx.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<
+
+.cxx.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -S $<
+
+.cpp.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<
+
+.cpp.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -S $<
+
+.c.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -c $<
+
+.c.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -S $<
+
+.m.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -c $<
+
+.m.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -S $<
+
+$(RUBYARCHDIR)/$(DLLIB): $(OBJS) Makefile $(TIMESTAMP_DIR)/.RUBYARCHDIR.-.json.-.ext.time
+ $(ECHO) linking shared-object json/ext/$(DLLIB)
+ -$(Q)$(RM) $(@)
+ $(Q) $(LDSHARED) -o $@ $(OBJS) $(LIBPATH) $(DLDFLAGS) $(LOCAL_LIBS) $(LIBS)
+
+$(STATIC_LIB): $(OBJS)
+ -$(Q)$(RM) $(@)
+ $(ECHO) linking static-library $(@)
+ $(Q) $(AR) cru $@ $(OBJS)
+ -$(Q)ranlib $(@) 2> /dev/null || true
+
+###
+$(OBJS): $(RUBY_EXTCONF_H)
+
+$(OBJS): $(ruby_headers)
+generator.o: generator.c generator.h $(srcdir)/../fbuffer/fbuffer.h
+
+# AUTOGENERATED DEPENDENCIES START
+generator.o: $(RUBY_EXTCONF_H)
+generator.o: $(arch_hdrdir)/ruby/config.h
+generator.o: $(hdrdir)/ruby/defines.h
+generator.o: $(hdrdir)/ruby/encoding.h
+generator.o: $(hdrdir)/ruby/intern.h
+generator.o: $(hdrdir)/ruby/missing.h
+generator.o: $(hdrdir)/ruby/oniguruma.h
+generator.o: $(hdrdir)/ruby/re.h
+generator.o: $(hdrdir)/ruby/regex.h
+generator.o: $(hdrdir)/ruby/ruby.h
+generator.o: $(hdrdir)/ruby/st.h
+generator.o: $(hdrdir)/ruby/subst.h
+generator.o: $(top_srcdir)/ext/json/fbuffer/fbuffer.h
+generator.o: $(top_srcdir)/include/ruby.h
+generator.o: generator.c
+generator.o: generator.h
+# AUTOGENERATED DEPENDENCIES END
diff --git a/jni/ruby/ext/json/generator/depend b/jni/ruby/ext/json/generator/depend
new file mode 100644
index 0000000..b7373cd
--- /dev/null
+++ b/jni/ruby/ext/json/generator/depend
@@ -0,0 +1,21 @@
+$(OBJS): $(ruby_headers)
+generator.o: generator.c generator.h $(srcdir)/../fbuffer/fbuffer.h
+
+# AUTOGENERATED DEPENDENCIES START
+generator.o: $(RUBY_EXTCONF_H)
+generator.o: $(arch_hdrdir)/ruby/config.h
+generator.o: $(hdrdir)/ruby/defines.h
+generator.o: $(hdrdir)/ruby/encoding.h
+generator.o: $(hdrdir)/ruby/intern.h
+generator.o: $(hdrdir)/ruby/missing.h
+generator.o: $(hdrdir)/ruby/oniguruma.h
+generator.o: $(hdrdir)/ruby/re.h
+generator.o: $(hdrdir)/ruby/regex.h
+generator.o: $(hdrdir)/ruby/ruby.h
+generator.o: $(hdrdir)/ruby/st.h
+generator.o: $(hdrdir)/ruby/subst.h
+generator.o: $(top_srcdir)/ext/json/fbuffer/fbuffer.h
+generator.o: $(top_srcdir)/include/ruby.h
+generator.o: generator.c
+generator.o: generator.h
+# AUTOGENERATED DEPENDENCIES END
diff --git a/jni/ruby/ext/json/generator/extconf.h b/jni/ruby/ext/json/generator/extconf.h
new file mode 100644
index 0000000..9245b78
--- /dev/null
+++ b/jni/ruby/ext/json/generator/extconf.h
@@ -0,0 +1,4 @@
+#ifndef EXTCONF_H
+#define EXTCONF_H
+#define JSON_GENERATOR 1
+#endif
diff --git a/jni/ruby/ext/json/generator/extconf.rb b/jni/ruby/ext/json/generator/extconf.rb
new file mode 100644
index 0000000..8627c5f
--- /dev/null
+++ b/jni/ruby/ext/json/generator/extconf.rb
@@ -0,0 +1,4 @@
+require 'mkmf'
+
+$defs << "-DJSON_GENERATOR"
+create_makefile 'json/ext/generator'
diff --git a/jni/ruby/ext/json/generator/generator.c b/jni/ruby/ext/json/generator/generator.c
new file mode 100644
index 0000000..f56ac09
--- /dev/null
+++ b/jni/ruby/ext/json/generator/generator.c
@@ -0,0 +1,1458 @@
+#include "../fbuffer/fbuffer.h"
+#include "generator.h"
+
+#ifdef HAVE_RUBY_ENCODING_H
+static VALUE CEncoding_UTF_8;
+static ID i_encoding, i_encode;
+#endif
+
+static VALUE mJSON, mExt, mGenerator, cState, mGeneratorMethods, mObject,
+ mHash, mArray, mFixnum, mBignum, mFloat, mString, mString_Extend,
+ mTrueClass, mFalseClass, mNilClass, eGeneratorError,
+ eNestingError, CRegexp_MULTILINE, CJSON_SAFE_STATE_PROTOTYPE,
+ i_SAFE_STATE_PROTOTYPE;
+
+static ID i_to_s, i_to_json, i_new, i_indent, i_space, i_space_before,
+ i_object_nl, i_array_nl, i_max_nesting, i_allow_nan, i_ascii_only,
+ i_quirks_mode, i_pack, i_unpack, i_create_id, i_extend, i_key_p,
+ i_aref, i_send, i_respond_to_p, i_match, i_keys, i_depth,
+ i_buffer_initial_length, i_dup;
+
+/*
+ * Copyright 2001-2004 Unicode, Inc.
+ *
+ * Disclaimer
+ *
+ * This source code is provided as is by Unicode, Inc. No claims are
+ * made as to fitness for any particular purpose. No warranties of any
+ * kind are expressed or implied. The recipient agrees to determine
+ * applicability of information provided. If this file has been
+ * purchased on magnetic or optical media from Unicode, Inc., the
+ * sole remedy for any claim will be exchange of defective media
+ * within 90 days of receipt.
+ *
+ * Limitations on Rights to Redistribute This Code
+ *
+ * Unicode, Inc. hereby grants the right to freely use the information
+ * supplied in this file in the creation of products supporting the
+ * Unicode Standard, and to make copies of this file in any form
+ * for internal or external distribution as long as this notice
+ * remains attached.
+ */
+
+/*
+ * Index into the table below with the first byte of a UTF-8 sequence to
+ * get the number of trailing bytes that are supposed to follow it.
+ * Note that *legal* UTF-8 values can't have 4 or 5-bytes. The table is
+ * left as-is for anyone who may want to do such conversion, which was
+ * allowed in earlier algorithms.
+ */
+static const char trailingBytesForUTF8[256] = {
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
+ 2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2, 3,3,3,3,3,3,3,3,4,4,4,4,5,5,5,5
+};
+
+/*
+ * Magic values subtracted from a buffer value during UTF8 conversion.
+ * This table contains as many values as there might be trailing bytes
+ * in a UTF-8 sequence.
+ */
+static const UTF32 offsetsFromUTF8[6] = { 0x00000000UL, 0x00003080UL, 0x000E2080UL,
+ 0x03C82080UL, 0xFA082080UL, 0x82082080UL };
+
+/*
+ * Utility routine to tell whether a sequence of bytes is legal UTF-8.
+ * This must be called with the length pre-determined by the first byte.
+ * If not calling this from ConvertUTF8to*, then the length can be set by:
+ * length = trailingBytesForUTF8[*source]+1;
+ * and the sequence is illegal right away if there aren't that many bytes
+ * available.
+ * If presented with a length > 4, this returns 0. The Unicode
+ * definition of UTF-8 goes up to 4-byte sequences.
+ */
+static unsigned char isLegalUTF8(const UTF8 *source, unsigned long length)
+{
+ UTF8 a;
+ const UTF8 *srcptr = source+length;
+ switch (length) {
+ default: return 0;
+ /* Everything else falls through when "1"... */
+ case 4: if ((a = (*--srcptr)) < 0x80 || a > 0xBF) return 0;
+ case 3: if ((a = (*--srcptr)) < 0x80 || a > 0xBF) return 0;
+ case 2: if ((a = (*--srcptr)) > 0xBF) return 0;
+
+ switch (*source) {
+ /* no fall-through in this inner switch */
+ case 0xE0: if (a < 0xA0) return 0; break;
+ case 0xED: if (a > 0x9F) return 0; break;
+ case 0xF0: if (a < 0x90) return 0; break;
+ case 0xF4: if (a > 0x8F) return 0; break;
+ default: if (a < 0x80) return 0;
+ }
+
+ case 1: if (*source >= 0x80 && *source < 0xC2) return 0;
+ }
+ if (*source > 0xF4) return 0;
+ return 1;
+}
+
+/* Escapes the UTF16 character and stores the result in the buffer buf. */
+static void unicode_escape(char *buf, UTF16 character)
+{
+ const char *digits = "0123456789abcdef";
+
+ buf[2] = digits[character >> 12];
+ buf[3] = digits[(character >> 8) & 0xf];
+ buf[4] = digits[(character >> 4) & 0xf];
+ buf[5] = digits[character & 0xf];
+}
+
+/* Escapes the UTF16 character and stores the result in the buffer buf, then
+ * the buffer buf is appended to the FBuffer buffer. */
+static void unicode_escape_to_buffer(FBuffer *buffer, char buf[6], UTF16
+ character)
+{
+ unicode_escape(buf, character);
+ fbuffer_append(buffer, buf, 6);
+}
+
+/* Converts string to a JSON string in FBuffer buffer, where all but the ASCII
+ * and control characters are JSON escaped. */
+static void convert_UTF8_to_JSON_ASCII(FBuffer *buffer, VALUE string)
+{
+ const UTF8 *source = (UTF8 *) RSTRING_PTR(string);
+ const UTF8 *sourceEnd = source + RSTRING_LEN(string);
+ char buf[6] = { '\\', 'u' };
+
+ while (source < sourceEnd) {
+ UTF32 ch = 0;
+ unsigned short extraBytesToRead = trailingBytesForUTF8[*source];
+ if (source + extraBytesToRead >= sourceEnd) {
+ rb_raise(rb_path2class("JSON::GeneratorError"),
+ "partial character in source, but hit end");
+ }
+ if (!isLegalUTF8(source, extraBytesToRead+1)) {
+ rb_raise(rb_path2class("JSON::GeneratorError"),
+ "source sequence is illegal/malformed utf-8");
+ }
+ /*
+ * The cases all fall through. See "Note A" below.
+ */
+ switch (extraBytesToRead) {
+ case 5: ch += *source++; ch <<= 6; /* remember, illegal UTF-8 */
+ case 4: ch += *source++; ch <<= 6; /* remember, illegal UTF-8 */
+ case 3: ch += *source++; ch <<= 6;
+ case 2: ch += *source++; ch <<= 6;
+ case 1: ch += *source++; ch <<= 6;
+ case 0: ch += *source++;
+ }
+ ch -= offsetsFromUTF8[extraBytesToRead];
+
+ if (ch <= UNI_MAX_BMP) { /* Target is a character <= 0xFFFF */
+ /* UTF-16 surrogate values are illegal in UTF-32 */
+ if (ch >= UNI_SUR_HIGH_START && ch <= UNI_SUR_LOW_END) {
+#if UNI_STRICT_CONVERSION
+ source -= (extraBytesToRead+1); /* return to the illegal value itself */
+ rb_raise(rb_path2class("JSON::GeneratorError"),
+ "source sequence is illegal/malformed utf-8");
+#else
+ unicode_escape_to_buffer(buffer, buf, UNI_REPLACEMENT_CHAR);
+#endif
+ } else {
+ /* normal case */
+ if (ch >= 0x20 && ch <= 0x7f) {
+ switch (ch) {
+ case '\\':
+ fbuffer_append(buffer, "\\\\", 2);
+ break;
+ case '"':
+ fbuffer_append(buffer, "\\\"", 2);
+ break;
+ default:
+ fbuffer_append_char(buffer, (char)ch);
+ break;
+ }
+ } else {
+ switch (ch) {
+ case '\n':
+ fbuffer_append(buffer, "\\n", 2);
+ break;
+ case '\r':
+ fbuffer_append(buffer, "\\r", 2);
+ break;
+ case '\t':
+ fbuffer_append(buffer, "\\t", 2);
+ break;
+ case '\f':
+ fbuffer_append(buffer, "\\f", 2);
+ break;
+ case '\b':
+ fbuffer_append(buffer, "\\b", 2);
+ break;
+ default:
+ unicode_escape_to_buffer(buffer, buf, (UTF16) ch);
+ break;
+ }
+ }
+ }
+ } else if (ch > UNI_MAX_UTF16) {
+#if UNI_STRICT_CONVERSION
+ source -= (extraBytesToRead+1); /* return to the start */
+ rb_raise(rb_path2class("JSON::GeneratorError"),
+ "source sequence is illegal/malformed utf8");
+#else
+ unicode_escape_to_buffer(buffer, buf, UNI_REPLACEMENT_CHAR);
+#endif
+ } else {
+ /* target is a character in range 0xFFFF - 0x10FFFF. */
+ ch -= halfBase;
+ unicode_escape_to_buffer(buffer, buf, (UTF16)((ch >> halfShift) + UNI_SUR_HIGH_START));
+ unicode_escape_to_buffer(buffer, buf, (UTF16)((ch & halfMask) + UNI_SUR_LOW_START));
+ }
+ }
+}
+
+/* Converts string to a JSON string in FBuffer buffer, where only the
+ * characters required by the JSON standard are JSON escaped. The remaining
+ * characters (should be UTF8) are just passed through and appended to the
+ * result. */
+static void convert_UTF8_to_JSON(FBuffer *buffer, VALUE string)
+{
+ const char *ptr = RSTRING_PTR(string), *p;
+ unsigned long len = RSTRING_LEN(string), start = 0, end = 0;
+ const char *escape = NULL;
+ int escape_len;
+ unsigned char c;
+ char buf[6] = { '\\', 'u' };
+
+ for (start = 0, end = 0; end < len;) {
+ p = ptr + end;
+ c = (unsigned char) *p;
+ if (c < 0x20) {
+ switch (c) {
+ case '\n':
+ escape = "\\n";
+ escape_len = 2;
+ break;
+ case '\r':
+ escape = "\\r";
+ escape_len = 2;
+ break;
+ case '\t':
+ escape = "\\t";
+ escape_len = 2;
+ break;
+ case '\f':
+ escape = "\\f";
+ escape_len = 2;
+ break;
+ case '\b':
+ escape = "\\b";
+ escape_len = 2;
+ break;
+ default:
+ unicode_escape(buf, (UTF16) *p);
+ escape = buf;
+ escape_len = 6;
+ break;
+ }
+ } else {
+ switch (c) {
+ case '\\':
+ escape = "\\\\";
+ escape_len = 2;
+ break;
+ case '"':
+ escape = "\\\"";
+ escape_len = 2;
+ break;
+ default:
+ {
+ unsigned short clen = trailingBytesForUTF8[c] + 1;
+ if (end + clen > len) {
+ rb_raise(rb_path2class("JSON::GeneratorError"),
+ "partial character in source, but hit end");
+ }
+ if (!isLegalUTF8((UTF8 *) p, clen)) {
+ rb_raise(rb_path2class("JSON::GeneratorError"),
+ "source sequence is illegal/malformed utf-8");
+ }
+ end += clen;
+ }
+ continue;
+ break;
+ }
+ }
+ fbuffer_append(buffer, ptr + start, end - start);
+ fbuffer_append(buffer, escape, escape_len);
+ start = ++end;
+ escape = NULL;
+ }
+ fbuffer_append(buffer, ptr + start, end - start);
+}
+
+static char *fstrndup(const char *ptr, unsigned long len) {
+ char *result;
+ if (len <= 0) return NULL;
+ result = ALLOC_N(char, len);
+ memccpy(result, ptr, 0, len);
+ return result;
+}
+
+/*
+ * Document-module: JSON::Ext::Generator
+ *
+ * This is the JSON generator implemented as a C extension. It can be
+ * configured to be used by setting
+ *
+ * JSON.generator = JSON::Ext::Generator
+ *
+ * with the method generator= in JSON.
+ *
+ */
+
+/*
+ * call-seq: to_json(state = nil)
+ *
+ * Returns a JSON string containing a JSON object, that is generated from
+ * this Hash instance.
+ * _state_ is a JSON::State object, that can also be used to configure the
+ * produced JSON string output further.
+ */
+static VALUE mHash_to_json(int argc, VALUE *argv, VALUE self)
+{
+ GENERATE_JSON(object);
+}
+
+/*
+ * call-seq: to_json(state = nil)
+ *
+ * Returns a JSON string containing a JSON array, that is generated from
+ * this Array instance.
+ * _state_ is a JSON::State object, that can also be used to configure the
+ * produced JSON string output further.
+ */
+static VALUE mArray_to_json(int argc, VALUE *argv, VALUE self) {
+ GENERATE_JSON(array);
+}
+
+/*
+ * call-seq: to_json(*)
+ *
+ * Returns a JSON string representation for this Integer number.
+ */
+static VALUE mFixnum_to_json(int argc, VALUE *argv, VALUE self)
+{
+ GENERATE_JSON(fixnum);
+}
+
+/*
+ * call-seq: to_json(*)
+ *
+ * Returns a JSON string representation for this Integer number.
+ */
+static VALUE mBignum_to_json(int argc, VALUE *argv, VALUE self)
+{
+ GENERATE_JSON(bignum);
+}
+
+/*
+ * call-seq: to_json(*)
+ *
+ * Returns a JSON string representation for this Float number.
+ */
+static VALUE mFloat_to_json(int argc, VALUE *argv, VALUE self)
+{
+ GENERATE_JSON(float);
+}
+
+/*
+ * call-seq: String.included(modul)
+ *
+ * Extends _modul_ with the String::Extend module.
+ */
+static VALUE mString_included_s(VALUE self, VALUE modul) {
+ VALUE result = rb_funcall(modul, i_extend, 1, mString_Extend);
+ return result;
+}
+
+/*
+ * call-seq: to_json(*)
+ *
+ * This string should be encoded with UTF-8 A call to this method
+ * returns a JSON string encoded with UTF16 big endian characters as
+ * \u????.
+ */
+static VALUE mString_to_json(int argc, VALUE *argv, VALUE self)
+{
+ GENERATE_JSON(string);
+}
+
+/*
+ * call-seq: to_json_raw_object()
+ *
+ * This method creates a raw object hash, that can be nested into
+ * other data structures and will be generated as a raw string. This
+ * method should be used, if you want to convert raw strings to JSON
+ * instead of UTF-8 strings, e. g. binary data.
+ */
+static VALUE mString_to_json_raw_object(VALUE self)
+{
+ VALUE ary;
+ VALUE result = rb_hash_new();
+ rb_hash_aset(result, rb_funcall(mJSON, i_create_id, 0), rb_class_name(rb_obj_class(self)));
+ ary = rb_funcall(self, i_unpack, 1, rb_str_new2("C*"));
+ rb_hash_aset(result, rb_str_new2("raw"), ary);
+ return result;
+}
+
+/*
+ * call-seq: to_json_raw(*args)
+ *
+ * This method creates a JSON text from the result of a call to
+ * to_json_raw_object of this String.
+ */
+static VALUE mString_to_json_raw(int argc, VALUE *argv, VALUE self)
+{
+ VALUE obj = mString_to_json_raw_object(self);
+ Check_Type(obj, T_HASH);
+ return mHash_to_json(argc, argv, obj);
+}
+
+/*
+ * call-seq: json_create(o)
+ *
+ * Raw Strings are JSON Objects (the raw bytes are stored in an array for the
+ * key "raw"). The Ruby String can be created by this module method.
+ */
+static VALUE mString_Extend_json_create(VALUE self, VALUE o)
+{
+ VALUE ary;
+ Check_Type(o, T_HASH);
+ ary = rb_hash_aref(o, rb_str_new2("raw"));
+ return rb_funcall(ary, i_pack, 1, rb_str_new2("C*"));
+}
+
+/*
+ * call-seq: to_json(*)
+ *
+ * Returns a JSON string for true: 'true'.
+ */
+static VALUE mTrueClass_to_json(int argc, VALUE *argv, VALUE self)
+{
+ GENERATE_JSON(true);
+}
+
+/*
+ * call-seq: to_json(*)
+ *
+ * Returns a JSON string for false: 'false'.
+ */
+static VALUE mFalseClass_to_json(int argc, VALUE *argv, VALUE self)
+{
+ GENERATE_JSON(false);
+}
+
+/*
+ * call-seq: to_json(*)
+ *
+ * Returns a JSON string for nil: 'null'.
+ */
+static VALUE mNilClass_to_json(int argc, VALUE *argv, VALUE self)
+{
+ GENERATE_JSON(null);
+}
+
+/*
+ * call-seq: to_json(*)
+ *
+ * Converts this object to a string (calling #to_s), converts
+ * it to a JSON string, and returns the result. This is a fallback, if no
+ * special method #to_json was defined for some object.
+ */
+static VALUE mObject_to_json(int argc, VALUE *argv, VALUE self)
+{
+ VALUE state;
+ VALUE string = rb_funcall(self, i_to_s, 0);
+ rb_scan_args(argc, argv, "01", &state);
+ Check_Type(string, T_STRING);
+ state = cState_from_state_s(cState, state);
+ return cState_partial_generate(state, string);
+}
+
+static void State_free(void *ptr)
+{
+ JSON_Generator_State *state = ptr;
+ if (state->indent) ruby_xfree(state->indent);
+ if (state->space) ruby_xfree(state->space);
+ if (state->space_before) ruby_xfree(state->space_before);
+ if (state->object_nl) ruby_xfree(state->object_nl);
+ if (state->array_nl) ruby_xfree(state->array_nl);
+ if (state->array_delim) fbuffer_free(state->array_delim);
+ if (state->object_delim) fbuffer_free(state->object_delim);
+ if (state->object_delim2) fbuffer_free(state->object_delim2);
+ ruby_xfree(state);
+}
+
+static size_t State_memsize(const void *ptr)
+{
+ const JSON_Generator_State *state = ptr;
+ size_t size = sizeof(*state);
+ if (state->indent) size += state->indent_len + 1;
+ if (state->space) size += state->space_len + 1;
+ if (state->space_before) size += state->space_before_len + 1;
+ if (state->object_nl) size += state->object_nl_len + 1;
+ if (state->array_nl) size += state->array_nl_len + 1;
+ if (state->array_delim) size += FBUFFER_CAPA(state->array_delim);
+ if (state->object_delim) size += FBUFFER_CAPA(state->object_delim);
+ if (state->object_delim2) size += FBUFFER_CAPA(state->object_delim2);
+ return size;
+}
+
+static const rb_data_type_t JSON_Generator_State_type = {
+ "JSON/Generator/State",
+ {NULL, State_free, State_memsize,},
+ 0, 0,
+ RUBY_TYPED_FREE_IMMEDIATELY,
+};
+
+static JSON_Generator_State *State_allocate(void)
+{
+ JSON_Generator_State *state = ZALLOC(JSON_Generator_State);
+ return state;
+}
+
+static VALUE cState_s_allocate(VALUE klass)
+{
+ JSON_Generator_State *state = State_allocate();
+ return TypedData_Wrap_Struct(klass, &JSON_Generator_State_type, state);
+}
+
+/*
+ * call-seq: configure(opts)
+ *
+ * Configure this State instance with the Hash _opts_, and return
+ * itself.
+ */
+static VALUE cState_configure(VALUE self, VALUE opts)
+{
+ VALUE tmp;
+ GET_STATE(self);
+ tmp = rb_check_convert_type(opts, T_HASH, "Hash", "to_hash");
+ if (NIL_P(tmp)) tmp = rb_convert_type(opts, T_HASH, "Hash", "to_h");
+ opts = tmp;
+ tmp = rb_hash_aref(opts, ID2SYM(i_indent));
+ if (RTEST(tmp)) {
+ unsigned long len;
+ Check_Type(tmp, T_STRING);
+ len = RSTRING_LEN(tmp);
+ state->indent = fstrndup(RSTRING_PTR(tmp), len + 1);
+ state->indent_len = len;
+ }
+ tmp = rb_hash_aref(opts, ID2SYM(i_space));
+ if (RTEST(tmp)) {
+ unsigned long len;
+ Check_Type(tmp, T_STRING);
+ len = RSTRING_LEN(tmp);
+ state->space = fstrndup(RSTRING_PTR(tmp), len + 1);
+ state->space_len = len;
+ }
+ tmp = rb_hash_aref(opts, ID2SYM(i_space_before));
+ if (RTEST(tmp)) {
+ unsigned long len;
+ Check_Type(tmp, T_STRING);
+ len = RSTRING_LEN(tmp);
+ state->space_before = fstrndup(RSTRING_PTR(tmp), len + 1);
+ state->space_before_len = len;
+ }
+ tmp = rb_hash_aref(opts, ID2SYM(i_array_nl));
+ if (RTEST(tmp)) {
+ unsigned long len;
+ Check_Type(tmp, T_STRING);
+ len = RSTRING_LEN(tmp);
+ state->array_nl = fstrndup(RSTRING_PTR(tmp), len + 1);
+ state->array_nl_len = len;
+ }
+ tmp = rb_hash_aref(opts, ID2SYM(i_object_nl));
+ if (RTEST(tmp)) {
+ unsigned long len;
+ Check_Type(tmp, T_STRING);
+ len = RSTRING_LEN(tmp);
+ state->object_nl = fstrndup(RSTRING_PTR(tmp), len + 1);
+ state->object_nl_len = len;
+ }
+ tmp = ID2SYM(i_max_nesting);
+ state->max_nesting = 100;
+ if (option_given_p(opts, tmp)) {
+ VALUE max_nesting = rb_hash_aref(opts, tmp);
+ if (RTEST(max_nesting)) {
+ Check_Type(max_nesting, T_FIXNUM);
+ state->max_nesting = FIX2LONG(max_nesting);
+ } else {
+ state->max_nesting = 0;
+ }
+ }
+ tmp = ID2SYM(i_depth);
+ state->depth = 0;
+ if (option_given_p(opts, tmp)) {
+ VALUE depth = rb_hash_aref(opts, tmp);
+ if (RTEST(depth)) {
+ Check_Type(depth, T_FIXNUM);
+ state->depth = FIX2LONG(depth);
+ } else {
+ state->depth = 0;
+ }
+ }
+ tmp = ID2SYM(i_buffer_initial_length);
+ if (option_given_p(opts, tmp)) {
+ VALUE buffer_initial_length = rb_hash_aref(opts, tmp);
+ if (RTEST(buffer_initial_length)) {
+ long initial_length;
+ Check_Type(buffer_initial_length, T_FIXNUM);
+ initial_length = FIX2LONG(buffer_initial_length);
+ if (initial_length > 0) state->buffer_initial_length = initial_length;
+ }
+ }
+ tmp = rb_hash_aref(opts, ID2SYM(i_allow_nan));
+ state->allow_nan = RTEST(tmp);
+ tmp = rb_hash_aref(opts, ID2SYM(i_ascii_only));
+ state->ascii_only = RTEST(tmp);
+ tmp = rb_hash_aref(opts, ID2SYM(i_quirks_mode));
+ state->quirks_mode = RTEST(tmp);
+ return self;
+}
+
+static void set_state_ivars(VALUE hash, VALUE state)
+{
+ VALUE ivars = rb_obj_instance_variables(state);
+ int i = 0;
+ for (i = 0; i < RARRAY_LEN(ivars); i++) {
+ VALUE key = rb_funcall(rb_ary_entry(ivars, i), i_to_s, 0);
+ long key_len = RSTRING_LEN(key);
+ VALUE value = rb_iv_get(state, StringValueCStr(key));
+ rb_hash_aset(hash, rb_str_intern(rb_str_substr(key, 1, key_len - 1)), value);
+ }
+}
+
+/*
+ * call-seq: to_h
+ *
+ * Returns the configuration instance variables as a hash, that can be
+ * passed to the configure method.
+ */
+static VALUE cState_to_h(VALUE self)
+{
+ VALUE result = rb_hash_new();
+ GET_STATE(self);
+ set_state_ivars(result, self);
+ rb_hash_aset(result, ID2SYM(i_indent), rb_str_new(state->indent, state->indent_len));
+ rb_hash_aset(result, ID2SYM(i_space), rb_str_new(state->space, state->space_len));
+ rb_hash_aset(result, ID2SYM(i_space_before), rb_str_new(state->space_before, state->space_before_len));
+ rb_hash_aset(result, ID2SYM(i_object_nl), rb_str_new(state->object_nl, state->object_nl_len));
+ rb_hash_aset(result, ID2SYM(i_array_nl), rb_str_new(state->array_nl, state->array_nl_len));
+ rb_hash_aset(result, ID2SYM(i_allow_nan), state->allow_nan ? Qtrue : Qfalse);
+ rb_hash_aset(result, ID2SYM(i_ascii_only), state->ascii_only ? Qtrue : Qfalse);
+ rb_hash_aset(result, ID2SYM(i_quirks_mode), state->quirks_mode ? Qtrue : Qfalse);
+ rb_hash_aset(result, ID2SYM(i_max_nesting), LONG2FIX(state->max_nesting));
+ rb_hash_aset(result, ID2SYM(i_depth), LONG2FIX(state->depth));
+ rb_hash_aset(result, ID2SYM(i_buffer_initial_length), LONG2FIX(state->buffer_initial_length));
+ return result;
+}
+
+/*
+* call-seq: [](name)
+*
+* Return the value returned by method +name+.
+*/
+static VALUE cState_aref(VALUE self, VALUE name)
+{
+ name = rb_funcall(name, i_to_s, 0);
+ if (RTEST(rb_funcall(self, i_respond_to_p, 1, name))) {
+ return rb_funcall(self, i_send, 1, name);
+ } else {
+ return rb_ivar_get(self, rb_intern_str(rb_str_concat(rb_str_new2("@"), name)));
+ }
+}
+
+/*
+* call-seq: []=(name, value)
+*
+* Set the attribute name to value.
+*/
+static VALUE cState_aset(VALUE self, VALUE name, VALUE value)
+{
+ VALUE name_writer;
+
+ name = rb_funcall(name, i_to_s, 0);
+ name_writer = rb_str_cat2(rb_str_dup(name), "=");
+ if (RTEST(rb_funcall(self, i_respond_to_p, 1, name_writer))) {
+ return rb_funcall(self, i_send, 2, name_writer, value);
+ } else {
+ rb_ivar_set(self, rb_intern_str(rb_str_concat(rb_str_new2("@"), name)), value);
+ }
+ return Qnil;
+}
+
+static void generate_json_object(FBuffer *buffer, VALUE Vstate, JSON_Generator_State *state, VALUE obj)
+{
+ char *object_nl = state->object_nl;
+ long object_nl_len = state->object_nl_len;
+ char *indent = state->indent;
+ long indent_len = state->indent_len;
+ long max_nesting = state->max_nesting;
+ char *delim = FBUFFER_PTR(state->object_delim);
+ long delim_len = FBUFFER_LEN(state->object_delim);
+ char *delim2 = FBUFFER_PTR(state->object_delim2);
+ long delim2_len = FBUFFER_LEN(state->object_delim2);
+ long depth = ++state->depth;
+ int i, j;
+ VALUE key, key_to_s, keys;
+ if (max_nesting != 0 && depth > max_nesting) {
+ fbuffer_free(buffer);
+ rb_raise(eNestingError, "nesting of %ld is too deep", --state->depth);
+ }
+ fbuffer_append_char(buffer, '{');
+ keys = rb_funcall(obj, i_keys, 0);
+ for(i = 0; i < RARRAY_LEN(keys); i++) {
+ if (i > 0) fbuffer_append(buffer, delim, delim_len);
+ if (object_nl) {
+ fbuffer_append(buffer, object_nl, object_nl_len);
+ }
+ if (indent) {
+ for (j = 0; j < depth; j++) {
+ fbuffer_append(buffer, indent, indent_len);
+ }
+ }
+ key = rb_ary_entry(keys, i);
+ key_to_s = rb_funcall(key, i_to_s, 0);
+ Check_Type(key_to_s, T_STRING);
+ generate_json(buffer, Vstate, state, key_to_s);
+ fbuffer_append(buffer, delim2, delim2_len);
+ generate_json(buffer, Vstate, state, rb_hash_aref(obj, key));
+ }
+ depth = --state->depth;
+ if (object_nl) {
+ fbuffer_append(buffer, object_nl, object_nl_len);
+ if (indent) {
+ for (j = 0; j < depth; j++) {
+ fbuffer_append(buffer, indent, indent_len);
+ }
+ }
+ }
+ fbuffer_append_char(buffer, '}');
+}
+
+static void generate_json_array(FBuffer *buffer, VALUE Vstate, JSON_Generator_State *state, VALUE obj)
+{
+ char *array_nl = state->array_nl;
+ long array_nl_len = state->array_nl_len;
+ char *indent = state->indent;
+ long indent_len = state->indent_len;
+ long max_nesting = state->max_nesting;
+ char *delim = FBUFFER_PTR(state->array_delim);
+ long delim_len = FBUFFER_LEN(state->array_delim);
+ long depth = ++state->depth;
+ int i, j;
+ if (max_nesting != 0 && depth > max_nesting) {
+ fbuffer_free(buffer);
+ rb_raise(eNestingError, "nesting of %ld is too deep", --state->depth);
+ }
+ fbuffer_append_char(buffer, '[');
+ if (array_nl) fbuffer_append(buffer, array_nl, array_nl_len);
+ for(i = 0; i < RARRAY_LEN(obj); i++) {
+ if (i > 0) fbuffer_append(buffer, delim, delim_len);
+ if (indent) {
+ for (j = 0; j < depth; j++) {
+ fbuffer_append(buffer, indent, indent_len);
+ }
+ }
+ generate_json(buffer, Vstate, state, rb_ary_entry(obj, i));
+ }
+ state->depth = --depth;
+ if (array_nl) {
+ fbuffer_append(buffer, array_nl, array_nl_len);
+ if (indent) {
+ for (j = 0; j < depth; j++) {
+ fbuffer_append(buffer, indent, indent_len);
+ }
+ }
+ }
+ fbuffer_append_char(buffer, ']');
+}
+
+static void generate_json_string(FBuffer *buffer, VALUE Vstate, JSON_Generator_State *state, VALUE obj)
+{
+ fbuffer_append_char(buffer, '"');
+#ifdef HAVE_RUBY_ENCODING_H
+ obj = rb_funcall(obj, i_encode, 1, CEncoding_UTF_8);
+#endif
+ if (state->ascii_only) {
+ convert_UTF8_to_JSON_ASCII(buffer, obj);
+ } else {
+ convert_UTF8_to_JSON(buffer, obj);
+ }
+ fbuffer_append_char(buffer, '"');
+}
+
+static void generate_json_null(FBuffer *buffer, VALUE Vstate, JSON_Generator_State *state, VALUE obj)
+{
+ fbuffer_append(buffer, "null", 4);
+}
+
+static void generate_json_false(FBuffer *buffer, VALUE Vstate, JSON_Generator_State *state, VALUE obj)
+{
+ fbuffer_append(buffer, "false", 5);
+}
+
+static void generate_json_true(FBuffer *buffer, VALUE Vstate, JSON_Generator_State *state, VALUE obj)
+{
+ fbuffer_append(buffer, "true", 4);
+}
+
+static void generate_json_fixnum(FBuffer *buffer, VALUE Vstate, JSON_Generator_State *state, VALUE obj)
+{
+ fbuffer_append_long(buffer, FIX2LONG(obj));
+}
+
+static void generate_json_bignum(FBuffer *buffer, VALUE Vstate, JSON_Generator_State *state, VALUE obj)
+{
+ VALUE tmp = rb_funcall(obj, i_to_s, 0);
+ fbuffer_append_str(buffer, tmp);
+}
+
+static void generate_json_float(FBuffer *buffer, VALUE Vstate, JSON_Generator_State *state, VALUE obj)
+{
+ double value = RFLOAT_VALUE(obj);
+ char allow_nan = state->allow_nan;
+ VALUE tmp = rb_funcall(obj, i_to_s, 0);
+ if (!allow_nan) {
+ if (isinf(value)) {
+ fbuffer_free(buffer);
+ rb_raise(eGeneratorError, "%u: %"PRIsVALUE" not allowed in JSON", __LINE__, RB_OBJ_STRING(tmp));
+ } else if (isnan(value)) {
+ fbuffer_free(buffer);
+ rb_raise(eGeneratorError, "%u: %"PRIsVALUE" not allowed in JSON", __LINE__, RB_OBJ_STRING(tmp));
+ }
+ }
+ fbuffer_append_str(buffer, tmp);
+}
+
+static void generate_json(FBuffer *buffer, VALUE Vstate, JSON_Generator_State *state, VALUE obj)
+{
+ VALUE tmp;
+ VALUE klass = CLASS_OF(obj);
+ if (klass == rb_cHash) {
+ generate_json_object(buffer, Vstate, state, obj);
+ } else if (klass == rb_cArray) {
+ generate_json_array(buffer, Vstate, state, obj);
+ } else if (klass == rb_cString) {
+ generate_json_string(buffer, Vstate, state, obj);
+ } else if (obj == Qnil) {
+ generate_json_null(buffer, Vstate, state, obj);
+ } else if (obj == Qfalse) {
+ generate_json_false(buffer, Vstate, state, obj);
+ } else if (obj == Qtrue) {
+ generate_json_true(buffer, Vstate, state, obj);
+ } else if (klass == rb_cFixnum) {
+ generate_json_fixnum(buffer, Vstate, state, obj);
+ } else if (klass == rb_cBignum) {
+ generate_json_bignum(buffer, Vstate, state, obj);
+ } else if (klass == rb_cFloat) {
+ generate_json_float(buffer, Vstate, state, obj);
+ } else if (rb_respond_to(obj, i_to_json)) {
+ tmp = rb_funcall(obj, i_to_json, 1, Vstate);
+ Check_Type(tmp, T_STRING);
+ fbuffer_append_str(buffer, tmp);
+ } else {
+ tmp = rb_funcall(obj, i_to_s, 0);
+ Check_Type(tmp, T_STRING);
+ generate_json(buffer, Vstate, state, tmp);
+ }
+}
+
+static FBuffer *cState_prepare_buffer(VALUE self)
+{
+ FBuffer *buffer;
+ GET_STATE(self);
+ buffer = fbuffer_alloc(state->buffer_initial_length);
+
+ if (state->object_delim) {
+ fbuffer_clear(state->object_delim);
+ } else {
+ state->object_delim = fbuffer_alloc(16);
+ }
+ fbuffer_append_char(state->object_delim, ',');
+ if (state->object_delim2) {
+ fbuffer_clear(state->object_delim2);
+ } else {
+ state->object_delim2 = fbuffer_alloc(16);
+ }
+ fbuffer_append_char(state->object_delim2, ':');
+ if (state->space) fbuffer_append(state->object_delim2, state->space, state->space_len);
+
+ if (state->array_delim) {
+ fbuffer_clear(state->array_delim);
+ } else {
+ state->array_delim = fbuffer_alloc(16);
+ }
+ fbuffer_append_char(state->array_delim, ',');
+ if (state->array_nl) fbuffer_append(state->array_delim, state->array_nl, state->array_nl_len);
+ return buffer;
+}
+
+static VALUE cState_partial_generate(VALUE self, VALUE obj)
+{
+ FBuffer *buffer = cState_prepare_buffer(self);
+ GET_STATE(self);
+ generate_json(buffer, self, state, obj);
+ return fbuffer_to_s(buffer);
+}
+
+/*
+ * This function returns true if string is either a JSON array or JSON object.
+ * It might suffer from false positives, e. g. syntactically incorrect JSON in
+ * the string or certain UTF-8 characters on the right hand side.
+ */
+static int isArrayOrObject(VALUE string)
+{
+ long string_len = RSTRING_LEN(string);
+ char *p = RSTRING_PTR(string), *q = p + string_len - 1;
+ if (string_len < 2) return 0;
+ for (; p < q && isspace((unsigned char)*p); p++);
+ for (; q > p && isspace((unsigned char)*q); q--);
+ return (*p == '[' && *q == ']') || (*p == '{' && *q == '}');
+}
+
+/*
+ * call-seq: generate(obj)
+ *
+ * Generates a valid JSON document from object +obj+ and returns the
+ * result. If no valid JSON document can be created this method raises a
+ * GeneratorError exception.
+ */
+static VALUE cState_generate(VALUE self, VALUE obj)
+{
+ VALUE result = cState_partial_generate(self, obj);
+ GET_STATE(self);
+ if (!state->quirks_mode && !isArrayOrObject(result)) {
+ rb_raise(eGeneratorError, "only generation of JSON objects or arrays allowed");
+ }
+ return result;
+}
+
+/*
+ * call-seq: new(opts = {})
+ *
+ * Instantiates a new State object, configured by _opts_.
+ *
+ * _opts_ can have the following keys:
+ *
+ * * *indent*: a string used to indent levels (default: ''),
+ * * *space*: a string that is put after, a : or , delimiter (default: ''),
+ * * *space_before*: a string that is put before a : pair delimiter (default: ''),
+ * * *object_nl*: a string that is put at the end of a JSON object (default: ''),
+ * * *array_nl*: a string that is put at the end of a JSON array (default: ''),
+ * * *allow_nan*: true if NaN, Infinity, and -Infinity should be
+ * generated, otherwise an exception is thrown, if these values are
+ * encountered. This options defaults to false.
+ * * *quirks_mode*: Enables quirks_mode for parser, that is for example
+ * generating single JSON values instead of documents is possible.
+ * * *buffer_initial_length*: sets the initial length of the generator's
+ * internal buffer.
+ */
+static VALUE cState_initialize(int argc, VALUE *argv, VALUE self)
+{
+ VALUE opts;
+ GET_STATE(self);
+ state->max_nesting = 100;
+ state->buffer_initial_length = FBUFFER_INITIAL_LENGTH_DEFAULT;
+ rb_scan_args(argc, argv, "01", &opts);
+ if (!NIL_P(opts)) cState_configure(self, opts);
+ return self;
+}
+
+/*
+ * call-seq: initialize_copy(orig)
+ *
+ * Initializes this object from orig if it to be duplicated/cloned and returns
+ * it.
+*/
+static VALUE cState_init_copy(VALUE obj, VALUE orig)
+{
+ JSON_Generator_State *objState, *origState;
+
+ if (obj == orig) return obj;
+ GET_STATE_TO(obj, objState);
+ GET_STATE_TO(orig, origState);
+ if (!objState) rb_raise(rb_eArgError, "unallocated JSON::State");
+
+ MEMCPY(objState, origState, JSON_Generator_State, 1);
+ objState->indent = fstrndup(origState->indent, origState->indent_len);
+ objState->space = fstrndup(origState->space, origState->space_len);
+ objState->space_before = fstrndup(origState->space_before, origState->space_before_len);
+ objState->object_nl = fstrndup(origState->object_nl, origState->object_nl_len);
+ objState->array_nl = fstrndup(origState->array_nl, origState->array_nl_len);
+ if (origState->array_delim) objState->array_delim = fbuffer_dup(origState->array_delim);
+ if (origState->object_delim) objState->object_delim = fbuffer_dup(origState->object_delim);
+ if (origState->object_delim2) objState->object_delim2 = fbuffer_dup(origState->object_delim2);
+ return obj;
+}
+
+/*
+ * call-seq: from_state(opts)
+ *
+ * Creates a State object from _opts_, which ought to be Hash to create a
+ * new State instance configured by _opts_, something else to create an
+ * unconfigured instance. If _opts_ is a State object, it is just returned.
+ */
+static VALUE cState_from_state_s(VALUE self, VALUE opts)
+{
+ if (rb_obj_is_kind_of(opts, self)) {
+ return opts;
+ } else if (rb_obj_is_kind_of(opts, rb_cHash)) {
+ return rb_funcall(self, i_new, 1, opts);
+ } else {
+ if (NIL_P(CJSON_SAFE_STATE_PROTOTYPE)) {
+ CJSON_SAFE_STATE_PROTOTYPE = rb_const_get(mJSON, i_SAFE_STATE_PROTOTYPE);
+ }
+ return rb_funcall(CJSON_SAFE_STATE_PROTOTYPE, i_dup, 0);
+ }
+}
+
+/*
+ * call-seq: indent()
+ *
+ * This string is used to indent levels in the JSON text.
+ */
+static VALUE cState_indent(VALUE self)
+{
+ GET_STATE(self);
+ return state->indent ? rb_str_new(state->indent, state->indent_len) : rb_str_new2("");
+}
+
+/*
+ * call-seq: indent=(indent)
+ *
+ * This string is used to indent levels in the JSON text.
+ */
+static VALUE cState_indent_set(VALUE self, VALUE indent)
+{
+ unsigned long len;
+ GET_STATE(self);
+ Check_Type(indent, T_STRING);
+ len = RSTRING_LEN(indent);
+ if (len == 0) {
+ if (state->indent) {
+ ruby_xfree(state->indent);
+ state->indent = NULL;
+ state->indent_len = 0;
+ }
+ } else {
+ if (state->indent) ruby_xfree(state->indent);
+ state->indent = strdup(RSTRING_PTR(indent));
+ state->indent_len = len;
+ }
+ return Qnil;
+}
+
+/*
+ * call-seq: space()
+ *
+ * This string is used to insert a space between the tokens in a JSON
+ * string.
+ */
+static VALUE cState_space(VALUE self)
+{
+ GET_STATE(self);
+ return state->space ? rb_str_new(state->space, state->space_len) : rb_str_new2("");
+}
+
+/*
+ * call-seq: space=(space)
+ *
+ * This string is used to insert a space between the tokens in a JSON
+ * string.
+ */
+static VALUE cState_space_set(VALUE self, VALUE space)
+{
+ unsigned long len;
+ GET_STATE(self);
+ Check_Type(space, T_STRING);
+ len = RSTRING_LEN(space);
+ if (len == 0) {
+ if (state->space) {
+ ruby_xfree(state->space);
+ state->space = NULL;
+ state->space_len = 0;
+ }
+ } else {
+ if (state->space) ruby_xfree(state->space);
+ state->space = strdup(RSTRING_PTR(space));
+ state->space_len = len;
+ }
+ return Qnil;
+}
+
+/*
+ * call-seq: space_before()
+ *
+ * This string is used to insert a space before the ':' in JSON objects.
+ */
+static VALUE cState_space_before(VALUE self)
+{
+ GET_STATE(self);
+ return state->space_before ? rb_str_new(state->space_before, state->space_before_len) : rb_str_new2("");
+}
+
+/*
+ * call-seq: space_before=(space_before)
+ *
+ * This string is used to insert a space before the ':' in JSON objects.
+ */
+static VALUE cState_space_before_set(VALUE self, VALUE space_before)
+{
+ unsigned long len;
+ GET_STATE(self);
+ Check_Type(space_before, T_STRING);
+ len = RSTRING_LEN(space_before);
+ if (len == 0) {
+ if (state->space_before) {
+ ruby_xfree(state->space_before);
+ state->space_before = NULL;
+ state->space_before_len = 0;
+ }
+ } else {
+ if (state->space_before) ruby_xfree(state->space_before);
+ state->space_before = strdup(RSTRING_PTR(space_before));
+ state->space_before_len = len;
+ }
+ return Qnil;
+}
+
+/*
+ * call-seq: object_nl()
+ *
+ * This string is put at the end of a line that holds a JSON object (or
+ * Hash).
+ */
+static VALUE cState_object_nl(VALUE self)
+{
+ GET_STATE(self);
+ return state->object_nl ? rb_str_new(state->object_nl, state->object_nl_len) : rb_str_new2("");
+}
+
+/*
+ * call-seq: object_nl=(object_nl)
+ *
+ * This string is put at the end of a line that holds a JSON object (or
+ * Hash).
+ */
+static VALUE cState_object_nl_set(VALUE self, VALUE object_nl)
+{
+ unsigned long len;
+ GET_STATE(self);
+ Check_Type(object_nl, T_STRING);
+ len = RSTRING_LEN(object_nl);
+ if (len == 0) {
+ if (state->object_nl) {
+ ruby_xfree(state->object_nl);
+ state->object_nl = NULL;
+ }
+ } else {
+ if (state->object_nl) ruby_xfree(state->object_nl);
+ state->object_nl = strdup(RSTRING_PTR(object_nl));
+ state->object_nl_len = len;
+ }
+ return Qnil;
+}
+
+/*
+ * call-seq: array_nl()
+ *
+ * This string is put at the end of a line that holds a JSON array.
+ */
+static VALUE cState_array_nl(VALUE self)
+{
+ GET_STATE(self);
+ return state->array_nl ? rb_str_new(state->array_nl, state->array_nl_len) : rb_str_new2("");
+}
+
+/*
+ * call-seq: array_nl=(array_nl)
+ *
+ * This string is put at the end of a line that holds a JSON array.
+ */
+static VALUE cState_array_nl_set(VALUE self, VALUE array_nl)
+{
+ unsigned long len;
+ GET_STATE(self);
+ Check_Type(array_nl, T_STRING);
+ len = RSTRING_LEN(array_nl);
+ if (len == 0) {
+ if (state->array_nl) {
+ ruby_xfree(state->array_nl);
+ state->array_nl = NULL;
+ }
+ } else {
+ if (state->array_nl) ruby_xfree(state->array_nl);
+ state->array_nl = strdup(RSTRING_PTR(array_nl));
+ state->array_nl_len = len;
+ }
+ return Qnil;
+}
+
+
+/*
+* call-seq: check_circular?
+*
+* Returns true, if circular data structures should be checked,
+* otherwise returns false.
+*/
+static VALUE cState_check_circular_p(VALUE self)
+{
+ GET_STATE(self);
+ return state->max_nesting ? Qtrue : Qfalse;
+}
+
+/*
+ * call-seq: max_nesting
+ *
+ * This integer returns the maximum level of data structure nesting in
+ * the generated JSON, max_nesting = 0 if no maximum is checked.
+ */
+static VALUE cState_max_nesting(VALUE self)
+{
+ GET_STATE(self);
+ return LONG2FIX(state->max_nesting);
+}
+
+/*
+ * call-seq: max_nesting=(depth)
+ *
+ * This sets the maximum level of data structure nesting in the generated JSON
+ * to the integer depth, max_nesting = 0 if no maximum should be checked.
+ */
+static VALUE cState_max_nesting_set(VALUE self, VALUE depth)
+{
+ GET_STATE(self);
+ Check_Type(depth, T_FIXNUM);
+ return state->max_nesting = FIX2LONG(depth);
+}
+
+/*
+ * call-seq: allow_nan?
+ *
+ * Returns true, if NaN, Infinity, and -Infinity should be generated, otherwise
+ * returns false.
+ */
+static VALUE cState_allow_nan_p(VALUE self)
+{
+ GET_STATE(self);
+ return state->allow_nan ? Qtrue : Qfalse;
+}
+
+/*
+ * call-seq: ascii_only?
+ *
+ * Returns true, if NaN, Infinity, and -Infinity should be generated, otherwise
+ * returns false.
+ */
+static VALUE cState_ascii_only_p(VALUE self)
+{
+ GET_STATE(self);
+ return state->ascii_only ? Qtrue : Qfalse;
+}
+
+/*
+ * call-seq: quirks_mode?
+ *
+ * Returns true, if quirks mode is enabled. Otherwise returns false.
+ */
+static VALUE cState_quirks_mode_p(VALUE self)
+{
+ GET_STATE(self);
+ return state->quirks_mode ? Qtrue : Qfalse;
+}
+
+/*
+ * call-seq: quirks_mode=(enable)
+ *
+ * If set to true, enables the quirks_mode mode.
+ */
+static VALUE cState_quirks_mode_set(VALUE self, VALUE enable)
+{
+ GET_STATE(self);
+ state->quirks_mode = RTEST(enable);
+ return Qnil;
+}
+
+/*
+ * call-seq: depth
+ *
+ * This integer returns the current depth of data structure nesting.
+ */
+static VALUE cState_depth(VALUE self)
+{
+ GET_STATE(self);
+ return LONG2FIX(state->depth);
+}
+
+/*
+ * call-seq: depth=(depth)
+ *
+ * This sets the maximum level of data structure nesting in the generated JSON
+ * to the integer depth, max_nesting = 0 if no maximum should be checked.
+ */
+static VALUE cState_depth_set(VALUE self, VALUE depth)
+{
+ GET_STATE(self);
+ Check_Type(depth, T_FIXNUM);
+ state->depth = FIX2LONG(depth);
+ return Qnil;
+}
+
+/*
+ * call-seq: buffer_initial_length
+ *
+ * This integer returns the current inital length of the buffer.
+ */
+static VALUE cState_buffer_initial_length(VALUE self)
+{
+ GET_STATE(self);
+ return LONG2FIX(state->buffer_initial_length);
+}
+
+/*
+ * call-seq: buffer_initial_length=(length)
+ *
+ * This sets the initial length of the buffer to +length+, if +length+ > 0,
+ * otherwise its value isn't changed.
+ */
+static VALUE cState_buffer_initial_length_set(VALUE self, VALUE buffer_initial_length)
+{
+ long initial_length;
+ GET_STATE(self);
+ Check_Type(buffer_initial_length, T_FIXNUM);
+ initial_length = FIX2LONG(buffer_initial_length);
+ if (initial_length > 0) {
+ state->buffer_initial_length = initial_length;
+ }
+ return Qnil;
+}
+
+/*
+ *
+ */
+void Init_generator(void)
+{
+ rb_require("json/common");
+
+ mJSON = rb_define_module("JSON");
+ mExt = rb_define_module_under(mJSON, "Ext");
+ mGenerator = rb_define_module_under(mExt, "Generator");
+
+ eGeneratorError = rb_path2class("JSON::GeneratorError");
+ eNestingError = rb_path2class("JSON::NestingError");
+
+ cState = rb_define_class_under(mGenerator, "State", rb_cObject);
+ rb_define_alloc_func(cState, cState_s_allocate);
+ rb_define_singleton_method(cState, "from_state", cState_from_state_s, 1);
+ rb_define_method(cState, "initialize", cState_initialize, -1);
+ rb_define_method(cState, "initialize_copy", cState_init_copy, 1);
+ rb_define_method(cState, "indent", cState_indent, 0);
+ rb_define_method(cState, "indent=", cState_indent_set, 1);
+ rb_define_method(cState, "space", cState_space, 0);
+ rb_define_method(cState, "space=", cState_space_set, 1);
+ rb_define_method(cState, "space_before", cState_space_before, 0);
+ rb_define_method(cState, "space_before=", cState_space_before_set, 1);
+ rb_define_method(cState, "object_nl", cState_object_nl, 0);
+ rb_define_method(cState, "object_nl=", cState_object_nl_set, 1);
+ rb_define_method(cState, "array_nl", cState_array_nl, 0);
+ rb_define_method(cState, "array_nl=", cState_array_nl_set, 1);
+ rb_define_method(cState, "max_nesting", cState_max_nesting, 0);
+ rb_define_method(cState, "max_nesting=", cState_max_nesting_set, 1);
+ rb_define_method(cState, "check_circular?", cState_check_circular_p, 0);
+ rb_define_method(cState, "allow_nan?", cState_allow_nan_p, 0);
+ rb_define_method(cState, "ascii_only?", cState_ascii_only_p, 0);
+ rb_define_method(cState, "quirks_mode?", cState_quirks_mode_p, 0);
+ rb_define_method(cState, "quirks_mode", cState_quirks_mode_p, 0);
+ rb_define_method(cState, "quirks_mode=", cState_quirks_mode_set, 1);
+ rb_define_method(cState, "depth", cState_depth, 0);
+ rb_define_method(cState, "depth=", cState_depth_set, 1);
+ rb_define_method(cState, "buffer_initial_length", cState_buffer_initial_length, 0);
+ rb_define_method(cState, "buffer_initial_length=", cState_buffer_initial_length_set, 1);
+ rb_define_method(cState, "configure", cState_configure, 1);
+ rb_define_alias(cState, "merge", "configure");
+ rb_define_method(cState, "to_h", cState_to_h, 0);
+ rb_define_alias(cState, "to_hash", "to_h");
+ rb_define_method(cState, "[]", cState_aref, 1);
+ rb_define_method(cState, "[]=", cState_aset, 2);
+ rb_define_method(cState, "generate", cState_generate, 1);
+
+ mGeneratorMethods = rb_define_module_under(mGenerator, "GeneratorMethods");
+ mObject = rb_define_module_under(mGeneratorMethods, "Object");
+ rb_define_method(mObject, "to_json", mObject_to_json, -1);
+ mHash = rb_define_module_under(mGeneratorMethods, "Hash");
+ rb_define_method(mHash, "to_json", mHash_to_json, -1);
+ mArray = rb_define_module_under(mGeneratorMethods, "Array");
+ rb_define_method(mArray, "to_json", mArray_to_json, -1);
+ mFixnum = rb_define_module_under(mGeneratorMethods, "Fixnum");
+ rb_define_method(mFixnum, "to_json", mFixnum_to_json, -1);
+ mBignum = rb_define_module_under(mGeneratorMethods, "Bignum");
+ rb_define_method(mBignum, "to_json", mBignum_to_json, -1);
+ mFloat = rb_define_module_under(mGeneratorMethods, "Float");
+ rb_define_method(mFloat, "to_json", mFloat_to_json, -1);
+ mString = rb_define_module_under(mGeneratorMethods, "String");
+ rb_define_singleton_method(mString, "included", mString_included_s, 1);
+ rb_define_method(mString, "to_json", mString_to_json, -1);
+ rb_define_method(mString, "to_json_raw", mString_to_json_raw, -1);
+ rb_define_method(mString, "to_json_raw_object", mString_to_json_raw_object, 0);
+ mString_Extend = rb_define_module_under(mString, "Extend");
+ rb_define_method(mString_Extend, "json_create", mString_Extend_json_create, 1);
+ mTrueClass = rb_define_module_under(mGeneratorMethods, "TrueClass");
+ rb_define_method(mTrueClass, "to_json", mTrueClass_to_json, -1);
+ mFalseClass = rb_define_module_under(mGeneratorMethods, "FalseClass");
+ rb_define_method(mFalseClass, "to_json", mFalseClass_to_json, -1);
+ mNilClass = rb_define_module_under(mGeneratorMethods, "NilClass");
+ rb_define_method(mNilClass, "to_json", mNilClass_to_json, -1);
+
+ CRegexp_MULTILINE = rb_const_get(rb_cRegexp, rb_intern("MULTILINE"));
+ i_to_s = rb_intern("to_s");
+ i_to_json = rb_intern("to_json");
+ i_new = rb_intern("new");
+ i_indent = rb_intern("indent");
+ i_space = rb_intern("space");
+ i_space_before = rb_intern("space_before");
+ i_object_nl = rb_intern("object_nl");
+ i_array_nl = rb_intern("array_nl");
+ i_max_nesting = rb_intern("max_nesting");
+ i_allow_nan = rb_intern("allow_nan");
+ i_ascii_only = rb_intern("ascii_only");
+ i_quirks_mode = rb_intern("quirks_mode");
+ i_depth = rb_intern("depth");
+ i_buffer_initial_length = rb_intern("buffer_initial_length");
+ i_pack = rb_intern("pack");
+ i_unpack = rb_intern("unpack");
+ i_create_id = rb_intern("create_id");
+ i_extend = rb_intern("extend");
+ i_key_p = rb_intern("key?");
+ i_aref = rb_intern("[]");
+ i_send = rb_intern("__send__");
+ i_respond_to_p = rb_intern("respond_to?");
+ i_match = rb_intern("match");
+ i_keys = rb_intern("keys");
+ i_dup = rb_intern("dup");
+#ifdef HAVE_RUBY_ENCODING_H
+ CEncoding_UTF_8 = rb_funcall(rb_path2class("Encoding"), rb_intern("find"), 1, rb_str_new2("utf-8"));
+ i_encoding = rb_intern("encoding");
+ i_encode = rb_intern("encode");
+#endif
+ i_SAFE_STATE_PROTOTYPE = rb_intern("SAFE_STATE_PROTOTYPE");
+ CJSON_SAFE_STATE_PROTOTYPE = Qnil;
+}
diff --git a/jni/ruby/ext/json/generator/generator.h b/jni/ruby/ext/json/generator/generator.h
new file mode 100644
index 0000000..ddd1aa8
--- /dev/null
+++ b/jni/ruby/ext/json/generator/generator.h
@@ -0,0 +1,152 @@
+#ifndef _GENERATOR_H_
+#define _GENERATOR_H_
+
+#include <string.h>
+#include <math.h>
+#include <ctype.h>
+
+#include "ruby.h"
+
+#ifdef HAVE_RUBY_RE_H
+#include "ruby/re.h"
+#else
+#include "re.h"
+#endif
+
+#ifndef rb_intern_str
+#define rb_intern_str(string) SYM2ID(rb_str_intern(string))
+#endif
+
+#ifndef rb_obj_instance_variables
+#define rb_obj_instance_variables(object) rb_funcall(object, rb_intern("instance_variables"), 0)
+#endif
+
+#define option_given_p(opts, key) RTEST(rb_funcall(opts, i_key_p, 1, key))
+
+/* unicode defintions */
+
+#define UNI_STRICT_CONVERSION 1
+
+typedef unsigned long UTF32; /* at least 32 bits */
+typedef unsigned short UTF16; /* at least 16 bits */
+typedef unsigned char UTF8; /* typically 8 bits */
+
+#define UNI_REPLACEMENT_CHAR (UTF32)0x0000FFFD
+#define UNI_MAX_BMP (UTF32)0x0000FFFF
+#define UNI_MAX_UTF16 (UTF32)0x0010FFFF
+#define UNI_MAX_UTF32 (UTF32)0x7FFFFFFF
+#define UNI_MAX_LEGAL_UTF32 (UTF32)0x0010FFFF
+
+#define UNI_SUR_HIGH_START (UTF32)0xD800
+#define UNI_SUR_HIGH_END (UTF32)0xDBFF
+#define UNI_SUR_LOW_START (UTF32)0xDC00
+#define UNI_SUR_LOW_END (UTF32)0xDFFF
+
+static const int halfShift = 10; /* used for shifting by 10 bits */
+
+static const UTF32 halfBase = 0x0010000UL;
+static const UTF32 halfMask = 0x3FFUL;
+
+static unsigned char isLegalUTF8(const UTF8 *source, unsigned long length);
+static void unicode_escape(char *buf, UTF16 character);
+static void unicode_escape_to_buffer(FBuffer *buffer, char buf[6], UTF16 character);
+static void convert_UTF8_to_JSON_ASCII(FBuffer *buffer, VALUE string);
+static void convert_UTF8_to_JSON(FBuffer *buffer, VALUE string);
+static char *fstrndup(const char *ptr, unsigned long len);
+
+/* ruby api and some helpers */
+
+typedef struct JSON_Generator_StateStruct {
+ char *indent;
+ long indent_len;
+ char *space;
+ long space_len;
+ char *space_before;
+ long space_before_len;
+ char *object_nl;
+ long object_nl_len;
+ char *array_nl;
+ long array_nl_len;
+ FBuffer *array_delim;
+ FBuffer *object_delim;
+ FBuffer *object_delim2;
+ long max_nesting;
+ char allow_nan;
+ char ascii_only;
+ char quirks_mode;
+ long depth;
+ long buffer_initial_length;
+} JSON_Generator_State;
+
+#define GET_STATE_TO(self, state) \
+ TypedData_Get_Struct(self, JSON_Generator_State, &JSON_Generator_State_type, state)
+
+#define GET_STATE(self) \
+ JSON_Generator_State *state; \
+ GET_STATE_TO(self, state)
+
+#define GENERATE_JSON(type) \
+ FBuffer *buffer; \
+ VALUE Vstate; \
+ JSON_Generator_State *state; \
+ \
+ rb_scan_args(argc, argv, "01", &Vstate); \
+ Vstate = cState_from_state_s(cState, Vstate); \
+ TypedData_Get_Struct(Vstate, JSON_Generator_State, &JSON_Generator_State_type, state); \
+ buffer = cState_prepare_buffer(Vstate); \
+ generate_json_##type(buffer, Vstate, state, self); \
+ return fbuffer_to_s(buffer)
+
+static VALUE mHash_to_json(int argc, VALUE *argv, VALUE self);
+static VALUE mArray_to_json(int argc, VALUE *argv, VALUE self);
+static VALUE mFixnum_to_json(int argc, VALUE *argv, VALUE self);
+static VALUE mBignum_to_json(int argc, VALUE *argv, VALUE self);
+static VALUE mFloat_to_json(int argc, VALUE *argv, VALUE self);
+static VALUE mString_included_s(VALUE self, VALUE modul);
+static VALUE mString_to_json(int argc, VALUE *argv, VALUE self);
+static VALUE mString_to_json_raw_object(VALUE self);
+static VALUE mString_to_json_raw(int argc, VALUE *argv, VALUE self);
+static VALUE mString_Extend_json_create(VALUE self, VALUE o);
+static VALUE mTrueClass_to_json(int argc, VALUE *argv, VALUE self);
+static VALUE mFalseClass_to_json(int argc, VALUE *argv, VALUE self);
+static VALUE mNilClass_to_json(int argc, VALUE *argv, VALUE self);
+static VALUE mObject_to_json(int argc, VALUE *argv, VALUE self);
+static void State_free(void *state);
+static JSON_Generator_State *State_allocate(void);
+static VALUE cState_s_allocate(VALUE klass);
+static VALUE cState_configure(VALUE self, VALUE opts);
+static VALUE cState_to_h(VALUE self);
+static void generate_json(FBuffer *buffer, VALUE Vstate, JSON_Generator_State *state, VALUE obj);
+static void generate_json_object(FBuffer *buffer, VALUE Vstate, JSON_Generator_State *state, VALUE obj);
+static void generate_json_array(FBuffer *buffer, VALUE Vstate, JSON_Generator_State *state, VALUE obj);
+static void generate_json_string(FBuffer *buffer, VALUE Vstate, JSON_Generator_State *state, VALUE obj);
+static void generate_json_null(FBuffer *buffer, VALUE Vstate, JSON_Generator_State *state, VALUE obj);
+static void generate_json_false(FBuffer *buffer, VALUE Vstate, JSON_Generator_State *state, VALUE obj);
+static void generate_json_true(FBuffer *buffer, VALUE Vstate, JSON_Generator_State *state, VALUE obj);
+static void generate_json_fixnum(FBuffer *buffer, VALUE Vstate, JSON_Generator_State *state, VALUE obj);
+static void generate_json_bignum(FBuffer *buffer, VALUE Vstate, JSON_Generator_State *state, VALUE obj);
+static void generate_json_float(FBuffer *buffer, VALUE Vstate, JSON_Generator_State *state, VALUE obj);
+static VALUE cState_partial_generate(VALUE self, VALUE obj);
+static VALUE cState_generate(VALUE self, VALUE obj);
+static VALUE cState_initialize(int argc, VALUE *argv, VALUE self);
+static VALUE cState_from_state_s(VALUE self, VALUE opts);
+static VALUE cState_indent(VALUE self);
+static VALUE cState_indent_set(VALUE self, VALUE indent);
+static VALUE cState_space(VALUE self);
+static VALUE cState_space_set(VALUE self, VALUE space);
+static VALUE cState_space_before(VALUE self);
+static VALUE cState_space_before_set(VALUE self, VALUE space_before);
+static VALUE cState_object_nl(VALUE self);
+static VALUE cState_object_nl_set(VALUE self, VALUE object_nl);
+static VALUE cState_array_nl(VALUE self);
+static VALUE cState_array_nl_set(VALUE self, VALUE array_nl);
+static VALUE cState_max_nesting(VALUE self);
+static VALUE cState_max_nesting_set(VALUE self, VALUE depth);
+static VALUE cState_allow_nan_p(VALUE self);
+static VALUE cState_ascii_only_p(VALUE self);
+static VALUE cState_depth(VALUE self);
+static VALUE cState_depth_set(VALUE self, VALUE depth);
+static FBuffer *cState_prepare_buffer(VALUE self);
+static const rb_data_type_t JSON_Generator_State_type;
+
+#endif
diff --git a/jni/ruby/ext/json/lib/json.rb b/jni/ruby/ext/json/lib/json.rb
new file mode 100644
index 0000000..24aa385
--- /dev/null
+++ b/jni/ruby/ext/json/lib/json.rb
@@ -0,0 +1,62 @@
+require 'json/common'
+
+##
+# = JavaScript Object Notation (JSON)
+#
+# JSON is a lightweight data-interchange format. It is easy for us
+# humans to read and write. Plus, equally simple for machines to generate or parse.
+# JSON is completely language agnostic, making it the ideal interchange format.
+#
+# Built on two universally available structures:
+# 1. A collection of name/value pairs. Often referred to as an _object_, hash table, record, struct, keyed list, or associative array.
+# 2. An ordered list of values. More commonly called an _array_, vector, sequence or list.
+#
+# To read more about JSON visit: http://json.org
+#
+# == Parsing JSON
+#
+# To parse a JSON string received by another application or generated within
+# your existing application:
+#
+# require 'json'
+#
+# my_hash = JSON.parse('{"hello": "goodbye"}')
+# puts my_hash["hello"] => "goodbye"
+#
+# Notice the extra quotes <tt>''</tt> around the hash notation. Ruby expects
+# the argument to be a string and can't convert objects like a hash or array.
+#
+# Ruby converts your string into a hash
+#
+# == Generating JSON
+#
+# Creating a JSON string for communication or serialization is
+# just as simple.
+#
+# require 'json'
+#
+# my_hash = {:hello => "goodbye"}
+# puts JSON.generate(my_hash) => "{\"hello\":\"goodbye\"}"
+#
+# Or an alternative way:
+#
+# require 'json'
+# puts {:hello => "goodbye"}.to_json => "{\"hello\":\"goodbye\"}"
+#
+# <tt>JSON.generate</tt> only allows objects or arrays to be converted
+# to JSON syntax. <tt>to_json</tt>, however, accepts many Ruby classes
+# even though it acts only as a method for serialization:
+#
+# require 'json'
+#
+# 1.to_json => "1"
+#
+module JSON
+ require 'json/version'
+
+ begin
+ require 'json/ext'
+ rescue LoadError
+ require 'json/pure'
+ end
+end
diff --git a/jni/ruby/ext/json/lib/json/add/bigdecimal.rb b/jni/ruby/ext/json/lib/json/add/bigdecimal.rb
new file mode 100644
index 0000000..0ef69f1
--- /dev/null
+++ b/jni/ruby/ext/json/lib/json/add/bigdecimal.rb
@@ -0,0 +1,28 @@
+unless defined?(::JSON::JSON_LOADED) and ::JSON::JSON_LOADED
+ require 'json'
+end
+defined?(::BigDecimal) or require 'bigdecimal'
+
+class BigDecimal
+ # Import a JSON Marshalled object.
+ #
+ # method used for JSON marshalling support.
+ def self.json_create(object)
+ BigDecimal._load object['b']
+ end
+
+ # Marshal the object to JSON.
+ #
+ # method used for JSON marshalling support.
+ def as_json(*)
+ {
+ JSON.create_id => self.class.name,
+ 'b' => _dump,
+ }
+ end
+
+ # return the JSON value
+ def to_json(*)
+ as_json.to_json
+ end
+end
diff --git a/jni/ruby/ext/json/lib/json/add/complex.rb b/jni/ruby/ext/json/lib/json/add/complex.rb
new file mode 100644
index 0000000..d7ebebf
--- /dev/null
+++ b/jni/ruby/ext/json/lib/json/add/complex.rb
@@ -0,0 +1,22 @@
+unless defined?(::JSON::JSON_LOADED) and ::JSON::JSON_LOADED
+ require 'json'
+end
+defined?(::Complex) or require 'complex'
+
+class Complex
+ def self.json_create(object)
+ Complex(object['r'], object['i'])
+ end
+
+ def as_json(*)
+ {
+ JSON.create_id => self.class.name,
+ 'r' => real,
+ 'i' => imag,
+ }
+ end
+
+ def to_json(*)
+ as_json.to_json
+ end
+end
diff --git a/jni/ruby/ext/json/lib/json/add/core.rb b/jni/ruby/ext/json/lib/json/add/core.rb
new file mode 100644
index 0000000..77d9dc0
--- /dev/null
+++ b/jni/ruby/ext/json/lib/json/add/core.rb
@@ -0,0 +1,11 @@
+# This file requires the implementations of ruby core's custom objects for
+# serialisation/deserialisation.
+
+require 'json/add/date'
+require 'json/add/date_time'
+require 'json/add/exception'
+require 'json/add/range'
+require 'json/add/regexp'
+require 'json/add/struct'
+require 'json/add/symbol'
+require 'json/add/time'
diff --git a/jni/ruby/ext/json/lib/json/add/date.rb b/jni/ruby/ext/json/lib/json/add/date.rb
new file mode 100644
index 0000000..4288237
--- /dev/null
+++ b/jni/ruby/ext/json/lib/json/add/date.rb
@@ -0,0 +1,34 @@
+unless defined?(::JSON::JSON_LOADED) and ::JSON::JSON_LOADED
+ require 'json'
+end
+require 'date'
+
+# Date serialization/deserialization
+class Date
+
+ # Deserializes JSON string by converting Julian year <tt>y</tt>, month
+ # <tt>m</tt>, day <tt>d</tt> and Day of Calendar Reform <tt>sg</tt> to Date.
+ def self.json_create(object)
+ civil(*object.values_at('y', 'm', 'd', 'sg'))
+ end
+
+ alias start sg unless method_defined?(:start)
+
+ # Returns a hash, that will be turned into a JSON object and represent this
+ # object.
+ def as_json(*)
+ {
+ JSON.create_id => self.class.name,
+ 'y' => year,
+ 'm' => month,
+ 'd' => day,
+ 'sg' => start,
+ }
+ end
+
+ # Stores class name (Date) with Julian year <tt>y</tt>, month <tt>m</tt>, day
+ # <tt>d</tt> and Day of Calendar Reform <tt>sg</tt> as JSON string
+ def to_json(*args)
+ as_json.to_json(*args)
+ end
+end
diff --git a/jni/ruby/ext/json/lib/json/add/date_time.rb b/jni/ruby/ext/json/lib/json/add/date_time.rb
new file mode 100644
index 0000000..5ea42ea
--- /dev/null
+++ b/jni/ruby/ext/json/lib/json/add/date_time.rb
@@ -0,0 +1,50 @@
+unless defined?(::JSON::JSON_LOADED) and ::JSON::JSON_LOADED
+ require 'json'
+end
+require 'date'
+
+# DateTime serialization/deserialization
+class DateTime
+
+ # Deserializes JSON string by converting year <tt>y</tt>, month <tt>m</tt>,
+ # day <tt>d</tt>, hour <tt>H</tt>, minute <tt>M</tt>, second <tt>S</tt>,
+ # offset <tt>of</tt> and Day of Calendar Reform <tt>sg</tt> to DateTime.
+ def self.json_create(object)
+ args = object.values_at('y', 'm', 'd', 'H', 'M', 'S')
+ of_a, of_b = object['of'].split('/')
+ if of_b and of_b != '0'
+ args << Rational(of_a.to_i, of_b.to_i)
+ else
+ args << of_a
+ end
+ args << object['sg']
+ civil(*args)
+ end
+
+ alias start sg unless method_defined?(:start)
+
+ # Returns a hash, that will be turned into a JSON object and represent this
+ # object.
+ def as_json(*)
+ {
+ JSON.create_id => self.class.name,
+ 'y' => year,
+ 'm' => month,
+ 'd' => day,
+ 'H' => hour,
+ 'M' => min,
+ 'S' => sec,
+ 'of' => offset.to_s,
+ 'sg' => start,
+ }
+ end
+
+ # Stores class name (DateTime) with Julian year <tt>y</tt>, month <tt>m</tt>,
+ # day <tt>d</tt>, hour <tt>H</tt>, minute <tt>M</tt>, second <tt>S</tt>,
+ # offset <tt>of</tt> and Day of Calendar Reform <tt>sg</tt> as JSON string
+ def to_json(*args)
+ as_json.to_json(*args)
+ end
+end
+
+
diff --git a/jni/ruby/ext/json/lib/json/add/exception.rb b/jni/ruby/ext/json/lib/json/add/exception.rb
new file mode 100644
index 0000000..e6ad257
--- /dev/null
+++ b/jni/ruby/ext/json/lib/json/add/exception.rb
@@ -0,0 +1,31 @@
+unless defined?(::JSON::JSON_LOADED) and ::JSON::JSON_LOADED
+ require 'json'
+end
+
+# Exception serialization/deserialization
+class Exception
+
+ # Deserializes JSON string by constructing new Exception object with message
+ # <tt>m</tt> and backtrace <tt>b</tt> serialized with <tt>to_json</tt>
+ def self.json_create(object)
+ result = new(object['m'])
+ result.set_backtrace object['b']
+ result
+ end
+
+ # Returns a hash, that will be turned into a JSON object and represent this
+ # object.
+ def as_json(*)
+ {
+ JSON.create_id => self.class.name,
+ 'm' => message,
+ 'b' => backtrace,
+ }
+ end
+
+ # Stores class name (Exception) with message <tt>m</tt> and backtrace array
+ # <tt>b</tt> as JSON string
+ def to_json(*args)
+ as_json.to_json(*args)
+ end
+end
diff --git a/jni/ruby/ext/json/lib/json/add/ostruct.rb b/jni/ruby/ext/json/lib/json/add/ostruct.rb
new file mode 100644
index 0000000..da81e10
--- /dev/null
+++ b/jni/ruby/ext/json/lib/json/add/ostruct.rb
@@ -0,0 +1,31 @@
+unless defined?(::JSON::JSON_LOADED) and ::JSON::JSON_LOADED
+ require 'json'
+end
+require 'ostruct'
+
+# OpenStruct serialization/deserialization
+class OpenStruct
+
+ # Deserializes JSON string by constructing new Struct object with values
+ # <tt>v</tt> serialized by <tt>to_json</tt>.
+ def self.json_create(object)
+ new(object['t'] || object[:t])
+ end
+
+ # Returns a hash, that will be turned into a JSON object and represent this
+ # object.
+ def as_json(*)
+ klass = self.class.name
+ klass.to_s.empty? and raise JSON::JSONError, "Only named structs are supported!"
+ {
+ JSON.create_id => klass,
+ 't' => table,
+ }
+ end
+
+ # Stores class name (OpenStruct) with this struct's values <tt>v</tt> as a
+ # JSON string.
+ def to_json(*args)
+ as_json.to_json(*args)
+ end
+end
diff --git a/jni/ruby/ext/json/lib/json/add/range.rb b/jni/ruby/ext/json/lib/json/add/range.rb
new file mode 100644
index 0000000..e61e553
--- /dev/null
+++ b/jni/ruby/ext/json/lib/json/add/range.rb
@@ -0,0 +1,29 @@
+unless defined?(::JSON::JSON_LOADED) and ::JSON::JSON_LOADED
+ require 'json'
+end
+
+# Range serialization/deserialization
+class Range
+
+ # Deserializes JSON string by constructing new Range object with arguments
+ # <tt>a</tt> serialized by <tt>to_json</tt>.
+ def self.json_create(object)
+ new(*object['a'])
+ end
+
+ # Returns a hash, that will be turned into a JSON object and represent this
+ # object.
+ def as_json(*)
+ {
+ JSON.create_id => self.class.name,
+ 'a' => [ first, last, exclude_end? ]
+ }
+ end
+
+ # Stores class name (Range) with JSON array of arguments <tt>a</tt> which
+ # include <tt>first</tt> (integer), <tt>last</tt> (integer), and
+ # <tt>exclude_end?</tt> (boolean) as JSON string.
+ def to_json(*args)
+ as_json.to_json(*args)
+ end
+end
diff --git a/jni/ruby/ext/json/lib/json/add/rational.rb b/jni/ruby/ext/json/lib/json/add/rational.rb
new file mode 100644
index 0000000..867cd92
--- /dev/null
+++ b/jni/ruby/ext/json/lib/json/add/rational.rb
@@ -0,0 +1,22 @@
+unless defined?(::JSON::JSON_LOADED) and ::JSON::JSON_LOADED
+ require 'json'
+end
+defined?(::Rational) or require 'rational'
+
+class Rational
+ def self.json_create(object)
+ Rational(object['n'], object['d'])
+ end
+
+ def as_json(*)
+ {
+ JSON.create_id => self.class.name,
+ 'n' => numerator,
+ 'd' => denominator,
+ }
+ end
+
+ def to_json(*)
+ as_json.to_json
+ end
+end
diff --git a/jni/ruby/ext/json/lib/json/add/regexp.rb b/jni/ruby/ext/json/lib/json/add/regexp.rb
new file mode 100644
index 0000000..2fcbb6f
--- /dev/null
+++ b/jni/ruby/ext/json/lib/json/add/regexp.rb
@@ -0,0 +1,30 @@
+unless defined?(::JSON::JSON_LOADED) and ::JSON::JSON_LOADED
+ require 'json'
+end
+
+# Regexp serialization/deserialization
+class Regexp
+
+ # Deserializes JSON string by constructing new Regexp object with source
+ # <tt>s</tt> (Regexp or String) and options <tt>o</tt> serialized by
+ # <tt>to_json</tt>
+ def self.json_create(object)
+ new(object['s'], object['o'])
+ end
+
+ # Returns a hash, that will be turned into a JSON object and represent this
+ # object.
+ def as_json(*)
+ {
+ JSON.create_id => self.class.name,
+ 'o' => options,
+ 's' => source,
+ }
+ end
+
+ # Stores class name (Regexp) with options <tt>o</tt> and source <tt>s</tt>
+ # (Regexp or String) as JSON string
+ def to_json(*)
+ as_json.to_json
+ end
+end
diff --git a/jni/ruby/ext/json/lib/json/add/struct.rb b/jni/ruby/ext/json/lib/json/add/struct.rb
new file mode 100644
index 0000000..6847cde
--- /dev/null
+++ b/jni/ruby/ext/json/lib/json/add/struct.rb
@@ -0,0 +1,30 @@
+unless defined?(::JSON::JSON_LOADED) and ::JSON::JSON_LOADED
+ require 'json'
+end
+
+# Struct serialization/deserialization
+class Struct
+
+ # Deserializes JSON string by constructing new Struct object with values
+ # <tt>v</tt> serialized by <tt>to_json</tt>.
+ def self.json_create(object)
+ new(*object['v'])
+ end
+
+ # Returns a hash, that will be turned into a JSON object and represent this
+ # object.
+ def as_json(*)
+ klass = self.class.name
+ klass.to_s.empty? and raise JSON::JSONError, "Only named structs are supported!"
+ {
+ JSON.create_id => klass,
+ 'v' => values,
+ }
+ end
+
+ # Stores class name (Struct) with Struct values <tt>v</tt> as a JSON string.
+ # Only named structs are supported.
+ def to_json(*args)
+ as_json.to_json(*args)
+ end
+end
diff --git a/jni/ruby/ext/json/lib/json/add/symbol.rb b/jni/ruby/ext/json/lib/json/add/symbol.rb
new file mode 100644
index 0000000..03dc9a5
--- /dev/null
+++ b/jni/ruby/ext/json/lib/json/add/symbol.rb
@@ -0,0 +1,25 @@
+unless defined?(::JSON::JSON_LOADED) and ::JSON::JSON_LOADED
+ require 'json'
+end
+
+# Symbol serialization/deserialization
+class Symbol
+ # Returns a hash, that will be turned into a JSON object and represent this
+ # object.
+ def as_json(*)
+ {
+ JSON.create_id => self.class.name,
+ 's' => to_s,
+ }
+ end
+
+ # Stores class name (Symbol) with String representation of Symbol as a JSON string.
+ def to_json(*a)
+ as_json.to_json(*a)
+ end
+
+ # Deserializes JSON string by converting the <tt>string</tt> value stored in the object to a Symbol
+ def self.json_create(o)
+ o['s'].to_sym
+ end
+end
diff --git a/jni/ruby/ext/json/lib/json/add/time.rb b/jni/ruby/ext/json/lib/json/add/time.rb
new file mode 100644
index 0000000..338209d
--- /dev/null
+++ b/jni/ruby/ext/json/lib/json/add/time.rb
@@ -0,0 +1,38 @@
+unless defined?(::JSON::JSON_LOADED) and ::JSON::JSON_LOADED
+ require 'json'
+end
+
+# Time serialization/deserialization
+class Time
+
+ # Deserializes JSON string by converting time since epoch to Time
+ def self.json_create(object)
+ if usec = object.delete('u') # used to be tv_usec -> tv_nsec
+ object['n'] = usec * 1000
+ end
+ if instance_methods.include?(:tv_nsec)
+ at(object['s'], Rational(object['n'], 1000))
+ else
+ at(object['s'], object['n'] / 1000)
+ end
+ end
+
+ # Returns a hash, that will be turned into a JSON object and represent this
+ # object.
+ def as_json(*)
+ nanoseconds = [ tv_usec * 1000 ]
+ respond_to?(:tv_nsec) and nanoseconds << tv_nsec
+ nanoseconds = nanoseconds.max
+ {
+ JSON.create_id => self.class.name,
+ 's' => tv_sec,
+ 'n' => nanoseconds,
+ }
+ end
+
+ # Stores class name (Time) with number of seconds since epoch and number of
+ # microseconds for Time as JSON string
+ def to_json(*args)
+ as_json.to_json(*args)
+ end
+end
diff --git a/jni/ruby/ext/json/lib/json/common.rb b/jni/ruby/ext/json/lib/json/common.rb
new file mode 100644
index 0000000..8fbaa2b
--- /dev/null
+++ b/jni/ruby/ext/json/lib/json/common.rb
@@ -0,0 +1,484 @@
+require 'json/version'
+require 'json/generic_object'
+
+module JSON
+ class << self
+ # If _object_ is string-like, parse the string and return the parsed result
+ # as a Ruby data structure. Otherwise generate a JSON text from the Ruby
+ # data structure object and return it.
+ #
+ # The _opts_ argument is passed through to generate/parse respectively. See
+ # generate and parse for their documentation.
+ def [](object, opts = {})
+ if object.respond_to? :to_str
+ JSON.parse(object.to_str, opts)
+ else
+ JSON.generate(object, opts)
+ end
+ end
+
+ # Returns the JSON parser class that is used by JSON. This is either
+ # JSON::Ext::Parser or JSON::Pure::Parser.
+ attr_reader :parser
+
+ # Set the JSON parser class _parser_ to be used by JSON.
+ def parser=(parser) # :nodoc:
+ @parser = parser
+ remove_const :Parser if JSON.const_defined_in?(self, :Parser)
+ const_set :Parser, parser
+ end
+
+ # Return the constant located at _path_. The format of _path_ has to be
+ # either ::A::B::C or A::B::C. In any case, A has to be located at the top
+ # level (absolute namespace path?). If there doesn't exist a constant at
+ # the given path, an ArgumentError is raised.
+ def deep_const_get(path) # :nodoc:
+ path.to_s.split(/::/).inject(Object) do |p, c|
+ case
+ when c.empty? then p
+ when JSON.const_defined_in?(p, c) then p.const_get(c)
+ else
+ begin
+ p.const_missing(c)
+ rescue NameError => e
+ raise ArgumentError, "can't get const #{path}: #{e}"
+ end
+ end
+ end
+ end
+
+ # Set the module _generator_ to be used by JSON.
+ def generator=(generator) # :nodoc:
+ old, $VERBOSE = $VERBOSE, nil
+ @generator = generator
+ generator_methods = generator::GeneratorMethods
+ for const in generator_methods.constants
+ klass = deep_const_get(const)
+ modul = generator_methods.const_get(const)
+ klass.class_eval do
+ instance_methods(false).each do |m|
+ m.to_s == 'to_json' and remove_method m
+ end
+ include modul
+ end
+ end
+ self.state = generator::State
+ const_set :State, self.state
+ const_set :SAFE_STATE_PROTOTYPE, State.new
+ const_set :FAST_STATE_PROTOTYPE, State.new(
+ :indent => '',
+ :space => '',
+ :object_nl => "",
+ :array_nl => "",
+ :max_nesting => false
+ )
+ const_set :PRETTY_STATE_PROTOTYPE, State.new(
+ :indent => ' ',
+ :space => ' ',
+ :object_nl => "\n",
+ :array_nl => "\n"
+ )
+ ensure
+ $VERBOSE = old
+ end
+
+ # Returns the JSON generator module that is used by JSON. This is
+ # either JSON::Ext::Generator or JSON::Pure::Generator.
+ attr_reader :generator
+
+ # Returns the JSON generator state class that is used by JSON. This is
+ # either JSON::Ext::Generator::State or JSON::Pure::Generator::State.
+ attr_accessor :state
+
+ # This is create identifier, which is used to decide if the _json_create_
+ # hook of a class should be called. It defaults to 'json_class'.
+ attr_accessor :create_id
+ end
+ self.create_id = 'json_class'
+
+ NaN = 0.0/0
+
+ Infinity = 1.0/0
+
+ MinusInfinity = -Infinity
+
+ # The base exception for JSON errors.
+ class JSONError < StandardError
+ def self.wrap(exception)
+ obj = new("Wrapped(#{exception.class}): #{exception.message.inspect}")
+ obj.set_backtrace exception.backtrace
+ obj
+ end
+ end
+
+ # This exception is raised if a parser error occurs.
+ class ParserError < JSONError; end
+
+ # This exception is raised if the nesting of parsed data structures is too
+ # deep.
+ class NestingError < ParserError; end
+
+ # :stopdoc:
+ class CircularDatastructure < NestingError; end
+ # :startdoc:
+
+ # This exception is raised if a generator or unparser error occurs.
+ class GeneratorError < JSONError; end
+ # For backwards compatibility
+ UnparserError = GeneratorError
+
+ # This exception is raised if the required unicode support is missing on the
+ # system. Usually this means that the iconv library is not installed.
+ class MissingUnicodeSupport < JSONError; end
+
+ module_function
+
+ # Parse the JSON document _source_ into a Ruby data structure and return it.
+ #
+ # _opts_ can have the following
+ # keys:
+ # * *max_nesting*: The maximum depth of nesting allowed in the parsed data
+ # structures. Disable depth checking with :max_nesting => false. It defaults
+ # to 100.
+ # * *allow_nan*: If set to true, allow NaN, Infinity and -Infinity in
+ # defiance of RFC 4627 to be parsed by the Parser. This option defaults
+ # to false.
+ # * *symbolize_names*: If set to true, returns symbols for the names
+ # (keys) in a JSON object. Otherwise strings are returned. Strings are
+ # the default.
+ # * *create_additions*: If set to false, the Parser doesn't create
+ # additions even if a matching class and create_id was found. This option
+ # defaults to true.
+ # * *object_class*: Defaults to Hash
+ # * *array_class*: Defaults to Array
+ def parse(source, opts = {})
+ Parser.new(source, opts).parse
+ end
+
+ # Parse the JSON document _source_ into a Ruby data structure and return it.
+ # The bang version of the parse method defaults to the more dangerous values
+ # for the _opts_ hash, so be sure only to parse trusted _source_ documents.
+ #
+ # _opts_ can have the following keys:
+ # * *max_nesting*: The maximum depth of nesting allowed in the parsed data
+ # structures. Enable depth checking with :max_nesting => anInteger. The parse!
+ # methods defaults to not doing max depth checking: This can be dangerous
+ # if someone wants to fill up your stack.
+ # * *allow_nan*: If set to true, allow NaN, Infinity, and -Infinity in
+ # defiance of RFC 4627 to be parsed by the Parser. This option defaults
+ # to true.
+ # * *create_additions*: If set to false, the Parser doesn't create
+ # additions even if a matching class and create_id was found. This option
+ # defaults to true.
+ def parse!(source, opts = {})
+ opts = {
+ :max_nesting => false,
+ :allow_nan => true
+ }.update(opts)
+ Parser.new(source, opts).parse
+ end
+
+ # Generate a JSON document from the Ruby data structure _obj_ and return
+ # it. _state_ is * a JSON::State object,
+ # * or a Hash like object (responding to to_hash),
+ # * an object convertible into a hash by a to_h method,
+ # that is used as or to configure a State object.
+ #
+ # It defaults to a state object, that creates the shortest possible JSON text
+ # in one line, checks for circular data structures and doesn't allow NaN,
+ # Infinity, and -Infinity.
+ #
+ # A _state_ hash can have the following keys:
+ # * *indent*: a string used to indent levels (default: ''),
+ # * *space*: a string that is put after, a : or , delimiter (default: ''),
+ # * *space_before*: a string that is put before a : pair delimiter (default: ''),
+ # * *object_nl*: a string that is put at the end of a JSON object (default: ''),
+ # * *array_nl*: a string that is put at the end of a JSON array (default: ''),
+ # * *allow_nan*: true if NaN, Infinity, and -Infinity should be
+ # generated, otherwise an exception is thrown if these values are
+ # encountered. This options defaults to false.
+ # * *max_nesting*: The maximum depth of nesting allowed in the data
+ # structures from which JSON is to be generated. Disable depth checking
+ # with :max_nesting => false, it defaults to 100.
+ #
+ # See also the fast_generate for the fastest creation method with the least
+ # amount of sanity checks, and the pretty_generate method for some
+ # defaults for pretty output.
+ def generate(obj, opts = nil)
+ if State === opts
+ state, opts = opts, nil
+ else
+ state = SAFE_STATE_PROTOTYPE.dup
+ end
+ if opts
+ if opts.respond_to? :to_hash
+ opts = opts.to_hash
+ elsif opts.respond_to? :to_h
+ opts = opts.to_h
+ else
+ raise TypeError, "can't convert #{opts.class} into Hash"
+ end
+ state = state.configure(opts)
+ end
+ state.generate(obj)
+ end
+
+ # :stopdoc:
+ # I want to deprecate these later, so I'll first be silent about them, and
+ # later delete them.
+ alias unparse generate
+ module_function :unparse
+ # :startdoc:
+
+ # Generate a JSON document from the Ruby data structure _obj_ and return it.
+ # This method disables the checks for circles in Ruby objects.
+ #
+ # *WARNING*: Be careful not to pass any Ruby data structures with circles as
+ # _obj_ argument because this will cause JSON to go into an infinite loop.
+ def fast_generate(obj, opts = nil)
+ if State === opts
+ state, opts = opts, nil
+ else
+ state = FAST_STATE_PROTOTYPE.dup
+ end
+ if opts
+ if opts.respond_to? :to_hash
+ opts = opts.to_hash
+ elsif opts.respond_to? :to_h
+ opts = opts.to_h
+ else
+ raise TypeError, "can't convert #{opts.class} into Hash"
+ end
+ state.configure(opts)
+ end
+ state.generate(obj)
+ end
+
+ # :stopdoc:
+ # I want to deprecate these later, so I'll first be silent about them, and later delete them.
+ alias fast_unparse fast_generate
+ module_function :fast_unparse
+ # :startdoc:
+
+ # Generate a JSON document from the Ruby data structure _obj_ and return it.
+ # The returned document is a prettier form of the document returned by
+ # #unparse.
+ #
+ # The _opts_ argument can be used to configure the generator. See the
+ # generate method for a more detailed explanation.
+ def pretty_generate(obj, opts = nil)
+ if State === opts
+ state, opts = opts, nil
+ else
+ state = PRETTY_STATE_PROTOTYPE.dup
+ end
+ if opts
+ if opts.respond_to? :to_hash
+ opts = opts.to_hash
+ elsif opts.respond_to? :to_h
+ opts = opts.to_h
+ else
+ raise TypeError, "can't convert #{opts.class} into Hash"
+ end
+ state.configure(opts)
+ end
+ state.generate(obj)
+ end
+
+ # :stopdoc:
+ # I want to deprecate these later, so I'll first be silent about them, and later delete them.
+ alias pretty_unparse pretty_generate
+ module_function :pretty_unparse
+ # :startdoc:
+
+ class << self
+ # The global default options for the JSON.load method:
+ # :max_nesting: false
+ # :allow_nan: true
+ # :quirks_mode: true
+ attr_accessor :load_default_options
+ end
+ self.load_default_options = {
+ :max_nesting => false,
+ :allow_nan => true,
+ :quirks_mode => true,
+ :create_additions => true,
+ }
+
+ # Load a ruby data structure from a JSON _source_ and return it. A source can
+ # either be a string-like object, an IO-like object, or an object responding
+ # to the read method. If _proc_ was given, it will be called with any nested
+ # Ruby object as an argument recursively in depth first order. To modify the
+ # default options pass in the optional _options_ argument as well.
+ #
+ # BEWARE: This method is meant to serialise data from trusted user input,
+ # like from your own database server or clients under your control, it could
+ # be dangerous to allow untrusted users to pass JSON sources into it. The
+ # default options for the parser can be changed via the load_default_options
+ # method.
+ #
+ # This method is part of the implementation of the load/dump interface of
+ # Marshal and YAML.
+ def load(source, proc = nil, options = {})
+ opts = load_default_options.merge options
+ if source.respond_to? :to_str
+ source = source.to_str
+ elsif source.respond_to? :to_io
+ source = source.to_io.read
+ elsif source.respond_to?(:read)
+ source = source.read
+ end
+ if opts[:quirks_mode] && (source.nil? || source.empty?)
+ source = 'null'
+ end
+ result = parse(source, opts)
+ recurse_proc(result, &proc) if proc
+ result
+ end
+
+ # Recursively calls passed _Proc_ if the parsed data structure is an _Array_ or _Hash_
+ def recurse_proc(result, &proc)
+ case result
+ when Array
+ result.each { |x| recurse_proc x, &proc }
+ proc.call result
+ when Hash
+ result.each { |x, y| recurse_proc x, &proc; recurse_proc y, &proc }
+ proc.call result
+ else
+ proc.call result
+ end
+ end
+
+ alias restore load
+ module_function :restore
+
+ class << self
+ # The global default options for the JSON.dump method:
+ # :max_nesting: false
+ # :allow_nan: true
+ # :quirks_mode: true
+ attr_accessor :dump_default_options
+ end
+ self.dump_default_options = {
+ :max_nesting => false,
+ :allow_nan => true,
+ :quirks_mode => true,
+ }
+
+ # Dumps _obj_ as a JSON string, i.e. calls generate on the object and returns
+ # the result.
+ #
+ # If anIO (an IO-like object or an object that responds to the write method)
+ # was given, the resulting JSON is written to it.
+ #
+ # If the number of nested arrays or objects exceeds _limit_, an ArgumentError
+ # exception is raised. This argument is similar (but not exactly the
+ # same!) to the _limit_ argument in Marshal.dump.
+ #
+ # The default options for the generator can be changed via the
+ # dump_default_options method.
+ #
+ # This method is part of the implementation of the load/dump interface of
+ # Marshal and YAML.
+ def dump(obj, anIO = nil, limit = nil)
+ if anIO and limit.nil?
+ anIO = anIO.to_io if anIO.respond_to?(:to_io)
+ unless anIO.respond_to?(:write)
+ limit = anIO
+ anIO = nil
+ end
+ end
+ opts = JSON.dump_default_options
+ limit and opts.update(:max_nesting => limit)
+ result = generate(obj, opts)
+ if anIO
+ anIO.write result
+ anIO
+ else
+ result
+ end
+ rescue JSON::NestingError
+ raise ArgumentError, "exceed depth limit"
+ end
+
+ # Swap consecutive bytes of _string_ in place.
+ def self.swap!(string) # :nodoc:
+ 0.upto(string.size / 2) do |i|
+ break unless string[2 * i + 1]
+ string[2 * i], string[2 * i + 1] = string[2 * i + 1], string[2 * i]
+ end
+ string
+ end
+
+ # Shortuct for iconv.
+ if ::String.method_defined?(:encode)
+ # Encodes string using Ruby's _String.encode_
+ def self.iconv(to, from, string)
+ string.encode(to, from)
+ end
+ else
+ require 'iconv'
+ # Encodes string using _iconv_ library
+ def self.iconv(to, from, string)
+ Iconv.conv(to, from, string)
+ end
+ end
+
+ if ::Object.method(:const_defined?).arity == 1
+ def self.const_defined_in?(modul, constant)
+ modul.const_defined?(constant)
+ end
+ else
+ def self.const_defined_in?(modul, constant)
+ modul.const_defined?(constant, false)
+ end
+ end
+end
+
+module ::Kernel
+ private
+
+ # Outputs _objs_ to STDOUT as JSON strings in the shortest form, that is in
+ # one line.
+ def j(*objs)
+ objs.each do |obj|
+ puts JSON::generate(obj, :allow_nan => true, :max_nesting => false)
+ end
+ nil
+ end
+
+ # Outputs _objs_ to STDOUT as JSON strings in a pretty format, with
+ # indentation and over many lines.
+ def jj(*objs)
+ objs.each do |obj|
+ puts JSON::pretty_generate(obj, :allow_nan => true, :max_nesting => false)
+ end
+ nil
+ end
+
+ # If _object_ is string-like, parse the string and return the parsed result as
+ # a Ruby data structure. Otherwise, generate a JSON text from the Ruby data
+ # structure object and return it.
+ #
+ # The _opts_ argument is passed through to generate/parse respectively. See
+ # generate and parse for their documentation.
+ def JSON(object, *args)
+ if object.respond_to? :to_str
+ JSON.parse(object.to_str, args.first)
+ else
+ JSON.generate(object, args.first)
+ end
+ end
+end
+
+# Extends any Class to include _json_creatable?_ method.
+class ::Class
+ # Returns true if this class can be used to create an instance
+ # from a serialised JSON string. The class has to implement a class
+ # method _json_create_ that expects a hash as first parameter. The hash
+ # should include the required data.
+ def json_creatable?
+ respond_to?(:json_create)
+ end
+end
diff --git a/jni/ruby/ext/json/lib/json/ext.rb b/jni/ruby/ext/json/lib/json/ext.rb
new file mode 100644
index 0000000..c5f8131
--- /dev/null
+++ b/jni/ruby/ext/json/lib/json/ext.rb
@@ -0,0 +1,21 @@
+if ENV['SIMPLECOV_COVERAGE'].to_i == 1
+ require 'simplecov'
+ SimpleCov.start do
+ add_filter "/tests/"
+ end
+end
+require 'json/common'
+
+module JSON
+ # This module holds all the modules/classes that implement JSON's
+ # functionality as C extensions.
+ module Ext
+ require 'json/ext/parser'
+ require 'json/ext/generator'
+ $DEBUG and warn "Using Ext extension for JSON."
+ JSON.parser = Parser
+ JSON.generator = Generator
+ end
+
+ JSON_LOADED = true unless defined?(::JSON::JSON_LOADED)
+end
diff --git a/jni/ruby/ext/json/lib/json/generic_object.rb b/jni/ruby/ext/json/lib/json/generic_object.rb
new file mode 100644
index 0000000..8b8fd53
--- /dev/null
+++ b/jni/ruby/ext/json/lib/json/generic_object.rb
@@ -0,0 +1,70 @@
+require 'ostruct'
+
+module JSON
+ class GenericObject < OpenStruct
+ class << self
+ alias [] new
+
+ def json_creatable?
+ @json_creatable
+ end
+
+ attr_writer :json_creatable
+
+ def json_create(data)
+ data = data.dup
+ data.delete JSON.create_id
+ self[data]
+ end
+
+ def from_hash(object)
+ case
+ when object.respond_to?(:to_hash)
+ result = new
+ object.to_hash.each do |key, value|
+ result[key] = from_hash(value)
+ end
+ result
+ when object.respond_to?(:to_ary)
+ object.to_ary.map { |a| from_hash(a) }
+ else
+ object
+ end
+ end
+
+ def load(source, proc = nil, opts = {})
+ result = ::JSON.load(source, proc, opts.merge(:object_class => self))
+ result.nil? ? new : result
+ end
+
+ def dump(obj, *args)
+ ::JSON.dump(obj, *args)
+ end
+ end
+ self.json_creatable = false
+
+ def to_hash
+ table
+ end
+
+ def [](name)
+ table[name.to_sym]
+ end
+
+ def []=(name, value)
+ __send__ "#{name}=", value
+ end
+
+ def |(other)
+ self.class[other.to_hash.merge(to_hash)]
+ end
+
+ def as_json(*)
+ { JSON.create_id => self.class.name }.merge to_hash
+ end
+
+ def to_json(*a)
+ as_json.to_json(*a)
+ end
+ end
+end
diff --git a/jni/ruby/ext/json/lib/json/version.rb b/jni/ruby/ext/json/lib/json/version.rb
new file mode 100644
index 0000000..47cdcd6
--- /dev/null
+++ b/jni/ruby/ext/json/lib/json/version.rb
@@ -0,0 +1,8 @@
+module JSON
+ # JSON version
+ VERSION = '1.8.1'
+ VERSION_ARRAY = VERSION.split(/\./).map { |x| x.to_i } # :nodoc:
+ VERSION_MAJOR = VERSION_ARRAY[0] # :nodoc:
+ VERSION_MINOR = VERSION_ARRAY[1] # :nodoc:
+ VERSION_BUILD = VERSION_ARRAY[2] # :nodoc:
+end
diff --git a/jni/ruby/ext/json/parser/Makefile b/jni/ruby/ext/json/parser/Makefile
new file mode 100644
index 0000000..f718487
--- /dev/null
+++ b/jni/ruby/ext/json/parser/Makefile
@@ -0,0 +1,289 @@
+
+SHELL = /bin/sh
+
+# V=0 quiet, V=1 verbose. other values don't work.
+V = 0
+Q1 = $(V:1=)
+Q = $(Q1:0=@)
+ECHO1 = $(V:1=@:)
+ECHO = $(ECHO1:0=@echo)
+NULLCMD = :
+
+#### Start of system configuration section. ####
+top_srcdir = $(topdir)/.
+srcdir = $(top_srcdir)/ext/json/parser
+topdir = ../../..
+hdrdir = $(top_srcdir)/include
+arch_hdrdir = $(extout)/include/$(arch)
+PATH_SEPARATOR = :
+VPATH = $(srcdir):$(arch_hdrdir)/ruby:$(hdrdir)/ruby
+RUBYLIB =
+RUBYOPT = -
+prefix = $(DESTDIR)/usr/local
+rubysitearchprefix = $(rubylibprefix)/$(sitearch)
+rubyarchprefix = $(rubylibprefix)/$(arch)
+rubylibprefix = $(libdir)/$(RUBY_BASE_NAME)
+exec_prefix = $(prefix)
+vendorarchhdrdir = $(vendorhdrdir)/$(sitearch)
+sitearchhdrdir = $(sitehdrdir)/$(sitearch)
+rubyarchhdrdir = $(rubyhdrdir)/$(arch)
+vendorhdrdir = $(rubyhdrdir)/vendor_ruby
+sitehdrdir = $(rubyhdrdir)/site_ruby
+rubyhdrdir = $(includedir)/$(RUBY_VERSION_NAME)
+vendorarchdir = $(vendorlibdir)/$(sitearch)
+vendorlibdir = $(vendordir)/$(ruby_version)
+vendordir = $(rubylibprefix)/vendor_ruby
+sitearchdir = $(sitelibdir)/$(sitearch)
+sitelibdir = $(sitedir)/$(ruby_version)
+sitedir = $(rubylibprefix)/site_ruby
+rubyarchdir = $(rubylibdir)/$(arch)
+rubylibdir = $(rubylibprefix)/$(ruby_version)
+sitearchincludedir = $(includedir)/$(sitearch)
+archincludedir = $(includedir)/$(arch)
+sitearchlibdir = $(libdir)/$(sitearch)
+archlibdir = $(libdir)/$(arch)
+ridir = $(datarootdir)/$(RI_BASE_NAME)
+mandir = $(datarootdir)/man
+localedir = $(datarootdir)/locale
+libdir = $(exec_prefix)/lib
+psdir = $(docdir)
+pdfdir = $(docdir)
+dvidir = $(docdir)
+htmldir = $(docdir)
+infodir = $(datarootdir)/info
+docdir = $(datarootdir)/doc/$(PACKAGE)
+oldincludedir = $(DESTDIR)/usr/include
+includedir = $(prefix)/include
+localstatedir = $(prefix)/var
+sharedstatedir = $(prefix)/com
+sysconfdir = $(prefix)/etc
+datadir = $(datarootdir)
+datarootdir = $(prefix)/share
+libexecdir = $(exec_prefix)/libexec
+sbindir = $(exec_prefix)/sbin
+bindir = $(exec_prefix)/bin
+archdir = $(rubyarchdir)
+
+
+CC = gcc
+CXX = g++
+LIBRUBY = $(LIBRUBY_SO)
+LIBRUBY_A = lib$(RUBY_SO_NAME)-static.a
+LIBRUBYARG_SHARED = -Wl,-R$(libdir) -L$(libdir) -l$(RUBY_SO_NAME)
+LIBRUBYARG_STATIC = -Wl,-R$(libdir) -L$(libdir) -l$(RUBY_SO_NAME)-static
+empty =
+OUTFLAG = -o $(empty)
+COUTFLAG = -o $(empty)
+
+RUBY_EXTCONF_H = extconf.h
+cflags = $(optflags) $(debugflags) $(warnflags)
+optflags = -O3 -fno-fast-math
+debugflags = -ggdb3
+warnflags = -Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wunused-variable -Wpointer-arith -Wwrite-strings -Wdeclaration-after-statement -Wimplicit-function-declaration -Wdeprecated-declarations -Wno-packed-bitfield-compat
+CCDLFLAGS = -fPIC
+CFLAGS = $(CCDLFLAGS) $(cflags) -fPIC $(ARCH_FLAG)
+INCFLAGS = -I. -I$(arch_hdrdir) -I$(hdrdir) -I$(srcdir)
+DEFS =
+CPPFLAGS = -DRUBY_EXTCONF_H=\"$(RUBY_EXTCONF_H)\" $(DEFS) $(cppflags)
+CXXFLAGS = $(CCDLFLAGS) $(cxxflags) $(ARCH_FLAG)
+ldflags = -L. -fstack-protector -rdynamic -Wl,-export-dynamic
+dldflags =
+ARCH_FLAG =
+DLDFLAGS = $(ldflags) $(dldflags) $(ARCH_FLAG)
+LDSHARED = $(CC) -shared
+LDSHAREDXX = $(CXX) -shared
+AR = ar
+EXEEXT =
+
+RUBY_INSTALL_NAME = $(RUBY_BASE_NAME)
+RUBY_SO_NAME = ruby
+RUBYW_INSTALL_NAME =
+RUBY_VERSION_NAME = $(RUBY_BASE_NAME)-$(ruby_version)
+RUBYW_BASE_NAME = rubyw
+RUBY_BASE_NAME = ruby
+
+arch = x86_64-linux
+sitearch = $(arch)
+ruby_version = 2.2.0
+ruby = $(topdir)/miniruby -I'$(topdir)' -I'$(top_srcdir)/lib' -I'$(extout)/$(arch)' -I'$(extout)/common'
+RUBY = $(ruby)
+ruby_headers = $(hdrdir)/ruby.h $(hdrdir)/ruby/ruby.h $(hdrdir)/ruby/defines.h $(hdrdir)/ruby/missing.h $(hdrdir)/ruby/intern.h $(hdrdir)/ruby/st.h $(hdrdir)/ruby/subst.h $(arch_hdrdir)/ruby/config.h $(RUBY_EXTCONF_H)
+
+RM = rm -f
+RM_RF = $(RUBY) -run -e rm -- -rf
+RMDIRS = rmdir --ignore-fail-on-non-empty -p
+MAKEDIRS = /bin/mkdir -p
+INSTALL = /usr/bin/install -c
+INSTALL_PROG = $(INSTALL) -m 0755
+INSTALL_DATA = $(INSTALL) -m 644
+COPY = cp
+TOUCH = exit >
+
+#### End of system configuration section. ####
+
+preload =
+
+libpath = . $(topdir)
+LIBPATH = -L. -L$(topdir)
+DEFFILE =
+
+CLEANFILES = mkmf.log
+DISTCLEANFILES =
+DISTCLEANDIRS =
+
+extout = $(topdir)/.ext
+extout_prefix = $(extout)$(target_prefix)/
+target_prefix = /json/ext
+LOCAL_LIBS =
+LIBS = $(LIBRUBYARG_SHARED) -lpthread -lgmp -ldl -lcrypt -lm -lc
+ORIG_SRCS = parser.c
+SRCS = $(ORIG_SRCS)
+OBJS = parser.o
+HDRS = $(srcdir)/extconf.h $(srcdir)/parser.h
+TARGET = parser
+TARGET_NAME = parser
+TARGET_ENTRY = Init_$(TARGET_NAME)
+DLLIB = $(TARGET).so
+EXTSTATIC =
+STATIC_LIB = $(TARGET).a
+
+TIMESTAMP_DIR = $(extout)/.timestamp
+BINDIR = $(extout)/bin
+RUBYCOMMONDIR = $(extout)/common
+RUBYLIBDIR = $(RUBYCOMMONDIR)$(target_prefix)
+RUBYARCHDIR = $(extout)/$(arch)$(target_prefix)
+HDRDIR = $(extout)/include/ruby$(target_prefix)
+ARCHHDRDIR = $(extout)/include/$(arch)/ruby$(target_prefix)
+
+TARGET_SO = $(RUBYARCHDIR)/$(DLLIB)
+CLEANLIBS = $(RUBYARCHDIR)/$(TARGET).so
+CLEANOBJS = *.o *.bak
+
+all: install
+static: all
+.PHONY: all install static install-so install-rb
+.PHONY: clean clean-so clean-static clean-rb
+
+clean-static::
+clean-rb-default::
+clean-rb::
+clean-so::
+clean: clean-so clean-static clean-rb-default clean-rb
+ -$(Q)$(RM) $(CLEANLIBS) $(CLEANOBJS) $(CLEANFILES) .*.time
+
+distclean-rb-default::
+distclean-rb::
+distclean-so::
+distclean-static::
+distclean: clean distclean-so distclean-static distclean-rb-default distclean-rb
+ -$(Q)$(RM) Makefile $(RUBY_EXTCONF_H) conftest.* mkmf.log
+ -$(Q)$(RM) core ruby$(EXEEXT) *~ $(DISTCLEANFILES)
+ -$(Q)$(RMDIRS) $(DISTCLEANDIRS) 2> /dev/null || true
+
+realclean: distclean
+install: install-so install-rb
+
+install-so: $(RUBYARCHDIR)/$(DLLIB)
+clean-so::
+ -$(Q)$(RM) $(RUBYARCHDIR)/$(DLLIB)
+ -$(Q)$(RMDIRS) $(RUBYARCHDIR) 2> /dev/null || true
+clean-static::
+ -$(Q)$(RM) $(STATIC_LIB)
+install-rb: pre-install-rb install-rb-default
+install-rb-default: pre-install-rb-default
+pre-install-rb: Makefile
+pre-install-rb-default: Makefile
+pre-install-rb-default:
+ @$(NULLCMD)
+$(TIMESTAMP_DIR)/.RUBYARCHDIR.-.json.-.ext.time:
+ $(Q) $(MAKEDIRS) $(@D) $(RUBYARCHDIR)
+ $(Q) $(TOUCH) $@
+
+site-install: site-install-so site-install-rb
+site-install-so: install-so
+site-install-rb: install-rb
+
+.SUFFIXES: .c .m .cc .mm .cxx .cpp .o .S
+
+.cc.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<
+
+.cc.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -S $<
+
+.mm.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<
+
+.mm.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -S $<
+
+.cxx.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<
+
+.cxx.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -S $<
+
+.cpp.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<
+
+.cpp.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -S $<
+
+.c.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -c $<
+
+.c.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -S $<
+
+.m.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -c $<
+
+.m.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -S $<
+
+$(RUBYARCHDIR)/$(DLLIB): $(OBJS) Makefile $(TIMESTAMP_DIR)/.RUBYARCHDIR.-.json.-.ext.time
+ $(ECHO) linking shared-object json/ext/$(DLLIB)
+ -$(Q)$(RM) $(@)
+ $(Q) $(LDSHARED) -o $@ $(OBJS) $(LIBPATH) $(DLDFLAGS) $(LOCAL_LIBS) $(LIBS)
+
+$(STATIC_LIB): $(OBJS)
+ -$(Q)$(RM) $(@)
+ $(ECHO) linking static-library $(@)
+ $(Q) $(AR) cru $@ $(OBJS)
+ -$(Q)ranlib $(@) 2> /dev/null || true
+
+###
+$(OBJS): $(RUBY_EXTCONF_H)
+
+$(OBJS): $(ruby_headers)
+parser.o: parser.c parser.h $(srcdir)/../fbuffer/fbuffer.h
+
+# AUTOGENERATED DEPENDENCIES START
+parser.o: $(RUBY_EXTCONF_H)
+parser.o: $(arch_hdrdir)/ruby/config.h
+parser.o: $(hdrdir)/ruby/defines.h
+parser.o: $(hdrdir)/ruby/encoding.h
+parser.o: $(hdrdir)/ruby/intern.h
+parser.o: $(hdrdir)/ruby/missing.h
+parser.o: $(hdrdir)/ruby/oniguruma.h
+parser.o: $(hdrdir)/ruby/ruby.h
+parser.o: $(hdrdir)/ruby/st.h
+parser.o: $(hdrdir)/ruby/subst.h
+parser.o: $(top_srcdir)/ext/json/fbuffer/fbuffer.h
+parser.o: $(top_srcdir)/include/ruby.h
+parser.o: parser.c
+parser.o: parser.h
+parser.o: parser.rl
+# AUTOGENERATED DEPENDENCIES END
diff --git a/jni/ruby/ext/json/parser/depend b/jni/ruby/ext/json/parser/depend
new file mode 100644
index 0000000..bc5db06
--- /dev/null
+++ b/jni/ruby/ext/json/parser/depend
@@ -0,0 +1,20 @@
+$(OBJS): $(ruby_headers)
+parser.o: parser.c parser.h $(srcdir)/../fbuffer/fbuffer.h
+
+# AUTOGENERATED DEPENDENCIES START
+parser.o: $(RUBY_EXTCONF_H)
+parser.o: $(arch_hdrdir)/ruby/config.h
+parser.o: $(hdrdir)/ruby/defines.h
+parser.o: $(hdrdir)/ruby/encoding.h
+parser.o: $(hdrdir)/ruby/intern.h
+parser.o: $(hdrdir)/ruby/missing.h
+parser.o: $(hdrdir)/ruby/oniguruma.h
+parser.o: $(hdrdir)/ruby/ruby.h
+parser.o: $(hdrdir)/ruby/st.h
+parser.o: $(hdrdir)/ruby/subst.h
+parser.o: $(top_srcdir)/ext/json/fbuffer/fbuffer.h
+parser.o: $(top_srcdir)/include/ruby.h
+parser.o: parser.c
+parser.o: parser.h
+parser.o: parser.rl
+# AUTOGENERATED DEPENDENCIES END
diff --git a/jni/ruby/ext/json/parser/extconf.h b/jni/ruby/ext/json/parser/extconf.h
new file mode 100644
index 0000000..d81efe0
--- /dev/null
+++ b/jni/ruby/ext/json/parser/extconf.h
@@ -0,0 +1,4 @@
+#ifndef EXTCONF_H
+#define EXTCONF_H
+#define HAVE_RB_ENC_RAISE 1
+#endif
diff --git a/jni/ruby/ext/json/parser/extconf.rb b/jni/ruby/ext/json/parser/extconf.rb
new file mode 100644
index 0000000..2addc53
--- /dev/null
+++ b/jni/ruby/ext/json/parser/extconf.rb
@@ -0,0 +1,5 @@
+require 'mkmf'
+
+have_func("rb_enc_raise", "ruby.h")
+
+create_makefile 'json/ext/parser'
diff --git a/jni/ruby/ext/json/parser/parser.c b/jni/ruby/ext/json/parser/parser.c
new file mode 100644
index 0000000..8e168e1
--- /dev/null
+++ b/jni/ruby/ext/json/parser/parser.c
@@ -0,0 +1,2235 @@
+
+#line 1 "parser.rl"
+#include "../fbuffer/fbuffer.h"
+#include "parser.h"
+
+#if defined HAVE_RUBY_ENCODING_H
+# define EXC_ENCODING UTF_8,
+# ifndef HAVE_RB_ENC_RAISE
+static void
+enc_raise(rb_encoding *enc, VALUE exc, const char *fmt, ...)
+{
+ va_list args;
+ VALUE mesg;
+
+ va_start(args, fmt);
+ mesg = rb_enc_vsprintf(enc, fmt, args);
+ va_end(args);
+
+ rb_exc_raise(rb_exc_new3(exc, mesg));
+}
+# define rb_enc_raise enc_raise
+# endif
+#else
+# define EXC_ENCODING /* nothing */
+# define rb_enc_raise rb_raise
+#endif
+
+/* unicode */
+
+static const char digit_values[256] = {
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, -1,
+ -1, -1, -1, -1, -1, -1, 10, 11, 12, 13, 14, 15, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+ 10, 11, 12, 13, 14, 15, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1
+};
+
+static UTF32 unescape_unicode(const unsigned char *p)
+{
+ char b;
+ UTF32 result = 0;
+ b = digit_values[p[0]];
+ if (b < 0) return UNI_REPLACEMENT_CHAR;
+ result = (result << 4) | b;
+ b = digit_values[p[1]];
+ result = (result << 4) | b;
+ if (b < 0) return UNI_REPLACEMENT_CHAR;
+ b = digit_values[p[2]];
+ result = (result << 4) | b;
+ if (b < 0) return UNI_REPLACEMENT_CHAR;
+ b = digit_values[p[3]];
+ result = (result << 4) | b;
+ if (b < 0) return UNI_REPLACEMENT_CHAR;
+ return result;
+}
+
+static int convert_UTF32_to_UTF8(char *buf, UTF32 ch)
+{
+ int len = 1;
+ if (ch <= 0x7F) {
+ buf[0] = (char) ch;
+ } else if (ch <= 0x07FF) {
+ buf[0] = (char) ((ch >> 6) | 0xC0);
+ buf[1] = (char) ((ch & 0x3F) | 0x80);
+ len++;
+ } else if (ch <= 0xFFFF) {
+ buf[0] = (char) ((ch >> 12) | 0xE0);
+ buf[1] = (char) (((ch >> 6) & 0x3F) | 0x80);
+ buf[2] = (char) ((ch & 0x3F) | 0x80);
+ len += 2;
+ } else if (ch <= 0x1fffff) {
+ buf[0] =(char) ((ch >> 18) | 0xF0);
+ buf[1] =(char) (((ch >> 12) & 0x3F) | 0x80);
+ buf[2] =(char) (((ch >> 6) & 0x3F) | 0x80);
+ buf[3] =(char) ((ch & 0x3F) | 0x80);
+ len += 3;
+ } else {
+ buf[0] = '?';
+ }
+ return len;
+}
+
+#ifdef HAVE_RUBY_ENCODING_H
+static rb_encoding *UTF_8, *UTF_16BE, *UTF_16LE, *UTF_32BE, *UTF_32LE;
+#else
+static ID i_iconv;
+#endif
+
+static VALUE mJSON, mExt, cParser, eParserError, eNestingError;
+static VALUE CNaN, CInfinity, CMinusInfinity;
+
+static ID i_json_creatable_p, i_json_create, i_create_id, i_create_additions,
+ i_chr, i_max_nesting, i_allow_nan, i_symbolize_names, i_quirks_mode,
+ i_object_class, i_array_class, i_key_p, i_deep_const_get, i_match,
+ i_match_string, i_aset, i_aref, i_leftshift;
+
+
+#line 130 "parser.rl"
+
+
+
+#line 112 "parser.c"
+enum {JSON_object_start = 1};
+enum {JSON_object_first_final = 27};
+enum {JSON_object_error = 0};
+
+enum {JSON_object_en_main = 1};
+
+
+#line 171 "parser.rl"
+
+
+static char *JSON_parse_object(JSON_Parser *json, char *p, char *pe, VALUE *result)
+{
+ int cs = EVIL;
+ VALUE last_name = Qnil;
+ VALUE object_class = json->object_class;
+
+ if (json->max_nesting && json->current_nesting > json->max_nesting) {
+ rb_raise(eNestingError, "nesting of %d is too deep", json->current_nesting);
+ }
+
+ *result = NIL_P(object_class) ? rb_hash_new() : rb_class_new_instance(0, 0, object_class);
+
+
+#line 136 "parser.c"
+ {
+ cs = JSON_object_start;
+ }
+
+#line 186 "parser.rl"
+
+#line 143 "parser.c"
+ {
+ if ( p == pe )
+ goto _test_eof;
+ switch ( cs )
+ {
+case 1:
+ if ( (*p) == 123 )
+ goto st2;
+ goto st0;
+st0:
+cs = 0;
+ goto _out;
+st2:
+ if ( ++p == pe )
+ goto _test_eof2;
+case 2:
+ switch( (*p) ) {
+ case 13: goto st2;
+ case 32: goto st2;
+ case 34: goto tr2;
+ case 47: goto st23;
+ case 125: goto tr4;
+ }
+ if ( 9 <= (*p) && (*p) <= 10 )
+ goto st2;
+ goto st0;
+tr2:
+#line 153 "parser.rl"
+ {
+ char *np;
+ json->parsing_name = 1;
+ np = JSON_parse_string(json, p, pe, &last_name);
+ json->parsing_name = 0;
+ if (np == NULL) { p--; {p++; cs = 3; goto _out;} } else {p = (( np))-1;}
+ }
+ goto st3;
+st3:
+ if ( ++p == pe )
+ goto _test_eof3;
+case 3:
+#line 184 "parser.c"
+ switch( (*p) ) {
+ case 13: goto st3;
+ case 32: goto st3;
+ case 47: goto st4;
+ case 58: goto st8;
+ }
+ if ( 9 <= (*p) && (*p) <= 10 )
+ goto st3;
+ goto st0;
+st4:
+ if ( ++p == pe )
+ goto _test_eof4;
+case 4:
+ switch( (*p) ) {
+ case 42: goto st5;
+ case 47: goto st7;
+ }
+ goto st0;
+st5:
+ if ( ++p == pe )
+ goto _test_eof5;
+case 5:
+ if ( (*p) == 42 )
+ goto st6;
+ goto st5;
+st6:
+ if ( ++p == pe )
+ goto _test_eof6;
+case 6:
+ switch( (*p) ) {
+ case 42: goto st6;
+ case 47: goto st3;
+ }
+ goto st5;
+st7:
+ if ( ++p == pe )
+ goto _test_eof7;
+case 7:
+ if ( (*p) == 10 )
+ goto st3;
+ goto st7;
+st8:
+ if ( ++p == pe )
+ goto _test_eof8;
+case 8:
+ switch( (*p) ) {
+ case 13: goto st8;
+ case 32: goto st8;
+ case 34: goto tr11;
+ case 45: goto tr11;
+ case 47: goto st19;
+ case 73: goto tr11;
+ case 78: goto tr11;
+ case 91: goto tr11;
+ case 102: goto tr11;
+ case 110: goto tr11;
+ case 116: goto tr11;
+ case 123: goto tr11;
+ }
+ if ( (*p) > 10 ) {
+ if ( 48 <= (*p) && (*p) <= 57 )
+ goto tr11;
+ } else if ( (*p) >= 9 )
+ goto st8;
+ goto st0;
+tr11:
+#line 138 "parser.rl"
+ {
+ VALUE v = Qnil;
+ char *np = JSON_parse_value(json, p, pe, &v);
+ if (np == NULL) {
+ p--; {p++; cs = 9; goto _out;}
+ } else {
+ if (NIL_P(json->object_class)) {
+ rb_hash_aset(*result, last_name, v);
+ } else {
+ rb_funcall(*result, i_aset, 2, last_name, v);
+ }
+ {p = (( np))-1;}
+ }
+ }
+ goto st9;
+st9:
+ if ( ++p == pe )
+ goto _test_eof9;
+case 9:
+#line 271 "parser.c"
+ switch( (*p) ) {
+ case 13: goto st9;
+ case 32: goto st9;
+ case 44: goto st10;
+ case 47: goto st15;
+ case 125: goto tr4;
+ }
+ if ( 9 <= (*p) && (*p) <= 10 )
+ goto st9;
+ goto st0;
+st10:
+ if ( ++p == pe )
+ goto _test_eof10;
+case 10:
+ switch( (*p) ) {
+ case 13: goto st10;
+ case 32: goto st10;
+ case 34: goto tr2;
+ case 47: goto st11;
+ }
+ if ( 9 <= (*p) && (*p) <= 10 )
+ goto st10;
+ goto st0;
+st11:
+ if ( ++p == pe )
+ goto _test_eof11;
+case 11:
+ switch( (*p) ) {
+ case 42: goto st12;
+ case 47: goto st14;
+ }
+ goto st0;
+st12:
+ if ( ++p == pe )
+ goto _test_eof12;
+case 12:
+ if ( (*p) == 42 )
+ goto st13;
+ goto st12;
+st13:
+ if ( ++p == pe )
+ goto _test_eof13;
+case 13:
+ switch( (*p) ) {
+ case 42: goto st13;
+ case 47: goto st10;
+ }
+ goto st12;
+st14:
+ if ( ++p == pe )
+ goto _test_eof14;
+case 14:
+ if ( (*p) == 10 )
+ goto st10;
+ goto st14;
+st15:
+ if ( ++p == pe )
+ goto _test_eof15;
+case 15:
+ switch( (*p) ) {
+ case 42: goto st16;
+ case 47: goto st18;
+ }
+ goto st0;
+st16:
+ if ( ++p == pe )
+ goto _test_eof16;
+case 16:
+ if ( (*p) == 42 )
+ goto st17;
+ goto st16;
+st17:
+ if ( ++p == pe )
+ goto _test_eof17;
+case 17:
+ switch( (*p) ) {
+ case 42: goto st17;
+ case 47: goto st9;
+ }
+ goto st16;
+st18:
+ if ( ++p == pe )
+ goto _test_eof18;
+case 18:
+ if ( (*p) == 10 )
+ goto st9;
+ goto st18;
+tr4:
+#line 161 "parser.rl"
+ { p--; {p++; cs = 27; goto _out;} }
+ goto st27;
+st27:
+ if ( ++p == pe )
+ goto _test_eof27;
+case 27:
+#line 367 "parser.c"
+ goto st0;
+st19:
+ if ( ++p == pe )
+ goto _test_eof19;
+case 19:
+ switch( (*p) ) {
+ case 42: goto st20;
+ case 47: goto st22;
+ }
+ goto st0;
+st20:
+ if ( ++p == pe )
+ goto _test_eof20;
+case 20:
+ if ( (*p) == 42 )
+ goto st21;
+ goto st20;
+st21:
+ if ( ++p == pe )
+ goto _test_eof21;
+case 21:
+ switch( (*p) ) {
+ case 42: goto st21;
+ case 47: goto st8;
+ }
+ goto st20;
+st22:
+ if ( ++p == pe )
+ goto _test_eof22;
+case 22:
+ if ( (*p) == 10 )
+ goto st8;
+ goto st22;
+st23:
+ if ( ++p == pe )
+ goto _test_eof23;
+case 23:
+ switch( (*p) ) {
+ case 42: goto st24;
+ case 47: goto st26;
+ }
+ goto st0;
+st24:
+ if ( ++p == pe )
+ goto _test_eof24;
+case 24:
+ if ( (*p) == 42 )
+ goto st25;
+ goto st24;
+st25:
+ if ( ++p == pe )
+ goto _test_eof25;
+case 25:
+ switch( (*p) ) {
+ case 42: goto st25;
+ case 47: goto st2;
+ }
+ goto st24;
+st26:
+ if ( ++p == pe )
+ goto _test_eof26;
+case 26:
+ if ( (*p) == 10 )
+ goto st2;
+ goto st26;
+ }
+ _test_eof2: cs = 2; goto _test_eof;
+ _test_eof3: cs = 3; goto _test_eof;
+ _test_eof4: cs = 4; goto _test_eof;
+ _test_eof5: cs = 5; goto _test_eof;
+ _test_eof6: cs = 6; goto _test_eof;
+ _test_eof7: cs = 7; goto _test_eof;
+ _test_eof8: cs = 8; goto _test_eof;
+ _test_eof9: cs = 9; goto _test_eof;
+ _test_eof10: cs = 10; goto _test_eof;
+ _test_eof11: cs = 11; goto _test_eof;
+ _test_eof12: cs = 12; goto _test_eof;
+ _test_eof13: cs = 13; goto _test_eof;
+ _test_eof14: cs = 14; goto _test_eof;
+ _test_eof15: cs = 15; goto _test_eof;
+ _test_eof16: cs = 16; goto _test_eof;
+ _test_eof17: cs = 17; goto _test_eof;
+ _test_eof18: cs = 18; goto _test_eof;
+ _test_eof27: cs = 27; goto _test_eof;
+ _test_eof19: cs = 19; goto _test_eof;
+ _test_eof20: cs = 20; goto _test_eof;
+ _test_eof21: cs = 21; goto _test_eof;
+ _test_eof22: cs = 22; goto _test_eof;
+ _test_eof23: cs = 23; goto _test_eof;
+ _test_eof24: cs = 24; goto _test_eof;
+ _test_eof25: cs = 25; goto _test_eof;
+ _test_eof26: cs = 26; goto _test_eof;
+
+ _test_eof: {}
+ _out: {}
+ }
+
+#line 187 "parser.rl"
+
+ if (cs >= JSON_object_first_final) {
+ if (json->create_additions) {
+ VALUE klassname;
+ if (NIL_P(json->object_class)) {
+ klassname = rb_hash_aref(*result, json->create_id);
+ } else {
+ klassname = rb_funcall(*result, i_aref, 1, json->create_id);
+ }
+ if (!NIL_P(klassname)) {
+ VALUE klass = rb_funcall(mJSON, i_deep_const_get, 1, klassname);
+ if (RTEST(rb_funcall(klass, i_json_creatable_p, 0))) {
+ *result = rb_funcall(klass, i_json_create, 1, *result);
+ }
+ }
+ }
+ return p + 1;
+ } else {
+ return NULL;
+ }
+}
+
+
+
+#line 490 "parser.c"
+enum {JSON_value_start = 1};
+enum {JSON_value_first_final = 21};
+enum {JSON_value_error = 0};
+
+enum {JSON_value_en_main = 1};
+
+
+#line 291 "parser.rl"
+
+
+static char *JSON_parse_value(JSON_Parser *json, char *p, char *pe, VALUE *result)
+{
+ int cs = EVIL;
+
+
+#line 506 "parser.c"
+ {
+ cs = JSON_value_start;
+ }
+
+#line 298 "parser.rl"
+
+#line 513 "parser.c"
+ {
+ if ( p == pe )
+ goto _test_eof;
+ switch ( cs )
+ {
+case 1:
+ switch( (*p) ) {
+ case 34: goto tr0;
+ case 45: goto tr2;
+ case 73: goto st2;
+ case 78: goto st9;
+ case 91: goto tr5;
+ case 102: goto st11;
+ case 110: goto st15;
+ case 116: goto st18;
+ case 123: goto tr9;
+ }
+ if ( 48 <= (*p) && (*p) <= 57 )
+ goto tr2;
+ goto st0;
+st0:
+cs = 0;
+ goto _out;
+tr0:
+#line 239 "parser.rl"
+ {
+ char *np = JSON_parse_string(json, p, pe, result);
+ if (np == NULL) { p--; {p++; cs = 21; goto _out;} } else {p = (( np))-1;}
+ }
+ goto st21;
+tr2:
+#line 244 "parser.rl"
+ {
+ char *np;
+ if(pe > p + 9 - json->quirks_mode && !strncmp(MinusInfinity, p, 9)) {
+ if (json->allow_nan) {
+ *result = CMinusInfinity;
+ {p = (( p + 10))-1;}
+ p--; {p++; cs = 21; goto _out;}
+ } else {
+ rb_enc_raise(EXC_ENCODING eParserError, "%u: unexpected token at '%s'", __LINE__, p);
+ }
+ }
+ np = JSON_parse_float(json, p, pe, result);
+ if (np != NULL) {p = (( np))-1;}
+ np = JSON_parse_integer(json, p, pe, result);
+ if (np != NULL) {p = (( np))-1;}
+ p--; {p++; cs = 21; goto _out;}
+ }
+ goto st21;
+tr5:
+#line 262 "parser.rl"
+ {
+ char *np;
+ json->current_nesting++;
+ np = JSON_parse_array(json, p, pe, result);
+ json->current_nesting--;
+ if (np == NULL) { p--; {p++; cs = 21; goto _out;} } else {p = (( np))-1;}
+ }
+ goto st21;
+tr9:
+#line 270 "parser.rl"
+ {
+ char *np;
+ json->current_nesting++;
+ np = JSON_parse_object(json, p, pe, result);
+ json->current_nesting--;
+ if (np == NULL) { p--; {p++; cs = 21; goto _out;} } else {p = (( np))-1;}
+ }
+ goto st21;
+tr16:
+#line 232 "parser.rl"
+ {
+ if (json->allow_nan) {
+ *result = CInfinity;
+ } else {
+ rb_enc_raise(EXC_ENCODING eParserError, "%u: unexpected token at '%s'", __LINE__, p - 8);
+ }
+ }
+ goto st21;
+tr18:
+#line 225 "parser.rl"
+ {
+ if (json->allow_nan) {
+ *result = CNaN;
+ } else {
+ rb_enc_raise(EXC_ENCODING eParserError, "%u: unexpected token at '%s'", __LINE__, p - 2);
+ }
+ }
+ goto st21;
+tr22:
+#line 219 "parser.rl"
+ {
+ *result = Qfalse;
+ }
+ goto st21;
+tr25:
+#line 216 "parser.rl"
+ {
+ *result = Qnil;
+ }
+ goto st21;
+tr28:
+#line 222 "parser.rl"
+ {
+ *result = Qtrue;
+ }
+ goto st21;
+st21:
+ if ( ++p == pe )
+ goto _test_eof21;
+case 21:
+#line 278 "parser.rl"
+ { p--; {p++; cs = 21; goto _out;} }
+#line 628 "parser.c"
+ goto st0;
+st2:
+ if ( ++p == pe )
+ goto _test_eof2;
+case 2:
+ if ( (*p) == 110 )
+ goto st3;
+ goto st0;
+st3:
+ if ( ++p == pe )
+ goto _test_eof3;
+case 3:
+ if ( (*p) == 102 )
+ goto st4;
+ goto st0;
+st4:
+ if ( ++p == pe )
+ goto _test_eof4;
+case 4:
+ if ( (*p) == 105 )
+ goto st5;
+ goto st0;
+st5:
+ if ( ++p == pe )
+ goto _test_eof5;
+case 5:
+ if ( (*p) == 110 )
+ goto st6;
+ goto st0;
+st6:
+ if ( ++p == pe )
+ goto _test_eof6;
+case 6:
+ if ( (*p) == 105 )
+ goto st7;
+ goto st0;
+st7:
+ if ( ++p == pe )
+ goto _test_eof7;
+case 7:
+ if ( (*p) == 116 )
+ goto st8;
+ goto st0;
+st8:
+ if ( ++p == pe )
+ goto _test_eof8;
+case 8:
+ if ( (*p) == 121 )
+ goto tr16;
+ goto st0;
+st9:
+ if ( ++p == pe )
+ goto _test_eof9;
+case 9:
+ if ( (*p) == 97 )
+ goto st10;
+ goto st0;
+st10:
+ if ( ++p == pe )
+ goto _test_eof10;
+case 10:
+ if ( (*p) == 78 )
+ goto tr18;
+ goto st0;
+st11:
+ if ( ++p == pe )
+ goto _test_eof11;
+case 11:
+ if ( (*p) == 97 )
+ goto st12;
+ goto st0;
+st12:
+ if ( ++p == pe )
+ goto _test_eof12;
+case 12:
+ if ( (*p) == 108 )
+ goto st13;
+ goto st0;
+st13:
+ if ( ++p == pe )
+ goto _test_eof13;
+case 13:
+ if ( (*p) == 115 )
+ goto st14;
+ goto st0;
+st14:
+ if ( ++p == pe )
+ goto _test_eof14;
+case 14:
+ if ( (*p) == 101 )
+ goto tr22;
+ goto st0;
+st15:
+ if ( ++p == pe )
+ goto _test_eof15;
+case 15:
+ if ( (*p) == 117 )
+ goto st16;
+ goto st0;
+st16:
+ if ( ++p == pe )
+ goto _test_eof16;
+case 16:
+ if ( (*p) == 108 )
+ goto st17;
+ goto st0;
+st17:
+ if ( ++p == pe )
+ goto _test_eof17;
+case 17:
+ if ( (*p) == 108 )
+ goto tr25;
+ goto st0;
+st18:
+ if ( ++p == pe )
+ goto _test_eof18;
+case 18:
+ if ( (*p) == 114 )
+ goto st19;
+ goto st0;
+st19:
+ if ( ++p == pe )
+ goto _test_eof19;
+case 19:
+ if ( (*p) == 117 )
+ goto st20;
+ goto st0;
+st20:
+ if ( ++p == pe )
+ goto _test_eof20;
+case 20:
+ if ( (*p) == 101 )
+ goto tr28;
+ goto st0;
+ }
+ _test_eof21: cs = 21; goto _test_eof;
+ _test_eof2: cs = 2; goto _test_eof;
+ _test_eof3: cs = 3; goto _test_eof;
+ _test_eof4: cs = 4; goto _test_eof;
+ _test_eof5: cs = 5; goto _test_eof;
+ _test_eof6: cs = 6; goto _test_eof;
+ _test_eof7: cs = 7; goto _test_eof;
+ _test_eof8: cs = 8; goto _test_eof;
+ _test_eof9: cs = 9; goto _test_eof;
+ _test_eof10: cs = 10; goto _test_eof;
+ _test_eof11: cs = 11; goto _test_eof;
+ _test_eof12: cs = 12; goto _test_eof;
+ _test_eof13: cs = 13; goto _test_eof;
+ _test_eof14: cs = 14; goto _test_eof;
+ _test_eof15: cs = 15; goto _test_eof;
+ _test_eof16: cs = 16; goto _test_eof;
+ _test_eof17: cs = 17; goto _test_eof;
+ _test_eof18: cs = 18; goto _test_eof;
+ _test_eof19: cs = 19; goto _test_eof;
+ _test_eof20: cs = 20; goto _test_eof;
+
+ _test_eof: {}
+ _out: {}
+ }
+
+#line 299 "parser.rl"
+
+ if (cs >= JSON_value_first_final) {
+ return p;
+ } else {
+ return NULL;
+ }
+}
+
+
+#line 799 "parser.c"
+enum {JSON_integer_start = 1};
+enum {JSON_integer_first_final = 3};
+enum {JSON_integer_error = 0};
+
+enum {JSON_integer_en_main = 1};
+
+
+#line 315 "parser.rl"
+
+
+static char *JSON_parse_integer(JSON_Parser *json, char *p, char *pe, VALUE *result)
+{
+ int cs = EVIL;
+
+
+#line 815 "parser.c"
+ {
+ cs = JSON_integer_start;
+ }
+
+#line 322 "parser.rl"
+ json->memo = p;
+
+#line 823 "parser.c"
+ {
+ if ( p == pe )
+ goto _test_eof;
+ switch ( cs )
+ {
+case 1:
+ switch( (*p) ) {
+ case 45: goto st2;
+ case 48: goto st3;
+ }
+ if ( 49 <= (*p) && (*p) <= 57 )
+ goto st5;
+ goto st0;
+st0:
+cs = 0;
+ goto _out;
+st2:
+ if ( ++p == pe )
+ goto _test_eof2;
+case 2:
+ if ( (*p) == 48 )
+ goto st3;
+ if ( 49 <= (*p) && (*p) <= 57 )
+ goto st5;
+ goto st0;
+st3:
+ if ( ++p == pe )
+ goto _test_eof3;
+case 3:
+ if ( 48 <= (*p) && (*p) <= 57 )
+ goto st0;
+ goto tr4;
+tr4:
+#line 312 "parser.rl"
+ { p--; {p++; cs = 4; goto _out;} }
+ goto st4;
+st4:
+ if ( ++p == pe )
+ goto _test_eof4;
+case 4:
+#line 864 "parser.c"
+ goto st0;
+st5:
+ if ( ++p == pe )
+ goto _test_eof5;
+case 5:
+ if ( 48 <= (*p) && (*p) <= 57 )
+ goto st5;
+ goto tr4;
+ }
+ _test_eof2: cs = 2; goto _test_eof;
+ _test_eof3: cs = 3; goto _test_eof;
+ _test_eof4: cs = 4; goto _test_eof;
+ _test_eof5: cs = 5; goto _test_eof;
+
+ _test_eof: {}
+ _out: {}
+ }
+
+#line 324 "parser.rl"
+
+ if (cs >= JSON_integer_first_final) {
+ long len = p - json->memo;
+ fbuffer_clear(json->fbuffer);
+ fbuffer_append(json->fbuffer, json->memo, len);
+ fbuffer_append_char(json->fbuffer, '\0');
+ *result = rb_cstr2inum(FBUFFER_PTR(json->fbuffer), 10);
+ return p + 1;
+ } else {
+ return NULL;
+ }
+}
+
+
+#line 898 "parser.c"
+enum {JSON_float_start = 1};
+enum {JSON_float_first_final = 8};
+enum {JSON_float_error = 0};
+
+enum {JSON_float_en_main = 1};
+
+
+#line 349 "parser.rl"
+
+
+static char *JSON_parse_float(JSON_Parser *json, char *p, char *pe, VALUE *result)
+{
+ int cs = EVIL;
+
+
+#line 914 "parser.c"
+ {
+ cs = JSON_float_start;
+ }
+
+#line 356 "parser.rl"
+ json->memo = p;
+
+#line 922 "parser.c"
+ {
+ if ( p == pe )
+ goto _test_eof;
+ switch ( cs )
+ {
+case 1:
+ switch( (*p) ) {
+ case 45: goto st2;
+ case 48: goto st3;
+ }
+ if ( 49 <= (*p) && (*p) <= 57 )
+ goto st7;
+ goto st0;
+st0:
+cs = 0;
+ goto _out;
+st2:
+ if ( ++p == pe )
+ goto _test_eof2;
+case 2:
+ if ( (*p) == 48 )
+ goto st3;
+ if ( 49 <= (*p) && (*p) <= 57 )
+ goto st7;
+ goto st0;
+st3:
+ if ( ++p == pe )
+ goto _test_eof3;
+case 3:
+ switch( (*p) ) {
+ case 46: goto st4;
+ case 69: goto st5;
+ case 101: goto st5;
+ }
+ goto st0;
+st4:
+ if ( ++p == pe )
+ goto _test_eof4;
+case 4:
+ if ( 48 <= (*p) && (*p) <= 57 )
+ goto st8;
+ goto st0;
+st8:
+ if ( ++p == pe )
+ goto _test_eof8;
+case 8:
+ switch( (*p) ) {
+ case 69: goto st5;
+ case 101: goto st5;
+ }
+ if ( (*p) > 46 ) {
+ if ( 48 <= (*p) && (*p) <= 57 )
+ goto st8;
+ } else if ( (*p) >= 45 )
+ goto st0;
+ goto tr9;
+tr9:
+#line 343 "parser.rl"
+ { p--; {p++; cs = 9; goto _out;} }
+ goto st9;
+st9:
+ if ( ++p == pe )
+ goto _test_eof9;
+case 9:
+#line 987 "parser.c"
+ goto st0;
+st5:
+ if ( ++p == pe )
+ goto _test_eof5;
+case 5:
+ switch( (*p) ) {
+ case 43: goto st6;
+ case 45: goto st6;
+ }
+ if ( 48 <= (*p) && (*p) <= 57 )
+ goto st10;
+ goto st0;
+st6:
+ if ( ++p == pe )
+ goto _test_eof6;
+case 6:
+ if ( 48 <= (*p) && (*p) <= 57 )
+ goto st10;
+ goto st0;
+st10:
+ if ( ++p == pe )
+ goto _test_eof10;
+case 10:
+ switch( (*p) ) {
+ case 69: goto st0;
+ case 101: goto st0;
+ }
+ if ( (*p) > 46 ) {
+ if ( 48 <= (*p) && (*p) <= 57 )
+ goto st10;
+ } else if ( (*p) >= 45 )
+ goto st0;
+ goto tr9;
+st7:
+ if ( ++p == pe )
+ goto _test_eof7;
+case 7:
+ switch( (*p) ) {
+ case 46: goto st4;
+ case 69: goto st5;
+ case 101: goto st5;
+ }
+ if ( 48 <= (*p) && (*p) <= 57 )
+ goto st7;
+ goto st0;
+ }
+ _test_eof2: cs = 2; goto _test_eof;
+ _test_eof3: cs = 3; goto _test_eof;
+ _test_eof4: cs = 4; goto _test_eof;
+ _test_eof8: cs = 8; goto _test_eof;
+ _test_eof9: cs = 9; goto _test_eof;
+ _test_eof5: cs = 5; goto _test_eof;
+ _test_eof6: cs = 6; goto _test_eof;
+ _test_eof10: cs = 10; goto _test_eof;
+ _test_eof7: cs = 7; goto _test_eof;
+
+ _test_eof: {}
+ _out: {}
+ }
+
+#line 358 "parser.rl"
+
+ if (cs >= JSON_float_first_final) {
+ long len = p - json->memo;
+ fbuffer_clear(json->fbuffer);
+ fbuffer_append(json->fbuffer, json->memo, len);
+ fbuffer_append_char(json->fbuffer, '\0');
+ *result = rb_float_new(rb_cstr_to_dbl(FBUFFER_PTR(json->fbuffer), 1));
+ return p + 1;
+ } else {
+ return NULL;
+ }
+}
+
+
+
+#line 1064 "parser.c"
+enum {JSON_array_start = 1};
+enum {JSON_array_first_final = 17};
+enum {JSON_array_error = 0};
+
+enum {JSON_array_en_main = 1};
+
+
+#line 401 "parser.rl"
+
+
+static char *JSON_parse_array(JSON_Parser *json, char *p, char *pe, VALUE *result)
+{
+ int cs = EVIL;
+ VALUE array_class = json->array_class;
+
+ if (json->max_nesting && json->current_nesting > json->max_nesting) {
+ rb_raise(eNestingError, "nesting of %d is too deep", json->current_nesting);
+ }
+ *result = NIL_P(array_class) ? rb_ary_new() : rb_class_new_instance(0, 0, array_class);
+
+
+#line 1086 "parser.c"
+ {
+ cs = JSON_array_start;
+ }
+
+#line 414 "parser.rl"
+
+#line 1093 "parser.c"
+ {
+ if ( p == pe )
+ goto _test_eof;
+ switch ( cs )
+ {
+case 1:
+ if ( (*p) == 91 )
+ goto st2;
+ goto st0;
+st0:
+cs = 0;
+ goto _out;
+st2:
+ if ( ++p == pe )
+ goto _test_eof2;
+case 2:
+ switch( (*p) ) {
+ case 13: goto st2;
+ case 32: goto st2;
+ case 34: goto tr2;
+ case 45: goto tr2;
+ case 47: goto st13;
+ case 73: goto tr2;
+ case 78: goto tr2;
+ case 91: goto tr2;
+ case 93: goto tr4;
+ case 102: goto tr2;
+ case 110: goto tr2;
+ case 116: goto tr2;
+ case 123: goto tr2;
+ }
+ if ( (*p) > 10 ) {
+ if ( 48 <= (*p) && (*p) <= 57 )
+ goto tr2;
+ } else if ( (*p) >= 9 )
+ goto st2;
+ goto st0;
+tr2:
+#line 378 "parser.rl"
+ {
+ VALUE v = Qnil;
+ char *np = JSON_parse_value(json, p, pe, &v);
+ if (np == NULL) {
+ p--; {p++; cs = 3; goto _out;}
+ } else {
+ if (NIL_P(json->array_class)) {
+ rb_ary_push(*result, v);
+ } else {
+ rb_funcall(*result, i_leftshift, 1, v);
+ }
+ {p = (( np))-1;}
+ }
+ }
+ goto st3;
+st3:
+ if ( ++p == pe )
+ goto _test_eof3;
+case 3:
+#line 1152 "parser.c"
+ switch( (*p) ) {
+ case 13: goto st3;
+ case 32: goto st3;
+ case 44: goto st4;
+ case 47: goto st9;
+ case 93: goto tr4;
+ }
+ if ( 9 <= (*p) && (*p) <= 10 )
+ goto st3;
+ goto st0;
+st4:
+ if ( ++p == pe )
+ goto _test_eof4;
+case 4:
+ switch( (*p) ) {
+ case 13: goto st4;
+ case 32: goto st4;
+ case 34: goto tr2;
+ case 45: goto tr2;
+ case 47: goto st5;
+ case 73: goto tr2;
+ case 78: goto tr2;
+ case 91: goto tr2;
+ case 102: goto tr2;
+ case 110: goto tr2;
+ case 116: goto tr2;
+ case 123: goto tr2;
+ }
+ if ( (*p) > 10 ) {
+ if ( 48 <= (*p) && (*p) <= 57 )
+ goto tr2;
+ } else if ( (*p) >= 9 )
+ goto st4;
+ goto st0;
+st5:
+ if ( ++p == pe )
+ goto _test_eof5;
+case 5:
+ switch( (*p) ) {
+ case 42: goto st6;
+ case 47: goto st8;
+ }
+ goto st0;
+st6:
+ if ( ++p == pe )
+ goto _test_eof6;
+case 6:
+ if ( (*p) == 42 )
+ goto st7;
+ goto st6;
+st7:
+ if ( ++p == pe )
+ goto _test_eof7;
+case 7:
+ switch( (*p) ) {
+ case 42: goto st7;
+ case 47: goto st4;
+ }
+ goto st6;
+st8:
+ if ( ++p == pe )
+ goto _test_eof8;
+case 8:
+ if ( (*p) == 10 )
+ goto st4;
+ goto st8;
+st9:
+ if ( ++p == pe )
+ goto _test_eof9;
+case 9:
+ switch( (*p) ) {
+ case 42: goto st10;
+ case 47: goto st12;
+ }
+ goto st0;
+st10:
+ if ( ++p == pe )
+ goto _test_eof10;
+case 10:
+ if ( (*p) == 42 )
+ goto st11;
+ goto st10;
+st11:
+ if ( ++p == pe )
+ goto _test_eof11;
+case 11:
+ switch( (*p) ) {
+ case 42: goto st11;
+ case 47: goto st3;
+ }
+ goto st10;
+st12:
+ if ( ++p == pe )
+ goto _test_eof12;
+case 12:
+ if ( (*p) == 10 )
+ goto st3;
+ goto st12;
+tr4:
+#line 393 "parser.rl"
+ { p--; {p++; cs = 17; goto _out;} }
+ goto st17;
+st17:
+ if ( ++p == pe )
+ goto _test_eof17;
+case 17:
+#line 1259 "parser.c"
+ goto st0;
+st13:
+ if ( ++p == pe )
+ goto _test_eof13;
+case 13:
+ switch( (*p) ) {
+ case 42: goto st14;
+ case 47: goto st16;
+ }
+ goto st0;
+st14:
+ if ( ++p == pe )
+ goto _test_eof14;
+case 14:
+ if ( (*p) == 42 )
+ goto st15;
+ goto st14;
+st15:
+ if ( ++p == pe )
+ goto _test_eof15;
+case 15:
+ switch( (*p) ) {
+ case 42: goto st15;
+ case 47: goto st2;
+ }
+ goto st14;
+st16:
+ if ( ++p == pe )
+ goto _test_eof16;
+case 16:
+ if ( (*p) == 10 )
+ goto st2;
+ goto st16;
+ }
+ _test_eof2: cs = 2; goto _test_eof;
+ _test_eof3: cs = 3; goto _test_eof;
+ _test_eof4: cs = 4; goto _test_eof;
+ _test_eof5: cs = 5; goto _test_eof;
+ _test_eof6: cs = 6; goto _test_eof;
+ _test_eof7: cs = 7; goto _test_eof;
+ _test_eof8: cs = 8; goto _test_eof;
+ _test_eof9: cs = 9; goto _test_eof;
+ _test_eof10: cs = 10; goto _test_eof;
+ _test_eof11: cs = 11; goto _test_eof;
+ _test_eof12: cs = 12; goto _test_eof;
+ _test_eof17: cs = 17; goto _test_eof;
+ _test_eof13: cs = 13; goto _test_eof;
+ _test_eof14: cs = 14; goto _test_eof;
+ _test_eof15: cs = 15; goto _test_eof;
+ _test_eof16: cs = 16; goto _test_eof;
+
+ _test_eof: {}
+ _out: {}
+ }
+
+#line 415 "parser.rl"
+
+ if(cs >= JSON_array_first_final) {
+ return p + 1;
+ } else {
+ rb_enc_raise(EXC_ENCODING eParserError, "%u: unexpected token at '%s'", __LINE__, p);
+ return NULL;
+ }
+}
+
+static VALUE json_string_unescape(VALUE result, char *string, char *stringEnd)
+{
+ char *p = string, *pe = string, *unescape;
+ int unescape_len;
+ char buf[4];
+
+ while (pe < stringEnd) {
+ if (*pe == '\\') {
+ unescape = (char *) "?";
+ unescape_len = 1;
+ if (pe > p) rb_str_buf_cat(result, p, pe - p);
+ switch (*++pe) {
+ case 'n':
+ unescape = (char *) "\n";
+ break;
+ case 'r':
+ unescape = (char *) "\r";
+ break;
+ case 't':
+ unescape = (char *) "\t";
+ break;
+ case '"':
+ unescape = (char *) "\"";
+ break;
+ case '\\':
+ unescape = (char *) "\\";
+ break;
+ case 'b':
+ unescape = (char *) "\b";
+ break;
+ case 'f':
+ unescape = (char *) "\f";
+ break;
+ case 'u':
+ if (pe > stringEnd - 4) {
+ return Qnil;
+ } else {
+ UTF32 ch = unescape_unicode((unsigned char *) ++pe);
+ pe += 3;
+ if (UNI_SUR_HIGH_START == (ch & 0xFC00)) {
+ pe++;
+ if (pe > stringEnd - 6) return Qnil;
+ if (pe[0] == '\\' && pe[1] == 'u') {
+ UTF32 sur = unescape_unicode((unsigned char *) pe + 2);
+ ch = (((ch & 0x3F) << 10) | ((((ch >> 6) & 0xF) + 1) << 16)
+ | (sur & 0x3FF));
+ pe += 5;
+ } else {
+ unescape = (char *) "?";
+ break;
+ }
+ }
+ unescape_len = convert_UTF32_to_UTF8(buf, ch);
+ unescape = buf;
+ }
+ break;
+ default:
+ p = pe;
+ continue;
+ }
+ rb_str_buf_cat(result, unescape, unescape_len);
+ p = ++pe;
+ } else {
+ pe++;
+ }
+ }
+ rb_str_buf_cat(result, p, pe - p);
+ return result;
+}
+
+
+#line 1396 "parser.c"
+enum {JSON_string_start = 1};
+enum {JSON_string_first_final = 8};
+enum {JSON_string_error = 0};
+
+enum {JSON_string_en_main = 1};
+
+
+#line 514 "parser.rl"
+
+
+static int
+match_i(VALUE regexp, VALUE klass, VALUE memo)
+{
+ if (regexp == Qundef) return ST_STOP;
+ if (RTEST(rb_funcall(klass, i_json_creatable_p, 0)) &&
+ RTEST(rb_funcall(regexp, i_match, 1, rb_ary_entry(memo, 0)))) {
+ rb_ary_push(memo, klass);
+ return ST_STOP;
+ }
+ return ST_CONTINUE;
+}
+
+static char *JSON_parse_string(JSON_Parser *json, char *p, char *pe, VALUE *result)
+{
+ int cs = EVIL;
+ VALUE match_string;
+
+ *result = rb_str_buf_new(0);
+
+#line 1426 "parser.c"
+ {
+ cs = JSON_string_start;
+ }
+
+#line 535 "parser.rl"
+ json->memo = p;
+
+#line 1434 "parser.c"
+ {
+ if ( p == pe )
+ goto _test_eof;
+ switch ( cs )
+ {
+case 1:
+ if ( (*p) == 34 )
+ goto st2;
+ goto st0;
+st0:
+cs = 0;
+ goto _out;
+st2:
+ if ( ++p == pe )
+ goto _test_eof2;
+case 2:
+ switch( (*p) ) {
+ case 34: goto tr2;
+ case 92: goto st3;
+ }
+ if ( 0 <= (*p) && (*p) <= 31 )
+ goto st0;
+ goto st2;
+tr2:
+#line 500 "parser.rl"
+ {
+ *result = json_string_unescape(*result, json->memo + 1, p);
+ if (NIL_P(*result)) {
+ p--;
+ {p++; cs = 8; goto _out;}
+ } else {
+ FORCE_UTF8(*result);
+ {p = (( p + 1))-1;}
+ }
+ }
+#line 511 "parser.rl"
+ { p--; {p++; cs = 8; goto _out;} }
+ goto st8;
+st8:
+ if ( ++p == pe )
+ goto _test_eof8;
+case 8:
+#line 1477 "parser.c"
+ goto st0;
+st3:
+ if ( ++p == pe )
+ goto _test_eof3;
+case 3:
+ if ( (*p) == 117 )
+ goto st4;
+ if ( 0 <= (*p) && (*p) <= 31 )
+ goto st0;
+ goto st2;
+st4:
+ if ( ++p == pe )
+ goto _test_eof4;
+case 4:
+ if ( (*p) < 65 ) {
+ if ( 48 <= (*p) && (*p) <= 57 )
+ goto st5;
+ } else if ( (*p) > 70 ) {
+ if ( 97 <= (*p) && (*p) <= 102 )
+ goto st5;
+ } else
+ goto st5;
+ goto st0;
+st5:
+ if ( ++p == pe )
+ goto _test_eof5;
+case 5:
+ if ( (*p) < 65 ) {
+ if ( 48 <= (*p) && (*p) <= 57 )
+ goto st6;
+ } else if ( (*p) > 70 ) {
+ if ( 97 <= (*p) && (*p) <= 102 )
+ goto st6;
+ } else
+ goto st6;
+ goto st0;
+st6:
+ if ( ++p == pe )
+ goto _test_eof6;
+case 6:
+ if ( (*p) < 65 ) {
+ if ( 48 <= (*p) && (*p) <= 57 )
+ goto st7;
+ } else if ( (*p) > 70 ) {
+ if ( 97 <= (*p) && (*p) <= 102 )
+ goto st7;
+ } else
+ goto st7;
+ goto st0;
+st7:
+ if ( ++p == pe )
+ goto _test_eof7;
+case 7:
+ if ( (*p) < 65 ) {
+ if ( 48 <= (*p) && (*p) <= 57 )
+ goto st2;
+ } else if ( (*p) > 70 ) {
+ if ( 97 <= (*p) && (*p) <= 102 )
+ goto st2;
+ } else
+ goto st2;
+ goto st0;
+ }
+ _test_eof2: cs = 2; goto _test_eof;
+ _test_eof8: cs = 8; goto _test_eof;
+ _test_eof3: cs = 3; goto _test_eof;
+ _test_eof4: cs = 4; goto _test_eof;
+ _test_eof5: cs = 5; goto _test_eof;
+ _test_eof6: cs = 6; goto _test_eof;
+ _test_eof7: cs = 7; goto _test_eof;
+
+ _test_eof: {}
+ _out: {}
+ }
+
+#line 537 "parser.rl"
+
+ if (json->create_additions && RTEST(match_string = json->match_string)) {
+ VALUE klass;
+ VALUE memo = rb_ary_new2(2);
+ rb_ary_push(memo, *result);
+ rb_hash_foreach(match_string, match_i, memo);
+ klass = rb_ary_entry(memo, 1);
+ if (RTEST(klass)) {
+ *result = rb_funcall(klass, i_json_create, 1, *result);
+ }
+ }
+
+ if (json->symbolize_names && json->parsing_name) {
+ *result = rb_str_intern(*result);
+ }
+ if (cs >= JSON_string_first_final) {
+ return p + 1;
+ } else {
+ return NULL;
+ }
+}
+
+/*
+ * Document-class: JSON::Ext::Parser
+ *
+ * This is the JSON parser implemented as a C extension. It can be configured
+ * to be used by setting
+ *
+ * JSON.parser = JSON::Ext::Parser
+ *
+ * with the method parser= in JSON.
+ *
+ */
+
+static VALUE convert_encoding(VALUE source)
+{
+ char *ptr = RSTRING_PTR(source);
+ long len = RSTRING_LEN(source);
+ if (len < 2) {
+ rb_raise(eParserError, "A JSON text must at least contain two octets!");
+ }
+#ifdef HAVE_RUBY_ENCODING_H
+ {
+ rb_encoding *enc = rb_enc_get(source);
+ if (enc == rb_ascii8bit_encoding()) {
+ if (len >= 4 && ptr[0] == 0 && ptr[1] == 0 && ptr[2] == 0) {
+ source = rb_str_conv_enc(source, UTF_32BE, rb_utf8_encoding());
+ } else if (len >= 4 && ptr[0] == 0 && ptr[2] == 0) {
+ source = rb_str_conv_enc(source, UTF_16BE, rb_utf8_encoding());
+ } else if (len >= 4 && ptr[1] == 0 && ptr[2] == 0 && ptr[3] == 0) {
+ source = rb_str_conv_enc(source, UTF_32LE, rb_utf8_encoding());
+ } else if (len >= 4 && ptr[1] == 0 && ptr[3] == 0) {
+ source = rb_str_conv_enc(source, UTF_16LE, rb_utf8_encoding());
+ } else {
+ source = rb_str_dup(source);
+ FORCE_UTF8(source);
+ }
+ } else {
+ source = rb_str_conv_enc(source, NULL, rb_utf8_encoding());
+ }
+ }
+#else
+ if (len >= 4 && ptr[0] == 0 && ptr[1] == 0 && ptr[2] == 0) {
+ source = rb_funcall(mJSON, i_iconv, 3, rb_str_new2("utf-8"), rb_str_new2("utf-32be"), source);
+ } else if (len >= 4 && ptr[0] == 0 && ptr[2] == 0) {
+ source = rb_funcall(mJSON, i_iconv, 3, rb_str_new2("utf-8"), rb_str_new2("utf-16be"), source);
+ } else if (len >= 4 && ptr[1] == 0 && ptr[2] == 0 && ptr[3] == 0) {
+ source = rb_funcall(mJSON, i_iconv, 3, rb_str_new2("utf-8"), rb_str_new2("utf-32le"), source);
+ } else if (len >= 4 && ptr[1] == 0 && ptr[3] == 0) {
+ source = rb_funcall(mJSON, i_iconv, 3, rb_str_new2("utf-8"), rb_str_new2("utf-16le"), source);
+ }
+#endif
+ return source;
+}
+
+/*
+ * call-seq: new(source, opts => {})
+ *
+ * Creates a new JSON::Ext::Parser instance for the string _source_.
+ *
+ * Creates a new JSON::Ext::Parser instance for the string _source_.
+ *
+ * It will be configured by the _opts_ hash. _opts_ can have the following
+ * keys:
+ *
+ * _opts_ can have the following keys:
+ * * *max_nesting*: The maximum depth of nesting allowed in the parsed data
+ * structures. Disable depth checking with :max_nesting => false|nil|0, it
+ * defaults to 100.
+ * * *allow_nan*: If set to true, allow NaN, Infinity and -Infinity in
+ * defiance of RFC 4627 to be parsed by the Parser. This option defaults to
+ * false.
+ * * *symbolize_names*: If set to true, returns symbols for the names
+ * (keys) in a JSON object. Otherwise strings are returned, which is also
+ * the default.
+ * * *create_additions*: If set to false, the Parser doesn't create
+ * additions even if a matchin class and create_id was found. This option
+ * defaults to true.
+ * * *object_class*: Defaults to Hash
+ * * *array_class*: Defaults to Array
+ */
+static VALUE cParser_initialize(int argc, VALUE *argv, VALUE self)
+{
+ VALUE source, opts;
+ GET_PARSER_INIT;
+
+ if (json->Vsource) {
+ rb_raise(rb_eTypeError, "already initialized instance");
+ }
+ rb_scan_args(argc, argv, "11", &source, &opts);
+ if (!NIL_P(opts)) {
+ opts = rb_convert_type(opts, T_HASH, "Hash", "to_hash");
+ if (NIL_P(opts)) {
+ rb_raise(rb_eArgError, "opts needs to be like a hash");
+ } else {
+ VALUE tmp = ID2SYM(i_max_nesting);
+ if (option_given_p(opts, tmp)) {
+ VALUE max_nesting = rb_hash_aref(opts, tmp);
+ if (RTEST(max_nesting)) {
+ Check_Type(max_nesting, T_FIXNUM);
+ json->max_nesting = FIX2INT(max_nesting);
+ } else {
+ json->max_nesting = 0;
+ }
+ } else {
+ json->max_nesting = 100;
+ }
+ tmp = ID2SYM(i_allow_nan);
+ if (option_given_p(opts, tmp)) {
+ json->allow_nan = RTEST(rb_hash_aref(opts, tmp)) ? 1 : 0;
+ } else {
+ json->allow_nan = 0;
+ }
+ tmp = ID2SYM(i_symbolize_names);
+ if (option_given_p(opts, tmp)) {
+ json->symbolize_names = RTEST(rb_hash_aref(opts, tmp)) ? 1 : 0;
+ } else {
+ json->symbolize_names = 0;
+ }
+ tmp = ID2SYM(i_quirks_mode);
+ if (option_given_p(opts, tmp)) {
+ VALUE quirks_mode = rb_hash_aref(opts, tmp);
+ json->quirks_mode = RTEST(quirks_mode) ? 1 : 0;
+ } else {
+ json->quirks_mode = 0;
+ }
+ tmp = ID2SYM(i_create_additions);
+ if (option_given_p(opts, tmp)) {
+ json->create_additions = RTEST(rb_hash_aref(opts, tmp));
+ } else {
+ json->create_additions = 0;
+ }
+ tmp = ID2SYM(i_create_id);
+ if (option_given_p(opts, tmp)) {
+ json->create_id = rb_hash_aref(opts, tmp);
+ } else {
+ json->create_id = rb_funcall(mJSON, i_create_id, 0);
+ }
+ tmp = ID2SYM(i_object_class);
+ if (option_given_p(opts, tmp)) {
+ json->object_class = rb_hash_aref(opts, tmp);
+ } else {
+ json->object_class = Qnil;
+ }
+ tmp = ID2SYM(i_array_class);
+ if (option_given_p(opts, tmp)) {
+ json->array_class = rb_hash_aref(opts, tmp);
+ } else {
+ json->array_class = Qnil;
+ }
+ tmp = ID2SYM(i_match_string);
+ if (option_given_p(opts, tmp)) {
+ VALUE match_string = rb_hash_aref(opts, tmp);
+ json->match_string = RTEST(match_string) ? match_string : Qnil;
+ } else {
+ json->match_string = Qnil;
+ }
+ }
+ } else {
+ json->max_nesting = 100;
+ json->allow_nan = 0;
+ json->create_additions = 1;
+ json->create_id = rb_funcall(mJSON, i_create_id, 0);
+ json->object_class = Qnil;
+ json->array_class = Qnil;
+ }
+ StringValue(source);
+ if (!json->quirks_mode) {
+ source = convert_encoding(source);
+ }
+ json->current_nesting = 0;
+ json->len = RSTRING_LEN(source);
+ json->source = RSTRING_PTR(source);;
+ json->Vsource = source;
+ return self;
+}
+
+
+#line 1752 "parser.c"
+enum {JSON_start = 1};
+enum {JSON_first_final = 10};
+enum {JSON_error = 0};
+
+enum {JSON_en_main = 1};
+
+
+#line 759 "parser.rl"
+
+
+static VALUE cParser_parse_strict(VALUE self)
+{
+ char *p, *pe;
+ int cs = EVIL;
+ VALUE result = Qnil;
+ GET_PARSER;
+
+
+#line 1771 "parser.c"
+ {
+ cs = JSON_start;
+ }
+
+#line 769 "parser.rl"
+ p = json->source;
+ pe = p + json->len;
+
+#line 1780 "parser.c"
+ {
+ if ( p == pe )
+ goto _test_eof;
+ switch ( cs )
+ {
+st1:
+ if ( ++p == pe )
+ goto _test_eof1;
+case 1:
+ switch( (*p) ) {
+ case 13: goto st1;
+ case 32: goto st1;
+ case 47: goto st2;
+ case 91: goto tr3;
+ case 123: goto tr4;
+ }
+ if ( 9 <= (*p) && (*p) <= 10 )
+ goto st1;
+ goto st0;
+st0:
+cs = 0;
+ goto _out;
+st2:
+ if ( ++p == pe )
+ goto _test_eof2;
+case 2:
+ switch( (*p) ) {
+ case 42: goto st3;
+ case 47: goto st5;
+ }
+ goto st0;
+st3:
+ if ( ++p == pe )
+ goto _test_eof3;
+case 3:
+ if ( (*p) == 42 )
+ goto st4;
+ goto st3;
+st4:
+ if ( ++p == pe )
+ goto _test_eof4;
+case 4:
+ switch( (*p) ) {
+ case 42: goto st4;
+ case 47: goto st1;
+ }
+ goto st3;
+st5:
+ if ( ++p == pe )
+ goto _test_eof5;
+case 5:
+ if ( (*p) == 10 )
+ goto st1;
+ goto st5;
+tr3:
+#line 748 "parser.rl"
+ {
+ char *np;
+ json->current_nesting = 1;
+ np = JSON_parse_array(json, p, pe, &result);
+ if (np == NULL) { p--; {p++; cs = 10; goto _out;} } else {p = (( np))-1;}
+ }
+ goto st10;
+tr4:
+#line 741 "parser.rl"
+ {
+ char *np;
+ json->current_nesting = 1;
+ np = JSON_parse_object(json, p, pe, &result);
+ if (np == NULL) { p--; {p++; cs = 10; goto _out;} } else {p = (( np))-1;}
+ }
+ goto st10;
+st10:
+ if ( ++p == pe )
+ goto _test_eof10;
+case 10:
+#line 1857 "parser.c"
+ switch( (*p) ) {
+ case 13: goto st10;
+ case 32: goto st10;
+ case 47: goto st6;
+ }
+ if ( 9 <= (*p) && (*p) <= 10 )
+ goto st10;
+ goto st0;
+st6:
+ if ( ++p == pe )
+ goto _test_eof6;
+case 6:
+ switch( (*p) ) {
+ case 42: goto st7;
+ case 47: goto st9;
+ }
+ goto st0;
+st7:
+ if ( ++p == pe )
+ goto _test_eof7;
+case 7:
+ if ( (*p) == 42 )
+ goto st8;
+ goto st7;
+st8:
+ if ( ++p == pe )
+ goto _test_eof8;
+case 8:
+ switch( (*p) ) {
+ case 42: goto st8;
+ case 47: goto st10;
+ }
+ goto st7;
+st9:
+ if ( ++p == pe )
+ goto _test_eof9;
+case 9:
+ if ( (*p) == 10 )
+ goto st10;
+ goto st9;
+ }
+ _test_eof1: cs = 1; goto _test_eof;
+ _test_eof2: cs = 2; goto _test_eof;
+ _test_eof3: cs = 3; goto _test_eof;
+ _test_eof4: cs = 4; goto _test_eof;
+ _test_eof5: cs = 5; goto _test_eof;
+ _test_eof10: cs = 10; goto _test_eof;
+ _test_eof6: cs = 6; goto _test_eof;
+ _test_eof7: cs = 7; goto _test_eof;
+ _test_eof8: cs = 8; goto _test_eof;
+ _test_eof9: cs = 9; goto _test_eof;
+
+ _test_eof: {}
+ _out: {}
+ }
+
+#line 772 "parser.rl"
+
+ if (cs >= JSON_first_final && p == pe) {
+ return result;
+ } else {
+ rb_enc_raise(EXC_ENCODING eParserError, "%u: unexpected token at '%s'", __LINE__, p);
+ return Qnil;
+ }
+}
+
+
+
+#line 1926 "parser.c"
+enum {JSON_quirks_mode_start = 1};
+enum {JSON_quirks_mode_first_final = 10};
+enum {JSON_quirks_mode_error = 0};
+
+enum {JSON_quirks_mode_en_main = 1};
+
+
+#line 797 "parser.rl"
+
+
+static VALUE cParser_parse_quirks_mode(VALUE self)
+{
+ char *p, *pe;
+ int cs = EVIL;
+ VALUE result = Qnil;
+ GET_PARSER;
+
+
+#line 1945 "parser.c"
+ {
+ cs = JSON_quirks_mode_start;
+ }
+
+#line 807 "parser.rl"
+ p = json->source;
+ pe = p + json->len;
+
+#line 1954 "parser.c"
+ {
+ if ( p == pe )
+ goto _test_eof;
+ switch ( cs )
+ {
+st1:
+ if ( ++p == pe )
+ goto _test_eof1;
+case 1:
+ switch( (*p) ) {
+ case 13: goto st1;
+ case 32: goto st1;
+ case 34: goto tr2;
+ case 45: goto tr2;
+ case 47: goto st6;
+ case 73: goto tr2;
+ case 78: goto tr2;
+ case 91: goto tr2;
+ case 102: goto tr2;
+ case 110: goto tr2;
+ case 116: goto tr2;
+ case 123: goto tr2;
+ }
+ if ( (*p) > 10 ) {
+ if ( 48 <= (*p) && (*p) <= 57 )
+ goto tr2;
+ } else if ( (*p) >= 9 )
+ goto st1;
+ goto st0;
+st0:
+cs = 0;
+ goto _out;
+tr2:
+#line 789 "parser.rl"
+ {
+ char *np = JSON_parse_value(json, p, pe, &result);
+ if (np == NULL) { p--; {p++; cs = 10; goto _out;} } else {p = (( np))-1;}
+ }
+ goto st10;
+st10:
+ if ( ++p == pe )
+ goto _test_eof10;
+case 10:
+#line 1998 "parser.c"
+ switch( (*p) ) {
+ case 13: goto st10;
+ case 32: goto st10;
+ case 47: goto st2;
+ }
+ if ( 9 <= (*p) && (*p) <= 10 )
+ goto st10;
+ goto st0;
+st2:
+ if ( ++p == pe )
+ goto _test_eof2;
+case 2:
+ switch( (*p) ) {
+ case 42: goto st3;
+ case 47: goto st5;
+ }
+ goto st0;
+st3:
+ if ( ++p == pe )
+ goto _test_eof3;
+case 3:
+ if ( (*p) == 42 )
+ goto st4;
+ goto st3;
+st4:
+ if ( ++p == pe )
+ goto _test_eof4;
+case 4:
+ switch( (*p) ) {
+ case 42: goto st4;
+ case 47: goto st10;
+ }
+ goto st3;
+st5:
+ if ( ++p == pe )
+ goto _test_eof5;
+case 5:
+ if ( (*p) == 10 )
+ goto st10;
+ goto st5;
+st6:
+ if ( ++p == pe )
+ goto _test_eof6;
+case 6:
+ switch( (*p) ) {
+ case 42: goto st7;
+ case 47: goto st9;
+ }
+ goto st0;
+st7:
+ if ( ++p == pe )
+ goto _test_eof7;
+case 7:
+ if ( (*p) == 42 )
+ goto st8;
+ goto st7;
+st8:
+ if ( ++p == pe )
+ goto _test_eof8;
+case 8:
+ switch( (*p) ) {
+ case 42: goto st8;
+ case 47: goto st1;
+ }
+ goto st7;
+st9:
+ if ( ++p == pe )
+ goto _test_eof9;
+case 9:
+ if ( (*p) == 10 )
+ goto st1;
+ goto st9;
+ }
+ _test_eof1: cs = 1; goto _test_eof;
+ _test_eof10: cs = 10; goto _test_eof;
+ _test_eof2: cs = 2; goto _test_eof;
+ _test_eof3: cs = 3; goto _test_eof;
+ _test_eof4: cs = 4; goto _test_eof;
+ _test_eof5: cs = 5; goto _test_eof;
+ _test_eof6: cs = 6; goto _test_eof;
+ _test_eof7: cs = 7; goto _test_eof;
+ _test_eof8: cs = 8; goto _test_eof;
+ _test_eof9: cs = 9; goto _test_eof;
+
+ _test_eof: {}
+ _out: {}
+ }
+
+#line 810 "parser.rl"
+
+ if (cs >= JSON_quirks_mode_first_final && p == pe) {
+ return result;
+ } else {
+ rb_enc_raise(EXC_ENCODING eParserError, "%u: unexpected token at '%s'", __LINE__, p);
+ return Qnil;
+ }
+}
+
+/*
+ * call-seq: parse()
+ *
+ * Parses the current JSON text _source_ and returns the complete data
+ * structure as a result.
+ */
+static VALUE cParser_parse(VALUE self)
+{
+ GET_PARSER;
+
+ if (json->quirks_mode) {
+ return cParser_parse_quirks_mode(self);
+ } else {
+ return cParser_parse_strict(self);
+ }
+}
+
+
+static JSON_Parser *JSON_allocate(void)
+{
+ JSON_Parser *json = ALLOC(JSON_Parser);
+ MEMZERO(json, JSON_Parser, 1);
+ json->fbuffer = fbuffer_alloc(0);
+ return json;
+}
+
+static void JSON_mark(void *ptr)
+{
+ JSON_Parser *json = ptr;
+ rb_gc_mark_maybe(json->Vsource);
+ rb_gc_mark_maybe(json->create_id);
+ rb_gc_mark_maybe(json->object_class);
+ rb_gc_mark_maybe(json->array_class);
+ rb_gc_mark_maybe(json->match_string);
+}
+
+static void JSON_free(void *ptr)
+{
+ JSON_Parser *json = ptr;
+ fbuffer_free(json->fbuffer);
+ ruby_xfree(json);
+}
+
+static size_t JSON_memsize(const void *ptr)
+{
+ const JSON_Parser *json = ptr;
+ return sizeof(*json) + FBUFFER_CAPA(json->fbuffer);
+}
+
+static const rb_data_type_t JSON_Parser_type = {
+ "JSON/Parser",
+ {JSON_mark, JSON_free, JSON_memsize,},
+ 0, 0,
+ RUBY_TYPED_FREE_IMMEDIATELY,
+};
+
+static VALUE cJSON_parser_s_allocate(VALUE klass)
+{
+ JSON_Parser *json = JSON_allocate();
+ return TypedData_Wrap_Struct(klass, &JSON_Parser_type, json);
+}
+
+/*
+ * call-seq: source()
+ *
+ * Returns a copy of the current _source_ string, that was used to construct
+ * this Parser.
+ */
+static VALUE cParser_source(VALUE self)
+{
+ GET_PARSER;
+ return rb_str_dup(json->Vsource);
+}
+
+/*
+ * call-seq: quirks_mode?()
+ *
+ * Returns a true, if this parser is in quirks_mode, false otherwise.
+ */
+static VALUE cParser_quirks_mode_p(VALUE self)
+{
+ GET_PARSER;
+ return json->quirks_mode ? Qtrue : Qfalse;
+}
+
+
+void Init_parser(void)
+{
+ rb_require("json/common");
+ mJSON = rb_define_module("JSON");
+ mExt = rb_define_module_under(mJSON, "Ext");
+ cParser = rb_define_class_under(mExt, "Parser", rb_cObject);
+ eParserError = rb_path2class("JSON::ParserError");
+ eNestingError = rb_path2class("JSON::NestingError");
+ rb_define_alloc_func(cParser, cJSON_parser_s_allocate);
+ rb_define_method(cParser, "initialize", cParser_initialize, -1);
+ rb_define_method(cParser, "parse", cParser_parse, 0);
+ rb_define_method(cParser, "source", cParser_source, 0);
+ rb_define_method(cParser, "quirks_mode?", cParser_quirks_mode_p, 0);
+
+ CNaN = rb_const_get(mJSON, rb_intern("NaN"));
+ CInfinity = rb_const_get(mJSON, rb_intern("Infinity"));
+ CMinusInfinity = rb_const_get(mJSON, rb_intern("MinusInfinity"));
+
+ i_json_creatable_p = rb_intern("json_creatable?");
+ i_json_create = rb_intern("json_create");
+ i_create_id = rb_intern("create_id");
+ i_create_additions = rb_intern("create_additions");
+ i_chr = rb_intern("chr");
+ i_max_nesting = rb_intern("max_nesting");
+ i_allow_nan = rb_intern("allow_nan");
+ i_symbolize_names = rb_intern("symbolize_names");
+ i_quirks_mode = rb_intern("quirks_mode");
+ i_object_class = rb_intern("object_class");
+ i_array_class = rb_intern("array_class");
+ i_match = rb_intern("match");
+ i_match_string = rb_intern("match_string");
+ i_key_p = rb_intern("key?");
+ i_deep_const_get = rb_intern("deep_const_get");
+ i_aset = rb_intern("[]=");
+ i_aref = rb_intern("[]");
+ i_leftshift = rb_intern("<<");
+#ifdef HAVE_RUBY_ENCODING_H
+ UTF_8 = rb_utf8_encoding();
+ UTF_16BE = rb_enc_find("utf-16be");
+ UTF_16LE = rb_enc_find("utf-16le");
+ UTF_32BE = rb_enc_find("utf-32be");
+ UTF_32LE = rb_enc_find("utf-32le");
+#else
+ i_iconv = rb_intern("iconv");
+#endif
+}
+
+/*
+ * Local variables:
+ * mode: c
+ * c-file-style: ruby
+ * indent-tabs-mode: nil
+ * End:
+ */
diff --git a/jni/ruby/ext/json/parser/parser.h b/jni/ruby/ext/json/parser/parser.h
new file mode 100644
index 0000000..45afbc2
--- /dev/null
+++ b/jni/ruby/ext/json/parser/parser.h
@@ -0,0 +1,78 @@
+#ifndef _PARSER_H_
+#define _PARSER_H_
+
+#include "ruby.h"
+
+#ifndef HAVE_RUBY_RE_H
+#include "re.h"
+#endif
+
+#ifdef HAVE_RUBY_ST_H
+#include "ruby/st.h"
+#else
+#include "st.h"
+#endif
+
+#define option_given_p(opts, key) RTEST(rb_funcall(opts, i_key_p, 1, key))
+
+/* unicode */
+
+typedef unsigned long UTF32; /* at least 32 bits */
+typedef unsigned short UTF16; /* at least 16 bits */
+typedef unsigned char UTF8; /* typically 8 bits */
+
+#define UNI_REPLACEMENT_CHAR (UTF32)0x0000FFFD
+#define UNI_SUR_HIGH_START (UTF32)0xD800
+#define UNI_SUR_HIGH_END (UTF32)0xDBFF
+#define UNI_SUR_LOW_START (UTF32)0xDC00
+#define UNI_SUR_LOW_END (UTF32)0xDFFF
+
+typedef struct JSON_ParserStruct {
+ VALUE Vsource;
+ char *source;
+ long len;
+ char *memo;
+ VALUE create_id;
+ int max_nesting;
+ int current_nesting;
+ int allow_nan;
+ int parsing_name;
+ int symbolize_names;
+ int quirks_mode;
+ VALUE object_class;
+ VALUE array_class;
+ int create_additions;
+ VALUE match_string;
+ FBuffer *fbuffer;
+} JSON_Parser;
+
+#define GET_PARSER \
+ GET_PARSER_INIT; \
+ if (!json->Vsource) rb_raise(rb_eTypeError, "uninitialized instance")
+#define GET_PARSER_INIT \
+ JSON_Parser *json; \
+ TypedData_Get_Struct(self, JSON_Parser, &JSON_Parser_type, json)
+
+#define MinusInfinity "-Infinity"
+#define EVIL 0x666
+
+static UTF32 unescape_unicode(const unsigned char *p);
+static int convert_UTF32_to_UTF8(char *buf, UTF32 ch);
+static char *JSON_parse_object(JSON_Parser *json, char *p, char *pe, VALUE *result);
+static char *JSON_parse_value(JSON_Parser *json, char *p, char *pe, VALUE *result);
+static char *JSON_parse_integer(JSON_Parser *json, char *p, char *pe, VALUE *result);
+static char *JSON_parse_float(JSON_Parser *json, char *p, char *pe, VALUE *result);
+static char *JSON_parse_array(JSON_Parser *json, char *p, char *pe, VALUE *result);
+static VALUE json_string_unescape(VALUE result, char *string, char *stringEnd);
+static char *JSON_parse_string(JSON_Parser *json, char *p, char *pe, VALUE *result);
+static VALUE convert_encoding(VALUE source);
+static VALUE cParser_initialize(int argc, VALUE *argv, VALUE self);
+static VALUE cParser_parse(VALUE self);
+static JSON_Parser *JSON_allocate(void);
+static void JSON_mark(void *json);
+static void JSON_free(void *json);
+static VALUE cJSON_parser_s_allocate(VALUE klass);
+static VALUE cParser_source(VALUE self);
+static const rb_data_type_t JSON_Parser_type;
+
+#endif
diff --git a/jni/ruby/ext/json/parser/parser.rl b/jni/ruby/ext/json/parser/parser.rl
new file mode 100644
index 0000000..54da92b
--- /dev/null
+++ b/jni/ruby/ext/json/parser/parser.rl
@@ -0,0 +1,958 @@
+#include "../fbuffer/fbuffer.h"
+#include "parser.h"
+
+#if defined HAVE_RUBY_ENCODING_H
+# define EXC_ENCODING UTF_8,
+# ifndef HAVE_RB_ENC_RAISE
+static void
+enc_raise(rb_encoding *enc, VALUE exc, const char *fmt, ...)
+{
+ va_list args;
+ VALUE mesg;
+
+ va_start(args, fmt);
+ mesg = rb_enc_vsprintf(enc, fmt, args);
+ va_end(args);
+
+ rb_exc_raise(rb_exc_new3(exc, mesg));
+}
+# define rb_enc_raise enc_raise
+# endif
+#else
+# define EXC_ENCODING /* nothing */
+# define rb_enc_raise rb_raise
+#endif
+
+/* unicode */
+
+static const char digit_values[256] = {
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, -1,
+ -1, -1, -1, -1, -1, -1, 10, 11, 12, 13, 14, 15, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+ 10, 11, 12, 13, 14, 15, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1
+};
+
+static UTF32 unescape_unicode(const unsigned char *p)
+{
+ char b;
+ UTF32 result = 0;
+ b = digit_values[p[0]];
+ if (b < 0) return UNI_REPLACEMENT_CHAR;
+ result = (result << 4) | b;
+ b = digit_values[p[1]];
+ result = (result << 4) | b;
+ if (b < 0) return UNI_REPLACEMENT_CHAR;
+ b = digit_values[p[2]];
+ result = (result << 4) | b;
+ if (b < 0) return UNI_REPLACEMENT_CHAR;
+ b = digit_values[p[3]];
+ result = (result << 4) | b;
+ if (b < 0) return UNI_REPLACEMENT_CHAR;
+ return result;
+}
+
+static int convert_UTF32_to_UTF8(char *buf, UTF32 ch)
+{
+ int len = 1;
+ if (ch <= 0x7F) {
+ buf[0] = (char) ch;
+ } else if (ch <= 0x07FF) {
+ buf[0] = (char) ((ch >> 6) | 0xC0);
+ buf[1] = (char) ((ch & 0x3F) | 0x80);
+ len++;
+ } else if (ch <= 0xFFFF) {
+ buf[0] = (char) ((ch >> 12) | 0xE0);
+ buf[1] = (char) (((ch >> 6) & 0x3F) | 0x80);
+ buf[2] = (char) ((ch & 0x3F) | 0x80);
+ len += 2;
+ } else if (ch <= 0x1fffff) {
+ buf[0] =(char) ((ch >> 18) | 0xF0);
+ buf[1] =(char) (((ch >> 12) & 0x3F) | 0x80);
+ buf[2] =(char) (((ch >> 6) & 0x3F) | 0x80);
+ buf[3] =(char) ((ch & 0x3F) | 0x80);
+ len += 3;
+ } else {
+ buf[0] = '?';
+ }
+ return len;
+}
+
+#ifdef HAVE_RUBY_ENCODING_H
+static rb_encoding *UTF_8, *UTF_16BE, *UTF_16LE, *UTF_32BE, *UTF_32LE;
+#else
+static ID i_iconv;
+#endif
+
+static VALUE mJSON, mExt, cParser, eParserError, eNestingError;
+static VALUE CNaN, CInfinity, CMinusInfinity;
+
+static ID i_json_creatable_p, i_json_create, i_create_id, i_create_additions,
+ i_chr, i_max_nesting, i_allow_nan, i_symbolize_names, i_quirks_mode,
+ i_object_class, i_array_class, i_key_p, i_deep_const_get, i_match,
+ i_match_string, i_aset, i_aref, i_leftshift;
+
+%%{
+ machine JSON_common;
+
+ cr = '\n';
+ cr_neg = [^\n];
+ ws = [ \t\r\n];
+ c_comment = '/*' ( any* - (any* '*/' any* ) ) '*/';
+ cpp_comment = '//' cr_neg* cr;
+ comment = c_comment | cpp_comment;
+ ignore = ws | comment;
+ name_separator = ':';
+ value_separator = ',';
+ Vnull = 'null';
+ Vfalse = 'false';
+ Vtrue = 'true';
+ VNaN = 'NaN';
+ VInfinity = 'Infinity';
+ VMinusInfinity = '-Infinity';
+ begin_value = [nft\"\-\[\{NI] | digit;
+ begin_object = '{';
+ end_object = '}';
+ begin_array = '[';
+ end_array = ']';
+ begin_string = '"';
+ begin_name = begin_string;
+ begin_number = digit | '-';
+}%%
+
+%%{
+ machine JSON_object;
+ include JSON_common;
+
+ write data;
+
+ action parse_value {
+ VALUE v = Qnil;
+ char *np = JSON_parse_value(json, fpc, pe, &v);
+ if (np == NULL) {
+ fhold; fbreak;
+ } else {
+ if (NIL_P(json->object_class)) {
+ rb_hash_aset(*result, last_name, v);
+ } else {
+ rb_funcall(*result, i_aset, 2, last_name, v);
+ }
+ fexec np;
+ }
+ }
+
+ action parse_name {
+ char *np;
+ json->parsing_name = 1;
+ np = JSON_parse_string(json, fpc, pe, &last_name);
+ json->parsing_name = 0;
+ if (np == NULL) { fhold; fbreak; } else fexec np;
+ }
+
+ action exit { fhold; fbreak; }
+
+ pair = ignore* begin_name >parse_name ignore* name_separator ignore* begin_value >parse_value;
+ next_pair = ignore* value_separator pair;
+
+ main := (
+ begin_object
+ (pair (next_pair)*)? ignore*
+ end_object
+ ) @exit;
+}%%
+
+static char *JSON_parse_object(JSON_Parser *json, char *p, char *pe, VALUE *result)
+{
+ int cs = EVIL;
+ VALUE last_name = Qnil;
+ VALUE object_class = json->object_class;
+
+ if (json->max_nesting && json->current_nesting > json->max_nesting) {
+ rb_raise(eNestingError, "nesting of %d is too deep", json->current_nesting);
+ }
+
+ *result = NIL_P(object_class) ? rb_hash_new() : rb_class_new_instance(0, 0, object_class);
+
+ %% write init;
+ %% write exec;
+
+ if (cs >= JSON_object_first_final) {
+ if (json->create_additions) {
+ VALUE klassname;
+ if (NIL_P(json->object_class)) {
+ klassname = rb_hash_aref(*result, json->create_id);
+ } else {
+ klassname = rb_funcall(*result, i_aref, 1, json->create_id);
+ }
+ if (!NIL_P(klassname)) {
+ VALUE klass = rb_funcall(mJSON, i_deep_const_get, 1, klassname);
+ if (RTEST(rb_funcall(klass, i_json_creatable_p, 0))) {
+ *result = rb_funcall(klass, i_json_create, 1, *result);
+ }
+ }
+ }
+ return p + 1;
+ } else {
+ return NULL;
+ }
+}
+
+
+%%{
+ machine JSON_value;
+ include JSON_common;
+
+ write data;
+
+ action parse_null {
+ *result = Qnil;
+ }
+ action parse_false {
+ *result = Qfalse;
+ }
+ action parse_true {
+ *result = Qtrue;
+ }
+ action parse_nan {
+ if (json->allow_nan) {
+ *result = CNaN;
+ } else {
+ rb_enc_raise(EXC_ENCODING eParserError, "%u: unexpected token at '%s'", __LINE__, p - 2);
+ }
+ }
+ action parse_infinity {
+ if (json->allow_nan) {
+ *result = CInfinity;
+ } else {
+ rb_enc_raise(EXC_ENCODING eParserError, "%u: unexpected token at '%s'", __LINE__, p - 8);
+ }
+ }
+ action parse_string {
+ char *np = JSON_parse_string(json, fpc, pe, result);
+ if (np == NULL) { fhold; fbreak; } else fexec np;
+ }
+
+ action parse_number {
+ char *np;
+ if(pe > fpc + 9 - json->quirks_mode && !strncmp(MinusInfinity, fpc, 9)) {
+ if (json->allow_nan) {
+ *result = CMinusInfinity;
+ fexec p + 10;
+ fhold; fbreak;
+ } else {
+ rb_enc_raise(EXC_ENCODING eParserError, "%u: unexpected token at '%s'", __LINE__, p);
+ }
+ }
+ np = JSON_parse_float(json, fpc, pe, result);
+ if (np != NULL) fexec np;
+ np = JSON_parse_integer(json, fpc, pe, result);
+ if (np != NULL) fexec np;
+ fhold; fbreak;
+ }
+
+ action parse_array {
+ char *np;
+ json->current_nesting++;
+ np = JSON_parse_array(json, fpc, pe, result);
+ json->current_nesting--;
+ if (np == NULL) { fhold; fbreak; } else fexec np;
+ }
+
+ action parse_object {
+ char *np;
+ json->current_nesting++;
+ np = JSON_parse_object(json, fpc, pe, result);
+ json->current_nesting--;
+ if (np == NULL) { fhold; fbreak; } else fexec np;
+ }
+
+ action exit { fhold; fbreak; }
+
+main := (
+ Vnull @parse_null |
+ Vfalse @parse_false |
+ Vtrue @parse_true |
+ VNaN @parse_nan |
+ VInfinity @parse_infinity |
+ begin_number >parse_number |
+ begin_string >parse_string |
+ begin_array >parse_array |
+ begin_object >parse_object
+ ) %*exit;
+}%%
+
+static char *JSON_parse_value(JSON_Parser *json, char *p, char *pe, VALUE *result)
+{
+ int cs = EVIL;
+
+ %% write init;
+ %% write exec;
+
+ if (cs >= JSON_value_first_final) {
+ return p;
+ } else {
+ return NULL;
+ }
+}
+
+%%{
+ machine JSON_integer;
+
+ write data;
+
+ action exit { fhold; fbreak; }
+
+ main := '-'? ('0' | [1-9][0-9]*) (^[0-9]? @exit);
+}%%
+
+static char *JSON_parse_integer(JSON_Parser *json, char *p, char *pe, VALUE *result)
+{
+ int cs = EVIL;
+
+ %% write init;
+ json->memo = p;
+ %% write exec;
+
+ if (cs >= JSON_integer_first_final) {
+ long len = p - json->memo;
+ fbuffer_clear(json->fbuffer);
+ fbuffer_append(json->fbuffer, json->memo, len);
+ fbuffer_append_char(json->fbuffer, '\0');
+ *result = rb_cstr2inum(FBUFFER_PTR(json->fbuffer), 10);
+ return p + 1;
+ } else {
+ return NULL;
+ }
+}
+
+%%{
+ machine JSON_float;
+ include JSON_common;
+
+ write data;
+
+ action exit { fhold; fbreak; }
+
+ main := '-'? (
+ (('0' | [1-9][0-9]*) '.' [0-9]+ ([Ee] [+\-]?[0-9]+)?)
+ | (('0' | [1-9][0-9]*) ([Ee] [+\-]?[0-9]+))
+ ) (^[0-9Ee.\-]? @exit );
+}%%
+
+static char *JSON_parse_float(JSON_Parser *json, char *p, char *pe, VALUE *result)
+{
+ int cs = EVIL;
+
+ %% write init;
+ json->memo = p;
+ %% write exec;
+
+ if (cs >= JSON_float_first_final) {
+ long len = p - json->memo;
+ fbuffer_clear(json->fbuffer);
+ fbuffer_append(json->fbuffer, json->memo, len);
+ fbuffer_append_char(json->fbuffer, '\0');
+ *result = rb_float_new(rb_cstr_to_dbl(FBUFFER_PTR(json->fbuffer), 1));
+ return p + 1;
+ } else {
+ return NULL;
+ }
+}
+
+
+%%{
+ machine JSON_array;
+ include JSON_common;
+
+ write data;
+
+ action parse_value {
+ VALUE v = Qnil;
+ char *np = JSON_parse_value(json, fpc, pe, &v);
+ if (np == NULL) {
+ fhold; fbreak;
+ } else {
+ if (NIL_P(json->array_class)) {
+ rb_ary_push(*result, v);
+ } else {
+ rb_funcall(*result, i_leftshift, 1, v);
+ }
+ fexec np;
+ }
+ }
+
+ action exit { fhold; fbreak; }
+
+ next_element = value_separator ignore* begin_value >parse_value;
+
+ main := begin_array ignore*
+ ((begin_value >parse_value ignore*)
+ (ignore* next_element ignore*)*)?
+ end_array @exit;
+}%%
+
+static char *JSON_parse_array(JSON_Parser *json, char *p, char *pe, VALUE *result)
+{
+ int cs = EVIL;
+ VALUE array_class = json->array_class;
+
+ if (json->max_nesting && json->current_nesting > json->max_nesting) {
+ rb_raise(eNestingError, "nesting of %d is too deep", json->current_nesting);
+ }
+ *result = NIL_P(array_class) ? rb_ary_new() : rb_class_new_instance(0, 0, array_class);
+
+ %% write init;
+ %% write exec;
+
+ if(cs >= JSON_array_first_final) {
+ return p + 1;
+ } else {
+ rb_enc_raise(EXC_ENCODING eParserError, "%u: unexpected token at '%s'", __LINE__, p);
+ return NULL;
+ }
+}
+
+static VALUE json_string_unescape(VALUE result, char *string, char *stringEnd)
+{
+ char *p = string, *pe = string, *unescape;
+ int unescape_len;
+ char buf[4];
+
+ while (pe < stringEnd) {
+ if (*pe == '\\') {
+ unescape = (char *) "?";
+ unescape_len = 1;
+ if (pe > p) rb_str_buf_cat(result, p, pe - p);
+ switch (*++pe) {
+ case 'n':
+ unescape = (char *) "\n";
+ break;
+ case 'r':
+ unescape = (char *) "\r";
+ break;
+ case 't':
+ unescape = (char *) "\t";
+ break;
+ case '"':
+ unescape = (char *) "\"";
+ break;
+ case '\\':
+ unescape = (char *) "\\";
+ break;
+ case 'b':
+ unescape = (char *) "\b";
+ break;
+ case 'f':
+ unescape = (char *) "\f";
+ break;
+ case 'u':
+ if (pe > stringEnd - 4) {
+ return Qnil;
+ } else {
+ UTF32 ch = unescape_unicode((unsigned char *) ++pe);
+ pe += 3;
+ if (UNI_SUR_HIGH_START == (ch & 0xFC00)) {
+ pe++;
+ if (pe > stringEnd - 6) return Qnil;
+ if (pe[0] == '\\' && pe[1] == 'u') {
+ UTF32 sur = unescape_unicode((unsigned char *) pe + 2);
+ ch = (((ch & 0x3F) << 10) | ((((ch >> 6) & 0xF) + 1) << 16)
+ | (sur & 0x3FF));
+ pe += 5;
+ } else {
+ unescape = (char *) "?";
+ break;
+ }
+ }
+ unescape_len = convert_UTF32_to_UTF8(buf, ch);
+ unescape = buf;
+ }
+ break;
+ default:
+ p = pe;
+ continue;
+ }
+ rb_str_buf_cat(result, unescape, unescape_len);
+ p = ++pe;
+ } else {
+ pe++;
+ }
+ }
+ rb_str_buf_cat(result, p, pe - p);
+ return result;
+}
+
+%%{
+ machine JSON_string;
+ include JSON_common;
+
+ write data;
+
+ action parse_string {
+ *result = json_string_unescape(*result, json->memo + 1, p);
+ if (NIL_P(*result)) {
+ fhold;
+ fbreak;
+ } else {
+ FORCE_UTF8(*result);
+ fexec p + 1;
+ }
+ }
+
+ action exit { fhold; fbreak; }
+
+ main := '"' ((^([\"\\] | 0..0x1f) | '\\'[\"\\/bfnrt] | '\\u'[0-9a-fA-F]{4} | '\\'^([\"\\/bfnrtu]|0..0x1f))* %parse_string) '"' @exit;
+}%%
+
+static int
+match_i(VALUE regexp, VALUE klass, VALUE memo)
+{
+ if (regexp == Qundef) return ST_STOP;
+ if (RTEST(rb_funcall(klass, i_json_creatable_p, 0)) &&
+ RTEST(rb_funcall(regexp, i_match, 1, rb_ary_entry(memo, 0)))) {
+ rb_ary_push(memo, klass);
+ return ST_STOP;
+ }
+ return ST_CONTINUE;
+}
+
+static char *JSON_parse_string(JSON_Parser *json, char *p, char *pe, VALUE *result)
+{
+ int cs = EVIL;
+ VALUE match_string;
+
+ *result = rb_str_buf_new(0);
+ %% write init;
+ json->memo = p;
+ %% write exec;
+
+ if (json->create_additions && RTEST(match_string = json->match_string)) {
+ VALUE klass;
+ VALUE memo = rb_ary_new2(2);
+ rb_ary_push(memo, *result);
+ rb_hash_foreach(match_string, match_i, memo);
+ klass = rb_ary_entry(memo, 1);
+ if (RTEST(klass)) {
+ *result = rb_funcall(klass, i_json_create, 1, *result);
+ }
+ }
+
+ if (json->symbolize_names && json->parsing_name) {
+ *result = rb_str_intern(*result);
+ }
+ if (cs >= JSON_string_first_final) {
+ return p + 1;
+ } else {
+ return NULL;
+ }
+}
+
+/*
+ * Document-class: JSON::Ext::Parser
+ *
+ * This is the JSON parser implemented as a C extension. It can be configured
+ * to be used by setting
+ *
+ * JSON.parser = JSON::Ext::Parser
+ *
+ * with the method parser= in JSON.
+ *
+ */
+
+static VALUE convert_encoding(VALUE source)
+{
+ char *ptr = RSTRING_PTR(source);
+ long len = RSTRING_LEN(source);
+ if (len < 2) {
+ rb_raise(eParserError, "A JSON text must at least contain two octets!");
+ }
+#ifdef HAVE_RUBY_ENCODING_H
+ {
+ rb_encoding *enc = rb_enc_get(source);
+ if (enc == rb_ascii8bit_encoding()) {
+ if (len >= 4 && ptr[0] == 0 && ptr[1] == 0 && ptr[2] == 0) {
+ source = rb_str_conv_enc(source, UTF_32BE, rb_utf8_encoding());
+ } else if (len >= 4 && ptr[0] == 0 && ptr[2] == 0) {
+ source = rb_str_conv_enc(source, UTF_16BE, rb_utf8_encoding());
+ } else if (len >= 4 && ptr[1] == 0 && ptr[2] == 0 && ptr[3] == 0) {
+ source = rb_str_conv_enc(source, UTF_32LE, rb_utf8_encoding());
+ } else if (len >= 4 && ptr[1] == 0 && ptr[3] == 0) {
+ source = rb_str_conv_enc(source, UTF_16LE, rb_utf8_encoding());
+ } else {
+ source = rb_str_dup(source);
+ FORCE_UTF8(source);
+ }
+ } else {
+ source = rb_str_conv_enc(source, NULL, rb_utf8_encoding());
+ }
+ }
+#else
+ if (len >= 4 && ptr[0] == 0 && ptr[1] == 0 && ptr[2] == 0) {
+ source = rb_funcall(mJSON, i_iconv, 3, rb_str_new2("utf-8"), rb_str_new2("utf-32be"), source);
+ } else if (len >= 4 && ptr[0] == 0 && ptr[2] == 0) {
+ source = rb_funcall(mJSON, i_iconv, 3, rb_str_new2("utf-8"), rb_str_new2("utf-16be"), source);
+ } else if (len >= 4 && ptr[1] == 0 && ptr[2] == 0 && ptr[3] == 0) {
+ source = rb_funcall(mJSON, i_iconv, 3, rb_str_new2("utf-8"), rb_str_new2("utf-32le"), source);
+ } else if (len >= 4 && ptr[1] == 0 && ptr[3] == 0) {
+ source = rb_funcall(mJSON, i_iconv, 3, rb_str_new2("utf-8"), rb_str_new2("utf-16le"), source);
+ }
+#endif
+ return source;
+}
+
+/*
+ * call-seq: new(source, opts => {})
+ *
+ * Creates a new JSON::Ext::Parser instance for the string _source_.
+ *
+ * Creates a new JSON::Ext::Parser instance for the string _source_.
+ *
+ * It will be configured by the _opts_ hash. _opts_ can have the following
+ * keys:
+ *
+ * _opts_ can have the following keys:
+ * * *max_nesting*: The maximum depth of nesting allowed in the parsed data
+ * structures. Disable depth checking with :max_nesting => false|nil|0, it
+ * defaults to 100.
+ * * *allow_nan*: If set to true, allow NaN, Infinity and -Infinity in
+ * defiance of RFC 4627 to be parsed by the Parser. This option defaults to
+ * false.
+ * * *symbolize_names*: If set to true, returns symbols for the names
+ * (keys) in a JSON object. Otherwise strings are returned, which is also
+ * the default.
+ * * *create_additions*: If set to false, the Parser doesn't create
+ * additions even if a matchin class and create_id was found. This option
+ * defaults to true.
+ * * *object_class*: Defaults to Hash
+ * * *array_class*: Defaults to Array
+ */
+static VALUE cParser_initialize(int argc, VALUE *argv, VALUE self)
+{
+ VALUE source, opts;
+ GET_PARSER_INIT;
+
+ if (json->Vsource) {
+ rb_raise(rb_eTypeError, "already initialized instance");
+ }
+ rb_scan_args(argc, argv, "11", &source, &opts);
+ if (!NIL_P(opts)) {
+ opts = rb_convert_type(opts, T_HASH, "Hash", "to_hash");
+ if (NIL_P(opts)) {
+ rb_raise(rb_eArgError, "opts needs to be like a hash");
+ } else {
+ VALUE tmp = ID2SYM(i_max_nesting);
+ if (option_given_p(opts, tmp)) {
+ VALUE max_nesting = rb_hash_aref(opts, tmp);
+ if (RTEST(max_nesting)) {
+ Check_Type(max_nesting, T_FIXNUM);
+ json->max_nesting = FIX2INT(max_nesting);
+ } else {
+ json->max_nesting = 0;
+ }
+ } else {
+ json->max_nesting = 100;
+ }
+ tmp = ID2SYM(i_allow_nan);
+ if (option_given_p(opts, tmp)) {
+ json->allow_nan = RTEST(rb_hash_aref(opts, tmp)) ? 1 : 0;
+ } else {
+ json->allow_nan = 0;
+ }
+ tmp = ID2SYM(i_symbolize_names);
+ if (option_given_p(opts, tmp)) {
+ json->symbolize_names = RTEST(rb_hash_aref(opts, tmp)) ? 1 : 0;
+ } else {
+ json->symbolize_names = 0;
+ }
+ tmp = ID2SYM(i_quirks_mode);
+ if (option_given_p(opts, tmp)) {
+ VALUE quirks_mode = rb_hash_aref(opts, tmp);
+ json->quirks_mode = RTEST(quirks_mode) ? 1 : 0;
+ } else {
+ json->quirks_mode = 0;
+ }
+ tmp = ID2SYM(i_create_additions);
+ if (option_given_p(opts, tmp)) {
+ json->create_additions = RTEST(rb_hash_aref(opts, tmp));
+ } else {
+ json->create_additions = 0;
+ }
+ tmp = ID2SYM(i_create_id);
+ if (option_given_p(opts, tmp)) {
+ json->create_id = rb_hash_aref(opts, tmp);
+ } else {
+ json->create_id = rb_funcall(mJSON, i_create_id, 0);
+ }
+ tmp = ID2SYM(i_object_class);
+ if (option_given_p(opts, tmp)) {
+ json->object_class = rb_hash_aref(opts, tmp);
+ } else {
+ json->object_class = Qnil;
+ }
+ tmp = ID2SYM(i_array_class);
+ if (option_given_p(opts, tmp)) {
+ json->array_class = rb_hash_aref(opts, tmp);
+ } else {
+ json->array_class = Qnil;
+ }
+ tmp = ID2SYM(i_match_string);
+ if (option_given_p(opts, tmp)) {
+ VALUE match_string = rb_hash_aref(opts, tmp);
+ json->match_string = RTEST(match_string) ? match_string : Qnil;
+ } else {
+ json->match_string = Qnil;
+ }
+ }
+ } else {
+ json->max_nesting = 100;
+ json->allow_nan = 0;
+ json->create_additions = 1;
+ json->create_id = rb_funcall(mJSON, i_create_id, 0);
+ json->object_class = Qnil;
+ json->array_class = Qnil;
+ }
+ StringValue(source);
+ if (!json->quirks_mode) {
+ source = convert_encoding(source);
+ }
+ json->current_nesting = 0;
+ json->len = RSTRING_LEN(source);
+ json->source = RSTRING_PTR(source);;
+ json->Vsource = source;
+ return self;
+}
+
+%%{
+ machine JSON;
+
+ write data;
+
+ include JSON_common;
+
+ action parse_object {
+ char *np;
+ json->current_nesting = 1;
+ np = JSON_parse_object(json, fpc, pe, &result);
+ if (np == NULL) { fhold; fbreak; } else fexec np;
+ }
+
+ action parse_array {
+ char *np;
+ json->current_nesting = 1;
+ np = JSON_parse_array(json, fpc, pe, &result);
+ if (np == NULL) { fhold; fbreak; } else fexec np;
+ }
+
+ main := ignore* (
+ begin_object >parse_object |
+ begin_array >parse_array
+ ) ignore*;
+}%%
+
+static VALUE cParser_parse_strict(VALUE self)
+{
+ char *p, *pe;
+ int cs = EVIL;
+ VALUE result = Qnil;
+ GET_PARSER;
+
+ %% write init;
+ p = json->source;
+ pe = p + json->len;
+ %% write exec;
+
+ if (cs >= JSON_first_final && p == pe) {
+ return result;
+ } else {
+ rb_enc_raise(EXC_ENCODING eParserError, "%u: unexpected token at '%s'", __LINE__, p);
+ return Qnil;
+ }
+}
+
+
+%%{
+ machine JSON_quirks_mode;
+
+ write data;
+
+ include JSON_common;
+
+ action parse_value {
+ char *np = JSON_parse_value(json, fpc, pe, &result);
+ if (np == NULL) { fhold; fbreak; } else fexec np;
+ }
+
+ main := ignore* (
+ begin_value >parse_value
+ ) ignore*;
+}%%
+
+static VALUE cParser_parse_quirks_mode(VALUE self)
+{
+ char *p, *pe;
+ int cs = EVIL;
+ VALUE result = Qnil;
+ GET_PARSER;
+
+ %% write init;
+ p = json->source;
+ pe = p + json->len;
+ %% write exec;
+
+ if (cs >= JSON_quirks_mode_first_final && p == pe) {
+ return result;
+ } else {
+ rb_enc_raise(EXC_ENCODING eParserError, "%u: unexpected token at '%s'", __LINE__, p);
+ return Qnil;
+ }
+}
+
+/*
+ * call-seq: parse()
+ *
+ * Parses the current JSON text _source_ and returns the complete data
+ * structure as a result.
+ */
+static VALUE cParser_parse(VALUE self)
+{
+ GET_PARSER;
+
+ if (json->quirks_mode) {
+ return cParser_parse_quirks_mode(self);
+ } else {
+ return cParser_parse_strict(self);
+ }
+}
+
+
+static JSON_Parser *JSON_allocate(void)
+{
+ JSON_Parser *json = ALLOC(JSON_Parser);
+ MEMZERO(json, JSON_Parser, 1);
+ json->fbuffer = fbuffer_alloc(0);
+ return json;
+}
+
+static void JSON_mark(void *ptr)
+{
+ JSON_Parser *json = ptr;
+ rb_gc_mark_maybe(json->Vsource);
+ rb_gc_mark_maybe(json->create_id);
+ rb_gc_mark_maybe(json->object_class);
+ rb_gc_mark_maybe(json->array_class);
+ rb_gc_mark_maybe(json->match_string);
+}
+
+static void JSON_free(void *ptr)
+{
+ JSON_Parser *json = ptr;
+ fbuffer_free(json->fbuffer);
+ ruby_xfree(json);
+}
+
+static size_t JSON_memsize(const void *ptr)
+{
+ const JSON_Parser *json = ptr;
+ return sizeof(*json) + FBUFFER_CAPA(json->fbuffer);
+}
+
+static const rb_data_type_t JSON_Parser_type = {
+ "JSON/Parser",
+ {JSON_mark, JSON_free, JSON_memsize,},
+ 0, 0,
+ RUBY_TYPED_FREE_IMMEDIATELY,
+};
+
+static VALUE cJSON_parser_s_allocate(VALUE klass)
+{
+ JSON_Parser *json = JSON_allocate();
+ return TypedData_Wrap_Struct(klass, &JSON_Parser_type, json);
+}
+
+/*
+ * call-seq: source()
+ *
+ * Returns a copy of the current _source_ string, that was used to construct
+ * this Parser.
+ */
+static VALUE cParser_source(VALUE self)
+{
+ GET_PARSER;
+ return rb_str_dup(json->Vsource);
+}
+
+/*
+ * call-seq: quirks_mode?()
+ *
+ * Returns a true, if this parser is in quirks_mode, false otherwise.
+ */
+static VALUE cParser_quirks_mode_p(VALUE self)
+{
+ GET_PARSER;
+ return json->quirks_mode ? Qtrue : Qfalse;
+}
+
+
+void Init_parser()
+{
+ rb_require("json/common");
+ mJSON = rb_define_module("JSON");
+ mExt = rb_define_module_under(mJSON, "Ext");
+ cParser = rb_define_class_under(mExt, "Parser", rb_cObject);
+ eParserError = rb_path2class("JSON::ParserError");
+ eNestingError = rb_path2class("JSON::NestingError");
+ rb_define_alloc_func(cParser, cJSON_parser_s_allocate);
+ rb_define_method(cParser, "initialize", cParser_initialize, -1);
+ rb_define_method(cParser, "parse", cParser_parse, 0);
+ rb_define_method(cParser, "source", cParser_source, 0);
+ rb_define_method(cParser, "quirks_mode?", cParser_quirks_mode_p, 0);
+
+ CNaN = rb_const_get(mJSON, rb_intern("NaN"));
+ CInfinity = rb_const_get(mJSON, rb_intern("Infinity"));
+ CMinusInfinity = rb_const_get(mJSON, rb_intern("MinusInfinity"));
+
+ i_json_creatable_p = rb_intern("json_creatable?");
+ i_json_create = rb_intern("json_create");
+ i_create_id = rb_intern("create_id");
+ i_create_additions = rb_intern("create_additions");
+ i_chr = rb_intern("chr");
+ i_max_nesting = rb_intern("max_nesting");
+ i_allow_nan = rb_intern("allow_nan");
+ i_symbolize_names = rb_intern("symbolize_names");
+ i_quirks_mode = rb_intern("quirks_mode");
+ i_object_class = rb_intern("object_class");
+ i_array_class = rb_intern("array_class");
+ i_match = rb_intern("match");
+ i_match_string = rb_intern("match_string");
+ i_key_p = rb_intern("key?");
+ i_deep_const_get = rb_intern("deep_const_get");
+ i_aset = rb_intern("[]=");
+ i_aref = rb_intern("[]");
+ i_leftshift = rb_intern("<<");
+#ifdef HAVE_RUBY_ENCODING_H
+ UTF_8 = rb_utf8_encoding();
+ UTF_16BE = rb_enc_find("utf-16be");
+ UTF_16LE = rb_enc_find("utf-16le");
+ UTF_32BE = rb_enc_find("utf-32be");
+ UTF_32LE = rb_enc_find("utf-32le");
+#else
+ i_iconv = rb_intern("iconv");
+#endif
+}
+
+/*
+ * Local variables:
+ * mode: c
+ * c-file-style: ruby
+ * indent-tabs-mode: nil
+ * End:
+ */
diff --git a/jni/ruby/ext/json/parser/prereq.mk b/jni/ruby/ext/json/parser/prereq.mk
new file mode 100644
index 0000000..be7bcb4
--- /dev/null
+++ b/jni/ruby/ext/json/parser/prereq.mk
@@ -0,0 +1,10 @@
+RAGEL = ragel
+
+.SUFFIXES: .rl
+
+.rl.c:
+ $(RAGEL) -G2 $<
+ $(BASERUBY) -pli -e '$$_.sub!(/[ \t]+$$/, "")' \
+ -e '$$_.sub!(/^static const int (JSON_.*=.*);$$/, "enum {\\1};")' $@
+
+parser.c:
diff --git a/jni/ruby/ext/mathn/complex/Makefile b/jni/ruby/ext/mathn/complex/Makefile
new file mode 100644
index 0000000..a1c8d8b
--- /dev/null
+++ b/jni/ruby/ext/mathn/complex/Makefile
@@ -0,0 +1,267 @@
+
+SHELL = /bin/sh
+
+# V=0 quiet, V=1 verbose. other values don't work.
+V = 0
+Q1 = $(V:1=)
+Q = $(Q1:0=@)
+ECHO1 = $(V:1=@:)
+ECHO = $(ECHO1:0=@echo)
+NULLCMD = :
+
+#### Start of system configuration section. ####
+top_srcdir = $(topdir)/.
+srcdir = $(top_srcdir)/ext/mathn/complex
+topdir = ../../..
+hdrdir = $(top_srcdir)/include
+arch_hdrdir = $(extout)/include/$(arch)
+PATH_SEPARATOR = :
+VPATH = $(srcdir):$(arch_hdrdir)/ruby:$(hdrdir)/ruby
+RUBYLIB =
+RUBYOPT = -
+prefix = $(DESTDIR)/usr/local
+rubysitearchprefix = $(rubylibprefix)/$(sitearch)
+rubyarchprefix = $(rubylibprefix)/$(arch)
+rubylibprefix = $(libdir)/$(RUBY_BASE_NAME)
+exec_prefix = $(prefix)
+vendorarchhdrdir = $(vendorhdrdir)/$(sitearch)
+sitearchhdrdir = $(sitehdrdir)/$(sitearch)
+rubyarchhdrdir = $(rubyhdrdir)/$(arch)
+vendorhdrdir = $(rubyhdrdir)/vendor_ruby
+sitehdrdir = $(rubyhdrdir)/site_ruby
+rubyhdrdir = $(includedir)/$(RUBY_VERSION_NAME)
+vendorarchdir = $(vendorlibdir)/$(sitearch)
+vendorlibdir = $(vendordir)/$(ruby_version)
+vendordir = $(rubylibprefix)/vendor_ruby
+sitearchdir = $(sitelibdir)/$(sitearch)
+sitelibdir = $(sitedir)/$(ruby_version)
+sitedir = $(rubylibprefix)/site_ruby
+rubyarchdir = $(rubylibdir)/$(arch)
+rubylibdir = $(rubylibprefix)/$(ruby_version)
+sitearchincludedir = $(includedir)/$(sitearch)
+archincludedir = $(includedir)/$(arch)
+sitearchlibdir = $(libdir)/$(sitearch)
+archlibdir = $(libdir)/$(arch)
+ridir = $(datarootdir)/$(RI_BASE_NAME)
+mandir = $(datarootdir)/man
+localedir = $(datarootdir)/locale
+libdir = $(exec_prefix)/lib
+psdir = $(docdir)
+pdfdir = $(docdir)
+dvidir = $(docdir)
+htmldir = $(docdir)
+infodir = $(datarootdir)/info
+docdir = $(datarootdir)/doc/$(PACKAGE)
+oldincludedir = $(DESTDIR)/usr/include
+includedir = $(prefix)/include
+localstatedir = $(prefix)/var
+sharedstatedir = $(prefix)/com
+sysconfdir = $(prefix)/etc
+datadir = $(datarootdir)
+datarootdir = $(prefix)/share
+libexecdir = $(exec_prefix)/libexec
+sbindir = $(exec_prefix)/sbin
+bindir = $(exec_prefix)/bin
+archdir = $(rubyarchdir)
+
+
+CC = gcc
+CXX = g++
+LIBRUBY = $(LIBRUBY_SO)
+LIBRUBY_A = lib$(RUBY_SO_NAME)-static.a
+LIBRUBYARG_SHARED = -Wl,-R$(libdir) -L$(libdir) -l$(RUBY_SO_NAME)
+LIBRUBYARG_STATIC = -Wl,-R$(libdir) -L$(libdir) -l$(RUBY_SO_NAME)-static
+empty =
+OUTFLAG = -o $(empty)
+COUTFLAG = -o $(empty)
+
+RUBY_EXTCONF_H = extconf.h
+cflags = $(optflags) $(debugflags) $(warnflags)
+optflags = -O3 -fno-fast-math
+debugflags = -ggdb3
+warnflags = -Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wunused-variable -Wpointer-arith -Wwrite-strings -Wdeclaration-after-statement -Wimplicit-function-declaration -Wdeprecated-declarations -Wno-packed-bitfield-compat
+CCDLFLAGS = -fPIC
+CFLAGS = $(CCDLFLAGS) $(cflags) -fPIC $(ARCH_FLAG)
+INCFLAGS = -I. -I$(arch_hdrdir) -I$(hdrdir) -I$(srcdir)
+DEFS =
+CPPFLAGS = -DRUBY_EXTCONF_H=\"$(RUBY_EXTCONF_H)\" $(DEFS) $(cppflags)
+CXXFLAGS = $(CCDLFLAGS) $(cxxflags) $(ARCH_FLAG)
+ldflags = -L. -fstack-protector -rdynamic -Wl,-export-dynamic
+dldflags =
+ARCH_FLAG =
+DLDFLAGS = $(ldflags) $(dldflags) $(ARCH_FLAG)
+LDSHARED = $(CC) -shared
+LDSHAREDXX = $(CXX) -shared
+AR = ar
+EXEEXT =
+
+RUBY_INSTALL_NAME = $(RUBY_BASE_NAME)
+RUBY_SO_NAME = ruby
+RUBYW_INSTALL_NAME =
+RUBY_VERSION_NAME = $(RUBY_BASE_NAME)-$(ruby_version)
+RUBYW_BASE_NAME = rubyw
+RUBY_BASE_NAME = ruby
+
+arch = x86_64-linux
+sitearch = $(arch)
+ruby_version = 2.2.0
+ruby = $(topdir)/miniruby -I'$(topdir)' -I'$(top_srcdir)/lib' -I'$(extout)/$(arch)' -I'$(extout)/common'
+RUBY = $(ruby)
+ruby_headers = $(hdrdir)/ruby.h $(hdrdir)/ruby/ruby.h $(hdrdir)/ruby/defines.h $(hdrdir)/ruby/missing.h $(hdrdir)/ruby/intern.h $(hdrdir)/ruby/st.h $(hdrdir)/ruby/subst.h $(arch_hdrdir)/ruby/config.h $(RUBY_EXTCONF_H)
+
+RM = rm -f
+RM_RF = $(RUBY) -run -e rm -- -rf
+RMDIRS = rmdir --ignore-fail-on-non-empty -p
+MAKEDIRS = /bin/mkdir -p
+INSTALL = /usr/bin/install -c
+INSTALL_PROG = $(INSTALL) -m 0755
+INSTALL_DATA = $(INSTALL) -m 644
+COPY = cp
+TOUCH = exit >
+
+#### End of system configuration section. ####
+
+preload =
+
+libpath = . $(topdir)
+LIBPATH = -L. -L$(topdir)
+DEFFILE =
+
+CLEANFILES = mkmf.log
+DISTCLEANFILES =
+DISTCLEANDIRS =
+
+extout = $(topdir)/.ext
+extout_prefix = $(extout)$(target_prefix)/
+target_prefix = /mathn
+LOCAL_LIBS =
+LIBS = $(LIBRUBYARG_SHARED) -lpthread -lgmp -ldl -lcrypt -lm -lc
+ORIG_SRCS = complex.c
+SRCS = $(ORIG_SRCS)
+OBJS = complex.o
+HDRS = $(srcdir)/extconf.h
+TARGET = complex
+TARGET_NAME = complex
+TARGET_ENTRY = Init_$(TARGET_NAME)
+DLLIB = $(TARGET).so
+EXTSTATIC =
+STATIC_LIB = $(TARGET).a
+
+TIMESTAMP_DIR = $(extout)/.timestamp
+BINDIR = $(extout)/bin
+RUBYCOMMONDIR = $(extout)/common
+RUBYLIBDIR = $(RUBYCOMMONDIR)$(target_prefix)
+RUBYARCHDIR = $(extout)/$(arch)$(target_prefix)
+HDRDIR = $(extout)/include/ruby$(target_prefix)
+ARCHHDRDIR = $(extout)/include/$(arch)/ruby$(target_prefix)
+
+TARGET_SO = $(RUBYARCHDIR)/$(DLLIB)
+CLEANLIBS = $(RUBYARCHDIR)/$(TARGET).so
+CLEANOBJS = *.o *.bak
+
+all: install
+static: all
+.PHONY: all install static install-so install-rb
+.PHONY: clean clean-so clean-static clean-rb
+
+clean-static::
+clean-rb-default::
+clean-rb::
+clean-so::
+clean: clean-so clean-static clean-rb-default clean-rb
+ -$(Q)$(RM) $(CLEANLIBS) $(CLEANOBJS) $(CLEANFILES) .*.time
+
+distclean-rb-default::
+distclean-rb::
+distclean-so::
+distclean-static::
+distclean: clean distclean-so distclean-static distclean-rb-default distclean-rb
+ -$(Q)$(RM) Makefile $(RUBY_EXTCONF_H) conftest.* mkmf.log
+ -$(Q)$(RM) core ruby$(EXEEXT) *~ $(DISTCLEANFILES)
+ -$(Q)$(RMDIRS) $(DISTCLEANDIRS) 2> /dev/null || true
+
+realclean: distclean
+install: install-so install-rb
+
+install-so: $(RUBYARCHDIR)/$(DLLIB)
+clean-so::
+ -$(Q)$(RM) $(RUBYARCHDIR)/$(DLLIB)
+ -$(Q)$(RMDIRS) $(RUBYARCHDIR) 2> /dev/null || true
+clean-static::
+ -$(Q)$(RM) $(STATIC_LIB)
+install-rb: pre-install-rb install-rb-default
+install-rb-default: pre-install-rb-default
+pre-install-rb: Makefile
+pre-install-rb-default: Makefile
+pre-install-rb-default:
+ @$(NULLCMD)
+$(TIMESTAMP_DIR)/.RUBYARCHDIR.-.mathn.time:
+ $(Q) $(MAKEDIRS) $(@D) $(RUBYARCHDIR)
+ $(Q) $(TOUCH) $@
+
+site-install: site-install-so site-install-rb
+site-install-so: install-so
+site-install-rb: install-rb
+
+.SUFFIXES: .c .m .cc .mm .cxx .cpp .o .S
+
+.cc.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<
+
+.cc.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -S $<
+
+.mm.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<
+
+.mm.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -S $<
+
+.cxx.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<
+
+.cxx.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -S $<
+
+.cpp.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<
+
+.cpp.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -S $<
+
+.c.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -c $<
+
+.c.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -S $<
+
+.m.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -c $<
+
+.m.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -S $<
+
+$(RUBYARCHDIR)/$(DLLIB): $(OBJS) Makefile $(TIMESTAMP_DIR)/.RUBYARCHDIR.-.mathn.time
+ $(ECHO) linking shared-object mathn/$(DLLIB)
+ -$(Q)$(RM) $(@)
+ $(Q) $(LDSHARED) -o $@ $(OBJS) $(LIBPATH) $(DLDFLAGS) $(LOCAL_LIBS) $(LIBS)
+
+$(STATIC_LIB): $(OBJS)
+ -$(Q)$(RM) $(@)
+ $(ECHO) linking static-library $(@)
+ $(Q) $(AR) cru $@ $(OBJS)
+ -$(Q)ranlib $(@) 2> /dev/null || true
+
+$(OBJS): $(HDRS) $(ruby_headers)
diff --git a/jni/ruby/ext/mathn/complex/complex.c b/jni/ruby/ext/mathn/complex/complex.c
new file mode 100644
index 0000000..dce4949
--- /dev/null
+++ b/jni/ruby/ext/mathn/complex/complex.c
@@ -0,0 +1,7 @@
+extern void nucomp_canonicalization(int);
+
+void
+Init_complex(void)
+{
+ nucomp_canonicalization(1);
+}
diff --git a/jni/ruby/ext/mathn/complex/extconf.h b/jni/ruby/ext/mathn/complex/extconf.h
new file mode 100644
index 0000000..cda0cc8
--- /dev/null
+++ b/jni/ruby/ext/mathn/complex/extconf.h
@@ -0,0 +1,3 @@
+#ifndef EXTCONF_H
+#define EXTCONF_H
+#endif
diff --git a/jni/ruby/ext/mathn/complex/extconf.rb b/jni/ruby/ext/mathn/complex/extconf.rb
new file mode 100644
index 0000000..d4d14ff
--- /dev/null
+++ b/jni/ruby/ext/mathn/complex/extconf.rb
@@ -0,0 +1,3 @@
+require "mkmf"
+
+create_makefile "mathn/complex"
diff --git a/jni/ruby/ext/mathn/rational/Makefile b/jni/ruby/ext/mathn/rational/Makefile
new file mode 100644
index 0000000..245b7fd
--- /dev/null
+++ b/jni/ruby/ext/mathn/rational/Makefile
@@ -0,0 +1,267 @@
+
+SHELL = /bin/sh
+
+# V=0 quiet, V=1 verbose. other values don't work.
+V = 0
+Q1 = $(V:1=)
+Q = $(Q1:0=@)
+ECHO1 = $(V:1=@:)
+ECHO = $(ECHO1:0=@echo)
+NULLCMD = :
+
+#### Start of system configuration section. ####
+top_srcdir = $(topdir)/.
+srcdir = $(top_srcdir)/ext/mathn/rational
+topdir = ../../..
+hdrdir = $(top_srcdir)/include
+arch_hdrdir = $(extout)/include/$(arch)
+PATH_SEPARATOR = :
+VPATH = $(srcdir):$(arch_hdrdir)/ruby:$(hdrdir)/ruby
+RUBYLIB =
+RUBYOPT = -
+prefix = $(DESTDIR)/usr/local
+rubysitearchprefix = $(rubylibprefix)/$(sitearch)
+rubyarchprefix = $(rubylibprefix)/$(arch)
+rubylibprefix = $(libdir)/$(RUBY_BASE_NAME)
+exec_prefix = $(prefix)
+vendorarchhdrdir = $(vendorhdrdir)/$(sitearch)
+sitearchhdrdir = $(sitehdrdir)/$(sitearch)
+rubyarchhdrdir = $(rubyhdrdir)/$(arch)
+vendorhdrdir = $(rubyhdrdir)/vendor_ruby
+sitehdrdir = $(rubyhdrdir)/site_ruby
+rubyhdrdir = $(includedir)/$(RUBY_VERSION_NAME)
+vendorarchdir = $(vendorlibdir)/$(sitearch)
+vendorlibdir = $(vendordir)/$(ruby_version)
+vendordir = $(rubylibprefix)/vendor_ruby
+sitearchdir = $(sitelibdir)/$(sitearch)
+sitelibdir = $(sitedir)/$(ruby_version)
+sitedir = $(rubylibprefix)/site_ruby
+rubyarchdir = $(rubylibdir)/$(arch)
+rubylibdir = $(rubylibprefix)/$(ruby_version)
+sitearchincludedir = $(includedir)/$(sitearch)
+archincludedir = $(includedir)/$(arch)
+sitearchlibdir = $(libdir)/$(sitearch)
+archlibdir = $(libdir)/$(arch)
+ridir = $(datarootdir)/$(RI_BASE_NAME)
+mandir = $(datarootdir)/man
+localedir = $(datarootdir)/locale
+libdir = $(exec_prefix)/lib
+psdir = $(docdir)
+pdfdir = $(docdir)
+dvidir = $(docdir)
+htmldir = $(docdir)
+infodir = $(datarootdir)/info
+docdir = $(datarootdir)/doc/$(PACKAGE)
+oldincludedir = $(DESTDIR)/usr/include
+includedir = $(prefix)/include
+localstatedir = $(prefix)/var
+sharedstatedir = $(prefix)/com
+sysconfdir = $(prefix)/etc
+datadir = $(datarootdir)
+datarootdir = $(prefix)/share
+libexecdir = $(exec_prefix)/libexec
+sbindir = $(exec_prefix)/sbin
+bindir = $(exec_prefix)/bin
+archdir = $(rubyarchdir)
+
+
+CC = gcc
+CXX = g++
+LIBRUBY = $(LIBRUBY_SO)
+LIBRUBY_A = lib$(RUBY_SO_NAME)-static.a
+LIBRUBYARG_SHARED = -Wl,-R$(libdir) -L$(libdir) -l$(RUBY_SO_NAME)
+LIBRUBYARG_STATIC = -Wl,-R$(libdir) -L$(libdir) -l$(RUBY_SO_NAME)-static
+empty =
+OUTFLAG = -o $(empty)
+COUTFLAG = -o $(empty)
+
+RUBY_EXTCONF_H = extconf.h
+cflags = $(optflags) $(debugflags) $(warnflags)
+optflags = -O3 -fno-fast-math
+debugflags = -ggdb3
+warnflags = -Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wunused-variable -Wpointer-arith -Wwrite-strings -Wdeclaration-after-statement -Wimplicit-function-declaration -Wdeprecated-declarations -Wno-packed-bitfield-compat
+CCDLFLAGS = -fPIC
+CFLAGS = $(CCDLFLAGS) $(cflags) -fPIC $(ARCH_FLAG)
+INCFLAGS = -I. -I$(arch_hdrdir) -I$(hdrdir) -I$(srcdir)
+DEFS =
+CPPFLAGS = -DRUBY_EXTCONF_H=\"$(RUBY_EXTCONF_H)\" $(DEFS) $(cppflags)
+CXXFLAGS = $(CCDLFLAGS) $(cxxflags) $(ARCH_FLAG)
+ldflags = -L. -fstack-protector -rdynamic -Wl,-export-dynamic
+dldflags =
+ARCH_FLAG =
+DLDFLAGS = $(ldflags) $(dldflags) $(ARCH_FLAG)
+LDSHARED = $(CC) -shared
+LDSHAREDXX = $(CXX) -shared
+AR = ar
+EXEEXT =
+
+RUBY_INSTALL_NAME = $(RUBY_BASE_NAME)
+RUBY_SO_NAME = ruby
+RUBYW_INSTALL_NAME =
+RUBY_VERSION_NAME = $(RUBY_BASE_NAME)-$(ruby_version)
+RUBYW_BASE_NAME = rubyw
+RUBY_BASE_NAME = ruby
+
+arch = x86_64-linux
+sitearch = $(arch)
+ruby_version = 2.2.0
+ruby = $(topdir)/miniruby -I'$(topdir)' -I'$(top_srcdir)/lib' -I'$(extout)/$(arch)' -I'$(extout)/common'
+RUBY = $(ruby)
+ruby_headers = $(hdrdir)/ruby.h $(hdrdir)/ruby/ruby.h $(hdrdir)/ruby/defines.h $(hdrdir)/ruby/missing.h $(hdrdir)/ruby/intern.h $(hdrdir)/ruby/st.h $(hdrdir)/ruby/subst.h $(arch_hdrdir)/ruby/config.h $(RUBY_EXTCONF_H)
+
+RM = rm -f
+RM_RF = $(RUBY) -run -e rm -- -rf
+RMDIRS = rmdir --ignore-fail-on-non-empty -p
+MAKEDIRS = /bin/mkdir -p
+INSTALL = /usr/bin/install -c
+INSTALL_PROG = $(INSTALL) -m 0755
+INSTALL_DATA = $(INSTALL) -m 644
+COPY = cp
+TOUCH = exit >
+
+#### End of system configuration section. ####
+
+preload =
+
+libpath = . $(topdir)
+LIBPATH = -L. -L$(topdir)
+DEFFILE =
+
+CLEANFILES = mkmf.log
+DISTCLEANFILES =
+DISTCLEANDIRS =
+
+extout = $(topdir)/.ext
+extout_prefix = $(extout)$(target_prefix)/
+target_prefix = /mathn
+LOCAL_LIBS =
+LIBS = $(LIBRUBYARG_SHARED) -lpthread -lgmp -ldl -lcrypt -lm -lc
+ORIG_SRCS = rational.c
+SRCS = $(ORIG_SRCS)
+OBJS = rational.o
+HDRS = $(srcdir)/extconf.h
+TARGET = rational
+TARGET_NAME = rational
+TARGET_ENTRY = Init_$(TARGET_NAME)
+DLLIB = $(TARGET).so
+EXTSTATIC =
+STATIC_LIB = $(TARGET).a
+
+TIMESTAMP_DIR = $(extout)/.timestamp
+BINDIR = $(extout)/bin
+RUBYCOMMONDIR = $(extout)/common
+RUBYLIBDIR = $(RUBYCOMMONDIR)$(target_prefix)
+RUBYARCHDIR = $(extout)/$(arch)$(target_prefix)
+HDRDIR = $(extout)/include/ruby$(target_prefix)
+ARCHHDRDIR = $(extout)/include/$(arch)/ruby$(target_prefix)
+
+TARGET_SO = $(RUBYARCHDIR)/$(DLLIB)
+CLEANLIBS = $(RUBYARCHDIR)/$(TARGET).so
+CLEANOBJS = *.o *.bak
+
+all: install
+static: all
+.PHONY: all install static install-so install-rb
+.PHONY: clean clean-so clean-static clean-rb
+
+clean-static::
+clean-rb-default::
+clean-rb::
+clean-so::
+clean: clean-so clean-static clean-rb-default clean-rb
+ -$(Q)$(RM) $(CLEANLIBS) $(CLEANOBJS) $(CLEANFILES) .*.time
+
+distclean-rb-default::
+distclean-rb::
+distclean-so::
+distclean-static::
+distclean: clean distclean-so distclean-static distclean-rb-default distclean-rb
+ -$(Q)$(RM) Makefile $(RUBY_EXTCONF_H) conftest.* mkmf.log
+ -$(Q)$(RM) core ruby$(EXEEXT) *~ $(DISTCLEANFILES)
+ -$(Q)$(RMDIRS) $(DISTCLEANDIRS) 2> /dev/null || true
+
+realclean: distclean
+install: install-so install-rb
+
+install-so: $(RUBYARCHDIR)/$(DLLIB)
+clean-so::
+ -$(Q)$(RM) $(RUBYARCHDIR)/$(DLLIB)
+ -$(Q)$(RMDIRS) $(RUBYARCHDIR) 2> /dev/null || true
+clean-static::
+ -$(Q)$(RM) $(STATIC_LIB)
+install-rb: pre-install-rb install-rb-default
+install-rb-default: pre-install-rb-default
+pre-install-rb: Makefile
+pre-install-rb-default: Makefile
+pre-install-rb-default:
+ @$(NULLCMD)
+$(TIMESTAMP_DIR)/.RUBYARCHDIR.-.mathn.time:
+ $(Q) $(MAKEDIRS) $(@D) $(RUBYARCHDIR)
+ $(Q) $(TOUCH) $@
+
+site-install: site-install-so site-install-rb
+site-install-so: install-so
+site-install-rb: install-rb
+
+.SUFFIXES: .c .m .cc .mm .cxx .cpp .o .S
+
+.cc.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<
+
+.cc.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -S $<
+
+.mm.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<
+
+.mm.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -S $<
+
+.cxx.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<
+
+.cxx.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -S $<
+
+.cpp.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<
+
+.cpp.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -S $<
+
+.c.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -c $<
+
+.c.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -S $<
+
+.m.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -c $<
+
+.m.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -S $<
+
+$(RUBYARCHDIR)/$(DLLIB): $(OBJS) Makefile $(TIMESTAMP_DIR)/.RUBYARCHDIR.-.mathn.time
+ $(ECHO) linking shared-object mathn/$(DLLIB)
+ -$(Q)$(RM) $(@)
+ $(Q) $(LDSHARED) -o $@ $(OBJS) $(LIBPATH) $(DLDFLAGS) $(LOCAL_LIBS) $(LIBS)
+
+$(STATIC_LIB): $(OBJS)
+ -$(Q)$(RM) $(@)
+ $(ECHO) linking static-library $(@)
+ $(Q) $(AR) cru $@ $(OBJS)
+ -$(Q)ranlib $(@) 2> /dev/null || true
+
+$(OBJS): $(HDRS) $(ruby_headers)
diff --git a/jni/ruby/ext/mathn/rational/extconf.h b/jni/ruby/ext/mathn/rational/extconf.h
new file mode 100644
index 0000000..cda0cc8
--- /dev/null
+++ b/jni/ruby/ext/mathn/rational/extconf.h
@@ -0,0 +1,3 @@
+#ifndef EXTCONF_H
+#define EXTCONF_H
+#endif
diff --git a/jni/ruby/ext/mathn/rational/extconf.rb b/jni/ruby/ext/mathn/rational/extconf.rb
new file mode 100644
index 0000000..ba76306
--- /dev/null
+++ b/jni/ruby/ext/mathn/rational/extconf.rb
@@ -0,0 +1,3 @@
+require "mkmf"
+
+create_makefile "mathn/rational"
diff --git a/jni/ruby/ext/mathn/rational/rational.c b/jni/ruby/ext/mathn/rational/rational.c
new file mode 100644
index 0000000..2ac5999
--- /dev/null
+++ b/jni/ruby/ext/mathn/rational/rational.c
@@ -0,0 +1,7 @@
+extern void nurat_canonicalization(int);
+
+void
+Init_rational(void)
+{
+ nurat_canonicalization(1);
+}
diff --git a/jni/ruby/ext/nkf/Makefile b/jni/ruby/ext/nkf/Makefile
new file mode 100644
index 0000000..dd18819
--- /dev/null
+++ b/jni/ruby/ext/nkf/Makefile
@@ -0,0 +1,302 @@
+
+SHELL = /bin/sh
+
+# V=0 quiet, V=1 verbose. other values don't work.
+V = 0
+Q1 = $(V:1=)
+Q = $(Q1:0=@)
+ECHO1 = $(V:1=@:)
+ECHO = $(ECHO1:0=@echo)
+NULLCMD = :
+
+#### Start of system configuration section. ####
+top_srcdir = $(topdir)/.
+srcdir = $(top_srcdir)/ext/nkf
+topdir = ../..
+hdrdir = $(top_srcdir)/include
+arch_hdrdir = $(extout)/include/$(arch)
+PATH_SEPARATOR = :
+VPATH = $(srcdir):$(arch_hdrdir)/ruby:$(hdrdir)/ruby
+RUBYLIB =
+RUBYOPT = -
+prefix = $(DESTDIR)/usr/local
+rubysitearchprefix = $(rubylibprefix)/$(sitearch)
+rubyarchprefix = $(rubylibprefix)/$(arch)
+rubylibprefix = $(libdir)/$(RUBY_BASE_NAME)
+exec_prefix = $(prefix)
+vendorarchhdrdir = $(vendorhdrdir)/$(sitearch)
+sitearchhdrdir = $(sitehdrdir)/$(sitearch)
+rubyarchhdrdir = $(rubyhdrdir)/$(arch)
+vendorhdrdir = $(rubyhdrdir)/vendor_ruby
+sitehdrdir = $(rubyhdrdir)/site_ruby
+rubyhdrdir = $(includedir)/$(RUBY_VERSION_NAME)
+vendorarchdir = $(vendorlibdir)/$(sitearch)
+vendorlibdir = $(vendordir)/$(ruby_version)
+vendordir = $(rubylibprefix)/vendor_ruby
+sitearchdir = $(sitelibdir)/$(sitearch)
+sitelibdir = $(sitedir)/$(ruby_version)
+sitedir = $(rubylibprefix)/site_ruby
+rubyarchdir = $(rubylibdir)/$(arch)
+rubylibdir = $(rubylibprefix)/$(ruby_version)
+sitearchincludedir = $(includedir)/$(sitearch)
+archincludedir = $(includedir)/$(arch)
+sitearchlibdir = $(libdir)/$(sitearch)
+archlibdir = $(libdir)/$(arch)
+ridir = $(datarootdir)/$(RI_BASE_NAME)
+mandir = $(datarootdir)/man
+localedir = $(datarootdir)/locale
+libdir = $(exec_prefix)/lib
+psdir = $(docdir)
+pdfdir = $(docdir)
+dvidir = $(docdir)
+htmldir = $(docdir)
+infodir = $(datarootdir)/info
+docdir = $(datarootdir)/doc/$(PACKAGE)
+oldincludedir = $(DESTDIR)/usr/include
+includedir = $(prefix)/include
+localstatedir = $(prefix)/var
+sharedstatedir = $(prefix)/com
+sysconfdir = $(prefix)/etc
+datadir = $(datarootdir)
+datarootdir = $(prefix)/share
+libexecdir = $(exec_prefix)/libexec
+sbindir = $(exec_prefix)/sbin
+bindir = $(exec_prefix)/bin
+archdir = $(rubyarchdir)
+
+
+CC = gcc
+CXX = g++
+LIBRUBY = $(LIBRUBY_SO)
+LIBRUBY_A = lib$(RUBY_SO_NAME)-static.a
+LIBRUBYARG_SHARED = -Wl,-R$(libdir) -L$(libdir) -l$(RUBY_SO_NAME)
+LIBRUBYARG_STATIC = -Wl,-R$(libdir) -L$(libdir) -l$(RUBY_SO_NAME)-static
+empty =
+OUTFLAG = -o $(empty)
+COUTFLAG = -o $(empty)
+
+RUBY_EXTCONF_H = extconf.h
+cflags = $(optflags) $(debugflags) $(warnflags)
+optflags = -O3 -fno-fast-math
+debugflags = -ggdb3
+warnflags = -Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wunused-variable -Wpointer-arith -Wwrite-strings -Wdeclaration-after-statement -Wimplicit-function-declaration -Wdeprecated-declarations -Wno-packed-bitfield-compat
+CCDLFLAGS = -fPIC
+CFLAGS = $(CCDLFLAGS) $(cflags) -fPIC $(ARCH_FLAG)
+INCFLAGS = -I. -I$(arch_hdrdir) -I$(hdrdir) -I$(srcdir)
+DEFS =
+CPPFLAGS = -DRUBY_EXTCONF_H=\"$(RUBY_EXTCONF_H)\" $(DEFS) $(cppflags)
+CXXFLAGS = $(CCDLFLAGS) $(cxxflags) $(ARCH_FLAG)
+ldflags = -L. -fstack-protector -rdynamic -Wl,-export-dynamic
+dldflags =
+ARCH_FLAG =
+DLDFLAGS = $(ldflags) $(dldflags) $(ARCH_FLAG)
+LDSHARED = $(CC) -shared
+LDSHAREDXX = $(CXX) -shared
+AR = ar
+EXEEXT =
+
+RUBY_INSTALL_NAME = $(RUBY_BASE_NAME)
+RUBY_SO_NAME = ruby
+RUBYW_INSTALL_NAME =
+RUBY_VERSION_NAME = $(RUBY_BASE_NAME)-$(ruby_version)
+RUBYW_BASE_NAME = rubyw
+RUBY_BASE_NAME = ruby
+
+arch = x86_64-linux
+sitearch = $(arch)
+ruby_version = 2.2.0
+ruby = $(topdir)/miniruby -I'$(topdir)' -I'$(top_srcdir)/lib' -I'$(extout)/$(arch)' -I'$(extout)/common'
+RUBY = $(ruby)
+ruby_headers = $(hdrdir)/ruby.h $(hdrdir)/ruby/ruby.h $(hdrdir)/ruby/defines.h $(hdrdir)/ruby/missing.h $(hdrdir)/ruby/intern.h $(hdrdir)/ruby/st.h $(hdrdir)/ruby/subst.h $(arch_hdrdir)/ruby/config.h $(RUBY_EXTCONF_H)
+
+RM = rm -f
+RM_RF = $(RUBY) -run -e rm -- -rf
+RMDIRS = rmdir --ignore-fail-on-non-empty -p
+MAKEDIRS = /bin/mkdir -p
+INSTALL = /usr/bin/install -c
+INSTALL_PROG = $(INSTALL) -m 0755
+INSTALL_DATA = $(INSTALL) -m 644
+COPY = cp
+TOUCH = exit >
+
+#### End of system configuration section. ####
+
+preload =
+
+libpath = . $(topdir)
+LIBPATH = -L. -L$(topdir)
+DEFFILE =
+
+CLEANFILES = mkmf.log
+DISTCLEANFILES =
+DISTCLEANDIRS =
+
+extout = $(topdir)/.ext
+extout_prefix = $(extout)$(target_prefix)/
+target_prefix =
+LOCAL_LIBS =
+LIBS = $(LIBRUBYARG_SHARED) -lpthread -lgmp -ldl -lcrypt -lm -lc
+ORIG_SRCS = nkf.c
+SRCS = $(ORIG_SRCS)
+OBJS = nkf.o
+HDRS = $(srcdir)/extconf.h
+TARGET = nkf
+TARGET_NAME = nkf
+TARGET_ENTRY = Init_$(TARGET_NAME)
+DLLIB = $(TARGET).so
+EXTSTATIC =
+STATIC_LIB = $(TARGET).a
+
+TIMESTAMP_DIR = $(extout)/.timestamp
+BINDIR = $(extout)/bin
+RUBYCOMMONDIR = $(extout)/common
+RUBYLIBDIR = $(RUBYCOMMONDIR)$(target_prefix)
+RUBYARCHDIR = $(extout)/$(arch)$(target_prefix)
+HDRDIR = $(extout)/include/ruby$(target_prefix)
+ARCHHDRDIR = $(extout)/include/$(arch)/ruby$(target_prefix)
+
+TARGET_SO = $(RUBYARCHDIR)/$(DLLIB)
+CLEANLIBS = $(RUBYARCHDIR)/$(TARGET).so
+CLEANOBJS = *.o *.bak
+
+all: install
+static: all
+.PHONY: all install static install-so install-rb
+.PHONY: clean clean-so clean-static clean-rb
+
+clean-static::
+clean-rb-default::
+clean-rb::
+clean-so::
+clean: clean-so clean-static clean-rb-default clean-rb
+ -$(Q)$(RM) $(CLEANLIBS) $(CLEANOBJS) $(CLEANFILES) .*.time
+
+distclean-rb-default::
+distclean-rb::
+distclean-so::
+distclean-static::
+distclean: clean distclean-so distclean-static distclean-rb-default distclean-rb
+ -$(Q)$(RM) Makefile $(RUBY_EXTCONF_H) conftest.* mkmf.log
+ -$(Q)$(RM) core ruby$(EXEEXT) *~ $(DISTCLEANFILES)
+ -$(Q)$(RMDIRS) $(DISTCLEANDIRS) 2> /dev/null || true
+
+realclean: distclean
+install: install-so install-rb
+
+install-so: $(RUBYARCHDIR)/$(DLLIB)
+clean-so::
+ -$(Q)$(RM) $(RUBYARCHDIR)/$(DLLIB)
+ -$(Q)$(RMDIRS) $(RUBYARCHDIR) 2> /dev/null || true
+clean-static::
+ -$(Q)$(RM) $(STATIC_LIB)
+install-rb: pre-install-rb install-rb-default
+install-rb-default: pre-install-rb-default
+pre-install-rb: Makefile
+pre-install-rb-default: Makefile
+pre-install-rb-default: $(TIMESTAMP_DIR)/.RUBYLIBDIR.time
+install-rb-default: $(RUBYLIBDIR)/kconv.rb
+$(RUBYLIBDIR)/kconv.rb: $(srcdir)/lib/kconv.rb $(TIMESTAMP_DIR)/.RUBYLIBDIR.time
+ $(Q) $(COPY) $(srcdir)/lib/kconv.rb $(@D)
+clean-rb-default::
+ -$(Q)$(RM) $(RUBYLIBDIR)/kconv.rb
+pre-install-rb-default:
+ $(ECHO) installing default nkf libraries
+clean-rb-default::
+ -$(Q)$(RMDIRS) $(RUBYLIBDIR) 2> /dev/null || true
+$(TIMESTAMP_DIR)/.RUBYARCHDIR.time:
+ $(Q) $(MAKEDIRS) $(@D) $(RUBYARCHDIR)
+ $(Q) $(TOUCH) $@
+$(TIMESTAMP_DIR)/.RUBYLIBDIR.time:
+ $(Q) $(MAKEDIRS) $(@D) $(RUBYLIBDIR)
+ $(Q) $(TOUCH) $@
+
+site-install: site-install-so site-install-rb
+site-install-so: install-so
+site-install-rb: install-rb
+
+.SUFFIXES: .c .m .cc .mm .cxx .cpp .o .S
+
+.cc.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<
+
+.cc.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -S $<
+
+.mm.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<
+
+.mm.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -S $<
+
+.cxx.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<
+
+.cxx.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -S $<
+
+.cpp.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<
+
+.cpp.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -S $<
+
+.c.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -c $<
+
+.c.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -S $<
+
+.m.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -c $<
+
+.m.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -S $<
+
+$(RUBYARCHDIR)/$(DLLIB): $(OBJS) Makefile $(TIMESTAMP_DIR)/.RUBYARCHDIR.time
+ $(ECHO) linking shared-object $(DLLIB)
+ -$(Q)$(RM) $(@)
+ $(Q) $(LDSHARED) -o $@ $(OBJS) $(LIBPATH) $(DLDFLAGS) $(LOCAL_LIBS) $(LIBS)
+
+$(STATIC_LIB): $(OBJS)
+ -$(Q)$(RM) $(@)
+ $(ECHO) linking static-library $(@)
+ $(Q) $(AR) cru $@ $(OBJS)
+ -$(Q)ranlib $(@) 2> /dev/null || true
+
+###
+$(OBJS): $(RUBY_EXTCONF_H)
+
+# BSD make needs "nkf.o: nkf.c" dependency BEFORE "nkf.o: nkf-utf8/nkf.c".
+# It seems BSD make searches the target for implicit rule in dependencies at first.
+nkf.o: nkf.c
+
+# AUTOGENERATED DEPENDENCIES START
+nkf.o: $(RUBY_EXTCONF_H)
+nkf.o: $(arch_hdrdir)/ruby/config.h
+nkf.o: $(hdrdir)/ruby/defines.h
+nkf.o: $(hdrdir)/ruby/encoding.h
+nkf.o: $(hdrdir)/ruby/intern.h
+nkf.o: $(hdrdir)/ruby/missing.h
+nkf.o: $(hdrdir)/ruby/oniguruma.h
+nkf.o: $(hdrdir)/ruby/ruby.h
+nkf.o: $(hdrdir)/ruby/st.h
+nkf.o: $(hdrdir)/ruby/subst.h
+nkf.o: nkf-utf8/config.h
+nkf.o: nkf-utf8/nkf.c
+nkf.o: nkf-utf8/nkf.h
+nkf.o: nkf-utf8/utf8tbl.c
+nkf.o: nkf-utf8/utf8tbl.h
+nkf.o: nkf.c
+# AUTOGENERATED DEPENDENCIES END
diff --git a/jni/ruby/ext/nkf/depend b/jni/ruby/ext/nkf/depend
new file mode 100644
index 0000000..1642150
--- /dev/null
+++ b/jni/ruby/ext/nkf/depend
@@ -0,0 +1,22 @@
+# BSD make needs "nkf.o: nkf.c" dependency BEFORE "nkf.o: nkf-utf8/nkf.c".
+# It seems BSD make searches the target for implicit rule in dependencies at first.
+nkf.o: nkf.c
+
+# AUTOGENERATED DEPENDENCIES START
+nkf.o: $(RUBY_EXTCONF_H)
+nkf.o: $(arch_hdrdir)/ruby/config.h
+nkf.o: $(hdrdir)/ruby/defines.h
+nkf.o: $(hdrdir)/ruby/encoding.h
+nkf.o: $(hdrdir)/ruby/intern.h
+nkf.o: $(hdrdir)/ruby/missing.h
+nkf.o: $(hdrdir)/ruby/oniguruma.h
+nkf.o: $(hdrdir)/ruby/ruby.h
+nkf.o: $(hdrdir)/ruby/st.h
+nkf.o: $(hdrdir)/ruby/subst.h
+nkf.o: nkf-utf8/config.h
+nkf.o: nkf-utf8/nkf.c
+nkf.o: nkf-utf8/nkf.h
+nkf.o: nkf-utf8/utf8tbl.c
+nkf.o: nkf-utf8/utf8tbl.h
+nkf.o: nkf.c
+# AUTOGENERATED DEPENDENCIES END
diff --git a/jni/ruby/ext/nkf/extconf.h b/jni/ruby/ext/nkf/extconf.h
new file mode 100644
index 0000000..cda0cc8
--- /dev/null
+++ b/jni/ruby/ext/nkf/extconf.h
@@ -0,0 +1,3 @@
+#ifndef EXTCONF_H
+#define EXTCONF_H
+#endif
diff --git a/jni/ruby/ext/nkf/extconf.rb b/jni/ruby/ext/nkf/extconf.rb
new file mode 100644
index 0000000..710662f
--- /dev/null
+++ b/jni/ruby/ext/nkf/extconf.rb
@@ -0,0 +1,2 @@
+require 'mkmf'
+create_makefile('nkf')
diff --git a/jni/ruby/ext/nkf/lib/kconv.rb b/jni/ruby/ext/nkf/lib/kconv.rb
new file mode 100644
index 0000000..25e04ed
--- /dev/null
+++ b/jni/ruby/ext/nkf/lib/kconv.rb
@@ -0,0 +1,282 @@
+#
+# kconv.rb - Kanji Converter.
+#
+# $Id: kconv.rb 30112 2010-12-07 11:47:39Z naruse $
+#
+# ----
+#
+# kconv.rb implements the Kconv class for Kanji Converter. Additionally,
+# some methods in String classes are added to allow easy conversion.
+#
+
+require 'nkf'
+
+#
+# Kanji Converter for Ruby.
+#
+module Kconv
+ #
+ # Public Constants
+ #
+
+ #Constant of Encoding
+
+ # Auto-Detect
+ AUTO = NKF::AUTO
+ # ISO-2022-JP
+ JIS = NKF::JIS
+ # EUC-JP
+ EUC = NKF::EUC
+ # Shift_JIS
+ SJIS = NKF::SJIS
+ # BINARY
+ BINARY = NKF::BINARY
+ # NOCONV
+ NOCONV = NKF::NOCONV
+ # ASCII
+ ASCII = NKF::ASCII
+ # UTF-8
+ UTF8 = NKF::UTF8
+ # UTF-16
+ UTF16 = NKF::UTF16
+ # UTF-32
+ UTF32 = NKF::UTF32
+ # UNKNOWN
+ UNKNOWN = NKF::UNKNOWN
+
+ #
+ # Public Methods
+ #
+
+ # call-seq:
+ # Kconv.kconv(str, to_enc, from_enc=nil)
+ #
+ # Convert <code>str</code> to <code>to_enc</code>.
+ # <code>to_enc</code> and <code>from_enc</code> are given as constants of Kconv or Encoding objects.
+ def kconv(str, to_enc, from_enc=nil)
+ opt = ''
+ opt += ' --ic=' + from_enc.to_s if from_enc
+ opt += ' --oc=' + to_enc.to_s if to_enc
+
+ ::NKF::nkf(opt, str)
+ end
+ module_function :kconv
+
+ #
+ # Encode to
+ #
+
+ # call-seq:
+ # Kconv.tojis(str) => string
+ #
+ # Convert <code>str</code> to ISO-2022-JP
+ def tojis(str)
+ kconv(str, JIS)
+ end
+ module_function :tojis
+
+ # call-seq:
+ # Kconv.toeuc(str) => string
+ #
+ # Convert <code>str</code> to EUC-JP
+ def toeuc(str)
+ kconv(str, EUC)
+ end
+ module_function :toeuc
+
+ # call-seq:
+ # Kconv.tosjis(str) => string
+ #
+ # Convert <code>str</code> to Shift_JIS
+ def tosjis(str)
+ kconv(str, SJIS)
+ end
+ module_function :tosjis
+
+ # call-seq:
+ # Kconv.toutf8(str) => string
+ #
+ # Convert <code>str</code> to UTF-8
+ def toutf8(str)
+ kconv(str, UTF8)
+ end
+ module_function :toutf8
+
+ # call-seq:
+ # Kconv.toutf16(str) => string
+ #
+ # Convert <code>str</code> to UTF-16
+ def toutf16(str)
+ kconv(str, UTF16)
+ end
+ module_function :toutf16
+
+ # call-seq:
+ # Kconv.toutf32(str) => string
+ #
+ # Convert <code>str</code> to UTF-32
+ def toutf32(str)
+ kconv(str, UTF32)
+ end
+ module_function :toutf32
+
+ # call-seq:
+ # Kconv.tolocale => string
+ #
+ # Convert <code>self</code> to locale encoding
+ def tolocale(str)
+ kconv(str, Encoding.locale_charmap)
+ end
+ module_function :tolocale
+
+ #
+ # guess
+ #
+
+ # call-seq:
+ # Kconv.guess(str) => encoding
+ #
+ # Guess input encoding by NKF.guess
+ def guess(str)
+ ::NKF::guess(str)
+ end
+ module_function :guess
+
+ #
+ # isEncoding
+ #
+
+ # call-seq:
+ # Kconv.iseuc(str) => true or false
+ #
+ # Returns whether input encoding is EUC-JP or not.
+ #
+ # *Note* don't expect this return value is MatchData.
+ def iseuc(str)
+ str.dup.force_encoding(EUC).valid_encoding?
+ end
+ module_function :iseuc
+
+ # call-seq:
+ # Kconv.issjis(str) => true or false
+ #
+ # Returns whether input encoding is Shift_JIS or not.
+ def issjis(str)
+ str.dup.force_encoding(SJIS).valid_encoding?
+ end
+ module_function :issjis
+
+ # call-seq:
+ # Kconv.isjis(str) => true or false
+ #
+ # Returns whether input encoding is ISO-2022-JP or not.
+ def isjis(str)
+ /\A [\t\n\r\x20-\x7E]*
+ (?:
+ (?:\x1b \x28 I [\x21-\x7E]*
+ |\x1b \x28 J [\x21-\x7E]*
+ |\x1b \x24 @ (?:[\x21-\x7E]{2})*
+ |\x1b \x24 B (?:[\x21-\x7E]{2})*
+ |\x1b \x24 \x28 D (?:[\x21-\x7E]{2})*
+ )*
+ \x1b \x28 B [\t\n\r\x20-\x7E]*
+ )*
+ \z/nox =~ str.dup.force_encoding('BINARY') ? true : false
+ end
+ module_function :isjis
+
+ # call-seq:
+ # Kconv.isutf8(str) => true or false
+ #
+ # Returns whether input encoding is UTF-8 or not.
+ def isutf8(str)
+ str.dup.force_encoding(UTF8).valid_encoding?
+ end
+ module_function :isutf8
+end
+
+class String
+ # call-seq:
+ # String#kconv(to_enc, from_enc)
+ #
+ # Convert <code>self</code> to <code>to_enc</code>.
+ # <code>to_enc</code> and <code>from_enc</code> are given as constants of Kconv or Encoding objects.
+ def kconv(to_enc, from_enc=nil)
+ from_enc = self.encoding if !from_enc && self.encoding != Encoding.list[0]
+ Kconv::kconv(self, to_enc, from_enc)
+ end
+
+ #
+ # to Encoding
+ #
+
+ # call-seq:
+ # String#tojis => string
+ #
+ # Convert <code>self</code> to ISO-2022-JP
+ def tojis; Kconv.tojis(self) end
+
+ # call-seq:
+ # String#toeuc => string
+ #
+ # Convert <code>self</code> to EUC-JP
+ def toeuc; Kconv.toeuc(self) end
+
+ # call-seq:
+ # String#tosjis => string
+ #
+ # Convert <code>self</code> to Shift_JIS
+ def tosjis; Kconv.tosjis(self) end
+
+ # call-seq:
+ # String#toutf8 => string
+ #
+ # Convert <code>self</code> to UTF-8
+ def toutf8; Kconv.toutf8(self) end
+
+ # call-seq:
+ # String#toutf16 => string
+ #
+ # Convert <code>self</code> to UTF-16
+ def toutf16; Kconv.toutf16(self) end
+
+ # call-seq:
+ # String#toutf32 => string
+ #
+ # Convert <code>self</code> to UTF-32
+ def toutf32; Kconv.toutf32(self) end
+
+ # call-seq:
+ # String#tolocale => string
+ #
+ # Convert <code>self</code> to locale encoding
+ def tolocale; Kconv.tolocale(self) end
+
+ #
+ # is Encoding
+ #
+
+ # call-seq:
+ # String#iseuc => true or false
+ #
+ # Returns whether <code>self</code>'s encoding is EUC-JP or not.
+ def iseuc; Kconv.iseuc(self) end
+
+ # call-seq:
+ # String#issjis => true or false
+ #
+ # Returns whether <code>self</code>'s encoding is Shift_JIS or not.
+ def issjis; Kconv.issjis(self) end
+
+ # call-seq:
+ # String#isjis => true or false
+ #
+ # Returns whether <code>self</code>'s encoding is ISO-2022-JP or not.
+ def isjis; Kconv.isjis(self) end
+
+ # call-seq:
+ # String#isutf8 => true or false
+ #
+ # Returns whether <code>self</code>'s encoding is UTF-8 or not.
+ def isutf8; Kconv.isutf8(self) end
+end
diff --git a/jni/ruby/ext/nkf/nkf-utf8/config.h b/jni/ruby/ext/nkf/nkf-utf8/config.h
new file mode 100644
index 0000000..51dc2a5
--- /dev/null
+++ b/jni/ruby/ext/nkf/nkf-utf8/config.h
@@ -0,0 +1,51 @@
+#ifndef _CONFIG_H_
+#define _CONFIG_H_
+
+/* UTF8 input and output */
+#define UTF8_INPUT_ENABLE
+#define UTF8_OUTPUT_ENABLE
+
+/* invert characters invalid in Shift_JIS to CP932 */
+#define SHIFTJIS_CP932
+
+/* fix input encoding when given by option */
+#define INPUT_CODE_FIX
+
+/* --overwrite option */
+/* by Satoru Takabayashi <ccsatoru@vega.aichi-u.ac.jp> */
+#define OVERWRITE
+
+/* --cap-input, --url-input option */
+#define INPUT_OPTION
+
+/* --numchar-input option */
+#define NUMCHAR_OPTION
+
+/* --debug, --no-output option */
+#define CHECK_OPTION
+
+/* JIS X0212 */
+#define X0212_ENABLE
+
+/* --exec-in, --exec-out option
+ * require pipe, fork, execvp and so on.
+ * please undef this on MS-DOS, MinGW
+ * this is still buggy arround child process
+ */
+/* #define EXEC_IO */
+
+/* Unicode Normalization */
+#define UNICODE_NORMALIZATION
+
+/*
+ * Select Default Output Encoding
+ *
+ */
+
+/* #define DEFAULT_CODE_JIS */
+/* #define DEFAULT_CODE_SJIS */
+/* #define DEFAULT_CODE_WINDOWS_31J */
+/* #define DEFAULT_CODE_EUC */
+/* #define DEFAULT_CODE_UTF8 */
+
+#endif /* _CONFIG_H_ */
diff --git a/jni/ruby/ext/nkf/nkf-utf8/nkf.c b/jni/ruby/ext/nkf/nkf-utf8/nkf.c
new file mode 100644
index 0000000..fcf95c4
--- /dev/null
+++ b/jni/ruby/ext/nkf/nkf-utf8/nkf.c
@@ -0,0 +1,7191 @@
+/*
+ * Copyright (c) 1987, Fujitsu LTD. (Itaru ICHIKAWA).
+ * Copyright (c) 1996-2013, The nkf Project.
+ *
+ * This software is provided 'as-is', without any express or implied
+ * warranty. In no event will the authors be held liable for any damages
+ * arising from the use of this software.
+ *
+ * Permission is granted to anyone to use this software for any purpose,
+ * including commercial applications, and to alter it and redistribute it
+ * freely, subject to the following restrictions:
+ *
+ * 1. The origin of this software must not be misrepresented; you must not
+ * claim that you wrote the original software. If you use this software
+ * in a product, an acknowledgment in the product documentation would be
+ * appreciated but is not required.
+ *
+ * 2. Altered source versions must be plainly marked as such, and must not be
+ * misrepresented as being the original software.
+ *
+ * 3. This notice may not be removed or altered from any source distribution.
+ */
+#define NKF_VERSION "2.1.3"
+#define NKF_RELEASE_DATE "2013-11-22"
+#define COPY_RIGHT \
+ "Copyright (C) 1987, FUJITSU LTD. (I.Ichikawa).\n" \
+ "Copyright (C) 1996-2013, The nkf Project."
+
+#include "config.h"
+#include "nkf.h"
+#include "utf8tbl.h"
+#ifdef __WIN32__
+#include <windows.h>
+#include <locale.h>
+#endif
+#if defined(__OS2__)
+# define INCL_DOS
+# define INCL_DOSERRORS
+# include <os2.h>
+#endif
+#include <assert.h>
+
+
+/* state of output_mode and input_mode
+
+ c2 0 means ASCII
+ JIS_X_0201_1976_K
+ ISO_8859_1
+ JIS_X_0208
+ EOF all termination
+ c1 32bit data
+
+ */
+
+/* MIME ENCODE */
+
+#define FIXED_MIME 7
+#define STRICT_MIME 8
+
+/* byte order */
+enum byte_order {
+ ENDIAN_BIG = 1,
+ ENDIAN_LITTLE = 2,
+ ENDIAN_2143 = 3,
+ ENDIAN_3412 = 4
+};
+
+/* ASCII CODE */
+
+#define BS 0x08
+#define TAB 0x09
+#define LF 0x0a
+#define CR 0x0d
+#define ESC 0x1b
+#define SP 0x20
+#define DEL 0x7f
+#define SI 0x0f
+#define SO 0x0e
+#define SS2 0x8e
+#define SS3 0x8f
+#define CRLF 0x0D0A
+
+
+/* encodings */
+
+enum nkf_encodings {
+ ASCII,
+ ISO_8859_1,
+ ISO_2022_JP,
+ CP50220,
+ CP50221,
+ CP50222,
+ ISO_2022_JP_1,
+ ISO_2022_JP_3,
+ ISO_2022_JP_2004,
+ SHIFT_JIS,
+ WINDOWS_31J,
+ CP10001,
+ EUC_JP,
+ EUCJP_NKF,
+ CP51932,
+ EUCJP_MS,
+ EUCJP_ASCII,
+ SHIFT_JISX0213,
+ SHIFT_JIS_2004,
+ EUC_JISX0213,
+ EUC_JIS_2004,
+ UTF_8,
+ UTF_8N,
+ UTF_8_BOM,
+ UTF8_MAC,
+ UTF_16,
+ UTF_16BE,
+ UTF_16BE_BOM,
+ UTF_16LE,
+ UTF_16LE_BOM,
+ UTF_32,
+ UTF_32BE,
+ UTF_32BE_BOM,
+ UTF_32LE,
+ UTF_32LE_BOM,
+ BINARY,
+ NKF_ENCODING_TABLE_SIZE,
+ JIS_X_0201_1976_K = 0x1013, /* I */ /* JIS C 6220-1969 */
+ /* JIS_X_0201_1976_R = 0x1014, */ /* J */ /* JIS C 6220-1969 */
+ /* JIS_X_0208_1978 = 0x1040, */ /* @ */ /* JIS C 6226-1978 */
+ /* JIS_X_0208_1983 = 0x1087, */ /* B */ /* JIS C 6226-1983 */
+ JIS_X_0208 = 0x1168, /* @B */
+ JIS_X_0212 = 0x1159, /* D */
+ /* JIS_X_0213_2000_1 = 0x1228, */ /* O */
+ JIS_X_0213_2 = 0x1229, /* P */
+ JIS_X_0213_1 = 0x1233 /* Q */
+};
+
+static nkf_char s_iconv(nkf_char c2, nkf_char c1, nkf_char c0);
+static nkf_char e_iconv(nkf_char c2, nkf_char c1, nkf_char c0);
+static nkf_char w_iconv(nkf_char c2, nkf_char c1, nkf_char c0);
+static nkf_char w_iconv16(nkf_char c2, nkf_char c1, nkf_char c0);
+static nkf_char w_iconv32(nkf_char c2, nkf_char c1, nkf_char c0);
+static void j_oconv(nkf_char c2, nkf_char c1);
+static void s_oconv(nkf_char c2, nkf_char c1);
+static void e_oconv(nkf_char c2, nkf_char c1);
+static void w_oconv(nkf_char c2, nkf_char c1);
+static void w_oconv16(nkf_char c2, nkf_char c1);
+static void w_oconv32(nkf_char c2, nkf_char c1);
+
+typedef struct {
+ const char *name;
+ nkf_char (*iconv)(nkf_char c2, nkf_char c1, nkf_char c0);
+ void (*oconv)(nkf_char c2, nkf_char c1);
+} nkf_native_encoding;
+
+nkf_native_encoding NkfEncodingASCII = { "ASCII", e_iconv, e_oconv };
+nkf_native_encoding NkfEncodingISO_2022_JP = { "ISO-2022-JP", e_iconv, j_oconv };
+nkf_native_encoding NkfEncodingShift_JIS = { "Shift_JIS", s_iconv, s_oconv };
+nkf_native_encoding NkfEncodingEUC_JP = { "EUC-JP", e_iconv, e_oconv };
+nkf_native_encoding NkfEncodingUTF_8 = { "UTF-8", w_iconv, w_oconv };
+nkf_native_encoding NkfEncodingUTF_16 = { "UTF-16", w_iconv16, w_oconv16 };
+nkf_native_encoding NkfEncodingUTF_32 = { "UTF-32", w_iconv32, w_oconv32 };
+
+typedef struct {
+ const int id;
+ const char *name;
+ const nkf_native_encoding *base_encoding;
+} nkf_encoding;
+
+nkf_encoding nkf_encoding_table[] = {
+ {ASCII, "US-ASCII", &NkfEncodingASCII},
+ {ISO_8859_1, "ISO-8859-1", &NkfEncodingASCII},
+ {ISO_2022_JP, "ISO-2022-JP", &NkfEncodingISO_2022_JP},
+ {CP50220, "CP50220", &NkfEncodingISO_2022_JP},
+ {CP50221, "CP50221", &NkfEncodingISO_2022_JP},
+ {CP50222, "CP50222", &NkfEncodingISO_2022_JP},
+ {ISO_2022_JP_1, "ISO-2022-JP-1", &NkfEncodingISO_2022_JP},
+ {ISO_2022_JP_3, "ISO-2022-JP-3", &NkfEncodingISO_2022_JP},
+ {ISO_2022_JP_2004, "ISO-2022-JP-2004", &NkfEncodingISO_2022_JP},
+ {SHIFT_JIS, "Shift_JIS", &NkfEncodingShift_JIS},
+ {WINDOWS_31J, "Windows-31J", &NkfEncodingShift_JIS},
+ {CP10001, "CP10001", &NkfEncodingShift_JIS},
+ {EUC_JP, "EUC-JP", &NkfEncodingEUC_JP},
+ {EUCJP_NKF, "eucJP-nkf", &NkfEncodingEUC_JP},
+ {CP51932, "CP51932", &NkfEncodingEUC_JP},
+ {EUCJP_MS, "eucJP-MS", &NkfEncodingEUC_JP},
+ {EUCJP_ASCII, "eucJP-ASCII", &NkfEncodingEUC_JP},
+ {SHIFT_JISX0213, "Shift_JISX0213", &NkfEncodingShift_JIS},
+ {SHIFT_JIS_2004, "Shift_JIS-2004", &NkfEncodingShift_JIS},
+ {EUC_JISX0213, "EUC-JISX0213", &NkfEncodingEUC_JP},
+ {EUC_JIS_2004, "EUC-JIS-2004", &NkfEncodingEUC_JP},
+ {UTF_8, "UTF-8", &NkfEncodingUTF_8},
+ {UTF_8N, "UTF-8N", &NkfEncodingUTF_8},
+ {UTF_8_BOM, "UTF-8-BOM", &NkfEncodingUTF_8},
+ {UTF8_MAC, "UTF8-MAC", &NkfEncodingUTF_8},
+ {UTF_16, "UTF-16", &NkfEncodingUTF_16},
+ {UTF_16BE, "UTF-16BE", &NkfEncodingUTF_16},
+ {UTF_16BE_BOM, "UTF-16BE-BOM", &NkfEncodingUTF_16},
+ {UTF_16LE, "UTF-16LE", &NkfEncodingUTF_16},
+ {UTF_16LE_BOM, "UTF-16LE-BOM", &NkfEncodingUTF_16},
+ {UTF_32, "UTF-32", &NkfEncodingUTF_32},
+ {UTF_32BE, "UTF-32BE", &NkfEncodingUTF_32},
+ {UTF_32BE_BOM, "UTF-32BE-BOM", &NkfEncodingUTF_32},
+ {UTF_32LE, "UTF-32LE", &NkfEncodingUTF_32},
+ {UTF_32LE_BOM, "UTF-32LE-BOM", &NkfEncodingUTF_32},
+ {BINARY, "BINARY", &NkfEncodingASCII},
+ {-1, NULL, NULL}
+};
+
+struct {
+ const char *name;
+ const int id;
+} encoding_name_to_id_table[] = {
+ {"US-ASCII", ASCII},
+ {"ASCII", ASCII},
+ {"646", ASCII},
+ {"ROMAN8", ASCII},
+ {"ISO-2022-JP", ISO_2022_JP},
+ {"ISO2022JP-CP932", CP50220},
+ {"CP50220", CP50220},
+ {"CP50221", CP50221},
+ {"CSISO2022JP", CP50221},
+ {"CP50222", CP50222},
+ {"ISO-2022-JP-1", ISO_2022_JP_1},
+ {"ISO-2022-JP-3", ISO_2022_JP_3},
+ {"ISO-2022-JP-2004", ISO_2022_JP_2004},
+ {"SHIFT_JIS", SHIFT_JIS},
+ {"SJIS", SHIFT_JIS},
+ {"MS_Kanji", SHIFT_JIS},
+ {"PCK", SHIFT_JIS},
+ {"WINDOWS-31J", WINDOWS_31J},
+ {"CSWINDOWS31J", WINDOWS_31J},
+ {"CP932", WINDOWS_31J},
+ {"MS932", WINDOWS_31J},
+ {"CP10001", CP10001},
+ {"EUCJP", EUC_JP},
+ {"EUC-JP", EUC_JP},
+ {"EUCJP-NKF", EUCJP_NKF},
+ {"CP51932", CP51932},
+ {"EUC-JP-MS", EUCJP_MS},
+ {"EUCJP-MS", EUCJP_MS},
+ {"EUCJPMS", EUCJP_MS},
+ {"EUC-JP-ASCII", EUCJP_ASCII},
+ {"EUCJP-ASCII", EUCJP_ASCII},
+ {"SHIFT_JISX0213", SHIFT_JISX0213},
+ {"SHIFT_JIS-2004", SHIFT_JIS_2004},
+ {"EUC-JISX0213", EUC_JISX0213},
+ {"EUC-JIS-2004", EUC_JIS_2004},
+ {"UTF-8", UTF_8},
+ {"UTF-8N", UTF_8N},
+ {"UTF-8-BOM", UTF_8_BOM},
+ {"UTF8-MAC", UTF8_MAC},
+ {"UTF-8-MAC", UTF8_MAC},
+ {"UTF-16", UTF_16},
+ {"UTF-16BE", UTF_16BE},
+ {"UTF-16BE-BOM", UTF_16BE_BOM},
+ {"UTF-16LE", UTF_16LE},
+ {"UTF-16LE-BOM", UTF_16LE_BOM},
+ {"UTF-32", UTF_32},
+ {"UTF-32BE", UTF_32BE},
+ {"UTF-32BE-BOM", UTF_32BE_BOM},
+ {"UTF-32LE", UTF_32LE},
+ {"UTF-32LE-BOM", UTF_32LE_BOM},
+ {"BINARY", BINARY},
+ {NULL, -1}
+};
+
+#if defined(DEFAULT_CODE_JIS)
+#define DEFAULT_ENCIDX ISO_2022_JP
+#elif defined(DEFAULT_CODE_SJIS)
+#define DEFAULT_ENCIDX SHIFT_JIS
+#elif defined(DEFAULT_CODE_WINDOWS_31J)
+#define DEFAULT_ENCIDX WINDOWS_31J
+#elif defined(DEFAULT_CODE_EUC)
+#define DEFAULT_ENCIDX EUC_JP
+#elif defined(DEFAULT_CODE_UTF8)
+#define DEFAULT_ENCIDX UTF_8
+#endif
+
+
+#define is_alnum(c) \
+ (('a'<=c && c<='z')||('A'<= c && c<='Z')||('0'<=c && c<='9'))
+
+/* I don't trust portablity of toupper */
+#define nkf_toupper(c) (('a'<=c && c<='z')?(c-('a'-'A')):c)
+#define nkf_isoctal(c) ('0'<=c && c<='7')
+#define nkf_isdigit(c) ('0'<=c && c<='9')
+#define nkf_isxdigit(c) (nkf_isdigit(c) || ('a'<=c && c<='f') || ('A'<=c && c <= 'F'))
+#define nkf_isblank(c) (c == SP || c == TAB)
+#define nkf_isspace(c) (nkf_isblank(c) || c == CR || c == LF)
+#define nkf_isalpha(c) (('a' <= c && c <= 'z') || ('A' <= c && c <= 'Z'))
+#define nkf_isalnum(c) (nkf_isdigit(c) || nkf_isalpha(c))
+#define nkf_isprint(c) (SP<=c && c<='~')
+#define nkf_isgraph(c) ('!'<=c && c<='~')
+#define hex2bin(c) (('0'<=c&&c<='9') ? (c-'0') : \
+ ('A'<=c&&c<='F') ? (c-'A'+10) : \
+ ('a'<=c&&c<='f') ? (c-'a'+10) : 0)
+#define bin2hex(c) ("0123456789ABCDEF"[c&15])
+#define is_eucg3(c2) (((unsigned short)c2 >> 8) == SS3)
+#define nkf_noescape_mime(c) ((c == CR) || (c == LF) || \
+ ((c > SP) && (c < DEL) && (c != '?') && (c != '=') && (c != '_') \
+ && (c != '(') && (c != ')') && (c != '.') && (c != 0x22)))
+
+#define is_ibmext_in_sjis(c2) (CP932_TABLE_BEGIN <= c2 && c2 <= CP932_TABLE_END)
+#define nkf_byte_jisx0201_katakana_p(c) (SP <= c && c <= 0x5F)
+
+#define HOLD_SIZE 1024
+#if defined(INT_IS_SHORT)
+#define IOBUF_SIZE 2048
+#else
+#define IOBUF_SIZE 16384
+#endif
+
+#define DEFAULT_J 'B'
+#define DEFAULT_R 'B'
+
+
+#define GETA1 0x22
+#define GETA2 0x2e
+
+
+/* MIME preprocessor */
+
+#ifdef EASYWIN /*Easy Win */
+extern POINT _BufferSize;
+#endif
+
+struct input_code{
+ const char *name;
+ nkf_char stat;
+ nkf_char score;
+ nkf_char index;
+ nkf_char buf[3];
+ void (*status_func)(struct input_code *, nkf_char);
+ nkf_char (*iconv_func)(nkf_char c2, nkf_char c1, nkf_char c0);
+ int _file_stat;
+};
+
+static const char *input_codename = NULL; /* NULL: unestablished, "": BINARY */
+static nkf_encoding *input_encoding = NULL;
+static nkf_encoding *output_encoding = NULL;
+
+#if defined(UTF8_INPUT_ENABLE) || defined(UTF8_OUTPUT_ENABLE)
+/* UCS Mapping
+ * 0: Shift_JIS, eucJP-ascii
+ * 1: eucJP-ms
+ * 2: CP932, CP51932
+ * 3: CP10001
+ */
+#define UCS_MAP_ASCII 0
+#define UCS_MAP_MS 1
+#define UCS_MAP_CP932 2
+#define UCS_MAP_CP10001 3
+static int ms_ucs_map_f = UCS_MAP_ASCII;
+#endif
+#ifdef UTF8_INPUT_ENABLE
+/* no NEC special, NEC-selected IBM extended and IBM extended characters */
+static int no_cp932ext_f = FALSE;
+/* ignore ZERO WIDTH NO-BREAK SPACE */
+static int no_best_fit_chars_f = FALSE;
+static int input_endian = ENDIAN_BIG;
+static int input_bom_f = FALSE;
+static nkf_char unicode_subchar = '?'; /* the regular substitution character */
+static void (*encode_fallback)(nkf_char c) = NULL;
+static void w_status(struct input_code *, nkf_char);
+#endif
+#ifdef UTF8_OUTPUT_ENABLE
+static int output_bom_f = FALSE;
+static int output_endian = ENDIAN_BIG;
+#endif
+
+static void std_putc(nkf_char c);
+static nkf_char std_getc(FILE *f);
+static nkf_char std_ungetc(nkf_char c,FILE *f);
+
+static nkf_char broken_getc(FILE *f);
+static nkf_char broken_ungetc(nkf_char c,FILE *f);
+
+static nkf_char mime_getc(FILE *f);
+
+static void mime_putc(nkf_char c);
+
+/* buffers */
+
+#if !defined(PERL_XS) && !defined(WIN32DLL)
+static unsigned char stdibuf[IOBUF_SIZE];
+static unsigned char stdobuf[IOBUF_SIZE];
+#endif
+
+#define NKF_UNSPECIFIED (-TRUE)
+
+/* flags */
+static int unbuf_f = FALSE;
+static int estab_f = FALSE;
+static int nop_f = FALSE;
+static int binmode_f = TRUE; /* binary mode */
+static int rot_f = FALSE; /* rot14/43 mode */
+static int hira_f = FALSE; /* hira/kata henkan */
+static int alpha_f = FALSE; /* convert JIx0208 alphbet to ASCII */
+static int mime_f = MIME_DECODE_DEFAULT; /* convert MIME B base64 or Q */
+static int mime_decode_f = FALSE; /* mime decode is explicitly on */
+static int mimebuf_f = FALSE; /* MIME buffered input */
+static int broken_f = FALSE; /* convert ESC-less broken JIS */
+static int iso8859_f = FALSE; /* ISO8859 through */
+static int mimeout_f = FALSE; /* base64 mode */
+static int x0201_f = NKF_UNSPECIFIED; /* convert JIS X 0201 */
+static int iso2022jp_f = FALSE; /* replace non ISO-2022-JP with GETA */
+
+#ifdef UNICODE_NORMALIZATION
+static int nfc_f = FALSE;
+static nkf_char (*i_nfc_getc)(FILE *) = std_getc; /* input of ugetc */
+static nkf_char (*i_nfc_ungetc)(nkf_char c ,FILE *f) = std_ungetc;
+#endif
+
+#ifdef INPUT_OPTION
+static int cap_f = FALSE;
+static nkf_char (*i_cgetc)(FILE *) = std_getc; /* input of cgetc */
+static nkf_char (*i_cungetc)(nkf_char c ,FILE *f) = std_ungetc;
+
+static int url_f = FALSE;
+static nkf_char (*i_ugetc)(FILE *) = std_getc; /* input of ugetc */
+static nkf_char (*i_uungetc)(nkf_char c ,FILE *f) = std_ungetc;
+#endif
+
+#define PREFIX_EUCG3 NKF_INT32_C(0x8F00)
+#define CLASS_MASK NKF_INT32_C(0xFF000000)
+#define CLASS_UNICODE NKF_INT32_C(0x01000000)
+#define VALUE_MASK NKF_INT32_C(0x00FFFFFF)
+#define UNICODE_BMP_MAX NKF_INT32_C(0x0000FFFF)
+#define UNICODE_MAX NKF_INT32_C(0x0010FFFF)
+#define nkf_char_euc3_new(c) ((c) | PREFIX_EUCG3)
+#define nkf_char_unicode_new(c) ((c) | CLASS_UNICODE)
+#define nkf_char_unicode_p(c) ((c & CLASS_MASK) == CLASS_UNICODE)
+#define nkf_char_unicode_bmp_p(c) ((c & VALUE_MASK) <= UNICODE_BMP_MAX)
+#define nkf_char_unicode_value_p(c) ((c & VALUE_MASK) <= UNICODE_MAX)
+
+#define UTF16_TO_UTF32(lead, trail) (((lead) << 10) + (trail) - NKF_INT32_C(0x35FDC00))
+
+#ifdef NUMCHAR_OPTION
+static int numchar_f = FALSE;
+static nkf_char (*i_ngetc)(FILE *) = std_getc; /* input of ugetc */
+static nkf_char (*i_nungetc)(nkf_char c ,FILE *f) = std_ungetc;
+#endif
+
+#ifdef CHECK_OPTION
+static int noout_f = FALSE;
+static void no_putc(nkf_char c);
+static int debug_f = FALSE;
+static void debug(const char *str);
+static nkf_char (*iconv_for_check)(nkf_char c2,nkf_char c1,nkf_char c0) = 0;
+#endif
+
+static int guess_f = 0; /* 0: OFF, 1: ON, 2: VERBOSE */
+static void set_input_codename(const char *codename);
+
+#ifdef EXEC_IO
+static int exec_f = 0;
+#endif
+
+#ifdef SHIFTJIS_CP932
+/* invert IBM extended characters to others */
+static int cp51932_f = FALSE;
+
+/* invert NEC-selected IBM extended characters to IBM extended characters */
+static int cp932inv_f = TRUE;
+
+/* static nkf_char cp932_conv(nkf_char c2, nkf_char c1); */
+#endif /* SHIFTJIS_CP932 */
+
+static int x0212_f = FALSE;
+static int x0213_f = FALSE;
+
+static unsigned char prefix_table[256];
+
+static void e_status(struct input_code *, nkf_char);
+static void s_status(struct input_code *, nkf_char);
+
+struct input_code input_code_list[] = {
+ {"EUC-JP", 0, 0, 0, {0, 0, 0}, e_status, e_iconv, 0},
+ {"Shift_JIS", 0, 0, 0, {0, 0, 0}, s_status, s_iconv, 0},
+#ifdef UTF8_INPUT_ENABLE
+ {"UTF-8", 0, 0, 0, {0, 0, 0}, w_status, w_iconv, 0},
+ {"UTF-16", 0, 0, 0, {0, 0, 0}, NULL, w_iconv16, 0},
+ {"UTF-32", 0, 0, 0, {0, 0, 0}, NULL, w_iconv32, 0},
+#endif
+ {NULL, 0, 0, 0, {0, 0, 0}, NULL, NULL, 0}
+};
+
+static int mimeout_mode = 0; /* 0, -1, 'Q', 'B', 1, 2 */
+static int base64_count = 0;
+
+/* X0208 -> ASCII converter */
+
+/* fold parameter */
+static int f_line = 0; /* chars in line */
+static int f_prev = 0;
+static int fold_preserve_f = FALSE; /* preserve new lines */
+static int fold_f = FALSE;
+static int fold_len = 0;
+
+/* options */
+static unsigned char kanji_intro = DEFAULT_J;
+static unsigned char ascii_intro = DEFAULT_R;
+
+/* Folding */
+
+#define FOLD_MARGIN 10
+#define DEFAULT_FOLD 60
+
+static int fold_margin = FOLD_MARGIN;
+
+/* process default */
+
+static nkf_char
+no_connection2(ARG_UNUSED nkf_char c2, ARG_UNUSED nkf_char c1, ARG_UNUSED nkf_char c0)
+{
+ fprintf(stderr,"nkf internal module connection failure.\n");
+ exit(EXIT_FAILURE);
+ return 0; /* LINT */
+}
+
+static void
+no_connection(nkf_char c2, nkf_char c1)
+{
+ no_connection2(c2,c1,0);
+}
+
+static nkf_char (*iconv)(nkf_char c2,nkf_char c1,nkf_char c0) = no_connection2;
+static void (*oconv)(nkf_char c2,nkf_char c1) = no_connection;
+
+static void (*o_zconv)(nkf_char c2,nkf_char c1) = no_connection;
+static void (*o_fconv)(nkf_char c2,nkf_char c1) = no_connection;
+static void (*o_eol_conv)(nkf_char c2,nkf_char c1) = no_connection;
+static void (*o_rot_conv)(nkf_char c2,nkf_char c1) = no_connection;
+static void (*o_hira_conv)(nkf_char c2,nkf_char c1) = no_connection;
+static void (*o_base64conv)(nkf_char c2,nkf_char c1) = no_connection;
+static void (*o_iso2022jp_check_conv)(nkf_char c2,nkf_char c1) = no_connection;
+
+/* static redirections */
+
+static void (*o_putc)(nkf_char c) = std_putc;
+
+static nkf_char (*i_getc)(FILE *f) = std_getc; /* general input */
+static nkf_char (*i_ungetc)(nkf_char c,FILE *f) =std_ungetc;
+
+static nkf_char (*i_bgetc)(FILE *) = std_getc; /* input of mgetc */
+static nkf_char (*i_bungetc)(nkf_char c ,FILE *f) = std_ungetc;
+
+static void (*o_mputc)(nkf_char c) = std_putc ; /* output of mputc */
+
+static nkf_char (*i_mgetc)(FILE *) = std_getc; /* input of mgetc */
+static nkf_char (*i_mungetc)(nkf_char c ,FILE *f) = std_ungetc;
+
+/* for strict mime */
+static nkf_char (*i_mgetc_buf)(FILE *) = std_getc; /* input of mgetc_buf */
+static nkf_char (*i_mungetc_buf)(nkf_char c,FILE *f) = std_ungetc;
+
+/* Global states */
+static int output_mode = ASCII; /* output kanji mode */
+static int input_mode = ASCII; /* input kanji mode */
+static int mime_decode_mode = FALSE; /* MIME mode B base64, Q hex */
+
+/* X0201 / X0208 conversion tables */
+
+/* X0201 kana conversion table */
+/* 90-9F A0-DF */
+static const unsigned char cv[]= {
+ 0x21,0x21,0x21,0x23,0x21,0x56,0x21,0x57,
+ 0x21,0x22,0x21,0x26,0x25,0x72,0x25,0x21,
+ 0x25,0x23,0x25,0x25,0x25,0x27,0x25,0x29,
+ 0x25,0x63,0x25,0x65,0x25,0x67,0x25,0x43,
+ 0x21,0x3c,0x25,0x22,0x25,0x24,0x25,0x26,
+ 0x25,0x28,0x25,0x2a,0x25,0x2b,0x25,0x2d,
+ 0x25,0x2f,0x25,0x31,0x25,0x33,0x25,0x35,
+ 0x25,0x37,0x25,0x39,0x25,0x3b,0x25,0x3d,
+ 0x25,0x3f,0x25,0x41,0x25,0x44,0x25,0x46,
+ 0x25,0x48,0x25,0x4a,0x25,0x4b,0x25,0x4c,
+ 0x25,0x4d,0x25,0x4e,0x25,0x4f,0x25,0x52,
+ 0x25,0x55,0x25,0x58,0x25,0x5b,0x25,0x5e,
+ 0x25,0x5f,0x25,0x60,0x25,0x61,0x25,0x62,
+ 0x25,0x64,0x25,0x66,0x25,0x68,0x25,0x69,
+ 0x25,0x6a,0x25,0x6b,0x25,0x6c,0x25,0x6d,
+ 0x25,0x6f,0x25,0x73,0x21,0x2b,0x21,0x2c,
+ 0x00,0x00};
+
+
+/* X0201 kana conversion table for daguten */
+/* 90-9F A0-DF */
+static const unsigned char dv[]= {
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x25,0x74,
+ 0x00,0x00,0x00,0x00,0x25,0x2c,0x25,0x2e,
+ 0x25,0x30,0x25,0x32,0x25,0x34,0x25,0x36,
+ 0x25,0x38,0x25,0x3a,0x25,0x3c,0x25,0x3e,
+ 0x25,0x40,0x25,0x42,0x25,0x45,0x25,0x47,
+ 0x25,0x49,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x25,0x50,0x25,0x53,
+ 0x25,0x56,0x25,0x59,0x25,0x5c,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00};
+
+/* X0201 kana conversion table for han-daguten */
+/* 90-9F A0-DF */
+static const unsigned char ev[]= {
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x25,0x51,0x25,0x54,
+ 0x25,0x57,0x25,0x5a,0x25,0x5d,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00};
+
+/* X0201 kana to X0213 conversion table for han-daguten */
+/* 90-9F A0-DF */
+static const unsigned char ev_x0213[]= {
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x25,0x77,0x25,0x78,
+ 0x25,0x79,0x25,0x7a,0x25,0x7b,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x25,0x7c,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x25,0x7d,0x00,0x00,
+ 0x25,0x7e,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00};
+
+
+/* X0208 kigou conversion table */
+/* 0x8140 - 0x819e */
+static const unsigned char fv[] = {
+
+ 0x00,0x00,0x00,0x00,0x2c,0x2e,0x00,0x3a,
+ 0x3b,0x3f,0x21,0x00,0x00,0x27,0x60,0x00,
+ 0x5e,0x00,0x5f,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x2d,0x00,0x2f,
+ 0x5c,0x00,0x00,0x7c,0x00,0x00,0x60,0x27,
+ 0x22,0x22,0x28,0x29,0x00,0x00,0x5b,0x5d,
+ 0x7b,0x7d,0x3c,0x3e,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x2b,0x2d,0x00,0x00,
+ 0x00,0x3d,0x00,0x3c,0x3e,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x24,0x00,0x00,0x25,0x23,0x26,0x2a,0x40,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
+} ;
+
+
+
+static int option_mode = 0;
+static int file_out_f = FALSE;
+#ifdef OVERWRITE
+static int overwrite_f = FALSE;
+static int preserve_time_f = FALSE;
+static int backup_f = FALSE;
+static char *backup_suffix = "";
+#endif
+
+static int eolmode_f = 0; /* CR, LF, CRLF */
+static int input_eol = 0; /* 0: unestablished, EOF: MIXED */
+static nkf_char prev_cr = 0; /* CR or 0 */
+#ifdef EASYWIN /*Easy Win */
+static int end_check;
+#endif /*Easy Win */
+
+static void *
+nkf_xmalloc(size_t size)
+{
+ void *ptr;
+
+ if (size == 0) size = 1;
+
+ ptr = malloc(size);
+ if (ptr == NULL) {
+ perror("can't malloc");
+ exit(EXIT_FAILURE);
+ }
+
+ return ptr;
+}
+
+static void *
+nkf_xrealloc(void *ptr, size_t size)
+{
+ if (size == 0) size = 1;
+
+ ptr = realloc(ptr, size);
+ if (ptr == NULL) {
+ perror("can't realloc");
+ exit(EXIT_FAILURE);
+ }
+
+ return ptr;
+}
+
+#define nkf_xfree(ptr) free(ptr)
+
+static int
+nkf_str_caseeql(const char *src, const char *target)
+{
+ int i;
+ for (i = 0; src[i] && target[i]; i++) {
+ if (nkf_toupper(src[i]) != nkf_toupper(target[i])) return FALSE;
+ }
+ if (src[i] || target[i]) return FALSE;
+ else return TRUE;
+}
+
+static nkf_encoding*
+nkf_enc_from_index(int idx)
+{
+ if (idx < 0 || NKF_ENCODING_TABLE_SIZE <= idx) {
+ return 0;
+ }
+ return &nkf_encoding_table[idx];
+}
+
+static int
+nkf_enc_find_index(const char *name)
+{
+ int i;
+ if (name[0] == 'X' && *(name+1) == '-') name += 2;
+ for (i = 0; encoding_name_to_id_table[i].id >= 0; i++) {
+ if (nkf_str_caseeql(encoding_name_to_id_table[i].name, name)) {
+ return encoding_name_to_id_table[i].id;
+ }
+ }
+ return -1;
+}
+
+static nkf_encoding*
+nkf_enc_find(const char *name)
+{
+ int idx = -1;
+ idx = nkf_enc_find_index(name);
+ if (idx < 0) return 0;
+ return nkf_enc_from_index(idx);
+}
+
+#define nkf_enc_name(enc) (enc)->name
+#define nkf_enc_to_index(enc) (enc)->id
+#define nkf_enc_to_base_encoding(enc) (enc)->base_encoding
+#define nkf_enc_to_iconv(enc) nkf_enc_to_base_encoding(enc)->iconv
+#define nkf_enc_to_oconv(enc) nkf_enc_to_base_encoding(enc)->oconv
+#define nkf_enc_asciicompat(enc) (\
+ nkf_enc_to_base_encoding(enc) == &NkfEncodingASCII ||\
+ nkf_enc_to_base_encoding(enc) == &NkfEncodingISO_2022_JP)
+#define nkf_enc_unicode_p(enc) (\
+ nkf_enc_to_base_encoding(enc) == &NkfEncodingUTF_8 ||\
+ nkf_enc_to_base_encoding(enc) == &NkfEncodingUTF_16 ||\
+ nkf_enc_to_base_encoding(enc) == &NkfEncodingUTF_32)
+#define nkf_enc_cp5022x_p(enc) (\
+ nkf_enc_to_index(enc) == CP50220 ||\
+ nkf_enc_to_index(enc) == CP50221 ||\
+ nkf_enc_to_index(enc) == CP50222)
+
+#ifdef DEFAULT_CODE_LOCALE
+static const char*
+nkf_locale_charmap(void)
+{
+#ifdef HAVE_LANGINFO_H
+ return nl_langinfo(CODESET);
+#elif defined(__WIN32__)
+ static char buf[16];
+ sprintf(buf, "CP%d", GetACP());
+ return buf;
+#elif defined(__OS2__)
+# if defined(INT_IS_SHORT)
+ /* OS/2 1.x */
+ return NULL;
+# else
+ /* OS/2 32bit */
+ static char buf[16];
+ ULONG ulCP[1], ulncp;
+ DosQueryCp(sizeof(ulCP), ulCP, &ulncp);
+ if (ulCP[0] == 932 || ulCP[0] == 943)
+ strcpy(buf, "Shift_JIS");
+ else
+ sprintf(buf, "CP%lu", ulCP[0]);
+ return buf;
+# endif
+#endif
+ return NULL;
+}
+
+static nkf_encoding*
+nkf_locale_encoding(void)
+{
+ nkf_encoding *enc = 0;
+ const char *encname = nkf_locale_charmap();
+ if (encname)
+ enc = nkf_enc_find(encname);
+ return enc;
+}
+#endif /* DEFAULT_CODE_LOCALE */
+
+static nkf_encoding*
+nkf_utf8_encoding(void)
+{
+ return &nkf_encoding_table[UTF_8];
+}
+
+static nkf_encoding*
+nkf_default_encoding(void)
+{
+ nkf_encoding *enc = 0;
+#ifdef DEFAULT_CODE_LOCALE
+ enc = nkf_locale_encoding();
+#elif defined(DEFAULT_ENCIDX)
+ enc = nkf_enc_from_index(DEFAULT_ENCIDX);
+#endif
+ if (!enc) enc = nkf_utf8_encoding();
+ return enc;
+}
+
+typedef struct {
+ long capa;
+ long len;
+ nkf_char *ptr;
+} nkf_buf_t;
+
+static nkf_buf_t *
+nkf_buf_new(int length)
+{
+ nkf_buf_t *buf = nkf_xmalloc(sizeof(nkf_buf_t));
+ buf->ptr = nkf_xmalloc(sizeof(nkf_char) * length);
+ buf->capa = length;
+ buf->len = 0;
+ return buf;
+}
+
+#if 0
+static void
+nkf_buf_dispose(nkf_buf_t *buf)
+{
+ nkf_xfree(buf->ptr);
+ nkf_xfree(buf);
+}
+#endif
+
+#define nkf_buf_length(buf) ((buf)->len)
+#define nkf_buf_empty_p(buf) ((buf)->len == 0)
+
+static nkf_char
+nkf_buf_at(nkf_buf_t *buf, int index)
+{
+ assert(index <= buf->len);
+ return buf->ptr[index];
+}
+
+static void
+nkf_buf_clear(nkf_buf_t *buf)
+{
+ buf->len = 0;
+}
+
+static void
+nkf_buf_push(nkf_buf_t *buf, nkf_char c)
+{
+ if (buf->capa <= buf->len) {
+ exit(EXIT_FAILURE);
+ }
+ buf->ptr[buf->len++] = c;
+}
+
+static nkf_char
+nkf_buf_pop(nkf_buf_t *buf)
+{
+ assert(!nkf_buf_empty_p(buf));
+ return buf->ptr[--buf->len];
+}
+
+/* Normalization Form C */
+#ifndef PERL_XS
+#ifdef WIN32DLL
+#define fprintf dllprintf
+#endif
+
+static void
+version(void)
+{
+ fprintf(HELP_OUTPUT,"Network Kanji Filter Version " NKF_VERSION " (" NKF_RELEASE_DATE ") \n" COPY_RIGHT "\n");
+}
+
+static void
+usage(void)
+{
+ fprintf(HELP_OUTPUT,
+ "Usage: nkf -[flags] [--] [in file] .. [out file for -O flag]\n"
+#ifdef UTF8_OUTPUT_ENABLE
+ " j/s/e/w Specify output encoding ISO-2022-JP, Shift_JIS, EUC-JP\n"
+ " UTF options is -w[8[0],{16,32}[{B,L}[0]]]\n"
+#else
+#endif
+#ifdef UTF8_INPUT_ENABLE
+ " J/S/E/W Specify input encoding ISO-2022-JP, Shift_JIS, EUC-JP\n"
+ " UTF option is -W[8,[16,32][B,L]]\n"
+#else
+ " J/S/E Specify output encoding ISO-2022-JP, Shift_JIS, EUC-JP\n"
+#endif
+ );
+ fprintf(HELP_OUTPUT,
+ " m[BQSN0] MIME decode [B:base64,Q:quoted,S:strict,N:nonstrict,0:no decode]\n"
+ " M[BQ] MIME encode [B:base64 Q:quoted]\n"
+ " f/F Folding: -f60 or -f or -f60-10 (fold margin 10) F preserve nl\n"
+ );
+ fprintf(HELP_OUTPUT,
+ " Z[0-4] Default/0: Convert JISX0208 Alphabet to ASCII\n"
+ " 1: Kankaku to one space 2: to two spaces 3: HTML Entity\n"
+ " 4: JISX0208 Katakana to JISX0201 Katakana\n"
+ " X,x Convert Halfwidth Katakana to Fullwidth or preserve it\n"
+ );
+ fprintf(HELP_OUTPUT,
+ " O Output to File (DEFAULT 'nkf.out')\n"
+ " L[uwm] Line mode u:LF w:CRLF m:CR (DEFAULT noconversion)\n"
+ );
+ fprintf(HELP_OUTPUT,
+ " --ic=<encoding> Specify the input encoding\n"
+ " --oc=<encoding> Specify the output encoding\n"
+ " --hiragana --katakana Hiragana/Katakana Conversion\n"
+ " --katakana-hiragana Converts each other\n"
+ );
+ fprintf(HELP_OUTPUT,
+#ifdef INPUT_OPTION
+ " --{cap, url}-input Convert hex after ':' or '%%'\n"
+#endif
+#ifdef NUMCHAR_OPTION
+ " --numchar-input Convert Unicode Character Reference\n"
+#endif
+#ifdef UTF8_INPUT_ENABLE
+ " --fb-{skip, html, xml, perl, java, subchar}\n"
+ " Specify unassigned character's replacement\n"
+#endif
+ );
+ fprintf(HELP_OUTPUT,
+#ifdef OVERWRITE
+ " --in-place[=SUF] Overwrite original files\n"
+ " --overwrite[=SUF] Preserve timestamp of original files\n"
+#endif
+ " -g --guess Guess the input code\n"
+ " -v --version Print the version\n"
+ " --help/-V Print this help / configuration\n"
+ );
+ version();
+}
+
+static void
+show_configuration(void)
+{
+ fprintf(HELP_OUTPUT,
+ "Summary of my nkf " NKF_VERSION " (" NKF_RELEASE_DATE ") configuration:\n"
+ " Compile-time options:\n"
+ " Compiled at: " __DATE__ " " __TIME__ "\n"
+ );
+ fprintf(HELP_OUTPUT,
+ " Default output encoding: "
+#ifdef DEFAULT_CODE_LOCALE
+ "LOCALE (%s)\n", nkf_enc_name(nkf_default_encoding())
+#elif defined(DEFAULT_ENCIDX)
+ "CONFIG (%s)\n", nkf_enc_name(nkf_default_encoding())
+#else
+ "NONE\n"
+#endif
+ );
+ fprintf(HELP_OUTPUT,
+ " Default output end of line: "
+#if DEFAULT_NEWLINE == CR
+ "CR"
+#elif DEFAULT_NEWLINE == CRLF
+ "CRLF"
+#else
+ "LF"
+#endif
+ "\n"
+ " Decode MIME encoded string: "
+#if MIME_DECODE_DEFAULT
+ "ON"
+#else
+ "OFF"
+#endif
+ "\n"
+ " Convert JIS X 0201 Katakana: "
+#if X0201_DEFAULT
+ "ON"
+#else
+ "OFF"
+#endif
+ "\n"
+ " --help, --version output: "
+#if HELP_OUTPUT_HELP_OUTPUT
+ "HELP_OUTPUT"
+#else
+ "STDOUT"
+#endif
+ "\n");
+}
+#endif /*PERL_XS*/
+
+#ifdef OVERWRITE
+static char*
+get_backup_filename(const char *suffix, const char *filename)
+{
+ char *backup_filename;
+ int asterisk_count = 0;
+ int i, j;
+ int filename_length = strlen(filename);
+
+ for(i = 0; suffix[i]; i++){
+ if(suffix[i] == '*') asterisk_count++;
+ }
+
+ if(asterisk_count){
+ backup_filename = nkf_xmalloc(strlen(suffix) + (asterisk_count * (filename_length - 1)) + 1);
+ for(i = 0, j = 0; suffix[i];){
+ if(suffix[i] == '*'){
+ backup_filename[j] = '\0';
+ strncat(backup_filename, filename, filename_length);
+ i++;
+ j += filename_length;
+ }else{
+ backup_filename[j++] = suffix[i++];
+ }
+ }
+ backup_filename[j] = '\0';
+ }else{
+ j = filename_length + strlen(suffix);
+ backup_filename = nkf_xmalloc(j + 1);
+ strcpy(backup_filename, filename);
+ strcat(backup_filename, suffix);
+ backup_filename[j] = '\0';
+ }
+ return backup_filename;
+}
+#endif
+
+#ifdef UTF8_INPUT_ENABLE
+static void
+nkf_each_char_to_hex(void (*f)(nkf_char c2,nkf_char c1), nkf_char c)
+{
+ int shift = 20;
+ c &= VALUE_MASK;
+ while(shift >= 0){
+ if(c >= NKF_INT32_C(1)<<shift){
+ while(shift >= 0){
+ (*f)(0, bin2hex(c>>shift));
+ shift -= 4;
+ }
+ }else{
+ shift -= 4;
+ }
+ }
+ return;
+}
+
+static void
+encode_fallback_html(nkf_char c)
+{
+ (*oconv)(0, '&');
+ (*oconv)(0, '#');
+ c &= VALUE_MASK;
+ if(c >= NKF_INT32_C(1000000))
+ (*oconv)(0, 0x30+(c/NKF_INT32_C(1000000))%10);
+ if(c >= NKF_INT32_C(100000))
+ (*oconv)(0, 0x30+(c/NKF_INT32_C(100000) )%10);
+ if(c >= 10000)
+ (*oconv)(0, 0x30+(c/10000 )%10);
+ if(c >= 1000)
+ (*oconv)(0, 0x30+(c/1000 )%10);
+ if(c >= 100)
+ (*oconv)(0, 0x30+(c/100 )%10);
+ if(c >= 10)
+ (*oconv)(0, 0x30+(c/10 )%10);
+ if(c >= 0)
+ (*oconv)(0, 0x30+ c %10);
+ (*oconv)(0, ';');
+ return;
+}
+
+static void
+encode_fallback_xml(nkf_char c)
+{
+ (*oconv)(0, '&');
+ (*oconv)(0, '#');
+ (*oconv)(0, 'x');
+ nkf_each_char_to_hex(oconv, c);
+ (*oconv)(0, ';');
+ return;
+}
+
+static void
+encode_fallback_java(nkf_char c)
+{
+ (*oconv)(0, '\\');
+ c &= VALUE_MASK;
+ if(!nkf_char_unicode_bmp_p(c)){
+ (*oconv)(0, 'U');
+ (*oconv)(0, '0');
+ (*oconv)(0, '0');
+ (*oconv)(0, bin2hex(c>>20));
+ (*oconv)(0, bin2hex(c>>16));
+ }else{
+ (*oconv)(0, 'u');
+ }
+ (*oconv)(0, bin2hex(c>>12));
+ (*oconv)(0, bin2hex(c>> 8));
+ (*oconv)(0, bin2hex(c>> 4));
+ (*oconv)(0, bin2hex(c ));
+ return;
+}
+
+static void
+encode_fallback_perl(nkf_char c)
+{
+ (*oconv)(0, '\\');
+ (*oconv)(0, 'x');
+ (*oconv)(0, '{');
+ nkf_each_char_to_hex(oconv, c);
+ (*oconv)(0, '}');
+ return;
+}
+
+static void
+encode_fallback_subchar(nkf_char c)
+{
+ c = unicode_subchar;
+ (*oconv)((c>>8)&0xFF, c&0xFF);
+ return;
+}
+#endif
+
+static const struct {
+ const char *name;
+ const char *alias;
+} long_option[] = {
+ {"ic=", ""},
+ {"oc=", ""},
+ {"base64","jMB"},
+ {"euc","e"},
+ {"euc-input","E"},
+ {"fj","jm"},
+ {"help",""},
+ {"jis","j"},
+ {"jis-input","J"},
+ {"mac","sLm"},
+ {"mime","jM"},
+ {"mime-input","m"},
+ {"msdos","sLw"},
+ {"sjis","s"},
+ {"sjis-input","S"},
+ {"unix","eLu"},
+ {"version","v"},
+ {"windows","sLw"},
+ {"hiragana","h1"},
+ {"katakana","h2"},
+ {"katakana-hiragana","h3"},
+ {"guess=", ""},
+ {"guess", "g2"},
+ {"cp932", ""},
+ {"no-cp932", ""},
+#ifdef X0212_ENABLE
+ {"x0212", ""},
+#endif
+#ifdef UTF8_OUTPUT_ENABLE
+ {"utf8", "w"},
+ {"utf16", "w16"},
+ {"ms-ucs-map", ""},
+ {"fb-skip", ""},
+ {"fb-html", ""},
+ {"fb-xml", ""},
+ {"fb-perl", ""},
+ {"fb-java", ""},
+ {"fb-subchar", ""},
+ {"fb-subchar=", ""},
+#endif
+#ifdef UTF8_INPUT_ENABLE
+ {"utf8-input", "W"},
+ {"utf16-input", "W16"},
+ {"no-cp932ext", ""},
+ {"no-best-fit-chars",""},
+#endif
+#ifdef UNICODE_NORMALIZATION
+ {"utf8mac-input", ""},
+#endif
+#ifdef OVERWRITE
+ {"overwrite", ""},
+ {"overwrite=", ""},
+ {"in-place", ""},
+ {"in-place=", ""},
+#endif
+#ifdef INPUT_OPTION
+ {"cap-input", ""},
+ {"url-input", ""},
+#endif
+#ifdef NUMCHAR_OPTION
+ {"numchar-input", ""},
+#endif
+#ifdef CHECK_OPTION
+ {"no-output", ""},
+ {"debug", ""},
+#endif
+#ifdef SHIFTJIS_CP932
+ {"cp932inv", ""},
+#endif
+#ifdef EXEC_IO
+ {"exec-in", ""},
+ {"exec-out", ""},
+#endif
+ {"prefix=", ""},
+};
+
+static void
+set_input_encoding(nkf_encoding *enc)
+{
+ switch (nkf_enc_to_index(enc)) {
+ case ISO_8859_1:
+ iso8859_f = TRUE;
+ break;
+ case CP50221:
+ case CP50222:
+ if (x0201_f == NKF_UNSPECIFIED) x0201_f = FALSE; /* -x specified implicitly */
+ case CP50220:
+#ifdef SHIFTJIS_CP932
+ cp51932_f = TRUE;
+#endif
+#ifdef UTF8_OUTPUT_ENABLE
+ ms_ucs_map_f = UCS_MAP_CP932;
+#endif
+ break;
+ case ISO_2022_JP_1:
+ x0212_f = TRUE;
+ break;
+ case ISO_2022_JP_3:
+ x0212_f = TRUE;
+ x0213_f = TRUE;
+ break;
+ case ISO_2022_JP_2004:
+ x0212_f = TRUE;
+ x0213_f = TRUE;
+ break;
+ case SHIFT_JIS:
+ break;
+ case WINDOWS_31J:
+ if (x0201_f == NKF_UNSPECIFIED) x0201_f = FALSE; /* -x specified implicitly */
+#ifdef SHIFTJIS_CP932
+ cp51932_f = TRUE;
+#endif
+#ifdef UTF8_OUTPUT_ENABLE
+ ms_ucs_map_f = UCS_MAP_CP932;
+#endif
+ break;
+ break;
+ case CP10001:
+#ifdef SHIFTJIS_CP932
+ cp51932_f = TRUE;
+#endif
+#ifdef UTF8_OUTPUT_ENABLE
+ ms_ucs_map_f = UCS_MAP_CP10001;
+#endif
+ break;
+ case EUC_JP:
+ break;
+ case EUCJP_NKF:
+ break;
+ case CP51932:
+ if (x0201_f == NKF_UNSPECIFIED) x0201_f = FALSE; /* -x specified implicitly */
+#ifdef SHIFTJIS_CP932
+ cp51932_f = TRUE;
+#endif
+#ifdef UTF8_OUTPUT_ENABLE
+ ms_ucs_map_f = UCS_MAP_CP932;
+#endif
+ break;
+ case EUCJP_MS:
+ if (x0201_f == NKF_UNSPECIFIED) x0201_f = FALSE; /* -x specified implicitly */
+#ifdef SHIFTJIS_CP932
+ cp51932_f = FALSE;
+#endif
+#ifdef UTF8_OUTPUT_ENABLE
+ ms_ucs_map_f = UCS_MAP_MS;
+#endif
+ break;
+ case EUCJP_ASCII:
+ if (x0201_f == NKF_UNSPECIFIED) x0201_f = FALSE; /* -x specified implicitly */
+#ifdef SHIFTJIS_CP932
+ cp51932_f = FALSE;
+#endif
+#ifdef UTF8_OUTPUT_ENABLE
+ ms_ucs_map_f = UCS_MAP_ASCII;
+#endif
+ break;
+ case SHIFT_JISX0213:
+ case SHIFT_JIS_2004:
+ x0213_f = TRUE;
+#ifdef SHIFTJIS_CP932
+ cp51932_f = FALSE;
+ if (cp932inv_f == TRUE) cp932inv_f = FALSE;
+#endif
+ break;
+ case EUC_JISX0213:
+ case EUC_JIS_2004:
+ x0213_f = TRUE;
+#ifdef SHIFTJIS_CP932
+ cp51932_f = FALSE;
+#endif
+ break;
+#ifdef UTF8_INPUT_ENABLE
+#ifdef UNICODE_NORMALIZATION
+ case UTF8_MAC:
+ nfc_f = TRUE;
+ break;
+#endif
+ case UTF_16:
+ case UTF_16BE:
+ case UTF_16BE_BOM:
+ input_endian = ENDIAN_BIG;
+ break;
+ case UTF_16LE:
+ case UTF_16LE_BOM:
+ input_endian = ENDIAN_LITTLE;
+ break;
+ case UTF_32:
+ case UTF_32BE:
+ case UTF_32BE_BOM:
+ input_endian = ENDIAN_BIG;
+ break;
+ case UTF_32LE:
+ case UTF_32LE_BOM:
+ input_endian = ENDIAN_LITTLE;
+ break;
+#endif
+ }
+}
+
+static void
+set_output_encoding(nkf_encoding *enc)
+{
+ switch (nkf_enc_to_index(enc)) {
+ case CP50220:
+#ifdef SHIFTJIS_CP932
+ if (cp932inv_f == TRUE) cp932inv_f = FALSE;
+#endif
+#ifdef UTF8_OUTPUT_ENABLE
+ ms_ucs_map_f = UCS_MAP_CP932;
+#endif
+ break;
+ case CP50221:
+ if (x0201_f == NKF_UNSPECIFIED) x0201_f = FALSE; /* -x specified implicitly */
+#ifdef SHIFTJIS_CP932
+ if (cp932inv_f == TRUE) cp932inv_f = FALSE;
+#endif
+#ifdef UTF8_OUTPUT_ENABLE
+ ms_ucs_map_f = UCS_MAP_CP932;
+#endif
+ break;
+ case ISO_2022_JP:
+#ifdef SHIFTJIS_CP932
+ if (cp932inv_f == TRUE) cp932inv_f = FALSE;
+#endif
+ break;
+ case ISO_2022_JP_1:
+ x0212_f = TRUE;
+#ifdef SHIFTJIS_CP932
+ if (cp932inv_f == TRUE) cp932inv_f = FALSE;
+#endif
+ break;
+ case ISO_2022_JP_3:
+ case ISO_2022_JP_2004:
+ x0212_f = TRUE;
+ x0213_f = TRUE;
+#ifdef SHIFTJIS_CP932
+ if (cp932inv_f == TRUE) cp932inv_f = FALSE;
+#endif
+ break;
+ case SHIFT_JIS:
+ break;
+ case WINDOWS_31J:
+ if (x0201_f == NKF_UNSPECIFIED) x0201_f = FALSE; /* -x specified implicitly */
+#ifdef UTF8_OUTPUT_ENABLE
+ ms_ucs_map_f = UCS_MAP_CP932;
+#endif
+ break;
+ case CP10001:
+#ifdef UTF8_OUTPUT_ENABLE
+ ms_ucs_map_f = UCS_MAP_CP10001;
+#endif
+ break;
+ case EUC_JP:
+ x0212_f = TRUE;
+#ifdef SHIFTJIS_CP932
+ if (cp932inv_f == TRUE) cp932inv_f = FALSE;
+#endif
+#ifdef UTF8_OUTPUT_ENABLE
+ ms_ucs_map_f = UCS_MAP_ASCII;
+#endif
+ break;
+ case EUCJP_NKF:
+ x0212_f = FALSE;
+#ifdef SHIFTJIS_CP932
+ if (cp932inv_f == TRUE) cp932inv_f = FALSE;
+#endif
+#ifdef UTF8_OUTPUT_ENABLE
+ ms_ucs_map_f = UCS_MAP_ASCII;
+#endif
+ break;
+ case CP51932:
+ if (x0201_f == NKF_UNSPECIFIED) x0201_f = FALSE; /* -x specified implicitly */
+#ifdef SHIFTJIS_CP932
+ if (cp932inv_f == TRUE) cp932inv_f = FALSE;
+#endif
+#ifdef UTF8_OUTPUT_ENABLE
+ ms_ucs_map_f = UCS_MAP_CP932;
+#endif
+ break;
+ case EUCJP_MS:
+ if (x0201_f == NKF_UNSPECIFIED) x0201_f = FALSE; /* -x specified implicitly */
+ x0212_f = TRUE;
+#ifdef UTF8_OUTPUT_ENABLE
+ ms_ucs_map_f = UCS_MAP_MS;
+#endif
+ break;
+ case EUCJP_ASCII:
+ if (x0201_f == NKF_UNSPECIFIED) x0201_f = FALSE; /* -x specified implicitly */
+ x0212_f = TRUE;
+#ifdef UTF8_OUTPUT_ENABLE
+ ms_ucs_map_f = UCS_MAP_ASCII;
+#endif
+ break;
+ case SHIFT_JISX0213:
+ case SHIFT_JIS_2004:
+ x0213_f = TRUE;
+#ifdef SHIFTJIS_CP932
+ if (cp932inv_f == TRUE) cp932inv_f = FALSE;
+#endif
+ break;
+ case EUC_JISX0213:
+ case EUC_JIS_2004:
+ x0212_f = TRUE;
+ x0213_f = TRUE;
+#ifdef SHIFTJIS_CP932
+ if (cp932inv_f == TRUE) cp932inv_f = FALSE;
+#endif
+ break;
+#ifdef UTF8_OUTPUT_ENABLE
+ case UTF_8_BOM:
+ output_bom_f = TRUE;
+ break;
+ case UTF_16:
+ case UTF_16BE_BOM:
+ output_bom_f = TRUE;
+ break;
+ case UTF_16LE:
+ output_endian = ENDIAN_LITTLE;
+ output_bom_f = FALSE;
+ break;
+ case UTF_16LE_BOM:
+ output_endian = ENDIAN_LITTLE;
+ output_bom_f = TRUE;
+ break;
+ case UTF_32:
+ case UTF_32BE_BOM:
+ output_bom_f = TRUE;
+ break;
+ case UTF_32LE:
+ output_endian = ENDIAN_LITTLE;
+ output_bom_f = FALSE;
+ break;
+ case UTF_32LE_BOM:
+ output_endian = ENDIAN_LITTLE;
+ output_bom_f = TRUE;
+ break;
+#endif
+ }
+}
+
+static struct input_code*
+find_inputcode_byfunc(nkf_char (*iconv_func)(nkf_char c2,nkf_char c1,nkf_char c0))
+{
+ if (iconv_func){
+ struct input_code *p = input_code_list;
+ while (p->name){
+ if (iconv_func == p->iconv_func){
+ return p;
+ }
+ p++;
+ }
+ }
+ return 0;
+}
+
+static void
+set_iconv(nkf_char f, nkf_char (*iconv_func)(nkf_char c2,nkf_char c1,nkf_char c0))
+{
+#ifdef INPUT_CODE_FIX
+ if (f || !input_encoding)
+#endif
+ if (estab_f != f){
+ estab_f = f;
+ }
+
+ if (iconv_func
+#ifdef INPUT_CODE_FIX
+ && (f == -TRUE || !input_encoding) /* -TRUE means "FORCE" */
+#endif
+ ){
+ iconv = iconv_func;
+ }
+#ifdef CHECK_OPTION
+ if (estab_f && iconv_for_check != iconv){
+ struct input_code *p = find_inputcode_byfunc(iconv);
+ if (p){
+ set_input_codename(p->name);
+ debug(p->name);
+ }
+ iconv_for_check = iconv;
+ }
+#endif
+}
+
+#ifdef X0212_ENABLE
+static nkf_char
+x0212_shift(nkf_char c)
+{
+ nkf_char ret = c;
+ c &= 0x7f;
+ if (is_eucg3(ret)){
+ if (0x75 <= c && c <= 0x7f){
+ ret = c + (0x109 - 0x75);
+ }
+ }else{
+ if (0x75 <= c && c <= 0x7f){
+ ret = c + (0x113 - 0x75);
+ }
+ }
+ return ret;
+}
+
+
+static nkf_char
+x0212_unshift(nkf_char c)
+{
+ nkf_char ret = c;
+ if (0x7f <= c && c <= 0x88){
+ ret = c + (0x75 - 0x7f);
+ }else if (0x89 <= c && c <= 0x92){
+ ret = PREFIX_EUCG3 | 0x80 | (c + (0x75 - 0x89));
+ }
+ return ret;
+}
+#endif /* X0212_ENABLE */
+
+static int
+is_x0213_2_in_x0212(nkf_char c1)
+{
+ static const char x0213_2_table[] =
+ {0, 1, 0, 1, 1, 1, 0, 0, 1, 0, 0, 0, 1, 1, 1, 1};
+ int ku = c1 - 0x20;
+ if (ku <= 15)
+ return x0213_2_table[ku]; /* 1, 3-5, 8, 12-15 */
+ if (78 <= ku && ku <= 94)
+ return 1;
+ return 0;
+}
+
+static nkf_char
+e2s_conv(nkf_char c2, nkf_char c1, nkf_char *p2, nkf_char *p1)
+{
+ nkf_char ndx;
+ if (is_eucg3(c2)){
+ ndx = c2 & 0x7f;
+ if (x0213_f && is_x0213_2_in_x0212(ndx)){
+ if((0x21 <= ndx && ndx <= 0x2F)){
+ if (p2) *p2 = ((ndx - 1) >> 1) + 0xec - ndx / 8 * 3;
+ if (p1) *p1 = c1 + ((ndx & 1) ? ((c1 < 0x60) ? 0x1f : 0x20) : 0x7e);
+ return 0;
+ }else if(0x6E <= ndx && ndx <= 0x7E){
+ if (p2) *p2 = ((ndx - 1) >> 1) + 0xbe;
+ if (p1) *p1 = c1 + ((ndx & 1) ? ((c1 < 0x60) ? 0x1f : 0x20) : 0x7e);
+ return 0;
+ }
+ return 1;
+ }
+#ifdef X0212_ENABLE
+ else if(nkf_isgraph(ndx)){
+ nkf_char val = 0;
+ const unsigned short *ptr;
+ ptr = x0212_shiftjis[ndx - 0x21];
+ if (ptr){
+ val = ptr[(c1 & 0x7f) - 0x21];
+ }
+ if (val){
+ c2 = val >> 8;
+ c1 = val & 0xff;
+ if (p2) *p2 = c2;
+ if (p1) *p1 = c1;
+ return 0;
+ }
+ c2 = x0212_shift(c2);
+ }
+#endif /* X0212_ENABLE */
+ }
+ if(0x7F < c2) return 1;
+ if (p2) *p2 = ((c2 - 1) >> 1) + ((c2 <= 0x5e) ? 0x71 : 0xb1);
+ if (p1) *p1 = c1 + ((c2 & 1) ? ((c1 < 0x60) ? 0x1f : 0x20) : 0x7e);
+ return 0;
+}
+
+static nkf_char
+s2e_conv(nkf_char c2, nkf_char c1, nkf_char *p2, nkf_char *p1)
+{
+#if defined(SHIFTJIS_CP932) || defined(X0212_ENABLE)
+ nkf_char val;
+#endif
+ static const char shift_jisx0213_s1a3_table[5][2] ={ { 1, 8}, { 3, 4}, { 5,12}, {13,14}, {15, 0} };
+ if (0xFC < c1) return 1;
+#ifdef SHIFTJIS_CP932
+ if (!cp932inv_f && !x0213_f && is_ibmext_in_sjis(c2)){
+ val = shiftjis_cp932[c2 - CP932_TABLE_BEGIN][c1 - 0x40];
+ if (val){
+ c2 = val >> 8;
+ c1 = val & 0xff;
+ }
+ }
+ if (cp932inv_f
+ && CP932INV_TABLE_BEGIN <= c2 && c2 <= CP932INV_TABLE_END){
+ val = cp932inv[c2 - CP932INV_TABLE_BEGIN][c1 - 0x40];
+ if (val){
+ c2 = val >> 8;
+ c1 = val & 0xff;
+ }
+ }
+#endif /* SHIFTJIS_CP932 */
+#ifdef X0212_ENABLE
+ if (!x0213_f && is_ibmext_in_sjis(c2)){
+ val = shiftjis_x0212[c2 - 0xfa][c1 - 0x40];
+ if (val){
+ if (val > 0x7FFF){
+ c2 = PREFIX_EUCG3 | ((val >> 8) & 0x7f);
+ c1 = val & 0xff;
+ }else{
+ c2 = val >> 8;
+ c1 = val & 0xff;
+ }
+ if (p2) *p2 = c2;
+ if (p1) *p1 = c1;
+ return 0;
+ }
+ }
+#endif
+ if(c2 >= 0x80){
+ if(x0213_f && c2 >= 0xF0){
+ if(c2 <= 0xF3 || (c2 == 0xF4 && c1 < 0x9F)){ /* k=1, 3<=k<=5, k=8, 12<=k<=15 */
+ c2 = PREFIX_EUCG3 | 0x20 | shift_jisx0213_s1a3_table[c2 - 0xF0][0x9E < c1];
+ }else{ /* 78<=k<=94 */
+ c2 = PREFIX_EUCG3 | (c2 * 2 - 0x17B);
+ if (0x9E < c1) c2++;
+ }
+ }else{
+#define SJ0162 0x00e1 /* 01 - 62 ku offset */
+#define SJ6394 0x0161 /* 63 - 94 ku offset */
+ c2 = c2 + c2 - ((c2 <= 0x9F) ? SJ0162 : SJ6394);
+ if (0x9E < c1) c2++;
+ }
+ if (c1 < 0x9F)
+ c1 = c1 - ((c1 > DEL) ? SP : 0x1F);
+ else {
+ c1 = c1 - 0x7E;
+ }
+ }
+
+#ifdef X0212_ENABLE
+ c2 = x0212_unshift(c2);
+#endif
+ if (p2) *p2 = c2;
+ if (p1) *p1 = c1;
+ return 0;
+}
+
+#if defined(UTF8_INPUT_ENABLE) || defined(UTF8_OUTPUT_ENABLE)
+static void
+nkf_unicode_to_utf8(nkf_char val, nkf_char *p1, nkf_char *p2, nkf_char *p3, nkf_char *p4)
+{
+ val &= VALUE_MASK;
+ if (val < 0x80){
+ *p1 = val;
+ *p2 = 0;
+ *p3 = 0;
+ *p4 = 0;
+ }else if (val < 0x800){
+ *p1 = 0xc0 | (val >> 6);
+ *p2 = 0x80 | (val & 0x3f);
+ *p3 = 0;
+ *p4 = 0;
+ } else if (nkf_char_unicode_bmp_p(val)) {
+ *p1 = 0xe0 | (val >> 12);
+ *p2 = 0x80 | ((val >> 6) & 0x3f);
+ *p3 = 0x80 | ( val & 0x3f);
+ *p4 = 0;
+ } else if (nkf_char_unicode_value_p(val)) {
+ *p1 = 0xf0 | (val >> 18);
+ *p2 = 0x80 | ((val >> 12) & 0x3f);
+ *p3 = 0x80 | ((val >> 6) & 0x3f);
+ *p4 = 0x80 | ( val & 0x3f);
+ } else {
+ *p1 = 0;
+ *p2 = 0;
+ *p3 = 0;
+ *p4 = 0;
+ }
+}
+
+static nkf_char
+nkf_utf8_to_unicode(nkf_char c1, nkf_char c2, nkf_char c3, nkf_char c4)
+{
+ nkf_char wc;
+ if (c1 <= 0x7F) {
+ /* single byte */
+ wc = c1;
+ }
+ else if (c1 <= 0xC1) {
+ /* trail byte or invalid */
+ return -1;
+ }
+ else if (c1 <= 0xDF) {
+ /* 2 bytes */
+ wc = (c1 & 0x1F) << 6;
+ wc |= (c2 & 0x3F);
+ }
+ else if (c1 <= 0xEF) {
+ /* 3 bytes */
+ wc = (c1 & 0x0F) << 12;
+ wc |= (c2 & 0x3F) << 6;
+ wc |= (c3 & 0x3F);
+ }
+ else if (c2 <= 0xF4) {
+ /* 4 bytes */
+ wc = (c1 & 0x0F) << 18;
+ wc |= (c2 & 0x3F) << 12;
+ wc |= (c3 & 0x3F) << 6;
+ wc |= (c4 & 0x3F);
+ }
+ else {
+ return -1;
+ }
+ return wc;
+}
+#endif
+
+#ifdef UTF8_INPUT_ENABLE
+static int
+unicode_to_jis_common2(nkf_char c1, nkf_char c0,
+ const unsigned short *const *pp, nkf_char psize,
+ nkf_char *p2, nkf_char *p1)
+{
+ nkf_char c2;
+ const unsigned short *p;
+ unsigned short val;
+
+ if (pp == 0) return 1;
+
+ c1 -= 0x80;
+ if (c1 < 0 || psize <= c1) return 1;
+ p = pp[c1];
+ if (p == 0) return 1;
+
+ c0 -= 0x80;
+ if (c0 < 0 || sizeof_utf8_to_euc_C2 <= c0) return 1;
+ val = p[c0];
+ if (val == 0) return 1;
+ if (no_cp932ext_f && (
+ (val>>8) == 0x2D || /* NEC special characters */
+ val > NKF_INT32_C(0xF300) /* IBM extended characters */
+ )) return 1;
+
+ c2 = val >> 8;
+ if (val > 0x7FFF){
+ c2 &= 0x7f;
+ c2 |= PREFIX_EUCG3;
+ }
+ if (c2 == SO) c2 = JIS_X_0201_1976_K;
+ c1 = val & 0xFF;
+ if (p2) *p2 = c2;
+ if (p1) *p1 = c1;
+ return 0;
+}
+
+static int
+unicode_to_jis_common(nkf_char c2, nkf_char c1, nkf_char c0, nkf_char *p2, nkf_char *p1)
+{
+ const unsigned short *const *pp;
+ const unsigned short *const *const *ppp;
+ static const char no_best_fit_chars_table_C2[] =
+ {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 0, 0, 1, 0, 0, 0, 0, 1, 1, 1, 2, 1, 1, 2,
+ 0, 0, 1, 1, 0, 1, 0, 1, 2, 1, 1, 1, 1, 1, 1, 1};
+ static const char no_best_fit_chars_table_C2_ms[] =
+ {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 0, 1, 1, 0, 1, 1, 0, 0, 0, 0, 1, 1, 1, 0, 0,
+ 0, 0, 1, 1, 0, 1, 0, 1, 0, 1, 0, 1, 1, 1, 1, 0};
+ static const char no_best_fit_chars_table_932_C2[] =
+ {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 0, 1, 1, 0, 0, 1, 1, 1, 1, 1, 1, 1,
+ 0, 0, 1, 1, 0, 1, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0};
+ static const char no_best_fit_chars_table_932_C3[] =
+ {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1};
+ nkf_char ret = 0;
+
+ if(c2 < 0x80){
+ *p2 = 0;
+ *p1 = c2;
+ }else if(c2 < 0xe0){
+ if(no_best_fit_chars_f){
+ if(ms_ucs_map_f == UCS_MAP_CP932){
+ switch(c2){
+ case 0xC2:
+ if(no_best_fit_chars_table_932_C2[c1&0x3F]) return 1;
+ break;
+ case 0xC3:
+ if(no_best_fit_chars_table_932_C3[c1&0x3F]) return 1;
+ break;
+ }
+ }else if(!cp932inv_f){
+ switch(c2){
+ case 0xC2:
+ if(no_best_fit_chars_table_C2[c1&0x3F]) return 1;
+ break;
+ case 0xC3:
+ if(no_best_fit_chars_table_932_C3[c1&0x3F]) return 1;
+ break;
+ }
+ }else if(ms_ucs_map_f == UCS_MAP_MS){
+ if(c2 == 0xC2 && no_best_fit_chars_table_C2_ms[c1&0x3F]) return 1;
+ }else if(ms_ucs_map_f == UCS_MAP_CP10001){
+ switch(c2){
+ case 0xC2:
+ switch(c1){
+ case 0xA2:
+ case 0xA3:
+ case 0xA5:
+ case 0xA6:
+ case 0xAC:
+ case 0xAF:
+ case 0xB8:
+ return 1;
+ }
+ break;
+ }
+ }
+ }
+ pp =
+ ms_ucs_map_f == UCS_MAP_CP932 ? utf8_to_euc_2bytes_932 :
+ ms_ucs_map_f == UCS_MAP_MS ? utf8_to_euc_2bytes_ms :
+ ms_ucs_map_f == UCS_MAP_CP10001 ? utf8_to_euc_2bytes_mac :
+ x0213_f ? utf8_to_euc_2bytes_x0213 :
+ utf8_to_euc_2bytes;
+ ret = unicode_to_jis_common2(c2, c1, pp, sizeof_utf8_to_euc_2bytes, p2, p1);
+ }else if(c0 < 0xF0){
+ if(no_best_fit_chars_f){
+ if(ms_ucs_map_f == UCS_MAP_CP932){
+ if(c2 == 0xE3 && c1 == 0x82 && c0 == 0x94) return 1;
+ }else if(ms_ucs_map_f == UCS_MAP_MS){
+ switch(c2){
+ case 0xE2:
+ switch(c1){
+ case 0x80:
+ if(c0 == 0x94 || c0 == 0x96 || c0 == 0xBE) return 1;
+ break;
+ case 0x88:
+ if(c0 == 0x92) return 1;
+ break;
+ }
+ break;
+ case 0xE3:
+ if(c1 == 0x80 || c0 == 0x9C) return 1;
+ break;
+ }
+ }else if(ms_ucs_map_f == UCS_MAP_CP10001){
+ switch(c2){
+ case 0xE3:
+ switch(c1){
+ case 0x82:
+ if(c0 == 0x94) return 1;
+ break;
+ case 0x83:
+ if(c0 == 0xBB) return 1;
+ break;
+ }
+ break;
+ }
+ }else{
+ switch(c2){
+ case 0xE2:
+ switch(c1){
+ case 0x80:
+ if(c0 == 0x95) return 1;
+ break;
+ case 0x88:
+ if(c0 == 0xA5) return 1;
+ break;
+ }
+ break;
+ case 0xEF:
+ switch(c1){
+ case 0xBC:
+ if(c0 == 0x8D) return 1;
+ break;
+ case 0xBD:
+ if(c0 == 0x9E && !cp932inv_f) return 1;
+ break;
+ case 0xBF:
+ if(0xA0 <= c0 && c0 <= 0xA5) return 1;
+ break;
+ }
+ break;
+ }
+ }
+ }
+ ppp =
+ ms_ucs_map_f == UCS_MAP_CP932 ? utf8_to_euc_3bytes_932 :
+ ms_ucs_map_f == UCS_MAP_MS ? utf8_to_euc_3bytes_ms :
+ ms_ucs_map_f == UCS_MAP_CP10001 ? utf8_to_euc_3bytes_mac :
+ x0213_f ? utf8_to_euc_3bytes_x0213 :
+ utf8_to_euc_3bytes;
+ ret = unicode_to_jis_common2(c1, c0, ppp[c2 - 0xE0], sizeof_utf8_to_euc_C2, p2, p1);
+ }else return -1;
+#ifdef SHIFTJIS_CP932
+ if (!ret && !cp932inv_f && is_eucg3(*p2)) {
+ nkf_char s2, s1;
+ if (e2s_conv(*p2, *p1, &s2, &s1) == 0) {
+ s2e_conv(s2, s1, p2, p1);
+ }else{
+ ret = 1;
+ }
+ }
+#endif
+ return ret;
+}
+
+#ifdef UTF8_OUTPUT_ENABLE
+#define X0213_SURROGATE_FIND(tbl, size, euc) do { \
+ int i; \
+ for (i = 0; i < size; i++) \
+ if (tbl[i][0] == euc) { \
+ low = tbl[i][2]; \
+ break; \
+ } \
+ } while (0)
+
+static nkf_char
+e2w_conv(nkf_char c2, nkf_char c1)
+{
+ const unsigned short *p;
+
+ if (c2 == JIS_X_0201_1976_K) {
+ if (ms_ucs_map_f == UCS_MAP_CP10001) {
+ switch (c1) {
+ case 0x20:
+ return 0xA0;
+ case 0x7D:
+ return 0xA9;
+ }
+ }
+ p = euc_to_utf8_1byte;
+#ifdef X0212_ENABLE
+ } else if (is_eucg3(c2)){
+ if(ms_ucs_map_f == UCS_MAP_ASCII&& c2 == NKF_INT32_C(0x8F22) && c1 == 0x43){
+ return 0xA6;
+ }
+ c2 = (c2&0x7f) - 0x21;
+ if (0<=c2 && c2<sizeof_euc_to_utf8_2bytes)
+ p =
+ x0213_f ? x0212_to_utf8_2bytes_x0213[c2] :
+ x0212_to_utf8_2bytes[c2];
+ else
+ return 0;
+#endif
+ } else {
+ c2 &= 0x7f;
+ c2 = (c2&0x7f) - 0x21;
+ if (0<=c2 && c2<sizeof_euc_to_utf8_2bytes)
+ p =
+ x0213_f ? euc_to_utf8_2bytes_x0213[c2] :
+ ms_ucs_map_f == UCS_MAP_ASCII ? euc_to_utf8_2bytes[c2] :
+ ms_ucs_map_f == UCS_MAP_CP10001 ? euc_to_utf8_2bytes_mac[c2] :
+ euc_to_utf8_2bytes_ms[c2];
+ else
+ return 0;
+ }
+ if (!p) return 0;
+ c1 = (c1 & 0x7f) - 0x21;
+ if (0<=c1 && c1<sizeof_euc_to_utf8_1byte) {
+ nkf_char val = p[c1];
+ if (x0213_f && 0xD800<=val && val<=0xDBFF) {
+ nkf_char euc = (c2+0x21)<<8 | (c1+0x21);
+ nkf_char low = 0;
+ if (p==x0212_to_utf8_2bytes_x0213[c2]) {
+ X0213_SURROGATE_FIND(x0213_2_surrogate_table, sizeof_x0213_2_surrogate_table, euc);
+ } else {
+ X0213_SURROGATE_FIND(x0213_1_surrogate_table, sizeof_x0213_1_surrogate_table, euc);
+ }
+ if (!low) return 0;
+ return UTF16_TO_UTF32(val, low);
+ } else {
+ return val;
+ }
+ }
+ return 0;
+}
+
+static nkf_char
+e2w_combining(nkf_char comb, nkf_char c2, nkf_char c1)
+{
+ nkf_char euc;
+ int i;
+ for (i = 0; i < sizeof_x0213_combining_chars; i++)
+ if (x0213_combining_chars[i] == comb)
+ break;
+ if (i >= sizeof_x0213_combining_chars)
+ return 0;
+ euc = (c2&0x7f)<<8 | (c1&0x7f);
+ for (i = 0; i < sizeof_x0213_combining_table; i++)
+ if (x0213_combining_table[i][0] == euc)
+ return x0213_combining_table[i][1];
+ return 0;
+}
+#endif
+
+static nkf_char
+w2e_conv(nkf_char c2, nkf_char c1, nkf_char c0, nkf_char *p2, nkf_char *p1)
+{
+ nkf_char ret = 0;
+
+ if (!c1){
+ *p2 = 0;
+ *p1 = c2;
+ }else if (0xc0 <= c2 && c2 <= 0xef) {
+ ret = unicode_to_jis_common(c2, c1, c0, p2, p1);
+#ifdef NUMCHAR_OPTION
+ if (ret > 0){
+ if (p2) *p2 = 0;
+ if (p1) *p1 = nkf_char_unicode_new(nkf_utf8_to_unicode(c2, c1, c0, 0));
+ ret = 0;
+ }
+#endif
+ }
+ return ret;
+}
+
+#ifdef UTF8_INPUT_ENABLE
+static nkf_char
+w16e_conv(nkf_char val, nkf_char *p2, nkf_char *p1)
+{
+ nkf_char c1, c2, c3, c4;
+ nkf_char ret = 0;
+ val &= VALUE_MASK;
+ if (val < 0x80) {
+ *p2 = 0;
+ *p1 = val;
+ }
+ else if (nkf_char_unicode_bmp_p(val)){
+ nkf_unicode_to_utf8(val, &c1, &c2, &c3, &c4);
+ ret = unicode_to_jis_common(c1, c2, c3, p2, p1);
+ if (ret > 0){
+ *p2 = 0;
+ *p1 = nkf_char_unicode_new(val);
+ ret = 0;
+ }
+ }
+ else {
+ int i;
+ if (x0213_f) {
+ c1 = (val >> 10) + NKF_INT32_C(0xD7C0); /* high surrogate */
+ c2 = (val & 0x3FF) + NKF_INT32_C(0xDC00); /* low surrogate */
+ for (i = 0; i < sizeof_x0213_1_surrogate_table; i++)
+ if (x0213_1_surrogate_table[i][1] == c1 && x0213_1_surrogate_table[i][2] == c2) {
+ val = x0213_1_surrogate_table[i][0];
+ *p2 = val >> 8;
+ *p1 = val & 0xFF;
+ return 0;
+ }
+ for (i = 0; i < sizeof_x0213_2_surrogate_table; i++)
+ if (x0213_2_surrogate_table[i][1] == c1 && x0213_2_surrogate_table[i][2] == c2) {
+ val = x0213_2_surrogate_table[i][0];
+ *p2 = PREFIX_EUCG3 | (val >> 8);
+ *p1 = val & 0xFF;
+ return 0;
+ }
+ }
+ *p2 = 0;
+ *p1 = nkf_char_unicode_new(val);
+ }
+ return ret;
+}
+#endif
+
+static nkf_char
+e_iconv(nkf_char c2, nkf_char c1, nkf_char c0)
+{
+ if (c2 == JIS_X_0201_1976_K || c2 == SS2){
+ if (iso2022jp_f && !x0201_f) {
+ c2 = GETA1; c1 = GETA2;
+ } else {
+ c2 = JIS_X_0201_1976_K;
+ c1 &= 0x7f;
+ }
+#ifdef X0212_ENABLE
+ }else if (c2 == 0x8f){
+ if (c0 == 0){
+ return -1;
+ }
+ if (!cp51932_f && !x0213_f && 0xF5 <= c1 && c1 <= 0xFE && 0xA1 <= c0 && c0 <= 0xFE) {
+ /* encoding is eucJP-ms, so invert to Unicode Private User Area */
+ c1 = nkf_char_unicode_new((c1 - 0xF5) * 94 + c0 - 0xA1 + 0xE3AC);
+ c2 = 0;
+ } else {
+ c2 = (c2 << 8) | (c1 & 0x7f);
+ c1 = c0 & 0x7f;
+#ifdef SHIFTJIS_CP932
+ if (cp51932_f){
+ nkf_char s2, s1;
+ if (e2s_conv(c2, c1, &s2, &s1) == 0){
+ s2e_conv(s2, s1, &c2, &c1);
+ if (c2 < 0x100){
+ c1 &= 0x7f;
+ c2 &= 0x7f;
+ }
+ }
+ }
+#endif /* SHIFTJIS_CP932 */
+ }
+#endif /* X0212_ENABLE */
+ } else if ((c2 == EOF) || (c2 == 0) || c2 < SP || c2 == ISO_8859_1) {
+ /* NOP */
+ } else {
+ if (!cp51932_f && ms_ucs_map_f && 0xF5 <= c2 && c2 <= 0xFE && 0xA1 <= c1 && c1 <= 0xFE) {
+ /* encoding is eucJP-ms, so invert to Unicode Private User Area */
+ c1 = nkf_char_unicode_new((c2 - 0xF5) * 94 + c1 - 0xA1 + 0xE000);
+ c2 = 0;
+ } else {
+ c1 &= 0x7f;
+ c2 &= 0x7f;
+#ifdef SHIFTJIS_CP932
+ if (cp51932_f && 0x79 <= c2 && c2 <= 0x7c){
+ nkf_char s2, s1;
+ if (e2s_conv(c2, c1, &s2, &s1) == 0){
+ s2e_conv(s2, s1, &c2, &c1);
+ if (c2 < 0x100){
+ c1 &= 0x7f;
+ c2 &= 0x7f;
+ }
+ }
+ }
+#endif /* SHIFTJIS_CP932 */
+ }
+ }
+ (*oconv)(c2, c1);
+ return 0;
+}
+
+static nkf_char
+s_iconv(ARG_UNUSED nkf_char c2, nkf_char c1, ARG_UNUSED nkf_char c0)
+{
+ if (c2 == JIS_X_0201_1976_K || (0xA1 <= c2 && c2 <= 0xDF)) {
+ if (iso2022jp_f && !x0201_f) {
+ c2 = GETA1; c1 = GETA2;
+ } else {
+ c1 &= 0x7f;
+ }
+ } else if ((c2 == EOF) || (c2 == 0) || c2 < SP) {
+ /* NOP */
+ } else if (!x0213_f && 0xF0 <= c2 && c2 <= 0xF9 && 0x40 <= c1 && c1 <= 0xFC) {
+ /* CP932 UDC */
+ if(c1 == 0x7F) return 0;
+ c1 = nkf_char_unicode_new((c2 - 0xF0) * 188 + (c1 - 0x40 - (0x7E < c1)) + 0xE000);
+ c2 = 0;
+ } else {
+ nkf_char ret = s2e_conv(c2, c1, &c2, &c1);
+ if (ret) return ret;
+ }
+ (*oconv)(c2, c1);
+ return 0;
+}
+
+static int
+x0213_wait_combining_p(nkf_char wc)
+{
+ int i;
+ for (i = 0; i < sizeof_x0213_combining_table; i++) {
+ if (x0213_combining_table[i][1] == wc) {
+ return TRUE;
+ }
+ }
+ return FALSE;
+}
+
+static int
+x0213_combining_p(nkf_char wc)
+{
+ int i;
+ for (i = 0; i < sizeof_x0213_combining_chars; i++) {
+ if (x0213_combining_chars[i] == wc) {
+ return TRUE;
+ }
+ }
+ return FALSE;
+}
+
+static nkf_char
+w_iconv(nkf_char c1, nkf_char c2, nkf_char c3)
+{
+ nkf_char ret = 0, c4 = 0;
+ static const char w_iconv_utf8_1st_byte[] =
+ { /* 0xC0 - 0xFF */
+ 20, 20, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21,
+ 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21,
+ 30, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 32, 33, 33,
+ 40, 41, 41, 41, 42, 43, 43, 43, 50, 50, 50, 50, 60, 60, 70, 70};
+
+ if (c3 > 0xFF) {
+ c4 = c3 & 0xFF;
+ c3 >>= 8;
+ }
+
+ if (c1 < 0 || 0xff < c1) {
+ }else if (c1 == 0) { /* 0 : 1 byte*/
+ c3 = 0;
+ } else if ((c1 & 0xC0) == 0x80) { /* 0x80-0xbf : trail byte */
+ return 0;
+ } else{
+ switch (w_iconv_utf8_1st_byte[c1 - 0xC0]) {
+ case 21:
+ if (c2 < 0x80 || 0xBF < c2) return 0;
+ break;
+ case 30:
+ if (c3 == 0) return -1;
+ if (c2 < 0xA0 || 0xBF < c2 || (c3 & 0xC0) != 0x80)
+ return 0;
+ break;
+ case 31:
+ case 33:
+ if (c3 == 0) return -1;
+ if ((c2 & 0xC0) != 0x80 || (c3 & 0xC0) != 0x80)
+ return 0;
+ break;
+ case 32:
+ if (c3 == 0) return -1;
+ if (c2 < 0x80 || 0x9F < c2 || (c3 & 0xC0) != 0x80)
+ return 0;
+ break;
+ case 40:
+ if (c3 == 0) return -2;
+ if (c2 < 0x90 || 0xBF < c2 || (c3 & 0xC0) != 0x80 || (c4 & 0xC0) != 0x80)
+ return 0;
+ break;
+ case 41:
+ if (c3 == 0) return -2;
+ if (c2 < 0x80 || 0xBF < c2 || (c3 & 0xC0) != 0x80 || (c4 & 0xC0) != 0x80)
+ return 0;
+ break;
+ case 42:
+ if (c3 == 0) return -2;
+ if (c2 < 0x80 || 0x8F < c2 || (c3 & 0xC0) != 0x80 || (c4 & 0xC0) != 0x80)
+ return 0;
+ break;
+ default:
+ return 0;
+ break;
+ }
+ }
+ if (c1 == 0 || c1 == EOF){
+ } else if ((c1 & 0xf8) == 0xf0) { /* 4 bytes */
+ c2 = nkf_char_unicode_new(nkf_utf8_to_unicode(c1, c2, c3, c4));
+ c1 = 0;
+ } else {
+ if (x0213_f && x0213_wait_combining_p(nkf_utf8_to_unicode(c1, c2, c3, c4)))
+ return -3;
+ ret = w2e_conv(c1, c2, c3, &c1, &c2);
+ }
+ if (ret == 0){
+ (*oconv)(c1, c2);
+ }
+ return ret;
+}
+
+static nkf_char
+w_iconv_nocombine(nkf_char c1, nkf_char c2, nkf_char c3)
+{
+ /* continue from the line below 'return -3;' in w_iconv() */
+ nkf_char ret = w2e_conv(c1, c2, c3, &c1, &c2);
+ if (ret == 0){
+ (*oconv)(c1, c2);
+ }
+ return ret;
+}
+
+#define NKF_ICONV_INVALID_CODE_RANGE -13
+#define NKF_ICONV_WAIT_COMBINING_CHAR -14
+#define NKF_ICONV_NOT_COMBINED -15
+static size_t
+unicode_iconv(nkf_char wc, int nocombine)
+{
+ nkf_char c1, c2;
+ int ret = 0;
+
+ if (wc < 0x80) {
+ c2 = 0;
+ c1 = wc;
+ }else if ((wc>>11) == 27) {
+ /* unpaired surrogate */
+ return NKF_ICONV_INVALID_CODE_RANGE;
+ }else if (wc < 0xFFFF) {
+ if (!nocombine && x0213_f && x0213_wait_combining_p(wc))
+ return NKF_ICONV_WAIT_COMBINING_CHAR;
+ ret = w16e_conv(wc, &c2, &c1);
+ if (ret) return ret;
+ }else if (wc < 0x10FFFF) {
+ c2 = 0;
+ c1 = nkf_char_unicode_new(wc);
+ } else {
+ return NKF_ICONV_INVALID_CODE_RANGE;
+ }
+ (*oconv)(c2, c1);
+ return 0;
+}
+
+static nkf_char
+unicode_iconv_combine(nkf_char wc, nkf_char wc2)
+{
+ nkf_char c1, c2;
+ int i;
+
+ if (wc2 < 0x80) {
+ return NKF_ICONV_NOT_COMBINED;
+ }else if ((wc2>>11) == 27) {
+ /* unpaired surrogate */
+ return NKF_ICONV_INVALID_CODE_RANGE;
+ }else if (wc2 < 0xFFFF) {
+ if (!x0213_combining_p(wc2))
+ return NKF_ICONV_NOT_COMBINED;
+ for (i = 0; i < sizeof_x0213_combining_table; i++) {
+ if (x0213_combining_table[i][1] == wc &&
+ x0213_combining_table[i][2] == wc2) {
+ c2 = x0213_combining_table[i][0] >> 8;
+ c1 = x0213_combining_table[i][0] & 0x7f;
+ (*oconv)(c2, c1);
+ return 0;
+ }
+ }
+ }else if (wc2 < 0x10FFFF) {
+ return NKF_ICONV_NOT_COMBINED;
+ } else {
+ return NKF_ICONV_INVALID_CODE_RANGE;
+ }
+ return NKF_ICONV_NOT_COMBINED;
+}
+
+static nkf_char
+w_iconv_combine(nkf_char c1, nkf_char c2, nkf_char c3, nkf_char c4, nkf_char c5, nkf_char c6)
+{
+ nkf_char wc, wc2;
+ wc = nkf_utf8_to_unicode(c1, c2, c3, 0);
+ wc2 = nkf_utf8_to_unicode(c4, c5, c6, 0);
+ if (wc2 < 0)
+ return wc2;
+ return unicode_iconv_combine(wc, wc2);
+}
+
+#define NKF_ICONV_NEED_ONE_MORE_BYTE (size_t)-1
+#define NKF_ICONV_NEED_TWO_MORE_BYTES (size_t)-2
+static size_t
+nkf_iconv_utf_16(nkf_char c1, nkf_char c2, nkf_char c3, nkf_char c4)
+{
+ nkf_char wc;
+
+ if (c1 == EOF) {
+ (*oconv)(EOF, 0);
+ return 0;
+ }
+
+ if (input_endian == ENDIAN_BIG) {
+ if (0xD8 <= c1 && c1 <= 0xDB) {
+ if (0xDC <= c3 && c3 <= 0xDF) {
+ wc = UTF16_TO_UTF32(c1 << 8 | c2, c3 << 8 | c4);
+ } else return NKF_ICONV_NEED_TWO_MORE_BYTES;
+ } else {
+ wc = c1 << 8 | c2;
+ }
+ } else {
+ if (0xD8 <= c2 && c2 <= 0xDB) {
+ if (0xDC <= c4 && c4 <= 0xDF) {
+ wc = UTF16_TO_UTF32(c2 << 8 | c1, c4 << 8 | c3);
+ } else return NKF_ICONV_NEED_TWO_MORE_BYTES;
+ } else {
+ wc = c2 << 8 | c1;
+ }
+ }
+
+ return (*unicode_iconv)(wc, FALSE);
+}
+
+static size_t
+nkf_iconv_utf_16_combine(nkf_char c1, nkf_char c2, nkf_char c3, nkf_char c4)
+{
+ nkf_char wc, wc2;
+
+ if (input_endian == ENDIAN_BIG) {
+ if (0xD8 <= c3 && c3 <= 0xDB) {
+ return NKF_ICONV_NOT_COMBINED;
+ } else {
+ wc = c1 << 8 | c2;
+ wc2 = c3 << 8 | c4;
+ }
+ } else {
+ if (0xD8 <= c2 && c2 <= 0xDB) {
+ return NKF_ICONV_NOT_COMBINED;
+ } else {
+ wc = c2 << 8 | c1;
+ wc2 = c4 << 8 | c3;
+ }
+ }
+
+ return unicode_iconv_combine(wc, wc2);
+}
+
+static size_t
+nkf_iconv_utf_16_nocombine(nkf_char c1, nkf_char c2)
+{
+ nkf_char wc;
+ if (input_endian == ENDIAN_BIG)
+ wc = c1 << 8 | c2;
+ else
+ wc = c2 << 8 | c1;
+ return (*unicode_iconv)(wc, TRUE);
+}
+
+static nkf_char
+w_iconv16(nkf_char c2, nkf_char c1, ARG_UNUSED nkf_char c0)
+{
+ (*oconv)(c2, c1);
+ return 16; /* different from w_iconv32 */
+}
+
+static nkf_char
+w_iconv32(nkf_char c2, nkf_char c1, ARG_UNUSED nkf_char c0)
+{
+ (*oconv)(c2, c1);
+ return 32; /* different from w_iconv16 */
+}
+
+static nkf_char
+utf32_to_nkf_char(nkf_char c1, nkf_char c2, nkf_char c3, nkf_char c4)
+{
+ nkf_char wc;
+
+ switch(input_endian){
+ case ENDIAN_BIG:
+ wc = c2 << 16 | c3 << 8 | c4;
+ break;
+ case ENDIAN_LITTLE:
+ wc = c3 << 16 | c2 << 8 | c1;
+ break;
+ case ENDIAN_2143:
+ wc = c1 << 16 | c4 << 8 | c3;
+ break;
+ case ENDIAN_3412:
+ wc = c4 << 16 | c1 << 8 | c2;
+ break;
+ default:
+ return NKF_ICONV_INVALID_CODE_RANGE;
+ }
+ return wc;
+}
+
+static size_t
+nkf_iconv_utf_32(nkf_char c1, nkf_char c2, nkf_char c3, nkf_char c4)
+{
+ nkf_char wc;
+
+ if (c1 == EOF) {
+ (*oconv)(EOF, 0);
+ return 0;
+ }
+
+ wc = utf32_to_nkf_char(c1, c2, c3, c4);
+ if (wc < 0)
+ return wc;
+
+ return (*unicode_iconv)(wc, FALSE);
+}
+
+static nkf_char
+nkf_iconv_utf_32_combine(nkf_char c1, nkf_char c2, nkf_char c3, nkf_char c4, nkf_char c5, nkf_char c6, nkf_char c7, nkf_char c8)
+{
+ nkf_char wc, wc2;
+
+ wc = utf32_to_nkf_char(c1, c2, c3, c4);
+ if (wc < 0)
+ return wc;
+ wc2 = utf32_to_nkf_char(c5, c6, c7, c8);
+ if (wc2 < 0)
+ return wc2;
+
+ return unicode_iconv_combine(wc, wc2);
+}
+
+static size_t
+nkf_iconv_utf_32_nocombine(nkf_char c1, nkf_char c2, nkf_char c3, nkf_char c4)
+{
+ nkf_char wc;
+
+ wc = utf32_to_nkf_char(c1, c2, c3, c4);
+ return (*unicode_iconv)(wc, TRUE);
+}
+#endif
+
+#define output_ascii_escape_sequence(mode) do { \
+ if (output_mode != ASCII && output_mode != ISO_8859_1) { \
+ (*o_putc)(ESC); \
+ (*o_putc)('('); \
+ (*o_putc)(ascii_intro); \
+ output_mode = mode; \
+ } \
+ } while (0)
+
+static void
+output_escape_sequence(int mode)
+{
+ if (output_mode == mode)
+ return;
+ switch(mode) {
+ case ISO_8859_1:
+ (*o_putc)(ESC);
+ (*o_putc)('.');
+ (*o_putc)('A');
+ break;
+ case JIS_X_0201_1976_K:
+ (*o_putc)(ESC);
+ (*o_putc)('(');
+ (*o_putc)('I');
+ break;
+ case JIS_X_0208:
+ (*o_putc)(ESC);
+ (*o_putc)('$');
+ (*o_putc)(kanji_intro);
+ break;
+ case JIS_X_0212:
+ (*o_putc)(ESC);
+ (*o_putc)('$');
+ (*o_putc)('(');
+ (*o_putc)('D');
+ break;
+ case JIS_X_0213_1:
+ (*o_putc)(ESC);
+ (*o_putc)('$');
+ (*o_putc)('(');
+ (*o_putc)('Q');
+ break;
+ case JIS_X_0213_2:
+ (*o_putc)(ESC);
+ (*o_putc)('$');
+ (*o_putc)('(');
+ (*o_putc)('P');
+ break;
+ }
+ output_mode = mode;
+}
+
+static void
+j_oconv(nkf_char c2, nkf_char c1)
+{
+#ifdef NUMCHAR_OPTION
+ if (c2 == 0 && nkf_char_unicode_p(c1)){
+ w16e_conv(c1, &c2, &c1);
+ if (c2 == 0 && nkf_char_unicode_p(c1)){
+ c2 = c1 & VALUE_MASK;
+ if (ms_ucs_map_f && 0xE000 <= c2 && c2 <= 0xE757) {
+ /* CP5022x UDC */
+ c1 &= 0xFFF;
+ c2 = 0x7F + c1 / 94;
+ c1 = 0x21 + c1 % 94;
+ } else {
+ if (encode_fallback) (*encode_fallback)(c1);
+ return;
+ }
+ }
+ }
+#endif
+ if (c2 == 0) {
+ output_ascii_escape_sequence(ASCII);
+ (*o_putc)(c1);
+ }
+ else if (c2 == EOF) {
+ output_ascii_escape_sequence(ASCII);
+ (*o_putc)(EOF);
+ }
+ else if (c2 == ISO_8859_1) {
+ output_ascii_escape_sequence(ISO_8859_1);
+ (*o_putc)(c1|0x80);
+ }
+ else if (c2 == JIS_X_0201_1976_K) {
+ output_escape_sequence(JIS_X_0201_1976_K);
+ (*o_putc)(c1);
+#ifdef X0212_ENABLE
+ } else if (is_eucg3(c2)){
+ output_escape_sequence(x0213_f ? JIS_X_0213_2 : JIS_X_0212);
+ (*o_putc)(c2 & 0x7f);
+ (*o_putc)(c1);
+#endif
+ } else {
+ if(ms_ucs_map_f
+ ? c2<0x20 || 0x92<c2 || c1<0x20 || 0x7e<c1
+ : c2<0x20 || 0x7e<c2 || c1<0x20 || 0x7e<c1) return;
+ output_escape_sequence(x0213_f ? JIS_X_0213_1 : JIS_X_0208);
+ (*o_putc)(c2);
+ (*o_putc)(c1);
+ }
+}
+
+static void
+e_oconv(nkf_char c2, nkf_char c1)
+{
+ if (c2 == 0 && nkf_char_unicode_p(c1)){
+ w16e_conv(c1, &c2, &c1);
+ if (c2 == 0 && nkf_char_unicode_p(c1)){
+ c2 = c1 & VALUE_MASK;
+ if (x0212_f && 0xE000 <= c2 && c2 <= 0xE757) {
+ /* eucJP-ms UDC */
+ c1 &= 0xFFF;
+ c2 = c1 / 94;
+ c2 += c2 < 10 ? 0x75 : 0x8FEB;
+ c1 = 0x21 + c1 % 94;
+ if (is_eucg3(c2)){
+ (*o_putc)(0x8f);
+ (*o_putc)((c2 & 0x7f) | 0x080);
+ (*o_putc)(c1 | 0x080);
+ }else{
+ (*o_putc)((c2 & 0x7f) | 0x080);
+ (*o_putc)(c1 | 0x080);
+ }
+ return;
+ } else {
+ if (encode_fallback) (*encode_fallback)(c1);
+ return;
+ }
+ }
+ }
+
+ if (c2 == EOF) {
+ (*o_putc)(EOF);
+ } else if (c2 == 0) {
+ output_mode = ASCII;
+ (*o_putc)(c1);
+ } else if (c2 == JIS_X_0201_1976_K) {
+ output_mode = EUC_JP;
+ (*o_putc)(SS2); (*o_putc)(c1|0x80);
+ } else if (c2 == ISO_8859_1) {
+ output_mode = ISO_8859_1;
+ (*o_putc)(c1 | 0x080);
+#ifdef X0212_ENABLE
+ } else if (is_eucg3(c2)){
+ output_mode = EUC_JP;
+#ifdef SHIFTJIS_CP932
+ if (!cp932inv_f){
+ nkf_char s2, s1;
+ if (e2s_conv(c2, c1, &s2, &s1) == 0){
+ s2e_conv(s2, s1, &c2, &c1);
+ }
+ }
+#endif
+ if (c2 == 0) {
+ output_mode = ASCII;
+ (*o_putc)(c1);
+ }else if (is_eucg3(c2)){
+ if (x0212_f){
+ (*o_putc)(0x8f);
+ (*o_putc)((c2 & 0x7f) | 0x080);
+ (*o_putc)(c1 | 0x080);
+ }
+ }else{
+ (*o_putc)((c2 & 0x7f) | 0x080);
+ (*o_putc)(c1 | 0x080);
+ }
+#endif
+ } else {
+ if (!nkf_isgraph(c1) || !nkf_isgraph(c2)) {
+ set_iconv(FALSE, 0);
+ return; /* too late to rescue this char */
+ }
+ output_mode = EUC_JP;
+ (*o_putc)(c2 | 0x080);
+ (*o_putc)(c1 | 0x080);
+ }
+}
+
+static void
+s_oconv(nkf_char c2, nkf_char c1)
+{
+#ifdef NUMCHAR_OPTION
+ if (c2 == 0 && nkf_char_unicode_p(c1)){
+ w16e_conv(c1, &c2, &c1);
+ if (c2 == 0 && nkf_char_unicode_p(c1)){
+ c2 = c1 & VALUE_MASK;
+ if (!x0213_f && 0xE000 <= c2 && c2 <= 0xE757) {
+ /* CP932 UDC */
+ c1 &= 0xFFF;
+ c2 = c1 / 188 + (cp932inv_f ? 0xF0 : 0xEB);
+ c1 = c1 % 188;
+ c1 += 0x40 + (c1 > 0x3e);
+ (*o_putc)(c2);
+ (*o_putc)(c1);
+ return;
+ } else {
+ if(encode_fallback)(*encode_fallback)(c1);
+ return;
+ }
+ }
+ }
+#endif
+ if (c2 == EOF) {
+ (*o_putc)(EOF);
+ return;
+ } else if (c2 == 0) {
+ output_mode = ASCII;
+ (*o_putc)(c1);
+ } else if (c2 == JIS_X_0201_1976_K) {
+ output_mode = SHIFT_JIS;
+ (*o_putc)(c1|0x80);
+ } else if (c2 == ISO_8859_1) {
+ output_mode = ISO_8859_1;
+ (*o_putc)(c1 | 0x080);
+#ifdef X0212_ENABLE
+ } else if (is_eucg3(c2)){
+ output_mode = SHIFT_JIS;
+ if (e2s_conv(c2, c1, &c2, &c1) == 0){
+ (*o_putc)(c2);
+ (*o_putc)(c1);
+ }
+#endif
+ } else {
+ if (!nkf_isprint(c1) || !nkf_isprint(c2)) {
+ set_iconv(FALSE, 0);
+ return; /* too late to rescue this char */
+ }
+ output_mode = SHIFT_JIS;
+ e2s_conv(c2, c1, &c2, &c1);
+
+#ifdef SHIFTJIS_CP932
+ if (cp932inv_f
+ && CP932INV_TABLE_BEGIN <= c2 && c2 <= CP932INV_TABLE_END){
+ nkf_char c = cp932inv[c2 - CP932INV_TABLE_BEGIN][c1 - 0x40];
+ if (c){
+ c2 = c >> 8;
+ c1 = c & 0xff;
+ }
+ }
+#endif /* SHIFTJIS_CP932 */
+
+ (*o_putc)(c2);
+ if (prefix_table[(unsigned char)c1]){
+ (*o_putc)(prefix_table[(unsigned char)c1]);
+ }
+ (*o_putc)(c1);
+ }
+}
+
+#ifdef UTF8_OUTPUT_ENABLE
+#define OUTPUT_UTF8(val) do { \
+ nkf_unicode_to_utf8(val, &c1, &c2, &c3, &c4); \
+ (*o_putc)(c1); \
+ if (c2) (*o_putc)(c2); \
+ if (c3) (*o_putc)(c3); \
+ if (c4) (*o_putc)(c4); \
+ } while (0)
+
+static void
+w_oconv(nkf_char c2, nkf_char c1)
+{
+ nkf_char c3, c4;
+ nkf_char val, val2;
+
+ if (output_bom_f) {
+ output_bom_f = FALSE;
+ (*o_putc)('\357');
+ (*o_putc)('\273');
+ (*o_putc)('\277');
+ }
+
+ if (c2 == EOF) {
+ (*o_putc)(EOF);
+ return;
+ }
+
+ if (c2 == 0 && nkf_char_unicode_p(c1)){
+ val = c1 & VALUE_MASK;
+ OUTPUT_UTF8(val);
+ return;
+ }
+
+ if (c2 == 0) {
+ (*o_putc)(c1);
+ } else {
+ val = e2w_conv(c2, c1);
+ if (val){
+ val2 = e2w_combining(val, c2, c1);
+ if (val2)
+ OUTPUT_UTF8(val2);
+ OUTPUT_UTF8(val);
+ }
+ }
+}
+
+#define OUTPUT_UTF16_BYTES(c1, c2) do { \
+ if (output_endian == ENDIAN_LITTLE){ \
+ (*o_putc)(c1); \
+ (*o_putc)(c2); \
+ }else{ \
+ (*o_putc)(c2); \
+ (*o_putc)(c1); \
+ } \
+ } while (0)
+
+#define OUTPUT_UTF16(val) do { \
+ if (nkf_char_unicode_bmp_p(val)) { \
+ c2 = (val >> 8) & 0xff; \
+ c1 = val & 0xff; \
+ OUTPUT_UTF16_BYTES(c1, c2); \
+ } else { \
+ val &= VALUE_MASK; \
+ if (val <= UNICODE_MAX) { \
+ c2 = (val >> 10) + NKF_INT32_C(0xD7C0); /* high surrogate */ \
+ c1 = (val & 0x3FF) + NKF_INT32_C(0xDC00); /* low surrogate */ \
+ OUTPUT_UTF16_BYTES(c2 & 0xff, (c2 >> 8) & 0xff); \
+ OUTPUT_UTF16_BYTES(c1 & 0xff, (c1 >> 8) & 0xff); \
+ } \
+ } \
+ } while (0)
+
+static void
+w_oconv16(nkf_char c2, nkf_char c1)
+{
+ if (output_bom_f) {
+ output_bom_f = FALSE;
+ OUTPUT_UTF16_BYTES(0xFF, 0xFE);
+ }
+
+ if (c2 == EOF) {
+ (*o_putc)(EOF);
+ return;
+ }
+
+ if (c2 == 0 && nkf_char_unicode_p(c1)) {
+ OUTPUT_UTF16(c1);
+ } else if (c2) {
+ nkf_char val, val2;
+ val = e2w_conv(c2, c1);
+ if (!val) return;
+ val2 = e2w_combining(val, c2, c1);
+ if (val2)
+ OUTPUT_UTF16(val2);
+ OUTPUT_UTF16(val);
+ } else {
+ OUTPUT_UTF16_BYTES(c1, c2);
+ }
+}
+
+#define OUTPUT_UTF32(c) do { \
+ if (output_endian == ENDIAN_LITTLE){ \
+ (*o_putc)( (c) & 0xFF); \
+ (*o_putc)(((c) >> 8) & 0xFF); \
+ (*o_putc)(((c) >> 16) & 0xFF); \
+ (*o_putc)(0); \
+ }else{ \
+ (*o_putc)(0); \
+ (*o_putc)(((c) >> 16) & 0xFF); \
+ (*o_putc)(((c) >> 8) & 0xFF); \
+ (*o_putc)( (c) & 0xFF); \
+ } \
+ } while (0)
+
+static void
+w_oconv32(nkf_char c2, nkf_char c1)
+{
+ if (output_bom_f) {
+ output_bom_f = FALSE;
+ if (output_endian == ENDIAN_LITTLE){
+ (*o_putc)(0xFF);
+ (*o_putc)(0xFE);
+ (*o_putc)(0);
+ (*o_putc)(0);
+ }else{
+ (*o_putc)(0);
+ (*o_putc)(0);
+ (*o_putc)(0xFE);
+ (*o_putc)(0xFF);
+ }
+ }
+
+ if (c2 == EOF) {
+ (*o_putc)(EOF);
+ return;
+ }
+
+ if (c2 == ISO_8859_1) {
+ c1 |= 0x80;
+ } else if (c2 == 0 && nkf_char_unicode_p(c1)) {
+ c1 &= VALUE_MASK;
+ } else if (c2) {
+ nkf_char val, val2;
+ val = e2w_conv(c2, c1);
+ if (!val) return;
+ val2 = e2w_combining(val, c2, c1);
+ if (val2)
+ OUTPUT_UTF32(val2);
+ c1 = val;
+ }
+ OUTPUT_UTF32(c1);
+}
+#endif
+
+#define SCORE_L2 (1) /* Kanji Level 2 */
+#define SCORE_KANA (SCORE_L2 << 1) /* Halfwidth Katakana */
+#define SCORE_DEPEND (SCORE_KANA << 1) /* MD Characters */
+#define SCORE_CP932 (SCORE_DEPEND << 1) /* IBM extended characters */
+#define SCORE_X0212 (SCORE_CP932 << 1) /* JIS X 0212 */
+#define SCORE_X0213 (SCORE_X0212 << 1) /* JIS X 0213 */
+#define SCORE_NO_EXIST (SCORE_X0213 << 1) /* Undefined Characters */
+#define SCORE_iMIME (SCORE_NO_EXIST << 1) /* MIME selected */
+#define SCORE_ERROR (SCORE_iMIME << 1) /* Error */
+
+#define SCORE_INIT (SCORE_iMIME)
+
+static const nkf_char score_table_A0[] = {
+ 0, 0, 0, 0,
+ 0, 0, 0, 0,
+ 0, SCORE_DEPEND, SCORE_DEPEND, SCORE_DEPEND,
+ SCORE_DEPEND, SCORE_DEPEND, SCORE_DEPEND, SCORE_X0213,
+};
+
+static const nkf_char score_table_F0[] = {
+ SCORE_L2, SCORE_L2, SCORE_L2, SCORE_L2,
+ SCORE_L2, SCORE_DEPEND, SCORE_X0213, SCORE_X0213,
+ SCORE_DEPEND, SCORE_DEPEND, SCORE_CP932, SCORE_CP932,
+ SCORE_CP932, SCORE_X0213, SCORE_X0213, SCORE_ERROR,
+};
+
+static const nkf_char score_table_8FA0[] = {
+ 0, SCORE_X0213, SCORE_X0212, SCORE_X0213,
+ SCORE_X0213, SCORE_X0213, SCORE_X0212, SCORE_X0212,
+ SCORE_X0213, SCORE_X0212, SCORE_X0212, SCORE_X0212,
+ SCORE_X0213, SCORE_X0213, SCORE_X0213, SCORE_X0213,
+};
+
+static const nkf_char score_table_8FE0[] = {
+ SCORE_X0212, SCORE_X0212, SCORE_X0212, SCORE_X0212,
+ SCORE_X0212, SCORE_X0212, SCORE_X0212, SCORE_X0212,
+ SCORE_X0212, SCORE_X0212, SCORE_X0212, SCORE_X0212,
+ SCORE_X0212, SCORE_X0212, SCORE_X0213, SCORE_X0213,
+};
+
+static const nkf_char score_table_8FF0[] = {
+ SCORE_X0213, SCORE_X0213, SCORE_X0213, SCORE_X0212,
+ SCORE_X0212, SCORE_X0213, SCORE_X0213, SCORE_X0213,
+ SCORE_X0213, SCORE_X0213, SCORE_X0213, SCORE_X0213,
+ SCORE_X0213, SCORE_X0213, SCORE_X0213, SCORE_X0213,
+};
+
+static void
+set_code_score(struct input_code *ptr, nkf_char score)
+{
+ if (ptr){
+ ptr->score |= score;
+ }
+}
+
+static void
+clr_code_score(struct input_code *ptr, nkf_char score)
+{
+ if (ptr){
+ ptr->score &= ~score;
+ }
+}
+
+static void
+code_score(struct input_code *ptr)
+{
+ nkf_char c2 = ptr->buf[0];
+ nkf_char c1 = ptr->buf[1];
+ if (c2 < 0){
+ set_code_score(ptr, SCORE_ERROR);
+ }else if (c2 == SS2){
+ set_code_score(ptr, SCORE_KANA);
+ }else if (c2 == 0x8f){
+ if ((c1 & 0x70) == 0x20){
+ set_code_score(ptr, score_table_8FA0[c1 & 0x0f]);
+ }else if ((c1 & 0x70) == 0x60){
+ set_code_score(ptr, score_table_8FE0[c1 & 0x0f]);
+ }else if ((c1 & 0x70) == 0x70){
+ set_code_score(ptr, score_table_8FF0[c1 & 0x0f]);
+ }else{
+ set_code_score(ptr, SCORE_X0212);
+ }
+#ifdef UTF8_OUTPUT_ENABLE
+ }else if (!e2w_conv(c2, c1)){
+ set_code_score(ptr, SCORE_NO_EXIST);
+#endif
+ }else if ((c2 & 0x70) == 0x20){
+ set_code_score(ptr, score_table_A0[c2 & 0x0f]);
+ }else if ((c2 & 0x70) == 0x70){
+ set_code_score(ptr, score_table_F0[c2 & 0x0f]);
+ }else if ((c2 & 0x70) >= 0x50){
+ set_code_score(ptr, SCORE_L2);
+ }
+}
+
+static void
+status_disable(struct input_code *ptr)
+{
+ ptr->stat = -1;
+ ptr->buf[0] = -1;
+ code_score(ptr);
+ if (iconv == ptr->iconv_func) set_iconv(FALSE, 0);
+}
+
+static void
+status_push_ch(struct input_code *ptr, nkf_char c)
+{
+ ptr->buf[ptr->index++] = c;
+}
+
+static void
+status_clear(struct input_code *ptr)
+{
+ ptr->stat = 0;
+ ptr->index = 0;
+}
+
+static void
+status_reset(struct input_code *ptr)
+{
+ status_clear(ptr);
+ ptr->score = SCORE_INIT;
+}
+
+static void
+status_reinit(struct input_code *ptr)
+{
+ status_reset(ptr);
+ ptr->_file_stat = 0;
+}
+
+static void
+status_check(struct input_code *ptr, nkf_char c)
+{
+ if (c <= DEL && estab_f){
+ status_reset(ptr);
+ }
+}
+
+static void
+s_status(struct input_code *ptr, nkf_char c)
+{
+ switch(ptr->stat){
+ case -1:
+ status_check(ptr, c);
+ break;
+ case 0:
+ if (c <= DEL){
+ break;
+ }else if (nkf_char_unicode_p(c)){
+ break;
+ }else if (0xa1 <= c && c <= 0xdf){
+ status_push_ch(ptr, SS2);
+ status_push_ch(ptr, c);
+ code_score(ptr);
+ status_clear(ptr);
+ }else if ((0x81 <= c && c < 0xa0) || (0xe0 <= c && c <= 0xea)){
+ ptr->stat = 1;
+ status_push_ch(ptr, c);
+ }else if (0xed <= c && c <= 0xee){
+ ptr->stat = 3;
+ status_push_ch(ptr, c);
+#ifdef SHIFTJIS_CP932
+ }else if (is_ibmext_in_sjis(c)){
+ ptr->stat = 2;
+ status_push_ch(ptr, c);
+#endif /* SHIFTJIS_CP932 */
+#ifdef X0212_ENABLE
+ }else if (0xf0 <= c && c <= 0xfc){
+ ptr->stat = 1;
+ status_push_ch(ptr, c);
+#endif /* X0212_ENABLE */
+ }else{
+ status_disable(ptr);
+ }
+ break;
+ case 1:
+ if ((0x40 <= c && c <= 0x7e) || (0x80 <= c && c <= 0xfc)){
+ status_push_ch(ptr, c);
+ s2e_conv(ptr->buf[0], ptr->buf[1], &ptr->buf[0], &ptr->buf[1]);
+ code_score(ptr);
+ status_clear(ptr);
+ }else{
+ status_disable(ptr);
+ }
+ break;
+ case 2:
+#ifdef SHIFTJIS_CP932
+ if ((0x40 <= c && c <= 0x7e) || (0x80 <= c && c <= 0xfc)) {
+ status_push_ch(ptr, c);
+ if (s2e_conv(ptr->buf[0], ptr->buf[1], &ptr->buf[0], &ptr->buf[1]) == 0) {
+ set_code_score(ptr, SCORE_CP932);
+ status_clear(ptr);
+ break;
+ }
+ }
+#endif /* SHIFTJIS_CP932 */
+ status_disable(ptr);
+ break;
+ case 3:
+ if ((0x40 <= c && c <= 0x7e) || (0x80 <= c && c <= 0xfc)){
+ status_push_ch(ptr, c);
+ s2e_conv(ptr->buf[0], ptr->buf[1], &ptr->buf[0], &ptr->buf[1]);
+ set_code_score(ptr, SCORE_CP932);
+ status_clear(ptr);
+ }else{
+ status_disable(ptr);
+ }
+ break;
+ }
+}
+
+static void
+e_status(struct input_code *ptr, nkf_char c)
+{
+ switch (ptr->stat){
+ case -1:
+ status_check(ptr, c);
+ break;
+ case 0:
+ if (c <= DEL){
+ break;
+ }else if (nkf_char_unicode_p(c)){
+ break;
+ }else if (SS2 == c || (0xa1 <= c && c <= 0xfe)){
+ ptr->stat = 1;
+ status_push_ch(ptr, c);
+#ifdef X0212_ENABLE
+ }else if (0x8f == c){
+ ptr->stat = 2;
+ status_push_ch(ptr, c);
+#endif /* X0212_ENABLE */
+ }else{
+ status_disable(ptr);
+ }
+ break;
+ case 1:
+ if (0xa1 <= c && c <= 0xfe){
+ status_push_ch(ptr, c);
+ code_score(ptr);
+ status_clear(ptr);
+ }else{
+ status_disable(ptr);
+ }
+ break;
+#ifdef X0212_ENABLE
+ case 2:
+ if (0xa1 <= c && c <= 0xfe){
+ ptr->stat = 1;
+ status_push_ch(ptr, c);
+ }else{
+ status_disable(ptr);
+ }
+#endif /* X0212_ENABLE */
+ }
+}
+
+#ifdef UTF8_INPUT_ENABLE
+static void
+w_status(struct input_code *ptr, nkf_char c)
+{
+ switch (ptr->stat){
+ case -1:
+ status_check(ptr, c);
+ break;
+ case 0:
+ if (c <= DEL){
+ break;
+ }else if (nkf_char_unicode_p(c)){
+ break;
+ }else if (0xc0 <= c && c <= 0xdf){
+ ptr->stat = 1;
+ status_push_ch(ptr, c);
+ }else if (0xe0 <= c && c <= 0xef){
+ ptr->stat = 2;
+ status_push_ch(ptr, c);
+ }else if (0xf0 <= c && c <= 0xf4){
+ ptr->stat = 3;
+ status_push_ch(ptr, c);
+ }else{
+ status_disable(ptr);
+ }
+ break;
+ case 1:
+ case 2:
+ if (0x80 <= c && c <= 0xbf){
+ status_push_ch(ptr, c);
+ if (ptr->index > ptr->stat){
+ int bom = (ptr->buf[0] == 0xef && ptr->buf[1] == 0xbb
+ && ptr->buf[2] == 0xbf);
+ w2e_conv(ptr->buf[0], ptr->buf[1], ptr->buf[2],
+ &ptr->buf[0], &ptr->buf[1]);
+ if (!bom){
+ code_score(ptr);
+ }
+ status_clear(ptr);
+ }
+ }else{
+ status_disable(ptr);
+ }
+ break;
+ case 3:
+ if (0x80 <= c && c <= 0xbf){
+ if (ptr->index < ptr->stat){
+ status_push_ch(ptr, c);
+ } else {
+ status_clear(ptr);
+ }
+ }else{
+ status_disable(ptr);
+ }
+ break;
+ }
+}
+#endif
+
+static void
+code_status(nkf_char c)
+{
+ int action_flag = 1;
+ struct input_code *result = 0;
+ struct input_code *p = input_code_list;
+ while (p->name){
+ if (!p->status_func) {
+ ++p;
+ continue;
+ }
+ if (!p->status_func)
+ continue;
+ (p->status_func)(p, c);
+ if (p->stat > 0){
+ action_flag = 0;
+ }else if(p->stat == 0){
+ if (result){
+ action_flag = 0;
+ }else{
+ result = p;
+ }
+ }
+ ++p;
+ }
+
+ if (action_flag){
+ if (result && !estab_f){
+ set_iconv(TRUE, result->iconv_func);
+ }else if (c <= DEL){
+ struct input_code *ptr = input_code_list;
+ while (ptr->name){
+ status_reset(ptr);
+ ++ptr;
+ }
+ }
+ }
+}
+
+typedef struct {
+ nkf_buf_t *std_gc_buf;
+ nkf_char broken_state;
+ nkf_buf_t *broken_buf;
+ nkf_char mimeout_state;
+ nkf_buf_t *nfc_buf;
+} nkf_state_t;
+
+static nkf_state_t *nkf_state = NULL;
+
+#define STD_GC_BUFSIZE (256)
+
+static void
+nkf_state_init(void)
+{
+ if (nkf_state) {
+ nkf_buf_clear(nkf_state->std_gc_buf);
+ nkf_buf_clear(nkf_state->broken_buf);
+ nkf_buf_clear(nkf_state->nfc_buf);
+ }
+ else {
+ nkf_state = nkf_xmalloc(sizeof(nkf_state_t));
+ nkf_state->std_gc_buf = nkf_buf_new(STD_GC_BUFSIZE);
+ nkf_state->broken_buf = nkf_buf_new(3);
+ nkf_state->nfc_buf = nkf_buf_new(9);
+ }
+ nkf_state->broken_state = 0;
+ nkf_state->mimeout_state = 0;
+}
+
+#ifndef WIN32DLL
+static nkf_char
+std_getc(FILE *f)
+{
+ if (!nkf_buf_empty_p(nkf_state->std_gc_buf)){
+ return nkf_buf_pop(nkf_state->std_gc_buf);
+ }
+ return getc(f);
+}
+#endif /*WIN32DLL*/
+
+static nkf_char
+std_ungetc(nkf_char c, ARG_UNUSED FILE *f)
+{
+ nkf_buf_push(nkf_state->std_gc_buf, c);
+ return c;
+}
+
+#ifndef WIN32DLL
+static void
+std_putc(nkf_char c)
+{
+ if(c!=EOF)
+ putchar(c);
+}
+#endif /*WIN32DLL*/
+
+static nkf_char hold_buf[HOLD_SIZE*2];
+static int hold_count = 0;
+static nkf_char
+push_hold_buf(nkf_char c2)
+{
+ if (hold_count >= HOLD_SIZE*2)
+ return (EOF);
+ hold_buf[hold_count++] = c2;
+ return ((hold_count >= HOLD_SIZE*2) ? EOF : hold_count);
+}
+
+static int
+h_conv(FILE *f, nkf_char c1, nkf_char c2)
+{
+ int ret;
+ int hold_index;
+ int fromhold_count;
+ nkf_char c3, c4;
+
+ /** it must NOT be in the kanji shifte sequence */
+ /** it must NOT be written in JIS7 */
+ /** and it must be after 2 byte 8bit code */
+
+ hold_count = 0;
+ push_hold_buf(c1);
+ push_hold_buf(c2);
+
+ while ((c2 = (*i_getc)(f)) != EOF) {
+ if (c2 == ESC){
+ (*i_ungetc)(c2,f);
+ break;
+ }
+ code_status(c2);
+ if (push_hold_buf(c2) == EOF || estab_f) {
+ break;
+ }
+ }
+
+ if (!estab_f) {
+ struct input_code *p = input_code_list;
+ struct input_code *result = p;
+ if (c2 == EOF) {
+ code_status(c2);
+ }
+ while (p->name) {
+ if (p->status_func && p->score < result->score) {
+ result = p;
+ }
+ p++;
+ }
+ set_iconv(TRUE, result->iconv_func);
+ }
+
+
+ /** now,
+ ** 1) EOF is detected, or
+ ** 2) Code is established, or
+ ** 3) Buffer is FULL (but last word is pushed)
+ **
+ ** in 1) and 3) cases, we continue to use
+ ** Kanji codes by oconv and leave estab_f unchanged.
+ **/
+
+ ret = c2;
+ hold_index = 0;
+ while (hold_index < hold_count){
+ c1 = hold_buf[hold_index++];
+ if (nkf_char_unicode_p(c1)) {
+ (*oconv)(0, c1);
+ continue;
+ }
+ else if (c1 <= DEL){
+ (*iconv)(0, c1, 0);
+ continue;
+ }else if (iconv == s_iconv && 0xa1 <= c1 && c1 <= 0xdf){
+ (*iconv)(JIS_X_0201_1976_K, c1, 0);
+ continue;
+ }
+ fromhold_count = 1;
+ if (hold_index < hold_count){
+ c2 = hold_buf[hold_index++];
+ fromhold_count++;
+ }else{
+ c2 = (*i_getc)(f);
+ if (c2 == EOF){
+ c4 = EOF;
+ break;
+ }
+ code_status(c2);
+ }
+ c3 = 0;
+ switch ((*iconv)(c1, c2, 0)) { /* can be EUC/SJIS/UTF-8 */
+ case -2:
+ /* 4 bytes UTF-8 */
+ if (hold_index < hold_count){
+ c3 = hold_buf[hold_index++];
+ } else if ((c3 = (*i_getc)(f)) == EOF) {
+ ret = EOF;
+ break;
+ }
+ code_status(c3);
+ if (hold_index < hold_count){
+ c4 = hold_buf[hold_index++];
+ } else if ((c4 = (*i_getc)(f)) == EOF) {
+ c3 = ret = EOF;
+ break;
+ }
+ code_status(c4);
+ (*iconv)(c1, c2, (c3<<8)|c4);
+ break;
+ case -3:
+ /* 4 bytes UTF-8 (check combining character) */
+ if (hold_index < hold_count){
+ c3 = hold_buf[hold_index++];
+ fromhold_count++;
+ } else if ((c3 = (*i_getc)(f)) == EOF) {
+ w_iconv_nocombine(c1, c2, 0);
+ break;
+ }
+ if (hold_index < hold_count){
+ c4 = hold_buf[hold_index++];
+ fromhold_count++;
+ } else if ((c4 = (*i_getc)(f)) == EOF) {
+ w_iconv_nocombine(c1, c2, 0);
+ if (fromhold_count <= 2)
+ (*i_ungetc)(c3,f);
+ else
+ hold_index--;
+ continue;
+ }
+ if (w_iconv_combine(c1, c2, 0, c3, c4, 0)) {
+ w_iconv_nocombine(c1, c2, 0);
+ if (fromhold_count <= 2) {
+ (*i_ungetc)(c4,f);
+ (*i_ungetc)(c3,f);
+ } else if (fromhold_count == 3) {
+ (*i_ungetc)(c4,f);
+ hold_index--;
+ } else {
+ hold_index -= 2;
+ }
+ }
+ break;
+ case -1:
+ /* 3 bytes EUC or UTF-8 */
+ if (hold_index < hold_count){
+ c3 = hold_buf[hold_index++];
+ fromhold_count++;
+ } else if ((c3 = (*i_getc)(f)) == EOF) {
+ ret = EOF;
+ break;
+ } else {
+ code_status(c3);
+ }
+ if ((*iconv)(c1, c2, c3) == -3) {
+ /* 6 bytes UTF-8 (check combining character) */
+ nkf_char c5, c6;
+ if (hold_index < hold_count){
+ c4 = hold_buf[hold_index++];
+ fromhold_count++;
+ } else if ((c4 = (*i_getc)(f)) == EOF) {
+ w_iconv_nocombine(c1, c2, c3);
+ continue;
+ }
+ if (hold_index < hold_count){
+ c5 = hold_buf[hold_index++];
+ fromhold_count++;
+ } else if ((c5 = (*i_getc)(f)) == EOF) {
+ w_iconv_nocombine(c1, c2, c3);
+ if (fromhold_count == 4)
+ hold_index--;
+ else
+ (*i_ungetc)(c4,f);
+ continue;
+ }
+ if (hold_index < hold_count){
+ c6 = hold_buf[hold_index++];
+ fromhold_count++;
+ } else if ((c6 = (*i_getc)(f)) == EOF) {
+ w_iconv_nocombine(c1, c2, c3);
+ if (fromhold_count == 5) {
+ hold_index -= 2;
+ } else if (fromhold_count == 4) {
+ hold_index--;
+ (*i_ungetc)(c5,f);
+ } else {
+ (*i_ungetc)(c5,f);
+ (*i_ungetc)(c4,f);
+ }
+ continue;
+ }
+ if (w_iconv_combine(c1, c2, c3, c4, c5, c6)) {
+ w_iconv_nocombine(c1, c2, c3);
+ if (fromhold_count == 6) {
+ hold_index -= 3;
+ } else if (fromhold_count == 5) {
+ hold_index -= 2;
+ (*i_ungetc)(c6,f);
+ } else if (fromhold_count == 4) {
+ hold_index--;
+ (*i_ungetc)(c6,f);
+ (*i_ungetc)(c5,f);
+ } else {
+ (*i_ungetc)(c6,f);
+ (*i_ungetc)(c5,f);
+ (*i_ungetc)(c4,f);
+ }
+ }
+ }
+ break;
+ }
+ if (c3 == EOF) break;
+ }
+ return ret;
+}
+
+/*
+ * Check and Ignore BOM
+ */
+static void
+check_bom(FILE *f)
+{
+ int c2;
+ switch(c2 = (*i_getc)(f)){
+ case 0x00:
+ if((c2 = (*i_getc)(f)) == 0x00){
+ if((c2 = (*i_getc)(f)) == 0xFE){
+ if((c2 = (*i_getc)(f)) == 0xFF){
+ if(!input_encoding){
+ set_iconv(TRUE, w_iconv32);
+ }
+ if (iconv == w_iconv32) {
+ input_bom_f = TRUE;
+ input_endian = ENDIAN_BIG;
+ return;
+ }
+ (*i_ungetc)(0xFF,f);
+ }else (*i_ungetc)(c2,f);
+ (*i_ungetc)(0xFE,f);
+ }else if(c2 == 0xFF){
+ if((c2 = (*i_getc)(f)) == 0xFE){
+ if(!input_encoding){
+ set_iconv(TRUE, w_iconv32);
+ }
+ if (iconv == w_iconv32) {
+ input_endian = ENDIAN_2143;
+ return;
+ }
+ (*i_ungetc)(0xFF,f);
+ }else (*i_ungetc)(c2,f);
+ (*i_ungetc)(0xFF,f);
+ }else (*i_ungetc)(c2,f);
+ (*i_ungetc)(0x00,f);
+ }else (*i_ungetc)(c2,f);
+ (*i_ungetc)(0x00,f);
+ break;
+ case 0xEF:
+ if((c2 = (*i_getc)(f)) == 0xBB){
+ if((c2 = (*i_getc)(f)) == 0xBF){
+ if(!input_encoding){
+ set_iconv(TRUE, w_iconv);
+ }
+ if (iconv == w_iconv) {
+ input_bom_f = TRUE;
+ return;
+ }
+ (*i_ungetc)(0xBF,f);
+ }else (*i_ungetc)(c2,f);
+ (*i_ungetc)(0xBB,f);
+ }else (*i_ungetc)(c2,f);
+ (*i_ungetc)(0xEF,f);
+ break;
+ case 0xFE:
+ if((c2 = (*i_getc)(f)) == 0xFF){
+ if((c2 = (*i_getc)(f)) == 0x00){
+ if((c2 = (*i_getc)(f)) == 0x00){
+ if(!input_encoding){
+ set_iconv(TRUE, w_iconv32);
+ }
+ if (iconv == w_iconv32) {
+ input_endian = ENDIAN_3412;
+ return;
+ }
+ (*i_ungetc)(0x00,f);
+ }else (*i_ungetc)(c2,f);
+ (*i_ungetc)(0x00,f);
+ }else (*i_ungetc)(c2,f);
+ if(!input_encoding){
+ set_iconv(TRUE, w_iconv16);
+ }
+ if (iconv == w_iconv16) {
+ input_endian = ENDIAN_BIG;
+ input_bom_f = TRUE;
+ return;
+ }
+ (*i_ungetc)(0xFF,f);
+ }else (*i_ungetc)(c2,f);
+ (*i_ungetc)(0xFE,f);
+ break;
+ case 0xFF:
+ if((c2 = (*i_getc)(f)) == 0xFE){
+ if((c2 = (*i_getc)(f)) == 0x00){
+ if((c2 = (*i_getc)(f)) == 0x00){
+ if(!input_encoding){
+ set_iconv(TRUE, w_iconv32);
+ }
+ if (iconv == w_iconv32) {
+ input_endian = ENDIAN_LITTLE;
+ input_bom_f = TRUE;
+ return;
+ }
+ (*i_ungetc)(0x00,f);
+ }else (*i_ungetc)(c2,f);
+ (*i_ungetc)(0x00,f);
+ }else (*i_ungetc)(c2,f);
+ if(!input_encoding){
+ set_iconv(TRUE, w_iconv16);
+ }
+ if (iconv == w_iconv16) {
+ input_endian = ENDIAN_LITTLE;
+ input_bom_f = TRUE;
+ return;
+ }
+ (*i_ungetc)(0xFE,f);
+ }else (*i_ungetc)(c2,f);
+ (*i_ungetc)(0xFF,f);
+ break;
+ default:
+ (*i_ungetc)(c2,f);
+ break;
+ }
+}
+
+static nkf_char
+broken_getc(FILE *f)
+{
+ nkf_char c, c1;
+
+ if (!nkf_buf_empty_p(nkf_state->broken_buf)) {
+ return nkf_buf_pop(nkf_state->broken_buf);
+ }
+ c = (*i_bgetc)(f);
+ if (c=='$' && nkf_state->broken_state != ESC
+ && (input_mode == ASCII || input_mode == JIS_X_0201_1976_K)) {
+ c1= (*i_bgetc)(f);
+ nkf_state->broken_state = 0;
+ if (c1=='@'|| c1=='B') {
+ nkf_buf_push(nkf_state->broken_buf, c1);
+ nkf_buf_push(nkf_state->broken_buf, c);
+ return ESC;
+ } else {
+ (*i_bungetc)(c1,f);
+ return c;
+ }
+ } else if (c=='(' && nkf_state->broken_state != ESC
+ && (input_mode == JIS_X_0208 || input_mode == JIS_X_0201_1976_K)) {
+ c1= (*i_bgetc)(f);
+ nkf_state->broken_state = 0;
+ if (c1=='J'|| c1=='B') {
+ nkf_buf_push(nkf_state->broken_buf, c1);
+ nkf_buf_push(nkf_state->broken_buf, c);
+ return ESC;
+ } else {
+ (*i_bungetc)(c1,f);
+ return c;
+ }
+ } else {
+ nkf_state->broken_state = c;
+ return c;
+ }
+}
+
+static nkf_char
+broken_ungetc(nkf_char c, ARG_UNUSED FILE *f)
+{
+ if (nkf_buf_length(nkf_state->broken_buf) < 2)
+ nkf_buf_push(nkf_state->broken_buf, c);
+ return c;
+}
+
+static void
+eol_conv(nkf_char c2, nkf_char c1)
+{
+ if (guess_f && input_eol != EOF) {
+ if (c2 == 0 && c1 == LF) {
+ if (!input_eol) input_eol = prev_cr ? CRLF : LF;
+ else if (input_eol != (prev_cr ? CRLF : LF)) input_eol = EOF;
+ } else if (c2 == 0 && c1 == CR && input_eol == LF) input_eol = EOF;
+ else if (!prev_cr);
+ else if (!input_eol) input_eol = CR;
+ else if (input_eol != CR) input_eol = EOF;
+ }
+ if (prev_cr || (c2 == 0 && c1 == LF)) {
+ prev_cr = 0;
+ if (eolmode_f != LF) (*o_eol_conv)(0, CR);
+ if (eolmode_f != CR) (*o_eol_conv)(0, LF);
+ }
+ if (c2 == 0 && c1 == CR) prev_cr = CR;
+ else if (c2 != 0 || c1 != LF) (*o_eol_conv)(c2, c1);
+}
+
+static void
+put_newline(void (*func)(nkf_char))
+{
+ switch (eolmode_f ? eolmode_f : DEFAULT_NEWLINE) {
+ case CRLF:
+ (*func)(0x0D);
+ (*func)(0x0A);
+ break;
+ case CR:
+ (*func)(0x0D);
+ break;
+ case LF:
+ (*func)(0x0A);
+ break;
+ }
+}
+
+static void
+oconv_newline(void (*func)(nkf_char, nkf_char))
+{
+ switch (eolmode_f ? eolmode_f : DEFAULT_NEWLINE) {
+ case CRLF:
+ (*func)(0, 0x0D);
+ (*func)(0, 0x0A);
+ break;
+ case CR:
+ (*func)(0, 0x0D);
+ break;
+ case LF:
+ (*func)(0, 0x0A);
+ break;
+ }
+}
+
+/*
+ Return value of fold_conv()
+
+ LF add newline and output char
+ CR add newline and output nothing
+ SP space
+ 0 skip
+ 1 (or else) normal output
+
+ fold state in prev (previous character)
+
+ >0x80 Japanese (X0208/X0201)
+ <0x80 ASCII
+ LF new line
+ SP space
+
+ This fold algorthm does not preserve heading space in a line.
+ This is the main difference from fmt.
+ */
+
+#define char_size(c2,c1) (c2?2:1)
+
+static void
+fold_conv(nkf_char c2, nkf_char c1)
+{
+ nkf_char prev0;
+ nkf_char fold_state;
+
+ if (c1== CR && !fold_preserve_f) {
+ fold_state=0; /* ignore cr */
+ }else if (c1== LF&&f_prev==CR && fold_preserve_f) {
+ f_prev = LF;
+ fold_state=0; /* ignore cr */
+ } else if (c1== BS) {
+ if (f_line>0) f_line--;
+ fold_state = 1;
+ } else if (c2==EOF && f_line != 0) { /* close open last line */
+ fold_state = LF;
+ } else if ((c1==LF && !fold_preserve_f)
+ || ((c1==CR||(c1==LF&&f_prev!=CR))
+ && fold_preserve_f)) {
+ /* new line */
+ if (fold_preserve_f) {
+ f_prev = c1;
+ f_line = 0;
+ fold_state = CR;
+ } else if ((f_prev == c1 && !fold_preserve_f)
+ || (f_prev == LF && fold_preserve_f)
+ ) { /* duplicate newline */
+ if (f_line) {
+ f_line = 0;
+ fold_state = LF; /* output two newline */
+ } else {
+ f_line = 0;
+ fold_state = 1;
+ }
+ } else {
+ if (f_prev&0x80) { /* Japanese? */
+ f_prev = c1;
+ fold_state = 0; /* ignore given single newline */
+ } else if (f_prev==SP) {
+ fold_state = 0;
+ } else {
+ f_prev = c1;
+ if (++f_line<=fold_len)
+ fold_state = SP;
+ else {
+ f_line = 0;
+ fold_state = CR; /* fold and output nothing */
+ }
+ }
+ }
+ } else if (c1=='\f') {
+ f_prev = LF;
+ f_line = 0;
+ fold_state = LF; /* output newline and clear */
+ } else if ((c2==0 && nkf_isblank(c1)) || (c2 == '!' && c1 == '!')) {
+ /* X0208 kankaku or ascii space */
+ if (f_prev == SP) {
+ fold_state = 0; /* remove duplicate spaces */
+ } else {
+ f_prev = SP;
+ if (++f_line<=fold_len)
+ fold_state = SP; /* output ASCII space only */
+ else {
+ f_prev = SP; f_line = 0;
+ fold_state = CR; /* fold and output nothing */
+ }
+ }
+ } else {
+ prev0 = f_prev; /* we still need this one... , but almost done */
+ f_prev = c1;
+ if (c2 || c2 == JIS_X_0201_1976_K)
+ f_prev |= 0x80; /* this is Japanese */
+ f_line += c2 == JIS_X_0201_1976_K ? 1: char_size(c2,c1);
+ if (f_line<=fold_len) { /* normal case */
+ fold_state = 1;
+ } else {
+ if (f_line>fold_len+fold_margin) { /* too many kinsoku suspension */
+ f_line = char_size(c2,c1);
+ fold_state = LF; /* We can't wait, do fold now */
+ } else if (c2 == JIS_X_0201_1976_K) {
+ /* simple kinsoku rules return 1 means no folding */
+ if (c1==(0xde&0x7f)) fold_state = 1; /* $B!+(B*/
+ else if (c1==(0xdf&0x7f)) fold_state = 1; /* $B!,(B*/
+ else if (c1==(0xa4&0x7f)) fold_state = 1; /* $B!#(B*/
+ else if (c1==(0xa3&0x7f)) fold_state = 1; /* $B!$(B*/
+ else if (c1==(0xa1&0x7f)) fold_state = 1; /* $B!W(B*/
+ else if (c1==(0xb0&0x7f)) fold_state = 1; /* - */
+ else if (SP<=c1 && c1<=(0xdf&0x7f)) { /* X0201 */
+ f_line = 1;
+ fold_state = LF;/* add one new f_line before this character */
+ } else {
+ f_line = 1;
+ fold_state = LF;/* add one new f_line before this character */
+ }
+ } else if (c2==0) {
+ /* kinsoku point in ASCII */
+ if ( c1==')'|| /* { [ ( */
+ c1==']'||
+ c1=='}'||
+ c1=='.'||
+ c1==','||
+ c1=='!'||
+ c1=='?'||
+ c1=='/'||
+ c1==':'||
+ c1==';') {
+ fold_state = 1;
+ /* just after special */
+ } else if (!is_alnum(prev0)) {
+ f_line = char_size(c2,c1);
+ fold_state = LF;
+ } else if ((prev0==SP) || /* ignored new f_line */
+ (prev0==LF)|| /* ignored new f_line */
+ (prev0&0x80)) { /* X0208 - ASCII */
+ f_line = char_size(c2,c1);
+ fold_state = LF;/* add one new f_line before this character */
+ } else {
+ fold_state = 1; /* default no fold in ASCII */
+ }
+ } else {
+ if (c2=='!') {
+ if (c1=='"') fold_state = 1; /* $B!"(B */
+ else if (c1=='#') fold_state = 1; /* $B!#(B */
+ else if (c1=='W') fold_state = 1; /* $B!W(B */
+ else if (c1=='K') fold_state = 1; /* $B!K(B */
+ else if (c1=='$') fold_state = 1; /* $B!$(B */
+ else if (c1=='%') fold_state = 1; /* $B!%(B */
+ else if (c1=='\'') fold_state = 1; /* $B!\(B */
+ else if (c1=='(') fold_state = 1; /* $B!((B */
+ else if (c1==')') fold_state = 1; /* $B!)(B */
+ else if (c1=='*') fold_state = 1; /* $B!*(B */
+ else if (c1=='+') fold_state = 1; /* $B!+(B */
+ else if (c1==',') fold_state = 1; /* $B!,(B */
+ /* default no fold in kinsoku */
+ else {
+ fold_state = LF;
+ f_line = char_size(c2,c1);
+ /* add one new f_line before this character */
+ }
+ } else {
+ f_line = char_size(c2,c1);
+ fold_state = LF;
+ /* add one new f_line before this character */
+ }
+ }
+ }
+ }
+ /* terminator process */
+ switch(fold_state) {
+ case LF:
+ oconv_newline(o_fconv);
+ (*o_fconv)(c2,c1);
+ break;
+ case 0:
+ return;
+ case CR:
+ oconv_newline(o_fconv);
+ break;
+ case TAB:
+ case SP:
+ (*o_fconv)(0,SP);
+ break;
+ default:
+ (*o_fconv)(c2,c1);
+ }
+}
+
+static nkf_char z_prev2=0,z_prev1=0;
+
+static void
+z_conv(nkf_char c2, nkf_char c1)
+{
+
+ /* if (c2) c1 &= 0x7f; assertion */
+
+ if (c2 == JIS_X_0201_1976_K && (c1 == 0x20 || c1 == 0x7D || c1 == 0x7E)) {
+ (*o_zconv)(c2,c1);
+ return;
+ }
+
+ if (x0201_f) {
+ if (z_prev2 == JIS_X_0201_1976_K) {
+ if (c2 == JIS_X_0201_1976_K) {
+ if (c1 == (0xde&0x7f)) { /* $BByE@(B */
+ z_prev2 = 0;
+ (*o_zconv)(dv[(z_prev1-SP)*2], dv[(z_prev1-SP)*2+1]);
+ return;
+ } else if (c1 == (0xdf&0x7f) && ev[(z_prev1-SP)*2]) { /* $BH>ByE@(B */
+ z_prev2 = 0;
+ (*o_zconv)(ev[(z_prev1-SP)*2], ev[(z_prev1-SP)*2+1]);
+ return;
+ } else if (x0213_f && c1 == (0xdf&0x7f) && ev_x0213[(z_prev1-SP)*2]) { /* $BH>ByE@(B */
+ z_prev2 = 0;
+ (*o_zconv)(ev_x0213[(z_prev1-SP)*2], ev_x0213[(z_prev1-SP)*2+1]);
+ return;
+ }
+ }
+ z_prev2 = 0;
+ (*o_zconv)(cv[(z_prev1-SP)*2], cv[(z_prev1-SP)*2+1]);
+ }
+ if (c2 == JIS_X_0201_1976_K) {
+ if (dv[(c1-SP)*2] || ev[(c1-SP)*2] || (x0213_f && ev_x0213[(c1-SP)*2])) {
+ /* wait for $BByE@(B or $BH>ByE@(B */
+ z_prev1 = c1;
+ z_prev2 = c2;
+ return;
+ } else {
+ (*o_zconv)(cv[(c1-SP)*2], cv[(c1-SP)*2+1]);
+ return;
+ }
+ }
+ }
+
+ if (c2 == EOF) {
+ (*o_zconv)(c2, c1);
+ return;
+ }
+
+ if (alpha_f&1 && c2 == 0x23) {
+ /* JISX0208 Alphabet */
+ c2 = 0;
+ } else if (c2 == 0x21) {
+ /* JISX0208 Kigou */
+ if (0x21==c1) {
+ if (alpha_f&2) {
+ c2 = 0;
+ c1 = SP;
+ } else if (alpha_f&4) {
+ (*o_zconv)(0, SP);
+ (*o_zconv)(0, SP);
+ return;
+ }
+ } else if (alpha_f&1 && 0x20<c1 && c1<0x7f && fv[c1-0x20]) {
+ c2 = 0;
+ c1 = fv[c1-0x20];
+ }
+ }
+
+ if (alpha_f&8 && c2 == 0) {
+ /* HTML Entity */
+ const char *entity = 0;
+ switch (c1){
+ case '>': entity = "&gt;"; break;
+ case '<': entity = "&lt;"; break;
+ case '\"': entity = "&quot;"; break;
+ case '&': entity = "&amp;"; break;
+ }
+ if (entity){
+ while (*entity) (*o_zconv)(0, *entity++);
+ return;
+ }
+ }
+
+ if (alpha_f & 16) {
+ /* JIS X 0208 Katakana to JIS X 0201 Katakana */
+ if (c2 == 0x21) {
+ nkf_char c = 0;
+ switch (c1) {
+ case 0x23:
+ /* U+3002 (0x8142) Ideographic Full Stop -> U+FF61 (0xA1) Halfwidth Ideographic Full Stop */
+ c = 0xA1;
+ break;
+ case 0x56:
+ /* U+300C (0x8175) Left Corner Bracket -> U+FF62 (0xA2) Halfwidth Left Corner Bracket */
+ c = 0xA2;
+ break;
+ case 0x57:
+ /* U+300D (0x8176) Right Corner Bracket -> U+FF63 (0xA3) Halfwidth Right Corner Bracket */
+ c = 0xA3;
+ break;
+ case 0x22:
+ /* U+3001 (0x8141) Ideographic Comma -> U+FF64 (0xA4) Halfwidth Ideographic Comma */
+ c = 0xA4;
+ break;
+ case 0x26:
+ /* U+30FB (0x8145) Katakana Middle Dot -> U+FF65 (0xA5) Halfwidth Katakana Middle Dot */
+ c = 0xA5;
+ break;
+ case 0x3C:
+ /* U+30FC (0x815B) Katakana-Hiragana Prolonged Sound Mark -> U+FF70 (0xB0) Halfwidth Katakana-Hiragana Prolonged Sound Mark */
+ c = 0xB0;
+ break;
+ case 0x2B:
+ /* U+309B (0x814A) Katakana-Hiragana Voiced Sound Mark -> U+FF9E (0xDE) Halfwidth Katakana Voiced Sound Mark */
+ c = 0xDE;
+ break;
+ case 0x2C:
+ /* U+309C (0x814B) Katakana-Hiragana Semi-Voiced Sound Mark -> U+FF9F (0xDF) Halfwidth Katakana Semi-Voiced Sound Mark */
+ c = 0xDF;
+ break;
+ }
+ if (c) {
+ (*o_zconv)(JIS_X_0201_1976_K, c);
+ return;
+ }
+ } else if (c2 == 0x25) {
+ /* JISX0208 Katakana */
+ static const int fullwidth_to_halfwidth[] =
+ {
+ 0x0000, 0x2700, 0x3100, 0x2800, 0x3200, 0x2900, 0x3300, 0x2A00,
+ 0x3400, 0x2B00, 0x3500, 0x3600, 0x365E, 0x3700, 0x375E, 0x3800,
+ 0x385E, 0x3900, 0x395E, 0x3A00, 0x3A5E, 0x3B00, 0x3B5E, 0x3C00,
+ 0x3C5E, 0x3D00, 0x3D5E, 0x3E00, 0x3E5E, 0x3F00, 0x3F5E, 0x4000,
+ 0x405E, 0x4100, 0x415E, 0x2F00, 0x4200, 0x425E, 0x4300, 0x435E,
+ 0x4400, 0x445E, 0x4500, 0x4600, 0x4700, 0x4800, 0x4900, 0x4A00,
+ 0x4A5E, 0x4A5F, 0x4B00, 0x4B5E, 0x4B5F, 0x4C00, 0x4C5E, 0x4C5F,
+ 0x4D00, 0x4D5E, 0x4D5F, 0x4E00, 0x4E5E, 0x4E5F, 0x4F00, 0x5000,
+ 0x5100, 0x5200, 0x5300, 0x2C00, 0x5400, 0x2D00, 0x5500, 0x2E00,
+ 0x5600, 0x5700, 0x5800, 0x5900, 0x5A00, 0x5B00, 0x0000, 0x5C00,
+ 0x0000, 0x0000, 0x2600, 0x5D00, 0x335E, 0x0000, 0x0000, 0x365F,
+ 0x375F, 0x385F, 0x395F, 0x3A5F, 0x3E5F, 0x425F, 0x445F, 0x0000
+ };
+ if (fullwidth_to_halfwidth[c1-0x20]){
+ c2 = fullwidth_to_halfwidth[c1-0x20];
+ (*o_zconv)(JIS_X_0201_1976_K, c2>>8);
+ if (c2 & 0xFF) {
+ (*o_zconv)(JIS_X_0201_1976_K, c2&0xFF);
+ }
+ return;
+ }
+ } else if (c2 == 0 && nkf_char_unicode_p(c1) &&
+ ((c1&VALUE_MASK) == 0x3099 || (c1&VALUE_MASK) == 0x309A)) { /* $B9g@.MQByE@!&H>ByE@(B */
+ (*o_zconv)(JIS_X_0201_1976_K, 0x5E + (c1&VALUE_MASK) - 0x3099);
+ return;
+ }
+ }
+ (*o_zconv)(c2,c1);
+}
+
+
+#define rot13(c) ( \
+ ( c < 'A') ? c: \
+ (c <= 'M') ? (c + 13): \
+ (c <= 'Z') ? (c - 13): \
+ (c < 'a') ? (c): \
+ (c <= 'm') ? (c + 13): \
+ (c <= 'z') ? (c - 13): \
+ (c) \
+ )
+
+#define rot47(c) ( \
+ ( c < '!') ? c: \
+ ( c <= 'O') ? (c + 47) : \
+ ( c <= '~') ? (c - 47) : \
+ c \
+ )
+
+static void
+rot_conv(nkf_char c2, nkf_char c1)
+{
+ if (c2 == 0 || c2 == JIS_X_0201_1976_K || c2 == ISO_8859_1) {
+ c1 = rot13(c1);
+ } else if (c2) {
+ c1 = rot47(c1);
+ c2 = rot47(c2);
+ }
+ (*o_rot_conv)(c2,c1);
+}
+
+static void
+hira_conv(nkf_char c2, nkf_char c1)
+{
+ if (hira_f & 1) {
+ if (c2 == 0x25) {
+ if (0x20 < c1 && c1 < 0x74) {
+ c2 = 0x24;
+ (*o_hira_conv)(c2,c1);
+ return;
+ } else if (c1 == 0x74 && nkf_enc_unicode_p(output_encoding)) {
+ c2 = 0;
+ c1 = nkf_char_unicode_new(0x3094);
+ (*o_hira_conv)(c2,c1);
+ return;
+ }
+ } else if (c2 == 0x21 && (c1 == 0x33 || c1 == 0x34)) {
+ c1 += 2;
+ (*o_hira_conv)(c2,c1);
+ return;
+ }
+ }
+ if (hira_f & 2) {
+ if (c2 == 0 && c1 == nkf_char_unicode_new(0x3094)) {
+ c2 = 0x25;
+ c1 = 0x74;
+ } else if (c2 == 0x24 && 0x20 < c1 && c1 < 0x74) {
+ c2 = 0x25;
+ } else if (c2 == 0x21 && (c1 == 0x35 || c1 == 0x36)) {
+ c1 -= 2;
+ }
+ }
+ (*o_hira_conv)(c2,c1);
+}
+
+
+static void
+iso2022jp_check_conv(nkf_char c2, nkf_char c1)
+{
+#define RANGE_NUM_MAX 18
+ static const nkf_char range[RANGE_NUM_MAX][2] = {
+ {0x222f, 0x2239,},
+ {0x2242, 0x2249,},
+ {0x2251, 0x225b,},
+ {0x226b, 0x2271,},
+ {0x227a, 0x227d,},
+ {0x2321, 0x232f,},
+ {0x233a, 0x2340,},
+ {0x235b, 0x2360,},
+ {0x237b, 0x237e,},
+ {0x2474, 0x247e,},
+ {0x2577, 0x257e,},
+ {0x2639, 0x2640,},
+ {0x2659, 0x267e,},
+ {0x2742, 0x2750,},
+ {0x2772, 0x277e,},
+ {0x2841, 0x287e,},
+ {0x4f54, 0x4f7e,},
+ {0x7425, 0x747e},
+ };
+ nkf_char i;
+ nkf_char start, end, c;
+
+ if(c2 >= 0x00 && c2 <= 0x20 && c1 >= 0x7f && c1 <= 0xff) {
+ c2 = GETA1;
+ c1 = GETA2;
+ }
+ if((c2 >= 0x29 && c2 <= 0x2f) || (c2 >= 0x75 && c2 <= 0x7e)) {
+ c2 = GETA1;
+ c1 = GETA2;
+ }
+
+ for (i = 0; i < RANGE_NUM_MAX; i++) {
+ start = range[i][0];
+ end = range[i][1];
+ c = (c2 << 8) + c1;
+ if (c >= start && c <= end) {
+ c2 = GETA1;
+ c1 = GETA2;
+ }
+ }
+ (*o_iso2022jp_check_conv)(c2,c1);
+}
+
+
+/* This converts =?ISO-2022-JP?B?HOGE HOGE?= */
+
+static const unsigned char *mime_pattern[] = {
+ (const unsigned char *)"\075?EUC-JP?B?",
+ (const unsigned char *)"\075?SHIFT_JIS?B?",
+ (const unsigned char *)"\075?ISO-8859-1?Q?",
+ (const unsigned char *)"\075?ISO-8859-1?B?",
+ (const unsigned char *)"\075?ISO-2022-JP?B?",
+ (const unsigned char *)"\075?ISO-2022-JP?B?",
+ (const unsigned char *)"\075?ISO-2022-JP?Q?",
+#if defined(UTF8_INPUT_ENABLE)
+ (const unsigned char *)"\075?UTF-8?B?",
+ (const unsigned char *)"\075?UTF-8?Q?",
+#endif
+ (const unsigned char *)"\075?US-ASCII?Q?",
+ NULL
+};
+
+
+/* $B3:Ev$9$k%3!<%I$NM%@hEY$r>e$2$k$?$a$NL\0u(B */
+nkf_char (*mime_priority_func[])(nkf_char c2, nkf_char c1, nkf_char c0) = {
+ e_iconv, s_iconv, 0, 0, 0, 0, 0,
+#if defined(UTF8_INPUT_ENABLE)
+ w_iconv, w_iconv,
+#endif
+ 0,
+};
+
+static const nkf_char mime_encode[] = {
+ EUC_JP, SHIFT_JIS, ISO_8859_1, ISO_8859_1, JIS_X_0208, JIS_X_0201_1976_K, JIS_X_0201_1976_K,
+#if defined(UTF8_INPUT_ENABLE)
+ UTF_8, UTF_8,
+#endif
+ ASCII,
+ 0
+};
+
+static const nkf_char mime_encode_method[] = {
+ 'B', 'B','Q', 'B', 'B', 'B', 'Q',
+#if defined(UTF8_INPUT_ENABLE)
+ 'B', 'Q',
+#endif
+ 'Q',
+ 0
+};
+
+
+/* MIME preprocessor fifo */
+
+#define MIME_BUF_SIZE (1024) /* 2^n ring buffer */
+#define MIME_BUF_MASK (MIME_BUF_SIZE-1)
+#define mime_input_buf(n) mime_input_state.buf[(n)&MIME_BUF_MASK]
+static struct {
+ unsigned char buf[MIME_BUF_SIZE];
+ unsigned int top;
+ unsigned int last; /* decoded */
+ unsigned int input; /* undecoded */
+} mime_input_state;
+static nkf_char (*mime_iconv_back)(nkf_char c2,nkf_char c1,nkf_char c0) = NULL;
+
+#define MAXRECOVER 20
+
+static void
+mime_input_buf_unshift(nkf_char c)
+{
+ mime_input_buf(--mime_input_state.top) = (unsigned char)c;
+}
+
+static nkf_char
+mime_ungetc(nkf_char c, ARG_UNUSED FILE *f)
+{
+ mime_input_buf_unshift(c);
+ return c;
+}
+
+static nkf_char
+mime_ungetc_buf(nkf_char c, FILE *f)
+{
+ if (mimebuf_f)
+ (*i_mungetc_buf)(c,f);
+ else
+ mime_input_buf(--mime_input_state.input) = (unsigned char)c;
+ return c;
+}
+
+static nkf_char
+mime_getc_buf(FILE *f)
+{
+ /* we don't keep eof of mime_input_buf, because it contains ?= as
+ a terminator. It was checked in mime_integrity. */
+ return ((mimebuf_f)?
+ (*i_mgetc_buf)(f):mime_input_buf(mime_input_state.input++));
+}
+
+static void
+switch_mime_getc(void)
+{
+ if (i_getc!=mime_getc) {
+ i_mgetc = i_getc; i_getc = mime_getc;
+ i_mungetc = i_ungetc; i_ungetc = mime_ungetc;
+ if(mime_f==STRICT_MIME) {
+ i_mgetc_buf = i_mgetc; i_mgetc = mime_getc_buf;
+ i_mungetc_buf = i_mungetc; i_mungetc = mime_ungetc_buf;
+ }
+ }
+}
+
+static void
+unswitch_mime_getc(void)
+{
+ if(mime_f==STRICT_MIME) {
+ i_mgetc = i_mgetc_buf;
+ i_mungetc = i_mungetc_buf;
+ }
+ i_getc = i_mgetc;
+ i_ungetc = i_mungetc;
+ if(mime_iconv_back)set_iconv(FALSE, mime_iconv_back);
+ mime_iconv_back = NULL;
+}
+
+static nkf_char
+mime_integrity(FILE *f, const unsigned char *p)
+{
+ nkf_char c,d;
+ unsigned int q;
+ /* In buffered mode, read until =? or NL or buffer full
+ */
+ mime_input_state.input = mime_input_state.top;
+ mime_input_state.last = mime_input_state.top;
+
+ while(*p) mime_input_buf(mime_input_state.input++) = *p++;
+ d = 0;
+ q = mime_input_state.input;
+ while((c=(*i_getc)(f))!=EOF) {
+ if (((mime_input_state.input-mime_input_state.top)&MIME_BUF_MASK)==0) {
+ break; /* buffer full */
+ }
+ if (c=='=' && d=='?') {
+ /* checked. skip header, start decode */
+ mime_input_buf(mime_input_state.input++) = (unsigned char)c;
+ /* mime_last_input = mime_input_state.input; */
+ mime_input_state.input = q;
+ switch_mime_getc();
+ return 1;
+ }
+ if (!( (c=='+'||c=='/'|| c=='=' || c=='?' || is_alnum(c))))
+ break;
+ /* Should we check length mod 4? */
+ mime_input_buf(mime_input_state.input++) = (unsigned char)c;
+ d=c;
+ }
+ /* In case of Incomplete MIME, no MIME decode */
+ mime_input_buf(mime_input_state.input++) = (unsigned char)c;
+ mime_input_state.last = mime_input_state.input; /* point undecoded buffer */
+ mime_decode_mode = 1; /* no decode on mime_input_buf last in mime_getc */
+ switch_mime_getc(); /* anyway we need buffered getc */
+ return 1;
+}
+
+static nkf_char
+mime_begin_strict(FILE *f)
+{
+ nkf_char c1 = 0;
+ int i,j,k;
+ const unsigned char *p,*q;
+ nkf_char r[MAXRECOVER]; /* recovery buffer, max mime pattern length */
+
+ mime_decode_mode = FALSE;
+ /* =? has been checked */
+ j = 0;
+ p = mime_pattern[j];
+ r[0]='='; r[1]='?';
+
+ for(i=2;p[i]>SP;i++) { /* start at =? */
+ if (((r[i] = c1 = (*i_getc)(f))==EOF) || nkf_toupper(c1) != p[i]) {
+ /* pattern fails, try next one */
+ q = p;
+ while (mime_pattern[++j]) {
+ p = mime_pattern[j];
+ for(k=2;k<i;k++) /* assume length(p) > i */
+ if (p[k]!=q[k]) break;
+ if (k==i && nkf_toupper(c1)==p[k]) break;
+ }
+ p = mime_pattern[j];
+ if (p) continue; /* found next one, continue */
+ /* all fails, output from recovery buffer */
+ (*i_ungetc)(c1,f);
+ for(j=0;j<i;j++) {
+ (*oconv)(0,r[j]);
+ }
+ return c1;
+ }
+ }
+ mime_decode_mode = p[i-2];
+
+ mime_iconv_back = iconv;
+ set_iconv(FALSE, mime_priority_func[j]);
+ clr_code_score(find_inputcode_byfunc(mime_priority_func[j]), SCORE_iMIME);
+
+ if (mime_decode_mode=='B') {
+ mimebuf_f = unbuf_f;
+ if (!unbuf_f) {
+ /* do MIME integrity check */
+ return mime_integrity(f,mime_pattern[j]);
+ }
+ }
+ switch_mime_getc();
+ mimebuf_f = TRUE;
+ return c1;
+}
+
+static nkf_char
+mime_begin(FILE *f)
+{
+ nkf_char c1 = 0;
+ int i,k;
+
+ /* In NONSTRICT mode, only =? is checked. In case of failure, we */
+ /* re-read and convert again from mime_buffer. */
+
+ /* =? has been checked */
+ k = mime_input_state.last;
+ mime_input_buf(mime_input_state.last++)='='; mime_input_buf(mime_input_state.last++)='?';
+ for(i=2;i<MAXRECOVER;i++) { /* start at =? */
+ /* We accept any character type even if it is breaked by new lines */
+ c1 = (*i_getc)(f); mime_input_buf(mime_input_state.last++) = (unsigned char)c1;
+ if (c1==LF||c1==SP||c1==CR||
+ c1=='-'||c1=='_'||is_alnum(c1)) continue;
+ if (c1=='=') {
+ /* Failed. But this could be another MIME preemble */
+ (*i_ungetc)(c1,f);
+ mime_input_state.last--;
+ break;
+ }
+ if (c1!='?') break;
+ else {
+ /* c1=='?' */
+ c1 = (*i_getc)(f); mime_input_buf(mime_input_state.last++) = (unsigned char)c1;
+ if (!(++i<MAXRECOVER) || c1==EOF) break;
+ if (c1=='b'||c1=='B') {
+ mime_decode_mode = 'B';
+ } else if (c1=='q'||c1=='Q') {
+ mime_decode_mode = 'Q';
+ } else {
+ break;
+ }
+ c1 = (*i_getc)(f); mime_input_buf(mime_input_state.last++) = (unsigned char)c1;
+ if (!(++i<MAXRECOVER) || c1==EOF) break;
+ if (c1!='?') {
+ mime_decode_mode = FALSE;
+ }
+ break;
+ }
+ }
+ switch_mime_getc();
+ if (!mime_decode_mode) {
+ /* false MIME premble, restart from mime_buffer */
+ mime_decode_mode = 1; /* no decode, but read from the mime_buffer */
+ /* Since we are in MIME mode until buffer becomes empty, */
+ /* we never go into mime_begin again for a while. */
+ return c1;
+ }
+ /* discard mime preemble, and goto MIME mode */
+ mime_input_state.last = k;
+ /* do no MIME integrity check */
+ return c1; /* used only for checking EOF */
+}
+
+#ifdef CHECK_OPTION
+static void
+no_putc(ARG_UNUSED nkf_char c)
+{
+ ;
+}
+
+static void
+debug(const char *str)
+{
+ if (debug_f){
+ fprintf(stderr, "%s\n", str ? str : "NULL");
+ }
+}
+#endif
+
+static void
+set_input_codename(const char *codename)
+{
+ if (!input_codename) {
+ input_codename = codename;
+ } else if (strcmp(codename, input_codename) != 0) {
+ input_codename = "";
+ }
+}
+
+static const char*
+get_guessed_code(void)
+{
+ if (input_codename && !*input_codename) {
+ input_codename = "BINARY";
+ } else {
+ struct input_code *p = find_inputcode_byfunc(iconv);
+ if (!input_codename) {
+ input_codename = "ASCII";
+ } else if (strcmp(input_codename, "Shift_JIS") == 0) {
+ if (p->score & (SCORE_DEPEND|SCORE_CP932))
+ input_codename = "CP932";
+ } else if (strcmp(input_codename, "EUC-JP") == 0) {
+ if (p->score & SCORE_X0213)
+ input_codename = "EUC-JIS-2004";
+ else if (p->score & (SCORE_X0212))
+ input_codename = "EUCJP-MS";
+ else if (p->score & (SCORE_DEPEND|SCORE_CP932))
+ input_codename = "CP51932";
+ } else if (strcmp(input_codename, "ISO-2022-JP") == 0) {
+ if (p->score & (SCORE_KANA))
+ input_codename = "CP50221";
+ else if (p->score & (SCORE_DEPEND|SCORE_CP932))
+ input_codename = "CP50220";
+ }
+ }
+ return input_codename;
+}
+
+#if !defined(PERL_XS) && !defined(WIN32DLL)
+static void
+print_guessed_code(char *filename)
+{
+ if (filename != NULL) printf("%s: ", filename);
+ if (input_codename && !*input_codename) {
+ printf("BINARY\n");
+ } else {
+ input_codename = get_guessed_code();
+ if (guess_f == 1) {
+ printf("%s\n", input_codename);
+ } else {
+ printf("%s%s%s%s\n",
+ input_codename,
+ iconv != w_iconv16 && iconv != w_iconv32 ? "" :
+ input_endian == ENDIAN_LITTLE ? " LE" :
+ input_endian == ENDIAN_BIG ? " BE" :
+ "[BUG]",
+ input_bom_f ? " (BOM)" : "",
+ input_eol == CR ? " (CR)" :
+ input_eol == LF ? " (LF)" :
+ input_eol == CRLF ? " (CRLF)" :
+ input_eol == EOF ? " (MIXED NL)" :
+ "");
+ }
+ }
+}
+#endif /*WIN32DLL*/
+
+#ifdef INPUT_OPTION
+
+static nkf_char
+hex_getc(nkf_char ch, FILE *f, nkf_char (*g)(FILE *f), nkf_char (*u)(nkf_char c, FILE *f))
+{
+ nkf_char c1, c2, c3;
+ c1 = (*g)(f);
+ if (c1 != ch){
+ return c1;
+ }
+ c2 = (*g)(f);
+ if (!nkf_isxdigit(c2)){
+ (*u)(c2, f);
+ return c1;
+ }
+ c3 = (*g)(f);
+ if (!nkf_isxdigit(c3)){
+ (*u)(c2, f);
+ (*u)(c3, f);
+ return c1;
+ }
+ return (hex2bin(c2) << 4) | hex2bin(c3);
+}
+
+static nkf_char
+cap_getc(FILE *f)
+{
+ return hex_getc(':', f, i_cgetc, i_cungetc);
+}
+
+static nkf_char
+cap_ungetc(nkf_char c, FILE *f)
+{
+ return (*i_cungetc)(c, f);
+}
+
+static nkf_char
+url_getc(FILE *f)
+{
+ return hex_getc('%', f, i_ugetc, i_uungetc);
+}
+
+static nkf_char
+url_ungetc(nkf_char c, FILE *f)
+{
+ return (*i_uungetc)(c, f);
+}
+#endif
+
+#ifdef NUMCHAR_OPTION
+static nkf_char
+numchar_getc(FILE *f)
+{
+ nkf_char (*g)(FILE *) = i_ngetc;
+ nkf_char (*u)(nkf_char c ,FILE *f) = i_nungetc;
+ int i = 0, j;
+ nkf_char buf[12];
+ nkf_char c = -1;
+
+ buf[i] = (*g)(f);
+ if (buf[i] == '&'){
+ buf[++i] = (*g)(f);
+ if (buf[i] == '#'){
+ c = 0;
+ buf[++i] = (*g)(f);
+ if (buf[i] == 'x' || buf[i] == 'X'){
+ for (j = 0; j < 7; j++){
+ buf[++i] = (*g)(f);
+ if (!nkf_isxdigit(buf[i])){
+ if (buf[i] != ';'){
+ c = -1;
+ }
+ break;
+ }
+ c <<= 4;
+ c |= hex2bin(buf[i]);
+ }
+ }else{
+ for (j = 0; j < 8; j++){
+ if (j){
+ buf[++i] = (*g)(f);
+ }
+ if (!nkf_isdigit(buf[i])){
+ if (buf[i] != ';'){
+ c = -1;
+ }
+ break;
+ }
+ c *= 10;
+ c += hex2bin(buf[i]);
+ }
+ }
+ }
+ }
+ if (c != -1){
+ return nkf_char_unicode_new(c);
+ }
+ while (i > 0){
+ (*u)(buf[i], f);
+ --i;
+ }
+ return buf[0];
+}
+
+static nkf_char
+numchar_ungetc(nkf_char c, FILE *f)
+{
+ return (*i_nungetc)(c, f);
+}
+#endif
+
+#ifdef UNICODE_NORMALIZATION
+
+static nkf_char
+nfc_getc(FILE *f)
+{
+ nkf_char (*g)(FILE *f) = i_nfc_getc;
+ nkf_char (*u)(nkf_char c ,FILE *f) = i_nfc_ungetc;
+ nkf_buf_t *buf = nkf_state->nfc_buf;
+ const unsigned char *array;
+ int lower=0, upper=NORMALIZATION_TABLE_LENGTH-1;
+ nkf_char c = (*g)(f);
+
+ if (c == EOF || c > 0xFF || (c & 0xc0) == 0x80) return c;
+
+ nkf_buf_push(buf, c);
+ do {
+ while (lower <= upper) {
+ int mid = (lower+upper) / 2;
+ int len;
+ array = normalization_table[mid].nfd;
+ for (len=0; len < NORMALIZATION_TABLE_NFD_LENGTH && array[len]; len++) {
+ if (len >= nkf_buf_length(buf)) {
+ c = (*g)(f);
+ if (c == EOF) {
+ len = 0;
+ lower = 1, upper = 0;
+ break;
+ }
+ nkf_buf_push(buf, c);
+ }
+ if (array[len] != nkf_buf_at(buf, len)) {
+ if (array[len] < nkf_buf_at(buf, len)) lower = mid + 1;
+ else upper = mid - 1;
+ len = 0;
+ break;
+ }
+ }
+ if (len > 0) {
+ int i;
+ array = normalization_table[mid].nfc;
+ nkf_buf_clear(buf);
+ for (i=0; i < NORMALIZATION_TABLE_NFC_LENGTH && array[i]; i++)
+ nkf_buf_push(buf, array[i]);
+ break;
+ }
+ }
+ } while (lower <= upper);
+
+ while (nkf_buf_length(buf) > 1) (*u)(nkf_buf_pop(buf), f);
+ c = nkf_buf_pop(buf);
+
+ return c;
+}
+
+static nkf_char
+nfc_ungetc(nkf_char c, FILE *f)
+{
+ return (*i_nfc_ungetc)(c, f);
+}
+#endif /* UNICODE_NORMALIZATION */
+
+
+static nkf_char
+base64decode(nkf_char c)
+{
+ int i;
+ if (c > '@') {
+ if (c < '[') {
+ i = c - 'A'; /* A..Z 0-25 */
+ } else if (c == '_') {
+ i = '?' /* 63 */ ; /* _ 63 */
+ } else {
+ i = c - 'G' /* - 'a' + 26 */ ; /* a..z 26-51 */
+ }
+ } else if (c > '/') {
+ i = c - '0' + '4' /* - '0' + 52 */ ; /* 0..9 52-61 */
+ } else if (c == '+' || c == '-') {
+ i = '>' /* 62 */ ; /* + and - 62 */
+ } else {
+ i = '?' /* 63 */ ; /* / 63 */
+ }
+ return (i);
+}
+
+static nkf_char
+mime_getc(FILE *f)
+{
+ nkf_char c1, c2, c3, c4, cc;
+ nkf_char t1, t2, t3, t4, mode, exit_mode;
+ nkf_char lwsp_count;
+ char *lwsp_buf;
+ char *lwsp_buf_new;
+ nkf_char lwsp_size = 128;
+
+ if (mime_input_state.top != mime_input_state.last) { /* Something is in FIFO */
+ return mime_input_buf(mime_input_state.top++);
+ }
+ if (mime_decode_mode==1 ||mime_decode_mode==FALSE) {
+ mime_decode_mode=FALSE;
+ unswitch_mime_getc();
+ return (*i_getc)(f);
+ }
+
+ if (mimebuf_f == FIXED_MIME)
+ exit_mode = mime_decode_mode;
+ else
+ exit_mode = FALSE;
+ if (mime_decode_mode == 'Q') {
+ if ((c1 = (*i_mgetc)(f)) == EOF) return (EOF);
+ restart_mime_q:
+ if (c1=='_' && mimebuf_f != FIXED_MIME) return SP;
+ if (c1<=SP || DEL<=c1) {
+ mime_decode_mode = exit_mode; /* prepare for quit */
+ return c1;
+ }
+ if (c1!='=' && (c1!='?' || mimebuf_f == FIXED_MIME)) {
+ return c1;
+ }
+
+ mime_decode_mode = exit_mode; /* prepare for quit */
+ if ((c2 = (*i_mgetc)(f)) == EOF) return (EOF);
+ if (c1=='?'&&c2=='=' && mimebuf_f != FIXED_MIME) {
+ /* end Q encoding */
+ input_mode = exit_mode;
+ lwsp_count = 0;
+ lwsp_buf = nkf_xmalloc((lwsp_size+5)*sizeof(char));
+ while ((c1=(*i_getc)(f))!=EOF) {
+ switch (c1) {
+ case LF:
+ case CR:
+ if (c1==LF) {
+ if ((c1=(*i_getc)(f))!=EOF && nkf_isblank(c1)) {
+ i_ungetc(SP,f);
+ continue;
+ } else {
+ i_ungetc(c1,f);
+ }
+ c1 = LF;
+ } else {
+ if ((c1=(*i_getc)(f))!=EOF && c1 == LF) {
+ if ((c1=(*i_getc)(f))!=EOF && nkf_isblank(c1)) {
+ i_ungetc(SP,f);
+ continue;
+ } else {
+ i_ungetc(c1,f);
+ }
+ i_ungetc(LF,f);
+ } else {
+ i_ungetc(c1,f);
+ }
+ c1 = CR;
+ }
+ break;
+ case SP:
+ case TAB:
+ lwsp_buf[lwsp_count] = (unsigned char)c1;
+ if (lwsp_count++>lwsp_size){
+ lwsp_size <<= 1;
+ lwsp_buf_new = nkf_xrealloc(lwsp_buf, (lwsp_size+5)*sizeof(char));
+ lwsp_buf = lwsp_buf_new;
+ }
+ continue;
+ }
+ break;
+ }
+ if (lwsp_count > 0 && (c1 != '=' || (lwsp_buf[lwsp_count-1] != SP && lwsp_buf[lwsp_count-1] != TAB))) {
+ i_ungetc(c1,f);
+ for(lwsp_count--;lwsp_count>0;lwsp_count--)
+ i_ungetc(lwsp_buf[lwsp_count],f);
+ c1 = lwsp_buf[0];
+ }
+ nkf_xfree(lwsp_buf);
+ return c1;
+ }
+ if (c1=='='&&c2<SP) { /* this is soft wrap */
+ while((c1 = (*i_mgetc)(f)) <=SP) {
+ if (c1 == EOF) return (EOF);
+ }
+ mime_decode_mode = 'Q'; /* still in MIME */
+ goto restart_mime_q;
+ }
+ if (c1=='?') {
+ mime_decode_mode = 'Q'; /* still in MIME */
+ (*i_mungetc)(c2,f);
+ return c1;
+ }
+ if ((c3 = (*i_mgetc)(f)) == EOF) return (EOF);
+ if (c2<=SP) return c2;
+ mime_decode_mode = 'Q'; /* still in MIME */
+ return ((hex2bin(c2)<<4) + hex2bin(c3));
+ }
+
+ if (mime_decode_mode != 'B') {
+ mime_decode_mode = FALSE;
+ return (*i_mgetc)(f);
+ }
+
+
+ /* Base64 encoding */
+ /*
+ MIME allows line break in the middle of
+ Base64, but we are very pessimistic in decoding
+ in unbuf mode because MIME encoded code may broken by
+ less or editor's control sequence (such as ESC-[-K in unbuffered
+ mode. ignore incomplete MIME.
+ */
+ mode = mime_decode_mode;
+ mime_decode_mode = exit_mode; /* prepare for quit */
+
+ while ((c1 = (*i_mgetc)(f))<=SP) {
+ if (c1==EOF)
+ return (EOF);
+ }
+ mime_c2_retry:
+ if ((c2 = (*i_mgetc)(f))<=SP) {
+ if (c2==EOF)
+ return (EOF);
+ if (mime_f != STRICT_MIME) goto mime_c2_retry;
+ if (mimebuf_f!=FIXED_MIME) input_mode = ASCII;
+ return c2;
+ }
+ if ((c1 == '?') && (c2 == '=')) {
+ input_mode = ASCII;
+ lwsp_count = 0;
+ lwsp_buf = nkf_xmalloc((lwsp_size+5)*sizeof(char));
+ while ((c1=(*i_getc)(f))!=EOF) {
+ switch (c1) {
+ case LF:
+ case CR:
+ if (c1==LF) {
+ if ((c1=(*i_getc)(f))!=EOF && nkf_isblank(c1)) {
+ i_ungetc(SP,f);
+ continue;
+ } else {
+ i_ungetc(c1,f);
+ }
+ c1 = LF;
+ } else {
+ if ((c1=(*i_getc)(f))!=EOF) {
+ if (c1==SP) {
+ i_ungetc(SP,f);
+ continue;
+ } else if ((c1=(*i_getc)(f))!=EOF && nkf_isblank(c1)) {
+ i_ungetc(SP,f);
+ continue;
+ } else {
+ i_ungetc(c1,f);
+ }
+ i_ungetc(LF,f);
+ } else {
+ i_ungetc(c1,f);
+ }
+ c1 = CR;
+ }
+ break;
+ case SP:
+ case TAB:
+ lwsp_buf[lwsp_count] = (unsigned char)c1;
+ if (lwsp_count++>lwsp_size){
+ lwsp_size <<= 1;
+ lwsp_buf_new = nkf_xrealloc(lwsp_buf, (lwsp_size+5)*sizeof(char));
+ lwsp_buf = lwsp_buf_new;
+ }
+ continue;
+ }
+ break;
+ }
+ if (lwsp_count > 0 && (c1 != '=' || (lwsp_buf[lwsp_count-1] != SP && lwsp_buf[lwsp_count-1] != TAB))) {
+ i_ungetc(c1,f);
+ for(lwsp_count--;lwsp_count>0;lwsp_count--)
+ i_ungetc(lwsp_buf[lwsp_count],f);
+ c1 = lwsp_buf[0];
+ }
+ nkf_xfree(lwsp_buf);
+ return c1;
+ }
+ mime_c3_retry:
+ if ((c3 = (*i_mgetc)(f))<=SP) {
+ if (c3==EOF)
+ return (EOF);
+ if (mime_f != STRICT_MIME) goto mime_c3_retry;
+ if (mimebuf_f!=FIXED_MIME) input_mode = ASCII;
+ return c3;
+ }
+ mime_c4_retry:
+ if ((c4 = (*i_mgetc)(f))<=SP) {
+ if (c4==EOF)
+ return (EOF);
+ if (mime_f != STRICT_MIME) goto mime_c4_retry;
+ if (mimebuf_f!=FIXED_MIME) input_mode = ASCII;
+ return c4;
+ }
+
+ mime_decode_mode = mode; /* still in MIME sigh... */
+
+ /* BASE 64 decoding */
+
+ t1 = 0x3f & base64decode(c1);
+ t2 = 0x3f & base64decode(c2);
+ t3 = 0x3f & base64decode(c3);
+ t4 = 0x3f & base64decode(c4);
+ cc = ((t1 << 2) & 0x0fc) | ((t2 >> 4) & 0x03);
+ if (c2 != '=') {
+ mime_input_buf(mime_input_state.last++) = (unsigned char)cc;
+ cc = ((t2 << 4) & 0x0f0) | ((t3 >> 2) & 0x0f);
+ if (c3 != '=') {
+ mime_input_buf(mime_input_state.last++) = (unsigned char)cc;
+ cc = ((t3 << 6) & 0x0c0) | (t4 & 0x3f);
+ if (c4 != '=')
+ mime_input_buf(mime_input_state.last++) = (unsigned char)cc;
+ }
+ } else {
+ return c1;
+ }
+ return mime_input_buf(mime_input_state.top++);
+}
+
+static const char basis_64[] =
+ "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
+
+#define MIMEOUT_BUF_LENGTH 74
+static struct {
+ unsigned char buf[MIMEOUT_BUF_LENGTH+1];
+ int count;
+} mimeout_state;
+
+/*nkf_char mime_lastchar2, mime_lastchar1;*/
+
+static void
+open_mime(nkf_char mode)
+{
+ const unsigned char *p;
+ int i;
+ int j;
+ p = mime_pattern[0];
+ for(i=0;mime_pattern[i];i++) {
+ if (mode == mime_encode[i]) {
+ p = mime_pattern[i];
+ break;
+ }
+ }
+ mimeout_mode = mime_encode_method[i];
+ i = 0;
+ if (base64_count>45) {
+ if (mimeout_state.count>0 && nkf_isblank(mimeout_state.buf[i])){
+ (*o_mputc)(mimeout_state.buf[i]);
+ i++;
+ }
+ put_newline(o_mputc);
+ (*o_mputc)(SP);
+ base64_count = 1;
+ if (mimeout_state.count>0 && nkf_isspace(mimeout_state.buf[i])) {
+ i++;
+ }
+ }
+ for (;i<mimeout_state.count;i++) {
+ if (nkf_isspace(mimeout_state.buf[i])) {
+ (*o_mputc)(mimeout_state.buf[i]);
+ base64_count ++;
+ } else {
+ break;
+ }
+ }
+ while(*p) {
+ (*o_mputc)(*p++);
+ base64_count ++;
+ }
+ j = mimeout_state.count;
+ mimeout_state.count = 0;
+ for (;i<j;i++) {
+ mime_putc(mimeout_state.buf[i]);
+ }
+}
+
+static void
+mime_prechar(nkf_char c2, nkf_char c1)
+{
+ if (mimeout_mode > 0){
+ if (c2 == EOF){
+ if (base64_count + mimeout_state.count/3*4> 73){
+ (*o_base64conv)(EOF,0);
+ oconv_newline(o_base64conv);
+ (*o_base64conv)(0,SP);
+ base64_count = 1;
+ }
+ } else {
+ if ((c2 != 0 || c1 > DEL) && base64_count + mimeout_state.count/3*4> 66) {
+ (*o_base64conv)(EOF,0);
+ oconv_newline(o_base64conv);
+ (*o_base64conv)(0,SP);
+ base64_count = 1;
+ mimeout_mode = -1;
+ }
+ }
+ } else if (c2) {
+ if (c2 != EOF && base64_count + mimeout_state.count/3*4> 60) {
+ mimeout_mode = (output_mode==ASCII ||output_mode == ISO_8859_1) ? 'Q' : 'B';
+ open_mime(output_mode);
+ (*o_base64conv)(EOF,0);
+ oconv_newline(o_base64conv);
+ (*o_base64conv)(0,SP);
+ base64_count = 1;
+ mimeout_mode = -1;
+ }
+ }
+}
+
+static void
+close_mime(void)
+{
+ (*o_mputc)('?');
+ (*o_mputc)('=');
+ base64_count += 2;
+ mimeout_mode = 0;
+}
+
+static void
+eof_mime(void)
+{
+ switch(mimeout_mode) {
+ case 'Q':
+ case 'B':
+ break;
+ case 2:
+ (*o_mputc)(basis_64[((nkf_state->mimeout_state & 0x3)<< 4)]);
+ (*o_mputc)('=');
+ (*o_mputc)('=');
+ base64_count += 3;
+ break;
+ case 1:
+ (*o_mputc)(basis_64[((nkf_state->mimeout_state & 0xF) << 2)]);
+ (*o_mputc)('=');
+ base64_count += 2;
+ break;
+ }
+ if (mimeout_mode > 0) {
+ if (mimeout_f!=FIXED_MIME) {
+ close_mime();
+ } else if (mimeout_mode != 'Q')
+ mimeout_mode = 'B';
+ }
+}
+
+static void
+mimeout_addchar(nkf_char c)
+{
+ switch(mimeout_mode) {
+ case 'Q':
+ if (c==CR||c==LF) {
+ (*o_mputc)(c);
+ base64_count = 0;
+ } else if(!nkf_isalnum(c)) {
+ (*o_mputc)('=');
+ (*o_mputc)(bin2hex(((c>>4)&0xf)));
+ (*o_mputc)(bin2hex((c&0xf)));
+ base64_count += 3;
+ } else {
+ (*o_mputc)(c);
+ base64_count++;
+ }
+ break;
+ case 'B':
+ nkf_state->mimeout_state=c;
+ (*o_mputc)(basis_64[c>>2]);
+ mimeout_mode=2;
+ base64_count ++;
+ break;
+ case 2:
+ (*o_mputc)(basis_64[((nkf_state->mimeout_state & 0x3)<< 4) | ((c & 0xF0) >> 4)]);
+ nkf_state->mimeout_state=c;
+ mimeout_mode=1;
+ base64_count ++;
+ break;
+ case 1:
+ (*o_mputc)(basis_64[((nkf_state->mimeout_state & 0xF) << 2) | ((c & 0xC0) >>6)]);
+ (*o_mputc)(basis_64[c & 0x3F]);
+ mimeout_mode='B';
+ base64_count += 2;
+ break;
+ default:
+ (*o_mputc)(c);
+ base64_count++;
+ break;
+ }
+}
+
+static void
+mime_putc(nkf_char c)
+{
+ int i, j;
+ nkf_char lastchar;
+
+ if (mimeout_f == FIXED_MIME){
+ if (mimeout_mode == 'Q'){
+ if (base64_count > 71){
+ if (c!=CR && c!=LF) {
+ (*o_mputc)('=');
+ put_newline(o_mputc);
+ }
+ base64_count = 0;
+ }
+ }else{
+ if (base64_count > 71){
+ eof_mime();
+ put_newline(o_mputc);
+ base64_count = 0;
+ }
+ if (c == EOF) { /* c==EOF */
+ eof_mime();
+ }
+ }
+ if (c != EOF) { /* c==EOF */
+ mimeout_addchar(c);
+ }
+ return;
+ }
+
+ /* mimeout_f != FIXED_MIME */
+
+ if (c == EOF) { /* c==EOF */
+ if (mimeout_mode == -1 && mimeout_state.count > 1) open_mime(output_mode);
+ j = mimeout_state.count;
+ mimeout_state.count = 0;
+ i = 0;
+ if (mimeout_mode > 0) {
+ if (!nkf_isblank(mimeout_state.buf[j-1])) {
+ for (;i<j;i++) {
+ if (nkf_isspace(mimeout_state.buf[i]) && base64_count < 71){
+ break;
+ }
+ mimeout_addchar(mimeout_state.buf[i]);
+ }
+ eof_mime();
+ for (;i<j;i++) {
+ mimeout_addchar(mimeout_state.buf[i]);
+ }
+ } else {
+ for (;i<j;i++) {
+ mimeout_addchar(mimeout_state.buf[i]);
+ }
+ eof_mime();
+ }
+ } else {
+ for (;i<j;i++) {
+ mimeout_addchar(mimeout_state.buf[i]);
+ }
+ }
+ return;
+ }
+
+ if (mimeout_state.count > 0){
+ lastchar = mimeout_state.buf[mimeout_state.count - 1];
+ }else{
+ lastchar = -1;
+ }
+
+ if (mimeout_mode=='Q') {
+ if (c <= DEL && (output_mode==ASCII ||output_mode == ISO_8859_1)) {
+ if (c == CR || c == LF) {
+ close_mime();
+ (*o_mputc)(c);
+ base64_count = 0;
+ return;
+ } else if (c <= SP) {
+ close_mime();
+ if (base64_count > 70) {
+ put_newline(o_mputc);
+ base64_count = 0;
+ }
+ if (!nkf_isblank(c)) {
+ (*o_mputc)(SP);
+ base64_count++;
+ }
+ } else {
+ if (base64_count > 70) {
+ close_mime();
+ put_newline(o_mputc);
+ (*o_mputc)(SP);
+ base64_count = 1;
+ open_mime(output_mode);
+ }
+ if (!nkf_noescape_mime(c)) {
+ mimeout_addchar(c);
+ return;
+ }
+ }
+ if (c != 0x1B) {
+ (*o_mputc)(c);
+ base64_count++;
+ return;
+ }
+ }
+ }
+
+ if (mimeout_mode <= 0) {
+ if (c <= DEL && (output_mode==ASCII || output_mode == ISO_8859_1 ||
+ output_mode == UTF_8)) {
+ if (nkf_isspace(c)) {
+ int flag = 0;
+ if (mimeout_mode == -1) {
+ flag = 1;
+ }
+ if (c==CR || c==LF) {
+ if (flag) {
+ open_mime(output_mode);
+ output_mode = 0;
+ } else {
+ base64_count = 0;
+ }
+ }
+ for (i=0;i<mimeout_state.count;i++) {
+ (*o_mputc)(mimeout_state.buf[i]);
+ if (mimeout_state.buf[i] == CR || mimeout_state.buf[i] == LF){
+ base64_count = 0;
+ }else{
+ base64_count++;
+ }
+ }
+ if (flag) {
+ eof_mime();
+ base64_count = 0;
+ mimeout_mode = 0;
+ }
+ mimeout_state.buf[0] = (char)c;
+ mimeout_state.count = 1;
+ }else{
+ if (base64_count > 1
+ && base64_count + mimeout_state.count > 76
+ && mimeout_state.buf[0] != CR && mimeout_state.buf[0] != LF){
+ static const char *str = "boundary=\"";
+ static int len = 10;
+ i = 0;
+
+ for (; i < mimeout_state.count - len; ++i) {
+ if (!strncmp((char *)(mimeout_state.buf+i), str, len)) {
+ i += len - 2;
+ break;
+ }
+ }
+
+ if (i == 0 || i == mimeout_state.count - len) {
+ put_newline(o_mputc);
+ base64_count = 0;
+ if (!nkf_isspace(mimeout_state.buf[0])){
+ (*o_mputc)(SP);
+ base64_count++;
+ }
+ }
+ else {
+ int j;
+ for (j = 0; j <= i; ++j) {
+ (*o_mputc)(mimeout_state.buf[j]);
+ }
+ put_newline(o_mputc);
+ base64_count = 1;
+ for (; j <= mimeout_state.count; ++j) {
+ mimeout_state.buf[j - i] = mimeout_state.buf[j];
+ }
+ mimeout_state.count -= i;
+ }
+ }
+ mimeout_state.buf[mimeout_state.count++] = (char)c;
+ if (mimeout_state.count>MIMEOUT_BUF_LENGTH) {
+ open_mime(output_mode);
+ }
+ }
+ return;
+ }else{
+ if (lastchar==CR || lastchar == LF){
+ for (i=0;i<mimeout_state.count;i++) {
+ (*o_mputc)(mimeout_state.buf[i]);
+ }
+ base64_count = 0;
+ mimeout_state.count = 0;
+ }
+ if (lastchar==SP) {
+ for (i=0;i<mimeout_state.count-1;i++) {
+ (*o_mputc)(mimeout_state.buf[i]);
+ base64_count++;
+ }
+ mimeout_state.buf[0] = SP;
+ mimeout_state.count = 1;
+ }
+ open_mime(output_mode);
+ }
+ }else{
+ /* mimeout_mode == 'B', 1, 2 */
+ if (c <= DEL && (output_mode==ASCII || output_mode == ISO_8859_1 ||
+ output_mode == UTF_8)) {
+ if (lastchar == CR || lastchar == LF){
+ if (nkf_isblank(c)) {
+ for (i=0;i<mimeout_state.count;i++) {
+ mimeout_addchar(mimeout_state.buf[i]);
+ }
+ mimeout_state.count = 0;
+ } else {
+ eof_mime();
+ for (i=0;i<mimeout_state.count;i++) {
+ (*o_mputc)(mimeout_state.buf[i]);
+ }
+ base64_count = 0;
+ mimeout_state.count = 0;
+ }
+ mimeout_state.buf[mimeout_state.count++] = (char)c;
+ return;
+ }
+ if (nkf_isspace(c)) {
+ for (i=0;i<mimeout_state.count;i++) {
+ if (SP<mimeout_state.buf[i] && mimeout_state.buf[i]<DEL) {
+ eof_mime();
+ for (i=0;i<mimeout_state.count;i++) {
+ (*o_mputc)(mimeout_state.buf[i]);
+ base64_count++;
+ }
+ mimeout_state.count = 0;
+ }
+ }
+ mimeout_state.buf[mimeout_state.count++] = (char)c;
+ if (mimeout_state.count>MIMEOUT_BUF_LENGTH) {
+ eof_mime();
+ for (i=0;i<mimeout_state.count;i++) {
+ (*o_mputc)(mimeout_state.buf[i]);
+ base64_count++;
+ }
+ mimeout_state.count = 0;
+ }
+ return;
+ }
+ if (mimeout_state.count>0 && SP<c && c!='=') {
+ mimeout_state.buf[mimeout_state.count++] = (char)c;
+ if (mimeout_state.count>MIMEOUT_BUF_LENGTH) {
+ j = mimeout_state.count;
+ mimeout_state.count = 0;
+ for (i=0;i<j;i++) {
+ mimeout_addchar(mimeout_state.buf[i]);
+ }
+ }
+ return;
+ }
+ }
+ }
+ if (mimeout_state.count>0) {
+ j = mimeout_state.count;
+ mimeout_state.count = 0;
+ for (i=0;i<j;i++) {
+ if (mimeout_state.buf[i]==CR || mimeout_state.buf[i]==LF)
+ break;
+ mimeout_addchar(mimeout_state.buf[i]);
+ }
+ if (i<j) {
+ eof_mime();
+ base64_count=0;
+ for (;i<j;i++) {
+ (*o_mputc)(mimeout_state.buf[i]);
+ }
+ open_mime(output_mode);
+ }
+ }
+ mimeout_addchar(c);
+}
+
+static void
+base64_conv(nkf_char c2, nkf_char c1)
+{
+ mime_prechar(c2, c1);
+ (*o_base64conv)(c2,c1);
+}
+
+#ifdef HAVE_ICONV_H
+typedef struct nkf_iconv_t {
+ iconv_t cd;
+ char *input_buffer;
+ size_t input_buffer_size;
+ char *output_buffer;
+ size_t output_buffer_size;
+}
+
+static nkf_iconv_t
+nkf_iconv_new(char *tocode, char *fromcode)
+{
+ nkf_iconv_t converter;
+
+ converter->input_buffer_size = IOBUF_SIZE;
+ converter->input_buffer = nkf_xmalloc(converter->input_buffer_size);
+ converter->output_buffer_size = IOBUF_SIZE * 2;
+ converter->output_buffer = nkf_xmalloc(converter->output_buffer_size);
+ converter->cd = iconv_open(tocode, fromcode);
+ if (converter->cd == (iconv_t)-1)
+ {
+ switch (errno) {
+ case EINVAL:
+ perror(fprintf("iconv doesn't support %s to %s conversion.", fromcode, tocode));
+ return -1;
+ default:
+ perror("can't iconv_open");
+ }
+ }
+}
+
+static size_t
+nkf_iconv_convert(nkf_iconv_t *converter, FILE *input)
+{
+ size_t invalid = (size_t)0;
+ char *input_buffer = converter->input_buffer;
+ size_t input_length = (size_t)0;
+ char *output_buffer = converter->output_buffer;
+ size_t output_length = converter->output_buffer_size;
+ int c;
+
+ do {
+ if (c != EOF) {
+ while ((c = (*i_getc)(f)) != EOF) {
+ input_buffer[input_length++] = c;
+ if (input_length < converter->input_buffer_size) break;
+ }
+ }
+
+ size_t ret = iconv(converter->cd, &input_buffer, &input_length, &output_buffer, &output_length);
+ while (output_length-- > 0) {
+ (*o_putc)(output_buffer[converter->output_buffer_size-output_length]);
+ }
+ if (ret == (size_t) - 1) {
+ switch (errno) {
+ case EINVAL:
+ if (input_buffer != converter->input_buffer)
+ memmove(converter->input_buffer, input_buffer, input_length);
+ break;
+ case E2BIG:
+ converter->output_buffer_size *= 2;
+ output_buffer = realloc(converter->outbuf, converter->output_buffer_size);
+ if (output_buffer == NULL) {
+ perror("can't realloc");
+ return -1;
+ }
+ converter->output_buffer = output_buffer;
+ break;
+ default:
+ perror("can't iconv");
+ return -1;
+ }
+ } else {
+ invalid += ret;
+ }
+ } while (1);
+
+ return invalid;
+}
+
+
+static void
+nkf_iconv_close(nkf_iconv_t *convert)
+{
+ nkf_xfree(converter->inbuf);
+ nkf_xfree(converter->outbuf);
+ iconv_close(converter->cd);
+}
+#endif
+
+
+static void
+reinit(void)
+{
+ {
+ struct input_code *p = input_code_list;
+ while (p->name){
+ status_reinit(p++);
+ }
+ }
+ unbuf_f = FALSE;
+ estab_f = FALSE;
+ nop_f = FALSE;
+ binmode_f = TRUE;
+ rot_f = FALSE;
+ hira_f = FALSE;
+ alpha_f = FALSE;
+ mime_f = MIME_DECODE_DEFAULT;
+ mime_decode_f = FALSE;
+ mimebuf_f = FALSE;
+ broken_f = FALSE;
+ iso8859_f = FALSE;
+ mimeout_f = FALSE;
+ x0201_f = NKF_UNSPECIFIED;
+ iso2022jp_f = FALSE;
+#if defined(UTF8_INPUT_ENABLE) || defined(UTF8_OUTPUT_ENABLE)
+ ms_ucs_map_f = UCS_MAP_ASCII;
+#endif
+#ifdef UTF8_INPUT_ENABLE
+ no_cp932ext_f = FALSE;
+ no_best_fit_chars_f = FALSE;
+ encode_fallback = NULL;
+ unicode_subchar = '?';
+ input_endian = ENDIAN_BIG;
+#endif
+#ifdef UTF8_OUTPUT_ENABLE
+ output_bom_f = FALSE;
+ output_endian = ENDIAN_BIG;
+#endif
+#ifdef UNICODE_NORMALIZATION
+ nfc_f = FALSE;
+#endif
+#ifdef INPUT_OPTION
+ cap_f = FALSE;
+ url_f = FALSE;
+ numchar_f = FALSE;
+#endif
+#ifdef CHECK_OPTION
+ noout_f = FALSE;
+ debug_f = FALSE;
+#endif
+ guess_f = 0;
+#ifdef EXEC_IO
+ exec_f = 0;
+#endif
+#ifdef SHIFTJIS_CP932
+ cp51932_f = TRUE;
+ cp932inv_f = TRUE;
+#endif
+#ifdef X0212_ENABLE
+ x0212_f = FALSE;
+ x0213_f = FALSE;
+#endif
+ {
+ int i;
+ for (i = 0; i < 256; i++){
+ prefix_table[i] = 0;
+ }
+ }
+ hold_count = 0;
+ mimeout_state.count = 0;
+ mimeout_mode = 0;
+ base64_count = 0;
+ f_line = 0;
+ f_prev = 0;
+ fold_preserve_f = FALSE;
+ fold_f = FALSE;
+ fold_len = 0;
+ kanji_intro = DEFAULT_J;
+ ascii_intro = DEFAULT_R;
+ fold_margin = FOLD_MARGIN;
+ o_zconv = no_connection;
+ o_fconv = no_connection;
+ o_eol_conv = no_connection;
+ o_rot_conv = no_connection;
+ o_hira_conv = no_connection;
+ o_base64conv = no_connection;
+ o_iso2022jp_check_conv = no_connection;
+ o_putc = std_putc;
+ i_getc = std_getc;
+ i_ungetc = std_ungetc;
+ i_bgetc = std_getc;
+ i_bungetc = std_ungetc;
+ o_mputc = std_putc;
+ i_mgetc = std_getc;
+ i_mungetc = std_ungetc;
+ i_mgetc_buf = std_getc;
+ i_mungetc_buf = std_ungetc;
+ output_mode = ASCII;
+ input_mode = ASCII;
+ mime_decode_mode = FALSE;
+ file_out_f = FALSE;
+ eolmode_f = 0;
+ input_eol = 0;
+ prev_cr = 0;
+ option_mode = 0;
+ z_prev2=0,z_prev1=0;
+#ifdef CHECK_OPTION
+ iconv_for_check = 0;
+#endif
+ input_codename = NULL;
+ input_encoding = NULL;
+ output_encoding = NULL;
+ nkf_state_init();
+#ifdef WIN32DLL
+ reinitdll();
+#endif /*WIN32DLL*/
+}
+
+static int
+module_connection(void)
+{
+ if (input_encoding) set_input_encoding(input_encoding);
+ if (!output_encoding) {
+ output_encoding = nkf_default_encoding();
+ }
+ if (!output_encoding) {
+ if (noout_f || guess_f) output_encoding = nkf_enc_from_index(ISO_2022_JP);
+ else return -1;
+ }
+ set_output_encoding(output_encoding);
+ oconv = nkf_enc_to_oconv(output_encoding);
+ o_putc = std_putc;
+ if (nkf_enc_unicode_p(output_encoding))
+ output_mode = UTF_8;
+
+ if (x0201_f == NKF_UNSPECIFIED) {
+ x0201_f = X0201_DEFAULT;
+ }
+
+ /* replace continuation module, from output side */
+
+ /* output redirection */
+#ifdef CHECK_OPTION
+ if (noout_f || guess_f){
+ o_putc = no_putc;
+ }
+#endif
+ if (mimeout_f) {
+ o_mputc = o_putc;
+ o_putc = mime_putc;
+ if (mimeout_f == TRUE) {
+ o_base64conv = oconv; oconv = base64_conv;
+ }
+ /* base64_count = 0; */
+ }
+
+ if (eolmode_f || guess_f) {
+ o_eol_conv = oconv; oconv = eol_conv;
+ }
+ if (rot_f) {
+ o_rot_conv = oconv; oconv = rot_conv;
+ }
+ if (iso2022jp_f) {
+ o_iso2022jp_check_conv = oconv; oconv = iso2022jp_check_conv;
+ }
+ if (hira_f) {
+ o_hira_conv = oconv; oconv = hira_conv;
+ }
+ if (fold_f) {
+ o_fconv = oconv; oconv = fold_conv;
+ f_line = 0;
+ }
+ if (alpha_f || x0201_f) {
+ o_zconv = oconv; oconv = z_conv;
+ }
+
+ i_getc = std_getc;
+ i_ungetc = std_ungetc;
+ /* input redirection */
+#ifdef INPUT_OPTION
+ if (cap_f){
+ i_cgetc = i_getc; i_getc = cap_getc;
+ i_cungetc = i_ungetc; i_ungetc= cap_ungetc;
+ }
+ if (url_f){
+ i_ugetc = i_getc; i_getc = url_getc;
+ i_uungetc = i_ungetc; i_ungetc= url_ungetc;
+ }
+#endif
+#ifdef NUMCHAR_OPTION
+ if (numchar_f){
+ i_ngetc = i_getc; i_getc = numchar_getc;
+ i_nungetc = i_ungetc; i_ungetc= numchar_ungetc;
+ }
+#endif
+#ifdef UNICODE_NORMALIZATION
+ if (nfc_f){
+ i_nfc_getc = i_getc; i_getc = nfc_getc;
+ i_nfc_ungetc = i_ungetc; i_ungetc= nfc_ungetc;
+ }
+#endif
+ if (mime_f && mimebuf_f==FIXED_MIME) {
+ i_mgetc = i_getc; i_getc = mime_getc;
+ i_mungetc = i_ungetc; i_ungetc = mime_ungetc;
+ }
+ if (broken_f & 1) {
+ i_bgetc = i_getc; i_getc = broken_getc;
+ i_bungetc = i_ungetc; i_ungetc = broken_ungetc;
+ }
+ if (input_encoding) {
+ set_iconv(-TRUE, nkf_enc_to_iconv(input_encoding));
+ } else {
+ set_iconv(FALSE, e_iconv);
+ }
+
+ {
+ struct input_code *p = input_code_list;
+ while (p->name){
+ status_reinit(p++);
+ }
+ }
+ return 0;
+}
+
+/*
+ Conversion main loop. Code detection only.
+ */
+
+#if !defined(PERL_XS) && !defined(WIN32DLL)
+static nkf_char
+noconvert(FILE *f)
+{
+ nkf_char c;
+
+ if (nop_f == 2)
+ module_connection();
+ while ((c = (*i_getc)(f)) != EOF)
+ (*o_putc)(c);
+ (*o_putc)(EOF);
+ return 1;
+}
+#endif
+
+#define NEXT continue /* no output, get next */
+#define SKIP c2=0;continue /* no output, get next */
+#define MORE c2=c1;continue /* need one more byte */
+#define SEND (void)0 /* output c1 and c2, get next */
+#define LAST break /* end of loop, go closing */
+#define set_input_mode(mode) do { \
+ input_mode = mode; \
+ shift_mode = 0; \
+ set_input_codename("ISO-2022-JP"); \
+ debug("ISO-2022-JP"); \
+} while (0)
+
+static int
+kanji_convert(FILE *f)
+{
+ nkf_char c1=0, c2=0, c3=0, c4=0;
+ int shift_mode = 0; /* 0, 1, 2, 3 */
+ int g2 = 0;
+ int is_8bit = FALSE;
+
+ if (input_encoding && !nkf_enc_asciicompat(input_encoding)) {
+ is_8bit = TRUE;
+ }
+
+ input_mode = ASCII;
+ output_mode = ASCII;
+
+ if (module_connection() < 0) {
+#if !defined(PERL_XS) && !defined(WIN32DLL)
+ fprintf(stderr, "no output encoding given\n");
+#endif
+ return -1;
+ }
+ check_bom(f);
+
+#ifdef UTF8_INPUT_ENABLE
+ if(iconv == w_iconv32){
+ while ((c1 = (*i_getc)(f)) != EOF &&
+ (c2 = (*i_getc)(f)) != EOF &&
+ (c3 = (*i_getc)(f)) != EOF &&
+ (c4 = (*i_getc)(f)) != EOF) {
+ nkf_char c5, c6, c7, c8;
+ if (nkf_iconv_utf_32(c1, c2, c3, c4) == (size_t)NKF_ICONV_WAIT_COMBINING_CHAR) {
+ if ((c5 = (*i_getc)(f)) != EOF &&
+ (c6 = (*i_getc)(f)) != EOF &&
+ (c7 = (*i_getc)(f)) != EOF &&
+ (c8 = (*i_getc)(f)) != EOF) {
+ if (nkf_iconv_utf_32_combine(c1, c2, c3, c4, c5, c6, c7, c8)) {
+ (*i_ungetc)(c8, f);
+ (*i_ungetc)(c7, f);
+ (*i_ungetc)(c6, f);
+ (*i_ungetc)(c5, f);
+ nkf_iconv_utf_32_nocombine(c1, c2, c3, c4);
+ }
+ } else {
+ nkf_iconv_utf_32_nocombine(c1, c2, c3, c4);
+ }
+ }
+ }
+ goto finished;
+ }
+ else if (iconv == w_iconv16) {
+ while ((c1 = (*i_getc)(f)) != EOF &&
+ (c2 = (*i_getc)(f)) != EOF) {
+ size_t ret = nkf_iconv_utf_16(c1, c2, 0, 0);
+ if (ret == NKF_ICONV_NEED_TWO_MORE_BYTES &&
+ (c3 = (*i_getc)(f)) != EOF &&
+ (c4 = (*i_getc)(f)) != EOF) {
+ nkf_iconv_utf_16(c1, c2, c3, c4);
+ } else if (ret == (size_t)NKF_ICONV_WAIT_COMBINING_CHAR) {
+ if ((c3 = (*i_getc)(f)) != EOF &&
+ (c4 = (*i_getc)(f)) != EOF) {
+ if (nkf_iconv_utf_16_combine(c1, c2, c3, c4)) {
+ (*i_ungetc)(c4, f);
+ (*i_ungetc)(c3, f);
+ nkf_iconv_utf_16_nocombine(c1, c2);
+ }
+ } else {
+ nkf_iconv_utf_16_nocombine(c1, c2);
+ }
+ }
+ }
+ goto finished;
+ }
+#endif
+
+ while ((c1 = (*i_getc)(f)) != EOF) {
+#ifdef INPUT_CODE_FIX
+ if (!input_encoding)
+#endif
+ code_status(c1);
+ if (c2) {
+ /* second byte */
+ if (c2 > ((input_encoding && nkf_enc_cp5022x_p(input_encoding)) ? 0x92 : DEL)) {
+ /* in case of 8th bit is on */
+ if (!estab_f&&!mime_decode_mode) {
+ /* in case of not established yet */
+ /* It is still ambiguous */
+ if (h_conv(f, c2, c1)==EOF) {
+ LAST;
+ }
+ else {
+ SKIP;
+ }
+ }
+ else {
+ /* in case of already established */
+ if (c1 < 0x40) {
+ /* ignore bogus code */
+ SKIP;
+ } else {
+ SEND;
+ }
+ }
+ }
+ else {
+ /* 2nd byte of 7 bit code or SJIS */
+ SEND;
+ }
+ }
+ else if (nkf_char_unicode_p(c1)) {
+ (*oconv)(0, c1);
+ NEXT;
+ }
+ else {
+ /* first byte */
+ if (input_mode == JIS_X_0208 && DEL <= c1 && c1 < 0x92) {
+ /* CP5022x */
+ MORE;
+ }else if (input_codename && input_codename[0] == 'I' &&
+ 0xA1 <= c1 && c1 <= 0xDF) {
+ /* JIS X 0201 Katakana in 8bit JIS */
+ c2 = JIS_X_0201_1976_K;
+ c1 &= 0x7f;
+ SEND;
+ } else if (c1 > DEL) {
+ /* 8 bit code */
+ if (!estab_f && !iso8859_f) {
+ /* not established yet */
+ MORE;
+ } else { /* estab_f==TRUE */
+ if (iso8859_f) {
+ c2 = ISO_8859_1;
+ c1 &= 0x7f;
+ SEND;
+ }
+ else if ((iconv == s_iconv && 0xA0 <= c1 && c1 <= 0xDF) ||
+ (ms_ucs_map_f == UCS_MAP_CP10001 && (c1 == 0xFD || c1 == 0xFE))) {
+ /* JIS X 0201 */
+ c2 = JIS_X_0201_1976_K;
+ c1 &= 0x7f;
+ SEND;
+ }
+ else {
+ /* already established */
+ MORE;
+ }
+ }
+ } else if (SP < c1 && c1 < DEL) {
+ /* in case of Roman characters */
+ if (shift_mode) {
+ /* output 1 shifted byte */
+ if (iso8859_f) {
+ c2 = ISO_8859_1;
+ SEND;
+ } else if (nkf_byte_jisx0201_katakana_p(c1)){
+ /* output 1 shifted byte */
+ c2 = JIS_X_0201_1976_K;
+ SEND;
+ } else {
+ /* look like bogus code */
+ SKIP;
+ }
+ } else if (input_mode == JIS_X_0208 || input_mode == JIS_X_0212 ||
+ input_mode == JIS_X_0213_1 || input_mode == JIS_X_0213_2) {
+ /* in case of Kanji shifted */
+ MORE;
+ } else if (c1 == '=' && mime_f && !mime_decode_mode) {
+ /* Check MIME code */
+ if ((c1 = (*i_getc)(f)) == EOF) {
+ (*oconv)(0, '=');
+ LAST;
+ } else if (c1 == '?') {
+ /* =? is mime conversion start sequence */
+ if(mime_f == STRICT_MIME) {
+ /* check in real detail */
+ if (mime_begin_strict(f) == EOF)
+ LAST;
+ SKIP;
+ } else if (mime_begin(f) == EOF)
+ LAST;
+ SKIP;
+ } else {
+ (*oconv)(0, '=');
+ (*i_ungetc)(c1,f);
+ SKIP;
+ }
+ } else {
+ /* normal ASCII code */
+ SEND;
+ }
+ } else if (c1 == SI && (!is_8bit || mime_decode_mode)) {
+ shift_mode = 0;
+ SKIP;
+ } else if (c1 == SO && (!is_8bit || mime_decode_mode)) {
+ shift_mode = 1;
+ SKIP;
+ } else if (c1 == ESC && (!is_8bit || mime_decode_mode)) {
+ if ((c1 = (*i_getc)(f)) == EOF) {
+ (*oconv)(0, ESC);
+ LAST;
+ }
+ else if (c1 == '&') {
+ /* IRR */
+ if ((c1 = (*i_getc)(f)) == EOF) {
+ LAST;
+ } else {
+ SKIP;
+ }
+ }
+ else if (c1 == '$') {
+ /* GZDMx */
+ if ((c1 = (*i_getc)(f)) == EOF) {
+ /* don't send bogus code
+ (*oconv)(0, ESC);
+ (*oconv)(0, '$'); */
+ LAST;
+ } else if (c1 == '@' || c1 == 'B') {
+ /* JIS X 0208 */
+ set_input_mode(JIS_X_0208);
+ SKIP;
+ } else if (c1 == '(') {
+ /* GZDM4 */
+ if ((c1 = (*i_getc)(f)) == EOF) {
+ /* don't send bogus code
+ (*oconv)(0, ESC);
+ (*oconv)(0, '$');
+ (*oconv)(0, '(');
+ */
+ LAST;
+ } else if (c1 == '@'|| c1 == 'B') {
+ /* JIS X 0208 */
+ set_input_mode(JIS_X_0208);
+ SKIP;
+#ifdef X0212_ENABLE
+ } else if (c1 == 'D'){
+ set_input_mode(JIS_X_0212);
+ SKIP;
+#endif /* X0212_ENABLE */
+ } else if (c1 == 'O' || c1 == 'Q'){
+ set_input_mode(JIS_X_0213_1);
+ SKIP;
+ } else if (c1 == 'P'){
+ set_input_mode(JIS_X_0213_2);
+ SKIP;
+ } else {
+ /* could be some special code */
+ (*oconv)(0, ESC);
+ (*oconv)(0, '$');
+ (*oconv)(0, '(');
+ (*oconv)(0, c1);
+ SKIP;
+ }
+ } else if (broken_f&0x2) {
+ /* accept any ESC-(-x as broken code ... */
+ input_mode = JIS_X_0208;
+ shift_mode = 0;
+ SKIP;
+ } else {
+ (*oconv)(0, ESC);
+ (*oconv)(0, '$');
+ (*oconv)(0, c1);
+ SKIP;
+ }
+ } else if (c1 == '(') {
+ /* GZD4 */
+ if ((c1 = (*i_getc)(f)) == EOF) {
+ /* don't send bogus code
+ (*oconv)(0, ESC);
+ (*oconv)(0, '('); */
+ LAST;
+ }
+ else if (c1 == 'I') {
+ /* JIS X 0201 Katakana */
+ set_input_mode(JIS_X_0201_1976_K);
+ shift_mode = 1;
+ SKIP;
+ }
+ else if (c1 == 'B' || c1 == 'J' || c1 == 'H') {
+ /* ISO-646IRV:1983 or JIS X 0201 Roman or JUNET */
+ set_input_mode(ASCII);
+ SKIP;
+ }
+ else if (broken_f&0x2) {
+ set_input_mode(ASCII);
+ SKIP;
+ }
+ else {
+ (*oconv)(0, ESC);
+ (*oconv)(0, '(');
+ SEND;
+ }
+ }
+ else if (c1 == '.') {
+ /* G2D6 */
+ if ((c1 = (*i_getc)(f)) == EOF) {
+ LAST;
+ }
+ else if (c1 == 'A') {
+ /* ISO-8859-1 */
+ g2 = ISO_8859_1;
+ SKIP;
+ }
+ else {
+ (*oconv)(0, ESC);
+ (*oconv)(0, '.');
+ SEND;
+ }
+ }
+ else if (c1 == 'N') {
+ /* SS2 */
+ c1 = (*i_getc)(f);
+ if (g2 == ISO_8859_1) {
+ c2 = ISO_8859_1;
+ SEND;
+ }else{
+ (*i_ungetc)(c1, f);
+ /* lonely ESC */
+ (*oconv)(0, ESC);
+ SEND;
+ }
+ }
+ else {
+ i_ungetc(c1,f);
+ /* lonely ESC */
+ (*oconv)(0, ESC);
+ SKIP;
+ }
+ } else if (c1 == ESC && iconv == s_iconv) {
+ /* ESC in Shift_JIS */
+ if ((c1 = (*i_getc)(f)) == EOF) {
+ (*oconv)(0, ESC);
+ LAST;
+ } else if (c1 == '$') {
+ /* J-PHONE emoji */
+ if ((c1 = (*i_getc)(f)) == EOF) {
+ LAST;
+ } else if (('E' <= c1 && c1 <= 'G') ||
+ ('O' <= c1 && c1 <= 'Q')) {
+ /*
+ NUM : 0 1 2 3 4 5
+ BYTE: G E F O P Q
+ C%7 : 1 6 0 2 3 4
+ C%7 : 0 1 2 3 4 5 6
+ NUM : 2 0 3 4 5 X 1
+ */
+ static const nkf_char jphone_emoji_first_table[7] =
+ {0xE1E0, 0xDFE0, 0xE2E0, 0xE3E0, 0xE4E0, 0xDFE0, 0xE0E0};
+ c3 = nkf_char_unicode_new(jphone_emoji_first_table[c1 % 7]);
+ if ((c1 = (*i_getc)(f)) == EOF) LAST;
+ while (SP <= c1 && c1 <= 'z') {
+ (*oconv)(0, c1 + c3);
+ if ((c1 = (*i_getc)(f)) == EOF) LAST;
+ }
+ SKIP;
+ }
+ else {
+ (*oconv)(0, ESC);
+ (*oconv)(0, '$');
+ SEND;
+ }
+ }
+ else {
+ i_ungetc(c1,f);
+ /* lonely ESC */
+ (*oconv)(0, ESC);
+ SKIP;
+ }
+ } else if (c1 == LF || c1 == CR) {
+ if (broken_f&4) {
+ input_mode = ASCII; set_iconv(FALSE, 0);
+ SEND;
+ } else if (mime_decode_f && !mime_decode_mode){
+ if (c1 == LF) {
+ if ((c1=(*i_getc)(f))!=EOF && c1 == SP) {
+ i_ungetc(SP,f);
+ continue;
+ } else {
+ i_ungetc(c1,f);
+ }
+ c1 = LF;
+ SEND;
+ } else { /* if (c1 == CR)*/
+ if ((c1=(*i_getc)(f))!=EOF) {
+ if (c1==SP) {
+ i_ungetc(SP,f);
+ continue;
+ } else if (c1 == LF && (c1=(*i_getc)(f))!=EOF && c1 == SP) {
+ i_ungetc(SP,f);
+ continue;
+ } else {
+ i_ungetc(c1,f);
+ }
+ i_ungetc(LF,f);
+ } else {
+ i_ungetc(c1,f);
+ }
+ c1 = CR;
+ SEND;
+ }
+ }
+ } else
+ SEND;
+ }
+ /* send: */
+ switch(input_mode){
+ case ASCII:
+ switch ((*iconv)(c2, c1, 0)) { /* can be EUC / SJIS / UTF-8 */
+ case -2:
+ /* 4 bytes UTF-8 */
+ if ((c3 = (*i_getc)(f)) != EOF) {
+ code_status(c3);
+ c3 <<= 8;
+ if ((c4 = (*i_getc)(f)) != EOF) {
+ code_status(c4);
+ (*iconv)(c2, c1, c3|c4);
+ }
+ }
+ break;
+ case -3:
+ /* 4 bytes UTF-8 (check combining character) */
+ if ((c3 = (*i_getc)(f)) != EOF) {
+ if ((c4 = (*i_getc)(f)) != EOF) {
+ if (w_iconv_combine(c2, c1, 0, c3, c4, 0)) {
+ (*i_ungetc)(c4, f);
+ (*i_ungetc)(c3, f);
+ w_iconv_nocombine(c2, c1, 0);
+ }
+ } else {
+ (*i_ungetc)(c3, f);
+ w_iconv_nocombine(c2, c1, 0);
+ }
+ } else {
+ w_iconv_nocombine(c2, c1, 0);
+ }
+ break;
+ case -1:
+ /* 3 bytes EUC or UTF-8 */
+ if ((c3 = (*i_getc)(f)) != EOF) {
+ code_status(c3);
+ if ((*iconv)(c2, c1, c3) == -3) {
+ /* 6 bytes UTF-8 (check combining character) */
+ nkf_char c5, c6;
+ if ((c4 = (*i_getc)(f)) != EOF) {
+ if ((c5 = (*i_getc)(f)) != EOF) {
+ if ((c6 = (*i_getc)(f)) != EOF) {
+ if (w_iconv_combine(c2, c1, c3, c4, c5, c6)) {
+ (*i_ungetc)(c6, f);
+ (*i_ungetc)(c5, f);
+ (*i_ungetc)(c4, f);
+ w_iconv_nocombine(c2, c1, c3);
+ }
+ } else {
+ (*i_ungetc)(c5, f);
+ (*i_ungetc)(c4, f);
+ w_iconv_nocombine(c2, c1, c3);
+ }
+ } else {
+ (*i_ungetc)(c4, f);
+ w_iconv_nocombine(c2, c1, c3);
+ }
+ } else {
+ w_iconv_nocombine(c2, c1, c3);
+ }
+ }
+ }
+ break;
+ }
+ break;
+ case JIS_X_0208:
+ case JIS_X_0213_1:
+ if (ms_ucs_map_f &&
+ 0x7F <= c2 && c2 <= 0x92 &&
+ 0x21 <= c1 && c1 <= 0x7E) {
+ /* CP932 UDC */
+ c1 = nkf_char_unicode_new((c2 - 0x7F) * 94 + c1 - 0x21 + 0xE000);
+ c2 = 0;
+ }
+ (*oconv)(c2, c1); /* this is JIS, not SJIS/EUC case */
+ break;
+#ifdef X0212_ENABLE
+ case JIS_X_0212:
+ (*oconv)(PREFIX_EUCG3 | c2, c1);
+ break;
+#endif /* X0212_ENABLE */
+ case JIS_X_0213_2:
+ (*oconv)(PREFIX_EUCG3 | c2, c1);
+ break;
+ default:
+ (*oconv)(input_mode, c1); /* other special case */
+ }
+
+ c2 = 0;
+ c3 = 0;
+ continue;
+ /* goto next_word */
+ }
+
+finished:
+ /* epilogue */
+ (*iconv)(EOF, 0, 0);
+ if (!input_codename)
+ {
+ if (is_8bit) {
+ struct input_code *p = input_code_list;
+ struct input_code *result = p;
+ while (p->name){
+ if (p->score < result->score) result = p;
+ ++p;
+ }
+ set_input_codename(result->name);
+#ifdef CHECK_OPTION
+ debug(result->name);
+#endif
+ }
+ }
+ return 0;
+}
+
+/*
+ * int options(unsigned char *cp)
+ *
+ * return values:
+ * 0: success
+ * -1: ArgumentError
+ */
+static int
+options(unsigned char *cp)
+{
+ nkf_char i, j;
+ unsigned char *p;
+ unsigned char *cp_back = NULL;
+ nkf_encoding *enc;
+
+ if (option_mode==1)
+ return 0;
+ while(*cp && *cp++!='-');
+ while (*cp || cp_back) {
+ if(!*cp){
+ cp = cp_back;
+ cp_back = NULL;
+ continue;
+ }
+ p = 0;
+ switch (*cp++) {
+ case '-': /* literal options */
+ if (!*cp || *cp == SP) { /* ignore the rest of arguments */
+ option_mode = 1;
+ return 0;
+ }
+ for (i=0;i<(int)(sizeof(long_option)/sizeof(long_option[0]));i++) {
+ p = (unsigned char *)long_option[i].name;
+ for (j=0;*p && *p != '=' && *p == cp[j];p++, j++);
+ if (*p == cp[j] || cp[j] == SP){
+ p = &cp[j] + 1;
+ break;
+ }
+ p = 0;
+ }
+ if (p == 0) {
+#if !defined(PERL_XS) && !defined(WIN32DLL)
+ fprintf(stderr, "unknown long option: --%s\n", cp);
+#endif
+ return -1;
+ }
+ while(*cp && *cp != SP && cp++);
+ if (long_option[i].alias[0]){
+ cp_back = cp;
+ cp = (unsigned char *)long_option[i].alias;
+ }else{
+#ifndef PERL_XS
+ if (strcmp(long_option[i].name, "help") == 0){
+ usage();
+ exit(EXIT_SUCCESS);
+ }
+#endif
+ if (strcmp(long_option[i].name, "ic=") == 0){
+ enc = nkf_enc_find((char *)p);
+ if (!enc) continue;
+ input_encoding = enc;
+ continue;
+ }
+ if (strcmp(long_option[i].name, "oc=") == 0){
+ enc = nkf_enc_find((char *)p);
+ /* if (enc <= 0) continue; */
+ if (!enc) continue;
+ output_encoding = enc;
+ continue;
+ }
+ if (strcmp(long_option[i].name, "guess=") == 0){
+ if (p[0] == '0' || p[0] == '1') {
+ guess_f = 1;
+ } else {
+ guess_f = 2;
+ }
+ continue;
+ }
+#ifdef OVERWRITE
+ if (strcmp(long_option[i].name, "overwrite") == 0){
+ file_out_f = TRUE;
+ overwrite_f = TRUE;
+ preserve_time_f = TRUE;
+ continue;
+ }
+ if (strcmp(long_option[i].name, "overwrite=") == 0){
+ file_out_f = TRUE;
+ overwrite_f = TRUE;
+ preserve_time_f = TRUE;
+ backup_f = TRUE;
+ backup_suffix = (char *)p;
+ continue;
+ }
+ if (strcmp(long_option[i].name, "in-place") == 0){
+ file_out_f = TRUE;
+ overwrite_f = TRUE;
+ preserve_time_f = FALSE;
+ continue;
+ }
+ if (strcmp(long_option[i].name, "in-place=") == 0){
+ file_out_f = TRUE;
+ overwrite_f = TRUE;
+ preserve_time_f = FALSE;
+ backup_f = TRUE;
+ backup_suffix = (char *)p;
+ continue;
+ }
+#endif
+#ifdef INPUT_OPTION
+ if (strcmp(long_option[i].name, "cap-input") == 0){
+ cap_f = TRUE;
+ continue;
+ }
+ if (strcmp(long_option[i].name, "url-input") == 0){
+ url_f = TRUE;
+ continue;
+ }
+#endif
+#ifdef NUMCHAR_OPTION
+ if (strcmp(long_option[i].name, "numchar-input") == 0){
+ numchar_f = TRUE;
+ continue;
+ }
+#endif
+#ifdef CHECK_OPTION
+ if (strcmp(long_option[i].name, "no-output") == 0){
+ noout_f = TRUE;
+ continue;
+ }
+ if (strcmp(long_option[i].name, "debug") == 0){
+ debug_f = TRUE;
+ continue;
+ }
+#endif
+ if (strcmp(long_option[i].name, "cp932") == 0){
+#ifdef SHIFTJIS_CP932
+ cp51932_f = TRUE;
+ cp932inv_f = -TRUE;
+#endif
+#ifdef UTF8_OUTPUT_ENABLE
+ ms_ucs_map_f = UCS_MAP_CP932;
+#endif
+ continue;
+ }
+ if (strcmp(long_option[i].name, "no-cp932") == 0){
+#ifdef SHIFTJIS_CP932
+ cp51932_f = FALSE;
+ cp932inv_f = FALSE;
+#endif
+#ifdef UTF8_OUTPUT_ENABLE
+ ms_ucs_map_f = UCS_MAP_ASCII;
+#endif
+ continue;
+ }
+#ifdef SHIFTJIS_CP932
+ if (strcmp(long_option[i].name, "cp932inv") == 0){
+ cp932inv_f = -TRUE;
+ continue;
+ }
+#endif
+
+#ifdef X0212_ENABLE
+ if (strcmp(long_option[i].name, "x0212") == 0){
+ x0212_f = TRUE;
+ continue;
+ }
+#endif
+
+#ifdef EXEC_IO
+ if (strcmp(long_option[i].name, "exec-in") == 0){
+ exec_f = 1;
+ return 0;
+ }
+ if (strcmp(long_option[i].name, "exec-out") == 0){
+ exec_f = -1;
+ return 0;
+ }
+#endif
+#if defined(UTF8_OUTPUT_ENABLE) && defined(UTF8_INPUT_ENABLE)
+ if (strcmp(long_option[i].name, "no-cp932ext") == 0){
+ no_cp932ext_f = TRUE;
+ continue;
+ }
+ if (strcmp(long_option[i].name, "no-best-fit-chars") == 0){
+ no_best_fit_chars_f = TRUE;
+ continue;
+ }
+ if (strcmp(long_option[i].name, "fb-skip") == 0){
+ encode_fallback = NULL;
+ continue;
+ }
+ if (strcmp(long_option[i].name, "fb-html") == 0){
+ encode_fallback = encode_fallback_html;
+ continue;
+ }
+ if (strcmp(long_option[i].name, "fb-xml") == 0){
+ encode_fallback = encode_fallback_xml;
+ continue;
+ }
+ if (strcmp(long_option[i].name, "fb-java") == 0){
+ encode_fallback = encode_fallback_java;
+ continue;
+ }
+ if (strcmp(long_option[i].name, "fb-perl") == 0){
+ encode_fallback = encode_fallback_perl;
+ continue;
+ }
+ if (strcmp(long_option[i].name, "fb-subchar") == 0){
+ encode_fallback = encode_fallback_subchar;
+ continue;
+ }
+ if (strcmp(long_option[i].name, "fb-subchar=") == 0){
+ encode_fallback = encode_fallback_subchar;
+ unicode_subchar = 0;
+ if (p[0] != '0'){
+ /* decimal number */
+ for (i = 0; i < 7 && nkf_isdigit(p[i]); i++){
+ unicode_subchar *= 10;
+ unicode_subchar += hex2bin(p[i]);
+ }
+ }else if(p[1] == 'x' || p[1] == 'X'){
+ /* hexadecimal number */
+ for (i = 2; i < 8 && nkf_isxdigit(p[i]); i++){
+ unicode_subchar <<= 4;
+ unicode_subchar |= hex2bin(p[i]);
+ }
+ }else{
+ /* octal number */
+ for (i = 1; i < 8 && nkf_isoctal(p[i]); i++){
+ unicode_subchar *= 8;
+ unicode_subchar += hex2bin(p[i]);
+ }
+ }
+ w16e_conv(unicode_subchar, &i, &j);
+ unicode_subchar = i<<8 | j;
+ continue;
+ }
+#endif
+#ifdef UTF8_OUTPUT_ENABLE
+ if (strcmp(long_option[i].name, "ms-ucs-map") == 0){
+ ms_ucs_map_f = UCS_MAP_MS;
+ continue;
+ }
+#endif
+#ifdef UNICODE_NORMALIZATION
+ if (strcmp(long_option[i].name, "utf8mac-input") == 0){
+ nfc_f = TRUE;
+ continue;
+ }
+#endif
+ if (strcmp(long_option[i].name, "prefix=") == 0){
+ if (nkf_isgraph(p[0])){
+ for (i = 1; nkf_isgraph(p[i]); i++){
+ prefix_table[p[i]] = p[0];
+ }
+ }
+ continue;
+ }
+#if !defined(PERL_XS) && !defined(WIN32DLL)
+ fprintf(stderr, "unsupported long option: --%s\n", long_option[i].name);
+#endif
+ return -1;
+ }
+ continue;
+ case 'b': /* buffered mode */
+ unbuf_f = FALSE;
+ continue;
+ case 'u': /* non bufferd mode */
+ unbuf_f = TRUE;
+ continue;
+ case 't': /* transparent mode */
+ if (*cp=='1') {
+ /* alias of -t */
+ cp++;
+ nop_f = TRUE;
+ } else if (*cp=='2') {
+ /*
+ * -t with put/get
+ *
+ * nkf -t2MB hoge.bin | nkf -t2mB | diff -s - hoge.bin
+ *
+ */
+ cp++;
+ nop_f = 2;
+ } else
+ nop_f = TRUE;
+ continue;
+ case 'j': /* JIS output */
+ case 'n':
+ output_encoding = nkf_enc_from_index(ISO_2022_JP);
+ continue;
+ case 'e': /* AT&T EUC output */
+ output_encoding = nkf_enc_from_index(EUCJP_NKF);
+ continue;
+ case 's': /* SJIS output */
+ output_encoding = nkf_enc_from_index(SHIFT_JIS);
+ continue;
+ case 'l': /* ISO8859 Latin-1 support, no conversion */
+ iso8859_f = TRUE; /* Only compatible with ISO-2022-JP */
+ input_encoding = nkf_enc_from_index(ISO_8859_1);
+ continue;
+ case 'i': /* Kanji IN ESC-$-@/B */
+ if (*cp=='@'||*cp=='B')
+ kanji_intro = *cp++;
+ continue;
+ case 'o': /* ASCII IN ESC-(-J/B/H */
+ /* ESC ( H was used in initial JUNET messages */
+ if (*cp=='J'||*cp=='B'||*cp=='H')
+ ascii_intro = *cp++;
+ continue;
+ case 'h':
+ /*
+ bit:1 katakana->hiragana
+ bit:2 hiragana->katakana
+ */
+ if ('9'>= *cp && *cp>='0')
+ hira_f |= (*cp++ -'0');
+ else
+ hira_f |= 1;
+ continue;
+ case 'r':
+ rot_f = TRUE;
+ continue;
+#if defined(MSDOS) || defined(__OS2__)
+ case 'T':
+ binmode_f = FALSE;
+ continue;
+#endif
+#ifndef PERL_XS
+ case 'V':
+ show_configuration();
+ exit(EXIT_SUCCESS);
+ break;
+ case 'v':
+ version();
+ exit(EXIT_SUCCESS);
+ break;
+#endif
+#ifdef UTF8_OUTPUT_ENABLE
+ case 'w': /* UTF-{8,16,32} output */
+ if (cp[0] == '8') {
+ cp++;
+ if (cp[0] == '0'){
+ cp++;
+ output_encoding = nkf_enc_from_index(UTF_8N);
+ } else {
+ output_bom_f = TRUE;
+ output_encoding = nkf_enc_from_index(UTF_8_BOM);
+ }
+ } else {
+ int enc_idx;
+ if ('1'== cp[0] && '6'==cp[1]) {
+ cp += 2;
+ enc_idx = UTF_16;
+ } else if ('3'== cp[0] && '2'==cp[1]) {
+ cp += 2;
+ enc_idx = UTF_32;
+ } else {
+ output_encoding = nkf_enc_from_index(UTF_8);
+ continue;
+ }
+ if (cp[0]=='L') {
+ cp++;
+ output_endian = ENDIAN_LITTLE;
+ output_bom_f = TRUE;
+ } else if (cp[0] == 'B') {
+ cp++;
+ output_bom_f = TRUE;
+ }
+ if (cp[0] == '0'){
+ output_bom_f = FALSE;
+ cp++;
+ enc_idx = enc_idx == UTF_16
+ ? (output_endian == ENDIAN_LITTLE ? UTF_16LE : UTF_16BE)
+ : (output_endian == ENDIAN_LITTLE ? UTF_32LE : UTF_32BE);
+ } else {
+ enc_idx = enc_idx == UTF_16
+ ? (output_endian == ENDIAN_LITTLE ? UTF_16LE_BOM : UTF_16BE_BOM)
+ : (output_endian == ENDIAN_LITTLE ? UTF_32LE_BOM : UTF_32BE_BOM);
+ }
+ output_encoding = nkf_enc_from_index(enc_idx);
+ }
+ continue;
+#endif
+#ifdef UTF8_INPUT_ENABLE
+ case 'W': /* UTF input */
+ if (cp[0] == '8') {
+ cp++;
+ input_encoding = nkf_enc_from_index(UTF_8);
+ }else{
+ int enc_idx;
+ if ('1'== cp[0] && '6'==cp[1]) {
+ cp += 2;
+ input_endian = ENDIAN_BIG;
+ enc_idx = UTF_16;
+ } else if ('3'== cp[0] && '2'==cp[1]) {
+ cp += 2;
+ input_endian = ENDIAN_BIG;
+ enc_idx = UTF_32;
+ } else {
+ input_encoding = nkf_enc_from_index(UTF_8);
+ continue;
+ }
+ if (cp[0]=='L') {
+ cp++;
+ input_endian = ENDIAN_LITTLE;
+ } else if (cp[0] == 'B') {
+ cp++;
+ input_endian = ENDIAN_BIG;
+ }
+ enc_idx = (enc_idx == UTF_16
+ ? (input_endian == ENDIAN_LITTLE ? UTF_16LE : UTF_16BE)
+ : (input_endian == ENDIAN_LITTLE ? UTF_32LE : UTF_32BE));
+ input_encoding = nkf_enc_from_index(enc_idx);
+ }
+ continue;
+#endif
+ /* Input code assumption */
+ case 'J': /* ISO-2022-JP input */
+ input_encoding = nkf_enc_from_index(ISO_2022_JP);
+ continue;
+ case 'E': /* EUC-JP input */
+ input_encoding = nkf_enc_from_index(EUCJP_NKF);
+ continue;
+ case 'S': /* Shift_JIS input */
+ input_encoding = nkf_enc_from_index(SHIFT_JIS);
+ continue;
+ case 'Z': /* Convert X0208 alphabet to asii */
+ /* alpha_f
+ bit:0 Convert JIS X 0208 Alphabet to ASCII
+ bit:1 Convert Kankaku to one space
+ bit:2 Convert Kankaku to two spaces
+ bit:3 Convert HTML Entity
+ bit:4 Convert JIS X 0208 Katakana to JIS X 0201 Katakana
+ */
+ while ('0'<= *cp && *cp <='4') {
+ alpha_f |= 1 << (*cp++ - '0');
+ }
+ alpha_f |= 1;
+ continue;
+ case 'x': /* Convert X0201 kana to X0208 or X0201 Conversion */
+ x0201_f = FALSE; /* No X0201->X0208 conversion */
+ /* accept X0201
+ ESC-(-I in JIS, EUC, MS Kanji
+ SI/SO in JIS, EUC, MS Kanji
+ SS2 in EUC, JIS, not in MS Kanji
+ MS Kanji (0xa0-0xdf)
+ output X0201
+ ESC-(-I in JIS (0x20-0x5f)
+ SS2 in EUC (0xa0-0xdf)
+ 0xa0-0xd in MS Kanji (0xa0-0xdf)
+ */
+ continue;
+ case 'X': /* Convert X0201 kana to X0208 */
+ x0201_f = TRUE;
+ continue;
+ case 'F': /* prserve new lines */
+ fold_preserve_f = TRUE;
+ case 'f': /* folding -f60 or -f */
+ fold_f = TRUE;
+ fold_len = 0;
+ while('0'<= *cp && *cp <='9') { /* we don't use atoi here */
+ fold_len *= 10;
+ fold_len += *cp++ - '0';
+ }
+ if (!(0<fold_len && fold_len<BUFSIZ))
+ fold_len = DEFAULT_FOLD;
+ if (*cp=='-') {
+ fold_margin = 0;
+ cp++;
+ while('0'<= *cp && *cp <='9') { /* we don't use atoi here */
+ fold_margin *= 10;
+ fold_margin += *cp++ - '0';
+ }
+ }
+ continue;
+ case 'm': /* MIME support */
+ /* mime_decode_f = TRUE; */ /* this has too large side effects... */
+ if (*cp=='B'||*cp=='Q') {
+ mime_decode_mode = *cp++;
+ mimebuf_f = FIXED_MIME;
+ } else if (*cp=='N') {
+ mime_f = TRUE; cp++;
+ } else if (*cp=='S') {
+ mime_f = STRICT_MIME; cp++;
+ } else if (*cp=='0') {
+ mime_decode_f = FALSE;
+ mime_f = FALSE; cp++;
+ } else {
+ mime_f = STRICT_MIME;
+ }
+ continue;
+ case 'M': /* MIME output */
+ if (*cp=='B') {
+ mimeout_mode = 'B';
+ mimeout_f = FIXED_MIME; cp++;
+ } else if (*cp=='Q') {
+ mimeout_mode = 'Q';
+ mimeout_f = FIXED_MIME; cp++;
+ } else {
+ mimeout_f = TRUE;
+ }
+ continue;
+ case 'B': /* Broken JIS support */
+ /* bit:0 no ESC JIS
+ bit:1 allow any x on ESC-(-x or ESC-$-x
+ bit:2 reset to ascii on NL
+ */
+ if ('9'>= *cp && *cp>='0')
+ broken_f |= 1<<(*cp++ -'0');
+ else
+ broken_f |= TRUE;
+ continue;
+#ifndef PERL_XS
+ case 'O':/* for Output file */
+ file_out_f = TRUE;
+ continue;
+#endif
+ case 'c':/* add cr code */
+ eolmode_f = CRLF;
+ continue;
+ case 'd':/* delete cr code */
+ eolmode_f = LF;
+ continue;
+ case 'I': /* ISO-2022-JP output */
+ iso2022jp_f = TRUE;
+ continue;
+ case 'L': /* line mode */
+ if (*cp=='u') { /* unix */
+ eolmode_f = LF; cp++;
+ } else if (*cp=='m') { /* mac */
+ eolmode_f = CR; cp++;
+ } else if (*cp=='w') { /* windows */
+ eolmode_f = CRLF; cp++;
+ } else if (*cp=='0') { /* no conversion */
+ eolmode_f = 0; cp++;
+ }
+ continue;
+#ifndef PERL_XS
+ case 'g':
+ if ('2' <= *cp && *cp <= '9') {
+ guess_f = 2;
+ cp++;
+ } else if (*cp == '0' || *cp == '1') {
+ guess_f = 1;
+ cp++;
+ } else {
+ guess_f = 1;
+ }
+ continue;
+#endif
+ case SP:
+ /* module multiple options in a string are allowed for Perl module */
+ while(*cp && *cp++!='-');
+ continue;
+ default:
+#if !defined(PERL_XS) && !defined(WIN32DLL)
+ fprintf(stderr, "unknown option: -%c\n", *(cp-1));
+#endif
+ /* bogus option but ignored */
+ return -1;
+ }
+ }
+ return 0;
+}
+
+#ifdef WIN32DLL
+#include "nkf32dll.c"
+#elif defined(PERL_XS)
+#else /* WIN32DLL */
+int
+main(int argc, char **argv)
+{
+ FILE *fin;
+ unsigned char *cp;
+
+ char *outfname = NULL;
+ char *origfname;
+
+#ifdef EASYWIN /*Easy Win */
+ _BufferSize.y = 400;/*Set Scroll Buffer Size*/
+#endif
+#ifdef DEFAULT_CODE_LOCALE
+ setlocale(LC_CTYPE, "");
+#endif
+ nkf_state_init();
+
+ for (argc--,argv++; (argc > 0) && **argv == '-'; argc--, argv++) {
+ cp = (unsigned char *)*argv;
+ options(cp);
+#ifdef EXEC_IO
+ if (exec_f){
+ int fds[2], pid;
+ if (pipe(fds) < 0 || (pid = fork()) < 0){
+ abort();
+ }
+ if (pid == 0){
+ if (exec_f > 0){
+ close(fds[0]);
+ dup2(fds[1], 1);
+ }else{
+ close(fds[1]);
+ dup2(fds[0], 0);
+ }
+ execvp(argv[1], &argv[1]);
+ }
+ if (exec_f > 0){
+ close(fds[1]);
+ dup2(fds[0], 0);
+ }else{
+ close(fds[0]);
+ dup2(fds[1], 1);
+ }
+ argc = 0;
+ break;
+ }
+#endif
+ }
+
+ if (guess_f) {
+#ifdef CHECK_OPTION
+ int debug_f_back = debug_f;
+#endif
+#ifdef EXEC_IO
+ int exec_f_back = exec_f;
+#endif
+#ifdef X0212_ENABLE
+ int x0212_f_back = x0212_f;
+#endif
+ int x0213_f_back = x0213_f;
+ int guess_f_back = guess_f;
+ reinit();
+ guess_f = guess_f_back;
+ mime_f = FALSE;
+#ifdef CHECK_OPTION
+ debug_f = debug_f_back;
+#endif
+#ifdef EXEC_IO
+ exec_f = exec_f_back;
+#endif
+ x0212_f = x0212_f_back;
+ x0213_f = x0213_f_back;
+ }
+
+ if (binmode_f == TRUE)
+#if defined(__OS2__) && (defined(__IBMC__) || defined(__IBMCPP__))
+ if (freopen("","wb",stdout) == NULL)
+ return (-1);
+#else
+ setbinmode(stdout);
+#endif
+
+ if (unbuf_f)
+ setbuf(stdout, (char *) NULL);
+ else
+ setvbuffer(stdout, (char *) stdobuf, IOBUF_SIZE);
+
+ if (argc == 0) {
+ if (binmode_f == TRUE)
+#if defined(__OS2__) && (defined(__IBMC__) || defined(__IBMCPP__))
+ if (freopen("","rb",stdin) == NULL) return (-1);
+#else
+ setbinmode(stdin);
+#endif
+ setvbuffer(stdin, (char *) stdibuf, IOBUF_SIZE);
+ if (nop_f)
+ noconvert(stdin);
+ else {
+ kanji_convert(stdin);
+ if (guess_f) print_guessed_code(NULL);
+ }
+ } else {
+ int nfiles = argc;
+ int is_argument_error = FALSE;
+ while (argc--) {
+ input_codename = NULL;
+ input_eol = 0;
+#ifdef CHECK_OPTION
+ iconv_for_check = 0;
+#endif
+ if ((fin = fopen((origfname = *argv++), "r")) == NULL) {
+ perror(*(argv-1));
+ is_argument_error = TRUE;
+ continue;
+ } else {
+#ifdef OVERWRITE
+ int fd = 0;
+ int fd_backup = 0;
+#endif
+
+ /* reopen file for stdout */
+ if (file_out_f == TRUE) {
+#ifdef OVERWRITE
+ if (overwrite_f){
+ outfname = nkf_xmalloc(strlen(origfname)
+ + strlen(".nkftmpXXXXXX")
+ + 1);
+ strcpy(outfname, origfname);
+#ifdef MSDOS
+ {
+ int i;
+ for (i = strlen(outfname); i; --i){
+ if (outfname[i - 1] == '/'
+ || outfname[i - 1] == '\\'){
+ break;
+ }
+ }
+ outfname[i] = '\0';
+ }
+ strcat(outfname, "ntXXXXXX");
+ mktemp(outfname);
+ fd = open(outfname, O_WRONLY | O_CREAT | O_TRUNC | O_EXCL,
+ S_IREAD | S_IWRITE);
+#else
+ strcat(outfname, ".nkftmpXXXXXX");
+ fd = mkstemp(outfname);
+#endif
+ if (fd < 0
+ || (fd_backup = dup(fileno(stdout))) < 0
+ || dup2(fd, fileno(stdout)) < 0
+ ){
+ perror(origfname);
+ return -1;
+ }
+ }else
+#endif
+ if(argc == 1) {
+ outfname = *argv++;
+ argc--;
+ } else {
+ outfname = "nkf.out";
+ }
+
+ if(freopen(outfname, "w", stdout) == NULL) {
+ perror (outfname);
+ return (-1);
+ }
+ if (binmode_f == TRUE) {
+#if defined(__OS2__) && (defined(__IBMC__) || defined(__IBMCPP__))
+ if (freopen("","wb",stdout) == NULL)
+ return (-1);
+#else
+ setbinmode(stdout);
+#endif
+ }
+ }
+ if (binmode_f == TRUE)
+#if defined(__OS2__) && (defined(__IBMC__) || defined(__IBMCPP__))
+ if (freopen("","rb",fin) == NULL)
+ return (-1);
+#else
+ setbinmode(fin);
+#endif
+ setvbuffer(fin, (char *) stdibuf, IOBUF_SIZE);
+ if (nop_f)
+ noconvert(fin);
+ else {
+ char *filename = NULL;
+ kanji_convert(fin);
+ if (nfiles > 1) filename = origfname;
+ if (guess_f) print_guessed_code(filename);
+ }
+ fclose(fin);
+#ifdef OVERWRITE
+ if (overwrite_f) {
+ struct stat sb;
+#if defined(MSDOS) && !defined(__MINGW32__) && !defined(__WIN32__) && !defined(__WATCOMC__) && !defined(__EMX__) && !defined(__OS2__) && !defined(__DJGPP__)
+ time_t tb[2];
+#else
+ struct utimbuf tb;
+#endif
+
+ fflush(stdout);
+ close(fd);
+ if (dup2(fd_backup, fileno(stdout)) < 0){
+ perror("dup2");
+ }
+ if (stat(origfname, &sb)) {
+ fprintf(stderr, "Can't stat %s\n", origfname);
+ }
+ /* $B%Q!<%_%C%7%g%s$rI|85(B */
+ if (chmod(outfname, sb.st_mode)) {
+ fprintf(stderr, "Can't set permission %s\n", outfname);
+ }
+
+ /* $B%?%$%`%9%?%s%W$rI|85(B */
+ if(preserve_time_f){
+#if defined(MSDOS) && !defined(__MINGW32__) && !defined(__WIN32__) && !defined(__WATCOMC__) && !defined(__EMX__) && !defined(__OS2__) && !defined(__DJGPP__)
+ tb[0] = tb[1] = sb.st_mtime;
+ if (utime(outfname, tb)) {
+ fprintf(stderr, "Can't set timestamp %s\n", outfname);
+ }
+#else
+ tb.actime = sb.st_atime;
+ tb.modtime = sb.st_mtime;
+ if (utime(outfname, &tb)) {
+ fprintf(stderr, "Can't set timestamp %s\n", outfname);
+ }
+#endif
+ }
+ if(backup_f){
+ char *backup_filename = get_backup_filename(backup_suffix, origfname);
+#ifdef MSDOS
+ unlink(backup_filename);
+#endif
+ if (rename(origfname, backup_filename)) {
+ perror(backup_filename);
+ fprintf(stderr, "Can't rename %s to %s\n",
+ origfname, backup_filename);
+ }
+ nkf_xfree(backup_filename);
+ }else{
+#ifdef MSDOS
+ if (unlink(origfname)){
+ perror(origfname);
+ }
+#endif
+ }
+ if (rename(outfname, origfname)) {
+ perror(origfname);
+ fprintf(stderr, "Can't rename %s to %s\n",
+ outfname, origfname);
+ }
+ nkf_xfree(outfname);
+ }
+#endif
+ }
+ }
+ if (is_argument_error)
+ return(-1);
+ }
+#ifdef EASYWIN /*Easy Win */
+ if (file_out_f == FALSE)
+ scanf("%d",&end_check);
+ else
+ fclose(stdout);
+#else /* for Other OS */
+ if (file_out_f == TRUE)
+ fclose(stdout);
+#endif /*Easy Win */
+ return (0);
+}
+#endif /* WIN32DLL */
diff --git a/jni/ruby/ext/nkf/nkf-utf8/nkf.h b/jni/ruby/ext/nkf/nkf-utf8/nkf.h
new file mode 100644
index 0000000..cd30376
--- /dev/null
+++ b/jni/ruby/ext/nkf/nkf-utf8/nkf.h
@@ -0,0 +1,189 @@
+/*
+ *
+ * nkf.h - Header file for nkf
+ *
+ */
+
+#ifndef NKF_H
+#define NKF_H
+
+/* Wrapper of configurations */
+
+#ifndef MIME_DECODE_DEFAULT
+#define MIME_DECODE_DEFAULT STRICT_MIME
+#endif
+#ifndef X0201_DEFAULT
+#define X0201_DEFAULT TRUE
+#endif
+
+#if DEFAULT_NEWLINE == 0x0D0A
+#elif DEFAULT_NEWLINE == 0x0D
+#else
+#define DEFAULT_NEWLINE 0x0A
+#endif
+#ifdef HELP_OUTPUT_STDERR
+#define HELP_OUTPUT stderr
+#else
+#define HELP_OUTPUT stdout
+#endif
+
+
+/* Compatibility definitions */
+
+#ifdef nkf_char
+#elif defined(INT_IS_SHORT)
+typedef long nkf_char;
+#define NKF_INT32_C(n) (n##L)
+#else
+typedef int nkf_char;
+#define NKF_INT32_C(n) (n)
+#endif
+
+#if (defined(__TURBOC__) || defined(_MSC_VER) || defined(LSI_C) || (defined(__WATCOMC__) && defined(__386__) && !defined(__LINUX__)) || defined(__MINGW32__) || defined(__EMX__) || defined(__MSDOS__) || defined(__WINDOWS__) || defined(__DOS__) || defined(__OS2__)) && !defined(MSDOS)
+#define MSDOS
+#if (defined(__Win32__) || defined(_WIN32)) && !defined(__WIN32__)
+#define __WIN32__
+#endif
+#endif
+
+#ifdef PERL_XS
+#undef OVERWRITE
+#endif
+
+#ifndef PERL_XS
+#include <stdio.h>
+#endif
+
+#include <stdlib.h>
+#include <string.h>
+
+#if defined(MSDOS) || defined(__OS2__)
+#include <fcntl.h>
+#include <io.h>
+#if defined(_MSC_VER) || defined(__WATCOMC__)
+#define mktemp _mktemp
+#endif
+#endif
+
+#ifdef MSDOS
+#ifdef LSI_C
+#define setbinmode(fp) fsetbin(fp)
+#elif defined(__DJGPP__)
+#include <libc/dosio.h>
+void setbinmode(FILE *fp)
+{
+ /* we do not use libc's setmode(), which changes COOKED/RAW mode in device. */
+ int fd, m;
+ fd = fileno(fp);
+ m = (__file_handle_modes[fd] & (~O_TEXT)) | O_BINARY;
+ __file_handle_set(fd, m);
+}
+#else /* Microsoft C, Turbo C */
+#define setbinmode(fp) setmode(fileno(fp), O_BINARY)
+#endif
+#else /* UNIX */
+#define setbinmode(fp) (void)(fp)
+#endif
+
+#ifdef _IOFBF /* SysV and MSDOS, Windows */
+#define setvbuffer(fp, buf, size) setvbuf(fp, buf, _IOFBF, size)
+#else /* BSD */
+#define setvbuffer(fp, buf, size) setbuffer(fp, buf, size)
+#endif
+
+/*Borland C++ 4.5 EasyWin*/
+#if defined(__TURBOC__) && defined(_Windows) && !defined(__WIN32__) /*Easy Win */
+#define EASYWIN
+#ifndef __WIN16__
+#define __WIN16__
+#endif
+#include <windows.h>
+#endif
+
+#ifdef OVERWRITE
+/* added by satoru@isoternet.org */
+#if defined(__EMX__)
+#include <sys/types.h>
+#endif
+#include <sys/stat.h>
+#if !defined(MSDOS) || defined(__DJGPP__) /* UNIX, djgpp */
+#include <unistd.h>
+#if defined(__WATCOMC__)
+#include <sys/utime.h>
+#else
+#include <utime.h>
+#endif
+#else /* defined(MSDOS) */
+#ifdef __WIN32__
+#ifdef __BORLANDC__ /* BCC32 */
+#include <utime.h>
+#else /* !defined(__BORLANDC__) */
+#include <sys/utime.h>
+#endif /* (__BORLANDC__) */
+#else /* !defined(__WIN32__) */
+#if defined(_MSC_VER) || defined(__MINGW32__) || defined(__WATCOMC__) || defined(__OS2__) || defined(__EMX__) || defined(__IBMC__) || defined(__IBMCPP__) /* VC++, MinGW, Watcom, emx+gcc, IBM VAC++ */
+#include <sys/utime.h>
+#elif defined(__TURBOC__) /* BCC */
+#include <utime.h>
+#elif defined(LSI_C) /* LSI C */
+#endif /* (__WIN32__) */
+#endif
+#endif
+#endif
+
+#if !defined(DEFAULT_CODE_JIS) && !defined(DEFAULT_CODE_SJIS) && \
+ !defined(DEFAULT_CODE_WINDOWS_31J) && !defined(DEFAULT_CODE_EUC) && \
+ !defined(DEFAULT_CODE_UTF8) && !defined(DEFAULT_CODE_LOCALE)
+#define DEFAULT_CODE_LOCALE
+#endif
+
+#ifdef DEFAULT_CODE_LOCALE
+
+#if defined(__WIN32__) /* not win32 should be posix */
+# ifndef HAVE_LOCALE_H
+# define HAVE_LOCALE_H
+# endif
+#elif defined(__OS2__)
+# undef HAVE_LANGINFO_H /* We do not use kLIBC's langinfo. */
+# ifndef HAVE_LOCALE_H
+# define HAVE_LOCALE_H
+# endif
+#elif defined(MSDOS)
+# ifndef HAVE_LOCALE_H
+# define HAVE_LOCALE_H
+# endif
+#elif defined(__BIONIC__) /* bionic doesn't have locale */
+#else
+# ifndef HAVE_LANGINFO_H
+# define HAVE_LANGINFO_H
+# endif
+# ifndef HAVE_LOCALE_H
+# define HAVE_LOCALE_H
+# endif
+#endif
+
+#ifdef HAVE_LANGINFO_H
+#include <langinfo.h>
+#endif
+#ifdef HAVE_LOCALE_H
+#include <locale.h>
+#endif
+
+#endif /* DEFAULT_CODE_LOCALE */
+
+#define FALSE 0
+#define TRUE 1
+
+#ifndef ARG_UNUSED
+#if defined(__GNUC__)
+# define ARG_UNUSED __attribute__ ((unused))
+#else
+# define ARG_UNUSED
+#endif
+#endif
+
+#ifdef WIN32DLL
+#include "nkf32.h"
+#endif
+
+#endif /* NKF_H */
diff --git a/jni/ruby/ext/nkf/nkf-utf8/utf8tbl.c b/jni/ruby/ext/nkf/nkf-utf8/utf8tbl.c
new file mode 100644
index 0000000..e493c6b
--- /dev/null
+++ b/jni/ruby/ext/nkf/nkf-utf8/utf8tbl.c
@@ -0,0 +1,14628 @@
+/*
+ * utf8tbl.c - Convertion Table for nkf
+ *
+ */
+
+#include "config.h"
+#include "utf8tbl.h"
+
+#ifdef UTF8_OUTPUT_ENABLE
+static const unsigned short euc_to_utf8_A1[] = {
+ 0x3000, 0x3001, 0x3002, 0xFF0C, 0xFF0E, 0x30FB, 0xFF1A,
+ 0xFF1B, 0xFF1F, 0xFF01, 0x309B, 0x309C, 0x00B4, 0xFF40, 0x00A8,
+ 0xFF3E, 0x203E, 0xFF3F, 0x30FD, 0x30FE, 0x309D, 0x309E, 0x3003,
+ 0x4EDD, 0x3005, 0x3006, 0x3007, 0x30FC, 0x2014, 0x2010, 0xFF0F,
+ 0xFF3C, 0x301C, 0x2016, 0xFF5C, 0x2026, 0x2025, 0x2018, 0x2019,
+ 0x201C, 0x201D, 0xFF08, 0xFF09, 0x3014, 0x3015, 0xFF3B, 0xFF3D,
+ 0xFF5B, 0xFF5D, 0x3008, 0x3009, 0x300A, 0x300B, 0x300C, 0x300D,
+ 0x300E, 0x300F, 0x3010, 0x3011, 0xFF0B, 0x2212, 0x00B1, 0x00D7,
+ 0x00F7, 0xFF1D, 0x2260, 0xFF1C, 0xFF1E, 0x2266, 0x2267, 0x221E,
+ 0x2234, 0x2642, 0x2640, 0x00B0, 0x2032, 0x2033, 0x2103, 0x00A5,
+ 0xFF04, 0x00A2, 0x00A3, 0xFF05, 0xFF03, 0xFF06, 0xFF0A, 0xFF20,
+ 0x00A7, 0x2606, 0x2605, 0x25CB, 0x25CF, 0x25CE, 0x25C7,
+};
+
+/* Microsoft UCS Mapping Compatible */
+static const unsigned short euc_to_utf8_A1_ms[] = {
+ 0x3000, 0x3001, 0x3002, 0xFF0C, 0xFF0E, 0x30FB, 0xFF1A,
+ 0xFF1B, 0xFF1F, 0xFF01, 0x309B, 0x309C, 0x00B4, 0xFF40, 0x00A8,
+ 0xFF3E, 0xFFE3, 0xFF3F, 0x30FD, 0x30FE, 0x309D, 0x309E, 0x3003,
+ 0x4EDD, 0x3005, 0x3006, 0x3007, 0x30FC, 0x2015, 0x2010, 0xFF0F,
+ 0xFF3C, 0xFF5E, 0x2225, 0xFF5C, 0x2026, 0x2025, 0x2018, 0x2019,
+ 0x201C, 0x201D, 0xFF08, 0xFF09, 0x3014, 0x3015, 0xFF3B, 0xFF3D,
+ 0xFF5B, 0xFF5D, 0x3008, 0x3009, 0x300A, 0x300B, 0x300C, 0x300D,
+ 0x300E, 0x300F, 0x3010, 0x3011, 0xFF0B, 0xFF0D, 0x00B1, 0x00D7,
+ 0x00F7, 0xFF1D, 0x2260, 0xFF1C, 0xFF1E, 0x2266, 0x2267, 0x221E,
+ 0x2234, 0x2642, 0x2640, 0x00B0, 0x2032, 0x2033, 0x2103, 0xFFE5,
+ 0xFF04, 0xFFE0, 0xFFE1, 0xFF05, 0xFF03, 0xFF06, 0xFF0A, 0xFF20,
+ 0x00A7, 0x2606, 0x2605, 0x25CB, 0x25CF, 0x25CE, 0x25C7,
+};
+static const unsigned short euc_to_utf8_A2[] = {
+ 0x25C6, 0x25A1, 0x25A0, 0x25B3, 0x25B2, 0x25BD, 0x25BC,
+ 0x203B, 0x3012, 0x2192, 0x2190, 0x2191, 0x2193, 0x3013, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0x2208, 0x220B, 0x2286, 0x2287, 0x2282, 0x2283,
+ 0x222A, 0x2229, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0x2227, 0x2228, 0x00AC, 0x21D2, 0x21D4, 0x2200,
+ 0x2203, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0x2220, 0x22A5, 0x2312, 0x2202,
+ 0x2207, 0x2261, 0x2252, 0x226A, 0x226B, 0x221A, 0x223D, 0x221D,
+ 0x2235, 0x222B, 0x222C, 0, 0, 0, 0, 0,
+ 0, 0, 0x212B, 0x2030, 0x266F, 0x266D, 0x266A, 0x2020,
+ 0x2021, 0x00B6, 0, 0, 0, 0, 0x25EF,
+};
+
+/* Microsoft UCS Mapping Compatible */
+static const unsigned short euc_to_utf8_A2_ms[] = {
+ 0x25C6, 0x25A1, 0x25A0, 0x25B3, 0x25B2, 0x25BD, 0x25BC,
+ 0x203B, 0x3012, 0x2192, 0x2190, 0x2191, 0x2193, 0x3013, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0x2208, 0x220B, 0x2286, 0x2287, 0x2282, 0x2283,
+ 0x222A, 0x2229, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0x2227, 0x2228, 0xFFE2, 0x21D2, 0x21D4, 0x2200,
+ 0x2203, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0x2220, 0x22A5, 0x2312, 0x2202,
+ 0x2207, 0x2261, 0x2252, 0x226A, 0x226B, 0x221A, 0x223D, 0x221D,
+ 0x2235, 0x222B, 0x222C, 0, 0, 0, 0, 0,
+ 0, 0, 0x212B, 0x2030, 0x266F, 0x266D, 0x266A, 0x2020,
+ 0x2021, 0x00B6, 0, 0, 0, 0, 0x25EF,
+};
+static const unsigned short euc_to_utf8_A2_x0213[] = {
+ 0x25C6, 0x25A1, 0x25A0, 0x25B3, 0x25B2, 0x25BD, 0x25BC,
+ 0x203B, 0x3012, 0x2192, 0x2190, 0x2191, 0x2193, 0x3013, 0xFF07,
+ 0xFF02, 0xFF0D, 0xFF5E, 0x3033, 0x3034, 0x3035, 0x303B, 0x303C,
+ 0x30FF, 0x309F, 0x2208, 0x220B, 0x2286, 0x2287, 0x2282, 0x2283,
+ 0x222A, 0x2229, 0x2284, 0x2285, 0x228A, 0x228B, 0x2209, 0x2205,
+ 0x2305, 0x2306, 0x2227, 0x2228, 0x00AC, 0x21D2, 0x21D4, 0x2200,
+ 0x2203, 0x2295, 0x2296, 0x2297, 0x2225, 0x2226, 0xFF5F, 0xFF60,
+ 0x3018, 0x3019, 0x3016, 0x3017, 0x2220, 0x22A5, 0x2312, 0x2202,
+ 0x2207, 0x2261, 0x2252, 0x226A, 0x226B, 0x221A, 0x223D, 0x221D,
+ 0x2235, 0x222B, 0x222C, 0x2262, 0x2243, 0x2245, 0x2248, 0x2276,
+ 0x2277, 0x2194, 0x212B, 0x2030, 0x266F, 0x266D, 0x266A, 0x2020,
+ 0x2021, 0x00B6, 0x266E, 0x266B, 0x266C, 0x2669, 0x25EF,
+};
+static const unsigned short euc_to_utf8_A3[] = {
+ 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0xFF10, 0xFF11, 0xFF12, 0xFF13, 0xFF14, 0xFF15, 0xFF16, 0xFF17,
+ 0xFF18, 0xFF19, 0, 0, 0, 0, 0, 0,
+ 0, 0xFF21, 0xFF22, 0xFF23, 0xFF24, 0xFF25, 0xFF26, 0xFF27,
+ 0xFF28, 0xFF29, 0xFF2A, 0xFF2B, 0xFF2C, 0xFF2D, 0xFF2E, 0xFF2F,
+ 0xFF30, 0xFF31, 0xFF32, 0xFF33, 0xFF34, 0xFF35, 0xFF36, 0xFF37,
+ 0xFF38, 0xFF39, 0xFF3A, 0, 0, 0, 0, 0,
+ 0, 0xFF41, 0xFF42, 0xFF43, 0xFF44, 0xFF45, 0xFF46, 0xFF47,
+ 0xFF48, 0xFF49, 0xFF4A, 0xFF4B, 0xFF4C, 0xFF4D, 0xFF4E, 0xFF4F,
+ 0xFF50, 0xFF51, 0xFF52, 0xFF53, 0xFF54, 0xFF55, 0xFF56, 0xFF57,
+ 0xFF58, 0xFF59, 0xFF5A, 0, 0, 0, 0,
+};
+static const unsigned short euc_to_utf8_A3_x0213[] = {
+ 0x25B7, 0x25B6, 0x25C1, 0x25C0, 0x2197, 0x2198, 0x2196,
+ 0x2199, 0x21C4, 0x21E8, 0x21E6, 0x21E7, 0x21E9, 0x2934, 0x2935,
+ 0xFF10, 0xFF11, 0xFF12, 0xFF13, 0xFF14, 0xFF15, 0xFF16, 0xFF17,
+ 0xFF18, 0xFF19, 0x29BF, 0x25C9, 0x303D, 0xFE46, 0xFE45, 0x25E6,
+ 0x2022, 0xFF21, 0xFF22, 0xFF23, 0xFF24, 0xFF25, 0xFF26, 0xFF27,
+ 0xFF28, 0xFF29, 0xFF2A, 0xFF2B, 0xFF2C, 0xFF2D, 0xFF2E, 0xFF2F,
+ 0xFF30, 0xFF31, 0xFF32, 0xFF33, 0xFF34, 0xFF35, 0xFF36, 0xFF37,
+ 0xFF38, 0xFF39, 0xFF3A, 0x2213, 0x2135, 0x210F, 0x33CB, 0x2113,
+ 0x2127, 0xFF41, 0xFF42, 0xFF43, 0xFF44, 0xFF45, 0xFF46, 0xFF47,
+ 0xFF48, 0xFF49, 0xFF4A, 0xFF4B, 0xFF4C, 0xFF4D, 0xFF4E, 0xFF4F,
+ 0xFF50, 0xFF51, 0xFF52, 0xFF53, 0xFF54, 0xFF55, 0xFF56, 0xFF57,
+ 0xFF58, 0xFF59, 0xFF5A, 0x30A0, 0x2013, 0x29FA, 0x29FB,
+};
+static const unsigned short euc_to_utf8_A4[] = {
+ 0x3041, 0x3042, 0x3043, 0x3044, 0x3045, 0x3046, 0x3047,
+ 0x3048, 0x3049, 0x304A, 0x304B, 0x304C, 0x304D, 0x304E, 0x304F,
+ 0x3050, 0x3051, 0x3052, 0x3053, 0x3054, 0x3055, 0x3056, 0x3057,
+ 0x3058, 0x3059, 0x305A, 0x305B, 0x305C, 0x305D, 0x305E, 0x305F,
+ 0x3060, 0x3061, 0x3062, 0x3063, 0x3064, 0x3065, 0x3066, 0x3067,
+ 0x3068, 0x3069, 0x306A, 0x306B, 0x306C, 0x306D, 0x306E, 0x306F,
+ 0x3070, 0x3071, 0x3072, 0x3073, 0x3074, 0x3075, 0x3076, 0x3077,
+ 0x3078, 0x3079, 0x307A, 0x307B, 0x307C, 0x307D, 0x307E, 0x307F,
+ 0x3080, 0x3081, 0x3082, 0x3083, 0x3084, 0x3085, 0x3086, 0x3087,
+ 0x3088, 0x3089, 0x308A, 0x308B, 0x308C, 0x308D, 0x308E, 0x308F,
+ 0x3090, 0x3091, 0x3092, 0x3093, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0,
+};
+static const unsigned short euc_to_utf8_A4_x0213[] = {
+ 0x3041, 0x3042, 0x3043, 0x3044, 0x3045, 0x3046, 0x3047,
+ 0x3048, 0x3049, 0x304A, 0x304B, 0x304C, 0x304D, 0x304E, 0x304F,
+ 0x3050, 0x3051, 0x3052, 0x3053, 0x3054, 0x3055, 0x3056, 0x3057,
+ 0x3058, 0x3059, 0x305A, 0x305B, 0x305C, 0x305D, 0x305E, 0x305F,
+ 0x3060, 0x3061, 0x3062, 0x3063, 0x3064, 0x3065, 0x3066, 0x3067,
+ 0x3068, 0x3069, 0x306A, 0x306B, 0x306C, 0x306D, 0x306E, 0x306F,
+ 0x3070, 0x3071, 0x3072, 0x3073, 0x3074, 0x3075, 0x3076, 0x3077,
+ 0x3078, 0x3079, 0x307A, 0x307B, 0x307C, 0x307D, 0x307E, 0x307F,
+ 0x3080, 0x3081, 0x3082, 0x3083, 0x3084, 0x3085, 0x3086, 0x3087,
+ 0x3088, 0x3089, 0x308A, 0x308B, 0x308C, 0x308D, 0x308E, 0x308F,
+ 0x3090, 0x3091, 0x3092, 0x3093, 0x3094, 0x3095, 0x3096, /*0x304B*/ 0x309A,
+ /*0x304D*/ 0x309A, /*0x304F*/ 0x309A, /*0x3051*/ 0x309A, /*0x3053*/ 0x309A, 0, 0, 0,
+};
+static const unsigned short euc_to_utf8_A5[] = {
+ 0x30A1, 0x30A2, 0x30A3, 0x30A4, 0x30A5, 0x30A6, 0x30A7,
+ 0x30A8, 0x30A9, 0x30AA, 0x30AB, 0x30AC, 0x30AD, 0x30AE, 0x30AF,
+ 0x30B0, 0x30B1, 0x30B2, 0x30B3, 0x30B4, 0x30B5, 0x30B6, 0x30B7,
+ 0x30B8, 0x30B9, 0x30BA, 0x30BB, 0x30BC, 0x30BD, 0x30BE, 0x30BF,
+ 0x30C0, 0x30C1, 0x30C2, 0x30C3, 0x30C4, 0x30C5, 0x30C6, 0x30C7,
+ 0x30C8, 0x30C9, 0x30CA, 0x30CB, 0x30CC, 0x30CD, 0x30CE, 0x30CF,
+ 0x30D0, 0x30D1, 0x30D2, 0x30D3, 0x30D4, 0x30D5, 0x30D6, 0x30D7,
+ 0x30D8, 0x30D9, 0x30DA, 0x30DB, 0x30DC, 0x30DD, 0x30DE, 0x30DF,
+ 0x30E0, 0x30E1, 0x30E2, 0x30E3, 0x30E4, 0x30E5, 0x30E6, 0x30E7,
+ 0x30E8, 0x30E9, 0x30EA, 0x30EB, 0x30EC, 0x30ED, 0x30EE, 0x30EF,
+ 0x30F0, 0x30F1, 0x30F2, 0x30F3, 0x30F4, 0x30F5, 0x30F6, 0,
+ 0, 0, 0, 0, 0, 0, 0,
+};
+static const unsigned short euc_to_utf8_A5_x0213[] = {
+ 0x30A1, 0x30A2, 0x30A3, 0x30A4, 0x30A5, 0x30A6, 0x30A7,
+ 0x30A8, 0x30A9, 0x30AA, 0x30AB, 0x30AC, 0x30AD, 0x30AE, 0x30AF,
+ 0x30B0, 0x30B1, 0x30B2, 0x30B3, 0x30B4, 0x30B5, 0x30B6, 0x30B7,
+ 0x30B8, 0x30B9, 0x30BA, 0x30BB, 0x30BC, 0x30BD, 0x30BE, 0x30BF,
+ 0x30C0, 0x30C1, 0x30C2, 0x30C3, 0x30C4, 0x30C5, 0x30C6, 0x30C7,
+ 0x30C8, 0x30C9, 0x30CA, 0x30CB, 0x30CC, 0x30CD, 0x30CE, 0x30CF,
+ 0x30D0, 0x30D1, 0x30D2, 0x30D3, 0x30D4, 0x30D5, 0x30D6, 0x30D7,
+ 0x30D8, 0x30D9, 0x30DA, 0x30DB, 0x30DC, 0x30DD, 0x30DE, 0x30DF,
+ 0x30E0, 0x30E1, 0x30E2, 0x30E3, 0x30E4, 0x30E5, 0x30E6, 0x30E7,
+ 0x30E8, 0x30E9, 0x30EA, 0x30EB, 0x30EC, 0x30ED, 0x30EE, 0x30EF,
+ 0x30F0, 0x30F1, 0x30F2, 0x30F3, 0x30F4, 0x30F5, 0x30F6, /*0x30AB*/ 0x309A,
+ /*0x30AD*/ 0x309A, /*0x30AF*/ 0x309A, /*0x30B1*/ 0x309A, /*0x30B3*/ 0x309A, /*0x30BB*/ 0x309A, /*0x30C4*/ 0x309A, /*0x30C8*/ 0x309A,
+};
+static const unsigned short euc_to_utf8_A6[] = {
+ 0x0391, 0x0392, 0x0393, 0x0394, 0x0395, 0x0396, 0x0397,
+ 0x0398, 0x0399, 0x039A, 0x039B, 0x039C, 0x039D, 0x039E, 0x039F,
+ 0x03A0, 0x03A1, 0x03A3, 0x03A4, 0x03A5, 0x03A6, 0x03A7, 0x03A8,
+ 0x03A9, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0x03B1, 0x03B2, 0x03B3, 0x03B4, 0x03B5, 0x03B6, 0x03B7,
+ 0x03B8, 0x03B9, 0x03BA, 0x03BB, 0x03BC, 0x03BD, 0x03BE, 0x03BF,
+ 0x03C0, 0x03C1, 0x03C3, 0x03C4, 0x03C5, 0x03C6, 0x03C7, 0x03C8,
+ 0x03C9, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0,
+};
+static const unsigned short euc_to_utf8_A6_x0213[] = {
+ 0x0391, 0x0392, 0x0393, 0x0394, 0x0395, 0x0396, 0x0397,
+ 0x0398, 0x0399, 0x039A, 0x039B, 0x039C, 0x039D, 0x039E, 0x039F,
+ 0x03A0, 0x03A1, 0x03A3, 0x03A4, 0x03A5, 0x03A6, 0x03A7, 0x03A8,
+ 0x03A9, 0x2664, 0x2660, 0x2662, 0x2666, 0x2661, 0x2665, 0x2667,
+ 0x2663, 0x03B1, 0x03B2, 0x03B3, 0x03B4, 0x03B5, 0x03B6, 0x03B7,
+ 0x03B8, 0x03B9, 0x03BA, 0x03BB, 0x03BC, 0x03BD, 0x03BE, 0x03BF,
+ 0x03C0, 0x03C1, 0x03C3, 0x03C4, 0x03C5, 0x03C6, 0x03C7, 0x03C8,
+ 0x03C9, 0x03C2, 0x24F5, 0x24F6, 0x24F7, 0x24F8, 0x24F9, 0x24FA,
+ 0x24FB, 0x24FC, 0x24FD, 0x24FE, 0x2616, 0x2617, 0x3020, 0x260E,
+ 0x2600, 0x2601, 0x2602, 0x2603, 0x2668, 0x25B1, 0x31F0, 0x31F1,
+ 0x31F2, 0x31F3, 0x31F4, 0x31F5, 0x31F6, 0x31F7, 0x31F8, 0x31F9,
+ /*0x31F7*/ 0x309A, 0x31FA, 0x31FB, 0x31FC, 0x31FD, 0x31FE, 0x31FF,
+};
+static const unsigned short euc_to_utf8_A7[] = {
+ 0x0410, 0x0411, 0x0412, 0x0413, 0x0414, 0x0415, 0x0401,
+ 0x0416, 0x0417, 0x0418, 0x0419, 0x041A, 0x041B, 0x041C, 0x041D,
+ 0x041E, 0x041F, 0x0420, 0x0421, 0x0422, 0x0423, 0x0424, 0x0425,
+ 0x0426, 0x0427, 0x0428, 0x0429, 0x042A, 0x042B, 0x042C, 0x042D,
+ 0x042E, 0x042F, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0x0430, 0x0431, 0x0432, 0x0433, 0x0434, 0x0435, 0x0451,
+ 0x0436, 0x0437, 0x0438, 0x0439, 0x043A, 0x043B, 0x043C, 0x043D,
+ 0x043E, 0x043F, 0x0440, 0x0441, 0x0442, 0x0443, 0x0444, 0x0445,
+ 0x0446, 0x0447, 0x0448, 0x0449, 0x044A, 0x044B, 0x044C, 0x044D,
+ 0x044E, 0x044F, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0,
+};
+static const unsigned short euc_to_utf8_A7_x0213[] = {
+ 0x0410, 0x0411, 0x0412, 0x0413, 0x0414, 0x0415, 0x0401,
+ 0x0416, 0x0417, 0x0418, 0x0419, 0x041A, 0x041B, 0x041C, 0x041D,
+ 0x041E, 0x041F, 0x0420, 0x0421, 0x0422, 0x0423, 0x0424, 0x0425,
+ 0x0426, 0x0427, 0x0428, 0x0429, 0x042A, 0x042B, 0x042C, 0x042D,
+ 0x042E, 0x042F, 0x23BE, 0x23BF, 0x23C0, 0x23C1, 0x23C2, 0x23C3,
+ 0x23C4, 0x23C5, 0x23C6, 0x23C7, 0x23C8, 0x23C9, 0x23CA, 0x23CB,
+ 0x23CC, 0x0430, 0x0431, 0x0432, 0x0433, 0x0434, 0x0435, 0x0451,
+ 0x0436, 0x0437, 0x0438, 0x0439, 0x043A, 0x043B, 0x043C, 0x043D,
+ 0x043E, 0x043F, 0x0440, 0x0441, 0x0442, 0x0443, 0x0444, 0x0445,
+ 0x0446, 0x0447, 0x0448, 0x0449, 0x044A, 0x044B, 0x044C, 0x044D,
+ 0x044E, 0x044F, 0x30F7, 0x30F8, 0x30F9, 0x30FA, 0x22DA, 0x22DB,
+ 0x2153, 0x2154, 0x2155, 0x2713, 0x2318, 0x2423, 0x23CE,
+};
+static const unsigned short euc_to_utf8_A8[] = {
+ 0x2500, 0x2502, 0x250C, 0x2510, 0x2518, 0x2514, 0x251C,
+ 0x252C, 0x2524, 0x2534, 0x253C, 0x2501, 0x2503, 0x250F, 0x2513,
+ 0x251B, 0x2517, 0x2523, 0x2533, 0x252B, 0x253B, 0x254B, 0x2520,
+ 0x252F, 0x2528, 0x2537, 0x253F, 0x251D, 0x2530, 0x2525, 0x2538,
+ 0x2542, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0,
+};
+static const unsigned short euc_to_utf8_A8_x0213[] = {
+ 0x2500, 0x2502, 0x250C, 0x2510, 0x2518, 0x2514, 0x251C,
+ 0x252C, 0x2524, 0x2534, 0x253C, 0x2501, 0x2503, 0x250F, 0x2513,
+ 0x251B, 0x2517, 0x2523, 0x2533, 0x252B, 0x253B, 0x254B, 0x2520,
+ 0x252F, 0x2528, 0x2537, 0x253F, 0x251D, 0x2530, 0x2525, 0x2538,
+ 0x2542, 0x3251, 0x3252, 0x3253, 0x3254, 0x3255, 0x3256, 0x3257,
+ 0x3258, 0x3259, 0x325A, 0x325B, 0x325C, 0x325D, 0x325E, 0x325F,
+ 0x32B1, 0x32B2, 0x32B3, 0x32B4, 0x32B5, 0x32B6, 0x32B7, 0x32B8,
+ 0x32B9, 0x32BA, 0x32BB, 0x32BC, 0x32BD, 0x32BE, 0x32BF, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0x25D0,
+ 0x25D1, 0x25D2, 0x25D3, 0x203C, 0x2047, 0x2048, 0x2049, 0x01CD,
+ 0x01CE, 0x01D0, 0x1E3E, 0x1E3F, 0x01F8, 0x01F9, 0x01D1, 0x01D2,
+ 0x01D4, 0x01D6, 0x01D8, 0x01DA, 0x01DC, 0, 0,
+};
+static const unsigned short euc_to_utf8_A9[] = {
+ 0x2460, 0x2461, 0x2462, 0x2463, 0x2464, 0x2465, 0x2466,
+ 0x2467, 0x2468, 0x2469, 0x246A, 0x246B, 0x246C, 0x246D, 0x246E,
+ 0x246F, 0x2470, 0x2471, 0x2472, 0x2473, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0x2474,
+ 0x2475, 0x2476, 0x2477, 0x2478, 0x2479, 0x247A, 0x247B, 0x247C,
+ 0x247D, 0x247E, 0x247F, 0x2480, 0x2481, 0x2482, 0x2483, 0x2484,
+ 0x2485, 0x2486, 0x2487, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0x2776, 0x2777, 0x2778,
+ 0x2779, 0x277A, 0x277B, 0x277C, 0x277D, 0x277E, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0x2488, 0x2489, 0x248A, 0x248B, 0x248C, 0x248D,
+ 0x248E, 0x248F, 0x2490, 0, 0, 0, 0,
+};
+static const unsigned short euc_to_utf8_A9_x0213[] = {
+ 0x20AC, 0x00A0, 0x00A1, 0x00A4, 0x00A6, 0x00A9, 0x00AA,
+ 0x00AB, 0x00AD, 0x00AE, 0x00AF, 0x00B2, 0x00B3, 0x00B7, 0x00B8,
+ 0x00B9, 0x00BA, 0x00BB, 0x00BC, 0x00BD, 0x00BE, 0x00BF, 0x00C0,
+ 0x00C1, 0x00C2, 0x00C3, 0x00C4, 0x00C5, 0x00C6, 0x00C7, 0x00C8,
+ 0x00C9, 0x00CA, 0x00CB, 0x00CC, 0x00CD, 0x00CE, 0x00CF, 0x00D0,
+ 0x00D1, 0x00D2, 0x00D3, 0x00D4, 0x00D5, 0x00D6, 0x00D8, 0x00D9,
+ 0x00DA, 0x00DB, 0x00DC, 0x00DD, 0x00DE, 0x00DF, 0x00E0, 0x00E1,
+ 0x00E2, 0x00E3, 0x00E4, 0x00E5, 0x00E6, 0x00E7, 0x00E8, 0x00E9,
+ 0x00EA, 0x00EB, 0x00EC, 0x00ED, 0x00EE, 0x00EF, 0x00F0, 0x00F1,
+ 0x00F2, 0x00F3, 0x00F4, 0x00F5, 0x00F6, 0x00F8, 0x00F9, 0x00FA,
+ 0x00FB, 0x00FC, 0x00FD, 0x00FE, 0x00FF, 0x0100, 0x012A, 0x016A,
+ 0x0112, 0x014C, 0x0101, 0x012B, 0x016B, 0x0113, 0x014D,
+};
+static const unsigned short euc_to_utf8_AA[] = {
+ 0x2160, 0x2161, 0x2162, 0x2163, 0x2164, 0x2165, 0x2166,
+ 0x2167, 0x2168, 0x2169, 0x216A, 0x216B, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0x2170, 0x2171, 0x2172,
+ 0x2173, 0x2174, 0x2175, 0x2176, 0x2177, 0x2178, 0x2179, 0x217A,
+ 0x217B, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0x249C, 0x249D, 0x249E,
+ 0x249F, 0x24A0, 0x24A1, 0x24A2, 0x24A3, 0x24A4, 0x24A5, 0x24A6,
+ 0x24A7, 0x24A8, 0x24A9, 0x24AA, 0x24AB, 0x24AC, 0x24AD, 0x24AE,
+ 0x24AF, 0x24B0, 0x24B1, 0x24B2, 0x24B3, 0x24B4, 0x24B5, 0,
+ 0, 0, 0, 0, 0, 0, 0,
+};
+static const unsigned short euc_to_utf8_AA_x0213[] = {
+ 0x0104, 0x02D8, 0x0141, 0x013D, 0x015A, 0x0160, 0x015E,
+ 0x0164, 0x0179, 0x017D, 0x017B, 0x0105, 0x02DB, 0x0142, 0x013E,
+ 0x015B, 0x02C7, 0x0161, 0x015F, 0x0165, 0x017A, 0x02DD, 0x017E,
+ 0x017C, 0x0154, 0x0102, 0x0139, 0x0106, 0x010C, 0x0118, 0x011A,
+ 0x010E, 0x0143, 0x0147, 0x0150, 0x0158, 0x016E, 0x0170, 0x0162,
+ 0x0155, 0x0103, 0x013A, 0x0107, 0x010D, 0x0119, 0x011B, 0x010F,
+ 0x0111, 0x0144, 0x0148, 0x0151, 0x0159, 0x016F, 0x0171, 0x0163,
+ 0x02D9, 0x0108, 0x011C, 0x0124, 0x0134, 0x015C, 0x016C, 0x0109,
+ 0x011D, 0x0125, 0x0135, 0x015D, 0x016D, 0x0271, 0x028B, 0x027E,
+ 0x0283, 0x0292, 0x026C, 0x026E, 0x0279, 0x0288, 0x0256, 0x0273,
+ 0x027D, 0x0282, 0x0290, 0x027B, 0x026D, 0x025F, 0x0272, 0x029D,
+ 0x028E, 0x0261, 0x014B, 0x0270, 0x0281, 0x0127, 0x0295,
+};
+static const unsigned short euc_to_utf8_AB[] = {
+ 0x339C, 0x339F, 0x339D, 0x33A0, 0x33A4, 0, 0x33A1,
+ 0x33A5, 0x339E, 0x33A2, 0x338E, 0, 0x338F, 0x33C4, 0x3396,
+ 0x3397, 0x2113, 0x3398, 0x33B3, 0x33B2, 0x33B1, 0x33B0, 0x2109,
+ 0x33D4, 0x33CB, 0x3390, 0x3385, 0x3386, 0x3387, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0x2116, 0x33CD, 0x2121, 0,
+};
+static const unsigned short euc_to_utf8_AB_x0213[] = {
+ 0x0294, 0x0266, 0x0298, 0x01C2, 0x0253, 0x0257, 0x0284,
+ 0x0260, 0x0193, 0x0153, 0x0152, 0x0268, 0x0289, 0x0258, 0x0275,
+ 0x0259, 0x025C, 0x025E, 0x0250, 0x026F, 0x028A, 0x0264, 0x028C,
+ 0x0254, 0x0251, 0x0252, 0x028D, 0x0265, 0x02A2, 0x02A1, 0x0255,
+ 0x0291, 0x027A, 0x0267, 0x025A, /*0x00E6*/ 0x0300, 0x01FD, 0x1F70, 0x1F71,
+ /*0x0254*/ 0x0300, /*0x0254*/ 0x0301, /*0x028C*/ 0x0300, /*0x028C*/ 0x0301, /*0x0259*/ 0x0300, /*0x0259*/ 0x0301, /*0x025A*/ 0x0300, /*0x025A*/ 0x0301,
+ 0x1F72, 0x1F73, 0x0361, 0x02C8, 0x02CC, 0x02D0, 0x02D1, 0x0306,
+ 0x203F, 0x030B, /*0*/ 0x0301, 0x0304, /*0*/ 0x0300, 0x030F, 0x030C, 0x0302,
+ /*0*/ 0x02E5, 0x02E6, 0x02E7, 0x02E8, /*0*/ 0x02E9, /*0x02E9*/ 0x02E5, /*0x02E5*/ 0x02E9, 0x0325,
+ 0x032C, 0x0339, 0x031C, 0x031F, 0x0320, 0x0308, 0x033D, 0x0329,
+ 0x032F, 0x02DE, 0x0324, 0x0330, 0x033C, 0x0334, 0x031D, 0x031E,
+ 0x0318, 0x0319, 0x032A, 0x033A, 0x033B, 0x0303, 0x031A,
+};
+static const unsigned short euc_to_utf8_AC[] = {
+ 0x2664, 0x2667, 0x2661, 0x2662, 0x2660, 0x2663, 0x2665,
+ 0x2666, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0x3020, 0x260E, 0x3004,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0x261E, 0x261C, 0x261D, 0x261F, 0x21C6, 0x21C4, 0x21C5,
+ 0, 0x21E8, 0x21E6, 0x21E7, 0x21E9, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0,
+};
+static const unsigned short euc_to_utf8_AC_mac[] = {
+ 0x2664, 0x2667, 0x2661, 0x2662, 0x2660, 0x2663, 0x2665,
+ 0x2666, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0x3020, 0x260E, 0x3004,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0x261E, 0x261C, 0x261D, 0x261F, 0x21C6, 0x21C4, 0x21C5,
+ 0, 0x21E8, 0x21E6, 0x21E7, 0x21E9, 0x2192, 0x2190, 0x2191,
+ 0x2193, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0,
+};
+static const unsigned short euc_to_utf8_AC_x0213[] = {
+ 0x2776, 0x2777, 0x2778, 0x2779, 0x277A, 0x277B, 0x277C,
+ 0x277D, 0x277E, 0x277F, 0x24EB, 0x24EC, 0x24ED, 0x24EE, 0x24EF,
+ 0x24F0, 0x24F1, 0x24F2, 0x24F3, 0x24F4, 0x2170, 0x2171, 0x2172,
+ 0x2173, 0x2174, 0x2175, 0x2176, 0x2177, 0x2178, 0x2179, 0x217A,
+ 0x217B, 0x24D0, 0x24D1, 0x24D2, 0x24D3, 0x24D4, 0x24D5, 0x24D6,
+ 0x24D7, 0x24D8, 0x24D9, 0x24DA, 0x24DB, 0x24DC, 0x24DD, 0x24DE,
+ 0x24DF, 0x24E0, 0x24E1, 0x24E2, 0x24E3, 0x24E4, 0x24E5, 0x24E6,
+ 0x24E7, 0x24E8, 0x24E9, 0x32D0, 0x32D1, 0x32D2, 0x32D3, 0x32D4,
+ 0x32D5, 0x32D6, 0x32D7, 0x32D8, 0x32D9, 0x32DA, 0x32DB, 0x32DC,
+ 0x32DD, 0x32DE, 0x32DF, 0x32E0, 0x32E1, 0x32E2, 0x32E3, 0x32FA,
+ 0x32E9, 0x32E5, 0x32ED, 0x32EC, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0x2051, 0x2042,
+};
+static const unsigned short euc_to_utf8_AD[] = {
+ 0x2460, 0x2461, 0x2462, 0x2463, 0x2464, 0x2465, 0x2466,
+ 0x2467, 0x2468, 0x2469, 0x246A, 0x246B, 0x246C, 0x246D, 0x246E,
+ 0x246F, 0x2470, 0x2471, 0x2472, 0x2473, 0x2160, 0x2161, 0x2162,
+ 0x2163, 0x2164, 0x2165, 0x2166, 0x2167, 0x2168, 0x2169, 0,
+ 0x3349, 0x3314, 0x3322, 0x334D, 0x3318, 0x3327, 0x3303, 0x3336,
+ 0x3351, 0x3357, 0x330D, 0x3326, 0x3323, 0x332B, 0x334A, 0x333B,
+ 0x339C, 0x339D, 0x339E, 0x338E, 0x338F, 0x33C4, 0x33A1, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0x337B,
+ 0x301D, 0x301F, 0x2116, 0x33CD, 0x2121, 0x32A4, 0x32A5, 0x32A6,
+ 0x32A7, 0x32A8, 0x3231, 0x3232, 0x3239, 0x337E, 0x337D, 0x337C,
+ 0x2252, 0x2261, 0x222B, 0x222E, 0x2211, 0x221A, 0x22A5, 0x2220,
+ 0x221F, 0x22BF, 0x2235, 0x2229, 0x222A, 0, 0x3299,
+};
+static const unsigned short euc_to_utf8_AD_mac[] = {
+ 0x65E5, 0x6708, 0x706B, 0x6C34, 0x6728, 0x91D1, 0x571F,
+ 0x796D, 0x795D, 0x81EA, 0x81F3, 0x3239, 0x547C, 0x3231, 0x8CC7,
+ 0x540D, 0x3232, 0x5B66, 0x8CA1, 0x793E, 0x7279, 0x76E3, 0x4F01,
+ 0x5354, 0x52B4, 0x2165, 0x2166, 0x2167, 0x2168, 0x2169, 0,
+ 0x3349, 0x3314, 0x3322, 0x334D, 0x3318, 0x3327, 0x3303, 0x3336,
+ 0x3351, 0x3357, 0x330D, 0x3326, 0x3323, 0x332B, 0x334A, 0x333B,
+ 0x339C, 0x339D, 0x339E, 0x338E, 0x338F, 0x33C4, 0x33A1, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0x337B,
+ 0x301D, 0x301F, 0x2116, 0x33CD, 0x2121, 0x32A4, 0x32A5, 0x32A6,
+ 0x32A7, 0x32A8, 0x3231, 0x3232, 0x3239, 0x337E, 0x337D, 0x337C,
+ 0x2252, 0x5927, 0x5C0F, 0x32A4, 0x32A5, 0x32A6, 0x32A7, 0x32A8,
+ 0x533B, 0x8CA1, 0x512A, 0x52B4, 0x5370, 0x63A7, 0x79D8,
+};
+static const unsigned short euc_to_utf8_AD_x0213[] = {
+ 0x2460, 0x2461, 0x2462, 0x2463, 0x2464, 0x2465, 0x2466,
+ 0x2467, 0x2468, 0x2469, 0x246A, 0x246B, 0x246C, 0x246D, 0x246E,
+ 0x246F, 0x2470, 0x2471, 0x2472, 0x2473, 0x2160, 0x2161, 0x2162,
+ 0x2163, 0x2164, 0x2165, 0x2166, 0x2167, 0x2168, 0x2169, 0x216A,
+ 0x3349, 0x3314, 0x3322, 0x334D, 0x3318, 0x3327, 0x3303, 0x3336,
+ 0x3351, 0x3357, 0x330D, 0x3326, 0x3323, 0x332B, 0x334A, 0x333B,
+ 0x339C, 0x339D, 0x339E, 0x338E, 0x338F, 0x33C4, 0x33A1, 0x216B,
+ 0, 0, 0, 0, 0, 0, 0, 0x337B,
+ 0x301D, 0x301F, 0x2116, 0x33CD, 0x2121, 0x32A4, 0x32A5, 0x32A6,
+ 0x32A7, 0x32A8, 0x3231, 0x3232, 0x3239, 0x337E, 0x337D, 0x337C,
+ 0x2252, 0x2261, 0x222B, 0x222E, 0x2211, 0x221A, 0x22A5, 0x2220,
+ 0x221F, 0x22BF, 0x2235, 0x2229, 0x222A, 0x2756, 0x261E,
+};
+static const unsigned short euc_to_utf8_AE[] = {
+ 0x3349, 0x3322, 0x334D, 0x3314, 0x3316, 0x3305, 0x3333,
+ 0x334E, 0x3303, 0x3336, 0x3318, 0x3315, 0x3327, 0x3351, 0x334A,
+ 0x3339, 0x3357, 0x330D, 0x3342, 0x3323, 0x3326, 0x333B, 0x332B,
+ 0, 0, 0, 0, 0, 0, 0, 0x3300,
+ 0x331E, 0x332A, 0x3331, 0x3347, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0x337E,
+ 0x337D, 0x337C, 0x337B, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0x337F, 0, 0,
+};
+static const unsigned short euc_to_utf8_AE_x0213[] = {
+ 0x4FF1, 0xD840 /*0xDC0B*/, 0x3402, 0x4E28, 0x4E2F, 0x4E30, 0x4E8D,
+ 0x4EE1, 0x4EFD, 0x4EFF, 0x4F03, 0x4F0B, 0x4F60, 0x4F48, 0x4F49,
+ 0x4F56, 0x4F5F, 0x4F6A, 0x4F6C, 0x4F7E, 0x4F8A, 0x4F94, 0x4F97,
+ 0xFA30, 0x4FC9, 0x4FE0, 0x5001, 0x5002, 0x500E, 0x5018, 0x5027,
+ 0x502E, 0x5040, 0x503B, 0x5041, 0x5094, 0x50CC, 0x50F2, 0x50D0,
+ 0x50E6, 0xFA31, 0x5106, 0x5103, 0x510B, 0x511E, 0x5135, 0x514A,
+ 0xFA32, 0x5155, 0x5157, 0x34B5, 0x519D, 0x51C3, 0x51CA, 0x51DE,
+ 0x51E2, 0x51EE, 0x5201, 0x34DB, 0x5213, 0x5215, 0x5249, 0x5257,
+ 0x5261, 0x5293, 0x52C8, 0xFA33, 0x52CC, 0x52D0, 0x52D6, 0x52DB,
+ 0xFA34, 0x52F0, 0x52FB, 0x5300, 0x5307, 0x531C, 0xFA35, 0x5361,
+ 0x5363, 0x537D, 0x5393, 0x539D, 0x53B2, 0x5412, 0x5427, 0x544D,
+ 0x549C, 0x546B, 0x5474, 0x547F, 0x5488, 0x5496, 0x54A1,
+};
+static const unsigned short euc_to_utf8_AF[] = {
+ 0x222E, 0x221F, 0x22BF, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0x301D, 0x301F, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0x3094, 0, 0x30F7, 0x30F8, 0x30F9, 0x30FA, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0,
+};
+static const unsigned short euc_to_utf8_AF_x0213[] = {
+ 0x54A9, 0x54C6, 0x54FF, 0x550E, 0x552B, 0x5535, 0x5550,
+ 0x555E, 0x5581, 0x5586, 0x558E, 0xFA36, 0x55AD, 0x55CE, 0xFA37,
+ 0x5608, 0x560E, 0x563B, 0x5649, 0x5676, 0x5666, 0xFA38, 0x566F,
+ 0x5671, 0x5672, 0x5699, 0x569E, 0x56A9, 0x56AC, 0x56B3, 0x56C9,
+ 0x56CA, 0x570A, 0xD844 /*0xDE3D*/, 0x5721, 0x572F, 0x5733, 0x5734, 0x5770,
+ 0x5777, 0x577C, 0x579C, 0xFA0F, 0xD844 /*0xDF1B*/, 0x57B8, 0x57C7, 0x57C8,
+ 0x57CF, 0x57E4, 0x57ED, 0x57F5, 0x57F6, 0x57FF, 0x5809, 0xFA10,
+ 0x5861, 0x5864, 0xFA39, 0x587C, 0x5889, 0x589E, 0xFA3A, 0x58A9,
+ 0xD845 /*0xDC6E*/, 0x58D2, 0x58CE, 0x58D4, 0x58DA, 0x58E0, 0x58E9, 0x590C,
+ 0x8641, 0x595D, 0x596D, 0x598B, 0x5992, 0x59A4, 0x59C3, 0x59D2,
+ 0x59DD, 0x5A13, 0x5A23, 0x5A67, 0x5A6D, 0x5A77, 0x5A7E, 0x5A84,
+ 0x5A9E, 0x5AA7, 0x5AC4, 0xD846 /*0xDCBD*/, 0x5B19, 0x5B25, 0x525D,
+};
+static const unsigned short euc_to_utf8_B0[] = {
+ 0x4E9C, 0x5516, 0x5A03, 0x963F, 0x54C0, 0x611B, 0x6328,
+ 0x59F6, 0x9022, 0x8475, 0x831C, 0x7A50, 0x60AA, 0x63E1, 0x6E25,
+ 0x65ED, 0x8466, 0x82A6, 0x9BF5, 0x6893, 0x5727, 0x65A1, 0x6271,
+ 0x5B9B, 0x59D0, 0x867B, 0x98F4, 0x7D62, 0x7DBE, 0x9B8E, 0x6216,
+ 0x7C9F, 0x88B7, 0x5B89, 0x5EB5, 0x6309, 0x6697, 0x6848, 0x95C7,
+ 0x978D, 0x674F, 0x4EE5, 0x4F0A, 0x4F4D, 0x4F9D, 0x5049, 0x56F2,
+ 0x5937, 0x59D4, 0x5A01, 0x5C09, 0x60DF, 0x610F, 0x6170, 0x6613,
+ 0x6905, 0x70BA, 0x754F, 0x7570, 0x79FB, 0x7DAD, 0x7DEF, 0x80C3,
+ 0x840E, 0x8863, 0x8B02, 0x9055, 0x907A, 0x533B, 0x4E95, 0x4EA5,
+ 0x57DF, 0x80B2, 0x90C1, 0x78EF, 0x4E00, 0x58F1, 0x6EA2, 0x9038,
+ 0x7A32, 0x8328, 0x828B, 0x9C2F, 0x5141, 0x5370, 0x54BD, 0x54E1,
+ 0x56E0, 0x59FB, 0x5F15, 0x98F2, 0x6DEB, 0x80E4, 0x852D,
+};
+static const unsigned short euc_to_utf8_B1[] = {
+ 0x9662, 0x9670, 0x96A0, 0x97FB, 0x540B, 0x53F3, 0x5B87,
+ 0x70CF, 0x7FBD, 0x8FC2, 0x96E8, 0x536F, 0x9D5C, 0x7ABA, 0x4E11,
+ 0x7893, 0x81FC, 0x6E26, 0x5618, 0x5504, 0x6B1D, 0x851A, 0x9C3B,
+ 0x59E5, 0x53A9, 0x6D66, 0x74DC, 0x958F, 0x5642, 0x4E91, 0x904B,
+ 0x96F2, 0x834F, 0x990C, 0x53E1, 0x55B6, 0x5B30, 0x5F71, 0x6620,
+ 0x66F3, 0x6804, 0x6C38, 0x6CF3, 0x6D29, 0x745B, 0x76C8, 0x7A4E,
+ 0x9834, 0x82F1, 0x885B, 0x8A60, 0x92ED, 0x6DB2, 0x75AB, 0x76CA,
+ 0x99C5, 0x60A6, 0x8B01, 0x8D8A, 0x95B2, 0x698E, 0x53AD, 0x5186,
+ 0x5712, 0x5830, 0x5944, 0x5BB4, 0x5EF6, 0x6028, 0x63A9, 0x63F4,
+ 0x6CBF, 0x6F14, 0x708E, 0x7114, 0x7159, 0x71D5, 0x733F, 0x7E01,
+ 0x8276, 0x82D1, 0x8597, 0x9060, 0x925B, 0x9D1B, 0x5869, 0x65BC,
+ 0x6C5A, 0x7525, 0x51F9, 0x592E, 0x5965, 0x5F80, 0x5FDC,
+};
+static const unsigned short euc_to_utf8_B2[] = {
+ 0x62BC, 0x65FA, 0x6A2A, 0x6B27, 0x6BB4, 0x738B, 0x7FC1,
+ 0x8956, 0x9D2C, 0x9D0E, 0x9EC4, 0x5CA1, 0x6C96, 0x837B, 0x5104,
+ 0x5C4B, 0x61B6, 0x81C6, 0x6876, 0x7261, 0x4E59, 0x4FFA, 0x5378,
+ 0x6069, 0x6E29, 0x7A4F, 0x97F3, 0x4E0B, 0x5316, 0x4EEE, 0x4F55,
+ 0x4F3D, 0x4FA1, 0x4F73, 0x52A0, 0x53EF, 0x5609, 0x590F, 0x5AC1,
+ 0x5BB6, 0x5BE1, 0x79D1, 0x6687, 0x679C, 0x67B6, 0x6B4C, 0x6CB3,
+ 0x706B, 0x73C2, 0x798D, 0x79BE, 0x7A3C, 0x7B87, 0x82B1, 0x82DB,
+ 0x8304, 0x8377, 0x83EF, 0x83D3, 0x8766, 0x8AB2, 0x5629, 0x8CA8,
+ 0x8FE6, 0x904E, 0x971E, 0x868A, 0x4FC4, 0x5CE8, 0x6211, 0x7259,
+ 0x753B, 0x81E5, 0x82BD, 0x86FE, 0x8CC0, 0x96C5, 0x9913, 0x99D5,
+ 0x4ECB, 0x4F1A, 0x89E3, 0x56DE, 0x584A, 0x58CA, 0x5EFB, 0x5FEB,
+ 0x602A, 0x6094, 0x6062, 0x61D0, 0x6212, 0x62D0, 0x6539,
+};
+static const unsigned short euc_to_utf8_B3[] = {
+ 0x9B41, 0x6666, 0x68B0, 0x6D77, 0x7070, 0x754C, 0x7686,
+ 0x7D75, 0x82A5, 0x87F9, 0x958B, 0x968E, 0x8C9D, 0x51F1, 0x52BE,
+ 0x5916, 0x54B3, 0x5BB3, 0x5D16, 0x6168, 0x6982, 0x6DAF, 0x788D,
+ 0x84CB, 0x8857, 0x8A72, 0x93A7, 0x9AB8, 0x6D6C, 0x99A8, 0x86D9,
+ 0x57A3, 0x67FF, 0x86CE, 0x920E, 0x5283, 0x5687, 0x5404, 0x5ED3,
+ 0x62E1, 0x64B9, 0x683C, 0x6838, 0x6BBB, 0x7372, 0x78BA, 0x7A6B,
+ 0x899A, 0x89D2, 0x8D6B, 0x8F03, 0x90ED, 0x95A3, 0x9694, 0x9769,
+ 0x5B66, 0x5CB3, 0x697D, 0x984D, 0x984E, 0x639B, 0x7B20, 0x6A2B,
+ 0x6A7F, 0x68B6, 0x9C0D, 0x6F5F, 0x5272, 0x559D, 0x6070, 0x62EC,
+ 0x6D3B, 0x6E07, 0x6ED1, 0x845B, 0x8910, 0x8F44, 0x4E14, 0x9C39,
+ 0x53F6, 0x691B, 0x6A3A, 0x9784, 0x682A, 0x515C, 0x7AC3, 0x84B2,
+ 0x91DC, 0x938C, 0x565B, 0x9D28, 0x6822, 0x8305, 0x8431,
+};
+static const unsigned short euc_to_utf8_B4[] = {
+ 0x7CA5, 0x5208, 0x82C5, 0x74E6, 0x4E7E, 0x4F83, 0x51A0,
+ 0x5BD2, 0x520A, 0x52D8, 0x52E7, 0x5DFB, 0x559A, 0x582A, 0x59E6,
+ 0x5B8C, 0x5B98, 0x5BDB, 0x5E72, 0x5E79, 0x60A3, 0x611F, 0x6163,
+ 0x61BE, 0x63DB, 0x6562, 0x67D1, 0x6853, 0x68FA, 0x6B3E, 0x6B53,
+ 0x6C57, 0x6F22, 0x6F97, 0x6F45, 0x74B0, 0x7518, 0x76E3, 0x770B,
+ 0x7AFF, 0x7BA1, 0x7C21, 0x7DE9, 0x7F36, 0x7FF0, 0x809D, 0x8266,
+ 0x839E, 0x89B3, 0x8ACC, 0x8CAB, 0x9084, 0x9451, 0x9593, 0x9591,
+ 0x95A2, 0x9665, 0x97D3, 0x9928, 0x8218, 0x4E38, 0x542B, 0x5CB8,
+ 0x5DCC, 0x73A9, 0x764C, 0x773C, 0x5CA9, 0x7FEB, 0x8D0B, 0x96C1,
+ 0x9811, 0x9854, 0x9858, 0x4F01, 0x4F0E, 0x5371, 0x559C, 0x5668,
+ 0x57FA, 0x5947, 0x5B09, 0x5BC4, 0x5C90, 0x5E0C, 0x5E7E, 0x5FCC,
+ 0x63EE, 0x673A, 0x65D7, 0x65E2, 0x671F, 0x68CB, 0x68C4,
+};
+static const unsigned short euc_to_utf8_B5[] = {
+ 0x6A5F, 0x5E30, 0x6BC5, 0x6C17, 0x6C7D, 0x757F, 0x7948,
+ 0x5B63, 0x7A00, 0x7D00, 0x5FBD, 0x898F, 0x8A18, 0x8CB4, 0x8D77,
+ 0x8ECC, 0x8F1D, 0x98E2, 0x9A0E, 0x9B3C, 0x4E80, 0x507D, 0x5100,
+ 0x5993, 0x5B9C, 0x622F, 0x6280, 0x64EC, 0x6B3A, 0x72A0, 0x7591,
+ 0x7947, 0x7FA9, 0x87FB, 0x8ABC, 0x8B70, 0x63AC, 0x83CA, 0x97A0,
+ 0x5409, 0x5403, 0x55AB, 0x6854, 0x6A58, 0x8A70, 0x7827, 0x6775,
+ 0x9ECD, 0x5374, 0x5BA2, 0x811A, 0x8650, 0x9006, 0x4E18, 0x4E45,
+ 0x4EC7, 0x4F11, 0x53CA, 0x5438, 0x5BAE, 0x5F13, 0x6025, 0x6551,
+ 0x673D, 0x6C42, 0x6C72, 0x6CE3, 0x7078, 0x7403, 0x7A76, 0x7AAE,
+ 0x7B08, 0x7D1A, 0x7CFE, 0x7D66, 0x65E7, 0x725B, 0x53BB, 0x5C45,
+ 0x5DE8, 0x62D2, 0x62E0, 0x6319, 0x6E20, 0x865A, 0x8A31, 0x8DDD,
+ 0x92F8, 0x6F01, 0x79A6, 0x9B5A, 0x4EA8, 0x4EAB, 0x4EAC,
+};
+static const unsigned short euc_to_utf8_B6[] = {
+ 0x4F9B, 0x4FA0, 0x50D1, 0x5147, 0x7AF6, 0x5171, 0x51F6,
+ 0x5354, 0x5321, 0x537F, 0x53EB, 0x55AC, 0x5883, 0x5CE1, 0x5F37,
+ 0x5F4A, 0x602F, 0x6050, 0x606D, 0x631F, 0x6559, 0x6A4B, 0x6CC1,
+ 0x72C2, 0x72ED, 0x77EF, 0x80F8, 0x8105, 0x8208, 0x854E, 0x90F7,
+ 0x93E1, 0x97FF, 0x9957, 0x9A5A, 0x4EF0, 0x51DD, 0x5C2D, 0x6681,
+ 0x696D, 0x5C40, 0x66F2, 0x6975, 0x7389, 0x6850, 0x7C81, 0x50C5,
+ 0x52E4, 0x5747, 0x5DFE, 0x9326, 0x65A4, 0x6B23, 0x6B3D, 0x7434,
+ 0x7981, 0x79BD, 0x7B4B, 0x7DCA, 0x82B9, 0x83CC, 0x887F, 0x895F,
+ 0x8B39, 0x8FD1, 0x91D1, 0x541F, 0x9280, 0x4E5D, 0x5036, 0x53E5,
+ 0x533A, 0x72D7, 0x7396, 0x77E9, 0x82E6, 0x8EAF, 0x99C6, 0x99C8,
+ 0x99D2, 0x5177, 0x611A, 0x865E, 0x55B0, 0x7A7A, 0x5076, 0x5BD3,
+ 0x9047, 0x9685, 0x4E32, 0x6ADB, 0x91E7, 0x5C51, 0x5C48,
+};
+static const unsigned short euc_to_utf8_B7[] = {
+ 0x6398, 0x7A9F, 0x6C93, 0x9774, 0x8F61, 0x7AAA, 0x718A,
+ 0x9688, 0x7C82, 0x6817, 0x7E70, 0x6851, 0x936C, 0x52F2, 0x541B,
+ 0x85AB, 0x8A13, 0x7FA4, 0x8ECD, 0x90E1, 0x5366, 0x8888, 0x7941,
+ 0x4FC2, 0x50BE, 0x5211, 0x5144, 0x5553, 0x572D, 0x73EA, 0x578B,
+ 0x5951, 0x5F62, 0x5F84, 0x6075, 0x6176, 0x6167, 0x61A9, 0x63B2,
+ 0x643A, 0x656C, 0x666F, 0x6842, 0x6E13, 0x7566, 0x7A3D, 0x7CFB,
+ 0x7D4C, 0x7D99, 0x7E4B, 0x7F6B, 0x830E, 0x834A, 0x86CD, 0x8A08,
+ 0x8A63, 0x8B66, 0x8EFD, 0x981A, 0x9D8F, 0x82B8, 0x8FCE, 0x9BE8,
+ 0x5287, 0x621F, 0x6483, 0x6FC0, 0x9699, 0x6841, 0x5091, 0x6B20,
+ 0x6C7A, 0x6F54, 0x7A74, 0x7D50, 0x8840, 0x8A23, 0x6708, 0x4EF6,
+ 0x5039, 0x5026, 0x5065, 0x517C, 0x5238, 0x5263, 0x55A7, 0x570F,
+ 0x5805, 0x5ACC, 0x5EFA, 0x61B2, 0x61F8, 0x62F3, 0x6372,
+};
+static const unsigned short euc_to_utf8_B8[] = {
+ 0x691C, 0x6A29, 0x727D, 0x72AC, 0x732E, 0x7814, 0x786F,
+ 0x7D79, 0x770C, 0x80A9, 0x898B, 0x8B19, 0x8CE2, 0x8ED2, 0x9063,
+ 0x9375, 0x967A, 0x9855, 0x9A13, 0x9E78, 0x5143, 0x539F, 0x53B3,
+ 0x5E7B, 0x5F26, 0x6E1B, 0x6E90, 0x7384, 0x73FE, 0x7D43, 0x8237,
+ 0x8A00, 0x8AFA, 0x9650, 0x4E4E, 0x500B, 0x53E4, 0x547C, 0x56FA,
+ 0x59D1, 0x5B64, 0x5DF1, 0x5EAB, 0x5F27, 0x6238, 0x6545, 0x67AF,
+ 0x6E56, 0x72D0, 0x7CCA, 0x88B4, 0x80A1, 0x80E1, 0x83F0, 0x864E,
+ 0x8A87, 0x8DE8, 0x9237, 0x96C7, 0x9867, 0x9F13, 0x4E94, 0x4E92,
+ 0x4F0D, 0x5348, 0x5449, 0x543E, 0x5A2F, 0x5F8C, 0x5FA1, 0x609F,
+ 0x68A7, 0x6A8E, 0x745A, 0x7881, 0x8A9E, 0x8AA4, 0x8B77, 0x9190,
+ 0x4E5E, 0x9BC9, 0x4EA4, 0x4F7C, 0x4FAF, 0x5019, 0x5016, 0x5149,
+ 0x516C, 0x529F, 0x52B9, 0x52FE, 0x539A, 0x53E3, 0x5411,
+};
+static const unsigned short euc_to_utf8_B9[] = {
+ 0x540E, 0x5589, 0x5751, 0x57A2, 0x597D, 0x5B54, 0x5B5D,
+ 0x5B8F, 0x5DE5, 0x5DE7, 0x5DF7, 0x5E78, 0x5E83, 0x5E9A, 0x5EB7,
+ 0x5F18, 0x6052, 0x614C, 0x6297, 0x62D8, 0x63A7, 0x653B, 0x6602,
+ 0x6643, 0x66F4, 0x676D, 0x6821, 0x6897, 0x69CB, 0x6C5F, 0x6D2A,
+ 0x6D69, 0x6E2F, 0x6E9D, 0x7532, 0x7687, 0x786C, 0x7A3F, 0x7CE0,
+ 0x7D05, 0x7D18, 0x7D5E, 0x7DB1, 0x8015, 0x8003, 0x80AF, 0x80B1,
+ 0x8154, 0x818F, 0x822A, 0x8352, 0x884C, 0x8861, 0x8B1B, 0x8CA2,
+ 0x8CFC, 0x90CA, 0x9175, 0x9271, 0x783F, 0x92FC, 0x95A4, 0x964D,
+ 0x9805, 0x9999, 0x9AD8, 0x9D3B, 0x525B, 0x52AB, 0x53F7, 0x5408,
+ 0x58D5, 0x62F7, 0x6FE0, 0x8C6A, 0x8F5F, 0x9EB9, 0x514B, 0x523B,
+ 0x544A, 0x56FD, 0x7A40, 0x9177, 0x9D60, 0x9ED2, 0x7344, 0x6F09,
+ 0x8170, 0x7511, 0x5FFD, 0x60DA, 0x9AA8, 0x72DB, 0x8FBC,
+};
+static const unsigned short euc_to_utf8_BA[] = {
+ 0x6B64, 0x9803, 0x4ECA, 0x56F0, 0x5764, 0x58BE, 0x5A5A,
+ 0x6068, 0x61C7, 0x660F, 0x6606, 0x6839, 0x68B1, 0x6DF7, 0x75D5,
+ 0x7D3A, 0x826E, 0x9B42, 0x4E9B, 0x4F50, 0x53C9, 0x5506, 0x5D6F,
+ 0x5DE6, 0x5DEE, 0x67FB, 0x6C99, 0x7473, 0x7802, 0x8A50, 0x9396,
+ 0x88DF, 0x5750, 0x5EA7, 0x632B, 0x50B5, 0x50AC, 0x518D, 0x6700,
+ 0x54C9, 0x585E, 0x59BB, 0x5BB0, 0x5F69, 0x624D, 0x63A1, 0x683D,
+ 0x6B73, 0x6E08, 0x707D, 0x91C7, 0x7280, 0x7815, 0x7826, 0x796D,
+ 0x658E, 0x7D30, 0x83DC, 0x88C1, 0x8F09, 0x969B, 0x5264, 0x5728,
+ 0x6750, 0x7F6A, 0x8CA1, 0x51B4, 0x5742, 0x962A, 0x583A, 0x698A,
+ 0x80B4, 0x54B2, 0x5D0E, 0x57FC, 0x7895, 0x9DFA, 0x4F5C, 0x524A,
+ 0x548B, 0x643E, 0x6628, 0x6714, 0x67F5, 0x7A84, 0x7B56, 0x7D22,
+ 0x932F, 0x685C, 0x9BAD, 0x7B39, 0x5319, 0x518A, 0x5237,
+};
+static const unsigned short euc_to_utf8_BB[] = {
+ 0x5BDF, 0x62F6, 0x64AE, 0x64E6, 0x672D, 0x6BBA, 0x85A9,
+ 0x96D1, 0x7690, 0x9BD6, 0x634C, 0x9306, 0x9BAB, 0x76BF, 0x6652,
+ 0x4E09, 0x5098, 0x53C2, 0x5C71, 0x60E8, 0x6492, 0x6563, 0x685F,
+ 0x71E6, 0x73CA, 0x7523, 0x7B97, 0x7E82, 0x8695, 0x8B83, 0x8CDB,
+ 0x9178, 0x9910, 0x65AC, 0x66AB, 0x6B8B, 0x4ED5, 0x4ED4, 0x4F3A,
+ 0x4F7F, 0x523A, 0x53F8, 0x53F2, 0x55E3, 0x56DB, 0x58EB, 0x59CB,
+ 0x59C9, 0x59FF, 0x5B50, 0x5C4D, 0x5E02, 0x5E2B, 0x5FD7, 0x601D,
+ 0x6307, 0x652F, 0x5B5C, 0x65AF, 0x65BD, 0x65E8, 0x679D, 0x6B62,
+ 0x6B7B, 0x6C0F, 0x7345, 0x7949, 0x79C1, 0x7CF8, 0x7D19, 0x7D2B,
+ 0x80A2, 0x8102, 0x81F3, 0x8996, 0x8A5E, 0x8A69, 0x8A66, 0x8A8C,
+ 0x8AEE, 0x8CC7, 0x8CDC, 0x96CC, 0x98FC, 0x6B6F, 0x4E8B, 0x4F3C,
+ 0x4F8D, 0x5150, 0x5B57, 0x5BFA, 0x6148, 0x6301, 0x6642,
+};
+static const unsigned short euc_to_utf8_BC[] = {
+ 0x6B21, 0x6ECB, 0x6CBB, 0x723E, 0x74BD, 0x75D4, 0x78C1,
+ 0x793A, 0x800C, 0x8033, 0x81EA, 0x8494, 0x8F9E, 0x6C50, 0x9E7F,
+ 0x5F0F, 0x8B58, 0x9D2B, 0x7AFA, 0x8EF8, 0x5B8D, 0x96EB, 0x4E03,
+ 0x53F1, 0x57F7, 0x5931, 0x5AC9, 0x5BA4, 0x6089, 0x6E7F, 0x6F06,
+ 0x75BE, 0x8CEA, 0x5B9F, 0x8500, 0x7BE0, 0x5072, 0x67F4, 0x829D,
+ 0x5C61, 0x854A, 0x7E1E, 0x820E, 0x5199, 0x5C04, 0x6368, 0x8D66,
+ 0x659C, 0x716E, 0x793E, 0x7D17, 0x8005, 0x8B1D, 0x8ECA, 0x906E,
+ 0x86C7, 0x90AA, 0x501F, 0x52FA, 0x5C3A, 0x6753, 0x707C, 0x7235,
+ 0x914C, 0x91C8, 0x932B, 0x82E5, 0x5BC2, 0x5F31, 0x60F9, 0x4E3B,
+ 0x53D6, 0x5B88, 0x624B, 0x6731, 0x6B8A, 0x72E9, 0x73E0, 0x7A2E,
+ 0x816B, 0x8DA3, 0x9152, 0x9996, 0x5112, 0x53D7, 0x546A, 0x5BFF,
+ 0x6388, 0x6A39, 0x7DAC, 0x9700, 0x56DA, 0x53CE, 0x5468,
+};
+static const unsigned short euc_to_utf8_BD[] = {
+ 0x5B97, 0x5C31, 0x5DDE, 0x4FEE, 0x6101, 0x62FE, 0x6D32,
+ 0x79C0, 0x79CB, 0x7D42, 0x7E4D, 0x7FD2, 0x81ED, 0x821F, 0x8490,
+ 0x8846, 0x8972, 0x8B90, 0x8E74, 0x8F2F, 0x9031, 0x914B, 0x916C,
+ 0x96C6, 0x919C, 0x4EC0, 0x4F4F, 0x5145, 0x5341, 0x5F93, 0x620E,
+ 0x67D4, 0x6C41, 0x6E0B, 0x7363, 0x7E26, 0x91CD, 0x9283, 0x53D4,
+ 0x5919, 0x5BBF, 0x6DD1, 0x795D, 0x7E2E, 0x7C9B, 0x587E, 0x719F,
+ 0x51FA, 0x8853, 0x8FF0, 0x4FCA, 0x5CFB, 0x6625, 0x77AC, 0x7AE3,
+ 0x821C, 0x99FF, 0x51C6, 0x5FAA, 0x65EC, 0x696F, 0x6B89, 0x6DF3,
+ 0x6E96, 0x6F64, 0x76FE, 0x7D14, 0x5DE1, 0x9075, 0x9187, 0x9806,
+ 0x51E6, 0x521D, 0x6240, 0x6691, 0x66D9, 0x6E1A, 0x5EB6, 0x7DD2,
+ 0x7F72, 0x66F8, 0x85AF, 0x85F7, 0x8AF8, 0x52A9, 0x53D9, 0x5973,
+ 0x5E8F, 0x5F90, 0x6055, 0x92E4, 0x9664, 0x50B7, 0x511F,
+};
+static const unsigned short euc_to_utf8_BE[] = {
+ 0x52DD, 0x5320, 0x5347, 0x53EC, 0x54E8, 0x5546, 0x5531,
+ 0x5617, 0x5968, 0x59BE, 0x5A3C, 0x5BB5, 0x5C06, 0x5C0F, 0x5C11,
+ 0x5C1A, 0x5E84, 0x5E8A, 0x5EE0, 0x5F70, 0x627F, 0x6284, 0x62DB,
+ 0x638C, 0x6377, 0x6607, 0x660C, 0x662D, 0x6676, 0x677E, 0x68A2,
+ 0x6A1F, 0x6A35, 0x6CBC, 0x6D88, 0x6E09, 0x6E58, 0x713C, 0x7126,
+ 0x7167, 0x75C7, 0x7701, 0x785D, 0x7901, 0x7965, 0x79F0, 0x7AE0,
+ 0x7B11, 0x7CA7, 0x7D39, 0x8096, 0x83D6, 0x848B, 0x8549, 0x885D,
+ 0x88F3, 0x8A1F, 0x8A3C, 0x8A54, 0x8A73, 0x8C61, 0x8CDE, 0x91A4,
+ 0x9266, 0x937E, 0x9418, 0x969C, 0x9798, 0x4E0A, 0x4E08, 0x4E1E,
+ 0x4E57, 0x5197, 0x5270, 0x57CE, 0x5834, 0x58CC, 0x5B22, 0x5E38,
+ 0x60C5, 0x64FE, 0x6761, 0x6756, 0x6D44, 0x72B6, 0x7573, 0x7A63,
+ 0x84B8, 0x8B72, 0x91B8, 0x9320, 0x5631, 0x57F4, 0x98FE,
+};
+static const unsigned short euc_to_utf8_BF[] = {
+ 0x62ED, 0x690D, 0x6B96, 0x71ED, 0x7E54, 0x8077, 0x8272,
+ 0x89E6, 0x98DF, 0x8755, 0x8FB1, 0x5C3B, 0x4F38, 0x4FE1, 0x4FB5,
+ 0x5507, 0x5A20, 0x5BDD, 0x5BE9, 0x5FC3, 0x614E, 0x632F, 0x65B0,
+ 0x664B, 0x68EE, 0x699B, 0x6D78, 0x6DF1, 0x7533, 0x75B9, 0x771F,
+ 0x795E, 0x79E6, 0x7D33, 0x81E3, 0x82AF, 0x85AA, 0x89AA, 0x8A3A,
+ 0x8EAB, 0x8F9B, 0x9032, 0x91DD, 0x9707, 0x4EBA, 0x4EC1, 0x5203,
+ 0x5875, 0x58EC, 0x5C0B, 0x751A, 0x5C3D, 0x814E, 0x8A0A, 0x8FC5,
+ 0x9663, 0x976D, 0x7B25, 0x8ACF, 0x9808, 0x9162, 0x56F3, 0x53A8,
+ 0x9017, 0x5439, 0x5782, 0x5E25, 0x63A8, 0x6C34, 0x708A, 0x7761,
+ 0x7C8B, 0x7FE0, 0x8870, 0x9042, 0x9154, 0x9310, 0x9318, 0x968F,
+ 0x745E, 0x9AC4, 0x5D07, 0x5D69, 0x6570, 0x67A2, 0x8DA8, 0x96DB,
+ 0x636E, 0x6749, 0x6919, 0x83C5, 0x9817, 0x96C0, 0x88FE,
+};
+static const unsigned short euc_to_utf8_C0[] = {
+ 0x6F84, 0x647A, 0x5BF8, 0x4E16, 0x702C, 0x755D, 0x662F,
+ 0x51C4, 0x5236, 0x52E2, 0x59D3, 0x5F81, 0x6027, 0x6210, 0x653F,
+ 0x6574, 0x661F, 0x6674, 0x68F2, 0x6816, 0x6B63, 0x6E05, 0x7272,
+ 0x751F, 0x76DB, 0x7CBE, 0x8056, 0x58F0, 0x88FD, 0x897F, 0x8AA0,
+ 0x8A93, 0x8ACB, 0x901D, 0x9192, 0x9752, 0x9759, 0x6589, 0x7A0E,
+ 0x8106, 0x96BB, 0x5E2D, 0x60DC, 0x621A, 0x65A5, 0x6614, 0x6790,
+ 0x77F3, 0x7A4D, 0x7C4D, 0x7E3E, 0x810A, 0x8CAC, 0x8D64, 0x8DE1,
+ 0x8E5F, 0x78A9, 0x5207, 0x62D9, 0x63A5, 0x6442, 0x6298, 0x8A2D,
+ 0x7A83, 0x7BC0, 0x8AAC, 0x96EA, 0x7D76, 0x820C, 0x8749, 0x4ED9,
+ 0x5148, 0x5343, 0x5360, 0x5BA3, 0x5C02, 0x5C16, 0x5DDD, 0x6226,
+ 0x6247, 0x64B0, 0x6813, 0x6834, 0x6CC9, 0x6D45, 0x6D17, 0x67D3,
+ 0x6F5C, 0x714E, 0x717D, 0x65CB, 0x7A7F, 0x7BAD, 0x7DDA,
+};
+static const unsigned short euc_to_utf8_C1[] = {
+ 0x7E4A, 0x7FA8, 0x817A, 0x821B, 0x8239, 0x85A6, 0x8A6E,
+ 0x8CCE, 0x8DF5, 0x9078, 0x9077, 0x92AD, 0x9291, 0x9583, 0x9BAE,
+ 0x524D, 0x5584, 0x6F38, 0x7136, 0x5168, 0x7985, 0x7E55, 0x81B3,
+ 0x7CCE, 0x564C, 0x5851, 0x5CA8, 0x63AA, 0x66FE, 0x66FD, 0x695A,
+ 0x72D9, 0x758F, 0x758E, 0x790E, 0x7956, 0x79DF, 0x7C97, 0x7D20,
+ 0x7D44, 0x8607, 0x8A34, 0x963B, 0x9061, 0x9F20, 0x50E7, 0x5275,
+ 0x53CC, 0x53E2, 0x5009, 0x55AA, 0x58EE, 0x594F, 0x723D, 0x5B8B,
+ 0x5C64, 0x531D, 0x60E3, 0x60F3, 0x635C, 0x6383, 0x633F, 0x63BB,
+ 0x64CD, 0x65E9, 0x66F9, 0x5DE3, 0x69CD, 0x69FD, 0x6F15, 0x71E5,
+ 0x4E89, 0x75E9, 0x76F8, 0x7A93, 0x7CDF, 0x7DCF, 0x7D9C, 0x8061,
+ 0x8349, 0x8358, 0x846C, 0x84BC, 0x85FB, 0x88C5, 0x8D70, 0x9001,
+ 0x906D, 0x9397, 0x971C, 0x9A12, 0x50CF, 0x5897, 0x618E,
+};
+static const unsigned short euc_to_utf8_C2[] = {
+ 0x81D3, 0x8535, 0x8D08, 0x9020, 0x4FC3, 0x5074, 0x5247,
+ 0x5373, 0x606F, 0x6349, 0x675F, 0x6E2C, 0x8DB3, 0x901F, 0x4FD7,
+ 0x5C5E, 0x8CCA, 0x65CF, 0x7D9A, 0x5352, 0x8896, 0x5176, 0x63C3,
+ 0x5B58, 0x5B6B, 0x5C0A, 0x640D, 0x6751, 0x905C, 0x4ED6, 0x591A,
+ 0x592A, 0x6C70, 0x8A51, 0x553E, 0x5815, 0x59A5, 0x60F0, 0x6253,
+ 0x67C1, 0x8235, 0x6955, 0x9640, 0x99C4, 0x9A28, 0x4F53, 0x5806,
+ 0x5BFE, 0x8010, 0x5CB1, 0x5E2F, 0x5F85, 0x6020, 0x614B, 0x6234,
+ 0x66FF, 0x6CF0, 0x6EDE, 0x80CE, 0x817F, 0x82D4, 0x888B, 0x8CB8,
+ 0x9000, 0x902E, 0x968A, 0x9EDB, 0x9BDB, 0x4EE3, 0x53F0, 0x5927,
+ 0x7B2C, 0x918D, 0x984C, 0x9DF9, 0x6EDD, 0x7027, 0x5353, 0x5544,
+ 0x5B85, 0x6258, 0x629E, 0x62D3, 0x6CA2, 0x6FEF, 0x7422, 0x8A17,
+ 0x9438, 0x6FC1, 0x8AFE, 0x8338, 0x51E7, 0x86F8, 0x53EA,
+};
+static const unsigned short euc_to_utf8_C3[] = {
+ 0x53E9, 0x4F46, 0x9054, 0x8FB0, 0x596A, 0x8131, 0x5DFD,
+ 0x7AEA, 0x8FBF, 0x68DA, 0x8C37, 0x72F8, 0x9C48, 0x6A3D, 0x8AB0,
+ 0x4E39, 0x5358, 0x5606, 0x5766, 0x62C5, 0x63A2, 0x65E6, 0x6B4E,
+ 0x6DE1, 0x6E5B, 0x70AD, 0x77ED, 0x7AEF, 0x7BAA, 0x7DBB, 0x803D,
+ 0x80C6, 0x86CB, 0x8A95, 0x935B, 0x56E3, 0x58C7, 0x5F3E, 0x65AD,
+ 0x6696, 0x6A80, 0x6BB5, 0x7537, 0x8AC7, 0x5024, 0x77E5, 0x5730,
+ 0x5F1B, 0x6065, 0x667A, 0x6C60, 0x75F4, 0x7A1A, 0x7F6E, 0x81F4,
+ 0x8718, 0x9045, 0x99B3, 0x7BC9, 0x755C, 0x7AF9, 0x7B51, 0x84C4,
+ 0x9010, 0x79E9, 0x7A92, 0x8336, 0x5AE1, 0x7740, 0x4E2D, 0x4EF2,
+ 0x5B99, 0x5FE0, 0x62BD, 0x663C, 0x67F1, 0x6CE8, 0x866B, 0x8877,
+ 0x8A3B, 0x914E, 0x92F3, 0x99D0, 0x6A17, 0x7026, 0x732A, 0x82E7,
+ 0x8457, 0x8CAF, 0x4E01, 0x5146, 0x51CB, 0x558B, 0x5BF5,
+};
+static const unsigned short euc_to_utf8_C4[] = {
+ 0x5E16, 0x5E33, 0x5E81, 0x5F14, 0x5F35, 0x5F6B, 0x5FB4,
+ 0x61F2, 0x6311, 0x66A2, 0x671D, 0x6F6E, 0x7252, 0x753A, 0x773A,
+ 0x8074, 0x8139, 0x8178, 0x8776, 0x8ABF, 0x8ADC, 0x8D85, 0x8DF3,
+ 0x929A, 0x9577, 0x9802, 0x9CE5, 0x52C5, 0x6357, 0x76F4, 0x6715,
+ 0x6C88, 0x73CD, 0x8CC3, 0x93AE, 0x9673, 0x6D25, 0x589C, 0x690E,
+ 0x69CC, 0x8FFD, 0x939A, 0x75DB, 0x901A, 0x585A, 0x6802, 0x63B4,
+ 0x69FB, 0x4F43, 0x6F2C, 0x67D8, 0x8FBB, 0x8526, 0x7DB4, 0x9354,
+ 0x693F, 0x6F70, 0x576A, 0x58F7, 0x5B2C, 0x7D2C, 0x722A, 0x540A,
+ 0x91E3, 0x9DB4, 0x4EAD, 0x4F4E, 0x505C, 0x5075, 0x5243, 0x8C9E,
+ 0x5448, 0x5824, 0x5B9A, 0x5E1D, 0x5E95, 0x5EAD, 0x5EF7, 0x5F1F,
+ 0x608C, 0x62B5, 0x633A, 0x63D0, 0x68AF, 0x6C40, 0x7887, 0x798E,
+ 0x7A0B, 0x7DE0, 0x8247, 0x8A02, 0x8AE6, 0x8E44, 0x9013,
+};
+static const unsigned short euc_to_utf8_C5[] = {
+ 0x90B8, 0x912D, 0x91D8, 0x9F0E, 0x6CE5, 0x6458, 0x64E2,
+ 0x6575, 0x6EF4, 0x7684, 0x7B1B, 0x9069, 0x93D1, 0x6EBA, 0x54F2,
+ 0x5FB9, 0x64A4, 0x8F4D, 0x8FED, 0x9244, 0x5178, 0x586B, 0x5929,
+ 0x5C55, 0x5E97, 0x6DFB, 0x7E8F, 0x751C, 0x8CBC, 0x8EE2, 0x985B,
+ 0x70B9, 0x4F1D, 0x6BBF, 0x6FB1, 0x7530, 0x96FB, 0x514E, 0x5410,
+ 0x5835, 0x5857, 0x59AC, 0x5C60, 0x5F92, 0x6597, 0x675C, 0x6E21,
+ 0x767B, 0x83DF, 0x8CED, 0x9014, 0x90FD, 0x934D, 0x7825, 0x783A,
+ 0x52AA, 0x5EA6, 0x571F, 0x5974, 0x6012, 0x5012, 0x515A, 0x51AC,
+ 0x51CD, 0x5200, 0x5510, 0x5854, 0x5858, 0x5957, 0x5B95, 0x5CF6,
+ 0x5D8B, 0x60BC, 0x6295, 0x642D, 0x6771, 0x6843, 0x68BC, 0x68DF,
+ 0x76D7, 0x6DD8, 0x6E6F, 0x6D9B, 0x706F, 0x71C8, 0x5F53, 0x75D8,
+ 0x7977, 0x7B49, 0x7B54, 0x7B52, 0x7CD6, 0x7D71, 0x5230,
+};
+static const unsigned short euc_to_utf8_C6[] = {
+ 0x8463, 0x8569, 0x85E4, 0x8A0E, 0x8B04, 0x8C46, 0x8E0F,
+ 0x9003, 0x900F, 0x9419, 0x9676, 0x982D, 0x9A30, 0x95D8, 0x50CD,
+ 0x52D5, 0x540C, 0x5802, 0x5C0E, 0x61A7, 0x649E, 0x6D1E, 0x77B3,
+ 0x7AE5, 0x80F4, 0x8404, 0x9053, 0x9285, 0x5CE0, 0x9D07, 0x533F,
+ 0x5F97, 0x5FB3, 0x6D9C, 0x7279, 0x7763, 0x79BF, 0x7BE4, 0x6BD2,
+ 0x72EC, 0x8AAD, 0x6803, 0x6A61, 0x51F8, 0x7A81, 0x6934, 0x5C4A,
+ 0x9CF6, 0x82EB, 0x5BC5, 0x9149, 0x701E, 0x5678, 0x5C6F, 0x60C7,
+ 0x6566, 0x6C8C, 0x8C5A, 0x9041, 0x9813, 0x5451, 0x66C7, 0x920D,
+ 0x5948, 0x90A3, 0x5185, 0x4E4D, 0x51EA, 0x8599, 0x8B0E, 0x7058,
+ 0x637A, 0x934B, 0x6962, 0x99B4, 0x7E04, 0x7577, 0x5357, 0x6960,
+ 0x8EDF, 0x96E3, 0x6C5D, 0x4E8C, 0x5C3C, 0x5F10, 0x8FE9, 0x5302,
+ 0x8CD1, 0x8089, 0x8679, 0x5EFF, 0x65E5, 0x4E73, 0x5165,
+};
+static const unsigned short euc_to_utf8_C7[] = {
+ 0x5982, 0x5C3F, 0x97EE, 0x4EFB, 0x598A, 0x5FCD, 0x8A8D,
+ 0x6FE1, 0x79B0, 0x7962, 0x5BE7, 0x8471, 0x732B, 0x71B1, 0x5E74,
+ 0x5FF5, 0x637B, 0x649A, 0x71C3, 0x7C98, 0x4E43, 0x5EFC, 0x4E4B,
+ 0x57DC, 0x56A2, 0x60A9, 0x6FC3, 0x7D0D, 0x80FD, 0x8133, 0x81BF,
+ 0x8FB2, 0x8997, 0x86A4, 0x5DF4, 0x628A, 0x64AD, 0x8987, 0x6777,
+ 0x6CE2, 0x6D3E, 0x7436, 0x7834, 0x5A46, 0x7F75, 0x82AD, 0x99AC,
+ 0x4FF3, 0x5EC3, 0x62DD, 0x6392, 0x6557, 0x676F, 0x76C3, 0x724C,
+ 0x80CC, 0x80BA, 0x8F29, 0x914D, 0x500D, 0x57F9, 0x5A92, 0x6885,
+ 0x6973, 0x7164, 0x72FD, 0x8CB7, 0x58F2, 0x8CE0, 0x966A, 0x9019,
+ 0x877F, 0x79E4, 0x77E7, 0x8429, 0x4F2F, 0x5265, 0x535A, 0x62CD,
+ 0x67CF, 0x6CCA, 0x767D, 0x7B94, 0x7C95, 0x8236, 0x8584, 0x8FEB,
+ 0x66DD, 0x6F20, 0x7206, 0x7E1B, 0x83AB, 0x99C1, 0x9EA6,
+};
+static const unsigned short euc_to_utf8_C8[] = {
+ 0x51FD, 0x7BB1, 0x7872, 0x7BB8, 0x8087, 0x7B48, 0x6AE8,
+ 0x5E61, 0x808C, 0x7551, 0x7560, 0x516B, 0x9262, 0x6E8C, 0x767A,
+ 0x9197, 0x9AEA, 0x4F10, 0x7F70, 0x629C, 0x7B4F, 0x95A5, 0x9CE9,
+ 0x567A, 0x5859, 0x86E4, 0x96BC, 0x4F34, 0x5224, 0x534A, 0x53CD,
+ 0x53DB, 0x5E06, 0x642C, 0x6591, 0x677F, 0x6C3E, 0x6C4E, 0x7248,
+ 0x72AF, 0x73ED, 0x7554, 0x7E41, 0x822C, 0x85E9, 0x8CA9, 0x7BC4,
+ 0x91C6, 0x7169, 0x9812, 0x98EF, 0x633D, 0x6669, 0x756A, 0x76E4,
+ 0x78D0, 0x8543, 0x86EE, 0x532A, 0x5351, 0x5426, 0x5983, 0x5E87,
+ 0x5F7C, 0x60B2, 0x6249, 0x6279, 0x62AB, 0x6590, 0x6BD4, 0x6CCC,
+ 0x75B2, 0x76AE, 0x7891, 0x79D8, 0x7DCB, 0x7F77, 0x80A5, 0x88AB,
+ 0x8AB9, 0x8CBB, 0x907F, 0x975E, 0x98DB, 0x6A0B, 0x7C38, 0x5099,
+ 0x5C3E, 0x5FAE, 0x6787, 0x6BD8, 0x7435, 0x7709, 0x7F8E,
+};
+static const unsigned short euc_to_utf8_C9[] = {
+ 0x9F3B, 0x67CA, 0x7A17, 0x5339, 0x758B, 0x9AED, 0x5F66,
+ 0x819D, 0x83F1, 0x8098, 0x5F3C, 0x5FC5, 0x7562, 0x7B46, 0x903C,
+ 0x6867, 0x59EB, 0x5A9B, 0x7D10, 0x767E, 0x8B2C, 0x4FF5, 0x5F6A,
+ 0x6A19, 0x6C37, 0x6F02, 0x74E2, 0x7968, 0x8868, 0x8A55, 0x8C79,
+ 0x5EDF, 0x63CF, 0x75C5, 0x79D2, 0x82D7, 0x9328, 0x92F2, 0x849C,
+ 0x86ED, 0x9C2D, 0x54C1, 0x5F6C, 0x658C, 0x6D5C, 0x7015, 0x8CA7,
+ 0x8CD3, 0x983B, 0x654F, 0x74F6, 0x4E0D, 0x4ED8, 0x57E0, 0x592B,
+ 0x5A66, 0x5BCC, 0x51A8, 0x5E03, 0x5E9C, 0x6016, 0x6276, 0x6577,
+ 0x65A7, 0x666E, 0x6D6E, 0x7236, 0x7B26, 0x8150, 0x819A, 0x8299,
+ 0x8B5C, 0x8CA0, 0x8CE6, 0x8D74, 0x961C, 0x9644, 0x4FAE, 0x64AB,
+ 0x6B66, 0x821E, 0x8461, 0x856A, 0x90E8, 0x5C01, 0x6953, 0x98A8,
+ 0x847A, 0x8557, 0x4F0F, 0x526F, 0x5FA9, 0x5E45, 0x670D,
+};
+static const unsigned short euc_to_utf8_CA[] = {
+ 0x798F, 0x8179, 0x8907, 0x8986, 0x6DF5, 0x5F17, 0x6255,
+ 0x6CB8, 0x4ECF, 0x7269, 0x9B92, 0x5206, 0x543B, 0x5674, 0x58B3,
+ 0x61A4, 0x626E, 0x711A, 0x596E, 0x7C89, 0x7CDE, 0x7D1B, 0x96F0,
+ 0x6587, 0x805E, 0x4E19, 0x4F75, 0x5175, 0x5840, 0x5E63, 0x5E73,
+ 0x5F0A, 0x67C4, 0x4E26, 0x853D, 0x9589, 0x965B, 0x7C73, 0x9801,
+ 0x50FB, 0x58C1, 0x7656, 0x78A7, 0x5225, 0x77A5, 0x8511, 0x7B86,
+ 0x504F, 0x5909, 0x7247, 0x7BC7, 0x7DE8, 0x8FBA, 0x8FD4, 0x904D,
+ 0x4FBF, 0x52C9, 0x5A29, 0x5F01, 0x97AD, 0x4FDD, 0x8217, 0x92EA,
+ 0x5703, 0x6355, 0x6B69, 0x752B, 0x88DC, 0x8F14, 0x7A42, 0x52DF,
+ 0x5893, 0x6155, 0x620A, 0x66AE, 0x6BCD, 0x7C3F, 0x83E9, 0x5023,
+ 0x4FF8, 0x5305, 0x5446, 0x5831, 0x5949, 0x5B9D, 0x5CF0, 0x5CEF,
+ 0x5D29, 0x5E96, 0x62B1, 0x6367, 0x653E, 0x65B9, 0x670B,
+};
+static const unsigned short euc_to_utf8_CB[] = {
+ 0x6CD5, 0x6CE1, 0x70F9, 0x7832, 0x7E2B, 0x80DE, 0x82B3,
+ 0x840C, 0x84EC, 0x8702, 0x8912, 0x8A2A, 0x8C4A, 0x90A6, 0x92D2,
+ 0x98FD, 0x9CF3, 0x9D6C, 0x4E4F, 0x4EA1, 0x508D, 0x5256, 0x574A,
+ 0x59A8, 0x5E3D, 0x5FD8, 0x5FD9, 0x623F, 0x66B4, 0x671B, 0x67D0,
+ 0x68D2, 0x5192, 0x7D21, 0x80AA, 0x81A8, 0x8B00, 0x8C8C, 0x8CBF,
+ 0x927E, 0x9632, 0x5420, 0x982C, 0x5317, 0x50D5, 0x535C, 0x58A8,
+ 0x64B2, 0x6734, 0x7267, 0x7766, 0x7A46, 0x91E6, 0x52C3, 0x6CA1,
+ 0x6B86, 0x5800, 0x5E4C, 0x5954, 0x672C, 0x7FFB, 0x51E1, 0x76C6,
+ 0x6469, 0x78E8, 0x9B54, 0x9EBB, 0x57CB, 0x59B9, 0x6627, 0x679A,
+ 0x6BCE, 0x54E9, 0x69D9, 0x5E55, 0x819C, 0x6795, 0x9BAA, 0x67FE,
+ 0x9C52, 0x685D, 0x4EA6, 0x4FE3, 0x53C8, 0x62B9, 0x672B, 0x6CAB,
+ 0x8FC4, 0x4FAD, 0x7E6D, 0x9EBF, 0x4E07, 0x6162, 0x6E80,
+};
+static const unsigned short euc_to_utf8_CC[] = {
+ 0x6F2B, 0x8513, 0x5473, 0x672A, 0x9B45, 0x5DF3, 0x7B95,
+ 0x5CAC, 0x5BC6, 0x871C, 0x6E4A, 0x84D1, 0x7A14, 0x8108, 0x5999,
+ 0x7C8D, 0x6C11, 0x7720, 0x52D9, 0x5922, 0x7121, 0x725F, 0x77DB,
+ 0x9727, 0x9D61, 0x690B, 0x5A7F, 0x5A18, 0x51A5, 0x540D, 0x547D,
+ 0x660E, 0x76DF, 0x8FF7, 0x9298, 0x9CF4, 0x59EA, 0x725D, 0x6EC5,
+ 0x514D, 0x68C9, 0x7DBF, 0x7DEC, 0x9762, 0x9EBA, 0x6478, 0x6A21,
+ 0x8302, 0x5984, 0x5B5F, 0x6BDB, 0x731B, 0x76F2, 0x7DB2, 0x8017,
+ 0x8499, 0x5132, 0x6728, 0x9ED9, 0x76EE, 0x6762, 0x52FF, 0x9905,
+ 0x5C24, 0x623B, 0x7C7E, 0x8CB0, 0x554F, 0x60B6, 0x7D0B, 0x9580,
+ 0x5301, 0x4E5F, 0x51B6, 0x591C, 0x723A, 0x8036, 0x91CE, 0x5F25,
+ 0x77E2, 0x5384, 0x5F79, 0x7D04, 0x85AC, 0x8A33, 0x8E8D, 0x9756,
+ 0x67F3, 0x85AE, 0x9453, 0x6109, 0x6108, 0x6CB9, 0x7652,
+};
+static const unsigned short euc_to_utf8_CD[] = {
+ 0x8AED, 0x8F38, 0x552F, 0x4F51, 0x512A, 0x52C7, 0x53CB,
+ 0x5BA5, 0x5E7D, 0x60A0, 0x6182, 0x63D6, 0x6709, 0x67DA, 0x6E67,
+ 0x6D8C, 0x7336, 0x7337, 0x7531, 0x7950, 0x88D5, 0x8A98, 0x904A,
+ 0x9091, 0x90F5, 0x96C4, 0x878D, 0x5915, 0x4E88, 0x4F59, 0x4E0E,
+ 0x8A89, 0x8F3F, 0x9810, 0x50AD, 0x5E7C, 0x5996, 0x5BB9, 0x5EB8,
+ 0x63DA, 0x63FA, 0x64C1, 0x66DC, 0x694A, 0x69D8, 0x6D0B, 0x6EB6,
+ 0x7194, 0x7528, 0x7AAF, 0x7F8A, 0x8000, 0x8449, 0x84C9, 0x8981,
+ 0x8B21, 0x8E0A, 0x9065, 0x967D, 0x990A, 0x617E, 0x6291, 0x6B32,
+ 0x6C83, 0x6D74, 0x7FCC, 0x7FFC, 0x6DC0, 0x7F85, 0x87BA, 0x88F8,
+ 0x6765, 0x83B1, 0x983C, 0x96F7, 0x6D1B, 0x7D61, 0x843D, 0x916A,
+ 0x4E71, 0x5375, 0x5D50, 0x6B04, 0x6FEB, 0x85CD, 0x862D, 0x89A7,
+ 0x5229, 0x540F, 0x5C65, 0x674E, 0x68A8, 0x7406, 0x7483,
+};
+static const unsigned short euc_to_utf8_CE[] = {
+ 0x75E2, 0x88CF, 0x88E1, 0x91CC, 0x96E2, 0x9678, 0x5F8B,
+ 0x7387, 0x7ACB, 0x844E, 0x63A0, 0x7565, 0x5289, 0x6D41, 0x6E9C,
+ 0x7409, 0x7559, 0x786B, 0x7C92, 0x9686, 0x7ADC, 0x9F8D, 0x4FB6,
+ 0x616E, 0x65C5, 0x865C, 0x4E86, 0x4EAE, 0x50DA, 0x4E21, 0x51CC,
+ 0x5BEE, 0x6599, 0x6881, 0x6DBC, 0x731F, 0x7642, 0x77AD, 0x7A1C,
+ 0x7CE7, 0x826F, 0x8AD2, 0x907C, 0x91CF, 0x9675, 0x9818, 0x529B,
+ 0x7DD1, 0x502B, 0x5398, 0x6797, 0x6DCB, 0x71D0, 0x7433, 0x81E8,
+ 0x8F2A, 0x96A3, 0x9C57, 0x9E9F, 0x7460, 0x5841, 0x6D99, 0x7D2F,
+ 0x985E, 0x4EE4, 0x4F36, 0x4F8B, 0x51B7, 0x52B1, 0x5DBA, 0x601C,
+ 0x73B2, 0x793C, 0x82D3, 0x9234, 0x96B7, 0x96F6, 0x970A, 0x9E97,
+ 0x9F62, 0x66A6, 0x6B74, 0x5217, 0x52A3, 0x70C8, 0x88C2, 0x5EC9,
+ 0x604B, 0x6190, 0x6F23, 0x7149, 0x7C3E, 0x7DF4, 0x806F,
+};
+static const unsigned short euc_to_utf8_CF[] = {
+ 0x84EE, 0x9023, 0x932C, 0x5442, 0x9B6F, 0x6AD3, 0x7089,
+ 0x8CC2, 0x8DEF, 0x9732, 0x52B4, 0x5A41, 0x5ECA, 0x5F04, 0x6717,
+ 0x697C, 0x6994, 0x6D6A, 0x6F0F, 0x7262, 0x72FC, 0x7BED, 0x8001,
+ 0x807E, 0x874B, 0x90CE, 0x516D, 0x9E93, 0x7984, 0x808B, 0x9332,
+ 0x8AD6, 0x502D, 0x548C, 0x8A71, 0x6B6A, 0x8CC4, 0x8107, 0x60D1,
+ 0x67A0, 0x9DF2, 0x4E99, 0x4E98, 0x9C10, 0x8A6B, 0x85C1, 0x8568,
+ 0x6900, 0x6E7E, 0x7897, 0x8155, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0,
+};
+static const unsigned short euc_to_utf8_CF_x0213[] = {
+ 0x84EE, 0x9023, 0x932C, 0x5442, 0x9B6F, 0x6AD3, 0x7089,
+ 0x8CC2, 0x8DEF, 0x9732, 0x52B4, 0x5A41, 0x5ECA, 0x5F04, 0x6717,
+ 0x697C, 0x6994, 0x6D6A, 0x6F0F, 0x7262, 0x72FC, 0x7BED, 0x8001,
+ 0x807E, 0x874B, 0x90CE, 0x516D, 0x9E93, 0x7984, 0x808B, 0x9332,
+ 0x8AD6, 0x502D, 0x548C, 0x8A71, 0x6B6A, 0x8CC4, 0x8107, 0x60D1,
+ 0x67A0, 0x9DF2, 0x4E99, 0x4E98, 0x9C10, 0x8A6B, 0x85C1, 0x8568,
+ 0x6900, 0x6E7E, 0x7897, 0x8155, 0xD842 /*0xDF9F*/, 0x5B41, 0x5B56, 0x5B7D,
+ 0x5B93, 0x5BD8, 0x5BEC, 0x5C12, 0x5C1E, 0x5C23, 0x5C2B, 0x378D,
+ 0x5C62, 0xFA3B, 0xFA3C, 0xD845 /*0xDEB4*/, 0x5C7A, 0x5C8F, 0x5C9F, 0x5CA3,
+ 0x5CAA, 0x5CBA, 0x5CCB, 0x5CD0, 0x5CD2, 0x5CF4, 0xD847 /*0xDE34*/, 0x37E2,
+ 0x5D0D, 0x5D27, 0xFA11, 0x5D46, 0x5D47, 0x5D53, 0x5D4A, 0x5D6D,
+ 0x5D81, 0x5DA0, 0x5DA4, 0x5DA7, 0x5DB8, 0x5DCB, 0x541E,
+};
+static const unsigned short euc_to_utf8_D0[] = {
+ 0x5F0C, 0x4E10, 0x4E15, 0x4E2A, 0x4E31, 0x4E36, 0x4E3C,
+ 0x4E3F, 0x4E42, 0x4E56, 0x4E58, 0x4E82, 0x4E85, 0x8C6B, 0x4E8A,
+ 0x8212, 0x5F0D, 0x4E8E, 0x4E9E, 0x4E9F, 0x4EA0, 0x4EA2, 0x4EB0,
+ 0x4EB3, 0x4EB6, 0x4ECE, 0x4ECD, 0x4EC4, 0x4EC6, 0x4EC2, 0x4ED7,
+ 0x4EDE, 0x4EED, 0x4EDF, 0x4EF7, 0x4F09, 0x4F5A, 0x4F30, 0x4F5B,
+ 0x4F5D, 0x4F57, 0x4F47, 0x4F76, 0x4F88, 0x4F8F, 0x4F98, 0x4F7B,
+ 0x4F69, 0x4F70, 0x4F91, 0x4F6F, 0x4F86, 0x4F96, 0x5118, 0x4FD4,
+ 0x4FDF, 0x4FCE, 0x4FD8, 0x4FDB, 0x4FD1, 0x4FDA, 0x4FD0, 0x4FE4,
+ 0x4FE5, 0x501A, 0x5028, 0x5014, 0x502A, 0x5025, 0x5005, 0x4F1C,
+ 0x4FF6, 0x5021, 0x5029, 0x502C, 0x4FFE, 0x4FEF, 0x5011, 0x5006,
+ 0x5043, 0x5047, 0x6703, 0x5055, 0x5050, 0x5048, 0x505A, 0x5056,
+ 0x506C, 0x5078, 0x5080, 0x509A, 0x5085, 0x50B4, 0x50B2,
+};
+static const unsigned short euc_to_utf8_D1[] = {
+ 0x50C9, 0x50CA, 0x50B3, 0x50C2, 0x50D6, 0x50DE, 0x50E5,
+ 0x50ED, 0x50E3, 0x50EE, 0x50F9, 0x50F5, 0x5109, 0x5101, 0x5102,
+ 0x5116, 0x5115, 0x5114, 0x511A, 0x5121, 0x513A, 0x5137, 0x513C,
+ 0x513B, 0x513F, 0x5140, 0x5152, 0x514C, 0x5154, 0x5162, 0x7AF8,
+ 0x5169, 0x516A, 0x516E, 0x5180, 0x5182, 0x56D8, 0x518C, 0x5189,
+ 0x518F, 0x5191, 0x5193, 0x5195, 0x5196, 0x51A4, 0x51A6, 0x51A2,
+ 0x51A9, 0x51AA, 0x51AB, 0x51B3, 0x51B1, 0x51B2, 0x51B0, 0x51B5,
+ 0x51BD, 0x51C5, 0x51C9, 0x51DB, 0x51E0, 0x8655, 0x51E9, 0x51ED,
+ 0x51F0, 0x51F5, 0x51FE, 0x5204, 0x520B, 0x5214, 0x520E, 0x5227,
+ 0x522A, 0x522E, 0x5233, 0x5239, 0x524F, 0x5244, 0x524B, 0x524C,
+ 0x525E, 0x5254, 0x526A, 0x5274, 0x5269, 0x5273, 0x527F, 0x527D,
+ 0x528D, 0x5294, 0x5292, 0x5271, 0x5288, 0x5291, 0x8FA8,
+};
+static const unsigned short euc_to_utf8_D2[] = {
+ 0x8FA7, 0x52AC, 0x52AD, 0x52BC, 0x52B5, 0x52C1, 0x52CD,
+ 0x52D7, 0x52DE, 0x52E3, 0x52E6, 0x98ED, 0x52E0, 0x52F3, 0x52F5,
+ 0x52F8, 0x52F9, 0x5306, 0x5308, 0x7538, 0x530D, 0x5310, 0x530F,
+ 0x5315, 0x531A, 0x5323, 0x532F, 0x5331, 0x5333, 0x5338, 0x5340,
+ 0x5346, 0x5345, 0x4E17, 0x5349, 0x534D, 0x51D6, 0x535E, 0x5369,
+ 0x536E, 0x5918, 0x537B, 0x5377, 0x5382, 0x5396, 0x53A0, 0x53A6,
+ 0x53A5, 0x53AE, 0x53B0, 0x53B6, 0x53C3, 0x7C12, 0x96D9, 0x53DF,
+ 0x66FC, 0x71EE, 0x53EE, 0x53E8, 0x53ED, 0x53FA, 0x5401, 0x543D,
+ 0x5440, 0x542C, 0x542D, 0x543C, 0x542E, 0x5436, 0x5429, 0x541D,
+ 0x544E, 0x548F, 0x5475, 0x548E, 0x545F, 0x5471, 0x5477, 0x5470,
+ 0x5492, 0x547B, 0x5480, 0x5476, 0x5484, 0x5490, 0x5486, 0x54C7,
+ 0x54A2, 0x54B8, 0x54A5, 0x54AC, 0x54C4, 0x54C8, 0x54A8,
+};
+static const unsigned short euc_to_utf8_D3[] = {
+ 0x54AB, 0x54C2, 0x54A4, 0x54BE, 0x54BC, 0x54D8, 0x54E5,
+ 0x54E6, 0x550F, 0x5514, 0x54FD, 0x54EE, 0x54ED, 0x54FA, 0x54E2,
+ 0x5539, 0x5540, 0x5563, 0x554C, 0x552E, 0x555C, 0x5545, 0x5556,
+ 0x5557, 0x5538, 0x5533, 0x555D, 0x5599, 0x5580, 0x54AF, 0x558A,
+ 0x559F, 0x557B, 0x557E, 0x5598, 0x559E, 0x55AE, 0x557C, 0x5583,
+ 0x55A9, 0x5587, 0x55A8, 0x55DA, 0x55C5, 0x55DF, 0x55C4, 0x55DC,
+ 0x55E4, 0x55D4, 0x5614, 0x55F7, 0x5616, 0x55FE, 0x55FD, 0x561B,
+ 0x55F9, 0x564E, 0x5650, 0x71DF, 0x5634, 0x5636, 0x5632, 0x5638,
+ 0x566B, 0x5664, 0x562F, 0x566C, 0x566A, 0x5686, 0x5680, 0x568A,
+ 0x56A0, 0x5694, 0x568F, 0x56A5, 0x56AE, 0x56B6, 0x56B4, 0x56C2,
+ 0x56BC, 0x56C1, 0x56C3, 0x56C0, 0x56C8, 0x56CE, 0x56D1, 0x56D3,
+ 0x56D7, 0x56EE, 0x56F9, 0x5700, 0x56FF, 0x5704, 0x5709,
+};
+static const unsigned short euc_to_utf8_D4[] = {
+ 0x5708, 0x570B, 0x570D, 0x5713, 0x5718, 0x5716, 0x55C7,
+ 0x571C, 0x5726, 0x5737, 0x5738, 0x574E, 0x573B, 0x5740, 0x574F,
+ 0x5769, 0x57C0, 0x5788, 0x5761, 0x577F, 0x5789, 0x5793, 0x57A0,
+ 0x57B3, 0x57A4, 0x57AA, 0x57B0, 0x57C3, 0x57C6, 0x57D4, 0x57D2,
+ 0x57D3, 0x580A, 0x57D6, 0x57E3, 0x580B, 0x5819, 0x581D, 0x5872,
+ 0x5821, 0x5862, 0x584B, 0x5870, 0x6BC0, 0x5852, 0x583D, 0x5879,
+ 0x5885, 0x58B9, 0x589F, 0x58AB, 0x58BA, 0x58DE, 0x58BB, 0x58B8,
+ 0x58AE, 0x58C5, 0x58D3, 0x58D1, 0x58D7, 0x58D9, 0x58D8, 0x58E5,
+ 0x58DC, 0x58E4, 0x58DF, 0x58EF, 0x58FA, 0x58F9, 0x58FB, 0x58FC,
+ 0x58FD, 0x5902, 0x590A, 0x5910, 0x591B, 0x68A6, 0x5925, 0x592C,
+ 0x592D, 0x5932, 0x5938, 0x593E, 0x7AD2, 0x5955, 0x5950, 0x594E,
+ 0x595A, 0x5958, 0x5962, 0x5960, 0x5967, 0x596C, 0x5969,
+};
+static const unsigned short euc_to_utf8_D5[] = {
+ 0x5978, 0x5981, 0x599D, 0x4F5E, 0x4FAB, 0x59A3, 0x59B2,
+ 0x59C6, 0x59E8, 0x59DC, 0x598D, 0x59D9, 0x59DA, 0x5A25, 0x5A1F,
+ 0x5A11, 0x5A1C, 0x5A09, 0x5A1A, 0x5A40, 0x5A6C, 0x5A49, 0x5A35,
+ 0x5A36, 0x5A62, 0x5A6A, 0x5A9A, 0x5ABC, 0x5ABE, 0x5ACB, 0x5AC2,
+ 0x5ABD, 0x5AE3, 0x5AD7, 0x5AE6, 0x5AE9, 0x5AD6, 0x5AFA, 0x5AFB,
+ 0x5B0C, 0x5B0B, 0x5B16, 0x5B32, 0x5AD0, 0x5B2A, 0x5B36, 0x5B3E,
+ 0x5B43, 0x5B45, 0x5B40, 0x5B51, 0x5B55, 0x5B5A, 0x5B5B, 0x5B65,
+ 0x5B69, 0x5B70, 0x5B73, 0x5B75, 0x5B78, 0x6588, 0x5B7A, 0x5B80,
+ 0x5B83, 0x5BA6, 0x5BB8, 0x5BC3, 0x5BC7, 0x5BC9, 0x5BD4, 0x5BD0,
+ 0x5BE4, 0x5BE6, 0x5BE2, 0x5BDE, 0x5BE5, 0x5BEB, 0x5BF0, 0x5BF6,
+ 0x5BF3, 0x5C05, 0x5C07, 0x5C08, 0x5C0D, 0x5C13, 0x5C20, 0x5C22,
+ 0x5C28, 0x5C38, 0x5C39, 0x5C41, 0x5C46, 0x5C4E, 0x5C53,
+};
+static const unsigned short euc_to_utf8_D6[] = {
+ 0x5C50, 0x5C4F, 0x5B71, 0x5C6C, 0x5C6E, 0x4E62, 0x5C76,
+ 0x5C79, 0x5C8C, 0x5C91, 0x5C94, 0x599B, 0x5CAB, 0x5CBB, 0x5CB6,
+ 0x5CBC, 0x5CB7, 0x5CC5, 0x5CBE, 0x5CC7, 0x5CD9, 0x5CE9, 0x5CFD,
+ 0x5CFA, 0x5CED, 0x5D8C, 0x5CEA, 0x5D0B, 0x5D15, 0x5D17, 0x5D5C,
+ 0x5D1F, 0x5D1B, 0x5D11, 0x5D14, 0x5D22, 0x5D1A, 0x5D19, 0x5D18,
+ 0x5D4C, 0x5D52, 0x5D4E, 0x5D4B, 0x5D6C, 0x5D73, 0x5D76, 0x5D87,
+ 0x5D84, 0x5D82, 0x5DA2, 0x5D9D, 0x5DAC, 0x5DAE, 0x5DBD, 0x5D90,
+ 0x5DB7, 0x5DBC, 0x5DC9, 0x5DCD, 0x5DD3, 0x5DD2, 0x5DD6, 0x5DDB,
+ 0x5DEB, 0x5DF2, 0x5DF5, 0x5E0B, 0x5E1A, 0x5E19, 0x5E11, 0x5E1B,
+ 0x5E36, 0x5E37, 0x5E44, 0x5E43, 0x5E40, 0x5E4E, 0x5E57, 0x5E54,
+ 0x5E5F, 0x5E62, 0x5E64, 0x5E47, 0x5E75, 0x5E76, 0x5E7A, 0x9EBC,
+ 0x5E7F, 0x5EA0, 0x5EC1, 0x5EC2, 0x5EC8, 0x5ED0, 0x5ECF,
+};
+static const unsigned short euc_to_utf8_D7[] = {
+ 0x5ED6, 0x5EE3, 0x5EDD, 0x5EDA, 0x5EDB, 0x5EE2, 0x5EE1,
+ 0x5EE8, 0x5EE9, 0x5EEC, 0x5EF1, 0x5EF3, 0x5EF0, 0x5EF4, 0x5EF8,
+ 0x5EFE, 0x5F03, 0x5F09, 0x5F5D, 0x5F5C, 0x5F0B, 0x5F11, 0x5F16,
+ 0x5F29, 0x5F2D, 0x5F38, 0x5F41, 0x5F48, 0x5F4C, 0x5F4E, 0x5F2F,
+ 0x5F51, 0x5F56, 0x5F57, 0x5F59, 0x5F61, 0x5F6D, 0x5F73, 0x5F77,
+ 0x5F83, 0x5F82, 0x5F7F, 0x5F8A, 0x5F88, 0x5F91, 0x5F87, 0x5F9E,
+ 0x5F99, 0x5F98, 0x5FA0, 0x5FA8, 0x5FAD, 0x5FBC, 0x5FD6, 0x5FFB,
+ 0x5FE4, 0x5FF8, 0x5FF1, 0x5FDD, 0x60B3, 0x5FFF, 0x6021, 0x6060,
+ 0x6019, 0x6010, 0x6029, 0x600E, 0x6031, 0x601B, 0x6015, 0x602B,
+ 0x6026, 0x600F, 0x603A, 0x605A, 0x6041, 0x606A, 0x6077, 0x605F,
+ 0x604A, 0x6046, 0x604D, 0x6063, 0x6043, 0x6064, 0x6042, 0x606C,
+ 0x606B, 0x6059, 0x6081, 0x608D, 0x60E7, 0x6083, 0x609A,
+};
+static const unsigned short euc_to_utf8_D8[] = {
+ 0x6084, 0x609B, 0x6096, 0x6097, 0x6092, 0x60A7, 0x608B,
+ 0x60E1, 0x60B8, 0x60E0, 0x60D3, 0x60B4, 0x5FF0, 0x60BD, 0x60C6,
+ 0x60B5, 0x60D8, 0x614D, 0x6115, 0x6106, 0x60F6, 0x60F7, 0x6100,
+ 0x60F4, 0x60FA, 0x6103, 0x6121, 0x60FB, 0x60F1, 0x610D, 0x610E,
+ 0x6147, 0x613E, 0x6128, 0x6127, 0x614A, 0x613F, 0x613C, 0x612C,
+ 0x6134, 0x613D, 0x6142, 0x6144, 0x6173, 0x6177, 0x6158, 0x6159,
+ 0x615A, 0x616B, 0x6174, 0x616F, 0x6165, 0x6171, 0x615F, 0x615D,
+ 0x6153, 0x6175, 0x6199, 0x6196, 0x6187, 0x61AC, 0x6194, 0x619A,
+ 0x618A, 0x6191, 0x61AB, 0x61AE, 0x61CC, 0x61CA, 0x61C9, 0x61F7,
+ 0x61C8, 0x61C3, 0x61C6, 0x61BA, 0x61CB, 0x7F79, 0x61CD, 0x61E6,
+ 0x61E3, 0x61F6, 0x61FA, 0x61F4, 0x61FF, 0x61FD, 0x61FC, 0x61FE,
+ 0x6200, 0x6208, 0x6209, 0x620D, 0x620C, 0x6214, 0x621B,
+};
+static const unsigned short euc_to_utf8_D9[] = {
+ 0x621E, 0x6221, 0x622A, 0x622E, 0x6230, 0x6232, 0x6233,
+ 0x6241, 0x624E, 0x625E, 0x6263, 0x625B, 0x6260, 0x6268, 0x627C,
+ 0x6282, 0x6289, 0x627E, 0x6292, 0x6293, 0x6296, 0x62D4, 0x6283,
+ 0x6294, 0x62D7, 0x62D1, 0x62BB, 0x62CF, 0x62FF, 0x62C6, 0x64D4,
+ 0x62C8, 0x62DC, 0x62CC, 0x62CA, 0x62C2, 0x62C7, 0x629B, 0x62C9,
+ 0x630C, 0x62EE, 0x62F1, 0x6327, 0x6302, 0x6308, 0x62EF, 0x62F5,
+ 0x6350, 0x633E, 0x634D, 0x641C, 0x634F, 0x6396, 0x638E, 0x6380,
+ 0x63AB, 0x6376, 0x63A3, 0x638F, 0x6389, 0x639F, 0x63B5, 0x636B,
+ 0x6369, 0x63BE, 0x63E9, 0x63C0, 0x63C6, 0x63E3, 0x63C9, 0x63D2,
+ 0x63F6, 0x63C4, 0x6416, 0x6434, 0x6406, 0x6413, 0x6426, 0x6436,
+ 0x651D, 0x6417, 0x6428, 0x640F, 0x6467, 0x646F, 0x6476, 0x644E,
+ 0x652A, 0x6495, 0x6493, 0x64A5, 0x64A9, 0x6488, 0x64BC,
+};
+static const unsigned short euc_to_utf8_DA[] = {
+ 0x64DA, 0x64D2, 0x64C5, 0x64C7, 0x64BB, 0x64D8, 0x64C2,
+ 0x64F1, 0x64E7, 0x8209, 0x64E0, 0x64E1, 0x62AC, 0x64E3, 0x64EF,
+ 0x652C, 0x64F6, 0x64F4, 0x64F2, 0x64FA, 0x6500, 0x64FD, 0x6518,
+ 0x651C, 0x6505, 0x6524, 0x6523, 0x652B, 0x6534, 0x6535, 0x6537,
+ 0x6536, 0x6538, 0x754B, 0x6548, 0x6556, 0x6555, 0x654D, 0x6558,
+ 0x655E, 0x655D, 0x6572, 0x6578, 0x6582, 0x6583, 0x8B8A, 0x659B,
+ 0x659F, 0x65AB, 0x65B7, 0x65C3, 0x65C6, 0x65C1, 0x65C4, 0x65CC,
+ 0x65D2, 0x65DB, 0x65D9, 0x65E0, 0x65E1, 0x65F1, 0x6772, 0x660A,
+ 0x6603, 0x65FB, 0x6773, 0x6635, 0x6636, 0x6634, 0x661C, 0x664F,
+ 0x6644, 0x6649, 0x6641, 0x665E, 0x665D, 0x6664, 0x6667, 0x6668,
+ 0x665F, 0x6662, 0x6670, 0x6683, 0x6688, 0x668E, 0x6689, 0x6684,
+ 0x6698, 0x669D, 0x66C1, 0x66B9, 0x66C9, 0x66BE, 0x66BC,
+};
+static const unsigned short euc_to_utf8_DB[] = {
+ 0x66C4, 0x66B8, 0x66D6, 0x66DA, 0x66E0, 0x663F, 0x66E6,
+ 0x66E9, 0x66F0, 0x66F5, 0x66F7, 0x670F, 0x6716, 0x671E, 0x6726,
+ 0x6727, 0x9738, 0x672E, 0x673F, 0x6736, 0x6741, 0x6738, 0x6737,
+ 0x6746, 0x675E, 0x6760, 0x6759, 0x6763, 0x6764, 0x6789, 0x6770,
+ 0x67A9, 0x677C, 0x676A, 0x678C, 0x678B, 0x67A6, 0x67A1, 0x6785,
+ 0x67B7, 0x67EF, 0x67B4, 0x67EC, 0x67B3, 0x67E9, 0x67B8, 0x67E4,
+ 0x67DE, 0x67DD, 0x67E2, 0x67EE, 0x67B9, 0x67CE, 0x67C6, 0x67E7,
+ 0x6A9C, 0x681E, 0x6846, 0x6829, 0x6840, 0x684D, 0x6832, 0x684E,
+ 0x68B3, 0x682B, 0x6859, 0x6863, 0x6877, 0x687F, 0x689F, 0x688F,
+ 0x68AD, 0x6894, 0x689D, 0x689B, 0x6883, 0x6AAE, 0x68B9, 0x6874,
+ 0x68B5, 0x68A0, 0x68BA, 0x690F, 0x688D, 0x687E, 0x6901, 0x68CA,
+ 0x6908, 0x68D8, 0x6922, 0x6926, 0x68E1, 0x690C, 0x68CD,
+};
+static const unsigned short euc_to_utf8_DC[] = {
+ 0x68D4, 0x68E7, 0x68D5, 0x6936, 0x6912, 0x6904, 0x68D7,
+ 0x68E3, 0x6925, 0x68F9, 0x68E0, 0x68EF, 0x6928, 0x692A, 0x691A,
+ 0x6923, 0x6921, 0x68C6, 0x6979, 0x6977, 0x695C, 0x6978, 0x696B,
+ 0x6954, 0x697E, 0x696E, 0x6939, 0x6974, 0x693D, 0x6959, 0x6930,
+ 0x6961, 0x695E, 0x695D, 0x6981, 0x696A, 0x69B2, 0x69AE, 0x69D0,
+ 0x69BF, 0x69C1, 0x69D3, 0x69BE, 0x69CE, 0x5BE8, 0x69CA, 0x69DD,
+ 0x69BB, 0x69C3, 0x69A7, 0x6A2E, 0x6991, 0x69A0, 0x699C, 0x6995,
+ 0x69B4, 0x69DE, 0x69E8, 0x6A02, 0x6A1B, 0x69FF, 0x6B0A, 0x69F9,
+ 0x69F2, 0x69E7, 0x6A05, 0x69B1, 0x6A1E, 0x69ED, 0x6A14, 0x69EB,
+ 0x6A0A, 0x6A12, 0x6AC1, 0x6A23, 0x6A13, 0x6A44, 0x6A0C, 0x6A72,
+ 0x6A36, 0x6A78, 0x6A47, 0x6A62, 0x6A59, 0x6A66, 0x6A48, 0x6A38,
+ 0x6A22, 0x6A90, 0x6A8D, 0x6AA0, 0x6A84, 0x6AA2, 0x6AA3,
+};
+static const unsigned short euc_to_utf8_DD[] = {
+ 0x6A97, 0x8617, 0x6ABB, 0x6AC3, 0x6AC2, 0x6AB8, 0x6AB3,
+ 0x6AAC, 0x6ADE, 0x6AD1, 0x6ADF, 0x6AAA, 0x6ADA, 0x6AEA, 0x6AFB,
+ 0x6B05, 0x8616, 0x6AFA, 0x6B12, 0x6B16, 0x9B31, 0x6B1F, 0x6B38,
+ 0x6B37, 0x76DC, 0x6B39, 0x98EE, 0x6B47, 0x6B43, 0x6B49, 0x6B50,
+ 0x6B59, 0x6B54, 0x6B5B, 0x6B5F, 0x6B61, 0x6B78, 0x6B79, 0x6B7F,
+ 0x6B80, 0x6B84, 0x6B83, 0x6B8D, 0x6B98, 0x6B95, 0x6B9E, 0x6BA4,
+ 0x6BAA, 0x6BAB, 0x6BAF, 0x6BB2, 0x6BB1, 0x6BB3, 0x6BB7, 0x6BBC,
+ 0x6BC6, 0x6BCB, 0x6BD3, 0x6BDF, 0x6BEC, 0x6BEB, 0x6BF3, 0x6BEF,
+ 0x9EBE, 0x6C08, 0x6C13, 0x6C14, 0x6C1B, 0x6C24, 0x6C23, 0x6C5E,
+ 0x6C55, 0x6C62, 0x6C6A, 0x6C82, 0x6C8D, 0x6C9A, 0x6C81, 0x6C9B,
+ 0x6C7E, 0x6C68, 0x6C73, 0x6C92, 0x6C90, 0x6CC4, 0x6CF1, 0x6CD3,
+ 0x6CBD, 0x6CD7, 0x6CC5, 0x6CDD, 0x6CAE, 0x6CB1, 0x6CBE,
+};
+static const unsigned short euc_to_utf8_DE[] = {
+ 0x6CBA, 0x6CDB, 0x6CEF, 0x6CD9, 0x6CEA, 0x6D1F, 0x884D,
+ 0x6D36, 0x6D2B, 0x6D3D, 0x6D38, 0x6D19, 0x6D35, 0x6D33, 0x6D12,
+ 0x6D0C, 0x6D63, 0x6D93, 0x6D64, 0x6D5A, 0x6D79, 0x6D59, 0x6D8E,
+ 0x6D95, 0x6FE4, 0x6D85, 0x6DF9, 0x6E15, 0x6E0A, 0x6DB5, 0x6DC7,
+ 0x6DE6, 0x6DB8, 0x6DC6, 0x6DEC, 0x6DDE, 0x6DCC, 0x6DE8, 0x6DD2,
+ 0x6DC5, 0x6DFA, 0x6DD9, 0x6DE4, 0x6DD5, 0x6DEA, 0x6DEE, 0x6E2D,
+ 0x6E6E, 0x6E2E, 0x6E19, 0x6E72, 0x6E5F, 0x6E3E, 0x6E23, 0x6E6B,
+ 0x6E2B, 0x6E76, 0x6E4D, 0x6E1F, 0x6E43, 0x6E3A, 0x6E4E, 0x6E24,
+ 0x6EFF, 0x6E1D, 0x6E38, 0x6E82, 0x6EAA, 0x6E98, 0x6EC9, 0x6EB7,
+ 0x6ED3, 0x6EBD, 0x6EAF, 0x6EC4, 0x6EB2, 0x6ED4, 0x6ED5, 0x6E8F,
+ 0x6EA5, 0x6EC2, 0x6E9F, 0x6F41, 0x6F11, 0x704C, 0x6EEC, 0x6EF8,
+ 0x6EFE, 0x6F3F, 0x6EF2, 0x6F31, 0x6EEF, 0x6F32, 0x6ECC,
+};
+static const unsigned short euc_to_utf8_DF[] = {
+ 0x6F3E, 0x6F13, 0x6EF7, 0x6F86, 0x6F7A, 0x6F78, 0x6F81,
+ 0x6F80, 0x6F6F, 0x6F5B, 0x6FF3, 0x6F6D, 0x6F82, 0x6F7C, 0x6F58,
+ 0x6F8E, 0x6F91, 0x6FC2, 0x6F66, 0x6FB3, 0x6FA3, 0x6FA1, 0x6FA4,
+ 0x6FB9, 0x6FC6, 0x6FAA, 0x6FDF, 0x6FD5, 0x6FEC, 0x6FD4, 0x6FD8,
+ 0x6FF1, 0x6FEE, 0x6FDB, 0x7009, 0x700B, 0x6FFA, 0x7011, 0x7001,
+ 0x700F, 0x6FFE, 0x701B, 0x701A, 0x6F74, 0x701D, 0x7018, 0x701F,
+ 0x7030, 0x703E, 0x7032, 0x7051, 0x7063, 0x7099, 0x7092, 0x70AF,
+ 0x70F1, 0x70AC, 0x70B8, 0x70B3, 0x70AE, 0x70DF, 0x70CB, 0x70DD,
+ 0x70D9, 0x7109, 0x70FD, 0x711C, 0x7119, 0x7165, 0x7155, 0x7188,
+ 0x7166, 0x7162, 0x714C, 0x7156, 0x716C, 0x718F, 0x71FB, 0x7184,
+ 0x7195, 0x71A8, 0x71AC, 0x71D7, 0x71B9, 0x71BE, 0x71D2, 0x71C9,
+ 0x71D4, 0x71CE, 0x71E0, 0x71EC, 0x71E7, 0x71F5, 0x71FC,
+};
+static const unsigned short euc_to_utf8_E0[] = {
+ 0x71F9, 0x71FF, 0x720D, 0x7210, 0x721B, 0x7228, 0x722D,
+ 0x722C, 0x7230, 0x7232, 0x723B, 0x723C, 0x723F, 0x7240, 0x7246,
+ 0x724B, 0x7258, 0x7274, 0x727E, 0x7282, 0x7281, 0x7287, 0x7292,
+ 0x7296, 0x72A2, 0x72A7, 0x72B9, 0x72B2, 0x72C3, 0x72C6, 0x72C4,
+ 0x72CE, 0x72D2, 0x72E2, 0x72E0, 0x72E1, 0x72F9, 0x72F7, 0x500F,
+ 0x7317, 0x730A, 0x731C, 0x7316, 0x731D, 0x7334, 0x732F, 0x7329,
+ 0x7325, 0x733E, 0x734E, 0x734F, 0x9ED8, 0x7357, 0x736A, 0x7368,
+ 0x7370, 0x7378, 0x7375, 0x737B, 0x737A, 0x73C8, 0x73B3, 0x73CE,
+ 0x73BB, 0x73C0, 0x73E5, 0x73EE, 0x73DE, 0x74A2, 0x7405, 0x746F,
+ 0x7425, 0x73F8, 0x7432, 0x743A, 0x7455, 0x743F, 0x745F, 0x7459,
+ 0x7441, 0x745C, 0x7469, 0x7470, 0x7463, 0x746A, 0x7476, 0x747E,
+ 0x748B, 0x749E, 0x74A7, 0x74CA, 0x74CF, 0x74D4, 0x73F1,
+};
+static const unsigned short euc_to_utf8_E1[] = {
+ 0x74E0, 0x74E3, 0x74E7, 0x74E9, 0x74EE, 0x74F2, 0x74F0,
+ 0x74F1, 0x74F8, 0x74F7, 0x7504, 0x7503, 0x7505, 0x750C, 0x750E,
+ 0x750D, 0x7515, 0x7513, 0x751E, 0x7526, 0x752C, 0x753C, 0x7544,
+ 0x754D, 0x754A, 0x7549, 0x755B, 0x7546, 0x755A, 0x7569, 0x7564,
+ 0x7567, 0x756B, 0x756D, 0x7578, 0x7576, 0x7586, 0x7587, 0x7574,
+ 0x758A, 0x7589, 0x7582, 0x7594, 0x759A, 0x759D, 0x75A5, 0x75A3,
+ 0x75C2, 0x75B3, 0x75C3, 0x75B5, 0x75BD, 0x75B8, 0x75BC, 0x75B1,
+ 0x75CD, 0x75CA, 0x75D2, 0x75D9, 0x75E3, 0x75DE, 0x75FE, 0x75FF,
+ 0x75FC, 0x7601, 0x75F0, 0x75FA, 0x75F2, 0x75F3, 0x760B, 0x760D,
+ 0x7609, 0x761F, 0x7627, 0x7620, 0x7621, 0x7622, 0x7624, 0x7634,
+ 0x7630, 0x763B, 0x7647, 0x7648, 0x7646, 0x765C, 0x7658, 0x7661,
+ 0x7662, 0x7668, 0x7669, 0x766A, 0x7667, 0x766C, 0x7670,
+};
+static const unsigned short euc_to_utf8_E2[] = {
+ 0x7672, 0x7676, 0x7678, 0x767C, 0x7680, 0x7683, 0x7688,
+ 0x768B, 0x768E, 0x7696, 0x7693, 0x7699, 0x769A, 0x76B0, 0x76B4,
+ 0x76B8, 0x76B9, 0x76BA, 0x76C2, 0x76CD, 0x76D6, 0x76D2, 0x76DE,
+ 0x76E1, 0x76E5, 0x76E7, 0x76EA, 0x862F, 0x76FB, 0x7708, 0x7707,
+ 0x7704, 0x7729, 0x7724, 0x771E, 0x7725, 0x7726, 0x771B, 0x7737,
+ 0x7738, 0x7747, 0x775A, 0x7768, 0x776B, 0x775B, 0x7765, 0x777F,
+ 0x777E, 0x7779, 0x778E, 0x778B, 0x7791, 0x77A0, 0x779E, 0x77B0,
+ 0x77B6, 0x77B9, 0x77BF, 0x77BC, 0x77BD, 0x77BB, 0x77C7, 0x77CD,
+ 0x77D7, 0x77DA, 0x77DC, 0x77E3, 0x77EE, 0x77FC, 0x780C, 0x7812,
+ 0x7926, 0x7820, 0x792A, 0x7845, 0x788E, 0x7874, 0x7886, 0x787C,
+ 0x789A, 0x788C, 0x78A3, 0x78B5, 0x78AA, 0x78AF, 0x78D1, 0x78C6,
+ 0x78CB, 0x78D4, 0x78BE, 0x78BC, 0x78C5, 0x78CA, 0x78EC,
+};
+static const unsigned short euc_to_utf8_E3[] = {
+ 0x78E7, 0x78DA, 0x78FD, 0x78F4, 0x7907, 0x7912, 0x7911,
+ 0x7919, 0x792C, 0x792B, 0x7940, 0x7960, 0x7957, 0x795F, 0x795A,
+ 0x7955, 0x7953, 0x797A, 0x797F, 0x798A, 0x799D, 0x79A7, 0x9F4B,
+ 0x79AA, 0x79AE, 0x79B3, 0x79B9, 0x79BA, 0x79C9, 0x79D5, 0x79E7,
+ 0x79EC, 0x79E1, 0x79E3, 0x7A08, 0x7A0D, 0x7A18, 0x7A19, 0x7A20,
+ 0x7A1F, 0x7980, 0x7A31, 0x7A3B, 0x7A3E, 0x7A37, 0x7A43, 0x7A57,
+ 0x7A49, 0x7A61, 0x7A62, 0x7A69, 0x9F9D, 0x7A70, 0x7A79, 0x7A7D,
+ 0x7A88, 0x7A97, 0x7A95, 0x7A98, 0x7A96, 0x7AA9, 0x7AC8, 0x7AB0,
+ 0x7AB6, 0x7AC5, 0x7AC4, 0x7ABF, 0x9083, 0x7AC7, 0x7ACA, 0x7ACD,
+ 0x7ACF, 0x7AD5, 0x7AD3, 0x7AD9, 0x7ADA, 0x7ADD, 0x7AE1, 0x7AE2,
+ 0x7AE6, 0x7AED, 0x7AF0, 0x7B02, 0x7B0F, 0x7B0A, 0x7B06, 0x7B33,
+ 0x7B18, 0x7B19, 0x7B1E, 0x7B35, 0x7B28, 0x7B36, 0x7B50,
+};
+static const unsigned short euc_to_utf8_E4[] = {
+ 0x7B7A, 0x7B04, 0x7B4D, 0x7B0B, 0x7B4C, 0x7B45, 0x7B75,
+ 0x7B65, 0x7B74, 0x7B67, 0x7B70, 0x7B71, 0x7B6C, 0x7B6E, 0x7B9D,
+ 0x7B98, 0x7B9F, 0x7B8D, 0x7B9C, 0x7B9A, 0x7B8B, 0x7B92, 0x7B8F,
+ 0x7B5D, 0x7B99, 0x7BCB, 0x7BC1, 0x7BCC, 0x7BCF, 0x7BB4, 0x7BC6,
+ 0x7BDD, 0x7BE9, 0x7C11, 0x7C14, 0x7BE6, 0x7BE5, 0x7C60, 0x7C00,
+ 0x7C07, 0x7C13, 0x7BF3, 0x7BF7, 0x7C17, 0x7C0D, 0x7BF6, 0x7C23,
+ 0x7C27, 0x7C2A, 0x7C1F, 0x7C37, 0x7C2B, 0x7C3D, 0x7C4C, 0x7C43,
+ 0x7C54, 0x7C4F, 0x7C40, 0x7C50, 0x7C58, 0x7C5F, 0x7C64, 0x7C56,
+ 0x7C65, 0x7C6C, 0x7C75, 0x7C83, 0x7C90, 0x7CA4, 0x7CAD, 0x7CA2,
+ 0x7CAB, 0x7CA1, 0x7CA8, 0x7CB3, 0x7CB2, 0x7CB1, 0x7CAE, 0x7CB9,
+ 0x7CBD, 0x7CC0, 0x7CC5, 0x7CC2, 0x7CD8, 0x7CD2, 0x7CDC, 0x7CE2,
+ 0x9B3B, 0x7CEF, 0x7CF2, 0x7CF4, 0x7CF6, 0x7CFA, 0x7D06,
+};
+static const unsigned short euc_to_utf8_E5[] = {
+ 0x7D02, 0x7D1C, 0x7D15, 0x7D0A, 0x7D45, 0x7D4B, 0x7D2E,
+ 0x7D32, 0x7D3F, 0x7D35, 0x7D46, 0x7D73, 0x7D56, 0x7D4E, 0x7D72,
+ 0x7D68, 0x7D6E, 0x7D4F, 0x7D63, 0x7D93, 0x7D89, 0x7D5B, 0x7D8F,
+ 0x7D7D, 0x7D9B, 0x7DBA, 0x7DAE, 0x7DA3, 0x7DB5, 0x7DC7, 0x7DBD,
+ 0x7DAB, 0x7E3D, 0x7DA2, 0x7DAF, 0x7DDC, 0x7DB8, 0x7D9F, 0x7DB0,
+ 0x7DD8, 0x7DDD, 0x7DE4, 0x7DDE, 0x7DFB, 0x7DF2, 0x7DE1, 0x7E05,
+ 0x7E0A, 0x7E23, 0x7E21, 0x7E12, 0x7E31, 0x7E1F, 0x7E09, 0x7E0B,
+ 0x7E22, 0x7E46, 0x7E66, 0x7E3B, 0x7E35, 0x7E39, 0x7E43, 0x7E37,
+ 0x7E32, 0x7E3A, 0x7E67, 0x7E5D, 0x7E56, 0x7E5E, 0x7E59, 0x7E5A,
+ 0x7E79, 0x7E6A, 0x7E69, 0x7E7C, 0x7E7B, 0x7E83, 0x7DD5, 0x7E7D,
+ 0x8FAE, 0x7E7F, 0x7E88, 0x7E89, 0x7E8C, 0x7E92, 0x7E90, 0x7E93,
+ 0x7E94, 0x7E96, 0x7E8E, 0x7E9B, 0x7E9C, 0x7F38, 0x7F3A,
+};
+static const unsigned short euc_to_utf8_E6[] = {
+ 0x7F45, 0x7F4C, 0x7F4D, 0x7F4E, 0x7F50, 0x7F51, 0x7F55,
+ 0x7F54, 0x7F58, 0x7F5F, 0x7F60, 0x7F68, 0x7F69, 0x7F67, 0x7F78,
+ 0x7F82, 0x7F86, 0x7F83, 0x7F88, 0x7F87, 0x7F8C, 0x7F94, 0x7F9E,
+ 0x7F9D, 0x7F9A, 0x7FA3, 0x7FAF, 0x7FB2, 0x7FB9, 0x7FAE, 0x7FB6,
+ 0x7FB8, 0x8B71, 0x7FC5, 0x7FC6, 0x7FCA, 0x7FD5, 0x7FD4, 0x7FE1,
+ 0x7FE6, 0x7FE9, 0x7FF3, 0x7FF9, 0x98DC, 0x8006, 0x8004, 0x800B,
+ 0x8012, 0x8018, 0x8019, 0x801C, 0x8021, 0x8028, 0x803F, 0x803B,
+ 0x804A, 0x8046, 0x8052, 0x8058, 0x805A, 0x805F, 0x8062, 0x8068,
+ 0x8073, 0x8072, 0x8070, 0x8076, 0x8079, 0x807D, 0x807F, 0x8084,
+ 0x8086, 0x8085, 0x809B, 0x8093, 0x809A, 0x80AD, 0x5190, 0x80AC,
+ 0x80DB, 0x80E5, 0x80D9, 0x80DD, 0x80C4, 0x80DA, 0x80D6, 0x8109,
+ 0x80EF, 0x80F1, 0x811B, 0x8129, 0x8123, 0x812F, 0x814B,
+};
+static const unsigned short euc_to_utf8_E7[] = {
+ 0x968B, 0x8146, 0x813E, 0x8153, 0x8151, 0x80FC, 0x8171,
+ 0x816E, 0x8165, 0x8166, 0x8174, 0x8183, 0x8188, 0x818A, 0x8180,
+ 0x8182, 0x81A0, 0x8195, 0x81A4, 0x81A3, 0x815F, 0x8193, 0x81A9,
+ 0x81B0, 0x81B5, 0x81BE, 0x81B8, 0x81BD, 0x81C0, 0x81C2, 0x81BA,
+ 0x81C9, 0x81CD, 0x81D1, 0x81D9, 0x81D8, 0x81C8, 0x81DA, 0x81DF,
+ 0x81E0, 0x81E7, 0x81FA, 0x81FB, 0x81FE, 0x8201, 0x8202, 0x8205,
+ 0x8207, 0x820A, 0x820D, 0x8210, 0x8216, 0x8229, 0x822B, 0x8238,
+ 0x8233, 0x8240, 0x8259, 0x8258, 0x825D, 0x825A, 0x825F, 0x8264,
+ 0x8262, 0x8268, 0x826A, 0x826B, 0x822E, 0x8271, 0x8277, 0x8278,
+ 0x827E, 0x828D, 0x8292, 0x82AB, 0x829F, 0x82BB, 0x82AC, 0x82E1,
+ 0x82E3, 0x82DF, 0x82D2, 0x82F4, 0x82F3, 0x82FA, 0x8393, 0x8303,
+ 0x82FB, 0x82F9, 0x82DE, 0x8306, 0x82DC, 0x8309, 0x82D9,
+};
+static const unsigned short euc_to_utf8_E8[] = {
+ 0x8335, 0x8334, 0x8316, 0x8332, 0x8331, 0x8340, 0x8339,
+ 0x8350, 0x8345, 0x832F, 0x832B, 0x8317, 0x8318, 0x8385, 0x839A,
+ 0x83AA, 0x839F, 0x83A2, 0x8396, 0x8323, 0x838E, 0x8387, 0x838A,
+ 0x837C, 0x83B5, 0x8373, 0x8375, 0x83A0, 0x8389, 0x83A8, 0x83F4,
+ 0x8413, 0x83EB, 0x83CE, 0x83FD, 0x8403, 0x83D8, 0x840B, 0x83C1,
+ 0x83F7, 0x8407, 0x83E0, 0x83F2, 0x840D, 0x8422, 0x8420, 0x83BD,
+ 0x8438, 0x8506, 0x83FB, 0x846D, 0x842A, 0x843C, 0x855A, 0x8484,
+ 0x8477, 0x846B, 0x84AD, 0x846E, 0x8482, 0x8469, 0x8446, 0x842C,
+ 0x846F, 0x8479, 0x8435, 0x84CA, 0x8462, 0x84B9, 0x84BF, 0x849F,
+ 0x84D9, 0x84CD, 0x84BB, 0x84DA, 0x84D0, 0x84C1, 0x84C6, 0x84D6,
+ 0x84A1, 0x8521, 0x84FF, 0x84F4, 0x8517, 0x8518, 0x852C, 0x851F,
+ 0x8515, 0x8514, 0x84FC, 0x8540, 0x8563, 0x8558, 0x8548,
+};
+static const unsigned short euc_to_utf8_E9[] = {
+ 0x8541, 0x8602, 0x854B, 0x8555, 0x8580, 0x85A4, 0x8588,
+ 0x8591, 0x858A, 0x85A8, 0x856D, 0x8594, 0x859B, 0x85EA, 0x8587,
+ 0x859C, 0x8577, 0x857E, 0x8590, 0x85C9, 0x85BA, 0x85CF, 0x85B9,
+ 0x85D0, 0x85D5, 0x85DD, 0x85E5, 0x85DC, 0x85F9, 0x860A, 0x8613,
+ 0x860B, 0x85FE, 0x85FA, 0x8606, 0x8622, 0x861A, 0x8630, 0x863F,
+ 0x864D, 0x4E55, 0x8654, 0x865F, 0x8667, 0x8671, 0x8693, 0x86A3,
+ 0x86A9, 0x86AA, 0x868B, 0x868C, 0x86B6, 0x86AF, 0x86C4, 0x86C6,
+ 0x86B0, 0x86C9, 0x8823, 0x86AB, 0x86D4, 0x86DE, 0x86E9, 0x86EC,
+ 0x86DF, 0x86DB, 0x86EF, 0x8712, 0x8706, 0x8708, 0x8700, 0x8703,
+ 0x86FB, 0x8711, 0x8709, 0x870D, 0x86F9, 0x870A, 0x8734, 0x873F,
+ 0x8737, 0x873B, 0x8725, 0x8729, 0x871A, 0x8760, 0x875F, 0x8778,
+ 0x874C, 0x874E, 0x8774, 0x8757, 0x8768, 0x876E, 0x8759,
+};
+static const unsigned short euc_to_utf8_EA[] = {
+ 0x8753, 0x8763, 0x876A, 0x8805, 0x87A2, 0x879F, 0x8782,
+ 0x87AF, 0x87CB, 0x87BD, 0x87C0, 0x87D0, 0x96D6, 0x87AB, 0x87C4,
+ 0x87B3, 0x87C7, 0x87C6, 0x87BB, 0x87EF, 0x87F2, 0x87E0, 0x880F,
+ 0x880D, 0x87FE, 0x87F6, 0x87F7, 0x880E, 0x87D2, 0x8811, 0x8816,
+ 0x8815, 0x8822, 0x8821, 0x8831, 0x8836, 0x8839, 0x8827, 0x883B,
+ 0x8844, 0x8842, 0x8852, 0x8859, 0x885E, 0x8862, 0x886B, 0x8881,
+ 0x887E, 0x889E, 0x8875, 0x887D, 0x88B5, 0x8872, 0x8882, 0x8897,
+ 0x8892, 0x88AE, 0x8899, 0x88A2, 0x888D, 0x88A4, 0x88B0, 0x88BF,
+ 0x88B1, 0x88C3, 0x88C4, 0x88D4, 0x88D8, 0x88D9, 0x88DD, 0x88F9,
+ 0x8902, 0x88FC, 0x88F4, 0x88E8, 0x88F2, 0x8904, 0x890C, 0x890A,
+ 0x8913, 0x8943, 0x891E, 0x8925, 0x892A, 0x892B, 0x8941, 0x8944,
+ 0x893B, 0x8936, 0x8938, 0x894C, 0x891D, 0x8960, 0x895E,
+};
+static const unsigned short euc_to_utf8_EB[] = {
+ 0x8966, 0x8964, 0x896D, 0x896A, 0x896F, 0x8974, 0x8977,
+ 0x897E, 0x8983, 0x8988, 0x898A, 0x8993, 0x8998, 0x89A1, 0x89A9,
+ 0x89A6, 0x89AC, 0x89AF, 0x89B2, 0x89BA, 0x89BD, 0x89BF, 0x89C0,
+ 0x89DA, 0x89DC, 0x89DD, 0x89E7, 0x89F4, 0x89F8, 0x8A03, 0x8A16,
+ 0x8A10, 0x8A0C, 0x8A1B, 0x8A1D, 0x8A25, 0x8A36, 0x8A41, 0x8A5B,
+ 0x8A52, 0x8A46, 0x8A48, 0x8A7C, 0x8A6D, 0x8A6C, 0x8A62, 0x8A85,
+ 0x8A82, 0x8A84, 0x8AA8, 0x8AA1, 0x8A91, 0x8AA5, 0x8AA6, 0x8A9A,
+ 0x8AA3, 0x8AC4, 0x8ACD, 0x8AC2, 0x8ADA, 0x8AEB, 0x8AF3, 0x8AE7,
+ 0x8AE4, 0x8AF1, 0x8B14, 0x8AE0, 0x8AE2, 0x8AF7, 0x8ADE, 0x8ADB,
+ 0x8B0C, 0x8B07, 0x8B1A, 0x8AE1, 0x8B16, 0x8B10, 0x8B17, 0x8B20,
+ 0x8B33, 0x97AB, 0x8B26, 0x8B2B, 0x8B3E, 0x8B28, 0x8B41, 0x8B4C,
+ 0x8B4F, 0x8B4E, 0x8B49, 0x8B56, 0x8B5B, 0x8B5A, 0x8B6B,
+};
+static const unsigned short euc_to_utf8_EC[] = {
+ 0x8B5F, 0x8B6C, 0x8B6F, 0x8B74, 0x8B7D, 0x8B80, 0x8B8C,
+ 0x8B8E, 0x8B92, 0x8B93, 0x8B96, 0x8B99, 0x8B9A, 0x8C3A, 0x8C41,
+ 0x8C3F, 0x8C48, 0x8C4C, 0x8C4E, 0x8C50, 0x8C55, 0x8C62, 0x8C6C,
+ 0x8C78, 0x8C7A, 0x8C82, 0x8C89, 0x8C85, 0x8C8A, 0x8C8D, 0x8C8E,
+ 0x8C94, 0x8C7C, 0x8C98, 0x621D, 0x8CAD, 0x8CAA, 0x8CBD, 0x8CB2,
+ 0x8CB3, 0x8CAE, 0x8CB6, 0x8CC8, 0x8CC1, 0x8CE4, 0x8CE3, 0x8CDA,
+ 0x8CFD, 0x8CFA, 0x8CFB, 0x8D04, 0x8D05, 0x8D0A, 0x8D07, 0x8D0F,
+ 0x8D0D, 0x8D10, 0x9F4E, 0x8D13, 0x8CCD, 0x8D14, 0x8D16, 0x8D67,
+ 0x8D6D, 0x8D71, 0x8D73, 0x8D81, 0x8D99, 0x8DC2, 0x8DBE, 0x8DBA,
+ 0x8DCF, 0x8DDA, 0x8DD6, 0x8DCC, 0x8DDB, 0x8DCB, 0x8DEA, 0x8DEB,
+ 0x8DDF, 0x8DE3, 0x8DFC, 0x8E08, 0x8E09, 0x8DFF, 0x8E1D, 0x8E1E,
+ 0x8E10, 0x8E1F, 0x8E42, 0x8E35, 0x8E30, 0x8E34, 0x8E4A,
+};
+static const unsigned short euc_to_utf8_ED[] = {
+ 0x8E47, 0x8E49, 0x8E4C, 0x8E50, 0x8E48, 0x8E59, 0x8E64,
+ 0x8E60, 0x8E2A, 0x8E63, 0x8E55, 0x8E76, 0x8E72, 0x8E7C, 0x8E81,
+ 0x8E87, 0x8E85, 0x8E84, 0x8E8B, 0x8E8A, 0x8E93, 0x8E91, 0x8E94,
+ 0x8E99, 0x8EAA, 0x8EA1, 0x8EAC, 0x8EB0, 0x8EC6, 0x8EB1, 0x8EBE,
+ 0x8EC5, 0x8EC8, 0x8ECB, 0x8EDB, 0x8EE3, 0x8EFC, 0x8EFB, 0x8EEB,
+ 0x8EFE, 0x8F0A, 0x8F05, 0x8F15, 0x8F12, 0x8F19, 0x8F13, 0x8F1C,
+ 0x8F1F, 0x8F1B, 0x8F0C, 0x8F26, 0x8F33, 0x8F3B, 0x8F39, 0x8F45,
+ 0x8F42, 0x8F3E, 0x8F4C, 0x8F49, 0x8F46, 0x8F4E, 0x8F57, 0x8F5C,
+ 0x8F62, 0x8F63, 0x8F64, 0x8F9C, 0x8F9F, 0x8FA3, 0x8FAD, 0x8FAF,
+ 0x8FB7, 0x8FDA, 0x8FE5, 0x8FE2, 0x8FEA, 0x8FEF, 0x9087, 0x8FF4,
+ 0x9005, 0x8FF9, 0x8FFA, 0x9011, 0x9015, 0x9021, 0x900D, 0x901E,
+ 0x9016, 0x900B, 0x9027, 0x9036, 0x9035, 0x9039, 0x8FF8,
+};
+static const unsigned short euc_to_utf8_EE[] = {
+ 0x904F, 0x9050, 0x9051, 0x9052, 0x900E, 0x9049, 0x903E,
+ 0x9056, 0x9058, 0x905E, 0x9068, 0x906F, 0x9076, 0x96A8, 0x9072,
+ 0x9082, 0x907D, 0x9081, 0x9080, 0x908A, 0x9089, 0x908F, 0x90A8,
+ 0x90AF, 0x90B1, 0x90B5, 0x90E2, 0x90E4, 0x6248, 0x90DB, 0x9102,
+ 0x9112, 0x9119, 0x9132, 0x9130, 0x914A, 0x9156, 0x9158, 0x9163,
+ 0x9165, 0x9169, 0x9173, 0x9172, 0x918B, 0x9189, 0x9182, 0x91A2,
+ 0x91AB, 0x91AF, 0x91AA, 0x91B5, 0x91B4, 0x91BA, 0x91C0, 0x91C1,
+ 0x91C9, 0x91CB, 0x91D0, 0x91D6, 0x91DF, 0x91E1, 0x91DB, 0x91FC,
+ 0x91F5, 0x91F6, 0x921E, 0x91FF, 0x9214, 0x922C, 0x9215, 0x9211,
+ 0x925E, 0x9257, 0x9245, 0x9249, 0x9264, 0x9248, 0x9295, 0x923F,
+ 0x924B, 0x9250, 0x929C, 0x9296, 0x9293, 0x929B, 0x925A, 0x92CF,
+ 0x92B9, 0x92B7, 0x92E9, 0x930F, 0x92FA, 0x9344, 0x932E,
+};
+static const unsigned short euc_to_utf8_EF[] = {
+ 0x9319, 0x9322, 0x931A, 0x9323, 0x933A, 0x9335, 0x933B,
+ 0x935C, 0x9360, 0x937C, 0x936E, 0x9356, 0x93B0, 0x93AC, 0x93AD,
+ 0x9394, 0x93B9, 0x93D6, 0x93D7, 0x93E8, 0x93E5, 0x93D8, 0x93C3,
+ 0x93DD, 0x93D0, 0x93C8, 0x93E4, 0x941A, 0x9414, 0x9413, 0x9403,
+ 0x9407, 0x9410, 0x9436, 0x942B, 0x9435, 0x9421, 0x943A, 0x9441,
+ 0x9452, 0x9444, 0x945B, 0x9460, 0x9462, 0x945E, 0x946A, 0x9229,
+ 0x9470, 0x9475, 0x9477, 0x947D, 0x945A, 0x947C, 0x947E, 0x9481,
+ 0x947F, 0x9582, 0x9587, 0x958A, 0x9594, 0x9596, 0x9598, 0x9599,
+ 0x95A0, 0x95A8, 0x95A7, 0x95AD, 0x95BC, 0x95BB, 0x95B9, 0x95BE,
+ 0x95CA, 0x6FF6, 0x95C3, 0x95CD, 0x95CC, 0x95D5, 0x95D4, 0x95D6,
+ 0x95DC, 0x95E1, 0x95E5, 0x95E2, 0x9621, 0x9628, 0x962E, 0x962F,
+ 0x9642, 0x964C, 0x964F, 0x964B, 0x9677, 0x965C, 0x965E,
+};
+static const unsigned short euc_to_utf8_F0[] = {
+ 0x965D, 0x965F, 0x9666, 0x9672, 0x966C, 0x968D, 0x9698,
+ 0x9695, 0x9697, 0x96AA, 0x96A7, 0x96B1, 0x96B2, 0x96B0, 0x96B4,
+ 0x96B6, 0x96B8, 0x96B9, 0x96CE, 0x96CB, 0x96C9, 0x96CD, 0x894D,
+ 0x96DC, 0x970D, 0x96D5, 0x96F9, 0x9704, 0x9706, 0x9708, 0x9713,
+ 0x970E, 0x9711, 0x970F, 0x9716, 0x9719, 0x9724, 0x972A, 0x9730,
+ 0x9739, 0x973D, 0x973E, 0x9744, 0x9746, 0x9748, 0x9742, 0x9749,
+ 0x975C, 0x9760, 0x9764, 0x9766, 0x9768, 0x52D2, 0x976B, 0x9771,
+ 0x9779, 0x9785, 0x977C, 0x9781, 0x977A, 0x9786, 0x978B, 0x978F,
+ 0x9790, 0x979C, 0x97A8, 0x97A6, 0x97A3, 0x97B3, 0x97B4, 0x97C3,
+ 0x97C6, 0x97C8, 0x97CB, 0x97DC, 0x97ED, 0x9F4F, 0x97F2, 0x7ADF,
+ 0x97F6, 0x97F5, 0x980F, 0x980C, 0x9838, 0x9824, 0x9821, 0x9837,
+ 0x983D, 0x9846, 0x984F, 0x984B, 0x986B, 0x986F, 0x9870,
+};
+static const unsigned short euc_to_utf8_F1[] = {
+ 0x9871, 0x9874, 0x9873, 0x98AA, 0x98AF, 0x98B1, 0x98B6,
+ 0x98C4, 0x98C3, 0x98C6, 0x98E9, 0x98EB, 0x9903, 0x9909, 0x9912,
+ 0x9914, 0x9918, 0x9921, 0x991D, 0x991E, 0x9924, 0x9920, 0x992C,
+ 0x992E, 0x993D, 0x993E, 0x9942, 0x9949, 0x9945, 0x9950, 0x994B,
+ 0x9951, 0x9952, 0x994C, 0x9955, 0x9997, 0x9998, 0x99A5, 0x99AD,
+ 0x99AE, 0x99BC, 0x99DF, 0x99DB, 0x99DD, 0x99D8, 0x99D1, 0x99ED,
+ 0x99EE, 0x99F1, 0x99F2, 0x99FB, 0x99F8, 0x9A01, 0x9A0F, 0x9A05,
+ 0x99E2, 0x9A19, 0x9A2B, 0x9A37, 0x9A45, 0x9A42, 0x9A40, 0x9A43,
+ 0x9A3E, 0x9A55, 0x9A4D, 0x9A5B, 0x9A57, 0x9A5F, 0x9A62, 0x9A65,
+ 0x9A64, 0x9A69, 0x9A6B, 0x9A6A, 0x9AAD, 0x9AB0, 0x9ABC, 0x9AC0,
+ 0x9ACF, 0x9AD1, 0x9AD3, 0x9AD4, 0x9ADE, 0x9ADF, 0x9AE2, 0x9AE3,
+ 0x9AE6, 0x9AEF, 0x9AEB, 0x9AEE, 0x9AF4, 0x9AF1, 0x9AF7,
+};
+static const unsigned short euc_to_utf8_F2[] = {
+ 0x9AFB, 0x9B06, 0x9B18, 0x9B1A, 0x9B1F, 0x9B22, 0x9B23,
+ 0x9B25, 0x9B27, 0x9B28, 0x9B29, 0x9B2A, 0x9B2E, 0x9B2F, 0x9B32,
+ 0x9B44, 0x9B43, 0x9B4F, 0x9B4D, 0x9B4E, 0x9B51, 0x9B58, 0x9B74,
+ 0x9B93, 0x9B83, 0x9B91, 0x9B96, 0x9B97, 0x9B9F, 0x9BA0, 0x9BA8,
+ 0x9BB4, 0x9BC0, 0x9BCA, 0x9BB9, 0x9BC6, 0x9BCF, 0x9BD1, 0x9BD2,
+ 0x9BE3, 0x9BE2, 0x9BE4, 0x9BD4, 0x9BE1, 0x9C3A, 0x9BF2, 0x9BF1,
+ 0x9BF0, 0x9C15, 0x9C14, 0x9C09, 0x9C13, 0x9C0C, 0x9C06, 0x9C08,
+ 0x9C12, 0x9C0A, 0x9C04, 0x9C2E, 0x9C1B, 0x9C25, 0x9C24, 0x9C21,
+ 0x9C30, 0x9C47, 0x9C32, 0x9C46, 0x9C3E, 0x9C5A, 0x9C60, 0x9C67,
+ 0x9C76, 0x9C78, 0x9CE7, 0x9CEC, 0x9CF0, 0x9D09, 0x9D08, 0x9CEB,
+ 0x9D03, 0x9D06, 0x9D2A, 0x9D26, 0x9DAF, 0x9D23, 0x9D1F, 0x9D44,
+ 0x9D15, 0x9D12, 0x9D41, 0x9D3F, 0x9D3E, 0x9D46, 0x9D48,
+};
+static const unsigned short euc_to_utf8_F3[] = {
+ 0x9D5D, 0x9D5E, 0x9D64, 0x9D51, 0x9D50, 0x9D59, 0x9D72,
+ 0x9D89, 0x9D87, 0x9DAB, 0x9D6F, 0x9D7A, 0x9D9A, 0x9DA4, 0x9DA9,
+ 0x9DB2, 0x9DC4, 0x9DC1, 0x9DBB, 0x9DB8, 0x9DBA, 0x9DC6, 0x9DCF,
+ 0x9DC2, 0x9DD9, 0x9DD3, 0x9DF8, 0x9DE6, 0x9DED, 0x9DEF, 0x9DFD,
+ 0x9E1A, 0x9E1B, 0x9E1E, 0x9E75, 0x9E79, 0x9E7D, 0x9E81, 0x9E88,
+ 0x9E8B, 0x9E8C, 0x9E92, 0x9E95, 0x9E91, 0x9E9D, 0x9EA5, 0x9EA9,
+ 0x9EB8, 0x9EAA, 0x9EAD, 0x9761, 0x9ECC, 0x9ECE, 0x9ECF, 0x9ED0,
+ 0x9ED4, 0x9EDC, 0x9EDE, 0x9EDD, 0x9EE0, 0x9EE5, 0x9EE8, 0x9EEF,
+ 0x9EF4, 0x9EF6, 0x9EF7, 0x9EF9, 0x9EFB, 0x9EFC, 0x9EFD, 0x9F07,
+ 0x9F08, 0x76B7, 0x9F15, 0x9F21, 0x9F2C, 0x9F3E, 0x9F4A, 0x9F52,
+ 0x9F54, 0x9F63, 0x9F5F, 0x9F60, 0x9F61, 0x9F66, 0x9F67, 0x9F6C,
+ 0x9F6A, 0x9F77, 0x9F72, 0x9F76, 0x9F95, 0x9F9C, 0x9FA0,
+};
+static const unsigned short euc_to_utf8_F4[] = {
+ 0x582F, 0x69C7, 0x9059, 0x7464, 0x51DC, 0x7199, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0,
+};
+static const unsigned short euc_to_utf8_F4_x0213[] = {
+ 0x582F, 0x69C7, 0x9059, 0x7464, 0x51DC, 0x7199, 0x5653,
+ 0x5DE2, 0x5E14, 0x5E18, 0x5E58, 0x5E5E, 0x5EBE, 0xF928, 0x5ECB,
+ 0x5EF9, 0x5F00, 0x5F02, 0x5F07, 0x5F1D, 0x5F23, 0x5F34, 0x5F36,
+ 0x5F3D, 0x5F40, 0x5F45, 0x5F54, 0x5F58, 0x5F64, 0x5F67, 0x5F7D,
+ 0x5F89, 0x5F9C, 0x5FA7, 0x5FAF, 0x5FB5, 0x5FB7, 0x5FC9, 0x5FDE,
+ 0x5FE1, 0x5FE9, 0x600D, 0x6014, 0x6018, 0x6033, 0x6035, 0x6047,
+ 0xFA3D, 0x609D, 0x609E, 0x60CB, 0x60D4, 0x60D5, 0x60DD, 0x60F8,
+ 0x611C, 0x612B, 0x6130, 0x6137, 0xFA3E, 0x618D, 0xFA3F, 0x61BC,
+ 0x61B9, 0xFA40, 0x6222, 0x623E, 0x6243, 0x6256, 0x625A, 0x626F,
+ 0x6285, 0x62C4, 0x62D6, 0x62FC, 0x630A, 0x6318, 0x6339, 0x6343,
+ 0x6365, 0x637C, 0x63E5, 0x63ED, 0x63F5, 0x6410, 0x6414, 0x6422,
+ 0x6479, 0x6451, 0x6460, 0x646D, 0x64CE, 0x64BE, 0x64BF,
+};
+static const unsigned short euc_to_utf8_F5[] = {
+ 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0xFE33, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0xFE31, 0, 0,
+ 0, 0, 0, 0, 0, 0xFE30, 0, 0,
+ 0, 0, 0xFE35, 0xFE36, 0xFE39, 0xFE3A, 0, 0,
+ 0xFE37, 0xFE38, 0xFE3F, 0xFE40, 0xFE3D, 0xFE3E, 0xFE41, 0xFE42,
+ 0xFE43, 0xFE44, 0xFE3B, 0xFE3C, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0,
+};
+static const unsigned short euc_to_utf8_F5_x0213[] = {
+ 0x64C4, 0x64CA, 0x64D0, 0x64F7, 0x64FB, 0x6522, 0x6529,
+ 0xFA41, 0x6567, 0x659D, 0xFA42, 0x6600, 0x6609, 0x6615, 0x661E,
+ 0x663A, 0x6622, 0x6624, 0x662B, 0x6630, 0x6631, 0x6633, 0x66FB,
+ 0x6648, 0x664C, 0xD84C /*0xDDC4*/, 0x6659, 0x665A, 0x6661, 0x6665, 0x6673,
+ 0x6677, 0x6678, 0x668D, 0xFA43, 0x66A0, 0x66B2, 0x66BB, 0x66C6,
+ 0x66C8, 0x3B22, 0x66DB, 0x66E8, 0x66FA, 0x6713, 0xF929, 0x6733,
+ 0x6766, 0x6747, 0x6748, 0x677B, 0x6781, 0x6793, 0x6798, 0x679B,
+ 0x67BB, 0x67F9, 0x67C0, 0x67D7, 0x67FC, 0x6801, 0x6852, 0x681D,
+ 0x682C, 0x6831, 0x685B, 0x6872, 0x6875, 0xFA44, 0x68A3, 0x68A5,
+ 0x68B2, 0x68C8, 0x68D0, 0x68E8, 0x68ED, 0x68F0, 0x68F1, 0x68FC,
+ 0x690A, 0x6949, 0xD84D /*0xDDC4*/, 0x6935, 0x6942, 0x6957, 0x6963, 0x6964,
+ 0x6968, 0x6980, 0xFA14, 0x69A5, 0x69AD, 0x69CF, 0x3BB6,
+};
+static const unsigned short euc_to_utf8_F6_x0213[] = {
+ 0x3BC3, 0x69E2, 0x69E9, 0x69EA, 0x69F5, 0x69F6, 0x6A0F,
+ 0x6A15, 0xD84D /*0xDF3F*/, 0x6A3B, 0x6A3E, 0x6A45, 0x6A50, 0x6A56, 0x6A5B,
+ 0x6A6B, 0x6A73, 0xD84D /*0xDF63*/, 0x6A89, 0x6A94, 0x6A9D, 0x6A9E, 0x6AA5,
+ 0x6AE4, 0x6AE7, 0x3C0F, 0xF91D, 0x6B1B, 0x6B1E, 0x6B2C, 0x6B35,
+ 0x6B46, 0x6B56, 0x6B60, 0x6B65, 0x6B67, 0x6B77, 0x6B82, 0x6BA9,
+ 0x6BAD, 0xF970, 0x6BCF, 0x6BD6, 0x6BD7, 0x6BFF, 0x6C05, 0x6C10,
+ 0x6C33, 0x6C59, 0x6C5C, 0x6CAA, 0x6C74, 0x6C76, 0x6C85, 0x6C86,
+ 0x6C98, 0x6C9C, 0x6CFB, 0x6CC6, 0x6CD4, 0x6CE0, 0x6CEB, 0x6CEE,
+ 0xD84F /*0xDCFE*/, 0x6D04, 0x6D0E, 0x6D2E, 0x6D31, 0x6D39, 0x6D3F, 0x6D58,
+ 0x6D65, 0xFA45, 0x6D82, 0x6D87, 0x6D89, 0x6D94, 0x6DAA, 0x6DAC,
+ 0x6DBF, 0x6DC4, 0x6DD6, 0x6DDA, 0x6DDB, 0x6DDD, 0x6DFC, 0xFA46,
+ 0x6E34, 0x6E44, 0x6E5C, 0x6E5E, 0x6EAB, 0x6EB1, 0x6EC1,
+};
+static const unsigned short euc_to_utf8_F7_x0213[] = {
+ 0x6EC7, 0x6ECE, 0x6F10, 0x6F1A, 0xFA47, 0x6F2A, 0x6F2F,
+ 0x6F33, 0x6F51, 0x6F59, 0x6F5E, 0x6F61, 0x6F62, 0x6F7E, 0x6F88,
+ 0x6F8C, 0x6F8D, 0x6F94, 0x6FA0, 0x6FA7, 0x6FB6, 0x6FBC, 0x6FC7,
+ 0x6FCA, 0x6FF9, 0x6FF0, 0x6FF5, 0x7005, 0x7006, 0x7028, 0x704A,
+ 0x705D, 0x705E, 0x704E, 0x7064, 0x7075, 0x7085, 0x70A4, 0x70AB,
+ 0x70B7, 0x70D4, 0x70D8, 0x70E4, 0x710F, 0x712B, 0x711E, 0x7120,
+ 0x712E, 0x7130, 0x7146, 0x7147, 0x7151, 0xFA48, 0x7152, 0x715C,
+ 0x7160, 0x7168, 0xFA15, 0x7185, 0x7187, 0x7192, 0x71C1, 0x71BA,
+ 0x71C4, 0x71FE, 0x7200, 0x7215, 0x7255, 0x7256, 0x3E3F, 0x728D,
+ 0x729B, 0x72BE, 0x72C0, 0x72FB, 0xD851 /*0xDFF1*/, 0x7327, 0x7328, 0xFA16,
+ 0x7350, 0x7366, 0x737C, 0x7395, 0x739F, 0x73A0, 0x73A2, 0x73A6,
+ 0x73AB, 0x73C9, 0x73CF, 0x73D6, 0x73D9, 0x73E3, 0x73E9,
+};
+static const unsigned short euc_to_utf8_F8_x0213[] = {
+ 0x7407, 0x740A, 0x741A, 0x741B, 0xFA4A, 0x7426, 0x7428,
+ 0x742A, 0x742B, 0x742C, 0x742E, 0x742F, 0x7430, 0x7444, 0x7446,
+ 0x7447, 0x744B, 0x7457, 0x7462, 0x746B, 0x746D, 0x7486, 0x7487,
+ 0x7489, 0x7498, 0x749C, 0x749F, 0x74A3, 0x7490, 0x74A6, 0x74A8,
+ 0x74A9, 0x74B5, 0x74BF, 0x74C8, 0x74C9, 0x74DA, 0x74FF, 0x7501,
+ 0x7517, 0x752F, 0x756F, 0x7579, 0x7592, 0x3F72, 0x75CE, 0x75E4,
+ 0x7600, 0x7602, 0x7608, 0x7615, 0x7616, 0x7619, 0x761E, 0x762D,
+ 0x7635, 0x7643, 0x764B, 0x7664, 0x7665, 0x766D, 0x766F, 0x7671,
+ 0x7681, 0x769B, 0x769D, 0x769E, 0x76A6, 0x76AA, 0x76B6, 0x76C5,
+ 0x76CC, 0x76CE, 0x76D4, 0x76E6, 0x76F1, 0x76FC, 0x770A, 0x7719,
+ 0x7734, 0x7736, 0x7746, 0x774D, 0x774E, 0x775C, 0x775F, 0x7762,
+ 0x777A, 0x7780, 0x7794, 0x77AA, 0x77E0, 0x782D, 0xD855 /*0xDC8E*/,
+};
+static const unsigned short euc_to_utf8_F9[] = {
+ 0x7E8A, 0x891C, 0x9348, 0x9288, 0x84DC, 0x4FC9, 0x70BB,
+ 0x6631, 0x68C8, 0x92F9, 0x66FB, 0x5F45, 0x4E28, 0x4EE1, 0x4EFC,
+ 0x4F00, 0x4F03, 0x4F39, 0x4F56, 0x4F92, 0x4F8A, 0x4F9A, 0x4F94,
+ 0x4FCD, 0x5040, 0x5022, 0x4FFF, 0x501E, 0x5046, 0x5070, 0x5042,
+ 0x5094, 0x50F4, 0x50D8, 0x514A, 0x5164, 0x519D, 0x51BE, 0x51EC,
+ 0x5215, 0x529C, 0x52A6, 0x52C0, 0x52DB, 0x5300, 0x5307, 0x5324,
+ 0x5372, 0x5393, 0x53B2, 0x53DD, 0xFA0E, 0x549C, 0x548A, 0x54A9,
+ 0x54FF, 0x5586, 0x5759, 0x5765, 0x57AC, 0x57C8, 0x57C7, 0xFA0F,
+ 0xFA10, 0x589E, 0x58B2, 0x590B, 0x5953, 0x595B, 0x595D, 0x5963,
+ 0x59A4, 0x59BA, 0x5B56, 0x5BC0, 0x752F, 0x5BD8, 0x5BEC, 0x5C1E,
+ 0x5CA6, 0x5CBA, 0x5CF5, 0x5D27, 0x5D53, 0xFA11, 0x5D42, 0x5D6D,
+ 0x5DB8, 0x5DB9, 0x5DD0, 0x5F21, 0x5F34, 0x5F67, 0x5FB7,
+};
+static const unsigned short euc_to_utf8_F9_x0213[] = {
+ 0x7843, 0x784E, 0x784F, 0x7851, 0x7868, 0x786E, 0xFA4B,
+ 0x78B0, 0xD855 /*0xDD0E*/, 0x78AD, 0x78E4, 0x78F2, 0x7900, 0x78F7, 0x791C,
+ 0x792E, 0x7931, 0x7934, 0xFA4C, 0xFA4D, 0x7945, 0x7946, 0xFA4E,
+ 0xFA4F, 0xFA50, 0x795C, 0xFA51, 0xFA19, 0xFA1A, 0x7979, 0xFA52,
+ 0xFA53, 0xFA1B, 0x7998, 0x79B1, 0x79B8, 0x79C8, 0x79CA, 0xD855 /*0xDF71*/,
+ 0x79D4, 0x79DE, 0x79EB, 0x79ED, 0x7A03, 0xFA54, 0x7A39, 0x7A5D,
+ 0x7A6D, 0xFA55, 0x7A85, 0x7AA0, 0xD856 /*0xDDC4*/, 0x7AB3, 0x7ABB, 0x7ACE,
+ 0x7AEB, 0x7AFD, 0x7B12, 0x7B2D, 0x7B3B, 0x7B47, 0x7B4E, 0x7B60,
+ 0x7B6D, 0x7B6F, 0x7B72, 0x7B9E, 0xFA56, 0x7BD7, 0x7BD9, 0x7C01,
+ 0x7C31, 0x7C1E, 0x7C20, 0x7C33, 0x7C36, 0x4264, 0xD857 /*0xDDA1*/, 0x7C59,
+ 0x7C6D, 0x7C79, 0x7C8F, 0x7C94, 0x7CA0, 0x7CBC, 0x7CD5, 0x7CD9,
+ 0x7CDD, 0x7D07, 0x7D08, 0x7D13, 0x7D1D, 0x7D23, 0x7D31,
+};
+static const unsigned short euc_to_utf8_FA[] = {
+ 0x5FDE, 0x605D, 0x6085, 0x608A, 0x60DE, 0x60D5, 0x6120,
+ 0x60F2, 0x6111, 0x6137, 0x6130, 0x6198, 0x6213, 0x62A6, 0x63F5,
+ 0x6460, 0x649D, 0x64CE, 0x654E, 0x6600, 0x6615, 0x663B, 0x6609,
+ 0x662E, 0x661E, 0x6624, 0x6665, 0x6657, 0x6659, 0xFA12, 0x6673,
+ 0x6699, 0x66A0, 0x66B2, 0x66BF, 0x66FA, 0x670E, 0xF929, 0x6766,
+ 0x67BB, 0x6852, 0x67C0, 0x6801, 0x6844, 0x68CF, 0xFA13, 0x6968,
+ 0xFA14, 0x6998, 0x69E2, 0x6A30, 0x6A6B, 0x6A46, 0x6A73, 0x6A7E,
+ 0x6AE2, 0x6AE4, 0x6BD6, 0x6C3F, 0x6C5C, 0x6C86, 0x6C6F, 0x6CDA,
+ 0x6D04, 0x6D87, 0x6D6F, 0x6D96, 0x6DAC, 0x6DCF, 0x6DF8, 0x6DF2,
+ 0x6DFC, 0x6E39, 0x6E5C, 0x6E27, 0x6E3C, 0x6EBF, 0x6F88, 0x6FB5,
+ 0x6FF5, 0x7005, 0x7007, 0x7028, 0x7085, 0x70AB, 0x710F, 0x7104,
+ 0x715C, 0x7146, 0x7147, 0xFA15, 0x71C1, 0x71FE, 0x72B1,
+};
+static const unsigned short euc_to_utf8_FA_x0213[] = {
+ 0x7D41, 0x7D48, 0x7D53, 0x7D5C, 0x7D7A, 0x7D83, 0x7D8B,
+ 0x7DA0, 0x7DA6, 0x7DC2, 0x7DCC, 0x7DD6, 0x7DE3, 0xFA57, 0x7E28,
+ 0x7E08, 0x7E11, 0x7E15, 0xFA59, 0x7E47, 0x7E52, 0x7E61, 0x7E8A,
+ 0x7E8D, 0x7F47, 0xFA5A, 0x7F91, 0x7F97, 0x7FBF, 0x7FCE, 0x7FDB,
+ 0x7FDF, 0x7FEC, 0x7FEE, 0x7FFA, 0xFA5B, 0x8014, 0x8026, 0x8035,
+ 0x8037, 0x803C, 0x80CA, 0x80D7, 0x80E0, 0x80F3, 0x8118, 0x814A,
+ 0x8160, 0x8167, 0x8168, 0x816D, 0x81BB, 0x81CA, 0x81CF, 0x81D7,
+ 0xFA5C, 0x4453, 0x445B, 0x8260, 0x8274, 0xD85A /*0xDEFF*/, 0x828E, 0x82A1,
+ 0x82A3, 0x82A4, 0x82A9, 0x82AE, 0x82B7, 0x82BE, 0x82BF, 0x82C6,
+ 0x82D5, 0x82FD, 0x82FE, 0x8300, 0x8301, 0x8362, 0x8322, 0x832D,
+ 0x833A, 0x8343, 0x8347, 0x8351, 0x8355, 0x837D, 0x8386, 0x8392,
+ 0x8398, 0x83A7, 0x83A9, 0x83BF, 0x83C0, 0x83C7, 0x83CF,
+};
+static const unsigned short euc_to_utf8_FB[] = {
+ 0x72BE, 0x7324, 0xFA16, 0x7377, 0x73BD, 0x73C9, 0x73D6,
+ 0x73E3, 0x73D2, 0x7407, 0x73F5, 0x7426, 0x742A, 0x7429, 0x742E,
+ 0x7462, 0x7489, 0x749F, 0x7501, 0x756F, 0x7682, 0x769C, 0x769E,
+ 0x769B, 0x76A6, 0xFA17, 0x7746, 0x52AF, 0x7821, 0x784E, 0x7864,
+ 0x787A, 0x7930, 0xFA18, 0xFA19, 0xFA1A, 0x7994, 0xFA1B, 0x799B,
+ 0x7AD1, 0x7AE7, 0xFA1C, 0x7AEB, 0x7B9E, 0xFA1D, 0x7D48, 0x7D5C,
+ 0x7DB7, 0x7DA0, 0x7DD6, 0x7E52, 0x7F47, 0x7FA1, 0xFA1E, 0x8301,
+ 0x8362, 0x837F, 0x83C7, 0x83F6, 0x8448, 0x84B4, 0x8553, 0x8559,
+ 0x856B, 0xFA1F, 0x85B0, 0xFA20, 0xFA21, 0x8807, 0x88F5, 0x8A12,
+ 0x8A37, 0x8A79, 0x8AA7, 0x8ABE, 0x8ADF, 0xFA22, 0x8AF6, 0x8B53,
+ 0x8B7F, 0x8CF0, 0x8CF4, 0x8D12, 0x8D76, 0xFA23, 0x8ECF, 0xFA24,
+ 0xFA25, 0x9067, 0x90DE, 0xFA26, 0x9115, 0x9127, 0x91DA,
+};
+static const unsigned short euc_to_utf8_FB_x0213[] = {
+ 0x83D1, 0x83E1, 0x83EA, 0x8401, 0x8406, 0x840A, 0xFA5F,
+ 0x8448, 0x845F, 0x8470, 0x8473, 0x8485, 0x849E, 0x84AF, 0x84B4,
+ 0x84BA, 0x84C0, 0x84C2, 0xD85B /*0xDE40*/, 0x8532, 0x851E, 0x8523, 0x852F,
+ 0x8559, 0x8564, 0xFA1F, 0x85AD, 0x857A, 0x858C, 0x858F, 0x85A2,
+ 0x85B0, 0x85CB, 0x85CE, 0x85ED, 0x8612, 0x85FF, 0x8604, 0x8605,
+ 0x8610, 0xD85C /*0xDCF4*/, 0x8618, 0x8629, 0x8638, 0x8657, 0x865B, 0xF936,
+ 0x8662, 0x459D, 0x866C, 0x8675, 0x8698, 0x86B8, 0x86FA, 0x86FC,
+ 0x86FD, 0x870B, 0x8771, 0x8787, 0x8788, 0x87AC, 0x87AD, 0x87B5,
+ 0x45EA, 0x87D6, 0x87EC, 0x8806, 0x880A, 0x8810, 0x8814, 0x881F,
+ 0x8898, 0x88AA, 0x88CA, 0x88CE, 0xD85D /*0xDE84*/, 0x88F5, 0x891C, 0xFA60,
+ 0x8918, 0x8919, 0x891A, 0x8927, 0x8930, 0x8932, 0x8939, 0x8940,
+ 0x8994, 0xFA61, 0x89D4, 0x89E5, 0x89F6, 0x8A12, 0x8A15,
+};
+static const unsigned short euc_to_utf8_FC[] = {
+ 0x91D7, 0x91DE, 0x91ED, 0x91EE, 0x91E4, 0x91E5, 0x9206,
+ 0x9210, 0x920A, 0x923A, 0x9240, 0x923C, 0x924E, 0x9259, 0x9251,
+ 0x9239, 0x9267, 0x92A7, 0x9277, 0x9278, 0x92E7, 0x92D7, 0x92D9,
+ 0x92D0, 0xFA27, 0x92D5, 0x92E0, 0x92D3, 0x9325, 0x9321, 0x92FB,
+ 0xFA28, 0x931E, 0x92FF, 0x931D, 0x9302, 0x9370, 0x9357, 0x93A4,
+ 0x93C6, 0x93DE, 0x93F8, 0x9431, 0x9445, 0x9448, 0x9592, 0xF9DC,
+ 0xFA29, 0x969D, 0x96AF, 0x9733, 0x973B, 0x9743, 0x974D, 0x974F,
+ 0x9751, 0x9755, 0x9857, 0x9865, 0xFA2A, 0xFA2B, 0x9927, 0xFA2C,
+ 0x999E, 0x9A4E, 0x9AD9, 0x9ADC, 0x9B75, 0x9B72, 0x9B8F, 0x9BB1,
+ 0x9BBB, 0x9C00, 0x9D70, 0x9D6B, 0xFA2D, 0x9E19, 0x9ED1, 0,
+ 0, 0x2170, 0x2171, 0x2172, 0x2173, 0x2174, 0x2175, 0x2176,
+ 0x2177, 0x2178, 0x2179, 0xFFE2, 0x00A6, 0xFF07, 0xFF02,
+};
+
+/* Microsoft UCS Mapping Compatible */
+static const unsigned short euc_to_utf8_FC_ms[] = {
+ 0x91D7, 0x91DE, 0x91ED, 0x91EE, 0x91E4, 0x91E5, 0x9206,
+ 0x9210, 0x920A, 0x923A, 0x9240, 0x923C, 0x924E, 0x9259, 0x9251,
+ 0x9239, 0x9267, 0x92A7, 0x9277, 0x9278, 0x92E7, 0x92D7, 0x92D9,
+ 0x92D0, 0xFA27, 0x92D5, 0x92E0, 0x92D3, 0x9325, 0x9321, 0x92FB,
+ 0xFA28, 0x931E, 0x92FF, 0x931D, 0x9302, 0x9370, 0x9357, 0x93A4,
+ 0x93C6, 0x93DE, 0x93F8, 0x9431, 0x9445, 0x9448, 0x9592, 0xF9DC,
+ 0xFA29, 0x969D, 0x96AF, 0x9733, 0x973B, 0x9743, 0x974D, 0x974F,
+ 0x9751, 0x9755, 0x9857, 0x9865, 0xFA2A, 0xFA2B, 0x9927, 0xFA2C,
+ 0x999E, 0x9A4E, 0x9AD9, 0x9ADC, 0x9B75, 0x9B72, 0x9B8F, 0x9BB1,
+ 0x9BBB, 0x9C00, 0x9D70, 0x9D6B, 0xFA2D, 0x9E19, 0x9ED1, 0,
+ 0, 0x2170, 0x2171, 0x2172, 0x2173, 0x2174, 0x2175, 0x2176,
+ 0x2177, 0x2178, 0x2179, 0xFFE2, 0xFFE4, 0xFF07, 0xFF02,
+};
+static const unsigned short euc_to_utf8_FC_x0213[] = {
+ 0x8A22, 0x8A37, 0x8A47, 0x8A4E, 0x8A5D, 0x8A61, 0x8A75,
+ 0x8A79, 0x8AA7, 0x8AD0, 0x8ADF, 0x8AF4, 0x8AF6, 0xFA22, 0xFA62,
+ 0xFA63, 0x8B46, 0x8B54, 0x8B59, 0x8B69, 0x8B9D, 0x8C49, 0x8C68,
+ 0xFA64, 0x8CE1, 0x8CF4, 0x8CF8, 0x8CFE, 0xFA65, 0x8D12, 0x8D1B,
+ 0x8DAF, 0x8DCE, 0x8DD1, 0x8DD7, 0x8E20, 0x8E23, 0x8E3D, 0x8E70,
+ 0x8E7B, 0xD860 /*0xDE77*/, 0x8EC0, 0x4844, 0x8EFA, 0x8F1E, 0x8F2D, 0x8F36,
+ 0x8F54, 0xD860 /*0xDFCD*/, 0x8FA6, 0x8FB5, 0x8FE4, 0x8FE8, 0x8FEE, 0x9008,
+ 0x902D, 0xFA67, 0x9088, 0x9095, 0x9097, 0x9099, 0x909B, 0x90A2,
+ 0x90B3, 0x90BE, 0x90C4, 0x90C5, 0x90C7, 0x90D7, 0x90DD, 0x90DE,
+ 0x90EF, 0x90F4, 0xFA26, 0x9114, 0x9115, 0x9116, 0x9122, 0x9123,
+ 0x9127, 0x912F, 0x9131, 0x9134, 0x913D, 0x9148, 0x915B, 0x9183,
+ 0x919E, 0x91AC, 0x91B1, 0x91BC, 0x91D7, 0x91FB, 0x91E4,
+};
+static const unsigned short euc_to_utf8_FD_x0213[] = {
+ 0x91E5, 0x91ED, 0x91F1, 0x9207, 0x9210, 0x9238, 0x9239,
+ 0x923A, 0x923C, 0x9240, 0x9243, 0x924F, 0x9278, 0x9288, 0x92C2,
+ 0x92CB, 0x92CC, 0x92D3, 0x92E0, 0x92FF, 0x9304, 0x931F, 0x9321,
+ 0x9325, 0x9348, 0x9349, 0x934A, 0x9364, 0x9365, 0x936A, 0x9370,
+ 0x939B, 0x93A3, 0x93BA, 0x93C6, 0x93DE, 0x93DF, 0x9404, 0x93FD,
+ 0x9433, 0x944A, 0x9463, 0x946B, 0x9471, 0x9472, 0x958E, 0x959F,
+ 0x95A6, 0x95A9, 0x95AC, 0x95B6, 0x95BD, 0x95CB, 0x95D0, 0x95D3,
+ 0x49B0, 0x95DA, 0x95DE, 0x9658, 0x9684, 0xF9DC, 0x969D, 0x96A4,
+ 0x96A5, 0x96D2, 0x96DE, 0xFA68, 0x96E9, 0x96EF, 0x9733, 0x973B,
+ 0x974D, 0x974E, 0x974F, 0x975A, 0x976E, 0x9773, 0x9795, 0x97AE,
+ 0x97BA, 0x97C1, 0x97C9, 0x97DE, 0x97DB, 0x97F4, 0xFA69, 0x980A,
+ 0x981E, 0x982B, 0x9830, 0xFA6A, 0x9852, 0x9853, 0x9856,
+};
+static const unsigned short euc_to_utf8_FE_x0213[] = {
+ 0x9857, 0x9859, 0x985A, 0xF9D0, 0x9865, 0x986C, 0x98BA,
+ 0x98C8, 0x98E7, 0x9958, 0x999E, 0x9A02, 0x9A03, 0x9A24, 0x9A2D,
+ 0x9A2E, 0x9A38, 0x9A4A, 0x9A4E, 0x9A52, 0x9AB6, 0x9AC1, 0x9AC3,
+ 0x9ACE, 0x9AD6, 0x9AF9, 0x9B02, 0x9B08, 0x9B20, 0x4C17, 0x9B2D,
+ 0x9B5E, 0x9B79, 0x9B66, 0x9B72, 0x9B75, 0x9B84, 0x9B8A, 0x9B8F,
+ 0x9B9E, 0x9BA7, 0x9BC1, 0x9BCE, 0x9BE5, 0x9BF8, 0x9BFD, 0x9C00,
+ 0x9C23, 0x9C41, 0x9C4F, 0x9C50, 0x9C53, 0x9C63, 0x9C65, 0x9C77,
+ 0x9D1D, 0x9D1E, 0x9D43, 0x9D47, 0x9D52, 0x9D63, 0x9D70, 0x9D7C,
+ 0x9D8A, 0x9D96, 0x9DC0, 0x9DAC, 0x9DBC, 0x9DD7, 0xD868 /*0xDD90*/, 0x9DE7,
+ 0x9E07, 0x9E15, 0x9E7C, 0x9E9E, 0x9EA4, 0x9EAC, 0x9EAF, 0x9EB4,
+ 0x9EB5, 0x9EC3, 0x9ED1, 0x9F10, 0x9F39, 0x9F57, 0x9F90, 0x9F94,
+ 0x9F97, 0x9FA2, 0x59F8, 0x5C5B, 0x5E77, 0x7626, 0x7E6B,
+};
+
+static const unsigned short euc_to_utf8_8FA1_x0213[] = {
+ 0xD840 /*0xDC89*/, 0x4E02, 0x4E0F, 0x4E12, 0x4E29, 0x4E2B, 0x4E2E,
+ 0x4E40, 0x4E47, 0x4E48, 0xD840 /*0xDCA2*/, 0x4E51, 0x3406, 0xD840 /*0xDCA4*/, 0x4E5A,
+ 0x4E69, 0x4E9D, 0x342C, 0x342E, 0x4EB9, 0x4EBB, 0xD840 /*0xDDA2*/, 0x4EBC,
+ 0x4EC3, 0x4EC8, 0x4ED0, 0x4EEB, 0x4EDA, 0x4EF1, 0x4EF5, 0x4F00,
+ 0x4F16, 0x4F64, 0x4F37, 0x4F3E, 0x4F54, 0x4F58, 0xD840 /*0xDE13*/, 0x4F77,
+ 0x4F78, 0x4F7A, 0x4F7D, 0x4F82, 0x4F85, 0x4F92, 0x4F9A, 0x4FE6,
+ 0x4FB2, 0x4FBE, 0x4FC5, 0x4FCB, 0x4FCF, 0x4FD2, 0x346A, 0x4FF2,
+ 0x5000, 0x5010, 0x5013, 0x501C, 0x501E, 0x5022, 0x3468, 0x5042,
+ 0x5046, 0x504E, 0x5053, 0x5057, 0x5063, 0x5066, 0x506A, 0x5070,
+ 0x50A3, 0x5088, 0x5092, 0x5093, 0x5095, 0x5096, 0x509C, 0x50AA,
+ 0xD840 /*0xDF2B*/, 0x50B1, 0x50BA, 0x50BB, 0x50C4, 0x50C7, 0x50F3, 0xD840 /*0xDF81*/,
+ 0x50CE, 0xD840 /*0xDF71*/, 0x50D4, 0x50D9, 0x50E1, 0x50E9, 0x3492,
+};
+static const unsigned short euc_to_utf8_8FA3_x0213[] = {
+ 0x5108, 0xD840 /*0xDFF9*/, 0x5117, 0x511B, 0xD841 /*0xDC4A*/, 0x5160, 0xD841 /*0xDD09*/,
+ 0x5173, 0x5183, 0x518B, 0x34BC, 0x5198, 0x51A3, 0x51AD, 0x34C7,
+ 0x51BC, 0xD841 /*0xDDD6*/, 0xD841 /*0xDE28*/, 0x51F3, 0x51F4, 0x5202, 0x5212, 0x5216,
+ 0xD841 /*0xDF4F*/, 0x5255, 0x525C, 0x526C, 0x5277, 0x5284, 0x5282, 0xD842 /*0xDC07*/,
+ 0x5298, 0xD842 /*0xDC3A*/, 0x52A4, 0x52A6, 0x52AF, 0x52BA, 0x52BB, 0x52CA,
+ 0x351F, 0x52D1, 0xD842 /*0xDCB9*/, 0x52F7, 0x530A, 0x530B, 0x5324, 0x5335,
+ 0x533E, 0x5342, 0xD842 /*0xDD7C*/, 0xD842 /*0xDD9D*/, 0x5367, 0x536C, 0x537A, 0x53A4,
+ 0x53B4, 0xD842 /*0xDED3*/, 0x53B7, 0x53C0, 0xD842 /*0xDF1D*/, 0x355D, 0x355E, 0x53D5,
+ 0x53DA, 0x3563, 0x53F4, 0x53F5, 0x5455, 0x5424, 0x5428, 0x356E,
+ 0x5443, 0x5462, 0x5466, 0x546C, 0x548A, 0x548D, 0x5495, 0x54A0,
+ 0x54A6, 0x54AD, 0x54AE, 0x54B7, 0x54BA, 0x54BF, 0x54C3, 0xD843 /*0xDD45*/,
+ 0x54EC, 0x54EF, 0x54F1, 0x54F3, 0x5500, 0x5501, 0x5509,
+};
+static const unsigned short euc_to_utf8_8FA4_x0213[] = {
+ 0x553C, 0x5541, 0x35A6, 0x5547, 0x554A, 0x35A8, 0x5560,
+ 0x5561, 0x5564, 0xD843 /*0xDDE1*/, 0x557D, 0x5582, 0x5588, 0x5591, 0x35C5,
+ 0x55D2, 0xD843 /*0xDE95*/, 0xD843 /*0xDE6D*/, 0x55BF, 0x55C9, 0x55CC, 0x55D1, 0x55DD,
+ 0x35DA, 0x55E2, 0xD843 /*0xDE64*/, 0x55E9, 0x5628, 0xD843 /*0xDF5F*/, 0x5607, 0x5610,
+ 0x5630, 0x5637, 0x35F4, 0x563D, 0x563F, 0x5640, 0x5647, 0x565E,
+ 0x5660, 0x566D, 0x3605, 0x5688, 0x568C, 0x5695, 0x569A, 0x569D,
+ 0x56A8, 0x56AD, 0x56B2, 0x56C5, 0x56CD, 0x56DF, 0x56E8, 0x56F6,
+ 0x56F7, 0xD844 /*0xDE01*/, 0x5715, 0x5723, 0xD844 /*0xDE55*/, 0x5729, 0xD844 /*0xDE7B*/, 0x5745,
+ 0x5746, 0x574C, 0x574D, 0xD844 /*0xDE74*/, 0x5768, 0x576F, 0x5773, 0x5774,
+ 0x5775, 0x577B, 0xD844 /*0xDEE4*/, 0xD844 /*0xDED7*/, 0x57AC, 0x579A, 0x579D, 0x579E,
+ 0x57A8, 0x57D7, 0xD844 /*0xDEFD*/, 0x57CC, 0xD844 /*0xDF36*/, 0xD844 /*0xDF44*/, 0x57DE, 0x57E6,
+ 0x57F0, 0x364A, 0x57F8, 0x57FB, 0x57FD, 0x5804, 0x581E,
+};
+static const unsigned short euc_to_utf8_8FA5_x0213[] = {
+ 0x5820, 0x5827, 0x5832, 0x5839, 0xD844 /*0xDFC4*/, 0x5849, 0x584C,
+ 0x5867, 0x588A, 0x588B, 0x588D, 0x588F, 0x5890, 0x5894, 0x589D,
+ 0x58AA, 0x58B1, 0xD845 /*0xDC6D*/, 0x58C3, 0x58CD, 0x58E2, 0x58F3, 0x58F4,
+ 0x5905, 0x5906, 0x590B, 0x590D, 0x5914, 0x5924, 0xD845 /*0xDDD7*/, 0x3691,
+ 0x593D, 0x3699, 0x5946, 0x3696, 0xD85B /*0xDC29*/, 0x595B, 0x595F, 0xD845 /*0xDE47*/,
+ 0x5975, 0x5976, 0x597C, 0x599F, 0x59AE, 0x59BC, 0x59C8, 0x59CD,
+ 0x59DE, 0x59E3, 0x59E4, 0x59E7, 0x59EE, 0xD845 /*0xDF06*/, 0xD845 /*0xDF42*/, 0x36CF,
+ 0x5A0C, 0x5A0D, 0x5A17, 0x5A27, 0x5A2D, 0x5A55, 0x5A65, 0x5A7A,
+ 0x5A8B, 0x5A9C, 0x5A9F, 0x5AA0, 0x5AA2, 0x5AB1, 0x5AB3, 0x5AB5,
+ 0x5ABA, 0x5ABF, 0x5ADA, 0x5ADC, 0x5AE0, 0x5AE5, 0x5AF0, 0x5AEE,
+ 0x5AF5, 0x5B00, 0x5B08, 0x5B17, 0x5B34, 0x5B2D, 0x5B4C, 0x5B52,
+ 0x5B68, 0x5B6F, 0x5B7C, 0x5B7F, 0x5B81, 0x5B84, 0xD846 /*0xDDC3*/,
+};
+static const unsigned short euc_to_utf8_8FA8_x0213[] = {
+ 0x5B96, 0x5BAC, 0x3761, 0x5BC0, 0x3762, 0x5BCE, 0x5BD6,
+ 0x376C, 0x376B, 0x5BF1, 0x5BFD, 0x3775, 0x5C03, 0x5C29, 0x5C30,
+ 0xD847 /*0xDC56*/, 0x5C5F, 0x5C63, 0x5C67, 0x5C68, 0x5C69, 0x5C70, 0xD847 /*0xDD2D*/,
+ 0xD847 /*0xDD45*/, 0x5C7C, 0xD847 /*0xDD78*/, 0xD847 /*0xDD62*/, 0x5C88, 0x5C8A, 0x37C1, 0xD847 /*0xDDA1*/,
+ 0xD847 /*0xDD9C*/, 0x5CA0, 0x5CA2, 0x5CA6, 0x5CA7, 0xD847 /*0xDD92*/, 0x5CAD, 0x5CB5,
+ 0xD847 /*0xDDB7*/, 0x5CC9, 0xD847 /*0xDDE0*/, 0xD847 /*0xDE33*/, 0x5D06, 0x5D10, 0x5D2B, 0x5D1D,
+ 0x5D20, 0x5D24, 0x5D26, 0x5D31, 0x5D39, 0x5D42, 0x37E8, 0x5D61,
+ 0x5D6A, 0x37F4, 0x5D70, 0xD847 /*0xDF1E*/, 0x37FD, 0x5D88, 0x3800, 0x5D92,
+ 0x5D94, 0x5D97, 0x5D99, 0x5DB0, 0x5DB2, 0x5DB4, 0xD847 /*0xDF76*/, 0x5DB9,
+ 0x5DD1, 0x5DD7, 0x5DD8, 0x5DE0, 0xD847 /*0xDFFA*/, 0x5DE4, 0x5DE9, 0x382F,
+ 0x5E00, 0x3836, 0x5E12, 0x5E15, 0x3840, 0x5E1F, 0x5E2E, 0x5E3E,
+ 0x5E49, 0x385C, 0x5E56, 0x3861, 0x5E6B, 0x5E6C, 0x5E6D,
+};
+static const unsigned short euc_to_utf8_8FAC_x0213[] = {
+ 0x5E6E, 0xD848 /*0xDD7B*/, 0x5EA5, 0x5EAA, 0x5EAC, 0x5EB9, 0x5EBF,
+ 0x5EC6, 0x5ED2, 0x5ED9, 0xD848 /*0xDF1E*/, 0x5EFD, 0x5F08, 0x5F0E, 0x5F1C,
+ 0xD848 /*0xDFAD*/, 0x5F1E, 0x5F47, 0x5F63, 0x5F72, 0x5F7E, 0x5F8F, 0x5FA2,
+ 0x5FA4, 0x5FB8, 0x5FC4, 0x38FA, 0x5FC7, 0x5FCB, 0x5FD2, 0x5FD3,
+ 0x5FD4, 0x5FE2, 0x5FEE, 0x5FEF, 0x5FF3, 0x5FFC, 0x3917, 0x6017,
+ 0x6022, 0x6024, 0x391A, 0x604C, 0x607F, 0x608A, 0x6095, 0x60A8,
+ 0xD849 /*0xDEF3*/, 0x60B0, 0x60B1, 0x60BE, 0x60C8, 0x60D9, 0x60DB, 0x60EE,
+ 0x60F2, 0x60F5, 0x6110, 0x6112, 0x6113, 0x6119, 0x611E, 0x613A,
+ 0x396F, 0x6141, 0x6146, 0x6160, 0x617C, 0xD84A /*0xDC5B*/, 0x6192, 0x6193,
+ 0x6197, 0x6198, 0x61A5, 0x61A8, 0x61AD, 0xD84A /*0xDCAB*/, 0x61D5, 0x61DD,
+ 0x61DF, 0x61F5, 0xD84A /*0xDD8F*/, 0x6215, 0x6223, 0x6229, 0x6246, 0x624C,
+ 0x6251, 0x6252, 0x6261, 0x6264, 0x627B, 0x626D, 0x6273,
+};
+static const unsigned short euc_to_utf8_8FAD_x0213[] = {
+ 0x6299, 0x62A6, 0x62D5, 0xD84A /*0xDEB8*/, 0x62FD, 0x6303, 0x630D,
+ 0x6310, 0xD84A /*0xDF4F*/, 0xD84A /*0xDF50*/, 0x6332, 0x6335, 0x633B, 0x633C, 0x6341,
+ 0x6344, 0x634E, 0xD84A /*0xDF46*/, 0x6359, 0xD84B /*0xDC1D*/, 0xD84A /*0xDFA6*/, 0x636C, 0x6384,
+ 0x6399, 0xD84B /*0xDC24*/, 0x6394, 0x63BD, 0x63F7, 0x63D4, 0x63D5, 0x63DC,
+ 0x63E0, 0x63EB, 0x63EC, 0x63F2, 0x6409, 0x641E, 0x6425, 0x6429,
+ 0x642F, 0x645A, 0x645B, 0x645D, 0x6473, 0x647D, 0x6487, 0x6491,
+ 0x649D, 0x649F, 0x64CB, 0x64CC, 0x64D5, 0x64D7, 0xD84B /*0xDDE1*/, 0x64E4,
+ 0x64E5, 0x64FF, 0x6504, 0x3A6E, 0x650F, 0x6514, 0x6516, 0x3A73,
+ 0x651E, 0x6532, 0x6544, 0x6554, 0x656B, 0x657A, 0x6581, 0x6584,
+ 0x6585, 0x658A, 0x65B2, 0x65B5, 0x65B8, 0x65BF, 0x65C2, 0x65C9,
+ 0x65D4, 0x3AD6, 0x65F2, 0x65F9, 0x65FC, 0x6604, 0x6608, 0x6621,
+ 0x662A, 0x6645, 0x6651, 0x664E, 0x3AEA, 0xD84C /*0xDDC3*/, 0x6657,
+};
+static const unsigned short euc_to_utf8_8FAE_x0213[] = {
+ 0x665B, 0x6663, 0xD84C /*0xDDF5*/, 0xD84C /*0xDDB6*/, 0x666A, 0x666B, 0x666C,
+ 0x666D, 0x667B, 0x6680, 0x6690, 0x6692, 0x6699, 0x3B0E, 0x66AD,
+ 0x66B1, 0x66B5, 0x3B1A, 0x66BF, 0x3B1C, 0x66EC, 0x3AD7, 0x6701,
+ 0x6705, 0x6712, 0xD84C /*0xDF72*/, 0x6719, 0xD84C /*0xDFD3*/, 0xD84C /*0xDFD2*/, 0x674C, 0x674D,
+ 0x6754, 0x675D, 0xD84C /*0xDFD0*/, 0xD84C /*0xDFE4*/, 0xD84C /*0xDFD5*/, 0x6774, 0x6776, 0xD84C /*0xDFDA*/,
+ 0x6792, 0xD84C /*0xDFDF*/, 0x8363, 0x6810, 0x67B0, 0x67B2, 0x67C3, 0x67C8,
+ 0x67D2, 0x67D9, 0x67DB, 0x67F0, 0x67F7, 0xD84D /*0xDC4A*/, 0xD84D /*0xDC51*/, 0xD84D /*0xDC4B*/,
+ 0x6818, 0x681F, 0x682D, 0xD84D /*0xDC65*/, 0x6833, 0x683B, 0x683E, 0x6844,
+ 0x6845, 0x6849, 0x684C, 0x6855, 0x6857, 0x3B77, 0x686B, 0x686E,
+ 0x687A, 0x687C, 0x6882, 0x6890, 0x6896, 0x3B6D, 0x6898, 0x6899,
+ 0x689A, 0x689C, 0x68AA, 0x68AB, 0x68B4, 0x68BB, 0x68FB, 0xD84D /*0xDCE4*/,
+ 0xD84D /*0xDD5A*/, 0xFA13, 0x68C3, 0x68C5, 0x68CC, 0x68CF, 0x68D6,
+};
+static const unsigned short euc_to_utf8_8FAF_x0213[] = {
+ 0x68D9, 0x68E4, 0x68E5, 0x68EC, 0x68F7, 0x6903, 0x6907,
+ 0x3B87, 0x3B88, 0xD84D /*0xDD94*/, 0x693B, 0x3B8D, 0x6946, 0x6969, 0x696C,
+ 0x6972, 0x697A, 0x697F, 0x6992, 0x3BA4, 0x6996, 0x6998, 0x69A6,
+ 0x69B0, 0x69B7, 0x69BA, 0x69BC, 0x69C0, 0x69D1, 0x69D6, 0xD84D /*0xDE39*/,
+ 0xD84D /*0xDE47*/, 0x6A30, 0xD84D /*0xDE38*/, 0xD84D /*0xDE3A*/, 0x69E3, 0x69EE, 0x69EF, 0x69F3,
+ 0x3BCD, 0x69F4, 0x69FE, 0x6A11, 0x6A1A, 0x6A1D, 0xD84D /*0xDF1C*/, 0x6A32,
+ 0x6A33, 0x6A34, 0x6A3F, 0x6A46, 0x6A49, 0x6A7A, 0x6A4E, 0x6A52,
+ 0x6A64, 0xD84D /*0xDF0C*/, 0x6A7E, 0x6A83, 0x6A8B, 0x3BF0, 0x6A91, 0x6A9F,
+ 0x6AA1, 0xD84D /*0xDF64*/, 0x6AAB, 0x6ABD, 0x6AC6, 0x6AD4, 0x6AD0, 0x6ADC,
+ 0x6ADD, 0xD84D /*0xDFFF*/, 0xD84D /*0xDFE7*/, 0x6AEC, 0x6AF1, 0x6AF2, 0x6AF3, 0x6AFD,
+ 0xD84E /*0xDC24*/, 0x6B0B, 0x6B0F, 0x6B10, 0x6B11, 0xD84E /*0xDC3D*/, 0x6B17, 0x3C26,
+ 0x6B2F, 0x6B4A, 0x6B58, 0x6B6C, 0x6B75, 0x6B7A, 0x6B81,
+};
+static const unsigned short euc_to_utf8_8FEE_x0213[] = {
+ 0x6B9B, 0x6BAE, 0xD84E /*0xDE98*/, 0x6BBD, 0x6BBE, 0x6BC7, 0x6BC8,
+ 0x6BC9, 0x6BDA, 0x6BE6, 0x6BE7, 0x6BEE, 0x6BF1, 0x6C02, 0x6C0A,
+ 0x6C0E, 0x6C35, 0x6C36, 0x6C3A, 0xD84F /*0xDC7F*/, 0x6C3F, 0x6C4D, 0x6C5B,
+ 0x6C6D, 0x6C84, 0x6C89, 0x3CC3, 0x6C94, 0x6C95, 0x6C97, 0x6CAD,
+ 0x6CC2, 0x6CD0, 0x3CD2, 0x6CD6, 0x6CDA, 0x6CDC, 0x6CE9, 0x6CEC,
+ 0x6CED, 0xD84F /*0xDD00*/, 0x6D00, 0x6D0A, 0x6D24, 0x6D26, 0x6D27, 0x6C67,
+ 0x6D2F, 0x6D3C, 0x6D5B, 0x6D5E, 0x6D60, 0x6D70, 0x6D80, 0x6D81,
+ 0x6D8A, 0x6D8D, 0x6D91, 0x6D98, 0xD84F /*0xDD40*/, 0x6E17, 0xD84F /*0xDDFA*/, 0xD84F /*0xDDF9*/,
+ 0xD84F /*0xDDD3*/, 0x6DAB, 0x6DAE, 0x6DB4, 0x6DC2, 0x6D34, 0x6DC8, 0x6DCE,
+ 0x6DCF, 0x6DD0, 0x6DDF, 0x6DE9, 0x6DF6, 0x6E36, 0x6E1E, 0x6E22,
+ 0x6E27, 0x3D11, 0x6E32, 0x6E3C, 0x6E48, 0x6E49, 0x6E4B, 0x6E4C,
+ 0x6E4F, 0x6E51, 0x6E53, 0x6E54, 0x6E57, 0x6E63, 0x3D1E,
+};
+static const unsigned short euc_to_utf8_8FEF_x0213[] = {
+ 0x6E93, 0x6EA7, 0x6EB4, 0x6EBF, 0x6EC3, 0x6ECA, 0x6ED9,
+ 0x6F35, 0x6EEB, 0x6EF9, 0x6EFB, 0x6F0A, 0x6F0C, 0x6F18, 0x6F25,
+ 0x6F36, 0x6F3C, 0xD84F /*0xDF7E*/, 0x6F52, 0x6F57, 0x6F5A, 0x6F60, 0x6F68,
+ 0x6F98, 0x6F7D, 0x6F90, 0x6F96, 0x6FBE, 0x6F9F, 0x6FA5, 0x6FAF,
+ 0x3D64, 0x6FB5, 0x6FC8, 0x6FC9, 0x6FDA, 0x6FDE, 0x6FE9, 0xD850 /*0xDC96*/,
+ 0x6FFC, 0x7000, 0x7007, 0x700A, 0x7023, 0xD850 /*0xDD03*/, 0x7039, 0x703A,
+ 0x703C, 0x7043, 0x7047, 0x704B, 0x3D9A, 0x7054, 0x7065, 0x7069,
+ 0x706C, 0x706E, 0x7076, 0x707E, 0x7081, 0x7086, 0x7095, 0x7097,
+ 0x70BB, 0xD850 /*0xDDC6*/, 0x709F, 0x70B1, 0xD850 /*0xDDFE*/, 0x70EC, 0x70CA, 0x70D1,
+ 0x70D3, 0x70DC, 0x7103, 0x7104, 0x7106, 0x7107, 0x7108, 0x710C,
+ 0x3DC0, 0x712F, 0x7131, 0x7150, 0x714A, 0x7153, 0x715E, 0x3DD4,
+ 0x7196, 0x7180, 0x719B, 0x71A0, 0x71A2, 0x71AE, 0x71AF,
+};
+static const unsigned short euc_to_utf8_8FF0_x0213[] = {
+ 0x71B3, 0xD850 /*0xDFBC*/, 0x71CB, 0x71D3, 0x71D9, 0x71DC, 0x7207,
+ 0x3E05, 0xFA49, 0x722B, 0x7234, 0x7238, 0x7239, 0x4E2C, 0x7242,
+ 0x7253, 0x7257, 0x7263, 0xD851 /*0xDE29*/, 0x726E, 0x726F, 0x7278, 0x727F,
+ 0x728E, 0xD851 /*0xDEA5*/, 0x72AD, 0x72AE, 0x72B0, 0x72B1, 0x72C1, 0x3E60,
+ 0x72CC, 0x3E66, 0x3E68, 0x72F3, 0x72FA, 0x7307, 0x7312, 0x7318,
+ 0x7319, 0x3E83, 0x7339, 0x732C, 0x7331, 0x7333, 0x733D, 0x7352,
+ 0x3E94, 0x736B, 0x736C, 0xD852 /*0xDC96*/, 0x736E, 0x736F, 0x7371, 0x7377,
+ 0x7381, 0x7385, 0x738A, 0x7394, 0x7398, 0x739C, 0x739E, 0x73A5,
+ 0x73A8, 0x73B5, 0x73B7, 0x73B9, 0x73BC, 0x73BF, 0x73C5, 0x73CB,
+ 0x73E1, 0x73E7, 0x73F9, 0x7413, 0x73FA, 0x7401, 0x7424, 0x7431,
+ 0x7439, 0x7453, 0x7440, 0x7443, 0x744D, 0x7452, 0x745D, 0x7471,
+ 0x7481, 0x7485, 0x7488, 0xD852 /*0xDE4D*/, 0x7492, 0x7497, 0x7499,
+};
+static const unsigned short euc_to_utf8_8FF1_x0213[] = {
+ 0x74A0, 0x74A1, 0x74A5, 0x74AA, 0x74AB, 0x74B9, 0x74BB,
+ 0x74BA, 0x74D6, 0x74D8, 0x74DE, 0x74EF, 0x74EB, 0xD852 /*0xDF56*/, 0x74FA,
+ 0xD852 /*0xDF6F*/, 0x7520, 0x7524, 0x752A, 0x3F57, 0xD853 /*0xDC16*/, 0x753D, 0x753E,
+ 0x7540, 0x7548, 0x754E, 0x7550, 0x7552, 0x756C, 0x7572, 0x7571,
+ 0x757A, 0x757D, 0x757E, 0x7581, 0xD853 /*0xDD14*/, 0x758C, 0x3F75, 0x75A2,
+ 0x3F77, 0x75B0, 0x75B7, 0x75BF, 0x75C0, 0x75C6, 0x75CF, 0x75D3,
+ 0x75DD, 0x75DF, 0x75E0, 0x75E7, 0x75EC, 0x75EE, 0x75F1, 0x75F9,
+ 0x7603, 0x7618, 0x7607, 0x760F, 0x3FAE, 0xD853 /*0xDE0E*/, 0x7613, 0x761B,
+ 0x761C, 0xD853 /*0xDE37*/, 0x7625, 0x7628, 0x763C, 0x7633, 0xD853 /*0xDE6A*/, 0x3FC9,
+ 0x7641, 0xD853 /*0xDE8B*/, 0x7649, 0x7655, 0x3FD7, 0x766E, 0x7695, 0x769C,
+ 0x76A1, 0x76A0, 0x76A7, 0x76A8, 0x76AF, 0xD854 /*0xDC4A*/, 0x76C9, 0xD854 /*0xDC55*/,
+ 0x76E8, 0x76EC, 0xD854 /*0xDD22*/, 0x7717, 0x771A, 0x772D, 0x7735,
+};
+static const unsigned short euc_to_utf8_8FF2_x0213[] = {
+ 0xD854 /*0xDDA9*/, 0x4039, 0xD854 /*0xDDE5*/, 0xD854 /*0xDDCD*/, 0x7758, 0x7760, 0x776A,
+ 0xD854 /*0xDE1E*/, 0x7772, 0x777C, 0x777D, 0xD854 /*0xDE4C*/, 0x4058, 0x779A, 0x779F,
+ 0x77A2, 0x77A4, 0x77A9, 0x77DE, 0x77DF, 0x77E4, 0x77E6, 0x77EA,
+ 0x77EC, 0x4093, 0x77F0, 0x77F4, 0x77FB, 0xD855 /*0xDC2E*/, 0x7805, 0x7806,
+ 0x7809, 0x780D, 0x7819, 0x7821, 0x782C, 0x7847, 0x7864, 0x786A,
+ 0xD855 /*0xDCD9*/, 0x788A, 0x7894, 0x78A4, 0x789D, 0x789E, 0x789F, 0x78BB,
+ 0x78C8, 0x78CC, 0x78CE, 0x78D5, 0x78E0, 0x78E1, 0x78E6, 0x78F9,
+ 0x78FA, 0x78FB, 0x78FE, 0xD855 /*0xDDA7*/, 0x7910, 0x791B, 0x7930, 0x7925,
+ 0x793B, 0x794A, 0x7958, 0x795B, 0x4105, 0x7967, 0x7972, 0x7994,
+ 0x7995, 0x7996, 0x799B, 0x79A1, 0x79A9, 0x79B4, 0x79BB, 0x79C2,
+ 0x79C7, 0x79CC, 0x79CD, 0x79D6, 0x4148, 0xD855 /*0xDFA9*/, 0xD855 /*0xDFB4*/, 0x414F,
+ 0x7A0A, 0x7A11, 0x7A15, 0x7A1B, 0x7A1E, 0x4163, 0x7A2D,
+};
+static const unsigned short euc_to_utf8_8FF3_x0213[] = {
+ 0x7A38, 0x7A47, 0x7A4C, 0x7A56, 0x7A59, 0x7A5C, 0x7A5F,
+ 0x7A60, 0x7A67, 0x7A6A, 0x7A75, 0x7A78, 0x7A82, 0x7A8A, 0x7A90,
+ 0x7AA3, 0x7AAC, 0xD856 /*0xDDD4*/, 0x41B4, 0x7AB9, 0x7ABC, 0x7ABE, 0x41BF,
+ 0x7ACC, 0x7AD1, 0x7AE7, 0x7AE8, 0x7AF4, 0xD856 /*0xDEE4*/, 0xD856 /*0xDEE3*/, 0x7B07,
+ 0xD856 /*0xDEF1*/, 0x7B3D, 0x7B27, 0x7B2A, 0x7B2E, 0x7B2F, 0x7B31, 0x41E6,
+ 0x41F3, 0x7B7F, 0x7B41, 0x41EE, 0x7B55, 0x7B79, 0x7B64, 0x7B66,
+ 0x7B69, 0x7B73, 0xD856 /*0xDFB2*/, 0x4207, 0x7B90, 0x7B91, 0x7B9B, 0x420E,
+ 0x7BAF, 0x7BB5, 0x7BBC, 0x7BC5, 0x7BCA, 0xD857 /*0xDC4B*/, 0xD857 /*0xDC64*/, 0x7BD4,
+ 0x7BD6, 0x7BDA, 0x7BEA, 0x7BF0, 0x7C03, 0x7C0B, 0x7C0E, 0x7C0F,
+ 0x7C26, 0x7C45, 0x7C4A, 0x7C51, 0x7C57, 0x7C5E, 0x7C61, 0x7C69,
+ 0x7C6E, 0x7C6F, 0x7C70, 0xD857 /*0xDE2E*/, 0xD857 /*0xDE56*/, 0xD857 /*0xDE65*/, 0x7CA6, 0xD857 /*0xDE62*/,
+ 0x7CB6, 0x7CB7, 0x7CBF, 0xD857 /*0xDED8*/, 0x7CC4, 0xD857 /*0xDEC2*/, 0x7CC8,
+};
+static const unsigned short euc_to_utf8_8FF4_x0213[] = {
+ 0x7CCD, 0xD857 /*0xDEE8*/, 0x7CD7, 0xD857 /*0xDF23*/, 0x7CE6, 0x7CEB, 0xD857 /*0xDF5C*/,
+ 0x7CF5, 0x7D03, 0x7D09, 0x42C6, 0x7D12, 0x7D1E, 0xD857 /*0xDFE0*/, 0xD857 /*0xDFD4*/,
+ 0x7D3D, 0x7D3E, 0x7D40, 0x7D47, 0xD858 /*0xDC0C*/, 0xD857 /*0xDFFB*/, 0x42D6, 0x7D59,
+ 0x7D5A, 0x7D6A, 0x7D70, 0x42DD, 0x7D7F, 0xD858 /*0xDC17*/, 0x7D86, 0x7D88,
+ 0x7D8C, 0x7D97, 0xD858 /*0xDC60*/, 0x7D9D, 0x7DA7, 0x7DAA, 0x7DB6, 0x7DB7,
+ 0x7DC0, 0x7DD7, 0x7DD9, 0x7DE6, 0x7DF1, 0x7DF9, 0x4302, 0xD858 /*0xDCED*/,
+ 0xFA58, 0x7E10, 0x7E17, 0x7E1D, 0x7E20, 0x7E27, 0x7E2C, 0x7E45,
+ 0x7E73, 0x7E75, 0x7E7E, 0x7E86, 0x7E87, 0x432B, 0x7E91, 0x7E98,
+ 0x7E9A, 0x4343, 0x7F3C, 0x7F3B, 0x7F3E, 0x7F43, 0x7F44, 0x7F4F,
+ 0x34C1, 0xD858 /*0xDE70*/, 0x7F52, 0xD858 /*0xDE86*/, 0x7F61, 0x7F63, 0x7F64, 0x7F6D,
+ 0x7F7D, 0x7F7E, 0xD858 /*0xDF4C*/, 0x7F90, 0x517B, 0xD84F /*0xDD0E*/, 0x7F96, 0x7F9C,
+ 0x7FAD, 0xD859 /*0xDC02*/, 0x7FC3, 0x7FCF, 0x7FE3, 0x7FE5, 0x7FEF,
+};
+static const unsigned short euc_to_utf8_8FF5_x0213[] = {
+ 0x7FF2, 0x8002, 0x800A, 0x8008, 0x800E, 0x8011, 0x8016,
+ 0x8024, 0x802C, 0x8030, 0x8043, 0x8066, 0x8071, 0x8075, 0x807B,
+ 0x8099, 0x809C, 0x80A4, 0x80A7, 0x80B8, 0xD859 /*0xDE7E*/, 0x80C5, 0x80D5,
+ 0x80D8, 0x80E6, 0xD859 /*0xDEB0*/, 0x810D, 0x80F5, 0x80FB, 0x43EE, 0x8135,
+ 0x8116, 0x811E, 0x43F0, 0x8124, 0x8127, 0x812C, 0xD859 /*0xDF1D*/, 0x813D,
+ 0x4408, 0x8169, 0x4417, 0x8181, 0x441C, 0x8184, 0x8185, 0x4422,
+ 0x8198, 0x81B2, 0x81C1, 0x81C3, 0x81D6, 0x81DB, 0xD85A /*0xDCDD*/, 0x81E4,
+ 0xD85A /*0xDCEA*/, 0x81EC, 0xD85A /*0xDD51*/, 0x81FD, 0x81FF, 0xD85A /*0xDD6F*/, 0x8204, 0xD85A /*0xDDDD*/,
+ 0x8219, 0x8221, 0x8222, 0xD85A /*0xDE1E*/, 0x8232, 0x8234, 0x823C, 0x8246,
+ 0x8249, 0x8245, 0xD85A /*0xDE58*/, 0x824B, 0x4476, 0x824F, 0x447A, 0x8257,
+ 0xD85A /*0xDE8C*/, 0x825C, 0x8263, 0xD85A /*0xDEB7*/, 0xFA5D, 0xFA5E, 0x8279, 0x4491,
+ 0x827D, 0x827F, 0x8283, 0x828A, 0x8293, 0x82A7, 0x82A8,
+};
+static const unsigned short euc_to_utf8_8FF6_x0213[] = {
+ 0x82B2, 0x82B4, 0x82BA, 0x82BC, 0x82E2, 0x82E8, 0x82F7,
+ 0x8307, 0x8308, 0x830C, 0x8354, 0x831B, 0x831D, 0x8330, 0x833C,
+ 0x8344, 0x8357, 0x44BE, 0x837F, 0x44D4, 0x44B3, 0x838D, 0x8394,
+ 0x8395, 0x839B, 0x839D, 0x83C9, 0x83D0, 0x83D4, 0x83DD, 0x83E5,
+ 0x83F9, 0x840F, 0x8411, 0x8415, 0xD85B /*0xDC73*/, 0x8417, 0x8439, 0x844A,
+ 0x844F, 0x8451, 0x8452, 0x8459, 0x845A, 0x845C, 0xD85B /*0xDCDD*/, 0x8465,
+ 0x8476, 0x8478, 0x847C, 0x8481, 0x450D, 0x84DC, 0x8497, 0x84A6,
+ 0x84BE, 0x4508, 0x84CE, 0x84CF, 0x84D3, 0xD85B /*0xDE65*/, 0x84E7, 0x84EA,
+ 0x84EF, 0x84F0, 0x84F1, 0x84FA, 0x84FD, 0x850C, 0x851B, 0x8524,
+ 0x8525, 0x852B, 0x8534, 0x854F, 0x856F, 0x4525, 0x4543, 0x853E,
+ 0x8551, 0x8553, 0x855E, 0x8561, 0x8562, 0xD85B /*0xDF94*/, 0x857B, 0x857D,
+ 0x857F, 0x8581, 0x8586, 0x8593, 0x859D, 0x859F, 0xD85B /*0xDFF8*/,
+};
+static const unsigned short euc_to_utf8_8FF7_x0213[] = {
+ 0xD85B /*0xDFF6*/, 0xD85B /*0xDFF7*/, 0x85B7, 0x85BC, 0x85C7, 0x85CA, 0x85D8,
+ 0x85D9, 0x85DF, 0x85E1, 0x85E6, 0x85F6, 0x8600, 0x8611, 0x861E,
+ 0x8621, 0x8624, 0x8627, 0xD85C /*0xDD0D*/, 0x8639, 0x863C, 0xD85C /*0xDD39*/, 0x8640,
+ 0xFA20, 0x8653, 0x8656, 0x866F, 0x8677, 0x867A, 0x8687, 0x8689,
+ 0x868D, 0x8691, 0x869C, 0x869D, 0x86A8, 0xFA21, 0x86B1, 0x86B3,
+ 0x86C1, 0x86C3, 0x86D1, 0x86D5, 0x86D7, 0x86E3, 0x86E6, 0x45B8,
+ 0x8705, 0x8707, 0x870E, 0x8710, 0x8713, 0x8719, 0x871F, 0x8721,
+ 0x8723, 0x8731, 0x873A, 0x873E, 0x8740, 0x8743, 0x8751, 0x8758,
+ 0x8764, 0x8765, 0x8772, 0x877C, 0xD85C /*0xDFDB*/, 0xD85C /*0xDFDA*/, 0x87A7, 0x8789,
+ 0x878B, 0x8793, 0x87A0, 0xD85C /*0xDFFE*/, 0x45E5, 0x87BE, 0xD85D /*0xDC10*/, 0x87C1,
+ 0x87CE, 0x87F5, 0x87DF, 0xD85D /*0xDC49*/, 0x87E3, 0x87E5, 0x87E6, 0x87EA,
+ 0x87EB, 0x87ED, 0x8801, 0x8803, 0x880B, 0x8813, 0x8828,
+};
+static const unsigned short euc_to_utf8_8FF8_x0213[] = {
+ 0x882E, 0x8832, 0x883C, 0x460F, 0x884A, 0x8858, 0x885F,
+ 0x8864, 0xD85D /*0xDE15*/, 0xD85D /*0xDE14*/, 0x8869, 0xD85D /*0xDE31*/, 0x886F, 0x88A0, 0x88BC,
+ 0x88BD, 0x88BE, 0x88C0, 0x88D2, 0xD85D /*0xDE93*/, 0x88D1, 0x88D3, 0x88DB,
+ 0x88F0, 0x88F1, 0x4641, 0x8901, 0xD85D /*0xDF0E*/, 0x8937, 0xD85D /*0xDF23*/, 0x8942,
+ 0x8945, 0x8949, 0xD85D /*0xDF52*/, 0x4665, 0x8962, 0x8980, 0x8989, 0x8990,
+ 0x899F, 0x89B0, 0x89B7, 0x89D6, 0x89D8, 0x89EB, 0x46A1, 0x89F1,
+ 0x89F3, 0x89FD, 0x89FF, 0x46AF, 0x8A11, 0x8A14, 0xD85E /*0xDD85*/, 0x8A21,
+ 0x8A35, 0x8A3E, 0x8A45, 0x8A4D, 0x8A58, 0x8AAE, 0x8A90, 0x8AB7,
+ 0x8ABE, 0x8AD7, 0x8AFC, 0xD85E /*0xDE84*/, 0x8B0A, 0x8B05, 0x8B0D, 0x8B1C,
+ 0x8B1F, 0x8B2D, 0x8B43, 0x470C, 0x8B51, 0x8B5E, 0x8B76, 0x8B7F,
+ 0x8B81, 0x8B8B, 0x8B94, 0x8B95, 0x8B9C, 0x8B9E, 0x8C39, 0xD85E /*0xDFB3*/,
+ 0x8C3D, 0xD85E /*0xDFBE*/, 0xD85E /*0xDFC7*/, 0x8C45, 0x8C47, 0x8C4F, 0x8C54,
+};
+static const unsigned short euc_to_utf8_8FF9_x0213[] = {
+ 0x8C57, 0x8C69, 0x8C6D, 0x8C73, 0xD85F /*0xDCB8*/, 0x8C93, 0x8C92,
+ 0x8C99, 0x4764, 0x8C9B, 0x8CA4, 0x8CD6, 0x8CD5, 0x8CD9, 0xD85F /*0xDDA0*/,
+ 0x8CF0, 0x8CF1, 0xD85F /*0xDE10*/, 0x8D09, 0x8D0E, 0x8D6C, 0x8D84, 0x8D95,
+ 0x8DA6, 0xD85F /*0xDFB7*/, 0x8DC6, 0x8DC8, 0x8DD9, 0x8DEC, 0x8E0C, 0x47FD,
+ 0x8DFD, 0x8E06, 0xD860 /*0xDC8A*/, 0x8E14, 0x8E16, 0x8E21, 0x8E22, 0x8E27,
+ 0xD860 /*0xDCBB*/, 0x4816, 0x8E36, 0x8E39, 0x8E4B, 0x8E54, 0x8E62, 0x8E6C,
+ 0x8E6D, 0x8E6F, 0x8E98, 0x8E9E, 0x8EAE, 0x8EB3, 0x8EB5, 0x8EB6,
+ 0x8EBB, 0xD860 /*0xDE82*/, 0x8ED1, 0x8ED4, 0x484E, 0x8EF9, 0xD860 /*0xDEF3*/, 0x8F00,
+ 0x8F08, 0x8F17, 0x8F2B, 0x8F40, 0x8F4A, 0x8F58, 0xD861 /*0xDC0C*/, 0x8FA4,
+ 0x8FB4, 0xFA66, 0x8FB6, 0xD861 /*0xDC55*/, 0x8FC1, 0x8FC6, 0xFA24, 0x8FCA,
+ 0x8FCD, 0x8FD3, 0x8FD5, 0x8FE0, 0x8FF1, 0x8FF5, 0x8FFB, 0x9002,
+ 0x900C, 0x9037, 0xD861 /*0xDD6B*/, 0x9043, 0x9044, 0x905D, 0xD861 /*0xDDC8*/,
+};
+static const unsigned short euc_to_utf8_8FFA_x0213[] = {
+ 0xD861 /*0xDDC9*/, 0x9085, 0x908C, 0x9090, 0x961D, 0x90A1, 0x48B5,
+ 0x90B0, 0x90B6, 0x90C3, 0x90C8, 0xD861 /*0xDED7*/, 0x90DC, 0x90DF, 0xD861 /*0xDEFA*/,
+ 0x90F6, 0x90F2, 0x9100, 0x90EB, 0x90FE, 0x90FF, 0x9104, 0x9106,
+ 0x9118, 0x911C, 0x911E, 0x9137, 0x9139, 0x913A, 0x9146, 0x9147,
+ 0x9157, 0x9159, 0x9161, 0x9164, 0x9174, 0x9179, 0x9185, 0x918E,
+ 0x91A8, 0x91AE, 0x91B3, 0x91B6, 0x91C3, 0x91C4, 0x91DA, 0xD862 /*0xDD49*/,
+ 0xD862 /*0xDD46*/, 0x91EC, 0x91EE, 0x9201, 0x920A, 0x9216, 0x9217, 0xD862 /*0xDD6B*/,
+ 0x9233, 0x9242, 0x9247, 0x924A, 0x924E, 0x9251, 0x9256, 0x9259,
+ 0x9260, 0x9261, 0x9265, 0x9267, 0x9268, 0xD862 /*0xDD87*/, 0xD862 /*0xDD88*/, 0x927C,
+ 0x927D, 0x927F, 0x9289, 0x928D, 0x9297, 0x9299, 0x929F, 0x92A7,
+ 0x92AB, 0xD862 /*0xDDBA*/, 0xD862 /*0xDDBB*/, 0x92B2, 0x92BF, 0x92C0, 0x92C6, 0x92CE,
+ 0x92D0, 0x92D7, 0x92D9, 0x92E5, 0x92E7, 0x9311, 0xD862 /*0xDE1E*/,
+};
+static const unsigned short euc_to_utf8_8FFB_x0213[] = {
+ 0xD862 /*0xDE29*/, 0x92F7, 0x92F9, 0x92FB, 0x9302, 0x930D, 0x9315,
+ 0x931D, 0x931E, 0x9327, 0x9329, 0xD862 /*0xDE71*/, 0xD862 /*0xDE43*/, 0x9347, 0x9351,
+ 0x9357, 0x935A, 0x936B, 0x9371, 0x9373, 0x93A1, 0xD862 /*0xDE99*/, 0xD862 /*0xDECD*/,
+ 0x9388, 0x938B, 0x938F, 0x939E, 0x93F5, 0xD862 /*0xDEE4*/, 0xD862 /*0xDEDD*/, 0x93F1,
+ 0x93C1, 0x93C7, 0x93DC, 0x93E2, 0x93E7, 0x9409, 0x940F, 0x9416,
+ 0x9417, 0x93FB, 0x9432, 0x9434, 0x943B, 0x9445, 0xD862 /*0xDFC1*/, 0xD862 /*0xDFEF*/,
+ 0x946D, 0x946F, 0x9578, 0x9579, 0x9586, 0x958C, 0x958D, 0xD863 /*0xDD10*/,
+ 0x95AB, 0x95B4, 0xD863 /*0xDD71*/, 0x95C8, 0xD863 /*0xDDFB*/, 0xD863 /*0xDE1F*/, 0x962C, 0x9633,
+ 0x9634, 0xD863 /*0xDE36*/, 0x963C, 0x9641, 0x9661, 0xD863 /*0xDE89*/, 0x9682, 0xD863 /*0xDEEB*/,
+ 0x969A, 0xD863 /*0xDF32*/, 0x49E7, 0x96A9, 0x96AF, 0x96B3, 0x96BA, 0x96BD,
+ 0x49FA, 0xD863 /*0xDFF8*/, 0x96D8, 0x96DA, 0x96DD, 0x4A04, 0x9714, 0x9723,
+ 0x4A29, 0x9736, 0x9741, 0x9747, 0x9755, 0x9757, 0x975B,
+};
+static const unsigned short euc_to_utf8_8FFC_x0213[] = {
+ 0x976A, 0xD864 /*0xDEA0*/, 0xD864 /*0xDEB1*/, 0x9796, 0x979A, 0x979E, 0x97A2,
+ 0x97B1, 0x97B2, 0x97BE, 0x97CC, 0x97D1, 0x97D4, 0x97D8, 0x97D9,
+ 0x97E1, 0x97F1, 0x9804, 0x980D, 0x980E, 0x9814, 0x9816, 0x4ABC,
+ 0xD865 /*0xDC90*/, 0x9823, 0x9832, 0x9833, 0x9825, 0x9847, 0x9866, 0x98AB,
+ 0x98AD, 0x98B0, 0xD865 /*0xDDCF*/, 0x98B7, 0x98B8, 0x98BB, 0x98BC, 0x98BF,
+ 0x98C2, 0x98C7, 0x98CB, 0x98E0, 0xD865 /*0xDE7F*/, 0x98E1, 0x98E3, 0x98E5,
+ 0x98EA, 0x98F0, 0x98F1, 0x98F3, 0x9908, 0x4B3B, 0xD865 /*0xDEF0*/, 0x9916,
+ 0x9917, 0xD865 /*0xDF19*/, 0x991A, 0x991B, 0x991C, 0xD865 /*0xDF50*/, 0x9931, 0x9932,
+ 0x9933, 0x993A, 0x993B, 0x993C, 0x9940, 0x9941, 0x9946, 0x994D,
+ 0x994E, 0x995C, 0x995F, 0x9960, 0x99A3, 0x99A6, 0x99B9, 0x99BD,
+ 0x99BF, 0x99C3, 0x99C9, 0x99D4, 0x99D9, 0x99DE, 0xD866 /*0xDCC6*/, 0x99F0,
+ 0x99F9, 0x99FC, 0x9A0A, 0x9A11, 0x9A16, 0x9A1A, 0x9A20,
+};
+static const unsigned short euc_to_utf8_8FFD_x0213[] = {
+ 0x9A31, 0x9A36, 0x9A44, 0x9A4C, 0x9A58, 0x4BC2, 0x9AAF,
+ 0x4BCA, 0x9AB7, 0x4BD2, 0x9AB9, 0xD866 /*0xDE72*/, 0x9AC6, 0x9AD0, 0x9AD2,
+ 0x9AD5, 0x4BE8, 0x9ADC, 0x9AE0, 0x9AE5, 0x9AE9, 0x9B03, 0x9B0C,
+ 0x9B10, 0x9B12, 0x9B16, 0x9B1C, 0x9B2B, 0x9B33, 0x9B3D, 0x4C20,
+ 0x9B4B, 0x9B63, 0x9B65, 0x9B6B, 0x9B6C, 0x9B73, 0x9B76, 0x9B77,
+ 0x9BA6, 0x9BAC, 0x9BB1, 0xD867 /*0xDDDB*/, 0xD867 /*0xDE3D*/, 0x9BB2, 0x9BB8, 0x9BBE,
+ 0x9BC7, 0x9BF3, 0x9BD8, 0x9BDD, 0x9BE7, 0x9BEA, 0x9BEB, 0x9BEF,
+ 0x9BEE, 0xD867 /*0xDE15*/, 0x9BFA, 0xD867 /*0xDE8A*/, 0x9BF7, 0xD867 /*0xDE49*/, 0x9C16, 0x9C18,
+ 0x9C19, 0x9C1A, 0x9C1D, 0x9C22, 0x9C27, 0x9C29, 0x9C2A, 0xD867 /*0xDEC4*/,
+ 0x9C31, 0x9C36, 0x9C37, 0x9C45, 0x9C5C, 0xD867 /*0xDEE9*/, 0x9C49, 0x9C4A,
+ 0xD867 /*0xDEDB*/, 0x9C54, 0x9C58, 0x9C5B, 0x9C5D, 0x9C5F, 0x9C69, 0x9C6A,
+ 0x9C6B, 0x9C6D, 0x9C6E, 0x9C70, 0x9C72, 0x9C75, 0x9C7A,
+};
+static const unsigned short euc_to_utf8_8FFE_x0213[] = {
+ 0x9CE6, 0x9CF2, 0x9D0B, 0x9D02, 0xD867 /*0xDFCE*/, 0x9D11, 0x9D17,
+ 0x9D18, 0xD868 /*0xDC2F*/, 0x4CC4, 0xD868 /*0xDC1A*/, 0x9D32, 0x4CD1, 0x9D42, 0x9D4A,
+ 0x9D5F, 0x9D62, 0xD868 /*0xDCF9*/, 0x9D69, 0x9D6B, 0xD868 /*0xDC82*/, 0x9D73, 0x9D76,
+ 0x9D77, 0x9D7E, 0x9D84, 0x9D8D, 0x9D99, 0x9DA1, 0x9DBF, 0x9DB5,
+ 0x9DB9, 0x9DBD, 0x9DC3, 0x9DC7, 0x9DC9, 0x9DD6, 0x9DDA, 0x9DDF,
+ 0x9DE0, 0x9DE3, 0x9DF4, 0x4D07, 0x9E0A, 0x9E02, 0x9E0D, 0x9E19,
+ 0x9E1C, 0x9E1D, 0x9E7B, 0xD848 /*0xDE18*/, 0x9E80, 0x9E85, 0x9E9B, 0x9EA8,
+ 0xD868 /*0xDF8C*/, 0x9EBD, 0xD869 /*0xDC37*/, 0x9EDF, 0x9EE7, 0x9EEE, 0x9EFF, 0x9F02,
+ 0x4D77, 0x9F03, 0x9F17, 0x9F19, 0x9F2F, 0x9F37, 0x9F3A, 0x9F3D,
+ 0x9F41, 0x9F45, 0x9F46, 0x9F53, 0x9F55, 0x9F58, 0xD869 /*0xDDF1*/, 0x9F5D,
+ 0xD869 /*0xDE02*/, 0x9F69, 0xD869 /*0xDE1A*/, 0x9F6D, 0x9F70, 0x9F75, 0xD869 /*0xDEB2*/, 0,
+ 0, 0, 0, 0, 0, 0, 0,
+};
+
+#ifdef X0212_ENABLE
+static const unsigned short euc_to_utf8_8FA2[] = {
+ 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0x02D8,
+ 0x02C7, 0x00B8, 0x02D9, 0x02DD, 0x00AF, 0x02DB, 0x02DA, 0xFF5E,
+ 0x0384, 0x0385, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0x00A1, 0xFFE4, 0x00BF, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0x00BA, 0x00AA, 0x00A9, 0x00AE, 0x2122,
+ 0x00A4, 0x2116, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0,
+};
+static const unsigned short euc_to_utf8_8FA6[] = {
+ 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0x0386, 0x0388, 0x0389, 0x038A, 0x03AA, 0, 0x038C,
+ 0, 0x038E, 0x03AB, 0, 0x038F, 0, 0, 0,
+ 0, 0x03AC, 0x03AD, 0x03AE, 0x03AF, 0x03CA, 0x0390, 0x03CC,
+ 0x03C2, 0x03CD, 0x03CB, 0x03B0, 0x03CE, 0, 0,
+};
+static const unsigned short euc_to_utf8_8FA7[] = {
+ 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0x0402, 0x0403, 0x0404, 0x0405, 0x0406, 0x0407,
+ 0x0408, 0x0409, 0x040A, 0x040B, 0x040C, 0x040E, 0x040F, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0x0452, 0x0453, 0x0454, 0x0455, 0x0456, 0x0457,
+ 0x0458, 0x0459, 0x045A, 0x045B, 0x045C, 0x045E, 0x045F,
+};
+static const unsigned short euc_to_utf8_8FA9[] = {
+ 0x00C6, 0x0110, 0, 0x0126, 0, 0x0132, 0,
+ 0x0141, 0x013F, 0, 0x014A, 0x00D8, 0x0152, 0, 0x0166,
+ 0x00DE, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0x00E6, 0x0111, 0x00F0, 0x0127, 0x0131, 0x0133, 0x0138,
+ 0x0142, 0x0140, 0x0149, 0x014B, 0x00F8, 0x0153, 0x00DF, 0x0167,
+ 0x00FE, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0,
+};
+static const unsigned short euc_to_utf8_8FAA[] = {
+ 0x00C1, 0x00C0, 0x00C4, 0x00C2, 0x0102, 0x01CD, 0x0100,
+ 0x0104, 0x00C5, 0x00C3, 0x0106, 0x0108, 0x010C, 0x00C7, 0x010A,
+ 0x010E, 0x00C9, 0x00C8, 0x00CB, 0x00CA, 0x011A, 0x0116, 0x0112,
+ 0x0118, 0, 0x011C, 0x011E, 0x0122, 0x0120, 0x0124, 0x00CD,
+ 0x00CC, 0x00CF, 0x00CE, 0x01CF, 0x0130, 0x012A, 0x012E, 0x0128,
+ 0x0134, 0x0136, 0x0139, 0x013D, 0x013B, 0x0143, 0x0147, 0x0145,
+ 0x00D1, 0x00D3, 0x00D2, 0x00D6, 0x00D4, 0x01D1, 0x0150, 0x014C,
+ 0x00D5, 0x0154, 0x0158, 0x0156, 0x015A, 0x015C, 0x0160, 0x015E,
+ 0x0164, 0x0162, 0x00DA, 0x00D9, 0x00DC, 0x00DB, 0x016C, 0x01D3,
+ 0x0170, 0x016A, 0x0172, 0x016E, 0x0168, 0x01D7, 0x01DB, 0x01D9,
+ 0x01D5, 0x0174, 0x00DD, 0x0178, 0x0176, 0x0179, 0x017D, 0x017B,
+ 0, 0, 0, 0, 0, 0, 0,
+};
+static const unsigned short euc_to_utf8_8FAB[] = {
+ 0x00E1, 0x00E0, 0x00E4, 0x00E2, 0x0103, 0x01CE, 0x0101,
+ 0x0105, 0x00E5, 0x00E3, 0x0107, 0x0109, 0x010D, 0x00E7, 0x010B,
+ 0x010F, 0x00E9, 0x00E8, 0x00EB, 0x00EA, 0x011B, 0x0117, 0x0113,
+ 0x0119, 0x01F5, 0x011D, 0x011F, 0, 0x0121, 0x0125, 0x00ED,
+ 0x00EC, 0x00EF, 0x00EE, 0x01D0, 0, 0x012B, 0x012F, 0x0129,
+ 0x0135, 0x0137, 0x013A, 0x013E, 0x013C, 0x0144, 0x0148, 0x0146,
+ 0x00F1, 0x00F3, 0x00F2, 0x00F6, 0x00F4, 0x01D2, 0x0151, 0x014D,
+ 0x00F5, 0x0155, 0x0159, 0x0157, 0x015B, 0x015D, 0x0161, 0x015F,
+ 0x0165, 0x0163, 0x00FA, 0x00F9, 0x00FC, 0x00FB, 0x016D, 0x01D4,
+ 0x0171, 0x016B, 0x0173, 0x016F, 0x0169, 0x01D8, 0x01DC, 0x01DA,
+ 0x01D6, 0x0175, 0x00FD, 0x00FF, 0x0177, 0x017A, 0x017E, 0x017C,
+ 0, 0, 0, 0, 0, 0, 0,
+};
+static const unsigned short euc_to_utf8_8FB0[] = {
+ 0x4E02, 0x4E04, 0x4E05, 0x4E0C, 0x4E12, 0x4E1F, 0x4E23,
+ 0x4E24, 0x4E28, 0x4E2B, 0x4E2E, 0x4E2F, 0x4E30, 0x4E35, 0x4E40,
+ 0x4E41, 0x4E44, 0x4E47, 0x4E51, 0x4E5A, 0x4E5C, 0x4E63, 0x4E68,
+ 0x4E69, 0x4E74, 0x4E75, 0x4E79, 0x4E7F, 0x4E8D, 0x4E96, 0x4E97,
+ 0x4E9D, 0x4EAF, 0x4EB9, 0x4EC3, 0x4ED0, 0x4EDA, 0x4EDB, 0x4EE0,
+ 0x4EE1, 0x4EE2, 0x4EE8, 0x4EEF, 0x4EF1, 0x4EF3, 0x4EF5, 0x4EFD,
+ 0x4EFE, 0x4EFF, 0x4F00, 0x4F02, 0x4F03, 0x4F08, 0x4F0B, 0x4F0C,
+ 0x4F12, 0x4F15, 0x4F16, 0x4F17, 0x4F19, 0x4F2E, 0x4F31, 0x4F60,
+ 0x4F33, 0x4F35, 0x4F37, 0x4F39, 0x4F3B, 0x4F3E, 0x4F40, 0x4F42,
+ 0x4F48, 0x4F49, 0x4F4B, 0x4F4C, 0x4F52, 0x4F54, 0x4F56, 0x4F58,
+ 0x4F5F, 0x4F63, 0x4F6A, 0x4F6C, 0x4F6E, 0x4F71, 0x4F77, 0x4F78,
+ 0x4F79, 0x4F7A, 0x4F7D, 0x4F7E, 0x4F81, 0x4F82, 0x4F84,
+};
+static const unsigned short euc_to_utf8_8FB1[] = {
+ 0x4F85, 0x4F89, 0x4F8A, 0x4F8C, 0x4F8E, 0x4F90, 0x4F92,
+ 0x4F93, 0x4F94, 0x4F97, 0x4F99, 0x4F9A, 0x4F9E, 0x4F9F, 0x4FB2,
+ 0x4FB7, 0x4FB9, 0x4FBB, 0x4FBC, 0x4FBD, 0x4FBE, 0x4FC0, 0x4FC1,
+ 0x4FC5, 0x4FC6, 0x4FC8, 0x4FC9, 0x4FCB, 0x4FCC, 0x4FCD, 0x4FCF,
+ 0x4FD2, 0x4FDC, 0x4FE0, 0x4FE2, 0x4FF0, 0x4FF2, 0x4FFC, 0x4FFD,
+ 0x4FFF, 0x5000, 0x5001, 0x5004, 0x5007, 0x500A, 0x500C, 0x500E,
+ 0x5010, 0x5013, 0x5017, 0x5018, 0x501B, 0x501C, 0x501D, 0x501E,
+ 0x5022, 0x5027, 0x502E, 0x5030, 0x5032, 0x5033, 0x5035, 0x5040,
+ 0x5041, 0x5042, 0x5045, 0x5046, 0x504A, 0x504C, 0x504E, 0x5051,
+ 0x5052, 0x5053, 0x5057, 0x5059, 0x505F, 0x5060, 0x5062, 0x5063,
+ 0x5066, 0x5067, 0x506A, 0x506D, 0x5070, 0x5071, 0x503B, 0x5081,
+ 0x5083, 0x5084, 0x5086, 0x508A, 0x508E, 0x508F, 0x5090,
+};
+static const unsigned short euc_to_utf8_8FB2[] = {
+ 0x5092, 0x5093, 0x5094, 0x5096, 0x509B, 0x509C, 0x509E,
+ 0x509F, 0x50A0, 0x50A1, 0x50A2, 0x50AA, 0x50AF, 0x50B0, 0x50B9,
+ 0x50BA, 0x50BD, 0x50C0, 0x50C3, 0x50C4, 0x50C7, 0x50CC, 0x50CE,
+ 0x50D0, 0x50D3, 0x50D4, 0x50D8, 0x50DC, 0x50DD, 0x50DF, 0x50E2,
+ 0x50E4, 0x50E6, 0x50E8, 0x50E9, 0x50EF, 0x50F1, 0x50F6, 0x50FA,
+ 0x50FE, 0x5103, 0x5106, 0x5107, 0x5108, 0x510B, 0x510C, 0x510D,
+ 0x510E, 0x50F2, 0x5110, 0x5117, 0x5119, 0x511B, 0x511C, 0x511D,
+ 0x511E, 0x5123, 0x5127, 0x5128, 0x512C, 0x512D, 0x512F, 0x5131,
+ 0x5133, 0x5134, 0x5135, 0x5138, 0x5139, 0x5142, 0x514A, 0x514F,
+ 0x5153, 0x5155, 0x5157, 0x5158, 0x515F, 0x5164, 0x5166, 0x517E,
+ 0x5183, 0x5184, 0x518B, 0x518E, 0x5198, 0x519D, 0x51A1, 0x51A3,
+ 0x51AD, 0x51B8, 0x51BA, 0x51BC, 0x51BE, 0x51BF, 0x51C2,
+};
+static const unsigned short euc_to_utf8_8FB3[] = {
+ 0x51C8, 0x51CF, 0x51D1, 0x51D2, 0x51D3, 0x51D5, 0x51D8,
+ 0x51DE, 0x51E2, 0x51E5, 0x51EE, 0x51F2, 0x51F3, 0x51F4, 0x51F7,
+ 0x5201, 0x5202, 0x5205, 0x5212, 0x5213, 0x5215, 0x5216, 0x5218,
+ 0x5222, 0x5228, 0x5231, 0x5232, 0x5235, 0x523C, 0x5245, 0x5249,
+ 0x5255, 0x5257, 0x5258, 0x525A, 0x525C, 0x525F, 0x5260, 0x5261,
+ 0x5266, 0x526E, 0x5277, 0x5278, 0x5279, 0x5280, 0x5282, 0x5285,
+ 0x528A, 0x528C, 0x5293, 0x5295, 0x5296, 0x5297, 0x5298, 0x529A,
+ 0x529C, 0x52A4, 0x52A5, 0x52A6, 0x52A7, 0x52AF, 0x52B0, 0x52B6,
+ 0x52B7, 0x52B8, 0x52BA, 0x52BB, 0x52BD, 0x52C0, 0x52C4, 0x52C6,
+ 0x52C8, 0x52CC, 0x52CF, 0x52D1, 0x52D4, 0x52D6, 0x52DB, 0x52DC,
+ 0x52E1, 0x52E5, 0x52E8, 0x52E9, 0x52EA, 0x52EC, 0x52F0, 0x52F1,
+ 0x52F4, 0x52F6, 0x52F7, 0x5300, 0x5303, 0x530A, 0x530B,
+};
+static const unsigned short euc_to_utf8_8FB4[] = {
+ 0x530C, 0x5311, 0x5313, 0x5318, 0x531B, 0x531C, 0x531E,
+ 0x531F, 0x5325, 0x5327, 0x5328, 0x5329, 0x532B, 0x532C, 0x532D,
+ 0x5330, 0x5332, 0x5335, 0x533C, 0x533D, 0x533E, 0x5342, 0x534C,
+ 0x534B, 0x5359, 0x535B, 0x5361, 0x5363, 0x5365, 0x536C, 0x536D,
+ 0x5372, 0x5379, 0x537E, 0x5383, 0x5387, 0x5388, 0x538E, 0x5393,
+ 0x5394, 0x5399, 0x539D, 0x53A1, 0x53A4, 0x53AA, 0x53AB, 0x53AF,
+ 0x53B2, 0x53B4, 0x53B5, 0x53B7, 0x53B8, 0x53BA, 0x53BD, 0x53C0,
+ 0x53C5, 0x53CF, 0x53D2, 0x53D3, 0x53D5, 0x53DA, 0x53DD, 0x53DE,
+ 0x53E0, 0x53E6, 0x53E7, 0x53F5, 0x5402, 0x5413, 0x541A, 0x5421,
+ 0x5427, 0x5428, 0x542A, 0x542F, 0x5431, 0x5434, 0x5435, 0x5443,
+ 0x5444, 0x5447, 0x544D, 0x544F, 0x545E, 0x5462, 0x5464, 0x5466,
+ 0x5467, 0x5469, 0x546B, 0x546D, 0x546E, 0x5474, 0x547F,
+};
+static const unsigned short euc_to_utf8_8FB5[] = {
+ 0x5481, 0x5483, 0x5485, 0x5488, 0x5489, 0x548D, 0x5491,
+ 0x5495, 0x5496, 0x549C, 0x549F, 0x54A1, 0x54A6, 0x54A7, 0x54A9,
+ 0x54AA, 0x54AD, 0x54AE, 0x54B1, 0x54B7, 0x54B9, 0x54BA, 0x54BB,
+ 0x54BF, 0x54C6, 0x54CA, 0x54CD, 0x54CE, 0x54E0, 0x54EA, 0x54EC,
+ 0x54EF, 0x54F6, 0x54FC, 0x54FE, 0x54FF, 0x5500, 0x5501, 0x5505,
+ 0x5508, 0x5509, 0x550C, 0x550D, 0x550E, 0x5515, 0x552A, 0x552B,
+ 0x5532, 0x5535, 0x5536, 0x553B, 0x553C, 0x553D, 0x5541, 0x5547,
+ 0x5549, 0x554A, 0x554D, 0x5550, 0x5551, 0x5558, 0x555A, 0x555B,
+ 0x555E, 0x5560, 0x5561, 0x5564, 0x5566, 0x557F, 0x5581, 0x5582,
+ 0x5586, 0x5588, 0x558E, 0x558F, 0x5591, 0x5592, 0x5593, 0x5594,
+ 0x5597, 0x55A3, 0x55A4, 0x55AD, 0x55B2, 0x55BF, 0x55C1, 0x55C3,
+ 0x55C6, 0x55C9, 0x55CB, 0x55CC, 0x55CE, 0x55D1, 0x55D2,
+};
+static const unsigned short euc_to_utf8_8FB6[] = {
+ 0x55D3, 0x55D7, 0x55D8, 0x55DB, 0x55DE, 0x55E2, 0x55E9,
+ 0x55F6, 0x55FF, 0x5605, 0x5608, 0x560A, 0x560D, 0x560E, 0x560F,
+ 0x5610, 0x5611, 0x5612, 0x5619, 0x562C, 0x5630, 0x5633, 0x5635,
+ 0x5637, 0x5639, 0x563B, 0x563C, 0x563D, 0x563F, 0x5640, 0x5641,
+ 0x5643, 0x5644, 0x5646, 0x5649, 0x564B, 0x564D, 0x564F, 0x5654,
+ 0x565E, 0x5660, 0x5661, 0x5662, 0x5663, 0x5666, 0x5669, 0x566D,
+ 0x566F, 0x5671, 0x5672, 0x5675, 0x5684, 0x5685, 0x5688, 0x568B,
+ 0x568C, 0x5695, 0x5699, 0x569A, 0x569D, 0x569E, 0x569F, 0x56A6,
+ 0x56A7, 0x56A8, 0x56A9, 0x56AB, 0x56AC, 0x56AD, 0x56B1, 0x56B3,
+ 0x56B7, 0x56BE, 0x56C5, 0x56C9, 0x56CA, 0x56CB, 0x56CF, 0x56D0,
+ 0x56CC, 0x56CD, 0x56D9, 0x56DC, 0x56DD, 0x56DF, 0x56E1, 0x56E4,
+ 0x56E5, 0x56E6, 0x56E7, 0x56E8, 0x56F1, 0x56EB, 0x56ED,
+};
+static const unsigned short euc_to_utf8_8FB7[] = {
+ 0x56F6, 0x56F7, 0x5701, 0x5702, 0x5707, 0x570A, 0x570C,
+ 0x5711, 0x5715, 0x571A, 0x571B, 0x571D, 0x5720, 0x5722, 0x5723,
+ 0x5724, 0x5725, 0x5729, 0x572A, 0x572C, 0x572E, 0x572F, 0x5733,
+ 0x5734, 0x573D, 0x573E, 0x573F, 0x5745, 0x5746, 0x574C, 0x574D,
+ 0x5752, 0x5762, 0x5765, 0x5767, 0x5768, 0x576B, 0x576D, 0x576E,
+ 0x576F, 0x5770, 0x5771, 0x5773, 0x5774, 0x5775, 0x5777, 0x5779,
+ 0x577A, 0x577B, 0x577C, 0x577E, 0x5781, 0x5783, 0x578C, 0x5794,
+ 0x5797, 0x5799, 0x579A, 0x579C, 0x579D, 0x579E, 0x579F, 0x57A1,
+ 0x5795, 0x57A7, 0x57A8, 0x57A9, 0x57AC, 0x57B8, 0x57BD, 0x57C7,
+ 0x57C8, 0x57CC, 0x57CF, 0x57D5, 0x57DD, 0x57DE, 0x57E4, 0x57E6,
+ 0x57E7, 0x57E9, 0x57ED, 0x57F0, 0x57F5, 0x57F6, 0x57F8, 0x57FD,
+ 0x57FE, 0x57FF, 0x5803, 0x5804, 0x5808, 0x5809, 0x57E1,
+};
+static const unsigned short euc_to_utf8_8FB8[] = {
+ 0x580C, 0x580D, 0x581B, 0x581E, 0x581F, 0x5820, 0x5826,
+ 0x5827, 0x582D, 0x5832, 0x5839, 0x583F, 0x5849, 0x584C, 0x584D,
+ 0x584F, 0x5850, 0x5855, 0x585F, 0x5861, 0x5864, 0x5867, 0x5868,
+ 0x5878, 0x587C, 0x587F, 0x5880, 0x5881, 0x5887, 0x5888, 0x5889,
+ 0x588A, 0x588C, 0x588D, 0x588F, 0x5890, 0x5894, 0x5896, 0x589D,
+ 0x58A0, 0x58A1, 0x58A2, 0x58A6, 0x58A9, 0x58B1, 0x58B2, 0x58C4,
+ 0x58BC, 0x58C2, 0x58C8, 0x58CD, 0x58CE, 0x58D0, 0x58D2, 0x58D4,
+ 0x58D6, 0x58DA, 0x58DD, 0x58E1, 0x58E2, 0x58E9, 0x58F3, 0x5905,
+ 0x5906, 0x590B, 0x590C, 0x5912, 0x5913, 0x5914, 0x8641, 0x591D,
+ 0x5921, 0x5923, 0x5924, 0x5928, 0x592F, 0x5930, 0x5933, 0x5935,
+ 0x5936, 0x593F, 0x5943, 0x5946, 0x5952, 0x5953, 0x5959, 0x595B,
+ 0x595D, 0x595E, 0x595F, 0x5961, 0x5963, 0x596B, 0x596D,
+};
+static const unsigned short euc_to_utf8_8FB9[] = {
+ 0x596F, 0x5972, 0x5975, 0x5976, 0x5979, 0x597B, 0x597C,
+ 0x598B, 0x598C, 0x598E, 0x5992, 0x5995, 0x5997, 0x599F, 0x59A4,
+ 0x59A7, 0x59AD, 0x59AE, 0x59AF, 0x59B0, 0x59B3, 0x59B7, 0x59BA,
+ 0x59BC, 0x59C1, 0x59C3, 0x59C4, 0x59C8, 0x59CA, 0x59CD, 0x59D2,
+ 0x59DD, 0x59DE, 0x59DF, 0x59E3, 0x59E4, 0x59E7, 0x59EE, 0x59EF,
+ 0x59F1, 0x59F2, 0x59F4, 0x59F7, 0x5A00, 0x5A04, 0x5A0C, 0x5A0D,
+ 0x5A0E, 0x5A12, 0x5A13, 0x5A1E, 0x5A23, 0x5A24, 0x5A27, 0x5A28,
+ 0x5A2A, 0x5A2D, 0x5A30, 0x5A44, 0x5A45, 0x5A47, 0x5A48, 0x5A4C,
+ 0x5A50, 0x5A55, 0x5A5E, 0x5A63, 0x5A65, 0x5A67, 0x5A6D, 0x5A77,
+ 0x5A7A, 0x5A7B, 0x5A7E, 0x5A8B, 0x5A90, 0x5A93, 0x5A96, 0x5A99,
+ 0x5A9C, 0x5A9E, 0x5A9F, 0x5AA0, 0x5AA2, 0x5AA7, 0x5AAC, 0x5AB1,
+ 0x5AB2, 0x5AB3, 0x5AB5, 0x5AB8, 0x5ABA, 0x5ABB, 0x5ABF,
+};
+static const unsigned short euc_to_utf8_8FBA[] = {
+ 0x5AC4, 0x5AC6, 0x5AC8, 0x5ACF, 0x5ADA, 0x5ADC, 0x5AE0,
+ 0x5AE5, 0x5AEA, 0x5AEE, 0x5AF5, 0x5AF6, 0x5AFD, 0x5B00, 0x5B01,
+ 0x5B08, 0x5B17, 0x5B34, 0x5B19, 0x5B1B, 0x5B1D, 0x5B21, 0x5B25,
+ 0x5B2D, 0x5B38, 0x5B41, 0x5B4B, 0x5B4C, 0x5B52, 0x5B56, 0x5B5E,
+ 0x5B68, 0x5B6E, 0x5B6F, 0x5B7C, 0x5B7D, 0x5B7E, 0x5B7F, 0x5B81,
+ 0x5B84, 0x5B86, 0x5B8A, 0x5B8E, 0x5B90, 0x5B91, 0x5B93, 0x5B94,
+ 0x5B96, 0x5BA8, 0x5BA9, 0x5BAC, 0x5BAD, 0x5BAF, 0x5BB1, 0x5BB2,
+ 0x5BB7, 0x5BBA, 0x5BBC, 0x5BC0, 0x5BC1, 0x5BCD, 0x5BCF, 0x5BD6,
+ 0x5BD7, 0x5BD8, 0x5BD9, 0x5BDA, 0x5BE0, 0x5BEF, 0x5BF1, 0x5BF4,
+ 0x5BFD, 0x5C0C, 0x5C17, 0x5C1E, 0x5C1F, 0x5C23, 0x5C26, 0x5C29,
+ 0x5C2B, 0x5C2C, 0x5C2E, 0x5C30, 0x5C32, 0x5C35, 0x5C36, 0x5C59,
+ 0x5C5A, 0x5C5C, 0x5C62, 0x5C63, 0x5C67, 0x5C68, 0x5C69,
+};
+static const unsigned short euc_to_utf8_8FBB[] = {
+ 0x5C6D, 0x5C70, 0x5C74, 0x5C75, 0x5C7A, 0x5C7B, 0x5C7C,
+ 0x5C7D, 0x5C87, 0x5C88, 0x5C8A, 0x5C8F, 0x5C92, 0x5C9D, 0x5C9F,
+ 0x5CA0, 0x5CA2, 0x5CA3, 0x5CA6, 0x5CAA, 0x5CB2, 0x5CB4, 0x5CB5,
+ 0x5CBA, 0x5CC9, 0x5CCB, 0x5CD2, 0x5CDD, 0x5CD7, 0x5CEE, 0x5CF1,
+ 0x5CF2, 0x5CF4, 0x5D01, 0x5D06, 0x5D0D, 0x5D12, 0x5D2B, 0x5D23,
+ 0x5D24, 0x5D26, 0x5D27, 0x5D31, 0x5D34, 0x5D39, 0x5D3D, 0x5D3F,
+ 0x5D42, 0x5D43, 0x5D46, 0x5D48, 0x5D55, 0x5D51, 0x5D59, 0x5D4A,
+ 0x5D5F, 0x5D60, 0x5D61, 0x5D62, 0x5D64, 0x5D6A, 0x5D6D, 0x5D70,
+ 0x5D79, 0x5D7A, 0x5D7E, 0x5D7F, 0x5D81, 0x5D83, 0x5D88, 0x5D8A,
+ 0x5D92, 0x5D93, 0x5D94, 0x5D95, 0x5D99, 0x5D9B, 0x5D9F, 0x5DA0,
+ 0x5DA7, 0x5DAB, 0x5DB0, 0x5DB4, 0x5DB8, 0x5DB9, 0x5DC3, 0x5DC7,
+ 0x5DCB, 0x5DD0, 0x5DCE, 0x5DD8, 0x5DD9, 0x5DE0, 0x5DE4,
+};
+static const unsigned short euc_to_utf8_8FBC[] = {
+ 0x5DE9, 0x5DF8, 0x5DF9, 0x5E00, 0x5E07, 0x5E0D, 0x5E12,
+ 0x5E14, 0x5E15, 0x5E18, 0x5E1F, 0x5E20, 0x5E2E, 0x5E28, 0x5E32,
+ 0x5E35, 0x5E3E, 0x5E4B, 0x5E50, 0x5E49, 0x5E51, 0x5E56, 0x5E58,
+ 0x5E5B, 0x5E5C, 0x5E5E, 0x5E68, 0x5E6A, 0x5E6B, 0x5E6C, 0x5E6D,
+ 0x5E6E, 0x5E70, 0x5E80, 0x5E8B, 0x5E8E, 0x5EA2, 0x5EA4, 0x5EA5,
+ 0x5EA8, 0x5EAA, 0x5EAC, 0x5EB1, 0x5EB3, 0x5EBD, 0x5EBE, 0x5EBF,
+ 0x5EC6, 0x5ECC, 0x5ECB, 0x5ECE, 0x5ED1, 0x5ED2, 0x5ED4, 0x5ED5,
+ 0x5EDC, 0x5EDE, 0x5EE5, 0x5EEB, 0x5F02, 0x5F06, 0x5F07, 0x5F08,
+ 0x5F0E, 0x5F19, 0x5F1C, 0x5F1D, 0x5F21, 0x5F22, 0x5F23, 0x5F24,
+ 0x5F28, 0x5F2B, 0x5F2C, 0x5F2E, 0x5F30, 0x5F34, 0x5F36, 0x5F3B,
+ 0x5F3D, 0x5F3F, 0x5F40, 0x5F44, 0x5F45, 0x5F47, 0x5F4D, 0x5F50,
+ 0x5F54, 0x5F58, 0x5F5B, 0x5F60, 0x5F63, 0x5F64, 0x5F67,
+};
+static const unsigned short euc_to_utf8_8FBD[] = {
+ 0x5F6F, 0x5F72, 0x5F74, 0x5F75, 0x5F78, 0x5F7A, 0x5F7D,
+ 0x5F7E, 0x5F89, 0x5F8D, 0x5F8F, 0x5F96, 0x5F9C, 0x5F9D, 0x5FA2,
+ 0x5FA7, 0x5FAB, 0x5FA4, 0x5FAC, 0x5FAF, 0x5FB0, 0x5FB1, 0x5FB8,
+ 0x5FC4, 0x5FC7, 0x5FC8, 0x5FC9, 0x5FCB, 0x5FD0, 0x5FD1, 0x5FD2,
+ 0x5FD3, 0x5FD4, 0x5FDE, 0x5FE1, 0x5FE2, 0x5FE8, 0x5FE9, 0x5FEA,
+ 0x5FEC, 0x5FED, 0x5FEE, 0x5FEF, 0x5FF2, 0x5FF3, 0x5FF6, 0x5FFA,
+ 0x5FFC, 0x6007, 0x600A, 0x600D, 0x6013, 0x6014, 0x6017, 0x6018,
+ 0x601A, 0x601F, 0x6024, 0x602D, 0x6033, 0x6035, 0x6040, 0x6047,
+ 0x6048, 0x6049, 0x604C, 0x6051, 0x6054, 0x6056, 0x6057, 0x605D,
+ 0x6061, 0x6067, 0x6071, 0x607E, 0x607F, 0x6082, 0x6086, 0x6088,
+ 0x608A, 0x608E, 0x6091, 0x6093, 0x6095, 0x6098, 0x609D, 0x609E,
+ 0x60A2, 0x60A4, 0x60A5, 0x60A8, 0x60B0, 0x60B1, 0x60B7,
+};
+static const unsigned short euc_to_utf8_8FBE[] = {
+ 0x60BB, 0x60BE, 0x60C2, 0x60C4, 0x60C8, 0x60C9, 0x60CA,
+ 0x60CB, 0x60CE, 0x60CF, 0x60D4, 0x60D5, 0x60D9, 0x60DB, 0x60DD,
+ 0x60DE, 0x60E2, 0x60E5, 0x60F2, 0x60F5, 0x60F8, 0x60FC, 0x60FD,
+ 0x6102, 0x6107, 0x610A, 0x610C, 0x6110, 0x6111, 0x6112, 0x6113,
+ 0x6114, 0x6116, 0x6117, 0x6119, 0x611C, 0x611E, 0x6122, 0x612A,
+ 0x612B, 0x6130, 0x6131, 0x6135, 0x6136, 0x6137, 0x6139, 0x6141,
+ 0x6145, 0x6146, 0x6149, 0x615E, 0x6160, 0x616C, 0x6172, 0x6178,
+ 0x617B, 0x617C, 0x617F, 0x6180, 0x6181, 0x6183, 0x6184, 0x618B,
+ 0x618D, 0x6192, 0x6193, 0x6197, 0x6198, 0x619C, 0x619D, 0x619F,
+ 0x61A0, 0x61A5, 0x61A8, 0x61AA, 0x61AD, 0x61B8, 0x61B9, 0x61BC,
+ 0x61C0, 0x61C1, 0x61C2, 0x61CE, 0x61CF, 0x61D5, 0x61DC, 0x61DD,
+ 0x61DE, 0x61DF, 0x61E1, 0x61E2, 0x61E7, 0x61E9, 0x61E5,
+};
+static const unsigned short euc_to_utf8_8FBF[] = {
+ 0x61EC, 0x61ED, 0x61EF, 0x6201, 0x6203, 0x6204, 0x6207,
+ 0x6213, 0x6215, 0x621C, 0x6220, 0x6222, 0x6223, 0x6227, 0x6229,
+ 0x622B, 0x6239, 0x623D, 0x6242, 0x6243, 0x6244, 0x6246, 0x624C,
+ 0x6250, 0x6251, 0x6252, 0x6254, 0x6256, 0x625A, 0x625C, 0x6264,
+ 0x626D, 0x626F, 0x6273, 0x627A, 0x627D, 0x628D, 0x628E, 0x628F,
+ 0x6290, 0x62A6, 0x62A8, 0x62B3, 0x62B6, 0x62B7, 0x62BA, 0x62BE,
+ 0x62BF, 0x62C4, 0x62CE, 0x62D5, 0x62D6, 0x62DA, 0x62EA, 0x62F2,
+ 0x62F4, 0x62FC, 0x62FD, 0x6303, 0x6304, 0x630A, 0x630B, 0x630D,
+ 0x6310, 0x6313, 0x6316, 0x6318, 0x6329, 0x632A, 0x632D, 0x6335,
+ 0x6336, 0x6339, 0x633C, 0x6341, 0x6342, 0x6343, 0x6344, 0x6346,
+ 0x634A, 0x634B, 0x634E, 0x6352, 0x6353, 0x6354, 0x6358, 0x635B,
+ 0x6365, 0x6366, 0x636C, 0x636D, 0x6371, 0x6374, 0x6375,
+};
+static const unsigned short euc_to_utf8_8FC0[] = {
+ 0x6378, 0x637C, 0x637D, 0x637F, 0x6382, 0x6384, 0x6387,
+ 0x638A, 0x6390, 0x6394, 0x6395, 0x6399, 0x639A, 0x639E, 0x63A4,
+ 0x63A6, 0x63AD, 0x63AE, 0x63AF, 0x63BD, 0x63C1, 0x63C5, 0x63C8,
+ 0x63CE, 0x63D1, 0x63D3, 0x63D4, 0x63D5, 0x63DC, 0x63E0, 0x63E5,
+ 0x63EA, 0x63EC, 0x63F2, 0x63F3, 0x63F5, 0x63F8, 0x63F9, 0x6409,
+ 0x640A, 0x6410, 0x6412, 0x6414, 0x6418, 0x641E, 0x6420, 0x6422,
+ 0x6424, 0x6425, 0x6429, 0x642A, 0x642F, 0x6430, 0x6435, 0x643D,
+ 0x643F, 0x644B, 0x644F, 0x6451, 0x6452, 0x6453, 0x6454, 0x645A,
+ 0x645B, 0x645C, 0x645D, 0x645F, 0x6460, 0x6461, 0x6463, 0x646D,
+ 0x6473, 0x6474, 0x647B, 0x647D, 0x6485, 0x6487, 0x648F, 0x6490,
+ 0x6491, 0x6498, 0x6499, 0x649B, 0x649D, 0x649F, 0x64A1, 0x64A3,
+ 0x64A6, 0x64A8, 0x64AC, 0x64B3, 0x64BD, 0x64BE, 0x64BF,
+};
+static const unsigned short euc_to_utf8_8FC1[] = {
+ 0x64C4, 0x64C9, 0x64CA, 0x64CB, 0x64CC, 0x64CE, 0x64D0,
+ 0x64D1, 0x64D5, 0x64D7, 0x64E4, 0x64E5, 0x64E9, 0x64EA, 0x64ED,
+ 0x64F0, 0x64F5, 0x64F7, 0x64FB, 0x64FF, 0x6501, 0x6504, 0x6508,
+ 0x6509, 0x650A, 0x650F, 0x6513, 0x6514, 0x6516, 0x6519, 0x651B,
+ 0x651E, 0x651F, 0x6522, 0x6526, 0x6529, 0x652E, 0x6531, 0x653A,
+ 0x653C, 0x653D, 0x6543, 0x6547, 0x6549, 0x6550, 0x6552, 0x6554,
+ 0x655F, 0x6560, 0x6567, 0x656B, 0x657A, 0x657D, 0x6581, 0x6585,
+ 0x658A, 0x6592, 0x6595, 0x6598, 0x659D, 0x65A0, 0x65A3, 0x65A6,
+ 0x65AE, 0x65B2, 0x65B3, 0x65B4, 0x65BF, 0x65C2, 0x65C8, 0x65C9,
+ 0x65CE, 0x65D0, 0x65D4, 0x65D6, 0x65D8, 0x65DF, 0x65F0, 0x65F2,
+ 0x65F4, 0x65F5, 0x65F9, 0x65FE, 0x65FF, 0x6600, 0x6604, 0x6608,
+ 0x6609, 0x660D, 0x6611, 0x6612, 0x6615, 0x6616, 0x661D,
+};
+static const unsigned short euc_to_utf8_8FC2[] = {
+ 0x661E, 0x6621, 0x6622, 0x6623, 0x6624, 0x6626, 0x6629,
+ 0x662A, 0x662B, 0x662C, 0x662E, 0x6630, 0x6631, 0x6633, 0x6639,
+ 0x6637, 0x6640, 0x6645, 0x6646, 0x664A, 0x664C, 0x6651, 0x664E,
+ 0x6657, 0x6658, 0x6659, 0x665B, 0x665C, 0x6660, 0x6661, 0x66FB,
+ 0x666A, 0x666B, 0x666C, 0x667E, 0x6673, 0x6675, 0x667F, 0x6677,
+ 0x6678, 0x6679, 0x667B, 0x6680, 0x667C, 0x668B, 0x668C, 0x668D,
+ 0x6690, 0x6692, 0x6699, 0x669A, 0x669B, 0x669C, 0x669F, 0x66A0,
+ 0x66A4, 0x66AD, 0x66B1, 0x66B2, 0x66B5, 0x66BB, 0x66BF, 0x66C0,
+ 0x66C2, 0x66C3, 0x66C8, 0x66CC, 0x66CE, 0x66CF, 0x66D4, 0x66DB,
+ 0x66DF, 0x66E8, 0x66EB, 0x66EC, 0x66EE, 0x66FA, 0x6705, 0x6707,
+ 0x670E, 0x6713, 0x6719, 0x671C, 0x6720, 0x6722, 0x6733, 0x673E,
+ 0x6745, 0x6747, 0x6748, 0x674C, 0x6754, 0x6755, 0x675D,
+};
+static const unsigned short euc_to_utf8_8FC3[] = {
+ 0x6766, 0x676C, 0x676E, 0x6774, 0x6776, 0x677B, 0x6781,
+ 0x6784, 0x678E, 0x678F, 0x6791, 0x6793, 0x6796, 0x6798, 0x6799,
+ 0x679B, 0x67B0, 0x67B1, 0x67B2, 0x67B5, 0x67BB, 0x67BC, 0x67BD,
+ 0x67F9, 0x67C0, 0x67C2, 0x67C3, 0x67C5, 0x67C8, 0x67C9, 0x67D2,
+ 0x67D7, 0x67D9, 0x67DC, 0x67E1, 0x67E6, 0x67F0, 0x67F2, 0x67F6,
+ 0x67F7, 0x6852, 0x6814, 0x6819, 0x681D, 0x681F, 0x6828, 0x6827,
+ 0x682C, 0x682D, 0x682F, 0x6830, 0x6831, 0x6833, 0x683B, 0x683F,
+ 0x6844, 0x6845, 0x684A, 0x684C, 0x6855, 0x6857, 0x6858, 0x685B,
+ 0x686B, 0x686E, 0x686F, 0x6870, 0x6871, 0x6872, 0x6875, 0x6879,
+ 0x687A, 0x687B, 0x687C, 0x6882, 0x6884, 0x6886, 0x6888, 0x6896,
+ 0x6898, 0x689A, 0x689C, 0x68A1, 0x68A3, 0x68A5, 0x68A9, 0x68AA,
+ 0x68AE, 0x68B2, 0x68BB, 0x68C5, 0x68C8, 0x68CC, 0x68CF,
+};
+static const unsigned short euc_to_utf8_8FC4[] = {
+ 0x68D0, 0x68D1, 0x68D3, 0x68D6, 0x68D9, 0x68DC, 0x68DD,
+ 0x68E5, 0x68E8, 0x68EA, 0x68EB, 0x68EC, 0x68ED, 0x68F0, 0x68F1,
+ 0x68F5, 0x68F6, 0x68FB, 0x68FC, 0x68FD, 0x6906, 0x6909, 0x690A,
+ 0x6910, 0x6911, 0x6913, 0x6916, 0x6917, 0x6931, 0x6933, 0x6935,
+ 0x6938, 0x693B, 0x6942, 0x6945, 0x6949, 0x694E, 0x6957, 0x695B,
+ 0x6963, 0x6964, 0x6965, 0x6966, 0x6968, 0x6969, 0x696C, 0x6970,
+ 0x6971, 0x6972, 0x697A, 0x697B, 0x697F, 0x6980, 0x698D, 0x6992,
+ 0x6996, 0x6998, 0x69A1, 0x69A5, 0x69A6, 0x69A8, 0x69AB, 0x69AD,
+ 0x69AF, 0x69B7, 0x69B8, 0x69BA, 0x69BC, 0x69C5, 0x69C8, 0x69D1,
+ 0x69D6, 0x69D7, 0x69E2, 0x69E5, 0x69EE, 0x69EF, 0x69F1, 0x69F3,
+ 0x69F5, 0x69FE, 0x6A00, 0x6A01, 0x6A03, 0x6A0F, 0x6A11, 0x6A15,
+ 0x6A1A, 0x6A1D, 0x6A20, 0x6A24, 0x6A28, 0x6A30, 0x6A32,
+};
+static const unsigned short euc_to_utf8_8FC5[] = {
+ 0x6A34, 0x6A37, 0x6A3B, 0x6A3E, 0x6A3F, 0x6A45, 0x6A46,
+ 0x6A49, 0x6A4A, 0x6A4E, 0x6A50, 0x6A51, 0x6A52, 0x6A55, 0x6A56,
+ 0x6A5B, 0x6A64, 0x6A67, 0x6A6A, 0x6A71, 0x6A73, 0x6A7E, 0x6A81,
+ 0x6A83, 0x6A86, 0x6A87, 0x6A89, 0x6A8B, 0x6A91, 0x6A9B, 0x6A9D,
+ 0x6A9E, 0x6A9F, 0x6AA5, 0x6AAB, 0x6AAF, 0x6AB0, 0x6AB1, 0x6AB4,
+ 0x6ABD, 0x6ABE, 0x6ABF, 0x6AC6, 0x6AC9, 0x6AC8, 0x6ACC, 0x6AD0,
+ 0x6AD4, 0x6AD5, 0x6AD6, 0x6ADC, 0x6ADD, 0x6AE4, 0x6AE7, 0x6AEC,
+ 0x6AF0, 0x6AF1, 0x6AF2, 0x6AFC, 0x6AFD, 0x6B02, 0x6B03, 0x6B06,
+ 0x6B07, 0x6B09, 0x6B0F, 0x6B10, 0x6B11, 0x6B17, 0x6B1B, 0x6B1E,
+ 0x6B24, 0x6B28, 0x6B2B, 0x6B2C, 0x6B2F, 0x6B35, 0x6B36, 0x6B3B,
+ 0x6B3F, 0x6B46, 0x6B4A, 0x6B4D, 0x6B52, 0x6B56, 0x6B58, 0x6B5D,
+ 0x6B60, 0x6B67, 0x6B6B, 0x6B6E, 0x6B70, 0x6B75, 0x6B7D,
+};
+static const unsigned short euc_to_utf8_8FC6[] = {
+ 0x6B7E, 0x6B82, 0x6B85, 0x6B97, 0x6B9B, 0x6B9F, 0x6BA0,
+ 0x6BA2, 0x6BA3, 0x6BA8, 0x6BA9, 0x6BAC, 0x6BAD, 0x6BAE, 0x6BB0,
+ 0x6BB8, 0x6BB9, 0x6BBD, 0x6BBE, 0x6BC3, 0x6BC4, 0x6BC9, 0x6BCC,
+ 0x6BD6, 0x6BDA, 0x6BE1, 0x6BE3, 0x6BE6, 0x6BE7, 0x6BEE, 0x6BF1,
+ 0x6BF7, 0x6BF9, 0x6BFF, 0x6C02, 0x6C04, 0x6C05, 0x6C09, 0x6C0D,
+ 0x6C0E, 0x6C10, 0x6C12, 0x6C19, 0x6C1F, 0x6C26, 0x6C27, 0x6C28,
+ 0x6C2C, 0x6C2E, 0x6C33, 0x6C35, 0x6C36, 0x6C3A, 0x6C3B, 0x6C3F,
+ 0x6C4A, 0x6C4B, 0x6C4D, 0x6C4F, 0x6C52, 0x6C54, 0x6C59, 0x6C5B,
+ 0x6C5C, 0x6C6B, 0x6C6D, 0x6C6F, 0x6C74, 0x6C76, 0x6C78, 0x6C79,
+ 0x6C7B, 0x6C85, 0x6C86, 0x6C87, 0x6C89, 0x6C94, 0x6C95, 0x6C97,
+ 0x6C98, 0x6C9C, 0x6C9F, 0x6CB0, 0x6CB2, 0x6CB4, 0x6CC2, 0x6CC6,
+ 0x6CCD, 0x6CCF, 0x6CD0, 0x6CD1, 0x6CD2, 0x6CD4, 0x6CD6,
+};
+static const unsigned short euc_to_utf8_8FC7[] = {
+ 0x6CDA, 0x6CDC, 0x6CE0, 0x6CE7, 0x6CE9, 0x6CEB, 0x6CEC,
+ 0x6CEE, 0x6CF2, 0x6CF4, 0x6D04, 0x6D07, 0x6D0A, 0x6D0E, 0x6D0F,
+ 0x6D11, 0x6D13, 0x6D1A, 0x6D26, 0x6D27, 0x6D28, 0x6C67, 0x6D2E,
+ 0x6D2F, 0x6D31, 0x6D39, 0x6D3C, 0x6D3F, 0x6D57, 0x6D5E, 0x6D5F,
+ 0x6D61, 0x6D65, 0x6D67, 0x6D6F, 0x6D70, 0x6D7C, 0x6D82, 0x6D87,
+ 0x6D91, 0x6D92, 0x6D94, 0x6D96, 0x6D97, 0x6D98, 0x6DAA, 0x6DAC,
+ 0x6DB4, 0x6DB7, 0x6DB9, 0x6DBD, 0x6DBF, 0x6DC4, 0x6DC8, 0x6DCA,
+ 0x6DCE, 0x6DCF, 0x6DD6, 0x6DDB, 0x6DDD, 0x6DDF, 0x6DE0, 0x6DE2,
+ 0x6DE5, 0x6DE9, 0x6DEF, 0x6DF0, 0x6DF4, 0x6DF6, 0x6DFC, 0x6E00,
+ 0x6E04, 0x6E1E, 0x6E22, 0x6E27, 0x6E32, 0x6E36, 0x6E39, 0x6E3B,
+ 0x6E3C, 0x6E44, 0x6E45, 0x6E48, 0x6E49, 0x6E4B, 0x6E4F, 0x6E51,
+ 0x6E52, 0x6E53, 0x6E54, 0x6E57, 0x6E5C, 0x6E5D, 0x6E5E,
+};
+static const unsigned short euc_to_utf8_8FC8[] = {
+ 0x6E62, 0x6E63, 0x6E68, 0x6E73, 0x6E7B, 0x6E7D, 0x6E8D,
+ 0x6E93, 0x6E99, 0x6EA0, 0x6EA7, 0x6EAD, 0x6EAE, 0x6EB1, 0x6EB3,
+ 0x6EBB, 0x6EBF, 0x6EC0, 0x6EC1, 0x6EC3, 0x6EC7, 0x6EC8, 0x6ECA,
+ 0x6ECD, 0x6ECE, 0x6ECF, 0x6EEB, 0x6EED, 0x6EEE, 0x6EF9, 0x6EFB,
+ 0x6EFD, 0x6F04, 0x6F08, 0x6F0A, 0x6F0C, 0x6F0D, 0x6F16, 0x6F18,
+ 0x6F1A, 0x6F1B, 0x6F26, 0x6F29, 0x6F2A, 0x6F2F, 0x6F30, 0x6F33,
+ 0x6F36, 0x6F3B, 0x6F3C, 0x6F2D, 0x6F4F, 0x6F51, 0x6F52, 0x6F53,
+ 0x6F57, 0x6F59, 0x6F5A, 0x6F5D, 0x6F5E, 0x6F61, 0x6F62, 0x6F68,
+ 0x6F6C, 0x6F7D, 0x6F7E, 0x6F83, 0x6F87, 0x6F88, 0x6F8B, 0x6F8C,
+ 0x6F8D, 0x6F90, 0x6F92, 0x6F93, 0x6F94, 0x6F96, 0x6F9A, 0x6F9F,
+ 0x6FA0, 0x6FA5, 0x6FA6, 0x6FA7, 0x6FA8, 0x6FAE, 0x6FAF, 0x6FB0,
+ 0x6FB5, 0x6FB6, 0x6FBC, 0x6FC5, 0x6FC7, 0x6FC8, 0x6FCA,
+};
+static const unsigned short euc_to_utf8_8FC9[] = {
+ 0x6FDA, 0x6FDE, 0x6FE8, 0x6FE9, 0x6FF0, 0x6FF5, 0x6FF9,
+ 0x6FFC, 0x6FFD, 0x7000, 0x7005, 0x7006, 0x7007, 0x700D, 0x7017,
+ 0x7020, 0x7023, 0x702F, 0x7034, 0x7037, 0x7039, 0x703C, 0x7043,
+ 0x7044, 0x7048, 0x7049, 0x704A, 0x704B, 0x7054, 0x7055, 0x705D,
+ 0x705E, 0x704E, 0x7064, 0x7065, 0x706C, 0x706E, 0x7075, 0x7076,
+ 0x707E, 0x7081, 0x7085, 0x7086, 0x7094, 0x7095, 0x7096, 0x7097,
+ 0x7098, 0x709B, 0x70A4, 0x70AB, 0x70B0, 0x70B1, 0x70B4, 0x70B7,
+ 0x70CA, 0x70D1, 0x70D3, 0x70D4, 0x70D5, 0x70D6, 0x70D8, 0x70DC,
+ 0x70E4, 0x70FA, 0x7103, 0x7104, 0x7105, 0x7106, 0x7107, 0x710B,
+ 0x710C, 0x710F, 0x711E, 0x7120, 0x712B, 0x712D, 0x712F, 0x7130,
+ 0x7131, 0x7138, 0x7141, 0x7145, 0x7146, 0x7147, 0x714A, 0x714B,
+ 0x7150, 0x7152, 0x7157, 0x715A, 0x715C, 0x715E, 0x7160,
+};
+static const unsigned short euc_to_utf8_8FCA[] = {
+ 0x7168, 0x7179, 0x7180, 0x7185, 0x7187, 0x718C, 0x7192,
+ 0x719A, 0x719B, 0x71A0, 0x71A2, 0x71AF, 0x71B0, 0x71B2, 0x71B3,
+ 0x71BA, 0x71BF, 0x71C0, 0x71C1, 0x71C4, 0x71CB, 0x71CC, 0x71D3,
+ 0x71D6, 0x71D9, 0x71DA, 0x71DC, 0x71F8, 0x71FE, 0x7200, 0x7207,
+ 0x7208, 0x7209, 0x7213, 0x7217, 0x721A, 0x721D, 0x721F, 0x7224,
+ 0x722B, 0x722F, 0x7234, 0x7238, 0x7239, 0x7241, 0x7242, 0x7243,
+ 0x7245, 0x724E, 0x724F, 0x7250, 0x7253, 0x7255, 0x7256, 0x725A,
+ 0x725C, 0x725E, 0x7260, 0x7263, 0x7268, 0x726B, 0x726E, 0x726F,
+ 0x7271, 0x7277, 0x7278, 0x727B, 0x727C, 0x727F, 0x7284, 0x7289,
+ 0x728D, 0x728E, 0x7293, 0x729B, 0x72A8, 0x72AD, 0x72AE, 0x72B1,
+ 0x72B4, 0x72BE, 0x72C1, 0x72C7, 0x72C9, 0x72CC, 0x72D5, 0x72D6,
+ 0x72D8, 0x72DF, 0x72E5, 0x72F3, 0x72F4, 0x72FA, 0x72FB,
+};
+static const unsigned short euc_to_utf8_8FCB[] = {
+ 0x72FE, 0x7302, 0x7304, 0x7305, 0x7307, 0x730B, 0x730D,
+ 0x7312, 0x7313, 0x7318, 0x7319, 0x731E, 0x7322, 0x7324, 0x7327,
+ 0x7328, 0x732C, 0x7331, 0x7332, 0x7335, 0x733A, 0x733B, 0x733D,
+ 0x7343, 0x734D, 0x7350, 0x7352, 0x7356, 0x7358, 0x735D, 0x735E,
+ 0x735F, 0x7360, 0x7366, 0x7367, 0x7369, 0x736B, 0x736C, 0x736E,
+ 0x736F, 0x7371, 0x7377, 0x7379, 0x737C, 0x7380, 0x7381, 0x7383,
+ 0x7385, 0x7386, 0x738E, 0x7390, 0x7393, 0x7395, 0x7397, 0x7398,
+ 0x739C, 0x739E, 0x739F, 0x73A0, 0x73A2, 0x73A5, 0x73A6, 0x73AA,
+ 0x73AB, 0x73AD, 0x73B5, 0x73B7, 0x73B9, 0x73BC, 0x73BD, 0x73BF,
+ 0x73C5, 0x73C6, 0x73C9, 0x73CB, 0x73CC, 0x73CF, 0x73D2, 0x73D3,
+ 0x73D6, 0x73D9, 0x73DD, 0x73E1, 0x73E3, 0x73E6, 0x73E7, 0x73E9,
+ 0x73F4, 0x73F5, 0x73F7, 0x73F9, 0x73FA, 0x73FB, 0x73FD,
+};
+static const unsigned short euc_to_utf8_8FCC[] = {
+ 0x73FF, 0x7400, 0x7401, 0x7404, 0x7407, 0x740A, 0x7411,
+ 0x741A, 0x741B, 0x7424, 0x7426, 0x7428, 0x7429, 0x742A, 0x742B,
+ 0x742C, 0x742D, 0x742E, 0x742F, 0x7430, 0x7431, 0x7439, 0x7440,
+ 0x7443, 0x7444, 0x7446, 0x7447, 0x744B, 0x744D, 0x7451, 0x7452,
+ 0x7457, 0x745D, 0x7462, 0x7466, 0x7467, 0x7468, 0x746B, 0x746D,
+ 0x746E, 0x7471, 0x7472, 0x7480, 0x7481, 0x7485, 0x7486, 0x7487,
+ 0x7489, 0x748F, 0x7490, 0x7491, 0x7492, 0x7498, 0x7499, 0x749A,
+ 0x749C, 0x749F, 0x74A0, 0x74A1, 0x74A3, 0x74A6, 0x74A8, 0x74A9,
+ 0x74AA, 0x74AB, 0x74AE, 0x74AF, 0x74B1, 0x74B2, 0x74B5, 0x74B9,
+ 0x74BB, 0x74BF, 0x74C8, 0x74C9, 0x74CC, 0x74D0, 0x74D3, 0x74D8,
+ 0x74DA, 0x74DB, 0x74DE, 0x74DF, 0x74E4, 0x74E8, 0x74EA, 0x74EB,
+ 0x74EF, 0x74F4, 0x74FA, 0x74FB, 0x74FC, 0x74FF, 0x7506,
+};
+static const unsigned short euc_to_utf8_8FCD[] = {
+ 0x7512, 0x7516, 0x7517, 0x7520, 0x7521, 0x7524, 0x7527,
+ 0x7529, 0x752A, 0x752F, 0x7536, 0x7539, 0x753D, 0x753E, 0x753F,
+ 0x7540, 0x7543, 0x7547, 0x7548, 0x754E, 0x7550, 0x7552, 0x7557,
+ 0x755E, 0x755F, 0x7561, 0x756F, 0x7571, 0x7579, 0x757A, 0x757B,
+ 0x757C, 0x757D, 0x757E, 0x7581, 0x7585, 0x7590, 0x7592, 0x7593,
+ 0x7595, 0x7599, 0x759C, 0x75A2, 0x75A4, 0x75B4, 0x75BA, 0x75BF,
+ 0x75C0, 0x75C1, 0x75C4, 0x75C6, 0x75CC, 0x75CE, 0x75CF, 0x75D7,
+ 0x75DC, 0x75DF, 0x75E0, 0x75E1, 0x75E4, 0x75E7, 0x75EC, 0x75EE,
+ 0x75EF, 0x75F1, 0x75F9, 0x7600, 0x7602, 0x7603, 0x7604, 0x7607,
+ 0x7608, 0x760A, 0x760C, 0x760F, 0x7612, 0x7613, 0x7615, 0x7616,
+ 0x7619, 0x761B, 0x761C, 0x761D, 0x761E, 0x7623, 0x7625, 0x7626,
+ 0x7629, 0x762D, 0x7632, 0x7633, 0x7635, 0x7638, 0x7639,
+};
+static const unsigned short euc_to_utf8_8FCE[] = {
+ 0x763A, 0x763C, 0x764A, 0x7640, 0x7641, 0x7643, 0x7644,
+ 0x7645, 0x7649, 0x764B, 0x7655, 0x7659, 0x765F, 0x7664, 0x7665,
+ 0x766D, 0x766E, 0x766F, 0x7671, 0x7674, 0x7681, 0x7685, 0x768C,
+ 0x768D, 0x7695, 0x769B, 0x769C, 0x769D, 0x769F, 0x76A0, 0x76A2,
+ 0x76A3, 0x76A4, 0x76A5, 0x76A6, 0x76A7, 0x76A8, 0x76AA, 0x76AD,
+ 0x76BD, 0x76C1, 0x76C5, 0x76C9, 0x76CB, 0x76CC, 0x76CE, 0x76D4,
+ 0x76D9, 0x76E0, 0x76E6, 0x76E8, 0x76EC, 0x76F0, 0x76F1, 0x76F6,
+ 0x76F9, 0x76FC, 0x7700, 0x7706, 0x770A, 0x770E, 0x7712, 0x7714,
+ 0x7715, 0x7717, 0x7719, 0x771A, 0x771C, 0x7722, 0x7728, 0x772D,
+ 0x772E, 0x772F, 0x7734, 0x7735, 0x7736, 0x7739, 0x773D, 0x773E,
+ 0x7742, 0x7745, 0x7746, 0x774A, 0x774D, 0x774E, 0x774F, 0x7752,
+ 0x7756, 0x7757, 0x775C, 0x775E, 0x775F, 0x7760, 0x7762,
+};
+static const unsigned short euc_to_utf8_8FCF[] = {
+ 0x7764, 0x7767, 0x776A, 0x776C, 0x7770, 0x7772, 0x7773,
+ 0x7774, 0x777A, 0x777D, 0x7780, 0x7784, 0x778C, 0x778D, 0x7794,
+ 0x7795, 0x7796, 0x779A, 0x779F, 0x77A2, 0x77A7, 0x77AA, 0x77AE,
+ 0x77AF, 0x77B1, 0x77B5, 0x77BE, 0x77C3, 0x77C9, 0x77D1, 0x77D2,
+ 0x77D5, 0x77D9, 0x77DE, 0x77DF, 0x77E0, 0x77E4, 0x77E6, 0x77EA,
+ 0x77EC, 0x77F0, 0x77F1, 0x77F4, 0x77F8, 0x77FB, 0x7805, 0x7806,
+ 0x7809, 0x780D, 0x780E, 0x7811, 0x781D, 0x7821, 0x7822, 0x7823,
+ 0x782D, 0x782E, 0x7830, 0x7835, 0x7837, 0x7843, 0x7844, 0x7847,
+ 0x7848, 0x784C, 0x784E, 0x7852, 0x785C, 0x785E, 0x7860, 0x7861,
+ 0x7863, 0x7864, 0x7868, 0x786A, 0x786E, 0x787A, 0x787E, 0x788A,
+ 0x788F, 0x7894, 0x7898, 0x78A1, 0x789D, 0x789E, 0x789F, 0x78A4,
+ 0x78A8, 0x78AC, 0x78AD, 0x78B0, 0x78B1, 0x78B2, 0x78B3,
+};
+static const unsigned short euc_to_utf8_8FD0[] = {
+ 0x78BB, 0x78BD, 0x78BF, 0x78C7, 0x78C8, 0x78C9, 0x78CC,
+ 0x78CE, 0x78D2, 0x78D3, 0x78D5, 0x78D6, 0x78E4, 0x78DB, 0x78DF,
+ 0x78E0, 0x78E1, 0x78E6, 0x78EA, 0x78F2, 0x78F3, 0x7900, 0x78F6,
+ 0x78F7, 0x78FA, 0x78FB, 0x78FF, 0x7906, 0x790C, 0x7910, 0x791A,
+ 0x791C, 0x791E, 0x791F, 0x7920, 0x7925, 0x7927, 0x7929, 0x792D,
+ 0x7931, 0x7934, 0x7935, 0x793B, 0x793D, 0x793F, 0x7944, 0x7945,
+ 0x7946, 0x794A, 0x794B, 0x794F, 0x7951, 0x7954, 0x7958, 0x795B,
+ 0x795C, 0x7967, 0x7969, 0x796B, 0x7972, 0x7979, 0x797B, 0x797C,
+ 0x797E, 0x798B, 0x798C, 0x7991, 0x7993, 0x7994, 0x7995, 0x7996,
+ 0x7998, 0x799B, 0x799C, 0x79A1, 0x79A8, 0x79A9, 0x79AB, 0x79AF,
+ 0x79B1, 0x79B4, 0x79B8, 0x79BB, 0x79C2, 0x79C4, 0x79C7, 0x79C8,
+ 0x79CA, 0x79CF, 0x79D4, 0x79D6, 0x79DA, 0x79DD, 0x79DE,
+};
+static const unsigned short euc_to_utf8_8FD1[] = {
+ 0x79E0, 0x79E2, 0x79E5, 0x79EA, 0x79EB, 0x79ED, 0x79F1,
+ 0x79F8, 0x79FC, 0x7A02, 0x7A03, 0x7A07, 0x7A09, 0x7A0A, 0x7A0C,
+ 0x7A11, 0x7A15, 0x7A1B, 0x7A1E, 0x7A21, 0x7A27, 0x7A2B, 0x7A2D,
+ 0x7A2F, 0x7A30, 0x7A34, 0x7A35, 0x7A38, 0x7A39, 0x7A3A, 0x7A44,
+ 0x7A45, 0x7A47, 0x7A48, 0x7A4C, 0x7A55, 0x7A56, 0x7A59, 0x7A5C,
+ 0x7A5D, 0x7A5F, 0x7A60, 0x7A65, 0x7A67, 0x7A6A, 0x7A6D, 0x7A75,
+ 0x7A78, 0x7A7E, 0x7A80, 0x7A82, 0x7A85, 0x7A86, 0x7A8A, 0x7A8B,
+ 0x7A90, 0x7A91, 0x7A94, 0x7A9E, 0x7AA0, 0x7AA3, 0x7AAC, 0x7AB3,
+ 0x7AB5, 0x7AB9, 0x7ABB, 0x7ABC, 0x7AC6, 0x7AC9, 0x7ACC, 0x7ACE,
+ 0x7AD1, 0x7ADB, 0x7AE8, 0x7AE9, 0x7AEB, 0x7AEC, 0x7AF1, 0x7AF4,
+ 0x7AFB, 0x7AFD, 0x7AFE, 0x7B07, 0x7B14, 0x7B1F, 0x7B23, 0x7B27,
+ 0x7B29, 0x7B2A, 0x7B2B, 0x7B2D, 0x7B2E, 0x7B2F, 0x7B30,
+};
+static const unsigned short euc_to_utf8_8FD2[] = {
+ 0x7B31, 0x7B34, 0x7B3D, 0x7B3F, 0x7B40, 0x7B41, 0x7B47,
+ 0x7B4E, 0x7B55, 0x7B60, 0x7B64, 0x7B66, 0x7B69, 0x7B6A, 0x7B6D,
+ 0x7B6F, 0x7B72, 0x7B73, 0x7B77, 0x7B84, 0x7B89, 0x7B8E, 0x7B90,
+ 0x7B91, 0x7B96, 0x7B9B, 0x7B9E, 0x7BA0, 0x7BA5, 0x7BAC, 0x7BAF,
+ 0x7BB0, 0x7BB2, 0x7BB5, 0x7BB6, 0x7BBA, 0x7BBB, 0x7BBC, 0x7BBD,
+ 0x7BC2, 0x7BC5, 0x7BC8, 0x7BCA, 0x7BD4, 0x7BD6, 0x7BD7, 0x7BD9,
+ 0x7BDA, 0x7BDB, 0x7BE8, 0x7BEA, 0x7BF2, 0x7BF4, 0x7BF5, 0x7BF8,
+ 0x7BF9, 0x7BFA, 0x7BFC, 0x7BFE, 0x7C01, 0x7C02, 0x7C03, 0x7C04,
+ 0x7C06, 0x7C09, 0x7C0B, 0x7C0C, 0x7C0E, 0x7C0F, 0x7C19, 0x7C1B,
+ 0x7C20, 0x7C25, 0x7C26, 0x7C28, 0x7C2C, 0x7C31, 0x7C33, 0x7C34,
+ 0x7C36, 0x7C39, 0x7C3A, 0x7C46, 0x7C4A, 0x7C55, 0x7C51, 0x7C52,
+ 0x7C53, 0x7C59, 0x7C5A, 0x7C5B, 0x7C5C, 0x7C5D, 0x7C5E,
+};
+static const unsigned short euc_to_utf8_8FD3[] = {
+ 0x7C61, 0x7C63, 0x7C67, 0x7C69, 0x7C6D, 0x7C6E, 0x7C70,
+ 0x7C72, 0x7C79, 0x7C7C, 0x7C7D, 0x7C86, 0x7C87, 0x7C8F, 0x7C94,
+ 0x7C9E, 0x7CA0, 0x7CA6, 0x7CB0, 0x7CB6, 0x7CB7, 0x7CBA, 0x7CBB,
+ 0x7CBC, 0x7CBF, 0x7CC4, 0x7CC7, 0x7CC8, 0x7CC9, 0x7CCD, 0x7CCF,
+ 0x7CD3, 0x7CD4, 0x7CD5, 0x7CD7, 0x7CD9, 0x7CDA, 0x7CDD, 0x7CE6,
+ 0x7CE9, 0x7CEB, 0x7CF5, 0x7D03, 0x7D07, 0x7D08, 0x7D09, 0x7D0F,
+ 0x7D11, 0x7D12, 0x7D13, 0x7D16, 0x7D1D, 0x7D1E, 0x7D23, 0x7D26,
+ 0x7D2A, 0x7D2D, 0x7D31, 0x7D3C, 0x7D3D, 0x7D3E, 0x7D40, 0x7D41,
+ 0x7D47, 0x7D48, 0x7D4D, 0x7D51, 0x7D53, 0x7D57, 0x7D59, 0x7D5A,
+ 0x7D5C, 0x7D5D, 0x7D65, 0x7D67, 0x7D6A, 0x7D70, 0x7D78, 0x7D7A,
+ 0x7D7B, 0x7D7F, 0x7D81, 0x7D82, 0x7D83, 0x7D85, 0x7D86, 0x7D88,
+ 0x7D8B, 0x7D8C, 0x7D8D, 0x7D91, 0x7D96, 0x7D97, 0x7D9D,
+};
+static const unsigned short euc_to_utf8_8FD4[] = {
+ 0x7D9E, 0x7DA6, 0x7DA7, 0x7DAA, 0x7DB3, 0x7DB6, 0x7DB7,
+ 0x7DB9, 0x7DC2, 0x7DC3, 0x7DC4, 0x7DC5, 0x7DC6, 0x7DCC, 0x7DCD,
+ 0x7DCE, 0x7DD7, 0x7DD9, 0x7E00, 0x7DE2, 0x7DE5, 0x7DE6, 0x7DEA,
+ 0x7DEB, 0x7DED, 0x7DF1, 0x7DF5, 0x7DF6, 0x7DF9, 0x7DFA, 0x7E08,
+ 0x7E10, 0x7E11, 0x7E15, 0x7E17, 0x7E1C, 0x7E1D, 0x7E20, 0x7E27,
+ 0x7E28, 0x7E2C, 0x7E2D, 0x7E2F, 0x7E33, 0x7E36, 0x7E3F, 0x7E44,
+ 0x7E45, 0x7E47, 0x7E4E, 0x7E50, 0x7E52, 0x7E58, 0x7E5F, 0x7E61,
+ 0x7E62, 0x7E65, 0x7E6B, 0x7E6E, 0x7E6F, 0x7E73, 0x7E78, 0x7E7E,
+ 0x7E81, 0x7E86, 0x7E87, 0x7E8A, 0x7E8D, 0x7E91, 0x7E95, 0x7E98,
+ 0x7E9A, 0x7E9D, 0x7E9E, 0x7F3C, 0x7F3B, 0x7F3D, 0x7F3E, 0x7F3F,
+ 0x7F43, 0x7F44, 0x7F47, 0x7F4F, 0x7F52, 0x7F53, 0x7F5B, 0x7F5C,
+ 0x7F5D, 0x7F61, 0x7F63, 0x7F64, 0x7F65, 0x7F66, 0x7F6D,
+};
+static const unsigned short euc_to_utf8_8FD5[] = {
+ 0x7F71, 0x7F7D, 0x7F7E, 0x7F7F, 0x7F80, 0x7F8B, 0x7F8D,
+ 0x7F8F, 0x7F90, 0x7F91, 0x7F96, 0x7F97, 0x7F9C, 0x7FA1, 0x7FA2,
+ 0x7FA6, 0x7FAA, 0x7FAD, 0x7FB4, 0x7FBC, 0x7FBF, 0x7FC0, 0x7FC3,
+ 0x7FC8, 0x7FCE, 0x7FCF, 0x7FDB, 0x7FDF, 0x7FE3, 0x7FE5, 0x7FE8,
+ 0x7FEC, 0x7FEE, 0x7FEF, 0x7FF2, 0x7FFA, 0x7FFD, 0x7FFE, 0x7FFF,
+ 0x8007, 0x8008, 0x800A, 0x800D, 0x800E, 0x800F, 0x8011, 0x8013,
+ 0x8014, 0x8016, 0x801D, 0x801E, 0x801F, 0x8020, 0x8024, 0x8026,
+ 0x802C, 0x802E, 0x8030, 0x8034, 0x8035, 0x8037, 0x8039, 0x803A,
+ 0x803C, 0x803E, 0x8040, 0x8044, 0x8060, 0x8064, 0x8066, 0x806D,
+ 0x8071, 0x8075, 0x8081, 0x8088, 0x808E, 0x809C, 0x809E, 0x80A6,
+ 0x80A7, 0x80AB, 0x80B8, 0x80B9, 0x80C8, 0x80CD, 0x80CF, 0x80D2,
+ 0x80D4, 0x80D5, 0x80D7, 0x80D8, 0x80E0, 0x80ED, 0x80EE,
+};
+static const unsigned short euc_to_utf8_8FD6[] = {
+ 0x80F0, 0x80F2, 0x80F3, 0x80F6, 0x80F9, 0x80FA, 0x80FE,
+ 0x8103, 0x810B, 0x8116, 0x8117, 0x8118, 0x811C, 0x811E, 0x8120,
+ 0x8124, 0x8127, 0x812C, 0x8130, 0x8135, 0x813A, 0x813C, 0x8145,
+ 0x8147, 0x814A, 0x814C, 0x8152, 0x8157, 0x8160, 0x8161, 0x8167,
+ 0x8168, 0x8169, 0x816D, 0x816F, 0x8177, 0x8181, 0x8190, 0x8184,
+ 0x8185, 0x8186, 0x818B, 0x818E, 0x8196, 0x8198, 0x819B, 0x819E,
+ 0x81A2, 0x81AE, 0x81B2, 0x81B4, 0x81BB, 0x81CB, 0x81C3, 0x81C5,
+ 0x81CA, 0x81CE, 0x81CF, 0x81D5, 0x81D7, 0x81DB, 0x81DD, 0x81DE,
+ 0x81E1, 0x81E4, 0x81EB, 0x81EC, 0x81F0, 0x81F1, 0x81F2, 0x81F5,
+ 0x81F6, 0x81F8, 0x81F9, 0x81FD, 0x81FF, 0x8200, 0x8203, 0x820F,
+ 0x8213, 0x8214, 0x8219, 0x821A, 0x821D, 0x8221, 0x8222, 0x8228,
+ 0x8232, 0x8234, 0x823A, 0x8243, 0x8244, 0x8245, 0x8246,
+};
+static const unsigned short euc_to_utf8_8FD7[] = {
+ 0x824B, 0x824E, 0x824F, 0x8251, 0x8256, 0x825C, 0x8260,
+ 0x8263, 0x8267, 0x826D, 0x8274, 0x827B, 0x827D, 0x827F, 0x8280,
+ 0x8281, 0x8283, 0x8284, 0x8287, 0x8289, 0x828A, 0x828E, 0x8291,
+ 0x8294, 0x8296, 0x8298, 0x829A, 0x829B, 0x82A0, 0x82A1, 0x82A3,
+ 0x82A4, 0x82A7, 0x82A8, 0x82A9, 0x82AA, 0x82AE, 0x82B0, 0x82B2,
+ 0x82B4, 0x82B7, 0x82BA, 0x82BC, 0x82BE, 0x82BF, 0x82C6, 0x82D0,
+ 0x82D5, 0x82DA, 0x82E0, 0x82E2, 0x82E4, 0x82E8, 0x82EA, 0x82ED,
+ 0x82EF, 0x82F6, 0x82F7, 0x82FD, 0x82FE, 0x8300, 0x8301, 0x8307,
+ 0x8308, 0x830A, 0x830B, 0x8354, 0x831B, 0x831D, 0x831E, 0x831F,
+ 0x8321, 0x8322, 0x832C, 0x832D, 0x832E, 0x8330, 0x8333, 0x8337,
+ 0x833A, 0x833C, 0x833D, 0x8342, 0x8343, 0x8344, 0x8347, 0x834D,
+ 0x834E, 0x8351, 0x8355, 0x8356, 0x8357, 0x8370, 0x8378,
+};
+static const unsigned short euc_to_utf8_8FD8[] = {
+ 0x837D, 0x837F, 0x8380, 0x8382, 0x8384, 0x8386, 0x838D,
+ 0x8392, 0x8394, 0x8395, 0x8398, 0x8399, 0x839B, 0x839C, 0x839D,
+ 0x83A6, 0x83A7, 0x83A9, 0x83AC, 0x83BE, 0x83BF, 0x83C0, 0x83C7,
+ 0x83C9, 0x83CF, 0x83D0, 0x83D1, 0x83D4, 0x83DD, 0x8353, 0x83E8,
+ 0x83EA, 0x83F6, 0x83F8, 0x83F9, 0x83FC, 0x8401, 0x8406, 0x840A,
+ 0x840F, 0x8411, 0x8415, 0x8419, 0x83AD, 0x842F, 0x8439, 0x8445,
+ 0x8447, 0x8448, 0x844A, 0x844D, 0x844F, 0x8451, 0x8452, 0x8456,
+ 0x8458, 0x8459, 0x845A, 0x845C, 0x8460, 0x8464, 0x8465, 0x8467,
+ 0x846A, 0x8470, 0x8473, 0x8474, 0x8476, 0x8478, 0x847C, 0x847D,
+ 0x8481, 0x8485, 0x8492, 0x8493, 0x8495, 0x849E, 0x84A6, 0x84A8,
+ 0x84A9, 0x84AA, 0x84AF, 0x84B1, 0x84B4, 0x84BA, 0x84BD, 0x84BE,
+ 0x84C0, 0x84C2, 0x84C7, 0x84C8, 0x84CC, 0x84CF, 0x84D3,
+};
+static const unsigned short euc_to_utf8_8FD9[] = {
+ 0x84DC, 0x84E7, 0x84EA, 0x84EF, 0x84F0, 0x84F1, 0x84F2,
+ 0x84F7, 0x8532, 0x84FA, 0x84FB, 0x84FD, 0x8502, 0x8503, 0x8507,
+ 0x850C, 0x850E, 0x8510, 0x851C, 0x851E, 0x8522, 0x8523, 0x8524,
+ 0x8525, 0x8527, 0x852A, 0x852B, 0x852F, 0x8533, 0x8534, 0x8536,
+ 0x853F, 0x8546, 0x854F, 0x8550, 0x8551, 0x8552, 0x8553, 0x8556,
+ 0x8559, 0x855C, 0x855D, 0x855E, 0x855F, 0x8560, 0x8561, 0x8562,
+ 0x8564, 0x856B, 0x856F, 0x8579, 0x857A, 0x857B, 0x857D, 0x857F,
+ 0x8581, 0x8585, 0x8586, 0x8589, 0x858B, 0x858C, 0x858F, 0x8593,
+ 0x8598, 0x859D, 0x859F, 0x85A0, 0x85A2, 0x85A5, 0x85A7, 0x85B4,
+ 0x85B6, 0x85B7, 0x85B8, 0x85BC, 0x85BD, 0x85BE, 0x85BF, 0x85C2,
+ 0x85C7, 0x85CA, 0x85CB, 0x85CE, 0x85AD, 0x85D8, 0x85DA, 0x85DF,
+ 0x85E0, 0x85E6, 0x85E8, 0x85ED, 0x85F3, 0x85F6, 0x85FC,
+};
+static const unsigned short euc_to_utf8_8FDA[] = {
+ 0x85FF, 0x8600, 0x8604, 0x8605, 0x860D, 0x860E, 0x8610,
+ 0x8611, 0x8612, 0x8618, 0x8619, 0x861B, 0x861E, 0x8621, 0x8627,
+ 0x8629, 0x8636, 0x8638, 0x863A, 0x863C, 0x863D, 0x8640, 0x8642,
+ 0x8646, 0x8652, 0x8653, 0x8656, 0x8657, 0x8658, 0x8659, 0x865D,
+ 0x8660, 0x8661, 0x8662, 0x8663, 0x8664, 0x8669, 0x866C, 0x866F,
+ 0x8675, 0x8676, 0x8677, 0x867A, 0x868D, 0x8691, 0x8696, 0x8698,
+ 0x869A, 0x869C, 0x86A1, 0x86A6, 0x86A7, 0x86A8, 0x86AD, 0x86B1,
+ 0x86B3, 0x86B4, 0x86B5, 0x86B7, 0x86B8, 0x86B9, 0x86BF, 0x86C0,
+ 0x86C1, 0x86C3, 0x86C5, 0x86D1, 0x86D2, 0x86D5, 0x86D7, 0x86DA,
+ 0x86DC, 0x86E0, 0x86E3, 0x86E5, 0x86E7, 0x8688, 0x86FA, 0x86FC,
+ 0x86FD, 0x8704, 0x8705, 0x8707, 0x870B, 0x870E, 0x870F, 0x8710,
+ 0x8713, 0x8714, 0x8719, 0x871E, 0x871F, 0x8721, 0x8723,
+};
+static const unsigned short euc_to_utf8_8FDB[] = {
+ 0x8728, 0x872E, 0x872F, 0x8731, 0x8732, 0x8739, 0x873A,
+ 0x873C, 0x873D, 0x873E, 0x8740, 0x8743, 0x8745, 0x874D, 0x8758,
+ 0x875D, 0x8761, 0x8764, 0x8765, 0x876F, 0x8771, 0x8772, 0x877B,
+ 0x8783, 0x8784, 0x8785, 0x8786, 0x8787, 0x8788, 0x8789, 0x878B,
+ 0x878C, 0x8790, 0x8793, 0x8795, 0x8797, 0x8798, 0x8799, 0x879E,
+ 0x87A0, 0x87A3, 0x87A7, 0x87AC, 0x87AD, 0x87AE, 0x87B1, 0x87B5,
+ 0x87BE, 0x87BF, 0x87C1, 0x87C8, 0x87C9, 0x87CA, 0x87CE, 0x87D5,
+ 0x87D6, 0x87D9, 0x87DA, 0x87DC, 0x87DF, 0x87E2, 0x87E3, 0x87E4,
+ 0x87EA, 0x87EB, 0x87ED, 0x87F1, 0x87F3, 0x87F8, 0x87FA, 0x87FF,
+ 0x8801, 0x8803, 0x8806, 0x8809, 0x880A, 0x880B, 0x8810, 0x8819,
+ 0x8812, 0x8813, 0x8814, 0x8818, 0x881A, 0x881B, 0x881C, 0x881E,
+ 0x881F, 0x8828, 0x882D, 0x882E, 0x8830, 0x8832, 0x8835,
+};
+static const unsigned short euc_to_utf8_8FDC[] = {
+ 0x883A, 0x883C, 0x8841, 0x8843, 0x8845, 0x8848, 0x8849,
+ 0x884A, 0x884B, 0x884E, 0x8851, 0x8855, 0x8856, 0x8858, 0x885A,
+ 0x885C, 0x885F, 0x8860, 0x8864, 0x8869, 0x8871, 0x8879, 0x887B,
+ 0x8880, 0x8898, 0x889A, 0x889B, 0x889C, 0x889F, 0x88A0, 0x88A8,
+ 0x88AA, 0x88BA, 0x88BD, 0x88BE, 0x88C0, 0x88CA, 0x88CB, 0x88CC,
+ 0x88CD, 0x88CE, 0x88D1, 0x88D2, 0x88D3, 0x88DB, 0x88DE, 0x88E7,
+ 0x88EF, 0x88F0, 0x88F1, 0x88F5, 0x88F7, 0x8901, 0x8906, 0x890D,
+ 0x890E, 0x890F, 0x8915, 0x8916, 0x8918, 0x8919, 0x891A, 0x891C,
+ 0x8920, 0x8926, 0x8927, 0x8928, 0x8930, 0x8931, 0x8932, 0x8935,
+ 0x8939, 0x893A, 0x893E, 0x8940, 0x8942, 0x8945, 0x8946, 0x8949,
+ 0x894F, 0x8952, 0x8957, 0x895A, 0x895B, 0x895C, 0x8961, 0x8962,
+ 0x8963, 0x896B, 0x896E, 0x8970, 0x8973, 0x8975, 0x897A,
+};
+static const unsigned short euc_to_utf8_8FDD[] = {
+ 0x897B, 0x897C, 0x897D, 0x8989, 0x898D, 0x8990, 0x8994,
+ 0x8995, 0x899B, 0x899C, 0x899F, 0x89A0, 0x89A5, 0x89B0, 0x89B4,
+ 0x89B5, 0x89B6, 0x89B7, 0x89BC, 0x89D4, 0x89D5, 0x89D6, 0x89D7,
+ 0x89D8, 0x89E5, 0x89E9, 0x89EB, 0x89ED, 0x89F1, 0x89F3, 0x89F6,
+ 0x89F9, 0x89FD, 0x89FF, 0x8A04, 0x8A05, 0x8A07, 0x8A0F, 0x8A11,
+ 0x8A12, 0x8A14, 0x8A15, 0x8A1E, 0x8A20, 0x8A22, 0x8A24, 0x8A26,
+ 0x8A2B, 0x8A2C, 0x8A2F, 0x8A35, 0x8A37, 0x8A3D, 0x8A3E, 0x8A40,
+ 0x8A43, 0x8A45, 0x8A47, 0x8A49, 0x8A4D, 0x8A4E, 0x8A53, 0x8A56,
+ 0x8A57, 0x8A58, 0x8A5C, 0x8A5D, 0x8A61, 0x8A65, 0x8A67, 0x8A75,
+ 0x8A76, 0x8A77, 0x8A79, 0x8A7A, 0x8A7B, 0x8A7E, 0x8A7F, 0x8A80,
+ 0x8A83, 0x8A86, 0x8A8B, 0x8A8F, 0x8A90, 0x8A92, 0x8A96, 0x8A97,
+ 0x8A99, 0x8A9F, 0x8AA7, 0x8AA9, 0x8AAE, 0x8AAF, 0x8AB3,
+};
+static const unsigned short euc_to_utf8_8FDE[] = {
+ 0x8AB6, 0x8AB7, 0x8ABB, 0x8ABE, 0x8AC3, 0x8AC6, 0x8AC8,
+ 0x8AC9, 0x8ACA, 0x8AD1, 0x8AD3, 0x8AD4, 0x8AD5, 0x8AD7, 0x8ADD,
+ 0x8ADF, 0x8AEC, 0x8AF0, 0x8AF4, 0x8AF5, 0x8AF6, 0x8AFC, 0x8AFF,
+ 0x8B05, 0x8B06, 0x8B0B, 0x8B11, 0x8B1C, 0x8B1E, 0x8B1F, 0x8B0A,
+ 0x8B2D, 0x8B30, 0x8B37, 0x8B3C, 0x8B42, 0x8B43, 0x8B44, 0x8B45,
+ 0x8B46, 0x8B48, 0x8B52, 0x8B53, 0x8B54, 0x8B59, 0x8B4D, 0x8B5E,
+ 0x8B63, 0x8B6D, 0x8B76, 0x8B78, 0x8B79, 0x8B7C, 0x8B7E, 0x8B81,
+ 0x8B84, 0x8B85, 0x8B8B, 0x8B8D, 0x8B8F, 0x8B94, 0x8B95, 0x8B9C,
+ 0x8B9E, 0x8B9F, 0x8C38, 0x8C39, 0x8C3D, 0x8C3E, 0x8C45, 0x8C47,
+ 0x8C49, 0x8C4B, 0x8C4F, 0x8C51, 0x8C53, 0x8C54, 0x8C57, 0x8C58,
+ 0x8C5B, 0x8C5D, 0x8C59, 0x8C63, 0x8C64, 0x8C66, 0x8C68, 0x8C69,
+ 0x8C6D, 0x8C73, 0x8C75, 0x8C76, 0x8C7B, 0x8C7E, 0x8C86,
+};
+static const unsigned short euc_to_utf8_8FDF[] = {
+ 0x8C87, 0x8C8B, 0x8C90, 0x8C92, 0x8C93, 0x8C99, 0x8C9B,
+ 0x8C9C, 0x8CA4, 0x8CB9, 0x8CBA, 0x8CC5, 0x8CC6, 0x8CC9, 0x8CCB,
+ 0x8CCF, 0x8CD6, 0x8CD5, 0x8CD9, 0x8CDD, 0x8CE1, 0x8CE8, 0x8CEC,
+ 0x8CEF, 0x8CF0, 0x8CF2, 0x8CF5, 0x8CF7, 0x8CF8, 0x8CFE, 0x8CFF,
+ 0x8D01, 0x8D03, 0x8D09, 0x8D12, 0x8D17, 0x8D1B, 0x8D65, 0x8D69,
+ 0x8D6C, 0x8D6E, 0x8D7F, 0x8D82, 0x8D84, 0x8D88, 0x8D8D, 0x8D90,
+ 0x8D91, 0x8D95, 0x8D9E, 0x8D9F, 0x8DA0, 0x8DA6, 0x8DAB, 0x8DAC,
+ 0x8DAF, 0x8DB2, 0x8DB5, 0x8DB7, 0x8DB9, 0x8DBB, 0x8DC0, 0x8DC5,
+ 0x8DC6, 0x8DC7, 0x8DC8, 0x8DCA, 0x8DCE, 0x8DD1, 0x8DD4, 0x8DD5,
+ 0x8DD7, 0x8DD9, 0x8DE4, 0x8DE5, 0x8DE7, 0x8DEC, 0x8DF0, 0x8DBC,
+ 0x8DF1, 0x8DF2, 0x8DF4, 0x8DFD, 0x8E01, 0x8E04, 0x8E05, 0x8E06,
+ 0x8E0B, 0x8E11, 0x8E14, 0x8E16, 0x8E20, 0x8E21, 0x8E22,
+};
+static const unsigned short euc_to_utf8_8FE0[] = {
+ 0x8E23, 0x8E26, 0x8E27, 0x8E31, 0x8E33, 0x8E36, 0x8E37,
+ 0x8E38, 0x8E39, 0x8E3D, 0x8E40, 0x8E41, 0x8E4B, 0x8E4D, 0x8E4E,
+ 0x8E4F, 0x8E54, 0x8E5B, 0x8E5C, 0x8E5D, 0x8E5E, 0x8E61, 0x8E62,
+ 0x8E69, 0x8E6C, 0x8E6D, 0x8E6F, 0x8E70, 0x8E71, 0x8E79, 0x8E7A,
+ 0x8E7B, 0x8E82, 0x8E83, 0x8E89, 0x8E90, 0x8E92, 0x8E95, 0x8E9A,
+ 0x8E9B, 0x8E9D, 0x8E9E, 0x8EA2, 0x8EA7, 0x8EA9, 0x8EAD, 0x8EAE,
+ 0x8EB3, 0x8EB5, 0x8EBA, 0x8EBB, 0x8EC0, 0x8EC1, 0x8EC3, 0x8EC4,
+ 0x8EC7, 0x8ECF, 0x8ED1, 0x8ED4, 0x8EDC, 0x8EE8, 0x8EEE, 0x8EF0,
+ 0x8EF1, 0x8EF7, 0x8EF9, 0x8EFA, 0x8EED, 0x8F00, 0x8F02, 0x8F07,
+ 0x8F08, 0x8F0F, 0x8F10, 0x8F16, 0x8F17, 0x8F18, 0x8F1E, 0x8F20,
+ 0x8F21, 0x8F23, 0x8F25, 0x8F27, 0x8F28, 0x8F2C, 0x8F2D, 0x8F2E,
+ 0x8F34, 0x8F35, 0x8F36, 0x8F37, 0x8F3A, 0x8F40, 0x8F41,
+};
+static const unsigned short euc_to_utf8_8FE1[] = {
+ 0x8F43, 0x8F47, 0x8F4F, 0x8F51, 0x8F52, 0x8F53, 0x8F54,
+ 0x8F55, 0x8F58, 0x8F5D, 0x8F5E, 0x8F65, 0x8F9D, 0x8FA0, 0x8FA1,
+ 0x8FA4, 0x8FA5, 0x8FA6, 0x8FB5, 0x8FB6, 0x8FB8, 0x8FBE, 0x8FC0,
+ 0x8FC1, 0x8FC6, 0x8FCA, 0x8FCB, 0x8FCD, 0x8FD0, 0x8FD2, 0x8FD3,
+ 0x8FD5, 0x8FE0, 0x8FE3, 0x8FE4, 0x8FE8, 0x8FEE, 0x8FF1, 0x8FF5,
+ 0x8FF6, 0x8FFB, 0x8FFE, 0x9002, 0x9004, 0x9008, 0x900C, 0x9018,
+ 0x901B, 0x9028, 0x9029, 0x902F, 0x902A, 0x902C, 0x902D, 0x9033,
+ 0x9034, 0x9037, 0x903F, 0x9043, 0x9044, 0x904C, 0x905B, 0x905D,
+ 0x9062, 0x9066, 0x9067, 0x906C, 0x9070, 0x9074, 0x9079, 0x9085,
+ 0x9088, 0x908B, 0x908C, 0x908E, 0x9090, 0x9095, 0x9097, 0x9098,
+ 0x9099, 0x909B, 0x90A0, 0x90A1, 0x90A2, 0x90A5, 0x90B0, 0x90B2,
+ 0x90B3, 0x90B4, 0x90B6, 0x90BD, 0x90CC, 0x90BE, 0x90C3,
+};
+static const unsigned short euc_to_utf8_8FE2[] = {
+ 0x90C4, 0x90C5, 0x90C7, 0x90C8, 0x90D5, 0x90D7, 0x90D8,
+ 0x90D9, 0x90DC, 0x90DD, 0x90DF, 0x90E5, 0x90D2, 0x90F6, 0x90EB,
+ 0x90EF, 0x90F0, 0x90F4, 0x90FE, 0x90FF, 0x9100, 0x9104, 0x9105,
+ 0x9106, 0x9108, 0x910D, 0x9110, 0x9114, 0x9116, 0x9117, 0x9118,
+ 0x911A, 0x911C, 0x911E, 0x9120, 0x9125, 0x9122, 0x9123, 0x9127,
+ 0x9129, 0x912E, 0x912F, 0x9131, 0x9134, 0x9136, 0x9137, 0x9139,
+ 0x913A, 0x913C, 0x913D, 0x9143, 0x9147, 0x9148, 0x914F, 0x9153,
+ 0x9157, 0x9159, 0x915A, 0x915B, 0x9161, 0x9164, 0x9167, 0x916D,
+ 0x9174, 0x9179, 0x917A, 0x917B, 0x9181, 0x9183, 0x9185, 0x9186,
+ 0x918A, 0x918E, 0x9191, 0x9193, 0x9194, 0x9195, 0x9198, 0x919E,
+ 0x91A1, 0x91A6, 0x91A8, 0x91AC, 0x91AD, 0x91AE, 0x91B0, 0x91B1,
+ 0x91B2, 0x91B3, 0x91B6, 0x91BB, 0x91BC, 0x91BD, 0x91BF,
+};
+static const unsigned short euc_to_utf8_8FE3[] = {
+ 0x91C2, 0x91C3, 0x91C5, 0x91D3, 0x91D4, 0x91D7, 0x91D9,
+ 0x91DA, 0x91DE, 0x91E4, 0x91E5, 0x91E9, 0x91EA, 0x91EC, 0x91ED,
+ 0x91EE, 0x91EF, 0x91F0, 0x91F1, 0x91F7, 0x91F9, 0x91FB, 0x91FD,
+ 0x9200, 0x9201, 0x9204, 0x9205, 0x9206, 0x9207, 0x9209, 0x920A,
+ 0x920C, 0x9210, 0x9212, 0x9213, 0x9216, 0x9218, 0x921C, 0x921D,
+ 0x9223, 0x9224, 0x9225, 0x9226, 0x9228, 0x922E, 0x922F, 0x9230,
+ 0x9233, 0x9235, 0x9236, 0x9238, 0x9239, 0x923A, 0x923C, 0x923E,
+ 0x9240, 0x9242, 0x9243, 0x9246, 0x9247, 0x924A, 0x924D, 0x924E,
+ 0x924F, 0x9251, 0x9258, 0x9259, 0x925C, 0x925D, 0x9260, 0x9261,
+ 0x9265, 0x9267, 0x9268, 0x9269, 0x926E, 0x926F, 0x9270, 0x9275,
+ 0x9276, 0x9277, 0x9278, 0x9279, 0x927B, 0x927C, 0x927D, 0x927F,
+ 0x9288, 0x9289, 0x928A, 0x928D, 0x928E, 0x9292, 0x9297,
+};
+static const unsigned short euc_to_utf8_8FE4[] = {
+ 0x9299, 0x929F, 0x92A0, 0x92A4, 0x92A5, 0x92A7, 0x92A8,
+ 0x92AB, 0x92AF, 0x92B2, 0x92B6, 0x92B8, 0x92BA, 0x92BB, 0x92BC,
+ 0x92BD, 0x92BF, 0x92C0, 0x92C1, 0x92C2, 0x92C3, 0x92C5, 0x92C6,
+ 0x92C7, 0x92C8, 0x92CB, 0x92CC, 0x92CD, 0x92CE, 0x92D0, 0x92D3,
+ 0x92D5, 0x92D7, 0x92D8, 0x92D9, 0x92DC, 0x92DD, 0x92DF, 0x92E0,
+ 0x92E1, 0x92E3, 0x92E5, 0x92E7, 0x92E8, 0x92EC, 0x92EE, 0x92F0,
+ 0x92F9, 0x92FB, 0x92FF, 0x9300, 0x9302, 0x9308, 0x930D, 0x9311,
+ 0x9314, 0x9315, 0x931C, 0x931D, 0x931E, 0x931F, 0x9321, 0x9324,
+ 0x9325, 0x9327, 0x9329, 0x932A, 0x9333, 0x9334, 0x9336, 0x9337,
+ 0x9347, 0x9348, 0x9349, 0x9350, 0x9351, 0x9352, 0x9355, 0x9357,
+ 0x9358, 0x935A, 0x935E, 0x9364, 0x9365, 0x9367, 0x9369, 0x936A,
+ 0x936D, 0x936F, 0x9370, 0x9371, 0x9373, 0x9374, 0x9376,
+};
+static const unsigned short euc_to_utf8_8FE5[] = {
+ 0x937A, 0x937D, 0x937F, 0x9380, 0x9381, 0x9382, 0x9388,
+ 0x938A, 0x938B, 0x938D, 0x938F, 0x9392, 0x9395, 0x9398, 0x939B,
+ 0x939E, 0x93A1, 0x93A3, 0x93A4, 0x93A6, 0x93A8, 0x93AB, 0x93B4,
+ 0x93B5, 0x93B6, 0x93BA, 0x93A9, 0x93C1, 0x93C4, 0x93C5, 0x93C6,
+ 0x93C7, 0x93C9, 0x93CA, 0x93CB, 0x93CC, 0x93CD, 0x93D3, 0x93D9,
+ 0x93DC, 0x93DE, 0x93DF, 0x93E2, 0x93E6, 0x93E7, 0x93F9, 0x93F7,
+ 0x93F8, 0x93FA, 0x93FB, 0x93FD, 0x9401, 0x9402, 0x9404, 0x9408,
+ 0x9409, 0x940D, 0x940E, 0x940F, 0x9415, 0x9416, 0x9417, 0x941F,
+ 0x942E, 0x942F, 0x9431, 0x9432, 0x9433, 0x9434, 0x943B, 0x943F,
+ 0x943D, 0x9443, 0x9445, 0x9448, 0x944A, 0x944C, 0x9455, 0x9459,
+ 0x945C, 0x945F, 0x9461, 0x9463, 0x9468, 0x946B, 0x946D, 0x946E,
+ 0x946F, 0x9471, 0x9472, 0x9484, 0x9483, 0x9578, 0x9579,
+};
+static const unsigned short euc_to_utf8_8FE6[] = {
+ 0x957E, 0x9584, 0x9588, 0x958C, 0x958D, 0x958E, 0x959D,
+ 0x959E, 0x959F, 0x95A1, 0x95A6, 0x95A9, 0x95AB, 0x95AC, 0x95B4,
+ 0x95B6, 0x95BA, 0x95BD, 0x95BF, 0x95C6, 0x95C8, 0x95C9, 0x95CB,
+ 0x95D0, 0x95D1, 0x95D2, 0x95D3, 0x95D9, 0x95DA, 0x95DD, 0x95DE,
+ 0x95DF, 0x95E0, 0x95E4, 0x95E6, 0x961D, 0x961E, 0x9622, 0x9624,
+ 0x9625, 0x9626, 0x962C, 0x9631, 0x9633, 0x9637, 0x9638, 0x9639,
+ 0x963A, 0x963C, 0x963D, 0x9641, 0x9652, 0x9654, 0x9656, 0x9657,
+ 0x9658, 0x9661, 0x966E, 0x9674, 0x967B, 0x967C, 0x967E, 0x967F,
+ 0x9681, 0x9682, 0x9683, 0x9684, 0x9689, 0x9691, 0x9696, 0x969A,
+ 0x969D, 0x969F, 0x96A4, 0x96A5, 0x96A6, 0x96A9, 0x96AE, 0x96AF,
+ 0x96B3, 0x96BA, 0x96CA, 0x96D2, 0x5DB2, 0x96D8, 0x96DA, 0x96DD,
+ 0x96DE, 0x96DF, 0x96E9, 0x96EF, 0x96F1, 0x96FA, 0x9702,
+};
+static const unsigned short euc_to_utf8_8FE7[] = {
+ 0x9703, 0x9705, 0x9709, 0x971A, 0x971B, 0x971D, 0x9721,
+ 0x9722, 0x9723, 0x9728, 0x9731, 0x9733, 0x9741, 0x9743, 0x974A,
+ 0x974E, 0x974F, 0x9755, 0x9757, 0x9758, 0x975A, 0x975B, 0x9763,
+ 0x9767, 0x976A, 0x976E, 0x9773, 0x9776, 0x9777, 0x9778, 0x977B,
+ 0x977D, 0x977F, 0x9780, 0x9789, 0x9795, 0x9796, 0x9797, 0x9799,
+ 0x979A, 0x979E, 0x979F, 0x97A2, 0x97AC, 0x97AE, 0x97B1, 0x97B2,
+ 0x97B5, 0x97B6, 0x97B8, 0x97B9, 0x97BA, 0x97BC, 0x97BE, 0x97BF,
+ 0x97C1, 0x97C4, 0x97C5, 0x97C7, 0x97C9, 0x97CA, 0x97CC, 0x97CD,
+ 0x97CE, 0x97D0, 0x97D1, 0x97D4, 0x97D7, 0x97D8, 0x97D9, 0x97DD,
+ 0x97DE, 0x97E0, 0x97DB, 0x97E1, 0x97E4, 0x97EF, 0x97F1, 0x97F4,
+ 0x97F7, 0x97F8, 0x97FA, 0x9807, 0x980A, 0x9819, 0x980D, 0x980E,
+ 0x9814, 0x9816, 0x981C, 0x981E, 0x9820, 0x9823, 0x9826,
+};
+static const unsigned short euc_to_utf8_8FE8[] = {
+ 0x982B, 0x982E, 0x982F, 0x9830, 0x9832, 0x9833, 0x9835,
+ 0x9825, 0x983E, 0x9844, 0x9847, 0x984A, 0x9851, 0x9852, 0x9853,
+ 0x9856, 0x9857, 0x9859, 0x985A, 0x9862, 0x9863, 0x9865, 0x9866,
+ 0x986A, 0x986C, 0x98AB, 0x98AD, 0x98AE, 0x98B0, 0x98B4, 0x98B7,
+ 0x98B8, 0x98BA, 0x98BB, 0x98BF, 0x98C2, 0x98C5, 0x98C8, 0x98CC,
+ 0x98E1, 0x98E3, 0x98E5, 0x98E6, 0x98E7, 0x98EA, 0x98F3, 0x98F6,
+ 0x9902, 0x9907, 0x9908, 0x9911, 0x9915, 0x9916, 0x9917, 0x991A,
+ 0x991B, 0x991C, 0x991F, 0x9922, 0x9926, 0x9927, 0x992B, 0x9931,
+ 0x9932, 0x9933, 0x9934, 0x9935, 0x9939, 0x993A, 0x993B, 0x993C,
+ 0x9940, 0x9941, 0x9946, 0x9947, 0x9948, 0x994D, 0x994E, 0x9954,
+ 0x9958, 0x9959, 0x995B, 0x995C, 0x995E, 0x995F, 0x9960, 0x999B,
+ 0x999D, 0x999F, 0x99A6, 0x99B0, 0x99B1, 0x99B2, 0x99B5,
+};
+static const unsigned short euc_to_utf8_8FE9[] = {
+ 0x99B9, 0x99BA, 0x99BD, 0x99BF, 0x99C3, 0x99C9, 0x99D3,
+ 0x99D4, 0x99D9, 0x99DA, 0x99DC, 0x99DE, 0x99E7, 0x99EA, 0x99EB,
+ 0x99EC, 0x99F0, 0x99F4, 0x99F5, 0x99F9, 0x99FD, 0x99FE, 0x9A02,
+ 0x9A03, 0x9A04, 0x9A0B, 0x9A0C, 0x9A10, 0x9A11, 0x9A16, 0x9A1E,
+ 0x9A20, 0x9A22, 0x9A23, 0x9A24, 0x9A27, 0x9A2D, 0x9A2E, 0x9A33,
+ 0x9A35, 0x9A36, 0x9A38, 0x9A47, 0x9A41, 0x9A44, 0x9A4A, 0x9A4B,
+ 0x9A4C, 0x9A4E, 0x9A51, 0x9A54, 0x9A56, 0x9A5D, 0x9AAA, 0x9AAC,
+ 0x9AAE, 0x9AAF, 0x9AB2, 0x9AB4, 0x9AB5, 0x9AB6, 0x9AB9, 0x9ABB,
+ 0x9ABE, 0x9ABF, 0x9AC1, 0x9AC3, 0x9AC6, 0x9AC8, 0x9ACE, 0x9AD0,
+ 0x9AD2, 0x9AD5, 0x9AD6, 0x9AD7, 0x9ADB, 0x9ADC, 0x9AE0, 0x9AE4,
+ 0x9AE5, 0x9AE7, 0x9AE9, 0x9AEC, 0x9AF2, 0x9AF3, 0x9AF5, 0x9AF9,
+ 0x9AFA, 0x9AFD, 0x9AFF, 0x9B00, 0x9B01, 0x9B02, 0x9B03,
+};
+static const unsigned short euc_to_utf8_8FEA[] = {
+ 0x9B04, 0x9B05, 0x9B08, 0x9B09, 0x9B0B, 0x9B0C, 0x9B0D,
+ 0x9B0E, 0x9B10, 0x9B12, 0x9B16, 0x9B19, 0x9B1B, 0x9B1C, 0x9B20,
+ 0x9B26, 0x9B2B, 0x9B2D, 0x9B33, 0x9B34, 0x9B35, 0x9B37, 0x9B39,
+ 0x9B3A, 0x9B3D, 0x9B48, 0x9B4B, 0x9B4C, 0x9B55, 0x9B56, 0x9B57,
+ 0x9B5B, 0x9B5E, 0x9B61, 0x9B63, 0x9B65, 0x9B66, 0x9B68, 0x9B6A,
+ 0x9B6B, 0x9B6C, 0x9B6D, 0x9B6E, 0x9B73, 0x9B75, 0x9B77, 0x9B78,
+ 0x9B79, 0x9B7F, 0x9B80, 0x9B84, 0x9B85, 0x9B86, 0x9B87, 0x9B89,
+ 0x9B8A, 0x9B8B, 0x9B8D, 0x9B8F, 0x9B90, 0x9B94, 0x9B9A, 0x9B9D,
+ 0x9B9E, 0x9BA6, 0x9BA7, 0x9BA9, 0x9BAC, 0x9BB0, 0x9BB1, 0x9BB2,
+ 0x9BB7, 0x9BB8, 0x9BBB, 0x9BBC, 0x9BBE, 0x9BBF, 0x9BC1, 0x9BC7,
+ 0x9BC8, 0x9BCE, 0x9BD0, 0x9BD7, 0x9BD8, 0x9BDD, 0x9BDF, 0x9BE5,
+ 0x9BE7, 0x9BEA, 0x9BEB, 0x9BEF, 0x9BF3, 0x9BF7, 0x9BF8,
+};
+static const unsigned short euc_to_utf8_8FEB[] = {
+ 0x9BF9, 0x9BFA, 0x9BFD, 0x9BFF, 0x9C00, 0x9C02, 0x9C0B,
+ 0x9C0F, 0x9C11, 0x9C16, 0x9C18, 0x9C19, 0x9C1A, 0x9C1C, 0x9C1E,
+ 0x9C22, 0x9C23, 0x9C26, 0x9C27, 0x9C28, 0x9C29, 0x9C2A, 0x9C31,
+ 0x9C35, 0x9C36, 0x9C37, 0x9C3D, 0x9C41, 0x9C43, 0x9C44, 0x9C45,
+ 0x9C49, 0x9C4A, 0x9C4E, 0x9C4F, 0x9C50, 0x9C53, 0x9C54, 0x9C56,
+ 0x9C58, 0x9C5B, 0x9C5D, 0x9C5E, 0x9C5F, 0x9C63, 0x9C69, 0x9C6A,
+ 0x9C5C, 0x9C6B, 0x9C68, 0x9C6E, 0x9C70, 0x9C72, 0x9C75, 0x9C77,
+ 0x9C7B, 0x9CE6, 0x9CF2, 0x9CF7, 0x9CF9, 0x9D0B, 0x9D02, 0x9D11,
+ 0x9D17, 0x9D18, 0x9D1C, 0x9D1D, 0x9D1E, 0x9D2F, 0x9D30, 0x9D32,
+ 0x9D33, 0x9D34, 0x9D3A, 0x9D3C, 0x9D45, 0x9D3D, 0x9D42, 0x9D43,
+ 0x9D47, 0x9D4A, 0x9D53, 0x9D54, 0x9D5F, 0x9D63, 0x9D62, 0x9D65,
+ 0x9D69, 0x9D6A, 0x9D6B, 0x9D70, 0x9D76, 0x9D77, 0x9D7B,
+};
+static const unsigned short euc_to_utf8_8FEC[] = {
+ 0x9D7C, 0x9D7E, 0x9D83, 0x9D84, 0x9D86, 0x9D8A, 0x9D8D,
+ 0x9D8E, 0x9D92, 0x9D93, 0x9D95, 0x9D96, 0x9D97, 0x9D98, 0x9DA1,
+ 0x9DAA, 0x9DAC, 0x9DAE, 0x9DB1, 0x9DB5, 0x9DB9, 0x9DBC, 0x9DBF,
+ 0x9DC3, 0x9DC7, 0x9DC9, 0x9DCA, 0x9DD4, 0x9DD5, 0x9DD6, 0x9DD7,
+ 0x9DDA, 0x9DDE, 0x9DDF, 0x9DE0, 0x9DE5, 0x9DE7, 0x9DE9, 0x9DEB,
+ 0x9DEE, 0x9DF0, 0x9DF3, 0x9DF4, 0x9DFE, 0x9E0A, 0x9E02, 0x9E07,
+ 0x9E0E, 0x9E10, 0x9E11, 0x9E12, 0x9E15, 0x9E16, 0x9E19, 0x9E1C,
+ 0x9E1D, 0x9E7A, 0x9E7B, 0x9E7C, 0x9E80, 0x9E82, 0x9E83, 0x9E84,
+ 0x9E85, 0x9E87, 0x9E8E, 0x9E8F, 0x9E96, 0x9E98, 0x9E9B, 0x9E9E,
+ 0x9EA4, 0x9EA8, 0x9EAC, 0x9EAE, 0x9EAF, 0x9EB0, 0x9EB3, 0x9EB4,
+ 0x9EB5, 0x9EC6, 0x9EC8, 0x9ECB, 0x9ED5, 0x9EDF, 0x9EE4, 0x9EE7,
+ 0x9EEC, 0x9EED, 0x9EEE, 0x9EF0, 0x9EF1, 0x9EF2, 0x9EF5,
+};
+static const unsigned short euc_to_utf8_8FED[] = {
+ 0x9EF8, 0x9EFF, 0x9F02, 0x9F03, 0x9F09, 0x9F0F, 0x9F10,
+ 0x9F11, 0x9F12, 0x9F14, 0x9F16, 0x9F17, 0x9F19, 0x9F1A, 0x9F1B,
+ 0x9F1F, 0x9F22, 0x9F26, 0x9F2A, 0x9F2B, 0x9F2F, 0x9F31, 0x9F32,
+ 0x9F34, 0x9F37, 0x9F39, 0x9F3A, 0x9F3C, 0x9F3D, 0x9F3F, 0x9F41,
+ 0x9F43, 0x9F44, 0x9F45, 0x9F46, 0x9F47, 0x9F53, 0x9F55, 0x9F56,
+ 0x9F57, 0x9F58, 0x9F5A, 0x9F5D, 0x9F5E, 0x9F68, 0x9F69, 0x9F6D,
+ 0x9F6E, 0x9F6F, 0x9F70, 0x9F71, 0x9F73, 0x9F75, 0x9F7A, 0x9F7D,
+ 0x9F8F, 0x9F90, 0x9F91, 0x9F92, 0x9F94, 0x9F96, 0x9F97, 0x9F9E,
+ 0x9FA1, 0x9FA2, 0x9FA3, 0x9FA5, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0,
+};
+static const unsigned short euc_to_utf8_8FF3[] = {
+ 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0x2170, 0x2171, 0x2172, 0x2173, 0x2174,
+ 0x2175, 0x2176, 0x2177, 0x2178, 0x2179, 0x2160, 0x2161,
+};
+static const unsigned short euc_to_utf8_8FF4[] = {
+ 0x2162, 0x2163, 0x2164, 0x2165, 0x2166, 0x2167, 0x2168,
+ 0x2169, 0xff07, 0xff02, 0x3231, 0x2116, 0x2121, 0x70bb, 0x4efc,
+ 0x50f4, 0x51ec, 0x5307, 0x5324, 0xfa0e, 0x548a, 0x5759, 0xfa0f,
+ 0xfa10, 0x589e, 0x5bec, 0x5cf5, 0x5d53, 0xfa11, 0x5fb7, 0x6085,
+ 0x6120, 0x654e, 0x663b, 0x6665, 0xfa12, 0xf929, 0x6801, 0xfa13,
+ 0xfa14, 0x6a6b, 0x6ae2, 0x6df8, 0x6df2, 0x7028, 0xfa15, 0xfa16,
+ 0x7501, 0x7682, 0x769e, 0xfa17, 0x7930, 0xfa18, 0xfa19, 0xfa1a,
+ 0xfa1b, 0x7ae7, 0xfa1c, 0xfa1d, 0x7da0, 0x7dd6, 0xfa1e, 0x8362,
+ 0xfa1f, 0x85b0, 0xfa20, 0xfa21, 0x8807, 0xfa22, 0x8b7f, 0x8cf4,
+ 0x8d76, 0xfa23, 0xfa24, 0xfa25, 0x90de, 0xfa26, 0x9115, 0xfa27,
+ 0xfa28, 0x9592, 0xf9dc, 0xfa29, 0x973b, 0x974d, 0x9751, 0xfa2a,
+ 0xfa2b, 0xfa2c, 0x999e, 0x9ad9, 0x9b72, 0xfa2d, 0x9ed1,
+};
+#endif /* X0212_ENABLE */
+
+const unsigned short euc_to_utf8_1byte[] = {
+ 0xFF61, 0xFF62, 0xFF63, 0xFF64, 0xFF65, 0xFF66, 0xFF67,
+ 0xFF68, 0xFF69, 0xFF6A, 0xFF6B, 0xFF6C, 0xFF6D, 0xFF6E, 0xFF6F,
+ 0xFF70, 0xFF71, 0xFF72, 0xFF73, 0xFF74, 0xFF75, 0xFF76, 0xFF77,
+ 0xFF78, 0xFF79, 0xFF7A, 0xFF7B, 0xFF7C, 0xFF7D, 0xFF7E, 0xFF7F,
+ 0xFF80, 0xFF81, 0xFF82, 0xFF83, 0xFF84, 0xFF85, 0xFF86, 0xFF87,
+ 0xFF88, 0xFF89, 0xFF8A, 0xFF8B, 0xFF8C, 0xFF8D, 0xFF8E, 0xFF8F,
+ 0xFF90, 0xFF91, 0xFF92, 0xFF93, 0xFF94, 0xFF95, 0xFF96, 0xFF97,
+ 0xFF98, 0xFF99, 0xFF9A, 0xFF9B, 0xFF9C, 0xFF9D, 0xFF9E, 0xFF9F,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0x00A9, 0x2122,
+};
+const unsigned short *const euc_to_utf8_2bytes[] = {
+ euc_to_utf8_A1, euc_to_utf8_A2, euc_to_utf8_A3,
+ euc_to_utf8_A4, euc_to_utf8_A5, euc_to_utf8_A6, euc_to_utf8_A7,
+ euc_to_utf8_A8, euc_to_utf8_A9, euc_to_utf8_AA, euc_to_utf8_AB,
+ euc_to_utf8_AC, euc_to_utf8_AD, euc_to_utf8_AE, euc_to_utf8_AF,
+ euc_to_utf8_B0, euc_to_utf8_B1, euc_to_utf8_B2, euc_to_utf8_B3,
+ euc_to_utf8_B4, euc_to_utf8_B5, euc_to_utf8_B6, euc_to_utf8_B7,
+ euc_to_utf8_B8, euc_to_utf8_B9, euc_to_utf8_BA, euc_to_utf8_BB,
+ euc_to_utf8_BC, euc_to_utf8_BD, euc_to_utf8_BE, euc_to_utf8_BF,
+ euc_to_utf8_C0, euc_to_utf8_C1, euc_to_utf8_C2, euc_to_utf8_C3,
+ euc_to_utf8_C4, euc_to_utf8_C5, euc_to_utf8_C6, euc_to_utf8_C7,
+ euc_to_utf8_C8, euc_to_utf8_C9, euc_to_utf8_CA, euc_to_utf8_CB,
+ euc_to_utf8_CC, euc_to_utf8_CD, euc_to_utf8_CE, euc_to_utf8_CF,
+ euc_to_utf8_D0, euc_to_utf8_D1, euc_to_utf8_D2, euc_to_utf8_D3,
+ euc_to_utf8_D4, euc_to_utf8_D5, euc_to_utf8_D6, euc_to_utf8_D7,
+ euc_to_utf8_D8, euc_to_utf8_D9, euc_to_utf8_DA, euc_to_utf8_DB,
+ euc_to_utf8_DC, euc_to_utf8_DD, euc_to_utf8_DE, euc_to_utf8_DF,
+ euc_to_utf8_E0, euc_to_utf8_E1, euc_to_utf8_E2, euc_to_utf8_E3,
+ euc_to_utf8_E4, euc_to_utf8_E5, euc_to_utf8_E6, euc_to_utf8_E7,
+ euc_to_utf8_E8, euc_to_utf8_E9, euc_to_utf8_EA, euc_to_utf8_EB,
+ euc_to_utf8_EC, euc_to_utf8_ED, euc_to_utf8_EE, euc_to_utf8_EF,
+ euc_to_utf8_F0, euc_to_utf8_F1, euc_to_utf8_F2, euc_to_utf8_F3,
+ euc_to_utf8_F4, euc_to_utf8_F5, 0, 0,
+ 0, euc_to_utf8_F9, euc_to_utf8_FA, euc_to_utf8_FB,
+ euc_to_utf8_FC, 0, 0,
+};
+/* Microsoft UCS Mapping Compatible */
+const unsigned short *const euc_to_utf8_2bytes_ms[] = {
+ euc_to_utf8_A1_ms, euc_to_utf8_A2_ms, euc_to_utf8_A3,
+ euc_to_utf8_A4, euc_to_utf8_A5, euc_to_utf8_A6, euc_to_utf8_A7,
+ euc_to_utf8_A8, euc_to_utf8_A9, euc_to_utf8_AA, euc_to_utf8_AB,
+ euc_to_utf8_AC, euc_to_utf8_AD, euc_to_utf8_AE, euc_to_utf8_AF,
+ euc_to_utf8_B0, euc_to_utf8_B1, euc_to_utf8_B2, euc_to_utf8_B3,
+ euc_to_utf8_B4, euc_to_utf8_B5, euc_to_utf8_B6, euc_to_utf8_B7,
+ euc_to_utf8_B8, euc_to_utf8_B9, euc_to_utf8_BA, euc_to_utf8_BB,
+ euc_to_utf8_BC, euc_to_utf8_BD, euc_to_utf8_BE, euc_to_utf8_BF,
+ euc_to_utf8_C0, euc_to_utf8_C1, euc_to_utf8_C2, euc_to_utf8_C3,
+ euc_to_utf8_C4, euc_to_utf8_C5, euc_to_utf8_C6, euc_to_utf8_C7,
+ euc_to_utf8_C8, euc_to_utf8_C9, euc_to_utf8_CA, euc_to_utf8_CB,
+ euc_to_utf8_CC, euc_to_utf8_CD, euc_to_utf8_CE, euc_to_utf8_CF,
+ euc_to_utf8_D0, euc_to_utf8_D1, euc_to_utf8_D2, euc_to_utf8_D3,
+ euc_to_utf8_D4, euc_to_utf8_D5, euc_to_utf8_D6, euc_to_utf8_D7,
+ euc_to_utf8_D8, euc_to_utf8_D9, euc_to_utf8_DA, euc_to_utf8_DB,
+ euc_to_utf8_DC, euc_to_utf8_DD, euc_to_utf8_DE, euc_to_utf8_DF,
+ euc_to_utf8_E0, euc_to_utf8_E1, euc_to_utf8_E2, euc_to_utf8_E3,
+ euc_to_utf8_E4, euc_to_utf8_E5, euc_to_utf8_E6, euc_to_utf8_E7,
+ euc_to_utf8_E8, euc_to_utf8_E9, euc_to_utf8_EA, euc_to_utf8_EB,
+ euc_to_utf8_EC, euc_to_utf8_ED, euc_to_utf8_EE, euc_to_utf8_EF,
+ euc_to_utf8_F0, euc_to_utf8_F1, euc_to_utf8_F2, euc_to_utf8_F3,
+ euc_to_utf8_F4, euc_to_utf8_F5, 0, 0,
+ 0, euc_to_utf8_F9, euc_to_utf8_FA, euc_to_utf8_FB,
+ euc_to_utf8_FC_ms, 0, 0,
+};
+/* CP10001 */
+const unsigned short *const euc_to_utf8_2bytes_mac[] = {
+ euc_to_utf8_A1_ms, euc_to_utf8_A2_ms, euc_to_utf8_A3,
+ euc_to_utf8_A4, euc_to_utf8_A5, euc_to_utf8_A6, euc_to_utf8_A7,
+ euc_to_utf8_A8, euc_to_utf8_A9, euc_to_utf8_AA, euc_to_utf8_AB,
+ euc_to_utf8_AC_mac, euc_to_utf8_AD_mac, euc_to_utf8_AE, euc_to_utf8_AF,
+ euc_to_utf8_B0, euc_to_utf8_B1, euc_to_utf8_B2, euc_to_utf8_B3,
+ euc_to_utf8_B4, euc_to_utf8_B5, euc_to_utf8_B6, euc_to_utf8_B7,
+ euc_to_utf8_B8, euc_to_utf8_B9, euc_to_utf8_BA, euc_to_utf8_BB,
+ euc_to_utf8_BC, euc_to_utf8_BD, euc_to_utf8_BE, euc_to_utf8_BF,
+ euc_to_utf8_C0, euc_to_utf8_C1, euc_to_utf8_C2, euc_to_utf8_C3,
+ euc_to_utf8_C4, euc_to_utf8_C5, euc_to_utf8_C6, euc_to_utf8_C7,
+ euc_to_utf8_C8, euc_to_utf8_C9, euc_to_utf8_CA, euc_to_utf8_CB,
+ euc_to_utf8_CC, euc_to_utf8_CD, euc_to_utf8_CE, euc_to_utf8_CF,
+ euc_to_utf8_D0, euc_to_utf8_D1, euc_to_utf8_D2, euc_to_utf8_D3,
+ euc_to_utf8_D4, euc_to_utf8_D5, euc_to_utf8_D6, euc_to_utf8_D7,
+ euc_to_utf8_D8, euc_to_utf8_D9, euc_to_utf8_DA, euc_to_utf8_DB,
+ euc_to_utf8_DC, euc_to_utf8_DD, euc_to_utf8_DE, euc_to_utf8_DF,
+ euc_to_utf8_E0, euc_to_utf8_E1, euc_to_utf8_E2, euc_to_utf8_E3,
+ euc_to_utf8_E4, euc_to_utf8_E5, euc_to_utf8_E6, euc_to_utf8_E7,
+ euc_to_utf8_E8, euc_to_utf8_E9, euc_to_utf8_EA, euc_to_utf8_EB,
+ euc_to_utf8_EC, euc_to_utf8_ED, euc_to_utf8_EE, euc_to_utf8_EF,
+ euc_to_utf8_F0, euc_to_utf8_F1, euc_to_utf8_F2, euc_to_utf8_F3,
+ euc_to_utf8_F4, euc_to_utf8_F5, 0, 0,
+ 0, euc_to_utf8_F9, euc_to_utf8_FA, euc_to_utf8_FB,
+ euc_to_utf8_FC_ms, 0, 0,
+};
+const unsigned short *const euc_to_utf8_2bytes_x0213[] = {
+ euc_to_utf8_A1, euc_to_utf8_A2_x0213, euc_to_utf8_A3_x0213,
+ euc_to_utf8_A4_x0213, euc_to_utf8_A5_x0213, euc_to_utf8_A6_x0213, euc_to_utf8_A7_x0213,
+ euc_to_utf8_A8_x0213, euc_to_utf8_A9_x0213, euc_to_utf8_AA_x0213, euc_to_utf8_AB_x0213,
+ euc_to_utf8_AC_x0213, euc_to_utf8_AD_x0213, euc_to_utf8_AE_x0213, euc_to_utf8_AF_x0213,
+ euc_to_utf8_B0, euc_to_utf8_B1, euc_to_utf8_B2, euc_to_utf8_B3,
+ euc_to_utf8_B4, euc_to_utf8_B5, euc_to_utf8_B6, euc_to_utf8_B7,
+ euc_to_utf8_B8, euc_to_utf8_B9, euc_to_utf8_BA, euc_to_utf8_BB,
+ euc_to_utf8_BC, euc_to_utf8_BD, euc_to_utf8_BE, euc_to_utf8_BF,
+ euc_to_utf8_C0, euc_to_utf8_C1, euc_to_utf8_C2, euc_to_utf8_C3,
+ euc_to_utf8_C4, euc_to_utf8_C5, euc_to_utf8_C6, euc_to_utf8_C7,
+ euc_to_utf8_C8, euc_to_utf8_C9, euc_to_utf8_CA, euc_to_utf8_CB,
+ euc_to_utf8_CC, euc_to_utf8_CD, euc_to_utf8_CE, euc_to_utf8_CF_x0213,
+ euc_to_utf8_D0, euc_to_utf8_D1, euc_to_utf8_D2, euc_to_utf8_D3,
+ euc_to_utf8_D4, euc_to_utf8_D5, euc_to_utf8_D6, euc_to_utf8_D7,
+ euc_to_utf8_D8, euc_to_utf8_D9, euc_to_utf8_DA, euc_to_utf8_DB,
+ euc_to_utf8_DC, euc_to_utf8_DD, euc_to_utf8_DE, euc_to_utf8_DF,
+ euc_to_utf8_E0, euc_to_utf8_E1, euc_to_utf8_E2, euc_to_utf8_E3,
+ euc_to_utf8_E4, euc_to_utf8_E5, euc_to_utf8_E6, euc_to_utf8_E7,
+ euc_to_utf8_E8, euc_to_utf8_E9, euc_to_utf8_EA, euc_to_utf8_EB,
+ euc_to_utf8_EC, euc_to_utf8_ED, euc_to_utf8_EE, euc_to_utf8_EF,
+ euc_to_utf8_F0, euc_to_utf8_F1, euc_to_utf8_F2, euc_to_utf8_F3,
+ euc_to_utf8_F4_x0213, euc_to_utf8_F5_x0213, euc_to_utf8_F6_x0213, euc_to_utf8_F7_x0213,
+ euc_to_utf8_F8_x0213, euc_to_utf8_F9_x0213, euc_to_utf8_FA_x0213, euc_to_utf8_FB_x0213,
+ euc_to_utf8_FC_x0213, euc_to_utf8_FD_x0213, euc_to_utf8_FE_x0213,
+};
+
+#ifdef X0212_ENABLE
+const unsigned short *const x0212_to_utf8_2bytes[] = {
+ 0, euc_to_utf8_8FA2, 0,
+ 0, 0, euc_to_utf8_8FA6, euc_to_utf8_8FA7,
+ 0, euc_to_utf8_8FA9, euc_to_utf8_8FAA, euc_to_utf8_8FAB,
+ 0, 0, 0, 0,
+ euc_to_utf8_8FB0, euc_to_utf8_8FB1, euc_to_utf8_8FB2, euc_to_utf8_8FB3,
+ euc_to_utf8_8FB4, euc_to_utf8_8FB5, euc_to_utf8_8FB6, euc_to_utf8_8FB7,
+ euc_to_utf8_8FB8, euc_to_utf8_8FB9, euc_to_utf8_8FBA, euc_to_utf8_8FBB,
+ euc_to_utf8_8FBC, euc_to_utf8_8FBD, euc_to_utf8_8FBE, euc_to_utf8_8FBF,
+ euc_to_utf8_8FC0, euc_to_utf8_8FC1, euc_to_utf8_8FC2, euc_to_utf8_8FC3,
+ euc_to_utf8_8FC4, euc_to_utf8_8FC5, euc_to_utf8_8FC6, euc_to_utf8_8FC7,
+ euc_to_utf8_8FC8, euc_to_utf8_8FC9, euc_to_utf8_8FCA, euc_to_utf8_8FCB,
+ euc_to_utf8_8FCC, euc_to_utf8_8FCD, euc_to_utf8_8FCE, euc_to_utf8_8FCF,
+ euc_to_utf8_8FD0, euc_to_utf8_8FD1, euc_to_utf8_8FD2, euc_to_utf8_8FD3,
+ euc_to_utf8_8FD4, euc_to_utf8_8FD5, euc_to_utf8_8FD6, euc_to_utf8_8FD7,
+ euc_to_utf8_8FD8, euc_to_utf8_8FD9, euc_to_utf8_8FDA, euc_to_utf8_8FDB,
+ euc_to_utf8_8FDC, euc_to_utf8_8FDD, euc_to_utf8_8FDE, euc_to_utf8_8FDF,
+ euc_to_utf8_8FE0, euc_to_utf8_8FE1, euc_to_utf8_8FE2, euc_to_utf8_8FE3,
+ euc_to_utf8_8FE4, euc_to_utf8_8FE5, euc_to_utf8_8FE6, euc_to_utf8_8FE7,
+ euc_to_utf8_8FE8, euc_to_utf8_8FE9, euc_to_utf8_8FEA, euc_to_utf8_8FEB,
+ euc_to_utf8_8FEC, euc_to_utf8_8FED, 0, 0,
+ 0, 0, 0, euc_to_utf8_8FF3,
+ euc_to_utf8_8FF4, 0, 0, 0,
+ 0, 0, 0, 0,
+ 0, 0, 0,};
+
+const unsigned short *const x0212_to_utf8_2bytes_x0213[] = {
+ euc_to_utf8_8FA1_x0213, euc_to_utf8_8FA2, euc_to_utf8_8FA3_x0213,
+ euc_to_utf8_8FA4_x0213, euc_to_utf8_8FA5_x0213, euc_to_utf8_8FA6, euc_to_utf8_8FA7,
+ euc_to_utf8_8FA8_x0213, euc_to_utf8_8FA9, euc_to_utf8_8FAA, euc_to_utf8_8FAB,
+ euc_to_utf8_8FAC_x0213, euc_to_utf8_8FAD_x0213, euc_to_utf8_8FAE_x0213, euc_to_utf8_8FAF_x0213,
+ euc_to_utf8_8FB0, euc_to_utf8_8FB1, euc_to_utf8_8FB2, euc_to_utf8_8FB3,
+ euc_to_utf8_8FB4, euc_to_utf8_8FB5, euc_to_utf8_8FB6, euc_to_utf8_8FB7,
+ euc_to_utf8_8FB8, euc_to_utf8_8FB9, euc_to_utf8_8FBA, euc_to_utf8_8FBB,
+ euc_to_utf8_8FBC, euc_to_utf8_8FBD, euc_to_utf8_8FBE, euc_to_utf8_8FBF,
+ euc_to_utf8_8FC0, euc_to_utf8_8FC1, euc_to_utf8_8FC2, euc_to_utf8_8FC3,
+ euc_to_utf8_8FC4, euc_to_utf8_8FC5, euc_to_utf8_8FC6, euc_to_utf8_8FC7,
+ euc_to_utf8_8FC8, euc_to_utf8_8FC9, euc_to_utf8_8FCA, euc_to_utf8_8FCB,
+ euc_to_utf8_8FCC, euc_to_utf8_8FCD, euc_to_utf8_8FCE, euc_to_utf8_8FCF,
+ euc_to_utf8_8FD0, euc_to_utf8_8FD1, euc_to_utf8_8FD2, euc_to_utf8_8FD3,
+ euc_to_utf8_8FD4, euc_to_utf8_8FD5, euc_to_utf8_8FD6, euc_to_utf8_8FD7,
+ euc_to_utf8_8FD8, euc_to_utf8_8FD9, euc_to_utf8_8FDA, euc_to_utf8_8FDB,
+ euc_to_utf8_8FDC, euc_to_utf8_8FDD, euc_to_utf8_8FDE, euc_to_utf8_8FDF,
+ euc_to_utf8_8FE0, euc_to_utf8_8FE1, euc_to_utf8_8FE2, euc_to_utf8_8FE3,
+ euc_to_utf8_8FE4, euc_to_utf8_8FE5, euc_to_utf8_8FE6, euc_to_utf8_8FE7,
+ euc_to_utf8_8FE8, euc_to_utf8_8FE9, euc_to_utf8_8FEA, euc_to_utf8_8FEB,
+ euc_to_utf8_8FEC, euc_to_utf8_8FED, euc_to_utf8_8FEE_x0213, euc_to_utf8_8FEF_x0213,
+ euc_to_utf8_8FF0_x0213, euc_to_utf8_8FF1_x0213, euc_to_utf8_8FF2_x0213, euc_to_utf8_8FF3_x0213,
+ euc_to_utf8_8FF4_x0213, euc_to_utf8_8FF5_x0213, euc_to_utf8_8FF6_x0213, euc_to_utf8_8FF7_x0213,
+ euc_to_utf8_8FF8_x0213, euc_to_utf8_8FF9_x0213, euc_to_utf8_8FFA_x0213, euc_to_utf8_8FFB_x0213,
+ euc_to_utf8_8FFC_x0213, euc_to_utf8_8FFD_x0213, euc_to_utf8_8FFE_x0213,};
+#endif /* X0212_ENABLE */
+
+const unsigned short x0213_combining_chars[sizeof_x0213_combining_chars] = {
+ 0x309A, 0x0300, 0x0301, 0x02E5, 0x02E9,
+};
+const unsigned short x0213_combining_table[sizeof_x0213_combining_table][3] = {
+ {0x2477, 0x304B, 0x309A},
+ {0x2478, 0x304D, 0x309A},
+ {0x2479, 0x304F, 0x309A},
+ {0x247A, 0x3051, 0x309A},
+ {0x247B, 0x3053, 0x309A},
+ {0x2577, 0x30AB, 0x309A},
+ {0x2578, 0x30AD, 0x309A},
+ {0x2579, 0x30AF, 0x309A},
+ {0x257A, 0x30B1, 0x309A},
+ {0x257B, 0x30B3, 0x309A},
+ {0x257C, 0x30BB, 0x309A},
+ {0x257D, 0x30C4, 0x309A},
+ {0x257E, 0x30C8, 0x309A},
+ {0x2678, 0x31F7, 0x309A},
+ {0x2B44, 0x00E6, 0x0300},
+ {0x2B48, 0x0254, 0x0300},
+ {0x2B49, 0x0254, 0x0301},
+ {0x2B4A, 0x028C, 0x0300},
+ {0x2B4B, 0x028C, 0x0301},
+ {0x2B4C, 0x0259, 0x0300},
+ {0x2B4D, 0x0259, 0x0301},
+ {0x2B4E, 0x025A, 0x0300},
+ {0x2B4F, 0x025A, 0x0301},
+ {0x2B65, 0x02E9, 0x02E5},
+ {0x2B66, 0x02E5, 0x02E9},
+};
+const unsigned short x0213_1_surrogate_table[sizeof_x0213_1_surrogate_table][3] = {
+ {0x2E22, 0xD840, 0xDC0B},
+ {0x2F42, 0xD844, 0xDE3D},
+ {0x2F4C, 0xD844, 0xDF1B},
+ {0x2F60, 0xD845, 0xDC6E},
+ {0x2F7B, 0xD846, 0xDCBD},
+ {0x4F54, 0xD842, 0xDF9F},
+ {0x4F63, 0xD845, 0xDEB4},
+ {0x4F6E, 0xD847, 0xDE34},
+ {0x753A, 0xD84C, 0xDDC4},
+ {0x7572, 0xD84D, 0xDDC4},
+ {0x7629, 0xD84D, 0xDF3F},
+ {0x7632, 0xD84D, 0xDF63},
+ {0x7660, 0xD84F, 0xDCFE},
+ {0x776C, 0xD851, 0xDFF1},
+ {0x787E, 0xD855, 0xDC8E},
+ {0x7929, 0xD855, 0xDD0E},
+ {0x7947, 0xD855, 0xDF71},
+ {0x7954, 0xD856, 0xDDC4},
+ {0x796E, 0xD857, 0xDDA1},
+ {0x7A5D, 0xD85A, 0xDEFF},
+ {0x7B33, 0xD85B, 0xDE40},
+ {0x7B49, 0xD85C, 0xDCF4},
+ {0x7B6C, 0xD85D, 0xDE84},
+ {0x7C49, 0xD860, 0xDE77},
+ {0x7C51, 0xD860, 0xDFCD},
+ {0x7E66, 0xD868, 0xDD90},
+};
+const unsigned short x0213_2_surrogate_table[sizeof_x0213_2_surrogate_table][3] = {
+ {0x2121, 0xD840, 0xDC89},
+ {0x212B, 0xD840, 0xDCA2},
+ {0x212E, 0xD840, 0xDCA4},
+ {0x2136, 0xD840, 0xDDA2},
+ {0x2146, 0xD840, 0xDE13},
+ {0x2170, 0xD840, 0xDF2B},
+ {0x2177, 0xD840, 0xDF81},
+ {0x2179, 0xD840, 0xDF71},
+ {0x2322, 0xD840, 0xDFF9},
+ {0x2325, 0xD841, 0xDC4A},
+ {0x2327, 0xD841, 0xDD09},
+ {0x2331, 0xD841, 0xDDD6},
+ {0x2332, 0xD841, 0xDE28},
+ {0x2338, 0xD841, 0xDF4F},
+ {0x233F, 0xD842, 0xDC07},
+ {0x2341, 0xD842, 0xDC3A},
+ {0x234A, 0xD842, 0xDCB9},
+ {0x2352, 0xD842, 0xDD7C},
+ {0x2353, 0xD842, 0xDD9D},
+ {0x2359, 0xD842, 0xDED3},
+ {0x235C, 0xD842, 0xDF1D},
+ {0x2377, 0xD843, 0xDD45},
+ {0x242A, 0xD843, 0xDDE1},
+ {0x2431, 0xD843, 0xDE95},
+ {0x2432, 0xD843, 0xDE6D},
+ {0x243A, 0xD843, 0xDE64},
+ {0x243D, 0xD843, 0xDF5F},
+ {0x2459, 0xD844, 0xDE01},
+ {0x245C, 0xD844, 0xDE55},
+ {0x245E, 0xD844, 0xDE7B},
+ {0x2463, 0xD844, 0xDE74},
+ {0x246A, 0xD844, 0xDEE4},
+ {0x246B, 0xD844, 0xDED7},
+ {0x2472, 0xD844, 0xDEFD},
+ {0x2474, 0xD844, 0xDF36},
+ {0x2475, 0xD844, 0xDF44},
+ {0x2525, 0xD844, 0xDFC4},
+ {0x2532, 0xD845, 0xDC6D},
+ {0x253E, 0xD845, 0xDDD7},
+ {0x2544, 0xD85B, 0xDC29},
+ {0x2547, 0xD845, 0xDE47},
+ {0x2555, 0xD845, 0xDF06},
+ {0x2556, 0xD845, 0xDF42},
+ {0x257E, 0xD846, 0xDDC3},
+ {0x2830, 0xD847, 0xDC56},
+ {0x2837, 0xD847, 0xDD2D},
+ {0x2838, 0xD847, 0xDD45},
+ {0x283A, 0xD847, 0xDD78},
+ {0x283B, 0xD847, 0xDD62},
+ {0x283F, 0xD847, 0xDDA1},
+ {0x2840, 0xD847, 0xDD9C},
+ {0x2845, 0xD847, 0xDD92},
+ {0x2848, 0xD847, 0xDDB7},
+ {0x284A, 0xD847, 0xDDE0},
+ {0x284B, 0xD847, 0xDE33},
+ {0x285B, 0xD847, 0xDF1E},
+ {0x2866, 0xD847, 0xDF76},
+ {0x286C, 0xD847, 0xDFFA},
+ {0x2C22, 0xD848, 0xDD7B},
+ {0x2C2B, 0xD848, 0xDF1E},
+ {0x2C30, 0xD848, 0xDFAD},
+ {0x2C50, 0xD849, 0xDEF3},
+ {0x2C65, 0xD84A, 0xDC5B},
+ {0x2C6D, 0xD84A, 0xDCAB},
+ {0x2C72, 0xD84A, 0xDD8F},
+ {0x2D24, 0xD84A, 0xDEB8},
+ {0x2D29, 0xD84A, 0xDF4F},
+ {0x2D2A, 0xD84A, 0xDF50},
+ {0x2D32, 0xD84A, 0xDF46},
+ {0x2D34, 0xD84B, 0xDC1D},
+ {0x2D35, 0xD84A, 0xDFA6},
+ {0x2D39, 0xD84B, 0xDC24},
+ {0x2D56, 0xD84B, 0xDDE1},
+ {0x2D7D, 0xD84C, 0xDDC3},
+ {0x2E23, 0xD84C, 0xDDF5},
+ {0x2E24, 0xD84C, 0xDDB6},
+ {0x2E3A, 0xD84C, 0xDF72},
+ {0x2E3C, 0xD84C, 0xDFD3},
+ {0x2E3D, 0xD84C, 0xDFD2},
+ {0x2E42, 0xD84C, 0xDFD0},
+ {0x2E43, 0xD84C, 0xDFE4},
+ {0x2E44, 0xD84C, 0xDFD5},
+ {0x2E47, 0xD84C, 0xDFDA},
+ {0x2E49, 0xD84C, 0xDFDF},
+ {0x2E55, 0xD84D, 0xDC4A},
+ {0x2E56, 0xD84D, 0xDC51},
+ {0x2E57, 0xD84D, 0xDC4B},
+ {0x2E5B, 0xD84D, 0xDC65},
+ {0x2E77, 0xD84D, 0xDCE4},
+ {0x2E78, 0xD84D, 0xDD5A},
+ {0x2F2A, 0xD84D, 0xDD94},
+ {0x2F3F, 0xD84D, 0xDE39},
+ {0x2F40, 0xD84D, 0xDE47},
+ {0x2F42, 0xD84D, 0xDE38},
+ {0x2F43, 0xD84D, 0xDE3A},
+ {0x2F4E, 0xD84D, 0xDF1C},
+ {0x2F59, 0xD84D, 0xDF0C},
+ {0x2F61, 0xD84D, 0xDF64},
+ {0x2F69, 0xD84D, 0xDFFF},
+ {0x2F6A, 0xD84D, 0xDFE7},
+ {0x2F70, 0xD84E, 0xDC24},
+ {0x2F75, 0xD84E, 0xDC3D},
+ {0x6E23, 0xD84E, 0xDE98},
+ {0x6E34, 0xD84F, 0xDC7F},
+ {0x6E49, 0xD84F, 0xDD00},
+ {0x6E5C, 0xD84F, 0xDD40},
+ {0x6E5E, 0xD84F, 0xDDFA},
+ {0x6E5F, 0xD84F, 0xDDF9},
+ {0x6E60, 0xD84F, 0xDDD3},
+ {0x6F32, 0xD84F, 0xDF7E},
+ {0x6F47, 0xD850, 0xDC96},
+ {0x6F4D, 0xD850, 0xDD03},
+ {0x6F61, 0xD850, 0xDDC6},
+ {0x6F64, 0xD850, 0xDDFE},
+ {0x7022, 0xD850, 0xDFBC},
+ {0x7033, 0xD851, 0xDE29},
+ {0x7039, 0xD851, 0xDEA5},
+ {0x7053, 0xD852, 0xDC96},
+ {0x707B, 0xD852, 0xDE4D},
+ {0x712E, 0xD852, 0xDF56},
+ {0x7130, 0xD852, 0xDF6F},
+ {0x7135, 0xD853, 0xDC16},
+ {0x7144, 0xD853, 0xDD14},
+ {0x715D, 0xD853, 0xDE0E},
+ {0x7161, 0xD853, 0xDE37},
+ {0x7166, 0xD853, 0xDE6A},
+ {0x7169, 0xD853, 0xDE8B},
+ {0x7175, 0xD854, 0xDC4A},
+ {0x7177, 0xD854, 0xDC55},
+ {0x717A, 0xD854, 0xDD22},
+ {0x7221, 0xD854, 0xDDA9},
+ {0x7223, 0xD854, 0xDDE5},
+ {0x7224, 0xD854, 0xDDCD},
+ {0x7228, 0xD854, 0xDE1E},
+ {0x722C, 0xD854, 0xDE4C},
+ {0x723D, 0xD855, 0xDC2E},
+ {0x7248, 0xD855, 0xDCD9},
+ {0x725B, 0xD855, 0xDDA7},
+ {0x7275, 0xD855, 0xDFA9},
+ {0x7276, 0xD855, 0xDFB4},
+ {0x7332, 0xD856, 0xDDD4},
+ {0x733D, 0xD856, 0xDEE4},
+ {0x733E, 0xD856, 0xDEE3},
+ {0x7340, 0xD856, 0xDEF1},
+ {0x7352, 0xD856, 0xDFB2},
+ {0x735D, 0xD857, 0xDC4B},
+ {0x735E, 0xD857, 0xDC64},
+ {0x7373, 0xD857, 0xDE2E},
+ {0x7374, 0xD857, 0xDE56},
+ {0x7375, 0xD857, 0xDE65},
+ {0x7377, 0xD857, 0xDE62},
+ {0x737B, 0xD857, 0xDED8},
+ {0x737D, 0xD857, 0xDEC2},
+ {0x7422, 0xD857, 0xDEE8},
+ {0x7424, 0xD857, 0xDF23},
+ {0x7427, 0xD857, 0xDF5C},
+ {0x742E, 0xD857, 0xDFE0},
+ {0x742F, 0xD857, 0xDFD4},
+ {0x7434, 0xD858, 0xDC0C},
+ {0x7435, 0xD857, 0xDFFB},
+ {0x743D, 0xD858, 0xDC17},
+ {0x7442, 0xD858, 0xDC60},
+ {0x744F, 0xD858, 0xDCED},
+ {0x7469, 0xD858, 0xDE70},
+ {0x746B, 0xD858, 0xDE86},
+ {0x7472, 0xD858, 0xDF4C},
+ {0x7475, 0xD84F, 0xDD0E},
+ {0x7479, 0xD859, 0xDC02},
+ {0x7535, 0xD859, 0xDE7E},
+ {0x753A, 0xD859, 0xDEB0},
+ {0x7546, 0xD859, 0xDF1D},
+ {0x7556, 0xD85A, 0xDCDD},
+ {0x7558, 0xD85A, 0xDCEA},
+ {0x755A, 0xD85A, 0xDD51},
+ {0x755D, 0xD85A, 0xDD6F},
+ {0x755F, 0xD85A, 0xDDDD},
+ {0x7563, 0xD85A, 0xDE1E},
+ {0x756A, 0xD85A, 0xDE58},
+ {0x7570, 0xD85A, 0xDE8C},
+ {0x7573, 0xD85A, 0xDEB7},
+ {0x7644, 0xD85B, 0xDC73},
+ {0x764E, 0xD85B, 0xDCDD},
+ {0x765D, 0xD85B, 0xDE65},
+ {0x7675, 0xD85B, 0xDF94},
+ {0x767E, 0xD85B, 0xDFF8},
+ {0x7721, 0xD85B, 0xDFF6},
+ {0x7722, 0xD85B, 0xDFF7},
+ {0x7733, 0xD85C, 0xDD0D},
+ {0x7736, 0xD85C, 0xDD39},
+ {0x7764, 0xD85C, 0xDFDB},
+ {0x7765, 0xD85C, 0xDFDA},
+ {0x776B, 0xD85C, 0xDFFE},
+ {0x776E, 0xD85D, 0xDC10},
+ {0x7773, 0xD85D, 0xDC49},
+ {0x7829, 0xD85D, 0xDE15},
+ {0x782A, 0xD85D, 0xDE14},
+ {0x782C, 0xD85D, 0xDE31},
+ {0x7834, 0xD85D, 0xDE93},
+ {0x783C, 0xD85D, 0xDF0E},
+ {0x783E, 0xD85D, 0xDF23},
+ {0x7842, 0xD85D, 0xDF52},
+ {0x7856, 0xD85E, 0xDD85},
+ {0x7863, 0xD85E, 0xDE84},
+ {0x7877, 0xD85E, 0xDFB3},
+ {0x7879, 0xD85E, 0xDFBE},
+ {0x787A, 0xD85E, 0xDFC7},
+ {0x7925, 0xD85F, 0xDCB8},
+ {0x792F, 0xD85F, 0xDDA0},
+ {0x7932, 0xD85F, 0xDE10},
+ {0x7939, 0xD85F, 0xDFB7},
+ {0x7942, 0xD860, 0xDC8A},
+ {0x7948, 0xD860, 0xDCBB},
+ {0x7959, 0xD860, 0xDE82},
+ {0x795E, 0xD860, 0xDEF3},
+ {0x7966, 0xD861, 0xDC0C},
+ {0x796B, 0xD861, 0xDC55},
+ {0x797A, 0xD861, 0xDD6B},
+ {0x797E, 0xD861, 0xDDC8},
+ {0x7A21, 0xD861, 0xDDC9},
+ {0x7A2C, 0xD861, 0xDED7},
+ {0x7A2F, 0xD861, 0xDEFA},
+ {0x7A4F, 0xD862, 0xDD49},
+ {0x7A50, 0xD862, 0xDD46},
+ {0x7A57, 0xD862, 0xDD6B},
+ {0x7A65, 0xD862, 0xDD87},
+ {0x7A66, 0xD862, 0xDD88},
+ {0x7A71, 0xD862, 0xDDBA},
+ {0x7A72, 0xD862, 0xDDBB},
+ {0x7A7E, 0xD862, 0xDE1E},
+ {0x7B21, 0xD862, 0xDE29},
+ {0x7B2C, 0xD862, 0xDE71},
+ {0x7B2D, 0xD862, 0xDE43},
+ {0x7B36, 0xD862, 0xDE99},
+ {0x7B37, 0xD862, 0xDECD},
+ {0x7B3D, 0xD862, 0xDEE4},
+ {0x7B3E, 0xD862, 0xDEDD},
+ {0x7B4E, 0xD862, 0xDFC1},
+ {0x7B4F, 0xD862, 0xDFEF},
+ {0x7B57, 0xD863, 0xDD10},
+ {0x7B5A, 0xD863, 0xDD71},
+ {0x7B5C, 0xD863, 0xDDFB},
+ {0x7B5D, 0xD863, 0xDE1F},
+ {0x7B61, 0xD863, 0xDE36},
+ {0x7B65, 0xD863, 0xDE89},
+ {0x7B67, 0xD863, 0xDEEB},
+ {0x7B69, 0xD863, 0xDF32},
+ {0x7B71, 0xD863, 0xDFF8},
+ {0x7C22, 0xD864, 0xDEA0},
+ {0x7C23, 0xD864, 0xDEB1},
+ {0x7C38, 0xD865, 0xDC90},
+ {0x7C42, 0xD865, 0xDDCF},
+ {0x7C4C, 0xD865, 0xDE7F},
+ {0x7C56, 0xD865, 0xDEF0},
+ {0x7C59, 0xD865, 0xDF19},
+ {0x7C5D, 0xD865, 0xDF50},
+ {0x7C76, 0xD866, 0xDCC6},
+ {0x7D2C, 0xD866, 0xDE72},
+ {0x7D4B, 0xD867, 0xDDDB},
+ {0x7D4C, 0xD867, 0xDE3D},
+ {0x7D59, 0xD867, 0xDE15},
+ {0x7D5B, 0xD867, 0xDE8A},
+ {0x7D5D, 0xD867, 0xDE49},
+ {0x7D67, 0xD867, 0xDEC4},
+ {0x7D6D, 0xD867, 0xDEE9},
+ {0x7D70, 0xD867, 0xDEDB},
+ {0x7E25, 0xD867, 0xDFCE},
+ {0x7E29, 0xD868, 0xDC2F},
+ {0x7E2B, 0xD868, 0xDC1A},
+ {0x7E32, 0xD868, 0xDCF9},
+ {0x7E35, 0xD868, 0xDC82},
+ {0x7E53, 0xD848, 0xDE18},
+ {0x7E58, 0xD868, 0xDF8C},
+ {0x7E5A, 0xD869, 0xDC37},
+ {0x7E6E, 0xD869, 0xDDF1},
+ {0x7E70, 0xD869, 0xDE02},
+ {0x7E72, 0xD869, 0xDE1A},
+ {0x7E76, 0xD869, 0xDEB2},
+};
+#endif /* UTF8_OUTPUT_ENABLE */
+
+#ifdef UTF8_INPUT_ENABLE
+static const unsigned short utf8_to_euc_C2[] = {
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0xA242, 0x2171, 0x2172, 0xA270, 0x216F, 0xA243, 0x2178,
+ 0x212F, 0xA26D, 0xA26C, 0, 0x224C, 0, 0xA26E, 0xA234,
+ 0x216B, 0x215E, 0, 0, 0x212D, 0, 0x2279, 0,
+ 0xA231, 0, 0xA26B, 0, 0, 0, 0, 0xA244,
+};
+static const unsigned short utf8_to_euc_C2_ms[] = {
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0xA242, 0x2171, 0x2172, 0xA270, 0x5C, 0xA243, 0x2178,
+ 0x212F, 0xA26D, 0xA26C, 0, 0x224C, 0, 0xA26E, 0xA234,
+ 0x216B, 0x215E, 0, 0, 0x212D, 0, 0x2279, 0,
+ 0xA231, 0, 0xA26B, 0, 0, 0, 0, 0xA244,
+};
+static const unsigned short utf8_to_euc_C2_mac[] = {
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0x00A0, 0xA242, 0x2171, 0x2172, 0xA270, 0x5C, 0xA243, 0x2178,
+ 0x212F, 0x00FD, 0xA26C, 0, 0x224C, 0, 0xA26E, 0xA234,
+ 0x216B, 0x215E, 0, 0, 0x212D, 0, 0x2279, 0,
+ 0xA231, 0, 0xA26B, 0, 0, 0, 0, 0xA244,
+};
+static const unsigned short utf8_to_euc_C2_932[] = {
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0x21, 0x2171, 0x2172, 0, 0x5C, 0x7C, 0x2178,
+ 0x212F, 0x63, 0x61, 0x2263, 0x224C, 0x2D, 0x52, 0x2131,
+ 0x216B, 0x215E, 0x32, 0x33, 0x212D, 0x264C, 0x2279, 0x2126,
+ 0x2124, 0x31, 0x6F, 0x2264, 0, 0, 0, 0,
+};
+static const unsigned short utf8_to_euc_C2_x0213[] = {
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0x2922, 0x2923, 0x2171, 0x2172, 0x2924, 0x216F, 0x2925, 0x2178,
+ 0x212F, 0x2926, 0x2927, 0x2928, 0x224C, 0x2929, 0x292A, 0x292B,
+ 0x216B, 0x215E, 0x292C, 0x292D, 0x212D, 0, 0x2279, 0x292E,
+ 0x292F, 0x2930, 0x2931, 0x2932, 0x2933, 0x2934, 0x2935, 0x2936,
+};
+static const unsigned short utf8_to_euc_C3[] = {
+ 0xAA22, 0xAA21, 0xAA24, 0xAA2A, 0xAA23, 0xAA29, 0xA921, 0xAA2E,
+ 0xAA32, 0xAA31, 0xAA34, 0xAA33, 0xAA40, 0xAA3F, 0xAA42, 0xAA41,
+ 0, 0xAA50, 0xAA52, 0xAA51, 0xAA54, 0xAA58, 0xAA53, 0x215F,
+ 0xA92C, 0xAA63, 0xAA62, 0xAA65, 0xAA64, 0xAA72, 0xA930, 0xA94E,
+ 0xAB22, 0xAB21, 0xAB24, 0xAB2A, 0xAB23, 0xAB29, 0xA941, 0xAB2E,
+ 0xAB32, 0xAB31, 0xAB34, 0xAB33, 0xAB40, 0xAB3F, 0xAB42, 0xAB41,
+ 0xA943, 0xAB50, 0xAB52, 0xAB51, 0xAB54, 0xAB58, 0xAB53, 0x2160,
+ 0xA94C, 0xAB63, 0xAB62, 0xAB65, 0xAB64, 0xAB72, 0xA950, 0xAB73,
+};
+static const unsigned short utf8_to_euc_C3_932[] = {
+ 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x43,
+ 0x45, 0x45, 0x45, 0x45, 0x49, 0x49, 0x49, 0x49,
+ 0x44, 0x4E, 0x4F, 0x4F, 0x4F, 0x4F, 0x4F, 0x215F,
+ 0x4F, 0x55, 0x55, 0x55, 0x55, 0x59, 0x54, 0x73,
+ 0x61, 0x61, 0x61, 0x61, 0x61, 0x61, 0x61, 0x63,
+ 0x65, 0x65, 0x65, 0x65, 0x69, 0x69, 0x69, 0x69,
+ 0x64, 0x6E, 0x6F, 0x6F, 0x6F, 0x6F, 0x6F, 0x2160,
+ 0x6F, 0x75, 0x75, 0x75, 0x75, 0x79, 0x74, 0x79,
+};
+static const unsigned short utf8_to_euc_C3_x0213[] = {
+ 0x2937, 0x2938, 0x2939, 0x293A, 0x293B, 0x293C, 0x293D, 0x293E,
+ 0x293F, 0x2940, 0x2941, 0x2942, 0x2943, 0x2944, 0x2945, 0x2946,
+ 0x2947, 0x2948, 0x2949, 0x294A, 0x294B, 0x294C, 0x294D, 0x215F,
+ 0x294E, 0x294F, 0x2950, 0x2951, 0x2952, 0x2953, 0x2954, 0x2955,
+ 0x2956, 0x2957, 0x2958, 0x2959, 0x295A, 0x295B, 0x295C, 0x295D,
+ 0x295E, 0x295F, 0x2960, 0x2961, 0x2962, 0x2963, 0x2964, 0x2965,
+ 0x2966, 0x2967, 0x2968, 0x2969, 0x296A, 0x296B, 0x296C, 0x2160,
+ 0x296D, 0x296E, 0x296F, 0x2970, 0x2971, 0x2972, 0x2973, 0x2974,
+};
+static const unsigned short utf8_to_euc_C4[] = {
+ 0xAA27, 0xAB27, 0xAA25, 0xAB25, 0xAA28, 0xAB28, 0xAA2B, 0xAB2B,
+ 0xAA2C, 0xAB2C, 0xAA2F, 0xAB2F, 0xAA2D, 0xAB2D, 0xAA30, 0xAB30,
+ 0xA922, 0xA942, 0xAA37, 0xAB37, 0, 0, 0xAA36, 0xAB36,
+ 0xAA38, 0xAB38, 0xAA35, 0xAB35, 0xAA3A, 0xAB3A, 0xAA3B, 0xAB3B,
+ 0xAA3D, 0xAB3D, 0xAA3C, 0, 0xAA3E, 0xAB3E, 0xA924, 0xA944,
+ 0xAA47, 0xAB47, 0xAA45, 0xAB45, 0, 0, 0xAA46, 0xAB46,
+ 0xAA44, 0xA945, 0xA926, 0xA946, 0xAA48, 0xAB48, 0xAA49, 0xAB49,
+ 0xA947, 0xAA4A, 0xAB4A, 0xAA4C, 0xAB4C, 0xAA4B, 0xAB4B, 0xA929,
+};
+static const unsigned short utf8_to_euc_C4_x0213[] = {
+ 0x2975, 0x297A, 0x2A3A, 0x2A49, 0x2A21, 0x2A2C, 0x2A3C, 0x2A4B,
+ 0x2A59, 0x2A5F, 0xAA2F, 0xAB2F, 0x2A3D, 0x2A4C, 0x2A40, 0x2A4F,
+ 0xA922, 0x2A50, 0x2978, 0x297D, 0, 0, 0xAA36, 0xAB36,
+ 0x2A3E, 0x2A4D, 0x2A3F, 0x2A4E, 0x2A5A, 0x2A60, 0xAA3B, 0xAB3B,
+ 0xAA3D, 0xAB3D, 0xAA3C, 0, 0x2A5B, 0x2A61, 0xA924, 0x2A7D,
+ 0xAA47, 0xAB47, 0x2976, 0x297B, 0, 0, 0xAA46, 0xAB46,
+ 0xAA44, 0xA945, 0xA926, 0xA946, 0x2A5C, 0x2A62, 0xAA49, 0xAB49,
+ 0xA947, 0x2A3B, 0x2A4A, 0xAA4C, 0xAB4C, 0x2A24, 0x2A2F, 0xA929,
+};
+static const unsigned short utf8_to_euc_C5[] = {
+ 0xA949, 0xA928, 0xA948, 0xAA4D, 0xAB4D, 0xAA4F, 0xAB4F, 0xAA4E,
+ 0xAB4E, 0xA94A, 0xA92B, 0xA94B, 0xAA57, 0xAB57, 0, 0,
+ 0xAA56, 0xAB56, 0xA92D, 0xA94D, 0xAA59, 0xAB59, 0xAA5B, 0xAB5B,
+ 0xAA5A, 0xAB5A, 0xAA5C, 0xAB5C, 0xAA5D, 0xAB5D, 0xAA5F, 0xAB5F,
+ 0xAA5E, 0xAB5E, 0xAA61, 0xAB61, 0xAA60, 0xAB60, 0xA92F, 0xA94F,
+ 0xAA6C, 0xAB6C, 0xAA69, 0xAB69, 0xAA66, 0xAB66, 0xAA6B, 0xAB6B,
+ 0xAA68, 0xAB68, 0xAA6A, 0xAB6A, 0xAA71, 0xAB71, 0xAA74, 0xAB74,
+ 0xAA73, 0xAA75, 0xAB75, 0xAA77, 0xAB77, 0xAA76, 0xAB76, 0,
+};
+static const unsigned short utf8_to_euc_C5_x0213[] = {
+ 0xA949, 0x2A23, 0x2A2E, 0x2A41, 0x2A51, 0xAA4F, 0xAB4F, 0x2A42,
+ 0x2A52, 0xA94A, 0xA92B, 0x2A7A, 0x2979, 0x297E, 0, 0,
+ 0x2A43, 0x2A53, 0x2B2B, 0x2B2A, 0x2A39, 0x2A48, 0xAA5B, 0xAB5B,
+ 0x2A44, 0x2A54, 0x2A25, 0x2A30, 0x2A5D, 0x2A63, 0x2A27, 0x2A33,
+ 0x2A26, 0x2A32, 0x2A47, 0x2A57, 0x2A28, 0x2A34, 0xA92F, 0xA94F,
+ 0xAA6C, 0xAB6C, 0x2977, 0x297C, 0x2A5E, 0x2A64, 0x2A45, 0x2A55,
+ 0x2A46, 0x2A56, 0xAA6A, 0xAB6A, 0xAA71, 0xAB71, 0xAA74, 0xAB74,
+ 0xAA73, 0x2A29, 0x2A35, 0x2A2B, 0x2A38, 0x2A2A, 0x2A37, 0,
+};
+static const unsigned short utf8_to_euc_C6_x0213[] = {
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0x2B29, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+};
+static const unsigned short utf8_to_euc_C7[] = {
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0xAA26, 0xAB26, 0xAA43,
+ 0xAB43, 0xAA55, 0xAB55, 0xAA67, 0xAB67, 0xAA70, 0xAB70, 0xAA6D,
+ 0xAB6D, 0xAA6F, 0xAB6F, 0xAA6E, 0xAB6E, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0xAB39, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+};
+static const unsigned short utf8_to_euc_C7_x0213[] = {
+ 0, 0, 0x2B24, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0x286F, 0x2870, 0xAA43,
+ 0x2871, 0x2876, 0x2877, 0xAA67, 0x2878, 0xAA70, 0x2879, 0xAA6D,
+ 0x287A, 0xAA6F, 0x287B, 0xAA6E, 0x287C, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0xAB39, 0, 0,
+ 0x2874, 0x2875, 0, 0, 0, 0x2B45, 0, 0,
+};
+static const unsigned short utf8_to_euc_C9_x0213[] = {
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0x2B33, 0x2B39, 0x2B3A, 0x2B25, 0x2B38, 0x2B3F, 0x2A6E, 0x2B26,
+ 0x2B2E, 0x2B30, 0x2B43, 0, 0x2B31, 0, 0x2B32, 0x2A75,
+ 0x2B28, 0x2A79, 0, 0, 0x2B36, 0x2B3C, 0x2B22, 0x2B42,
+ 0x2B2C, 0, 0, 0, 0x2A6A, 0x2A74, 0x2A6B, 0x2B34,
+ 0x2A7B, 0x2A65, 0x2A76, 0x2A6F, 0, 0x2B2F, 0, 0,
+ 0, 0x2A6C, 0x2B41, 0x2A73, 0, 0x2A70, 0x2A67, 0,
+};
+static const unsigned short utf8_to_euc_CA_x0213[] = {
+ 0, 0x2A7C, 0x2A71, 0x2A68, 0x2B27, 0, 0, 0,
+ 0x2A6D, 0x2B2D, 0x2B35, 0x2A66, 0x2B37, 0x2B3B, 0x2A78, 0,
+ 0x2A72, 0x2B40, 0x2A69, 0, 0x2B21, 0x2A7E, 0, 0,
+ 0x2B23, 0, 0, 0, 0, 0x2A77, 0, 0,
+ 0, 0x2B3E, 0x2B3D, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+};
+static const unsigned short utf8_to_euc_CB[] = {
+ 0, 0, 0, 0, 0, 0, 0, 0xA230,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0xA22F, 0xA232, 0xA236, 0xA235, 0, 0xA233, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+};
+static const unsigned short utf8_to_euc_CB_x0213[] = {
+ 0, 0, 0, 0, 0, 0, 0, 0x2A31,
+ 0x2B53, 0, 0, 0, 0x2B54, 0, 0, 0,
+ 0x2B55, 0x2B56, 0, 0, 0, 0, 0, 0,
+ 0x2A22, 0x2A58, 0xA236, 0x2A2D, 0, 0x2A36, 0x2B71, 0,
+ 0, 0, 0, 0, 0, 0x2B60, 0x2B61, 0x2B62,
+ 0x2B63, 0x2B64, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+};
+static const unsigned short utf8_to_euc_CC_x0213[] = {
+ 0x2B5C, 0x2B5A, 0x2B5F, 0x2B7D, 0x2B5B, 0, 0x2B57, 0,
+ 0x2B6D, 0, 0, 0x2B59, 0x2B5E, 0, 0, 0x2B5D,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0x2B78, 0x2B79, 0x2B7E, 0, 0x2B6A, 0x2B76, 0x2B77, 0x2B6B,
+ 0x2B6C, 0, 0, 0, 0x2B72, 0x2B67, 0, 0,
+ 0, 0x2B6F, 0x2B7A, 0, 0x2B68, 0, 0, 0x2B70,
+ 0x2B73, 0, 0, 0, 0x2B75, 0, 0, 0,
+ 0, 0x2B69, 0x2B7B, 0x2B7C, 0x2B74, 0x2B6E, 0, 0,
+};
+static const unsigned short utf8_to_euc_CD_x0213[] = {
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0x2B52, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+};
+static const unsigned short utf8_to_euc_CE[] = {
+ 0, 0, 0, 0, 0xA238, 0xA239, 0xA661, 0,
+ 0xA662, 0xA663, 0xA664, 0, 0xA667, 0, 0xA669, 0xA66C,
+ 0xA676, 0x2621, 0x2622, 0x2623, 0x2624, 0x2625, 0x2626, 0x2627,
+ 0x2628, 0x2629, 0x262A, 0x262B, 0x262C, 0x262D, 0x262E, 0x262F,
+ 0x2630, 0x2631, 0, 0x2632, 0x2633, 0x2634, 0x2635, 0x2636,
+ 0x2637, 0x2638, 0xA665, 0xA66A, 0xA671, 0xA672, 0xA673, 0xA674,
+ 0xA67B, 0x2641, 0x2642, 0x2643, 0x2644, 0x2645, 0x2646, 0x2647,
+ 0x2648, 0x2649, 0x264A, 0x264B, 0x264C, 0x264D, 0x264E, 0x264F,
+};
+static const unsigned short utf8_to_euc_CF[] = {
+ 0x2650, 0x2651, 0xA678, 0x2652, 0x2653, 0x2654, 0x2655, 0x2656,
+ 0x2657, 0x2658, 0xA675, 0xA67A, 0xA677, 0xA679, 0xA67C, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+};
+static const unsigned short utf8_to_euc_CF_x0213[] = {
+ 0x2650, 0x2651, 0x2659, 0x2652, 0x2653, 0x2654, 0x2655, 0x2656,
+ 0x2657, 0x2658, 0xA675, 0xA67A, 0xA677, 0xA679, 0xA67C, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+};
+static const unsigned short utf8_to_euc_D0[] = {
+ 0, 0x2727, 0xA742, 0xA743, 0xA744, 0xA745, 0xA746, 0xA747,
+ 0xA748, 0xA749, 0xA74A, 0xA74B, 0xA74C, 0, 0xA74D, 0xA74E,
+ 0x2721, 0x2722, 0x2723, 0x2724, 0x2725, 0x2726, 0x2728, 0x2729,
+ 0x272A, 0x272B, 0x272C, 0x272D, 0x272E, 0x272F, 0x2730, 0x2731,
+ 0x2732, 0x2733, 0x2734, 0x2735, 0x2736, 0x2737, 0x2738, 0x2739,
+ 0x273A, 0x273B, 0x273C, 0x273D, 0x273E, 0x273F, 0x2740, 0x2741,
+ 0x2751, 0x2752, 0x2753, 0x2754, 0x2755, 0x2756, 0x2758, 0x2759,
+ 0x275A, 0x275B, 0x275C, 0x275D, 0x275E, 0x275F, 0x2760, 0x2761,
+};
+static const unsigned short utf8_to_euc_D1[] = {
+ 0x2762, 0x2763, 0x2764, 0x2765, 0x2766, 0x2767, 0x2768, 0x2769,
+ 0x276A, 0x276B, 0x276C, 0x276D, 0x276E, 0x276F, 0x2770, 0x2771,
+ 0, 0x2757, 0xA772, 0xA773, 0xA774, 0xA775, 0xA776, 0xA777,
+ 0xA778, 0xA779, 0xA77A, 0xA77B, 0xA77C, 0, 0xA77D, 0xA77E,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+};
+static const unsigned short utf8_to_euc_E1B8_x0213[] = {
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0x2872, 0x2873,
+};
+static const unsigned short utf8_to_euc_E1BD_x0213[] = {
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0x2B46, 0x2B47, 0x2B50, 0x2B51, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+};
+static const unsigned short utf8_to_euc_E280[] = {
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0x213E, 0, 0, 0, 0x213D, 0x213D, 0x2142, 0,
+ 0x2146, 0x2147, 0, 0, 0x2148, 0x2149, 0, 0,
+ 0x2277, 0x2278, 0, 0, 0, 0x2145, 0x2144, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0x2273, 0, 0x216C, 0x216D, 0, 0, 0, 0,
+ 0, 0, 0, 0x2228, 0, 0, 0x2131, 0,
+};
+static const unsigned short utf8_to_euc_E280_ms[] = {
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0x213E, 0, 0, 0, 0x213D, 0x213D, 0x2142, 0,
+ 0x2146, 0x2147, 0, 0, 0x2148, 0x2149, 0, 0,
+ 0x2277, 0x2278, 0, 0, 0, 0x2145, 0x2144, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0x2273, 0, 0x216C, 0x216D, 0, 0, 0, 0,
+ 0, 0, 0, 0x2228, 0, 0, 0x7E, 0,
+};
+static const unsigned short utf8_to_euc_E280_932[] = {
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0x213E, 0, 0, 0, 0, 0x213D, 0, 0,
+ 0x2146, 0x2147, 0, 0, 0x2148, 0x2149, 0, 0,
+ 0x2277, 0x2278, 0, 0, 0, 0x2145, 0x2144, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0x2273, 0, 0x216C, 0x216D, 0, 0, 0, 0,
+ 0, 0, 0, 0x2228, 0, 0, 0, 0,
+};
+static const unsigned short utf8_to_euc_E280_x0213[] = {
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0x213E, 0, 0, 0x237C, 0x213D, 0x213D, 0x2142, 0,
+ 0x2146, 0x2147, 0, 0, 0x2148, 0x2149, 0, 0,
+ 0x2277, 0x2278, 0x2340, 0, 0, 0x2145, 0x2144, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0x2273, 0, 0x216C, 0x216D, 0, 0, 0, 0,
+ 0, 0, 0, 0x2228, 0x286B, 0, 0x2131, 0x2B58,
+};
+static const unsigned short utf8_to_euc_E281_x0213[] = {
+ 0, 0, 0x2C7E, 0, 0, 0, 0, 0x286C,
+ 0x286D, 0x286E, 0, 0, 0, 0, 0, 0,
+ 0, 0x2C7D, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+};
+static const unsigned short utf8_to_euc_E282_x0213[] = {
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0x2921, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+};
+static const unsigned short utf8_to_euc_E284[] = {
+ 0, 0, 0, 0x216E, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0x2D62, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0x2D64, 0xA26F, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0x2272, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+};
+static const unsigned short utf8_to_euc_E284_mac[] = {
+ 0, 0, 0, 0x216E, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0x2B7B, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0x2B7D, 0x00FE, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0x2272, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+};
+static const unsigned short utf8_to_euc_E284_x0213[] = {
+ 0, 0, 0, 0x216E, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0x235D,
+ 0, 0, 0, 0x235F, 0, 0, 0x2D62, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0x2D64, 0xA26F, 0, 0, 0, 0, 0x2360,
+ 0, 0, 0, 0x2272, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0x235C, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+};
+static const unsigned short utf8_to_euc_E285[] = {
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0x2D35, 0x2D36, 0x2D37, 0x2D38, 0x2D39, 0x2D3A, 0x2D3B, 0x2D3C,
+ 0x2D3D, 0x2D3E, 0, 0, 0, 0, 0, 0,
+ 0xF373, 0xF374, 0xF375, 0xF376, 0xF377, 0xF378, 0xF379, 0xF37A,
+ 0xF37B, 0xF37C, 0, 0, 0, 0, 0, 0,
+};
+static const unsigned short utf8_to_euc_E285_mac[] = {
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0x2A21, 0x2A22, 0x2A23, 0x2A24, 0x2A25, 0x2A26, 0x2A27, 0x2A28,
+ 0x2A29, 0x2A2A, 0, 0, 0, 0, 0, 0,
+ 0x2A35, 0x2A36, 0x2A37, 0x2A38, 0x2A39, 0x2A3A, 0x2A3B, 0x2A3C,
+ 0x2A3D, 0x2A3E, 0, 0, 0, 0, 0, 0,
+};
+static const unsigned short utf8_to_euc_E285_x0213[] = {
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0x2778, 0x2779, 0x277A, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0x2D35, 0x2D36, 0x2D37, 0x2D38, 0x2D39, 0x2D3A, 0x2D3B, 0x2D3C,
+ 0x2D3D, 0x2D3E, 0x2D3F, 0x2D57, 0, 0, 0, 0,
+ 0x2C35, 0x2C36, 0x2C37, 0x2C38, 0x2C39, 0x2C3A, 0x2C3B, 0x2C3C,
+ 0x2C3D, 0x2C3E, 0x2C3F, 0x2C40, 0, 0, 0, 0,
+};
+static const unsigned short utf8_to_euc_E286[] = {
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0x222B, 0x222C, 0x222A, 0x222D, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+};
+static const unsigned short utf8_to_euc_E286_x0213[] = {
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0x222B, 0x222C, 0x222A, 0x222D, 0x2271, 0, 0x2327, 0x2325,
+ 0x2326, 0x2328, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+};
+static const unsigned short utf8_to_euc_E287[] = {
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0x224D, 0, 0x224E, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+};
+static const unsigned short utf8_to_euc_E287_x0213[] = {
+ 0, 0, 0, 0, 0x2329, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0x224D, 0, 0x224E, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0x232B, 0x232C,
+ 0x232A, 0x232D, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+};
+static const unsigned short utf8_to_euc_E288[] = {
+ 0x224F, 0, 0x225F, 0x2250, 0, 0, 0, 0x2260,
+ 0x223A, 0, 0, 0x223B, 0, 0, 0, 0,
+ 0, 0x2D74, 0x215D, 0, 0, 0, 0, 0,
+ 0, 0, 0x2265, 0, 0, 0x2267, 0x2167, 0x2D78,
+ 0x225C, 0, 0, 0, 0, 0x2142, 0, 0x224A,
+ 0x224B, 0x2241, 0x2240, 0x2269, 0x226A, 0, 0x2D73, 0,
+ 0, 0, 0, 0, 0x2168, 0x2268, 0, 0,
+ 0, 0, 0, 0, 0, 0x2266, 0, 0,
+};
+static const unsigned short utf8_to_euc_E288_932[] = {
+ 0x224F, 0, 0x225F, 0x2250, 0, 0, 0, 0x2260,
+ 0x223A, 0, 0, 0x223B, 0, 0, 0, 0,
+ 0, 0x2D74, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0x2265, 0, 0, 0x2267, 0x2167, 0x2D78,
+ 0x225C, 0, 0, 0, 0, 0x2142, 0, 0x224A,
+ 0x224B, 0x2241, 0x2240, 0x2269, 0x226A, 0, 0x2D73, 0,
+ 0, 0, 0, 0, 0x2168, 0x2268, 0, 0,
+ 0, 0, 0, 0, 0, 0x2266, 0, 0,
+};
+static const unsigned short utf8_to_euc_E288_mac[] = {
+ 0x224F, 0, 0x225F, 0x2250, 0, 0, 0, 0x2260,
+ 0x223A, 0, 0, 0x223B, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0x2265, 0, 0, 0x2267, 0x2167, 0x2F22,
+ 0x225C, 0, 0, 0, 0, 0x2142, 0, 0x224A,
+ 0x224B, 0x2241, 0x2240, 0x2269, 0x226A, 0, 0x2F21, 0,
+ 0, 0, 0, 0, 0x2168, 0x2268, 0, 0,
+ 0, 0, 0, 0, 0, 0x2266, 0, 0,
+};
+static const unsigned short utf8_to_euc_E288_x0213[] = {
+ 0x224F, 0, 0x225F, 0x2250, 0, 0x2247, 0, 0x2260,
+ 0x223A, 0x2246, 0, 0x223B, 0, 0, 0, 0,
+ 0, 0x2D74, 0x215D, 0x235B, 0, 0, 0, 0,
+ 0, 0, 0x2265, 0, 0, 0x2267, 0x2167, 0x2D78,
+ 0x225C, 0, 0, 0, 0, 0x2254, 0x2255, 0x224A,
+ 0x224B, 0x2241, 0x2240, 0x2269, 0x226A, 0, 0x2D73, 0,
+ 0, 0, 0, 0, 0x2168, 0x2268, 0, 0,
+ 0, 0, 0, 0, 0, 0x2266, 0, 0,
+};
+static const unsigned short utf8_to_euc_E289[] = {
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0x2262, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0x2162, 0x2261, 0, 0, 0, 0, 0x2165, 0x2166,
+ 0, 0, 0x2263, 0x2264, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+};
+static const unsigned short utf8_to_euc_E289_x0213[] = {
+ 0, 0, 0, 0x226C, 0, 0x226D, 0, 0,
+ 0x226E, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0x2262, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0x2162, 0x2261, 0x226B, 0, 0, 0, 0x2165, 0x2166,
+ 0, 0, 0x2263, 0x2264, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0x226F, 0x2270,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+};
+static const unsigned short utf8_to_euc_E28A[] = {
+ 0, 0, 0x223E, 0x223F, 0, 0, 0x223C, 0x223D,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0x225D, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0x2D79,
+};
+static const unsigned short utf8_to_euc_E28A_mac[] = {
+ 0, 0, 0x223E, 0x223F, 0, 0, 0x223C, 0x223D,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0x225D, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0x2F23,
+};
+static const unsigned short utf8_to_euc_E28A_x0213[] = {
+ 0, 0, 0x223E, 0x223F, 0x2242, 0x2243, 0x223C, 0x223D,
+ 0, 0, 0x2244, 0x2245, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0x2251, 0x2252, 0x2253,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0x225D, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0x2D79,
+};
+static const unsigned short utf8_to_euc_E28B_x0213[] = {
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0x2776, 0x2777, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+};
+static const unsigned short utf8_to_euc_E28C[] = {
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0x225E, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+};
+static const unsigned short utf8_to_euc_E28C_x0213[] = {
+ 0, 0, 0, 0, 0, 0x2248, 0x2249, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0x225E, 0, 0, 0, 0, 0,
+ 0x277C, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+};
+static const unsigned short utf8_to_euc_E28E_x0213[] = {
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0x2742, 0x2743,
+};
+static const unsigned short utf8_to_euc_E28F_x0213[] = {
+ 0x2744, 0x2745, 0x2746, 0x2747, 0x2748, 0x2749, 0x274A, 0x274B,
+ 0x274C, 0x274D, 0x274E, 0x274F, 0x2750, 0, 0x277E, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+};
+static const unsigned short utf8_to_euc_E290_x0213[] = {
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0x277D, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+};
+static const unsigned short utf8_to_euc_E291[] = {
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0x2D21, 0x2D22, 0x2D23, 0x2D24, 0x2D25, 0x2D26, 0x2D27, 0x2D28,
+ 0x2D29, 0x2D2A, 0x2D2B, 0x2D2C, 0x2D2D, 0x2D2E, 0x2D2F, 0x2D30,
+ 0x2D31, 0x2D32, 0x2D33, 0x2D34, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+};
+static const unsigned short utf8_to_euc_E291_mac[] = {
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0x2921, 0x2922, 0x2923, 0x2924, 0x2925, 0x2926, 0x2927, 0x2928,
+ 0x2929, 0x292A, 0x292B, 0x292C, 0x292D, 0x292E, 0x292F, 0x2930,
+ 0x2931, 0x2932, 0x2933, 0x2934, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+};
+static const unsigned short utf8_to_euc_E293_x0213[] = {
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0x2C41, 0x2C42, 0x2C43, 0x2C44, 0x2C45, 0x2C46, 0x2C47, 0x2C48,
+ 0x2C49, 0x2C4A, 0x2C4B, 0x2C4C, 0x2C4D, 0x2C4E, 0x2C4F, 0x2C50,
+ 0x2C51, 0x2C52, 0x2C53, 0x2C54, 0x2C55, 0x2C56, 0x2C57, 0x2C58,
+ 0x2C59, 0x2C5A, 0, 0x2C2B, 0x2C2C, 0x2C2D, 0x2C2E, 0x2C2F,
+ 0x2C30, 0x2C31, 0x2C32, 0x2C33, 0x2C34, 0x265A, 0x265B, 0x265C,
+ 0x265D, 0x265E, 0x265F, 0x2660, 0x2661, 0x2662, 0x2663, 0,
+};
+static const unsigned short utf8_to_euc_E294[] = {
+ 0x2821, 0x282C, 0x2822, 0x282D, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0x2823, 0, 0, 0x282E,
+ 0x2824, 0, 0, 0x282F, 0x2826, 0, 0, 0x2831,
+ 0x2825, 0, 0, 0x2830, 0x2827, 0x283C, 0, 0,
+ 0x2837, 0, 0, 0x2832, 0x2829, 0x283E, 0, 0,
+ 0x2839, 0, 0, 0x2834, 0x2828, 0, 0, 0x2838,
+ 0x283D, 0, 0, 0x2833, 0x282A, 0, 0, 0x283A,
+ 0x283F, 0, 0, 0x2835, 0x282B, 0, 0, 0x283B,
+};
+static const unsigned short utf8_to_euc_E295[] = {
+ 0, 0, 0x2840, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0x2836, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+};
+static const unsigned short utf8_to_euc_E296[] = {
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0x2223, 0x2222, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0x2225, 0x2224, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0x2227, 0x2226, 0, 0,
+};
+static const unsigned short utf8_to_euc_E296_x0213[] = {
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0x2223, 0x2222, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0x266D, 0x2225, 0x2224, 0, 0, 0x2322, 0x2321,
+ 0, 0, 0, 0, 0x2227, 0x2226, 0, 0,
+};
+static const unsigned short utf8_to_euc_E297[] = {
+ 0, 0, 0, 0, 0, 0, 0x2221, 0x217E,
+ 0, 0, 0, 0x217B, 0, 0, 0x217D, 0x217C,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0x227E,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+};
+static const unsigned short utf8_to_euc_E297_x0213[] = {
+ 0x2324, 0x2323, 0, 0, 0, 0, 0x2221, 0x217E,
+ 0, 0x233B, 0, 0x217B, 0, 0, 0x217D, 0x217C,
+ 0x2867, 0x2868, 0x2869, 0x286A, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0x233F, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0x227E,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+};
+static const unsigned short utf8_to_euc_E298[] = {
+ 0, 0, 0, 0, 0, 0x217A, 0x2179, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+};
+static const unsigned short utf8_to_euc_E298_x0213[] = {
+ 0x2668, 0x2669, 0x266A, 0x266B, 0, 0x217A, 0x2179, 0,
+ 0, 0, 0, 0, 0, 0, 0x2667, 0,
+ 0, 0, 0, 0, 0, 0, 0x2664, 0x2665,
+ 0, 0, 0, 0, 0, 0, 0x2D7E, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+};
+static const unsigned short utf8_to_euc_E299[] = {
+ 0x216A, 0, 0x2169, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0x2276, 0, 0, 0x2275, 0, 0x2274,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+};
+static const unsigned short utf8_to_euc_E299_x0213[] = {
+ 0x216A, 0, 0x2169, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0x263A, 0x263D, 0x263B, 0x2640, 0x2639, 0x263E, 0x263C, 0x263F,
+ 0x266C, 0x227D, 0x2276, 0x227B, 0x227C, 0x2275, 0x227A, 0x2274,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+};
+static const unsigned short utf8_to_euc_E29C_x0213[] = {
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0x277B, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+};
+static const unsigned short utf8_to_euc_E29D_x0213[] = {
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0x2D7D, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0x2C21, 0x2C22,
+ 0x2C23, 0x2C24, 0x2C25, 0x2C26, 0x2C27, 0x2C28, 0x2C29, 0x2C2A,
+};
+static const unsigned short utf8_to_euc_E2A4_x0213[] = {
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0x232E, 0x232F, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+};
+static const unsigned short utf8_to_euc_E2A6_x0213[] = {
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0x233A,
+};
+static const unsigned short utf8_to_euc_E2A7_x0213[] = {
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0x237D, 0x237E, 0, 0, 0, 0,
+};
+static const unsigned short utf8_to_euc_E380[] = {
+ 0x2121, 0x2122, 0x2123, 0x2137, 0, 0x2139, 0x213A, 0x213B,
+ 0x2152, 0x2153, 0x2154, 0x2155, 0x2156, 0x2157, 0x2158, 0x2159,
+ 0x215A, 0x215B, 0x2229, 0x222E, 0x214C, 0x214D, 0, 0,
+ 0, 0, 0, 0, 0x2141, 0x2D60, 0, 0x2D61,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+};
+static const unsigned short utf8_to_euc_E380_932[] = {
+ 0x2121, 0x2122, 0x2123, 0x2137, 0, 0x2139, 0x213A, 0x213B,
+ 0x2152, 0x2153, 0x2154, 0x2155, 0x2156, 0x2157, 0x2158, 0x2159,
+ 0x215A, 0x215B, 0x2229, 0x222E, 0x214C, 0x214D, 0, 0,
+ 0, 0, 0, 0, 0, 0x2D60, 0, 0x2D61,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+};
+static const unsigned short utf8_to_euc_E380_x0213[] = {
+ 0x2121, 0x2122, 0x2123, 0x2137, 0, 0x2139, 0x213A, 0x213B,
+ 0x2152, 0x2153, 0x2154, 0x2155, 0x2156, 0x2157, 0x2158, 0x2159,
+ 0x215A, 0x215B, 0x2229, 0x222E, 0x214C, 0x214D, 0x225A, 0x225B,
+ 0x2258, 0x2259, 0, 0, 0x2141, 0x2D60, 0, 0x2D61,
+ 0x2666, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0x2233, 0x2234, 0x2235, 0, 0,
+ 0, 0, 0, 0x2236, 0x2237, 0x233C, 0, 0,
+};
+static const unsigned short utf8_to_euc_E381[] = {
+ 0, 0x2421, 0x2422, 0x2423, 0x2424, 0x2425, 0x2426, 0x2427,
+ 0x2428, 0x2429, 0x242A, 0x242B, 0x242C, 0x242D, 0x242E, 0x242F,
+ 0x2430, 0x2431, 0x2432, 0x2433, 0x2434, 0x2435, 0x2436, 0x2437,
+ 0x2438, 0x2439, 0x243A, 0x243B, 0x243C, 0x243D, 0x243E, 0x243F,
+ 0x2440, 0x2441, 0x2442, 0x2443, 0x2444, 0x2445, 0x2446, 0x2447,
+ 0x2448, 0x2449, 0x244A, 0x244B, 0x244C, 0x244D, 0x244E, 0x244F,
+ 0x2450, 0x2451, 0x2452, 0x2453, 0x2454, 0x2455, 0x2456, 0x2457,
+ 0x2458, 0x2459, 0x245A, 0x245B, 0x245C, 0x245D, 0x245E, 0x245F,
+};
+static const unsigned short utf8_to_euc_E382[] = {
+ 0x2460, 0x2461, 0x2462, 0x2463, 0x2464, 0x2465, 0x2466, 0x2467,
+ 0x2468, 0x2469, 0x246A, 0x246B, 0x246C, 0x246D, 0x246E, 0x246F,
+ 0x2470, 0x2471, 0x2472, 0x2473, 0, 0, 0, 0,
+ 0, 0, 0, 0x212B, 0x212C, 0x2135, 0x2136, 0,
+ 0, 0x2521, 0x2522, 0x2523, 0x2524, 0x2525, 0x2526, 0x2527,
+ 0x2528, 0x2529, 0x252A, 0x252B, 0x252C, 0x252D, 0x252E, 0x252F,
+ 0x2530, 0x2531, 0x2532, 0x2533, 0x2534, 0x2535, 0x2536, 0x2537,
+ 0x2538, 0x2539, 0x253A, 0x253B, 0x253C, 0x253D, 0x253E, 0x253F,
+};
+static const unsigned short utf8_to_euc_E382_932[] = {
+ 0x2460, 0x2461, 0x2462, 0x2463, 0x2464, 0x2465, 0x2466, 0x2467,
+ 0x2468, 0x2469, 0x246A, 0x246B, 0x246C, 0x246D, 0x246E, 0x246F,
+ 0x2470, 0x2471, 0x2472, 0x2473, 0x2574, 0, 0, 0,
+ 0, 0, 0, 0x212B, 0x212C, 0x2135, 0x2136, 0,
+ 0, 0x2521, 0x2522, 0x2523, 0x2524, 0x2525, 0x2526, 0x2527,
+ 0x2528, 0x2529, 0x252A, 0x252B, 0x252C, 0x252D, 0x252E, 0x252F,
+ 0x2530, 0x2531, 0x2532, 0x2533, 0x2534, 0x2535, 0x2536, 0x2537,
+ 0x2538, 0x2539, 0x253A, 0x253B, 0x253C, 0x253D, 0x253E, 0x253F,
+};
+static const unsigned short utf8_to_euc_E382_x0213[] = {
+ 0x2460, 0x2461, 0x2462, 0x2463, 0x2464, 0x2465, 0x2466, 0x2467,
+ 0x2468, 0x2469, 0x246A, 0x246B, 0x246C, 0x246D, 0x246E, 0x246F,
+ 0x2470, 0x2471, 0x2472, 0x2473, 0x2474, 0x2475, 0x2476, 0,
+ 0, 0, 0, 0x212B, 0x212C, 0x2135, 0x2136, 0x2239,
+ 0x237B, 0x2521, 0x2522, 0x2523, 0x2524, 0x2525, 0x2526, 0x2527,
+ 0x2528, 0x2529, 0x252A, 0x252B, 0x252C, 0x252D, 0x252E, 0x252F,
+ 0x2530, 0x2531, 0x2532, 0x2533, 0x2534, 0x2535, 0x2536, 0x2537,
+ 0x2538, 0x2539, 0x253A, 0x253B, 0x253C, 0x253D, 0x253E, 0x253F,
+};
+static const unsigned short utf8_to_euc_E383[] = {
+ 0x2540, 0x2541, 0x2542, 0x2543, 0x2544, 0x2545, 0x2546, 0x2547,
+ 0x2548, 0x2549, 0x254A, 0x254B, 0x254C, 0x254D, 0x254E, 0x254F,
+ 0x2550, 0x2551, 0x2552, 0x2553, 0x2554, 0x2555, 0x2556, 0x2557,
+ 0x2558, 0x2559, 0x255A, 0x255B, 0x255C, 0x255D, 0x255E, 0x255F,
+ 0x2560, 0x2561, 0x2562, 0x2563, 0x2564, 0x2565, 0x2566, 0x2567,
+ 0x2568, 0x2569, 0x256A, 0x256B, 0x256C, 0x256D, 0x256E, 0x256F,
+ 0x2570, 0x2571, 0x2572, 0x2573, 0x2574, 0x2575, 0x2576, 0,
+ 0, 0, 0, 0x2126, 0x213C, 0x2133, 0x2134, 0,
+};
+static const unsigned short utf8_to_euc_E383_x0213[] = {
+ 0x2540, 0x2541, 0x2542, 0x2543, 0x2544, 0x2545, 0x2546, 0x2547,
+ 0x2548, 0x2549, 0x254A, 0x254B, 0x254C, 0x254D, 0x254E, 0x254F,
+ 0x2550, 0x2551, 0x2552, 0x2553, 0x2554, 0x2555, 0x2556, 0x2557,
+ 0x2558, 0x2559, 0x255A, 0x255B, 0x255C, 0x255D, 0x255E, 0x255F,
+ 0x2560, 0x2561, 0x2562, 0x2563, 0x2564, 0x2565, 0x2566, 0x2567,
+ 0x2568, 0x2569, 0x256A, 0x256B, 0x256C, 0x256D, 0x256E, 0x256F,
+ 0x2570, 0x2571, 0x2572, 0x2573, 0x2574, 0x2575, 0x2576, 0x2772,
+ 0x2773, 0x2774, 0x2775, 0x2126, 0x213C, 0x2133, 0x2134, 0x2238,
+};
+static const unsigned short utf8_to_euc_E387_x0213[] = {
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0x266E, 0x266F, 0x2670, 0x2671, 0x2672, 0x2673, 0x2674, 0x2675,
+ 0x2676, 0x2677, 0x2679, 0x267A, 0x267B, 0x267C, 0x267D, 0x267E,
+};
+static const unsigned short utf8_to_euc_E388[] = {
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0x2D6A, 0x2D6B, 0, 0, 0, 0, 0,
+ 0, 0x2D6C, 0, 0, 0, 0, 0, 0,
+};
+static const unsigned short utf8_to_euc_E388_mac[] = {
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0x2D2E, 0x2D31, 0, 0, 0, 0, 0,
+ 0, 0x2D2C, 0, 0, 0, 0, 0, 0,
+};
+static const unsigned short utf8_to_euc_E389_x0213[] = {
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0x2841, 0x2842, 0x2843, 0x2844, 0x2845, 0x2846, 0x2847,
+ 0x2848, 0x2849, 0x284A, 0x284B, 0x284C, 0x284D, 0x284E, 0x284F,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+};
+static const unsigned short utf8_to_euc_E38A[] = {
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0x2D65, 0x2D66, 0x2D67, 0x2D68,
+ 0x2D69, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+};
+static const unsigned short utf8_to_euc_E38A_mac[] = {
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0x2D73, 0x2D74, 0x2D75, 0x2D76,
+ 0x2D77, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+};
+static const unsigned short utf8_to_euc_E38A_x0213[] = {
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0x2D65, 0x2D66, 0x2D67, 0x2D68,
+ 0x2D69, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0x2850, 0x2851, 0x2852, 0x2853, 0x2854, 0x2855, 0x2856,
+ 0x2857, 0x2858, 0x2859, 0x285A, 0x285B, 0x285C, 0x285D, 0x285E,
+};
+static const unsigned short utf8_to_euc_E38B_x0213[] = {
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0x2C5B, 0x2C5C, 0x2C5D, 0x2C5E, 0x2C5F, 0x2C60, 0x2C61, 0x2C62,
+ 0x2C63, 0x2C64, 0x2C65, 0x2C66, 0x2C67, 0x2C68, 0x2C69, 0x2C6A,
+ 0x2C6B, 0x2C6C, 0x2C6D, 0x2C6E, 0, 0x2C71, 0, 0,
+ 0, 0x2C70, 0, 0, 0x2C73, 0x2C72, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0x2C6F, 0, 0, 0, 0, 0,
+};
+static const unsigned short utf8_to_euc_E38C[] = {
+ 0, 0, 0, 0x2D46, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0x2D4A, 0, 0,
+ 0, 0, 0, 0, 0x2D41, 0, 0, 0,
+ 0x2D44, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0x2D42, 0x2D4C, 0, 0, 0x2D4B, 0x2D45,
+ 0, 0, 0, 0x2D4D, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0x2D47, 0,
+ 0, 0, 0, 0x2D4F, 0, 0, 0, 0,
+};
+static const unsigned short utf8_to_euc_E38C_mac[] = {
+ 0, 0, 0, 0x2E29, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0x2E32, 0, 0,
+ 0, 0, 0, 0, 0x2E24, 0, 0, 0,
+ 0x2E2B, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0x2E22, 0x2E34, 0, 0, 0x2E35, 0x2E2D,
+ 0, 0, 0, 0x2E37, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0x2E2A, 0,
+ 0, 0, 0, 0x2E36, 0, 0, 0, 0,
+};
+static const unsigned short utf8_to_euc_E38D[] = {
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0x2D40, 0x2D4E, 0, 0, 0x2D43, 0, 0,
+ 0, 0x2D48, 0, 0, 0, 0, 0, 0x2D49,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0x2D5F, 0x2D6F, 0x2D6E, 0x2D6D, 0,
+};
+static const unsigned short utf8_to_euc_E38D_mac[] = {
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0x2E21, 0x2E2F, 0, 0, 0x2E23, 0, 0,
+ 0, 0x2E2E, 0, 0, 0, 0, 0, 0x2E31,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0x2E6A, 0x2E69, 0x2E68, 0x2E67, 0,
+};
+static const unsigned short utf8_to_euc_E38E[] = {
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0x2D53, 0x2D54,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0x2D50, 0x2D51, 0x2D52, 0,
+ 0, 0x2D56, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+};
+static const unsigned short utf8_to_euc_E38E_mac[] = {
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0x2B2B, 0x2B2D,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0x2B21, 0x2B23, 0x2B29, 0,
+ 0, 0x2B27, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+};
+static const unsigned short utf8_to_euc_E38F[] = {
+ 0, 0, 0, 0, 0x2D55, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0x2D63, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+};
+static const unsigned short utf8_to_euc_E38F_mac[] = {
+ 0, 0, 0, 0, 0x2B2E, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0x2B7C, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+};
+static const unsigned short utf8_to_euc_E38F_x0213[] = {
+ 0, 0, 0, 0, 0x2D55, 0, 0, 0,
+ 0, 0, 0, 0x235E, 0, 0x2D63, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+};
+static const unsigned short utf8_to_euc_E390_x0213[] = {
+ 0, 0, 0x2E23, 0, 0, 0, 0xA12D, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0xA132, 0, 0xA133, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+};
+static const unsigned short utf8_to_euc_E391_x0213[] = {
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0xA15E, 0, 0xA156, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+};
+static const unsigned short utf8_to_euc_E392_x0213[] = {
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0xA17E, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0x2E53, 0, 0,
+ 0, 0, 0, 0, 0xA32B, 0, 0, 0,
+};
+static const unsigned short utf8_to_euc_E393_x0213[] = {
+ 0, 0xF468, 0, 0, 0, 0, 0, 0xA32F,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0x2E5B, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+};
+static const unsigned short utf8_to_euc_E394_x0213[] = {
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0xA348,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+};
+static const unsigned short utf8_to_euc_E395_x0213[] = {
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0xA35D, 0xA35E, 0,
+ 0, 0, 0, 0xA361, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0xA367, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+};
+static const unsigned short utf8_to_euc_E396_x0213[] = {
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0xA423, 0,
+ 0xA426, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+};
+static const unsigned short utf8_to_euc_E397_x0213[] = {
+ 0, 0, 0, 0, 0, 0xA42F, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0xA438, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0xA442, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+};
+static const unsigned short utf8_to_euc_E398_x0213[] = {
+ 0, 0, 0, 0, 0, 0xA44A, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+};
+static const unsigned short utf8_to_euc_E399_x0213[] = {
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0xA479, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+};
+static const unsigned short utf8_to_euc_E39A_x0213[] = {
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0xA53F, 0, 0, 0, 0, 0xA543, 0,
+ 0, 0xA541, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+};
+static const unsigned short utf8_to_euc_E39B_x0213[] = {
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0xA557,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+};
+static const unsigned short utf8_to_euc_E39D_x0213[] = {
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0xA823, 0xA825, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0xA829, 0xA828, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0xA82C, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+};
+static const unsigned short utf8_to_euc_E39E_x0213[] = {
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0x4F5F, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+};
+static const unsigned short utf8_to_euc_E39F_x0213[] = {
+ 0, 0xA83E, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0x4F6F, 0, 0, 0, 0, 0,
+ 0xA856, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0xA859, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0xA85C, 0, 0,
+};
+static const unsigned short utf8_to_euc_E3A0_x0213[] = {
+ 0xA85E, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0xA86F,
+ 0, 0, 0, 0, 0, 0, 0xA871, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+};
+static const unsigned short utf8_to_euc_E3A1_x0213[] = {
+ 0xA874, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0xA879, 0, 0, 0,
+ 0, 0xA87B, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+};
+static const unsigned short utf8_to_euc_E3A3_x0213[] = {
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0xAC3B, 0, 0, 0, 0, 0,
+};
+static const unsigned short utf8_to_euc_E3A4_x0213[] = {
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0xAC46,
+ 0, 0, 0xAC4A, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+};
+static const unsigned short utf8_to_euc_E3A5_x0213[] = {
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0xAC60,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+};
+static const unsigned short utf8_to_euc_E3A9_x0213[] = {
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0xAD5B, 0,
+ 0, 0, 0, 0xAD5F, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+};
+static const unsigned short utf8_to_euc_E3AB_x0213[] = {
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0xAD71, 0xAE36,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0xAD7C, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+};
+static const unsigned short utf8_to_euc_E3AC_x0213[] = {
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0xAE2E, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0xAE32, 0, 0xAE34, 0, 0, 0,
+ 0, 0, 0x7549, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+};
+static const unsigned short utf8_to_euc_E3AD_x0213[] = {
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0xAE6D, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0xAE65,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+};
+static const unsigned short utf8_to_euc_E3AE_x0213[] = {
+ 0, 0, 0, 0, 0, 0, 0, 0xAF28,
+ 0xAF29, 0, 0, 0, 0, 0xAF2C, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0xAF34, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0x757E, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+};
+static const unsigned short utf8_to_euc_E3AF_x0213[] = {
+ 0, 0, 0, 0x7621, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0xAF48, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0xAF5D, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+};
+static const unsigned short utf8_to_euc_E3B0_x0213[] = {
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0x763A,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0xAF77, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+};
+static const unsigned short utf8_to_euc_E3B3_x0213[] = {
+ 0, 0, 0, 0xEE3B, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0xEE42, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+};
+static const unsigned short utf8_to_euc_E3B4_x0213[] = {
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0xEE71, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0xEE7E, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+};
+static const unsigned short utf8_to_euc_E3B5_x0213[] = {
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0xEF40, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+};
+static const unsigned short utf8_to_euc_E3B6_x0213[] = {
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0xEF54, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+};
+static const unsigned short utf8_to_euc_E3B7_x0213[] = {
+ 0xEF70, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0xEF77, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+};
+static const unsigned short utf8_to_euc_E3B8_x0213[] = {
+ 0, 0, 0, 0, 0, 0xF028, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0x7766,
+};
+static const unsigned short utf8_to_euc_E3B9_x0213[] = {
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0xF03F, 0, 0, 0, 0, 0, 0xF041, 0,
+ 0xF042, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+};
+static const unsigned short utf8_to_euc_E3BA_x0213[] = {
+ 0, 0, 0, 0xF049, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0xF050, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+};
+static const unsigned short utf8_to_euc_E3BD_x0213[] = {
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0xF134,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0x784D, 0, 0, 0xF146, 0, 0xF148,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+};
+static const unsigned short utf8_to_euc_E3BE_x0213[] = {
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0xF15C, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+};
+static const unsigned short utf8_to_euc_E3BF_x0213[] = {
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0xF167, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0xF16C,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+};
+static const unsigned short utf8_to_euc_E480_x0213[] = {
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0xF222, 0, 0, 0, 0, 0, 0,
+};
+static const unsigned short utf8_to_euc_E481_x0213[] = {
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0xF22D, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+};
+static const unsigned short utf8_to_euc_E482_x0213[] = {
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0xF239, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+};
+static const unsigned short utf8_to_euc_E484_x0213[] = {
+ 0, 0, 0, 0, 0, 0xF264, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+};
+static const unsigned short utf8_to_euc_E485_x0213[] = {
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0xF274, 0, 0, 0, 0, 0, 0, 0xF277,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0xF27D, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+};
+static const unsigned short utf8_to_euc_E486_x0213[] = {
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0xF333, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0xF337,
+};
+static const unsigned short utf8_to_euc_E487_x0213[] = {
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0xF347, 0,
+ 0, 0, 0, 0, 0, 0, 0xF34B, 0,
+ 0, 0, 0, 0xF348, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+};
+static const unsigned short utf8_to_euc_E488_x0213[] = {
+ 0, 0, 0, 0, 0, 0, 0, 0xF353,
+ 0, 0, 0, 0, 0, 0, 0xF357, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+};
+static const unsigned short utf8_to_euc_E489_x0213[] = {
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0x796D, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+};
+static const unsigned short utf8_to_euc_E48B_x0213[] = {
+ 0, 0, 0, 0, 0, 0, 0xF42B, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0xF436, 0,
+ 0, 0, 0, 0, 0, 0xF43B, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+};
+static const unsigned short utf8_to_euc_E48C_x0213[] = {
+ 0, 0, 0xF44E, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0xF45D, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+};
+static const unsigned short utf8_to_euc_E48D_x0213[] = {
+ 0, 0, 0, 0xF461, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+};
+static const unsigned short utf8_to_euc_E48F_x0213[] = {
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0xF53E, 0,
+ 0xF542, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+};
+static const unsigned short utf8_to_euc_E490_x0213[] = {
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0xF548, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0xF54A,
+ 0, 0, 0, 0, 0xF54C, 0, 0, 0,
+ 0, 0, 0xF54F, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+};
+static const unsigned short utf8_to_euc_E491_x0213[] = {
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0x7A59, 0, 0, 0, 0,
+ 0, 0, 0, 0x7A5A, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0xF56C, 0,
+ 0, 0, 0xF56E, 0, 0, 0, 0, 0,
+};
+static const unsigned short utf8_to_euc_E492_x0213[] = {
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0xF577, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0xF635, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0xF632, 0,
+};
+static const unsigned short utf8_to_euc_E493_x0213[] = {
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0xF634, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+};
+static const unsigned short utf8_to_euc_E494_x0213[] = {
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0xF659, 0, 0, 0, 0, 0xF654, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0xF66D, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+};
+static const unsigned short utf8_to_euc_E495_x0213[] = {
+ 0, 0, 0, 0xF66E, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+};
+static const unsigned short utf8_to_euc_E496_x0213[] = {
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0x7B51, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0xF74F, 0, 0, 0, 0, 0, 0, 0,
+};
+static const unsigned short utf8_to_euc_E497_x0213[] = {
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0xF76C, 0, 0,
+ 0, 0, 0x7B60, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+};
+static const unsigned short utf8_to_euc_E498_x0213[] = {
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0xF824,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+};
+static const unsigned short utf8_to_euc_E499_x0213[] = {
+ 0, 0xF83A, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0xF843, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+};
+static const unsigned short utf8_to_euc_E49A_x0213[] = {
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0xF84E, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0xF853,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+};
+static const unsigned short utf8_to_euc_E49C_x0213[] = {
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0xF86B, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+};
+static const unsigned short utf8_to_euc_E49D_x0213[] = {
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0xF929, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+};
+static const unsigned short utf8_to_euc_E49F_x0213[] = {
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0xF93F, 0, 0,
+};
+static const unsigned short utf8_to_euc_E4A0_x0213[] = {
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0xF949, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+};
+static const unsigned short utf8_to_euc_E4A1_x0213[] = {
+ 0, 0, 0, 0, 0x7C4B, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0xF95C, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+};
+static const unsigned short utf8_to_euc_E4A2_x0213[] = {
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0xFA27, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+};
+static const unsigned short utf8_to_euc_E4A6_x0213[] = {
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0x7D58, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+};
+static const unsigned short utf8_to_euc_E4A7_x0213[] = {
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0xFB6A,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0xFB70, 0, 0, 0, 0, 0,
+};
+static const unsigned short utf8_to_euc_E4A8_x0213[] = {
+ 0, 0, 0, 0, 0xFB75, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0xFB78, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+};
+static const unsigned short utf8_to_euc_E4AA_x0213[] = {
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0xFC37, 0, 0, 0,
+};
+static const unsigned short utf8_to_euc_E4AC_x0213[] = {
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0xFC55, 0, 0, 0, 0,
+};
+static const unsigned short utf8_to_euc_E4AF_x0213[] = {
+ 0, 0, 0xFD26, 0, 0, 0, 0, 0,
+ 0, 0, 0xFD28, 0, 0, 0, 0, 0,
+ 0, 0, 0xFD2A, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0xFD31, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+};
+static const unsigned short utf8_to_euc_E4B0_x0213[] = {
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0x7E3E,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0xFD3F, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+};
+static const unsigned short utf8_to_euc_E4B3_x0213[] = {
+ 0, 0, 0, 0, 0xFE2A, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0xFE2D, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+};
+static const unsigned short utf8_to_euc_E4B4_x0213[] = {
+ 0, 0, 0, 0, 0, 0, 0, 0xFE4B,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+};
+static const unsigned short utf8_to_euc_E4B5_x0213[] = {
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0xFE60,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+};
+static const unsigned short utf8_to_euc_E4B8[] = {
+ 0x306C, 0x437A, 0xB021, 0x3C37, 0xB022, 0xB023, 0, 0x4B7C,
+ 0x3E66, 0x3B30, 0x3E65, 0x323C, 0xB024, 0x4954, 0x4D3F, 0,
+ 0x5022, 0x312F, 0xB025, 0, 0x336E, 0x5023, 0x4024, 0x5242,
+ 0x3556, 0x4A3A, 0, 0, 0, 0, 0x3E67, 0xB026,
+ 0, 0x4E3E, 0, 0xB027, 0xB028, 0, 0x4A42, 0,
+ 0xB029, 0, 0x5024, 0xB02A, 0, 0x4366, 0xB02B, 0xB02C,
+ 0xB02D, 0x5025, 0x367A, 0, 0, 0xB02E, 0x5026, 0,
+ 0x345D, 0x4330, 0, 0x3C67, 0x5027, 0, 0, 0x5028,
+};
+static const unsigned short utf8_to_euc_E4B8_x0213[] = {
+ 0x306C, 0x437A, 0xA122, 0x3C37, 0xB022, 0xB023, 0, 0x4B7C,
+ 0x3E66, 0x3B30, 0x3E65, 0x323C, 0xB024, 0x4954, 0x4D3F, 0xA123,
+ 0x5022, 0x312F, 0xA124, 0, 0x336E, 0x5023, 0x4024, 0x5242,
+ 0x3556, 0x4A3A, 0, 0, 0, 0, 0x3E67, 0xB026,
+ 0, 0x4E3E, 0, 0xB027, 0xB028, 0, 0x4A42, 0,
+ 0x2E24, 0xA125, 0x5024, 0xA126, 0xF02E, 0x4366, 0xA127, 0x2E25,
+ 0x2E26, 0x5025, 0x367A, 0, 0, 0xB02E, 0x5026, 0,
+ 0x345D, 0x4330, 0, 0x3C67, 0x5027, 0, 0, 0x5028,
+};
+static const unsigned short utf8_to_euc_E4B9[] = {
+ 0xB02F, 0xB030, 0x5029, 0x4735, 0xB031, 0x3557, 0, 0xB032,
+ 0, 0, 0, 0x4737, 0, 0x4663, 0x3843, 0x4B33,
+ 0, 0xB033, 0, 0, 0, 0x6949, 0x502A, 0x3E68,
+ 0x502B, 0x3235, 0xB034, 0, 0xB035, 0x3665, 0x3870, 0x4C69,
+ 0, 0, 0x5626, 0xB036, 0, 0, 0, 0,
+ 0xB037, 0xB038, 0, 0, 0, 0, 0, 0,
+ 0, 0x4D70, 0, 0x467D, 0xB039, 0xB03A, 0, 0,
+ 0, 0xB03B, 0, 0, 0, 0, 0x3425, 0xB03C,
+};
+static const unsigned short utf8_to_euc_E4B9_x0213[] = {
+ 0xA128, 0xB030, 0x5029, 0x4735, 0xB031, 0x3557, 0, 0xA129,
+ 0xA12A, 0, 0, 0x4737, 0, 0x4663, 0x3843, 0x4B33,
+ 0, 0xA12C, 0, 0, 0, 0x6949, 0x502A, 0x3E68,
+ 0x502B, 0x3235, 0xA12F, 0, 0xB035, 0x3665, 0x3870, 0x4C69,
+ 0, 0, 0x5626, 0xB036, 0, 0, 0, 0,
+ 0xB037, 0xA130, 0, 0, 0, 0, 0, 0,
+ 0, 0x4D70, 0, 0x467D, 0xB039, 0xB03A, 0, 0,
+ 0, 0xB03B, 0, 0, 0, 0, 0x3425, 0xB03C,
+};
+static const unsigned short utf8_to_euc_E4BA[] = {
+ 0x3535, 0, 0x502C, 0, 0, 0x502D, 0x4E3B, 0,
+ 0x4D3D, 0x4168, 0x502F, 0x3B76, 0x4673, 0xB03D, 0x5032, 0,
+ 0, 0x313E, 0x385F, 0, 0x385E, 0x3066, 0xB03E, 0xB03F,
+ 0x4F4B, 0x4F4A, 0, 0x3A33, 0x3021, 0xB040, 0x5033, 0x5034,
+ 0x5035, 0x4B34, 0x5036, 0, 0x3872, 0x3067, 0x4B72, 0,
+ 0x357C, 0, 0, 0x357D, 0x357E, 0x4462, 0x4E3C, 0xB041,
+ 0x5037, 0, 0, 0x5038, 0, 0, 0x5039, 0,
+ 0, 0xB042, 0x3F4D, 0, 0, 0, 0, 0,
+};
+static const unsigned short utf8_to_euc_E4BA_x0213[] = {
+ 0x3535, 0, 0x502C, 0, 0, 0x502D, 0x4E3B, 0,
+ 0x4D3D, 0x4168, 0x502F, 0x3B76, 0x4673, 0x2E27, 0x5032, 0,
+ 0, 0x313E, 0x385F, 0, 0x385E, 0x3066, 0xB03E, 0xB03F,
+ 0x4F4B, 0x4F4A, 0, 0x3A33, 0x3021, 0xA131, 0x5033, 0x5034,
+ 0x5035, 0x4B34, 0x5036, 0, 0x3872, 0x3067, 0x4B72, 0,
+ 0x357C, 0, 0, 0x357D, 0x357E, 0x4462, 0x4E3C, 0xB041,
+ 0x5037, 0, 0, 0x5038, 0, 0, 0x5039, 0,
+ 0, 0xA134, 0x3F4D, 0xA135, 0xA137, 0, 0, 0,
+};
+static const unsigned short utf8_to_euc_E4BB[] = {
+ 0x3D3A, 0x3F4E, 0x503E, 0xB043, 0x503C, 0, 0x503D, 0x3558,
+ 0, 0, 0x3A23, 0x3270, 0, 0x503B, 0x503A, 0x4A29,
+ 0xB044, 0, 0, 0, 0x3B46, 0x3B45, 0x423E, 0x503F,
+ 0x4955, 0x4067, 0xB045, 0xB046, 0, 0x2138, 0x5040, 0x5042,
+ 0xB047, 0xB048, 0xB049, 0x4265, 0x4E61, 0x304A, 0, 0,
+ 0xB04A, 0, 0, 0, 0, 0x5041, 0x323E, 0xB04B,
+ 0x3644, 0xB04C, 0x4367, 0xB04D, 0, 0xB04E, 0x376F, 0x5043,
+ 0, 0, 0, 0x4724, 0xF42F, 0xB04F, 0xB050, 0xB051,
+};
+static const unsigned short utf8_to_euc_E4BB_x0213[] = {
+ 0x3D3A, 0x3F4E, 0x503E, 0xA138, 0x503C, 0, 0x503D, 0x3558,
+ 0xA139, 0, 0x3A23, 0x3270, 0, 0x503B, 0x503A, 0x4A29,
+ 0xA13A, 0, 0, 0, 0x3B46, 0x3B45, 0x423E, 0x503F,
+ 0x4955, 0x4067, 0xA13C, 0xB046, 0, 0x2138, 0x5040, 0x5042,
+ 0xB047, 0x2E28, 0xB049, 0x4265, 0x4E61, 0x304A, 0, 0,
+ 0xB04A, 0, 0, 0xA13B, 0, 0x5041, 0x323E, 0xB04B,
+ 0x3644, 0xA13D, 0x4367, 0xB04D, 0, 0xA13E, 0x376F, 0x5043,
+ 0, 0, 0, 0x4724, 0xF42F, 0x2E29, 0xB050, 0x2E2A,
+};
+static const unsigned short utf8_to_euc_E4BC[] = {
+ 0xB052, 0x346B, 0xB053, 0xB054, 0, 0, 0, 0,
+ 0xB055, 0x5044, 0x304B, 0xB056, 0xB057, 0x3860, 0x346C, 0x497A,
+ 0x4832, 0x3559, 0xB058, 0, 0, 0xB059, 0xB05A, 0xB05B,
+ 0, 0xB05C, 0x3271, 0, 0x5067, 0x4541, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0xB05D, 0x476C,
+ 0x5046, 0xB05E, 0, 0xB060, 0x483C, 0xB061, 0x4E62, 0xB062,
+ 0x3F2D, 0xB063, 0x3B47, 0xB064, 0x3B77, 0x3240, 0xB065, 0,
+};
+static const unsigned short utf8_to_euc_E4BC_x0213[] = {
+ 0xA13F, 0x346B, 0xB053, 0x2E2B, 0, 0, 0, 0,
+ 0xB055, 0x5044, 0x304B, 0x2E2C, 0xB057, 0x3860, 0x346C, 0x497A,
+ 0x4832, 0x3559, 0xB058, 0, 0, 0xB059, 0xA140, 0xB05B,
+ 0, 0xB05C, 0x3271, 0, 0x5067, 0x4541, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0xB05D, 0x476C,
+ 0x5046, 0xB05E, 0, 0xB060, 0x483C, 0xB061, 0x4E62, 0xA142,
+ 0x3F2D, 0xB063, 0x3B47, 0xB064, 0x3B77, 0x3240, 0xA143, 0,
+};
+static const unsigned short utf8_to_euc_E4BD[] = {
+ 0xB066, 0, 0xB067, 0x4451, 0, 0, 0x4322, 0x504A,
+ 0xB068, 0xB069, 0, 0xB06A, 0xB06B, 0x304C, 0x4463, 0x3D3B,
+ 0x3A34, 0x4D24, 0xB06C, 0x424E, 0xB06D, 0x323F, 0xB06E, 0x5049,
+ 0xB06F, 0x4D3E, 0x5045, 0x5047, 0x3A6E, 0x5048, 0x5524, 0xB070,
+ 0xB05F, 0, 0, 0xB071, 0, 0, 0, 0,
+ 0, 0x5050, 0xB072, 0, 0xB073, 0, 0xB074, 0x5053,
+ 0x5051, 0xB075, 0, 0x3242, 0, 0x4A3B, 0x504B, 0xB076,
+ 0xB077, 0xB078, 0xB079, 0x504F, 0x3873, 0xB07A, 0xB07B, 0x3B48,
+};
+static const unsigned short utf8_to_euc_E4BD_x0213[] = {
+ 0xB066, 0, 0xB067, 0x4451, 0, 0, 0x4322, 0x504A,
+ 0x2E2E, 0x2E2F, 0, 0xB06A, 0xB06B, 0x304C, 0x4463, 0x3D3B,
+ 0x3A34, 0x4D24, 0xB06C, 0x424E, 0xA144, 0x323F, 0x2E30, 0x5049,
+ 0xA145, 0x4D3E, 0x5045, 0x5047, 0x3A6E, 0x5048, 0x5524, 0x2E31,
+ 0x2E2D, 0, 0, 0xB071, 0xA141, 0, 0, 0,
+ 0, 0x5050, 0x2E32, 0, 0x2E33, 0, 0xB074, 0x5053,
+ 0x5051, 0xB075, 0, 0x3242, 0, 0x4A3B, 0x504B, 0xA147,
+ 0xA148, 0xB078, 0xA149, 0x504F, 0x3873, 0xA14A, 0x2E34, 0x3B48,
+};
+static const unsigned short utf8_to_euc_E4BE[] = {
+ 0, 0xB07C, 0xB07D, 0x3426, 0xB07E, 0xB121, 0x5054, 0,
+ 0x504C, 0xB122, 0xB123, 0x4E63, 0xB124, 0x3B78, 0xB125, 0x504D,
+ 0xB126, 0x5052, 0xB127, 0xB128, 0xB129, 0, 0x5055, 0xB12A,
+ 0x504E, 0xB12B, 0xB12C, 0x3621, 0, 0x304D, 0xB12D, 0xB12E,
+ 0x3622, 0x3241, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0x5525, 0, 0x4B79, 0x496E, 0x3874,
+ 0, 0, 0xB12F, 0, 0, 0x3F2F, 0x4E37, 0xB130,
+ 0, 0xB131, 0, 0xB132, 0xB133, 0xB134, 0xB135, 0x4A58,
+};
+static const unsigned short utf8_to_euc_E4BE_x0213[] = {
+ 0, 0xB07C, 0xA14B, 0x3426, 0xB07E, 0xA14C, 0x5054, 0,
+ 0x504C, 0xB122, 0x2E35, 0x4E63, 0xB124, 0x3B78, 0xB125, 0x504D,
+ 0xB126, 0x5052, 0xA14D, 0xB128, 0x2E36, 0, 0x5055, 0x2E37,
+ 0x504E, 0xB12B, 0xA14E, 0x3621, 0, 0x304D, 0xB12D, 0xB12E,
+ 0x3622, 0x3241, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0x5525, 0, 0x4B79, 0x496E, 0x3874,
+ 0, 0, 0xA150, 0, 0, 0x3F2F, 0x4E37, 0xB130,
+ 0, 0xB131, 0, 0xB132, 0xB133, 0xB134, 0xA151, 0x4A58,
+};
+static const unsigned short utf8_to_euc_E4BF[] = {
+ 0xB136, 0xB137, 0x3738, 0x4225, 0x3264, 0xB138, 0xB139, 0,
+ 0xB13A, 0xB13B, 0x3D53, 0xB13C, 0xB13D, 0xB13E, 0x5059, 0xB13F,
+ 0x505E, 0x505C, 0xB140, 0, 0x5057, 0, 0, 0x422F,
+ 0x505A, 0, 0x505D, 0x505B, 0xB141, 0x4A5D, 0, 0x5058,
+ 0xB142, 0x3F2E, 0xB143, 0x4B73, 0x505F, 0x5060, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0x3D24, 0x506D,
+ 0xB144, 0, 0xB145, 0x4750, 0, 0x4936, 0x5068, 0,
+ 0x4A70, 0, 0x3236, 0, 0xB146, 0xB147, 0x506C, 0xB148,
+};
+static const unsigned short utf8_to_euc_E4BF_x0213[] = {
+ 0xB136, 0xB137, 0x3738, 0x4225, 0x3264, 0xA152, 0xB139, 0,
+ 0xB13A, 0x2E39, 0x3D53, 0xA153, 0xB13D, 0xB13E, 0x5059, 0xA154,
+ 0x505E, 0x505C, 0xA155, 0, 0x5057, 0, 0, 0x422F,
+ 0x505A, 0, 0x505D, 0x505B, 0xB141, 0x4A5D, 0, 0x5058,
+ 0x2E3A, 0x3F2E, 0xB143, 0x4B73, 0x505F, 0x5060, 0xA14F, 0,
+ 0, 0, 0, 0, 0, 0, 0x3D24, 0x506D,
+ 0xB144, 0x2E21, 0xA157, 0x4750, 0, 0x4936, 0x5068, 0,
+ 0x4A70, 0, 0x3236, 0, 0xB146, 0xB147, 0x506C, 0xB148,
+};
+static const unsigned short utf8_to_euc_E580[] = {
+ 0xB149, 0xB14A, 0, 0, 0xB14B, 0x5066, 0x506F, 0xB14C,
+ 0, 0x4152, 0xB14D, 0x3844, 0xB14E, 0x475C, 0xB14F, 0x6047,
+ 0xB150, 0x506E, 0x455D, 0xB151, 0x5063, 0, 0x3876, 0xB152,
+ 0xB153, 0x3875, 0x5061, 0xB154, 0xB155, 0xB156, 0xB157, 0x3C5A,
+ 0, 0x5069, 0xB158, 0x4A6F, 0x434D, 0x5065, 0x3771, 0xB159,
+ 0x5062, 0x506A, 0x5064, 0x4E51, 0x506B, 0x4F41, 0xB15A, 0,
+ 0xB15B, 0, 0xB15C, 0xB15D, 0, 0xB15E, 0x3666, 0,
+ 0, 0x3770, 0, 0xB176, 0, 0, 0, 0,
+};
+static const unsigned short utf8_to_euc_E580_x0213[] = {
+ 0xA158, 0x2E3B, 0x2E3C, 0, 0xB14B, 0x5066, 0x506F, 0xB14C,
+ 0, 0x4152, 0xB14D, 0x3844, 0xB14E, 0x475C, 0x2E3D, 0x6047,
+ 0xA159, 0x506E, 0x455D, 0xA15A, 0x5063, 0, 0x3876, 0xB152,
+ 0x2E3E, 0x3875, 0x5061, 0xB154, 0xA15B, 0xB156, 0xA15C, 0x3C5A,
+ 0, 0x5069, 0xA15D, 0x4A6F, 0x434D, 0x5065, 0x3771, 0x2E3F,
+ 0x5062, 0x506A, 0x5064, 0x4E51, 0x506B, 0x4F41, 0x2E40, 0,
+ 0xB15B, 0, 0xB15C, 0xB15D, 0, 0xB15E, 0x3666, 0,
+ 0, 0x3770, 0, 0x2E42, 0, 0, 0, 0,
+};
+static const unsigned short utf8_to_euc_E581[] = {
+ 0xB15F, 0xB160, 0xB161, 0x5070, 0, 0xB162, 0xB163, 0x5071,
+ 0x5075, 0x304E, 0xB164, 0, 0xB165, 0, 0xB166, 0x4A50,
+ 0x5074, 0xB167, 0xB168, 0xB169, 0, 0x5073, 0x5077, 0xB16A,
+ 0, 0xB16B, 0x5076, 0, 0x4464, 0, 0, 0xB16C,
+ 0xB16D, 0, 0xB16E, 0xB16F, 0, 0x3772, 0xB170, 0xB171,
+ 0, 0, 0xB172, 0, 0x5078, 0xB173, 0, 0,
+ 0xB174, 0xB175, 0x3C45, 0, 0x4226, 0x4465, 0x3676, 0,
+ 0x5079, 0, 0, 0, 0, 0x3536, 0, 0,
+};
+static const unsigned short utf8_to_euc_E581_x0213[] = {
+ 0x2E41, 0x2E43, 0xA15F, 0x5070, 0, 0xB162, 0xA160, 0x5071,
+ 0x5075, 0x304E, 0xB164, 0, 0xB165, 0, 0xA161, 0x4A50,
+ 0x5074, 0xB167, 0xB168, 0xA162, 0, 0x5073, 0x5077, 0xA163,
+ 0, 0xB16B, 0x5076, 0, 0x4464, 0, 0, 0xB16C,
+ 0xB16D, 0, 0xB16E, 0xA164, 0, 0x3772, 0xA165, 0xB171,
+ 0, 0, 0xA166, 0, 0x5078, 0xB173, 0, 0,
+ 0xA167, 0xB175, 0x3C45, 0, 0x4226, 0x4465, 0x3676, 0,
+ 0x5079, 0, 0, 0, 0, 0x3536, 0, 0,
+};
+static const unsigned short utf8_to_euc_E582[] = {
+ 0x507A, 0xB177, 0, 0xB178, 0xB179, 0x507C, 0xB17A, 0,
+ 0, 0, 0xB17B, 0, 0, 0x4B35, 0xB17C, 0xB17D,
+ 0xB17E, 0x3766, 0xB221, 0xB222, 0xB223, 0, 0xB224, 0,
+ 0x3B31, 0x4877, 0x507B, 0xB225, 0xB226, 0, 0xB227, 0xB228,
+ 0xB229, 0xB22A, 0xB22B, 0, 0, 0, 0, 0,
+ 0, 0, 0xB22C, 0, 0x3A45, 0x4D43, 0, 0xB22D,
+ 0xB22E, 0, 0x507E, 0x5123, 0x507D, 0x3A44, 0, 0x3D7D,
+ 0, 0xB22F, 0xB230, 0, 0, 0xB231, 0x3739, 0,
+};
+static const unsigned short utf8_to_euc_E582_x0213[] = {
+ 0x507A, 0xB177, 0, 0xB178, 0xB179, 0x507C, 0xB17A, 0,
+ 0xA169, 0, 0xB17B, 0, 0, 0x4B35, 0xB17C, 0xB17D,
+ 0xB17E, 0x3766, 0xA16A, 0xA16B, 0x2E44, 0xA16C, 0xA16D, 0,
+ 0x3B31, 0x4877, 0x507B, 0xB225, 0xA16E, 0, 0xB227, 0xB228,
+ 0xB229, 0xB22A, 0xB22B, 0xA168, 0, 0, 0, 0,
+ 0, 0, 0xA16F, 0, 0x3A45, 0x4D43, 0, 0xB22D,
+ 0xB22E, 0xA171, 0x507E, 0x5123, 0x507D, 0x3A44, 0, 0x3D7D,
+ 0, 0xB22F, 0xA172, 0xA173, 0, 0xB231, 0x3739, 0,
+};
+static const unsigned short utf8_to_euc_E583[] = {
+ 0xB232, 0, 0x5124, 0xB233, 0xB234, 0x364F, 0, 0xB235,
+ 0, 0x5121, 0x5122, 0, 0xB236, 0x462F, 0xB237, 0x417C,
+ 0xB238, 0x3623, 0, 0xB239, 0xB23A, 0x4B4D, 0x5125, 0,
+ 0xB23B, 0, 0x4E3D, 0, 0xB23C, 0xB23D, 0x5126, 0xB23E,
+ 0, 0, 0xB23F, 0x5129, 0xB240, 0x5127, 0xB241, 0x414E,
+ 0xB242, 0xB243, 0, 0, 0, 0x5128, 0x512A, 0xB244,
+ 0, 0xB245, 0xB251, 0, 0xF430, 0x512C, 0xB246, 0,
+ 0, 0x512B, 0xB247, 0x4A48, 0, 0, 0xB248, 0,
+};
+static const unsigned short utf8_to_euc_E583_x0213[] = {
+ 0xB232, 0, 0x5124, 0xB233, 0xA174, 0x364F, 0, 0xA175,
+ 0, 0x5121, 0x5122, 0, 0x2E45, 0x462F, 0xA178, 0x417C,
+ 0x2E47, 0x3623, 0, 0xB239, 0xA17A, 0x4B4D, 0x5125, 0,
+ 0xB23B, 0xA17B, 0x4E3D, 0, 0xB23C, 0xB23D, 0x5126, 0xB23E,
+ 0, 0xA17C, 0xB23F, 0x5129, 0xB240, 0x5127, 0x2E48, 0x414E,
+ 0xB242, 0xA17D, 0, 0, 0, 0x5128, 0x512A, 0xB244,
+ 0, 0xB245, 0x2E46, 0xA176, 0xF430, 0x512C, 0xB246, 0,
+ 0, 0x512B, 0xB247, 0x4A48, 0, 0, 0xB248, 0,
+};
+static const unsigned short utf8_to_euc_E584[] = {
+ 0x3537, 0x512E, 0x512F, 0xB249, 0x322F, 0, 0xB24A, 0xB24B,
+ 0xB24C, 0x512D, 0, 0xB24D, 0xB24E, 0xB24F, 0xB250, 0,
+ 0xB252, 0, 0x3C74, 0, 0x5132, 0x5131, 0x5130, 0xB253,
+ 0x5056, 0xB254, 0x5133, 0xB255, 0xB256, 0xB257, 0xB258, 0x3D7E,
+ 0, 0x5134, 0, 0xB259, 0, 0, 0, 0xB25A,
+ 0xB25B, 0, 0x4D25, 0, 0xB25C, 0xB25D, 0, 0xB25E,
+ 0, 0xB25F, 0x4C59, 0xB260, 0xB261, 0xB262, 0, 0x5136,
+ 0xB263, 0xB264, 0x5135, 0x5138, 0x5137, 0, 0, 0x5139,
+};
+static const unsigned short utf8_to_euc_E584_x0213[] = {
+ 0x3537, 0x512E, 0x512F, 0x2E4B, 0x322F, 0, 0x2E4A, 0xB24B,
+ 0xA321, 0x512D, 0, 0x2E4C, 0xB24E, 0xB24F, 0xB250, 0,
+ 0xB252, 0, 0x3C74, 0, 0x5132, 0x5131, 0x5130, 0xA323,
+ 0x5056, 0xB254, 0x5133, 0xA324, 0xB256, 0xB257, 0x2E4D, 0x3D7E,
+ 0, 0x5134, 0, 0xB259, 0, 0, 0, 0xB25A,
+ 0xB25B, 0, 0x4D25, 0, 0xB25C, 0xB25D, 0, 0xB25E,
+ 0, 0xB25F, 0x4C59, 0xB260, 0xB261, 0x2E4E, 0, 0x5136,
+ 0xB263, 0xB264, 0x5135, 0x5138, 0x5137, 0, 0, 0x5139,
+};
+static const unsigned short utf8_to_euc_E585[] = {
+ 0x513A, 0x3074, 0xB265, 0x3835, 0x373B, 0x3D3C, 0x437B, 0x3624,
+ 0x4068, 0x3877, 0xB266, 0x396E, 0x513C, 0x4C48, 0x4546, 0xB267,
+ 0x3B79, 0, 0x513B, 0xB268, 0x513D, 0xB269, 0, 0xB26A,
+ 0xB26B, 0, 0x455E, 0, 0x3375, 0, 0, 0xB26C,
+ 0, 0, 0x513E, 0, 0xB26D, 0x467E, 0xB26E, 0,
+ 0x4134, 0x5140, 0x5141, 0x482C, 0x3878, 0x4F3B, 0x5142, 0,
+ 0, 0x3626, 0, 0, 0, 0x4A3C, 0x4236, 0x3671,
+ 0x4535, 0, 0, 0, 0x3773, 0, 0xB26F, 0,
+};
+static const unsigned short utf8_to_euc_E585_x0213[] = {
+ 0x513A, 0x3074, 0xB265, 0x3835, 0x373B, 0x3D3C, 0x437B, 0x3624,
+ 0x4068, 0x3877, 0x2E4F, 0x396E, 0x513C, 0x4C48, 0x4546, 0xB267,
+ 0x3B79, 0, 0x513B, 0xB268, 0x513D, 0x2E51, 0, 0x2E52,
+ 0xB26B, 0, 0x455E, 0, 0x3375, 0, 0, 0xB26C,
+ 0xA326, 0, 0x513E, 0, 0xB26D, 0x467E, 0xB26E, 0,
+ 0x4134, 0x5140, 0x5141, 0x482C, 0x3878, 0x4F3B, 0x5142, 0,
+ 0, 0x3626, 0, 0xA328, 0, 0x4A3C, 0x4236, 0x3671,
+ 0x4535, 0, 0, 0xF474, 0x3773, 0, 0xB26F, 0,
+};
+static const unsigned short utf8_to_euc_E586[] = {
+ 0x5143, 0, 0x5144, 0xB270, 0xB271, 0x4662, 0x315F, 0,
+ 0, 0x5147, 0x3A7D, 0xB272, 0x5146, 0x3A46, 0xB273, 0x5148,
+ 0x666E, 0x5149, 0x4B41, 0x514A, 0, 0x514B, 0x514C, 0x3E69,
+ 0xB274, 0x3C4C, 0, 0, 0, 0xB275, 0, 0,
+ 0x3427, 0xB276, 0x514F, 0xB277, 0x514D, 0x4C3D, 0x514E, 0,
+ 0x495A, 0x5150, 0x5151, 0x5152, 0x455F, 0xB278, 0, 0,
+ 0x5156, 0x5154, 0x5155, 0x5153, 0x3A63, 0x5157, 0x4C6A, 0x4E64,
+ 0xB279, 0, 0xB27A, 0, 0xB27B, 0x5158, 0xB27C, 0xB27D,
+};
+static const unsigned short utf8_to_euc_E586_x0213[] = {
+ 0x5143, 0, 0x5144, 0xA329, 0xB271, 0x4662, 0x315F, 0,
+ 0, 0x5147, 0x3A7D, 0xA32A, 0x5146, 0x3A46, 0xB273, 0x5148,
+ 0x666E, 0x5149, 0x4B41, 0x514A, 0, 0x514B, 0x514C, 0x3E69,
+ 0xA32C, 0x3C4C, 0, 0, 0, 0x2E54, 0, 0,
+ 0x3427, 0xB276, 0x514F, 0xA32D, 0x514D, 0x4C3D, 0x514E, 0,
+ 0x495A, 0x5150, 0x5151, 0x5152, 0x455F, 0xA32E, 0, 0,
+ 0x5156, 0x5154, 0x5155, 0x5153, 0x3A63, 0x5157, 0x4C6A, 0x4E64,
+ 0xB279, 0, 0xB27A, 0, 0xA330, 0x5158, 0xB27C, 0xB27D,
+};
+static const unsigned short utf8_to_euc_E587[] = {
+ 0, 0, 0xB27E, 0, 0x4028, 0x5159, 0x3D5A, 0,
+ 0xB321, 0x515A, 0, 0x437C, 0x4E3F, 0x4560, 0, 0xB322,
+ 0, 0xB323, 0xB324, 0xB325, 0, 0xB326, 0x5245, 0,
+ 0xB327, 0, 0, 0x515B, 0x7425, 0x3645, 0xB328, 0,
+ 0x515C, 0x4B5E, 0xB329, 0, 0, 0xB32A, 0x3D68, 0x427C,
+ 0, 0x515E, 0x4664, 0, 0xF431, 0x515F, 0xB32B, 0,
+ 0x5160, 0x332E, 0xB32C, 0xB32D, 0xB32E, 0x5161, 0x3627, 0xB32F,
+ 0x464C, 0x317A, 0x3D50, 0, 0, 0x4821, 0x5162, 0,
+};
+static const unsigned short utf8_to_euc_E587_x0213[] = {
+ 0, 0, 0xB27E, 0x2E55, 0x4028, 0x5159, 0x3D5A, 0,
+ 0xB321, 0x515A, 0x2E56, 0x437C, 0x4E3F, 0x4560, 0, 0xB322,
+ 0, 0xB323, 0xB324, 0xB325, 0, 0xB326, 0x5245, 0,
+ 0xB327, 0, 0, 0x515B, 0x7425, 0x3645, 0x2E57, 0,
+ 0x515C, 0x4B5E, 0x2E58, 0, 0, 0xB32A, 0x3D68, 0x427C,
+ 0, 0x515E, 0x4664, 0, 0xF431, 0x515F, 0x2E59, 0,
+ 0x5160, 0x332E, 0xB32C, 0xA333, 0xA334, 0x5161, 0x3627, 0xB32F,
+ 0x464C, 0x317A, 0x3D50, 0, 0, 0x4821, 0x5162, 0,
+};
+static const unsigned short utf8_to_euc_E588[] = {
+ 0x4561, 0xB330, 0xB331, 0x3F4F, 0x5163, 0xB332, 0x4A2C, 0x405A,
+ 0x3422, 0, 0x3429, 0x5164, 0, 0, 0x5166, 0,
+ 0, 0x373A, 0xB333, 0xB334, 0x5165, 0xB335, 0xB336, 0x4E73,
+ 0xB337, 0, 0, 0, 0, 0x3D69, 0, 0,
+ 0, 0, 0xB338, 0, 0x483D, 0x4A4C, 0, 0x5167,
+ 0xB339, 0x4D78, 0x5168, 0, 0, 0, 0x5169, 0,
+ 0x457E, 0xB33A, 0xB33B, 0x516A, 0, 0xB33C, 0x4029, 0x3A7E,
+ 0x3774, 0x516B, 0x3B49, 0x396F, 0xB33D, 0, 0, 0,
+};
+static const unsigned short utf8_to_euc_E588_x0213[] = {
+ 0x4561, 0x2E5A, 0xA335, 0x3F4F, 0x5163, 0xB332, 0x4A2C, 0x405A,
+ 0x3422, 0, 0x3429, 0x5164, 0, 0, 0x5166, 0,
+ 0, 0x373A, 0xA336, 0x2E5C, 0x5165, 0x2E5D, 0xA337, 0x4E73,
+ 0xB337, 0, 0, 0, 0, 0x3D69, 0, 0,
+ 0, 0, 0xB338, 0, 0x483D, 0x4A4C, 0, 0x5167,
+ 0xB339, 0x4D78, 0x5168, 0, 0, 0, 0x5169, 0,
+ 0x457E, 0xB33A, 0xB33B, 0x516A, 0, 0xB33C, 0x4029, 0x3A7E,
+ 0x3774, 0x516B, 0x3B49, 0x396F, 0xB33D, 0, 0, 0,
+};
+static const unsigned short utf8_to_euc_E589[] = {
+ 0, 0, 0, 0x4466, 0x516D, 0xB33E, 0, 0x4227,
+ 0, 0xB33F, 0x3A6F, 0x516E, 0x516F, 0x4130, 0, 0x516C,
+ 0, 0, 0, 0, 0x5171, 0xB340, 0x4B36, 0xB341,
+ 0xB342, 0, 0xB343, 0x3964, 0xB344, 0, 0x5170, 0xB345,
+ 0xB346, 0xB347, 0, 0x3775, 0x3A5E, 0x476D, 0xB348, 0,
+ 0, 0x5174, 0x5172, 0, 0, 0, 0xB349, 0x497B,
+ 0x3E6A, 0x517B, 0x3364, 0x5175, 0x5173, 0x414F, 0, 0xB34A,
+ 0xB34B, 0xB34C, 0, 0, 0, 0x5177, 0, 0x5176,
+};
+static const unsigned short utf8_to_euc_E589_x0213[] = {
+ 0, 0, 0, 0x4466, 0x516D, 0xB33E, 0, 0x4227,
+ 0, 0x2E5E, 0x3A6F, 0x516E, 0x516F, 0x4130, 0, 0x516C,
+ 0, 0, 0, 0, 0x5171, 0xA339, 0x4B36, 0x2E5F,
+ 0xB342, 0, 0xB343, 0x3964, 0xA33A, 0x2F7E, 0x5170, 0xB345,
+ 0xB346, 0x2E60, 0, 0x3775, 0x3A5E, 0x476D, 0xB348, 0,
+ 0, 0x5174, 0x5172, 0, 0xA33B, 0, 0xB349, 0x497B,
+ 0x3E6A, 0x517B, 0x3364, 0x5175, 0x5173, 0x414F, 0, 0xA33C,
+ 0xB34B, 0xB34C, 0, 0, 0, 0x5177, 0, 0x5176,
+};
+static const unsigned short utf8_to_euc_E58A[] = {
+ 0xB34D, 0, 0xB34E, 0x3344, 0, 0xB34F, 0, 0x3760,
+ 0x517C, 0x4E2D, 0xB350, 0, 0xB351, 0x5178, 0, 0,
+ 0, 0x517D, 0x517A, 0xB352, 0x5179, 0xB353, 0xB354, 0xB355,
+ 0xB356, 0, 0xB357, 0x4E4F, 0xB358, 0, 0, 0x3879,
+ 0x3243, 0, 0, 0x4E74, 0xB359, 0xB35A, 0xB35B, 0xB35C,
+ 0, 0x3D75, 0x4558, 0x3965, 0x5222, 0x5223, 0, 0xB35D,
+ 0xB35E, 0x4E65, 0, 0, 0x4F2B, 0x5225, 0xB35F, 0xB360,
+ 0xB361, 0x387A, 0xB362, 0xB363, 0x5224, 0xB364, 0x332F, 0,
+};
+static const unsigned short utf8_to_euc_E58A_x0213[] = {
+ 0xB34D, 0, 0xA33E, 0x3344, 0xA33D, 0xB34F, 0, 0x3760,
+ 0x517C, 0x4E2D, 0xB350, 0, 0xB351, 0x5178, 0, 0,
+ 0, 0x517D, 0x517A, 0x2E61, 0x5179, 0xB353, 0xB354, 0xB355,
+ 0xA340, 0, 0xB357, 0x4E4F, 0xB358, 0, 0, 0x3879,
+ 0x3243, 0, 0, 0x4E74, 0xA342, 0xB35A, 0xA343, 0xB35C,
+ 0, 0x3D75, 0x4558, 0x3965, 0x5222, 0x5223, 0, 0xA344,
+ 0xB35E, 0x4E65, 0, 0, 0x4F2B, 0x5225, 0xB35F, 0xB360,
+ 0xB361, 0x387A, 0xA345, 0xA346, 0x5224, 0xB364, 0x332F, 0,
+};
+static const unsigned short utf8_to_euc_E58B[] = {
+ 0xB365, 0x5226, 0, 0x4B56, 0xB366, 0x443C, 0xB367, 0x4D26,
+ 0xB368, 0x4A59, 0, 0, 0xB369, 0x5227, 0, 0xB36A,
+ 0, 0xB36B, 0x7055, 0, 0xB36C, 0x4630, 0xB36D, 0x5228,
+ 0x342A, 0x4C33, 0, 0xB36E, 0xB36F, 0x3E21, 0x5229, 0x4A67,
+ 0x522D, 0xB370, 0x402A, 0x522A, 0x3650, 0xB371, 0x522B, 0x342B,
+ 0xB372, 0xB373, 0xB374, 0, 0xB375, 0, 0, 0,
+ 0xB376, 0xB377, 0x372E, 0x522E, 0xB378, 0x522F, 0xB379, 0xB37A,
+ 0x5230, 0x5231, 0x3C5B, 0, 0, 0, 0x387B, 0x4C5E,
+};
+static const unsigned short utf8_to_euc_E58B_x0213[] = {
+ 0xB365, 0x5226, 0, 0x4B56, 0xB366, 0x443C, 0xB367, 0x4D26,
+ 0x2E62, 0x4A59, 0xA347, 0, 0x2E64, 0x5227, 0, 0xB36A,
+ 0x2E65, 0xA349, 0x7055, 0, 0xB36C, 0x4630, 0x2E66, 0x5228,
+ 0x342A, 0x4C33, 0, 0x2E67, 0xB36F, 0x3E21, 0x5229, 0x4A67,
+ 0x522D, 0xB370, 0x402A, 0x522A, 0x3650, 0xB371, 0x522B, 0x342B,
+ 0xB372, 0xB373, 0xB374, 0, 0xB375, 0, 0, 0,
+ 0x2E69, 0xB377, 0x372E, 0x522E, 0xB378, 0x522F, 0xB379, 0xA34B,
+ 0x5230, 0x5231, 0x3C5B, 0x2E6A, 0, 0, 0x387B, 0x4C5E,
+};
+static const unsigned short utf8_to_euc_E58C[] = {
+ 0xB37B, 0x4C68, 0x4677, 0xB37C, 0, 0x4A71, 0x5232, 0xF432,
+ 0x5233, 0, 0xB37D, 0xB37E, 0xB421, 0x5235, 0, 0x5237,
+ 0x5236, 0xB422, 0, 0xB423, 0, 0x5238, 0x323D, 0x4B4C,
+ 0xB424, 0x3A7C, 0x5239, 0xB425, 0xB426, 0x4159, 0xB427, 0xB428,
+ 0x3E22, 0x3629, 0, 0x523A, 0xF433, 0xB429, 0, 0xB42A,
+ 0xB42B, 0xB42C, 0x485B, 0xB42D, 0xB42E, 0xB42F, 0, 0x523B,
+ 0xB430, 0x523C, 0xB431, 0x523D, 0, 0xB432, 0, 0,
+ 0x523E, 0x4924, 0x3668, 0x3065, 0xB433, 0xB434, 0xB435, 0x463F,
+};
+static const unsigned short utf8_to_euc_E58C_x0213[] = {
+ 0x2E6B, 0x4C68, 0x4677, 0xB37C, 0, 0x4A71, 0x5232, 0x2E6C,
+ 0x5233, 0, 0xA34C, 0xA34D, 0xB421, 0x5235, 0, 0x5237,
+ 0x5236, 0xB422, 0, 0xB423, 0, 0x5238, 0x323D, 0x4B4C,
+ 0xB424, 0x3A7C, 0x5239, 0xB425, 0x2E6D, 0x4159, 0xB427, 0xB428,
+ 0x3E22, 0x3629, 0, 0x523A, 0xA34E, 0xB429, 0, 0xB42A,
+ 0xB42B, 0xB42C, 0x485B, 0xB42D, 0xB42E, 0xB42F, 0, 0x523B,
+ 0xB430, 0x523C, 0xB431, 0x523D, 0, 0xA34F, 0, 0,
+ 0x523E, 0x4924, 0x3668, 0x3065, 0xB433, 0xB434, 0xA350, 0x463F,
+};
+static const unsigned short utf8_to_euc_E58D[] = {
+ 0x523F, 0x3D3D, 0xB436, 0x4069, 0, 0x5241, 0x5240, 0x3E23,
+ 0x3861, 0x5243, 0x483E, 0xB438, 0xB437, 0x5244, 0, 0,
+ 0, 0x485C, 0x4234, 0x426E, 0x3628, 0, 0, 0x466E,
+ 0x4331, 0xB439, 0x476E, 0xB43A, 0x4B4E, 0, 0x5246, 0,
+ 0x406A, 0xB43B, 0, 0xB43C, 0, 0xB43D, 0x3735, 0,
+ 0, 0x5247, 0, 0, 0xB43E, 0xB43F, 0x5248, 0x312C,
+ 0x3075, 0x346D, 0xB440, 0x4228, 0x3551, 0x4D71, 0, 0x524B,
+ 0x3237, 0xB441, 0, 0x524A, 0, 0, 0xB442, 0x362A,
+};
+static const unsigned short utf8_to_euc_E58D_x0213[] = {
+ 0x523F, 0x3D3D, 0xA351, 0x4069, 0, 0x5241, 0x5240, 0x3E23,
+ 0x3861, 0x5243, 0x483E, 0xB438, 0xB437, 0x5244, 0, 0,
+ 0, 0x485C, 0x4234, 0x426E, 0x3628, 0, 0, 0x466E,
+ 0x4331, 0xB439, 0x476E, 0xB43A, 0x4B4E, 0, 0x5246, 0,
+ 0x406A, 0x2E6F, 0, 0x2E70, 0, 0xB43D, 0x3735, 0xA354,
+ 0, 0x5247, 0, 0, 0xA355, 0xB43F, 0x5248, 0x312C,
+ 0x3075, 0x346D, 0xB440, 0x4228, 0x3551, 0x4D71, 0, 0x524B,
+ 0x3237, 0xB441, 0xA356, 0x524A, 0, 0x2E71, 0xB442, 0x362A,
+};
+static const unsigned short utf8_to_euc_E58E[] = {
+ 0, 0, 0x524C, 0xB443, 0x4C71, 0, 0, 0xB444,
+ 0xB445, 0, 0, 0, 0, 0, 0xB446, 0,
+ 0, 0, 0, 0xB447, 0xB448, 0, 0x524D, 0,
+ 0x4E52, 0xB449, 0x387C, 0, 0, 0xB44A, 0, 0x3836,
+ 0x524E, 0xB44B, 0, 0, 0xB44C, 0x5250, 0x524F, 0,
+ 0x3F5F, 0x3139, 0xB44D, 0xB44E, 0, 0x315E, 0x5251, 0xB44F,
+ 0x5252, 0, 0xB450, 0x3837, 0xB451, 0xB452, 0x5253, 0xB453,
+ 0xB454, 0, 0xB455, 0x356E, 0, 0xB456, 0, 0,
+};
+static const unsigned short utf8_to_euc_E58E_x0213[] = {
+ 0, 0, 0x524C, 0xB443, 0x4C71, 0, 0, 0xB444,
+ 0xB445, 0, 0, 0, 0, 0, 0xB446, 0,
+ 0, 0, 0, 0x2E72, 0xB448, 0, 0x524D, 0,
+ 0x4E52, 0xB449, 0x387C, 0, 0, 0x2E73, 0, 0x3836,
+ 0x524E, 0xB44B, 0, 0, 0xA357, 0x5250, 0x524F, 0,
+ 0x3F5F, 0x3139, 0xB44D, 0xB44E, 0, 0x315E, 0x5251, 0xB44F,
+ 0x5252, 0, 0x2E74, 0x3837, 0xA358, 0xB452, 0x5253, 0xA35A,
+ 0xB454, 0, 0xB455, 0x356E, 0, 0xB456, 0, 0,
+};
+static const unsigned short utf8_to_euc_E58F[] = {
+ 0xB457, 0, 0x3B32, 0x5254, 0, 0xB458, 0, 0,
+ 0x4B74, 0x3A35, 0x355A, 0x4D27, 0x4150, 0x483F, 0x3C7D, 0xB459,
+ 0, 0, 0xB45A, 0xB45B, 0x3D47, 0xB45C, 0x3C68, 0x3C75,
+ 0, 0x3D76, 0xB45D, 0x4840, 0, 0xB45E, 0xB45F, 0x5257,
+ 0xB460, 0x3143, 0x4151, 0x387D, 0x3845, 0x3667, 0xB461, 0xB462,
+ 0x525B, 0x4321, 0x427E, 0x362B, 0x3E24, 0x525C, 0x525A, 0x3244,
+ 0x4266, 0x3C38, 0x3B4B, 0x3126, 0, 0xB463, 0x3370, 0x3966,
+ 0x3B4A, 0, 0x525D, 0, 0, 0, 0, 0,
+};
+static const unsigned short utf8_to_euc_E58F_x0213[] = {
+ 0xA35B, 0, 0x3B32, 0x5254, 0, 0xB458, 0, 0,
+ 0x4B74, 0x3A35, 0x355A, 0x4D27, 0x4150, 0x483F, 0x3C7D, 0xB459,
+ 0, 0, 0xB45A, 0xB45B, 0x3D47, 0xA35F, 0x3C68, 0x3C75,
+ 0, 0x3D76, 0xA360, 0x4840, 0, 0xB45E, 0xB45F, 0x5257,
+ 0xB460, 0x3143, 0x4151, 0x387D, 0x3845, 0x3667, 0xB461, 0xB462,
+ 0x525B, 0x4321, 0x427E, 0x362B, 0x3E24, 0x525C, 0x525A, 0x3244,
+ 0x4266, 0x3C38, 0x3B4B, 0x3126, 0xA362, 0xA363, 0x3370, 0x3966,
+ 0x3B4A, 0, 0x525D, 0, 0, 0, 0, 0,
+};
+static const unsigned short utf8_to_euc_E590[] = {
+ 0, 0x525E, 0xB464, 0x3549, 0x3346, 0, 0, 0,
+ 0x3967, 0x3548, 0x445F, 0x3125, 0x4631, 0x4C3E, 0x3921, 0x4D79,
+ 0x4547, 0x387E, 0, 0xB465, 0, 0, 0, 0,
+ 0, 0, 0xB466, 0x372F, 0, 0x5267, 0, 0x3663,
+ 0x4B4A, 0xB467, 0, 0, 0, 0, 0x485D, 0xB468,
+ 0xB469, 0x5266, 0xB46A, 0x345E, 0x5261, 0x5262, 0x5264, 0xB46B,
+ 0, 0xB46C, 0, 0, 0xB46D, 0xB46E, 0x5265, 0,
+ 0x355B, 0x3F61, 0, 0x4A2D, 0x5263, 0x525F, 0x3863, 0,
+};
+static const unsigned short utf8_to_euc_E590_x0213[] = {
+ 0, 0x525E, 0xB464, 0x3549, 0x3346, 0, 0, 0,
+ 0x3967, 0x3548, 0x445F, 0x3125, 0x4631, 0x4C3E, 0x3921, 0x4D79,
+ 0x4547, 0x387E, 0x2E75, 0xB465, 0, 0, 0, 0,
+ 0, 0, 0xB466, 0x372F, 0, 0x5267, 0x4F7E, 0x3663,
+ 0x4B4A, 0xB467, 0, 0, 0xA365, 0, 0x485D, 0x2E76,
+ 0xA366, 0x5266, 0xB46A, 0x345E, 0x5261, 0x5262, 0x5264, 0xB46B,
+ 0, 0xB46C, 0, 0, 0xB46D, 0xB46E, 0x5265, 0,
+ 0x355B, 0x3F61, 0, 0x4A2D, 0x5263, 0x525F, 0x3863, 0,
+};
+static const unsigned short utf8_to_euc_E591[] = {
+ 0x5260, 0, 0x4F24, 0xB46F, 0xB470, 0, 0x4A72, 0xB471,
+ 0x4468, 0x3862, 0x3970, 0, 0, 0xB472, 0x5268, 0xB473,
+ 0, 0x465D, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0xB474, 0x526C,
+ 0, 0, 0xB475, 0, 0xB476, 0, 0xB477, 0xB478,
+ 0x3C7E, 0xB479, 0x3C76, 0xB47A, 0, 0xB47B, 0xB47C, 0,
+ 0x526F, 0x526D, 0, 0x4C23, 0xB47D, 0x526A, 0x5273, 0x526E,
+ 0, 0, 0, 0x5271, 0x3846, 0x4C3F, 0, 0xB47E,
+};
+static const unsigned short utf8_to_euc_E591_x0213[] = {
+ 0x5260, 0, 0x4F24, 0xA368, 0xB470, 0, 0x4A72, 0xB471,
+ 0x4468, 0x3862, 0x3970, 0, 0, 0x2E77, 0x5268, 0xB473,
+ 0, 0x465D, 0, 0, 0, 0xA364, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0xB474, 0x526C,
+ 0, 0, 0xA369, 0, 0xB476, 0, 0xA36A, 0xB478,
+ 0x3C7E, 0xB479, 0x3C76, 0x2E79, 0xA36B, 0xB47B, 0xB47C, 0,
+ 0x526F, 0x526D, 0, 0x4C23, 0x2E7A, 0x526A, 0x5273, 0x526E,
+ 0, 0, 0, 0x5271, 0x3846, 0x4C3F, 0, 0x2E7B,
+};
+static const unsigned short utf8_to_euc_E592[] = {
+ 0x5272, 0xB521, 0, 0xB522, 0x5274, 0xB523, 0x5276, 0,
+ 0xB524, 0xB525, 0xF435, 0x3A70, 0x4F42, 0xB526, 0x526B, 0x5269,
+ 0x5275, 0xB527, 0x5270, 0, 0, 0xB528, 0xB529, 0,
+ 0, 0, 0, 0, 0xB52A, 0, 0, 0xB52B,
+ 0, 0xB52C, 0x5278, 0, 0x5323, 0x527A, 0xB52D, 0xB52E,
+ 0x527E, 0xB52F, 0xB530, 0x5321, 0x527B, 0xB531, 0xB532, 0x533E,
+ 0, 0xB533, 0x3A69, 0x3331, 0, 0, 0, 0xB534,
+ 0x5279, 0xB535, 0xB536, 0xB537, 0x5325, 0x3076, 0x5324, 0xB538,
+};
+static const unsigned short utf8_to_euc_E592_x0213[] = {
+ 0x5272, 0xB521, 0, 0xB522, 0x5274, 0xB523, 0x5276, 0,
+ 0x2E7C, 0xB525, 0xA36C, 0x3A70, 0x4F42, 0xA36D, 0x526B, 0x5269,
+ 0x5275, 0xB527, 0x5270, 0, 0, 0xA36E, 0x2E7D, 0,
+ 0, 0, 0, 0, 0x2E78, 0, 0, 0xB52B,
+ 0xA36F, 0x2E7E, 0x5278, 0, 0x5323, 0x527A, 0xA370, 0xB52E,
+ 0x527E, 0x2F21, 0xB530, 0x5321, 0x527B, 0xA371, 0xA372, 0x533E,
+ 0, 0xB533, 0x3A69, 0x3331, 0, 0, 0, 0xA373,
+ 0x5279, 0xB535, 0xA374, 0xB537, 0x5325, 0x3076, 0x5324, 0xA375,
+};
+static const unsigned short utf8_to_euc_E593[] = {
+ 0x3025, 0x494A, 0x5322, 0, 0x527C, 0, 0xB539, 0x5277,
+ 0x527D, 0x3A48, 0xB53A, 0, 0, 0xB53B, 0xB53C, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0x5326, 0, 0, 0, 0, 0, 0, 0,
+ 0xB53D, 0x3077, 0x532F, 0, 0, 0x5327, 0x5328, 0,
+ 0x3E25, 0x4B69, 0xB53E, 0, 0xB53F, 0x532D, 0x532C, 0xB540,
+ 0, 0, 0x452F, 0, 0, 0, 0xB541, 0,
+ 0, 0, 0x532E, 0, 0xB542, 0x532B, 0xB543, 0xB544,
+};
+static const unsigned short utf8_to_euc_E593_x0213[] = {
+ 0x3025, 0x494A, 0x5322, 0xA376, 0x527C, 0, 0x2F22, 0x5277,
+ 0x527D, 0x3A48, 0xB53A, 0, 0, 0xB53B, 0xB53C, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0x5326, 0, 0, 0, 0, 0, 0, 0,
+ 0xB53D, 0x3077, 0x532F, 0, 0, 0x5327, 0x5328, 0,
+ 0x3E25, 0x4B69, 0xB53E, 0, 0xA378, 0x532D, 0x532C, 0xA379,
+ 0, 0xA37A, 0x452F, 0xA37B, 0, 0, 0xB541, 0,
+ 0, 0, 0x532E, 0, 0xB542, 0x532B, 0xB543, 0x2F23,
+};
+static const unsigned short utf8_to_euc_E594[] = {
+ 0xB545, 0xB546, 0, 0, 0x3134, 0xB547, 0x3A36, 0x3F30,
+ 0xB548, 0xB549, 0, 0, 0xB54A, 0xB54B, 0xB54C, 0x5329,
+ 0x4562, 0, 0, 0, 0x532A, 0xB54D, 0x3022, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0xB54E, 0xB54F, 0, 0, 0x5334, 0x4D23,
+ 0, 0x3E27, 0xB550, 0x533A, 0, 0xB551, 0xB552, 0,
+ 0x5339, 0x5330, 0, 0xB553, 0xB554, 0xB555, 0x4243, 0,
+};
+static const unsigned short utf8_to_euc_E594_x0213[] = {
+ 0xA37C, 0xA37D, 0, 0, 0x3134, 0xB547, 0x3A36, 0x3F30,
+ 0xB548, 0xA37E, 0, 0, 0xB54A, 0xB54B, 0x2F24, 0x5329,
+ 0x4562, 0, 0, 0, 0x532A, 0xB54D, 0x3022, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0xB54E, 0x2F25, 0, 0, 0x5334, 0x4D23,
+ 0, 0x3E27, 0xB550, 0x533A, 0, 0x2F26, 0xB552, 0,
+ 0x5339, 0x5330, 0, 0xB553, 0xA421, 0xB555, 0x4243, 0,
+};
+static const unsigned short utf8_to_euc_E595[] = {
+ 0x5331, 0xB556, 0, 0, 0x426F, 0x5336, 0x3E26, 0xB557,
+ 0, 0xB558, 0xB559, 0, 0x5333, 0xB55A, 0, 0x4C64,
+ 0xB55B, 0xB55C, 0, 0x373C, 0, 0, 0x5337, 0x5338,
+ 0xB55D, 0, 0xB55E, 0xB55F, 0x5335, 0x533B, 0xB560, 0,
+ 0xB561, 0xB562, 0, 0x5332, 0xB563, 0, 0xB564, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0x5341, 0x5346, 0, 0x5342, 0xB565,
+};
+static const unsigned short utf8_to_euc_E595_x0213[] = {
+ 0x5331, 0xA422, 0, 0, 0x426F, 0x5336, 0x3E26, 0xA424,
+ 0, 0xB558, 0xA425, 0, 0x5333, 0xB55A, 0, 0x4C64,
+ 0x2F27, 0xB55C, 0, 0x373C, 0, 0, 0x5337, 0x5338,
+ 0xB55D, 0, 0xB55E, 0xB55F, 0x5335, 0x533B, 0x2F28, 0,
+ 0xA427, 0xA428, 0, 0x5332, 0xA429, 0, 0xB564, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0x5341, 0x5346, 0xA42B, 0x5342, 0xB565,
+};
+static const unsigned short utf8_to_euc_E596[] = {
+ 0x533D, 0xB566, 0xB567, 0x5347, 0x4131, 0, 0xB568, 0x5349,
+ 0xB569, 0x3922, 0x533F, 0x437D, 0, 0, 0xB56A, 0xB56B,
+ 0, 0xB56C, 0xB56D, 0xB56E, 0xB56F, 0, 0, 0xB570,
+ 0x5343, 0x533C, 0x342D, 0, 0x346E, 0x3365, 0x5344, 0x5340,
+ 0, 0, 0, 0xB571, 0xB572, 0, 0, 0x3776,
+ 0x534A, 0x5348, 0x4153, 0x354A, 0x362C, 0xB573, 0x5345, 0,
+ 0x3674, 0, 0xB574, 0, 0, 0, 0x3144, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0xB575,
+};
+static const unsigned short utf8_to_euc_E596_x0213[] = {
+ 0x533D, 0x2F29, 0xA42C, 0x5347, 0x4131, 0, 0x2F2A, 0x5349,
+ 0xA42D, 0x3922, 0x533F, 0x437D, 0, 0, 0x2F2B, 0xB56B,
+ 0, 0xA42E, 0xB56D, 0xB56E, 0xB56F, 0, 0, 0xB570,
+ 0x5343, 0x533C, 0x342D, 0, 0x346E, 0x3365, 0x5344, 0x5340,
+ 0, 0, 0, 0xB571, 0xB572, 0, 0, 0x3776,
+ 0x534A, 0x5348, 0x4153, 0x354A, 0x362C, 0x2F2D, 0x5345, 0,
+ 0x3674, 0, 0xB574, 0, 0, 0, 0x3144, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0xA433,
+};
+static const unsigned short utf8_to_euc_E597[] = {
+ 0, 0xB576, 0, 0xB577, 0x534E, 0x534C, 0xB578, 0x5427,
+ 0, 0xB579, 0, 0xB57A, 0xB57B, 0, 0xB57C, 0,
+ 0, 0xB57D, 0xB57E, 0xB621, 0x5351, 0, 0, 0xB622,
+ 0xB623, 0, 0x534B, 0xB624, 0x534F, 0, 0xB625, 0x534D,
+ 0, 0, 0xB626, 0x3B4C, 0x5350, 0, 0, 0,
+ 0, 0xB627, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0xB628, 0x5353,
+ 0, 0x5358, 0, 0, 0, 0x5356, 0x5355, 0xB629,
+};
+static const unsigned short utf8_to_euc_E597_x0213[] = {
+ 0, 0xB576, 0, 0xB577, 0x534E, 0x534C, 0xB578, 0x5427,
+ 0, 0xA434, 0, 0xB57A, 0xA435, 0, 0x2F2E, 0,
+ 0, 0xA436, 0xA430, 0xB621, 0x5351, 0, 0, 0xB622,
+ 0xB623, 0, 0x534B, 0xB624, 0x534F, 0xA437, 0xB625, 0x534D,
+ 0, 0, 0xA439, 0x3B4C, 0x5350, 0, 0, 0,
+ 0, 0xA43B, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0xB628, 0x5353,
+ 0, 0x5358, 0, 0, 0, 0x5356, 0x5355, 0xB629,
+};
+static const unsigned short utf8_to_euc_E598[] = {
+ 0, 0, 0, 0, 0, 0xB62A, 0x4332, 0,
+ 0xB62B, 0x3245, 0xB62C, 0, 0, 0xB62D, 0xB62E, 0xB62F,
+ 0xB630, 0xB631, 0xB632, 0, 0x5352, 0, 0x5354, 0x3E28,
+ 0x3133, 0xB633, 0, 0x5357, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0x325E, 0, 0, 0xB634, 0, 0, 0x5362,
+ 0xB635, 0x3E7C, 0x535E, 0xB636, 0x535C, 0xB637, 0x535D, 0xB638,
+ 0x535F, 0xB639, 0, 0xB63A, 0xB63B, 0xB63C, 0, 0xB63D,
+};
+static const unsigned short utf8_to_euc_E598_x0213[] = {
+ 0, 0, 0, 0, 0, 0xB62A, 0x4332, 0xA43E,
+ 0x2F30, 0x3245, 0xB62C, 0, 0, 0xB62D, 0x2F31, 0xB62F,
+ 0xA43F, 0xB631, 0xB632, 0, 0x5352, 0, 0x5354, 0x3E28,
+ 0x3133, 0xB633, 0, 0x5357, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0xA43C, 0x325E, 0, 0, 0xB634, 0, 0, 0x5362,
+ 0xA440, 0x3E7C, 0x535E, 0xB636, 0x535C, 0xB637, 0x535D, 0xA441,
+ 0x535F, 0xB639, 0, 0x2F32, 0xB63B, 0xA443, 0, 0xA444,
+};
+static const unsigned short utf8_to_euc_E599[] = {
+ 0xB63E, 0xB63F, 0x313D, 0xB640, 0xB641, 0, 0xB642, 0,
+ 0, 0xB643, 0, 0xB644, 0x4139, 0xB645, 0x5359, 0xB646,
+ 0x535A, 0, 0, 0, 0xB647, 0, 0, 0,
+ 0, 0, 0, 0x337A, 0, 0, 0xB648, 0,
+ 0xB649, 0xB64A, 0xB64B, 0xB64C, 0x5361, 0, 0xB64D, 0,
+ 0x346F, 0xB64E, 0x5364, 0x5360, 0x5363, 0xB64F, 0, 0xB650,
+ 0, 0xB651, 0xB652, 0, 0x4A2E, 0xB653, 0, 0,
+ 0x4655, 0, 0x4838, 0, 0, 0, 0, 0,
+};
+static const unsigned short utf8_to_euc_E599_x0213[] = {
+ 0xA445, 0xB63F, 0x313D, 0xB640, 0xB641, 0, 0xB642, 0xA446,
+ 0, 0x2F33, 0, 0xB644, 0x4139, 0xB645, 0x5359, 0xB646,
+ 0x535A, 0, 0, 0x7427, 0xB647, 0, 0, 0,
+ 0, 0, 0, 0x337A, 0, 0, 0xA447, 0,
+ 0xA448, 0xB64A, 0xB64B, 0xB64C, 0x5361, 0, 0x2F35, 0,
+ 0x346F, 0xB64E, 0x5364, 0x5360, 0x5363, 0xA449, 0, 0x2F37,
+ 0, 0x2F38, 0x2F39, 0, 0x4A2E, 0xB653, 0x2F34, 0,
+ 0x4655, 0, 0x4838, 0, 0, 0, 0, 0,
+};
+static const unsigned short utf8_to_euc_E59A[] = {
+ 0x5366, 0, 0, 0, 0xB654, 0xB655, 0x5365, 0x3345,
+ 0xB656, 0, 0x5367, 0xB657, 0xB658, 0, 0, 0x536A,
+ 0, 0, 0, 0, 0x5369, 0xB659, 0, 0,
+ 0, 0xB65A, 0xB65B, 0, 0, 0xB65C, 0xB65D, 0xB65E,
+ 0x5368, 0, 0x4739, 0, 0, 0x536B, 0xB65F, 0xB660,
+ 0xB661, 0xB662, 0, 0xB663, 0xB664, 0xB665, 0x536C, 0,
+ 0, 0xB666, 0, 0xB667, 0x536E, 0, 0x536D, 0xB668,
+ 0, 0, 0, 0, 0x5370, 0, 0xB669, 0,
+};
+static const unsigned short utf8_to_euc_E59A_x0213[] = {
+ 0x5366, 0, 0, 0, 0xB654, 0xB655, 0x5365, 0x3345,
+ 0xA44B, 0, 0x5367, 0xB657, 0xA44C, 0, 0, 0x536A,
+ 0, 0, 0, 0, 0x5369, 0xA44D, 0, 0,
+ 0, 0x2F3A, 0xA44E, 0, 0, 0xA44F, 0x2F3B, 0xB65E,
+ 0x5368, 0, 0x4739, 0, 0, 0x536B, 0xB65F, 0xB660,
+ 0xA450, 0x2F3C, 0, 0xB663, 0x2F3D, 0xA451, 0x536C, 0,
+ 0, 0xB666, 0xA452, 0x2F3E, 0x536E, 0, 0x536D, 0xB668,
+ 0, 0, 0, 0, 0x5370, 0, 0xB669, 0,
+};
+static const unsigned short utf8_to_euc_E59B[] = {
+ 0x5373, 0x5371, 0x536F, 0x5372, 0, 0xB66A, 0, 0,
+ 0x5374, 0xB66B, 0xB66C, 0xB66D, 0xB670, 0xB671, 0x5375, 0xB66E,
+ 0xB66F, 0x5376, 0, 0x5377, 0, 0, 0, 0x5378,
+ 0x5145, 0xB672, 0x3C7C, 0x3B4D, 0xB673, 0xB674, 0x3273, 0xB675,
+ 0x3078, 0xB676, 0, 0x4344, 0xB677, 0xB678, 0xB679, 0xB67A,
+ 0xB67B, 0, 0, 0xB67D, 0, 0xB67E, 0x5379, 0,
+ 0x3A24, 0xB67C, 0x304F, 0x3F5E, 0, 0, 0xB721, 0xB722,
+ 0, 0x537A, 0x3847, 0, 0, 0x3971, 0, 0x537C,
+};
+static const unsigned short utf8_to_euc_E59B_x0213[] = {
+ 0x5373, 0x5371, 0x536F, 0x5372, 0, 0xA453, 0, 0,
+ 0x5374, 0x2F3F, 0x2F40, 0xB66D, 0xB670, 0xA454, 0x5375, 0xB66E,
+ 0xB66F, 0x5376, 0, 0x5377, 0, 0, 0, 0x5378,
+ 0x5145, 0xB672, 0x3C7C, 0x3B4D, 0xB673, 0xB674, 0x3273, 0xA455,
+ 0x3078, 0xB676, 0, 0x4344, 0xB677, 0xB678, 0xB679, 0xB67A,
+ 0xA456, 0, 0, 0xB67D, 0, 0xB67E, 0x5379, 0,
+ 0x3A24, 0xB67C, 0x304F, 0x3F5E, 0, 0, 0xA457, 0xA458,
+ 0, 0x537A, 0x3847, 0, 0, 0x3971, 0, 0x537C,
+};
+static const unsigned short utf8_to_euc_E59C[] = {
+ 0x537B, 0xB723, 0xB724, 0x4A60, 0x537D, 0, 0, 0xB725,
+ 0x5421, 0x537E, 0xB726, 0x5422, 0xB727, 0x5423, 0, 0x3777,
+ 0, 0xB728, 0x3160, 0x5424, 0, 0xB729, 0x5426, 0,
+ 0x5425, 0, 0xB72A, 0xB72B, 0x5428, 0xB72C, 0, 0x455A,
+ 0xB72D, 0, 0xB72E, 0xB72F, 0xB730, 0xB731, 0x5429, 0x3035,
+ 0x3A5F, 0xB732, 0xB733, 0, 0xB734, 0x373D, 0xB735, 0xB736,
+ 0x434F, 0, 0, 0xB737, 0xB738, 0, 0, 0x542A,
+ 0x542B, 0, 0, 0x542D, 0, 0xB739, 0xB73A, 0xB73B,
+};
+static const unsigned short utf8_to_euc_E59C_x0213[] = {
+ 0x537B, 0xB723, 0xB724, 0x4A60, 0x537D, 0, 0, 0xB725,
+ 0x5421, 0x537E, 0x2F41, 0x5422, 0xB727, 0x5423, 0, 0x3777,
+ 0, 0xB728, 0x3160, 0x5424, 0, 0xA45A, 0x5426, 0,
+ 0x5425, 0, 0xB72A, 0xB72B, 0x5428, 0xB72C, 0, 0x455A,
+ 0xB72D, 0x2F43, 0xB72E, 0xA45B, 0xB730, 0xB731, 0x5429, 0x3035,
+ 0x3A5F, 0xA45D, 0xB733, 0, 0xB734, 0x373D, 0xB735, 0x2F44,
+ 0x434F, 0, 0, 0x2F45, 0x2F46, 0, 0, 0x542A,
+ 0x542B, 0, 0, 0x542D, 0, 0xB739, 0xB73A, 0xB73B,
+};
+static const unsigned short utf8_to_euc_E59D[] = {
+ 0x542E, 0, 0x3A64, 0, 0, 0xB73C, 0xB73D, 0x3651,
+ 0, 0, 0x4B37, 0, 0xB73E, 0xB73F, 0x542C, 0x542F,
+ 0x3A41, 0x3923, 0xB740, 0, 0, 0, 0, 0,
+ 0, 0xF436, 0, 0, 0, 0, 0, 0,
+ 0, 0x5433, 0xB741, 0, 0x3A25, 0xB742, 0x4333, 0xB743,
+ 0xB744, 0x5430, 0x445A, 0xB745, 0, 0xB746, 0xB747, 0xB748,
+ 0xB749, 0xB74A, 0, 0xB74B, 0xB74C, 0xB74D, 0, 0xB74E,
+ 0, 0xB74F, 0xB750, 0xB751, 0xB752, 0, 0xB753, 0x5434,
+};
+static const unsigned short utf8_to_euc_E59D_x0213[] = {
+ 0x542E, 0, 0x3A64, 0, 0, 0xA45F, 0xA460, 0x3651,
+ 0, 0, 0x4B37, 0, 0xA461, 0xA462, 0x542C, 0x542F,
+ 0x3A41, 0x3923, 0xB740, 0, 0, 0, 0, 0,
+ 0, 0xF436, 0, 0, 0, 0, 0, 0,
+ 0, 0x5433, 0xB741, 0, 0x3A25, 0xB742, 0x4333, 0xB743,
+ 0xA464, 0x5430, 0x445A, 0xB745, 0, 0xB746, 0xB747, 0xA465,
+ 0x2F47, 0xB74A, 0, 0xA466, 0xA467, 0xA468, 0, 0x2F48,
+ 0, 0xB74F, 0xB750, 0xA469, 0x2F49, 0, 0xB753, 0x5434,
+};
+static const unsigned short utf8_to_euc_E59E[] = {
+ 0, 0xB754, 0x3F62, 0xB755, 0, 0, 0, 0,
+ 0x5432, 0x5435, 0, 0x373F, 0xB756, 0, 0, 0,
+ 0, 0, 0, 0x5436, 0xB757, 0xB760, 0, 0xB758,
+ 0, 0xB759, 0xB75A, 0, 0xB75B, 0xB75C, 0xB75D, 0xB75E,
+ 0x5437, 0xB75F, 0x3924, 0x3340, 0x5439, 0, 0, 0xB761,
+ 0xB762, 0xB763, 0x543A, 0, 0xB764, 0, 0, 0,
+ 0x543B, 0, 0, 0x5438, 0, 0, 0, 0,
+ 0xB765, 0, 0, 0, 0, 0xB766, 0, 0,
+};
+static const unsigned short utf8_to_euc_E59E_x0213[] = {
+ 0, 0xB754, 0x3F62, 0xB755, 0, 0, 0, 0,
+ 0x5432, 0x5435, 0, 0x373F, 0xB756, 0, 0, 0,
+ 0, 0, 0, 0x5436, 0xB757, 0xB760, 0, 0xB758,
+ 0, 0xB759, 0xA46D, 0, 0x2F4A, 0xA46E, 0xA46F, 0xB75E,
+ 0x5437, 0xB75F, 0x3924, 0x3340, 0x5439, 0, 0, 0xB761,
+ 0xA470, 0xB763, 0x543A, 0, 0xA46C, 0, 0, 0,
+ 0x543B, 0, 0, 0x5438, 0, 0, 0, 0,
+ 0x2F4D, 0, 0, 0, 0, 0xB766, 0, 0,
+};
+static const unsigned short utf8_to_euc_E59F[] = {
+ 0x5431, 0, 0, 0x543C, 0, 0, 0x543D, 0xB767,
+ 0xB768, 0, 0, 0x4B64, 0xB769, 0, 0x3E6B, 0xB76A,
+ 0, 0, 0x543F, 0x5440, 0x543E, 0xB76B, 0x5442, 0,
+ 0, 0, 0, 0, 0x4738, 0xB76C, 0xB76D, 0x3068,
+ 0x4956, 0xB77E, 0, 0x5443, 0xB76E, 0, 0xB76F, 0xB770,
+ 0, 0xB771, 0, 0, 0, 0xB772, 0, 0,
+ 0xB773, 0, 0, 0, 0x3E7D, 0xB774, 0xB775, 0x3C39,
+ 0xB776, 0x475D, 0x3470, 0, 0x3A6B, 0xB777, 0xB778, 0xB779,
+};
+static const unsigned short utf8_to_euc_E59F_x0213[] = {
+ 0x5431, 0, 0, 0x543C, 0, 0, 0x543D, 0x2F4E,
+ 0x2F4F, 0, 0, 0x4B64, 0xA473, 0, 0x3E6B, 0x2F50,
+ 0, 0, 0x543F, 0x5440, 0x543E, 0xB76B, 0x5442, 0xA471,
+ 0, 0, 0, 0, 0x4738, 0xB76C, 0xA476, 0x3068,
+ 0x4956, 0xB77E, 0, 0x5443, 0x2F51, 0, 0xA477, 0xB770,
+ 0, 0xB771, 0, 0, 0, 0x2F52, 0, 0,
+ 0xA478, 0, 0, 0, 0x3E7D, 0x2F53, 0x2F54, 0x3C39,
+ 0xA47A, 0x475D, 0x3470, 0xA47B, 0x3A6B, 0xA47C, 0xB778, 0x2F55,
+};
+static const unsigned short utf8_to_euc_E5A0[] = {
+ 0x4B59, 0, 0x4632, 0xB77A, 0xB77B, 0x3778, 0x424F, 0,
+ 0xB77C, 0xB77D, 0x5441, 0x5444, 0xB821, 0xB822, 0, 0,
+ 0, 0, 0, 0, 0, 0x4244, 0, 0,
+ 0, 0x5445, 0, 0xB823, 0, 0x5446, 0xB824, 0xB825,
+ 0xB826, 0x5448, 0, 0, 0x4469, 0, 0xB827, 0xB828,
+ 0, 0, 0x342E, 0, 0, 0xB829, 0, 0x7421,
+ 0x3161, 0x4A73, 0xB82A, 0, 0x3E6C, 0x4548, 0, 0,
+ 0, 0xB82B, 0x3A66, 0, 0, 0x544E, 0, 0xB82C,
+};
+static const unsigned short utf8_to_euc_E5A0_x0213[] = {
+ 0x4B59, 0, 0x4632, 0xB77A, 0xA47D, 0x3778, 0x424F, 0,
+ 0xB77C, 0x2F56, 0x5441, 0x5444, 0xB821, 0xB822, 0, 0,
+ 0, 0, 0, 0, 0, 0x4244, 0, 0,
+ 0, 0x5445, 0, 0xB823, 0, 0x5446, 0xA47E, 0xB825,
+ 0xA521, 0x5448, 0, 0, 0x4469, 0, 0xB827, 0xA522,
+ 0, 0, 0x342E, 0, 0, 0xB829, 0, 0x7421,
+ 0x3161, 0x4A73, 0xA523, 0, 0x3E6C, 0x4548, 0, 0,
+ 0, 0xA524, 0x3A66, 0, 0, 0x544E, 0, 0xB82C,
+};
+static const unsigned short utf8_to_euc_E5A1[] = {
+ 0x4A3D, 0x4E5D, 0, 0, 0, 0, 0, 0,
+ 0, 0xB82D, 0x3274, 0x544A, 0xB82E, 0xB82F, 0, 0xB830,
+ 0xB831, 0x413A, 0x544D, 0, 0x4563, 0xB832, 0, 0x4549,
+ 0x4564, 0x4839, 0x444D, 0, 0, 0, 0x3A49, 0xB833,
+ 0, 0xB834, 0x5449, 0, 0xB835, 0, 0, 0xB836,
+ 0xB837, 0x3176, 0, 0x4536, 0, 0, 0, 0,
+ 0x544B, 0, 0x5447, 0, 0, 0x3F50, 0, 0,
+ 0xB838, 0x544F, 0, 0, 0xB839, 0, 0x3D4E, 0xB83A,
+};
+static const unsigned short utf8_to_euc_E5A1_x0213[] = {
+ 0x4A3D, 0x4E5D, 0, 0, 0, 0, 0, 0,
+ 0, 0xA526, 0x3274, 0x544A, 0xA527, 0xB82F, 0, 0xB830,
+ 0xB831, 0x413A, 0x544D, 0, 0x4563, 0xB832, 0, 0x4549,
+ 0x4564, 0x4839, 0x444D, 0, 0, 0, 0x3A49, 0xB833,
+ 0, 0x2F58, 0x5449, 0, 0x2F59, 0, 0, 0xA528,
+ 0xB837, 0x3176, 0, 0x4536, 0, 0, 0, 0,
+ 0x544B, 0, 0x5447, 0, 0, 0x3F50, 0, 0,
+ 0xB838, 0x544F, 0, 0, 0x2F5B, 0, 0x3D4E, 0xB83A,
+};
+static const unsigned short utf8_to_euc_E5A2[] = {
+ 0xB83B, 0xB83C, 0, 0x362D, 0, 0x5450, 0, 0xB83D,
+ 0xB83E, 0xB83F, 0xB840, 0, 0xB841, 0xB842, 0, 0xB843,
+ 0xB844, 0, 0, 0x4A68, 0xB845, 0, 0xB846, 0x417D,
+ 0, 0, 0, 0, 0x4446, 0xB847, 0xF439, 0x5452,
+ 0xB848, 0xB849, 0xB84A, 0, 0, 0, 0xB84B, 0,
+ 0x4B4F, 0xB84C, 0, 0x5453, 0, 0, 0x5458, 0,
+ 0, 0xB84D, 0xB84E, 0x4A2F, 0, 0, 0, 0,
+ 0x5457, 0x5451, 0x5454, 0x5456, 0xB850, 0, 0x3A26, 0,
+};
+static const unsigned short utf8_to_euc_E5A2_x0213[] = {
+ 0xB83B, 0xB83C, 0, 0x362D, 0, 0x5450, 0, 0xB83D,
+ 0xB83E, 0x2F5C, 0xA529, 0xA52A, 0xB841, 0xA52B, 0, 0xA52C,
+ 0xA52D, 0, 0, 0x4A68, 0xA52E, 0, 0xB846, 0x417D,
+ 0, 0, 0, 0, 0x4446, 0xA52F, 0x2F5D, 0x5452,
+ 0xB848, 0xB849, 0xB84A, 0, 0, 0, 0xB84B, 0,
+ 0x4B4F, 0x2F5F, 0xA530, 0x5453, 0, 0, 0x5458, 0,
+ 0, 0xA531, 0xB84E, 0x4A2F, 0, 0, 0, 0,
+ 0x5457, 0x5451, 0x5454, 0x5456, 0xB850, 0, 0x3A26, 0,
+};
+static const unsigned short utf8_to_euc_E5A3[] = {
+ 0, 0x4A49, 0xB851, 0, 0xB84F, 0x5459, 0, 0x4345,
+ 0xB852, 0, 0x3275, 0, 0x3E6D, 0xB853, 0xB854, 0,
+ 0xB855, 0x545B, 0xB856, 0x545A, 0xB857, 0x3968, 0xB858, 0x545C,
+ 0x545E, 0x545D, 0xB859, 0, 0x5460, 0xB85A, 0x5455, 0x5462,
+ 0, 0xB85B, 0xB85C, 0, 0x5461, 0x545F, 0, 0,
+ 0, 0xB85D, 0, 0x3B4E, 0x3F51, 0, 0x4154, 0x5463,
+ 0x403C, 0x306D, 0x4764, 0xB85E, 0, 0, 0, 0x445B,
+ 0, 0x5465, 0x5464, 0x5466, 0x5467, 0x5468, 0, 0,
+};
+static const unsigned short utf8_to_euc_E5A3_x0213[] = {
+ 0, 0x4A49, 0xB851, 0xA533, 0xB84F, 0x5459, 0, 0x4345,
+ 0xB852, 0, 0x3275, 0, 0x3E6D, 0xA534, 0x2F62, 0,
+ 0xB855, 0x545B, 0x2F61, 0x545A, 0x2F63, 0x3968, 0xB858, 0x545C,
+ 0x545E, 0x545D, 0x2F64, 0, 0x5460, 0xB85A, 0x5455, 0x5462,
+ 0x2F65, 0xB85B, 0xA535, 0, 0x5461, 0x545F, 0, 0,
+ 0, 0x2F66, 0, 0x3B4E, 0x3F51, 0, 0x4154, 0x5463,
+ 0x403C, 0x306D, 0x4764, 0xA536, 0xA537, 0, 0, 0x445B,
+ 0, 0x5465, 0x5464, 0x5466, 0x5467, 0x5468, 0, 0,
+};
+static const unsigned short utf8_to_euc_E5A4[] = {
+ 0, 0, 0x5469, 0, 0, 0xB85F, 0xB860, 0,
+ 0, 0x4A51, 0x546A, 0xB861, 0xB862, 0, 0, 0x3246,
+ 0x546B, 0, 0xB863, 0xB864, 0xB865, 0x4D3C, 0x3330, 0,
+ 0x5249, 0x3D48, 0x423F, 0x546C, 0x4C6B, 0xB867, 0, 0,
+ 0, 0xB868, 0x4C34, 0xB869, 0xB86A, 0x546E, 0, 0x4267,
+ 0xB86B, 0x4537, 0x4240, 0x4957, 0x546F, 0x5470, 0x317B, 0xB86C,
+ 0xB86D, 0x3C3A, 0x5471, 0xB86E, 0, 0xB86F, 0xB870, 0x3050,
+ 0x5472, 0, 0, 0, 0, 0, 0x5473, 0xB871,
+};
+static const unsigned short utf8_to_euc_E5A4_x0213[] = {
+ 0, 0, 0x5469, 0, 0, 0xA538, 0xA539, 0,
+ 0, 0x4A51, 0x546A, 0xA53A, 0x2F67, 0xA53B, 0, 0x3246,
+ 0x546B, 0, 0xB863, 0xB864, 0xA53C, 0x4D3C, 0x3330, 0,
+ 0x5249, 0x3D48, 0x423F, 0x546C, 0x4C6B, 0xB867, 0, 0,
+ 0, 0xB868, 0x4C34, 0xB869, 0xA53D, 0x546E, 0, 0x4267,
+ 0xB86B, 0x4537, 0x4240, 0x4957, 0x546F, 0x5470, 0x317B, 0xB86C,
+ 0xB86D, 0x3C3A, 0x5471, 0xB86E, 0, 0xB86F, 0xB870, 0x3050,
+ 0x5472, 0, 0, 0, 0, 0xA540, 0x5473, 0xB871,
+};
+static const unsigned short utf8_to_euc_E5A5[] = {
+ 0, 0, 0, 0xB872, 0x3162, 0, 0xB873, 0x3471,
+ 0x4660, 0x4A74, 0, 0, 0, 0, 0x5477, 0x4155,
+ 0x5476, 0x3740, 0xB874, 0xB875, 0x4B5B, 0x5475, 0, 0x4565,
+ 0x5479, 0xB876, 0x5478, 0xB877, 0, 0xB878, 0xB879, 0xB87A,
+ 0x547B, 0xB87B, 0x547A, 0xB87C, 0, 0x317C, 0, 0x547C,
+ 0x3E29, 0x547E, 0x4325, 0xB87D, 0x547D, 0xB87E, 0x4A33, 0xB921,
+ 0, 0, 0xB922, 0x3D77, 0x455B, 0xB923, 0xB924, 0,
+ 0x5521, 0xB925, 0, 0xB926, 0xB927, 0x3925, 0, 0,
+};
+static const unsigned short utf8_to_euc_E5A5_x0213[] = {
+ 0, 0, 0, 0xB872, 0x3162, 0, 0xA542, 0x3471,
+ 0x4660, 0x4A74, 0, 0, 0, 0, 0x5477, 0x4155,
+ 0x5476, 0x3740, 0xB874, 0xB875, 0x4B5B, 0x5475, 0, 0x4565,
+ 0x5479, 0xB876, 0x5478, 0xA545, 0, 0x2F69, 0xB879, 0xA546,
+ 0x547B, 0xB87B, 0x547A, 0xB87C, 0, 0x317C, 0, 0x547C,
+ 0x3E29, 0x547E, 0x4325, 0xB87D, 0x547D, 0x2F6A, 0x4A33, 0xB921,
+ 0, 0, 0xB922, 0x3D77, 0x455B, 0xA548, 0xA549, 0,
+ 0x5521, 0xB925, 0, 0xB926, 0xA54A, 0x3925, 0, 0,
+};
+static const unsigned short utf8_to_euc_E5A6[] = {
+ 0, 0x5522, 0x4721, 0x485E, 0x4C51, 0, 0, 0,
+ 0, 0, 0x4725, 0xB928, 0xB929, 0x552B, 0xB92A, 0,
+ 0, 0, 0xB92B, 0x3538, 0, 0xB92C, 0x4D45, 0xB92D,
+ 0, 0x4C2F, 0, 0x562C, 0, 0x5523, 0, 0xB92E,
+ 0, 0, 0, 0x5526, 0xB92F, 0x4245, 0, 0xB930,
+ 0x4B38, 0, 0, 0, 0x454A, 0xB931, 0xB932, 0xB933,
+ 0xB934, 0, 0x5527, 0xB935, 0, 0, 0, 0xB936,
+ 0, 0x4B65, 0xB937, 0x3A4A, 0xB938, 0, 0x3E2A, 0,
+};
+static const unsigned short utf8_to_euc_E5A6_x0213[] = {
+ 0, 0x5522, 0x4721, 0x485E, 0x4C51, 0, 0, 0,
+ 0, 0, 0x4725, 0x2F6B, 0xB929, 0x552B, 0xB92A, 0,
+ 0, 0, 0x2F6C, 0x3538, 0, 0xB92C, 0x4D45, 0xB92D,
+ 0, 0x4C2F, 0, 0x562C, 0, 0x5523, 0, 0xA54B,
+ 0, 0, 0, 0x5526, 0x2F6D, 0x4245, 0, 0xB930,
+ 0x4B38, 0, 0, 0, 0x454A, 0xB931, 0xA54C, 0xB933,
+ 0xB934, 0, 0x5527, 0xB935, 0, 0, 0, 0xB936,
+ 0, 0x4B65, 0xB937, 0x3A4A, 0xA54D, 0, 0x3E2A, 0,
+};
+static const unsigned short utf8_to_euc_E5A7[] = {
+ 0, 0xB939, 0, 0xB93A, 0xB93B, 0, 0x5528, 0,
+ 0xB93C, 0x3B50, 0xB93D, 0x3B4F, 0, 0xB93E, 0, 0,
+ 0x3039, 0x3848, 0xB93F, 0x402B, 0x3051, 0, 0, 0,
+ 0, 0x552C, 0x552D, 0, 0x552A, 0xB940, 0xB941, 0xB942,
+ 0, 0, 0, 0xB943, 0xB944, 0x3138, 0x342F, 0xB945,
+ 0x5529, 0, 0x4C45, 0x4931, 0, 0, 0xB946, 0xB947,
+ 0, 0xB948, 0xB949, 0, 0xB94A, 0, 0x3028, 0xB94B,
+ 0, 0, 0, 0x3079, 0, 0, 0, 0x3B51,
+};
+static const unsigned short utf8_to_euc_E5A7_x0213[] = {
+ 0, 0xB939, 0, 0x2F6E, 0xB93B, 0, 0x5528, 0,
+ 0xA54E, 0x3B50, 0xB93D, 0x3B4F, 0, 0xA54F, 0, 0,
+ 0x3039, 0x3848, 0x2F6F, 0x402B, 0x3051, 0, 0, 0,
+ 0, 0x552C, 0x552D, 0, 0x552A, 0x2F70, 0xA550, 0xB942,
+ 0, 0, 0, 0xA551, 0xA552, 0x3138, 0x342F, 0xA553,
+ 0x5529, 0, 0x4C45, 0x4931, 0, 0, 0xA554, 0xB947,
+ 0, 0xB948, 0xB949, 0, 0xB94A, 0, 0x3028, 0xB94B,
+ 0x7E7A, 0, 0, 0x3079, 0, 0, 0, 0x3B51,
+};
+static const unsigned short utf8_to_euc_E5A8[] = {
+ 0xB94C, 0x3052, 0, 0x3023, 0xB94D, 0, 0, 0,
+ 0, 0x5532, 0, 0, 0xB94E, 0xB94F, 0xB950, 0,
+ 0, 0x5530, 0xB951, 0xB952, 0, 0, 0, 0,
+ 0x4C3C, 0, 0x5533, 0, 0x5531, 0, 0xB953, 0x552F,
+ 0x3F31, 0, 0, 0xB954, 0xB955, 0x552E, 0, 0xB956,
+ 0xB957, 0x4A5A, 0xB958, 0, 0, 0xB959, 0, 0x3864,
+ 0xB95A, 0, 0, 0, 0, 0x5537, 0x5538, 0,
+ 0, 0, 0, 0, 0x3E2B, 0, 0, 0,
+};
+static const unsigned short utf8_to_euc_E5A8_x0213[] = {
+ 0xB94C, 0x3052, 0, 0x3023, 0xB94D, 0, 0, 0,
+ 0, 0x5532, 0, 0, 0xA558, 0xA559, 0xB950, 0,
+ 0, 0x5530, 0xB951, 0x2F71, 0, 0, 0, 0xA55A,
+ 0x4C3C, 0, 0x5533, 0, 0x5531, 0, 0xB953, 0x552F,
+ 0x3F31, 0, 0, 0x2F72, 0xB955, 0x552E, 0, 0xA55B,
+ 0xB957, 0x4A5A, 0xB958, 0, 0, 0xA55C, 0, 0x3864,
+ 0xB95A, 0, 0, 0, 0, 0x5537, 0x5538, 0,
+ 0, 0, 0, 0, 0x3E2B, 0, 0, 0,
+};
+static const unsigned short utf8_to_euc_E5A9[] = {
+ 0x5534, 0x4F2C, 0, 0, 0xB95B, 0xB95C, 0x474C, 0xB95D,
+ 0xB95E, 0x5536, 0, 0, 0xB95F, 0, 0, 0,
+ 0xB960, 0, 0, 0, 0, 0xB961, 0, 0,
+ 0, 0, 0x3A27, 0, 0, 0, 0xB962, 0,
+ 0, 0, 0x5539, 0xB963, 0, 0xB964, 0x4958, 0xB965,
+ 0, 0, 0x553A, 0, 0x5535, 0xB966, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0xB967,
+ 0, 0, 0xB968, 0xB969, 0, 0, 0xB96A, 0x4C3B,
+};
+static const unsigned short utf8_to_euc_E5A9_x0213[] = {
+ 0x5534, 0x4F2C, 0, 0, 0xB95B, 0xB95C, 0x474C, 0xB95D,
+ 0xB95E, 0x5536, 0, 0, 0xB95F, 0, 0, 0,
+ 0xB960, 0, 0, 0, 0, 0xA55D, 0, 0,
+ 0, 0, 0x3A27, 0, 0, 0, 0xB962, 0,
+ 0, 0, 0x5539, 0xB963, 0, 0xA55E, 0x4958, 0x2F73,
+ 0, 0, 0x553A, 0, 0x5535, 0x2F74, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0x2F75,
+ 0, 0, 0xA55F, 0xB969, 0, 0, 0x2F76, 0x4C3B,
+};
+static const unsigned short utf8_to_euc_E5AA[] = {
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0xB96B, 0, 0, 0, 0,
+ 0xB96C, 0, 0x475E, 0xB96D, 0, 0, 0xB96E, 0,
+ 0, 0xB96F, 0x553B, 0x4932, 0xB970, 0, 0xB971, 0xB972,
+ 0xB973, 0, 0xB974, 0, 0, 0, 0, 0xB975,
+ 0, 0, 0, 0, 0xB976, 0, 0, 0,
+ 0, 0xB977, 0xB978, 0xB979, 0, 0xB97A, 0, 0,
+ 0xB97B, 0, 0xB97C, 0xB97D, 0x553C, 0x5540, 0x553D, 0xB97E,
+};
+static const unsigned short utf8_to_euc_E5AA_x0213[] = {
+ 0, 0, 0, 0, 0x2F77, 0, 0, 0,
+ 0, 0, 0, 0xA560, 0, 0, 0, 0,
+ 0xB96C, 0, 0x475E, 0xB96D, 0, 0, 0xB96E, 0,
+ 0, 0xB96F, 0x553B, 0x4932, 0xA561, 0, 0x2F78, 0xA562,
+ 0xA563, 0, 0xA564, 0, 0, 0, 0, 0x2F79,
+ 0, 0, 0, 0, 0xB976, 0, 0, 0,
+ 0, 0xA565, 0xB978, 0xA566, 0, 0xA567, 0, 0,
+ 0xB97B, 0, 0xA568, 0xB97D, 0x553C, 0x5540, 0x553D, 0xA569,
+};
+static const unsigned short utf8_to_euc_E5AB[] = {
+ 0, 0x3247, 0x553F, 0, 0xBA21, 0, 0xBA22, 0,
+ 0xBA23, 0x3C3B, 0, 0x553E, 0x3779, 0, 0, 0xBA24,
+ 0x554C, 0, 0, 0, 0, 0, 0x5545, 0x5542,
+ 0, 0, 0xBA25, 0, 0xBA26, 0, 0, 0,
+ 0xBA27, 0x4364, 0, 0x5541, 0, 0xBA28, 0x5543, 0,
+ 0, 0x5544, 0xBA29, 0, 0, 0, 0xBA2A, 0,
+ 0, 0, 0, 0, 0, 0xBA2B, 0xBA2C, 0,
+ 0, 0, 0x5546, 0x5547, 0, 0xBA2D, 0, 0,
+};
+static const unsigned short utf8_to_euc_E5AB_x0213[] = {
+ 0, 0x3247, 0x553F, 0, 0x2F7A, 0, 0xBA22, 0,
+ 0xBA23, 0x3C3B, 0, 0x553E, 0x3779, 0, 0, 0xBA24,
+ 0x554C, 0, 0, 0, 0, 0, 0x5545, 0x5542,
+ 0, 0, 0xA56A, 0, 0xA56B, 0, 0, 0,
+ 0xA56C, 0x4364, 0, 0x5541, 0, 0xA56D, 0x5543, 0,
+ 0, 0x5544, 0xBA29, 0, 0, 0, 0xA56F, 0,
+ 0xA56E, 0, 0, 0, 0, 0xA570, 0xBA2C, 0,
+ 0, 0, 0x5546, 0x5547, 0, 0xBA2D, 0, 0,
+};
+static const unsigned short utf8_to_euc_E5AC[] = {
+ 0xBA2E, 0xBA2F, 0, 0, 0, 0, 0, 0,
+ 0xBA30, 0x3472, 0, 0x5549, 0x5548, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0x554A, 0xBA31,
+ 0, 0xBA33, 0, 0xBA34, 0, 0xBA35, 0, 0,
+ 0, 0xBA36, 0x3E6E, 0, 0, 0xBA37, 0, 0,
+ 0, 0, 0x554D, 0, 0x445C, 0xBA38, 0, 0,
+ 0x3145, 0, 0x554B, 0, 0xBA32, 0, 0x554E, 0,
+ 0xBA39, 0, 0, 0, 0, 0, 0x554F, 0,
+};
+static const unsigned short utf8_to_euc_E5AC_x0213[] = {
+ 0xA571, 0xBA2F, 0, 0, 0, 0, 0, 0,
+ 0xA572, 0x3472, 0, 0x5549, 0x5548, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0x554A, 0xA573,
+ 0, 0x2F7C, 0, 0xBA34, 0, 0xBA35, 0, 0,
+ 0, 0xBA36, 0x3E6E, 0, 0, 0x2F7D, 0, 0,
+ 0, 0, 0x554D, 0, 0x445C, 0xA575, 0, 0,
+ 0x3145, 0, 0x554B, 0, 0xA574, 0, 0x554E, 0,
+ 0xBA39, 0, 0, 0, 0, 0, 0x554F, 0,
+};
+static const unsigned short utf8_to_euc_E5AD[] = {
+ 0x5552, 0xBA3A, 0, 0x5550, 0, 0x5551, 0, 0,
+ 0, 0, 0, 0xBA3B, 0xBA3C, 0, 0, 0,
+ 0x3B52, 0x5553, 0xBA3D, 0, 0x3926, 0x5554, 0xBA3E, 0x3B7A,
+ 0x4238, 0, 0x5555, 0x5556, 0x3B5A, 0x3927, 0xBA3F, 0x4C52,
+ 0, 0, 0, 0x3528, 0x3849, 0x5557, 0x3358, 0,
+ 0xBA40, 0x5558, 0, 0x4239, 0, 0, 0xBA41, 0xBA42,
+ 0x5559, 0x5623, 0, 0x555A, 0, 0x555B, 0, 0,
+ 0x555C, 0, 0x555E, 0, 0xBA43, 0xBA44, 0xBA45, 0xBA46,
+};
+static const unsigned short utf8_to_euc_E5AD_x0213[] = {
+ 0x5552, 0x4F55, 0, 0x5550, 0, 0x5551, 0, 0,
+ 0, 0, 0, 0xBA3B, 0xA576, 0, 0, 0,
+ 0x3B52, 0x5553, 0xA577, 0, 0x3926, 0x5554, 0x4F56, 0x3B7A,
+ 0x4238, 0, 0x5555, 0x5556, 0x3B5A, 0x3927, 0xBA3F, 0x4C52,
+ 0, 0, 0, 0x3528, 0x3849, 0x5557, 0x3358, 0,
+ 0xA578, 0x5558, 0, 0x4239, 0, 0, 0xBA41, 0xA579,
+ 0x5559, 0x5623, 0, 0x555A, 0, 0x555B, 0, 0,
+ 0x555C, 0, 0x555E, 0, 0xA57A, 0x4F57, 0xBA45, 0xA57B,
+};
+static const unsigned short utf8_to_euc_E5AE[] = {
+ 0x555F, 0xBA47, 0, 0x5560, 0xBA48, 0x4270, 0xBA49, 0x3127,
+ 0x3C69, 0x3042, 0xBA4A, 0x4157, 0x3430, 0x3C35, 0xBA4B, 0x3928,
+ 0xBA4C, 0xBA4D, 0, 0xBA4E, 0xBA4F, 0x4566, 0xBA50, 0x3D21,
+ 0x3431, 0x4368, 0x446A, 0x3038, 0x3539, 0x4A75, 0, 0x3C42,
+ 0, 0, 0x3552, 0x406B, 0x3C3C, 0x4D28, 0x5561, 0,
+ 0xBA51, 0xBA52, 0, 0, 0xBA53, 0xBA54, 0x355C, 0xBA55,
+ 0x3A4B, 0xBA56, 0xBA57, 0x3332, 0x3163, 0x3E2C, 0x3248, 0xBA58,
+ 0x5562, 0x4D46, 0xBA59, 0, 0xBA5A, 0, 0, 0x3D49,
+};
+static const unsigned short utf8_to_euc_E5AE_x0213[] = {
+ 0x555F, 0xA57C, 0, 0x5560, 0xA57D, 0x4270, 0xBA49, 0x3127,
+ 0x3C69, 0x3042, 0xBA4A, 0x4157, 0x3430, 0x3C35, 0xBA4B, 0x3928,
+ 0xBA4C, 0xBA4D, 0, 0x4F58, 0xBA4F, 0x4566, 0xA821, 0x3D21,
+ 0x3431, 0x4368, 0x446A, 0x3038, 0x3539, 0x4A75, 0, 0x3C42,
+ 0, 0, 0x3552, 0x406B, 0x3C3C, 0x4D28, 0x5561, 0,
+ 0xBA51, 0xBA52, 0, 0, 0xA822, 0xBA54, 0x355C, 0xBA55,
+ 0x3A4B, 0xBA56, 0xBA57, 0x3332, 0x3163, 0x3E2C, 0x3248, 0xBA58,
+ 0x5562, 0x4D46, 0xBA59, 0, 0xBA5A, 0, 0, 0x3D49,
+};
+static const unsigned short utf8_to_euc_E5AF[] = {
+ 0xBA5B, 0xBA5C, 0x3C64, 0x5563, 0x3473, 0x4652, 0x4C29, 0x5564,
+ 0, 0x5565, 0, 0, 0x4959, 0xBA5D, 0, 0xBA5E,
+ 0x5567, 0, 0x3428, 0x3677, 0x5566, 0, 0xBA5F, 0xBA60,
+ 0xBA61, 0xBA62, 0xBA63, 0x3432, 0, 0x3F32, 0x556B, 0x3B21,
+ 0xBA64, 0x3249, 0x556A, 0, 0x5568, 0x556C, 0x5569, 0x472B,
+ 0x5C4D, 0x3F33, 0, 0x556D, 0xF43A, 0, 0x4E40, 0xBA65,
+ 0x556E, 0xBA66, 0, 0x5570, 0xBA67, 0x437E, 0x556F, 0,
+ 0x4023, 0, 0x3B7B, 0, 0, 0xBA68, 0x4250, 0x3C77,
+};
+static const unsigned short utf8_to_euc_E5AF_x0213[] = {
+ 0xA824, 0xBA5C, 0x3C64, 0x5563, 0x3473, 0x4652, 0x4C29, 0x5564,
+ 0, 0x5565, 0, 0, 0x4959, 0xBA5D, 0xA826, 0xBA5E,
+ 0x5567, 0, 0x3428, 0x3677, 0x5566, 0, 0xA827, 0xBA60,
+ 0x4F59, 0xBA62, 0xBA63, 0x3432, 0, 0x3F32, 0x556B, 0x3B21,
+ 0xBA64, 0x3249, 0x556A, 0, 0x5568, 0x556C, 0x5569, 0x472B,
+ 0x5C4D, 0x3F33, 0, 0x556D, 0x4F5A, 0, 0x4E40, 0xBA65,
+ 0x556E, 0xA82A, 0, 0x5570, 0xBA67, 0x437E, 0x556F, 0,
+ 0x4023, 0, 0x3B7B, 0, 0, 0xA82B, 0x4250, 0x3C77,
+};
+static const unsigned short utf8_to_euc_E5B0[] = {
+ 0, 0x4975, 0x406C, 0, 0x3C4D, 0x5571, 0x3E2D, 0x5572,
+ 0x5573, 0x3053, 0x423A, 0x3F52, 0xBA69, 0x5574, 0x4633, 0x3E2E,
+ 0, 0x3E2F, 0, 0x5575, 0, 0, 0x406D, 0xBA6A,
+ 0, 0, 0x3E30, 0, 0, 0, 0xBA6B, 0xBA6C,
+ 0x5576, 0, 0x5577, 0xBA6D, 0x4C60, 0, 0xBA6E, 0,
+ 0x5578, 0xBA6F, 0, 0xBA70, 0xBA71, 0x3646, 0xBA72, 0,
+ 0xBA73, 0x3D22, 0xBA74, 0, 0, 0xBA75, 0xBA76, 0,
+ 0x5579, 0x557A, 0x3C5C, 0x3F2C, 0x4674, 0x3F54, 0x4878, 0x4722,
+};
+static const unsigned short utf8_to_euc_E5B0_x0213[] = {
+ 0, 0x4975, 0x406C, 0xA82D, 0x3C4D, 0x5571, 0x3E2D, 0x5572,
+ 0x5573, 0x3053, 0x423A, 0x3F52, 0xBA69, 0x5574, 0x4633, 0x3E2E,
+ 0, 0x3E2F, 0x4F5B, 0x5575, 0, 0, 0x406D, 0xBA6A,
+ 0, 0, 0x3E30, 0, 0, 0, 0x4F5C, 0xBA6C,
+ 0x5576, 0, 0x5577, 0x4F5D, 0x4C60, 0, 0xBA6E, 0,
+ 0x5578, 0xA82E, 0, 0x4F5E, 0xBA71, 0x3646, 0xBA72, 0,
+ 0xA82F, 0x3D22, 0xBA74, 0, 0, 0xBA75, 0xBA76, 0,
+ 0x5579, 0x557A, 0x3C5C, 0x3F2C, 0x4674, 0x3F54, 0x4878, 0x4722,
+};
+static const unsigned short utf8_to_euc_E5B1[] = {
+ 0x3649, 0x557B, 0, 0, 0, 0x356F, 0x557C, 0,
+ 0x367E, 0, 0x464F, 0x3230, 0, 0x3B53, 0x557D, 0x5622,
+ 0x5621, 0x367D, 0, 0x557E, 0, 0x4538, 0, 0,
+ 0, 0xBA77, 0xBA78, 0, 0xBA79, 0, 0x4230, 0,
+ 0x454B, 0x3C48, 0xBA7A, 0xBA7B, 0x4158, 0x4D7A, 0, 0xBA7C,
+ 0xBA7D, 0xBA7E, 0, 0, 0x5624, 0xBB21, 0x5625, 0x4656,
+ 0xBB22, 0x3B33, 0, 0, 0xBB23, 0xBB24, 0x5627, 0,
+ 0, 0x5628, 0xBB25, 0xBB26, 0xBB27, 0xBB28, 0, 0,
+};
+static const unsigned short utf8_to_euc_E5B1_x0213[] = {
+ 0x3649, 0x557B, 0, 0, 0, 0x356F, 0x557C, 0,
+ 0x367E, 0, 0x464F, 0x3230, 0, 0x3B53, 0x557D, 0x5622,
+ 0x5621, 0x367D, 0, 0x557E, 0, 0x4538, 0, 0,
+ 0, 0xBA77, 0xBA78, 0x7E7B, 0xBA79, 0, 0x4230, 0xA831,
+ 0x454B, 0x3C48, 0x4F60, 0xA832, 0x4158, 0x4D7A, 0, 0xA833,
+ 0xA834, 0xA835, 0, 0, 0x5624, 0xBB21, 0x5625, 0x4656,
+ 0xA836, 0x3B33, 0, 0, 0xBB23, 0xBB24, 0x5627, 0,
+ 0, 0x5628, 0x4F64, 0xBB26, 0xA839, 0xBB28, 0, 0,
+};
+static const unsigned short utf8_to_euc_E5B2[] = {
+ 0, 0, 0, 0, 0, 0, 0, 0xBB29,
+ 0xBB2A, 0, 0xBB2B, 0, 0x5629, 0, 0, 0xBB2C,
+ 0x3474, 0x562A, 0xBB2D, 0, 0x562B, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0xBB2E, 0, 0xBB2F,
+ 0xBB30, 0x322C, 0xBB31, 0xBB32, 0, 0, 0xBB33, 0,
+ 0x413B, 0x3464, 0xBB34, 0x562D, 0x4C28, 0, 0, 0,
+ 0, 0x4252, 0xBB35, 0x3359, 0xBB36, 0xBB37, 0x562F, 0x5631,
+ 0x345F, 0, 0xBB38, 0x562E, 0x5630, 0, 0x5633, 0,
+};
+static const unsigned short utf8_to_euc_E5B2_x0213[] = {
+ 0, 0, 0, 0, 0, 0, 0, 0xBB29,
+ 0xA83C, 0, 0xA83D, 0, 0x5629, 0, 0, 0x4F65,
+ 0x3474, 0x562A, 0xBB2D, 0, 0x562B, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0xBB2E, 0, 0x4F66,
+ 0xA841, 0x322C, 0xA842, 0x4F67, 0, 0, 0xA843, 0xA844,
+ 0x413B, 0x3464, 0x4F68, 0x562D, 0x4C28, 0xA846, 0, 0,
+ 0, 0x4252, 0xBB35, 0x3359, 0xBB36, 0xA847, 0x562F, 0x5631,
+ 0x345F, 0, 0x4F69, 0x562E, 0x5630, 0, 0x5633, 0,
+};
+static const unsigned short utf8_to_euc_E5B3[] = {
+ 0, 0, 0, 0, 0, 0x5632, 0, 0x5634,
+ 0, 0xBB39, 0, 0xBB3A, 0, 0, 0, 0,
+ 0, 0, 0xBB3B, 0, 0, 0, 0, 0xBB3D,
+ 0, 0x5635, 0, 0, 0, 0xBB3C, 0, 0,
+ 0x463D, 0x362E, 0, 0, 0, 0, 0, 0,
+ 0x3265, 0x5636, 0x563B, 0, 0, 0x5639, 0xBB3E, 0x4A77,
+ 0x4A76, 0xBB3F, 0xBB40, 0, 0xBB41, 0xF43B, 0x4567, 0,
+ 0, 0, 0x5638, 0x3D54, 0, 0x5637, 0, 0,
+};
+static const unsigned short utf8_to_euc_E5B3_x0213[] = {
+ 0, 0, 0, 0, 0, 0x5632, 0, 0x5634,
+ 0, 0xA849, 0, 0x4F6A, 0, 0, 0, 0,
+ 0x4F6B, 0, 0x4F6C, 0, 0, 0, 0, 0xBB3D,
+ 0, 0x5635, 0, 0, 0, 0xBB3C, 0, 0,
+ 0x463D, 0x362E, 0, 0, 0, 0, 0, 0,
+ 0x3265, 0x5636, 0x563B, 0, 0, 0x5639, 0xBB3E, 0x4A77,
+ 0x4A76, 0xBB3F, 0xBB40, 0, 0x4F6D, 0xF43B, 0x4567, 0,
+ 0, 0, 0x5638, 0x3D54, 0, 0x5637, 0, 0,
+};
+static const unsigned short utf8_to_euc_E5B4[] = {
+ 0, 0xBB42, 0, 0, 0, 0, 0xBB43, 0x3F72,
+ 0, 0, 0, 0x563C, 0, 0xBB44, 0x3A6A, 0,
+ 0, 0x5642, 0xBB45, 0, 0x5643, 0x563D, 0x3333, 0x563E,
+ 0x5647, 0x5646, 0x5645, 0x5641, 0, 0, 0, 0x5640,
+ 0, 0, 0x5644, 0xBB47, 0xBB48, 0, 0xBB49, 0xBB4A,
+ 0, 0x4A78, 0, 0xBB46, 0, 0, 0, 0,
+ 0, 0xBB4B, 0, 0, 0xBB4C, 0, 0, 0,
+ 0, 0xBB4D, 0, 0, 0, 0xBB4E, 0, 0xBB4F,
+};
+static const unsigned short utf8_to_euc_E5B4_x0213[] = {
+ 0, 0xBB42, 0, 0, 0, 0, 0xA84C, 0x3F72,
+ 0, 0, 0, 0x563C, 0, 0x4F70, 0x3A6A, 0,
+ 0xA84D, 0x5642, 0xBB45, 0, 0x5643, 0x563D, 0x3333, 0x563E,
+ 0x5647, 0x5646, 0x5645, 0x5641, 0, 0xA84F, 0, 0x5640,
+ 0xA850, 0, 0x5644, 0xBB47, 0xA851, 0, 0xA852, 0x4F71,
+ 0, 0x4A78, 0, 0xA84E, 0, 0, 0, 0,
+ 0, 0xA853, 0, 0, 0xBB4C, 0, 0, 0,
+ 0, 0xA854, 0, 0, 0, 0xBB4E, 0, 0xBB4F,
+};
+static const unsigned short utf8_to_euc_E5B5[] = {
+ 0, 0, 0xBB50, 0xBB51, 0, 0, 0xBB52, 0,
+ 0xBB53, 0, 0xBB57, 0x564B, 0x5648, 0, 0x564A, 0,
+ 0x4D72, 0xBB55, 0x5649, 0xF43C, 0, 0xBB54, 0, 0,
+ 0, 0xBB56, 0, 0, 0x563F, 0, 0, 0xBB58,
+ 0xBB59, 0xBB5A, 0xBB5B, 0, 0xBB5C, 0, 0, 0,
+ 0, 0x3F73, 0xBB5D, 0, 0x564C, 0xBB5E, 0, 0x3A37,
+ 0xBB5F, 0, 0, 0x564D, 0, 0, 0x564E, 0,
+ 0, 0xBB60, 0xBB61, 0, 0, 0, 0xBB62, 0xBB63,
+};
+static const unsigned short utf8_to_euc_E5B5_x0213[] = {
+ 0, 0, 0xA855, 0xBB51, 0, 0, 0x4F73, 0x4F74,
+ 0xBB53, 0, 0x4F76, 0x564B, 0x5648, 0, 0x564A, 0,
+ 0x4D72, 0xBB55, 0x5649, 0x4F75, 0, 0xBB54, 0, 0,
+ 0, 0xBB56, 0, 0, 0x563F, 0, 0, 0xBB58,
+ 0xBB59, 0xA857, 0xBB5B, 0, 0xBB5C, 0, 0, 0,
+ 0, 0x3F73, 0xA858, 0, 0x564C, 0x4F77, 0, 0x3A37,
+ 0xA85A, 0, 0, 0x564D, 0, 0, 0x564E, 0,
+ 0, 0xBB60, 0xBB61, 0, 0, 0, 0xBB62, 0xBB63,
+};
+static const unsigned short utf8_to_euc_E5B6[] = {
+ 0, 0xBB64, 0x5651, 0xBB65, 0x5650, 0, 0, 0x564F,
+ 0xBB66, 0, 0xBB67, 0x4568, 0x563A, 0, 0, 0,
+ 0x5657, 0, 0xBB68, 0xBB69, 0xBB6A, 0xBB6B, 0, 0,
+ 0, 0xBB6C, 0, 0xBB6D, 0, 0x5653, 0, 0xBB6E,
+ 0xBB6F, 0, 0x5652, 0, 0, 0, 0, 0xBB70,
+ 0, 0, 0, 0xBB71, 0x5654, 0, 0x5655, 0,
+ 0xBB72, 0, 0xE674, 0, 0xBB73, 0, 0, 0x5658,
+ 0xBB74, 0xBB75, 0x4E66, 0, 0x5659, 0x5656, 0, 0,
+};
+static const unsigned short utf8_to_euc_E5B6_x0213[] = {
+ 0, 0x4F78, 0x5651, 0xBB65, 0x5650, 0, 0, 0x564F,
+ 0xA85D, 0, 0xBB67, 0x4568, 0x563A, 0, 0, 0,
+ 0x5657, 0, 0xA85F, 0xBB69, 0xA860, 0xBB6B, 0, 0xA861,
+ 0, 0xA862, 0, 0xBB6D, 0, 0x5653, 0, 0xBB6E,
+ 0x4F79, 0, 0x5652, 0, 0x4F7A, 0, 0, 0x4F7B,
+ 0, 0, 0, 0xBB71, 0x5654, 0, 0x5655, 0,
+ 0xA863, 0, 0xA864, 0, 0xA865, 0, 0, 0x5658,
+ 0x4F7C, 0xA867, 0x4E66, 0, 0x5659, 0x5656, 0, 0,
+};
+static const unsigned short utf8_to_euc_E5B7[] = {
+ 0, 0, 0, 0xBB76, 0, 0, 0, 0xBB77,
+ 0, 0x565A, 0, 0xBB78, 0x3460, 0x565B, 0xBB7A, 0,
+ 0xBB79, 0, 0x565D, 0x565C, 0, 0, 0x565E, 0,
+ 0xBB7B, 0xBB7C, 0, 0x565F, 0, 0x406E, 0x3D23, 0,
+ 0xBB7D, 0x3D64, 0, 0x4163, 0xBB7E, 0x3929, 0x3A38, 0x392A,
+ 0x3570, 0xBC21, 0, 0x5660, 0, 0, 0x3A39, 0,
+ 0, 0x384A, 0x5661, 0x4C26, 0x4743, 0x5662, 0, 0x392B,
+ 0xBC22, 0xBC23, 0, 0x342C, 0, 0x4327, 0x3652, 0,
+};
+static const unsigned short utf8_to_euc_E5B7_x0213[] = {
+ 0, 0, 0, 0xBB76, 0, 0, 0, 0xBB77,
+ 0, 0x565A, 0, 0x4F7D, 0x3460, 0x565B, 0xBB7A, 0,
+ 0xBB79, 0xA868, 0x565D, 0x565C, 0, 0, 0x565E, 0xA869,
+ 0xA86A, 0xBB7C, 0, 0x565F, 0, 0x406E, 0x3D23, 0,
+ 0xA86B, 0x3D64, 0x7428, 0x4163, 0xA86D, 0x3929, 0x3A38, 0x392A,
+ 0x3570, 0xA86E, 0, 0x5660, 0, 0, 0x3A39, 0,
+ 0, 0x384A, 0x5661, 0x4C26, 0x4743, 0x5662, 0, 0x392B,
+ 0xBC22, 0xBC23, 0, 0x342C, 0, 0x4327, 0x3652, 0,
+};
+static const unsigned short utf8_to_euc_E5B8[] = {
+ 0xBC24, 0, 0x3B54, 0x495B, 0, 0, 0x4841, 0xBC25,
+ 0, 0, 0, 0x5663, 0x3475, 0xBC26, 0, 0,
+ 0, 0x5666, 0xBC27, 0, 0xBC28, 0xBC29, 0x4421, 0,
+ 0xBC2A, 0x5665, 0x5664, 0x5667, 0, 0x446B, 0, 0xBC2B,
+ 0xBC2C, 0, 0, 0, 0, 0x3F63, 0, 0,
+ 0xBC2E, 0, 0, 0x3B55, 0, 0x404A, 0xBC2D, 0x4253,
+ 0x3522, 0, 0xBC2F, 0x4422, 0, 0xBC30, 0x5668, 0x5669,
+ 0x3E6F, 0, 0, 0, 0, 0x4B39, 0xBC31, 0,
+};
+static const unsigned short utf8_to_euc_E5B8_x0213[] = {
+ 0xA870, 0, 0x3B54, 0x495B, 0, 0, 0x4841, 0xBC25,
+ 0, 0, 0, 0x5663, 0x3475, 0xBC26, 0, 0,
+ 0, 0x5666, 0xA872, 0, 0x7429, 0xA873, 0x4421, 0,
+ 0x742A, 0x5665, 0x5664, 0x5667, 0, 0x446B, 0, 0xA875,
+ 0xBC2C, 0, 0, 0, 0, 0x3F63, 0, 0,
+ 0xBC2E, 0, 0, 0x3B55, 0, 0x404A, 0xA876, 0x4253,
+ 0x3522, 0, 0xBC2F, 0x4422, 0, 0xBC30, 0x5668, 0x5669,
+ 0x3E6F, 0, 0, 0, 0, 0x4B39, 0xA877, 0,
+};
+static const unsigned short utf8_to_euc_E5B9[] = {
+ 0x566C, 0, 0, 0x566B, 0x566A, 0x497D, 0, 0x5673,
+ 0, 0xBC34, 0, 0xBC32, 0x4B5A, 0, 0x566D, 0,
+ 0xBC33, 0xBC35, 0, 0, 0x566F, 0x4B6B, 0xBC36, 0x566E,
+ 0xBC37, 0, 0, 0xBC38, 0xBC39, 0, 0xBC3A, 0x5670,
+ 0, 0x4828, 0x5671, 0x4A3E, 0x5672, 0, 0, 0,
+ 0xBC3B, 0, 0xBC3C, 0xBC3D, 0xBC3E, 0xBC3F, 0xBC40, 0,
+ 0xBC41, 0, 0x3433, 0x4A3F, 0x472F, 0x5674, 0x5675, 0,
+ 0x392C, 0x3434, 0x5676, 0x3838, 0x4D44, 0x4D29, 0x3476, 0x5678,
+};
+static const unsigned short utf8_to_euc_E5B9_x0213[] = {
+ 0x566C, 0, 0, 0x566B, 0x566A, 0x497D, 0, 0x5673,
+ 0, 0xA878, 0, 0xBC32, 0x4B5A, 0, 0x566D, 0,
+ 0xBC33, 0xBC35, 0, 0, 0x566F, 0x4B6B, 0xA87A, 0x566E,
+ 0x742B, 0, 0, 0xBC38, 0xBC39, 0, 0x742C, 0x5670,
+ 0, 0x4828, 0x5671, 0x4A3E, 0x5672, 0, 0, 0,
+ 0xBC3B, 0, 0xBC3C, 0xA87C, 0xA87D, 0xA87E, 0xAC21, 0,
+ 0xBC41, 0, 0x3433, 0x4A3F, 0x472F, 0x5674, 0x5675, 0x7E7C,
+ 0x392C, 0x3434, 0x5676, 0x3838, 0x4D44, 0x4D29, 0x3476, 0x5678,
+};
+static const unsigned short utf8_to_euc_E5BA[] = {
+ 0xBC42, 0x4423, 0, 0x392D, 0x3E31, 0, 0, 0x485F,
+ 0, 0, 0x3E32, 0xBC43, 0, 0, 0xBC44, 0x3D78,
+ 0, 0, 0, 0, 0, 0x446C, 0x4A79, 0x4539,
+ 0, 0, 0x392E, 0, 0x495C, 0, 0, 0,
+ 0x5679, 0, 0xBC45, 0, 0xBC46, 0xBC47, 0x4559, 0x3A42,
+ 0xBC48, 0, 0xBC49, 0x384B, 0xBC4A, 0x446D, 0, 0,
+ 0, 0xBC4B, 0, 0xBC4C, 0, 0x3043, 0x3D6E, 0x392F,
+ 0x4D47, 0, 0, 0, 0, 0xBC4D, 0xBC4E, 0xBC4F,
+};
+static const unsigned short utf8_to_euc_E5BA_x0213[] = {
+ 0xBC42, 0x4423, 0, 0x392D, 0x3E31, 0, 0, 0x485F,
+ 0, 0, 0x3E32, 0xBC43, 0, 0, 0xBC44, 0x3D78,
+ 0, 0, 0, 0, 0, 0x446C, 0x4A79, 0x4539,
+ 0, 0, 0x392E, 0, 0x495C, 0, 0, 0,
+ 0x5679, 0, 0xBC45, 0, 0xBC46, 0xAC23, 0x4559, 0x3A42,
+ 0xBC48, 0, 0xAC24, 0x384B, 0xAC25, 0x446D, 0, 0,
+ 0, 0xBC4B, 0, 0xBC4C, 0, 0x3043, 0x3D6E, 0x392F,
+ 0x4D47, 0xAC26, 0, 0, 0, 0xBC4D, 0x742D, 0xAC27,
+};
+static const unsigned short utf8_to_euc_E5BB[] = {
+ 0, 0x567A, 0x567B, 0x4751, 0, 0, 0xBC50, 0,
+ 0x567C, 0x4E77, 0x4F2D, 0xBC52, 0xBC51, 0, 0xBC53, 0x567E,
+ 0x567D, 0xBC54, 0xBC55, 0x3347, 0xBC56, 0xBC57, 0x5721, 0,
+ 0, 0, 0x5724, 0x5725, 0xBC58, 0x5723, 0xBC59, 0x4940,
+ 0x3E33, 0x5727, 0x5726, 0x5722, 0, 0xBC5A, 0, 0,
+ 0x5728, 0x5729, 0, 0xBC5B, 0x572A, 0, 0, 0,
+ 0x572D, 0x572B, 0, 0x572C, 0x572E, 0, 0x3164, 0x446E,
+ 0x572F, 0, 0x377A, 0x3276, 0x4736, 0, 0x5730, 0x467B,
+};
+static const unsigned short utf8_to_euc_E5BB_x0213[] = {
+ 0, 0x567A, 0x567B, 0x4751, 0, 0, 0xAC28, 0,
+ 0x567C, 0x4E77, 0x4F2D, 0x742F, 0xBC51, 0, 0xBC53, 0x567E,
+ 0x567D, 0xBC54, 0xAC29, 0x3347, 0xBC56, 0xBC57, 0x5721, 0,
+ 0, 0xAC2A, 0x5724, 0x5725, 0xBC58, 0x5723, 0xBC59, 0x4940,
+ 0x3E33, 0x5727, 0x5726, 0x5722, 0, 0xBC5A, 0, 0,
+ 0x5728, 0x5729, 0, 0xBC5B, 0x572A, 0, 0, 0,
+ 0x572D, 0x572B, 0, 0x572C, 0x572E, 0, 0x3164, 0x446E,
+ 0x572F, 0x7430, 0x377A, 0x3276, 0x4736, 0xAC2C, 0x5730, 0x467B,
+};
+static const unsigned short utf8_to_euc_E5BC[] = {
+ 0, 0x4A5B, 0xBC5C, 0x5731, 0x4F2E, 0, 0xBC5D, 0xBC5E,
+ 0xBC5F, 0x5732, 0x4A40, 0x5735, 0x5021, 0x5031, 0xBC60, 0x3C30,
+ 0x4675, 0x5736, 0, 0x355D, 0x4424, 0x307A, 0x5737, 0x4A26,
+ 0x3930, 0xBC61, 0, 0x4350, 0xBC62, 0xBC63, 0, 0x446F,
+ 0, 0xBC64, 0xBC65, 0xBC66, 0xBC67, 0x4C6F, 0x3839, 0x384C,
+ 0xBC68, 0x5738, 0, 0xBC69, 0xBC6A, 0x5739, 0xBC6B, 0x573F,
+ 0xBC6C, 0x3C65, 0, 0, 0xBC6D, 0x4425, 0xBC6E, 0x362F,
+ 0x573A, 0, 0, 0xBC6F, 0x492B, 0xBC70, 0x4346, 0xBC71,
+};
+static const unsigned short utf8_to_euc_E5BC_x0213[] = {
+ 0x7431, 0x4A5B, 0x7432, 0x5731, 0x4F2E, 0, 0xBC5D, 0x7433,
+ 0xAC2D, 0x5732, 0x4A40, 0x5735, 0x5021, 0x5031, 0xAC2E, 0x3C30,
+ 0x4675, 0x5736, 0, 0x355D, 0x4424, 0x307A, 0x5737, 0x4A26,
+ 0x3930, 0xBC61, 0, 0x4350, 0xAC2F, 0x7434, 0xAC31, 0x446F,
+ 0, 0xBC64, 0xBC65, 0x7435, 0xBC67, 0x4C6F, 0x3839, 0x384C,
+ 0xBC68, 0x5738, 0, 0xBC69, 0xBC6A, 0x5739, 0xBC6B, 0x573F,
+ 0xBC6C, 0x3C65, 0, 0, 0x7436, 0x4425, 0x7437, 0x362F,
+ 0x573A, 0, 0, 0xBC6F, 0x492B, 0x7438, 0x4346, 0xBC71,
+};
+static const unsigned short utf8_to_euc_E5BD[] = {
+ 0xBC72, 0x573B, 0, 0, 0xBC73, 0xBC74, 0, 0xBC75,
+ 0x573C, 0, 0x3630, 0, 0x573D, 0xBC76, 0x573E, 0,
+ 0xBC77, 0x5740, 0, 0x4576, 0xBC78, 0, 0x5741, 0x5742,
+ 0xBC79, 0x5743, 0, 0xBC7A, 0x5734, 0x5733, 0, 0,
+ 0xBC7B, 0x5744, 0x3741, 0xBC7C, 0xBC7D, 0, 0x4927, 0xBC7E,
+ 0, 0x3A4C, 0x4937, 0x4426, 0x494B, 0x5745, 0, 0xBD21,
+ 0x3E34, 0x3146, 0xBD22, 0x5746, 0xBD23, 0xBD24, 0, 0x5747,
+ 0xBD25, 0x4C72, 0xBD26, 0, 0x4860, 0xBD27, 0xBD28, 0x574A,
+};
+static const unsigned short utf8_to_euc_E5BD_x0213[] = {
+ 0x7439, 0x573B, 0, 0, 0xBC73, 0x743A, 0, 0xAC32,
+ 0x573C, 0, 0x3630, 0, 0x573D, 0xBC76, 0x573E, 0,
+ 0xBC77, 0x5740, 0, 0x4576, 0x743B, 0, 0x5741, 0x5742,
+ 0x743C, 0x5743, 0, 0xBC7A, 0x5734, 0x5733, 0, 0,
+ 0xBC7B, 0x5744, 0x3741, 0xAC33, 0x743D, 0, 0x4927, 0x743E,
+ 0, 0x3A4C, 0x4937, 0x4426, 0x494B, 0x5745, 0, 0xBD21,
+ 0x3E34, 0x3146, 0xAC34, 0x5746, 0xBD23, 0xBD24, 0, 0x5747,
+ 0xBD25, 0x4C72, 0xBD26, 0, 0x4860, 0x743F, 0xAC35, 0x574A,
+};
+static const unsigned short utf8_to_euc_E5BE[] = {
+ 0x317D, 0x402C, 0x5749, 0x5748, 0x3742, 0x4254, 0, 0x574E,
+ 0x574C, 0xBD29, 0x574B, 0x4E27, 0x3865, 0xBD2A, 0, 0xBD2B,
+ 0x3D79, 0x574D, 0x454C, 0x3D3E, 0, 0, 0xBD2C, 0x4640,
+ 0x5751, 0x5750, 0, 0, 0xBD2D, 0xBD2E, 0x574F, 0,
+ 0x5752, 0x3866, 0xBD2F, 0, 0xBD32, 0, 0, 0xBD30,
+ 0x5753, 0x497C, 0x3D5B, 0xBD31, 0xBD33, 0x5754, 0x4879, 0xBD34,
+ 0xBD35, 0xBD36, 0, 0x4641, 0x4427, 0, 0, 0xF43E,
+ 0xBD37, 0x4530, 0, 0, 0x5755, 0x352B, 0, 0,
+};
+static const unsigned short utf8_to_euc_E5BE_x0213[] = {
+ 0x317D, 0x402C, 0x5749, 0x5748, 0x3742, 0x4254, 0, 0x574E,
+ 0x574C, 0x7440, 0x574B, 0x4E27, 0x3865, 0xBD2A, 0, 0xAC36,
+ 0x3D79, 0x574D, 0x454C, 0x3D3E, 0, 0, 0xBD2C, 0x4640,
+ 0x5751, 0x5750, 0, 0, 0x7441, 0xBD2E, 0x574F, 0,
+ 0x5752, 0x3866, 0xAC37, 0, 0xAC38, 0, 0, 0x7442,
+ 0x5753, 0x497C, 0x3D5B, 0xBD31, 0xBD33, 0x5754, 0x4879, 0x7443,
+ 0xBD35, 0xBD36, 0, 0x4641, 0x4427, 0x7444, 0, 0x7445,
+ 0xAC39, 0x4530, 0, 0, 0x5755, 0x352B, 0, 0,
+};
+static const unsigned short utf8_to_euc_E5BF[] = {
+ 0, 0, 0, 0x3F34, 0xBD38, 0x492C, 0, 0xBD39,
+ 0xBD3A, 0xBD3B, 0, 0xBD3C, 0x3477, 0x4726, 0, 0,
+ 0xBD3D, 0xBD3E, 0xBD3F, 0xBD40, 0xBD41, 0, 0x5756, 0x3B56,
+ 0x4B3A, 0x4B3B, 0, 0, 0x317E, 0x575B, 0xBD42, 0,
+ 0x4369, 0xBD43, 0xBD44, 0, 0x5758, 0, 0, 0,
+ 0xBD45, 0xBD46, 0xBD47, 0x3277, 0xBD48, 0xBD49, 0xBD4A, 0xBD4B,
+ 0x582D, 0x575A, 0xBD4C, 0xBD4D, 0, 0x4730, 0xBD4E, 0,
+ 0x5759, 0, 0xBD4F, 0x5757, 0xBD50, 0x397A, 0, 0x575D,
+};
+static const unsigned short utf8_to_euc_E5BF_x0213[] = {
+ 0, 0, 0, 0x3F34, 0xAC3A, 0x492C, 0, 0xAC3C,
+ 0xBD3A, 0x7446, 0, 0xAC3D, 0x3477, 0x4726, 0, 0,
+ 0xBD3D, 0xBD3E, 0xAC3E, 0xAC3F, 0xAC40, 0, 0x5756, 0x3B56,
+ 0x4B3A, 0x4B3B, 0, 0, 0x317E, 0x575B, 0x7447, 0,
+ 0x4369, 0x7448, 0xAC41, 0, 0x5758, 0, 0, 0,
+ 0xBD45, 0x7449, 0xBD47, 0x3277, 0xBD48, 0xBD49, 0xAC42, 0xAC43,
+ 0x582D, 0x575A, 0xBD4C, 0xAC44, 0, 0x4730, 0xBD4E, 0,
+ 0x5759, 0, 0xBD4F, 0x5757, 0xAC45, 0x397A, 0, 0x575D,
+};
+static const unsigned short utf8_to_euc_E680[] = {
+ 0, 0, 0, 0, 0, 0, 0, 0xBD51,
+ 0, 0, 0xBD52, 0, 0, 0xBD53, 0x5763, 0x5769,
+ 0x5761, 0, 0x455C, 0xBD54, 0xBD55, 0x5766, 0x495D, 0xBD56,
+ 0xBD57, 0x5760, 0xBD58, 0x5765, 0x4E67, 0x3B57, 0, 0xBD59,
+ 0x4255, 0x575E, 0, 0, 0xBD5A, 0x355E, 0x5768, 0x402D,
+ 0x3165, 0x5762, 0x3278, 0x5767, 0, 0xBD5B, 0, 0x3631,
+ 0, 0x5764, 0, 0xBD5C, 0, 0xBD5D, 0, 0,
+ 0, 0, 0x576A, 0, 0, 0, 0, 0,
+};
+static const unsigned short utf8_to_euc_E680_x0213[] = {
+ 0, 0, 0, 0, 0, 0, 0, 0xBD51,
+ 0, 0, 0xBD52, 0, 0, 0x744A, 0x5763, 0x5769,
+ 0x5761, 0, 0x455C, 0xBD54, 0x744B, 0x5766, 0x495D, 0xAC47,
+ 0x744C, 0x5760, 0xBD58, 0x5765, 0x4E67, 0x3B57, 0, 0xBD59,
+ 0x4255, 0x575E, 0xAC48, 0, 0xAC49, 0x355E, 0x5768, 0x402D,
+ 0x3165, 0x5762, 0x3278, 0x5767, 0, 0xBD5B, 0, 0x3631,
+ 0, 0x5764, 0, 0x744D, 0, 0x744E, 0, 0,
+ 0, 0, 0x576A, 0, 0, 0, 0, 0,
+};
+static const unsigned short utf8_to_euc_E681[] = {
+ 0xBD5E, 0x576C, 0x5776, 0x5774, 0, 0, 0x5771, 0xBD5F,
+ 0xBD60, 0xBD61, 0x5770, 0x4E78, 0xBD62, 0x5772, 0, 0,
+ 0x3632, 0xBD63, 0x3931, 0, 0xBD64, 0x3D7A, 0xBD65, 0xBD66,
+ 0, 0x5779, 0x576B, 0, 0, 0xBD67, 0, 0x576F,
+ 0x575F, 0xBD68, 0x327A, 0x5773, 0x5775, 0x4351, 0, 0xBD69,
+ 0x3A28, 0x3238, 0x576D, 0x5778, 0x5777, 0x3633, 0, 0x4229,
+ 0x3366, 0xBD6A, 0, 0, 0, 0x3743, 0, 0x576E,
+ 0, 0, 0, 0, 0, 0, 0xBD6B, 0xBD6C,
+};
+static const unsigned short utf8_to_euc_E681_x0213[] = {
+ 0xBD5E, 0x576C, 0x5776, 0x5774, 0, 0, 0x5771, 0x744F,
+ 0xBD60, 0xBD61, 0x5770, 0x4E78, 0xAC4B, 0x5772, 0, 0,
+ 0x3632, 0xBD63, 0x3931, 0, 0xBD64, 0x3D7A, 0xBD65, 0xBD66,
+ 0, 0x5779, 0x576B, 0, 0, 0xBD67, 0, 0x576F,
+ 0x575F, 0xBD68, 0x327A, 0x5773, 0x5775, 0x4351, 0, 0xBD69,
+ 0x3A28, 0x3238, 0x576D, 0x5778, 0x5777, 0x3633, 0, 0x4229,
+ 0x3366, 0xBD6A, 0, 0, 0, 0x3743, 0, 0x576E,
+ 0, 0, 0, 0, 0, 0, 0xBD6B, 0xAC4C,
+};
+static const unsigned short utf8_to_euc_E682[] = {
+ 0, 0x577A, 0xBD6D, 0x577D, 0x5821, 0xF43F, 0xBD6E, 0,
+ 0xBD6F, 0x3C3D, 0xBD70, 0x5827, 0x4470, 0x577B, 0xBD71, 0,
+ 0, 0xBD72, 0x5825, 0xBD73, 0x3279, 0xBD74, 0x5823, 0x5824,
+ 0xBD75, 0, 0x577E, 0x5822, 0, 0xBD76, 0xBD77, 0x3867,
+ 0x4D2A, 0, 0xBD78, 0x3435, 0xBD79, 0xBD7A, 0x3159, 0x5826,
+ 0xBD7B, 0x473A, 0x302D, 0, 0, 0, 0, 0,
+ 0xBD7C, 0xBD7D, 0x4861, 0x575C, 0x582C, 0x5830, 0x4C65, 0xBD7E,
+ 0x5829, 0, 0, 0xBE21, 0x4569, 0x582E, 0xBE22, 0,
+};
+static const unsigned short utf8_to_euc_E682_x0213[] = {
+ 0, 0x577A, 0xBD6D, 0x577D, 0x5821, 0xF43F, 0xBD6E, 0,
+ 0xBD6F, 0x3C3D, 0xAC4D, 0x5827, 0x4470, 0x577B, 0xBD71, 0,
+ 0, 0xBD72, 0x5825, 0xBD73, 0x3279, 0xAC4E, 0x5823, 0x5824,
+ 0xBD75, 0, 0x577E, 0x5822, 0, 0x7451, 0x7452, 0x3867,
+ 0x4D2A, 0, 0xBD78, 0x3435, 0xBD79, 0xBD7A, 0x3159, 0x5826,
+ 0xAC4F, 0x473A, 0x302D, 0, 0, 0, 0, 0,
+ 0xAC51, 0xAC52, 0x4861, 0x575C, 0x582C, 0x5830, 0x4C65, 0xBD7E,
+ 0x5829, 0, 0, 0xBE21, 0x4569, 0x582E, 0xAC53, 0,
+};
+static const unsigned short utf8_to_euc_E683[] = {
+ 0, 0, 0xBE23, 0, 0xBE24, 0x3E70, 0x582F, 0x4657,
+ 0xBE25, 0xBE26, 0xBE27, 0xBE28, 0, 0, 0xBE29, 0xBE2A,
+ 0, 0x4F47, 0, 0x582B, 0xBE2B, 0xBE2C, 0, 0,
+ 0x5831, 0xBE2D, 0x397B, 0xBE2E, 0x404B, 0xBE2F, 0xBE30, 0x3054,
+ 0x582A, 0x5828, 0xBE31, 0x415A, 0, 0xBE32, 0, 0x577C,
+ 0x3B34, 0, 0, 0, 0, 0, 0, 0,
+ 0x4246, 0x583D, 0xBE33, 0x415B, 0x5838, 0xBE34, 0x5835, 0x5836,
+ 0xBE35, 0x3C66, 0x5839, 0x583C, 0xBE36, 0xBE37, 0, 0,
+};
+static const unsigned short utf8_to_euc_E683_x0213[] = {
+ 0, 0, 0xBE23, 0, 0xBE24, 0x3E70, 0x582F, 0x4657,
+ 0xAC54, 0xBE26, 0xBE27, 0x7453, 0, 0, 0xBE29, 0xBE2A,
+ 0, 0x4F47, 0, 0x582B, 0x7454, 0x7455, 0, 0,
+ 0x5831, 0xAC55, 0x397B, 0xAC56, 0x404B, 0x7456, 0xBE30, 0x3054,
+ 0x582A, 0x5828, 0xBE31, 0x415A, 0, 0xBE32, 0, 0x577C,
+ 0x3B34, 0, 0, 0, 0, 0, 0xAC57, 0,
+ 0x4246, 0x583D, 0xAC58, 0x415B, 0x5838, 0xAC59, 0x5835, 0x5836,
+ 0x7457, 0x3C66, 0x5839, 0x583C, 0xBE36, 0xBE37, 0, 0,
+};
+static const unsigned short utf8_to_euc_E684[] = {
+ 0x5837, 0x3D25, 0xBE38, 0x583A, 0, 0, 0x5834, 0xBE39,
+ 0x4C7C, 0x4C7B, 0xBE3A, 0, 0xBE3B, 0x583E, 0x583F, 0x3055,
+ 0xBE3C, 0xBE3D, 0xBE3E, 0xBE3F, 0xBE40, 0x5833, 0xBE41, 0xBE42,
+ 0, 0xBE43, 0x3672, 0x3026, 0xBE44, 0, 0xBE45, 0x3436,
+ 0xF440, 0x583B, 0xBE46, 0, 0, 0, 0, 0x5843,
+ 0x5842, 0, 0xBE47, 0xBE48, 0x5847, 0, 0, 0,
+ 0xBE49, 0xBE4A, 0, 0, 0x5848, 0xBE4B, 0xBE4C, 0xBE4D,
+ 0, 0xBE4E, 0, 0, 0x5846, 0x5849, 0x5841, 0x5845,
+};
+static const unsigned short utf8_to_euc_E684_x0213[] = {
+ 0x5837, 0x3D25, 0xBE38, 0x583A, 0, 0, 0x5834, 0xBE39,
+ 0x4C7C, 0x4C7B, 0xBE3A, 0, 0xBE3B, 0x583E, 0x583F, 0x3055,
+ 0xAC5A, 0xBE3D, 0xAC5B, 0xAC5C, 0xBE40, 0x5833, 0xBE41, 0xBE42,
+ 0, 0xAC5D, 0x3672, 0x3026, 0x7458, 0, 0xAC5E, 0x3436,
+ 0xF440, 0x583B, 0xBE46, 0, 0, 0, 0, 0x5843,
+ 0x5842, 0, 0xBE47, 0x7459, 0x5847, 0, 0, 0,
+ 0x745A, 0xBE4A, 0, 0, 0x5848, 0xBE4B, 0xBE4C, 0x745B,
+ 0, 0xBE4E, 0xAC5F, 0, 0x5846, 0x5849, 0x5841, 0x5845,
+};
+static const unsigned short utf8_to_euc_E685[] = {
+ 0, 0xBE4F, 0x584A, 0, 0x584B, 0xBE50, 0xBE51, 0x5840,
+ 0x3B7C, 0xBE52, 0x5844, 0x4256, 0x3932, 0x5832, 0x3F35, 0,
+ 0, 0, 0, 0x5858, 0, 0x4A69, 0, 0,
+ 0x584E, 0x584F, 0x5850, 0, 0, 0x5857, 0xBE53, 0x5856,
+ 0xBE54, 0, 0x4B7D, 0x3437, 0, 0x5854, 0, 0x3745,
+ 0x3334, 0, 0, 0x5851, 0xBE55, 0, 0x4E38, 0x5853,
+ 0x3056, 0x5855, 0xBE56, 0x584C, 0x5852, 0x5859, 0x3744, 0x584D,
+ 0xBE57, 0, 0, 0xBE58, 0xBE59, 0, 0x4D5D, 0xBE5A,
+};
+static const unsigned short utf8_to_euc_E685_x0213[] = {
+ 0, 0xAC61, 0x584A, 0, 0x584B, 0xBE50, 0xAC62, 0x5840,
+ 0x3B7C, 0xBE52, 0x5844, 0x4256, 0x3932, 0x5832, 0x3F35, 0,
+ 0, 0, 0, 0x5858, 0, 0x4A69, 0, 0,
+ 0x584E, 0x584F, 0x5850, 0, 0, 0x5857, 0xBE53, 0x5856,
+ 0xAC63, 0, 0x4B7D, 0x3437, 0, 0x5854, 0, 0x3745,
+ 0x3334, 0, 0, 0x5851, 0xBE55, 0, 0x4E38, 0x5853,
+ 0x3056, 0x5855, 0xBE56, 0x584C, 0x5852, 0x5859, 0x3744, 0x584D,
+ 0xBE57, 0, 0, 0xBE58, 0xAC64, 0, 0x4D5D, 0xBE5A,
+};
+static const unsigned short utf8_to_euc_E686[] = {
+ 0xBE5B, 0xBE5C, 0x4D2B, 0xBE5D, 0xBE5E, 0, 0, 0x585C,
+ 0, 0, 0x5860, 0xBE5F, 0, 0xBE60, 0x417E, 0,
+ 0x4E79, 0x5861, 0xBE61, 0xBE62, 0x585E, 0, 0x585B, 0xBE63,
+ 0xBE64, 0x585A, 0x585F, 0, 0xBE65, 0xBE66, 0, 0xBE67,
+ 0xBE68, 0, 0, 0, 0x4A30, 0xBE69, 0, 0x4634,
+ 0xBE6A, 0x3746, 0xBE6B, 0x5862, 0x585D, 0xBE6C, 0x5863, 0,
+ 0, 0, 0x377B, 0, 0, 0, 0x3231, 0,
+ 0xBE6D, 0xBE6E, 0x586B, 0, 0xBE6F, 0, 0x3438, 0,
+};
+static const unsigned short utf8_to_euc_E686_x0213[] = {
+ 0xBE5B, 0xBE5C, 0x4D2B, 0xBE5D, 0xBE5E, 0, 0, 0x585C,
+ 0, 0, 0x5860, 0xBE5F, 0, 0x745D, 0x417E, 0,
+ 0x4E79, 0x5861, 0xAC66, 0xAC67, 0x585E, 0, 0x585B, 0xAC68,
+ 0xAC69, 0x585A, 0x585F, 0, 0xBE65, 0xBE66, 0, 0xBE67,
+ 0xBE68, 0, 0, 0, 0x4A30, 0xAC6A, 0, 0x4634,
+ 0xAC6B, 0x3746, 0xBE6B, 0x5862, 0x585D, 0xAC6C, 0x5863, 0,
+ 0, 0, 0x377B, 0, 0, 0, 0x3231, 0,
+ 0xBE6D, 0x7460, 0x586B, 0, 0x745F, 0, 0x3438, 0,
+};
+static const unsigned short utf8_to_euc_E687[] = {
+ 0xBE70, 0xBE71, 0xBE72, 0x5869, 0, 0, 0x586A, 0x3A29,
+ 0x5868, 0x5866, 0x5865, 0x586C, 0x5864, 0x586E, 0xBE73, 0xBE74,
+ 0x327B, 0, 0, 0, 0, 0xBE75, 0, 0,
+ 0, 0, 0, 0, 0xBE76, 0xBE77, 0xBE78, 0xBE79,
+ 0, 0xBE7A, 0xBE7B, 0x5870, 0, 0xBE7E, 0x586F, 0xBE7C,
+ 0, 0xBE7D, 0, 0, 0xBF21, 0xBF22, 0, 0xBF23,
+ 0, 0, 0x4428, 0, 0x5873, 0, 0x5871, 0x5867,
+ 0x377C, 0, 0x5872, 0, 0x5876, 0x5875, 0x5877, 0x5874,
+};
+static const unsigned short utf8_to_euc_E687_x0213[] = {
+ 0xBE70, 0xBE71, 0xBE72, 0x5869, 0, 0, 0x586A, 0x3A29,
+ 0x5868, 0x5866, 0x5865, 0x586C, 0x5864, 0x586E, 0xBE73, 0xBE74,
+ 0x327B, 0, 0, 0, 0, 0xAC6E, 0, 0,
+ 0, 0, 0, 0, 0xBE76, 0xAC6F, 0xBE78, 0xAC70,
+ 0, 0xBE7A, 0xBE7B, 0x5870, 0, 0xBE7E, 0x586F, 0xBE7C,
+ 0, 0xBE7D, 0, 0, 0xBF21, 0xBF22, 0, 0xBF23,
+ 0, 0, 0x4428, 0, 0x5873, 0xAC71, 0x5871, 0x5867,
+ 0x377C, 0, 0x5872, 0, 0x5876, 0x5875, 0x5877, 0x5874,
+};
+static const unsigned short utf8_to_euc_E688[] = {
+ 0x5878, 0xBF24, 0, 0xBF25, 0xBF26, 0, 0, 0xBF27,
+ 0x5879, 0x587A, 0x4A6A, 0, 0x587C, 0x587B, 0x3D3F, 0,
+ 0x402E, 0x3266, 0x327C, 0xBF28, 0x587D, 0xBF29, 0x303F, 0,
+ 0, 0, 0x404C, 0x587E, 0xBF2A, 0x6C43, 0x5921, 0x3761,
+ 0xBF2B, 0x5922, 0xBF2C, 0xBF2D, 0, 0, 0x406F, 0xBF2E,
+ 0, 0xBF2F, 0x5923, 0xBF30, 0, 0, 0x5924, 0x353A,
+ 0x5925, 0, 0x5926, 0x5927, 0x4257, 0, 0, 0,
+ 0x384D, 0xBF31, 0, 0x4C61, 0, 0xBF32, 0, 0x4B3C,
+};
+static const unsigned short utf8_to_euc_E688_x0213[] = {
+ 0x5878, 0xBF24, 0, 0xBF25, 0xBF26, 0, 0, 0xBF27,
+ 0x5879, 0x587A, 0x4A6A, 0, 0x587C, 0x587B, 0x3D3F, 0,
+ 0x402E, 0x3266, 0x327C, 0xBF28, 0x587D, 0xAC73, 0x303F, 0,
+ 0, 0, 0x404C, 0x587E, 0xBF2A, 0x6C43, 0x5921, 0x3761,
+ 0xBF2B, 0x5922, 0x7462, 0xAC74, 0, 0, 0x406F, 0xBF2E,
+ 0, 0xAC75, 0x5923, 0xBF30, 0, 0, 0x5924, 0x353A,
+ 0x5925, 0, 0x5926, 0x5927, 0x4257, 0, 0, 0,
+ 0x384D, 0xBF31, 0, 0x4C61, 0, 0xBF32, 0x7463, 0x4B3C,
+};
+static const unsigned short utf8_to_euc_E689[] = {
+ 0x3D6A, 0x5928, 0xBF33, 0xBF34, 0xBF35, 0, 0xBF36, 0x4070,
+ 0x6E3D, 0x4862, 0, 0x3C6A, 0xBF37, 0x3A4D, 0x5929, 0,
+ 0xBF38, 0xBF39, 0xBF3A, 0x4247, 0xBF3B, 0x4A27, 0xBF3C, 0,
+ 0x4271, 0, 0xBF3D, 0x592C, 0xBF3E, 0, 0x592A, 0,
+ 0x592D, 0, 0, 0x592B, 0xBF3F, 0, 0, 0,
+ 0x592E, 0, 0, 0, 0, 0xBF40, 0x4A31, 0xBF41,
+ 0, 0x3037, 0, 0xBF42, 0, 0, 0x495E, 0,
+ 0, 0x4863, 0xBF43, 0, 0x592F, 0xBF44, 0x5932, 0x3E35,
+};
+static const unsigned short utf8_to_euc_E689_x0213[] = {
+ 0x3D6A, 0x5928, 0xBF33, 0x7464, 0xBF35, 0, 0xAC76, 0x4070,
+ 0x6E3D, 0x4862, 0, 0x3C6A, 0xAC77, 0x3A4D, 0x5929, 0,
+ 0xBF38, 0xAC78, 0xAC79, 0x4247, 0xBF3B, 0x4A27, 0x7465, 0,
+ 0x4271, 0, 0x7466, 0x592C, 0xBF3E, 0, 0x592A, 0,
+ 0x592D, 0xAC7A, 0, 0x592B, 0xAC7B, 0, 0, 0,
+ 0x592E, 0, 0, 0, 0, 0xAC7D, 0x4A31, 0x7467,
+ 0, 0x3037, 0, 0xAC7E, 0, 0, 0x495E, 0,
+ 0, 0x4863, 0xBF43, 0xAC7C, 0x592F, 0xBF44, 0x5932, 0x3E35,
+};
+static const unsigned short utf8_to_euc_E68A[] = {
+ 0x353B, 0, 0x5930, 0x5937, 0x3E36, 0, 0, 0,
+ 0, 0x5931, 0x4744, 0, 0, 0xBF45, 0xBF46, 0xBF47,
+ 0xBF48, 0x4D5E, 0x5933, 0x5934, 0x5938, 0x456A, 0x5935, 0x3933,
+ 0x405E, 0, 0, 0x5946, 0x4834, 0, 0x4272, 0,
+ 0, 0, 0, 0, 0, 0, 0xBF49, 0,
+ 0xBF4A, 0, 0, 0x4864, 0x5A2D, 0, 0, 0,
+ 0, 0x4A7A, 0, 0xBF4B, 0, 0x4471, 0xBF4C, 0xBF4D,
+ 0, 0x4B75, 0xBF4E, 0x593B, 0x3221, 0x436A, 0xBF4F, 0xBF50,
+};
+static const unsigned short utf8_to_euc_E68A_x0213[] = {
+ 0x353B, 0, 0x5930, 0x5937, 0x3E36, 0x7468, 0, 0,
+ 0, 0x5931, 0x4744, 0, 0, 0xBF45, 0xBF46, 0xBF47,
+ 0xBF48, 0x4D5E, 0x5933, 0x5934, 0x5938, 0x456A, 0x5935, 0x3933,
+ 0x405E, 0xAD21, 0, 0x5946, 0x4834, 0, 0x4272, 0,
+ 0, 0, 0, 0, 0, 0, 0xAD22, 0,
+ 0xBF4A, 0, 0, 0x4864, 0x5A2D, 0, 0, 0,
+ 0, 0x4A7A, 0, 0xBF4B, 0, 0x4471, 0xBF4C, 0xBF4D,
+ 0, 0x4B75, 0xBF4E, 0x593B, 0x3221, 0x436A, 0xBF4F, 0xBF50,
+};
+static const unsigned short utf8_to_euc_E68B[] = {
+ 0, 0, 0x5944, 0, 0xBF51, 0x4334, 0x593E, 0x5945,
+ 0x5940, 0x5947, 0x5943, 0, 0x5942, 0x476F, 0xBF52, 0x593C,
+ 0x327D, 0x593A, 0x3571, 0x4273, 0x5936, 0xBF53, 0xBF54, 0x5939,
+ 0x3934, 0x405B, 0xBF55, 0x3E37, 0x5941, 0x4752, 0, 0,
+ 0x3572, 0x3348, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0xBF56, 0, 0x3367, 0x3F21, 0x5949, 0x594E,
+ 0, 0x594A, 0xBF57, 0x377D, 0xBF58, 0x594F, 0x3B22, 0x3969,
+ 0, 0, 0, 0, 0xBF59, 0xBF5A, 0x3D26, 0x593D,
+};
+static const unsigned short utf8_to_euc_E68B_x0213[] = {
+ 0, 0, 0x5944, 0, 0x7469, 0x4334, 0x593E, 0x5945,
+ 0x5940, 0x5947, 0x5943, 0, 0x5942, 0x476F, 0xBF52, 0x593C,
+ 0x327D, 0x593A, 0x3571, 0x4273, 0x5936, 0xAD23, 0x746A, 0x5939,
+ 0x3934, 0x405B, 0xBF55, 0x3E37, 0x5941, 0x4752, 0, 0,
+ 0x3572, 0x3348, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0xBF56, 0, 0x3367, 0x3F21, 0x5949, 0x594E,
+ 0, 0x594A, 0xBF57, 0x377D, 0xBF58, 0x594F, 0x3B22, 0x3969,
+ 0, 0, 0, 0, 0x746B, 0xAD25, 0x3D26, 0x593D,
+};
+static const unsigned short utf8_to_euc_E68C[] = {
+ 0, 0x3B7D, 0x594C, 0xBF5B, 0xBF5C, 0, 0, 0x3B58,
+ 0x594D, 0x3044, 0xBF5D, 0xBF5E, 0x5948, 0xBF5F, 0, 0,
+ 0xBF60, 0x4429, 0, 0xBF61, 0, 0, 0xBF62, 0,
+ 0xBF63, 0x3573, 0, 0, 0, 0, 0, 0x3634,
+ 0, 0, 0, 0, 0, 0, 0, 0x594B,
+ 0x3027, 0xBF64, 0xBF65, 0x3A43, 0, 0xBF66, 0, 0x3F36,
+ 0, 0, 0, 0, 0, 0xBF67, 0xBF68, 0,
+ 0, 0xBF69, 0x4472, 0, 0xBF6A, 0x4854, 0x5951, 0x415E,
+};
+static const unsigned short utf8_to_euc_E68C_x0213[] = {
+ 0, 0x3B7D, 0x594C, 0xAD26, 0xBF5C, 0, 0, 0x3B58,
+ 0x594D, 0x3044, 0x746C, 0xBF5E, 0x5948, 0xAD27, 0, 0,
+ 0xAD28, 0x4429, 0, 0xBF61, 0, 0, 0xBF62, 0,
+ 0x746D, 0x3573, 0, 0, 0, 0, 0, 0x3634,
+ 0, 0, 0, 0, 0, 0, 0, 0x594B,
+ 0x3027, 0xBF64, 0xBF65, 0x3A43, 0, 0xBF66, 0, 0x3F36,
+ 0, 0, 0xAD2B, 0, 0, 0xAD2C, 0xBF68, 0,
+ 0, 0x746E, 0x4472, 0xAD2D, 0xAD2E, 0x4854, 0x5951, 0x415E,
+};
+static const unsigned short utf8_to_euc_E68D[] = {
+ 0, 0xBF6B, 0xBF6C, 0xBF6D, 0xBF6E, 0, 0xBF6F, 0,
+ 0, 0x422A, 0xBF70, 0xBF71, 0x3B2B, 0x5952, 0xBF72, 0x5954,
+ 0x5950, 0, 0xBF73, 0xBF74, 0xBF75, 0x4A61, 0, 0x443D,
+ 0xBF76, 0, 0, 0xBF77, 0x415C, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0xBF78, 0xBF79, 0x4A7B,
+ 0x3C4E, 0x5960, 0, 0x595F, 0xBF7A, 0xBF7B, 0x3F78, 0,
+ 0, 0xBF7C, 0x377E, 0, 0xBF7D, 0xBF7E, 0x5959, 0x3E39,
+ 0xC021, 0, 0x4668, 0x4731, 0xC022, 0xC023, 0, 0xC024,
+};
+static const unsigned short utf8_to_euc_E68D_x0213[] = {
+ 0, 0xAD2F, 0xBF6C, 0x746F, 0xAD30, 0, 0xBF6F, 0,
+ 0, 0x422A, 0xBF70, 0xBF71, 0x3B2B, 0x5952, 0xAD31, 0x5954,
+ 0x5950, 0, 0xBF73, 0xBF74, 0xBF75, 0x4A61, 0, 0x443D,
+ 0xBF76, 0xAD33, 0, 0xBF77, 0x415C, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0x7470, 0xBF79, 0x4A7B,
+ 0x3C4E, 0x5960, 0, 0x595F, 0xAD36, 0xBF7B, 0x3F78, 0,
+ 0, 0xBF7C, 0x377E, 0, 0xBF7D, 0xBF7E, 0x5959, 0x3E39,
+ 0xC021, 0, 0x4668, 0x4731, 0x7471, 0xC023, 0, 0xC024,
+};
+static const unsigned short utf8_to_euc_E68E[] = {
+ 0x5957, 0, 0xC025, 0x415D, 0xC026, 0, 0, 0xC027,
+ 0x3C78, 0x595C, 0xC028, 0, 0x3E38, 0, 0x5956, 0x595B,
+ 0xC029, 0, 0x4753, 0, 0xC02A, 0xC02B, 0x5955, 0,
+ 0x3721, 0xC02C, 0xC02D, 0x335D, 0, 0, 0xC02E, 0x595D,
+ 0x4E2B, 0x3A4E, 0x4335, 0x595A, 0xC02F, 0x405C, 0xC030, 0x3935,
+ 0x3F64, 0x3166, 0x413C, 0x5958, 0x3545, 0xC031, 0xC032, 0xC033,
+ 0, 0, 0x3747, 0, 0x444F, 0x595E, 0, 0,
+ 0, 0, 0, 0x415F, 0, 0xC034, 0x5961, 0,
+};
+static const unsigned short utf8_to_euc_E68E_x0213[] = {
+ 0x5957, 0, 0xC025, 0x415D, 0xAD37, 0, 0, 0xC027,
+ 0x3C78, 0x595C, 0xC028, 0, 0x3E38, 0, 0x5956, 0x595B,
+ 0xC029, 0, 0x4753, 0, 0xAD3A, 0xC02B, 0x5955, 0,
+ 0x3721, 0xAD38, 0xC02D, 0x335D, 0, 0, 0xC02E, 0x595D,
+ 0x4E2B, 0x3A4E, 0x4335, 0x595A, 0xC02F, 0x405C, 0xC030, 0x3935,
+ 0x3F64, 0x3166, 0x413C, 0x5958, 0x3545, 0xC031, 0xC032, 0xC033,
+ 0, 0, 0x3747, 0, 0x444F, 0x595E, 0, 0,
+ 0, 0, 0, 0x415F, 0, 0xAD3B, 0x5961, 0,
+};
+static const unsigned short utf8_to_euc_E68F[] = {
+ 0x5963, 0xC035, 0, 0x4237, 0x5969, 0xC036, 0x5964, 0,
+ 0xC037, 0x5966, 0, 0, 0, 0, 0xC038, 0x4941,
+ 0x4473, 0xC039, 0x5967, 0xC03A, 0xC03B, 0xC03C, 0x4D2C, 0,
+ 0, 0, 0x4D48, 0x3439, 0xC03D, 0, 0, 0,
+ 0xC03E, 0x302E, 0, 0x5965, 0, 0xC03F, 0, 0,
+ 0, 0x5962, 0xC040, 0, 0xC041, 0, 0x3478, 0,
+ 0, 0, 0xC042, 0xC043, 0x3167, 0xC044, 0x5968, 0,
+ 0xC045, 0xC046, 0x4D49, 0, 0, 0, 0, 0,
+};
+static const unsigned short utf8_to_euc_E68F_x0213[] = {
+ 0x5963, 0xC035, 0, 0x4237, 0x5969, 0xC036, 0x5964, 0,
+ 0xC037, 0x5966, 0, 0, 0, 0, 0xC038, 0x4941,
+ 0x4473, 0xC039, 0x5967, 0xC03A, 0xAD3D, 0xAD3E, 0x4D2C, 0,
+ 0, 0, 0x4D48, 0x3439, 0xAD3F, 0, 0, 0,
+ 0xAD40, 0x302E, 0, 0x5965, 0, 0x7472, 0, 0,
+ 0, 0x5962, 0xC040, 0xAD41, 0xAD42, 0x7473, 0x3478, 0,
+ 0, 0, 0xAD43, 0xC043, 0x3167, 0x7474, 0x5968, 0xAD3C,
+ 0xC045, 0xC046, 0x4D49, 0, 0, 0, 0, 0,
+};
+static const unsigned short utf8_to_euc_E690[] = {
+ 0, 0, 0, 0, 0, 0, 0x596C, 0,
+ 0, 0xC047, 0xC048, 0, 0, 0x423B, 0, 0x5973,
+ 0xC049, 0, 0xC04A, 0x596D, 0xC04B, 0, 0x596A, 0x5971,
+ 0xC04C, 0, 0, 0, 0x5953, 0, 0xC04D, 0,
+ 0xC04E, 0, 0xC04F, 0, 0xC050, 0xC051, 0x596E, 0,
+ 0x5972, 0xC052, 0xC053, 0, 0x4842, 0x456B, 0, 0xC054,
+ 0xC055, 0, 0, 0, 0x596B, 0xC056, 0x596F, 0,
+ 0, 0, 0x3748, 0, 0, 0xC057, 0x3A71, 0xC058,
+};
+static const unsigned short utf8_to_euc_E690_x0213[] = {
+ 0, 0, 0, 0, 0, 0, 0x596C, 0,
+ 0, 0xAD44, 0xC048, 0, 0, 0x423B, 0, 0x5973,
+ 0x7475, 0, 0xC04A, 0x596D, 0x7476, 0, 0x596A, 0x5971,
+ 0xC04C, 0, 0, 0, 0x5953, 0, 0xAD45, 0,
+ 0xC04E, 0, 0x7477, 0, 0xC050, 0xAD46, 0x596E, 0,
+ 0x5972, 0xAD47, 0xC053, 0, 0x4842, 0x456B, 0, 0xAD48,
+ 0xC055, 0, 0, 0, 0x596B, 0xC056, 0x596F, 0,
+ 0, 0, 0x3748, 0, 0, 0xC057, 0x3A71, 0xC058,
+};
+static const unsigned short utf8_to_euc_E691[] = {
+ 0, 0, 0x405D, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0xC059, 0, 0, 0x5977, 0xC05A,
+ 0, 0xC05B, 0xC05C, 0xC05D, 0xC05E, 0, 0, 0,
+ 0x4526, 0, 0xC05F, 0xC060, 0xC061, 0xC062, 0, 0xC063,
+ 0xC064, 0xC065, 0, 0xC066, 0, 0, 0, 0x5974,
+ 0, 0x4B60, 0, 0, 0, 0xC067, 0, 0x5975,
+ 0, 0, 0, 0xC068, 0xC069, 0, 0x5976, 0,
+ 0x4C4E, 0, 0x4022, 0xC06A, 0, 0xC06B, 0, 0,
+};
+static const unsigned short utf8_to_euc_E691_x0213[] = {
+ 0, 0, 0x405D, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0xC059, 0, 0, 0x5977, 0xC05A,
+ 0, 0x7479, 0xC05C, 0xC05D, 0xC05E, 0, 0, 0,
+ 0x4526, 0, 0xAD49, 0xAD4A, 0xC061, 0xAD4B, 0, 0xC063,
+ 0x747A, 0xC065, 0, 0xC066, 0, 0, 0, 0x5974,
+ 0, 0x4B60, 0, 0, 0, 0x747B, 0, 0x5975,
+ 0, 0, 0, 0xAD4C, 0xC069, 0, 0x5976, 0,
+ 0x4C4E, 0x7478, 0x4022, 0xC06A, 0, 0xAD4D, 0, 0,
+};
+static const unsigned short utf8_to_euc_E692[] = {
+ 0, 0, 0, 0x3762, 0, 0xC06C, 0, 0xC06D,
+ 0x597D, 0, 0, 0, 0, 0, 0, 0xC06E,
+ 0xC06F, 0xC070, 0x3B35, 0x597A, 0, 0x5979, 0, 0,
+ 0xC071, 0xC072, 0x4732, 0xC073, 0, 0xC074, 0x4635, 0xC075,
+ 0, 0xC076, 0, 0xC077, 0x4531, 0x597B, 0xC078, 0,
+ 0xC079, 0x597C, 0, 0x496F, 0xC07A, 0x4745, 0x3B23, 0,
+ 0x4071, 0, 0x4B50, 0xC07B, 0, 0, 0, 0,
+ 0, 0x3349, 0, 0x5A25, 0x597E, 0xC07C, 0xC07D, 0xC07E,
+};
+static const unsigned short utf8_to_euc_E692_x0213[] = {
+ 0, 0, 0, 0x3762, 0, 0xC06C, 0, 0xAD4E,
+ 0x597D, 0, 0, 0, 0, 0, 0, 0xC06E,
+ 0xC06F, 0xAD4F, 0x3B35, 0x597A, 0, 0x5979, 0, 0,
+ 0xC071, 0xC072, 0x4732, 0xC073, 0, 0xAD50, 0x4635, 0xAD51,
+ 0, 0xC076, 0, 0xC077, 0x4531, 0x597B, 0xC078, 0,
+ 0xC079, 0x597C, 0, 0x496F, 0xC07A, 0x4745, 0x3B23, 0,
+ 0x4071, 0, 0x4B50, 0xC07B, 0, 0, 0, 0,
+ 0, 0x3349, 0, 0x5A25, 0x597E, 0xC07C, 0x747D, 0x747E,
+};
+static const unsigned short utf8_to_euc_E693[] = {
+ 0, 0x4D4A, 0x5A27, 0, 0xC121, 0x5A23, 0, 0x5A24,
+ 0, 0xC122, 0xC123, 0xC124, 0xC125, 0x4160, 0xC126, 0,
+ 0xC127, 0xC128, 0x5A22, 0, 0x593F, 0xC129, 0, 0xC12A,
+ 0x5A26, 0, 0x5A21, 0, 0, 0, 0, 0,
+ 0x5A2B, 0x5A2C, 0x4527, 0x5A2E, 0xC12B, 0xC12C, 0x3B24, 0x5A29,
+ 0, 0xC12D, 0xC12E, 0, 0x353C, 0xC12F, 0, 0x5A2F,
+ 0xC130, 0x5A28, 0x5A33, 0, 0x5A32, 0xC131, 0x5A31, 0xC132,
+ 0, 0, 0x5A34, 0xC133, 0, 0x5A36, 0x3E71, 0xC134,
+};
+static const unsigned short utf8_to_euc_E693_x0213[] = {
+ 0, 0x4D4A, 0x5A27, 0, 0x7521, 0x5A23, 0, 0x5A24,
+ 0, 0xC122, 0x7522, 0xAD52, 0xAD53, 0x4160, 0x747C, 0,
+ 0x7523, 0xC128, 0x5A22, 0, 0x593F, 0xAD54, 0, 0xAD55,
+ 0x5A26, 0, 0x5A21, 0, 0, 0, 0, 0,
+ 0x5A2B, 0x5A2C, 0x4527, 0x5A2E, 0xAD57, 0xAD58, 0x3B24, 0x5A29,
+ 0, 0xC12D, 0xC12E, 0, 0x353C, 0xC12F, 0, 0x5A2F,
+ 0xC130, 0x5A28, 0x5A33, 0, 0x5A32, 0xC131, 0x5A31, 0x7524,
+ 0, 0, 0x5A34, 0x7525, 0, 0x5A36, 0x3E71, 0xAD59,
+};
+static const unsigned short utf8_to_euc_E694[] = {
+ 0x5A35, 0xC135, 0, 0, 0xC136, 0x5A39, 0, 0,
+ 0xC137, 0xC138, 0xC139, 0, 0, 0, 0, 0xC13A,
+ 0, 0, 0, 0xC13B, 0xC13C, 0, 0xC13D, 0,
+ 0x5A37, 0xC13E, 0, 0xC13F, 0x5A38, 0x5970, 0xC140, 0xC141,
+ 0, 0, 0xC142, 0x5A3B, 0x5A3A, 0, 0xC143, 0,
+ 0, 0xC144, 0x5978, 0x5A3C, 0x5A30, 0, 0xC145, 0x3B59,
+ 0, 0xC146, 0, 0, 0x5A3D, 0x5A3E, 0x5A40, 0x5A3F,
+ 0x5A41, 0x327E, 0xC147, 0x3936, 0xC148, 0xC149, 0x4A7C, 0x402F,
+};
+static const unsigned short utf8_to_euc_E694_x0213[] = {
+ 0x5A35, 0xC135, 0, 0, 0xAD5A, 0x5A39, 0, 0,
+ 0xC137, 0xC138, 0xC139, 0, 0, 0, 0, 0xAD5C,
+ 0, 0, 0, 0xC13B, 0xAD5D, 0, 0xAD5E, 0,
+ 0x5A37, 0xC13E, 0, 0xC13F, 0x5A38, 0x5970, 0xAD60, 0xC141,
+ 0, 0, 0x7526, 0x5A3B, 0x5A3A, 0, 0xC143, 0,
+ 0, 0x7527, 0x5978, 0x5A3C, 0x5A30, 0, 0xC145, 0x3B59,
+ 0, 0xC146, 0xAD61, 0, 0x5A3D, 0x5A3E, 0x5A40, 0x5A3F,
+ 0x5A41, 0x327E, 0xC147, 0x3936, 0xC148, 0xC149, 0x4A7C, 0x402F,
+};
+static const unsigned short utf8_to_euc_E695[] = {
+ 0, 0, 0, 0xC14A, 0, 0x384E, 0, 0xC14B,
+ 0x5A43, 0xC14C, 0, 0, 0, 0x5A46, 0xF441, 0x4952,
+ 0xC14D, 0x355F, 0xC14E, 0, 0xC14F, 0x5A45, 0x5A44, 0x4754,
+ 0x5A47, 0x3635, 0, 0, 0, 0x5A49, 0x5A48, 0xC150,
+ 0xC151, 0, 0x343A, 0x3B36, 0, 0, 0x4658, 0xC152,
+ 0, 0, 0, 0xC153, 0x3749, 0, 0, 0,
+ 0x3F74, 0, 0x5A4A, 0, 0x4030, 0x4528, 0, 0x495F,
+ 0x5A4B, 0, 0xC154, 0, 0, 0xC155, 0, 0,
+};
+static const unsigned short utf8_to_euc_E695_x0213[] = {
+ 0, 0, 0, 0xC14A, 0xAD62, 0x384E, 0, 0xC14B,
+ 0x5A43, 0xC14C, 0, 0, 0, 0x5A46, 0xF441, 0x4952,
+ 0xC14D, 0x355F, 0xC14E, 0, 0xAD63, 0x5A45, 0x5A44, 0x4754,
+ 0x5A47, 0x3635, 0, 0, 0, 0x5A49, 0x5A48, 0xC150,
+ 0xC151, 0, 0x343A, 0x3B36, 0, 0, 0x4658, 0x7529,
+ 0, 0, 0, 0xAD64, 0x3749, 0, 0, 0,
+ 0x3F74, 0, 0x5A4A, 0, 0x4030, 0x4528, 0, 0x495F,
+ 0x5A4B, 0, 0xAD65, 0, 0, 0xC155, 0, 0,
+};
+static const unsigned short utf8_to_euc_E696[] = {
+ 0, 0xC156, 0x5A4C, 0x5A4D, 0, 0xC157, 0, 0x4A38,
+ 0x555D, 0x4046, 0xC158, 0, 0x494C, 0, 0x3A58, 0,
+ 0x4865, 0x4843, 0xC159, 0, 0, 0xC15A, 0, 0x454D,
+ 0xC15B, 0x4E41, 0, 0x5A4F, 0x3C50, 0xC15C, 0, 0x5A50,
+ 0xC15D, 0x3036, 0, 0xC15E, 0x3654, 0x404D, 0xC15F, 0x4960,
+ 0, 0, 0, 0x5A51, 0x3B42, 0x4347, 0xC160, 0x3B5B,
+ 0x3F37, 0, 0xC161, 0xC162, 0xC163, 0, 0, 0x5A52,
+ 0, 0x4A7D, 0, 0, 0x3177, 0x3B5C, 0, 0xC164,
+};
+static const unsigned short utf8_to_euc_E696_x0213[] = {
+ 0, 0xAD66, 0x5A4C, 0x5A4D, 0xAD67, 0xAD68, 0, 0x4A38,
+ 0x555D, 0x4046, 0xAD69, 0, 0x494C, 0, 0x3A58, 0,
+ 0x4865, 0x4843, 0xC159, 0, 0, 0xC15A, 0, 0x454D,
+ 0xC15B, 0x4E41, 0, 0x5A4F, 0x3C50, 0x752A, 0, 0x5A50,
+ 0xC15D, 0x3036, 0, 0xC15E, 0x3654, 0x404D, 0xC15F, 0x4960,
+ 0, 0, 0, 0x5A51, 0x3B42, 0x4347, 0xC160, 0x3B5B,
+ 0x3F37, 0, 0xAD6A, 0xC162, 0xC163, 0xAD6B, 0, 0x5A52,
+ 0xAD6C, 0x4A7D, 0, 0, 0x3177, 0x3B5C, 0, 0xAD6D,
+};
+static const unsigned short utf8_to_euc_E697[] = {
+ 0, 0x5A55, 0xC165, 0x5A53, 0x5A56, 0x4E39, 0x5A54, 0,
+ 0xC166, 0xC167, 0, 0x407B, 0x5A57, 0, 0xC168, 0x4232,
+ 0xC169, 0, 0x5A58, 0, 0xC16A, 0, 0xC16B, 0x347A,
+ 0xC16C, 0x5A5A, 0, 0x5A59, 0, 0, 0, 0xC16D,
+ 0x5A5B, 0x5A5C, 0x347B, 0, 0, 0x467C, 0x4336, 0x356C,
+ 0x3B5D, 0x4161, 0, 0, 0x3D5C, 0x3030, 0, 0,
+ 0xC16E, 0x5A5D, 0xC16F, 0, 0xC170, 0xC171, 0, 0,
+ 0, 0xC172, 0x3222, 0x5A61, 0, 0, 0xC173, 0xC174,
+};
+static const unsigned short utf8_to_euc_E697_x0213[] = {
+ 0, 0x5A55, 0xAD6E, 0x5A53, 0x5A56, 0x4E39, 0x5A54, 0,
+ 0xC166, 0xAD6F, 0, 0x407B, 0x5A57, 0, 0xC168, 0x4232,
+ 0xC169, 0, 0x5A58, 0, 0xAD70, 0, 0xC16B, 0x347A,
+ 0xC16C, 0x5A5A, 0, 0x5A59, 0, 0, 0, 0xC16D,
+ 0x5A5B, 0x5A5C, 0x347B, 0, 0, 0x467C, 0x4336, 0x356C,
+ 0x3B5D, 0x4161, 0, 0, 0x3D5C, 0x3030, 0, 0,
+ 0xC16E, 0x5A5D, 0xAD72, 0, 0xC170, 0xC171, 0, 0,
+ 0, 0xAD73, 0x3222, 0x5A61, 0xAD74, 0, 0xC173, 0xC174,
+};
+static const unsigned short utf8_to_euc_E698[] = {
+ 0xC175, 0, 0x3937, 0x5A60, 0xC176, 0, 0x3A2B, 0x3E3A,
+ 0xC177, 0xC178, 0x5A5F, 0, 0x3E3B, 0xC179, 0x4C40, 0x3A2A,
+ 0, 0xC17A, 0xC17B, 0x3057, 0x404E, 0xC17C, 0xC17D, 0,
+ 0, 0, 0, 0, 0x5A66, 0xC17E, 0xC221, 0x4031,
+ 0x3147, 0xC222, 0xC223, 0xC224, 0xC225, 0x3D55, 0xC226, 0x4B66,
+ 0x3A72, 0xC227, 0xC228, 0xC229, 0xC22A, 0x3E3C, 0xC22B, 0x4027,
+ 0xC22C, 0xC22D, 0, 0xC22E, 0x5A65, 0x5A63, 0x5A64, 0xC230,
+ 0, 0xC22F, 0, 0xF442, 0x436B, 0, 0, 0x5B26,
+};
+static const unsigned short utf8_to_euc_E698_x0213[] = {
+ 0x752C, 0, 0x3937, 0x5A60, 0xAD75, 0, 0x3A2B, 0x3E3A,
+ 0xAD76, 0x752D, 0x5A5F, 0, 0x3E3B, 0xC179, 0x4C40, 0x3A2A,
+ 0, 0xC17A, 0xC17B, 0x3057, 0x404E, 0x752E, 0xC17D, 0,
+ 0, 0, 0, 0, 0x5A66, 0xC17E, 0x752F, 0x4031,
+ 0x3147, 0xAD77, 0x7531, 0xC224, 0x7532, 0x3D55, 0xC226, 0x4B66,
+ 0x3A72, 0xC227, 0xAD78, 0x7533, 0xC22A, 0x3E3C, 0xC22B, 0x4027,
+ 0x7534, 0x7535, 0, 0x7536, 0x5A65, 0x5A63, 0x5A64, 0xC230,
+ 0, 0xC22F, 0x7530, 0xF442, 0x436B, 0, 0, 0x5B26,
+};
+static const unsigned short utf8_to_euc_E699[] = {
+ 0xC231, 0x5A6A, 0x3B7E, 0x3938, 0x5A68, 0xC232, 0xC233, 0,
+ 0, 0x5A69, 0xC234, 0x3F38, 0xC235, 0, 0xC237, 0x5A67,
+ 0, 0xC236, 0x3B2F, 0, 0, 0, 0, 0xC238,
+ 0xC239, 0xC23A, 0, 0xC23B, 0xC23C, 0x5A6C, 0x5A6B, 0x5A70,
+ 0xC23D, 0xC23E, 0x5A71, 0, 0x5A6D, 0xF443, 0x3322, 0x5A6E,
+ 0x5A6F, 0x4855, 0xC240, 0xC241, 0xC242, 0, 0x4961, 0x374A,
+ 0x5A72, 0, 0, 0xC244, 0x4032, 0xC245, 0x3E3D, 0xC247,
+ 0xC248, 0xC249, 0x4352, 0xC24A, 0xC24C, 0, 0xC243, 0xC246,
+};
+static const unsigned short utf8_to_euc_E699_x0213[] = {
+ 0xC231, 0x5A6A, 0x3B7E, 0x3938, 0x5A68, 0xAD79, 0xC233, 0,
+ 0x7538, 0x5A69, 0xC234, 0x3F38, 0x7539, 0, 0xAD7B, 0x5A67,
+ 0, 0xAD7A, 0x3B2F, 0, 0, 0, 0, 0xAD7E,
+ 0xC239, 0x753B, 0x753C, 0xAE21, 0xC23C, 0x5A6C, 0x5A6B, 0x5A70,
+ 0xC23D, 0x753D, 0x5A71, 0xAE22, 0x5A6D, 0x753E, 0x3322, 0x5A6E,
+ 0x5A6F, 0x4855, 0xAE25, 0xAE26, 0xAE27, 0xAE28, 0x4961, 0x374A,
+ 0x5A72, 0, 0, 0x753F, 0x4032, 0xC245, 0x3E3D, 0x7540,
+ 0x7541, 0xC249, 0x4352, 0xAE29, 0xC24C, 0, 0xC243, 0xC246,
+};
+static const unsigned short utf8_to_euc_E69A[] = {
+ 0xC24B, 0x3647, 0, 0x5A73, 0x5A77, 0, 0, 0x324B,
+ 0x5A74, 0x5A76, 0, 0xC24D, 0xC24E, 0xC24F, 0x5A75, 0,
+ 0xC250, 0x3D6B, 0xC251, 0, 0, 0, 0x4348, 0x3045,
+ 0x5A78, 0xC252, 0xC253, 0xC254, 0xC255, 0x5A79, 0, 0xC256,
+ 0xC257, 0, 0x442A, 0, 0xC258, 0, 0x4E71, 0,
+ 0, 0, 0, 0x3B43, 0, 0xC259, 0x4A6B, 0,
+ 0, 0xC25A, 0xC25B, 0, 0x4B3D, 0xC25C, 0, 0,
+ 0x5B22, 0x5A7B, 0, 0xC25D, 0x5A7E, 0, 0x5A7D, 0xC25E,
+};
+static const unsigned short utf8_to_euc_E69A_x0213[] = {
+ 0xAE2A, 0x3647, 0, 0x5A73, 0x5A77, 0, 0, 0x324B,
+ 0x5A74, 0x5A76, 0, 0xC24D, 0xC24E, 0x7542, 0x5A75, 0,
+ 0xAE2B, 0x3D6B, 0xAE2C, 0, 0, 0, 0x4348, 0x3045,
+ 0x5A78, 0xAE2D, 0xC253, 0xC254, 0xC255, 0x5A79, 0, 0xC256,
+ 0x7544, 0, 0x442A, 0, 0xC258, 0, 0x4E71, 0,
+ 0, 0, 0, 0x3B43, 0, 0xAE2F, 0x4A6B, 0,
+ 0, 0xAE30, 0x7545, 0, 0x4B3D, 0xAE31, 0, 0,
+ 0x5B22, 0x5A7B, 0, 0x7546, 0x5A7E, 0, 0x5A7D, 0xAE33,
+};
+static const unsigned short utf8_to_euc_E69B[] = {
+ 0xC25F, 0x5A7A, 0xC260, 0xC261, 0x5B21, 0, 0, 0x465E,
+ 0xC262, 0x5A7C, 0, 0, 0xC263, 0, 0xC264, 0xC265,
+ 0, 0, 0, 0, 0xC266, 0, 0x5B23, 0,
+ 0, 0x3D6C, 0x5B24, 0xC267, 0x4D4B, 0x4778, 0, 0xC268,
+ 0x5B25, 0, 0, 0, 0, 0, 0x5B27, 0,
+ 0xC269, 0x5B28, 0, 0xC26A, 0xC26B, 0, 0xC26C, 0,
+ 0x5B29, 0, 0x364A, 0x3148, 0x3939, 0x5B2A, 0, 0x5B2B,
+ 0x3D71, 0x4162, 0xC26D, 0xC23F, 0x5258, 0x413E, 0x413D, 0x4258,
+};
+static const unsigned short utf8_to_euc_E69B_x0213[] = {
+ 0xC25F, 0x5A7A, 0xC260, 0xC261, 0x5B21, 0, 0x7547, 0x465E,
+ 0x7548, 0x5A7C, 0, 0, 0xC263, 0, 0xC264, 0xC265,
+ 0, 0, 0, 0, 0xC266, 0, 0x5B23, 0,
+ 0, 0x3D6C, 0x5B24, 0x754A, 0x4D4B, 0x4778, 0, 0xC268,
+ 0x5B25, 0, 0, 0, 0, 0, 0x5B27, 0,
+ 0x754B, 0x5B28, 0, 0xC26A, 0xAE35, 0, 0xC26C, 0,
+ 0x5B29, 0, 0x364A, 0x3148, 0x3939, 0x5B2A, 0, 0x5B2B,
+ 0x3D71, 0x4162, 0x754C, 0x7537, 0x5258, 0x413E, 0x413D, 0x4258,
+};
+static const unsigned short utf8_to_euc_E69C[] = {
+ 0x3A47, 0, 0, 0x5072, 0, 0xC26E, 0, 0xC26F,
+ 0x376E, 0x4D2D, 0, 0x4A7E, 0, 0x497E, 0xC270, 0x5B2C,
+ 0, 0, 0, 0xC271, 0x3A73, 0x443F, 0x5B2D, 0x4F2F,
+ 0, 0xC272, 0, 0x4B3E, 0xC273, 0x442B, 0x5B2E, 0x347C,
+ 0xC274, 0, 0xC275, 0, 0, 0, 0x5B2F, 0x5B30,
+ 0x4C5A, 0, 0x4C24, 0x4B76, 0x4B5C, 0x3B25, 0x5B32, 0,
+ 0, 0x3C6B, 0, 0xC276, 0x4B51, 0, 0x5B34, 0x5B37,
+ 0x5B36, 0, 0x3479, 0, 0, 0x3560, 0xC277, 0x5B33,
+};
+static const unsigned short utf8_to_euc_E69C_x0213[] = {
+ 0x3A47, 0xAE37, 0, 0x5072, 0, 0xAE38, 0, 0xC26F,
+ 0x376E, 0x4D2D, 0, 0x4A7E, 0, 0x497E, 0xC270, 0x5B2C,
+ 0, 0, 0xAE39, 0x754D, 0x3A73, 0x443F, 0x5B2D, 0x4F2F,
+ 0, 0xAE3B, 0, 0x4B3E, 0xC273, 0x442B, 0x5B2E, 0x347C,
+ 0xC274, 0, 0xC275, 0, 0, 0, 0x5B2F, 0x5B30,
+ 0x4C5A, 0, 0x4C24, 0x4B76, 0x4B5C, 0x3B25, 0x5B32, 0,
+ 0, 0x3C6B, 0, 0x754F, 0x4B51, 0, 0x5B34, 0x5B37,
+ 0x5B36, 0, 0x3479, 0, 0, 0x3560, 0xC277, 0x5B33,
+};
+static const unsigned short utf8_to_euc_E69D[] = {
+ 0, 0x5B35, 0, 0, 0, 0xC278, 0x5B38, 0xC279,
+ 0xC27A, 0x3F79, 0, 0, 0xC27B, 0, 0x4D7B, 0x3049,
+ 0x3A60, 0x423C, 0, 0x3C5D, 0xC27C, 0xC27D, 0x3E73, 0,
+ 0, 0x5B3B, 0, 0, 0x454E, 0xC27E, 0x5B39, 0x422B,
+ 0x5B3A, 0x3E72, 0x4C5D, 0x5B3C, 0x5B3D, 0x4D68, 0xC321, 0,
+ 0, 0, 0x5B42, 0, 0xC322, 0x393A, 0xC323, 0x4755,
+ 0x5B3F, 0x456C, 0x5A5E, 0x5A62, 0xC324, 0x354F, 0xC325, 0x4747,
+ 0, 0, 0, 0xC326, 0x5B41, 0, 0x3E3E, 0x4844,
+};
+static const unsigned short utf8_to_euc_E69D_x0213[] = {
+ 0, 0x5B35, 0, 0, 0, 0xC278, 0x5B38, 0x7551,
+ 0x7552, 0x3F79, 0, 0, 0xAE3E, 0xAE3F, 0x4D7B, 0x3049,
+ 0x3A60, 0x423C, 0, 0x3C5D, 0xAE40, 0xC27D, 0x3E73, 0,
+ 0, 0x5B3B, 0, 0, 0x454E, 0xAE41, 0x5B39, 0x422B,
+ 0x5B3A, 0x3E72, 0x4C5D, 0x5B3C, 0x5B3D, 0x4D68, 0x7550, 0,
+ 0, 0, 0x5B42, 0, 0xC322, 0x393A, 0xC323, 0x4755,
+ 0x5B3F, 0x456C, 0x5A5E, 0x5A62, 0xAE45, 0x354F, 0xAE46, 0x4747,
+ 0, 0, 0, 0x7553, 0x5B41, 0, 0x3E3E, 0x4844,
+};
+static const unsigned short utf8_to_euc_E69E[] = {
+ 0, 0xC327, 0, 0, 0xC328, 0x5B47, 0, 0x487A,
+ 0, 0x5B3E, 0, 0x5B44, 0x5B43, 0, 0xC329, 0xC32A,
+ 0x404F, 0xC32B, 0, 0xC32C, 0, 0x4B6D, 0xC32D, 0x4E53,
+ 0xC32E, 0xC32F, 0x4B67, 0xC330, 0x324C, 0x3B5E, 0, 0,
+ 0x4F48, 0x5B46, 0x3F75, 0, 0, 0, 0x5B45, 0,
+ 0, 0x5B40, 0, 0, 0, 0, 0, 0x384F,
+ 0xC331, 0xC332, 0xC333, 0x5B4C, 0x5B4A, 0xC334, 0x324D, 0x5B48,
+ 0x5B4E, 0x5B54, 0, 0xC335, 0xC336, 0xC337, 0, 0,
+};
+static const unsigned short utf8_to_euc_E69E_x0213[] = {
+ 0, 0x7554, 0, 0, 0xC328, 0x5B47, 0, 0x487A,
+ 0, 0x5B3E, 0, 0x5B44, 0x5B43, 0, 0xC329, 0xC32A,
+ 0x404F, 0xC32B, 0xAE48, 0x7555, 0, 0x4B6D, 0xC32D, 0x4E53,
+ 0x7556, 0xC32F, 0x4B67, 0x7557, 0x324C, 0x3B5E, 0, 0,
+ 0x4F48, 0x5B46, 0x3F75, 0, 0, 0, 0x5B45, 0,
+ 0, 0x5B40, 0, 0, 0, 0, 0, 0x384F,
+ 0xAE4C, 0xC332, 0xAE4D, 0x5B4C, 0x5B4A, 0xC334, 0x324D, 0x5B48,
+ 0x5B4E, 0x5B54, 0, 0x7558, 0xC336, 0xC337, 0, 0,
+};
+static const unsigned short utf8_to_euc_E69F[] = {
+ 0xC339, 0x4248, 0xC33A, 0xC33B, 0x4A41, 0xC33C, 0x5B56, 0,
+ 0xC33D, 0xC33E, 0x4922, 0, 0, 0, 0x5B55, 0x4770,
+ 0x4B3F, 0x343B, 0xC33F, 0x4077, 0x3D40, 0, 0, 0xC340,
+ 0x4453, 0xC341, 0x4D2E, 0, 0xC342, 0x5B51, 0x5B50, 0,
+ 0, 0xC343, 0x5B52, 0, 0x5B4F, 0, 0xC344, 0x5B57,
+ 0, 0x5B4D, 0, 0, 0x5B4B, 0, 0x5B53, 0x5B49,
+ 0xC345, 0x436C, 0xC346, 0x4C78, 0x3C46, 0x3A74, 0xC347, 0xC348,
+ 0, 0xC338, 0, 0x3A3A, 0, 0, 0x4B6F, 0x3341,
+};
+static const unsigned short utf8_to_euc_E69F_x0213[] = {
+ 0x755A, 0x4248, 0xC33A, 0xAE4E, 0x4A41, 0xC33C, 0x5B56, 0,
+ 0xAE4F, 0xC33E, 0x4922, 0, 0, 0, 0x5B55, 0x4770,
+ 0x4B3F, 0x343B, 0xAE50, 0x4077, 0x3D40, 0, 0, 0x755B,
+ 0x4453, 0xAE51, 0x4D2E, 0xAE52, 0xC342, 0x5B51, 0x5B50, 0,
+ 0, 0xC343, 0x5B52, 0, 0x5B4F, 0, 0xC344, 0x5B57,
+ 0, 0x5B4D, 0, 0, 0x5B4B, 0, 0x5B53, 0x5B49,
+ 0xAE53, 0x436C, 0xC346, 0x4C78, 0x3C46, 0x3A74, 0xC347, 0xAE54,
+ 0, 0x7559, 0, 0x3A3A, 0x755C, 0, 0x4B6F, 0x3341,
+};
+static const unsigned short utf8_to_euc_E6A0[] = {
+ 0, 0xF446, 0x444E, 0x464A, 0x3149, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0x4072, 0xC34A, 0, 0x4034, 0x372A,
+ 0, 0xC34B, 0, 0, 0, 0xC34C, 0x5B59, 0xC34D,
+ 0, 0x393B, 0x337C, 0, 0, 0, 0, 0xC34F,
+ 0xC34E, 0x5B5B, 0x3374, 0x5B61, 0xC350, 0xC351, 0, 0xC352,
+ 0xC353, 0xC354, 0x5B5E, 0xC355, 0x4073, 0, 0, 0,
+ 0x334B, 0x3A2C, 0, 0xC356, 0x334A, 0x3A4F, 0, 0xC357,
+};
+static const unsigned short utf8_to_euc_E6A0_x0213[] = {
+ 0, 0x755D, 0x444E, 0x464A, 0x3149, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0xAE4B, 0, 0, 0x4072, 0xC34A, 0, 0x4034, 0x372A,
+ 0xAE58, 0xC34B, 0, 0, 0, 0x755F, 0x5B59, 0xAE59,
+ 0, 0x393B, 0x337C, 0, 0, 0, 0, 0xC34F,
+ 0xC34E, 0x5B5B, 0x3374, 0x5B61, 0x7560, 0xAE5A, 0, 0xC352,
+ 0xC353, 0x7561, 0x5B5E, 0xAE5C, 0x4073, 0, 0, 0,
+ 0x334B, 0x3A2C, 0, 0xAE5D, 0x334A, 0x3A4F, 0xAE5E, 0xC357,
+};
+static const unsigned short utf8_to_euc_E6A1[] = {
+ 0x5B5C, 0x3765, 0x374B, 0x456D, 0xC358, 0xC359, 0x5B5A, 0,
+ 0x3046, 0, 0xC35A, 0, 0xC35B, 0x5B5D, 0x5B5F, 0,
+ 0x364D, 0x372C, 0xC349, 0x343C, 0x354B, 0xC35C, 0, 0xC35D,
+ 0xC35E, 0x5B62, 0, 0xC35F, 0x3A79, 0x4B71, 0, 0x3B37,
+ 0, 0, 0, 0x5B63, 0, 0, 0, 0x4930,
+ 0, 0, 0, 0xC360, 0, 0, 0xC361, 0xC362,
+ 0xC363, 0xC364, 0xC365, 0, 0x5B6F, 0xC366, 0x3233, 0x5B64,
+ 0, 0xC367, 0xC368, 0xC369, 0xC36A, 0, 0x5B75, 0x5B65,
+};
+static const unsigned short utf8_to_euc_E6A1_x0213[] = {
+ 0x5B5C, 0x3765, 0x374B, 0x456D, 0xAE5F, 0xAE60, 0x5B5A, 0,
+ 0x3046, 0xAE61, 0xC35A, 0, 0xAE62, 0x5B5D, 0x5B5F, 0,
+ 0x364D, 0x372C, 0x755E, 0x343C, 0x354B, 0xAE63, 0, 0xAE64,
+ 0xC35E, 0x5B62, 0, 0x7562, 0x3A79, 0x4B71, 0, 0x3B37,
+ 0, 0, 0, 0x5B63, 0, 0, 0, 0x4930,
+ 0, 0, 0, 0xAE66, 0, 0, 0xAE67, 0xC362,
+ 0xC363, 0xC364, 0x7563, 0, 0x5B6F, 0x7564, 0x3233, 0x5B64,
+ 0, 0xC367, 0xAE68, 0xC369, 0xAE69, 0, 0x5B75, 0x5B65,
+};
+static const unsigned short utf8_to_euc_E6A2[] = {
+ 0, 0x4E42, 0xC36B, 0x5B6C, 0xC36C, 0x475F, 0xC36D, 0,
+ 0xC36E, 0, 0, 0, 0, 0x5B74, 0, 0x5B67,
+ 0, 0, 0, 0x3034, 0x5B69, 0, 0xC36F, 0x393C,
+ 0xC370, 0, 0xC371, 0x5B6B, 0xC372, 0x5B6A, 0, 0x5B66,
+ 0x5B71, 0xC373, 0x3E3F, 0xC374, 0, 0xC375, 0x546D, 0x3868,
+ 0x4D7C, 0xC376, 0xC377, 0, 0, 0x5B68, 0xC378, 0x4474,
+ 0x3323, 0x3A2D, 0xC379, 0x5B60, 0, 0x5B70, 0x3361, 0,
+ 0, 0x5B6E, 0x5B72, 0xC37A, 0x456E, 0, 0, 0,
+};
+static const unsigned short utf8_to_euc_E6A2_x0213[] = {
+ 0, 0x4E42, 0xAE6A, 0x5B6C, 0xC36C, 0x475F, 0xC36D, 0,
+ 0xC36E, 0, 0, 0, 0, 0x5B74, 0, 0x5B67,
+ 0xAE6B, 0, 0, 0x3034, 0x5B69, 0, 0xAE6C, 0x393C,
+ 0xAE6E, 0xAE6F, 0xAE70, 0x5B6B, 0xAE71, 0x5B6A, 0, 0x5B66,
+ 0x5B71, 0xC373, 0x3E3F, 0x7566, 0, 0x7567, 0x546D, 0x3868,
+ 0x4D7C, 0xC376, 0xAE72, 0xAE73, 0, 0x5B68, 0xC378, 0x4474,
+ 0x3323, 0x3A2D, 0x7568, 0x5B60, 0xAE74, 0x5B70, 0x3361, 0,
+ 0, 0x5B6E, 0x5B72, 0xAE75, 0x456E, 0, 0, 0,
+};
+static const unsigned short utf8_to_euc_E6A3[] = {
+ 0, 0, 0, 0, 0x347E, 0xC37B, 0x5C32, 0,
+ 0xC37C, 0x4C49, 0x5B77, 0x347D, 0xC37D, 0x5B7E, 0, 0xC37E,
+ 0xC421, 0xC422, 0x4B40, 0xC423, 0x5C21, 0x5C23, 0xC424, 0x5C27,
+ 0x5B79, 0xC425, 0x432A, 0, 0xC426, 0xC427, 0, 0x456F,
+ 0x5C2B, 0x5B7C, 0, 0x5C28, 0, 0xC428, 0, 0x5C22,
+ 0xC429, 0, 0xC42A, 0xC42B, 0xC42C, 0xC42D, 0x3F39, 0x5C2C,
+ 0xC42E, 0xC42F, 0x4033, 0, 0, 0xC430, 0xC431, 0,
+ 0, 0x5C2A, 0x343D, 0xC432, 0xC433, 0xC434, 0, 0,
+};
+static const unsigned short utf8_to_euc_E6A3_x0213[] = {
+ 0, 0, 0, 0xAE7A, 0x347E, 0xAE7B, 0x5C32, 0,
+ 0x7569, 0x4C49, 0x5B77, 0x347D, 0xAE7C, 0x5B7E, 0, 0xAE7D,
+ 0x756A, 0xC422, 0x4B40, 0xC423, 0x5C21, 0x5C23, 0xAE7E, 0x5C27,
+ 0x5B79, 0xAF21, 0x432A, 0, 0xC426, 0xC427, 0, 0x456F,
+ 0x5C2B, 0x5B7C, 0, 0x5C28, 0xAF22, 0xAF23, 0, 0x5C22,
+ 0x756B, 0, 0xC42A, 0xC42B, 0xAF24, 0x756C, 0x3F39, 0x5C2C,
+ 0x756D, 0x756E, 0x4033, 0, 0, 0xC430, 0xC431, 0xAF25,
+ 0, 0x5C2A, 0x343D, 0xAE76, 0x756F, 0xC434, 0, 0,
+};
+static const unsigned short utf8_to_euc_E6A4[] = {
+ 0x4F50, 0x5B76, 0, 0, 0x5C26, 0x3058, 0xC435, 0,
+ 0x5B78, 0xC436, 0xC437, 0x4C3A, 0x5B7D, 0x3F22, 0x4447, 0x5B73,
+ 0xC438, 0xC439, 0x5C25, 0xC43A, 0, 0, 0xC43B, 0xC43C,
+ 0, 0x3F7A, 0x5C2F, 0x3371, 0x3821, 0, 0, 0,
+ 0, 0x5C31, 0x5B7A, 0x5C30, 0, 0x5C29, 0x5B7B, 0,
+ 0x5C2D, 0, 0x5C2E, 0, 0, 0, 0, 0,
+ 0x5C3F, 0xC43D, 0, 0xC43E, 0x464E, 0xC43F, 0x5C24, 0,
+ 0xC440, 0x5C3B, 0, 0xC441, 0, 0x5C3D, 0, 0x4458,
+};
+static const unsigned short utf8_to_euc_E6A4_x0213[] = {
+ 0x4F50, 0x5B76, 0, 0xAF26, 0x5C26, 0x3058, 0xC435, 0xAF27,
+ 0x5B78, 0xC436, 0x7570, 0x4C3A, 0x5B7D, 0x3F22, 0x4447, 0x5B73,
+ 0xC438, 0xC439, 0x5C25, 0xC43A, 0, 0, 0xC43B, 0xC43C,
+ 0, 0x3F7A, 0x5C2F, 0x3371, 0x3821, 0, 0, 0,
+ 0, 0x5C31, 0x5B7A, 0x5C30, 0, 0x5C29, 0x5B7B, 0,
+ 0x5C2D, 0, 0x5C2E, 0, 0, 0, 0, 0,
+ 0x5C3F, 0xC43D, 0, 0xC43E, 0x464E, 0x7573, 0x5C24, 0,
+ 0xC440, 0x5C3B, 0, 0xAF2B, 0, 0x5C3D, 0, 0x4458,
+};
+static const unsigned short utf8_to_euc_E6A5[] = {
+ 0, 0, 0xC442, 0, 0, 0xC443, 0, 0,
+ 0, 0xC444, 0x4D4C, 0, 0, 0, 0xC445, 0,
+ 0, 0, 0, 0x4976, 0x5C38, 0x424A, 0, 0xC446,
+ 0, 0x5C3E, 0x413F, 0xC447, 0x5C35, 0x5C42, 0x5C41, 0,
+ 0x466F, 0x5C40, 0x466A, 0xC448, 0xC449, 0xC44A, 0xC44B, 0,
+ 0xC44C, 0xC44D, 0x5C44, 0x5C37, 0xC44E, 0x3648, 0x5C3A, 0x3D5D,
+ 0xC44F, 0xC450, 0xC451, 0x4760, 0x5C3C, 0x364B, 0, 0x5C34,
+ 0x5C36, 0x5C33, 0xC452, 0xC453, 0x4F30, 0x335A, 0x5C39, 0xC454,
+};
+static const unsigned short utf8_to_euc_E6A5_x0213[] = {
+ 0, 0, 0x7574, 0, 0, 0xC443, 0xAF2D, 0,
+ 0, 0x7571, 0x4D4C, 0, 0, 0, 0xC445, 0,
+ 0, 0, 0, 0x4976, 0x5C38, 0x424A, 0, 0x7575,
+ 0, 0x5C3E, 0x413F, 0xC447, 0x5C35, 0x5C42, 0x5C41, 0,
+ 0x466F, 0x5C40, 0x466A, 0x7576, 0x7577, 0xC44A, 0xC44B, 0,
+ 0x7578, 0xAF2E, 0x5C44, 0x5C37, 0xAF2F, 0x3648, 0x5C3A, 0x3D5D,
+ 0xC44F, 0xC450, 0xAF30, 0x4760, 0x5C3C, 0x364B, 0, 0x5C34,
+ 0x5C36, 0x5C33, 0xAF31, 0xC453, 0x4F30, 0x335A, 0x5C39, 0xAF32,
+};
+static const unsigned short utf8_to_euc_E6A6[] = {
+ 0xC455, 0x5C43, 0x3335, 0, 0, 0, 0, 0,
+ 0, 0, 0x3A67, 0, 0, 0xC456, 0x315D, 0,
+ 0, 0x5C54, 0xC457, 0, 0x4F31, 0x5C57, 0xC458, 0,
+ 0xC459, 0, 0, 0x3F3A, 0x5C56, 0, 0, 0,
+ 0x5C55, 0xC45A, 0, 0, 0, 0xC45B, 0xC45C, 0x5C52,
+ 0xC45D, 0, 0, 0xC45E, 0, 0xC45F, 0x5C46, 0xC460,
+ 0, 0x5C63, 0x5C45, 0, 0x5C58, 0, 0, 0xC461,
+ 0xC462, 0, 0xC463, 0x5C50, 0xC464, 0, 0x5C4B, 0x5C48,
+};
+static const unsigned short utf8_to_euc_E6A6_x0213[] = {
+ 0x7579, 0x5C43, 0x3335, 0, 0, 0, 0, 0,
+ 0, 0, 0x3A67, 0, 0, 0xC456, 0x315D, 0,
+ 0, 0x5C54, 0xAF33, 0, 0x4F31, 0x5C57, 0xAF35, 0,
+ 0xAF36, 0, 0, 0x3F3A, 0x5C56, 0, 0, 0,
+ 0x5C55, 0xC45A, 0, 0, 0, 0x757B, 0xAF37, 0x5C52,
+ 0xC45D, 0, 0, 0xC45E, 0, 0x757C, 0x5C46, 0xC460,
+ 0xAF38, 0x5C63, 0x5C45, 0, 0x5C58, 0, 0, 0xAF39,
+ 0xC462, 0, 0xAF3A, 0x5C50, 0xAF3B, 0, 0x5C4B, 0x5C48,
+};
+static const unsigned short utf8_to_euc_E6A7[] = {
+ 0, 0x5C49, 0, 0x5C51, 0, 0xC465, 0, 0x7422,
+ 0xC466, 0, 0x5C4E, 0x393D, 0x4448, 0x4164, 0x5C4C, 0,
+ 0x5C47, 0xC467, 0, 0x5C4A, 0, 0, 0xC468, 0xC469,
+ 0x4D4D, 0x4B6A, 0, 0, 0, 0x5C4F, 0x5C59, 0,
+ 0, 0, 0xC46A, 0, 0, 0xC46B, 0, 0x5C61,
+ 0x5C5A, 0, 0, 0x5C67, 0, 0x5C65, 0xC46C, 0xC46D,
+ 0, 0xC46E, 0x5C60, 0xC46F, 0, 0xC470, 0, 0,
+ 0, 0x5C5F, 0, 0x4450, 0, 0x4165, 0xC471, 0x5C5D,
+};
+static const unsigned short utf8_to_euc_E6A7_x0213[] = {
+ 0xAF3C, 0x5C49, 0, 0x5C51, 0, 0xC465, 0, 0x7422,
+ 0xC466, 0, 0x5C4E, 0x393D, 0x4448, 0x4164, 0x5C4C, 0x757D,
+ 0x5C47, 0xAF3D, 0, 0x5C4A, 0, 0, 0xAF3E, 0xC469,
+ 0x4D4D, 0x4B6A, 0, 0, 0, 0x5C4F, 0x5C59, 0,
+ 0, 0, 0x7622, 0xAF44, 0, 0xC46B, 0, 0x5C61,
+ 0x5C5A, 0x7623, 0x7624, 0x5C67, 0, 0x5C65, 0xAF45, 0xAF46,
+ 0, 0xC46E, 0x5C60, 0xAF47, 0xAF49, 0x7625, 0x7626, 0,
+ 0, 0x5C5F, 0, 0x4450, 0, 0x4165, 0xAF4A, 0x5C5D,
+};
+static const unsigned short utf8_to_euc_E6A8[] = {
+ 0xC472, 0xC473, 0x5C5B, 0xC474, 0, 0x5C62, 0, 0,
+ 0, 0, 0x5C68, 0x4875, 0x5C6E, 0, 0, 0xC475,
+ 0, 0xC476, 0x5C69, 0x5C6C, 0x5C66, 0xC477, 0, 0x4374,
+ 0, 0x4938, 0xC478, 0x5C5C, 0, 0xC479, 0x5C64, 0x3E40,
+ 0xC47A, 0x4C4F, 0x5C78, 0x5C6B, 0xC47B, 0, 0, 0,
+ 0xC47C, 0x3822, 0x3223, 0x335F, 0, 0, 0x5C53, 0,
+ 0xC47D, 0, 0xC47E, 0, 0xC521, 0x3E41, 0x5C70, 0xC522,
+ 0x5C77, 0x3C79, 0x3372, 0xC523, 0, 0x432E, 0xC524, 0xC525,
+};
+static const unsigned short utf8_to_euc_E6A8_x0213[] = {
+ 0xC472, 0xC473, 0x5C5B, 0xC474, 0, 0x5C62, 0, 0,
+ 0, 0, 0x5C68, 0x4875, 0x5C6E, 0, 0, 0x7627,
+ 0, 0xAF4B, 0x5C69, 0x5C6C, 0x5C66, 0x7628, 0, 0x4374,
+ 0, 0x4938, 0xAF4C, 0x5C5C, 0, 0xAF4D, 0x5C64, 0x3E40,
+ 0xC47A, 0x4C4F, 0x5C78, 0x5C6B, 0xC47B, 0, 0, 0,
+ 0xC47C, 0x3822, 0x3223, 0x335F, 0, 0, 0x5C53, 0,
+ 0xAF41, 0, 0xAF4F, 0xAF50, 0xAF51, 0x3E41, 0x5C70, 0xC522,
+ 0x5C77, 0x3C79, 0x3372, 0x762A, 0, 0x432E, 0x762B, 0xAF52,
+};
+static const unsigned short utf8_to_euc_E6A9[] = {
+ 0, 0, 0, 0, 0x5C6D, 0xC526, 0xC527, 0x5C72,
+ 0x5C76, 0xC528, 0xC529, 0x3636, 0, 0, 0xC52A, 0,
+ 0xC52B, 0xC52C, 0xC52D, 0, 0, 0xC52E, 0xC52F, 0,
+ 0x354C, 0x5C74, 0, 0xC530, 0, 0, 0, 0x3521,
+ 0, 0x464B, 0x5C73, 0, 0xC531, 0, 0x5C75, 0xC532,
+ 0, 0, 0xC533, 0xF449, 0, 0, 0, 0,
+ 0, 0xC534, 0x5C6F, 0xC535, 0, 0, 0, 0,
+ 0x5C71, 0, 0, 0, 0, 0, 0xC536, 0x3360,
+};
+static const unsigned short utf8_to_euc_E6A9_x0213[] = {
+ 0, 0, 0, 0, 0x5C6D, 0x762C, 0xAF53, 0x5C72,
+ 0x5C76, 0xAF54, 0xC529, 0x3636, 0, 0, 0xAF56, 0,
+ 0x762D, 0xC52C, 0xAF57, 0, 0, 0xC52E, 0x762E, 0,
+ 0x354C, 0x5C74, 0, 0x762F, 0, 0, 0, 0x3521,
+ 0, 0x464B, 0x5C73, 0, 0xAF58, 0, 0x5C75, 0xC532,
+ 0, 0, 0xC533, 0x7630, 0, 0, 0, 0,
+ 0, 0xC534, 0x5C6F, 0x7631, 0, 0, 0, 0,
+ 0x5C71, 0, 0xAF55, 0, 0, 0, 0xAF5A, 0x3360,
+};
+static const unsigned short utf8_to_euc_E6AA[] = {
+ 0x4349, 0xC537, 0, 0xC538, 0x5C7C, 0, 0xC539, 0xC53A,
+ 0, 0xC53B, 0, 0xC53C, 0, 0x5C7A, 0x3869, 0,
+ 0x5C79, 0xC53D, 0, 0, 0, 0, 0, 0x5D21,
+ 0, 0, 0, 0xC53E, 0x5B58, 0xC53F, 0xC540, 0xC541,
+ 0x5C7B, 0, 0x5C7D, 0x5C7E, 0, 0xC542, 0, 0,
+ 0, 0, 0x5D2C, 0xC543, 0x5D28, 0, 0x5B6D, 0xC544,
+ 0xC545, 0xC546, 0, 0x5D27, 0xC547, 0, 0, 0,
+ 0x5D26, 0, 0, 0x5D23, 0, 0xC548, 0xC549, 0xC54A,
+};
+static const unsigned short utf8_to_euc_E6AA_x0213[] = {
+ 0x4349, 0xC537, 0, 0xAF5B, 0x5C7C, 0, 0xC539, 0xC53A,
+ 0, 0x7633, 0, 0xAF5C, 0, 0x5C7A, 0x3869, 0,
+ 0x5C79, 0xAF5E, 0, 0, 0x7634, 0, 0, 0x5D21,
+ 0, 0, 0, 0xC53E, 0x5B58, 0x7635, 0x7636, 0xAF5F,
+ 0x5C7B, 0xAF60, 0x5C7D, 0x5C7E, 0, 0x7637, 0, 0,
+ 0, 0, 0x5D2C, 0xAF62, 0x5D28, 0, 0x5B6D, 0xC544,
+ 0xC545, 0xC546, 0, 0x5D27, 0xC547, 0, 0, 0,
+ 0x5D26, 0, 0, 0x5D23, 0, 0xAF63, 0xC549, 0xC54A,
+};
+static const unsigned short utf8_to_euc_E6AB[] = {
+ 0, 0x5C6A, 0x5D25, 0x5D24, 0, 0, 0xC54B, 0,
+ 0xC54D, 0xC54C, 0, 0, 0xC54E, 0, 0, 0,
+ 0xC54F, 0x5D2A, 0, 0x4F26, 0xC550, 0xC551, 0xC552, 0,
+ 0, 0, 0x5D2D, 0x367B, 0xC553, 0xC554, 0x5D29, 0x5D2B,
+ 0, 0, 0xF44A, 0, 0xC555, 0, 0, 0xC556,
+ 0x4827, 0, 0x5D2E, 0, 0xC557, 0, 0, 0,
+ 0xC558, 0xC559, 0xC55A, 0, 0, 0, 0, 0,
+ 0, 0, 0x5D32, 0x5D2F, 0xC55B, 0xC55C, 0, 0,
+};
+static const unsigned short utf8_to_euc_E6AB_x0213[] = {
+ 0, 0x5C6A, 0x5D25, 0x5D24, 0, 0, 0xAF64, 0,
+ 0xC54D, 0xC54C, 0, 0, 0xC54E, 0, 0, 0,
+ 0xAF66, 0x5D2A, 0, 0x4F26, 0xAF65, 0xC551, 0xC552, 0,
+ 0, 0, 0x5D2D, 0x367B, 0xAF67, 0xAF68, 0x5D29, 0x5D2B,
+ 0, 0, 0xF44A, 0, 0x7638, 0, 0, 0x7639,
+ 0x4827, 0, 0x5D2E, 0, 0xAF6B, 0, 0, 0,
+ 0xC558, 0xAF6C, 0xAF6D, 0xAF6E, 0, 0, 0, 0,
+ 0, 0, 0x5D32, 0x5D2F, 0xC55B, 0xAF6F, 0, 0,
+};
+static const unsigned short utf8_to_euc_E6AC[] = {
+ 0, 0, 0xC55D, 0xC55E, 0x4D73, 0x5D30, 0xC55F, 0xC560,
+ 0, 0xC561, 0x5C5E, 0, 0, 0, 0, 0xC562,
+ 0xC563, 0xC564, 0x5D33, 0, 0, 0, 0x5D34, 0xC565,
+ 0, 0, 0, 0xC566, 0, 0x3135, 0xC567, 0x5D36,
+ 0x3767, 0x3C21, 0, 0x3655, 0xC568, 0, 0, 0x3224,
+ 0xC569, 0, 0, 0xC56A, 0xC56B, 0, 0, 0xC56C,
+ 0, 0, 0x4D5F, 0, 0, 0xC56D, 0xC56E, 0x5D38,
+ 0x5D37, 0x5D3A, 0x353D, 0xC56F, 0, 0x3656, 0x343E, 0xC570,
+};
+static const unsigned short utf8_to_euc_E6AC_x0213[] = {
+ 0, 0, 0xC55D, 0xC55E, 0x4D73, 0x5D30, 0xC55F, 0xC560,
+ 0, 0xC561, 0x5C5E, 0xAF71, 0, 0, 0, 0xAF72,
+ 0xAF73, 0xAF74, 0x5D33, 0, 0, 0, 0x5D34, 0xAF76,
+ 0, 0, 0, 0x763C, 0, 0x3135, 0x763D, 0x5D36,
+ 0x3767, 0x3C21, 0, 0x3655, 0xC568, 0, 0, 0x3224,
+ 0xC569, 0, 0, 0xC56A, 0x763E, 0, 0, 0xAF78,
+ 0, 0, 0x4D5F, 0, 0, 0x763F, 0xC56E, 0x5D38,
+ 0x5D37, 0x5D3A, 0x353D, 0xC56F, 0, 0x3656, 0x343E, 0xC570,
+};
+static const unsigned short utf8_to_euc_E6AD[] = {
+ 0, 0, 0, 0x5D3D, 0, 0, 0xC571, 0x5D3C,
+ 0, 0x5D3E, 0xC572, 0, 0x324E, 0xC573, 0x4337, 0,
+ 0x5D3F, 0, 0xC574, 0x343F, 0x5D41, 0, 0xC575, 0,
+ 0xC576, 0x5D40, 0, 0x5D42, 0, 0xC577, 0, 0x5D43,
+ 0xC578, 0x5D44, 0x3B5F, 0x4035, 0x3A21, 0, 0x4970, 0xC579,
+ 0, 0x4A62, 0x4F44, 0xC57A, 0, 0, 0xC57B, 0x3B75,
+ 0xC57C, 0, 0, 0x3A50, 0x4E72, 0xC57D, 0, 0,
+ 0x5D45, 0x5D46, 0, 0x3B60, 0, 0xC57E, 0xC621, 0x5D47,
+};
+static const unsigned short utf8_to_euc_E6AD_x0213[] = {
+ 0, 0, 0, 0x5D3D, 0, 0, 0x7640, 0x5D3C,
+ 0, 0x5D3E, 0xAF79, 0, 0x324E, 0xC573, 0x4337, 0,
+ 0x5D3F, 0, 0xC574, 0x343F, 0x5D41, 0, 0x7641, 0,
+ 0xAF7A, 0x5D40, 0, 0x5D42, 0, 0xC577, 0, 0x5D43,
+ 0x7642, 0x5D44, 0x3B5F, 0x4035, 0x3A21, 0x7643, 0x4970, 0x7644,
+ 0, 0x4A62, 0x4F44, 0xC57A, 0xAF7B, 0, 0xC57B, 0x3B75,
+ 0xC57C, 0, 0, 0x3A50, 0x4E72, 0xAF7C, 0, 0x7645,
+ 0x5D45, 0x5D46, 0xAF7D, 0x3B60, 0, 0xC57E, 0xC621, 0x5D47,
+};
+static const unsigned short utf8_to_euc_E6AE[] = {
+ 0x5D48, 0, 0xC622, 0x5D4A, 0x5D49, 0xC623, 0x4B58, 0,
+ 0, 0x3D5E, 0x3C6C, 0x3B44, 0, 0x5D4B, 0, 0,
+ 0, 0, 0, 0, 0, 0x5D4D, 0x3F23, 0xC624,
+ 0x5D4C, 0, 0, 0xC625, 0, 0, 0x5D4E, 0xC626,
+ 0xC627, 0, 0xC628, 0xC629, 0x5D4F, 0, 0, 0,
+ 0xC62A, 0xC62B, 0x5D50, 0x5D51, 0xC62C, 0xC62D, 0xC62E, 0x5D52,
+ 0xC62F, 0x5D54, 0x5D53, 0x5D55, 0x3225, 0x434A, 0, 0x5D56,
+ 0xC630, 0xC631, 0x3B26, 0x334C, 0x5D57, 0xC632, 0xC633, 0x4542,
+};
+static const unsigned short utf8_to_euc_E6AE_x0213[] = {
+ 0x5D48, 0xAF7E, 0x7646, 0x5D4A, 0x5D49, 0xC623, 0x4B58, 0,
+ 0, 0x3D5E, 0x3C6C, 0x3B44, 0, 0x5D4B, 0, 0,
+ 0, 0, 0, 0, 0, 0x5D4D, 0x3F23, 0xC624,
+ 0x5D4C, 0, 0, 0xEE21, 0, 0, 0x5D4E, 0xC626,
+ 0xC627, 0, 0xC628, 0xC629, 0x5D4F, 0, 0, 0,
+ 0xC62A, 0x7647, 0x5D50, 0x5D51, 0xC62C, 0x7648, 0xEE22, 0x5D52,
+ 0xC62F, 0x5D54, 0x5D53, 0x5D55, 0x3225, 0x434A, 0, 0x5D56,
+ 0xC630, 0xC631, 0x3B26, 0x334C, 0x5D57, 0xEE24, 0xEE25, 0x4542,
+};
+static const unsigned short utf8_to_euc_E6AF[] = {
+ 0x544C, 0, 0, 0xC634, 0xC635, 0x3523, 0x5D58, 0,
+ 0, 0xC636, 0, 0x5D59, 0xC637, 0x4A6C, 0x4B68, 0,
+ 0, 0, 0x4647, 0x5D5A, 0x4866, 0, 0xC638, 0,
+ 0x487B, 0, 0xC639, 0x4C53, 0, 0, 0, 0x5D5B,
+ 0, 0xC63A, 0, 0xC63B, 0, 0, 0xC63C, 0xC63D,
+ 0, 0, 0, 0x5D5D, 0x5D5C, 0, 0xC63E, 0x5D5F,
+ 0, 0xC63F, 0, 0x5D5E, 0, 0, 0, 0xC640,
+ 0, 0xC641, 0, 0, 0, 0, 0, 0xC642,
+};
+static const unsigned short utf8_to_euc_E6AF_x0213[] = {
+ 0x544C, 0, 0, 0xC634, 0xC635, 0x3523, 0x5D58, 0xEE26,
+ 0xEE27, 0xEE28, 0, 0x5D59, 0xC637, 0x4A6C, 0x4B68, 0x764A,
+ 0, 0, 0x4647, 0x5D5A, 0x4866, 0, 0x764B, 0x764C,
+ 0x487B, 0, 0xEE29, 0x4C53, 0, 0, 0, 0x5D5B,
+ 0, 0xC63A, 0, 0xC63B, 0, 0, 0xEE2A, 0xEE2B,
+ 0, 0, 0, 0x5D5D, 0x5D5C, 0, 0xEE2C, 0x5D5F,
+ 0, 0xEE2D, 0, 0x5D5E, 0, 0, 0, 0xC640,
+ 0, 0xC641, 0, 0, 0, 0, 0, 0x764D,
+};
+static const unsigned short utf8_to_euc_E6B0[] = {
+ 0, 0, 0xC643, 0, 0xC644, 0xC645, 0, 0,
+ 0x5D61, 0xC646, 0, 0, 0, 0xC647, 0xC648, 0x3B61,
+ 0xC649, 0x4C31, 0xC64A, 0x5D62, 0x5D63, 0, 0, 0x3524,
+ 0, 0xC64B, 0, 0x5D64, 0, 0, 0, 0xC64C,
+ 0, 0, 0, 0x5D66, 0x5D65, 0, 0xC64D, 0xC64E,
+ 0xC64F, 0, 0, 0, 0xC650, 0, 0xC651, 0,
+ 0, 0, 0, 0xC652, 0x3F65, 0xC653, 0xC654, 0x4939,
+ 0x314A, 0, 0xC655, 0xC656, 0, 0, 0x4845, 0xC657,
+};
+static const unsigned short utf8_to_euc_E6B0_x0213[] = {
+ 0, 0, 0xEE2E, 0, 0xC644, 0x764E, 0, 0,
+ 0x5D61, 0xC646, 0xEE2F, 0, 0, 0xC647, 0xEE30, 0x3B61,
+ 0x764F, 0x4C31, 0xC64A, 0x5D62, 0x5D63, 0, 0, 0x3524,
+ 0, 0xC64B, 0, 0x5D64, 0, 0, 0, 0xC64C,
+ 0, 0, 0, 0x5D66, 0x5D65, 0, 0xC64D, 0xC64E,
+ 0xC64F, 0, 0, 0, 0xC650, 0, 0xC651, 0,
+ 0, 0, 0, 0x7650, 0x3F65, 0xEE31, 0xEE32, 0x4939,
+ 0x314A, 0, 0xEE33, 0xC656, 0, 0, 0x4845, 0xEE35,
+};
+static const unsigned short utf8_to_euc_E6B1[] = {
+ 0x4475, 0x3D41, 0x3561, 0, 0, 0, 0, 0,
+ 0, 0, 0xC658, 0xC659, 0, 0xC65A, 0x4846, 0xC65B,
+ 0x3C2E, 0, 0xC65C, 0, 0xC65D, 0x5D68, 0, 0x3440,
+ 0, 0xC65E, 0x3178, 0xC65F, 0xC660, 0x4672, 0x5D67, 0x393E,
+ 0x4353, 0, 0x5D69, 0, 0, 0, 0, 0xC736,
+ 0x5D71, 0, 0x5D6A, 0xC661, 0, 0xC662, 0, 0xC663,
+ 0x4241, 0, 0x3562, 0x5D72, 0xC664, 0, 0xC665, 0,
+ 0xC666, 0xC667, 0x3768, 0xC668, 0, 0x3525, 0x5D70, 0,
+};
+static const unsigned short utf8_to_euc_E6B1_x0213[] = {
+ 0x4475, 0x3D41, 0x3561, 0, 0, 0, 0, 0,
+ 0, 0, 0xC658, 0xC659, 0, 0xEE36, 0x4846, 0xC65B,
+ 0x3C2E, 0, 0xC65C, 0, 0xC65D, 0x5D68, 0, 0x3440,
+ 0, 0x7651, 0x3178, 0xEE37, 0x7652, 0x4672, 0x5D67, 0x393E,
+ 0x4353, 0, 0x5D69, 0, 0, 0, 0, 0xEE4F,
+ 0x5D71, 0, 0x5D6A, 0xC661, 0, 0xEE38, 0, 0xC663,
+ 0x4241, 0, 0x3562, 0x5D72, 0x7654, 0, 0x7655, 0,
+ 0xC666, 0xC667, 0x3768, 0xC668, 0, 0x3525, 0x5D70, 0,
+};
+static const unsigned short utf8_to_euc_E6B2[] = {
+ 0, 0x5D6E, 0x5D6B, 0x4D60, 0, 0xC669, 0xC66A, 0xC66B,
+ 0x4440, 0xC66C, 0, 0, 0x4659, 0x5D6C, 0, 0,
+ 0x5D74, 0, 0x5D73, 0x3723, 0xC66D, 0xC66E, 0x322D, 0xC66F,
+ 0xC670, 0x3A3B, 0x5D6D, 0x5D6F, 0xC671, 0, 0, 0xC672,
+ 0, 0x4B57, 0x4274, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0x4B77, 0, 0, 0x5D7C, 0,
+ 0xC673, 0x5D7D, 0xC674, 0x324F, 0xC675, 0, 0, 0,
+ 0x4A28, 0x4C7D, 0x5E21, 0x3C23, 0x3E42, 0x5D78, 0x5D7E, 0x3168,
+};
+static const unsigned short utf8_to_euc_E6B2_x0213[] = {
+ 0, 0x5D6E, 0x5D6B, 0x4D60, 0xEE39, 0x7656, 0x7657, 0xC66B,
+ 0x4440, 0xEE3A, 0, 0, 0x4659, 0x5D6C, 0, 0,
+ 0x5D74, 0, 0x5D73, 0x3723, 0xEE3C, 0xEE3D, 0x322D, 0xEE3E,
+ 0x7658, 0x3A3B, 0x5D6D, 0x5D6F, 0x7659, 0, 0, 0xC672,
+ 0, 0x4B57, 0x4274, 0, 0, 0, 0, 0,
+ 0, 0, 0x7653, 0x4B77, 0, 0xEE3F, 0x5D7C, 0,
+ 0xC673, 0x5D7D, 0xC674, 0x324F, 0xC675, 0, 0, 0,
+ 0x4A28, 0x4C7D, 0x5E21, 0x3C23, 0x3E42, 0x5D78, 0x5D7E, 0x3168,
+};
+static const unsigned short utf8_to_euc_E6B3[] = {
+ 0, 0x3637, 0xC676, 0, 0x5D75, 0x5D7A, 0xC677, 0,
+ 0, 0x4074, 0x4771, 0, 0x4867, 0xC678, 0, 0xC679,
+ 0xC67A, 0xC67B, 0xC67C, 0x5D77, 0xC67D, 0x4B21, 0xC67E, 0x5D79,
+ 0, 0x5E24, 0xC721, 0x5E22, 0xC722, 0x5D7B, 0, 0,
+ 0xC723, 0x4B22, 0x4748, 0x3563, 0, 0x4525, 0, 0xC724,
+ 0x436D, 0xC725, 0x5E25, 0xC726, 0xC727, 0, 0xC728, 0x5E23,
+ 0x4259, 0x5D76, 0xC729, 0x314B, 0xC72A, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+};
+static const unsigned short utf8_to_euc_E6B3_x0213[] = {
+ 0, 0x3637, 0xEE40, 0, 0x5D75, 0x5D7A, 0x765B, 0,
+ 0, 0x4074, 0x4771, 0, 0x4867, 0xC678, 0, 0xC679,
+ 0xEE41, 0xC67B, 0xC67C, 0x5D77, 0x765C, 0x4B21, 0xEE43, 0x5D79,
+ 0, 0x5E24, 0xEE44, 0x5E22, 0xEE45, 0x5D7B, 0, 0,
+ 0x765D, 0x4B22, 0x4748, 0x3563, 0, 0x4525, 0, 0xC724,
+ 0x436D, 0xEE46, 0x5E25, 0x765E, 0xEE47, 0xEE48, 0x765F, 0x5E23,
+ 0x4259, 0x5D76, 0xC729, 0x314B, 0xC72A, 0, 0, 0,
+ 0, 0, 0, 0x765A, 0, 0, 0, 0,
+};
+static const unsigned short utf8_to_euc_E6B4[] = {
+ 0, 0, 0, 0, 0xC72B, 0, 0, 0xC72C,
+ 0, 0, 0xC72D, 0x4D4E, 0x5E30, 0, 0xC72E, 0xC72F,
+ 0, 0xC730, 0x5E2F, 0xC731, 0, 0, 0, 0x4076,
+ 0, 0x5E2C, 0xC732, 0x4D6C, 0, 0, 0x4636, 0x5E26,
+ 0, 0, 0, 0, 0, 0x4445, 0xC733, 0xC734,
+ 0xC735, 0x314C, 0x393F, 0x5E29, 0, 0, 0xC737, 0xC738,
+ 0, 0xC739, 0x3D27, 0x5E2E, 0, 0x5E2D, 0x5E28, 0,
+ 0x5E2B, 0xC73A, 0, 0x3368, 0xC73B, 0x5E2A, 0x4749, 0xC73C,
+};
+static const unsigned short utf8_to_euc_E6B4_x0213[] = {
+ 0xEE4A, 0, 0, 0, 0x7661, 0, 0, 0xC72C,
+ 0, 0, 0xEE4B, 0x4D4E, 0x5E30, 0, 0x7662, 0xC72F,
+ 0, 0xC730, 0x5E2F, 0xC731, 0, 0, 0, 0x4076,
+ 0, 0x5E2C, 0xC732, 0x4D6C, 0, 0, 0x4636, 0x5E26,
+ 0, 0, 0, 0, 0xEE4C, 0x4445, 0xEE4D, 0xEE4E,
+ 0xC735, 0x314C, 0x393F, 0x5E29, 0, 0, 0x7663, 0xEE50,
+ 0, 0x7664, 0x3D27, 0x5E2E, 0xEE65, 0x5E2D, 0x5E28, 0,
+ 0x5E2B, 0x7665, 0, 0x3368, 0xEE51, 0x5E2A, 0x4749, 0x7666,
+};
+static const unsigned short utf8_to_euc_E6B5[] = {
+ 0, 0x4E2E, 0, 0, 0x3E74, 0x4075, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0xC73D,
+ 0, 0x5E36, 0x5E34, 0, 0x494D, 0, 0xC73E, 0xC73F,
+ 0, 0xC740, 0, 0x5E31, 0x5E33, 0xC741, 0x313A, 0xC742,
+ 0, 0x3940, 0x4F32, 0, 0x333D, 0, 0x4962, 0xC743,
+ 0xC744, 0, 0, 0, 0x4D61, 0, 0, 0x3324,
+ 0x3F3B, 0x5E35, 0, 0, 0xC745, 0, 0, 0,
+};
+static const unsigned short utf8_to_euc_E6B5_x0213[] = {
+ 0, 0x4E2E, 0, 0, 0x3E74, 0x4075, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0xC73D,
+ 0x7667, 0x5E36, 0x5E34, 0xEE52, 0x494D, 0, 0xEE53, 0xC73F,
+ 0xEE54, 0xC740, 0, 0x5E31, 0x5E33, 0x7668, 0x313A, 0xC742,
+ 0, 0x3940, 0x4F32, 0, 0x333D, 0, 0x4962, 0xC743,
+ 0xEE55, 0, 0, 0, 0x4D61, 0, 0, 0x3324,
+ 0x3F3B, 0x5E35, 0, 0, 0xC745, 0, 0, 0,
+};
+static const unsigned short utf8_to_euc_E6B6[] = {
+ 0, 0, 0xC746, 0, 0, 0x5E3A, 0, 0xC747,
+ 0x3E43, 0, 0, 0, 0x4D30, 0, 0x5E37, 0,
+ 0, 0xC748, 0xC749, 0x5E32, 0xC74A, 0x5E38, 0xC74B, 0xC74C,
+ 0xC74D, 0x4E5E, 0, 0x4573, 0x4642, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0xC74E, 0, 0xC74F, 0, 0, 0x3336,
+ 0, 0, 0x3155, 0, 0xC750, 0x5E3E, 0, 0xC751,
+ 0x5E41, 0xC752, 0, 0, 0x4E43, 0xC753, 0, 0xC754,
+};
+static const unsigned short utf8_to_euc_E6B6_x0213[] = {
+ 0xEE56, 0xEE57, 0x766A, 0, 0, 0x5E3A, 0, 0x766B,
+ 0x3E43, 0x766C, 0xEE58, 0, 0x4D30, 0xEE59, 0x5E37, 0,
+ 0, 0xEE5A, 0xC749, 0x5E32, 0x766D, 0x5E38, 0xC74B, 0xC74C,
+ 0xEE5B, 0x4E5E, 0, 0x4573, 0x4642, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0x766E, 0xEE61, 0x766F, 0, 0xEE62, 0x3336,
+ 0, 0, 0x3155, 0, 0xEE63, 0x5E3E, 0, 0xC751,
+ 0x5E41, 0xC752, 0, 0, 0x4E43, 0xC753, 0, 0x7670,
+};
+static const unsigned short utf8_to_euc_E6B7[] = {
+ 0x4D64, 0, 0, 0, 0xC755, 0x5E48, 0x5E42, 0x5E3F,
+ 0xC756, 0, 0xC757, 0x4E54, 0x5E45, 0, 0xC758, 0xC759,
+ 0, 0x3D4A, 0x5E47, 0, 0, 0x5E4C, 0xC75A, 0,
+ 0x4571, 0x5E4A, 0, 0xC75B, 0, 0xC75C, 0x5E44, 0xC75D,
+ 0xC75E, 0x4338, 0xC75F, 0, 0x5E4B, 0xC760, 0x5E40, 0,
+ 0x5E46, 0xC761, 0x5E4D, 0x307C, 0x5E43, 0, 0x5E4E, 0xC762,
+ 0xC763, 0x3F3C, 0xF44C, 0x3D5F, 0xC764, 0x4A25, 0xC765, 0x3A2E,
+ 0xF44B, 0x5E3B, 0x5E49, 0x453A, 0xC766, 0, 0, 0,
+};
+static const unsigned short utf8_to_euc_E6B7_x0213[] = {
+ 0x4D64, 0, 0xEE64, 0, 0x7671, 0x5E48, 0x5E42, 0x5E3F,
+ 0xEE66, 0, 0xC757, 0x4E54, 0x5E45, 0, 0xEE67, 0xEE68,
+ 0xEE69, 0x3D4A, 0x5E47, 0, 0, 0x5E4C, 0x7672, 0,
+ 0x4571, 0x5E4A, 0x7673, 0x7674, 0, 0x7675, 0x5E44, 0xEE6A,
+ 0xC75E, 0x4338, 0xC75F, 0, 0x5E4B, 0xC760, 0x5E40, 0,
+ 0x5E46, 0xEE6B, 0x5E4D, 0x307C, 0x5E43, 0, 0x5E4E, 0xC762,
+ 0xC763, 0x3F3C, 0xF44C, 0x3D5F, 0xC764, 0x4A25, 0xEE6C, 0x3A2E,
+ 0xF44B, 0x5E3B, 0x5E49, 0x453A, 0x7676, 0, 0, 0,
+};
+static const unsigned short utf8_to_euc_E6B8[] = {
+ 0xC767, 0, 0, 0, 0xC768, 0x4036, 0, 0x3369,
+ 0x3A51, 0x3E44, 0x5E3D, 0x3D42, 0, 0, 0, 0,
+ 0, 0, 0, 0x374C, 0, 0x5E3C, 0, 0,
+ 0, 0x5E52, 0x3D6D, 0x383A, 0, 0x5E61, 0xC769, 0x5E5B,
+ 0x3574, 0x454F, 0xC76A, 0x5E56, 0x5E5F, 0x302F, 0x3132, 0xC76B,
+ 0, 0x3239, 0, 0x5E58, 0x422C, 0x5E4F, 0x5E51, 0x3941,
+ 0, 0, 0xC76C, 0, 0, 0, 0xC76D, 0,
+ 0x5E62, 0xC76E, 0x5E5D, 0xC76F, 0xC770, 0, 0x5E55, 0,
+};
+static const unsigned short utf8_to_euc_E6B8_x0213[] = {
+ 0xC767, 0, 0, 0, 0xC768, 0x4036, 0, 0x3369,
+ 0x3A51, 0x3E44, 0x5E3D, 0x3D42, 0, 0, 0, 0,
+ 0, 0, 0, 0x374C, 0, 0x5E3C, 0, 0xEE5D,
+ 0, 0x5E52, 0x3D6D, 0x383A, 0, 0x5E61, 0xEE6E, 0x5E5B,
+ 0x3574, 0x454F, 0xEE6F, 0x5E56, 0x5E5F, 0x302F, 0x3132, 0xEE70,
+ 0, 0x3239, 0, 0x5E58, 0x422C, 0x5E4F, 0x5E51, 0x3941,
+ 0, 0, 0xEE72, 0, 0x7678, 0, 0xEE6D, 0,
+ 0x5E62, 0xC76E, 0x5E5D, 0xC76F, 0xEE73, 0, 0x5E55, 0,
+};
+static const unsigned short utf8_to_euc_E6B9[] = {
+ 0, 0, 0, 0x5E5C, 0xC771, 0xC772, 0, 0,
+ 0xC773, 0xC774, 0x4C2B, 0xC775, 0, 0x5E5A, 0x5E5E, 0xC776,
+ 0, 0xC777, 0xC778, 0xC779, 0xC77A, 0, 0x3850, 0xC77B,
+ 0x3E45, 0, 0, 0x4339, 0xC77C, 0xC77D, 0xC77E, 0x5E54,
+ 0, 0, 0xC821, 0xC822, 0, 0, 0, 0x4D2F,
+ 0xC823, 0, 0, 0x5E57, 0, 0, 0x5E50, 0x4572,
+ 0, 0, 0x5E53, 0xC824, 0, 0, 0x5E59, 0,
+ 0, 0, 0, 0xC825, 0, 0xC826, 0x4F51, 0x3C3E,
+};
+static const unsigned short utf8_to_euc_E6B9_x0213[] = {
+ 0, 0, 0, 0x5E5C, 0x7679, 0xC772, 0, 0,
+ 0xEE74, 0xEE75, 0x4C2B, 0xEE76, 0xEE77, 0x5E5A, 0x5E5E, 0xEE78,
+ 0, 0xEE79, 0xC778, 0xEE7A, 0xEE7B, 0, 0x3850, 0xEE7C,
+ 0x3E45, 0, 0, 0x4339, 0x767A, 0xC77D, 0x767B, 0x5E54,
+ 0, 0, 0xC821, 0xEE7D, 0, 0, 0, 0x4D2F,
+ 0xC823, 0, 0, 0x5E57, 0, 0, 0x5E50, 0x4572,
+ 0, 0, 0x5E53, 0xC824, 0, 0, 0x5E59, 0,
+ 0, 0, 0, 0xC825, 0, 0xC826, 0x4F51, 0x3C3E,
+};
+static const unsigned short utf8_to_euc_E6BA[] = {
+ 0x4B7E, 0, 0x5E63, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0x482E, 0xC827, 0, 0x5E6F,
+ 0x383B, 0, 0, 0xC828, 0, 0, 0x3D60, 0,
+ 0x5E65, 0xC829, 0, 0, 0x4E2F, 0x3942, 0, 0x5E72,
+ 0xC82A, 0, 0x306E, 0, 0, 0x5E70, 0, 0xC82B,
+ 0, 0, 0x5E64, 0, 0, 0xC82C, 0xC82D, 0x5E6A,
+ 0, 0xC82E, 0x5E6C, 0xC82F, 0, 0, 0x4D4F, 0x5E67,
+ 0, 0, 0x452E, 0xC830, 0, 0x5E69, 0, 0xC831,
+};
+static const unsigned short utf8_to_euc_E6BA_x0213[] = {
+ 0x4B7E, 0, 0x5E63, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0x482E, 0xC827, 0, 0x5E6F,
+ 0x383B, 0, 0, 0xEF21, 0, 0, 0x3D60, 0,
+ 0x5E65, 0xC829, 0, 0, 0x4E2F, 0x3942, 0, 0x5E72,
+ 0xC82A, 0, 0x306E, 0, 0, 0x5E70, 0, 0xEF22,
+ 0, 0, 0x5E64, 0x767C, 0, 0xC82C, 0xC82D, 0x5E6A,
+ 0, 0x767D, 0x5E6C, 0xC82F, 0xEF23, 0, 0x4D4F, 0x5E67,
+ 0, 0, 0x452E, 0xC830, 0, 0x5E69, 0, 0xEF24,
+};
+static const unsigned short utf8_to_euc_E6BB[] = {
+ 0xC832, 0xC833, 0x5E71, 0xC834, 0x5E6B, 0x4C47, 0, 0xC835,
+ 0xC836, 0x5E66, 0xC837, 0x3C22, 0x5E7E, 0xC838, 0xC839, 0xC83A,
+ 0, 0x336A, 0, 0x5E68, 0x5E6D, 0x5E6E, 0, 0,
+ 0, 0, 0, 0, 0, 0x426C, 0x425A, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0xC83B, 0x5E76, 0xC83C, 0xC83D, 0x5E7C,
+ 0, 0, 0x5E7A, 0, 0x4529, 0, 0, 0x5F23,
+ 0x5E77, 0xC83E, 0, 0xC83F, 0, 0xC840, 0x5E78, 0x5E60,
+};
+static const unsigned short utf8_to_euc_E6BB_x0213[] = {
+ 0xC832, 0x767E, 0x5E71, 0xEF25, 0x5E6B, 0x4C47, 0, 0x7721,
+ 0xC836, 0x5E66, 0xEF26, 0x3C22, 0x5E7E, 0xC838, 0x7722, 0xC83A,
+ 0, 0x336A, 0, 0x5E68, 0x5E6D, 0x5E6E, 0, 0,
+ 0, 0xEF27, 0, 0, 0, 0x426C, 0x425A, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0xEF29, 0x5E76, 0xC83C, 0xC83D, 0x5E7C,
+ 0, 0, 0x5E7A, 0, 0x4529, 0, 0, 0x5F23,
+ 0x5E77, 0xEF2A, 0, 0xEF2B, 0, 0xC840, 0x5E78, 0x5E60,
+};
+static const unsigned short utf8_to_euc_E6BC[] = {
+ 0, 0x3579, 0x493A, 0, 0xC841, 0, 0x3C3F, 0,
+ 0xC842, 0x3977, 0xC843, 0, 0xC844, 0xC845, 0, 0x4F33,
+ 0, 0x5E74, 0, 0x5F22, 0x3169, 0x4166, 0xC846, 0,
+ 0xC847, 0, 0xC848, 0xC849, 0, 0, 0, 0,
+ 0x4779, 0, 0x3441, 0x4E7A, 0, 0, 0xC84A, 0,
+ 0, 0xC84B, 0xC84C, 0x4C21, 0x4452, 0xC853, 0, 0xC84D,
+ 0xC84E, 0x5E7B, 0x5E7D, 0xC84F, 0, 0, 0xC850, 0,
+ 0x4132, 0, 0, 0xC851, 0xC852, 0, 0x5F21, 0x5E79,
+};
+static const unsigned short utf8_to_euc_E6BC_x0213[] = {
+ 0, 0x3579, 0x493A, 0, 0xC841, 0, 0x3C3F, 0,
+ 0xC842, 0x3977, 0xEF2C, 0, 0xEF2D, 0xC845, 0, 0x4F33,
+ 0x7723, 0x5E74, 0, 0x5F22, 0x3169, 0x4166, 0xC846, 0,
+ 0xEF2E, 0, 0x7724, 0xC849, 0, 0, 0, 0,
+ 0x4779, 0, 0x3441, 0x4E7A, 0, 0xEF2F, 0xC84A, 0,
+ 0, 0xC84B, 0x7726, 0x4C21, 0x4452, 0xC853, 0, 0x7727,
+ 0xC84E, 0x5E7B, 0x5E7D, 0x7728, 0, 0xEF28, 0xEF30, 0,
+ 0x4132, 0, 0, 0xC851, 0xEF31, 0, 0x5F21, 0x5E79,
+};
+static const unsigned short utf8_to_euc_E6BD[] = {
+ 0, 0x5E73, 0, 0, 0, 0x3443, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0xC854,
+ 0, 0xC855, 0xC856, 0xC857, 0x3769, 0, 0, 0xC858,
+ 0x5F2F, 0xC859, 0xC85A, 0x5F2A, 0x4078, 0xC85B, 0xC85C, 0x3363,
+ 0, 0xC85D, 0xC85E, 0, 0x3D61, 0, 0x5F33, 0,
+ 0xC85F, 0, 0, 0, 0xC860, 0x5F2C, 0x442C, 0x5F29,
+ 0x4459, 0, 0, 0, 0x5F4C, 0, 0, 0,
+ 0x5F26, 0, 0x5F25, 0, 0x5F2E, 0xC861, 0xC862, 0,
+};
+static const unsigned short utf8_to_euc_E6BD_x0213[] = {
+ 0, 0x5E73, 0, 0, 0, 0x3443, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0xC854,
+ 0, 0x7729, 0xEF33, 0xC857, 0x3769, 0, 0, 0xEF34,
+ 0x5F2F, 0x772A, 0xEF35, 0x5F2A, 0x4078, 0xC85B, 0x772B, 0x3363,
+ 0xEF36, 0x772C, 0x772D, 0, 0x3D61, 0, 0x5F33, 0,
+ 0xEF37, 0, 0, 0, 0xC860, 0x5F2C, 0x442C, 0x5F29,
+ 0x4459, 0, 0, 0, 0x5F4C, 0, 0, 0,
+ 0x5F26, 0, 0x5F25, 0, 0x5F2E, 0xEF39, 0x772E, 0,
+};
+static const unsigned short utf8_to_euc_E6BE[] = {
+ 0x5F28, 0x5F27, 0x5F2D, 0xC863, 0x4021, 0, 0x5F24, 0xC864,
+ 0xC865, 0, 0, 0xC866, 0xC867, 0xC868, 0x5F30, 0,
+ 0xC869, 0x5F31, 0xC86A, 0xC86B, 0xC86C, 0, 0xC86D, 0x3442,
+ 0, 0, 0xC86E, 0, 0, 0, 0, 0xC86F,
+ 0xC870, 0x5F36, 0, 0x5F35, 0x5F37, 0xC871, 0xC872, 0xC873,
+ 0xC874, 0, 0x5F3A, 0, 0, 0, 0xC875, 0xC876,
+ 0xC877, 0x4543, 0, 0x5F34, 0, 0xC878, 0xC879, 0,
+ 0, 0x5F38, 0, 0, 0xC87A, 0, 0, 0,
+};
+static const unsigned short utf8_to_euc_E6BE_x0213[] = {
+ 0x5F28, 0x5F27, 0x5F2D, 0xC863, 0x4021, 0, 0x5F24, 0xC864,
+ 0x772F, 0, 0, 0xC866, 0x7730, 0x7731, 0x5F30, 0,
+ 0xEF3A, 0x5F31, 0xC86A, 0xC86B, 0x7732, 0, 0xEF3B, 0x3442,
+ 0xEF38, 0, 0xC86E, 0, 0, 0, 0, 0xEF3D,
+ 0x7733, 0x5F36, 0, 0x5F35, 0x5F37, 0xEF3E, 0xC872, 0x7734,
+ 0xC874, 0, 0x5F3A, 0, 0, 0, 0xC875, 0xEF3F,
+ 0xC877, 0x4543, 0, 0x5F34, 0, 0xEF41, 0x7735, 0,
+ 0, 0x5F38, 0, 0, 0x7736, 0, 0xEF3C, 0,
+};
+static const unsigned short utf8_to_euc_E6BF[] = {
+ 0x3763, 0x4279, 0x5F32, 0x473B, 0, 0xC87B, 0x5F39, 0xC87C,
+ 0xC87D, 0, 0xC87E, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0x5F3E, 0x5F3C, 0, 0,
+ 0x5F3F, 0, 0xC921, 0x5F42, 0, 0, 0xC922, 0x5F3B,
+ 0x396A, 0x4728, 0, 0, 0x5E39, 0, 0, 0,
+ 0xC923, 0xC924, 0, 0x4D74, 0x5F3D, 0, 0x5F41, 0x4275,
+ 0xC925, 0x5F40, 0, 0x5F2B, 0, 0xC926, 0x6F69, 0,
+ 0, 0xC927, 0x5F45, 0, 0xC928, 0xC929, 0x5F49, 0,
+};
+static const unsigned short utf8_to_euc_E6BF_x0213[] = {
+ 0x3763, 0x4279, 0x5F32, 0x473B, 0, 0xC87B, 0x5F39, 0x7737,
+ 0xEF42, 0xEF43, 0x7738, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0x5F3E, 0x5F3C, 0, 0,
+ 0x5F3F, 0, 0xEF44, 0x5F42, 0, 0, 0xEF45, 0x5F3B,
+ 0x396A, 0x4728, 0, 0, 0x5E39, 0, 0, 0,
+ 0xC923, 0xEF46, 0, 0x4D74, 0x5F3D, 0, 0x5F41, 0x4275,
+ 0x773A, 0x5F40, 0, 0x5F2B, 0, 0x773B, 0x6F69, 0,
+ 0, 0x7739, 0x5F45, 0, 0xEF48, 0xC929, 0x5F49, 0,
+};
+static const unsigned short utf8_to_euc_E780[] = {
+ 0xC92A, 0x5F47, 0, 0, 0, 0xC92B, 0xC92C, 0xC92D,
+ 0, 0x5F43, 0, 0x5F44, 0, 0xC92E, 0, 0x5F48,
+ 0, 0x5F46, 0, 0, 0, 0x494E, 0, 0xC92F,
+ 0x5F4E, 0, 0x5F4B, 0x5F4A, 0, 0x5F4D, 0x4654, 0x5F4F,
+ 0xC930, 0, 0, 0xC931, 0, 0, 0x4375, 0x426D,
+ 0xF44D, 0, 0, 0, 0x4025, 0, 0, 0xC932,
+ 0x5F50, 0, 0x5F52, 0, 0xC933, 0, 0, 0xC934,
+ 0, 0xC935, 0, 0, 0xC936, 0, 0x5F51, 0,
+};
+static const unsigned short utf8_to_euc_E780_x0213[] = {
+ 0xEF49, 0x5F47, 0, 0, 0, 0x773C, 0x773D, 0xEF4A,
+ 0, 0x5F43, 0xEF4B, 0x5F44, 0, 0xC92E, 0, 0x5F48,
+ 0, 0x5F46, 0, 0, 0, 0x494E, 0, 0xC92F,
+ 0x5F4E, 0, 0x5F4B, 0x5F4A, 0, 0x5F4D, 0x4654, 0x5F4F,
+ 0xC930, 0, 0, 0xEF4C, 0, 0, 0x4375, 0x426D,
+ 0x773E, 0, 0, 0, 0x4025, 0, 0, 0xC932,
+ 0x5F50, 0, 0x5F52, 0, 0xC933, 0, 0, 0xC934,
+ 0, 0xEF4E, 0xEF4F, 0, 0xEF50, 0, 0x5F51, 0,
+};
+static const unsigned short utf8_to_euc_E781[] = {
+ 0, 0, 0, 0xC937, 0xC938, 0, 0, 0,
+ 0xC939, 0xC93A, 0xC93B, 0xC93C, 0x5E75, 0, 0xC941, 0,
+ 0, 0x5F53, 0, 0, 0xC93D, 0xC93E, 0, 0,
+ 0x4667, 0, 0, 0, 0, 0xC93F, 0xC940, 0,
+ 0, 0, 0, 0x5F54, 0xC942, 0xC943, 0, 0,
+ 0, 0, 0, 0x3250, 0xC944, 0, 0xC945, 0x4574,
+ 0x3325, 0, 0, 0, 0, 0xC946, 0xC947, 0,
+ 0x3564, 0, 0, 0, 0x3C5E, 0x3A52, 0xC948, 0,
+};
+static const unsigned short utf8_to_euc_E781_x0213[] = {
+ 0, 0, 0, 0xEF51, 0xC938, 0, 0, 0xEF52,
+ 0xC939, 0xC93A, 0x773F, 0xEF53, 0x5E75, 0, 0x7742, 0,
+ 0, 0x5F53, 0, 0, 0xEF55, 0xC93E, 0, 0,
+ 0x4667, 0, 0, 0, 0, 0x7740, 0x7741, 0,
+ 0, 0, 0, 0x5F54, 0x7743, 0xEF56, 0, 0,
+ 0, 0xEF57, 0, 0x3250, 0xEF58, 0, 0xEF59, 0x4574,
+ 0x3325, 0, 0, 0, 0, 0x7744, 0xEF5A, 0,
+ 0x3564, 0, 0, 0, 0x3C5E, 0x3A52, 0xEF5B, 0,
+};
+static const unsigned short utf8_to_euc_E782[] = {
+ 0, 0xC949, 0, 0, 0, 0xC94A, 0xC94B, 0,
+ 0, 0x4F27, 0x3F66, 0, 0, 0, 0x316A, 0,
+ 0, 0, 0x5F56, 0, 0xC94C, 0xC94D, 0xC94E, 0xC94F,
+ 0xC950, 0x5F55, 0, 0xC951, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0xC952, 0, 0, 0,
+ 0, 0, 0, 0xC953, 0x5F59, 0x433A, 0x5F5C, 0x5F57,
+ 0xC954, 0xC955, 0, 0x5F5B, 0xC956, 0, 0, 0xC957,
+ 0x5F5A, 0x4540, 0x3059, 0xF42E, 0, 0, 0, 0,
+};
+static const unsigned short utf8_to_euc_E782_x0213[] = {
+ 0, 0xEF5C, 0, 0, 0, 0x7745, 0xEF5D, 0,
+ 0, 0x4F27, 0x3F66, 0, 0, 0, 0x316A, 0,
+ 0, 0, 0x5F56, 0, 0xC94C, 0xEF5E, 0xC94E, 0xEF5F,
+ 0xC950, 0x5F55, 0, 0xC951, 0, 0, 0, 0xEF62,
+ 0, 0, 0, 0, 0x7746, 0, 0, 0,
+ 0, 0, 0, 0x7747, 0x5F59, 0x433A, 0x5F5C, 0x5F57,
+ 0xC954, 0xEF63, 0, 0x5F5B, 0xC956, 0, 0, 0x7748,
+ 0x5F5A, 0x4540, 0x3059, 0xEF60, 0, 0, 0, 0,
+};
+static const unsigned short utf8_to_euc_E783[] = {
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0x4E75, 0, 0xC958, 0x5F5E, 0, 0, 0, 0x3128,
+ 0, 0xC959, 0, 0xC95A, 0xC95B, 0xC95C, 0xC95D, 0,
+ 0xC95E, 0x5F60, 0, 0, 0xC95F, 0x5F5F, 0, 0x5F5D,
+ 0, 0, 0, 0, 0xC960, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0x5F58, 0, 0, 0, 0, 0, 0,
+ 0, 0x4B23, 0xC961, 0, 0, 0x5F62, 0, 0,
+};
+static const unsigned short utf8_to_euc_E783_x0213[] = {
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0x4E75, 0, 0xEF66, 0x5F5E, 0, 0, 0, 0x3128,
+ 0, 0xEF67, 0, 0xEF68, 0x7749, 0xC95C, 0xC95D, 0,
+ 0x774A, 0x5F60, 0, 0, 0xEF69, 0x5F5F, 0, 0x5F5D,
+ 0, 0, 0, 0, 0x774B, 0, 0, 0,
+ 0, 0, 0, 0, 0xEF65, 0, 0, 0,
+ 0, 0x5F58, 0, 0, 0, 0, 0, 0,
+ 0, 0x4B23, 0xC961, 0, 0, 0x5F62, 0, 0,
+};
+static const unsigned short utf8_to_euc_E784[] = {
+ 0, 0, 0, 0xC962, 0xC963, 0xC964, 0xC965, 0xC966,
+ 0, 0x5F61, 0, 0xC967, 0xC968, 0, 0, 0xC969,
+ 0, 0, 0, 0, 0x316B, 0, 0, 0,
+ 0, 0x5F64, 0x4A32, 0, 0x5F63, 0, 0xC96A, 0,
+ 0xC96B, 0x4C35, 0, 0, 0, 0, 0x3E47, 0,
+ 0, 0, 0, 0xC96C, 0, 0xC96D, 0, 0xC96E,
+ 0xC96F, 0xC970, 0, 0, 0, 0, 0x4133, 0,
+ 0xC971, 0, 0, 0, 0x3E46, 0, 0, 0,
+};
+static const unsigned short utf8_to_euc_E784_x0213[] = {
+ 0, 0, 0, 0xEF6A, 0xEF6B, 0xC964, 0xEF6C, 0xEF6D,
+ 0xEF6E, 0x5F61, 0, 0xC967, 0xEF6F, 0, 0, 0x774C,
+ 0, 0, 0, 0, 0x316B, 0, 0, 0,
+ 0, 0x5F64, 0x4A32, 0, 0x5F63, 0, 0x774E, 0,
+ 0x774F, 0x4C35, 0, 0, 0, 0, 0x3E47, 0,
+ 0, 0, 0, 0x774D, 0, 0xC96D, 0x7750, 0xEF71,
+ 0x7751, 0xEF72, 0, 0, 0, 0, 0x4133, 0,
+ 0xC971, 0, 0, 0, 0x3E46, 0, 0, 0,
+};
+static const unsigned short utf8_to_euc_E785[] = {
+ 0, 0xC972, 0, 0, 0, 0xC973, 0xC974, 0xC975,
+ 0, 0x4E7B, 0xC976, 0xC977, 0x5F6A, 0, 0x4079, 0,
+ 0xC978, 0, 0xC979, 0, 0, 0x5F66, 0x5F6B, 0xC97A,
+ 0, 0x316C, 0xC97B, 0, 0xC97C, 0, 0xC97D, 0,
+ 0xC97E, 0, 0x5F69, 0, 0x4761, 0x5F65, 0x5F68, 0x3E48,
+ 0xCA21, 0x4851, 0, 0, 0x5F6C, 0, 0x3C51, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0xCA22, 0, 0, 0, 0x407A, 0, 0,
+};
+static const unsigned short utf8_to_euc_E785_x0213[] = {
+ 0, 0xC972, 0, 0, 0, 0xC973, 0x7752, 0x7753,
+ 0, 0x4E7B, 0xEF74, 0xC977, 0x5F6A, 0, 0x4079, 0,
+ 0xEF73, 0x7754, 0x7756, 0xEF75, 0, 0x5F66, 0x5F6B, 0xC97A,
+ 0, 0x316C, 0xC97B, 0, 0x7757, 0, 0xEF76, 0,
+ 0x7758, 0, 0x5F69, 0, 0x4761, 0x5F65, 0x5F68, 0x3E48,
+ 0x7759, 0x4851, 0, 0, 0x5F6C, 0, 0x3C51, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0xCA22, 0, 0, 0, 0x407A, 0, 0,
+};
+static const unsigned short utf8_to_euc_E786[] = {
+ 0xCA23, 0, 0, 0, 0x5F6F, 0xCA24, 0, 0xCA25,
+ 0x5F67, 0, 0x3727, 0, 0xCA26, 0, 0, 0x5F6D,
+ 0, 0, 0xCA27, 0, 0x4D50, 0x5F70, 0, 0,
+ 0, 0x7426, 0xCA28, 0xCA29, 0, 0, 0, 0x3D4F,
+ 0xCA2A, 0, 0xCA2B, 0, 0, 0, 0, 0,
+ 0x5F71, 0, 0, 0, 0x5F72, 0, 0, 0xCA2C,
+ 0xCA2D, 0x472E, 0xCA2E, 0xCA2F, 0, 0, 0, 0,
+ 0, 0x5F74, 0xCA30, 0, 0, 0, 0x5F75, 0xCA31,
+};
+static const unsigned short utf8_to_euc_E786_x0213[] = {
+ 0xEF79, 0, 0, 0, 0x5F6F, 0x775B, 0, 0x775C,
+ 0x5F67, 0, 0x3727, 0, 0xCA26, 0, 0, 0x5F6D,
+ 0, 0, 0x775D, 0, 0x4D50, 0x5F70, 0xEF78, 0,
+ 0, 0x7426, 0xCA28, 0xEF7A, 0, 0, 0, 0x3D4F,
+ 0xEF7B, 0, 0xEF7C, 0, 0, 0, 0, 0,
+ 0x5F71, 0, 0, 0, 0x5F72, 0, 0xEF7D, 0xEF7E,
+ 0xCA2D, 0x472E, 0xCA2E, 0xF021, 0, 0, 0, 0,
+ 0, 0x5F74, 0x775F, 0, 0, 0, 0x5F75, 0xCA31,
+};
+static const unsigned short utf8_to_euc_E787[] = {
+ 0xCA32, 0xCA33, 0, 0x4733, 0xCA34, 0, 0, 0,
+ 0x4575, 0x5F77, 0, 0xCA35, 0xCA36, 0, 0x5F79, 0,
+ 0x4E55, 0, 0x5F76, 0xCA37, 0x5F78, 0x316D, 0xCA38, 0x5F73,
+ 0, 0xCA39, 0xCA3A, 0, 0xCA3B, 0, 0, 0x535B,
+ 0x5F7A, 0, 0, 0, 0, 0x4167, 0x3B38, 0x5F7C,
+ 0, 0, 0, 0, 0x5F7B, 0x3F24, 0x5259, 0,
+ 0, 0, 0, 0, 0, 0x5F7D, 0, 0,
+ 0xCA3C, 0x6021, 0, 0x5F6E, 0x5F7E, 0, 0xCA3D, 0x6022,
+};
+static const unsigned short utf8_to_euc_E787_x0213[] = {
+ 0xCA32, 0x775E, 0, 0x4733, 0x7760, 0, 0, 0,
+ 0x4575, 0x5F77, 0, 0xF023, 0xCA36, 0, 0x5F79, 0,
+ 0x4E55, 0, 0x5F76, 0xF024, 0x5F78, 0x316D, 0xCA38, 0x5F73,
+ 0, 0xF025, 0xCA3A, 0, 0xF026, 0, 0, 0x535B,
+ 0x5F7A, 0, 0, 0, 0, 0x4167, 0x3B38, 0x5F7C,
+ 0, 0, 0, 0, 0x5F7B, 0x3F24, 0x5259, 0,
+ 0, 0, 0, 0, 0, 0x5F7D, 0, 0,
+ 0xCA3C, 0x6021, 0, 0x5F6E, 0x5F7E, 0, 0x7761, 0x6022,
+};
+static const unsigned short utf8_to_euc_E788[] = {
+ 0xCA3E, 0, 0, 0, 0, 0, 0x477A, 0xCA3F,
+ 0xCA40, 0xCA41, 0, 0, 0, 0x6023, 0, 0,
+ 0x6024, 0, 0, 0xCA42, 0, 0, 0, 0xCA43,
+ 0, 0, 0xCA44, 0x6025, 0, 0xCA45, 0, 0xCA46,
+ 0, 0, 0, 0, 0xCA47, 0, 0, 0,
+ 0x6026, 0, 0x445E, 0xCA48, 0x6028, 0x6027, 0, 0xCA49,
+ 0x6029, 0, 0x602A, 0, 0xCA4A, 0x3C5F, 0x4963, 0,
+ 0xCA4B, 0xCA4C, 0x4C6C, 0x602B, 0x602C, 0x4156, 0x3C24, 0x602D,
+};
+static const unsigned short utf8_to_euc_E788_x0213[] = {
+ 0x7762, 0, 0, 0, 0, 0, 0x477A, 0xF027,
+ 0xCA40, 0xCA41, 0, 0, 0, 0x6023, 0, 0,
+ 0x6024, 0, 0, 0xCA42, 0, 0x7763, 0, 0xCA43,
+ 0, 0, 0xCA44, 0x6025, 0, 0xCA45, 0, 0xCA46,
+ 0, 0, 0, 0, 0xCA47, 0, 0, 0,
+ 0x6026, 0, 0x445E, 0xF02A, 0x6028, 0x6027, 0, 0xCA49,
+ 0x6029, 0, 0x602A, 0, 0xF02B, 0x3C5F, 0x4963, 0,
+ 0xF02C, 0xF02D, 0x4C6C, 0x602B, 0x602C, 0x4156, 0x3C24, 0x602D,
+};
+static const unsigned short utf8_to_euc_E789[] = {
+ 0x602E, 0xCA4D, 0xCA4E, 0xCA4F, 0, 0xCA50, 0x602F, 0x4A52,
+ 0x4847, 0, 0, 0x6030, 0x4757, 0, 0xCA51, 0xCA52,
+ 0xCA53, 0, 0x442D, 0xCA54, 0, 0xCA55, 0xCA56, 0,
+ 0x6031, 0x3267, 0xCA57, 0x356D, 0xCA58, 0x4C46, 0xCA59, 0x4C36,
+ 0xCA5A, 0x3234, 0x4F34, 0xCA5B, 0, 0, 0, 0x4B52,
+ 0xCA5C, 0x4A2A, 0, 0xCA5D, 0, 0, 0xCA5E, 0xCA5F,
+ 0, 0xCA60, 0x4037, 0, 0x6032, 0, 0, 0xCA61,
+ 0xCA62, 0x4643, 0, 0xCA63, 0xCA64, 0x3823, 0x6033, 0xCA65,
+};
+static const unsigned short utf8_to_euc_E789_x0213[] = {
+ 0x602E, 0xCA4D, 0xF02F, 0xCA4F, 0, 0xCA50, 0x602F, 0x4A52,
+ 0x4847, 0, 0, 0x6030, 0x4757, 0, 0xCA51, 0xCA52,
+ 0xCA53, 0, 0x442D, 0xF030, 0, 0x7764, 0x7765, 0xF031,
+ 0x6031, 0x3267, 0xCA57, 0x356D, 0xCA58, 0x4C46, 0xCA59, 0x4C36,
+ 0xCA5A, 0x3234, 0x4F34, 0xF032, 0, 0, 0, 0x4B52,
+ 0xCA5C, 0x4A2A, 0, 0xCA5D, 0, 0, 0xF034, 0xF035,
+ 0, 0xCA60, 0x4037, 0, 0x6032, 0, 0, 0xCA61,
+ 0xF036, 0x4643, 0, 0xCA63, 0xCA64, 0x3823, 0x6033, 0xF037,
+};
+static const unsigned short utf8_to_euc_E78A[] = {
+ 0x3A54, 0x6035, 0x6034, 0, 0xCA66, 0, 0, 0x6036,
+ 0, 0xCA67, 0, 0, 0, 0xCA68, 0xCA69, 0,
+ 0, 0, 0x6037, 0xCA6A, 0, 0, 0x6038, 0,
+ 0, 0, 0, 0xCA6B, 0, 0, 0, 0,
+ 0x353E, 0, 0x6039, 0, 0, 0, 0, 0x603A,
+ 0xCA6C, 0, 0, 0, 0x3824, 0xCA6D, 0xCA6E, 0x4848,
+ 0, 0xCA6F, 0x603C, 0, 0xCA70, 0, 0x3E75, 0,
+ 0, 0x603B, 0, 0, 0, 0, 0xCA71, 0,
+};
+static const unsigned short utf8_to_euc_E78A_x0213[] = {
+ 0x3A54, 0x6035, 0x6034, 0, 0xCA66, 0, 0, 0x6036,
+ 0, 0xCA67, 0, 0, 0, 0x7767, 0xF038, 0,
+ 0, 0, 0x6037, 0xCA6A, 0, 0, 0x6038, 0,
+ 0, 0, 0, 0x7768, 0, 0, 0, 0,
+ 0x353E, 0, 0x6039, 0, 0, 0, 0, 0x603A,
+ 0xCA6C, 0, 0, 0, 0x3824, 0xF03A, 0xF03B, 0x4848,
+ 0xF03C, 0xF03D, 0x603C, 0, 0xCA70, 0, 0x3E75, 0,
+ 0, 0x603B, 0, 0, 0, 0, 0x7769, 0,
+};
+static const unsigned short utf8_to_euc_E78B[] = {
+ 0, 0xCA72, 0x3638, 0x603D, 0x603F, 0, 0x603E, 0xCA73,
+ 0, 0xCA74, 0, 0, 0xCA75, 0, 0x6040, 0,
+ 0x3851, 0, 0x6041, 0, 0, 0xCA76, 0xCA77, 0x3669,
+ 0xCA78, 0x4140, 0, 0x397D, 0, 0, 0, 0xCA79,
+ 0x6043, 0x6044, 0x6042, 0, 0, 0xCA7A, 0, 0,
+ 0, 0x3C6D, 0, 0, 0x4648, 0x3639, 0, 0,
+ 0, 0, 0, 0xCA7B, 0xCA7C, 0, 0, 0x6046,
+ 0x432C, 0x6045, 0xCA7D, 0xCA7E, 0x4F35, 0x4762, 0xCB21, 0,
+};
+static const unsigned short utf8_to_euc_E78B_x0213[] = {
+ 0x776A, 0xF03E, 0x3638, 0x603D, 0x603F, 0, 0x603E, 0xCA73,
+ 0, 0xCA74, 0, 0, 0xF040, 0, 0x6040, 0,
+ 0x3851, 0, 0x6041, 0, 0, 0xCA76, 0xCA77, 0x3669,
+ 0xCA78, 0x4140, 0, 0x397D, 0, 0, 0, 0xCA79,
+ 0x6043, 0x6044, 0x6042, 0, 0, 0xCA7A, 0, 0,
+ 0, 0x3C6D, 0, 0, 0x4648, 0x3639, 0, 0,
+ 0, 0, 0, 0xF043, 0xCA7C, 0, 0, 0x6046,
+ 0x432C, 0x6045, 0xF044, 0x776B, 0x4F35, 0x4762, 0xCB21, 0,
+};
+static const unsigned short utf8_to_euc_E78C[] = {
+ 0, 0, 0xCB22, 0, 0xCB23, 0xCB24, 0, 0xCB25,
+ 0, 0, 0x6049, 0xCB26, 0, 0xCB27, 0, 0,
+ 0, 0, 0xCB28, 0xCB29, 0, 0, 0x604B, 0x6048,
+ 0xCB2A, 0xCB2B, 0, 0x4C54, 0x604A, 0x604C, 0xCB2C, 0x4E44,
+ 0, 0, 0xCB2D, 0, 0xCB2E, 0x6050, 0, 0xCB2F,
+ 0xCB30, 0x604F, 0x4376, 0x472D, 0xCB31, 0, 0x3825, 0x604E,
+ 0, 0xCB32, 0xCB33, 0, 0x604D, 0xCB34, 0x4D31, 0x4D32,
+ 0, 0, 0xCB35, 0xCB36, 0, 0xCB37, 0x6051, 0x316E,
+};
+static const unsigned short utf8_to_euc_E78C_x0213[] = {
+ 0, 0, 0xCB22, 0, 0xCB23, 0xCB24, 0, 0xF045,
+ 0, 0, 0x6049, 0xCB26, 0, 0xCB27, 0, 0,
+ 0, 0, 0xF046, 0xCB29, 0, 0, 0x604B, 0x6048,
+ 0xF047, 0xF048, 0, 0x4C54, 0x604A, 0x604C, 0xCB2C, 0x4E44,
+ 0, 0, 0xCB2D, 0, 0xCB2E, 0x6050, 0, 0x776D,
+ 0x776E, 0x604F, 0x4376, 0x472D, 0xF04B, 0, 0x3825, 0x604E,
+ 0, 0xF04C, 0xCB33, 0xF04D, 0x604D, 0xCB34, 0x4D31, 0x4D32,
+ 0, 0xF04A, 0xCB35, 0xCB36, 0, 0xF04E, 0x6051, 0x316E,
+};
+static const unsigned short utf8_to_euc_E78D[] = {
+ 0, 0, 0, 0xCB38, 0x3976, 0x3B62, 0, 0,
+ 0, 0, 0, 0, 0, 0xCB39, 0x6052, 0x6053,
+ 0xCB3A, 0, 0xCB3B, 0, 0, 0, 0xCB3C, 0x6055,
+ 0xCB3D, 0, 0, 0, 0, 0xCB3E, 0xCB3F, 0xCB40,
+ 0xCB41, 0, 0, 0x3D43, 0, 0, 0xCB42, 0xCB43,
+ 0x6057, 0xCB44, 0x6056, 0xCB45, 0xCB46, 0, 0xCB47, 0xCB48,
+ 0x6058, 0xCB49, 0x334D, 0, 0, 0x605A, 0, 0xCB4A,
+ 0x6059, 0xCB4B, 0x605C, 0x605B, 0xCB4C, 0, 0, 0,
+};
+static const unsigned short utf8_to_euc_E78D_x0213[] = {
+ 0, 0, 0, 0xCB38, 0x3976, 0x3B62, 0, 0,
+ 0, 0, 0, 0, 0, 0xCB39, 0x6052, 0x6053,
+ 0x7770, 0, 0xF04F, 0, 0, 0, 0xCB3C, 0x6055,
+ 0xCB3D, 0, 0, 0, 0, 0xCB3E, 0xCB3F, 0xCB40,
+ 0xCB41, 0, 0, 0x3D43, 0, 0, 0x7771, 0xCB43,
+ 0x6057, 0xCB44, 0x6056, 0xF051, 0xF052, 0, 0xF054, 0xF055,
+ 0x6058, 0xF056, 0x334D, 0, 0, 0x605A, 0, 0xF057,
+ 0x6059, 0xCB4B, 0x605C, 0x605B, 0x7772, 0, 0, 0,
+};
+static const unsigned short utf8_to_euc_E78E[] = {
+ 0xCB4D, 0xCB4E, 0, 0xCB4F, 0x383C, 0xCB50, 0xCB51, 0x4E28,
+ 0, 0x364C, 0, 0x3226, 0, 0, 0xCB52, 0,
+ 0xCB53, 0, 0, 0xCB54, 0, 0xCB55, 0x366A, 0xCB56,
+ 0xCB57, 0, 0, 0, 0xCB58, 0, 0xCB59, 0xCB5A,
+ 0xCB5B, 0, 0xCB5C, 0, 0, 0xCB5D, 0xCB5E, 0,
+ 0, 0x3461, 0xCB5F, 0xCB60, 0, 0xCB61, 0, 0,
+ 0, 0, 0x4E68, 0x605E, 0, 0xCB62, 0, 0xCB63,
+ 0, 0xCB64, 0, 0x6060, 0xCB65, 0xCB66, 0, 0xCB67,
+};
+static const unsigned short utf8_to_euc_E78E_x0213[] = {
+ 0xCB4D, 0xF058, 0, 0xCB4F, 0x383C, 0xF059, 0xCB51, 0x4E28,
+ 0, 0x364C, 0xF05A, 0x3226, 0, 0, 0xCB52, 0,
+ 0xCB53, 0, 0, 0xCB54, 0xF05B, 0x7773, 0x366A, 0xCB56,
+ 0xF05C, 0, 0, 0, 0xF05D, 0, 0xF05E, 0x7774,
+ 0x7775, 0, 0x7776, 0, 0, 0xF05F, 0x7777, 0,
+ 0xF060, 0x3461, 0xCB5F, 0x7778, 0, 0xCB61, 0, 0,
+ 0, 0, 0x4E68, 0x605E, 0, 0xF061, 0, 0xF062,
+ 0, 0xF063, 0, 0x6060, 0xF064, 0xCB66, 0, 0xF065,
+};
+static const unsigned short utf8_to_euc_E78F[] = {
+ 0x6061, 0, 0x3251, 0, 0, 0xCB68, 0xCB69, 0,
+ 0x605D, 0xCB6A, 0x3B39, 0xCB6B, 0xCB6C, 0x4441, 0x605F, 0xCB6D,
+ 0, 0, 0xCB6E, 0xCB6F, 0, 0, 0xCB70, 0,
+ 0, 0xCB71, 0, 0, 0, 0xCB72, 0x6064, 0,
+ 0x3C6E, 0xCB73, 0, 0xCB74, 0, 0x6062, 0xCB75, 0xCB76,
+ 0, 0xCB77, 0x373E, 0, 0, 0x4849, 0x6063, 0,
+ 0, 0x607E, 0, 0, 0xCB78, 0xCB79, 0, 0xCB7A,
+ 0x6069, 0xCB7B, 0xCB7C, 0xCB7D, 0, 0xCB7E, 0x383D, 0xCC21,
+};
+static const unsigned short utf8_to_euc_E78F_x0213[] = {
+ 0x6061, 0, 0x3251, 0, 0, 0xF066, 0xCB69, 0,
+ 0x605D, 0x7779, 0x3B39, 0xF067, 0xCB6C, 0x4441, 0x605F, 0x777A,
+ 0, 0, 0xCB6E, 0xCB6F, 0, 0, 0x777B, 0,
+ 0, 0x777C, 0, 0, 0, 0xCB72, 0x6064, 0,
+ 0x3C6E, 0xF068, 0, 0x777D, 0, 0x6062, 0xCB75, 0xF069,
+ 0, 0x777E, 0x373E, 0, 0, 0x4849, 0x6063, 0,
+ 0, 0x607E, 0, 0, 0xCB78, 0xCB79, 0, 0xCB7A,
+ 0x6069, 0xF06A, 0xF06C, 0xCB7D, 0, 0xCB7E, 0x383D, 0xCC21,
+};
+static const unsigned short utf8_to_euc_E790[] = {
+ 0xCC22, 0xCC23, 0, 0x3565, 0xCC24, 0x6066, 0x4D7D, 0xCC25,
+ 0, 0x4E30, 0xCC26, 0, 0, 0, 0, 0,
+ 0, 0xCC27, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0xCC28, 0xCC29, 0, 0, 0, 0,
+ 0, 0, 0x4276, 0, 0xCC2A, 0x6068, 0xCC2B, 0,
+ 0xCC2C, 0xCC2D, 0xCC2E, 0xCC2F, 0xCC30, 0xCC31, 0xCC32, 0xCC33,
+ 0xCC34, 0xCC35, 0x606A, 0x4E56, 0x3657, 0x487C, 0x474A, 0,
+ 0, 0xCC36, 0x606B, 0, 0, 0, 0, 0x606D,
+};
+static const unsigned short utf8_to_euc_E790_x0213[] = {
+ 0xCC22, 0xF06D, 0, 0x3565, 0xCC24, 0x6066, 0x4D7D, 0x7821,
+ 0, 0x4E30, 0x7822, 0, 0, 0, 0, 0,
+ 0, 0xCC27, 0, 0xF06B, 0, 0, 0, 0,
+ 0, 0, 0x7823, 0x7824, 0, 0, 0, 0,
+ 0, 0, 0x4276, 0, 0xF06E, 0x6068, 0x7826, 0,
+ 0x7827, 0xCC2D, 0x7828, 0x7829, 0x782A, 0xCC31, 0x782B, 0x782C,
+ 0x782D, 0xF06F, 0x606A, 0x4E56, 0x3657, 0x487C, 0x474A, 0,
+ 0, 0xF070, 0x606B, 0, 0, 0, 0, 0x606D,
+};
+static const unsigned short utf8_to_euc_E791[] = {
+ 0xCC37, 0x6070, 0, 0xCC38, 0xCC39, 0, 0xCC3A, 0xCC3B,
+ 0, 0, 0, 0xCC3C, 0, 0xCC3D, 0, 0,
+ 0, 0xCC3E, 0xCC3F, 0, 0, 0x606C, 0, 0xCC40,
+ 0, 0x606F, 0x386A, 0x314D, 0x6071, 0xCC41, 0x3F70, 0x606E,
+ 0x4E5C, 0, 0xCC42, 0x6074, 0x7424, 0, 0xCC43, 0xCC44,
+ 0xCC45, 0x6072, 0x6075, 0xCC46, 0, 0xCC47, 0xCC48, 0x6067,
+ 0x6073, 0xCC49, 0xCC4A, 0x3A3C, 0, 0, 0x6076, 0,
+ 0, 0, 0, 0, 0, 0, 0x6077, 0,
+};
+static const unsigned short utf8_to_euc_E791_x0213[] = {
+ 0xF072, 0x6070, 0, 0xF073, 0x782E, 0, 0x782F, 0x7830,
+ 0, 0, 0, 0x7831, 0, 0xF074, 0, 0,
+ 0, 0xCC3E, 0xF075, 0xF071, 0, 0x606C, 0, 0x7832,
+ 0, 0x606F, 0x386A, 0x314D, 0x6071, 0xF076, 0x3F70, 0x606E,
+ 0x4E5C, 0, 0x7833, 0x6074, 0x7424, 0, 0xCC43, 0xCC44,
+ 0xCC45, 0x6072, 0x6075, 0x7834, 0, 0x7835, 0xCC48, 0x6067,
+ 0x6073, 0xF077, 0xCC4A, 0x3A3C, 0, 0, 0x6076, 0,
+ 0, 0, 0, 0, 0, 0, 0x6077, 0,
+};
+static const unsigned short utf8_to_euc_E792[] = {
+ 0xCC4B, 0xCC4C, 0, 0x4D7E, 0, 0xCC4D, 0xCC4E, 0xCC4F,
+ 0, 0xCC50, 0, 0x6078, 0, 0, 0, 0xCC51,
+ 0xCC52, 0xCC53, 0xCC54, 0, 0, 0, 0, 0,
+ 0xCC55, 0xCC56, 0xCC57, 0, 0xCC58, 0, 0x6079, 0xCC59,
+ 0xCC5A, 0xCC5B, 0x6065, 0xCC5C, 0, 0, 0xCC5D, 0x607A,
+ 0xCC5E, 0xCC5F, 0xCC60, 0xCC61, 0, 0, 0xCC62, 0xCC63,
+ 0x3444, 0xCC64, 0xCC65, 0, 0, 0xCC66, 0, 0,
+ 0, 0xCC67, 0, 0xCC68, 0, 0x3C25, 0, 0xCC69,
+};
+static const unsigned short utf8_to_euc_E792_x0213[] = {
+ 0xCC4B, 0xF078, 0, 0x4D7E, 0, 0xF079, 0x7836, 0x7837,
+ 0xF07A, 0x7838, 0, 0x6078, 0, 0, 0, 0xCC51,
+ 0x783D, 0xCC53, 0xF07C, 0, 0, 0, 0, 0xF07D,
+ 0x7839, 0xF07E, 0xCC57, 0, 0x783A, 0, 0x6079, 0x783B,
+ 0xF121, 0xF122, 0x6065, 0x783C, 0, 0xF123, 0x783E, 0x607A,
+ 0x783F, 0x7840, 0xF124, 0xF125, 0, 0, 0xCC62, 0xCC63,
+ 0x3444, 0xCC64, 0xCC65, 0, 0, 0x7841, 0, 0,
+ 0, 0xF126, 0xF128, 0xF127, 0, 0x3C25, 0, 0x7842,
+};
+static const unsigned short utf8_to_euc_E793[] = {
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0xCC6A, 0xCC6B, 0x607B, 0, 0xCC6C, 0, 0, 0x607C,
+ 0xCC6D, 0, 0, 0xCC6E, 0x607D, 0, 0, 0,
+ 0xCC6F, 0, 0xCC70, 0xCC71, 0x313B, 0, 0xCC72, 0xCC73,
+ 0x6121, 0, 0x493B, 0x6122, 0xCC74, 0, 0x3424, 0x6123,
+ 0xCC75, 0x6124, 0xCC76, 0xCC77, 0, 0, 0x6125, 0xCC78,
+ 0x6127, 0x6128, 0x6126, 0, 0xCC79, 0, 0x4953, 0x612A,
+ 0x6129, 0, 0xCC7A, 0xCC7B, 0xCC7C, 0, 0, 0xCC7D,
+};
+static const unsigned short utf8_to_euc_E793_x0213[] = {
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0x7843, 0x7844, 0x607B, 0, 0xCC6C, 0, 0, 0x607C,
+ 0xCC6D, 0, 0, 0xCC6E, 0x607D, 0, 0xF129, 0,
+ 0xF12A, 0, 0x7845, 0xCC71, 0x313B, 0, 0xF12B, 0xCC73,
+ 0x6121, 0, 0x493B, 0x6122, 0xCC74, 0, 0x3424, 0x6123,
+ 0xCC75, 0x6124, 0xCC76, 0xF12D, 0, 0, 0x6125, 0xF12C,
+ 0x6127, 0x6128, 0x6126, 0, 0xCC79, 0, 0x4953, 0x612A,
+ 0x6129, 0, 0xF12F, 0xCC7B, 0xCC7C, 0, 0, 0x7846,
+};
+static const unsigned short utf8_to_euc_E794[] = {
+ 0, 0xF450, 0, 0x612C, 0x612B, 0x612D, 0xCC7E, 0,
+ 0, 0, 0, 0, 0x612E, 0x6130, 0x612F, 0,
+ 0, 0x3979, 0xCD21, 0x6132, 0, 0x6131, 0xCD22, 0xCD23,
+ 0x3445, 0, 0x3F53, 0, 0x453C, 0, 0x6133, 0x4038,
+ 0xCD24, 0xCD25, 0, 0x3B3A, 0xCD26, 0x3179, 0x6134, 0xCD27,
+ 0x4D51, 0xCD28, 0xCD29, 0x4A63, 0x6135, 0, 0, 0xCD2A,
+ 0x4544, 0x4D33, 0x3943, 0x3F3D, 0, 0, 0xCD2B, 0x434B,
+ 0x5234, 0xCD2C, 0x442E, 0x3268, 0x6136, 0xCD2D, 0xCD2E, 0xCD2F,
+};
+static const unsigned short utf8_to_euc_E794_x0213[] = {
+ 0, 0x7847, 0, 0x612C, 0x612B, 0x612D, 0xCC7E, 0,
+ 0, 0, 0, 0, 0x612E, 0x6130, 0x612F, 0,
+ 0, 0x3979, 0xCD21, 0x6132, 0, 0x6131, 0xCD22, 0x7848,
+ 0x3445, 0, 0x3F53, 0, 0x453C, 0, 0x6133, 0x4038,
+ 0xF131, 0xCD25, 0, 0x3B3A, 0xF132, 0x3179, 0x6134, 0xCD27,
+ 0x4D51, 0xCD28, 0xF133, 0x4A63, 0x6135, 0, 0, 0x7849,
+ 0x4544, 0x4D33, 0x3943, 0x3F3D, 0, 0, 0xCD2B, 0x434B,
+ 0x5234, 0xCD2C, 0x442E, 0x3268, 0x6136, 0xF136, 0xF137, 0xCD2F,
+};
+static const unsigned short utf8_to_euc_E795[] = {
+ 0xCD30, 0, 0, 0xCD31, 0x6137, 0, 0x613C, 0xCD32,
+ 0xCD33, 0x613A, 0x6139, 0x5A42, 0x3326, 0x6138, 0xCD34, 0x305A,
+ 0xCD35, 0x482A, 0xCD36, 0, 0x484A, 0, 0, 0xCD37,
+ 0, 0x4E31, 0x613D, 0x613B, 0x435C, 0x4026, 0xCD38, 0xCD39,
+ 0x482B, 0xCD3A, 0x492D, 0, 0x613F, 0x4E2C, 0x374D, 0x6140,
+ 0, 0x613E, 0x4856, 0x6141, 0, 0x6142, 0, 0xCD3B,
+ 0x305B, 0xCD3C, 0, 0x3E76, 0x6147, 0, 0x6144, 0x466D,
+ 0x6143, 0xCD3D, 0xCD3E, 0xCD3F, 0xCD40, 0xCD41, 0xCD42, 0x3526,
+};
+static const unsigned short utf8_to_euc_E795_x0213[] = {
+ 0xF138, 0, 0, 0xCD31, 0x6137, 0, 0x613C, 0xCD32,
+ 0xF139, 0x613A, 0x6139, 0x5A42, 0x3326, 0x6138, 0xF13A, 0x305A,
+ 0xF13B, 0x482A, 0xF13C, 0, 0x484A, 0, 0, 0xCD37,
+ 0, 0x4E31, 0x613D, 0x613B, 0x435C, 0x4026, 0xCD38, 0xCD39,
+ 0x482B, 0xCD3A, 0x492D, 0, 0x613F, 0x4E2C, 0x374D, 0x6140,
+ 0, 0x613E, 0x4856, 0x6141, 0xF13D, 0x6142, 0, 0x784A,
+ 0x305B, 0xF13F, 0xF13E, 0x3E76, 0x6147, 0, 0x6144, 0x466D,
+ 0x6143, 0x784B, 0xF140, 0xCD3F, 0xCD40, 0xF141, 0xF142, 0x3526,
+};
+static const unsigned short utf8_to_euc_E796[] = {
+ 0, 0xCD43, 0x614A, 0, 0, 0xCD44, 0x6145, 0x6146,
+ 0, 0x6149, 0x6148, 0x4925, 0, 0, 0x4142, 0x4141,
+ 0xCD45, 0x353F, 0xCD46, 0xCD47, 0x614B, 0xCD48, 0, 0,
+ 0, 0xCD49, 0x614C, 0, 0xCD4A, 0x614D, 0, 0,
+ 0, 0, 0xCD4B, 0x614F, 0xCD4C, 0x614E, 0, 0,
+ 0, 0, 0, 0x3156, 0, 0, 0, 0,
+ 0, 0x6157, 0x4868, 0x6151, 0xCD4D, 0x6153, 0, 0,
+ 0x6155, 0x3F3E, 0xCD4E, 0, 0x6156, 0x6154, 0x3C40, 0xCD4F,
+};
+static const unsigned short utf8_to_euc_E796_x0213[] = {
+ 0, 0xF143, 0x614A, 0, 0, 0xCD44, 0x6145, 0x6146,
+ 0, 0x6149, 0x6148, 0x4925, 0xF145, 0, 0x4142, 0x4141,
+ 0xCD45, 0x353F, 0x784C, 0xCD47, 0x614B, 0xCD48, 0, 0,
+ 0, 0xCD49, 0x614C, 0, 0xCD4A, 0x614D, 0, 0,
+ 0, 0, 0xF147, 0x614F, 0xCD4C, 0x614E, 0, 0,
+ 0, 0, 0, 0x3156, 0, 0, 0, 0,
+ 0xF149, 0x6157, 0x4868, 0x6151, 0xCD4D, 0x6153, 0, 0xF14A,
+ 0x6155, 0x3F3E, 0xCD4E, 0, 0x6156, 0x6154, 0x3C40, 0xF14B,
+};
+static const unsigned short utf8_to_euc_E797[] = {
+ 0xCD50, 0xCD51, 0x6150, 0x6152, 0xCD52, 0x4942, 0xCD53, 0x3E49,
+ 0, 0, 0x6159, 0, 0xCD54, 0x6158, 0xCD55, 0xCD56,
+ 0, 0, 0x615A, 0, 0x3C26, 0x3A2F, 0, 0xCD57,
+ 0x4577, 0x615B, 0, 0x444B, 0xCD58, 0, 0x615D, 0xCD59,
+ 0xCD5A, 0xCD5B, 0x4E21, 0x615C, 0xCD5C, 0, 0, 0xCD5D,
+ 0, 0x4169, 0, 0, 0xCD5E, 0, 0xCD5F, 0xCD60,
+ 0x6162, 0xCD61, 0x6164, 0x6165, 0x4354, 0, 0, 0,
+ 0, 0xCD62, 0x6163, 0, 0x6160, 0, 0x615E, 0x615F,
+};
+static const unsigned short utf8_to_euc_E797_x0213[] = {
+ 0xF14C, 0xCD51, 0x6150, 0x6152, 0xCD52, 0x4942, 0xF14D, 0x3E49,
+ 0, 0, 0x6159, 0, 0xCD54, 0x6158, 0x784E, 0xF14E,
+ 0, 0, 0x615A, 0xF14F, 0x3C26, 0x3A2F, 0, 0xCD57,
+ 0x4577, 0x615B, 0, 0x444B, 0xCD58, 0xF150, 0x615D, 0xF151,
+ 0xF152, 0xCD5B, 0x4E21, 0x615C, 0x784F, 0, 0, 0xF153,
+ 0, 0x4169, 0, 0, 0xF154, 0, 0xF155, 0xCD60,
+ 0x6162, 0xF156, 0x6164, 0x6165, 0x4354, 0, 0, 0,
+ 0, 0xF157, 0x6163, 0, 0x6160, 0, 0x615E, 0x615F,
+};
+static const unsigned short utf8_to_euc_E798[] = {
+ 0xCD63, 0x6161, 0xCD64, 0xCD65, 0xCD66, 0, 0, 0xCD67,
+ 0xCD68, 0x6168, 0xCD69, 0x6166, 0xCD6A, 0x6167, 0, 0xCD6B,
+ 0, 0, 0xCD6C, 0xCD6D, 0, 0xCD6E, 0xCD6F, 0,
+ 0, 0xCD70, 0, 0xCD71, 0xCD72, 0xCD73, 0xCD74, 0x6169,
+ 0x616B, 0x616C, 0x616D, 0xCD75, 0x616E, 0xCD76, 0xCD77, 0x616A,
+ 0, 0xCD78, 0, 0, 0, 0xCD79, 0, 0,
+ 0x6170, 0, 0xCD7A, 0xCD7B, 0x616F, 0xCD7C, 0, 0,
+ 0xCD7D, 0xCD7E, 0xCE21, 0x6171, 0xCE22, 0, 0, 0,
+};
+static const unsigned short utf8_to_euc_E798_x0213[] = {
+ 0x7850, 0x6161, 0x7851, 0xF158, 0xCD66, 0, 0, 0xF15A,
+ 0x7852, 0x6168, 0xCD69, 0x6166, 0xCD6A, 0x6167, 0, 0xF15B,
+ 0, 0, 0xCD6C, 0xF15E, 0, 0x7853, 0x7854, 0,
+ 0xF159, 0x7855, 0, 0xF15F, 0xF160, 0xCD73, 0x7856, 0x6169,
+ 0x616B, 0x616C, 0x616D, 0xCD75, 0x616E, 0xF162, 0x7E7D, 0x616A,
+ 0xF163, 0xCD78, 0, 0, 0, 0x7857, 0, 0,
+ 0x6170, 0, 0xCD7A, 0xF165, 0x616F, 0x7858, 0, 0,
+ 0xCD7D, 0xCD7E, 0xCE21, 0x6171, 0xF164, 0, 0, 0,
+};
+static const unsigned short utf8_to_euc_E799[] = {
+ 0xCE24, 0xCE25, 0x4E45, 0xCE26, 0xCE27, 0xCE28, 0x6174, 0x6172,
+ 0x6173, 0xCE29, 0xCE23, 0xCE2A, 0x3462, 0, 0, 0,
+ 0, 0, 0x4C7E, 0, 0, 0xCE2B, 0x4A4A, 0,
+ 0x6176, 0xCE2C, 0, 0, 0x6175, 0, 0, 0xCE2D,
+ 0, 0x6177, 0x6178, 0, 0xCE2E, 0xCE2F, 0, 0x617C,
+ 0x6179, 0x617A, 0x617B, 0, 0x617D, 0xCE30, 0xCE31, 0xCE32,
+ 0x617E, 0xCE33, 0x6221, 0, 0xCE34, 0, 0x6222, 0,
+ 0x6223, 0, 0x482F, 0x4550, 0x6224, 0x4772, 0x4934, 0,
+};
+static const unsigned short utf8_to_euc_E799_x0213[] = {
+ 0xCE24, 0xF168, 0x4E45, 0x7859, 0xCE27, 0xCE28, 0x6174, 0x6172,
+ 0x6173, 0xF16A, 0xCE23, 0x785A, 0x3462, 0, 0, 0,
+ 0, 0, 0x4C7E, 0, 0, 0xF16B, 0x4A4A, 0,
+ 0x6176, 0xCE2C, 0, 0, 0x6175, 0, 0, 0xCE2D,
+ 0, 0x6177, 0x6178, 0, 0x785B, 0x785C, 0, 0x617C,
+ 0x6179, 0x617A, 0x617B, 0, 0x617D, 0x785D, 0xF16D, 0x785E,
+ 0x617E, 0x785F, 0x6221, 0, 0xCE34, 0, 0x6222, 0,
+ 0x6223, 0, 0x482F, 0x4550, 0x6224, 0x4772, 0x4934, 0,
+};
+static const unsigned short utf8_to_euc_E79A[] = {
+ 0x6225, 0xCE35, 0xF451, 0x6226, 0x452A, 0xCE36, 0x3327, 0x3944,
+ 0x6227, 0, 0, 0x6228, 0xCE37, 0xCE38, 0x6229, 0,
+ 0x3B29, 0, 0, 0x622B, 0, 0xCE39, 0x622A, 0,
+ 0, 0x622C, 0x622D, 0xCE3A, 0xCE3B, 0xCE3C, 0xF452, 0xCE3D,
+ 0xCE3E, 0, 0xCE3F, 0xCE40, 0xCE41, 0xCE42, 0xCE43, 0xCE44,
+ 0xCE45, 0, 0xCE46, 0, 0, 0xCE47, 0x4869, 0,
+ 0x622E, 0, 0, 0, 0x622F, 0, 0, 0x7369,
+ 0x6230, 0x6231, 0x6232, 0, 0, 0xCE48, 0, 0x3B2E,
+};
+static const unsigned short utf8_to_euc_E79A_x0213[] = {
+ 0x6225, 0x7860, 0xF451, 0x6226, 0x452A, 0xCE36, 0x3327, 0x3944,
+ 0x6227, 0, 0, 0x6228, 0xCE37, 0xCE38, 0x6229, 0,
+ 0x3B29, 0, 0, 0x622B, 0, 0xF16E, 0x622A, 0,
+ 0, 0x622C, 0x622D, 0x7861, 0xF16F, 0x7862, 0x7863, 0xCE3D,
+ 0xF171, 0xF170, 0xCE3F, 0xCE40, 0xCE41, 0xCE42, 0x7864, 0xF172,
+ 0xF173, 0, 0x7865, 0, 0, 0xCE47, 0x4869, 0xF174,
+ 0x622E, 0, 0, 0, 0x622F, 0, 0x7866, 0x7369,
+ 0x6230, 0x6231, 0x6232, 0, 0, 0xCE48, 0, 0x3B2E,
+};
+static const unsigned short utf8_to_euc_E79B[] = {
+ 0, 0xCE49, 0x6233, 0x4756, 0, 0xCE4A, 0x4B5F, 0,
+ 0x314E, 0xCE4B, 0x3157, 0xCE4C, 0xCE4D, 0x6234, 0xCE4E, 0,
+ 0, 0, 0x6236, 0, 0xCE4F, 0, 0x6235, 0x4570,
+ 0, 0xCE50, 0, 0x4039, 0x5D39, 0, 0x6237, 0x4C41,
+ 0xCE51, 0x6238, 0, 0x3446, 0x4857, 0x6239, 0xCE52, 0x623A,
+ 0xCE53, 0, 0x623B, 0, 0xCE54, 0, 0x4C5C, 0,
+ 0xCE55, 0xCE56, 0x4C55, 0, 0x443E, 0, 0xCE57, 0,
+ 0x416A, 0xCE58, 0, 0x623D, 0xCE59, 0, 0x3D62, 0,
+};
+static const unsigned short utf8_to_euc_E79B_x0213[] = {
+ 0, 0xCE49, 0x6233, 0x4756, 0, 0x7867, 0x4B5F, 0,
+ 0x314E, 0xF176, 0x3157, 0xCE4C, 0x7868, 0x6234, 0x7869, 0,
+ 0, 0, 0x6236, 0, 0x786A, 0, 0x6235, 0x4570,
+ 0, 0xCE50, 0, 0x4039, 0x5D39, 0, 0x6237, 0x4C41,
+ 0xCE51, 0x6238, 0, 0x3446, 0x4857, 0x6239, 0x786B, 0x623A,
+ 0xF178, 0, 0x623B, 0, 0xF179, 0, 0x4C5C, 0,
+ 0xCE55, 0x786C, 0x4C55, 0, 0x443E, 0, 0xCE57, 0,
+ 0x416A, 0xCE58, 0, 0x623D, 0x786D, 0, 0x3D62, 0,
+};
+static const unsigned short utf8_to_euc_E79C[] = {
+ 0xCE5A, 0x3E4A, 0, 0, 0x6240, 0, 0xCE5B, 0x623F,
+ 0x623E, 0x487D, 0xCE5C, 0x3447, 0x3829, 0, 0xCE5D, 0,
+ 0, 0, 0xCE5E, 0, 0xCE5F, 0xCE60, 0, 0xCE61,
+ 0, 0xCE62, 0xCE63, 0x6246, 0xCE64, 0, 0x6243, 0x3F3F,
+ 0x4C32, 0, 0xCE65, 0, 0x6242, 0x6244, 0x6245, 0,
+ 0xCE66, 0x6241, 0, 0, 0, 0xCE67, 0xCE68, 0xCE69,
+ 0, 0, 0, 0, 0xCE6A, 0xCE6B, 0xCE6C, 0x6247,
+ 0x6248, 0xCE6D, 0x442F, 0, 0x3463, 0xCE6E, 0xCE6F, 0,
+};
+static const unsigned short utf8_to_euc_E79C_x0213[] = {
+ 0xCE5A, 0x3E4A, 0, 0, 0x6240, 0, 0xCE5B, 0x623F,
+ 0x623E, 0x487D, 0x786E, 0x3447, 0x3829, 0, 0xCE5D, 0,
+ 0, 0, 0xCE5E, 0, 0xCE5F, 0xCE60, 0, 0xF17B,
+ 0, 0x786F, 0xF17C, 0x6246, 0xCE64, 0, 0x6243, 0x3F3F,
+ 0x4C32, 0, 0xCE65, 0, 0x6242, 0x6244, 0x6245, 0,
+ 0xCE66, 0x6241, 0, 0, 0, 0xF17D, 0xCE68, 0xCE69,
+ 0, 0, 0, 0, 0x7870, 0xF17E, 0x7871, 0x6247,
+ 0x6248, 0xCE6D, 0x442F, 0, 0x3463, 0xCE6E, 0xCE6F, 0,
+};
+static const unsigned short utf8_to_euc_E79D[] = {
+ 0x4365, 0, 0xCE70, 0, 0, 0xCE71, 0xCE72, 0x6249,
+ 0, 0, 0xCE73, 0, 0, 0xCE74, 0xCE75, 0xCE76,
+ 0, 0, 0xCE77, 0, 0, 0, 0xCE78, 0xCE79,
+ 0, 0, 0x624A, 0x624D, 0xCE7A, 0, 0xCE7B, 0xCE7C,
+ 0xCE7D, 0x3F67, 0xCE7E, 0x4644, 0xCF21, 0x624E, 0x4B53, 0xCF22,
+ 0x624B, 0, 0xCF23, 0x624C, 0xCF24, 0, 0, 0,
+ 0xCF25, 0, 0xCF26, 0xCF27, 0xCF28, 0, 0, 0,
+ 0, 0x6251, 0xCF29, 0, 0, 0xCF2A, 0x6250, 0x624F,
+};
+static const unsigned short utf8_to_euc_E79D_x0213[] = {
+ 0x4365, 0, 0xCE70, 0, 0, 0xCE71, 0x7872, 0x6249,
+ 0, 0, 0xCE73, 0, 0, 0x7873, 0x7874, 0xCE76,
+ 0, 0, 0xCE77, 0, 0, 0, 0xCE78, 0xCE79,
+ 0xF225, 0, 0x624A, 0x624D, 0x7875, 0, 0xCE7B, 0x7876,
+ 0xF226, 0x3F67, 0x7877, 0x4644, 0xCF21, 0x624E, 0x4B53, 0xCF22,
+ 0x624B, 0, 0xF227, 0x624C, 0xCF24, 0, 0, 0,
+ 0xCF25, 0, 0xF229, 0xCF27, 0xCF28, 0, 0, 0,
+ 0, 0x6251, 0x7878, 0, 0xF22A, 0xF22B, 0x6250, 0x624F,
+};
+static const unsigned short utf8_to_euc_E79E[] = {
+ 0xCF2B, 0, 0, 0, 0xCF2C, 0, 0, 0,
+ 0, 0, 0, 0x6253, 0xCF2D, 0xCF2E, 0x6252, 0,
+ 0, 0x6254, 0, 0, 0xCF2F, 0xCF30, 0xCF31, 0,
+ 0, 0, 0xCF32, 0, 0, 0, 0x6256, 0xCF33,
+ 0x6255, 0, 0xCF34, 0, 0, 0x4A4D, 0, 0xCF35,
+ 0, 0, 0xCF36, 0, 0x3D56, 0x4E46, 0xCF37, 0xCF38,
+ 0x6257, 0xCF39, 0, 0x4637, 0, 0xCF3A, 0x6258, 0,
+ 0, 0x6259, 0, 0x625D, 0x625B, 0x625C, 0xCF3B, 0x625A,
+};
+static const unsigned short utf8_to_euc_E79E_x0213[] = {
+ 0x7879, 0, 0, 0, 0xCF2C, 0, 0, 0,
+ 0, 0, 0, 0x6253, 0xCF2D, 0xCF2E, 0x6252, 0,
+ 0, 0x6254, 0, 0, 0x787A, 0xCF30, 0xCF31, 0,
+ 0, 0, 0xF22E, 0, 0, 0, 0x6256, 0xF22F,
+ 0x6255, 0, 0xF230, 0, 0xF231, 0x4A4D, 0, 0xCF35,
+ 0, 0xF232, 0x787B, 0, 0x3D56, 0x4E46, 0xCF37, 0xCF38,
+ 0x6257, 0xCF39, 0, 0x4637, 0, 0xCF3A, 0x6258, 0,
+ 0, 0x6259, 0, 0x625D, 0x625B, 0x625C, 0xCF3B, 0x625A,
+};
+static const unsigned short utf8_to_euc_E79F[] = {
+ 0, 0, 0, 0xCF3C, 0, 0, 0, 0x625E,
+ 0, 0xCF3D, 0, 0, 0, 0x625F, 0, 0,
+ 0, 0xCF3E, 0xCF3F, 0, 0, 0xCF40, 0, 0x6260,
+ 0, 0xCF41, 0x6261, 0x4C37, 0x6262, 0, 0xCF42, 0xCF43,
+ 0xCF44, 0, 0x4C70, 0x6263, 0xCF45, 0x434E, 0xCF46, 0x476A,
+ 0, 0x366B, 0xCF47, 0, 0xCF48, 0x433B, 0x6264, 0x363A,
+ 0xCF49, 0xCF4A, 0, 0x4050, 0xCF4B, 0, 0, 0,
+ 0xCF4C, 0, 0, 0xCF4D, 0x6265, 0, 0, 0,
+};
+static const unsigned short utf8_to_euc_E79F_x0213[] = {
+ 0, 0, 0, 0xCF3C, 0, 0, 0, 0x625E,
+ 0, 0xCF3D, 0, 0, 0, 0x625F, 0, 0,
+ 0, 0xCF3E, 0xCF3F, 0, 0, 0xCF40, 0, 0x6260,
+ 0, 0xCF41, 0x6261, 0x4C37, 0x6262, 0, 0xF233, 0xF234,
+ 0x787C, 0, 0x4C70, 0x6263, 0xF235, 0x434E, 0xF236, 0x476A,
+ 0, 0x366B, 0xF237, 0, 0xF238, 0x433B, 0x6264, 0x363A,
+ 0xF23A, 0xCF4A, 0, 0x4050, 0xF23B, 0, 0, 0,
+ 0xCF4C, 0, 0, 0xF23C, 0x6265, 0, 0, 0,
+};
+static const unsigned short utf8_to_euc_E7A0[] = {
+ 0, 0, 0x3A3D, 0, 0, 0xCF4E, 0xCF4F, 0,
+ 0, 0xCF50, 0, 0, 0x6266, 0xCF51, 0xCF52, 0,
+ 0, 0xCF53, 0x6267, 0, 0x3826, 0x3A55, 0, 0,
+ 0, 0, 0, 0, 0, 0xCF54, 0, 0,
+ 0x6269, 0xCF55, 0xCF56, 0xCF57, 0, 0x4556, 0x3A56, 0x354E,
+ 0, 0, 0, 0, 0, 0xCF58, 0xCF59, 0,
+ 0xCF5A, 0, 0x4B24, 0, 0x474B, 0xCF5B, 0, 0xCF5C,
+ 0, 0, 0x4557, 0, 0, 0, 0, 0x395C,
+};
+static const unsigned short utf8_to_euc_E7A0_x0213[] = {
+ 0, 0, 0x3A3D, 0, 0, 0xF23E, 0xF23F, 0,
+ 0, 0xF240, 0, 0, 0x6266, 0xF241, 0xCF52, 0,
+ 0, 0xCF53, 0x6267, 0, 0x3826, 0x3A55, 0, 0,
+ 0, 0xF242, 0, 0, 0, 0xCF54, 0, 0,
+ 0x6269, 0xF243, 0xCF56, 0xCF57, 0, 0x4556, 0x3A56, 0x354E,
+ 0, 0, 0, 0, 0xF244, 0x787D, 0xCF59, 0,
+ 0xCF5A, 0, 0x4B24, 0, 0x474B, 0xCF5B, 0, 0xCF5C,
+ 0, 0, 0x4557, 0, 0, 0, 0, 0x395C,
+};
+static const unsigned short utf8_to_euc_E7A1[] = {
+ 0, 0, 0, 0xCF5D, 0xCF5E, 0x626B, 0, 0xCF5F,
+ 0xCF60, 0, 0, 0, 0xCF61, 0, 0xCF62, 0,
+ 0, 0, 0xCF63, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0xCF64, 0x3E4B, 0xCF65, 0,
+ 0xCF66, 0xCF67, 0, 0xCF68, 0xCF69, 0, 0, 0,
+ 0xCF6A, 0, 0xCF6B, 0x4E32, 0x3945, 0, 0xCF6C, 0x3827,
+ 0, 0, 0x4823, 0, 0x626D, 0, 0, 0,
+ 0, 0, 0xCF6D, 0, 0x626F, 0, 0xCF6E, 0,
+};
+static const unsigned short utf8_to_euc_E7A1_x0213[] = {
+ 0, 0, 0, 0x7921, 0xCF5E, 0x626B, 0, 0xF245,
+ 0xCF60, 0, 0, 0, 0xCF61, 0, 0x7922, 0x7923,
+ 0, 0x7924, 0xCF63, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0xCF64, 0x3E4B, 0xCF65, 0,
+ 0xCF66, 0xCF67, 0, 0xCF68, 0xF246, 0, 0, 0,
+ 0x7925, 0, 0xF247, 0x4E32, 0x3945, 0, 0x7926, 0x3827,
+ 0, 0, 0x4823, 0, 0x626D, 0, 0, 0,
+ 0, 0, 0xCF6D, 0, 0x626F, 0, 0xCF6E, 0,
+};
+static const unsigned short utf8_to_euc_E7A2[] = {
+ 0, 0x386B, 0, 0, 0, 0, 0x626E, 0x4476,
+ 0, 0, 0xCF6F, 0, 0x6271, 0x3337, 0x626C, 0xCF70,
+ 0, 0x486A, 0, 0x3130, 0xCF71, 0x3A6C, 0, 0x4F52,
+ 0xCF72, 0, 0x6270, 0, 0, 0xCF74, 0xCF75, 0xCF76,
+ 0, 0xCF73, 0, 0x6272, 0xCF77, 0, 0, 0x4A4B,
+ 0xCF78, 0x4059, 0x6274, 0, 0xCF79, 0xCF7A, 0, 0x6275,
+ 0xCF7B, 0xCF7C, 0xCF7D, 0xCF7E, 0, 0x6273, 0, 0,
+ 0, 0, 0x334E, 0xD021, 0x627B, 0xD022, 0x627A, 0xD023,
+};
+static const unsigned short utf8_to_euc_E7A2_x0213[] = {
+ 0, 0x386B, 0, 0, 0, 0, 0x626E, 0x4476,
+ 0, 0, 0xF249, 0, 0x6271, 0x3337, 0x626C, 0xCF70,
+ 0, 0x486A, 0, 0x3130, 0xF24A, 0x3A6C, 0, 0x4F52,
+ 0xCF72, 0, 0x6270, 0, 0, 0xF24C, 0xF24D, 0xF24E,
+ 0, 0xCF73, 0, 0x6272, 0xF24B, 0, 0, 0x4A4B,
+ 0xCF78, 0x4059, 0x6274, 0, 0xCF79, 0x792A, 0, 0x6275,
+ 0x7928, 0xCF7C, 0xCF7D, 0xCF7E, 0, 0x6273, 0, 0,
+ 0, 0, 0x334E, 0xF24F, 0x627B, 0xD022, 0x627A, 0xD023,
+};
+static const unsigned short utf8_to_euc_E7A3[] = {
+ 0, 0x3C27, 0, 0, 0, 0x627C, 0x6277, 0xD024,
+ 0xD025, 0xD026, 0x627D, 0x6278, 0xD027, 0, 0xD028, 0,
+ 0x4858, 0x6276, 0xD029, 0xD02A, 0x6279, 0xD02B, 0xD02C, 0,
+ 0, 0, 0x6322, 0xD02E, 0, 0, 0, 0xD02F,
+ 0xD030, 0xD031, 0, 0, 0xD02D, 0, 0xD032, 0x6321,
+ 0x4B61, 0, 0xD033, 0, 0x627E, 0, 0, 0x306B,
+ 0, 0, 0xD034, 0xD035, 0x6324, 0, 0xD037, 0xD038,
+ 0, 0, 0xD039, 0xD03A, 0, 0x6323, 0, 0xD03B,
+};
+static const unsigned short utf8_to_euc_E7A3_x0213[] = {
+ 0, 0x3C27, 0, 0, 0, 0x627C, 0x6277, 0xD024,
+ 0xF250, 0xD026, 0x627D, 0x6278, 0xF251, 0, 0xF252, 0,
+ 0x4858, 0x6276, 0xD029, 0xD02A, 0x6279, 0xF253, 0xD02C, 0,
+ 0, 0, 0x6322, 0xD02E, 0, 0, 0, 0xD02F,
+ 0xF254, 0xF255, 0, 0, 0x792B, 0, 0xF256, 0x6321,
+ 0x4B61, 0, 0xD033, 0, 0x627E, 0, 0, 0x306B,
+ 0, 0, 0x792C, 0xD035, 0x6324, 0, 0xD037, 0x792E,
+ 0, 0xF257, 0xF258, 0xF259, 0, 0x6323, 0xF25A, 0xD03B,
+};
+static const unsigned short utf8_to_euc_E7A4[] = {
+ 0xD036, 0x3E4C, 0, 0, 0, 0, 0xD03C, 0x6325,
+ 0, 0, 0, 0, 0xD03D, 0, 0x4143, 0,
+ 0xD03E, 0x6327, 0x6326, 0, 0, 0, 0, 0,
+ 0, 0x6328, 0xD03F, 0, 0xD040, 0, 0xD041, 0xD042,
+ 0xD043, 0, 0, 0, 0, 0xD044, 0x6268, 0xD045,
+ 0, 0xD046, 0x626A, 0x632A, 0x6329, 0xD047, 0, 0,
+ 0xF454, 0xD048, 0, 0, 0xD049, 0xD04A, 0, 0,
+ 0, 0, 0x3C28, 0xD04B, 0x4E69, 0xD04C, 0x3C52, 0xD04D,
+};
+static const unsigned short utf8_to_euc_E7A4_x0213[] = {
+ 0x792D, 0x3E4C, 0, 0, 0, 0, 0xD03C, 0x6325,
+ 0, 0, 0, 0, 0xD03D, 0, 0x4143, 0,
+ 0xF25C, 0x6327, 0x6326, 0, 0, 0, 0, 0,
+ 0, 0x6328, 0xD03F, 0xF25D, 0x792F, 0, 0xD041, 0xD042,
+ 0xD043, 0, 0, 0, 0, 0xF25F, 0x6268, 0xD045,
+ 0, 0xD046, 0x626A, 0x632A, 0x6329, 0xD047, 0x7930, 0,
+ 0xF25E, 0x7931, 0, 0, 0x7932, 0xD04A, 0, 0,
+ 0, 0, 0x3C28, 0xF260, 0x4E69, 0xD04C, 0x3C52, 0xD04D,
+};
+static const unsigned short utf8_to_euc_E7A5[] = {
+ 0x632B, 0x3737, 0, 0, 0xD04E, 0xD04F, 0xD050, 0x3540,
+ 0x3527, 0x3B63, 0xD051, 0xD052, 0, 0, 0, 0xD053,
+ 0x4D34, 0xD054, 0, 0x6331, 0xD055, 0x6330, 0x4144, 0x632D,
+ 0xD056, 0, 0x632F, 0xD057, 0xD058, 0x3D4B, 0x3F40, 0x632E,
+ 0x632C, 0, 0x472A, 0, 0, 0x3E4D, 0, 0xD059,
+ 0x493C, 0xD05A, 0, 0xD05B, 0, 0x3A57, 0, 0,
+ 0, 0, 0xD05C, 0, 0, 0, 0, 0x4578,
+ 0, 0xD05D, 0x6332, 0xD05E, 0xD05F, 0, 0xD060, 0x6333,
+};
+static const unsigned short utf8_to_euc_E7A5_x0213[] = {
+ 0x632B, 0x3737, 0, 0, 0xD04E, 0x7935, 0x7936, 0x3540,
+ 0x3527, 0x3B63, 0xF261, 0xD052, 0, 0, 0, 0xD053,
+ 0x4D34, 0xD054, 0, 0x6331, 0xD055, 0x6330, 0x4144, 0x632D,
+ 0xF262, 0, 0x632F, 0xF263, 0x793A, 0x3D4B, 0x3F40, 0x632E,
+ 0x632C, 0, 0x472A, 0, 0, 0x3E4D, 0, 0xF265,
+ 0x493C, 0xD05A, 0, 0xD05B, 0, 0x3A57, 0, 0,
+ 0, 0, 0xF266, 0, 0, 0, 0, 0x4578,
+ 0, 0x793E, 0x6332, 0xD05E, 0xD05F, 0, 0xD060, 0x6333,
+};
+static const unsigned short utf8_to_euc_E7A6[] = {
+ 0x6349, 0x3658, 0, 0, 0x4F3D, 0x4135, 0, 0,
+ 0, 0, 0x6334, 0xD061, 0xD062, 0x3252, 0x4477, 0x4A21,
+ 0, 0xD063, 0, 0xD064, 0xD065, 0xD066, 0xD067, 0,
+ 0xD068, 0, 0, 0xD069, 0xD06A, 0x6335, 0, 0,
+ 0, 0xD06B, 0, 0, 0, 0, 0x357A, 0x6336,
+ 0xD06C, 0xD06D, 0x6338, 0xD06E, 0, 0, 0x6339, 0xD06F,
+ 0x4729, 0xD070, 0, 0x633A, 0xD071, 0, 0, 0,
+ 0xD072, 0x633B, 0x633C, 0xD073, 0, 0x3659, 0x3253, 0x4645,
+};
+static const unsigned short utf8_to_euc_E7A6_x0213[] = {
+ 0x6349, 0x3658, 0, 0, 0x4F3D, 0x4135, 0, 0,
+ 0, 0, 0x6334, 0xD061, 0xD062, 0x3252, 0x4477, 0x4A21,
+ 0, 0xD063, 0, 0xD064, 0xF267, 0xF268, 0xF269, 0,
+ 0x7942, 0, 0, 0xF26A, 0xD06A, 0x6335, 0, 0,
+ 0, 0xF26B, 0, 0, 0, 0, 0x357A, 0x6336,
+ 0xD06C, 0xF26C, 0x6338, 0xD06E, 0, 0, 0x6339, 0xD06F,
+ 0x4729, 0x7943, 0, 0x633A, 0xF26D, 0, 0, 0,
+ 0x7944, 0x633B, 0x633C, 0xF26E, 0, 0x3659, 0x3253, 0x4645,
+};
+static const unsigned short utf8_to_euc_E7A7[] = {
+ 0x3D28, 0x3B64, 0xD074, 0, 0xD075, 0, 0, 0xD076,
+ 0xD077, 0x633D, 0xD078, 0x3D29, 0, 0, 0, 0xD079,
+ 0, 0x324A, 0x4943, 0, 0xD07A, 0x633E, 0xD07B, 0,
+ 0x486B, 0, 0xD07C, 0, 0, 0xD07D, 0xD07E, 0x4145,
+ 0xD121, 0x6341, 0xD122, 0x6342, 0x4769, 0xD123, 0x3F41, 0x633F,
+ 0, 0x4361, 0xD124, 0xD125, 0x6340, 0xD126, 0, 0,
+ 0x3E4E, 0xD127, 0, 0, 0, 0, 0, 0,
+ 0xD128, 0, 0, 0x305C, 0xD129, 0, 0, 0,
+};
+static const unsigned short utf8_to_euc_E7A7_x0213[] = {
+ 0x3D28, 0x3B64, 0xF26F, 0, 0xD075, 0, 0, 0xF270,
+ 0x7945, 0x633D, 0x7946, 0x3D29, 0xF271, 0xF272, 0, 0xD079,
+ 0, 0x324A, 0x4943, 0, 0x7948, 0x633E, 0xF273, 0,
+ 0x486B, 0, 0xD07C, 0, 0, 0xD07D, 0x7949, 0x4145,
+ 0xD121, 0x6341, 0xD122, 0x6342, 0x4769, 0xD123, 0x3F41, 0x633F,
+ 0, 0x4361, 0xD124, 0x794A, 0x6340, 0x794B, 0, 0,
+ 0x3E4E, 0xD127, 0, 0, 0, 0, 0, 0,
+ 0xD128, 0, 0, 0x305C, 0xD129, 0, 0, 0,
+};
+static const unsigned short utf8_to_euc_E7A8[] = {
+ 0x3529, 0, 0xD12A, 0xD12B, 0, 0, 0, 0xD12C,
+ 0x6343, 0xD12D, 0xD12E, 0x4478, 0xD12F, 0x6344, 0x4047, 0,
+ 0, 0xD130, 0, 0, 0x4C2D, 0xD131, 0, 0x4923,
+ 0x6345, 0x6346, 0x4355, 0xD132, 0x4E47, 0, 0xD133, 0x6348,
+ 0x6347, 0xD134, 0, 0, 0, 0, 0, 0xD135,
+ 0, 0, 0, 0xD136, 0, 0xD137, 0x3C6F, 0xD138,
+ 0xD139, 0x634A, 0x3070, 0, 0xD13A, 0xD13B, 0, 0x634D,
+ 0xD13C, 0xD13D, 0xD13E, 0x634B, 0x3254, 0x374E, 0x634C, 0x3946,
+};
+static const unsigned short utf8_to_euc_E7A8_x0213[] = {
+ 0x3529, 0, 0xD12A, 0x794C, 0, 0, 0, 0xD12C,
+ 0x6343, 0xD12D, 0xF278, 0x4478, 0xD12F, 0x6344, 0x4047, 0,
+ 0, 0xF279, 0, 0, 0x4C2D, 0xF27A, 0, 0x4923,
+ 0x6345, 0x6346, 0x4355, 0xF27B, 0x4E47, 0, 0xF27C, 0x6348,
+ 0x6347, 0xD134, 0, 0, 0, 0, 0, 0xD135,
+ 0, 0, 0, 0xD136, 0, 0xF27E, 0x3C6F, 0xD138,
+ 0xD139, 0x634A, 0x3070, 0, 0xD13A, 0xD13B, 0, 0x634D,
+ 0xF321, 0x794E, 0xD13E, 0x634B, 0x3254, 0x374E, 0x634C, 0x3946,
+};
+static const unsigned short utf8_to_euc_E7A9[] = {
+ 0x3972, 0, 0x4A66, 0x634E, 0xD13F, 0xD140, 0x4B54, 0xD141,
+ 0xD142, 0x6350, 0, 0, 0xD143, 0x4051, 0x314F, 0x323A,
+ 0x302C, 0, 0, 0, 0, 0xD144, 0xD145, 0x634F,
+ 0, 0xD146, 0, 0, 0xD147, 0xD148, 0, 0xD149,
+ 0xD14A, 0x6351, 0x6352, 0x3E77, 0, 0xD14B, 0, 0xD14C,
+ 0, 0x6353, 0xD14D, 0x334F, 0, 0xD14E, 0, 0,
+ 0x6355, 0, 0, 0, 0x376A, 0xD14F, 0x3566, 0,
+ 0xD150, 0x6356, 0x3675, 0, 0, 0x6357, 0xD151, 0x407C,
+};
+static const unsigned short utf8_to_euc_E7A9_x0213[] = {
+ 0x3972, 0, 0x4A66, 0x634E, 0xD13F, 0xD140, 0x4B54, 0xF322,
+ 0xD142, 0x6350, 0, 0, 0xF323, 0x4051, 0x314F, 0x323A,
+ 0x302C, 0, 0, 0, 0, 0xD144, 0xF324, 0x634F,
+ 0, 0xF325, 0, 0, 0xF326, 0x794F, 0, 0xF327,
+ 0xF328, 0x6351, 0x6352, 0x3E77, 0, 0xD14B, 0, 0xF329,
+ 0, 0x6353, 0xF32A, 0x334F, 0, 0x7950, 0, 0,
+ 0x6355, 0, 0, 0, 0x376A, 0xF32B, 0x3566, 0,
+ 0xF32C, 0x6356, 0x3675, 0, 0, 0x6357, 0xD151, 0x407C,
+};
+static const unsigned short utf8_to_euc_E7AA[] = {
+ 0xD152, 0x464D, 0xD153, 0x4060, 0x3A75, 0xD154, 0xD155, 0,
+ 0x6358, 0, 0xD156, 0xD157, 0, 0, 0, 0,
+ 0xD158, 0xD159, 0x4362, 0x416B, 0xD15A, 0x635A, 0x635C, 0x6359,
+ 0x635B, 0, 0, 0, 0, 0, 0xD15B, 0x3722,
+ 0xD15C, 0, 0, 0xD15D, 0, 0, 0, 0,
+ 0, 0x635D, 0x3726, 0, 0xD15E, 0, 0x3567, 0x4D52,
+ 0x635F, 0, 0, 0xD15F, 0, 0xD160, 0x6360, 0,
+ 0, 0xD161, 0x312E, 0xD162, 0xD163, 0, 0, 0x6363,
+};
+static const unsigned short utf8_to_euc_E7AA_x0213[] = {
+ 0xD152, 0x464D, 0xF32D, 0x4060, 0x3A75, 0x7952, 0xD155, 0,
+ 0x6358, 0, 0xF32E, 0xD157, 0, 0, 0, 0,
+ 0xF32F, 0xD159, 0x4362, 0x416B, 0xD15A, 0x635A, 0x635C, 0x6359,
+ 0x635B, 0, 0, 0, 0, 0, 0xD15B, 0x3722,
+ 0x7953, 0, 0, 0xF330, 0, 0, 0, 0,
+ 0, 0x635D, 0x3726, 0, 0xF331, 0, 0x3567, 0x4D52,
+ 0x635F, 0, 0, 0x7955, 0, 0xD160, 0x6360, 0,
+ 0, 0xF334, 0x312E, 0x7956, 0xF335, 0, 0xF336, 0x6363,
+};
+static const unsigned short utf8_to_euc_E7AB[] = {
+ 0, 0, 0, 0x3376, 0x6362, 0x6361, 0xD164, 0x6365,
+ 0x635E, 0xD165, 0x6366, 0x4E29, 0xD166, 0x6367, 0xD167, 0x6368,
+ 0, 0xD168, 0x5474, 0x636A, 0, 0x6369, 0, 0,
+ 0, 0x636B, 0x636C, 0xD169, 0x4E35, 0x636D, 0, 0x706F,
+ 0x3E4F, 0x636E, 0x636F, 0x3D57, 0, 0x4638, 0x6370, 0xF459,
+ 0xD16A, 0xD16B, 0x4328, 0xD16C, 0xD16D, 0x6371, 0, 0x433C,
+ 0x6372, 0xD16E, 0, 0, 0xD16F, 0, 0x3625, 0,
+ 0x513F, 0x435D, 0x3C33, 0xD170, 0, 0xD171, 0xD172, 0x3448,
+};
+static const unsigned short utf8_to_euc_E7AB_x0213[] = {
+ 0, 0, 0, 0x3376, 0x6362, 0x6361, 0xD164, 0x6365,
+ 0x635E, 0xD165, 0x6366, 0x4E29, 0xF338, 0x6367, 0x7957, 0x6368,
+ 0, 0xF339, 0x5474, 0x636A, 0, 0x6369, 0, 0,
+ 0, 0x636B, 0x636C, 0xD169, 0x4E35, 0x636D, 0, 0x706F,
+ 0x3E4F, 0x636E, 0x636F, 0x3D57, 0, 0x4638, 0x6370, 0xF33A,
+ 0xF33B, 0xD16B, 0x4328, 0x7958, 0xD16D, 0x6371, 0, 0x433C,
+ 0x6372, 0xD16E, 0, 0, 0xF33C, 0, 0x3625, 0,
+ 0x513F, 0x435D, 0x3C33, 0xD170, 0, 0x7959, 0xD172, 0x3448,
+};
+static const unsigned short utf8_to_euc_E7AC[] = {
+ 0, 0, 0x6373, 0, 0x6422, 0, 0x6376, 0xD173,
+ 0x3568, 0, 0x6375, 0x6424, 0, 0, 0, 0x6374,
+ 0, 0x3E50, 0, 0, 0xD174, 0, 0, 0,
+ 0x6378, 0x6379, 0, 0x452B, 0, 0, 0x637A, 0xD175,
+ 0x335E, 0, 0, 0xD176, 0, 0x3F5A, 0x4964, 0xD177,
+ 0x637C, 0xD178, 0xD179, 0xD17A, 0x4268, 0xD17B, 0xD17C, 0xD17D,
+ 0xD17E, 0xD221, 0, 0x6377, 0xD222, 0x637B, 0x637D, 0,
+ 0, 0x3A7B, 0, 0, 0, 0xD223, 0, 0xD224,
+};
+static const unsigned short utf8_to_euc_E7AC_x0213[] = {
+ 0, 0, 0x6373, 0, 0x6422, 0, 0x6376, 0xF33F,
+ 0x3568, 0, 0x6375, 0x6424, 0, 0, 0, 0x6374,
+ 0, 0x3E50, 0x795A, 0, 0xD174, 0, 0, 0,
+ 0x6378, 0x6379, 0, 0x452B, 0, 0, 0x637A, 0xD175,
+ 0x335E, 0, 0, 0xD176, 0, 0x3F5A, 0x4964, 0xF342,
+ 0x637C, 0xD178, 0xF343, 0xD17A, 0x4268, 0x795B, 0xF344, 0xF345,
+ 0xD17E, 0xF346, 0, 0x6377, 0xD222, 0x637B, 0x637D, 0,
+ 0, 0x3A7B, 0, 0x795C, 0, 0xF341, 0, 0xD224,
+};
+static const unsigned short utf8_to_euc_E7AD[] = {
+ 0xD225, 0xD226, 0, 0, 0, 0x6426, 0x492E, 0xD227,
+ 0x4826, 0x4579, 0, 0x365A, 0x6425, 0x6423, 0xD228, 0x4835,
+ 0x637E, 0x435E, 0x457B, 0, 0x457A, 0xD229, 0x3A76, 0,
+ 0, 0, 0, 0, 0, 0x6438, 0, 0,
+ 0xD22A, 0, 0, 0, 0xD22B, 0x6428, 0xD22C, 0x642A,
+ 0, 0xD22D, 0xD22E, 0, 0x642D, 0xD22F, 0x642E, 0xD230,
+ 0x642B, 0x642C, 0xD231, 0xD232, 0x6429, 0x6427, 0, 0xD233,
+ 0, 0, 0x6421, 0, 0, 0, 0, 0,
+};
+static const unsigned short utf8_to_euc_E7AD_x0213[] = {
+ 0xD225, 0xF34A, 0, 0, 0, 0x6426, 0x492E, 0x795D,
+ 0x4826, 0x4579, 0, 0x365A, 0x6425, 0x6423, 0x795E, 0x4835,
+ 0x637E, 0x435E, 0x457B, 0, 0x457A, 0xF34C, 0x3A76, 0,
+ 0, 0, 0, 0, 0, 0x6438, 0, 0,
+ 0x795F, 0, 0, 0, 0xF34E, 0x6428, 0xF34F, 0x642A,
+ 0, 0xF350, 0xD22E, 0, 0x642D, 0x7960, 0x642E, 0x7961,
+ 0x642B, 0x642C, 0x7962, 0xF351, 0x6429, 0x6427, 0, 0xD233,
+ 0, 0xF34D, 0x6421, 0, 0, 0, 0, 0xF349,
+};
+static const unsigned short utf8_to_euc_E7AE[] = {
+ 0, 0, 0, 0, 0xD234, 0, 0x4A4F, 0x3255,
+ 0, 0xD235, 0, 0x6435, 0, 0x6432, 0xD236, 0x6437,
+ 0xD237, 0xD238, 0x6436, 0, 0x4773, 0x4C27, 0xD239, 0x3B3B,
+ 0x6430, 0x6439, 0x6434, 0xD23A, 0x6433, 0x642F, 0xD23B, 0x6431,
+ 0xD23C, 0x3449, 0, 0, 0, 0xD23D, 0, 0,
+ 0, 0, 0x433D, 0, 0xD23E, 0x407D, 0, 0xD23F,
+ 0xD240, 0x4822, 0xD241, 0, 0x643E, 0xD242, 0xD243, 0,
+ 0x4824, 0, 0xD244, 0xD245, 0xD246, 0xD247, 0, 0,
+};
+static const unsigned short utf8_to_euc_E7AE_x0213[] = {
+ 0, 0, 0, 0, 0xD234, 0, 0x4A4F, 0x3255,
+ 0, 0xD235, 0, 0x6435, 0, 0x6432, 0xD236, 0x6437,
+ 0xF354, 0xF355, 0x6436, 0, 0x4773, 0x4C27, 0xD239, 0x3B3B,
+ 0x6430, 0x6439, 0x6434, 0xF356, 0x6433, 0x642F, 0x7963, 0x6431,
+ 0xD23C, 0x3449, 0, 0, 0, 0xD23D, 0, 0,
+ 0, 0, 0x433D, 0, 0xD23E, 0x407D, 0, 0xF358,
+ 0xD240, 0x4822, 0xD241, 0, 0x643E, 0xF359, 0xD243, 0,
+ 0x4824, 0, 0xD244, 0xD245, 0xF35A, 0xD247, 0, 0,
+};
+static const unsigned short utf8_to_euc_E7AF[] = {
+ 0x4061, 0x643B, 0xD248, 0, 0x484F, 0xD249, 0x643F, 0x4A53,
+ 0xD24A, 0x435B, 0xD24B, 0x643A, 0x643C, 0, 0, 0x643D,
+ 0, 0, 0, 0, 0xD24C, 0, 0xD24D, 0xD24E,
+ 0, 0xD24F, 0xD250, 0xD251, 0, 0x6440, 0, 0,
+ 0x3C44, 0, 0, 0, 0x4646, 0x6445, 0x6444, 0,
+ 0xD252, 0x6441, 0xD253, 0, 0, 0x4F36, 0, 0,
+ 0, 0, 0xD254, 0x644A, 0xD255, 0xD256, 0x644E, 0x644B,
+ 0xD257, 0xD258, 0xD259, 0, 0xD25A, 0, 0xD25B, 0,
+};
+static const unsigned short utf8_to_euc_E7AF_x0213[] = {
+ 0x4061, 0x643B, 0xD248, 0, 0x484F, 0xF35B, 0x643F, 0x4A53,
+ 0xD24A, 0x435B, 0xF35C, 0x643A, 0x643C, 0, 0, 0x643D,
+ 0, 0, 0, 0, 0xF35F, 0, 0xF360, 0x7965,
+ 0, 0x7966, 0xF361, 0xD251, 0, 0x6440, 0, 0,
+ 0x3C44, 0, 0, 0, 0x4646, 0x6445, 0x6444, 0,
+ 0xD252, 0x6441, 0xF362, 0, 0, 0x4F36, 0, 0,
+ 0xF363, 0, 0xD254, 0x644A, 0xD255, 0xD256, 0x644E, 0x644B,
+ 0xD257, 0xD258, 0xD259, 0, 0xD25A, 0, 0xD25B, 0,
+};
+static const unsigned short utf8_to_euc_E7B0[] = {
+ 0x6447, 0xD25C, 0xD25D, 0xD25E, 0xD25F, 0, 0xD260, 0x6448,
+ 0, 0xD261, 0, 0xD262, 0xD263, 0x644D, 0xD264, 0xD265,
+ 0, 0x6442, 0x5255, 0x6449, 0x6443, 0, 0, 0x644C,
+ 0, 0xD266, 0, 0xD267, 0, 0, 0, 0x6452,
+ 0xD268, 0x344A, 0, 0x644F, 0, 0xD269, 0xD26A, 0x6450,
+ 0xD26B, 0, 0x6451, 0x6454, 0xD26C, 0, 0, 0,
+ 0, 0xD26D, 0, 0xD26E, 0xD26F, 0, 0xD270, 0x6453,
+ 0x4876, 0xD271, 0xD272, 0, 0, 0x6455, 0x4E7C, 0x4A6D,
+};
+static const unsigned short utf8_to_euc_E7B0_x0213[] = {
+ 0x6447, 0x7967, 0xD25D, 0xF364, 0xD25F, 0, 0xD260, 0x6448,
+ 0, 0xD261, 0, 0xF365, 0xD263, 0x644D, 0xF366, 0xF367,
+ 0, 0x6442, 0x5255, 0x6449, 0x6443, 0, 0, 0x644C,
+ 0, 0xD266, 0, 0xD267, 0, 0, 0x7969, 0x6452,
+ 0x796A, 0x344A, 0, 0x644F, 0, 0xD269, 0xF368, 0x6450,
+ 0xD26B, 0, 0x6451, 0x6454, 0xD26C, 0, 0, 0,
+ 0, 0x7968, 0, 0x796B, 0xD26F, 0, 0x796C, 0x6453,
+ 0x4876, 0xD271, 0xD272, 0, 0, 0x6455, 0x4E7C, 0x4A6D,
+};
+static const unsigned short utf8_to_euc_E7B1[] = {
+ 0x645A, 0, 0, 0x6457, 0, 0, 0xD273, 0,
+ 0, 0, 0xD274, 0, 0x6456, 0x4052, 0, 0x6459,
+ 0x645B, 0xD276, 0xD277, 0xD278, 0x6458, 0xD275, 0x645F, 0,
+ 0x645C, 0xD279, 0xD27A, 0xD27B, 0xD27C, 0xD27D, 0xD27E, 0x645D,
+ 0x6446, 0xD321, 0, 0xD322, 0x645E, 0x6460, 0, 0xD323,
+ 0, 0xD324, 0, 0, 0x6461, 0xD325, 0xD326, 0,
+ 0xD327, 0, 0xD328, 0x4A46, 0, 0x6462, 0, 0,
+ 0, 0xD329, 0, 0, 0xD32A, 0xD32B, 0x4C62, 0,
+};
+static const unsigned short utf8_to_euc_E7B1_x0213[] = {
+ 0x645A, 0, 0, 0x6457, 0, 0xF369, 0xD273, 0,
+ 0, 0, 0xF36A, 0, 0x6456, 0x4052, 0, 0x6459,
+ 0x645B, 0xF36B, 0xD277, 0xD278, 0x6458, 0xD275, 0x645F, 0xF36C,
+ 0x645C, 0x796F, 0xD27A, 0xD27B, 0xD27C, 0xD27D, 0xF36D, 0x645D,
+ 0x6446, 0xF36E, 0, 0xD322, 0x645E, 0x6460, 0, 0xD323,
+ 0, 0xF36F, 0, 0, 0x6461, 0x7970, 0xF370, 0xF371,
+ 0xF372, 0, 0xD328, 0x4A46, 0, 0x6462, 0, 0,
+ 0, 0x7971, 0, 0, 0xD32A, 0xD32B, 0x4C62, 0,
+};
+static const unsigned short utf8_to_euc_E7B2[] = {
+ 0, 0x364E, 0x3729, 0x6463, 0, 0, 0xD32C, 0xD32D,
+ 0, 0x4A34, 0, 0x3F68, 0, 0x4C30, 0, 0xD32E,
+ 0x6464, 0, 0x4E33, 0, 0xD32F, 0x4774, 0, 0x4146,
+ 0x4734, 0, 0, 0x3D4D, 0, 0, 0xD330, 0x3040,
+ 0xD331, 0x6469, 0x6467, 0, 0x6465, 0x3421, 0xD332, 0x3E51,
+ 0x646A, 0, 0, 0x6468, 0, 0x6466, 0x646E, 0,
+ 0xD333, 0x646D, 0x646C, 0x646B, 0, 0, 0xD334, 0xD335,
+ 0, 0x646F, 0xD336, 0xD337, 0xD338, 0x6470, 0x403A, 0xD339,
+};
+static const unsigned short utf8_to_euc_E7B2_x0213[] = {
+ 0, 0x364E, 0x3729, 0x6463, 0, 0, 0xD32C, 0xD32D,
+ 0, 0x4A34, 0, 0x3F68, 0, 0x4C30, 0, 0x7972,
+ 0x6464, 0, 0x4E33, 0, 0x7973, 0x4774, 0, 0x4146,
+ 0x4734, 0, 0, 0x3D4D, 0, 0, 0xD330, 0x3040,
+ 0x7974, 0x6469, 0x6467, 0, 0x6465, 0x3421, 0xF376, 0x3E51,
+ 0x646A, 0, 0, 0x6468, 0, 0x6466, 0x646E, 0,
+ 0xD333, 0x646D, 0x646C, 0x646B, 0, 0, 0xF378, 0xF379,
+ 0, 0x646F, 0xD336, 0xD337, 0x7975, 0x6470, 0x403A, 0xF37A,
+};
+static const unsigned short utf8_to_euc_E7B3[] = {
+ 0x6471, 0, 0x6473, 0, 0xD33A, 0x6472, 0, 0xD33B,
+ 0xD33C, 0xD33D, 0x3852, 0, 0, 0xD33E, 0x4138, 0xD33F,
+ 0, 0, 0x6475, 0xD340, 0xD341, 0xD342, 0x457C, 0xD343,
+ 0x6474, 0xD344, 0xD345, 0, 0x6476, 0xD346, 0x4A35, 0x416C,
+ 0x3947, 0, 0x6477, 0, 0, 0, 0xD347, 0x4E48,
+ 0, 0xD348, 0, 0xD349, 0, 0, 0, 0x6479,
+ 0, 0, 0x647A, 0, 0x647B, 0xD34A, 0x647C, 0,
+ 0x3B65, 0, 0x647D, 0x374F, 0, 0, 0x356A, 0,
+};
+static const unsigned short utf8_to_euc_E7B3_x0213[] = {
+ 0x6471, 0, 0x6473, 0, 0xF37C, 0x6472, 0, 0xD33B,
+ 0xF37E, 0xD33D, 0x3852, 0, 0, 0xF421, 0x4138, 0xD33F,
+ 0, 0, 0x6475, 0xD340, 0xD341, 0x7976, 0x457C, 0xF423,
+ 0x6474, 0x7977, 0xD345, 0, 0x6476, 0x7978, 0x4A35, 0x416C,
+ 0x3947, 0, 0x6477, 0, 0, 0, 0xF425, 0x4E48,
+ 0, 0xD348, 0, 0xF426, 0, 0, 0, 0x6479,
+ 0, 0, 0x647A, 0, 0x647B, 0xF428, 0x647C, 0,
+ 0x3B65, 0, 0x647D, 0x374F, 0, 0, 0x356A, 0,
+};
+static const unsigned short utf8_to_euc_E7B4[] = {
+ 0x352A, 0, 0x6521, 0xD34B, 0x4C73, 0x3948, 0x647E, 0xD34C,
+ 0xD34D, 0xD34E, 0x6524, 0x4C66, 0, 0x473C, 0, 0xD34F,
+ 0x4933, 0xD350, 0xD351, 0xD352, 0x3D63, 0x6523, 0xD353, 0x3C53,
+ 0x3949, 0x3B66, 0x3569, 0x4A36, 0x6522, 0xD354, 0xD355, 0,
+ 0x4147, 0x4B42, 0x3A77, 0xD356, 0, 0, 0xD357, 0,
+ 0, 0, 0xD358, 0x3B67, 0x445D, 0xD359, 0x6527, 0x4E5F,
+ 0x3A59, 0xD35A, 0x6528, 0x3F42, 0, 0x652A, 0, 0,
+ 0, 0x3E52, 0x3A30, 0, 0xD35B, 0xD35C, 0xD35D, 0x6529,
+};
+static const unsigned short utf8_to_euc_E7B4_x0213[] = {
+ 0x352A, 0, 0x6521, 0xF429, 0x4C73, 0x3948, 0x647E, 0x7979,
+ 0x797A, 0xF42A, 0x6524, 0x4C66, 0, 0x473C, 0, 0xD34F,
+ 0x4933, 0xD350, 0xF42C, 0x797B, 0x3D63, 0x6523, 0xD353, 0x3C53,
+ 0x3949, 0x3B66, 0x3569, 0x4A36, 0x6522, 0x797C, 0xF42D, 0,
+ 0x4147, 0x4B42, 0x3A77, 0x797D, 0, 0, 0xD357, 0,
+ 0, 0, 0xD358, 0x3B67, 0x445D, 0xD359, 0x6527, 0x4E5F,
+ 0x3A59, 0x797E, 0x6528, 0x3F42, 0, 0x652A, 0, 0,
+ 0, 0x3E52, 0x3A30, 0, 0xD35B, 0xF430, 0xF431, 0x6529,
+};
+static const unsigned short utf8_to_euc_E7B5[] = {
+ 0xD35E, 0xD35F, 0x3D2A, 0x383E, 0x4148, 0x6525, 0x652B, 0xD360,
+ 0xD361, 0, 0, 0x6526, 0x3750, 0xD362, 0x652E, 0x6532,
+ 0x376B, 0xD363, 0, 0xD364, 0, 0, 0x652D, 0xD365,
+ 0, 0xD366, 0xD367, 0x6536, 0xD368, 0xD369, 0x394A, 0,
+ 0, 0x4D6D, 0x303C, 0x6533, 0, 0xD36A, 0x356B, 0xD36B,
+ 0x6530, 0, 0xD36C, 0, 0, 0, 0x6531, 0,
+ 0xD36D, 0x457D, 0x652F, 0x652C, 0, 0x3328, 0x4064, 0,
+ 0xD36E, 0x3828, 0xD36F, 0xD370, 0, 0x6538, 0, 0xD371,
+};
+static const unsigned short utf8_to_euc_E7B5_x0213[] = {
+ 0xF432, 0x7A21, 0x3D2A, 0x383E, 0x4148, 0x6525, 0x652B, 0xF433,
+ 0x7A22, 0, 0, 0x6526, 0x3750, 0xD362, 0x652E, 0x6532,
+ 0x376B, 0xD363, 0, 0x7A23, 0, 0, 0x652D, 0xD365,
+ 0, 0xF437, 0xF438, 0x6536, 0x7A24, 0xD369, 0x394A, 0,
+ 0, 0x4D6D, 0x303C, 0x6533, 0, 0xD36A, 0x356B, 0xD36B,
+ 0x6530, 0, 0xF439, 0, 0, 0, 0x6531, 0,
+ 0xF43A, 0x457D, 0x652F, 0x652C, 0, 0x3328, 0x4064, 0,
+ 0xD36E, 0x3828, 0x7A25, 0xD370, 0, 0x6538, 0, 0xF43C,
+};
+static const unsigned short utf8_to_euc_E7B6[] = {
+ 0, 0xD372, 0xD373, 0xD374, 0, 0xD375, 0xD376, 0,
+ 0xD377, 0x6535, 0, 0xD378, 0xD379, 0xD37A, 0, 0x6537,
+ 0, 0xD37B, 0, 0x6534, 0, 0, 0xD37C, 0xD37D,
+ 0, 0x3751, 0x4233, 0x6539, 0x416E, 0xD37E, 0xD421, 0x6546,
+ 0xF45C, 0, 0x6542, 0x653C, 0, 0, 0xD422, 0xD423,
+ 0, 0, 0xD424, 0x6540, 0x3C7A, 0x305D, 0x653B, 0x6543,
+ 0x6547, 0x394B, 0x4C56, 0xD425, 0x4456, 0x653D, 0xD426, 0xD427,
+ 0x6545, 0xD428, 0x653A, 0x433E, 0, 0x653F, 0x303D, 0x4C4A,
+};
+static const unsigned short utf8_to_euc_E7B6_x0213[] = {
+ 0, 0xD372, 0xD373, 0x7A26, 0, 0xD375, 0xF43E, 0,
+ 0xF43F, 0x6535, 0, 0x7A27, 0xF440, 0xD37A, 0, 0x6537,
+ 0, 0xD37B, 0, 0x6534, 0, 0, 0xD37C, 0xF441,
+ 0, 0x3751, 0x4233, 0x6539, 0x416E, 0xF443, 0xD421, 0x6546,
+ 0x7A28, 0, 0x6542, 0x653C, 0, 0, 0x7A29, 0xF444,
+ 0, 0, 0xF445, 0x6540, 0x3C7A, 0x305D, 0x653B, 0x6543,
+ 0x6547, 0x394B, 0x4C56, 0xD425, 0x4456, 0x653D, 0xF446, 0xF447,
+ 0x6545, 0xD428, 0x653A, 0x433E, 0, 0x653F, 0x303D, 0x4C4A,
+};
+static const unsigned short utf8_to_euc_E7B7[] = {
+ 0, 0, 0xD429, 0xD42A, 0xD42B, 0xD42C, 0xD42D, 0x653E,
+ 0, 0, 0x365B, 0x486C, 0xD42E, 0xD42F, 0xD430, 0x416D,
+ 0, 0x4E50, 0x3D6F, 0, 0, 0x656E, 0xF45D, 0xD431,
+ 0x6548, 0xD432, 0x407E, 0, 0x6544, 0x6549, 0x654B, 0,
+ 0x4479, 0x654E, 0xD434, 0, 0x654A, 0xD435, 0xD436, 0,
+ 0x4A54, 0x344B, 0xD437, 0xD438, 0x4C4B, 0xD439, 0, 0x305E,
+ 0, 0xD43A, 0x654D, 0, 0x4E7D, 0xD43B, 0xD43C, 0,
+ 0, 0xD43D, 0xD43E, 0x654C, 0, 0, 0, 0,
+};
+static const unsigned short utf8_to_euc_E7B7_x0213[] = {
+ 0xF448, 0, 0x7A2A, 0xD42A, 0xD42B, 0xD42C, 0xD42D, 0x653E,
+ 0, 0, 0x365B, 0x486C, 0x7A2B, 0xD42F, 0xD430, 0x416D,
+ 0, 0x4E50, 0x3D6F, 0, 0, 0x656E, 0x7A2C, 0xF449,
+ 0x6548, 0xF44A, 0x407E, 0, 0x6544, 0x6549, 0x654B, 0,
+ 0x4479, 0x654E, 0xD434, 0x7A2D, 0x654A, 0xD435, 0xF44B, 0,
+ 0x4A54, 0x344B, 0xD437, 0xD438, 0x4C4B, 0xD439, 0, 0x305E,
+ 0, 0xF44C, 0x654D, 0, 0x4E7D, 0xD43B, 0xD43C, 0,
+ 0, 0xF44D, 0xD43E, 0x654C, 0, 0, 0, 0,
+};
+static const unsigned short utf8_to_euc_E7B8[] = {
+ 0xD433, 0x316F, 0, 0, 0x466C, 0x654F, 0, 0,
+ 0xD43F, 0x6556, 0x6550, 0x6557, 0, 0, 0, 0,
+ 0xD440, 0xD441, 0x6553, 0, 0, 0xD442, 0, 0xD443,
+ 0, 0, 0, 0x477B, 0xD444, 0xD445, 0x3C4A, 0x6555,
+ 0xD446, 0x6552, 0x6558, 0x6551, 0, 0, 0x3D44, 0xD447,
+ 0xD448, 0, 0, 0x4B25, 0xD449, 0xD44A, 0x3D4C, 0xD44B,
+ 0, 0x6554, 0x6560, 0xD44C, 0, 0x655C, 0xD44D, 0x655F,
+ 0, 0x655D, 0x6561, 0x655B, 0, 0x6541, 0x4053, 0xD44E,
+};
+static const unsigned short utf8_to_euc_E7B8_x0213[] = {
+ 0xD433, 0x316F, 0, 0, 0x466C, 0x654F, 0, 0,
+ 0x7A30, 0x6556, 0x6550, 0x6557, 0, 0, 0, 0,
+ 0xF451, 0x7A31, 0x6553, 0, 0, 0x7A32, 0, 0xF452,
+ 0, 0, 0, 0x477B, 0xD444, 0xF453, 0x3C4A, 0x6555,
+ 0xF454, 0x6552, 0x6558, 0x6551, 0, 0, 0x3D44, 0xF455,
+ 0x7A2F, 0, 0, 0x4B25, 0xF456, 0xD44A, 0x3D4C, 0xD44B,
+ 0, 0x6554, 0x6560, 0xD44C, 0, 0x655C, 0xD44D, 0x655F,
+ 0, 0x655D, 0x6561, 0x655B, 0, 0x6541, 0x4053, 0xD44E,
+};
+static const unsigned short utf8_to_euc_E7B9[] = {
+ 0, 0x484B, 0, 0x655E, 0xD44F, 0xD450, 0x6559, 0xD451,
+ 0, 0, 0x4121, 0x3752, 0, 0x3D2B, 0xD452, 0,
+ 0xD453, 0, 0xD454, 0, 0x3F25, 0x4136, 0x6564, 0,
+ 0xD455, 0x6566, 0x6567, 0, 0, 0x6563, 0x6565, 0xD456,
+ 0, 0xD457, 0xD458, 0, 0, 0xD459, 0x655A, 0x6562,
+ 0, 0x656A, 0x6569, 0xD45A, 0, 0x4B7A, 0xD45B, 0xD45C,
+ 0x372B, 0, 0, 0xD45D, 0, 0, 0, 0,
+ 0xD45E, 0x6568, 0, 0x656C, 0x656B, 0x656F, 0xD45F, 0x6571,
+};
+static const unsigned short utf8_to_euc_E7B9_x0213[] = {
+ 0, 0x484B, 0, 0x655E, 0xD44F, 0xF457, 0x6559, 0x7A34,
+ 0, 0, 0x4121, 0x3752, 0, 0x3D2B, 0xD452, 0,
+ 0xD453, 0, 0x7A35, 0, 0x3F25, 0x4136, 0x6564, 0,
+ 0xD455, 0x6566, 0x6567, 0, 0, 0x6563, 0x6565, 0xD456,
+ 0, 0x7A36, 0xD458, 0, 0, 0xD459, 0x655A, 0x6562,
+ 0, 0x656A, 0x6569, 0x7E7E, 0, 0x4B7A, 0xD45B, 0xD45C,
+ 0x372B, 0, 0, 0xF458, 0, 0xF459, 0, 0,
+ 0xD45E, 0x6568, 0, 0x656C, 0x656B, 0x656F, 0xF45A, 0x6571,
+};
+static const unsigned short utf8_to_euc_E7BA[] = {
+ 0, 0xD460, 0x3B3C, 0x656D, 0, 0, 0xD461, 0xD462,
+ 0x6572, 0x6573, 0xD463, 0, 0x6574, 0xD464, 0x657A, 0x453B,
+ 0x6576, 0xD465, 0x6575, 0x6577, 0x6578, 0xD466, 0x6579, 0,
+ 0xD467, 0, 0xD468, 0x657B, 0x657C, 0xD469, 0xD46A, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+};
+static const unsigned short utf8_to_euc_E7BA_x0213[] = {
+ 0, 0xD460, 0x3B3C, 0x656D, 0, 0, 0xF45B, 0xF45C,
+ 0x6572, 0x6573, 0x7A37, 0, 0x6574, 0x7A38, 0x657A, 0x453B,
+ 0x6576, 0xF45E, 0x6575, 0x6577, 0x6578, 0xD466, 0x6579, 0,
+ 0xF45F, 0, 0xF460, 0x657B, 0x657C, 0xD469, 0xD46A, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+};
+static const unsigned short utf8_to_euc_E7BC[] = {
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0x344C, 0,
+ 0x657D, 0, 0x657E, 0xD46C, 0xD46B, 0xD46D, 0xD46E, 0xD46F,
+};
+static const unsigned short utf8_to_euc_E7BC_x0213[] = {
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0x344C, 0,
+ 0x657D, 0, 0x657E, 0xF463, 0xF462, 0xD46D, 0xF464, 0xD46F,
+};
+static const unsigned short utf8_to_euc_E7BD[] = {
+ 0, 0, 0, 0xD470, 0xD471, 0x6621, 0, 0xD472,
+ 0, 0, 0, 0, 0x6622, 0x6623, 0x6624, 0xD473,
+ 0x6625, 0x6626, 0xD474, 0xD475, 0x6628, 0x6627, 0, 0,
+ 0x6629, 0, 0, 0xD476, 0xD477, 0xD478, 0, 0x662A,
+ 0x662B, 0xD479, 0, 0xD47A, 0xD47B, 0xD47C, 0xD47D, 0x662E,
+ 0x662C, 0x662D, 0x3A61, 0x3753, 0, 0xD47E, 0x4356, 0,
+ 0x4833, 0xD521, 0x3D70, 0, 0, 0x474D, 0, 0x486D,
+ 0x662F, 0x586D, 0, 0, 0, 0xD522, 0xD523, 0xD524,
+};
+static const unsigned short utf8_to_euc_E7BD_x0213[] = {
+ 0, 0, 0, 0xF465, 0xF466, 0x6621, 0, 0x7A39,
+ 0, 0, 0, 0, 0x6622, 0x6623, 0x6624, 0xF467,
+ 0x6625, 0x6626, 0xF46A, 0xD475, 0x6628, 0x6627, 0, 0,
+ 0x6629, 0, 0, 0xD476, 0xD477, 0xD478, 0, 0x662A,
+ 0x662B, 0xF46C, 0, 0xF46D, 0xF46E, 0xD47C, 0xD47D, 0x662E,
+ 0x662C, 0x662D, 0x3A61, 0x3753, 0, 0xF46F, 0x4356, 0,
+ 0x4833, 0xD521, 0x3D70, 0, 0, 0x474D, 0, 0x486D,
+ 0x662F, 0x586D, 0, 0, 0, 0xF470, 0xF471, 0xD524,
+};
+static const unsigned short utf8_to_euc_E7BE[] = {
+ 0xD525, 0, 0x6630, 0x6632, 0, 0x4D65, 0x6631, 0x6634,
+ 0x6633, 0, 0x4D53, 0xD526, 0x6635, 0xD527, 0x487E, 0xD528,
+ 0xD529, 0xD52A, 0, 0, 0x6636, 0, 0xD52B, 0xD52C,
+ 0, 0, 0x6639, 0, 0xD52D, 0x6638, 0x6637, 0,
+ 0, 0xD52E, 0xD52F, 0x663A, 0x3732, 0, 0xD530, 0,
+ 0x4122, 0x3541, 0xD531, 0, 0, 0xD532, 0x663E, 0x663B,
+ 0, 0, 0x663C, 0, 0xD533, 0, 0x663F, 0,
+ 0x6640, 0x663D, 0, 0, 0xD534, 0x3129, 0, 0xD535,
+};
+static const unsigned short utf8_to_euc_E7BE_x0213[] = {
+ 0xD525, 0, 0x6630, 0x6632, 0, 0x4D65, 0x6631, 0x6634,
+ 0x6633, 0, 0x4D53, 0xD526, 0x6635, 0xD527, 0x487E, 0xD528,
+ 0xF473, 0x7A3B, 0, 0, 0x6636, 0, 0xF476, 0x7A3C,
+ 0, 0, 0x6639, 0, 0xF477, 0x6638, 0x6637, 0,
+ 0, 0xD52E, 0xD52F, 0x663A, 0x3732, 0, 0xD530, 0,
+ 0x4122, 0x3541, 0xD531, 0, 0, 0xF478, 0x663E, 0x663B,
+ 0, 0, 0x663C, 0, 0xD533, 0, 0x663F, 0,
+ 0x6640, 0x663D, 0, 0, 0xD534, 0x3129, 0, 0x7A3D,
+};
+static const unsigned short utf8_to_euc_E7BF[] = {
+ 0xD536, 0x3227, 0, 0xD537, 0, 0x6642, 0x6643, 0,
+ 0xD538, 0, 0x6644, 0, 0x4D62, 0, 0xD539, 0xD53A,
+ 0, 0, 0x3D2C, 0, 0x6646, 0x6645, 0, 0,
+ 0, 0, 0, 0xD53B, 0, 0, 0, 0xD53C,
+ 0x3F69, 0x6647, 0, 0xD53D, 0, 0xD53E, 0x6648, 0,
+ 0xD53F, 0x6649, 0, 0x3465, 0xD540, 0, 0xD541, 0xD542,
+ 0x344D, 0, 0xD543, 0x664A, 0, 0, 0, 0,
+ 0, 0x664B, 0xD544, 0x4B5D, 0x4D63, 0xD545, 0xD546, 0xD547,
+};
+static const unsigned short utf8_to_euc_E7BF_x0213[] = {
+ 0xD536, 0x3227, 0, 0xF47A, 0, 0x6642, 0x6643, 0,
+ 0xD538, 0, 0x6644, 0, 0x4D62, 0, 0x7A3E, 0xF47B,
+ 0, 0, 0x3D2C, 0, 0x6646, 0x6645, 0, 0,
+ 0, 0, 0, 0x7A3F, 0, 0, 0, 0x7A40,
+ 0x3F69, 0x6647, 0, 0xF47C, 0, 0xF47D, 0x6648, 0,
+ 0xD53F, 0x6649, 0, 0x3465, 0x7A41, 0, 0x7A42, 0xF47E,
+ 0x344D, 0, 0xF521, 0x664A, 0, 0, 0, 0,
+ 0, 0x664B, 0x7A43, 0x4B5D, 0x4D63, 0xD545, 0xD546, 0xD547,
+};
+static const unsigned short utf8_to_euc_E880[] = {
+ 0x4D54, 0x4F37, 0, 0x394D, 0x664E, 0x3C54, 0x664D, 0xD548,
+ 0xD549, 0, 0xD54A, 0x664F, 0x3C29, 0xD54B, 0xD54C, 0xD54D,
+ 0x4251, 0xD54E, 0x6650, 0xD54F, 0xD550, 0x394C, 0xD551, 0x4C57,
+ 0x6651, 0x6652, 0, 0, 0x6653, 0xD552, 0xD553, 0xD554,
+ 0xD555, 0x6654, 0, 0, 0xD556, 0, 0xD557, 0,
+ 0x6655, 0, 0, 0, 0xD558, 0, 0xD559, 0,
+ 0xD55A, 0, 0, 0x3C2A, 0xD55B, 0xD55C, 0x4C6D, 0xD55D,
+ 0, 0xD55E, 0xD55F, 0x6657, 0xD560, 0x433F, 0xD561, 0x6656,
+};
+static const unsigned short utf8_to_euc_E880_x0213[] = {
+ 0x4D54, 0x4F37, 0xF522, 0x394D, 0x664E, 0x3C54, 0x664D, 0xD548,
+ 0xF524, 0, 0xF523, 0x664F, 0x3C29, 0xD54B, 0xF525, 0xD54D,
+ 0x4251, 0xF526, 0x6650, 0xD54F, 0x7A45, 0x394C, 0xF527, 0x4C57,
+ 0x6651, 0x6652, 0, 0, 0x6653, 0xD552, 0xD553, 0xD554,
+ 0xD555, 0x6654, 0, 0, 0xF528, 0, 0x7A46, 0,
+ 0x6655, 0, 0, 0, 0xF529, 0, 0xD559, 0,
+ 0xF52A, 0, 0, 0x3C2A, 0xD55B, 0x7A47, 0x4C6D, 0x7A48,
+ 0, 0xD55E, 0xD55F, 0x6657, 0x7A49, 0x433F, 0xD561, 0x6656,
+};
+static const unsigned short utf8_to_euc_E881[] = {
+ 0xD562, 0, 0, 0, 0xD563, 0, 0x6659, 0,
+ 0, 0, 0x6658, 0, 0, 0, 0, 0,
+ 0, 0, 0x665A, 0, 0, 0, 0x403B, 0,
+ 0x665B, 0, 0x665C, 0, 0, 0, 0x4A39, 0x665D,
+ 0xD564, 0x416F, 0x665E, 0, 0xD565, 0, 0xD566, 0,
+ 0x665F, 0, 0, 0, 0, 0xD567, 0, 0x4E7E,
+ 0x6662, 0xD568, 0x6661, 0x6660, 0x4430, 0xD569, 0x6663, 0x3F26,
+ 0, 0x6664, 0, 0, 0, 0x6665, 0x4F38, 0x6666,
+};
+static const unsigned short utf8_to_euc_E881_x0213[] = {
+ 0xD562, 0, 0, 0xF52B, 0xD563, 0, 0x6659, 0,
+ 0, 0, 0x6658, 0, 0, 0, 0, 0,
+ 0, 0, 0x665A, 0, 0, 0, 0x403B, 0,
+ 0x665B, 0, 0x665C, 0, 0, 0, 0x4A39, 0x665D,
+ 0xD564, 0x416F, 0x665E, 0, 0xD565, 0, 0xF52C, 0,
+ 0x665F, 0, 0, 0, 0, 0xD567, 0, 0x4E7E,
+ 0x6662, 0xF52D, 0x6661, 0x6660, 0x4430, 0xF52E, 0x6663, 0x3F26,
+ 0, 0x6664, 0, 0xF52F, 0, 0x6665, 0x4F38, 0x6666,
+};
+static const unsigned short utf8_to_euc_E882[] = {
+ 0, 0xD56A, 0, 0, 0x6667, 0x6669, 0x6668, 0x4825,
+ 0xD56B, 0x4679, 0, 0x4F3E, 0x4829, 0, 0xD56C, 0,
+ 0, 0, 0, 0x666B, 0, 0, 0x3E53, 0,
+ 0x492A, 0, 0x666C, 0x666A, 0xD56D, 0x344E, 0xD56E, 0,
+ 0, 0x3854, 0x3B68, 0, 0, 0x486E, 0xD56F, 0xD570,
+ 0, 0x382A, 0x4B43, 0xD571, 0x666F, 0x666D, 0, 0x394E,
+ 0, 0x394F, 0x3069, 0, 0x3A68, 0, 0, 0,
+ 0xD572, 0xD573, 0x4759, 0, 0, 0, 0, 0,
+};
+static const unsigned short utf8_to_euc_E882_x0213[] = {
+ 0, 0xD56A, 0, 0, 0x6667, 0x6669, 0x6668, 0x4825,
+ 0xD56B, 0x4679, 0, 0x4F3E, 0x4829, 0, 0xD56C, 0,
+ 0, 0, 0, 0x666B, 0, 0, 0x3E53, 0,
+ 0x492A, 0xF530, 0x666C, 0x666A, 0xF531, 0x344E, 0xD56E, 0,
+ 0, 0x3854, 0x3B68, 0, 0xF532, 0x486E, 0xD56F, 0xF533,
+ 0, 0x382A, 0x4B43, 0xD571, 0x666F, 0x666D, 0, 0x394E,
+ 0, 0x394F, 0x3069, 0, 0x3A68, 0, 0, 0,
+ 0xF534, 0xD573, 0x4759, 0, 0, 0, 0, 0,
+};
+static const unsigned short utf8_to_euc_E883[] = {
+ 0, 0, 0, 0x305F, 0x6674, 0, 0x4340, 0,
+ 0xD574, 0, 0, 0, 0x4758, 0xD575, 0x425B, 0xD576,
+ 0, 0, 0xD577, 0, 0xD578, 0xD579, 0x6676, 0xD57A,
+ 0xD57B, 0x6672, 0x6675, 0x6670, 0, 0x6673, 0x4B26, 0,
+ 0xD57C, 0x3855, 0, 0, 0x307D, 0x6671, 0, 0,
+ 0, 0, 0, 0, 0, 0xD57D, 0xD57E, 0x6678,
+ 0xD621, 0x6679, 0xD622, 0xD623, 0x4639, 0, 0xD624, 0,
+ 0x363B, 0xD625, 0xD626, 0, 0x6726, 0x473D, 0xD627, 0,
+};
+static const unsigned short utf8_to_euc_E883_x0213[] = {
+ 0, 0, 0, 0x305F, 0x6674, 0xF536, 0x4340, 0,
+ 0xD574, 0, 0x7A4A, 0, 0x4758, 0xD575, 0x425B, 0xD576,
+ 0, 0, 0xD577, 0, 0xD578, 0xF537, 0x6676, 0x7A4B,
+ 0xF538, 0x6672, 0x6675, 0x6670, 0, 0x6673, 0x4B26, 0,
+ 0x7A4C, 0x3855, 0, 0, 0x307D, 0x6671, 0xF539, 0,
+ 0, 0, 0, 0, 0, 0xD57D, 0xD57E, 0x6678,
+ 0xD621, 0x6679, 0xD622, 0x7A4D, 0x4639, 0xF53C, 0xD624, 0,
+ 0x363B, 0xD625, 0xD626, 0xF53D, 0x6726, 0x473D, 0xD627, 0,
+};
+static const unsigned short utf8_to_euc_E884[] = {
+ 0, 0, 0x3B69, 0xD628, 0, 0x363C, 0x4048, 0x4F46,
+ 0x4C2E, 0x6677, 0x4054, 0xD629, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0xD62A, 0xD62B,
+ 0xD62C, 0, 0x3553, 0x667A, 0xD62D, 0, 0xD62E, 0,
+ 0xD62F, 0, 0, 0x667C, 0xD630, 0, 0, 0xD631,
+ 0, 0x667B, 0, 0, 0xD632, 0, 0, 0x667D,
+ 0xD633, 0x4326, 0, 0x473E, 0, 0xD634, 0, 0,
+ 0, 0x4431, 0xD635, 0, 0xD636, 0, 0x6723, 0,
+};
+static const unsigned short utf8_to_euc_E884_x0213[] = {
+ 0, 0, 0x3B69, 0xD628, 0, 0x363C, 0x4048, 0x4F46,
+ 0x4C2E, 0x6677, 0x4054, 0xD629, 0, 0xF53B, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0xF540, 0xD62B,
+ 0x7A4E, 0, 0x3553, 0x667A, 0xD62D, 0, 0xF541, 0,
+ 0xD62F, 0, 0, 0x667C, 0xF543, 0, 0, 0xF544,
+ 0, 0x667B, 0, 0, 0xF545, 0, 0, 0x667D,
+ 0xD633, 0x4326, 0, 0x473E, 0, 0xF53F, 0, 0,
+ 0, 0x4431, 0xD635, 0, 0xD636, 0xF547, 0x6723, 0,
+};
+static const unsigned short utf8_to_euc_E885[] = {
+ 0, 0, 0, 0, 0, 0xD637, 0x6722, 0xD638,
+ 0, 0, 0xD639, 0x667E, 0xD63A, 0, 0x3F55, 0,
+ 0x4965, 0x6725, 0xD63B, 0x6724, 0x3950, 0x4F53, 0, 0xD63C,
+ 0, 0, 0, 0, 0, 0, 0, 0x6735,
+ 0xD63D, 0xD63E, 0, 0, 0, 0x6729, 0x672A, 0xD63F,
+ 0xD640, 0xD641, 0, 0x3C70, 0, 0xD642, 0x6728, 0xD643,
+ 0x3978, 0x6727, 0, 0, 0x672B, 0, 0, 0xD644,
+ 0x4432, 0x4A22, 0x4123, 0, 0, 0, 0, 0x425C,
+};
+static const unsigned short utf8_to_euc_E885_x0213[] = {
+ 0, 0, 0, 0, 0, 0xD637, 0x6722, 0xD638,
+ 0, 0, 0x7A4F, 0x667E, 0xD63A, 0, 0x3F55, 0,
+ 0x4965, 0x6725, 0xD63B, 0x6724, 0x3950, 0x4F53, 0, 0xD63C,
+ 0, 0, 0, 0, 0, 0, 0, 0x6735,
+ 0x7A50, 0xD63E, 0, 0, 0, 0x6729, 0x672A, 0x7A51,
+ 0x7A52, 0xF549, 0, 0x3C70, 0, 0x7A53, 0x6728, 0xD643,
+ 0x3978, 0x6727, 0, 0, 0x672B, 0, 0, 0xD644,
+ 0x4432, 0x4A22, 0x4123, 0, 0, 0, 0, 0x425C,
+};
+static const unsigned short utf8_to_euc_E886[] = {
+ 0x672F, 0xD645, 0x6730, 0x672C, 0xD647, 0xD648, 0xD649, 0,
+ 0x672D, 0, 0x672E, 0xD64A, 0, 0, 0xD64B, 0x3951,
+ 0xD646, 0, 0, 0x6736, 0, 0x6732, 0xD64C, 0,
+ 0xD64D, 0, 0x4966, 0xD64E, 0x4B6C, 0x4928, 0xD64F, 0,
+ 0x6731, 0, 0xD650, 0x6734, 0x6733, 0, 0, 0,
+ 0x4B44, 0x6737, 0, 0, 0, 0, 0xD651, 0,
+ 0x6738, 0, 0xD652, 0x4137, 0xD653, 0x6739, 0, 0,
+ 0x673B, 0, 0x673F, 0xD654, 0, 0x673C, 0x673A, 0x473F,
+};
+static const unsigned short utf8_to_euc_E886_x0213[] = {
+ 0x672F, 0xF54B, 0x6730, 0x672C, 0xF54D, 0xF54E, 0xD649, 0,
+ 0x672D, 0, 0x672E, 0xD64A, 0, 0, 0xD64B, 0x3951,
+ 0xD646, 0, 0, 0x6736, 0, 0x6732, 0xD64C, 0,
+ 0xF550, 0, 0x4966, 0xD64E, 0x4B6C, 0x4928, 0xD64F, 0,
+ 0x6731, 0, 0xD650, 0x6734, 0x6733, 0, 0, 0,
+ 0x4B44, 0x6737, 0, 0, 0, 0, 0xD651, 0,
+ 0x6738, 0, 0xF551, 0x4137, 0xD653, 0x6739, 0, 0,
+ 0x673B, 0, 0x673F, 0x7A54, 0, 0x673C, 0x673A, 0x473F,
+};
+static const unsigned short utf8_to_euc_E887[] = {
+ 0x673D, 0, 0x673E, 0xD656, 0, 0xD657, 0x3232, 0,
+ 0x6745, 0x6740, 0xD658, 0xD655, 0, 0x6741, 0xD659, 0xD65A,
+ 0, 0x6742, 0, 0x4221, 0, 0xD65B, 0, 0xD65C,
+ 0x6744, 0x6743, 0x6746, 0xD65D, 0, 0xD65E, 0xD65F, 0x6747,
+ 0x6748, 0xD660, 0, 0x3F43, 0xD661, 0x3269, 0, 0x6749,
+ 0x4E57, 0, 0x3C2B, 0xD662, 0xD663, 0x3D2D, 0, 0,
+ 0xD664, 0xD665, 0xD666, 0x3B6A, 0x4357, 0xD667, 0xD668, 0,
+ 0xD669, 0xD66A, 0x674A, 0x674B, 0x3131, 0xD66B, 0x674C, 0xD66C,
+};
+static const unsigned short utf8_to_euc_E887_x0213[] = {
+ 0x673D, 0xF552, 0x673E, 0xF553, 0, 0xD657, 0x3232, 0,
+ 0x6745, 0x6740, 0x7A55, 0xD655, 0, 0x6741, 0xD659, 0x7A56,
+ 0, 0x6742, 0, 0x4221, 0, 0xD65B, 0xF554, 0x7A57,
+ 0x6744, 0x6743, 0x6746, 0xF555, 0, 0xD65E, 0xD65F, 0x6747,
+ 0x6748, 0xD660, 0, 0x3F43, 0xF557, 0x3269, 0, 0x6749,
+ 0x4E57, 0, 0x3C2B, 0xD662, 0xF559, 0x3D2D, 0, 0,
+ 0xD664, 0xD665, 0xD666, 0x3B6A, 0x4357, 0xD667, 0xD668, 0,
+ 0xD669, 0xD66A, 0x674A, 0x674B, 0x3131, 0xF55B, 0x674C, 0xF55C,
+};
+static const unsigned short utf8_to_euc_E888[] = {
+ 0xD66D, 0x674D, 0x674E, 0xD66E, 0, 0x674F, 0, 0x6750,
+ 0x363D, 0x5A2A, 0x6751, 0, 0x4065, 0x6752, 0x3C4B, 0xD66F,
+ 0x6753, 0, 0x5030, 0xD670, 0xD671, 0, 0x6754, 0x4A5E,
+ 0x345C, 0xD672, 0xD673, 0x4124, 0x3D58, 0xD674, 0x4971, 0x3D2E,
+ 0, 0xD675, 0xD676, 0, 0, 0, 0, 0,
+ 0xD677, 0x6755, 0x3952, 0x6756, 0x484C, 0, 0x6764, 0,
+ 0, 0, 0xD678, 0x6758, 0xD679, 0x4249, 0x4775, 0x383F,
+ 0x6757, 0x4125, 0xD67A, 0, 0, 0, 0, 0,
+};
+static const unsigned short utf8_to_euc_E888_x0213[] = {
+ 0xD66D, 0x674D, 0x674E, 0xD66E, 0xF55E, 0x674F, 0, 0x6750,
+ 0x363D, 0x5A2A, 0x6751, 0, 0x4065, 0x6752, 0x3C4B, 0xD66F,
+ 0x6753, 0, 0x5030, 0xD670, 0xD671, 0, 0x6754, 0x4A5E,
+ 0x345C, 0xF560, 0xD673, 0x4124, 0x3D58, 0xD674, 0x4971, 0x3D2E,
+ 0, 0xF561, 0xF562, 0, 0, 0, 0, 0,
+ 0xD677, 0x6755, 0x3952, 0x6756, 0x484C, 0, 0x6764, 0,
+ 0, 0, 0xF564, 0x6758, 0xF565, 0x4249, 0x4775, 0x383F,
+ 0x6757, 0x4125, 0xD67A, 0, 0xF566, 0, 0, 0,
+};
+static const unsigned short utf8_to_euc_E889[] = {
+ 0x6759, 0, 0, 0xD67B, 0xD67C, 0xD67D, 0xD67E, 0x447A,
+ 0, 0, 0, 0xD721, 0, 0, 0xD722, 0xD723,
+ 0, 0xD724, 0, 0, 0, 0, 0xD725, 0,
+ 0x675B, 0x675A, 0x675D, 0, 0xD726, 0x675C, 0, 0x675E,
+ 0xD727, 0, 0x6760, 0xD728, 0x675F, 0, 0x344F, 0xD729,
+ 0x6761, 0, 0x6762, 0x6763, 0, 0xD72A, 0x3A31, 0x4E49,
+ 0, 0x6765, 0x3F27, 0, 0xD72B, 0, 0x3170, 0x6766,
+ 0x6767, 0, 0, 0xD72C, 0, 0xD72D, 0x6768, 0xD72E,
+};
+static const unsigned short utf8_to_euc_E889_x0213[] = {
+ 0x6759, 0, 0, 0xD67B, 0xD67C, 0xF569, 0xF567, 0x447A,
+ 0, 0xF568, 0, 0xF56B, 0, 0, 0xD722, 0xF56D,
+ 0, 0xD724, 0, 0, 0, 0, 0xD725, 0xF56F,
+ 0x675B, 0x675A, 0x675D, 0, 0xF571, 0x675C, 0, 0x675E,
+ 0x7A5B, 0, 0x6760, 0xF572, 0x675F, 0, 0x344F, 0xD729,
+ 0x6761, 0, 0x6762, 0x6763, 0, 0xD72A, 0x3A31, 0x4E49,
+ 0, 0x6765, 0x3F27, 0, 0x7A5C, 0, 0x3170, 0x6766,
+ 0x6767, 0xF576, 0, 0xD72C, 0, 0xF578, 0x6768, 0xF579,
+};
+static const unsigned short utf8_to_euc_E88A[] = {
+ 0xD72F, 0xD730, 0, 0xD731, 0xD732, 0, 0, 0xD733,
+ 0, 0xD734, 0xD735, 0x3072, 0, 0x6769, 0xD736, 0,
+ 0, 0xD737, 0x676A, 0, 0xD738, 0, 0xD739, 0,
+ 0xD73A, 0x4967, 0xD73B, 0xD73C, 0, 0x3C47, 0, 0x676C,
+ 0xD73D, 0xD73E, 0, 0xD73F, 0xD740, 0x3329, 0x3032, 0xD741,
+ 0xD742, 0xD743, 0xD744, 0x676B, 0x676E, 0x474E, 0xD745, 0x3F44,
+ 0xD746, 0x3256, 0xD747, 0x4B27, 0xD748, 0, 0, 0xD749,
+ 0x375D, 0x365C, 0xD74A, 0x676D, 0xD74B, 0x326A, 0xD74C, 0xD74D,
+};
+static const unsigned short utf8_to_euc_E88A_x0213[] = {
+ 0xD72F, 0xD730, 0, 0xF57A, 0xD732, 0, 0, 0xD733,
+ 0, 0xD734, 0xF57B, 0x3072, 0, 0x6769, 0x7A5E, 0,
+ 0, 0xD737, 0x676A, 0xF57C, 0xD738, 0, 0xD739, 0,
+ 0xD73A, 0x4967, 0xD73B, 0xD73C, 0, 0x3C47, 0, 0x676C,
+ 0xD73D, 0x7A5F, 0, 0x7A60, 0x7A61, 0x3329, 0x3032, 0xF57D,
+ 0xF57E, 0x7A62, 0xD744, 0x676B, 0x676E, 0x474E, 0x7A63, 0x3F44,
+ 0xD746, 0x3256, 0xF621, 0x4B27, 0xF622, 0, 0, 0x7A64,
+ 0x375D, 0x365C, 0xF623, 0x676D, 0xF624, 0x326A, 0x7A65, 0x7A66,
+};
+static const unsigned short utf8_to_euc_E88B[] = {
+ 0, 0, 0, 0, 0, 0x3423, 0xD74E, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0xD74F, 0x3171, 0x6772, 0x4E6A, 0x425D, 0xD750, 0, 0x4944,
+ 0, 0x677E, 0xD751, 0x3257, 0x677C, 0, 0x677A, 0x6771,
+ 0xD752, 0x676F, 0xD753, 0x6770, 0xD754, 0x3C63, 0x366C, 0x4377,
+ 0xD755, 0, 0xD756, 0x4651, 0, 0xD757, 0, 0xD758,
+ 0, 0x3151, 0, 0x6774, 0x6773, 0, 0xD759, 0xD75A,
+ 0, 0x6779, 0x6775, 0x6778, 0, 0xD75B, 0xD75C, 0,
+};
+static const unsigned short utf8_to_euc_E88B_x0213[] = {
+ 0, 0, 0, 0, 0, 0x3423, 0x7A67, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0xD74F, 0x3171, 0x6772, 0x4E6A, 0x425D, 0x7A68, 0, 0x4944,
+ 0, 0x677E, 0xD751, 0x3257, 0x677C, 0, 0x677A, 0x6771,
+ 0xD752, 0x676F, 0xF625, 0x6770, 0xD754, 0x3C63, 0x366C, 0x4377,
+ 0xF626, 0, 0xD756, 0x4651, 0, 0xD757, 0, 0xD758,
+ 0, 0x3151, 0, 0x6774, 0x6773, 0, 0xD759, 0xF627,
+ 0, 0x6779, 0x6775, 0x6778, 0, 0x7A69, 0x7A6A, 0,
+};
+static const unsigned short utf8_to_euc_E88C[] = {
+ 0xD75D, 0xD75E, 0x4C50, 0x6777, 0x3258, 0x337D, 0x677B, 0xD75F,
+ 0xD760, 0x677D, 0xD761, 0xD762, 0, 0, 0x3754, 0,
+ 0, 0, 0, 0, 0, 0, 0x6823, 0x682C,
+ 0x682D, 0, 0, 0xD764, 0x302B, 0xD765, 0xD766, 0xD767,
+ 0, 0xD768, 0xD769, 0x6834, 0, 0, 0, 0,
+ 0x3071, 0, 0, 0x682B, 0xD76A, 0xD76B, 0xD76C, 0x682A,
+ 0xD76D, 0x6825, 0x6824, 0xD76E, 0x6822, 0x6821, 0x4363, 0xD76F,
+ 0x427B, 0x6827, 0xD770, 0, 0xD771, 0xD772, 0, 0,
+};
+static const unsigned short utf8_to_euc_E88C_x0213[] = {
+ 0x7A6B, 0x7A6C, 0x4C50, 0x6777, 0x3258, 0x337D, 0x677B, 0xF628,
+ 0xF629, 0x677D, 0xD761, 0xD762, 0xF62A, 0, 0x3754, 0,
+ 0, 0, 0, 0, 0, 0, 0x6823, 0x682C,
+ 0x682D, 0, 0, 0xF62C, 0x302B, 0xF62D, 0xD766, 0xD767,
+ 0, 0xD768, 0x7A6E, 0x6834, 0, 0, 0, 0,
+ 0x3071, 0, 0, 0x682B, 0xD76A, 0x7A6F, 0xD76C, 0x682A,
+ 0xF62E, 0x6825, 0x6824, 0xD76E, 0x6822, 0x6821, 0x4363, 0xD76F,
+ 0x427B, 0x6827, 0x7A70, 0, 0xF62F, 0xD772, 0, 0,
+};
+static const unsigned short utf8_to_euc_E88D[] = {
+ 0x6826, 0, 0xD773, 0xD774, 0xD775, 0x6829, 0, 0xD776,
+ 0, 0x4170, 0x3755, 0, 0, 0xD777, 0xD778, 0x3141,
+ 0x6828, 0xD779, 0x3953, 0xD83E, 0xD763, 0xD77A, 0xD77B, 0xD77C,
+ 0x4171, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0xF45F, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0xD77D, 0, 0, 0x683A, 0, 0x683B, 0, 0x3259,
+ 0xD77E, 0, 0, 0x322E, 0x6838, 0xD821, 0, 0xD822,
+};
+static const unsigned short utf8_to_euc_E88D_x0213[] = {
+ 0x6826, 0, 0xD773, 0x7A71, 0xF630, 0x6829, 0, 0x7A72,
+ 0, 0x4170, 0x3755, 0, 0, 0xD777, 0xD778, 0x3141,
+ 0x6828, 0x7A73, 0x3953, 0xD83E, 0xF62B, 0x7A74, 0xD77B, 0xF631,
+ 0x4171, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0x7A6D, 0xAE4A, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0xD77D, 0, 0, 0x683A, 0, 0x683B, 0, 0x3259,
+ 0xD77E, 0, 0, 0x322E, 0x6838, 0x7A75, 0, 0xF633,
+};
+static const unsigned short utf8_to_euc_E88E[] = {
+ 0xD823, 0, 0xD824, 0, 0xD825, 0x682E, 0xD826, 0x6836,
+ 0, 0x683D, 0x6837, 0, 0, 0xD827, 0x6835, 0,
+ 0, 0, 0xD828, 0x6776, 0xD829, 0xD82A, 0x6833, 0,
+ 0xD82B, 0xD82C, 0x682F, 0xD82D, 0xD82E, 0xD82F, 0x3450, 0x6831,
+ 0x683C, 0, 0x6832, 0, 0, 0, 0xD830, 0xD831,
+ 0x683E, 0xD832, 0x6830, 0x477C, 0xD833, 0xD84C, 0, 0,
+ 0, 0x4D69, 0, 0, 0, 0x6839, 0, 0,
+ 0, 0, 0, 0, 0, 0x684F, 0xD834, 0xD835,
+};
+static const unsigned short utf8_to_euc_E88E_x0213[] = {
+ 0xD823, 0, 0xD824, 0, 0xD825, 0x682E, 0x7A76, 0x6836,
+ 0, 0x683D, 0x6837, 0, 0, 0xF636, 0x6835, 0,
+ 0, 0, 0x7A77, 0x6776, 0xF637, 0xF638, 0x6833, 0,
+ 0x7A78, 0xD82C, 0x682F, 0xF639, 0xD82E, 0xF63A, 0x3450, 0x6831,
+ 0x683C, 0, 0x6832, 0, 0, 0, 0xD830, 0x7A79,
+ 0x683E, 0x7A7A, 0x6830, 0x477C, 0xD833, 0xD84C, 0, 0,
+ 0, 0x4D69, 0, 0, 0, 0x6839, 0, 0,
+ 0, 0, 0, 0, 0, 0x684F, 0xD834, 0x7A7B,
+};
+static const unsigned short utf8_to_euc_E88F[] = {
+ 0xD836, 0x6847, 0, 0, 0, 0x3F7B, 0, 0xD837,
+ 0, 0xD838, 0x3546, 0, 0x365D, 0, 0x6842, 0xD839,
+ 0xD83A, 0xD83B, 0, 0x325B, 0xD83C, 0, 0x3E54, 0,
+ 0x6845, 0, 0, 0, 0x3A5A, 0xD83D, 0, 0x4551,
+ 0x684A, 0, 0, 0, 0, 0, 0, 0,
+ 0xD83F, 0x4A6E, 0xD840, 0x6841, 0, 0, 0, 0x325A,
+ 0x3856, 0x4929, 0x684B, 0, 0x683F, 0, 0xD841, 0x6848,
+ 0xD842, 0xD843, 0, 0x6852, 0xD844, 0x6843, 0, 0,
+};
+static const unsigned short utf8_to_euc_E88F_x0213[] = {
+ 0x7A7C, 0x6847, 0, 0, 0, 0x3F7B, 0, 0x7A7D,
+ 0, 0xF63B, 0x3546, 0, 0x365D, 0, 0x6842, 0x7A7E,
+ 0xF63C, 0x7B21, 0, 0x325B, 0xF63D, 0, 0x3E54, 0,
+ 0x6845, 0, 0, 0, 0x3A5A, 0xF63E, 0, 0x4551,
+ 0x684A, 0x7B22, 0, 0, 0, 0xF63F, 0, 0,
+ 0xD83F, 0x4A6E, 0x7B23, 0x6841, 0, 0, 0, 0x325A,
+ 0x3856, 0x4929, 0x684B, 0, 0x683F, 0, 0xD841, 0x6848,
+ 0xD842, 0xF640, 0, 0x6852, 0xD844, 0x6843, 0, 0,
+};
+static const unsigned short utf8_to_euc_E890[] = {
+ 0, 0xD845, 0, 0x6844, 0x463A, 0, 0xD846, 0x6849,
+ 0, 0, 0xD847, 0x6846, 0x4B28, 0x684C, 0x3060, 0xD848,
+ 0, 0xD849, 0, 0x6840, 0, 0xD84A, 0, 0,
+ 0, 0xD84B, 0, 0, 0, 0, 0, 0,
+ 0x684E, 0, 0x684D, 0, 0, 0, 0, 0,
+ 0, 0x476B, 0x6854, 0, 0x685F, 0, 0, 0xD84D,
+ 0, 0x337E, 0, 0, 0, 0x6862, 0, 0,
+ 0x6850, 0xD84E, 0, 0, 0x6855, 0x4D6E, 0, 0,
+};
+static const unsigned short utf8_to_euc_E890_x0213[] = {
+ 0, 0x7B24, 0, 0x6844, 0x463A, 0, 0x7B25, 0x6849,
+ 0, 0, 0x7B26, 0x6846, 0x4B28, 0x684C, 0x3060, 0xF641,
+ 0, 0xF642, 0, 0x6840, 0, 0xF643, 0, 0xF645,
+ 0, 0xD84B, 0, 0, 0, 0, 0, 0,
+ 0x684E, 0, 0x684D, 0, 0, 0, 0, 0,
+ 0, 0x476B, 0x6854, 0, 0x685F, 0, 0, 0xD84D,
+ 0, 0x337E, 0, 0, 0, 0x6862, 0, 0,
+ 0x6850, 0xF646, 0, 0, 0x6855, 0x4D6E, 0, 0,
+};
+static const unsigned short utf8_to_euc_E891[] = {
+ 0, 0, 0, 0, 0, 0xD84F, 0x685E, 0xD850,
+ 0xD851, 0x4D55, 0xD852, 0, 0, 0xD853, 0x4E2A, 0xD854,
+ 0, 0xD855, 0xD856, 0, 0, 0, 0xD857, 0x4378,
+ 0xD858, 0xD859, 0xD85A, 0x336B, 0xD85B, 0, 0, 0,
+ 0xD85C, 0x4972, 0x6864, 0x4621, 0xD85D, 0xD85E, 0x3031, 0xD85F,
+ 0, 0x685D, 0xD860, 0x6859, 0x4172, 0x6853, 0x685B, 0x6860,
+ 0xD861, 0x472C, 0, 0xD862, 0xD863, 0x302A, 0xD864, 0x6858,
+ 0xD865, 0x6861, 0x4978, 0, 0xD866, 0xD867, 0, 0,
+};
+static const unsigned short utf8_to_euc_E891_x0213[] = {
+ 0, 0, 0, 0, 0, 0xD84F, 0x685E, 0xD850,
+ 0x7B28, 0x4D55, 0xF647, 0, 0, 0xD853, 0x4E2A, 0xF648,
+ 0, 0xF649, 0xF64A, 0, 0, 0, 0xD857, 0x4378,
+ 0xD858, 0xF64B, 0xF64C, 0x336B, 0xF64D, 0, 0, 0x7B29,
+ 0xD85C, 0x4972, 0x6864, 0x4621, 0xD85D, 0xF64F, 0x3031, 0xD85F,
+ 0, 0x685D, 0xD860, 0x6859, 0x4172, 0x6853, 0x685B, 0x6860,
+ 0x7B2A, 0x472C, 0, 0x7B2B, 0xD863, 0x302A, 0xF650, 0x6858,
+ 0xF651, 0x6861, 0x4978, 0, 0xF652, 0xD867, 0, 0,
+};
+static const unsigned short utf8_to_euc_E892[] = {
+ 0, 0xD868, 0x685C, 0, 0x6857, 0xD869, 0, 0,
+ 0, 0, 0, 0x3E55, 0, 0, 0, 0,
+ 0x3D2F, 0, 0xD86A, 0xD86B, 0x3C2C, 0xD86C, 0, 0,
+ 0, 0x4C58, 0, 0, 0x4947, 0, 0xD86D, 0x6867,
+ 0, 0x6870, 0, 0, 0, 0, 0xD86E, 0,
+ 0xD86F, 0xD870, 0xD871, 0, 0, 0x685A, 0, 0xD872,
+ 0, 0xD873, 0x3377, 0, 0xD874, 0, 0, 0,
+ 0x3E78, 0x6865, 0xD875, 0x686A, 0x4173, 0xD876, 0xD877, 0x6866,
+};
+static const unsigned short utf8_to_euc_E892_x0213[] = {
+ 0, 0xF653, 0x685C, 0, 0x6857, 0x7B2C, 0, 0,
+ 0, 0, 0, 0x3E55, 0, 0, 0, 0,
+ 0x3D2F, 0, 0xD86A, 0xD86B, 0x3C2C, 0xD86C, 0, 0xF656,
+ 0, 0x4C58, 0, 0, 0x4947, 0, 0x7B2D, 0x6867,
+ 0, 0x6870, 0, 0, 0, 0, 0xF657, 0,
+ 0xD86F, 0xD870, 0xD871, 0, 0, 0x685A, 0, 0x7B2E,
+ 0, 0xD873, 0x3377, 0, 0x7B2F, 0, 0, 0,
+ 0x3E78, 0x6865, 0x7B30, 0x686A, 0x4173, 0xD876, 0xF658, 0x6866,
+};
+static const unsigned short utf8_to_euc_E893[] = {
+ 0xD878, 0x686D, 0xD879, 0, 0x435F, 0, 0x686E, 0xD87A,
+ 0xD87B, 0x4D56, 0x6863, 0x3338, 0xD87C, 0x6869, 0, 0xD87D,
+ 0x686C, 0x4C2C, 0, 0xD87E, 0, 0, 0x686F, 0,
+ 0, 0x6868, 0x686B, 0, 0xD921, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0xD922,
+ 0, 0, 0xD923, 0, 0x4B29, 0, 0x4F21, 0xD924,
+ 0xD925, 0xD926, 0xD927, 0, 0x6873, 0, 0, 0xD928,
+ 0, 0, 0xD92A, 0xD92B, 0x687A, 0xD92C, 0, 0x6872,
+};
+static const unsigned short utf8_to_euc_E893_x0213[] = {
+ 0x7B31, 0x686D, 0x7B32, 0, 0x435F, 0, 0x686E, 0xD87A,
+ 0xD87B, 0x4D56, 0x6863, 0x3338, 0xD87C, 0x6869, 0xF65A, 0xF65B,
+ 0x686C, 0x4C2C, 0, 0xF65C, 0, 0, 0x686F, 0,
+ 0, 0x6868, 0x686B, 0, 0xF655, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0xF65E,
+ 0, 0, 0xF65F, 0, 0x4B29, 0, 0x4F21, 0xF660,
+ 0xF661, 0xF662, 0xD927, 0, 0x6873, 0, 0, 0xD928,
+ 0, 0, 0xF663, 0xD92B, 0x687A, 0xF664, 0, 0x6872,
+};
+static const unsigned short utf8_to_euc_E894[] = {
+ 0x3C43, 0, 0xD92D, 0xD92E, 0, 0, 0x6851, 0xD92F,
+ 0, 0, 0, 0, 0xD930, 0, 0xD931, 0,
+ 0xD932, 0x4A4E, 0, 0x4C22, 0x6879, 0x6878, 0, 0x6874,
+ 0x6875, 0, 0x3136, 0, 0xD933, 0, 0xD934, 0x6877,
+ 0, 0x6871, 0xD935, 0xD936, 0xD937, 0xD938, 0x4455, 0xD939,
+ 0, 0, 0xD93A, 0xD93B, 0x6876, 0x307E, 0, 0xD93C,
+ 0, 0, 0xD929, 0xD93D, 0xD93E, 0x4222, 0xD93F, 0,
+ 0, 0, 0, 0, 0, 0x4A43, 0, 0xD940,
+};
+static const unsigned short utf8_to_euc_E894_x0213[] = {
+ 0x3C43, 0, 0xD92D, 0xD92E, 0, 0, 0x6851, 0xD92F,
+ 0, 0, 0, 0, 0xF665, 0, 0xD931, 0,
+ 0xD932, 0x4A4E, 0, 0x4C22, 0x6879, 0x6878, 0, 0x6874,
+ 0x6875, 0, 0x3136, 0xF666, 0xD933, 0, 0x7B35, 0x6877,
+ 0, 0x6871, 0xD935, 0x7B36, 0xF667, 0xF668, 0x4455, 0xD939,
+ 0, 0, 0xD93A, 0xF669, 0x6876, 0x307E, 0, 0x7B37,
+ 0, 0, 0x7B34, 0xD93D, 0xF66A, 0x4222, 0xD93F, 0,
+ 0, 0, 0, 0, 0, 0x4A43, 0xF66F, 0xD940,
+};
+static const unsigned short utf8_to_euc_E895[] = {
+ 0x687B, 0x6921, 0, 0x4859, 0, 0, 0xD941, 0,
+ 0x687E, 0x3E56, 0x3C49, 0x6923, 0, 0, 0x363E, 0xD942,
+ 0xD943, 0xD944, 0xD945, 0xD946, 0, 0x6924, 0xD947, 0x4979,
+ 0x687D, 0xD948, 0x6856, 0, 0xD949, 0xD94A, 0xD94B, 0xD94C,
+ 0xD94D, 0xD94E, 0xD94F, 0x687C, 0xD950, 0, 0, 0,
+ 0x4F4F, 0x4622, 0x4973, 0xD951, 0, 0x692B, 0, 0xD952,
+ 0, 0, 0, 0, 0, 0, 0, 0x6931,
+ 0, 0xD953, 0xD954, 0xD955, 0, 0xD956, 0x6932, 0xD957,
+};
+static const unsigned short utf8_to_euc_E895_x0213[] = {
+ 0x687B, 0x6921, 0, 0x4859, 0, 0, 0xD941, 0,
+ 0x687E, 0x3E56, 0x3C49, 0x6923, 0, 0, 0x363E, 0xF66B,
+ 0xD943, 0xF670, 0xD945, 0xF671, 0, 0x6924, 0xD947, 0x4979,
+ 0x687D, 0x7B38, 0x6856, 0, 0xD949, 0xD94A, 0xF672, 0xD94C,
+ 0xD94D, 0xF673, 0xF674, 0x687C, 0x7B39, 0, 0, 0,
+ 0x4F4F, 0x4622, 0x4973, 0xD951, 0, 0x692B, 0, 0xF66C,
+ 0, 0, 0, 0, 0, 0, 0, 0x6931,
+ 0, 0xD953, 0x7B3C, 0xF676, 0, 0xF677, 0x6932, 0xF678,
+};
+static const unsigned short utf8_to_euc_E896[] = {
+ 0x6925, 0xD958, 0, 0, 0x4776, 0xD959, 0xD95A, 0x692F,
+ 0x6927, 0xD95B, 0x6929, 0xD95C, 0xD95D, 0, 0, 0xD95E,
+ 0x6933, 0x6928, 0, 0xD95F, 0x692C, 0, 0, 0x3172,
+ 0xD960, 0x4665, 0, 0x692D, 0x6930, 0xD961, 0, 0xD962,
+ 0xD963, 0, 0xD964, 0, 0x6926, 0xD965, 0x4126, 0xD966,
+ 0x692A, 0x3B27, 0x3F45, 0x3730, 0x4C74, 0xD974, 0x4C79, 0x3D72,
+ 0xF461, 0, 0, 0, 0xD967, 0, 0xD968, 0xD969,
+ 0xD96A, 0x6937, 0x6935, 0, 0xD96B, 0xD96C, 0xD96D, 0xD96E,
+};
+static const unsigned short utf8_to_euc_E896_x0213[] = {
+ 0x6925, 0xF679, 0, 0, 0x4776, 0xD959, 0xF67A, 0x692F,
+ 0x6927, 0xD95B, 0x6929, 0xD95C, 0x7B3D, 0, 0, 0x7B3E,
+ 0x6933, 0x6928, 0, 0xF67B, 0x692C, 0, 0, 0x3172,
+ 0xD960, 0x4665, 0, 0x692D, 0x6930, 0xF67C, 0, 0xF67D,
+ 0xD963, 0, 0x7B3F, 0, 0x6926, 0xD965, 0x4126, 0xD966,
+ 0x692A, 0x3B27, 0x3F45, 0x3730, 0x4C74, 0x7B3B, 0x4C79, 0x3D72,
+ 0x7B40, 0, 0, 0, 0xD967, 0, 0xD968, 0xF723,
+ 0xD96A, 0x6937, 0x6935, 0, 0xF724, 0xD96C, 0xD96D, 0xD96E,
+};
+static const unsigned short utf8_to_euc_E897[] = {
+ 0, 0x4F4E, 0xD96F, 0, 0, 0, 0, 0xD970,
+ 0, 0x6934, 0xD971, 0xD972, 0, 0x4D75, 0xD973, 0x6936,
+ 0x6938, 0, 0, 0, 0, 0x6939, 0, 0,
+ 0xD975, 0, 0xD976, 0, 0x693C, 0x693A, 0, 0xD977,
+ 0xD978, 0, 0, 0, 0x4623, 0x693B, 0xD979, 0,
+ 0xD97A, 0x484D, 0x692E, 0, 0, 0xD97B, 0, 0,
+ 0, 0, 0, 0xD97C, 0, 0, 0xD97D, 0x3D73,
+ 0, 0x693D, 0x6942, 0x4174, 0xD97E, 0, 0x6941, 0xDA21,
+};
+static const unsigned short utf8_to_euc_E897_x0213[] = {
+ 0, 0x4F4E, 0xD96F, 0, 0, 0, 0, 0xF725,
+ 0, 0x6934, 0xF726, 0x7B41, 0, 0x4D75, 0x7B42, 0x6936,
+ 0x6938, 0, 0, 0, 0, 0x6939, 0, 0,
+ 0xF727, 0xF728, 0xD976, 0, 0x693C, 0x693A, 0, 0xF729,
+ 0xD978, 0xF72A, 0, 0, 0x4623, 0x693B, 0xF72B, 0,
+ 0xD97A, 0x484D, 0x692E, 0, 0, 0x7B43, 0, 0,
+ 0, 0, 0, 0xD97C, 0, 0, 0xF72C, 0x3D73,
+ 0, 0x693D, 0x6942, 0x4174, 0xD97E, 0, 0x6941, 0x7B45,
+};
+static const unsigned short utf8_to_euc_E898[] = {
+ 0xDA22, 0, 0x6922, 0, 0xDA23, 0xDA24, 0x6943, 0x4149,
+ 0, 0, 0x693E, 0x6940, 0, 0xDA25, 0xDA26, 0,
+ 0xDA27, 0xDA28, 0xDA29, 0x693F, 0, 0, 0x5D31, 0x5D22,
+ 0xDA2A, 0xDA2B, 0x6945, 0xDA2C, 0, 0, 0xDA2D, 0,
+ 0, 0xDA2E, 0x6944, 0, 0, 0, 0, 0xDA2F,
+ 0, 0xDA30, 0, 0, 0, 0x4D76, 0, 0x623C,
+ 0x6946, 0, 0, 0, 0, 0, 0xDA31, 0,
+ 0xDA32, 0, 0xDA33, 0, 0xDA34, 0xDA35, 0, 0x6947,
+};
+static const unsigned short utf8_to_euc_E898_x0213[] = {
+ 0xF72D, 0, 0x6922, 0, 0x7B46, 0x7B47, 0x6943, 0x4149,
+ 0, 0, 0x693E, 0x6940, 0, 0xDA25, 0xDA26, 0,
+ 0x7B48, 0xF72E, 0x7B44, 0x693F, 0, 0, 0x5D31, 0x5D22,
+ 0x7B4A, 0xDA2B, 0x6945, 0xDA2C, 0, 0, 0xF72F, 0,
+ 0, 0xF730, 0x6944, 0, 0xF731, 0, 0, 0xF732,
+ 0, 0x7B4B, 0, 0, 0, 0x4D76, 0, 0x623C,
+ 0x6946, 0, 0, 0, 0, 0, 0xDA31, 0,
+ 0x7B4C, 0xF734, 0xDA33, 0, 0xF735, 0xDA35, 0, 0x6947,
+};
+static const unsigned short utf8_to_euc_E899[] = {
+ 0xDA36, 0xB866, 0xDA37, 0, 0, 0, 0xDA38, 0,
+ 0, 0, 0, 0, 0, 0x6948, 0x3857, 0,
+ 0x3554, 0, 0xDA39, 0xDA3A, 0x694A, 0x515D, 0xDA3B, 0xDA3C,
+ 0xDA3D, 0xDA3E, 0x3575, 0, 0x4E3A, 0xDA3F, 0x3673, 0x694B,
+ 0xDA40, 0xDA41, 0xDA42, 0xDA43, 0xDA44, 0, 0, 0x694C,
+ 0, 0xDA45, 0, 0x436E, 0xDA46, 0, 0, 0xDA47,
+ 0, 0x694D, 0, 0, 0, 0xDA48, 0xDA49, 0xDA4A,
+ 0, 0x467A, 0xDA4B, 0x303A, 0, 0, 0, 0,
+};
+static const unsigned short utf8_to_euc_E899_x0213[] = {
+ 0xF737, 0x2F68, 0xDA37, 0, 0, 0, 0xDA38, 0,
+ 0, 0, 0, 0, 0, 0x6948, 0x3857, 0,
+ 0x3554, 0, 0xDA39, 0xF739, 0x694A, 0x515D, 0xF73A, 0x7B4D,
+ 0xDA3D, 0xDA3E, 0x3575, 0x7B4E, 0x4E3A, 0xDA3F, 0x3673, 0x694B,
+ 0xDA40, 0xDA41, 0x7B50, 0xDA43, 0xDA44, 0, 0, 0x694C,
+ 0, 0xDA45, 0, 0x436E, 0x7B52, 0, 0, 0xF73B,
+ 0, 0x694D, 0, 0, 0, 0x7B53, 0xDA49, 0xF73C,
+ 0, 0x467A, 0xF73D, 0x303A, 0, 0, 0, 0,
+};
+static const unsigned short utf8_to_euc_E89A[] = {
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0xDA6D, 0, 0x3263, 0x6952, 0x6953, 0xDA4C, 0, 0,
+ 0, 0xDA4D, 0, 0x694E, 0, 0x3B3D, 0xDA4E, 0,
+ 0xDA4F, 0, 0xDA50, 0, 0xDA51, 0, 0, 0,
+ 0, 0xDA52, 0, 0x694F, 0x4742, 0, 0xDA53, 0xDA54,
+ 0xDA55, 0x6950, 0x6951, 0x695B, 0, 0xDA56, 0, 0x6955,
+ 0x6958, 0xDA57, 0, 0xDA58, 0xDA59, 0xDA5A, 0x6954, 0xDA5B,
+ 0xDA5C, 0xDA5D, 0, 0, 0, 0, 0, 0xDA5E,
+};
+static const unsigned short utf8_to_euc_E89A_x0213[] = {
+ 0, 0, 0, 0, 0, 0, 0, 0xF73E,
+ 0xDA6D, 0xF73F, 0x3263, 0x6952, 0x6953, 0xF740, 0, 0,
+ 0, 0xF741, 0, 0x694E, 0, 0x3B3D, 0xDA4E, 0,
+ 0x7B54, 0, 0xDA50, 0, 0xF742, 0xF743, 0, 0,
+ 0, 0xDA52, 0, 0x694F, 0x4742, 0, 0xDA53, 0xDA54,
+ 0xF744, 0x6950, 0x6951, 0x695B, 0, 0xDA56, 0, 0x6955,
+ 0x6958, 0xF746, 0, 0xF747, 0xDA59, 0xDA5A, 0x6954, 0xDA5B,
+ 0x7B55, 0xDA5D, 0, 0, 0, 0, 0, 0xDA5E,
+};
+static const unsigned short utf8_to_euc_E89B[] = {
+ 0xDA5F, 0xDA60, 0, 0xDA61, 0x6956, 0xDA62, 0x6957, 0x3C58,
+ 0, 0x6959, 0, 0x4341, 0, 0x3756, 0x3342, 0,
+ 0, 0xDA63, 0xDA64, 0, 0x695C, 0xDA65, 0, 0xDA66,
+ 0, 0x333F, 0xDA67, 0x6961, 0xDA68, 0, 0x695D, 0x6960,
+ 0xDA69, 0, 0, 0xDA6A, 0x483A, 0xDA6B, 0, 0xDA6C,
+ 0, 0x695E, 0, 0, 0x695F, 0x4948, 0x485A, 0x6962,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0x427D, 0x696C, 0xDA6E, 0x6968, 0xDA6F, 0xDA70, 0x326B, 0,
+};
+static const unsigned short utf8_to_euc_E89B_x0213[] = {
+ 0xDA5F, 0xF748, 0, 0xF749, 0x6956, 0xDA62, 0x6957, 0x3C58,
+ 0, 0x6959, 0, 0x4341, 0, 0x3756, 0x3342, 0,
+ 0, 0xF74A, 0xDA64, 0, 0x695C, 0xF74B, 0, 0xF74C,
+ 0, 0x333F, 0xDA67, 0x6961, 0xDA68, 0, 0x695D, 0x6960,
+ 0xDA69, 0, 0, 0xF74D, 0x483A, 0xDA6B, 0xF74E, 0xDA6C,
+ 0, 0x695E, 0, 0, 0x695F, 0x4948, 0x485A, 0x6962,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0x427D, 0x696C, 0x7B56, 0x6968, 0x7B57, 0x7B58, 0x326B, 0,
+};
+static const unsigned short utf8_to_euc_E89C[] = {
+ 0x6966, 0, 0x4B2A, 0x6967, 0xDA71, 0xDA72, 0x6964, 0xDA73,
+ 0x6965, 0x696A, 0x696D, 0xDA74, 0, 0x696B, 0xDA75, 0xDA76,
+ 0xDA77, 0x6969, 0x6963, 0xDA78, 0xDA79, 0, 0, 0,
+ 0x4358, 0xDA7A, 0x6974, 0, 0x4C2A, 0, 0xDA7B, 0xDA7C,
+ 0, 0xDA7D, 0, 0xDA7E, 0, 0x6972, 0, 0,
+ 0xDB21, 0x6973, 0, 0, 0, 0, 0xDB22, 0xDB23,
+ 0, 0xDB24, 0xDB25, 0, 0x696E, 0, 0, 0x6970,
+ 0, 0xDB26, 0xDB27, 0x6971, 0xDB28, 0xDB29, 0xDB2A, 0x696F,
+};
+static const unsigned short utf8_to_euc_E89C_x0213[] = {
+ 0x6966, 0, 0x4B2A, 0x6967, 0xDA71, 0xF750, 0x6964, 0xF751,
+ 0x6965, 0x696A, 0x696D, 0x7B59, 0, 0x696B, 0xF752, 0xDA76,
+ 0xF753, 0x6969, 0x6963, 0xF754, 0xDA79, 0, 0, 0,
+ 0x4358, 0xF755, 0x6974, 0, 0x4C2A, 0, 0xDA7B, 0xF756,
+ 0, 0xF757, 0, 0xF758, 0, 0x6972, 0, 0,
+ 0xDB21, 0x6973, 0, 0, 0, 0, 0xDB22, 0xDB23,
+ 0, 0xF759, 0xDB25, 0, 0x696E, 0, 0, 0x6970,
+ 0, 0xDB26, 0xF75A, 0x6971, 0xDB28, 0xDB29, 0xF75B, 0x696F,
+};
+static const unsigned short utf8_to_euc_E89D[] = {
+ 0xDB2B, 0, 0, 0xDB2C, 0, 0xDB2D, 0, 0,
+ 0, 0x4066, 0, 0x4F39, 0x6978, 0xDB2E, 0x6979, 0,
+ 0, 0, 0, 0x6A21, 0, 0x3F2A, 0, 0x697B,
+ 0xDB2F, 0x697E, 0, 0, 0, 0xDB30, 0, 0x6976,
+ 0x6975, 0xDB31, 0, 0x6A22, 0xDB32, 0xDB33, 0x325C, 0,
+ 0x697C, 0, 0x6A23, 0, 0, 0, 0x697D, 0xDB34,
+ 0, 0xDB35, 0xDB36, 0, 0x697A, 0, 0x4433, 0,
+ 0x6977, 0, 0, 0xDB37, 0, 0, 0, 0x4768,
+};
+static const unsigned short utf8_to_euc_E89D_x0213[] = {
+ 0xF75C, 0, 0, 0xF75D, 0, 0xDB2D, 0, 0,
+ 0, 0x4066, 0, 0x4F39, 0x6978, 0xDB2E, 0x6979, 0,
+ 0, 0xF75E, 0, 0x6A21, 0, 0x3F2A, 0, 0x697B,
+ 0xF75F, 0x697E, 0, 0, 0, 0xDB30, 0, 0x6976,
+ 0x6975, 0xDB31, 0, 0x6A22, 0xF760, 0xF761, 0x325C, 0,
+ 0x697C, 0, 0x6A23, 0, 0, 0, 0x697D, 0xDB34,
+ 0, 0x7B5A, 0xF762, 0, 0x697A, 0, 0x4433, 0,
+ 0x6977, 0, 0, 0xDB37, 0xF763, 0, 0, 0x4768,
+};
+static const unsigned short utf8_to_euc_E89E[] = {
+ 0, 0, 0x6A27, 0xDB38, 0xDB39, 0xDB3A, 0xDB3B, 0xDB3C,
+ 0xDB3D, 0xDB3E, 0, 0xDB3F, 0xDB40, 0x4D3B, 0, 0,
+ 0xDB41, 0, 0, 0xDB42, 0, 0xDB43, 0, 0xDB44,
+ 0xDB45, 0xDB46, 0, 0, 0, 0, 0xDB47, 0x6A26,
+ 0xDB48, 0, 0x6A25, 0xDB49, 0, 0, 0, 0xDB4A,
+ 0, 0, 0, 0x6A2E, 0xDB4B, 0xDB4C, 0xDB4D, 0x6A28,
+ 0, 0xDB4E, 0, 0x6A30, 0, 0xDB4F, 0, 0,
+ 0, 0, 0x4D66, 0x6A33, 0, 0x6A2A, 0xDB50, 0xDB51,
+};
+static const unsigned short utf8_to_euc_E89E_x0213[] = {
+ 0, 0, 0x6A27, 0xDB38, 0xDB39, 0xDB3A, 0xDB3B, 0x7B5B,
+ 0x7B5C, 0xF767, 0, 0xF768, 0xDB40, 0x4D3B, 0, 0,
+ 0xDB41, 0, 0, 0xF769, 0, 0xDB43, 0, 0xDB44,
+ 0xDB45, 0xDB46, 0, 0, 0, 0, 0xDB47, 0x6A26,
+ 0xF76A, 0, 0x6A25, 0xDB49, 0, 0, 0, 0xF766,
+ 0, 0, 0, 0x6A2E, 0x7B5D, 0x7B5E, 0xDB4D, 0x6A28,
+ 0, 0xDB4E, 0, 0x6A30, 0, 0x7B5F, 0, 0,
+ 0, 0, 0x4D66, 0x6A33, 0, 0x6A2A, 0xF76D, 0xDB51,
+};
+static const unsigned short utf8_to_euc_E89F[] = {
+ 0x6A2B, 0xDB52, 0, 0, 0x6A2F, 0, 0x6A32, 0x6A31,
+ 0xDB53, 0xDB54, 0xDB55, 0x6A29, 0, 0, 0xDB56, 0,
+ 0x6A2C, 0, 0x6A3D, 0, 0, 0xDB57, 0xDB58, 0,
+ 0, 0xDB59, 0xDB5A, 0, 0xDB5B, 0, 0, 0xDB5C,
+ 0x6A36, 0, 0xDB5D, 0xDB5E, 0xDB5F, 0, 0, 0,
+ 0, 0, 0xDB60, 0xDB61, 0, 0xDB62, 0, 0x6A34,
+ 0, 0xDB63, 0x6A35, 0xDB64, 0, 0, 0x6A3A, 0x6A3B,
+ 0xDB65, 0x332A, 0xDB66, 0x3542, 0, 0, 0x6A39, 0xDB67,
+};
+static const unsigned short utf8_to_euc_E89F_x0213[] = {
+ 0x6A2B, 0xF76F, 0, 0, 0x6A2F, 0, 0x6A32, 0x6A31,
+ 0xDB53, 0xDB54, 0xDB55, 0x6A29, 0, 0, 0xF770, 0,
+ 0x6A2C, 0, 0x6A3D, 0, 0, 0xDB57, 0x7B61, 0,
+ 0, 0xDB59, 0xDB5A, 0, 0xDB5B, 0, 0, 0xF772,
+ 0x6A36, 0, 0xDB5D, 0xF774, 0xDB5F, 0xF775, 0xF776, 0,
+ 0, 0, 0xF777, 0xF778, 0x7B62, 0xF779, 0, 0x6A34,
+ 0, 0xDB63, 0x6A35, 0xDB64, 0, 0xF771, 0x6A3A, 0x6A3B,
+ 0xDB65, 0x332A, 0xDB66, 0x3542, 0, 0, 0x6A39, 0xDB67,
+};
+static const unsigned short utf8_to_euc_E8A0[] = {
+ 0, 0xDB68, 0, 0xDB69, 0, 0x6A24, 0xDB6A, 0xF464,
+ 0, 0xDB6B, 0xDB6C, 0xDB6D, 0, 0x6A38, 0x6A3C, 0x6A37,
+ 0xDB6E, 0x6A3E, 0xDB70, 0xDB71, 0xDB72, 0x6A40, 0x6A3F, 0,
+ 0xDB73, 0xDB6F, 0xDB74, 0xDB75, 0xDB76, 0, 0xDB77, 0xDB78,
+ 0, 0x6A42, 0x6A41, 0x695A, 0, 0, 0, 0x6A46,
+ 0xDB79, 0, 0, 0, 0, 0xDB7A, 0xDB7B, 0,
+ 0xDB7C, 0x6A43, 0xDB7D, 0, 0, 0xDB7E, 0x6A44, 0,
+ 0, 0x6A45, 0xDC21, 0x6A47, 0xDC22, 0, 0, 0,
+};
+static const unsigned short utf8_to_euc_E8A0_x0213[] = {
+ 0, 0xF77A, 0, 0xF77B, 0, 0x6A24, 0x7B63, 0xF464,
+ 0, 0xDB6B, 0x7B64, 0xF77C, 0, 0x6A38, 0x6A3C, 0x6A37,
+ 0x7B65, 0x6A3E, 0xDB70, 0xF77D, 0x7B66, 0x6A40, 0x6A3F, 0,
+ 0xDB73, 0xDB6F, 0xDB74, 0xDB75, 0xDB76, 0, 0xDB77, 0x7B67,
+ 0, 0x6A42, 0x6A41, 0x695A, 0, 0, 0, 0x6A46,
+ 0xF77E, 0, 0, 0, 0, 0xDB7A, 0xF821, 0,
+ 0xDB7C, 0x6A43, 0xF822, 0, 0, 0xDB7E, 0x6A44, 0,
+ 0, 0x6A45, 0xDC21, 0x6A47, 0xF823, 0, 0, 0,
+};
+static const unsigned short utf8_to_euc_E8A1[] = {
+ 0x376C, 0xDC23, 0x6A49, 0xDC24, 0x6A48, 0xDC25, 0x3D30, 0,
+ 0xDC26, 0xDC27, 0xDC28, 0xDC29, 0x3954, 0x5E27, 0xDC2A, 0,
+ 0, 0xDC2B, 0x6A4A, 0x3D51, 0, 0xDC2C, 0xDC2D, 0x3339,
+ 0xDC2E, 0x6A4B, 0xDC2F, 0x3152, 0xDC30, 0x3E57, 0x6A4C, 0xDC31,
+ 0xDC32, 0x3955, 0x6A4D, 0x3061, 0xDC33, 0, 0, 0,
+ 0x493D, 0xDC34, 0, 0x6A4E, 0, 0, 0, 0,
+ 0x3F6A, 0xDC35, 0x6A55, 0, 0, 0x6A52, 0, 0x436F,
+ 0, 0xDC36, 0, 0xDC37, 0, 0x6A53, 0x6A50, 0x365E,
+};
+static const unsigned short utf8_to_euc_E8A1_x0213[] = {
+ 0x376C, 0xDC23, 0x6A49, 0xDC24, 0x6A48, 0xDC25, 0x3D30, 0,
+ 0xDC26, 0xDC27, 0xF825, 0xDC29, 0x3954, 0x5E27, 0xDC2A, 0,
+ 0, 0xDC2B, 0x6A4A, 0x3D51, 0, 0xDC2C, 0xDC2D, 0x3339,
+ 0xF826, 0x6A4B, 0xDC2F, 0x3152, 0xDC30, 0x3E57, 0x6A4C, 0xF827,
+ 0xDC32, 0x3955, 0x6A4D, 0x3061, 0xF828, 0, 0, 0,
+ 0x493D, 0xF82B, 0, 0x6A4E, 0, 0, 0, 0xF82D,
+ 0x3F6A, 0xDC35, 0x6A55, 0, 0, 0x6A52, 0, 0x436F,
+ 0, 0xDC36, 0, 0xDC37, 0, 0x6A53, 0x6A50, 0x365E,
+};
+static const unsigned short utf8_to_euc_E8A2[] = {
+ 0xDC38, 0x6A4F, 0x6A56, 0, 0, 0, 0, 0,
+ 0x3736, 0, 0, 0x425E, 0, 0x6A5C, 0, 0,
+ 0, 0, 0x6A58, 0, 0, 0, 0x4235, 0x6A57,
+ 0xDC39, 0x6A5A, 0xDC3A, 0xDC3B, 0xDC3C, 0, 0x6A51, 0xDC3D,
+ 0xDC3E, 0, 0x6A5B, 0, 0x6A5D, 0, 0, 0,
+ 0xDC3F, 0, 0xDC40, 0x486F, 0, 0, 0x6A59, 0,
+ 0x6A5E, 0x6A60, 0, 0, 0x3853, 0x6A54, 0, 0x3041,
+ 0, 0, 0xDC41, 0, 0, 0xDC42, 0xDC43, 0x6A5F,
+};
+static const unsigned short utf8_to_euc_E8A2_x0213[] = {
+ 0xDC38, 0x6A4F, 0x6A56, 0, 0, 0, 0, 0,
+ 0x3736, 0, 0, 0x425E, 0, 0x6A5C, 0, 0,
+ 0, 0, 0x6A58, 0, 0, 0, 0x4235, 0x6A57,
+ 0x7B68, 0x6A5A, 0xDC3A, 0xDC3B, 0xDC3C, 0, 0x6A51, 0xDC3D,
+ 0xF82E, 0, 0x6A5B, 0, 0x6A5D, 0, 0, 0,
+ 0xDC3F, 0, 0x7B69, 0x486F, 0, 0, 0x6A59, 0,
+ 0x6A5E, 0x6A60, 0, 0, 0x3853, 0x6A54, 0, 0x3041,
+ 0, 0, 0xDC41, 0, 0xF82F, 0xF830, 0xF831, 0x6A5F,
+};
+static const unsigned short utf8_to_euc_E8A3[] = {
+ 0xDC44, 0x3A5B, 0x4E76, 0x6A61, 0x6A62, 0x4175, 0, 0,
+ 0, 0, 0xDC45, 0xDC46, 0xDC47, 0xDC48, 0xDC49, 0x4E22,
+ 0, 0xDC4A, 0xDC4B, 0xDC4C, 0x6A63, 0x4D35, 0, 0,
+ 0x6A64, 0x6A65, 0, 0xDC4D, 0x4A64, 0x6A66, 0xDC4E, 0x3A40,
+ 0, 0x4E23, 0, 0, 0, 0, 0, 0xDC4F,
+ 0x6A6B, 0, 0, 0, 0, 0, 0, 0xDC50,
+ 0xDC51, 0xDC52, 0x6A6C, 0x3E58, 0x6A6A, 0xDC53, 0, 0xDC54,
+ 0x4D67, 0x6A67, 0, 0, 0x6A69, 0x403D, 0x3F7E, 0,
+};
+static const unsigned short utf8_to_euc_E8A3_x0213[] = {
+ 0xF832, 0x3A5B, 0x4E76, 0x6A61, 0x6A62, 0x4175, 0, 0,
+ 0, 0, 0x7B6A, 0xDC46, 0xDC47, 0xDC48, 0x7B6B, 0x4E22,
+ 0, 0xF835, 0xF833, 0xF836, 0x6A63, 0x4D35, 0, 0,
+ 0x6A64, 0x6A65, 0, 0xF837, 0x4A64, 0x6A66, 0xDC4E, 0x3A40,
+ 0, 0x4E23, 0, 0, 0, 0, 0, 0xDC4F,
+ 0x6A6B, 0, 0, 0, 0, 0, 0, 0xDC50,
+ 0xF838, 0xF839, 0x6A6C, 0x3E58, 0x6A6A, 0x7B6D, 0, 0xDC54,
+ 0x4D67, 0x6A67, 0, 0, 0x6A69, 0x403D, 0x3F7E, 0,
+};
+static const unsigned short utf8_to_euc_E8A4[] = {
+ 0, 0xDC55, 0x6A68, 0, 0x6A6D, 0, 0xDC56, 0x4A23,
+ 0, 0, 0x6A6F, 0, 0x6A6E, 0xDC57, 0xDC58, 0xDC59,
+ 0x336C, 0, 0x4B2B, 0x6A70, 0, 0xDC5A, 0xDC5B, 0,
+ 0xDC5C, 0xDC5D, 0xDC5E, 0, 0xDC5F, 0x6A7C, 0x6A72, 0,
+ 0xDC60, 0, 0, 0, 0, 0x6A73, 0xDC61, 0xDC62,
+ 0xDC63, 0, 0x6A74, 0x6A75, 0, 0, 0, 0,
+ 0xDC64, 0xDC65, 0xDC66, 0, 0, 0xDC67, 0x6A79, 0,
+ 0x6A7A, 0xDC68, 0xDC69, 0x6A78, 0, 0, 0xDC6A, 0,
+};
+static const unsigned short utf8_to_euc_E8A4_x0213[] = {
+ 0, 0xF83B, 0x6A68, 0, 0x6A6D, 0, 0xDC56, 0x4A23,
+ 0, 0, 0x6A6F, 0, 0x6A6E, 0xDC57, 0xDC58, 0xDC59,
+ 0x336C, 0, 0x4B2B, 0x6A70, 0, 0xDC5A, 0xDC5B, 0,
+ 0x7B70, 0x7B71, 0x7B72, 0, 0x7B6E, 0x6A7C, 0x6A72, 0,
+ 0xDC60, 0, 0, 0, 0, 0x6A73, 0xDC61, 0x7B73,
+ 0xDC63, 0, 0x6A74, 0x6A75, 0, 0, 0, 0,
+ 0x7B74, 0xDC65, 0x7B75, 0, 0, 0xDC67, 0x6A79, 0xF83D,
+ 0x6A7A, 0x7B76, 0xDC69, 0x6A78, 0, 0, 0xDC6A, 0,
+};
+static const unsigned short utf8_to_euc_E8A5[] = {
+ 0xDC6B, 0x6A76, 0xDC6C, 0x6A71, 0x6A77, 0xDC6D, 0xDC6E, 0,
+ 0, 0xDC6F, 0, 0, 0x6A7B, 0x7037, 0, 0xDC70,
+ 0, 0, 0xDC71, 0, 0, 0, 0x3228, 0xDC72,
+ 0, 0, 0xDC73, 0xDC74, 0xDC75, 0, 0x6A7E, 0x365F,
+ 0x6A7D, 0xDC76, 0xDC77, 0xDC78, 0x6B22, 0, 0x6B21, 0,
+ 0, 0, 0x6B24, 0xDC79, 0, 0x6B23, 0xDC7A, 0x6B25,
+ 0xDC7B, 0, 0x3D31, 0xDC7C, 0x6B26, 0xDC7D, 0, 0x6B27,
+ 0, 0, 0xDC7E, 0xDD21, 0xDD22, 0xDD23, 0x6B28, 0x403E,
+};
+static const unsigned short utf8_to_euc_E8A5_x0213[] = {
+ 0x7B77, 0x6A76, 0xF83F, 0x6A71, 0x6A77, 0xF840, 0xDC6E, 0,
+ 0, 0xF841, 0, 0, 0x6A7B, 0x7037, 0, 0xDC70,
+ 0, 0, 0xDC71, 0, 0, 0, 0x3228, 0xDC72,
+ 0, 0, 0xDC73, 0xDC74, 0xDC75, 0, 0x6A7E, 0x365F,
+ 0x6A7D, 0xDC76, 0xF844, 0xDC78, 0x6B22, 0, 0x6B21, 0,
+ 0, 0, 0x6B24, 0xDC79, 0, 0x6B23, 0xDC7A, 0x6B25,
+ 0xDC7B, 0, 0x3D31, 0xDC7C, 0x6B26, 0xDC7D, 0, 0x6B27,
+ 0, 0, 0xDC7E, 0xDD21, 0xDD22, 0xDD23, 0x6B28, 0x403E,
+};
+static const unsigned short utf8_to_euc_E8A6[] = {
+ 0, 0x4D57, 0, 0x6B29, 0, 0, 0x4A24, 0x4746,
+ 0x6B2A, 0xDD24, 0x6B2B, 0x382B, 0, 0xDD25, 0, 0x352C,
+ 0xDD26, 0, 0, 0x6B2C, 0xDD27, 0xDD28, 0x3B6B, 0x4741,
+ 0x6B2D, 0, 0x3350, 0xDD29, 0xDD2A, 0, 0, 0xDD2B,
+ 0xDD2C, 0x6B2E, 0, 0, 0, 0xDD2D, 0x6B30, 0x4D77,
+ 0, 0x6B2F, 0x3F46, 0, 0x6B31, 0, 0, 0x6B32,
+ 0xDD2E, 0, 0x6B33, 0x3451, 0xDD2F, 0xDD30, 0xDD31, 0xDD32,
+ 0, 0, 0x6B34, 0, 0xDD33, 0x6B35, 0, 0x6B36,
+};
+static const unsigned short utf8_to_euc_E8A6_x0213[] = {
+ 0xF845, 0x4D57, 0, 0x6B29, 0, 0, 0x4A24, 0x4746,
+ 0x6B2A, 0xF846, 0x6B2B, 0x382B, 0, 0xDD25, 0, 0x352C,
+ 0xF847, 0, 0, 0x6B2C, 0x7B78, 0xDD28, 0x3B6B, 0x4741,
+ 0x6B2D, 0, 0x3350, 0xDD29, 0xDD2A, 0, 0, 0xF848,
+ 0xDD2C, 0x6B2E, 0, 0, 0, 0xDD2D, 0x6B30, 0x4D77,
+ 0, 0x6B2F, 0x3F46, 0, 0x6B31, 0, 0, 0x6B32,
+ 0xF849, 0, 0x6B33, 0x3451, 0xDD2F, 0xDD30, 0xDD31, 0xF84A,
+ 0, 0, 0x6B34, 0, 0xDD33, 0x6B35, 0, 0x6B36,
+};
+static const unsigned short utf8_to_euc_E8A7[] = {
+ 0x6B37, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0x3351, 0, 0xDD34, 0xDD35, 0xDD36, 0xDD37,
+ 0xDD38, 0, 0x6B38, 0, 0x6B39, 0x6B3A, 0, 0,
+ 0, 0, 0, 0x3272, 0, 0xDD39, 0x3F28, 0x6B3B,
+ 0, 0xDD3A, 0, 0xDD3B, 0, 0xDD3C, 0, 0,
+ 0, 0xDD3D, 0, 0xDD3E, 0x6B3C, 0, 0xDD3F, 0,
+ 0x6B3D, 0xDD40, 0, 0, 0, 0xDD41, 0, 0xDD42,
+};
+static const unsigned short utf8_to_euc_E8A7_x0213[] = {
+ 0x6B37, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0x3351, 0, 0x7B7A, 0xDD35, 0xF84B, 0xDD37,
+ 0xF84C, 0, 0x6B38, 0, 0x6B39, 0x6B3A, 0, 0,
+ 0, 0, 0, 0x3272, 0, 0x7B7B, 0x3F28, 0x6B3B,
+ 0, 0xDD3A, 0, 0xF84D, 0, 0xDD3C, 0, 0,
+ 0, 0xF84F, 0, 0xF850, 0x6B3C, 0, 0x7B7C, 0,
+ 0x6B3D, 0xDD40, 0, 0, 0, 0xF851, 0, 0xF852,
+};
+static const unsigned short utf8_to_euc_E8A8[] = {
+ 0x3840, 0, 0x447B, 0x6B3E, 0xDD43, 0xDD44, 0, 0xDD45,
+ 0x3757, 0, 0x3F56, 0, 0x6B41, 0, 0x4624, 0xDD46,
+ 0x6B40, 0xDD47, 0xDD48, 0x3731, 0xDD49, 0xDD4A, 0x6B3F, 0x4277,
+ 0x352D, 0, 0, 0x6B42, 0, 0x6B43, 0xDD4B, 0x3E59,
+ 0xDD4C, 0, 0xDD4D, 0x376D, 0xDD4E, 0x6B44, 0xDD4F, 0,
+ 0, 0, 0x4B2C, 0xDD50, 0xDD51, 0x405F, 0, 0xDD52,
+ 0, 0x3576, 0, 0x4C75, 0x414A, 0xDD53, 0x6B45, 0xDD54,
+ 0, 0, 0x3F47, 0x4370, 0x3E5A, 0xDD55, 0xDD56, 0,
+};
+static const unsigned short utf8_to_euc_E8A8_x0213[] = {
+ 0x3840, 0, 0x447B, 0x6B3E, 0xDD43, 0xDD44, 0, 0xDD45,
+ 0x3757, 0, 0x3F56, 0, 0x6B41, 0, 0x4624, 0xDD46,
+ 0x6B40, 0xF854, 0x7B7D, 0x3731, 0xF855, 0x7B7E, 0x6B3F, 0x4277,
+ 0x352D, 0, 0, 0x6B42, 0, 0x6B43, 0xDD4B, 0x3E59,
+ 0xDD4C, 0xF857, 0x7C21, 0x376D, 0xDD4E, 0x6B44, 0xDD4F, 0,
+ 0, 0, 0x4B2C, 0xDD50, 0xDD51, 0x405F, 0, 0xDD52,
+ 0, 0x3576, 0, 0x4C75, 0x414A, 0xF858, 0x6B45, 0x7C22,
+ 0, 0, 0x3F47, 0x4370, 0x3E5A, 0xDD55, 0xF859, 0,
+};
+static const unsigned short utf8_to_euc_E8A9[] = {
+ 0xDD57, 0x6B46, 0, 0xDD58, 0, 0xDD59, 0x6B49, 0xDD5A,
+ 0x6B4A, 0xDD5B, 0, 0, 0, 0xDD5C, 0xDD5D, 0,
+ 0x3A3E, 0x4242, 0x6B48, 0xDD5E, 0x3E5B, 0x493E, 0xDD5F, 0xDD60,
+ 0xDD61, 0, 0, 0x6B47, 0xDD62, 0xDD63, 0x3B6C, 0,
+ 0x3153, 0xDD64, 0x6B4E, 0x3758, 0, 0xDD65, 0x3B6E, 0xDD66,
+ 0, 0x3B6D, 0, 0x4F4D, 0x6B4D, 0x6B4C, 0x4127, 0,
+ 0x354D, 0x4F43, 0x333A, 0x3E5C, 0, 0xDD67, 0xDD68, 0xDD69,
+ 0, 0xDD6A, 0xDD6B, 0xDD6C, 0x6B4B, 0, 0xDD6D, 0xDD6E,
+};
+static const unsigned short utf8_to_euc_E8A9_x0213[] = {
+ 0xDD57, 0x6B46, 0, 0xDD58, 0, 0xF85A, 0x6B49, 0x7C23,
+ 0x6B4A, 0xDD5B, 0, 0, 0, 0xF85B, 0x7C24, 0,
+ 0x3A3E, 0x4242, 0x6B48, 0xDD5E, 0x3E5B, 0x493E, 0xDD5F, 0xDD60,
+ 0xF85C, 0, 0, 0x6B47, 0xDD62, 0x7C25, 0x3B6C, 0,
+ 0x3153, 0x7C26, 0x6B4E, 0x3758, 0, 0xDD65, 0x3B6E, 0xDD66,
+ 0, 0x3B6D, 0, 0x4F4D, 0x6B4D, 0x6B4C, 0x4127, 0,
+ 0x354D, 0x4F43, 0x333A, 0x3E5C, 0, 0x7C27, 0xDD68, 0xDD69,
+ 0, 0x7C28, 0xDD6B, 0xDD6C, 0x6B4B, 0, 0xDD6D, 0xDD6E,
+};
+static const unsigned short utf8_to_euc_E8AA[] = {
+ 0xDD6F, 0, 0x6B50, 0xDD70, 0x6B51, 0x6B4F, 0xDD71, 0x3858,
+ 0, 0x4D40, 0, 0xDD72, 0x3B6F, 0x4727, 0, 0xDD73,
+ 0xDD74, 0x6B54, 0xDD75, 0x4040, 0, 0x4342, 0xDD76, 0xDD77,
+ 0x4D36, 0xDD78, 0x6B57, 0, 0, 0, 0x386C, 0xDD79,
+ 0x403F, 0x6B53, 0, 0x6B58, 0x386D, 0x6B55, 0x6B56, 0xDD7A,
+ 0x6B52, 0xDD7B, 0, 0, 0x4062, 0x4649, 0xDD7C, 0xDD7D,
+ 0x432F, 0, 0x325D, 0xDD7E, 0, 0, 0xDE21, 0xDE22,
+ 0, 0x4870, 0, 0xDE23, 0x3543, 0, 0xDE24, 0x4434,
+};
+static const unsigned short utf8_to_euc_E8AA_x0213[] = {
+ 0xDD6F, 0, 0x6B50, 0xDD70, 0x6B51, 0x6B4F, 0xDD71, 0x3858,
+ 0, 0x4D40, 0, 0xDD72, 0x3B6F, 0x4727, 0, 0xDD73,
+ 0xF85E, 0x6B54, 0xDD75, 0x4040, 0, 0x4342, 0xDD76, 0xDD77,
+ 0x4D36, 0xDD78, 0x6B57, 0, 0, 0, 0x386C, 0xDD79,
+ 0x403F, 0x6B53, 0, 0x6B58, 0x386D, 0x6B55, 0x6B56, 0x7C29,
+ 0x6B52, 0xDD7B, 0, 0, 0x4062, 0x4649, 0xF85D, 0xDD7D,
+ 0x432F, 0, 0x325D, 0xDD7E, 0, 0, 0xDE21, 0xF85F,
+ 0, 0x4870, 0, 0xDE23, 0x3543, 0, 0xF860, 0x4434,
+};
+static const unsigned short utf8_to_euc_E8AB[] = {
+ 0, 0, 0x6B5B, 0xDE25, 0x6B59, 0, 0xDE26, 0x434C,
+ 0xDE27, 0xDE28, 0xDE29, 0x4041, 0x3452, 0x6B5A, 0, 0x3F5B,
+ 0, 0xDE2A, 0x4E4A, 0xDE2B, 0xDE2C, 0xDE2D, 0x4F40, 0xDE2E,
+ 0, 0, 0x6B5C, 0x6B67, 0x4435, 0xDE2F, 0x6B66, 0xDE30,
+ 0x6B63, 0x6B6B, 0x6B64, 0, 0x6B60, 0, 0x447C, 0x6B5F,
+ 0, 0, 0, 0x6B5D, 0xDE31, 0x4D21, 0x3B70, 0,
+ 0xDE32, 0x6B61, 0, 0x6B5E, 0xDE33, 0xDE34, 0xDE35, 0x6B65,
+ 0x3D74, 0, 0x3841, 0, 0xDE36, 0, 0x427A, 0xDE37,
+};
+static const unsigned short utf8_to_euc_E8AB_x0213[] = {
+ 0, 0, 0x6B5B, 0xDE25, 0x6B59, 0, 0xDE26, 0x434C,
+ 0xDE27, 0xDE28, 0xDE29, 0x4041, 0x3452, 0x6B5A, 0, 0x3F5B,
+ 0x7C2A, 0xDE2A, 0x4E4A, 0xDE2B, 0xDE2C, 0xDE2D, 0x4F40, 0xF861,
+ 0, 0, 0x6B5C, 0x6B67, 0x4435, 0xDE2F, 0x6B66, 0x7C2B,
+ 0x6B63, 0x6B6B, 0x6B64, 0, 0x6B60, 0, 0x447C, 0x6B5F,
+ 0, 0, 0, 0x6B5D, 0xDE31, 0x4D21, 0x3B70, 0,
+ 0xDE32, 0x6B61, 0, 0x6B5E, 0x7C2C, 0xDE34, 0x7C2D, 0x6B65,
+ 0x3D74, 0, 0x3841, 0, 0xF862, 0, 0x427A, 0xDE37,
+};
+static const unsigned short utf8_to_euc_E8AC[] = {
+ 0x4B45, 0x315A, 0x3062, 0, 0x4625, 0xDE38, 0xDE39, 0x6B69,
+ 0, 0, 0xDE3F, 0xDE3A, 0x6B68, 0, 0x4666, 0,
+ 0x6B6D, 0xDE3B, 0, 0, 0x6B62, 0, 0x6B6C, 0x6B6E,
+ 0, 0x382C, 0x6B6A, 0x3956, 0xDE3C, 0x3C55, 0xDE3D, 0xDE3E,
+ 0x6B6F, 0x4D58, 0, 0, 0, 0, 0x6B72, 0,
+ 0x6B75, 0, 0, 0x6B73, 0x4935, 0xDE40, 0, 0,
+ 0xDE41, 0, 0, 0x6B70, 0, 0, 0, 0xDE42,
+ 0, 0x3660, 0, 0, 0xDE43, 0, 0x6B74, 0,
+};
+static const unsigned short utf8_to_euc_E8AC_x0213[] = {
+ 0x4B45, 0x315A, 0x3062, 0, 0x4625, 0xF865, 0xDE39, 0x6B69,
+ 0, 0, 0xF864, 0xDE3A, 0x6B68, 0xF866, 0x4666, 0,
+ 0x6B6D, 0xDE3B, 0, 0, 0x6B62, 0, 0x6B6C, 0x6B6E,
+ 0, 0x382C, 0x6B6A, 0x3956, 0xF867, 0x3C55, 0xDE3D, 0xF868,
+ 0x6B6F, 0x4D58, 0, 0, 0, 0, 0x6B72, 0,
+ 0x6B75, 0, 0, 0x6B73, 0x4935, 0xF869, 0, 0,
+ 0xDE41, 0, 0, 0x6B70, 0, 0, 0, 0xDE42,
+ 0, 0x3660, 0, 0, 0xDE43, 0, 0x6B74, 0,
+};
+static const unsigned short utf8_to_euc_E8AD[] = {
+ 0, 0x6B76, 0xDE44, 0xDE45, 0xDE46, 0xDE47, 0xDE48, 0,
+ 0xDE49, 0x6B7A, 0, 0, 0x6B77, 0xDE4E, 0x6B79, 0x6B78,
+ 0, 0, 0xDE4A, 0xDE4B, 0xDE4C, 0, 0x6B7B, 0,
+ 0x3C31, 0xDE4D, 0x6B7D, 0x6B7C, 0x4968, 0, 0xDE4F, 0x6C21,
+ 0, 0, 0, 0xDE50, 0, 0, 0x3759, 0,
+ 0, 0, 0, 0x6B7E, 0x6C22, 0xDE51, 0, 0x6C23,
+ 0x3544, 0x6641, 0x3E79, 0, 0x6C24, 0, 0xDE52, 0x386E,
+ 0xDE53, 0xDE54, 0, 0, 0xDE55, 0x6C25, 0xDE56, 0xF466,
+};
+static const unsigned short utf8_to_euc_E8AD_x0213[] = {
+ 0, 0x6B76, 0xDE44, 0xF86A, 0xDE46, 0xDE47, 0x7C31, 0,
+ 0xDE49, 0x6B7A, 0, 0, 0x6B77, 0xDE4E, 0x6B79, 0x6B78,
+ 0, 0xF86C, 0xDE4A, 0xDE4B, 0x7C32, 0, 0x6B7B, 0,
+ 0x3C31, 0x7C33, 0x6B7D, 0x6B7C, 0x4968, 0, 0xF86D, 0x6C21,
+ 0, 0, 0, 0xDE50, 0, 0, 0x3759, 0,
+ 0, 0x7C34, 0, 0x6B7E, 0x6C22, 0xDE51, 0, 0x6C23,
+ 0x3544, 0x6641, 0x3E79, 0, 0x6C24, 0, 0xF86E, 0x386E,
+ 0xDE53, 0xDE54, 0, 0, 0xDE55, 0x6C25, 0xDE56, 0xF86F,
+};
+static const unsigned short utf8_to_euc_E8AE[] = {
+ 0x6C26, 0xDE57, 0, 0x3B3E, 0xDE58, 0xDE59, 0, 0,
+ 0, 0, 0x5A4E, 0xDE5A, 0x6C27, 0xDE5B, 0x6C28, 0xDE5C,
+ 0x3D32, 0, 0x6C29, 0x6C2A, 0xDE5D, 0xDE5E, 0x6C2B, 0,
+ 0, 0x6C2C, 0x6C2D, 0, 0xDE5F, 0, 0xDE60, 0xDE61,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+};
+static const unsigned short utf8_to_euc_E8AE_x0213[] = {
+ 0x6C26, 0xF870, 0, 0x3B3E, 0xDE58, 0xDE59, 0, 0,
+ 0, 0, 0x5A4E, 0xF871, 0x6C27, 0xDE5B, 0x6C28, 0xDE5C,
+ 0x3D32, 0, 0x6C29, 0x6C2A, 0xF872, 0xF873, 0x6C2B, 0,
+ 0, 0x6C2C, 0x6C2D, 0, 0xF874, 0x7C35, 0xF875, 0xDE61,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+};
+static const unsigned short utf8_to_euc_E8B0[] = {
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0x432B,
+ 0xDE62, 0xDE63, 0x6C2E, 0, 0, 0xDE64, 0xDE65, 0x6C30,
+};
+static const unsigned short utf8_to_euc_E8B0_x0213[] = {
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0x432B,
+ 0xDE62, 0xF876, 0x6C2E, 0, 0, 0xF878, 0xDE65, 0x6C30,
+};
+static const unsigned short utf8_to_euc_E8B1[] = {
+ 0, 0x6C2F, 0, 0, 0, 0xDE66, 0x4626, 0xDE67,
+ 0x6C31, 0xDE68, 0x4B2D, 0xDE69, 0x6C32, 0, 0x6C33, 0xDE6A,
+ 0x6C34, 0xDE6B, 0, 0xDE6C, 0xDE6D, 0x6C35, 0, 0xDE6E,
+ 0xDE6F, 0xDE72, 0x465A, 0xDE70, 0, 0xDE71, 0, 0,
+ 0, 0x3E5D, 0x6C36, 0xDE73, 0xDE74, 0, 0xDE75, 0,
+ 0xDE76, 0xDE77, 0x396B, 0x502E, 0x6C37, 0xDE78, 0, 0,
+ 0, 0, 0, 0xDE79, 0, 0xDE7A, 0xDE7B, 0,
+ 0x6C38, 0x493F, 0x6C39, 0xDE7C, 0x6C41, 0, 0xDE7D, 0,
+};
+static const unsigned short utf8_to_euc_E8B1_x0213[] = {
+ 0, 0x6C2F, 0, 0, 0, 0xF87B, 0x4626, 0xF87C,
+ 0x6C31, 0x7C36, 0x4B2D, 0xDE69, 0x6C32, 0, 0x6C33, 0xF87D,
+ 0x6C34, 0xDE6B, 0, 0xDE6C, 0xF87E, 0x6C35, 0, 0xF921,
+ 0xDE6F, 0xDE72, 0x465A, 0xDE70, 0, 0xDE71, 0, 0,
+ 0, 0x3E5D, 0x6C36, 0xDE73, 0xDE74, 0, 0xDE75, 0,
+ 0x7C37, 0xF922, 0x396B, 0x502E, 0x6C37, 0xF923, 0, 0,
+ 0, 0, 0, 0xF924, 0, 0xDE7A, 0xDE7B, 0,
+ 0x6C38, 0x493F, 0x6C39, 0xDE7C, 0x6C41, 0, 0xDE7D, 0,
+};
+static const unsigned short utf8_to_euc_E8B2[] = {
+ 0, 0, 0x6C3A, 0, 0, 0x6C3C, 0xDE7E, 0xDF21,
+ 0, 0x6C3B, 0x6C3D, 0xDF22, 0x4B46, 0x6C3E, 0x6C3F, 0,
+ 0xDF23, 0, 0xDF24, 0xDF25, 0x6C40, 0, 0, 0,
+ 0x6C42, 0xDF26, 0, 0xDF27, 0xDF28, 0x332D, 0x4467, 0,
+ 0x4969, 0x3A62, 0x3957, 0, 0xDF29, 0, 0, 0x494F,
+ 0x325F, 0x484E, 0x6C45, 0x3453, 0x4055, 0x6C44, 0x6C49, 0x4379,
+ 0x4C63, 0, 0x6C47, 0x6C48, 0x352E, 0, 0x6C4A, 0x4763,
+ 0x425F, 0xDF2A, 0xDF2B, 0x4871, 0x453D, 0x6C46, 0, 0x4B47,
+};
+static const unsigned short utf8_to_euc_E8B2_x0213[] = {
+ 0, 0, 0x6C3A, 0, 0, 0x6C3C, 0xDE7E, 0xDF21,
+ 0, 0x6C3B, 0x6C3D, 0xDF22, 0x4B46, 0x6C3E, 0x6C3F, 0,
+ 0xDF23, 0, 0xF927, 0xF926, 0x6C40, 0, 0, 0,
+ 0x6C42, 0xF928, 0, 0xF92A, 0xDF28, 0x332D, 0x4467, 0,
+ 0x4969, 0x3A62, 0x3957, 0, 0xF92B, 0, 0, 0x494F,
+ 0x325F, 0x484E, 0x6C45, 0x3453, 0x4055, 0x6C44, 0x6C49, 0x4379,
+ 0x4C63, 0, 0x6C47, 0x6C48, 0x352E, 0, 0x6C4A, 0x4763,
+ 0x425F, 0xDF2A, 0xDF2B, 0x4871, 0x453D, 0x6C46, 0, 0x4B47,
+};
+static const unsigned short utf8_to_euc_E8B3[] = {
+ 0x326C, 0x6C4C, 0x4F28, 0x4442, 0x4F45, 0xDF2C, 0xDF2D, 0x3B71,
+ 0x6C4B, 0xDF2E, 0x4231, 0xDF2F, 0, 0x6C5C, 0x4128, 0xDF30,
+ 0, 0x4678, 0, 0x4950, 0, 0xDF32, 0xDF31, 0,
+ 0, 0xDF33, 0x6C4F, 0x3B3F, 0x3B72, 0xDF34, 0x3E5E, 0,
+ 0x4765, 0xDF35, 0x382D, 0x6C4E, 0x6C4D, 0, 0x496A, 0,
+ 0xDF36, 0, 0x3C41, 0, 0xDF37, 0x4552, 0, 0xDF38,
+ 0xDF39, 0, 0xDF3A, 0, 0xF467, 0xDF3B, 0, 0xDF3C,
+ 0xDF3D, 0, 0x6C51, 0x6C52, 0x3958, 0x6C50, 0xDF3E, 0xDF3F,
+};
+static const unsigned short utf8_to_euc_E8B3_x0213[] = {
+ 0x326C, 0x6C4C, 0x4F28, 0x4442, 0x4F45, 0xDF2C, 0xDF2D, 0x3B71,
+ 0x6C4B, 0xDF2E, 0x4231, 0xDF2F, 0, 0x6C5C, 0x4128, 0xDF30,
+ 0, 0x4678, 0, 0x4950, 0, 0xF92D, 0xF92C, 0,
+ 0, 0xF92E, 0x6C4F, 0x3B3F, 0x3B72, 0xDF34, 0x3E5E, 0,
+ 0x4765, 0x7C39, 0x382D, 0x6C4E, 0x6C4D, 0, 0x496A, 0,
+ 0xDF36, 0, 0x3C41, 0, 0xDF37, 0x4552, 0, 0xDF38,
+ 0xF930, 0xF931, 0xDF3A, 0, 0x7C3A, 0xDF3B, 0, 0xDF3C,
+ 0x7C3B, 0, 0x6C51, 0x6C52, 0x3958, 0x6C50, 0x7C3C, 0xDF3F,
+};
+static const unsigned short utf8_to_euc_E8B4[] = {
+ 0, 0xDF40, 0, 0xDF41, 0x6C53, 0x6C54, 0, 0x6C56,
+ 0x4223, 0xDF42, 0x6C55, 0x3466, 0, 0x6C58, 0, 0x6C57,
+ 0x6C59, 0, 0xDF43, 0x6C5B, 0x6C5D, 0, 0x6C5E, 0xDF44,
+ 0, 0, 0, 0xDF45, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+};
+static const unsigned short utf8_to_euc_E8B4_x0213[] = {
+ 0, 0xDF40, 0, 0xDF41, 0x6C53, 0x6C54, 0, 0x6C56,
+ 0x4223, 0xF933, 0x6C55, 0x3466, 0, 0x6C58, 0xF934, 0x6C57,
+ 0x6C59, 0, 0x7C3E, 0x6C5B, 0x6C5D, 0, 0x6C5E, 0xDF44,
+ 0, 0, 0, 0x7C3F, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+};
+static const unsigned short utf8_to_euc_E8B5[] = {
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0x4056, 0xDF46, 0x3C4F, 0x6C5F,
+ 0, 0xDF47, 0, 0x3352, 0xDF48, 0x6C60, 0xDF49, 0,
+ 0x4176, 0x6C61, 0, 0x6C62, 0x496B, 0, 0xF468, 0x352F,
+ 0, 0, 0, 0, 0, 0, 0, 0xDF4A,
+};
+static const unsigned short utf8_to_euc_E8B5_x0213[] = {
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0x4056, 0xDF46, 0x3C4F, 0x6C5F,
+ 0, 0xDF47, 0, 0x3352, 0xF935, 0x6C60, 0xDF49, 0,
+ 0x4176, 0x6C61, 0, 0x6C62, 0x496B, 0, 0xF468, 0x352F,
+ 0, 0, 0, 0, 0, 0, 0, 0xDF4A,
+};
+static const unsigned short utf8_to_euc_E8B6[] = {
+ 0, 0x6C63, 0xDF4B, 0, 0xDF4C, 0x4436, 0, 0,
+ 0xDF4D, 0, 0x315B, 0, 0, 0xDF4E, 0, 0,
+ 0xDF4F, 0xDF50, 0, 0, 0, 0xDF51, 0, 0,
+ 0, 0x6C64, 0, 0, 0, 0, 0xDF52, 0xDF53,
+ 0xDF54, 0, 0, 0x3C71, 0, 0, 0xDF55, 0,
+ 0x3F76, 0, 0, 0xDF56, 0xDF57, 0, 0, 0xDF58,
+ 0, 0, 0xDF59, 0x422D, 0, 0xDF5A, 0, 0xDF5B,
+ 0, 0xDF5C, 0x6C67, 0xDF5D, 0xDF6F, 0, 0x6C66, 0,
+};
+static const unsigned short utf8_to_euc_E8B6_x0213[] = {
+ 0, 0x6C63, 0xDF4B, 0, 0xF936, 0x4436, 0, 0,
+ 0xDF4D, 0, 0x315B, 0, 0, 0xDF4E, 0, 0,
+ 0xDF4F, 0xDF50, 0, 0, 0, 0xF937, 0, 0,
+ 0, 0x6C64, 0, 0, 0, 0, 0xDF52, 0xDF53,
+ 0xDF54, 0, 0, 0x3C71, 0, 0, 0xF938, 0,
+ 0x3F76, 0, 0, 0xDF56, 0xDF57, 0, 0, 0x7C40,
+ 0, 0, 0xDF59, 0x422D, 0, 0xDF5A, 0, 0xDF5B,
+ 0, 0xDF5C, 0x6C67, 0xDF5D, 0xDF6F, 0, 0x6C66, 0,
+};
+static const unsigned short utf8_to_euc_E8B7[] = {
+ 0xDF5E, 0, 0x6C65, 0, 0, 0xDF5F, 0xDF60, 0xDF61,
+ 0xDF62, 0, 0xDF63, 0x6C6D, 0x6C6B, 0, 0xDF64, 0x6C68,
+ 0, 0xDF65, 0, 0, 0xDF66, 0xDF67, 0x6C6A, 0xDF68,
+ 0, 0xDF69, 0x6C69, 0x6C6C, 0, 0x3577, 0, 0x6C70,
+ 0, 0x4057, 0, 0x6C71, 0xDF6A, 0xDF6B, 0, 0xDF6C,
+ 0x3859, 0, 0x6C6E, 0x6C6F, 0xDF6D, 0, 0, 0x4F29,
+ 0xDF6E, 0xDF70, 0xDF71, 0x4437, 0xDF72, 0x4129, 0, 0,
+ 0, 0, 0, 0, 0x6C72, 0xDF73, 0, 0x6C75,
+};
+static const unsigned short utf8_to_euc_E8B7_x0213[] = {
+ 0xDF5E, 0, 0x6C65, 0, 0, 0xDF5F, 0xF93A, 0xDF61,
+ 0xF93B, 0, 0xDF63, 0x6C6D, 0x6C6B, 0, 0x7C41, 0x6C68,
+ 0, 0x7C42, 0, 0, 0xDF66, 0xDF67, 0x6C6A, 0x7C43,
+ 0, 0xF93C, 0x6C69, 0x6C6C, 0, 0x3577, 0, 0x6C70,
+ 0, 0x4057, 0, 0x6C71, 0xDF6A, 0xDF6B, 0, 0xDF6C,
+ 0x3859, 0, 0x6C6E, 0x6C6F, 0xF93D, 0, 0, 0x4F29,
+ 0xDF6E, 0xDF70, 0xDF71, 0x4437, 0xDF72, 0x4129, 0, 0,
+ 0, 0, 0, 0, 0x6C72, 0xF940, 0, 0x6C75,
+};
+static const unsigned short utf8_to_euc_E8B8[] = {
+ 0, 0xDF74, 0, 0, 0xDF75, 0xDF76, 0xDF77, 0,
+ 0x6C73, 0x6C74, 0x4D59, 0xDF78, 0, 0, 0, 0x4627,
+ 0x6C78, 0xDF79, 0, 0, 0xDF7A, 0, 0xDF7B, 0,
+ 0, 0, 0, 0, 0, 0x6C76, 0x6C77, 0x6C79,
+ 0xDF7C, 0xDF7D, 0xDF7E, 0xE021, 0, 0, 0xE022, 0xE023,
+ 0, 0, 0x6D29, 0, 0, 0, 0, 0,
+ 0x6C7C, 0xE024, 0, 0xE025, 0x6C7D, 0x6C7B, 0xE026, 0xE027,
+ 0xE028, 0xE029, 0, 0, 0, 0xE02A, 0, 0,
+};
+static const unsigned short utf8_to_euc_E8B8_x0213[] = {
+ 0, 0xDF74, 0, 0, 0xDF75, 0xDF76, 0xF941, 0,
+ 0x6C73, 0x6C74, 0x4D59, 0xDF78, 0xF93E, 0, 0, 0x4627,
+ 0x6C78, 0xDF79, 0, 0, 0xF943, 0, 0xF944, 0,
+ 0, 0, 0, 0, 0, 0x6C76, 0x6C77, 0x6C79,
+ 0x7C44, 0xF945, 0xF946, 0x7C45, 0, 0, 0xE022, 0xF947,
+ 0, 0, 0x6D29, 0, 0, 0, 0, 0,
+ 0x6C7C, 0xE024, 0, 0xE025, 0x6C7D, 0x6C7B, 0xF94A, 0xE027,
+ 0xE028, 0xF94B, 0, 0, 0, 0x7C46, 0, 0,
+};
+static const unsigned short utf8_to_euc_E8B9[] = {
+ 0xE02B, 0xE02C, 0x6C7A, 0, 0x447D, 0, 0, 0x6D21,
+ 0x6D25, 0x6D22, 0x6C7E, 0xE02D, 0x6D23, 0xE02E, 0xE02F, 0xE030,
+ 0x6D24, 0, 0, 0, 0xE031, 0x6D2B, 0, 0,
+ 0, 0x6D26, 0, 0xE032, 0xE033, 0xE034, 0xE035, 0x4058,
+ 0x6D28, 0xE036, 0xE037, 0x6D2A, 0x6D27, 0, 0, 0,
+ 0, 0xE038, 0, 0, 0xE039, 0xE03A, 0, 0xE03B,
+ 0xE03C, 0xE03D, 0x6D2D, 0, 0x3D33, 0, 0x6D2C, 0,
+ 0, 0xE03E, 0xE03F, 0xE040, 0x6D2E, 0, 0, 0,
+};
+static const unsigned short utf8_to_euc_E8B9_x0213[] = {
+ 0xE02B, 0xE02C, 0x6C7A, 0, 0x447D, 0, 0, 0x6D21,
+ 0x6D25, 0x6D22, 0x6C7E, 0xF94C, 0x6D23, 0xE02E, 0xE02F, 0xE030,
+ 0x6D24, 0, 0, 0, 0xF94D, 0x6D2B, 0, 0,
+ 0, 0x6D26, 0, 0xE032, 0xE033, 0xE034, 0xE035, 0x4058,
+ 0x6D28, 0xE036, 0xF94E, 0x6D2A, 0x6D27, 0, 0, 0,
+ 0, 0xE038, 0, 0, 0xF94F, 0xF950, 0, 0xF951,
+ 0x7C47, 0xE03D, 0x6D2D, 0, 0x3D33, 0, 0x6D2C, 0,
+ 0, 0xE03E, 0xE03F, 0x7C48, 0x6D2E, 0, 0, 0,
+};
+static const unsigned short utf8_to_euc_E8BA[] = {
+ 0, 0x6D2F, 0xE041, 0xE042, 0x6D32, 0x6D31, 0, 0x6D30,
+ 0, 0xE043, 0x6D34, 0x6D33, 0, 0x4C76, 0, 0,
+ 0xE044, 0x6D36, 0xE045, 0x6D35, 0x6D37, 0xE046, 0, 0,
+ 0, 0x6D38, 0xE047, 0xE048, 0, 0xE049, 0xE04A, 0,
+ 0, 0x6D3A, 0xE04B, 0, 0, 0, 0, 0xE04C,
+ 0, 0xE04D, 0x6D39, 0x3F48, 0x6D3B, 0xE04E, 0xE04F, 0x366D,
+ 0x6D3C, 0x6D3E, 0, 0xE050, 0, 0xE051, 0, 0,
+ 0, 0, 0xE052, 0xE053, 0, 0, 0x6D3F, 0,
+};
+static const unsigned short utf8_to_euc_E8BA_x0213[] = {
+ 0, 0x6D2F, 0xE041, 0xE042, 0x6D32, 0x6D31, 0, 0x6D30,
+ 0, 0xE043, 0x6D34, 0x6D33, 0, 0x4C76, 0, 0,
+ 0xE044, 0x6D36, 0xE045, 0x6D35, 0x6D37, 0xE046, 0, 0,
+ 0xF952, 0x6D38, 0xE047, 0xE048, 0, 0xE049, 0xF953, 0,
+ 0, 0x6D3A, 0xE04B, 0, 0, 0, 0, 0xE04C,
+ 0, 0xE04D, 0x6D39, 0x3F48, 0x6D3B, 0xE04E, 0xF954, 0x366D,
+ 0x6D3C, 0x6D3E, 0, 0xF955, 0, 0xF956, 0xF957, 0,
+ 0, 0, 0xE052, 0xF958, 0, 0, 0x6D3F, 0,
+};
+static const unsigned short utf8_to_euc_E8BB[] = {
+ 0xE054, 0xE055, 0, 0xE056, 0xE057, 0x6D40, 0x6D3D, 0xE058,
+ 0x6D41, 0, 0x3C56, 0x6D42, 0x3530, 0x3733, 0, 0xE059,
+ 0, 0xE05A, 0x382E, 0, 0xE05B, 0, 0, 0,
+ 0, 0, 0, 0x6D43, 0xE05C, 0, 0, 0x4670,
+ 0, 0, 0x453E, 0x6D44, 0, 0, 0, 0,
+ 0xE05D, 0, 0, 0x6D47, 0, 0xE064, 0xE05E, 0,
+ 0xE05F, 0xE060, 0, 0, 0, 0, 0, 0xE061,
+ 0x3C34, 0xE062, 0xE063, 0x6D46, 0x6D45, 0x375A, 0x6D48, 0,
+};
+static const unsigned short utf8_to_euc_E8BB_x0213[] = {
+ 0x7C4A, 0xE055, 0, 0xE056, 0xE057, 0x6D40, 0x6D3D, 0xE058,
+ 0x6D41, 0, 0x3C56, 0x6D42, 0x3530, 0x3733, 0, 0xE059,
+ 0, 0xF95A, 0x382E, 0, 0xF95B, 0, 0, 0,
+ 0, 0, 0, 0x6D43, 0xE05C, 0, 0, 0x4670,
+ 0, 0, 0x453E, 0x6D44, 0, 0, 0, 0,
+ 0xE05D, 0, 0, 0x6D47, 0, 0xE064, 0xE05E, 0,
+ 0xE05F, 0xE060, 0, 0, 0, 0, 0, 0xE061,
+ 0x3C34, 0xF95D, 0x7C4C, 0x6D46, 0x6D45, 0x375A, 0x6D48, 0,
+};
+static const unsigned short utf8_to_euc_E8BC[] = {
+ 0xE065, 0, 0xE066, 0x3353, 0, 0x6D4A, 0, 0xE067,
+ 0xE068, 0x3A5C, 0x6D49, 0, 0x6D52, 0, 0, 0xE069,
+ 0xE06A, 0, 0x6D4C, 0x6D4E, 0x4A65, 0x6D4B, 0xE06B, 0xE06C,
+ 0xE06D, 0x6D4D, 0, 0x6D51, 0x6D4F, 0x3531, 0xE06E, 0x6D50,
+ 0xE06F, 0xE070, 0, 0xE071, 0, 0xE072, 0x6D53, 0xE073,
+ 0xE074, 0x475A, 0x4E58, 0, 0xE075, 0xE076, 0xE077, 0x3D34,
+ 0, 0, 0, 0x6D54, 0xE078, 0xE079, 0xE07A, 0xE07B,
+ 0x4D22, 0x6D56, 0xE07C, 0x6D55, 0, 0, 0x6D59, 0x4D41,
+};
+static const unsigned short utf8_to_euc_E8BC_x0213[] = {
+ 0xF95F, 0, 0xE066, 0x3353, 0, 0x6D4A, 0, 0xE067,
+ 0xF960, 0x3A5C, 0x6D49, 0, 0x6D52, 0, 0, 0xE069,
+ 0xE06A, 0, 0x6D4C, 0x6D4E, 0x4A65, 0x6D4B, 0xE06B, 0xF961,
+ 0xE06D, 0x6D4D, 0, 0x6D51, 0x6D4F, 0x3531, 0x7C4D, 0x6D50,
+ 0xE06F, 0xE070, 0, 0xE071, 0, 0xE072, 0x6D53, 0xE073,
+ 0xE074, 0x475A, 0x4E58, 0xF962, 0xE075, 0x7C4E, 0xE077, 0x3D34,
+ 0, 0, 0, 0x6D54, 0xE078, 0xE079, 0x7C4F, 0xE07B,
+ 0x4D22, 0x6D56, 0xE07C, 0x6D55, 0, 0, 0x6D59, 0x4D41,
+};
+static const unsigned short utf8_to_euc_E8BD[] = {
+ 0xE07D, 0xE07E, 0x6D58, 0xE121, 0x336D, 0x6D57, 0x6D5C, 0xE122,
+ 0, 0x6D5B, 0, 0, 0x6D5A, 0x4532, 0x6D5D, 0xE123,
+ 0, 0xE124, 0xE125, 0xE126, 0xE127, 0xE128, 0, 0x6D5E,
+ 0xE129, 0, 0, 0, 0x6D5F, 0xE12A, 0xE12B, 0x396C,
+ 0, 0x3725, 0x6D60, 0x6D61, 0x6D62, 0xE12C, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+};
+static const unsigned short utf8_to_euc_E8BD_x0213[] = {
+ 0xF963, 0xE07E, 0x6D58, 0xE121, 0x336D, 0x6D57, 0x6D5C, 0xE122,
+ 0, 0x6D5B, 0xF964, 0, 0x6D5A, 0x4532, 0x6D5D, 0xE123,
+ 0, 0xE124, 0xE125, 0xE126, 0x7C50, 0xE128, 0, 0x6D5E,
+ 0xF965, 0, 0, 0, 0x6D5F, 0xE12A, 0xE12B, 0x396C,
+ 0, 0x3725, 0x6D60, 0x6D61, 0x6D62, 0xE12C, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+};
+static const unsigned short utf8_to_euc_E8BE[] = {
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0x3F49, 0x6D63, 0xE12D, 0x3C2D, 0x6D64,
+ 0xE12E, 0xE12F, 0, 0x6D65, 0xE130, 0xE131, 0xE132, 0x5221,
+ 0x517E, 0, 0, 0, 0, 0x6D66, 0x6570, 0x6D67,
+ 0x4324, 0x3F2B, 0x4740, 0, 0, 0xE133, 0xE134, 0x6D68,
+ 0xE135, 0, 0x4A55, 0x4454, 0x397E, 0, 0xE136, 0x4329,
+};
+static const unsigned short utf8_to_euc_E8BE_x0213[] = {
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0x3F49, 0x6D63, 0xE12D, 0x3C2D, 0x6D64,
+ 0xE12E, 0xE12F, 0, 0x6D65, 0xF967, 0xE131, 0x7C52, 0x5221,
+ 0x517E, 0, 0, 0, 0, 0x6D66, 0x6570, 0x6D67,
+ 0x4324, 0x3F2B, 0x4740, 0, 0xF968, 0x7C53, 0xF96A, 0x6D68,
+ 0xE135, 0, 0x4A55, 0x4454, 0x397E, 0, 0xE136, 0x4329,
+};
+static const unsigned short utf8_to_euc_E8BF[] = {
+ 0xE137, 0xE138, 0x312A, 0, 0x4B78, 0x3F57, 0xE139, 0,
+ 0, 0, 0xE13A, 0xE13B, 0, 0xE13C, 0x375E, 0,
+ 0xE13D, 0x3661, 0xE13E, 0xE13F, 0x4A56, 0xE140, 0, 0,
+ 0, 0, 0x6D69, 0, 0, 0, 0, 0,
+ 0xE141, 0, 0x6D6B, 0xE142, 0xE143, 0x6D6A, 0x3260, 0,
+ 0xE144, 0x4676, 0x6D6C, 0x4777, 0, 0x4533, 0xE145, 0x6D6D,
+ 0x3D52, 0xE146, 0, 0, 0x6D6F, 0xE147, 0xE148, 0x4C42,
+ 0x6D7E, 0x6D71, 0x6D72, 0xE149, 0, 0x4449, 0xE14A, 0,
+};
+static const unsigned short utf8_to_euc_E8BF_x0213[] = {
+ 0xE137, 0xF96C, 0x312A, 0, 0x4B78, 0x3F57, 0xF96D, 0,
+ 0, 0, 0xF96F, 0xE13B, 0, 0xF970, 0x375E, 0,
+ 0xE13D, 0x3661, 0xE13E, 0xF971, 0x4A56, 0xF972, 0, 0,
+ 0, 0, 0x6D69, 0, 0, 0, 0, 0,
+ 0xF973, 0, 0x6D6B, 0xE142, 0x7C54, 0x6D6A, 0x3260, 0,
+ 0x7C55, 0x4676, 0x6D6C, 0x4777, 0, 0x4533, 0x7C56, 0x6D6D,
+ 0x3D52, 0xF974, 0, 0, 0x6D6F, 0xF975, 0xE148, 0x4C42,
+ 0x6D7E, 0x6D71, 0x6D72, 0xF976, 0, 0x4449, 0xE14A, 0,
+};
+static const unsigned short utf8_to_euc_E980[] = {
+ 0x4260, 0x4177, 0xE14B, 0x4628, 0xE14C, 0x6D70, 0x3555, 0,
+ 0xE14D, 0, 0, 0x6D79, 0xE14E, 0x6D76, 0x6E25, 0x4629,
+ 0x4360, 0x6D73, 0, 0x447E, 0x4553, 0x6D74, 0x6D78, 0x3F60,
+ 0xE14F, 0x4767, 0x444C, 0xE150, 0, 0x4042, 0x6D77, 0x422E,
+ 0x4224, 0x6D75, 0x3029, 0x4F22, 0, 0, 0, 0x6D7A,
+ 0xE151, 0xE152, 0xE154, 0, 0xE155, 0xE156, 0x4261, 0xE153,
+ 0, 0x3D35, 0x3F4A, 0xE157, 0xE158, 0x6D7C, 0x6D7B, 0xE159,
+ 0x306F, 0x6D7D, 0, 0, 0x492F, 0, 0x6E27, 0xE15A,
+};
+static const unsigned short utf8_to_euc_E980_x0213[] = {
+ 0x4260, 0x4177, 0xF977, 0x4628, 0xE14C, 0x6D70, 0x3555, 0,
+ 0x7C57, 0, 0, 0x6D79, 0xF978, 0x6D76, 0x6E25, 0x4629,
+ 0x4360, 0x6D73, 0, 0x447E, 0x4553, 0x6D74, 0x6D78, 0x3F60,
+ 0xE14F, 0x4767, 0x444C, 0xE150, 0, 0x4042, 0x6D77, 0x422E,
+ 0x4224, 0x6D75, 0x3029, 0x4F22, 0, 0, 0, 0x6D7A,
+ 0xE151, 0xE152, 0xE154, 0, 0xE155, 0x7C58, 0x4261, 0xE153,
+ 0, 0x3D35, 0x3F4A, 0xE157, 0xE158, 0x6D7C, 0x6D7B, 0xF979,
+ 0x306F, 0x6D7D, 0, 0, 0x492F, 0, 0x6E27, 0xE15A,
+};
+static const unsigned short utf8_to_euc_E981[] = {
+ 0, 0x465B, 0x3F6B, 0xE15B, 0xE15C, 0x4359, 0, 0x3678,
+ 0, 0x6E26, 0x4D37, 0x313F, 0xE15D, 0x4A57, 0x3261, 0x6E21,
+ 0x6E22, 0x6E23, 0x6E24, 0x463B, 0x4323, 0x3063, 0x6E28, 0,
+ 0x6E29, 0x7423, 0, 0xE15E, 0x423D, 0xE15F, 0x6E2A, 0,
+ 0x3173, 0x414C, 0xE160, 0x382F, 0, 0x4D5A, 0xE161, 0xE162,
+ 0x6E2B, 0x452C, 0, 0, 0xE163, 0x4178, 0x3C57, 0x6E2C,
+ 0xE164, 0, 0x6E2F, 0, 0xE165, 0x3D65, 0x6E2D, 0x412B,
+ 0x412A, 0xE166, 0x3064, 0, 0x4E4B, 0x6E31, 0, 0x4872,
+};
+static const unsigned short utf8_to_euc_E981_x0213[] = {
+ 0, 0x465B, 0x3F6B, 0xF97B, 0xF97C, 0x4359, 0, 0x3678,
+ 0, 0x6E26, 0x4D37, 0x313F, 0xE15D, 0x4A57, 0x3261, 0x6E21,
+ 0x6E22, 0x6E23, 0x6E24, 0x463B, 0x4323, 0x3063, 0x6E28, 0,
+ 0x6E29, 0x7423, 0, 0xE15E, 0x423D, 0xF97D, 0x6E2A, 0,
+ 0x3173, 0x414C, 0xE160, 0x382F, 0, 0x4D5A, 0xE161, 0xE162,
+ 0x6E2B, 0x452C, 0, 0, 0xE163, 0x4178, 0x3C57, 0x6E2C,
+ 0xE164, 0, 0x6E2F, 0, 0xE165, 0x3D65, 0x6E2D, 0x412B,
+ 0x412A, 0xE166, 0x3064, 0, 0x4E4B, 0x6E31, 0, 0x4872,
+};
+static const unsigned short utf8_to_euc_E982[] = {
+ 0x6E33, 0x6E32, 0x6E30, 0x6364, 0x3454, 0xE167, 0, 0x6D6E,
+ 0xE168, 0x6E35, 0x6E34, 0xE169, 0xE16A, 0, 0xE16B, 0x6E36,
+ 0xE16C, 0x4D38, 0, 0, 0, 0xE16D, 0, 0xE16E,
+ 0xE16F, 0xE170, 0, 0xE171, 0, 0, 0, 0,
+ 0xE172, 0xE173, 0xE174, 0x4661, 0, 0xE175, 0x4B2E, 0,
+ 0x6E37, 0, 0x3C59, 0, 0, 0, 0, 0x6E38,
+ 0xE176, 0x6E39, 0xE177, 0xE178, 0xE179, 0x6E3A, 0xE17A, 0,
+ 0x4521, 0, 0, 0, 0, 0xE17B, 0xE17D, 0,
+};
+static const unsigned short utf8_to_euc_E982_x0213[] = {
+ 0x6E33, 0x6E32, 0x6E30, 0x6364, 0x3454, 0xFA22, 0, 0x6D6E,
+ 0x7C5A, 0x6E35, 0x6E34, 0xE169, 0xFA23, 0, 0xE16B, 0x6E36,
+ 0xFA24, 0x4D38, 0, 0, 0, 0x7C5B, 0, 0x7C5C,
+ 0xE16F, 0x7C5D, 0, 0x7C5E, 0, 0, 0, 0,
+ 0xE172, 0xFA26, 0x7C5F, 0x4661, 0, 0xE175, 0x4B2E, 0,
+ 0x6E37, 0, 0x3C59, 0, 0, 0, 0, 0x6E38,
+ 0xFA28, 0x6E39, 0xE177, 0x7C60, 0xE179, 0x6E3A, 0xFA29, 0,
+ 0x4521, 0, 0, 0, 0, 0xE17B, 0x7C61, 0,
+};
+static const unsigned short utf8_to_euc_E983[] = {
+ 0, 0x306A, 0, 0xE17E, 0xE221, 0xE222, 0, 0xE223,
+ 0xE224, 0, 0x3959, 0, 0xE17C, 0, 0x4F3A, 0,
+ 0, 0, 0xE22D, 0, 0, 0xE225, 0, 0xE226,
+ 0xE227, 0xE228, 0, 0x6E3E, 0xE229, 0xE22A, 0xF46C, 0xE22B,
+ 0, 0x3734, 0x6E3B, 0, 0x6E3C, 0xE22C, 0, 0,
+ 0x4974, 0, 0, 0xE22F, 0, 0x3354, 0, 0xE230,
+ 0xE231, 0, 0, 0, 0xE232, 0x4D39, 0xE22E, 0x363F,
+ 0, 0, 0, 0, 0, 0x4554, 0xE233, 0xE234,
+};
+static const unsigned short utf8_to_euc_E983_x0213[] = {
+ 0, 0x306A, 0, 0xFA2A, 0x7C62, 0x7C63, 0, 0x7C64,
+ 0xFA2B, 0, 0x3959, 0, 0xE17C, 0, 0x4F3A, 0,
+ 0, 0, 0xE22D, 0, 0, 0xE225, 0, 0x7C65,
+ 0xE227, 0xE228, 0, 0x6E3E, 0xFA2D, 0x7C66, 0x7C67, 0xFA2E,
+ 0, 0x3734, 0x6E3B, 0, 0x6E3C, 0xE22C, 0, 0,
+ 0x4974, 0, 0, 0xFA33, 0, 0x3354, 0, 0x7C68,
+ 0xE231, 0, 0xFA31, 0, 0x7C69, 0x4D39, 0xFA30, 0x363F,
+ 0, 0, 0, 0, 0, 0x4554, 0xFA34, 0xFA35,
+};
+static const unsigned short utf8_to_euc_E984[] = {
+ 0xE235, 0, 0x6E3F, 0, 0xE236, 0xE237, 0xE238, 0,
+ 0xE239, 0, 0, 0, 0, 0xE23A, 0, 0,
+ 0xE23B, 0, 0x6E40, 0, 0xE23C, 0xF46E, 0xE23D, 0xE23E,
+ 0xE23F, 0x6E41, 0xE240, 0, 0xE241, 0, 0xE242, 0,
+ 0xE243, 0, 0xE245, 0xE246, 0, 0xE244, 0, 0xE247,
+ 0, 0xE248, 0, 0, 0, 0x4522, 0xE249, 0xE24A,
+ 0x6E43, 0xE24B, 0x6E42, 0, 0xE24C, 0, 0xE24D, 0xE24E,
+ 0, 0xE24F, 0xE250, 0, 0xE251, 0xE252, 0, 0,
+};
+static const unsigned short utf8_to_euc_E984_x0213[] = {
+ 0xFA32, 0, 0x6E3F, 0, 0xFA36, 0xE237, 0xFA37, 0,
+ 0xE239, 0, 0, 0, 0, 0xE23A, 0, 0,
+ 0xE23B, 0, 0x6E40, 0, 0x7C6B, 0x7C6C, 0x7C6D, 0xE23E,
+ 0xFA38, 0x6E41, 0xE240, 0, 0xFA39, 0, 0xFA3A, 0,
+ 0xE243, 0, 0x7C6E, 0x7C6F, 0, 0xE244, 0, 0x7C70,
+ 0, 0xE248, 0, 0, 0, 0x4522, 0xE249, 0x7C71,
+ 0x6E43, 0x7C72, 0x6E42, 0, 0x7C73, 0, 0xE24D, 0xFA3B,
+ 0, 0xFA3C, 0xFA3D, 0, 0xE251, 0x7C74, 0, 0,
+};
+static const unsigned short utf8_to_euc_E985[] = {
+ 0, 0, 0, 0xE253, 0, 0, 0, 0xE254,
+ 0xE255, 0x4653, 0x6E44, 0x3D36, 0x3C60, 0x475B, 0x4371, 0xE256,
+ 0, 0, 0x3C72, 0xE257, 0x3F6C, 0, 0x6E45, 0xE258,
+ 0x6E46, 0xE259, 0xE25A, 0xE25B, 0, 0, 0, 0,
+ 0, 0xE25C, 0x3F5D, 0x6E47, 0xE25D, 0x6E48, 0, 0xE25E,
+ 0, 0x6E49, 0x4D6F, 0, 0x3D37, 0xE25F, 0, 0,
+ 0, 0, 0x6E4B, 0x6E4A, 0xE260, 0x395A, 0, 0x3973,
+ 0x3B40, 0xE261, 0xE262, 0xE263, 0, 0, 0, 0,
+};
+static const unsigned short utf8_to_euc_E985_x0213[] = {
+ 0, 0, 0, 0xE253, 0, 0, 0xFA3E, 0xFA3F,
+ 0x7C75, 0x4653, 0x6E44, 0x3D36, 0x3C60, 0x475B, 0x4371, 0xE256,
+ 0, 0, 0x3C72, 0xE257, 0x3F6C, 0, 0x6E45, 0xFA40,
+ 0x6E46, 0xFA41, 0xE25A, 0x7C76, 0, 0, 0, 0,
+ 0, 0xFA42, 0x3F5D, 0x6E47, 0xFA43, 0x6E48, 0, 0xE25E,
+ 0, 0x6E49, 0x4D6F, 0, 0x3D37, 0xE25F, 0, 0,
+ 0, 0, 0x6E4B, 0x6E4A, 0xFA44, 0x395A, 0, 0x3973,
+ 0x3B40, 0xFA45, 0xE262, 0xE263, 0, 0, 0, 0,
+};
+static const unsigned short utf8_to_euc_E986[] = {
+ 0, 0xE264, 0x6E4E, 0xE265, 0, 0xE266, 0xE267, 0x3D66,
+ 0, 0x6E4D, 0xE268, 0x6E4C, 0, 0x4269, 0xE269, 0,
+ 0x386F, 0xE26A, 0x4043, 0xE26B, 0xE26C, 0xE26D, 0, 0x4830,
+ 0xE26E, 0, 0, 0, 0x3D39, 0, 0xE26F, 0,
+ 0, 0xE270, 0x6E4F, 0, 0x3E5F, 0, 0xE271, 0,
+ 0xE272, 0, 0x6E52, 0x6E50, 0xE273, 0xE274, 0xE275, 0x6E51,
+ 0xE276, 0xE277, 0xE278, 0xE279, 0x6E54, 0x6E53, 0xE27A, 0,
+ 0x3E7A, 0, 0x6E55, 0xE27B, 0xE27C, 0xE27D, 0, 0xE27E,
+};
+static const unsigned short utf8_to_euc_E986_x0213[] = {
+ 0, 0xE264, 0x6E4E, 0x7C77, 0, 0xFA46, 0xE267, 0x3D66,
+ 0, 0x6E4D, 0xE268, 0x6E4C, 0, 0x4269, 0xFA47, 0,
+ 0x386F, 0xE26A, 0x4043, 0xE26B, 0xE26C, 0xE26D, 0, 0x4830,
+ 0xE26E, 0, 0, 0, 0x3D39, 0, 0x7C78, 0,
+ 0, 0xE270, 0x6E4F, 0, 0x3E5F, 0, 0xE271, 0,
+ 0xFA48, 0, 0x6E52, 0x6E50, 0x7C79, 0xE274, 0xFA49, 0x6E51,
+ 0xE276, 0x7C7A, 0xE278, 0xFA4A, 0x6E54, 0x6E53, 0xFA4B, 0,
+ 0x3E7A, 0, 0x6E55, 0xE27B, 0x7C7B, 0xE27D, 0, 0xE27E,
+};
+static const unsigned short utf8_to_euc_E987[] = {
+ 0x6E56, 0x6E57, 0xE321, 0xE322, 0, 0xE323, 0x4850, 0x3A53,
+ 0x3C61, 0x6E58, 0, 0x6E59, 0x4E24, 0x3D45, 0x4C6E, 0x4E4C,
+ 0x6E5A, 0x3662, 0, 0xE324, 0xE325, 0, 0x6E5B, 0xE326,
+ 0x4523, 0xE327, 0xE328, 0x6E5E, 0x3378, 0x3F4B, 0xE329, 0x6E5C,
+ 0, 0x6E5D, 0, 0x4460, 0xE32A, 0xE32B, 0x4B55, 0x367C,
+ 0, 0xE32C, 0xE32D, 0, 0xE32E, 0xE32F, 0xE330, 0xE331,
+ 0xE332, 0xE333, 0, 0, 0, 0x6E60, 0x6E61, 0xE334,
+ 0, 0xE335, 0, 0xE336, 0x6E5F, 0xE337, 0, 0x6E63,
+};
+static const unsigned short utf8_to_euc_E987_x0213[] = {
+ 0x6E56, 0x6E57, 0xE321, 0xFA4C, 0xFA4D, 0xE323, 0x4850, 0x3A53,
+ 0x3C61, 0x6E58, 0, 0x6E59, 0x4E24, 0x3D45, 0x4C6E, 0x4E4C,
+ 0x6E5A, 0x3662, 0, 0xE324, 0xE325, 0, 0x6E5B, 0x7C7C,
+ 0x4523, 0xE327, 0xFA4E, 0x6E5E, 0x3378, 0x3F4B, 0xE329, 0x6E5C,
+ 0, 0x6E5D, 0, 0x4460, 0x7C7E, 0x7D21, 0x4B55, 0x367C,
+ 0, 0xE32C, 0xE32D, 0, 0xFA51, 0x7D22, 0xFA52, 0xE331,
+ 0xE332, 0x7D23, 0, 0, 0, 0x6E60, 0x6E61, 0xE334,
+ 0, 0xE335, 0, 0x7C7D, 0x6E5F, 0xE337, 0, 0x6E63,
+};
+static const unsigned short utf8_to_euc_E988[] = {
+ 0xE338, 0xE339, 0, 0, 0xE33A, 0xE33B, 0xE33C, 0xE33D,
+ 0, 0xE33E, 0xE33F, 0, 0xE340, 0x465F, 0x3343, 0,
+ 0xE341, 0x6E67, 0xE342, 0xE343, 0x6E64, 0x6E66, 0xE344, 0,
+ 0xE345, 0, 0, 0, 0xE346, 0xE347, 0x6E62, 0,
+ 0, 0, 0, 0xE348, 0xE349, 0xE34A, 0xE34B, 0,
+ 0xE34C, 0x6F4F, 0, 0, 0x6E65, 0, 0xE34D, 0xE34E,
+ 0xE34F, 0, 0, 0xE350, 0x4E6B, 0xE351, 0xE352, 0x385A,
+ 0xE353, 0xE354, 0xE355, 0, 0xE356, 0, 0xE357, 0x6E6F,
+};
+static const unsigned short utf8_to_euc_E988_x0213[] = {
+ 0xE338, 0xFA53, 0, 0, 0xE33A, 0xE33B, 0xE33C, 0x7D24,
+ 0, 0xE33E, 0xFA54, 0, 0xE340, 0x465F, 0x3343, 0,
+ 0x7D25, 0x6E67, 0xE342, 0xE343, 0x6E64, 0x6E66, 0xFA55, 0xFA56,
+ 0xE345, 0, 0, 0, 0xE346, 0xE347, 0x6E62, 0,
+ 0, 0, 0, 0xE348, 0xE349, 0xE34A, 0xE34B, 0,
+ 0xE34C, 0x6F4F, 0, 0, 0x6E65, 0, 0xE34D, 0xE34E,
+ 0xE34F, 0, 0, 0xFA58, 0x4E6B, 0xE351, 0xE352, 0x385A,
+ 0x7D26, 0x7D27, 0x7D28, 0, 0x7D29, 0, 0xE357, 0x6E6F,
+};
+static const unsigned short utf8_to_euc_E989[] = {
+ 0xE358, 0, 0xE359, 0xE35A, 0x4534, 0x6E6A, 0xE35B, 0xE35C,
+ 0x6E6D, 0x6E6B, 0xE35D, 0x6E70, 0, 0xE35E, 0xE35F, 0xE360,
+ 0x6E71, 0xE361, 0, 0, 0, 0, 0, 0x6E69,
+ 0xE362, 0xE363, 0x6E76, 0x3174, 0xE364, 0xE365, 0x6E68, 0,
+ 0xE366, 0xE367, 0x482D, 0, 0x6E6C, 0xE368, 0x3E60, 0xE369,
+ 0xE36A, 0xE36B, 0, 0, 0, 0, 0xE36C, 0xE36D,
+ 0xE36E, 0x395B, 0, 0, 0, 0xE36F, 0xE370, 0xE371,
+ 0xE372, 0xE373, 0, 0xE374, 0xE375, 0xE376, 0x4B48, 0xE377,
+};
+static const unsigned short utf8_to_euc_E989_x0213[] = {
+ 0x7D2A, 0, 0xFA59, 0x7D2B, 0x4534, 0x6E6A, 0xE35B, 0xFA5A,
+ 0x6E6D, 0x6E6B, 0xFA5B, 0x6E70, 0, 0xE35E, 0xFA5C, 0x7D2C,
+ 0x6E71, 0xFA5D, 0, 0, 0, 0, 0xFA5E, 0x6E69,
+ 0xE362, 0xFA5F, 0x6E76, 0x3174, 0xE364, 0xE365, 0x6E68, 0,
+ 0xFA60, 0xFA61, 0x482D, 0, 0x6E6C, 0xFA62, 0x3E60, 0xFA63,
+ 0xFA64, 0xE36B, 0, 0, 0, 0, 0xE36C, 0xE36D,
+ 0xE36E, 0x395B, 0, 0, 0, 0xE36F, 0xE370, 0xE371,
+ 0x7D2D, 0xE373, 0, 0xE374, 0xFA67, 0xFA68, 0x4B48, 0xFA69,
+};
+static const unsigned short utf8_to_euc_E98A[] = {
+ 0x3664, 0, 0, 0x3D46, 0, 0x463C, 0, 0,
+ 0xE378, 0xE379, 0xE37A, 0, 0, 0xE37B, 0xE37C, 0,
+ 0, 0x412D, 0xE37D, 0x6E74, 0, 0x6E6E, 0x6E73, 0xE37E,
+ 0x4C43, 0xE421, 0x4438, 0x6E75, 0x6E72, 0, 0, 0xE422,
+ 0xE423, 0, 0, 0, 0xE424, 0xE425, 0, 0xE426,
+ 0xE427, 0, 0, 0xE428, 0, 0x412C, 0, 0xE429,
+ 0, 0, 0xE42A, 0, 0, 0, 0xE42B, 0x6E79,
+ 0xE42C, 0x6E78, 0xE42D, 0xE42E, 0xE42F, 0xE430, 0, 0xE431,
+};
+static const unsigned short utf8_to_euc_E98A_x0213[] = {
+ 0x3664, 0, 0, 0x3D46, 0, 0x463C, 0, 0,
+ 0x7D2E, 0xFA6A, 0xE37A, 0, 0, 0xFA6B, 0xE37C, 0,
+ 0, 0x412D, 0xE37D, 0x6E74, 0, 0x6E6E, 0x6E73, 0xFA6C,
+ 0x4C43, 0xFA6D, 0x4438, 0x6E75, 0x6E72, 0, 0, 0xFA6E,
+ 0xE423, 0, 0, 0, 0xE424, 0xE425, 0, 0xFA6F,
+ 0xE427, 0, 0, 0xFA70, 0, 0x412C, 0, 0xE429,
+ 0, 0, 0xFA73, 0, 0, 0, 0xE42B, 0x6E79,
+ 0xE42C, 0x6E78, 0xE42D, 0xE42E, 0xE42F, 0xE430, 0, 0xFA74,
+};
+static const unsigned short utf8_to_euc_E98B[] = {
+ 0xE432, 0xE433, 0xE434, 0xE435, 0, 0xE436, 0xE437, 0xE438,
+ 0xE439, 0, 0, 0xE43A, 0xE43B, 0xE43C, 0xE43D, 0x6E77,
+ 0xE43E, 0, 0x4B2F, 0xE43F, 0, 0xE440, 0, 0xE441,
+ 0xE442, 0xE443, 0, 0, 0xE444, 0xE445, 0, 0xE446,
+ 0xE447, 0xE448, 0, 0xE449, 0x3D7B, 0xE44A, 0, 0xE44B,
+ 0xE44C, 0x6E7A, 0x4A5F, 0, 0xE44D, 0x3154, 0xE44E, 0,
+ 0xE44F, 0, 0x4946, 0x4372, 0, 0, 0, 0,
+ 0x3578, 0xE450, 0x6E7C, 0xE451, 0x395D, 0, 0, 0xE452,
+};
+static const unsigned short utf8_to_euc_E98B_x0213[] = {
+ 0xFA75, 0xE433, 0x7D2F, 0xE435, 0, 0xE436, 0xFA76, 0xE438,
+ 0xE439, 0, 0, 0x7D30, 0x7D31, 0xE43C, 0xFA77, 0x6E77,
+ 0xFA78, 0, 0x4B2F, 0x7D32, 0, 0xE440, 0, 0xFA79,
+ 0xE442, 0xFA7A, 0, 0, 0xE444, 0xE445, 0, 0xE446,
+ 0x7D33, 0xE448, 0, 0xE449, 0x3D7B, 0xFA7B, 0, 0xFA7C,
+ 0xE44C, 0x6E7A, 0x4A5F, 0, 0xE44D, 0x3154, 0xE44E, 0,
+ 0xE44F, 0, 0x4946, 0x4372, 0, 0, 0, 0xFB22,
+ 0x3578, 0xFB23, 0x6E7C, 0xFB24, 0x395D, 0, 0, 0x7D34,
+};
+static const unsigned short utf8_to_euc_E98C[] = {
+ 0xE453, 0, 0xE454, 0, 0, 0, 0x3B2C, 0,
+ 0xE455, 0, 0, 0, 0, 0xE456, 0, 0x6E7B,
+ 0x3F6D, 0xE457, 0, 0, 0xE458, 0xE459, 0, 0,
+ 0x3F6E, 0x6F21, 0x6F23, 0, 0xE45A, 0xE45B, 0xE45C, 0xE45D,
+ 0x3E7B, 0xE45E, 0x6F22, 0x6F24, 0xE45F, 0xE460, 0x3653, 0xE461,
+ 0x4945, 0xE462, 0xE463, 0x3C62, 0x4F23, 0, 0x6E7E, 0x3A78,
+ 0, 0, 0x4F3F, 0xE464, 0xE465, 0x6F26, 0xE466, 0xE467,
+ 0, 0, 0x6F25, 0x6F27, 0, 0, 0, 0,
+};
+static const unsigned short utf8_to_euc_E98C_x0213[] = {
+ 0xE453, 0, 0xFB25, 0, 0x7D35, 0, 0x3B2C, 0,
+ 0xE455, 0, 0, 0, 0, 0xFB26, 0, 0x6E7B,
+ 0x3F6D, 0xFA7D, 0, 0, 0xE458, 0xFB27, 0, 0,
+ 0x3F6E, 0x6F21, 0x6F23, 0, 0xE45A, 0xFB28, 0xFB29, 0x7D36,
+ 0x3E7B, 0x7D37, 0x6F22, 0x6F24, 0xE45F, 0x7D38, 0x3653, 0xFB2A,
+ 0x4945, 0xFB2B, 0xE463, 0x3C62, 0x4F23, 0, 0x6E7E, 0x3A78,
+ 0, 0, 0x4F3F, 0xE464, 0xE465, 0x6F26, 0xE466, 0xE467,
+ 0, 0, 0x6F25, 0x6F27, 0, 0, 0, 0,
+};
+static const unsigned short utf8_to_euc_E98D[] = {
+ 0, 0, 0, 0, 0x6E7D, 0, 0, 0xE468,
+ 0xE469, 0xE46A, 0, 0x4669, 0, 0x4555, 0, 0,
+ 0xE46B, 0xE46C, 0xE46D, 0, 0x4457, 0xE46E, 0x6F2C, 0xE46F,
+ 0xE470, 0, 0xE471, 0x4343, 0x6F28, 0, 0xE472, 0,
+ 0x6F29, 0, 0, 0, 0xE473, 0xE474, 0, 0xE475,
+ 0, 0xE476, 0xE477, 0, 0x372D, 0xE478, 0x6F2B, 0xE479,
+ 0xE47A, 0xE47B, 0, 0xE47C, 0xE47D, 0x3830, 0xE47E, 0,
+ 0, 0, 0xE521, 0, 0x6F2A, 0xE522, 0x3E61, 0xE523,
+};
+static const unsigned short utf8_to_euc_E98D_x0213[] = {
+ 0, 0, 0, 0, 0x6E7D, 0, 0, 0xFB2E,
+ 0x7D39, 0x7D3A, 0x7D3B, 0x4669, 0, 0x4555, 0, 0,
+ 0xE46B, 0xFB2F, 0xE46D, 0, 0x4457, 0xE46E, 0x6F2C, 0xFB30,
+ 0xE470, 0, 0xFB31, 0x4343, 0x6F28, 0, 0xE472, 0,
+ 0x6F29, 0, 0, 0, 0x7D3C, 0x7D3D, 0, 0xE475,
+ 0, 0xE476, 0x7D3E, 0xFB32, 0x372D, 0xE478, 0x6F2B, 0xE479,
+ 0x7D3F, 0xFB33, 0, 0xFB34, 0xE47D, 0x3830, 0xE47E, 0,
+ 0, 0, 0xE521, 0, 0x6F2A, 0xE522, 0x3E61, 0xE523,
+};
+static const unsigned short utf8_to_euc_E98E[] = {
+ 0xE524, 0xE525, 0xE526, 0, 0, 0, 0, 0,
+ 0xE527, 0, 0xE528, 0xE529, 0x3379, 0xE52A, 0, 0xE52B,
+ 0, 0, 0xE52C, 0, 0x6F30, 0xE52D, 0x3A3F, 0x4179,
+ 0xE52E, 0, 0x444A, 0xE52F, 0, 0, 0xE530, 0,
+ 0, 0xE531, 0, 0xE532, 0xE533, 0, 0xE534, 0x333B,
+ 0xE535, 0xE53B, 0, 0xE536, 0x6F2E, 0x6F2F, 0x4443, 0,
+ 0x6F2D, 0, 0, 0, 0xE537, 0xE538, 0xE539, 0,
+ 0, 0x6F31, 0xE53A, 0, 0, 0, 0, 0,
+};
+static const unsigned short utf8_to_euc_E98E_x0213[] = {
+ 0xE524, 0xE525, 0xE526, 0, 0, 0, 0, 0,
+ 0xFB38, 0, 0xE528, 0xFB39, 0x3379, 0xE52A, 0, 0xFB3A,
+ 0, 0, 0xE52C, 0, 0x6F30, 0xE52D, 0x3A3F, 0x4179,
+ 0xE52E, 0, 0x444A, 0x7D40, 0, 0, 0xFB3B, 0,
+ 0, 0xFB35, 0, 0x7D41, 0xE533, 0, 0xE534, 0x333B,
+ 0xE535, 0xE53B, 0, 0xE536, 0x6F2E, 0x6F2F, 0x4443, 0,
+ 0x6F2D, 0, 0, 0, 0xE537, 0xE538, 0xE539, 0,
+ 0, 0x6F31, 0x7D42, 0, 0, 0, 0, 0,
+};
+static const unsigned short utf8_to_euc_E98F[] = {
+ 0, 0xE53C, 0, 0x6F37, 0xE53D, 0xE53E, 0xE53F, 0xE540,
+ 0x6F3A, 0xE541, 0xE542, 0xE543, 0xE544, 0xE545, 0, 0,
+ 0x6F39, 0x452D, 0, 0xE546, 0, 0, 0x6F32, 0x6F33,
+ 0x6F36, 0xE547, 0, 0, 0xE548, 0x6F38, 0xE549, 0xE54A,
+ 0, 0x3640, 0xE54B, 0, 0x6F3B, 0x6F35, 0xE54C, 0xE54D,
+ 0x6F34, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0xE54F,
+ 0xE550, 0xE54E, 0xE551, 0xE552, 0, 0xE553, 0, 0,
+};
+static const unsigned short utf8_to_euc_E98F_x0213[] = {
+ 0, 0xFB40, 0, 0x6F37, 0xE53D, 0xE53E, 0x7D43, 0xFB41,
+ 0x6F3A, 0xE541, 0xE542, 0xE543, 0xE544, 0xE545, 0, 0,
+ 0x6F39, 0x452D, 0, 0xE546, 0, 0, 0x6F32, 0x6F33,
+ 0x6F36, 0xE547, 0, 0, 0xFB42, 0x6F38, 0x7D44, 0x7D45,
+ 0, 0x3640, 0xFB43, 0, 0x6F3B, 0x6F35, 0xE54C, 0xFB44,
+ 0x6F34, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0xFB3F, 0, 0, 0, 0xFB3C, 0, 0xE54F,
+ 0xE550, 0xE54E, 0xE551, 0xFB49, 0, 0x7D47, 0, 0,
+};
+static const unsigned short utf8_to_euc_E990[] = {
+ 0, 0xE554, 0xE555, 0x6F3F, 0xE556, 0, 0, 0x6F40,
+ 0xE557, 0xE558, 0, 0, 0, 0xE559, 0xE55A, 0xE55B,
+ 0x6F41, 0, 0, 0x6F3E, 0x6F3D, 0xE55C, 0xE55D, 0xE55E,
+ 0x3E62, 0x462A, 0x6F3C, 0, 0, 0, 0, 0xE55F,
+ 0, 0x6F45, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0x6F43, 0, 0, 0xE560, 0xE561,
+ 0, 0xE562, 0xE563, 0xE564, 0xE565, 0x6F44, 0x6F42, 0,
+ 0x4278, 0, 0x6F46, 0xE566, 0, 0xE568, 0, 0xE567,
+};
+static const unsigned short utf8_to_euc_E990_x0213[] = {
+ 0, 0xE554, 0xE555, 0x6F3F, 0x7D46, 0, 0, 0x6F40,
+ 0xE557, 0xFB45, 0, 0, 0, 0xE559, 0xE55A, 0xFB46,
+ 0x6F41, 0, 0, 0x6F3E, 0x6F3D, 0xE55C, 0xFB47, 0xFB48,
+ 0x3E62, 0x462A, 0x6F3C, 0, 0, 0, 0, 0xE55F,
+ 0, 0x6F45, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0x6F43, 0, 0, 0xE560, 0xE561,
+ 0, 0xE562, 0xFB4A, 0x7D48, 0xFB4B, 0x6F44, 0x6F42, 0,
+ 0x4278, 0, 0x6F46, 0xFB4C, 0, 0xE568, 0, 0xE567,
+};
+static const unsigned short utf8_to_euc_E991[] = {
+ 0, 0x6F47, 0, 0xE569, 0x6F49, 0xE56A, 0, 0,
+ 0xE56B, 0, 0xE56C, 0, 0xE56D, 0, 0, 0,
+ 0, 0x3455, 0x6F48, 0x4C7A, 0, 0xE56E, 0, 0,
+ 0, 0xE56F, 0x6F54, 0x6F4A, 0xE570, 0, 0x6F4D, 0xE571,
+ 0x6F4B, 0xE572, 0x6F4C, 0xE573, 0, 0, 0, 0,
+ 0xE574, 0, 0x6F4E, 0xE575, 0, 0xE576, 0xE577, 0xE578,
+ 0x6F50, 0xE579, 0xE57A, 0, 0, 0x6F51, 0, 0x6F52,
+ 0, 0, 0, 0, 0x6F55, 0x6F53, 0x6F56, 0x6F58,
+};
+static const unsigned short utf8_to_euc_E991_x0213[] = {
+ 0, 0x6F47, 0, 0xE569, 0x6F49, 0xFB4D, 0, 0,
+ 0xE56B, 0, 0x7D49, 0, 0xE56D, 0, 0, 0,
+ 0, 0x3455, 0x6F48, 0x4C7A, 0, 0xE56E, 0, 0,
+ 0, 0xE56F, 0x6F54, 0x6F4A, 0xE570, 0, 0x6F4D, 0xE571,
+ 0x6F4B, 0xE572, 0x6F4C, 0x7D4A, 0, 0, 0, 0,
+ 0xE574, 0, 0x6F4E, 0x7D4B, 0, 0xFB50, 0xE577, 0xFB51,
+ 0x6F50, 0x7D4C, 0x7D4D, 0, 0, 0x6F51, 0, 0x6F52,
+ 0, 0, 0, 0, 0x6F55, 0x6F53, 0x6F56, 0x6F58,
+};
+static const unsigned short utf8_to_euc_E992[] = {
+ 0, 0x6F57, 0, 0xE57C, 0xE57B, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+};
+static const unsigned short utf8_to_euc_E995[] = {
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0x4439,
+ 0xE57D, 0xE57E, 0, 0, 0, 0, 0xE621, 0,
+};
+static const unsigned short utf8_to_euc_E995_x0213[] = {
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0x4439,
+ 0xFB52, 0xFB53, 0, 0, 0, 0, 0xE621, 0,
+};
+static const unsigned short utf8_to_euc_E996[] = {
+ 0x4C67, 0, 0x6F59, 0x412E, 0xE622, 0, 0, 0x6F5A,
+ 0xE623, 0x4A44, 0x6F5B, 0x332B, 0xE624, 0xE625, 0xE626, 0x313C,
+ 0, 0x3457, 0xF471, 0x3456, 0x6F5C, 0, 0x6F5D, 0,
+ 0x6F5E, 0x6F5F, 0, 0, 0, 0xE627, 0xE628, 0xE629,
+ 0x6F60, 0xE62A, 0x3458, 0x3355, 0x395E, 0x4836, 0xE62B, 0x6F62,
+ 0x6F61, 0xE62C, 0, 0xE62D, 0xE62E, 0x6F63, 0, 0,
+ 0, 0, 0x315C, 0, 0xE62F, 0, 0xE630, 0,
+ 0, 0x6F66, 0xE631, 0x6F65, 0x6F64, 0xE632, 0x6F67, 0xE633,
+};
+static const unsigned short utf8_to_euc_E996_x0213[] = {
+ 0x4C67, 0, 0x6F59, 0x412E, 0xE622, 0, 0xFB54, 0x6F5A,
+ 0xE623, 0x4A44, 0x6F5B, 0x332B, 0xFB55, 0xFB56, 0x7D4E, 0x313C,
+ 0, 0x3457, 0xF471, 0x3456, 0x6F5C, 0, 0x6F5D, 0,
+ 0x6F5E, 0x6F5F, 0, 0, 0, 0xE627, 0xE628, 0x7D4F,
+ 0x6F60, 0xE62A, 0x3458, 0x3355, 0x395E, 0x4836, 0x7D50, 0x6F62,
+ 0x6F61, 0x7D51, 0, 0xFB58, 0x7D52, 0x6F63, 0, 0,
+ 0, 0, 0x315C, 0, 0xFB59, 0, 0x7D53, 0,
+ 0, 0x6F66, 0xE631, 0x6F65, 0x6F64, 0x7D54, 0x6F67, 0xE633,
+};
+static const unsigned short utf8_to_euc_E997[] = {
+ 0, 0, 0, 0x6F6A, 0, 0, 0xE634, 0x3047,
+ 0xE635, 0xE636, 0x6F68, 0xE637, 0x6F6C, 0x6F6B, 0, 0,
+ 0xE638, 0xE639, 0xE63A, 0xE63B, 0x6F6E, 0x6F6D, 0x6F6F, 0,
+ 0x462E, 0xE63C, 0xE63D, 0, 0x6F70, 0xE63E, 0xE63F, 0xE640,
+ 0xE641, 0x6F71, 0x6F73, 0, 0xE642, 0x6F72, 0xE643, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+};
+static const unsigned short utf8_to_euc_E997_x0213[] = {
+ 0, 0, 0, 0x6F6A, 0, 0, 0xE634, 0x3047,
+ 0xFB5B, 0xE636, 0x6F68, 0x7D55, 0x6F6C, 0x6F6B, 0, 0,
+ 0x7D56, 0xE639, 0xE63A, 0x7D57, 0x6F6E, 0x6F6D, 0x6F6F, 0,
+ 0x462E, 0xE63C, 0x7D59, 0, 0x6F70, 0xE63E, 0x7D5A, 0xE640,
+ 0xE641, 0x6F71, 0x6F73, 0, 0xE642, 0x6F72, 0xE643, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+};
+static const unsigned short utf8_to_euc_E998[] = {
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0x496C, 0xE644, 0xE645, 0,
+ 0, 0x6F74, 0xE646, 0, 0xE647, 0xE648, 0xE649, 0,
+ 0x6F75, 0, 0x3A65, 0, 0xE64A, 0, 0x6F76, 0x6F77,
+ 0, 0xE64B, 0x4B49, 0xE64C, 0, 0, 0, 0xE64D,
+ 0xE64E, 0xE64F, 0xE650, 0x414B, 0xE651, 0xE652, 0, 0x3024,
+};
+static const unsigned short utf8_to_euc_E998_x0213[] = {
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0x496C, 0xFA25, 0xE645, 0,
+ 0, 0x6F74, 0xE646, 0, 0xE647, 0xE648, 0xE649, 0,
+ 0x6F75, 0, 0x3A65, 0, 0xFB5E, 0, 0x6F76, 0x6F77,
+ 0, 0xE64B, 0x4B49, 0xFB5F, 0xFB60, 0, 0, 0xE64D,
+ 0xE64E, 0xE64F, 0xE650, 0x414B, 0xFB62, 0xE652, 0, 0x3024,
+};
+static const unsigned short utf8_to_euc_E999[] = {
+ 0x424B, 0xE653, 0x6F78, 0, 0x496D, 0, 0, 0,
+ 0, 0, 0, 0x6F7B, 0x6F79, 0x395F, 0, 0x6F7A,
+ 0x3842, 0, 0xE654, 0, 0xE655, 0, 0xE656, 0xE657,
+ 0xE658, 0, 0, 0x4A45, 0x6F7D, 0x7021, 0x6F7E, 0x7022,
+ 0, 0xE659, 0x3121, 0x3F58, 0x3D7C, 0x3459, 0x7023, 0,
+ 0, 0, 0x4766, 0, 0x7025, 0, 0xE65A, 0,
+ 0x3122, 0, 0x7024, 0x4444, 0xE65B, 0x4E4D, 0x462B, 0x6F7C,
+ 0x4E26, 0, 0x3831, 0xE65C, 0xE65D, 0x4D5B, 0xE65E, 0xE65F,
+};
+static const unsigned short utf8_to_euc_E999_x0213[] = {
+ 0x424B, 0xFB63, 0x6F78, 0, 0x496D, 0, 0, 0,
+ 0, 0, 0, 0x6F7B, 0x6F79, 0x395F, 0, 0x6F7A,
+ 0x3842, 0, 0xE654, 0, 0xE655, 0, 0xE656, 0xE657,
+ 0x7D5B, 0, 0, 0x4A45, 0x6F7D, 0x7021, 0x6F7E, 0x7022,
+ 0, 0xFB64, 0x3121, 0x3F58, 0x3D7C, 0x3459, 0x7023, 0,
+ 0, 0, 0x4766, 0, 0x7025, 0, 0xE65A, 0,
+ 0x3122, 0, 0x7024, 0x4444, 0xE65B, 0x4E4D, 0x462B, 0x6F7C,
+ 0x4E26, 0, 0x3831, 0xE65C, 0xE65D, 0x4D5B, 0xE65E, 0xE65F,
+};
+static const unsigned short utf8_to_euc_E99A[] = {
+ 0, 0xE660, 0xE661, 0xE662, 0xE663, 0x3679, 0x4E34, 0,
+ 0x3728, 0xE664, 0x4262, 0x6721, 0, 0x7026, 0x332C, 0x3F6F,
+ 0, 0xE665, 0, 0, 0x3356, 0x7028, 0xE666, 0x7029,
+ 0x7027, 0x3764, 0xE667, 0x3A5D, 0x3E63, 0xE668, 0, 0xE669,
+ 0x3123, 0, 0, 0x4E59, 0xE66A, 0xE66B, 0xE66C, 0x702B,
+ 0x6E2E, 0xE66D, 0x702A, 0, 0, 0, 0xE66E, 0xE66F,
+ 0x702E, 0x702C, 0x702D, 0xE670, 0x702F, 0, 0x7030, 0x4E6C,
+ 0x7031, 0x7032, 0xE671, 0x4049, 0x483B, 0, 0, 0,
+};
+static const unsigned short utf8_to_euc_E99A_x0213[] = {
+ 0, 0xE660, 0xFB66, 0xE662, 0x7D5C, 0x3679, 0x4E34, 0,
+ 0x3728, 0xE664, 0x4262, 0x6721, 0, 0x7026, 0x332C, 0x3F6F,
+ 0, 0xE665, 0, 0, 0x3356, 0x7028, 0xE666, 0x7029,
+ 0x7027, 0x3764, 0xFB68, 0x3A5D, 0x3E63, 0x7D5E, 0, 0xE669,
+ 0x3123, 0, 0, 0x4E59, 0x7D5F, 0x7D60, 0xE66C, 0x702B,
+ 0x6E2E, 0xFB6B, 0x702A, 0, 0, 0, 0xE66E, 0xFB6C,
+ 0x702E, 0x702C, 0x702D, 0xFB6D, 0x702F, 0, 0x7030, 0x4E6C,
+ 0x7031, 0x7032, 0xFB6E, 0x4049, 0x483B, 0xFB6F, 0, 0,
+};
+static const unsigned short utf8_to_euc_E99B[] = {
+ 0x3F7D, 0x3467, 0, 0, 0x4D3A, 0x326D, 0x3D38, 0x385B,
+ 0, 0x7035, 0xE672, 0x7034, 0x3B73, 0x7036, 0x7033, 0,
+ 0, 0x3B28, 0xE673, 0, 0, 0x703A, 0x6A2D, 0,
+ 0xE675, 0x5256, 0xE676, 0x3F77, 0x7038, 0xE677, 0xE678, 0xE679,
+ 0, 0, 0x4E25, 0x4671, 0, 0, 0, 0,
+ 0x312B, 0xE67A, 0x4063, 0x3C36, 0, 0, 0, 0xE67B,
+ 0x4A37, 0xE67C, 0x3140, 0, 0, 0, 0x4E6D, 0x4D6B,
+ 0, 0x703B, 0xE67D, 0x4545, 0, 0, 0, 0,
+};
+static const unsigned short utf8_to_euc_E99B_x0213[] = {
+ 0x3F7D, 0x3467, 0, 0, 0x4D3A, 0x326D, 0x3D38, 0x385B,
+ 0, 0x7035, 0xE672, 0x7034, 0x3B73, 0x7036, 0x7033, 0,
+ 0, 0x3B28, 0x7D61, 0, 0, 0x703A, 0x6A2D, 0,
+ 0xFB72, 0x5256, 0xFB73, 0x3F77, 0x7038, 0xFB74, 0x7D62, 0xE679,
+ 0, 0, 0x4E25, 0x4671, 0, 0, 0, 0,
+ 0x312B, 0x7D64, 0x4063, 0x3C36, 0, 0, 0, 0x7D65,
+ 0x4A37, 0xE67C, 0x3140, 0, 0, 0, 0x4E6D, 0x4D6B,
+ 0, 0x703B, 0xE67D, 0x4545, 0, 0, 0, 0,
+};
+static const unsigned short utf8_to_euc_E99C[] = {
+ 0x3C7B, 0, 0xE67E, 0xE721, 0x703C, 0xE722, 0x703D, 0x3F4C,
+ 0x703E, 0xE723, 0x4E6E, 0, 0, 0x7039, 0x7040, 0x7042,
+ 0, 0x7041, 0, 0x703F, 0, 0, 0x7043, 0,
+ 0, 0x7044, 0xE724, 0xE725, 0x417A, 0xE726, 0x3262, 0,
+ 0, 0xE727, 0xE728, 0xE729, 0x7045, 0, 0, 0x4C38,
+ 0xE72A, 0, 0x7046, 0, 0, 0, 0, 0,
+ 0x7047, 0xE72B, 0x4F2A, 0xE72C, 0, 0, 0, 0,
+ 0x5B31, 0x7048, 0, 0xF474, 0, 0x7049, 0x704A, 0,
+};
+static const unsigned short utf8_to_euc_E99C_x0213[] = {
+ 0x3C7B, 0, 0xE67E, 0xE721, 0x703C, 0xE722, 0x703D, 0x3F4C,
+ 0x703E, 0xE723, 0x4E6E, 0, 0, 0x7039, 0x7040, 0x7042,
+ 0, 0x7041, 0, 0x703F, 0xFB76, 0, 0x7043, 0,
+ 0, 0x7044, 0xE724, 0xE725, 0x417A, 0xE726, 0x3262, 0,
+ 0, 0xE727, 0xE728, 0xFB77, 0x7045, 0, 0, 0x4C38,
+ 0xE72A, 0, 0x7046, 0, 0, 0, 0, 0,
+ 0x7047, 0xE72B, 0x4F2A, 0x7D66, 0, 0, 0xFB79, 0,
+ 0x5B31, 0x7048, 0, 0x7D67, 0, 0x7049, 0x704A, 0,
+};
+static const unsigned short utf8_to_euc_E99D[] = {
+ 0, 0xE72D, 0x704E, 0xE72E, 0x704B, 0, 0x704C, 0,
+ 0x704D, 0x704F, 0xE72F, 0, 0, 0xF475, 0xE730, 0xE731,
+ 0, 0xF476, 0x4044, 0, 0, 0xE732, 0x4C77, 0xE733,
+ 0xE734, 0x4045, 0xE735, 0xE736, 0x7050, 0, 0x4873, 0,
+ 0x7051, 0x7353, 0x4C4C, 0xE737, 0x7052, 0, 0x7053, 0xE738,
+ 0x7054, 0x3357, 0xE739, 0x7056, 0, 0x3F59, 0xE73A, 0,
+ 0, 0x7057, 0, 0xE73B, 0x3724, 0, 0xE73C, 0xE73D,
+ 0xE73E, 0x7058, 0x705C, 0xE73F, 0x705A, 0xE740, 0, 0xE741,
+};
+static const unsigned short utf8_to_euc_E99D_x0213[] = {
+ 0, 0xFB7A, 0x704E, 0xE72E, 0x704B, 0, 0x704C, 0xFB7B,
+ 0x704D, 0x704F, 0xE72F, 0, 0, 0x7D68, 0x7D69, 0x7D6A,
+ 0, 0xF476, 0x4044, 0, 0, 0xFB7C, 0x4C77, 0xFB7D,
+ 0xE734, 0x4045, 0x7D6B, 0xFB7E, 0x7050, 0, 0x4873, 0,
+ 0x7051, 0x7353, 0x4C4C, 0xE737, 0x7052, 0, 0x7053, 0xE738,
+ 0x7054, 0x3357, 0xFC21, 0x7056, 0, 0x3F59, 0x7D6C, 0,
+ 0, 0x7057, 0, 0x7D6D, 0x3724, 0, 0xE73C, 0xE73D,
+ 0xE73E, 0x7058, 0x705C, 0xE73F, 0x705A, 0xE740, 0, 0xE741,
+};
+static const unsigned short utf8_to_euc_E99E[] = {
+ 0xE742, 0x705B, 0, 0, 0x3373, 0x7059, 0x705D, 0,
+ 0, 0xE743, 0, 0x705E, 0, 0x3048, 0, 0x705F,
+ 0x7060, 0, 0, 0, 0, 0xE744, 0xE745, 0xE746,
+ 0x3E64, 0xE747, 0xE748, 0, 0x7061, 0, 0xE749, 0xE74A,
+ 0x3547, 0, 0xE74B, 0x7064, 0, 0, 0x7063, 0,
+ 0x7062, 0, 0, 0x6B71, 0xE74C, 0x4A5C, 0xE74D, 0,
+ 0, 0xE74E, 0xE74F, 0x7065, 0x7066, 0xE750, 0xE751, 0,
+ 0xE752, 0xE753, 0xE754, 0, 0xE755, 0, 0xE756, 0xE757,
+};
+static const unsigned short utf8_to_euc_E99E_x0213[] = {
+ 0xE742, 0x705B, 0, 0, 0x3373, 0x7059, 0x705D, 0,
+ 0, 0xE743, 0, 0x705E, 0, 0x3048, 0, 0x705F,
+ 0x7060, 0, 0, 0, 0, 0x7D6E, 0xFC24, 0xE746,
+ 0x3E64, 0xE747, 0xFC25, 0, 0x7061, 0, 0xFC26, 0xE74A,
+ 0x3547, 0, 0xFC27, 0x7064, 0, 0, 0x7063, 0,
+ 0x7062, 0, 0, 0x6B71, 0xE74C, 0x4A5C, 0x7D6F, 0,
+ 0, 0xFC28, 0xFC29, 0x7065, 0x7066, 0xE750, 0xE751, 0,
+ 0xE752, 0xE753, 0x7D70, 0, 0xE755, 0, 0xFC2A, 0xE757,
+};
+static const unsigned short utf8_to_euc_E99F[] = {
+ 0, 0xE758, 0, 0x7067, 0xE759, 0xE75A, 0x7068, 0xE75B,
+ 0x7069, 0xE75C, 0xE75D, 0x706A, 0xE75E, 0xE75F, 0xE760, 0,
+ 0xE761, 0xE762, 0, 0x345A, 0xE763, 0, 0, 0xE764,
+ 0xE765, 0xE766, 0, 0xE76A, 0x706B, 0xE767, 0xE768, 0,
+ 0xE769, 0xE76B, 0, 0, 0xE76C, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0x706C, 0x4723, 0xE76D,
+ 0, 0xE76E, 0x706E, 0x323B, 0xE76F, 0x7071, 0x7070, 0xE770,
+ 0xE771, 0, 0xE772, 0x3124, 0, 0, 0, 0x3641,
+};
+static const unsigned short utf8_to_euc_E99F_x0213[] = {
+ 0, 0x7D71, 0, 0x7067, 0xE759, 0xE75A, 0x7068, 0xE75B,
+ 0x7069, 0x7D72, 0xE75D, 0x706A, 0xFC2B, 0xE75F, 0xE760, 0,
+ 0xE761, 0xFC2C, 0, 0x345A, 0xFC2D, 0, 0, 0xE764,
+ 0xFC2E, 0xFC2F, 0, 0x7D74, 0x706B, 0xE767, 0x7D73, 0,
+ 0xE769, 0xFC30, 0, 0, 0xE76C, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0x706C, 0x4723, 0xE76D,
+ 0, 0xFC31, 0x706E, 0x323B, 0x7D75, 0x7071, 0x7070, 0xE770,
+ 0xE771, 0, 0xE772, 0x3124, 0, 0, 0, 0x3641,
+};
+static const unsigned short utf8_to_euc_E9A0[] = {
+ 0, 0x4A47, 0x443A, 0x3A22, 0, 0x3960, 0x3D67, 0xE773,
+ 0x3F5C, 0, 0xE774, 0, 0x7073, 0xE776, 0xE777, 0x7072,
+ 0x4D42, 0x3468, 0x4852, 0x465C, 0xE778, 0, 0xE779, 0x3F7C,
+ 0x4E4E, 0xE775, 0x375B, 0, 0xE77A, 0, 0xE77B, 0,
+ 0xE77C, 0x7076, 0, 0xE77D, 0x7075, 0xE828, 0xE77E, 0,
+ 0, 0, 0, 0xE821, 0x4B4B, 0x462C, 0xE822, 0xE823,
+ 0xE824, 0, 0xE825, 0xE826, 0x3150, 0xE827, 0, 0x7077,
+ 0x7074, 0, 0, 0x4951, 0x4D6A, 0x7078, 0xE829, 0,
+};
+static const unsigned short utf8_to_euc_E9A0_x0213[] = {
+ 0, 0x4A47, 0x443A, 0x3A22, 0xFC32, 0x3960, 0x3D67, 0xE773,
+ 0x3F5C, 0, 0x7D77, 0, 0x7073, 0xFC33, 0xFC34, 0x7072,
+ 0x4D42, 0x3468, 0x4852, 0x465C, 0xFC35, 0, 0xFC36, 0x3F7C,
+ 0x4E4E, 0xE775, 0x375B, 0, 0xE77A, 0, 0x7D78, 0,
+ 0xE77C, 0x7076, 0, 0xFC39, 0x7075, 0xFC3C, 0xE77E, 0,
+ 0, 0, 0, 0x7D79, 0x4B4B, 0x462C, 0xE822, 0xE823,
+ 0x7D7A, 0, 0xFC3A, 0xFC3B, 0x3150, 0xE827, 0, 0x7077,
+ 0x7074, 0, 0, 0x4951, 0x4D6A, 0x7078, 0xE829, 0,
+};
+static const unsigned short utf8_to_euc_E9A1[] = {
+ 0, 0, 0, 0, 0xE82A, 0, 0x7079, 0xE82B,
+ 0, 0, 0xE82C, 0x707B, 0x426A, 0x335B, 0x335C, 0x707A,
+ 0, 0xE82D, 0xE82E, 0xE82F, 0x3469, 0x3832, 0xE830, 0xE831,
+ 0x346A, 0xE832, 0xE833, 0x453F, 0, 0, 0x4E60, 0,
+ 0, 0, 0xE834, 0xE835, 0, 0xE836, 0xE837, 0x385C,
+ 0, 0, 0xE838, 0x707C, 0xE839, 0, 0, 0x707D,
+ 0x707E, 0x7121, 0, 0x7123, 0x7122, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+};
+static const unsigned short utf8_to_euc_E9A1_x0213[] = {
+ 0, 0, 0, 0, 0xE82A, 0, 0x7079, 0xFC3D,
+ 0, 0, 0xE82C, 0x707B, 0x426A, 0x335B, 0x335C, 0x707A,
+ 0, 0xE82D, 0x7D7C, 0x7D7D, 0x3469, 0x3832, 0x7D7E, 0x7E21,
+ 0x346A, 0x7E22, 0x7E23, 0x453F, 0, 0, 0x4E60, 0,
+ 0, 0, 0xE834, 0xE835, 0, 0x7E25, 0xFC3E, 0x385C,
+ 0, 0, 0xE838, 0x707C, 0x7E26, 0, 0, 0x707D,
+ 0x707E, 0x7121, 0, 0x7123, 0x7122, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+};
+static const unsigned short utf8_to_euc_E9A2[] = {
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0x4977, 0, 0x7124, 0xE83A, 0, 0xE83B, 0xE83C, 0x7125,
+ 0xE83D, 0x7126, 0, 0, 0xE83E, 0, 0x7127, 0xE83F,
+ 0xE840, 0, 0xE841, 0xE842, 0, 0, 0, 0xE843,
+};
+static const unsigned short utf8_to_euc_E9A2_x0213[] = {
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0x4977, 0, 0x7124, 0xFC3F, 0, 0xFC40, 0xE83C, 0x7125,
+ 0xFC41, 0x7126, 0, 0, 0xE83E, 0, 0x7127, 0xFC43,
+ 0xFC44, 0, 0x7E27, 0xFC45, 0xFC46, 0, 0, 0xFC47,
+};
+static const unsigned short utf8_to_euc_E9A3[] = {
+ 0, 0, 0xE844, 0x7129, 0x7128, 0xE845, 0x712A, 0,
+ 0xE846, 0, 0, 0, 0xE847, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0x4874, 0x664C, 0, 0, 0x3F29,
+ 0, 0xE848, 0x3532, 0xE849, 0, 0xE84A, 0xE84B, 0xE84C,
+ 0, 0x712B, 0xE84D, 0x712C, 0, 0x522C, 0x5D3B, 0x4853,
+ 0, 0, 0x307B, 0xE84E, 0x303B, 0, 0xE84F, 0,
+ 0, 0, 0, 0, 0x3B74, 0x4B30, 0x3E7E, 0,
+};
+static const unsigned short utf8_to_euc_E9A3_x0213[] = {
+ 0, 0, 0xFC48, 0x7129, 0x7128, 0xE845, 0x712A, 0xFC49,
+ 0x7E28, 0, 0, 0xFC4A, 0xE847, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0x4874, 0x664C, 0, 0, 0x3F29,
+ 0xFC4B, 0xFC4D, 0x3532, 0xFC4E, 0, 0xFC4F, 0xE84B, 0x7E29,
+ 0, 0x712B, 0xFC50, 0x712C, 0, 0x522C, 0x5D3B, 0x4853,
+ 0xFC51, 0xFC52, 0x307B, 0xFC53, 0x303B, 0, 0xE84F, 0,
+ 0, 0, 0, 0, 0x3B74, 0x4B30, 0x3E7E, 0,
+};
+static const unsigned short utf8_to_euc_E9A4[] = {
+ 0, 0, 0xE850, 0x712D, 0, 0x4C5F, 0, 0xE851,
+ 0xE852, 0x712E, 0x4D5C, 0, 0x3142, 0, 0, 0,
+ 0x3B41, 0xE853, 0x712F, 0x326E, 0x7130, 0xE854, 0xE855, 0xE856,
+ 0x7131, 0, 0xE857, 0xE858, 0xE859, 0x7133, 0x7134, 0xE85A,
+ 0x7136, 0x7132, 0xE85B, 0, 0x7135, 0, 0xE85C, 0xE85D,
+ 0x345B, 0, 0, 0xE85E, 0x7137, 0, 0x7138, 0,
+ 0, 0xE85F, 0xE860, 0xE861, 0xE862, 0xE863, 0, 0,
+ 0, 0xE864, 0xE865, 0xE866, 0xE867, 0x7139, 0x713A, 0,
+};
+static const unsigned short utf8_to_euc_E9A4_x0213[] = {
+ 0, 0, 0xE850, 0x712D, 0, 0x4C5F, 0, 0xE851,
+ 0xFC54, 0x712E, 0x4D5C, 0, 0x3142, 0, 0, 0,
+ 0x3B41, 0xE853, 0x712F, 0x326E, 0x7130, 0xE854, 0xFC57, 0xFC58,
+ 0x7131, 0, 0xFC5A, 0xFC5B, 0xFC5C, 0x7133, 0x7134, 0xE85A,
+ 0x7136, 0x7132, 0xE85B, 0, 0x7135, 0, 0xE85C, 0xE85D,
+ 0x345B, 0, 0, 0xE85E, 0x7137, 0, 0x7138, 0,
+ 0, 0xFC5E, 0xFC5F, 0xFC60, 0xE862, 0xE863, 0, 0,
+ 0, 0xE864, 0xFC61, 0xFC62, 0xFC63, 0x7139, 0x713A, 0,
+};
+static const unsigned short utf8_to_euc_E9A5[] = {
+ 0xE868, 0xE869, 0x713B, 0, 0, 0x713D, 0xE86A, 0xE86B,
+ 0xE86C, 0x713C, 0, 0x713F, 0x7142, 0xE86D, 0xE86E, 0,
+ 0x713E, 0x7140, 0x7141, 0, 0xE86F, 0x7143, 0, 0x3642,
+ 0xE870, 0xE871, 0, 0xE872, 0xE873, 0, 0xE874, 0xE875,
+ 0xE876, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+};
+static const unsigned short utf8_to_euc_E9A5_x0213[] = {
+ 0xFC64, 0xFC65, 0x713B, 0, 0, 0x713D, 0xFC66, 0xE86B,
+ 0xE86C, 0x713C, 0, 0x713F, 0x7142, 0xFC67, 0xFC68, 0,
+ 0x713E, 0x7140, 0x7141, 0, 0xE86F, 0x7143, 0, 0x3642,
+ 0x7E2A, 0xE871, 0, 0xE872, 0xFC69, 0, 0xE874, 0xFC6A,
+ 0xFC6B, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+};
+static const unsigned short utf8_to_euc_E9A6[] = {
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0x3C73, 0x7144,
+ 0x7145, 0x3961, 0, 0xE877, 0, 0xE878, 0xF47A, 0xE879,
+ 0, 0, 0, 0, 0, 0x7146, 0xE87A, 0,
+ 0x333E, 0, 0, 0, 0x474F, 0x7147, 0x7148, 0,
+ 0xE87B, 0xE87C, 0xE87D, 0x435A, 0x466B, 0xE87E, 0, 0,
+ 0, 0xE921, 0xE922, 0, 0x7149, 0xE923, 0, 0xE924,
+};
+static const unsigned short utf8_to_euc_E9A6_x0213[] = {
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0x3C73, 0x7144,
+ 0x7145, 0x3961, 0, 0xE877, 0, 0xE878, 0x7E2B, 0xE879,
+ 0, 0, 0, 0xFC6C, 0, 0x7146, 0xFC6D, 0,
+ 0x333E, 0, 0, 0, 0x474F, 0x7147, 0x7148, 0,
+ 0xE87B, 0xE87C, 0xE87D, 0x435A, 0x466B, 0xE87E, 0, 0,
+ 0, 0xFC6E, 0xE922, 0, 0x7149, 0xFC6F, 0, 0xFC70,
+};
+static const unsigned short utf8_to_euc_E9A7[] = {
+ 0, 0x477D, 0, 0xE925, 0x424C, 0x3158, 0x366E, 0,
+ 0x366F, 0xE926, 0, 0, 0, 0, 0, 0,
+ 0x4373, 0x714E, 0x3670, 0xE927, 0xE928, 0x326F, 0, 0,
+ 0x714D, 0xE929, 0xE92A, 0x714B, 0xE92B, 0x714C, 0xE92C, 0x714A,
+ 0, 0, 0x7158, 0, 0, 0, 0, 0xE92D,
+ 0, 0, 0xE92E, 0xE92F, 0xE930, 0x714F, 0x7150, 0,
+ 0xE931, 0x7151, 0x7152, 0, 0xE932, 0xE933, 0, 0,
+ 0x7154, 0xE934, 0, 0x7153, 0, 0xE935, 0xE936, 0x3D59,
+};
+static const unsigned short utf8_to_euc_E9A7_x0213[] = {
+ 0, 0x477D, 0, 0xFC71, 0x424C, 0x3158, 0x366E, 0,
+ 0x366F, 0xFC72, 0, 0, 0, 0, 0, 0,
+ 0x4373, 0x714E, 0x3670, 0xE927, 0xFC73, 0x326F, 0, 0,
+ 0x714D, 0xFC74, 0xE92A, 0x714B, 0xE92B, 0x714C, 0xFC75, 0x714A,
+ 0, 0, 0x7158, 0, 0, 0, 0, 0xE92D,
+ 0, 0, 0xE92E, 0xE92F, 0xE930, 0x714F, 0x7150, 0,
+ 0xFC77, 0x7151, 0x7152, 0, 0xE932, 0xE933, 0, 0,
+ 0x7154, 0xFC78, 0, 0x7153, 0xFC79, 0xE935, 0xE936, 0x3D59,
+};
+static const unsigned short utf8_to_euc_E9A8[] = {
+ 0, 0x7155, 0xE937, 0xE938, 0xE939, 0x7157, 0, 0,
+ 0, 0, 0, 0xE93A, 0xE93B, 0, 0x3533, 0x7156,
+ 0xE93C, 0xE93D, 0x417B, 0x3833, 0, 0, 0xE93E, 0,
+ 0, 0x7159, 0, 0, 0, 0, 0xE93F, 0,
+ 0xE940, 0, 0xE941, 0xE942, 0xE943, 0, 0, 0xE944,
+ 0x424D, 0, 0, 0x715A, 0, 0xE945, 0xE946, 0,
+ 0x462D, 0, 0, 0xE947, 0, 0xE948, 0xE949, 0x715B,
+ 0xE94A, 0, 0, 0, 0, 0, 0x7160, 0,
+};
+static const unsigned short utf8_to_euc_E9A8_x0213[] = {
+ 0, 0x7155, 0x7E2C, 0x7E2D, 0xE939, 0x7157, 0, 0,
+ 0, 0, 0xFC7A, 0xE93A, 0xE93B, 0, 0x3533, 0x7156,
+ 0xE93C, 0xFC7B, 0x417B, 0x3833, 0, 0, 0xFC7C, 0,
+ 0, 0x7159, 0xFC7D, 0, 0, 0, 0xE93F, 0,
+ 0xFC7E, 0, 0xE941, 0xE942, 0x7E2E, 0, 0, 0xE944,
+ 0x424D, 0, 0, 0x715A, 0, 0x7E2F, 0x7E30, 0,
+ 0x462D, 0xFD21, 0, 0xE947, 0, 0xE948, 0xFD22, 0x715B,
+ 0x7E31, 0, 0, 0, 0, 0, 0x7160, 0,
+};
+static const unsigned short utf8_to_euc_E9A9[] = {
+ 0x715E, 0xE94C, 0x715D, 0x715F, 0xE94D, 0x715C, 0, 0xE94B,
+ 0, 0, 0xE94E, 0xE94F, 0xE950, 0x7162, 0xE951, 0,
+ 0, 0xE952, 0, 0, 0xE953, 0x7161, 0xE954, 0x7164,
+ 0, 0, 0x3643, 0x7163, 0, 0xE955, 0, 0x7165,
+ 0, 0, 0x7166, 0, 0x7168, 0x7167, 0, 0,
+ 0, 0x7169, 0x716B, 0x716A, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+};
+static const unsigned short utf8_to_euc_E9A9_x0213[] = {
+ 0x715E, 0xE94C, 0x715D, 0x715F, 0xFD23, 0x715C, 0, 0xE94B,
+ 0, 0, 0x7E32, 0xE94F, 0xFD24, 0x7162, 0x7E33, 0,
+ 0, 0xE952, 0x7E34, 0, 0xE953, 0x7161, 0xE954, 0x7164,
+ 0xFD25, 0, 0x3643, 0x7163, 0, 0xE955, 0, 0x7165,
+ 0, 0, 0x7166, 0, 0x7168, 0x7167, 0, 0,
+ 0, 0x7169, 0x716B, 0x716A, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+};
+static const unsigned short utf8_to_euc_E9AA[] = {
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0x397C, 0, 0xE956, 0, 0xE957, 0x716C, 0xE958, 0xE959,
+ 0x716D, 0, 0xE95A, 0, 0xE95B, 0xE95C, 0xE95D, 0,
+ 0x333C, 0xE95E, 0, 0xE95F, 0x716E, 0, 0xE960, 0xE961,
+};
+static const unsigned short utf8_to_euc_E9AA_x0213[] = {
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0x397C, 0, 0xE956, 0, 0xE957, 0x716C, 0xE958, 0xFD27,
+ 0x716D, 0, 0xE95A, 0, 0xE95B, 0xE95C, 0x7E35, 0xFD29,
+ 0x333C, 0xFD2B, 0, 0xE95F, 0x716E, 0, 0xE960, 0xE961,
+};
+static const unsigned short utf8_to_euc_E9AB[] = {
+ 0x716F, 0xE962, 0, 0xE963, 0x3F71, 0, 0xE964, 0,
+ 0xE965, 0, 0, 0, 0, 0, 0xE966, 0x7170,
+ 0xE967, 0x7171, 0xE968, 0x7172, 0x7173, 0xE969, 0xE96A, 0xE96B,
+ 0x3962, 0xF47B, 0, 0xE96C, 0xE96D, 0, 0x7174, 0x7175,
+ 0xE96E, 0, 0x7176, 0x7177, 0xE96F, 0xE970, 0x7178, 0xE971,
+ 0, 0xE972, 0x4831, 0x717A, 0xE973, 0x4926, 0x717B, 0x7179,
+ 0, 0x717D, 0xE974, 0xE975, 0x717C, 0xE976, 0, 0x717E,
+ 0, 0xE977, 0xE978, 0x7221, 0, 0xE979, 0, 0xE97A,
+};
+static const unsigned short utf8_to_euc_E9AB_x0213[] = {
+ 0x716F, 0x7E36, 0, 0x7E37, 0x3F71, 0, 0xFD2D, 0,
+ 0xE965, 0, 0, 0, 0, 0, 0x7E38, 0x7170,
+ 0xFD2E, 0x7171, 0xFD2F, 0x7172, 0x7173, 0xFD30, 0x7E39, 0xE96B,
+ 0x3962, 0xF47B, 0, 0xE96C, 0xFD32, 0, 0x7174, 0x7175,
+ 0xFD33, 0, 0x7176, 0x7177, 0xE96F, 0xFD34, 0x7178, 0xE971,
+ 0, 0xFD35, 0x4831, 0x717A, 0xE973, 0x4926, 0x717B, 0x7179,
+ 0, 0x717D, 0xE974, 0xE975, 0x717C, 0xE976, 0, 0x717E,
+ 0, 0x7E3A, 0xE978, 0x7221, 0, 0xE979, 0, 0xE97A,
+};
+static const unsigned short utf8_to_euc_E9AC[] = {
+ 0xE97B, 0xE97C, 0xE97D, 0xE97E, 0xEA21, 0xEA22, 0x7222, 0,
+ 0xEA23, 0xEA24, 0, 0xEA25, 0xEA26, 0xEA27, 0xEA28, 0,
+ 0xEA29, 0, 0xEA2A, 0, 0, 0, 0xEA2B, 0,
+ 0x7223, 0xEA2C, 0x7224, 0xEA2D, 0xEA2E, 0, 0, 0x7225,
+ 0xEA2F, 0, 0x7226, 0x7227, 0, 0x7228, 0xEA30, 0x7229,
+ 0x722A, 0x722B, 0x722C, 0xEA31, 0, 0xEA32, 0x722D, 0x722E,
+ 0, 0x5D35, 0x722F, 0xEA33, 0xEA34, 0xEA35, 0, 0xEA36,
+ 0, 0xEA37, 0xEA38, 0x6478, 0x3534, 0xEA39, 0, 0,
+};
+static const unsigned short utf8_to_euc_E9AC_x0213[] = {
+ 0xE97B, 0xE97C, 0x7E3B, 0xFD36, 0xEA21, 0xEA22, 0x7222, 0,
+ 0x7E3C, 0xEA24, 0, 0xEA25, 0xFD37, 0xEA27, 0xEA28, 0,
+ 0xFD38, 0, 0xFD39, 0, 0, 0, 0xFD3A, 0,
+ 0x7223, 0xEA2C, 0x7224, 0xEA2D, 0xFD3B, 0, 0, 0x7225,
+ 0x7E3D, 0, 0x7226, 0x7227, 0, 0x7228, 0xEA30, 0x7229,
+ 0x722A, 0x722B, 0x722C, 0xFD3C, 0, 0x7E3F, 0x722D, 0x722E,
+ 0, 0x5D35, 0x722F, 0xFD3D, 0xEA34, 0xEA35, 0, 0xEA36,
+ 0, 0xEA37, 0xEA38, 0x6478, 0x3534, 0xFD3E, 0, 0,
+};
+static const unsigned short utf8_to_euc_E9AD[] = {
+ 0, 0x3321, 0x3A32, 0x7231, 0x7230, 0x4C25, 0, 0,
+ 0xEA3A, 0, 0, 0xEA3B, 0xEA3C, 0x7233, 0x7234, 0x7232,
+ 0, 0x7235, 0, 0, 0x4B62, 0xEA3D, 0xEA3E, 0xEA3F,
+ 0x7236, 0, 0x357B, 0xEA40, 0, 0, 0xEA41, 0,
+ 0, 0xEA42, 0, 0xEA43, 0, 0xEA44, 0xEA45, 0,
+ 0xEA46, 0, 0xEA47, 0xEA48, 0xEA49, 0xEA4A, 0xEA4B, 0x4F25,
+ 0, 0, 0xF47C, 0xEA4C, 0x7237, 0xEA4D, 0, 0xEA4E,
+ 0xEA4F, 0xEA50, 0, 0, 0, 0, 0, 0xEA51,
+};
+static const unsigned short utf8_to_euc_E9AD_x0213[] = {
+ 0, 0x3321, 0x3A32, 0x7231, 0x7230, 0x4C25, 0, 0,
+ 0xEA3A, 0, 0, 0xFD40, 0xEA3C, 0x7233, 0x7234, 0x7232,
+ 0, 0x7235, 0, 0, 0x4B62, 0xEA3D, 0xEA3E, 0xEA3F,
+ 0x7236, 0, 0x357B, 0xEA40, 0, 0, 0x7E40, 0,
+ 0, 0xEA42, 0, 0xFD41, 0, 0xFD42, 0x7E42, 0,
+ 0xEA46, 0, 0xEA47, 0xFD43, 0xFD44, 0xEA4A, 0xEA4B, 0x4F25,
+ 0, 0, 0x7E43, 0xFD45, 0x7237, 0x7E44, 0xFD46, 0xFD47,
+ 0xEA4F, 0x7E41, 0, 0, 0, 0, 0, 0xEA51,
+};
+static const unsigned short utf8_to_euc_E9AE[] = {
+ 0xEA52, 0, 0, 0x7239, 0xEA53, 0xEA54, 0xEA55, 0xEA56,
+ 0, 0xEA57, 0xEA58, 0xEA59, 0, 0xEA5A, 0x303E, 0xEA5B,
+ 0xEA5C, 0x723A, 0x4A2B, 0x7238, 0xEA5D, 0, 0x723B, 0x723C,
+ 0, 0, 0xEA5E, 0, 0, 0xEA5F, 0xEA60, 0x723D,
+ 0x723E, 0, 0, 0, 0, 0, 0xEA61, 0xEA62,
+ 0x723F, 0xEA63, 0x4B6E, 0x3B2D, 0xEA64, 0x3A7A, 0x412F, 0,
+ 0xEA65, 0xEA66, 0xEA67, 0, 0x7240, 0, 0, 0xEA68,
+ 0xEA69, 0x7243, 0, 0xEA6A, 0xEA6B, 0, 0xEA6C, 0xEA6D,
+};
+static const unsigned short utf8_to_euc_E9AE_x0213[] = {
+ 0xEA52, 0, 0, 0x7239, 0x7E45, 0xEA54, 0xEA55, 0xEA56,
+ 0, 0xEA57, 0x7E46, 0xEA59, 0, 0xEA5A, 0x303E, 0x7E47,
+ 0xEA5C, 0x723A, 0x4A2B, 0x7238, 0xEA5D, 0, 0x723B, 0x723C,
+ 0, 0, 0xEA5E, 0, 0, 0xEA5F, 0x7E48, 0x723D,
+ 0x723E, 0, 0, 0, 0, 0, 0xFD48, 0x7E49,
+ 0x723F, 0xEA63, 0x4B6E, 0x3B2D, 0xFD49, 0x3A7A, 0x412F, 0,
+ 0xEA65, 0xFD4A, 0xFD4D, 0, 0x7240, 0, 0, 0xEA68,
+ 0xFD4E, 0x7243, 0, 0xEA6A, 0xEA6B, 0, 0xFD4F, 0xEA6D,
+};
+static const unsigned short utf8_to_euc_E9AF[] = {
+ 0x7241, 0xEA6E, 0, 0, 0, 0, 0x7244, 0xEA6F,
+ 0xEA70, 0x3871, 0x7242, 0, 0, 0, 0xEA71, 0x7245,
+ 0xEA72, 0x7246, 0x7247, 0, 0x724B, 0, 0x3B2A, 0xEA73,
+ 0xEA74, 0, 0, 0x4264, 0, 0xEA75, 0, 0xEA76,
+ 0, 0x724C, 0x7249, 0x7248, 0x724A, 0xEA77, 0, 0xEA78,
+ 0x375F, 0, 0xEA79, 0xEA7A, 0, 0, 0, 0xEA7B,
+ 0x7250, 0x724F, 0x724E, 0xEA7C, 0, 0x3033, 0, 0xEA7D,
+ 0xEA7E, 0xEB21, 0xEB22, 0, 0, 0xEB23, 0, 0xEB24,
+};
+static const unsigned short utf8_to_euc_E9AF_x0213[] = {
+ 0x7241, 0x7E4A, 0, 0, 0, 0, 0x7244, 0xFD50,
+ 0xEA70, 0x3871, 0x7242, 0, 0, 0, 0x7E4B, 0x7245,
+ 0xEA72, 0x7246, 0x7247, 0, 0x724B, 0, 0x3B2A, 0xEA73,
+ 0xFD52, 0, 0, 0x4264, 0, 0xFD53, 0, 0xEA76,
+ 0, 0x724C, 0x7249, 0x7248, 0x724A, 0x7E4C, 0, 0xFD54,
+ 0x375F, 0, 0xFD55, 0xFD56, 0, 0, 0xFD58, 0xFD57,
+ 0x7250, 0x724F, 0x724E, 0xFD51, 0, 0x3033, 0, 0xFD5C,
+ 0x7E4D, 0xEB21, 0xFD5A, 0, 0, 0x7E4E, 0, 0xEB24,
+};
+static const unsigned short utf8_to_euc_E9B0[] = {
+ 0xEB25, 0, 0xEB26, 0, 0x725A, 0, 0x7256, 0,
+ 0x7257, 0x7253, 0x7259, 0xEB27, 0x7255, 0x3362, 0, 0xEB28,
+ 0x4F4C, 0xEB29, 0x7258, 0x7254, 0x7252, 0x7251, 0xEB2A, 0,
+ 0xEB2B, 0xEB2C, 0xEB2D, 0x725C, 0xEB2E, 0, 0xEB2F, 0,
+ 0, 0x725F, 0xEB30, 0xEB31, 0x725E, 0x725D, 0xEB32, 0xEB33,
+ 0xEB34, 0xEB35, 0xEB36, 0, 0, 0x4949, 0x725B, 0x3073,
+ 0x7260, 0xEB37, 0x7262, 0, 0, 0xEB38, 0xEB39, 0xEB3A,
+ 0, 0x336F, 0x724D, 0x3137, 0, 0xEB3B, 0x7264, 0,
+};
+static const unsigned short utf8_to_euc_E9B0_x0213[] = {
+ 0x7E4F, 0, 0xEB26, 0, 0x725A, 0, 0x7256, 0,
+ 0x7257, 0x7253, 0x7259, 0xEB27, 0x7255, 0x3362, 0, 0xEB28,
+ 0x4F4C, 0xEB29, 0x7258, 0x7254, 0x7252, 0x7251, 0xFD5E, 0,
+ 0xFD5F, 0xFD60, 0xFD61, 0x725C, 0xEB2E, 0xFD62, 0xEB2F, 0,
+ 0, 0x725F, 0xFD63, 0x7E50, 0x725E, 0x725D, 0xEB32, 0xFD64,
+ 0xEB34, 0xFD65, 0xFD66, 0, 0, 0x4949, 0x725B, 0x3073,
+ 0x7260, 0xFD68, 0x7262, 0, 0, 0xEB38, 0xFD69, 0xFD6A,
+ 0, 0x336F, 0x724D, 0x3137, 0, 0xEB3B, 0x7264, 0,
+};
+static const unsigned short utf8_to_euc_E9B1[] = {
+ 0, 0xEB3C, 0, 0xEB3D, 0xEB3E, 0xEB3F, 0x7263, 0x7261,
+ 0x432D, 0xEB40, 0xEB41, 0, 0, 0, 0xEB42, 0xEB43,
+ 0xEB44, 0, 0x4B70, 0xEB45, 0xEB46, 0, 0xEB47, 0x4E5A,
+ 0xEB48, 0, 0x7265, 0xEB49, 0xEB50, 0xEB4A, 0xEB4B, 0xEB4C,
+ 0x7266, 0, 0, 0xEB4D, 0, 0, 0, 0x7267,
+ 0xEB52, 0xEB4E, 0xEB4F, 0xEB51, 0, 0, 0xEB53, 0,
+ 0xEB54, 0, 0xEB55, 0, 0, 0xEB56, 0x7268, 0xEB57,
+ 0x7269, 0, 0, 0xEB58, 0, 0, 0, 0,
+};
+static const unsigned short utf8_to_euc_E9B1_x0213[] = {
+ 0, 0x7E51, 0, 0xEB3D, 0xEB3E, 0xFD6B, 0x7263, 0x7261,
+ 0x432D, 0xFD6E, 0xFD6F, 0, 0, 0, 0xEB42, 0x7E52,
+ 0x7E53, 0, 0x4B70, 0x7E54, 0xFD71, 0, 0xEB47, 0x4E5A,
+ 0xFD72, 0, 0x7265, 0xFD73, 0xFD6C, 0xFD74, 0xEB4B, 0xFD75,
+ 0x7266, 0, 0, 0x7E55, 0, 0x7E56, 0, 0x7267,
+ 0xEB52, 0xFD76, 0xFD77, 0xFD78, 0, 0xFD79, 0xFD7A, 0,
+ 0xFD7B, 0, 0xFD7C, 0, 0, 0xFD7D, 0x7268, 0x7E57,
+ 0x7269, 0, 0xFD7E, 0xEB58, 0, 0, 0, 0,
+};
+static const unsigned short utf8_to_euc_E9B3[] = {
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0x443B, 0xEB59, 0x726A,
+ 0, 0x4837, 0, 0x726F, 0x726B, 0, 0, 0,
+ 0x726C, 0, 0xEB5A, 0x4B31, 0x4C44, 0, 0x4650, 0xEB5B,
+ 0, 0xEB5C, 0, 0, 0, 0, 0, 0,
+};
+static const unsigned short utf8_to_euc_E9B3_x0213[] = {
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0x443B, 0xFE21, 0x726A,
+ 0, 0x4837, 0, 0x726F, 0x726B, 0, 0, 0,
+ 0x726C, 0, 0xFE22, 0x4B31, 0x4C44, 0, 0x4650, 0xEB5B,
+ 0, 0xEB5C, 0, 0, 0, 0, 0, 0,
+};
+static const unsigned short utf8_to_euc_E9B4[] = {
+ 0, 0, 0xEB5E, 0x7270, 0, 0, 0x7271, 0x463E,
+ 0x726E, 0x726D, 0, 0xEB5D, 0, 0, 0x322A, 0,
+ 0, 0xEB5F, 0x7279, 0, 0, 0x7278, 0, 0xEB60,
+ 0xEB61, 0, 0, 0x3175, 0xEB62, 0xEB63, 0xEB64, 0x7276,
+ 0, 0, 0, 0x7275, 0, 0, 0x7273, 0,
+ 0x337B, 0, 0x7272, 0x3C32, 0x3229, 0, 0, 0xEB65,
+ 0xEB66, 0, 0xEB67, 0xEB68, 0xEB69, 0, 0, 0,
+ 0, 0, 0xEB6A, 0x3963, 0xEB6B, 0xEB6D, 0x727C, 0x727B,
+};
+static const unsigned short utf8_to_euc_E9B4_x0213[] = {
+ 0, 0, 0xFE24, 0x7270, 0, 0, 0x7271, 0x463E,
+ 0x726E, 0x726D, 0, 0xFE23, 0, 0, 0x322A, 0,
+ 0, 0xFE26, 0x7279, 0, 0, 0x7278, 0, 0xFE27,
+ 0xFE28, 0, 0, 0x3175, 0xEB62, 0x7E58, 0x7E59, 0x7276,
+ 0, 0, 0, 0x7275, 0, 0, 0x7273, 0,
+ 0x337B, 0, 0x7272, 0x3C32, 0x3229, 0, 0, 0xEB65,
+ 0xEB66, 0, 0xFE2C, 0xEB68, 0xEB69, 0, 0, 0,
+ 0, 0, 0xEB6A, 0x3963, 0xEB6B, 0xEB6D, 0x727C, 0x727B,
+};
+static const unsigned short utf8_to_euc_E9B5[] = {
+ 0, 0x727A, 0xEB6E, 0xEB6F, 0x7277, 0xEB6C, 0x727D, 0xEB70,
+ 0x727E, 0, 0xEB71, 0, 0, 0, 0, 0,
+ 0x7325, 0x7324, 0, 0xEB72, 0xEB73, 0, 0, 0,
+ 0, 0x7326, 0, 0, 0x312D, 0x7321, 0x7322, 0xEB74,
+ 0x3974, 0x4C39, 0xEB76, 0xEB75, 0x7323, 0xEB77, 0, 0,
+ 0, 0xEB78, 0xEB79, 0xEB7A, 0x4B32, 0, 0, 0x732B,
+ 0xEB7B, 0, 0x7327, 0, 0, 0, 0xEB7C, 0xEB7D,
+ 0, 0, 0x732C, 0xEB7E, 0xEC21, 0, 0xEC22, 0,
+};
+static const unsigned short utf8_to_euc_E9B5_x0213[] = {
+ 0, 0x727A, 0xFE2E, 0x7E5A, 0x7277, 0xEB6C, 0x727D, 0x7E5B,
+ 0x727E, 0, 0xFE2F, 0, 0, 0, 0, 0,
+ 0x7325, 0x7324, 0x7E5C, 0xEB72, 0xEB73, 0, 0, 0,
+ 0, 0x7326, 0, 0, 0x312D, 0x7321, 0x7322, 0xFE30,
+ 0x3974, 0x4C39, 0xFE31, 0x7E5D, 0x7323, 0xEB77, 0, 0,
+ 0, 0xFE33, 0xEB79, 0xFE34, 0x4B32, 0, 0, 0x732B,
+ 0x7E5E, 0, 0x7327, 0xFE36, 0, 0, 0xFE37, 0xFE38,
+ 0, 0, 0x732C, 0xEB7E, 0x7E5F, 0, 0xFE39, 0,
+};
+static const unsigned short utf8_to_euc_E9B6[] = {
+ 0, 0, 0, 0xEC23, 0xEC24, 0, 0xEC25, 0x7329,
+ 0, 0x7328, 0xEC26, 0, 0, 0xEC27, 0xEC28, 0x375C,
+ 0, 0, 0xEC29, 0xEC2A, 0, 0xEC2B, 0xEC2C, 0xEC2D,
+ 0xEC2E, 0, 0x732D, 0, 0, 0, 0, 0,
+ 0, 0xEC2F, 0, 0, 0x732E, 0, 0, 0,
+ 0, 0x732F, 0xEC30, 0x732A, 0xEC31, 0, 0xEC32, 0x7274,
+ 0, 0xEC33, 0x7330, 0, 0x4461, 0xEC34, 0, 0,
+ 0x7334, 0xEC35, 0x7335, 0x7333, 0xEC36, 0, 0, 0xEC37,
+};
+static const unsigned short utf8_to_euc_E9B6_x0213[] = {
+ 0, 0, 0, 0xEC23, 0xFE3A, 0, 0xEC25, 0x7329,
+ 0, 0x7328, 0x7E60, 0, 0, 0xFE3B, 0xEC28, 0x375C,
+ 0, 0, 0xEC29, 0xEC2A, 0, 0xEC2B, 0x7E61, 0xEC2D,
+ 0xEC2E, 0xFE3C, 0x732D, 0, 0, 0, 0, 0,
+ 0, 0xFE3D, 0, 0, 0x732E, 0, 0, 0,
+ 0, 0x732F, 0xEC30, 0x732A, 0x7E63, 0, 0xEC32, 0x7274,
+ 0, 0xEC33, 0x7330, 0, 0x4461, 0xFE3F, 0, 0,
+ 0x7334, 0xFE40, 0x7335, 0x7333, 0x7E64, 0xFE41, 0, 0xFE3E,
+};
+static const unsigned short utf8_to_euc_E9B7[] = {
+ 0, 0x7332, 0x7338, 0xEC38, 0x7331, 0, 0x7336, 0xEC39,
+ 0, 0xEC3A, 0xEC3B, 0, 0, 0, 0, 0x7337,
+ 0, 0, 0, 0x733A, 0xEC3C, 0xEC3D, 0xEC3E, 0xEC3F,
+ 0, 0x7339, 0xEC40, 0, 0, 0, 0xEC41, 0xEC42,
+ 0xEC43, 0, 0, 0, 0, 0xEC44, 0x733C, 0xEC45,
+ 0, 0xEC46, 0, 0xEC47, 0, 0x733D, 0xEC48, 0x733E,
+ 0xEC49, 0, 0x4F49, 0xEC4A, 0xEC4B, 0, 0, 0,
+ 0x733B, 0x426B, 0x3A6D, 0, 0, 0x733F, 0xEC4C, 0,
+};
+static const unsigned short utf8_to_euc_E9B7_x0213[] = {
+ 0x7E62, 0x7332, 0x7338, 0xFE42, 0x7331, 0, 0x7336, 0xFE43,
+ 0, 0xFE44, 0xEC3B, 0, 0, 0, 0, 0x7337,
+ 0, 0, 0, 0x733A, 0xEC3C, 0xEC3D, 0xFE45, 0x7E65,
+ 0, 0x7339, 0xFE46, 0, 0, 0, 0xEC41, 0xFE47,
+ 0xFE48, 0, 0, 0xFE49, 0, 0xEC44, 0x733C, 0x7E67,
+ 0, 0xEC46, 0, 0xEC47, 0, 0x733D, 0xEC48, 0x733E,
+ 0xEC49, 0, 0x4F49, 0xEC4A, 0xFE4A, 0, 0, 0,
+ 0x733B, 0x426B, 0x3A6D, 0, 0, 0x733F, 0xEC4C, 0,
+};
+static const unsigned short utf8_to_euc_E9B8[] = {
+ 0, 0, 0xEC4E, 0, 0, 0, 0, 0xEC4F,
+ 0, 0, 0xEC4D, 0, 0, 0, 0xEC50, 0,
+ 0xEC51, 0xEC52, 0xEC53, 0, 0, 0xEC54, 0xEC55, 0,
+ 0, 0xEC56, 0x7340, 0x7341, 0xEC57, 0xEC58, 0x7342, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+};
+static const unsigned short utf8_to_euc_E9B8_x0213[] = {
+ 0, 0, 0xFE4D, 0, 0, 0, 0, 0x7E68,
+ 0, 0, 0xFE4C, 0, 0, 0xFE4E, 0xEC50, 0,
+ 0xEC51, 0xEC52, 0xEC53, 0, 0, 0x7E69, 0xEC55, 0,
+ 0, 0xFE4F, 0x7340, 0x7341, 0xFE50, 0xFE51, 0x7342, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+};
+static const unsigned short utf8_to_euc_E9B9[] = {
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0x7343, 0, 0,
+ 0x3834, 0x7344, 0xEC59, 0xEC5A, 0xEC5B, 0x7345, 0, 0x3C2F,
+};
+static const unsigned short utf8_to_euc_E9B9_x0213[] = {
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0x7343, 0, 0,
+ 0x3834, 0x7344, 0xEC59, 0xFE52, 0x7E6A, 0x7345, 0, 0x3C2F,
+};
+static const unsigned short utf8_to_euc_E9BA[] = {
+ 0xEC5C, 0x7346, 0xEC5D, 0xEC5E, 0xEC5F, 0xEC60, 0, 0xEC61,
+ 0x7347, 0, 0, 0x7348, 0x7349, 0, 0xEC62, 0xEC63,
+ 0, 0x734C, 0x734A, 0x4F3C, 0, 0x734B, 0xEC64, 0x4E6F,
+ 0xEC65, 0, 0, 0xEC66, 0, 0x734D, 0xEC67, 0x4E5B,
+ 0, 0, 0, 0, 0xEC68, 0x734E, 0x477E, 0,
+ 0xEC69, 0x734F, 0x7351, 0, 0xEC6A, 0x7352, 0xEC6B, 0xEC6C,
+ 0xEC6D, 0, 0, 0xEC6E, 0xEC6F, 0xEC70, 0, 0,
+ 0x7350, 0x396D, 0x4C4D, 0x4B63, 0x5677, 0, 0x5D60, 0x4B7B,
+};
+static const unsigned short utf8_to_euc_E9BA_x0213[] = {
+ 0xFE54, 0x7346, 0xEC5D, 0xEC5E, 0xEC5F, 0xFE55, 0, 0xEC61,
+ 0x7347, 0, 0, 0x7348, 0x7349, 0, 0xEC62, 0xEC63,
+ 0, 0x734C, 0x734A, 0x4F3C, 0, 0x734B, 0xEC64, 0x4E6F,
+ 0xEC65, 0, 0, 0xFE56, 0, 0x734D, 0x7E6B, 0x4E5B,
+ 0, 0, 0, 0, 0x7E6C, 0x734E, 0x477E, 0,
+ 0xFE57, 0x734F, 0x7351, 0, 0x7E6D, 0x7352, 0xEC6B, 0x7E6E,
+ 0xEC6D, 0, 0, 0xEC6E, 0x7E6F, 0x7E70, 0, 0,
+ 0x7350, 0x396D, 0x4C4D, 0x4B63, 0x5677, 0xFE59, 0x5D60, 0x4B7B,
+};
+static const unsigned short utf8_to_euc_E9BB[] = {
+ 0, 0, 0, 0, 0x322B, 0, 0xEC71, 0,
+ 0xEC72, 0, 0, 0xEC73, 0x7354, 0x3550, 0x7355, 0x7356,
+ 0x7357, 0xF47E, 0x3975, 0, 0x7358, 0xEC74, 0, 0,
+ 0x6054, 0x4C5B, 0, 0x4263, 0x7359, 0x735B, 0x735A, 0xEC75,
+ 0x735C, 0, 0, 0, 0xEC76, 0x735D, 0, 0xEC77,
+ 0x735E, 0, 0, 0, 0xEC78, 0xEC79, 0xEC7A, 0x735F,
+ 0xEC7B, 0xEC7C, 0xEC7D, 0, 0x7360, 0xEC7E, 0x7361, 0x7362,
+ 0xED21, 0x7363, 0, 0x7364, 0x7365, 0x7366, 0, 0xED22,
+};
+static const unsigned short utf8_to_euc_E9BB_x0213[] = {
+ 0, 0, 0, 0x7E71, 0x322B, 0, 0xEC71, 0,
+ 0xEC72, 0, 0, 0xEC73, 0x7354, 0x3550, 0x7355, 0x7356,
+ 0x7357, 0x7E72, 0x3975, 0, 0x7358, 0xEC74, 0, 0,
+ 0x6054, 0x4C5B, 0, 0x4263, 0x7359, 0x735B, 0x735A, 0xFE5B,
+ 0x735C, 0, 0, 0, 0xEC76, 0x735D, 0, 0xFE5C,
+ 0x735E, 0, 0, 0, 0xEC78, 0xEC79, 0xFE5D, 0x735F,
+ 0xEC7B, 0xEC7C, 0xEC7D, 0, 0x7360, 0xEC7E, 0x7361, 0x7362,
+ 0xED21, 0x7363, 0, 0x7364, 0x7365, 0x7366, 0, 0xFE5E,
+};
+static const unsigned short utf8_to_euc_E9BC[] = {
+ 0, 0, 0xED23, 0xED24, 0, 0, 0, 0x7367,
+ 0x7368, 0xED25, 0, 0, 0, 0, 0x4524, 0xED26,
+ 0xED27, 0xED28, 0xED29, 0x385D, 0xED2A, 0x736A, 0xED2B, 0xED2C,
+ 0, 0xED2D, 0xED2E, 0xED2F, 0, 0, 0, 0xED30,
+ 0x414D, 0x736B, 0xED31, 0, 0, 0, 0xED32, 0,
+ 0, 0, 0xED33, 0xED34, 0x736C, 0, 0, 0xED35,
+ 0, 0xED36, 0xED37, 0, 0xED38, 0, 0, 0xED39,
+ 0, 0xED3A, 0xED3B, 0x4921, 0xED3C, 0xED3D, 0x736D, 0xED3E,
+};
+static const unsigned short utf8_to_euc_E9BC_x0213[] = {
+ 0, 0, 0xFE5F, 0xFE61, 0, 0, 0, 0x7367,
+ 0x7368, 0xED25, 0, 0, 0, 0, 0x4524, 0xED26,
+ 0x7E73, 0xED28, 0xED29, 0x385D, 0xED2A, 0x736A, 0xED2B, 0xFE62,
+ 0, 0xFE63, 0xED2E, 0xED2F, 0, 0, 0, 0xED30,
+ 0x414D, 0x736B, 0xED31, 0, 0, 0, 0xED32, 0,
+ 0, 0, 0xED33, 0xED34, 0x736C, 0, 0, 0xFE64,
+ 0, 0xED36, 0xED37, 0, 0xED38, 0, 0, 0xFE65,
+ 0, 0x7E74, 0xFE66, 0x4921, 0xED3C, 0xFE67, 0x736D, 0xED3E,
+};
+static const unsigned short utf8_to_euc_E9BD[] = {
+ 0, 0xED3F, 0, 0xED40, 0xED41, 0xED42, 0xED43, 0xED44,
+ 0, 0, 0x736E, 0x6337, 0, 0, 0x6C5A, 0x706D,
+ 0, 0, 0x736F, 0xED45, 0x7370, 0xED46, 0xED47, 0xED48,
+ 0xED49, 0, 0xED4A, 0, 0, 0xED4B, 0xED4C, 0x7372,
+ 0x7373, 0x7374, 0x4E70, 0x7371, 0, 0, 0x7375, 0x7376,
+ 0xED4D, 0xED4E, 0x7378, 0, 0x7377, 0xED4F, 0xED50, 0xED51,
+ 0xED52, 0xED53, 0x737A, 0xED54, 0, 0xED55, 0x737B, 0x7379,
+ 0, 0, 0xED56, 0, 0, 0xED57, 0, 0,
+};
+static const unsigned short utf8_to_euc_E9BD_x0213[] = {
+ 0, 0xFE68, 0, 0xED40, 0xED41, 0xFE69, 0xFE6A, 0xED44,
+ 0, 0, 0x736E, 0x6337, 0, 0, 0x6C5A, 0x706D,
+ 0, 0, 0x736F, 0xFE6B, 0x7370, 0xFE6C, 0xED47, 0x7E75,
+ 0xFE6D, 0, 0xED4A, 0, 0, 0xFE6F, 0xED4C, 0x7372,
+ 0x7373, 0x7374, 0x4E70, 0x7371, 0, 0, 0x7375, 0x7376,
+ 0xED4D, 0xFE71, 0x7378, 0, 0x7377, 0xFE73, 0xED50, 0xED51,
+ 0xFE74, 0xED53, 0x737A, 0xED54, 0, 0xFE75, 0x737B, 0x7379,
+ 0, 0, 0xED56, 0, 0, 0xED57, 0, 0,
+};
+static const unsigned short utf8_to_euc_E9BE[] = {
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0x4E36, 0, 0xED58,
+ 0xED59, 0xED5A, 0xED5B, 0, 0xED5C, 0x737C, 0xED5D, 0xED5E,
+ 0, 0, 0, 0, 0x737D, 0x6354, 0xED5F, 0,
+ 0x737E, 0xED60, 0xED61, 0xED62, 0, 0xED63, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+};
+static const unsigned short utf8_to_euc_E9BE_x0213[] = {
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0x4E36, 0, 0xED58,
+ 0x7E76, 0xED5A, 0xED5B, 0, 0x7E77, 0x737C, 0xED5D, 0x7E78,
+ 0, 0, 0, 0, 0x737D, 0x6354, 0xED5F, 0,
+ 0x737E, 0xED60, 0x7E79, 0xED62, 0, 0xED63, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+};
+static const unsigned short utf8_to_euc_EFA4[] = {
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0xF445, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+};
+static const unsigned short utf8_to_euc_EFA4_x0213[] = {
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0x763B, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0x742E, 0x754E, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0x7B4F, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+};
+static const unsigned short utf8_to_euc_EFA5_x0213[] = {
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0x7649, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+};
+static const unsigned short utf8_to_euc_EFA7[] = {
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0xF472, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+};
+static const unsigned short utf8_to_euc_EFA7_x0213[] = {
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0x7E24, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0x7D5D, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+};
+static const unsigned short utf8_to_euc_EFA8[] = {
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0xF434, 0xF437,
+ 0xF438, 0xF43D, 0xF444, 0xF447, 0xF448, 0xF44E, 0xF44F, 0xF453,
+ 0xF455, 0xF456, 0xF457, 0xF458, 0xF45A, 0xF45B, 0xF45E, 0xF460,
+ 0xF462, 0xF463, 0xF465, 0xF469, 0xF46A, 0xF46B, 0xF46D, 0xF46F,
+ 0xF470, 0xF473, 0xF477, 0xF478, 0xF479, 0xF47D, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+};
+static const unsigned short utf8_to_euc_EFA8_x0213[] = {
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0xF434, 0x2F4B,
+ 0x2F57, 0x4F72, 0xF444, 0xAE79, 0x757A, 0x775A, 0x776F, 0xF453,
+ 0xF455, 0x793C, 0x793D, 0x7941, 0xF45A, 0xF45B, 0xF45E, 0x7B3A,
+ 0xF738, 0xF745, 0x7C2E, 0xF469, 0xF96E, 0xF46B, 0x7C6A, 0xF46F,
+ 0xF470, 0xF473, 0xF477, 0xF478, 0xF479, 0xF47D, 0, 0,
+ 0x2E38, 0x2E49, 0x2E50, 0x2E63, 0x2E68, 0x2E6E, 0x2F2C, 0x2F2F,
+ 0x2F36, 0x2F5A, 0x2F5E, 0x4F61, 0x4F62, 0x7450, 0x745C, 0x745E,
+};
+static const unsigned short utf8_to_euc_EFA9_x0213[] = {
+ 0x7461, 0x7528, 0x752B, 0x7543, 0x7565, 0x7669, 0x7677, 0x7725,
+ 0x7755, 0xF029, 0x7825, 0x7927, 0x7933, 0x7934, 0x7937, 0x7938,
+ 0x7939, 0x793B, 0x793F, 0x7940, 0x794D, 0x7951, 0x7964, 0x7A2E,
+ 0xF450, 0x7A33, 0x7A3A, 0x7A44, 0x7A58, 0xF574, 0xF575, 0x7B27,
+ 0x7B6F, 0x7B79, 0x7C2F, 0x7C30, 0x7C38, 0x7C3D, 0xF969, 0x7C59,
+ 0x7D63, 0x7D76, 0x7D7B, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+};
+static const unsigned short utf8_to_euc_EFB9_x0213[] = {
+ 0, 0, 0, 0, 0, 0x233E, 0x233D, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+};
+static const unsigned short utf8_to_euc_EFBC[] = {
+ 0, 0x212A, 0xF42A, 0x2174, 0x2170, 0x2173, 0x2175, 0xF429,
+ 0x214A, 0x214B, 0x2176, 0x215C, 0x2124, 0x215D, 0x2125, 0x213F,
+ 0x2330, 0x2331, 0x2332, 0x2333, 0x2334, 0x2335, 0x2336, 0x2337,
+ 0x2338, 0x2339, 0x2127, 0x2128, 0x2163, 0x2161, 0x2164, 0x2129,
+ 0x2177, 0x2341, 0x2342, 0x2343, 0x2344, 0x2345, 0x2346, 0x2347,
+ 0x2348, 0x2349, 0x234A, 0x234B, 0x234C, 0x234D, 0x234E, 0x234F,
+ 0x2350, 0x2351, 0x2352, 0x2353, 0x2354, 0x2355, 0x2356, 0x2357,
+ 0x2358, 0x2359, 0x235A, 0x214E, 0x2140, 0x214F, 0x2130, 0x2132,
+};
+static const unsigned short utf8_to_euc_EFBC_x0213[] = {
+ 0, 0x212A, 0x2230, 0x2174, 0x2170, 0x2173, 0x2175, 0x222F,
+ 0x214A, 0x214B, 0x2176, 0x215C, 0x2124, 0x2231, 0x2125, 0x213F,
+ 0x2330, 0x2331, 0x2332, 0x2333, 0x2334, 0x2335, 0x2336, 0x2337,
+ 0x2338, 0x2339, 0x2127, 0x2128, 0x2163, 0x2161, 0x2164, 0x2129,
+ 0x2177, 0x2341, 0x2342, 0x2343, 0x2344, 0x2345, 0x2346, 0x2347,
+ 0x2348, 0x2349, 0x234A, 0x234B, 0x234C, 0x234D, 0x234E, 0x234F,
+ 0x2350, 0x2351, 0x2352, 0x2353, 0x2354, 0x2355, 0x2356, 0x2357,
+ 0x2358, 0x2359, 0x235A, 0x214E, 0x2140, 0x214F, 0x2130, 0x2132,
+};
+static const unsigned short utf8_to_euc_EFBD[] = {
+ 0x212E, 0x2361, 0x2362, 0x2363, 0x2364, 0x2365, 0x2366, 0x2367,
+ 0x2368, 0x2369, 0x236A, 0x236B, 0x236C, 0x236D, 0x236E, 0x236F,
+ 0x2370, 0x2371, 0x2372, 0x2373, 0x2374, 0x2375, 0x2376, 0x2377,
+ 0x2378, 0x2379, 0x237A, 0x2150, 0x2143, 0x2151, 0xA237, 0,
+ 0, 0x0E21, 0x0E22, 0x0E23, 0x0E24, 0x0E25, 0x0E26, 0x0E27,
+ 0x0E28, 0x0E29, 0x0E2A, 0x0E2B, 0x0E2C, 0x0E2D, 0x0E2E, 0x0E2F,
+ 0x0E30, 0x0E31, 0x0E32, 0x0E33, 0x0E34, 0x0E35, 0x0E36, 0x0E37,
+ 0x0E38, 0x0E39, 0x0E3A, 0x0E3B, 0x0E3C, 0x0E3D, 0x0E3E, 0x0E3F,
+};
+static const unsigned short utf8_to_euc_EFBD_ms[] = {
+ 0x212E, 0x2361, 0x2362, 0x2363, 0x2364, 0x2365, 0x2366, 0x2367,
+ 0x2368, 0x2369, 0x236A, 0x236B, 0x236C, 0x236D, 0x236E, 0x236F,
+ 0x2370, 0x2371, 0x2372, 0x2373, 0x2374, 0x2375, 0x2376, 0x2377,
+ 0x2378, 0x2379, 0x237A, 0x2150, 0x2143, 0x2151, 0x2141, 0,
+ 0, 0x0E21, 0x0E22, 0x0E23, 0x0E24, 0x0E25, 0x0E26, 0x0E27,
+ 0x0E28, 0x0E29, 0x0E2A, 0x0E2B, 0x0E2C, 0x0E2D, 0x0E2E, 0x0E2F,
+ 0x0E30, 0x0E31, 0x0E32, 0x0E33, 0x0E34, 0x0E35, 0x0E36, 0x0E37,
+ 0x0E38, 0x0E39, 0x0E3A, 0x0E3B, 0x0E3C, 0x0E3D, 0x0E3E, 0x0E3F,
+};
+static const unsigned short utf8_to_euc_EFBD_x0213[] = {
+ 0x212E, 0x2361, 0x2362, 0x2363, 0x2364, 0x2365, 0x2366, 0x2367,
+ 0x2368, 0x2369, 0x236A, 0x236B, 0x236C, 0x236D, 0x236E, 0x236F,
+ 0x2370, 0x2371, 0x2372, 0x2373, 0x2374, 0x2375, 0x2376, 0x2377,
+ 0x2378, 0x2379, 0x237A, 0x2150, 0x2143, 0x2151, 0x2232, 0x2256,
+ 0x2257, 0x0E21, 0x0E22, 0x0E23, 0x0E24, 0x0E25, 0x0E26, 0x0E27,
+ 0x0E28, 0x0E29, 0x0E2A, 0x0E2B, 0x0E2C, 0x0E2D, 0x0E2E, 0x0E2F,
+ 0x0E30, 0x0E31, 0x0E32, 0x0E33, 0x0E34, 0x0E35, 0x0E36, 0x0E37,
+ 0x0E38, 0x0E39, 0x0E3A, 0x0E3B, 0x0E3C, 0x0E3D, 0x0E3E, 0x0E3F,
+};
+static const unsigned short utf8_to_euc_EFBE[] = {
+ 0x0E40, 0x0E41, 0x0E42, 0x0E43, 0x0E44, 0x0E45, 0x0E46, 0x0E47,
+ 0x0E48, 0x0E49, 0x0E4A, 0x0E4B, 0x0E4C, 0x0E4D, 0x0E4E, 0x0E4F,
+ 0x0E50, 0x0E51, 0x0E52, 0x0E53, 0x0E54, 0x0E55, 0x0E56, 0x0E57,
+ 0x0E58, 0x0E59, 0x0E5A, 0x0E5B, 0x0E5C, 0x0E5D, 0x0E5E, 0x0E5F,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+};
+static const unsigned short utf8_to_euc_EFBF[] = {
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0x2171, 0x2172, 0x224C, 0x2131, 0xA243, 0x216F, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+};
+static const unsigned short *const utf8_to_euc_E1_x0213[] = {
+ 0, 0, 0, 0,
+ 0, 0, 0, 0,
+ 0, 0, 0, 0,
+ 0, 0, 0, 0,
+ 0, 0, 0, 0,
+ 0, 0, 0, 0,
+ 0, 0, 0, 0,
+ 0, 0, 0, 0,
+ 0, 0, 0, 0,
+ 0, 0, 0, 0,
+ 0, 0, 0, 0,
+ 0, 0, 0, 0,
+ 0, 0, 0, 0,
+ 0, 0, 0, 0,
+ utf8_to_euc_E1B8_x0213, 0, 0, 0,
+ 0, utf8_to_euc_E1BD_x0213, 0, 0,
+};
+static const unsigned short *const utf8_to_euc_E2[] = {
+ utf8_to_euc_E280, 0, 0, 0,
+ utf8_to_euc_E284, utf8_to_euc_E285, utf8_to_euc_E286, utf8_to_euc_E287,
+ utf8_to_euc_E288, utf8_to_euc_E289, utf8_to_euc_E28A, 0,
+ utf8_to_euc_E28C, 0, 0, 0,
+ 0, utf8_to_euc_E291, 0, 0,
+ utf8_to_euc_E294, utf8_to_euc_E295, utf8_to_euc_E296, utf8_to_euc_E297,
+ utf8_to_euc_E298, utf8_to_euc_E299, 0, 0,
+ 0, 0, 0, 0,
+ 0, 0, 0, 0,
+ 0, 0, 0, 0,
+ 0, 0, 0, 0,
+ 0, 0, 0, 0,
+ 0, 0, 0, 0,
+ 0, 0, 0, 0,
+ 0, 0, 0, 0,
+ 0, 0, 0, 0,
+};
+static const unsigned short *const utf8_to_euc_E2_ms[] = {
+ utf8_to_euc_E280_ms, 0, 0, 0,
+ utf8_to_euc_E284, utf8_to_euc_E285, utf8_to_euc_E286, utf8_to_euc_E287,
+ utf8_to_euc_E288, utf8_to_euc_E289, utf8_to_euc_E28A, 0,
+ utf8_to_euc_E28C, 0, 0, 0,
+ 0, utf8_to_euc_E291, 0, 0,
+ utf8_to_euc_E294, utf8_to_euc_E295, utf8_to_euc_E296, utf8_to_euc_E297,
+ utf8_to_euc_E298, utf8_to_euc_E299, 0, 0,
+ 0, 0, 0, 0,
+ 0, 0, 0, 0,
+ 0, 0, 0, 0,
+ 0, 0, 0, 0,
+ 0, 0, 0, 0,
+ 0, 0, 0, 0,
+ 0, 0, 0, 0,
+ 0, 0, 0, 0,
+ 0, 0, 0, 0,
+};
+static const unsigned short *const utf8_to_euc_E2_932[] = {
+ utf8_to_euc_E280_932, 0, 0, 0,
+ utf8_to_euc_E284, utf8_to_euc_E285, utf8_to_euc_E286, utf8_to_euc_E287,
+ utf8_to_euc_E288_932, utf8_to_euc_E289, utf8_to_euc_E28A, 0,
+ utf8_to_euc_E28C, 0, 0, 0,
+ 0, utf8_to_euc_E291, 0, 0,
+ utf8_to_euc_E294, utf8_to_euc_E295, utf8_to_euc_E296, utf8_to_euc_E297,
+ utf8_to_euc_E298, utf8_to_euc_E299, 0, 0,
+ 0, 0, 0, 0,
+ 0, 0, 0, 0,
+ 0, 0, 0, 0,
+ 0, 0, 0, 0,
+ 0, 0, 0, 0,
+ 0, 0, 0, 0,
+ 0, 0, 0, 0,
+ 0, 0, 0, 0,
+ 0, 0, 0, 0,
+};
+static const unsigned short *const utf8_to_euc_E2_mac[] = {
+ utf8_to_euc_E280_932, 0, 0, 0,
+ utf8_to_euc_E284_mac, utf8_to_euc_E285_mac, utf8_to_euc_E286, utf8_to_euc_E287,
+ utf8_to_euc_E288_mac, utf8_to_euc_E289, utf8_to_euc_E28A_mac, 0,
+ utf8_to_euc_E28C, 0, 0, 0,
+ 0, utf8_to_euc_E291_mac, 0, 0,
+ utf8_to_euc_E294, utf8_to_euc_E295, utf8_to_euc_E296, utf8_to_euc_E297,
+ utf8_to_euc_E298, utf8_to_euc_E299, 0, 0,
+ 0, 0, 0, 0,
+ 0, 0, 0, 0,
+ 0, 0, 0, 0,
+ 0, 0, 0, 0,
+ 0, 0, 0, 0,
+ 0, 0, 0, 0,
+ 0, 0, 0, 0,
+ 0, 0, 0, 0,
+ 0, 0, 0, 0,
+};
+static const unsigned short *const utf8_to_euc_E2_x0213[] = {
+ utf8_to_euc_E280_x0213, utf8_to_euc_E281_x0213, utf8_to_euc_E282_x0213, 0,
+ utf8_to_euc_E284_x0213, utf8_to_euc_E285_x0213, utf8_to_euc_E286_x0213, utf8_to_euc_E287_x0213,
+ utf8_to_euc_E288_x0213, utf8_to_euc_E289_x0213, utf8_to_euc_E28A_x0213, utf8_to_euc_E28B_x0213,
+ utf8_to_euc_E28C_x0213, 0, utf8_to_euc_E28E_x0213, utf8_to_euc_E28F_x0213,
+ utf8_to_euc_E290_x0213, utf8_to_euc_E291, 0, utf8_to_euc_E293_x0213,
+ utf8_to_euc_E294, utf8_to_euc_E295, utf8_to_euc_E296_x0213, utf8_to_euc_E297_x0213,
+ utf8_to_euc_E298_x0213, utf8_to_euc_E299_x0213, 0, 0,
+ utf8_to_euc_E29C_x0213, utf8_to_euc_E29D_x0213, 0, 0,
+ 0, 0, 0, 0,
+ utf8_to_euc_E2A4_x0213, 0, utf8_to_euc_E2A6_x0213, utf8_to_euc_E2A7_x0213,
+ 0, 0, 0, 0,
+ 0, 0, 0, 0,
+ 0, 0, 0, 0,
+ 0, 0, 0, 0,
+ 0, 0, 0, 0,
+ 0, 0, 0, 0,
+};
+static const unsigned short *const utf8_to_euc_E3[] = {
+ utf8_to_euc_E380, utf8_to_euc_E381, utf8_to_euc_E382, utf8_to_euc_E383,
+ 0, 0, 0, 0,
+ utf8_to_euc_E388, 0, utf8_to_euc_E38A, 0,
+ utf8_to_euc_E38C, utf8_to_euc_E38D, utf8_to_euc_E38E, utf8_to_euc_E38F,
+ 0, 0, 0, 0,
+ 0, 0, 0, 0,
+ 0, 0, 0, 0,
+ 0, 0, 0, 0,
+ 0, 0, 0, 0,
+ 0, 0, 0, 0,
+ 0, 0, 0, 0,
+ 0, 0, 0, 0,
+ 0, 0, 0, 0,
+ 0, 0, 0, 0,
+ 0, 0, 0, 0,
+ 0, 0, 0, 0,
+};
+static const unsigned short *const utf8_to_euc_E3_932[] = {
+ utf8_to_euc_E380_932, utf8_to_euc_E381, utf8_to_euc_E382_932, utf8_to_euc_E383,
+ 0, 0, 0, 0,
+ utf8_to_euc_E388, 0, utf8_to_euc_E38A, 0,
+ utf8_to_euc_E38C, utf8_to_euc_E38D, utf8_to_euc_E38E, utf8_to_euc_E38F,
+ 0, 0, 0, 0,
+ 0, 0, 0, 0,
+ 0, 0, 0, 0,
+ 0, 0, 0, 0,
+ 0, 0, 0, 0,
+ 0, 0, 0, 0,
+ 0, 0, 0, 0,
+ 0, 0, 0, 0,
+ 0, 0, 0, 0,
+ 0, 0, 0, 0,
+ 0, 0, 0, 0,
+ 0, 0, 0, 0,
+};
+static const unsigned short *const utf8_to_euc_E3_mac[] = {
+ utf8_to_euc_E380_932, utf8_to_euc_E381, utf8_to_euc_E382_932, utf8_to_euc_E383,
+ 0, 0, 0, 0,
+ utf8_to_euc_E388_mac, 0, utf8_to_euc_E38A_mac, 0,
+ utf8_to_euc_E38C_mac, utf8_to_euc_E38D_mac, utf8_to_euc_E38E_mac, utf8_to_euc_E38F_mac,
+ 0, 0, 0, 0,
+ 0, 0, 0, 0,
+ 0, 0, 0, 0,
+ 0, 0, 0, 0,
+ 0, 0, 0, 0,
+ 0, 0, 0, 0,
+ 0, 0, 0, 0,
+ 0, 0, 0, 0,
+ 0, 0, 0, 0,
+ 0, 0, 0, 0,
+ 0, 0, 0, 0,
+ 0, 0, 0, 0,
+};
+static const unsigned short *const utf8_to_euc_E3_x0213[] = {
+ utf8_to_euc_E380_x0213, utf8_to_euc_E381, utf8_to_euc_E382_x0213, utf8_to_euc_E383_x0213,
+ 0, 0, 0, utf8_to_euc_E387_x0213,
+ utf8_to_euc_E388, utf8_to_euc_E389_x0213, utf8_to_euc_E38A_x0213, utf8_to_euc_E38B_x0213,
+ utf8_to_euc_E38C, utf8_to_euc_E38D, utf8_to_euc_E38E, utf8_to_euc_E38F_x0213,
+ utf8_to_euc_E390_x0213, utf8_to_euc_E391_x0213, utf8_to_euc_E392_x0213, utf8_to_euc_E393_x0213,
+ utf8_to_euc_E394_x0213, utf8_to_euc_E395_x0213, utf8_to_euc_E396_x0213, utf8_to_euc_E397_x0213,
+ utf8_to_euc_E398_x0213, utf8_to_euc_E399_x0213, utf8_to_euc_E39A_x0213, utf8_to_euc_E39B_x0213,
+ 0, utf8_to_euc_E39D_x0213, utf8_to_euc_E39E_x0213, utf8_to_euc_E39F_x0213,
+ utf8_to_euc_E3A0_x0213, utf8_to_euc_E3A1_x0213, 0, utf8_to_euc_E3A3_x0213,
+ utf8_to_euc_E3A4_x0213, utf8_to_euc_E3A5_x0213, 0, 0,
+ 0, utf8_to_euc_E3A9_x0213, 0, utf8_to_euc_E3AB_x0213,
+ utf8_to_euc_E3AC_x0213, utf8_to_euc_E3AD_x0213, utf8_to_euc_E3AE_x0213, utf8_to_euc_E3AF_x0213,
+ utf8_to_euc_E3B0_x0213, 0, 0, utf8_to_euc_E3B3_x0213,
+ utf8_to_euc_E3B4_x0213, utf8_to_euc_E3B5_x0213, utf8_to_euc_E3B6_x0213, utf8_to_euc_E3B7_x0213,
+ utf8_to_euc_E3B8_x0213, utf8_to_euc_E3B9_x0213, utf8_to_euc_E3BA_x0213, 0,
+ 0, utf8_to_euc_E3BD_x0213, utf8_to_euc_E3BE_x0213, utf8_to_euc_E3BF_x0213,
+};
+static const unsigned short *const utf8_to_euc_E4[] = {
+ 0, 0, 0, 0,
+ 0, 0, 0, 0,
+ 0, 0, 0, 0,
+ 0, 0, 0, 0,
+ 0, 0, 0, 0,
+ 0, 0, 0, 0,
+ 0, 0, 0, 0,
+ 0, 0, 0, 0,
+ 0, 0, 0, 0,
+ 0, 0, 0, 0,
+ 0, 0, 0, 0,
+ 0, 0, 0, 0,
+ 0, 0, 0, 0,
+ 0, 0, 0, 0,
+ utf8_to_euc_E4B8, utf8_to_euc_E4B9, utf8_to_euc_E4BA, utf8_to_euc_E4BB,
+ utf8_to_euc_E4BC, utf8_to_euc_E4BD, utf8_to_euc_E4BE, utf8_to_euc_E4BF,
+};
+static const unsigned short *const utf8_to_euc_E4_x0213[] = {
+ utf8_to_euc_E480_x0213, utf8_to_euc_E481_x0213, utf8_to_euc_E482_x0213, 0,
+ utf8_to_euc_E484_x0213, utf8_to_euc_E485_x0213, utf8_to_euc_E486_x0213, utf8_to_euc_E487_x0213,
+ utf8_to_euc_E488_x0213, utf8_to_euc_E489_x0213, 0, utf8_to_euc_E48B_x0213,
+ utf8_to_euc_E48C_x0213, utf8_to_euc_E48D_x0213, 0, utf8_to_euc_E48F_x0213,
+ utf8_to_euc_E490_x0213, utf8_to_euc_E491_x0213, utf8_to_euc_E492_x0213, utf8_to_euc_E493_x0213,
+ utf8_to_euc_E494_x0213, utf8_to_euc_E495_x0213, utf8_to_euc_E496_x0213, utf8_to_euc_E497_x0213,
+ utf8_to_euc_E498_x0213, utf8_to_euc_E499_x0213, utf8_to_euc_E49A_x0213, 0,
+ utf8_to_euc_E49C_x0213, utf8_to_euc_E49D_x0213, 0, utf8_to_euc_E49F_x0213,
+ utf8_to_euc_E4A0_x0213, utf8_to_euc_E4A1_x0213, utf8_to_euc_E4A2_x0213, 0,
+ 0, 0, utf8_to_euc_E4A6_x0213, utf8_to_euc_E4A7_x0213,
+ utf8_to_euc_E4A8_x0213, 0, utf8_to_euc_E4AA_x0213, 0,
+ utf8_to_euc_E4AC_x0213, 0, 0, utf8_to_euc_E4AF_x0213,
+ utf8_to_euc_E4B0_x0213, 0, 0, utf8_to_euc_E4B3_x0213,
+ utf8_to_euc_E4B4_x0213, utf8_to_euc_E4B5_x0213, 0, 0,
+ utf8_to_euc_E4B8_x0213, utf8_to_euc_E4B9_x0213, utf8_to_euc_E4BA_x0213, utf8_to_euc_E4BB_x0213,
+ utf8_to_euc_E4BC_x0213, utf8_to_euc_E4BD_x0213, utf8_to_euc_E4BE_x0213, utf8_to_euc_E4BF_x0213,
+};
+static const unsigned short *const utf8_to_euc_E5[] = {
+ utf8_to_euc_E580, utf8_to_euc_E581, utf8_to_euc_E582, utf8_to_euc_E583,
+ utf8_to_euc_E584, utf8_to_euc_E585, utf8_to_euc_E586, utf8_to_euc_E587,
+ utf8_to_euc_E588, utf8_to_euc_E589, utf8_to_euc_E58A, utf8_to_euc_E58B,
+ utf8_to_euc_E58C, utf8_to_euc_E58D, utf8_to_euc_E58E, utf8_to_euc_E58F,
+ utf8_to_euc_E590, utf8_to_euc_E591, utf8_to_euc_E592, utf8_to_euc_E593,
+ utf8_to_euc_E594, utf8_to_euc_E595, utf8_to_euc_E596, utf8_to_euc_E597,
+ utf8_to_euc_E598, utf8_to_euc_E599, utf8_to_euc_E59A, utf8_to_euc_E59B,
+ utf8_to_euc_E59C, utf8_to_euc_E59D, utf8_to_euc_E59E, utf8_to_euc_E59F,
+ utf8_to_euc_E5A0, utf8_to_euc_E5A1, utf8_to_euc_E5A2, utf8_to_euc_E5A3,
+ utf8_to_euc_E5A4, utf8_to_euc_E5A5, utf8_to_euc_E5A6, utf8_to_euc_E5A7,
+ utf8_to_euc_E5A8, utf8_to_euc_E5A9, utf8_to_euc_E5AA, utf8_to_euc_E5AB,
+ utf8_to_euc_E5AC, utf8_to_euc_E5AD, utf8_to_euc_E5AE, utf8_to_euc_E5AF,
+ utf8_to_euc_E5B0, utf8_to_euc_E5B1, utf8_to_euc_E5B2, utf8_to_euc_E5B3,
+ utf8_to_euc_E5B4, utf8_to_euc_E5B5, utf8_to_euc_E5B6, utf8_to_euc_E5B7,
+ utf8_to_euc_E5B8, utf8_to_euc_E5B9, utf8_to_euc_E5BA, utf8_to_euc_E5BB,
+ utf8_to_euc_E5BC, utf8_to_euc_E5BD, utf8_to_euc_E5BE, utf8_to_euc_E5BF,
+};
+static const unsigned short *const utf8_to_euc_E5_x0213[] = {
+ utf8_to_euc_E580_x0213, utf8_to_euc_E581_x0213, utf8_to_euc_E582_x0213, utf8_to_euc_E583_x0213,
+ utf8_to_euc_E584_x0213, utf8_to_euc_E585_x0213, utf8_to_euc_E586_x0213, utf8_to_euc_E587_x0213,
+ utf8_to_euc_E588_x0213, utf8_to_euc_E589_x0213, utf8_to_euc_E58A_x0213, utf8_to_euc_E58B_x0213,
+ utf8_to_euc_E58C_x0213, utf8_to_euc_E58D_x0213, utf8_to_euc_E58E_x0213, utf8_to_euc_E58F_x0213,
+ utf8_to_euc_E590_x0213, utf8_to_euc_E591_x0213, utf8_to_euc_E592_x0213, utf8_to_euc_E593_x0213,
+ utf8_to_euc_E594_x0213, utf8_to_euc_E595_x0213, utf8_to_euc_E596_x0213, utf8_to_euc_E597_x0213,
+ utf8_to_euc_E598_x0213, utf8_to_euc_E599_x0213, utf8_to_euc_E59A_x0213, utf8_to_euc_E59B_x0213,
+ utf8_to_euc_E59C_x0213, utf8_to_euc_E59D_x0213, utf8_to_euc_E59E_x0213, utf8_to_euc_E59F_x0213,
+ utf8_to_euc_E5A0_x0213, utf8_to_euc_E5A1_x0213, utf8_to_euc_E5A2_x0213, utf8_to_euc_E5A3_x0213,
+ utf8_to_euc_E5A4_x0213, utf8_to_euc_E5A5_x0213, utf8_to_euc_E5A6_x0213, utf8_to_euc_E5A7_x0213,
+ utf8_to_euc_E5A8_x0213, utf8_to_euc_E5A9_x0213, utf8_to_euc_E5AA_x0213, utf8_to_euc_E5AB_x0213,
+ utf8_to_euc_E5AC_x0213, utf8_to_euc_E5AD_x0213, utf8_to_euc_E5AE_x0213, utf8_to_euc_E5AF_x0213,
+ utf8_to_euc_E5B0_x0213, utf8_to_euc_E5B1_x0213, utf8_to_euc_E5B2_x0213, utf8_to_euc_E5B3_x0213,
+ utf8_to_euc_E5B4_x0213, utf8_to_euc_E5B5_x0213, utf8_to_euc_E5B6_x0213, utf8_to_euc_E5B7_x0213,
+ utf8_to_euc_E5B8_x0213, utf8_to_euc_E5B9_x0213, utf8_to_euc_E5BA_x0213, utf8_to_euc_E5BB_x0213,
+ utf8_to_euc_E5BC_x0213, utf8_to_euc_E5BD_x0213, utf8_to_euc_E5BE_x0213, utf8_to_euc_E5BF_x0213,
+};
+static const unsigned short *const utf8_to_euc_E6[] = {
+ utf8_to_euc_E680, utf8_to_euc_E681, utf8_to_euc_E682, utf8_to_euc_E683,
+ utf8_to_euc_E684, utf8_to_euc_E685, utf8_to_euc_E686, utf8_to_euc_E687,
+ utf8_to_euc_E688, utf8_to_euc_E689, utf8_to_euc_E68A, utf8_to_euc_E68B,
+ utf8_to_euc_E68C, utf8_to_euc_E68D, utf8_to_euc_E68E, utf8_to_euc_E68F,
+ utf8_to_euc_E690, utf8_to_euc_E691, utf8_to_euc_E692, utf8_to_euc_E693,
+ utf8_to_euc_E694, utf8_to_euc_E695, utf8_to_euc_E696, utf8_to_euc_E697,
+ utf8_to_euc_E698, utf8_to_euc_E699, utf8_to_euc_E69A, utf8_to_euc_E69B,
+ utf8_to_euc_E69C, utf8_to_euc_E69D, utf8_to_euc_E69E, utf8_to_euc_E69F,
+ utf8_to_euc_E6A0, utf8_to_euc_E6A1, utf8_to_euc_E6A2, utf8_to_euc_E6A3,
+ utf8_to_euc_E6A4, utf8_to_euc_E6A5, utf8_to_euc_E6A6, utf8_to_euc_E6A7,
+ utf8_to_euc_E6A8, utf8_to_euc_E6A9, utf8_to_euc_E6AA, utf8_to_euc_E6AB,
+ utf8_to_euc_E6AC, utf8_to_euc_E6AD, utf8_to_euc_E6AE, utf8_to_euc_E6AF,
+ utf8_to_euc_E6B0, utf8_to_euc_E6B1, utf8_to_euc_E6B2, utf8_to_euc_E6B3,
+ utf8_to_euc_E6B4, utf8_to_euc_E6B5, utf8_to_euc_E6B6, utf8_to_euc_E6B7,
+ utf8_to_euc_E6B8, utf8_to_euc_E6B9, utf8_to_euc_E6BA, utf8_to_euc_E6BB,
+ utf8_to_euc_E6BC, utf8_to_euc_E6BD, utf8_to_euc_E6BE, utf8_to_euc_E6BF,
+};
+static const unsigned short *const utf8_to_euc_E6_x0213[] = {
+ utf8_to_euc_E680_x0213, utf8_to_euc_E681_x0213, utf8_to_euc_E682_x0213, utf8_to_euc_E683_x0213,
+ utf8_to_euc_E684_x0213, utf8_to_euc_E685_x0213, utf8_to_euc_E686_x0213, utf8_to_euc_E687_x0213,
+ utf8_to_euc_E688_x0213, utf8_to_euc_E689_x0213, utf8_to_euc_E68A_x0213, utf8_to_euc_E68B_x0213,
+ utf8_to_euc_E68C_x0213, utf8_to_euc_E68D_x0213, utf8_to_euc_E68E_x0213, utf8_to_euc_E68F_x0213,
+ utf8_to_euc_E690_x0213, utf8_to_euc_E691_x0213, utf8_to_euc_E692_x0213, utf8_to_euc_E693_x0213,
+ utf8_to_euc_E694_x0213, utf8_to_euc_E695_x0213, utf8_to_euc_E696_x0213, utf8_to_euc_E697_x0213,
+ utf8_to_euc_E698_x0213, utf8_to_euc_E699_x0213, utf8_to_euc_E69A_x0213, utf8_to_euc_E69B_x0213,
+ utf8_to_euc_E69C_x0213, utf8_to_euc_E69D_x0213, utf8_to_euc_E69E_x0213, utf8_to_euc_E69F_x0213,
+ utf8_to_euc_E6A0_x0213, utf8_to_euc_E6A1_x0213, utf8_to_euc_E6A2_x0213, utf8_to_euc_E6A3_x0213,
+ utf8_to_euc_E6A4_x0213, utf8_to_euc_E6A5_x0213, utf8_to_euc_E6A6_x0213, utf8_to_euc_E6A7_x0213,
+ utf8_to_euc_E6A8_x0213, utf8_to_euc_E6A9_x0213, utf8_to_euc_E6AA_x0213, utf8_to_euc_E6AB_x0213,
+ utf8_to_euc_E6AC_x0213, utf8_to_euc_E6AD_x0213, utf8_to_euc_E6AE_x0213, utf8_to_euc_E6AF_x0213,
+ utf8_to_euc_E6B0_x0213, utf8_to_euc_E6B1_x0213, utf8_to_euc_E6B2_x0213, utf8_to_euc_E6B3_x0213,
+ utf8_to_euc_E6B4_x0213, utf8_to_euc_E6B5_x0213, utf8_to_euc_E6B6_x0213, utf8_to_euc_E6B7_x0213,
+ utf8_to_euc_E6B8_x0213, utf8_to_euc_E6B9_x0213, utf8_to_euc_E6BA_x0213, utf8_to_euc_E6BB_x0213,
+ utf8_to_euc_E6BC_x0213, utf8_to_euc_E6BD_x0213, utf8_to_euc_E6BE_x0213, utf8_to_euc_E6BF_x0213,
+};
+static const unsigned short *const utf8_to_euc_E7[] = {
+ utf8_to_euc_E780, utf8_to_euc_E781, utf8_to_euc_E782, utf8_to_euc_E783,
+ utf8_to_euc_E784, utf8_to_euc_E785, utf8_to_euc_E786, utf8_to_euc_E787,
+ utf8_to_euc_E788, utf8_to_euc_E789, utf8_to_euc_E78A, utf8_to_euc_E78B,
+ utf8_to_euc_E78C, utf8_to_euc_E78D, utf8_to_euc_E78E, utf8_to_euc_E78F,
+ utf8_to_euc_E790, utf8_to_euc_E791, utf8_to_euc_E792, utf8_to_euc_E793,
+ utf8_to_euc_E794, utf8_to_euc_E795, utf8_to_euc_E796, utf8_to_euc_E797,
+ utf8_to_euc_E798, utf8_to_euc_E799, utf8_to_euc_E79A, utf8_to_euc_E79B,
+ utf8_to_euc_E79C, utf8_to_euc_E79D, utf8_to_euc_E79E, utf8_to_euc_E79F,
+ utf8_to_euc_E7A0, utf8_to_euc_E7A1, utf8_to_euc_E7A2, utf8_to_euc_E7A3,
+ utf8_to_euc_E7A4, utf8_to_euc_E7A5, utf8_to_euc_E7A6, utf8_to_euc_E7A7,
+ utf8_to_euc_E7A8, utf8_to_euc_E7A9, utf8_to_euc_E7AA, utf8_to_euc_E7AB,
+ utf8_to_euc_E7AC, utf8_to_euc_E7AD, utf8_to_euc_E7AE, utf8_to_euc_E7AF,
+ utf8_to_euc_E7B0, utf8_to_euc_E7B1, utf8_to_euc_E7B2, utf8_to_euc_E7B3,
+ utf8_to_euc_E7B4, utf8_to_euc_E7B5, utf8_to_euc_E7B6, utf8_to_euc_E7B7,
+ utf8_to_euc_E7B8, utf8_to_euc_E7B9, utf8_to_euc_E7BA, 0,
+ utf8_to_euc_E7BC, utf8_to_euc_E7BD, utf8_to_euc_E7BE, utf8_to_euc_E7BF,
+};
+static const unsigned short *const utf8_to_euc_E7_x0213[] = {
+ utf8_to_euc_E780_x0213, utf8_to_euc_E781_x0213, utf8_to_euc_E782_x0213, utf8_to_euc_E783_x0213,
+ utf8_to_euc_E784_x0213, utf8_to_euc_E785_x0213, utf8_to_euc_E786_x0213, utf8_to_euc_E787_x0213,
+ utf8_to_euc_E788_x0213, utf8_to_euc_E789_x0213, utf8_to_euc_E78A_x0213, utf8_to_euc_E78B_x0213,
+ utf8_to_euc_E78C_x0213, utf8_to_euc_E78D_x0213, utf8_to_euc_E78E_x0213, utf8_to_euc_E78F_x0213,
+ utf8_to_euc_E790_x0213, utf8_to_euc_E791_x0213, utf8_to_euc_E792_x0213, utf8_to_euc_E793_x0213,
+ utf8_to_euc_E794_x0213, utf8_to_euc_E795_x0213, utf8_to_euc_E796_x0213, utf8_to_euc_E797_x0213,
+ utf8_to_euc_E798_x0213, utf8_to_euc_E799_x0213, utf8_to_euc_E79A_x0213, utf8_to_euc_E79B_x0213,
+ utf8_to_euc_E79C_x0213, utf8_to_euc_E79D_x0213, utf8_to_euc_E79E_x0213, utf8_to_euc_E79F_x0213,
+ utf8_to_euc_E7A0_x0213, utf8_to_euc_E7A1_x0213, utf8_to_euc_E7A2_x0213, utf8_to_euc_E7A3_x0213,
+ utf8_to_euc_E7A4_x0213, utf8_to_euc_E7A5_x0213, utf8_to_euc_E7A6_x0213, utf8_to_euc_E7A7_x0213,
+ utf8_to_euc_E7A8_x0213, utf8_to_euc_E7A9_x0213, utf8_to_euc_E7AA_x0213, utf8_to_euc_E7AB_x0213,
+ utf8_to_euc_E7AC_x0213, utf8_to_euc_E7AD_x0213, utf8_to_euc_E7AE_x0213, utf8_to_euc_E7AF_x0213,
+ utf8_to_euc_E7B0_x0213, utf8_to_euc_E7B1_x0213, utf8_to_euc_E7B2_x0213, utf8_to_euc_E7B3_x0213,
+ utf8_to_euc_E7B4_x0213, utf8_to_euc_E7B5_x0213, utf8_to_euc_E7B6_x0213, utf8_to_euc_E7B7_x0213,
+ utf8_to_euc_E7B8_x0213, utf8_to_euc_E7B9_x0213, utf8_to_euc_E7BA_x0213, 0,
+ utf8_to_euc_E7BC_x0213, utf8_to_euc_E7BD_x0213, utf8_to_euc_E7BE_x0213, utf8_to_euc_E7BF_x0213,
+};
+static const unsigned short *const utf8_to_euc_E8[] = {
+ utf8_to_euc_E880, utf8_to_euc_E881, utf8_to_euc_E882, utf8_to_euc_E883,
+ utf8_to_euc_E884, utf8_to_euc_E885, utf8_to_euc_E886, utf8_to_euc_E887,
+ utf8_to_euc_E888, utf8_to_euc_E889, utf8_to_euc_E88A, utf8_to_euc_E88B,
+ utf8_to_euc_E88C, utf8_to_euc_E88D, utf8_to_euc_E88E, utf8_to_euc_E88F,
+ utf8_to_euc_E890, utf8_to_euc_E891, utf8_to_euc_E892, utf8_to_euc_E893,
+ utf8_to_euc_E894, utf8_to_euc_E895, utf8_to_euc_E896, utf8_to_euc_E897,
+ utf8_to_euc_E898, utf8_to_euc_E899, utf8_to_euc_E89A, utf8_to_euc_E89B,
+ utf8_to_euc_E89C, utf8_to_euc_E89D, utf8_to_euc_E89E, utf8_to_euc_E89F,
+ utf8_to_euc_E8A0, utf8_to_euc_E8A1, utf8_to_euc_E8A2, utf8_to_euc_E8A3,
+ utf8_to_euc_E8A4, utf8_to_euc_E8A5, utf8_to_euc_E8A6, utf8_to_euc_E8A7,
+ utf8_to_euc_E8A8, utf8_to_euc_E8A9, utf8_to_euc_E8AA, utf8_to_euc_E8AB,
+ utf8_to_euc_E8AC, utf8_to_euc_E8AD, utf8_to_euc_E8AE, 0,
+ utf8_to_euc_E8B0, utf8_to_euc_E8B1, utf8_to_euc_E8B2, utf8_to_euc_E8B3,
+ utf8_to_euc_E8B4, utf8_to_euc_E8B5, utf8_to_euc_E8B6, utf8_to_euc_E8B7,
+ utf8_to_euc_E8B8, utf8_to_euc_E8B9, utf8_to_euc_E8BA, utf8_to_euc_E8BB,
+ utf8_to_euc_E8BC, utf8_to_euc_E8BD, utf8_to_euc_E8BE, utf8_to_euc_E8BF,
+};
+static const unsigned short *const utf8_to_euc_E8_x0213[] = {
+ utf8_to_euc_E880_x0213, utf8_to_euc_E881_x0213, utf8_to_euc_E882_x0213, utf8_to_euc_E883_x0213,
+ utf8_to_euc_E884_x0213, utf8_to_euc_E885_x0213, utf8_to_euc_E886_x0213, utf8_to_euc_E887_x0213,
+ utf8_to_euc_E888_x0213, utf8_to_euc_E889_x0213, utf8_to_euc_E88A_x0213, utf8_to_euc_E88B_x0213,
+ utf8_to_euc_E88C_x0213, utf8_to_euc_E88D_x0213, utf8_to_euc_E88E_x0213, utf8_to_euc_E88F_x0213,
+ utf8_to_euc_E890_x0213, utf8_to_euc_E891_x0213, utf8_to_euc_E892_x0213, utf8_to_euc_E893_x0213,
+ utf8_to_euc_E894_x0213, utf8_to_euc_E895_x0213, utf8_to_euc_E896_x0213, utf8_to_euc_E897_x0213,
+ utf8_to_euc_E898_x0213, utf8_to_euc_E899_x0213, utf8_to_euc_E89A_x0213, utf8_to_euc_E89B_x0213,
+ utf8_to_euc_E89C_x0213, utf8_to_euc_E89D_x0213, utf8_to_euc_E89E_x0213, utf8_to_euc_E89F_x0213,
+ utf8_to_euc_E8A0_x0213, utf8_to_euc_E8A1_x0213, utf8_to_euc_E8A2_x0213, utf8_to_euc_E8A3_x0213,
+ utf8_to_euc_E8A4_x0213, utf8_to_euc_E8A5_x0213, utf8_to_euc_E8A6_x0213, utf8_to_euc_E8A7_x0213,
+ utf8_to_euc_E8A8_x0213, utf8_to_euc_E8A9_x0213, utf8_to_euc_E8AA_x0213, utf8_to_euc_E8AB_x0213,
+ utf8_to_euc_E8AC_x0213, utf8_to_euc_E8AD_x0213, utf8_to_euc_E8AE_x0213, 0,
+ utf8_to_euc_E8B0_x0213, utf8_to_euc_E8B1_x0213, utf8_to_euc_E8B2_x0213, utf8_to_euc_E8B3_x0213,
+ utf8_to_euc_E8B4_x0213, utf8_to_euc_E8B5_x0213, utf8_to_euc_E8B6_x0213, utf8_to_euc_E8B7_x0213,
+ utf8_to_euc_E8B8_x0213, utf8_to_euc_E8B9_x0213, utf8_to_euc_E8BA_x0213, utf8_to_euc_E8BB_x0213,
+ utf8_to_euc_E8BC_x0213, utf8_to_euc_E8BD_x0213, utf8_to_euc_E8BE_x0213, utf8_to_euc_E8BF_x0213,
+};
+static const unsigned short *const utf8_to_euc_E9[] = {
+ utf8_to_euc_E980, utf8_to_euc_E981, utf8_to_euc_E982, utf8_to_euc_E983,
+ utf8_to_euc_E984, utf8_to_euc_E985, utf8_to_euc_E986, utf8_to_euc_E987,
+ utf8_to_euc_E988, utf8_to_euc_E989, utf8_to_euc_E98A, utf8_to_euc_E98B,
+ utf8_to_euc_E98C, utf8_to_euc_E98D, utf8_to_euc_E98E, utf8_to_euc_E98F,
+ utf8_to_euc_E990, utf8_to_euc_E991, utf8_to_euc_E992, 0,
+ 0, utf8_to_euc_E995, utf8_to_euc_E996, utf8_to_euc_E997,
+ utf8_to_euc_E998, utf8_to_euc_E999, utf8_to_euc_E99A, utf8_to_euc_E99B,
+ utf8_to_euc_E99C, utf8_to_euc_E99D, utf8_to_euc_E99E, utf8_to_euc_E99F,
+ utf8_to_euc_E9A0, utf8_to_euc_E9A1, utf8_to_euc_E9A2, utf8_to_euc_E9A3,
+ utf8_to_euc_E9A4, utf8_to_euc_E9A5, utf8_to_euc_E9A6, utf8_to_euc_E9A7,
+ utf8_to_euc_E9A8, utf8_to_euc_E9A9, utf8_to_euc_E9AA, utf8_to_euc_E9AB,
+ utf8_to_euc_E9AC, utf8_to_euc_E9AD, utf8_to_euc_E9AE, utf8_to_euc_E9AF,
+ utf8_to_euc_E9B0, utf8_to_euc_E9B1, 0, utf8_to_euc_E9B3,
+ utf8_to_euc_E9B4, utf8_to_euc_E9B5, utf8_to_euc_E9B6, utf8_to_euc_E9B7,
+ utf8_to_euc_E9B8, utf8_to_euc_E9B9, utf8_to_euc_E9BA, utf8_to_euc_E9BB,
+ utf8_to_euc_E9BC, utf8_to_euc_E9BD, utf8_to_euc_E9BE, 0,
+};
+static const unsigned short *const utf8_to_euc_E9_x0213[] = {
+ utf8_to_euc_E980_x0213, utf8_to_euc_E981_x0213, utf8_to_euc_E982_x0213, utf8_to_euc_E983_x0213,
+ utf8_to_euc_E984_x0213, utf8_to_euc_E985_x0213, utf8_to_euc_E986_x0213, utf8_to_euc_E987_x0213,
+ utf8_to_euc_E988_x0213, utf8_to_euc_E989_x0213, utf8_to_euc_E98A_x0213, utf8_to_euc_E98B_x0213,
+ utf8_to_euc_E98C_x0213, utf8_to_euc_E98D_x0213, utf8_to_euc_E98E_x0213, utf8_to_euc_E98F_x0213,
+ utf8_to_euc_E990_x0213, utf8_to_euc_E991_x0213, utf8_to_euc_E992, 0,
+ 0, utf8_to_euc_E995_x0213, utf8_to_euc_E996_x0213, utf8_to_euc_E997_x0213,
+ utf8_to_euc_E998_x0213, utf8_to_euc_E999_x0213, utf8_to_euc_E99A_x0213, utf8_to_euc_E99B_x0213,
+ utf8_to_euc_E99C_x0213, utf8_to_euc_E99D_x0213, utf8_to_euc_E99E_x0213, utf8_to_euc_E99F_x0213,
+ utf8_to_euc_E9A0_x0213, utf8_to_euc_E9A1_x0213, utf8_to_euc_E9A2_x0213, utf8_to_euc_E9A3_x0213,
+ utf8_to_euc_E9A4_x0213, utf8_to_euc_E9A5_x0213, utf8_to_euc_E9A6_x0213, utf8_to_euc_E9A7_x0213,
+ utf8_to_euc_E9A8_x0213, utf8_to_euc_E9A9_x0213, utf8_to_euc_E9AA_x0213, utf8_to_euc_E9AB_x0213,
+ utf8_to_euc_E9AC_x0213, utf8_to_euc_E9AD_x0213, utf8_to_euc_E9AE_x0213, utf8_to_euc_E9AF_x0213,
+ utf8_to_euc_E9B0_x0213, utf8_to_euc_E9B1_x0213, 0, utf8_to_euc_E9B3_x0213,
+ utf8_to_euc_E9B4_x0213, utf8_to_euc_E9B5_x0213, utf8_to_euc_E9B6_x0213, utf8_to_euc_E9B7_x0213,
+ utf8_to_euc_E9B8_x0213, utf8_to_euc_E9B9_x0213, utf8_to_euc_E9BA_x0213, utf8_to_euc_E9BB_x0213,
+ utf8_to_euc_E9BC_x0213, utf8_to_euc_E9BD_x0213, utf8_to_euc_E9BE_x0213, 0,
+};
+static const unsigned short *const utf8_to_euc_EF[] = {
+ 0, 0, 0, 0,
+ 0, 0, 0, 0,
+ 0, 0, 0, 0,
+ 0, 0, 0, 0,
+ 0, 0, 0, 0,
+ 0, 0, 0, 0,
+ 0, 0, 0, 0,
+ 0, 0, 0, 0,
+ 0, 0, 0, 0,
+ utf8_to_euc_EFA4, 0, 0, utf8_to_euc_EFA7,
+ utf8_to_euc_EFA8, 0, 0, 0,
+ 0, 0, 0, 0,
+ 0, 0, 0, 0,
+ 0, 0, 0, 0,
+ 0, 0, 0, 0,
+ utf8_to_euc_EFBC, utf8_to_euc_EFBD, utf8_to_euc_EFBE, utf8_to_euc_EFBF,
+};
+static const unsigned short *const utf8_to_euc_EF_ms[] = {
+ 0, 0, 0, 0,
+ 0, 0, 0, 0,
+ 0, 0, 0, 0,
+ 0, 0, 0, 0,
+ 0, 0, 0, 0,
+ 0, 0, 0, 0,
+ 0, 0, 0, 0,
+ 0, 0, 0, 0,
+ 0, 0, 0, 0,
+ utf8_to_euc_EFA4, 0, 0, utf8_to_euc_EFA7,
+ utf8_to_euc_EFA8, 0, 0, 0,
+ 0, 0, 0, 0,
+ 0, 0, 0, 0,
+ 0, 0, 0, 0,
+ 0, 0, 0, 0,
+ utf8_to_euc_EFBC, utf8_to_euc_EFBD_ms, utf8_to_euc_EFBE, utf8_to_euc_EFBF,
+};
+static const unsigned short *const utf8_to_euc_EF_x0213[] = {
+ 0, 0, 0, 0,
+ 0, 0, 0, 0,
+ 0, 0, 0, 0,
+ 0, 0, 0, 0,
+ 0, 0, 0, 0,
+ 0, 0, 0, 0,
+ 0, 0, 0, 0,
+ 0, 0, 0, 0,
+ 0, 0, 0, 0,
+ utf8_to_euc_EFA4_x0213, utf8_to_euc_EFA5_x0213, 0, utf8_to_euc_EFA7_x0213,
+ utf8_to_euc_EFA8_x0213, utf8_to_euc_EFA9_x0213, 0, 0,
+ 0, 0, 0, 0,
+ 0, 0, 0, 0,
+ 0, 0, 0, 0,
+ 0, utf8_to_euc_EFB9_x0213, 0, 0,
+ utf8_to_euc_EFBC_x0213, utf8_to_euc_EFBD_x0213, utf8_to_euc_EFBE, utf8_to_euc_EFBF,
+};
+const unsigned short *const utf8_to_euc_2bytes[] = {
+ 0, 0, 0, 0,
+ 0, 0, 0, 0,
+ 0, 0, 0, 0,
+ 0, 0, 0, 0,
+ 0, 0, 0, 0,
+ 0, 0, 0, 0,
+ 0, 0, 0, 0,
+ 0, 0, 0, 0,
+ 0, 0, 0, 0,
+ 0, 0, 0, 0,
+ 0, 0, 0, 0,
+ 0, 0, 0, 0,
+ 0, 0, 0, 0,
+ 0, 0, 0, 0,
+ 0, 0, 0, 0,
+ 0, 0, 0, 0,
+ 0, 0, utf8_to_euc_C2, utf8_to_euc_C3,
+ utf8_to_euc_C4, utf8_to_euc_C5, 0, utf8_to_euc_C7,
+ 0, 0, 0, utf8_to_euc_CB,
+ 0, 0, utf8_to_euc_CE, utf8_to_euc_CF,
+ utf8_to_euc_D0, utf8_to_euc_D1, 0, 0,
+ 0, 0, 0, 0,
+ 0, 0, 0, 0,
+ 0, 0, 0, 0,
+ 0, 0, 0, 0,
+ 0, 0, 0, 0,
+ 0, 0, 0, 0,
+ 0, 0, 0, 0,
+};
+const unsigned short *const utf8_to_euc_2bytes_ms[] = {
+ 0, 0, 0, 0,
+ 0, 0, 0, 0,
+ 0, 0, 0, 0,
+ 0, 0, 0, 0,
+ 0, 0, 0, 0,
+ 0, 0, 0, 0,
+ 0, 0, 0, 0,
+ 0, 0, 0, 0,
+ 0, 0, 0, 0,
+ 0, 0, 0, 0,
+ 0, 0, 0, 0,
+ 0, 0, 0, 0,
+ 0, 0, 0, 0,
+ 0, 0, 0, 0,
+ 0, 0, 0, 0,
+ 0, 0, 0, 0,
+ 0, 0, utf8_to_euc_C2_ms, utf8_to_euc_C3,
+ utf8_to_euc_C4, utf8_to_euc_C5, 0, utf8_to_euc_C7,
+ 0, 0, 0, utf8_to_euc_CB,
+ 0, 0, utf8_to_euc_CE, utf8_to_euc_CF,
+ utf8_to_euc_D0, utf8_to_euc_D1, 0, 0,
+ 0, 0, 0, 0,
+ 0, 0, 0, 0,
+ 0, 0, 0, 0,
+ 0, 0, 0, 0,
+ 0, 0, 0, 0,
+ 0, 0, 0, 0,
+ 0, 0, 0, 0,
+};
+const unsigned short *const utf8_to_euc_2bytes_932[] = {
+ 0, 0, 0, 0,
+ 0, 0, 0, 0,
+ 0, 0, 0, 0,
+ 0, 0, 0, 0,
+ 0, 0, 0, 0,
+ 0, 0, 0, 0,
+ 0, 0, 0, 0,
+ 0, 0, 0, 0,
+ 0, 0, 0, 0,
+ 0, 0, 0, 0,
+ 0, 0, 0, 0,
+ 0, 0, 0, 0,
+ 0, 0, 0, 0,
+ 0, 0, 0, 0,
+ 0, 0, 0, 0,
+ 0, 0, 0, 0,
+ 0, 0, utf8_to_euc_C2_932, utf8_to_euc_C3_932,
+ utf8_to_euc_C4, utf8_to_euc_C5, 0, utf8_to_euc_C7,
+ 0, 0, 0, utf8_to_euc_CB,
+ 0, 0, utf8_to_euc_CE, utf8_to_euc_CF,
+ utf8_to_euc_D0, utf8_to_euc_D1, 0, 0,
+ 0, 0, 0, 0,
+ 0, 0, 0, 0,
+ 0, 0, 0, 0,
+ 0, 0, 0, 0,
+ 0, 0, 0, 0,
+ 0, 0, 0, 0,
+ 0, 0, 0, 0,
+};
+const unsigned short *const utf8_to_euc_2bytes_mac[] = {
+ 0, 0, 0, 0,
+ 0, 0, 0, 0,
+ 0, 0, 0, 0,
+ 0, 0, 0, 0,
+ 0, 0, 0, 0,
+ 0, 0, 0, 0,
+ 0, 0, 0, 0,
+ 0, 0, 0, 0,
+ 0, 0, 0, 0,
+ 0, 0, 0, 0,
+ 0, 0, 0, 0,
+ 0, 0, 0, 0,
+ 0, 0, 0, 0,
+ 0, 0, 0, 0,
+ 0, 0, 0, 0,
+ 0, 0, 0, 0,
+ 0, 0, utf8_to_euc_C2_mac, utf8_to_euc_C3,
+ utf8_to_euc_C4, utf8_to_euc_C5, 0, utf8_to_euc_C7,
+ 0, 0, 0, utf8_to_euc_CB,
+ 0, 0, utf8_to_euc_CE, utf8_to_euc_CF,
+ utf8_to_euc_D0, utf8_to_euc_D1, 0, 0,
+ 0, 0, 0, 0,
+ 0, 0, 0, 0,
+ 0, 0, 0, 0,
+ 0, 0, 0, 0,
+ 0, 0, 0, 0,
+ 0, 0, 0, 0,
+ 0, 0, 0, 0,
+};
+const unsigned short *const utf8_to_euc_2bytes_x0213[] = {
+ 0, 0, 0, 0,
+ 0, 0, 0, 0,
+ 0, 0, 0, 0,
+ 0, 0, 0, 0,
+ 0, 0, 0, 0,
+ 0, 0, 0, 0,
+ 0, 0, 0, 0,
+ 0, 0, 0, 0,
+ 0, 0, 0, 0,
+ 0, 0, 0, 0,
+ 0, 0, 0, 0,
+ 0, 0, 0, 0,
+ 0, 0, 0, 0,
+ 0, 0, 0, 0,
+ 0, 0, 0, 0,
+ 0, 0, 0, 0,
+ 0, 0, utf8_to_euc_C2_x0213, utf8_to_euc_C3_x0213,
+ utf8_to_euc_C4_x0213, utf8_to_euc_C5_x0213, utf8_to_euc_C6_x0213, utf8_to_euc_C7_x0213,
+ 0, utf8_to_euc_C9_x0213, utf8_to_euc_CA_x0213, utf8_to_euc_CB_x0213,
+ utf8_to_euc_CC_x0213, utf8_to_euc_CD_x0213, utf8_to_euc_CE, utf8_to_euc_CF_x0213,
+ utf8_to_euc_D0, utf8_to_euc_D1, 0, 0,
+ 0, 0, 0, 0,
+ 0, 0, 0, 0,
+ 0, 0, 0, 0,
+ 0, 0, 0, 0,
+ 0, 0, 0, 0,
+ 0, 0, 0, 0,
+ 0, 0, 0, 0,
+};
+const unsigned short *const *const utf8_to_euc_3bytes[] = {
+ 0, 0, utf8_to_euc_E2, utf8_to_euc_E3,
+ utf8_to_euc_E4, utf8_to_euc_E5, utf8_to_euc_E6, utf8_to_euc_E7,
+ utf8_to_euc_E8, utf8_to_euc_E9, 0, 0,
+ 0, 0, 0, utf8_to_euc_EF,
+};
+const unsigned short *const *const utf8_to_euc_3bytes_ms[] = {
+ 0, 0, utf8_to_euc_E2_ms, utf8_to_euc_E3,
+ utf8_to_euc_E4, utf8_to_euc_E5, utf8_to_euc_E6, utf8_to_euc_E7,
+ utf8_to_euc_E8, utf8_to_euc_E9, 0, 0,
+ 0, 0, 0, utf8_to_euc_EF_ms,
+};
+const unsigned short *const *const utf8_to_euc_3bytes_932[] = {
+ 0, 0, utf8_to_euc_E2_932, utf8_to_euc_E3_932,
+ utf8_to_euc_E4, utf8_to_euc_E5, utf8_to_euc_E6, utf8_to_euc_E7,
+ utf8_to_euc_E8, utf8_to_euc_E9, 0, 0,
+ 0, 0, 0, utf8_to_euc_EF_ms,
+};
+const unsigned short *const *const utf8_to_euc_3bytes_mac[] = {
+ 0, 0, utf8_to_euc_E2_mac, utf8_to_euc_E3_mac,
+ utf8_to_euc_E4, utf8_to_euc_E5, utf8_to_euc_E6, utf8_to_euc_E7,
+ utf8_to_euc_E8, utf8_to_euc_E9, 0, 0,
+ 0, 0, 0, utf8_to_euc_EF_ms,
+};
+const unsigned short *const *const utf8_to_euc_3bytes_x0213[] = {
+ 0, utf8_to_euc_E1_x0213, utf8_to_euc_E2_x0213, utf8_to_euc_E3_x0213,
+ utf8_to_euc_E4_x0213, utf8_to_euc_E5_x0213, utf8_to_euc_E6_x0213, utf8_to_euc_E7_x0213,
+ utf8_to_euc_E8_x0213, utf8_to_euc_E9_x0213, 0, 0,
+ 0, 0, 0, utf8_to_euc_EF_x0213,
+};
+
+#ifdef UNICODE_NORMALIZATION
+
+/* Normalization Table by Apple */
+/* http://developer.apple.com/technotes/tn/tn1150table.html */
+
+const struct normalization_pair normalization_table[] = {
+ {{0xcd,0xbe}, {0x3b}},
+ {{0xc3,0x80}, {0x41,0xcc,0x80,0x00}},
+ {{0xc3,0x81}, {0x41,0xcc,0x81}},
+ {{0xc3,0x82}, {0x41,0xcc,0x82}},
+ {{0xe1,0xba,0xa6}, {0x41,0xcc,0x82,0xcc,0x80}},
+ {{0xe1,0xba,0xa4}, {0x41,0xcc,0x82,0xcc,0x81}},
+ {{0xe1,0xba,0xaa}, {0x41,0xcc,0x82,0xcc,0x83}},
+ {{0xe1,0xba,0xa8}, {0x41,0xcc,0x82,0xcc,0x89}},
+ {{0xc3,0x83}, {0x41,0xcc,0x83}},
+ {{0xc4,0x80}, {0x41,0xcc,0x84}},
+ {{0xc4,0x82}, {0x41,0xcc,0x86}},
+ {{0xe1,0xba,0xb0}, {0x41,0xcc,0x86,0xcc,0x80}},
+ {{0xe1,0xba,0xae}, {0x41,0xcc,0x86,0xcc,0x81}},
+ {{0xe1,0xba,0xb4}, {0x41,0xcc,0x86,0xcc,0x83}},
+ {{0xe1,0xba,0xb2}, {0x41,0xcc,0x86,0xcc,0x89}},
+ {{0xc7,0xa0}, {0x41,0xcc,0x87,0xcc,0x84}},
+ {{0xc3,0x84}, {0x41,0xcc,0x88}},
+ {{0xc7,0x9e}, {0x41,0xcc,0x88,0xcc,0x84}},
+ {{0xe1,0xba,0xa2}, {0x41,0xcc,0x89}},
+ {{0xc3,0x85}, {0x41,0xcc,0x8a}},
+ {{0xc7,0xba}, {0x41,0xcc,0x8a,0xcc,0x81}},
+ {{0xc7,0x8d}, {0x41,0xcc,0x8c}},
+ {{0xc8,0x80}, {0x41,0xcc,0x8f}},
+ {{0xc8,0x82}, {0x41,0xcc,0x91}},
+ {{0xe1,0xba,0xa0}, {0x41,0xcc,0xa3}},
+ {{0xe1,0xba,0xac}, {0x41,0xcc,0xa3,0xcc,0x82}},
+ {{0xe1,0xba,0xb6}, {0x41,0xcc,0xa3,0xcc,0x86}},
+ {{0xe1,0xb8,0x80}, {0x41,0xcc,0xa5}},
+ {{0xc4,0x84}, {0x41,0xcc,0xa8}},
+ {{0xe1,0xb8,0x82}, {0x42,0xcc,0x87}},
+ {{0xe1,0xb8,0x84}, {0x42,0xcc,0xa3}},
+ {{0xe1,0xb8,0x86}, {0x42,0xcc,0xb1}},
+ {{0xc4,0x86}, {0x43,0xcc,0x81}},
+ {{0xc4,0x88}, {0x43,0xcc,0x82}},
+ {{0xc4,0x8a}, {0x43,0xcc,0x87}},
+ {{0xc4,0x8c}, {0x43,0xcc,0x8c}},
+ {{0xc3,0x87}, {0x43,0xcc,0xa7}},
+ {{0xe1,0xb8,0x88}, {0x43,0xcc,0xa7,0xcc,0x81}},
+ {{0xe1,0xb8,0x8a}, {0x44,0xcc,0x87}},
+ {{0xc4,0x8e}, {0x44,0xcc,0x8c}},
+ {{0xe1,0xb8,0x8c}, {0x44,0xcc,0xa3}},
+ {{0xe1,0xb8,0x90}, {0x44,0xcc,0xa7}},
+ {{0xe1,0xb8,0x92}, {0x44,0xcc,0xad}},
+ {{0xe1,0xb8,0x8e}, {0x44,0xcc,0xb1}},
+ {{0xc3,0x88}, {0x45,0xcc,0x80}},
+ {{0xc3,0x89}, {0x45,0xcc,0x81}},
+ {{0xc3,0x8a}, {0x45,0xcc,0x82}},
+ {{0xe1,0xbb,0x80}, {0x45,0xcc,0x82,0xcc,0x80}},
+ {{0xe1,0xba,0xbe}, {0x45,0xcc,0x82,0xcc,0x81}},
+ {{0xe1,0xbb,0x84}, {0x45,0xcc,0x82,0xcc,0x83}},
+ {{0xe1,0xbb,0x82}, {0x45,0xcc,0x82,0xcc,0x89}},
+ {{0xe1,0xba,0xbc}, {0x45,0xcc,0x83}},
+ {{0xc4,0x92}, {0x45,0xcc,0x84}},
+ {{0xe1,0xb8,0x94}, {0x45,0xcc,0x84,0xcc,0x80}},
+ {{0xe1,0xb8,0x96}, {0x45,0xcc,0x84,0xcc,0x81}},
+ {{0xc4,0x94}, {0x45,0xcc,0x86}},
+ {{0xc4,0x96}, {0x45,0xcc,0x87}},
+ {{0xc3,0x8b}, {0x45,0xcc,0x88}},
+ {{0xe1,0xba,0xba}, {0x45,0xcc,0x89}},
+ {{0xc4,0x9a}, {0x45,0xcc,0x8c}},
+ {{0xc8,0x84}, {0x45,0xcc,0x8f}},
+ {{0xc8,0x86}, {0x45,0xcc,0x91}},
+ {{0xe1,0xba,0xb8}, {0x45,0xcc,0xa3}},
+ {{0xe1,0xbb,0x86}, {0x45,0xcc,0xa3,0xcc,0x82}},
+ {{0xe1,0xb8,0x9c}, {0x45,0xcc,0xa7,0xcc,0x86}},
+ {{0xc4,0x98}, {0x45,0xcc,0xa8}},
+ {{0xe1,0xb8,0x98}, {0x45,0xcc,0xad}},
+ {{0xe1,0xb8,0x9a}, {0x45,0xcc,0xb0}},
+ {{0xe1,0xb8,0x9e}, {0x46,0xcc,0x87}},
+ {{0xc7,0xb4}, {0x47,0xcc,0x81}},
+ {{0xc4,0x9c}, {0x47,0xcc,0x82}},
+ {{0xe1,0xb8,0xa0}, {0x47,0xcc,0x84}},
+ {{0xc4,0x9e}, {0x47,0xcc,0x86}},
+ {{0xc4,0xa0}, {0x47,0xcc,0x87}},
+ {{0xc7,0xa6}, {0x47,0xcc,0x8c}},
+ {{0xc4,0xa2}, {0x47,0xcc,0xa7}},
+ {{0xc4,0xa4}, {0x48,0xcc,0x82}},
+ {{0xe1,0xb8,0xa2}, {0x48,0xcc,0x87}},
+ {{0xe1,0xb8,0xa6}, {0x48,0xcc,0x88}},
+ {{0xe1,0xb8,0xa4}, {0x48,0xcc,0xa3}},
+ {{0xe1,0xb8,0xa8}, {0x48,0xcc,0xa7}},
+ {{0xe1,0xb8,0xaa}, {0x48,0xcc,0xae}},
+ {{0xc3,0x8c}, {0x49,0xcc,0x80}},
+ {{0xc3,0x8d}, {0x49,0xcc,0x81}},
+ {{0xc3,0x8e}, {0x49,0xcc,0x82}},
+ {{0xc4,0xa8}, {0x49,0xcc,0x83}},
+ {{0xc4,0xaa}, {0x49,0xcc,0x84}},
+ {{0xc4,0xac}, {0x49,0xcc,0x86}},
+ {{0xc4,0xb0}, {0x49,0xcc,0x87}},
+ {{0xc3,0x8f}, {0x49,0xcc,0x88}},
+ {{0xe1,0xb8,0xae}, {0x49,0xcc,0x88,0xcc,0x81}},
+ {{0xe1,0xbb,0x88}, {0x49,0xcc,0x89}},
+ {{0xc7,0x8f}, {0x49,0xcc,0x8c}},
+ {{0xc8,0x88}, {0x49,0xcc,0x8f}},
+ {{0xc8,0x8a}, {0x49,0xcc,0x91}},
+ {{0xe1,0xbb,0x8a}, {0x49,0xcc,0xa3}},
+ {{0xc4,0xae}, {0x49,0xcc,0xa8}},
+ {{0xe1,0xb8,0xac}, {0x49,0xcc,0xb0}},
+ {{0xc4,0xb4}, {0x4a,0xcc,0x82}},
+ {{0xe1,0xb8,0xb0}, {0x4b,0xcc,0x81}},
+ {{0xc7,0xa8}, {0x4b,0xcc,0x8c}},
+ {{0xe1,0xb8,0xb2}, {0x4b,0xcc,0xa3}},
+ {{0xc4,0xb6}, {0x4b,0xcc,0xa7}},
+ {{0xe1,0xb8,0xb4}, {0x4b,0xcc,0xb1}},
+ {{0xc4,0xb9}, {0x4c,0xcc,0x81}},
+ {{0xc4,0xbd}, {0x4c,0xcc,0x8c}},
+ {{0xe1,0xb8,0xb6}, {0x4c,0xcc,0xa3}},
+ {{0xe1,0xb8,0xb8}, {0x4c,0xcc,0xa3,0xcc,0x84}},
+ {{0xc4,0xbb}, {0x4c,0xcc,0xa7}},
+ {{0xe1,0xb8,0xbc}, {0x4c,0xcc,0xad}},
+ {{0xe1,0xb8,0xba}, {0x4c,0xcc,0xb1}},
+ {{0xe1,0xb8,0xbe}, {0x4d,0xcc,0x81}},
+ {{0xe1,0xb9,0x80}, {0x4d,0xcc,0x87}},
+ {{0xe1,0xb9,0x82}, {0x4d,0xcc,0xa3}},
+ {{0xc5,0x83}, {0x4e,0xcc,0x81}},
+ {{0xc3,0x91}, {0x4e,0xcc,0x83}},
+ {{0xe1,0xb9,0x84}, {0x4e,0xcc,0x87}},
+ {{0xc5,0x87}, {0x4e,0xcc,0x8c}},
+ {{0xe1,0xb9,0x86}, {0x4e,0xcc,0xa3}},
+ {{0xc5,0x85}, {0x4e,0xcc,0xa7}},
+ {{0xe1,0xb9,0x8a}, {0x4e,0xcc,0xad}},
+ {{0xe1,0xb9,0x88}, {0x4e,0xcc,0xb1}},
+ {{0xc3,0x92}, {0x4f,0xcc,0x80}},
+ {{0xc3,0x93}, {0x4f,0xcc,0x81}},
+ {{0xc3,0x94}, {0x4f,0xcc,0x82}},
+ {{0xe1,0xbb,0x92}, {0x4f,0xcc,0x82,0xcc,0x80}},
+ {{0xe1,0xbb,0x90}, {0x4f,0xcc,0x82,0xcc,0x81}},
+ {{0xe1,0xbb,0x96}, {0x4f,0xcc,0x82,0xcc,0x83}},
+ {{0xe1,0xbb,0x94}, {0x4f,0xcc,0x82,0xcc,0x89}},
+ {{0xc3,0x95}, {0x4f,0xcc,0x83}},
+ {{0xe1,0xb9,0x8c}, {0x4f,0xcc,0x83,0xcc,0x81}},
+ {{0xe1,0xb9,0x8e}, {0x4f,0xcc,0x83,0xcc,0x88}},
+ {{0xc5,0x8c}, {0x4f,0xcc,0x84}},
+ {{0xe1,0xb9,0x90}, {0x4f,0xcc,0x84,0xcc,0x80}},
+ {{0xe1,0xb9,0x92}, {0x4f,0xcc,0x84,0xcc,0x81}},
+ {{0xc5,0x8e}, {0x4f,0xcc,0x86}},
+ {{0xc3,0x96}, {0x4f,0xcc,0x88}},
+ {{0xe1,0xbb,0x8e}, {0x4f,0xcc,0x89}},
+ {{0xc5,0x90}, {0x4f,0xcc,0x8b}},
+ {{0xc7,0x91}, {0x4f,0xcc,0x8c}},
+ {{0xc8,0x8c}, {0x4f,0xcc,0x8f}},
+ {{0xc8,0x8e}, {0x4f,0xcc,0x91}},
+ {{0xc6,0xa0}, {0x4f,0xcc,0x9b}},
+ {{0xe1,0xbb,0x9c}, {0x4f,0xcc,0x9b,0xcc,0x80}},
+ {{0xe1,0xbb,0x9a}, {0x4f,0xcc,0x9b,0xcc,0x81}},
+ {{0xe1,0xbb,0xa0}, {0x4f,0xcc,0x9b,0xcc,0x83}},
+ {{0xe1,0xbb,0x9e}, {0x4f,0xcc,0x9b,0xcc,0x89}},
+ {{0xe1,0xbb,0xa2}, {0x4f,0xcc,0x9b,0xcc,0xa3}},
+ {{0xe1,0xbb,0x8c}, {0x4f,0xcc,0xa3}},
+ {{0xe1,0xbb,0x98}, {0x4f,0xcc,0xa3,0xcc,0x82}},
+ {{0xc7,0xaa}, {0x4f,0xcc,0xa8}},
+ {{0xc7,0xac}, {0x4f,0xcc,0xa8,0xcc,0x84}},
+ {{0xe1,0xb9,0x94}, {0x50,0xcc,0x81}},
+ {{0xe1,0xb9,0x96}, {0x50,0xcc,0x87}},
+ {{0xc5,0x94}, {0x52,0xcc,0x81}},
+ {{0xe1,0xb9,0x98}, {0x52,0xcc,0x87}},
+ {{0xc5,0x98}, {0x52,0xcc,0x8c}},
+ {{0xc8,0x90}, {0x52,0xcc,0x8f}},
+ {{0xc8,0x92}, {0x52,0xcc,0x91}},
+ {{0xe1,0xb9,0x9a}, {0x52,0xcc,0xa3}},
+ {{0xe1,0xb9,0x9c}, {0x52,0xcc,0xa3,0xcc,0x84}},
+ {{0xc5,0x96}, {0x52,0xcc,0xa7}},
+ {{0xe1,0xb9,0x9e}, {0x52,0xcc,0xb1}},
+ {{0xc5,0x9a}, {0x53,0xcc,0x81}},
+ {{0xe1,0xb9,0xa4}, {0x53,0xcc,0x81,0xcc,0x87}},
+ {{0xc5,0x9c}, {0x53,0xcc,0x82}},
+ {{0xe1,0xb9,0xa0}, {0x53,0xcc,0x87}},
+ {{0xc5,0xa0}, {0x53,0xcc,0x8c}},
+ {{0xe1,0xb9,0xa6}, {0x53,0xcc,0x8c,0xcc,0x87}},
+ {{0xe1,0xb9,0xa2}, {0x53,0xcc,0xa3}},
+ {{0xe1,0xb9,0xa8}, {0x53,0xcc,0xa3,0xcc,0x87}},
+ {{0xc5,0x9e}, {0x53,0xcc,0xa7}},
+ {{0xe1,0xb9,0xaa}, {0x54,0xcc,0x87}},
+ {{0xc5,0xa4}, {0x54,0xcc,0x8c}},
+ {{0xe1,0xb9,0xac}, {0x54,0xcc,0xa3}},
+ {{0xc5,0xa2}, {0x54,0xcc,0xa7}},
+ {{0xe1,0xb9,0xb0}, {0x54,0xcc,0xad}},
+ {{0xe1,0xb9,0xae}, {0x54,0xcc,0xb1}},
+ {{0xc3,0x99}, {0x55,0xcc,0x80}},
+ {{0xc3,0x9a}, {0x55,0xcc,0x81}},
+ {{0xc3,0x9b}, {0x55,0xcc,0x82}},
+ {{0xc5,0xa8}, {0x55,0xcc,0x83}},
+ {{0xe1,0xb9,0xb8}, {0x55,0xcc,0x83,0xcc,0x81}},
+ {{0xc5,0xaa}, {0x55,0xcc,0x84}},
+ {{0xe1,0xb9,0xba}, {0x55,0xcc,0x84,0xcc,0x88}},
+ {{0xc5,0xac}, {0x55,0xcc,0x86}},
+ {{0xc3,0x9c}, {0x55,0xcc,0x88}},
+ {{0xc7,0x9b}, {0x55,0xcc,0x88,0xcc,0x80}},
+ {{0xc7,0x97}, {0x55,0xcc,0x88,0xcc,0x81}},
+ {{0xc7,0x95}, {0x55,0xcc,0x88,0xcc,0x84}},
+ {{0xc7,0x99}, {0x55,0xcc,0x88,0xcc,0x8c}},
+ {{0xe1,0xbb,0xa6}, {0x55,0xcc,0x89}},
+ {{0xc5,0xae}, {0x55,0xcc,0x8a}},
+ {{0xc5,0xb0}, {0x55,0xcc,0x8b}},
+ {{0xc7,0x93}, {0x55,0xcc,0x8c}},
+ {{0xc8,0x94}, {0x55,0xcc,0x8f}},
+ {{0xc8,0x96}, {0x55,0xcc,0x91}},
+ {{0xc6,0xaf}, {0x55,0xcc,0x9b}},
+ {{0xe1,0xbb,0xaa}, {0x55,0xcc,0x9b,0xcc,0x80}},
+ {{0xe1,0xbb,0xa8}, {0x55,0xcc,0x9b,0xcc,0x81}},
+ {{0xe1,0xbb,0xae}, {0x55,0xcc,0x9b,0xcc,0x83}},
+ {{0xe1,0xbb,0xac}, {0x55,0xcc,0x9b,0xcc,0x89}},
+ {{0xe1,0xbb,0xb0}, {0x55,0xcc,0x9b,0xcc,0xa3}},
+ {{0xe1,0xbb,0xa4}, {0x55,0xcc,0xa3}},
+ {{0xe1,0xb9,0xb2}, {0x55,0xcc,0xa4}},
+ {{0xc5,0xb2}, {0x55,0xcc,0xa8}},
+ {{0xe1,0xb9,0xb6}, {0x55,0xcc,0xad}},
+ {{0xe1,0xb9,0xb4}, {0x55,0xcc,0xb0}},
+ {{0xe1,0xb9,0xbc}, {0x56,0xcc,0x83}},
+ {{0xe1,0xb9,0xbe}, {0x56,0xcc,0xa3}},
+ {{0xe1,0xba,0x80}, {0x57,0xcc,0x80}},
+ {{0xe1,0xba,0x82}, {0x57,0xcc,0x81}},
+ {{0xc5,0xb4}, {0x57,0xcc,0x82}},
+ {{0xe1,0xba,0x86}, {0x57,0xcc,0x87}},
+ {{0xe1,0xba,0x84}, {0x57,0xcc,0x88}},
+ {{0xe1,0xba,0x88}, {0x57,0xcc,0xa3}},
+ {{0xe1,0xba,0x8a}, {0x58,0xcc,0x87}},
+ {{0xe1,0xba,0x8c}, {0x58,0xcc,0x88}},
+ {{0xe1,0xbb,0xb2}, {0x59,0xcc,0x80}},
+ {{0xc3,0x9d}, {0x59,0xcc,0x81}},
+ {{0xc5,0xb6}, {0x59,0xcc,0x82}},
+ {{0xe1,0xbb,0xb8}, {0x59,0xcc,0x83}},
+ {{0xe1,0xba,0x8e}, {0x59,0xcc,0x87}},
+ {{0xc5,0xb8}, {0x59,0xcc,0x88}},
+ {{0xe1,0xbb,0xb6}, {0x59,0xcc,0x89}},
+ {{0xe1,0xbb,0xb4}, {0x59,0xcc,0xa3}},
+ {{0xc5,0xb9}, {0x5a,0xcc,0x81}},
+ {{0xe1,0xba,0x90}, {0x5a,0xcc,0x82}},
+ {{0xc5,0xbb}, {0x5a,0xcc,0x87}},
+ {{0xc5,0xbd}, {0x5a,0xcc,0x8c}},
+ {{0xe1,0xba,0x92}, {0x5a,0xcc,0xa3}},
+ {{0xe1,0xba,0x94}, {0x5a,0xcc,0xb1}},
+ {{0xe1,0xbf,0xaf}, {0x60}},
+ {{0xc3,0xa0}, {0x61,0xcc,0x80}},
+ {{0xc3,0xa1}, {0x61,0xcc,0x81}},
+ {{0xc3,0xa2}, {0x61,0xcc,0x82}},
+ {{0xe1,0xba,0xa7}, {0x61,0xcc,0x82,0xcc,0x80}},
+ {{0xe1,0xba,0xa5}, {0x61,0xcc,0x82,0xcc,0x81}},
+ {{0xe1,0xba,0xab}, {0x61,0xcc,0x82,0xcc,0x83}},
+ {{0xe1,0xba,0xa9}, {0x61,0xcc,0x82,0xcc,0x89}},
+ {{0xc3,0xa3}, {0x61,0xcc,0x83}},
+ {{0xc4,0x81}, {0x61,0xcc,0x84}},
+ {{0xc4,0x83}, {0x61,0xcc,0x86}},
+ {{0xe1,0xba,0xb1}, {0x61,0xcc,0x86,0xcc,0x80}},
+ {{0xe1,0xba,0xaf}, {0x61,0xcc,0x86,0xcc,0x81}},
+ {{0xe1,0xba,0xb5}, {0x61,0xcc,0x86,0xcc,0x83}},
+ {{0xe1,0xba,0xb3}, {0x61,0xcc,0x86,0xcc,0x89}},
+ {{0xc7,0xa1}, {0x61,0xcc,0x87,0xcc,0x84}},
+ {{0xc3,0xa4}, {0x61,0xcc,0x88}},
+ {{0xc7,0x9f}, {0x61,0xcc,0x88,0xcc,0x84}},
+ {{0xe1,0xba,0xa3}, {0x61,0xcc,0x89}},
+ {{0xc3,0xa5}, {0x61,0xcc,0x8a}},
+ {{0xc7,0xbb}, {0x61,0xcc,0x8a,0xcc,0x81}},
+ {{0xc7,0x8e}, {0x61,0xcc,0x8c}},
+ {{0xc8,0x81}, {0x61,0xcc,0x8f}},
+ {{0xc8,0x83}, {0x61,0xcc,0x91}},
+ {{0xe1,0xba,0xa1}, {0x61,0xcc,0xa3}},
+ {{0xe1,0xba,0xad}, {0x61,0xcc,0xa3,0xcc,0x82}},
+ {{0xe1,0xba,0xb7}, {0x61,0xcc,0xa3,0xcc,0x86}},
+ {{0xe1,0xb8,0x81}, {0x61,0xcc,0xa5}},
+ {{0xc4,0x85}, {0x61,0xcc,0xa8}},
+ {{0xe1,0xb8,0x83}, {0x62,0xcc,0x87}},
+ {{0xe1,0xb8,0x85}, {0x62,0xcc,0xa3}},
+ {{0xe1,0xb8,0x87}, {0x62,0xcc,0xb1}},
+ {{0xc4,0x87}, {0x63,0xcc,0x81}},
+ {{0xc4,0x89}, {0x63,0xcc,0x82}},
+ {{0xc4,0x8b}, {0x63,0xcc,0x87}},
+ {{0xc4,0x8d}, {0x63,0xcc,0x8c}},
+ {{0xc3,0xa7}, {0x63,0xcc,0xa7}},
+ {{0xe1,0xb8,0x89}, {0x63,0xcc,0xa7,0xcc,0x81}},
+ {{0xe1,0xb8,0x8b}, {0x64,0xcc,0x87}},
+ {{0xc4,0x8f}, {0x64,0xcc,0x8c}},
+ {{0xe1,0xb8,0x8d}, {0x64,0xcc,0xa3}},
+ {{0xe1,0xb8,0x91}, {0x64,0xcc,0xa7}},
+ {{0xe1,0xb8,0x93}, {0x64,0xcc,0xad}},
+ {{0xe1,0xb8,0x8f}, {0x64,0xcc,0xb1}},
+ {{0xc3,0xa8}, {0x65,0xcc,0x80}},
+ {{0xc3,0xa9}, {0x65,0xcc,0x81}},
+ {{0xc3,0xaa}, {0x65,0xcc,0x82}},
+ {{0xe1,0xbb,0x81}, {0x65,0xcc,0x82,0xcc,0x80}},
+ {{0xe1,0xba,0xbf}, {0x65,0xcc,0x82,0xcc,0x81}},
+ {{0xe1,0xbb,0x85}, {0x65,0xcc,0x82,0xcc,0x83}},
+ {{0xe1,0xbb,0x83}, {0x65,0xcc,0x82,0xcc,0x89}},
+ {{0xe1,0xba,0xbd}, {0x65,0xcc,0x83}},
+ {{0xc4,0x93}, {0x65,0xcc,0x84}},
+ {{0xe1,0xb8,0x95}, {0x65,0xcc,0x84,0xcc,0x80}},
+ {{0xe1,0xb8,0x97}, {0x65,0xcc,0x84,0xcc,0x81}},
+ {{0xc4,0x95}, {0x65,0xcc,0x86}},
+ {{0xc4,0x97}, {0x65,0xcc,0x87}},
+ {{0xc3,0xab}, {0x65,0xcc,0x88}},
+ {{0xe1,0xba,0xbb}, {0x65,0xcc,0x89}},
+ {{0xc4,0x9b}, {0x65,0xcc,0x8c}},
+ {{0xc8,0x85}, {0x65,0xcc,0x8f}},
+ {{0xc8,0x87}, {0x65,0xcc,0x91}},
+ {{0xe1,0xba,0xb9}, {0x65,0xcc,0xa3}},
+ {{0xe1,0xbb,0x87}, {0x65,0xcc,0xa3,0xcc,0x82}},
+ {{0xe1,0xb8,0x9d}, {0x65,0xcc,0xa7,0xcc,0x86}},
+ {{0xc4,0x99}, {0x65,0xcc,0xa8}},
+ {{0xe1,0xb8,0x99}, {0x65,0xcc,0xad}},
+ {{0xe1,0xb8,0x9b}, {0x65,0xcc,0xb0}},
+ {{0xe1,0xb8,0x9f}, {0x66,0xcc,0x87}},
+ {{0xc7,0xb5}, {0x67,0xcc,0x81}},
+ {{0xc4,0x9d}, {0x67,0xcc,0x82}},
+ {{0xe1,0xb8,0xa1}, {0x67,0xcc,0x84}},
+ {{0xc4,0x9f}, {0x67,0xcc,0x86}},
+ {{0xc4,0xa1}, {0x67,0xcc,0x87}},
+ {{0xc7,0xa7}, {0x67,0xcc,0x8c}},
+ {{0xc4,0xa3}, {0x67,0xcc,0xa7}},
+ {{0xc4,0xa5}, {0x68,0xcc,0x82}},
+ {{0xe1,0xb8,0xa3}, {0x68,0xcc,0x87}},
+ {{0xe1,0xb8,0xa7}, {0x68,0xcc,0x88}},
+ {{0xe1,0xb8,0xa5}, {0x68,0xcc,0xa3}},
+ {{0xe1,0xb8,0xa9}, {0x68,0xcc,0xa7}},
+ {{0xe1,0xb8,0xab}, {0x68,0xcc,0xae}},
+ {{0xe1,0xba,0x96}, {0x68,0xcc,0xb1}},
+ {{0xc3,0xac}, {0x69,0xcc,0x80}},
+ {{0xc3,0xad}, {0x69,0xcc,0x81}},
+ {{0xc3,0xae}, {0x69,0xcc,0x82}},
+ {{0xc4,0xa9}, {0x69,0xcc,0x83}},
+ {{0xc4,0xab}, {0x69,0xcc,0x84}},
+ {{0xc4,0xad}, {0x69,0xcc,0x86}},
+ {{0xc3,0xaf}, {0x69,0xcc,0x88}},
+ {{0xe1,0xb8,0xaf}, {0x69,0xcc,0x88,0xcc,0x81}},
+ {{0xe1,0xbb,0x89}, {0x69,0xcc,0x89}},
+ {{0xc7,0x90}, {0x69,0xcc,0x8c}},
+ {{0xc8,0x89}, {0x69,0xcc,0x8f}},
+ {{0xc8,0x8b}, {0x69,0xcc,0x91}},
+ {{0xe1,0xbb,0x8b}, {0x69,0xcc,0xa3}},
+ {{0xc4,0xaf}, {0x69,0xcc,0xa8}},
+ {{0xe1,0xb8,0xad}, {0x69,0xcc,0xb0}},
+ {{0xc4,0xb5}, {0x6a,0xcc,0x82}},
+ {{0xc7,0xb0}, {0x6a,0xcc,0x8c}},
+ {{0xe1,0xb8,0xb1}, {0x6b,0xcc,0x81}},
+ {{0xc7,0xa9}, {0x6b,0xcc,0x8c}},
+ {{0xe1,0xb8,0xb3}, {0x6b,0xcc,0xa3}},
+ {{0xc4,0xb7}, {0x6b,0xcc,0xa7}},
+ {{0xe1,0xb8,0xb5}, {0x6b,0xcc,0xb1}},
+ {{0xc4,0xba}, {0x6c,0xcc,0x81}},
+ {{0xc4,0xbe}, {0x6c,0xcc,0x8c}},
+ {{0xe1,0xb8,0xb7}, {0x6c,0xcc,0xa3}},
+ {{0xe1,0xb8,0xb9}, {0x6c,0xcc,0xa3,0xcc,0x84}},
+ {{0xc4,0xbc}, {0x6c,0xcc,0xa7}},
+ {{0xe1,0xb8,0xbd}, {0x6c,0xcc,0xad}},
+ {{0xe1,0xb8,0xbb}, {0x6c,0xcc,0xb1}},
+ {{0xe1,0xb8,0xbf}, {0x6d,0xcc,0x81}},
+ {{0xe1,0xb9,0x81}, {0x6d,0xcc,0x87}},
+ {{0xe1,0xb9,0x83}, {0x6d,0xcc,0xa3}},
+ {{0xc5,0x84}, {0x6e,0xcc,0x81}},
+ {{0xc3,0xb1}, {0x6e,0xcc,0x83}},
+ {{0xe1,0xb9,0x85}, {0x6e,0xcc,0x87}},
+ {{0xc5,0x88}, {0x6e,0xcc,0x8c}},
+ {{0xe1,0xb9,0x87}, {0x6e,0xcc,0xa3}},
+ {{0xc5,0x86}, {0x6e,0xcc,0xa7}},
+ {{0xe1,0xb9,0x8b}, {0x6e,0xcc,0xad}},
+ {{0xe1,0xb9,0x89}, {0x6e,0xcc,0xb1}},
+ {{0xc3,0xb2}, {0x6f,0xcc,0x80}},
+ {{0xc3,0xb3}, {0x6f,0xcc,0x81}},
+ {{0xc3,0xb4}, {0x6f,0xcc,0x82}},
+ {{0xe1,0xbb,0x93}, {0x6f,0xcc,0x82,0xcc,0x80}},
+ {{0xe1,0xbb,0x91}, {0x6f,0xcc,0x82,0xcc,0x81}},
+ {{0xe1,0xbb,0x97}, {0x6f,0xcc,0x82,0xcc,0x83}},
+ {{0xe1,0xbb,0x95}, {0x6f,0xcc,0x82,0xcc,0x89}},
+ {{0xc3,0xb5}, {0x6f,0xcc,0x83}},
+ {{0xe1,0xb9,0x8d}, {0x6f,0xcc,0x83,0xcc,0x81}},
+ {{0xe1,0xb9,0x8f}, {0x6f,0xcc,0x83,0xcc,0x88}},
+ {{0xc5,0x8d}, {0x6f,0xcc,0x84}},
+ {{0xe1,0xb9,0x91}, {0x6f,0xcc,0x84,0xcc,0x80}},
+ {{0xe1,0xb9,0x93}, {0x6f,0xcc,0x84,0xcc,0x81}},
+ {{0xc5,0x8f}, {0x6f,0xcc,0x86}},
+ {{0xc3,0xb6}, {0x6f,0xcc,0x88}},
+ {{0xe1,0xbb,0x8f}, {0x6f,0xcc,0x89}},
+ {{0xc5,0x91}, {0x6f,0xcc,0x8b}},
+ {{0xc7,0x92}, {0x6f,0xcc,0x8c}},
+ {{0xc8,0x8d}, {0x6f,0xcc,0x8f}},
+ {{0xc8,0x8f}, {0x6f,0xcc,0x91}},
+ {{0xc6,0xa1}, {0x6f,0xcc,0x9b}},
+ {{0xe1,0xbb,0x9d}, {0x6f,0xcc,0x9b,0xcc,0x80}},
+ {{0xe1,0xbb,0x9b}, {0x6f,0xcc,0x9b,0xcc,0x81}},
+ {{0xe1,0xbb,0xa1}, {0x6f,0xcc,0x9b,0xcc,0x83}},
+ {{0xe1,0xbb,0x9f}, {0x6f,0xcc,0x9b,0xcc,0x89}},
+ {{0xe1,0xbb,0xa3}, {0x6f,0xcc,0x9b,0xcc,0xa3}},
+ {{0xe1,0xbb,0x8d}, {0x6f,0xcc,0xa3}},
+ {{0xe1,0xbb,0x99}, {0x6f,0xcc,0xa3,0xcc,0x82}},
+ {{0xc7,0xab}, {0x6f,0xcc,0xa8}},
+ {{0xc7,0xad}, {0x6f,0xcc,0xa8,0xcc,0x84}},
+ {{0xe1,0xb9,0x95}, {0x70,0xcc,0x81}},
+ {{0xe1,0xb9,0x97}, {0x70,0xcc,0x87}},
+ {{0xc5,0x95}, {0x72,0xcc,0x81}},
+ {{0xe1,0xb9,0x99}, {0x72,0xcc,0x87}},
+ {{0xc5,0x99}, {0x72,0xcc,0x8c}},
+ {{0xc8,0x91}, {0x72,0xcc,0x8f}},
+ {{0xc8,0x93}, {0x72,0xcc,0x91}},
+ {{0xe1,0xb9,0x9b}, {0x72,0xcc,0xa3}},
+ {{0xe1,0xb9,0x9d}, {0x72,0xcc,0xa3,0xcc,0x84}},
+ {{0xc5,0x97}, {0x72,0xcc,0xa7}},
+ {{0xe1,0xb9,0x9f}, {0x72,0xcc,0xb1}},
+ {{0xc5,0x9b}, {0x73,0xcc,0x81}},
+ {{0xe1,0xb9,0xa5}, {0x73,0xcc,0x81,0xcc,0x87}},
+ {{0xc5,0x9d}, {0x73,0xcc,0x82}},
+ {{0xe1,0xb9,0xa1}, {0x73,0xcc,0x87}},
+ {{0xc5,0xa1}, {0x73,0xcc,0x8c}},
+ {{0xe1,0xb9,0xa7}, {0x73,0xcc,0x8c,0xcc,0x87}},
+ {{0xe1,0xb9,0xa3}, {0x73,0xcc,0xa3}},
+ {{0xe1,0xb9,0xa9}, {0x73,0xcc,0xa3,0xcc,0x87}},
+ {{0xc5,0x9f}, {0x73,0xcc,0xa7}},
+ {{0xe1,0xb9,0xab}, {0x74,0xcc,0x87}},
+ {{0xe1,0xba,0x97}, {0x74,0xcc,0x88}},
+ {{0xc5,0xa5}, {0x74,0xcc,0x8c}},
+ {{0xe1,0xb9,0xad}, {0x74,0xcc,0xa3}},
+ {{0xc5,0xa3}, {0x74,0xcc,0xa7}},
+ {{0xe1,0xb9,0xb1}, {0x74,0xcc,0xad}},
+ {{0xe1,0xb9,0xaf}, {0x74,0xcc,0xb1}},
+ {{0xc3,0xb9}, {0x75,0xcc,0x80}},
+ {{0xc3,0xba}, {0x75,0xcc,0x81}},
+ {{0xc3,0xbb}, {0x75,0xcc,0x82}},
+ {{0xc5,0xa9}, {0x75,0xcc,0x83}},
+ {{0xe1,0xb9,0xb9}, {0x75,0xcc,0x83,0xcc,0x81}},
+ {{0xc5,0xab}, {0x75,0xcc,0x84}},
+ {{0xe1,0xb9,0xbb}, {0x75,0xcc,0x84,0xcc,0x88}},
+ {{0xc5,0xad}, {0x75,0xcc,0x86}},
+ {{0xc3,0xbc}, {0x75,0xcc,0x88}},
+ {{0xc7,0x9c}, {0x75,0xcc,0x88,0xcc,0x80}},
+ {{0xc7,0x98}, {0x75,0xcc,0x88,0xcc,0x81}},
+ {{0xc7,0x96}, {0x75,0xcc,0x88,0xcc,0x84}},
+ {{0xc7,0x9a}, {0x75,0xcc,0x88,0xcc,0x8c}},
+ {{0xe1,0xbb,0xa7}, {0x75,0xcc,0x89}},
+ {{0xc5,0xaf}, {0x75,0xcc,0x8a}},
+ {{0xc5,0xb1}, {0x75,0xcc,0x8b}},
+ {{0xc7,0x94}, {0x75,0xcc,0x8c}},
+ {{0xc8,0x95}, {0x75,0xcc,0x8f}},
+ {{0xc8,0x97}, {0x75,0xcc,0x91}},
+ {{0xc6,0xb0}, {0x75,0xcc,0x9b}},
+ {{0xe1,0xbb,0xab}, {0x75,0xcc,0x9b,0xcc,0x80}},
+ {{0xe1,0xbb,0xa9}, {0x75,0xcc,0x9b,0xcc,0x81}},
+ {{0xe1,0xbb,0xaf}, {0x75,0xcc,0x9b,0xcc,0x83}},
+ {{0xe1,0xbb,0xad}, {0x75,0xcc,0x9b,0xcc,0x89}},
+ {{0xe1,0xbb,0xb1}, {0x75,0xcc,0x9b,0xcc,0xa3}},
+ {{0xe1,0xbb,0xa5}, {0x75,0xcc,0xa3}},
+ {{0xe1,0xb9,0xb3}, {0x75,0xcc,0xa4}},
+ {{0xc5,0xb3}, {0x75,0xcc,0xa8}},
+ {{0xe1,0xb9,0xb7}, {0x75,0xcc,0xad}},
+ {{0xe1,0xb9,0xb5}, {0x75,0xcc,0xb0}},
+ {{0xe1,0xb9,0xbd}, {0x76,0xcc,0x83}},
+ {{0xe1,0xb9,0xbf}, {0x76,0xcc,0xa3}},
+ {{0xe1,0xba,0x81}, {0x77,0xcc,0x80}},
+ {{0xe1,0xba,0x83}, {0x77,0xcc,0x81}},
+ {{0xc5,0xb5}, {0x77,0xcc,0x82}},
+ {{0xe1,0xba,0x87}, {0x77,0xcc,0x87}},
+ {{0xe1,0xba,0x85}, {0x77,0xcc,0x88}},
+ {{0xe1,0xba,0x98}, {0x77,0xcc,0x8a}},
+ {{0xe1,0xba,0x89}, {0x77,0xcc,0xa3}},
+ {{0xe1,0xba,0x8b}, {0x78,0xcc,0x87}},
+ {{0xe1,0xba,0x8d}, {0x78,0xcc,0x88}},
+ {{0xe1,0xbb,0xb3}, {0x79,0xcc,0x80}},
+ {{0xc3,0xbd}, {0x79,0xcc,0x81}},
+ {{0xc5,0xb7}, {0x79,0xcc,0x82}},
+ {{0xe1,0xbb,0xb9}, {0x79,0xcc,0x83}},
+ {{0xe1,0xba,0x8f}, {0x79,0xcc,0x87}},
+ {{0xc3,0xbf}, {0x79,0xcc,0x88}},
+ {{0xe1,0xbb,0xb7}, {0x79,0xcc,0x89}},
+ {{0xe1,0xba,0x99}, {0x79,0xcc,0x8a}},
+ {{0xe1,0xbb,0xb5}, {0x79,0xcc,0xa3}},
+ {{0xc5,0xba}, {0x7a,0xcc,0x81}},
+ {{0xe1,0xba,0x91}, {0x7a,0xcc,0x82}},
+ {{0xc5,0xbc}, {0x7a,0xcc,0x87}},
+ {{0xc5,0xbe}, {0x7a,0xcc,0x8c}},
+ {{0xe1,0xba,0x93}, {0x7a,0xcc,0xa3}},
+ {{0xe1,0xba,0x95}, {0x7a,0xcc,0xb1}},
+ {{0xe1,0xbf,0xad}, {0xc2,0xa8,0xcc,0x80}},
+ {{0xe1,0xbf,0xae}, {0xc2,0xa8,0xcc,0x81}},
+ {{0xce,0x85}, {0xc2,0xa8,0xcc,0x8d}},
+ {{0xe1,0xbf,0x81}, {0xc2,0xa8,0xcd,0x82}},
+ {{0xe1,0xbf,0xbd}, {0xc2,0xb4}},
+ {{0xce,0x87}, {0xc2,0xb7}},
+ {{0xd3,0x94}, {0xc3,0x86}},
+ {{0xc7,0xbc}, {0xc3,0x86,0xcc,0x81}},
+ {{0xc7,0xa2}, {0xc3,0x86,0xcc,0x84}},
+ {{0xc7,0xbe}, {0xc3,0x98,0xcc,0x81}},
+ {{0xd3,0x95}, {0xc3,0xa6}},
+ {{0xc7,0xbd}, {0xc3,0xa6,0xcc,0x81}},
+ {{0xc7,0xa3}, {0xc3,0xa6,0xcc,0x84}},
+ {{0xc7,0xbf}, {0xc3,0xb8,0xcc,0x81}},
+ {{0xe1,0xba,0x9b}, {0xc5,0xbf,0xcc,0x87}},
+ {{0xd3,0x98}, {0xc6,0x8f}},
+ {{0xd3,0x9a}, {0xc6,0x8f,0xcc,0x88}},
+ {{0xd3,0xa8}, {0xc6,0x9f}},
+ {{0xd3,0xaa}, {0xc6,0x9f,0xcc,0x88}},
+ {{0xd3,0xa0}, {0xc6,0xb7}},
+ {{0xc7,0xae}, {0xc6,0xb7,0xcc,0x8c}},
+ {{0xd3,0x99}, {0xc9,0x99}},
+ {{0xd3,0x9b}, {0xc9,0x99,0xcc,0x88}},
+ {{0xd3,0xa9}, {0xc9,0xb5}},
+ {{0xd3,0xab}, {0xc9,0xb5,0xcc,0x88}},
+ {{0xd3,0xa1}, {0xca,0x92}},
+ {{0xc7,0xaf}, {0xca,0x92,0xcc,0x8c}},
+ {{0xcd,0xb4}, {0xca,0xb9}},
+ {{0xcd,0x80}, {0xcc,0x80}},
+ {{0xcd,0x81}, {0xcc,0x81}},
+ {{0xcc,0x90}, {0xcc,0x86,0xcc,0x87}},
+ {{0xcd,0x84}, {0xcc,0x88,0xcc,0x8d}},
+ {{0xcd,0x83}, {0xcc,0x93}},
+ {{0xe1,0xbe,0xba}, {0xce,0x91,0xcc,0x80}},
+ {{0xe1,0xbe,0xbb}, {0xce,0x91,0xcc,0x81}},
+ {{0xe1,0xbe,0xb9}, {0xce,0x91,0xcc,0x84}},
+ {{0xe1,0xbe,0xb8}, {0xce,0x91,0xcc,0x86}},
+ {{0xce,0x86}, {0xce,0x91,0xcc,0x8d}},
+ {{0xe1,0xbc,0x88}, {0xce,0x91,0xcc,0x93}},
+ {{0xe1,0xbc,0x8a}, {0xce,0x91,0xcc,0x93,0xcc,0x80}},
+ {{0xe1,0xbc,0x8c}, {0xce,0x91,0xcc,0x93,0xcc,0x81}},
+ {{0xe1,0xbc,0x8e}, {0xce,0x91,0xcc,0x93,0xcd,0x82}},
+ {{0xe1,0xbc,0x89}, {0xce,0x91,0xcc,0x94}},
+ {{0xe1,0xbc,0x8b}, {0xce,0x91,0xcc,0x94,0xcc,0x80}},
+ {{0xe1,0xbc,0x8d}, {0xce,0x91,0xcc,0x94,0xcc,0x81}},
+ {{0xe1,0xbc,0x8f}, {0xce,0x91,0xcc,0x94,0xcd,0x82}},
+ {{0xe1,0xbe,0xbc}, {0xce,0x91,0xcd,0x85}},
+ {{0xe1,0xbe,0x88}, {0xce,0x91,0xcd,0x85,0xcc,0x93}},
+ {{0xe1,0xbe,0x8a}, {0xce,0x91,0xcd,0x85,0xcc,0x93,0xcc,0x80}},
+ {{0xe1,0xbe,0x8c}, {0xce,0x91,0xcd,0x85,0xcc,0x93,0xcc,0x81}},
+ {{0xe1,0xbe,0x8e}, {0xce,0x91,0xcd,0x85,0xcc,0x93,0xcd,0x82}},
+ {{0xe1,0xbe,0x89}, {0xce,0x91,0xcd,0x85,0xcc,0x94}},
+ {{0xe1,0xbe,0x8b}, {0xce,0x91,0xcd,0x85,0xcc,0x94,0xcc,0x80}},
+ {{0xe1,0xbe,0x8d}, {0xce,0x91,0xcd,0x85,0xcc,0x94,0xcc,0x81}},
+ {{0xe1,0xbe,0x8f}, {0xce,0x91,0xcd,0x85,0xcc,0x94,0xcd,0x82}},
+ {{0xe1,0xbf,0x88}, {0xce,0x95,0xcc,0x80}},
+ {{0xe1,0xbf,0x89}, {0xce,0x95,0xcc,0x81}},
+ {{0xce,0x88}, {0xce,0x95,0xcc,0x8d}},
+ {{0xe1,0xbc,0x98}, {0xce,0x95,0xcc,0x93}},
+ {{0xe1,0xbc,0x9a}, {0xce,0x95,0xcc,0x93,0xcc,0x80}},
+ {{0xe1,0xbc,0x9c}, {0xce,0x95,0xcc,0x93,0xcc,0x81}},
+ {{0xe1,0xbc,0x99}, {0xce,0x95,0xcc,0x94}},
+ {{0xe1,0xbc,0x9b}, {0xce,0x95,0xcc,0x94,0xcc,0x80}},
+ {{0xe1,0xbc,0x9d}, {0xce,0x95,0xcc,0x94,0xcc,0x81}},
+ {{0xe1,0xbf,0x8a}, {0xce,0x97,0xcc,0x80}},
+ {{0xe1,0xbf,0x8b}, {0xce,0x97,0xcc,0x81}},
+ {{0xce,0x89}, {0xce,0x97,0xcc,0x8d}},
+ {{0xe1,0xbc,0xa8}, {0xce,0x97,0xcc,0x93}},
+ {{0xe1,0xbc,0xaa}, {0xce,0x97,0xcc,0x93,0xcc,0x80}},
+ {{0xe1,0xbc,0xac}, {0xce,0x97,0xcc,0x93,0xcc,0x81}},
+ {{0xe1,0xbc,0xae}, {0xce,0x97,0xcc,0x93,0xcd,0x82}},
+ {{0xe1,0xbc,0xa9}, {0xce,0x97,0xcc,0x94}},
+ {{0xe1,0xbc,0xab}, {0xce,0x97,0xcc,0x94,0xcc,0x80}},
+ {{0xe1,0xbc,0xad}, {0xce,0x97,0xcc,0x94,0xcc,0x81}},
+ {{0xe1,0xbc,0xaf}, {0xce,0x97,0xcc,0x94,0xcd,0x82}},
+ {{0xe1,0xbf,0x8c}, {0xce,0x97,0xcd,0x85}},
+ {{0xe1,0xbe,0x98}, {0xce,0x97,0xcd,0x85,0xcc,0x93}},
+ {{0xe1,0xbe,0x9a}, {0xce,0x97,0xcd,0x85,0xcc,0x93,0xcc,0x80}},
+ {{0xe1,0xbe,0x9c}, {0xce,0x97,0xcd,0x85,0xcc,0x93,0xcc,0x81}},
+ {{0xe1,0xbe,0x9e}, {0xce,0x97,0xcd,0x85,0xcc,0x93,0xcd,0x82}},
+ {{0xe1,0xbe,0x99}, {0xce,0x97,0xcd,0x85,0xcc,0x94}},
+ {{0xe1,0xbe,0x9b}, {0xce,0x97,0xcd,0x85,0xcc,0x94,0xcc,0x80}},
+ {{0xe1,0xbe,0x9d}, {0xce,0x97,0xcd,0x85,0xcc,0x94,0xcc,0x81}},
+ {{0xe1,0xbe,0x9f}, {0xce,0x97,0xcd,0x85,0xcc,0x94,0xcd,0x82}},
+ {{0xe1,0xbf,0x9a}, {0xce,0x99,0xcc,0x80}},
+ {{0xe1,0xbf,0x9b}, {0xce,0x99,0xcc,0x81}},
+ {{0xe1,0xbf,0x99}, {0xce,0x99,0xcc,0x84}},
+ {{0xe1,0xbf,0x98}, {0xce,0x99,0xcc,0x86}},
+ {{0xce,0xaa}, {0xce,0x99,0xcc,0x88}},
+ {{0xce,0x8a}, {0xce,0x99,0xcc,0x8d}},
+ {{0xe1,0xbc,0xb8}, {0xce,0x99,0xcc,0x93}},
+ {{0xe1,0xbc,0xba}, {0xce,0x99,0xcc,0x93,0xcc,0x80}},
+ {{0xe1,0xbc,0xbc}, {0xce,0x99,0xcc,0x93,0xcc,0x81}},
+ {{0xe1,0xbc,0xbe}, {0xce,0x99,0xcc,0x93,0xcd,0x82}},
+ {{0xe1,0xbc,0xb9}, {0xce,0x99,0xcc,0x94}},
+ {{0xe1,0xbc,0xbb}, {0xce,0x99,0xcc,0x94,0xcc,0x80}},
+ {{0xe1,0xbc,0xbd}, {0xce,0x99,0xcc,0x94,0xcc,0x81}},
+ {{0xe1,0xbc,0xbf}, {0xce,0x99,0xcc,0x94,0xcd,0x82}},
+ {{0xe1,0xbf,0xb8}, {0xce,0x9f,0xcc,0x80}},
+ {{0xe1,0xbf,0xb9}, {0xce,0x9f,0xcc,0x81}},
+ {{0xce,0x8c}, {0xce,0x9f,0xcc,0x8d}},
+ {{0xe1,0xbd,0x88}, {0xce,0x9f,0xcc,0x93}},
+ {{0xe1,0xbd,0x8a}, {0xce,0x9f,0xcc,0x93,0xcc,0x80}},
+ {{0xe1,0xbd,0x8c}, {0xce,0x9f,0xcc,0x93,0xcc,0x81}},
+ {{0xe1,0xbd,0x89}, {0xce,0x9f,0xcc,0x94}},
+ {{0xe1,0xbd,0x8b}, {0xce,0x9f,0xcc,0x94,0xcc,0x80}},
+ {{0xe1,0xbd,0x8d}, {0xce,0x9f,0xcc,0x94,0xcc,0x81}},
+ {{0xe1,0xbf,0xac}, {0xce,0xa1,0xcc,0x94}},
+ {{0xe1,0xbf,0xaa}, {0xce,0xa5,0xcc,0x80}},
+ {{0xe1,0xbf,0xab}, {0xce,0xa5,0xcc,0x81}},
+ {{0xe1,0xbf,0xa9}, {0xce,0xa5,0xcc,0x84}},
+ {{0xe1,0xbf,0xa8}, {0xce,0xa5,0xcc,0x86}},
+ {{0xce,0xab}, {0xce,0xa5,0xcc,0x88}},
+ {{0xce,0x8e}, {0xce,0xa5,0xcc,0x8d}},
+ {{0xe1,0xbd,0x99}, {0xce,0xa5,0xcc,0x94}},
+ {{0xe1,0xbd,0x9b}, {0xce,0xa5,0xcc,0x94,0xcc,0x80}},
+ {{0xe1,0xbd,0x9d}, {0xce,0xa5,0xcc,0x94,0xcc,0x81}},
+ {{0xe1,0xbd,0x9f}, {0xce,0xa5,0xcc,0x94,0xcd,0x82}},
+ {{0xe1,0xbf,0xba}, {0xce,0xa9,0xcc,0x80}},
+ {{0xe1,0xbf,0xbb}, {0xce,0xa9,0xcc,0x81}},
+ {{0xce,0x8f}, {0xce,0xa9,0xcc,0x8d}},
+ {{0xe1,0xbd,0xa8}, {0xce,0xa9,0xcc,0x93}},
+ {{0xe1,0xbd,0xaa}, {0xce,0xa9,0xcc,0x93,0xcc,0x80}},
+ {{0xe1,0xbd,0xac}, {0xce,0xa9,0xcc,0x93,0xcc,0x81}},
+ {{0xe1,0xbd,0xae}, {0xce,0xa9,0xcc,0x93,0xcd,0x82}},
+ {{0xe1,0xbd,0xa9}, {0xce,0xa9,0xcc,0x94}},
+ {{0xe1,0xbd,0xab}, {0xce,0xa9,0xcc,0x94,0xcc,0x80}},
+ {{0xe1,0xbd,0xad}, {0xce,0xa9,0xcc,0x94,0xcc,0x81}},
+ {{0xe1,0xbd,0xaf}, {0xce,0xa9,0xcc,0x94,0xcd,0x82}},
+ {{0xe1,0xbf,0xbc}, {0xce,0xa9,0xcd,0x85}},
+ {{0xe1,0xbe,0xa8}, {0xce,0xa9,0xcd,0x85,0xcc,0x93}},
+ {{0xe1,0xbe,0xaa}, {0xce,0xa9,0xcd,0x85,0xcc,0x93,0xcc,0x80}},
+ {{0xe1,0xbe,0xac}, {0xce,0xa9,0xcd,0x85,0xcc,0x93,0xcc,0x81}},
+ {{0xe1,0xbe,0xae}, {0xce,0xa9,0xcd,0x85,0xcc,0x93,0xcd,0x82}},
+ {{0xe1,0xbe,0xa9}, {0xce,0xa9,0xcd,0x85,0xcc,0x94}},
+ {{0xe1,0xbe,0xab}, {0xce,0xa9,0xcd,0x85,0xcc,0x94,0xcc,0x80}},
+ {{0xe1,0xbe,0xad}, {0xce,0xa9,0xcd,0x85,0xcc,0x94,0xcc,0x81}},
+ {{0xe1,0xbe,0xaf}, {0xce,0xa9,0xcd,0x85,0xcc,0x94,0xcd,0x82}},
+ {{0xe1,0xbd,0xb0}, {0xce,0xb1,0xcc,0x80}},
+ {{0xe1,0xbd,0xb1}, {0xce,0xb1,0xcc,0x81}},
+ {{0xe1,0xbe,0xb1}, {0xce,0xb1,0xcc,0x84}},
+ {{0xe1,0xbe,0xb0}, {0xce,0xb1,0xcc,0x86}},
+ {{0xce,0xac}, {0xce,0xb1,0xcc,0x8d}},
+ {{0xe1,0xbc,0x80}, {0xce,0xb1,0xcc,0x93}},
+ {{0xe1,0xbc,0x82}, {0xce,0xb1,0xcc,0x93,0xcc,0x80}},
+ {{0xe1,0xbc,0x84}, {0xce,0xb1,0xcc,0x93,0xcc,0x81}},
+ {{0xe1,0xbc,0x86}, {0xce,0xb1,0xcc,0x93,0xcd,0x82}},
+ {{0xe1,0xbc,0x81}, {0xce,0xb1,0xcc,0x94}},
+ {{0xe1,0xbc,0x83}, {0xce,0xb1,0xcc,0x94,0xcc,0x80}},
+ {{0xe1,0xbc,0x85}, {0xce,0xb1,0xcc,0x94,0xcc,0x81}},
+ {{0xe1,0xbc,0x87}, {0xce,0xb1,0xcc,0x94,0xcd,0x82}},
+ {{0xe1,0xbe,0xb6}, {0xce,0xb1,0xcd,0x82}},
+ {{0xe1,0xbe,0xb3}, {0xce,0xb1,0xcd,0x85}},
+ {{0xe1,0xbe,0xb2}, {0xce,0xb1,0xcd,0x85,0xcc,0x80}},
+ {{0xe1,0xbe,0xb4}, {0xce,0xb1,0xcd,0x85,0xcc,0x81}},
+ {{0xe1,0xbe,0x80}, {0xce,0xb1,0xcd,0x85,0xcc,0x93}},
+ {{0xe1,0xbe,0x82}, {0xce,0xb1,0xcd,0x85,0xcc,0x93,0xcc,0x80}},
+ {{0xe1,0xbe,0x84}, {0xce,0xb1,0xcd,0x85,0xcc,0x93,0xcc,0x81}},
+ {{0xe1,0xbe,0x86}, {0xce,0xb1,0xcd,0x85,0xcc,0x93,0xcd,0x82}},
+ {{0xe1,0xbe,0x81}, {0xce,0xb1,0xcd,0x85,0xcc,0x94}},
+ {{0xe1,0xbe,0x83}, {0xce,0xb1,0xcd,0x85,0xcc,0x94,0xcc,0x80}},
+ {{0xe1,0xbe,0x85}, {0xce,0xb1,0xcd,0x85,0xcc,0x94,0xcc,0x81}},
+ {{0xe1,0xbe,0x87}, {0xce,0xb1,0xcd,0x85,0xcc,0x94,0xcd,0x82}},
+ {{0xe1,0xbe,0xb7}, {0xce,0xb1,0xcd,0x85,0xcd,0x82}},
+ {{0xe1,0xbd,0xb2}, {0xce,0xb5,0xcc,0x80}},
+ {{0xe1,0xbd,0xb3}, {0xce,0xb5,0xcc,0x81}},
+ {{0xce,0xad}, {0xce,0xb5,0xcc,0x8d}},
+ {{0xe1,0xbc,0x90}, {0xce,0xb5,0xcc,0x93}},
+ {{0xe1,0xbc,0x92}, {0xce,0xb5,0xcc,0x93,0xcc,0x80}},
+ {{0xe1,0xbc,0x94}, {0xce,0xb5,0xcc,0x93,0xcc,0x81}},
+ {{0xe1,0xbc,0x91}, {0xce,0xb5,0xcc,0x94}},
+ {{0xe1,0xbc,0x93}, {0xce,0xb5,0xcc,0x94,0xcc,0x80}},
+ {{0xe1,0xbc,0x95}, {0xce,0xb5,0xcc,0x94,0xcc,0x81}},
+ {{0xe1,0xbd,0xb4}, {0xce,0xb7,0xcc,0x80}},
+ {{0xe1,0xbd,0xb5}, {0xce,0xb7,0xcc,0x81}},
+ {{0xce,0xae}, {0xce,0xb7,0xcc,0x8d}},
+ {{0xe1,0xbc,0xa0}, {0xce,0xb7,0xcc,0x93}},
+ {{0xe1,0xbc,0xa2}, {0xce,0xb7,0xcc,0x93,0xcc,0x80}},
+ {{0xe1,0xbc,0xa4}, {0xce,0xb7,0xcc,0x93,0xcc,0x81}},
+ {{0xe1,0xbc,0xa6}, {0xce,0xb7,0xcc,0x93,0xcd,0x82}},
+ {{0xe1,0xbc,0xa1}, {0xce,0xb7,0xcc,0x94}},
+ {{0xe1,0xbc,0xa3}, {0xce,0xb7,0xcc,0x94,0xcc,0x80}},
+ {{0xe1,0xbc,0xa5}, {0xce,0xb7,0xcc,0x94,0xcc,0x81}},
+ {{0xe1,0xbc,0xa7}, {0xce,0xb7,0xcc,0x94,0xcd,0x82}},
+ {{0xe1,0xbf,0x86}, {0xce,0xb7,0xcd,0x82}},
+ {{0xe1,0xbf,0x83}, {0xce,0xb7,0xcd,0x85}},
+ {{0xe1,0xbf,0x82}, {0xce,0xb7,0xcd,0x85,0xcc,0x80}},
+ {{0xe1,0xbf,0x84}, {0xce,0xb7,0xcd,0x85,0xcc,0x81}},
+ {{0xe1,0xbe,0x90}, {0xce,0xb7,0xcd,0x85,0xcc,0x93}},
+ {{0xe1,0xbe,0x92}, {0xce,0xb7,0xcd,0x85,0xcc,0x93,0xcc,0x80}},
+ {{0xe1,0xbe,0x94}, {0xce,0xb7,0xcd,0x85,0xcc,0x93,0xcc,0x81}},
+ {{0xe1,0xbe,0x96}, {0xce,0xb7,0xcd,0x85,0xcc,0x93,0xcd,0x82}},
+ {{0xe1,0xbe,0x91}, {0xce,0xb7,0xcd,0x85,0xcc,0x94}},
+ {{0xe1,0xbe,0x93}, {0xce,0xb7,0xcd,0x85,0xcc,0x94,0xcc,0x80}},
+ {{0xe1,0xbe,0x95}, {0xce,0xb7,0xcd,0x85,0xcc,0x94,0xcc,0x81}},
+ {{0xe1,0xbe,0x97}, {0xce,0xb7,0xcd,0x85,0xcc,0x94,0xcd,0x82}},
+ {{0xe1,0xbf,0x87}, {0xce,0xb7,0xcd,0x85,0xcd,0x82}},
+ {{0xe1,0xbe,0xbe}, {0xce,0xb9}},
+ {{0xe1,0xbd,0xb6}, {0xce,0xb9,0xcc,0x80}},
+ {{0xe1,0xbd,0xb7}, {0xce,0xb9,0xcc,0x81}},
+ {{0xe1,0xbf,0x91}, {0xce,0xb9,0xcc,0x84}},
+ {{0xe1,0xbf,0x90}, {0xce,0xb9,0xcc,0x86}},
+ {{0xcf,0x8a}, {0xce,0xb9,0xcc,0x88}},
+ {{0xe1,0xbf,0x92}, {0xce,0xb9,0xcc,0x88,0xcc,0x80}},
+ {{0xe1,0xbf,0x93}, {0xce,0xb9,0xcc,0x88,0xcc,0x81}},
+ {{0xce,0x90}, {0xce,0xb9,0xcc,0x88,0xcc,0x8d}},
+ {{0xe1,0xbf,0x97}, {0xce,0xb9,0xcc,0x88,0xcd,0x82}},
+ {{0xce,0xaf}, {0xce,0xb9,0xcc,0x8d}},
+ {{0xe1,0xbc,0xb0}, {0xce,0xb9,0xcc,0x93}},
+ {{0xe1,0xbc,0xb2}, {0xce,0xb9,0xcc,0x93,0xcc,0x80}},
+ {{0xe1,0xbc,0xb4}, {0xce,0xb9,0xcc,0x93,0xcc,0x81}},
+ {{0xe1,0xbc,0xb6}, {0xce,0xb9,0xcc,0x93,0xcd,0x82}},
+ {{0xe1,0xbc,0xb1}, {0xce,0xb9,0xcc,0x94}},
+ {{0xe1,0xbc,0xb3}, {0xce,0xb9,0xcc,0x94,0xcc,0x80}},
+ {{0xe1,0xbc,0xb5}, {0xce,0xb9,0xcc,0x94,0xcc,0x81}},
+ {{0xe1,0xbc,0xb7}, {0xce,0xb9,0xcc,0x94,0xcd,0x82}},
+ {{0xe1,0xbf,0x96}, {0xce,0xb9,0xcd,0x82}},
+ {{0xe1,0xbd,0xb8}, {0xce,0xbf,0xcc,0x80}},
+ {{0xe1,0xbd,0xb9}, {0xce,0xbf,0xcc,0x81}},
+ {{0xcf,0x8c}, {0xce,0xbf,0xcc,0x8d}},
+ {{0xe1,0xbd,0x80}, {0xce,0xbf,0xcc,0x93}},
+ {{0xe1,0xbd,0x82}, {0xce,0xbf,0xcc,0x93,0xcc,0x80}},
+ {{0xe1,0xbd,0x84}, {0xce,0xbf,0xcc,0x93,0xcc,0x81}},
+ {{0xe1,0xbd,0x81}, {0xce,0xbf,0xcc,0x94}},
+ {{0xe1,0xbd,0x83}, {0xce,0xbf,0xcc,0x94,0xcc,0x80}},
+ {{0xe1,0xbd,0x85}, {0xce,0xbf,0xcc,0x94,0xcc,0x81}},
+ {{0xe1,0xbf,0xb4}, {0xce,0xbf,0xcd,0x85,0xcc,0x81}},
+ {{0xe1,0xbf,0xa4}, {0xcf,0x81,0xcc,0x93}},
+ {{0xe1,0xbf,0xa5}, {0xcf,0x81,0xcc,0x94}},
+ {{0xe1,0xbd,0xba}, {0xcf,0x85,0xcc,0x80}},
+ {{0xe1,0xbd,0xbb}, {0xcf,0x85,0xcc,0x81}},
+ {{0xe1,0xbf,0xa1}, {0xcf,0x85,0xcc,0x84}},
+ {{0xe1,0xbf,0xa0}, {0xcf,0x85,0xcc,0x86}},
+ {{0xcf,0x8b}, {0xcf,0x85,0xcc,0x88}},
+ {{0xe1,0xbf,0xa2}, {0xcf,0x85,0xcc,0x88,0xcc,0x80}},
+ {{0xe1,0xbf,0xa3}, {0xcf,0x85,0xcc,0x88,0xcc,0x81}},
+ {{0xce,0xb0}, {0xcf,0x85,0xcc,0x88,0xcc,0x8d}},
+ {{0xe1,0xbf,0xa7}, {0xcf,0x85,0xcc,0x88,0xcd,0x82}},
+ {{0xcf,0x8d}, {0xcf,0x85,0xcc,0x8d}},
+ {{0xe1,0xbd,0x90}, {0xcf,0x85,0xcc,0x93}},
+ {{0xe1,0xbd,0x92}, {0xcf,0x85,0xcc,0x93,0xcc,0x80}},
+ {{0xe1,0xbd,0x94}, {0xcf,0x85,0xcc,0x93,0xcc,0x81}},
+ {{0xe1,0xbd,0x96}, {0xcf,0x85,0xcc,0x93,0xcd,0x82}},
+ {{0xe1,0xbd,0x91}, {0xcf,0x85,0xcc,0x94}},
+ {{0xe1,0xbd,0x93}, {0xcf,0x85,0xcc,0x94,0xcc,0x80}},
+ {{0xe1,0xbd,0x95}, {0xcf,0x85,0xcc,0x94,0xcc,0x81}},
+ {{0xe1,0xbd,0x97}, {0xcf,0x85,0xcc,0x94,0xcd,0x82}},
+ {{0xe1,0xbf,0xa6}, {0xcf,0x85,0xcd,0x82}},
+ {{0xe1,0xbd,0xbc}, {0xcf,0x89,0xcc,0x80}},
+ {{0xe1,0xbd,0xbd}, {0xcf,0x89,0xcc,0x81}},
+ {{0xcf,0x8e}, {0xcf,0x89,0xcc,0x8d}},
+ {{0xe1,0xbd,0xa0}, {0xcf,0x89,0xcc,0x93}},
+ {{0xe1,0xbd,0xa2}, {0xcf,0x89,0xcc,0x93,0xcc,0x80}},
+ {{0xe1,0xbd,0xa4}, {0xcf,0x89,0xcc,0x93,0xcc,0x81}},
+ {{0xe1,0xbd,0xa6}, {0xcf,0x89,0xcc,0x93,0xcd,0x82}},
+ {{0xe1,0xbd,0xa1}, {0xcf,0x89,0xcc,0x94}},
+ {{0xe1,0xbd,0xa3}, {0xcf,0x89,0xcc,0x94,0xcc,0x80}},
+ {{0xe1,0xbd,0xa5}, {0xcf,0x89,0xcc,0x94,0xcc,0x81}},
+ {{0xe1,0xbd,0xa7}, {0xcf,0x89,0xcc,0x94,0xcd,0x82}},
+ {{0xe1,0xbf,0xb6}, {0xcf,0x89,0xcd,0x82}},
+ {{0xe1,0xbf,0xb3}, {0xcf,0x89,0xcd,0x85}},
+ {{0xe1,0xbf,0xb2}, {0xcf,0x89,0xcd,0x85,0xcc,0x80}},
+ {{0xe1,0xbe,0xa0}, {0xcf,0x89,0xcd,0x85,0xcc,0x93}},
+ {{0xe1,0xbe,0xa2}, {0xcf,0x89,0xcd,0x85,0xcc,0x93,0xcc,0x80}},
+ {{0xe1,0xbe,0xa4}, {0xcf,0x89,0xcd,0x85,0xcc,0x93,0xcc,0x81}},
+ {{0xe1,0xbe,0xa6}, {0xcf,0x89,0xcd,0x85,0xcc,0x93,0xcd,0x82}},
+ {{0xe1,0xbe,0xa1}, {0xcf,0x89,0xcd,0x85,0xcc,0x94}},
+ {{0xe1,0xbe,0xa3}, {0xcf,0x89,0xcd,0x85,0xcc,0x94,0xcc,0x80}},
+ {{0xe1,0xbe,0xa5}, {0xcf,0x89,0xcd,0x85,0xcc,0x94,0xcc,0x81}},
+ {{0xe1,0xbe,0xa7}, {0xcf,0x89,0xcd,0x85,0xcc,0x94,0xcd,0x82}},
+ {{0xe1,0xbf,0xb7}, {0xcf,0x89,0xcd,0x85,0xcd,0x82}},
+ {{0xcf,0x94}, {0xcf,0x92,0xcc,0x88}},
+ {{0xcf,0x93}, {0xcf,0x92,0xcc,0x8d}},
+ {{0xd0,0x87}, {0xd0,0x86,0xcc,0x88}},
+ {{0xd3,0x90}, {0xd0,0x90,0xcc,0x86}},
+ {{0xd3,0x92}, {0xd0,0x90,0xcc,0x88}},
+ {{0xd0,0x83}, {0xd0,0x93,0xcc,0x81}},
+ {{0xd3,0x96}, {0xd0,0x95,0xcc,0x86}},
+ {{0xd0,0x81}, {0xd0,0x95,0xcc,0x88}},
+ {{0xd3,0x81}, {0xd0,0x96,0xcc,0x86}},
+ {{0xd3,0x9c}, {0xd0,0x96,0xcc,0x88}},
+ {{0xd3,0x9e}, {0xd0,0x97,0xcc,0x88}},
+ {{0xd3,0xa2}, {0xd0,0x98,0xcc,0x84}},
+ {{0xd0,0x99}, {0xd0,0x98,0xcc,0x86}},
+ {{0xd3,0xa4}, {0xd0,0x98,0xcc,0x88}},
+ {{0xd0,0x8c}, {0xd0,0x9a,0xcc,0x81}},
+ {{0xd3,0xa6}, {0xd0,0x9e,0xcc,0x88}},
+ {{0xd3,0xae}, {0xd0,0xa3,0xcc,0x84}},
+ {{0xd0,0x8e}, {0xd0,0xa3,0xcc,0x86}},
+ {{0xd3,0xb0}, {0xd0,0xa3,0xcc,0x88}},
+ {{0xd3,0xb2}, {0xd0,0xa3,0xcc,0x8b}},
+ {{0xd3,0xb4}, {0xd0,0xa7,0xcc,0x88}},
+ {{0xd3,0xb8}, {0xd0,0xab,0xcc,0x88}},
+ {{0xd3,0x91}, {0xd0,0xb0,0xcc,0x86}},
+ {{0xd3,0x93}, {0xd0,0xb0,0xcc,0x88}},
+ {{0xd1,0x93}, {0xd0,0xb3,0xcc,0x81}},
+ {{0xd3,0x97}, {0xd0,0xb5,0xcc,0x86}},
+ {{0xd1,0x91}, {0xd0,0xb5,0xcc,0x88}},
+ {{0xd3,0x82}, {0xd0,0xb6,0xcc,0x86}},
+ {{0xd3,0x9d}, {0xd0,0xb6,0xcc,0x88}},
+ {{0xd3,0x9f}, {0xd0,0xb7,0xcc,0x88}},
+ {{0xd3,0xa3}, {0xd0,0xb8,0xcc,0x84}},
+ {{0xd0,0xb9}, {0xd0,0xb8,0xcc,0x86}},
+ {{0xd3,0xa5}, {0xd0,0xb8,0xcc,0x88}},
+ {{0xd1,0x9c}, {0xd0,0xba,0xcc,0x81}},
+ {{0xd3,0xa7}, {0xd0,0xbe,0xcc,0x88}},
+ {{0xd3,0xaf}, {0xd1,0x83,0xcc,0x84}},
+ {{0xd1,0x9e}, {0xd1,0x83,0xcc,0x86}},
+ {{0xd3,0xb1}, {0xd1,0x83,0xcc,0x88}},
+ {{0xd3,0xb3}, {0xd1,0x83,0xcc,0x8b}},
+ {{0xd3,0xb5}, {0xd1,0x87,0xcc,0x88}},
+ {{0xd3,0xb9}, {0xd1,0x8b,0xcc,0x88}},
+ {{0xd1,0x97}, {0xd1,0x96,0xcc,0x88}},
+ {{0xd1,0xb6}, {0xd1,0xb4,0xcc,0x8f}},
+ {{0xd1,0xb7}, {0xd1,0xb5,0xcc,0x8f}},
+ {{0xef,0xac,0xae}, {0xd7,0x90,0xd6,0xb7}},
+ {{0xef,0xac,0xaf}, {0xd7,0x90,0xd6,0xb8}},
+ {{0xef,0xac,0xb0}, {0xd7,0x90,0xd6,0xbc}},
+ {{0xef,0xac,0xb1}, {0xd7,0x91,0xd6,0xbc}},
+ {{0xef,0xad,0x8c}, {0xd7,0x91,0xd6,0xbf}},
+ {{0xef,0xac,0xb2}, {0xd7,0x92,0xd6,0xbc}},
+ {{0xef,0xac,0xb3}, {0xd7,0x93,0xd6,0xbc}},
+ {{0xef,0xac,0xb4}, {0xd7,0x94,0xd6,0xbc}},
+ {{0xef,0xad,0x8b}, {0xd7,0x95,0xd6,0xb9}},
+ {{0xef,0xac,0xb5}, {0xd7,0x95,0xd6,0xbc}},
+ {{0xef,0xac,0xb6}, {0xd7,0x96,0xd6,0xbc}},
+ {{0xef,0xac,0xb8}, {0xd7,0x98,0xd6,0xbc}},
+ {{0xef,0xac,0xb9}, {0xd7,0x99,0xd6,0xbc}},
+ {{0xef,0xac,0xba}, {0xd7,0x9a,0xd6,0xbc}},
+ {{0xef,0xac,0xbb}, {0xd7,0x9b,0xd6,0xbc}},
+ {{0xef,0xad,0x8d}, {0xd7,0x9b,0xd6,0xbf}},
+ {{0xef,0xac,0xbc}, {0xd7,0x9c,0xd6,0xbc}},
+ {{0xef,0xac,0xbe}, {0xd7,0x9e,0xd6,0xbc}},
+ {{0xef,0xad,0x80}, {0xd7,0xa0,0xd6,0xbc}},
+ {{0xef,0xad,0x81}, {0xd7,0xa1,0xd6,0xbc}},
+ {{0xef,0xad,0x83}, {0xd7,0xa3,0xd6,0xbc}},
+ {{0xef,0xad,0x84}, {0xd7,0xa4,0xd6,0xbc}},
+ {{0xef,0xad,0x8e}, {0xd7,0xa4,0xd6,0xbf}},
+ {{0xef,0xad,0x86}, {0xd7,0xa6,0xd6,0xbc}},
+ {{0xef,0xad,0x87}, {0xd7,0xa7,0xd6,0xbc}},
+ {{0xef,0xad,0x88}, {0xd7,0xa8,0xd6,0xbc}},
+ {{0xef,0xad,0x89}, {0xd7,0xa9,0xd6,0xbc}},
+ {{0xef,0xac,0xac}, {0xd7,0xa9,0xd6,0xbc,0xd7,0x81}},
+ {{0xef,0xac,0xad}, {0xd7,0xa9,0xd6,0xbc,0xd7,0x82}},
+ {{0xef,0xac,0xaa}, {0xd7,0xa9,0xd7,0x81}},
+ {{0xef,0xac,0xab}, {0xd7,0xa9,0xd7,0x82}},
+ {{0xef,0xad,0x8a}, {0xd7,0xaa,0xd6,0xbc}},
+ {{0xef,0xac,0x9f}, {0xd7,0xb2,0xd6,0xb7}},
+ {{0xe0,0xa5,0x98}, {0xe0,0xa4,0x95,0xe0,0xa4,0xbc}},
+ {{0xe0,0xa5,0x99}, {0xe0,0xa4,0x96,0xe0,0xa4,0xbc}},
+ {{0xe0,0xa5,0x9a}, {0xe0,0xa4,0x97,0xe0,0xa4,0xbc}},
+ {{0xe0,0xa5,0x9b}, {0xe0,0xa4,0x9c,0xe0,0xa4,0xbc}},
+ {{0xe0,0xa5,0x9c}, {0xe0,0xa4,0xa1,0xe0,0xa4,0xbc}},
+ {{0xe0,0xa5,0x9d}, {0xe0,0xa4,0xa2,0xe0,0xa4,0xbc}},
+ {{0xe0,0xa4,0xa9}, {0xe0,0xa4,0xa8,0xe0,0xa4,0xbc}},
+ {{0xe0,0xa5,0x9e}, {0xe0,0xa4,0xab,0xe0,0xa4,0xbc}},
+ {{0xe0,0xa5,0x9f}, {0xe0,0xa4,0xaf,0xe0,0xa4,0xbc}},
+ {{0xe0,0xa4,0xb1}, {0xe0,0xa4,0xb0,0xe0,0xa4,0xbc}},
+ {{0xe0,0xa4,0xb4}, {0xe0,0xa4,0xb3,0xe0,0xa4,0xbc}},
+ {{0xe0,0xa7,0x9c}, {0xe0,0xa6,0xa1,0xe0,0xa6,0xbc}},
+ {{0xe0,0xa7,0x9d}, {0xe0,0xa6,0xa2,0xe0,0xa6,0xbc}},
+ {{0xe0,0xa6,0xb0}, {0xe0,0xa6,0xac,0xe0,0xa6,0xbc}},
+ {{0xe0,0xa7,0x9f}, {0xe0,0xa6,0xaf,0xe0,0xa6,0xbc}},
+ {{0xe0,0xa7,0x8b}, {0xe0,0xa7,0x87,0xe0,0xa6,0xbe}},
+ {{0xe0,0xa7,0x8c}, {0xe0,0xa7,0x87,0xe0,0xa7,0x97}},
+ {{0xe0,0xa9,0x99}, {0xe0,0xa8,0x96,0xe0,0xa8,0xbc}},
+ {{0xe0,0xa9,0x9a}, {0xe0,0xa8,0x97,0xe0,0xa8,0xbc}},
+ {{0xe0,0xa9,0x9b}, {0xe0,0xa8,0x9c,0xe0,0xa8,0xbc}},
+ {{0xe0,0xa9,0x9c}, {0xe0,0xa8,0xa1,0xe0,0xa8,0xbc}},
+ {{0xe0,0xa9,0x9e}, {0xe0,0xa8,0xab,0xe0,0xa8,0xbc}},
+ {{0xe0,0xad,0x9c}, {0xe0,0xac,0xa1,0xe0,0xac,0xbc}},
+ {{0xe0,0xad,0x9d}, {0xe0,0xac,0xa2,0xe0,0xac,0xbc}},
+ {{0xe0,0xad,0x9f}, {0xe0,0xac,0xaf,0xe0,0xac,0xbc}},
+ {{0xe0,0xad,0x8b}, {0xe0,0xad,0x87,0xe0,0xac,0xbe}},
+ {{0xe0,0xad,0x88}, {0xe0,0xad,0x87,0xe0,0xad,0x96}},
+ {{0xe0,0xad,0x8c}, {0xe0,0xad,0x87,0xe0,0xad,0x97}},
+ {{0xe0,0xae,0x94}, {0xe0,0xae,0x92,0xe0,0xaf,0x97}},
+ {{0xe0,0xaf,0x8a}, {0xe0,0xaf,0x86,0xe0,0xae,0xbe}},
+ {{0xe0,0xaf,0x8c}, {0xe0,0xaf,0x86,0xe0,0xaf,0x97}},
+ {{0xe0,0xaf,0x8b}, {0xe0,0xaf,0x87,0xe0,0xae,0xbe}},
+ {{0xe0,0xb1,0x88}, {0xe0,0xb1,0x86,0xe0,0xb1,0x96}},
+ {{0xe0,0xb3,0x80}, {0xe0,0xb2,0xbf,0xe0,0xb3,0x95}},
+ {{0xe0,0xb3,0x8a}, {0xe0,0xb3,0x86,0xe0,0xb3,0x82}},
+ {{0xe0,0xb3,0x8b}, {0xe0,0xb3,0x86,0xe0,0xb3,0x82,0xe0,0xb3,0x95}},
+ {{0xe0,0xb3,0x87}, {0xe0,0xb3,0x86,0xe0,0xb3,0x95}},
+ {{0xe0,0xb3,0x88}, {0xe0,0xb3,0x86,0xe0,0xb3,0x96}},
+ {{0xe0,0xb5,0x8a}, {0xe0,0xb5,0x86,0xe0,0xb4,0xbe}},
+ {{0xe0,0xb5,0x8c}, {0xe0,0xb5,0x86,0xe0,0xb5,0x97}},
+ {{0xe0,0xb5,0x8b}, {0xe0,0xb5,0x87,0xe0,0xb4,0xbe}},
+ {{0xe0,0xb8,0xb3}, {0xe0,0xb9,0x8d,0xe0,0xb8,0xb2}},
+ {{0xe0,0xba,0xb3}, {0xe0,0xbb,0x8d,0xe0,0xba,0xb2}},
+ {{0xe0,0xbd,0xa9}, {0xe0,0xbd,0x80,0xe0,0xbe,0xb5}},
+ {{0xe0,0xbd,0x83}, {0xe0,0xbd,0x82,0xe0,0xbe,0xb7}},
+ {{0xe0,0xbd,0x8d}, {0xe0,0xbd,0x8c,0xe0,0xbe,0xb7}},
+ {{0xe0,0xbd,0x92}, {0xe0,0xbd,0x91,0xe0,0xbe,0xb7}},
+ {{0xe0,0xbd,0x97}, {0xe0,0xbd,0x96,0xe0,0xbe,0xb7}},
+ {{0xe0,0xbd,0x9c}, {0xe0,0xbd,0x9b,0xe0,0xbe,0xb7}},
+ {{0xe0,0xbd,0xb3}, {0xe0,0xbd,0xb2,0xe0,0xbd,0xb1}},
+ {{0xe0,0xbd,0xb5}, {0xe0,0xbd,0xb4,0xe0,0xbd,0xb1}},
+ {{0xe0,0xbe,0x81}, {0xe0,0xbe,0x80,0xe0,0xbd,0xb1}},
+ {{0xe0,0xbe,0xb9}, {0xe0,0xbe,0x90,0xe0,0xbe,0xb5}},
+ {{0xe0,0xbe,0x93}, {0xe0,0xbe,0x92,0xe0,0xbe,0xb7}},
+ {{0xe0,0xbe,0x9d}, {0xe0,0xbe,0x9c,0xe0,0xbe,0xb7}},
+ {{0xe0,0xbe,0xa2}, {0xe0,0xbe,0xa1,0xe0,0xbe,0xb7}},
+ {{0xe0,0xbe,0xa7}, {0xe0,0xbe,0xa6,0xe0,0xbe,0xb7}},
+ {{0xe0,0xbe,0xac}, {0xe0,0xbe,0xab,0xe0,0xbe,0xb7}},
+ {{0xe0,0xbd,0xb6}, {0xe0,0xbe,0xb2,0xe0,0xbe,0x80}},
+ {{0xe0,0xbd,0xb7}, {0xe0,0xbe,0xb2,0xe0,0xbe,0x80,0xe0,0xbd,0xb1}},
+ {{0xe0,0xbd,0xb8}, {0xe0,0xbe,0xb3,0xe0,0xbe,0x80}},
+ {{0xe0,0xbd,0xb9}, {0xe0,0xbe,0xb3,0xe0,0xbe,0x80,0xe0,0xbd,0xb1}},
+ {{0xe1,0xbf,0x8d}, {0xe1,0xbe,0xbf,0xcc,0x80}},
+ {{0xe1,0xbf,0x8e}, {0xe1,0xbe,0xbf,0xcc,0x81}},
+ {{0xe1,0xbf,0x8f}, {0xe1,0xbe,0xbf,0xcd,0x82}},
+ {{0xe1,0xbf,0x9d}, {0xe1,0xbf,0xbe,0xcc,0x80}},
+ {{0xe1,0xbf,0x9e}, {0xe1,0xbf,0xbe,0xcc,0x81}},
+ {{0xe1,0xbf,0x9f}, {0xe1,0xbf,0xbe,0xcd,0x82}},
+ {{0xe3,0x82,0x94}, {0xe3,0x81,0x86,0xe3,0x82,0x99}},
+ {{0xe3,0x81,0x8c}, {0xe3,0x81,0x8b,0xe3,0x82,0x99}},
+ {{0xe3,0x81,0x8e}, {0xe3,0x81,0x8d,0xe3,0x82,0x99}},
+ {{0xe3,0x81,0x90}, {0xe3,0x81,0x8f,0xe3,0x82,0x99}},
+ {{0xe3,0x81,0x92}, {0xe3,0x81,0x91,0xe3,0x82,0x99}},
+ {{0xe3,0x81,0x94}, {0xe3,0x81,0x93,0xe3,0x82,0x99}},
+ {{0xe3,0x81,0x96}, {0xe3,0x81,0x95,0xe3,0x82,0x99}},
+ {{0xe3,0x81,0x98}, {0xe3,0x81,0x97,0xe3,0x82,0x99}},
+ {{0xe3,0x81,0x9a}, {0xe3,0x81,0x99,0xe3,0x82,0x99}},
+ {{0xe3,0x81,0x9c}, {0xe3,0x81,0x9b,0xe3,0x82,0x99}},
+ {{0xe3,0x81,0x9e}, {0xe3,0x81,0x9d,0xe3,0x82,0x99}},
+ {{0xe3,0x81,0xa0}, {0xe3,0x81,0x9f,0xe3,0x82,0x99}},
+ {{0xe3,0x81,0xa2}, {0xe3,0x81,0xa1,0xe3,0x82,0x99}},
+ {{0xe3,0x81,0xa5}, {0xe3,0x81,0xa4,0xe3,0x82,0x99}},
+ {{0xe3,0x81,0xa7}, {0xe3,0x81,0xa6,0xe3,0x82,0x99}},
+ {{0xe3,0x81,0xa9}, {0xe3,0x81,0xa8,0xe3,0x82,0x99}},
+ {{0xe3,0x81,0xb0}, {0xe3,0x81,0xaf,0xe3,0x82,0x99}},
+ {{0xe3,0x81,0xb1}, {0xe3,0x81,0xaf,0xe3,0x82,0x9a}},
+ {{0xe3,0x81,0xb3}, {0xe3,0x81,0xb2,0xe3,0x82,0x99}},
+ {{0xe3,0x81,0xb4}, {0xe3,0x81,0xb2,0xe3,0x82,0x9a}},
+ {{0xe3,0x81,0xb6}, {0xe3,0x81,0xb5,0xe3,0x82,0x99}},
+ {{0xe3,0x81,0xb7}, {0xe3,0x81,0xb5,0xe3,0x82,0x9a}},
+ {{0xe3,0x81,0xb9}, {0xe3,0x81,0xb8,0xe3,0x82,0x99}},
+ {{0xe3,0x81,0xba}, {0xe3,0x81,0xb8,0xe3,0x82,0x9a}},
+ {{0xe3,0x81,0xbc}, {0xe3,0x81,0xbb,0xe3,0x82,0x99}},
+ {{0xe3,0x81,0xbd}, {0xe3,0x81,0xbb,0xe3,0x82,0x9a}},
+ {{0xe3,0x82,0x9e}, {0xe3,0x82,0x9d,0xe3,0x82,0x99}},
+ {{0xe3,0x83,0xb4}, {0xe3,0x82,0xa6,0xe3,0x82,0x99}},
+ {{0xe3,0x82,0xac}, {0xe3,0x82,0xab,0xe3,0x82,0x99}},
+ {{0xe3,0x82,0xae}, {0xe3,0x82,0xad,0xe3,0x82,0x99}},
+ {{0xe3,0x82,0xb0}, {0xe3,0x82,0xaf,0xe3,0x82,0x99}},
+ {{0xe3,0x82,0xb2}, {0xe3,0x82,0xb1,0xe3,0x82,0x99}},
+ {{0xe3,0x82,0xb4}, {0xe3,0x82,0xb3,0xe3,0x82,0x99}},
+ {{0xe3,0x82,0xb6}, {0xe3,0x82,0xb5,0xe3,0x82,0x99}},
+ {{0xe3,0x82,0xb8}, {0xe3,0x82,0xb7,0xe3,0x82,0x99}},
+ {{0xe3,0x82,0xba}, {0xe3,0x82,0xb9,0xe3,0x82,0x99}},
+ {{0xe3,0x82,0xbc}, {0xe3,0x82,0xbb,0xe3,0x82,0x99}},
+ {{0xe3,0x82,0xbe}, {0xe3,0x82,0xbd,0xe3,0x82,0x99}},
+ {{0xe3,0x83,0x80}, {0xe3,0x82,0xbf,0xe3,0x82,0x99}},
+ {{0xe3,0x83,0x82}, {0xe3,0x83,0x81,0xe3,0x82,0x99}},
+ {{0xe3,0x83,0x85}, {0xe3,0x83,0x84,0xe3,0x82,0x99}},
+ {{0xe3,0x83,0x87}, {0xe3,0x83,0x86,0xe3,0x82,0x99}},
+ {{0xe3,0x83,0x89}, {0xe3,0x83,0x88,0xe3,0x82,0x99}},
+ {{0xe3,0x83,0x90}, {0xe3,0x83,0x8f,0xe3,0x82,0x99}},
+ {{0xe3,0x83,0x91}, {0xe3,0x83,0x8f,0xe3,0x82,0x9a}},
+ {{0xe3,0x83,0x93}, {0xe3,0x83,0x92,0xe3,0x82,0x99}},
+ {{0xe3,0x83,0x94}, {0xe3,0x83,0x92,0xe3,0x82,0x9a}},
+ {{0xe3,0x83,0x96}, {0xe3,0x83,0x95,0xe3,0x82,0x99}},
+ {{0xe3,0x83,0x97}, {0xe3,0x83,0x95,0xe3,0x82,0x9a}},
+ {{0xe3,0x83,0x99}, {0xe3,0x83,0x98,0xe3,0x82,0x99}},
+ {{0xe3,0x83,0x9a}, {0xe3,0x83,0x98,0xe3,0x82,0x9a}},
+ {{0xe3,0x83,0x9c}, {0xe3,0x83,0x9b,0xe3,0x82,0x99}},
+ {{0xe3,0x83,0x9d}, {0xe3,0x83,0x9b,0xe3,0x82,0x9a}},
+ {{0xe3,0x83,0xb7}, {0xe3,0x83,0xaf,0xe3,0x82,0x99}},
+ {{0xe3,0x83,0xb8}, {0xe3,0x83,0xb0,0xe3,0x82,0x99}},
+ {{0xe3,0x83,0xb9}, {0xe3,0x83,0xb1,0xe3,0x82,0x99}},
+ {{0xe3,0x83,0xba}, {0xe3,0x83,0xb2,0xe3,0x82,0x99}},
+ {{0xe3,0x83,0xbe}, {0xe3,0x83,0xbd,0xe3,0x82,0x99}},
+};
+#endif /* UNICODE_NORMALIZATION */
+#endif /* UTF8_INPUT_ENABLE */
+
+#ifdef SHIFTJIS_CP932
+const unsigned short shiftjis_cp932[3][189] = {
+ {
+ 0xEEEF, 0xEEF0, 0xEEF1, 0xEEF2, 0xEEF3, 0xEEF4, 0xEEF5, 0xEEF6,
+ 0xEEF7, 0xEEF8, 0x8754, 0x8755, 0x8756, 0x8757, 0x8758, 0x8759,
+ 0x875A, 0x875B, 0x875C, 0x875D, 0x81CA, 0xEEFA, 0xEEFB, 0xEEFC,
+ 0x878A, 0x8782, 0x8784, 0x81E6, 0xED40, 0xED41, 0xED42, 0xED43,
+ 0xED44, 0xED45, 0xED46, 0xED47, 0xED48, 0xED49, 0xED4A, 0xED4B,
+ 0xED4C, 0xED4D, 0xED4E, 0xED4F, 0xED50, 0xED51, 0xED52, 0xED53,
+ 0xED54, 0xED55, 0xED56, 0xED57, 0xED58, 0xED59, 0xED5A, 0xED5B,
+ 0xED5C, 0xED5D, 0xED5E, 0xED5F, 0xED60, 0xED61, 0xED62, 0,
+ 0xED63, 0xED64, 0xED65, 0xED66, 0xED67, 0xED68, 0xED69, 0xED6A,
+ 0xED6B, 0xED6C, 0xED6D, 0xED6E, 0xED6F, 0xED70, 0xED71, 0xED72,
+ 0xED73, 0xED74, 0xED75, 0xED76, 0xED77, 0xED78, 0xED79, 0xED7A,
+ 0xED7B, 0xED7C, 0xED7D, 0xED7E, 0xED80, 0xED81, 0xED82, 0xED83,
+ 0xED84, 0xED85, 0xED86, 0xED87, 0xED88, 0xED89, 0xED8A, 0xED8B,
+ 0xED8C, 0xED8D, 0xED8E, 0xED8F, 0xED90, 0xED91, 0xED92, 0xED93,
+ 0xED94, 0xED95, 0xED96, 0xED97, 0xED98, 0xED99, 0xED9A, 0xED9B,
+ 0xED9C, 0xED9D, 0xED9E, 0xED9F, 0xEDA0, 0xEDA1, 0xEDA2, 0xEDA3,
+ 0xEDA4, 0xEDA5, 0xEDA6, 0xEDA7, 0xEDA8, 0xEDA9, 0xEDAA, 0xEDAB,
+ 0xEDAC, 0xEDAD, 0xEDAE, 0xEDAF, 0xEDB0, 0xEDB1, 0xEDB2, 0xEDB3,
+ 0xEDB4, 0xEDB5, 0xEDB6, 0xEDB7, 0xEDB8, 0xEDB9, 0xEDBA, 0xEDBB,
+ 0xEDBC, 0xEDBD, 0xEDBE, 0xEDBF, 0xEDC0, 0xEDC1, 0xEDC2, 0xEDC3,
+ 0xEDC4, 0xEDC5, 0xEDC6, 0xEDC7, 0xEDC8, 0xEDC9, 0xEDCA, 0xEDCB,
+ 0xEDCC, 0xEDCD, 0xEDCE, 0xEDCF, 0xEDD0, 0xEDD1, 0xEDD2, 0xEDD3,
+ 0xEDD4, 0xEDD5, 0xEDD6, 0xEDD7, 0xEDD8, 0xEDD9, 0xEDDA, 0xEDDB,
+ 0xEDDC, 0xEDDD, 0xEDDE, 0xEDDF, 0xEDE0,
+ },
+ {
+ 0xEDE1, 0xEDE2, 0xEDE3, 0xEDE4, 0xEDE5, 0xEDE6, 0xEDE7, 0xEDE8,
+ 0xEDE9, 0xEDEA, 0xEDEB, 0xEDEC, 0xEDED, 0xEDEE, 0xEDEF, 0xEDF0,
+ 0xEDF1, 0xEDF2, 0xEDF3, 0xEDF4, 0xEDF5, 0xEDF6, 0xEDF7, 0xEDF8,
+ 0xEDF9, 0xEDFA, 0xEDFB, 0xEDFC, 0xEE40, 0xEE41, 0xEE42, 0xEE43,
+ 0xEE44, 0xEE45, 0xEE46, 0xEE47, 0xEE48, 0xEE49, 0xEE4A, 0xEE4B,
+ 0xEE4C, 0xEE4D, 0xEE4E, 0xEE4F, 0xEE50, 0xEE51, 0xEE52, 0xEE53,
+ 0xEE54, 0xEE55, 0xEE56, 0xEE57, 0xEE58, 0xEE59, 0xEE5A, 0xEE5B,
+ 0xEE5C, 0xEE5D, 0xEE5E, 0xEE5F, 0xEE60, 0xEE61, 0xEE62, 0,
+ 0xEE63, 0xEE64, 0xEE65, 0xEE66, 0xEE67, 0xEE68, 0xEE69, 0xEE6A,
+ 0xEE6B, 0xEE6C, 0xEE6D, 0xEE6E, 0xEE6F, 0xEE70, 0xEE71, 0xEE72,
+ 0xEE73, 0xEE74, 0xEE75, 0xEE76, 0xEE77, 0xEE78, 0xEE79, 0xEE7A,
+ 0xEE7B, 0xEE7C, 0xEE7D, 0xEE7E, 0xEE80, 0xEE81, 0xEE82, 0xEE83,
+ 0xEE84, 0xEE85, 0xEE86, 0xEE87, 0xEE88, 0xEE89, 0xEE8A, 0xEE8B,
+ 0xEE8C, 0xEE8D, 0xEE8E, 0xEE8F, 0xEE90, 0xEE91, 0xEE92, 0xEE93,
+ 0xEE94, 0xEE95, 0xEE96, 0xEE97, 0xEE98, 0xEE99, 0xEE9A, 0xEE9B,
+ 0xEE9C, 0xEE9D, 0xEE9E, 0xEE9F, 0xEEA0, 0xEEA1, 0xEEA2, 0xEEA3,
+ 0xEEA4, 0xEEA5, 0xEEA6, 0xEEA7, 0xEEA8, 0xEEA9, 0xEEAA, 0xEEAB,
+ 0xEEAC, 0xEEAD, 0xEEAE, 0xEEAF, 0xEEB0, 0xEEB1, 0xEEB2, 0xEEB3,
+ 0xEEB4, 0xEEB5, 0xEEB6, 0xEEB7, 0xEEB8, 0xEEB9, 0xEEBA, 0xEEBB,
+ 0xEEBC, 0xEEBD, 0xEEBE, 0xEEBF, 0xEEC0, 0xEEC1, 0xEEC2, 0xEEC3,
+ 0xEEC4, 0xEEC5, 0xEEC6, 0xEEC7, 0xEEC8, 0xEEC9, 0xEECA, 0xEECB,
+ 0xEECC, 0xEECD, 0xEECE, 0xEECF, 0xEED0, 0xEED1, 0xEED2, 0xEED3,
+ 0xEED4, 0xEED5, 0xEED6, 0xEED7, 0xEED8, 0xEED9, 0xEEDA, 0xEEDB,
+ 0xEEDC, 0xEEDD, 0xEEDE, 0xEEDF, 0xEEE0,
+ },
+ {
+ 0xEEE1, 0xEEE2, 0xEEE3, 0xEEE4, 0xEEE5, 0xEEE6, 0xEEE7, 0xEEE8,
+ 0xEEE9, 0xEEEA, 0xEEEB, 0xEEEC, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0,
+ },
+};
+const unsigned short cp932inv[2][189] = {
+ {
+ 0xFA5C, 0xFA5D, 0xFA5E, 0xFA5F, 0xFA60, 0xFA61, 0xFA62, 0xFA63,
+ 0xFA64, 0xFA65, 0xFA66, 0xFA67, 0xFA68, 0xFA69, 0xFA6A, 0xFA6B,
+ 0xFA6C, 0xFA6D, 0xFA6E, 0xFA6F, 0xFA70, 0xFA71, 0xFA72, 0xFA73,
+ 0xFA74, 0xFA75, 0xFA76, 0xFA77, 0xFA78, 0xFA79, 0xFA7A, 0xFA7B,
+ 0xFA7C, 0xFA7D, 0xFA7E, 0xFA80, 0xFA81, 0xFA82, 0xFA83, 0xFA84,
+ 0xFA85, 0xFA86, 0xFA87, 0xFA88, 0xFA89, 0xFA8A, 0xFA8B, 0xFA8C,
+ 0xFA8D, 0xFA8E, 0xFA8F, 0xFA90, 0xFA91, 0xFA92, 0xFA93, 0xFA94,
+ 0xFA95, 0xFA96, 0xFA97, 0xFA98, 0xFA99, 0xFA9A, 0xFA9B, 0,
+ 0xFA9C, 0xFA9D, 0xFA9E, 0xFA9F, 0xFAA0, 0xFAA1, 0xFAA2, 0xFAA3,
+ 0xFAA4, 0xFAA5, 0xFAA6, 0xFAA7, 0xFAA8, 0xFAA9, 0xFAAA, 0xFAAB,
+ 0xFAAC, 0xFAAD, 0xFAAE, 0xFAAF, 0xFAB0, 0xFAB1, 0xFAB2, 0xFAB3,
+ 0xFAB4, 0xFAB5, 0xFAB6, 0xFAB7, 0xFAB8, 0xFAB9, 0xFABA, 0xFABB,
+ 0xFABC, 0xFABD, 0xFABE, 0xFABF, 0xFAC0, 0xFAC1, 0xFAC2, 0xFAC3,
+ 0xFAC4, 0xFAC5, 0xFAC6, 0xFAC7, 0xFAC8, 0xFAC9, 0xFACA, 0xFACB,
+ 0xFACC, 0xFACD, 0xFACE, 0xFACF, 0xFAD0, 0xFAD1, 0xFAD2, 0xFAD3,
+ 0xFAD4, 0xFAD5, 0xFAD6, 0xFAD7, 0xFAD8, 0xFAD9, 0xFADA, 0xFADB,
+ 0xFADC, 0xFADD, 0xFADE, 0xFADF, 0xFAE0, 0xFAE1, 0xFAE2, 0xFAE3,
+ 0xFAE4, 0xFAE5, 0xFAE6, 0xFAE7, 0xFAE8, 0xFAE9, 0xFAEA, 0xFAEB,
+ 0xFAEC, 0xFAED, 0xFAEE, 0xFAEF, 0xFAF0, 0xFAF1, 0xFAF2, 0xFAF3,
+ 0xFAF4, 0xFAF5, 0xFAF6, 0xFAF7, 0xFAF8, 0xFAF9, 0xFAFA, 0xFAFB,
+ 0xFAFC, 0xFB40, 0xFB41, 0xFB42, 0xFB43, 0xFB44, 0xFB45, 0xFB46,
+ 0xFB47, 0xFB48, 0xFB49, 0xFB4A, 0xFB4B, 0xFB4C, 0xFB4D, 0xFB4E,
+ 0xFB4F, 0xFB50, 0xFB51, 0xFB52, 0xFB53, 0xFB54, 0xFB55, 0xFB56,
+ 0xFB57, 0xFB58, 0xFB59, 0xFB5A, 0xFB5B,
+ },
+ {
+ 0xFB5C, 0xFB5D, 0xFB5E, 0xFB5F, 0xFB60, 0xFB61, 0xFB62, 0xFB63,
+ 0xFB64, 0xFB65, 0xFB66, 0xFB67, 0xFB68, 0xFB69, 0xFB6A, 0xFB6B,
+ 0xFB6C, 0xFB6D, 0xFB6E, 0xFB6F, 0xFB70, 0xFB71, 0xFB72, 0xFB73,
+ 0xFB74, 0xFB75, 0xFB76, 0xFB77, 0xFB78, 0xFB79, 0xFB7A, 0xFB7B,
+ 0xFB7C, 0xFB7D, 0xFB7E, 0xFB80, 0xFB81, 0xFB82, 0xFB83, 0xFB84,
+ 0xFB85, 0xFB86, 0xFB87, 0xFB88, 0xFB89, 0xFB8A, 0xFB8B, 0xFB8C,
+ 0xFB8D, 0xFB8E, 0xFB8F, 0xFB90, 0xFB91, 0xFB92, 0xFB93, 0xFB94,
+ 0xFB95, 0xFB96, 0xFB97, 0xFB98, 0xFB99, 0xFB9A, 0xFB9B, 0,
+ 0xFB9C, 0xFB9D, 0xFB9E, 0xFB9F, 0xFBA0, 0xFBA1, 0xFBA2, 0xFBA3,
+ 0xFBA4, 0xFBA5, 0xFBA6, 0xFBA7, 0xFBA8, 0xFBA9, 0xFBAA, 0xFBAB,
+ 0xFBAC, 0xFBAD, 0xFBAE, 0xFBAF, 0xFBB0, 0xFBB1, 0xFBB2, 0xFBB3,
+ 0xFBB4, 0xFBB5, 0xFBB6, 0xFBB7, 0xFBB8, 0xFBB9, 0xFBBA, 0xFBBB,
+ 0xFBBC, 0xFBBD, 0xFBBE, 0xFBBF, 0xFBC0, 0xFBC1, 0xFBC2, 0xFBC3,
+ 0xFBC4, 0xFBC5, 0xFBC6, 0xFBC7, 0xFBC8, 0xFBC9, 0xFBCA, 0xFBCB,
+ 0xFBCC, 0xFBCD, 0xFBCE, 0xFBCF, 0xFBD0, 0xFBD1, 0xFBD2, 0xFBD3,
+ 0xFBD4, 0xFBD5, 0xFBD6, 0xFBD7, 0xFBD8, 0xFBD9, 0xFBDA, 0xFBDB,
+ 0xFBDC, 0xFBDD, 0xFBDE, 0xFBDF, 0xFBE0, 0xFBE1, 0xFBE2, 0xFBE3,
+ 0xFBE4, 0xFBE5, 0xFBE6, 0xFBE7, 0xFBE8, 0xFBE9, 0xFBEA, 0xFBEB,
+ 0xFBEC, 0xFBED, 0xFBEE, 0xFBEF, 0xFBF0, 0xFBF1, 0xFBF2, 0xFBF3,
+ 0xFBF4, 0xFBF5, 0xFBF6, 0xFBF7, 0xFBF8, 0xFBF9, 0xFBFA, 0xFBFB,
+ 0xFBFC, 0xFC40, 0xFC41, 0xFC42, 0xFC43, 0xFC44, 0xFC45, 0xFC46,
+ 0xFC47, 0xFC48, 0xFC49, 0xFC4A, 0xFC4B, 0, 0, 0xFA40,
+ 0xFA41, 0xFA42, 0xFA43, 0xFA44, 0xFA45, 0xFA46, 0xFA47, 0xFA48,
+ 0xFA49, 0x81CA, 0xFA55, 0xFA56, 0xFA57,
+ },
+};
+#endif /* SHIFTJIS_CP932 */
+
+#ifdef X0212_ENABLE
+const unsigned short shiftjis_x0212[3][189] = {
+ {
+ 0xF373, 0xF374, 0xF375, 0xF376, 0xF377, 0xF378, 0xF379, 0xF37A,
+ 0xF37B, 0xF37C, 0xF37D, 0xF37E, 0xF421, 0xF422, 0xF423, 0xF424,
+ 0xF425, 0xF426, 0xF427, 0xF428, 0x224C, 0xA243, 0xF429, 0xF42A,
+ 0xF42B, 0xF42C, 0xF42D, 0x2268, 0xD463, 0xDC5F, 0xE469, 0xE378,
+ 0xD921, 0xB13B, 0xF42E, 0xC22D, 0xC37C, 0xE450, 0xC23F, 0xBC74,
+ 0xB029, 0xB048, 0xF42F, 0xB052, 0xB054, 0xB063, 0xB06E, 0xB127,
+ 0xB123, 0xB12C, 0xB129, 0xB13E, 0xB15F, 0xB158, 0xB148, 0xB157,
+ 0xB163, 0xB174, 0xB161, 0xB223, 0xF430, 0xB23B, 0xB266, 0,
+ 0xB26D, 0xB275, 0xB27C, 0xF431, 0xB335, 0xB358, 0xB35B, 0xB365,
+ 0xB36E, 0xB37B, 0xF432, 0xF433, 0xB440, 0xB447, 0xB450, 0xB45E,
+ 0xF434, 0xB52A, 0xF435, 0xB52F, 0xB544, 0xB568, 0xF436, 0xB742,
+ 0xB764, 0xB768, 0xB767, 0xF437, 0xF438, 0xF439, 0xB84E, 0xB861,
+ 0xB875, 0xB877, 0xB878, 0xB87C, 0xB92F, 0xB937, 0xBA3E, 0xBA5B,
+ 0xCD2A, 0xBA61, 0xF43A, 0xBA6B, 0xBB33, 0xBB38, 0xF43B, 0xBB4A,
+ 0xF43C, 0xF43D, 0xBB50, 0xBB5E, 0xBB74, 0xBB75, 0xBB79, 0xBC64,
+ 0xBC6D, 0xBC7E, 0xF43E, 0xBD42, 0xBD67, 0xF43F, 0xBD70, 0xBE30,
+ 0xBE2C, 0xF440, 0xBE33, 0xBE3D, 0xBE4D, 0xBE49, 0xBE64, 0xBF28,
+ 0xBF49, 0xC044, 0xC064, 0xC074, 0xC126, 0xF441, 0xC175, 0xC17C,
+ 0xF442, 0xC178, 0xC22B, 0xC221, 0xC225, 0xF443, 0xC238, 0xC23A,
+ 0xF444, 0xC244, 0xC252, 0xC257, 0xC25B, 0xC25E, 0xC26D, 0xC270,
+ 0xF445, 0xC321, 0xC335, 0xC349, 0xC339, 0xF446, 0xC358, 0xC37E,
+ 0xF447, 0xC44C, 0xF448, 0xC459, 0xC46A, 0xC47D, 0xF449, 0xC527,
+ 0xC535, 0xC536, 0xF44A, 0xC555, 0xC638, 0xC657, 0xC660, 0xC66A,
+ 0xC663, 0xC721, 0xC72B, 0xC747, 0xC743,
+ },
+ {
+ 0xC74B, 0xC74F, 0xC759, 0xF44B, 0xF44C, 0xC766, 0xC76E, 0xC77C,
+ 0xC76B, 0xC770, 0xC831, 0xC865, 0xC878, 0xC926, 0xC92B, 0xC92D,
+ 0xF44D, 0xC94A, 0xC953, 0xC969, 0xC963, 0xC97C, 0xC974, 0xC975,
+ 0xF44E, 0xCA33, 0xCA3D, 0xCA6F, 0xCA71, 0xCB2E, 0xF44F, 0xCB4A,
+ 0xCB66, 0xCB6A, 0xCB70, 0xCB74, 0xCB6E, 0xCC25, 0xCB79, 0xCC2B,
+ 0xCC2E, 0xCC2D, 0xCC32, 0xCC42, 0xCC50, 0xCC59, 0xF450, 0xCD3B,
+ 0xF451, 0xCE3B, 0xF452, 0xCE3A, 0xCE43, 0xF453, 0xCE72, 0xB35D,
+ 0xCF55, 0xCF62, 0xCF69, 0xCF6D, 0xF454, 0xF455, 0xF456, 0,
+ 0xF457, 0xD065, 0xF458, 0xD069, 0xD168, 0xF459, 0xF45A, 0xD16C,
+ 0xD23B, 0xF45B, 0xD361, 0xD368, 0xD427, 0xF45C, 0xF45D, 0xD454,
+ 0xD472, 0xD52E, 0xF45E, 0xD75E, 0xF45F, 0xD822, 0xD837, 0xD841,
+ 0xD851, 0xD874, 0xD946, 0xD948, 0xD951, 0xF460, 0xF461, 0xF462,
+ 0xF463, 0xF464, 0xDC53, 0xDD48, 0xDD54, 0xDD6A, 0xDD7A, 0xDE24,
+ 0xDE30, 0xF465, 0xDE35, 0xDE4B, 0xF466, 0xDF39, 0xF467, 0xDF43,
+ 0xF468, 0xF469, 0xE059, 0xF46A, 0xF46B, 0xE162, 0xF46C, 0xF46D,
+ 0xF46E, 0xE247, 0xE328, 0xE326, 0xE329, 0xE32F, 0xE330, 0xE32A,
+ 0xE32B, 0xE33C, 0xE341, 0xE33F, 0xE355, 0xE358, 0xE356, 0xE35F,
+ 0xE363, 0xE361, 0xE354, 0xE369, 0xE426, 0xE371, 0xE372, 0xE44B,
+ 0xE441, 0xE443, 0xE43E, 0xF46F, 0xE440, 0xE447, 0xE43F, 0xE460,
+ 0xE45E, 0xE451, 0xF470, 0xE45C, 0xE452, 0xE45B, 0xE454, 0xE47A,
+ 0xE46F, 0xE533, 0xE53F, 0xE549, 0xE550, 0xE562, 0xE56A, 0xE56B,
+ 0xF471, 0xF472, 0xF473, 0xE668, 0xE66F, 0xE72C, 0xF474, 0xE72E,
+ 0xF475, 0xE731, 0xF476, 0xE732, 0xE831, 0xE836, 0xF477, 0xF478,
+ 0xE85D, 0xF479, 0xF47A, 0xE951, 0xF47B,
+ },
+ {
+ 0xE96D, 0xEA4D, 0xF47C, 0xEA5B, 0xEA66, 0xEA6A, 0xEB25, 0xEB7B,
+ 0xEB7A, 0xF47D, 0xEC56, 0xF47E, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0,
+ },
+};
+
+static const unsigned short x0212_shiftjis_A2[] = {
+ 0x819F, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0x8143, 0, 0, 0x8150, 0, 0, 0x8160,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0xFA55, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0,
+};
+static const unsigned short x0212_shiftjis_B0[] = {
+ 0, 0, 0, 0, 0, 0, 0,
+ 0, 0xFA68, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0xFA69, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0xFA6B, 0, 0xFA6C, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0xFA6D, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0xFA6E, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0,
+};
+static const unsigned short x0212_shiftjis_B1[] = {
+ 0, 0, 0xFA70, 0, 0, 0, 0xFA6F,
+ 0, 0xFA72, 0, 0, 0xFA71, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0xFA61, 0, 0, 0xFA73, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0xFA76, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0xFA77,
+ 0xFA75, 0, 0, 0, 0, 0, 0, 0xFA74,
+ 0, 0xFA7A, 0, 0xFA78, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0xFA79, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0,
+};
+static const unsigned short x0212_shiftjis_B2[] = {
+ 0, 0, 0xFA7B, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0xFA7D, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0xFA7E, 0,
+ 0, 0, 0, 0, 0, 0xFA80, 0, 0,
+ 0, 0, 0, 0, 0, 0xFA81, 0, 0,
+ 0, 0, 0, 0, 0xFA82, 0, 0,
+};
+static const unsigned short x0212_shiftjis_B3[] = {
+ 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0xFA84, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0xFA85, 0, 0, 0xFA86, 0, 0xFB77, 0, 0,
+ 0, 0, 0, 0, 0, 0xFA87, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0xFA88, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0xFA89, 0, 0, 0,
+};
+static const unsigned short x0212_shiftjis_B4[] = {
+ 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0xFA8C, 0, 0, 0, 0, 0, 0, 0xFA8D,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0xFA8E, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0xFA8F, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0,
+};
+static const unsigned short x0212_shiftjis_B5[] = {
+ 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0xFA91, 0, 0, 0, 0, 0xFA93,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0xFA94, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0xFA95, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0,
+};
+static const unsigned short x0212_shiftjis_B7[] = {
+ 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0xFA97, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0xFA98, 0, 0, 0xFA9A,
+ 0xFA99, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0,
+};
+static const unsigned short x0212_shiftjis_B8[] = {
+ 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0xFA9E, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0xFA9F, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0xFAA0, 0, 0xFAA1,
+ 0xFAA2, 0, 0, 0, 0xFAA3, 0, 0,
+};
+static const unsigned short x0212_shiftjis_B9[] = {
+ 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0xFAA4,
+ 0, 0, 0, 0, 0, 0, 0, 0xFAA5,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0,
+};
+static const unsigned short x0212_shiftjis_BA[] = {
+ 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0xFAA6, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0xFAA7, 0, 0, 0, 0,
+ 0, 0xFAA9, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0xFAAB, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0,
+};
+static const unsigned short x0212_shiftjis_BB[] = {
+ 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0xFAAC, 0, 0, 0, 0,
+ 0xFAAD, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0xFAAF, 0, 0, 0, 0, 0,
+ 0xFAB2, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0xFAB3, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0xFAB4, 0xFAB5, 0, 0,
+ 0, 0xFAB6, 0, 0, 0, 0, 0,
+};
+static const unsigned short x0212_shiftjis_BC[] = {
+ 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0xFAB7, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0xFAB8, 0, 0,
+ 0, 0, 0, 0, 0xFA67, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0xFAB9,
+};
+static const unsigned short x0212_shiftjis_BD[] = {
+ 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0xFABB, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0xFABC,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0xFABE, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0,
+};
+static const unsigned short x0212_shiftjis_BE[] = {
+ 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0xFAC0, 0, 0, 0,
+ 0xFABF, 0, 0, 0xFAC2, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0xFAC3, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0xFAC5, 0, 0, 0, 0xFAC4, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0xFAC6, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0,
+};
+static const unsigned short x0212_shiftjis_BF[] = {
+ 0, 0, 0, 0, 0, 0, 0,
+ 0xFAC7, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0xFAC8, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0,
+};
+static const unsigned short x0212_shiftjis_C0[] = {
+ 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0xFAC9, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0xFACA, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0xFACB, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0,
+};
+static const unsigned short x0212_shiftjis_C1[] = {
+ 0, 0, 0, 0, 0, 0xFACC, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0xFACE, 0, 0,
+ 0xFAD1, 0, 0, 0, 0xFACF, 0, 0,
+};
+static const unsigned short x0212_shiftjis_C2[] = {
+ 0xFAD3, 0, 0, 0, 0xFAD4, 0, 0,
+ 0, 0, 0, 0xFAD2, 0, 0xFA63, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0xFAD6, 0, 0xFAD7, 0, 0, 0, 0, 0xFA66,
+ 0, 0, 0, 0, 0xFAD9, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0xFADA, 0, 0, 0, 0, 0xFADB,
+ 0, 0, 0, 0xFADC, 0, 0, 0xFADD, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0xFADE, 0, 0,
+ 0xFADF, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0,
+};
+static const unsigned short x0212_shiftjis_C3[] = {
+ 0xFAE1, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0xFAE2, 0, 0,
+ 0, 0xFAE4, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0xFAE3, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0xFAE6, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0xFA64, 0, 0xFAE7,
+};
+static const unsigned short x0212_shiftjis_C4[] = {
+ 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0xFAE9, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0xFAEB, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0xFAEC, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0xFAED, 0,
+};
+static const unsigned short x0212_shiftjis_C5[] = {
+ 0, 0, 0, 0, 0, 0, 0xFAEF,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0xFAF0, 0xFAF1, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0xFAF3, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0,
+};
+static const unsigned short x0212_shiftjis_C6[] = {
+ 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0xFAF4, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0xFAF5,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0xFAF6, 0, 0, 0xFAF8, 0, 0, 0, 0,
+ 0, 0, 0xFAF7, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0,
+};
+static const unsigned short x0212_shiftjis_C7[] = {
+ 0xFAF9, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0xFAFA, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0xFAFC, 0, 0, 0, 0xFAFB,
+ 0, 0, 0, 0xFB40, 0, 0, 0, 0xFB41,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0xFB42, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0xFB45, 0,
+ 0, 0, 0, 0xFB48, 0, 0, 0xFB46, 0,
+ 0xFB49, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0xFB47, 0, 0,
+};
+static const unsigned short x0212_shiftjis_C8[] = {
+ 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0xFB4A, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0xFB4B, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0xFB4C, 0, 0, 0, 0, 0, 0,
+};
+static const unsigned short x0212_shiftjis_C9[] = {
+ 0, 0, 0, 0, 0, 0xFB4D, 0,
+ 0, 0, 0, 0xFB4E, 0, 0xFB4F, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0xFB51, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0xFB52, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0xFB54, 0, 0, 0, 0,
+ 0, 0xFB53, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0xFB56, 0xFB57, 0, 0,
+ 0, 0, 0, 0, 0xFB55, 0, 0,
+};
+static const unsigned short x0212_shiftjis_CA[] = {
+ 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0xFB59, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0xFB5A, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0xFB5B,
+ 0, 0xFB5C, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0,
+};
+static const unsigned short x0212_shiftjis_CB[] = {
+ 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0xFB5D, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0xFB5F, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0xFB60, 0,
+ 0, 0, 0xFB61, 0, 0, 0, 0xFB64, 0,
+ 0xFB62, 0, 0, 0, 0xFB63, 0, 0, 0,
+ 0, 0xFB66, 0, 0, 0, 0, 0,
+};
+static const unsigned short x0212_shiftjis_CC[] = {
+ 0, 0, 0, 0, 0xFB65, 0, 0,
+ 0, 0, 0, 0xFB67, 0, 0xFB69, 0xFB68, 0,
+ 0, 0, 0xFB6A, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0xFB6B, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0xFB6C, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0xFB6D, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0,
+};
+static const unsigned short x0212_shiftjis_CD[] = {
+ 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0xFAA8, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0xFB6F, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0,
+};
+static const unsigned short x0212_shiftjis_CE[] = {
+ 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0xFB73, 0xFB71, 0, 0, 0, 0,
+ 0, 0, 0, 0xFB74, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0xFB76, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0,
+};
+static const unsigned short x0212_shiftjis_CF[] = {
+ 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0xFB78, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0xFB79, 0, 0, 0, 0, 0,
+ 0, 0xFB7A, 0, 0, 0, 0xFB7B, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0,
+};
+static const unsigned short x0212_shiftjis_D0[] = {
+ 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0xFB81, 0, 0,
+ 0, 0xFB83, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0,
+};
+static const unsigned short x0212_shiftjis_D1[] = {
+ 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0xFB84, 0, 0, 0, 0xFB87, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0,
+};
+static const unsigned short x0212_shiftjis_D2[] = {
+ 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0xFB88, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0,
+};
+static const unsigned short x0212_shiftjis_D3[] = {
+ 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0xFB8A, 0, 0, 0, 0, 0, 0,
+ 0xFB8B, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0,
+};
+static const unsigned short x0212_shiftjis_D4[] = {
+ 0, 0, 0, 0, 0, 0, 0xFB8C,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0xFB8F, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0xFA5C, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0xFB90, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0,
+};
+static const unsigned short x0212_shiftjis_D5[] = {
+ 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0xFB91, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0,
+};
+static const unsigned short x0212_shiftjis_D7[] = {
+ 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0xFB93, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0,
+};
+static const unsigned short x0212_shiftjis_D8[] = {
+ 0, 0xFB95, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0xFB96,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0xFB97, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0xFB98, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0xFB99, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0,
+};
+static const unsigned short x0212_shiftjis_D9[] = {
+ 0xFA60, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0xFB9A, 0,
+ 0xFB9B, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0xFB9C, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0,
+};
+static const unsigned short x0212_shiftjis_DC[] = {
+ 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0xFBA2, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0xFA5D,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0,
+};
+static const unsigned short x0212_shiftjis_DD[] = {
+ 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0xFBA3, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0xFBA4, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0xFBA5, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0xFBA6, 0, 0, 0, 0,
+};
+static const unsigned short x0212_shiftjis_DE[] = {
+ 0, 0, 0, 0xFBA7, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0xFBA8, 0, 0, 0, 0, 0xFBAA, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0xFBAB, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0,
+};
+static const unsigned short x0212_shiftjis_DF[] = {
+ 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0xFBAD, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0xFBAF, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0,
+};
+static const unsigned short x0212_shiftjis_E0[] = {
+ 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0xFBB2, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0,
+};
+static const unsigned short x0212_shiftjis_E1[] = {
+ 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0xFBB5, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0,
+};
+static const unsigned short x0212_shiftjis_E2[] = {
+ 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0xFBB9,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0,
+};
+static const unsigned short x0212_shiftjis_E3[] = {
+ 0, 0, 0, 0, 0, 0xFBBB, 0,
+ 0xFBBA, 0xFBBC, 0xFBBF, 0xFBC0, 0, 0, 0, 0xFBBD,
+ 0xFBBE, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0xFBC1, 0, 0, 0xFBC3,
+ 0, 0xFBC2, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0xFBCA, 0xFBC4, 0xFBC6, 0,
+ 0xFBC5, 0, 0, 0, 0, 0, 0, 0xFBC7,
+ 0, 0xFBC9, 0, 0xFBC8, 0, 0, 0, 0,
+ 0, 0xFBCB, 0, 0, 0, 0, 0, 0,
+ 0, 0xFBCD, 0xFBCE, 0, 0, 0, 0, 0,
+ 0xFA5F, 0, 0, 0, 0, 0, 0,
+};
+static const unsigned short x0212_shiftjis_E4[] = {
+ 0, 0, 0, 0, 0, 0xFBCC, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0xFBD2, 0xFBD6,
+ 0xFBD4, 0xFBD0, 0, 0xFBD1, 0, 0, 0, 0xFBD5,
+ 0, 0, 0, 0xFBCF, 0, 0, 0, 0,
+ 0xFA65, 0xFBD9, 0xFBDC, 0, 0xFBDE, 0, 0, 0,
+ 0, 0, 0, 0xFBDD, 0xFBDB, 0, 0xFBD8, 0,
+ 0xFBD7, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0xFA5E, 0, 0, 0, 0, 0, 0xFBE0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0xFBDF, 0, 0, 0, 0,
+};
+static const unsigned short x0212_shiftjis_E5[] = {
+ 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0xFBE1, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0xFBE2,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0xFBE3, 0, 0, 0, 0, 0, 0,
+ 0xFBE4, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0xFBE5, 0, 0, 0, 0, 0,
+ 0, 0, 0xFBE6, 0xFBE7, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0,
+};
+static const unsigned short x0212_shiftjis_E6[] = {
+ 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0xFBEB, 0, 0, 0, 0, 0, 0, 0xFBEC,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0,
+};
+static const unsigned short x0212_shiftjis_E7[] = {
+ 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0xFBED, 0, 0xFBEF, 0,
+ 0, 0xFBF1, 0xFBF3, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0,
+};
+static const unsigned short x0212_shiftjis_E8[] = {
+ 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0xFBF4, 0, 0, 0, 0, 0xFBF5, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0xFBF8, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0,
+};
+static const unsigned short x0212_shiftjis_E9[] = {
+ 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0xFBFB, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0xFC40, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0,
+};
+static const unsigned short x0212_shiftjis_EA[] = {
+ 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0xFC41, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0xFC43, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0xFC44, 0,
+ 0, 0, 0xFC45, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0,
+};
+static const unsigned short x0212_shiftjis_EB[] = {
+ 0, 0, 0, 0, 0xFC46, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0xFC48, 0xFC47, 0, 0, 0,
+};
+static const unsigned short x0212_shiftjis_EC[] = {
+ 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0xFC4A, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0,
+};
+static const unsigned short x0212_shiftjis_F3[] = {
+ 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0xFA40, 0xFA41, 0xFA42, 0xFA43, 0xFA44,
+ 0xFA45, 0xFA46, 0xFA47, 0xFA48, 0xFA49, 0xFA4A, 0xFA4B,
+};
+static const unsigned short x0212_shiftjis_F4[] = {
+ 0xFA4C, 0xFA4D, 0xFA4E, 0xFA4F, 0xFA50, 0xFA51, 0xFA52,
+ 0xFA53, 0xFA56, 0xFA57, 0xFA58, 0xFA59, 0xFA5A, 0xFA62, 0xFA6A,
+ 0xFA7C, 0xFA83, 0xFA8A, 0xFA8B, 0xFA90, 0xFA92, 0xFA96, 0xFA9B,
+ 0xFA9C, 0xFA9D, 0xFAAA, 0xFAAE, 0xFAB0, 0xFAB1, 0xFABA, 0xFABD,
+ 0xFAC1, 0xFACD, 0xFAD0, 0xFAD5, 0xFAD8, 0xFAE0, 0xFAE5, 0xFAE8,
+ 0xFAEA, 0xFAEE, 0xFAF2, 0xFB43, 0xFB44, 0xFB50, 0xFB58, 0xFB5E,
+ 0xFB6E, 0xFB70, 0xFB72, 0xFB75, 0xFB7C, 0xFB7D, 0xFB7E, 0xFB80,
+ 0xFB82, 0xFB85, 0xFB86, 0xFB89, 0xFB8D, 0xFB8E, 0xFB92, 0xFB94,
+ 0xFB9D, 0xFB9E, 0xFB9F, 0xFBA0, 0xFBA1, 0xFBA9, 0xFBAC, 0xFBAE,
+ 0xFBB0, 0xFBB1, 0xFBB3, 0xFBB4, 0xFBB6, 0xFBB7, 0xFBB8, 0xFBD3,
+ 0xFBDA, 0xFBE8, 0xFBE9, 0xFBEA, 0xFBEE, 0xFBF0, 0xFBF2, 0xFBF6,
+ 0xFBF7, 0xFBF9, 0xFBFA, 0xFBFC, 0xFC42, 0xFC49, 0xFC4B,
+};
+const unsigned short *const x0212_shiftjis[] = {
+ 0, x0212_shiftjis_A2, 0,
+ 0, 0, 0, 0,
+ 0, 0, 0, 0,
+ 0, 0, 0, 0,
+ x0212_shiftjis_B0, x0212_shiftjis_B1, x0212_shiftjis_B2, x0212_shiftjis_B3,
+ x0212_shiftjis_B4, x0212_shiftjis_B5, 0, x0212_shiftjis_B7,
+ x0212_shiftjis_B8, x0212_shiftjis_B9, x0212_shiftjis_BA, x0212_shiftjis_BB,
+ x0212_shiftjis_BC, x0212_shiftjis_BD, x0212_shiftjis_BE, x0212_shiftjis_BF,
+ x0212_shiftjis_C0, x0212_shiftjis_C1, x0212_shiftjis_C2, x0212_shiftjis_C3,
+ x0212_shiftjis_C4, x0212_shiftjis_C5, x0212_shiftjis_C6, x0212_shiftjis_C7,
+ x0212_shiftjis_C8, x0212_shiftjis_C9, x0212_shiftjis_CA, x0212_shiftjis_CB,
+ x0212_shiftjis_CC, x0212_shiftjis_CD, x0212_shiftjis_CE, x0212_shiftjis_CF,
+ x0212_shiftjis_D0, x0212_shiftjis_D1, x0212_shiftjis_D2, x0212_shiftjis_D3,
+ x0212_shiftjis_D4, x0212_shiftjis_D5, 0, x0212_shiftjis_D7,
+ x0212_shiftjis_D8, x0212_shiftjis_D9, 0, 0,
+ x0212_shiftjis_DC, x0212_shiftjis_DD, x0212_shiftjis_DE, x0212_shiftjis_DF,
+ x0212_shiftjis_E0, x0212_shiftjis_E1, x0212_shiftjis_E2, x0212_shiftjis_E3,
+ x0212_shiftjis_E4, x0212_shiftjis_E5, x0212_shiftjis_E6, x0212_shiftjis_E7,
+ x0212_shiftjis_E8, x0212_shiftjis_E9, x0212_shiftjis_EA, x0212_shiftjis_EB,
+ x0212_shiftjis_EC, 0, 0, 0,
+ 0, 0, 0, x0212_shiftjis_F3,
+ x0212_shiftjis_F4, 0, 0, 0,
+ 0, 0, 0, 0,
+ 0, 0, 0,
+};
+#endif /* X0212_ENABLE */
diff --git a/jni/ruby/ext/nkf/nkf-utf8/utf8tbl.h b/jni/ruby/ext/nkf/nkf-utf8/utf8tbl.h
new file mode 100644
index 0000000..96b61ed
--- /dev/null
+++ b/jni/ruby/ext/nkf/nkf-utf8/utf8tbl.h
@@ -0,0 +1,72 @@
+/*
+ * utf8tbl.h - Header file for Convertion Table
+ *
+ */
+
+#ifndef _UTF8TBL_H_
+#define _UTF8TBL_H_
+
+#ifdef UTF8_OUTPUT_ENABLE
+#define sizeof_euc_to_utf8_1byte 94
+#define sizeof_euc_to_utf8_2bytes 94
+extern const unsigned short euc_to_utf8_1byte[];
+extern const unsigned short *const euc_to_utf8_2bytes[];
+extern const unsigned short *const euc_to_utf8_2bytes_ms[];
+extern const unsigned short *const euc_to_utf8_2bytes_mac[];
+extern const unsigned short *const euc_to_utf8_2bytes_x0213[];
+extern const unsigned short *const x0212_to_utf8_2bytes[];
+extern const unsigned short *const x0212_to_utf8_2bytes_x0213[];
+#define sizeof_x0213_combining_chars 5
+#define sizeof_x0213_combining_table 25
+#define sizeof_x0213_1_surrogate_table 26
+#define sizeof_x0213_2_surrogate_table 277
+extern const unsigned short x0213_combining_chars[sizeof_x0213_combining_chars];
+extern const unsigned short x0213_combining_table[sizeof_x0213_combining_table][3];
+extern const unsigned short x0213_1_surrogate_table[sizeof_x0213_1_surrogate_table][3];
+extern const unsigned short x0213_2_surrogate_table[sizeof_x0213_2_surrogate_table][3];
+#endif /* UTF8_OUTPUT_ENABLE */
+
+#ifdef UTF8_INPUT_ENABLE
+#define sizeof_utf8_to_euc_C2 64
+#define sizeof_utf8_to_euc_E5B8 64
+#define sizeof_utf8_to_euc_2bytes 112
+#define sizeof_utf8_to_euc_3bytes 16
+extern const unsigned short *const utf8_to_euc_2bytes[];
+extern const unsigned short *const utf8_to_euc_2bytes_ms[];
+extern const unsigned short *const utf8_to_euc_2bytes_932[];
+extern const unsigned short *const utf8_to_euc_2bytes_mac[];
+extern const unsigned short *const utf8_to_euc_2bytes_x0213[];
+extern const unsigned short *const *const utf8_to_euc_3bytes[];
+extern const unsigned short *const *const utf8_to_euc_3bytes_ms[];
+extern const unsigned short *const *const utf8_to_euc_3bytes_932[];
+extern const unsigned short *const *const utf8_to_euc_3bytes_mac[];
+extern const unsigned short *const *const utf8_to_euc_3bytes_x0213[];
+#endif /* UTF8_INPUT_ENABLE */
+
+#ifdef UNICODE_NORMALIZATION
+
+#define NORMALIZATION_TABLE_LENGTH 942
+#define NORMALIZATION_TABLE_NFC_LENGTH 3
+#define NORMALIZATION_TABLE_NFD_LENGTH 9
+struct normalization_pair {
+ const unsigned char nfc[NORMALIZATION_TABLE_NFC_LENGTH];
+ const unsigned char nfd[NORMALIZATION_TABLE_NFD_LENGTH];
+};
+extern const struct normalization_pair normalization_table[];
+#endif
+
+#ifdef SHIFTJIS_CP932
+#define CP932_TABLE_BEGIN 0xFA
+#define CP932_TABLE_END 0xFC
+extern const unsigned short shiftjis_cp932[3][189];
+#define CP932INV_TABLE_BEGIN 0xED
+#define CP932INV_TABLE_END 0xEE
+extern const unsigned short cp932inv[2][189];
+#endif /* SHIFTJIS_CP932 */
+
+#ifdef X0212_ENABLE
+extern const unsigned short shiftjis_x0212[3][189];
+extern const unsigned short *const x0212_shiftjis[];
+#endif /* X0212_ENABLE */
+
+#endif
diff --git a/jni/ruby/ext/nkf/nkf.c b/jni/ruby/ext/nkf/nkf.c
new file mode 100644
index 0000000..0569dde
--- /dev/null
+++ b/jni/ruby/ext/nkf/nkf.c
@@ -0,0 +1,507 @@
+/*
+ * NKF - Ruby extension for Network Kanji Filter
+ *
+ * original nkf2.x is maintained at http://sourceforge.jp/projects/nkf/
+ *
+ * $Id: nkf.c 47744 2014-09-30 05:25:32Z nobu $
+ *
+ */
+
+#define RUBY_NKF_REVISION "$Revision: 47744 $"
+#define RUBY_NKF_VERSION NKF_VERSION " (" NKF_RELEASE_DATE ")"
+
+#include "ruby/ruby.h"
+#include "ruby/encoding.h"
+
+/* Replace nkf's getchar/putchar for variable modification */
+/* we never use getc, ungetc */
+
+#undef getc
+#undef ungetc
+#define getc(f) (input_ctr>=i_len?-1:input[input_ctr++])
+#define ungetc(c,f) input_ctr--
+
+#define INCSIZE 32
+#undef putchar
+#undef TRUE
+#undef FALSE
+#define putchar(c) rb_nkf_putchar(c)
+
+/* Input/Output pointers */
+
+static unsigned char *output;
+static unsigned char *input;
+static int input_ctr;
+static int i_len;
+static int output_ctr;
+static int o_len;
+static int incsize;
+
+static VALUE result;
+
+static int
+rb_nkf_putchar(unsigned int c)
+{
+ if (output_ctr >= o_len) {
+ o_len += incsize;
+ rb_str_resize(result, o_len);
+ incsize *= 2;
+ output = (unsigned char *)RSTRING_PTR(result);
+ }
+ output[output_ctr++] = c;
+
+ return c;
+}
+
+/* Include kanji filter main part */
+/* getchar and putchar will be replaced during inclusion */
+
+#define PERL_XS 1
+#include "nkf-utf8/config.h"
+#include "nkf-utf8/utf8tbl.c"
+#include "nkf-utf8/nkf.c"
+
+rb_encoding* rb_nkf_enc_get(const char *name)
+{
+ int idx = rb_enc_find_index(name);
+ if (idx < 0) {
+ nkf_encoding *nkf_enc = nkf_enc_find(name);
+ idx = rb_enc_find_index(nkf_enc_name(nkf_enc_to_base_encoding(nkf_enc)));
+ if (idx < 0) {
+ idx = rb_define_dummy_encoding(name);
+ }
+ }
+ return rb_enc_from_index(idx);
+}
+
+int nkf_split_options(const char *arg)
+{
+ int count = 0;
+ unsigned char option[256];
+ int i = 0, j = 0;
+ int is_escaped = FALSE;
+ int is_single_quoted = FALSE;
+ int is_double_quoted = FALSE;
+ for(i = 0; arg[i]; i++){
+ if(j == 255){
+ return -1;
+ }else if(is_single_quoted){
+ if(arg[i] == '\''){
+ is_single_quoted = FALSE;
+ }else{
+ option[j++] = arg[i];
+ }
+ }else if(is_escaped){
+ is_escaped = FALSE;
+ option[j++] = arg[i];
+ }else if(arg[i] == '\\'){
+ is_escaped = TRUE;
+ }else if(is_double_quoted){
+ if(arg[i] == '"'){
+ is_double_quoted = FALSE;
+ }else{
+ option[j++] = arg[i];
+ }
+ }else if(arg[i] == '\''){
+ is_single_quoted = TRUE;
+ }else if(arg[i] == '"'){
+ is_double_quoted = TRUE;
+ }else if(arg[i] == ' '){
+ option[j] = '\0';
+ options(option);
+ j = 0;
+ }else{
+ option[j++] = arg[i];
+ }
+ }
+ if(j){
+ option[j] = '\0';
+ options(option);
+ }
+ return count;
+}
+
+/*
+ * call-seq:
+ * NKF.nkf(opt, str) => string
+ *
+ * Convert _str_ and return converted result.
+ * Conversion details are specified by _opt_ as String.
+ *
+ * require 'nkf'
+ * output = NKF.nkf("-s", input)
+ */
+
+static VALUE
+rb_nkf_convert(VALUE obj, VALUE opt, VALUE src)
+{
+ VALUE tmp;
+ reinit();
+ StringValue(opt);
+ nkf_split_options(RSTRING_PTR(opt));
+ if (!output_encoding) rb_raise(rb_eArgError, "no output encoding given");
+
+ switch (nkf_enc_to_index(output_encoding)) {
+ case UTF_8_BOM: output_encoding = nkf_enc_from_index(UTF_8); break;
+ case UTF_16BE_BOM: output_encoding = nkf_enc_from_index(UTF_16BE); break;
+ case UTF_16LE_BOM: output_encoding = nkf_enc_from_index(UTF_16LE); break;
+ case UTF_32BE_BOM: output_encoding = nkf_enc_from_index(UTF_32BE); break;
+ case UTF_32LE_BOM: output_encoding = nkf_enc_from_index(UTF_32LE); break;
+ }
+ output_bom_f = FALSE;
+
+ incsize = INCSIZE;
+
+ input_ctr = 0;
+ StringValue(src);
+ input = (unsigned char *)RSTRING_PTR(src);
+ i_len = RSTRING_LENINT(src);
+ tmp = rb_str_new(0, i_len*3 + 10);
+
+ output_ctr = 0;
+ output = (unsigned char *)RSTRING_PTR(tmp);
+ o_len = RSTRING_LENINT(tmp);
+ *output = '\0';
+
+ /* use _result_ begin*/
+ result = tmp;
+ kanji_convert(NULL);
+ result = Qnil;
+ /* use _result_ end */
+
+ rb_str_set_len(tmp, output_ctr);
+ OBJ_INFECT(tmp, src);
+
+ if (mimeout_f)
+ rb_enc_associate(tmp, rb_usascii_encoding());
+ else
+ rb_enc_associate(tmp, rb_nkf_enc_get(nkf_enc_name(output_encoding)));
+
+ return tmp;
+}
+
+
+/*
+ * call-seq:
+ * NKF.guess(str) => encoding
+ *
+ * Returns guessed encoding of _str_ by nkf routine.
+ *
+ */
+
+static VALUE
+rb_nkf_guess(VALUE obj, VALUE src)
+{
+ reinit();
+
+ input_ctr = 0;
+ StringValue(src);
+ input = (unsigned char *)RSTRING_PTR(src);
+ i_len = RSTRING_LENINT(src);
+
+ guess_f = TRUE;
+ kanji_convert( NULL );
+ guess_f = FALSE;
+
+ return rb_enc_from_encoding(rb_nkf_enc_get(get_guessed_code()));
+}
+
+
+/*
+ * NKF - Ruby extension for Network Kanji Filter
+ *
+ * == Description
+ *
+ * This is a Ruby Extension version of nkf (Network Kanji Filter).
+ * It converts the first argument and returns converted result. Conversion
+ * details are specified by flags as the first argument.
+ *
+ * *Nkf* is a yet another kanji code converter among networks, hosts and terminals.
+ * It converts input kanji code to designated kanji code
+ * such as ISO-2022-JP, Shift_JIS, EUC-JP, UTF-8 or UTF-16.
+ *
+ * One of the most unique faculty of *nkf* is the guess of the input kanji encodings.
+ * It currently recognizes ISO-2022-JP, Shift_JIS, EUC-JP, UTF-8 and UTF-16.
+ * So users needn't set the input kanji code explicitly.
+ *
+ * By default, X0201 kana is converted into X0208 kana.
+ * For X0201 kana, SO/SI, SSO and ESC-(-I methods are supported.
+ * For automatic code detection, nkf assumes no X0201 kana in Shift_JIS.
+ * To accept X0201 in Shift_JIS, use <b>-X</b>, <b>-x</b> or <b>-S</b>.
+ *
+ * == Flags
+ *
+ * === -b -u
+ *
+ * Output is buffered (DEFAULT), Output is unbuffered.
+ *
+ * === -j -s -e -w -w16 -w32
+ *
+ * Output code is ISO-2022-JP (7bit JIS), Shift_JIS, EUC-JP,
+ * UTF-8N, UTF-16BE, UTF-32BE.
+ * Without this option and compile option, ISO-2022-JP is assumed.
+ *
+ * === -J -S -E -W -W16 -W32
+ *
+ * Input assumption is JIS 7 bit, Shift_JIS, EUC-JP,
+ * UTF-8, UTF-16, UTF-32.
+ *
+ * ==== -J
+ *
+ * Assume JIS input. It also accepts EUC-JP.
+ * This is the default. This flag does not exclude Shift_JIS.
+ *
+ * ==== -S
+ *
+ * Assume Shift_JIS and X0201 kana input. It also accepts JIS.
+ * EUC-JP is recognized as X0201 kana. Without <b>-x</b> flag,
+ * X0201 kana (halfwidth kana) is converted into X0208.
+ *
+ * ==== -E
+ *
+ * Assume EUC-JP input. It also accepts JIS.
+ * Same as -J.
+ *
+ * === -t
+ *
+ * No conversion.
+ *
+ * === -i_
+ *
+ * Output sequence to designate JIS-kanji. (DEFAULT B)
+ *
+ * === -o_
+ *
+ * Output sequence to designate ASCII. (DEFAULT B)
+ *
+ * === -r
+ *
+ * {de/en}crypt ROT13/47
+ *
+ * === -h[123] --hiragana --katakana --katakana-hiragana
+ *
+ * [-h1 --hiragana] Katakana to Hiragana conversion.
+ *
+ * [-h2 --katakana] Hiragana to Katakana conversion.
+ *
+ * [-h3 --katakana-hiragana] Katakana to Hiragana and Hiragana to Katakana conversion.
+ *
+ * === -T
+ *
+ * Text mode output (MS-DOS)
+ *
+ * === -l
+ *
+ * ISO8859-1 (Latin-1) support
+ *
+ * === -f[<code>m</code> [- <code>n</code>]]
+ *
+ * Folding on <code>m</code> length with <code>n</code> margin in a line.
+ * Without this option, fold length is 60 and fold margin is 10.
+ *
+ * === -F
+ *
+ * New line preserving line folding.
+ *
+ * === -Z[0-3]
+ *
+ * Convert X0208 alphabet (Fullwidth Alphabets) to ASCII.
+ *
+ * [-Z -Z0] Convert X0208 alphabet to ASCII.
+ *
+ * [-Z1] Converts X0208 kankaku to single ASCII space.
+ *
+ * [-Z2] Converts X0208 kankaku to double ASCII spaces.
+ *
+ * [-Z3] Replacing Fullwidth >, <, ", & into '&gt;', '&lt;', '&quot;', '&amp;' as in HTML.
+ *
+ * === -X -x
+ *
+ * Assume X0201 kana in MS-Kanji.
+ * With <b>-X</b> or without this option, X0201 is converted into X0208 Kana.
+ * With <b>-x</b>, try to preserve X0208 kana and do not convert X0201 kana to X0208.
+ * In JIS output, ESC-(-I is used. In EUC output, SSO is used.
+ *
+ * === -B[0-2]
+ *
+ * Assume broken JIS-Kanji input, which lost ESC.
+ * Useful when your site is using old B-News Nihongo patch.
+ *
+ * [-B1] allows any char after ESC-( or ESC-$.
+ *
+ * [-B2] forces ASCII after NL.
+ *
+ * === -I
+ *
+ * Replacing non iso-2022-jp char into a geta character
+ * (substitute character in Japanese).
+ *
+ * === -d -c
+ *
+ * Delete \r in line feed, Add \r in line feed.
+ *
+ * === -m[BQN0]
+ *
+ * MIME ISO-2022-JP/ISO8859-1 decode. (DEFAULT)
+ * To see ISO8859-1 (Latin-1) -l is necessary.
+ *
+ * [-mB] Decode MIME base64 encoded stream. Remove header or other part before
+ * conversion.
+ *
+ * [-mQ] Decode MIME quoted stream. '_' in quoted stream is converted to space.
+ *
+ * [-mN] Non-strict decoding.
+ * It allows line break in the middle of the base64 encoding.
+ *
+ * [-m0] No MIME decode.
+ *
+ * === -M
+ *
+ * MIME encode. Header style. All ASCII code and control characters are intact.
+ * Kanji conversion is performed before encoding, so this cannot be used as a picture encoder.
+ *
+ * [-MB] MIME encode Base64 stream.
+ *
+ * [-MQ] Perfome quoted encoding.
+ *
+ * === -l
+ *
+ * Input and output code is ISO8859-1 (Latin-1) and ISO-2022-JP.
+ * <b>-s</b>, <b>-e</b> and <b>-x</b> are not compatible with this option.
+ *
+ * === -L[uwm]
+ *
+ * new line mode
+ * Without this option, nkf doesn't convert line breaks.
+ *
+ * [-Lu] unix (LF)
+ *
+ * [-Lw] windows (CRLF)
+ *
+ * [-Lm] mac (CR)
+ *
+ * === --fj --unix --mac --msdos --windows
+ *
+ * convert for these system
+ *
+ * === --jis --euc --sjis --mime --base64
+ *
+ * convert for named code
+ *
+ * === --jis-input --euc-input --sjis-input --mime-input --base64-input
+ *
+ * assume input system
+ *
+ * === --ic=<code>input codeset</code> --oc=<code>output codeset</code>
+ *
+ * Set the input or output codeset.
+ * NKF supports following codesets and those codeset name are case insensitive.
+ *
+ * [ISO-2022-JP] a.k.a. RFC1468, 7bit JIS, JUNET
+ *
+ * [EUC-JP (eucJP-nkf)] a.k.a. AT&T JIS, Japanese EUC, UJIS
+ *
+ * [eucJP-ascii] a.k.a. x-eucjp-open-19970715-ascii
+ *
+ * [eucJP-ms] a.k.a. x-eucjp-open-19970715-ms
+ *
+ * [CP51932] Microsoft Version of EUC-JP.
+ *
+ * [Shift_JIS] SJIS, MS-Kanji
+ *
+ * [Windows-31J] a.k.a. CP932
+ *
+ * [UTF-8] same as UTF-8N
+ *
+ * [UTF-8N] UTF-8 without BOM
+ *
+ * [UTF-8-BOM] UTF-8 with BOM
+ *
+ * [UTF-16] same as UTF-16BE
+ *
+ * [UTF-16BE] UTF-16 Big Endian without BOM
+ *
+ * [UTF-16BE-BOM] UTF-16 Big Endian with BOM
+ *
+ * [UTF-16LE] UTF-16 Little Endian without BOM
+ *
+ * [UTF-16LE-BOM] UTF-16 Little Endian with BOM
+ *
+ * [UTF-32] same as UTF-32BE
+ *
+ * [UTF-32BE] UTF-32 Big Endian without BOM
+ *
+ * [UTF-32BE-BOM] UTF-32 Big Endian with BOM
+ *
+ * [UTF-32LE] UTF-32 Little Endian without BOM
+ *
+ * [UTF-32LE-BOM] UTF-32 Little Endian with BOM
+ *
+ * [UTF8-MAC] NKDed UTF-8, a.k.a. UTF8-NFD (input only)
+ *
+ * === --fb-{skip, html, xml, perl, java, subchar}
+ *
+ * Specify the way that nkf handles unassigned characters.
+ * Without this option, --fb-skip is assumed.
+ *
+ * === --prefix= <code>escape character</code> <code>target character</code> ..
+ *
+ * When nkf converts to Shift_JIS,
+ * nkf adds a specified escape character to specified 2nd byte of Shift_JIS characters.
+ * 1st byte of argument is the escape character and following bytes are target characters.
+ *
+ * === --no-cp932ext
+ *
+ * Handle the characters extended in CP932 as unassigned characters.
+ *
+ * == --no-best-fit-chars
+ *
+ * When Unicode to Encoded byte conversion,
+ * don't convert characters which is not round trip safe.
+ * When Unicode to Unicode conversion,
+ * with this and -x option, nkf can be used as UTF converter.
+ * (In other words, without this and -x option, nkf doesn't save some characters)
+ *
+ * When nkf convert string which related to path, you should use this opion.
+ *
+ * === --cap-input
+ *
+ * Decode hex encoded characters.
+ *
+ * === --url-input
+ *
+ * Unescape percent escaped characters.
+ *
+ * === --
+ *
+ * Ignore rest of -option.
+ */
+
+void
+Init_nkf(void)
+{
+ VALUE mNKF = rb_define_module("NKF");
+
+ rb_define_module_function(mNKF, "nkf", rb_nkf_convert, 2);
+ rb_define_module_function(mNKF, "guess", rb_nkf_guess, 1);
+ rb_define_alias(rb_singleton_class(mNKF), "guess", "guess");
+
+ rb_define_const(mNKF, "AUTO", Qnil);
+ rb_define_const(mNKF, "NOCONV", Qnil);
+ rb_define_const(mNKF, "UNKNOWN", Qnil);
+ rb_define_const(mNKF, "BINARY", rb_enc_from_encoding(rb_nkf_enc_get("BINARY")));
+ rb_define_const(mNKF, "ASCII", rb_enc_from_encoding(rb_nkf_enc_get("US-ASCII")));
+ rb_define_const(mNKF, "JIS", rb_enc_from_encoding(rb_nkf_enc_get("ISO-2022-JP")));
+ rb_define_const(mNKF, "EUC", rb_enc_from_encoding(rb_nkf_enc_get("EUC-JP")));
+ rb_define_const(mNKF, "SJIS", rb_enc_from_encoding(rb_nkf_enc_get("Shift_JIS")));
+ rb_define_const(mNKF, "UTF8", rb_enc_from_encoding(rb_utf8_encoding()));
+ rb_define_const(mNKF, "UTF16", rb_enc_from_encoding(rb_nkf_enc_get("UTF-16BE")));
+ rb_define_const(mNKF, "UTF32", rb_enc_from_encoding(rb_nkf_enc_get("UTF-32BE")));
+
+ /* Full version string of nkf */
+ rb_define_const(mNKF, "VERSION", rb_str_new2(RUBY_NKF_VERSION));
+ /* Version of nkf */
+ rb_define_const(mNKF, "NKF_VERSION", rb_str_new2(NKF_VERSION));
+ /* Release date of nkf */
+ rb_define_const(mNKF, "NKF_RELEASE_DATE", rb_str_new2(NKF_RELEASE_DATE));
+}
diff --git a/jni/ruby/ext/objspace/Makefile b/jni/ruby/ext/objspace/Makefile
new file mode 100644
index 0000000..a583e14
--- /dev/null
+++ b/jni/ruby/ext/objspace/Makefile
@@ -0,0 +1,335 @@
+
+SHELL = /bin/sh
+
+# V=0 quiet, V=1 verbose. other values don't work.
+V = 0
+Q1 = $(V:1=)
+Q = $(Q1:0=@)
+ECHO1 = $(V:1=@:)
+ECHO = $(ECHO1:0=@echo)
+NULLCMD = :
+
+#### Start of system configuration section. ####
+top_srcdir = $(topdir)/.
+srcdir = $(top_srcdir)/ext/objspace
+topdir = ../..
+hdrdir = $(top_srcdir)/include
+arch_hdrdir = $(extout)/include/$(arch)
+PATH_SEPARATOR = :
+VPATH = $(srcdir):$(arch_hdrdir)/ruby:$(hdrdir)/ruby:$(topdir):$(top_srcdir)
+RUBYLIB =
+RUBYOPT = -
+prefix = $(DESTDIR)/usr/local
+rubysitearchprefix = $(rubylibprefix)/$(sitearch)
+rubyarchprefix = $(rubylibprefix)/$(arch)
+rubylibprefix = $(libdir)/$(RUBY_BASE_NAME)
+exec_prefix = $(prefix)
+vendorarchhdrdir = $(vendorhdrdir)/$(sitearch)
+sitearchhdrdir = $(sitehdrdir)/$(sitearch)
+rubyarchhdrdir = $(rubyhdrdir)/$(arch)
+vendorhdrdir = $(rubyhdrdir)/vendor_ruby
+sitehdrdir = $(rubyhdrdir)/site_ruby
+rubyhdrdir = $(includedir)/$(RUBY_VERSION_NAME)
+vendorarchdir = $(vendorlibdir)/$(sitearch)
+vendorlibdir = $(vendordir)/$(ruby_version)
+vendordir = $(rubylibprefix)/vendor_ruby
+sitearchdir = $(sitelibdir)/$(sitearch)
+sitelibdir = $(sitedir)/$(ruby_version)
+sitedir = $(rubylibprefix)/site_ruby
+rubyarchdir = $(rubylibdir)/$(arch)
+rubylibdir = $(rubylibprefix)/$(ruby_version)
+sitearchincludedir = $(includedir)/$(sitearch)
+archincludedir = $(includedir)/$(arch)
+sitearchlibdir = $(libdir)/$(sitearch)
+archlibdir = $(libdir)/$(arch)
+ridir = $(datarootdir)/$(RI_BASE_NAME)
+mandir = $(datarootdir)/man
+localedir = $(datarootdir)/locale
+libdir = $(exec_prefix)/lib
+psdir = $(docdir)
+pdfdir = $(docdir)
+dvidir = $(docdir)
+htmldir = $(docdir)
+infodir = $(datarootdir)/info
+docdir = $(datarootdir)/doc/$(PACKAGE)
+oldincludedir = $(DESTDIR)/usr/include
+includedir = $(prefix)/include
+localstatedir = $(prefix)/var
+sharedstatedir = $(prefix)/com
+sysconfdir = $(prefix)/etc
+datadir = $(datarootdir)
+datarootdir = $(prefix)/share
+libexecdir = $(exec_prefix)/libexec
+sbindir = $(exec_prefix)/sbin
+bindir = $(exec_prefix)/bin
+archdir = $(rubyarchdir)
+
+
+CC = gcc
+CXX = g++
+LIBRUBY = $(LIBRUBY_SO)
+LIBRUBY_A = lib$(RUBY_SO_NAME)-static.a
+LIBRUBYARG_SHARED = -Wl,-R$(libdir) -L$(libdir) -l$(RUBY_SO_NAME)
+LIBRUBYARG_STATIC = -Wl,-R$(libdir) -L$(libdir) -l$(RUBY_SO_NAME)-static
+empty =
+OUTFLAG = -o $(empty)
+COUTFLAG = -o $(empty)
+
+RUBY_EXTCONF_H = extconf.h
+cflags = $(optflags) $(debugflags) $(warnflags)
+optflags = -O3 -fno-fast-math
+debugflags = -ggdb3
+warnflags = -Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wunused-variable -Wpointer-arith -Wwrite-strings -Wdeclaration-after-statement -Wimplicit-function-declaration -Wdeprecated-declarations -Wno-packed-bitfield-compat
+CCDLFLAGS = -fPIC
+CFLAGS = $(CCDLFLAGS) $(cflags) -fPIC $(ARCH_FLAG)
+INCFLAGS = -I. -I$(arch_hdrdir) -I$(hdrdir) -I$(srcdir) -I$(topdir) -I$(top_srcdir)
+DEFS =
+CPPFLAGS = -DRUBY_EXTCONF_H=\"$(RUBY_EXTCONF_H)\" $(DEFS) $(cppflags)
+CXXFLAGS = $(CCDLFLAGS) $(cxxflags) $(ARCH_FLAG)
+ldflags = -L. -fstack-protector -rdynamic -Wl,-export-dynamic
+dldflags =
+ARCH_FLAG =
+DLDFLAGS = $(ldflags) $(dldflags) $(ARCH_FLAG)
+LDSHARED = $(CC) -shared
+LDSHAREDXX = $(CXX) -shared
+AR = ar
+EXEEXT =
+
+RUBY_INSTALL_NAME = $(RUBY_BASE_NAME)
+RUBY_SO_NAME = ruby
+RUBYW_INSTALL_NAME =
+RUBY_VERSION_NAME = $(RUBY_BASE_NAME)-$(ruby_version)
+RUBYW_BASE_NAME = rubyw
+RUBY_BASE_NAME = ruby
+
+arch = x86_64-linux
+sitearch = $(arch)
+ruby_version = 2.2.0
+ruby = $(topdir)/miniruby -I'$(topdir)' -I'$(top_srcdir)/lib' -I'$(extout)/$(arch)' -I'$(extout)/common'
+RUBY = $(ruby)
+ruby_headers = $(hdrdir)/ruby.h $(hdrdir)/ruby/ruby.h $(hdrdir)/ruby/defines.h $(hdrdir)/ruby/missing.h $(hdrdir)/ruby/intern.h $(hdrdir)/ruby/st.h $(hdrdir)/ruby/subst.h $(arch_hdrdir)/ruby/config.h $(RUBY_EXTCONF_H)
+
+RM = rm -f
+RM_RF = $(RUBY) -run -e rm -- -rf
+RMDIRS = rmdir --ignore-fail-on-non-empty -p
+MAKEDIRS = /bin/mkdir -p
+INSTALL = /usr/bin/install -c
+INSTALL_PROG = $(INSTALL) -m 0755
+INSTALL_DATA = $(INSTALL) -m 644
+COPY = cp
+TOUCH = exit >
+
+#### End of system configuration section. ####
+
+preload =
+
+libpath = . $(topdir)
+LIBPATH = -L. -L$(topdir)
+DEFFILE =
+
+CLEANFILES = mkmf.log
+DISTCLEANFILES =
+DISTCLEANDIRS =
+
+extout = $(topdir)/.ext
+extout_prefix = $(extout)$(target_prefix)/
+target_prefix =
+LOCAL_LIBS =
+LIBS = $(LIBRUBYARG_SHARED) -lpthread -lgmp -ldl -lcrypt -lm -lc
+ORIG_SRCS = objspace_dump.c object_tracing.c objspace.c
+SRCS = $(ORIG_SRCS)
+OBJS = objspace_dump.o object_tracing.o objspace.o
+HDRS = $(srcdir)/extconf.h $(srcdir)/objspace.h
+TARGET = objspace
+TARGET_NAME = objspace
+TARGET_ENTRY = Init_$(TARGET_NAME)
+DLLIB = $(TARGET).so
+EXTSTATIC =
+STATIC_LIB = $(TARGET).a
+
+TIMESTAMP_DIR = $(extout)/.timestamp
+BINDIR = $(extout)/bin
+RUBYCOMMONDIR = $(extout)/common
+RUBYLIBDIR = $(RUBYCOMMONDIR)$(target_prefix)
+RUBYARCHDIR = $(extout)/$(arch)$(target_prefix)
+HDRDIR = $(extout)/include/ruby$(target_prefix)
+ARCHHDRDIR = $(extout)/include/$(arch)/ruby$(target_prefix)
+
+TARGET_SO = $(RUBYARCHDIR)/$(DLLIB)
+CLEANLIBS = $(RUBYARCHDIR)/$(TARGET).so
+CLEANOBJS = *.o *.bak
+
+all: install
+static: all
+.PHONY: all install static install-so install-rb
+.PHONY: clean clean-so clean-static clean-rb
+
+clean-static::
+clean-rb-default::
+clean-rb::
+clean-so::
+clean: clean-so clean-static clean-rb-default clean-rb
+ -$(Q)$(RM) $(CLEANLIBS) $(CLEANOBJS) $(CLEANFILES) .*.time
+
+distclean-rb-default::
+distclean-rb::
+distclean-so::
+distclean-static::
+distclean: clean distclean-so distclean-static distclean-rb-default distclean-rb
+ -$(Q)$(RM) Makefile $(RUBY_EXTCONF_H) conftest.* mkmf.log
+ -$(Q)$(RM) core ruby$(EXEEXT) *~ $(DISTCLEANFILES)
+ -$(Q)$(RMDIRS) $(DISTCLEANDIRS) 2> /dev/null || true
+
+realclean: distclean
+install: install-so install-rb
+
+install-so: $(RUBYARCHDIR)/$(DLLIB)
+clean-so::
+ -$(Q)$(RM) $(RUBYARCHDIR)/$(DLLIB)
+ -$(Q)$(RMDIRS) $(RUBYARCHDIR) 2> /dev/null || true
+clean-static::
+ -$(Q)$(RM) $(STATIC_LIB)
+install-rb: pre-install-rb install-rb-default
+install-rb-default: pre-install-rb-default
+pre-install-rb: Makefile
+pre-install-rb-default: Makefile
+pre-install-rb-default:
+ @$(NULLCMD)
+$(TIMESTAMP_DIR)/.RUBYARCHDIR.time:
+ $(Q) $(MAKEDIRS) $(@D) $(RUBYARCHDIR)
+ $(Q) $(TOUCH) $@
+
+site-install: site-install-so site-install-rb
+site-install-so: install-so
+site-install-rb: install-rb
+
+.SUFFIXES: .c .m .cc .mm .cxx .cpp .o .S
+
+.cc.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<
+
+.cc.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -S $<
+
+.mm.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<
+
+.mm.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -S $<
+
+.cxx.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<
+
+.cxx.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -S $<
+
+.cpp.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<
+
+.cpp.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -S $<
+
+.c.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -c $<
+
+.c.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -S $<
+
+.m.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -c $<
+
+.m.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -S $<
+
+$(RUBYARCHDIR)/$(DLLIB): $(OBJS) Makefile $(TIMESTAMP_DIR)/.RUBYARCHDIR.time
+ $(ECHO) linking shared-object $(DLLIB)
+ -$(Q)$(RM) $(@)
+ $(Q) $(LDSHARED) -o $@ $(OBJS) $(LIBPATH) $(DLDFLAGS) $(LOCAL_LIBS) $(LIBS)
+
+$(STATIC_LIB): $(OBJS)
+ -$(Q)$(RM) $(@)
+ $(ECHO) linking static-library $(@)
+ $(Q) $(AR) cru $@ $(OBJS)
+ -$(Q)ranlib $(@) 2> /dev/null || true
+
+###
+$(OBJS): $(RUBY_EXTCONF_H)
+
+# AUTOGENERATED DEPENDENCIES START
+object_tracing.o: $(RUBY_EXTCONF_H)
+object_tracing.o: $(arch_hdrdir)/ruby/config.h
+object_tracing.o: $(hdrdir)/ruby/debug.h
+object_tracing.o: $(hdrdir)/ruby/defines.h
+object_tracing.o: $(hdrdir)/ruby/encoding.h
+object_tracing.o: $(hdrdir)/ruby/intern.h
+object_tracing.o: $(hdrdir)/ruby/io.h
+object_tracing.o: $(hdrdir)/ruby/missing.h
+object_tracing.o: $(hdrdir)/ruby/oniguruma.h
+object_tracing.o: $(hdrdir)/ruby/ruby.h
+object_tracing.o: $(hdrdir)/ruby/st.h
+object_tracing.o: $(hdrdir)/ruby/subst.h
+object_tracing.o: $(top_srcdir)/include/ruby.h
+object_tracing.o: $(top_srcdir)/internal.h
+object_tracing.o: object_tracing.c
+object_tracing.o: objspace.h
+objspace.o: $(RUBY_EXTCONF_H)
+objspace.o: $(arch_hdrdir)/ruby/config.h
+objspace.o: $(hdrdir)/ruby/defines.h
+objspace.o: $(hdrdir)/ruby/encoding.h
+objspace.o: $(hdrdir)/ruby/intern.h
+objspace.o: $(hdrdir)/ruby/io.h
+objspace.o: $(hdrdir)/ruby/missing.h
+objspace.o: $(hdrdir)/ruby/oniguruma.h
+objspace.o: $(hdrdir)/ruby/re.h
+objspace.o: $(hdrdir)/ruby/regex.h
+objspace.o: $(hdrdir)/ruby/ruby.h
+objspace.o: $(hdrdir)/ruby/st.h
+objspace.o: $(hdrdir)/ruby/subst.h
+objspace.o: $(top_srcdir)/gc.h
+objspace.o: $(top_srcdir)/include/ruby.h
+objspace.o: $(top_srcdir)/internal.h
+objspace.o: $(top_srcdir)/node.h
+objspace.o: objspace.c
+objspace_dump.o: $(RUBY_EXTCONF_H)
+objspace_dump.o: $(arch_hdrdir)/ruby/config.h
+objspace_dump.o: $(hdrdir)/ruby/debug.h
+objspace_dump.o: $(hdrdir)/ruby/defines.h
+objspace_dump.o: $(hdrdir)/ruby/encoding.h
+objspace_dump.o: $(hdrdir)/ruby/intern.h
+objspace_dump.o: $(hdrdir)/ruby/io.h
+objspace_dump.o: $(hdrdir)/ruby/missing.h
+objspace_dump.o: $(hdrdir)/ruby/oniguruma.h
+objspace_dump.o: $(hdrdir)/ruby/ruby.h
+objspace_dump.o: $(hdrdir)/ruby/st.h
+objspace_dump.o: $(hdrdir)/ruby/subst.h
+objspace_dump.o: $(hdrdir)/ruby/thread_native.h
+objspace_dump.o: $(top_srcdir)/ccan/check_type/check_type.h
+objspace_dump.o: $(top_srcdir)/ccan/container_of/container_of.h
+objspace_dump.o: $(top_srcdir)/ccan/list/list.h
+objspace_dump.o: $(top_srcdir)/ccan/str/str.h
+objspace_dump.o: $(top_srcdir)/gc.h
+objspace_dump.o: $(top_srcdir)/include/ruby.h
+objspace_dump.o: $(top_srcdir)/internal.h
+objspace_dump.o: $(top_srcdir)/method.h
+objspace_dump.o: $(top_srcdir)/node.h
+objspace_dump.o: $(top_srcdir)/ruby_atomic.h
+objspace_dump.o: $(top_srcdir)/thread_pthread.h
+objspace_dump.o: $(top_srcdir)/vm_core.h
+objspace_dump.o: $(top_srcdir)/vm_debug.h
+objspace_dump.o: $(top_srcdir)/vm_opts.h
+objspace_dump.o: objspace.h
+objspace_dump.o: objspace_dump.c
+objspace_dump.o: id.h
+# AUTOGENERATED DEPENDENCIES END
diff --git a/jni/ruby/ext/objspace/depend b/jni/ruby/ext/objspace/depend
new file mode 100644
index 0000000..32af521
--- /dev/null
+++ b/jni/ruby/ext/objspace/depend
@@ -0,0 +1,66 @@
+# AUTOGENERATED DEPENDENCIES START
+object_tracing.o: $(RUBY_EXTCONF_H)
+object_tracing.o: $(arch_hdrdir)/ruby/config.h
+object_tracing.o: $(hdrdir)/ruby/debug.h
+object_tracing.o: $(hdrdir)/ruby/defines.h
+object_tracing.o: $(hdrdir)/ruby/encoding.h
+object_tracing.o: $(hdrdir)/ruby/intern.h
+object_tracing.o: $(hdrdir)/ruby/io.h
+object_tracing.o: $(hdrdir)/ruby/missing.h
+object_tracing.o: $(hdrdir)/ruby/oniguruma.h
+object_tracing.o: $(hdrdir)/ruby/ruby.h
+object_tracing.o: $(hdrdir)/ruby/st.h
+object_tracing.o: $(hdrdir)/ruby/subst.h
+object_tracing.o: $(top_srcdir)/include/ruby.h
+object_tracing.o: $(top_srcdir)/internal.h
+object_tracing.o: object_tracing.c
+object_tracing.o: objspace.h
+objspace.o: $(RUBY_EXTCONF_H)
+objspace.o: $(arch_hdrdir)/ruby/config.h
+objspace.o: $(hdrdir)/ruby/defines.h
+objspace.o: $(hdrdir)/ruby/encoding.h
+objspace.o: $(hdrdir)/ruby/intern.h
+objspace.o: $(hdrdir)/ruby/io.h
+objspace.o: $(hdrdir)/ruby/missing.h
+objspace.o: $(hdrdir)/ruby/oniguruma.h
+objspace.o: $(hdrdir)/ruby/re.h
+objspace.o: $(hdrdir)/ruby/regex.h
+objspace.o: $(hdrdir)/ruby/ruby.h
+objspace.o: $(hdrdir)/ruby/st.h
+objspace.o: $(hdrdir)/ruby/subst.h
+objspace.o: $(top_srcdir)/gc.h
+objspace.o: $(top_srcdir)/include/ruby.h
+objspace.o: $(top_srcdir)/internal.h
+objspace.o: $(top_srcdir)/node.h
+objspace.o: objspace.c
+objspace_dump.o: $(RUBY_EXTCONF_H)
+objspace_dump.o: $(arch_hdrdir)/ruby/config.h
+objspace_dump.o: $(hdrdir)/ruby/debug.h
+objspace_dump.o: $(hdrdir)/ruby/defines.h
+objspace_dump.o: $(hdrdir)/ruby/encoding.h
+objspace_dump.o: $(hdrdir)/ruby/intern.h
+objspace_dump.o: $(hdrdir)/ruby/io.h
+objspace_dump.o: $(hdrdir)/ruby/missing.h
+objspace_dump.o: $(hdrdir)/ruby/oniguruma.h
+objspace_dump.o: $(hdrdir)/ruby/ruby.h
+objspace_dump.o: $(hdrdir)/ruby/st.h
+objspace_dump.o: $(hdrdir)/ruby/subst.h
+objspace_dump.o: $(hdrdir)/ruby/thread_native.h
+objspace_dump.o: $(top_srcdir)/ccan/check_type/check_type.h
+objspace_dump.o: $(top_srcdir)/ccan/container_of/container_of.h
+objspace_dump.o: $(top_srcdir)/ccan/list/list.h
+objspace_dump.o: $(top_srcdir)/ccan/str/str.h
+objspace_dump.o: $(top_srcdir)/gc.h
+objspace_dump.o: $(top_srcdir)/include/ruby.h
+objspace_dump.o: $(top_srcdir)/internal.h
+objspace_dump.o: $(top_srcdir)/method.h
+objspace_dump.o: $(top_srcdir)/node.h
+objspace_dump.o: $(top_srcdir)/ruby_atomic.h
+objspace_dump.o: $(top_srcdir)/thread_pthread.h
+objspace_dump.o: $(top_srcdir)/vm_core.h
+objspace_dump.o: $(top_srcdir)/vm_debug.h
+objspace_dump.o: $(top_srcdir)/vm_opts.h
+objspace_dump.o: objspace.h
+objspace_dump.o: objspace_dump.c
+objspace_dump.o: {$(VPATH)}id.h
+# AUTOGENERATED DEPENDENCIES END
diff --git a/jni/ruby/ext/objspace/extconf.h b/jni/ruby/ext/objspace/extconf.h
new file mode 100644
index 0000000..cda0cc8
--- /dev/null
+++ b/jni/ruby/ext/objspace/extconf.h
@@ -0,0 +1,3 @@
+#ifndef EXTCONF_H
+#define EXTCONF_H
+#endif
diff --git a/jni/ruby/ext/objspace/extconf.rb b/jni/ruby/ext/objspace/extconf.rb
new file mode 100644
index 0000000..2b41543
--- /dev/null
+++ b/jni/ruby/ext/objspace/extconf.rb
@@ -0,0 +1,3 @@
+$INCFLAGS << " -I$(topdir) -I$(top_srcdir)"
+$VPATH << '$(topdir)' << '$(top_srcdir)' # for id.h.
+create_makefile('objspace')
diff --git a/jni/ruby/ext/objspace/object_tracing.c b/jni/ruby/ext/objspace/object_tracing.c
new file mode 100644
index 0000000..3a7f544
--- /dev/null
+++ b/jni/ruby/ext/objspace/object_tracing.c
@@ -0,0 +1,492 @@
+/**********************************************************************
+
+ object_tracing.c - Object Tracing mechanism/ObjectSpace extender for MRI.
+
+ $Author$
+ created at: Mon May 27 16:27:44 2013
+
+ NOTE: This extension library is not expected to exist except C Ruby.
+ NOTE: This feature is an example usage of internal event tracing APIs.
+
+ All the files in this distribution are covered under the Ruby's
+ license (see the file COPYING).
+
+**********************************************************************/
+
+#include "internal.h"
+#include "ruby/debug.h"
+#include "objspace.h"
+
+struct traceobj_arg {
+ int running;
+ int keep_remains;
+ VALUE newobj_trace;
+ VALUE freeobj_trace;
+ st_table *object_table; /* obj (VALUE) -> allocation_info */
+ st_table *str_table; /* cstr -> refcount */
+ struct traceobj_arg *prev_traceobj_arg;
+};
+
+static const char *
+make_unique_str(st_table *tbl, const char *str, long len)
+{
+ if (!str) {
+ return NULL;
+ }
+ else {
+ st_data_t n;
+ char *result;
+
+ if (st_lookup(tbl, (st_data_t)str, &n)) {
+ st_insert(tbl, (st_data_t)str, n+1);
+ st_get_key(tbl, (st_data_t)str, (st_data_t *)&result);
+ }
+ else {
+ result = (char *)ruby_xmalloc(len+1);
+ strncpy(result, str, len);
+ result[len] = 0;
+ st_add_direct(tbl, (st_data_t)result, 1);
+ }
+ return result;
+ }
+}
+
+static void
+delete_unique_str(st_table *tbl, const char *str)
+{
+ if (str) {
+ st_data_t n;
+
+ st_lookup(tbl, (st_data_t)str, &n);
+ if (n == 1) {
+ st_delete(tbl, (st_data_t *)&str, 0);
+ ruby_xfree((char *)str);
+ }
+ else {
+ st_insert(tbl, (st_data_t)str, n-1);
+ }
+ }
+}
+
+static void
+newobj_i(VALUE tpval, void *data)
+{
+ struct traceobj_arg *arg = (struct traceobj_arg *)data;
+ rb_trace_arg_t *tparg = rb_tracearg_from_tracepoint(tpval);
+ VALUE obj = rb_tracearg_object(tparg);
+ VALUE path = rb_tracearg_path(tparg);
+ VALUE line = rb_tracearg_lineno(tparg);
+ VALUE mid = rb_tracearg_method_id(tparg);
+ VALUE klass = rb_tracearg_defined_class(tparg);
+ struct allocation_info *info;
+ const char *path_cstr = RTEST(path) ? make_unique_str(arg->str_table, RSTRING_PTR(path), RSTRING_LEN(path)) : 0;
+ VALUE class_path = (RTEST(klass) && !OBJ_FROZEN(klass)) ? rb_class_path_cached(klass) : Qnil;
+ const char *class_path_cstr = RTEST(class_path) ? make_unique_str(arg->str_table, RSTRING_PTR(class_path), RSTRING_LEN(class_path)) : 0;
+
+ if (st_lookup(arg->object_table, (st_data_t)obj, (st_data_t *)&info)) {
+ if (arg->keep_remains) {
+ if (info->living) {
+ /* do nothing. there is possibility to keep living if FREEOBJ events while suppressing tracing */
+ }
+ }
+ /* reuse info */
+ delete_unique_str(arg->str_table, info->path);
+ delete_unique_str(arg->str_table, info->class_path);
+ }
+ else {
+ info = (struct allocation_info *)ruby_xmalloc(sizeof(struct allocation_info));
+ }
+ info->living = 1;
+ info->flags = RBASIC(obj)->flags;
+ info->klass = RBASIC_CLASS(obj);
+
+ info->path = path_cstr;
+ info->line = NUM2INT(line);
+ info->mid = mid;
+ info->class_path = class_path_cstr;
+ info->generation = rb_gc_count();
+ st_insert(arg->object_table, (st_data_t)obj, (st_data_t)info);
+}
+
+static void
+freeobj_i(VALUE tpval, void *data)
+{
+ struct traceobj_arg *arg = (struct traceobj_arg *)data;
+ rb_trace_arg_t *tparg = rb_tracearg_from_tracepoint(tpval);
+ VALUE obj = rb_tracearg_object(tparg);
+ struct allocation_info *info;
+
+ if (st_lookup(arg->object_table, (st_data_t)obj, (st_data_t *)&info)) {
+ if (arg->keep_remains) {
+ info->living = 0;
+ }
+ else {
+ st_delete(arg->object_table, (st_data_t *)&obj, (st_data_t *)&info);
+ delete_unique_str(arg->str_table, info->path);
+ delete_unique_str(arg->str_table, info->class_path);
+ ruby_xfree(info);
+ }
+ }
+}
+
+static int
+free_keys_i(st_data_t key, st_data_t value, void *data)
+{
+ ruby_xfree((void *)key);
+ return ST_CONTINUE;
+}
+
+static int
+free_values_i(st_data_t key, st_data_t value, void *data)
+{
+ ruby_xfree((void *)value);
+ return ST_CONTINUE;
+}
+
+static struct traceobj_arg *tmp_trace_arg; /* TODO: Do not use global variables */
+static int tmp_keep_remains; /* TODO: Do not use global variables */
+
+static struct traceobj_arg *
+get_traceobj_arg(void)
+{
+ if (tmp_trace_arg == 0) {
+ tmp_trace_arg = ALLOC_N(struct traceobj_arg, 1);
+ tmp_trace_arg->running = 0;
+ tmp_trace_arg->keep_remains = tmp_keep_remains;
+ tmp_trace_arg->newobj_trace = 0;
+ tmp_trace_arg->freeobj_trace = 0;
+ tmp_trace_arg->object_table = st_init_numtable();
+ tmp_trace_arg->str_table = st_init_strtable();
+ }
+ return tmp_trace_arg;
+}
+
+/*
+ * call-seq: trace_object_allocations_start
+ *
+ * Starts tracing object allocations.
+ *
+ */
+static VALUE
+trace_object_allocations_start(VALUE self)
+{
+ struct traceobj_arg *arg = get_traceobj_arg();
+
+ if (arg->running++ > 0) {
+ /* do nothing */
+ }
+ else {
+ if (arg->newobj_trace == 0) {
+ arg->newobj_trace = rb_tracepoint_new(0, RUBY_INTERNAL_EVENT_NEWOBJ, newobj_i, arg);
+ arg->freeobj_trace = rb_tracepoint_new(0, RUBY_INTERNAL_EVENT_FREEOBJ, freeobj_i, arg);
+ }
+ rb_tracepoint_enable(arg->newobj_trace);
+ rb_tracepoint_enable(arg->freeobj_trace);
+ }
+
+ return Qnil;
+}
+
+/*
+ * call-seq: trace_object_allocations_stop
+ *
+ * Stop tracing object allocations.
+ *
+ * Note that if ::trace_object_allocations_start is called n-times, then
+ * tracing will stop after calling ::trace_object_allocations_stop n-times.
+ *
+ */
+static VALUE
+trace_object_allocations_stop(VALUE self)
+{
+ struct traceobj_arg *arg = get_traceobj_arg();
+
+ if (arg->running > 0) {
+ arg->running--;
+ }
+
+ if (arg->running == 0) {
+ rb_tracepoint_disable(arg->newobj_trace);
+ rb_tracepoint_disable(arg->freeobj_trace);
+ arg->newobj_trace = 0;
+ arg->freeobj_trace = 0;
+ }
+
+ return Qnil;
+}
+
+/*
+ * call-seq: trace_object_allocations_clear
+ *
+ * Clear recorded tracing information.
+ *
+ */
+static VALUE
+trace_object_allocations_clear(VALUE self)
+{
+ struct traceobj_arg *arg = get_traceobj_arg();
+
+ /* clear tables */
+ st_foreach(arg->object_table, free_values_i, 0);
+ st_clear(arg->object_table);
+ st_foreach(arg->str_table, free_keys_i, 0);
+ st_clear(arg->str_table);
+
+ /* do not touch TracePoints */
+
+ return Qnil;
+}
+
+/*
+ * call-seq: trace_object_allocations { block }
+ *
+ * Starts tracing object allocations from the ObjectSpace extension module.
+ *
+ * For example:
+ *
+ * require 'objspace'
+ *
+ * class C
+ * include ObjectSpace
+ *
+ * def foo
+ * trace_object_allocations do
+ * obj = Object.new
+ * p "#{allocation_sourcefile(obj)}:#{allocation_sourceline(obj)}"
+ * end
+ * end
+ * end
+ *
+ * C.new.foo #=> "objtrace.rb:8"
+ *
+ * This example has included the ObjectSpace module to make it easier to read,
+ * but you can also use the ::trace_object_allocations notation (recommended).
+ *
+ * Note that this feature introduces a huge performance decrease and huge
+ * memory consumption.
+ */
+static VALUE
+trace_object_allocations(VALUE self)
+{
+ trace_object_allocations_start(self);
+ return rb_ensure(rb_yield, Qnil, trace_object_allocations_stop, self);
+}
+
+int rb_bug_reporter_add(void (*func)(FILE *, void *), void *data);
+static int object_allocations_reporter_registered = 0;
+
+static int
+object_allocations_reporter_i(st_data_t key, st_data_t val, st_data_t ptr)
+{
+ FILE *out = (FILE *)ptr;
+ VALUE obj = (VALUE)key;
+ struct allocation_info *info = (struct allocation_info *)val;
+
+ fprintf(out, "-- %p (%s F: %p, ", (void *)obj, info->living ? "live" : "dead", (void *)info->flags);
+ if (info->class_path) fprintf(out, "C: %s", info->class_path);
+ else fprintf(out, "C: %p", (void *)info->klass);
+ fprintf(out, "@%s:%lu", info->path ? info->path : "", info->line);
+ if (!NIL_P(info->mid)) {
+ VALUE m = rb_sym2str(info->mid);
+ fprintf(out, " (%s)", RSTRING_PTR(m));
+ }
+ fprintf(out, ")\n");
+
+ return ST_CONTINUE;
+}
+
+static void
+object_allocations_reporter(FILE *out, void *ptr)
+{
+ fprintf(out, "== object_allocations_reporter: START\n");
+ if (tmp_trace_arg) {
+ st_foreach(tmp_trace_arg->object_table, object_allocations_reporter_i, (st_data_t)out);
+ }
+ fprintf(out, "== object_allocations_reporter: END\n");
+}
+
+static VALUE
+trace_object_allocations_debug_start(VALUE self)
+{
+ tmp_keep_remains = 1;
+ if (object_allocations_reporter_registered == 0) {
+ object_allocations_reporter_registered = 1;
+ rb_bug_reporter_add(object_allocations_reporter, 0);
+ }
+
+ return trace_object_allocations_start(self);
+}
+
+static struct allocation_info *
+lookup_allocation_info(VALUE obj)
+{
+ if (tmp_trace_arg) {
+ struct allocation_info *info;
+ if (st_lookup(tmp_trace_arg->object_table, obj, (st_data_t *)&info)) {
+ return info;
+ }
+ }
+ return NULL;
+}
+
+struct allocation_info *
+objspace_lookup_allocation_info(VALUE obj)
+{
+ return lookup_allocation_info(obj);
+}
+
+/*
+ * call-seq: allocation_sourcefile(object) -> string
+ *
+ * Returns the source file origin from the given +object+.
+ *
+ * See ::trace_object_allocations for more information and examples.
+ */
+static VALUE
+allocation_sourcefile(VALUE self, VALUE obj)
+{
+ struct allocation_info *info = lookup_allocation_info(obj);
+
+ if (info && info->path) {
+ return rb_str_new2(info->path);
+ }
+ else {
+ return Qnil;
+ }
+}
+
+/*
+ * call-seq: allocation_sourceline(object) -> string
+ *
+ * Returns the original line from source for from the given +object+.
+ *
+ * See ::trace_object_allocations for more information and examples.
+ */
+static VALUE
+allocation_sourceline(VALUE self, VALUE obj)
+{
+ struct allocation_info *info = lookup_allocation_info(obj);
+
+ if (info) {
+ return INT2FIX(info->line);
+ }
+ else {
+ return Qnil;
+ }
+}
+
+/*
+ * call-seq: allocation_class_path(object) -> string
+ *
+ * Returns the class for the given +object+.
+ *
+ * class A
+ * def foo
+ * ObjectSpace::trace_object_allocations do
+ * obj = Object.new
+ * p "#{ObjectSpace::allocation_class_path(obj)}"
+ * end
+ * end
+ * end
+ *
+ * A.new.foo #=> "Class"
+ *
+ * See ::trace_object_allocations for more information and examples.
+ */
+static VALUE
+allocation_class_path(VALUE self, VALUE obj)
+{
+ struct allocation_info *info = lookup_allocation_info(obj);
+
+ if (info && info->class_path) {
+ return rb_str_new2(info->class_path);
+ }
+ else {
+ return Qnil;
+ }
+}
+
+/*
+ * call-seq: allocation_method_id(object) -> string
+ *
+ * Returns the method identifier for the given +object+.
+ *
+ * class A
+ * include ObjectSpace
+ *
+ * def foo
+ * trace_object_allocations do
+ * obj = Object.new
+ * p "#{allocation_class_path(obj)}##{allocation_method_id(obj)}"
+ * end
+ * end
+ * end
+ *
+ * A.new.foo #=> "Class#new"
+ *
+ * See ::trace_object_allocations for more information and examples.
+ */
+static VALUE
+allocation_method_id(VALUE self, VALUE obj)
+{
+ struct allocation_info *info = lookup_allocation_info(obj);
+ if (info) {
+ return info->mid;
+ }
+ else {
+ return Qnil;
+ }
+}
+
+/*
+ * call-seq: allocation_generation(object) -> Fixnum
+ *
+ * Returns garbage collector generation for the given +object+.
+ *
+ * class B
+ * include ObjectSpace
+ *
+ * def foo
+ * trace_object_allocations do
+ * obj = Object.new
+ * p "Generation is #{allocation_generation(obj)}"
+ * end
+ * end
+ * end
+ *
+ * B.new.foo #=> "Generation is 3"
+ *
+ * See ::trace_object_allocations for more information and examples.
+ */
+static VALUE
+allocation_generation(VALUE self, VALUE obj)
+{
+ struct allocation_info *info = lookup_allocation_info(obj);
+ if (info) {
+ return SIZET2NUM(info->generation);
+ }
+ else {
+ return Qnil;
+ }
+}
+
+void
+Init_object_tracing(VALUE rb_mObjSpace)
+{
+#if 0
+ rb_mObjSpace = rb_define_module("ObjectSpace"); /* let rdoc know */
+#endif
+
+ rb_define_module_function(rb_mObjSpace, "trace_object_allocations", trace_object_allocations, 0);
+ rb_define_module_function(rb_mObjSpace, "trace_object_allocations_start", trace_object_allocations_start, 0);
+ rb_define_module_function(rb_mObjSpace, "trace_object_allocations_stop", trace_object_allocations_stop, 0);
+ rb_define_module_function(rb_mObjSpace, "trace_object_allocations_clear", trace_object_allocations_clear, 0);
+
+ rb_define_module_function(rb_mObjSpace, "trace_object_allocations_debug_start", trace_object_allocations_debug_start, 0);
+
+ rb_define_module_function(rb_mObjSpace, "allocation_sourcefile", allocation_sourcefile, 1);
+ rb_define_module_function(rb_mObjSpace, "allocation_sourceline", allocation_sourceline, 1);
+ rb_define_module_function(rb_mObjSpace, "allocation_class_path", allocation_class_path, 1);
+ rb_define_module_function(rb_mObjSpace, "allocation_method_id", allocation_method_id, 1);
+ rb_define_module_function(rb_mObjSpace, "allocation_generation", allocation_generation, 1);
+}
diff --git a/jni/ruby/ext/objspace/objspace.c b/jni/ruby/ext/objspace/objspace.c
new file mode 100644
index 0000000..5f5a79b
--- /dev/null
+++ b/jni/ruby/ext/objspace/objspace.c
@@ -0,0 +1,777 @@
+/**********************************************************************
+
+ objspace.c - ObjectSpace extender for MRI.
+
+ $Author: ko1 $
+ created at: Wed Jun 17 07:39:17 2009
+
+ NOTE: This extension library is only expected to exist with C Ruby.
+
+ All the files in this distribution are covered under the Ruby's
+ license (see the file COPYING).
+
+**********************************************************************/
+
+#include "internal.h"
+#include <ruby/st.h>
+#include <ruby/io.h>
+#include <ruby/re.h>
+#include "node.h"
+#include "gc.h"
+
+/*
+ * call-seq:
+ * ObjectSpace.memsize_of(obj) -> Integer
+ *
+ * Return consuming memory size of obj.
+ *
+ * Note that the return size is incomplete. You need to deal with this
+ * information as only a *HINT*. Especially, the size of +T_DATA+ may not be
+ * correct.
+ *
+ * This method is only expected to work with C Ruby.
+ *
+ * From Ruby 2.2, memsize_of(obj) returns a memory size includes
+ * sizeof(RVALUE).
+ */
+
+static VALUE
+memsize_of_m(VALUE self, VALUE obj)
+{
+ return SIZET2NUM(rb_obj_memsize_of(obj));
+}
+
+struct total_data {
+ size_t total;
+ VALUE klass;
+};
+
+static int
+total_i(void *vstart, void *vend, size_t stride, void *ptr)
+{
+ VALUE v;
+ struct total_data *data = (struct total_data *)ptr;
+
+ for (v = (VALUE)vstart; v != (VALUE)vend; v += stride) {
+ if (RBASIC(v)->flags) {
+ switch (BUILTIN_TYPE(v)) {
+ case T_NONE:
+ case T_ICLASS:
+ case T_NODE:
+ case T_ZOMBIE:
+ continue;
+ case T_CLASS:
+ if (FL_TEST(v, FL_SINGLETON))
+ continue;
+ default:
+ if (data->klass == 0 || rb_obj_is_kind_of(v, data->klass)) {
+ data->total += rb_obj_memsize_of(v);
+ }
+ }
+ }
+ }
+
+ return 0;
+}
+
+/*
+ * call-seq:
+ * ObjectSpace.memsize_of_all([klass]) -> Integer
+ *
+ * Return consuming memory size of all living objects.
+ *
+ * If +klass+ (should be Class object) is given, return the total memory size
+ * of instances of the given class.
+ *
+ * Note that the returned size is incomplete. You need to deal with this
+ * information as only a *HINT*. Especially, the size of +T_DATA+ may not be
+ * correct.
+ *
+ * Note that this method does *NOT* return total malloc'ed memory size.
+ *
+ * This method can be defined by the following Ruby code:
+ *
+ * def memsize_of_all klass = false
+ * total = 0
+ * ObjectSpace.each_object{|e|
+ * total += ObjectSpace.memsize_of(e) if klass == false || e.kind_of?(klass)
+ * }
+ * total
+ * end
+ *
+ * This method is only expected to work with C Ruby.
+ */
+
+static VALUE
+memsize_of_all_m(int argc, VALUE *argv, VALUE self)
+{
+ struct total_data data = {0, 0};
+
+ if (argc > 0) {
+ rb_scan_args(argc, argv, "01", &data.klass);
+ }
+
+ rb_objspace_each_objects(total_i, &data);
+ return SIZET2NUM(data.total);
+}
+
+static int
+set_zero_i(st_data_t key, st_data_t val, st_data_t arg)
+{
+ VALUE k = (VALUE)key;
+ VALUE hash = (VALUE)arg;
+ rb_hash_aset(hash, k, INT2FIX(0));
+ return ST_CONTINUE;
+}
+
+static int
+cos_i(void *vstart, void *vend, size_t stride, void *data)
+{
+ size_t *counts = (size_t *)data;
+ VALUE v = (VALUE)vstart;
+
+ for (;v != (VALUE)vend; v += stride) {
+ if (RBASIC(v)->flags) {
+ counts[BUILTIN_TYPE(v)] += rb_obj_memsize_of(v);
+ }
+ }
+ return 0;
+}
+
+static VALUE
+type2sym(enum ruby_value_type i)
+{
+ VALUE type;
+ switch (i) {
+#define CASE_TYPE(t) case t: type = ID2SYM(rb_intern(#t)); break;
+ CASE_TYPE(T_NONE);
+ CASE_TYPE(T_OBJECT);
+ CASE_TYPE(T_CLASS);
+ CASE_TYPE(T_MODULE);
+ CASE_TYPE(T_FLOAT);
+ CASE_TYPE(T_STRING);
+ CASE_TYPE(T_REGEXP);
+ CASE_TYPE(T_ARRAY);
+ CASE_TYPE(T_HASH);
+ CASE_TYPE(T_STRUCT);
+ CASE_TYPE(T_BIGNUM);
+ CASE_TYPE(T_FILE);
+ CASE_TYPE(T_DATA);
+ CASE_TYPE(T_MATCH);
+ CASE_TYPE(T_COMPLEX);
+ CASE_TYPE(T_RATIONAL);
+ CASE_TYPE(T_NIL);
+ CASE_TYPE(T_TRUE);
+ CASE_TYPE(T_FALSE);
+ CASE_TYPE(T_SYMBOL);
+ CASE_TYPE(T_FIXNUM);
+ CASE_TYPE(T_UNDEF);
+ CASE_TYPE(T_NODE);
+ CASE_TYPE(T_ICLASS);
+ CASE_TYPE(T_ZOMBIE);
+#undef CASE_TYPE
+ default: rb_bug("type2sym: unknown type (%d)", i);
+ }
+ return type;
+}
+
+/*
+ * call-seq:
+ * ObjectSpace.count_objects_size([result_hash]) -> hash
+ *
+ * Counts objects size (in bytes) for each type.
+ *
+ * Note that this information is incomplete. You need to deal with
+ * this information as only a *HINT*. Especially, total size of
+ * T_DATA may not right size.
+ *
+ * It returns a hash as:
+ * {:TOTAL=>1461154, :T_CLASS=>158280, :T_MODULE=>20672, :T_STRING=>527249, ...}
+ *
+ * If the optional argument, result_hash, is given,
+ * it is overwritten and returned.
+ * This is intended to avoid probe effect.
+ *
+ * The contents of the returned hash is implementation defined.
+ * It may be changed in future.
+ *
+ * This method is only expected to work with C Ruby.
+ */
+
+static VALUE
+count_objects_size(int argc, VALUE *argv, VALUE os)
+{
+ size_t counts[T_MASK+1];
+ size_t total = 0;
+ enum ruby_value_type i;
+ VALUE hash;
+
+ if (rb_scan_args(argc, argv, "01", &hash) == 1) {
+ if (!RB_TYPE_P(hash, T_HASH))
+ rb_raise(rb_eTypeError, "non-hash given");
+ }
+
+ for (i = 0; i <= T_MASK; i++) {
+ counts[i] = 0;
+ }
+
+ rb_objspace_each_objects(cos_i, &counts[0]);
+
+ if (hash == Qnil) {
+ hash = rb_hash_new();
+ }
+ else if (!RHASH_EMPTY_P(hash)) {
+ st_foreach(RHASH_TBL(hash), set_zero_i, hash);
+ }
+
+ for (i = 0; i <= T_MASK; i++) {
+ if (counts[i]) {
+ VALUE type = type2sym(i);
+ total += counts[i];
+ rb_hash_aset(hash, type, SIZET2NUM(counts[i]));
+ }
+ }
+ rb_hash_aset(hash, ID2SYM(rb_intern("TOTAL")), SIZET2NUM(total));
+ return hash;
+}
+
+static int
+cn_i(void *vstart, void *vend, size_t stride, void *n)
+{
+ size_t *nodes = (size_t *)n;
+ VALUE v = (VALUE)vstart;
+
+ for (; v != (VALUE)vend; v += stride) {
+ if (RBASIC(v)->flags && BUILTIN_TYPE(v) == T_NODE) {
+ size_t s = nd_type((NODE *)v);
+ nodes[s]++;
+ }
+ }
+
+ return 0;
+}
+
+/*
+ * call-seq:
+ * ObjectSpace.count_nodes([result_hash]) -> hash
+ *
+ * Counts nodes for each node type.
+ *
+ * This method is only for MRI developers interested in performance and memory
+ * usage of Ruby programs.
+ *
+ * It returns a hash as:
+ *
+ * {:NODE_METHOD=>2027, :NODE_FBODY=>1927, :NODE_CFUNC=>1798, ...}
+ *
+ * If the optional argument, result_hash, is given, it is overwritten and
+ * returned. This is intended to avoid probe effect.
+ *
+ * Note:
+ * The contents of the returned hash is implementation defined.
+ * It may be changed in future.
+ *
+ * This method is only expected to work with C Ruby.
+ */
+
+static VALUE
+count_nodes(int argc, VALUE *argv, VALUE os)
+{
+ size_t nodes[NODE_LAST+1];
+ size_t i;
+ VALUE hash;
+
+ if (rb_scan_args(argc, argv, "01", &hash) == 1) {
+ if (!RB_TYPE_P(hash, T_HASH))
+ rb_raise(rb_eTypeError, "non-hash given");
+ }
+
+ for (i = 0; i <= NODE_LAST; i++) {
+ nodes[i] = 0;
+ }
+
+ rb_objspace_each_objects(cn_i, &nodes[0]);
+
+ if (hash == Qnil) {
+ hash = rb_hash_new();
+ }
+ else if (!RHASH_EMPTY_P(hash)) {
+ st_foreach(RHASH_TBL(hash), set_zero_i, hash);
+ }
+
+ for (i=0; i<NODE_LAST; i++) {
+ if (nodes[i] != 0) {
+ VALUE node;
+ switch (i) {
+#define COUNT_NODE(n) case n: node = ID2SYM(rb_intern(#n)); break;
+ COUNT_NODE(NODE_SCOPE);
+ COUNT_NODE(NODE_BLOCK);
+ COUNT_NODE(NODE_IF);
+ COUNT_NODE(NODE_CASE);
+ COUNT_NODE(NODE_WHEN);
+ COUNT_NODE(NODE_OPT_N);
+ COUNT_NODE(NODE_WHILE);
+ COUNT_NODE(NODE_UNTIL);
+ COUNT_NODE(NODE_ITER);
+ COUNT_NODE(NODE_FOR);
+ COUNT_NODE(NODE_BREAK);
+ COUNT_NODE(NODE_NEXT);
+ COUNT_NODE(NODE_REDO);
+ COUNT_NODE(NODE_RETRY);
+ COUNT_NODE(NODE_BEGIN);
+ COUNT_NODE(NODE_RESCUE);
+ COUNT_NODE(NODE_RESBODY);
+ COUNT_NODE(NODE_ENSURE);
+ COUNT_NODE(NODE_AND);
+ COUNT_NODE(NODE_OR);
+ COUNT_NODE(NODE_MASGN);
+ COUNT_NODE(NODE_LASGN);
+ COUNT_NODE(NODE_DASGN);
+ COUNT_NODE(NODE_DASGN_CURR);
+ COUNT_NODE(NODE_GASGN);
+ COUNT_NODE(NODE_IASGN);
+ COUNT_NODE(NODE_IASGN2);
+ COUNT_NODE(NODE_CDECL);
+ COUNT_NODE(NODE_CVASGN);
+ COUNT_NODE(NODE_CVDECL);
+ COUNT_NODE(NODE_OP_ASGN1);
+ COUNT_NODE(NODE_OP_ASGN2);
+ COUNT_NODE(NODE_OP_ASGN_AND);
+ COUNT_NODE(NODE_OP_ASGN_OR);
+ COUNT_NODE(NODE_OP_CDECL);
+ COUNT_NODE(NODE_CALL);
+ COUNT_NODE(NODE_FCALL);
+ COUNT_NODE(NODE_VCALL);
+ COUNT_NODE(NODE_SUPER);
+ COUNT_NODE(NODE_ZSUPER);
+ COUNT_NODE(NODE_ARRAY);
+ COUNT_NODE(NODE_ZARRAY);
+ COUNT_NODE(NODE_VALUES);
+ COUNT_NODE(NODE_HASH);
+ COUNT_NODE(NODE_RETURN);
+ COUNT_NODE(NODE_YIELD);
+ COUNT_NODE(NODE_LVAR);
+ COUNT_NODE(NODE_DVAR);
+ COUNT_NODE(NODE_GVAR);
+ COUNT_NODE(NODE_IVAR);
+ COUNT_NODE(NODE_CONST);
+ COUNT_NODE(NODE_CVAR);
+ COUNT_NODE(NODE_NTH_REF);
+ COUNT_NODE(NODE_BACK_REF);
+ COUNT_NODE(NODE_MATCH);
+ COUNT_NODE(NODE_MATCH2);
+ COUNT_NODE(NODE_MATCH3);
+ COUNT_NODE(NODE_LIT);
+ COUNT_NODE(NODE_STR);
+ COUNT_NODE(NODE_DSTR);
+ COUNT_NODE(NODE_XSTR);
+ COUNT_NODE(NODE_DXSTR);
+ COUNT_NODE(NODE_EVSTR);
+ COUNT_NODE(NODE_DREGX);
+ COUNT_NODE(NODE_DREGX_ONCE);
+ COUNT_NODE(NODE_ARGS);
+ COUNT_NODE(NODE_ARGS_AUX);
+ COUNT_NODE(NODE_OPT_ARG);
+ COUNT_NODE(NODE_KW_ARG);
+ COUNT_NODE(NODE_POSTARG);
+ COUNT_NODE(NODE_ARGSCAT);
+ COUNT_NODE(NODE_ARGSPUSH);
+ COUNT_NODE(NODE_SPLAT);
+ COUNT_NODE(NODE_TO_ARY);
+ COUNT_NODE(NODE_BLOCK_ARG);
+ COUNT_NODE(NODE_BLOCK_PASS);
+ COUNT_NODE(NODE_DEFN);
+ COUNT_NODE(NODE_DEFS);
+ COUNT_NODE(NODE_ALIAS);
+ COUNT_NODE(NODE_VALIAS);
+ COUNT_NODE(NODE_UNDEF);
+ COUNT_NODE(NODE_CLASS);
+ COUNT_NODE(NODE_MODULE);
+ COUNT_NODE(NODE_SCLASS);
+ COUNT_NODE(NODE_COLON2);
+ COUNT_NODE(NODE_COLON3);
+ COUNT_NODE(NODE_CREF);
+ COUNT_NODE(NODE_DOT2);
+ COUNT_NODE(NODE_DOT3);
+ COUNT_NODE(NODE_FLIP2);
+ COUNT_NODE(NODE_FLIP3);
+ COUNT_NODE(NODE_SELF);
+ COUNT_NODE(NODE_NIL);
+ COUNT_NODE(NODE_TRUE);
+ COUNT_NODE(NODE_FALSE);
+ COUNT_NODE(NODE_ERRINFO);
+ COUNT_NODE(NODE_DEFINED);
+ COUNT_NODE(NODE_POSTEXE);
+ COUNT_NODE(NODE_ALLOCA);
+ COUNT_NODE(NODE_BMETHOD);
+ COUNT_NODE(NODE_MEMO);
+ COUNT_NODE(NODE_IFUNC);
+ COUNT_NODE(NODE_DSYM);
+ COUNT_NODE(NODE_ATTRASGN);
+ COUNT_NODE(NODE_PRELUDE);
+ COUNT_NODE(NODE_LAMBDA);
+#undef COUNT_NODE
+ default: node = INT2FIX(i);
+ }
+ rb_hash_aset(hash, node, SIZET2NUM(nodes[i]));
+ }
+ }
+ return hash;
+}
+
+static int
+cto_i(void *vstart, void *vend, size_t stride, void *data)
+{
+ VALUE hash = (VALUE)data;
+ VALUE v = (VALUE)vstart;
+
+ for (; v != (VALUE)vend; v += stride) {
+ if (RBASIC(v)->flags && BUILTIN_TYPE(v) == T_DATA) {
+ VALUE counter;
+ VALUE key = RBASIC(v)->klass;
+
+ if (key == 0) {
+ const char *name = rb_objspace_data_type_name(v);
+ if (name == 0) name = "unknown";
+ key = ID2SYM(rb_intern(name));
+ }
+
+ counter = rb_hash_aref(hash, key);
+ if (NIL_P(counter)) {
+ counter = INT2FIX(1);
+ }
+ else {
+ counter = INT2FIX(FIX2INT(counter) + 1);
+ }
+
+ rb_hash_aset(hash, key, counter);
+ }
+ }
+
+ return 0;
+}
+
+/*
+ * call-seq:
+ * ObjectSpace.count_tdata_objects([result_hash]) -> hash
+ *
+ * Counts objects for each +T_DATA+ type.
+ *
+ * This method is only for MRI developers interested in performance and memory
+ * usage of Ruby programs.
+ *
+ * It returns a hash as:
+ *
+ * {RubyVM::InstructionSequence=>504, :parser=>5, :barrier=>6,
+ * :mutex=>6, Proc=>60, RubyVM::Env=>57, Mutex=>1, Encoding=>99,
+ * ThreadGroup=>1, Binding=>1, Thread=>1, RubyVM=>1, :iseq=>1,
+ * Random=>1, ARGF.class=>1, Data=>1, :autoload=>3, Time=>2}
+ * # T_DATA objects existing at startup on r32276.
+ *
+ * If the optional argument, result_hash, is given, it is overwritten and
+ * returned. This is intended to avoid probe effect.
+ *
+ * The contents of the returned hash is implementation specific and may change
+ * in the future.
+ *
+ * In this version, keys are Class object or Symbol object.
+ *
+ * If object is kind of normal (accessible) object, the key is Class object.
+ * If object is not a kind of normal (internal) object, the key is symbol
+ * name, registered by rb_data_type_struct.
+ *
+ * This method is only expected to work with C Ruby.
+ */
+
+static VALUE
+count_tdata_objects(int argc, VALUE *argv, VALUE self)
+{
+ VALUE hash;
+
+ if (rb_scan_args(argc, argv, "01", &hash) == 1) {
+ if (!RB_TYPE_P(hash, T_HASH))
+ rb_raise(rb_eTypeError, "non-hash given");
+ }
+
+ if (hash == Qnil) {
+ hash = rb_hash_new();
+ }
+ else if (!RHASH_EMPTY_P(hash)) {
+ st_foreach(RHASH_TBL(hash), set_zero_i, hash);
+ }
+
+ rb_objspace_each_objects(cto_i, (void *)hash);
+
+ return hash;
+}
+
+static void
+iow_mark(void *ptr)
+{
+ rb_gc_mark((VALUE)ptr);
+}
+
+static size_t
+iow_size(const void *ptr)
+{
+ VALUE obj = (VALUE)ptr;
+ return rb_obj_memsize_of(obj);
+}
+
+static const rb_data_type_t iow_data_type = {
+ "ObjectSpace::InternalObjectWrapper",
+ {iow_mark, 0, iow_size,},
+ 0, 0, RUBY_TYPED_FREE_IMMEDIATELY
+};
+
+static VALUE rb_mInternalObjectWrapper;
+
+static VALUE
+iow_newobj(VALUE obj)
+{
+ return rb_data_typed_object_alloc(rb_mInternalObjectWrapper, (void *)obj, &iow_data_type);
+}
+
+/* Returns the type of the internal object. */
+static VALUE
+iow_type(VALUE self)
+{
+ VALUE obj = (VALUE)DATA_PTR(self);
+ return type2sym(BUILTIN_TYPE(obj));
+}
+
+/* See Object#inspect. */
+static VALUE
+iow_inspect(VALUE self)
+{
+ VALUE obj = (VALUE)DATA_PTR(self);
+ VALUE type = type2sym(BUILTIN_TYPE(obj));
+
+ return rb_sprintf("#<InternalObject:%p %"PRIsVALUE">", (void *)obj, rb_sym2str(type));
+}
+
+/* Returns the Object#object_id of the internal object. */
+static VALUE
+iow_internal_object_id(VALUE self)
+{
+ VALUE obj = (VALUE)DATA_PTR(self);
+ return rb_obj_id(obj);
+}
+
+struct rof_data {
+ st_table *refs;
+ VALUE internals;
+};
+
+static void
+reachable_object_from_i(VALUE obj, void *data_ptr)
+{
+ struct rof_data *data = (struct rof_data *)data_ptr;
+ VALUE key = obj;
+ VALUE val = obj;
+
+ if (rb_objspace_markable_object_p(obj)) {
+ if (rb_objspace_internal_object_p(obj)) {
+ val = iow_newobj(obj);
+ rb_ary_push(data->internals, val);
+ }
+ st_insert(data->refs, key, val);
+ }
+}
+
+static int
+collect_values(st_data_t key, st_data_t value, st_data_t data)
+{
+ VALUE ary = (VALUE)data;
+ rb_ary_push(ary, (VALUE)value);
+ return ST_CONTINUE;
+}
+
+/*
+ * call-seq:
+ * ObjectSpace.reachable_objects_from(obj) -> array or nil
+ *
+ * [MRI specific feature] Return all reachable objects from `obj'.
+ *
+ * This method returns all reachable objects from `obj'.
+ *
+ * If `obj' has two or more references to the same object `x', then returned
+ * array only includes one `x' object.
+ *
+ * If `obj' is a non-markable (non-heap management) object such as true,
+ * false, nil, symbols and Fixnums (and Flonum) then it simply returns nil.
+ *
+ * If `obj' has references to an internal object, then it returns instances of
+ * ObjectSpace::InternalObjectWrapper class. This object contains a reference
+ * to an internal object and you can check the type of internal object with
+ * `type' method.
+ *
+ * If `obj' is instance of ObjectSpace::InternalObjectWrapper class, then this
+ * method returns all reachable object from an internal object, which is
+ * pointed by `obj'.
+ *
+ * With this method, you can find memory leaks.
+ *
+ * This method is only expected to work except with C Ruby.
+ *
+ * Example:
+ * ObjectSpace.reachable_objects_from(['a', 'b', 'c'])
+ * #=> [Array, 'a', 'b', 'c']
+ *
+ * ObjectSpace.reachable_objects_from(['a', 'a', 'a'])
+ * #=> [Array, 'a', 'a', 'a'] # all 'a' strings have different object id
+ *
+ * ObjectSpace.reachable_objects_from([v = 'a', v, v])
+ * #=> [Array, 'a']
+ *
+ * ObjectSpace.reachable_objects_from(1)
+ * #=> nil # 1 is not markable (heap managed) object
+ *
+ */
+
+static VALUE
+reachable_objects_from(VALUE self, VALUE obj)
+{
+ if (rb_objspace_markable_object_p(obj)) {
+ VALUE ret = rb_ary_new();
+ struct rof_data data;
+
+ if (rb_typeddata_is_kind_of(obj, &iow_data_type)) {
+ obj = (VALUE)DATA_PTR(obj);
+ }
+
+ data.refs = st_init_numtable();
+ data.internals = rb_ary_new();
+
+ rb_objspace_reachable_objects_from(obj, reachable_object_from_i, &data);
+
+ st_foreach(data.refs, collect_values, (st_data_t)ret);
+ return ret;
+ }
+ else {
+ return Qnil;
+ }
+}
+
+struct rofr_data {
+ VALUE categories;
+ const char *last_category;
+ VALUE last_category_str;
+ VALUE last_category_objects;
+};
+
+static void
+reachable_object_from_root_i(const char *category, VALUE obj, void *ptr)
+{
+ struct rofr_data *data = (struct rofr_data *)ptr;
+ VALUE category_str;
+ VALUE category_objects;
+
+ if (category == data->last_category) {
+ category_str = data->last_category_str;
+ category_objects = data->last_category_objects;
+ }
+ else {
+ data->last_category = category;
+ category_str = data->last_category_str = rb_str_new2(category);
+ category_objects = data->last_category_objects = rb_hash_new();
+ rb_funcall(category_objects, rb_intern("compare_by_identity"), 0);
+ if (!NIL_P(rb_hash_lookup(data->categories, category_str))) {
+ rb_bug("reachable_object_from_root_i: category should insert at once");
+ }
+ rb_hash_aset(data->categories, category_str, category_objects);
+ }
+
+ if (rb_objspace_markable_object_p(obj) &&
+ obj != data->categories &&
+ obj != data->last_category_objects) {
+ if (rb_objspace_internal_object_p(obj)) {
+ obj = iow_newobj(obj);
+ }
+ rb_hash_aset(category_objects, obj, obj);
+ }
+}
+
+static int
+collect_values_of_values(VALUE category, VALUE category_objects, VALUE categories)
+{
+ VALUE ary = rb_ary_new();
+ st_foreach(rb_hash_tbl(category_objects), collect_values, ary);
+ rb_hash_aset(categories, category, ary);
+ return ST_CONTINUE;
+}
+
+/*
+ * call-seq:
+ * ObjectSpace.reachable_objects_from_root -> hash
+ *
+ * [MRI specific feature] Return all reachable objects from root.
+ */
+static VALUE
+reachable_objects_from_root(VALUE self)
+{
+ struct rofr_data data;
+ VALUE hash = data.categories = rb_hash_new();
+ data.last_category = 0;
+
+ rb_funcall(hash, rb_intern("compare_by_identity"), 0);
+ rb_objspace_reachable_objects_from_root(reachable_object_from_root_i, &data);
+ rb_hash_foreach(hash, collect_values_of_values, hash);
+
+ return hash;
+}
+
+void Init_object_tracing(VALUE rb_mObjSpace);
+void Init_objspace_dump(VALUE rb_mObjSpace);
+
+/*
+ * Document-module: ObjectSpace
+ *
+ * The objspace library extends the ObjectSpace module and adds several
+ * methods to get internal statistic information about
+ * object/memory management.
+ *
+ * You need to <code>require 'objspace'</code> to use this extension module.
+ *
+ * Generally, you *SHOULD NOT* use this library if you do not know
+ * about the MRI implementation. Mainly, this library is for (memory)
+ * profiler developers and MRI developers who need to know about MRI
+ * memory usage.
+ */
+
+void
+Init_objspace(void)
+{
+ VALUE rb_mObjSpace;
+#if 0
+ rb_mObjSpace = rb_define_module("ObjectSpace"); /* let rdoc know */
+#endif
+ rb_mObjSpace = rb_const_get(rb_cObject, rb_intern("ObjectSpace"));
+
+ rb_define_module_function(rb_mObjSpace, "memsize_of", memsize_of_m, 1);
+ rb_define_module_function(rb_mObjSpace, "memsize_of_all", memsize_of_all_m, -1);
+
+ rb_define_module_function(rb_mObjSpace, "count_objects_size", count_objects_size, -1);
+ rb_define_module_function(rb_mObjSpace, "count_nodes", count_nodes, -1);
+ rb_define_module_function(rb_mObjSpace, "count_tdata_objects", count_tdata_objects, -1);
+
+ rb_define_module_function(rb_mObjSpace, "reachable_objects_from", reachable_objects_from, 1);
+ rb_define_module_function(rb_mObjSpace, "reachable_objects_from_root", reachable_objects_from_root, 0);
+
+ /*
+ * This class is used as a return value from
+ * ObjectSpace::reachable_objects_from.
+ *
+ * When ObjectSpace::reachable_objects_from returns an object with
+ * references to an internal object, an instance of this class is returned.
+ *
+ * You can use the #type method to check the type of the internal object.
+ */
+ rb_mInternalObjectWrapper = rb_define_class_under(rb_mObjSpace, "InternalObjectWrapper", rb_cObject);
+ rb_define_method(rb_mInternalObjectWrapper, "type", iow_type, 0);
+ rb_define_method(rb_mInternalObjectWrapper, "inspect", iow_inspect, 0);
+ rb_define_method(rb_mInternalObjectWrapper, "internal_object_id", iow_internal_object_id, 0);
+
+ Init_object_tracing(rb_mObjSpace);
+ Init_objspace_dump(rb_mObjSpace);
+}
diff --git a/jni/ruby/ext/objspace/objspace.h b/jni/ruby/ext/objspace/objspace.h
new file mode 100644
index 0000000..95b84d6
--- /dev/null
+++ b/jni/ruby/ext/objspace/objspace.h
@@ -0,0 +1,20 @@
+#ifndef OBJSPACE_H
+#define OBJSPACE_H 1
+
+/* object_tracing.c */
+struct allocation_info {
+ /* all of information don't need marking. */
+ int living;
+ VALUE flags;
+ VALUE klass;
+
+ /* allocation info */
+ const char *path;
+ unsigned long line;
+ const char *class_path;
+ VALUE mid;
+ size_t generation;
+};
+struct allocation_info *objspace_lookup_allocation_info(VALUE obj);
+
+#endif
diff --git a/jni/ruby/ext/objspace/objspace_dump.c b/jni/ruby/ext/objspace/objspace_dump.c
new file mode 100644
index 0000000..b6973df
--- /dev/null
+++ b/jni/ruby/ext/objspace/objspace_dump.c
@@ -0,0 +1,434 @@
+/**********************************************************************
+
+ objspace_dump.c - Heap dumping ObjectSpace extender for MRI.
+
+ $Author$
+ created at: Sat Oct 11 10:11:00 2013
+
+ NOTE: This extension library is not expected to exist except C Ruby.
+
+ All the files in this distribution are covered under the Ruby's
+ license (see the file COPYING).
+
+**********************************************************************/
+
+#include "internal.h"
+#include "ruby/debug.h"
+#include "ruby/io.h"
+#include "gc.h"
+#include "node.h"
+#include "vm_core.h"
+#include "objspace.h"
+
+static VALUE sym_output, sym_stdout, sym_string, sym_file;
+
+struct dump_config {
+ VALUE type;
+ FILE *stream;
+ VALUE string;
+ int roots;
+ const char *root_category;
+ VALUE cur_obj;
+ VALUE cur_obj_klass;
+ size_t cur_obj_references;
+};
+
+static void
+dump_append(struct dump_config *dc, const char *format, ...)
+{
+ va_list vl;
+ va_start(vl, format);
+
+ if (dc->stream) {
+ vfprintf(dc->stream, format, vl);
+ }
+ else if (dc->string)
+ rb_str_vcatf(dc->string, format, vl);
+
+ va_end(vl);
+}
+
+static void
+dump_append_string_value(struct dump_config *dc, VALUE obj)
+{
+ int i;
+ char c, *value;
+
+ dump_append(dc, "\"");
+ for (i = 0, value = RSTRING_PTR(obj); i < RSTRING_LEN(obj); i++) {
+ switch ((c = value[i])) {
+ case '\\':
+ case '"':
+ dump_append(dc, "\\%c", c);
+ break;
+ case '\0':
+ dump_append(dc, "\\u0000");
+ break;
+ case '\b':
+ dump_append(dc, "\\b");
+ break;
+ case '\t':
+ dump_append(dc, "\\t");
+ break;
+ case '\f':
+ dump_append(dc, "\\f");
+ break;
+ case '\n':
+ dump_append(dc, "\\n");
+ break;
+ case '\r':
+ dump_append(dc, "\\r");
+ break;
+ default:
+ if (c <= 0x1f)
+ dump_append(dc, "\\u%04d", c);
+ else
+ dump_append(dc, "%c", c);
+ }
+ }
+ dump_append(dc, "\"");
+}
+
+static inline const char *
+obj_type(VALUE obj)
+{
+ switch (BUILTIN_TYPE(obj)) {
+#define CASE_TYPE(type) case T_##type: return #type; break
+ CASE_TYPE(NONE);
+ CASE_TYPE(NIL);
+ CASE_TYPE(OBJECT);
+ CASE_TYPE(CLASS);
+ CASE_TYPE(ICLASS);
+ CASE_TYPE(MODULE);
+ CASE_TYPE(FLOAT);
+ CASE_TYPE(STRING);
+ CASE_TYPE(REGEXP);
+ CASE_TYPE(ARRAY);
+ CASE_TYPE(HASH);
+ CASE_TYPE(STRUCT);
+ CASE_TYPE(BIGNUM);
+ CASE_TYPE(FILE);
+ CASE_TYPE(FIXNUM);
+ CASE_TYPE(TRUE);
+ CASE_TYPE(FALSE);
+ CASE_TYPE(DATA);
+ CASE_TYPE(MATCH);
+ CASE_TYPE(SYMBOL);
+ CASE_TYPE(RATIONAL);
+ CASE_TYPE(COMPLEX);
+ CASE_TYPE(UNDEF);
+ CASE_TYPE(NODE);
+ CASE_TYPE(ZOMBIE);
+#undef CASE_TYPE
+ }
+ return "UNKNOWN";
+}
+
+static void
+reachable_object_i(VALUE ref, void *data)
+{
+ struct dump_config *dc = (struct dump_config *)data;
+
+ if (dc->cur_obj_klass == ref)
+ return;
+
+ if (dc->cur_obj_references == 0)
+ dump_append(dc, ", \"references\":[\"%p\"", (void *)ref);
+ else
+ dump_append(dc, ", \"%p\"", (void *)ref);
+
+ dc->cur_obj_references++;
+}
+
+static void
+dump_object(VALUE obj, struct dump_config *dc)
+{
+ size_t memsize;
+ struct allocation_info *ainfo;
+ rb_io_t *fptr;
+ ID flags[RB_OBJ_GC_FLAGS_MAX];
+ size_t n, i;
+
+ if (SPECIAL_CONST_P(obj)) {
+ dump_append(dc, "{}");
+ return;
+ }
+
+ dc->cur_obj = obj;
+ dc->cur_obj_references = 0;
+ dc->cur_obj_klass = BUILTIN_TYPE(obj) == T_NODE ? 0 : RBASIC_CLASS(obj);
+
+ if (dc->cur_obj == dc->string)
+ return;
+
+ dump_append(dc, "{\"address\":\"%p\", \"type\":\"%s\"", (void *)obj, obj_type(obj));
+
+ if (dc->cur_obj_klass)
+ dump_append(dc, ", \"class\":\"%p\"", (void *)dc->cur_obj_klass);
+ if (rb_obj_frozen_p(obj))
+ dump_append(dc, ", \"frozen\":true");
+
+ switch (BUILTIN_TYPE(obj)) {
+ case T_NODE:
+ dump_append(dc, ", \"node_type\":\"%s\"", ruby_node_name(nd_type(obj)));
+ break;
+
+ case T_STRING:
+ if (STR_EMBED_P(obj))
+ dump_append(dc, ", \"embedded\":true");
+ if (is_broken_string(obj))
+ dump_append(dc, ", \"broken\":true");
+ if (FL_TEST(obj, RSTRING_FSTR))
+ dump_append(dc, ", \"fstring\":true");
+ if (STR_SHARED_P(obj))
+ dump_append(dc, ", \"shared\":true");
+ else {
+ dump_append(dc, ", \"bytesize\":%ld", RSTRING_LEN(obj));
+ if (!STR_EMBED_P(obj) && !STR_SHARED_P(obj) && (long)rb_str_capacity(obj) != RSTRING_LEN(obj))
+ dump_append(dc, ", \"capacity\":%ld", rb_str_capacity(obj));
+
+ if (is_ascii_string(obj)) {
+ dump_append(dc, ", \"value\":");
+ dump_append_string_value(dc, obj);
+ }
+ }
+
+ if (!ENCODING_IS_ASCII8BIT(obj))
+ dump_append(dc, ", \"encoding\":\"%s\"", rb_enc_name(rb_enc_from_index(ENCODING_GET(obj))));
+ break;
+
+ case T_HASH:
+ dump_append(dc, ", \"size\":%ld", RHASH_SIZE(obj));
+ if (FL_TEST(obj, HASH_PROC_DEFAULT))
+ dump_append(dc, ", \"default\":\"%p\"", (void *)RHASH_IFNONE(obj));
+ break;
+
+ case T_ARRAY:
+ dump_append(dc, ", \"length\":%ld", RARRAY_LEN(obj));
+ if (RARRAY_LEN(obj) > 0 && FL_TEST(obj, ELTS_SHARED))
+ dump_append(dc, ", \"shared\":true");
+ if (RARRAY_LEN(obj) > 0 && FL_TEST(obj, RARRAY_EMBED_FLAG))
+ dump_append(dc, ", \"embedded\":true");
+ break;
+
+ case T_CLASS:
+ case T_MODULE:
+ if (dc->cur_obj_klass)
+ dump_append(dc, ", \"name\":\"%s\"", rb_class2name(obj));
+ break;
+
+ case T_DATA:
+ if (RTYPEDDATA_P(obj))
+ dump_append(dc, ", \"struct\":\"%s\"", RTYPEDDATA_TYPE(obj)->wrap_struct_name);
+ break;
+
+ case T_FLOAT:
+ dump_append(dc, ", \"value\":\"%g\"", RFLOAT_VALUE(obj));
+ break;
+
+ case T_OBJECT:
+ dump_append(dc, ", \"ivars\":%ld", ROBJECT_NUMIV(obj));
+ break;
+
+ case T_FILE:
+ fptr = RFILE(obj)->fptr;
+ if (fptr)
+ dump_append(dc, ", \"fd\":%d", fptr->fd);
+ break;
+
+ case T_ZOMBIE:
+ dump_append(dc, "}\n");
+ return;
+ }
+
+ rb_objspace_reachable_objects_from(obj, reachable_object_i, dc);
+ if (dc->cur_obj_references > 0)
+ dump_append(dc, "]");
+
+ if ((ainfo = objspace_lookup_allocation_info(obj))) {
+ dump_append(dc, ", \"file\":\"%s\", \"line\":%lu", ainfo->path, ainfo->line);
+ if (RTEST(ainfo->mid)) {
+ VALUE m = rb_sym2str(ainfo->mid);
+ dump_append(dc, ", \"method\":\"%s\"", RSTRING_PTR(m));
+ }
+ dump_append(dc, ", \"generation\":%"PRIuSIZE, ainfo->generation);
+ }
+
+ if ((memsize = rb_obj_memsize_of(obj)) > 0)
+ dump_append(dc, ", \"memsize\":%"PRIuSIZE, memsize);
+
+ if ((n = rb_obj_gc_flags(obj, flags, sizeof(flags))) > 0) {
+ dump_append(dc, ", \"flags\":{");
+ for (i=0; i<n; i++) {
+ dump_append(dc, "\"%s\":true", rb_id2name(flags[i]));
+ if (i != n-1) dump_append(dc, ", ");
+ }
+ dump_append(dc, "}");
+ }
+
+ dump_append(dc, "}\n");
+}
+
+static int
+heap_i(void *vstart, void *vend, size_t stride, void *data)
+{
+ VALUE v = (VALUE)vstart;
+ for (; v != (VALUE)vend; v += stride) {
+ if (RBASIC(v)->flags)
+ dump_object(v, data);
+ }
+ return 0;
+}
+
+static void
+root_obj_i(const char *category, VALUE obj, void *data)
+{
+ struct dump_config *dc = (struct dump_config *)data;
+
+ if (dc->root_category != NULL && category != dc->root_category)
+ dump_append(dc, "]}\n");
+ if (dc->root_category == NULL || category != dc->root_category)
+ dump_append(dc, "{\"type\":\"ROOT\", \"root\":\"%s\", \"references\":[\"%p\"", category, (void *)obj);
+ else
+ dump_append(dc, ", \"%p\"", (void *)obj);
+
+ dc->root_category = category;
+ dc->roots++;
+}
+
+static VALUE
+dump_output(struct dump_config *dc, VALUE opts, VALUE output, const char *filename)
+{
+ VALUE tmp;
+
+ if (RTEST(opts))
+ output = rb_hash_aref(opts, sym_output);
+
+ if (output == sym_stdout) {
+ dc->stream = stdout;
+ dc->string = Qnil;
+ }
+ else if (output == sym_file) {
+ rb_io_t *fptr;
+ rb_require("tempfile");
+ tmp = rb_assoc_new(rb_str_new_cstr(filename), rb_str_new_cstr(".json"));
+ tmp = rb_funcallv(rb_path2class("Tempfile"), rb_intern("create"), 1, &tmp);
+ io:
+ dc->string = rb_io_get_write_io(tmp);
+ rb_io_flush(dc->string);
+ GetOpenFile(dc->string, fptr);
+ dc->stream = rb_io_stdio_file(fptr);
+ }
+ else if (output == sym_string) {
+ dc->string = rb_str_new_cstr("");
+ }
+ else if (!NIL_P(tmp = rb_io_check_io(output))) {
+ output = sym_file;
+ goto io;
+ }
+ else {
+ rb_raise(rb_eArgError, "wrong output option: %"PRIsVALUE, output);
+ }
+ return output;
+}
+
+static VALUE
+dump_result(struct dump_config *dc, VALUE output)
+{
+ if (output == sym_string) {
+ return dc->string;
+ }
+ else if (output == sym_file) {
+ rb_io_flush(dc->string);
+ return dc->string;
+ }
+ else {
+ return Qnil;
+ }
+}
+
+/*
+ * call-seq:
+ * ObjectSpace.dump(obj[, output: :string]) # => "{ ... }"
+ * ObjectSpace.dump(obj, output: :file) # => #<File:/tmp/rubyobj20131125-88733-1xkfmpv.json>
+ * ObjectSpace.dump(obj, output: :stdout) # => nil
+ *
+ * Dump the contents of a ruby object as JSON.
+ *
+ * This method is only expected to work with C Ruby.
+ * This is an experimental method and is subject to change.
+ * In particular, the function signature and output format are
+ * not guaranteed to be compatible in future versions of ruby.
+ */
+
+static VALUE
+objspace_dump(int argc, VALUE *argv, VALUE os)
+{
+ static const char filename[] = "rubyobj";
+ VALUE obj = Qnil, opts = Qnil, output;
+ struct dump_config dc = {0,};
+
+ rb_scan_args(argc, argv, "1:", &obj, &opts);
+
+ output = dump_output(&dc, opts, sym_string, filename);
+
+ dump_object(obj, &dc);
+
+ return dump_result(&dc, output);
+}
+
+/*
+ * call-seq:
+ * ObjectSpace.dump_all([output: :file]) # => #<File:/tmp/rubyheap20131125-88469-laoj3v.json>
+ * ObjectSpace.dump_all(output: :stdout) # => nil
+ * ObjectSpace.dump_all(output: :string) # => "{...}\n{...}\n..."
+ * ObjectSpace.dump_all(output:
+ * File.open('heap.json','w')) # => #<File:heap.json>
+ *
+ * Dump the contents of the ruby heap as JSON.
+ *
+ * This method is only expected to work with C Ruby.
+ * This is an experimental method and is subject to change.
+ * In particular, the function signature and output format are
+ * not guaranteed to be compatible in future versions of ruby.
+ */
+
+static VALUE
+objspace_dump_all(int argc, VALUE *argv, VALUE os)
+{
+ static const char filename[] = "rubyheap";
+ VALUE opts = Qnil, output;
+ struct dump_config dc = {0,};
+
+ rb_scan_args(argc, argv, "0:", &opts);
+
+ output = dump_output(&dc, opts, sym_file, filename);
+
+ /* dump roots */
+ rb_objspace_reachable_objects_from_root(root_obj_i, &dc);
+ if (dc.roots) dump_append(&dc, "]}\n");
+
+ /* dump all objects */
+ rb_objspace_each_objects(heap_i, &dc);
+
+ return dump_result(&dc, output);
+}
+
+void
+Init_objspace_dump(VALUE rb_mObjSpace)
+{
+#if 0
+ rb_mObjSpace = rb_define_module("ObjectSpace"); /* let rdoc know */
+#endif
+
+ rb_define_module_function(rb_mObjSpace, "dump", objspace_dump, -1);
+ rb_define_module_function(rb_mObjSpace, "dump_all", objspace_dump_all, -1);
+
+ sym_output = ID2SYM(rb_intern("output"));
+ sym_stdout = ID2SYM(rb_intern("stdout"));
+ sym_string = ID2SYM(rb_intern("string"));
+ sym_file = ID2SYM(rb_intern("file"));
+
+ /* force create static IDs */
+ rb_obj_gc_flags(rb_mObjSpace, 0, 0);
+}
diff --git a/jni/ruby/ext/openssl/Makefile b/jni/ruby/ext/openssl/Makefile
new file mode 100644
index 0000000..891dc52
--- /dev/null
+++ b/jni/ruby/ext/openssl/Makefile
@@ -0,0 +1,1412 @@
+
+SHELL = /bin/sh
+
+# V=0 quiet, V=1 verbose. other values don't work.
+V = 0
+Q1 = $(V:1=)
+Q = $(Q1:0=@)
+ECHO1 = $(V:1=@:)
+ECHO = $(ECHO1:0=@echo)
+NULLCMD = :
+
+#### Start of system configuration section. ####
+top_srcdir = $(topdir)/.
+srcdir = $(top_srcdir)/ext/openssl
+topdir = ../..
+hdrdir = $(top_srcdir)/include
+arch_hdrdir = $(extout)/include/$(arch)
+PATH_SEPARATOR = :
+VPATH = $(srcdir):$(arch_hdrdir)/ruby:$(hdrdir)/ruby
+RUBYLIB =
+RUBYOPT = -
+prefix = $(DESTDIR)/usr/local
+rubysitearchprefix = $(rubylibprefix)/$(sitearch)
+rubyarchprefix = $(rubylibprefix)/$(arch)
+rubylibprefix = $(libdir)/$(RUBY_BASE_NAME)
+exec_prefix = $(prefix)
+vendorarchhdrdir = $(vendorhdrdir)/$(sitearch)
+sitearchhdrdir = $(sitehdrdir)/$(sitearch)
+rubyarchhdrdir = $(rubyhdrdir)/$(arch)
+vendorhdrdir = $(rubyhdrdir)/vendor_ruby
+sitehdrdir = $(rubyhdrdir)/site_ruby
+rubyhdrdir = $(includedir)/$(RUBY_VERSION_NAME)
+vendorarchdir = $(vendorlibdir)/$(sitearch)
+vendorlibdir = $(vendordir)/$(ruby_version)
+vendordir = $(rubylibprefix)/vendor_ruby
+sitearchdir = $(sitelibdir)/$(sitearch)
+sitelibdir = $(sitedir)/$(ruby_version)
+sitedir = $(rubylibprefix)/site_ruby
+rubyarchdir = $(rubylibdir)/$(arch)
+rubylibdir = $(rubylibprefix)/$(ruby_version)
+sitearchincludedir = $(includedir)/$(sitearch)
+archincludedir = $(includedir)/$(arch)
+sitearchlibdir = $(libdir)/$(sitearch)
+archlibdir = $(libdir)/$(arch)
+ridir = $(datarootdir)/$(RI_BASE_NAME)
+mandir = $(datarootdir)/man
+localedir = $(datarootdir)/locale
+libdir = $(exec_prefix)/lib
+psdir = $(docdir)
+pdfdir = $(docdir)
+dvidir = $(docdir)
+htmldir = $(docdir)
+infodir = $(datarootdir)/info
+docdir = $(datarootdir)/doc/$(PACKAGE)
+oldincludedir = $(DESTDIR)/usr/include
+includedir = $(prefix)/include
+localstatedir = $(prefix)/var
+sharedstatedir = $(prefix)/com
+sysconfdir = $(prefix)/etc
+datadir = $(datarootdir)
+datarootdir = $(prefix)/share
+libexecdir = $(exec_prefix)/libexec
+sbindir = $(exec_prefix)/sbin
+bindir = $(exec_prefix)/bin
+archdir = $(rubyarchdir)
+
+
+CC = gcc
+CXX = g++
+LIBRUBY = $(LIBRUBY_SO)
+LIBRUBY_A = lib$(RUBY_SO_NAME)-static.a
+LIBRUBYARG_SHARED = -Wl,-R$(libdir) -L$(libdir) -l$(RUBY_SO_NAME)
+LIBRUBYARG_STATIC = -Wl,-R$(libdir) -L$(libdir) -l$(RUBY_SO_NAME)-static
+empty =
+OUTFLAG = -o $(empty)
+COUTFLAG = -o $(empty)
+
+RUBY_EXTCONF_H = extconf.h
+cflags = $(optflags) $(debugflags) $(warnflags)
+optflags = -O3 -fno-fast-math
+debugflags = -ggdb3
+warnflags = -Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wunused-variable -Wpointer-arith -Wwrite-strings -Wdeclaration-after-statement -Wimplicit-function-declaration -Wdeprecated-declarations -Wno-packed-bitfield-compat
+CCDLFLAGS = -fPIC
+CFLAGS = $(CCDLFLAGS) $(cflags) -fPIC $(ARCH_FLAG)
+INCFLAGS = -I. -I$(arch_hdrdir) -I$(hdrdir) -I$(srcdir)
+DEFS =
+CPPFLAGS = -DRUBY_EXTCONF_H=\"$(RUBY_EXTCONF_H)\" $(DEFS) $(cppflags)
+CXXFLAGS = $(CCDLFLAGS) $(cxxflags) $(ARCH_FLAG)
+ldflags = -L. -fstack-protector -rdynamic -Wl,-export-dynamic
+dldflags =
+ARCH_FLAG =
+DLDFLAGS = $(ldflags) $(dldflags) $(ARCH_FLAG)
+LDSHARED = $(CC) -shared
+LDSHAREDXX = $(CXX) -shared
+AR = ar
+EXEEXT =
+
+RUBY_INSTALL_NAME = $(RUBY_BASE_NAME)
+RUBY_SO_NAME = ruby
+RUBYW_INSTALL_NAME =
+RUBY_VERSION_NAME = $(RUBY_BASE_NAME)-$(ruby_version)
+RUBYW_BASE_NAME = rubyw
+RUBY_BASE_NAME = ruby
+
+arch = x86_64-linux
+sitearch = $(arch)
+ruby_version = 2.2.0
+ruby = $(topdir)/miniruby -I'$(topdir)' -I'$(top_srcdir)/lib' -I'$(extout)/$(arch)' -I'$(extout)/common'
+RUBY = $(ruby)
+ruby_headers = $(hdrdir)/ruby.h $(hdrdir)/ruby/ruby.h $(hdrdir)/ruby/defines.h $(hdrdir)/ruby/missing.h $(hdrdir)/ruby/intern.h $(hdrdir)/ruby/st.h $(hdrdir)/ruby/subst.h $(arch_hdrdir)/ruby/config.h $(RUBY_EXTCONF_H)
+
+RM = rm -f
+RM_RF = $(RUBY) -run -e rm -- -rf
+RMDIRS = rmdir --ignore-fail-on-non-empty -p
+MAKEDIRS = /bin/mkdir -p
+INSTALL = /usr/bin/install -c
+INSTALL_PROG = $(INSTALL) -m 0755
+INSTALL_DATA = $(INSTALL) -m 644
+COPY = cp
+TOUCH = exit >
+
+#### End of system configuration section. ####
+
+preload =
+THREAD_MODEL = pthread
+
+libpath = . $(topdir)
+LIBPATH = -L. -L$(topdir)
+DEFFILE =
+
+CLEANFILES = mkmf.log
+DISTCLEANFILES =
+DISTCLEANDIRS =
+
+extout = $(topdir)/.ext
+extout_prefix = $(extout)$(target_prefix)/
+target_prefix =
+LOCAL_LIBS =
+LIBS = $(LIBRUBYARG_SHARED) -lssl -lcrypto -lpthread -lgmp -ldl -lcrypt -lm -lc
+ORIG_SRCS = ossl_pkey_ec.c ossl_digest.c ossl_bio.c ossl_pkcs7.c ossl_ocsp.c ossl_x509.c ossl_x509ext.c ossl_x509name.c ossl_x509revoked.c ossl_pkey_dsa.c ossl_rand.c ossl_pkcs12.c ossl_x509store.c ossl_engine.c ossl_ns_spki.c ossl_pkey.c ossl_pkcs5.c ossl.c ossl_asn1.c ossl_x509attr.c ossl_cipher.c ossl_x509crl.c ossl_x509req.c ossl_pkey_dh.c ossl_hmac.c ossl_x509cert.c ossl_config.c ossl_ssl_session.c openssl_missing.c ossl_ssl.c ossl_pkey_rsa.c ossl_bn.c
+SRCS = $(ORIG_SRCS)
+OBJS = ossl_pkey_ec.o ossl_digest.o ossl_bio.o ossl_pkcs7.o ossl_ocsp.o ossl_x509.o ossl_x509ext.o ossl_x509name.o ossl_x509revoked.o ossl_pkey_dsa.o ossl_rand.o ossl_pkcs12.o ossl_x509store.o ossl_engine.o ossl_ns_spki.o ossl_pkey.o ossl_pkcs5.o ossl.o ossl_asn1.o ossl_x509attr.o ossl_cipher.o ossl_x509crl.o ossl_x509req.o ossl_pkey_dh.o ossl_hmac.o ossl_x509cert.o ossl_config.o ossl_ssl_session.o openssl_missing.o ossl_ssl.o ossl_pkey_rsa.o ossl_bn.o
+HDRS = $(srcdir)/ossl_version.h $(srcdir)/ossl_engine.h $(srcdir)/ossl_ssl.h $(srcdir)/ruby_missing.h $(srcdir)/ossl_hmac.h $(srcdir)/ossl_pkcs7.h $(srcdir)/ossl_bio.h $(srcdir)/ossl_asn1.h $(srcdir)/extconf.h $(srcdir)/ossl_ns_spki.h $(srcdir)/ossl_cipher.h $(srcdir)/ossl_pkey.h $(srcdir)/ossl_rand.h $(srcdir)/openssl_missing.h $(srcdir)/ossl_x509.h $(srcdir)/ossl_pkcs12.h $(srcdir)/ossl_bn.h $(srcdir)/ossl_ocsp.h $(srcdir)/ossl_config.h $(srcdir)/ossl.h $(srcdir)/ossl_pkcs5.h $(srcdir)/ossl_digest.h
+TARGET = openssl
+TARGET_NAME = openssl
+TARGET_ENTRY = Init_$(TARGET_NAME)
+DLLIB = $(TARGET).so
+EXTSTATIC =
+STATIC_LIB = $(TARGET).a
+
+TIMESTAMP_DIR = $(extout)/.timestamp
+BINDIR = $(extout)/bin
+RUBYCOMMONDIR = $(extout)/common
+RUBYLIBDIR = $(RUBYCOMMONDIR)$(target_prefix)
+RUBYARCHDIR = $(extout)/$(arch)$(target_prefix)
+HDRDIR = $(extout)/include/ruby$(target_prefix)
+ARCHHDRDIR = $(extout)/include/$(arch)/ruby$(target_prefix)
+
+TARGET_SO = $(RUBYARCHDIR)/$(DLLIB)
+CLEANLIBS = $(RUBYARCHDIR)/$(TARGET).so
+CLEANOBJS = *.o *.bak
+
+all: install
+static: all
+.PHONY: all install static install-so install-rb
+.PHONY: clean clean-so clean-static clean-rb
+
+clean-static::
+clean-rb-default::
+clean-rb::
+clean-so::
+clean: clean-so clean-static clean-rb-default clean-rb
+ -$(Q)$(RM) $(CLEANLIBS) $(CLEANOBJS) $(CLEANFILES) .*.time
+
+distclean-rb-default::
+distclean-rb::
+distclean-so::
+distclean-static::
+distclean: clean distclean-so distclean-static distclean-rb-default distclean-rb
+ -$(Q)$(RM) Makefile $(RUBY_EXTCONF_H) conftest.* mkmf.log
+ -$(Q)$(RM) core ruby$(EXEEXT) *~ $(DISTCLEANFILES)
+ -$(Q)$(RMDIRS) $(DISTCLEANDIRS) 2> /dev/null || true
+
+realclean: distclean
+install: install-so install-rb
+
+install-so: $(RUBYARCHDIR)/$(DLLIB)
+clean-so::
+ -$(Q)$(RM) $(RUBYARCHDIR)/$(DLLIB)
+ -$(Q)$(RMDIRS) $(RUBYARCHDIR) 2> /dev/null || true
+clean-static::
+ -$(Q)$(RM) $(STATIC_LIB)
+install-rb: pre-install-rb install-rb-default
+install-rb-default: pre-install-rb-default
+pre-install-rb: Makefile
+pre-install-rb-default: Makefile
+pre-install-rb-default: $(TIMESTAMP_DIR)/.RUBYLIBDIR.time
+install-rb-default: $(RUBYLIBDIR)/openssl.rb
+$(RUBYLIBDIR)/openssl.rb: $(srcdir)/lib/openssl.rb $(TIMESTAMP_DIR)/.RUBYLIBDIR.time
+ $(Q) $(COPY) $(srcdir)/lib/openssl.rb $(@D)
+clean-rb-default::
+ -$(Q)$(RM) $(RUBYLIBDIR)/openssl.rb
+pre-install-rb-default: $(TIMESTAMP_DIR)/.RUBYLIBDIR.-.openssl.time
+install-rb-default: $(RUBYLIBDIR)/openssl/cipher.rb
+$(RUBYLIBDIR)/openssl/cipher.rb: $(srcdir)/lib/openssl/cipher.rb $(TIMESTAMP_DIR)/.RUBYLIBDIR.-.openssl.time
+ $(Q) $(COPY) $(srcdir)/lib/openssl/cipher.rb $(@D)
+clean-rb-default::
+ -$(Q)$(RM) $(RUBYLIBDIR)/openssl/cipher.rb
+install-rb-default: $(RUBYLIBDIR)/openssl/config.rb
+$(RUBYLIBDIR)/openssl/config.rb: $(srcdir)/lib/openssl/config.rb $(TIMESTAMP_DIR)/.RUBYLIBDIR.-.openssl.time
+ $(Q) $(COPY) $(srcdir)/lib/openssl/config.rb $(@D)
+clean-rb-default::
+ -$(Q)$(RM) $(RUBYLIBDIR)/openssl/config.rb
+install-rb-default: $(RUBYLIBDIR)/openssl/x509.rb
+$(RUBYLIBDIR)/openssl/x509.rb: $(srcdir)/lib/openssl/x509.rb $(TIMESTAMP_DIR)/.RUBYLIBDIR.-.openssl.time
+ $(Q) $(COPY) $(srcdir)/lib/openssl/x509.rb $(@D)
+clean-rb-default::
+ -$(Q)$(RM) $(RUBYLIBDIR)/openssl/x509.rb
+install-rb-default: $(RUBYLIBDIR)/openssl/bn.rb
+$(RUBYLIBDIR)/openssl/bn.rb: $(srcdir)/lib/openssl/bn.rb $(TIMESTAMP_DIR)/.RUBYLIBDIR.-.openssl.time
+ $(Q) $(COPY) $(srcdir)/lib/openssl/bn.rb $(@D)
+clean-rb-default::
+ -$(Q)$(RM) $(RUBYLIBDIR)/openssl/bn.rb
+install-rb-default: $(RUBYLIBDIR)/openssl/buffering.rb
+$(RUBYLIBDIR)/openssl/buffering.rb: $(srcdir)/lib/openssl/buffering.rb $(TIMESTAMP_DIR)/.RUBYLIBDIR.-.openssl.time
+ $(Q) $(COPY) $(srcdir)/lib/openssl/buffering.rb $(@D)
+clean-rb-default::
+ -$(Q)$(RM) $(RUBYLIBDIR)/openssl/buffering.rb
+install-rb-default: $(RUBYLIBDIR)/openssl/digest.rb
+$(RUBYLIBDIR)/openssl/digest.rb: $(srcdir)/lib/openssl/digest.rb $(TIMESTAMP_DIR)/.RUBYLIBDIR.-.openssl.time
+ $(Q) $(COPY) $(srcdir)/lib/openssl/digest.rb $(@D)
+clean-rb-default::
+ -$(Q)$(RM) $(RUBYLIBDIR)/openssl/digest.rb
+install-rb-default: $(RUBYLIBDIR)/openssl/ssl.rb
+$(RUBYLIBDIR)/openssl/ssl.rb: $(srcdir)/lib/openssl/ssl.rb $(TIMESTAMP_DIR)/.RUBYLIBDIR.-.openssl.time
+ $(Q) $(COPY) $(srcdir)/lib/openssl/ssl.rb $(@D)
+clean-rb-default::
+ -$(Q)$(RM) $(RUBYLIBDIR)/openssl/ssl.rb
+pre-install-rb-default:
+ $(ECHO) installing default openssl libraries
+clean-rb-default::
+ -$(Q)$(RMDIRS) $(RUBYLIBDIR)/openssl 2> /dev/null || true
+ -$(Q)$(RMDIRS) $(RUBYLIBDIR) 2> /dev/null || true
+$(TIMESTAMP_DIR)/.RUBYARCHDIR.time:
+ $(Q) $(MAKEDIRS) $(@D) $(RUBYARCHDIR)
+ $(Q) $(TOUCH) $@
+$(TIMESTAMP_DIR)/.RUBYLIBDIR.time:
+ $(Q) $(MAKEDIRS) $(@D) $(RUBYLIBDIR)
+ $(Q) $(TOUCH) $@
+$(TIMESTAMP_DIR)/.RUBYLIBDIR.-.openssl.time:
+ $(Q) $(MAKEDIRS) $(@D) $(RUBYLIBDIR)/openssl
+ $(Q) $(TOUCH) $@
+
+site-install: site-install-so site-install-rb
+site-install-so: install-so
+site-install-rb: install-rb
+
+.SUFFIXES: .c .m .cc .mm .cxx .cpp .o .S
+
+.cc.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<
+
+.cc.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -S $<
+
+.mm.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<
+
+.mm.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -S $<
+
+.cxx.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<
+
+.cxx.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -S $<
+
+.cpp.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<
+
+.cpp.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -S $<
+
+.c.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -c $<
+
+.c.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -S $<
+
+.m.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -c $<
+
+.m.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -S $<
+
+$(RUBYARCHDIR)/$(DLLIB): $(OBJS) Makefile $(TIMESTAMP_DIR)/.RUBYARCHDIR.time
+ $(ECHO) linking shared-object $(DLLIB)
+ -$(Q)$(RM) $(@)
+ $(Q) $(LDSHARED) -o $@ $(OBJS) $(LIBPATH) $(DLDFLAGS) $(LOCAL_LIBS) $(LIBS)
+
+$(STATIC_LIB): $(OBJS)
+ -$(Q)$(RM) $(@)
+ $(ECHO) linking static-library $(@)
+ $(Q) $(AR) cru $@ $(OBJS)
+ -$(Q)ranlib $(@) 2> /dev/null || true
+
+###
+$(OBJS): $(RUBY_EXTCONF_H)
+
+# AUTOGENERATED DEPENDENCIES START
+openssl_missing.o: $(RUBY_EXTCONF_H)
+openssl_missing.o: openssl_missing.c
+openssl_missing.o: openssl_missing.h
+ossl.o: $(RUBY_EXTCONF_H)
+ossl.o: $(arch_hdrdir)/ruby/config.h
+ossl.o: $(hdrdir)/ruby/defines.h
+ossl.o: $(hdrdir)/ruby/encoding.h
+ossl.o: $(hdrdir)/ruby/intern.h
+ossl.o: $(hdrdir)/ruby/io.h
+ossl.o: $(hdrdir)/ruby/missing.h
+ossl.o: $(hdrdir)/ruby/oniguruma.h
+ossl.o: $(hdrdir)/ruby/ruby.h
+ossl.o: $(hdrdir)/ruby/st.h
+ossl.o: $(hdrdir)/ruby/subst.h
+ossl.o: $(hdrdir)/ruby/thread.h
+ossl.o: $(hdrdir)/ruby/thread_native.h
+ossl.o: $(top_srcdir)/include/ruby.h
+ossl.o: openssl_missing.h
+ossl.o: ossl.c
+ossl.o: ossl.h
+ossl.o: ossl_asn1.h
+ossl.o: ossl_bio.h
+ossl.o: ossl_bn.h
+ossl.o: ossl_cipher.h
+ossl.o: ossl_config.h
+ossl.o: ossl_digest.h
+ossl.o: ossl_engine.h
+ossl.o: ossl_hmac.h
+ossl.o: ossl_ns_spki.h
+ossl.o: ossl_ocsp.h
+ossl.o: ossl_pkcs12.h
+ossl.o: ossl_pkcs5.h
+ossl.o: ossl_pkcs7.h
+ossl.o: ossl_pkey.h
+ossl.o: ossl_rand.h
+ossl.o: ossl_ssl.h
+ossl.o: ossl_version.h
+ossl.o: ossl_x509.h
+ossl.o: ruby_missing.h
+ossl_asn1.o: $(RUBY_EXTCONF_H)
+ossl_asn1.o: $(arch_hdrdir)/ruby/config.h
+ossl_asn1.o: $(hdrdir)/ruby/defines.h
+ossl_asn1.o: $(hdrdir)/ruby/encoding.h
+ossl_asn1.o: $(hdrdir)/ruby/intern.h
+ossl_asn1.o: $(hdrdir)/ruby/io.h
+ossl_asn1.o: $(hdrdir)/ruby/missing.h
+ossl_asn1.o: $(hdrdir)/ruby/oniguruma.h
+ossl_asn1.o: $(hdrdir)/ruby/ruby.h
+ossl_asn1.o: $(hdrdir)/ruby/st.h
+ossl_asn1.o: $(hdrdir)/ruby/subst.h
+ossl_asn1.o: $(hdrdir)/ruby/thread.h
+ossl_asn1.o: $(top_srcdir)/include/ruby.h
+ossl_asn1.o: openssl_missing.h
+ossl_asn1.o: ossl.h
+ossl_asn1.o: ossl_asn1.c
+ossl_asn1.o: ossl_asn1.h
+ossl_asn1.o: ossl_bio.h
+ossl_asn1.o: ossl_bn.h
+ossl_asn1.o: ossl_cipher.h
+ossl_asn1.o: ossl_config.h
+ossl_asn1.o: ossl_digest.h
+ossl_asn1.o: ossl_engine.h
+ossl_asn1.o: ossl_hmac.h
+ossl_asn1.o: ossl_ns_spki.h
+ossl_asn1.o: ossl_ocsp.h
+ossl_asn1.o: ossl_pkcs12.h
+ossl_asn1.o: ossl_pkcs5.h
+ossl_asn1.o: ossl_pkcs7.h
+ossl_asn1.o: ossl_pkey.h
+ossl_asn1.o: ossl_rand.h
+ossl_asn1.o: ossl_ssl.h
+ossl_asn1.o: ossl_version.h
+ossl_asn1.o: ossl_x509.h
+ossl_asn1.o: ruby_missing.h
+ossl_bio.o: $(RUBY_EXTCONF_H)
+ossl_bio.o: $(arch_hdrdir)/ruby/config.h
+ossl_bio.o: $(hdrdir)/ruby/defines.h
+ossl_bio.o: $(hdrdir)/ruby/encoding.h
+ossl_bio.o: $(hdrdir)/ruby/intern.h
+ossl_bio.o: $(hdrdir)/ruby/io.h
+ossl_bio.o: $(hdrdir)/ruby/missing.h
+ossl_bio.o: $(hdrdir)/ruby/oniguruma.h
+ossl_bio.o: $(hdrdir)/ruby/ruby.h
+ossl_bio.o: $(hdrdir)/ruby/st.h
+ossl_bio.o: $(hdrdir)/ruby/subst.h
+ossl_bio.o: $(hdrdir)/ruby/thread.h
+ossl_bio.o: $(top_srcdir)/include/ruby.h
+ossl_bio.o: openssl_missing.h
+ossl_bio.o: ossl.h
+ossl_bio.o: ossl_asn1.h
+ossl_bio.o: ossl_bio.c
+ossl_bio.o: ossl_bio.h
+ossl_bio.o: ossl_bn.h
+ossl_bio.o: ossl_cipher.h
+ossl_bio.o: ossl_config.h
+ossl_bio.o: ossl_digest.h
+ossl_bio.o: ossl_engine.h
+ossl_bio.o: ossl_hmac.h
+ossl_bio.o: ossl_ns_spki.h
+ossl_bio.o: ossl_ocsp.h
+ossl_bio.o: ossl_pkcs12.h
+ossl_bio.o: ossl_pkcs5.h
+ossl_bio.o: ossl_pkcs7.h
+ossl_bio.o: ossl_pkey.h
+ossl_bio.o: ossl_rand.h
+ossl_bio.o: ossl_ssl.h
+ossl_bio.o: ossl_version.h
+ossl_bio.o: ossl_x509.h
+ossl_bio.o: ruby_missing.h
+ossl_bn.o: $(RUBY_EXTCONF_H)
+ossl_bn.o: $(arch_hdrdir)/ruby/config.h
+ossl_bn.o: $(hdrdir)/ruby/defines.h
+ossl_bn.o: $(hdrdir)/ruby/encoding.h
+ossl_bn.o: $(hdrdir)/ruby/intern.h
+ossl_bn.o: $(hdrdir)/ruby/io.h
+ossl_bn.o: $(hdrdir)/ruby/missing.h
+ossl_bn.o: $(hdrdir)/ruby/oniguruma.h
+ossl_bn.o: $(hdrdir)/ruby/ruby.h
+ossl_bn.o: $(hdrdir)/ruby/st.h
+ossl_bn.o: $(hdrdir)/ruby/subst.h
+ossl_bn.o: $(hdrdir)/ruby/thread.h
+ossl_bn.o: $(top_srcdir)/include/ruby.h
+ossl_bn.o: openssl_missing.h
+ossl_bn.o: ossl.h
+ossl_bn.o: ossl_asn1.h
+ossl_bn.o: ossl_bio.h
+ossl_bn.o: ossl_bn.c
+ossl_bn.o: ossl_bn.h
+ossl_bn.o: ossl_cipher.h
+ossl_bn.o: ossl_config.h
+ossl_bn.o: ossl_digest.h
+ossl_bn.o: ossl_engine.h
+ossl_bn.o: ossl_hmac.h
+ossl_bn.o: ossl_ns_spki.h
+ossl_bn.o: ossl_ocsp.h
+ossl_bn.o: ossl_pkcs12.h
+ossl_bn.o: ossl_pkcs5.h
+ossl_bn.o: ossl_pkcs7.h
+ossl_bn.o: ossl_pkey.h
+ossl_bn.o: ossl_rand.h
+ossl_bn.o: ossl_ssl.h
+ossl_bn.o: ossl_version.h
+ossl_bn.o: ossl_x509.h
+ossl_bn.o: ruby_missing.h
+ossl_cipher.o: $(RUBY_EXTCONF_H)
+ossl_cipher.o: $(arch_hdrdir)/ruby/config.h
+ossl_cipher.o: $(hdrdir)/ruby/defines.h
+ossl_cipher.o: $(hdrdir)/ruby/encoding.h
+ossl_cipher.o: $(hdrdir)/ruby/intern.h
+ossl_cipher.o: $(hdrdir)/ruby/io.h
+ossl_cipher.o: $(hdrdir)/ruby/missing.h
+ossl_cipher.o: $(hdrdir)/ruby/oniguruma.h
+ossl_cipher.o: $(hdrdir)/ruby/ruby.h
+ossl_cipher.o: $(hdrdir)/ruby/st.h
+ossl_cipher.o: $(hdrdir)/ruby/subst.h
+ossl_cipher.o: $(hdrdir)/ruby/thread.h
+ossl_cipher.o: $(top_srcdir)/include/ruby.h
+ossl_cipher.o: openssl_missing.h
+ossl_cipher.o: ossl.h
+ossl_cipher.o: ossl_asn1.h
+ossl_cipher.o: ossl_bio.h
+ossl_cipher.o: ossl_bn.h
+ossl_cipher.o: ossl_cipher.c
+ossl_cipher.o: ossl_cipher.h
+ossl_cipher.o: ossl_config.h
+ossl_cipher.o: ossl_digest.h
+ossl_cipher.o: ossl_engine.h
+ossl_cipher.o: ossl_hmac.h
+ossl_cipher.o: ossl_ns_spki.h
+ossl_cipher.o: ossl_ocsp.h
+ossl_cipher.o: ossl_pkcs12.h
+ossl_cipher.o: ossl_pkcs5.h
+ossl_cipher.o: ossl_pkcs7.h
+ossl_cipher.o: ossl_pkey.h
+ossl_cipher.o: ossl_rand.h
+ossl_cipher.o: ossl_ssl.h
+ossl_cipher.o: ossl_version.h
+ossl_cipher.o: ossl_x509.h
+ossl_cipher.o: ruby_missing.h
+ossl_config.o: $(RUBY_EXTCONF_H)
+ossl_config.o: $(arch_hdrdir)/ruby/config.h
+ossl_config.o: $(hdrdir)/ruby/defines.h
+ossl_config.o: $(hdrdir)/ruby/encoding.h
+ossl_config.o: $(hdrdir)/ruby/intern.h
+ossl_config.o: $(hdrdir)/ruby/io.h
+ossl_config.o: $(hdrdir)/ruby/missing.h
+ossl_config.o: $(hdrdir)/ruby/oniguruma.h
+ossl_config.o: $(hdrdir)/ruby/ruby.h
+ossl_config.o: $(hdrdir)/ruby/st.h
+ossl_config.o: $(hdrdir)/ruby/subst.h
+ossl_config.o: $(hdrdir)/ruby/thread.h
+ossl_config.o: $(top_srcdir)/include/ruby.h
+ossl_config.o: openssl_missing.h
+ossl_config.o: ossl.h
+ossl_config.o: ossl_asn1.h
+ossl_config.o: ossl_bio.h
+ossl_config.o: ossl_bn.h
+ossl_config.o: ossl_cipher.h
+ossl_config.o: ossl_config.c
+ossl_config.o: ossl_config.h
+ossl_config.o: ossl_digest.h
+ossl_config.o: ossl_engine.h
+ossl_config.o: ossl_hmac.h
+ossl_config.o: ossl_ns_spki.h
+ossl_config.o: ossl_ocsp.h
+ossl_config.o: ossl_pkcs12.h
+ossl_config.o: ossl_pkcs5.h
+ossl_config.o: ossl_pkcs7.h
+ossl_config.o: ossl_pkey.h
+ossl_config.o: ossl_rand.h
+ossl_config.o: ossl_ssl.h
+ossl_config.o: ossl_version.h
+ossl_config.o: ossl_x509.h
+ossl_config.o: ruby_missing.h
+ossl_digest.o: $(RUBY_EXTCONF_H)
+ossl_digest.o: $(arch_hdrdir)/ruby/config.h
+ossl_digest.o: $(hdrdir)/ruby/defines.h
+ossl_digest.o: $(hdrdir)/ruby/encoding.h
+ossl_digest.o: $(hdrdir)/ruby/intern.h
+ossl_digest.o: $(hdrdir)/ruby/io.h
+ossl_digest.o: $(hdrdir)/ruby/missing.h
+ossl_digest.o: $(hdrdir)/ruby/oniguruma.h
+ossl_digest.o: $(hdrdir)/ruby/ruby.h
+ossl_digest.o: $(hdrdir)/ruby/st.h
+ossl_digest.o: $(hdrdir)/ruby/subst.h
+ossl_digest.o: $(hdrdir)/ruby/thread.h
+ossl_digest.o: $(top_srcdir)/include/ruby.h
+ossl_digest.o: openssl_missing.h
+ossl_digest.o: ossl.h
+ossl_digest.o: ossl_asn1.h
+ossl_digest.o: ossl_bio.h
+ossl_digest.o: ossl_bn.h
+ossl_digest.o: ossl_cipher.h
+ossl_digest.o: ossl_config.h
+ossl_digest.o: ossl_digest.c
+ossl_digest.o: ossl_digest.h
+ossl_digest.o: ossl_engine.h
+ossl_digest.o: ossl_hmac.h
+ossl_digest.o: ossl_ns_spki.h
+ossl_digest.o: ossl_ocsp.h
+ossl_digest.o: ossl_pkcs12.h
+ossl_digest.o: ossl_pkcs5.h
+ossl_digest.o: ossl_pkcs7.h
+ossl_digest.o: ossl_pkey.h
+ossl_digest.o: ossl_rand.h
+ossl_digest.o: ossl_ssl.h
+ossl_digest.o: ossl_version.h
+ossl_digest.o: ossl_x509.h
+ossl_digest.o: ruby_missing.h
+ossl_engine.o: $(RUBY_EXTCONF_H)
+ossl_engine.o: $(arch_hdrdir)/ruby/config.h
+ossl_engine.o: $(hdrdir)/ruby/defines.h
+ossl_engine.o: $(hdrdir)/ruby/encoding.h
+ossl_engine.o: $(hdrdir)/ruby/intern.h
+ossl_engine.o: $(hdrdir)/ruby/io.h
+ossl_engine.o: $(hdrdir)/ruby/missing.h
+ossl_engine.o: $(hdrdir)/ruby/oniguruma.h
+ossl_engine.o: $(hdrdir)/ruby/ruby.h
+ossl_engine.o: $(hdrdir)/ruby/st.h
+ossl_engine.o: $(hdrdir)/ruby/subst.h
+ossl_engine.o: $(hdrdir)/ruby/thread.h
+ossl_engine.o: $(top_srcdir)/include/ruby.h
+ossl_engine.o: openssl_missing.h
+ossl_engine.o: ossl.h
+ossl_engine.o: ossl_asn1.h
+ossl_engine.o: ossl_bio.h
+ossl_engine.o: ossl_bn.h
+ossl_engine.o: ossl_cipher.h
+ossl_engine.o: ossl_config.h
+ossl_engine.o: ossl_digest.h
+ossl_engine.o: ossl_engine.c
+ossl_engine.o: ossl_engine.h
+ossl_engine.o: ossl_hmac.h
+ossl_engine.o: ossl_ns_spki.h
+ossl_engine.o: ossl_ocsp.h
+ossl_engine.o: ossl_pkcs12.h
+ossl_engine.o: ossl_pkcs5.h
+ossl_engine.o: ossl_pkcs7.h
+ossl_engine.o: ossl_pkey.h
+ossl_engine.o: ossl_rand.h
+ossl_engine.o: ossl_ssl.h
+ossl_engine.o: ossl_version.h
+ossl_engine.o: ossl_x509.h
+ossl_engine.o: ruby_missing.h
+ossl_hmac.o: $(RUBY_EXTCONF_H)
+ossl_hmac.o: $(arch_hdrdir)/ruby/config.h
+ossl_hmac.o: $(hdrdir)/ruby/defines.h
+ossl_hmac.o: $(hdrdir)/ruby/encoding.h
+ossl_hmac.o: $(hdrdir)/ruby/intern.h
+ossl_hmac.o: $(hdrdir)/ruby/io.h
+ossl_hmac.o: $(hdrdir)/ruby/missing.h
+ossl_hmac.o: $(hdrdir)/ruby/oniguruma.h
+ossl_hmac.o: $(hdrdir)/ruby/ruby.h
+ossl_hmac.o: $(hdrdir)/ruby/st.h
+ossl_hmac.o: $(hdrdir)/ruby/subst.h
+ossl_hmac.o: $(hdrdir)/ruby/thread.h
+ossl_hmac.o: $(top_srcdir)/include/ruby.h
+ossl_hmac.o: openssl_missing.h
+ossl_hmac.o: ossl.h
+ossl_hmac.o: ossl_asn1.h
+ossl_hmac.o: ossl_bio.h
+ossl_hmac.o: ossl_bn.h
+ossl_hmac.o: ossl_cipher.h
+ossl_hmac.o: ossl_config.h
+ossl_hmac.o: ossl_digest.h
+ossl_hmac.o: ossl_engine.h
+ossl_hmac.o: ossl_hmac.c
+ossl_hmac.o: ossl_hmac.h
+ossl_hmac.o: ossl_ns_spki.h
+ossl_hmac.o: ossl_ocsp.h
+ossl_hmac.o: ossl_pkcs12.h
+ossl_hmac.o: ossl_pkcs5.h
+ossl_hmac.o: ossl_pkcs7.h
+ossl_hmac.o: ossl_pkey.h
+ossl_hmac.o: ossl_rand.h
+ossl_hmac.o: ossl_ssl.h
+ossl_hmac.o: ossl_version.h
+ossl_hmac.o: ossl_x509.h
+ossl_hmac.o: ruby_missing.h
+ossl_ns_spki.o: $(RUBY_EXTCONF_H)
+ossl_ns_spki.o: $(arch_hdrdir)/ruby/config.h
+ossl_ns_spki.o: $(hdrdir)/ruby/defines.h
+ossl_ns_spki.o: $(hdrdir)/ruby/encoding.h
+ossl_ns_spki.o: $(hdrdir)/ruby/intern.h
+ossl_ns_spki.o: $(hdrdir)/ruby/io.h
+ossl_ns_spki.o: $(hdrdir)/ruby/missing.h
+ossl_ns_spki.o: $(hdrdir)/ruby/oniguruma.h
+ossl_ns_spki.o: $(hdrdir)/ruby/ruby.h
+ossl_ns_spki.o: $(hdrdir)/ruby/st.h
+ossl_ns_spki.o: $(hdrdir)/ruby/subst.h
+ossl_ns_spki.o: $(hdrdir)/ruby/thread.h
+ossl_ns_spki.o: $(top_srcdir)/include/ruby.h
+ossl_ns_spki.o: openssl_missing.h
+ossl_ns_spki.o: ossl.h
+ossl_ns_spki.o: ossl_asn1.h
+ossl_ns_spki.o: ossl_bio.h
+ossl_ns_spki.o: ossl_bn.h
+ossl_ns_spki.o: ossl_cipher.h
+ossl_ns_spki.o: ossl_config.h
+ossl_ns_spki.o: ossl_digest.h
+ossl_ns_spki.o: ossl_engine.h
+ossl_ns_spki.o: ossl_hmac.h
+ossl_ns_spki.o: ossl_ns_spki.c
+ossl_ns_spki.o: ossl_ns_spki.h
+ossl_ns_spki.o: ossl_ocsp.h
+ossl_ns_spki.o: ossl_pkcs12.h
+ossl_ns_spki.o: ossl_pkcs5.h
+ossl_ns_spki.o: ossl_pkcs7.h
+ossl_ns_spki.o: ossl_pkey.h
+ossl_ns_spki.o: ossl_rand.h
+ossl_ns_spki.o: ossl_ssl.h
+ossl_ns_spki.o: ossl_version.h
+ossl_ns_spki.o: ossl_x509.h
+ossl_ns_spki.o: ruby_missing.h
+ossl_ocsp.o: $(RUBY_EXTCONF_H)
+ossl_ocsp.o: $(arch_hdrdir)/ruby/config.h
+ossl_ocsp.o: $(hdrdir)/ruby/defines.h
+ossl_ocsp.o: $(hdrdir)/ruby/encoding.h
+ossl_ocsp.o: $(hdrdir)/ruby/intern.h
+ossl_ocsp.o: $(hdrdir)/ruby/io.h
+ossl_ocsp.o: $(hdrdir)/ruby/missing.h
+ossl_ocsp.o: $(hdrdir)/ruby/oniguruma.h
+ossl_ocsp.o: $(hdrdir)/ruby/ruby.h
+ossl_ocsp.o: $(hdrdir)/ruby/st.h
+ossl_ocsp.o: $(hdrdir)/ruby/subst.h
+ossl_ocsp.o: $(hdrdir)/ruby/thread.h
+ossl_ocsp.o: $(top_srcdir)/include/ruby.h
+ossl_ocsp.o: openssl_missing.h
+ossl_ocsp.o: ossl.h
+ossl_ocsp.o: ossl_asn1.h
+ossl_ocsp.o: ossl_bio.h
+ossl_ocsp.o: ossl_bn.h
+ossl_ocsp.o: ossl_cipher.h
+ossl_ocsp.o: ossl_config.h
+ossl_ocsp.o: ossl_digest.h
+ossl_ocsp.o: ossl_engine.h
+ossl_ocsp.o: ossl_hmac.h
+ossl_ocsp.o: ossl_ns_spki.h
+ossl_ocsp.o: ossl_ocsp.c
+ossl_ocsp.o: ossl_ocsp.h
+ossl_ocsp.o: ossl_pkcs12.h
+ossl_ocsp.o: ossl_pkcs5.h
+ossl_ocsp.o: ossl_pkcs7.h
+ossl_ocsp.o: ossl_pkey.h
+ossl_ocsp.o: ossl_rand.h
+ossl_ocsp.o: ossl_ssl.h
+ossl_ocsp.o: ossl_version.h
+ossl_ocsp.o: ossl_x509.h
+ossl_ocsp.o: ruby_missing.h
+ossl_pkcs12.o: $(RUBY_EXTCONF_H)
+ossl_pkcs12.o: $(arch_hdrdir)/ruby/config.h
+ossl_pkcs12.o: $(hdrdir)/ruby/defines.h
+ossl_pkcs12.o: $(hdrdir)/ruby/encoding.h
+ossl_pkcs12.o: $(hdrdir)/ruby/intern.h
+ossl_pkcs12.o: $(hdrdir)/ruby/io.h
+ossl_pkcs12.o: $(hdrdir)/ruby/missing.h
+ossl_pkcs12.o: $(hdrdir)/ruby/oniguruma.h
+ossl_pkcs12.o: $(hdrdir)/ruby/ruby.h
+ossl_pkcs12.o: $(hdrdir)/ruby/st.h
+ossl_pkcs12.o: $(hdrdir)/ruby/subst.h
+ossl_pkcs12.o: $(hdrdir)/ruby/thread.h
+ossl_pkcs12.o: $(top_srcdir)/include/ruby.h
+ossl_pkcs12.o: openssl_missing.h
+ossl_pkcs12.o: ossl.h
+ossl_pkcs12.o: ossl_asn1.h
+ossl_pkcs12.o: ossl_bio.h
+ossl_pkcs12.o: ossl_bn.h
+ossl_pkcs12.o: ossl_cipher.h
+ossl_pkcs12.o: ossl_config.h
+ossl_pkcs12.o: ossl_digest.h
+ossl_pkcs12.o: ossl_engine.h
+ossl_pkcs12.o: ossl_hmac.h
+ossl_pkcs12.o: ossl_ns_spki.h
+ossl_pkcs12.o: ossl_ocsp.h
+ossl_pkcs12.o: ossl_pkcs12.c
+ossl_pkcs12.o: ossl_pkcs12.h
+ossl_pkcs12.o: ossl_pkcs5.h
+ossl_pkcs12.o: ossl_pkcs7.h
+ossl_pkcs12.o: ossl_pkey.h
+ossl_pkcs12.o: ossl_rand.h
+ossl_pkcs12.o: ossl_ssl.h
+ossl_pkcs12.o: ossl_version.h
+ossl_pkcs12.o: ossl_x509.h
+ossl_pkcs12.o: ruby_missing.h
+ossl_pkcs5.o: $(RUBY_EXTCONF_H)
+ossl_pkcs5.o: $(arch_hdrdir)/ruby/config.h
+ossl_pkcs5.o: $(hdrdir)/ruby/defines.h
+ossl_pkcs5.o: $(hdrdir)/ruby/encoding.h
+ossl_pkcs5.o: $(hdrdir)/ruby/intern.h
+ossl_pkcs5.o: $(hdrdir)/ruby/io.h
+ossl_pkcs5.o: $(hdrdir)/ruby/missing.h
+ossl_pkcs5.o: $(hdrdir)/ruby/oniguruma.h
+ossl_pkcs5.o: $(hdrdir)/ruby/ruby.h
+ossl_pkcs5.o: $(hdrdir)/ruby/st.h
+ossl_pkcs5.o: $(hdrdir)/ruby/subst.h
+ossl_pkcs5.o: $(hdrdir)/ruby/thread.h
+ossl_pkcs5.o: $(top_srcdir)/include/ruby.h
+ossl_pkcs5.o: openssl_missing.h
+ossl_pkcs5.o: ossl.h
+ossl_pkcs5.o: ossl_asn1.h
+ossl_pkcs5.o: ossl_bio.h
+ossl_pkcs5.o: ossl_bn.h
+ossl_pkcs5.o: ossl_cipher.h
+ossl_pkcs5.o: ossl_config.h
+ossl_pkcs5.o: ossl_digest.h
+ossl_pkcs5.o: ossl_engine.h
+ossl_pkcs5.o: ossl_hmac.h
+ossl_pkcs5.o: ossl_ns_spki.h
+ossl_pkcs5.o: ossl_ocsp.h
+ossl_pkcs5.o: ossl_pkcs12.h
+ossl_pkcs5.o: ossl_pkcs5.c
+ossl_pkcs5.o: ossl_pkcs5.h
+ossl_pkcs5.o: ossl_pkcs7.h
+ossl_pkcs5.o: ossl_pkey.h
+ossl_pkcs5.o: ossl_rand.h
+ossl_pkcs5.o: ossl_ssl.h
+ossl_pkcs5.o: ossl_version.h
+ossl_pkcs5.o: ossl_x509.h
+ossl_pkcs5.o: ruby_missing.h
+ossl_pkcs7.o: $(RUBY_EXTCONF_H)
+ossl_pkcs7.o: $(arch_hdrdir)/ruby/config.h
+ossl_pkcs7.o: $(hdrdir)/ruby/defines.h
+ossl_pkcs7.o: $(hdrdir)/ruby/encoding.h
+ossl_pkcs7.o: $(hdrdir)/ruby/intern.h
+ossl_pkcs7.o: $(hdrdir)/ruby/io.h
+ossl_pkcs7.o: $(hdrdir)/ruby/missing.h
+ossl_pkcs7.o: $(hdrdir)/ruby/oniguruma.h
+ossl_pkcs7.o: $(hdrdir)/ruby/ruby.h
+ossl_pkcs7.o: $(hdrdir)/ruby/st.h
+ossl_pkcs7.o: $(hdrdir)/ruby/subst.h
+ossl_pkcs7.o: $(hdrdir)/ruby/thread.h
+ossl_pkcs7.o: $(top_srcdir)/include/ruby.h
+ossl_pkcs7.o: openssl_missing.h
+ossl_pkcs7.o: ossl.h
+ossl_pkcs7.o: ossl_asn1.h
+ossl_pkcs7.o: ossl_bio.h
+ossl_pkcs7.o: ossl_bn.h
+ossl_pkcs7.o: ossl_cipher.h
+ossl_pkcs7.o: ossl_config.h
+ossl_pkcs7.o: ossl_digest.h
+ossl_pkcs7.o: ossl_engine.h
+ossl_pkcs7.o: ossl_hmac.h
+ossl_pkcs7.o: ossl_ns_spki.h
+ossl_pkcs7.o: ossl_ocsp.h
+ossl_pkcs7.o: ossl_pkcs12.h
+ossl_pkcs7.o: ossl_pkcs5.h
+ossl_pkcs7.o: ossl_pkcs7.c
+ossl_pkcs7.o: ossl_pkcs7.h
+ossl_pkcs7.o: ossl_pkey.h
+ossl_pkcs7.o: ossl_rand.h
+ossl_pkcs7.o: ossl_ssl.h
+ossl_pkcs7.o: ossl_version.h
+ossl_pkcs7.o: ossl_x509.h
+ossl_pkcs7.o: ruby_missing.h
+ossl_pkey.o: $(RUBY_EXTCONF_H)
+ossl_pkey.o: $(arch_hdrdir)/ruby/config.h
+ossl_pkey.o: $(hdrdir)/ruby/defines.h
+ossl_pkey.o: $(hdrdir)/ruby/encoding.h
+ossl_pkey.o: $(hdrdir)/ruby/intern.h
+ossl_pkey.o: $(hdrdir)/ruby/io.h
+ossl_pkey.o: $(hdrdir)/ruby/missing.h
+ossl_pkey.o: $(hdrdir)/ruby/oniguruma.h
+ossl_pkey.o: $(hdrdir)/ruby/ruby.h
+ossl_pkey.o: $(hdrdir)/ruby/st.h
+ossl_pkey.o: $(hdrdir)/ruby/subst.h
+ossl_pkey.o: $(hdrdir)/ruby/thread.h
+ossl_pkey.o: $(top_srcdir)/include/ruby.h
+ossl_pkey.o: openssl_missing.h
+ossl_pkey.o: ossl.h
+ossl_pkey.o: ossl_asn1.h
+ossl_pkey.o: ossl_bio.h
+ossl_pkey.o: ossl_bn.h
+ossl_pkey.o: ossl_cipher.h
+ossl_pkey.o: ossl_config.h
+ossl_pkey.o: ossl_digest.h
+ossl_pkey.o: ossl_engine.h
+ossl_pkey.o: ossl_hmac.h
+ossl_pkey.o: ossl_ns_spki.h
+ossl_pkey.o: ossl_ocsp.h
+ossl_pkey.o: ossl_pkcs12.h
+ossl_pkey.o: ossl_pkcs5.h
+ossl_pkey.o: ossl_pkcs7.h
+ossl_pkey.o: ossl_pkey.c
+ossl_pkey.o: ossl_pkey.h
+ossl_pkey.o: ossl_rand.h
+ossl_pkey.o: ossl_ssl.h
+ossl_pkey.o: ossl_version.h
+ossl_pkey.o: ossl_x509.h
+ossl_pkey.o: ruby_missing.h
+ossl_pkey_dh.o: $(RUBY_EXTCONF_H)
+ossl_pkey_dh.o: $(arch_hdrdir)/ruby/config.h
+ossl_pkey_dh.o: $(hdrdir)/ruby/defines.h
+ossl_pkey_dh.o: $(hdrdir)/ruby/encoding.h
+ossl_pkey_dh.o: $(hdrdir)/ruby/intern.h
+ossl_pkey_dh.o: $(hdrdir)/ruby/io.h
+ossl_pkey_dh.o: $(hdrdir)/ruby/missing.h
+ossl_pkey_dh.o: $(hdrdir)/ruby/oniguruma.h
+ossl_pkey_dh.o: $(hdrdir)/ruby/ruby.h
+ossl_pkey_dh.o: $(hdrdir)/ruby/st.h
+ossl_pkey_dh.o: $(hdrdir)/ruby/subst.h
+ossl_pkey_dh.o: $(hdrdir)/ruby/thread.h
+ossl_pkey_dh.o: $(top_srcdir)/include/ruby.h
+ossl_pkey_dh.o: openssl_missing.h
+ossl_pkey_dh.o: ossl.h
+ossl_pkey_dh.o: ossl_asn1.h
+ossl_pkey_dh.o: ossl_bio.h
+ossl_pkey_dh.o: ossl_bn.h
+ossl_pkey_dh.o: ossl_cipher.h
+ossl_pkey_dh.o: ossl_config.h
+ossl_pkey_dh.o: ossl_digest.h
+ossl_pkey_dh.o: ossl_engine.h
+ossl_pkey_dh.o: ossl_hmac.h
+ossl_pkey_dh.o: ossl_ns_spki.h
+ossl_pkey_dh.o: ossl_ocsp.h
+ossl_pkey_dh.o: ossl_pkcs12.h
+ossl_pkey_dh.o: ossl_pkcs5.h
+ossl_pkey_dh.o: ossl_pkcs7.h
+ossl_pkey_dh.o: ossl_pkey.h
+ossl_pkey_dh.o: ossl_pkey_dh.c
+ossl_pkey_dh.o: ossl_rand.h
+ossl_pkey_dh.o: ossl_ssl.h
+ossl_pkey_dh.o: ossl_version.h
+ossl_pkey_dh.o: ossl_x509.h
+ossl_pkey_dh.o: ruby_missing.h
+ossl_pkey_dsa.o: $(RUBY_EXTCONF_H)
+ossl_pkey_dsa.o: $(arch_hdrdir)/ruby/config.h
+ossl_pkey_dsa.o: $(hdrdir)/ruby/defines.h
+ossl_pkey_dsa.o: $(hdrdir)/ruby/encoding.h
+ossl_pkey_dsa.o: $(hdrdir)/ruby/intern.h
+ossl_pkey_dsa.o: $(hdrdir)/ruby/io.h
+ossl_pkey_dsa.o: $(hdrdir)/ruby/missing.h
+ossl_pkey_dsa.o: $(hdrdir)/ruby/oniguruma.h
+ossl_pkey_dsa.o: $(hdrdir)/ruby/ruby.h
+ossl_pkey_dsa.o: $(hdrdir)/ruby/st.h
+ossl_pkey_dsa.o: $(hdrdir)/ruby/subst.h
+ossl_pkey_dsa.o: $(hdrdir)/ruby/thread.h
+ossl_pkey_dsa.o: $(top_srcdir)/include/ruby.h
+ossl_pkey_dsa.o: openssl_missing.h
+ossl_pkey_dsa.o: ossl.h
+ossl_pkey_dsa.o: ossl_asn1.h
+ossl_pkey_dsa.o: ossl_bio.h
+ossl_pkey_dsa.o: ossl_bn.h
+ossl_pkey_dsa.o: ossl_cipher.h
+ossl_pkey_dsa.o: ossl_config.h
+ossl_pkey_dsa.o: ossl_digest.h
+ossl_pkey_dsa.o: ossl_engine.h
+ossl_pkey_dsa.o: ossl_hmac.h
+ossl_pkey_dsa.o: ossl_ns_spki.h
+ossl_pkey_dsa.o: ossl_ocsp.h
+ossl_pkey_dsa.o: ossl_pkcs12.h
+ossl_pkey_dsa.o: ossl_pkcs5.h
+ossl_pkey_dsa.o: ossl_pkcs7.h
+ossl_pkey_dsa.o: ossl_pkey.h
+ossl_pkey_dsa.o: ossl_pkey_dsa.c
+ossl_pkey_dsa.o: ossl_rand.h
+ossl_pkey_dsa.o: ossl_ssl.h
+ossl_pkey_dsa.o: ossl_version.h
+ossl_pkey_dsa.o: ossl_x509.h
+ossl_pkey_dsa.o: ruby_missing.h
+ossl_pkey_ec.o: $(RUBY_EXTCONF_H)
+ossl_pkey_ec.o: $(arch_hdrdir)/ruby/config.h
+ossl_pkey_ec.o: $(hdrdir)/ruby/defines.h
+ossl_pkey_ec.o: $(hdrdir)/ruby/encoding.h
+ossl_pkey_ec.o: $(hdrdir)/ruby/intern.h
+ossl_pkey_ec.o: $(hdrdir)/ruby/io.h
+ossl_pkey_ec.o: $(hdrdir)/ruby/missing.h
+ossl_pkey_ec.o: $(hdrdir)/ruby/oniguruma.h
+ossl_pkey_ec.o: $(hdrdir)/ruby/ruby.h
+ossl_pkey_ec.o: $(hdrdir)/ruby/st.h
+ossl_pkey_ec.o: $(hdrdir)/ruby/subst.h
+ossl_pkey_ec.o: $(hdrdir)/ruby/thread.h
+ossl_pkey_ec.o: $(top_srcdir)/include/ruby.h
+ossl_pkey_ec.o: openssl_missing.h
+ossl_pkey_ec.o: ossl.h
+ossl_pkey_ec.o: ossl_asn1.h
+ossl_pkey_ec.o: ossl_bio.h
+ossl_pkey_ec.o: ossl_bn.h
+ossl_pkey_ec.o: ossl_cipher.h
+ossl_pkey_ec.o: ossl_config.h
+ossl_pkey_ec.o: ossl_digest.h
+ossl_pkey_ec.o: ossl_engine.h
+ossl_pkey_ec.o: ossl_hmac.h
+ossl_pkey_ec.o: ossl_ns_spki.h
+ossl_pkey_ec.o: ossl_ocsp.h
+ossl_pkey_ec.o: ossl_pkcs12.h
+ossl_pkey_ec.o: ossl_pkcs5.h
+ossl_pkey_ec.o: ossl_pkcs7.h
+ossl_pkey_ec.o: ossl_pkey.h
+ossl_pkey_ec.o: ossl_pkey_ec.c
+ossl_pkey_ec.o: ossl_rand.h
+ossl_pkey_ec.o: ossl_ssl.h
+ossl_pkey_ec.o: ossl_version.h
+ossl_pkey_ec.o: ossl_x509.h
+ossl_pkey_ec.o: ruby_missing.h
+ossl_pkey_rsa.o: $(RUBY_EXTCONF_H)
+ossl_pkey_rsa.o: $(arch_hdrdir)/ruby/config.h
+ossl_pkey_rsa.o: $(hdrdir)/ruby/defines.h
+ossl_pkey_rsa.o: $(hdrdir)/ruby/encoding.h
+ossl_pkey_rsa.o: $(hdrdir)/ruby/intern.h
+ossl_pkey_rsa.o: $(hdrdir)/ruby/io.h
+ossl_pkey_rsa.o: $(hdrdir)/ruby/missing.h
+ossl_pkey_rsa.o: $(hdrdir)/ruby/oniguruma.h
+ossl_pkey_rsa.o: $(hdrdir)/ruby/ruby.h
+ossl_pkey_rsa.o: $(hdrdir)/ruby/st.h
+ossl_pkey_rsa.o: $(hdrdir)/ruby/subst.h
+ossl_pkey_rsa.o: $(hdrdir)/ruby/thread.h
+ossl_pkey_rsa.o: $(top_srcdir)/include/ruby.h
+ossl_pkey_rsa.o: openssl_missing.h
+ossl_pkey_rsa.o: ossl.h
+ossl_pkey_rsa.o: ossl_asn1.h
+ossl_pkey_rsa.o: ossl_bio.h
+ossl_pkey_rsa.o: ossl_bn.h
+ossl_pkey_rsa.o: ossl_cipher.h
+ossl_pkey_rsa.o: ossl_config.h
+ossl_pkey_rsa.o: ossl_digest.h
+ossl_pkey_rsa.o: ossl_engine.h
+ossl_pkey_rsa.o: ossl_hmac.h
+ossl_pkey_rsa.o: ossl_ns_spki.h
+ossl_pkey_rsa.o: ossl_ocsp.h
+ossl_pkey_rsa.o: ossl_pkcs12.h
+ossl_pkey_rsa.o: ossl_pkcs5.h
+ossl_pkey_rsa.o: ossl_pkcs7.h
+ossl_pkey_rsa.o: ossl_pkey.h
+ossl_pkey_rsa.o: ossl_pkey_rsa.c
+ossl_pkey_rsa.o: ossl_rand.h
+ossl_pkey_rsa.o: ossl_ssl.h
+ossl_pkey_rsa.o: ossl_version.h
+ossl_pkey_rsa.o: ossl_x509.h
+ossl_pkey_rsa.o: ruby_missing.h
+ossl_rand.o: $(RUBY_EXTCONF_H)
+ossl_rand.o: $(arch_hdrdir)/ruby/config.h
+ossl_rand.o: $(hdrdir)/ruby/defines.h
+ossl_rand.o: $(hdrdir)/ruby/encoding.h
+ossl_rand.o: $(hdrdir)/ruby/intern.h
+ossl_rand.o: $(hdrdir)/ruby/io.h
+ossl_rand.o: $(hdrdir)/ruby/missing.h
+ossl_rand.o: $(hdrdir)/ruby/oniguruma.h
+ossl_rand.o: $(hdrdir)/ruby/ruby.h
+ossl_rand.o: $(hdrdir)/ruby/st.h
+ossl_rand.o: $(hdrdir)/ruby/subst.h
+ossl_rand.o: $(hdrdir)/ruby/thread.h
+ossl_rand.o: $(top_srcdir)/include/ruby.h
+ossl_rand.o: openssl_missing.h
+ossl_rand.o: ossl.h
+ossl_rand.o: ossl_asn1.h
+ossl_rand.o: ossl_bio.h
+ossl_rand.o: ossl_bn.h
+ossl_rand.o: ossl_cipher.h
+ossl_rand.o: ossl_config.h
+ossl_rand.o: ossl_digest.h
+ossl_rand.o: ossl_engine.h
+ossl_rand.o: ossl_hmac.h
+ossl_rand.o: ossl_ns_spki.h
+ossl_rand.o: ossl_ocsp.h
+ossl_rand.o: ossl_pkcs12.h
+ossl_rand.o: ossl_pkcs5.h
+ossl_rand.o: ossl_pkcs7.h
+ossl_rand.o: ossl_pkey.h
+ossl_rand.o: ossl_rand.c
+ossl_rand.o: ossl_rand.h
+ossl_rand.o: ossl_ssl.h
+ossl_rand.o: ossl_version.h
+ossl_rand.o: ossl_x509.h
+ossl_rand.o: ruby_missing.h
+ossl_ssl.o: $(RUBY_EXTCONF_H)
+ossl_ssl.o: $(arch_hdrdir)/ruby/config.h
+ossl_ssl.o: $(hdrdir)/ruby/defines.h
+ossl_ssl.o: $(hdrdir)/ruby/encoding.h
+ossl_ssl.o: $(hdrdir)/ruby/intern.h
+ossl_ssl.o: $(hdrdir)/ruby/io.h
+ossl_ssl.o: $(hdrdir)/ruby/missing.h
+ossl_ssl.o: $(hdrdir)/ruby/oniguruma.h
+ossl_ssl.o: $(hdrdir)/ruby/ruby.h
+ossl_ssl.o: $(hdrdir)/ruby/st.h
+ossl_ssl.o: $(hdrdir)/ruby/subst.h
+ossl_ssl.o: $(hdrdir)/ruby/thread.h
+ossl_ssl.o: $(top_srcdir)/include/ruby.h
+ossl_ssl.o: openssl_missing.h
+ossl_ssl.o: ossl.h
+ossl_ssl.o: ossl_asn1.h
+ossl_ssl.o: ossl_bio.h
+ossl_ssl.o: ossl_bn.h
+ossl_ssl.o: ossl_cipher.h
+ossl_ssl.o: ossl_config.h
+ossl_ssl.o: ossl_digest.h
+ossl_ssl.o: ossl_engine.h
+ossl_ssl.o: ossl_hmac.h
+ossl_ssl.o: ossl_ns_spki.h
+ossl_ssl.o: ossl_ocsp.h
+ossl_ssl.o: ossl_pkcs12.h
+ossl_ssl.o: ossl_pkcs5.h
+ossl_ssl.o: ossl_pkcs7.h
+ossl_ssl.o: ossl_pkey.h
+ossl_ssl.o: ossl_rand.h
+ossl_ssl.o: ossl_ssl.c
+ossl_ssl.o: ossl_ssl.h
+ossl_ssl.o: ossl_version.h
+ossl_ssl.o: ossl_x509.h
+ossl_ssl.o: ruby_missing.h
+ossl_ssl_session.o: $(RUBY_EXTCONF_H)
+ossl_ssl_session.o: $(arch_hdrdir)/ruby/config.h
+ossl_ssl_session.o: $(hdrdir)/ruby/defines.h
+ossl_ssl_session.o: $(hdrdir)/ruby/encoding.h
+ossl_ssl_session.o: $(hdrdir)/ruby/intern.h
+ossl_ssl_session.o: $(hdrdir)/ruby/io.h
+ossl_ssl_session.o: $(hdrdir)/ruby/missing.h
+ossl_ssl_session.o: $(hdrdir)/ruby/oniguruma.h
+ossl_ssl_session.o: $(hdrdir)/ruby/ruby.h
+ossl_ssl_session.o: $(hdrdir)/ruby/st.h
+ossl_ssl_session.o: $(hdrdir)/ruby/subst.h
+ossl_ssl_session.o: $(hdrdir)/ruby/thread.h
+ossl_ssl_session.o: $(top_srcdir)/include/ruby.h
+ossl_ssl_session.o: openssl_missing.h
+ossl_ssl_session.o: ossl.h
+ossl_ssl_session.o: ossl_asn1.h
+ossl_ssl_session.o: ossl_bio.h
+ossl_ssl_session.o: ossl_bn.h
+ossl_ssl_session.o: ossl_cipher.h
+ossl_ssl_session.o: ossl_config.h
+ossl_ssl_session.o: ossl_digest.h
+ossl_ssl_session.o: ossl_engine.h
+ossl_ssl_session.o: ossl_hmac.h
+ossl_ssl_session.o: ossl_ns_spki.h
+ossl_ssl_session.o: ossl_ocsp.h
+ossl_ssl_session.o: ossl_pkcs12.h
+ossl_ssl_session.o: ossl_pkcs5.h
+ossl_ssl_session.o: ossl_pkcs7.h
+ossl_ssl_session.o: ossl_pkey.h
+ossl_ssl_session.o: ossl_rand.h
+ossl_ssl_session.o: ossl_ssl.h
+ossl_ssl_session.o: ossl_ssl_session.c
+ossl_ssl_session.o: ossl_version.h
+ossl_ssl_session.o: ossl_x509.h
+ossl_ssl_session.o: ruby_missing.h
+ossl_x509.o: $(RUBY_EXTCONF_H)
+ossl_x509.o: $(arch_hdrdir)/ruby/config.h
+ossl_x509.o: $(hdrdir)/ruby/defines.h
+ossl_x509.o: $(hdrdir)/ruby/encoding.h
+ossl_x509.o: $(hdrdir)/ruby/intern.h
+ossl_x509.o: $(hdrdir)/ruby/io.h
+ossl_x509.o: $(hdrdir)/ruby/missing.h
+ossl_x509.o: $(hdrdir)/ruby/oniguruma.h
+ossl_x509.o: $(hdrdir)/ruby/ruby.h
+ossl_x509.o: $(hdrdir)/ruby/st.h
+ossl_x509.o: $(hdrdir)/ruby/subst.h
+ossl_x509.o: $(hdrdir)/ruby/thread.h
+ossl_x509.o: $(top_srcdir)/include/ruby.h
+ossl_x509.o: openssl_missing.h
+ossl_x509.o: ossl.h
+ossl_x509.o: ossl_asn1.h
+ossl_x509.o: ossl_bio.h
+ossl_x509.o: ossl_bn.h
+ossl_x509.o: ossl_cipher.h
+ossl_x509.o: ossl_config.h
+ossl_x509.o: ossl_digest.h
+ossl_x509.o: ossl_engine.h
+ossl_x509.o: ossl_hmac.h
+ossl_x509.o: ossl_ns_spki.h
+ossl_x509.o: ossl_ocsp.h
+ossl_x509.o: ossl_pkcs12.h
+ossl_x509.o: ossl_pkcs5.h
+ossl_x509.o: ossl_pkcs7.h
+ossl_x509.o: ossl_pkey.h
+ossl_x509.o: ossl_rand.h
+ossl_x509.o: ossl_ssl.h
+ossl_x509.o: ossl_version.h
+ossl_x509.o: ossl_x509.c
+ossl_x509.o: ossl_x509.h
+ossl_x509.o: ruby_missing.h
+ossl_x509attr.o: $(RUBY_EXTCONF_H)
+ossl_x509attr.o: $(arch_hdrdir)/ruby/config.h
+ossl_x509attr.o: $(hdrdir)/ruby/defines.h
+ossl_x509attr.o: $(hdrdir)/ruby/encoding.h
+ossl_x509attr.o: $(hdrdir)/ruby/intern.h
+ossl_x509attr.o: $(hdrdir)/ruby/io.h
+ossl_x509attr.o: $(hdrdir)/ruby/missing.h
+ossl_x509attr.o: $(hdrdir)/ruby/oniguruma.h
+ossl_x509attr.o: $(hdrdir)/ruby/ruby.h
+ossl_x509attr.o: $(hdrdir)/ruby/st.h
+ossl_x509attr.o: $(hdrdir)/ruby/subst.h
+ossl_x509attr.o: $(hdrdir)/ruby/thread.h
+ossl_x509attr.o: $(top_srcdir)/include/ruby.h
+ossl_x509attr.o: openssl_missing.h
+ossl_x509attr.o: ossl.h
+ossl_x509attr.o: ossl_asn1.h
+ossl_x509attr.o: ossl_bio.h
+ossl_x509attr.o: ossl_bn.h
+ossl_x509attr.o: ossl_cipher.h
+ossl_x509attr.o: ossl_config.h
+ossl_x509attr.o: ossl_digest.h
+ossl_x509attr.o: ossl_engine.h
+ossl_x509attr.o: ossl_hmac.h
+ossl_x509attr.o: ossl_ns_spki.h
+ossl_x509attr.o: ossl_ocsp.h
+ossl_x509attr.o: ossl_pkcs12.h
+ossl_x509attr.o: ossl_pkcs5.h
+ossl_x509attr.o: ossl_pkcs7.h
+ossl_x509attr.o: ossl_pkey.h
+ossl_x509attr.o: ossl_rand.h
+ossl_x509attr.o: ossl_ssl.h
+ossl_x509attr.o: ossl_version.h
+ossl_x509attr.o: ossl_x509.h
+ossl_x509attr.o: ossl_x509attr.c
+ossl_x509attr.o: ruby_missing.h
+ossl_x509cert.o: $(RUBY_EXTCONF_H)
+ossl_x509cert.o: $(arch_hdrdir)/ruby/config.h
+ossl_x509cert.o: $(hdrdir)/ruby/defines.h
+ossl_x509cert.o: $(hdrdir)/ruby/encoding.h
+ossl_x509cert.o: $(hdrdir)/ruby/intern.h
+ossl_x509cert.o: $(hdrdir)/ruby/io.h
+ossl_x509cert.o: $(hdrdir)/ruby/missing.h
+ossl_x509cert.o: $(hdrdir)/ruby/oniguruma.h
+ossl_x509cert.o: $(hdrdir)/ruby/ruby.h
+ossl_x509cert.o: $(hdrdir)/ruby/st.h
+ossl_x509cert.o: $(hdrdir)/ruby/subst.h
+ossl_x509cert.o: $(hdrdir)/ruby/thread.h
+ossl_x509cert.o: $(top_srcdir)/include/ruby.h
+ossl_x509cert.o: openssl_missing.h
+ossl_x509cert.o: ossl.h
+ossl_x509cert.o: ossl_asn1.h
+ossl_x509cert.o: ossl_bio.h
+ossl_x509cert.o: ossl_bn.h
+ossl_x509cert.o: ossl_cipher.h
+ossl_x509cert.o: ossl_config.h
+ossl_x509cert.o: ossl_digest.h
+ossl_x509cert.o: ossl_engine.h
+ossl_x509cert.o: ossl_hmac.h
+ossl_x509cert.o: ossl_ns_spki.h
+ossl_x509cert.o: ossl_ocsp.h
+ossl_x509cert.o: ossl_pkcs12.h
+ossl_x509cert.o: ossl_pkcs5.h
+ossl_x509cert.o: ossl_pkcs7.h
+ossl_x509cert.o: ossl_pkey.h
+ossl_x509cert.o: ossl_rand.h
+ossl_x509cert.o: ossl_ssl.h
+ossl_x509cert.o: ossl_version.h
+ossl_x509cert.o: ossl_x509.h
+ossl_x509cert.o: ossl_x509cert.c
+ossl_x509cert.o: ruby_missing.h
+ossl_x509crl.o: $(RUBY_EXTCONF_H)
+ossl_x509crl.o: $(arch_hdrdir)/ruby/config.h
+ossl_x509crl.o: $(hdrdir)/ruby/defines.h
+ossl_x509crl.o: $(hdrdir)/ruby/encoding.h
+ossl_x509crl.o: $(hdrdir)/ruby/intern.h
+ossl_x509crl.o: $(hdrdir)/ruby/io.h
+ossl_x509crl.o: $(hdrdir)/ruby/missing.h
+ossl_x509crl.o: $(hdrdir)/ruby/oniguruma.h
+ossl_x509crl.o: $(hdrdir)/ruby/ruby.h
+ossl_x509crl.o: $(hdrdir)/ruby/st.h
+ossl_x509crl.o: $(hdrdir)/ruby/subst.h
+ossl_x509crl.o: $(hdrdir)/ruby/thread.h
+ossl_x509crl.o: $(top_srcdir)/include/ruby.h
+ossl_x509crl.o: openssl_missing.h
+ossl_x509crl.o: ossl.h
+ossl_x509crl.o: ossl_asn1.h
+ossl_x509crl.o: ossl_bio.h
+ossl_x509crl.o: ossl_bn.h
+ossl_x509crl.o: ossl_cipher.h
+ossl_x509crl.o: ossl_config.h
+ossl_x509crl.o: ossl_digest.h
+ossl_x509crl.o: ossl_engine.h
+ossl_x509crl.o: ossl_hmac.h
+ossl_x509crl.o: ossl_ns_spki.h
+ossl_x509crl.o: ossl_ocsp.h
+ossl_x509crl.o: ossl_pkcs12.h
+ossl_x509crl.o: ossl_pkcs5.h
+ossl_x509crl.o: ossl_pkcs7.h
+ossl_x509crl.o: ossl_pkey.h
+ossl_x509crl.o: ossl_rand.h
+ossl_x509crl.o: ossl_ssl.h
+ossl_x509crl.o: ossl_version.h
+ossl_x509crl.o: ossl_x509.h
+ossl_x509crl.o: ossl_x509crl.c
+ossl_x509crl.o: ruby_missing.h
+ossl_x509ext.o: $(RUBY_EXTCONF_H)
+ossl_x509ext.o: $(arch_hdrdir)/ruby/config.h
+ossl_x509ext.o: $(hdrdir)/ruby/defines.h
+ossl_x509ext.o: $(hdrdir)/ruby/encoding.h
+ossl_x509ext.o: $(hdrdir)/ruby/intern.h
+ossl_x509ext.o: $(hdrdir)/ruby/io.h
+ossl_x509ext.o: $(hdrdir)/ruby/missing.h
+ossl_x509ext.o: $(hdrdir)/ruby/oniguruma.h
+ossl_x509ext.o: $(hdrdir)/ruby/ruby.h
+ossl_x509ext.o: $(hdrdir)/ruby/st.h
+ossl_x509ext.o: $(hdrdir)/ruby/subst.h
+ossl_x509ext.o: $(hdrdir)/ruby/thread.h
+ossl_x509ext.o: $(top_srcdir)/include/ruby.h
+ossl_x509ext.o: openssl_missing.h
+ossl_x509ext.o: ossl.h
+ossl_x509ext.o: ossl_asn1.h
+ossl_x509ext.o: ossl_bio.h
+ossl_x509ext.o: ossl_bn.h
+ossl_x509ext.o: ossl_cipher.h
+ossl_x509ext.o: ossl_config.h
+ossl_x509ext.o: ossl_digest.h
+ossl_x509ext.o: ossl_engine.h
+ossl_x509ext.o: ossl_hmac.h
+ossl_x509ext.o: ossl_ns_spki.h
+ossl_x509ext.o: ossl_ocsp.h
+ossl_x509ext.o: ossl_pkcs12.h
+ossl_x509ext.o: ossl_pkcs5.h
+ossl_x509ext.o: ossl_pkcs7.h
+ossl_x509ext.o: ossl_pkey.h
+ossl_x509ext.o: ossl_rand.h
+ossl_x509ext.o: ossl_ssl.h
+ossl_x509ext.o: ossl_version.h
+ossl_x509ext.o: ossl_x509.h
+ossl_x509ext.o: ossl_x509ext.c
+ossl_x509ext.o: ruby_missing.h
+ossl_x509name.o: $(RUBY_EXTCONF_H)
+ossl_x509name.o: $(arch_hdrdir)/ruby/config.h
+ossl_x509name.o: $(hdrdir)/ruby/defines.h
+ossl_x509name.o: $(hdrdir)/ruby/encoding.h
+ossl_x509name.o: $(hdrdir)/ruby/intern.h
+ossl_x509name.o: $(hdrdir)/ruby/io.h
+ossl_x509name.o: $(hdrdir)/ruby/missing.h
+ossl_x509name.o: $(hdrdir)/ruby/oniguruma.h
+ossl_x509name.o: $(hdrdir)/ruby/ruby.h
+ossl_x509name.o: $(hdrdir)/ruby/st.h
+ossl_x509name.o: $(hdrdir)/ruby/subst.h
+ossl_x509name.o: $(hdrdir)/ruby/thread.h
+ossl_x509name.o: $(top_srcdir)/include/ruby.h
+ossl_x509name.o: openssl_missing.h
+ossl_x509name.o: ossl.h
+ossl_x509name.o: ossl_asn1.h
+ossl_x509name.o: ossl_bio.h
+ossl_x509name.o: ossl_bn.h
+ossl_x509name.o: ossl_cipher.h
+ossl_x509name.o: ossl_config.h
+ossl_x509name.o: ossl_digest.h
+ossl_x509name.o: ossl_engine.h
+ossl_x509name.o: ossl_hmac.h
+ossl_x509name.o: ossl_ns_spki.h
+ossl_x509name.o: ossl_ocsp.h
+ossl_x509name.o: ossl_pkcs12.h
+ossl_x509name.o: ossl_pkcs5.h
+ossl_x509name.o: ossl_pkcs7.h
+ossl_x509name.o: ossl_pkey.h
+ossl_x509name.o: ossl_rand.h
+ossl_x509name.o: ossl_ssl.h
+ossl_x509name.o: ossl_version.h
+ossl_x509name.o: ossl_x509.h
+ossl_x509name.o: ossl_x509name.c
+ossl_x509name.o: ruby_missing.h
+ossl_x509req.o: $(RUBY_EXTCONF_H)
+ossl_x509req.o: $(arch_hdrdir)/ruby/config.h
+ossl_x509req.o: $(hdrdir)/ruby/defines.h
+ossl_x509req.o: $(hdrdir)/ruby/encoding.h
+ossl_x509req.o: $(hdrdir)/ruby/intern.h
+ossl_x509req.o: $(hdrdir)/ruby/io.h
+ossl_x509req.o: $(hdrdir)/ruby/missing.h
+ossl_x509req.o: $(hdrdir)/ruby/oniguruma.h
+ossl_x509req.o: $(hdrdir)/ruby/ruby.h
+ossl_x509req.o: $(hdrdir)/ruby/st.h
+ossl_x509req.o: $(hdrdir)/ruby/subst.h
+ossl_x509req.o: $(hdrdir)/ruby/thread.h
+ossl_x509req.o: $(top_srcdir)/include/ruby.h
+ossl_x509req.o: openssl_missing.h
+ossl_x509req.o: ossl.h
+ossl_x509req.o: ossl_asn1.h
+ossl_x509req.o: ossl_bio.h
+ossl_x509req.o: ossl_bn.h
+ossl_x509req.o: ossl_cipher.h
+ossl_x509req.o: ossl_config.h
+ossl_x509req.o: ossl_digest.h
+ossl_x509req.o: ossl_engine.h
+ossl_x509req.o: ossl_hmac.h
+ossl_x509req.o: ossl_ns_spki.h
+ossl_x509req.o: ossl_ocsp.h
+ossl_x509req.o: ossl_pkcs12.h
+ossl_x509req.o: ossl_pkcs5.h
+ossl_x509req.o: ossl_pkcs7.h
+ossl_x509req.o: ossl_pkey.h
+ossl_x509req.o: ossl_rand.h
+ossl_x509req.o: ossl_ssl.h
+ossl_x509req.o: ossl_version.h
+ossl_x509req.o: ossl_x509.h
+ossl_x509req.o: ossl_x509req.c
+ossl_x509req.o: ruby_missing.h
+ossl_x509revoked.o: $(RUBY_EXTCONF_H)
+ossl_x509revoked.o: $(arch_hdrdir)/ruby/config.h
+ossl_x509revoked.o: $(hdrdir)/ruby/defines.h
+ossl_x509revoked.o: $(hdrdir)/ruby/encoding.h
+ossl_x509revoked.o: $(hdrdir)/ruby/intern.h
+ossl_x509revoked.o: $(hdrdir)/ruby/io.h
+ossl_x509revoked.o: $(hdrdir)/ruby/missing.h
+ossl_x509revoked.o: $(hdrdir)/ruby/oniguruma.h
+ossl_x509revoked.o: $(hdrdir)/ruby/ruby.h
+ossl_x509revoked.o: $(hdrdir)/ruby/st.h
+ossl_x509revoked.o: $(hdrdir)/ruby/subst.h
+ossl_x509revoked.o: $(hdrdir)/ruby/thread.h
+ossl_x509revoked.o: $(top_srcdir)/include/ruby.h
+ossl_x509revoked.o: openssl_missing.h
+ossl_x509revoked.o: ossl.h
+ossl_x509revoked.o: ossl_asn1.h
+ossl_x509revoked.o: ossl_bio.h
+ossl_x509revoked.o: ossl_bn.h
+ossl_x509revoked.o: ossl_cipher.h
+ossl_x509revoked.o: ossl_config.h
+ossl_x509revoked.o: ossl_digest.h
+ossl_x509revoked.o: ossl_engine.h
+ossl_x509revoked.o: ossl_hmac.h
+ossl_x509revoked.o: ossl_ns_spki.h
+ossl_x509revoked.o: ossl_ocsp.h
+ossl_x509revoked.o: ossl_pkcs12.h
+ossl_x509revoked.o: ossl_pkcs5.h
+ossl_x509revoked.o: ossl_pkcs7.h
+ossl_x509revoked.o: ossl_pkey.h
+ossl_x509revoked.o: ossl_rand.h
+ossl_x509revoked.o: ossl_ssl.h
+ossl_x509revoked.o: ossl_version.h
+ossl_x509revoked.o: ossl_x509.h
+ossl_x509revoked.o: ossl_x509revoked.c
+ossl_x509revoked.o: ruby_missing.h
+ossl_x509store.o: $(RUBY_EXTCONF_H)
+ossl_x509store.o: $(arch_hdrdir)/ruby/config.h
+ossl_x509store.o: $(hdrdir)/ruby/defines.h
+ossl_x509store.o: $(hdrdir)/ruby/encoding.h
+ossl_x509store.o: $(hdrdir)/ruby/intern.h
+ossl_x509store.o: $(hdrdir)/ruby/io.h
+ossl_x509store.o: $(hdrdir)/ruby/missing.h
+ossl_x509store.o: $(hdrdir)/ruby/oniguruma.h
+ossl_x509store.o: $(hdrdir)/ruby/ruby.h
+ossl_x509store.o: $(hdrdir)/ruby/st.h
+ossl_x509store.o: $(hdrdir)/ruby/subst.h
+ossl_x509store.o: $(hdrdir)/ruby/thread.h
+ossl_x509store.o: $(top_srcdir)/include/ruby.h
+ossl_x509store.o: openssl_missing.h
+ossl_x509store.o: ossl.h
+ossl_x509store.o: ossl_asn1.h
+ossl_x509store.o: ossl_bio.h
+ossl_x509store.o: ossl_bn.h
+ossl_x509store.o: ossl_cipher.h
+ossl_x509store.o: ossl_config.h
+ossl_x509store.o: ossl_digest.h
+ossl_x509store.o: ossl_engine.h
+ossl_x509store.o: ossl_hmac.h
+ossl_x509store.o: ossl_ns_spki.h
+ossl_x509store.o: ossl_ocsp.h
+ossl_x509store.o: ossl_pkcs12.h
+ossl_x509store.o: ossl_pkcs5.h
+ossl_x509store.o: ossl_pkcs7.h
+ossl_x509store.o: ossl_pkey.h
+ossl_x509store.o: ossl_rand.h
+ossl_x509store.o: ossl_ssl.h
+ossl_x509store.o: ossl_version.h
+ossl_x509store.o: ossl_x509.h
+ossl_x509store.o: ossl_x509store.c
+ossl_x509store.o: ruby_missing.h
+# AUTOGENERATED DEPENDENCIES END
diff --git a/jni/ruby/ext/openssl/depend b/jni/ruby/ext/openssl/depend
new file mode 100644
index 0000000..21ba20a
--- /dev/null
+++ b/jni/ruby/ext/openssl/depend
@@ -0,0 +1,1091 @@
+# AUTOGENERATED DEPENDENCIES START
+openssl_missing.o: $(RUBY_EXTCONF_H)
+openssl_missing.o: openssl_missing.c
+openssl_missing.o: openssl_missing.h
+ossl.o: $(RUBY_EXTCONF_H)
+ossl.o: $(arch_hdrdir)/ruby/config.h
+ossl.o: $(hdrdir)/ruby/defines.h
+ossl.o: $(hdrdir)/ruby/encoding.h
+ossl.o: $(hdrdir)/ruby/intern.h
+ossl.o: $(hdrdir)/ruby/io.h
+ossl.o: $(hdrdir)/ruby/missing.h
+ossl.o: $(hdrdir)/ruby/oniguruma.h
+ossl.o: $(hdrdir)/ruby/ruby.h
+ossl.o: $(hdrdir)/ruby/st.h
+ossl.o: $(hdrdir)/ruby/subst.h
+ossl.o: $(hdrdir)/ruby/thread.h
+ossl.o: $(hdrdir)/ruby/thread_native.h
+ossl.o: $(top_srcdir)/include/ruby.h
+ossl.o: openssl_missing.h
+ossl.o: ossl.c
+ossl.o: ossl.h
+ossl.o: ossl_asn1.h
+ossl.o: ossl_bio.h
+ossl.o: ossl_bn.h
+ossl.o: ossl_cipher.h
+ossl.o: ossl_config.h
+ossl.o: ossl_digest.h
+ossl.o: ossl_engine.h
+ossl.o: ossl_hmac.h
+ossl.o: ossl_ns_spki.h
+ossl.o: ossl_ocsp.h
+ossl.o: ossl_pkcs12.h
+ossl.o: ossl_pkcs5.h
+ossl.o: ossl_pkcs7.h
+ossl.o: ossl_pkey.h
+ossl.o: ossl_rand.h
+ossl.o: ossl_ssl.h
+ossl.o: ossl_version.h
+ossl.o: ossl_x509.h
+ossl.o: ruby_missing.h
+ossl_asn1.o: $(RUBY_EXTCONF_H)
+ossl_asn1.o: $(arch_hdrdir)/ruby/config.h
+ossl_asn1.o: $(hdrdir)/ruby/defines.h
+ossl_asn1.o: $(hdrdir)/ruby/encoding.h
+ossl_asn1.o: $(hdrdir)/ruby/intern.h
+ossl_asn1.o: $(hdrdir)/ruby/io.h
+ossl_asn1.o: $(hdrdir)/ruby/missing.h
+ossl_asn1.o: $(hdrdir)/ruby/oniguruma.h
+ossl_asn1.o: $(hdrdir)/ruby/ruby.h
+ossl_asn1.o: $(hdrdir)/ruby/st.h
+ossl_asn1.o: $(hdrdir)/ruby/subst.h
+ossl_asn1.o: $(hdrdir)/ruby/thread.h
+ossl_asn1.o: $(top_srcdir)/include/ruby.h
+ossl_asn1.o: openssl_missing.h
+ossl_asn1.o: ossl.h
+ossl_asn1.o: ossl_asn1.c
+ossl_asn1.o: ossl_asn1.h
+ossl_asn1.o: ossl_bio.h
+ossl_asn1.o: ossl_bn.h
+ossl_asn1.o: ossl_cipher.h
+ossl_asn1.o: ossl_config.h
+ossl_asn1.o: ossl_digest.h
+ossl_asn1.o: ossl_engine.h
+ossl_asn1.o: ossl_hmac.h
+ossl_asn1.o: ossl_ns_spki.h
+ossl_asn1.o: ossl_ocsp.h
+ossl_asn1.o: ossl_pkcs12.h
+ossl_asn1.o: ossl_pkcs5.h
+ossl_asn1.o: ossl_pkcs7.h
+ossl_asn1.o: ossl_pkey.h
+ossl_asn1.o: ossl_rand.h
+ossl_asn1.o: ossl_ssl.h
+ossl_asn1.o: ossl_version.h
+ossl_asn1.o: ossl_x509.h
+ossl_asn1.o: ruby_missing.h
+ossl_bio.o: $(RUBY_EXTCONF_H)
+ossl_bio.o: $(arch_hdrdir)/ruby/config.h
+ossl_bio.o: $(hdrdir)/ruby/defines.h
+ossl_bio.o: $(hdrdir)/ruby/encoding.h
+ossl_bio.o: $(hdrdir)/ruby/intern.h
+ossl_bio.o: $(hdrdir)/ruby/io.h
+ossl_bio.o: $(hdrdir)/ruby/missing.h
+ossl_bio.o: $(hdrdir)/ruby/oniguruma.h
+ossl_bio.o: $(hdrdir)/ruby/ruby.h
+ossl_bio.o: $(hdrdir)/ruby/st.h
+ossl_bio.o: $(hdrdir)/ruby/subst.h
+ossl_bio.o: $(hdrdir)/ruby/thread.h
+ossl_bio.o: $(top_srcdir)/include/ruby.h
+ossl_bio.o: openssl_missing.h
+ossl_bio.o: ossl.h
+ossl_bio.o: ossl_asn1.h
+ossl_bio.o: ossl_bio.c
+ossl_bio.o: ossl_bio.h
+ossl_bio.o: ossl_bn.h
+ossl_bio.o: ossl_cipher.h
+ossl_bio.o: ossl_config.h
+ossl_bio.o: ossl_digest.h
+ossl_bio.o: ossl_engine.h
+ossl_bio.o: ossl_hmac.h
+ossl_bio.o: ossl_ns_spki.h
+ossl_bio.o: ossl_ocsp.h
+ossl_bio.o: ossl_pkcs12.h
+ossl_bio.o: ossl_pkcs5.h
+ossl_bio.o: ossl_pkcs7.h
+ossl_bio.o: ossl_pkey.h
+ossl_bio.o: ossl_rand.h
+ossl_bio.o: ossl_ssl.h
+ossl_bio.o: ossl_version.h
+ossl_bio.o: ossl_x509.h
+ossl_bio.o: ruby_missing.h
+ossl_bn.o: $(RUBY_EXTCONF_H)
+ossl_bn.o: $(arch_hdrdir)/ruby/config.h
+ossl_bn.o: $(hdrdir)/ruby/defines.h
+ossl_bn.o: $(hdrdir)/ruby/encoding.h
+ossl_bn.o: $(hdrdir)/ruby/intern.h
+ossl_bn.o: $(hdrdir)/ruby/io.h
+ossl_bn.o: $(hdrdir)/ruby/missing.h
+ossl_bn.o: $(hdrdir)/ruby/oniguruma.h
+ossl_bn.o: $(hdrdir)/ruby/ruby.h
+ossl_bn.o: $(hdrdir)/ruby/st.h
+ossl_bn.o: $(hdrdir)/ruby/subst.h
+ossl_bn.o: $(hdrdir)/ruby/thread.h
+ossl_bn.o: $(top_srcdir)/include/ruby.h
+ossl_bn.o: openssl_missing.h
+ossl_bn.o: ossl.h
+ossl_bn.o: ossl_asn1.h
+ossl_bn.o: ossl_bio.h
+ossl_bn.o: ossl_bn.c
+ossl_bn.o: ossl_bn.h
+ossl_bn.o: ossl_cipher.h
+ossl_bn.o: ossl_config.h
+ossl_bn.o: ossl_digest.h
+ossl_bn.o: ossl_engine.h
+ossl_bn.o: ossl_hmac.h
+ossl_bn.o: ossl_ns_spki.h
+ossl_bn.o: ossl_ocsp.h
+ossl_bn.o: ossl_pkcs12.h
+ossl_bn.o: ossl_pkcs5.h
+ossl_bn.o: ossl_pkcs7.h
+ossl_bn.o: ossl_pkey.h
+ossl_bn.o: ossl_rand.h
+ossl_bn.o: ossl_ssl.h
+ossl_bn.o: ossl_version.h
+ossl_bn.o: ossl_x509.h
+ossl_bn.o: ruby_missing.h
+ossl_cipher.o: $(RUBY_EXTCONF_H)
+ossl_cipher.o: $(arch_hdrdir)/ruby/config.h
+ossl_cipher.o: $(hdrdir)/ruby/defines.h
+ossl_cipher.o: $(hdrdir)/ruby/encoding.h
+ossl_cipher.o: $(hdrdir)/ruby/intern.h
+ossl_cipher.o: $(hdrdir)/ruby/io.h
+ossl_cipher.o: $(hdrdir)/ruby/missing.h
+ossl_cipher.o: $(hdrdir)/ruby/oniguruma.h
+ossl_cipher.o: $(hdrdir)/ruby/ruby.h
+ossl_cipher.o: $(hdrdir)/ruby/st.h
+ossl_cipher.o: $(hdrdir)/ruby/subst.h
+ossl_cipher.o: $(hdrdir)/ruby/thread.h
+ossl_cipher.o: $(top_srcdir)/include/ruby.h
+ossl_cipher.o: openssl_missing.h
+ossl_cipher.o: ossl.h
+ossl_cipher.o: ossl_asn1.h
+ossl_cipher.o: ossl_bio.h
+ossl_cipher.o: ossl_bn.h
+ossl_cipher.o: ossl_cipher.c
+ossl_cipher.o: ossl_cipher.h
+ossl_cipher.o: ossl_config.h
+ossl_cipher.o: ossl_digest.h
+ossl_cipher.o: ossl_engine.h
+ossl_cipher.o: ossl_hmac.h
+ossl_cipher.o: ossl_ns_spki.h
+ossl_cipher.o: ossl_ocsp.h
+ossl_cipher.o: ossl_pkcs12.h
+ossl_cipher.o: ossl_pkcs5.h
+ossl_cipher.o: ossl_pkcs7.h
+ossl_cipher.o: ossl_pkey.h
+ossl_cipher.o: ossl_rand.h
+ossl_cipher.o: ossl_ssl.h
+ossl_cipher.o: ossl_version.h
+ossl_cipher.o: ossl_x509.h
+ossl_cipher.o: ruby_missing.h
+ossl_config.o: $(RUBY_EXTCONF_H)
+ossl_config.o: $(arch_hdrdir)/ruby/config.h
+ossl_config.o: $(hdrdir)/ruby/defines.h
+ossl_config.o: $(hdrdir)/ruby/encoding.h
+ossl_config.o: $(hdrdir)/ruby/intern.h
+ossl_config.o: $(hdrdir)/ruby/io.h
+ossl_config.o: $(hdrdir)/ruby/missing.h
+ossl_config.o: $(hdrdir)/ruby/oniguruma.h
+ossl_config.o: $(hdrdir)/ruby/ruby.h
+ossl_config.o: $(hdrdir)/ruby/st.h
+ossl_config.o: $(hdrdir)/ruby/subst.h
+ossl_config.o: $(hdrdir)/ruby/thread.h
+ossl_config.o: $(top_srcdir)/include/ruby.h
+ossl_config.o: openssl_missing.h
+ossl_config.o: ossl.h
+ossl_config.o: ossl_asn1.h
+ossl_config.o: ossl_bio.h
+ossl_config.o: ossl_bn.h
+ossl_config.o: ossl_cipher.h
+ossl_config.o: ossl_config.c
+ossl_config.o: ossl_config.h
+ossl_config.o: ossl_digest.h
+ossl_config.o: ossl_engine.h
+ossl_config.o: ossl_hmac.h
+ossl_config.o: ossl_ns_spki.h
+ossl_config.o: ossl_ocsp.h
+ossl_config.o: ossl_pkcs12.h
+ossl_config.o: ossl_pkcs5.h
+ossl_config.o: ossl_pkcs7.h
+ossl_config.o: ossl_pkey.h
+ossl_config.o: ossl_rand.h
+ossl_config.o: ossl_ssl.h
+ossl_config.o: ossl_version.h
+ossl_config.o: ossl_x509.h
+ossl_config.o: ruby_missing.h
+ossl_digest.o: $(RUBY_EXTCONF_H)
+ossl_digest.o: $(arch_hdrdir)/ruby/config.h
+ossl_digest.o: $(hdrdir)/ruby/defines.h
+ossl_digest.o: $(hdrdir)/ruby/encoding.h
+ossl_digest.o: $(hdrdir)/ruby/intern.h
+ossl_digest.o: $(hdrdir)/ruby/io.h
+ossl_digest.o: $(hdrdir)/ruby/missing.h
+ossl_digest.o: $(hdrdir)/ruby/oniguruma.h
+ossl_digest.o: $(hdrdir)/ruby/ruby.h
+ossl_digest.o: $(hdrdir)/ruby/st.h
+ossl_digest.o: $(hdrdir)/ruby/subst.h
+ossl_digest.o: $(hdrdir)/ruby/thread.h
+ossl_digest.o: $(top_srcdir)/include/ruby.h
+ossl_digest.o: openssl_missing.h
+ossl_digest.o: ossl.h
+ossl_digest.o: ossl_asn1.h
+ossl_digest.o: ossl_bio.h
+ossl_digest.o: ossl_bn.h
+ossl_digest.o: ossl_cipher.h
+ossl_digest.o: ossl_config.h
+ossl_digest.o: ossl_digest.c
+ossl_digest.o: ossl_digest.h
+ossl_digest.o: ossl_engine.h
+ossl_digest.o: ossl_hmac.h
+ossl_digest.o: ossl_ns_spki.h
+ossl_digest.o: ossl_ocsp.h
+ossl_digest.o: ossl_pkcs12.h
+ossl_digest.o: ossl_pkcs5.h
+ossl_digest.o: ossl_pkcs7.h
+ossl_digest.o: ossl_pkey.h
+ossl_digest.o: ossl_rand.h
+ossl_digest.o: ossl_ssl.h
+ossl_digest.o: ossl_version.h
+ossl_digest.o: ossl_x509.h
+ossl_digest.o: ruby_missing.h
+ossl_engine.o: $(RUBY_EXTCONF_H)
+ossl_engine.o: $(arch_hdrdir)/ruby/config.h
+ossl_engine.o: $(hdrdir)/ruby/defines.h
+ossl_engine.o: $(hdrdir)/ruby/encoding.h
+ossl_engine.o: $(hdrdir)/ruby/intern.h
+ossl_engine.o: $(hdrdir)/ruby/io.h
+ossl_engine.o: $(hdrdir)/ruby/missing.h
+ossl_engine.o: $(hdrdir)/ruby/oniguruma.h
+ossl_engine.o: $(hdrdir)/ruby/ruby.h
+ossl_engine.o: $(hdrdir)/ruby/st.h
+ossl_engine.o: $(hdrdir)/ruby/subst.h
+ossl_engine.o: $(hdrdir)/ruby/thread.h
+ossl_engine.o: $(top_srcdir)/include/ruby.h
+ossl_engine.o: openssl_missing.h
+ossl_engine.o: ossl.h
+ossl_engine.o: ossl_asn1.h
+ossl_engine.o: ossl_bio.h
+ossl_engine.o: ossl_bn.h
+ossl_engine.o: ossl_cipher.h
+ossl_engine.o: ossl_config.h
+ossl_engine.o: ossl_digest.h
+ossl_engine.o: ossl_engine.c
+ossl_engine.o: ossl_engine.h
+ossl_engine.o: ossl_hmac.h
+ossl_engine.o: ossl_ns_spki.h
+ossl_engine.o: ossl_ocsp.h
+ossl_engine.o: ossl_pkcs12.h
+ossl_engine.o: ossl_pkcs5.h
+ossl_engine.o: ossl_pkcs7.h
+ossl_engine.o: ossl_pkey.h
+ossl_engine.o: ossl_rand.h
+ossl_engine.o: ossl_ssl.h
+ossl_engine.o: ossl_version.h
+ossl_engine.o: ossl_x509.h
+ossl_engine.o: ruby_missing.h
+ossl_hmac.o: $(RUBY_EXTCONF_H)
+ossl_hmac.o: $(arch_hdrdir)/ruby/config.h
+ossl_hmac.o: $(hdrdir)/ruby/defines.h
+ossl_hmac.o: $(hdrdir)/ruby/encoding.h
+ossl_hmac.o: $(hdrdir)/ruby/intern.h
+ossl_hmac.o: $(hdrdir)/ruby/io.h
+ossl_hmac.o: $(hdrdir)/ruby/missing.h
+ossl_hmac.o: $(hdrdir)/ruby/oniguruma.h
+ossl_hmac.o: $(hdrdir)/ruby/ruby.h
+ossl_hmac.o: $(hdrdir)/ruby/st.h
+ossl_hmac.o: $(hdrdir)/ruby/subst.h
+ossl_hmac.o: $(hdrdir)/ruby/thread.h
+ossl_hmac.o: $(top_srcdir)/include/ruby.h
+ossl_hmac.o: openssl_missing.h
+ossl_hmac.o: ossl.h
+ossl_hmac.o: ossl_asn1.h
+ossl_hmac.o: ossl_bio.h
+ossl_hmac.o: ossl_bn.h
+ossl_hmac.o: ossl_cipher.h
+ossl_hmac.o: ossl_config.h
+ossl_hmac.o: ossl_digest.h
+ossl_hmac.o: ossl_engine.h
+ossl_hmac.o: ossl_hmac.c
+ossl_hmac.o: ossl_hmac.h
+ossl_hmac.o: ossl_ns_spki.h
+ossl_hmac.o: ossl_ocsp.h
+ossl_hmac.o: ossl_pkcs12.h
+ossl_hmac.o: ossl_pkcs5.h
+ossl_hmac.o: ossl_pkcs7.h
+ossl_hmac.o: ossl_pkey.h
+ossl_hmac.o: ossl_rand.h
+ossl_hmac.o: ossl_ssl.h
+ossl_hmac.o: ossl_version.h
+ossl_hmac.o: ossl_x509.h
+ossl_hmac.o: ruby_missing.h
+ossl_ns_spki.o: $(RUBY_EXTCONF_H)
+ossl_ns_spki.o: $(arch_hdrdir)/ruby/config.h
+ossl_ns_spki.o: $(hdrdir)/ruby/defines.h
+ossl_ns_spki.o: $(hdrdir)/ruby/encoding.h
+ossl_ns_spki.o: $(hdrdir)/ruby/intern.h
+ossl_ns_spki.o: $(hdrdir)/ruby/io.h
+ossl_ns_spki.o: $(hdrdir)/ruby/missing.h
+ossl_ns_spki.o: $(hdrdir)/ruby/oniguruma.h
+ossl_ns_spki.o: $(hdrdir)/ruby/ruby.h
+ossl_ns_spki.o: $(hdrdir)/ruby/st.h
+ossl_ns_spki.o: $(hdrdir)/ruby/subst.h
+ossl_ns_spki.o: $(hdrdir)/ruby/thread.h
+ossl_ns_spki.o: $(top_srcdir)/include/ruby.h
+ossl_ns_spki.o: openssl_missing.h
+ossl_ns_spki.o: ossl.h
+ossl_ns_spki.o: ossl_asn1.h
+ossl_ns_spki.o: ossl_bio.h
+ossl_ns_spki.o: ossl_bn.h
+ossl_ns_spki.o: ossl_cipher.h
+ossl_ns_spki.o: ossl_config.h
+ossl_ns_spki.o: ossl_digest.h
+ossl_ns_spki.o: ossl_engine.h
+ossl_ns_spki.o: ossl_hmac.h
+ossl_ns_spki.o: ossl_ns_spki.c
+ossl_ns_spki.o: ossl_ns_spki.h
+ossl_ns_spki.o: ossl_ocsp.h
+ossl_ns_spki.o: ossl_pkcs12.h
+ossl_ns_spki.o: ossl_pkcs5.h
+ossl_ns_spki.o: ossl_pkcs7.h
+ossl_ns_spki.o: ossl_pkey.h
+ossl_ns_spki.o: ossl_rand.h
+ossl_ns_spki.o: ossl_ssl.h
+ossl_ns_spki.o: ossl_version.h
+ossl_ns_spki.o: ossl_x509.h
+ossl_ns_spki.o: ruby_missing.h
+ossl_ocsp.o: $(RUBY_EXTCONF_H)
+ossl_ocsp.o: $(arch_hdrdir)/ruby/config.h
+ossl_ocsp.o: $(hdrdir)/ruby/defines.h
+ossl_ocsp.o: $(hdrdir)/ruby/encoding.h
+ossl_ocsp.o: $(hdrdir)/ruby/intern.h
+ossl_ocsp.o: $(hdrdir)/ruby/io.h
+ossl_ocsp.o: $(hdrdir)/ruby/missing.h
+ossl_ocsp.o: $(hdrdir)/ruby/oniguruma.h
+ossl_ocsp.o: $(hdrdir)/ruby/ruby.h
+ossl_ocsp.o: $(hdrdir)/ruby/st.h
+ossl_ocsp.o: $(hdrdir)/ruby/subst.h
+ossl_ocsp.o: $(hdrdir)/ruby/thread.h
+ossl_ocsp.o: $(top_srcdir)/include/ruby.h
+ossl_ocsp.o: openssl_missing.h
+ossl_ocsp.o: ossl.h
+ossl_ocsp.o: ossl_asn1.h
+ossl_ocsp.o: ossl_bio.h
+ossl_ocsp.o: ossl_bn.h
+ossl_ocsp.o: ossl_cipher.h
+ossl_ocsp.o: ossl_config.h
+ossl_ocsp.o: ossl_digest.h
+ossl_ocsp.o: ossl_engine.h
+ossl_ocsp.o: ossl_hmac.h
+ossl_ocsp.o: ossl_ns_spki.h
+ossl_ocsp.o: ossl_ocsp.c
+ossl_ocsp.o: ossl_ocsp.h
+ossl_ocsp.o: ossl_pkcs12.h
+ossl_ocsp.o: ossl_pkcs5.h
+ossl_ocsp.o: ossl_pkcs7.h
+ossl_ocsp.o: ossl_pkey.h
+ossl_ocsp.o: ossl_rand.h
+ossl_ocsp.o: ossl_ssl.h
+ossl_ocsp.o: ossl_version.h
+ossl_ocsp.o: ossl_x509.h
+ossl_ocsp.o: ruby_missing.h
+ossl_pkcs12.o: $(RUBY_EXTCONF_H)
+ossl_pkcs12.o: $(arch_hdrdir)/ruby/config.h
+ossl_pkcs12.o: $(hdrdir)/ruby/defines.h
+ossl_pkcs12.o: $(hdrdir)/ruby/encoding.h
+ossl_pkcs12.o: $(hdrdir)/ruby/intern.h
+ossl_pkcs12.o: $(hdrdir)/ruby/io.h
+ossl_pkcs12.o: $(hdrdir)/ruby/missing.h
+ossl_pkcs12.o: $(hdrdir)/ruby/oniguruma.h
+ossl_pkcs12.o: $(hdrdir)/ruby/ruby.h
+ossl_pkcs12.o: $(hdrdir)/ruby/st.h
+ossl_pkcs12.o: $(hdrdir)/ruby/subst.h
+ossl_pkcs12.o: $(hdrdir)/ruby/thread.h
+ossl_pkcs12.o: $(top_srcdir)/include/ruby.h
+ossl_pkcs12.o: openssl_missing.h
+ossl_pkcs12.o: ossl.h
+ossl_pkcs12.o: ossl_asn1.h
+ossl_pkcs12.o: ossl_bio.h
+ossl_pkcs12.o: ossl_bn.h
+ossl_pkcs12.o: ossl_cipher.h
+ossl_pkcs12.o: ossl_config.h
+ossl_pkcs12.o: ossl_digest.h
+ossl_pkcs12.o: ossl_engine.h
+ossl_pkcs12.o: ossl_hmac.h
+ossl_pkcs12.o: ossl_ns_spki.h
+ossl_pkcs12.o: ossl_ocsp.h
+ossl_pkcs12.o: ossl_pkcs12.c
+ossl_pkcs12.o: ossl_pkcs12.h
+ossl_pkcs12.o: ossl_pkcs5.h
+ossl_pkcs12.o: ossl_pkcs7.h
+ossl_pkcs12.o: ossl_pkey.h
+ossl_pkcs12.o: ossl_rand.h
+ossl_pkcs12.o: ossl_ssl.h
+ossl_pkcs12.o: ossl_version.h
+ossl_pkcs12.o: ossl_x509.h
+ossl_pkcs12.o: ruby_missing.h
+ossl_pkcs5.o: $(RUBY_EXTCONF_H)
+ossl_pkcs5.o: $(arch_hdrdir)/ruby/config.h
+ossl_pkcs5.o: $(hdrdir)/ruby/defines.h
+ossl_pkcs5.o: $(hdrdir)/ruby/encoding.h
+ossl_pkcs5.o: $(hdrdir)/ruby/intern.h
+ossl_pkcs5.o: $(hdrdir)/ruby/io.h
+ossl_pkcs5.o: $(hdrdir)/ruby/missing.h
+ossl_pkcs5.o: $(hdrdir)/ruby/oniguruma.h
+ossl_pkcs5.o: $(hdrdir)/ruby/ruby.h
+ossl_pkcs5.o: $(hdrdir)/ruby/st.h
+ossl_pkcs5.o: $(hdrdir)/ruby/subst.h
+ossl_pkcs5.o: $(hdrdir)/ruby/thread.h
+ossl_pkcs5.o: $(top_srcdir)/include/ruby.h
+ossl_pkcs5.o: openssl_missing.h
+ossl_pkcs5.o: ossl.h
+ossl_pkcs5.o: ossl_asn1.h
+ossl_pkcs5.o: ossl_bio.h
+ossl_pkcs5.o: ossl_bn.h
+ossl_pkcs5.o: ossl_cipher.h
+ossl_pkcs5.o: ossl_config.h
+ossl_pkcs5.o: ossl_digest.h
+ossl_pkcs5.o: ossl_engine.h
+ossl_pkcs5.o: ossl_hmac.h
+ossl_pkcs5.o: ossl_ns_spki.h
+ossl_pkcs5.o: ossl_ocsp.h
+ossl_pkcs5.o: ossl_pkcs12.h
+ossl_pkcs5.o: ossl_pkcs5.c
+ossl_pkcs5.o: ossl_pkcs5.h
+ossl_pkcs5.o: ossl_pkcs7.h
+ossl_pkcs5.o: ossl_pkey.h
+ossl_pkcs5.o: ossl_rand.h
+ossl_pkcs5.o: ossl_ssl.h
+ossl_pkcs5.o: ossl_version.h
+ossl_pkcs5.o: ossl_x509.h
+ossl_pkcs5.o: ruby_missing.h
+ossl_pkcs7.o: $(RUBY_EXTCONF_H)
+ossl_pkcs7.o: $(arch_hdrdir)/ruby/config.h
+ossl_pkcs7.o: $(hdrdir)/ruby/defines.h
+ossl_pkcs7.o: $(hdrdir)/ruby/encoding.h
+ossl_pkcs7.o: $(hdrdir)/ruby/intern.h
+ossl_pkcs7.o: $(hdrdir)/ruby/io.h
+ossl_pkcs7.o: $(hdrdir)/ruby/missing.h
+ossl_pkcs7.o: $(hdrdir)/ruby/oniguruma.h
+ossl_pkcs7.o: $(hdrdir)/ruby/ruby.h
+ossl_pkcs7.o: $(hdrdir)/ruby/st.h
+ossl_pkcs7.o: $(hdrdir)/ruby/subst.h
+ossl_pkcs7.o: $(hdrdir)/ruby/thread.h
+ossl_pkcs7.o: $(top_srcdir)/include/ruby.h
+ossl_pkcs7.o: openssl_missing.h
+ossl_pkcs7.o: ossl.h
+ossl_pkcs7.o: ossl_asn1.h
+ossl_pkcs7.o: ossl_bio.h
+ossl_pkcs7.o: ossl_bn.h
+ossl_pkcs7.o: ossl_cipher.h
+ossl_pkcs7.o: ossl_config.h
+ossl_pkcs7.o: ossl_digest.h
+ossl_pkcs7.o: ossl_engine.h
+ossl_pkcs7.o: ossl_hmac.h
+ossl_pkcs7.o: ossl_ns_spki.h
+ossl_pkcs7.o: ossl_ocsp.h
+ossl_pkcs7.o: ossl_pkcs12.h
+ossl_pkcs7.o: ossl_pkcs5.h
+ossl_pkcs7.o: ossl_pkcs7.c
+ossl_pkcs7.o: ossl_pkcs7.h
+ossl_pkcs7.o: ossl_pkey.h
+ossl_pkcs7.o: ossl_rand.h
+ossl_pkcs7.o: ossl_ssl.h
+ossl_pkcs7.o: ossl_version.h
+ossl_pkcs7.o: ossl_x509.h
+ossl_pkcs7.o: ruby_missing.h
+ossl_pkey.o: $(RUBY_EXTCONF_H)
+ossl_pkey.o: $(arch_hdrdir)/ruby/config.h
+ossl_pkey.o: $(hdrdir)/ruby/defines.h
+ossl_pkey.o: $(hdrdir)/ruby/encoding.h
+ossl_pkey.o: $(hdrdir)/ruby/intern.h
+ossl_pkey.o: $(hdrdir)/ruby/io.h
+ossl_pkey.o: $(hdrdir)/ruby/missing.h
+ossl_pkey.o: $(hdrdir)/ruby/oniguruma.h
+ossl_pkey.o: $(hdrdir)/ruby/ruby.h
+ossl_pkey.o: $(hdrdir)/ruby/st.h
+ossl_pkey.o: $(hdrdir)/ruby/subst.h
+ossl_pkey.o: $(hdrdir)/ruby/thread.h
+ossl_pkey.o: $(top_srcdir)/include/ruby.h
+ossl_pkey.o: openssl_missing.h
+ossl_pkey.o: ossl.h
+ossl_pkey.o: ossl_asn1.h
+ossl_pkey.o: ossl_bio.h
+ossl_pkey.o: ossl_bn.h
+ossl_pkey.o: ossl_cipher.h
+ossl_pkey.o: ossl_config.h
+ossl_pkey.o: ossl_digest.h
+ossl_pkey.o: ossl_engine.h
+ossl_pkey.o: ossl_hmac.h
+ossl_pkey.o: ossl_ns_spki.h
+ossl_pkey.o: ossl_ocsp.h
+ossl_pkey.o: ossl_pkcs12.h
+ossl_pkey.o: ossl_pkcs5.h
+ossl_pkey.o: ossl_pkcs7.h
+ossl_pkey.o: ossl_pkey.c
+ossl_pkey.o: ossl_pkey.h
+ossl_pkey.o: ossl_rand.h
+ossl_pkey.o: ossl_ssl.h
+ossl_pkey.o: ossl_version.h
+ossl_pkey.o: ossl_x509.h
+ossl_pkey.o: ruby_missing.h
+ossl_pkey_dh.o: $(RUBY_EXTCONF_H)
+ossl_pkey_dh.o: $(arch_hdrdir)/ruby/config.h
+ossl_pkey_dh.o: $(hdrdir)/ruby/defines.h
+ossl_pkey_dh.o: $(hdrdir)/ruby/encoding.h
+ossl_pkey_dh.o: $(hdrdir)/ruby/intern.h
+ossl_pkey_dh.o: $(hdrdir)/ruby/io.h
+ossl_pkey_dh.o: $(hdrdir)/ruby/missing.h
+ossl_pkey_dh.o: $(hdrdir)/ruby/oniguruma.h
+ossl_pkey_dh.o: $(hdrdir)/ruby/ruby.h
+ossl_pkey_dh.o: $(hdrdir)/ruby/st.h
+ossl_pkey_dh.o: $(hdrdir)/ruby/subst.h
+ossl_pkey_dh.o: $(hdrdir)/ruby/thread.h
+ossl_pkey_dh.o: $(top_srcdir)/include/ruby.h
+ossl_pkey_dh.o: openssl_missing.h
+ossl_pkey_dh.o: ossl.h
+ossl_pkey_dh.o: ossl_asn1.h
+ossl_pkey_dh.o: ossl_bio.h
+ossl_pkey_dh.o: ossl_bn.h
+ossl_pkey_dh.o: ossl_cipher.h
+ossl_pkey_dh.o: ossl_config.h
+ossl_pkey_dh.o: ossl_digest.h
+ossl_pkey_dh.o: ossl_engine.h
+ossl_pkey_dh.o: ossl_hmac.h
+ossl_pkey_dh.o: ossl_ns_spki.h
+ossl_pkey_dh.o: ossl_ocsp.h
+ossl_pkey_dh.o: ossl_pkcs12.h
+ossl_pkey_dh.o: ossl_pkcs5.h
+ossl_pkey_dh.o: ossl_pkcs7.h
+ossl_pkey_dh.o: ossl_pkey.h
+ossl_pkey_dh.o: ossl_pkey_dh.c
+ossl_pkey_dh.o: ossl_rand.h
+ossl_pkey_dh.o: ossl_ssl.h
+ossl_pkey_dh.o: ossl_version.h
+ossl_pkey_dh.o: ossl_x509.h
+ossl_pkey_dh.o: ruby_missing.h
+ossl_pkey_dsa.o: $(RUBY_EXTCONF_H)
+ossl_pkey_dsa.o: $(arch_hdrdir)/ruby/config.h
+ossl_pkey_dsa.o: $(hdrdir)/ruby/defines.h
+ossl_pkey_dsa.o: $(hdrdir)/ruby/encoding.h
+ossl_pkey_dsa.o: $(hdrdir)/ruby/intern.h
+ossl_pkey_dsa.o: $(hdrdir)/ruby/io.h
+ossl_pkey_dsa.o: $(hdrdir)/ruby/missing.h
+ossl_pkey_dsa.o: $(hdrdir)/ruby/oniguruma.h
+ossl_pkey_dsa.o: $(hdrdir)/ruby/ruby.h
+ossl_pkey_dsa.o: $(hdrdir)/ruby/st.h
+ossl_pkey_dsa.o: $(hdrdir)/ruby/subst.h
+ossl_pkey_dsa.o: $(hdrdir)/ruby/thread.h
+ossl_pkey_dsa.o: $(top_srcdir)/include/ruby.h
+ossl_pkey_dsa.o: openssl_missing.h
+ossl_pkey_dsa.o: ossl.h
+ossl_pkey_dsa.o: ossl_asn1.h
+ossl_pkey_dsa.o: ossl_bio.h
+ossl_pkey_dsa.o: ossl_bn.h
+ossl_pkey_dsa.o: ossl_cipher.h
+ossl_pkey_dsa.o: ossl_config.h
+ossl_pkey_dsa.o: ossl_digest.h
+ossl_pkey_dsa.o: ossl_engine.h
+ossl_pkey_dsa.o: ossl_hmac.h
+ossl_pkey_dsa.o: ossl_ns_spki.h
+ossl_pkey_dsa.o: ossl_ocsp.h
+ossl_pkey_dsa.o: ossl_pkcs12.h
+ossl_pkey_dsa.o: ossl_pkcs5.h
+ossl_pkey_dsa.o: ossl_pkcs7.h
+ossl_pkey_dsa.o: ossl_pkey.h
+ossl_pkey_dsa.o: ossl_pkey_dsa.c
+ossl_pkey_dsa.o: ossl_rand.h
+ossl_pkey_dsa.o: ossl_ssl.h
+ossl_pkey_dsa.o: ossl_version.h
+ossl_pkey_dsa.o: ossl_x509.h
+ossl_pkey_dsa.o: ruby_missing.h
+ossl_pkey_ec.o: $(RUBY_EXTCONF_H)
+ossl_pkey_ec.o: $(arch_hdrdir)/ruby/config.h
+ossl_pkey_ec.o: $(hdrdir)/ruby/defines.h
+ossl_pkey_ec.o: $(hdrdir)/ruby/encoding.h
+ossl_pkey_ec.o: $(hdrdir)/ruby/intern.h
+ossl_pkey_ec.o: $(hdrdir)/ruby/io.h
+ossl_pkey_ec.o: $(hdrdir)/ruby/missing.h
+ossl_pkey_ec.o: $(hdrdir)/ruby/oniguruma.h
+ossl_pkey_ec.o: $(hdrdir)/ruby/ruby.h
+ossl_pkey_ec.o: $(hdrdir)/ruby/st.h
+ossl_pkey_ec.o: $(hdrdir)/ruby/subst.h
+ossl_pkey_ec.o: $(hdrdir)/ruby/thread.h
+ossl_pkey_ec.o: $(top_srcdir)/include/ruby.h
+ossl_pkey_ec.o: openssl_missing.h
+ossl_pkey_ec.o: ossl.h
+ossl_pkey_ec.o: ossl_asn1.h
+ossl_pkey_ec.o: ossl_bio.h
+ossl_pkey_ec.o: ossl_bn.h
+ossl_pkey_ec.o: ossl_cipher.h
+ossl_pkey_ec.o: ossl_config.h
+ossl_pkey_ec.o: ossl_digest.h
+ossl_pkey_ec.o: ossl_engine.h
+ossl_pkey_ec.o: ossl_hmac.h
+ossl_pkey_ec.o: ossl_ns_spki.h
+ossl_pkey_ec.o: ossl_ocsp.h
+ossl_pkey_ec.o: ossl_pkcs12.h
+ossl_pkey_ec.o: ossl_pkcs5.h
+ossl_pkey_ec.o: ossl_pkcs7.h
+ossl_pkey_ec.o: ossl_pkey.h
+ossl_pkey_ec.o: ossl_pkey_ec.c
+ossl_pkey_ec.o: ossl_rand.h
+ossl_pkey_ec.o: ossl_ssl.h
+ossl_pkey_ec.o: ossl_version.h
+ossl_pkey_ec.o: ossl_x509.h
+ossl_pkey_ec.o: ruby_missing.h
+ossl_pkey_rsa.o: $(RUBY_EXTCONF_H)
+ossl_pkey_rsa.o: $(arch_hdrdir)/ruby/config.h
+ossl_pkey_rsa.o: $(hdrdir)/ruby/defines.h
+ossl_pkey_rsa.o: $(hdrdir)/ruby/encoding.h
+ossl_pkey_rsa.o: $(hdrdir)/ruby/intern.h
+ossl_pkey_rsa.o: $(hdrdir)/ruby/io.h
+ossl_pkey_rsa.o: $(hdrdir)/ruby/missing.h
+ossl_pkey_rsa.o: $(hdrdir)/ruby/oniguruma.h
+ossl_pkey_rsa.o: $(hdrdir)/ruby/ruby.h
+ossl_pkey_rsa.o: $(hdrdir)/ruby/st.h
+ossl_pkey_rsa.o: $(hdrdir)/ruby/subst.h
+ossl_pkey_rsa.o: $(hdrdir)/ruby/thread.h
+ossl_pkey_rsa.o: $(top_srcdir)/include/ruby.h
+ossl_pkey_rsa.o: openssl_missing.h
+ossl_pkey_rsa.o: ossl.h
+ossl_pkey_rsa.o: ossl_asn1.h
+ossl_pkey_rsa.o: ossl_bio.h
+ossl_pkey_rsa.o: ossl_bn.h
+ossl_pkey_rsa.o: ossl_cipher.h
+ossl_pkey_rsa.o: ossl_config.h
+ossl_pkey_rsa.o: ossl_digest.h
+ossl_pkey_rsa.o: ossl_engine.h
+ossl_pkey_rsa.o: ossl_hmac.h
+ossl_pkey_rsa.o: ossl_ns_spki.h
+ossl_pkey_rsa.o: ossl_ocsp.h
+ossl_pkey_rsa.o: ossl_pkcs12.h
+ossl_pkey_rsa.o: ossl_pkcs5.h
+ossl_pkey_rsa.o: ossl_pkcs7.h
+ossl_pkey_rsa.o: ossl_pkey.h
+ossl_pkey_rsa.o: ossl_pkey_rsa.c
+ossl_pkey_rsa.o: ossl_rand.h
+ossl_pkey_rsa.o: ossl_ssl.h
+ossl_pkey_rsa.o: ossl_version.h
+ossl_pkey_rsa.o: ossl_x509.h
+ossl_pkey_rsa.o: ruby_missing.h
+ossl_rand.o: $(RUBY_EXTCONF_H)
+ossl_rand.o: $(arch_hdrdir)/ruby/config.h
+ossl_rand.o: $(hdrdir)/ruby/defines.h
+ossl_rand.o: $(hdrdir)/ruby/encoding.h
+ossl_rand.o: $(hdrdir)/ruby/intern.h
+ossl_rand.o: $(hdrdir)/ruby/io.h
+ossl_rand.o: $(hdrdir)/ruby/missing.h
+ossl_rand.o: $(hdrdir)/ruby/oniguruma.h
+ossl_rand.o: $(hdrdir)/ruby/ruby.h
+ossl_rand.o: $(hdrdir)/ruby/st.h
+ossl_rand.o: $(hdrdir)/ruby/subst.h
+ossl_rand.o: $(hdrdir)/ruby/thread.h
+ossl_rand.o: $(top_srcdir)/include/ruby.h
+ossl_rand.o: openssl_missing.h
+ossl_rand.o: ossl.h
+ossl_rand.o: ossl_asn1.h
+ossl_rand.o: ossl_bio.h
+ossl_rand.o: ossl_bn.h
+ossl_rand.o: ossl_cipher.h
+ossl_rand.o: ossl_config.h
+ossl_rand.o: ossl_digest.h
+ossl_rand.o: ossl_engine.h
+ossl_rand.o: ossl_hmac.h
+ossl_rand.o: ossl_ns_spki.h
+ossl_rand.o: ossl_ocsp.h
+ossl_rand.o: ossl_pkcs12.h
+ossl_rand.o: ossl_pkcs5.h
+ossl_rand.o: ossl_pkcs7.h
+ossl_rand.o: ossl_pkey.h
+ossl_rand.o: ossl_rand.c
+ossl_rand.o: ossl_rand.h
+ossl_rand.o: ossl_ssl.h
+ossl_rand.o: ossl_version.h
+ossl_rand.o: ossl_x509.h
+ossl_rand.o: ruby_missing.h
+ossl_ssl.o: $(RUBY_EXTCONF_H)
+ossl_ssl.o: $(arch_hdrdir)/ruby/config.h
+ossl_ssl.o: $(hdrdir)/ruby/defines.h
+ossl_ssl.o: $(hdrdir)/ruby/encoding.h
+ossl_ssl.o: $(hdrdir)/ruby/intern.h
+ossl_ssl.o: $(hdrdir)/ruby/io.h
+ossl_ssl.o: $(hdrdir)/ruby/missing.h
+ossl_ssl.o: $(hdrdir)/ruby/oniguruma.h
+ossl_ssl.o: $(hdrdir)/ruby/ruby.h
+ossl_ssl.o: $(hdrdir)/ruby/st.h
+ossl_ssl.o: $(hdrdir)/ruby/subst.h
+ossl_ssl.o: $(hdrdir)/ruby/thread.h
+ossl_ssl.o: $(top_srcdir)/include/ruby.h
+ossl_ssl.o: openssl_missing.h
+ossl_ssl.o: ossl.h
+ossl_ssl.o: ossl_asn1.h
+ossl_ssl.o: ossl_bio.h
+ossl_ssl.o: ossl_bn.h
+ossl_ssl.o: ossl_cipher.h
+ossl_ssl.o: ossl_config.h
+ossl_ssl.o: ossl_digest.h
+ossl_ssl.o: ossl_engine.h
+ossl_ssl.o: ossl_hmac.h
+ossl_ssl.o: ossl_ns_spki.h
+ossl_ssl.o: ossl_ocsp.h
+ossl_ssl.o: ossl_pkcs12.h
+ossl_ssl.o: ossl_pkcs5.h
+ossl_ssl.o: ossl_pkcs7.h
+ossl_ssl.o: ossl_pkey.h
+ossl_ssl.o: ossl_rand.h
+ossl_ssl.o: ossl_ssl.c
+ossl_ssl.o: ossl_ssl.h
+ossl_ssl.o: ossl_version.h
+ossl_ssl.o: ossl_x509.h
+ossl_ssl.o: ruby_missing.h
+ossl_ssl_session.o: $(RUBY_EXTCONF_H)
+ossl_ssl_session.o: $(arch_hdrdir)/ruby/config.h
+ossl_ssl_session.o: $(hdrdir)/ruby/defines.h
+ossl_ssl_session.o: $(hdrdir)/ruby/encoding.h
+ossl_ssl_session.o: $(hdrdir)/ruby/intern.h
+ossl_ssl_session.o: $(hdrdir)/ruby/io.h
+ossl_ssl_session.o: $(hdrdir)/ruby/missing.h
+ossl_ssl_session.o: $(hdrdir)/ruby/oniguruma.h
+ossl_ssl_session.o: $(hdrdir)/ruby/ruby.h
+ossl_ssl_session.o: $(hdrdir)/ruby/st.h
+ossl_ssl_session.o: $(hdrdir)/ruby/subst.h
+ossl_ssl_session.o: $(hdrdir)/ruby/thread.h
+ossl_ssl_session.o: $(top_srcdir)/include/ruby.h
+ossl_ssl_session.o: openssl_missing.h
+ossl_ssl_session.o: ossl.h
+ossl_ssl_session.o: ossl_asn1.h
+ossl_ssl_session.o: ossl_bio.h
+ossl_ssl_session.o: ossl_bn.h
+ossl_ssl_session.o: ossl_cipher.h
+ossl_ssl_session.o: ossl_config.h
+ossl_ssl_session.o: ossl_digest.h
+ossl_ssl_session.o: ossl_engine.h
+ossl_ssl_session.o: ossl_hmac.h
+ossl_ssl_session.o: ossl_ns_spki.h
+ossl_ssl_session.o: ossl_ocsp.h
+ossl_ssl_session.o: ossl_pkcs12.h
+ossl_ssl_session.o: ossl_pkcs5.h
+ossl_ssl_session.o: ossl_pkcs7.h
+ossl_ssl_session.o: ossl_pkey.h
+ossl_ssl_session.o: ossl_rand.h
+ossl_ssl_session.o: ossl_ssl.h
+ossl_ssl_session.o: ossl_ssl_session.c
+ossl_ssl_session.o: ossl_version.h
+ossl_ssl_session.o: ossl_x509.h
+ossl_ssl_session.o: ruby_missing.h
+ossl_x509.o: $(RUBY_EXTCONF_H)
+ossl_x509.o: $(arch_hdrdir)/ruby/config.h
+ossl_x509.o: $(hdrdir)/ruby/defines.h
+ossl_x509.o: $(hdrdir)/ruby/encoding.h
+ossl_x509.o: $(hdrdir)/ruby/intern.h
+ossl_x509.o: $(hdrdir)/ruby/io.h
+ossl_x509.o: $(hdrdir)/ruby/missing.h
+ossl_x509.o: $(hdrdir)/ruby/oniguruma.h
+ossl_x509.o: $(hdrdir)/ruby/ruby.h
+ossl_x509.o: $(hdrdir)/ruby/st.h
+ossl_x509.o: $(hdrdir)/ruby/subst.h
+ossl_x509.o: $(hdrdir)/ruby/thread.h
+ossl_x509.o: $(top_srcdir)/include/ruby.h
+ossl_x509.o: openssl_missing.h
+ossl_x509.o: ossl.h
+ossl_x509.o: ossl_asn1.h
+ossl_x509.o: ossl_bio.h
+ossl_x509.o: ossl_bn.h
+ossl_x509.o: ossl_cipher.h
+ossl_x509.o: ossl_config.h
+ossl_x509.o: ossl_digest.h
+ossl_x509.o: ossl_engine.h
+ossl_x509.o: ossl_hmac.h
+ossl_x509.o: ossl_ns_spki.h
+ossl_x509.o: ossl_ocsp.h
+ossl_x509.o: ossl_pkcs12.h
+ossl_x509.o: ossl_pkcs5.h
+ossl_x509.o: ossl_pkcs7.h
+ossl_x509.o: ossl_pkey.h
+ossl_x509.o: ossl_rand.h
+ossl_x509.o: ossl_ssl.h
+ossl_x509.o: ossl_version.h
+ossl_x509.o: ossl_x509.c
+ossl_x509.o: ossl_x509.h
+ossl_x509.o: ruby_missing.h
+ossl_x509attr.o: $(RUBY_EXTCONF_H)
+ossl_x509attr.o: $(arch_hdrdir)/ruby/config.h
+ossl_x509attr.o: $(hdrdir)/ruby/defines.h
+ossl_x509attr.o: $(hdrdir)/ruby/encoding.h
+ossl_x509attr.o: $(hdrdir)/ruby/intern.h
+ossl_x509attr.o: $(hdrdir)/ruby/io.h
+ossl_x509attr.o: $(hdrdir)/ruby/missing.h
+ossl_x509attr.o: $(hdrdir)/ruby/oniguruma.h
+ossl_x509attr.o: $(hdrdir)/ruby/ruby.h
+ossl_x509attr.o: $(hdrdir)/ruby/st.h
+ossl_x509attr.o: $(hdrdir)/ruby/subst.h
+ossl_x509attr.o: $(hdrdir)/ruby/thread.h
+ossl_x509attr.o: $(top_srcdir)/include/ruby.h
+ossl_x509attr.o: openssl_missing.h
+ossl_x509attr.o: ossl.h
+ossl_x509attr.o: ossl_asn1.h
+ossl_x509attr.o: ossl_bio.h
+ossl_x509attr.o: ossl_bn.h
+ossl_x509attr.o: ossl_cipher.h
+ossl_x509attr.o: ossl_config.h
+ossl_x509attr.o: ossl_digest.h
+ossl_x509attr.o: ossl_engine.h
+ossl_x509attr.o: ossl_hmac.h
+ossl_x509attr.o: ossl_ns_spki.h
+ossl_x509attr.o: ossl_ocsp.h
+ossl_x509attr.o: ossl_pkcs12.h
+ossl_x509attr.o: ossl_pkcs5.h
+ossl_x509attr.o: ossl_pkcs7.h
+ossl_x509attr.o: ossl_pkey.h
+ossl_x509attr.o: ossl_rand.h
+ossl_x509attr.o: ossl_ssl.h
+ossl_x509attr.o: ossl_version.h
+ossl_x509attr.o: ossl_x509.h
+ossl_x509attr.o: ossl_x509attr.c
+ossl_x509attr.o: ruby_missing.h
+ossl_x509cert.o: $(RUBY_EXTCONF_H)
+ossl_x509cert.o: $(arch_hdrdir)/ruby/config.h
+ossl_x509cert.o: $(hdrdir)/ruby/defines.h
+ossl_x509cert.o: $(hdrdir)/ruby/encoding.h
+ossl_x509cert.o: $(hdrdir)/ruby/intern.h
+ossl_x509cert.o: $(hdrdir)/ruby/io.h
+ossl_x509cert.o: $(hdrdir)/ruby/missing.h
+ossl_x509cert.o: $(hdrdir)/ruby/oniguruma.h
+ossl_x509cert.o: $(hdrdir)/ruby/ruby.h
+ossl_x509cert.o: $(hdrdir)/ruby/st.h
+ossl_x509cert.o: $(hdrdir)/ruby/subst.h
+ossl_x509cert.o: $(hdrdir)/ruby/thread.h
+ossl_x509cert.o: $(top_srcdir)/include/ruby.h
+ossl_x509cert.o: openssl_missing.h
+ossl_x509cert.o: ossl.h
+ossl_x509cert.o: ossl_asn1.h
+ossl_x509cert.o: ossl_bio.h
+ossl_x509cert.o: ossl_bn.h
+ossl_x509cert.o: ossl_cipher.h
+ossl_x509cert.o: ossl_config.h
+ossl_x509cert.o: ossl_digest.h
+ossl_x509cert.o: ossl_engine.h
+ossl_x509cert.o: ossl_hmac.h
+ossl_x509cert.o: ossl_ns_spki.h
+ossl_x509cert.o: ossl_ocsp.h
+ossl_x509cert.o: ossl_pkcs12.h
+ossl_x509cert.o: ossl_pkcs5.h
+ossl_x509cert.o: ossl_pkcs7.h
+ossl_x509cert.o: ossl_pkey.h
+ossl_x509cert.o: ossl_rand.h
+ossl_x509cert.o: ossl_ssl.h
+ossl_x509cert.o: ossl_version.h
+ossl_x509cert.o: ossl_x509.h
+ossl_x509cert.o: ossl_x509cert.c
+ossl_x509cert.o: ruby_missing.h
+ossl_x509crl.o: $(RUBY_EXTCONF_H)
+ossl_x509crl.o: $(arch_hdrdir)/ruby/config.h
+ossl_x509crl.o: $(hdrdir)/ruby/defines.h
+ossl_x509crl.o: $(hdrdir)/ruby/encoding.h
+ossl_x509crl.o: $(hdrdir)/ruby/intern.h
+ossl_x509crl.o: $(hdrdir)/ruby/io.h
+ossl_x509crl.o: $(hdrdir)/ruby/missing.h
+ossl_x509crl.o: $(hdrdir)/ruby/oniguruma.h
+ossl_x509crl.o: $(hdrdir)/ruby/ruby.h
+ossl_x509crl.o: $(hdrdir)/ruby/st.h
+ossl_x509crl.o: $(hdrdir)/ruby/subst.h
+ossl_x509crl.o: $(hdrdir)/ruby/thread.h
+ossl_x509crl.o: $(top_srcdir)/include/ruby.h
+ossl_x509crl.o: openssl_missing.h
+ossl_x509crl.o: ossl.h
+ossl_x509crl.o: ossl_asn1.h
+ossl_x509crl.o: ossl_bio.h
+ossl_x509crl.o: ossl_bn.h
+ossl_x509crl.o: ossl_cipher.h
+ossl_x509crl.o: ossl_config.h
+ossl_x509crl.o: ossl_digest.h
+ossl_x509crl.o: ossl_engine.h
+ossl_x509crl.o: ossl_hmac.h
+ossl_x509crl.o: ossl_ns_spki.h
+ossl_x509crl.o: ossl_ocsp.h
+ossl_x509crl.o: ossl_pkcs12.h
+ossl_x509crl.o: ossl_pkcs5.h
+ossl_x509crl.o: ossl_pkcs7.h
+ossl_x509crl.o: ossl_pkey.h
+ossl_x509crl.o: ossl_rand.h
+ossl_x509crl.o: ossl_ssl.h
+ossl_x509crl.o: ossl_version.h
+ossl_x509crl.o: ossl_x509.h
+ossl_x509crl.o: ossl_x509crl.c
+ossl_x509crl.o: ruby_missing.h
+ossl_x509ext.o: $(RUBY_EXTCONF_H)
+ossl_x509ext.o: $(arch_hdrdir)/ruby/config.h
+ossl_x509ext.o: $(hdrdir)/ruby/defines.h
+ossl_x509ext.o: $(hdrdir)/ruby/encoding.h
+ossl_x509ext.o: $(hdrdir)/ruby/intern.h
+ossl_x509ext.o: $(hdrdir)/ruby/io.h
+ossl_x509ext.o: $(hdrdir)/ruby/missing.h
+ossl_x509ext.o: $(hdrdir)/ruby/oniguruma.h
+ossl_x509ext.o: $(hdrdir)/ruby/ruby.h
+ossl_x509ext.o: $(hdrdir)/ruby/st.h
+ossl_x509ext.o: $(hdrdir)/ruby/subst.h
+ossl_x509ext.o: $(hdrdir)/ruby/thread.h
+ossl_x509ext.o: $(top_srcdir)/include/ruby.h
+ossl_x509ext.o: openssl_missing.h
+ossl_x509ext.o: ossl.h
+ossl_x509ext.o: ossl_asn1.h
+ossl_x509ext.o: ossl_bio.h
+ossl_x509ext.o: ossl_bn.h
+ossl_x509ext.o: ossl_cipher.h
+ossl_x509ext.o: ossl_config.h
+ossl_x509ext.o: ossl_digest.h
+ossl_x509ext.o: ossl_engine.h
+ossl_x509ext.o: ossl_hmac.h
+ossl_x509ext.o: ossl_ns_spki.h
+ossl_x509ext.o: ossl_ocsp.h
+ossl_x509ext.o: ossl_pkcs12.h
+ossl_x509ext.o: ossl_pkcs5.h
+ossl_x509ext.o: ossl_pkcs7.h
+ossl_x509ext.o: ossl_pkey.h
+ossl_x509ext.o: ossl_rand.h
+ossl_x509ext.o: ossl_ssl.h
+ossl_x509ext.o: ossl_version.h
+ossl_x509ext.o: ossl_x509.h
+ossl_x509ext.o: ossl_x509ext.c
+ossl_x509ext.o: ruby_missing.h
+ossl_x509name.o: $(RUBY_EXTCONF_H)
+ossl_x509name.o: $(arch_hdrdir)/ruby/config.h
+ossl_x509name.o: $(hdrdir)/ruby/defines.h
+ossl_x509name.o: $(hdrdir)/ruby/encoding.h
+ossl_x509name.o: $(hdrdir)/ruby/intern.h
+ossl_x509name.o: $(hdrdir)/ruby/io.h
+ossl_x509name.o: $(hdrdir)/ruby/missing.h
+ossl_x509name.o: $(hdrdir)/ruby/oniguruma.h
+ossl_x509name.o: $(hdrdir)/ruby/ruby.h
+ossl_x509name.o: $(hdrdir)/ruby/st.h
+ossl_x509name.o: $(hdrdir)/ruby/subst.h
+ossl_x509name.o: $(hdrdir)/ruby/thread.h
+ossl_x509name.o: $(top_srcdir)/include/ruby.h
+ossl_x509name.o: openssl_missing.h
+ossl_x509name.o: ossl.h
+ossl_x509name.o: ossl_asn1.h
+ossl_x509name.o: ossl_bio.h
+ossl_x509name.o: ossl_bn.h
+ossl_x509name.o: ossl_cipher.h
+ossl_x509name.o: ossl_config.h
+ossl_x509name.o: ossl_digest.h
+ossl_x509name.o: ossl_engine.h
+ossl_x509name.o: ossl_hmac.h
+ossl_x509name.o: ossl_ns_spki.h
+ossl_x509name.o: ossl_ocsp.h
+ossl_x509name.o: ossl_pkcs12.h
+ossl_x509name.o: ossl_pkcs5.h
+ossl_x509name.o: ossl_pkcs7.h
+ossl_x509name.o: ossl_pkey.h
+ossl_x509name.o: ossl_rand.h
+ossl_x509name.o: ossl_ssl.h
+ossl_x509name.o: ossl_version.h
+ossl_x509name.o: ossl_x509.h
+ossl_x509name.o: ossl_x509name.c
+ossl_x509name.o: ruby_missing.h
+ossl_x509req.o: $(RUBY_EXTCONF_H)
+ossl_x509req.o: $(arch_hdrdir)/ruby/config.h
+ossl_x509req.o: $(hdrdir)/ruby/defines.h
+ossl_x509req.o: $(hdrdir)/ruby/encoding.h
+ossl_x509req.o: $(hdrdir)/ruby/intern.h
+ossl_x509req.o: $(hdrdir)/ruby/io.h
+ossl_x509req.o: $(hdrdir)/ruby/missing.h
+ossl_x509req.o: $(hdrdir)/ruby/oniguruma.h
+ossl_x509req.o: $(hdrdir)/ruby/ruby.h
+ossl_x509req.o: $(hdrdir)/ruby/st.h
+ossl_x509req.o: $(hdrdir)/ruby/subst.h
+ossl_x509req.o: $(hdrdir)/ruby/thread.h
+ossl_x509req.o: $(top_srcdir)/include/ruby.h
+ossl_x509req.o: openssl_missing.h
+ossl_x509req.o: ossl.h
+ossl_x509req.o: ossl_asn1.h
+ossl_x509req.o: ossl_bio.h
+ossl_x509req.o: ossl_bn.h
+ossl_x509req.o: ossl_cipher.h
+ossl_x509req.o: ossl_config.h
+ossl_x509req.o: ossl_digest.h
+ossl_x509req.o: ossl_engine.h
+ossl_x509req.o: ossl_hmac.h
+ossl_x509req.o: ossl_ns_spki.h
+ossl_x509req.o: ossl_ocsp.h
+ossl_x509req.o: ossl_pkcs12.h
+ossl_x509req.o: ossl_pkcs5.h
+ossl_x509req.o: ossl_pkcs7.h
+ossl_x509req.o: ossl_pkey.h
+ossl_x509req.o: ossl_rand.h
+ossl_x509req.o: ossl_ssl.h
+ossl_x509req.o: ossl_version.h
+ossl_x509req.o: ossl_x509.h
+ossl_x509req.o: ossl_x509req.c
+ossl_x509req.o: ruby_missing.h
+ossl_x509revoked.o: $(RUBY_EXTCONF_H)
+ossl_x509revoked.o: $(arch_hdrdir)/ruby/config.h
+ossl_x509revoked.o: $(hdrdir)/ruby/defines.h
+ossl_x509revoked.o: $(hdrdir)/ruby/encoding.h
+ossl_x509revoked.o: $(hdrdir)/ruby/intern.h
+ossl_x509revoked.o: $(hdrdir)/ruby/io.h
+ossl_x509revoked.o: $(hdrdir)/ruby/missing.h
+ossl_x509revoked.o: $(hdrdir)/ruby/oniguruma.h
+ossl_x509revoked.o: $(hdrdir)/ruby/ruby.h
+ossl_x509revoked.o: $(hdrdir)/ruby/st.h
+ossl_x509revoked.o: $(hdrdir)/ruby/subst.h
+ossl_x509revoked.o: $(hdrdir)/ruby/thread.h
+ossl_x509revoked.o: $(top_srcdir)/include/ruby.h
+ossl_x509revoked.o: openssl_missing.h
+ossl_x509revoked.o: ossl.h
+ossl_x509revoked.o: ossl_asn1.h
+ossl_x509revoked.o: ossl_bio.h
+ossl_x509revoked.o: ossl_bn.h
+ossl_x509revoked.o: ossl_cipher.h
+ossl_x509revoked.o: ossl_config.h
+ossl_x509revoked.o: ossl_digest.h
+ossl_x509revoked.o: ossl_engine.h
+ossl_x509revoked.o: ossl_hmac.h
+ossl_x509revoked.o: ossl_ns_spki.h
+ossl_x509revoked.o: ossl_ocsp.h
+ossl_x509revoked.o: ossl_pkcs12.h
+ossl_x509revoked.o: ossl_pkcs5.h
+ossl_x509revoked.o: ossl_pkcs7.h
+ossl_x509revoked.o: ossl_pkey.h
+ossl_x509revoked.o: ossl_rand.h
+ossl_x509revoked.o: ossl_ssl.h
+ossl_x509revoked.o: ossl_version.h
+ossl_x509revoked.o: ossl_x509.h
+ossl_x509revoked.o: ossl_x509revoked.c
+ossl_x509revoked.o: ruby_missing.h
+ossl_x509store.o: $(RUBY_EXTCONF_H)
+ossl_x509store.o: $(arch_hdrdir)/ruby/config.h
+ossl_x509store.o: $(hdrdir)/ruby/defines.h
+ossl_x509store.o: $(hdrdir)/ruby/encoding.h
+ossl_x509store.o: $(hdrdir)/ruby/intern.h
+ossl_x509store.o: $(hdrdir)/ruby/io.h
+ossl_x509store.o: $(hdrdir)/ruby/missing.h
+ossl_x509store.o: $(hdrdir)/ruby/oniguruma.h
+ossl_x509store.o: $(hdrdir)/ruby/ruby.h
+ossl_x509store.o: $(hdrdir)/ruby/st.h
+ossl_x509store.o: $(hdrdir)/ruby/subst.h
+ossl_x509store.o: $(hdrdir)/ruby/thread.h
+ossl_x509store.o: $(top_srcdir)/include/ruby.h
+ossl_x509store.o: openssl_missing.h
+ossl_x509store.o: ossl.h
+ossl_x509store.o: ossl_asn1.h
+ossl_x509store.o: ossl_bio.h
+ossl_x509store.o: ossl_bn.h
+ossl_x509store.o: ossl_cipher.h
+ossl_x509store.o: ossl_config.h
+ossl_x509store.o: ossl_digest.h
+ossl_x509store.o: ossl_engine.h
+ossl_x509store.o: ossl_hmac.h
+ossl_x509store.o: ossl_ns_spki.h
+ossl_x509store.o: ossl_ocsp.h
+ossl_x509store.o: ossl_pkcs12.h
+ossl_x509store.o: ossl_pkcs5.h
+ossl_x509store.o: ossl_pkcs7.h
+ossl_x509store.o: ossl_pkey.h
+ossl_x509store.o: ossl_rand.h
+ossl_x509store.o: ossl_ssl.h
+ossl_x509store.o: ossl_version.h
+ossl_x509store.o: ossl_x509.h
+ossl_x509store.o: ossl_x509store.c
+ossl_x509store.o: ruby_missing.h
+# AUTOGENERATED DEPENDENCIES END
diff --git a/jni/ruby/ext/openssl/deprecation.rb b/jni/ruby/ext/openssl/deprecation.rb
new file mode 100644
index 0000000..39ebfa0
--- /dev/null
+++ b/jni/ruby/ext/openssl/deprecation.rb
@@ -0,0 +1,21 @@
+module OpenSSL
+ def self.deprecated_warning_flag
+ unless flag = (@deprecated_warning_flag ||= nil)
+ if try_compile("", flag = "-Werror=deprecated-declarations")
+ if with_config("broken-apple-openssl")
+ flag = "-Wno-deprecated-declarations"
+ end
+ $warnflags << " #{flag}"
+ else
+ flag = ""
+ end
+ @deprecated_warning_flag = flag
+ end
+ flag
+ end
+
+ def self.check_func(func, header)
+ have_func(func, header, deprecated_warning_flag) and
+ have_header(header, nil, deprecated_warning_flag)
+ end
+end
diff --git a/jni/ruby/ext/openssl/extconf.h b/jni/ruby/ext/openssl/extconf.h
new file mode 100644
index 0000000..03ec92b
--- /dev/null
+++ b/jni/ruby/ext/openssl/extconf.h
@@ -0,0 +1,71 @@
+#ifndef EXTCONF_H
+#define EXTCONF_H
+#define HAVE_ASSERT_H 1
+#define HAVE_OPENSSL_SSL_H 1
+#define HAVE_OPENSSL_CONF_API_H 1
+#define HAVE_SSL_LIBRARY_INIT 1
+#define HAVE_OPENSSL_SSL_H 1
+#define HAVE_ERR_PEEK_LAST_ERROR 1
+#define HAVE_ASN1_PUT_EOC 1
+#define HAVE_BN_MOD_ADD 1
+#define HAVE_BN_MOD_SQR 1
+#define HAVE_BN_MOD_SUB 1
+#define HAVE_BN_PSEUDO_RAND_RANGE 1
+#define HAVE_BN_RAND_RANGE 1
+#define HAVE_CONF_GET1_DEFAULT_CONFIG_FILE 1
+#define HAVE_EVP_CIPHER_CTX_COPY 1
+#define HAVE_EVP_CIPHER_CTX_SET_PADDING 1
+#define HAVE_EVP_CIPHERFINAL_EX 1
+#define HAVE_EVP_CIPHERINIT_EX 1
+#define HAVE_EVP_DIGESTFINAL_EX 1
+#define HAVE_EVP_DIGESTINIT_EX 1
+#define HAVE_EVP_MD_CTX_CLEANUP 1
+#define HAVE_EVP_MD_CTX_CREATE 1
+#define HAVE_EVP_MD_CTX_DESTROY 1
+#define HAVE_EVP_MD_CTX_INIT 1
+#define HAVE_HMAC_CTX_CLEANUP 1
+#define HAVE_HMAC_CTX_COPY 1
+#define HAVE_HMAC_CTX_INIT 1
+#define HAVE_PEM_DEF_CALLBACK 1
+#define HAVE_PKCS5_PBKDF2_HMAC 1
+#define HAVE_PKCS5_PBKDF2_HMAC_SHA1 1
+#define HAVE_X509V3_SET_NCONF 1
+#define HAVE_X509V3_EXT_NCONF_NID 1
+#define HAVE_X509_CRL_ADD0_REVOKED 1
+#define HAVE_X509_CRL_SET_ISSUER_NAME 1
+#define HAVE_X509_CRL_SET_VERSION 1
+#define HAVE_X509_CRL_SORT 1
+#define HAVE_X509_NAME_HASH_OLD 1
+#define HAVE_OBJ_NAME_DO_ALL_SORTED 1
+#define HAVE_SSL_SESSION_GET_ID 1
+#define HAVE_OPENSSL_CLEANSE 1
+#define HAVE_TLSV1_1_METHOD 1
+#define HAVE_TLSV1_1_SERVER_METHOD 1
+#define HAVE_TLSV1_1_CLIENT_METHOD 1
+#define HAVE_TLSV1_2_METHOD 1
+#define HAVE_TLSV1_2_SERVER_METHOD 1
+#define HAVE_TLSV1_2_CLIENT_METHOD 1
+#define HAVE_OPENSSL_NPN_NEGOTIATED 1
+#define HAVE_SSL_SET_TLSEXT_HOST_NAME 1
+#define HAVE_OPENSSL_ENGINE_H 1
+#define HAVE_ENGINE_ADD 1
+#define HAVE_ENGINE_LOAD_BUILTIN_ENGINES 1
+#define HAVE_ENGINE_GET_DIGEST 1
+#define HAVE_ENGINE_GET_CIPHER 1
+#define HAVE_ENGINE_CLEANUP 1
+#define HAVE_ENGINE_LOAD_DYNAMIC 1
+#define HAVE_ENGINE_LOAD_CRYPTODEV 1
+#define HAVE_DH_GENERATE_PARAMETERS_EX 1
+#define HAVE_DSA_GENERATE_PARAMETERS_EX 1
+#define HAVE_RSA_GENERATE_KEY_EX 1
+#define HAVE_OPENSSL_OCSP_H 1
+#define HAVE_CRYPTO_THREADID_PTR 1
+#define HAVE_ST_PTR 1
+#define HAVE_EVP_CIPHER_CTX_FLAGS 1
+#define HAVE_ST_FLAGS 1
+#define HAVE_EVP_CIPHER_CTX_ENGINE 1
+#define HAVE_ST_ENGINE 1
+#define HAVE_X509_ATTRIBUTE_SINGLE 1
+#define HAVE_ST_SINGLE 1
+#define HAVE_AUTHENTICATED_ENCRYPTION 1
+#endif
diff --git a/jni/ruby/ext/openssl/extconf.rb b/jni/ruby/ext/openssl/extconf.rb
new file mode 100644
index 0000000..af9fa49
--- /dev/null
+++ b/jni/ruby/ext/openssl/extconf.rb
@@ -0,0 +1,160 @@
+# -*- coding: us-ascii -*-
+=begin
+= $RCSfile$ -- Generator for Makefile
+
+= Info
+ 'OpenSSL for Ruby 2' project
+ Copyright (C) 2002 Michal Rokos <m.rokos@sh.cvut.cz>
+ All rights reserved.
+
+= Licence
+ This program is licenced under the same licence as Ruby.
+ (See the file 'LICENCE'.)
+
+= Version
+ $Id: extconf.rb 43451 2013-10-28 06:32:24Z nobu $
+=end
+
+require "mkmf"
+require File.expand_path('../deprecation', __FILE__)
+
+dir_config("openssl")
+dir_config("kerberos")
+
+Logging::message "=== OpenSSL for Ruby configurator ===\n"
+
+##
+# Adds -DOSSL_DEBUG for compilation and some more targets when GCC is used
+# To turn it on, use: --with-debug or --enable-debug
+#
+if with_config("debug") or enable_config("debug")
+ $defs.push("-DOSSL_DEBUG") unless $defs.include? "-DOSSL_DEBUG"
+end
+
+Logging::message "=== Checking for system dependent stuff... ===\n"
+have_library("nsl", "t_open")
+have_library("socket", "socket")
+have_header("assert.h")
+
+Logging::message "=== Checking for required stuff... ===\n"
+if $mingw
+ have_library("wsock32")
+ have_library("gdi32")
+end
+
+result = pkg_config("openssl") && have_header("openssl/ssl.h")
+
+unless result
+ result = have_header("openssl/ssl.h")
+ result &&= %w[crypto libeay32].any? {|lib| have_library(lib, "OpenSSL_add_all_digests")}
+ result &&= %w[ssl ssleay32].any? {|lib| have_library(lib, "SSL_library_init")}
+ unless result
+ Logging::message "=== Checking for required stuff failed. ===\n"
+ Logging::message "Makefile wasn't created. Fix the errors above.\n"
+ exit 1
+ end
+end
+
+unless have_header("openssl/conf_api.h")
+ raise "OpenSSL 0.9.6 or later required."
+end
+unless OpenSSL.check_func("SSL_library_init()", "openssl/ssl.h")
+ raise "Ignore OpenSSL broken by Apple.\nPlease use another openssl. (e.g. using `configure --with-openssl-dir=/path/to/openssl')"
+end
+
+Logging::message "=== Checking for OpenSSL features... ===\n"
+have_func("ERR_peek_last_error")
+have_func("ASN1_put_eoc")
+have_func("BN_mod_add")
+have_func("BN_mod_sqr")
+have_func("BN_mod_sub")
+have_func("BN_pseudo_rand_range")
+have_func("BN_rand_range")
+have_func("CONF_get1_default_config_file")
+have_func("EVP_CIPHER_CTX_copy")
+have_func("EVP_CIPHER_CTX_set_padding")
+have_func("EVP_CipherFinal_ex")
+have_func("EVP_CipherInit_ex")
+have_func("EVP_DigestFinal_ex")
+have_func("EVP_DigestInit_ex")
+have_func("EVP_MD_CTX_cleanup")
+have_func("EVP_MD_CTX_create")
+have_func("EVP_MD_CTX_destroy")
+have_func("EVP_MD_CTX_init")
+have_func("HMAC_CTX_cleanup")
+have_func("HMAC_CTX_copy")
+have_func("HMAC_CTX_init")
+have_func("PEM_def_callback")
+have_func("PKCS5_PBKDF2_HMAC")
+have_func("PKCS5_PBKDF2_HMAC_SHA1")
+have_func("X509V3_set_nconf")
+have_func("X509V3_EXT_nconf_nid")
+have_func("X509_CRL_add0_revoked")
+have_func("X509_CRL_set_issuer_name")
+have_func("X509_CRL_set_version")
+have_func("X509_CRL_sort")
+have_func("X509_NAME_hash_old")
+have_func("X509_STORE_get_ex_data")
+have_func("X509_STORE_set_ex_data")
+have_func("OBJ_NAME_do_all_sorted")
+have_func("SSL_SESSION_get_id")
+have_func("SSL_SESSION_cmp")
+have_func("OPENSSL_cleanse")
+have_func("SSLv2_method")
+have_func("SSLv2_server_method")
+have_func("SSLv2_client_method")
+have_func("TLSv1_1_method")
+have_func("TLSv1_1_server_method")
+have_func("TLSv1_1_client_method")
+have_func("TLSv1_2_method")
+have_func("TLSv1_2_server_method")
+have_func("TLSv1_2_client_method")
+have_macro("OPENSSL_NPN_NEGOTIATED", ['openssl/ssl.h']) && $defs.push("-DHAVE_OPENSSL_NPN_NEGOTIATED")
+unless have_func("SSL_set_tlsext_host_name", ['openssl/ssl.h'])
+ have_macro("SSL_set_tlsext_host_name", ['openssl/ssl.h']) && $defs.push("-DHAVE_SSL_SET_TLSEXT_HOST_NAME")
+end
+if have_header("openssl/engine.h")
+ have_func("ENGINE_add")
+ have_func("ENGINE_load_builtin_engines")
+ have_func("ENGINE_load_openbsd_dev_crypto")
+ have_func("ENGINE_get_digest")
+ have_func("ENGINE_get_cipher")
+ have_func("ENGINE_cleanup")
+ have_func("ENGINE_load_dynamic")
+ have_func("ENGINE_load_4758cca")
+ have_func("ENGINE_load_aep")
+ have_func("ENGINE_load_atalla")
+ have_func("ENGINE_load_chil")
+ have_func("ENGINE_load_cswift")
+ have_func("ENGINE_load_nuron")
+ have_func("ENGINE_load_sureware")
+ have_func("ENGINE_load_ubsec")
+ have_func("ENGINE_load_padlock")
+ have_func("ENGINE_load_capi")
+ have_func("ENGINE_load_gmp")
+ have_func("ENGINE_load_gost")
+ have_func("ENGINE_load_cryptodev")
+ have_func("ENGINE_load_aesni")
+end
+have_func("DH_generate_parameters_ex")
+have_func("DSA_generate_parameters_ex")
+have_func("RSA_generate_key_ex")
+if checking_for('OpenSSL version is 0.9.7 or later') {
+ try_static_assert('OPENSSL_VERSION_NUMBER >= 0x00907000L', 'openssl/opensslv.h')
+ }
+ have_header("openssl/ocsp.h")
+end
+have_struct_member("CRYPTO_THREADID", "ptr", "openssl/crypto.h")
+have_struct_member("EVP_CIPHER_CTX", "flags", "openssl/evp.h")
+have_struct_member("EVP_CIPHER_CTX", "engine", "openssl/evp.h")
+have_struct_member("X509_ATTRIBUTE", "single", "openssl/x509.h")
+have_macro("OPENSSL_FIPS", ['openssl/opensslconf.h']) && $defs.push("-DHAVE_OPENSSL_FIPS")
+have_macro("EVP_CTRL_GCM_GET_TAG", ['openssl/evp.h']) && $defs.push("-DHAVE_AUTHENTICATED_ENCRYPTION")
+
+Logging::message "=== Checking done. ===\n"
+
+create_header
+create_makefile("openssl") {|conf|
+ conf << "THREAD_MODEL = #{CONFIG["THREAD_MODEL"]}\n"
+}
+Logging::message "Done.\n"
diff --git a/jni/ruby/ext/openssl/lib/openssl.rb b/jni/ruby/ext/openssl/lib/openssl.rb
new file mode 100644
index 0000000..adcaee7
--- /dev/null
+++ b/jni/ruby/ext/openssl/lib/openssl.rb
@@ -0,0 +1,24 @@
+=begin
+= $RCSfile$ -- Loader for all OpenSSL C-space and Ruby-space definitions
+
+= Info
+ 'OpenSSL for Ruby 2' project
+ Copyright (C) 2002 Michal Rokos <m.rokos@sh.cvut.cz>
+ All rights reserved.
+
+= Licence
+ This program is licenced under the same licence as Ruby.
+ (See the file 'LICENCE'.)
+
+= Version
+ $Id: openssl.rb 32664 2011-07-25 06:30:07Z nahi $
+=end
+
+require 'openssl.so'
+
+require 'openssl/bn'
+require 'openssl/cipher'
+require 'openssl/config'
+require 'openssl/digest'
+require 'openssl/x509'
+require 'openssl/ssl'
diff --git a/jni/ruby/ext/openssl/lib/openssl/bn.rb b/jni/ruby/ext/openssl/lib/openssl/bn.rb
new file mode 100644
index 0000000..8c07eac
--- /dev/null
+++ b/jni/ruby/ext/openssl/lib/openssl/bn.rb
@@ -0,0 +1,45 @@
+#--
+#
+# $RCSfile$
+#
+# = Ruby-space definitions that completes C-space funcs for BN
+#
+# = Info
+# 'OpenSSL for Ruby 2' project
+# Copyright (C) 2002 Michal Rokos <m.rokos@sh.cvut.cz>
+# All rights reserved.
+#
+# = Licence
+# This program is licenced under the same licence as Ruby.
+# (See the file 'LICENCE'.)
+#
+# = Version
+# $Id: bn.rb 47647 2014-09-20 01:17:05Z akr $
+#
+#++
+
+module OpenSSL
+ class BN
+ include Comparable
+
+ def pretty_print(q)
+ q.object_group(self) {
+ q.text ' '
+ q.text to_i.to_s
+ }
+ end
+ end # BN
+end # OpenSSL
+
+##
+# Add double dispatch to Integer
+#
+class Integer
+ # Casts an Integer as an OpenSSL::BN
+ #
+ # See `man bn` for more info.
+ def to_bn
+ OpenSSL::BN::new(self)
+ end
+end # Integer
+
diff --git a/jni/ruby/ext/openssl/lib/openssl/buffering.rb b/jni/ruby/ext/openssl/lib/openssl/buffering.rb
new file mode 100644
index 0000000..40bbd0f
--- /dev/null
+++ b/jni/ruby/ext/openssl/lib/openssl/buffering.rb
@@ -0,0 +1,457 @@
+# coding: binary
+#--
+#= $RCSfile$ -- Buffering mix-in module.
+#
+#= Info
+# 'OpenSSL for Ruby 2' project
+# Copyright (C) 2001 GOTOU YUUZOU <gotoyuzo@notwork.org>
+# All rights reserved.
+#
+#= Licence
+# This program is licenced under the same licence as Ruby.
+# (See the file 'LICENCE'.)
+#
+#= Version
+# $Id: buffering.rb 43964 2013-12-03 01:44:41Z drbrain $
+#++
+
+##
+# OpenSSL IO buffering mix-in module.
+#
+# This module allows an OpenSSL::SSL::SSLSocket to behave like an IO.
+#
+# You typically won't use this module directly, you can see it implemented in
+# OpenSSL::SSL::SSLSocket.
+
+module OpenSSL::Buffering
+ include Enumerable
+
+ ##
+ # The "sync mode" of the SSLSocket.
+ #
+ # See IO#sync for full details.
+
+ attr_accessor :sync
+
+ ##
+ # Default size to read from or write to the SSLSocket for buffer operations.
+
+ BLOCK_SIZE = 1024*16
+
+ ##
+ # Creates an instance of OpenSSL's buffering IO module.
+
+ def initialize(*)
+ super
+ @eof = false
+ @rbuffer = ""
+ @sync = @io.sync
+ end
+
+ #
+ # for reading.
+ #
+ private
+
+ ##
+ # Fills the buffer from the underlying SSLSocket
+
+ def fill_rbuff
+ begin
+ @rbuffer << self.sysread(BLOCK_SIZE)
+ rescue Errno::EAGAIN
+ retry
+ rescue EOFError
+ @eof = true
+ end
+ end
+
+ ##
+ # Consumes +size+ bytes from the buffer
+
+ def consume_rbuff(size=nil)
+ if @rbuffer.empty?
+ nil
+ else
+ size = @rbuffer.size unless size
+ ret = @rbuffer[0, size]
+ @rbuffer[0, size] = ""
+ ret
+ end
+ end
+
+ public
+
+ ##
+ # Reads +size+ bytes from the stream. If +buf+ is provided it must
+ # reference a string which will receive the data.
+ #
+ # See IO#read for full details.
+
+ def read(size=nil, buf=nil)
+ if size == 0
+ if buf
+ buf.clear
+ return buf
+ else
+ return ""
+ end
+ end
+ until @eof
+ break if size && size <= @rbuffer.size
+ fill_rbuff
+ end
+ ret = consume_rbuff(size) || ""
+ if buf
+ buf.replace(ret)
+ ret = buf
+ end
+ (size && ret.empty?) ? nil : ret
+ end
+
+ ##
+ # Reads at most +maxlen+ bytes from the stream. If +buf+ is provided it
+ # must reference a string which will receive the data.
+ #
+ # See IO#readpartial for full details.
+
+ def readpartial(maxlen, buf=nil)
+ if maxlen == 0
+ if buf
+ buf.clear
+ return buf
+ else
+ return ""
+ end
+ end
+ if @rbuffer.empty?
+ begin
+ return sysread(maxlen, buf)
+ rescue Errno::EAGAIN
+ retry
+ end
+ end
+ ret = consume_rbuff(maxlen)
+ if buf
+ buf.replace(ret)
+ ret = buf
+ end
+ raise EOFError if ret.empty?
+ ret
+ end
+
+ ##
+ # Reads at most +maxlen+ bytes in the non-blocking manner.
+ #
+ # When no data can be read without blocking it raises
+ # OpenSSL::SSL::SSLError extended by IO::WaitReadable or IO::WaitWritable.
+ #
+ # IO::WaitReadable means SSL needs to read internally so read_nonblock
+ # should be called again when the underlying IO is readable.
+ #
+ # IO::WaitWritable means SSL needs to write internally so read_nonblock
+ # should be called again after the underlying IO is writable.
+ #
+ # OpenSSL::Buffering#read_nonblock needs two rescue clause as follows:
+ #
+ # # emulates blocking read (readpartial).
+ # begin
+ # result = ssl.read_nonblock(maxlen)
+ # rescue IO::WaitReadable
+ # IO.select([io])
+ # retry
+ # rescue IO::WaitWritable
+ # IO.select(nil, [io])
+ # retry
+ # end
+ #
+ # Note that one reason that read_nonblock writes to the underlying IO is
+ # when the peer requests a new TLS/SSL handshake. See openssl the FAQ for
+ # more details. http://www.openssl.org/support/faq.html
+
+ def read_nonblock(maxlen, buf=nil, exception: true)
+ if maxlen == 0
+ if buf
+ buf.clear
+ return buf
+ else
+ return ""
+ end
+ end
+ if @rbuffer.empty?
+ return sysread_nonblock(maxlen, buf, exception: exception)
+ end
+ ret = consume_rbuff(maxlen)
+ if buf
+ buf.replace(ret)
+ ret = buf
+ end
+ raise EOFError if ret.empty?
+ ret
+ end
+
+ ##
+ # Reads the next "line+ from the stream. Lines are separated by +eol+. If
+ # +limit+ is provided the result will not be longer than the given number of
+ # bytes.
+ #
+ # +eol+ may be a String or Regexp.
+ #
+ # Unlike IO#gets the line read will not be assigned to +$_+.
+ #
+ # Unlike IO#gets the separator must be provided if a limit is provided.
+
+ def gets(eol=$/, limit=nil)
+ idx = @rbuffer.index(eol)
+ until @eof
+ break if idx
+ fill_rbuff
+ idx = @rbuffer.index(eol)
+ end
+ if eol.is_a?(Regexp)
+ size = idx ? idx+$&.size : nil
+ else
+ size = idx ? idx+eol.size : nil
+ end
+ if limit and limit >= 0
+ size = [size, limit].min
+ end
+ consume_rbuff(size)
+ end
+
+ ##
+ # Executes the block for every line in the stream where lines are separated
+ # by +eol+.
+ #
+ # See also #gets
+
+ def each(eol=$/)
+ while line = self.gets(eol)
+ yield line
+ end
+ end
+ alias each_line each
+
+ ##
+ # Reads lines from the stream which are separated by +eol+.
+ #
+ # See also #gets
+
+ def readlines(eol=$/)
+ ary = []
+ while line = self.gets(eol)
+ ary << line
+ end
+ ary
+ end
+
+ ##
+ # Reads a line from the stream which is separated by +eol+.
+ #
+ # Raises EOFError if at end of file.
+
+ def readline(eol=$/)
+ raise EOFError if eof?
+ gets(eol)
+ end
+
+ ##
+ # Reads one character from the stream. Returns nil if called at end of
+ # file.
+
+ def getc
+ read(1)
+ end
+
+ ##
+ # Calls the given block once for each byte in the stream.
+
+ def each_byte # :yields: byte
+ while c = getc
+ yield(c.ord)
+ end
+ end
+
+ ##
+ # Reads a one-character string from the stream. Raises an EOFError at end
+ # of file.
+
+ def readchar
+ raise EOFError if eof?
+ getc
+ end
+
+ ##
+ # Pushes character +c+ back onto the stream such that a subsequent buffered
+ # character read will return it.
+ #
+ # Unlike IO#getc multiple bytes may be pushed back onto the stream.
+ #
+ # Has no effect on unbuffered reads (such as #sysread).
+
+ def ungetc(c)
+ @rbuffer[0,0] = c.chr
+ end
+
+ ##
+ # Returns true if the stream is at file which means there is no more data to
+ # be read.
+
+ def eof?
+ fill_rbuff if !@eof && @rbuffer.empty?
+ @eof && @rbuffer.empty?
+ end
+ alias eof eof?
+
+ #
+ # for writing.
+ #
+ private
+
+ ##
+ # Writes +s+ to the buffer. When the buffer is full or #sync is true the
+ # buffer is flushed to the underlying socket.
+
+ def do_write(s)
+ @wbuffer = "" unless defined? @wbuffer
+ @wbuffer << s
+ @wbuffer.force_encoding(Encoding::BINARY)
+ @sync ||= false
+ if @sync or @wbuffer.size > BLOCK_SIZE or idx = @wbuffer.rindex($/)
+ remain = idx ? idx + $/.size : @wbuffer.length
+ nwritten = 0
+ while remain > 0
+ str = @wbuffer[nwritten,remain]
+ begin
+ nwrote = syswrite(str)
+ rescue Errno::EAGAIN
+ retry
+ end
+ remain -= nwrote
+ nwritten += nwrote
+ end
+ @wbuffer[0,nwritten] = ""
+ end
+ end
+
+ public
+
+ ##
+ # Writes +s+ to the stream. If the argument is not a string it will be
+ # converted using String#to_s. Returns the number of bytes written.
+
+ def write(s)
+ do_write(s)
+ s.bytesize
+ end
+
+ ##
+ # Writes +str+ in the non-blocking manner.
+ #
+ # If there is buffered data, it is flushed first. This may block.
+ #
+ # write_nonblock returns number of bytes written to the SSL connection.
+ #
+ # When no data can be written without blocking it raises
+ # OpenSSL::SSL::SSLError extended by IO::WaitReadable or IO::WaitWritable.
+ #
+ # IO::WaitReadable means SSL needs to read internally so write_nonblock
+ # should be called again after the underlying IO is readable.
+ #
+ # IO::WaitWritable means SSL needs to write internally so write_nonblock
+ # should be called again after underlying IO is writable.
+ #
+ # So OpenSSL::Buffering#write_nonblock needs two rescue clause as follows.
+ #
+ # # emulates blocking write.
+ # begin
+ # result = ssl.write_nonblock(str)
+ # rescue IO::WaitReadable
+ # IO.select([io])
+ # retry
+ # rescue IO::WaitWritable
+ # IO.select(nil, [io])
+ # retry
+ # end
+ #
+ # Note that one reason that write_nonblock reads from the underlying IO
+ # is when the peer requests a new TLS/SSL handshake. See the openssl FAQ
+ # for more details. http://www.openssl.org/support/faq.html
+
+ def write_nonblock(s, exception: true)
+ flush
+ syswrite_nonblock(s, exception: exception)
+ end
+
+ ##
+ # Writes +s+ to the stream. +s+ will be converted to a String using
+ # String#to_s.
+
+ def << (s)
+ do_write(s)
+ self
+ end
+
+ ##
+ # Writes +args+ to the stream along with a record separator.
+ #
+ # See IO#puts for full details.
+
+ def puts(*args)
+ s = ""
+ if args.empty?
+ s << "\n"
+ end
+ args.each{|arg|
+ s << arg.to_s
+ if $/ && /\n\z/ !~ s
+ s << "\n"
+ end
+ }
+ do_write(s)
+ nil
+ end
+
+ ##
+ # Writes +args+ to the stream.
+ #
+ # See IO#print for full details.
+
+ def print(*args)
+ s = ""
+ args.each{ |arg| s << arg.to_s }
+ do_write(s)
+ nil
+ end
+
+ ##
+ # Formats and writes to the stream converting parameters under control of
+ # the format string.
+ #
+ # See Kernel#sprintf for format string details.
+
+ def printf(s, *args)
+ do_write(s % args)
+ nil
+ end
+
+ ##
+ # Flushes buffered data to the SSLSocket.
+
+ def flush
+ osync = @sync
+ @sync = true
+ do_write ""
+ return self
+ ensure
+ @sync = osync
+ end
+
+ ##
+ # Closes the SSLSocket and flushes any unwritten data.
+
+ def close
+ flush rescue nil
+ sysclose
+ end
+end
diff --git a/jni/ruby/ext/openssl/lib/openssl/cipher.rb b/jni/ruby/ext/openssl/lib/openssl/cipher.rb
new file mode 100644
index 0000000..c32cea2
--- /dev/null
+++ b/jni/ruby/ext/openssl/lib/openssl/cipher.rb
@@ -0,0 +1,65 @@
+#--
+#
+# $RCSfile$
+#
+# = Ruby-space predefined Cipher subclasses
+#
+# = Info
+# 'OpenSSL for Ruby 2' project
+# Copyright (C) 2002 Michal Rokos <m.rokos@sh.cvut.cz>
+# All rights reserved.
+#
+# = Licence
+# This program is licenced under the same licence as Ruby.
+# (See the file 'LICENCE'.)
+#
+# = Version
+# $Id: cipher.rb 36895 2012-09-04 00:57:31Z nobu $
+#
+#++
+
+module OpenSSL
+ class Cipher
+ %w(AES CAST5 BF DES IDEA RC2 RC4 RC5).each{|name|
+ klass = Class.new(Cipher){
+ define_method(:initialize){|*args|
+ cipher_name = args.inject(name){|n, arg| "#{n}-#{arg}" }
+ super(cipher_name)
+ }
+ }
+ const_set(name, klass)
+ }
+
+ %w(128 192 256).each{|keylen|
+ klass = Class.new(Cipher){
+ define_method(:initialize){|mode|
+ mode ||= "CBC"
+ cipher_name = "AES-#{keylen}-#{mode}"
+ super(cipher_name)
+ }
+ }
+ const_set("AES#{keylen}", klass)
+ }
+
+ # Generate, set, and return a random key.
+ # You must call cipher.encrypt or cipher.decrypt before calling this method.
+ def random_key
+ str = OpenSSL::Random.random_bytes(self.key_len)
+ self.key = str
+ return str
+ end
+
+ # Generate, set, and return a random iv.
+ # You must call cipher.encrypt or cipher.decrypt before calling this method.
+ def random_iv
+ str = OpenSSL::Random.random_bytes(self.iv_len)
+ self.iv = str
+ return str
+ end
+
+ # This class is only provided for backwards compatibility. Use OpenSSL::Cipher in the future.
+ class Cipher < Cipher
+ # add warning
+ end
+ end # Cipher
+end # OpenSSL
diff --git a/jni/ruby/ext/openssl/lib/openssl/config.rb b/jni/ruby/ext/openssl/lib/openssl/config.rb
new file mode 100644
index 0000000..5716d59
--- /dev/null
+++ b/jni/ruby/ext/openssl/lib/openssl/config.rb
@@ -0,0 +1,472 @@
+=begin
+= Ruby-space definitions that completes C-space funcs for Config
+
+= Info
+ Copyright (C) 2010 Hiroshi Nakamura <nahi@ruby-lang.org>
+
+= Licence
+ This program is licenced under the same licence as Ruby.
+ (See the file 'LICENCE'.)
+
+=end
+
+require 'stringio'
+
+module OpenSSL
+ ##
+ # = OpenSSL::Config
+ #
+ # Configuration for the openssl library.
+ #
+ # Many system's installation of openssl library will depend on your system
+ # configuration. See the value of OpenSSL::Config::DEFAULT_CONFIG_FILE for
+ # the location of the file for your host.
+ #
+ # See also http://www.openssl.org/docs/apps/config.html
+ class Config
+ include Enumerable
+
+ class << self
+
+ ##
+ # Parses a given +string+ as a blob that contains configuration for openssl.
+ #
+ # If the source of the IO is a file, then consider using #parse_config.
+ def parse(string)
+ c = new()
+ parse_config(StringIO.new(string)).each do |section, hash|
+ c[section] = hash
+ end
+ c
+ end
+
+ ##
+ # load is an alias to ::new
+ alias load new
+
+ ##
+ # Parses the configuration data read from +io+, see also #parse.
+ #
+ # Raises a ConfigError on invalid configuration data.
+ def parse_config(io)
+ begin
+ parse_config_lines(io)
+ rescue ConfigError => e
+ e.message.replace("error in line #{io.lineno}: " + e.message)
+ raise
+ end
+ end
+
+ def get_key_string(data, section, key) # :nodoc:
+ if v = data[section] && data[section][key]
+ return v
+ elsif section == 'ENV'
+ if v = ENV[key]
+ return v
+ end
+ end
+ if v = data['default'] && data['default'][key]
+ return v
+ end
+ end
+
+ private
+
+ def parse_config_lines(io)
+ section = 'default'
+ data = {section => {}}
+ while definition = get_definition(io)
+ definition = clear_comments(definition)
+ next if definition.empty?
+ if definition[0] == ?[
+ if /\[([^\]]*)\]/ =~ definition
+ section = $1.strip
+ data[section] ||= {}
+ else
+ raise ConfigError, "missing close square bracket"
+ end
+ else
+ if /\A([^:\s]*)(?:::([^:\s]*))?\s*=(.*)\z/ =~ definition
+ if $2
+ section = $1
+ key = $2
+ else
+ key = $1
+ end
+ value = unescape_value(data, section, $3)
+ (data[section] ||= {})[key] = value.strip
+ else
+ raise ConfigError, "missing equal sign"
+ end
+ end
+ end
+ data
+ end
+
+ # escape with backslash
+ QUOTE_REGEXP_SQ = /\A([^'\\]*(?:\\.[^'\\]*)*)'/
+ # escape with backslash and doubled dq
+ QUOTE_REGEXP_DQ = /\A([^"\\]*(?:""[^"\\]*|\\.[^"\\]*)*)"/
+ # escaped char map
+ ESCAPE_MAP = {
+ "r" => "\r",
+ "n" => "\n",
+ "b" => "\b",
+ "t" => "\t",
+ }
+
+ def unescape_value(data, section, value)
+ scanned = []
+ while m = value.match(/['"\\$]/)
+ scanned << m.pre_match
+ c = m[0]
+ value = m.post_match
+ case c
+ when "'"
+ if m = value.match(QUOTE_REGEXP_SQ)
+ scanned << m[1].gsub(/\\(.)/, '\\1')
+ value = m.post_match
+ else
+ break
+ end
+ when '"'
+ if m = value.match(QUOTE_REGEXP_DQ)
+ scanned << m[1].gsub(/""/, '').gsub(/\\(.)/, '\\1')
+ value = m.post_match
+ else
+ break
+ end
+ when "\\"
+ c = value.slice!(0, 1)
+ scanned << (ESCAPE_MAP[c] || c)
+ when "$"
+ ref, value = extract_reference(value)
+ refsec = section
+ if ref.index('::')
+ refsec, ref = ref.split('::', 2)
+ end
+ if v = get_key_string(data, refsec, ref)
+ scanned << v
+ else
+ raise ConfigError, "variable has no value"
+ end
+ else
+ raise 'must not reaced'
+ end
+ end
+ scanned << value
+ scanned.join
+ end
+
+ def extract_reference(value)
+ rest = ''
+ if m = value.match(/\(([^)]*)\)|\{([^}]*)\}/)
+ value = m[1] || m[2]
+ rest = m.post_match
+ elsif [?(, ?{].include?(value[0])
+ raise ConfigError, "no close brace"
+ end
+ if m = value.match(/[a-zA-Z0-9_]*(?:::[a-zA-Z0-9_]*)?/)
+ return m[0], m.post_match + rest
+ else
+ raise
+ end
+ end
+
+ def clear_comments(line)
+ # FCOMMENT
+ if m = line.match(/\A([\t\n\f ]*);.*\z/)
+ return m[1]
+ end
+ # COMMENT
+ scanned = []
+ while m = line.match(/[#'"\\]/)
+ scanned << m.pre_match
+ c = m[0]
+ line = m.post_match
+ case c
+ when '#'
+ line = nil
+ break
+ when "'", '"'
+ regexp = (c == "'") ? QUOTE_REGEXP_SQ : QUOTE_REGEXP_DQ
+ scanned << c
+ if m = line.match(regexp)
+ scanned << m[0]
+ line = m.post_match
+ else
+ scanned << line
+ line = nil
+ break
+ end
+ when "\\"
+ scanned << c
+ scanned << line.slice!(0, 1)
+ else
+ raise 'must not reaced'
+ end
+ end
+ scanned << line
+ scanned.join
+ end
+
+ def get_definition(io)
+ if line = get_line(io)
+ while /[^\\]\\\z/ =~ line
+ if extra = get_line(io)
+ line += extra
+ else
+ break
+ end
+ end
+ return line.strip
+ end
+ end
+
+ def get_line(io)
+ if line = io.gets
+ line.gsub(/[\r\n]*/, '')
+ end
+ end
+ end
+
+ ##
+ # Creates an instance of OpenSSL's configuration class.
+ #
+ # This can be used in contexts like OpenSSL::X509::ExtensionFactory.config=
+ #
+ # If the optional +filename+ parameter is provided, then it is read in and
+ # parsed via #parse_config.
+ #
+ # This can raise IO exceptions based on the access, or availability of the
+ # file. A ConfigError exception may be raised depending on the validity of
+ # the data being configured.
+ #
+ def initialize(filename = nil)
+ @data = {}
+ if filename
+ File.open(filename.to_s) do |file|
+ Config.parse_config(file).each do |section, hash|
+ self[section] = hash
+ end
+ end
+ end
+ end
+
+ ##
+ # Gets the value of +key+ from the given +section+
+ #
+ # Given the following configurating file being loaded:
+ #
+ # config = OpenSSL::Config.load('foo.cnf')
+ # #=> #<OpenSSL::Config sections=["default"]>
+ # puts config.to_s
+ # #=> [ default ]
+ # # foo=bar
+ #
+ # You can get a specific value from the config if you know the +section+
+ # and +key+ like so:
+ #
+ # config.get_value('default','foo')
+ # #=> "bar"
+ #
+ def get_value(section, key)
+ if section.nil?
+ raise TypeError.new('nil not allowed')
+ end
+ section = 'default' if section.empty?
+ get_key_string(section, key)
+ end
+
+ ##
+ #
+ # *Deprecated*
+ #
+ # Use #get_value instead
+ def value(arg1, arg2 = nil) # :nodoc:
+ warn('Config#value is deprecated; use Config#get_value')
+ if arg2.nil?
+ section, key = 'default', arg1
+ else
+ section, key = arg1, arg2
+ end
+ section ||= 'default'
+ section = 'default' if section.empty?
+ get_key_string(section, key)
+ end
+
+ ##
+ # Set the target +key+ with a given +value+ under a specific +section+.
+ #
+ # Given the following configurating file being loaded:
+ #
+ # config = OpenSSL::Config.load('foo.cnf')
+ # #=> #<OpenSSL::Config sections=["default"]>
+ # puts config.to_s
+ # #=> [ default ]
+ # # foo=bar
+ #
+ # You can set the value of +foo+ under the +default+ section to a new
+ # value:
+ #
+ # config.add_value('default', 'foo', 'buzz')
+ # #=> "buzz"
+ # puts config.to_s
+ # #=> [ default ]
+ # # foo=buzz
+ #
+ def add_value(section, key, value)
+ check_modify
+ (@data[section] ||= {})[key] = value
+ end
+
+ ##
+ # Get a specific +section+ from the current configuration
+ #
+ # Given the following configurating file being loaded:
+ #
+ # config = OpenSSL::Config.load('foo.cnf')
+ # #=> #<OpenSSL::Config sections=["default"]>
+ # puts config.to_s
+ # #=> [ default ]
+ # # foo=bar
+ #
+ # You can get a hash of the specific section like so:
+ #
+ # config['default']
+ # #=> {"foo"=>"bar"}
+ #
+ def [](section)
+ @data[section] || {}
+ end
+
+ ##
+ # Deprecated
+ #
+ # Use #[] instead
+ def section(name) # :nodoc:
+ warn('Config#section is deprecated; use Config#[]')
+ @data[name] || {}
+ end
+
+ ##
+ # Sets a specific +section+ name with a Hash +pairs+
+ #
+ # Given the following configuration being created:
+ #
+ # config = OpenSSL::Config.new
+ # #=> #<OpenSSL::Config sections=[]>
+ # config['default'] = {"foo"=>"bar","baz"=>"buz"}
+ # #=> {"foo"=>"bar", "baz"=>"buz"}
+ # puts config.to_s
+ # #=> [ default ]
+ # # foo=bar
+ # # baz=buz
+ #
+ # It's important to note that this will essentially merge any of the keys
+ # in +pairs+ with the existing +section+. For example:
+ #
+ # config['default']
+ # #=> {"foo"=>"bar", "baz"=>"buz"}
+ # config['default'] = {"foo" => "changed"}
+ # #=> {"foo"=>"changed"}
+ # config['default']
+ # #=> {"foo"=>"changed", "baz"=>"buz"}
+ #
+ def []=(section, pairs)
+ check_modify
+ @data[section] ||= {}
+ pairs.each do |key, value|
+ self.add_value(section, key, value)
+ end
+ end
+
+ ##
+ # Get the names of all sections in the current configuration
+ def sections
+ @data.keys
+ end
+
+ ##
+ # Get the parsable form of the current configuration
+ #
+ # Given the following configuration being created:
+ #
+ # config = OpenSSL::Config.new
+ # #=> #<OpenSSL::Config sections=[]>
+ # config['default'] = {"foo"=>"bar","baz"=>"buz"}
+ # #=> {"foo"=>"bar", "baz"=>"buz"}
+ # puts config.to_s
+ # #=> [ default ]
+ # # foo=bar
+ # # baz=buz
+ #
+ # You can parse get the serialized configuration using #to_s and then parse
+ # it later:
+ #
+ # serialized_config = config.to_s
+ # # much later...
+ # new_config = OpenSSL::Config.parse(serialized_config)
+ # #=> #<OpenSSL::Config sections=["default"]>
+ # puts new_config
+ # #=> [ default ]
+ # foo=bar
+ # baz=buz
+ #
+ def to_s
+ ary = []
+ @data.keys.sort.each do |section|
+ ary << "[ #{section} ]\n"
+ @data[section].keys.each do |key|
+ ary << "#{key}=#{@data[section][key]}\n"
+ end
+ ary << "\n"
+ end
+ ary.join
+ end
+
+ ##
+ # For a block.
+ #
+ # Receive the section and its pairs for the current configuration.
+ #
+ # config.each do |section, key, value|
+ # # ...
+ # end
+ #
+ def each
+ @data.each do |section, hash|
+ hash.each do |key, value|
+ yield [section, key, value]
+ end
+ end
+ end
+
+ ##
+ # String representation of this configuration object, including the class
+ # name and its sections.
+ def inspect
+ "#<#{self.class.name} sections=#{sections.inspect}>"
+ end
+
+ protected
+
+ def data # :nodoc:
+ @data
+ end
+
+ private
+
+ def initialize_copy(other)
+ @data = other.data.dup
+ end
+
+ def check_modify
+ raise TypeError.new("Insecure: can't modify OpenSSL config") if frozen?
+ end
+
+ def get_key_string(section, key)
+ Config.get_key_string(@data, section, key)
+ end
+ end
+end
diff --git a/jni/ruby/ext/openssl/lib/openssl/digest.rb b/jni/ruby/ext/openssl/lib/openssl/digest.rb
new file mode 100644
index 0000000..f63892a
--- /dev/null
+++ b/jni/ruby/ext/openssl/lib/openssl/digest.rb
@@ -0,0 +1,88 @@
+#--
+#
+# $RCSfile$
+#
+# = Ruby-space predefined Digest subclasses
+#
+# = Info
+# 'OpenSSL for Ruby 2' project
+# Copyright (C) 2002 Michal Rokos <m.rokos@sh.cvut.cz>
+# All rights reserved.
+#
+# = Licence
+# This program is licenced under the same licence as Ruby.
+# (See the file 'LICENCE'.)
+#
+# = Version
+# $Id: digest.rb 44116 2013-12-10 07:16:03Z nobu $
+#
+#++
+
+module OpenSSL
+ class Digest
+
+ alg = %w(DSS DSS1 MD2 MD4 MD5 MDC2 RIPEMD160 SHA SHA1)
+ if OPENSSL_VERSION_NUMBER > 0x00908000
+ alg += %w(SHA224 SHA256 SHA384 SHA512)
+ end
+
+ # Return the +data+ hash computed with +name+ Digest. +name+ is either the
+ # long name or short name of a supported digest algorithm.
+ #
+ # === Examples
+ #
+ # OpenSSL::Digest.digest("SHA256", "abc")
+ #
+ # which is equivalent to:
+ #
+ # OpenSSL::Digest::SHA256.digest("abc")
+
+ def self.digest(name, data)
+ super(data, name)
+ end
+
+ alg.each{|name|
+ klass = Class.new(self) {
+ define_method(:initialize, ->(data = nil) {super(name, data)})
+ }
+ singleton = (class << klass; self; end)
+ singleton.class_eval{
+ define_method(:digest){|data| new.digest(data) }
+ define_method(:hexdigest){|data| new.hexdigest(data) }
+ }
+ const_set(name, klass)
+ }
+
+ # Deprecated.
+ #
+ # This class is only provided for backwards compatibility.
+ class Digest < Digest # :nodoc:
+ # Deprecated.
+ #
+ # See OpenSSL::Digest.new
+ def initialize(*args)
+ warn('Digest::Digest is deprecated; use Digest')
+ super(*args)
+ end
+ end
+
+ end # Digest
+
+ # Returns a Digest subclass by +name+.
+ #
+ # require 'openssl'
+ #
+ # OpenSSL::Digest("MD5")
+ # # => OpenSSL::Digest::MD5
+ #
+ # Digest("Foo")
+ # # => NameError: wrong constant name Foo
+
+ def Digest(name)
+ OpenSSL::Digest.const_get(name)
+ end
+
+ module_function :Digest
+
+end # OpenSSL
+
diff --git a/jni/ruby/ext/openssl/lib/openssl/ssl.rb b/jni/ruby/ext/openssl/lib/openssl/ssl.rb
new file mode 100644
index 0000000..fdd037b
--- /dev/null
+++ b/jni/ruby/ext/openssl/lib/openssl/ssl.rb
@@ -0,0 +1,324 @@
+=begin
+= $RCSfile$ -- Ruby-space definitions that completes C-space funcs for SSL
+
+= Info
+ 'OpenSSL for Ruby 2' project
+ Copyright (C) 2001 GOTOU YUUZOU <gotoyuzo@notwork.org>
+ All rights reserved.
+
+= Licence
+ This program is licenced under the same licence as Ruby.
+ (See the file 'LICENCE'.)
+
+= Version
+ $Id: ssl.rb 51554 2015-08-12 15:16:42Z nagachika $
+=end
+
+require "openssl/buffering"
+require "fcntl"
+
+module OpenSSL
+ module SSL
+ class SSLContext
+ DEFAULT_PARAMS = {
+ :ssl_version => "SSLv23",
+ :verify_mode => OpenSSL::SSL::VERIFY_PEER,
+ :ciphers => %w{
+ ECDHE-ECDSA-AES128-GCM-SHA256
+ ECDHE-RSA-AES128-GCM-SHA256
+ ECDHE-ECDSA-AES256-GCM-SHA384
+ ECDHE-RSA-AES256-GCM-SHA384
+ DHE-RSA-AES128-GCM-SHA256
+ DHE-DSS-AES128-GCM-SHA256
+ DHE-RSA-AES256-GCM-SHA384
+ DHE-DSS-AES256-GCM-SHA384
+ ECDHE-ECDSA-AES128-SHA256
+ ECDHE-RSA-AES128-SHA256
+ ECDHE-ECDSA-AES128-SHA
+ ECDHE-RSA-AES128-SHA
+ ECDHE-ECDSA-AES256-SHA384
+ ECDHE-RSA-AES256-SHA384
+ ECDHE-ECDSA-AES256-SHA
+ ECDHE-RSA-AES256-SHA
+ DHE-RSA-AES128-SHA256
+ DHE-RSA-AES256-SHA256
+ DHE-RSA-AES128-SHA
+ DHE-RSA-AES256-SHA
+ DHE-DSS-AES128-SHA256
+ DHE-DSS-AES256-SHA256
+ DHE-DSS-AES128-SHA
+ DHE-DSS-AES256-SHA
+ AES128-GCM-SHA256
+ AES256-GCM-SHA384
+ AES128-SHA256
+ AES256-SHA256
+ AES128-SHA
+ AES256-SHA
+ ECDHE-ECDSA-RC4-SHA
+ ECDHE-RSA-RC4-SHA
+ RC4-SHA
+ }.join(":"),
+ :options => -> {
+ opts = OpenSSL::SSL::OP_ALL
+ opts &= ~OpenSSL::SSL::OP_DONT_INSERT_EMPTY_FRAGMENTS if defined?(OpenSSL::SSL::OP_DONT_INSERT_EMPTY_FRAGMENTS)
+ opts |= OpenSSL::SSL::OP_NO_COMPRESSION if defined?(OpenSSL::SSL::OP_NO_COMPRESSION)
+ opts |= OpenSSL::SSL::OP_NO_SSLv2 if defined?(OpenSSL::SSL::OP_NO_SSLv2)
+ opts |= OpenSSL::SSL::OP_NO_SSLv3 if defined?(OpenSSL::SSL::OP_NO_SSLv3)
+ opts
+ }.call
+ }
+
+ DEFAULT_CERT_STORE = OpenSSL::X509::Store.new
+ DEFAULT_CERT_STORE.set_default_paths
+ if defined?(OpenSSL::X509::V_FLAG_CRL_CHECK_ALL)
+ DEFAULT_CERT_STORE.flags = OpenSSL::X509::V_FLAG_CRL_CHECK_ALL
+ end
+
+ ##
+ # Sets the parameters for this SSL context to the values in +params+.
+ # The keys in +params+ must be assignment methods on SSLContext.
+ #
+ # If the verify_mode is not VERIFY_NONE and ca_file, ca_path and
+ # cert_store are not set then the system default certificate store is
+ # used.
+
+ def set_params(params={})
+ params = DEFAULT_PARAMS.merge(params)
+ params.each{|name, value| self.__send__("#{name}=", value) }
+ if self.verify_mode != OpenSSL::SSL::VERIFY_NONE
+ unless self.ca_file or self.ca_path or self.cert_store
+ self.cert_store = DEFAULT_CERT_STORE
+ end
+ end
+ return params
+ end
+ end
+
+ module SocketForwarder
+ def addr
+ to_io.addr
+ end
+
+ def peeraddr
+ to_io.peeraddr
+ end
+
+ def setsockopt(level, optname, optval)
+ to_io.setsockopt(level, optname, optval)
+ end
+
+ def getsockopt(level, optname)
+ to_io.getsockopt(level, optname)
+ end
+
+ def fcntl(*args)
+ to_io.fcntl(*args)
+ end
+
+ def closed?
+ to_io.closed?
+ end
+
+ def do_not_reverse_lookup=(flag)
+ to_io.do_not_reverse_lookup = flag
+ end
+ end
+
+ module Nonblock
+ def initialize(*args)
+ flag = File::NONBLOCK
+ flag |= @io.fcntl(Fcntl::F_GETFL) if defined?(Fcntl::F_GETFL)
+ @io.fcntl(Fcntl::F_SETFL, flag)
+ super
+ end
+ end
+
+ def verify_certificate_identity(cert, hostname)
+ should_verify_common_name = true
+ cert.extensions.each{|ext|
+ next if ext.oid != "subjectAltName"
+ ostr = OpenSSL::ASN1.decode(ext.to_der).value.last
+ sequence = OpenSSL::ASN1.decode(ostr.value)
+ sequence.value.each{|san|
+ case san.tag
+ when 2 # dNSName in GeneralName (RFC5280)
+ should_verify_common_name = false
+ return true if verify_hostname(hostname, san.value)
+ when 7 # iPAddress in GeneralName (RFC5280)
+ should_verify_common_name = false
+ # follows GENERAL_NAME_print() in x509v3/v3_alt.c
+ if san.value.size == 4
+ return true if san.value.unpack('C*').join('.') == hostname
+ elsif san.value.size == 16
+ return true if san.value.unpack('n*').map { |e| sprintf("%X", e) }.join(':') == hostname
+ end
+ end
+ }
+ }
+ if should_verify_common_name
+ cert.subject.to_a.each{|oid, value|
+ if oid == "CN"
+ return true if verify_hostname(hostname, value)
+ end
+ }
+ end
+ return false
+ end
+ module_function :verify_certificate_identity
+
+ def verify_hostname(hostname, san) # :nodoc:
+ # RFC 5280, IA5String is limited to the set of ASCII characters
+ return false unless san.ascii_only?
+ return false unless hostname.ascii_only?
+
+ # See RFC 6125, section 6.4.1
+ # Matching is case-insensitive.
+ san_parts = san.downcase.split(".")
+
+ # TODO: this behavior should probably be more strict
+ return san == hostname if san_parts.size < 2
+
+ # Matching is case-insensitive.
+ host_parts = hostname.downcase.split(".")
+
+ # RFC 6125, section 6.4.3, subitem 2.
+ # If the wildcard character is the only character of the left-most
+ # label in the presented identifier, the client SHOULD NOT compare
+ # against anything but the left-most label of the reference
+ # identifier (e.g., *.example.com would match foo.example.com but
+ # not bar.foo.example.com or example.com).
+ return false unless san_parts.size == host_parts.size
+
+ # RFC 6125, section 6.4.3, subitem 1.
+ # The client SHOULD NOT attempt to match a presented identifier in
+ # which the wildcard character comprises a label other than the
+ # left-most label (e.g., do not match bar.*.example.net).
+ return false unless verify_wildcard(host_parts.shift, san_parts.shift)
+
+ san_parts.join(".") == host_parts.join(".")
+ end
+ module_function :verify_hostname
+
+ def verify_wildcard(domain_component, san_component) # :nodoc:
+ parts = san_component.split("*", -1)
+
+ return false if parts.size > 2
+ return san_component == domain_component if parts.size == 1
+
+ # RFC 6125, section 6.4.3, subitem 3.
+ # The client SHOULD NOT attempt to match a presented identifier
+ # where the wildcard character is embedded within an A-label or
+ # U-label of an internationalized domain name.
+ return false if domain_component.start_with?("xn--") && san_component != "*"
+
+ parts[0].length + parts[1].length < domain_component.length &&
+ domain_component.start_with?(parts[0]) &&
+ domain_component.end_with?(parts[1])
+ end
+ module_function :verify_wildcard
+
+ class SSLSocket
+ include Buffering
+ include SocketForwarder
+ include Nonblock
+
+ ##
+ # Perform hostname verification after an SSL connection is established
+ #
+ # This method MUST be called after calling #connect to ensure that the
+ # hostname of a remote peer has been verified.
+ def post_connection_check(hostname)
+ if peer_cert.nil?
+ msg = "Peer verification enabled, but no certificate received."
+ if using_anon_cipher?
+ msg += " Anonymous cipher suite #{cipher[0]} was negotiated. Anonymous suites must be disabled to use peer verification."
+ end
+ raise SSLError, msg
+ end
+
+ unless OpenSSL::SSL.verify_certificate_identity(peer_cert, hostname)
+ raise SSLError, "hostname \"#{hostname}\" does not match the server certificate"
+ end
+ return true
+ end
+
+ def session
+ SSL::Session.new(self)
+ rescue SSL::Session::SessionError
+ nil
+ end
+
+ private
+
+ def using_anon_cipher?
+ ctx = OpenSSL::SSL::SSLContext.new
+ ctx.ciphers = "aNULL"
+ ctx.ciphers.include?(cipher)
+ end
+ end
+
+ ##
+ # SSLServer represents a TCP/IP server socket with Secure Sockets Layer.
+ class SSLServer
+ include SocketForwarder
+ # When true then #accept works exactly the same as TCPServer#accept
+ attr_accessor :start_immediately
+
+ # Creates a new instance of SSLServer.
+ # * +srv+ is an instance of TCPServer.
+ # * +ctx+ is an instance of OpenSSL::SSL::SSLContext.
+ def initialize(svr, ctx)
+ @svr = svr
+ @ctx = ctx
+ unless ctx.session_id_context
+ # see #6137 - session id may not exceed 32 bytes
+ prng = ::Random.new($0.hash)
+ session_id = prng.bytes(16).unpack('H*')[0]
+ @ctx.session_id_context = session_id
+ end
+ @start_immediately = true
+ end
+
+ # Returns the TCPServer passed to the SSLServer when initialized.
+ def to_io
+ @svr
+ end
+
+ # See TCPServer#listen for details.
+ def listen(backlog=5)
+ @svr.listen(backlog)
+ end
+
+ # See BasicSocket#shutdown for details.
+ def shutdown(how=Socket::SHUT_RDWR)
+ @svr.shutdown(how)
+ end
+
+ # Works similar to TCPServer#accept.
+ def accept
+ # Socket#accept returns [socket, addrinfo].
+ # TCPServer#accept returns a socket.
+ # The following comma strips addrinfo.
+ sock, = @svr.accept
+ begin
+ ssl = OpenSSL::SSL::SSLSocket.new(sock, @ctx)
+ ssl.sync_close = true
+ ssl.accept if @start_immediately
+ ssl
+ rescue Exception => ex
+ if ssl
+ ssl.close
+ else
+ sock.close
+ end
+ raise ex
+ end
+ end
+
+ # See IO#close for details.
+ def close
+ @svr.close
+ end
+ end
+ end
+end
diff --git a/jni/ruby/ext/openssl/lib/openssl/x509.rb b/jni/ruby/ext/openssl/lib/openssl/x509.rb
new file mode 100644
index 0000000..bdeadb1
--- /dev/null
+++ b/jni/ruby/ext/openssl/lib/openssl/x509.rb
@@ -0,0 +1,182 @@
+#--
+#
+# $RCSfile$
+#
+# = Ruby-space definitions that completes C-space funcs for X509 and subclasses
+#
+# = Info
+# 'OpenSSL for Ruby 2' project
+# Copyright (C) 2002 Michal Rokos <m.rokos@sh.cvut.cz>
+# All rights reserved.
+#
+# = Licence
+# This program is licenced under the same licence as Ruby.
+# (See the file 'LICENCE'.)
+#
+# = Version
+# $Id: x509.rb 48521 2014-11-20 15:39:03Z usa $
+#
+#++
+
+module OpenSSL
+ module X509
+ class ExtensionFactory
+ def create_extension(*arg)
+ if arg.size > 1
+ create_ext(*arg)
+ else
+ send("create_ext_from_"+arg[0].class.name.downcase, arg[0])
+ end
+ end
+
+ def create_ext_from_array(ary)
+ raise ExtensionError, "unexpected array form" if ary.size > 3
+ create_ext(ary[0], ary[1], ary[2])
+ end
+
+ def create_ext_from_string(str) # "oid = critical, value"
+ oid, value = str.split(/=/, 2)
+ oid.strip!
+ value.strip!
+ create_ext(oid, value)
+ end
+
+ def create_ext_from_hash(hash)
+ create_ext(hash["oid"], hash["value"], hash["critical"])
+ end
+ end
+
+ class Extension
+ def to_s # "oid = critical, value"
+ str = self.oid
+ str << " = "
+ str << "critical, " if self.critical?
+ str << self.value.gsub(/\n/, ", ")
+ end
+
+ def to_h # {"oid"=>sn|ln, "value"=>value, "critical"=>true|false}
+ {"oid"=>self.oid,"value"=>self.value,"critical"=>self.critical?}
+ end
+
+ def to_a
+ [ self.oid, self.value, self.critical? ]
+ end
+ end
+
+ class Name
+ module RFC2253DN
+ Special = ',=+<>#;'
+ HexChar = /[0-9a-fA-F]/
+ HexPair = /#{HexChar}#{HexChar}/
+ HexString = /#{HexPair}+/
+ Pair = /\\(?:[#{Special}]|\\|"|#{HexPair})/
+ StringChar = /[^\\"#{Special}]/
+ QuoteChar = /[^\\"]/
+ AttributeType = /[a-zA-Z][0-9a-zA-Z]*|[0-9]+(?:\.[0-9]+)*/
+ AttributeValue = /
+ (?!["#])((?:#{StringChar}|#{Pair})*)|
+ \#(#{HexString})|
+ "((?:#{QuoteChar}|#{Pair})*)"
+ /x
+ TypeAndValue = /\A(#{AttributeType})=#{AttributeValue}/
+
+ module_function
+
+ def expand_pair(str)
+ return nil unless str
+ return str.gsub(Pair){
+ pair = $&
+ case pair.size
+ when 2 then pair[1,1]
+ when 3 then Integer("0x#{pair[1,2]}").chr
+ else raise OpenSSL::X509::NameError, "invalid pair: #{str}"
+ end
+ }
+ end
+
+ def expand_hexstring(str)
+ return nil unless str
+ der = str.gsub(HexPair){$&.to_i(16).chr }
+ a1 = OpenSSL::ASN1.decode(der)
+ return a1.value, a1.tag
+ end
+
+ def expand_value(str1, str2, str3)
+ value = expand_pair(str1)
+ value, tag = expand_hexstring(str2) unless value
+ value = expand_pair(str3) unless value
+ return value, tag
+ end
+
+ def scan(dn)
+ str = dn
+ ary = []
+ while true
+ if md = TypeAndValue.match(str)
+ remain = md.post_match
+ type = md[1]
+ value, tag = expand_value(md[2], md[3], md[4]) rescue nil
+ if value
+ type_and_value = [type, value]
+ type_and_value.push(tag) if tag
+ ary.unshift(type_and_value)
+ if remain.length > 2 && remain[0] == ?,
+ str = remain[1..-1]
+ next
+ elsif remain.length > 2 && remain[0] == ?+
+ raise OpenSSL::X509::NameError,
+ "multi-valued RDN is not supported: #{dn}"
+ elsif remain.empty?
+ break
+ end
+ end
+ end
+ msg_dn = dn[0, dn.length - str.length] + " =>" + str
+ raise OpenSSL::X509::NameError, "malformed RDN: #{msg_dn}"
+ end
+ return ary
+ end
+ end
+
+ class << self
+ def parse_rfc2253(str, template=OBJECT_TYPE_TEMPLATE)
+ ary = OpenSSL::X509::Name::RFC2253DN.scan(str)
+ self.new(ary, template)
+ end
+
+ def parse_openssl(str, template=OBJECT_TYPE_TEMPLATE)
+ ary = str.scan(/\s*([^\/,]+)\s*/).collect{|i| i[0].split("=", 2) }
+ self.new(ary, template)
+ end
+
+ alias parse parse_openssl
+ end
+
+ def pretty_print(q)
+ q.object_group(self) {
+ q.text ' '
+ q.text to_s(OpenSSL::X509::Name::RFC2253)
+ }
+ end
+ end
+
+ class StoreContext
+ def cleanup
+ warn "(#{caller.first}) OpenSSL::X509::StoreContext#cleanup is deprecated with no replacement" if $VERBOSE
+ end
+ end
+
+ class Certificate
+ def pretty_print(q)
+ q.object_group(self) {
+ q.breakable
+ q.text 'subject='; q.pp self.subject; q.text ','; q.breakable
+ q.text 'issuer='; q.pp self.issuer; q.text ','; q.breakable
+ q.text 'serial='; q.pp self.serial; q.text ','; q.breakable
+ q.text 'not_before='; q.pp self.not_before; q.text ','; q.breakable
+ q.text 'not_after='; q.pp self.not_after
+ }
+ end
+ end
+ end
+end
diff --git a/jni/ruby/ext/openssl/openssl_missing.c b/jni/ruby/ext/openssl/openssl_missing.c
new file mode 100644
index 0000000..dd88ab9
--- /dev/null
+++ b/jni/ruby/ext/openssl/openssl_missing.c
@@ -0,0 +1,356 @@
+/*
+ * $Id: openssl_missing.c 40625 2013-05-09 12:12:17Z akr $
+ * 'OpenSSL for Ruby' project
+ * Copyright (C) 2001-2002 Michal Rokos <m.rokos@sh.cvut.cz>
+ * All rights reserved.
+ */
+/*
+ * This program is licenced under the same licence as Ruby.
+ * (See the file 'LICENCE'.)
+ */
+#include RUBY_EXTCONF_H
+
+#if defined(HAVE_OPENSSL_ENGINE_H) && defined(HAVE_EVP_CIPHER_CTX_ENGINE)
+# include <openssl/engine.h>
+#endif
+#include <openssl/x509_vfy.h>
+
+#if !defined(OPENSSL_NO_HMAC)
+#include <string.h> /* memcpy() */
+#include <openssl/hmac.h>
+
+#include "openssl_missing.h"
+
+#if !defined(HAVE_HMAC_CTX_COPY)
+void
+HMAC_CTX_copy(HMAC_CTX *out, HMAC_CTX *in)
+{
+ if (!out || !in) return;
+ memcpy(out, in, sizeof(HMAC_CTX));
+
+ EVP_MD_CTX_copy(&out->md_ctx, &in->md_ctx);
+ EVP_MD_CTX_copy(&out->i_ctx, &in->i_ctx);
+ EVP_MD_CTX_copy(&out->o_ctx, &in->o_ctx);
+}
+#endif /* HAVE_HMAC_CTX_COPY */
+#endif /* NO_HMAC */
+
+#if !defined(HAVE_X509_STORE_SET_EX_DATA)
+int X509_STORE_set_ex_data(X509_STORE *str, int idx, void *data)
+{
+ return CRYPTO_set_ex_data(&str->ex_data, idx, data);
+}
+#endif
+
+#if !defined(HAVE_X509_STORE_GET_EX_DATA)
+void *X509_STORE_get_ex_data(X509_STORE *str, int idx)
+{
+ return CRYPTO_get_ex_data(&str->ex_data, idx);
+}
+#endif
+
+#if !defined(HAVE_EVP_MD_CTX_CREATE)
+EVP_MD_CTX *
+EVP_MD_CTX_create(void)
+{
+ EVP_MD_CTX *ctx = OPENSSL_malloc(sizeof(EVP_MD_CTX));
+ if (!ctx) return NULL;
+
+ memset(ctx, 0, sizeof(EVP_MD_CTX));
+
+ return ctx;
+}
+#endif
+
+#if !defined(HAVE_EVP_MD_CTX_CLEANUP)
+int
+EVP_MD_CTX_cleanup(EVP_MD_CTX *ctx)
+{
+ /* FIXME!!! */
+ memset(ctx, 0, sizeof(EVP_MD_CTX));
+
+ return 1;
+}
+#endif
+
+#if !defined(HAVE_EVP_MD_CTX_DESTROY)
+void
+EVP_MD_CTX_destroy(EVP_MD_CTX *ctx)
+{
+ EVP_MD_CTX_cleanup(ctx);
+ OPENSSL_free(ctx);
+}
+#endif
+
+#if !defined(HAVE_EVP_MD_CTX_INIT)
+void
+EVP_MD_CTX_init(EVP_MD_CTX *ctx)
+{
+ memset(ctx, 0, sizeof(EVP_MD_CTX));
+}
+#endif
+
+#if !defined(HAVE_HMAC_CTX_INIT)
+void
+HMAC_CTX_init(HMAC_CTX *ctx)
+{
+ EVP_MD_CTX_init(&ctx->i_ctx);
+ EVP_MD_CTX_init(&ctx->o_ctx);
+ EVP_MD_CTX_init(&ctx->md_ctx);
+}
+#endif
+
+#if !defined(HAVE_HMAC_CTX_CLEANUP)
+void
+HMAC_CTX_cleanup(HMAC_CTX *ctx)
+{
+ EVP_MD_CTX_cleanup(&ctx->i_ctx);
+ EVP_MD_CTX_cleanup(&ctx->o_ctx);
+ EVP_MD_CTX_cleanup(&ctx->md_ctx);
+ memset(ctx, 0, sizeof(HMAC_CTX));
+}
+#endif
+
+#if !defined(HAVE_EVP_CIPHER_CTX_COPY)
+/*
+ * this function does not exist in OpenSSL yet... or ever?.
+ * a future version may break this function.
+ * tested on 0.9.7d.
+ */
+int
+EVP_CIPHER_CTX_copy(EVP_CIPHER_CTX *out, EVP_CIPHER_CTX *in)
+{
+ memcpy(out, in, sizeof(EVP_CIPHER_CTX));
+
+#if defined(HAVE_ENGINE_ADD) && defined(HAVE_EVP_CIPHER_CTX_ENGINE)
+ if (in->engine) ENGINE_add(out->engine);
+ if (in->cipher_data) {
+ out->cipher_data = OPENSSL_malloc(in->cipher->ctx_size);
+ memcpy(out->cipher_data, in->cipher_data, in->cipher->ctx_size);
+ }
+#endif
+
+ return 1;
+}
+#endif
+
+#if !defined(HAVE_X509_CRL_SET_VERSION)
+int
+X509_CRL_set_version(X509_CRL *x, long version)
+{
+ if (x == NULL || x->crl == NULL) return 0;
+ if (x->crl->version == NULL) {
+ x->crl->version = M_ASN1_INTEGER_new();
+ if (x->crl->version == NULL) return 0;
+ }
+ return ASN1_INTEGER_set(x->crl->version, version);
+}
+#endif
+
+#if !defined(HAVE_X509_CRL_SET_ISSUER_NAME)
+int
+X509_CRL_set_issuer_name(X509_CRL *x, X509_NAME *name)
+{
+ if (x == NULL || x->crl == NULL) return 0;
+ return X509_NAME_set(&x->crl->issuer, name);
+}
+#endif
+
+#if !defined(HAVE_X509_CRL_SORT)
+int
+X509_CRL_sort(X509_CRL *c)
+{
+ int i;
+ X509_REVOKED *r;
+ /* sort the data so it will be written in serial
+ * number order */
+ sk_X509_REVOKED_sort(c->crl->revoked);
+ for (i=0; i<sk_X509_REVOKED_num(c->crl->revoked); i++) {
+ r=sk_X509_REVOKED_value(c->crl->revoked, i);
+ r->sequence=i;
+ }
+ return 1;
+}
+#endif
+
+#if !defined(HAVE_X509_CRL_ADD0_REVOKED)
+static int
+OSSL_X509_REVOKED_cmp(const X509_REVOKED * const *a, const X509_REVOKED * const *b)
+{
+ return(ASN1_STRING_cmp(
+ (ASN1_STRING *)(*a)->serialNumber,
+ (ASN1_STRING *)(*b)->serialNumber));
+}
+
+int
+X509_CRL_add0_revoked(X509_CRL *crl, X509_REVOKED *rev)
+{
+ X509_CRL_INFO *inf;
+
+ inf = crl->crl;
+ if (!inf->revoked)
+ inf->revoked = sk_X509_REVOKED_new(OSSL_X509_REVOKED_cmp);
+ if (!inf->revoked || !sk_X509_REVOKED_push(inf->revoked, rev))
+ return 0;
+ return 1;
+}
+#endif
+
+#if !defined(HAVE_BN_MOD_SQR)
+int
+BN_mod_sqr(BIGNUM *r, const BIGNUM *a, const BIGNUM *m, BN_CTX *ctx)
+{
+ if (!BN_sqr(r, (BIGNUM*)a, ctx)) return 0;
+ return BN_mod(r, r, m, ctx);
+}
+#endif
+
+#if !defined(HAVE_BN_MOD_ADD) || !defined(HAVE_BN_MOD_SUB)
+int BN_nnmod(BIGNUM *r, const BIGNUM *m, const BIGNUM *d, BN_CTX *ctx)
+{
+ if (!BN_mod(r,m,d,ctx)) return 0;
+ if (!r->neg) return 1;
+ return (d->neg ? BN_sub : BN_add)(r, r, d);
+}
+#endif
+
+#if !defined(HAVE_BN_MOD_ADD)
+int
+BN_mod_add(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, const BIGNUM *m, BN_CTX *ctx)
+{
+ if (!BN_add(r, a, b)) return 0;
+ return BN_nnmod(r, r, m, ctx);
+}
+#endif
+
+#if !defined(HAVE_BN_MOD_SUB)
+int
+BN_mod_sub(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, const BIGNUM *m, BN_CTX *ctx)
+{
+ if (!BN_sub(r, a, b)) return 0;
+ return BN_nnmod(r, r, m, ctx);
+}
+#endif
+
+#if !defined(HAVE_BN_RAND_RANGE) || !defined(HAVE_BN_PSEUDO_RAND_RANGE)
+static int
+bn_rand_range(int pseudo, BIGNUM *r, BIGNUM *range)
+{
+ int (*bn_rand)(BIGNUM *, int, int, int) = pseudo ? BN_pseudo_rand : BN_rand;
+ int n;
+
+ if (range->neg || BN_is_zero(range)) return 0;
+
+ n = BN_num_bits(range);
+
+ if (n == 1) {
+ if (!BN_zero(r)) return 0;
+ } else if (!BN_is_bit_set(range, n - 2) && !BN_is_bit_set(range, n - 3)) {
+ do {
+ if (!bn_rand(r, n + 1, -1, 0)) return 0;
+ if (BN_cmp(r ,range) >= 0) {
+ if (!BN_sub(r, r, range)) return 0;
+ if (BN_cmp(r, range) >= 0)
+ if (!BN_sub(r, r, range)) return 0;
+ }
+ } while (BN_cmp(r, range) >= 0);
+ } else {
+ do {
+ if (!bn_rand(r, n, -1, 0)) return 0;
+ } while (BN_cmp(r, range) >= 0);
+ }
+
+ return 1;
+}
+#endif
+
+#if !defined(HAVE_BN_RAND_RANGE)
+int
+BN_rand_range(BIGNUM *r, BIGNUM *range)
+{
+ return bn_rand_range(0, r, range);
+}
+#endif
+
+#if !defined(HAVE_BN_PSEUDO_RAND_RANGE)
+int
+BN_pseudo_rand_range(BIGNUM *r, BIGNUM *range)
+{
+ return bn_rand_range(1, r, range);
+}
+#endif
+
+#if !defined(HAVE_CONF_GET1_DEFAULT_CONFIG_FILE)
+#define OPENSSL_CONF "openssl.cnf"
+char *
+CONF_get1_default_config_file(void)
+{
+ char *file;
+ int len;
+
+ file = getenv("OPENSSL_CONF");
+ if (file) return BUF_strdup(file);
+ len = strlen(X509_get_default_cert_area());
+#ifndef OPENSSL_SYS_VMS
+ len++;
+#endif
+ len += strlen(OPENSSL_CONF);
+ file = OPENSSL_malloc(len + 1);
+ if (!file) return NULL;
+ strcpy(file,X509_get_default_cert_area());
+#ifndef OPENSSL_SYS_VMS
+ strcat(file,"/");
+#endif
+ strcat(file,OPENSSL_CONF);
+
+ return file;
+}
+#endif
+
+#if !defined(HAVE_PEM_DEF_CALLBACK)
+#define OSSL_PASS_MIN_LENGTH 4
+int
+PEM_def_callback(char *buf, int num, int w, void *key)
+{
+ int i,j;
+ const char *prompt;
+
+ if (key) {
+ i = strlen(key);
+ i = (i > num) ? num : i;
+ memcpy(buf, key, i);
+ return i;
+ }
+
+ prompt = EVP_get_pw_prompt();
+ if (prompt == NULL) prompt = "Enter PEM pass phrase:";
+ for (;;) {
+ i = EVP_read_pw_string(buf, num, prompt, w);
+ if (i != 0) {
+ memset(buf, 0, (unsigned int)num);
+ return(-1);
+ }
+ j = strlen(buf);
+ if (j < OSSL_PASS_MIN_LENGTH) {
+ fprintf(stderr,
+ "phrase is too short, needs to be at least %d chars\n",
+ OSSL_PASS_MIN_LENGTH);
+ }
+ else break;
+ }
+ return j;
+}
+#endif
+
+#if !defined(HAVE_ASN1_PUT_EOC)
+int
+ASN1_put_eoc(unsigned char **pp)
+{
+ unsigned char *p = *pp;
+ *p++ = 0;
+ *p++ = 0;
+ *pp = p;
+ return 2;
+}
+#endif
+
diff --git a/jni/ruby/ext/openssl/openssl_missing.h b/jni/ruby/ext/openssl/openssl_missing.h
new file mode 100644
index 0000000..983c481
--- /dev/null
+++ b/jni/ruby/ext/openssl/openssl_missing.h
@@ -0,0 +1,198 @@
+/*
+ * $Id: openssl_missing.h 32230 2011-06-26 01:32:03Z emboss $
+ * 'OpenSSL for Ruby' project
+ * Copyright (C) 2001-2002 Michal Rokos <m.rokos@sh.cvut.cz>
+ * All rights reserved.
+ */
+/*
+ * This program is licenced under the same licence as Ruby.
+ * (See the file 'LICENCE'.)
+ */
+#if !defined(_OSSL_OPENSSL_MISSING_H_)
+#define _OSSL_OPENSSL_MISSING_H_
+
+#if defined(__cplusplus)
+extern "C" {
+#endif
+
+#ifndef TYPEDEF_D2I_OF
+typedef char *d2i_of_void();
+#endif
+#ifndef TYPEDEF_I2D_OF
+typedef int i2d_of_void();
+#endif
+
+/*
+ * These functions are not included in headers of OPENSSL <= 0.9.6b
+ */
+
+#if !defined(PEM_read_bio_DSAPublicKey)
+# define PEM_read_bio_DSAPublicKey(bp,x,cb,u) (DSA *)PEM_ASN1_read_bio( \
+ (d2i_of_void *)d2i_DSAPublicKey,PEM_STRING_DSA_PUBLIC,(bp),(void **)(x),(cb),(u))
+#endif
+
+#if !defined(PEM_write_bio_DSAPublicKey)
+# define PEM_write_bio_DSAPublicKey(bp,x) \
+ PEM_ASN1_write_bio((i2d_of_void *)i2d_DSAPublicKey,\
+ PEM_STRING_DSA_PUBLIC,\
+ (bp),(char *)(x), NULL, NULL, 0, NULL, NULL)
+#endif
+
+#if !defined(DSAPrivateKey_dup)
+# define DSAPrivateKey_dup(dsa) (DSA *)ASN1_dup((i2d_of_void *)i2d_DSAPrivateKey, \
+ (d2i_of_void *)d2i_DSAPrivateKey,(char *)(dsa))
+#endif
+
+#if !defined(DSAPublicKey_dup)
+# define DSAPublicKey_dup(dsa) (DSA *)ASN1_dup((i2d_of_void *)i2d_DSAPublicKey, \
+ (d2i_of_void *)d2i_DSAPublicKey,(char *)(dsa))
+#endif
+
+#if !defined(X509_REVOKED_dup)
+# define X509_REVOKED_dup(rev) (X509_REVOKED *)ASN1_dup((i2d_of_void *)i2d_X509_REVOKED, \
+ (d2i_of_void *)d2i_X509_REVOKED, (char *)(rev))
+#endif
+
+#if !defined(PKCS7_SIGNER_INFO_dup)
+# define PKCS7_SIGNER_INFO_dup(si) (PKCS7_SIGNER_INFO *)ASN1_dup((i2d_of_void *)i2d_PKCS7_SIGNER_INFO, \
+ (d2i_of_void *)d2i_PKCS7_SIGNER_INFO, (char *)(si))
+#endif
+
+#if !defined(PKCS7_RECIP_INFO_dup)
+# define PKCS7_RECIP_INFO_dup(ri) (PKCS7_RECIP_INFO *)ASN1_dup((i2d_of_void *)i2d_PKCS7_RECIP_INFO, \
+ (d2i_of_void *)d2i_PKCS7_RECIP_INFO, (char *)(ri))
+#endif
+
+#if !defined(HAVE_HMAC_CTX_INIT)
+void HMAC_CTX_init(HMAC_CTX *ctx);
+#endif
+
+#if !defined(HAVE_HMAC_CTX_COPY)
+void HMAC_CTX_copy(HMAC_CTX *out, HMAC_CTX *in);
+#endif
+
+#if !defined(HAVE_HMAC_CTX_CLEANUP)
+void HMAC_CTX_cleanup(HMAC_CTX *ctx);
+#endif
+
+#if !defined(HAVE_EVP_MD_CTX_CREATE)
+EVP_MD_CTX *EVP_MD_CTX_create(void);
+#endif
+
+#if !defined(HAVE_EVP_MD_CTX_INIT)
+void EVP_MD_CTX_init(EVP_MD_CTX *ctx);
+#endif
+
+#if !defined(HAVE_EVP_MD_CTX_CLEANUP)
+int EVP_MD_CTX_cleanup(EVP_MD_CTX *ctx);
+#endif
+
+#if !defined(HAVE_EVP_MD_CTX_DESTROY)
+void EVP_MD_CTX_destroy(EVP_MD_CTX *ctx);
+#endif
+
+#if !defined(HAVE_EVP_CIPHER_CTX_COPY)
+int EVP_CIPHER_CTX_copy(EVP_CIPHER_CTX *out, EVP_CIPHER_CTX *in);
+#endif
+
+#if !defined(HAVE_EVP_DIGESTINIT_EX)
+# define EVP_DigestInit_ex(ctx, md, engine) EVP_DigestInit((ctx), (md))
+#endif
+#if !defined(HAVE_EVP_DIGESTFINAL_EX)
+# define EVP_DigestFinal_ex(ctx, buf, len) EVP_DigestFinal((ctx), (buf), (len))
+#endif
+
+#if !defined(HAVE_EVP_CIPHERINIT_EX)
+# define EVP_CipherInit_ex(ctx, type, impl, key, iv, enc) EVP_CipherInit((ctx), (type), (key), (iv), (enc))
+#endif
+#if !defined(HAVE_EVP_CIPHERFINAL_EX)
+# define EVP_CipherFinal_ex(ctx, outm, outl) EVP_CipherFinal((ctx), (outm), (outl))
+#endif
+
+#if !defined(EVP_CIPHER_name)
+# define EVP_CIPHER_name(e) OBJ_nid2sn(EVP_CIPHER_nid(e))
+#endif
+
+#if !defined(EVP_MD_name)
+# define EVP_MD_name(e) OBJ_nid2sn(EVP_MD_type(e))
+#endif
+
+#if !defined(HAVE_EVP_HMAC_INIT_EX)
+# define HMAC_Init_ex(ctx, key, len, digest, engine) HMAC_Init((ctx), (key), (len), (digest))
+#endif
+
+#if !defined(PKCS7_is_detached)
+# define PKCS7_is_detached(p7) (PKCS7_type_is_signed(p7) && PKCS7_get_detached(p7))
+#endif
+
+#if !defined(PKCS7_type_is_encrypted)
+# define PKCS7_type_is_encrypted(a) (OBJ_obj2nid((a)->type) == NID_pkcs7_encrypted)
+#endif
+
+#if !defined(HAVE_OPENSSL_CLEANSE)
+#define OPENSSL_cleanse(p, l) memset((p), 0, (l))
+#endif
+
+#if !defined(HAVE_X509_STORE_GET_EX_DATA)
+void *X509_STORE_get_ex_data(X509_STORE *str, int idx);
+#endif
+
+#if !defined(HAVE_X509_STORE_SET_EX_DATA)
+int X509_STORE_set_ex_data(X509_STORE *str, int idx, void *data);
+#endif
+
+#if !defined(HAVE_X509_CRL_SET_VERSION)
+int X509_CRL_set_version(X509_CRL *x, long version);
+#endif
+
+#if !defined(HAVE_X509_CRL_SET_ISSUER_NAME)
+int X509_CRL_set_issuer_name(X509_CRL *x, X509_NAME *name);
+#endif
+
+#if !defined(HAVE_X509_CRL_SORT)
+int X509_CRL_sort(X509_CRL *c);
+#endif
+
+#if !defined(HAVE_X509_CRL_ADD0_REVOKED)
+int X509_CRL_add0_revoked(X509_CRL *crl, X509_REVOKED *rev);
+#endif
+
+#if !defined(HAVE_BN_MOD_SQR)
+int BN_mod_sqr(BIGNUM *r, const BIGNUM *a, const BIGNUM *m, BN_CTX *ctx);
+#endif
+
+#if !defined(HAVE_BN_MOD_ADD)
+int BN_mod_add(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, const BIGNUM *m, BN_CTX *ctx);
+#endif
+
+#if !defined(HAVE_BN_MOD_SUB)
+int BN_mod_sub(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, const BIGNUM *m, BN_CTX *ctx);
+#endif
+
+#if !defined(HAVE_BN_RAND_RANGE)
+int BN_rand_range(BIGNUM *r, BIGNUM *range);
+#endif
+
+#if !defined(HAVE_BN_PSEUDO_RAND_RANGE)
+int BN_pseudo_rand_range(BIGNUM *r, BIGNUM *range);
+#endif
+
+#if !defined(HAVE_CONF_GET1_DEFAULT_CONFIG_FILE)
+char *CONF_get1_default_config_file(void);
+#endif
+
+#if !defined(HAVE_PEM_DEF_CALLBACK)
+int PEM_def_callback(char *buf, int num, int w, void *key);
+#endif
+
+#if !defined(HAVE_ASN1_PUT_EOC)
+int ASN1_put_eoc(unsigned char **pp);
+#endif
+
+#if defined(__cplusplus)
+}
+#endif
+
+
+#endif /* _OSSL_OPENSSL_MISSING_H_ */
+
diff --git a/jni/ruby/ext/openssl/ossl.c b/jni/ruby/ext/openssl/ossl.c
new file mode 100644
index 0000000..0d1ea8b
--- /dev/null
+++ b/jni/ruby/ext/openssl/ossl.c
@@ -0,0 +1,1168 @@
+/*
+ * $Id: ossl.c 47744 2014-09-30 05:25:32Z nobu $
+ * 'OpenSSL for Ruby' project
+ * Copyright (C) 2001-2002 Michal Rokos <m.rokos@sh.cvut.cz>
+ * All rights reserved.
+ */
+/*
+ * This program is licenced under the same licence as Ruby.
+ * (See the file 'LICENCE'.)
+ */
+#include "ossl.h"
+#include <stdarg.h> /* for ossl_raise */
+
+/*
+ * String to HEXString conversion
+ */
+int
+string2hex(const unsigned char *buf, int buf_len, char **hexbuf, int *hexbuf_len)
+{
+ static const char hex[]="0123456789abcdef";
+ int i, len;
+
+ if (buf_len < 0 || buf_len > INT_MAX / 2) { /* PARANOIA? */
+ return -1;
+ }
+ len = 2 * buf_len;
+ if (!hexbuf) { /* if no buf, return calculated len */
+ if (hexbuf_len) {
+ *hexbuf_len = len;
+ }
+ return len;
+ }
+ if (!(*hexbuf = OPENSSL_malloc(len + 1))) {
+ return -1;
+ }
+ for (i = 0; i < buf_len; i++) {
+ (*hexbuf)[2 * i] = hex[((unsigned char)buf[i]) >> 4];
+ (*hexbuf)[2 * i + 1] = hex[buf[i] & 0x0f];
+ }
+ (*hexbuf)[2 * i] = '\0';
+
+ if (hexbuf_len) {
+ *hexbuf_len = len;
+ }
+ return len;
+}
+
+/*
+ * Data Conversion
+ */
+#define OSSL_IMPL_ARY2SK(name, type, expected_class, dup) \
+STACK_OF(type) * \
+ossl_##name##_ary2sk0(VALUE ary) \
+{ \
+ STACK_OF(type) *sk; \
+ VALUE val; \
+ type *x; \
+ int i; \
+ \
+ Check_Type(ary, T_ARRAY); \
+ sk = sk_##type##_new_null(); \
+ if (!sk) ossl_raise(eOSSLError, NULL); \
+ \
+ for (i = 0; i < RARRAY_LEN(ary); i++) { \
+ val = rb_ary_entry(ary, i); \
+ if (!rb_obj_is_kind_of(val, expected_class)) { \
+ sk_##type##_pop_free(sk, type##_free); \
+ ossl_raise(eOSSLError, "object in array not" \
+ " of class ##type##"); \
+ } \
+ x = dup(val); /* NEED TO DUP */ \
+ sk_##type##_push(sk, x); \
+ } \
+ return sk; \
+} \
+ \
+STACK_OF(type) * \
+ossl_protect_##name##_ary2sk(VALUE ary, int *status) \
+{ \
+ return (STACK_OF(type)*)rb_protect( \
+ (VALUE(*)_((VALUE)))ossl_##name##_ary2sk0, \
+ ary, \
+ status); \
+} \
+ \
+STACK_OF(type) * \
+ossl_##name##_ary2sk(VALUE ary) \
+{ \
+ STACK_OF(type) *sk; \
+ int status = 0; \
+ \
+ sk = ossl_protect_##name##_ary2sk(ary, &status); \
+ if (status) rb_jump_tag(status); \
+ \
+ return sk; \
+}
+OSSL_IMPL_ARY2SK(x509, X509, cX509Cert, DupX509CertPtr)
+
+#define OSSL_IMPL_SK2ARY(name, type) \
+VALUE \
+ossl_##name##_sk2ary(STACK_OF(type) *sk) \
+{ \
+ type *t; \
+ int i, num; \
+ VALUE ary; \
+ \
+ if (!sk) { \
+ OSSL_Debug("empty sk!"); \
+ return Qnil; \
+ } \
+ num = sk_##type##_num(sk); \
+ if (num < 0) { \
+ OSSL_Debug("items in sk < -1???"); \
+ return rb_ary_new(); \
+ } \
+ ary = rb_ary_new2(num); \
+ \
+ for (i=0; i<num; i++) { \
+ t = sk_##type##_value(sk, i); \
+ rb_ary_push(ary, ossl_##name##_new(t)); \
+ } \
+ return ary; \
+}
+OSSL_IMPL_SK2ARY(x509, X509)
+OSSL_IMPL_SK2ARY(x509crl, X509_CRL)
+OSSL_IMPL_SK2ARY(x509name, X509_NAME)
+
+static VALUE
+ossl_str_new(int size)
+{
+ return rb_str_new(0, size);
+}
+
+VALUE
+ossl_buf2str(char *buf, int len)
+{
+ VALUE str;
+ int status = 0;
+
+ str = rb_protect((VALUE(*)_((VALUE)))ossl_str_new, len, &status);
+ if(!NIL_P(str)) memcpy(RSTRING_PTR(str), buf, len);
+ OPENSSL_free(buf);
+ if(status) rb_jump_tag(status);
+
+ return str;
+}
+
+/*
+ * our default PEM callback
+ */
+static VALUE
+ossl_pem_passwd_cb0(VALUE flag)
+{
+ VALUE pass;
+
+ pass = rb_yield(flag);
+ SafeStringValue(pass);
+
+ return pass;
+}
+
+int
+ossl_pem_passwd_cb(char *buf, int max_len, int flag, void *pwd)
+{
+ int len, status = 0;
+ VALUE rflag, pass;
+
+ if (pwd || !rb_block_given_p())
+ return PEM_def_callback(buf, max_len, flag, pwd);
+
+ while (1) {
+ /*
+ * when the flag is nonzero, this passphrase
+ * will be used to perform encryption; otherwise it will
+ * be used to perform decryption.
+ */
+ rflag = flag ? Qtrue : Qfalse;
+ pass = rb_protect(ossl_pem_passwd_cb0, rflag, &status);
+ if (status) {
+ /* ignore an exception raised. */
+ rb_set_errinfo(Qnil);
+ return -1;
+ }
+ len = RSTRING_LENINT(pass);
+ if (len < 4) { /* 4 is OpenSSL hardcoded limit */
+ rb_warning("password must be longer than 4 bytes");
+ continue;
+ }
+ if (len > max_len) {
+ rb_warning("password must be shorter then %d bytes", max_len-1);
+ continue;
+ }
+ memcpy(buf, RSTRING_PTR(pass), len);
+ break;
+ }
+ return len;
+}
+
+/*
+ * Verify callback
+ */
+int ossl_verify_cb_idx;
+
+VALUE
+ossl_call_verify_cb_proc(struct ossl_verify_cb_args *args)
+{
+ return rb_funcall(args->proc, rb_intern("call"), 2,
+ args->preverify_ok, args->store_ctx);
+}
+
+int
+ossl_verify_cb(int ok, X509_STORE_CTX *ctx)
+{
+ VALUE proc, rctx, ret;
+ struct ossl_verify_cb_args args;
+ int state = 0;
+
+ proc = (VALUE)X509_STORE_CTX_get_ex_data(ctx, ossl_verify_cb_idx);
+ if ((void*)proc == 0)
+ proc = (VALUE)X509_STORE_get_ex_data(ctx->ctx, ossl_verify_cb_idx);
+ if ((void*)proc == 0)
+ return ok;
+ if (!NIL_P(proc)) {
+ ret = Qfalse;
+ rctx = rb_protect((VALUE(*)(VALUE))ossl_x509stctx_new,
+ (VALUE)ctx, &state);
+ if (state) {
+ rb_set_errinfo(Qnil);
+ rb_warn("StoreContext initialization failure");
+ }
+ else {
+ args.proc = proc;
+ args.preverify_ok = ok ? Qtrue : Qfalse;
+ args.store_ctx = rctx;
+ ret = rb_protect((VALUE(*)(VALUE))ossl_call_verify_cb_proc, (VALUE)&args, &state);
+ if (state) {
+ rb_set_errinfo(Qnil);
+ rb_warn("exception in verify_callback is ignored");
+ }
+ ossl_x509stctx_clear_ptr(rctx);
+ }
+ if (ret == Qtrue) {
+ X509_STORE_CTX_set_error(ctx, X509_V_OK);
+ ok = 1;
+ }
+ else{
+ if (X509_STORE_CTX_get_error(ctx) == X509_V_OK) {
+ X509_STORE_CTX_set_error(ctx, X509_V_ERR_CERT_REJECTED);
+ }
+ ok = 0;
+ }
+ }
+
+ return ok;
+}
+
+/*
+ * main module
+ */
+VALUE mOSSL;
+
+/*
+ * OpenSSLError < StandardError
+ */
+VALUE eOSSLError;
+
+/*
+ * Convert to DER string
+ */
+ID ossl_s_to_der;
+
+VALUE
+ossl_to_der(VALUE obj)
+{
+ VALUE tmp;
+
+ tmp = rb_funcall(obj, ossl_s_to_der, 0);
+ StringValue(tmp);
+
+ return tmp;
+}
+
+VALUE
+ossl_to_der_if_possible(VALUE obj)
+{
+ if(rb_respond_to(obj, ossl_s_to_der))
+ return ossl_to_der(obj);
+ return obj;
+}
+
+/*
+ * Errors
+ */
+static VALUE
+ossl_make_error(VALUE exc, const char *fmt, va_list args)
+{
+ VALUE str = Qnil;
+ const char *msg;
+ long e;
+
+#ifdef HAVE_ERR_PEEK_LAST_ERROR
+ e = ERR_peek_last_error();
+#else
+ e = ERR_peek_error();
+#endif
+ if (fmt) {
+ str = rb_vsprintf(fmt, args);
+ }
+ if (e) {
+ if (dOSSL == Qtrue) /* FULL INFO */
+ msg = ERR_error_string(e, NULL);
+ else
+ msg = ERR_reason_error_string(e);
+ if (NIL_P(str)) {
+ if (msg) str = rb_str_new_cstr(msg);
+ }
+ else {
+ if (RSTRING_LEN(str)) rb_str_cat2(str, ": ");
+ rb_str_cat2(str, msg ? msg : "(null)");
+ }
+ }
+ if (dOSSL == Qtrue){ /* show all errors on the stack */
+ while ((e = ERR_get_error()) != 0){
+ rb_warn("error on stack: %s", ERR_error_string(e, NULL));
+ }
+ }
+ ERR_clear_error();
+
+ if (NIL_P(str)) str = rb_str_new(0, 0);
+ return rb_exc_new3(exc, str);
+}
+
+void
+ossl_raise(VALUE exc, const char *fmt, ...)
+{
+ va_list args;
+ VALUE err;
+ va_start(args, fmt);
+ err = ossl_make_error(exc, fmt, args);
+ va_end(args);
+ rb_exc_raise(err);
+}
+
+VALUE
+ossl_exc_new(VALUE exc, const char *fmt, ...)
+{
+ va_list args;
+ VALUE err;
+ va_start(args, fmt);
+ err = ossl_make_error(exc, fmt, args);
+ va_end(args);
+ return err;
+}
+
+/*
+ * call-seq:
+ * OpenSSL.errors -> [String...]
+ *
+ * See any remaining errors held in queue.
+ *
+ * Any errors you see here are probably due to a bug in ruby's OpenSSL implementation.
+ */
+VALUE
+ossl_get_errors(void)
+{
+ VALUE ary;
+ long e;
+
+ ary = rb_ary_new();
+ while ((e = ERR_get_error()) != 0){
+ rb_ary_push(ary, rb_str_new2(ERR_error_string(e, NULL)));
+ }
+
+ return ary;
+}
+
+/*
+ * Debug
+ */
+VALUE dOSSL;
+
+#if !defined(HAVE_VA_ARGS_MACRO)
+void
+ossl_debug(const char *fmt, ...)
+{
+ va_list args;
+
+ if (dOSSL == Qtrue) {
+ fprintf(stderr, "OSSL_DEBUG: ");
+ va_start(args, fmt);
+ vfprintf(stderr, fmt, args);
+ va_end(args);
+ fprintf(stderr, " [CONTEXT N/A]\n");
+ }
+}
+#endif
+
+/*
+ * call-seq:
+ * OpenSSL.debug -> true | false
+ */
+static VALUE
+ossl_debug_get(VALUE self)
+{
+ return dOSSL;
+}
+
+/*
+ * call-seq:
+ * OpenSSL.debug = boolean -> boolean
+ *
+ * Turns on or off CRYPTO_MEM_CHECK.
+ * Also shows some debugging message on stderr.
+ */
+static VALUE
+ossl_debug_set(VALUE self, VALUE val)
+{
+ VALUE old = dOSSL;
+ dOSSL = val;
+
+ if (old != dOSSL) {
+ if (dOSSL == Qtrue) {
+ CRYPTO_mem_ctrl(CRYPTO_MEM_CHECK_ON);
+ fprintf(stderr, "OSSL_DEBUG: IS NOW ON!\n");
+ } else if (old == Qtrue) {
+ CRYPTO_mem_ctrl(CRYPTO_MEM_CHECK_OFF);
+ fprintf(stderr, "OSSL_DEBUG: IS NOW OFF!\n");
+ }
+ }
+ return val;
+}
+
+/*
+ * call-seq:
+ * OpenSSL.fips_mode = boolean -> boolean
+ *
+ * Turns FIPS mode on or off. Turning on FIPS mode will obviously only have an
+ * effect for FIPS-capable installations of the OpenSSL library. Trying to do
+ * so otherwise will result in an error.
+ *
+ * === Examples
+ *
+ * OpenSSL.fips_mode = true # turn FIPS mode on
+ * OpenSSL.fips_mode = false # and off again
+ */
+static VALUE
+ossl_fips_mode_set(VALUE self, VALUE enabled)
+{
+
+#ifdef HAVE_OPENSSL_FIPS
+ if (RTEST(enabled)) {
+ int mode = FIPS_mode();
+ if(!mode && !FIPS_mode_set(1)) /* turning on twice leads to an error */
+ ossl_raise(eOSSLError, "Turning on FIPS mode failed");
+ } else {
+ if(!FIPS_mode_set(0)) /* turning off twice is OK */
+ ossl_raise(eOSSLError, "Turning off FIPS mode failed");
+ }
+ return enabled;
+#else
+ if (RTEST(enabled))
+ ossl_raise(eOSSLError, "This version of OpenSSL does not support FIPS mode");
+ return enabled;
+#endif
+}
+
+/**
+ * Stores locks needed for OpenSSL thread safety
+ */
+#include "ruby/thread_native.h"
+static rb_nativethread_lock_t *ossl_locks;
+
+static void
+ossl_lock_unlock(int mode, rb_nativethread_lock_t *lock)
+{
+ if (mode & CRYPTO_LOCK) {
+ rb_nativethread_lock_lock(lock);
+ } else {
+ rb_nativethread_lock_unlock(lock);
+ }
+}
+
+static void
+ossl_lock_callback(int mode, int type, const char *file, int line)
+{
+ ossl_lock_unlock(mode, &ossl_locks[type]);
+}
+
+struct CRYPTO_dynlock_value {
+ rb_nativethread_lock_t lock;
+};
+
+static struct CRYPTO_dynlock_value *
+ossl_dyn_create_callback(const char *file, int line)
+{
+ struct CRYPTO_dynlock_value *dynlock = (struct CRYPTO_dynlock_value *)OPENSSL_malloc((int)sizeof(struct CRYPTO_dynlock_value));
+ rb_nativethread_lock_initialize(&dynlock->lock);
+ return dynlock;
+}
+
+static void
+ossl_dyn_lock_callback(int mode, struct CRYPTO_dynlock_value *l, const char *file, int line)
+{
+ ossl_lock_unlock(mode, &l->lock);
+}
+
+static void
+ossl_dyn_destroy_callback(struct CRYPTO_dynlock_value *l, const char *file, int line)
+{
+ rb_nativethread_lock_destroy(&l->lock);
+ OPENSSL_free(l);
+}
+
+#ifdef HAVE_CRYPTO_THREADID_PTR
+static void ossl_threadid_func(CRYPTO_THREADID *id)
+{
+ /* register native thread id */
+ CRYPTO_THREADID_set_pointer(id, (void *)rb_nativethread_self());
+}
+#else
+static unsigned long ossl_thread_id(void)
+{
+ /* before OpenSSL 1.0, this is 'unsigned long' */
+ return (unsigned long)rb_nativethread_self();
+}
+#endif
+
+static void Init_ossl_locks(void)
+{
+ int i;
+ int num_locks = CRYPTO_num_locks();
+
+ if ((unsigned)num_locks >= INT_MAX / (int)sizeof(VALUE)) {
+ rb_raise(rb_eRuntimeError, "CRYPTO_num_locks() is too big: %d", num_locks);
+ }
+ ossl_locks = (rb_nativethread_lock_t *) OPENSSL_malloc(num_locks * (int)sizeof(rb_nativethread_lock_t));
+ if (!ossl_locks) {
+ rb_raise(rb_eNoMemError, "CRYPTO_num_locks() is too big: %d", num_locks);
+ }
+ for (i = 0; i < num_locks; i++) {
+ rb_nativethread_lock_initialize(&ossl_locks[i]);
+ }
+
+#ifdef HAVE_CRYPTO_THREADID_PTR
+ CRYPTO_THREADID_set_callback(ossl_threadid_func);
+#else
+ CRYPTO_set_id_callback(ossl_thread_id);
+#endif
+ CRYPTO_set_locking_callback(ossl_lock_callback);
+ CRYPTO_set_dynlock_create_callback(ossl_dyn_create_callback);
+ CRYPTO_set_dynlock_lock_callback(ossl_dyn_lock_callback);
+ CRYPTO_set_dynlock_destroy_callback(ossl_dyn_destroy_callback);
+}
+
+/*
+ * OpenSSL provides SSL, TLS and general purpose cryptography. It wraps the
+ * OpenSSL[http://www.openssl.org/] library.
+ *
+ * = Examples
+ *
+ * All examples assume you have loaded OpenSSL with:
+ *
+ * require 'openssl'
+ *
+ * These examples build atop each other. For example the key created in the
+ * next is used in throughout these examples.
+ *
+ * == Keys
+ *
+ * === Creating a Key
+ *
+ * This example creates a 2048 bit RSA keypair and writes it to the current
+ * directory.
+ *
+ * key = OpenSSL::PKey::RSA.new 2048
+ *
+ * open 'private_key.pem', 'w' do |io| io.write key.to_pem end
+ * open 'public_key.pem', 'w' do |io| io.write key.public_key.to_pem end
+ *
+ * === Exporting a Key
+ *
+ * Keys saved to disk without encryption are not secure as anyone who gets
+ * ahold of the key may use it unless it is encrypted. In order to securely
+ * export a key you may export it with a pass phrase.
+ *
+ * cipher = OpenSSL::Cipher.new 'AES-128-CBC'
+ * pass_phrase = 'my secure pass phrase goes here'
+ *
+ * key_secure = key.export cipher, pass_phrase
+ *
+ * open 'private.secure.pem', 'w' do |io|
+ * io.write key_secure
+ * end
+ *
+ * OpenSSL::Cipher.ciphers returns a list of available ciphers.
+ *
+ * === Loading a Key
+ *
+ * A key can also be loaded from a file.
+ *
+ * key2 = OpenSSL::PKey::RSA.new File.read 'private_key.pem'
+ * key2.public? # => true
+ *
+ * or
+ *
+ * key3 = OpenSSL::PKey::RSA.new File.read 'public_key.pem'
+ * key3.private? # => false
+ *
+ * === Loading an Encrypted Key
+ *
+ * OpenSSL will prompt you for your pass phrase when loading an encrypted key.
+ * If you will not be able to type in the pass phrase you may provide it when
+ * loading the key:
+ *
+ * key4_pem = File.read 'private.secure.pem'
+ * key4 = OpenSSL::PKey::RSA.new key4_pem, pass_phrase
+ *
+ * == RSA Encryption
+ *
+ * RSA provides encryption and decryption using the public and private keys.
+ * You can use a variety of padding methods depending upon the intended use of
+ * encrypted data.
+ *
+ * === Encryption & Decryption
+ *
+ * Asymmetric public/private key encryption is slow and victim to attack in
+ * cases where it is used without padding or directly to encrypt larger chunks
+ * of data. Typical use cases for RSA encryption involve "wrapping" a symmetric
+ * key with the public key of the recipient who would "unwrap" that symmetric
+ * key again using their private key.
+ * The following illustrates a simplified example of such a key transport
+ * scheme. It shouldn't be used in practice, though, standardized protocols
+ * should always be preferred.
+ *
+ * wrapped_key = key.public_encrypt key
+ *
+ * A symmetric key encrypted with the public key can only be decrypted with
+ * the corresponding private key of the recipient.
+ *
+ * original_key = key.private_decrypt wrapped_key
+ *
+ * By default PKCS#1 padding will be used, but it is also possible to use
+ * other forms of padding, see PKey::RSA for further details.
+ *
+ * === Signatures
+ *
+ * Using "private_encrypt" to encrypt some data with the private key is
+ * equivalent to applying a digital signature to the data. A verifying
+ * party may validate the signature by comparing the result of decrypting
+ * the signature with "public_decrypt" to the original data. However,
+ * OpenSSL::PKey already has methods "sign" and "verify" that handle
+ * digital signatures in a standardized way - "private_encrypt" and
+ * "public_decrypt" shouldn't be used in practice.
+ *
+ * To sign a document, a cryptographically secure hash of the document is
+ * computed first, which is then signed using the private key.
+ *
+ * digest = OpenSSL::Digest::SHA256.new
+ * signature = key.sign digest, document
+ *
+ * To validate the signature, again a hash of the document is computed and
+ * the signature is decrypted using the public key. The result is then
+ * compared to the hash just computed, if they are equal the signature was
+ * valid.
+ *
+ * digest = OpenSSL::Digest::SHA256.new
+ * if key.verify digest, signature, document
+ * puts 'Valid'
+ * else
+ * puts 'Invalid'
+ * end
+ *
+ * == PBKDF2 Password-based Encryption
+ *
+ * If supported by the underlying OpenSSL version used, Password-based
+ * Encryption should use the features of PKCS5. If not supported or if
+ * required by legacy applications, the older, less secure methods specified
+ * in RFC 2898 are also supported (see below).
+ *
+ * PKCS5 supports PBKDF2 as it was specified in PKCS#5
+ * v2.0[http://www.rsa.com/rsalabs/node.asp?id=2127]. It still uses a
+ * password, a salt, and additionally a number of iterations that will
+ * slow the key derivation process down. The slower this is, the more work
+ * it requires being able to brute-force the resulting key.
+ *
+ * === Encryption
+ *
+ * The strategy is to first instantiate a Cipher for encryption, and
+ * then to generate a random IV plus a key derived from the password
+ * using PBKDF2. PKCS #5 v2.0 recommends at least 8 bytes for the salt,
+ * the number of iterations largely depends on the hardware being used.
+ *
+ * cipher = OpenSSL::Cipher.new 'AES-128-CBC'
+ * cipher.encrypt
+ * iv = cipher.random_iv
+ *
+ * pwd = 'some hopefully not to easily guessable password'
+ * salt = OpenSSL::Random.random_bytes 16
+ * iter = 20000
+ * key_len = cipher.key_len
+ * digest = OpenSSL::Digest::SHA256.new
+ *
+ * key = OpenSSL::PKCS5.pbkdf2_hmac(pwd, salt, iter, key_len, digest)
+ * cipher.key = key
+ *
+ * Now encrypt the data:
+ *
+ * encrypted = cipher.update document
+ * encrypted << cipher.final
+ *
+ * === Decryption
+ *
+ * Use the same steps as before to derive the symmetric AES key, this time
+ * setting the Cipher up for decryption.
+ *
+ * cipher = OpenSSL::Cipher.new 'AES-128-CBC'
+ * cipher.decrypt
+ * cipher.iv = iv # the one generated with #random_iv
+ *
+ * pwd = 'some hopefully not to easily guessable password'
+ * salt = ... # the one generated above
+ * iter = 20000
+ * key_len = cipher.key_len
+ * digest = OpenSSL::Digest::SHA256.new
+ *
+ * key = OpenSSL::PKCS5.pbkdf2_hmac(pwd, salt, iter, key_len, digest)
+ * cipher.key = key
+ *
+ * Now decrypt the data:
+ *
+ * decrypted = cipher.update encrypted
+ * decrypted << cipher.final
+ *
+ * == PKCS #5 Password-based Encryption
+ *
+ * PKCS #5 is a password-based encryption standard documented at
+ * RFC2898[http://www.ietf.org/rfc/rfc2898.txt]. It allows a short password or
+ * passphrase to be used to create a secure encryption key. If possible, PBKDF2
+ * as described above should be used if the circumstances allow it.
+ *
+ * PKCS #5 uses a Cipher, a pass phrase and a salt to generate an encryption
+ * key.
+ *
+ * pass_phrase = 'my secure pass phrase goes here'
+ * salt = '8 octets'
+ *
+ * === Encryption
+ *
+ * First set up the cipher for encryption
+ *
+ * encryptor = OpenSSL::Cipher.new 'AES-128-CBC'
+ * encryptor.encrypt
+ * encryptor.pkcs5_keyivgen pass_phrase, salt
+ *
+ * Then pass the data you want to encrypt through
+ *
+ * encrypted = encryptor.update 'top secret document'
+ * encrypted << encryptor.final
+ *
+ * === Decryption
+ *
+ * Use a new Cipher instance set up for decryption
+ *
+ * decryptor = OpenSSL::Cipher.new 'AES-128-CBC'
+ * decryptor.decrypt
+ * decryptor.pkcs5_keyivgen pass_phrase, salt
+ *
+ * Then pass the data you want to decrypt through
+ *
+ * plain = decryptor.update encrypted
+ * plain << decryptor.final
+ *
+ * == X509 Certificates
+ *
+ * === Creating a Certificate
+ *
+ * This example creates a self-signed certificate using an RSA key and a SHA1
+ * signature.
+ *
+ * name = OpenSSL::X509::Name.parse 'CN=nobody/DC=example'
+ *
+ * cert = OpenSSL::X509::Certificate.new
+ * cert.version = 2
+ * cert.serial = 0
+ * cert.not_before = Time.now
+ * cert.not_after = Time.now + 3600
+ *
+ * cert.public_key = key.public_key
+ * cert.subject = name
+ *
+ * === Certificate Extensions
+ *
+ * You can add extensions to the certificate with
+ * OpenSSL::SSL::ExtensionFactory to indicate the purpose of the certificate.
+ *
+ * extension_factory = OpenSSL::X509::ExtensionFactory.new nil, cert
+ *
+ * cert.add_extension \
+ * extension_factory.create_extension('basicConstraints', 'CA:FALSE', true)
+ *
+ * cert.add_extension \
+ * extension_factory.create_extension(
+ * 'keyUsage', 'keyEncipherment,dataEncipherment,digitalSignature')
+ *
+ * cert.add_extension \
+ * extension_factory.create_extension('subjectKeyIdentifier', 'hash')
+ *
+ * The list of supported extensions (and in some cases their possible values)
+ * can be derived from the "objects.h" file in the OpenSSL source code.
+ *
+ * === Signing a Certificate
+ *
+ * To sign a certificate set the issuer and use OpenSSL::X509::Certificate#sign
+ * with a digest algorithm. This creates a self-signed cert because we're using
+ * the same name and key to sign the certificate as was used to create the
+ * certificate.
+ *
+ * cert.issuer = name
+ * cert.sign key, OpenSSL::Digest::SHA1.new
+ *
+ * open 'certificate.pem', 'w' do |io| io.write cert.to_pem end
+ *
+ * === Loading a Certificate
+ *
+ * Like a key, a cert can also be loaded from a file.
+ *
+ * cert2 = OpenSSL::X509::Certificate.new File.read 'certificate.pem'
+ *
+ * === Verifying a Certificate
+ *
+ * Certificate#verify will return true when a certificate was signed with the
+ * given public key.
+ *
+ * raise 'certificate can not be verified' unless cert2.verify key
+ *
+ * == Certificate Authority
+ *
+ * A certificate authority (CA) is a trusted third party that allows you to
+ * verify the ownership of unknown certificates. The CA issues key signatures
+ * that indicate it trusts the user of that key. A user encountering the key
+ * can verify the signature by using the CA's public key.
+ *
+ * === CA Key
+ *
+ * CA keys are valuable, so we encrypt and save it to disk and make sure it is
+ * not readable by other users.
+ *
+ * ca_key = OpenSSL::PKey::RSA.new 2048
+ *
+ * cipher = OpenSSL::Cipher::Cipher.new 'AES-128-CBC'
+ *
+ * open 'ca_key.pem', 'w', 0400 do |io|
+ * io.write ca_key.export(cipher, pass_phrase)
+ * end
+ *
+ * === CA Certificate
+ *
+ * A CA certificate is created the same way we created a certificate above, but
+ * with different extensions.
+ *
+ * ca_name = OpenSSL::X509::Name.parse 'CN=ca/DC=example'
+ *
+ * ca_cert = OpenSSL::X509::Certificate.new
+ * ca_cert.serial = 0
+ * ca_cert.version = 2
+ * ca_cert.not_before = Time.now
+ * ca_cert.not_after = Time.now + 86400
+ *
+ * ca_cert.public_key = ca_key.public_key
+ * ca_cert.subject = ca_name
+ * ca_cert.issuer = ca_name
+ *
+ * extension_factory = OpenSSL::X509::ExtensionFactory.new
+ * extension_factory.subject_certificate = ca_cert
+ * extension_factory.issuer_certificate = ca_cert
+ *
+ * ca_cert.add_extension \
+ * extension_factory.create_extension('subjectKeyIdentifier', 'hash')
+ *
+ * This extension indicates the CA's key may be used as a CA.
+ *
+ * ca_cert.add_extension \
+ * extension_factory.create_extension('basicConstraints', 'CA:TRUE', true)
+ *
+ * This extension indicates the CA's key may be used to verify signatures on
+ * both certificates and certificate revocations.
+ *
+ * ca_cert.add_extension \
+ * extension_factory.create_extension(
+ * 'keyUsage', 'cRLSign,keyCertSign', true)
+ *
+ * Root CA certificates are self-signed.
+ *
+ * ca_cert.sign ca_key, OpenSSL::Digest::SHA1.new
+ *
+ * The CA certificate is saved to disk so it may be distributed to all the
+ * users of the keys this CA will sign.
+ *
+ * open 'ca_cert.pem', 'w' do |io|
+ * io.write ca_cert.to_pem
+ * end
+ *
+ * === Certificate Signing Request
+ *
+ * The CA signs keys through a Certificate Signing Request (CSR). The CSR
+ * contains the information necessary to identify the key.
+ *
+ * csr = OpenSSL::X509::Request.new
+ * csr.version = 0
+ * csr.subject = name
+ * csr.public_key = key.public_key
+ * csr.sign key, OpenSSL::Digest::SHA1.new
+ *
+ * A CSR is saved to disk and sent to the CA for signing.
+ *
+ * open 'csr.pem', 'w' do |io|
+ * io.write csr.to_pem
+ * end
+ *
+ * === Creating a Certificate from a CSR
+ *
+ * Upon receiving a CSR the CA will verify it before signing it. A minimal
+ * verification would be to check the CSR's signature.
+ *
+ * csr = OpenSSL::X509::Request.new File.read 'csr.pem'
+ *
+ * raise 'CSR can not be verified' unless csr.verify csr.public_key
+ *
+ * After verification a certificate is created, marked for various usages,
+ * signed with the CA key and returned to the requester.
+ *
+ * csr_cert = OpenSSL::X509::Certificate.new
+ * csr_cert.serial = 0
+ * csr_cert.version = 2
+ * csr_cert.not_before = Time.now
+ * csr_cert.not_after = Time.now + 600
+ *
+ * csr_cert.subject = csr.subject
+ * csr_cert.public_key = csr.public_key
+ * csr_cert.issuer = ca_cert.subject
+ *
+ * extension_factory = OpenSSL::X509::ExtensionFactory.new
+ * extension_factory.subject_certificate = csr_cert
+ * extension_factory.issuer_certificate = ca_cert
+ *
+ * csr_cert.add_extension \
+ * extension_factory.create_extension('basicConstraints', 'CA:FALSE')
+ *
+ * csr_cert.add_extension \
+ * extension_factory.create_extension(
+ * 'keyUsage', 'keyEncipherment,dataEncipherment,digitalSignature')
+ *
+ * csr_cert.add_extension \
+ * extension_factory.create_extension('subjectKeyIdentifier', 'hash')
+ *
+ * csr_cert.sign ca_key, OpenSSL::Digest::SHA1.new
+ *
+ * open 'csr_cert.pem', 'w' do |io|
+ * io.write csr_cert.to_pem
+ * end
+ *
+ * == SSL and TLS Connections
+ *
+ * Using our created key and certificate we can create an SSL or TLS connection.
+ * An SSLContext is used to set up an SSL session.
+ *
+ * context = OpenSSL::SSL::SSLContext.new
+ *
+ * === SSL Server
+ *
+ * An SSL server requires the certificate and private key to communicate
+ * securely with its clients:
+ *
+ * context.cert = cert
+ * context.key = key
+ *
+ * Then create an SSLServer with a TCP server socket and the context. Use the
+ * SSLServer like an ordinary TCP server.
+ *
+ * require 'socket'
+ *
+ * tcp_server = TCPServer.new 5000
+ * ssl_server = OpenSSL::SSL::SSLServer.new tcp_server, context
+ *
+ * loop do
+ * ssl_connection = ssl_server.accept
+ *
+ * data = connection.gets
+ *
+ * response = "I got #{data.dump}"
+ * puts response
+ *
+ * connection.puts "I got #{data.dump}"
+ * connection.close
+ * end
+ *
+ * === SSL client
+ *
+ * An SSL client is created with a TCP socket and the context.
+ * SSLSocket#connect must be called to initiate the SSL handshake and start
+ * encryption. A key and certificate are not required for the client socket.
+ *
+ * require 'socket'
+ *
+ * tcp_client = TCPSocket.new 'localhost', 5000
+ * ssl_client = OpenSSL::SSL::SSLSocket.new client_socket, context
+ * ssl_client.connect
+ *
+ * ssl_client.puts "hello server!"
+ * puts ssl_client.gets
+ *
+ * === Peer Verification
+ *
+ * An unverified SSL connection does not provide much security. For enhanced
+ * security the client or server can verify the certificate of its peer.
+ *
+ * The client can be modified to verify the server's certificate against the
+ * certificate authority's certificate:
+ *
+ * context.ca_file = 'ca_cert.pem'
+ * context.verify_mode = OpenSSL::SSL::VERIFY_PEER
+ *
+ * require 'socket'
+ *
+ * tcp_client = TCPSocket.new 'localhost', 5000
+ * ssl_client = OpenSSL::SSL::SSLSocket.new client_socket, context
+ * ssl_client.connect
+ *
+ * ssl_client.puts "hello server!"
+ * puts ssl_client.gets
+ *
+ * If the server certificate is invalid or <tt>context.ca_file</tt> is not set
+ * when verifying peers an OpenSSL::SSL::SSLError will be raised.
+ *
+ */
+void
+Init_openssl(void)
+{
+ /*
+ * Init timezone info
+ */
+#if 0
+ tzset();
+#endif
+
+ /*
+ * Init all digests, ciphers
+ */
+ /* CRYPTO_malloc_init(); */
+ /* ENGINE_load_builtin_engines(); */
+ OpenSSL_add_ssl_algorithms();
+ OpenSSL_add_all_algorithms();
+ ERR_load_crypto_strings();
+ SSL_load_error_strings();
+
+ /*
+ * FIXME:
+ * On unload do:
+ */
+#if 0
+ CONF_modules_unload(1);
+ destroy_ui_method();
+ EVP_cleanup();
+ ENGINE_cleanup();
+ CRYPTO_cleanup_all_ex_data();
+ ERR_remove_state(0);
+ ERR_free_strings();
+#endif
+
+ /*
+ * Init main module
+ */
+ mOSSL = rb_define_module("OpenSSL");
+ rb_global_variable(&mOSSL);
+
+ /*
+ * OpenSSL ruby extension version
+ */
+ rb_define_const(mOSSL, "VERSION", rb_str_new2(OSSL_VERSION));
+
+ /*
+ * Version of OpenSSL the ruby OpenSSL extension was built with
+ */
+ rb_define_const(mOSSL, "OPENSSL_VERSION", rb_str_new2(OPENSSL_VERSION_TEXT));
+
+ /*
+ * Version of OpenSSL the ruby OpenSSL extension is running with
+ */
+ rb_define_const(mOSSL, "OPENSSL_LIBRARY_VERSION", rb_str_new2(SSLeay_version(SSLEAY_VERSION)));
+
+ /*
+ * Version number of OpenSSL the ruby OpenSSL extension was built with
+ * (base 16)
+ */
+ rb_define_const(mOSSL, "OPENSSL_VERSION_NUMBER", INT2NUM(OPENSSL_VERSION_NUMBER));
+
+ /*
+ * Boolean indicating whether OpenSSL is FIPS-enabled or not
+ */
+#ifdef HAVE_OPENSSL_FIPS
+ rb_define_const(mOSSL, "OPENSSL_FIPS", Qtrue);
+#else
+ rb_define_const(mOSSL, "OPENSSL_FIPS", Qfalse);
+#endif
+ rb_define_module_function(mOSSL, "fips_mode=", ossl_fips_mode_set, 1);
+
+ /*
+ * Generic error,
+ * common for all classes under OpenSSL module
+ */
+ eOSSLError = rb_define_class_under(mOSSL,"OpenSSLError",rb_eStandardError);
+ rb_global_variable(&eOSSLError);
+
+ /*
+ * Verify callback Proc index for ext-data
+ */
+ if ((ossl_verify_cb_idx = X509_STORE_CTX_get_ex_new_index(0, (void *)"ossl_verify_cb_idx", 0, 0, 0)) < 0)
+ ossl_raise(eOSSLError, "X509_STORE_CTX_get_ex_new_index");
+
+ /*
+ * Init debug core
+ */
+ dOSSL = Qfalse;
+ rb_global_variable(&dOSSL);
+
+ rb_define_module_function(mOSSL, "debug", ossl_debug_get, 0);
+ rb_define_module_function(mOSSL, "debug=", ossl_debug_set, 1);
+ rb_define_module_function(mOSSL, "errors", ossl_get_errors, 0);
+
+ /*
+ * Get ID of to_der
+ */
+ ossl_s_to_der = rb_intern("to_der");
+
+ Init_ossl_locks();
+
+ /*
+ * Init components
+ */
+ Init_ossl_bn();
+ Init_ossl_cipher();
+ Init_ossl_config();
+ Init_ossl_digest();
+ Init_ossl_hmac();
+ Init_ossl_ns_spki();
+ Init_ossl_pkcs12();
+ Init_ossl_pkcs7();
+ Init_ossl_pkcs5();
+ Init_ossl_pkey();
+ Init_ossl_rand();
+ Init_ossl_ssl();
+ Init_ossl_x509();
+ Init_ossl_ocsp();
+ Init_ossl_engine();
+ Init_ossl_asn1();
+}
+
+#if defined(OSSL_DEBUG)
+/*
+ * Check if all symbols are OK with 'make LDSHARED=gcc all'
+ */
+int
+main(int argc, char *argv[])
+{
+ return 0;
+}
+#endif /* OSSL_DEBUG */
+
diff --git a/jni/ruby/ext/openssl/ossl.h b/jni/ruby/ext/openssl/ossl.h
new file mode 100644
index 0000000..5665423
--- /dev/null
+++ b/jni/ruby/ext/openssl/ossl.h
@@ -0,0 +1,247 @@
+/*
+ * $Id: ossl.h 44582 2014-01-13 00:57:42Z nobu $
+ * 'OpenSSL for Ruby' project
+ * Copyright (C) 2001-2002 Michal Rokos <m.rokos@sh.cvut.cz>
+ * All rights reserved.
+ */
+/*
+ * This program is licenced under the same licence as Ruby.
+ * (See the file 'LICENCE'.)
+ */
+#if !defined(_OSSL_H_)
+#define _OSSL_H_
+
+#include RUBY_EXTCONF_H
+
+#if defined(__cplusplus)
+extern "C" {
+#endif
+
+#if 0
+ mOSSL = rb_define_module("OpenSSL");
+ mX509 = rb_define_module_under(mOSSL, "X509");
+#endif
+
+/*
+* OpenSSL has defined RFILE and Ruby has defined RFILE - so undef it!
+*/
+#if defined(RFILE) /*&& !defined(OSSL_DEBUG)*/
+# undef RFILE
+#endif
+#include <ruby.h>
+#include <ruby/io.h>
+#include <ruby/thread.h>
+
+/*
+ * Check the OpenSSL version
+ * The only supported are:
+ * OpenSSL >= 0.9.7
+ */
+#include <openssl/opensslv.h>
+
+#ifdef HAVE_ASSERT_H
+# include <assert.h>
+#else
+# define assert(condition)
+#endif
+
+#if defined(_WIN32)
+# include <openssl/e_os2.h>
+# define OSSL_NO_CONF_API 1
+# if !defined(OPENSSL_SYS_WIN32)
+# define OPENSSL_SYS_WIN32 1
+# endif
+# include <winsock2.h>
+#endif
+#include <errno.h>
+#include <openssl/err.h>
+#include <openssl/asn1_mac.h>
+#include <openssl/x509v3.h>
+#include <openssl/ssl.h>
+#include <openssl/pkcs12.h>
+#include <openssl/pkcs7.h>
+#include <openssl/hmac.h>
+#include <openssl/rand.h>
+#include <openssl/conf.h>
+#include <openssl/conf_api.h>
+#undef X509_NAME
+#undef PKCS7_SIGNER_INFO
+#if defined(HAVE_OPENSSL_ENGINE_H) && defined(HAVE_EVP_CIPHER_CTX_ENGINE)
+# define OSSL_ENGINE_ENABLED
+# include <openssl/engine.h>
+#endif
+#if defined(HAVE_OPENSSL_OCSP_H)
+# define OSSL_OCSP_ENABLED
+# include <openssl/ocsp.h>
+#endif
+
+/* OpenSSL requires passwords for PEM-encoded files to be at least four
+ * characters long
+ */
+#define OSSL_MIN_PWD_LEN 4
+
+/*
+ * Common Module
+ */
+extern VALUE mOSSL;
+
+/*
+ * Common Error Class
+ */
+extern VALUE eOSSLError;
+
+/*
+ * CheckTypes
+ */
+#define OSSL_Check_Kind(obj, klass) do {\
+ if (!rb_obj_is_kind_of((obj), (klass))) {\
+ ossl_raise(rb_eTypeError, "wrong argument (%"PRIsVALUE")! (Expected kind of %"PRIsVALUE")",\
+ rb_obj_class(obj), (klass));\
+ }\
+} while (0)
+
+#define OSSL_Check_Instance(obj, klass) do {\
+ if (!rb_obj_is_instance_of((obj), (klass))) {\
+ ossl_raise(rb_eTypeError, "wrong argument (%"PRIsVALUE")! (Expected instance of %"PRIsVALUE")",\
+ rb_obj_class(obj), (klass));\
+ }\
+} while (0)
+
+#define OSSL_Check_Same_Class(obj1, obj2) do {\
+ if (!rb_obj_is_instance_of((obj1), rb_obj_class(obj2))) {\
+ ossl_raise(rb_eTypeError, "wrong argument type");\
+ }\
+} while (0)
+
+/*
+ * Compatibility
+ */
+#if OPENSSL_VERSION_NUMBER >= 0x10000000L
+#define STACK _STACK
+#endif
+
+/*
+ * String to HEXString conversion
+ */
+int string2hex(const unsigned char *, int, char **, int *);
+
+/*
+ * Data Conversion
+ */
+STACK_OF(X509) *ossl_x509_ary2sk0(VALUE);
+STACK_OF(X509) *ossl_x509_ary2sk(VALUE);
+STACK_OF(X509) *ossl_protect_x509_ary2sk(VALUE,int*);
+VALUE ossl_x509_sk2ary(STACK_OF(X509) *certs);
+VALUE ossl_x509crl_sk2ary(STACK_OF(X509_CRL) *crl);
+VALUE ossl_x509name_sk2ary(STACK_OF(X509_NAME) *names);
+VALUE ossl_buf2str(char *buf, int len);
+#define ossl_str_adjust(str, p) \
+do{\
+ long len = RSTRING_LEN(str);\
+ long newlen = (long)((p) - (unsigned char*)RSTRING_PTR(str));\
+ assert(newlen <= len);\
+ rb_str_set_len((str), newlen);\
+}while(0)
+
+/*
+ * our default PEM callback
+ */
+int ossl_pem_passwd_cb(char *, int, int, void *);
+
+/*
+ * Clear BIO* with this in PEM/DER fallback scenarios to avoid decoding
+ * errors piling up in OpenSSL::Errors
+ */
+#define OSSL_BIO_reset(bio) (void)BIO_reset((bio)); \
+ ERR_clear_error();
+
+/*
+ * ERRor messages
+ */
+#define OSSL_ErrMsg() ERR_reason_error_string(ERR_get_error())
+NORETURN(void ossl_raise(VALUE, const char *, ...));
+VALUE ossl_exc_new(VALUE, const char *, ...);
+
+/*
+ * Verify callback
+ */
+extern int ossl_verify_cb_idx;
+
+struct ossl_verify_cb_args {
+ VALUE proc;
+ VALUE preverify_ok;
+ VALUE store_ctx;
+};
+
+VALUE ossl_call_verify_cb_proc(struct ossl_verify_cb_args *);
+int ossl_verify_cb(int, X509_STORE_CTX *);
+
+/*
+ * String to DER String
+ */
+extern ID ossl_s_to_der;
+VALUE ossl_to_der(VALUE);
+VALUE ossl_to_der_if_possible(VALUE);
+
+/*
+ * Debug
+ */
+extern VALUE dOSSL;
+
+#if defined(HAVE_VA_ARGS_MACRO)
+#define OSSL_Debug(...) do { \
+ if (dOSSL == Qtrue) { \
+ fprintf(stderr, "OSSL_DEBUG: "); \
+ fprintf(stderr, __VA_ARGS__); \
+ fprintf(stderr, " [%s:%d]\n", __FILE__, __LINE__); \
+ } \
+} while (0)
+
+#define OSSL_Warning(fmt, ...) do { \
+ OSSL_Debug((fmt), ##__VA_ARGS__); \
+ rb_warning((fmt), ##__VA_ARGS__); \
+} while (0)
+
+#define OSSL_Warn(fmt, ...) do { \
+ OSSL_Debug((fmt), ##__VA_ARGS__); \
+ rb_warn((fmt), ##__VA_ARGS__); \
+} while (0)
+#else
+void ossl_debug(const char *, ...);
+#define OSSL_Debug ossl_debug
+#define OSSL_Warning rb_warning
+#define OSSL_Warn rb_warn
+#endif
+
+/*
+ * Include all parts
+ */
+#include "openssl_missing.h"
+#include "ruby_missing.h"
+#include "ossl_asn1.h"
+#include "ossl_bio.h"
+#include "ossl_bn.h"
+#include "ossl_cipher.h"
+#include "ossl_config.h"
+#include "ossl_digest.h"
+#include "ossl_hmac.h"
+#include "ossl_ns_spki.h"
+#include "ossl_ocsp.h"
+#include "ossl_pkcs12.h"
+#include "ossl_pkcs7.h"
+#include "ossl_pkcs5.h"
+#include "ossl_pkey.h"
+#include "ossl_rand.h"
+#include "ossl_ssl.h"
+#include "ossl_version.h"
+#include "ossl_x509.h"
+#include "ossl_engine.h"
+
+void Init_openssl(void);
+
+#if defined(__cplusplus)
+}
+#endif
+
+#endif /* _OSSL_H_ */
+
diff --git a/jni/ruby/ext/openssl/ossl_asn1.c b/jni/ruby/ext/openssl/ossl_asn1.c
new file mode 100644
index 0000000..8741bec
--- /dev/null
+++ b/jni/ruby/ext/openssl/ossl_asn1.c
@@ -0,0 +1,2000 @@
+/*
+ * $Id: ossl_asn1.c 50837 2015-06-11 16:38:12Z nagachika $
+ * 'OpenSSL for Ruby' team members
+ * Copyright (C) 2003
+ * All rights reserved.
+ */
+/*
+ * This program is licenced under the same licence as Ruby.
+ * (See the file 'LICENCE'.)
+ */
+#include "ossl.h"
+
+#if defined(HAVE_SYS_TIME_H)
+# include <sys/time.h>
+#elif !defined(NT) && !defined(_WIN32)
+struct timeval {
+ long tv_sec; /* seconds */
+ long tv_usec; /* and microseconds */
+};
+#endif
+
+static VALUE join_der(VALUE enumerable);
+static VALUE ossl_asn1_decode0(unsigned char **pp, long length, long *offset,
+ int depth, int yield, long *num_read);
+static VALUE ossl_asn1_initialize(int argc, VALUE *argv, VALUE self);
+static VALUE ossl_asn1eoc_initialize(VALUE self);
+
+/*
+ * DATE conversion
+ */
+VALUE
+asn1time_to_time(ASN1_TIME *time)
+{
+ struct tm tm;
+ VALUE argv[6];
+ int count;
+
+ if (!time || !time->data) return Qnil;
+ memset(&tm, 0, sizeof(struct tm));
+
+ switch (time->type) {
+ case V_ASN1_UTCTIME:
+ count = sscanf((const char *)time->data, "%2d%2d%2d%2d%2d%2dZ",
+ &tm.tm_year, &tm.tm_mon, &tm.tm_mday, &tm.tm_hour, &tm.tm_min,
+ &tm.tm_sec);
+
+ if (count == 5) {
+ tm.tm_sec = 0;
+ } else if (count != 6) {
+ ossl_raise(rb_eTypeError, "bad UTCTIME format: \"%s\"",
+ time->data);
+ }
+ if (tm.tm_year < 69) {
+ tm.tm_year += 2000;
+ } else {
+ tm.tm_year += 1900;
+ }
+ break;
+ case V_ASN1_GENERALIZEDTIME:
+ if (sscanf((const char *)time->data, "%4d%2d%2d%2d%2d%2dZ", &tm.tm_year, &tm.tm_mon,
+ &tm.tm_mday, &tm.tm_hour, &tm.tm_min, &tm.tm_sec) != 6) {
+ ossl_raise(rb_eTypeError, "bad GENERALIZEDTIME format" );
+ }
+ break;
+ default:
+ rb_warning("unknown time format");
+ return Qnil;
+ }
+ argv[0] = INT2NUM(tm.tm_year);
+ argv[1] = INT2NUM(tm.tm_mon);
+ argv[2] = INT2NUM(tm.tm_mday);
+ argv[3] = INT2NUM(tm.tm_hour);
+ argv[4] = INT2NUM(tm.tm_min);
+ argv[5] = INT2NUM(tm.tm_sec);
+
+ return rb_funcall2(rb_cTime, rb_intern("utc"), 6, argv);
+}
+
+/*
+ * This function is not exported in Ruby's *.h
+ */
+extern struct timeval rb_time_timeval(VALUE);
+
+time_t
+time_to_time_t(VALUE time)
+{
+ return (time_t)NUM2LONG(rb_Integer(time));
+}
+
+/*
+ * STRING conversion
+ */
+VALUE
+asn1str_to_str(ASN1_STRING *str)
+{
+ return rb_str_new((const char *)str->data, str->length);
+}
+
+/*
+ * ASN1_INTEGER conversions
+ * TODO: Make a decision what's the right way to do this.
+ */
+#define DO_IT_VIA_RUBY 0
+VALUE
+asn1integer_to_num(ASN1_INTEGER *ai)
+{
+ BIGNUM *bn;
+#if DO_IT_VIA_RUBY
+ char *txt;
+#endif
+ VALUE num;
+
+ if (!ai) {
+ ossl_raise(rb_eTypeError, "ASN1_INTEGER is NULL!");
+ }
+ if (!(bn = ASN1_INTEGER_to_BN(ai, NULL))) {
+ ossl_raise(eOSSLError, NULL);
+ }
+#if DO_IT_VIA_RUBY
+ if (!(txt = BN_bn2dec(bn))) {
+ BN_free(bn);
+ ossl_raise(eOSSLError, NULL);
+ }
+ num = rb_cstr_to_inum(txt, 10, Qtrue);
+ OPENSSL_free(txt);
+#else
+ num = ossl_bn_new(bn);
+#endif
+ BN_free(bn);
+
+ return num;
+}
+
+#if DO_IT_VIA_RUBY
+ASN1_INTEGER *
+num_to_asn1integer(VALUE obj, ASN1_INTEGER *ai)
+{
+ BIGNUM *bn = NULL;
+
+ if (RTEST(rb_obj_is_kind_of(obj, cBN))) {
+ bn = GetBNPtr(obj);
+ } else {
+ obj = rb_String(obj);
+ if (!BN_dec2bn(&bn, StringValuePtr(obj))) {
+ ossl_raise(eOSSLError, NULL);
+ }
+ }
+ if (!(ai = BN_to_ASN1_INTEGER(bn, ai))) {
+ BN_free(bn);
+ ossl_raise(eOSSLError, NULL);
+ }
+ BN_free(bn);
+ return ai;
+}
+#else
+ASN1_INTEGER *
+num_to_asn1integer(VALUE obj, ASN1_INTEGER *ai)
+{
+ BIGNUM *bn;
+
+ if (NIL_P(obj))
+ ossl_raise(rb_eTypeError, "Can't convert nil into Integer");
+
+ bn = GetBNPtr(obj);
+
+ if (!(ai = BN_to_ASN1_INTEGER(bn, ai)))
+ ossl_raise(eOSSLError, NULL);
+
+ return ai;
+}
+#endif
+
+/********/
+/*
+ * ASN1 module
+ */
+#define ossl_asn1_get_value(o) rb_attr_get((o),sivVALUE)
+#define ossl_asn1_get_tag(o) rb_attr_get((o),sivTAG)
+#define ossl_asn1_get_tagging(o) rb_attr_get((o),sivTAGGING)
+#define ossl_asn1_get_tag_class(o) rb_attr_get((o),sivTAG_CLASS)
+#define ossl_asn1_get_infinite_length(o) rb_attr_get((o),sivINFINITE_LENGTH)
+
+#define ossl_asn1_set_value(o,v) rb_ivar_set((o),sivVALUE,(v))
+#define ossl_asn1_set_tag(o,v) rb_ivar_set((o),sivTAG,(v))
+#define ossl_asn1_set_tagging(o,v) rb_ivar_set((o),sivTAGGING,(v))
+#define ossl_asn1_set_tag_class(o,v) rb_ivar_set((o),sivTAG_CLASS,(v))
+#define ossl_asn1_set_infinite_length(o,v) rb_ivar_set((o),sivINFINITE_LENGTH,(v))
+
+VALUE mASN1;
+VALUE eASN1Error;
+
+VALUE cASN1Data;
+VALUE cASN1Primitive;
+VALUE cASN1Constructive;
+
+VALUE cASN1EndOfContent;
+VALUE cASN1Boolean; /* BOOLEAN */
+VALUE cASN1Integer, cASN1Enumerated; /* INTEGER */
+VALUE cASN1BitString; /* BIT STRING */
+VALUE cASN1OctetString, cASN1UTF8String; /* STRINGs */
+VALUE cASN1NumericString, cASN1PrintableString;
+VALUE cASN1T61String, cASN1VideotexString;
+VALUE cASN1IA5String, cASN1GraphicString;
+VALUE cASN1ISO64String, cASN1GeneralString;
+VALUE cASN1UniversalString, cASN1BMPString;
+VALUE cASN1Null; /* NULL */
+VALUE cASN1ObjectId; /* OBJECT IDENTIFIER */
+VALUE cASN1UTCTime, cASN1GeneralizedTime; /* TIME */
+VALUE cASN1Sequence, cASN1Set; /* CONSTRUCTIVE */
+
+static ID sIMPLICIT, sEXPLICIT;
+static ID sUNIVERSAL, sAPPLICATION, sCONTEXT_SPECIFIC, sPRIVATE;
+static ID sivVALUE, sivTAG, sivTAG_CLASS, sivTAGGING, sivINFINITE_LENGTH, sivUNUSED_BITS;
+
+/*
+ * We need to implement these for backward compatibility
+ * reasons, behavior of ASN1_put_object and ASN1_object_size
+ * for infinite length values is different in OpenSSL <= 0.9.7
+ */
+#if OPENSSL_VERSION_NUMBER < 0x00908000L
+#define ossl_asn1_object_size(cons, len, tag) (cons) == 2 ? (len) + ASN1_object_size((cons), 0, (tag)) : ASN1_object_size((cons), (len), (tag))
+#define ossl_asn1_put_object(pp, cons, len, tag, xc) (cons) == 2 ? ASN1_put_object((pp), (cons), 0, (tag), (xc)) : ASN1_put_object((pp), (cons), (len), (tag), (xc))
+#else
+#define ossl_asn1_object_size(cons, len, tag) ASN1_object_size((cons), (len), (tag))
+#define ossl_asn1_put_object(pp, cons, len, tag, xc) ASN1_put_object((pp), (cons), (len), (tag), (xc))
+#endif
+
+/*
+ * Ruby to ASN1 converters
+ */
+static ASN1_BOOLEAN
+obj_to_asn1bool(VALUE obj)
+{
+ if (NIL_P(obj))
+ ossl_raise(rb_eTypeError, "Can't convert nil into Boolean");
+
+#if OPENSSL_VERSION_NUMBER < 0x00907000L
+ return RTEST(obj) ? 0xff : 0x100;
+#else
+ return RTEST(obj) ? 0xff : 0x0;
+#endif
+}
+
+static ASN1_INTEGER*
+obj_to_asn1int(VALUE obj)
+{
+ return num_to_asn1integer(obj, NULL);
+}
+
+static ASN1_BIT_STRING*
+obj_to_asn1bstr(VALUE obj, long unused_bits)
+{
+ ASN1_BIT_STRING *bstr;
+
+ if(unused_bits < 0) unused_bits = 0;
+ StringValue(obj);
+ if(!(bstr = ASN1_BIT_STRING_new()))
+ ossl_raise(eASN1Error, NULL);
+ ASN1_BIT_STRING_set(bstr, (unsigned char *)RSTRING_PTR(obj), RSTRING_LENINT(obj));
+ bstr->flags &= ~(ASN1_STRING_FLAG_BITS_LEFT|0x07); /* clear */
+ bstr->flags |= ASN1_STRING_FLAG_BITS_LEFT|(unused_bits&0x07);
+
+ return bstr;
+}
+
+static ASN1_STRING*
+obj_to_asn1str(VALUE obj)
+{
+ ASN1_STRING *str;
+
+ StringValue(obj);
+ if(!(str = ASN1_STRING_new()))
+ ossl_raise(eASN1Error, NULL);
+ ASN1_STRING_set(str, RSTRING_PTR(obj), RSTRING_LENINT(obj));
+
+ return str;
+}
+
+static ASN1_NULL*
+obj_to_asn1null(VALUE obj)
+{
+ ASN1_NULL *null;
+
+ if(!NIL_P(obj))
+ ossl_raise(eASN1Error, "nil expected");
+ if(!(null = ASN1_NULL_new()))
+ ossl_raise(eASN1Error, NULL);
+
+ return null;
+}
+
+static ASN1_OBJECT*
+obj_to_asn1obj(VALUE obj)
+{
+ ASN1_OBJECT *a1obj;
+
+ StringValue(obj);
+ a1obj = OBJ_txt2obj(RSTRING_PTR(obj), 0);
+ if(!a1obj) a1obj = OBJ_txt2obj(RSTRING_PTR(obj), 1);
+ if(!a1obj) ossl_raise(eASN1Error, "invalid OBJECT ID");
+
+ return a1obj;
+}
+
+static ASN1_UTCTIME*
+obj_to_asn1utime(VALUE time)
+{
+ time_t sec;
+ ASN1_UTCTIME *t;
+
+ sec = time_to_time_t(time);
+ if(!(t = ASN1_UTCTIME_set(NULL, sec)))
+ ossl_raise(eASN1Error, NULL);
+
+ return t;
+}
+
+static ASN1_GENERALIZEDTIME*
+obj_to_asn1gtime(VALUE time)
+{
+ time_t sec;
+ ASN1_GENERALIZEDTIME *t;
+
+ sec = time_to_time_t(time);
+ if(!(t =ASN1_GENERALIZEDTIME_set(NULL, sec)))
+ ossl_raise(eASN1Error, NULL);
+
+ return t;
+}
+
+static ASN1_STRING*
+obj_to_asn1derstr(VALUE obj)
+{
+ ASN1_STRING *a1str;
+ VALUE str;
+
+ str = ossl_to_der(obj);
+ if(!(a1str = ASN1_STRING_new()))
+ ossl_raise(eASN1Error, NULL);
+ ASN1_STRING_set(a1str, RSTRING_PTR(str), RSTRING_LENINT(str));
+
+ return a1str;
+}
+
+/*
+ * DER to Ruby converters
+ */
+static VALUE
+decode_bool(unsigned char* der, long length)
+{
+ int val;
+ const unsigned char *p;
+
+ p = der;
+ if((val = d2i_ASN1_BOOLEAN(NULL, &p, length)) < 0)
+ ossl_raise(eASN1Error, NULL);
+
+ return val ? Qtrue : Qfalse;
+}
+
+static VALUE
+decode_int(unsigned char* der, long length)
+{
+ ASN1_INTEGER *ai;
+ const unsigned char *p;
+ VALUE ret;
+ int status = 0;
+
+ p = der;
+ if(!(ai = d2i_ASN1_INTEGER(NULL, &p, length)))
+ ossl_raise(eASN1Error, NULL);
+ ret = rb_protect((VALUE(*)_((VALUE)))asn1integer_to_num,
+ (VALUE)ai, &status);
+ ASN1_INTEGER_free(ai);
+ if(status) rb_jump_tag(status);
+
+ return ret;
+}
+
+static VALUE
+decode_bstr(unsigned char* der, long length, long *unused_bits)
+{
+ ASN1_BIT_STRING *bstr;
+ const unsigned char *p;
+ long len;
+ VALUE ret;
+
+ p = der;
+ if(!(bstr = d2i_ASN1_BIT_STRING(NULL, &p, length)))
+ ossl_raise(eASN1Error, NULL);
+ len = bstr->length;
+ *unused_bits = 0;
+ if(bstr->flags & ASN1_STRING_FLAG_BITS_LEFT)
+ *unused_bits = bstr->flags & 0x07;
+ ret = rb_str_new((const char *)bstr->data, len);
+ ASN1_BIT_STRING_free(bstr);
+
+ return ret;
+}
+
+static VALUE
+decode_enum(unsigned char* der, long length)
+{
+ ASN1_ENUMERATED *ai;
+ const unsigned char *p;
+ VALUE ret;
+ int status = 0;
+
+ p = der;
+ if(!(ai = d2i_ASN1_ENUMERATED(NULL, &p, length)))
+ ossl_raise(eASN1Error, NULL);
+ ret = rb_protect((VALUE(*)_((VALUE)))asn1integer_to_num,
+ (VALUE)ai, &status);
+ ASN1_ENUMERATED_free(ai);
+ if(status) rb_jump_tag(status);
+
+ return ret;
+}
+
+static VALUE
+decode_null(unsigned char* der, long length)
+{
+ ASN1_NULL *null;
+ const unsigned char *p;
+
+ p = der;
+ if(!(null = d2i_ASN1_NULL(NULL, &p, length)))
+ ossl_raise(eASN1Error, NULL);
+ ASN1_NULL_free(null);
+
+ return Qnil;
+}
+
+static VALUE
+decode_obj(unsigned char* der, long length)
+{
+ ASN1_OBJECT *obj;
+ const unsigned char *p;
+ VALUE ret;
+ int nid;
+ BIO *bio;
+
+ p = der;
+ if(!(obj = d2i_ASN1_OBJECT(NULL, &p, length)))
+ ossl_raise(eASN1Error, NULL);
+ if((nid = OBJ_obj2nid(obj)) != NID_undef){
+ ASN1_OBJECT_free(obj);
+ ret = rb_str_new2(OBJ_nid2sn(nid));
+ }
+ else{
+ if(!(bio = BIO_new(BIO_s_mem()))){
+ ASN1_OBJECT_free(obj);
+ ossl_raise(eASN1Error, NULL);
+ }
+ i2a_ASN1_OBJECT(bio, obj);
+ ASN1_OBJECT_free(obj);
+ ret = ossl_membio2str(bio);
+ }
+
+ return ret;
+}
+
+static VALUE
+decode_time(unsigned char* der, long length)
+{
+ ASN1_TIME *time;
+ const unsigned char *p;
+ VALUE ret;
+ int status = 0;
+
+ p = der;
+ if(!(time = d2i_ASN1_TIME(NULL, &p, length)))
+ ossl_raise(eASN1Error, NULL);
+ ret = rb_protect((VALUE(*)_((VALUE)))asn1time_to_time,
+ (VALUE)time, &status);
+ ASN1_TIME_free(time);
+ if(status) rb_jump_tag(status);
+
+ return ret;
+}
+
+static VALUE
+decode_eoc(unsigned char *der, long length)
+{
+ if (length != 2 || !(der[0] == 0x00 && der[1] == 0x00))
+ ossl_raise(eASN1Error, NULL);
+
+ return rb_str_new("", 0);
+}
+
+/********/
+
+typedef struct {
+ const char *name;
+ VALUE *klass;
+} ossl_asn1_info_t;
+
+static const ossl_asn1_info_t ossl_asn1_info[] = {
+ { "EOC", &cASN1EndOfContent, }, /* 0 */
+ { "BOOLEAN", &cASN1Boolean, }, /* 1 */
+ { "INTEGER", &cASN1Integer, }, /* 2 */
+ { "BIT_STRING", &cASN1BitString, }, /* 3 */
+ { "OCTET_STRING", &cASN1OctetString, }, /* 4 */
+ { "NULL", &cASN1Null, }, /* 5 */
+ { "OBJECT", &cASN1ObjectId, }, /* 6 */
+ { "OBJECT_DESCRIPTOR", NULL, }, /* 7 */
+ { "EXTERNAL", NULL, }, /* 8 */
+ { "REAL", NULL, }, /* 9 */
+ { "ENUMERATED", &cASN1Enumerated, }, /* 10 */
+ { "EMBEDDED_PDV", NULL, }, /* 11 */
+ { "UTF8STRING", &cASN1UTF8String, }, /* 12 */
+ { "RELATIVE_OID", NULL, }, /* 13 */
+ { "[UNIVERSAL 14]", NULL, }, /* 14 */
+ { "[UNIVERSAL 15]", NULL, }, /* 15 */
+ { "SEQUENCE", &cASN1Sequence, }, /* 16 */
+ { "SET", &cASN1Set, }, /* 17 */
+ { "NUMERICSTRING", &cASN1NumericString, }, /* 18 */
+ { "PRINTABLESTRING", &cASN1PrintableString, }, /* 19 */
+ { "T61STRING", &cASN1T61String, }, /* 20 */
+ { "VIDEOTEXSTRING", &cASN1VideotexString, }, /* 21 */
+ { "IA5STRING", &cASN1IA5String, }, /* 22 */
+ { "UTCTIME", &cASN1UTCTime, }, /* 23 */
+ { "GENERALIZEDTIME", &cASN1GeneralizedTime, }, /* 24 */
+ { "GRAPHICSTRING", &cASN1GraphicString, }, /* 25 */
+ { "ISO64STRING", &cASN1ISO64String, }, /* 26 */
+ { "GENERALSTRING", &cASN1GeneralString, }, /* 27 */
+ { "UNIVERSALSTRING", &cASN1UniversalString, }, /* 28 */
+ { "CHARACTER_STRING", NULL, }, /* 29 */
+ { "BMPSTRING", &cASN1BMPString, }, /* 30 */
+};
+
+enum {ossl_asn1_info_size = (sizeof(ossl_asn1_info)/sizeof(ossl_asn1_info[0]))};
+
+static VALUE class_tag_map;
+
+static int ossl_asn1_default_tag(VALUE obj);
+
+ASN1_TYPE*
+ossl_asn1_get_asn1type(VALUE obj)
+{
+ ASN1_TYPE *ret;
+ VALUE value, rflag;
+ void *ptr;
+ void (*free_func)();
+ int tag, flag;
+
+ tag = ossl_asn1_default_tag(obj);
+ value = ossl_asn1_get_value(obj);
+ switch(tag){
+ case V_ASN1_BOOLEAN:
+ ptr = (void*)(VALUE)obj_to_asn1bool(value);
+ free_func = NULL;
+ break;
+ case V_ASN1_INTEGER: /* FALLTHROUGH */
+ case V_ASN1_ENUMERATED:
+ ptr = obj_to_asn1int(value);
+ free_func = ASN1_INTEGER_free;
+ break;
+ case V_ASN1_BIT_STRING:
+ rflag = rb_attr_get(obj, sivUNUSED_BITS);
+ flag = NIL_P(rflag) ? -1 : NUM2INT(rflag);
+ ptr = obj_to_asn1bstr(value, flag);
+ free_func = ASN1_BIT_STRING_free;
+ break;
+ case V_ASN1_NULL:
+ ptr = obj_to_asn1null(value);
+ free_func = ASN1_NULL_free;
+ break;
+ case V_ASN1_OCTET_STRING: /* FALLTHROUGH */
+ case V_ASN1_UTF8STRING: /* FALLTHROUGH */
+ case V_ASN1_NUMERICSTRING: /* FALLTHROUGH */
+ case V_ASN1_PRINTABLESTRING: /* FALLTHROUGH */
+ case V_ASN1_T61STRING: /* FALLTHROUGH */
+ case V_ASN1_VIDEOTEXSTRING: /* FALLTHROUGH */
+ case V_ASN1_IA5STRING: /* FALLTHROUGH */
+ case V_ASN1_GRAPHICSTRING: /* FALLTHROUGH */
+ case V_ASN1_ISO64STRING: /* FALLTHROUGH */
+ case V_ASN1_GENERALSTRING: /* FALLTHROUGH */
+ case V_ASN1_UNIVERSALSTRING: /* FALLTHROUGH */
+ case V_ASN1_BMPSTRING:
+ ptr = obj_to_asn1str(value);
+ free_func = ASN1_STRING_free;
+ break;
+ case V_ASN1_OBJECT:
+ ptr = obj_to_asn1obj(value);
+ free_func = ASN1_OBJECT_free;
+ break;
+ case V_ASN1_UTCTIME:
+ ptr = obj_to_asn1utime(value);
+ free_func = ASN1_TIME_free;
+ break;
+ case V_ASN1_GENERALIZEDTIME:
+ ptr = obj_to_asn1gtime(value);
+ free_func = ASN1_TIME_free;
+ break;
+ case V_ASN1_SET: /* FALLTHROUGH */
+ case V_ASN1_SEQUENCE:
+ ptr = obj_to_asn1derstr(obj);
+ free_func = ASN1_STRING_free;
+ break;
+ default:
+ ossl_raise(eASN1Error, "unsupported ASN.1 type");
+ }
+ if(!(ret = OPENSSL_malloc(sizeof(ASN1_TYPE)))){
+ if(free_func) free_func(ptr);
+ ossl_raise(eASN1Error, "ASN1_TYPE alloc failure");
+ }
+ memset(ret, 0, sizeof(ASN1_TYPE));
+ ASN1_TYPE_set(ret, tag, ptr);
+
+ return ret;
+}
+
+static int
+ossl_asn1_default_tag(VALUE obj)
+{
+ VALUE tmp_class, tag;
+
+ tmp_class = CLASS_OF(obj);
+ while (tmp_class) {
+ tag = rb_hash_lookup(class_tag_map, tmp_class);
+ if (tag != Qnil) {
+ return NUM2INT(tag);
+ }
+ tmp_class = rb_class_superclass(tmp_class);
+ }
+ ossl_raise(eASN1Error, "universal tag for %"PRIsVALUE" not found",
+ rb_obj_class(obj));
+
+ return -1; /* dummy */
+}
+
+static int
+ossl_asn1_tag(VALUE obj)
+{
+ VALUE tag;
+
+ tag = ossl_asn1_get_tag(obj);
+ if(NIL_P(tag))
+ ossl_raise(eASN1Error, "tag number not specified");
+
+ return NUM2INT(tag);
+}
+
+static int
+ossl_asn1_is_explicit(VALUE obj)
+{
+ VALUE s;
+ int ret = -1;
+
+ s = ossl_asn1_get_tagging(obj);
+ if(NIL_P(s)) return 0;
+ else if(SYMBOL_P(s)){
+ if (SYM2ID(s) == sIMPLICIT)
+ ret = 0;
+ else if (SYM2ID(s) == sEXPLICIT)
+ ret = 1;
+ }
+ if(ret < 0){
+ ossl_raise(eASN1Error, "invalid tag default");
+ }
+
+ return ret;
+}
+
+static int
+ossl_asn1_tag_class(VALUE obj)
+{
+ VALUE s;
+ int ret = -1;
+
+ s = ossl_asn1_get_tag_class(obj);
+ if(NIL_P(s)) ret = V_ASN1_UNIVERSAL;
+ else if(SYMBOL_P(s)){
+ if (SYM2ID(s) == sUNIVERSAL)
+ ret = V_ASN1_UNIVERSAL;
+ else if (SYM2ID(s) == sAPPLICATION)
+ ret = V_ASN1_APPLICATION;
+ else if (SYM2ID(s) == sCONTEXT_SPECIFIC)
+ ret = V_ASN1_CONTEXT_SPECIFIC;
+ else if (SYM2ID(s) == sPRIVATE)
+ ret = V_ASN1_PRIVATE;
+ }
+ if(ret < 0){
+ ossl_raise(eASN1Error, "invalid tag class");
+ }
+
+ return ret;
+}
+
+static VALUE
+ossl_asn1_class2sym(int tc)
+{
+ if((tc & V_ASN1_PRIVATE) == V_ASN1_PRIVATE)
+ return ID2SYM(sPRIVATE);
+ else if((tc & V_ASN1_CONTEXT_SPECIFIC) == V_ASN1_CONTEXT_SPECIFIC)
+ return ID2SYM(sCONTEXT_SPECIFIC);
+ else if((tc & V_ASN1_APPLICATION) == V_ASN1_APPLICATION)
+ return ID2SYM(sAPPLICATION);
+ else
+ return ID2SYM(sUNIVERSAL);
+}
+
+/*
+ * call-seq:
+ * OpenSSL::ASN1::ASN1Data.new(value, tag, tag_class) => ASN1Data
+ *
+ * +value+: Please have a look at Constructive and Primitive to see how Ruby
+ * types are mapped to ASN.1 types and vice versa.
+ *
+ * +tag+: A +Number+ indicating the tag number.
+ *
+ * +tag_class+: A +Symbol+ indicating the tag class. Please cf. ASN1 for
+ * possible values.
+ *
+ * == Example
+ * asn1_int = OpenSSL::ASN1Data.new(42, 2, :UNIVERSAL) # => Same as OpenSSL::ASN1::Integer.new(42)
+ * tagged_int = OpenSSL::ASN1Data.new(42, 0, :CONTEXT_SPECIFIC) # implicitly 0-tagged INTEGER
+ */
+static VALUE
+ossl_asn1data_initialize(VALUE self, VALUE value, VALUE tag, VALUE tag_class)
+{
+ if(!SYMBOL_P(tag_class))
+ ossl_raise(eASN1Error, "invalid tag class");
+ if((SYM2ID(tag_class) == sUNIVERSAL) && NUM2INT(tag) > 31)
+ ossl_raise(eASN1Error, "tag number for Universal too large");
+ ossl_asn1_set_tag(self, tag);
+ ossl_asn1_set_value(self, value);
+ ossl_asn1_set_tag_class(self, tag_class);
+ ossl_asn1_set_infinite_length(self, Qfalse);
+
+ return self;
+}
+
+static VALUE
+join_der_i(RB_BLOCK_CALL_FUNC_ARGLIST(i, str))
+{
+ i = ossl_to_der_if_possible(i);
+ StringValue(i);
+ rb_str_append(str, i);
+ return Qnil;
+}
+
+static VALUE
+join_der(VALUE enumerable)
+{
+ VALUE str = rb_str_new(0, 0);
+ rb_block_call(enumerable, rb_intern("each"), 0, 0, join_der_i, str);
+ return str;
+}
+
+/*
+ * call-seq:
+ * asn1.to_der => DER-encoded String
+ *
+ * Encodes this ASN1Data into a DER-encoded String value. The result is
+ * DER-encoded except for the possibility of infinite length encodings.
+ * Infinite length encodings are not allowed in strict DER, so strictly
+ * speaking the result of such an encoding would be a BER-encoding.
+ */
+static VALUE
+ossl_asn1data_to_der(VALUE self)
+{
+ VALUE value, der, inf_length;
+ int tag, tag_class, is_cons = 0;
+ long length;
+ unsigned char *p;
+
+ value = ossl_asn1_get_value(self);
+ if(rb_obj_is_kind_of(value, rb_cArray)){
+ is_cons = 1;
+ value = join_der(value);
+ }
+ StringValue(value);
+
+ tag = ossl_asn1_tag(self);
+ tag_class = ossl_asn1_tag_class(self);
+ inf_length = ossl_asn1_get_infinite_length(self);
+ if (inf_length == Qtrue) {
+ is_cons = 2;
+ }
+ if((length = ossl_asn1_object_size(is_cons, RSTRING_LENINT(value), tag)) <= 0)
+ ossl_raise(eASN1Error, NULL);
+ der = rb_str_new(0, length);
+ p = (unsigned char *)RSTRING_PTR(der);
+ ossl_asn1_put_object(&p, is_cons, RSTRING_LENINT(value), tag, tag_class);
+ memcpy(p, RSTRING_PTR(value), RSTRING_LEN(value));
+ p += RSTRING_LEN(value);
+ ossl_str_adjust(der, p);
+
+ return der;
+}
+
+static VALUE
+int_ossl_asn1_decode0_prim(unsigned char **pp, long length, long hlen, int tag,
+ VALUE tc, long *num_read)
+{
+ VALUE value, asn1data;
+ unsigned char *p;
+ long flag = 0;
+
+ p = *pp;
+
+ if(tc == sUNIVERSAL && tag < ossl_asn1_info_size) {
+ switch(tag){
+ case V_ASN1_EOC:
+ value = decode_eoc(p, hlen+length);
+ break;
+ case V_ASN1_BOOLEAN:
+ value = decode_bool(p, hlen+length);
+ break;
+ case V_ASN1_INTEGER:
+ value = decode_int(p, hlen+length);
+ break;
+ case V_ASN1_BIT_STRING:
+ value = decode_bstr(p, hlen+length, &flag);
+ break;
+ case V_ASN1_NULL:
+ value = decode_null(p, hlen+length);
+ break;
+ case V_ASN1_ENUMERATED:
+ value = decode_enum(p, hlen+length);
+ break;
+ case V_ASN1_OBJECT:
+ value = decode_obj(p, hlen+length);
+ break;
+ case V_ASN1_UTCTIME: /* FALLTHROUGH */
+ case V_ASN1_GENERALIZEDTIME:
+ value = decode_time(p, hlen+length);
+ break;
+ default:
+ /* use original value */
+ p += hlen;
+ value = rb_str_new((const char *)p, length);
+ break;
+ }
+ }
+ else {
+ p += hlen;
+ value = rb_str_new((const char *)p, length);
+ }
+
+ *pp += hlen + length;
+ *num_read = hlen + length;
+
+ if (tc == sUNIVERSAL && tag < ossl_asn1_info_size && ossl_asn1_info[tag].klass) {
+ VALUE klass = *ossl_asn1_info[tag].klass;
+ VALUE args[4];
+ args[0] = value;
+ args[1] = INT2NUM(tag);
+ args[2] = Qnil;
+ args[3] = ID2SYM(tc);
+ asn1data = rb_obj_alloc(klass);
+ ossl_asn1_initialize(4, args, asn1data);
+ if(tag == V_ASN1_BIT_STRING){
+ rb_ivar_set(asn1data, sivUNUSED_BITS, LONG2NUM(flag));
+ }
+ }
+ else {
+ asn1data = rb_obj_alloc(cASN1Data);
+ ossl_asn1data_initialize(asn1data, value, INT2NUM(tag), ID2SYM(tc));
+ }
+
+ return asn1data;
+}
+
+static VALUE
+int_ossl_asn1_decode0_cons(unsigned char **pp, long max_len, long length,
+ long *offset, int depth, int yield, int j,
+ int tag, VALUE tc, long *num_read)
+{
+ VALUE value, asn1data, ary;
+ int infinite;
+ long off = *offset;
+
+ infinite = (j == 0x21);
+ ary = rb_ary_new();
+
+ while (length > 0 || infinite) {
+ long inner_read = 0;
+ value = ossl_asn1_decode0(pp, max_len, &off, depth + 1, yield, &inner_read);
+ *num_read += inner_read;
+ max_len -= inner_read;
+ rb_ary_push(ary, value);
+ if (length > 0)
+ length -= inner_read;
+
+ if (infinite &&
+ NUM2INT(ossl_asn1_get_tag(value)) == V_ASN1_EOC &&
+ SYM2ID(ossl_asn1_get_tag_class(value)) == sUNIVERSAL) {
+ break;
+ }
+ }
+
+ if (tc == sUNIVERSAL) {
+ VALUE args[4];
+ int not_sequence_or_set;
+
+ not_sequence_or_set = tag != V_ASN1_SEQUENCE && tag != V_ASN1_SET;
+
+ if (not_sequence_or_set) {
+ if (infinite) {
+ asn1data = rb_obj_alloc(cASN1Constructive);
+ }
+ else {
+ ossl_raise(eASN1Error, "invalid non-infinite tag");
+ return Qnil;
+ }
+ }
+ else {
+ VALUE klass = *ossl_asn1_info[tag].klass;
+ asn1data = rb_obj_alloc(klass);
+ }
+ args[0] = ary;
+ args[1] = INT2NUM(tag);
+ args[2] = Qnil;
+ args[3] = ID2SYM(tc);
+ ossl_asn1_initialize(4, args, asn1data);
+ }
+ else {
+ asn1data = rb_obj_alloc(cASN1Data);
+ ossl_asn1data_initialize(asn1data, ary, INT2NUM(tag), ID2SYM(tc));
+ }
+
+ if (infinite)
+ ossl_asn1_set_infinite_length(asn1data, Qtrue);
+ else
+ ossl_asn1_set_infinite_length(asn1data, Qfalse);
+
+ *offset = off;
+ return asn1data;
+}
+
+static VALUE
+ossl_asn1_decode0(unsigned char **pp, long length, long *offset, int depth,
+ int yield, long *num_read)
+{
+ unsigned char *start, *p;
+ const unsigned char *p0;
+ long len = 0, inner_read = 0, off = *offset, hlen;
+ int tag, tc, j;
+ VALUE asn1data, tag_class;
+
+ p = *pp;
+ start = p;
+ p0 = p;
+ j = ASN1_get_object(&p0, &len, &tag, &tc, length);
+ p = (unsigned char *)p0;
+ if(j & 0x80) ossl_raise(eASN1Error, NULL);
+ if(len > length) ossl_raise(eASN1Error, "value is too short");
+ if((tc & V_ASN1_PRIVATE) == V_ASN1_PRIVATE)
+ tag_class = sPRIVATE;
+ else if((tc & V_ASN1_CONTEXT_SPECIFIC) == V_ASN1_CONTEXT_SPECIFIC)
+ tag_class = sCONTEXT_SPECIFIC;
+ else if((tc & V_ASN1_APPLICATION) == V_ASN1_APPLICATION)
+ tag_class = sAPPLICATION;
+ else
+ tag_class = sUNIVERSAL;
+
+ hlen = p - start;
+
+ if(yield) {
+ VALUE arg = rb_ary_new();
+ rb_ary_push(arg, LONG2NUM(depth));
+ rb_ary_push(arg, LONG2NUM(*offset));
+ rb_ary_push(arg, LONG2NUM(hlen));
+ rb_ary_push(arg, LONG2NUM(len));
+ rb_ary_push(arg, (j & V_ASN1_CONSTRUCTED) ? Qtrue : Qfalse);
+ rb_ary_push(arg, ossl_asn1_class2sym(tc));
+ rb_ary_push(arg, INT2NUM(tag));
+ rb_yield(arg);
+ }
+
+ if(j & V_ASN1_CONSTRUCTED) {
+ *pp += hlen;
+ off += hlen;
+ asn1data = int_ossl_asn1_decode0_cons(pp, length, len, &off, depth, yield, j, tag, tag_class, &inner_read);
+ inner_read += hlen;
+ }
+ else {
+ if ((j & 0x01) && (len == 0)) ossl_raise(eASN1Error, "Infinite length for primitive value");
+ asn1data = int_ossl_asn1_decode0_prim(pp, len, hlen, tag, tag_class, &inner_read);
+ off += hlen + len;
+ }
+ if (num_read)
+ *num_read = inner_read;
+ if (len != 0 && inner_read != hlen + len) {
+ ossl_raise(eASN1Error,
+ "Type mismatch. Bytes read: %ld Bytes available: %ld",
+ inner_read, hlen + len);
+ }
+
+ *offset = off;
+ return asn1data;
+}
+
+static void
+int_ossl_decode_sanity_check(long len, long read, long offset)
+{
+ if (len != 0 && (read != len || offset != len)) {
+ ossl_raise(eASN1Error,
+ "Type mismatch. Total bytes read: %ld Bytes available: %ld Offset: %ld",
+ read, len, offset);
+ }
+}
+
+/*
+ * call-seq:
+ * OpenSSL::ASN1.traverse(asn1) -> nil
+ *
+ * If a block is given, it prints out each of the elements encountered.
+ * Block parameters are (in that order):
+ * * depth: The recursion depth, plus one with each constructed value being encountered (Number)
+ * * offset: Current byte offset (Number)
+ * * header length: Combined length in bytes of the Tag and Length headers. (Number)
+ * * length: The overall remaining length of the entire data (Number)
+ * * constructed: Whether this value is constructed or not (Boolean)
+ * * tag_class: Current tag class (Symbol)
+ * * tag: The current tag (Number)
+ *
+ * == Example
+ * der = File.binread('asn1data.der')
+ * OpenSSL::ASN1.traverse(der) do | depth, offset, header_len, length, constructed, tag_class, tag|
+ * puts "Depth: #{depth} Offset: #{offset} Length: #{length}"
+ * puts "Header length: #{header_len} Tag: #{tag} Tag class: #{tag_class} Constructed: #{constructed}"
+ * end
+ */
+static VALUE
+ossl_asn1_traverse(VALUE self, VALUE obj)
+{
+ unsigned char *p;
+ VALUE tmp;
+ long len, read = 0, offset = 0;
+
+ obj = ossl_to_der_if_possible(obj);
+ tmp = rb_str_new4(StringValue(obj));
+ p = (unsigned char *)RSTRING_PTR(tmp);
+ len = RSTRING_LEN(tmp);
+ ossl_asn1_decode0(&p, len, &offset, 0, 1, &read);
+ RB_GC_GUARD(tmp);
+ int_ossl_decode_sanity_check(len, read, offset);
+ return Qnil;
+}
+
+/*
+ * call-seq:
+ * OpenSSL::ASN1.decode(der) -> ASN1Data
+ *
+ * Decodes a BER- or DER-encoded value and creates an ASN1Data instance. +der+
+ * may be a +String+ or any object that features a +#to_der+ method transforming
+ * it into a BER-/DER-encoded +String+.
+ *
+ * == Example
+ * der = File.binread('asn1data')
+ * asn1 = OpenSSL::ASN1.decode(der)
+ */
+static VALUE
+ossl_asn1_decode(VALUE self, VALUE obj)
+{
+ VALUE ret;
+ unsigned char *p;
+ VALUE tmp;
+ long len, read = 0, offset = 0;
+
+ obj = ossl_to_der_if_possible(obj);
+ tmp = rb_str_new4(StringValue(obj));
+ p = (unsigned char *)RSTRING_PTR(tmp);
+ len = RSTRING_LEN(tmp);
+ ret = ossl_asn1_decode0(&p, len, &offset, 0, 0, &read);
+ RB_GC_GUARD(tmp);
+ int_ossl_decode_sanity_check(len, read, offset);
+ return ret;
+}
+
+/*
+ * call-seq:
+ * OpenSSL::ASN1.decode_all(der) -> Array of ASN1Data
+ *
+ * Similar to +decode+ with the difference that +decode+ expects one
+ * distinct value represented in +der+. +decode_all+ on the contrary
+ * decodes a sequence of sequential BER/DER values lined up in +der+
+ * and returns them as an array.
+ *
+ * == Example
+ * ders = File.binread('asn1data_seq')
+ * asn1_ary = OpenSSL::ASN1.decode_all(ders)
+ */
+static VALUE
+ossl_asn1_decode_all(VALUE self, VALUE obj)
+{
+ VALUE ary, val;
+ unsigned char *p;
+ long len, tmp_len = 0, read = 0, offset = 0;
+ VALUE tmp;
+
+ obj = ossl_to_der_if_possible(obj);
+ tmp = rb_str_new4(StringValue(obj));
+ p = (unsigned char *)RSTRING_PTR(tmp);
+ len = RSTRING_LEN(tmp);
+ tmp_len = len;
+ ary = rb_ary_new();
+ while (tmp_len > 0) {
+ long tmp_read = 0;
+ val = ossl_asn1_decode0(&p, tmp_len, &offset, 0, 0, &tmp_read);
+ rb_ary_push(ary, val);
+ read += tmp_read;
+ tmp_len -= tmp_read;
+ }
+ RB_GC_GUARD(tmp);
+ int_ossl_decode_sanity_check(len, read, offset);
+ return ary;
+}
+
+/*
+ * call-seq:
+ * OpenSSL::ASN1::Primitive.new( value [, tag, tagging, tag_class ]) => Primitive
+ *
+ * +value+: is mandatory.
+ *
+ * +tag+: optional, may be specified for tagged values. If no +tag+ is
+ * specified, the UNIVERSAL tag corresponding to the Primitive sub-class
+ * is used by default.
+ *
+ * +tagging+: may be used as an encoding hint to encode a value either
+ * explicitly or implicitly, see ASN1 for possible values.
+ *
+ * +tag_class+: if +tag+ and +tagging+ are +nil+ then this is set to
+ * +:UNIVERSAL+ by default. If either +tag+ or +tagging+ are set then
+ * +:CONTEXT_SPECIFIC+ is used as the default. For possible values please
+ * cf. ASN1.
+ *
+ * == Example
+ * int = OpenSSL::ASN1::Integer.new(42)
+ * zero_tagged_int = OpenSSL::ASN1::Integer.new(42, 0, :IMPLICIT)
+ * private_explicit_zero_tagged_int = OpenSSL::ASN1::Integer.new(42, 0, :EXPLICIT, :PRIVATE)
+ */
+static VALUE
+ossl_asn1_initialize(int argc, VALUE *argv, VALUE self)
+{
+ VALUE value, tag, tagging, tag_class;
+
+ rb_scan_args(argc, argv, "13", &value, &tag, &tagging, &tag_class);
+ if(argc > 1){
+ if(NIL_P(tag))
+ ossl_raise(eASN1Error, "must specify tag number");
+ if(!NIL_P(tagging) && !SYMBOL_P(tagging))
+ ossl_raise(eASN1Error, "invalid tagging method");
+ if(NIL_P(tag_class)) {
+ if (NIL_P(tagging))
+ tag_class = ID2SYM(sUNIVERSAL);
+ else
+ tag_class = ID2SYM(sCONTEXT_SPECIFIC);
+ }
+ if(!SYMBOL_P(tag_class))
+ ossl_raise(eASN1Error, "invalid tag class");
+ if(!NIL_P(tagging) && SYM2ID(tagging) == sIMPLICIT && NUM2INT(tag) > 31)
+ ossl_raise(eASN1Error, "tag number for Universal too large");
+ }
+ else{
+ tag = INT2NUM(ossl_asn1_default_tag(self));
+ tagging = Qnil;
+ tag_class = ID2SYM(sUNIVERSAL);
+ }
+ ossl_asn1_set_tag(self, tag);
+ ossl_asn1_set_value(self, value);
+ ossl_asn1_set_tagging(self, tagging);
+ ossl_asn1_set_tag_class(self, tag_class);
+ ossl_asn1_set_infinite_length(self, Qfalse);
+
+ return self;
+}
+
+static VALUE
+ossl_asn1eoc_initialize(VALUE self) {
+ VALUE tag, tagging, tag_class, value;
+ tag = INT2NUM(ossl_asn1_default_tag(self));
+ tagging = Qnil;
+ tag_class = ID2SYM(sUNIVERSAL);
+ value = rb_str_new("", 0);
+ ossl_asn1_set_tag(self, tag);
+ ossl_asn1_set_value(self, value);
+ ossl_asn1_set_tagging(self, tagging);
+ ossl_asn1_set_tag_class(self, tag_class);
+ ossl_asn1_set_infinite_length(self, Qfalse);
+ return self;
+}
+
+static int
+ossl_i2d_ASN1_TYPE(ASN1_TYPE *a, unsigned char **pp)
+{
+#if OPENSSL_VERSION_NUMBER < 0x00907000L
+ if(!a) return 0;
+ if(a->type == V_ASN1_BOOLEAN)
+ return i2d_ASN1_BOOLEAN(a->value.boolean, pp);
+#endif
+ return i2d_ASN1_TYPE(a, pp);
+}
+
+static void
+ossl_ASN1_TYPE_free(ASN1_TYPE *a)
+{
+#if OPENSSL_VERSION_NUMBER < 0x00907000L
+ if(!a) return;
+ if(a->type == V_ASN1_BOOLEAN){
+ OPENSSL_free(a);
+ return;
+ }
+#endif
+ ASN1_TYPE_free(a);
+}
+
+/*
+ * call-seq:
+ * asn1.to_der => DER-encoded String
+ *
+ * See ASN1Data#to_der for details. *
+ */
+static VALUE
+ossl_asn1prim_to_der(VALUE self)
+{
+ ASN1_TYPE *asn1;
+ int tn, tc, explicit;
+ long len, reallen;
+ unsigned char *buf, *p;
+ VALUE str;
+
+ tn = NUM2INT(ossl_asn1_get_tag(self));
+ tc = ossl_asn1_tag_class(self);
+ explicit = ossl_asn1_is_explicit(self);
+ asn1 = ossl_asn1_get_asn1type(self);
+
+ len = ossl_asn1_object_size(1, ossl_i2d_ASN1_TYPE(asn1, NULL), tn);
+ if(!(buf = OPENSSL_malloc(len))){
+ ossl_ASN1_TYPE_free(asn1);
+ ossl_raise(eASN1Error, "cannot alloc buffer");
+ }
+ p = buf;
+ if (tc == V_ASN1_UNIVERSAL) {
+ ossl_i2d_ASN1_TYPE(asn1, &p);
+ } else if (explicit) {
+ ossl_asn1_put_object(&p, 1, ossl_i2d_ASN1_TYPE(asn1, NULL), tn, tc);
+ ossl_i2d_ASN1_TYPE(asn1, &p);
+ } else {
+ ossl_i2d_ASN1_TYPE(asn1, &p);
+ *buf = tc | tn | (*buf & V_ASN1_CONSTRUCTED);
+ }
+ ossl_ASN1_TYPE_free(asn1);
+ reallen = p - buf;
+ assert(reallen <= len);
+ str = ossl_buf2str((char *)buf, rb_long2int(reallen)); /* buf will be free in ossl_buf2str */
+
+ return str;
+}
+
+/*
+ * call-seq:
+ * asn1.to_der => DER-encoded String
+ *
+ * See ASN1Data#to_der for details.
+ */
+static VALUE
+ossl_asn1cons_to_der(VALUE self)
+{
+ int tag, tn, tc, explicit, constructed = 1;
+ int found_prim = 0, seq_len;
+ long length;
+ unsigned char *p;
+ VALUE value, str, inf_length;
+
+ tn = NUM2INT(ossl_asn1_get_tag(self));
+ tc = ossl_asn1_tag_class(self);
+ inf_length = ossl_asn1_get_infinite_length(self);
+ if (inf_length == Qtrue) {
+ VALUE ary, example;
+ constructed = 2;
+ if (CLASS_OF(self) == cASN1Sequence ||
+ CLASS_OF(self) == cASN1Set) {
+ tag = ossl_asn1_default_tag(self);
+ }
+ else { /* must be a constructive encoding of a primitive value */
+ ary = ossl_asn1_get_value(self);
+ if (!rb_obj_is_kind_of(ary, rb_cArray))
+ ossl_raise(eASN1Error, "Constructive value must be an Array");
+ /* Recursively descend until a primitive value is found.
+ The overall value of the entire constructed encoding
+ is of the type of the first primitive encoding to be
+ found. */
+ while (!found_prim){
+ example = rb_ary_entry(ary, 0);
+ if (rb_obj_is_kind_of(example, cASN1Primitive)){
+ found_prim = 1;
+ }
+ else {
+ /* example is another ASN1Constructive */
+ if (!rb_obj_is_kind_of(example, cASN1Constructive)){
+ ossl_raise(eASN1Error, "invalid constructed encoding");
+ return Qnil; /* dummy */
+ }
+ ary = ossl_asn1_get_value(example);
+ }
+ }
+ tag = ossl_asn1_default_tag(example);
+ }
+ }
+ else {
+ if (CLASS_OF(self) == cASN1Constructive)
+ ossl_raise(eASN1Error, "Constructive shall only be used with infinite length");
+ tag = ossl_asn1_default_tag(self);
+ }
+ explicit = ossl_asn1_is_explicit(self);
+ value = join_der(ossl_asn1_get_value(self));
+
+ seq_len = ossl_asn1_object_size(constructed, RSTRING_LENINT(value), tag);
+ length = ossl_asn1_object_size(constructed, seq_len, tn);
+ str = rb_str_new(0, length);
+ p = (unsigned char *)RSTRING_PTR(str);
+ if(tc == V_ASN1_UNIVERSAL)
+ ossl_asn1_put_object(&p, constructed, RSTRING_LENINT(value), tn, tc);
+ else{
+ if(explicit){
+ ossl_asn1_put_object(&p, constructed, seq_len, tn, tc);
+ ossl_asn1_put_object(&p, constructed, RSTRING_LENINT(value), tag, V_ASN1_UNIVERSAL);
+ }
+ else{
+ ossl_asn1_put_object(&p, constructed, RSTRING_LENINT(value), tn, tc);
+ }
+ }
+ memcpy(p, RSTRING_PTR(value), RSTRING_LEN(value));
+ p += RSTRING_LEN(value);
+
+ /* In this case we need an additional EOC (one for the explicit part and
+ * one for the Constructive itself. The EOC for the Constructive is
+ * supplied by the user, but that for the "explicit wrapper" must be
+ * added here.
+ */
+ if (explicit && inf_length == Qtrue) {
+ ASN1_put_eoc(&p);
+ }
+ ossl_str_adjust(str, p);
+
+ return str;
+}
+
+/*
+ * call-seq:
+ * asn1_ary.each { |asn1| block } => asn1_ary
+ *
+ * Calls <i>block</i> once for each element in +self+, passing that element
+ * as parameter +asn1+. If no block is given, an enumerator is returned
+ * instead.
+ *
+ * == Example
+ * asn1_ary.each do |asn1|
+ * puts asn1
+ * end
+ */
+static VALUE
+ossl_asn1cons_each(VALUE self)
+{
+ rb_ary_each(ossl_asn1_get_value(self));
+ return self;
+}
+
+/*
+ * call-seq:
+ * ObjectId.register(object_id, short_name, long_name)
+ *
+ * This adds a new ObjectId to the internal tables. Where +object_id+ is the
+ * numerical form, +short_name+ is the short name, and +long_name+ is the long
+ * name.
+ *
+ * Returns +true+ if successful. Raises an ASN1Error otherwise.
+ *
+ */
+static VALUE
+ossl_asn1obj_s_register(VALUE self, VALUE oid, VALUE sn, VALUE ln)
+{
+ StringValue(oid);
+ StringValue(sn);
+ StringValue(ln);
+
+ if(!OBJ_create(RSTRING_PTR(oid), RSTRING_PTR(sn), RSTRING_PTR(ln)))
+ ossl_raise(eASN1Error, NULL);
+
+ return Qtrue;
+}
+
+/* Document-method: OpenSSL::ASN1::ObjectId#sn
+ *
+ * The short name of the ObjectId, as defined in +openssl/objects.h+.
+ */
+/* Document-method: OpenSSL::ASN1::ObjectId#short_name
+ *
+ * #short_name is an alias to #sn
+ */
+static VALUE
+ossl_asn1obj_get_sn(VALUE self)
+{
+ VALUE val, ret = Qnil;
+ int nid;
+
+ val = ossl_asn1_get_value(self);
+ if ((nid = OBJ_txt2nid(StringValuePtr(val))) != NID_undef)
+ ret = rb_str_new2(OBJ_nid2sn(nid));
+
+ return ret;
+}
+
+/* Document-method: OpenSSL::ASN1::ObjectId#ln
+ *
+ * The long name of the ObjectId, as defined in +openssl/objects.h+.
+ */
+/* Document-method: OpenSSL::ASN1::ObjectId.long_name
+ *
+ * #long_name is an alias to #ln
+ */
+static VALUE
+ossl_asn1obj_get_ln(VALUE self)
+{
+ VALUE val, ret = Qnil;
+ int nid;
+
+ val = ossl_asn1_get_value(self);
+ if ((nid = OBJ_txt2nid(StringValuePtr(val))) != NID_undef)
+ ret = rb_str_new2(OBJ_nid2ln(nid));
+
+ return ret;
+}
+
+/* Document-method: OpenSSL::ASN1::ObjectId#oid
+ *
+ * The object identifier as a String.
+ */
+static VALUE
+ossl_asn1obj_get_oid(VALUE self)
+{
+ VALUE val;
+ ASN1_OBJECT *a1obj;
+ char buf[128];
+
+ val = ossl_asn1_get_value(self);
+ a1obj = obj_to_asn1obj(val);
+ OBJ_obj2txt(buf, sizeof(buf), a1obj, 1);
+ ASN1_OBJECT_free(a1obj);
+
+ return rb_str_new2(buf);
+}
+
+#define OSSL_ASN1_IMPL_FACTORY_METHOD(klass) \
+static VALUE ossl_asn1_##klass(int argc, VALUE *argv, VALUE self)\
+{ return rb_funcall3(cASN1##klass, rb_intern("new"), argc, argv); }
+
+OSSL_ASN1_IMPL_FACTORY_METHOD(Boolean)
+OSSL_ASN1_IMPL_FACTORY_METHOD(Integer)
+OSSL_ASN1_IMPL_FACTORY_METHOD(Enumerated)
+OSSL_ASN1_IMPL_FACTORY_METHOD(BitString)
+OSSL_ASN1_IMPL_FACTORY_METHOD(OctetString)
+OSSL_ASN1_IMPL_FACTORY_METHOD(UTF8String)
+OSSL_ASN1_IMPL_FACTORY_METHOD(NumericString)
+OSSL_ASN1_IMPL_FACTORY_METHOD(PrintableString)
+OSSL_ASN1_IMPL_FACTORY_METHOD(T61String)
+OSSL_ASN1_IMPL_FACTORY_METHOD(VideotexString)
+OSSL_ASN1_IMPL_FACTORY_METHOD(IA5String)
+OSSL_ASN1_IMPL_FACTORY_METHOD(GraphicString)
+OSSL_ASN1_IMPL_FACTORY_METHOD(ISO64String)
+OSSL_ASN1_IMPL_FACTORY_METHOD(GeneralString)
+OSSL_ASN1_IMPL_FACTORY_METHOD(UniversalString)
+OSSL_ASN1_IMPL_FACTORY_METHOD(BMPString)
+OSSL_ASN1_IMPL_FACTORY_METHOD(Null)
+OSSL_ASN1_IMPL_FACTORY_METHOD(ObjectId)
+OSSL_ASN1_IMPL_FACTORY_METHOD(UTCTime)
+OSSL_ASN1_IMPL_FACTORY_METHOD(GeneralizedTime)
+OSSL_ASN1_IMPL_FACTORY_METHOD(Sequence)
+OSSL_ASN1_IMPL_FACTORY_METHOD(Set)
+OSSL_ASN1_IMPL_FACTORY_METHOD(EndOfContent)
+
+void
+Init_ossl_asn1(void)
+{
+ VALUE ary;
+ int i;
+
+#if 0
+ mOSSL = rb_define_module("OpenSSL"); /* let rdoc know about mOSSL */
+#endif
+
+ sUNIVERSAL = rb_intern("UNIVERSAL");
+ sCONTEXT_SPECIFIC = rb_intern("CONTEXT_SPECIFIC");
+ sAPPLICATION = rb_intern("APPLICATION");
+ sPRIVATE = rb_intern("PRIVATE");
+ sEXPLICIT = rb_intern("EXPLICIT");
+ sIMPLICIT = rb_intern("IMPLICIT");
+
+ sivVALUE = rb_intern("@value");
+ sivTAG = rb_intern("@tag");
+ sivTAGGING = rb_intern("@tagging");
+ sivTAG_CLASS = rb_intern("@tag_class");
+ sivINFINITE_LENGTH = rb_intern("@infinite_length");
+ sivUNUSED_BITS = rb_intern("@unused_bits");
+
+ /*
+ * Document-module: OpenSSL::ASN1
+ *
+ * Abstract Syntax Notation One (or ASN.1) is a notation syntax to
+ * describe data structures and is defined in ITU-T X.680. ASN.1 itself
+ * does not mandate any encoding or parsing rules, but usually ASN.1 data
+ * structures are encoded using the Distinguished Encoding Rules (DER) or
+ * less often the Basic Encoding Rules (BER) described in ITU-T X.690. DER
+ * and BER encodings are binary Tag-Length-Value (TLV) encodings that are
+ * quite concise compared to other popular data description formats such
+ * as XML, JSON etc.
+ * ASN.1 data structures are very common in cryptographic applications,
+ * e.g. X.509 public key certificates or certificate revocation lists
+ * (CRLs) are all defined in ASN.1 and DER-encoded. ASN.1, DER and BER are
+ * the building blocks of applied cryptography.
+ * The ASN1 module provides the necessary classes that allow generation
+ * of ASN.1 data structures and the methods to encode them using a DER
+ * encoding. The decode method allows parsing arbitrary BER-/DER-encoded
+ * data to a Ruby object that can then be modified and re-encoded at will.
+ *
+ * == ASN.1 class hierarchy
+ *
+ * The base class representing ASN.1 structures is ASN1Data. ASN1Data offers
+ * attributes to read and set the +tag+, the +tag_class+ and finally the
+ * +value+ of a particular ASN.1 item. Upon parsing, any tagged values
+ * (implicit or explicit) will be represented by ASN1Data instances because
+ * their "real type" can only be determined using out-of-band information
+ * from the ASN.1 type declaration. Since this information is normally
+ * known when encoding a type, all sub-classes of ASN1Data offer an
+ * additional attribute +tagging+ that allows to encode a value implicitly
+ * (+:IMPLICIT+) or explicitly (+:EXPLICIT+).
+ *
+ * === Constructive
+ *
+ * Constructive is, as its name implies, the base class for all
+ * constructed encodings, i.e. those that consist of several values,
+ * opposed to "primitive" encodings with just one single value.
+ * Primitive values that are encoded with "infinite length" are typically
+ * constructed (their values come in multiple chunks) and are therefore
+ * represented by instances of Constructive. The value of an Constructive
+ * is always an Array.
+ *
+ * ==== ASN1::Set and ASN1::Sequence
+ *
+ * The most common constructive encodings are SETs and SEQUENCEs, which is
+ * why there are two sub-classes of Constructive representing each of
+ * them.
+ *
+ * === Primitive
+ *
+ * This is the super class of all primitive values. Primitive
+ * itself is not used when parsing ASN.1 data, all values are either
+ * instances of a corresponding sub-class of Primitive or they are
+ * instances of ASN1Data if the value was tagged implicitly or explicitly.
+ * Please cf. Primitive documentation for details on sub-classes and
+ * their respective mappings of ASN.1 data types to Ruby objects.
+ *
+ * == Possible values for +tagging+
+ *
+ * When constructing an ASN1Data object the ASN.1 type definition may
+ * require certain elements to be either implicitly or explicitly tagged.
+ * This can be achieved by setting the +tagging+ attribute manually for
+ * sub-classes of ASN1Data. Use the symbol +:IMPLICIT+ for implicit
+ * tagging and +:EXPLICIT+ if the element requires explicit tagging.
+ *
+ * == Possible values for +tag_class+
+ *
+ * It is possible to create arbitrary ASN1Data objects that also support
+ * a PRIVATE or APPLICATION tag class. Possible values for the +tag_class+
+ * attribute are:
+ * * +:UNIVERSAL+ (the default for untagged values)
+ * * +:CONTEXT_SPECIFIC+ (the default for tagged values)
+ * * +:APPLICATION+
+ * * +:PRIVATE+
+ *
+ * == Tag constants
+ *
+ * There is a constant defined for each universal tag:
+ * * OpenSSL::ASN1::EOC (0)
+ * * OpenSSL::ASN1::BOOLEAN (1)
+ * * OpenSSL::ASN1::INTEGER (2)
+ * * OpenSSL::ASN1::BIT_STRING (3)
+ * * OpenSSL::ASN1::OCTET_STRING (4)
+ * * OpenSSL::ASN1::NULL (5)
+ * * OpenSSL::ASN1::OBJECT (6)
+ * * OpenSSL::ASN1::ENUMERATED (10)
+ * * OpenSSL::ASN1::UTF8STRING (12)
+ * * OpenSSL::ASN1::SEQUENCE (16)
+ * * OpenSSL::ASN1::SET (17)
+ * * OpenSSL::ASN1::NUMERICSTRING (18)
+ * * OpenSSL::ASN1::PRINTABLESTRING (19)
+ * * OpenSSL::ASN1::T61STRING (20)
+ * * OpenSSL::ASN1::VIDEOTEXSTRING (21)
+ * * OpenSSL::ASN1::IA5STRING (22)
+ * * OpenSSL::ASN1::UTCTIME (23)
+ * * OpenSSL::ASN1::GENERALIZEDTIME (24)
+ * * OpenSSL::ASN1::GRAPHICSTRING (25)
+ * * OpenSSL::ASN1::ISO64STRING (26)
+ * * OpenSSL::ASN1::GENERALSTRING (27)
+ * * OpenSSL::ASN1::UNIVERSALSTRING (28)
+ * * OpenSSL::ASN1::BMPSTRING (30)
+ *
+ * == UNIVERSAL_TAG_NAME constant
+ *
+ * An Array that stores the name of a given tag number. These names are
+ * the same as the name of the tag constant that is additionally defined,
+ * e.g. UNIVERSAL_TAG_NAME[2] = "INTEGER" and OpenSSL::ASN1::INTEGER = 2.
+ *
+ * == Example usage
+ *
+ * === Decoding and viewing a DER-encoded file
+ * require 'openssl'
+ * require 'pp'
+ * der = File.binread('data.der')
+ * asn1 = OpenSSL::ASN1.decode(der)
+ * pp der
+ *
+ * === Creating an ASN.1 structure and DER-encoding it
+ * require 'openssl'
+ * version = OpenSSL::ASN1::Integer.new(1)
+ * # Explicitly 0-tagged implies context-specific tag class
+ * serial = OpenSSL::ASN1::Integer.new(12345, 0, :EXPLICIT, :CONTEXT_SPECIFIC)
+ * name = OpenSSL::ASN1::PrintableString.new('Data 1')
+ * sequence = OpenSSL::ASN1::Sequence.new( [ version, serial, name ] )
+ * der = sequence.to_der
+ */
+ mASN1 = rb_define_module_under(mOSSL, "ASN1");
+
+ /* Document-class: OpenSSL::ASN1::ASN1Error
+ *
+ * Generic error class for all errors raised in ASN1 and any of the
+ * classes defined in it.
+ */
+ eASN1Error = rb_define_class_under(mASN1, "ASN1Error", eOSSLError);
+ rb_define_module_function(mASN1, "traverse", ossl_asn1_traverse, 1);
+ rb_define_module_function(mASN1, "decode", ossl_asn1_decode, 1);
+ rb_define_module_function(mASN1, "decode_all", ossl_asn1_decode_all, 1);
+ ary = rb_ary_new();
+
+ /*
+ * Array storing tag names at the tag's index.
+ */
+ rb_define_const(mASN1, "UNIVERSAL_TAG_NAME", ary);
+ for(i = 0; i < ossl_asn1_info_size; i++){
+ if(ossl_asn1_info[i].name[0] == '[') continue;
+ rb_define_const(mASN1, ossl_asn1_info[i].name, INT2NUM(i));
+ rb_ary_store(ary, i, rb_str_new2(ossl_asn1_info[i].name));
+ }
+
+ /* Document-class: OpenSSL::ASN1::ASN1Data
+ *
+ * The top-level class representing any ASN.1 object. When parsed by
+ * ASN1.decode, tagged values are always represented by an instance
+ * of ASN1Data.
+ *
+ * == The role of ASN1Data for parsing tagged values
+ *
+ * When encoding an ASN.1 type it is inherently clear what original
+ * type (e.g. INTEGER, OCTET STRING etc.) this value has, regardless
+ * of its tagging.
+ * But opposed to the time an ASN.1 type is to be encoded, when parsing
+ * them it is not possible to deduce the "real type" of tagged
+ * values. This is why tagged values are generally parsed into ASN1Data
+ * instances, but with a different outcome for implicit and explicit
+ * tagging.
+ *
+ * === Example of a parsed implicitly tagged value
+ *
+ * An implicitly 1-tagged INTEGER value will be parsed as an
+ * ASN1Data with
+ * * +tag+ equal to 1
+ * * +tag_class+ equal to +:CONTEXT_SPECIFIC+
+ * * +value+ equal to a +String+ that carries the raw encoding
+ * of the INTEGER.
+ * This implies that a subsequent decoding step is required to
+ * completely decode implicitly tagged values.
+ *
+ * === Example of a parsed explicitly tagged value
+ *
+ * An explicitly 1-tagged INTEGER value will be parsed as an
+ * ASN1Data with
+ * * +tag+ equal to 1
+ * * +tag_class+ equal to +:CONTEXT_SPECIFIC+
+ * * +value+ equal to an +Array+ with one single element, an
+ * instance of OpenSSL::ASN1::Integer, i.e. the inner element
+ * is the non-tagged primitive value, and the tagging is represented
+ * in the outer ASN1Data
+ *
+ * == Example - Decoding an implicitly tagged INTEGER
+ * int = OpenSSL::ASN1::Integer.new(1, 0, :IMPLICIT) # implicit 0-tagged
+ * seq = OpenSSL::ASN1::Sequence.new( [int] )
+ * der = seq.to_der
+ * asn1 = OpenSSL::ASN1.decode(der)
+ * # pp asn1 => #<OpenSSL::ASN1::Sequence:0x87326e0
+ * # @infinite_length=false,
+ * # @tag=16,
+ * # @tag_class=:UNIVERSAL,
+ * # @tagging=nil,
+ * # @value=
+ * # [#<OpenSSL::ASN1::ASN1Data:0x87326f4
+ * # @infinite_length=false,
+ * # @tag=0,
+ * # @tag_class=:CONTEXT_SPECIFIC,
+ * # @value="\x01">]>
+ * raw_int = asn1.value[0]
+ * # manually rewrite tag and tag class to make it an UNIVERSAL value
+ * raw_int.tag = OpenSSL::ASN1::INTEGER
+ * raw_int.tag_class = :UNIVERSAL
+ * int2 = OpenSSL::ASN1.decode(raw_int)
+ * puts int2.value # => 1
+ *
+ * == Example - Decoding an explicitly tagged INTEGER
+ * int = OpenSSL::ASN1::Integer.new(1, 0, :EXPLICIT) # explicit 0-tagged
+ * seq = OpenSSL::ASN1::Sequence.new( [int] )
+ * der = seq.to_der
+ * asn1 = OpenSSL::ASN1.decode(der)
+ * # pp asn1 => #<OpenSSL::ASN1::Sequence:0x87326e0
+ * # @infinite_length=false,
+ * # @tag=16,
+ * # @tag_class=:UNIVERSAL,
+ * # @tagging=nil,
+ * # @value=
+ * # [#<OpenSSL::ASN1::ASN1Data:0x87326f4
+ * # @infinite_length=false,
+ * # @tag=0,
+ * # @tag_class=:CONTEXT_SPECIFIC,
+ * # @value=
+ * # [#<OpenSSL::ASN1::Integer:0x85bf308
+ * # @infinite_length=false,
+ * # @tag=2,
+ * # @tag_class=:UNIVERSAL
+ * # @tagging=nil,
+ * # @value=1>]>]>
+ * int2 = asn1.value[0].value[0]
+ * puts int2.value # => 1
+ */
+ cASN1Data = rb_define_class_under(mASN1, "ASN1Data", rb_cObject);
+ /*
+ * Carries the value of a ASN.1 type.
+ * Please confer Constructive and Primitive for the mappings between
+ * ASN.1 data types and Ruby classes.
+ */
+ rb_attr(cASN1Data, rb_intern("value"), 1, 1, 0);
+ /*
+ * A +Number+ representing the tag number of this ASN1Data. Never +nil+.
+ */
+ rb_attr(cASN1Data, rb_intern("tag"), 1, 1, 0);
+ /*
+ * A +Symbol+ representing the tag class of this ASN1Data. Never +nil+.
+ * See ASN1Data for possible values.
+ */
+ rb_attr(cASN1Data, rb_intern("tag_class"), 1, 1, 0);
+ /*
+ * Never +nil+. A +Boolean+ indicating whether the encoding was infinite
+ * length (in the case of parsing) or whether an infinite length encoding
+ * shall be used (in the encoding case).
+ * In DER, every value has a finite length associated with it. But in
+ * scenarios where large amounts of data need to be transferred it
+ * might be desirable to have some kind of streaming support available.
+ * For example, huge OCTET STRINGs are preferably sent in smaller-sized
+ * chunks, each at a time.
+ * This is possible in BER by setting the length bytes of an encoding
+ * to zero and by this indicating that the following value will be
+ * sent in chunks. Infinite length encodings are always constructed.
+ * The end of such a stream of chunks is indicated by sending a EOC
+ * (End of Content) tag. SETs and SEQUENCEs may use an infinite length
+ * encoding, but also primitive types such as e.g. OCTET STRINGS or
+ * BIT STRINGS may leverage this functionality (cf. ITU-T X.690).
+ */
+ rb_attr(cASN1Data, rb_intern("infinite_length"), 1, 1, 0);
+ rb_define_method(cASN1Data, "initialize", ossl_asn1data_initialize, 3);
+ rb_define_method(cASN1Data, "to_der", ossl_asn1data_to_der, 0);
+
+ /* Document-class: OpenSSL::ASN1::Primitive
+ *
+ * The parent class for all primitive encodings. Attributes are the same as
+ * for ASN1Data, with the addition of +tagging+.
+ * Primitive values can never be infinite length encodings, thus it is not
+ * possible to set the +infinite_length+ attribute for Primitive and its
+ * sub-classes.
+ *
+ * == Primitive sub-classes and their mapping to Ruby classes
+ * * OpenSSL::ASN1::EndOfContent <=> +value+ is always +nil+
+ * * OpenSSL::ASN1::Boolean <=> +value+ is a +Boolean+
+ * * OpenSSL::ASN1::Integer <=> +value+ is a +Number+
+ * * OpenSSL::ASN1::BitString <=> +value+ is a +String+
+ * * OpenSSL::ASN1::OctetString <=> +value+ is a +String+
+ * * OpenSSL::ASN1::Null <=> +value+ is always +nil+
+ * * OpenSSL::ASN1::Object <=> +value+ is a +String+
+ * * OpenSSL::ASN1::Enumerated <=> +value+ is a +Number+
+ * * OpenSSL::ASN1::UTF8String <=> +value+ is a +String+
+ * * OpenSSL::ASN1::NumericString <=> +value+ is a +String+
+ * * OpenSSL::ASN1::PrintableString <=> +value+ is a +String+
+ * * OpenSSL::ASN1::T61String <=> +value+ is a +String+
+ * * OpenSSL::ASN1::VideotexString <=> +value+ is a +String+
+ * * OpenSSL::ASN1::IA5String <=> +value+ is a +String+
+ * * OpenSSL::ASN1::UTCTime <=> +value+ is a +Time+
+ * * OpenSSL::ASN1::GeneralizedTime <=> +value+ is a +Time+
+ * * OpenSSL::ASN1::GraphicString <=> +value+ is a +String+
+ * * OpenSSL::ASN1::ISO64String <=> +value+ is a +String+
+ * * OpenSSL::ASN1::GeneralString <=> +value+ is a +String+
+ * * OpenSSL::ASN1::UniversalString <=> +value+ is a +String+
+ * * OpenSSL::ASN1::BMPString <=> +value+ is a +String+
+ *
+ * == OpenSSL::ASN1::BitString
+ *
+ * === Additional attributes
+ * +unused_bits+: if the underlying BIT STRING's
+ * length is a multiple of 8 then +unused_bits+ is 0. Otherwise
+ * +unused_bits+ indicates the number of bits that are to be ignored in
+ * the final octet of the +BitString+'s +value+.
+ *
+ * == OpenSSL::ASN1::ObjectId
+ *
+ * While OpenSSL::ASN1::ObjectId.new will allocate a new ObjectId, it is
+ * not typically allocated this way, but rather that are received from
+ * parsed ASN1 encodings.
+ *
+ * === Additional attributes
+ * * +sn+: the short name as defined in <openssl/objects.h>.
+ * * +ln+: the long name as defined in <openssl/objects.h>.
+ * * +oid+: the object identifier as a +String+, e.g. "1.2.3.4.5"
+ * * +short_name+: alias for +sn+.
+ * * +long_name+: alias for +ln+.
+ *
+ * == Examples
+ * With the Exception of OpenSSL::ASN1::EndOfContent, each Primitive class
+ * constructor takes at least one parameter, the +value+.
+ *
+ * === Creating EndOfContent
+ * eoc = OpenSSL::ASN1::EndOfContent.new
+ *
+ * === Creating any other Primitive
+ * prim = <class>.new(value) # <class> being one of the sub-classes except EndOfContent
+ * prim_zero_tagged_implicit = <class>.new(value, 0, :IMPLICIT)
+ * prim_zero_tagged_explicit = <class>.new(value, 0, :EXPLICIT)
+ */
+ cASN1Primitive = rb_define_class_under(mASN1, "Primitive", cASN1Data);
+ /*
+ * May be used as a hint for encoding a value either implicitly or
+ * explicitly by setting it either to +:IMPLICIT+ or to +:EXPLICIT+.
+ * +tagging+ is not set when a ASN.1 structure is parsed using
+ * OpenSSL::ASN1.decode.
+ */
+ rb_attr(cASN1Primitive, rb_intern("tagging"), 1, 1, Qtrue);
+ rb_undef_method(cASN1Primitive, "infinite_length=");
+ rb_define_method(cASN1Primitive, "initialize", ossl_asn1_initialize, -1);
+ rb_define_method(cASN1Primitive, "to_der", ossl_asn1prim_to_der, 0);
+
+ /* Document-class: OpenSSL::ASN1::Constructive
+ *
+ * The parent class for all constructed encodings. The +value+ attribute
+ * of a Constructive is always an +Array+. Attributes are the same as
+ * for ASN1Data, with the addition of +tagging+.
+ *
+ * == SET and SEQUENCE
+ *
+ * Most constructed encodings come in the form of a SET or a SEQUENCE.
+ * These encodings are represented by one of the two sub-classes of
+ * Constructive:
+ * * OpenSSL::ASN1::Set
+ * * OpenSSL::ASN1::Sequence
+ * Please note that tagged sequences and sets are still parsed as
+ * instances of ASN1Data. Find further details on tagged values
+ * there.
+ *
+ * === Example - constructing a SEQUENCE
+ * int = OpenSSL::ASN1::Integer.new(1)
+ * str = OpenSSL::ASN1::PrintableString.new('abc')
+ * sequence = OpenSSL::ASN1::Sequence.new( [ int, str ] )
+ *
+ * === Example - constructing a SET
+ * int = OpenSSL::ASN1::Integer.new(1)
+ * str = OpenSSL::ASN1::PrintableString.new('abc')
+ * set = OpenSSL::ASN1::Set.new( [ int, str ] )
+ *
+ * == Infinite length primitive values
+ *
+ * The only case where Constructive is used directly is for infinite
+ * length encodings of primitive values. These encodings are always
+ * constructed, with the contents of the +value+ +Array+ being either
+ * UNIVERSAL non-infinite length partial encodings of the actual value
+ * or again constructive encodings with infinite length (i.e. infinite
+ * length primitive encodings may be constructed recursively with another
+ * infinite length value within an already infinite length value). Each
+ * partial encoding must be of the same UNIVERSAL type as the overall
+ * encoding. The value of the overall encoding consists of the
+ * concatenation of each partial encoding taken in sequence. The +value+
+ * array of the outer infinite length value must end with a
+ * OpenSSL::ASN1::EndOfContent instance.
+ *
+ * Please note that it is not possible to encode Constructive without
+ * the +infinite_length+ attribute being set to +true+, use
+ * OpenSSL::ASN1::Sequence or OpenSSL::ASN1::Set in these cases instead.
+ *
+ * === Example - Infinite length OCTET STRING
+ * partial1 = OpenSSL::ASN1::OctetString.new("\x01")
+ * partial2 = OpenSSL::ASN1::OctetString.new("\x02")
+ * inf_octets = OpenSSL::ASN1::Constructive.new( [ partial1,
+ * partial2,
+ * OpenSSL::ASN1::EndOfContent.new ],
+ * OpenSSL::ASN1::OCTET_STRING,
+ * nil,
+ * :UNIVERSAL )
+ * # The real value of inf_octets is "\x01\x02", i.e. the concatenation
+ * # of partial1 and partial2
+ * inf_octets.infinite_length = true
+ * der = inf_octets.to_der
+ * asn1 = OpenSSL::ASN1.decode(der)
+ * puts asn1.infinite_length # => true
+ */
+ cASN1Constructive = rb_define_class_under(mASN1,"Constructive", cASN1Data);
+ rb_include_module(cASN1Constructive, rb_mEnumerable);
+ /*
+ * May be used as a hint for encoding a value either implicitly or
+ * explicitly by setting it either to +:IMPLICIT+ or to +:EXPLICIT+.
+ * +tagging+ is not set when a ASN.1 structure is parsed using
+ * OpenSSL::ASN1.decode.
+ */
+ rb_attr(cASN1Constructive, rb_intern("tagging"), 1, 1, Qtrue);
+ rb_define_method(cASN1Constructive, "initialize", ossl_asn1_initialize, -1);
+ rb_define_method(cASN1Constructive, "to_der", ossl_asn1cons_to_der, 0);
+ rb_define_method(cASN1Constructive, "each", ossl_asn1cons_each, 0);
+
+#define OSSL_ASN1_DEFINE_CLASS(name, super) \
+do{\
+ cASN1##name = rb_define_class_under(mASN1, #name, cASN1##super);\
+ rb_define_module_function(mASN1, #name, ossl_asn1_##name, -1);\
+}while(0)
+
+ OSSL_ASN1_DEFINE_CLASS(Boolean, Primitive);
+ OSSL_ASN1_DEFINE_CLASS(Integer, Primitive);
+ OSSL_ASN1_DEFINE_CLASS(Enumerated, Primitive);
+ OSSL_ASN1_DEFINE_CLASS(BitString, Primitive);
+ OSSL_ASN1_DEFINE_CLASS(OctetString, Primitive);
+ OSSL_ASN1_DEFINE_CLASS(UTF8String, Primitive);
+ OSSL_ASN1_DEFINE_CLASS(NumericString, Primitive);
+ OSSL_ASN1_DEFINE_CLASS(PrintableString, Primitive);
+ OSSL_ASN1_DEFINE_CLASS(T61String, Primitive);
+ OSSL_ASN1_DEFINE_CLASS(VideotexString, Primitive);
+ OSSL_ASN1_DEFINE_CLASS(IA5String, Primitive);
+ OSSL_ASN1_DEFINE_CLASS(GraphicString, Primitive);
+ OSSL_ASN1_DEFINE_CLASS(ISO64String, Primitive);
+ OSSL_ASN1_DEFINE_CLASS(GeneralString, Primitive);
+ OSSL_ASN1_DEFINE_CLASS(UniversalString, Primitive);
+ OSSL_ASN1_DEFINE_CLASS(BMPString, Primitive);
+ OSSL_ASN1_DEFINE_CLASS(Null, Primitive);
+ OSSL_ASN1_DEFINE_CLASS(ObjectId, Primitive);
+ OSSL_ASN1_DEFINE_CLASS(UTCTime, Primitive);
+ OSSL_ASN1_DEFINE_CLASS(GeneralizedTime, Primitive);
+
+ OSSL_ASN1_DEFINE_CLASS(Sequence, Constructive);
+ OSSL_ASN1_DEFINE_CLASS(Set, Constructive);
+
+ OSSL_ASN1_DEFINE_CLASS(EndOfContent, Data);
+
+
+ /* Document-class: OpenSSL::ASN1::ObjectId
+ *
+ * Represents the primitive object id for OpenSSL::ASN1
+ */
+#if 0
+ cASN1ObjectId = rb_define_class_under(mASN1, "ObjectId", cASN1Primitive); /* let rdoc know */
+#endif
+ rb_define_singleton_method(cASN1ObjectId, "register", ossl_asn1obj_s_register, 3);
+ rb_define_method(cASN1ObjectId, "sn", ossl_asn1obj_get_sn, 0);
+ rb_define_method(cASN1ObjectId, "ln", ossl_asn1obj_get_ln, 0);
+ rb_define_method(cASN1ObjectId, "oid", ossl_asn1obj_get_oid, 0);
+ rb_define_alias(cASN1ObjectId, "short_name", "sn");
+ rb_define_alias(cASN1ObjectId, "long_name", "ln");
+ rb_attr(cASN1BitString, rb_intern("unused_bits"), 1, 1, 0);
+
+ rb_define_method(cASN1EndOfContent, "initialize", ossl_asn1eoc_initialize, 0);
+
+ class_tag_map = rb_hash_new();
+ rb_hash_aset(class_tag_map, cASN1EndOfContent, INT2NUM(V_ASN1_EOC));
+ rb_hash_aset(class_tag_map, cASN1Boolean, INT2NUM(V_ASN1_BOOLEAN));
+ rb_hash_aset(class_tag_map, cASN1Integer, INT2NUM(V_ASN1_INTEGER));
+ rb_hash_aset(class_tag_map, cASN1BitString, INT2NUM(V_ASN1_BIT_STRING));
+ rb_hash_aset(class_tag_map, cASN1OctetString, INT2NUM(V_ASN1_OCTET_STRING));
+ rb_hash_aset(class_tag_map, cASN1Null, INT2NUM(V_ASN1_NULL));
+ rb_hash_aset(class_tag_map, cASN1ObjectId, INT2NUM(V_ASN1_OBJECT));
+ rb_hash_aset(class_tag_map, cASN1Enumerated, INT2NUM(V_ASN1_ENUMERATED));
+ rb_hash_aset(class_tag_map, cASN1UTF8String, INT2NUM(V_ASN1_UTF8STRING));
+ rb_hash_aset(class_tag_map, cASN1Sequence, INT2NUM(V_ASN1_SEQUENCE));
+ rb_hash_aset(class_tag_map, cASN1Set, INT2NUM(V_ASN1_SET));
+ rb_hash_aset(class_tag_map, cASN1NumericString, INT2NUM(V_ASN1_NUMERICSTRING));
+ rb_hash_aset(class_tag_map, cASN1PrintableString, INT2NUM(V_ASN1_PRINTABLESTRING));
+ rb_hash_aset(class_tag_map, cASN1T61String, INT2NUM(V_ASN1_T61STRING));
+ rb_hash_aset(class_tag_map, cASN1VideotexString, INT2NUM(V_ASN1_VIDEOTEXSTRING));
+ rb_hash_aset(class_tag_map, cASN1IA5String, INT2NUM(V_ASN1_IA5STRING));
+ rb_hash_aset(class_tag_map, cASN1UTCTime, INT2NUM(V_ASN1_UTCTIME));
+ rb_hash_aset(class_tag_map, cASN1GeneralizedTime, INT2NUM(V_ASN1_GENERALIZEDTIME));
+ rb_hash_aset(class_tag_map, cASN1GraphicString, INT2NUM(V_ASN1_GRAPHICSTRING));
+ rb_hash_aset(class_tag_map, cASN1ISO64String, INT2NUM(V_ASN1_ISO64STRING));
+ rb_hash_aset(class_tag_map, cASN1GeneralString, INT2NUM(V_ASN1_GENERALSTRING));
+ rb_hash_aset(class_tag_map, cASN1UniversalString, INT2NUM(V_ASN1_UNIVERSALSTRING));
+ rb_hash_aset(class_tag_map, cASN1BMPString, INT2NUM(V_ASN1_BMPSTRING));
+ rb_global_variable(&class_tag_map);
+}
diff --git a/jni/ruby/ext/openssl/ossl_asn1.h b/jni/ruby/ext/openssl/ossl_asn1.h
new file mode 100644
index 0000000..187ef39
--- /dev/null
+++ b/jni/ruby/ext/openssl/ossl_asn1.h
@@ -0,0 +1,59 @@
+/*
+ * $Id: ossl_asn1.h 27437 2010-04-22 08:04:13Z nobu $
+ * 'OpenSSL for Ruby' team members
+ * Copyright (C) 2003
+ * All rights reserved.
+ */
+/*
+ * This program is licenced under the same licence as Ruby.
+ * (See the file 'LICENCE'.)
+ */
+#if !defined(_OSSL_ASN1_H_)
+#define _OSSL_ASN1_H_
+
+/*
+ * ASN1_DATE conversions
+ */
+VALUE asn1time_to_time(ASN1_TIME *);
+time_t time_to_time_t(VALUE);
+
+/*
+ * ASN1_STRING conversions
+ */
+VALUE asn1str_to_str(ASN1_STRING *);
+
+/*
+ * ASN1_INTEGER conversions
+ */
+VALUE asn1integer_to_num(ASN1_INTEGER *);
+ASN1_INTEGER *num_to_asn1integer(VALUE, ASN1_INTEGER *);
+
+/*
+ * ASN1 module
+ */
+extern VALUE mASN1;
+extern VALUE eASN1Error;
+
+extern VALUE cASN1Data;
+extern VALUE cASN1Primitive;
+extern VALUE cASN1Constructive;
+
+extern VALUE cASN1Boolean; /* BOOLEAN */
+extern VALUE cASN1Integer, cASN1Enumerated; /* INTEGER */
+extern VALUE cASN1BitString; /* BIT STRING */
+extern VALUE cASN1OctetString, cASN1UTF8String; /* STRINGs */
+extern VALUE cASN1NumericString, cASN1PrintableString;
+extern VALUE cASN1T61String, cASN1VideotexString;
+extern VALUE cASN1IA5String, cASN1GraphicString;
+extern VALUE cASN1ISO64String, cASN1GeneralString;
+extern VALUE cASN1UniversalString, cASN1BMPString;
+extern VALUE cASN1Null; /* NULL */
+extern VALUE cASN1ObjectId; /* OBJECT IDENTIFIER */
+extern VALUE cASN1UTCTime, cASN1GeneralizedTime; /* TIME */
+extern VALUE cASN1Sequence, cASN1Set; /* CONSTRUCTIVE */
+
+ASN1_TYPE *ossl_asn1_get_asn1type(VALUE);
+
+void Init_ossl_asn1(void);
+
+#endif
diff --git a/jni/ruby/ext/openssl/ossl_bio.c b/jni/ruby/ext/openssl/ossl_bio.c
new file mode 100644
index 0000000..c082b98
--- /dev/null
+++ b/jni/ruby/ext/openssl/ossl_bio.c
@@ -0,0 +1,87 @@
+/*
+ * $Id: ossl_bio.c 47042 2014-08-03 01:56:01Z nobu $
+ * 'OpenSSL for Ruby' team members
+ * Copyright (C) 2003
+ * All rights reserved.
+ */
+/*
+ * This program is licenced under the same licence as Ruby.
+ * (See the file 'LICENCE'.)
+ */
+#include "ossl.h"
+#ifdef HAVE_UNISTD_H
+#include <unistd.h>
+#endif
+
+BIO *
+ossl_obj2bio(VALUE obj)
+{
+ BIO *bio;
+
+ if (RB_TYPE_P(obj, T_FILE)) {
+ rb_io_t *fptr;
+ FILE *fp;
+ int fd;
+
+ GetOpenFile(obj, fptr);
+ rb_io_check_readable(fptr);
+ if ((fd = rb_cloexec_dup(FPTR_TO_FD(fptr))) < 0){
+ rb_sys_fail(0);
+ }
+ rb_update_max_fd(fd);
+ if (!(fp = fdopen(fd, "r"))){
+ close(fd);
+ rb_sys_fail(0);
+ }
+ if (!(bio = BIO_new_fp(fp, BIO_CLOSE))){
+ fclose(fp);
+ ossl_raise(eOSSLError, NULL);
+ }
+ }
+ else {
+ StringValue(obj);
+ bio = BIO_new_mem_buf(RSTRING_PTR(obj), RSTRING_LENINT(obj));
+ if (!bio) ossl_raise(eOSSLError, NULL);
+ }
+
+ return bio;
+}
+
+BIO *
+ossl_protect_obj2bio(VALUE obj, int *status)
+{
+ BIO *ret = NULL;
+ ret = (BIO*)rb_protect((VALUE(*)_((VALUE)))ossl_obj2bio, obj, status);
+ return ret;
+}
+
+VALUE
+ossl_membio2str0(BIO *bio)
+{
+ VALUE ret;
+ BUF_MEM *buf;
+
+ BIO_get_mem_ptr(bio, &buf);
+ ret = rb_str_new(buf->data, buf->length);
+
+ return ret;
+}
+
+VALUE
+ossl_protect_membio2str(BIO *bio, int *status)
+{
+ return rb_protect((VALUE(*)_((VALUE)))ossl_membio2str0, (VALUE)bio, status);
+}
+
+VALUE
+ossl_membio2str(BIO *bio)
+{
+ VALUE ret;
+ int status = 0;
+
+ ret = ossl_protect_membio2str(bio, &status);
+ BIO_free(bio);
+ if(status) rb_jump_tag(status);
+
+ return ret;
+}
diff --git a/jni/ruby/ext/openssl/ossl_bio.h b/jni/ruby/ext/openssl/ossl_bio.h
new file mode 100644
index 0000000..a6a3e24
--- /dev/null
+++ b/jni/ruby/ext/openssl/ossl_bio.h
@@ -0,0 +1,21 @@
+/*
+ * $Id: ossl_bio.h 25189 2009-10-02 12:04:37Z akr $
+ * 'OpenSSL for Ruby' team members
+ * Copyright (C) 2003
+ * All rights reserved.
+ */
+/*
+ * This program is licenced under the same licence as Ruby.
+ * (See the file 'LICENCE'.)
+ */
+#if !defined(_OSSL_BIO_H_)
+#define _OSSL_BIO_H_
+
+BIO *ossl_obj2bio(VALUE);
+BIO *ossl_protect_obj2bio(VALUE,int*);
+VALUE ossl_membio2str0(BIO*);
+VALUE ossl_membio2str(BIO*);
+VALUE ossl_protect_membio2str(BIO*,int*);
+
+#endif
+
diff --git a/jni/ruby/ext/openssl/ossl_bn.c b/jni/ruby/ext/openssl/ossl_bn.c
new file mode 100644
index 0000000..e46266d
--- /dev/null
+++ b/jni/ruby/ext/openssl/ossl_bn.c
@@ -0,0 +1,915 @@
+/*
+ * $Id: ossl_bn.c 48662 2014-12-01 06:38:04Z nobu $
+ * 'OpenSSL for Ruby' project
+ * Copyright (C) 2001-2002 Technorama team <oss-ruby@technorama.net>
+ * All rights reserved.
+ */
+/*
+ * This program is licenced under the same licence as Ruby.
+ * (See the file 'LICENCE'.)
+ */
+/* modified by Michal Rokos <m.rokos@sh.cvut.cz> */
+#include "ossl.h"
+
+#define WrapBN(klass, obj, bn) do { \
+ if (!(bn)) { \
+ ossl_raise(rb_eRuntimeError, "BN wasn't initialized!"); \
+ } \
+ (obj) = TypedData_Wrap_Struct((klass), &ossl_bn_type, (bn)); \
+} while (0)
+
+#define GetBN(obj, bn) do { \
+ TypedData_Get_Struct((obj), BIGNUM, &ossl_bn_type, (bn)); \
+ if (!(bn)) { \
+ ossl_raise(rb_eRuntimeError, "BN wasn't initialized!"); \
+ } \
+} while (0)
+
+#define SafeGetBN(obj, bn) do { \
+ OSSL_Check_Kind((obj), cBN); \
+ GetBN((obj), (bn)); \
+} while (0)
+
+static void
+ossl_bn_free(void *ptr)
+{
+ BN_clear_free(ptr);
+}
+
+static size_t
+ossl_bn_size(const void *ptr)
+{
+ return sizeof(BIGNUM);
+}
+
+static const rb_data_type_t ossl_bn_type = {
+ "OpenSSL/BN",
+ {0, ossl_bn_free, ossl_bn_size,},
+ 0, 0,
+ RUBY_TYPED_FREE_IMMEDIATELY,
+};
+
+/*
+ * Classes
+ */
+VALUE cBN;
+VALUE eBNError;
+
+/*
+ * Public
+ */
+VALUE
+ossl_bn_new(const BIGNUM *bn)
+{
+ BIGNUM *newbn;
+ VALUE obj;
+
+ newbn = bn ? BN_dup(bn) : BN_new();
+ if (!newbn) {
+ ossl_raise(eBNError, NULL);
+ }
+ WrapBN(cBN, obj, newbn);
+
+ return obj;
+}
+
+BIGNUM *
+GetBNPtr(VALUE obj)
+{
+ BIGNUM *bn = NULL;
+
+ if (RTEST(rb_obj_is_kind_of(obj, cBN))) {
+ GetBN(obj, bn);
+ } else switch (TYPE(obj)) {
+ case T_FIXNUM:
+ case T_BIGNUM:
+ obj = rb_String(obj);
+ if (!BN_dec2bn(&bn, StringValuePtr(obj))) {
+ ossl_raise(eBNError, NULL);
+ }
+ WrapBN(cBN, obj, bn); /* Handle potencial mem leaks */
+ break;
+ case T_NIL:
+ break;
+ default:
+ ossl_raise(rb_eTypeError, "Cannot convert into OpenSSL::BN");
+ }
+ return bn;
+}
+
+/*
+ * Private
+ */
+/*
+ * BN_CTX - is used in more difficult math. ops
+ * (Why just 1? Because Ruby itself isn't thread safe,
+ * we don't need to care about threads)
+ */
+BN_CTX *ossl_bn_ctx;
+
+static VALUE
+ossl_bn_alloc(VALUE klass)
+{
+ BIGNUM *bn;
+ VALUE obj;
+
+ if (!(bn = BN_new())) {
+ ossl_raise(eBNError, NULL);
+ }
+ WrapBN(klass, obj, bn);
+
+ return obj;
+}
+
+/*
+ * call-seq:
+ * BN.new => aBN
+ * BN.new(bn) => aBN
+ * BN.new(integer) => aBN
+ * BN.new(string) => aBN
+ * BN.new(string, 0 | 2 | 10 | 16) => aBN
+ */
+static VALUE
+ossl_bn_initialize(int argc, VALUE *argv, VALUE self)
+{
+ BIGNUM *bn;
+ VALUE str, bs;
+ int base = 10;
+
+ if (rb_scan_args(argc, argv, "11", &str, &bs) == 2) {
+ base = NUM2INT(bs);
+ }
+
+ if (RB_TYPE_P(str, T_FIXNUM)) {
+ long i;
+ unsigned char bin[sizeof(long)];
+ long n = FIX2LONG(str);
+ unsigned long un = labs(n);
+
+ for (i = sizeof(long) - 1; 0 <= i; i--) {
+ bin[i] = un&0xff;
+ un >>= 8;
+ }
+
+ GetBN(self, bn);
+ if (!BN_bin2bn(bin, sizeof(bin), bn)) {
+ ossl_raise(eBNError, NULL);
+ }
+ if (n < 0) BN_set_negative(bn, 1);
+ return self;
+ }
+ else if (RB_TYPE_P(str, T_BIGNUM)) {
+ size_t len = rb_absint_size(str, NULL);
+ unsigned char *bin;
+ VALUE buf;
+ int sign;
+
+ if (INT_MAX < len) {
+ rb_raise(eBNError, "bignum too long");
+ }
+ bin = (unsigned char*)ALLOCV_N(unsigned char, buf, len);
+ sign = rb_integer_pack(str, bin, len, 1, 0, INTEGER_PACK_BIG_ENDIAN);
+
+ GetBN(self, bn);
+ if (!BN_bin2bn(bin, (int)len, bn)) {
+ ALLOCV_END(buf);
+ ossl_raise(eBNError, NULL);
+ }
+ ALLOCV_END(buf);
+ if (sign < 0) BN_set_negative(bn, 1);
+ return self;
+ }
+ if (RTEST(rb_obj_is_kind_of(str, cBN))) {
+ BIGNUM *other;
+
+ GetBN(self, bn);
+ GetBN(str, other); /* Safe - we checked kind_of? above */
+ if (!BN_copy(bn, other)) {
+ ossl_raise(eBNError, NULL);
+ }
+ return self;
+ }
+
+ StringValue(str);
+ GetBN(self, bn);
+ switch (base) {
+ case 0:
+ if (!BN_mpi2bn((unsigned char *)RSTRING_PTR(str), RSTRING_LENINT(str), bn)) {
+ ossl_raise(eBNError, NULL);
+ }
+ break;
+ case 2:
+ if (!BN_bin2bn((unsigned char *)RSTRING_PTR(str), RSTRING_LENINT(str), bn)) {
+ ossl_raise(eBNError, NULL);
+ }
+ break;
+ case 10:
+ if (!BN_dec2bn(&bn, RSTRING_PTR(str))) {
+ ossl_raise(eBNError, NULL);
+ }
+ break;
+ case 16:
+ if (!BN_hex2bn(&bn, RSTRING_PTR(str))) {
+ ossl_raise(eBNError, NULL);
+ }
+ break;
+ default:
+ ossl_raise(rb_eArgError, "invalid radix %d", base);
+ }
+ return self;
+}
+
+/*
+ * call-seq:
+ * bn.to_s => string
+ * bn.to_s(base) => string
+ *
+ * === Parameters
+ * * +base+ - integer
+ * * * Valid values:
+ * * * * 0 - MPI
+ * * * * 2 - binary
+ * * * * 10 - the default
+ * * * * 16 - hex
+ */
+static VALUE
+ossl_bn_to_s(int argc, VALUE *argv, VALUE self)
+{
+ BIGNUM *bn;
+ VALUE str, bs;
+ int base = 10, len;
+ char *buf;
+
+ if (rb_scan_args(argc, argv, "01", &bs) == 1) {
+ base = NUM2INT(bs);
+ }
+ GetBN(self, bn);
+ switch (base) {
+ case 0:
+ len = BN_bn2mpi(bn, NULL);
+ str = rb_str_new(0, len);
+ if (BN_bn2mpi(bn, (unsigned char *)RSTRING_PTR(str)) != len)
+ ossl_raise(eBNError, NULL);
+ break;
+ case 2:
+ len = BN_num_bytes(bn);
+ str = rb_str_new(0, len);
+ if (BN_bn2bin(bn, (unsigned char *)RSTRING_PTR(str)) != len)
+ ossl_raise(eBNError, NULL);
+ break;
+ case 10:
+ if (!(buf = BN_bn2dec(bn))) ossl_raise(eBNError, NULL);
+ str = ossl_buf2str(buf, rb_long2int(strlen(buf)));
+ break;
+ case 16:
+ if (!(buf = BN_bn2hex(bn))) ossl_raise(eBNError, NULL);
+ str = ossl_buf2str(buf, rb_long2int(strlen(buf)));
+ break;
+ default:
+ ossl_raise(rb_eArgError, "invalid radix %d", base);
+ }
+
+ return str;
+}
+
+/*
+ * call-seq:
+ * bn.to_i => integer
+ */
+static VALUE
+ossl_bn_to_i(VALUE self)
+{
+ BIGNUM *bn;
+ char *txt;
+ VALUE num;
+
+ GetBN(self, bn);
+
+ if (!(txt = BN_bn2hex(bn))) {
+ ossl_raise(eBNError, NULL);
+ }
+ num = rb_cstr_to_inum(txt, 16, Qtrue);
+ OPENSSL_free(txt);
+
+ return num;
+}
+
+static VALUE
+ossl_bn_to_bn(VALUE self)
+{
+ return self;
+}
+
+static VALUE
+ossl_bn_coerce(VALUE self, VALUE other)
+{
+ switch(TYPE(other)) {
+ case T_STRING:
+ self = ossl_bn_to_s(0, NULL, self);
+ break;
+ case T_FIXNUM:
+ case T_BIGNUM:
+ self = ossl_bn_to_i(self);
+ break;
+ default:
+ if (!RTEST(rb_obj_is_kind_of(other, cBN))) {
+ ossl_raise(rb_eTypeError, "Don't know how to coerce");
+ }
+ }
+ return rb_assoc_new(other, self);
+}
+
+#define BIGNUM_BOOL1(func) \
+ /* \
+ * call-seq: \
+ * bn.##func -> true | false \
+ * \
+ */ \
+ static VALUE \
+ ossl_bn_##func(VALUE self) \
+ { \
+ BIGNUM *bn; \
+ GetBN(self, bn); \
+ if (BN_##func(bn)) { \
+ return Qtrue; \
+ } \
+ return Qfalse; \
+ }
+BIGNUM_BOOL1(is_zero)
+BIGNUM_BOOL1(is_one)
+BIGNUM_BOOL1(is_odd)
+
+#define BIGNUM_1c(func) \
+ /* \
+ * call-seq: \
+ * bn.##func -> aBN \
+ * \
+ */ \
+ static VALUE \
+ ossl_bn_##func(VALUE self) \
+ { \
+ BIGNUM *bn, *result; \
+ VALUE obj; \
+ GetBN(self, bn); \
+ if (!(result = BN_new())) { \
+ ossl_raise(eBNError, NULL); \
+ } \
+ if (!BN_##func(result, bn, ossl_bn_ctx)) { \
+ BN_free(result); \
+ ossl_raise(eBNError, NULL); \
+ } \
+ WrapBN(CLASS_OF(self), obj, result); \
+ return obj; \
+ }
+BIGNUM_1c(sqr)
+
+#define BIGNUM_2(func) \
+ /* \
+ * call-seq: \
+ * bn.##func(bn2) -> aBN \
+ * \
+ */ \
+ static VALUE \
+ ossl_bn_##func(VALUE self, VALUE other) \
+ { \
+ BIGNUM *bn1, *bn2 = GetBNPtr(other), *result; \
+ VALUE obj; \
+ GetBN(self, bn1); \
+ if (!(result = BN_new())) { \
+ ossl_raise(eBNError, NULL); \
+ } \
+ if (!BN_##func(result, bn1, bn2)) { \
+ BN_free(result); \
+ ossl_raise(eBNError, NULL); \
+ } \
+ WrapBN(CLASS_OF(self), obj, result); \
+ return obj; \
+ }
+BIGNUM_2(add)
+BIGNUM_2(sub)
+
+#define BIGNUM_2c(func) \
+ /* \
+ * call-seq: \
+ * bn.##func(bn2) -> aBN \
+ * \
+ */ \
+ static VALUE \
+ ossl_bn_##func(VALUE self, VALUE other) \
+ { \
+ BIGNUM *bn1, *bn2 = GetBNPtr(other), *result; \
+ VALUE obj; \
+ GetBN(self, bn1); \
+ if (!(result = BN_new())) { \
+ ossl_raise(eBNError, NULL); \
+ } \
+ if (!BN_##func(result, bn1, bn2, ossl_bn_ctx)) { \
+ BN_free(result); \
+ ossl_raise(eBNError, NULL); \
+ } \
+ WrapBN(CLASS_OF(self), obj, result); \
+ return obj; \
+ }
+BIGNUM_2c(mul)
+BIGNUM_2c(mod)
+BIGNUM_2c(exp)
+BIGNUM_2c(gcd)
+BIGNUM_2c(mod_sqr)
+BIGNUM_2c(mod_inverse)
+
+/*
+ * call-seq:
+ * bn1 / bn2 => [result, remainder]
+ */
+static VALUE
+ossl_bn_div(VALUE self, VALUE other)
+{
+ BIGNUM *bn1, *bn2 = GetBNPtr(other), *r1, *r2;
+ VALUE obj1, obj2;
+
+ GetBN(self, bn1);
+
+ if (!(r1 = BN_new())) {
+ ossl_raise(eBNError, NULL);
+ }
+ if (!(r2 = BN_new())) {
+ BN_free(r1);
+ ossl_raise(eBNError, NULL);
+ }
+ if (!BN_div(r1, r2, bn1, bn2, ossl_bn_ctx)) {
+ BN_free(r1);
+ BN_free(r2);
+ ossl_raise(eBNError, NULL);
+ }
+ WrapBN(CLASS_OF(self), obj1, r1);
+ WrapBN(CLASS_OF(self), obj2, r2);
+
+ return rb_ary_new3(2, obj1, obj2);
+}
+
+#define BIGNUM_3c(func) \
+ /* \
+ * call-seq: \
+ * bn.##func(bn1, bn2) -> aBN \
+ * \
+ */ \
+ static VALUE \
+ ossl_bn_##func(VALUE self, VALUE other1, VALUE other2) \
+ { \
+ BIGNUM *bn1, *bn2 = GetBNPtr(other1); \
+ BIGNUM *bn3 = GetBNPtr(other2), *result; \
+ VALUE obj; \
+ GetBN(self, bn1); \
+ if (!(result = BN_new())) { \
+ ossl_raise(eBNError, NULL); \
+ } \
+ if (!BN_##func(result, bn1, bn2, bn3, ossl_bn_ctx)) { \
+ BN_free(result); \
+ ossl_raise(eBNError, NULL); \
+ } \
+ WrapBN(CLASS_OF(self), obj, result); \
+ return obj; \
+ }
+BIGNUM_3c(mod_add)
+BIGNUM_3c(mod_sub)
+BIGNUM_3c(mod_mul)
+BIGNUM_3c(mod_exp)
+
+#define BIGNUM_BIT(func) \
+ /* \
+ * call-seq: \
+ * bn.##func(bit) -> self \
+ * \
+ */ \
+ static VALUE \
+ ossl_bn_##func(VALUE self, VALUE bit) \
+ { \
+ BIGNUM *bn; \
+ GetBN(self, bn); \
+ if (!BN_##func(bn, NUM2INT(bit))) { \
+ ossl_raise(eBNError, NULL); \
+ } \
+ return self; \
+ }
+BIGNUM_BIT(set_bit)
+BIGNUM_BIT(clear_bit)
+BIGNUM_BIT(mask_bits)
+
+/*
+ * call-seq:
+ * bn.bit_set?(bit) => true | false
+ */
+static VALUE
+ossl_bn_is_bit_set(VALUE self, VALUE bit)
+{
+ int b;
+ BIGNUM *bn;
+
+ b = NUM2INT(bit);
+ GetBN(self, bn);
+ if (BN_is_bit_set(bn, b)) {
+ return Qtrue;
+ }
+ return Qfalse;
+}
+
+#define BIGNUM_SHIFT(func) \
+ /* \
+ * call-seq: \
+ * bn.##func(bits) -> aBN \
+ * \
+ */ \
+ static VALUE \
+ ossl_bn_##func(VALUE self, VALUE bits) \
+ { \
+ BIGNUM *bn, *result; \
+ int b; \
+ VALUE obj; \
+ b = NUM2INT(bits); \
+ GetBN(self, bn); \
+ if (!(result = BN_new())) { \
+ ossl_raise(eBNError, NULL); \
+ } \
+ if (!BN_##func(result, bn, b)) { \
+ BN_free(result); \
+ ossl_raise(eBNError, NULL); \
+ } \
+ WrapBN(CLASS_OF(self), obj, result); \
+ return obj; \
+ }
+BIGNUM_SHIFT(lshift)
+BIGNUM_SHIFT(rshift)
+
+#define BIGNUM_SELF_SHIFT(func) \
+ /* \
+ * call-seq: \
+ * bn.##func!(bits) -> self \
+ * \
+ */ \
+ static VALUE \
+ ossl_bn_self_##func(VALUE self, VALUE bits) \
+ { \
+ BIGNUM *bn; \
+ int b; \
+ b = NUM2INT(bits); \
+ GetBN(self, bn); \
+ if (!BN_##func(bn, bn, b)) \
+ ossl_raise(eBNError, NULL); \
+ return self; \
+ }
+BIGNUM_SELF_SHIFT(lshift)
+BIGNUM_SELF_SHIFT(rshift)
+
+#define BIGNUM_RAND(func) \
+ /* \
+ * call-seq: \
+ * BN.##func(bits [, fill [, odd]]) -> aBN \
+ * \
+ */ \
+ static VALUE \
+ ossl_bn_s_##func(int argc, VALUE *argv, VALUE klass) \
+ { \
+ BIGNUM *result; \
+ int bottom = 0, top = 0, b; \
+ VALUE bits, fill, odd, obj; \
+ \
+ switch (rb_scan_args(argc, argv, "12", &bits, &fill, &odd)) { \
+ case 3: \
+ bottom = (odd == Qtrue) ? 1 : 0; \
+ /* FALLTHROUGH */ \
+ case 2: \
+ top = NUM2INT(fill); \
+ } \
+ b = NUM2INT(bits); \
+ if (!(result = BN_new())) { \
+ ossl_raise(eBNError, NULL); \
+ } \
+ if (!BN_##func(result, b, top, bottom)) { \
+ BN_free(result); \
+ ossl_raise(eBNError, NULL); \
+ } \
+ WrapBN(klass, obj, result); \
+ return obj; \
+ }
+BIGNUM_RAND(rand)
+BIGNUM_RAND(pseudo_rand)
+
+#define BIGNUM_RAND_RANGE(func) \
+ /* \
+ * call-seq: \
+ * BN.##func(range) -> aBN \
+ * \
+ */ \
+ static VALUE \
+ ossl_bn_s_##func##_range(VALUE klass, VALUE range) \
+ { \
+ BIGNUM *bn = GetBNPtr(range), *result; \
+ VALUE obj; \
+ if (!(result = BN_new())) { \
+ ossl_raise(eBNError, NULL); \
+ } \
+ if (!BN_##func##_range(result, bn)) { \
+ BN_free(result); \
+ ossl_raise(eBNError, NULL); \
+ } \
+ WrapBN(klass, obj, result); \
+ return obj; \
+ }
+BIGNUM_RAND_RANGE(rand)
+BIGNUM_RAND_RANGE(pseudo_rand)
+
+/*
+ * call-seq:
+ * BN.generate_prime(bits, [, safe [, add [, rem]]]) => bn
+ *
+ * === Parameters
+ * * +bits+ - integer
+ * * +safe+ - boolean
+ * * +add+ - BN
+ * * +rem+ - BN
+ */
+static VALUE
+ossl_bn_s_generate_prime(int argc, VALUE *argv, VALUE klass)
+{
+ BIGNUM *add = NULL, *rem = NULL, *result;
+ int safe = 1, num;
+ VALUE vnum, vsafe, vadd, vrem, obj;
+
+ rb_scan_args(argc, argv, "13", &vnum, &vsafe, &vadd, &vrem);
+
+ num = NUM2INT(vnum);
+
+ if (vsafe == Qfalse) {
+ safe = 0;
+ }
+ if (!NIL_P(vadd)) {
+ add = GetBNPtr(vadd);
+ rem = NIL_P(vrem) ? NULL : GetBNPtr(vrem);
+ }
+ if (!(result = BN_new())) {
+ ossl_raise(eBNError, NULL);
+ }
+ if (!BN_generate_prime(result, num, safe, add, rem, NULL, NULL)) {
+ BN_free(result);
+ ossl_raise(eBNError, NULL);
+ }
+ WrapBN(klass, obj, result);
+
+ return obj;
+}
+
+#define BIGNUM_NUM(func) \
+ /* \
+ * call-seq: \
+ * bn.##func -> integer \
+ * \
+ */ \
+ static VALUE \
+ ossl_bn_##func(VALUE self) \
+ { \
+ BIGNUM *bn; \
+ GetBN(self, bn); \
+ return INT2FIX(BN_##func(bn)); \
+ }
+BIGNUM_NUM(num_bytes)
+BIGNUM_NUM(num_bits)
+
+static VALUE
+ossl_bn_copy(VALUE self, VALUE other)
+{
+ BIGNUM *bn1, *bn2;
+
+ rb_check_frozen(self);
+
+ if (self == other) return self;
+
+ GetBN(self, bn1);
+ bn2 = GetBNPtr(other);
+
+ if (!BN_copy(bn1, bn2)) {
+ ossl_raise(eBNError, NULL);
+ }
+ return self;
+}
+
+#define BIGNUM_CMP(func) \
+ /* \
+ * call-seq: \
+ * bn.##func(bn2) -> integer \
+ * \
+ */ \
+ static VALUE \
+ ossl_bn_##func(VALUE self, VALUE other) \
+ { \
+ BIGNUM *bn1, *bn2 = GetBNPtr(other); \
+ GetBN(self, bn1); \
+ return INT2FIX(BN_##func(bn1, bn2)); \
+ }
+BIGNUM_CMP(cmp)
+BIGNUM_CMP(ucmp)
+
+static VALUE
+ossl_bn_eql(VALUE self, VALUE other)
+{
+ if (ossl_bn_cmp(self, other) == INT2FIX(0)) {
+ return Qtrue;
+ }
+ return Qfalse;
+}
+
+/*
+ * call-seq:
+ * bn.prime? => true | false
+ * bn.prime?(checks) => true | false
+ *
+ * === Parameters
+ * * +checks+ - integer
+ */
+static VALUE
+ossl_bn_is_prime(int argc, VALUE *argv, VALUE self)
+{
+ BIGNUM *bn;
+ VALUE vchecks;
+ int checks = BN_prime_checks;
+
+ if (rb_scan_args(argc, argv, "01", &vchecks) == 1) {
+ checks = NUM2INT(vchecks);
+ }
+ GetBN(self, bn);
+ switch (BN_is_prime(bn, checks, NULL, ossl_bn_ctx, NULL)) {
+ case 1:
+ return Qtrue;
+ case 0:
+ return Qfalse;
+ default:
+ ossl_raise(eBNError, NULL);
+ }
+ /* not reachable */
+ return Qnil;
+}
+
+/*
+ * call-seq:
+ * bn.prime_fasttest? => true | false
+ * bn.prime_fasttest?(checks) => true | false
+ * bn.prime_fasttest?(checks, trial_div) => true | false
+ *
+ * === Parameters
+ * * +checks+ - integer
+ * * +trial_div+ - boolean
+ */
+static VALUE
+ossl_bn_is_prime_fasttest(int argc, VALUE *argv, VALUE self)
+{
+ BIGNUM *bn;
+ VALUE vchecks, vtrivdiv;
+ int checks = BN_prime_checks, do_trial_division = 1;
+
+ rb_scan_args(argc, argv, "02", &vchecks, &vtrivdiv);
+
+ if (!NIL_P(vchecks)) {
+ checks = NUM2INT(vchecks);
+ }
+ GetBN(self, bn);
+ /* handle true/false */
+ if (vtrivdiv == Qfalse) {
+ do_trial_division = 0;
+ }
+ switch (BN_is_prime_fasttest(bn, checks, NULL, ossl_bn_ctx, NULL, do_trial_division)) {
+ case 1:
+ return Qtrue;
+ case 0:
+ return Qfalse;
+ default:
+ ossl_raise(eBNError, NULL);
+ }
+ /* not reachable */
+ return Qnil;
+}
+
+/*
+ * INIT
+ * (NOTE: ordering of methods is the same as in 'man bn')
+ */
+void
+Init_ossl_bn(void)
+{
+#if 0
+ mOSSL = rb_define_module("OpenSSL"); /* let rdoc know about mOSSL */
+#endif
+
+ if (!(ossl_bn_ctx = BN_CTX_new())) {
+ ossl_raise(rb_eRuntimeError, "Cannot init BN_CTX");
+ }
+
+ eBNError = rb_define_class_under(mOSSL, "BNError", eOSSLError);
+
+ cBN = rb_define_class_under(mOSSL, "BN", rb_cObject);
+
+ rb_define_alloc_func(cBN, ossl_bn_alloc);
+ rb_define_method(cBN, "initialize", ossl_bn_initialize, -1);
+
+ rb_define_copy_func(cBN, ossl_bn_copy);
+ rb_define_method(cBN, "copy", ossl_bn_copy, 1);
+
+ /* swap (=coerce?) */
+
+ rb_define_method(cBN, "num_bytes", ossl_bn_num_bytes, 0);
+ rb_define_method(cBN, "num_bits", ossl_bn_num_bits, 0);
+ /* num_bits_word */
+
+ rb_define_method(cBN, "+", ossl_bn_add, 1);
+ rb_define_method(cBN, "-", ossl_bn_sub, 1);
+ rb_define_method(cBN, "*", ossl_bn_mul, 1);
+ rb_define_method(cBN, "sqr", ossl_bn_sqr, 0);
+ rb_define_method(cBN, "/", ossl_bn_div, 1);
+ rb_define_method(cBN, "%", ossl_bn_mod, 1);
+ /* nnmod */
+
+ rb_define_method(cBN, "mod_add", ossl_bn_mod_add, 2);
+ rb_define_method(cBN, "mod_sub", ossl_bn_mod_sub, 2);
+ rb_define_method(cBN, "mod_mul", ossl_bn_mod_mul, 2);
+ rb_define_method(cBN, "mod_sqr", ossl_bn_mod_sqr, 1);
+ rb_define_method(cBN, "**", ossl_bn_exp, 1);
+ rb_define_method(cBN, "mod_exp", ossl_bn_mod_exp, 2);
+ rb_define_method(cBN, "gcd", ossl_bn_gcd, 1);
+
+ /* add_word
+ * sub_word
+ * mul_word
+ * div_word
+ * mod_word */
+
+ rb_define_method(cBN, "cmp", ossl_bn_cmp, 1);
+ rb_define_alias(cBN, "<=>", "cmp");
+ rb_define_method(cBN, "ucmp", ossl_bn_ucmp, 1);
+ rb_define_method(cBN, "eql?", ossl_bn_eql, 1);
+ rb_define_alias(cBN, "==", "eql?");
+ rb_define_alias(cBN, "===", "eql?");
+ rb_define_method(cBN, "zero?", ossl_bn_is_zero, 0);
+ rb_define_method(cBN, "one?", ossl_bn_is_one, 0);
+ /* is_word */
+ rb_define_method(cBN, "odd?", ossl_bn_is_odd, 0);
+
+ /* zero
+ * one
+ * value_one - DON'T IMPL.
+ * set_word
+ * get_word */
+
+ rb_define_singleton_method(cBN, "rand", ossl_bn_s_rand, -1);
+ rb_define_singleton_method(cBN, "pseudo_rand", ossl_bn_s_pseudo_rand, -1);
+ rb_define_singleton_method(cBN, "rand_range", ossl_bn_s_rand_range, 1);
+ rb_define_singleton_method(cBN, "pseudo_rand_range", ossl_bn_s_pseudo_rand_range, 1);
+
+ rb_define_singleton_method(cBN, "generate_prime", ossl_bn_s_generate_prime, -1);
+ rb_define_method(cBN, "prime?", ossl_bn_is_prime, -1);
+
+ rb_define_method(cBN, "set_bit!", ossl_bn_set_bit, 1);
+ rb_define_method(cBN, "clear_bit!", ossl_bn_clear_bit, 1);
+ rb_define_method(cBN, "bit_set?", ossl_bn_is_bit_set, 1);
+ rb_define_method(cBN, "mask_bits!", ossl_bn_mask_bits, 1);
+ rb_define_method(cBN, "<<", ossl_bn_lshift, 1);
+ rb_define_method(cBN, ">>", ossl_bn_rshift, 1);
+ rb_define_method(cBN, "lshift!", ossl_bn_self_lshift, 1);
+ rb_define_method(cBN, "rshift!", ossl_bn_self_rshift, 1);
+ /* lshift1 - DON'T IMPL. */
+ /* rshift1 - DON'T IMPL. */
+
+ /*
+ * bn2bin
+ * bin2bn
+ * bn2hex
+ * bn2dec
+ * hex2bn
+ * dec2bn - all these are implemented in ossl_bn_initialize, and ossl_bn_to_s
+ * print - NOT IMPL.
+ * print_fp - NOT IMPL.
+ * bn2mpi
+ * mpi2bn
+ */
+ rb_define_method(cBN, "to_s", ossl_bn_to_s, -1);
+ rb_define_method(cBN, "to_i", ossl_bn_to_i, 0);
+ rb_define_alias(cBN, "to_int", "to_i");
+ rb_define_method(cBN, "to_bn", ossl_bn_to_bn, 0);
+ rb_define_method(cBN, "coerce", ossl_bn_coerce, 1);
+
+ /*
+ * TODO:
+ * But how to: from_bin, from_mpi? PACK?
+ * to_bin
+ * to_mpi
+ */
+
+ rb_define_method(cBN, "mod_inverse", ossl_bn_mod_inverse, 1);
+
+ /* RECiProcal
+ * MONTgomery */
+
+ /*
+ * TODO:
+ * Where to belong these?
+ */
+ rb_define_method(cBN, "prime_fasttest?", ossl_bn_is_prime_fasttest, -1);
+}
+
diff --git a/jni/ruby/ext/openssl/ossl_bn.h b/jni/ruby/ext/openssl/ossl_bn.h
new file mode 100644
index 0000000..55dc041
--- /dev/null
+++ b/jni/ruby/ext/openssl/ossl_bn.h
@@ -0,0 +1,25 @@
+/*
+ * $Id: ossl_bn.h 25189 2009-10-02 12:04:37Z akr $
+ * 'OpenSSL for Ruby' project
+ * Copyright (C) 2001-2002 Michal Rokos <m.rokos@sh.cvut.cz>
+ * All rights reserved.
+ */
+/*
+ * This program is licenced under the same licence as Ruby.
+ * (See the file 'LICENCE'.)
+ */
+#if !defined(_OSSL_BN_H_)
+#define _OSSL_BN_H_
+
+extern VALUE cBN;
+extern VALUE eBNError;
+
+extern BN_CTX *ossl_bn_ctx;
+
+VALUE ossl_bn_new(const BIGNUM *);
+BIGNUM *GetBNPtr(VALUE);
+void Init_ossl_bn(void);
+
+
+#endif /* _OSS_BN_H_ */
+
diff --git a/jni/ruby/ext/openssl/ossl_cipher.c b/jni/ruby/ext/openssl/ossl_cipher.c
new file mode 100644
index 0000000..4daf575
--- /dev/null
+++ b/jni/ruby/ext/openssl/ossl_cipher.c
@@ -0,0 +1,1017 @@
+/*
+ * $Id: ossl_cipher.c 48923 2014-12-23 02:42:16Z nobu $
+ * 'OpenSSL for Ruby' project
+ * Copyright (C) 2001-2002 Michal Rokos <m.rokos@sh.cvut.cz>
+ * All rights reserved.
+ */
+/*
+ * This program is licenced under the same licence as Ruby.
+ * (See the file 'LICENCE'.)
+ */
+#include "ossl.h"
+
+#define WrapCipher(obj, klass, ctx) \
+ (obj) = TypedData_Wrap_Struct((klass), &ossl_cipher_type, (ctx))
+#define MakeCipher(obj, klass, ctx) \
+ (obj) = TypedData_Make_Struct((klass), EVP_CIPHER_CTX, &ossl_cipher_type, (ctx))
+#define AllocCipher(obj, ctx) \
+ (DATA_PTR(obj) = (ctx) = ZALLOC(EVP_CIPHER_CTX))
+#define GetCipherInit(obj, ctx) do { \
+ TypedData_Get_Struct((obj), EVP_CIPHER_CTX, &ossl_cipher_type, (ctx)); \
+} while (0)
+#define GetCipher(obj, ctx) do { \
+ GetCipherInit((obj), (ctx)); \
+ if (!(ctx)) { \
+ ossl_raise(rb_eRuntimeError, "Cipher not inititalized!"); \
+ } \
+} while (0)
+#define SafeGetCipher(obj, ctx) do { \
+ OSSL_Check_Kind((obj), cCipher); \
+ GetCipher((obj), (ctx)); \
+} while (0)
+
+/*
+ * Classes
+ */
+VALUE cCipher;
+VALUE eCipherError;
+
+static VALUE ossl_cipher_alloc(VALUE klass);
+static void ossl_cipher_free(void *ptr);
+static size_t ossl_cipher_memsize(const void *ptr);
+
+static const rb_data_type_t ossl_cipher_type = {
+ "OpenSSL/Cipher",
+ {0, ossl_cipher_free, ossl_cipher_memsize,},
+ 0, 0,
+ RUBY_TYPED_FREE_IMMEDIATELY,
+};
+
+/*
+ * PUBLIC
+ */
+const EVP_CIPHER *
+GetCipherPtr(VALUE obj)
+{
+ EVP_CIPHER_CTX *ctx;
+
+ SafeGetCipher(obj, ctx);
+
+ return EVP_CIPHER_CTX_cipher(ctx);
+}
+
+VALUE
+ossl_cipher_new(const EVP_CIPHER *cipher)
+{
+ VALUE ret;
+ EVP_CIPHER_CTX *ctx;
+
+ ret = ossl_cipher_alloc(cCipher);
+ AllocCipher(ret, ctx);
+ EVP_CIPHER_CTX_init(ctx);
+ if (EVP_CipherInit_ex(ctx, cipher, NULL, NULL, NULL, -1) != 1)
+ ossl_raise(eCipherError, NULL);
+
+ return ret;
+}
+
+/*
+ * PRIVATE
+ */
+static void
+ossl_cipher_free(void *ptr)
+{
+ EVP_CIPHER_CTX *ctx = ptr;
+ if (ctx) {
+ EVP_CIPHER_CTX_cleanup(ctx);
+ ruby_xfree(ctx);
+ }
+}
+
+static size_t
+ossl_cipher_memsize(const void *ptr)
+{
+ const EVP_CIPHER_CTX *ctx = ptr;
+ return ctx ? sizeof(*ctx) : 0;
+}
+
+static VALUE
+ossl_cipher_alloc(VALUE klass)
+{
+ VALUE obj;
+
+ WrapCipher(obj, klass, 0);
+
+ return obj;
+}
+
+/*
+ * call-seq:
+ * Cipher.new(string) -> cipher
+ *
+ * The string must contain a valid cipher name like "AES-128-CBC" or "3DES".
+ *
+ * A list of cipher names is available by calling OpenSSL::Cipher.ciphers.
+ */
+static VALUE
+ossl_cipher_initialize(VALUE self, VALUE str)
+{
+ EVP_CIPHER_CTX *ctx;
+ const EVP_CIPHER *cipher;
+ char *name;
+ unsigned char key[EVP_MAX_KEY_LENGTH];
+
+ name = StringValuePtr(str);
+ GetCipherInit(self, ctx);
+ if (ctx) {
+ ossl_raise(rb_eRuntimeError, "Cipher already inititalized!");
+ }
+ AllocCipher(self, ctx);
+ EVP_CIPHER_CTX_init(ctx);
+ if (!(cipher = EVP_get_cipherbyname(name))) {
+ ossl_raise(rb_eRuntimeError, "unsupported cipher algorithm (%s)", name);
+ }
+ /*
+ * The EVP which has EVP_CIPH_RAND_KEY flag (such as DES3) allows
+ * uninitialized key, but other EVPs (such as AES) does not allow it.
+ * Calling EVP_CipherUpdate() without initializing key causes SEGV so we
+ * set the data filled with "\0" as the key by default.
+ */
+ memset(key, 0, EVP_MAX_KEY_LENGTH);
+ if (EVP_CipherInit_ex(ctx, cipher, NULL, key, NULL, -1) != 1)
+ ossl_raise(eCipherError, NULL);
+
+ return self;
+}
+
+static VALUE
+ossl_cipher_copy(VALUE self, VALUE other)
+{
+ EVP_CIPHER_CTX *ctx1, *ctx2;
+
+ rb_check_frozen(self);
+ if (self == other) return self;
+
+ GetCipherInit(self, ctx1);
+ if (!ctx1) {
+ AllocCipher(self, ctx1);
+ }
+ SafeGetCipher(other, ctx2);
+ if (EVP_CIPHER_CTX_copy(ctx1, ctx2) != 1)
+ ossl_raise(eCipherError, NULL);
+
+ return self;
+}
+
+#ifdef HAVE_OBJ_NAME_DO_ALL_SORTED
+static void*
+add_cipher_name_to_ary(const OBJ_NAME *name, VALUE ary)
+{
+ rb_ary_push(ary, rb_str_new2(name->name));
+ return NULL;
+}
+#endif
+
+#ifdef HAVE_OBJ_NAME_DO_ALL_SORTED
+/*
+ * call-seq:
+ * OpenSSL::Cipher.ciphers -> array[string...]
+ *
+ * Returns the names of all available ciphers in an array.
+ */
+static VALUE
+ossl_s_ciphers(VALUE self)
+{
+ VALUE ary;
+
+ ary = rb_ary_new();
+ OBJ_NAME_do_all_sorted(OBJ_NAME_TYPE_CIPHER_METH,
+ (void(*)(const OBJ_NAME*,void*))add_cipher_name_to_ary,
+ (void*)ary);
+
+ return ary;
+}
+#else
+#define ossl_s_ciphers rb_f_notimplement
+#endif
+
+/*
+ * call-seq:
+ * cipher.reset -> self
+ *
+ * Fully resets the internal state of the Cipher. By using this, the same
+ * Cipher instance may be used several times for encryption or decryption tasks.
+ *
+ * Internally calls EVP_CipherInit_ex(ctx, NULL, NULL, NULL, NULL, -1).
+ */
+static VALUE
+ossl_cipher_reset(VALUE self)
+{
+ EVP_CIPHER_CTX *ctx;
+
+ GetCipher(self, ctx);
+ if (EVP_CipherInit_ex(ctx, NULL, NULL, NULL, NULL, -1) != 1)
+ ossl_raise(eCipherError, NULL);
+
+ return self;
+}
+
+static VALUE
+ossl_cipher_init(int argc, VALUE *argv, VALUE self, int mode)
+{
+ EVP_CIPHER_CTX *ctx;
+ unsigned char key[EVP_MAX_KEY_LENGTH], *p_key = NULL;
+ unsigned char iv[EVP_MAX_IV_LENGTH], *p_iv = NULL;
+ VALUE pass, init_v;
+
+ if(rb_scan_args(argc, argv, "02", &pass, &init_v) > 0){
+ /*
+ * oops. this code mistakes salt for IV.
+ * We deprecated the arguments for this method, but we decided
+ * keeping this behaviour for backward compatibility.
+ */
+ VALUE cname = rb_class_path(rb_obj_class(self));
+ rb_warn("arguments for %"PRIsVALUE"#encrypt and %"PRIsVALUE"#decrypt were deprecated; "
+ "use %"PRIsVALUE"#pkcs5_keyivgen to derive key and IV",
+ cname, cname, cname);
+ StringValue(pass);
+ GetCipher(self, ctx);
+ if (NIL_P(init_v)) memcpy(iv, "OpenSSL for Ruby rulez!", sizeof(iv));
+ else{
+ StringValue(init_v);
+ if (EVP_MAX_IV_LENGTH > RSTRING_LEN(init_v)) {
+ memset(iv, 0, EVP_MAX_IV_LENGTH);
+ memcpy(iv, RSTRING_PTR(init_v), RSTRING_LEN(init_v));
+ }
+ else memcpy(iv, RSTRING_PTR(init_v), sizeof(iv));
+ }
+ EVP_BytesToKey(EVP_CIPHER_CTX_cipher(ctx), EVP_md5(), iv,
+ (unsigned char *)RSTRING_PTR(pass), RSTRING_LENINT(pass), 1, key, NULL);
+ p_key = key;
+ p_iv = iv;
+ }
+ else {
+ GetCipher(self, ctx);
+ }
+ if (EVP_CipherInit_ex(ctx, NULL, NULL, p_key, p_iv, mode) != 1) {
+ ossl_raise(eCipherError, NULL);
+ }
+
+ return self;
+}
+
+/*
+ * call-seq:
+ * cipher.encrypt -> self
+ *
+ * Initializes the Cipher for encryption.
+ *
+ * Make sure to call Cipher#encrypt or Cipher#decrypt before using any of the
+ * following methods:
+ * * [key=, iv=, random_key, random_iv, pkcs5_keyivgen]
+ *
+ * Internally calls EVP_CipherInit_ex(ctx, NULL, NULL, NULL, NULL, 1).
+ */
+static VALUE
+ossl_cipher_encrypt(int argc, VALUE *argv, VALUE self)
+{
+ return ossl_cipher_init(argc, argv, self, 1);
+}
+
+/*
+ * call-seq:
+ * cipher.decrypt -> self
+ *
+ * Initializes the Cipher for decryption.
+ *
+ * Make sure to call Cipher#encrypt or Cipher#decrypt before using any of the
+ * following methods:
+ * * [key=, iv=, random_key, random_iv, pkcs5_keyivgen]
+ *
+ * Internally calls EVP_CipherInit_ex(ctx, NULL, NULL, NULL, NULL, 0).
+ */
+static VALUE
+ossl_cipher_decrypt(int argc, VALUE *argv, VALUE self)
+{
+ return ossl_cipher_init(argc, argv, self, 0);
+}
+
+/*
+ * call-seq:
+ * cipher.pkcs5_keyivgen(pass [, salt [, iterations [, digest]]] ) -> nil
+ *
+ * Generates and sets the key/IV based on a password.
+ *
+ * WARNING: This method is only PKCS5 v1.5 compliant when using RC2, RC4-40,
+ * or DES with MD5 or SHA1. Using anything else (like AES) will generate the
+ * key/iv using an OpenSSL specific method. This method is deprecated and
+ * should no longer be used. Use a PKCS5 v2 key generation method from
+ * OpenSSL::PKCS5 instead.
+ *
+ * === Parameters
+ * +salt+ must be an 8 byte string if provided.
+ * +iterations+ is a integer with a default of 2048.
+ * +digest+ is a Digest object that defaults to 'MD5'
+ *
+ * A minimum of 1000 iterations is recommended.
+ *
+ */
+static VALUE
+ossl_cipher_pkcs5_keyivgen(int argc, VALUE *argv, VALUE self)
+{
+ EVP_CIPHER_CTX *ctx;
+ const EVP_MD *digest;
+ VALUE vpass, vsalt, viter, vdigest;
+ unsigned char key[EVP_MAX_KEY_LENGTH], iv[EVP_MAX_IV_LENGTH], *salt = NULL;
+ int iter;
+
+ rb_scan_args(argc, argv, "13", &vpass, &vsalt, &viter, &vdigest);
+ StringValue(vpass);
+ if(!NIL_P(vsalt)){
+ StringValue(vsalt);
+ if(RSTRING_LEN(vsalt) != PKCS5_SALT_LEN)
+ ossl_raise(eCipherError, "salt must be an 8-octet string");
+ salt = (unsigned char *)RSTRING_PTR(vsalt);
+ }
+ iter = NIL_P(viter) ? 2048 : NUM2INT(viter);
+ digest = NIL_P(vdigest) ? EVP_md5() : GetDigestPtr(vdigest);
+ GetCipher(self, ctx);
+ EVP_BytesToKey(EVP_CIPHER_CTX_cipher(ctx), digest, salt,
+ (unsigned char *)RSTRING_PTR(vpass), RSTRING_LENINT(vpass), iter, key, iv);
+ if (EVP_CipherInit_ex(ctx, NULL, NULL, key, iv, -1) != 1)
+ ossl_raise(eCipherError, NULL);
+ OPENSSL_cleanse(key, sizeof key);
+ OPENSSL_cleanse(iv, sizeof iv);
+
+ return Qnil;
+}
+
+static int
+ossl_cipher_update_long(EVP_CIPHER_CTX *ctx, unsigned char *out, long *out_len_ptr,
+ const unsigned char *in, long in_len)
+{
+ int out_part_len;
+ long out_len = 0;
+#define UPDATE_LENGTH_LIMIT INT_MAX
+
+#if SIZEOF_LONG > UPDATE_LENGTH_LIMIT
+ if (in_len > UPDATE_LENGTH_LIMIT) {
+ const int in_part_len = (UPDATE_LENGTH_LIMIT / 2 + 1) & ~1;
+ do {
+ if (!EVP_CipherUpdate(ctx, out ? (out + out_len) : 0,
+ &out_part_len, in, in_part_len))
+ return 0;
+ out_len += out_part_len;
+ in += in_part_len;
+ } while ((in_len -= in_part_len) > UPDATE_LENGTH_LIMIT);
+ }
+#endif
+ if (!EVP_CipherUpdate(ctx, out ? (out + out_len) : 0,
+ &out_part_len, in, (int)in_len))
+ return 0;
+ if (out_len_ptr) *out_len_ptr = out_len += out_part_len;
+ return 1;
+}
+
+/*
+ * call-seq:
+ * cipher.update(data [, buffer]) -> string or buffer
+ *
+ * Encrypts data in a streaming fashion. Hand consecutive blocks of data
+ * to the +update+ method in order to encrypt it. Returns the encrypted
+ * data chunk. When done, the output of Cipher#final should be additionally
+ * added to the result.
+ *
+ * === Parameters
+ * +data+ is a nonempty string.
+ * +buffer+ is an optional string to store the result.
+ */
+static VALUE
+ossl_cipher_update(int argc, VALUE *argv, VALUE self)
+{
+ EVP_CIPHER_CTX *ctx;
+ unsigned char *in;
+ long in_len, out_len;
+ VALUE data, str;
+
+ rb_scan_args(argc, argv, "11", &data, &str);
+
+ StringValue(data);
+ in = (unsigned char *)RSTRING_PTR(data);
+ if ((in_len = RSTRING_LEN(data)) == 0)
+ ossl_raise(rb_eArgError, "data must not be empty");
+ GetCipher(self, ctx);
+ out_len = in_len+EVP_CIPHER_CTX_block_size(ctx);
+ if (out_len <= 0) {
+ ossl_raise(rb_eRangeError,
+ "data too big to make output buffer: %ld bytes", in_len);
+ }
+
+ if (NIL_P(str)) {
+ str = rb_str_new(0, out_len);
+ } else {
+ StringValue(str);
+ rb_str_resize(str, out_len);
+ }
+
+ if (!ossl_cipher_update_long(ctx, (unsigned char *)RSTRING_PTR(str), &out_len, in, in_len))
+ ossl_raise(eCipherError, NULL);
+ assert(out_len < RSTRING_LEN(str));
+ rb_str_set_len(str, out_len);
+
+ return str;
+}
+
+/*
+ * call-seq:
+ * cipher.final -> string
+ *
+ * Returns the remaining data held in the cipher object. Further calls to
+ * Cipher#update or Cipher#final will return garbage. This call should always
+ * be made as the last call of an encryption or decryption operation, after
+ * after having fed the entire plaintext or ciphertext to the Cipher instance.
+ *
+ * If an authenticated cipher was used, a CipherError is raised if the tag
+ * could not be authenticated successfully. Only call this method after
+ * setting the authentication tag and passing the entire contents of the
+ * ciphertext into the cipher.
+ */
+static VALUE
+ossl_cipher_final(VALUE self)
+{
+ EVP_CIPHER_CTX *ctx;
+ int out_len;
+ VALUE str;
+
+ GetCipher(self, ctx);
+ str = rb_str_new(0, EVP_CIPHER_CTX_block_size(ctx));
+ if (!EVP_CipherFinal_ex(ctx, (unsigned char *)RSTRING_PTR(str), &out_len))
+ ossl_raise(eCipherError, NULL);
+ assert(out_len <= RSTRING_LEN(str));
+ rb_str_set_len(str, out_len);
+
+ return str;
+}
+
+/*
+ * call-seq:
+ * cipher.name -> string
+ *
+ * Returns the name of the cipher which may differ slightly from the original
+ * name provided.
+ */
+static VALUE
+ossl_cipher_name(VALUE self)
+{
+ EVP_CIPHER_CTX *ctx;
+
+ GetCipher(self, ctx);
+
+ return rb_str_new2(EVP_CIPHER_name(EVP_CIPHER_CTX_cipher(ctx)));
+}
+
+/*
+ * call-seq:
+ * cipher.key = string -> string
+ *
+ * Sets the cipher key. To generate a key, you should either use a secure
+ * random byte string or, if the key is to be derived from a password, you
+ * should rely on PBKDF2 functionality provided by OpenSSL::PKCS5. To
+ * generate a secure random-based key, Cipher#random_key may be used.
+ *
+ * Only call this method after calling Cipher#encrypt or Cipher#decrypt.
+ */
+static VALUE
+ossl_cipher_set_key(VALUE self, VALUE key)
+{
+ EVP_CIPHER_CTX *ctx;
+
+ StringValue(key);
+ GetCipher(self, ctx);
+
+ if (RSTRING_LEN(key) < EVP_CIPHER_CTX_key_length(ctx))
+ ossl_raise(eCipherError, "key length too short");
+
+ if (EVP_CipherInit_ex(ctx, NULL, NULL, (unsigned char *)RSTRING_PTR(key), NULL, -1) != 1)
+ ossl_raise(eCipherError, NULL);
+
+ return key;
+}
+
+/*
+ * call-seq:
+ * cipher.iv = string -> string
+ *
+ * Sets the cipher IV. Please note that since you should never be using ECB
+ * mode, an IV is always explicitly required and should be set prior to
+ * encryption. The IV itself can be safely transmitted in public, but it
+ * should be unpredictable to prevent certain kinds of attacks. You may use
+ * Cipher#random_iv to create a secure random IV.
+ *
+ * Only call this method after calling Cipher#encrypt or Cipher#decrypt.
+ *
+ * If not explicitly set, the OpenSSL default of an all-zeroes ("\\0") IV is
+ * used.
+ */
+static VALUE
+ossl_cipher_set_iv(VALUE self, VALUE iv)
+{
+ EVP_CIPHER_CTX *ctx;
+
+ StringValue(iv);
+ GetCipher(self, ctx);
+
+ if (RSTRING_LEN(iv) < EVP_CIPHER_CTX_iv_length(ctx))
+ ossl_raise(eCipherError, "iv length too short");
+
+ if (EVP_CipherInit_ex(ctx, NULL, NULL, NULL, (unsigned char *)RSTRING_PTR(iv), -1) != 1)
+ ossl_raise(eCipherError, NULL);
+
+ return iv;
+}
+
+#ifdef HAVE_AUTHENTICATED_ENCRYPTION
+/*
+ * call-seq:
+ * cipher.auth_data = string -> string
+ *
+ * Sets the cipher's additional authenticated data. This field must be
+ * set when using AEAD cipher modes such as GCM or CCM. If no associated
+ * data shall be used, this method must *still* be called with a value of "".
+ * The contents of this field should be non-sensitive data which will be
+ * added to the ciphertext to generate the authentication tag which validates
+ * the contents of the ciphertext.
+ *
+ * The AAD must be set prior to encryption or decryption. In encryption mode,
+ * it must be set after calling Cipher#encrypt and setting Cipher#key= and
+ * Cipher#iv=. When decrypting, the authenticated data must be set after key,
+ * iv and especially *after* the authentication tag has been set. I.e. set it
+ * only after calling Cipher#decrypt, Cipher#key=, Cipher#iv= and
+ * Cipher#auth_tag= first.
+ */
+static VALUE
+ossl_cipher_set_auth_data(VALUE self, VALUE data)
+{
+ EVP_CIPHER_CTX *ctx;
+ unsigned char *in;
+ long in_len, out_len;
+
+ StringValue(data);
+
+ in = (unsigned char *) RSTRING_PTR(data);
+ in_len = RSTRING_LEN(data);
+
+ GetCipher(self, ctx);
+
+ if (!ossl_cipher_update_long(ctx, NULL, &out_len, in, in_len))
+ ossl_raise(eCipherError, "couldn't set additional authenticated data");
+
+ return data;
+}
+
+#define ossl_is_gcm(nid) (nid) == NID_aes_128_gcm || \
+ (nid) == NID_aes_192_gcm || \
+ (nid) == NID_aes_256_gcm
+
+static VALUE
+ossl_get_gcm_auth_tag(EVP_CIPHER_CTX *ctx, int len)
+{
+ unsigned char *tag;
+ VALUE ret;
+
+ tag = ALLOC_N(unsigned char, len);
+
+ if (!EVP_CIPHER_CTX_ctrl(ctx, EVP_CTRL_GCM_GET_TAG, len, tag))
+ ossl_raise(eCipherError, "retrieving the authentication tag failed");
+
+ ret = rb_str_new((const char *) tag, len);
+ xfree(tag);
+ return ret;
+}
+
+/*
+ * call-seq:
+ * cipher.auth_tag([ tag_len ] -> string
+ *
+ * Gets the authentication tag generated by Authenticated Encryption Cipher
+ * modes (GCM for example). This tag may be stored along with the ciphertext,
+ * then set on the decryption cipher to authenticate the contents of the
+ * ciphertext against changes. If the optional integer parameter +tag_len+ is
+ * given, the returned tag will be +tag_len+ bytes long. If the parameter is
+ * omitted, the maximum length of 16 bytes will be returned. For maximum
+ * security, the default of 16 bytes should be chosen.
+ *
+ * The tag may only be retrieved after calling Cipher#final.
+ */
+static VALUE
+ossl_cipher_get_auth_tag(int argc, VALUE *argv, VALUE self)
+{
+ VALUE vtag_len;
+ EVP_CIPHER_CTX *ctx;
+ int nid, tag_len;
+
+ if (rb_scan_args(argc, argv, "01", &vtag_len) == 0) {
+ tag_len = 16;
+ } else {
+ tag_len = NUM2INT(vtag_len);
+ }
+
+ GetCipher(self, ctx);
+ nid = EVP_CIPHER_CTX_nid(ctx);
+
+ if (ossl_is_gcm(nid)) {
+ return ossl_get_gcm_auth_tag(ctx, tag_len);
+ } else {
+ ossl_raise(eCipherError, "authentication tag not supported by this cipher");
+ return Qnil; /* dummy */
+ }
+}
+
+static inline void
+ossl_set_gcm_auth_tag(EVP_CIPHER_CTX *ctx, unsigned char *tag, int tag_len)
+{
+ if (!EVP_CIPHER_CTX_ctrl(ctx, EVP_CTRL_GCM_SET_TAG, tag_len, tag))
+ ossl_raise(eCipherError, "unable to set GCM tag");
+}
+
+/*
+ * call-seq:
+ * cipher.auth_tag = string -> string
+ *
+ * Sets the authentication tag to verify the contents of the
+ * ciphertext. The tag must be set after calling Cipher#decrypt,
+ * Cipher#key= and Cipher#iv=, but before assigning the associated
+ * authenticated data using Cipher#auth_data= and of course, before
+ * decrypting any of the ciphertext. After all decryption is
+ * performed, the tag is verified automatically in the call to
+ * Cipher#final.
+ */
+static VALUE
+ossl_cipher_set_auth_tag(VALUE self, VALUE vtag)
+{
+ EVP_CIPHER_CTX *ctx;
+ int nid;
+ unsigned char *tag;
+ int tag_len;
+
+ StringValue(vtag);
+ tag = (unsigned char *) RSTRING_PTR(vtag);
+ tag_len = RSTRING_LENINT(vtag);
+
+ GetCipher(self, ctx);
+ nid = EVP_CIPHER_CTX_nid(ctx);
+
+ if (ossl_is_gcm(nid)) {
+ ossl_set_gcm_auth_tag(ctx, tag, tag_len);
+ } else {
+ ossl_raise(eCipherError, "authentication tag not supported by this cipher");
+ }
+
+ return vtag;
+}
+
+/*
+ * call-seq:
+ * cipher.authenticated? -> boolean
+ *
+ * Indicated whether this Cipher instance uses an Authenticated Encryption
+ * mode.
+ */
+static VALUE
+ossl_cipher_is_authenticated(VALUE self)
+{
+ EVP_CIPHER_CTX *ctx;
+ int nid;
+
+ GetCipher(self, ctx);
+ nid = EVP_CIPHER_CTX_nid(ctx);
+
+ if (ossl_is_gcm(nid)) {
+ return Qtrue;
+ } else {
+ return Qfalse;
+ }
+}
+#else
+#define ossl_cipher_set_auth_data rb_f_notimplement
+#define ossl_cipher_get_auth_tag rb_f_notimplement
+#define ossl_cipher_set_auth_tag rb_f_notimplement
+#define ossl_cipher_is_authenticated rb_f_notimplement
+#endif
+
+/*
+ * call-seq:
+ * cipher.key_len = integer -> integer
+ *
+ * Sets the key length of the cipher. If the cipher is a fixed length cipher
+ * then attempting to set the key length to any value other than the fixed
+ * value is an error.
+ *
+ * Under normal circumstances you do not need to call this method (and probably shouldn't).
+ *
+ * See EVP_CIPHER_CTX_set_key_length for further information.
+ */
+static VALUE
+ossl_cipher_set_key_length(VALUE self, VALUE key_length)
+{
+ int len = NUM2INT(key_length);
+ EVP_CIPHER_CTX *ctx;
+
+ GetCipher(self, ctx);
+ if (EVP_CIPHER_CTX_set_key_length(ctx, len) != 1)
+ ossl_raise(eCipherError, NULL);
+
+ return key_length;
+}
+
+#if defined(HAVE_EVP_CIPHER_CTX_SET_PADDING)
+/*
+ * call-seq:
+ * cipher.padding = integer -> integer
+ *
+ * Enables or disables padding. By default encryption operations are padded using standard block padding and the
+ * padding is checked and removed when decrypting. If the pad parameter is zero then no padding is performed, the
+ * total amount of data encrypted or decrypted must then be a multiple of the block size or an error will occur.
+ *
+ * See EVP_CIPHER_CTX_set_padding for further information.
+ */
+static VALUE
+ossl_cipher_set_padding(VALUE self, VALUE padding)
+{
+ EVP_CIPHER_CTX *ctx;
+ int pad = NUM2INT(padding);
+
+ GetCipher(self, ctx);
+ if (EVP_CIPHER_CTX_set_padding(ctx, pad) != 1)
+ ossl_raise(eCipherError, NULL);
+ return padding;
+}
+#else
+#define ossl_cipher_set_padding rb_f_notimplement
+#endif
+
+#define CIPHER_0ARG_INT(func) \
+ static VALUE \
+ ossl_cipher_##func(VALUE self) \
+ { \
+ EVP_CIPHER_CTX *ctx; \
+ GetCipher(self, ctx); \
+ return INT2NUM(EVP_CIPHER_##func(EVP_CIPHER_CTX_cipher(ctx))); \
+ }
+
+/*
+ * call-seq:
+ * cipher.key_len -> integer
+ *
+ * Returns the key length in bytes of the Cipher.
+ */
+CIPHER_0ARG_INT(key_length)
+/*
+ * call-seq:
+ * cipher.iv_len -> integer
+ *
+ * Returns the expected length in bytes for an IV for this Cipher.
+ */
+CIPHER_0ARG_INT(iv_length)
+/*
+ * call-seq:
+ * cipher.block_size -> integer
+ *
+ * Returns the size in bytes of the blocks on which this Cipher operates on.
+ */
+CIPHER_0ARG_INT(block_size)
+
+/*
+ * INIT
+ */
+void
+Init_ossl_cipher(void)
+{
+#if 0
+ mOSSL = rb_define_module("OpenSSL"); /* let rdoc know about mOSSL */
+#endif
+
+ /* Document-class: OpenSSL::Cipher
+ *
+ * Provides symmetric algorithms for encryption and decryption. The
+ * algorithms that are available depend on the particular version
+ * of OpenSSL that is installed.
+ *
+ * === Listing all supported algorithms
+ *
+ * A list of supported algorithms can be obtained by
+ *
+ * puts OpenSSL::Cipher.ciphers
+ *
+ * === Instantiating a Cipher
+ *
+ * There are several ways to create a Cipher instance. Generally, a
+ * Cipher algorithm is categorized by its name, the key length in bits
+ * and the cipher mode to be used. The most generic way to create a
+ * Cipher is the following
+ *
+ * cipher = OpenSSL::Cipher.new('<name>-<key length>-<mode>')
+ *
+ * That is, a string consisting of the hyphenated concatenation of the
+ * individual components name, key length and mode. Either all uppercase
+ * or all lowercase strings may be used, for example:
+ *
+ * cipher = OpenSSL::Cipher.new('AES-128-CBC')
+ *
+ * For each algorithm supported, there is a class defined under the
+ * Cipher class that goes by the name of the cipher, e.g. to obtain an
+ * instance of AES, you could also use
+ *
+ * # these are equivalent
+ * cipher = OpenSSL::Cipher::AES.new(128, :CBC)
+ * cipher = OpenSSL::Cipher::AES.new(128, 'CBC')
+ * cipher = OpenSSL::Cipher::AES.new('128-CBC')
+ *
+ * Finally, due to its wide-spread use, there are also extra classes
+ * defined for the different key sizes of AES
+ *
+ * cipher = OpenSSL::Cipher::AES128.new(:CBC)
+ * cipher = OpenSSL::Cipher::AES192.new(:CBC)
+ * cipher = OpenSSL::Cipher::AES256.new(:CBC)
+ *
+ * === Choosing either encryption or decryption mode
+ *
+ * Encryption and decryption are often very similar operations for
+ * symmetric algorithms, this is reflected by not having to choose
+ * different classes for either operation, both can be done using the
+ * same class. Still, after obtaining a Cipher instance, we need to
+ * tell the instance what it is that we intend to do with it, so we
+ * need to call either
+ *
+ * cipher.encrypt
+ *
+ * or
+ *
+ * cipher.decrypt
+ *
+ * on the Cipher instance. This should be the first call after creating
+ * the instance, otherwise configuration that has already been set could
+ * get lost in the process.
+ *
+ * === Choosing a key
+ *
+ * Symmetric encryption requires a key that is the same for the encrypting
+ * and for the decrypting party and after initial key establishment should
+ * be kept as private information. There are a lot of ways to create
+ * insecure keys, the most notable is to simply take a password as the key
+ * without processing the password further. A simple and secure way to
+ * create a key for a particular Cipher is
+ *
+ * cipher = OpenSSL::AES256.new(:CFB)
+ * cipher.encrypt
+ * key = cipher.random_key # also sets the generated key on the Cipher
+ *
+ * If you absolutely need to use passwords as encryption keys, you
+ * should use Password-Based Key Derivation Function 2 (PBKDF2) by
+ * generating the key with the help of the functionality provided by
+ * OpenSSL::PKCS5.pbkdf2_hmac_sha1 or OpenSSL::PKCS5.pbkdf2_hmac.
+ *
+ * Although there is Cipher#pkcs5_keyivgen, its use is deprecated and
+ * it should only be used in legacy applications because it does not use
+ * the newer PKCS#5 v2 algorithms.
+ *
+ * === Choosing an IV
+ *
+ * The cipher modes CBC, CFB, OFB and CTR all need an "initialization
+ * vector", or short, IV. ECB mode is the only mode that does not require
+ * an IV, but there is almost no legitimate use case for this mode
+ * because of the fact that it does not sufficiently hide plaintext
+ * patterns. Therefore
+ *
+ * <b>You should never use ECB mode unless you are absolutely sure that
+ * you absolutely need it</b>
+ *
+ * Because of this, you will end up with a mode that explicitly requires
+ * an IV in any case. Note that for backwards compatibility reasons,
+ * setting an IV is not explicitly mandated by the Cipher API. If not
+ * set, OpenSSL itself defaults to an all-zeroes IV ("\\0", not the
+ * character). Although the IV can be seen as public information, i.e.
+ * it may be transmitted in public once generated, it should still stay
+ * unpredictable to prevent certain kinds of attacks. Therefore, ideally
+ *
+ * <b>Always create a secure random IV for every encryption of your
+ * Cipher</b>
+ *
+ * A new, random IV should be created for every encryption of data. Think
+ * of the IV as a nonce (number used once) - it's public but random and
+ * unpredictable. A secure random IV can be created as follows
+ *
+ * cipher = ...
+ * cipher.encrypt
+ * key = cipher.random_key
+ * iv = cipher.random_iv # also sets the generated IV on the Cipher
+ *
+ * Although the key is generally a random value, too, it is a bad choice
+ * as an IV. There are elaborate ways how an attacker can take advantage
+ * of such an IV. As a general rule of thumb, exposing the key directly
+ * or indirectly should be avoided at all cost and exceptions only be
+ * made with good reason.
+ *
+ * === Calling Cipher#final
+ *
+ * ECB (which should not be used) and CBC are both block-based modes.
+ * This means that unlike for the other streaming-based modes, they
+ * operate on fixed-size blocks of data, and therefore they require a
+ * "finalization" step to produce or correctly decrypt the last block of
+ * data by appropriately handling some form of padding. Therefore it is
+ * essential to add the output of OpenSSL::Cipher#final to your
+ * encryption/decryption buffer or you will end up with decryption errors
+ * or truncated data.
+ *
+ * Although this is not really necessary for streaming-mode ciphers, it is
+ * still recommended to apply the same pattern of adding the output of
+ * Cipher#final there as well - it also enables you to switch between
+ * modes more easily in the future.
+ *
+ * === Encrypting and decrypting some data
+ *
+ * data = "Very, very confidential data"
+ *
+ * cipher = OpenSSL::Cipher::AES.new(128, :CBC)
+ * cipher.encrypt
+ * key = cipher.random_key
+ * iv = cipher.random_iv
+ *
+ * encrypted = cipher.update(data) + cipher.final
+ * ...
+ * decipher = OpenSSL::Cipher::AES.new(128, :CBC)
+ * decipher.decrypt
+ * decipher.key = key
+ * decipher.iv = iv
+ *
+ * plain = decipher.update(encrypted) + decipher.final
+ *
+ * puts data == plain #=> true
+ *
+ * === Authenticated Encryption and Associated Data (AEAD)
+ *
+ * If the OpenSSL version used supports it, an Authenticated Encryption
+ * mode (such as GCM or CCM) should always be preferred over any
+ * unauthenticated mode. Currently, OpenSSL supports AE only in combination
+ * with Associated Data (AEAD) where additional associated data is included
+ * in the encryption process to compute a tag at the end of the encryption.
+ * This tag will also be used in the decryption process and by verifying
+ * its validity, the authenticity of a given ciphertext is established.
+ *
+ * This is superior to unauthenticated modes in that it allows to detect
+ * if somebody effectively changed the ciphertext after it had been
+ * encrypted. This prevents malicious modifications of the ciphertext that
+ * could otherwise be exploited to modify ciphertexts in ways beneficial to
+ * potential attackers.
+ *
+ * If no associated data is needed for encryption and later decryption,
+ * the OpenSSL library still requires a value to be set - "" may be used in
+ * case none is available. An example using the GCM (Galois Counter Mode):
+ *
+ * cipher = OpenSSL::Cipher::AES.new(128, :GCM)
+ * cipher.encrypt
+ * key = cipher.random_key
+ * iv = cipher.random_iv
+ * cipher.auth_data = ""
+ *
+ * encrypted = cipher.update(data) + cipher.final
+ * tag = cipher.auth_tag
+ *
+ * decipher = OpenSSL::Cipher::AES.new(128, :GCM)
+ * decipher.decrypt
+ * decipher.key = key
+ * decipher.iv = iv
+ * decipher.auth_tag = tag
+ * decipher.auth_data = ""
+ *
+ * plain = decipher.update(encrypted) + decipher.final
+ *
+ * puts data == plain #=> true
+ */
+ cCipher = rb_define_class_under(mOSSL, "Cipher", rb_cObject);
+ eCipherError = rb_define_class_under(cCipher, "CipherError", eOSSLError);
+
+ rb_define_alloc_func(cCipher, ossl_cipher_alloc);
+ rb_define_copy_func(cCipher, ossl_cipher_copy);
+ rb_define_module_function(cCipher, "ciphers", ossl_s_ciphers, 0);
+ rb_define_method(cCipher, "initialize", ossl_cipher_initialize, 1);
+ rb_define_method(cCipher, "reset", ossl_cipher_reset, 0);
+ rb_define_method(cCipher, "encrypt", ossl_cipher_encrypt, -1);
+ rb_define_method(cCipher, "decrypt", ossl_cipher_decrypt, -1);
+ rb_define_method(cCipher, "pkcs5_keyivgen", ossl_cipher_pkcs5_keyivgen, -1);
+ rb_define_method(cCipher, "update", ossl_cipher_update, -1);
+ rb_define_method(cCipher, "final", ossl_cipher_final, 0);
+ rb_define_method(cCipher, "name", ossl_cipher_name, 0);
+ rb_define_method(cCipher, "key=", ossl_cipher_set_key, 1);
+ rb_define_method(cCipher, "auth_data=", ossl_cipher_set_auth_data, 1);
+ rb_define_method(cCipher, "auth_tag=", ossl_cipher_set_auth_tag, 1);
+ rb_define_method(cCipher, "auth_tag", ossl_cipher_get_auth_tag, -1);
+ rb_define_method(cCipher, "authenticated?", ossl_cipher_is_authenticated, 0);
+ rb_define_method(cCipher, "key_len=", ossl_cipher_set_key_length, 1);
+ rb_define_method(cCipher, "key_len", ossl_cipher_key_length, 0);
+ rb_define_method(cCipher, "iv=", ossl_cipher_set_iv, 1);
+ rb_define_method(cCipher, "iv_len", ossl_cipher_iv_length, 0);
+ rb_define_method(cCipher, "block_size", ossl_cipher_block_size, 0);
+ rb_define_method(cCipher, "padding=", ossl_cipher_set_padding, 1);
+}
+
diff --git a/jni/ruby/ext/openssl/ossl_cipher.h b/jni/ruby/ext/openssl/ossl_cipher.h
new file mode 100644
index 0000000..869dbf7
--- /dev/null
+++ b/jni/ruby/ext/openssl/ossl_cipher.h
@@ -0,0 +1,22 @@
+/*
+ * $Id: ossl_cipher.h 25189 2009-10-02 12:04:37Z akr $
+ * 'OpenSSL for Ruby' project
+ * Copyright (C) 2001-2002 Michal Rokos <m.rokos@sh.cvut.cz>
+ * All rights reserved.
+ */
+/*
+ * This program is licenced under the same licence as Ruby.
+ * (See the file 'LICENCE'.)
+ */
+#if !defined(_OSSL_CIPHER_H_)
+#define _OSSL_CIPHER_H_
+
+extern VALUE cCipher;
+extern VALUE eCipherError;
+
+const EVP_CIPHER *GetCipherPtr(VALUE);
+VALUE ossl_cipher_new(const EVP_CIPHER *);
+void Init_ossl_cipher(void);
+
+#endif /* _OSSL_CIPHER_H_ */
+
diff --git a/jni/ruby/ext/openssl/ossl_config.c b/jni/ruby/ext/openssl/ossl_config.c
new file mode 100644
index 0000000..af92b4b
--- /dev/null
+++ b/jni/ruby/ext/openssl/ossl_config.c
@@ -0,0 +1,83 @@
+/*
+ * $Id: ossl_config.c 47744 2014-09-30 05:25:32Z nobu $
+ * 'OpenSSL for Ruby' project
+ * Copyright (C) 2001-2002 Michal Rokos <m.rokos@sh.cvut.cz>
+ * All rights reserved.
+ */
+/*
+ * This program is licenced under the same licence as Ruby.
+ * (See the file 'LICENCE'.)
+ */
+#include "ossl.h"
+
+
+/*
+ * Classes
+ */
+VALUE cConfig;
+/* Document-class: OpenSSL::ConfigError
+ *
+ * General error for openssl library configuration files. Including formatting,
+ * parsing errors, etc.
+ */
+VALUE eConfigError;
+
+/*
+ * Public
+ */
+
+/*
+ * GetConfigPtr is a public C-level function for getting OpenSSL CONF struct
+ * from an OpenSSL::Config(eConfig) instance. We decided to implement
+ * OpenSSL::Config in Ruby level but we need to pass native CONF struct for
+ * some OpenSSL features such as X509V3_EXT_*.
+ */
+CONF *
+GetConfigPtr(VALUE obj)
+{
+ CONF *conf;
+ VALUE str;
+ BIO *bio;
+ long eline = -1;
+
+ OSSL_Check_Kind(obj, cConfig);
+ str = rb_funcall(obj, rb_intern("to_s"), 0);
+ bio = ossl_obj2bio(str);
+ conf = NCONF_new(NULL);
+ if(!conf){
+ BIO_free(bio);
+ ossl_raise(eConfigError, NULL);
+ }
+ if(!NCONF_load_bio(conf, bio, &eline)){
+ BIO_free(bio);
+ NCONF_free(conf);
+ if (eline <= 0) ossl_raise(eConfigError, "wrong config format");
+ else ossl_raise(eConfigError, "error in line %d", eline);
+ ossl_raise(eConfigError, NULL);
+ }
+ BIO_free(bio);
+
+ return conf;
+}
+
+/* Document-const: DEFAULT_CONFIG_FILE
+ *
+ * The default system configuration file for openssl
+ */
+
+/*
+ * INIT
+ */
+void
+Init_ossl_config(void)
+{
+ char *default_config_file;
+ eConfigError = rb_define_class_under(mOSSL, "ConfigError", eOSSLError);
+ cConfig = rb_define_class_under(mOSSL, "Config", rb_cObject);
+
+ default_config_file = CONF_get1_default_config_file();
+ rb_define_const(cConfig, "DEFAULT_CONFIG_FILE",
+ rb_str_new2(default_config_file));
+ OPENSSL_free(default_config_file);
+ /* methods are defined by openssl/config.rb */
+}
diff --git a/jni/ruby/ext/openssl/ossl_config.h b/jni/ruby/ext/openssl/ossl_config.h
new file mode 100644
index 0000000..0e14341
--- /dev/null
+++ b/jni/ruby/ext/openssl/ossl_config.h
@@ -0,0 +1,22 @@
+/*
+ * $Id: ossl_config.h 25189 2009-10-02 12:04:37Z akr $
+ * 'OpenSSL for Ruby' project
+ * Copyright (C) 2001-2002 Michal Rokos <m.rokos@sh.cvut.cz>
+ * All rights reserved.
+ */
+/*
+ * This program is licenced under the same licence as Ruby.
+ * (See the file 'LICENCE'.)
+ */
+#if !defined(_OSSL_CONFIG_H_)
+#define _OSSL_CONFIG_H_
+
+extern VALUE cConfig;
+extern VALUE eConfigError;
+
+CONF* GetConfigPtr(VALUE obj);
+CONF* DupConfigPtr(VALUE obj);
+void Init_ossl_config(void);
+
+#endif /* _OSSL_CONFIG_H_ */
+
diff --git a/jni/ruby/ext/openssl/ossl_digest.c b/jni/ruby/ext/openssl/ossl_digest.c
new file mode 100644
index 0000000..fc969d0
--- /dev/null
+++ b/jni/ruby/ext/openssl/ossl_digest.c
@@ -0,0 +1,452 @@
+/*
+ * $Id: ossl_digest.c 48791 2014-12-12 21:57:44Z nobu $
+ * 'OpenSSL for Ruby' project
+ * Copyright (C) 2001-2002 Michal Rokos <m.rokos@sh.cvut.cz>
+ * All rights reserved.
+ */
+/*
+ * This program is licenced under the same licence as Ruby.
+ * (See the file 'LICENCE'.)
+ */
+#include "ossl.h"
+
+#define GetDigest(obj, ctx) do { \
+ TypedData_Get_Struct((obj), EVP_MD_CTX, &ossl_digest_type, (ctx)); \
+ if (!(ctx)) { \
+ ossl_raise(rb_eRuntimeError, "Digest CTX wasn't initialized!"); \
+ } \
+} while (0)
+#define SafeGetDigest(obj, ctx) do { \
+ OSSL_Check_Kind((obj), cDigest); \
+ GetDigest((obj), (ctx)); \
+} while (0)
+
+/*
+ * Classes
+ */
+VALUE cDigest;
+VALUE eDigestError;
+
+static VALUE ossl_digest_alloc(VALUE klass);
+
+static void
+ossl_digest_free(void *ctx)
+{
+ EVP_MD_CTX_destroy(ctx);
+}
+
+static const rb_data_type_t ossl_digest_type = {
+ "OpenSSL/Digest",
+ {
+ 0, ossl_digest_free,
+ },
+ 0, 0, RUBY_TYPED_FREE_IMMEDIATELY,
+};
+
+/*
+ * Public
+ */
+const EVP_MD *
+GetDigestPtr(VALUE obj)
+{
+ const EVP_MD *md;
+ ASN1_OBJECT *oid = NULL;
+
+ if (RB_TYPE_P(obj, T_STRING)) {
+ const char *name = StringValueCStr(obj);
+
+ md = EVP_get_digestbyname(name);
+ if (!md) {
+ oid = OBJ_txt2obj(name, 0);
+ md = EVP_get_digestbyobj(oid);
+ ASN1_OBJECT_free(oid);
+ }
+ if(!md)
+ ossl_raise(rb_eRuntimeError, "Unsupported digest algorithm (%s).", name);
+ } else {
+ EVP_MD_CTX *ctx;
+
+ SafeGetDigest(obj, ctx);
+
+ md = EVP_MD_CTX_md(ctx);
+ }
+
+ return md;
+}
+
+VALUE
+ossl_digest_new(const EVP_MD *md)
+{
+ VALUE ret;
+ EVP_MD_CTX *ctx;
+
+ ret = ossl_digest_alloc(cDigest);
+ GetDigest(ret, ctx);
+ if (EVP_DigestInit_ex(ctx, md, NULL) != 1) {
+ ossl_raise(eDigestError, "Digest initialization failed.");
+ }
+
+ return ret;
+}
+
+/*
+ * Private
+ */
+static VALUE
+ossl_digest_alloc(VALUE klass)
+{
+ EVP_MD_CTX *ctx;
+ VALUE obj;
+
+ ctx = EVP_MD_CTX_create();
+ if (ctx == NULL)
+ ossl_raise(rb_eRuntimeError, "EVP_MD_CTX_create() failed");
+ obj = TypedData_Wrap_Struct(klass, &ossl_digest_type, ctx);
+
+ return obj;
+}
+
+VALUE ossl_digest_update(VALUE, VALUE);
+
+/*
+ * call-seq:
+ * Digest.new(string [, data]) -> Digest
+ *
+ * Creates a Digest instance based on +string+, which is either the ln
+ * (long name) or sn (short name) of a supported digest algorithm.
+ * If +data+ (a +String+) is given, it is used as the initial input to the
+ * Digest instance, i.e.
+ * digest = OpenSSL::Digest.new('sha256', 'digestdata')
+ * is equal to
+ * digest = OpenSSL::Digest.new('sha256')
+ * digest.update('digestdata')
+ *
+ * === Example
+ * digest = OpenSSL::Digest.new('sha1')
+ *
+ *
+ */
+static VALUE
+ossl_digest_initialize(int argc, VALUE *argv, VALUE self)
+{
+ EVP_MD_CTX *ctx;
+ const EVP_MD *md;
+ VALUE type, data;
+
+ rb_scan_args(argc, argv, "11", &type, &data);
+ md = GetDigestPtr(type);
+ if (!NIL_P(data)) StringValue(data);
+
+ GetDigest(self, ctx);
+ if (EVP_DigestInit_ex(ctx, md, NULL) != 1) {
+ ossl_raise(eDigestError, "Digest initialization failed.");
+ }
+
+ if (!NIL_P(data)) return ossl_digest_update(self, data);
+ return self;
+}
+
+static VALUE
+ossl_digest_copy(VALUE self, VALUE other)
+{
+ EVP_MD_CTX *ctx1, *ctx2;
+
+ rb_check_frozen(self);
+ if (self == other) return self;
+
+ GetDigest(self, ctx1);
+ SafeGetDigest(other, ctx2);
+
+ if (!EVP_MD_CTX_copy(ctx1, ctx2)) {
+ ossl_raise(eDigestError, NULL);
+ }
+ return self;
+}
+
+/*
+ * call-seq:
+ * digest.reset -> self
+ *
+ * Resets the Digest in the sense that any Digest#update that has been
+ * performed is abandoned and the Digest is set to its initial state again.
+ *
+ */
+static VALUE
+ossl_digest_reset(VALUE self)
+{
+ EVP_MD_CTX *ctx;
+
+ GetDigest(self, ctx);
+ if (EVP_DigestInit_ex(ctx, EVP_MD_CTX_md(ctx), NULL) != 1) {
+ ossl_raise(eDigestError, "Digest initialization failed.");
+ }
+
+ return self;
+}
+
+/*
+ * call-seq:
+ * digest.update(string) -> aString
+ *
+ * Not every message digest can be computed in one single pass. If a message
+ * digest is to be computed from several subsequent sources, then each may
+ * be passed individually to the Digest instance.
+ *
+ * === Example
+ * digest = OpenSSL::Digest::SHA256.new
+ * digest.update('First input')
+ * digest << 'Second input' # equivalent to digest.update('Second input')
+ * result = digest.digest
+ *
+ */
+VALUE
+ossl_digest_update(VALUE self, VALUE data)
+{
+ EVP_MD_CTX *ctx;
+
+ StringValue(data);
+ GetDigest(self, ctx);
+ EVP_DigestUpdate(ctx, RSTRING_PTR(data), RSTRING_LEN(data));
+
+ return self;
+}
+
+/*
+ * call-seq:
+ * digest.finish -> aString
+ *
+ */
+static VALUE
+ossl_digest_finish(int argc, VALUE *argv, VALUE self)
+{
+ EVP_MD_CTX *ctx;
+ VALUE str;
+
+ rb_scan_args(argc, argv, "01", &str);
+
+ GetDigest(self, ctx);
+
+ if (NIL_P(str)) {
+ str = rb_str_new(NULL, EVP_MD_CTX_size(ctx));
+ } else {
+ StringValue(str);
+ rb_str_resize(str, EVP_MD_CTX_size(ctx));
+ }
+
+ EVP_DigestFinal_ex(ctx, (unsigned char *)RSTRING_PTR(str), NULL);
+
+ return str;
+}
+
+/*
+ * call-seq:
+ * digest.name -> string
+ *
+ * Returns the sn of this Digest instance.
+ *
+ * === Example
+ * digest = OpenSSL::Digest::SHA512.new
+ * puts digest.name # => SHA512
+ *
+ */
+static VALUE
+ossl_digest_name(VALUE self)
+{
+ EVP_MD_CTX *ctx;
+
+ GetDigest(self, ctx);
+
+ return rb_str_new2(EVP_MD_name(EVP_MD_CTX_md(ctx)));
+}
+
+/*
+ * call-seq:
+ * digest.digest_length -> integer
+ *
+ * Returns the output size of the digest, i.e. the length in bytes of the
+ * final message digest result.
+ *
+ * === Example
+ * digest = OpenSSL::Digest::SHA1.new
+ * puts digest.digest_length # => 20
+ *
+ */
+static VALUE
+ossl_digest_size(VALUE self)
+{
+ EVP_MD_CTX *ctx;
+
+ GetDigest(self, ctx);
+
+ return INT2NUM(EVP_MD_CTX_size(ctx));
+}
+
+/*
+ * call-seq:
+ * digest.block_length -> integer
+ *
+ * Returns the block length of the digest algorithm, i.e. the length in bytes
+ * of an individual block. Most modern algorithms partition a message to be
+ * digested into a sequence of fix-sized blocks that are processed
+ * consecutively.
+ *
+ * === Example
+ * digest = OpenSSL::Digest::SHA1.new
+ * puts digest.block_length # => 64
+ */
+static VALUE
+ossl_digest_block_length(VALUE self)
+{
+ EVP_MD_CTX *ctx;
+
+ GetDigest(self, ctx);
+
+ return INT2NUM(EVP_MD_CTX_block_size(ctx));
+}
+
+/*
+ * INIT
+ */
+void
+Init_ossl_digest(void)
+{
+ rb_require("digest");
+
+#if 0
+ mOSSL = rb_define_module("OpenSSL"); /* let rdoc know about mOSSL */
+#endif
+
+ /* Document-class: OpenSSL::Digest
+ *
+ * OpenSSL::Digest allows you to compute message digests (sometimes
+ * interchangeably called "hashes") of arbitrary data that are
+ * cryptographically secure, i.e. a Digest implements a secure one-way
+ * function.
+ *
+ * One-way functions offer some useful properties. E.g. given two
+ * distinct inputs the probability that both yield the same output
+ * is highly unlikely. Combined with the fact that every message digest
+ * algorithm has a fixed-length output of just a few bytes, digests are
+ * often used to create unique identifiers for arbitrary data. A common
+ * example is the creation of a unique id for binary documents that are
+ * stored in a database.
+ *
+ * Another useful characteristic of one-way functions (and thus the name)
+ * is that given a digest there is no indication about the original
+ * data that produced it, i.e. the only way to identify the original input
+ * is to "brute-force" through every possible combination of inputs.
+ *
+ * These characteristics make one-way functions also ideal companions
+ * for public key signature algorithms: instead of signing an entire
+ * document, first a hash of the document is produced with a considerably
+ * faster message digest algorithm and only the few bytes of its output
+ * need to be signed using the slower public key algorithm. To validate
+ * the integrity of a signed document, it suffices to re-compute the hash
+ * and verify that it is equal to that in the signature.
+ *
+ * Among the supported message digest algorithms are:
+ * * SHA, SHA1, SHA224, SHA256, SHA384 and SHA512
+ * * MD2, MD4, MDC2 and MD5
+ * * RIPEMD160
+ * * DSS, DSS1 (Pseudo algorithms to be used for DSA signatures. DSS is
+ * equal to SHA and DSS1 is equal to SHA1)
+ *
+ * For each of these algorithms, there is a sub-class of Digest that
+ * can be instantiated as simply as e.g.
+ *
+ * digest = OpenSSL::Digest::SHA1.new
+ *
+ * === Mapping between Digest class and sn/ln
+ *
+ * The sn (short names) and ln (long names) are defined in
+ * <openssl/object.h> and <openssl/obj_mac.h>. They are textual
+ * representations of ASN.1 OBJECT IDENTIFIERs. Each supported digest
+ * algorithm has an OBJECT IDENTIFIER associated to it and those again
+ * have short/long names assigned to them.
+ * E.g. the OBJECT IDENTIFIER for SHA-1 is 1.3.14.3.2.26 and its
+ * sn is "SHA1" and its ln is "sha1".
+ * ==== MD2
+ * * sn: MD2
+ * * ln: md2
+ * ==== MD4
+ * * sn: MD4
+ * * ln: md4
+ * ==== MD5
+ * * sn: MD5
+ * * ln: md5
+ * ==== SHA
+ * * sn: SHA
+ * * ln: SHA
+ * ==== SHA-1
+ * * sn: SHA1
+ * * ln: sha1
+ * ==== SHA-224
+ * * sn: SHA224
+ * * ln: sha224
+ * ==== SHA-256
+ * * sn: SHA256
+ * * ln: sha256
+ * ==== SHA-384
+ * * sn: SHA384
+ * * ln: sha384
+ * ==== SHA-512
+ * * sn: SHA512
+ * * ln: sha512
+ *
+ * "Breaking" a message digest algorithm means defying its one-way
+ * function characteristics, i.e. producing a collision or finding a way
+ * to get to the original data by means that are more efficient than
+ * brute-forcing etc. Most of the supported digest algorithms can be
+ * considered broken in this sense, even the very popular MD5 and SHA1
+ * algorithms. Should security be your highest concern, then you should
+ * probably rely on SHA224, SHA256, SHA384 or SHA512.
+ *
+ * === Hashing a file
+ *
+ * data = File.read('document')
+ * sha256 = OpenSSL::Digest::SHA256.new
+ * digest = sha256.digest(data)
+ *
+ * === Hashing several pieces of data at once
+ *
+ * data1 = File.read('file1')
+ * data2 = File.read('file2')
+ * data3 = File.read('file3')
+ * sha256 = OpenSSL::Digest::SHA256.new
+ * sha256 << data1
+ * sha256 << data2
+ * sha256 << data3
+ * digest = sha256.digest
+ *
+ * === Reuse a Digest instance
+ *
+ * data1 = File.read('file1')
+ * sha256 = OpenSSL::Digest::SHA256.new
+ * digest1 = sha256.digest(data1)
+ *
+ * data2 = File.read('file2')
+ * sha256.reset
+ * digest2 = sha256.digest(data2)
+ *
+ */
+ cDigest = rb_define_class_under(mOSSL, "Digest", rb_path2class("Digest::Class"));
+ /* Document-class: OpenSSL::Digest::DigestError
+ *
+ * Generic Exception class that is raised if an error occurs during a
+ * Digest operation.
+ */
+ eDigestError = rb_define_class_under(cDigest, "DigestError", eOSSLError);
+
+ rb_define_alloc_func(cDigest, ossl_digest_alloc);
+
+ rb_define_method(cDigest, "initialize", ossl_digest_initialize, -1);
+ rb_define_copy_func(cDigest, ossl_digest_copy);
+ rb_define_method(cDigest, "reset", ossl_digest_reset, 0);
+ rb_define_method(cDigest, "update", ossl_digest_update, 1);
+ rb_define_alias(cDigest, "<<", "update");
+ rb_define_private_method(cDigest, "finish", ossl_digest_finish, -1);
+ rb_define_method(cDigest, "digest_length", ossl_digest_size, 0);
+ rb_define_method(cDigest, "block_length", ossl_digest_block_length, 0);
+
+ rb_define_method(cDigest, "name", ossl_digest_name, 0);
+}
diff --git a/jni/ruby/ext/openssl/ossl_digest.h b/jni/ruby/ext/openssl/ossl_digest.h
new file mode 100644
index 0000000..1a67a42
--- /dev/null
+++ b/jni/ruby/ext/openssl/ossl_digest.h
@@ -0,0 +1,22 @@
+/*
+ * $Id: ossl_digest.h 25189 2009-10-02 12:04:37Z akr $
+ * 'OpenSSL for Ruby' project
+ * Copyright (C) 2001-2002 Michal Rokos <m.rokos@sh.cvut.cz>
+ * All rights reserved.
+ */
+/*
+ * This program is licenced under the same licence as Ruby.
+ * (See the file 'LICENCE'.)
+ */
+#if !defined(_OSSL_DIGEST_H_)
+#define _OSSL_DIGEST_H_
+
+extern VALUE cDigest;
+extern VALUE eDigestError;
+
+const EVP_MD *GetDigestPtr(VALUE);
+VALUE ossl_digest_new(const EVP_MD *);
+void Init_ossl_digest(void);
+
+#endif /* _OSSL_DIGEST_H_ */
+
diff --git a/jni/ruby/ext/openssl/ossl_engine.c b/jni/ruby/ext/openssl/ossl_engine.c
new file mode 100644
index 0000000..9341a0e
--- /dev/null
+++ b/jni/ruby/ext/openssl/ossl_engine.c
@@ -0,0 +1,598 @@
+/*
+ * $Id: ossl_engine.c 48792 2014-12-12 21:57:49Z nobu $
+ * 'OpenSSL for Ruby' project
+ * Copyright (C) 2003 GOTOU Yuuzou <gotoyuzo@notwork.org>
+ * All rights reserved.
+ */
+/*
+ * This program is licenced under the same licence as Ruby.
+ * (See the file 'LICENCE'.)
+ */
+#include "ossl.h"
+
+#if defined(OSSL_ENGINE_ENABLED)
+
+#define WrapEngine(klass, obj, engine) do { \
+ if (!(engine)) { \
+ ossl_raise(rb_eRuntimeError, "ENGINE wasn't initialized."); \
+ } \
+ (obj) = TypedData_Wrap_Struct((klass), &ossl_engine_type, (engine)); \
+} while(0)
+#define GetEngine(obj, engine) do { \
+ TypedData_Get_Struct((obj), ENGINE, &ossl_engine_type, (engine)); \
+ if (!(engine)) { \
+ ossl_raise(rb_eRuntimeError, "ENGINE wasn't initialized."); \
+ } \
+} while (0)
+#define SafeGetEngine(obj, engine) do { \
+ OSSL_Check_Kind((obj), cEngine); \
+ GetPKCS7((obj), (engine)); \
+} while (0)
+
+/*
+ * Classes
+ */
+/* Document-class: OpenSSL::Engine
+ *
+ * This class is the access to openssl's ENGINE cryptographic module
+ * implementation.
+ *
+ * See also, https://www.openssl.org/docs/crypto/engine.html
+ */
+VALUE cEngine;
+/* Document-class: OpenSSL::Engine::EngineError
+ *
+ * This is the generic exception for OpenSSL::Engine related errors
+ */
+VALUE eEngineError;
+
+/*
+ * Private
+ */
+#define OSSL_ENGINE_LOAD_IF_MATCH(x) \
+do{\
+ if(!strcmp(#x, RSTRING_PTR(name))){\
+ ENGINE_load_##x();\
+ return Qtrue;\
+ }\
+}while(0)
+
+static void
+ossl_engine_free(void *engine)
+{
+ ENGINE_free(engine);
+}
+
+static const rb_data_type_t ossl_engine_type = {
+ "OpenSSL/Engine",
+ {
+ 0, ossl_engine_free,
+ },
+ 0, 0, RUBY_TYPED_FREE_IMMEDIATELY,
+};
+
+/* Document-method: OpenSSL::Engine.load
+ *
+ * call-seq:
+ * load(enginename = nil)
+ *
+ * This method loads engines. If +name+ is nil, then all builtin engines are
+ * loaded. Otherwise, the given +name+, as a string, is loaded if available to
+ * your runtime, and returns true. If +name+ is not found, then nil is
+ * returned.
+ *
+ */
+static VALUE
+ossl_engine_s_load(int argc, VALUE *argv, VALUE klass)
+{
+#if !defined(HAVE_ENGINE_LOAD_BUILTIN_ENGINES)
+ return Qnil;
+#else
+ VALUE name;
+
+ rb_scan_args(argc, argv, "01", &name);
+ if(NIL_P(name)){
+ ENGINE_load_builtin_engines();
+ return Qtrue;
+ }
+ StringValue(name);
+#ifndef OPENSSL_NO_STATIC_ENGINE
+#if HAVE_ENGINE_LOAD_DYNAMIC
+ OSSL_ENGINE_LOAD_IF_MATCH(dynamic);
+#endif
+#if HAVE_ENGINE_LOAD_4758CCA
+ OSSL_ENGINE_LOAD_IF_MATCH(4758cca);
+#endif
+#if HAVE_ENGINE_LOAD_AEP
+ OSSL_ENGINE_LOAD_IF_MATCH(aep);
+#endif
+#if HAVE_ENGINE_LOAD_ATALLA
+ OSSL_ENGINE_LOAD_IF_MATCH(atalla);
+#endif
+#if HAVE_ENGINE_LOAD_CHIL
+ OSSL_ENGINE_LOAD_IF_MATCH(chil);
+#endif
+#if HAVE_ENGINE_LOAD_CSWIFT
+ OSSL_ENGINE_LOAD_IF_MATCH(cswift);
+#endif
+#if HAVE_ENGINE_LOAD_NURON
+ OSSL_ENGINE_LOAD_IF_MATCH(nuron);
+#endif
+#if HAVE_ENGINE_LOAD_SUREWARE
+ OSSL_ENGINE_LOAD_IF_MATCH(sureware);
+#endif
+#if HAVE_ENGINE_LOAD_UBSEC
+ OSSL_ENGINE_LOAD_IF_MATCH(ubsec);
+#endif
+#if HAVE_ENGINE_LOAD_PADLOCK
+ OSSL_ENGINE_LOAD_IF_MATCH(padlock);
+#endif
+#if HAVE_ENGINE_LOAD_CAPI
+ OSSL_ENGINE_LOAD_IF_MATCH(capi);
+#endif
+#if HAVE_ENGINE_LOAD_GMP
+ OSSL_ENGINE_LOAD_IF_MATCH(gmp);
+#endif
+#if HAVE_ENGINE_LOAD_GOST
+ OSSL_ENGINE_LOAD_IF_MATCH(gost);
+#endif
+#if HAVE_ENGINE_LOAD_CRYPTODEV
+ OSSL_ENGINE_LOAD_IF_MATCH(cryptodev);
+#endif
+#if HAVE_ENGINE_LOAD_AESNI
+ OSSL_ENGINE_LOAD_IF_MATCH(aesni);
+#endif
+#endif
+#ifdef HAVE_ENGINE_LOAD_OPENBSD_DEV_CRYPTO
+ OSSL_ENGINE_LOAD_IF_MATCH(openbsd_dev_crypto);
+#endif
+ OSSL_ENGINE_LOAD_IF_MATCH(openssl);
+ rb_warning("no such builtin loader for `%s'", RSTRING_PTR(name));
+ return Qnil;
+#endif /* HAVE_ENGINE_LOAD_BUILTIN_ENGINES */
+}
+
+/* Document-method: OpenSSL::Engine.cleanup
+ * call-seq:
+ * OpenSSL::Engine.cleanup
+ *
+ * It is only necessary to run cleanup when engines are loaded via
+ * OpenSSL::Engine.load. However, running cleanup before exit is recommended.
+ *
+ * See also, https://www.openssl.org/docs/crypto/engine.html
+ */
+static VALUE
+ossl_engine_s_cleanup(VALUE self)
+{
+#if defined(HAVE_ENGINE_CLEANUP)
+ ENGINE_cleanup();
+#endif
+ return Qnil;
+}
+
+/* Document-method: OpenSSL::Engine.engines
+ *
+ * Returns an array of currently loaded engines.
+ */
+static VALUE
+ossl_engine_s_engines(VALUE klass)
+{
+ ENGINE *e;
+ VALUE ary, obj;
+
+ ary = rb_ary_new();
+ for(e = ENGINE_get_first(); e; e = ENGINE_get_next(e)){
+ /* Need a ref count of two here because of ENGINE_free being
+ * called internally by OpenSSL when moving to the next ENGINE
+ * and by us when releasing the ENGINE reference */
+ ENGINE_up_ref(e);
+ WrapEngine(klass, obj, e);
+ rb_ary_push(ary, obj);
+ }
+
+ return ary;
+}
+
+/* Document-method: OpenSSL::Engine.by_id
+ *
+ * call-seq:
+ * by_id(name) -> engine
+ *
+ * Fetch the engine as specified by the +id+ String
+ *
+ * OpenSSL::Engine.by_id("openssl")
+ * => #<OpenSSL::Engine id="openssl" name="Software engine support">
+ *
+ * See OpenSSL::Engine.engines for the currently loaded engines
+ */
+static VALUE
+ossl_engine_s_by_id(VALUE klass, VALUE id)
+{
+ ENGINE *e;
+ VALUE obj;
+
+ StringValue(id);
+ ossl_engine_s_load(1, &id, klass);
+ if(!(e = ENGINE_by_id(RSTRING_PTR(id))))
+ ossl_raise(eEngineError, NULL);
+ WrapEngine(klass, obj, e);
+ if(rb_block_given_p()) rb_yield(obj);
+ if(!ENGINE_init(e))
+ ossl_raise(eEngineError, NULL);
+ ENGINE_ctrl(e, ENGINE_CTRL_SET_PASSWORD_CALLBACK,
+ 0, NULL, (void(*)(void))ossl_pem_passwd_cb);
+ ERR_clear_error();
+
+ return obj;
+}
+
+static VALUE
+ossl_engine_s_alloc(VALUE klass)
+{
+ ENGINE *e;
+ VALUE obj;
+
+ if (!(e = ENGINE_new())) {
+ ossl_raise(eEngineError, NULL);
+ }
+ WrapEngine(klass, obj, e);
+
+ return obj;
+}
+
+/* Document-method: OpenSSL::Engine#id
+ *
+ * Get the id for this engine
+ *
+ * OpenSSL::Engine.load
+ * OpenSSL::Engine.engines #=> [#<OpenSSL::Engine#>, ...]
+ * OpenSSL::Engine.engines.first.id
+ * #=> "rsax"
+ */
+static VALUE
+ossl_engine_get_id(VALUE self)
+{
+ ENGINE *e;
+ GetEngine(self, e);
+ return rb_str_new2(ENGINE_get_id(e));
+}
+
+/* Document-method: OpenSSL::Engine#name
+ *
+ * Get the descriptive name for this engine
+ *
+ * OpenSSL::Engine.load
+ * OpenSSL::Engine.engines #=> [#<OpenSSL::Engine#>, ...]
+ * OpenSSL::Engine.engines.first.name
+ * #=> "RSAX engine support"
+ *
+ */
+static VALUE
+ossl_engine_get_name(VALUE self)
+{
+ ENGINE *e;
+ GetEngine(self, e);
+ return rb_str_new2(ENGINE_get_name(e));
+}
+
+/* Document-method: OpenSSL::Engine#finish
+ *
+ * Releases all internal structural references for this engine.
+ *
+ * May raise an EngineError if the engine is unavailable
+ */
+static VALUE
+ossl_engine_finish(VALUE self)
+{
+ ENGINE *e;
+
+ GetEngine(self, e);
+ if(!ENGINE_finish(e)) ossl_raise(eEngineError, NULL);
+
+ return Qnil;
+}
+
+#if defined(HAVE_ENGINE_GET_CIPHER)
+/* Document-method: OpenSSL::Engine#cipher
+ *
+ * call-seq:
+ * engine.cipher(name) -> OpenSSL::Cipher
+ *
+ * This returns an OpenSSL::Cipher by +name+, if it is available in this
+ * engine.
+ *
+ * A EngineError will be raised if the cipher is unavailable.
+ *
+ * e = OpenSSL::Engine.by_id("openssl")
+ * => #<OpenSSL::Engine id="openssl" name="Software engine support">
+ * e.cipher("RC4")
+ * => #<OpenSSL::Cipher:0x007fc5cacc3048>
+ *
+ */
+static VALUE
+ossl_engine_get_cipher(VALUE self, VALUE name)
+{
+ ENGINE *e;
+ const EVP_CIPHER *ciph, *tmp;
+ char *s;
+ int nid;
+
+ s = StringValuePtr(name);
+ tmp = EVP_get_cipherbyname(s);
+ if(!tmp) ossl_raise(eEngineError, "no such cipher `%s'", s);
+ nid = EVP_CIPHER_nid(tmp);
+ GetEngine(self, e);
+ ciph = ENGINE_get_cipher(e, nid);
+ if(!ciph) ossl_raise(eEngineError, NULL);
+
+ return ossl_cipher_new(ciph);
+}
+#else
+#define ossl_engine_get_cipher rb_f_notimplement
+#endif
+
+#if defined(HAVE_ENGINE_GET_DIGEST)
+/* Document-method: OpenSSL::Engine#digest
+ *
+ * call-seq:
+ * engine.digest(name) -> OpenSSL::Digest
+ *
+ * This returns an OpenSSL::Digest by +name+.
+ *
+ * Will raise an EngineError if the digest is unavailable.
+ *
+ * e = OpenSSL::Engine.by_id("openssl")
+ * #=> #<OpenSSL::Engine id="openssl" name="Software engine support">
+ * e.digest("SHA1")
+ * #=> #<OpenSSL::Digest: da39a3ee5e6b4b0d3255bfef95601890afd80709>
+ * e.digest("zomg")
+ * #=> OpenSSL::Engine::EngineError: no such digest `zomg'
+ */
+static VALUE
+ossl_engine_get_digest(VALUE self, VALUE name)
+{
+ ENGINE *e;
+ const EVP_MD *md, *tmp;
+ char *s;
+ int nid;
+
+ s = StringValuePtr(name);
+ tmp = EVP_get_digestbyname(s);
+ if(!tmp) ossl_raise(eEngineError, "no such digest `%s'", s);
+ nid = EVP_MD_nid(tmp);
+ GetEngine(self, e);
+ md = ENGINE_get_digest(e, nid);
+ if(!md) ossl_raise(eEngineError, NULL);
+
+ return ossl_digest_new(md);
+}
+#else
+#define ossl_engine_get_digest rb_f_notimplement
+#endif
+
+/* Document-method: OpenSSL::Engine#load_private_key
+ *
+ * call-seq:
+ * engine.load_private_key(id = nil, data = nil) -> OpenSSL::PKey
+ *
+ * Loads the given private key by +id+ and +data+.
+ *
+ * An EngineError is raised of the OpenSSL::PKey is unavailable.
+ *
+ */
+static VALUE
+ossl_engine_load_privkey(int argc, VALUE *argv, VALUE self)
+{
+ ENGINE *e;
+ EVP_PKEY *pkey;
+ VALUE id, data, obj;
+ char *sid, *sdata;
+
+ rb_scan_args(argc, argv, "02", &id, &data);
+ sid = NIL_P(id) ? NULL : StringValuePtr(id);
+ sdata = NIL_P(data) ? NULL : StringValuePtr(data);
+ GetEngine(self, e);
+#if OPENSSL_VERSION_NUMBER < 0x00907000L
+ pkey = ENGINE_load_private_key(e, sid, sdata);
+#else
+ pkey = ENGINE_load_private_key(e, sid, NULL, sdata);
+#endif
+ if (!pkey) ossl_raise(eEngineError, NULL);
+ obj = ossl_pkey_new(pkey);
+ OSSL_PKEY_SET_PRIVATE(obj);
+
+ return obj;
+}
+
+/* Document-method: OpenSSL::Engine#load_public_key
+ *
+ * call-seq:
+ * engine.load_public_key(id = nil, data = nil) -> OpenSSL::PKey
+ *
+ * Loads the given private key by +id+ and +data+.
+ *
+ * An EngineError is raised of the OpenSSL::PKey is unavailable.
+ *
+ */
+static VALUE
+ossl_engine_load_pubkey(int argc, VALUE *argv, VALUE self)
+{
+ ENGINE *e;
+ EVP_PKEY *pkey;
+ VALUE id, data;
+ char *sid, *sdata;
+
+ rb_scan_args(argc, argv, "02", &id, &data);
+ sid = NIL_P(id) ? NULL : StringValuePtr(id);
+ sdata = NIL_P(data) ? NULL : StringValuePtr(data);
+ GetEngine(self, e);
+#if OPENSSL_VERSION_NUMBER < 0x00907000L
+ pkey = ENGINE_load_public_key(e, sid, sdata);
+#else
+ pkey = ENGINE_load_public_key(e, sid, NULL, sdata);
+#endif
+ if (!pkey) ossl_raise(eEngineError, NULL);
+
+ return ossl_pkey_new(pkey);
+}
+
+/* Document-method: OpenSSL::Engine#set_default
+ *
+ * call-seq:
+ * engine.set_default(flag)
+ *
+ * Set the defaults for this engine with the given +flag+.
+ *
+ * These flags are used to control combinations of algorithm methods.
+ *
+ * +flag+ can be one of the following, other flags are available depending on
+ * your OS.
+ *
+ * [All flags] 0xFFFF
+ * [No flags] 0x0000
+ *
+ * See also <openssl/engine.h>
+ */
+static VALUE
+ossl_engine_set_default(VALUE self, VALUE flag)
+{
+ ENGINE *e;
+ int f = NUM2INT(flag);
+
+ GetEngine(self, e);
+ ENGINE_set_default(e, f);
+
+ return Qtrue;
+}
+
+/* Document-method: OpenSSL::Engine#ctrl_cmd
+ *
+ * call-seq:
+ * engine.ctrl_cmd(command, value = nil) -> engine
+ *
+ * Send the given +command+ to this engine.
+ *
+ * Raises an EngineError if the +command+ fails.
+ */
+static VALUE
+ossl_engine_ctrl_cmd(int argc, VALUE *argv, VALUE self)
+{
+ ENGINE *e;
+ VALUE cmd, val;
+ int ret;
+
+ GetEngine(self, e);
+ rb_scan_args(argc, argv, "11", &cmd, &val);
+ StringValue(cmd);
+ if (!NIL_P(val)) StringValue(val);
+ ret = ENGINE_ctrl_cmd_string(e, RSTRING_PTR(cmd),
+ NIL_P(val) ? NULL : RSTRING_PTR(val), 0);
+ if (!ret) ossl_raise(eEngineError, NULL);
+
+ return self;
+}
+
+static VALUE
+ossl_engine_cmd_flag_to_name(int flag)
+{
+ switch(flag){
+ case ENGINE_CMD_FLAG_NUMERIC: return rb_str_new2("NUMERIC");
+ case ENGINE_CMD_FLAG_STRING: return rb_str_new2("STRING");
+ case ENGINE_CMD_FLAG_NO_INPUT: return rb_str_new2("NO_INPUT");
+ case ENGINE_CMD_FLAG_INTERNAL: return rb_str_new2("INTERNAL");
+ default: return rb_str_new2("UNKNOWN");
+ }
+}
+
+/* Document-method: OpenSSL::Engine#cmds
+ *
+ * Returns an array of command definitions for the current engine
+ */
+static VALUE
+ossl_engine_get_cmds(VALUE self)
+{
+ ENGINE *e;
+ const ENGINE_CMD_DEFN *defn, *p;
+ VALUE ary, tmp;
+
+ GetEngine(self, e);
+ ary = rb_ary_new();
+ if ((defn = ENGINE_get_cmd_defns(e)) != NULL){
+ for (p = defn; p->cmd_num > 0; p++){
+ tmp = rb_ary_new();
+ rb_ary_push(tmp, rb_str_new2(p->cmd_name));
+ rb_ary_push(tmp, rb_str_new2(p->cmd_desc));
+ rb_ary_push(tmp, ossl_engine_cmd_flag_to_name(p->cmd_flags));
+ rb_ary_push(ary, tmp);
+ }
+ }
+
+ return ary;
+}
+
+/* Document-method: OpenSSL::Engine#inspect
+ *
+ * Pretty print this engine
+ */
+static VALUE
+ossl_engine_inspect(VALUE self)
+{
+ ENGINE *e;
+
+ GetEngine(self, e);
+ return rb_sprintf("#<%"PRIsVALUE" id=\"%s\" name=\"%s\">",
+ rb_obj_class(self), ENGINE_get_id(e), ENGINE_get_name(e));
+}
+
+#define DefEngineConst(x) rb_define_const(cEngine, #x, INT2NUM(ENGINE_##x))
+
+void
+Init_ossl_engine(void)
+{
+ cEngine = rb_define_class_under(mOSSL, "Engine", rb_cObject);
+ eEngineError = rb_define_class_under(cEngine, "EngineError", eOSSLError);
+
+ rb_define_alloc_func(cEngine, ossl_engine_s_alloc);
+ rb_define_singleton_method(cEngine, "load", ossl_engine_s_load, -1);
+ rb_define_singleton_method(cEngine, "cleanup", ossl_engine_s_cleanup, 0);
+ rb_define_singleton_method(cEngine, "engines", ossl_engine_s_engines, 0);
+ rb_define_singleton_method(cEngine, "by_id", ossl_engine_s_by_id, 1);
+ rb_undef_method(CLASS_OF(cEngine), "new");
+
+ rb_define_method(cEngine, "id", ossl_engine_get_id, 0);
+ rb_define_method(cEngine, "name", ossl_engine_get_name, 0);
+ rb_define_method(cEngine, "finish", ossl_engine_finish, 0);
+ rb_define_method(cEngine, "cipher", ossl_engine_get_cipher, 1);
+ rb_define_method(cEngine, "digest", ossl_engine_get_digest, 1);
+ rb_define_method(cEngine, "load_private_key", ossl_engine_load_privkey, -1);
+ rb_define_method(cEngine, "load_public_key", ossl_engine_load_pubkey, -1);
+ rb_define_method(cEngine, "set_default", ossl_engine_set_default, 1);
+ rb_define_method(cEngine, "ctrl_cmd", ossl_engine_ctrl_cmd, -1);
+ rb_define_method(cEngine, "cmds", ossl_engine_get_cmds, 0);
+ rb_define_method(cEngine, "inspect", ossl_engine_inspect, 0);
+
+ DefEngineConst(METHOD_RSA);
+ DefEngineConst(METHOD_DSA);
+ DefEngineConst(METHOD_DH);
+ DefEngineConst(METHOD_RAND);
+#ifdef ENGINE_METHOD_BN_MOD_EXP
+ DefEngineConst(METHOD_BN_MOD_EXP);
+#endif
+#ifdef ENGINE_METHOD_BN_MOD_EXP_CRT
+ DefEngineConst(METHOD_BN_MOD_EXP_CRT);
+#endif
+#ifdef ENGINE_METHOD_CIPHERS
+ DefEngineConst(METHOD_CIPHERS);
+#endif
+#ifdef ENGINE_METHOD_DIGESTS
+ DefEngineConst(METHOD_DIGESTS);
+#endif
+ DefEngineConst(METHOD_ALL);
+ DefEngineConst(METHOD_NONE);
+}
+#else
+void
+Init_ossl_engine(void)
+{
+}
+#endif
diff --git a/jni/ruby/ext/openssl/ossl_engine.h b/jni/ruby/ext/openssl/ossl_engine.h
new file mode 100644
index 0000000..88298b9
--- /dev/null
+++ b/jni/ruby/ext/openssl/ossl_engine.h
@@ -0,0 +1,20 @@
+/*
+ * $Id: ossl_engine.h 25189 2009-10-02 12:04:37Z akr $
+ * 'OpenSSL for Ruby' project
+ * Copyright (C) 2003 Michal Rokos <m.rokos@sh.cvut.cz>
+ * Copyright (C) 2003 GOTOU Yuuzou <gotoyuzo@notwork.org>
+ * All rights reserved.
+ */
+/*
+ * This program is licenced under the same licence as Ruby.
+ * (See the file 'LICENCE'.)
+ */
+#if !defined(OSSL_ENGINE_H)
+#define OSSL_ENGINE_H
+
+extern VALUE cEngine;
+extern VALUE eEngineError;
+
+void Init_ossl_engine(void);
+
+#endif /* OSSL_ENGINE_H */
diff --git a/jni/ruby/ext/openssl/ossl_hmac.c b/jni/ruby/ext/openssl/ossl_hmac.c
new file mode 100644
index 0000000..76f63f7
--- /dev/null
+++ b/jni/ruby/ext/openssl/ossl_hmac.c
@@ -0,0 +1,372 @@
+/*
+ * $Id: ossl_hmac.c 48793 2014-12-12 21:57:56Z nobu $
+ * 'OpenSSL for Ruby' project
+ * Copyright (C) 2001-2002 Michal Rokos <m.rokos@sh.cvut.cz>
+ * All rights reserved.
+ */
+/*
+ * This program is licenced under the same licence as Ruby.
+ * (See the file 'LICENCE'.)
+ */
+#if !defined(OPENSSL_NO_HMAC)
+
+#include "ossl.h"
+
+#define MakeHMAC(obj, klass, ctx) \
+ (obj) = TypedData_Make_Struct((klass), HMAC_CTX, &ossl_hmac_type, (ctx))
+#define GetHMAC(obj, ctx) do { \
+ TypedData_Get_Struct((obj), HMAC_CTX, &ossl_hmac_type, (ctx)); \
+ if (!(ctx)) { \
+ ossl_raise(rb_eRuntimeError, "HMAC wasn't initialized"); \
+ } \
+} while (0)
+#define SafeGetHMAC(obj, ctx) do { \
+ OSSL_Check_Kind((obj), cHMAC); \
+ GetHMAC((obj), (ctx)); \
+} while (0)
+
+/*
+ * Classes
+ */
+VALUE cHMAC;
+VALUE eHMACError;
+
+/*
+ * Public
+ */
+
+/*
+ * Private
+ */
+static void
+ossl_hmac_free(void *ctx)
+{
+ HMAC_CTX_cleanup(ctx);
+ ruby_xfree(ctx);
+}
+
+static const rb_data_type_t ossl_hmac_type = {
+ "OpenSSL/HMAC",
+ {
+ 0, ossl_hmac_free,
+ },
+ 0, 0, RUBY_TYPED_FREE_IMMEDIATELY,
+};
+
+static VALUE
+ossl_hmac_alloc(VALUE klass)
+{
+ HMAC_CTX *ctx;
+ VALUE obj;
+
+ MakeHMAC(obj, klass, ctx);
+ HMAC_CTX_init(ctx);
+
+ return obj;
+}
+
+
+/*
+ * call-seq:
+ * HMAC.new(key, digest) -> hmac
+ *
+ * Returns an instance of OpenSSL::HMAC set with the key and digest
+ * algorithm to be used. The instance represents the initial state of
+ * the message authentication code before any data has been processed.
+ * To process data with it, use the instance method #update with your
+ * data as an argument.
+ *
+ * === Example
+ *
+ * key = 'key'
+ * digest = OpenSSL::Digest.new('sha1')
+ * instance = OpenSSL::HMAC.new(key, digest)
+ * #=> f42bb0eeb018ebbd4597ae7213711ec60760843f
+ * instance.class
+ * #=> OpenSSL::HMAC
+ *
+ * === A note about comparisons
+ *
+ * Two instances won't be equal when they're compared, even if they have the
+ * same value. Use #to_s or #hexdigest to return the authentication code that
+ * the instance represents. For example:
+ *
+ * other_instance = OpenSSL::HMAC.new('key', OpenSSL::Digest.new('sha1'))
+ * #=> f42bb0eeb018ebbd4597ae7213711ec60760843f
+ * instance
+ * #=> f42bb0eeb018ebbd4597ae7213711ec60760843f
+ * instance == other_instance
+ * #=> false
+ * instance.to_s == other_instance.to_s
+ * #=> true
+ *
+ */
+static VALUE
+ossl_hmac_initialize(VALUE self, VALUE key, VALUE digest)
+{
+ HMAC_CTX *ctx;
+
+ StringValue(key);
+ GetHMAC(self, ctx);
+ HMAC_Init(ctx, RSTRING_PTR(key), RSTRING_LENINT(key),
+ GetDigestPtr(digest));
+
+ return self;
+}
+
+static VALUE
+ossl_hmac_copy(VALUE self, VALUE other)
+{
+ HMAC_CTX *ctx1, *ctx2;
+
+ rb_check_frozen(self);
+ if (self == other) return self;
+
+ GetHMAC(self, ctx1);
+ SafeGetHMAC(other, ctx2);
+
+ HMAC_CTX_copy(ctx1, ctx2);
+ return self;
+}
+
+/*
+ * call-seq:
+ * hmac.update(string) -> self
+ *
+ * Returns +self+ updated with the message to be authenticated.
+ * Can be called repeatedly with chunks of the message.
+ *
+ * === Example
+ *
+ * first_chunk = 'The quick brown fox jumps '
+ * second_chunk = 'over the lazy dog'
+ *
+ * instance.update(first_chunk)
+ * #=> 5b9a8038a65d571076d97fe783989e52278a492a
+ * instance.update(second_chunk)
+ * #=> de7c9b85b8b78aa6bc8a7a36f70a90701c9db4d9
+ *
+ */
+static VALUE
+ossl_hmac_update(VALUE self, VALUE data)
+{
+ HMAC_CTX *ctx;
+
+ StringValue(data);
+ GetHMAC(self, ctx);
+ HMAC_Update(ctx, (unsigned char *)RSTRING_PTR(data), RSTRING_LEN(data));
+
+ return self;
+}
+
+static void
+hmac_final(HMAC_CTX *ctx, unsigned char **buf, unsigned int *buf_len)
+{
+ HMAC_CTX final;
+
+ HMAC_CTX_copy(&final, ctx);
+ if (!(*buf = OPENSSL_malloc(HMAC_size(&final)))) {
+ HMAC_CTX_cleanup(&final);
+ OSSL_Debug("Allocating %d mem", HMAC_size(&final));
+ ossl_raise(eHMACError, "Cannot allocate memory for hmac");
+ }
+ HMAC_Final(&final, *buf, buf_len);
+ HMAC_CTX_cleanup(&final);
+}
+
+/*
+ * call-seq:
+ * hmac.digest -> string
+ *
+ * Returns the authentication code an instance represents as a binary string.
+ *
+ * === Example
+ *
+ * instance = OpenSSL::HMAC.new('key', OpenSSL::Digest.new('sha1'))
+ * #=> f42bb0eeb018ebbd4597ae7213711ec60760843f
+ * instance.digest
+ * #=> "\xF4+\xB0\xEE\xB0\x18\xEB\xBDE\x97\xAEr\x13q\x1E\xC6\a`\x84?"
+ *
+ */
+static VALUE
+ossl_hmac_digest(VALUE self)
+{
+ HMAC_CTX *ctx;
+ unsigned char *buf;
+ unsigned int buf_len;
+ VALUE digest;
+
+ GetHMAC(self, ctx);
+ hmac_final(ctx, &buf, &buf_len);
+ digest = ossl_buf2str((char *)buf, buf_len);
+
+ return digest;
+}
+
+/*
+ * call-seq:
+ * hmac.hexdigest -> string
+ *
+ * Returns the authentication code an instance represents as a hex-encoded
+ * string.
+ *
+ */
+static VALUE
+ossl_hmac_hexdigest(VALUE self)
+{
+ HMAC_CTX *ctx;
+ unsigned char *buf;
+ char *hexbuf;
+ unsigned int buf_len;
+ VALUE hexdigest;
+
+ GetHMAC(self, ctx);
+ hmac_final(ctx, &buf, &buf_len);
+ if (string2hex(buf, buf_len, &hexbuf, NULL) != 2 * (int)buf_len) {
+ OPENSSL_free(buf);
+ ossl_raise(eHMACError, "Memory alloc error");
+ }
+ OPENSSL_free(buf);
+ hexdigest = ossl_buf2str(hexbuf, 2 * buf_len);
+
+ return hexdigest;
+}
+
+/*
+ * call-seq:
+ * hmac.reset -> self
+ *
+ * Returns +self+ as it was when it was first initialized, with all processed
+ * data cleared from it.
+ *
+ * === Example
+ *
+ * data = "The quick brown fox jumps over the lazy dog"
+ * instance = OpenSSL::HMAC.new('key', OpenSSL::Digest.new('sha1'))
+ * #=> f42bb0eeb018ebbd4597ae7213711ec60760843f
+ *
+ * instance.update(data)
+ * #=> de7c9b85b8b78aa6bc8a7a36f70a90701c9db4d9
+ * instance.reset
+ * #=> f42bb0eeb018ebbd4597ae7213711ec60760843f
+ *
+ */
+static VALUE
+ossl_hmac_reset(VALUE self)
+{
+ HMAC_CTX *ctx;
+
+ GetHMAC(self, ctx);
+ HMAC_Init(ctx, NULL, 0, NULL);
+
+ return self;
+}
+
+/*
+ * call-seq:
+ * HMAC.digest(digest, key, data) -> aString
+ *
+ * Returns the authentication code as a binary string. The +digest+ parameter
+ * must be an instance of OpenSSL::Digest.
+ *
+ * === Example
+ *
+ * key = 'key'
+ * data = 'The quick brown fox jumps over the lazy dog'
+ * digest = OpenSSL::Digest.new('sha1')
+ *
+ * hmac = OpenSSL::HMAC.digest(digest, key, data)
+ * #=> "\xDE|\x9B\x85\xB8\xB7\x8A\xA6\xBC\x8Az6\xF7\n\x90p\x1C\x9D\xB4\xD9"
+ *
+ */
+static VALUE
+ossl_hmac_s_digest(VALUE klass, VALUE digest, VALUE key, VALUE data)
+{
+ unsigned char *buf;
+ unsigned int buf_len;
+
+ StringValue(key);
+ StringValue(data);
+ buf = HMAC(GetDigestPtr(digest), RSTRING_PTR(key), RSTRING_LENINT(key),
+ (unsigned char *)RSTRING_PTR(data), RSTRING_LEN(data), NULL, &buf_len);
+
+ return rb_str_new((const char *)buf, buf_len);
+}
+
+/*
+ * call-seq:
+ * HMAC.hexdigest(digest, key, data) -> aString
+ *
+ * Returns the authentication code as a hex-encoded string. The +digest+
+ * parameter must be an instance of OpenSSL::Digest.
+ *
+ * === Example
+ *
+ * key = 'key'
+ * data = 'The quick brown fox jumps over the lazy dog'
+ * digest = OpenSSL::Digest.new('sha1')
+ *
+ * hmac = OpenSSL::HMAC.hexdigest(digest, key, data)
+ * #=> "de7c9b85b8b78aa6bc8a7a36f70a90701c9db4d9"
+ *
+ */
+static VALUE
+ossl_hmac_s_hexdigest(VALUE klass, VALUE digest, VALUE key, VALUE data)
+{
+ unsigned char *buf;
+ char *hexbuf;
+ unsigned int buf_len;
+ VALUE hexdigest;
+
+ StringValue(key);
+ StringValue(data);
+
+ buf = HMAC(GetDigestPtr(digest), RSTRING_PTR(key), RSTRING_LENINT(key),
+ (unsigned char *)RSTRING_PTR(data), RSTRING_LEN(data), NULL, &buf_len);
+ if (string2hex(buf, buf_len, &hexbuf, NULL) != 2 * (int)buf_len) {
+ ossl_raise(eHMACError, "Cannot convert buf to hexbuf");
+ }
+ hexdigest = ossl_buf2str(hexbuf, 2 * buf_len);
+
+ return hexdigest;
+}
+
+/*
+ * INIT
+ */
+void
+Init_ossl_hmac(void)
+{
+#if 0
+ /* :nodoc: */
+ mOSSL = rb_define_module("OpenSSL"); /* let rdoc know about mOSSL */
+#endif
+
+ eHMACError = rb_define_class_under(mOSSL, "HMACError", eOSSLError);
+
+ cHMAC = rb_define_class_under(mOSSL, "HMAC", rb_cObject);
+
+ rb_define_alloc_func(cHMAC, ossl_hmac_alloc);
+ rb_define_singleton_method(cHMAC, "digest", ossl_hmac_s_digest, 3);
+ rb_define_singleton_method(cHMAC, "hexdigest", ossl_hmac_s_hexdigest, 3);
+
+ rb_define_method(cHMAC, "initialize", ossl_hmac_initialize, 2);
+ rb_define_copy_func(cHMAC, ossl_hmac_copy);
+
+ rb_define_method(cHMAC, "reset", ossl_hmac_reset, 0);
+ rb_define_method(cHMAC, "update", ossl_hmac_update, 1);
+ rb_define_alias(cHMAC, "<<", "update");
+ rb_define_method(cHMAC, "digest", ossl_hmac_digest, 0);
+ rb_define_method(cHMAC, "hexdigest", ossl_hmac_hexdigest, 0);
+ rb_define_alias(cHMAC, "inspect", "hexdigest");
+ rb_define_alias(cHMAC, "to_s", "hexdigest");
+}
+
+#else /* NO_HMAC */
+# warning >>> OpenSSL is compiled without HMAC support <<<
+void
+Init_ossl_hmac(void)
+{
+ rb_warning("HMAC is not available: OpenSSL is compiled without HMAC.");
+}
+#endif /* NO_HMAC */
diff --git a/jni/ruby/ext/openssl/ossl_hmac.h b/jni/ruby/ext/openssl/ossl_hmac.h
new file mode 100644
index 0000000..0b846c2
--- /dev/null
+++ b/jni/ruby/ext/openssl/ossl_hmac.h
@@ -0,0 +1,19 @@
+/*
+ * $Id: ossl_hmac.h 25189 2009-10-02 12:04:37Z akr $
+ * 'OpenSSL for Ruby' project
+ * Copyright (C) 2001-2002 Michal Rokos <m.rokos@sh.cvut.cz>
+ * All rights reserved.
+ */
+/*
+ * This program is licenced under the same licence as Ruby.
+ * (See the file 'LICENCE'.)
+ */
+#if !defined(_OSSL_HMAC_H_)
+#define _OSSL_HMAC_H_
+
+extern VALUE cHMAC;
+extern VALUE eHMACError;
+
+void Init_ossl_hmac(void);
+
+#endif /* _OSSL_HMAC_H_ */
diff --git a/jni/ruby/ext/openssl/ossl_ns_spki.c b/jni/ruby/ext/openssl/ossl_ns_spki.c
new file mode 100644
index 0000000..210ba10
--- /dev/null
+++ b/jni/ruby/ext/openssl/ossl_ns_spki.c
@@ -0,0 +1,404 @@
+/*
+ * $Id: ossl_ns_spki.c 48794 2014-12-12 21:58:03Z nobu $
+ * 'OpenSSL for Ruby' project
+ * Copyright (C) 2001-2002 Michal Rokos <m.rokos@sh.cvut.cz>
+ * All rights reserved.
+ */
+/*
+ * This program is licenced under the same licence as Ruby.
+ * (See the file 'LICENCE'.)
+ */
+#include "ossl.h"
+
+#define WrapSPKI(klass, obj, spki) do { \
+ if (!(spki)) { \
+ ossl_raise(rb_eRuntimeError, "SPKI wasn't initialized!"); \
+ } \
+ (obj) = TypedData_Wrap_Struct((klass), &ossl_netscape_spki_type, (spki)); \
+} while (0)
+#define GetSPKI(obj, spki) do { \
+ TypedData_Get_Struct((obj), NETSCAPE_SPKI, &ossl_netscape_spki_type, (spki)); \
+ if (!(spki)) { \
+ ossl_raise(rb_eRuntimeError, "SPKI wasn't initialized!"); \
+ } \
+} while (0)
+
+/*
+ * Classes
+ */
+VALUE mNetscape;
+VALUE cSPKI;
+VALUE eSPKIError;
+
+/*
+ * Public functions
+ */
+
+/*
+ * Private functions
+ */
+
+static void
+ossl_netscape_spki_free(void *spki)
+{
+ NETSCAPE_SPKI_free(spki);
+}
+
+static const rb_data_type_t ossl_netscape_spki_type = {
+ "OpenSSL/NETSCAPE_SPKI",
+ {
+ 0, ossl_netscape_spki_free,
+ },
+ 0, 0, RUBY_TYPED_FREE_IMMEDIATELY,
+};
+
+static VALUE
+ossl_spki_alloc(VALUE klass)
+{
+ NETSCAPE_SPKI *spki;
+ VALUE obj;
+
+ if (!(spki = NETSCAPE_SPKI_new())) {
+ ossl_raise(eSPKIError, NULL);
+ }
+ WrapSPKI(klass, obj, spki);
+
+ return obj;
+}
+
+/*
+ * call-seq:
+ * SPKI.new([request]) => spki
+ *
+ * === Parameters
+ * * +request+ - optional raw request, either in PEM or DER format.
+ */
+static VALUE
+ossl_spki_initialize(int argc, VALUE *argv, VALUE self)
+{
+ NETSCAPE_SPKI *spki;
+ VALUE buffer;
+ const unsigned char *p;
+
+ if (rb_scan_args(argc, argv, "01", &buffer) == 0) {
+ return self;
+ }
+ StringValue(buffer);
+ if (!(spki = NETSCAPE_SPKI_b64_decode(RSTRING_PTR(buffer), -1))) {
+ p = (unsigned char *)RSTRING_PTR(buffer);
+ if (!(spki = d2i_NETSCAPE_SPKI(NULL, &p, RSTRING_LEN(buffer)))) {
+ ossl_raise(eSPKIError, NULL);
+ }
+ }
+ NETSCAPE_SPKI_free(DATA_PTR(self));
+ DATA_PTR(self) = spki;
+ ERR_clear_error();
+
+ return self;
+}
+
+/*
+ * call-seq:
+ * spki.to_der => DER-encoded string
+ *
+ * Returns the DER encoding of this SPKI.
+ */
+static VALUE
+ossl_spki_to_der(VALUE self)
+{
+ NETSCAPE_SPKI *spki;
+ VALUE str;
+ long len;
+ unsigned char *p;
+
+ GetSPKI(self, spki);
+ if ((len = i2d_NETSCAPE_SPKI(spki, NULL)) <= 0)
+ ossl_raise(eX509CertError, NULL);
+ str = rb_str_new(0, len);
+ p = (unsigned char *)RSTRING_PTR(str);
+ if (i2d_NETSCAPE_SPKI(spki, &p) <= 0)
+ ossl_raise(eX509CertError, NULL);
+ ossl_str_adjust(str, p);
+
+ return str;
+}
+
+/*
+ * call-seq:
+ * spki.to_pem => PEM-encoded string
+ *
+ * Returns the PEM encoding of this SPKI.
+ */
+static VALUE
+ossl_spki_to_pem(VALUE self)
+{
+ NETSCAPE_SPKI *spki;
+ char *data;
+ VALUE str;
+
+ GetSPKI(self, spki);
+ if (!(data = NETSCAPE_SPKI_b64_encode(spki))) {
+ ossl_raise(eSPKIError, NULL);
+ }
+ str = ossl_buf2str(data, rb_long2int(strlen(data)));
+
+ return str;
+}
+
+/*
+ * call-seq:
+ * spki.to_text => string
+ *
+ * Returns a textual representation of this SPKI, useful for debugging
+ * purposes.
+ */
+static VALUE
+ossl_spki_print(VALUE self)
+{
+ NETSCAPE_SPKI *spki;
+ BIO *out;
+ BUF_MEM *buf;
+ VALUE str;
+
+ GetSPKI(self, spki);
+ if (!(out = BIO_new(BIO_s_mem()))) {
+ ossl_raise(eSPKIError, NULL);
+ }
+ if (!NETSCAPE_SPKI_print(out, spki)) {
+ BIO_free(out);
+ ossl_raise(eSPKIError, NULL);
+ }
+ BIO_get_mem_ptr(out, &buf);
+ str = rb_str_new(buf->data, buf->length);
+ BIO_free(out);
+
+ return str;
+}
+
+/*
+ * call-seq:
+ * spki.public_key => pkey
+ *
+ * Returns the public key associated with the SPKI, an instance of
+ * OpenSSL::PKey.
+ */
+static VALUE
+ossl_spki_get_public_key(VALUE self)
+{
+ NETSCAPE_SPKI *spki;
+ EVP_PKEY *pkey;
+
+ GetSPKI(self, spki);
+ if (!(pkey = NETSCAPE_SPKI_get_pubkey(spki))) { /* adds an reference */
+ ossl_raise(eSPKIError, NULL);
+ }
+
+ return ossl_pkey_new(pkey); /* NO DUP - OK */
+}
+
+/*
+ * call-seq:
+ * spki.public_key = pub => pkey
+ *
+ * === Parameters
+ * * +pub+ - the public key to be set for this instance
+ *
+ * Sets the public key to be associated with the SPKI, an instance of
+ * OpenSSL::PKey. This should be the public key corresponding to the
+ * private key used for signing the SPKI.
+ */
+static VALUE
+ossl_spki_set_public_key(VALUE self, VALUE key)
+{
+ NETSCAPE_SPKI *spki;
+
+ GetSPKI(self, spki);
+ if (!NETSCAPE_SPKI_set_pubkey(spki, GetPKeyPtr(key))) { /* NO NEED TO DUP */
+ ossl_raise(eSPKIError, NULL);
+ }
+
+ return key;
+}
+
+/*
+ * call-seq:
+ * spki.challenge => string
+ *
+ * Returns the challenge string associated with this SPKI.
+ */
+static VALUE
+ossl_spki_get_challenge(VALUE self)
+{
+ NETSCAPE_SPKI *spki;
+
+ GetSPKI(self, spki);
+ if (spki->spkac->challenge->length <= 0) {
+ OSSL_Debug("Challenge.length <= 0?");
+ return rb_str_new(0, 0);
+ }
+
+ return rb_str_new((const char *)spki->spkac->challenge->data,
+ spki->spkac->challenge->length);
+}
+
+/*
+ * call-seq:
+ * spki.challenge = str => string
+ *
+ * === Parameters
+ * * +str+ - the challenge string to be set for this instance
+ *
+ * Sets the challenge to be associated with the SPKI. May be used by the
+ * server, e.g. to prevent replay.
+ */
+static VALUE
+ossl_spki_set_challenge(VALUE self, VALUE str)
+{
+ NETSCAPE_SPKI *spki;
+
+ StringValue(str);
+ GetSPKI(self, spki);
+ if (!ASN1_STRING_set(spki->spkac->challenge, RSTRING_PTR(str),
+ RSTRING_LENINT(str))) {
+ ossl_raise(eSPKIError, NULL);
+ }
+
+ return str;
+}
+
+/*
+ * call-seq:
+ * spki.sign(key, digest) => spki
+ *
+ * === Parameters
+ * * +key+ - the private key to be used for signing this instance
+ * * +digest+ - the digest to be used for signing this instance
+ *
+ * To sign an SPKI, the private key corresponding to the public key set
+ * for this instance should be used, in addition to a digest algorithm in
+ * the form of an OpenSSL::Digest. The private key should be an instance of
+ * OpenSSL::PKey.
+ */
+static VALUE
+ossl_spki_sign(VALUE self, VALUE key, VALUE digest)
+{
+ NETSCAPE_SPKI *spki;
+ EVP_PKEY *pkey;
+ const EVP_MD *md;
+
+ pkey = GetPrivPKeyPtr(key); /* NO NEED TO DUP */
+ md = GetDigestPtr(digest);
+ GetSPKI(self, spki);
+ if (!NETSCAPE_SPKI_sign(spki, pkey, md)) {
+ ossl_raise(eSPKIError, NULL);
+ }
+
+ return self;
+}
+
+/*
+ * call-seq:
+ * spki.verify(key) => boolean
+ *
+ * === Parameters
+ * * +key+ - the public key to be used for verifying the SPKI signature
+ *
+ * Returns +true+ if the signature is valid, +false+ otherwise. To verify an
+ * SPKI, the public key contained within the SPKI should be used.
+ */
+static VALUE
+ossl_spki_verify(VALUE self, VALUE key)
+{
+ NETSCAPE_SPKI *spki;
+
+ GetSPKI(self, spki);
+ switch (NETSCAPE_SPKI_verify(spki, GetPKeyPtr(key))) { /* NO NEED TO DUP */
+ case 0:
+ return Qfalse;
+ case 1:
+ return Qtrue;
+ default:
+ ossl_raise(eSPKIError, NULL);
+ }
+ return Qnil; /* dummy */
+}
+
+/* Document-class: OpenSSL::Netscape::SPKI
+ *
+ * A Simple Public Key Infrastructure implementation (pronounced "spookey").
+ * The structure is defined as
+ * PublicKeyAndChallenge ::= SEQUENCE {
+ * spki SubjectPublicKeyInfo,
+ * challenge IA5STRING
+ * }
+ *
+ * SignedPublicKeyAndChallenge ::= SEQUENCE {
+ * publicKeyAndChallenge PublicKeyAndChallenge,
+ * signatureAlgorithm AlgorithmIdentifier,
+ * signature BIT STRING
+ * }
+ * where the definitions of SubjectPublicKeyInfo and AlgorithmIdentifier can
+ * be found in RFC5280. SPKI is typically used in browsers for generating
+ * a public/private key pair and a subsequent certificate request, using
+ * the HTML <keygen> element.
+ *
+ * == Examples
+ *
+ * === Creating an SPKI
+ * key = OpenSSL::PKey::RSA.new 2048
+ * spki = OpenSSL::Netscape::SPKI.new
+ * spki.challenge = "RandomChallenge"
+ * spki.public_key = key.public_key
+ * spki.sign(key, OpenSSL::Digest::SHA256.new)
+ * #send a request containing this to a server generating a certificate
+ * === Verifiying an SPKI request
+ * request = #...
+ * spki = OpenSSL::Netscape::SPKI.new request
+ * unless spki.verify(spki.public_key)
+ * # signature is invalid
+ * end
+ * #proceed
+ */
+
+/* Document-module: OpenSSL::Netscape
+ *
+ * OpenSSL::Netscape is a namespace for SPKI (Simple Public Key
+ * Infrastructure) which implements Signed Public Key and Challenge.
+ * See {RFC 2692}[http://tools.ietf.org/html/rfc2692] and {RFC
+ * 2693}[http://tools.ietf.org/html/rfc2692] for details.
+ */
+
+/* Document-class: OpenSSL::Netscape::SPKIError
+ *
+ * Generic Exception class that is raised if an error occurs during an
+ * operation on an instance of OpenSSL::Netscape::SPKI.
+ */
+
+void
+Init_ossl_ns_spki(void)
+{
+#if 0
+ mOSSL = rb_define_module("OpenSSL"); /* let rdoc know about mOSSL */
+#endif
+
+ mNetscape = rb_define_module_under(mOSSL, "Netscape");
+
+ eSPKIError = rb_define_class_under(mNetscape, "SPKIError", eOSSLError);
+
+ cSPKI = rb_define_class_under(mNetscape, "SPKI", rb_cObject);
+
+ rb_define_alloc_func(cSPKI, ossl_spki_alloc);
+ rb_define_method(cSPKI, "initialize", ossl_spki_initialize, -1);
+
+ rb_define_method(cSPKI, "to_der", ossl_spki_to_der, 0);
+ rb_define_method(cSPKI, "to_pem", ossl_spki_to_pem, 0);
+ rb_define_alias(cSPKI, "to_s", "to_pem");
+ rb_define_method(cSPKI, "to_text", ossl_spki_print, 0);
+ rb_define_method(cSPKI, "public_key", ossl_spki_get_public_key, 0);
+ rb_define_method(cSPKI, "public_key=", ossl_spki_set_public_key, 1);
+ rb_define_method(cSPKI, "sign", ossl_spki_sign, 2);
+ rb_define_method(cSPKI, "verify", ossl_spki_verify, 1);
+ rb_define_method(cSPKI, "challenge", ossl_spki_get_challenge, 0);
+ rb_define_method(cSPKI, "challenge=", ossl_spki_set_challenge, 1);
+}
+
diff --git a/jni/ruby/ext/openssl/ossl_ns_spki.h b/jni/ruby/ext/openssl/ossl_ns_spki.h
new file mode 100644
index 0000000..c84ef2b
--- /dev/null
+++ b/jni/ruby/ext/openssl/ossl_ns_spki.h
@@ -0,0 +1,21 @@
+/*
+ * $Id: ossl_ns_spki.h 25189 2009-10-02 12:04:37Z akr $
+ * 'OpenSSL for Ruby' project
+ * Copyright (C) 2001-2002 Michal Rokos <m.rokos@sh.cvut.cz>
+ * All rights reserved.
+ */
+/*
+ * This program is licenced under the same licence as Ruby.
+ * (See the file 'LICENCE'.)
+ */
+#if !defined(_OSSL_NS_SPKI_H_)
+#define _OSSL_NS_SPKI_H_
+
+extern VALUE mNetscape;
+extern VALUE cSPKI;
+extern VALUE eSPKIError;
+
+void Init_ossl_ns_spki(void);
+
+#endif /* _OSSL_NS_SPKI_H_ */
+
diff --git a/jni/ruby/ext/openssl/ossl_ocsp.c b/jni/ruby/ext/openssl/ossl_ocsp.c
new file mode 100644
index 0000000..8be60bd
--- /dev/null
+++ b/jni/ruby/ext/openssl/ossl_ocsp.c
@@ -0,0 +1,1244 @@
+/*
+ * $Id: ossl_ocsp.c 48798 2014-12-12 21:58:22Z nobu $
+ * 'OpenSSL for Ruby' project
+ * Copyright (C) 2003 Michal Rokos <m.rokos@sh.cvut.cz>
+ * Copyright (C) 2003 GOTOU Yuuzou <gotoyuzo@notwork.org>
+ * All rights reserved.
+ */
+/*
+ * This program is licenced under the same licence as Ruby.
+ * (See the file 'LICENCE'.)
+ */
+#include "ossl.h"
+
+#if defined(OSSL_OCSP_ENABLED)
+
+#define WrapOCSPReq(klass, obj, req) do { \
+ if(!(req)) ossl_raise(rb_eRuntimeError, "Request wasn't initialized!"); \
+ (obj) = TypedData_Wrap_Struct((klass), &ossl_ocsp_request_type, (req)); \
+} while (0)
+#define GetOCSPReq(obj, req) do { \
+ TypedData_Get_Struct((obj), OCSP_REQUEST, &ossl_ocsp_request_type, (req)); \
+ if(!(req)) ossl_raise(rb_eRuntimeError, "Request wasn't initialized!"); \
+} while (0)
+#define SafeGetOCSPReq(obj, req) do { \
+ OSSL_Check_Kind((obj), cOCSPReq); \
+ GetOCSPReq((obj), (req)); \
+} while (0)
+
+#define WrapOCSPRes(klass, obj, res) do { \
+ if(!(res)) ossl_raise(rb_eRuntimeError, "Response wasn't initialized!"); \
+ (obj) = TypedData_Wrap_Struct((klass), &ossl_ocsp_response_type, (res)); \
+} while (0)
+#define GetOCSPRes(obj, res) do { \
+ TypedData_Get_Struct((obj), OCSP_RESPONSE, &ossl_ocsp_response_type, (res)); \
+ if(!(res)) ossl_raise(rb_eRuntimeError, "Response wasn't initialized!"); \
+} while (0)
+#define SafeGetOCSPRes(obj, res) do { \
+ OSSL_Check_Kind((obj), cOCSPRes); \
+ GetOCSPRes((obj), (res)); \
+} while (0)
+
+#define WrapOCSPBasicRes(klass, obj, res) do { \
+ if(!(res)) ossl_raise(rb_eRuntimeError, "Response wasn't initialized!"); \
+ (obj) = TypedData_Wrap_Struct((klass), &ossl_ocsp_basicresp_type, (res)); \
+} while (0)
+#define GetOCSPBasicRes(obj, res) do { \
+ TypedData_Get_Struct((obj), OCSP_BASICRESP, &ossl_ocsp_basicresp_type, (res)); \
+ if(!(res)) ossl_raise(rb_eRuntimeError, "Response wasn't initialized!"); \
+} while (0)
+#define SafeGetOCSPBasicRes(obj, res) do { \
+ OSSL_Check_Kind((obj), cOCSPBasicRes); \
+ GetOCSPBasicRes((obj), (res)); \
+} while (0)
+
+#define WrapOCSPCertId(klass, obj, cid) do { \
+ if(!(cid)) ossl_raise(rb_eRuntimeError, "Cert ID wasn't initialized!"); \
+ (obj) = TypedData_Wrap_Struct((klass), &ossl_ocsp_certid_type, (cid)); \
+} while (0)
+#define GetOCSPCertId(obj, cid) do { \
+ TypedData_Get_Struct((obj), OCSP_CERTID, &ossl_ocsp_certid_type, (cid)); \
+ if(!(cid)) ossl_raise(rb_eRuntimeError, "Cert ID wasn't initialized!"); \
+} while (0)
+#define SafeGetOCSPCertId(obj, cid) do { \
+ OSSL_Check_Kind((obj), cOCSPCertId); \
+ GetOCSPCertId((obj), (cid)); \
+} while (0)
+
+VALUE mOCSP;
+VALUE eOCSPError;
+VALUE cOCSPReq;
+VALUE cOCSPRes;
+VALUE cOCSPBasicRes;
+VALUE cOCSPCertId;
+
+static void
+ossl_ocsp_request_free(void *ptr)
+{
+ OCSP_REQUEST_free(ptr);
+}
+
+static const rb_data_type_t ossl_ocsp_request_type = {
+ "OpenSSL/OCSP/REQUEST",
+ {
+ 0, ossl_ocsp_request_free,
+ },
+ 0, 0, RUBY_TYPED_FREE_IMMEDIATELY,
+};
+
+static void
+ossl_ocsp_response_free(void *ptr)
+{
+ OCSP_RESPONSE_free(ptr);
+}
+
+static const rb_data_type_t ossl_ocsp_response_type = {
+ "OpenSSL/OCSP/RESPONSE",
+ {
+ 0, ossl_ocsp_response_free,
+ },
+ 0, 0, RUBY_TYPED_FREE_IMMEDIATELY,
+};
+
+static void
+ossl_ocsp_basicresp_free(void *ptr)
+{
+ OCSP_BASICRESP_free(ptr);
+}
+
+static const rb_data_type_t ossl_ocsp_basicresp_type = {
+ "OpenSSL/OCSP/BASICRESP",
+ {
+ 0, ossl_ocsp_basicresp_free,
+ },
+ 0, 0, RUBY_TYPED_FREE_IMMEDIATELY,
+};
+
+static void
+ossl_ocsp_certid_free(void *ptr)
+{
+ OCSP_CERTID_free(ptr);
+}
+
+static const rb_data_type_t ossl_ocsp_certid_type = {
+ "OpenSSL/OCSP/CERTID",
+ {
+ 0, ossl_ocsp_certid_free,
+ },
+ 0, 0, RUBY_TYPED_FREE_IMMEDIATELY,
+};
+
+/*
+ * Public
+ */
+static VALUE
+ossl_ocspcertid_new(OCSP_CERTID *cid)
+{
+ VALUE obj;
+ WrapOCSPCertId(cOCSPCertId, obj, cid);
+ return obj;
+}
+
+/*
+ * OCSP::Resquest
+ */
+static VALUE
+ossl_ocspreq_alloc(VALUE klass)
+{
+ OCSP_REQUEST *req;
+ VALUE obj;
+
+ if (!(req = OCSP_REQUEST_new()))
+ ossl_raise(eOCSPError, NULL);
+ WrapOCSPReq(klass, obj, req);
+
+ return obj;
+}
+
+/*
+ * call-seq:
+ * OpenSSL::OCSP::Request.new -> request
+ * OpenSSL::OCSP::Request.new(request_der) -> request
+ *
+ * Creates a new OpenSSL::OCSP::Request. The request may be created empty or
+ * from a +request_der+ string.
+ */
+
+static VALUE
+ossl_ocspreq_initialize(int argc, VALUE *argv, VALUE self)
+{
+ VALUE arg;
+ const unsigned char *p;
+
+ rb_scan_args(argc, argv, "01", &arg);
+ if(!NIL_P(arg)){
+ OCSP_REQUEST *req = DATA_PTR(self), *x;
+ arg = ossl_to_der_if_possible(arg);
+ StringValue(arg);
+ p = (unsigned char*)RSTRING_PTR(arg);
+ x = d2i_OCSP_REQUEST(&req, &p, RSTRING_LEN(arg));
+ DATA_PTR(self) = req;
+ if(!x){
+ ossl_raise(eOCSPError, "cannot load DER encoded request");
+ }
+ }
+
+ return self;
+}
+
+/*
+ * call-seq:
+ * request.add_nonce(nonce = nil) -> request
+ *
+ * Adds a +nonce+ to the OCSP request. If no nonce is given a random one will
+ * be generated.
+ *
+ * The nonce is used to prevent replay attacks but some servers do not support
+ * it.
+ */
+
+static VALUE
+ossl_ocspreq_add_nonce(int argc, VALUE *argv, VALUE self)
+{
+ OCSP_REQUEST *req;
+ VALUE val;
+ int ret;
+
+ rb_scan_args(argc, argv, "01", &val);
+ if(NIL_P(val)) {
+ GetOCSPReq(self, req);
+ ret = OCSP_request_add1_nonce(req, NULL, -1);
+ }
+ else{
+ StringValue(val);
+ GetOCSPReq(self, req);
+ ret = OCSP_request_add1_nonce(req, (unsigned char *)RSTRING_PTR(val), RSTRING_LENINT(val));
+ }
+ if(!ret) ossl_raise(eOCSPError, NULL);
+
+ return self;
+}
+
+/*
+ * call-seq:
+ * request.check_nonce(response) -> result
+ *
+ * Checks the nonce validity for this request and +response+.
+ *
+ * The return value is one of the following:
+ *
+ * -1 :: nonce in request only.
+ * 0 :: nonces both present and not equal.
+ * 1 :: nonces present and equal.
+ * 2 :: nonces both absent.
+ * 3 :: nonce present in response only.
+ *
+ * For most responses, clients can check +result+ > 0. If a responder doesn't
+ * handle nonces <code>result.nonzero?</code> may be necessary. A result of
+ * <code>0</code> is always an error.
+ */
+
+static VALUE
+ossl_ocspreq_check_nonce(VALUE self, VALUE basic_resp)
+{
+ OCSP_REQUEST *req;
+ OCSP_BASICRESP *bs;
+ int res;
+
+ GetOCSPReq(self, req);
+ SafeGetOCSPBasicRes(basic_resp, bs);
+ res = OCSP_check_nonce(req, bs);
+
+ return INT2NUM(res);
+}
+
+/*
+ * call-seq:
+ * request.add_certid(certificate_id) -> request
+ *
+ * Adds +certificate_id+ to the request.
+ */
+
+static VALUE
+ossl_ocspreq_add_certid(VALUE self, VALUE certid)
+{
+ OCSP_REQUEST *req;
+ OCSP_CERTID *id;
+
+ GetOCSPReq(self, req);
+ GetOCSPCertId(certid, id);
+ if(!OCSP_request_add0_id(req, OCSP_CERTID_dup(id)))
+ ossl_raise(eOCSPError, NULL);
+
+ return self;
+}
+
+/*
+ * call-seq:
+ * request.certid -> [certificate_id, ...]
+ *
+ * Returns all certificate IDs in this request.
+ */
+
+static VALUE
+ossl_ocspreq_get_certid(VALUE self)
+{
+ OCSP_REQUEST *req;
+ OCSP_ONEREQ *one;
+ OCSP_CERTID *id;
+ VALUE ary, tmp;
+ int i, count;
+
+ GetOCSPReq(self, req);
+ count = OCSP_request_onereq_count(req);
+ ary = (count > 0) ? rb_ary_new() : Qnil;
+ for(i = 0; i < count; i++){
+ one = OCSP_request_onereq_get0(req, i);
+ if(!(id = OCSP_CERTID_dup(OCSP_onereq_get0_id(one))))
+ ossl_raise(eOCSPError, NULL);
+ WrapOCSPCertId(cOCSPCertId, tmp, id);
+ rb_ary_push(ary, tmp);
+ }
+
+ return ary;
+}
+
+/*
+ * call-seq:
+ * request.sign(signer_cert, signer_key) -> self
+ * request.sign(signer_cert, signer_key, certificates) -> self
+ * request.sign(signer_cert, signer_key, certificates, flags) -> self
+ *
+ * Signs this OCSP request using +signer_cert+ and +signer_key+.
+ * +certificates+ is an optional Array of certificates that may be included in
+ * the request.
+ */
+
+static VALUE
+ossl_ocspreq_sign(int argc, VALUE *argv, VALUE self)
+{
+ VALUE signer_cert, signer_key, certs, flags;
+ OCSP_REQUEST *req;
+ X509 *signer;
+ EVP_PKEY *key;
+ STACK_OF(X509) *x509s;
+ unsigned long flg;
+ int ret;
+
+ rb_scan_args(argc, argv, "22", &signer_cert, &signer_key, &certs, &flags);
+ signer = GetX509CertPtr(signer_cert);
+ key = GetPrivPKeyPtr(signer_key);
+ flg = NIL_P(flags) ? 0 : NUM2INT(flags);
+ if(NIL_P(certs)){
+ x509s = sk_X509_new_null();
+ flags |= OCSP_NOCERTS;
+ }
+ else x509s = ossl_x509_ary2sk(certs);
+ GetOCSPReq(self, req);
+ ret = OCSP_request_sign(req, signer, key, EVP_sha1(), x509s, flg);
+ sk_X509_pop_free(x509s, X509_free);
+ if(!ret) ossl_raise(eOCSPError, NULL);
+
+ return self;
+}
+
+/*
+ * call-seq:
+ * request.verify(certificates, store) -> true or false
+ * request.verify(certificates, store, flags) -> true or false
+ *
+ * Verifies this request using the given +certificates+ and X509 +store+.
+ */
+
+static VALUE
+ossl_ocspreq_verify(int argc, VALUE *argv, VALUE self)
+{
+ VALUE certs, store, flags;
+ OCSP_REQUEST *req;
+ STACK_OF(X509) *x509s;
+ X509_STORE *x509st;
+ int flg, result;
+
+ rb_scan_args(argc, argv, "21", &certs, &store, &flags);
+ x509st = GetX509StorePtr(store);
+ flg = NIL_P(flags) ? 0 : NUM2INT(flags);
+ x509s = ossl_x509_ary2sk(certs);
+ GetOCSPReq(self, req);
+ result = OCSP_request_verify(req, x509s, x509st, flg);
+ sk_X509_pop_free(x509s, X509_free);
+ if(!result) rb_warn("%s", ERR_error_string(ERR_peek_error(), NULL));
+
+ return result ? Qtrue : Qfalse;
+}
+
+/*
+ * Returns this request as a DER-encoded string
+ */
+
+static VALUE
+ossl_ocspreq_to_der(VALUE self)
+{
+ OCSP_REQUEST *req;
+ VALUE str;
+ unsigned char *p;
+ long len;
+
+ GetOCSPReq(self, req);
+ if((len = i2d_OCSP_REQUEST(req, NULL)) <= 0)
+ ossl_raise(eOCSPError, NULL);
+ str = rb_str_new(0, len);
+ p = (unsigned char *)RSTRING_PTR(str);
+ if(i2d_OCSP_REQUEST(req, &p) <= 0)
+ ossl_raise(eOCSPError, NULL);
+ ossl_str_adjust(str, p);
+
+ return str;
+}
+
+/*
+ * OCSP::Response
+ */
+
+/* call-seq:
+ * OpenSSL::OCSP::Response.create(status, basic_response = nil) -> response
+ *
+ * Creates an OpenSSL::OCSP::Response from +status+ and +basic_response+.
+ */
+
+static VALUE
+ossl_ocspres_s_create(VALUE klass, VALUE status, VALUE basic_resp)
+{
+ OCSP_BASICRESP *bs;
+ OCSP_RESPONSE *res;
+ VALUE obj;
+ int st = NUM2INT(status);
+
+ if(NIL_P(basic_resp)) bs = NULL;
+ else GetOCSPBasicRes(basic_resp, bs); /* NO NEED TO DUP */
+ if(!(res = OCSP_response_create(st, bs)))
+ ossl_raise(eOCSPError, NULL);
+ WrapOCSPRes(klass, obj, res);
+
+ return obj;
+}
+
+static VALUE
+ossl_ocspres_alloc(VALUE klass)
+{
+ OCSP_RESPONSE *res;
+ VALUE obj;
+
+ if(!(res = OCSP_RESPONSE_new()))
+ ossl_raise(eOCSPError, NULL);
+ WrapOCSPRes(klass, obj, res);
+
+ return obj;
+}
+
+/*
+ * call-seq:
+ * OpenSSL::OCSP::Response.new -> response
+ * OpenSSL::OCSP::Response.new(response_der) -> response
+ *
+ * Creates a new OpenSSL::OCSP::Response. The response may be created empty or
+ * from a +response_der+ string.
+ */
+
+static VALUE
+ossl_ocspres_initialize(int argc, VALUE *argv, VALUE self)
+{
+ VALUE arg;
+ const unsigned char *p;
+
+ rb_scan_args(argc, argv, "01", &arg);
+ if(!NIL_P(arg)){
+ OCSP_RESPONSE *res = DATA_PTR(self), *x;
+ arg = ossl_to_der_if_possible(arg);
+ StringValue(arg);
+ p = (unsigned char *)RSTRING_PTR(arg);
+ x = d2i_OCSP_RESPONSE(&res, &p, RSTRING_LEN(arg));
+ DATA_PTR(self) = res;
+ if(!x){
+ ossl_raise(eOCSPError, "cannot load DER encoded response");
+ }
+ }
+
+ return self;
+}
+
+/*
+ * call-seq:
+ * response.status -> Integer
+ *
+ * Returns the status of the response.
+ */
+
+static VALUE
+ossl_ocspres_status(VALUE self)
+{
+ OCSP_RESPONSE *res;
+ int st;
+
+ GetOCSPRes(self, res);
+ st = OCSP_response_status(res);
+
+ return INT2NUM(st);
+}
+
+/*
+ * call-seq:
+ * response.status_string -> String
+ *
+ * Returns a status string for the response.
+ */
+
+static VALUE
+ossl_ocspres_status_string(VALUE self)
+{
+ OCSP_RESPONSE *res;
+ int st;
+
+ GetOCSPRes(self, res);
+ st = OCSP_response_status(res);
+
+ return rb_str_new2(OCSP_response_status_str(st));
+}
+
+/*
+ * call-seq:
+ * response.basic
+ *
+ * Returns a BasicResponse for this response
+ */
+
+static VALUE
+ossl_ocspres_get_basic(VALUE self)
+{
+ OCSP_RESPONSE *res;
+ OCSP_BASICRESP *bs;
+ VALUE ret;
+
+ GetOCSPRes(self, res);
+ if(!(bs = OCSP_response_get1_basic(res)))
+ return Qnil;
+ WrapOCSPBasicRes(cOCSPBasicRes, ret, bs);
+
+ return ret;
+}
+
+/*
+ * call-seq:
+ * response.to_der -> String
+ *
+ * Returns this response as a DER-encoded string.
+ */
+
+static VALUE
+ossl_ocspres_to_der(VALUE self)
+{
+ OCSP_RESPONSE *res;
+ VALUE str;
+ long len;
+ unsigned char *p;
+
+ GetOCSPRes(self, res);
+ if((len = i2d_OCSP_RESPONSE(res, NULL)) <= 0)
+ ossl_raise(eOCSPError, NULL);
+ str = rb_str_new(0, len);
+ p = (unsigned char *)RSTRING_PTR(str);
+ if(i2d_OCSP_RESPONSE(res, &p) <= 0)
+ ossl_raise(eOCSPError, NULL);
+ ossl_str_adjust(str, p);
+
+ return str;
+}
+
+/*
+ * OCSP::BasicResponse
+ */
+static VALUE
+ossl_ocspbres_alloc(VALUE klass)
+{
+ OCSP_BASICRESP *bs;
+ VALUE obj;
+
+ if(!(bs = OCSP_BASICRESP_new()))
+ ossl_raise(eOCSPError, NULL);
+ WrapOCSPBasicRes(klass, obj, bs);
+
+ return obj;
+}
+
+/*
+ * call-seq:
+ * OpenSSL::OCSP::BasicResponse.new(*) -> basic_response
+ *
+ * Creates a new BasicResponse and ignores all arguments.
+ */
+
+static VALUE
+ossl_ocspbres_initialize(int argc, VALUE *argv, VALUE self)
+{
+ return self;
+}
+
+/*
+ * call-seq:
+ * basic_response.copy_nonce(request) -> Integer
+ *
+ * Copies the nonce from +request+ into this response. Returns 1 on success
+ * and 0 on failure.
+ */
+
+static VALUE
+ossl_ocspbres_copy_nonce(VALUE self, VALUE request)
+{
+ OCSP_BASICRESP *bs;
+ OCSP_REQUEST *req;
+ int ret;
+
+ GetOCSPBasicRes(self, bs);
+ SafeGetOCSPReq(request, req);
+ ret = OCSP_copy_nonce(bs, req);
+
+ return INT2NUM(ret);
+}
+
+/*
+ * call-seq:
+ * basic_response.add_nonce(nonce = nil)
+ *
+ * Adds +nonce+ to this response. If no nonce was provided a random nonce
+ * will be added.
+ */
+
+static VALUE
+ossl_ocspbres_add_nonce(int argc, VALUE *argv, VALUE self)
+{
+ OCSP_BASICRESP *bs;
+ VALUE val;
+ int ret;
+
+ rb_scan_args(argc, argv, "01", &val);
+ if(NIL_P(val)) {
+ GetOCSPBasicRes(self, bs);
+ ret = OCSP_basic_add1_nonce(bs, NULL, -1);
+ }
+ else{
+ StringValue(val);
+ GetOCSPBasicRes(self, bs);
+ ret = OCSP_basic_add1_nonce(bs, (unsigned char *)RSTRING_PTR(val), RSTRING_LENINT(val));
+ }
+ if(!ret) ossl_raise(eOCSPError, NULL);
+
+ return self;
+}
+
+/*
+ * call-seq:
+ * basic_response.add_status(certificate_id, status, reason, revocation_time, this_update, next_update, extensions) -> basic_response
+ *
+ * Adds a validation +status+ (0 for revoked, 1 for success) to this
+ * response for +certificate_id+. +reason+ describes the reason for the
+ * revocation, if any.
+ *
+ * The +revocation_time+, +this_update+ and +next_update+ are times for the
+ * certificate's revocation time, the time of this status and the next update
+ * time for a new status, respectively.
+ *
+ * +extensions+ may be an Array of OpenSSL::X509::Extension that will
+ * be added to this response or nil.
+ */
+
+static VALUE
+ossl_ocspbres_add_status(VALUE self, VALUE cid, VALUE status,
+ VALUE reason, VALUE revtime,
+ VALUE thisupd, VALUE nextupd, VALUE ext)
+{
+ OCSP_BASICRESP *bs;
+ OCSP_SINGLERESP *single;
+ OCSP_CERTID *id;
+ int st, rsn;
+ ASN1_TIME *ths, *nxt, *rev;
+ int error, i, rstatus = 0;
+ VALUE tmp;
+
+ st = NUM2INT(status);
+ rsn = NIL_P(status) ? 0 : NUM2INT(reason);
+ if(!NIL_P(ext)){
+ /* All ary's members should be X509Extension */
+ Check_Type(ext, T_ARRAY);
+ for (i = 0; i < RARRAY_LEN(ext); i++)
+ OSSL_Check_Kind(RARRAY_PTR(ext)[i], cX509Ext);
+ }
+
+ error = 0;
+ ths = nxt = rev = NULL;
+ if(!NIL_P(revtime)){
+ tmp = rb_protect(rb_Integer, revtime, &rstatus);
+ if(rstatus) goto err;
+ rev = X509_gmtime_adj(NULL, NUM2INT(tmp));
+ }
+ tmp = rb_protect(rb_Integer, thisupd, &rstatus);
+ if(rstatus) goto err;
+ ths = X509_gmtime_adj(NULL, NUM2INT(tmp));
+ tmp = rb_protect(rb_Integer, nextupd, &rstatus);
+ if(rstatus) goto err;
+ nxt = X509_gmtime_adj(NULL, NUM2INT(tmp));
+
+ GetOCSPBasicRes(self, bs);
+ SafeGetOCSPCertId(cid, id);
+ if(!(single = OCSP_basic_add1_status(bs, id, st, rsn, rev, ths, nxt))){
+ error = 1;
+ goto err;
+ }
+
+ if(!NIL_P(ext)){
+ X509_EXTENSION *x509ext;
+ sk_X509_EXTENSION_pop_free(single->singleExtensions, X509_EXTENSION_free);
+ single->singleExtensions = NULL;
+ for(i = 0; i < RARRAY_LEN(ext); i++){
+ x509ext = DupX509ExtPtr(RARRAY_PTR(ext)[i]);
+ if(!OCSP_SINGLERESP_add_ext(single, x509ext, -1)){
+ X509_EXTENSION_free(x509ext);
+ error = 1;
+ goto err;
+ }
+ X509_EXTENSION_free(x509ext);
+ }
+ }
+
+ err:
+ ASN1_TIME_free(ths);
+ ASN1_TIME_free(nxt);
+ ASN1_TIME_free(rev);
+ if(error) ossl_raise(eOCSPError, NULL);
+ if(rstatus) rb_jump_tag(rstatus);
+
+ return self;
+}
+
+/*
+ * call-seq:
+ * basic_response.status -> statuses
+ *
+ * Returns an Array of statuses for this response. Each status contains a
+ * CertificateId, the status (0 for success, 1 for revoked), the reason for
+ * the status, the revocation time, the time of this update, the time for the
+ * next update and a list of OpenSSL::X509::Extensions.
+ */
+
+static VALUE
+ossl_ocspbres_get_status(VALUE self)
+{
+ OCSP_BASICRESP *bs;
+ OCSP_SINGLERESP *single;
+ OCSP_CERTID *cid;
+ ASN1_TIME *revtime, *thisupd, *nextupd;
+ int status, reason;
+ X509_EXTENSION *x509ext;
+ VALUE ret, ary, ext;
+ int count, ext_count, i, j;
+
+ GetOCSPBasicRes(self, bs);
+ ret = rb_ary_new();
+ count = OCSP_resp_count(bs);
+ for(i = 0; i < count; i++){
+ single = OCSP_resp_get0(bs, i);
+ if(!single) continue;
+
+ revtime = thisupd = nextupd = NULL;
+ status = OCSP_single_get0_status(single, &reason, &revtime,
+ &thisupd, &nextupd);
+ if(status < 0) continue;
+ if(!(cid = OCSP_CERTID_dup(single->certId)))
+ ossl_raise(eOCSPError, NULL);
+ ary = rb_ary_new();
+ rb_ary_push(ary, ossl_ocspcertid_new(cid));
+ rb_ary_push(ary, INT2NUM(status));
+ rb_ary_push(ary, INT2NUM(reason));
+ rb_ary_push(ary, revtime ? asn1time_to_time(revtime) : Qnil);
+ rb_ary_push(ary, thisupd ? asn1time_to_time(thisupd) : Qnil);
+ rb_ary_push(ary, nextupd ? asn1time_to_time(nextupd) : Qnil);
+ ext = rb_ary_new();
+ ext_count = OCSP_SINGLERESP_get_ext_count(single);
+ for(j = 0; j < ext_count; j++){
+ x509ext = OCSP_SINGLERESP_get_ext(single, j);
+ rb_ary_push(ext, ossl_x509ext_new(x509ext));
+ }
+ rb_ary_push(ary, ext);
+ rb_ary_push(ret, ary);
+ }
+
+ return ret;
+}
+
+/*
+ * call-seq:
+ * basic_response.sign(signer_cert, signer_key) -> self
+ * basic_response.sign(signer_cert, signer_key, certificates) -> self
+ * basic_response.sign(signer_cert, signer_key, certificates, flags) -> self
+ *
+ * Signs this response using the +signer_cert+ and +signer_key+. Additional
+ * +certificates+ may be added to the signature along with a set of +flags+.
+ */
+
+static VALUE
+ossl_ocspbres_sign(int argc, VALUE *argv, VALUE self)
+{
+ VALUE signer_cert, signer_key, certs, flags;
+ OCSP_BASICRESP *bs;
+ X509 *signer;
+ EVP_PKEY *key;
+ STACK_OF(X509) *x509s;
+ unsigned long flg;
+ int ret;
+
+ rb_scan_args(argc, argv, "22", &signer_cert, &signer_key, &certs, &flags);
+ signer = GetX509CertPtr(signer_cert);
+ key = GetPrivPKeyPtr(signer_key);
+ flg = NIL_P(flags) ? 0 : NUM2INT(flags);
+ if(NIL_P(certs)){
+ x509s = sk_X509_new_null();
+ flg |= OCSP_NOCERTS;
+ }
+ else{
+ x509s = ossl_x509_ary2sk(certs);
+ }
+ GetOCSPBasicRes(self, bs);
+ ret = OCSP_basic_sign(bs, signer, key, EVP_sha1(), x509s, flg);
+ sk_X509_pop_free(x509s, X509_free);
+ if(!ret) ossl_raise(eOCSPError, NULL);
+
+ return self;
+}
+
+/*
+ * call-seq:
+ * basic_response.verify(certificates, store) -> true or false
+ * basic_response.verify(certificates, store, flags) -> true or false
+ *
+ * Verifies the signature of the response using the given +certificates+,
+ * +store+ and +flags+.
+ */
+static VALUE
+ossl_ocspbres_verify(int argc, VALUE *argv, VALUE self)
+{
+ VALUE certs, store, flags, result;
+ OCSP_BASICRESP *bs;
+ STACK_OF(X509) *x509s;
+ X509_STORE *x509st;
+ int flg;
+
+ rb_scan_args(argc, argv, "21", &certs, &store, &flags);
+ x509st = GetX509StorePtr(store);
+ flg = NIL_P(flags) ? 0 : NUM2INT(flags);
+ x509s = ossl_x509_ary2sk(certs);
+ GetOCSPBasicRes(self, bs);
+ result = OCSP_basic_verify(bs, x509s, x509st, flg) > 0 ? Qtrue : Qfalse;
+ sk_X509_pop_free(x509s, X509_free);
+ if(!result) rb_warn("%s", ERR_error_string(ERR_peek_error(), NULL));
+
+ return result;
+}
+
+/*
+ * OCSP::CertificateId
+ */
+static VALUE
+ossl_ocspcid_alloc(VALUE klass)
+{
+ OCSP_CERTID *id;
+ VALUE obj;
+
+ if(!(id = OCSP_CERTID_new()))
+ ossl_raise(eOCSPError, NULL);
+ WrapOCSPCertId(klass, obj, id);
+
+ return obj;
+}
+
+/*
+ * call-seq:
+ * OpenSSL::OCSP::CertificateId.new(subject, issuer, digest = nil) -> certificate_id
+ *
+ * Creates a new OpenSSL::OCSP::CertificateId for the given +subject+ and
+ * +issuer+ X509 certificates. The +digest+ is used to compute the
+ * certificate ID and must be an OpenSSL::Digest instance.
+ */
+
+static VALUE
+ossl_ocspcid_initialize(int argc, VALUE *argv, VALUE self)
+{
+ OCSP_CERTID *id, *newid;
+ X509 *x509s, *x509i;
+ VALUE subject, issuer, digest;
+ const EVP_MD *md;
+
+ if (rb_scan_args(argc, argv, "21", &subject, &issuer, &digest) == 0) {
+ return self;
+ }
+
+ x509s = GetX509CertPtr(subject); /* NO NEED TO DUP */
+ x509i = GetX509CertPtr(issuer); /* NO NEED TO DUP */
+
+ if (!NIL_P(digest)) {
+ md = GetDigestPtr(digest);
+ newid = OCSP_cert_to_id(md, x509s, x509i);
+ } else {
+ newid = OCSP_cert_to_id(NULL, x509s, x509i);
+ }
+ if(!newid)
+ ossl_raise(eOCSPError, NULL);
+ GetOCSPCertId(self, id);
+ OCSP_CERTID_free(id);
+ RDATA(self)->data = newid;
+
+ return self;
+}
+
+/*
+ * call-seq:
+ * certificate_id.cmp(other) -> true or false
+ *
+ * Compares this certificate id with +other+ and returns true if they are the
+ * same.
+ */
+static VALUE
+ossl_ocspcid_cmp(VALUE self, VALUE other)
+{
+ OCSP_CERTID *id, *id2;
+ int result;
+
+ GetOCSPCertId(self, id);
+ SafeGetOCSPCertId(other, id2);
+ result = OCSP_id_cmp(id, id2);
+
+ return (result == 0) ? Qtrue : Qfalse;
+}
+
+/*
+ * call-seq:
+ * certificate_id.cmp_issuer(other) -> true or false
+ *
+ * Compares this certificate id's issuer with +other+ and returns true if
+ * they are the same.
+ */
+
+static VALUE
+ossl_ocspcid_cmp_issuer(VALUE self, VALUE other)
+{
+ OCSP_CERTID *id, *id2;
+ int result;
+
+ GetOCSPCertId(self, id);
+ SafeGetOCSPCertId(other, id2);
+ result = OCSP_id_issuer_cmp(id, id2);
+
+ return (result == 0) ? Qtrue : Qfalse;
+}
+
+/*
+ * call-seq:
+ * certificate_id.get_serial -> Integer
+ *
+ * Returns the serial number of the issuing certificate.
+ */
+
+static VALUE
+ossl_ocspcid_get_serial(VALUE self)
+{
+ OCSP_CERTID *id;
+
+ GetOCSPCertId(self, id);
+
+ return asn1integer_to_num(id->serialNumber);
+}
+
+void
+Init_ossl_ocsp(void)
+{
+ /*
+ * OpenSSL::OCSP implements Online Certificate Status Protocol requests
+ * and responses.
+ *
+ * Creating and sending an OCSP request requires a subject certificate
+ * that contains an OCSP URL in an authorityInfoAccess extension and the
+ * issuer certificate for the subject certificate. First, load the issuer
+ * and subject certificates:
+ *
+ * subject = OpenSSL::X509::Certificate.new subject_pem
+ * issuer = OpenSSL::X509::Certificate.new issuer_pem
+ *
+ * To create the request we need to create a certificate ID for the
+ * subject certificate so the CA knows which certificate we are asking
+ * about:
+ *
+ * digest = OpenSSL::Digest::SHA1.new
+ * certificate_id =
+ * OpenSSL::OCSP::CertificateId.new subject, issuer, digest
+ *
+ * Then create a request and add the certificate ID to it:
+ *
+ * request = OpenSSL::OCSP::Request.new
+ * request.add_certid certificate_id
+ *
+ * Adding a nonce to the request protects against replay attacks but not
+ * all CA process the nonce.
+ *
+ * request.add_nonce
+ *
+ * To submit the request to the CA for verification we need to extract the
+ * OCSP URI from the subject certificate:
+ *
+ * authority_info_access = subject.extensions.find do |extension|
+ * extension.oid == 'authorityInfoAccess'
+ * end
+ *
+ * descriptions = authority_info_access.value.split "\n"
+ * ocsp = descriptions.find do |description|
+ * description.start_with? 'OCSP'
+ * end
+ *
+ * require 'uri'
+ *
+ * ocsp_uri = URI ocsp[/URI:(.*)/, 1]
+ *
+ * To submit the request we'll POST the request to the OCSP URI (per RFC
+ * 2560). Note that we only handle HTTP requests and don't handle any
+ * redirects in this example, so this is insufficient for serious use.
+ *
+ * require 'net/http'
+ *
+ * http_response =
+ * Net::HTTP.start ocsp_uri.hostname, ocsp.port do |http|
+ * http.post ocsp_uri.path, request.to_der,
+ * 'content-type' => 'application/ocsp-request'
+ * end
+ *
+ * response = OpenSSL::OCSP::Response.new http_response.body
+ * response_basic = response.basic
+ *
+ * First we check if the response has a valid signature. Without a valid
+ * signature we cannot trust it. If you get a failure here you may be
+ * missing a system certificate store or may be missing the intermediate
+ * certificates.
+ *
+ * store = OpenSSL::X509::Store.new
+ * store.set_default_paths
+ *
+ * unless response.verify [], store then
+ * raise 'response is not signed by a trusted certificate'
+ * end
+ *
+ * The response contains the status information (success/fail). We can
+ * display the status as a string:
+ *
+ * puts response.status_string #=> successful
+ *
+ * Next we need to know the response details to determine if the response
+ * matches our request. First we check the nonce. Again, not all CAs
+ * support a nonce. See Request#check_nonce for the meanings of the
+ * return values.
+ *
+ * p request.check_nonce basic_response #=> value from -1 to 3
+ *
+ * Then extract the status information from the basic response. (You can
+ * check multiple certificates in a request, but for this example we only
+ * submitted one.)
+ *
+ * response_certificate_id, status, reason, revocation_time,
+ * this_update, next_update, extensions = basic_response.status
+ *
+ * Then check the various fields.
+ *
+ * unless response_certificate_id == certificate_id then
+ * raise 'certificate id mismatch'
+ * end
+ *
+ * now = Time.now
+ *
+ * if this_update > now then
+ * raise 'update date is in the future'
+ * end
+ *
+ * if now > next_update then
+ * raise 'next update time has passed'
+ * end
+ */
+
+ mOCSP = rb_define_module_under(mOSSL, "OCSP");
+
+ /*
+ * OCSP error class.
+ */
+
+ eOCSPError = rb_define_class_under(mOCSP, "OCSPError", eOSSLError);
+
+ /*
+ * An OpenSSL::OCSP::Request contains the certificate information for
+ * determining if a certificate has been revoked or not. A Request can be
+ * created for a certificate or from a DER-encoded request created
+ * elsewhere.
+ */
+
+ cOCSPReq = rb_define_class_under(mOCSP, "Request", rb_cObject);
+ rb_define_alloc_func(cOCSPReq, ossl_ocspreq_alloc);
+ rb_define_method(cOCSPReq, "initialize", ossl_ocspreq_initialize, -1);
+ rb_define_method(cOCSPReq, "add_nonce", ossl_ocspreq_add_nonce, -1);
+ rb_define_method(cOCSPReq, "check_nonce", ossl_ocspreq_check_nonce, 1);
+ rb_define_method(cOCSPReq, "add_certid", ossl_ocspreq_add_certid, 1);
+ rb_define_method(cOCSPReq, "certid", ossl_ocspreq_get_certid, 0);
+ rb_define_method(cOCSPReq, "sign", ossl_ocspreq_sign, -1);
+ rb_define_method(cOCSPReq, "verify", ossl_ocspreq_verify, -1);
+ rb_define_method(cOCSPReq, "to_der", ossl_ocspreq_to_der, 0);
+
+ /*
+ * An OpenSSL::OCSP::Response contains the status of a certificate check
+ * which is created from an OpenSSL::OCSP::Request.
+ */
+
+ cOCSPRes = rb_define_class_under(mOCSP, "Response", rb_cObject);
+ rb_define_singleton_method(cOCSPRes, "create", ossl_ocspres_s_create, 2);
+ rb_define_alloc_func(cOCSPRes, ossl_ocspres_alloc);
+ rb_define_method(cOCSPRes, "initialize", ossl_ocspres_initialize, -1);
+ rb_define_method(cOCSPRes, "status", ossl_ocspres_status, 0);
+ rb_define_method(cOCSPRes, "status_string", ossl_ocspres_status_string, 0);
+ rb_define_method(cOCSPRes, "basic", ossl_ocspres_get_basic, 0);
+ rb_define_method(cOCSPRes, "to_der", ossl_ocspres_to_der, 0);
+
+ /*
+ * An OpenSSL::OCSP::BasicResponse contains the status of a certificate
+ * check which is created from an OpenSSL::OCSP::Request. A
+ * BasicResponse is more detailed than a Response.
+ */
+
+ cOCSPBasicRes = rb_define_class_under(mOCSP, "BasicResponse", rb_cObject);
+ rb_define_alloc_func(cOCSPBasicRes, ossl_ocspbres_alloc);
+ rb_define_method(cOCSPBasicRes, "initialize", ossl_ocspbres_initialize, -1);
+ rb_define_method(cOCSPBasicRes, "copy_nonce", ossl_ocspbres_copy_nonce, 1);
+ rb_define_method(cOCSPBasicRes, "add_nonce", ossl_ocspbres_add_nonce, -1);
+ rb_define_method(cOCSPBasicRes, "add_status", ossl_ocspbres_add_status, 7);
+ rb_define_method(cOCSPBasicRes, "status", ossl_ocspbres_get_status, 0);
+ rb_define_method(cOCSPBasicRes, "sign", ossl_ocspbres_sign, -1);
+ rb_define_method(cOCSPBasicRes, "verify", ossl_ocspbres_verify, -1);
+
+ /*
+ * An OpenSSL::OCSP::CertificateId identifies a certificate to the CA so
+ * that a status check can be performed.
+ */
+
+ cOCSPCertId = rb_define_class_under(mOCSP, "CertificateId", rb_cObject);
+ rb_define_alloc_func(cOCSPCertId, ossl_ocspcid_alloc);
+ rb_define_method(cOCSPCertId, "initialize", ossl_ocspcid_initialize, -1);
+ rb_define_method(cOCSPCertId, "cmp", ossl_ocspcid_cmp, 1);
+ rb_define_method(cOCSPCertId, "cmp_issuer", ossl_ocspcid_cmp_issuer, 1);
+ rb_define_method(cOCSPCertId, "serial", ossl_ocspcid_get_serial, 0);
+
+ /* Internal error in issuer */
+ rb_define_const(mOCSP, "RESPONSE_STATUS_INTERNALERROR", INT2NUM(OCSP_RESPONSE_STATUS_INTERNALERROR));
+
+ /* Illegal confirmation request */
+ rb_define_const(mOCSP, "RESPONSE_STATUS_MALFORMEDREQUEST", INT2NUM(OCSP_RESPONSE_STATUS_MALFORMEDREQUEST));
+
+ /* The certificate was revoked for an unknown reason */
+ rb_define_const(mOCSP, "REVOKED_STATUS_NOSTATUS", INT2NUM(OCSP_REVOKED_STATUS_NOSTATUS));
+
+ /* You must sign the request and resubmit */
+ rb_define_const(mOCSP, "RESPONSE_STATUS_SIGREQUIRED", INT2NUM(OCSP_RESPONSE_STATUS_SIGREQUIRED));
+
+ /* Response has valid confirmations */
+ rb_define_const(mOCSP, "RESPONSE_STATUS_SUCCESSFUL", INT2NUM(OCSP_RESPONSE_STATUS_SUCCESSFUL));
+
+ /* Try again later */
+ rb_define_const(mOCSP, "RESPONSE_STATUS_TRYLATER", INT2NUM(OCSP_RESPONSE_STATUS_TRYLATER));
+
+ /* The certificate subject's name or other information changed */
+ rb_define_const(mOCSP, "REVOKED_STATUS_AFFILIATIONCHANGED", INT2NUM(OCSP_REVOKED_STATUS_AFFILIATIONCHANGED));
+
+ /* This CA certificate was revoked due to a key compromise */
+ rb_define_const(mOCSP, "REVOKED_STATUS_CACOMPROMISE", INT2NUM(OCSP_REVOKED_STATUS_CACOMPROMISE));
+
+ /* The certificate is on hold */
+ rb_define_const(mOCSP, "REVOKED_STATUS_CERTIFICATEHOLD", INT2NUM(OCSP_REVOKED_STATUS_CERTIFICATEHOLD));
+
+ /* The certificate is no longer needed */
+ rb_define_const(mOCSP, "REVOKED_STATUS_CESSATIONOFOPERATION", INT2NUM(OCSP_REVOKED_STATUS_CESSATIONOFOPERATION));
+
+ /* The certificate was revoked due to a key compromise */
+ rb_define_const(mOCSP, "REVOKED_STATUS_KEYCOMPROMISE", INT2NUM(OCSP_REVOKED_STATUS_KEYCOMPROMISE));
+
+ /* The certificate was previously on hold and should now be removed from
+ * the CRL */
+ rb_define_const(mOCSP, "REVOKED_STATUS_REMOVEFROMCRL", INT2NUM(OCSP_REVOKED_STATUS_REMOVEFROMCRL));
+
+ /* The certificate was superseded by a new certificate */
+ rb_define_const(mOCSP, "REVOKED_STATUS_SUPERSEDED", INT2NUM(OCSP_REVOKED_STATUS_SUPERSEDED));
+
+ /* Your request is unauthorized. */
+ rb_define_const(mOCSP, "RESPONSE_STATUS_UNAUTHORIZED", INT2NUM(OCSP_RESPONSE_STATUS_UNAUTHORIZED));
+
+ /* The certificate was revoked for an unspecified reason */
+ rb_define_const(mOCSP, "REVOKED_STATUS_UNSPECIFIED", INT2NUM(OCSP_REVOKED_STATUS_UNSPECIFIED));
+
+ /* Do not include certificates in the response */
+ rb_define_const(mOCSP, "NOCERTS", INT2NUM(OCSP_NOCERTS));
+
+ /* Do not search certificates contained in the response for a signer */
+ rb_define_const(mOCSP, "NOINTERN", INT2NUM(OCSP_NOINTERN));
+
+ /* Do not check the signature on the response */
+ rb_define_const(mOCSP, "NOSIGS", INT2NUM(OCSP_NOSIGS));
+
+ /* Do not verify the certificate chain on the response */
+ rb_define_const(mOCSP, "NOCHAIN", INT2NUM(OCSP_NOCHAIN));
+
+ /* Do not verify the response at all */
+ rb_define_const(mOCSP, "NOVERIFY", INT2NUM(OCSP_NOVERIFY));
+
+ /* Do not check trust */
+ rb_define_const(mOCSP, "NOEXPLICIT", INT2NUM(OCSP_NOEXPLICIT));
+
+ /* (This flag is not used by OpenSSL 1.0.1g) */
+ rb_define_const(mOCSP, "NOCASIGN", INT2NUM(OCSP_NOCASIGN));
+
+ /* (This flag is not used by OpenSSL 1.0.1g) */
+ rb_define_const(mOCSP, "NODELEGATED", INT2NUM(OCSP_NODELEGATED));
+
+ /* Do not make additional signing certificate checks */
+ rb_define_const(mOCSP, "NOCHECKS", INT2NUM(OCSP_NOCHECKS));
+
+ /* Do not verify additional certificates */
+ rb_define_const(mOCSP, "TRUSTOTHER", INT2NUM(OCSP_TRUSTOTHER));
+
+ /* Identify the response by signing the certificate key ID */
+ rb_define_const(mOCSP, "RESPID_KEY", INT2NUM(OCSP_RESPID_KEY));
+
+ /* Do not include producedAt time in response */
+ rb_define_const(mOCSP, "NOTIME", INT2NUM(OCSP_NOTIME));
+
+ /* Indicates the certificate is not revoked but does not necessarily mean
+ * the certificate was issued or that this response is within the
+ * certificate's validity interval */
+ rb_define_const(mOCSP, "V_CERTSTATUS_GOOD", INT2NUM(V_OCSP_CERTSTATUS_GOOD));
+ /* Indicates the certificate has been revoked either permanently or
+ * temporarily (on hold). */
+ rb_define_const(mOCSP, "V_CERTSTATUS_REVOKED", INT2NUM(V_OCSP_CERTSTATUS_REVOKED));
+
+ /* Indicates the responder does not know about the certificate being
+ * requested. */
+ rb_define_const(mOCSP, "V_CERTSTATUS_UNKNOWN", INT2NUM(V_OCSP_CERTSTATUS_UNKNOWN));
+
+ /* The responder ID is based on the key name. */
+ rb_define_const(mOCSP, "V_RESPID_NAME", INT2NUM(V_OCSP_RESPID_NAME));
+
+ /* The responder ID is based on the public key. */
+ rb_define_const(mOCSP, "V_RESPID_KEY", INT2NUM(V_OCSP_RESPID_KEY));
+}
+
+#else /* ! OSSL_OCSP_ENABLED */
+void
+Init_ossl_ocsp(void)
+{
+}
+#endif
diff --git a/jni/ruby/ext/openssl/ossl_ocsp.h b/jni/ruby/ext/openssl/ossl_ocsp.h
new file mode 100644
index 0000000..7b6818c
--- /dev/null
+++ b/jni/ruby/ext/openssl/ossl_ocsp.h
@@ -0,0 +1,24 @@
+/*
+ * $Id: ossl_ocsp.h 25189 2009-10-02 12:04:37Z akr $
+ * 'OpenSSL for Ruby' project
+ * Copyright (C) 2003 Michal Rokos <m.rokos@sh.cvut.cz>
+ * Copyright (C) 2003 GOTOU Yuuzou <gotoyuzo@notwork.org>
+ * All rights reserved.
+ */
+/*
+ * This program is licenced under the same licence as Ruby.
+ * (See the file 'LICENCE'.)
+ */
+#if !defined(_OSSL_OCSP_H_)
+#define _OSSL_OCSP_H_
+
+#if defined(OSSL_OCSP_ENABLED)
+extern VALUE mOCSP;
+extern VALUE cOPCSReq;
+extern VALUE cOPCSRes;
+extern VALUE cOPCSBasicRes;
+#endif
+
+void Init_ossl_ocsp(void);
+
+#endif /* _OSSL_OCSP_H_ */
diff --git a/jni/ruby/ext/openssl/ossl_pkcs12.c b/jni/ruby/ext/openssl/ossl_pkcs12.c
new file mode 100644
index 0000000..5d8ad7e
--- /dev/null
+++ b/jni/ruby/ext/openssl/ossl_pkcs12.c
@@ -0,0 +1,226 @@
+/*
+ * This program is licenced under the same licence as Ruby.
+ * (See the file 'LICENCE'.)
+ * $Id: ossl_pkcs12.c 48802 2014-12-12 22:37:53Z nobu $
+ */
+#include "ossl.h"
+
+#define WrapPKCS12(klass, obj, p12) do { \
+ if(!(p12)) ossl_raise(rb_eRuntimeError, "PKCS12 wasn't initialized."); \
+ (obj) = TypedData_Wrap_Struct((klass), &ossl_pkcs12_type, (p12)); \
+} while (0)
+
+#define GetPKCS12(obj, p12) do { \
+ TypedData_Get_Struct((obj), PKCS12, &ossl_pkcs12_type, (p12)); \
+ if(!(p12)) ossl_raise(rb_eRuntimeError, "PKCS12 wasn't initialized."); \
+} while (0)
+
+#define SafeGetPKCS12(obj, p12) do { \
+ OSSL_Check_Kind((obj), cPKCS12); \
+ GetPKCS12((obj), (p12)); \
+} while (0)
+
+#define ossl_pkcs12_set_key(o,v) rb_iv_set((o), "@key", (v))
+#define ossl_pkcs12_set_cert(o,v) rb_iv_set((o), "@certificate", (v))
+#define ossl_pkcs12_set_ca_certs(o,v) rb_iv_set((o), "@ca_certs", (v))
+#define ossl_pkcs12_get_key(o) rb_iv_get((o), "@key")
+#define ossl_pkcs12_get_cert(o) rb_iv_get((o), "@certificate")
+#define ossl_pkcs12_get_ca_certs(o) rb_iv_get((o), "@ca_certs")
+
+/*
+ * Classes
+ */
+VALUE cPKCS12;
+VALUE ePKCS12Error;
+
+/*
+ * Private
+ */
+static void
+ossl_pkcs12_free(void *ptr)
+{
+ PKCS12_free(ptr);
+}
+
+static const rb_data_type_t ossl_pkcs12_type = {
+ "OpenSSL/PKCS12",
+ {
+ 0, ossl_pkcs12_free,
+ },
+ 0, 0, RUBY_TYPED_FREE_IMMEDIATELY,
+};
+
+static VALUE
+ossl_pkcs12_s_allocate(VALUE klass)
+{
+ PKCS12 *p12;
+ VALUE obj;
+
+ if(!(p12 = PKCS12_new())) ossl_raise(ePKCS12Error, NULL);
+ WrapPKCS12(klass, obj, p12);
+
+ return obj;
+}
+
+/*
+ * call-seq:
+ * PKCS12.create(pass, name, key, cert [, ca, [, key_pbe [, cert_pbe [, key_iter [, mac_iter [, keytype]]]]]])
+ *
+ * === Parameters
+ * * +pass+ - string
+ * * +name+ - A string describing the key.
+ * * +key+ - Any PKey.
+ * * +cert+ - A X509::Certificate.
+ * * * The public_key portion of the certificate must contain a valid public key.
+ * * * The not_before and not_after fields must be filled in.
+ * * +ca+ - An optional array of X509::Certificate's.
+ * * +key_pbe+ - string
+ * * +cert_pbe+ - string
+ * * +key_iter+ - integer
+ * * +mac_iter+ - integer
+ * * +keytype+ - An integer representing an MSIE specific extension.
+ *
+ * Any optional arguments may be supplied as nil to preserve the OpenSSL defaults.
+ *
+ * See the OpenSSL documentation for PKCS12_create().
+ */
+static VALUE
+ossl_pkcs12_s_create(int argc, VALUE *argv, VALUE self)
+{
+ VALUE pass, name, pkey, cert, ca, key_nid, cert_nid, key_iter, mac_iter, keytype;
+ VALUE obj;
+ char *passphrase, *friendlyname;
+ EVP_PKEY *key;
+ X509 *x509;
+ STACK_OF(X509) *x509s;
+ int nkey = 0, ncert = 0, kiter = 0, miter = 0, ktype = 0;
+ PKCS12 *p12;
+
+ rb_scan_args(argc, argv, "46", &pass, &name, &pkey, &cert, &ca, &key_nid, &cert_nid, &key_iter, &mac_iter, &keytype);
+ passphrase = NIL_P(pass) ? NULL : StringValuePtr(pass);
+ friendlyname = NIL_P(name) ? NULL : StringValuePtr(name);
+ key = GetPKeyPtr(pkey);
+ x509 = GetX509CertPtr(cert);
+ x509s = NIL_P(ca) ? NULL : ossl_x509_ary2sk(ca);
+/* TODO: make a VALUE to nid function */
+ if (!NIL_P(key_nid)) {
+ if ((nkey = OBJ_txt2nid(StringValuePtr(key_nid))) == NID_undef)
+ ossl_raise(rb_eArgError, "Unknown PBE algorithm %s", StringValuePtr(key_nid));
+ }
+ if (!NIL_P(cert_nid)) {
+ if ((ncert = OBJ_txt2nid(StringValuePtr(cert_nid))) == NID_undef)
+ ossl_raise(rb_eArgError, "Unknown PBE algorithm %s", StringValuePtr(cert_nid));
+ }
+ if (!NIL_P(key_iter))
+ kiter = NUM2INT(key_iter);
+ if (!NIL_P(mac_iter))
+ miter = NUM2INT(mac_iter);
+ if (!NIL_P(keytype))
+ ktype = NUM2INT(keytype);
+
+ p12 = PKCS12_create(passphrase, friendlyname, key, x509, x509s,
+ nkey, ncert, kiter, miter, ktype);
+ sk_X509_pop_free(x509s, X509_free);
+ if(!p12) ossl_raise(ePKCS12Error, NULL);
+ WrapPKCS12(cPKCS12, obj, p12);
+
+ ossl_pkcs12_set_key(obj, pkey);
+ ossl_pkcs12_set_cert(obj, cert);
+ ossl_pkcs12_set_ca_certs(obj, ca);
+
+ return obj;
+}
+
+/*
+ * call-seq:
+ * PKCS12.new -> pkcs12
+ * PKCS12.new(str) -> pkcs12
+ * PKCS12.new(str, pass) -> pkcs12
+ *
+ * === Parameters
+ * * +str+ - Must be a DER encoded PKCS12 string.
+ * * +pass+ - string
+ */
+static VALUE
+ossl_pkcs12_initialize(int argc, VALUE *argv, VALUE self)
+{
+ BIO *in;
+ VALUE arg, pass, pkey, cert, ca;
+ char *passphrase;
+ EVP_PKEY *key;
+ X509 *x509;
+ STACK_OF(X509) *x509s = NULL;
+ int st = 0;
+ PKCS12 *pkcs = DATA_PTR(self);
+
+ if(rb_scan_args(argc, argv, "02", &arg, &pass) == 0) return self;
+ passphrase = NIL_P(pass) ? NULL : StringValuePtr(pass);
+ in = ossl_obj2bio(arg);
+ d2i_PKCS12_bio(in, &pkcs);
+ DATA_PTR(self) = pkcs;
+ BIO_free(in);
+
+ pkey = cert = ca = Qnil;
+ if(!PKCS12_parse(pkcs, passphrase, &key, &x509, &x509s))
+ ossl_raise(ePKCS12Error, "PKCS12_parse");
+ pkey = rb_protect((VALUE(*)_((VALUE)))ossl_pkey_new, (VALUE)key,
+ &st); /* NO DUP */
+ if(st) goto err;
+ cert = rb_protect((VALUE(*)_((VALUE)))ossl_x509_new, (VALUE)x509, &st);
+ if(st) goto err;
+ if(x509s){
+ ca =
+ rb_protect((VALUE(*)_((VALUE)))ossl_x509_sk2ary, (VALUE)x509s, &st);
+ if(st) goto err;
+ }
+
+ err:
+ X509_free(x509);
+ sk_X509_pop_free(x509s, X509_free);
+ ossl_pkcs12_set_key(self, pkey);
+ ossl_pkcs12_set_cert(self, cert);
+ ossl_pkcs12_set_ca_certs(self, ca);
+ if(st) rb_jump_tag(st);
+
+ return self;
+}
+
+static VALUE
+ossl_pkcs12_to_der(VALUE self)
+{
+ PKCS12 *p12;
+ VALUE str;
+ long len;
+ unsigned char *p;
+
+ GetPKCS12(self, p12);
+ if((len = i2d_PKCS12(p12, NULL)) <= 0)
+ ossl_raise(ePKCS12Error, NULL);
+ str = rb_str_new(0, len);
+ p = (unsigned char *)RSTRING_PTR(str);
+ if(i2d_PKCS12(p12, &p) <= 0)
+ ossl_raise(ePKCS12Error, NULL);
+ ossl_str_adjust(str, p);
+
+ return str;
+}
+
+void
+Init_ossl_pkcs12(void)
+{
+ /*
+ * Defines a file format commonly used to store private keys with
+ * accompanying public key certificates, protected with a password-based
+ * symmetric key.
+ */
+ cPKCS12 = rb_define_class_under(mOSSL, "PKCS12", rb_cObject);
+ ePKCS12Error = rb_define_class_under(cPKCS12, "PKCS12Error", eOSSLError);
+ rb_define_singleton_method(cPKCS12, "create", ossl_pkcs12_s_create, -1);
+
+ rb_define_alloc_func(cPKCS12, ossl_pkcs12_s_allocate);
+ rb_attr(cPKCS12, rb_intern("key"), 1, 0, Qfalse);
+ rb_attr(cPKCS12, rb_intern("certificate"), 1, 0, Qfalse);
+ rb_attr(cPKCS12, rb_intern("ca_certs"), 1, 0, Qfalse);
+ rb_define_method(cPKCS12, "initialize", ossl_pkcs12_initialize, -1);
+ rb_define_method(cPKCS12, "to_der", ossl_pkcs12_to_der, 0);
+}
diff --git a/jni/ruby/ext/openssl/ossl_pkcs12.h b/jni/ruby/ext/openssl/ossl_pkcs12.h
new file mode 100644
index 0000000..c3e5491
--- /dev/null
+++ b/jni/ruby/ext/openssl/ossl_pkcs12.h
@@ -0,0 +1,15 @@
+/*
+ * This program is licenced under the same licence as Ruby.
+ * (See the file 'LICENCE'.)
+ * $Id: ossl_pkcs12.h 25189 2009-10-02 12:04:37Z akr $
+ */
+#if !defined(_OSSL_PKCS12_H_)
+#define _OSSL_PKCS12_H_
+
+extern VALUE cPKCS12;
+extern VALUE ePKCS12Error;
+
+void Init_ossl_pkcs12(void);
+
+#endif /* _OSSL_PKCS12_H_ */
+
diff --git a/jni/ruby/ext/openssl/ossl_pkcs5.c b/jni/ruby/ext/openssl/ossl_pkcs5.c
new file mode 100644
index 0000000..6c7738a
--- /dev/null
+++ b/jni/ruby/ext/openssl/ossl_pkcs5.c
@@ -0,0 +1,189 @@
+/*
+ * $Id$
+ * Copyright (C) 2007 Technorama Ltd. <oss-ruby@technorama.net>
+ */
+#include "ossl.h"
+
+VALUE mPKCS5;
+VALUE ePKCS5;
+
+#ifdef HAVE_PKCS5_PBKDF2_HMAC
+/*
+ * call-seq:
+ * PKCS5.pbkdf2_hmac(pass, salt, iter, keylen, digest) => string
+ *
+ * === Parameters
+ * * +pass+ - string
+ * * +salt+ - string - should be at least 8 bytes long.
+ * * +iter+ - integer - should be greater than 1000. 20000 is better.
+ * * +keylen+ - integer
+ * * +digest+ - a string or OpenSSL::Digest object.
+ *
+ * Available in OpenSSL 0.9.4.
+ *
+ * Digests other than SHA1 may not be supported by other cryptography libraries.
+ */
+static VALUE
+ossl_pkcs5_pbkdf2_hmac(VALUE self, VALUE pass, VALUE salt, VALUE iter, VALUE keylen, VALUE digest)
+{
+ VALUE str;
+ const EVP_MD *md;
+ int len = NUM2INT(keylen);
+
+ StringValue(pass);
+ StringValue(salt);
+ md = GetDigestPtr(digest);
+
+ str = rb_str_new(0, len);
+
+ if (PKCS5_PBKDF2_HMAC(RSTRING_PTR(pass), RSTRING_LENINT(pass),
+ (unsigned char *)RSTRING_PTR(salt), RSTRING_LENINT(salt),
+ NUM2INT(iter), md, len,
+ (unsigned char *)RSTRING_PTR(str)) != 1)
+ ossl_raise(ePKCS5, "PKCS5_PBKDF2_HMAC");
+
+ return str;
+}
+#else
+#define ossl_pkcs5_pbkdf2_hmac rb_f_notimplement
+#endif
+
+
+#ifdef HAVE_PKCS5_PBKDF2_HMAC_SHA1
+/*
+ * call-seq:
+ * PKCS5.pbkdf2_hmac_sha1(pass, salt, iter, keylen) => string
+ *
+ * === Parameters
+ * * +pass+ - string
+ * * +salt+ - string - should be at least 8 bytes long.
+ * * +iter+ - integer - should be greater than 1000. 20000 is better.
+ * * +keylen+ - integer
+ *
+ * This method is available in almost any version of OpenSSL.
+ *
+ * Conforms to rfc2898.
+ */
+static VALUE
+ossl_pkcs5_pbkdf2_hmac_sha1(VALUE self, VALUE pass, VALUE salt, VALUE iter, VALUE keylen)
+{
+ VALUE str;
+ int len = NUM2INT(keylen);
+
+ StringValue(pass);
+ StringValue(salt);
+
+ str = rb_str_new(0, len);
+
+ if (PKCS5_PBKDF2_HMAC_SHA1(RSTRING_PTR(pass), RSTRING_LENINT(pass),
+ (const unsigned char *)RSTRING_PTR(salt), RSTRING_LENINT(salt), NUM2INT(iter),
+ len, (unsigned char *)RSTRING_PTR(str)) != 1)
+ ossl_raise(ePKCS5, "PKCS5_PBKDF2_HMAC_SHA1");
+
+ return str;
+}
+#else
+#define ossl_pkcs5_pbkdf2_hmac_sha1 rb_f_notimplement
+#endif
+
+void
+Init_ossl_pkcs5(void)
+{
+ /*
+ * Password-based Encryption
+ *
+ */
+
+ #if 0
+ mOSSL = rb_define_module("OpenSSL"); /* let rdoc know about mOSSL */
+ #endif
+
+ /* Document-class: OpenSSL::PKCS5
+ *
+ * Provides password-based encryption functionality based on PKCS#5.
+ * Typically used for securely deriving arbitrary length symmetric keys
+ * to be used with an OpenSSL::Cipher from passwords. Another use case
+ * is for storing passwords: Due to the ability to tweak the effort of
+ * computation by increasing the iteration count, computation can be
+ * slowed down artificially in order to render possible attacks infeasible.
+ *
+ * PKCS5 offers support for PBKDF2 with an OpenSSL::Digest::SHA1-based
+ * HMAC, or an arbitrary Digest if the underlying version of OpenSSL
+ * already supports it (>= 0.9.4).
+ *
+ * === Parameters
+ * ==== Password
+ * Typically an arbitrary String that represents the password to be used
+ * for deriving a key.
+ * ==== Salt
+ * Prevents attacks based on dictionaries of common passwords. It is a
+ * public value that can be safely stored along with the password (e.g.
+ * if PBKDF2 is used for password storage). For maximum security, a fresh,
+ * random salt should be generated for each stored password. According
+ * to PKCS#5, a salt should be at least 8 bytes long.
+ * ==== Iteration Count
+ * Allows to tweak the length that the actual computation will take. The
+ * larger the iteration count, the longer it will take.
+ * ==== Key Length
+ * Specifies the length in bytes of the output that will be generated.
+ * Typically, the key length should be larger than or equal to the output
+ * length of the underlying digest function, otherwise an attacker could
+ * simply try to brute-force the key. According to PKCS#5, security is
+ * limited by the output length of the underlying digest function, i.e.
+ * security is not improved if a key length strictly larger than the
+ * digest output length is chosen. Therefore, when using PKCS5 for
+ * password storage, it suffices to store values equal to the digest
+ * output length, nothing is gained by storing larger values.
+ *
+ * == Examples
+ * === Generating a 128 bit key for a Cipher (e.g. AES)
+ * pass = "secret"
+ * salt = OpenSSL::Random.random_bytes(16)
+ * iter = 20000
+ * key_len = 16
+ * key = OpenSSL::PKCS5.pbkdf2_hmac_sha1(pass, salt, iter, key_len)
+ *
+ * === Storing Passwords
+ * pass = "secret"
+ * salt = OpenSSL::Random.random_bytes(16) #store this with the generated value
+ * iter = 20000
+ * digest = OpenSSL::Digest::SHA256.new
+ * len = digest.digest_length
+ * #the final value to be stored
+ * value = OpenSSL::PKCS5.pbkdf2_hmac(pass, salt, iter, len, digest)
+ *
+ * === Important Note on Checking Passwords
+ * When comparing passwords provided by the user with previously stored
+ * values, a common mistake made is comparing the two values using "==".
+ * Typically, "==" short-circuits on evaluation, and is therefore
+ * vulnerable to timing attacks. The proper way is to use a method that
+ * always takes the same amount of time when comparing two values, thus
+ * not leaking any information to potential attackers. To compare two
+ * values, the following could be used:
+ * def eql_time_cmp(a, b)
+ * unless a.length == b.length
+ * return false
+ * end
+ * cmp = b.bytes.to_a
+ * result = 0
+ * a.bytes.each_with_index {|c,i|
+ * result |= c ^ cmp[i]
+ * }
+ * result == 0
+ * end
+ * Please note that the premature return in case of differing lengths
+ * typically does not leak valuable information - when using PKCS#5, the
+ * length of the values to be compared is of fixed size.
+ */
+
+ mPKCS5 = rb_define_module_under(mOSSL, "PKCS5");
+ /* Document-class: OpenSSL::PKCS5::PKCS5Error
+ *
+ * Generic Exception class that is raised if an error occurs during a
+ * computation.
+ */
+ ePKCS5 = rb_define_class_under(mPKCS5, "PKCS5Error", eOSSLError);
+
+ rb_define_module_function(mPKCS5, "pbkdf2_hmac", ossl_pkcs5_pbkdf2_hmac, 5);
+ rb_define_module_function(mPKCS5, "pbkdf2_hmac_sha1", ossl_pkcs5_pbkdf2_hmac_sha1, 4);
+}
diff --git a/jni/ruby/ext/openssl/ossl_pkcs5.h b/jni/ruby/ext/openssl/ossl_pkcs5.h
new file mode 100644
index 0000000..a3b132b
--- /dev/null
+++ b/jni/ruby/ext/openssl/ossl_pkcs5.h
@@ -0,0 +1,6 @@
+#if !defined(_OSSL_PKCS5_H_)
+#define _OSSL_PKCS5_H_
+
+void Init_ossl_pkcs5(void);
+
+#endif /* _OSSL_PKCS5_H_ */
diff --git a/jni/ruby/ext/openssl/ossl_pkcs7.c b/jni/ruby/ext/openssl/ossl_pkcs7.c
new file mode 100644
index 0000000..fb6c0a2
--- /dev/null
+++ b/jni/ruby/ext/openssl/ossl_pkcs7.c
@@ -0,0 +1,1090 @@
+/*
+ * $Id: ossl_pkcs7.c 48805 2014-12-12 22:38:01Z nobu $
+ * 'OpenSSL for Ruby' project
+ * Copyright (C) 2001-2002 Michal Rokos <m.rokos@sh.cvut.cz>
+ * All rights reserved.
+ */
+/*
+ * This program is licenced under the same licence as Ruby.
+ * (See the file 'LICENCE'.)
+ */
+#include "ossl.h"
+
+#define WrapPKCS7(klass, obj, pkcs7) do { \
+ if (!(pkcs7)) { \
+ ossl_raise(rb_eRuntimeError, "PKCS7 wasn't initialized."); \
+ } \
+ (obj) = TypedData_Wrap_Struct((klass), &ossl_pkcs7_type, (pkcs7)); \
+} while (0)
+#define GetPKCS7(obj, pkcs7) do { \
+ TypedData_Get_Struct((obj), PKCS7, &ossl_pkcs7_type, (pkcs7)); \
+ if (!(pkcs7)) { \
+ ossl_raise(rb_eRuntimeError, "PKCS7 wasn't initialized."); \
+ } \
+} while (0)
+#define SafeGetPKCS7(obj, pkcs7) do { \
+ OSSL_Check_Kind((obj), cPKCS7); \
+ GetPKCS7((obj), (pkcs7)); \
+} while (0)
+
+#define WrapPKCS7si(klass, obj, p7si) do { \
+ if (!(p7si)) { \
+ ossl_raise(rb_eRuntimeError, "PKCS7si wasn't initialized."); \
+ } \
+ (obj) = TypedData_Wrap_Struct((klass), &ossl_pkcs7_signer_info_type, (p7si)); \
+} while (0)
+#define GetPKCS7si(obj, p7si) do { \
+ TypedData_Get_Struct((obj), PKCS7_SIGNER_INFO, &ossl_pkcs7_signer_info_type, (p7si)); \
+ if (!(p7si)) { \
+ ossl_raise(rb_eRuntimeError, "PKCS7si wasn't initialized."); \
+ } \
+} while (0)
+#define SafeGetPKCS7si(obj, p7si) do { \
+ OSSL_Check_Kind((obj), cPKCS7Signer); \
+ GetPKCS7si((obj), (p7si)); \
+} while (0)
+
+#define WrapPKCS7ri(klass, obj, p7ri) do { \
+ if (!(p7ri)) { \
+ ossl_raise(rb_eRuntimeError, "PKCS7ri wasn't initialized."); \
+ } \
+ (obj) = TypedData_Wrap_Struct((klass), &ossl_pkcs7_recip_info_type, (p7ri)); \
+} while (0)
+#define GetPKCS7ri(obj, p7ri) do { \
+ TypedData_Get_Struct((obj), PKCS7_RECIP_INFO, &ossl_pkcs7_recip_info_type, (p7ri)); \
+ if (!(p7ri)) { \
+ ossl_raise(rb_eRuntimeError, "PKCS7ri wasn't initialized."); \
+ } \
+} while (0)
+#define SafeGetPKCS7ri(obj, p7ri) do { \
+ OSSL_Check_Kind((obj), cPKCS7Recipient); \
+ GetPKCS7ri((obj), (p7ri)); \
+} while (0)
+
+#define numberof(ary) (int)(sizeof(ary)/sizeof((ary)[0]))
+
+#define ossl_pkcs7_set_data(o,v) rb_iv_set((o), "@data", (v))
+#define ossl_pkcs7_get_data(o) rb_iv_get((o), "@data")
+#define ossl_pkcs7_set_err_string(o,v) rb_iv_set((o), "@error_string", (v))
+#define ossl_pkcs7_get_err_string(o) rb_iv_get((o), "@error_string")
+
+/*
+ * Classes
+ */
+VALUE cPKCS7;
+VALUE cPKCS7Signer;
+VALUE cPKCS7Recipient;
+VALUE ePKCS7Error;
+
+static void
+ossl_pkcs7_free(void *ptr)
+{
+ PKCS7_free(ptr);
+}
+
+static const rb_data_type_t ossl_pkcs7_type = {
+ "OpenSSL/PKCS7",
+ {
+ 0, ossl_pkcs7_free,
+ },
+ 0, 0, RUBY_TYPED_FREE_IMMEDIATELY,
+};
+
+static void
+ossl_pkcs7_signer_info_free(void *ptr)
+{
+ PKCS7_SIGNER_INFO_free(ptr);
+}
+
+static const rb_data_type_t ossl_pkcs7_signer_info_type = {
+ "OpenSSL/PKCS7/SIGNER_INFO",
+ {
+ 0, ossl_pkcs7_signer_info_free,
+ },
+ 0, 0, RUBY_TYPED_FREE_IMMEDIATELY,
+};
+
+static void
+ossl_pkcs7_recip_info_free(void *ptr)
+{
+ PKCS7_RECIP_INFO_free(ptr);
+}
+
+static const rb_data_type_t ossl_pkcs7_recip_info_type = {
+ "OpenSSL/PKCS7/RECIP_INFO",
+ {
+ 0, ossl_pkcs7_recip_info_free,
+ },
+ 0, 0, RUBY_TYPED_FREE_IMMEDIATELY,
+};
+
+/*
+ * Public
+ * (MADE PRIVATE UNTIL SOMEBODY WILL NEED THEM)
+ */
+static VALUE
+ossl_pkcs7si_new(PKCS7_SIGNER_INFO *p7si)
+{
+ PKCS7_SIGNER_INFO *pkcs7;
+ VALUE obj;
+
+ pkcs7 = p7si ? PKCS7_SIGNER_INFO_dup(p7si) : PKCS7_SIGNER_INFO_new();
+ if (!pkcs7) ossl_raise(ePKCS7Error, NULL);
+ WrapPKCS7si(cPKCS7Signer, obj, pkcs7);
+
+ return obj;
+}
+
+static PKCS7_SIGNER_INFO *
+DupPKCS7SignerPtr(VALUE obj)
+{
+ PKCS7_SIGNER_INFO *p7si, *pkcs7;
+
+ SafeGetPKCS7si(obj, p7si);
+ if (!(pkcs7 = PKCS7_SIGNER_INFO_dup(p7si))) {
+ ossl_raise(ePKCS7Error, NULL);
+ }
+
+ return pkcs7;
+}
+
+static VALUE
+ossl_pkcs7ri_new(PKCS7_RECIP_INFO *p7ri)
+{
+ PKCS7_RECIP_INFO *pkcs7;
+ VALUE obj;
+
+ pkcs7 = p7ri ? PKCS7_RECIP_INFO_dup(p7ri) : PKCS7_RECIP_INFO_new();
+ if (!pkcs7) ossl_raise(ePKCS7Error, NULL);
+ WrapPKCS7ri(cPKCS7Recipient, obj, pkcs7);
+
+ return obj;
+}
+
+static PKCS7_RECIP_INFO *
+DupPKCS7RecipientPtr(VALUE obj)
+{
+ PKCS7_RECIP_INFO *p7ri, *pkcs7;
+
+ SafeGetPKCS7ri(obj, p7ri);
+ if (!(pkcs7 = PKCS7_RECIP_INFO_dup(p7ri))) {
+ ossl_raise(ePKCS7Error, NULL);
+ }
+
+ return pkcs7;
+}
+
+/*
+ * call-seq:
+ * PKCS7.read_smime(string) => pkcs7
+ */
+static VALUE
+ossl_pkcs7_s_read_smime(VALUE klass, VALUE arg)
+{
+ BIO *in, *out;
+ PKCS7 *pkcs7;
+ VALUE ret, data;
+
+ in = ossl_obj2bio(arg);
+ out = NULL;
+ pkcs7 = SMIME_read_PKCS7(in, &out);
+ BIO_free(in);
+ if(!pkcs7) ossl_raise(ePKCS7Error, NULL);
+ data = out ? ossl_membio2str(out) : Qnil;
+ WrapPKCS7(cPKCS7, ret, pkcs7);
+ ossl_pkcs7_set_data(ret, data);
+ ossl_pkcs7_set_err_string(ret, Qnil);
+
+ return ret;
+}
+
+/*
+ * call-seq:
+ * PKCS7.write_smime(pkcs7 [, data [, flags]]) => string
+ */
+static VALUE
+ossl_pkcs7_s_write_smime(int argc, VALUE *argv, VALUE klass)
+{
+ VALUE pkcs7, data, flags;
+ BIO *out, *in;
+ PKCS7 *p7;
+ VALUE str;
+ int flg;
+
+ rb_scan_args(argc, argv, "12", &pkcs7, &data, &flags);
+ flg = NIL_P(flags) ? 0 : NUM2INT(flags);
+ if(NIL_P(data)) data = ossl_pkcs7_get_data(pkcs7);
+ SafeGetPKCS7(pkcs7, p7);
+ if(!NIL_P(data) && PKCS7_is_detached(p7))
+ flg |= PKCS7_DETACHED;
+ in = NIL_P(data) ? NULL : ossl_obj2bio(data);
+ if(!(out = BIO_new(BIO_s_mem()))){
+ BIO_free(in);
+ ossl_raise(ePKCS7Error, NULL);
+ }
+ if(!SMIME_write_PKCS7(out, p7, in, flg)){
+ BIO_free(out);
+ BIO_free(in);
+ ossl_raise(ePKCS7Error, NULL);
+ }
+ BIO_free(in);
+ str = ossl_membio2str(out);
+
+ return str;
+}
+
+/*
+ * call-seq:
+ * PKCS7.sign(cert, key, data, [, certs [, flags]]) => pkcs7
+ */
+static VALUE
+ossl_pkcs7_s_sign(int argc, VALUE *argv, VALUE klass)
+{
+ VALUE cert, key, data, certs, flags;
+ X509 *x509;
+ EVP_PKEY *pkey;
+ BIO *in;
+ STACK_OF(X509) *x509s;
+ int flg, status = 0;
+ PKCS7 *pkcs7;
+ VALUE ret;
+
+ rb_scan_args(argc, argv, "32", &cert, &key, &data, &certs, &flags);
+ x509 = GetX509CertPtr(cert); /* NO NEED TO DUP */
+ pkey = GetPrivPKeyPtr(key); /* NO NEED TO DUP */
+ flg = NIL_P(flags) ? 0 : NUM2INT(flags);
+ in = ossl_obj2bio(data);
+ if(NIL_P(certs)) x509s = NULL;
+ else{
+ x509s = ossl_protect_x509_ary2sk(certs, &status);
+ if(status){
+ BIO_free(in);
+ rb_jump_tag(status);
+ }
+ }
+ if(!(pkcs7 = PKCS7_sign(x509, pkey, x509s, in, flg))){
+ BIO_free(in);
+ sk_X509_pop_free(x509s, X509_free);
+ ossl_raise(ePKCS7Error, NULL);
+ }
+ WrapPKCS7(cPKCS7, ret, pkcs7);
+ ossl_pkcs7_set_data(ret, data);
+ ossl_pkcs7_set_err_string(ret, Qnil);
+ BIO_free(in);
+ sk_X509_pop_free(x509s, X509_free);
+
+ return ret;
+}
+
+/*
+ * call-seq:
+ * PKCS7.encrypt(certs, data, [, cipher [, flags]]) => pkcs7
+ */
+static VALUE
+ossl_pkcs7_s_encrypt(int argc, VALUE *argv, VALUE klass)
+{
+ VALUE certs, data, cipher, flags;
+ STACK_OF(X509) *x509s;
+ BIO *in;
+ const EVP_CIPHER *ciph;
+ int flg, status = 0;
+ VALUE ret;
+ PKCS7 *p7;
+
+ rb_scan_args(argc, argv, "22", &certs, &data, &cipher, &flags);
+ if(NIL_P(cipher)){
+#if !defined(OPENSSL_NO_RC2)
+ ciph = EVP_rc2_40_cbc();
+#elif !defined(OPENSSL_NO_DES)
+ ciph = EVP_des_ede3_cbc();
+#elif !defined(OPENSSL_NO_RC2)
+ ciph = EVP_rc2_40_cbc();
+#elif !defined(OPENSSL_NO_AES)
+ ciph = EVP_EVP_aes_128_cbc();
+#else
+ ossl_raise(ePKCS7Error, "Must specify cipher");
+#endif
+
+ }
+ else ciph = GetCipherPtr(cipher); /* NO NEED TO DUP */
+ flg = NIL_P(flags) ? 0 : NUM2INT(flags);
+ in = ossl_obj2bio(data);
+ x509s = ossl_protect_x509_ary2sk(certs, &status);
+ if(status){
+ BIO_free(in);
+ rb_jump_tag(status);
+ }
+ if(!(p7 = PKCS7_encrypt(x509s, in, (EVP_CIPHER*)ciph, flg))){
+ BIO_free(in);
+ sk_X509_pop_free(x509s, X509_free);
+ ossl_raise(ePKCS7Error, NULL);
+ }
+ BIO_free(in);
+ WrapPKCS7(cPKCS7, ret, p7);
+ ossl_pkcs7_set_data(ret, data);
+ sk_X509_pop_free(x509s, X509_free);
+
+ return ret;
+}
+
+static VALUE
+ossl_pkcs7_alloc(VALUE klass)
+{
+ PKCS7 *pkcs7;
+ VALUE obj;
+
+ if (!(pkcs7 = PKCS7_new())) {
+ ossl_raise(ePKCS7Error, NULL);
+ }
+ WrapPKCS7(klass, obj, pkcs7);
+
+ return obj;
+}
+
+/*
+ * call-seq:
+ * PKCS7.new => pkcs7
+ * PKCS7.new(string) => pkcs7
+ *
+ * Many methods in this class aren't documented.
+ */
+static VALUE
+ossl_pkcs7_initialize(int argc, VALUE *argv, VALUE self)
+{
+ PKCS7 *p7, *pkcs = DATA_PTR(self);
+ BIO *in;
+ VALUE arg;
+
+ if(rb_scan_args(argc, argv, "01", &arg) == 0)
+ return self;
+ arg = ossl_to_der_if_possible(arg);
+ in = ossl_obj2bio(arg);
+ p7 = PEM_read_bio_PKCS7(in, &pkcs, NULL, NULL);
+ if (!p7) {
+ OSSL_BIO_reset(in);
+ p7 = d2i_PKCS7_bio(in, &pkcs);
+ if (!p7) {
+ BIO_free(in);
+ PKCS7_free(pkcs);
+ DATA_PTR(self) = NULL;
+ ossl_raise(rb_eArgError, "Could not parse the PKCS7");
+ }
+ }
+ DATA_PTR(self) = pkcs;
+ BIO_free(in);
+ ossl_pkcs7_set_data(self, Qnil);
+ ossl_pkcs7_set_err_string(self, Qnil);
+
+ return self;
+}
+
+static VALUE
+ossl_pkcs7_copy(VALUE self, VALUE other)
+{
+ PKCS7 *a, *b, *pkcs7;
+
+ rb_check_frozen(self);
+ if (self == other) return self;
+
+ GetPKCS7(self, a);
+ SafeGetPKCS7(other, b);
+
+ pkcs7 = PKCS7_dup(b);
+ if (!pkcs7) {
+ ossl_raise(ePKCS7Error, NULL);
+ }
+ DATA_PTR(self) = pkcs7;
+ PKCS7_free(a);
+
+ return self;
+}
+
+static int
+ossl_pkcs7_sym2typeid(VALUE sym)
+{
+ int i, ret = Qnil;
+ const char *s;
+ size_t l;
+
+ static const struct {
+ char name[20];
+ int nid;
+ } p7_type_tab[] = {
+ { "signed", NID_pkcs7_signed },
+ { "data", NID_pkcs7_data },
+ { "signedAndEnveloped", NID_pkcs7_signedAndEnveloped },
+ { "enveloped", NID_pkcs7_enveloped },
+ { "encrypted", NID_pkcs7_encrypted },
+ { "digest", NID_pkcs7_digest },
+ };
+
+ if (RB_TYPE_P(sym, T_SYMBOL)) sym = rb_sym2str(sym);
+ else StringValue(sym);
+ RSTRING_GETMEM(sym, s, l);
+ for(i = 0; ; i++){
+ if(i == numberof(p7_type_tab))
+ ossl_raise(ePKCS7Error, "unknown type \"%s\"", s);
+ if(strlen(p7_type_tab[i].name) != l) continue;
+ if(strcmp(p7_type_tab[i].name, s) == 0){
+ ret = p7_type_tab[i].nid;
+ break;
+ }
+ }
+
+ return ret;
+}
+
+/*
+ * call-seq:
+ * pkcs7.type = type => type
+ */
+static VALUE
+ossl_pkcs7_set_type(VALUE self, VALUE type)
+{
+ PKCS7 *p7;
+
+ GetPKCS7(self, p7);
+ if(!PKCS7_set_type(p7, ossl_pkcs7_sym2typeid(type)))
+ ossl_raise(ePKCS7Error, NULL);
+
+ return type;
+}
+
+/*
+ * call-seq:
+ * pkcs7.type => string or nil
+ */
+static VALUE
+ossl_pkcs7_get_type(VALUE self)
+{
+ PKCS7 *p7;
+
+ GetPKCS7(self, p7);
+ if(PKCS7_type_is_signed(p7))
+ return ID2SYM(rb_intern("signed"));
+ if(PKCS7_type_is_encrypted(p7))
+ return ID2SYM(rb_intern("encrypted"));
+ if(PKCS7_type_is_enveloped(p7))
+ return ID2SYM(rb_intern("enveloped"));
+ if(PKCS7_type_is_signedAndEnveloped(p7))
+ return ID2SYM(rb_intern("signedAndEnveloped"));
+ if(PKCS7_type_is_data(p7))
+ return ID2SYM(rb_intern("data"));
+ return Qnil;
+}
+
+static VALUE
+ossl_pkcs7_set_detached(VALUE self, VALUE flag)
+{
+ PKCS7 *p7;
+
+ GetPKCS7(self, p7);
+ if(flag != Qtrue && flag != Qfalse)
+ ossl_raise(ePKCS7Error, "must specify a boolean");
+ if(!PKCS7_set_detached(p7, flag == Qtrue ? 1 : 0))
+ ossl_raise(ePKCS7Error, NULL);
+
+ return flag;
+}
+
+static VALUE
+ossl_pkcs7_get_detached(VALUE self)
+{
+ PKCS7 *p7;
+ GetPKCS7(self, p7);
+ return PKCS7_get_detached(p7) ? Qtrue : Qfalse;
+}
+
+static VALUE
+ossl_pkcs7_detached_p(VALUE self)
+{
+ PKCS7 *p7;
+ GetPKCS7(self, p7);
+ return PKCS7_is_detached(p7) ? Qtrue : Qfalse;
+}
+
+static VALUE
+ossl_pkcs7_set_cipher(VALUE self, VALUE cipher)
+{
+ PKCS7 *pkcs7;
+
+ GetPKCS7(self, pkcs7);
+ if (!PKCS7_set_cipher(pkcs7, GetCipherPtr(cipher))) {
+ ossl_raise(ePKCS7Error, NULL);
+ }
+
+ return cipher;
+}
+
+static VALUE
+ossl_pkcs7_add_signer(VALUE self, VALUE signer)
+{
+ PKCS7 *pkcs7;
+ PKCS7_SIGNER_INFO *p7si;
+
+ p7si = DupPKCS7SignerPtr(signer); /* NEED TO DUP */
+ GetPKCS7(self, pkcs7);
+ if (!PKCS7_add_signer(pkcs7, p7si)) {
+ PKCS7_SIGNER_INFO_free(p7si);
+ ossl_raise(ePKCS7Error, "Could not add signer.");
+ }
+ if (PKCS7_type_is_signed(pkcs7)){
+ PKCS7_add_signed_attribute(p7si, NID_pkcs9_contentType,
+ V_ASN1_OBJECT, OBJ_nid2obj(NID_pkcs7_data));
+ }
+
+ return self;
+}
+
+static VALUE
+ossl_pkcs7_get_signer(VALUE self)
+{
+ PKCS7 *pkcs7;
+ STACK_OF(PKCS7_SIGNER_INFO) *sk;
+ PKCS7_SIGNER_INFO *si;
+ int num, i;
+ VALUE ary;
+
+ GetPKCS7(self, pkcs7);
+ if (!(sk = PKCS7_get_signer_info(pkcs7))) {
+ OSSL_Debug("OpenSSL::PKCS7#get_signer_info == NULL!");
+ return rb_ary_new();
+ }
+ if ((num = sk_PKCS7_SIGNER_INFO_num(sk)) < 0) {
+ ossl_raise(ePKCS7Error, "Negative number of signers!");
+ }
+ ary = rb_ary_new2(num);
+ for (i=0; i<num; i++) {
+ si = sk_PKCS7_SIGNER_INFO_value(sk, i);
+ rb_ary_push(ary, ossl_pkcs7si_new(si));
+ }
+
+ return ary;
+}
+
+static VALUE
+ossl_pkcs7_add_recipient(VALUE self, VALUE recip)
+{
+ PKCS7 *pkcs7;
+ PKCS7_RECIP_INFO *ri;
+
+ ri = DupPKCS7RecipientPtr(recip); /* NEED TO DUP */
+ GetPKCS7(self, pkcs7);
+ if (!PKCS7_add_recipient_info(pkcs7, ri)) {
+ PKCS7_RECIP_INFO_free(ri);
+ ossl_raise(ePKCS7Error, "Could not add recipient.");
+ }
+
+ return self;
+}
+
+static VALUE
+ossl_pkcs7_get_recipient(VALUE self)
+{
+ PKCS7 *pkcs7;
+ STACK_OF(PKCS7_RECIP_INFO) *sk;
+ PKCS7_RECIP_INFO *si;
+ int num, i;
+ VALUE ary;
+
+ GetPKCS7(self, pkcs7);
+ if (PKCS7_type_is_enveloped(pkcs7))
+ sk = pkcs7->d.enveloped->recipientinfo;
+ else if (PKCS7_type_is_signedAndEnveloped(pkcs7))
+ sk = pkcs7->d.signed_and_enveloped->recipientinfo;
+ else sk = NULL;
+ if (!sk) return rb_ary_new();
+ if ((num = sk_PKCS7_RECIP_INFO_num(sk)) < 0) {
+ ossl_raise(ePKCS7Error, "Negative number of recipient!");
+ }
+ ary = rb_ary_new2(num);
+ for (i=0; i<num; i++) {
+ si = sk_PKCS7_RECIP_INFO_value(sk, i);
+ rb_ary_push(ary, ossl_pkcs7ri_new(si));
+ }
+
+ return ary;
+}
+
+static VALUE
+ossl_pkcs7_add_certificate(VALUE self, VALUE cert)
+{
+ PKCS7 *pkcs7;
+ X509 *x509;
+
+ GetPKCS7(self, pkcs7);
+ x509 = GetX509CertPtr(cert); /* NO NEED TO DUP */
+ if (!PKCS7_add_certificate(pkcs7, x509)){
+ ossl_raise(ePKCS7Error, NULL);
+ }
+
+ return self;
+}
+
+static STACK_OF(X509) *
+pkcs7_get_certs(VALUE self)
+{
+ PKCS7 *pkcs7;
+ STACK_OF(X509) *certs;
+ int i;
+
+ GetPKCS7(self, pkcs7);
+ i = OBJ_obj2nid(pkcs7->type);
+ switch(i){
+ case NID_pkcs7_signed:
+ certs = pkcs7->d.sign->cert;
+ break;
+ case NID_pkcs7_signedAndEnveloped:
+ certs = pkcs7->d.signed_and_enveloped->cert;
+ break;
+ default:
+ certs = NULL;
+ }
+
+ return certs;
+}
+
+static STACK_OF(X509_CRL) *
+pkcs7_get_crls(VALUE self)
+{
+ PKCS7 *pkcs7;
+ STACK_OF(X509_CRL) *crls;
+ int i;
+
+ GetPKCS7(self, pkcs7);
+ i = OBJ_obj2nid(pkcs7->type);
+ switch(i){
+ case NID_pkcs7_signed:
+ crls = pkcs7->d.sign->crl;
+ break;
+ case NID_pkcs7_signedAndEnveloped:
+ crls = pkcs7->d.signed_and_enveloped->crl;
+ break;
+ default:
+ crls = NULL;
+ }
+
+ return crls;
+}
+
+static VALUE
+ossl_pkcs7_set_certs_i(RB_BLOCK_CALL_FUNC_ARGLIST(i, arg))
+{
+ return ossl_pkcs7_add_certificate(arg, i);
+}
+
+static VALUE
+ossl_pkcs7_set_certificates(VALUE self, VALUE ary)
+{
+ STACK_OF(X509) *certs;
+ X509 *cert;
+
+ certs = pkcs7_get_certs(self);
+ while((cert = sk_X509_pop(certs))) X509_free(cert);
+ rb_block_call(ary, rb_intern("each"), 0, 0, ossl_pkcs7_set_certs_i, self);
+
+ return ary;
+}
+
+static VALUE
+ossl_pkcs7_get_certificates(VALUE self)
+{
+ return ossl_x509_sk2ary(pkcs7_get_certs(self));
+}
+
+static VALUE
+ossl_pkcs7_add_crl(VALUE self, VALUE crl)
+{
+ PKCS7 *pkcs7;
+ X509_CRL *x509crl;
+
+ GetPKCS7(self, pkcs7); /* NO DUP needed! */
+ x509crl = GetX509CRLPtr(crl);
+ if (!PKCS7_add_crl(pkcs7, x509crl)) {
+ ossl_raise(ePKCS7Error, NULL);
+ }
+
+ return self;
+}
+
+static VALUE
+ossl_pkcs7_set_crls_i(RB_BLOCK_CALL_FUNC_ARGLIST(i, arg))
+{
+ return ossl_pkcs7_add_crl(arg, i);
+}
+
+static VALUE
+ossl_pkcs7_set_crls(VALUE self, VALUE ary)
+{
+ STACK_OF(X509_CRL) *crls;
+ X509_CRL *crl;
+
+ crls = pkcs7_get_crls(self);
+ while((crl = sk_X509_CRL_pop(crls))) X509_CRL_free(crl);
+ rb_block_call(ary, rb_intern("each"), 0, 0, ossl_pkcs7_set_crls_i, self);
+
+ return ary;
+}
+
+static VALUE
+ossl_pkcs7_get_crls(VALUE self)
+{
+ return ossl_x509crl_sk2ary(pkcs7_get_crls(self));
+}
+
+static VALUE
+ossl_pkcs7_verify(int argc, VALUE *argv, VALUE self)
+{
+ VALUE certs, store, indata, flags;
+ STACK_OF(X509) *x509s;
+ X509_STORE *x509st;
+ int flg, ok, status = 0;
+ BIO *in, *out;
+ PKCS7 *p7;
+ VALUE data;
+ const char *msg;
+
+ rb_scan_args(argc, argv, "22", &certs, &store, &indata, &flags);
+ flg = NIL_P(flags) ? 0 : NUM2INT(flags);
+ if(NIL_P(indata)) indata = ossl_pkcs7_get_data(self);
+ in = NIL_P(indata) ? NULL : ossl_obj2bio(indata);
+ if(NIL_P(certs)) x509s = NULL;
+ else{
+ x509s = ossl_protect_x509_ary2sk(certs, &status);
+ if(status){
+ BIO_free(in);
+ rb_jump_tag(status);
+ }
+ }
+ x509st = GetX509StorePtr(store);
+ GetPKCS7(self, p7);
+ if(!(out = BIO_new(BIO_s_mem()))){
+ BIO_free(in);
+ sk_X509_pop_free(x509s, X509_free);
+ ossl_raise(ePKCS7Error, NULL);
+ }
+ ok = PKCS7_verify(p7, x509s, x509st, in, out, flg);
+ BIO_free(in);
+ if (ok < 0) ossl_raise(ePKCS7Error, NULL);
+ msg = ERR_reason_error_string(ERR_get_error());
+ ossl_pkcs7_set_err_string(self, msg ? rb_str_new2(msg) : Qnil);
+ ERR_clear_error();
+ data = ossl_membio2str(out);
+ ossl_pkcs7_set_data(self, data);
+ sk_X509_pop_free(x509s, X509_free);
+
+ return (ok == 1) ? Qtrue : Qfalse;
+}
+
+static VALUE
+ossl_pkcs7_decrypt(int argc, VALUE *argv, VALUE self)
+{
+ VALUE pkey, cert, flags;
+ EVP_PKEY *key;
+ X509 *x509;
+ int flg;
+ PKCS7 *p7;
+ BIO *out;
+ VALUE str;
+
+ rb_scan_args(argc, argv, "21", &pkey, &cert, &flags);
+ key = GetPrivPKeyPtr(pkey); /* NO NEED TO DUP */
+ x509 = GetX509CertPtr(cert); /* NO NEED TO DUP */
+ flg = NIL_P(flags) ? 0 : NUM2INT(flags);
+ GetPKCS7(self, p7);
+ if(!(out = BIO_new(BIO_s_mem())))
+ ossl_raise(ePKCS7Error, NULL);
+ if(!PKCS7_decrypt(p7, key, x509, out, flg)){
+ BIO_free(out);
+ ossl_raise(ePKCS7Error, NULL);
+ }
+ str = ossl_membio2str(out); /* out will be free */
+
+ return str;
+}
+
+static VALUE
+ossl_pkcs7_add_data(VALUE self, VALUE data)
+{
+ PKCS7 *pkcs7;
+ BIO *out, *in;
+ char buf[4096];
+ int len;
+
+ in = ossl_obj2bio(data);
+ GetPKCS7(self, pkcs7);
+ if(PKCS7_type_is_signed(pkcs7)){
+ if(!PKCS7_content_new(pkcs7, NID_pkcs7_data))
+ ossl_raise(ePKCS7Error, NULL);
+ }
+ if(!(out = PKCS7_dataInit(pkcs7, NULL))) goto err;
+ for(;;){
+ if((len = BIO_read(in, buf, sizeof(buf))) <= 0)
+ break;
+ if(BIO_write(out, buf, len) != len)
+ goto err;
+ }
+ if(!PKCS7_dataFinal(pkcs7, out)) goto err;
+ ossl_pkcs7_set_data(self, Qnil);
+
+ err:
+ BIO_free(out);
+ BIO_free(in);
+ if(ERR_peek_error()){
+ ossl_raise(ePKCS7Error, NULL);
+ }
+
+ return data;
+}
+
+static VALUE
+ossl_pkcs7_to_der(VALUE self)
+{
+ PKCS7 *pkcs7;
+ VALUE str;
+ long len;
+ unsigned char *p;
+
+ GetPKCS7(self, pkcs7);
+ if((len = i2d_PKCS7(pkcs7, NULL)) <= 0)
+ ossl_raise(ePKCS7Error, NULL);
+ str = rb_str_new(0, len);
+ p = (unsigned char *)RSTRING_PTR(str);
+ if(i2d_PKCS7(pkcs7, &p) <= 0)
+ ossl_raise(ePKCS7Error, NULL);
+ ossl_str_adjust(str, p);
+
+ return str;
+}
+
+static VALUE
+ossl_pkcs7_to_pem(VALUE self)
+{
+ PKCS7 *pkcs7;
+ BIO *out;
+ VALUE str;
+
+ GetPKCS7(self, pkcs7);
+ if (!(out = BIO_new(BIO_s_mem()))) {
+ ossl_raise(ePKCS7Error, NULL);
+ }
+ if (!PEM_write_bio_PKCS7(out, pkcs7)) {
+ BIO_free(out);
+ ossl_raise(ePKCS7Error, NULL);
+ }
+ str = ossl_membio2str(out);
+
+ return str;
+}
+
+/*
+ * SIGNER INFO
+ */
+static VALUE
+ossl_pkcs7si_alloc(VALUE klass)
+{
+ PKCS7_SIGNER_INFO *p7si;
+ VALUE obj;
+
+ if (!(p7si = PKCS7_SIGNER_INFO_new())) {
+ ossl_raise(ePKCS7Error, NULL);
+ }
+ WrapPKCS7si(klass, obj, p7si);
+
+ return obj;
+}
+
+static VALUE
+ossl_pkcs7si_initialize(VALUE self, VALUE cert, VALUE key, VALUE digest)
+{
+ PKCS7_SIGNER_INFO *p7si;
+ EVP_PKEY *pkey;
+ X509 *x509;
+ const EVP_MD *md;
+
+ pkey = GetPrivPKeyPtr(key); /* NO NEED TO DUP */
+ x509 = GetX509CertPtr(cert); /* NO NEED TO DUP */
+ md = GetDigestPtr(digest);
+ GetPKCS7si(self, p7si);
+ if (!(PKCS7_SIGNER_INFO_set(p7si, x509, pkey, (EVP_MD*)md))) {
+ ossl_raise(ePKCS7Error, NULL);
+ }
+
+ return self;
+}
+
+static VALUE
+ossl_pkcs7si_get_issuer(VALUE self)
+{
+ PKCS7_SIGNER_INFO *p7si;
+
+ GetPKCS7si(self, p7si);
+
+ return ossl_x509name_new(p7si->issuer_and_serial->issuer);
+}
+
+static VALUE
+ossl_pkcs7si_get_serial(VALUE self)
+{
+ PKCS7_SIGNER_INFO *p7si;
+
+ GetPKCS7si(self, p7si);
+
+ return asn1integer_to_num(p7si->issuer_and_serial->serial);
+}
+
+static VALUE
+ossl_pkcs7si_get_signed_time(VALUE self)
+{
+ PKCS7_SIGNER_INFO *p7si;
+ ASN1_TYPE *asn1obj;
+
+ GetPKCS7si(self, p7si);
+
+ if (!(asn1obj = PKCS7_get_signed_attribute(p7si, NID_pkcs9_signingTime))) {
+ ossl_raise(ePKCS7Error, NULL);
+ }
+ if (asn1obj->type == V_ASN1_UTCTIME) {
+ return asn1time_to_time(asn1obj->value.utctime);
+ }
+ /*
+ * OR
+ * ossl_raise(ePKCS7Error, "...");
+ * ?
+ */
+
+ return Qnil;
+}
+
+/*
+ * RECIPIENT INFO
+ */
+static VALUE
+ossl_pkcs7ri_alloc(VALUE klass)
+{
+ PKCS7_RECIP_INFO *p7ri;
+ VALUE obj;
+
+ if (!(p7ri = PKCS7_RECIP_INFO_new())) {
+ ossl_raise(ePKCS7Error, NULL);
+ }
+ WrapPKCS7ri(klass, obj, p7ri);
+
+ return obj;
+}
+
+static VALUE
+ossl_pkcs7ri_initialize(VALUE self, VALUE cert)
+{
+ PKCS7_RECIP_INFO *p7ri;
+ X509 *x509;
+
+ x509 = GetX509CertPtr(cert); /* NO NEED TO DUP */
+ GetPKCS7ri(self, p7ri);
+ if (!PKCS7_RECIP_INFO_set(p7ri, x509)) {
+ ossl_raise(ePKCS7Error, NULL);
+ }
+
+ return self;
+}
+
+static VALUE
+ossl_pkcs7ri_get_issuer(VALUE self)
+{
+ PKCS7_RECIP_INFO *p7ri;
+
+ GetPKCS7ri(self, p7ri);
+
+ return ossl_x509name_new(p7ri->issuer_and_serial->issuer);
+}
+
+static VALUE
+ossl_pkcs7ri_get_serial(VALUE self)
+{
+ PKCS7_RECIP_INFO *p7ri;
+
+ GetPKCS7ri(self, p7ri);
+
+ return asn1integer_to_num(p7ri->issuer_and_serial->serial);
+}
+
+static VALUE
+ossl_pkcs7ri_get_enc_key(VALUE self)
+{
+ PKCS7_RECIP_INFO *p7ri;
+
+ GetPKCS7ri(self, p7ri);
+
+ return asn1str_to_str(p7ri->enc_key);
+}
+
+/*
+ * INIT
+ */
+void
+Init_ossl_pkcs7(void)
+{
+ cPKCS7 = rb_define_class_under(mOSSL, "PKCS7", rb_cObject);
+ ePKCS7Error = rb_define_class_under(cPKCS7, "PKCS7Error", eOSSLError);
+ rb_define_singleton_method(cPKCS7, "read_smime", ossl_pkcs7_s_read_smime, 1);
+ rb_define_singleton_method(cPKCS7, "write_smime", ossl_pkcs7_s_write_smime, -1);
+ rb_define_singleton_method(cPKCS7, "sign", ossl_pkcs7_s_sign, -1);
+ rb_define_singleton_method(cPKCS7, "encrypt", ossl_pkcs7_s_encrypt, -1);
+ rb_attr(cPKCS7, rb_intern("data"), 1, 0, Qfalse);
+ rb_attr(cPKCS7, rb_intern("error_string"), 1, 1, Qfalse);
+ rb_define_alloc_func(cPKCS7, ossl_pkcs7_alloc);
+ rb_define_copy_func(cPKCS7, ossl_pkcs7_copy);
+ rb_define_method(cPKCS7, "initialize", ossl_pkcs7_initialize, -1);
+ rb_define_method(cPKCS7, "type=", ossl_pkcs7_set_type, 1);
+ rb_define_method(cPKCS7, "type", ossl_pkcs7_get_type, 0);
+ rb_define_method(cPKCS7, "detached=", ossl_pkcs7_set_detached, 1);
+ rb_define_method(cPKCS7, "detached", ossl_pkcs7_get_detached, 0);
+ rb_define_method(cPKCS7, "detached?", ossl_pkcs7_detached_p, 0);
+ rb_define_method(cPKCS7, "cipher=", ossl_pkcs7_set_cipher, 1);
+ rb_define_method(cPKCS7, "add_signer", ossl_pkcs7_add_signer, 1);
+ rb_define_method(cPKCS7, "signers", ossl_pkcs7_get_signer, 0);
+ rb_define_method(cPKCS7, "add_recipient", ossl_pkcs7_add_recipient, 1);
+ rb_define_method(cPKCS7, "recipients", ossl_pkcs7_get_recipient, 0);
+ rb_define_method(cPKCS7, "add_certificate", ossl_pkcs7_add_certificate, 1);
+ rb_define_method(cPKCS7, "certificates=", ossl_pkcs7_set_certificates, 1);
+ rb_define_method(cPKCS7, "certificates", ossl_pkcs7_get_certificates, 0);
+ rb_define_method(cPKCS7, "add_crl", ossl_pkcs7_add_crl, 1);
+ rb_define_method(cPKCS7, "crls=", ossl_pkcs7_set_crls, 1);
+ rb_define_method(cPKCS7, "crls", ossl_pkcs7_get_crls, 0);
+ rb_define_method(cPKCS7, "add_data", ossl_pkcs7_add_data, 1);
+ rb_define_alias(cPKCS7, "data=", "add_data");
+ rb_define_method(cPKCS7, "verify", ossl_pkcs7_verify, -1);
+ rb_define_method(cPKCS7, "decrypt", ossl_pkcs7_decrypt, -1);
+ rb_define_method(cPKCS7, "to_pem", ossl_pkcs7_to_pem, 0);
+ rb_define_alias(cPKCS7, "to_s", "to_pem");
+ rb_define_method(cPKCS7, "to_der", ossl_pkcs7_to_der, 0);
+
+ cPKCS7Signer = rb_define_class_under(cPKCS7, "SignerInfo", rb_cObject);
+ rb_define_const(cPKCS7, "Signer", cPKCS7Signer);
+ rb_define_alloc_func(cPKCS7Signer, ossl_pkcs7si_alloc);
+ rb_define_method(cPKCS7Signer, "initialize", ossl_pkcs7si_initialize,3);
+ rb_define_method(cPKCS7Signer, "issuer", ossl_pkcs7si_get_issuer, 0);
+ rb_define_alias(cPKCS7Signer, "name", "issuer");
+ rb_define_method(cPKCS7Signer, "serial", ossl_pkcs7si_get_serial,0);
+ rb_define_method(cPKCS7Signer,"signed_time",ossl_pkcs7si_get_signed_time,0);
+
+ cPKCS7Recipient = rb_define_class_under(cPKCS7,"RecipientInfo",rb_cObject);
+ rb_define_alloc_func(cPKCS7Recipient, ossl_pkcs7ri_alloc);
+ rb_define_method(cPKCS7Recipient, "initialize", ossl_pkcs7ri_initialize,1);
+ rb_define_method(cPKCS7Recipient, "issuer", ossl_pkcs7ri_get_issuer,0);
+ rb_define_method(cPKCS7Recipient, "serial", ossl_pkcs7ri_get_serial,0);
+ rb_define_method(cPKCS7Recipient, "enc_key", ossl_pkcs7ri_get_enc_key,0);
+
+#define DefPKCS7Const(x) rb_define_const(cPKCS7, #x, INT2NUM(PKCS7_##x))
+
+ DefPKCS7Const(TEXT);
+ DefPKCS7Const(NOCERTS);
+ DefPKCS7Const(NOSIGS);
+ DefPKCS7Const(NOCHAIN);
+ DefPKCS7Const(NOINTERN);
+ DefPKCS7Const(NOVERIFY);
+ DefPKCS7Const(DETACHED);
+ DefPKCS7Const(BINARY);
+ DefPKCS7Const(NOATTR);
+ DefPKCS7Const(NOSMIMECAP);
+}
diff --git a/jni/ruby/ext/openssl/ossl_pkcs7.h b/jni/ruby/ext/openssl/ossl_pkcs7.h
new file mode 100644
index 0000000..4d86af9
--- /dev/null
+++ b/jni/ruby/ext/openssl/ossl_pkcs7.h
@@ -0,0 +1,22 @@
+/*
+ * $Id: ossl_pkcs7.h 25189 2009-10-02 12:04:37Z akr $
+ * 'OpenSSL for Ruby' project
+ * Copyright (C) 2001-2002 Michal Rokos <m.rokos@sh.cvut.cz>
+ * All rights reserved.
+ */
+/*
+ * This program is licenced under the same licence as Ruby.
+ * (See the file 'LICENCE'.)
+ */
+#if !defined(_OSSL_PKCS7_H_)
+#define _OSSL_PKCS7_H_
+
+extern VALUE cPKCS7;
+extern VALUE cPKCS7Signer;
+extern VALUE cPKCS7Recipient;
+extern VALUE ePKCS7Error;
+
+void Init_ossl_pkcs7(void);
+
+#endif /* _OSSL_PKCS7_H_ */
+
diff --git a/jni/ruby/ext/openssl/ossl_pkey.c b/jni/ruby/ext/openssl/ossl_pkey.c
new file mode 100644
index 0000000..9144496
--- /dev/null
+++ b/jni/ruby/ext/openssl/ossl_pkey.c
@@ -0,0 +1,453 @@
+/*
+ * $Id: ossl_pkey.c 48806 2014-12-12 23:19:07Z nobu $
+ * 'OpenSSL for Ruby' project
+ * Copyright (C) 2001-2002 Michal Rokos <m.rokos@sh.cvut.cz>
+ * All rights reserved.
+ */
+/*
+ * This program is licenced under the same licence as Ruby.
+ * (See the file 'LICENCE'.)
+ */
+#include "ossl.h"
+
+/*
+ * Classes
+ */
+VALUE mPKey;
+VALUE cPKey;
+VALUE ePKeyError;
+ID id_private_q;
+
+/*
+ * callback for generating keys
+ */
+void
+ossl_generate_cb(int p, int n, void *arg)
+{
+ VALUE ary;
+
+ ary = rb_ary_new2(2);
+ rb_ary_store(ary, 0, INT2NUM(p));
+ rb_ary_store(ary, 1, INT2NUM(n));
+
+ rb_yield(ary);
+}
+
+#if HAVE_BN_GENCB
+/* OpenSSL 2nd version of GN generation callback */
+int
+ossl_generate_cb_2(int p, int n, BN_GENCB *cb)
+{
+ VALUE ary;
+ struct ossl_generate_cb_arg *arg;
+ int state;
+
+ arg = (struct ossl_generate_cb_arg *)cb->arg;
+ if (arg->yield) {
+ ary = rb_ary_new2(2);
+ rb_ary_store(ary, 0, INT2NUM(p));
+ rb_ary_store(ary, 1, INT2NUM(n));
+
+ /*
+ * can be break by raising exception or 'break'
+ */
+ rb_protect(rb_yield, ary, &state);
+ if (state) {
+ arg->stop = 1;
+ arg->state = state;
+ }
+ }
+ if (arg->stop) return 0;
+ return 1;
+}
+
+void
+ossl_generate_cb_stop(void *ptr)
+{
+ struct ossl_generate_cb_arg *arg = (struct ossl_generate_cb_arg *)ptr;
+ arg->stop = 1;
+}
+#endif
+
+static void
+ossl_evp_pkey_free(void *ptr)
+{
+ EVP_PKEY_free(ptr);
+}
+
+/*
+ * Public
+ */
+const rb_data_type_t ossl_evp_pkey_type = {
+ "OpenSSL/EVP_PKEY",
+ {
+ 0, ossl_evp_pkey_free,
+ },
+ 0, 0, RUBY_TYPED_FREE_IMMEDIATELY,
+};
+
+VALUE
+ossl_pkey_new(EVP_PKEY *pkey)
+{
+ if (!pkey) {
+ ossl_raise(ePKeyError, "Cannot make new key from NULL.");
+ }
+ switch (EVP_PKEY_type(pkey->type)) {
+#if !defined(OPENSSL_NO_RSA)
+ case EVP_PKEY_RSA:
+ return ossl_rsa_new(pkey);
+#endif
+#if !defined(OPENSSL_NO_DSA)
+ case EVP_PKEY_DSA:
+ return ossl_dsa_new(pkey);
+#endif
+#if !defined(OPENSSL_NO_DH)
+ case EVP_PKEY_DH:
+ return ossl_dh_new(pkey);
+#endif
+#if !defined(OPENSSL_NO_EC) && (OPENSSL_VERSION_NUMBER >= 0x0090802fL)
+ case EVP_PKEY_EC:
+ return ossl_ec_new(pkey);
+#endif
+ default:
+ ossl_raise(ePKeyError, "unsupported key type");
+ }
+
+ UNREACHABLE;
+}
+
+VALUE
+ossl_pkey_new_from_file(VALUE filename)
+{
+ FILE *fp;
+ EVP_PKEY *pkey;
+
+ SafeStringValue(filename);
+ if (!(fp = fopen(RSTRING_PTR(filename), "r"))) {
+ ossl_raise(ePKeyError, "%s", strerror(errno));
+ }
+ rb_fd_fix_cloexec(fileno(fp));
+
+ pkey = PEM_read_PrivateKey(fp, NULL, ossl_pem_passwd_cb, NULL);
+ fclose(fp);
+ if (!pkey) {
+ ossl_raise(ePKeyError, NULL);
+ }
+
+ return ossl_pkey_new(pkey);
+}
+
+/*
+ * call-seq:
+ * OpenSSL::PKey.read(string [, pwd ] ) -> PKey
+ * OpenSSL::PKey.read(file [, pwd ]) -> PKey
+ *
+ * === Parameters
+ * * +string+ is a DER- or PEM-encoded string containing an arbitrary private
+ * or public key.
+ * * +file+ is an instance of +File+ containing a DER- or PEM-encoded
+ * arbitrary private or public key.
+ * * +pwd+ is an optional password in case +string+ or +file+ is an encrypted
+ * PEM resource.
+ */
+static VALUE
+ossl_pkey_new_from_data(int argc, VALUE *argv, VALUE self)
+{
+ EVP_PKEY *pkey;
+ BIO *bio;
+ VALUE data, pass;
+ char *passwd = NULL;
+
+ rb_scan_args(argc, argv, "11", &data, &pass);
+
+ bio = ossl_obj2bio(data);
+ if (!(pkey = d2i_PrivateKey_bio(bio, NULL))) {
+ OSSL_BIO_reset(bio);
+ if (!NIL_P(pass)) {
+ passwd = StringValuePtr(pass);
+ }
+ if (!(pkey = PEM_read_bio_PrivateKey(bio, NULL, ossl_pem_passwd_cb, passwd))) {
+ OSSL_BIO_reset(bio);
+ if (!(pkey = d2i_PUBKEY_bio(bio, NULL))) {
+ OSSL_BIO_reset(bio);
+ if (!NIL_P(pass)) {
+ passwd = StringValuePtr(pass);
+ }
+ pkey = PEM_read_bio_PUBKEY(bio, NULL, ossl_pem_passwd_cb, passwd);
+ }
+ }
+ }
+
+ BIO_free(bio);
+ if (!pkey)
+ ossl_raise(rb_eArgError, "Could not parse PKey");
+ return ossl_pkey_new(pkey);
+}
+
+EVP_PKEY *
+GetPKeyPtr(VALUE obj)
+{
+ EVP_PKEY *pkey;
+
+ SafeGetPKey(obj, pkey);
+
+ return pkey;
+}
+
+EVP_PKEY *
+GetPrivPKeyPtr(VALUE obj)
+{
+ EVP_PKEY *pkey;
+
+ if (rb_funcall(obj, id_private_q, 0, NULL) != Qtrue) {
+ ossl_raise(rb_eArgError, "Private key is needed.");
+ }
+ SafeGetPKey(obj, pkey);
+
+ return pkey;
+}
+
+EVP_PKEY *
+DupPKeyPtr(VALUE obj)
+{
+ EVP_PKEY *pkey;
+
+ SafeGetPKey(obj, pkey);
+ CRYPTO_add(&pkey->references, 1, CRYPTO_LOCK_EVP_PKEY);
+
+ return pkey;
+}
+
+EVP_PKEY *
+DupPrivPKeyPtr(VALUE obj)
+{
+ EVP_PKEY *pkey;
+
+ if (rb_funcall(obj, id_private_q, 0, NULL) != Qtrue) {
+ ossl_raise(rb_eArgError, "Private key is needed.");
+ }
+ SafeGetPKey(obj, pkey);
+ CRYPTO_add(&pkey->references, 1, CRYPTO_LOCK_EVP_PKEY);
+
+ return pkey;
+}
+
+/*
+ * Private
+ */
+static VALUE
+ossl_pkey_alloc(VALUE klass)
+{
+ EVP_PKEY *pkey;
+ VALUE obj;
+
+ if (!(pkey = EVP_PKEY_new())) {
+ ossl_raise(ePKeyError, NULL);
+ }
+ WrapPKey(klass, obj, pkey);
+
+ return obj;
+}
+
+/*
+ * call-seq:
+ * PKeyClass.new -> self
+ *
+ * Because PKey is an abstract class, actually calling this method explicitly
+ * will raise a +NotImplementedError+.
+ */
+static VALUE
+ossl_pkey_initialize(VALUE self)
+{
+ if (rb_obj_is_instance_of(self, cPKey)) {
+ ossl_raise(rb_eNotImpError, "OpenSSL::PKey::PKey is an abstract class.");
+ }
+ return self;
+}
+
+/*
+ * call-seq:
+ * pkey.sign(digest, data) -> String
+ *
+ * To sign the +String+ +data+, +digest+, an instance of OpenSSL::Digest, must
+ * be provided. The return value is again a +String+ containing the signature.
+ * A PKeyError is raised should errors occur.
+ * Any previous state of the +Digest+ instance is irrelevant to the signature
+ * outcome, the digest instance is reset to its initial state during the
+ * operation.
+ *
+ * == Example
+ * data = 'Sign me!'
+ * digest = OpenSSL::Digest::SHA256.new
+ * pkey = OpenSSL::PKey::RSA.new(2048)
+ * signature = pkey.sign(digest, data)
+ */
+static VALUE
+ossl_pkey_sign(VALUE self, VALUE digest, VALUE data)
+{
+ EVP_PKEY *pkey;
+ EVP_MD_CTX ctx;
+ unsigned int buf_len;
+ VALUE str;
+
+ if (rb_funcall(self, id_private_q, 0, NULL) != Qtrue) {
+ ossl_raise(rb_eArgError, "Private key is needed.");
+ }
+ GetPKey(self, pkey);
+ EVP_SignInit(&ctx, GetDigestPtr(digest));
+ StringValue(data);
+ EVP_SignUpdate(&ctx, RSTRING_PTR(data), RSTRING_LEN(data));
+ str = rb_str_new(0, EVP_PKEY_size(pkey)+16);
+ if (!EVP_SignFinal(&ctx, (unsigned char *)RSTRING_PTR(str), &buf_len, pkey))
+ ossl_raise(ePKeyError, NULL);
+ assert((long)buf_len <= RSTRING_LEN(str));
+ rb_str_set_len(str, buf_len);
+
+ return str;
+}
+
+/*
+ * call-seq:
+ * pkey.verify(digest, signature, data) -> String
+ *
+ * To verify the +String+ +signature+, +digest+, an instance of
+ * OpenSSL::Digest, must be provided to re-compute the message digest of the
+ * original +data+, also a +String+. The return value is +true+ if the
+ * signature is valid, +false+ otherwise. A PKeyError is raised should errors
+ * occur.
+ * Any previous state of the +Digest+ instance is irrelevant to the validation
+ * outcome, the digest instance is reset to its initial state during the
+ * operation.
+ *
+ * == Example
+ * data = 'Sign me!'
+ * digest = OpenSSL::Digest::SHA256.new
+ * pkey = OpenSSL::PKey::RSA.new(2048)
+ * signature = pkey.sign(digest, data)
+ * pub_key = pkey.public_key
+ * puts pub_key.verify(digest, signature, data) # => true
+ */
+static VALUE
+ossl_pkey_verify(VALUE self, VALUE digest, VALUE sig, VALUE data)
+{
+ EVP_PKEY *pkey;
+ EVP_MD_CTX ctx;
+ int result;
+
+ GetPKey(self, pkey);
+ StringValue(sig);
+ StringValue(data);
+ EVP_VerifyInit(&ctx, GetDigestPtr(digest));
+ EVP_VerifyUpdate(&ctx, RSTRING_PTR(data), RSTRING_LEN(data));
+ result = EVP_VerifyFinal(&ctx, (unsigned char *)RSTRING_PTR(sig), RSTRING_LENINT(sig), pkey);
+ EVP_MD_CTX_cleanup(&ctx);
+ switch (result) {
+ case 0:
+ return Qfalse;
+ case 1:
+ return Qtrue;
+ default:
+ ossl_raise(ePKeyError, NULL);
+ }
+ return Qnil; /* dummy */
+}
+
+/*
+ * INIT
+ */
+void
+Init_ossl_pkey(void)
+{
+#if 0
+ mOSSL = rb_define_module("OpenSSL"); /* let rdoc know about mOSSL */
+#endif
+
+ /* Document-module: OpenSSL::PKey
+ *
+ * == Asymmetric Public Key Algorithms
+ *
+ * Asymmetric public key algorithms solve the problem of establishing and
+ * sharing secret keys to en-/decrypt messages. The key in such an
+ * algorithm consists of two parts: a public key that may be distributed
+ * to others and a private key that needs to remain secret.
+ *
+ * Messages encrypted with a public key can only be encrypted by
+ * recipients that are in possession of the associated private key.
+ * Since public key algorithms are considerably slower than symmetric
+ * key algorithms (cf. OpenSSL::Cipher) they are often used to establish
+ * a symmetric key shared between two parties that are in possession of
+ * each other's public key.
+ *
+ * Asymmetric algorithms offer a lot of nice features that are used in a
+ * lot of different areas. A very common application is the creation and
+ * validation of digital signatures. To sign a document, the signatory
+ * generally uses a message digest algorithm (cf. OpenSSL::Digest) to
+ * compute a digest of the document that is then encrypted (i.e. signed)
+ * using the private key. Anyone in possession of the public key may then
+ * verify the signature by computing the message digest of the original
+ * document on their own, decrypting the signature using the signatory's
+ * public key and comparing the result to the message digest they
+ * previously computed. The signature is valid if and only if the
+ * decrypted signature is equal to this message digest.
+ *
+ * The PKey module offers support for three popular public/private key
+ * algorithms:
+ * * RSA (OpenSSL::PKey::RSA)
+ * * DSA (OpenSSL::PKey::DSA)
+ * * Elliptic Curve Cryptography (OpenSSL::PKey::EC)
+ * Each of these implementations is in fact a sub-class of the abstract
+ * PKey class which offers the interface for supporting digital signatures
+ * in the form of PKey#sign and PKey#verify.
+ *
+ * == Diffie-Hellman Key Exchange
+ *
+ * Finally PKey also features OpenSSL::PKey::DH, an implementation of
+ * the Diffie-Hellman key exchange protocol based on discrete logarithms
+ * in finite fields, the same basis that DSA is built on.
+ * The Diffie-Hellman protocol can be used to exchange (symmetric) keys
+ * over insecure channels without needing any prior joint knowledge
+ * between the participating parties. As the security of DH demands
+ * relatively long "public keys" (i.e. the part that is overtly
+ * transmitted between participants) DH tends to be quite slow. If
+ * security or speed is your primary concern, OpenSSL::PKey::EC offers
+ * another implementation of the Diffie-Hellman protocol.
+ *
+ */
+ mPKey = rb_define_module_under(mOSSL, "PKey");
+
+ /* Document-class: OpenSSL::PKey::PKeyError
+ *
+ *Raised when errors occur during PKey#sign or PKey#verify.
+ */
+ ePKeyError = rb_define_class_under(mPKey, "PKeyError", eOSSLError);
+
+ /* Document-class: OpenSSL::PKey::PKey
+ *
+ * An abstract class that bundles signature creation (PKey#sign) and
+ * validation (PKey#verify) that is common to all implementations except
+ * OpenSSL::PKey::DH
+ * * OpenSSL::PKey::RSA
+ * * OpenSSL::PKey::DSA
+ * * OpenSSL::PKey::EC
+ */
+ cPKey = rb_define_class_under(mPKey, "PKey", rb_cObject);
+
+ rb_define_module_function(mPKey, "read", ossl_pkey_new_from_data, -1);
+
+ rb_define_alloc_func(cPKey, ossl_pkey_alloc);
+ rb_define_method(cPKey, "initialize", ossl_pkey_initialize, 0);
+
+ rb_define_method(cPKey, "sign", ossl_pkey_sign, 2);
+ rb_define_method(cPKey, "verify", ossl_pkey_verify, 3);
+
+ id_private_q = rb_intern("private?");
+
+ /*
+ * INIT rsa, dsa, dh, ec
+ */
+ Init_ossl_rsa();
+ Init_ossl_dsa();
+ Init_ossl_dh();
+ Init_ossl_ec();
+}
+
diff --git a/jni/ruby/ext/openssl/ossl_pkey.h b/jni/ruby/ext/openssl/ossl_pkey.h
new file mode 100644
index 0000000..8611ba7
--- /dev/null
+++ b/jni/ruby/ext/openssl/ossl_pkey.h
@@ -0,0 +1,152 @@
+/*
+ * $Id: ossl_pkey.h 48806 2014-12-12 23:19:07Z nobu $
+ * 'OpenSSL for Ruby' project
+ * Copyright (C) 2001 Michal Rokos <m.rokos@sh.cvut.cz>
+ * All rights reserved.
+ */
+/*
+ * This program is licenced under the same licence as Ruby.
+ * (See the file 'LICENCE'.)
+ */
+#if !defined(_OSSL_PKEY_H_)
+#define _OSSL_PKEY_H_
+
+extern VALUE mPKey;
+extern VALUE cPKey;
+extern VALUE ePKeyError;
+extern ID id_private_q;
+extern const rb_data_type_t ossl_evp_pkey_type;
+
+#define OSSL_PKEY_SET_PRIVATE(obj) rb_iv_set((obj), "private", Qtrue)
+#define OSSL_PKEY_SET_PUBLIC(obj) rb_iv_set((obj), "private", Qfalse)
+#define OSSL_PKEY_IS_PRIVATE(obj) (rb_iv_get((obj), "private") == Qtrue)
+
+#define WrapPKey(klass, obj, pkey) do { \
+ if (!(pkey)) { \
+ rb_raise(rb_eRuntimeError, "PKEY wasn't initialized!"); \
+ } \
+ (obj) = TypedData_Wrap_Struct((klass), &ossl_evp_pkey_type, (pkey)); \
+ OSSL_PKEY_SET_PUBLIC(obj); \
+} while (0)
+#define GetPKey(obj, pkey) do {\
+ TypedData_Get_Struct((obj), EVP_PKEY, &ossl_evp_pkey_type, (pkey)); \
+ if (!(pkey)) { \
+ rb_raise(rb_eRuntimeError, "PKEY wasn't initialized!");\
+ } \
+} while (0)
+#define SafeGetPKey(obj, pkey) do { \
+ OSSL_Check_Kind((obj), cPKey); \
+ GetPKey((obj), (pkey)); \
+} while (0)
+
+void ossl_generate_cb(int, int, void *);
+#define HAVE_BN_GENCB defined(HAVE_RSA_GENERATE_KEY_EX) || defined(HAVE_DH_GENERATE_PARAMETERS_EX) || defined(HAVE_DSA_GENERATE_PARAMETERS_EX)
+#if HAVE_BN_GENCB
+struct ossl_generate_cb_arg {
+ int yield;
+ int stop;
+ int state;
+};
+int ossl_generate_cb_2(int p, int n, BN_GENCB *cb);
+void ossl_generate_cb_stop(void *ptr);
+#endif
+
+VALUE ossl_pkey_new(EVP_PKEY *);
+VALUE ossl_pkey_new_from_file(VALUE);
+EVP_PKEY *GetPKeyPtr(VALUE);
+EVP_PKEY *DupPKeyPtr(VALUE);
+EVP_PKEY *GetPrivPKeyPtr(VALUE);
+EVP_PKEY *DupPrivPKeyPtr(VALUE);
+void Init_ossl_pkey(void);
+
+/*
+ * RSA
+ */
+extern VALUE cRSA;
+extern VALUE eRSAError;
+
+VALUE ossl_rsa_new(EVP_PKEY *);
+void Init_ossl_rsa(void);
+
+/*
+ * DSA
+ */
+extern VALUE cDSA;
+extern VALUE eDSAError;
+
+VALUE ossl_dsa_new(EVP_PKEY *);
+void Init_ossl_dsa(void);
+
+/*
+ * DH
+ */
+extern VALUE cDH;
+extern VALUE eDHError;
+extern DH *OSSL_DEFAULT_DH_512;
+extern DH *OSSL_DEFAULT_DH_1024;
+
+VALUE ossl_dh_new(EVP_PKEY *);
+void Init_ossl_dh(void);
+
+/*
+ * EC
+ */
+extern VALUE cEC;
+extern VALUE eECError;
+extern VALUE cEC_GROUP;
+extern VALUE eEC_GROUP;
+extern VALUE cEC_POINT;
+extern VALUE eEC_POINT;
+VALUE ossl_ec_new(EVP_PKEY *);
+void Init_ossl_ec(void);
+
+
+#define OSSL_PKEY_BN(keytype, name) \
+/* \
+ * call-seq: \
+ * key.##name -> aBN \
+ */ \
+static VALUE ossl_##keytype##_get_##name(VALUE self) \
+{ \
+ EVP_PKEY *pkey; \
+ BIGNUM *bn; \
+ \
+ GetPKey(self, pkey); \
+ bn = pkey->pkey.keytype->name; \
+ if (bn == NULL) \
+ return Qnil; \
+ return ossl_bn_new(bn); \
+} \
+/* \
+ * call-seq: \
+ * key.##name = bn -> bn \
+ */ \
+static VALUE ossl_##keytype##_set_##name(VALUE self, VALUE bignum) \
+{ \
+ EVP_PKEY *pkey; \
+ BIGNUM *bn; \
+ \
+ GetPKey(self, pkey); \
+ if (NIL_P(bignum)) { \
+ BN_clear_free(pkey->pkey.keytype->name); \
+ pkey->pkey.keytype->name = NULL; \
+ return Qnil; \
+ } \
+ \
+ bn = GetBNPtr(bignum); \
+ if (pkey->pkey.keytype->name == NULL) \
+ pkey->pkey.keytype->name = BN_new(); \
+ if (pkey->pkey.keytype->name == NULL) \
+ ossl_raise(eBNError, NULL); \
+ if (BN_copy(pkey->pkey.keytype->name, bn) == NULL) \
+ ossl_raise(eBNError, NULL); \
+ return bignum; \
+}
+
+#define DEF_OSSL_PKEY_BN(class, keytype, name) \
+do { \
+ rb_define_method((class), #name, ossl_##keytype##_get_##name, 0); \
+ rb_define_method((class), #name "=", ossl_##keytype##_set_##name, 1);\
+} while (0)
+
+#endif /* _OSSL_PKEY_H_ */
diff --git a/jni/ruby/ext/openssl/ossl_pkey_dh.c b/jni/ruby/ext/openssl/ossl_pkey_dh.c
new file mode 100644
index 0000000..084deec
--- /dev/null
+++ b/jni/ruby/ext/openssl/ossl_pkey_dh.c
@@ -0,0 +1,666 @@
+/*
+ * $Id: ossl_pkey_dh.c 47744 2014-09-30 05:25:32Z nobu $
+ * 'OpenSSL for Ruby' project
+ * Copyright (C) 2001-2002 Michal Rokos <m.rokos@sh.cvut.cz>
+ * All rights reserved.
+ */
+/*
+ * This program is licenced under the same licence as Ruby.
+ * (See the file 'LICENCE'.)
+ */
+#if !defined(OPENSSL_NO_DH)
+
+#include "ossl.h"
+
+#define GetPKeyDH(obj, pkey) do { \
+ GetPKey((obj), (pkey)); \
+ if (EVP_PKEY_type((pkey)->type) != EVP_PKEY_DH) { /* PARANOIA? */ \
+ ossl_raise(rb_eRuntimeError, "THIS IS NOT A DH!") ; \
+ } \
+} while (0)
+
+#define DH_HAS_PRIVATE(dh) ((dh)->priv_key)
+
+#ifdef OSSL_ENGINE_ENABLED
+# define DH_PRIVATE(dh) (DH_HAS_PRIVATE(dh) || (dh)->engine)
+#else
+# define DH_PRIVATE(dh) DH_HAS_PRIVATE(dh)
+#endif
+
+
+/*
+ * Classes
+ */
+VALUE cDH;
+VALUE eDHError;
+
+/*
+ * Public
+ */
+static VALUE
+dh_instance(VALUE klass, DH *dh)
+{
+ EVP_PKEY *pkey;
+ VALUE obj;
+
+ if (!dh) {
+ return Qfalse;
+ }
+ if (!(pkey = EVP_PKEY_new())) {
+ return Qfalse;
+ }
+ if (!EVP_PKEY_assign_DH(pkey, dh)) {
+ EVP_PKEY_free(pkey);
+ return Qfalse;
+ }
+ WrapPKey(klass, obj, pkey);
+
+ return obj;
+}
+
+VALUE
+ossl_dh_new(EVP_PKEY *pkey)
+{
+ VALUE obj;
+
+ if (!pkey) {
+ obj = dh_instance(cDH, DH_new());
+ } else {
+ if (EVP_PKEY_type(pkey->type) != EVP_PKEY_DH) {
+ ossl_raise(rb_eTypeError, "Not a DH key!");
+ }
+ WrapPKey(cDH, obj, pkey);
+ }
+ if (obj == Qfalse) {
+ ossl_raise(eDHError, NULL);
+ }
+
+ return obj;
+}
+
+/*
+ * Private
+ */
+#if defined(HAVE_DH_GENERATE_PARAMETERS_EX) && HAVE_BN_GENCB
+struct dh_blocking_gen_arg {
+ DH *dh;
+ int size;
+ int gen;
+ BN_GENCB *cb;
+ int result;
+};
+
+static void *
+dh_blocking_gen(void *arg)
+{
+ struct dh_blocking_gen_arg *gen = (struct dh_blocking_gen_arg *)arg;
+ gen->result = DH_generate_parameters_ex(gen->dh, gen->size, gen->gen, gen->cb);
+ return 0;
+}
+#endif
+
+static DH *
+dh_generate(int size, int gen)
+{
+#if defined(HAVE_DH_GENERATE_PARAMETERS_EX) && HAVE_BN_GENCB
+ BN_GENCB cb;
+ struct ossl_generate_cb_arg cb_arg;
+ struct dh_blocking_gen_arg gen_arg;
+ DH *dh = DH_new();
+
+ if (!dh) return 0;
+
+ memset(&cb_arg, 0, sizeof(struct ossl_generate_cb_arg));
+ if (rb_block_given_p())
+ cb_arg.yield = 1;
+ BN_GENCB_set(&cb, ossl_generate_cb_2, &cb_arg);
+ gen_arg.dh = dh;
+ gen_arg.size = size;
+ gen_arg.gen = gen;
+ gen_arg.cb = &cb;
+ if (cb_arg.yield == 1) {
+ /* we cannot release GVL when callback proc is supplied */
+ dh_blocking_gen(&gen_arg);
+ } else {
+ /* there's a chance to unblock */
+ rb_thread_call_without_gvl(dh_blocking_gen, &gen_arg, ossl_generate_cb_stop, &cb_arg);
+ }
+
+ if (!gen_arg.result) {
+ DH_free(dh);
+ if (cb_arg.state) rb_jump_tag(cb_arg.state);
+ return 0;
+ }
+#else
+ DH *dh;
+
+ dh = DH_generate_parameters(size, gen, rb_block_given_p() ? ossl_generate_cb : NULL, NULL);
+ if (!dh) return 0;
+#endif
+
+ if (!DH_generate_key(dh)) {
+ DH_free(dh);
+ return 0;
+ }
+
+ return dh;
+}
+
+/*
+ * call-seq:
+ * DH.generate(size [, generator]) -> dh
+ *
+ * Creates a new DH instance from scratch by generating the private and public
+ * components alike.
+ *
+ * === Parameters
+ * * +size+ is an integer representing the desired key size. Keys smaller than 1024 bits should be considered insecure.
+ * * +generator+ is a small number > 1, typically 2 or 5.
+ *
+ */
+static VALUE
+ossl_dh_s_generate(int argc, VALUE *argv, VALUE klass)
+{
+ DH *dh ;
+ int g = 2;
+ VALUE size, gen, obj;
+
+ if (rb_scan_args(argc, argv, "11", &size, &gen) == 2) {
+ g = NUM2INT(gen);
+ }
+ dh = dh_generate(NUM2INT(size), g);
+ obj = dh_instance(klass, dh);
+ if (obj == Qfalse) {
+ DH_free(dh);
+ ossl_raise(eDHError, NULL);
+ }
+
+ return obj;
+}
+
+/*
+ * call-seq:
+ * DH.new([size [, generator] | string]) -> dh
+ *
+ * Either generates a DH instance from scratch or by reading already existing
+ * DH parameters from +string+. Note that when reading a DH instance from
+ * data that was encoded from a DH instance by using DH#to_pem or DH#to_der
+ * the result will *not* contain a public/private key pair yet. This needs to
+ * be generated using DH#generate_key! first.
+ *
+ * === Parameters
+ * * +size+ is an integer representing the desired key size. Keys smaller than 1024 bits should be considered insecure.
+ * * +generator+ is a small number > 1, typically 2 or 5.
+ * * +string+ contains the DER or PEM encoded key.
+ *
+ * === Examples
+ * DH.new # -> dh
+ * DH.new(1024) # -> dh
+ * DH.new(1024, 5) # -> dh
+ * #Reading DH parameters
+ * dh = DH.new(File.read('parameters.pem')) # -> dh, but no public/private key yet
+ * dh.generate_key! # -> dh with public and private key
+ */
+static VALUE
+ossl_dh_initialize(int argc, VALUE *argv, VALUE self)
+{
+ EVP_PKEY *pkey;
+ DH *dh;
+ int g = 2;
+ BIO *in;
+ VALUE arg, gen;
+
+ GetPKey(self, pkey);
+ if(rb_scan_args(argc, argv, "02", &arg, &gen) == 0) {
+ dh = DH_new();
+ }
+ else if (FIXNUM_P(arg)) {
+ if (!NIL_P(gen)) {
+ g = NUM2INT(gen);
+ }
+ if (!(dh = dh_generate(FIX2INT(arg), g))) {
+ ossl_raise(eDHError, NULL);
+ }
+ }
+ else {
+ arg = ossl_to_der_if_possible(arg);
+ in = ossl_obj2bio(arg);
+ dh = PEM_read_bio_DHparams(in, NULL, NULL, NULL);
+ if (!dh){
+ OSSL_BIO_reset(in);
+ dh = d2i_DHparams_bio(in, NULL);
+ }
+ BIO_free(in);
+ if (!dh) {
+ ossl_raise(eDHError, NULL);
+ }
+ }
+ if (!EVP_PKEY_assign_DH(pkey, dh)) {
+ DH_free(dh);
+ ossl_raise(eDHError, NULL);
+ }
+ return self;
+}
+
+/*
+ * call-seq:
+ * dh.public? -> true | false
+ *
+ * Indicates whether this DH instance has a public key associated with it or
+ * not. The public key may be retrieved with DH#pub_key.
+ */
+static VALUE
+ossl_dh_is_public(VALUE self)
+{
+ EVP_PKEY *pkey;
+
+ GetPKeyDH(self, pkey);
+
+ return (pkey->pkey.dh->pub_key) ? Qtrue : Qfalse;
+}
+
+/*
+ * call-seq:
+ * dh.private? -> true | false
+ *
+ * Indicates whether this DH instance has a private key associated with it or
+ * not. The private key may be retrieved with DH#priv_key.
+ */
+static VALUE
+ossl_dh_is_private(VALUE self)
+{
+ EVP_PKEY *pkey;
+
+ GetPKeyDH(self, pkey);
+
+ return (DH_PRIVATE(pkey->pkey.dh)) ? Qtrue : Qfalse;
+}
+
+/*
+ * call-seq:
+ * dh.export -> aString
+ * dh.to_pem -> aString
+ * dh.to_s -> aString
+ *
+ * Encodes this DH to its PEM encoding. Note that any existing per-session
+ * public/private keys will *not* get encoded, just the Diffie-Hellman
+ * parameters will be encoded.
+ */
+static VALUE
+ossl_dh_export(VALUE self)
+{
+ EVP_PKEY *pkey;
+ BIO *out;
+ VALUE str;
+
+ GetPKeyDH(self, pkey);
+ if (!(out = BIO_new(BIO_s_mem()))) {
+ ossl_raise(eDHError, NULL);
+ }
+ if (!PEM_write_bio_DHparams(out, pkey->pkey.dh)) {
+ BIO_free(out);
+ ossl_raise(eDHError, NULL);
+ }
+ str = ossl_membio2str(out);
+
+ return str;
+}
+
+/*
+ * call-seq:
+ * dh.to_der -> aString
+ *
+ * Encodes this DH to its DER encoding. Note that any existing per-session
+ * public/private keys will *not* get encoded, just the Diffie-Hellman
+ * parameters will be encoded.
+
+ */
+static VALUE
+ossl_dh_to_der(VALUE self)
+{
+ EVP_PKEY *pkey;
+ unsigned char *p;
+ long len;
+ VALUE str;
+
+ GetPKeyDH(self, pkey);
+ if((len = i2d_DHparams(pkey->pkey.dh, NULL)) <= 0)
+ ossl_raise(eDHError, NULL);
+ str = rb_str_new(0, len);
+ p = (unsigned char *)RSTRING_PTR(str);
+ if(i2d_DHparams(pkey->pkey.dh, &p) < 0)
+ ossl_raise(eDHError, NULL);
+ ossl_str_adjust(str, p);
+
+ return str;
+}
+
+/*
+ * call-seq:
+ * dh.params -> hash
+ *
+ * Stores all parameters of key to the hash
+ * INSECURE: PRIVATE INFORMATIONS CAN LEAK OUT!!!
+ * Don't use :-)) (I's up to you)
+ */
+static VALUE
+ossl_dh_get_params(VALUE self)
+{
+ EVP_PKEY *pkey;
+ VALUE hash;
+
+ GetPKeyDH(self, pkey);
+
+ hash = rb_hash_new();
+
+ rb_hash_aset(hash, rb_str_new2("p"), ossl_bn_new(pkey->pkey.dh->p));
+ rb_hash_aset(hash, rb_str_new2("g"), ossl_bn_new(pkey->pkey.dh->g));
+ rb_hash_aset(hash, rb_str_new2("pub_key"), ossl_bn_new(pkey->pkey.dh->pub_key));
+ rb_hash_aset(hash, rb_str_new2("priv_key"), ossl_bn_new(pkey->pkey.dh->priv_key));
+
+ return hash;
+}
+
+/*
+ * call-seq:
+ * dh.to_text -> aString
+ *
+ * Prints all parameters of key to buffer
+ * INSECURE: PRIVATE INFORMATIONS CAN LEAK OUT!!!
+ * Don't use :-)) (I's up to you)
+ */
+static VALUE
+ossl_dh_to_text(VALUE self)
+{
+ EVP_PKEY *pkey;
+ BIO *out;
+ VALUE str;
+
+ GetPKeyDH(self, pkey);
+ if (!(out = BIO_new(BIO_s_mem()))) {
+ ossl_raise(eDHError, NULL);
+ }
+ if (!DHparams_print(out, pkey->pkey.dh)) {
+ BIO_free(out);
+ ossl_raise(eDHError, NULL);
+ }
+ str = ossl_membio2str(out);
+
+ return str;
+}
+
+/*
+ * call-seq:
+ * dh.public_key -> aDH
+ *
+ * Returns a new DH instance that carries just the public information, i.e.
+ * the prime +p+ and the generator +g+, but no public/private key yet. Such
+ * a pair may be generated using DH#generate_key!. The "public key" needed
+ * for a key exchange with DH#compute_key is considered as per-session
+ * information and may be retrieved with DH#pub_key once a key pair has
+ * been generated.
+ * If the current instance already contains private information (and thus a
+ * valid public/private key pair), this information will no longer be present
+ * in the new instance generated by DH#public_key. This feature is helpful for
+ * publishing the Diffie-Hellman parameters without leaking any of the private
+ * per-session information.
+ *
+ * === Example
+ * dh = OpenSSL::PKey::DH.new(2048) # has public and private key set
+ * public_key = dh.public_key # contains only prime and generator
+ * parameters = public_key.to_der # it's safe to publish this
+ */
+static VALUE
+ossl_dh_to_public_key(VALUE self)
+{
+ EVP_PKEY *pkey;
+ DH *dh;
+ VALUE obj;
+
+ GetPKeyDH(self, pkey);
+ dh = DHparams_dup(pkey->pkey.dh); /* err check perfomed by dh_instance */
+ obj = dh_instance(CLASS_OF(self), dh);
+ if (obj == Qfalse) {
+ DH_free(dh);
+ ossl_raise(eDHError, NULL);
+ }
+
+ return obj;
+}
+
+/*
+ * call-seq:
+ * dh.params_ok? -> true | false
+ *
+ * Validates the Diffie-Hellman parameters associated with this instance.
+ * It checks whether a safe prime and a suitable generator are used. If this
+ * is not the case, +false+ is returned.
+ */
+static VALUE
+ossl_dh_check_params(VALUE self)
+{
+ DH *dh;
+ EVP_PKEY *pkey;
+ int codes;
+
+ GetPKeyDH(self, pkey);
+ dh = pkey->pkey.dh;
+
+ if (!DH_check(dh, &codes)) {
+ return Qfalse;
+ }
+
+ return codes == 0 ? Qtrue : Qfalse;
+}
+
+/*
+ * call-seq:
+ * dh.generate_key! -> self
+ *
+ * Generates a private and public key unless a private key already exists.
+ * If this DH instance was generated from public DH parameters (e.g. by
+ * encoding the result of DH#public_key), then this method needs to be
+ * called first in order to generate the per-session keys before performing
+ * the actual key exchange.
+ *
+ * === Example
+ * dh = OpenSSL::PKey::DH.new(2048)
+ * public_key = dh.public_key #contains no private/public key yet
+ * public_key.generate_key!
+ * puts public_key.private? # => true
+ */
+static VALUE
+ossl_dh_generate_key(VALUE self)
+{
+ DH *dh;
+ EVP_PKEY *pkey;
+
+ GetPKeyDH(self, pkey);
+ dh = pkey->pkey.dh;
+
+ if (!DH_generate_key(dh))
+ ossl_raise(eDHError, "Failed to generate key");
+ return self;
+}
+
+/*
+ * call-seq:
+ * dh.compute_key(pub_bn) -> aString
+ *
+ * Returns a String containing a shared secret computed from the other party's public value.
+ * See DH_compute_key() for further information.
+ *
+ * === Parameters
+ * * +pub_bn+ is a OpenSSL::BN, *not* the DH instance returned by
+ * DH#public_key as that contains the DH parameters only.
+ */
+static VALUE
+ossl_dh_compute_key(VALUE self, VALUE pub)
+{
+ DH *dh;
+ EVP_PKEY *pkey;
+ BIGNUM *pub_key;
+ VALUE str;
+ int len;
+
+ GetPKeyDH(self, pkey);
+ dh = pkey->pkey.dh;
+ pub_key = GetBNPtr(pub);
+ len = DH_size(dh);
+ str = rb_str_new(0, len);
+ if ((len = DH_compute_key((unsigned char *)RSTRING_PTR(str), pub_key, dh)) < 0) {
+ ossl_raise(eDHError, NULL);
+ }
+ rb_str_set_len(str, len);
+
+ return str;
+}
+
+OSSL_PKEY_BN(dh, p)
+OSSL_PKEY_BN(dh, g)
+OSSL_PKEY_BN(dh, pub_key)
+OSSL_PKEY_BN(dh, priv_key)
+
+/*
+ * -----BEGIN DH PARAMETERS-----
+ * MEYCQQD0zXHljRg/mJ9PYLACLv58Cd8VxBxxY7oEuCeURMiTqEhMym16rhhKgZG2
+ * zk2O9uUIBIxSj+NKMURHGaFKyIvLAgEC
+ * -----END DH PARAMETERS-----
+ */
+static unsigned char DEFAULT_DH_512_PRIM[] = {
+ 0xf4, 0xcd, 0x71, 0xe5, 0x8d, 0x18, 0x3f, 0x98,
+ 0x9f, 0x4f, 0x60, 0xb0, 0x02, 0x2e, 0xfe, 0x7c,
+ 0x09, 0xdf, 0x15, 0xc4, 0x1c, 0x71, 0x63, 0xba,
+ 0x04, 0xb8, 0x27, 0x94, 0x44, 0xc8, 0x93, 0xa8,
+ 0x48, 0x4c, 0xca, 0x6d, 0x7a, 0xae, 0x18, 0x4a,
+ 0x81, 0x91, 0xb6, 0xce, 0x4d, 0x8e, 0xf6, 0xe5,
+ 0x08, 0x04, 0x8c, 0x52, 0x8f, 0xe3, 0x4a, 0x31,
+ 0x44, 0x47, 0x19, 0xa1, 0x4a, 0xc8, 0x8b, 0xcb,
+};
+static unsigned char DEFAULT_DH_512_GEN[] = { 0x02 };
+DH *OSSL_DEFAULT_DH_512 = NULL;
+
+/*
+ * -----BEGIN DH PARAMETERS-----
+ * MIGHAoGBAJ0lOVy0VIr/JebWn0zDwY2h+rqITFOpdNr6ugsgvkDXuucdcChhYExJ
+ * AV/ZD2AWPbrTqV76mGRgJg4EddgT1zG0jq3rnFdMj2XzkBYx3BVvfR0Arnby0RHR
+ * T4h7KZ/2zmjvV+eF8kBUHBJAojUlzxKj4QeO2x20FP9X5xmNUXeDAgEC
+ * -----END DH PARAMETERS-----
+ */
+static unsigned char DEFAULT_DH_1024_PRIM[] = {
+ 0x9d, 0x25, 0x39, 0x5c, 0xb4, 0x54, 0x8a, 0xff,
+ 0x25, 0xe6, 0xd6, 0x9f, 0x4c, 0xc3, 0xc1, 0x8d,
+ 0xa1, 0xfa, 0xba, 0x88, 0x4c, 0x53, 0xa9, 0x74,
+ 0xda, 0xfa, 0xba, 0x0b, 0x20, 0xbe, 0x40, 0xd7,
+ 0xba, 0xe7, 0x1d, 0x70, 0x28, 0x61, 0x60, 0x4c,
+ 0x49, 0x01, 0x5f, 0xd9, 0x0f, 0x60, 0x16, 0x3d,
+ 0xba, 0xd3, 0xa9, 0x5e, 0xfa, 0x98, 0x64, 0x60,
+ 0x26, 0x0e, 0x04, 0x75, 0xd8, 0x13, 0xd7, 0x31,
+ 0xb4, 0x8e, 0xad, 0xeb, 0x9c, 0x57, 0x4c, 0x8f,
+ 0x65, 0xf3, 0x90, 0x16, 0x31, 0xdc, 0x15, 0x6f,
+ 0x7d, 0x1d, 0x00, 0xae, 0x76, 0xf2, 0xd1, 0x11,
+ 0xd1, 0x4f, 0x88, 0x7b, 0x29, 0x9f, 0xf6, 0xce,
+ 0x68, 0xef, 0x57, 0xe7, 0x85, 0xf2, 0x40, 0x54,
+ 0x1c, 0x12, 0x40, 0xa2, 0x35, 0x25, 0xcf, 0x12,
+ 0xa3, 0xe1, 0x07, 0x8e, 0xdb, 0x1d, 0xb4, 0x14,
+ 0xff, 0x57, 0xe7, 0x19, 0x8d, 0x51, 0x77, 0x83
+};
+static unsigned char DEFAULT_DH_1024_GEN[] = { 0x02 };
+DH *OSSL_DEFAULT_DH_1024 = NULL;
+
+static DH*
+ossl_create_dh(unsigned char *p, size_t plen, unsigned char *g, size_t glen)
+{
+ DH *dh;
+
+ if ((dh = DH_new()) == NULL) ossl_raise(eDHError, NULL);
+ dh->p = BN_bin2bn(p, rb_long2int(plen), NULL);
+ dh->g = BN_bin2bn(g, rb_long2int(glen), NULL);
+ if (dh->p == NULL || dh->g == NULL){
+ DH_free(dh);
+ ossl_raise(eDHError, NULL);
+ }
+
+ return dh;
+}
+
+/*
+ * INIT
+ */
+void
+Init_ossl_dh(void)
+{
+#if 0
+ mOSSL = rb_define_module("OpenSSL"); /* let rdoc know about mOSSL and mPKey */
+ mPKey = rb_define_module_under(mOSSL, "PKey");
+#endif
+
+ /* Document-class: OpenSSL::PKey::DHError
+ *
+ * Generic exception that is raised if an operation on a DH PKey
+ * fails unexpectedly or in case an instantiation of an instance of DH
+ * fails due to non-conformant input data.
+ */
+ eDHError = rb_define_class_under(mPKey, "DHError", ePKeyError);
+ /* Document-class: OpenSSL::PKey::DH
+ *
+ * An implementation of the Diffie-Hellman key exchange protocol based on
+ * discrete logarithms in finite fields, the same basis that DSA is built
+ * on.
+ *
+ * === Accessor methods for the Diffie-Hellman parameters
+ * * DH#p
+ * The prime (an OpenSSL::BN) of the Diffie-Hellman parameters.
+ * * DH#g
+ * The generator (an OpenSSL::BN) g of the Diffie-Hellman parameters.
+ * * DH#pub_key
+ * The per-session public key (an OpenSSL::BN) matching the private key.
+ * This needs to be passed to DH#compute_key.
+ * * DH#priv_key
+ * The per-session private key, an OpenSSL::BN.
+ *
+ * === Example of a key exchange
+ * dh1 = OpenSSL::PKey::DH.new(2048)
+ * der = dh1.public_key.to_der #you may send this publicly to the participating party
+ * dh2 = OpenSSL::PKey::DH.new(der)
+ * dh2.generate_key! #generate the per-session key pair
+ * symm_key1 = dh1.compute_key(dh2.pub_key)
+ * symm_key2 = dh2.compute_key(dh1.pub_key)
+ *
+ * puts symm_key1 == symm_key2 # => true
+ */
+ cDH = rb_define_class_under(mPKey, "DH", cPKey);
+ rb_define_singleton_method(cDH, "generate", ossl_dh_s_generate, -1);
+ rb_define_method(cDH, "initialize", ossl_dh_initialize, -1);
+ rb_define_method(cDH, "public?", ossl_dh_is_public, 0);
+ rb_define_method(cDH, "private?", ossl_dh_is_private, 0);
+ rb_define_method(cDH, "to_text", ossl_dh_to_text, 0);
+ rb_define_method(cDH, "export", ossl_dh_export, 0);
+ rb_define_alias(cDH, "to_pem", "export");
+ rb_define_alias(cDH, "to_s", "export");
+ rb_define_method(cDH, "to_der", ossl_dh_to_der, 0);
+ rb_define_method(cDH, "public_key", ossl_dh_to_public_key, 0);
+ rb_define_method(cDH, "params_ok?", ossl_dh_check_params, 0);
+ rb_define_method(cDH, "generate_key!", ossl_dh_generate_key, 0);
+ rb_define_method(cDH, "compute_key", ossl_dh_compute_key, 1);
+
+ DEF_OSSL_PKEY_BN(cDH, dh, p);
+ DEF_OSSL_PKEY_BN(cDH, dh, g);
+ DEF_OSSL_PKEY_BN(cDH, dh, pub_key);
+ DEF_OSSL_PKEY_BN(cDH, dh, priv_key);
+ rb_define_method(cDH, "params", ossl_dh_get_params, 0);
+
+ OSSL_DEFAULT_DH_512 = ossl_create_dh(
+ DEFAULT_DH_512_PRIM, sizeof(DEFAULT_DH_512_PRIM),
+ DEFAULT_DH_512_GEN, sizeof(DEFAULT_DH_512_GEN));
+ OSSL_DEFAULT_DH_1024 = ossl_create_dh(
+ DEFAULT_DH_1024_PRIM, sizeof(DEFAULT_DH_1024_PRIM),
+ DEFAULT_DH_1024_GEN, sizeof(DEFAULT_DH_1024_GEN));
+}
+
+#else /* defined NO_DH */
+void
+Init_ossl_dh(void)
+{
+}
+#endif /* NO_DH */
diff --git a/jni/ruby/ext/openssl/ossl_pkey_dsa.c b/jni/ruby/ext/openssl/ossl_pkey_dsa.c
new file mode 100644
index 0000000..750c928
--- /dev/null
+++ b/jni/ruby/ext/openssl/ossl_pkey_dsa.c
@@ -0,0 +1,623 @@
+/*
+ * $Id: ossl_pkey_dsa.c 47744 2014-09-30 05:25:32Z nobu $
+ * 'OpenSSL for Ruby' project
+ * Copyright (C) 2001-2002 Michal Rokos <m.rokos@sh.cvut.cz>
+ * All rights reserved.
+ */
+/*
+ * This program is licenced under the same licence as Ruby.
+ * (See the file 'LICENCE'.)
+ */
+#if !defined(OPENSSL_NO_DSA)
+
+#include "ossl.h"
+
+#define GetPKeyDSA(obj, pkey) do { \
+ GetPKey((obj), (pkey)); \
+ if (EVP_PKEY_type((pkey)->type) != EVP_PKEY_DSA) { /* PARANOIA? */ \
+ ossl_raise(rb_eRuntimeError, "THIS IS NOT A DSA!"); \
+ } \
+} while (0)
+
+#define DSA_HAS_PRIVATE(dsa) ((dsa)->priv_key)
+#define DSA_PRIVATE(obj,dsa) (DSA_HAS_PRIVATE(dsa)||OSSL_PKEY_IS_PRIVATE(obj))
+
+/*
+ * Classes
+ */
+VALUE cDSA;
+VALUE eDSAError;
+
+/*
+ * Public
+ */
+static VALUE
+dsa_instance(VALUE klass, DSA *dsa)
+{
+ EVP_PKEY *pkey;
+ VALUE obj;
+
+ if (!dsa) {
+ return Qfalse;
+ }
+ if (!(pkey = EVP_PKEY_new())) {
+ return Qfalse;
+ }
+ if (!EVP_PKEY_assign_DSA(pkey, dsa)) {
+ EVP_PKEY_free(pkey);
+ return Qfalse;
+ }
+ WrapPKey(klass, obj, pkey);
+
+ return obj;
+}
+
+VALUE
+ossl_dsa_new(EVP_PKEY *pkey)
+{
+ VALUE obj;
+
+ if (!pkey) {
+ obj = dsa_instance(cDSA, DSA_new());
+ } else {
+ if (EVP_PKEY_type(pkey->type) != EVP_PKEY_DSA) {
+ ossl_raise(rb_eTypeError, "Not a DSA key!");
+ }
+ WrapPKey(cDSA, obj, pkey);
+ }
+ if (obj == Qfalse) {
+ ossl_raise(eDSAError, NULL);
+ }
+
+ return obj;
+}
+
+/*
+ * Private
+ */
+#if defined(HAVE_DSA_GENERATE_PARAMETERS_EX) && HAVE_BN_GENCB
+struct dsa_blocking_gen_arg {
+ DSA *dsa;
+ int size;
+ unsigned char* seed;
+ int seed_len;
+ int *counter;
+ unsigned long *h;
+ BN_GENCB *cb;
+ int result;
+};
+
+static void *
+dsa_blocking_gen(void *arg)
+{
+ struct dsa_blocking_gen_arg *gen = (struct dsa_blocking_gen_arg *)arg;
+ gen->result = DSA_generate_parameters_ex(gen->dsa, gen->size, gen->seed, gen->seed_len, gen->counter, gen->h, gen->cb);
+ return 0;
+}
+#endif
+
+static DSA *
+dsa_generate(int size)
+{
+#if defined(HAVE_DSA_GENERATE_PARAMETERS_EX) && HAVE_BN_GENCB
+ BN_GENCB cb;
+ struct ossl_generate_cb_arg cb_arg;
+ struct dsa_blocking_gen_arg gen_arg;
+ DSA *dsa = DSA_new();
+ unsigned char seed[20];
+ int seed_len = 20, counter;
+ unsigned long h;
+
+ if (!dsa) return 0;
+ if (!RAND_bytes(seed, seed_len)) {
+ DSA_free(dsa);
+ return 0;
+ }
+
+ memset(&cb_arg, 0, sizeof(struct ossl_generate_cb_arg));
+ if (rb_block_given_p())
+ cb_arg.yield = 1;
+ BN_GENCB_set(&cb, ossl_generate_cb_2, &cb_arg);
+ gen_arg.dsa = dsa;
+ gen_arg.size = size;
+ gen_arg.seed = seed;
+ gen_arg.seed_len = seed_len;
+ gen_arg.counter = &counter;
+ gen_arg.h = &h;
+ gen_arg.cb = &cb;
+ if (cb_arg.yield == 1) {
+ /* we cannot release GVL when callback proc is supplied */
+ dsa_blocking_gen(&gen_arg);
+ } else {
+ /* there's a chance to unblock */
+ rb_thread_call_without_gvl(dsa_blocking_gen, &gen_arg, ossl_generate_cb_stop, &cb_arg);
+ }
+ if (!gen_arg.result) {
+ DSA_free(dsa);
+ if (cb_arg.state) rb_jump_tag(cb_arg.state);
+ return 0;
+ }
+#else
+ DSA *dsa;
+ unsigned char seed[20];
+ int seed_len = 20, counter;
+ unsigned long h;
+
+ if (!RAND_bytes(seed, seed_len)) {
+ return 0;
+ }
+ dsa = DSA_generate_parameters(size, seed, seed_len, &counter, &h,
+ rb_block_given_p() ? ossl_generate_cb : NULL, NULL);
+ if(!dsa) return 0;
+#endif
+
+ if (!DSA_generate_key(dsa)) {
+ DSA_free(dsa);
+ return 0;
+ }
+
+ return dsa;
+}
+
+/*
+ * call-seq:
+ * DSA.generate(size) -> dsa
+ *
+ * Creates a new DSA instance by generating a private/public key pair
+ * from scratch.
+ *
+ * === Parameters
+ * * +size+ is an integer representing the desired key size.
+ *
+ */
+static VALUE
+ossl_dsa_s_generate(VALUE klass, VALUE size)
+{
+ DSA *dsa = dsa_generate(NUM2INT(size)); /* err handled by dsa_instance */
+ VALUE obj = dsa_instance(klass, dsa);
+
+ if (obj == Qfalse) {
+ DSA_free(dsa);
+ ossl_raise(eDSAError, NULL);
+ }
+
+ return obj;
+}
+
+/*
+ * call-seq:
+ * DSA.new([size | string [, pass]) -> dsa
+ *
+ * Creates a new DSA instance by reading an existing key from +string+.
+ *
+ * === Parameters
+ * * +size+ is an integer representing the desired key size.
+ * * +string+ contains a DER or PEM encoded key.
+ * * +pass+ is a string that contains an optional password.
+ *
+ * === Examples
+ * DSA.new -> dsa
+ * DSA.new(1024) -> dsa
+ * DSA.new(File.read('dsa.pem')) -> dsa
+ * DSA.new(File.read('dsa.pem'), 'mypassword') -> dsa
+ *
+ */
+static VALUE
+ossl_dsa_initialize(int argc, VALUE *argv, VALUE self)
+{
+ EVP_PKEY *pkey;
+ DSA *dsa;
+ BIO *in;
+ char *passwd = NULL;
+ VALUE arg, pass;
+
+ GetPKey(self, pkey);
+ if(rb_scan_args(argc, argv, "02", &arg, &pass) == 0) {
+ dsa = DSA_new();
+ }
+ else if (FIXNUM_P(arg)) {
+ if (!(dsa = dsa_generate(FIX2INT(arg)))) {
+ ossl_raise(eDSAError, NULL);
+ }
+ }
+ else {
+ if (!NIL_P(pass)) passwd = StringValuePtr(pass);
+ arg = ossl_to_der_if_possible(arg);
+ in = ossl_obj2bio(arg);
+ dsa = PEM_read_bio_DSAPrivateKey(in, NULL, ossl_pem_passwd_cb, passwd);
+ if (!dsa) {
+ OSSL_BIO_reset(in);
+ dsa = PEM_read_bio_DSA_PUBKEY(in, NULL, NULL, NULL);
+ }
+ if (!dsa) {
+ OSSL_BIO_reset(in);
+ dsa = d2i_DSAPrivateKey_bio(in, NULL);
+ }
+ if (!dsa) {
+ OSSL_BIO_reset(in);
+ dsa = d2i_DSA_PUBKEY_bio(in, NULL);
+ }
+ if (!dsa) {
+ OSSL_BIO_reset(in);
+ dsa = PEM_read_bio_DSAPublicKey(in, NULL, NULL, NULL);
+ }
+ BIO_free(in);
+ if (!dsa) {
+ ERR_clear_error();
+ ossl_raise(eDSAError, "Neither PUB key nor PRIV key");
+ }
+ }
+ if (!EVP_PKEY_assign_DSA(pkey, dsa)) {
+ DSA_free(dsa);
+ ossl_raise(eDSAError, NULL);
+ }
+
+ return self;
+}
+
+/*
+ * call-seq:
+ * dsa.public? -> true | false
+ *
+ * Indicates whether this DSA instance has a public key associated with it or
+ * not. The public key may be retrieved with DSA#public_key.
+ */
+static VALUE
+ossl_dsa_is_public(VALUE self)
+{
+ EVP_PKEY *pkey;
+
+ GetPKeyDSA(self, pkey);
+
+ return (pkey->pkey.dsa->pub_key) ? Qtrue : Qfalse;
+}
+
+/*
+ * call-seq:
+ * dsa.private? -> true | false
+ *
+ * Indicates whether this DSA instance has a private key associated with it or
+ * not. The private key may be retrieved with DSA#private_key.
+ */
+static VALUE
+ossl_dsa_is_private(VALUE self)
+{
+ EVP_PKEY *pkey;
+
+ GetPKeyDSA(self, pkey);
+
+ return (DSA_PRIVATE(self, pkey->pkey.dsa)) ? Qtrue : Qfalse;
+}
+
+/*
+ * call-seq:
+ * dsa.export([cipher, password]) -> aString
+ * dsa.to_pem([cipher, password]) -> aString
+ * dsa.to_s([cipher, password]) -> aString
+ *
+ * Encodes this DSA to its PEM encoding.
+ *
+ * === Parameters
+ * * +cipher+ is an OpenSSL::Cipher.
+ * * +password+ is a string containing your password.
+ *
+ * === Examples
+ * DSA.to_pem -> aString
+ * DSA.to_pem(cipher, 'mypassword') -> aString
+ *
+ */
+static VALUE
+ossl_dsa_export(int argc, VALUE *argv, VALUE self)
+{
+ EVP_PKEY *pkey;
+ BIO *out;
+ const EVP_CIPHER *ciph = NULL;
+ char *passwd = NULL;
+ VALUE cipher, pass, str;
+
+ GetPKeyDSA(self, pkey);
+ rb_scan_args(argc, argv, "02", &cipher, &pass);
+ if (!NIL_P(cipher)) {
+ ciph = GetCipherPtr(cipher);
+ if (!NIL_P(pass)) {
+ StringValue(pass);
+ if (RSTRING_LENINT(pass) < OSSL_MIN_PWD_LEN)
+ ossl_raise(eOSSLError, "OpenSSL requires passwords to be at least four characters long");
+ passwd = RSTRING_PTR(pass);
+ }
+ }
+ if (!(out = BIO_new(BIO_s_mem()))) {
+ ossl_raise(eDSAError, NULL);
+ }
+ if (DSA_HAS_PRIVATE(pkey->pkey.dsa)) {
+ if (!PEM_write_bio_DSAPrivateKey(out, pkey->pkey.dsa, ciph,
+ NULL, 0, ossl_pem_passwd_cb, passwd)){
+ BIO_free(out);
+ ossl_raise(eDSAError, NULL);
+ }
+ } else {
+ if (!PEM_write_bio_DSA_PUBKEY(out, pkey->pkey.dsa)) {
+ BIO_free(out);
+ ossl_raise(eDSAError, NULL);
+ }
+ }
+ str = ossl_membio2str(out);
+
+ return str;
+}
+
+/*
+ * call-seq:
+ * dsa.to_der -> aString
+ *
+ * Encodes this DSA to its DER encoding.
+ *
+ */
+static VALUE
+ossl_dsa_to_der(VALUE self)
+{
+ EVP_PKEY *pkey;
+ int (*i2d_func)_((DSA*, unsigned char**));
+ unsigned char *p;
+ long len;
+ VALUE str;
+
+ GetPKeyDSA(self, pkey);
+ if(DSA_HAS_PRIVATE(pkey->pkey.dsa))
+ i2d_func = (int(*)_((DSA*,unsigned char**)))i2d_DSAPrivateKey;
+ else
+ i2d_func = i2d_DSA_PUBKEY;
+ if((len = i2d_func(pkey->pkey.dsa, NULL)) <= 0)
+ ossl_raise(eDSAError, NULL);
+ str = rb_str_new(0, len);
+ p = (unsigned char *)RSTRING_PTR(str);
+ if(i2d_func(pkey->pkey.dsa, &p) < 0)
+ ossl_raise(eDSAError, NULL);
+ ossl_str_adjust(str, p);
+
+ return str;
+}
+
+/*
+ * call-seq:
+ * dsa.params -> hash
+ *
+ * Stores all parameters of key to the hash
+ * INSECURE: PRIVATE INFORMATIONS CAN LEAK OUT!!!
+ * Don't use :-)) (I's up to you)
+ */
+static VALUE
+ossl_dsa_get_params(VALUE self)
+{
+ EVP_PKEY *pkey;
+ VALUE hash;
+
+ GetPKeyDSA(self, pkey);
+
+ hash = rb_hash_new();
+
+ rb_hash_aset(hash, rb_str_new2("p"), ossl_bn_new(pkey->pkey.dsa->p));
+ rb_hash_aset(hash, rb_str_new2("q"), ossl_bn_new(pkey->pkey.dsa->q));
+ rb_hash_aset(hash, rb_str_new2("g"), ossl_bn_new(pkey->pkey.dsa->g));
+ rb_hash_aset(hash, rb_str_new2("pub_key"), ossl_bn_new(pkey->pkey.dsa->pub_key));
+ rb_hash_aset(hash, rb_str_new2("priv_key"), ossl_bn_new(pkey->pkey.dsa->priv_key));
+
+ return hash;
+}
+
+/*
+ * call-seq:
+ * dsa.to_text -> aString
+ *
+ * Prints all parameters of key to buffer
+ * INSECURE: PRIVATE INFORMATIONS CAN LEAK OUT!!!
+ * Don't use :-)) (I's up to you)
+ */
+static VALUE
+ossl_dsa_to_text(VALUE self)
+{
+ EVP_PKEY *pkey;
+ BIO *out;
+ VALUE str;
+
+ GetPKeyDSA(self, pkey);
+ if (!(out = BIO_new(BIO_s_mem()))) {
+ ossl_raise(eDSAError, NULL);
+ }
+ if (!DSA_print(out, pkey->pkey.dsa, 0)) { /* offset = 0 */
+ BIO_free(out);
+ ossl_raise(eDSAError, NULL);
+ }
+ str = ossl_membio2str(out);
+
+ return str;
+}
+
+/*
+ * call-seq:
+ * dsa.public_key -> aDSA
+ *
+ * Returns a new DSA instance that carries just the public key information.
+ * If the current instance has also private key information, this will no
+ * longer be present in the new instance. This feature is helpful for
+ * publishing the public key information without leaking any of the private
+ * information.
+ *
+ * === Example
+ * dsa = OpenSSL::PKey::DSA.new(2048) # has public and private information
+ * pub_key = dsa.public_key # has only the public part available
+ * pub_key_der = pub_key.to_der # it's safe to publish this
+ *
+ *
+ */
+static VALUE
+ossl_dsa_to_public_key(VALUE self)
+{
+ EVP_PKEY *pkey;
+ DSA *dsa;
+ VALUE obj;
+
+ GetPKeyDSA(self, pkey);
+ /* err check performed by dsa_instance */
+ dsa = DSAPublicKey_dup(pkey->pkey.dsa);
+ obj = dsa_instance(CLASS_OF(self), dsa);
+ if (obj == Qfalse) {
+ DSA_free(dsa);
+ ossl_raise(eDSAError, NULL);
+ }
+ return obj;
+}
+
+#define ossl_dsa_buf_size(pkey) (DSA_size((pkey)->pkey.dsa)+16)
+
+/*
+ * call-seq:
+ * dsa.syssign(string) -> aString
+ *
+ * Computes and returns the DSA signature of +string+, where +string+ is
+ * expected to be an already-computed message digest of the original input
+ * data. The signature is issued using the private key of this DSA instance.
+ *
+ * === Parameters
+ * * +string+ is a message digest of the original input data to be signed
+ *
+ * === Example
+ * dsa = OpenSSL::PKey::DSA.new(2048)
+ * doc = "Sign me"
+ * digest = OpenSSL::Digest::SHA1.digest(doc)
+ * sig = dsa.syssign(digest)
+ *
+ *
+ */
+static VALUE
+ossl_dsa_sign(VALUE self, VALUE data)
+{
+ EVP_PKEY *pkey;
+ unsigned int buf_len;
+ VALUE str;
+
+ GetPKeyDSA(self, pkey);
+ StringValue(data);
+ if (!DSA_PRIVATE(self, pkey->pkey.dsa)) {
+ ossl_raise(eDSAError, "Private DSA key needed!");
+ }
+ str = rb_str_new(0, ossl_dsa_buf_size(pkey));
+ if (!DSA_sign(0, (unsigned char *)RSTRING_PTR(data), RSTRING_LENINT(data),
+ (unsigned char *)RSTRING_PTR(str),
+ &buf_len, pkey->pkey.dsa)) { /* type is ignored (0) */
+ ossl_raise(eDSAError, NULL);
+ }
+ rb_str_set_len(str, buf_len);
+
+ return str;
+}
+
+/*
+ * call-seq:
+ * dsa.sysverify(digest, sig) -> true | false
+ *
+ * Verifies whether the signature is valid given the message digest input. It
+ * does so by validating +sig+ using the public key of this DSA instance.
+ *
+ * === Parameters
+ * * +digest+ is a message digest of the original input data to be signed
+ * * +sig+ is a DSA signature value
+ *
+ * === Example
+ * dsa = OpenSSL::PKey::DSA.new(2048)
+ * doc = "Sign me"
+ * digest = OpenSSL::Digest::SHA1.digest(doc)
+ * sig = dsa.syssign(digest)
+ * puts dsa.sysverify(digest, sig) # => true
+ *
+ */
+static VALUE
+ossl_dsa_verify(VALUE self, VALUE digest, VALUE sig)
+{
+ EVP_PKEY *pkey;
+ int ret;
+
+ GetPKeyDSA(self, pkey);
+ StringValue(digest);
+ StringValue(sig);
+ /* type is ignored (0) */
+ ret = DSA_verify(0, (unsigned char *)RSTRING_PTR(digest), RSTRING_LENINT(digest),
+ (unsigned char *)RSTRING_PTR(sig), RSTRING_LENINT(sig), pkey->pkey.dsa);
+ if (ret < 0) {
+ ossl_raise(eDSAError, NULL);
+ }
+ else if (ret == 1) {
+ return Qtrue;
+ }
+
+ return Qfalse;
+}
+
+OSSL_PKEY_BN(dsa, p)
+OSSL_PKEY_BN(dsa, q)
+OSSL_PKEY_BN(dsa, g)
+OSSL_PKEY_BN(dsa, pub_key)
+OSSL_PKEY_BN(dsa, priv_key)
+
+/*
+ * INIT
+ */
+void
+Init_ossl_dsa(void)
+{
+#if 0
+ mOSSL = rb_define_module("OpenSSL"); /* let rdoc know about mOSSL and mPKey */
+ mPKey = rb_define_module_under(mOSSL, "PKey");
+#endif
+
+ /* Document-class: OpenSSL::PKey::DSAError
+ *
+ * Generic exception that is raised if an operation on a DSA PKey
+ * fails unexpectedly or in case an instantiation of an instance of DSA
+ * fails due to non-conformant input data.
+ */
+ eDSAError = rb_define_class_under(mPKey, "DSAError", ePKeyError);
+
+ /* Document-class: OpenSSL::PKey::DSA
+ *
+ * DSA, the Digital Signature Algorithm, is specified in NIST's
+ * FIPS 186-3. It is an asymmetric public key algorithm that may be used
+ * similar to e.g. RSA.
+ * Please note that for OpenSSL versions prior to 1.0.0 the digest
+ * algorithms OpenSSL::Digest::DSS (equivalent to SHA) or
+ * OpenSSL::Digest::DSS1 (equivalent to SHA-1) must be used for issuing
+ * signatures with a DSA key using OpenSSL::PKey#sign.
+ * Starting with OpenSSL 1.0.0, digest algorithms are no longer restricted,
+ * any Digest may be used for signing.
+ */
+ cDSA = rb_define_class_under(mPKey, "DSA", cPKey);
+
+ rb_define_singleton_method(cDSA, "generate", ossl_dsa_s_generate, 1);
+ rb_define_method(cDSA, "initialize", ossl_dsa_initialize, -1);
+
+ rb_define_method(cDSA, "public?", ossl_dsa_is_public, 0);
+ rb_define_method(cDSA, "private?", ossl_dsa_is_private, 0);
+ rb_define_method(cDSA, "to_text", ossl_dsa_to_text, 0);
+ rb_define_method(cDSA, "export", ossl_dsa_export, -1);
+ rb_define_alias(cDSA, "to_pem", "export");
+ rb_define_alias(cDSA, "to_s", "export");
+ rb_define_method(cDSA, "to_der", ossl_dsa_to_der, 0);
+ rb_define_method(cDSA, "public_key", ossl_dsa_to_public_key, 0);
+ rb_define_method(cDSA, "syssign", ossl_dsa_sign, 1);
+ rb_define_method(cDSA, "sysverify", ossl_dsa_verify, 2);
+
+ DEF_OSSL_PKEY_BN(cDSA, dsa, p);
+ DEF_OSSL_PKEY_BN(cDSA, dsa, q);
+ DEF_OSSL_PKEY_BN(cDSA, dsa, g);
+ DEF_OSSL_PKEY_BN(cDSA, dsa, pub_key);
+ DEF_OSSL_PKEY_BN(cDSA, dsa, priv_key);
+
+ rb_define_method(cDSA, "params", ossl_dsa_get_params, 0);
+}
+
+#else /* defined NO_DSA */
+void
+Init_ossl_dsa(void)
+{
+}
+#endif /* NO_DSA */
diff --git a/jni/ruby/ext/openssl/ossl_pkey_ec.c b/jni/ruby/ext/openssl/ossl_pkey_ec.c
new file mode 100644
index 0000000..d63f757
--- /dev/null
+++ b/jni/ruby/ext/openssl/ossl_pkey_ec.c
@@ -0,0 +1,1703 @@
+/*
+ * Copyright (C) 2006-2007 Technorama Ltd. <oss-ruby@technorama.net>
+ */
+
+#include "ossl.h"
+
+#if !defined(OPENSSL_NO_EC) && (OPENSSL_VERSION_NUMBER >= 0x0090802fL)
+
+typedef struct {
+ EC_GROUP *group;
+ int dont_free;
+} ossl_ec_group;
+
+typedef struct {
+ EC_POINT *point;
+ int dont_free;
+} ossl_ec_point;
+
+
+#define EXPORT_PEM 0
+#define EXPORT_DER 1
+
+static const rb_data_type_t ossl_ec_group_type;
+static const rb_data_type_t ossl_ec_point_type;
+
+#define GetPKeyEC(obj, pkey) do { \
+ GetPKey((obj), (pkey)); \
+ if (EVP_PKEY_type((pkey)->type) != EVP_PKEY_EC) { \
+ ossl_raise(rb_eRuntimeError, "THIS IS NOT A EC PKEY!"); \
+ } \
+} while (0)
+
+#define SafeGet_ec_group(obj, group) do { \
+ OSSL_Check_Kind((obj), cEC_GROUP); \
+ TypedData_Get_Struct((obj), ossl_ec_group, &ossl_ec_group_type, (group)); \
+} while(0)
+
+#define Get_EC_KEY(obj, key) do { \
+ EVP_PKEY *pkey; \
+ GetPKeyEC((obj), pkey); \
+ (key) = pkey->pkey.ec; \
+} while(0)
+
+#define Require_EC_KEY(obj, key) do { \
+ Get_EC_KEY((obj), (key)); \
+ if ((key) == NULL) \
+ ossl_raise(eECError, "EC_KEY is not initialized"); \
+} while(0)
+
+#define SafeRequire_EC_KEY(obj, key) do { \
+ OSSL_Check_Kind((obj), cEC); \
+ Require_EC_KEY((obj), (key)); \
+} while (0)
+
+#define Get_EC_GROUP(obj, g) do { \
+ ossl_ec_group *ec_group; \
+ TypedData_Get_Struct((obj), ossl_ec_group, &ossl_ec_group_type, ec_group); \
+ if (ec_group == NULL) \
+ ossl_raise(eEC_GROUP, "missing ossl_ec_group structure"); \
+ (g) = ec_group->group; \
+} while(0)
+
+#define Require_EC_GROUP(obj, group) do { \
+ Get_EC_GROUP((obj), (group)); \
+ if ((group) == NULL) \
+ ossl_raise(eEC_GROUP, "EC_GROUP is not initialized"); \
+} while(0)
+
+#define SafeRequire_EC_GROUP(obj, group) do { \
+ OSSL_Check_Kind((obj), cEC_GROUP); \
+ Require_EC_GROUP((obj), (group)); \
+} while(0)
+
+#define Get_EC_POINT(obj, p) do { \
+ ossl_ec_point *ec_point; \
+ TypedData_Get_Struct((obj), ossl_ec_point, &ossl_ec_point_type, ec_point); \
+ if (ec_point == NULL) \
+ ossl_raise(eEC_POINT, "missing ossl_ec_point structure"); \
+ (p) = ec_point->point; \
+} while(0)
+
+#define Require_EC_POINT(obj, point) do { \
+ Get_EC_POINT((obj), (point)); \
+ if ((point) == NULL) \
+ ossl_raise(eEC_POINT, "EC_POINT is not initialized"); \
+} while(0)
+
+#define SafeRequire_EC_POINT(obj, point) do { \
+ OSSL_Check_Kind((obj), cEC_POINT); \
+ Require_EC_POINT((obj), (point)); \
+} while(0)
+
+VALUE cEC;
+VALUE eECError;
+VALUE cEC_GROUP;
+VALUE eEC_GROUP;
+VALUE cEC_POINT;
+VALUE eEC_POINT;
+
+static ID s_GFp;
+static ID s_GFp_simple;
+static ID s_GFp_mont;
+static ID s_GFp_nist;
+static ID s_GF2m;
+static ID s_GF2m_simple;
+
+static ID ID_uncompressed;
+static ID ID_compressed;
+static ID ID_hybrid;
+
+static VALUE ec_instance(VALUE klass, EC_KEY *ec)
+{
+ EVP_PKEY *pkey;
+ VALUE obj;
+
+ if (!ec) {
+ return Qfalse;
+ }
+ if (!(pkey = EVP_PKEY_new())) {
+ return Qfalse;
+ }
+ if (!EVP_PKEY_assign_EC_KEY(pkey, ec)) {
+ EVP_PKEY_free(pkey);
+ return Qfalse;
+ }
+ WrapPKey(klass, obj, pkey);
+
+ return obj;
+}
+
+VALUE ossl_ec_new(EVP_PKEY *pkey)
+{
+ VALUE obj;
+
+ if (!pkey) {
+ obj = ec_instance(cEC, EC_KEY_new());
+ } else {
+ if (EVP_PKEY_type(pkey->type) != EVP_PKEY_EC) {
+ ossl_raise(rb_eTypeError, "Not a EC key!");
+ }
+ WrapPKey(cEC, obj, pkey);
+ }
+ if (obj == Qfalse) {
+ ossl_raise(eECError, NULL);
+ }
+
+ return obj;
+}
+
+
+/* call-seq:
+ * OpenSSL::PKey::EC.new()
+ * OpenSSL::PKey::EC.new(ec_key)
+ * OpenSSL::PKey::EC.new(ec_group)
+ * OpenSSL::PKey::EC.new("secp112r1")
+ * OpenSSL::PKey::EC.new(pem_string)
+ * OpenSSL::PKey::EC.new(pem_string [, pwd])
+ * OpenSSL::PKey::EC.new(der_string)
+ *
+ * See the OpenSSL documentation for:
+ * EC_KEY_*
+ */
+static VALUE ossl_ec_key_initialize(int argc, VALUE *argv, VALUE self)
+{
+ EVP_PKEY *pkey;
+ EC_KEY *ec = NULL;
+ VALUE arg, pass;
+ VALUE group = Qnil;
+ char *passwd = NULL;
+
+ GetPKey(self, pkey);
+ if (pkey->pkey.ec)
+ ossl_raise(eECError, "EC_KEY already initialized");
+
+ rb_scan_args(argc, argv, "02", &arg, &pass);
+
+ if (NIL_P(arg)) {
+ ec = EC_KEY_new();
+ } else {
+ if (rb_obj_is_kind_of(arg, cEC)) {
+ EC_KEY *other_ec = NULL;
+
+ SafeRequire_EC_KEY(arg, other_ec);
+ ec = EC_KEY_dup(other_ec);
+ } else if (rb_obj_is_kind_of(arg, cEC_GROUP)) {
+ ec = EC_KEY_new();
+ group = arg;
+ } else {
+ BIO *in = ossl_obj2bio(arg);
+
+ if (!NIL_P(pass)) {
+ passwd = StringValuePtr(pass);
+ }
+ ec = PEM_read_bio_ECPrivateKey(in, NULL, ossl_pem_passwd_cb, passwd);
+ if (!ec) {
+ OSSL_BIO_reset(in);
+ ec = PEM_read_bio_EC_PUBKEY(in, NULL, ossl_pem_passwd_cb, passwd);
+ }
+ if (!ec) {
+ OSSL_BIO_reset(in);
+ ec = d2i_ECPrivateKey_bio(in, NULL);
+ }
+ if (!ec) {
+ OSSL_BIO_reset(in);
+ ec = d2i_EC_PUBKEY_bio(in, NULL);
+ }
+
+ BIO_free(in);
+
+ if (ec == NULL) {
+ const char *name = StringValueCStr(arg);
+ int nid = OBJ_sn2nid(name);
+
+ (void)ERR_get_error();
+ if (nid == NID_undef)
+ ossl_raise(eECError, "unknown curve name (%s)\n", name);
+
+ if ((ec = EC_KEY_new_by_curve_name(nid)) == NULL)
+ ossl_raise(eECError, "unable to create curve (%s)\n", name);
+
+ EC_KEY_set_asn1_flag(ec, OPENSSL_EC_NAMED_CURVE);
+ EC_KEY_set_conv_form(ec, POINT_CONVERSION_UNCOMPRESSED);
+ }
+ }
+ }
+
+ if (ec == NULL)
+ ossl_raise(eECError, NULL);
+
+ if (!EVP_PKEY_assign_EC_KEY(pkey, ec)) {
+ EC_KEY_free(ec);
+ ossl_raise(eECError, "EVP_PKEY_assign_EC_KEY");
+ }
+
+ rb_iv_set(self, "@group", Qnil);
+
+ if (!NIL_P(group))
+ rb_funcall(self, rb_intern("group="), 1, arg);
+
+ return self;
+}
+
+/*
+ * call-seq:
+ * key.group => group
+ *
+ * Returns a constant <code>OpenSSL::EC::Group</code> that is tied to the key.
+ * Modifying the returned group can make the key invalid.
+ */
+static VALUE ossl_ec_key_get_group(VALUE self)
+{
+ VALUE group_v;
+ EC_KEY *ec;
+ ossl_ec_group *ec_group;
+ EC_GROUP *group;
+
+ Require_EC_KEY(self, ec);
+
+ group_v = rb_iv_get(self, "@group");
+ if (!NIL_P(group_v))
+ return group_v;
+
+ if ((group = (EC_GROUP *)EC_KEY_get0_group(ec)) != NULL) {
+ group_v = rb_obj_alloc(cEC_GROUP);
+ SafeGet_ec_group(group_v, ec_group);
+ ec_group->group = group;
+ ec_group->dont_free = 1;
+ rb_iv_set(group_v, "@key", self);
+ rb_iv_set(self, "@group", group_v);
+ return group_v;
+ }
+
+ return Qnil;
+}
+
+/*
+ * call-seq:
+ * key.group = group => group
+ *
+ * Returns the same object passed, not the group object associated with the key.
+ * If you wish to access the group object tied to the key call key.group after setting
+ * the group.
+ *
+ * Setting the group will immediately destroy any previously assigned group object.
+ * The group is internally copied by OpenSSL. Modifying the original group after
+ * assignment will not effect the internal key structure.
+ * (your changes may be lost). BE CAREFUL.
+ *
+ * EC_KEY_set_group calls EC_GROUP_free(key->group) then EC_GROUP_dup(), not EC_GROUP_copy.
+ * This documentation is accurate for OpenSSL 0.9.8b.
+ */
+static VALUE ossl_ec_key_set_group(VALUE self, VALUE group_v)
+{
+ VALUE old_group_v;
+ EC_KEY *ec;
+ EC_GROUP *group;
+
+ Require_EC_KEY(self, ec);
+ SafeRequire_EC_GROUP(group_v, group);
+
+ old_group_v = rb_iv_get(self, "@group");
+ if (!NIL_P(old_group_v)) {
+ ossl_ec_group *old_ec_group;
+ SafeGet_ec_group(old_group_v, old_ec_group);
+
+ old_ec_group->group = NULL;
+ old_ec_group->dont_free = 0;
+ rb_iv_set(old_group_v, "@key", Qnil);
+ }
+
+ rb_iv_set(self, "@group", Qnil);
+
+ if (EC_KEY_set_group(ec, group) != 1)
+ ossl_raise(eECError, "EC_KEY_set_group");
+
+ return group_v;
+}
+
+/*
+ * call-seq:
+ * key.private_key => OpenSSL::BN
+ *
+ * See the OpenSSL documentation for EC_KEY_get0_private_key()
+ */
+static VALUE ossl_ec_key_get_private_key(VALUE self)
+{
+ EC_KEY *ec;
+ const BIGNUM *bn;
+
+ Require_EC_KEY(self, ec);
+
+ if ((bn = EC_KEY_get0_private_key(ec)) == NULL)
+ return Qnil;
+
+ return ossl_bn_new(bn);
+}
+
+/*
+ * call-seq:
+ * key.private_key = openssl_bn
+ *
+ * See the OpenSSL documentation for EC_KEY_set_private_key()
+ */
+static VALUE ossl_ec_key_set_private_key(VALUE self, VALUE private_key)
+{
+ EC_KEY *ec;
+ BIGNUM *bn = NULL;
+
+ Require_EC_KEY(self, ec);
+ if (!NIL_P(private_key))
+ bn = GetBNPtr(private_key);
+
+ switch (EC_KEY_set_private_key(ec, bn)) {
+ case 1:
+ break;
+ case 0:
+ if (bn == NULL)
+ break;
+ default:
+ ossl_raise(eECError, "EC_KEY_set_private_key");
+ }
+
+ return private_key;
+}
+
+
+static VALUE ossl_ec_point_dup(const EC_POINT *point, VALUE group_v)
+{
+ VALUE obj;
+ const EC_GROUP *group;
+ ossl_ec_point *new_point;
+
+ obj = rb_obj_alloc(cEC_POINT);
+ TypedData_Get_Struct(obj, ossl_ec_point, &ossl_ec_point_type, new_point);
+
+ SafeRequire_EC_GROUP(group_v, group);
+
+ new_point->point = EC_POINT_dup(point, group);
+ if (new_point->point == NULL)
+ ossl_raise(eEC_POINT, "EC_POINT_dup");
+ rb_iv_set(obj, "@group", group_v);
+
+ return obj;
+}
+
+/*
+ * call-seq:
+ * key.public_key => OpenSSL::PKey::EC::Point
+ *
+ * See the OpenSSL documentation for EC_KEY_get0_public_key()
+ */
+static VALUE ossl_ec_key_get_public_key(VALUE self)
+{
+ EC_KEY *ec;
+ const EC_POINT *point;
+ VALUE group;
+
+ Require_EC_KEY(self, ec);
+
+ if ((point = EC_KEY_get0_public_key(ec)) == NULL)
+ return Qnil;
+
+ group = rb_funcall(self, rb_intern("group"), 0);
+ if (NIL_P(group))
+ ossl_raise(eECError, "EC_KEY_get0_get0_group (has public_key but no group???");
+
+ return ossl_ec_point_dup(point, group);
+}
+
+/*
+ * call-seq:
+ * key.public_key = ec_point
+ *
+ * See the OpenSSL documentation for EC_KEY_set_public_key()
+ */
+static VALUE ossl_ec_key_set_public_key(VALUE self, VALUE public_key)
+{
+ EC_KEY *ec;
+ EC_POINT *point = NULL;
+
+ Require_EC_KEY(self, ec);
+ if (!NIL_P(public_key))
+ SafeRequire_EC_POINT(public_key, point);
+
+ switch (EC_KEY_set_public_key(ec, point)) {
+ case 1:
+ break;
+ case 0:
+ if (point == NULL)
+ break;
+ default:
+ ossl_raise(eECError, "EC_KEY_set_public_key");
+ }
+
+ return public_key;
+}
+
+/*
+ * call-seq:
+ * key.public_key? => true or false
+ *
+ * Both public_key? and private_key? may return false at the same time unlike other PKey classes.
+ */
+static VALUE ossl_ec_key_is_public_key(VALUE self)
+{
+ EC_KEY *ec;
+
+ Require_EC_KEY(self, ec);
+
+ return (EC_KEY_get0_public_key(ec) ? Qtrue : Qfalse);
+}
+
+/*
+ * call-seq:
+ * key.private_key? => true or false
+ *
+ * Both public_key? and private_key? may return false at the same time unlike other PKey classes.
+ */
+static VALUE ossl_ec_key_is_private_key(VALUE self)
+{
+ EC_KEY *ec;
+
+ Require_EC_KEY(self, ec);
+
+ return (EC_KEY_get0_private_key(ec) ? Qtrue : Qfalse);
+}
+
+static VALUE ossl_ec_key_to_string(VALUE self, VALUE ciph, VALUE pass, int format)
+{
+ EC_KEY *ec;
+ BIO *out;
+ int i = -1;
+ int private = 0;
+ char *password = NULL;
+ VALUE str;
+
+ Require_EC_KEY(self, ec);
+
+ if (EC_KEY_get0_public_key(ec) == NULL)
+ ossl_raise(eECError, "can't export - no public key set");
+
+ if (EC_KEY_check_key(ec) != 1)
+ ossl_raise(eECError, "can't export - EC_KEY_check_key failed");
+
+ if (EC_KEY_get0_private_key(ec))
+ private = 1;
+
+ if (!(out = BIO_new(BIO_s_mem())))
+ ossl_raise(eECError, "BIO_new(BIO_s_mem())");
+
+ switch(format) {
+ case EXPORT_PEM:
+ if (private) {
+ const EVP_CIPHER *cipher;
+ if (!NIL_P(ciph)) {
+ cipher = GetCipherPtr(ciph);
+ if (!NIL_P(pass)) {
+ StringValue(pass);
+ if (RSTRING_LENINT(pass) < OSSL_MIN_PWD_LEN)
+ ossl_raise(eOSSLError, "OpenSSL requires passwords to be at least four characters long");
+ password = RSTRING_PTR(pass);
+ }
+ }
+ else {
+ cipher = NULL;
+ }
+ i = PEM_write_bio_ECPrivateKey(out, ec, cipher, NULL, 0, NULL, password);
+ } else {
+ i = PEM_write_bio_EC_PUBKEY(out, ec);
+ }
+
+ break;
+ case EXPORT_DER:
+ if (private) {
+ i = i2d_ECPrivateKey_bio(out, ec);
+ } else {
+ i = i2d_EC_PUBKEY_bio(out, ec);
+ }
+
+ break;
+ default:
+ BIO_free(out);
+ ossl_raise(rb_eRuntimeError, "unknown format (internal error)");
+ }
+
+ if (i != 1) {
+ BIO_free(out);
+ ossl_raise(eECError, "outlen=%d", i);
+ }
+
+ str = ossl_membio2str(out);
+
+ return str;
+}
+
+/*
+ * call-seq:
+ * key.export([cipher, pass_phrase]) => String
+ * key.to_pem([cipher, pass_phrase]) => String
+ *
+ * Outputs the EC key in PEM encoding. If +cipher+ and +pass_phrase+ are
+ * given they will be used to encrypt the key. +cipher+ must be an
+ * OpenSSL::Cipher::Cipher instance. Note that encryption will only be
+ * effective for a private key, public keys will always be encoded in plain
+ * text.
+ *
+ */
+static VALUE ossl_ec_key_export(int argc, VALUE *argv, VALUE self)
+{
+ VALUE cipher, passwd;
+ rb_scan_args(argc, argv, "02", &cipher, &passwd);
+ return ossl_ec_key_to_string(self, cipher, passwd, EXPORT_PEM);
+}
+
+/*
+ * call-seq:
+ * key.to_der => String
+ *
+ * See the OpenSSL documentation for i2d_ECPrivateKey_bio()
+ */
+static VALUE ossl_ec_key_to_der(VALUE self)
+{
+ return ossl_ec_key_to_string(self, Qnil, Qnil, EXPORT_DER);
+}
+
+/*
+ * call-seq:
+ * key.to_text => String
+ *
+ * See the OpenSSL documentation for EC_KEY_print()
+ */
+static VALUE ossl_ec_key_to_text(VALUE self)
+{
+ EC_KEY *ec;
+ BIO *out;
+ VALUE str;
+
+ Require_EC_KEY(self, ec);
+ if (!(out = BIO_new(BIO_s_mem()))) {
+ ossl_raise(eECError, "BIO_new(BIO_s_mem())");
+ }
+ if (!EC_KEY_print(out, ec, 0)) {
+ BIO_free(out);
+ ossl_raise(eECError, "EC_KEY_print");
+ }
+ str = ossl_membio2str(out);
+
+ return str;
+}
+
+/*
+ * call-seq:
+ * key.generate_key => self
+ *
+ * See the OpenSSL documentation for EC_KEY_generate_key()
+ */
+static VALUE ossl_ec_key_generate_key(VALUE self)
+{
+ EC_KEY *ec;
+
+ Require_EC_KEY(self, ec);
+
+ if (EC_KEY_generate_key(ec) != 1)
+ ossl_raise(eECError, "EC_KEY_generate_key");
+
+ return self;
+}
+
+/*
+ * call-seq:
+ * key.check_key => true
+ *
+ * Raises an exception if the key is invalid.
+ *
+ * See the OpenSSL documentation for EC_KEY_check_key()
+ */
+static VALUE ossl_ec_key_check_key(VALUE self)
+{
+ EC_KEY *ec;
+
+ Require_EC_KEY(self, ec);
+
+ if (EC_KEY_check_key(ec) != 1)
+ ossl_raise(eECError, "EC_KEY_check_key");
+
+ return Qtrue;
+}
+
+/*
+ * call-seq:
+ * key.dh_compute_key(pubkey) => String
+ *
+ * See the OpenSSL documentation for ECDH_compute_key()
+ */
+static VALUE ossl_ec_key_dh_compute_key(VALUE self, VALUE pubkey)
+{
+ EC_KEY *ec;
+ EC_POINT *point;
+ int buf_len;
+ VALUE str;
+
+ Require_EC_KEY(self, ec);
+ SafeRequire_EC_POINT(pubkey, point);
+
+/* BUG: need a way to figure out the maximum string size */
+ buf_len = 1024;
+ str = rb_str_new(0, buf_len);
+/* BUG: take KDF as a block */
+ buf_len = ECDH_compute_key(RSTRING_PTR(str), buf_len, point, ec, NULL);
+ if (buf_len < 0)
+ ossl_raise(eECError, "ECDH_compute_key");
+
+ rb_str_resize(str, buf_len);
+
+ return str;
+}
+
+/* sign_setup */
+
+/*
+ * call-seq:
+ * key.dsa_sign_asn1(data) => String
+ *
+ * See the OpenSSL documentation for ECDSA_sign()
+ */
+static VALUE ossl_ec_key_dsa_sign_asn1(VALUE self, VALUE data)
+{
+ EC_KEY *ec;
+ unsigned int buf_len;
+ VALUE str;
+
+ Require_EC_KEY(self, ec);
+ StringValue(data);
+
+ if (EC_KEY_get0_private_key(ec) == NULL)
+ ossl_raise(eECError, "Private EC key needed!");
+
+ str = rb_str_new(0, ECDSA_size(ec) + 16);
+ if (ECDSA_sign(0, (unsigned char *) RSTRING_PTR(data), RSTRING_LENINT(data), (unsigned char *) RSTRING_PTR(str), &buf_len, ec) != 1)
+ ossl_raise(eECError, "ECDSA_sign");
+
+ rb_str_resize(str, buf_len);
+
+ return str;
+}
+
+/*
+ * call-seq:
+ * key.dsa_verify_asn1(data, sig) => true or false
+ *
+ * See the OpenSSL documentation for ECDSA_verify()
+ */
+static VALUE ossl_ec_key_dsa_verify_asn1(VALUE self, VALUE data, VALUE sig)
+{
+ EC_KEY *ec;
+
+ Require_EC_KEY(self, ec);
+ StringValue(data);
+ StringValue(sig);
+
+ switch (ECDSA_verify(0, (unsigned char *) RSTRING_PTR(data), RSTRING_LENINT(data), (unsigned char *) RSTRING_PTR(sig), (int)RSTRING_LEN(sig), ec)) {
+ case 1: return Qtrue;
+ case 0: return Qfalse;
+ default: break;
+ }
+
+ ossl_raise(eECError, "ECDSA_verify");
+
+ UNREACHABLE;
+}
+
+static void ossl_ec_group_free(void *ptr)
+{
+ ossl_ec_group *ec_group = ptr;
+ if (!ec_group->dont_free && ec_group->group)
+ EC_GROUP_clear_free(ec_group->group);
+ ruby_xfree(ec_group);
+}
+
+static const rb_data_type_t ossl_ec_group_type = {
+ "OpenSSL/ec_group",
+ {
+ 0, ossl_ec_group_free,
+ },
+ 0, 0, RUBY_TYPED_FREE_IMMEDIATELY,
+};
+
+static VALUE ossl_ec_group_alloc(VALUE klass)
+{
+ ossl_ec_group *ec_group;
+ VALUE obj;
+
+ obj = TypedData_Make_Struct(klass, ossl_ec_group, &ossl_ec_group_type, ec_group);
+
+ return obj;
+}
+
+/* call-seq:
+ * OpenSSL::PKey::EC::Group.new("secp112r1")
+ * OpenSSL::PKey::EC::Group.new(ec_group)
+ * OpenSSL::PKey::EC::Group.new(pem_string)
+ * OpenSSL::PKey::EC::Group.new(der_string)
+ * OpenSSL::PKey::EC::Group.new(pem_file)
+ * OpenSSL::PKey::EC::Group.new(der_file)
+ * OpenSSL::PKey::EC::Group.new(:GFp_simple)
+ * OpenSSL::PKey::EC::Group.new(:GFp_mult)
+ * OpenSSL::PKey::EC::Group.new(:GFp_nist)
+ * OpenSSL::PKey::EC::Group.new(:GF2m_simple)
+ * OpenSSL::PKey::EC::Group.new(:GFp, bignum_p, bignum_a, bignum_b)
+ * OpenSSL::PKey::EC::Group.new(:GF2m, bignum_p, bignum_a, bignum_b)
+ *
+ * See the OpenSSL documentation for EC_GROUP_*
+ */
+static VALUE ossl_ec_group_initialize(int argc, VALUE *argv, VALUE self)
+{
+ VALUE arg1, arg2, arg3, arg4;
+ ossl_ec_group *ec_group;
+ EC_GROUP *group = NULL;
+
+ TypedData_Get_Struct(self, ossl_ec_group, &ossl_ec_group_type, ec_group);
+ if (ec_group->group != NULL)
+ ossl_raise(rb_eRuntimeError, "EC_GROUP is already initialized");
+
+ switch (rb_scan_args(argc, argv, "13", &arg1, &arg2, &arg3, &arg4)) {
+ case 1:
+ if (SYMBOL_P(arg1)) {
+ const EC_METHOD *method = NULL;
+ ID id = SYM2ID(arg1);
+
+ if (id == s_GFp_simple) {
+ method = EC_GFp_simple_method();
+ } else if (id == s_GFp_mont) {
+ method = EC_GFp_mont_method();
+ } else if (id == s_GFp_nist) {
+ method = EC_GFp_nist_method();
+#if !defined(OPENSSL_NO_EC2M)
+ } else if (id == s_GF2m_simple) {
+ method = EC_GF2m_simple_method();
+#endif
+ }
+
+ if (method) {
+ if ((group = EC_GROUP_new(method)) == NULL)
+ ossl_raise(eEC_GROUP, "EC_GROUP_new");
+ } else {
+ ossl_raise(rb_eArgError, "unknown symbol, must be :GFp_simple, :GFp_mont, :GFp_nist or :GF2m_simple");
+ }
+ } else if (rb_obj_is_kind_of(arg1, cEC_GROUP)) {
+ const EC_GROUP *arg1_group;
+
+ SafeRequire_EC_GROUP(arg1, arg1_group);
+ if ((group = EC_GROUP_dup(arg1_group)) == NULL)
+ ossl_raise(eEC_GROUP, "EC_GROUP_dup");
+ } else {
+ BIO *in = ossl_obj2bio(arg1);
+
+ group = PEM_read_bio_ECPKParameters(in, NULL, NULL, NULL);
+ if (!group) {
+ OSSL_BIO_reset(in);
+ group = d2i_ECPKParameters_bio(in, NULL);
+ }
+
+ BIO_free(in);
+
+ if (!group) {
+ const char *name = StringValueCStr(arg1);
+ int nid = OBJ_sn2nid(name);
+
+ (void)ERR_get_error();
+ if (nid == NID_undef)
+ ossl_raise(eEC_GROUP, "unknown curve name (%s)", name);
+
+ group = EC_GROUP_new_by_curve_name(nid);
+ if (group == NULL)
+ ossl_raise(eEC_GROUP, "unable to create curve (%s)", name);
+
+ EC_GROUP_set_asn1_flag(group, OPENSSL_EC_NAMED_CURVE);
+ EC_GROUP_set_point_conversion_form(group, POINT_CONVERSION_UNCOMPRESSED);
+ }
+ }
+
+ break;
+ case 4:
+ if (SYMBOL_P(arg1)) {
+ ID id = SYM2ID(arg1);
+ EC_GROUP *(*new_curve)(const BIGNUM *, const BIGNUM *, const BIGNUM *, BN_CTX *) = NULL;
+ const BIGNUM *p = GetBNPtr(arg2);
+ const BIGNUM *a = GetBNPtr(arg3);
+ const BIGNUM *b = GetBNPtr(arg4);
+
+ if (id == s_GFp) {
+ new_curve = EC_GROUP_new_curve_GFp;
+#if !defined(OPENSSL_NO_EC2M)
+ } else if (id == s_GF2m) {
+ new_curve = EC_GROUP_new_curve_GF2m;
+#endif
+ } else {
+ ossl_raise(rb_eArgError, "unknown symbol, must be :GFp or :GF2m");
+ }
+
+ if ((group = new_curve(p, a, b, ossl_bn_ctx)) == NULL)
+ ossl_raise(eEC_GROUP, "EC_GROUP_new_by_GF*");
+ } else {
+ ossl_raise(rb_eArgError, "unknown argument, must be :GFp or :GF2m");
+ }
+
+ break;
+ default:
+ ossl_raise(rb_eArgError, "wrong number of arguments");
+ }
+
+ if (group == NULL)
+ ossl_raise(eEC_GROUP, "");
+
+ ec_group->group = group;
+
+ return self;
+}
+
+/* call-seq:
+ * group1.eql?(group2) => true | false
+ * group1 == group2 => true | false
+ *
+ */
+static VALUE ossl_ec_group_eql(VALUE a, VALUE b)
+{
+ EC_GROUP *group1 = NULL, *group2 = NULL;
+
+ Require_EC_GROUP(a, group1);
+ SafeRequire_EC_GROUP(b, group2);
+
+ if (EC_GROUP_cmp(group1, group2, ossl_bn_ctx) == 1)
+ return Qfalse;
+
+ return Qtrue;
+}
+
+/* call-seq:
+ * group.generator => ec_point
+ *
+ * See the OpenSSL documentation for EC_GROUP_get0_generator()
+ */
+static VALUE ossl_ec_group_get_generator(VALUE self)
+{
+ VALUE point_obj;
+ EC_GROUP *group = NULL;
+
+ Require_EC_GROUP(self, group);
+
+ point_obj = ossl_ec_point_dup(EC_GROUP_get0_generator(group), self);
+
+ return point_obj;
+}
+
+/* call-seq:
+ * group.set_generator(generator, order, cofactor) => self
+ *
+ * See the OpenSSL documentation for EC_GROUP_set_generator()
+ */
+static VALUE ossl_ec_group_set_generator(VALUE self, VALUE generator, VALUE order, VALUE cofactor)
+{
+ EC_GROUP *group = NULL;
+ const EC_POINT *point;
+ const BIGNUM *o, *co;
+
+ Require_EC_GROUP(self, group);
+ SafeRequire_EC_POINT(generator, point);
+ o = GetBNPtr(order);
+ co = GetBNPtr(cofactor);
+
+ if (EC_GROUP_set_generator(group, point, o, co) != 1)
+ ossl_raise(eEC_GROUP, "EC_GROUP_set_generator");
+
+ return self;
+}
+
+/* call-seq:
+ * group.get_order => order_bn
+ *
+ * See the OpenSSL documentation for EC_GROUP_get_order()
+ */
+static VALUE ossl_ec_group_get_order(VALUE self)
+{
+ VALUE bn_obj;
+ BIGNUM *bn;
+ EC_GROUP *group = NULL;
+
+ Require_EC_GROUP(self, group);
+
+ bn_obj = ossl_bn_new(NULL);
+ bn = GetBNPtr(bn_obj);
+
+ if (EC_GROUP_get_order(group, bn, ossl_bn_ctx) != 1)
+ ossl_raise(eEC_GROUP, "EC_GROUP_get_order");
+
+ return bn_obj;
+}
+
+/* call-seq:
+ * group.get_cofactor => cofactor_bn
+ *
+ * See the OpenSSL documentation for EC_GROUP_get_cofactor()
+ */
+static VALUE ossl_ec_group_get_cofactor(VALUE self)
+{
+ VALUE bn_obj;
+ BIGNUM *bn;
+ EC_GROUP *group = NULL;
+
+ Require_EC_GROUP(self, group);
+
+ bn_obj = ossl_bn_new(NULL);
+ bn = GetBNPtr(bn_obj);
+
+ if (EC_GROUP_get_cofactor(group, bn, ossl_bn_ctx) != 1)
+ ossl_raise(eEC_GROUP, "EC_GROUP_get_cofactor");
+
+ return bn_obj;
+}
+
+/* call-seq:
+ * group.curve_name => String
+ *
+ * See the OpenSSL documentation for EC_GROUP_get_curve_name()
+ */
+static VALUE ossl_ec_group_get_curve_name(VALUE self)
+{
+ EC_GROUP *group = NULL;
+ int nid;
+
+ Get_EC_GROUP(self, group);
+ if (group == NULL)
+ return Qnil;
+
+ nid = EC_GROUP_get_curve_name(group);
+
+/* BUG: an nid or asn1 object should be returned, maybe. */
+ return rb_str_new2(OBJ_nid2sn(nid));
+}
+
+/* call-seq:
+ * EC.builtin_curves => [[name, comment], ...]
+ *
+ * See the OpenSSL documentation for EC_builtin_curves()
+ */
+static VALUE ossl_s_builtin_curves(VALUE self)
+{
+ EC_builtin_curve *curves = NULL;
+ int n;
+ int crv_len = rb_long2int(EC_get_builtin_curves(NULL, 0));
+ VALUE ary, ret;
+
+ curves = ALLOCA_N(EC_builtin_curve, crv_len);
+ if (curves == NULL)
+ return Qnil;
+ if (!EC_get_builtin_curves(curves, crv_len))
+ ossl_raise(rb_eRuntimeError, "EC_get_builtin_curves");
+
+ ret = rb_ary_new2(crv_len);
+
+ for (n = 0; n < crv_len; n++) {
+ const char *sname = OBJ_nid2sn(curves[n].nid);
+ const char *comment = curves[n].comment;
+
+ ary = rb_ary_new2(2);
+ rb_ary_push(ary, rb_str_new2(sname));
+ rb_ary_push(ary, comment ? rb_str_new2(comment) : Qnil);
+ rb_ary_push(ret, ary);
+ }
+
+ return ret;
+}
+
+/* call-seq:
+ * group.asn1_flag => Fixnum
+ *
+ * See the OpenSSL documentation for EC_GROUP_get_asn1_flag()
+ */
+static VALUE ossl_ec_group_get_asn1_flag(VALUE self)
+{
+ EC_GROUP *group = NULL;
+ int flag;
+
+ Require_EC_GROUP(self, group);
+
+ flag = EC_GROUP_get_asn1_flag(group);
+
+ return INT2FIX(flag);
+}
+
+/* call-seq:
+ * group.asn1_flag = Fixnum => Fixnum
+ *
+ * See the OpenSSL documentation for EC_GROUP_set_asn1_flag()
+ */
+static VALUE ossl_ec_group_set_asn1_flag(VALUE self, VALUE flag_v)
+{
+ EC_GROUP *group = NULL;
+
+ Require_EC_GROUP(self, group);
+
+ EC_GROUP_set_asn1_flag(group, NUM2INT(flag_v));
+
+ return flag_v;
+}
+
+/* call-seq:
+ * group.point_conversion_form => :uncompressed | :compressed | :hybrid
+ *
+ * See the OpenSSL documentation for EC_GROUP_get_point_conversion_form()
+ */
+static VALUE ossl_ec_group_get_point_conversion_form(VALUE self)
+{
+ EC_GROUP *group = NULL;
+ point_conversion_form_t form;
+ VALUE ret;
+
+ Require_EC_GROUP(self, group);
+
+ form = EC_GROUP_get_point_conversion_form(group);
+
+ switch (form) {
+ case POINT_CONVERSION_UNCOMPRESSED: ret = ID_uncompressed; break;
+ case POINT_CONVERSION_COMPRESSED: ret = ID_compressed; break;
+ case POINT_CONVERSION_HYBRID: ret = ID_hybrid; break;
+ default: ossl_raise(eEC_GROUP, "unsupported point conversion form: %d, this module should be updated", form);
+ }
+
+ return ID2SYM(ret);
+}
+
+/* call-seq:
+ * group.point_conversion_form = form => form
+ *
+ * See the OpenSSL documentation for EC_GROUP_set_point_conversion_form()
+ */
+static VALUE ossl_ec_group_set_point_conversion_form(VALUE self, VALUE form_v)
+{
+ EC_GROUP *group = NULL;
+ point_conversion_form_t form;
+ ID form_id = SYM2ID(form_v);
+
+ Require_EC_GROUP(self, group);
+
+ if (form_id == ID_uncompressed) {
+ form = POINT_CONVERSION_UNCOMPRESSED;
+ } else if (form_id == ID_compressed) {
+ form = POINT_CONVERSION_COMPRESSED;
+ } else if (form_id == ID_hybrid) {
+ form = POINT_CONVERSION_HYBRID;
+ } else {
+ ossl_raise(rb_eArgError, "form must be :compressed, :uncompressed, or :hybrid");
+ }
+
+ EC_GROUP_set_point_conversion_form(group, form);
+
+ return form_v;
+}
+
+/* call-seq:
+ * group.seed => String or nil
+ *
+ * See the OpenSSL documentation for EC_GROUP_get0_seed()
+ */
+static VALUE ossl_ec_group_get_seed(VALUE self)
+{
+ EC_GROUP *group = NULL;
+ size_t seed_len;
+
+ Require_EC_GROUP(self, group);
+
+ seed_len = EC_GROUP_get_seed_len(group);
+
+ if (seed_len == 0)
+ return Qnil;
+
+ return rb_str_new((const char *)EC_GROUP_get0_seed(group), seed_len);
+}
+
+/* call-seq:
+ * group.seed = seed => seed
+ *
+ * See the OpenSSL documentation for EC_GROUP_set_seed()
+ */
+static VALUE ossl_ec_group_set_seed(VALUE self, VALUE seed)
+{
+ EC_GROUP *group = NULL;
+
+ Require_EC_GROUP(self, group);
+ StringValue(seed);
+
+ if (EC_GROUP_set_seed(group, (unsigned char *)RSTRING_PTR(seed), RSTRING_LEN(seed)) != (size_t)RSTRING_LEN(seed))
+ ossl_raise(eEC_GROUP, "EC_GROUP_set_seed");
+
+ return seed;
+}
+
+/* get/set curve GFp, GF2m */
+
+/* call-seq:
+ * group.degree => Fixnum
+ *
+ * See the OpenSSL documentation for EC_GROUP_get_degree()
+ */
+static VALUE ossl_ec_group_get_degree(VALUE self)
+{
+ EC_GROUP *group = NULL;
+
+ Require_EC_GROUP(self, group);
+
+ return INT2NUM(EC_GROUP_get_degree(group));
+}
+
+static VALUE ossl_ec_group_to_string(VALUE self, int format)
+{
+ EC_GROUP *group;
+ BIO *out;
+ int i = -1;
+ VALUE str;
+
+ Get_EC_GROUP(self, group);
+
+ if (!(out = BIO_new(BIO_s_mem())))
+ ossl_raise(eEC_GROUP, "BIO_new(BIO_s_mem())");
+
+ switch(format) {
+ case EXPORT_PEM:
+ i = PEM_write_bio_ECPKParameters(out, group);
+ break;
+ case EXPORT_DER:
+ i = i2d_ECPKParameters_bio(out, group);
+ break;
+ default:
+ BIO_free(out);
+ ossl_raise(rb_eRuntimeError, "unknown format (internal error)");
+ }
+
+ if (i != 1) {
+ BIO_free(out);
+ ossl_raise(eECError, NULL);
+ }
+
+ str = ossl_membio2str(out);
+
+ return str;
+}
+
+/* call-seq:
+ * group.to_pem => String
+ *
+ * See the OpenSSL documentation for PEM_write_bio_ECPKParameters()
+ */
+static VALUE ossl_ec_group_to_pem(VALUE self)
+{
+ return ossl_ec_group_to_string(self, EXPORT_PEM);
+}
+
+/* call-seq:
+ * group.to_der => String
+ *
+ * See the OpenSSL documentation for i2d_ECPKParameters_bio()
+ */
+static VALUE ossl_ec_group_to_der(VALUE self)
+{
+ return ossl_ec_group_to_string(self, EXPORT_DER);
+}
+
+/* call-seq:
+ * group.to_text => String
+ *
+ * See the OpenSSL documentation for ECPKParameters_print()
+ */
+static VALUE ossl_ec_group_to_text(VALUE self)
+{
+ EC_GROUP *group;
+ BIO *out;
+ VALUE str;
+
+ Require_EC_GROUP(self, group);
+ if (!(out = BIO_new(BIO_s_mem()))) {
+ ossl_raise(eEC_GROUP, "BIO_new(BIO_s_mem())");
+ }
+ if (!ECPKParameters_print(out, group, 0)) {
+ BIO_free(out);
+ ossl_raise(eEC_GROUP, NULL);
+ }
+ str = ossl_membio2str(out);
+
+ return str;
+}
+
+
+static void ossl_ec_point_free(void *ptr)
+{
+ ossl_ec_point *ec_point = ptr;
+ if (!ec_point->dont_free && ec_point->point)
+ EC_POINT_clear_free(ec_point->point);
+ ruby_xfree(ec_point);
+}
+
+static const rb_data_type_t ossl_ec_point_type = {
+ "OpenSSL/ec_point",
+ {
+ 0, ossl_ec_point_free,
+ },
+ 0, 0, RUBY_TYPED_FREE_IMMEDIATELY,
+};
+
+static VALUE ossl_ec_point_alloc(VALUE klass)
+{
+ ossl_ec_point *ec_point;
+ VALUE obj;
+
+ obj = TypedData_Make_Struct(klass, ossl_ec_point, &ossl_ec_point_type, ec_point);
+
+ return obj;
+}
+
+/*
+ * call-seq:
+ * OpenSSL::PKey::EC::Point.new(point)
+ * OpenSSL::PKey::EC::Point.new(group)
+ * OpenSSL::PKey::EC::Point.new(group, bn)
+ *
+ * See the OpenSSL documentation for EC_POINT_*
+ */
+static VALUE ossl_ec_point_initialize(int argc, VALUE *argv, VALUE self)
+{
+ ossl_ec_point *ec_point;
+ EC_POINT *point = NULL;
+ VALUE arg1, arg2;
+ VALUE group_v = Qnil;
+ const EC_GROUP *group = NULL;
+
+ TypedData_Get_Struct(self, ossl_ec_point, &ossl_ec_point_type, ec_point);
+ if (ec_point->point)
+ ossl_raise(eEC_POINT, "EC_POINT already initialized");
+
+ switch (rb_scan_args(argc, argv, "11", &arg1, &arg2)) {
+ case 1:
+ if (rb_obj_is_kind_of(arg1, cEC_POINT)) {
+ const EC_POINT *arg_point;
+
+ group_v = rb_iv_get(arg1, "@group");
+ SafeRequire_EC_GROUP(group_v, group);
+ SafeRequire_EC_POINT(arg1, arg_point);
+
+ point = EC_POINT_dup(arg_point, group);
+ } else if (rb_obj_is_kind_of(arg1, cEC_GROUP)) {
+ group_v = arg1;
+ SafeRequire_EC_GROUP(group_v, group);
+
+ point = EC_POINT_new(group);
+ } else {
+ ossl_raise(eEC_POINT, "wrong argument type: must be OpenSSL::PKey::EC::Point or OpenSSL::Pkey::EC::Group");
+ }
+
+ break;
+ case 2:
+ if (!rb_obj_is_kind_of(arg1, cEC_GROUP))
+ ossl_raise(rb_eArgError, "1st argument must be OpenSSL::PKey::EC::Group");
+ group_v = arg1;
+ SafeRequire_EC_GROUP(group_v, group);
+
+ if (rb_obj_is_kind_of(arg2, cBN)) {
+ const BIGNUM *bn = GetBNPtr(arg2);
+
+ point = EC_POINT_bn2point(group, bn, NULL, ossl_bn_ctx);
+ } else {
+ BIO *in = ossl_obj2bio(arg1);
+
+/* BUG: finish me */
+
+ BIO_free(in);
+
+ if (point == NULL) {
+ ossl_raise(eEC_POINT, "unknown type for 2nd arg");
+ }
+ }
+ break;
+ default:
+ ossl_raise(rb_eArgError, "wrong number of arguments");
+ }
+
+ if (point == NULL)
+ ossl_raise(eEC_POINT, NULL);
+
+ if (NIL_P(group_v))
+ ossl_raise(rb_eRuntimeError, "missing group (internal error)");
+
+ ec_point->point = point;
+
+ rb_iv_set(self, "@group", group_v);
+
+ return self;
+}
+
+/*
+ * call-seq:
+ * point1.eql?(point2) => true | false
+ * point1 == point2 => true | false
+ *
+ */
+static VALUE ossl_ec_point_eql(VALUE a, VALUE b)
+{
+ EC_POINT *point1, *point2;
+ VALUE group_v1 = rb_iv_get(a, "@group");
+ VALUE group_v2 = rb_iv_get(b, "@group");
+ const EC_GROUP *group;
+
+ if (ossl_ec_group_eql(group_v1, group_v2) == Qfalse)
+ return Qfalse;
+
+ Require_EC_POINT(a, point1);
+ SafeRequire_EC_POINT(b, point2);
+ SafeRequire_EC_GROUP(group_v1, group);
+
+ if (EC_POINT_cmp(group, point1, point2, ossl_bn_ctx) == 1)
+ return Qfalse;
+
+ return Qtrue;
+}
+
+/*
+ * call-seq:
+ * point.infinity? => true | false
+ *
+ */
+static VALUE ossl_ec_point_is_at_infinity(VALUE self)
+{
+ EC_POINT *point;
+ VALUE group_v = rb_iv_get(self, "@group");
+ const EC_GROUP *group;
+
+ Require_EC_POINT(self, point);
+ SafeRequire_EC_GROUP(group_v, group);
+
+ switch (EC_POINT_is_at_infinity(group, point)) {
+ case 1: return Qtrue;
+ case 0: return Qfalse;
+ default: ossl_raise(cEC_POINT, "EC_POINT_is_at_infinity");
+ }
+
+ UNREACHABLE;
+}
+
+/*
+ * call-seq:
+ * point.on_curve? => true | false
+ *
+ */
+static VALUE ossl_ec_point_is_on_curve(VALUE self)
+{
+ EC_POINT *point;
+ VALUE group_v = rb_iv_get(self, "@group");
+ const EC_GROUP *group;
+
+ Require_EC_POINT(self, point);
+ SafeRequire_EC_GROUP(group_v, group);
+
+ switch (EC_POINT_is_on_curve(group, point, ossl_bn_ctx)) {
+ case 1: return Qtrue;
+ case 0: return Qfalse;
+ default: ossl_raise(cEC_POINT, "EC_POINT_is_on_curve");
+ }
+
+ UNREACHABLE;
+}
+
+/*
+ * call-seq:
+ * point.make_affine! => self
+ *
+ */
+static VALUE ossl_ec_point_make_affine(VALUE self)
+{
+ EC_POINT *point;
+ VALUE group_v = rb_iv_get(self, "@group");
+ const EC_GROUP *group;
+
+ Require_EC_POINT(self, point);
+ SafeRequire_EC_GROUP(group_v, group);
+
+ if (EC_POINT_make_affine(group, point, ossl_bn_ctx) != 1)
+ ossl_raise(cEC_POINT, "EC_POINT_make_affine");
+
+ return self;
+}
+
+/*
+ * call-seq:
+ * point.invert! => self
+ *
+ */
+static VALUE ossl_ec_point_invert(VALUE self)
+{
+ EC_POINT *point;
+ VALUE group_v = rb_iv_get(self, "@group");
+ const EC_GROUP *group;
+
+ Require_EC_POINT(self, point);
+ SafeRequire_EC_GROUP(group_v, group);
+
+ if (EC_POINT_invert(group, point, ossl_bn_ctx) != 1)
+ ossl_raise(cEC_POINT, "EC_POINT_invert");
+
+ return self;
+}
+
+/*
+ * call-seq:
+ * point.set_to_infinity! => self
+ *
+ */
+static VALUE ossl_ec_point_set_to_infinity(VALUE self)
+{
+ EC_POINT *point;
+ VALUE group_v = rb_iv_get(self, "@group");
+ const EC_GROUP *group;
+
+ Require_EC_POINT(self, point);
+ SafeRequire_EC_GROUP(group_v, group);
+
+ if (EC_POINT_set_to_infinity(group, point) != 1)
+ ossl_raise(cEC_POINT, "EC_POINT_set_to_infinity");
+
+ return self;
+}
+
+/*
+ * call-seq:
+ * point.to_bn => OpenSSL::BN
+ *
+ * See the OpenSSL documentation for EC_POINT_point2bn()
+ */
+static VALUE ossl_ec_point_to_bn(VALUE self)
+{
+ EC_POINT *point;
+ VALUE bn_obj;
+ VALUE group_v = rb_iv_get(self, "@group");
+ const EC_GROUP *group;
+ point_conversion_form_t form;
+ BIGNUM *bn;
+
+ Require_EC_POINT(self, point);
+ SafeRequire_EC_GROUP(group_v, group);
+
+ form = EC_GROUP_get_point_conversion_form(group);
+
+ bn_obj = rb_obj_alloc(cBN);
+ bn = GetBNPtr(bn_obj);
+
+ if (EC_POINT_point2bn(group, point, form, bn, ossl_bn_ctx) == NULL)
+ ossl_raise(eEC_POINT, "EC_POINT_point2bn");
+
+ return bn_obj;
+}
+
+/*
+ * call-seq:
+ * point.mul(bn) => point
+ * point.mul(bn, bn) => point
+ * point.mul([bn], [point]) => point
+ * point.mul([bn], [point], bn) => point
+ */
+static VALUE ossl_ec_point_mul(int argc, VALUE *argv, VALUE self)
+{
+ EC_POINT *point1, *point2;
+ const EC_GROUP *group;
+ VALUE group_v = rb_iv_get(self, "@group");
+ VALUE bn_v1, bn_v2, r, points_v;
+ BIGNUM *bn1 = NULL, *bn2 = NULL;
+
+ Require_EC_POINT(self, point1);
+ SafeRequire_EC_GROUP(group_v, group);
+
+ r = rb_obj_alloc(cEC_POINT);
+ ossl_ec_point_initialize(1, &group_v, r);
+ Require_EC_POINT(r, point2);
+
+ argc = rb_scan_args(argc, argv, "12", &bn_v1, &points_v, &bn_v2);
+
+ if (rb_obj_is_kind_of(bn_v1, cBN)) {
+ bn1 = GetBNPtr(bn_v1);
+ if (argc >= 2) {
+ bn2 = GetBNPtr(points_v);
+ }
+ if (EC_POINT_mul(group, point2, bn2, point1, bn1, ossl_bn_ctx) != 1)
+ ossl_raise(eEC_POINT, "Multiplication failed");
+ } else {
+ size_t i, points_len, bignums_len;
+ const EC_POINT **points;
+ const BIGNUM **bignums;
+
+ Check_Type(bn_v1, T_ARRAY);
+ bignums_len = RARRAY_LEN(bn_v1);
+ bignums = (const BIGNUM **)OPENSSL_malloc(bignums_len * (int)sizeof(BIGNUM *));
+
+ for (i = 0; i < bignums_len; ++i) {
+ bignums[i] = GetBNPtr(rb_ary_entry(bn_v1, i));
+ }
+
+ if (!rb_obj_is_kind_of(points_v, rb_cArray)) {
+ OPENSSL_free((void *)bignums);
+ rb_raise(rb_eTypeError, "Argument2 must be an array");
+ }
+
+ rb_ary_unshift(points_v, self);
+ points_len = RARRAY_LEN(points_v);
+ points = (const EC_POINT **)OPENSSL_malloc(points_len * (int)sizeof(EC_POINT *));
+
+ for (i = 0; i < points_len; ++i) {
+ Get_EC_POINT(rb_ary_entry(points_v, i), points[i]);
+ }
+
+ if (argc >= 3) {
+ bn2 = GetBNPtr(bn_v2);
+ }
+ if (EC_POINTs_mul(group, point2, bn2, points_len, points, bignums, ossl_bn_ctx) != 1) {
+ OPENSSL_free((void *)bignums);
+ OPENSSL_free((void *)points);
+ ossl_raise(eEC_POINT, "Multiplication failed");
+ }
+ OPENSSL_free((void *)bignums);
+ OPENSSL_free((void *)points);
+ }
+
+ return r;
+}
+
+static void no_copy(VALUE klass)
+{
+ rb_undef_method(klass, "copy");
+ rb_undef_method(klass, "clone");
+ rb_undef_method(klass, "dup");
+ rb_undef_method(klass, "initialize_copy");
+}
+
+void Init_ossl_ec(void)
+{
+#ifdef DONT_NEED_RDOC_WORKAROUND
+ mOSSL = rb_define_module("OpenSSL");
+ mPKey = rb_define_module_under(mOSSL, "PKey");
+#endif
+
+ eECError = rb_define_class_under(mPKey, "ECError", ePKeyError);
+
+ cEC = rb_define_class_under(mPKey, "EC", cPKey);
+ cEC_GROUP = rb_define_class_under(cEC, "Group", rb_cObject);
+ cEC_POINT = rb_define_class_under(cEC, "Point", rb_cObject);
+ eEC_GROUP = rb_define_class_under(cEC_GROUP, "Error", eOSSLError);
+ eEC_POINT = rb_define_class_under(cEC_POINT, "Error", eOSSLError);
+
+ s_GFp = rb_intern("GFp");
+ s_GF2m = rb_intern("GF2m");
+ s_GFp_simple = rb_intern("GFp_simple");
+ s_GFp_mont = rb_intern("GFp_mont");
+ s_GFp_nist = rb_intern("GFp_nist");
+ s_GF2m_simple = rb_intern("GF2m_simple");
+
+ ID_uncompressed = rb_intern("uncompressed");
+ ID_compressed = rb_intern("compressed");
+ ID_hybrid = rb_intern("hybrid");
+
+#ifdef OPENSSL_EC_NAMED_CURVE
+ rb_define_const(cEC, "NAMED_CURVE", ULONG2NUM(OPENSSL_EC_NAMED_CURVE));
+#endif
+
+ rb_define_singleton_method(cEC, "builtin_curves", ossl_s_builtin_curves, 0);
+
+ rb_define_method(cEC, "initialize", ossl_ec_key_initialize, -1);
+/* copy/dup/cmp */
+
+ rb_define_method(cEC, "group", ossl_ec_key_get_group, 0);
+ rb_define_method(cEC, "group=", ossl_ec_key_set_group, 1);
+ rb_define_method(cEC, "private_key", ossl_ec_key_get_private_key, 0);
+ rb_define_method(cEC, "private_key=", ossl_ec_key_set_private_key, 1);
+ rb_define_method(cEC, "public_key", ossl_ec_key_get_public_key, 0);
+ rb_define_method(cEC, "public_key=", ossl_ec_key_set_public_key, 1);
+ rb_define_method(cEC, "private_key?", ossl_ec_key_is_private_key, 0);
+ rb_define_method(cEC, "public_key?", ossl_ec_key_is_public_key, 0);
+/* rb_define_method(cEC, "", ossl_ec_key_get_, 0);
+ rb_define_method(cEC, "=", ossl_ec_key_set_ 1);
+ set/get enc_flags
+ set/get _conv_from
+ set/get asn1_flag (can use ruby to call self.group.asn1_flag)
+ set/get precompute_mult
+*/
+ rb_define_method(cEC, "generate_key", ossl_ec_key_generate_key, 0);
+ rb_define_method(cEC, "check_key", ossl_ec_key_check_key, 0);
+
+ rb_define_method(cEC, "dh_compute_key", ossl_ec_key_dh_compute_key, 1);
+ rb_define_method(cEC, "dsa_sign_asn1", ossl_ec_key_dsa_sign_asn1, 1);
+ rb_define_method(cEC, "dsa_verify_asn1", ossl_ec_key_dsa_verify_asn1, 2);
+/* do_sign/do_verify */
+
+ rb_define_method(cEC, "export", ossl_ec_key_export, -1);
+ rb_define_alias(cEC, "to_pem", "export");
+ rb_define_method(cEC, "to_der", ossl_ec_key_to_der, 0);
+ rb_define_method(cEC, "to_text", ossl_ec_key_to_text, 0);
+
+
+ rb_define_alloc_func(cEC_GROUP, ossl_ec_group_alloc);
+ rb_define_method(cEC_GROUP, "initialize", ossl_ec_group_initialize, -1);
+ rb_define_method(cEC_GROUP, "eql?", ossl_ec_group_eql, 1);
+ rb_define_alias(cEC_GROUP, "==", "eql?");
+/* copy/dup/cmp */
+
+ rb_define_method(cEC_GROUP, "generator", ossl_ec_group_get_generator, 0);
+ rb_define_method(cEC_GROUP, "set_generator", ossl_ec_group_set_generator, 3);
+ rb_define_method(cEC_GROUP, "order", ossl_ec_group_get_order, 0);
+ rb_define_method(cEC_GROUP, "cofactor", ossl_ec_group_get_cofactor, 0);
+
+ rb_define_method(cEC_GROUP, "curve_name", ossl_ec_group_get_curve_name, 0);
+/* rb_define_method(cEC_GROUP, "curve_name=", ossl_ec_group_set_curve_name, 1); */
+
+ rb_define_method(cEC_GROUP, "asn1_flag", ossl_ec_group_get_asn1_flag, 0);
+ rb_define_method(cEC_GROUP, "asn1_flag=", ossl_ec_group_set_asn1_flag, 1);
+
+ rb_define_method(cEC_GROUP, "point_conversion_form", ossl_ec_group_get_point_conversion_form, 0);
+ rb_define_method(cEC_GROUP, "point_conversion_form=", ossl_ec_group_set_point_conversion_form, 1);
+
+ rb_define_method(cEC_GROUP, "seed", ossl_ec_group_get_seed, 0);
+ rb_define_method(cEC_GROUP, "seed=", ossl_ec_group_set_seed, 1);
+
+/* get/set GFp, GF2m */
+
+ rb_define_method(cEC_GROUP, "degree", ossl_ec_group_get_degree, 0);
+
+/* check* */
+
+
+ rb_define_method(cEC_GROUP, "to_pem", ossl_ec_group_to_pem, 0);
+ rb_define_method(cEC_GROUP, "to_der", ossl_ec_group_to_der, 0);
+ rb_define_method(cEC_GROUP, "to_text", ossl_ec_group_to_text, 0);
+
+
+ rb_define_alloc_func(cEC_POINT, ossl_ec_point_alloc);
+ rb_define_method(cEC_POINT, "initialize", ossl_ec_point_initialize, -1);
+ rb_attr(cEC_POINT, rb_intern("group"), 1, 0, 0);
+ rb_define_method(cEC_POINT, "eql?", ossl_ec_point_eql, 1);
+ rb_define_alias(cEC_POINT, "==", "eql?");
+
+ rb_define_method(cEC_POINT, "infinity?", ossl_ec_point_is_at_infinity, 0);
+ rb_define_method(cEC_POINT, "on_curve?", ossl_ec_point_is_on_curve, 0);
+ rb_define_method(cEC_POINT, "make_affine!", ossl_ec_point_make_affine, 0);
+ rb_define_method(cEC_POINT, "invert!", ossl_ec_point_invert, 0);
+ rb_define_method(cEC_POINT, "set_to_infinity!", ossl_ec_point_set_to_infinity, 0);
+/* all the other methods */
+
+ rb_define_method(cEC_POINT, "to_bn", ossl_ec_point_to_bn, 0);
+ rb_define_method(cEC_POINT, "mul", ossl_ec_point_mul, -1);
+
+ no_copy(cEC);
+ no_copy(cEC_GROUP);
+ no_copy(cEC_POINT);
+}
+
+#else /* defined NO_EC */
+void Init_ossl_ec(void)
+{
+}
+#endif /* NO_EC */
diff --git a/jni/ruby/ext/openssl/ossl_pkey_rsa.c b/jni/ruby/ext/openssl/ossl_pkey_rsa.c
new file mode 100644
index 0000000..3c92933
--- /dev/null
+++ b/jni/ruby/ext/openssl/ossl_pkey_rsa.c
@@ -0,0 +1,701 @@
+/*
+ * $Id: ossl_pkey_rsa.c 47744 2014-09-30 05:25:32Z nobu $
+ * 'OpenSSL for Ruby' project
+ * Copyright (C) 2001-2002 Michal Rokos <m.rokos@sh.cvut.cz>
+ * All rights reserved.
+ */
+/*
+ * This program is licenced under the same licence as Ruby.
+ * (See the file 'LICENCE'.)
+ */
+#if !defined(OPENSSL_NO_RSA)
+
+#include "ossl.h"
+
+#define GetPKeyRSA(obj, pkey) do { \
+ GetPKey((obj), (pkey)); \
+ if (EVP_PKEY_type((pkey)->type) != EVP_PKEY_RSA) { /* PARANOIA? */ \
+ ossl_raise(rb_eRuntimeError, "THIS IS NOT A RSA!") ; \
+ } \
+} while (0)
+
+#define RSA_HAS_PRIVATE(rsa) ((rsa)->p && (rsa)->q)
+#define RSA_PRIVATE(obj,rsa) (RSA_HAS_PRIVATE(rsa)||OSSL_PKEY_IS_PRIVATE(obj))
+
+/*
+ * Classes
+ */
+VALUE cRSA;
+VALUE eRSAError;
+
+/*
+ * Public
+ */
+static VALUE
+rsa_instance(VALUE klass, RSA *rsa)
+{
+ EVP_PKEY *pkey;
+ VALUE obj;
+
+ if (!rsa) {
+ return Qfalse;
+ }
+ if (!(pkey = EVP_PKEY_new())) {
+ return Qfalse;
+ }
+ if (!EVP_PKEY_assign_RSA(pkey, rsa)) {
+ EVP_PKEY_free(pkey);
+ return Qfalse;
+ }
+ WrapPKey(klass, obj, pkey);
+
+ return obj;
+}
+
+VALUE
+ossl_rsa_new(EVP_PKEY *pkey)
+{
+ VALUE obj;
+
+ if (!pkey) {
+ obj = rsa_instance(cRSA, RSA_new());
+ }
+ else {
+ if (EVP_PKEY_type(pkey->type) != EVP_PKEY_RSA) {
+ ossl_raise(rb_eTypeError, "Not a RSA key!");
+ }
+ WrapPKey(cRSA, obj, pkey);
+ }
+ if (obj == Qfalse) {
+ ossl_raise(eRSAError, NULL);
+ }
+
+ return obj;
+}
+
+/*
+ * Private
+ */
+#if defined(HAVE_RSA_GENERATE_KEY_EX) && HAVE_BN_GENCB
+struct rsa_blocking_gen_arg {
+ RSA *rsa;
+ BIGNUM *e;
+ int size;
+ BN_GENCB *cb;
+ int result;
+};
+
+static void *
+rsa_blocking_gen(void *arg)
+{
+ struct rsa_blocking_gen_arg *gen = (struct rsa_blocking_gen_arg *)arg;
+ gen->result = RSA_generate_key_ex(gen->rsa, gen->size, gen->e, gen->cb);
+ return 0;
+}
+#endif
+
+static RSA *
+rsa_generate(int size, unsigned long exp)
+{
+#if defined(HAVE_RSA_GENERATE_KEY_EX) && HAVE_BN_GENCB
+ int i;
+ BN_GENCB cb;
+ struct ossl_generate_cb_arg cb_arg;
+ struct rsa_blocking_gen_arg gen_arg;
+ RSA *rsa = RSA_new();
+ BIGNUM *e = BN_new();
+
+ if (!rsa || !e) {
+ if (e) BN_free(e);
+ if (rsa) RSA_free(rsa);
+ return 0;
+ }
+ for (i = 0; i < (int)sizeof(exp) * 8; ++i) {
+ if (exp & (1UL << i)) {
+ if (BN_set_bit(e, i) == 0) {
+ BN_free(e);
+ RSA_free(rsa);
+ return 0;
+ }
+ }
+ }
+
+ memset(&cb_arg, 0, sizeof(struct ossl_generate_cb_arg));
+ if (rb_block_given_p())
+ cb_arg.yield = 1;
+ BN_GENCB_set(&cb, ossl_generate_cb_2, &cb_arg);
+ gen_arg.rsa = rsa;
+ gen_arg.e = e;
+ gen_arg.size = size;
+ gen_arg.cb = &cb;
+ if (cb_arg.yield == 1) {
+ /* we cannot release GVL when callback proc is supplied */
+ rsa_blocking_gen(&gen_arg);
+ } else {
+ /* there's a chance to unblock */
+ rb_thread_call_without_gvl(rsa_blocking_gen, &gen_arg, ossl_generate_cb_stop, &cb_arg);
+ }
+ if (!gen_arg.result) {
+ BN_free(e);
+ RSA_free(rsa);
+ if (cb_arg.state) rb_jump_tag(cb_arg.state);
+ return 0;
+ }
+
+ BN_free(e);
+ return rsa;
+#else
+ return RSA_generate_key(size, exp, rb_block_given_p() ? ossl_generate_cb : NULL, NULL);
+#endif
+}
+
+/*
+ * call-seq:
+ * RSA.generate(size) => RSA instance
+ * RSA.generate(size, exponent) => RSA instance
+ *
+ * Generates an RSA keypair. +size+ is an integer representing the desired key
+ * size. Keys smaller than 1024 should be considered insecure. +exponent+ is
+ * an odd number normally 3, 17, or 65537.
+ */
+static VALUE
+ossl_rsa_s_generate(int argc, VALUE *argv, VALUE klass)
+{
+/* why does this method exist? why can't initialize take an optional exponent? */
+ RSA *rsa;
+ VALUE size, exp;
+ VALUE obj;
+
+ rb_scan_args(argc, argv, "11", &size, &exp);
+
+ rsa = rsa_generate(NUM2INT(size), NIL_P(exp) ? RSA_F4 : NUM2ULONG(exp)); /* err handled by rsa_instance */
+ obj = rsa_instance(klass, rsa);
+
+ if (obj == Qfalse) {
+ RSA_free(rsa);
+ ossl_raise(eRSAError, NULL);
+ }
+
+ return obj;
+}
+
+/*
+ * call-seq:
+ * RSA.new(key_size) => RSA instance
+ * RSA.new(encoded_key) => RSA instance
+ * RSA.new(encoded_key, pass_phrase) => RSA instance
+ *
+ * Generates or loads an RSA keypair. If an integer +key_size+ is given it
+ * represents the desired key size. Keys less than 1024 bits should be
+ * considered insecure.
+ *
+ * A key can instead be loaded from an +encoded_key+ which must be PEM or DER
+ * encoded. A +pass_phrase+ can be used to decrypt the key. If none is given
+ * OpenSSL will prompt for the pass phrase.
+ *
+ * = Examples
+ *
+ * OpenSSL::PKey::RSA.new 2048
+ * OpenSSL::PKey::RSA.new File.read 'rsa.pem'
+ * OpenSSL::PKey::RSA.new File.read('rsa.pem'), 'my pass phrase'
+ */
+static VALUE
+ossl_rsa_initialize(int argc, VALUE *argv, VALUE self)
+{
+ EVP_PKEY *pkey;
+ RSA *rsa;
+ BIO *in;
+ char *passwd = NULL;
+ VALUE arg, pass;
+
+ GetPKey(self, pkey);
+ if(rb_scan_args(argc, argv, "02", &arg, &pass) == 0) {
+ rsa = RSA_new();
+ }
+ else if (FIXNUM_P(arg)) {
+ rsa = rsa_generate(FIX2INT(arg), NIL_P(pass) ? RSA_F4 : NUM2ULONG(pass));
+ if (!rsa) ossl_raise(eRSAError, NULL);
+ }
+ else {
+ if (!NIL_P(pass)) passwd = StringValuePtr(pass);
+ arg = ossl_to_der_if_possible(arg);
+ in = ossl_obj2bio(arg);
+ rsa = PEM_read_bio_RSAPrivateKey(in, NULL, ossl_pem_passwd_cb, passwd);
+ if (!rsa) {
+ OSSL_BIO_reset(in);
+ rsa = PEM_read_bio_RSA_PUBKEY(in, NULL, NULL, NULL);
+ }
+ if (!rsa) {
+ OSSL_BIO_reset(in);
+ rsa = d2i_RSAPrivateKey_bio(in, NULL);
+ }
+ if (!rsa) {
+ OSSL_BIO_reset(in);
+ rsa = d2i_RSA_PUBKEY_bio(in, NULL);
+ }
+ if (!rsa) {
+ OSSL_BIO_reset(in);
+ rsa = PEM_read_bio_RSAPublicKey(in, NULL, NULL, NULL);
+ }
+ if (!rsa) {
+ OSSL_BIO_reset(in);
+ rsa = d2i_RSAPublicKey_bio(in, NULL);
+ }
+ BIO_free(in);
+ if (!rsa) {
+ ossl_raise(eRSAError, "Neither PUB key nor PRIV key");
+ }
+ }
+ if (!EVP_PKEY_assign_RSA(pkey, rsa)) {
+ RSA_free(rsa);
+ ossl_raise(eRSAError, NULL);
+ }
+
+ return self;
+}
+
+/*
+ * call-seq:
+ * rsa.public? => true
+ *
+ * The return value is always true since every private key is also a public
+ * key.
+ */
+static VALUE
+ossl_rsa_is_public(VALUE self)
+{
+ EVP_PKEY *pkey;
+
+ GetPKeyRSA(self, pkey);
+ /*
+ * This method should check for n and e. BUG.
+ */
+ return Qtrue;
+}
+
+/*
+ * call-seq:
+ * rsa.private? => true | false
+ *
+ * Does this keypair contain a private key?
+ */
+static VALUE
+ossl_rsa_is_private(VALUE self)
+{
+ EVP_PKEY *pkey;
+
+ GetPKeyRSA(self, pkey);
+
+ return (RSA_PRIVATE(self, pkey->pkey.rsa)) ? Qtrue : Qfalse;
+}
+
+/*
+ * call-seq:
+ * rsa.export([cipher, pass_phrase]) => PEM-format String
+ * rsa.to_pem([cipher, pass_phrase]) => PEM-format String
+ * rsa.to_s([cipher, pass_phrase]) => PEM-format String
+ *
+ * Outputs this keypair in PEM encoding. If +cipher+ and +pass_phrase+ are
+ * given they will be used to encrypt the key. +cipher+ must be an
+ * OpenSSL::Cipher::Cipher instance.
+ */
+static VALUE
+ossl_rsa_export(int argc, VALUE *argv, VALUE self)
+{
+ EVP_PKEY *pkey;
+ BIO *out;
+ const EVP_CIPHER *ciph = NULL;
+ char *passwd = NULL;
+ VALUE cipher, pass, str;
+
+ GetPKeyRSA(self, pkey);
+
+ rb_scan_args(argc, argv, "02", &cipher, &pass);
+
+ if (!NIL_P(cipher)) {
+ ciph = GetCipherPtr(cipher);
+ if (!NIL_P(pass)) {
+ StringValue(pass);
+ if (RSTRING_LENINT(pass) < OSSL_MIN_PWD_LEN)
+ ossl_raise(eOSSLError, "OpenSSL requires passwords to be at least four characters long");
+ passwd = RSTRING_PTR(pass);
+ }
+ }
+ if (!(out = BIO_new(BIO_s_mem()))) {
+ ossl_raise(eRSAError, NULL);
+ }
+ if (RSA_HAS_PRIVATE(pkey->pkey.rsa)) {
+ if (!PEM_write_bio_RSAPrivateKey(out, pkey->pkey.rsa, ciph,
+ NULL, 0, ossl_pem_passwd_cb, passwd)) {
+ BIO_free(out);
+ ossl_raise(eRSAError, NULL);
+ }
+ } else {
+ if (!PEM_write_bio_RSA_PUBKEY(out, pkey->pkey.rsa)) {
+ BIO_free(out);
+ ossl_raise(eRSAError, NULL);
+ }
+ }
+ str = ossl_membio2str(out);
+
+ return str;
+}
+
+/*
+ * call-seq:
+ * rsa.to_der => DER-format String
+ *
+ * Outputs this keypair in DER encoding.
+ */
+static VALUE
+ossl_rsa_to_der(VALUE self)
+{
+ EVP_PKEY *pkey;
+ int (*i2d_func)_((const RSA*, unsigned char**));
+ unsigned char *p;
+ long len;
+ VALUE str;
+
+ GetPKeyRSA(self, pkey);
+ if(RSA_HAS_PRIVATE(pkey->pkey.rsa))
+ i2d_func = i2d_RSAPrivateKey;
+ else
+ i2d_func = (int (*)(const RSA*, unsigned char**))i2d_RSA_PUBKEY;
+ if((len = i2d_func(pkey->pkey.rsa, NULL)) <= 0)
+ ossl_raise(eRSAError, NULL);
+ str = rb_str_new(0, len);
+ p = (unsigned char *)RSTRING_PTR(str);
+ if(i2d_func(pkey->pkey.rsa, &p) < 0)
+ ossl_raise(eRSAError, NULL);
+ ossl_str_adjust(str, p);
+
+ return str;
+}
+
+#define ossl_rsa_buf_size(pkey) (RSA_size((pkey)->pkey.rsa)+16)
+
+/*
+ * call-seq:
+ * rsa.public_encrypt(string) => String
+ * rsa.public_encrypt(string, padding) => String
+ *
+ * Encrypt +string+ with the public key. +padding+ defaults to PKCS1_PADDING.
+ * The encrypted string output can be decrypted using #private_decrypt.
+ */
+static VALUE
+ossl_rsa_public_encrypt(int argc, VALUE *argv, VALUE self)
+{
+ EVP_PKEY *pkey;
+ int buf_len, pad;
+ VALUE str, buffer, padding;
+
+ GetPKeyRSA(self, pkey);
+ rb_scan_args(argc, argv, "11", &buffer, &padding);
+ pad = (argc == 1) ? RSA_PKCS1_PADDING : NUM2INT(padding);
+ StringValue(buffer);
+ str = rb_str_new(0, ossl_rsa_buf_size(pkey));
+ buf_len = RSA_public_encrypt(RSTRING_LENINT(buffer), (unsigned char *)RSTRING_PTR(buffer),
+ (unsigned char *)RSTRING_PTR(str), pkey->pkey.rsa,
+ pad);
+ if (buf_len < 0) ossl_raise(eRSAError, NULL);
+ rb_str_set_len(str, buf_len);
+
+ return str;
+}
+
+/*
+ * call-seq:
+ * rsa.public_decrypt(string) => String
+ * rsa.public_decrypt(string, padding) => String
+ *
+ * Decrypt +string+, which has been encrypted with the private key, with the
+ * public key. +padding+ defaults to PKCS1_PADDING.
+ */
+static VALUE
+ossl_rsa_public_decrypt(int argc, VALUE *argv, VALUE self)
+{
+ EVP_PKEY *pkey;
+ int buf_len, pad;
+ VALUE str, buffer, padding;
+
+ GetPKeyRSA(self, pkey);
+ rb_scan_args(argc, argv, "11", &buffer, &padding);
+ pad = (argc == 1) ? RSA_PKCS1_PADDING : NUM2INT(padding);
+ StringValue(buffer);
+ str = rb_str_new(0, ossl_rsa_buf_size(pkey));
+ buf_len = RSA_public_decrypt(RSTRING_LENINT(buffer), (unsigned char *)RSTRING_PTR(buffer),
+ (unsigned char *)RSTRING_PTR(str), pkey->pkey.rsa,
+ pad);
+ if (buf_len < 0) ossl_raise(eRSAError, NULL);
+ rb_str_set_len(str, buf_len);
+
+ return str;
+}
+
+/*
+ * call-seq:
+ * rsa.private_encrypt(string) => String
+ * rsa.private_encrypt(string, padding) => String
+ *
+ * Encrypt +string+ with the private key. +padding+ defaults to PKCS1_PADDING.
+ * The encrypted string output can be decrypted using #public_decrypt.
+ */
+static VALUE
+ossl_rsa_private_encrypt(int argc, VALUE *argv, VALUE self)
+{
+ EVP_PKEY *pkey;
+ int buf_len, pad;
+ VALUE str, buffer, padding;
+
+ GetPKeyRSA(self, pkey);
+ if (!RSA_PRIVATE(self, pkey->pkey.rsa)) {
+ ossl_raise(eRSAError, "private key needed.");
+ }
+ rb_scan_args(argc, argv, "11", &buffer, &padding);
+ pad = (argc == 1) ? RSA_PKCS1_PADDING : NUM2INT(padding);
+ StringValue(buffer);
+ str = rb_str_new(0, ossl_rsa_buf_size(pkey));
+ buf_len = RSA_private_encrypt(RSTRING_LENINT(buffer), (unsigned char *)RSTRING_PTR(buffer),
+ (unsigned char *)RSTRING_PTR(str), pkey->pkey.rsa,
+ pad);
+ if (buf_len < 0) ossl_raise(eRSAError, NULL);
+ rb_str_set_len(str, buf_len);
+
+ return str;
+}
+
+/*
+ * call-seq:
+ * rsa.private_decrypt(string) => String
+ * rsa.private_decrypt(string, padding) => String
+ *
+ * Decrypt +string+, which has been encrypted with the public key, with the
+ * private key. +padding+ defaults to PKCS1_PADDING.
+ */
+static VALUE
+ossl_rsa_private_decrypt(int argc, VALUE *argv, VALUE self)
+{
+ EVP_PKEY *pkey;
+ int buf_len, pad;
+ VALUE str, buffer, padding;
+
+ GetPKeyRSA(self, pkey);
+ if (!RSA_PRIVATE(self, pkey->pkey.rsa)) {
+ ossl_raise(eRSAError, "private key needed.");
+ }
+ rb_scan_args(argc, argv, "11", &buffer, &padding);
+ pad = (argc == 1) ? RSA_PKCS1_PADDING : NUM2INT(padding);
+ StringValue(buffer);
+ str = rb_str_new(0, ossl_rsa_buf_size(pkey));
+ buf_len = RSA_private_decrypt(RSTRING_LENINT(buffer), (unsigned char *)RSTRING_PTR(buffer),
+ (unsigned char *)RSTRING_PTR(str), pkey->pkey.rsa,
+ pad);
+ if (buf_len < 0) ossl_raise(eRSAError, NULL);
+ rb_str_set_len(str, buf_len);
+
+ return str;
+}
+
+/*
+ * call-seq:
+ * rsa.params => hash
+ *
+ * THIS METHOD IS INSECURE, PRIVATE INFORMATION CAN LEAK OUT!!!
+ *
+ * Stores all parameters of key to the hash. The hash has keys 'n', 'e', 'd',
+ * 'p', 'q', 'dmp1', 'dmq1', 'iqmp'.
+ *
+ * Don't use :-)) (It's up to you)
+ */
+static VALUE
+ossl_rsa_get_params(VALUE self)
+{
+ EVP_PKEY *pkey;
+ VALUE hash;
+
+ GetPKeyRSA(self, pkey);
+
+ hash = rb_hash_new();
+
+ rb_hash_aset(hash, rb_str_new2("n"), ossl_bn_new(pkey->pkey.rsa->n));
+ rb_hash_aset(hash, rb_str_new2("e"), ossl_bn_new(pkey->pkey.rsa->e));
+ rb_hash_aset(hash, rb_str_new2("d"), ossl_bn_new(pkey->pkey.rsa->d));
+ rb_hash_aset(hash, rb_str_new2("p"), ossl_bn_new(pkey->pkey.rsa->p));
+ rb_hash_aset(hash, rb_str_new2("q"), ossl_bn_new(pkey->pkey.rsa->q));
+ rb_hash_aset(hash, rb_str_new2("dmp1"), ossl_bn_new(pkey->pkey.rsa->dmp1));
+ rb_hash_aset(hash, rb_str_new2("dmq1"), ossl_bn_new(pkey->pkey.rsa->dmq1));
+ rb_hash_aset(hash, rb_str_new2("iqmp"), ossl_bn_new(pkey->pkey.rsa->iqmp));
+
+ return hash;
+}
+
+/*
+ * call-seq:
+ * rsa.to_text => String
+ *
+ * THIS METHOD IS INSECURE, PRIVATE INFORMATION CAN LEAK OUT!!!
+ *
+ * Dumps all parameters of a keypair to a String
+ *
+ * Don't use :-)) (It's up to you)
+ */
+static VALUE
+ossl_rsa_to_text(VALUE self)
+{
+ EVP_PKEY *pkey;
+ BIO *out;
+ VALUE str;
+
+ GetPKeyRSA(self, pkey);
+ if (!(out = BIO_new(BIO_s_mem()))) {
+ ossl_raise(eRSAError, NULL);
+ }
+ if (!RSA_print(out, pkey->pkey.rsa, 0)) { /* offset = 0 */
+ BIO_free(out);
+ ossl_raise(eRSAError, NULL);
+ }
+ str = ossl_membio2str(out);
+
+ return str;
+}
+
+/*
+ * call-seq:
+ * rsa.public_key -> RSA
+ *
+ * Makes new RSA instance containing the public key from the private key.
+ */
+static VALUE
+ossl_rsa_to_public_key(VALUE self)
+{
+ EVP_PKEY *pkey;
+ RSA *rsa;
+ VALUE obj;
+
+ GetPKeyRSA(self, pkey);
+ /* err check performed by rsa_instance */
+ rsa = RSAPublicKey_dup(pkey->pkey.rsa);
+ obj = rsa_instance(CLASS_OF(self), rsa);
+ if (obj == Qfalse) {
+ RSA_free(rsa);
+ ossl_raise(eRSAError, NULL);
+ }
+ return obj;
+}
+
+/*
+ * TODO: Test me
+
+static VALUE
+ossl_rsa_blinding_on(VALUE self)
+{
+ EVP_PKEY *pkey;
+
+ GetPKeyRSA(self, pkey);
+
+ if (RSA_blinding_on(pkey->pkey.rsa, ossl_bn_ctx) != 1) {
+ ossl_raise(eRSAError, NULL);
+ }
+ return self;
+}
+
+static VALUE
+ossl_rsa_blinding_off(VALUE self)
+{
+ EVP_PKEY *pkey;
+
+ GetPKeyRSA(self, pkey);
+ RSA_blinding_off(pkey->pkey.rsa);
+
+ return self;
+}
+ */
+
+OSSL_PKEY_BN(rsa, n)
+OSSL_PKEY_BN(rsa, e)
+OSSL_PKEY_BN(rsa, d)
+OSSL_PKEY_BN(rsa, p)
+OSSL_PKEY_BN(rsa, q)
+OSSL_PKEY_BN(rsa, dmp1)
+OSSL_PKEY_BN(rsa, dmq1)
+OSSL_PKEY_BN(rsa, iqmp)
+
+/*
+ * INIT
+ */
+#define DefRSAConst(x) rb_define_const(cRSA, #x,INT2FIX(RSA_##x))
+
+void
+Init_ossl_rsa(void)
+{
+#if 0
+ mOSSL = rb_define_module("OpenSSL"); /* let rdoc know about mOSSL and mPKey */
+ mPKey = rb_define_module_under(mOSSL, "PKey");
+#endif
+
+ /* Document-class: OpenSSL::PKey::RSAError
+ *
+ * Generic exception that is raised if an operation on an RSA PKey
+ * fails unexpectedly or in case an instantiation of an instance of RSA
+ * fails due to non-conformant input data.
+ */
+ eRSAError = rb_define_class_under(mPKey, "RSAError", ePKeyError);
+
+ /* Document-class: OpenSSL::PKey::RSA
+ *
+ * RSA is an asymmetric public key algorithm that has been formalized in
+ * RFC 3447. It is in widespread use in public key infrastuctures (PKI)
+ * where certificates (cf. OpenSSL::X509::Certificate) often are issued
+ * on the basis of a public/private RSA key pair. RSA is used in a wide
+ * field of applications such as secure (symmetric) key exchange, e.g.
+ * when establishing a secure TLS/SSL connection. It is also used in
+ * various digital signature schemes.
+ */
+ cRSA = rb_define_class_under(mPKey, "RSA", cPKey);
+
+ rb_define_singleton_method(cRSA, "generate", ossl_rsa_s_generate, -1);
+ rb_define_method(cRSA, "initialize", ossl_rsa_initialize, -1);
+
+ rb_define_method(cRSA, "public?", ossl_rsa_is_public, 0);
+ rb_define_method(cRSA, "private?", ossl_rsa_is_private, 0);
+ rb_define_method(cRSA, "to_text", ossl_rsa_to_text, 0);
+ rb_define_method(cRSA, "export", ossl_rsa_export, -1);
+ rb_define_alias(cRSA, "to_pem", "export");
+ rb_define_alias(cRSA, "to_s", "export");
+ rb_define_method(cRSA, "to_der", ossl_rsa_to_der, 0);
+ rb_define_method(cRSA, "public_key", ossl_rsa_to_public_key, 0);
+ rb_define_method(cRSA, "public_encrypt", ossl_rsa_public_encrypt, -1);
+ rb_define_method(cRSA, "public_decrypt", ossl_rsa_public_decrypt, -1);
+ rb_define_method(cRSA, "private_encrypt", ossl_rsa_private_encrypt, -1);
+ rb_define_method(cRSA, "private_decrypt", ossl_rsa_private_decrypt, -1);
+
+ DEF_OSSL_PKEY_BN(cRSA, rsa, n);
+ DEF_OSSL_PKEY_BN(cRSA, rsa, e);
+ DEF_OSSL_PKEY_BN(cRSA, rsa, d);
+ DEF_OSSL_PKEY_BN(cRSA, rsa, p);
+ DEF_OSSL_PKEY_BN(cRSA, rsa, q);
+ DEF_OSSL_PKEY_BN(cRSA, rsa, dmp1);
+ DEF_OSSL_PKEY_BN(cRSA, rsa, dmq1);
+ DEF_OSSL_PKEY_BN(cRSA, rsa, iqmp);
+
+ rb_define_method(cRSA, "params", ossl_rsa_get_params, 0);
+
+ DefRSAConst(PKCS1_PADDING);
+ DefRSAConst(SSLV23_PADDING);
+ DefRSAConst(NO_PADDING);
+ DefRSAConst(PKCS1_OAEP_PADDING);
+
+/*
+ * TODO: Test it
+ rb_define_method(cRSA, "blinding_on!", ossl_rsa_blinding_on, 0);
+ rb_define_method(cRSA, "blinding_off!", ossl_rsa_blinding_off, 0);
+ */
+}
+
+#else /* defined NO_RSA */
+void
+Init_ossl_rsa(void)
+{
+}
+#endif /* NO_RSA */
+
diff --git a/jni/ruby/ext/openssl/ossl_rand.c b/jni/ruby/ext/openssl/ossl_rand.c
new file mode 100644
index 0000000..e12b0c0
--- /dev/null
+++ b/jni/ruby/ext/openssl/ossl_rand.c
@@ -0,0 +1,226 @@
+/*
+ * $Id: ossl_rand.c 47782 2014-10-04 00:01:07Z zzak $
+ * 'OpenSSL for Ruby' project
+ * Copyright (C) 2001-2002 Michal Rokos <m.rokos@sh.cvut.cz>
+ *
+ * All rights reserved.
+ *
+ * This program is licenced under the same licence as Ruby.
+ * (See the file 'LICENCE'.)
+ */
+#include "ossl.h"
+
+VALUE mRandom;
+VALUE eRandomError;
+
+/*
+ * call-seq:
+ * seed(str) -> str
+ *
+ * ::seed is equivalent to ::add where +entropy+ is length of +str+.
+ */
+static VALUE
+ossl_rand_seed(VALUE self, VALUE str)
+{
+ StringValue(str);
+ RAND_seed(RSTRING_PTR(str), RSTRING_LENINT(str));
+
+ return str;
+}
+
+/*
+ * call-seq:
+ * add(str, entropy) -> self
+ *
+ * Mixes the bytes from +str+ into the Pseudo Random Number Generator(PRNG)
+ * state.
+ *
+ * Thus, if the data from +str+ are unpredictable to an adversary, this
+ * increases the uncertainty about the state and makes the PRNG output less
+ * predictable.
+ *
+ * The +entropy+ argument is (the lower bound of) an estimate of how much
+ * randomness is contained in +str+, measured in bytes.
+ *
+ * Example:
+ *
+ * pid = $$
+ * now = Time.now
+ * ary = [now.to_i, now.nsec, 1000, pid]
+ * OpenSSL::Random.add(ary.join("").to_s, 0.0)
+ * OpenSSL::Random.seed(ary.join("").to_s)
+ */
+static VALUE
+ossl_rand_add(VALUE self, VALUE str, VALUE entropy)
+{
+ StringValue(str);
+ RAND_add(RSTRING_PTR(str), RSTRING_LENINT(str), NUM2DBL(entropy));
+
+ return self;
+}
+
+/*
+ * call-seq:
+ * load_random_file(filename) -> true
+ *
+ * Reads bytes from +filename+ and adds them to the PRNG.
+ */
+static VALUE
+ossl_rand_load_file(VALUE self, VALUE filename)
+{
+ SafeStringValue(filename);
+
+ if(!RAND_load_file(RSTRING_PTR(filename), -1)) {
+ ossl_raise(eRandomError, NULL);
+ }
+ return Qtrue;
+}
+
+/*
+ * call-seq:
+ * write_random_file(filename) -> true
+ *
+ * Writes a number of random generated bytes (currently 1024) to +filename+
+ * which can be used to initialize the PRNG by calling ::load_random_file in a
+ * later session.
+ */
+static VALUE
+ossl_rand_write_file(VALUE self, VALUE filename)
+{
+ SafeStringValue(filename);
+ if (RAND_write_file(RSTRING_PTR(filename)) == -1) {
+ ossl_raise(eRandomError, NULL);
+ }
+ return Qtrue;
+}
+
+/*
+ * call-seq:
+ * random_bytes(length) -> string
+ *
+ * Generates +string+ with +length+ number of cryptographically strong
+ * pseudo-random bytes.
+ *
+ * Example:
+ *
+ * OpenSSL::Random.random_bytes(12)
+ * => "..."
+ */
+static VALUE
+ossl_rand_bytes(VALUE self, VALUE len)
+{
+ VALUE str;
+ int n = NUM2INT(len);
+
+ str = rb_str_new(0, n);
+ if (!RAND_bytes((unsigned char *)RSTRING_PTR(str), n)) {
+ ossl_raise(eRandomError, NULL);
+ }
+
+ return str;
+}
+
+/*
+ * call-seq:
+ * pseudo_bytes(length) -> string
+ *
+ * Generates +string+ with +length+ number of pseudo-random bytes.
+ *
+ * Pseudo-random byte sequences generated by ::pseudo_bytes will be unique if
+ * they are of sufficient length, but are not necessarily unpredictable.
+ *
+ * Example:
+ *
+ * OpenSSL::Random.pseudo_bytes(12)
+ * => "..."
+ */
+static VALUE
+ossl_rand_pseudo_bytes(VALUE self, VALUE len)
+{
+ VALUE str;
+ int n = NUM2INT(len);
+
+ str = rb_str_new(0, n);
+ if (!RAND_pseudo_bytes((unsigned char *)RSTRING_PTR(str), n)) {
+ ossl_raise(eRandomError, NULL);
+ }
+
+ return str;
+}
+
+/*
+ * call-seq:
+ * egd(filename) -> true
+ *
+ * Same as ::egd_bytes but queries 255 bytes by default.
+ */
+static VALUE
+ossl_rand_egd(VALUE self, VALUE filename)
+{
+ SafeStringValue(filename);
+
+ if(!RAND_egd(RSTRING_PTR(filename))) {
+ ossl_raise(eRandomError, NULL);
+ }
+ return Qtrue;
+}
+
+/*
+ * call-seq:
+ * egd_bytes(filename, length) -> true
+ *
+ * Queries the entropy gathering daemon EGD on socket path given by +filename+.
+ *
+ * Fetches +length+ number of bytes and uses ::add to seed the OpenSSL built-in
+ * PRNG.
+ */
+static VALUE
+ossl_rand_egd_bytes(VALUE self, VALUE filename, VALUE len)
+{
+ int n = NUM2INT(len);
+
+ SafeStringValue(filename);
+
+ if (!RAND_egd_bytes(RSTRING_PTR(filename), n)) {
+ ossl_raise(eRandomError, NULL);
+ }
+ return Qtrue;
+}
+
+/*
+ * call-seq:
+ * status? => true | false
+ *
+ * Return true if the PRNG has been seeded with enough data, false otherwise.
+ */
+static VALUE
+ossl_rand_status(VALUE self)
+{
+ return RAND_status() ? Qtrue : Qfalse;
+}
+
+/*
+ * INIT
+ */
+void
+Init_ossl_rand(void)
+{
+#if 0
+ mOSSL = rb_define_module("OpenSSL"); /* let rdoc know about mOSSL */
+#endif
+
+ mRandom = rb_define_module_under(mOSSL, "Random");
+
+ eRandomError = rb_define_class_under(mRandom, "RandomError", eOSSLError);
+
+ rb_define_module_function(mRandom, "seed", ossl_rand_seed, 1);
+ rb_define_module_function(mRandom, "random_add", ossl_rand_add, 2);
+ rb_define_module_function(mRandom, "load_random_file", ossl_rand_load_file, 1);
+ rb_define_module_function(mRandom, "write_random_file", ossl_rand_write_file, 1);
+ rb_define_module_function(mRandom, "random_bytes", ossl_rand_bytes, 1);
+ rb_define_module_function(mRandom, "pseudo_bytes", ossl_rand_pseudo_bytes, 1);
+ rb_define_module_function(mRandom, "egd", ossl_rand_egd, 1);
+ rb_define_module_function(mRandom, "egd_bytes", ossl_rand_egd_bytes, 2);
+ rb_define_module_function(mRandom, "status?", ossl_rand_status, 0);
+}
+
diff --git a/jni/ruby/ext/openssl/ossl_rand.h b/jni/ruby/ext/openssl/ossl_rand.h
new file mode 100644
index 0000000..e9f5bc9
--- /dev/null
+++ b/jni/ruby/ext/openssl/ossl_rand.h
@@ -0,0 +1,20 @@
+/*
+ * $Id: ossl_rand.h 25189 2009-10-02 12:04:37Z akr $
+ * 'OpenSSL for Ruby' project
+ * Copyright (C) 2001-2002 Michal Rokos <m.rokos@sh.cvut.cz>
+ * All rights reserved.
+ */
+/*
+ * This program is licenced under the same licence as Ruby.
+ * (See the file 'LICENCE'.)
+ */
+#if !defined(_OSSL_RAND_H_)
+#define _OSSL_RAND_H_
+
+extern VALUE mRandom;
+extern VALUE eRandomError;
+
+void Init_ossl_rand(void);
+
+#endif /* _OSSL_RAND_H_ */
+
diff --git a/jni/ruby/ext/openssl/ossl_ssl.c b/jni/ruby/ext/openssl/ossl_ssl.c
new file mode 100644
index 0000000..912e6e9
--- /dev/null
+++ b/jni/ruby/ext/openssl/ossl_ssl.c
@@ -0,0 +1,2302 @@
+/*
+ * $Id: ossl_ssl.c 48801 2014-12-12 21:58:34Z nobu $
+ * 'OpenSSL for Ruby' project
+ * Copyright (C) 2000-2002 GOTOU Yuuzou <gotoyuzo@notwork.org>
+ * Copyright (C) 2001-2002 Michal Rokos <m.rokos@sh.cvut.cz>
+ * Copyright (C) 2001-2007 Technorama Ltd. <oss-ruby@technorama.net>
+ * All rights reserved.
+ */
+/*
+ * This program is licenced under the same licence as Ruby.
+ * (See the file 'LICENCE'.)
+ */
+#include "ossl.h"
+
+#if defined(HAVE_UNISTD_H)
+# include <unistd.h> /* for read(), and write() */
+#endif
+
+#define numberof(ary) (int)(sizeof(ary)/sizeof((ary)[0]))
+
+#ifdef _WIN32
+# define TO_SOCKET(s) _get_osfhandle(s)
+#else
+# define TO_SOCKET(s) (s)
+#endif
+
+#define GetSSLCTX(obj, ctx) do { \
+ TypedData_Get_Struct((obj), SSL_CTX, &ossl_sslctx_type, (ctx)); \
+} while (0)
+
+VALUE mSSL;
+VALUE eSSLError;
+VALUE cSSLContext;
+VALUE cSSLSocket;
+
+static VALUE eSSLErrorWaitReadable;
+static VALUE eSSLErrorWaitWritable;
+
+#define ossl_sslctx_set_cert(o,v) rb_iv_set((o),"@cert",(v))
+#define ossl_sslctx_set_key(o,v) rb_iv_set((o),"@key",(v))
+#define ossl_sslctx_set_client_ca(o,v) rb_iv_set((o),"@client_ca",(v))
+#define ossl_sslctx_set_ca_file(o,v) rb_iv_set((o),"@ca_file",(v))
+#define ossl_sslctx_set_ca_path(o,v) rb_iv_set((o),"@ca_path",(v))
+#define ossl_sslctx_set_timeout(o,v) rb_iv_set((o),"@timeout",(v))
+#define ossl_sslctx_set_verify_mode(o,v) rb_iv_set((o),"@verify_mode",(v))
+#define ossl_sslctx_set_verify_dep(o,v) rb_iv_set((o),"@verify_depth",(v))
+#define ossl_sslctx_set_verify_cb(o,v) rb_iv_set((o),"@verify_callback",(v))
+#define ossl_sslctx_set_options(o,v) rb_iv_set((o),"@options",(v))
+#define ossl_sslctx_set_cert_store(o,v) rb_iv_set((o),"@cert_store",(v))
+#define ossl_sslctx_set_extra_cert(o,v) rb_iv_set((o),"@extra_chain_cert",(v))
+#define ossl_sslctx_set_client_cert_cb(o,v) rb_iv_set((o),"@client_cert_cb",(v))
+#define ossl_sslctx_set_tmp_dh_cb(o,v) rb_iv_set((o),"@tmp_dh_callback",(v))
+#define ossl_sslctx_set_sess_id_ctx(o, v) rb_iv_set((o),"@session_id_context",(v))
+
+#define ossl_sslctx_get_cert(o) rb_iv_get((o),"@cert")
+#define ossl_sslctx_get_key(o) rb_iv_get((o),"@key")
+#define ossl_sslctx_get_client_ca(o) rb_iv_get((o),"@client_ca")
+#define ossl_sslctx_get_ca_file(o) rb_iv_get((o),"@ca_file")
+#define ossl_sslctx_get_ca_path(o) rb_iv_get((o),"@ca_path")
+#define ossl_sslctx_get_timeout(o) rb_iv_get((o),"@timeout")
+#define ossl_sslctx_get_verify_mode(o) rb_iv_get((o),"@verify_mode")
+#define ossl_sslctx_get_verify_dep(o) rb_iv_get((o),"@verify_depth")
+#define ossl_sslctx_get_verify_cb(o) rb_iv_get((o),"@verify_callback")
+#define ossl_sslctx_get_options(o) rb_iv_get((o),"@options")
+#define ossl_sslctx_get_cert_store(o) rb_iv_get((o),"@cert_store")
+#define ossl_sslctx_get_extra_cert(o) rb_iv_get((o),"@extra_chain_cert")
+#define ossl_sslctx_get_client_cert_cb(o) rb_iv_get((o),"@client_cert_cb")
+#define ossl_sslctx_get_tmp_dh_cb(o) rb_iv_get((o),"@tmp_dh_callback")
+#define ossl_sslctx_get_sess_id_ctx(o) rb_iv_get((o),"@session_id_context")
+
+static const char *ossl_sslctx_attrs[] = {
+ "cert", "key", "client_ca", "ca_file", "ca_path",
+ "timeout", "verify_mode", "verify_depth", "renegotiation_cb",
+ "verify_callback", "options", "cert_store", "extra_chain_cert",
+ "client_cert_cb", "tmp_dh_callback", "session_id_context",
+ "session_get_cb", "session_new_cb", "session_remove_cb",
+#ifdef HAVE_SSL_SET_TLSEXT_HOST_NAME
+ "servername_cb",
+#endif
+#ifdef HAVE_OPENSSL_NPN_NEGOTIATED
+ "npn_protocols",
+ "npn_select_cb",
+#endif
+};
+
+#define ossl_ssl_get_io(o) rb_iv_get((o),"@io")
+#define ossl_ssl_get_ctx(o) rb_iv_get((o),"@context")
+#define ossl_ssl_get_sync_close(o) rb_iv_get((o),"@sync_close")
+#define ossl_ssl_get_x509(o) rb_iv_get((o),"@x509")
+#define ossl_ssl_get_key(o) rb_iv_get((o),"@key")
+#define ossl_ssl_get_tmp_dh(o) rb_iv_get((o),"@tmp_dh")
+
+#define ossl_ssl_set_io(o,v) rb_iv_set((o),"@io",(v))
+#define ossl_ssl_set_ctx(o,v) rb_iv_set((o),"@context",(v))
+#define ossl_ssl_set_sync_close(o,v) rb_iv_set((o),"@sync_close",(v))
+#define ossl_ssl_set_x509(o,v) rb_iv_set((o),"@x509",(v))
+#define ossl_ssl_set_key(o,v) rb_iv_set((o),"@key",(v))
+#define ossl_ssl_set_tmp_dh(o,v) rb_iv_set((o),"@tmp_dh",(v))
+
+static const char *ossl_ssl_attr_readers[] = { "io", "context", };
+static const char *ossl_ssl_attrs[] = {
+#ifdef HAVE_SSL_SET_TLSEXT_HOST_NAME
+ "hostname",
+#endif
+ "sync_close",
+};
+
+ID ID_callback_state;
+
+static VALUE sym_exception;
+
+/*
+ * SSLContext class
+ */
+static const struct {
+ const char *name;
+ SSL_METHOD *(*func)(void);
+} ossl_ssl_method_tab[] = {
+#define OSSL_SSL_METHOD_ENTRY(name) { #name, (SSL_METHOD *(*)(void))name##_method }
+ OSSL_SSL_METHOD_ENTRY(TLSv1),
+ OSSL_SSL_METHOD_ENTRY(TLSv1_server),
+ OSSL_SSL_METHOD_ENTRY(TLSv1_client),
+#if defined(HAVE_TLSV1_2_METHOD) && defined(HAVE_TLSV1_2_SERVER_METHOD) && \
+ defined(HAVE_TLSV1_2_CLIENT_METHOD)
+ OSSL_SSL_METHOD_ENTRY(TLSv1_2),
+ OSSL_SSL_METHOD_ENTRY(TLSv1_2_server),
+ OSSL_SSL_METHOD_ENTRY(TLSv1_2_client),
+#endif
+#if defined(HAVE_TLSV1_1_METHOD) && defined(HAVE_TLSV1_1_SERVER_METHOD) && \
+ defined(HAVE_TLSV1_1_CLIENT_METHOD)
+ OSSL_SSL_METHOD_ENTRY(TLSv1_1),
+ OSSL_SSL_METHOD_ENTRY(TLSv1_1_server),
+ OSSL_SSL_METHOD_ENTRY(TLSv1_1_client),
+#endif
+#if defined(HAVE_SSLV2_METHOD) && defined(HAVE_SSLV2_SERVER_METHOD) && \
+ defined(HAVE_SSLV2_CLIENT_METHOD)
+ OSSL_SSL_METHOD_ENTRY(SSLv2),
+ OSSL_SSL_METHOD_ENTRY(SSLv2_server),
+ OSSL_SSL_METHOD_ENTRY(SSLv2_client),
+#endif
+ OSSL_SSL_METHOD_ENTRY(SSLv3),
+ OSSL_SSL_METHOD_ENTRY(SSLv3_server),
+ OSSL_SSL_METHOD_ENTRY(SSLv3_client),
+ OSSL_SSL_METHOD_ENTRY(SSLv23),
+ OSSL_SSL_METHOD_ENTRY(SSLv23_server),
+ OSSL_SSL_METHOD_ENTRY(SSLv23_client),
+#undef OSSL_SSL_METHOD_ENTRY
+};
+
+int ossl_ssl_ex_vcb_idx;
+int ossl_ssl_ex_store_p;
+int ossl_ssl_ex_ptr_idx;
+int ossl_ssl_ex_client_cert_cb_idx;
+int ossl_ssl_ex_tmp_dh_callback_idx;
+
+static void
+ossl_sslctx_free(void *ptr)
+{
+ SSL_CTX *ctx = ptr;
+ if(ctx && SSL_CTX_get_ex_data(ctx, ossl_ssl_ex_store_p)== (void*)1)
+ ctx->cert_store = NULL;
+ SSL_CTX_free(ctx);
+}
+
+static const rb_data_type_t ossl_sslctx_type = {
+ "OpenSSL/SSL/CTX",
+ {
+ 0, ossl_sslctx_free,
+ },
+ 0, 0, RUBY_TYPED_FREE_IMMEDIATELY,
+};
+
+static VALUE
+ossl_sslctx_s_alloc(VALUE klass)
+{
+ SSL_CTX *ctx;
+ long mode = SSL_MODE_ENABLE_PARTIAL_WRITE;
+
+#ifdef SSL_MODE_RELEASE_BUFFERS
+ mode |= SSL_MODE_RELEASE_BUFFERS;
+#endif
+
+ ctx = SSL_CTX_new(SSLv23_method());
+ if (!ctx) {
+ ossl_raise(eSSLError, "SSL_CTX_new");
+ }
+ SSL_CTX_set_mode(ctx, mode);
+ return TypedData_Wrap_Struct(klass, &ossl_sslctx_type, ctx);
+}
+
+/*
+ * call-seq:
+ * ctx.ssl_version = :TLSv1
+ * ctx.ssl_version = "SSLv23_client"
+ *
+ * You can get a list of valid versions with OpenSSL::SSL::SSLContext::METHODS
+ */
+static VALUE
+ossl_sslctx_set_ssl_version(VALUE self, VALUE ssl_method)
+{
+ SSL_METHOD *method = NULL;
+ const char *s;
+ int i;
+
+ SSL_CTX *ctx;
+ if (RB_TYPE_P(ssl_method, T_SYMBOL))
+ s = rb_id2name(SYM2ID(ssl_method));
+ else
+ s = StringValuePtr(ssl_method);
+ for (i = 0; i < numberof(ossl_ssl_method_tab); i++) {
+ if (strcmp(ossl_ssl_method_tab[i].name, s) == 0) {
+ method = ossl_ssl_method_tab[i].func();
+ break;
+ }
+ }
+ if (!method) {
+ ossl_raise(rb_eArgError, "unknown SSL method `%s'.", s);
+ }
+ GetSSLCTX(self, ctx);
+ if (SSL_CTX_set_ssl_version(ctx, method) != 1) {
+ ossl_raise(eSSLError, "SSL_CTX_set_ssl_version");
+ }
+
+ return ssl_method;
+}
+
+/*
+ * call-seq:
+ * SSLContext.new => ctx
+ * SSLContext.new(:TLSv1) => ctx
+ * SSLContext.new("SSLv23_client") => ctx
+ *
+ * You can get a list of valid methods with OpenSSL::SSL::SSLContext::METHODS
+ */
+static VALUE
+ossl_sslctx_initialize(int argc, VALUE *argv, VALUE self)
+{
+ VALUE ssl_method;
+ int i;
+
+ for(i = 0; i < numberof(ossl_sslctx_attrs); i++){
+ char buf[32];
+ snprintf(buf, sizeof(buf), "@%s", ossl_sslctx_attrs[i]);
+ rb_iv_set(self, buf, Qnil);
+ }
+ if (rb_scan_args(argc, argv, "01", &ssl_method) == 0){
+ return self;
+ }
+ ossl_sslctx_set_ssl_version(self, ssl_method);
+
+ return self;
+}
+
+static VALUE
+ossl_call_client_cert_cb(VALUE obj)
+{
+ VALUE cb, ary, cert, key;
+ SSL *ssl;
+
+ GetSSL(obj, ssl);
+ cb = (VALUE)SSL_get_ex_data(ssl, ossl_ssl_ex_client_cert_cb_idx);
+ if (NIL_P(cb)) return Qfalse;
+ ary = rb_funcall(cb, rb_intern("call"), 1, obj);
+ Check_Type(ary, T_ARRAY);
+ GetX509CertPtr(cert = rb_ary_entry(ary, 0));
+ GetPKeyPtr(key = rb_ary_entry(ary, 1));
+ ossl_ssl_set_x509(obj, cert);
+ ossl_ssl_set_key(obj, key);
+
+ return Qtrue;
+}
+
+static int
+ossl_client_cert_cb(SSL *ssl, X509 **x509, EVP_PKEY **pkey)
+{
+ VALUE obj, success;
+
+ obj = (VALUE)SSL_get_ex_data(ssl, ossl_ssl_ex_ptr_idx);
+ success = rb_protect((VALUE(*)_((VALUE)))ossl_call_client_cert_cb,
+ obj, NULL);
+ if (!RTEST(success)) return 0;
+ *x509 = DupX509CertPtr(ossl_ssl_get_x509(obj));
+ *pkey = DupPKeyPtr(ossl_ssl_get_key(obj));
+
+ return 1;
+}
+
+#if !defined(OPENSSL_NO_DH)
+static VALUE
+ossl_call_tmp_dh_callback(VALUE *args)
+{
+ SSL *ssl;
+ VALUE cb, dh;
+ EVP_PKEY *pkey;
+
+ GetSSL(args[0], ssl);
+ cb = (VALUE)SSL_get_ex_data(ssl, ossl_ssl_ex_tmp_dh_callback_idx);
+ if (NIL_P(cb)) return Qfalse;
+ dh = rb_funcall(cb, rb_intern("call"), 3, args[0], args[1], args[2]);
+ pkey = GetPKeyPtr(dh);
+ if (EVP_PKEY_type(pkey->type) != EVP_PKEY_DH) return Qfalse;
+ ossl_ssl_set_tmp_dh(args[0], dh);
+
+ return Qtrue;
+}
+
+static DH*
+ossl_tmp_dh_callback(SSL *ssl, int is_export, int keylength)
+{
+ VALUE args[3], success;
+
+ args[0] = (VALUE)SSL_get_ex_data(ssl, ossl_ssl_ex_ptr_idx);
+ args[1] = INT2FIX(is_export);
+ args[2] = INT2FIX(keylength);
+ success = rb_protect((VALUE(*)_((VALUE)))ossl_call_tmp_dh_callback,
+ (VALUE)args, NULL);
+ if (!RTEST(success)) return NULL;
+
+ return GetPKeyPtr(ossl_ssl_get_tmp_dh(args[0]))->pkey.dh;
+}
+
+static DH*
+ossl_default_tmp_dh_callback(SSL *ssl, int is_export, int keylength)
+{
+ rb_warning("using default DH parameters.");
+
+ switch(keylength){
+ case 512:
+ return OSSL_DEFAULT_DH_512;
+ case 1024:
+ return OSSL_DEFAULT_DH_1024;
+ }
+ return NULL;
+}
+#endif /* OPENSSL_NO_DH */
+
+static int
+ossl_ssl_verify_callback(int preverify_ok, X509_STORE_CTX *ctx)
+{
+ VALUE cb;
+ SSL *ssl;
+
+ ssl = X509_STORE_CTX_get_ex_data(ctx, SSL_get_ex_data_X509_STORE_CTX_idx());
+ cb = (VALUE)SSL_get_ex_data(ssl, ossl_ssl_ex_vcb_idx);
+ X509_STORE_CTX_set_ex_data(ctx, ossl_verify_cb_idx, (void*)cb);
+ return ossl_verify_cb(preverify_ok, ctx);
+}
+
+static VALUE
+ossl_call_session_get_cb(VALUE ary)
+{
+ VALUE ssl_obj, sslctx_obj, cb;
+
+ Check_Type(ary, T_ARRAY);
+ ssl_obj = rb_ary_entry(ary, 0);
+
+ sslctx_obj = rb_iv_get(ssl_obj, "@context");
+ if (NIL_P(sslctx_obj)) return Qnil;
+ cb = rb_iv_get(sslctx_obj, "@session_get_cb");
+ if (NIL_P(cb)) return Qnil;
+
+ return rb_funcall(cb, rb_intern("call"), 1, ary);
+}
+
+/* this method is currently only called for servers (in OpenSSL <= 0.9.8e) */
+static SSL_SESSION *
+ossl_sslctx_session_get_cb(SSL *ssl, unsigned char *buf, int len, int *copy)
+{
+ VALUE ary, ssl_obj, ret_obj;
+ SSL_SESSION *sess;
+ void *ptr;
+ int state = 0;
+
+ OSSL_Debug("SSL SESSION get callback entered");
+ if ((ptr = SSL_get_ex_data(ssl, ossl_ssl_ex_ptr_idx)) == NULL)
+ return NULL;
+ ssl_obj = (VALUE)ptr;
+ ary = rb_ary_new2(2);
+ rb_ary_push(ary, ssl_obj);
+ rb_ary_push(ary, rb_str_new((const char *)buf, len));
+
+ ret_obj = rb_protect((VALUE(*)_((VALUE)))ossl_call_session_get_cb, ary, &state);
+ if (state) {
+ rb_ivar_set(ssl_obj, ID_callback_state, INT2NUM(state));
+ return NULL;
+ }
+ if (!rb_obj_is_instance_of(ret_obj, cSSLSession))
+ return NULL;
+
+ SafeGetSSLSession(ret_obj, sess);
+ *copy = 1;
+
+ return sess;
+}
+
+static VALUE
+ossl_call_session_new_cb(VALUE ary)
+{
+ VALUE ssl_obj, sslctx_obj, cb;
+
+ Check_Type(ary, T_ARRAY);
+ ssl_obj = rb_ary_entry(ary, 0);
+
+ sslctx_obj = rb_iv_get(ssl_obj, "@context");
+ if (NIL_P(sslctx_obj)) return Qnil;
+ cb = rb_iv_get(sslctx_obj, "@session_new_cb");
+ if (NIL_P(cb)) return Qnil;
+
+ return rb_funcall(cb, rb_intern("call"), 1, ary);
+}
+
+/* return 1 normal. return 0 removes the session */
+static int
+ossl_sslctx_session_new_cb(SSL *ssl, SSL_SESSION *sess)
+{
+ VALUE ary, ssl_obj, sess_obj;
+ void *ptr;
+ int state = 0;
+
+ OSSL_Debug("SSL SESSION new callback entered");
+
+ if ((ptr = SSL_get_ex_data(ssl, ossl_ssl_ex_ptr_idx)) == NULL)
+ return 1;
+ ssl_obj = (VALUE)ptr;
+ sess_obj = rb_obj_alloc(cSSLSession);
+ CRYPTO_add(&sess->references, 1, CRYPTO_LOCK_SSL_SESSION);
+ DATA_PTR(sess_obj) = sess;
+
+ ary = rb_ary_new2(2);
+ rb_ary_push(ary, ssl_obj);
+ rb_ary_push(ary, sess_obj);
+
+ rb_protect((VALUE(*)_((VALUE)))ossl_call_session_new_cb, ary, &state);
+ if (state) {
+ rb_ivar_set(ssl_obj, ID_callback_state, INT2NUM(state));
+ }
+
+ /*
+ * return 0 which means to OpenSSL that the session is still
+ * valid (since we created Ruby Session object) and was not freed by us
+ * with SSL_SESSION_free(). Call SSLContext#remove_session(sess) in
+ * session_get_cb block if you don't want OpenSSL to cache the session
+ * internally.
+ */
+ return 0;
+}
+
+static VALUE
+ossl_call_session_remove_cb(VALUE ary)
+{
+ VALUE sslctx_obj, cb;
+
+ Check_Type(ary, T_ARRAY);
+ sslctx_obj = rb_ary_entry(ary, 0);
+
+ cb = rb_iv_get(sslctx_obj, "@session_remove_cb");
+ if (NIL_P(cb)) return Qnil;
+
+ return rb_funcall(cb, rb_intern("call"), 1, ary);
+}
+
+static void
+ossl_sslctx_session_remove_cb(SSL_CTX *ctx, SSL_SESSION *sess)
+{
+ VALUE ary, sslctx_obj, sess_obj;
+ void *ptr;
+ int state = 0;
+
+ OSSL_Debug("SSL SESSION remove callback entered");
+
+ if ((ptr = SSL_CTX_get_ex_data(ctx, ossl_ssl_ex_ptr_idx)) == NULL)
+ return;
+ sslctx_obj = (VALUE)ptr;
+ sess_obj = rb_obj_alloc(cSSLSession);
+ CRYPTO_add(&sess->references, 1, CRYPTO_LOCK_SSL_SESSION);
+ DATA_PTR(sess_obj) = sess;
+
+ ary = rb_ary_new2(2);
+ rb_ary_push(ary, sslctx_obj);
+ rb_ary_push(ary, sess_obj);
+
+ rb_protect((VALUE(*)_((VALUE)))ossl_call_session_remove_cb, ary, &state);
+ if (state) {
+/*
+ the SSL_CTX is frozen, nowhere to save state.
+ there is no common accessor method to check it either.
+ rb_ivar_set(sslctx_obj, ID_callback_state, INT2NUM(state));
+*/
+ }
+}
+
+static VALUE
+ossl_sslctx_add_extra_chain_cert_i(RB_BLOCK_CALL_FUNC_ARGLIST(i, arg))
+{
+ X509 *x509;
+ SSL_CTX *ctx;
+
+ GetSSLCTX(arg, ctx);
+ x509 = DupX509CertPtr(i);
+ if(!SSL_CTX_add_extra_chain_cert(ctx, x509)){
+ ossl_raise(eSSLError, NULL);
+ }
+
+ return i;
+}
+
+static VALUE ossl_sslctx_setup(VALUE self);
+
+#ifdef HAVE_SSL_SET_TLSEXT_HOST_NAME
+static VALUE
+ossl_call_servername_cb(VALUE ary)
+{
+ VALUE ssl_obj, sslctx_obj, cb, ret_obj;
+
+ Check_Type(ary, T_ARRAY);
+ ssl_obj = rb_ary_entry(ary, 0);
+
+ sslctx_obj = rb_iv_get(ssl_obj, "@context");
+ if (NIL_P(sslctx_obj)) return Qnil;
+ cb = rb_iv_get(sslctx_obj, "@servername_cb");
+ if (NIL_P(cb)) return Qnil;
+
+ ret_obj = rb_funcall(cb, rb_intern("call"), 1, ary);
+ if (rb_obj_is_kind_of(ret_obj, cSSLContext)) {
+ SSL *ssl;
+ SSL_CTX *ctx2;
+
+ ossl_sslctx_setup(ret_obj);
+ GetSSL(ssl_obj, ssl);
+ GetSSLCTX(ret_obj, ctx2);
+ SSL_set_SSL_CTX(ssl, ctx2);
+ } else if (!NIL_P(ret_obj)) {
+ ossl_raise(rb_eArgError, "servername_cb must return an OpenSSL::SSL::SSLContext object or nil");
+ }
+
+ return ret_obj;
+}
+
+static int
+ssl_servername_cb(SSL *ssl, int *ad, void *arg)
+{
+ VALUE ary, ssl_obj;
+ void *ptr;
+ int state = 0;
+ const char *servername = SSL_get_servername(ssl, TLSEXT_NAMETYPE_host_name);
+
+ if (!servername)
+ return SSL_TLSEXT_ERR_OK;
+
+ if ((ptr = SSL_get_ex_data(ssl, ossl_ssl_ex_ptr_idx)) == NULL)
+ return SSL_TLSEXT_ERR_ALERT_FATAL;
+ ssl_obj = (VALUE)ptr;
+ ary = rb_ary_new2(2);
+ rb_ary_push(ary, ssl_obj);
+ rb_ary_push(ary, rb_str_new2(servername));
+
+ rb_protect((VALUE(*)_((VALUE)))ossl_call_servername_cb, ary, &state);
+ if (state) {
+ rb_ivar_set(ssl_obj, ID_callback_state, INT2NUM(state));
+ return SSL_TLSEXT_ERR_ALERT_FATAL;
+ }
+
+ return SSL_TLSEXT_ERR_OK;
+}
+#endif
+
+static void
+ssl_renegotiation_cb(const SSL *ssl)
+{
+ VALUE ssl_obj, sslctx_obj, cb;
+ void *ptr;
+
+ if ((ptr = SSL_get_ex_data(ssl, ossl_ssl_ex_ptr_idx)) == NULL)
+ ossl_raise(eSSLError, "SSL object could not be retrieved");
+ ssl_obj = (VALUE)ptr;
+
+ sslctx_obj = rb_iv_get(ssl_obj, "@context");
+ if (NIL_P(sslctx_obj)) return;
+ cb = rb_iv_get(sslctx_obj, "@renegotiation_cb");
+ if (NIL_P(cb)) return;
+
+ (void) rb_funcall(cb, rb_intern("call"), 1, ssl_obj);
+}
+
+#ifdef HAVE_OPENSSL_NPN_NEGOTIATED
+static VALUE
+ssl_npn_encode_protocol_i(VALUE cur, VALUE encoded)
+{
+ int len = RSTRING_LENINT(cur);
+ char len_byte;
+ if (len < 1 || len > 255)
+ ossl_raise(eSSLError, "Advertised protocol must have length 1..255");
+ /* Encode the length byte */
+ len_byte = len;
+ rb_str_buf_cat(encoded, &len_byte, 1);
+ rb_str_buf_cat(encoded, RSTRING_PTR(cur), len);
+ return Qnil;
+}
+
+static void
+ssl_npn_encode_protocols(VALUE sslctx, VALUE protocols)
+{
+ VALUE encoded = rb_str_new2("");
+ rb_iterate(rb_each, protocols, ssl_npn_encode_protocol_i, encoded);
+ StringValueCStr(encoded);
+ rb_iv_set(sslctx, "@_protocols", encoded);
+}
+
+static int
+ssl_npn_advertise_cb(SSL *ssl, const unsigned char **out, unsigned int *outlen, void *arg)
+{
+ VALUE sslctx_obj = (VALUE) arg;
+ VALUE protocols = rb_iv_get(sslctx_obj, "@_protocols");
+
+ *out = (const unsigned char *) RSTRING_PTR(protocols);
+ *outlen = RSTRING_LENINT(protocols);
+
+ return SSL_TLSEXT_ERR_OK;
+}
+
+static int
+ssl_npn_select_cb(SSL *s, unsigned char **out, unsigned char *outlen, const unsigned char *in, unsigned int inlen, void *arg)
+{
+ int i = 0;
+ VALUE sslctx_obj, cb, protocols, selected;
+
+ sslctx_obj = (VALUE) arg;
+ cb = rb_iv_get(sslctx_obj, "@npn_select_cb");
+ protocols = rb_ary_new();
+
+ /* The format is len_1|proto_1|...|len_n|proto_n\0 */
+ while (in[i]) {
+ VALUE protocol = rb_str_new((const char *) &in[i + 1], in[i]);
+ rb_ary_push(protocols, protocol);
+ i += in[i] + 1;
+ }
+
+ selected = rb_funcall(cb, rb_intern("call"), 1, protocols);
+ StringValue(selected);
+ *out = (unsigned char *) StringValuePtr(selected);
+ *outlen = RSTRING_LENINT(selected);
+
+ return SSL_TLSEXT_ERR_OK;
+}
+#endif
+
+/* This function may serve as the entry point to support further
+ * callbacks. */
+static void
+ssl_info_cb(const SSL *ssl, int where, int val)
+{
+ int state = SSL_state(ssl);
+
+ if ((where & SSL_CB_HANDSHAKE_START) &&
+ (state & SSL_ST_ACCEPT)) {
+ ssl_renegotiation_cb(ssl);
+ }
+}
+
+/*
+ * call-seq:
+ * ctx.setup => Qtrue # first time
+ * ctx.setup => nil # thereafter
+ *
+ * This method is called automatically when a new SSLSocket is created.
+ * Normally you do not need to call this method (unless you are writing an
+ * extension in C).
+ */
+static VALUE
+ossl_sslctx_setup(VALUE self)
+{
+ SSL_CTX *ctx;
+ X509 *cert = NULL, *client_ca = NULL;
+ X509_STORE *store;
+ EVP_PKEY *key = NULL;
+ char *ca_path = NULL, *ca_file = NULL;
+ int i, verify_mode;
+ VALUE val;
+
+ if(OBJ_FROZEN(self)) return Qnil;
+ GetSSLCTX(self, ctx);
+
+#if !defined(OPENSSL_NO_DH)
+ if (RTEST(ossl_sslctx_get_tmp_dh_cb(self))){
+ SSL_CTX_set_tmp_dh_callback(ctx, ossl_tmp_dh_callback);
+ }
+ else{
+ SSL_CTX_set_tmp_dh_callback(ctx, ossl_default_tmp_dh_callback);
+ }
+#endif
+ SSL_CTX_set_ex_data(ctx, ossl_ssl_ex_ptr_idx, (void*)self);
+
+ val = ossl_sslctx_get_cert_store(self);
+ if(!NIL_P(val)){
+ /*
+ * WORKAROUND:
+ * X509_STORE can count references, but
+ * X509_STORE_free() doesn't care it.
+ * So we won't increment it but mark it by ex_data.
+ */
+ store = GetX509StorePtr(val); /* NO NEED TO DUP */
+ SSL_CTX_set_cert_store(ctx, store);
+ SSL_CTX_set_ex_data(ctx, ossl_ssl_ex_store_p, (void*)1);
+ }
+
+ val = ossl_sslctx_get_extra_cert(self);
+ if(!NIL_P(val)){
+ rb_block_call(val, rb_intern("each"), 0, 0, ossl_sslctx_add_extra_chain_cert_i, self);
+ }
+
+ /* private key may be bundled in certificate file. */
+ val = ossl_sslctx_get_cert(self);
+ cert = NIL_P(val) ? NULL : GetX509CertPtr(val); /* NO DUP NEEDED */
+ val = ossl_sslctx_get_key(self);
+ key = NIL_P(val) ? NULL : GetPKeyPtr(val); /* NO DUP NEEDED */
+ if (cert && key) {
+ if (!SSL_CTX_use_certificate(ctx, cert)) {
+ /* Adds a ref => Safe to FREE */
+ ossl_raise(eSSLError, "SSL_CTX_use_certificate");
+ }
+ if (!SSL_CTX_use_PrivateKey(ctx, key)) {
+ /* Adds a ref => Safe to FREE */
+ ossl_raise(eSSLError, "SSL_CTX_use_PrivateKey");
+ }
+ if (!SSL_CTX_check_private_key(ctx)) {
+ ossl_raise(eSSLError, "SSL_CTX_check_private_key");
+ }
+ }
+
+ val = ossl_sslctx_get_client_ca(self);
+ if(!NIL_P(val)){
+ if (RB_TYPE_P(val, T_ARRAY)) {
+ for(i = 0; i < RARRAY_LEN(val); i++){
+ client_ca = GetX509CertPtr(RARRAY_PTR(val)[i]);
+ if (!SSL_CTX_add_client_CA(ctx, client_ca)){
+ /* Copies X509_NAME => FREE it. */
+ ossl_raise(eSSLError, "SSL_CTX_add_client_CA");
+ }
+ }
+ }
+ else{
+ client_ca = GetX509CertPtr(val); /* NO DUP NEEDED. */
+ if (!SSL_CTX_add_client_CA(ctx, client_ca)){
+ /* Copies X509_NAME => FREE it. */
+ ossl_raise(eSSLError, "SSL_CTX_add_client_CA");
+ }
+ }
+ }
+
+ val = ossl_sslctx_get_ca_file(self);
+ ca_file = NIL_P(val) ? NULL : StringValuePtr(val);
+ val = ossl_sslctx_get_ca_path(self);
+ ca_path = NIL_P(val) ? NULL : StringValuePtr(val);
+ if(ca_file || ca_path){
+ if (!SSL_CTX_load_verify_locations(ctx, ca_file, ca_path))
+ rb_warning("can't set verify locations");
+ }
+
+ val = ossl_sslctx_get_verify_mode(self);
+ verify_mode = NIL_P(val) ? SSL_VERIFY_NONE : NUM2INT(val);
+ SSL_CTX_set_verify(ctx, verify_mode, ossl_ssl_verify_callback);
+ if (RTEST(ossl_sslctx_get_client_cert_cb(self)))
+ SSL_CTX_set_client_cert_cb(ctx, ossl_client_cert_cb);
+
+ val = ossl_sslctx_get_timeout(self);
+ if(!NIL_P(val)) SSL_CTX_set_timeout(ctx, NUM2LONG(val));
+
+ val = ossl_sslctx_get_verify_dep(self);
+ if(!NIL_P(val)) SSL_CTX_set_verify_depth(ctx, NUM2INT(val));
+
+ val = ossl_sslctx_get_options(self);
+ if(!NIL_P(val)) {
+ SSL_CTX_set_options(ctx, NUM2LONG(val));
+ } else {
+ SSL_CTX_set_options(ctx, SSL_OP_ALL);
+ }
+
+#ifdef HAVE_OPENSSL_NPN_NEGOTIATED
+ val = rb_iv_get(self, "@npn_protocols");
+ if (!NIL_P(val)) {
+ ssl_npn_encode_protocols(self, val);
+ SSL_CTX_set_next_protos_advertised_cb(ctx, ssl_npn_advertise_cb, (void *) self);
+ OSSL_Debug("SSL NPN advertise callback added");
+ }
+ if (RTEST(rb_iv_get(self, "@npn_select_cb"))) {
+ SSL_CTX_set_next_proto_select_cb(ctx, ssl_npn_select_cb, (void *) self);
+ OSSL_Debug("SSL NPN select callback added");
+ }
+#endif
+
+ rb_obj_freeze(self);
+
+ val = ossl_sslctx_get_sess_id_ctx(self);
+ if (!NIL_P(val)){
+ StringValue(val);
+ if (!SSL_CTX_set_session_id_context(ctx, (unsigned char *)RSTRING_PTR(val),
+ RSTRING_LENINT(val))){
+ ossl_raise(eSSLError, "SSL_CTX_set_session_id_context");
+ }
+ }
+
+ if (RTEST(rb_iv_get(self, "@session_get_cb"))) {
+ SSL_CTX_sess_set_get_cb(ctx, ossl_sslctx_session_get_cb);
+ OSSL_Debug("SSL SESSION get callback added");
+ }
+ if (RTEST(rb_iv_get(self, "@session_new_cb"))) {
+ SSL_CTX_sess_set_new_cb(ctx, ossl_sslctx_session_new_cb);
+ OSSL_Debug("SSL SESSION new callback added");
+ }
+ if (RTEST(rb_iv_get(self, "@session_remove_cb"))) {
+ SSL_CTX_sess_set_remove_cb(ctx, ossl_sslctx_session_remove_cb);
+ OSSL_Debug("SSL SESSION remove callback added");
+ }
+
+#ifdef HAVE_SSL_SET_TLSEXT_HOST_NAME
+ val = rb_iv_get(self, "@servername_cb");
+ if (!NIL_P(val)) {
+ SSL_CTX_set_tlsext_servername_callback(ctx, ssl_servername_cb);
+ OSSL_Debug("SSL TLSEXT servername callback added");
+ }
+#endif
+
+ return Qtrue;
+}
+
+static VALUE
+ossl_ssl_cipher_to_ary(SSL_CIPHER *cipher)
+{
+ VALUE ary;
+ int bits, alg_bits;
+
+ ary = rb_ary_new2(4);
+ rb_ary_push(ary, rb_str_new2(SSL_CIPHER_get_name(cipher)));
+ rb_ary_push(ary, rb_str_new2(SSL_CIPHER_get_version(cipher)));
+ bits = SSL_CIPHER_get_bits(cipher, &alg_bits);
+ rb_ary_push(ary, INT2FIX(bits));
+ rb_ary_push(ary, INT2FIX(alg_bits));
+
+ return ary;
+}
+
+/*
+ * call-seq:
+ * ctx.ciphers => [[name, version, bits, alg_bits], ...]
+ *
+ * The list of ciphers configured for this context.
+ */
+static VALUE
+ossl_sslctx_get_ciphers(VALUE self)
+{
+ SSL_CTX *ctx;
+ STACK_OF(SSL_CIPHER) *ciphers;
+ SSL_CIPHER *cipher;
+ VALUE ary;
+ int i, num;
+
+ GetSSLCTX(self, ctx);
+ if(!ctx){
+ rb_warning("SSL_CTX is not initialized.");
+ return Qnil;
+ }
+ ciphers = ctx->cipher_list;
+
+ if (!ciphers)
+ return rb_ary_new();
+
+ num = sk_SSL_CIPHER_num(ciphers);
+ ary = rb_ary_new2(num);
+ for(i = 0; i < num; i++){
+ cipher = sk_SSL_CIPHER_value(ciphers, i);
+ rb_ary_push(ary, ossl_ssl_cipher_to_ary(cipher));
+ }
+ return ary;
+}
+
+/*
+ * call-seq:
+ * ctx.ciphers = "cipher1:cipher2:..."
+ * ctx.ciphers = [name, ...]
+ * ctx.ciphers = [[name, version, bits, alg_bits], ...]
+ *
+ * Sets the list of available ciphers for this context. Note in a server
+ * context some ciphers require the appropriate certificates. For example, an
+ * RSA cipher can only be chosen when an RSA certificate is available.
+ *
+ * See also OpenSSL::Cipher and OpenSSL::Cipher::ciphers
+ */
+static VALUE
+ossl_sslctx_set_ciphers(VALUE self, VALUE v)
+{
+ SSL_CTX *ctx;
+ VALUE str, elem;
+ int i;
+
+ rb_check_frozen(self);
+ if (NIL_P(v))
+ return v;
+ else if (RB_TYPE_P(v, T_ARRAY)) {
+ str = rb_str_new(0, 0);
+ for (i = 0; i < RARRAY_LEN(v); i++) {
+ elem = rb_ary_entry(v, i);
+ if (RB_TYPE_P(elem, T_ARRAY)) elem = rb_ary_entry(elem, 0);
+ elem = rb_String(elem);
+ rb_str_append(str, elem);
+ if (i < RARRAY_LEN(v)-1) rb_str_cat2(str, ":");
+ }
+ } else {
+ str = v;
+ StringValue(str);
+ }
+
+ GetSSLCTX(self, ctx);
+ if(!ctx){
+ ossl_raise(eSSLError, "SSL_CTX is not initialized.");
+ return Qnil;
+ }
+ if (!SSL_CTX_set_cipher_list(ctx, RSTRING_PTR(str))) {
+ ossl_raise(eSSLError, "SSL_CTX_set_cipher_list");
+ }
+
+ return v;
+}
+
+/*
+ * call-seq:
+ * ctx.session_add(session) -> true | false
+ *
+ * Adds +session+ to the session cache
+ */
+static VALUE
+ossl_sslctx_session_add(VALUE self, VALUE arg)
+{
+ SSL_CTX *ctx;
+ SSL_SESSION *sess;
+
+ GetSSLCTX(self, ctx);
+ SafeGetSSLSession(arg, sess);
+
+ return SSL_CTX_add_session(ctx, sess) == 1 ? Qtrue : Qfalse;
+}
+
+/*
+ * call-seq:
+ * ctx.session_remove(session) -> true | false
+ *
+ * Removes +session+ from the session cache
+ */
+static VALUE
+ossl_sslctx_session_remove(VALUE self, VALUE arg)
+{
+ SSL_CTX *ctx;
+ SSL_SESSION *sess;
+
+ GetSSLCTX(self, ctx);
+ SafeGetSSLSession(arg, sess);
+
+ return SSL_CTX_remove_session(ctx, sess) == 1 ? Qtrue : Qfalse;
+}
+
+/*
+ * call-seq:
+ * ctx.session_cache_mode -> Integer
+ *
+ * The current session cache mode.
+ */
+static VALUE
+ossl_sslctx_get_session_cache_mode(VALUE self)
+{
+ SSL_CTX *ctx;
+
+ GetSSLCTX(self, ctx);
+
+ return LONG2NUM(SSL_CTX_get_session_cache_mode(ctx));
+}
+
+/*
+ * call-seq:
+ * ctx.session_cache_mode=(integer) -> Integer
+ *
+ * Sets the SSL session cache mode. Bitwise-or together the desired
+ * SESSION_CACHE_* constants to set. See SSL_CTX_set_session_cache_mode(3) for
+ * details.
+ */
+static VALUE
+ossl_sslctx_set_session_cache_mode(VALUE self, VALUE arg)
+{
+ SSL_CTX *ctx;
+
+ GetSSLCTX(self, ctx);
+
+ SSL_CTX_set_session_cache_mode(ctx, NUM2LONG(arg));
+
+ return arg;
+}
+
+/*
+ * call-seq:
+ * ctx.session_cache_size -> Integer
+ *
+ * Returns the current session cache size. Zero is used to represent an
+ * unlimited cache size.
+ */
+static VALUE
+ossl_sslctx_get_session_cache_size(VALUE self)
+{
+ SSL_CTX *ctx;
+
+ GetSSLCTX(self, ctx);
+
+ return LONG2NUM(SSL_CTX_sess_get_cache_size(ctx));
+}
+
+/*
+ * call-seq:
+ * ctx.session_cache_size=(integer) -> Integer
+ *
+ * Sets the session cache size. Returns the previously valid session cache
+ * size. Zero is used to represent an unlimited session cache size.
+ */
+static VALUE
+ossl_sslctx_set_session_cache_size(VALUE self, VALUE arg)
+{
+ SSL_CTX *ctx;
+
+ GetSSLCTX(self, ctx);
+
+ SSL_CTX_sess_set_cache_size(ctx, NUM2LONG(arg));
+
+ return arg;
+}
+
+/*
+ * call-seq:
+ * ctx.session_cache_stats -> Hash
+ *
+ * Returns a Hash containing the following keys:
+ *
+ * :accept:: Number of started SSL/TLS handshakes in server mode
+ * :accept_good:: Number of established SSL/TLS sessions in server mode
+ * :accept_renegotiate:: Number of start renegotiations in server mode
+ * :cache_full:: Number of sessions that were removed due to cache overflow
+ * :cache_hits:: Number of successfully reused connections
+ * :cache_misses:: Number of sessions proposed by clients that were not found
+ * in the cache
+ * :cache_num:: Number of sessions in the internal session cache
+ * :cb_hits:: Number of sessions retrieved from the external cache in server
+ * mode
+ * :connect:: Number of started SSL/TLS handshakes in client mode
+ * :connect_good:: Number of established SSL/TLS sessions in client mode
+ * :connect_renegotiate:: Number of start renegotiations in client mode
+ * :timeouts:: Number of sessions proposed by clients that were found in the
+ * cache but had expired due to timeouts
+ */
+static VALUE
+ossl_sslctx_get_session_cache_stats(VALUE self)
+{
+ SSL_CTX *ctx;
+ VALUE hash;
+
+ GetSSLCTX(self, ctx);
+
+ hash = rb_hash_new();
+ rb_hash_aset(hash, ID2SYM(rb_intern("cache_num")), LONG2NUM(SSL_CTX_sess_number(ctx)));
+ rb_hash_aset(hash, ID2SYM(rb_intern("connect")), LONG2NUM(SSL_CTX_sess_connect(ctx)));
+ rb_hash_aset(hash, ID2SYM(rb_intern("connect_good")), LONG2NUM(SSL_CTX_sess_connect_good(ctx)));
+ rb_hash_aset(hash, ID2SYM(rb_intern("connect_renegotiate")), LONG2NUM(SSL_CTX_sess_connect_renegotiate(ctx)));
+ rb_hash_aset(hash, ID2SYM(rb_intern("accept")), LONG2NUM(SSL_CTX_sess_accept(ctx)));
+ rb_hash_aset(hash, ID2SYM(rb_intern("accept_good")), LONG2NUM(SSL_CTX_sess_accept_good(ctx)));
+ rb_hash_aset(hash, ID2SYM(rb_intern("accept_renegotiate")), LONG2NUM(SSL_CTX_sess_accept_renegotiate(ctx)));
+ rb_hash_aset(hash, ID2SYM(rb_intern("cache_hits")), LONG2NUM(SSL_CTX_sess_hits(ctx)));
+ rb_hash_aset(hash, ID2SYM(rb_intern("cb_hits")), LONG2NUM(SSL_CTX_sess_cb_hits(ctx)));
+ rb_hash_aset(hash, ID2SYM(rb_intern("cache_misses")), LONG2NUM(SSL_CTX_sess_misses(ctx)));
+ rb_hash_aset(hash, ID2SYM(rb_intern("cache_full")), LONG2NUM(SSL_CTX_sess_cache_full(ctx)));
+ rb_hash_aset(hash, ID2SYM(rb_intern("timeouts")), LONG2NUM(SSL_CTX_sess_timeouts(ctx)));
+
+ return hash;
+}
+
+
+/*
+ * call-seq:
+ * ctx.flush_sessions(time | nil) -> self
+ *
+ * Removes sessions in the internal cache that have expired at +time+.
+ */
+static VALUE
+ossl_sslctx_flush_sessions(int argc, VALUE *argv, VALUE self)
+{
+ VALUE arg1;
+ SSL_CTX *ctx;
+ time_t tm = 0;
+
+ rb_scan_args(argc, argv, "01", &arg1);
+
+ GetSSLCTX(self, ctx);
+
+ if (NIL_P(arg1)) {
+ tm = time(0);
+ } else if (rb_obj_is_instance_of(arg1, rb_cTime)) {
+ tm = NUM2LONG(rb_funcall(arg1, rb_intern("to_i"), 0));
+ } else {
+ ossl_raise(rb_eArgError, "arg must be Time or nil");
+ }
+
+ SSL_CTX_flush_sessions(ctx, (long)tm);
+
+ return self;
+}
+
+/*
+ * SSLSocket class
+ */
+#ifndef OPENSSL_NO_SOCK
+static void
+ossl_ssl_shutdown(SSL *ssl)
+{
+ int i, rc;
+
+ if (ssl) {
+ /* 4 is from SSL_smart_shutdown() of mod_ssl.c (v2.2.19) */
+ /* It says max 2x pending + 2x data = 4 */
+ for (i = 0; i < 4; ++i) {
+ /*
+ * Ignore the case SSL_shutdown returns -1. Empty handshake_func
+ * must not happen.
+ */
+ if (rc = SSL_shutdown(ssl))
+ break;
+ }
+ SSL_clear(ssl);
+ ERR_clear_error();
+ }
+}
+
+static void
+ossl_ssl_free(void *ssl)
+{
+ SSL_free(ssl);
+}
+
+const rb_data_type_t ossl_ssl_type = {
+ "OpenSSL/SSL",
+ {
+ 0, ossl_ssl_free,
+ },
+ 0, 0, RUBY_TYPED_FREE_IMMEDIATELY,
+};
+
+static VALUE
+ossl_ssl_s_alloc(VALUE klass)
+{
+ return TypedData_Wrap_Struct(klass, &ossl_ssl_type, NULL);
+}
+
+/*
+ * call-seq:
+ * SSLSocket.new(io) => aSSLSocket
+ * SSLSocket.new(io, ctx) => aSSLSocket
+ *
+ * Creates a new SSL socket from +io+ which must be a real ruby object (not an
+ * IO-like object that responds to read/write).
+ *
+ * If +ctx+ is provided the SSL Sockets initial params will be taken from
+ * the context.
+ *
+ * The OpenSSL::Buffering module provides additional IO methods.
+ *
+ * This method will freeze the SSLContext if one is provided;
+ * however, session management is still allowed in the frozen SSLContext.
+ */
+static VALUE
+ossl_ssl_initialize(int argc, VALUE *argv, VALUE self)
+{
+ VALUE io, ctx;
+
+ if (rb_scan_args(argc, argv, "11", &io, &ctx) == 1) {
+ ctx = rb_funcall(cSSLContext, rb_intern("new"), 0);
+ }
+ OSSL_Check_Kind(ctx, cSSLContext);
+ Check_Type(io, T_FILE);
+ ossl_ssl_set_io(self, io);
+ ossl_ssl_set_ctx(self, ctx);
+ ossl_ssl_set_sync_close(self, Qfalse);
+ ossl_sslctx_setup(ctx);
+
+ rb_iv_set(self, "@hostname", Qnil);
+
+ rb_call_super(0, 0);
+
+ return self;
+}
+
+static VALUE
+ossl_ssl_setup(VALUE self)
+{
+ VALUE io, v_ctx, cb;
+ SSL_CTX *ctx;
+ SSL *ssl;
+ rb_io_t *fptr;
+
+ GetSSL(self, ssl);
+ if(!ssl){
+#ifdef HAVE_SSL_SET_TLSEXT_HOST_NAME
+ VALUE hostname = rb_iv_get(self, "@hostname");
+#endif
+
+ v_ctx = ossl_ssl_get_ctx(self);
+ GetSSLCTX(v_ctx, ctx);
+
+ ssl = SSL_new(ctx);
+ if (!ssl) {
+ ossl_raise(eSSLError, "SSL_new");
+ }
+ DATA_PTR(self) = ssl;
+
+#ifdef HAVE_SSL_SET_TLSEXT_HOST_NAME
+ if (!NIL_P(hostname)) {
+ if (SSL_set_tlsext_host_name(ssl, StringValuePtr(hostname)) != 1)
+ ossl_raise(eSSLError, "SSL_set_tlsext_host_name");
+ }
+#endif
+ io = ossl_ssl_get_io(self);
+ GetOpenFile(io, fptr);
+ rb_io_check_readable(fptr);
+ rb_io_check_writable(fptr);
+ SSL_set_fd(ssl, TO_SOCKET(FPTR_TO_FD(fptr)));
+ SSL_set_ex_data(ssl, ossl_ssl_ex_ptr_idx, (void*)self);
+ cb = ossl_sslctx_get_verify_cb(v_ctx);
+ SSL_set_ex_data(ssl, ossl_ssl_ex_vcb_idx, (void*)cb);
+ cb = ossl_sslctx_get_client_cert_cb(v_ctx);
+ SSL_set_ex_data(ssl, ossl_ssl_ex_client_cert_cb_idx, (void*)cb);
+ cb = ossl_sslctx_get_tmp_dh_cb(v_ctx);
+ SSL_set_ex_data(ssl, ossl_ssl_ex_tmp_dh_callback_idx, (void*)cb);
+ SSL_set_info_callback(ssl, ssl_info_cb);
+ }
+
+ return Qtrue;
+}
+
+#ifdef _WIN32
+#define ssl_get_error(ssl, ret) (errno = rb_w32_map_errno(WSAGetLastError()), SSL_get_error((ssl), (ret)))
+#else
+#define ssl_get_error(ssl, ret) SSL_get_error((ssl), (ret))
+#endif
+
+#define ossl_ssl_data_get_struct(v, ssl) \
+do { \
+ GetSSL((v), (ssl)); \
+ if (!(ssl)) { \
+ rb_warning("SSL session is not started yet."); \
+ return Qnil; \
+ } \
+} while (0)
+
+static void
+write_would_block(int nonblock)
+{
+ if (nonblock) {
+ VALUE exc = ossl_exc_new(eSSLErrorWaitWritable, "write would block");
+ rb_exc_raise(exc);
+ }
+}
+
+static void
+read_would_block(int nonblock)
+{
+ if (nonblock) {
+ VALUE exc = ossl_exc_new(eSSLErrorWaitReadable, "read would block");
+ rb_exc_raise(exc);
+ }
+}
+
+static VALUE
+ossl_start_ssl(VALUE self, int (*func)(), const char *funcname, int nonblock)
+{
+ SSL *ssl;
+ rb_io_t *fptr;
+ int ret, ret2;
+ VALUE cb_state;
+
+ rb_ivar_set(self, ID_callback_state, Qnil);
+
+ ossl_ssl_data_get_struct(self, ssl);
+
+ GetOpenFile(ossl_ssl_get_io(self), fptr);
+ for(;;){
+ ret = func(ssl);
+
+ cb_state = rb_ivar_get(self, ID_callback_state);
+ if (!NIL_P(cb_state))
+ rb_jump_tag(NUM2INT(cb_state));
+
+ if (ret > 0)
+ break;
+
+ switch((ret2 = ssl_get_error(ssl, ret))){
+ case SSL_ERROR_WANT_WRITE:
+ write_would_block(nonblock);
+ rb_io_wait_writable(FPTR_TO_FD(fptr));
+ continue;
+ case SSL_ERROR_WANT_READ:
+ read_would_block(nonblock);
+ rb_io_wait_readable(FPTR_TO_FD(fptr));
+ continue;
+ case SSL_ERROR_SYSCALL:
+ if (errno) rb_sys_fail(funcname);
+ ossl_raise(eSSLError, "%s SYSCALL returned=%d errno=%d state=%s", funcname, ret2, errno, SSL_state_string_long(ssl));
+ default:
+ ossl_raise(eSSLError, "%s returned=%d errno=%d state=%s", funcname, ret2, errno, SSL_state_string_long(ssl));
+ }
+ }
+
+ return self;
+}
+
+/*
+ * call-seq:
+ * ssl.connect => self
+ *
+ * Initiates an SSL/TLS handshake with a server. The handshake may be started
+ * after unencrypted data has been sent over the socket.
+ */
+static VALUE
+ossl_ssl_connect(VALUE self)
+{
+ ossl_ssl_setup(self);
+ return ossl_start_ssl(self, SSL_connect, "SSL_connect", 0);
+}
+
+/*
+ * call-seq:
+ * ssl.connect_nonblock => self
+ *
+ * Initiates the SSL/TLS handshake as a client in non-blocking manner.
+ *
+ * # emulates blocking connect
+ * begin
+ * ssl.connect_nonblock
+ * rescue IO::WaitReadable
+ * IO.select([s2])
+ * retry
+ * rescue IO::WaitWritable
+ * IO.select(nil, [s2])
+ * retry
+ * end
+ *
+ */
+static VALUE
+ossl_ssl_connect_nonblock(VALUE self)
+{
+ ossl_ssl_setup(self);
+ return ossl_start_ssl(self, SSL_connect, "SSL_connect", 1);
+}
+
+/*
+ * call-seq:
+ * ssl.accept => self
+ *
+ * Waits for a SSL/TLS client to initiate a handshake. The handshake may be
+ * started after unencrypted data has been sent over the socket.
+ */
+static VALUE
+ossl_ssl_accept(VALUE self)
+{
+ ossl_ssl_setup(self);
+ return ossl_start_ssl(self, SSL_accept, "SSL_accept", 0);
+}
+
+/*
+ * call-seq:
+ * ssl.accept_nonblock => self
+ *
+ * Initiates the SSL/TLS handshake as a server in non-blocking manner.
+ *
+ * # emulates blocking accept
+ * begin
+ * ssl.accept_nonblock
+ * rescue IO::WaitReadable
+ * IO.select([s2])
+ * retry
+ * rescue IO::WaitWritable
+ * IO.select(nil, [s2])
+ * retry
+ * end
+ *
+ */
+static VALUE
+ossl_ssl_accept_nonblock(VALUE self)
+{
+ ossl_ssl_setup(self);
+ return ossl_start_ssl(self, SSL_accept, "SSL_accept", 1);
+}
+
+static VALUE
+ossl_ssl_read_internal(int argc, VALUE *argv, VALUE self, int nonblock)
+{
+ SSL *ssl;
+ int ilen, nread = 0;
+ int no_exception = 0;
+ VALUE len, str;
+ rb_io_t *fptr;
+ VALUE opts = Qnil;
+
+ rb_scan_args(argc, argv, "11:", &len, &str, &opts);
+
+ if (!NIL_P(opts) && Qfalse == rb_hash_aref(opts, sym_exception))
+ no_exception = 1;
+
+ ilen = NUM2INT(len);
+ if(NIL_P(str)) str = rb_str_new(0, ilen);
+ else{
+ StringValue(str);
+ rb_str_modify(str);
+ rb_str_resize(str, ilen);
+ }
+ if(ilen == 0) return str;
+
+ GetSSL(self, ssl);
+ GetOpenFile(ossl_ssl_get_io(self), fptr);
+ if (ssl) {
+ if(!nonblock && SSL_pending(ssl) <= 0)
+ rb_thread_wait_fd(FPTR_TO_FD(fptr));
+ for (;;){
+ nread = SSL_read(ssl, RSTRING_PTR(str), RSTRING_LENINT(str));
+ switch(ssl_get_error(ssl, nread)){
+ case SSL_ERROR_NONE:
+ goto end;
+ case SSL_ERROR_ZERO_RETURN:
+ if (no_exception) { return Qnil; }
+ rb_eof_error();
+ case SSL_ERROR_WANT_WRITE:
+ if (no_exception) { return ID2SYM(rb_intern("wait_writable")); }
+ write_would_block(nonblock);
+ rb_io_wait_writable(FPTR_TO_FD(fptr));
+ continue;
+ case SSL_ERROR_WANT_READ:
+ if (no_exception) { return ID2SYM(rb_intern("wait_readable")); }
+ read_would_block(nonblock);
+ rb_io_wait_readable(FPTR_TO_FD(fptr));
+ continue;
+ case SSL_ERROR_SYSCALL:
+ if(ERR_peek_error() == 0 && nread == 0) {
+ if (no_exception) { return Qnil; }
+ rb_eof_error();
+ }
+ rb_sys_fail(0);
+ default:
+ ossl_raise(eSSLError, "SSL_read");
+ }
+ }
+ }
+ else {
+ ID meth = nonblock ? rb_intern("read_nonblock") : rb_intern("sysread");
+ rb_warning("SSL session is not started yet.");
+ if (nonblock) {
+ return rb_funcall(ossl_ssl_get_io(self), meth, 3, len, str, opts);
+ } else {
+ return rb_funcall(ossl_ssl_get_io(self), meth, 2, len, str);
+ }
+ }
+
+ end:
+ rb_str_set_len(str, nread);
+ OBJ_TAINT(str);
+
+ return str;
+}
+
+/*
+ * call-seq:
+ * ssl.sysread(length) => string
+ * ssl.sysread(length, buffer) => buffer
+ *
+ * Reads +length+ bytes from the SSL connection. If a pre-allocated +buffer+
+ * is provided the data will be written into it.
+ */
+static VALUE
+ossl_ssl_read(int argc, VALUE *argv, VALUE self)
+{
+ return ossl_ssl_read_internal(argc, argv, self, 0);
+}
+
+/*
+ * call-seq:
+ * ssl.sysread_nonblock(length) => string
+ * ssl.sysread_nonblock(length, buffer) => buffer
+ * ssl.sysread_nonblock(length[, buffer [, opts]) => buffer
+ *
+ * A non-blocking version of #sysread. Raises an SSLError if reading would
+ * block. If "exception: false" is passed, this method returns a symbol of
+ * :wait_readable, :wait_writable, or nil, rather than raising an exception.
+ *
+ * Reads +length+ bytes from the SSL connection. If a pre-allocated +buffer+
+ * is provided the data will be written into it.
+ */
+static VALUE
+ossl_ssl_read_nonblock(int argc, VALUE *argv, VALUE self)
+{
+ return ossl_ssl_read_internal(argc, argv, self, 1);
+}
+
+static VALUE
+ossl_ssl_write_internal(VALUE self, VALUE str, int nonblock, int no_exception)
+{
+ SSL *ssl;
+ int nwrite = 0;
+ rb_io_t *fptr;
+
+ StringValue(str);
+ GetSSL(self, ssl);
+ GetOpenFile(ossl_ssl_get_io(self), fptr);
+
+ if (ssl) {
+ for (;;){
+ nwrite = SSL_write(ssl, RSTRING_PTR(str), RSTRING_LENINT(str));
+ switch(ssl_get_error(ssl, nwrite)){
+ case SSL_ERROR_NONE:
+ goto end;
+ case SSL_ERROR_WANT_WRITE:
+ if (no_exception) { return ID2SYM(rb_intern("wait_writable")); }
+ write_would_block(nonblock);
+ rb_io_wait_writable(FPTR_TO_FD(fptr));
+ continue;
+ case SSL_ERROR_WANT_READ:
+ if (no_exception) { return ID2SYM(rb_intern("wait_readable")); }
+ read_would_block(nonblock);
+ rb_io_wait_readable(FPTR_TO_FD(fptr));
+ continue;
+ case SSL_ERROR_SYSCALL:
+ if (errno) rb_sys_fail(0);
+ default:
+ ossl_raise(eSSLError, "SSL_write");
+ }
+ }
+ }
+ else {
+ ID id_syswrite = rb_intern("syswrite");
+ rb_warning("SSL session is not started yet.");
+ return rb_funcall(ossl_ssl_get_io(self), id_syswrite, 1, str);
+ }
+
+ end:
+ return INT2NUM(nwrite);
+}
+
+/*
+ * call-seq:
+ * ssl.syswrite(string) => Integer
+ *
+ * Writes +string+ to the SSL connection.
+ */
+static VALUE
+ossl_ssl_write(VALUE self, VALUE str)
+{
+ return ossl_ssl_write_internal(self, str, 0, 0);
+}
+
+/*
+ * call-seq:
+ * ssl.syswrite_nonblock(string) => Integer
+ *
+ * Writes +string+ to the SSL connection in a non-blocking manner. Raises an
+ * SSLError if writing would block.
+ */
+static VALUE
+ossl_ssl_write_nonblock(int argc, VALUE *argv, VALUE self)
+{
+ VALUE str;
+ VALUE opts = Qnil;
+ int no_exception = 0;
+
+ rb_scan_args(argc, argv, "1:", &str, &opts);
+
+ if (!NIL_P(opts) && Qfalse == rb_hash_aref(opts, sym_exception))
+ no_exception = 1;
+
+ return ossl_ssl_write_internal(self, str, 1, no_exception);
+}
+
+/*
+ * call-seq:
+ * ssl.sysclose => nil
+ *
+ * Shuts down the SSL connection and prepares it for another connection.
+ */
+static VALUE
+ossl_ssl_close(VALUE self)
+{
+ SSL *ssl;
+ VALUE io;
+
+ /* ossl_ssl_data_get_struct() is not usable here because it may return
+ * from this function; */
+
+ GetSSL(self, ssl);
+
+ io = ossl_ssl_get_io(self);
+ if (!RTEST(rb_funcall(io, rb_intern("closed?"), 0))) {
+ if (ssl) {
+ ossl_ssl_shutdown(ssl);
+ SSL_free(ssl);
+ }
+ DATA_PTR(self) = NULL;
+ if (RTEST(ossl_ssl_get_sync_close(self)))
+ rb_funcall(io, rb_intern("close"), 0);
+ }
+
+ return Qnil;
+}
+
+/*
+ * call-seq:
+ * ssl.cert => cert or nil
+ *
+ * The X509 certificate for this socket endpoint.
+ */
+static VALUE
+ossl_ssl_get_cert(VALUE self)
+{
+ SSL *ssl;
+ X509 *cert = NULL;
+
+ ossl_ssl_data_get_struct(self, ssl);
+
+ /*
+ * Is this OpenSSL bug? Should add a ref?
+ * TODO: Ask for.
+ */
+ cert = SSL_get_certificate(ssl); /* NO DUPs => DON'T FREE. */
+
+ if (!cert) {
+ return Qnil;
+ }
+ return ossl_x509_new(cert);
+}
+
+/*
+ * call-seq:
+ * ssl.peer_cert => cert or nil
+ *
+ * The X509 certificate for this socket's peer.
+ */
+static VALUE
+ossl_ssl_get_peer_cert(VALUE self)
+{
+ SSL *ssl;
+ X509 *cert = NULL;
+ VALUE obj;
+
+ ossl_ssl_data_get_struct(self, ssl);
+
+ cert = SSL_get_peer_certificate(ssl); /* Adds a ref => Safe to FREE. */
+
+ if (!cert) {
+ return Qnil;
+ }
+ obj = ossl_x509_new(cert);
+ X509_free(cert);
+
+ return obj;
+}
+
+/*
+ * call-seq:
+ * ssl.peer_cert_chain => [cert, ...] or nil
+ *
+ * The X509 certificate chain for this socket's peer.
+ */
+static VALUE
+ossl_ssl_get_peer_cert_chain(VALUE self)
+{
+ SSL *ssl;
+ STACK_OF(X509) *chain;
+ X509 *cert;
+ VALUE ary;
+ int i, num;
+
+ ossl_ssl_data_get_struct(self, ssl);
+
+ chain = SSL_get_peer_cert_chain(ssl);
+ if(!chain) return Qnil;
+ num = sk_X509_num(chain);
+ ary = rb_ary_new2(num);
+ for (i = 0; i < num; i++){
+ cert = sk_X509_value(chain, i);
+ rb_ary_push(ary, ossl_x509_new(cert));
+ }
+
+ return ary;
+}
+
+/*
+* call-seq:
+* ssl.ssl_version => String
+*
+* Returns a String representing the SSL/TLS version that was negotiated
+* for the connection, for example "TLSv1.2".
+*/
+static VALUE
+ossl_ssl_get_version(VALUE self)
+{
+ SSL *ssl;
+
+ ossl_ssl_data_get_struct(self, ssl);
+
+ return rb_str_new2(SSL_get_version(ssl));
+}
+
+/*
+* call-seq:
+* ssl.cipher => [name, version, bits, alg_bits]
+*
+* The cipher being used for the current connection
+*/
+static VALUE
+ossl_ssl_get_cipher(VALUE self)
+{
+ SSL *ssl;
+ SSL_CIPHER *cipher;
+
+ ossl_ssl_data_get_struct(self, ssl);
+
+ cipher = (SSL_CIPHER *)SSL_get_current_cipher(ssl);
+
+ return ossl_ssl_cipher_to_ary(cipher);
+}
+
+/*
+ * call-seq:
+ * ssl.state => string
+ *
+ * A description of the current connection state.
+ */
+static VALUE
+ossl_ssl_get_state(VALUE self)
+{
+ SSL *ssl;
+ VALUE ret;
+
+ ossl_ssl_data_get_struct(self, ssl);
+
+ ret = rb_str_new2(SSL_state_string(ssl));
+ if (ruby_verbose) {
+ rb_str_cat2(ret, ": ");
+ rb_str_cat2(ret, SSL_state_string_long(ssl));
+ }
+ return ret;
+}
+
+/*
+ * call-seq:
+ * ssl.pending => Integer
+ *
+ * The number of bytes that are immediately available for reading
+ */
+static VALUE
+ossl_ssl_pending(VALUE self)
+{
+ SSL *ssl;
+
+ ossl_ssl_data_get_struct(self, ssl);
+
+ return INT2NUM(SSL_pending(ssl));
+}
+
+/*
+ * call-seq:
+ * ssl.session_reused? -> true | false
+ *
+ * Returns true if a reused session was negotiated during the handshake.
+ */
+static VALUE
+ossl_ssl_session_reused(VALUE self)
+{
+ SSL *ssl;
+
+ ossl_ssl_data_get_struct(self, ssl);
+
+ switch(SSL_session_reused(ssl)) {
+ case 1: return Qtrue;
+ case 0: return Qfalse;
+ default: ossl_raise(eSSLError, "SSL_session_reused");
+ }
+
+ UNREACHABLE;
+}
+
+/*
+ * call-seq:
+ * ssl.session = session -> session
+ *
+ * Sets the Session to be used when the connection is established.
+ */
+static VALUE
+ossl_ssl_set_session(VALUE self, VALUE arg1)
+{
+ SSL *ssl;
+ SSL_SESSION *sess;
+
+/* why is ossl_ssl_setup delayed? */
+ ossl_ssl_setup(self);
+
+ ossl_ssl_data_get_struct(self, ssl);
+
+ SafeGetSSLSession(arg1, sess);
+
+ if (SSL_set_session(ssl, sess) != 1)
+ ossl_raise(eSSLError, "SSL_set_session");
+
+ return arg1;
+}
+
+/*
+ * call-seq:
+ * ssl.verify_result => Integer
+ *
+ * Returns the result of the peer certificates verification. See verify(1)
+ * for error values and descriptions.
+ *
+ * If no peer certificate was presented X509_V_OK is returned.
+ */
+static VALUE
+ossl_ssl_get_verify_result(VALUE self)
+{
+ SSL *ssl;
+
+ ossl_ssl_data_get_struct(self, ssl);
+
+ return INT2FIX(SSL_get_verify_result(ssl));
+}
+
+/*
+ * call-seq:
+ * ssl.client_ca => [x509name, ...]
+ *
+ * Returns the list of client CAs. Please note that in contrast to
+ * SSLContext#client_ca= no array of X509::Certificate is returned but
+ * X509::Name instances of the CA's subject distinguished name.
+ *
+ * In server mode, returns the list set by SSLContext#client_ca=.
+ * In client mode, returns the list of client CAs sent from the server.
+ */
+static VALUE
+ossl_ssl_get_client_ca_list(VALUE self)
+{
+ SSL *ssl;
+ STACK_OF(X509_NAME) *ca;
+
+ ossl_ssl_data_get_struct(self, ssl);
+
+ ca = SSL_get_client_CA_list(ssl);
+ return ossl_x509name_sk2ary(ca);
+}
+
+# ifdef HAVE_OPENSSL_NPN_NEGOTIATED
+/*
+ * call-seq:
+ * ssl.npn_protocol => String
+ *
+ * Returns the protocol string that was finally selected by the client
+ * during the handshake.
+ */
+static VALUE
+ossl_ssl_npn_protocol(VALUE self)
+{
+ SSL *ssl;
+ const unsigned char *out;
+ unsigned int outlen;
+
+ ossl_ssl_data_get_struct(self, ssl);
+
+ SSL_get0_next_proto_negotiated(ssl, &out, &outlen);
+ if (!outlen)
+ return Qnil;
+ else
+ return rb_str_new((const char *) out, outlen);
+}
+# endif
+#endif /* !defined(OPENSSL_NO_SOCK) */
+
+void
+Init_ossl_ssl(void)
+{
+ int i;
+ VALUE ary;
+
+#if 0
+ mOSSL = rb_define_module("OpenSSL"); /* let rdoc know about mOSSL */
+#endif
+
+ ID_callback_state = rb_intern("@callback_state");
+
+ ossl_ssl_ex_vcb_idx = SSL_get_ex_new_index(0,(void *)"ossl_ssl_ex_vcb_idx",0,0,0);
+ ossl_ssl_ex_store_p = SSL_get_ex_new_index(0,(void *)"ossl_ssl_ex_store_p",0,0,0);
+ ossl_ssl_ex_ptr_idx = SSL_get_ex_new_index(0,(void *)"ossl_ssl_ex_ptr_idx",0,0,0);
+ ossl_ssl_ex_client_cert_cb_idx =
+ SSL_get_ex_new_index(0,(void *)"ossl_ssl_ex_client_cert_cb_idx",0,0,0);
+ ossl_ssl_ex_tmp_dh_callback_idx =
+ SSL_get_ex_new_index(0,(void *)"ossl_ssl_ex_tmp_dh_callback_idx",0,0,0);
+
+ /* Document-module: OpenSSL::SSL
+ *
+ * Use SSLContext to set up the parameters for a TLS (former SSL)
+ * connection. Both client and server TLS connections are supported,
+ * SSLSocket and SSLServer may be used in conjunction with an instance
+ * of SSLContext to set up connections.
+ */
+ mSSL = rb_define_module_under(mOSSL, "SSL");
+ /* Document-class: OpenSSL::SSL::SSLError
+ *
+ * Generic error class raised by SSLSocket and SSLContext.
+ */
+ eSSLError = rb_define_class_under(mSSL, "SSLError", eOSSLError);
+ eSSLErrorWaitReadable = rb_define_class_under(mSSL, "SSLErrorWaitReadable", eSSLError);
+ rb_include_module(eSSLErrorWaitReadable, rb_mWaitReadable);
+ eSSLErrorWaitWritable = rb_define_class_under(mSSL, "SSLErrorWaitWritable", eSSLError);
+ rb_include_module(eSSLErrorWaitWritable, rb_mWaitWritable);
+
+ Init_ossl_ssl_session();
+
+ /* Document-class: OpenSSL::SSL::SSLContext
+ *
+ * An SSLContext is used to set various options regarding certificates,
+ * algorithms, verification, session caching, etc. The SSLContext is
+ * used to create an SSLSocket.
+ *
+ * All attributes must be set before creating an SSLSocket as the
+ * SSLContext will be frozen afterward.
+ *
+ * The following attributes are available but don't show up in rdoc:
+ * * ssl_version, cert, key, client_ca, ca_file, ca_path, timeout,
+ * * verify_mode, verify_depth client_cert_cb, tmp_dh_callback,
+ * * session_id_context, session_add_cb, session_new_cb, session_remove_cb
+ */
+ cSSLContext = rb_define_class_under(mSSL, "SSLContext", rb_cObject);
+ rb_define_alloc_func(cSSLContext, ossl_sslctx_s_alloc);
+
+ /*
+ * Context certificate
+ */
+ rb_attr(cSSLContext, rb_intern("cert"), 1, 1, Qfalse);
+
+ /*
+ * Context private key
+ */
+ rb_attr(cSSLContext, rb_intern("key"), 1, 1, Qfalse);
+
+ /*
+ * A certificate or Array of certificates that will be sent to the client.
+ */
+ rb_attr(cSSLContext, rb_intern("client_ca"), 1, 1, Qfalse);
+
+ /*
+ * The path to a file containing a PEM-format CA certificate
+ */
+ rb_attr(cSSLContext, rb_intern("ca_file"), 1, 1, Qfalse);
+
+ /*
+ * The path to a directory containing CA certificates in PEM format.
+ *
+ * Files are looked up by subject's X509 name's hash value.
+ */
+ rb_attr(cSSLContext, rb_intern("ca_path"), 1, 1, Qfalse);
+
+ /*
+ * Maximum session lifetime.
+ */
+ rb_attr(cSSLContext, rb_intern("timeout"), 1, 1, Qfalse);
+
+ /*
+ * Session verification mode.
+ *
+ * Valid modes are VERIFY_NONE, VERIFY_PEER, VERIFY_CLIENT_ONCE,
+ * VERIFY_FAIL_IF_NO_PEER_CERT and defined on OpenSSL::SSL
+ */
+ rb_attr(cSSLContext, rb_intern("verify_mode"), 1, 1, Qfalse);
+
+ /*
+ * Number of CA certificates to walk when verifying a certificate chain.
+ */
+ rb_attr(cSSLContext, rb_intern("verify_depth"), 1, 1, Qfalse);
+
+ /*
+ * A callback for additional certificate verification. The callback is
+ * invoked for each certificate in the chain.
+ *
+ * The callback is invoked with two values. +preverify_ok+ indicates
+ * indicates if the verification was passed (true) or not (false).
+ * +store_context+ is an OpenSSL::X509::StoreContext containing the
+ * context used for certificate verification.
+ *
+ * If the callback returns false verification is stopped.
+ */
+ rb_attr(cSSLContext, rb_intern("verify_callback"), 1, 1, Qfalse);
+
+ /*
+ * Sets various OpenSSL options.
+ */
+ rb_attr(cSSLContext, rb_intern("options"), 1, 1, Qfalse);
+
+ /*
+ * An OpenSSL::X509::Store used for certificate verification
+ */
+ rb_attr(cSSLContext, rb_intern("cert_store"), 1, 1, Qfalse);
+
+ /*
+ * An Array of extra X509 certificates to be added to the certificate
+ * chain.
+ */
+ rb_attr(cSSLContext, rb_intern("extra_chain_cert"), 1, 1, Qfalse);
+
+ /*
+ * A callback invoked when a client certificate is requested by a server
+ * and no certificate has been set.
+ *
+ * The callback is invoked with a Session and must return an Array
+ * containing an OpenSSL::X509::Certificate and an OpenSSL::PKey. If any
+ * other value is returned the handshake is suspended.
+ */
+ rb_attr(cSSLContext, rb_intern("client_cert_cb"), 1, 1, Qfalse);
+
+ /*
+ * A callback invoked when DH parameters are required.
+ *
+ * The callback is invoked with the Session for the key exchange, an
+ * flag indicating the use of an export cipher and the keylength
+ * required.
+ *
+ * The callback must return an OpenSSL::PKey::DH instance of the correct
+ * key length.
+ */
+ rb_attr(cSSLContext, rb_intern("tmp_dh_callback"), 1, 1, Qfalse);
+
+ /*
+ * Sets the context in which a session can be reused. This allows
+ * sessions for multiple applications to be distinguished, for example, by
+ * name.
+ */
+ rb_attr(cSSLContext, rb_intern("session_id_context"), 1, 1, Qfalse);
+
+ /*
+ * A callback invoked on a server when a session is proposed by the client
+ * but the session could not be found in the server's internal cache.
+ *
+ * The callback is invoked with the SSLSocket and session id. The
+ * callback may return a Session from an external cache.
+ */
+ rb_attr(cSSLContext, rb_intern("session_get_cb"), 1, 1, Qfalse);
+
+ /*
+ * A callback invoked when a new session was negotiated.
+ *
+ * The callback is invoked with an SSLSocket. If false is returned the
+ * session will be removed from the internal cache.
+ */
+ rb_attr(cSSLContext, rb_intern("session_new_cb"), 1, 1, Qfalse);
+
+ /*
+ * A callback invoked when a session is removed from the internal cache.
+ *
+ * The callback is invoked with an SSLContext and a Session.
+ */
+ rb_attr(cSSLContext, rb_intern("session_remove_cb"), 1, 1, Qfalse);
+
+#ifdef HAVE_SSL_SET_TLSEXT_HOST_NAME
+ /*
+ * A callback invoked at connect time to distinguish between multiple
+ * server names.
+ *
+ * The callback is invoked with an SSLSocket and a server name. The
+ * callback must return an SSLContext for the server name or nil.
+ */
+ rb_attr(cSSLContext, rb_intern("servername_cb"), 1, 1, Qfalse);
+#endif
+ /*
+ * A callback invoked whenever a new handshake is initiated. May be used
+ * to disable renegotiation entirely.
+ *
+ * The callback is invoked with the active SSLSocket. The callback's
+ * return value is irrelevant, normal return indicates "approval" of the
+ * renegotiation and will continue the process. To forbid renegotiation
+ * and to cancel the process, an Error may be raised within the callback.
+ *
+ * === Disable client renegotiation
+ *
+ * When running a server, it is often desirable to disable client
+ * renegotiation entirely. You may use a callback as follows to implement
+ * this feature:
+ *
+ * num_handshakes = 0
+ * ctx.renegotiation_cb = lambda do |ssl|
+ * num_handshakes += 1
+ * raise RuntimeError.new("Client renegotiation disabled") if num_handshakes > 1
+ * end
+ */
+ rb_attr(cSSLContext, rb_intern("renegotiation_cb"), 1, 1, Qfalse);
+#ifdef HAVE_OPENSSL_NPN_NEGOTIATED
+ /*
+ * An Enumerable of Strings. Each String represents a protocol to be
+ * advertised as the list of supported protocols for Next Protocol
+ * Negotiation. Supported in OpenSSL 1.0.1 and higher. Has no effect
+ * on the client side. If not set explicitly, the NPN extension will
+ * not be sent by the server in the handshake.
+ *
+ * === Example
+ *
+ * ctx.npn_protocols = ["http/1.1", "spdy/2"]
+ */
+ rb_attr(cSSLContext, rb_intern("npn_protocols"), 1, 1, Qfalse);
+ /*
+ * A callback invoked on the client side when the client needs to select
+ * a protocol from the list sent by the server. Supported in OpenSSL 1.0.1
+ * and higher. The client MUST select a protocol of those advertised by
+ * the server. If none is acceptable, raising an error in the callback
+ * will cause the handshake to fail. Not setting this callback explicitly
+ * means not supporting the NPN extension on the client - any protocols
+ * advertised by the server will be ignored.
+ *
+ * === Example
+ *
+ * ctx.npn_select_cb = lambda do |protocols|
+ * #inspect the protocols and select one
+ * protocols.first
+ * end
+ */
+ rb_attr(cSSLContext, rb_intern("npn_select_cb"), 1, 1, Qfalse);
+#endif
+
+ rb_define_alias(cSSLContext, "ssl_timeout", "timeout");
+ rb_define_alias(cSSLContext, "ssl_timeout=", "timeout=");
+ rb_define_method(cSSLContext, "initialize", ossl_sslctx_initialize, -1);
+ rb_define_method(cSSLContext, "ssl_version=", ossl_sslctx_set_ssl_version, 1);
+ rb_define_method(cSSLContext, "ciphers", ossl_sslctx_get_ciphers, 0);
+ rb_define_method(cSSLContext, "ciphers=", ossl_sslctx_set_ciphers, 1);
+
+ rb_define_method(cSSLContext, "setup", ossl_sslctx_setup, 0);
+
+ /*
+ * No session caching for client or server
+ */
+ rb_define_const(cSSLContext, "SESSION_CACHE_OFF", LONG2FIX(SSL_SESS_CACHE_OFF));
+
+ /*
+ * Client sessions are added to the session cache
+ */
+ rb_define_const(cSSLContext, "SESSION_CACHE_CLIENT", LONG2FIX(SSL_SESS_CACHE_CLIENT)); /* doesn't actually do anything in 0.9.8e */
+
+ /*
+ * Server sessions are added to the session cache
+ */
+ rb_define_const(cSSLContext, "SESSION_CACHE_SERVER", LONG2FIX(SSL_SESS_CACHE_SERVER));
+
+ /*
+ * Both client and server sessions are added to the session cache
+ */
+ rb_define_const(cSSLContext, "SESSION_CACHE_BOTH", LONG2FIX(SSL_SESS_CACHE_BOTH)); /* no different than CACHE_SERVER in 0.9.8e */
+
+ /*
+ * Normally the session cache is checked for expired sessions every 255
+ * connections. Since this may lead to a delay that cannot be controlled,
+ * the automatic flushing may be disabled and #flush_sessions can be
+ * called explicitly.
+ */
+ rb_define_const(cSSLContext, "SESSION_CACHE_NO_AUTO_CLEAR", LONG2FIX(SSL_SESS_CACHE_NO_AUTO_CLEAR));
+
+ /*
+ * Always perform external lookups of sessions even if they are in the
+ * internal cache.
+ *
+ * This flag has no effect on clients
+ */
+ rb_define_const(cSSLContext, "SESSION_CACHE_NO_INTERNAL_LOOKUP", LONG2FIX(SSL_SESS_CACHE_NO_INTERNAL_LOOKUP));
+
+ /*
+ * Never automatically store sessions in the internal store.
+ */
+ rb_define_const(cSSLContext, "SESSION_CACHE_NO_INTERNAL_STORE", LONG2FIX(SSL_SESS_CACHE_NO_INTERNAL_STORE));
+
+ /*
+ * Enables both SESSION_CACHE_NO_INTERNAL_LOOKUP and
+ * SESSION_CACHE_NO_INTERNAL_STORE.
+ */
+ rb_define_const(cSSLContext, "SESSION_CACHE_NO_INTERNAL", LONG2FIX(SSL_SESS_CACHE_NO_INTERNAL));
+
+ rb_define_method(cSSLContext, "session_add", ossl_sslctx_session_add, 1);
+ rb_define_method(cSSLContext, "session_remove", ossl_sslctx_session_remove, 1);
+ rb_define_method(cSSLContext, "session_cache_mode", ossl_sslctx_get_session_cache_mode, 0);
+ rb_define_method(cSSLContext, "session_cache_mode=", ossl_sslctx_set_session_cache_mode, 1);
+ rb_define_method(cSSLContext, "session_cache_size", ossl_sslctx_get_session_cache_size, 0);
+ rb_define_method(cSSLContext, "session_cache_size=", ossl_sslctx_set_session_cache_size, 1);
+ rb_define_method(cSSLContext, "session_cache_stats", ossl_sslctx_get_session_cache_stats, 0);
+ rb_define_method(cSSLContext, "flush_sessions", ossl_sslctx_flush_sessions, -1);
+
+ ary = rb_ary_new2(numberof(ossl_ssl_method_tab));
+ for (i = 0; i < numberof(ossl_ssl_method_tab); i++) {
+ rb_ary_push(ary, ID2SYM(rb_intern(ossl_ssl_method_tab[i].name)));
+ }
+ rb_obj_freeze(ary);
+ /* The list of available SSL/TLS methods */
+ rb_define_const(cSSLContext, "METHODS", ary);
+
+ /*
+ * Document-class: OpenSSL::SSL::SSLSocket
+ *
+ * The following attributes are available but don't show up in rdoc.
+ * * io, context, sync_close
+ *
+ */
+ cSSLSocket = rb_define_class_under(mSSL, "SSLSocket", rb_cObject);
+#ifdef OPENSSL_NO_SOCK
+ rb_define_method(cSSLSocket, "initialize", rb_notimplement, -1);
+#else
+ rb_define_alloc_func(cSSLSocket, ossl_ssl_s_alloc);
+ for(i = 0; i < numberof(ossl_ssl_attr_readers); i++)
+ rb_attr(cSSLSocket, rb_intern(ossl_ssl_attr_readers[i]), 1, 0, Qfalse);
+ for(i = 0; i < numberof(ossl_ssl_attrs); i++)
+ rb_attr(cSSLSocket, rb_intern(ossl_ssl_attrs[i]), 1, 1, Qfalse);
+ rb_define_alias(cSSLSocket, "to_io", "io");
+ rb_define_method(cSSLSocket, "initialize", ossl_ssl_initialize, -1);
+ rb_define_method(cSSLSocket, "connect", ossl_ssl_connect, 0);
+ rb_define_method(cSSLSocket, "connect_nonblock", ossl_ssl_connect_nonblock, 0);
+ rb_define_method(cSSLSocket, "accept", ossl_ssl_accept, 0);
+ rb_define_method(cSSLSocket, "accept_nonblock", ossl_ssl_accept_nonblock, 0);
+ rb_define_method(cSSLSocket, "sysread", ossl_ssl_read, -1);
+ rb_define_private_method(cSSLSocket, "sysread_nonblock", ossl_ssl_read_nonblock, -1);
+ rb_define_method(cSSLSocket, "syswrite", ossl_ssl_write, 1);
+ rb_define_private_method(cSSLSocket, "syswrite_nonblock", ossl_ssl_write_nonblock, -1);
+ rb_define_method(cSSLSocket, "sysclose", ossl_ssl_close, 0);
+ rb_define_method(cSSLSocket, "cert", ossl_ssl_get_cert, 0);
+ rb_define_method(cSSLSocket, "peer_cert", ossl_ssl_get_peer_cert, 0);
+ rb_define_method(cSSLSocket, "peer_cert_chain", ossl_ssl_get_peer_cert_chain, 0);
+ rb_define_method(cSSLSocket, "ssl_version", ossl_ssl_get_version, 0);
+ rb_define_method(cSSLSocket, "cipher", ossl_ssl_get_cipher, 0);
+ rb_define_method(cSSLSocket, "state", ossl_ssl_get_state, 0);
+ rb_define_method(cSSLSocket, "pending", ossl_ssl_pending, 0);
+ rb_define_method(cSSLSocket, "session_reused?", ossl_ssl_session_reused, 0);
+ /* implementation of OpenSSL::SSL::SSLSocket#session is in lib/openssl/ssl.rb */
+ rb_define_method(cSSLSocket, "session=", ossl_ssl_set_session, 1);
+ rb_define_method(cSSLSocket, "verify_result", ossl_ssl_get_verify_result, 0);
+ rb_define_method(cSSLSocket, "client_ca", ossl_ssl_get_client_ca_list, 0);
+# ifdef HAVE_OPENSSL_NPN_NEGOTIATED
+ rb_define_method(cSSLSocket, "npn_protocol", ossl_ssl_npn_protocol, 0);
+# endif
+#endif
+
+#define ossl_ssl_def_const(x) rb_define_const(mSSL, #x, INT2NUM(SSL_##x))
+
+ ossl_ssl_def_const(VERIFY_NONE);
+ ossl_ssl_def_const(VERIFY_PEER);
+ ossl_ssl_def_const(VERIFY_FAIL_IF_NO_PEER_CERT);
+ ossl_ssl_def_const(VERIFY_CLIENT_ONCE);
+ /* Introduce constants included in OP_ALL. These constants are mostly for
+ * unset some bits in OP_ALL such as;
+ * ctx.options = OP_ALL & ~OP_DONT_INSERT_EMPTY_FRAGMENTS
+ */
+ ossl_ssl_def_const(OP_MICROSOFT_SESS_ID_BUG);
+ ossl_ssl_def_const(OP_NETSCAPE_CHALLENGE_BUG);
+ ossl_ssl_def_const(OP_NETSCAPE_REUSE_CIPHER_CHANGE_BUG);
+ ossl_ssl_def_const(OP_SSLREF2_REUSE_CERT_TYPE_BUG);
+ ossl_ssl_def_const(OP_MICROSOFT_BIG_SSLV3_BUFFER);
+#if defined(SSL_OP_MSIE_SSLV2_RSA_PADDING)
+ ossl_ssl_def_const(OP_MSIE_SSLV2_RSA_PADDING);
+#endif
+ ossl_ssl_def_const(OP_SSLEAY_080_CLIENT_DH_BUG);
+ ossl_ssl_def_const(OP_TLS_D5_BUG);
+ ossl_ssl_def_const(OP_TLS_BLOCK_PADDING_BUG);
+ ossl_ssl_def_const(OP_DONT_INSERT_EMPTY_FRAGMENTS);
+ ossl_ssl_def_const(OP_ALL);
+#if defined(SSL_OP_NO_SESSION_RESUMPTION_ON_RENEGOTIATION)
+ ossl_ssl_def_const(OP_NO_SESSION_RESUMPTION_ON_RENEGOTIATION);
+#endif
+#if defined(SSL_OP_SINGLE_ECDH_USE)
+ ossl_ssl_def_const(OP_SINGLE_ECDH_USE);
+#endif
+ ossl_ssl_def_const(OP_SINGLE_DH_USE);
+ ossl_ssl_def_const(OP_EPHEMERAL_RSA);
+#if defined(SSL_OP_CIPHER_SERVER_PREFERENCE)
+ ossl_ssl_def_const(OP_CIPHER_SERVER_PREFERENCE);
+#endif
+ ossl_ssl_def_const(OP_TLS_ROLLBACK_BUG);
+ ossl_ssl_def_const(OP_NO_SSLv2);
+ ossl_ssl_def_const(OP_NO_SSLv3);
+ ossl_ssl_def_const(OP_NO_TLSv1);
+#if defined(SSL_OP_NO_TLSv1_1)
+ ossl_ssl_def_const(OP_NO_TLSv1_1);
+#endif
+#if defined(SSL_OP_NO_TLSv1_2)
+ ossl_ssl_def_const(OP_NO_TLSv1_2);
+#endif
+#if defined(SSL_OP_NO_TICKET)
+ ossl_ssl_def_const(OP_NO_TICKET);
+#endif
+#if defined(SSL_OP_NO_COMPRESSION)
+ ossl_ssl_def_const(OP_NO_COMPRESSION);
+#endif
+ ossl_ssl_def_const(OP_PKCS1_CHECK_1);
+ ossl_ssl_def_const(OP_PKCS1_CHECK_2);
+ ossl_ssl_def_const(OP_NETSCAPE_CA_DN_BUG);
+ ossl_ssl_def_const(OP_NETSCAPE_DEMO_CIPHER_CHANGE_BUG);
+
+ sym_exception = ID2SYM(rb_intern("exception"));
+}
diff --git a/jni/ruby/ext/openssl/ossl_ssl.h b/jni/ruby/ext/openssl/ossl_ssl.h
new file mode 100644
index 0000000..1215ab5
--- /dev/null
+++ b/jni/ruby/ext/openssl/ossl_ssl.h
@@ -0,0 +1,42 @@
+/*
+ * $Id: ossl_ssl.h 48801 2014-12-12 21:58:34Z nobu $
+ * 'OpenSSL for Ruby' project
+ * Copyright (C) 2001-2002 Michal Rokos <m.rokos@sh.cvut.cz>
+ * All rights reserved.
+ */
+/*
+ * This program is licenced under the same licence as Ruby.
+ * (See the file 'LICENCE'.)
+ */
+#if !defined(_OSSL_SSL_H_)
+#define _OSSL_SSL_H_
+
+#define GetSSL(obj, ssl) do { \
+ TypedData_Get_Struct((obj), SSL, &ossl_ssl_type, (ssl)); \
+} while (0)
+
+#define GetSSLSession(obj, sess) do { \
+ TypedData_Get_Struct((obj), SSL_SESSION, &ossl_ssl_session_type, (sess)); \
+ if (!(sess)) { \
+ ossl_raise(rb_eRuntimeError, "SSL Session wasn't initialized."); \
+ } \
+} while (0)
+
+#define SafeGetSSLSession(obj, sess) do { \
+ OSSL_Check_Kind((obj), cSSLSession); \
+ GetSSLSession((obj), (sess)); \
+} while (0)
+
+extern const rb_data_type_t ossl_ssl_type;
+extern const rb_data_type_t ossl_ssl_session_type;
+extern VALUE mSSL;
+extern VALUE eSSLError;
+extern VALUE cSSLSocket;
+extern VALUE cSSLContext;
+extern VALUE cSSLSession;
+
+void Init_ossl_ssl(void);
+void Init_ossl_ssl_session(void);
+
+#endif /* _OSSL_SSL_H_ */
+
diff --git a/jni/ruby/ext/openssl/ossl_ssl_session.c b/jni/ruby/ext/openssl/ossl_ssl_session.c
new file mode 100644
index 0000000..5318f1a
--- /dev/null
+++ b/jni/ruby/ext/openssl/ossl_ssl_session.c
@@ -0,0 +1,324 @@
+/*
+ * Copyright (C) 2004-2007 Technorama Ltd. <oss-ruby@technorama.net>
+ */
+
+#include "ossl.h"
+
+VALUE cSSLSession;
+static VALUE eSSLSession;
+
+static void
+ossl_ssl_session_free(void *ptr)
+{
+ SSL_SESSION_free(ptr);
+}
+
+const rb_data_type_t ossl_ssl_session_type = {
+ "OpenSSL/SSL/Session",
+ {
+ 0, ossl_ssl_session_free,
+ },
+ 0, 0, RUBY_TYPED_FREE_IMMEDIATELY,
+};
+
+static VALUE ossl_ssl_session_alloc(VALUE klass)
+{
+ return TypedData_Wrap_Struct(klass, &ossl_ssl_session_type, NULL);
+}
+
+/*
+ * call-seq:
+ * Session.new(SSLSocket | string) => session
+ *
+ * === Parameters
+ * +SSLSocket+ is an OpenSSL::SSL::SSLSocket
+ * +string+ must be a DER or PEM encoded Session.
+*/
+static VALUE ossl_ssl_session_initialize(VALUE self, VALUE arg1)
+{
+ SSL_SESSION *ctx = NULL;
+
+ if (RDATA(self)->data)
+ ossl_raise(eSSLSession, "SSL Session already initialized");
+
+ if (rb_obj_is_instance_of(arg1, cSSLSocket)) {
+ SSL *ssl;
+
+ GetSSL(arg1, ssl);
+
+ if (!ssl || (ctx = SSL_get1_session(ssl)) == NULL)
+ ossl_raise(eSSLSession, "no session available");
+ } else {
+ BIO *in = ossl_obj2bio(arg1);
+
+ ctx = PEM_read_bio_SSL_SESSION(in, NULL, NULL, NULL);
+
+ if (!ctx) {
+ OSSL_BIO_reset(in);
+ ctx = d2i_SSL_SESSION_bio(in, NULL);
+ }
+
+ BIO_free(in);
+
+ if (!ctx)
+ ossl_raise(rb_eArgError, "unknown type");
+ }
+
+ /* should not happen */
+ if (ctx == NULL)
+ ossl_raise(eSSLSession, "ctx not set - internal error");
+
+ RDATA(self)->data = ctx;
+
+ return self;
+}
+
+#if HAVE_SSL_SESSION_CMP == 0
+int SSL_SESSION_cmp(const SSL_SESSION *a,const SSL_SESSION *b)
+{
+ if (a->ssl_version != b->ssl_version ||
+ a->session_id_length != b->session_id_length)
+ return 1;
+ return memcmp(a->session_id,b-> session_id, a->session_id_length);
+}
+#endif
+
+/*
+ * call-seq:
+ * session1 == session2 -> boolean
+ *
+*/
+static VALUE ossl_ssl_session_eq(VALUE val1, VALUE val2)
+{
+ SSL_SESSION *ctx1, *ctx2;
+
+ GetSSLSession(val1, ctx1);
+ SafeGetSSLSession(val2, ctx2);
+
+ switch (SSL_SESSION_cmp(ctx1, ctx2)) {
+ case 0: return Qtrue;
+ default: return Qfalse;
+ }
+}
+
+/*
+ * call-seq:
+ * session.time -> Time
+ *
+ * Gets start time of the session.
+ *
+*/
+static VALUE ossl_ssl_session_get_time(VALUE self)
+{
+ SSL_SESSION *ctx;
+ time_t t;
+
+ GetSSLSession(self, ctx);
+
+ t = SSL_SESSION_get_time(ctx);
+
+ if (t == 0)
+ return Qnil;
+
+ return rb_funcall(rb_cTime, rb_intern("at"), 1, TIMET2NUM(t));
+}
+
+/*
+ * call-seq:
+ * session.timeout -> integer
+ *
+ * Gets how long until the session expires in seconds.
+ *
+*/
+static VALUE ossl_ssl_session_get_timeout(VALUE self)
+{
+ SSL_SESSION *ctx;
+ time_t t;
+
+ GetSSLSession(self, ctx);
+
+ t = SSL_SESSION_get_timeout(ctx);
+
+ return TIMET2NUM(t);
+}
+
+/*
+ * call-seq:
+ * session.time=(Time) -> Time
+ * session.time=(integer) -> Time
+ *
+ * Sets start time of the session. Time resolution is in seconds.
+ *
+*/
+static VALUE ossl_ssl_session_set_time(VALUE self, VALUE time_v)
+{
+ SSL_SESSION *ctx;
+ long t;
+
+ GetSSLSession(self, ctx);
+ if (rb_obj_is_instance_of(time_v, rb_cTime)) {
+ time_v = rb_funcall(time_v, rb_intern("to_i"), 0);
+ }
+ t = NUM2LONG(time_v);
+ SSL_SESSION_set_time(ctx, t);
+ return ossl_ssl_session_get_time(self);
+}
+
+/*
+ * call-seq:
+ * session.timeout=(integer) -> integer
+ *
+ * Sets how long until the session expires in seconds.
+ *
+*/
+static VALUE ossl_ssl_session_set_timeout(VALUE self, VALUE time_v)
+{
+ SSL_SESSION *ctx;
+ long t;
+
+ GetSSLSession(self, ctx);
+ t = NUM2LONG(time_v);
+ SSL_SESSION_set_timeout(ctx, t);
+ return ossl_ssl_session_get_timeout(self);
+}
+
+#ifdef HAVE_SSL_SESSION_GET_ID
+/*
+ * call-seq:
+ * session.id -> aString
+ *
+ * Returns the Session ID.
+*/
+static VALUE ossl_ssl_session_get_id(VALUE self)
+{
+ SSL_SESSION *ctx;
+ const unsigned char *p = NULL;
+ unsigned int i = 0;
+
+ GetSSLSession(self, ctx);
+
+ p = SSL_SESSION_get_id(ctx, &i);
+
+ return rb_str_new((const char *) p, i);
+}
+#endif
+
+/*
+ * call-seq:
+ * session.to_der -> aString
+ *
+ * Returns an ASN1 encoded String that contains the Session object.
+*/
+static VALUE ossl_ssl_session_to_der(VALUE self)
+{
+ SSL_SESSION *ctx;
+ unsigned char *p;
+ int len;
+ VALUE str;
+
+ GetSSLSession(self, ctx);
+ len = i2d_SSL_SESSION(ctx, NULL);
+ if (len <= 0) {
+ ossl_raise(eSSLSession, "i2d_SSL_SESSION");
+ }
+
+ str = rb_str_new(0, len);
+ p = (unsigned char *)RSTRING_PTR(str);
+ i2d_SSL_SESSION(ctx, &p);
+ ossl_str_adjust(str, p);
+ return str;
+}
+
+/*
+ * call-seq:
+ * session.to_pem -> String
+ *
+ * Returns a PEM encoded String that contains the Session object.
+*/
+static VALUE ossl_ssl_session_to_pem(VALUE self)
+{
+ SSL_SESSION *ctx;
+ BIO *out;
+ BUF_MEM *buf;
+ VALUE str;
+ int i;
+
+ GetSSLSession(self, ctx);
+
+ if (!(out = BIO_new(BIO_s_mem()))) {
+ ossl_raise(eSSLSession, "BIO_s_mem()");
+ }
+
+ if (!(i=PEM_write_bio_SSL_SESSION(out, ctx))) {
+ BIO_free(out);
+ ossl_raise(eSSLSession, "SSL_SESSION_print()");
+ }
+
+ BIO_get_mem_ptr(out, &buf);
+ str = rb_str_new(buf->data, buf->length);
+ BIO_free(out);
+
+ return str;
+}
+
+
+/*
+ * call-seq:
+ * session.to_text -> String
+ *
+ * Shows everything in the Session object.
+*/
+static VALUE ossl_ssl_session_to_text(VALUE self)
+{
+ SSL_SESSION *ctx;
+ BIO *out;
+ BUF_MEM *buf;
+ VALUE str;
+
+ GetSSLSession(self, ctx);
+
+ if (!(out = BIO_new(BIO_s_mem()))) {
+ ossl_raise(eSSLSession, "BIO_s_mem()");
+ }
+
+ if (!SSL_SESSION_print(out, ctx)) {
+ BIO_free(out);
+ ossl_raise(eSSLSession, "SSL_SESSION_print()");
+ }
+
+ BIO_get_mem_ptr(out, &buf);
+ str = rb_str_new(buf->data, buf->length);
+ BIO_free(out);
+
+ return str;
+}
+
+
+void Init_ossl_ssl_session(void)
+{
+#if 0
+ mOSSL = rb_define_module("OpenSSL"); /* let rdoc know about mOSSL */
+ mSSL = rb_define_module_under(mOSSL, "SSL");
+#endif
+ cSSLSession = rb_define_class_under(mSSL, "Session", rb_cObject);
+ eSSLSession = rb_define_class_under(cSSLSession, "SessionError", eOSSLError);
+
+ rb_define_alloc_func(cSSLSession, ossl_ssl_session_alloc);
+ rb_define_method(cSSLSession, "initialize", ossl_ssl_session_initialize, 1);
+
+ rb_define_method(cSSLSession, "==", ossl_ssl_session_eq, 1);
+
+ rb_define_method(cSSLSession, "time", ossl_ssl_session_get_time, 0);
+ rb_define_method(cSSLSession, "time=", ossl_ssl_session_set_time, 1);
+ rb_define_method(cSSLSession, "timeout", ossl_ssl_session_get_timeout, 0);
+ rb_define_method(cSSLSession, "timeout=", ossl_ssl_session_set_timeout, 1);
+
+#ifdef HAVE_SSL_SESSION_GET_ID
+ rb_define_method(cSSLSession, "id", ossl_ssl_session_get_id, 0);
+#else
+ rb_undef_method(cSSLSession, "id");
+#endif
+ rb_define_method(cSSLSession, "to_der", ossl_ssl_session_to_der, 0);
+ rb_define_method(cSSLSession, "to_pem", ossl_ssl_session_to_pem, 0);
+ rb_define_method(cSSLSession, "to_text", ossl_ssl_session_to_text, 0);
+}
diff --git a/jni/ruby/ext/openssl/ossl_version.h b/jni/ruby/ext/openssl/ossl_version.h
new file mode 100644
index 0000000..235af51
--- /dev/null
+++ b/jni/ruby/ext/openssl/ossl_version.h
@@ -0,0 +1,16 @@
+/*
+ * $Id: ossl_version.h 25189 2009-10-02 12:04:37Z akr $
+ * 'OpenSSL for Ruby' project
+ * Copyright (C) 2001-2002 Michal Rokos <m.rokos@sh.cvut.cz>
+ * All rights reserved.
+ */
+/*
+ * This program is licenced under the same licence as Ruby.
+ * (See the file 'LICENCE'.)
+ */
+#if !defined(_OSSL_VERSION_H_)
+#define _OSSL_VERSION_H_
+
+#define OSSL_VERSION "1.1.0"
+
+#endif /* _OSSL_VERSION_H_ */
diff --git a/jni/ruby/ext/openssl/ossl_x509.c b/jni/ruby/ext/openssl/ossl_x509.c
new file mode 100644
index 0000000..f78a9a8
--- /dev/null
+++ b/jni/ruby/ext/openssl/ossl_x509.c
@@ -0,0 +1,104 @@
+/*
+ * $Id: ossl_x509.c 47744 2014-09-30 05:25:32Z nobu $
+ * 'OpenSSL for Ruby' project
+ * Copyright (C) 2001-2002 Michal Rokos <m.rokos@sh.cvut.cz>
+ * All rights reserved.
+ */
+/*
+ * This program is licenced under the same licence as Ruby.
+ * (See the file 'LICENCE'.)
+ */
+#include "ossl.h"
+
+VALUE mX509;
+
+#define DefX509Const(x) rb_define_const(mX509, #x,INT2FIX(X509_##x))
+#define DefX509Default(x,i) \
+ rb_define_const(mX509, "DEFAULT_" #x, rb_str_new2(X509_get_default_##i()))
+
+void
+Init_ossl_x509(void)
+{
+ mX509 = rb_define_module_under(mOSSL, "X509");
+
+ Init_ossl_x509attr();
+ Init_ossl_x509cert();
+ Init_ossl_x509crl();
+ Init_ossl_x509ext();
+ Init_ossl_x509name();
+ Init_ossl_x509req();
+ Init_ossl_x509revoked();
+ Init_ossl_x509store();
+
+ DefX509Const(V_OK);
+ DefX509Const(V_ERR_UNABLE_TO_GET_ISSUER_CERT);
+ DefX509Const(V_ERR_UNABLE_TO_GET_CRL);
+ DefX509Const(V_ERR_UNABLE_TO_DECRYPT_CERT_SIGNATURE);
+ DefX509Const(V_ERR_UNABLE_TO_DECRYPT_CRL_SIGNATURE);
+ DefX509Const(V_ERR_UNABLE_TO_DECODE_ISSUER_PUBLIC_KEY);
+ DefX509Const(V_ERR_CERT_SIGNATURE_FAILURE);
+ DefX509Const(V_ERR_CRL_SIGNATURE_FAILURE);
+ DefX509Const(V_ERR_CERT_NOT_YET_VALID);
+ DefX509Const(V_ERR_CERT_HAS_EXPIRED);
+ DefX509Const(V_ERR_CRL_NOT_YET_VALID);
+ DefX509Const(V_ERR_CRL_HAS_EXPIRED);
+ DefX509Const(V_ERR_ERROR_IN_CERT_NOT_BEFORE_FIELD);
+ DefX509Const(V_ERR_ERROR_IN_CERT_NOT_AFTER_FIELD);
+ DefX509Const(V_ERR_ERROR_IN_CRL_LAST_UPDATE_FIELD);
+ DefX509Const(V_ERR_ERROR_IN_CRL_NEXT_UPDATE_FIELD);
+ DefX509Const(V_ERR_OUT_OF_MEM);
+ DefX509Const(V_ERR_DEPTH_ZERO_SELF_SIGNED_CERT);
+ DefX509Const(V_ERR_SELF_SIGNED_CERT_IN_CHAIN);
+ DefX509Const(V_ERR_UNABLE_TO_GET_ISSUER_CERT_LOCALLY);
+ DefX509Const(V_ERR_UNABLE_TO_VERIFY_LEAF_SIGNATURE);
+ DefX509Const(V_ERR_CERT_CHAIN_TOO_LONG);
+ DefX509Const(V_ERR_CERT_REVOKED);
+ DefX509Const(V_ERR_INVALID_CA);
+ DefX509Const(V_ERR_PATH_LENGTH_EXCEEDED);
+ DefX509Const(V_ERR_INVALID_PURPOSE);
+ DefX509Const(V_ERR_CERT_UNTRUSTED);
+ DefX509Const(V_ERR_CERT_REJECTED);
+ DefX509Const(V_ERR_SUBJECT_ISSUER_MISMATCH);
+ DefX509Const(V_ERR_AKID_SKID_MISMATCH);
+ DefX509Const(V_ERR_AKID_ISSUER_SERIAL_MISMATCH);
+ DefX509Const(V_ERR_KEYUSAGE_NO_CERTSIGN);
+ DefX509Const(V_ERR_APPLICATION_VERIFICATION);
+
+#if defined(X509_V_FLAG_CRL_CHECK)
+ DefX509Const(V_FLAG_CRL_CHECK);
+#endif
+#if defined(X509_V_FLAG_CRL_CHECK_ALL)
+ DefX509Const(V_FLAG_CRL_CHECK_ALL);
+#endif
+
+ DefX509Const(PURPOSE_SSL_CLIENT);
+ DefX509Const(PURPOSE_SSL_SERVER);
+ DefX509Const(PURPOSE_NS_SSL_SERVER);
+ DefX509Const(PURPOSE_SMIME_SIGN);
+ DefX509Const(PURPOSE_SMIME_ENCRYPT);
+ DefX509Const(PURPOSE_CRL_SIGN);
+ DefX509Const(PURPOSE_ANY);
+#if defined(X509_PURPOSE_OCSP_HELPER)
+ DefX509Const(PURPOSE_OCSP_HELPER);
+#endif
+
+ DefX509Const(TRUST_COMPAT);
+ DefX509Const(TRUST_SSL_CLIENT);
+ DefX509Const(TRUST_SSL_SERVER);
+ DefX509Const(TRUST_EMAIL);
+ DefX509Const(TRUST_OBJECT_SIGN);
+#if defined(X509_TRUST_OCSP_SIGN)
+ DefX509Const(TRUST_OCSP_SIGN);
+#endif
+#if defined(X509_TRUST_OCSP_REQUEST)
+ DefX509Const(TRUST_OCSP_REQUEST);
+#endif
+
+ DefX509Default(CERT_AREA, cert_area);
+ DefX509Default(CERT_DIR, cert_dir);
+ DefX509Default(CERT_FILE, cert_file);
+ DefX509Default(CERT_DIR_ENV, cert_dir_env);
+ DefX509Default(CERT_FILE_ENV, cert_file_env);
+ DefX509Default(PRIVATE_DIR, private_dir);
+}
+
diff --git a/jni/ruby/ext/openssl/ossl_x509.h b/jni/ruby/ext/openssl/ossl_x509.h
new file mode 100644
index 0000000..a96d0f0
--- /dev/null
+++ b/jni/ruby/ext/openssl/ossl_x509.h
@@ -0,0 +1,114 @@
+/*
+ * $Id: ossl_x509.h 25189 2009-10-02 12:04:37Z akr $
+ * 'OpenSSL for Ruby' project
+ * Copyright (C) 2001-2002 Michal Rokos <m.rokos@sh.cvut.cz>
+ * All rights reserved.
+ */
+/*
+ * This program is licenced under the same licence as Ruby.
+ * (See the file 'LICENCE'.)
+ */
+#if !defined(_OSSL_X509_H_)
+#define _OSSL_X509_H_
+
+/*
+ * X509 main module
+ */
+extern VALUE mX509;
+
+void Init_ossl_x509(void);
+
+/*
+ * X509Attr
+ */
+extern VALUE cX509Attr;
+extern VALUE eX509AttrError;
+
+VALUE ossl_x509attr_new(X509_ATTRIBUTE *);
+X509_ATTRIBUTE *DupX509AttrPtr(VALUE);
+void Init_ossl_x509attr(void);
+
+/*
+ * X509Cert
+ */
+extern VALUE cX509Cert;
+extern VALUE eX509CertError;
+
+VALUE ossl_x509_new(X509 *);
+VALUE ossl_x509_new_from_file(VALUE);
+X509 *GetX509CertPtr(VALUE);
+X509 *DupX509CertPtr(VALUE);
+void Init_ossl_x509cert(void);
+
+/*
+ * X509CRL
+ */
+extern VALUE cX509CRL;
+extern VALUE eX509CRLError;
+
+VALUE ossl_x509crl_new(X509_CRL *);
+X509_CRL *GetX509CRLPtr(VALUE);
+X509_CRL *DupX509CRLPtr(VALUE);
+void Init_ossl_x509crl(void);
+
+/*
+ * X509Extension
+ */
+extern VALUE cX509Ext;
+extern VALUE cX509ExtFactory;
+extern VALUE eX509ExtError;
+
+VALUE ossl_x509ext_new(X509_EXTENSION *);
+X509_EXTENSION *GetX509ExtPtr(VALUE);
+X509_EXTENSION *DupX509ExtPtr(VALUE);
+void Init_ossl_x509ext(void);
+
+/*
+ * X509Name
+ */
+extern VALUE cX509Name;
+extern VALUE eX509NameError;
+
+VALUE ossl_x509name_new(X509_NAME *);
+X509_NAME *GetX509NamePtr(VALUE);
+void Init_ossl_x509name(void);
+
+/*
+ * X509Request
+ */
+extern VALUE cX509Req;
+extern VALUE eX509ReqError;
+
+VALUE ossl_x509req_new(X509_REQ *);
+X509_REQ *GetX509ReqPtr(VALUE);
+X509_REQ *DupX509ReqPtr(VALUE);
+void Init_ossl_x509req(void);
+
+/*
+ * X509Revoked
+ */
+extern VALUE cX509Rev;
+extern VALUE eX509RevError;
+
+VALUE ossl_x509revoked_new(X509_REVOKED *);
+X509_REVOKED *DupX509RevokedPtr(VALUE);
+void Init_ossl_x509revoked(void);
+
+/*
+ * X509Store and X509StoreContext
+ */
+extern VALUE cX509Store;
+extern VALUE cX509StoreContext;
+extern VALUE eX509StoreError;
+
+VALUE ossl_x509store_new(X509_STORE *);
+X509_STORE *GetX509StorePtr(VALUE);
+X509_STORE *DupX509StorePtr(VALUE);
+
+VALUE ossl_x509stctx_new(X509_STORE_CTX *);
+VALUE ossl_x509stctx_clear_ptr(VALUE);
+X509_STORE_CTX *GetX509StCtxtPtr(VALUE);
+
+void Init_ossl_x509store(void);
+
+#endif /* _OSSL_X509_H_ */
diff --git a/jni/ruby/ext/openssl/ossl_x509attr.c b/jni/ruby/ext/openssl/ossl_x509attr.c
new file mode 100644
index 0000000..8df45cf
--- /dev/null
+++ b/jni/ruby/ext/openssl/ossl_x509attr.c
@@ -0,0 +1,289 @@
+/*
+ * $Id: ossl_x509attr.c 48809 2014-12-12 23:38:44Z nobu $
+ * 'OpenSSL for Ruby' project
+ * Copyright (C) 2001 Michal Rokos <m.rokos@sh.cvut.cz>
+ * All rights reserved.
+ */
+/*
+ * This program is licenced under the same licence as Ruby.
+ * (See the file 'LICENCE'.)
+ */
+#include "ossl.h"
+
+#define WrapX509Attr(klass, obj, attr) do { \
+ if (!(attr)) { \
+ ossl_raise(rb_eRuntimeError, "ATTR wasn't initialized!"); \
+ } \
+ (obj) = TypedData_Wrap_Struct((klass), &ossl_x509attr_type, (attr)); \
+} while (0)
+#define GetX509Attr(obj, attr) do { \
+ TypedData_Get_Struct((obj), X509_ATTRIBUTE, &ossl_x509attr_type, (attr)); \
+ if (!(attr)) { \
+ ossl_raise(rb_eRuntimeError, "ATTR wasn't initialized!"); \
+ } \
+} while (0)
+#define SafeGetX509Attr(obj, attr) do { \
+ OSSL_Check_Kind((obj), cX509Attr); \
+ GetX509Attr((obj), (attr)); \
+} while (0)
+
+/*
+ * Classes
+ */
+VALUE cX509Attr;
+VALUE eX509AttrError;
+
+static void
+ossl_x509attr_free(void *ptr)
+{
+ X509_ATTRIBUTE_free(ptr);
+}
+
+static const rb_data_type_t ossl_x509attr_type = {
+ "OpenSSL/X509/ATTRIBUTE",
+ {
+ 0, ossl_x509attr_free,
+ },
+ 0, 0, RUBY_TYPED_FREE_IMMEDIATELY,
+};
+
+/*
+ * Public
+ */
+VALUE
+ossl_x509attr_new(X509_ATTRIBUTE *attr)
+{
+ X509_ATTRIBUTE *new;
+ VALUE obj;
+
+ if (!attr) {
+ new = X509_ATTRIBUTE_new();
+ } else {
+ new = X509_ATTRIBUTE_dup(attr);
+ }
+ if (!new) {
+ ossl_raise(eX509AttrError, NULL);
+ }
+ WrapX509Attr(cX509Attr, obj, new);
+
+ return obj;
+}
+
+X509_ATTRIBUTE *
+DupX509AttrPtr(VALUE obj)
+{
+ X509_ATTRIBUTE *attr, *new;
+
+ SafeGetX509Attr(obj, attr);
+ if (!(new = X509_ATTRIBUTE_dup(attr))) {
+ ossl_raise(eX509AttrError, NULL);
+ }
+
+ return new;
+}
+
+/*
+ * Private
+ */
+static VALUE
+ossl_x509attr_alloc(VALUE klass)
+{
+ X509_ATTRIBUTE *attr;
+ VALUE obj;
+
+ if (!(attr = X509_ATTRIBUTE_new()))
+ ossl_raise(eX509AttrError, NULL);
+ WrapX509Attr(klass, obj, attr);
+
+ return obj;
+}
+
+/*
+ * call-seq:
+ * Attribute.new(oid [, value]) => attr
+ */
+static VALUE
+ossl_x509attr_initialize(int argc, VALUE *argv, VALUE self)
+{
+ VALUE oid, value;
+ X509_ATTRIBUTE *attr, *x;
+ const unsigned char *p;
+
+ GetX509Attr(self, attr);
+ if(rb_scan_args(argc, argv, "11", &oid, &value) == 1){
+ oid = ossl_to_der_if_possible(oid);
+ StringValue(oid);
+ p = (unsigned char *)RSTRING_PTR(oid);
+ x = d2i_X509_ATTRIBUTE(&attr, &p, RSTRING_LEN(oid));
+ DATA_PTR(self) = attr;
+ if(!x){
+ ossl_raise(eX509AttrError, NULL);
+ }
+ return self;
+ }
+ rb_funcall(self, rb_intern("oid="), 1, oid);
+ rb_funcall(self, rb_intern("value="), 1, value);
+
+ return self;
+}
+
+/*
+ * call-seq:
+ * attr.oid = string => string
+ */
+static VALUE
+ossl_x509attr_set_oid(VALUE self, VALUE oid)
+{
+ X509_ATTRIBUTE *attr;
+ ASN1_OBJECT *obj;
+ char *s;
+
+ s = StringValuePtr(oid);
+ obj = OBJ_txt2obj(s, 0);
+ if(!obj) obj = OBJ_txt2obj(s, 1);
+ if(!obj) ossl_raise(eX509AttrError, NULL);
+ GetX509Attr(self, attr);
+ X509_ATTRIBUTE_set1_object(attr, obj);
+
+ return oid;
+}
+
+/*
+ * call-seq:
+ * attr.oid => string
+ */
+static VALUE
+ossl_x509attr_get_oid(VALUE self)
+{
+ X509_ATTRIBUTE *attr;
+ ASN1_OBJECT *oid;
+ BIO *out;
+ VALUE ret;
+ int nid;
+
+ GetX509Attr(self, attr);
+ oid = X509_ATTRIBUTE_get0_object(attr);
+ if ((nid = OBJ_obj2nid(oid)) != NID_undef)
+ ret = rb_str_new2(OBJ_nid2sn(nid));
+ else{
+ if (!(out = BIO_new(BIO_s_mem())))
+ ossl_raise(eX509AttrError, NULL);
+ i2a_ASN1_OBJECT(out, oid);
+ ret = ossl_membio2str(out);
+ }
+
+ return ret;
+}
+
+#if defined(HAVE_ST_X509_ATTRIBUTE_SINGLE) || defined(HAVE_ST_SINGLE)
+# define OSSL_X509ATTR_IS_SINGLE(attr) ((attr)->single)
+# define OSSL_X509ATTR_SET_SINGLE(attr) ((attr)->single = 1)
+#else
+# define OSSL_X509ATTR_IS_SINGLE(attr) (!(attr)->value.set)
+# define OSSL_X509ATTR_SET_SINGLE(attr) ((attr)->value.set = 0)
+#endif
+
+/*
+ * call-seq:
+ * attr.value = asn1 => asn1
+ */
+static VALUE
+ossl_x509attr_set_value(VALUE self, VALUE value)
+{
+ X509_ATTRIBUTE *attr;
+ ASN1_TYPE *a1type;
+
+ if(!(a1type = ossl_asn1_get_asn1type(value)))
+ ossl_raise(eASN1Error, "could not get ASN1_TYPE");
+ if(ASN1_TYPE_get(a1type) == V_ASN1_SEQUENCE){
+ ASN1_TYPE_free(a1type);
+ ossl_raise(eASN1Error, "couldn't set SEQUENCE for attribute value.");
+ }
+ GetX509Attr(self, attr);
+ if(attr->value.set){
+ if(OSSL_X509ATTR_IS_SINGLE(attr)) ASN1_TYPE_free(attr->value.single);
+ else sk_ASN1_TYPE_free(attr->value.set);
+ }
+ OSSL_X509ATTR_SET_SINGLE(attr);
+ attr->value.single = a1type;
+
+ return value;
+}
+
+/*
+ * call-seq:
+ * attr.value => asn1
+ */
+static VALUE
+ossl_x509attr_get_value(VALUE self)
+{
+ X509_ATTRIBUTE *attr;
+ VALUE str, asn1;
+ long length;
+ unsigned char *p;
+
+ GetX509Attr(self, attr);
+ if(attr->value.ptr == NULL) return Qnil;
+ if(OSSL_X509ATTR_IS_SINGLE(attr)){
+ length = i2d_ASN1_TYPE(attr->value.single, NULL);
+ str = rb_str_new(0, length);
+ p = (unsigned char *)RSTRING_PTR(str);
+ i2d_ASN1_TYPE(attr->value.single, &p);
+ ossl_str_adjust(str, p);
+ }
+ else{
+ length = i2d_ASN1_SET_OF_ASN1_TYPE(attr->value.set,
+ (unsigned char **) NULL, i2d_ASN1_TYPE,
+ V_ASN1_SET, V_ASN1_UNIVERSAL, 0);
+ str = rb_str_new(0, length);
+ p = (unsigned char *)RSTRING_PTR(str);
+ i2d_ASN1_SET_OF_ASN1_TYPE(attr->value.set, &p,
+ i2d_ASN1_TYPE, V_ASN1_SET, V_ASN1_UNIVERSAL, 0);
+ ossl_str_adjust(str, p);
+ }
+ asn1 = rb_funcall(mASN1, rb_intern("decode"), 1, str);
+
+ return asn1;
+}
+
+/*
+ * call-seq:
+ * attr.to_der => string
+ */
+static VALUE
+ossl_x509attr_to_der(VALUE self)
+{
+ X509_ATTRIBUTE *attr;
+ VALUE str;
+ int len;
+ unsigned char *p;
+
+ GetX509Attr(self, attr);
+ if((len = i2d_X509_ATTRIBUTE(attr, NULL)) <= 0)
+ ossl_raise(eX509AttrError, NULL);
+ str = rb_str_new(0, len);
+ p = (unsigned char *)RSTRING_PTR(str);
+ if(i2d_X509_ATTRIBUTE(attr, &p) <= 0)
+ ossl_raise(eX509AttrError, NULL);
+ rb_str_set_len(str, p - (unsigned char*)RSTRING_PTR(str));
+
+ return str;
+}
+
+/*
+ * X509_ATTRIBUTE init
+ */
+void
+Init_ossl_x509attr(void)
+{
+ eX509AttrError = rb_define_class_under(mX509, "AttributeError", eOSSLError);
+
+ cX509Attr = rb_define_class_under(mX509, "Attribute", rb_cObject);
+ rb_define_alloc_func(cX509Attr, ossl_x509attr_alloc);
+ rb_define_method(cX509Attr, "initialize", ossl_x509attr_initialize, -1);
+ rb_define_method(cX509Attr, "oid=", ossl_x509attr_set_oid, 1);
+ rb_define_method(cX509Attr, "oid", ossl_x509attr_get_oid, 0);
+ rb_define_method(cX509Attr, "value=", ossl_x509attr_set_value, 1);
+ rb_define_method(cX509Attr, "value", ossl_x509attr_get_value, 0);
+ rb_define_method(cX509Attr, "to_der", ossl_x509attr_to_der, 0);
+}
diff --git a/jni/ruby/ext/openssl/ossl_x509cert.c b/jni/ruby/ext/openssl/ossl_x509cert.c
new file mode 100644
index 0000000..175143e
--- /dev/null
+++ b/jni/ruby/ext/openssl/ossl_x509cert.c
@@ -0,0 +1,860 @@
+/*
+ * $Id: ossl_x509cert.c 48810 2014-12-12 23:38:55Z nobu $
+ * 'OpenSSL for Ruby' project
+ * Copyright (C) 2001-2002 Michal Rokos <m.rokos@sh.cvut.cz>
+ * All rights reserved.
+ */
+/*
+ * This program is licenced under the same licence as Ruby.
+ * (See the file 'LICENCE'.)
+ */
+#include "ossl.h"
+
+#define WrapX509(klass, obj, x509) do { \
+ if (!(x509)) { \
+ ossl_raise(rb_eRuntimeError, "CERT wasn't initialized!"); \
+ } \
+ (obj) = TypedData_Wrap_Struct((klass), &ossl_x509_type, (x509)); \
+} while (0)
+#define GetX509(obj, x509) do { \
+ TypedData_Get_Struct((obj), X509, &ossl_x509_type, (x509)); \
+ if (!(x509)) { \
+ ossl_raise(rb_eRuntimeError, "CERT wasn't initialized!"); \
+ } \
+} while (0)
+#define SafeGetX509(obj, x509) do { \
+ OSSL_Check_Kind((obj), cX509Cert); \
+ GetX509((obj), (x509)); \
+} while (0)
+
+/*
+ * Classes
+ */
+VALUE cX509Cert;
+VALUE eX509CertError;
+
+static void
+ossl_x509_free(void *ptr)
+{
+ X509_free(ptr);
+}
+
+static const rb_data_type_t ossl_x509_type = {
+ "OpenSSL/X509",
+ {
+ 0, ossl_x509_free,
+ },
+ 0, 0, RUBY_TYPED_FREE_IMMEDIATELY,
+};
+
+/*
+ * Public
+ */
+VALUE
+ossl_x509_new(X509 *x509)
+{
+ X509 *new;
+ VALUE obj;
+
+ if (!x509) {
+ new = X509_new();
+ } else {
+ new = X509_dup(x509);
+ }
+ if (!new) {
+ ossl_raise(eX509CertError, NULL);
+ }
+ WrapX509(cX509Cert, obj, new);
+
+ return obj;
+}
+
+VALUE
+ossl_x509_new_from_file(VALUE filename)
+{
+ X509 *x509;
+ FILE *fp;
+ VALUE obj;
+
+ SafeStringValue(filename);
+ if (!(fp = fopen(RSTRING_PTR(filename), "r"))) {
+ ossl_raise(eX509CertError, "%s", strerror(errno));
+ }
+ rb_fd_fix_cloexec(fileno(fp));
+ x509 = PEM_read_X509(fp, NULL, NULL, NULL);
+ /*
+ * prepare for DER...
+#if !defined(OPENSSL_NO_FP_API)
+ if (!x509) {
+ (void)ERR_get_error();
+ rewind(fp);
+
+ x509 = d2i_X509_fp(fp, NULL);
+ }
+#endif
+ */
+ fclose(fp);
+ if (!x509) {
+ ossl_raise(eX509CertError, NULL);
+ }
+ WrapX509(cX509Cert, obj, x509);
+
+ return obj;
+}
+
+X509 *
+GetX509CertPtr(VALUE obj)
+{
+ X509 *x509;
+
+ SafeGetX509(obj, x509);
+
+ return x509;
+}
+
+X509 *
+DupX509CertPtr(VALUE obj)
+{
+ X509 *x509;
+
+ SafeGetX509(obj, x509);
+
+ CRYPTO_add(&x509->references, 1, CRYPTO_LOCK_X509);
+
+ return x509;
+}
+
+/*
+ * Private
+ */
+static VALUE
+ossl_x509_alloc(VALUE klass)
+{
+ X509 *x509;
+ VALUE obj;
+
+ x509 = X509_new();
+ if (!x509) ossl_raise(eX509CertError, NULL);
+
+ WrapX509(klass, obj, x509);
+
+ return obj;
+}
+
+/*
+ * call-seq:
+ * Certificate.new => cert
+ * Certificate.new(string) => cert
+ */
+static VALUE
+ossl_x509_initialize(int argc, VALUE *argv, VALUE self)
+{
+ BIO *in;
+ X509 *x509, *x = DATA_PTR(self);
+ VALUE arg;
+
+ if (rb_scan_args(argc, argv, "01", &arg) == 0) {
+ /* create just empty X509Cert */
+ return self;
+ }
+ arg = ossl_to_der_if_possible(arg);
+ in = ossl_obj2bio(arg);
+ x509 = PEM_read_bio_X509(in, &x, NULL, NULL);
+ DATA_PTR(self) = x;
+ if (!x509) {
+ OSSL_BIO_reset(in);
+ x509 = d2i_X509_bio(in, &x);
+ DATA_PTR(self) = x;
+ }
+ BIO_free(in);
+ if (!x509) ossl_raise(eX509CertError, NULL);
+
+ return self;
+}
+
+static VALUE
+ossl_x509_copy(VALUE self, VALUE other)
+{
+ X509 *a, *b, *x509;
+
+ rb_check_frozen(self);
+ if (self == other) return self;
+
+ GetX509(self, a);
+ SafeGetX509(other, b);
+
+ x509 = X509_dup(b);
+ if (!x509) ossl_raise(eX509CertError, NULL);
+
+ DATA_PTR(self) = x509;
+ X509_free(a);
+
+ return self;
+}
+
+/*
+ * call-seq:
+ * cert.to_der => string
+ */
+static VALUE
+ossl_x509_to_der(VALUE self)
+{
+ X509 *x509;
+ VALUE str;
+ long len;
+ unsigned char *p;
+
+ GetX509(self, x509);
+ if ((len = i2d_X509(x509, NULL)) <= 0)
+ ossl_raise(eX509CertError, NULL);
+ str = rb_str_new(0, len);
+ p = (unsigned char *)RSTRING_PTR(str);
+ if (i2d_X509(x509, &p) <= 0)
+ ossl_raise(eX509CertError, NULL);
+ ossl_str_adjust(str, p);
+
+ return str;
+}
+
+/*
+ * call-seq:
+ * cert.to_pem => string
+ */
+static VALUE
+ossl_x509_to_pem(VALUE self)
+{
+ X509 *x509;
+ BIO *out;
+ VALUE str;
+
+ GetX509(self, x509);
+ out = BIO_new(BIO_s_mem());
+ if (!out) ossl_raise(eX509CertError, NULL);
+
+ if (!PEM_write_bio_X509(out, x509)) {
+ BIO_free(out);
+ ossl_raise(eX509CertError, NULL);
+ }
+ str = ossl_membio2str(out);
+
+ return str;
+}
+
+/*
+ * call-seq:
+ * cert.to_text => string
+ */
+static VALUE
+ossl_x509_to_text(VALUE self)
+{
+ X509 *x509;
+ BIO *out;
+ VALUE str;
+
+ GetX509(self, x509);
+
+ out = BIO_new(BIO_s_mem());
+ if (!out) ossl_raise(eX509CertError, NULL);
+
+ if (!X509_print(out, x509)) {
+ BIO_free(out);
+ ossl_raise(eX509CertError, NULL);
+ }
+ str = ossl_membio2str(out);
+
+ return str;
+}
+
+#if 0
+/*
+ * Makes from X509 X509_REQuest
+ */
+static VALUE
+ossl_x509_to_req(VALUE self)
+{
+ X509 *x509;
+ X509_REQ *req;
+ VALUE obj;
+
+ GetX509(self, x509);
+ if (!(req = X509_to_X509_REQ(x509, NULL, EVP_md5()))) {
+ ossl_raise(eX509CertError, NULL);
+ }
+ obj = ossl_x509req_new(req);
+ X509_REQ_free(req);
+
+ return obj;
+}
+#endif
+
+/*
+ * call-seq:
+ * cert.version => integer
+ */
+static VALUE
+ossl_x509_get_version(VALUE self)
+{
+ X509 *x509;
+
+ GetX509(self, x509);
+
+ return LONG2NUM(X509_get_version(x509));
+}
+
+/*
+ * call-seq:
+ * cert.version = integer => integer
+ */
+static VALUE
+ossl_x509_set_version(VALUE self, VALUE version)
+{
+ X509 *x509;
+ long ver;
+
+ if ((ver = NUM2LONG(version)) < 0) {
+ ossl_raise(eX509CertError, "version must be >= 0!");
+ }
+ GetX509(self, x509);
+ if (!X509_set_version(x509, ver)) {
+ ossl_raise(eX509CertError, NULL);
+ }
+
+ return version;
+}
+
+/*
+ * call-seq:
+ * cert.serial => integer
+ */
+static VALUE
+ossl_x509_get_serial(VALUE self)
+{
+ X509 *x509;
+
+ GetX509(self, x509);
+
+ return asn1integer_to_num(X509_get_serialNumber(x509));
+}
+
+/*
+ * call-seq:
+ * cert.serial = integer => integer
+ */
+static VALUE
+ossl_x509_set_serial(VALUE self, VALUE num)
+{
+ X509 *x509;
+
+ GetX509(self, x509);
+
+ x509->cert_info->serialNumber =
+ num_to_asn1integer(num, X509_get_serialNumber(x509));
+
+ return num;
+}
+
+/*
+ * call-seq:
+ * cert.signature_algorithm => string
+ */
+static VALUE
+ossl_x509_get_signature_algorithm(VALUE self)
+{
+ X509 *x509;
+ BIO *out;
+ VALUE str;
+
+ GetX509(self, x509);
+ out = BIO_new(BIO_s_mem());
+ if (!out) ossl_raise(eX509CertError, NULL);
+
+ if (!i2a_ASN1_OBJECT(out, x509->cert_info->signature->algorithm)) {
+ BIO_free(out);
+ ossl_raise(eX509CertError, NULL);
+ }
+ str = ossl_membio2str(out);
+
+ return str;
+}
+
+/*
+ * call-seq:
+ * cert.subject => name
+ */
+static VALUE
+ossl_x509_get_subject(VALUE self)
+{
+ X509 *x509;
+ X509_NAME *name;
+
+ GetX509(self, x509);
+ if (!(name = X509_get_subject_name(x509))) { /* NO DUP - don't free! */
+ ossl_raise(eX509CertError, NULL);
+ }
+
+ return ossl_x509name_new(name);
+}
+
+/*
+ * call-seq:
+ * cert.subject = name => name
+ */
+static VALUE
+ossl_x509_set_subject(VALUE self, VALUE subject)
+{
+ X509 *x509;
+
+ GetX509(self, x509);
+ if (!X509_set_subject_name(x509, GetX509NamePtr(subject))) { /* DUPs name */
+ ossl_raise(eX509CertError, NULL);
+ }
+
+ return subject;
+}
+
+/*
+ * call-seq:
+ * cert.issuer => name
+ */
+static VALUE
+ossl_x509_get_issuer(VALUE self)
+{
+ X509 *x509;
+ X509_NAME *name;
+
+ GetX509(self, x509);
+ if(!(name = X509_get_issuer_name(x509))) { /* NO DUP - don't free! */
+ ossl_raise(eX509CertError, NULL);
+ }
+
+ return ossl_x509name_new(name);
+}
+
+/*
+ * call-seq:
+ * cert.issuer = name => name
+ */
+static VALUE
+ossl_x509_set_issuer(VALUE self, VALUE issuer)
+{
+ X509 *x509;
+
+ GetX509(self, x509);
+ if (!X509_set_issuer_name(x509, GetX509NamePtr(issuer))) { /* DUPs name */
+ ossl_raise(eX509CertError, NULL);
+ }
+
+ return issuer;
+}
+
+/*
+ * call-seq:
+ * cert.not_before => time
+ */
+static VALUE
+ossl_x509_get_not_before(VALUE self)
+{
+ X509 *x509;
+ ASN1_UTCTIME *asn1time;
+
+ GetX509(self, x509);
+ if (!(asn1time = X509_get_notBefore(x509))) { /* NO DUP - don't free! */
+ ossl_raise(eX509CertError, NULL);
+ }
+
+ return asn1time_to_time(asn1time);
+}
+
+/*
+ * call-seq:
+ * cert.not_before = time => time
+ */
+static VALUE
+ossl_x509_set_not_before(VALUE self, VALUE time)
+{
+ X509 *x509;
+ time_t sec;
+
+ sec = time_to_time_t(time);
+ GetX509(self, x509);
+ if (!X509_time_adj(X509_get_notBefore(x509), 0, &sec)) {
+ ossl_raise(eX509CertError, NULL);
+ }
+
+ return time;
+}
+
+/*
+ * call-seq:
+ * cert.not_after => time
+ */
+static VALUE
+ossl_x509_get_not_after(VALUE self)
+{
+ X509 *x509;
+ ASN1_TIME *asn1time;
+
+ GetX509(self, x509);
+ if (!(asn1time = X509_get_notAfter(x509))) { /* NO DUP - don't free! */
+ ossl_raise(eX509CertError, NULL);
+ }
+
+ return asn1time_to_time(asn1time);
+}
+
+/*
+ * call-seq:
+ * cert.not_after = time => time
+ */
+static VALUE
+ossl_x509_set_not_after(VALUE self, VALUE time)
+{
+ X509 *x509;
+ time_t sec;
+
+ sec = time_to_time_t(time);
+ GetX509(self, x509);
+ if (!X509_time_adj(X509_get_notAfter(x509), 0, &sec)) {
+ ossl_raise(eX509CertError, NULL);
+ }
+
+ return time;
+}
+
+/*
+ * call-seq:
+ * cert.public_key => key
+ */
+static VALUE
+ossl_x509_get_public_key(VALUE self)
+{
+ X509 *x509;
+ EVP_PKEY *pkey;
+
+ GetX509(self, x509);
+ if (!(pkey = X509_get_pubkey(x509))) { /* adds an reference */
+ ossl_raise(eX509CertError, NULL);
+ }
+
+ return ossl_pkey_new(pkey); /* NO DUP - OK */
+}
+
+/*
+ * call-seq:
+ * cert.public_key = key => key
+ */
+static VALUE
+ossl_x509_set_public_key(VALUE self, VALUE key)
+{
+ X509 *x509;
+
+ GetX509(self, x509);
+ if (!X509_set_pubkey(x509, GetPKeyPtr(key))) { /* DUPs pkey */
+ ossl_raise(eX509CertError, NULL);
+ }
+
+ return key;
+}
+
+/*
+ * call-seq:
+ * cert.sign(key, digest) => self
+ */
+static VALUE
+ossl_x509_sign(VALUE self, VALUE key, VALUE digest)
+{
+ X509 *x509;
+ EVP_PKEY *pkey;
+ const EVP_MD *md;
+
+ pkey = GetPrivPKeyPtr(key); /* NO NEED TO DUP */
+ md = GetDigestPtr(digest);
+ GetX509(self, x509);
+ if (!X509_sign(x509, pkey, md)) {
+ ossl_raise(eX509CertError, NULL);
+ }
+
+ return self;
+}
+
+/*
+ * call-seq:
+ * cert.verify(key) => true | false
+ *
+ * Checks that cert signature is made with PRIVversion of this PUBLIC 'key'
+ */
+static VALUE
+ossl_x509_verify(VALUE self, VALUE key)
+{
+ X509 *x509;
+ EVP_PKEY *pkey;
+ int i;
+
+ pkey = GetPKeyPtr(key); /* NO NEED TO DUP */
+ GetX509(self, x509);
+ if ((i = X509_verify(x509, pkey)) < 0) {
+ ossl_raise(eX509CertError, NULL);
+ }
+ if (i > 0) {
+ return Qtrue;
+ }
+
+ return Qfalse;
+}
+
+/*
+ * call-seq:
+ * cert.check_private_key(key)
+ *
+ * Checks if 'key' is PRIV key for this cert
+ */
+static VALUE
+ossl_x509_check_private_key(VALUE self, VALUE key)
+{
+ X509 *x509;
+ EVP_PKEY *pkey;
+
+ /* not needed private key, but should be */
+ pkey = GetPrivPKeyPtr(key); /* NO NEED TO DUP */
+ GetX509(self, x509);
+ if (!X509_check_private_key(x509, pkey)) {
+ OSSL_Warning("Check private key:%s", OSSL_ErrMsg());
+ return Qfalse;
+ }
+
+ return Qtrue;
+}
+
+/*
+ * call-seq:
+ * cert.extensions => [extension...]
+ */
+static VALUE
+ossl_x509_get_extensions(VALUE self)
+{
+ X509 *x509;
+ int count, i;
+ X509_EXTENSION *ext;
+ VALUE ary;
+
+ GetX509(self, x509);
+ count = X509_get_ext_count(x509);
+ if (count < 0) {
+ return rb_ary_new();
+ }
+ ary = rb_ary_new2(count);
+ for (i=0; i<count; i++) {
+ ext = X509_get_ext(x509, i); /* NO DUP - don't free! */
+ rb_ary_push(ary, ossl_x509ext_new(ext));
+ }
+
+ return ary;
+}
+
+/*
+ * call-seq:
+ * cert.extensions = [ext...] => [ext...]
+ */
+static VALUE
+ossl_x509_set_extensions(VALUE self, VALUE ary)
+{
+ X509 *x509;
+ X509_EXTENSION *ext;
+ int i;
+
+ Check_Type(ary, T_ARRAY);
+ /* All ary's members should be X509Extension */
+ for (i=0; i<RARRAY_LEN(ary); i++) {
+ OSSL_Check_Kind(RARRAY_PTR(ary)[i], cX509Ext);
+ }
+ GetX509(self, x509);
+ sk_X509_EXTENSION_pop_free(x509->cert_info->extensions, X509_EXTENSION_free);
+ x509->cert_info->extensions = NULL;
+ for (i=0; i<RARRAY_LEN(ary); i++) {
+ ext = DupX509ExtPtr(RARRAY_PTR(ary)[i]);
+
+ if (!X509_add_ext(x509, ext, -1)) { /* DUPs ext - FREE it */
+ X509_EXTENSION_free(ext);
+ ossl_raise(eX509CertError, NULL);
+ }
+ X509_EXTENSION_free(ext);
+ }
+
+ return ary;
+}
+
+/*
+ * call-seq:
+ * cert.add_extension(extension) => extension
+ */
+static VALUE
+ossl_x509_add_extension(VALUE self, VALUE extension)
+{
+ X509 *x509;
+ X509_EXTENSION *ext;
+
+ GetX509(self, x509);
+ ext = DupX509ExtPtr(extension);
+ if (!X509_add_ext(x509, ext, -1)) { /* DUPs ext - FREE it */
+ X509_EXTENSION_free(ext);
+ ossl_raise(eX509CertError, NULL);
+ }
+ X509_EXTENSION_free(ext);
+
+ return extension;
+}
+
+static VALUE
+ossl_x509_inspect(VALUE self)
+{
+ return rb_sprintf("#<%"PRIsVALUE": subject=%+"PRIsVALUE", "
+ "issuer=%+"PRIsVALUE", serial=%+"PRIsVALUE", "
+ "not_before=%+"PRIsVALUE", not_after=%+"PRIsVALUE">",
+ rb_obj_class(self),
+ ossl_x509_get_subject(self),
+ ossl_x509_get_issuer(self),
+ ossl_x509_get_serial(self),
+ ossl_x509_get_not_before(self),
+ ossl_x509_get_not_after(self));
+}
+
+/*
+ * INIT
+ */
+void
+Init_ossl_x509cert(void)
+{
+
+#if 0
+ mOSSL = rb_define_module("OpenSSL"); /* let rdoc know about mOSSL */
+ mX509 = rb_define_module_under(mOSSL, "X509");
+#endif
+
+ eX509CertError = rb_define_class_under(mX509, "CertificateError", eOSSLError);
+
+ /* Document-class: OpenSSL::X509::Certificate
+ *
+ * Implementation of an X.509 certificate as specified in RFC 5280.
+ * Provides access to a certificate's attributes and allows certificates
+ * to be read from a string, but also supports the creation of new
+ * certificates from scratch.
+ *
+ * === Reading a certificate from a file
+ *
+ * Certificate is capable of handling DER-encoded certificates and
+ * certificates encoded in OpenSSL's PEM format.
+ *
+ * raw = File.read "cert.cer" # DER- or PEM-encoded
+ * certificate = OpenSSL::X509::Certificate.new raw
+ *
+ * === Saving a certificate to a file
+ *
+ * A certificate may be encoded in DER format
+ *
+ * cert = ...
+ * File.open("cert.cer", "wb") { |f| f.print cert.to_der }
+ *
+ * or in PEM format
+ *
+ * cert = ...
+ * File.open("cert.pem", "wb") { |f| f.print cert.to_pem }
+ *
+ * X.509 certificates are associated with a private/public key pair,
+ * typically a RSA, DSA or ECC key (see also OpenSSL::PKey::RSA,
+ * OpenSSL::PKey::DSA and OpenSSL::PKey::EC), the public key itself is
+ * stored within the certificate and can be accessed in form of an
+ * OpenSSL::PKey. Certificates are typically used to be able to associate
+ * some form of identity with a key pair, for example web servers serving
+ * pages over HTTPs use certificates to authenticate themselves to the user.
+ *
+ * The public key infrastructure (PKI) model relies on trusted certificate
+ * authorities ("root CAs") that issue these certificates, so that end
+ * users need to base their trust just on a selected few authorities
+ * that themselves again vouch for subordinate CAs issuing their
+ * certificates to end users.
+ *
+ * The OpenSSL::X509 module provides the tools to set up an independent
+ * PKI, similar to scenarios where the 'openssl' command line tool is
+ * used for issuing certificates in a private PKI.
+ *
+ * === Creating a root CA certificate and an end-entity certificate
+ *
+ * First, we need to create a "self-signed" root certificate. To do so,
+ * we need to generate a key first. Please note that the choice of "1"
+ * as a serial number is considered a security flaw for real certificates.
+ * Secure choices are integers in the two-digit byte range and ideally
+ * not sequential but secure random numbers, steps omitted here to keep
+ * the example concise.
+ *
+ * root_key = OpenSSL::PKey::RSA.new 2048 # the CA's public/private key
+ * root_ca = OpenSSL::X509::Certificate.new
+ * root_ca.version = 2 # cf. RFC 5280 - to make it a "v3" certificate
+ * root_ca.serial = 1
+ * root_ca.subject = OpenSSL::X509::Name.parse "/DC=org/DC=ruby-lang/CN=Ruby CA"
+ * root_ca.issuer = root_ca.subject # root CA's are "self-signed"
+ * root_ca.public_key = root_key.public_key
+ * root_ca.not_before = Time.now
+ * root_ca.not_after = root_ca.not_before + 2 * 365 * 24 * 60 * 60 # 2 years validity
+ * ef = OpenSSL::X509::ExtensionFactory.new
+ * ef.subject_certificate = root_ca
+ * ef.issuer_certificate = root_ca
+ * root_ca.add_extension(ef.create_extension("basicConstraints","CA:TRUE",true))
+ * root_ca.add_extension(ef.create_extension("keyUsage","keyCertSign, cRLSign", true))
+ * root_ca.add_extension(ef.create_extension("subjectKeyIdentifier","hash",false))
+ * root_ca.add_extension(ef.create_extension("authorityKeyIdentifier","keyid:always",false))
+ * root_ca.sign(root_key, OpenSSL::Digest::SHA256.new)
+ *
+ * The next step is to create the end-entity certificate using the root CA
+ * certificate.
+ *
+ * key = OpenSSL::PKey::RSA.new 2048
+ * cert = OpenSSL::X509::Certificate.new
+ * cert.version = 2
+ * cert.serial = 2
+ * cert.subject = OpenSSL::X509::Name.parse "/DC=org/DC=ruby-lang/CN=Ruby certificate"
+ * cert.issuer = root_ca.subject # root CA is the issuer
+ * cert.public_key = key.public_key
+ * cert.not_before = Time.now
+ * cert.not_after = cert.not_before + 1 * 365 * 24 * 60 * 60 # 1 years validity
+ * ef = OpenSSL::X509::ExtensionFactory.new
+ * ef.subject_certificate = cert
+ * ef.issuer_certificate = root_ca
+ * cert.add_extension(ef.create_extension("keyUsage","digitalSignature", true))
+ * cert.add_extension(ef.create_extension("subjectKeyIdentifier","hash",false))
+ * cert.sign(root_key, OpenSSL::Digest::SHA256.new)
+ *
+ */
+ cX509Cert = rb_define_class_under(mX509, "Certificate", rb_cObject);
+
+ rb_define_alloc_func(cX509Cert, ossl_x509_alloc);
+ rb_define_method(cX509Cert, "initialize", ossl_x509_initialize, -1);
+ rb_define_copy_func(cX509Cert, ossl_x509_copy);
+
+ rb_define_method(cX509Cert, "to_der", ossl_x509_to_der, 0);
+ rb_define_method(cX509Cert, "to_pem", ossl_x509_to_pem, 0);
+ rb_define_alias(cX509Cert, "to_s", "to_pem");
+ rb_define_method(cX509Cert, "to_text", ossl_x509_to_text, 0);
+ rb_define_method(cX509Cert, "version", ossl_x509_get_version, 0);
+ rb_define_method(cX509Cert, "version=", ossl_x509_set_version, 1);
+ rb_define_method(cX509Cert, "signature_algorithm", ossl_x509_get_signature_algorithm, 0);
+ rb_define_method(cX509Cert, "serial", ossl_x509_get_serial, 0);
+ rb_define_method(cX509Cert, "serial=", ossl_x509_set_serial, 1);
+ rb_define_method(cX509Cert, "subject", ossl_x509_get_subject, 0);
+ rb_define_method(cX509Cert, "subject=", ossl_x509_set_subject, 1);
+ rb_define_method(cX509Cert, "issuer", ossl_x509_get_issuer, 0);
+ rb_define_method(cX509Cert, "issuer=", ossl_x509_set_issuer, 1);
+ rb_define_method(cX509Cert, "not_before", ossl_x509_get_not_before, 0);
+ rb_define_method(cX509Cert, "not_before=", ossl_x509_set_not_before, 1);
+ rb_define_method(cX509Cert, "not_after", ossl_x509_get_not_after, 0);
+ rb_define_method(cX509Cert, "not_after=", ossl_x509_set_not_after, 1);
+ rb_define_method(cX509Cert, "public_key", ossl_x509_get_public_key, 0);
+ rb_define_method(cX509Cert, "public_key=", ossl_x509_set_public_key, 1);
+ rb_define_method(cX509Cert, "sign", ossl_x509_sign, 2);
+ rb_define_method(cX509Cert, "verify", ossl_x509_verify, 1);
+ rb_define_method(cX509Cert, "check_private_key", ossl_x509_check_private_key, 1);
+ rb_define_method(cX509Cert, "extensions", ossl_x509_get_extensions, 0);
+ rb_define_method(cX509Cert, "extensions=", ossl_x509_set_extensions, 1);
+ rb_define_method(cX509Cert, "add_extension", ossl_x509_add_extension, 1);
+ rb_define_method(cX509Cert, "inspect", ossl_x509_inspect, 0);
+}
+
diff --git a/jni/ruby/ext/openssl/ossl_x509crl.c b/jni/ruby/ext/openssl/ossl_x509crl.c
new file mode 100644
index 0000000..08421fd
--- /dev/null
+++ b/jni/ruby/ext/openssl/ossl_x509crl.c
@@ -0,0 +1,551 @@
+/*
+ * $Id: ossl_x509crl.c 48811 2014-12-12 23:39:04Z nobu $
+ * 'OpenSSL for Ruby' project
+ * Copyright (C) 2001-2002 Michal Rokos <m.rokos@sh.cvut.cz>
+ * All rights reserved.
+ */
+/*
+ * This program is licenced under the same licence as Ruby.
+ * (See the file 'LICENCE'.)
+ */
+#include "ossl.h"
+
+#define WrapX509CRL(klass, obj, crl) do { \
+ if (!(crl)) { \
+ ossl_raise(rb_eRuntimeError, "CRL wasn't initialized!"); \
+ } \
+ (obj) = TypedData_Wrap_Struct((klass), &ossl_x509crl_type, (crl)); \
+} while (0)
+#define GetX509CRL(obj, crl) do { \
+ TypedData_Get_Struct((obj), X509_CRL, &ossl_x509crl_type, (crl)); \
+ if (!(crl)) { \
+ ossl_raise(rb_eRuntimeError, "CRL wasn't initialized!"); \
+ } \
+} while (0)
+#define SafeGetX509CRL(obj, crl) do { \
+ OSSL_Check_Kind((obj), cX509CRL); \
+ GetX509CRL((obj), (crl)); \
+} while (0)
+
+/*
+ * Classes
+ */
+VALUE cX509CRL;
+VALUE eX509CRLError;
+
+static void
+ossl_x509crl_free(void *ptr)
+{
+ X509_CRL_free(ptr);
+}
+
+static const rb_data_type_t ossl_x509crl_type = {
+ "OpenSSL/X509/CRL",
+ {
+ 0, ossl_x509crl_free,
+ },
+ 0, 0, RUBY_TYPED_FREE_IMMEDIATELY,
+};
+
+/*
+ * PUBLIC
+ */
+X509_CRL *
+GetX509CRLPtr(VALUE obj)
+{
+ X509_CRL *crl;
+
+ SafeGetX509CRL(obj, crl);
+
+ return crl;
+}
+
+X509_CRL *
+DupX509CRLPtr(VALUE obj)
+{
+ X509_CRL *crl;
+
+ SafeGetX509CRL(obj, crl);
+ CRYPTO_add(&crl->references, 1, CRYPTO_LOCK_X509_CRL);
+
+ return crl;
+}
+
+VALUE
+ossl_x509crl_new(X509_CRL *crl)
+{
+ X509_CRL *tmp;
+ VALUE obj;
+
+ tmp = crl ? X509_CRL_dup(crl) : X509_CRL_new();
+ if(!tmp) ossl_raise(eX509CRLError, NULL);
+ WrapX509CRL(cX509CRL, obj, tmp);
+
+ return obj;
+}
+
+/*
+ * PRIVATE
+ */
+static VALUE
+ossl_x509crl_alloc(VALUE klass)
+{
+ X509_CRL *crl;
+ VALUE obj;
+
+ if (!(crl = X509_CRL_new())) {
+ ossl_raise(eX509CRLError, NULL);
+ }
+ WrapX509CRL(klass, obj, crl);
+
+ return obj;
+}
+
+static VALUE
+ossl_x509crl_initialize(int argc, VALUE *argv, VALUE self)
+{
+ BIO *in;
+ X509_CRL *crl, *x = DATA_PTR(self);
+ VALUE arg;
+
+ if (rb_scan_args(argc, argv, "01", &arg) == 0) {
+ return self;
+ }
+ arg = ossl_to_der_if_possible(arg);
+ in = ossl_obj2bio(arg);
+ crl = PEM_read_bio_X509_CRL(in, &x, NULL, NULL);
+ DATA_PTR(self) = x;
+ if (!crl) {
+ OSSL_BIO_reset(in);
+ crl = d2i_X509_CRL_bio(in, &x);
+ DATA_PTR(self) = x;
+ }
+ BIO_free(in);
+ if (!crl) ossl_raise(eX509CRLError, NULL);
+
+ return self;
+}
+
+static VALUE
+ossl_x509crl_copy(VALUE self, VALUE other)
+{
+ X509_CRL *a, *b, *crl;
+
+ rb_check_frozen(self);
+ if (self == other) return self;
+ GetX509CRL(self, a);
+ SafeGetX509CRL(other, b);
+ if (!(crl = X509_CRL_dup(b))) {
+ ossl_raise(eX509CRLError, NULL);
+ }
+ X509_CRL_free(a);
+ DATA_PTR(self) = crl;
+
+ return self;
+}
+
+static VALUE
+ossl_x509crl_get_version(VALUE self)
+{
+ X509_CRL *crl;
+ long ver;
+
+ GetX509CRL(self, crl);
+ ver = X509_CRL_get_version(crl);
+
+ return LONG2NUM(ver);
+}
+
+static VALUE
+ossl_x509crl_set_version(VALUE self, VALUE version)
+{
+ X509_CRL *crl;
+ long ver;
+
+ if ((ver = NUM2LONG(version)) < 0) {
+ ossl_raise(eX509CRLError, "version must be >= 0!");
+ }
+ GetX509CRL(self, crl);
+ if (!X509_CRL_set_version(crl, ver)) {
+ ossl_raise(eX509CRLError, NULL);
+ }
+
+ return version;
+}
+
+static VALUE
+ossl_x509crl_get_signature_algorithm(VALUE self)
+{
+ X509_CRL *crl;
+ BIO *out;
+ BUF_MEM *buf;
+ VALUE str;
+
+ GetX509CRL(self, crl);
+ if (!(out = BIO_new(BIO_s_mem()))) {
+ ossl_raise(eX509CRLError, NULL);
+ }
+ if (!i2a_ASN1_OBJECT(out, crl->sig_alg->algorithm)) {
+ BIO_free(out);
+ ossl_raise(eX509CRLError, NULL);
+ }
+ BIO_get_mem_ptr(out, &buf);
+ str = rb_str_new(buf->data, buf->length);
+ BIO_free(out);
+ return str;
+}
+
+static VALUE
+ossl_x509crl_get_issuer(VALUE self)
+{
+ X509_CRL *crl;
+
+ GetX509CRL(self, crl);
+
+ return ossl_x509name_new(X509_CRL_get_issuer(crl)); /* NO DUP - don't free */
+}
+
+static VALUE
+ossl_x509crl_set_issuer(VALUE self, VALUE issuer)
+{
+ X509_CRL *crl;
+
+ GetX509CRL(self, crl);
+
+ if (!X509_CRL_set_issuer_name(crl, GetX509NamePtr(issuer))) { /* DUPs name */
+ ossl_raise(eX509CRLError, NULL);
+ }
+ return issuer;
+}
+
+static VALUE
+ossl_x509crl_get_last_update(VALUE self)
+{
+ X509_CRL *crl;
+
+ GetX509CRL(self, crl);
+
+ return asn1time_to_time(X509_CRL_get_lastUpdate(crl));
+}
+
+static VALUE
+ossl_x509crl_set_last_update(VALUE self, VALUE time)
+{
+ X509_CRL *crl;
+ time_t sec;
+
+ sec = time_to_time_t(time);
+ GetX509CRL(self, crl);
+ if (!X509_time_adj(crl->crl->lastUpdate, 0, &sec)) {
+ ossl_raise(eX509CRLError, NULL);
+ }
+
+ return time;
+}
+
+static VALUE
+ossl_x509crl_get_next_update(VALUE self)
+{
+ X509_CRL *crl;
+
+ GetX509CRL(self, crl);
+
+ return asn1time_to_time(X509_CRL_get_nextUpdate(crl));
+}
+
+static VALUE
+ossl_x509crl_set_next_update(VALUE self, VALUE time)
+{
+ X509_CRL *crl;
+ time_t sec;
+
+ sec = time_to_time_t(time);
+ GetX509CRL(self, crl);
+ /* This must be some thinko in OpenSSL */
+ if (!(crl->crl->nextUpdate = X509_time_adj(crl->crl->nextUpdate, 0, &sec))){
+ ossl_raise(eX509CRLError, NULL);
+ }
+
+ return time;
+}
+
+static VALUE
+ossl_x509crl_get_revoked(VALUE self)
+{
+ X509_CRL *crl;
+ int i, num;
+ X509_REVOKED *rev;
+ VALUE ary, revoked;
+
+ GetX509CRL(self, crl);
+ num = sk_X509_REVOKED_num(X509_CRL_get_REVOKED(crl));
+ if (num < 0) {
+ OSSL_Debug("num < 0???");
+ return rb_ary_new();
+ }
+ ary = rb_ary_new2(num);
+ for(i=0; i<num; i++) {
+ /* NO DUP - don't free! */
+ rev = sk_X509_REVOKED_value(X509_CRL_get_REVOKED(crl), i);
+ revoked = ossl_x509revoked_new(rev);
+ rb_ary_push(ary, revoked);
+ }
+
+ return ary;
+}
+
+static VALUE
+ossl_x509crl_set_revoked(VALUE self, VALUE ary)
+{
+ X509_CRL *crl;
+ X509_REVOKED *rev;
+ int i;
+
+ Check_Type(ary, T_ARRAY);
+ /* All ary members should be X509 Revoked */
+ for (i=0; i<RARRAY_LEN(ary); i++) {
+ OSSL_Check_Kind(RARRAY_PTR(ary)[i], cX509Rev);
+ }
+ GetX509CRL(self, crl);
+ sk_X509_REVOKED_pop_free(crl->crl->revoked, X509_REVOKED_free);
+ crl->crl->revoked = NULL;
+ for (i=0; i<RARRAY_LEN(ary); i++) {
+ rev = DupX509RevokedPtr(RARRAY_PTR(ary)[i]);
+ if (!X509_CRL_add0_revoked(crl, rev)) { /* NO DUP - don't free! */
+ ossl_raise(eX509CRLError, NULL);
+ }
+ }
+ X509_CRL_sort(crl);
+
+ return ary;
+}
+
+static VALUE
+ossl_x509crl_add_revoked(VALUE self, VALUE revoked)
+{
+ X509_CRL *crl;
+ X509_REVOKED *rev;
+
+ GetX509CRL(self, crl);
+ rev = DupX509RevokedPtr(revoked);
+ if (!X509_CRL_add0_revoked(crl, rev)) { /* NO DUP - don't free! */
+ ossl_raise(eX509CRLError, NULL);
+ }
+ X509_CRL_sort(crl);
+
+ return revoked;
+}
+
+static VALUE
+ossl_x509crl_sign(VALUE self, VALUE key, VALUE digest)
+{
+ X509_CRL *crl;
+ EVP_PKEY *pkey;
+ const EVP_MD *md;
+
+ GetX509CRL(self, crl);
+ pkey = GetPrivPKeyPtr(key); /* NO NEED TO DUP */
+ md = GetDigestPtr(digest);
+ if (!X509_CRL_sign(crl, pkey, md)) {
+ ossl_raise(eX509CRLError, NULL);
+ }
+
+ return self;
+}
+
+static VALUE
+ossl_x509crl_verify(VALUE self, VALUE key)
+{
+ X509_CRL *crl;
+ int ret;
+
+ GetX509CRL(self, crl);
+ if ((ret = X509_CRL_verify(crl, GetPKeyPtr(key))) < 0) {
+ ossl_raise(eX509CRLError, NULL);
+ }
+ if (ret == 1) {
+ return Qtrue;
+ }
+
+ return Qfalse;
+}
+
+static VALUE
+ossl_x509crl_to_der(VALUE self)
+{
+ X509_CRL *crl;
+ BIO *out;
+ BUF_MEM *buf;
+ VALUE str;
+
+ GetX509CRL(self, crl);
+ if (!(out = BIO_new(BIO_s_mem()))) {
+ ossl_raise(eX509CRLError, NULL);
+ }
+ if (!i2d_X509_CRL_bio(out, crl)) {
+ BIO_free(out);
+ ossl_raise(eX509CRLError, NULL);
+ }
+ BIO_get_mem_ptr(out, &buf);
+ str = rb_str_new(buf->data, buf->length);
+ BIO_free(out);
+
+ return str;
+}
+
+static VALUE
+ossl_x509crl_to_pem(VALUE self)
+{
+ X509_CRL *crl;
+ BIO *out;
+ BUF_MEM *buf;
+ VALUE str;
+
+ GetX509CRL(self, crl);
+ if (!(out = BIO_new(BIO_s_mem()))) {
+ ossl_raise(eX509CRLError, NULL);
+ }
+ if (!PEM_write_bio_X509_CRL(out, crl)) {
+ BIO_free(out);
+ ossl_raise(eX509CRLError, NULL);
+ }
+ BIO_get_mem_ptr(out, &buf);
+ str = rb_str_new(buf->data, buf->length);
+ BIO_free(out);
+
+ return str;
+}
+
+static VALUE
+ossl_x509crl_to_text(VALUE self)
+{
+ X509_CRL *crl;
+ BIO *out;
+ BUF_MEM *buf;
+ VALUE str;
+
+ GetX509CRL(self, crl);
+ if (!(out = BIO_new(BIO_s_mem()))) {
+ ossl_raise(eX509CRLError, NULL);
+ }
+ if (!X509_CRL_print(out, crl)) {
+ BIO_free(out);
+ ossl_raise(eX509CRLError, NULL);
+ }
+ BIO_get_mem_ptr(out, &buf);
+ str = rb_str_new(buf->data, buf->length);
+ BIO_free(out);
+
+ return str;
+}
+
+/*
+ * Gets X509v3 extensions as array of X509Ext objects
+ */
+static VALUE
+ossl_x509crl_get_extensions(VALUE self)
+{
+ X509_CRL *crl;
+ int count, i;
+ X509_EXTENSION *ext;
+ VALUE ary;
+
+ GetX509CRL(self, crl);
+ count = X509_CRL_get_ext_count(crl);
+ if (count < 0) {
+ OSSL_Debug("count < 0???");
+ return rb_ary_new();
+ }
+ ary = rb_ary_new2(count);
+ for (i=0; i<count; i++) {
+ ext = X509_CRL_get_ext(crl, i); /* NO DUP - don't free! */
+ rb_ary_push(ary, ossl_x509ext_new(ext));
+ }
+
+ return ary;
+}
+
+/*
+ * Sets X509_EXTENSIONs
+ */
+static VALUE
+ossl_x509crl_set_extensions(VALUE self, VALUE ary)
+{
+ X509_CRL *crl;
+ X509_EXTENSION *ext;
+ int i;
+
+ Check_Type(ary, T_ARRAY);
+ /* All ary members should be X509 Extensions */
+ for (i=0; i<RARRAY_LEN(ary); i++) {
+ OSSL_Check_Kind(RARRAY_PTR(ary)[i], cX509Ext);
+ }
+ GetX509CRL(self, crl);
+ sk_X509_EXTENSION_pop_free(crl->crl->extensions, X509_EXTENSION_free);
+ crl->crl->extensions = NULL;
+ for (i=0; i<RARRAY_LEN(ary); i++) {
+ ext = DupX509ExtPtr(RARRAY_PTR(ary)[i]);
+ if(!X509_CRL_add_ext(crl, ext, -1)) { /* DUPs ext - FREE it */
+ X509_EXTENSION_free(ext);
+ ossl_raise(eX509CRLError, NULL);
+ }
+ X509_EXTENSION_free(ext);
+ }
+
+ return ary;
+}
+
+static VALUE
+ossl_x509crl_add_extension(VALUE self, VALUE extension)
+{
+ X509_CRL *crl;
+ X509_EXTENSION *ext;
+
+ GetX509CRL(self, crl);
+ ext = DupX509ExtPtr(extension);
+ if (!X509_CRL_add_ext(crl, ext, -1)) { /* DUPs ext - FREE it */
+ X509_EXTENSION_free(ext);
+ ossl_raise(eX509CRLError, NULL);
+ }
+ X509_EXTENSION_free(ext);
+
+ return extension;
+}
+
+/*
+ * INIT
+ */
+void
+Init_ossl_x509crl(void)
+{
+ eX509CRLError = rb_define_class_under(mX509, "CRLError", eOSSLError);
+
+ cX509CRL = rb_define_class_under(mX509, "CRL", rb_cObject);
+
+ rb_define_alloc_func(cX509CRL, ossl_x509crl_alloc);
+ rb_define_method(cX509CRL, "initialize", ossl_x509crl_initialize, -1);
+ rb_define_copy_func(cX509CRL, ossl_x509crl_copy);
+
+ rb_define_method(cX509CRL, "version", ossl_x509crl_get_version, 0);
+ rb_define_method(cX509CRL, "version=", ossl_x509crl_set_version, 1);
+ rb_define_method(cX509CRL, "signature_algorithm", ossl_x509crl_get_signature_algorithm, 0);
+ rb_define_method(cX509CRL, "issuer", ossl_x509crl_get_issuer, 0);
+ rb_define_method(cX509CRL, "issuer=", ossl_x509crl_set_issuer, 1);
+ rb_define_method(cX509CRL, "last_update", ossl_x509crl_get_last_update, 0);
+ rb_define_method(cX509CRL, "last_update=", ossl_x509crl_set_last_update, 1);
+ rb_define_method(cX509CRL, "next_update", ossl_x509crl_get_next_update, 0);
+ rb_define_method(cX509CRL, "next_update=", ossl_x509crl_set_next_update, 1);
+ rb_define_method(cX509CRL, "revoked", ossl_x509crl_get_revoked, 0);
+ rb_define_method(cX509CRL, "revoked=", ossl_x509crl_set_revoked, 1);
+ rb_define_method(cX509CRL, "add_revoked", ossl_x509crl_add_revoked, 1);
+ rb_define_method(cX509CRL, "sign", ossl_x509crl_sign, 2);
+ rb_define_method(cX509CRL, "verify", ossl_x509crl_verify, 1);
+ rb_define_method(cX509CRL, "to_der", ossl_x509crl_to_der, 0);
+ rb_define_method(cX509CRL, "to_pem", ossl_x509crl_to_pem, 0);
+ rb_define_alias(cX509CRL, "to_s", "to_pem");
+ rb_define_method(cX509CRL, "to_text", ossl_x509crl_to_text, 0);
+ rb_define_method(cX509CRL, "extensions", ossl_x509crl_get_extensions, 0);
+ rb_define_method(cX509CRL, "extensions=", ossl_x509crl_set_extensions, 1);
+ rb_define_method(cX509CRL, "add_extension", ossl_x509crl_add_extension, 1);
+}
+
diff --git a/jni/ruby/ext/openssl/ossl_x509ext.c b/jni/ruby/ext/openssl/ossl_x509ext.c
new file mode 100644
index 0000000..4250d00
--- /dev/null
+++ b/jni/ruby/ext/openssl/ossl_x509ext.c
@@ -0,0 +1,493 @@
+/*
+ * $Id: ossl_x509ext.c 48813 2014-12-12 23:46:42Z nobu $
+ * 'OpenSSL for Ruby' project
+ * Copyright (C) 2001-2002 Michal Rokos <m.rokos@sh.cvut.cz>
+ * All rights reserved.
+ */
+/*
+ * This program is licenced under the same licence as Ruby.
+ * (See the file 'LICENCE'.)
+ */
+#include "ossl.h"
+
+#define WrapX509Ext(klass, obj, ext) do { \
+ if (!(ext)) { \
+ ossl_raise(rb_eRuntimeError, "EXT wasn't initialized!"); \
+ } \
+ (obj) = TypedData_Wrap_Struct((klass), &ossl_x509ext_type, (ext)); \
+} while (0)
+#define GetX509Ext(obj, ext) do { \
+ TypedData_Get_Struct((obj), X509_EXTENSION, &ossl_x509ext_type, (ext)); \
+ if (!(ext)) { \
+ ossl_raise(rb_eRuntimeError, "EXT wasn't initialized!"); \
+ } \
+} while (0)
+#define SafeGetX509Ext(obj, ext) do { \
+ OSSL_Check_Kind((obj), cX509Ext); \
+ GetX509Ext((obj), (ext)); \
+} while (0)
+#define MakeX509ExtFactory(klass, obj, ctx) do { \
+ if (!((ctx) = OPENSSL_malloc(sizeof(X509V3_CTX)))) \
+ ossl_raise(rb_eRuntimeError, "CTX wasn't allocated!"); \
+ X509V3_set_ctx((ctx), NULL, NULL, NULL, NULL, 0); \
+ (obj) = TypedData_Wrap_Struct((klass), &ossl_x509extfactory_type, (ctx)); \
+} while (0)
+#define GetX509ExtFactory(obj, ctx) do { \
+ TypedData_Get_Struct((obj), X509V3_CTX, &ossl_x509extfactory_type, (ctx)); \
+ if (!(ctx)) { \
+ ossl_raise(rb_eRuntimeError, "CTX wasn't initialized!"); \
+ } \
+} while (0)
+
+/*
+ * Classes
+ */
+VALUE cX509Ext;
+VALUE cX509ExtFactory;
+VALUE eX509ExtError;
+
+static void
+ossl_x509ext_free(void *ptr)
+{
+ X509_EXTENSION_free(ptr);
+}
+
+static const rb_data_type_t ossl_x509ext_type = {
+ "OpenSSL/X509/EXTENSION",
+ {
+ 0, ossl_x509ext_free,
+ },
+ 0, 0, RUBY_TYPED_FREE_IMMEDIATELY,
+};
+
+/*
+ * Public
+ */
+VALUE
+ossl_x509ext_new(X509_EXTENSION *ext)
+{
+ X509_EXTENSION *new;
+ VALUE obj;
+
+ if (!ext) {
+ new = X509_EXTENSION_new();
+ } else {
+ new = X509_EXTENSION_dup(ext);
+ }
+ if (!new) {
+ ossl_raise(eX509ExtError, NULL);
+ }
+ WrapX509Ext(cX509Ext, obj, new);
+
+ return obj;
+}
+
+X509_EXTENSION *
+GetX509ExtPtr(VALUE obj)
+{
+ X509_EXTENSION *ext;
+
+ SafeGetX509Ext(obj, ext);
+
+ return ext;
+}
+
+X509_EXTENSION *
+DupX509ExtPtr(VALUE obj)
+{
+ X509_EXTENSION *ext, *new;
+
+ SafeGetX509Ext(obj, ext);
+ if (!(new = X509_EXTENSION_dup(ext))) {
+ ossl_raise(eX509ExtError, NULL);
+ }
+
+ return new;
+}
+
+/*
+ * Private
+ */
+/*
+ * Ext factory
+ */
+static void
+ossl_x509extfactory_free(void *ctx)
+{
+ OPENSSL_free(ctx);
+}
+
+static const rb_data_type_t ossl_x509extfactory_type = {
+ "OpenSSL/X509/EXTENSION/Factory",
+ {
+ 0, ossl_x509extfactory_free,
+ },
+ 0, 0, RUBY_TYPED_FREE_IMMEDIATELY,
+};
+
+static VALUE
+ossl_x509extfactory_alloc(VALUE klass)
+{
+ X509V3_CTX *ctx;
+ VALUE obj;
+
+ MakeX509ExtFactory(klass, obj, ctx);
+ rb_iv_set(obj, "@config", Qnil);
+
+ return obj;
+}
+
+static VALUE
+ossl_x509extfactory_set_issuer_cert(VALUE self, VALUE cert)
+{
+ X509V3_CTX *ctx;
+
+ GetX509ExtFactory(self, ctx);
+ rb_iv_set(self, "@issuer_certificate", cert);
+ ctx->issuer_cert = GetX509CertPtr(cert); /* NO DUP NEEDED */
+
+ return cert;
+}
+
+static VALUE
+ossl_x509extfactory_set_subject_cert(VALUE self, VALUE cert)
+{
+ X509V3_CTX *ctx;
+
+ GetX509ExtFactory(self, ctx);
+ rb_iv_set(self, "@subject_certificate", cert);
+ ctx->subject_cert = GetX509CertPtr(cert); /* NO DUP NEEDED */
+
+ return cert;
+}
+
+static VALUE
+ossl_x509extfactory_set_subject_req(VALUE self, VALUE req)
+{
+ X509V3_CTX *ctx;
+
+ GetX509ExtFactory(self, ctx);
+ rb_iv_set(self, "@subject_request", req);
+ ctx->subject_req = GetX509ReqPtr(req); /* NO DUP NEEDED */
+
+ return req;
+}
+
+static VALUE
+ossl_x509extfactory_set_crl(VALUE self, VALUE crl)
+{
+ X509V3_CTX *ctx;
+
+ GetX509ExtFactory(self, ctx);
+ rb_iv_set(self, "@crl", crl);
+ ctx->crl = GetX509CRLPtr(crl); /* NO DUP NEEDED */
+
+ return crl;
+}
+
+#ifdef HAVE_X509V3_SET_NCONF
+static VALUE
+ossl_x509extfactory_set_config(VALUE self, VALUE config)
+{
+ X509V3_CTX *ctx;
+ CONF *conf;
+
+ GetX509ExtFactory(self, ctx);
+ rb_iv_set(self, "@config", config);
+ conf = GetConfigPtr(config); /* NO DUP NEEDED */
+ X509V3_set_nconf(ctx, conf);
+
+ return config;
+}
+#else
+#define ossl_x509extfactory_set_config rb_f_notimplement
+#endif
+
+static VALUE
+ossl_x509extfactory_initialize(int argc, VALUE *argv, VALUE self)
+{
+ /*X509V3_CTX *ctx;*/
+ VALUE issuer_cert, subject_cert, subject_req, crl;
+
+ /*GetX509ExtFactory(self, ctx);*/
+
+ rb_scan_args(argc, argv, "04",
+ &issuer_cert, &subject_cert, &subject_req, &crl);
+ if (!NIL_P(issuer_cert))
+ ossl_x509extfactory_set_issuer_cert(self, issuer_cert);
+ if (!NIL_P(subject_cert))
+ ossl_x509extfactory_set_subject_cert(self, subject_cert);
+ if (!NIL_P(subject_req))
+ ossl_x509extfactory_set_subject_req(self, subject_req);
+ if (!NIL_P(crl))
+ ossl_x509extfactory_set_crl(self, crl);
+
+ return self;
+}
+
+/*
+ * Array to X509_EXTENSION
+ * Structure:
+ * ["ln", "value", bool_critical] or
+ * ["sn", "value", bool_critical] or
+ * ["ln", "critical,value"] or the same for sn
+ * ["ln", "value"] => not critical
+ */
+static VALUE
+ossl_x509extfactory_create_ext(int argc, VALUE *argv, VALUE self)
+{
+ X509V3_CTX *ctx;
+ X509_EXTENSION *ext;
+ VALUE oid, value, critical, valstr, obj;
+ int nid;
+#ifdef HAVE_X509V3_EXT_NCONF_NID
+ VALUE rconf;
+ CONF *conf;
+#else
+ static LHASH *empty_lhash;
+#endif
+
+ rb_scan_args(argc, argv, "21", &oid, &value, &critical);
+ StringValue(oid);
+ StringValue(value);
+ if(NIL_P(critical)) critical = Qfalse;
+
+ nid = OBJ_ln2nid(RSTRING_PTR(oid));
+ if(!nid) nid = OBJ_sn2nid(RSTRING_PTR(oid));
+ if(!nid) ossl_raise(eX509ExtError, "unknown OID `%s'", RSTRING_PTR(oid));
+ valstr = rb_str_new2(RTEST(critical) ? "critical," : "");
+ rb_str_append(valstr, value);
+ GetX509ExtFactory(self, ctx);
+#ifdef HAVE_X509V3_EXT_NCONF_NID
+ rconf = rb_iv_get(self, "@config");
+ conf = NIL_P(rconf) ? NULL : GetConfigPtr(rconf);
+ ext = X509V3_EXT_nconf_nid(conf, ctx, nid, RSTRING_PTR(valstr));
+#else
+ if (!empty_lhash) empty_lhash = lh_new(NULL, NULL);
+ ext = X509V3_EXT_conf_nid(empty_lhash, ctx, nid, RSTRING_PTR(valstr));
+#endif
+ if (!ext){
+ ossl_raise(eX509ExtError, "%s = %s",
+ RSTRING_PTR(oid), RSTRING_PTR(value));
+ }
+ WrapX509Ext(cX509Ext, obj, ext);
+
+ return obj;
+}
+
+/*
+ * Ext
+ */
+static VALUE
+ossl_x509ext_alloc(VALUE klass)
+{
+ X509_EXTENSION *ext;
+ VALUE obj;
+
+ if(!(ext = X509_EXTENSION_new())){
+ ossl_raise(eX509ExtError, NULL);
+ }
+ WrapX509Ext(klass, obj, ext);
+
+ return obj;
+}
+
+/*
+ * call-seq:
+ * OpenSSL::X509::Extension.new asn1
+ * OpenSSL::X509::Extension.new name, value
+ * OpenSSL::X509::Extension.new name, value, critical
+ *
+ * Creates an X509 extension.
+ *
+ * The extension may be created from +asn1+ data or from an extension +name+
+ * and +value+. The +name+ may be either an OID or an extension name. If
+ * +critical+ is true the extension is marked critical.
+ */
+static VALUE
+ossl_x509ext_initialize(int argc, VALUE *argv, VALUE self)
+{
+ VALUE oid, value, critical;
+ const unsigned char *p;
+ X509_EXTENSION *ext, *x;
+
+ GetX509Ext(self, ext);
+ if(rb_scan_args(argc, argv, "12", &oid, &value, &critical) == 1){
+ oid = ossl_to_der_if_possible(oid);
+ StringValue(oid);
+ p = (unsigned char *)RSTRING_PTR(oid);
+ x = d2i_X509_EXTENSION(&ext, &p, RSTRING_LEN(oid));
+ DATA_PTR(self) = ext;
+ if(!x)
+ ossl_raise(eX509ExtError, NULL);
+ return self;
+ }
+ rb_funcall(self, rb_intern("oid="), 1, oid);
+ rb_funcall(self, rb_intern("value="), 1, value);
+ if(argc > 2) rb_funcall(self, rb_intern("critical="), 1, critical);
+
+ return self;
+}
+
+static VALUE
+ossl_x509ext_set_oid(VALUE self, VALUE oid)
+{
+ X509_EXTENSION *ext;
+ ASN1_OBJECT *obj;
+ char *s;
+
+ s = StringValuePtr(oid);
+ obj = OBJ_txt2obj(s, 0);
+ if(!obj) obj = OBJ_txt2obj(s, 1);
+ if(!obj) ossl_raise(eX509ExtError, NULL);
+ GetX509Ext(self, ext);
+ X509_EXTENSION_set_object(ext, obj);
+
+ return oid;
+}
+
+static VALUE
+ossl_x509ext_set_value(VALUE self, VALUE data)
+{
+ X509_EXTENSION *ext;
+ ASN1_OCTET_STRING *asn1s;
+ char *s;
+
+ data = ossl_to_der_if_possible(data);
+ StringValue(data);
+ if(!(s = OPENSSL_malloc(RSTRING_LEN(data))))
+ ossl_raise(eX509ExtError, "malloc error");
+ memcpy(s, RSTRING_PTR(data), RSTRING_LEN(data));
+ if(!(asn1s = ASN1_OCTET_STRING_new())){
+ OPENSSL_free(s);
+ ossl_raise(eX509ExtError, NULL);
+ }
+ if(!M_ASN1_OCTET_STRING_set(asn1s, s, RSTRING_LENINT(data))){
+ OPENSSL_free(s);
+ ASN1_OCTET_STRING_free(asn1s);
+ ossl_raise(eX509ExtError, NULL);
+ }
+ OPENSSL_free(s);
+ GetX509Ext(self, ext);
+ X509_EXTENSION_set_data(ext, asn1s);
+
+ return data;
+}
+
+static VALUE
+ossl_x509ext_set_critical(VALUE self, VALUE flag)
+{
+ X509_EXTENSION *ext;
+
+ GetX509Ext(self, ext);
+ X509_EXTENSION_set_critical(ext, RTEST(flag) ? 1 : 0);
+
+ return flag;
+}
+
+static VALUE
+ossl_x509ext_get_oid(VALUE obj)
+{
+ X509_EXTENSION *ext;
+ ASN1_OBJECT *extobj;
+ BIO *out;
+ VALUE ret;
+ int nid;
+
+ GetX509Ext(obj, ext);
+ extobj = X509_EXTENSION_get_object(ext);
+ if ((nid = OBJ_obj2nid(extobj)) != NID_undef)
+ ret = rb_str_new2(OBJ_nid2sn(nid));
+ else{
+ if (!(out = BIO_new(BIO_s_mem())))
+ ossl_raise(eX509ExtError, NULL);
+ i2a_ASN1_OBJECT(out, extobj);
+ ret = ossl_membio2str(out);
+ }
+
+ return ret;
+}
+
+static VALUE
+ossl_x509ext_get_value(VALUE obj)
+{
+ X509_EXTENSION *ext;
+ BIO *out;
+ VALUE ret;
+
+ GetX509Ext(obj, ext);
+ if (!(out = BIO_new(BIO_s_mem())))
+ ossl_raise(eX509ExtError, NULL);
+ if (!X509V3_EXT_print(out, ext, 0, 0))
+ M_ASN1_OCTET_STRING_print(out, ext->value);
+ ret = ossl_membio2str(out);
+
+ return ret;
+}
+
+static VALUE
+ossl_x509ext_get_critical(VALUE obj)
+{
+ X509_EXTENSION *ext;
+
+ GetX509Ext(obj, ext);
+ return X509_EXTENSION_get_critical(ext) ? Qtrue : Qfalse;
+}
+
+static VALUE
+ossl_x509ext_to_der(VALUE obj)
+{
+ X509_EXTENSION *ext;
+ unsigned char *p;
+ long len;
+ VALUE str;
+
+ GetX509Ext(obj, ext);
+ if((len = i2d_X509_EXTENSION(ext, NULL)) <= 0)
+ ossl_raise(eX509ExtError, NULL);
+ str = rb_str_new(0, len);
+ p = (unsigned char *)RSTRING_PTR(str);
+ if(i2d_X509_EXTENSION(ext, &p) < 0)
+ ossl_raise(eX509ExtError, NULL);
+ ossl_str_adjust(str, p);
+
+ return str;
+}
+
+/*
+ * INIT
+ */
+void
+Init_ossl_x509ext(void)
+{
+ eX509ExtError = rb_define_class_under(mX509, "ExtensionError", eOSSLError);
+
+ cX509ExtFactory = rb_define_class_under(mX509, "ExtensionFactory", rb_cObject);
+
+ rb_define_alloc_func(cX509ExtFactory, ossl_x509extfactory_alloc);
+ rb_define_method(cX509ExtFactory, "initialize", ossl_x509extfactory_initialize, -1);
+
+ rb_attr(cX509ExtFactory, rb_intern("issuer_certificate"), 1, 0, Qfalse);
+ rb_attr(cX509ExtFactory, rb_intern("subject_certificate"), 1, 0, Qfalse);
+ rb_attr(cX509ExtFactory, rb_intern("subject_request"), 1, 0, Qfalse);
+ rb_attr(cX509ExtFactory, rb_intern("crl"), 1, 0, Qfalse);
+ rb_attr(cX509ExtFactory, rb_intern("config"), 1, 0, Qfalse);
+
+ rb_define_method(cX509ExtFactory, "issuer_certificate=", ossl_x509extfactory_set_issuer_cert, 1);
+ rb_define_method(cX509ExtFactory, "subject_certificate=", ossl_x509extfactory_set_subject_cert, 1);
+ rb_define_method(cX509ExtFactory, "subject_request=", ossl_x509extfactory_set_subject_req, 1);
+ rb_define_method(cX509ExtFactory, "crl=", ossl_x509extfactory_set_crl, 1);
+ rb_define_method(cX509ExtFactory, "config=", ossl_x509extfactory_set_config, 1);
+ rb_define_method(cX509ExtFactory, "create_ext", ossl_x509extfactory_create_ext, -1);
+
+ cX509Ext = rb_define_class_under(mX509, "Extension", rb_cObject);
+ rb_define_alloc_func(cX509Ext, ossl_x509ext_alloc);
+ rb_define_method(cX509Ext, "initialize", ossl_x509ext_initialize, -1);
+ rb_define_method(cX509Ext, "oid=", ossl_x509ext_set_oid, 1);
+ rb_define_method(cX509Ext, "value=", ossl_x509ext_set_value, 1);
+ rb_define_method(cX509Ext, "critical=", ossl_x509ext_set_critical, 1);
+ rb_define_method(cX509Ext, "oid", ossl_x509ext_get_oid, 0);
+ rb_define_method(cX509Ext, "value", ossl_x509ext_get_value, 0);
+ rb_define_method(cX509Ext, "critical?", ossl_x509ext_get_critical, 0);
+ rb_define_method(cX509Ext, "to_der", ossl_x509ext_to_der, 0);
+}
diff --git a/jni/ruby/ext/openssl/ossl_x509name.c b/jni/ruby/ext/openssl/ossl_x509name.c
new file mode 100644
index 0000000..2fc6ba9
--- /dev/null
+++ b/jni/ruby/ext/openssl/ossl_x509name.c
@@ -0,0 +1,524 @@
+/*
+ * $Id: ossl_x509name.c 48814 2014-12-12 23:59:19Z nobu $
+ * 'OpenSSL for Ruby' project
+ * Copyright (C) 2001 Michal Rokos <m.rokos@sh.cvut.cz>
+ * All rights reserved.
+ */
+/*
+ * This program is licenced under the same licence as Ruby.
+ * (See the file 'LICENCE'.)
+ */
+#include "ossl.h"
+
+#define WrapX509Name(klass, obj, name) do { \
+ if (!(name)) { \
+ ossl_raise(rb_eRuntimeError, "Name wasn't initialized."); \
+ } \
+ (obj) = TypedData_Wrap_Struct((klass), &ossl_x509name_type, (name)); \
+} while (0)
+#define GetX509Name(obj, name) do { \
+ TypedData_Get_Struct((obj), X509_NAME, &ossl_x509name_type, (name)); \
+ if (!(name)) { \
+ ossl_raise(rb_eRuntimeError, "Name wasn't initialized."); \
+ } \
+} while (0)
+#define SafeGetX509Name(obj, name) do { \
+ OSSL_Check_Kind((obj), cX509Name); \
+ GetX509Name((obj), (name)); \
+} while (0)
+
+#define OBJECT_TYPE_TEMPLATE \
+ rb_const_get(cX509Name, rb_intern("OBJECT_TYPE_TEMPLATE"))
+#define DEFAULT_OBJECT_TYPE \
+ rb_const_get(cX509Name, rb_intern("DEFAULT_OBJECT_TYPE"))
+
+/*
+ * Classes
+ */
+VALUE cX509Name;
+VALUE eX509NameError;
+
+static void
+ossl_x509name_free(void *ptr)
+{
+ X509_NAME_free(ptr);
+}
+
+static const rb_data_type_t ossl_x509name_type = {
+ "OpenSSL/X509/NAME",
+ {
+ 0, ossl_x509name_free,
+ },
+ 0, 0, RUBY_TYPED_FREE_IMMEDIATELY,
+};
+
+/*
+ * Public
+ */
+VALUE
+ossl_x509name_new(X509_NAME *name)
+{
+ X509_NAME *new;
+ VALUE obj;
+
+ if (!name) {
+ new = X509_NAME_new();
+ } else {
+ new = X509_NAME_dup(name);
+ }
+ if (!new) {
+ ossl_raise(eX509NameError, NULL);
+ }
+ WrapX509Name(cX509Name, obj, new);
+
+ return obj;
+}
+
+X509_NAME *
+GetX509NamePtr(VALUE obj)
+{
+ X509_NAME *name;
+
+ SafeGetX509Name(obj, name);
+
+ return name;
+}
+
+/*
+ * Private
+ */
+static VALUE
+ossl_x509name_alloc(VALUE klass)
+{
+ X509_NAME *name;
+ VALUE obj;
+
+ if (!(name = X509_NAME_new())) {
+ ossl_raise(eX509NameError, NULL);
+ }
+ WrapX509Name(klass, obj, name);
+
+ return obj;
+}
+
+static ID id_aref;
+static VALUE ossl_x509name_add_entry(int, VALUE*, VALUE);
+#define rb_aref(obj, key) rb_funcall((obj), id_aref, 1, (key))
+
+static VALUE
+ossl_x509name_init_i(RB_BLOCK_CALL_FUNC_ARGLIST(i, args))
+{
+ VALUE self = rb_ary_entry(args, 0);
+ VALUE template = rb_ary_entry(args, 1);
+ VALUE entry[3];
+
+ Check_Type(i, T_ARRAY);
+ entry[0] = rb_ary_entry(i, 0);
+ entry[1] = rb_ary_entry(i, 1);
+ entry[2] = rb_ary_entry(i, 2);
+ if(NIL_P(entry[2])) entry[2] = rb_aref(template, entry[0]);
+ if(NIL_P(entry[2])) entry[2] = DEFAULT_OBJECT_TYPE;
+ ossl_x509name_add_entry(3, entry, self);
+
+ return Qnil;
+}
+
+/*
+ * call-seq:
+ * X509::Name.new => name
+ * X509::Name.new(der) => name
+ * X509::Name.new(distinguished_name) => name
+ * X509::Name.new(distinguished_name, template) => name
+ *
+ * Creates a new Name.
+ *
+ * A name may be created from a DER encoded string +der+, an Array
+ * representing a +distinguished_name+ or a +distinguished_name+ along with a
+ * +template+.
+ *
+ * name = OpenSSL::X509::Name.new [['CN', 'nobody'], ['DC', 'example']]
+ *
+ * name = OpenSSL::X509::Name.new name.to_der
+ *
+ * See add_entry for a description of the +distinguished_name+ Array's
+ * contents
+ */
+static VALUE
+ossl_x509name_initialize(int argc, VALUE *argv, VALUE self)
+{
+ X509_NAME *name;
+ VALUE arg, template;
+
+ GetX509Name(self, name);
+ if (rb_scan_args(argc, argv, "02", &arg, &template) == 0) {
+ return self;
+ }
+ else {
+ VALUE tmp = rb_check_array_type(arg);
+ if (!NIL_P(tmp)) {
+ VALUE args;
+ if(NIL_P(template)) template = OBJECT_TYPE_TEMPLATE;
+ args = rb_ary_new3(2, self, template);
+ rb_block_call(tmp, rb_intern("each"), 0, 0, ossl_x509name_init_i, args);
+ }
+ else{
+ const unsigned char *p;
+ VALUE str = ossl_to_der_if_possible(arg);
+ X509_NAME *x;
+ StringValue(str);
+ p = (unsigned char *)RSTRING_PTR(str);
+ x = d2i_X509_NAME(&name, &p, RSTRING_LEN(str));
+ DATA_PTR(self) = name;
+ if(!x){
+ ossl_raise(eX509NameError, NULL);
+ }
+ }
+ }
+
+ return self;
+}
+
+/*
+ * call-seq:
+ * name.add_entry(oid, value [, type]) => self
+ *
+ * Adds a new entry with the given +oid+ and +value+ to this name. The +oid+
+ * is an object identifier defined in ASN.1. Some common OIDs are:
+ *
+ * C:: Country Name
+ * CN:: Common Name
+ * DC:: Domain Component
+ * O:: Organization Name
+ * OU:: Organizational Unit Name
+ * ST:: State or Province Name
+ */
+static
+VALUE ossl_x509name_add_entry(int argc, VALUE *argv, VALUE self)
+{
+ X509_NAME *name;
+ VALUE oid, value, type;
+ const char *oid_name;
+
+ rb_scan_args(argc, argv, "21", &oid, &value, &type);
+ oid_name = StringValueCStr(oid);
+ StringValue(value);
+ if(NIL_P(type)) type = rb_aref(OBJECT_TYPE_TEMPLATE, oid);
+ GetX509Name(self, name);
+ if (!X509_NAME_add_entry_by_txt(name, oid_name, NUM2INT(type),
+ (const unsigned char *)RSTRING_PTR(value), RSTRING_LENINT(value), -1, 0)) {
+ ossl_raise(eX509NameError, NULL);
+ }
+
+ return self;
+}
+
+static VALUE
+ossl_x509name_to_s_old(VALUE self)
+{
+ X509_NAME *name;
+ char *buf;
+ VALUE str;
+
+ GetX509Name(self, name);
+ buf = X509_NAME_oneline(name, NULL, 0);
+ str = rb_str_new2(buf);
+ OPENSSL_free(buf);
+
+ return str;
+}
+
+/*
+ * call-seq:
+ * name.to_s => string
+ * name.to_s(flags) => string
+ *
+ * Returns this name as a Distinguished Name string. +flags+ may be one of:
+ *
+ * * OpenSSL::X509::Name::COMPAT
+ * * OpenSSL::X509::Name::RFC2253
+ * * OpenSSL::X509::Name::ONELINE
+ * * OpenSSL::X509::Name::MULTILINE
+ */
+static VALUE
+ossl_x509name_to_s(int argc, VALUE *argv, VALUE self)
+{
+ X509_NAME *name;
+ VALUE flag, str;
+ BIO *out;
+ unsigned long iflag;
+
+ rb_scan_args(argc, argv, "01", &flag);
+ if (NIL_P(flag))
+ return ossl_x509name_to_s_old(self);
+ else iflag = NUM2ULONG(flag);
+ if (!(out = BIO_new(BIO_s_mem())))
+ ossl_raise(eX509NameError, NULL);
+ GetX509Name(self, name);
+ if (!X509_NAME_print_ex(out, name, 0, iflag)){
+ BIO_free(out);
+ ossl_raise(eX509NameError, NULL);
+ }
+ str = ossl_membio2str(out);
+
+ return str;
+}
+
+/*
+ * call-seq:
+ * name.to_a => [[name, data, type], ...]
+ *
+ * Returns an Array representation of the distinguished name suitable for
+ * passing to ::new
+ */
+static VALUE
+ossl_x509name_to_a(VALUE self)
+{
+ X509_NAME *name;
+ X509_NAME_ENTRY *entry;
+ int i,entries,nid;
+ char long_name[512];
+ const char *short_name;
+ VALUE ary, vname, ret;
+
+ GetX509Name(self, name);
+ entries = X509_NAME_entry_count(name);
+ if (entries < 0) {
+ OSSL_Debug("name entries < 0!");
+ return rb_ary_new();
+ }
+ ret = rb_ary_new2(entries);
+ for (i=0; i<entries; i++) {
+ if (!(entry = X509_NAME_get_entry(name, i))) {
+ ossl_raise(eX509NameError, NULL);
+ }
+ if (!i2t_ASN1_OBJECT(long_name, sizeof(long_name), entry->object)) {
+ ossl_raise(eX509NameError, NULL);
+ }
+ nid = OBJ_ln2nid(long_name);
+ if (nid == NID_undef) {
+ vname = rb_str_new2((const char *) &long_name);
+ } else {
+ short_name = OBJ_nid2sn(nid);
+ vname = rb_str_new2(short_name); /*do not free*/
+ }
+ ary = rb_ary_new3(3,
+ vname,
+ rb_str_new((const char *)entry->value->data, entry->value->length),
+ INT2FIX(entry->value->type));
+ rb_ary_push(ret, ary);
+ }
+ return ret;
+}
+
+static int
+ossl_x509name_cmp0(VALUE self, VALUE other)
+{
+ X509_NAME *name1, *name2;
+
+ GetX509Name(self, name1);
+ SafeGetX509Name(other, name2);
+
+ return X509_NAME_cmp(name1, name2);
+}
+
+/*
+ * call-seq:
+ * name.cmp other => integer
+ * name.<=> other => integer
+ *
+ * Compares this Name with +other+ and returns 0 if they are the same and -1 or
+ * +1 if they are greater or less than each other respectively.
+ */
+static VALUE
+ossl_x509name_cmp(VALUE self, VALUE other)
+{
+ int result;
+
+ result = ossl_x509name_cmp0(self, other);
+ if (result < 0) return INT2FIX(-1);
+ if (result > 1) return INT2FIX(1);
+
+ return INT2FIX(0);
+}
+
+/*
+ * call-seq:
+ * name.eql? other => boolean
+ *
+ * Returns true if +name+ and +other+ refer to the same hash key.
+ */
+static VALUE
+ossl_x509name_eql(VALUE self, VALUE other)
+{
+ int result;
+
+ if(CLASS_OF(other) != cX509Name) return Qfalse;
+ result = ossl_x509name_cmp0(self, other);
+
+ return (result == 0) ? Qtrue : Qfalse;
+}
+
+/*
+ * call-seq:
+ * name.hash => integer
+ *
+ * The hash value returned is suitable for use as a certificate's filename in
+ * a CA path.
+ */
+static VALUE
+ossl_x509name_hash(VALUE self)
+{
+ X509_NAME *name;
+ unsigned long hash;
+
+ GetX509Name(self, name);
+
+ hash = X509_NAME_hash(name);
+
+ return ULONG2NUM(hash);
+}
+
+#ifdef HAVE_X509_NAME_HASH_OLD
+/*
+ * call-seq:
+ * name.hash_old => integer
+ *
+ * Returns an MD5 based hash used in OpenSSL 0.9.X.
+ */
+static VALUE
+ossl_x509name_hash_old(VALUE self)
+{
+ X509_NAME *name;
+ unsigned long hash;
+
+ GetX509Name(self, name);
+
+ hash = X509_NAME_hash_old(name);
+
+ return ULONG2NUM(hash);
+}
+#endif
+
+/*
+ * call-seq:
+ * name.to_der => string
+ *
+ * Converts the name to DER encoding
+ */
+static VALUE
+ossl_x509name_to_der(VALUE self)
+{
+ X509_NAME *name;
+ VALUE str;
+ long len;
+ unsigned char *p;
+
+ GetX509Name(self, name);
+ if((len = i2d_X509_NAME(name, NULL)) <= 0)
+ ossl_raise(eX509NameError, NULL);
+ str = rb_str_new(0, len);
+ p = (unsigned char *)RSTRING_PTR(str);
+ if(i2d_X509_NAME(name, &p) <= 0)
+ ossl_raise(eX509NameError, NULL);
+ ossl_str_adjust(str, p);
+
+ return str;
+}
+
+/*
+ * Document-class: OpenSSL::X509::Name
+ *
+ * An X.509 name represents a hostname, email address or other entity
+ * associated with a public key.
+ *
+ * You can create a Name by parsing a distinguished name String or by
+ * supplying the distinguished name as an Array.
+ *
+ * name = OpenSSL::X509::Name.parse 'CN=nobody/DC=example'
+ *
+ * name = OpenSSL::X509::Name.new [['CN', 'nobody'], ['DC', 'example']]
+ */
+
+void
+Init_ossl_x509name(void)
+{
+ VALUE utf8str, ptrstr, ia5str, hash;
+
+ id_aref = rb_intern("[]");
+ eX509NameError = rb_define_class_under(mX509, "NameError", eOSSLError);
+ cX509Name = rb_define_class_under(mX509, "Name", rb_cObject);
+
+ rb_include_module(cX509Name, rb_mComparable);
+
+ rb_define_alloc_func(cX509Name, ossl_x509name_alloc);
+ rb_define_method(cX509Name, "initialize", ossl_x509name_initialize, -1);
+ rb_define_method(cX509Name, "add_entry", ossl_x509name_add_entry, -1);
+ rb_define_method(cX509Name, "to_s", ossl_x509name_to_s, -1);
+ rb_define_method(cX509Name, "to_a", ossl_x509name_to_a, 0);
+ rb_define_method(cX509Name, "cmp", ossl_x509name_cmp, 1);
+ rb_define_alias(cX509Name, "<=>", "cmp");
+ rb_define_method(cX509Name, "eql?", ossl_x509name_eql, 1);
+ rb_define_method(cX509Name, "hash", ossl_x509name_hash, 0);
+#ifdef HAVE_X509_NAME_HASH_OLD
+ rb_define_method(cX509Name, "hash_old", ossl_x509name_hash_old, 0);
+#endif
+ rb_define_method(cX509Name, "to_der", ossl_x509name_to_der, 0);
+
+ utf8str = INT2NUM(V_ASN1_UTF8STRING);
+ ptrstr = INT2NUM(V_ASN1_PRINTABLESTRING);
+ ia5str = INT2NUM(V_ASN1_IA5STRING);
+
+ /* Document-const: DEFAULT_OBJECT_TYPE
+ *
+ * The default object type for name entries.
+ */
+ rb_define_const(cX509Name, "DEFAULT_OBJECT_TYPE", utf8str);
+ hash = rb_hash_new();
+ RHASH_SET_IFNONE(hash, utf8str);
+ rb_hash_aset(hash, rb_str_new2("C"), ptrstr);
+ rb_hash_aset(hash, rb_str_new2("countryName"), ptrstr);
+ rb_hash_aset(hash, rb_str_new2("serialNumber"), ptrstr);
+ rb_hash_aset(hash, rb_str_new2("dnQualifier"), ptrstr);
+ rb_hash_aset(hash, rb_str_new2("DC"), ia5str);
+ rb_hash_aset(hash, rb_str_new2("domainComponent"), ia5str);
+ rb_hash_aset(hash, rb_str_new2("emailAddress"), ia5str);
+
+ /* Document-const: OBJECT_TYPE_TEMPLATE
+ *
+ * The default object type template for name entries.
+ */
+ rb_define_const(cX509Name, "OBJECT_TYPE_TEMPLATE", hash);
+
+ /* Document-const: COMPAT
+ *
+ * A flag for #to_s.
+ *
+ * Breaks the name returned into multiple lines if longer than 80
+ * characters.
+ */
+ rb_define_const(cX509Name, "COMPAT", ULONG2NUM(XN_FLAG_COMPAT));
+
+ /* Document-const: RFC2253
+ *
+ * A flag for #to_s.
+ *
+ * Returns an RFC2253 format name.
+ */
+ rb_define_const(cX509Name, "RFC2253", ULONG2NUM(XN_FLAG_RFC2253));
+
+ /* Document-const: ONELINE
+ *
+ * A flag for #to_s.
+ *
+ * Returns a more readable format than RFC2253.
+ */
+ rb_define_const(cX509Name, "ONELINE", ULONG2NUM(XN_FLAG_ONELINE));
+
+ /* Document-const: MULTILINE
+ *
+ * A flag for #to_s.
+ *
+ * Returns a multiline format.
+ */
+ rb_define_const(cX509Name, "MULTILINE", ULONG2NUM(XN_FLAG_MULTILINE));
+}
diff --git a/jni/ruby/ext/openssl/ossl_x509req.c b/jni/ruby/ext/openssl/ossl_x509req.c
new file mode 100644
index 0000000..95458cb
--- /dev/null
+++ b/jni/ruby/ext/openssl/ossl_x509req.c
@@ -0,0 +1,482 @@
+/*
+ * $Id: ossl_x509req.c 48815 2014-12-12 23:59:28Z nobu $
+ * 'OpenSSL for Ruby' project
+ * Copyright (C) 2001-2002 Michal Rokos <m.rokos@sh.cvut.cz>
+ * All rights reserved.
+ */
+/*
+ * This program is licenced under the same licence as Ruby.
+ * (See the file 'LICENCE'.)
+ */
+#include "ossl.h"
+
+#define WrapX509Req(klass, obj, req) do { \
+ if (!(req)) { \
+ ossl_raise(rb_eRuntimeError, "Req wasn't initialized!"); \
+ } \
+ (obj) = TypedData_Wrap_Struct((klass), &ossl_x509req_type, (req)); \
+} while (0)
+#define GetX509Req(obj, req) do { \
+ TypedData_Get_Struct((obj), X509_REQ, &ossl_x509req_type, (req)); \
+ if (!(req)) { \
+ ossl_raise(rb_eRuntimeError, "Req wasn't initialized!"); \
+ } \
+} while (0)
+#define SafeGetX509Req(obj, req) do { \
+ OSSL_Check_Kind((obj), cX509Req); \
+ GetX509Req((obj), (req)); \
+} while (0)
+
+/*
+ * Classes
+ */
+VALUE cX509Req;
+VALUE eX509ReqError;
+
+static void
+ossl_x509req_free(void *ptr)
+{
+ X509_REQ_free(ptr);
+}
+
+static const rb_data_type_t ossl_x509req_type = {
+ "OpenSSL/X509/REQ",
+ {
+ 0, ossl_x509req_free,
+ },
+ 0, 0, RUBY_TYPED_FREE_IMMEDIATELY,
+};
+
+/*
+ * Public functions
+ */
+VALUE
+ossl_x509req_new(X509_REQ *req)
+{
+ X509_REQ *new;
+ VALUE obj;
+
+ if (!req) {
+ new = X509_REQ_new();
+ } else {
+ new = X509_REQ_dup(req);
+ }
+ if (!new) {
+ ossl_raise(eX509ReqError, NULL);
+ }
+ WrapX509Req(cX509Req, obj, new);
+
+ return obj;
+}
+
+X509_REQ *
+GetX509ReqPtr(VALUE obj)
+{
+ X509_REQ *req;
+
+ SafeGetX509Req(obj, req);
+
+ return req;
+}
+
+X509_REQ *
+DupX509ReqPtr(VALUE obj)
+{
+ X509_REQ *req, *new;
+
+ SafeGetX509Req(obj, req);
+ if (!(new = X509_REQ_dup(req))) {
+ ossl_raise(eX509ReqError, NULL);
+ }
+
+ return new;
+}
+
+/*
+ * Private functions
+ */
+static VALUE
+ossl_x509req_alloc(VALUE klass)
+{
+ X509_REQ *req;
+ VALUE obj;
+
+ if (!(req = X509_REQ_new())) {
+ ossl_raise(eX509ReqError, NULL);
+ }
+ WrapX509Req(klass, obj, req);
+
+ return obj;
+}
+
+static VALUE
+ossl_x509req_initialize(int argc, VALUE *argv, VALUE self)
+{
+ BIO *in;
+ X509_REQ *req, *x = DATA_PTR(self);
+ VALUE arg;
+
+ if (rb_scan_args(argc, argv, "01", &arg) == 0) {
+ return self;
+ }
+ arg = ossl_to_der_if_possible(arg);
+ in = ossl_obj2bio(arg);
+ req = PEM_read_bio_X509_REQ(in, &x, NULL, NULL);
+ DATA_PTR(self) = x;
+ if (!req) {
+ OSSL_BIO_reset(in);
+ req = d2i_X509_REQ_bio(in, &x);
+ DATA_PTR(self) = x;
+ }
+ BIO_free(in);
+ if (!req) ossl_raise(eX509ReqError, NULL);
+
+ return self;
+}
+
+static VALUE
+ossl_x509req_copy(VALUE self, VALUE other)
+{
+ X509_REQ *a, *b, *req;
+
+ rb_check_frozen(self);
+ if (self == other) return self;
+ GetX509Req(self, a);
+ SafeGetX509Req(other, b);
+ if (!(req = X509_REQ_dup(b))) {
+ ossl_raise(eX509ReqError, NULL);
+ }
+ X509_REQ_free(a);
+ DATA_PTR(self) = req;
+
+ return self;
+}
+
+static VALUE
+ossl_x509req_to_pem(VALUE self)
+{
+ X509_REQ *req;
+ BIO *out;
+ BUF_MEM *buf;
+ VALUE str;
+
+ GetX509Req(self, req);
+ if (!(out = BIO_new(BIO_s_mem()))) {
+ ossl_raise(eX509ReqError, NULL);
+ }
+ if (!PEM_write_bio_X509_REQ(out, req)) {
+ BIO_free(out);
+ ossl_raise(eX509ReqError, NULL);
+ }
+ BIO_get_mem_ptr(out, &buf);
+ str = rb_str_new(buf->data, buf->length);
+ BIO_free(out);
+
+ return str;
+}
+
+static VALUE
+ossl_x509req_to_der(VALUE self)
+{
+ X509_REQ *req;
+ VALUE str;
+ long len;
+ unsigned char *p;
+
+ GetX509Req(self, req);
+ if ((len = i2d_X509_REQ(req, NULL)) <= 0)
+ ossl_raise(eX509ReqError, NULL);
+ str = rb_str_new(0, len);
+ p = (unsigned char *)RSTRING_PTR(str);
+ if (i2d_X509_REQ(req, &p) <= 0)
+ ossl_raise(eX509ReqError, NULL);
+ ossl_str_adjust(str, p);
+
+ return str;
+}
+
+static VALUE
+ossl_x509req_to_text(VALUE self)
+{
+ X509_REQ *req;
+ BIO *out;
+ BUF_MEM *buf;
+ VALUE str;
+
+ GetX509Req(self, req);
+ if (!(out = BIO_new(BIO_s_mem()))) {
+ ossl_raise(eX509ReqError, NULL);
+ }
+ if (!X509_REQ_print(out, req)) {
+ BIO_free(out);
+ ossl_raise(eX509ReqError, NULL);
+ }
+ BIO_get_mem_ptr(out, &buf);
+ str = rb_str_new(buf->data, buf->length);
+ BIO_free(out);
+
+ return str;
+}
+
+#if 0
+/*
+ * Makes X509 from X509_REQuest
+ */
+static VALUE
+ossl_x509req_to_x509(VALUE self, VALUE days, VALUE key)
+{
+ X509_REQ *req;
+ X509 *x509;
+
+ GetX509Req(self, req);
+ ...
+ if (!(x509 = X509_REQ_to_X509(req, d, pkey))) {
+ ossl_raise(eX509ReqError, NULL);
+ }
+
+ return ossl_x509_new(x509);
+}
+#endif
+
+static VALUE
+ossl_x509req_get_version(VALUE self)
+{
+ X509_REQ *req;
+ long version;
+
+ GetX509Req(self, req);
+ version = X509_REQ_get_version(req);
+
+ return LONG2FIX(version);
+}
+
+static VALUE
+ossl_x509req_set_version(VALUE self, VALUE version)
+{
+ X509_REQ *req;
+ long ver;
+
+ if ((ver = FIX2LONG(version)) < 0) {
+ ossl_raise(eX509ReqError, "version must be >= 0!");
+ }
+ GetX509Req(self, req);
+ if (!X509_REQ_set_version(req, ver)) {
+ ossl_raise(eX509ReqError, NULL);
+ }
+
+ return version;
+}
+
+static VALUE
+ossl_x509req_get_subject(VALUE self)
+{
+ X509_REQ *req;
+ X509_NAME *name;
+
+ GetX509Req(self, req);
+ if (!(name = X509_REQ_get_subject_name(req))) { /* NO DUP - don't free */
+ ossl_raise(eX509ReqError, NULL);
+ }
+
+ return ossl_x509name_new(name);
+}
+
+static VALUE
+ossl_x509req_set_subject(VALUE self, VALUE subject)
+{
+ X509_REQ *req;
+
+ GetX509Req(self, req);
+ /* DUPs name */
+ if (!X509_REQ_set_subject_name(req, GetX509NamePtr(subject))) {
+ ossl_raise(eX509ReqError, NULL);
+ }
+
+ return subject;
+}
+
+static VALUE
+ossl_x509req_get_signature_algorithm(VALUE self)
+{
+ X509_REQ *req;
+ BIO *out;
+ BUF_MEM *buf;
+ VALUE str;
+
+ GetX509Req(self, req);
+
+ if (!(out = BIO_new(BIO_s_mem()))) {
+ ossl_raise(eX509ReqError, NULL);
+ }
+ if (!i2a_ASN1_OBJECT(out, req->sig_alg->algorithm)) {
+ BIO_free(out);
+ ossl_raise(eX509ReqError, NULL);
+ }
+ BIO_get_mem_ptr(out, &buf);
+ str = rb_str_new(buf->data, buf->length);
+ BIO_free(out);
+ return str;
+}
+
+static VALUE
+ossl_x509req_get_public_key(VALUE self)
+{
+ X509_REQ *req;
+ EVP_PKEY *pkey;
+
+ GetX509Req(self, req);
+ if (!(pkey = X509_REQ_get_pubkey(req))) { /* adds reference */
+ ossl_raise(eX509ReqError, NULL);
+ }
+
+ return ossl_pkey_new(pkey); /* NO DUP - OK */
+}
+
+static VALUE
+ossl_x509req_set_public_key(VALUE self, VALUE key)
+{
+ X509_REQ *req;
+ EVP_PKEY *pkey;
+
+ GetX509Req(self, req);
+ pkey = GetPKeyPtr(key); /* NO NEED TO DUP */
+ if (!X509_REQ_set_pubkey(req, pkey)) {
+ ossl_raise(eX509ReqError, NULL);
+ }
+
+ return key;
+}
+
+static VALUE
+ossl_x509req_sign(VALUE self, VALUE key, VALUE digest)
+{
+ X509_REQ *req;
+ EVP_PKEY *pkey;
+ const EVP_MD *md;
+
+ GetX509Req(self, req);
+ pkey = GetPrivPKeyPtr(key); /* NO NEED TO DUP */
+ md = GetDigestPtr(digest);
+ if (!X509_REQ_sign(req, pkey, md)) {
+ ossl_raise(eX509ReqError, NULL);
+ }
+
+ return self;
+}
+
+/*
+ * Checks that cert signature is made with PRIVversion of this PUBLIC 'key'
+ */
+static VALUE
+ossl_x509req_verify(VALUE self, VALUE key)
+{
+ X509_REQ *req;
+ EVP_PKEY *pkey;
+ int i;
+
+ GetX509Req(self, req);
+ pkey = GetPKeyPtr(key); /* NO NEED TO DUP */
+ if ((i = X509_REQ_verify(req, pkey)) < 0) {
+ ossl_raise(eX509ReqError, NULL);
+ }
+ if (i > 0) {
+ return Qtrue;
+ }
+
+ return Qfalse;
+}
+
+static VALUE
+ossl_x509req_get_attributes(VALUE self)
+{
+ X509_REQ *req;
+ int count, i;
+ X509_ATTRIBUTE *attr;
+ VALUE ary;
+
+ GetX509Req(self, req);
+
+ count = X509_REQ_get_attr_count(req);
+ if (count < 0) {
+ OSSL_Debug("count < 0???");
+ return rb_ary_new();
+ }
+ ary = rb_ary_new2(count);
+ for (i=0; i<count; i++) {
+ attr = X509_REQ_get_attr(req, i);
+ rb_ary_push(ary, ossl_x509attr_new(attr));
+ }
+
+ return ary;
+}
+
+static VALUE
+ossl_x509req_set_attributes(VALUE self, VALUE ary)
+{
+ X509_REQ *req;
+ X509_ATTRIBUTE *attr;
+ int i;
+ VALUE item;
+
+ Check_Type(ary, T_ARRAY);
+ for (i=0;i<RARRAY_LEN(ary); i++) {
+ OSSL_Check_Kind(RARRAY_PTR(ary)[i], cX509Attr);
+ }
+ GetX509Req(self, req);
+ sk_X509_ATTRIBUTE_pop_free(req->req_info->attributes, X509_ATTRIBUTE_free);
+ req->req_info->attributes = NULL;
+ for (i=0;i<RARRAY_LEN(ary); i++) {
+ item = RARRAY_PTR(ary)[i];
+ attr = DupX509AttrPtr(item);
+ if (!X509_REQ_add1_attr(req, attr)) {
+ ossl_raise(eX509ReqError, NULL);
+ }
+ }
+ return ary;
+}
+
+static VALUE
+ossl_x509req_add_attribute(VALUE self, VALUE attr)
+{
+ X509_REQ *req;
+
+ GetX509Req(self, req);
+ if (!X509_REQ_add1_attr(req, DupX509AttrPtr(attr))) {
+ ossl_raise(eX509ReqError, NULL);
+ }
+
+ return attr;
+}
+
+/*
+ * X509_REQUEST init
+ */
+void
+Init_ossl_x509req(void)
+{
+ eX509ReqError = rb_define_class_under(mX509, "RequestError", eOSSLError);
+
+ cX509Req = rb_define_class_under(mX509, "Request", rb_cObject);
+
+ rb_define_alloc_func(cX509Req, ossl_x509req_alloc);
+ rb_define_method(cX509Req, "initialize", ossl_x509req_initialize, -1);
+ rb_define_copy_func(cX509Req, ossl_x509req_copy);
+
+ rb_define_method(cX509Req, "to_pem", ossl_x509req_to_pem, 0);
+ rb_define_method(cX509Req, "to_der", ossl_x509req_to_der, 0);
+ rb_define_alias(cX509Req, "to_s", "to_pem");
+ rb_define_method(cX509Req, "to_text", ossl_x509req_to_text, 0);
+ rb_define_method(cX509Req, "version", ossl_x509req_get_version, 0);
+ rb_define_method(cX509Req, "version=", ossl_x509req_set_version, 1);
+ rb_define_method(cX509Req, "subject", ossl_x509req_get_subject, 0);
+ rb_define_method(cX509Req, "subject=", ossl_x509req_set_subject, 1);
+ rb_define_method(cX509Req, "signature_algorithm", ossl_x509req_get_signature_algorithm, 0);
+ rb_define_method(cX509Req, "public_key", ossl_x509req_get_public_key, 0);
+ rb_define_method(cX509Req, "public_key=", ossl_x509req_set_public_key, 1);
+ rb_define_method(cX509Req, "sign", ossl_x509req_sign, 2);
+ rb_define_method(cX509Req, "verify", ossl_x509req_verify, 1);
+ rb_define_method(cX509Req, "attributes", ossl_x509req_get_attributes, 0);
+ rb_define_method(cX509Req, "attributes=", ossl_x509req_set_attributes, 1);
+ rb_define_method(cX509Req, "add_attribute", ossl_x509req_add_attribute, 1);
+}
+
diff --git a/jni/ruby/ext/openssl/ossl_x509revoked.c b/jni/ruby/ext/openssl/ossl_x509revoked.c
new file mode 100644
index 0000000..ea7aad9
--- /dev/null
+++ b/jni/ruby/ext/openssl/ossl_x509revoked.c
@@ -0,0 +1,243 @@
+/*
+ * $Id: ossl_x509revoked.c 48816 2014-12-12 23:59:36Z nobu $
+ * 'OpenSSL for Ruby' project
+ * Copyright (C) 2001-2002 Michal Rokos <m.rokos@sh.cvut.cz>
+ * All rights reserved.
+ */
+/*
+ * This program is licenced under the same licence as Ruby.
+ * (See the file 'LICENCE'.)
+ */
+#include "ossl.h"
+
+#define WrapX509Rev(klass, obj, rev) do { \
+ if (!(rev)) { \
+ ossl_raise(rb_eRuntimeError, "REV wasn't initialized!"); \
+ } \
+ (obj) = TypedData_Wrap_Struct((klass), &ossl_x509rev_type, (rev)); \
+} while (0)
+#define GetX509Rev(obj, rev) do { \
+ TypedData_Get_Struct((obj), X509_REVOKED, &ossl_x509rev_type, (rev)); \
+ if (!(rev)) { \
+ ossl_raise(rb_eRuntimeError, "REV wasn't initialized!"); \
+ } \
+} while (0)
+#define SafeGetX509Rev(obj, rev) do { \
+ OSSL_Check_Kind((obj), cX509Rev); \
+ GetX509Rev((obj), (rev)); \
+} while (0)
+
+/*
+ * Classes
+ */
+VALUE cX509Rev;
+VALUE eX509RevError;
+
+static void
+ossl_x509rev_free(void *ptr)
+{
+ X509_REVOKED_free(ptr);
+}
+
+static const rb_data_type_t ossl_x509rev_type = {
+ "OpenSSL/X509/REV",
+ {
+ 0, ossl_x509rev_free,
+ },
+ 0, 0, RUBY_TYPED_FREE_IMMEDIATELY,
+};
+
+/*
+ * PUBLIC
+ */
+VALUE
+ossl_x509revoked_new(X509_REVOKED *rev)
+{
+ X509_REVOKED *new;
+ VALUE obj;
+
+ if (!rev) {
+ new = X509_REVOKED_new();
+ } else {
+ new = X509_REVOKED_dup(rev);
+ }
+ if (!new) {
+ ossl_raise(eX509RevError, NULL);
+ }
+ WrapX509Rev(cX509Rev, obj, new);
+
+ return obj;
+}
+
+X509_REVOKED *
+DupX509RevokedPtr(VALUE obj)
+{
+ X509_REVOKED *rev, *new;
+
+ SafeGetX509Rev(obj, rev);
+ if (!(new = X509_REVOKED_dup(rev))) {
+ ossl_raise(eX509RevError, NULL);
+ }
+
+ return new;
+}
+
+/*
+ * PRIVATE
+ */
+static VALUE
+ossl_x509revoked_alloc(VALUE klass)
+{
+ X509_REVOKED *rev;
+ VALUE obj;
+
+ if (!(rev = X509_REVOKED_new())) {
+ ossl_raise(eX509RevError, NULL);
+ }
+ WrapX509Rev(klass, obj, rev);
+
+ return obj;
+}
+
+static VALUE
+ossl_x509revoked_initialize(int argc, VALUE *argv, VALUE self)
+{
+ /* EMPTY */
+ return self;
+}
+
+static VALUE
+ossl_x509revoked_get_serial(VALUE self)
+{
+ X509_REVOKED *rev;
+
+ GetX509Rev(self, rev);
+
+ return asn1integer_to_num(rev->serialNumber);
+}
+
+static VALUE
+ossl_x509revoked_set_serial(VALUE self, VALUE num)
+{
+ X509_REVOKED *rev;
+
+ GetX509Rev(self, rev);
+ rev->serialNumber = num_to_asn1integer(num, rev->serialNumber);
+
+ return num;
+}
+
+static VALUE
+ossl_x509revoked_get_time(VALUE self)
+{
+ X509_REVOKED *rev;
+
+ GetX509Rev(self, rev);
+
+ return asn1time_to_time(rev->revocationDate);
+}
+
+static VALUE
+ossl_x509revoked_set_time(VALUE self, VALUE time)
+{
+ X509_REVOKED *rev;
+ time_t sec;
+
+ sec = time_to_time_t(time);
+ GetX509Rev(self, rev);
+ if (!X509_time_adj(rev->revocationDate, 0, &sec)) {
+ ossl_raise(eX509RevError, NULL);
+ }
+
+ return time;
+}
+/*
+ * Gets X509v3 extensions as array of X509Ext objects
+ */
+static VALUE
+ossl_x509revoked_get_extensions(VALUE self)
+{
+ X509_REVOKED *rev;
+ int count, i;
+ X509_EXTENSION *ext;
+ VALUE ary;
+
+ GetX509Rev(self, rev);
+ count = X509_REVOKED_get_ext_count(rev);
+ if (count < 0) {
+ OSSL_Debug("count < 0???");
+ return rb_ary_new();
+ }
+ ary = rb_ary_new2(count);
+ for (i=0; i<count; i++) {
+ ext = X509_REVOKED_get_ext(rev, i);
+ rb_ary_push(ary, ossl_x509ext_new(ext));
+ }
+
+ return ary;
+}
+
+/*
+ * Sets X509_EXTENSIONs
+ */
+static VALUE
+ossl_x509revoked_set_extensions(VALUE self, VALUE ary)
+{
+ X509_REVOKED *rev;
+ X509_EXTENSION *ext;
+ int i;
+ VALUE item;
+
+ Check_Type(ary, T_ARRAY);
+ for (i=0; i<RARRAY_LEN(ary); i++) {
+ OSSL_Check_Kind(RARRAY_PTR(ary)[i], cX509Ext);
+ }
+ GetX509Rev(self, rev);
+ sk_X509_EXTENSION_pop_free(rev->extensions, X509_EXTENSION_free);
+ rev->extensions = NULL;
+ for (i=0; i<RARRAY_LEN(ary); i++) {
+ item = RARRAY_PTR(ary)[i];
+ ext = DupX509ExtPtr(item);
+ if(!X509_REVOKED_add_ext(rev, ext, -1)) {
+ ossl_raise(eX509RevError, NULL);
+ }
+ }
+
+ return ary;
+}
+
+static VALUE
+ossl_x509revoked_add_extension(VALUE self, VALUE ext)
+{
+ X509_REVOKED *rev;
+
+ GetX509Rev(self, rev);
+ if(!X509_REVOKED_add_ext(rev, DupX509ExtPtr(ext), -1)) {
+ ossl_raise(eX509RevError, NULL);
+ }
+
+ return ext;
+}
+
+/*
+ * INIT
+ */
+void
+Init_ossl_x509revoked(void)
+{
+ eX509RevError = rb_define_class_under(mX509, "RevokedError", eOSSLError);
+
+ cX509Rev = rb_define_class_under(mX509, "Revoked", rb_cObject);
+
+ rb_define_alloc_func(cX509Rev, ossl_x509revoked_alloc);
+ rb_define_method(cX509Rev, "initialize", ossl_x509revoked_initialize, -1);
+
+ rb_define_method(cX509Rev, "serial", ossl_x509revoked_get_serial, 0);
+ rb_define_method(cX509Rev, "serial=", ossl_x509revoked_set_serial, 1);
+ rb_define_method(cX509Rev, "time", ossl_x509revoked_get_time, 0);
+ rb_define_method(cX509Rev, "time=", ossl_x509revoked_set_time, 1);
+ rb_define_method(cX509Rev, "extensions", ossl_x509revoked_get_extensions, 0);
+ rb_define_method(cX509Rev, "extensions=", ossl_x509revoked_set_extensions, 1);
+ rb_define_method(cX509Rev, "add_extension", ossl_x509revoked_add_extension, 1);
+}
+
diff --git a/jni/ruby/ext/openssl/ossl_x509store.c b/jni/ruby/ext/openssl/ossl_x509store.c
new file mode 100644
index 0000000..5efba1b
--- /dev/null
+++ b/jni/ruby/ext/openssl/ossl_x509store.c
@@ -0,0 +1,702 @@
+/*
+ * $Id: ossl_x509store.c 48818 2014-12-13 00:06:54Z nobu $
+ * 'OpenSSL for Ruby' project
+ * Copyright (C) 2001-2002 Michal Rokos <m.rokos@sh.cvut.cz>
+ * All rights reserved.
+ */
+/*
+ * This program is licenced under the same licence as Ruby.
+ * (See the file 'LICENCE'.)
+ */
+#include "ossl.h"
+
+#define WrapX509Store(klass, obj, st) do { \
+ if (!(st)) { \
+ ossl_raise(rb_eRuntimeError, "STORE wasn't initialized!"); \
+ } \
+ (obj) = TypedData_Wrap_Struct((klass), &ossl_x509store_type, (st)); \
+} while (0)
+#define GetX509Store(obj, st) do { \
+ TypedData_Get_Struct((obj), X509_STORE, &ossl_x509store_type, (st)); \
+ if (!(st)) { \
+ ossl_raise(rb_eRuntimeError, "STORE wasn't initialized!"); \
+ } \
+} while (0)
+#define SafeGetX509Store(obj, st) do { \
+ OSSL_Check_Kind((obj), cX509Store); \
+ GetX509Store((obj), (st)); \
+} while (0)
+
+#define WrapX509StCtx(klass, obj, ctx) do { \
+ if (!(ctx)) { \
+ ossl_raise(rb_eRuntimeError, "STORE_CTX wasn't initialized!"); \
+ } \
+ (obj) = TypedData_Wrap_Struct((klass), &ossl_x509stctx_type, (ctx)); \
+} while (0)
+#define GetX509StCtx(obj, ctx) do { \
+ TypedData_Get_Struct((obj), X509_STORE_CTX, &ossl_x509stctx_type, (ctx)); \
+ if (!(ctx)) { \
+ ossl_raise(rb_eRuntimeError, "STORE_CTX is out of scope!"); \
+ } \
+} while (0)
+#define SafeGetX509StCtx(obj, storep) do { \
+ OSSL_Check_Kind((obj), cX509StoreContext); \
+ GetX509Store((obj), (ctx)); \
+} while (0)
+
+/*
+ * Classes
+ */
+VALUE cX509Store;
+VALUE cX509StoreContext;
+VALUE eX509StoreError;
+
+static void
+ossl_x509store_free(void *ptr)
+{
+ X509_STORE_free(ptr);
+}
+
+static const rb_data_type_t ossl_x509store_type = {
+ "OpenSSL/X509/STORE",
+ {
+ 0, ossl_x509store_free,
+ },
+ 0, 0, RUBY_TYPED_FREE_IMMEDIATELY,
+};
+
+/*
+ * Public functions
+ */
+VALUE
+ossl_x509store_new(X509_STORE *store)
+{
+ VALUE obj;
+
+ WrapX509Store(cX509Store, obj, store);
+
+ return obj;
+}
+
+X509_STORE *
+GetX509StorePtr(VALUE obj)
+{
+ X509_STORE *store;
+
+ SafeGetX509Store(obj, store);
+
+ return store;
+}
+
+X509_STORE *
+DupX509StorePtr(VALUE obj)
+{
+ X509_STORE *store;
+
+ SafeGetX509Store(obj, store);
+ CRYPTO_add(&store->references, 1, CRYPTO_LOCK_X509_STORE);
+
+ return store;
+}
+
+/*
+ * Private functions
+ */
+static VALUE
+ossl_x509store_alloc(VALUE klass)
+{
+ X509_STORE *store;
+ VALUE obj;
+
+ if((store = X509_STORE_new()) == NULL){
+ ossl_raise(eX509StoreError, NULL);
+ }
+ WrapX509Store(klass, obj, store);
+
+ return obj;
+}
+
+/*
+ * General callback for OpenSSL verify
+ */
+static VALUE
+ossl_x509store_set_vfy_cb(VALUE self, VALUE cb)
+{
+ X509_STORE *store;
+
+ GetX509Store(self, store);
+ X509_STORE_set_ex_data(store, ossl_verify_cb_idx, (void*)cb);
+ rb_iv_set(self, "@verify_callback", cb);
+
+ return cb;
+}
+
+
+/*
+ * call-seq:
+ * X509::Store.new => store
+ *
+ */
+static VALUE
+ossl_x509store_initialize(int argc, VALUE *argv, VALUE self)
+{
+ X509_STORE *store;
+
+/* BUG: This method takes any number of arguments but appears to ignore them. */
+ GetX509Store(self, store);
+ store->ex_data.sk = NULL;
+ X509_STORE_set_verify_cb_func(store, ossl_verify_cb);
+ ossl_x509store_set_vfy_cb(self, Qnil);
+
+#if (OPENSSL_VERSION_NUMBER < 0x00907000L)
+ rb_iv_set(self, "@flags", INT2FIX(0));
+ rb_iv_set(self, "@purpose", INT2FIX(0));
+ rb_iv_set(self, "@trust", INT2FIX(0));
+#endif
+
+ /* last verification status */
+ rb_iv_set(self, "@error", Qnil);
+ rb_iv_set(self, "@error_string", Qnil);
+ rb_iv_set(self, "@chain", Qnil);
+ rb_iv_set(self, "@time", Qnil);
+
+ return self;
+}
+
+static VALUE
+ossl_x509store_set_flags(VALUE self, VALUE flags)
+{
+#if (OPENSSL_VERSION_NUMBER >= 0x00907000L)
+ X509_STORE *store;
+ long f = NUM2LONG(flags);
+
+ GetX509Store(self, store);
+ X509_STORE_set_flags(store, f);
+#else
+ rb_iv_set(self, "@flags", flags);
+#endif
+
+ return flags;
+}
+
+static VALUE
+ossl_x509store_set_purpose(VALUE self, VALUE purpose)
+{
+#if (OPENSSL_VERSION_NUMBER >= 0x00907000L)
+ X509_STORE *store;
+ int p = NUM2INT(purpose);
+
+ GetX509Store(self, store);
+ X509_STORE_set_purpose(store, p);
+#else
+ rb_iv_set(self, "@purpose", purpose);
+#endif
+
+ return purpose;
+}
+
+static VALUE
+ossl_x509store_set_trust(VALUE self, VALUE trust)
+{
+#if (OPENSSL_VERSION_NUMBER >= 0x00907000L)
+ X509_STORE *store;
+ int t = NUM2INT(trust);
+
+ GetX509Store(self, store);
+ X509_STORE_set_trust(store, t);
+#else
+ rb_iv_set(self, "@trust", trust);
+#endif
+
+ return trust;
+}
+
+static VALUE
+ossl_x509store_set_time(VALUE self, VALUE time)
+{
+ rb_iv_set(self, "@time", time);
+ return time;
+}
+
+/*
+ * call-seq:
+ * store.add_file(file) -> store
+ *
+ *
+ * Adds the certificates in +file+ to the certificate store. The +file+ can
+ * contain multiple PEM-encoded certificates.
+ */
+
+static VALUE
+ossl_x509store_add_file(VALUE self, VALUE file)
+{
+ X509_STORE *store;
+ X509_LOOKUP *lookup;
+ char *path = NULL;
+
+ if(file != Qnil){
+ SafeStringValue(file);
+ path = RSTRING_PTR(file);
+ }
+ GetX509Store(self, store);
+ lookup = X509_STORE_add_lookup(store, X509_LOOKUP_file());
+ if(lookup == NULL) ossl_raise(eX509StoreError, NULL);
+ if(X509_LOOKUP_load_file(lookup, path, X509_FILETYPE_PEM) != 1){
+ ossl_raise(eX509StoreError, NULL);
+ }
+
+ return self;
+}
+
+static VALUE
+ossl_x509store_add_path(VALUE self, VALUE dir)
+{
+ X509_STORE *store;
+ X509_LOOKUP *lookup;
+ char *path = NULL;
+
+ if(dir != Qnil){
+ SafeStringValue(dir);
+ path = RSTRING_PTR(dir);
+ }
+ GetX509Store(self, store);
+ lookup = X509_STORE_add_lookup(store, X509_LOOKUP_hash_dir());
+ if(lookup == NULL) ossl_raise(eX509StoreError, NULL);
+ if(X509_LOOKUP_add_dir(lookup, path, X509_FILETYPE_PEM) != 1){
+ ossl_raise(eX509StoreError, NULL);
+ }
+
+ return self;
+}
+
+/*
+ * call-seq:
+ * store.set_default_paths
+ *
+ * Adds the default certificates to the certificate store. These certificates
+ * are loaded from the default configuration directory which can usually be
+ * determined by:
+ *
+ * File.dirname OpenSSL::Config::DEFAULT_CONFIG_FILE
+ */
+static VALUE
+ossl_x509store_set_default_paths(VALUE self)
+{
+ X509_STORE *store;
+
+ GetX509Store(self, store);
+ if (X509_STORE_set_default_paths(store) != 1){
+ ossl_raise(eX509StoreError, NULL);
+ }
+
+ return Qnil;
+}
+
+/*
+ * call-seq:
+ * store.add_cert(cert)
+ *
+ * Adds the OpenSSL::X509::Certificate +cert+ to the certificate store.
+ */
+
+static VALUE
+ossl_x509store_add_cert(VALUE self, VALUE arg)
+{
+ X509_STORE *store;
+ X509 *cert;
+
+ cert = GetX509CertPtr(arg); /* NO NEED TO DUP */
+ GetX509Store(self, store);
+ if (X509_STORE_add_cert(store, cert) != 1){
+ ossl_raise(eX509StoreError, NULL);
+ }
+
+ return self;
+}
+
+static VALUE
+ossl_x509store_add_crl(VALUE self, VALUE arg)
+{
+ X509_STORE *store;
+ X509_CRL *crl;
+
+ crl = GetX509CRLPtr(arg); /* NO NEED TO DUP */
+ GetX509Store(self, store);
+ if (X509_STORE_add_crl(store, crl) != 1){
+ ossl_raise(eX509StoreError, NULL);
+ }
+
+ return self;
+}
+
+static VALUE ossl_x509stctx_get_err(VALUE);
+static VALUE ossl_x509stctx_get_err_string(VALUE);
+static VALUE ossl_x509stctx_get_chain(VALUE);
+
+static VALUE
+ossl_x509store_verify(int argc, VALUE *argv, VALUE self)
+{
+ VALUE cert, chain;
+ VALUE ctx, proc, result;
+
+ rb_scan_args(argc, argv, "11", &cert, &chain);
+ ctx = rb_funcall(cX509StoreContext, rb_intern("new"), 3, self, cert, chain);
+ proc = rb_block_given_p() ? rb_block_proc() :
+ rb_iv_get(self, "@verify_callback");
+ rb_iv_set(ctx, "@verify_callback", proc);
+ result = rb_funcall(ctx, rb_intern("verify"), 0);
+
+ rb_iv_set(self, "@error", ossl_x509stctx_get_err(ctx));
+ rb_iv_set(self, "@error_string", ossl_x509stctx_get_err_string(ctx));
+ rb_iv_set(self, "@chain", ossl_x509stctx_get_chain(ctx));
+
+ return result;
+}
+
+/*
+ * Public Functions
+ */
+static void ossl_x509stctx_free(void*);
+
+
+static const rb_data_type_t ossl_x509stctx_type = {
+ "OpenSSL/X509/STORE_CTX",
+ {
+ 0, ossl_x509stctx_free,
+ },
+ 0, 0, RUBY_TYPED_FREE_IMMEDIATELY,
+};
+
+
+VALUE
+ossl_x509stctx_new(X509_STORE_CTX *ctx)
+{
+ VALUE obj;
+
+ WrapX509StCtx(cX509StoreContext, obj, ctx);
+
+ return obj;
+}
+
+VALUE
+ossl_x509stctx_clear_ptr(VALUE obj)
+{
+ OSSL_Check_Kind(obj, cX509StoreContext);
+ RDATA(obj)->data = NULL;
+
+ return obj;
+}
+
+/*
+ * Private functions
+ */
+static void
+ossl_x509stctx_free(void *ptr)
+{
+ X509_STORE_CTX *ctx = ptr;
+ if(ctx->untrusted)
+ sk_X509_pop_free(ctx->untrusted, X509_free);
+ if(ctx->cert)
+ X509_free(ctx->cert);
+ X509_STORE_CTX_free(ctx);
+}
+
+static VALUE
+ossl_x509stctx_alloc(VALUE klass)
+{
+ X509_STORE_CTX *ctx;
+ VALUE obj;
+
+ if((ctx = X509_STORE_CTX_new()) == NULL){
+ ossl_raise(eX509StoreError, NULL);
+ }
+ WrapX509StCtx(klass, obj, ctx);
+
+ return obj;
+}
+
+static VALUE ossl_x509stctx_set_flags(VALUE, VALUE);
+static VALUE ossl_x509stctx_set_purpose(VALUE, VALUE);
+static VALUE ossl_x509stctx_set_trust(VALUE, VALUE);
+static VALUE ossl_x509stctx_set_time(VALUE, VALUE);
+
+static VALUE
+ossl_x509stctx_initialize(int argc, VALUE *argv, VALUE self)
+{
+ VALUE store, cert, chain, t;
+ X509_STORE_CTX *ctx;
+ X509_STORE *x509st;
+ X509 *x509 = NULL;
+ STACK_OF(X509) *x509s = NULL;
+
+ rb_scan_args(argc, argv, "12", &store, &cert, &chain);
+ GetX509StCtx(self, ctx);
+ SafeGetX509Store(store, x509st);
+ if(!NIL_P(cert)) x509 = DupX509CertPtr(cert); /* NEED TO DUP */
+ if(!NIL_P(chain)) x509s = ossl_x509_ary2sk(chain);
+#if (OPENSSL_VERSION_NUMBER >= 0x00907000L)
+ if(X509_STORE_CTX_init(ctx, x509st, x509, x509s) != 1){
+ sk_X509_pop_free(x509s, X509_free);
+ ossl_raise(eX509StoreError, NULL);
+ }
+#else
+ X509_STORE_CTX_init(ctx, x509st, x509, x509s);
+ ossl_x509stctx_set_flags(self, rb_iv_get(store, "@flags"));
+ ossl_x509stctx_set_purpose(self, rb_iv_get(store, "@purpose"));
+ ossl_x509stctx_set_trust(self, rb_iv_get(store, "@trust"));
+#endif
+ if (!NIL_P(t = rb_iv_get(store, "@time")))
+ ossl_x509stctx_set_time(self, t);
+ rb_iv_set(self, "@verify_callback", rb_iv_get(store, "@verify_callback"));
+ rb_iv_set(self, "@cert", cert);
+
+ return self;
+}
+
+static VALUE
+ossl_x509stctx_verify(VALUE self)
+{
+ X509_STORE_CTX *ctx;
+ int result;
+
+ GetX509StCtx(self, ctx);
+ X509_STORE_CTX_set_ex_data(ctx, ossl_verify_cb_idx,
+ (void*)rb_iv_get(self, "@verify_callback"));
+ result = X509_verify_cert(ctx);
+
+ return result ? Qtrue : Qfalse;
+}
+
+static VALUE
+ossl_x509stctx_get_chain(VALUE self)
+{
+ X509_STORE_CTX *ctx;
+ STACK_OF(X509) *chain;
+ X509 *x509;
+ int i, num;
+ VALUE ary;
+
+ GetX509StCtx(self, ctx);
+ if((chain = X509_STORE_CTX_get_chain(ctx)) == NULL){
+ return Qnil;
+ }
+ if((num = sk_X509_num(chain)) < 0){
+ OSSL_Debug("certs in chain < 0???");
+ return rb_ary_new();
+ }
+ ary = rb_ary_new2(num);
+ for(i = 0; i < num; i++) {
+ x509 = sk_X509_value(chain, i);
+ rb_ary_push(ary, ossl_x509_new(x509));
+ }
+
+ return ary;
+}
+
+static VALUE
+ossl_x509stctx_get_err(VALUE self)
+{
+ X509_STORE_CTX *ctx;
+
+ GetX509StCtx(self, ctx);
+
+ return INT2FIX(X509_STORE_CTX_get_error(ctx));
+}
+
+static VALUE
+ossl_x509stctx_set_error(VALUE self, VALUE err)
+{
+ X509_STORE_CTX *ctx;
+
+ GetX509StCtx(self, ctx);
+ X509_STORE_CTX_set_error(ctx, NUM2INT(err));
+
+ return err;
+}
+
+static VALUE
+ossl_x509stctx_get_err_string(VALUE self)
+{
+ X509_STORE_CTX *ctx;
+ long err;
+
+ GetX509StCtx(self, ctx);
+ err = X509_STORE_CTX_get_error(ctx);
+
+ return rb_str_new2(X509_verify_cert_error_string(err));
+}
+
+static VALUE
+ossl_x509stctx_get_err_depth(VALUE self)
+{
+ X509_STORE_CTX *ctx;
+
+ GetX509StCtx(self, ctx);
+
+ return INT2FIX(X509_STORE_CTX_get_error_depth(ctx));
+}
+
+static VALUE
+ossl_x509stctx_get_curr_cert(VALUE self)
+{
+ X509_STORE_CTX *ctx;
+
+ GetX509StCtx(self, ctx);
+
+ return ossl_x509_new(X509_STORE_CTX_get_current_cert(ctx));
+}
+
+static VALUE
+ossl_x509stctx_get_curr_crl(VALUE self)
+{
+#if (OPENSSL_VERSION_NUMBER >= 0x00907000L)
+ X509_STORE_CTX *ctx;
+
+ GetX509StCtx(self, ctx);
+ if(!ctx->current_crl) return Qnil;
+
+ return ossl_x509crl_new(ctx->current_crl);
+#else
+ return Qnil;
+#endif
+}
+
+static VALUE
+ossl_x509stctx_set_flags(VALUE self, VALUE flags)
+{
+ X509_STORE_CTX *store;
+ long f = NUM2LONG(flags);
+
+ GetX509StCtx(self, store);
+ X509_STORE_CTX_set_flags(store, f);
+
+ return flags;
+}
+
+static VALUE
+ossl_x509stctx_set_purpose(VALUE self, VALUE purpose)
+{
+ X509_STORE_CTX *store;
+ int p = NUM2INT(purpose);
+
+ GetX509StCtx(self, store);
+ X509_STORE_CTX_set_purpose(store, p);
+
+ return purpose;
+}
+
+static VALUE
+ossl_x509stctx_set_trust(VALUE self, VALUE trust)
+{
+ X509_STORE_CTX *store;
+ int t = NUM2INT(trust);
+
+ GetX509StCtx(self, store);
+ X509_STORE_CTX_set_trust(store, t);
+
+ return trust;
+}
+
+/*
+ * call-seq:
+ * storectx.time = time => time
+ */
+static VALUE
+ossl_x509stctx_set_time(VALUE self, VALUE time)
+{
+ X509_STORE_CTX *store;
+ long t;
+
+ t = NUM2LONG(rb_Integer(time));
+ GetX509StCtx(self, store);
+ X509_STORE_CTX_set_time(store, 0, t);
+
+ return time;
+}
+
+/*
+ * INIT
+ */
+void
+Init_ossl_x509store(void)
+{
+ VALUE x509stctx;
+
+#if 0
+ mOSSL = rb_define_module("OpenSSL"); /* let rdoc know about mOSSL */
+ mX509 = rb_define_module_under(mOSSL, "X509");
+#endif
+
+ eX509StoreError = rb_define_class_under(mX509, "StoreError", eOSSLError);
+
+ /* Document-class: OpenSSL::X509::Store
+ *
+ * The X509 certificate store holds trusted CA certificates used to verify
+ * peer certificates.
+ *
+ * The easiest way to create a useful certificate store is:
+ *
+ * cert_store = OpenSSL::X509::Store.new
+ * cert_store.set_default_paths
+ *
+ * This will use your system's built-in certificates.
+ *
+ * If your system does not have a default set of certificates you can
+ * obtain a set from Mozilla here: http://curl.haxx.se/docs/caextract.html
+ * (Note that this set does not have an HTTPS download option so you may
+ * wish to use the firefox-db2pem.sh script to extract the certificates
+ * from a local install to avoid man-in-the-middle attacks.)
+ *
+ * After downloading or generating a cacert.pem from the above link you
+ * can create a certificate store from the pem file like this:
+ *
+ * cert_store = OpenSSL::X509::Store.new
+ * cert_store.add_file 'cacert.pem'
+ *
+ * The certificate store can be used with an SSLSocket like this:
+ *
+ * ssl_context = OpenSSL::SSL::SSLContext.new
+ * ssl_context.cert_store = cert_store
+ *
+ * tcp_socket = TCPSocket.open 'example.com', 443
+ *
+ * ssl_socket = OpenSSL::SSL::SSLSocket.new tcp_socket, ssl_context
+ */
+
+ cX509Store = rb_define_class_under(mX509, "Store", rb_cObject);
+ rb_attr(cX509Store, rb_intern("verify_callback"), 1, 0, Qfalse);
+ rb_attr(cX509Store, rb_intern("error"), 1, 0, Qfalse);
+ rb_attr(cX509Store, rb_intern("error_string"), 1, 0, Qfalse);
+ rb_attr(cX509Store, rb_intern("chain"), 1, 0, Qfalse);
+ rb_define_alloc_func(cX509Store, ossl_x509store_alloc);
+ rb_define_method(cX509Store, "initialize", ossl_x509store_initialize, -1);
+ rb_define_method(cX509Store, "verify_callback=", ossl_x509store_set_vfy_cb, 1);
+ rb_define_method(cX509Store, "flags=", ossl_x509store_set_flags, 1);
+ rb_define_method(cX509Store, "purpose=", ossl_x509store_set_purpose, 1);
+ rb_define_method(cX509Store, "trust=", ossl_x509store_set_trust, 1);
+ rb_define_method(cX509Store, "time=", ossl_x509store_set_time, 1);
+ rb_define_method(cX509Store, "add_path", ossl_x509store_add_path, 1);
+ rb_define_method(cX509Store, "add_file", ossl_x509store_add_file, 1);
+ rb_define_method(cX509Store, "set_default_paths", ossl_x509store_set_default_paths, 0);
+ rb_define_method(cX509Store, "add_cert", ossl_x509store_add_cert, 1);
+ rb_define_method(cX509Store, "add_crl", ossl_x509store_add_crl, 1);
+ rb_define_method(cX509Store, "verify", ossl_x509store_verify, -1);
+
+ cX509StoreContext = rb_define_class_under(mX509,"StoreContext",rb_cObject);
+ x509stctx = cX509StoreContext;
+ rb_define_alloc_func(cX509StoreContext, ossl_x509stctx_alloc);
+ rb_define_method(x509stctx,"initialize", ossl_x509stctx_initialize, -1);
+ rb_define_method(x509stctx,"verify", ossl_x509stctx_verify, 0);
+ rb_define_method(x509stctx,"chain", ossl_x509stctx_get_chain,0);
+ rb_define_method(x509stctx,"error", ossl_x509stctx_get_err, 0);
+ rb_define_method(x509stctx,"error=", ossl_x509stctx_set_error, 1);
+ rb_define_method(x509stctx,"error_string",ossl_x509stctx_get_err_string,0);
+ rb_define_method(x509stctx,"error_depth", ossl_x509stctx_get_err_depth, 0);
+ rb_define_method(x509stctx,"current_cert",ossl_x509stctx_get_curr_cert, 0);
+ rb_define_method(x509stctx,"current_crl", ossl_x509stctx_get_curr_crl, 0);
+ rb_define_method(x509stctx,"flags=", ossl_x509stctx_set_flags, 1);
+ rb_define_method(x509stctx,"purpose=", ossl_x509stctx_set_purpose, 1);
+ rb_define_method(x509stctx,"trust=", ossl_x509stctx_set_trust, 1);
+ rb_define_method(x509stctx,"time=", ossl_x509stctx_set_time, 1);
+
+}
diff --git a/jni/ruby/ext/openssl/ruby_missing.h b/jni/ruby/ext/openssl/ruby_missing.h
new file mode 100644
index 0000000..a36c338
--- /dev/null
+++ b/jni/ruby/ext/openssl/ruby_missing.h
@@ -0,0 +1,28 @@
+/*
+ * $Id: ruby_missing.h 33843 2011-11-26 01:49:36Z emboss $
+ * 'OpenSSL for Ruby' project
+ * Copyright (C) 2001-2003 Michal Rokos <m.rokos@sh.cvut.cz>
+ * All rights reserved.
+ */
+/*
+ * This program is licenced under the same licence as Ruby.
+ * (See the file 'LICENCE'.)
+ */
+#if !defined(_OSSL_RUBY_MISSING_H_)
+#define _OSSL_RUBY_MISSING_H_
+
+#define rb_define_copy_func(klass, func) \
+ rb_define_method((klass), "initialize_copy", (func), 1)
+
+
+#ifndef GetReadFile
+#define FPTR_TO_FD(fptr) ((fptr)->fd)
+#else
+#define FPTR_TO_FD(fptr) (fileno(GetReadFile(fptr)))
+#endif
+
+#ifndef HAVE_RB_IO_T
+#define rb_io_t OpenFile
+#endif
+
+#endif /* _OSSL_RUBY_MISSING_H_ */
diff --git a/jni/ruby/ext/pathname/Makefile b/jni/ruby/ext/pathname/Makefile
new file mode 100644
index 0000000..0a2bcb2
--- /dev/null
+++ b/jni/ruby/ext/pathname/Makefile
@@ -0,0 +1,283 @@
+
+SHELL = /bin/sh
+
+# V=0 quiet, V=1 verbose. other values don't work.
+V = 0
+Q1 = $(V:1=)
+Q = $(Q1:0=@)
+ECHO1 = $(V:1=@:)
+ECHO = $(ECHO1:0=@echo)
+NULLCMD = :
+
+#### Start of system configuration section. ####
+top_srcdir = $(topdir)/.
+srcdir = $(top_srcdir)/ext/pathname
+topdir = ../..
+hdrdir = $(top_srcdir)/include
+arch_hdrdir = $(extout)/include/$(arch)
+PATH_SEPARATOR = :
+VPATH = $(srcdir):$(arch_hdrdir)/ruby:$(hdrdir)/ruby
+RUBYLIB =
+RUBYOPT = -
+prefix = $(DESTDIR)/usr/local
+rubysitearchprefix = $(rubylibprefix)/$(sitearch)
+rubyarchprefix = $(rubylibprefix)/$(arch)
+rubylibprefix = $(libdir)/$(RUBY_BASE_NAME)
+exec_prefix = $(prefix)
+vendorarchhdrdir = $(vendorhdrdir)/$(sitearch)
+sitearchhdrdir = $(sitehdrdir)/$(sitearch)
+rubyarchhdrdir = $(rubyhdrdir)/$(arch)
+vendorhdrdir = $(rubyhdrdir)/vendor_ruby
+sitehdrdir = $(rubyhdrdir)/site_ruby
+rubyhdrdir = $(includedir)/$(RUBY_VERSION_NAME)
+vendorarchdir = $(vendorlibdir)/$(sitearch)
+vendorlibdir = $(vendordir)/$(ruby_version)
+vendordir = $(rubylibprefix)/vendor_ruby
+sitearchdir = $(sitelibdir)/$(sitearch)
+sitelibdir = $(sitedir)/$(ruby_version)
+sitedir = $(rubylibprefix)/site_ruby
+rubyarchdir = $(rubylibdir)/$(arch)
+rubylibdir = $(rubylibprefix)/$(ruby_version)
+sitearchincludedir = $(includedir)/$(sitearch)
+archincludedir = $(includedir)/$(arch)
+sitearchlibdir = $(libdir)/$(sitearch)
+archlibdir = $(libdir)/$(arch)
+ridir = $(datarootdir)/$(RI_BASE_NAME)
+mandir = $(datarootdir)/man
+localedir = $(datarootdir)/locale
+libdir = $(exec_prefix)/lib
+psdir = $(docdir)
+pdfdir = $(docdir)
+dvidir = $(docdir)
+htmldir = $(docdir)
+infodir = $(datarootdir)/info
+docdir = $(datarootdir)/doc/$(PACKAGE)
+oldincludedir = $(DESTDIR)/usr/include
+includedir = $(prefix)/include
+localstatedir = $(prefix)/var
+sharedstatedir = $(prefix)/com
+sysconfdir = $(prefix)/etc
+datadir = $(datarootdir)
+datarootdir = $(prefix)/share
+libexecdir = $(exec_prefix)/libexec
+sbindir = $(exec_prefix)/sbin
+bindir = $(exec_prefix)/bin
+archdir = $(rubyarchdir)
+
+
+CC = gcc
+CXX = g++
+LIBRUBY = $(LIBRUBY_SO)
+LIBRUBY_A = lib$(RUBY_SO_NAME)-static.a
+LIBRUBYARG_SHARED = -Wl,-R$(libdir) -L$(libdir) -l$(RUBY_SO_NAME)
+LIBRUBYARG_STATIC = -Wl,-R$(libdir) -L$(libdir) -l$(RUBY_SO_NAME)-static
+empty =
+OUTFLAG = -o $(empty)
+COUTFLAG = -o $(empty)
+
+RUBY_EXTCONF_H = extconf.h
+cflags = $(optflags) $(debugflags) $(warnflags)
+optflags = -O3 -fno-fast-math
+debugflags = -ggdb3
+warnflags = -Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wunused-variable -Wpointer-arith -Wwrite-strings -Wdeclaration-after-statement -Wimplicit-function-declaration -Wdeprecated-declarations -Wno-packed-bitfield-compat
+CCDLFLAGS = -fPIC
+CFLAGS = $(CCDLFLAGS) $(cflags) -fPIC $(ARCH_FLAG)
+INCFLAGS = -I. -I$(arch_hdrdir) -I$(hdrdir) -I$(srcdir)
+DEFS =
+CPPFLAGS = -DRUBY_EXTCONF_H=\"$(RUBY_EXTCONF_H)\" $(DEFS) $(cppflags)
+CXXFLAGS = $(CCDLFLAGS) $(cxxflags) $(ARCH_FLAG)
+ldflags = -L. -fstack-protector -rdynamic -Wl,-export-dynamic
+dldflags =
+ARCH_FLAG =
+DLDFLAGS = $(ldflags) $(dldflags) $(ARCH_FLAG)
+LDSHARED = $(CC) -shared
+LDSHAREDXX = $(CXX) -shared
+AR = ar
+EXEEXT =
+
+RUBY_INSTALL_NAME = $(RUBY_BASE_NAME)
+RUBY_SO_NAME = ruby
+RUBYW_INSTALL_NAME =
+RUBY_VERSION_NAME = $(RUBY_BASE_NAME)-$(ruby_version)
+RUBYW_BASE_NAME = rubyw
+RUBY_BASE_NAME = ruby
+
+arch = x86_64-linux
+sitearch = $(arch)
+ruby_version = 2.2.0
+ruby = $(topdir)/miniruby -I'$(topdir)' -I'$(top_srcdir)/lib' -I'$(extout)/$(arch)' -I'$(extout)/common'
+RUBY = $(ruby)
+ruby_headers = $(hdrdir)/ruby.h $(hdrdir)/ruby/ruby.h $(hdrdir)/ruby/defines.h $(hdrdir)/ruby/missing.h $(hdrdir)/ruby/intern.h $(hdrdir)/ruby/st.h $(hdrdir)/ruby/subst.h $(arch_hdrdir)/ruby/config.h $(RUBY_EXTCONF_H)
+
+RM = rm -f
+RM_RF = $(RUBY) -run -e rm -- -rf
+RMDIRS = rmdir --ignore-fail-on-non-empty -p
+MAKEDIRS = /bin/mkdir -p
+INSTALL = /usr/bin/install -c
+INSTALL_PROG = $(INSTALL) -m 0755
+INSTALL_DATA = $(INSTALL) -m 644
+COPY = cp
+TOUCH = exit >
+
+#### End of system configuration section. ####
+
+preload =
+
+libpath = . $(topdir)
+LIBPATH = -L. -L$(topdir)
+DEFFILE =
+
+CLEANFILES = mkmf.log
+DISTCLEANFILES =
+DISTCLEANDIRS =
+
+extout = $(topdir)/.ext
+extout_prefix = $(extout)$(target_prefix)/
+target_prefix =
+LOCAL_LIBS =
+LIBS = $(LIBRUBYARG_SHARED) -lpthread -lgmp -ldl -lcrypt -lm -lc
+ORIG_SRCS = pathname.c
+SRCS = $(ORIG_SRCS)
+OBJS = pathname.o
+HDRS = $(srcdir)/extconf.h
+TARGET = pathname
+TARGET_NAME = pathname
+TARGET_ENTRY = Init_$(TARGET_NAME)
+DLLIB = $(TARGET).so
+EXTSTATIC =
+STATIC_LIB = $(TARGET).a
+
+TIMESTAMP_DIR = $(extout)/.timestamp
+BINDIR = $(extout)/bin
+RUBYCOMMONDIR = $(extout)/common
+RUBYLIBDIR = $(RUBYCOMMONDIR)$(target_prefix)
+RUBYARCHDIR = $(extout)/$(arch)$(target_prefix)
+HDRDIR = $(extout)/include/ruby$(target_prefix)
+ARCHHDRDIR = $(extout)/include/$(arch)/ruby$(target_prefix)
+
+TARGET_SO = $(RUBYARCHDIR)/$(DLLIB)
+CLEANLIBS = $(RUBYARCHDIR)/$(TARGET).so
+CLEANOBJS = *.o *.bak
+
+all: install
+static: all
+.PHONY: all install static install-so install-rb
+.PHONY: clean clean-so clean-static clean-rb
+
+clean-static::
+clean-rb-default::
+clean-rb::
+clean-so::
+clean: clean-so clean-static clean-rb-default clean-rb
+ -$(Q)$(RM) $(CLEANLIBS) $(CLEANOBJS) $(CLEANFILES) .*.time
+
+distclean-rb-default::
+distclean-rb::
+distclean-so::
+distclean-static::
+distclean: clean distclean-so distclean-static distclean-rb-default distclean-rb
+ -$(Q)$(RM) Makefile $(RUBY_EXTCONF_H) conftest.* mkmf.log
+ -$(Q)$(RM) core ruby$(EXEEXT) *~ $(DISTCLEANFILES)
+ -$(Q)$(RMDIRS) $(DISTCLEANDIRS) 2> /dev/null || true
+
+realclean: distclean
+install: install-so install-rb
+
+install-so: $(RUBYARCHDIR)/$(DLLIB)
+clean-so::
+ -$(Q)$(RM) $(RUBYARCHDIR)/$(DLLIB)
+ -$(Q)$(RMDIRS) $(RUBYARCHDIR) 2> /dev/null || true
+clean-static::
+ -$(Q)$(RM) $(STATIC_LIB)
+install-rb: pre-install-rb install-rb-default
+install-rb-default: pre-install-rb-default
+pre-install-rb: Makefile
+pre-install-rb-default: Makefile
+pre-install-rb-default: $(TIMESTAMP_DIR)/.RUBYLIBDIR.time
+install-rb-default: $(RUBYLIBDIR)/pathname.rb
+$(RUBYLIBDIR)/pathname.rb: $(srcdir)/lib/pathname.rb $(TIMESTAMP_DIR)/.RUBYLIBDIR.time
+ $(Q) $(COPY) $(srcdir)/lib/pathname.rb $(@D)
+clean-rb-default::
+ -$(Q)$(RM) $(RUBYLIBDIR)/pathname.rb
+pre-install-rb-default:
+ $(ECHO) installing default pathname libraries
+clean-rb-default::
+ -$(Q)$(RMDIRS) $(RUBYLIBDIR) 2> /dev/null || true
+$(TIMESTAMP_DIR)/.RUBYARCHDIR.time:
+ $(Q) $(MAKEDIRS) $(@D) $(RUBYARCHDIR)
+ $(Q) $(TOUCH) $@
+$(TIMESTAMP_DIR)/.RUBYLIBDIR.time:
+ $(Q) $(MAKEDIRS) $(@D) $(RUBYLIBDIR)
+ $(Q) $(TOUCH) $@
+
+site-install: site-install-so site-install-rb
+site-install-so: install-so
+site-install-rb: install-rb
+
+.SUFFIXES: .c .m .cc .mm .cxx .cpp .o .S
+
+.cc.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<
+
+.cc.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -S $<
+
+.mm.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<
+
+.mm.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -S $<
+
+.cxx.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<
+
+.cxx.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -S $<
+
+.cpp.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<
+
+.cpp.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -S $<
+
+.c.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -c $<
+
+.c.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -S $<
+
+.m.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -c $<
+
+.m.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -S $<
+
+$(RUBYARCHDIR)/$(DLLIB): $(OBJS) Makefile $(TIMESTAMP_DIR)/.RUBYARCHDIR.time
+ $(ECHO) linking shared-object $(DLLIB)
+ -$(Q)$(RM) $(@)
+ $(Q) $(LDSHARED) -o $@ $(OBJS) $(LIBPATH) $(DLDFLAGS) $(LOCAL_LIBS) $(LIBS)
+
+$(STATIC_LIB): $(OBJS)
+ -$(Q)$(RM) $(@)
+ $(ECHO) linking static-library $(@)
+ $(Q) $(AR) cru $@ $(OBJS)
+ -$(Q)ranlib $(@) 2> /dev/null || true
+
+###
+$(OBJS): $(RUBY_EXTCONF_H)
+
+$(OBJS): $(HDRS) $(ruby_headers) \
+ $(hdrdir)/ruby/encoding.h \
+ $(hdrdir)/ruby/oniguruma.h
diff --git a/jni/ruby/ext/pathname/depend b/jni/ruby/ext/pathname/depend
new file mode 100644
index 0000000..79b6c53
--- /dev/null
+++ b/jni/ruby/ext/pathname/depend
@@ -0,0 +1,3 @@
+$(OBJS): $(HDRS) $(ruby_headers) \
+ $(hdrdir)/ruby/encoding.h \
+ $(hdrdir)/ruby/oniguruma.h
diff --git a/jni/ruby/ext/pathname/extconf.h b/jni/ruby/ext/pathname/extconf.h
new file mode 100644
index 0000000..cda0cc8
--- /dev/null
+++ b/jni/ruby/ext/pathname/extconf.h
@@ -0,0 +1,3 @@
+#ifndef EXTCONF_H
+#define EXTCONF_H
+#endif
diff --git a/jni/ruby/ext/pathname/extconf.rb b/jni/ruby/ext/pathname/extconf.rb
new file mode 100644
index 0000000..037f100
--- /dev/null
+++ b/jni/ruby/ext/pathname/extconf.rb
@@ -0,0 +1,3 @@
+require 'mkmf'
+have_struct_member("struct stat", "st_birthtimespec", "sys/stat.h")
+create_makefile('pathname')
diff --git a/jni/ruby/ext/pathname/lib/pathname.rb b/jni/ruby/ext/pathname/lib/pathname.rb
new file mode 100644
index 0000000..82541e9
--- /dev/null
+++ b/jni/ruby/ext/pathname/lib/pathname.rb
@@ -0,0 +1,579 @@
+#
+# = pathname.rb
+#
+# Object-Oriented Pathname Class
+#
+# Author:: Tanaka Akira <akr@m17n.org>
+# Documentation:: Author and Gavin Sinclair
+#
+# For documentation, see class Pathname.
+#
+
+require 'pathname.so'
+
+class Pathname
+
+ # :stopdoc:
+ if RUBY_VERSION < "1.9"
+ TO_PATH = :to_str
+ else
+ # to_path is implemented so Pathname objects are usable with File.open, etc.
+ TO_PATH = :to_path
+ end
+
+ SAME_PATHS = if File::FNM_SYSCASE.nonzero?
+ # Avoid #zero? here because #casecmp can return nil.
+ proc {|a, b| a.casecmp(b) == 0}
+ else
+ proc {|a, b| a == b}
+ end
+
+
+ if File::ALT_SEPARATOR
+ SEPARATOR_LIST = "#{Regexp.quote File::ALT_SEPARATOR}#{Regexp.quote File::SEPARATOR}"
+ SEPARATOR_PAT = /[#{SEPARATOR_LIST}]/
+ else
+ SEPARATOR_LIST = "#{Regexp.quote File::SEPARATOR}"
+ SEPARATOR_PAT = /#{Regexp.quote File::SEPARATOR}/
+ end
+
+ # :startdoc:
+
+ # chop_basename(path) -> [pre-basename, basename] or nil
+ def chop_basename(path) # :nodoc:
+ base = File.basename(path)
+ if /\A#{SEPARATOR_PAT}?\z/o =~ base
+ return nil
+ else
+ return path[0, path.rindex(base)], base
+ end
+ end
+ private :chop_basename
+
+ # split_names(path) -> prefix, [name, ...]
+ def split_names(path) # :nodoc:
+ names = []
+ while r = chop_basename(path)
+ path, basename = r
+ names.unshift basename
+ end
+ return path, names
+ end
+ private :split_names
+
+ def prepend_prefix(prefix, relpath) # :nodoc:
+ if relpath.empty?
+ File.dirname(prefix)
+ elsif /#{SEPARATOR_PAT}/o =~ prefix
+ prefix = File.dirname(prefix)
+ prefix = File.join(prefix, "") if File.basename(prefix + 'a') != 'a'
+ prefix + relpath
+ else
+ prefix + relpath
+ end
+ end
+ private :prepend_prefix
+
+ # Returns clean pathname of +self+ with consecutive slashes and useless dots
+ # removed. The filesystem is not accessed.
+ #
+ # If +consider_symlink+ is +true+, then a more conservative algorithm is used
+ # to avoid breaking symbolic linkages. This may retain more +..+
+ # entries than absolutely necessary, but without accessing the filesystem,
+ # this can't be avoided.
+ #
+ # See Pathname#realpath.
+ #
+ def cleanpath(consider_symlink=false)
+ if consider_symlink
+ cleanpath_conservative
+ else
+ cleanpath_aggressive
+ end
+ end
+
+ #
+ # Clean the path simply by resolving and removing excess +.+ and +..+ entries.
+ # Nothing more, nothing less.
+ #
+ def cleanpath_aggressive # :nodoc:
+ path = @path
+ names = []
+ pre = path
+ while r = chop_basename(pre)
+ pre, base = r
+ case base
+ when '.'
+ when '..'
+ names.unshift base
+ else
+ if names[0] == '..'
+ names.shift
+ else
+ names.unshift base
+ end
+ end
+ end
+ pre.tr!(File::ALT_SEPARATOR, File::SEPARATOR) if File::ALT_SEPARATOR
+ if /#{SEPARATOR_PAT}/o =~ File.basename(pre)
+ names.shift while names[0] == '..'
+ end
+ self.class.new(prepend_prefix(pre, File.join(*names)))
+ end
+ private :cleanpath_aggressive
+
+ # has_trailing_separator?(path) -> bool
+ def has_trailing_separator?(path) # :nodoc:
+ if r = chop_basename(path)
+ pre, basename = r
+ pre.length + basename.length < path.length
+ else
+ false
+ end
+ end
+ private :has_trailing_separator?
+
+ # add_trailing_separator(path) -> path
+ def add_trailing_separator(path) # :nodoc:
+ if File.basename(path + 'a') == 'a'
+ path
+ else
+ File.join(path, "") # xxx: Is File.join is appropriate to add separator?
+ end
+ end
+ private :add_trailing_separator
+
+ def del_trailing_separator(path) # :nodoc:
+ if r = chop_basename(path)
+ pre, basename = r
+ pre + basename
+ elsif /#{SEPARATOR_PAT}+\z/o =~ path
+ $` + File.dirname(path)[/#{SEPARATOR_PAT}*\z/o]
+ else
+ path
+ end
+ end
+ private :del_trailing_separator
+
+ def cleanpath_conservative # :nodoc:
+ path = @path
+ names = []
+ pre = path
+ while r = chop_basename(pre)
+ pre, base = r
+ names.unshift base if base != '.'
+ end
+ pre.tr!(File::ALT_SEPARATOR, File::SEPARATOR) if File::ALT_SEPARATOR
+ if /#{SEPARATOR_PAT}/o =~ File.basename(pre)
+ names.shift while names[0] == '..'
+ end
+ if names.empty?
+ self.class.new(File.dirname(pre))
+ else
+ if names.last != '..' && File.basename(path) == '.'
+ names << '.'
+ end
+ result = prepend_prefix(pre, File.join(*names))
+ if /\A(?:\.|\.\.)\z/ !~ names.last && has_trailing_separator?(path)
+ self.class.new(add_trailing_separator(result))
+ else
+ self.class.new(result)
+ end
+ end
+ end
+ private :cleanpath_conservative
+
+ # Returns the parent directory.
+ #
+ # This is same as <code>self + '..'</code>.
+ def parent
+ self + '..'
+ end
+
+ # Returns +true+ if +self+ points to a mountpoint.
+ def mountpoint?
+ begin
+ stat1 = self.lstat
+ stat2 = self.parent.lstat
+ stat1.dev == stat2.dev && stat1.ino == stat2.ino ||
+ stat1.dev != stat2.dev
+ rescue Errno::ENOENT
+ false
+ end
+ end
+
+ #
+ # Predicate method for root directories. Returns +true+ if the
+ # pathname consists of consecutive slashes.
+ #
+ # It doesn't access the filesystem. So it may return +false+ for some
+ # pathnames which points to roots such as <tt>/usr/..</tt>.
+ #
+ def root?
+ !!(chop_basename(@path) == nil && /#{SEPARATOR_PAT}/o =~ @path)
+ end
+
+ # Predicate method for testing whether a path is absolute.
+ #
+ # It returns +true+ if the pathname begins with a slash.
+ #
+ # p = Pathname.new('/im/sure')
+ # p.absolute?
+ # #=> true
+ #
+ # p = Pathname.new('not/so/sure')
+ # p.absolute?
+ # #=> false
+ def absolute?
+ !relative?
+ end
+
+ # The opposite of Pathname#absolute?
+ #
+ # It returns +false+ if the pathname begins with a slash.
+ #
+ # p = Pathname.new('/im/sure')
+ # p.relative?
+ # #=> false
+ #
+ # p = Pathname.new('not/so/sure')
+ # p.relative?
+ # #=> true
+ def relative?
+ path = @path
+ while r = chop_basename(path)
+ path, = r
+ end
+ path == ''
+ end
+
+ #
+ # Iterates over each component of the path.
+ #
+ # Pathname.new("/usr/bin/ruby").each_filename {|filename| ... }
+ # # yields "usr", "bin", and "ruby".
+ #
+ # Returns an Enumerator if no block was given.
+ #
+ # enum = Pathname.new("/usr/bin/ruby").each_filename
+ # # ... do stuff ...
+ # enum.each { |e| ... }
+ # # yields "usr", "bin", and "ruby".
+ #
+ def each_filename # :yield: filename
+ return to_enum(__method__) unless block_given?
+ _, names = split_names(@path)
+ names.each {|filename| yield filename }
+ nil
+ end
+
+ # Iterates over and yields a new Pathname object
+ # for each element in the given path in descending order.
+ #
+ # Pathname.new('/path/to/some/file.rb').descend {|v| p v}
+ # #<Pathname:/>
+ # #<Pathname:/path>
+ # #<Pathname:/path/to>
+ # #<Pathname:/path/to/some>
+ # #<Pathname:/path/to/some/file.rb>
+ #
+ # Pathname.new('path/to/some/file.rb').descend {|v| p v}
+ # #<Pathname:path>
+ # #<Pathname:path/to>
+ # #<Pathname:path/to/some>
+ # #<Pathname:path/to/some/file.rb>
+ #
+ # It doesn't access the filesystem.
+ #
+ def descend
+ vs = []
+ ascend {|v| vs << v }
+ vs.reverse_each {|v| yield v }
+ nil
+ end
+
+ # Iterates over and yields a new Pathname object
+ # for each element in the given path in ascending order.
+ #
+ # Pathname.new('/path/to/some/file.rb').ascend {|v| p v}
+ # #<Pathname:/path/to/some/file.rb>
+ # #<Pathname:/path/to/some>
+ # #<Pathname:/path/to>
+ # #<Pathname:/path>
+ # #<Pathname:/>
+ #
+ # Pathname.new('path/to/some/file.rb').ascend {|v| p v}
+ # #<Pathname:path/to/some/file.rb>
+ # #<Pathname:path/to/some>
+ # #<Pathname:path/to>
+ # #<Pathname:path>
+ #
+ # It doesn't access the filesystem.
+ #
+ def ascend
+ path = @path
+ yield self
+ while r = chop_basename(path)
+ path, = r
+ break if path.empty?
+ yield self.class.new(del_trailing_separator(path))
+ end
+ end
+
+ #
+ # Appends a pathname fragment to +self+ to produce a new Pathname object.
+ #
+ # p1 = Pathname.new("/usr") # Pathname:/usr
+ # p2 = p1 + "bin/ruby" # Pathname:/usr/bin/ruby
+ # p3 = p1 + "/etc/passwd" # Pathname:/etc/passwd
+ #
+ # # / is aliased to +.
+ # p4 = p1 / "bin/ruby" # Pathname:/usr/bin/ruby
+ # p5 = p1 / "/etc/passwd" # Pathname:/etc/passwd
+ #
+ # This method doesn't access the file system; it is pure string manipulation.
+ #
+ def +(other)
+ other = Pathname.new(other) unless Pathname === other
+ Pathname.new(plus(@path, other.to_s))
+ end
+ alias / +
+
+ def plus(path1, path2) # -> path # :nodoc:
+ prefix2 = path2
+ index_list2 = []
+ basename_list2 = []
+ while r2 = chop_basename(prefix2)
+ prefix2, basename2 = r2
+ index_list2.unshift prefix2.length
+ basename_list2.unshift basename2
+ end
+ return path2 if prefix2 != ''
+ prefix1 = path1
+ while true
+ while !basename_list2.empty? && basename_list2.first == '.'
+ index_list2.shift
+ basename_list2.shift
+ end
+ break unless r1 = chop_basename(prefix1)
+ prefix1, basename1 = r1
+ next if basename1 == '.'
+ if basename1 == '..' || basename_list2.empty? || basename_list2.first != '..'
+ prefix1 = prefix1 + basename1
+ break
+ end
+ index_list2.shift
+ basename_list2.shift
+ end
+ r1 = chop_basename(prefix1)
+ if !r1 && /#{SEPARATOR_PAT}/o =~ File.basename(prefix1)
+ while !basename_list2.empty? && basename_list2.first == '..'
+ index_list2.shift
+ basename_list2.shift
+ end
+ end
+ if !basename_list2.empty?
+ suffix2 = path2[index_list2.first..-1]
+ r1 ? File.join(prefix1, suffix2) : prefix1 + suffix2
+ else
+ r1 ? prefix1 : File.dirname(prefix1)
+ end
+ end
+ private :plus
+
+ #
+ # Joins the given pathnames onto +self+ to create a new Pathname object.
+ #
+ # path0 = Pathname.new("/usr") # Pathname:/usr
+ # path0 = path0.join("bin/ruby") # Pathname:/usr/bin/ruby
+ # # is the same as
+ # path1 = Pathname.new("/usr") + "bin/ruby" # Pathname:/usr/bin/ruby
+ # path0 == path1
+ # #=> true
+ #
+ def join(*args)
+ return self if args.empty?
+ result = args.pop
+ result = Pathname.new(result) unless Pathname === result
+ return result if result.absolute?
+ args.reverse_each {|arg|
+ arg = Pathname.new(arg) unless Pathname === arg
+ result = arg + result
+ return result if result.absolute?
+ }
+ self + result
+ end
+
+ #
+ # Returns the children of the directory (files and subdirectories, not
+ # recursive) as an array of Pathname objects.
+ #
+ # By default, the returned pathnames will have enough information to access
+ # the files. If you set +with_directory+ to +false+, then the returned
+ # pathnames will contain the filename only.
+ #
+ # For example:
+ # pn = Pathname("/usr/lib/ruby/1.8")
+ # pn.children
+ # # -> [ Pathname:/usr/lib/ruby/1.8/English.rb,
+ # Pathname:/usr/lib/ruby/1.8/Env.rb,
+ # Pathname:/usr/lib/ruby/1.8/abbrev.rb, ... ]
+ # pn.children(false)
+ # # -> [ Pathname:English.rb, Pathname:Env.rb, Pathname:abbrev.rb, ... ]
+ #
+ # Note that the results never contain the entries +.+ and +..+ in
+ # the directory because they are not children.
+ #
+ def children(with_directory=true)
+ with_directory = false if @path == '.'
+ result = []
+ Dir.foreach(@path) {|e|
+ next if e == '.' || e == '..'
+ if with_directory
+ result << self.class.new(File.join(@path, e))
+ else
+ result << self.class.new(e)
+ end
+ }
+ result
+ end
+
+ # Iterates over the children of the directory
+ # (files and subdirectories, not recursive).
+ #
+ # It yields Pathname object for each child.
+ #
+ # By default, the yielded pathnames will have enough information to access
+ # the files.
+ #
+ # If you set +with_directory+ to +false+, then the returned pathnames will
+ # contain the filename only.
+ #
+ # Pathname("/usr/local").each_child {|f| p f }
+ # #=> #<Pathname:/usr/local/share>
+ # # #<Pathname:/usr/local/bin>
+ # # #<Pathname:/usr/local/games>
+ # # #<Pathname:/usr/local/lib>
+ # # #<Pathname:/usr/local/include>
+ # # #<Pathname:/usr/local/sbin>
+ # # #<Pathname:/usr/local/src>
+ # # #<Pathname:/usr/local/man>
+ #
+ # Pathname("/usr/local").each_child(false) {|f| p f }
+ # #=> #<Pathname:share>
+ # # #<Pathname:bin>
+ # # #<Pathname:games>
+ # # #<Pathname:lib>
+ # # #<Pathname:include>
+ # # #<Pathname:sbin>
+ # # #<Pathname:src>
+ # # #<Pathname:man>
+ #
+ # Note that the results never contain the entries +.+ and +..+ in
+ # the directory because they are not children.
+ #
+ # See Pathname#children
+ #
+ def each_child(with_directory=true, &b)
+ children(with_directory).each(&b)
+ end
+
+ #
+ # Returns a relative path from the given +base_directory+ to the receiver.
+ #
+ # If +self+ is absolute, then +base_directory+ must be absolute too.
+ #
+ # If +self+ is relative, then +base_directory+ must be relative too.
+ #
+ # This method doesn't access the filesystem. It assumes no symlinks.
+ #
+ # ArgumentError is raised when it cannot find a relative path.
+ #
+ def relative_path_from(base_directory)
+ dest_directory = self.cleanpath.to_s
+ base_directory = base_directory.cleanpath.to_s
+ dest_prefix = dest_directory
+ dest_names = []
+ while r = chop_basename(dest_prefix)
+ dest_prefix, basename = r
+ dest_names.unshift basename if basename != '.'
+ end
+ base_prefix = base_directory
+ base_names = []
+ while r = chop_basename(base_prefix)
+ base_prefix, basename = r
+ base_names.unshift basename if basename != '.'
+ end
+ unless SAME_PATHS[dest_prefix, base_prefix]
+ raise ArgumentError, "different prefix: #{dest_prefix.inspect} and #{base_directory.inspect}"
+ end
+ while !dest_names.empty? &&
+ !base_names.empty? &&
+ SAME_PATHS[dest_names.first, base_names.first]
+ dest_names.shift
+ base_names.shift
+ end
+ if base_names.include? '..'
+ raise ArgumentError, "base_directory has ..: #{base_directory.inspect}"
+ end
+ base_names.fill('..')
+ relpath_names = base_names + dest_names
+ if relpath_names.empty?
+ Pathname.new('.')
+ else
+ Pathname.new(File.join(*relpath_names))
+ end
+ end
+end
+
+
+class Pathname # * Find *
+ #
+ # Iterates over the directory tree in a depth first manner, yielding a
+ # Pathname for each file under "this" directory.
+ #
+ # Returns an Enumerator if no block is given.
+ #
+ # Since it is implemented by the standard library module Find, Find.prune can
+ # be used to control the traversal.
+ #
+ # If +self+ is +.+, yielded pathnames begin with a filename in the
+ # current directory, not +./+.
+ #
+ # See Find.find
+ #
+ def find(ignore_error: true) # :yield: pathname
+ return to_enum(__method__, ignore_error: ignore_error) unless block_given?
+ require 'find'
+ if @path == '.'
+ Find.find(@path, ignore_error: ignore_error) {|f| yield self.class.new(f.sub(%r{\A\./}, '')) }
+ else
+ Find.find(@path, ignore_error: ignore_error) {|f| yield self.class.new(f) }
+ end
+ end
+end
+
+
+class Pathname # * FileUtils *
+ # Creates a full path, including any intermediate directories that don't yet
+ # exist.
+ #
+ # See FileUtils.mkpath and FileUtils.mkdir_p
+ def mkpath
+ require 'fileutils'
+ FileUtils.mkpath(@path)
+ nil
+ end
+
+ # Recursively deletes a directory, including all directories beneath it.
+ #
+ # See FileUtils.rm_r
+ def rmtree
+ # The name "rmtree" is borrowed from File::Path of Perl.
+ # File::Path provides "mkpath" and "rmtree".
+ require 'fileutils'
+ FileUtils.rm_r(@path)
+ nil
+ end
+end
+
diff --git a/jni/ruby/ext/pathname/pathname.c b/jni/ruby/ext/pathname/pathname.c
new file mode 100644
index 0000000..982ef0f
--- /dev/null
+++ b/jni/ruby/ext/pathname/pathname.c
@@ -0,0 +1,1463 @@
+#include "ruby.h"
+#include "ruby/encoding.h"
+
+static VALUE rb_cPathname;
+static ID id_at_path, id_to_path;
+
+static VALUE
+get_strpath(VALUE obj)
+{
+ VALUE strpath;
+ strpath = rb_ivar_get(obj, id_at_path);
+ if (!RB_TYPE_P(strpath, T_STRING))
+ rb_raise(rb_eTypeError, "unexpected @path");
+ return strpath;
+}
+
+static void
+set_strpath(VALUE obj, VALUE val)
+{
+ rb_ivar_set(obj, id_at_path, val);
+}
+
+/*
+ * Create a Pathname object from the given String (or String-like object).
+ * If +path+ contains a NULL character (<tt>\0</tt>), an ArgumentError is raised.
+ */
+static VALUE
+path_initialize(VALUE self, VALUE arg)
+{
+ VALUE str;
+ if (RB_TYPE_P(arg, T_STRING)) {
+ str = arg;
+ }
+ else {
+ str = rb_check_funcall(arg, id_to_path, 0, NULL);
+ if (str == Qundef)
+ str = arg;
+ StringValue(str);
+ }
+ if (memchr(RSTRING_PTR(str), '\0', RSTRING_LEN(str)))
+ rb_raise(rb_eArgError, "pathname contains null byte");
+ str = rb_obj_dup(str);
+
+ set_strpath(self, str);
+ OBJ_INFECT(self, str);
+ return self;
+}
+
+/*
+ * call-seq:
+ * pathname.freeze -> obj
+ *
+ * Freezes this Pathname.
+ *
+ * See Object.freeze.
+ */
+static VALUE
+path_freeze(VALUE self)
+{
+ rb_call_super(0, 0);
+ rb_str_freeze(get_strpath(self));
+ return self;
+}
+
+/*
+ * call-seq:
+ * pathname.taint -> obj
+ *
+ * Taints this Pathname.
+ *
+ * See Object.taint.
+ */
+static VALUE
+path_taint(VALUE self)
+{
+ rb_call_super(0, 0);
+ rb_obj_taint(get_strpath(self));
+ return self;
+}
+
+/*
+ * call-seq:
+ * pathname.untaint -> obj
+ *
+ * Untaints this Pathname.
+ *
+ * See Object.untaint.
+ */
+static VALUE
+path_untaint(VALUE self)
+{
+ rb_call_super(0, 0);
+ rb_obj_untaint(get_strpath(self));
+ return self;
+}
+
+/*
+ * Compare this pathname with +other+. The comparison is string-based.
+ * Be aware that two different paths (<tt>foo.txt</tt> and <tt>./foo.txt</tt>)
+ * can refer to the same file.
+ */
+static VALUE
+path_eq(VALUE self, VALUE other)
+{
+ if (!rb_obj_is_kind_of(other, rb_cPathname))
+ return Qfalse;
+ return rb_str_equal(get_strpath(self), get_strpath(other));
+}
+
+/*
+ * Provides a case-sensitive comparison operator for pathnames.
+ *
+ * Pathname.new('/usr') <=> Pathname.new('/usr/bin')
+ * #=> -1
+ * Pathname.new('/usr/bin') <=> Pathname.new('/usr/bin')
+ * #=> 0
+ * Pathname.new('/usr/bin') <=> Pathname.new('/USR/BIN')
+ * #=> 1
+ *
+ * It will return +-1+, +0+ or +1+ depending on the value of the left argument
+ * relative to the right argument. Or it will return +nil+ if the arguments
+ * are not comparable.
+ */
+static VALUE
+path_cmp(VALUE self, VALUE other)
+{
+ VALUE s1, s2;
+ char *p1, *p2;
+ char *e1, *e2;
+ if (!rb_obj_is_kind_of(other, rb_cPathname))
+ return Qnil;
+ s1 = get_strpath(self);
+ s2 = get_strpath(other);
+ p1 = RSTRING_PTR(s1);
+ p2 = RSTRING_PTR(s2);
+ e1 = p1 + RSTRING_LEN(s1);
+ e2 = p2 + RSTRING_LEN(s2);
+ while (p1 < e1 && p2 < e2) {
+ int c1, c2;
+ c1 = (unsigned char)*p1++;
+ c2 = (unsigned char)*p2++;
+ if (c1 == '/') c1 = '\0';
+ if (c2 == '/') c2 = '\0';
+ if (c1 != c2) {
+ if (c1 < c2)
+ return INT2FIX(-1);
+ else
+ return INT2FIX(1);
+ }
+ }
+ if (p1 < e1)
+ return INT2FIX(1);
+ if (p2 < e2)
+ return INT2FIX(-1);
+ return INT2FIX(0);
+}
+
+/* :nodoc: */
+static VALUE
+path_hash(VALUE self)
+{
+ return INT2FIX(rb_str_hash(get_strpath(self)));
+}
+
+/*
+ * call-seq:
+ * pathname.to_s -> string
+ * pathname.to_path -> string
+ *
+ * Return the path as a String.
+ *
+ * to_path is implemented so Pathname objects are usable with File.open, etc.
+ */
+static VALUE
+path_to_s(VALUE self)
+{
+ return rb_obj_dup(get_strpath(self));
+}
+
+/* :nodoc: */
+static VALUE
+path_inspect(VALUE self)
+{
+ const char *c = rb_obj_classname(self);
+ VALUE str = get_strpath(self);
+ return rb_sprintf("#<%s:%"PRIsVALUE">", c, str);
+}
+
+/*
+ * Return a pathname which is substituted by String#sub.
+ *
+ * path1 = Pathname.new('/usr/bin/perl')
+ * path1.sub('perl', 'ruby')
+ * #=> #<Pathname:/usr/bin/ruby>
+ */
+static VALUE
+path_sub(int argc, VALUE *argv, VALUE self)
+{
+ VALUE str = get_strpath(self);
+
+ if (rb_block_given_p()) {
+ str = rb_block_call(str, rb_intern("sub"), argc, argv, 0, 0);
+ }
+ else {
+ str = rb_funcall2(str, rb_intern("sub"), argc, argv);
+ }
+ return rb_class_new_instance(1, &str, rb_obj_class(self));
+}
+
+/*
+ * Return a pathname with +repl+ added as a suffix to the basename.
+ *
+ * If self has no extension part, +repl+ is appended.
+ *
+ * Pathname.new('/usr/bin/shutdown').sub_ext('.rb')
+ * #=> #<Pathname:/usr/bin/shutdown.rb>
+ */
+static VALUE
+path_sub_ext(VALUE self, VALUE repl)
+{
+ VALUE str = get_strpath(self);
+ VALUE str2;
+ long extlen;
+ const char *ext;
+ const char *p;
+
+ StringValue(repl);
+ p = RSTRING_PTR(str);
+ extlen = RSTRING_LEN(str);
+ ext = ruby_enc_find_extname(p, &extlen, rb_enc_get(str));
+ if (ext == NULL) {
+ ext = p + RSTRING_LEN(str);
+ }
+ else if (extlen <= 1) {
+ ext += extlen;
+ }
+ str2 = rb_str_subseq(str, 0, ext-p);
+ rb_str_append(str2, repl);
+ OBJ_INFECT(str2, str);
+ return rb_class_new_instance(1, &str2, rb_obj_class(self));
+}
+
+/* Facade for File */
+
+/*
+ * Returns the real (absolute) pathname for +self+ in the actual
+ * filesystem.
+ *
+ * Does not contain symlinks or useless dots, +..+ and +.+.
+ *
+ * All components of the pathname must exist when this method is
+ * called.
+ *
+ */
+static VALUE
+path_realpath(int argc, VALUE *argv, VALUE self)
+{
+ VALUE basedir, str;
+ rb_scan_args(argc, argv, "01", &basedir);
+ str = rb_funcall(rb_cFile, rb_intern("realpath"), 2, get_strpath(self), basedir);
+ return rb_class_new_instance(1, &str, rb_obj_class(self));
+}
+
+/*
+ * Returns the real (absolute) pathname of +self+ in the actual filesystem.
+ *
+ * Does not contain symlinks or useless dots, +..+ and +.+.
+ *
+ * The last component of the real pathname can be nonexistent.
+ */
+static VALUE
+path_realdirpath(int argc, VALUE *argv, VALUE self)
+{
+ VALUE basedir, str;
+ rb_scan_args(argc, argv, "01", &basedir);
+ str = rb_funcall(rb_cFile, rb_intern("realdirpath"), 2, get_strpath(self), basedir);
+ return rb_class_new_instance(1, &str, rb_obj_class(self));
+}
+
+/*
+ * call-seq:
+ * pathname.each_line {|line| ... }
+ * pathname.each_line(sep=$/ [, open_args]) {|line| block } -> nil
+ * pathname.each_line(limit [, open_args]) {|line| block } -> nil
+ * pathname.each_line(sep, limit [, open_args]) {|line| block } -> nil
+ * pathname.each_line(...) -> an_enumerator
+ *
+ * Iterates over each line in the file and yields a String object for each.
+ */
+static VALUE
+path_each_line(int argc, VALUE *argv, VALUE self)
+{
+ VALUE args[4];
+ int n;
+
+ args[0] = get_strpath(self);
+ n = rb_scan_args(argc, argv, "03", &args[1], &args[2], &args[3]);
+ if (rb_block_given_p()) {
+ return rb_block_call(rb_cIO, rb_intern("foreach"), 1+n, args, 0, 0);
+ }
+ else {
+ return rb_funcall2(rb_cIO, rb_intern("foreach"), 1+n, args);
+ }
+}
+
+/*
+ * call-seq:
+ * pathname.read([length [, offset]]) -> string
+ * pathname.read([length [, offset]], open_args) -> string
+ *
+ * Returns all data from the file, or the first +N+ bytes if specified.
+ *
+ * See IO.read.
+ *
+ */
+static VALUE
+path_read(int argc, VALUE *argv, VALUE self)
+{
+ VALUE args[4];
+ int n;
+
+ args[0] = get_strpath(self);
+ n = rb_scan_args(argc, argv, "03", &args[1], &args[2], &args[3]);
+ return rb_funcall2(rb_cIO, rb_intern("read"), 1+n, args);
+}
+
+/*
+ * call-seq:
+ * pathname.binread([length [, offset]]) -> string
+ *
+ * Returns all the bytes from the file, or the first +N+ if specified.
+ *
+ * See IO.binread.
+ *
+ */
+static VALUE
+path_binread(int argc, VALUE *argv, VALUE self)
+{
+ VALUE args[3];
+ int n;
+
+ args[0] = get_strpath(self);
+ n = rb_scan_args(argc, argv, "02", &args[1], &args[2]);
+ return rb_funcall2(rb_cIO, rb_intern("binread"), 1+n, args);
+}
+
+/*
+ * call-seq:
+ * pathname.write(string, [offset] ) => fixnum
+ * pathname.write(string, [offset], open_args ) => fixnum
+ *
+ * Writes +contents+ to the file.
+ *
+ * See IO.write.
+ *
+ */
+static VALUE
+path_write(int argc, VALUE *argv, VALUE self)
+{
+ VALUE args[4];
+ int n;
+
+ args[0] = get_strpath(self);
+ n = rb_scan_args(argc, argv, "03", &args[1], &args[2], &args[3]);
+ return rb_funcall2(rb_cIO, rb_intern("write"), 1+n, args);
+}
+
+/*
+ * call-seq:
+ * pathname.binwrite(string, [offset] ) => fixnum
+ * pathname.binwrite(string, [offset], open_args ) => fixnum
+ *
+ * Writes +contents+ to the file, opening it in binary mode.
+ *
+ * See IO.binwrite.
+ *
+ */
+static VALUE
+path_binwrite(int argc, VALUE *argv, VALUE self)
+{
+ VALUE args[4];
+ int n;
+
+ args[0] = get_strpath(self);
+ n = rb_scan_args(argc, argv, "03", &args[1], &args[2], &args[3]);
+ return rb_funcall2(rb_cIO, rb_intern("binwrite"), 1+n, args);
+}
+
+/*
+ * call-seq:
+ * pathname.readlines(sep=$/ [, open_args]) -> array
+ * pathname.readlines(limit [, open_args]) -> array
+ * pathname.readlines(sep, limit [, open_args]) -> array
+ *
+ * Returns all the lines from the file.
+ *
+ * See IO.readlines.
+ *
+ */
+static VALUE
+path_readlines(int argc, VALUE *argv, VALUE self)
+{
+ VALUE args[4];
+ int n;
+
+ args[0] = get_strpath(self);
+ n = rb_scan_args(argc, argv, "03", &args[1], &args[2], &args[3]);
+ return rb_funcall2(rb_cIO, rb_intern("readlines"), 1+n, args);
+}
+
+/*
+ * call-seq:
+ * pathname.sysopen([mode, [perm]]) -> fixnum
+ *
+ * See IO.sysopen.
+ *
+ */
+static VALUE
+path_sysopen(int argc, VALUE *argv, VALUE self)
+{
+ VALUE args[3];
+ int n;
+
+ args[0] = get_strpath(self);
+ n = rb_scan_args(argc, argv, "02", &args[1], &args[2]);
+ return rb_funcall2(rb_cIO, rb_intern("sysopen"), 1+n, args);
+}
+
+/*
+ * call-seq:
+ * pathname.atime -> time
+ *
+ * Returns the last access time for the file.
+ *
+ * See File.atime.
+ */
+static VALUE
+path_atime(VALUE self)
+{
+ return rb_funcall(rb_cFile, rb_intern("atime"), 1, get_strpath(self));
+}
+
+#if defined(HAVE_STRUCT_STAT_ST_BIRTHTIMESPEC) || defined(_WIN32)
+/*
+ * call-seq:
+ * pathname.birthtime -> time
+ *
+ * Returns the birth time for the file.
+ * If the platform doesn't have birthtime, returns <i>ctime</i>.
+ *
+ * See File.birthtime.
+ */
+static VALUE
+path_birthtime(VALUE self)
+{
+ return rb_funcall(rb_cFile, rb_intern("birthtime"), 1, get_strpath(self));
+}
+#else
+# define path_birthtime rb_f_notimplement
+#endif
+
+/*
+ * call-seq:
+ * pathname.ctime -> time
+ *
+ * Returns the last change time, using directory information, not the file itself.
+ *
+ * See File.ctime.
+ */
+static VALUE
+path_ctime(VALUE self)
+{
+ return rb_funcall(rb_cFile, rb_intern("ctime"), 1, get_strpath(self));
+}
+
+/*
+ * call-seq:
+ * pathname.mtime -> time
+ *
+ * Returns the last modified time of the file.
+ *
+ * See File.mtime.
+ */
+static VALUE
+path_mtime(VALUE self)
+{
+ return rb_funcall(rb_cFile, rb_intern("mtime"), 1, get_strpath(self));
+}
+
+/*
+ * call-seq:
+ * pathname.chmod -> integer
+ *
+ * Changes file permissions.
+ *
+ * See File.chmod.
+ */
+static VALUE
+path_chmod(VALUE self, VALUE mode)
+{
+ return rb_funcall(rb_cFile, rb_intern("chmod"), 2, mode, get_strpath(self));
+}
+
+/*
+ * call-seq:
+ * pathname.lchmod -> integer
+ *
+ * Same as Pathname.chmod, but does not follow symbolic links.
+ *
+ * See File.lchmod.
+ */
+static VALUE
+path_lchmod(VALUE self, VALUE mode)
+{
+ return rb_funcall(rb_cFile, rb_intern("lchmod"), 2, mode, get_strpath(self));
+}
+
+/*
+ * call-seq:
+ * pathname.chown -> integer
+ *
+ * Change owner and group of the file.
+ *
+ * See File.chown.
+ */
+static VALUE
+path_chown(VALUE self, VALUE owner, VALUE group)
+{
+ return rb_funcall(rb_cFile, rb_intern("chown"), 3, owner, group, get_strpath(self));
+}
+
+/*
+ * call-seq:
+ * pathname.lchown -> integer
+ *
+ * Same as Pathname.chown, but does not follow symbolic links.
+ *
+ * See File.lchown.
+ */
+static VALUE
+path_lchown(VALUE self, VALUE owner, VALUE group)
+{
+ return rb_funcall(rb_cFile, rb_intern("lchown"), 3, owner, group, get_strpath(self));
+}
+
+/*
+ * call-seq:
+ * pathname.fnmatch(pattern, [flags]) -> string
+ * pathname.fnmatch?(pattern, [flags]) -> string
+ *
+ * Return +true+ if the receiver matches the given pattern.
+ *
+ * See File.fnmatch.
+ */
+static VALUE
+path_fnmatch(int argc, VALUE *argv, VALUE self)
+{
+ VALUE str = get_strpath(self);
+ VALUE pattern, flags;
+ if (rb_scan_args(argc, argv, "11", &pattern, &flags) == 1)
+ return rb_funcall(rb_cFile, rb_intern("fnmatch"), 2, pattern, str);
+ else
+ return rb_funcall(rb_cFile, rb_intern("fnmatch"), 3, pattern, str, flags);
+}
+
+/*
+ * call-seq:
+ * pathname.ftype -> string
+ *
+ * Returns "type" of file ("file", "directory", etc).
+ *
+ * See File.ftype.
+ */
+static VALUE
+path_ftype(VALUE self)
+{
+ return rb_funcall(rb_cFile, rb_intern("ftype"), 1, get_strpath(self));
+}
+
+/*
+ * call-seq:
+ * pathname.make_link(old)
+ *
+ * Creates a hard link at _pathname_.
+ *
+ * See File.link.
+ */
+static VALUE
+path_make_link(VALUE self, VALUE old)
+{
+ return rb_funcall(rb_cFile, rb_intern("link"), 2, old, get_strpath(self));
+}
+
+/*
+ * Opens the file for reading or writing.
+ *
+ * See File.open.
+ */
+static VALUE
+path_open(int argc, VALUE *argv, VALUE self)
+{
+ VALUE args[4];
+ int n;
+
+ args[0] = get_strpath(self);
+ n = rb_scan_args(argc, argv, "03", &args[1], &args[2], &args[3]);
+ if (rb_block_given_p()) {
+ return rb_block_call(rb_cFile, rb_intern("open"), 1+n, args, 0, 0);
+ }
+ else {
+ return rb_funcall2(rb_cFile, rb_intern("open"), 1+n, args);
+ }
+}
+
+/*
+ * Read symbolic link.
+ *
+ * See File.readlink.
+ */
+static VALUE
+path_readlink(VALUE self)
+{
+ VALUE str;
+ str = rb_funcall(rb_cFile, rb_intern("readlink"), 1, get_strpath(self));
+ return rb_class_new_instance(1, &str, rb_obj_class(self));
+}
+
+/*
+ * Rename the file.
+ *
+ * See File.rename.
+ */
+static VALUE
+path_rename(VALUE self, VALUE to)
+{
+ return rb_funcall(rb_cFile, rb_intern("rename"), 2, get_strpath(self), to);
+}
+
+/*
+ * Returns a File::Stat object.
+ *
+ * See File.stat.
+ */
+static VALUE
+path_stat(VALUE self)
+{
+ return rb_funcall(rb_cFile, rb_intern("stat"), 1, get_strpath(self));
+}
+
+/*
+ * See File.lstat.
+ */
+static VALUE
+path_lstat(VALUE self)
+{
+ return rb_funcall(rb_cFile, rb_intern("lstat"), 1, get_strpath(self));
+}
+
+/*
+ * call-seq:
+ * pathname.make_symlink(old)
+ *
+ * Creates a symbolic link.
+ *
+ * See File.symlink.
+ */
+static VALUE
+path_make_symlink(VALUE self, VALUE old)
+{
+ return rb_funcall(rb_cFile, rb_intern("symlink"), 2, old, get_strpath(self));
+}
+
+/*
+ * Truncates the file to +length+ bytes.
+ *
+ * See File.truncate.
+ */
+static VALUE
+path_truncate(VALUE self, VALUE length)
+{
+ return rb_funcall(rb_cFile, rb_intern("truncate"), 2, get_strpath(self), length);
+}
+
+/*
+ * Update the access and modification times of the file.
+ *
+ * See File.utime.
+ */
+static VALUE
+path_utime(VALUE self, VALUE atime, VALUE mtime)
+{
+ return rb_funcall(rb_cFile, rb_intern("utime"), 3, atime, mtime, get_strpath(self));
+}
+
+/*
+ * Returns the last component of the path.
+ *
+ * See File.basename.
+ */
+static VALUE
+path_basename(int argc, VALUE *argv, VALUE self)
+{
+ VALUE str = get_strpath(self);
+ VALUE fext;
+ if (rb_scan_args(argc, argv, "01", &fext) == 0)
+ str = rb_funcall(rb_cFile, rb_intern("basename"), 1, str);
+ else
+ str = rb_funcall(rb_cFile, rb_intern("basename"), 2, str, fext);
+ return rb_class_new_instance(1, &str, rb_obj_class(self));
+}
+
+/*
+ * Returns all but the last component of the path.
+ *
+ * See File.dirname.
+ */
+static VALUE
+path_dirname(VALUE self)
+{
+ VALUE str = get_strpath(self);
+ str = rb_funcall(rb_cFile, rb_intern("dirname"), 1, str);
+ return rb_class_new_instance(1, &str, rb_obj_class(self));
+}
+
+/*
+ * Returns the file's extension.
+ *
+ * See File.extname.
+ */
+static VALUE
+path_extname(VALUE self)
+{
+ VALUE str = get_strpath(self);
+ return rb_funcall(rb_cFile, rb_intern("extname"), 1, str);
+}
+
+/*
+ * Returns the absolute path for the file.
+ *
+ * See File.expand_path.
+ */
+static VALUE
+path_expand_path(int argc, VALUE *argv, VALUE self)
+{
+ VALUE str = get_strpath(self);
+ VALUE dname;
+ if (rb_scan_args(argc, argv, "01", &dname) == 0)
+ str = rb_funcall(rb_cFile, rb_intern("expand_path"), 1, str);
+ else
+ str = rb_funcall(rb_cFile, rb_intern("expand_path"), 2, str, dname);
+ return rb_class_new_instance(1, &str, rb_obj_class(self));
+}
+
+/*
+ * Returns the #dirname and the #basename in an Array.
+ *
+ * See File.split.
+ */
+static VALUE
+path_split(VALUE self)
+{
+ VALUE str = get_strpath(self);
+ VALUE ary, dirname, basename;
+ ary = rb_funcall(rb_cFile, rb_intern("split"), 1, str);
+ ary = rb_check_array_type(ary);
+ dirname = rb_ary_entry(ary, 0);
+ basename = rb_ary_entry(ary, 1);
+ dirname = rb_class_new_instance(1, &dirname, rb_obj_class(self));
+ basename = rb_class_new_instance(1, &basename, rb_obj_class(self));
+ return rb_ary_new3(2, dirname, basename);
+}
+
+/*
+ * See FileTest.blockdev?.
+ */
+static VALUE
+path_blockdev_p(VALUE self)
+{
+ return rb_funcall(rb_mFileTest, rb_intern("blockdev?"), 1, get_strpath(self));
+}
+
+/*
+ * See FileTest.chardev?.
+ */
+static VALUE
+path_chardev_p(VALUE self)
+{
+ return rb_funcall(rb_mFileTest, rb_intern("chardev?"), 1, get_strpath(self));
+}
+
+/*
+ * See FileTest.executable?.
+ */
+static VALUE
+path_executable_p(VALUE self)
+{
+ return rb_funcall(rb_mFileTest, rb_intern("executable?"), 1, get_strpath(self));
+}
+
+/*
+ * See FileTest.executable_real?.
+ */
+static VALUE
+path_executable_real_p(VALUE self)
+{
+ return rb_funcall(rb_mFileTest, rb_intern("executable_real?"), 1, get_strpath(self));
+}
+
+/*
+ * See FileTest.exist?.
+ */
+static VALUE
+path_exist_p(VALUE self)
+{
+ return rb_funcall(rb_mFileTest, rb_intern("exist?"), 1, get_strpath(self));
+}
+
+/*
+ * See FileTest.grpowned?.
+ */
+static VALUE
+path_grpowned_p(VALUE self)
+{
+ return rb_funcall(rb_mFileTest, rb_intern("grpowned?"), 1, get_strpath(self));
+}
+
+/*
+ * See FileTest.directory?.
+ */
+static VALUE
+path_directory_p(VALUE self)
+{
+ return rb_funcall(rb_mFileTest, rb_intern("directory?"), 1, get_strpath(self));
+}
+
+/*
+ * See FileTest.file?.
+ */
+static VALUE
+path_file_p(VALUE self)
+{
+ return rb_funcall(rb_mFileTest, rb_intern("file?"), 1, get_strpath(self));
+}
+
+/*
+ * See FileTest.pipe?.
+ */
+static VALUE
+path_pipe_p(VALUE self)
+{
+ return rb_funcall(rb_mFileTest, rb_intern("pipe?"), 1, get_strpath(self));
+}
+
+/*
+ * See FileTest.socket?.
+ */
+static VALUE
+path_socket_p(VALUE self)
+{
+ return rb_funcall(rb_mFileTest, rb_intern("socket?"), 1, get_strpath(self));
+}
+
+/*
+ * See FileTest.owned?.
+ */
+static VALUE
+path_owned_p(VALUE self)
+{
+ return rb_funcall(rb_mFileTest, rb_intern("owned?"), 1, get_strpath(self));
+}
+
+/*
+ * See FileTest.readable?.
+ */
+static VALUE
+path_readable_p(VALUE self)
+{
+ return rb_funcall(rb_mFileTest, rb_intern("readable?"), 1, get_strpath(self));
+}
+
+/*
+ * See FileTest.world_readable?.
+ */
+static VALUE
+path_world_readable_p(VALUE self)
+{
+ return rb_funcall(rb_mFileTest, rb_intern("world_readable?"), 1, get_strpath(self));
+}
+
+/*
+ * See FileTest.readable_real?.
+ */
+static VALUE
+path_readable_real_p(VALUE self)
+{
+ return rb_funcall(rb_mFileTest, rb_intern("readable_real?"), 1, get_strpath(self));
+}
+
+/*
+ * See FileTest.setuid?.
+ */
+static VALUE
+path_setuid_p(VALUE self)
+{
+ return rb_funcall(rb_mFileTest, rb_intern("setuid?"), 1, get_strpath(self));
+}
+
+/*
+ * See FileTest.setgid?.
+ */
+static VALUE
+path_setgid_p(VALUE self)
+{
+ return rb_funcall(rb_mFileTest, rb_intern("setgid?"), 1, get_strpath(self));
+}
+
+/*
+ * See FileTest.size.
+ */
+static VALUE
+path_size(VALUE self)
+{
+ return rb_funcall(rb_mFileTest, rb_intern("size"), 1, get_strpath(self));
+}
+
+/*
+ * See FileTest.size?.
+ */
+static VALUE
+path_size_p(VALUE self)
+{
+ return rb_funcall(rb_mFileTest, rb_intern("size?"), 1, get_strpath(self));
+}
+
+/*
+ * See FileTest.sticky?.
+ */
+static VALUE
+path_sticky_p(VALUE self)
+{
+ return rb_funcall(rb_mFileTest, rb_intern("sticky?"), 1, get_strpath(self));
+}
+
+/*
+ * See FileTest.symlink?.
+ */
+static VALUE
+path_symlink_p(VALUE self)
+{
+ return rb_funcall(rb_mFileTest, rb_intern("symlink?"), 1, get_strpath(self));
+}
+
+/*
+ * See FileTest.writable?.
+ */
+static VALUE
+path_writable_p(VALUE self)
+{
+ return rb_funcall(rb_mFileTest, rb_intern("writable?"), 1, get_strpath(self));
+}
+
+/*
+ * See FileTest.world_writable?.
+ */
+static VALUE
+path_world_writable_p(VALUE self)
+{
+ return rb_funcall(rb_mFileTest, rb_intern("world_writable?"), 1, get_strpath(self));
+}
+
+/*
+ * See FileTest.writable_real?.
+ */
+static VALUE
+path_writable_real_p(VALUE self)
+{
+ return rb_funcall(rb_mFileTest, rb_intern("writable_real?"), 1, get_strpath(self));
+}
+
+/*
+ * See FileTest.zero?.
+ */
+static VALUE
+path_zero_p(VALUE self)
+{
+ return rb_funcall(rb_mFileTest, rb_intern("zero?"), 1, get_strpath(self));
+}
+
+static VALUE
+glob_i(RB_BLOCK_CALL_FUNC_ARGLIST(elt, klass))
+{
+ return rb_yield(rb_class_new_instance(1, &elt, klass));
+}
+
+/*
+ * Returns or yields Pathname objects.
+ *
+ * Pathname.glob("config/" "*.rb")
+ * #=> [#<Pathname:config/environment.rb>, #<Pathname:config/routes.rb>, ..]
+ *
+ * See Dir.glob.
+ */
+static VALUE
+path_s_glob(int argc, VALUE *argv, VALUE klass)
+{
+ VALUE args[2];
+ int n;
+
+ n = rb_scan_args(argc, argv, "11", &args[0], &args[1]);
+ if (rb_block_given_p()) {
+ return rb_block_call(rb_cDir, rb_intern("glob"), n, args, glob_i, klass);
+ }
+ else {
+ VALUE ary;
+ long i;
+ ary = rb_funcall2(rb_cDir, rb_intern("glob"), n, args);
+ ary = rb_convert_type(ary, T_ARRAY, "Array", "to_ary");
+ for (i = 0; i < RARRAY_LEN(ary); i++) {
+ VALUE elt = RARRAY_AREF(ary, i);
+ elt = rb_class_new_instance(1, &elt, klass);
+ rb_ary_store(ary, i, elt);
+ }
+ return ary;
+ }
+}
+
+/*
+ * Returns the current working directory as a Pathname.
+ *
+ * Pathname.getwd
+ * #=> #<Pathname:/home/zzak/projects/ruby>
+ *
+ * See Dir.getwd.
+ */
+static VALUE
+path_s_getwd(VALUE klass)
+{
+ VALUE str;
+ str = rb_funcall(rb_cDir, rb_intern("getwd"), 0);
+ return rb_class_new_instance(1, &str, klass);
+}
+
+/*
+ * Return the entries (files and subdirectories) in the directory, each as a
+ * Pathname object.
+ *
+ * The results contains just the names in the directory, without any trailing
+ * slashes or recursive look-up.
+ *
+ * pp Pathname.new('/usr/local').entries
+ * #=> [#<Pathname:share>,
+ * # #<Pathname:lib>,
+ * # #<Pathname:..>,
+ * # #<Pathname:include>,
+ * # #<Pathname:etc>,
+ * # #<Pathname:bin>,
+ * # #<Pathname:man>,
+ * # #<Pathname:games>,
+ * # #<Pathname:.>,
+ * # #<Pathname:sbin>,
+ * # #<Pathname:src>]
+ *
+ * The result may contain the current directory <code>#<Pathname:.></code> and
+ * the parent directory <code>#<Pathname:..></code>.
+ *
+ * If you don't want +.+ and +..+ and
+ * want directories, consider Pathname#children.
+ */
+static VALUE
+path_entries(VALUE self)
+{
+ VALUE klass, str, ary;
+ long i;
+ klass = rb_obj_class(self);
+ str = get_strpath(self);
+ ary = rb_funcall(rb_cDir, rb_intern("entries"), 1, str);
+ ary = rb_convert_type(ary, T_ARRAY, "Array", "to_ary");
+ for (i = 0; i < RARRAY_LEN(ary); i++) {
+ VALUE elt = RARRAY_AREF(ary, i);
+ elt = rb_class_new_instance(1, &elt, klass);
+ rb_ary_store(ary, i, elt);
+ }
+ return ary;
+}
+
+/*
+ * Create the referenced directory.
+ *
+ * See Dir.mkdir.
+ */
+static VALUE
+path_mkdir(int argc, VALUE *argv, VALUE self)
+{
+ VALUE str = get_strpath(self);
+ VALUE vmode;
+ if (rb_scan_args(argc, argv, "01", &vmode) == 0)
+ return rb_funcall(rb_cDir, rb_intern("mkdir"), 1, str);
+ else
+ return rb_funcall(rb_cDir, rb_intern("mkdir"), 2, str, vmode);
+}
+
+/*
+ * Remove the referenced directory.
+ *
+ * See Dir.rmdir.
+ */
+static VALUE
+path_rmdir(VALUE self)
+{
+ return rb_funcall(rb_cDir, rb_intern("rmdir"), 1, get_strpath(self));
+}
+
+/*
+ * Opens the referenced directory.
+ *
+ * See Dir.open.
+ */
+static VALUE
+path_opendir(VALUE self)
+{
+ VALUE args[1];
+
+ args[0] = get_strpath(self);
+ return rb_block_call(rb_cDir, rb_intern("open"), 1, args, 0, 0);
+}
+
+static VALUE
+each_entry_i(RB_BLOCK_CALL_FUNC_ARGLIST(elt, klass))
+{
+ return rb_yield(rb_class_new_instance(1, &elt, klass));
+}
+
+/*
+ * Iterates over the entries (files and subdirectories) in the directory,
+ * yielding a Pathname object for each entry.
+ */
+static VALUE
+path_each_entry(VALUE self)
+{
+ VALUE args[1];
+
+ args[0] = get_strpath(self);
+ return rb_block_call(rb_cDir, rb_intern("foreach"), 1, args, each_entry_i, rb_obj_class(self));
+}
+
+static VALUE
+unlink_body(VALUE str)
+{
+ return rb_funcall(rb_cDir, rb_intern("unlink"), 1, str);
+}
+
+static VALUE
+unlink_rescue(VALUE str, VALUE errinfo)
+{
+ return rb_funcall(rb_cFile, rb_intern("unlink"), 1, str);
+}
+
+/*
+ * Removes a file or directory, using File.unlink if +self+ is a file, or
+ * Dir.unlink as necessary.
+ */
+static VALUE
+path_unlink(VALUE self)
+{
+ VALUE eENOTDIR = rb_const_get_at(rb_mErrno, rb_intern("ENOTDIR"));
+ VALUE str = get_strpath(self);
+ return rb_rescue2(unlink_body, str, unlink_rescue, str, eENOTDIR, (VALUE)0);
+}
+
+/*
+ * :call-seq:
+ * Pathname(path) -> pathname
+ *
+ * Creates a new Pathname object from the given string, +path+, and returns
+ * pathname object.
+ *
+ * In order to use this constructor, you must first require the Pathname
+ * standard library extension.
+ *
+ * require 'pathname'
+ * Pathname("/home/zzak")
+ * #=> #<Pathname:/home/zzak>
+ *
+ * See also Pathname::new for more information.
+ */
+static VALUE
+path_f_pathname(VALUE self, VALUE str)
+{
+ return rb_class_new_instance(1, &str, rb_cPathname);
+}
+
+/*
+ *
+ * Pathname represents the name of a file or directory on the filesystem,
+ * but not the file itself.
+ *
+ * The pathname depends on the Operating System: Unix, Windows, etc.
+ * This library works with pathnames of local OS, however non-Unix pathnames
+ * are supported experimentally.
+ *
+ * A Pathname can be relative or absolute. It's not until you try to
+ * reference the file that it even matters whether the file exists or not.
+ *
+ * Pathname is immutable. It has no method for destructive update.
+ *
+ * The goal of this class is to manipulate file path information in a neater
+ * way than standard Ruby provides. The examples below demonstrate the
+ * difference.
+ *
+ * *All* functionality from File, FileTest, and some from Dir and FileUtils is
+ * included, in an unsurprising way. It is essentially a facade for all of
+ * these, and more.
+ *
+ * == Examples
+ *
+ * === Example 1: Using Pathname
+ *
+ * require 'pathname'
+ * pn = Pathname.new("/usr/bin/ruby")
+ * size = pn.size # 27662
+ * isdir = pn.directory? # false
+ * dir = pn.dirname # Pathname:/usr/bin
+ * base = pn.basename # Pathname:ruby
+ * dir, base = pn.split # [Pathname:/usr/bin, Pathname:ruby]
+ * data = pn.read
+ * pn.open { |f| _ }
+ * pn.each_line { |line| _ }
+ *
+ * === Example 2: Using standard Ruby
+ *
+ * pn = "/usr/bin/ruby"
+ * size = File.size(pn) # 27662
+ * isdir = File.directory?(pn) # false
+ * dir = File.dirname(pn) # "/usr/bin"
+ * base = File.basename(pn) # "ruby"
+ * dir, base = File.split(pn) # ["/usr/bin", "ruby"]
+ * data = File.read(pn)
+ * File.open(pn) { |f| _ }
+ * File.foreach(pn) { |line| _ }
+ *
+ * === Example 3: Special features
+ *
+ * p1 = Pathname.new("/usr/lib") # Pathname:/usr/lib
+ * p2 = p1 + "ruby/1.8" # Pathname:/usr/lib/ruby/1.8
+ * p3 = p1.parent # Pathname:/usr
+ * p4 = p2.relative_path_from(p3) # Pathname:lib/ruby/1.8
+ * pwd = Pathname.pwd # Pathname:/home/gavin
+ * pwd.absolute? # true
+ * p5 = Pathname.new "." # Pathname:.
+ * p5 = p5 + "music/../articles" # Pathname:music/../articles
+ * p5.cleanpath # Pathname:articles
+ * p5.realpath # Pathname:/home/gavin/articles
+ * p5.children # [Pathname:/home/gavin/articles/linux, ...]
+ *
+ * == Breakdown of functionality
+ *
+ * === Core methods
+ *
+ * These methods are effectively manipulating a String, because that's
+ * all a path is. None of these access the file system except for
+ * #mountpoint?, #children, #each_child, #realdirpath and #realpath.
+ *
+ * - +
+ * - #join
+ * - #parent
+ * - #root?
+ * - #absolute?
+ * - #relative?
+ * - #relative_path_from
+ * - #each_filename
+ * - #cleanpath
+ * - #realpath
+ * - #realdirpath
+ * - #children
+ * - #each_child
+ * - #mountpoint?
+ *
+ * === File status predicate methods
+ *
+ * These methods are a facade for FileTest:
+ * - #blockdev?
+ * - #chardev?
+ * - #directory?
+ * - #executable?
+ * - #executable_real?
+ * - #exist?
+ * - #file?
+ * - #grpowned?
+ * - #owned?
+ * - #pipe?
+ * - #readable?
+ * - #world_readable?
+ * - #readable_real?
+ * - #setgid?
+ * - #setuid?
+ * - #size
+ * - #size?
+ * - #socket?
+ * - #sticky?
+ * - #symlink?
+ * - #writable?
+ * - #world_writable?
+ * - #writable_real?
+ * - #zero?
+ *
+ * === File property and manipulation methods
+ *
+ * These methods are a facade for File:
+ * - #atime
+ * - #birthtime
+ * - #ctime
+ * - #mtime
+ * - #chmod(mode)
+ * - #lchmod(mode)
+ * - #chown(owner, group)
+ * - #lchown(owner, group)
+ * - #fnmatch(pattern, *args)
+ * - #fnmatch?(pattern, *args)
+ * - #ftype
+ * - #make_link(old)
+ * - #open(*args, &block)
+ * - #readlink
+ * - #rename(to)
+ * - #stat
+ * - #lstat
+ * - #make_symlink(old)
+ * - #truncate(length)
+ * - #utime(atime, mtime)
+ * - #basename(*args)
+ * - #dirname
+ * - #extname
+ * - #expand_path(*args)
+ * - #split
+ *
+ * === Directory methods
+ *
+ * These methods are a facade for Dir:
+ * - Pathname.glob(*args)
+ * - Pathname.getwd / Pathname.pwd
+ * - #rmdir
+ * - #entries
+ * - #each_entry(&block)
+ * - #mkdir(*args)
+ * - #opendir(*args)
+ *
+ * === IO
+ *
+ * These methods are a facade for IO:
+ * - #each_line(*args, &block)
+ * - #read(*args)
+ * - #binread(*args)
+ * - #readlines(*args)
+ * - #sysopen(*args)
+ *
+ * === Utilities
+ *
+ * These methods are a mixture of Find, FileUtils, and others:
+ * - #find(&block)
+ * - #mkpath
+ * - #rmtree
+ * - #unlink / #delete
+ *
+ *
+ * == Method documentation
+ *
+ * As the above section shows, most of the methods in Pathname are facades. The
+ * documentation for these methods generally just says, for instance, "See
+ * FileTest.writable?", as you should be familiar with the original method
+ * anyway, and its documentation (e.g. through +ri+) will contain more
+ * information. In some cases, a brief description will follow.
+ */
+void
+Init_pathname(void)
+{
+ id_at_path = rb_intern("@path");
+ id_to_path = rb_intern("to_path");
+
+ rb_cPathname = rb_define_class("Pathname", rb_cObject);
+ rb_define_method(rb_cPathname, "initialize", path_initialize, 1);
+ rb_define_method(rb_cPathname, "freeze", path_freeze, 0);
+ rb_define_method(rb_cPathname, "taint", path_taint, 0);
+ rb_define_method(rb_cPathname, "untaint", path_untaint, 0);
+ rb_define_method(rb_cPathname, "==", path_eq, 1);
+ rb_define_method(rb_cPathname, "===", path_eq, 1);
+ rb_define_method(rb_cPathname, "eql?", path_eq, 1);
+ rb_define_method(rb_cPathname, "<=>", path_cmp, 1);
+ rb_define_method(rb_cPathname, "hash", path_hash, 0);
+ rb_define_method(rb_cPathname, "to_s", path_to_s, 0);
+ rb_define_method(rb_cPathname, "to_path", path_to_s, 0);
+ rb_define_method(rb_cPathname, "inspect", path_inspect, 0);
+ rb_define_method(rb_cPathname, "sub", path_sub, -1);
+ rb_define_method(rb_cPathname, "sub_ext", path_sub_ext, 1);
+ rb_define_method(rb_cPathname, "realpath", path_realpath, -1);
+ rb_define_method(rb_cPathname, "realdirpath", path_realdirpath, -1);
+ rb_define_method(rb_cPathname, "each_line", path_each_line, -1);
+ rb_define_method(rb_cPathname, "read", path_read, -1);
+ rb_define_method(rb_cPathname, "binread", path_binread, -1);
+ rb_define_method(rb_cPathname, "readlines", path_readlines, -1);
+ rb_define_method(rb_cPathname, "write", path_write, -1);
+ rb_define_method(rb_cPathname, "binwrite", path_binwrite, -1);
+ rb_define_method(rb_cPathname, "sysopen", path_sysopen, -1);
+ rb_define_method(rb_cPathname, "atime", path_atime, 0);
+ rb_define_method(rb_cPathname, "birthtime", path_birthtime, 0);
+ rb_define_method(rb_cPathname, "ctime", path_ctime, 0);
+ rb_define_method(rb_cPathname, "mtime", path_mtime, 0);
+ rb_define_method(rb_cPathname, "chmod", path_chmod, 1);
+ rb_define_method(rb_cPathname, "lchmod", path_lchmod, 1);
+ rb_define_method(rb_cPathname, "chown", path_chown, 2);
+ rb_define_method(rb_cPathname, "lchown", path_lchown, 2);
+ rb_define_method(rb_cPathname, "fnmatch", path_fnmatch, -1);
+ rb_define_method(rb_cPathname, "fnmatch?", path_fnmatch, -1);
+ rb_define_method(rb_cPathname, "ftype", path_ftype, 0);
+ rb_define_method(rb_cPathname, "make_link", path_make_link, 1);
+ rb_define_method(rb_cPathname, "open", path_open, -1);
+ rb_define_method(rb_cPathname, "readlink", path_readlink, 0);
+ rb_define_method(rb_cPathname, "rename", path_rename, 1);
+ rb_define_method(rb_cPathname, "stat", path_stat, 0);
+ rb_define_method(rb_cPathname, "lstat", path_lstat, 0);
+ rb_define_method(rb_cPathname, "make_symlink", path_make_symlink, 1);
+ rb_define_method(rb_cPathname, "truncate", path_truncate, 1);
+ rb_define_method(rb_cPathname, "utime", path_utime, 2);
+ rb_define_method(rb_cPathname, "basename", path_basename, -1);
+ rb_define_method(rb_cPathname, "dirname", path_dirname, 0);
+ rb_define_method(rb_cPathname, "extname", path_extname, 0);
+ rb_define_method(rb_cPathname, "expand_path", path_expand_path, -1);
+ rb_define_method(rb_cPathname, "split", path_split, 0);
+ rb_define_method(rb_cPathname, "blockdev?", path_blockdev_p, 0);
+ rb_define_method(rb_cPathname, "chardev?", path_chardev_p, 0);
+ rb_define_method(rb_cPathname, "executable?", path_executable_p, 0);
+ rb_define_method(rb_cPathname, "executable_real?", path_executable_real_p, 0);
+ rb_define_method(rb_cPathname, "exist?", path_exist_p, 0);
+ rb_define_method(rb_cPathname, "grpowned?", path_grpowned_p, 0);
+ rb_define_method(rb_cPathname, "directory?", path_directory_p, 0);
+ rb_define_method(rb_cPathname, "file?", path_file_p, 0);
+ rb_define_method(rb_cPathname, "pipe?", path_pipe_p, 0);
+ rb_define_method(rb_cPathname, "socket?", path_socket_p, 0);
+ rb_define_method(rb_cPathname, "owned?", path_owned_p, 0);
+ rb_define_method(rb_cPathname, "readable?", path_readable_p, 0);
+ rb_define_method(rb_cPathname, "world_readable?", path_world_readable_p, 0);
+ rb_define_method(rb_cPathname, "readable_real?", path_readable_real_p, 0);
+ rb_define_method(rb_cPathname, "setuid?", path_setuid_p, 0);
+ rb_define_method(rb_cPathname, "setgid?", path_setgid_p, 0);
+ rb_define_method(rb_cPathname, "size", path_size, 0);
+ rb_define_method(rb_cPathname, "size?", path_size_p, 0);
+ rb_define_method(rb_cPathname, "sticky?", path_sticky_p, 0);
+ rb_define_method(rb_cPathname, "symlink?", path_symlink_p, 0);
+ rb_define_method(rb_cPathname, "writable?", path_writable_p, 0);
+ rb_define_method(rb_cPathname, "world_writable?", path_world_writable_p, 0);
+ rb_define_method(rb_cPathname, "writable_real?", path_writable_real_p, 0);
+ rb_define_method(rb_cPathname, "zero?", path_zero_p, 0);
+ rb_define_singleton_method(rb_cPathname, "glob", path_s_glob, -1);
+ rb_define_singleton_method(rb_cPathname, "getwd", path_s_getwd, 0);
+ rb_define_singleton_method(rb_cPathname, "pwd", path_s_getwd, 0);
+ rb_define_method(rb_cPathname, "entries", path_entries, 0);
+ rb_define_method(rb_cPathname, "mkdir", path_mkdir, -1);
+ rb_define_method(rb_cPathname, "rmdir", path_rmdir, 0);
+ rb_define_method(rb_cPathname, "opendir", path_opendir, 0);
+ rb_define_method(rb_cPathname, "each_entry", path_each_entry, 0);
+ rb_define_method(rb_cPathname, "unlink", path_unlink, 0);
+ rb_define_method(rb_cPathname, "delete", path_unlink, 0);
+ rb_undef_method(rb_cPathname, "=~");
+ rb_define_global_function("Pathname", path_f_pathname, 1);
+}
diff --git a/jni/ruby/ext/psych/Makefile b/jni/ruby/ext/psych/Makefile
new file mode 100644
index 0000000..66f276f
--- /dev/null
+++ b/jni/ruby/ext/psych/Makefile
@@ -0,0 +1,488 @@
+
+SHELL = /bin/sh
+
+# V=0 quiet, V=1 verbose. other values don't work.
+V = 0
+Q1 = $(V:1=)
+Q = $(Q1:0=@)
+ECHO1 = $(V:1=@:)
+ECHO = $(ECHO1:0=@echo)
+NULLCMD = :
+
+#### Start of system configuration section. ####
+top_srcdir = $(topdir)/.
+srcdir = $(top_srcdir)/ext/psych
+topdir = ../..
+hdrdir = $(top_srcdir)/include
+arch_hdrdir = $(extout)/include/$(arch)
+PATH_SEPARATOR = :
+VPATH = $(srcdir):$(arch_hdrdir)/ruby:$(hdrdir)/ruby:$(srcdir)/yaml
+RUBYLIB =
+RUBYOPT = -
+prefix = $(DESTDIR)/usr/local
+rubysitearchprefix = $(rubylibprefix)/$(sitearch)
+rubyarchprefix = $(rubylibprefix)/$(arch)
+rubylibprefix = $(libdir)/$(RUBY_BASE_NAME)
+exec_prefix = $(prefix)
+vendorarchhdrdir = $(vendorhdrdir)/$(sitearch)
+sitearchhdrdir = $(sitehdrdir)/$(sitearch)
+rubyarchhdrdir = $(rubyhdrdir)/$(arch)
+vendorhdrdir = $(rubyhdrdir)/vendor_ruby
+sitehdrdir = $(rubyhdrdir)/site_ruby
+rubyhdrdir = $(includedir)/$(RUBY_VERSION_NAME)
+vendorarchdir = $(vendorlibdir)/$(sitearch)
+vendorlibdir = $(vendordir)/$(ruby_version)
+vendordir = $(rubylibprefix)/vendor_ruby
+sitearchdir = $(sitelibdir)/$(sitearch)
+sitelibdir = $(sitedir)/$(ruby_version)
+sitedir = $(rubylibprefix)/site_ruby
+rubyarchdir = $(rubylibdir)/$(arch)
+rubylibdir = $(rubylibprefix)/$(ruby_version)
+sitearchincludedir = $(includedir)/$(sitearch)
+archincludedir = $(includedir)/$(arch)
+sitearchlibdir = $(libdir)/$(sitearch)
+archlibdir = $(libdir)/$(arch)
+ridir = $(datarootdir)/$(RI_BASE_NAME)
+mandir = $(datarootdir)/man
+localedir = $(datarootdir)/locale
+libdir = $(exec_prefix)/lib
+psdir = $(docdir)
+pdfdir = $(docdir)
+dvidir = $(docdir)
+htmldir = $(docdir)
+infodir = $(datarootdir)/info
+docdir = $(datarootdir)/doc/$(PACKAGE)
+oldincludedir = $(DESTDIR)/usr/include
+includedir = $(prefix)/include
+localstatedir = $(prefix)/var
+sharedstatedir = $(prefix)/com
+sysconfdir = $(prefix)/etc
+datadir = $(datarootdir)
+datarootdir = $(prefix)/share
+libexecdir = $(exec_prefix)/libexec
+sbindir = $(exec_prefix)/sbin
+bindir = $(exec_prefix)/bin
+archdir = $(rubyarchdir)
+
+
+CC = gcc
+CXX = g++
+LIBRUBY = $(LIBRUBY_SO)
+LIBRUBY_A = lib$(RUBY_SO_NAME)-static.a
+LIBRUBYARG_SHARED = -Wl,-R$(libdir) -L$(libdir) -l$(RUBY_SO_NAME)
+LIBRUBYARG_STATIC = -Wl,-R$(libdir) -L$(libdir) -l$(RUBY_SO_NAME)-static
+empty =
+OUTFLAG = -o $(empty)
+COUTFLAG = -o $(empty)
+
+RUBY_EXTCONF_H = extconf.h
+cflags = $(optflags) $(debugflags) $(warnflags)
+optflags = -O3 -fno-fast-math
+debugflags = -ggdb3
+warnflags = -Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wunused-variable -Wpointer-arith -Wwrite-strings -Wdeclaration-after-statement -Wimplicit-function-declaration -Wdeprecated-declarations -Wno-packed-bitfield-compat
+CCDLFLAGS = -fPIC
+CFLAGS = $(CCDLFLAGS) $(cflags) -fPIC $(ARCH_FLAG)
+INCFLAGS = -I. -I$(arch_hdrdir) -I$(hdrdir) -I$(srcdir) -I$(srcdir)/yaml
+DEFS =
+CPPFLAGS = -DRUBY_EXTCONF_H=\"$(RUBY_EXTCONF_H)\" $(DEFS) $(cppflags)
+CXXFLAGS = $(CCDLFLAGS) $(cxxflags) $(ARCH_FLAG)
+ldflags = -L. -fstack-protector -rdynamic -Wl,-export-dynamic
+dldflags =
+ARCH_FLAG =
+DLDFLAGS = $(ldflags) $(dldflags) $(ARCH_FLAG)
+LDSHARED = $(CC) -shared
+LDSHAREDXX = $(CXX) -shared
+AR = ar
+EXEEXT =
+
+RUBY_INSTALL_NAME = $(RUBY_BASE_NAME)
+RUBY_SO_NAME = ruby
+RUBYW_INSTALL_NAME =
+RUBY_VERSION_NAME = $(RUBY_BASE_NAME)-$(ruby_version)
+RUBYW_BASE_NAME = rubyw
+RUBY_BASE_NAME = ruby
+
+arch = x86_64-linux
+sitearch = $(arch)
+ruby_version = 2.2.0
+ruby = $(topdir)/miniruby -I'$(topdir)' -I'$(top_srcdir)/lib' -I'$(extout)/$(arch)' -I'$(extout)/common'
+RUBY = $(ruby)
+ruby_headers = $(hdrdir)/ruby.h $(hdrdir)/ruby/ruby.h $(hdrdir)/ruby/defines.h $(hdrdir)/ruby/missing.h $(hdrdir)/ruby/intern.h $(hdrdir)/ruby/st.h $(hdrdir)/ruby/subst.h $(arch_hdrdir)/ruby/config.h $(RUBY_EXTCONF_H)
+
+RM = rm -f
+RM_RF = $(RUBY) -run -e rm -- -rf
+RMDIRS = rmdir --ignore-fail-on-non-empty -p
+MAKEDIRS = /bin/mkdir -p
+INSTALL = /usr/bin/install -c
+INSTALL_PROG = $(INSTALL) -m 0755
+INSTALL_DATA = $(INSTALL) -m 644
+COPY = cp
+TOUCH = exit >
+
+#### End of system configuration section. ####
+
+preload =
+
+libpath = . $(topdir)
+LIBPATH = -L. -L$(topdir)
+DEFFILE =
+
+CLEANFILES = mkmf.log
+DISTCLEANFILES =
+DISTCLEANDIRS =
+
+extout = $(topdir)/.ext
+extout_prefix = $(extout)$(target_prefix)/
+target_prefix =
+LOCAL_LIBS =
+LIBS = $(LIBRUBYARG_SHARED) -lpthread -lgmp -ldl -lcrypt -lm -lc
+ORIG_SRCS = psych.c psych_emitter.c psych_parser.c psych_yaml_tree.c psych_to_ruby.c
+SRCS = $(ORIG_SRCS) psych.c psych_emitter.c psych_parser.c psych_yaml_tree.c psych_to_ruby.c writer.c dumper.c parser.c emitter.c loader.c api.c scanner.c reader.c
+OBJS = psych.o psych_emitter.o psych_parser.o psych_yaml_tree.o psych_to_ruby.o writer.o dumper.o parser.o emitter.o loader.o api.o scanner.o reader.o
+HDRS = $(srcdir)/psych_to_ruby.h $(srcdir)/extconf.h $(srcdir)/psych_parser.h $(srcdir)/psych_yaml_tree.h $(srcdir)/psych.h $(srcdir)/psych_emitter.h
+TARGET = psych
+TARGET_NAME = psych
+TARGET_ENTRY = Init_$(TARGET_NAME)
+DLLIB = $(TARGET).so
+EXTSTATIC =
+STATIC_LIB = $(TARGET).a
+
+TIMESTAMP_DIR = $(extout)/.timestamp
+BINDIR = $(extout)/bin
+RUBYCOMMONDIR = $(extout)/common
+RUBYLIBDIR = $(RUBYCOMMONDIR)$(target_prefix)
+RUBYARCHDIR = $(extout)/$(arch)$(target_prefix)
+HDRDIR = $(extout)/include/ruby$(target_prefix)
+ARCHHDRDIR = $(extout)/include/$(arch)/ruby$(target_prefix)
+
+TARGET_SO = $(RUBYARCHDIR)/$(DLLIB)
+CLEANLIBS = $(RUBYARCHDIR)/$(TARGET).so
+CLEANOBJS = *.o *.bak
+
+all: install
+static: all
+.PHONY: all install static install-so install-rb
+.PHONY: clean clean-so clean-static clean-rb
+
+clean-static::
+clean-rb-default::
+clean-rb::
+clean-so::
+clean: clean-so clean-static clean-rb-default clean-rb
+ -$(Q)$(RM) $(CLEANLIBS) $(CLEANOBJS) $(CLEANFILES) .*.time
+
+distclean-rb-default::
+distclean-rb::
+distclean-so::
+distclean-static::
+distclean: clean distclean-so distclean-static distclean-rb-default distclean-rb
+ -$(Q)$(RM) Makefile $(RUBY_EXTCONF_H) conftest.* mkmf.log
+ -$(Q)$(RM) core ruby$(EXEEXT) *~ $(DISTCLEANFILES)
+ -$(Q)$(RMDIRS) $(DISTCLEANDIRS) 2> /dev/null || true
+
+realclean: distclean
+install: install-so install-rb
+
+install-so: $(RUBYARCHDIR)/$(DLLIB)
+clean-so::
+ -$(Q)$(RM) $(RUBYARCHDIR)/$(DLLIB)
+ -$(Q)$(RMDIRS) $(RUBYARCHDIR) 2> /dev/null || true
+clean-static::
+ -$(Q)$(RM) $(STATIC_LIB)
+install-rb: pre-install-rb install-rb-default
+install-rb-default: pre-install-rb-default
+pre-install-rb: Makefile
+pre-install-rb-default: Makefile
+pre-install-rb-default: $(TIMESTAMP_DIR)/.RUBYLIBDIR.-.psych.-.json.time
+install-rb-default: $(RUBYLIBDIR)/psych/json/yaml_events.rb
+$(RUBYLIBDIR)/psych/json/yaml_events.rb: $(srcdir)/lib/psych/json/yaml_events.rb $(TIMESTAMP_DIR)/.RUBYLIBDIR.-.psych.-.json.time
+ $(Q) $(COPY) $(srcdir)/lib/psych/json/yaml_events.rb $(@D)
+clean-rb-default::
+ -$(Q)$(RM) $(RUBYLIBDIR)/psych/json/yaml_events.rb
+install-rb-default: $(RUBYLIBDIR)/psych/json/stream.rb
+$(RUBYLIBDIR)/psych/json/stream.rb: $(srcdir)/lib/psych/json/stream.rb $(TIMESTAMP_DIR)/.RUBYLIBDIR.-.psych.-.json.time
+ $(Q) $(COPY) $(srcdir)/lib/psych/json/stream.rb $(@D)
+clean-rb-default::
+ -$(Q)$(RM) $(RUBYLIBDIR)/psych/json/stream.rb
+install-rb-default: $(RUBYLIBDIR)/psych/json/ruby_events.rb
+$(RUBYLIBDIR)/psych/json/ruby_events.rb: $(srcdir)/lib/psych/json/ruby_events.rb $(TIMESTAMP_DIR)/.RUBYLIBDIR.-.psych.-.json.time
+ $(Q) $(COPY) $(srcdir)/lib/psych/json/ruby_events.rb $(@D)
+clean-rb-default::
+ -$(Q)$(RM) $(RUBYLIBDIR)/psych/json/ruby_events.rb
+install-rb-default: $(RUBYLIBDIR)/psych/json/tree_builder.rb
+$(RUBYLIBDIR)/psych/json/tree_builder.rb: $(srcdir)/lib/psych/json/tree_builder.rb $(TIMESTAMP_DIR)/.RUBYLIBDIR.-.psych.-.json.time
+ $(Q) $(COPY) $(srcdir)/lib/psych/json/tree_builder.rb $(@D)
+clean-rb-default::
+ -$(Q)$(RM) $(RUBYLIBDIR)/psych/json/tree_builder.rb
+pre-install-rb-default: $(TIMESTAMP_DIR)/.RUBYLIBDIR.-.psych.time
+install-rb-default: $(RUBYLIBDIR)/psych/omap.rb
+$(RUBYLIBDIR)/psych/omap.rb: $(srcdir)/lib/psych/omap.rb $(TIMESTAMP_DIR)/.RUBYLIBDIR.-.psych.time
+ $(Q) $(COPY) $(srcdir)/lib/psych/omap.rb $(@D)
+clean-rb-default::
+ -$(Q)$(RM) $(RUBYLIBDIR)/psych/omap.rb
+install-rb-default: $(RUBYLIBDIR)/psych/set.rb
+$(RUBYLIBDIR)/psych/set.rb: $(srcdir)/lib/psych/set.rb $(TIMESTAMP_DIR)/.RUBYLIBDIR.-.psych.time
+ $(Q) $(COPY) $(srcdir)/lib/psych/set.rb $(@D)
+clean-rb-default::
+ -$(Q)$(RM) $(RUBYLIBDIR)/psych/set.rb
+install-rb-default: $(RUBYLIBDIR)/psych/nodes.rb
+$(RUBYLIBDIR)/psych/nodes.rb: $(srcdir)/lib/psych/nodes.rb $(TIMESTAMP_DIR)/.RUBYLIBDIR.-.psych.time
+ $(Q) $(COPY) $(srcdir)/lib/psych/nodes.rb $(@D)
+clean-rb-default::
+ -$(Q)$(RM) $(RUBYLIBDIR)/psych/nodes.rb
+install-rb-default: $(RUBYLIBDIR)/psych/handler.rb
+$(RUBYLIBDIR)/psych/handler.rb: $(srcdir)/lib/psych/handler.rb $(TIMESTAMP_DIR)/.RUBYLIBDIR.-.psych.time
+ $(Q) $(COPY) $(srcdir)/lib/psych/handler.rb $(@D)
+clean-rb-default::
+ -$(Q)$(RM) $(RUBYLIBDIR)/psych/handler.rb
+install-rb-default: $(RUBYLIBDIR)/psych/scalar_scanner.rb
+$(RUBYLIBDIR)/psych/scalar_scanner.rb: $(srcdir)/lib/psych/scalar_scanner.rb $(TIMESTAMP_DIR)/.RUBYLIBDIR.-.psych.time
+ $(Q) $(COPY) $(srcdir)/lib/psych/scalar_scanner.rb $(@D)
+clean-rb-default::
+ -$(Q)$(RM) $(RUBYLIBDIR)/psych/scalar_scanner.rb
+install-rb-default: $(RUBYLIBDIR)/psych/coder.rb
+$(RUBYLIBDIR)/psych/coder.rb: $(srcdir)/lib/psych/coder.rb $(TIMESTAMP_DIR)/.RUBYLIBDIR.-.psych.time
+ $(Q) $(COPY) $(srcdir)/lib/psych/coder.rb $(@D)
+clean-rb-default::
+ -$(Q)$(RM) $(RUBYLIBDIR)/psych/coder.rb
+install-rb-default: $(RUBYLIBDIR)/psych/syntax_error.rb
+$(RUBYLIBDIR)/psych/syntax_error.rb: $(srcdir)/lib/psych/syntax_error.rb $(TIMESTAMP_DIR)/.RUBYLIBDIR.-.psych.time
+ $(Q) $(COPY) $(srcdir)/lib/psych/syntax_error.rb $(@D)
+clean-rb-default::
+ -$(Q)$(RM) $(RUBYLIBDIR)/psych/syntax_error.rb
+install-rb-default: $(RUBYLIBDIR)/psych/deprecated.rb
+$(RUBYLIBDIR)/psych/deprecated.rb: $(srcdir)/lib/psych/deprecated.rb $(TIMESTAMP_DIR)/.RUBYLIBDIR.-.psych.time
+ $(Q) $(COPY) $(srcdir)/lib/psych/deprecated.rb $(@D)
+clean-rb-default::
+ -$(Q)$(RM) $(RUBYLIBDIR)/psych/deprecated.rb
+install-rb-default: $(RUBYLIBDIR)/psych/stream.rb
+$(RUBYLIBDIR)/psych/stream.rb: $(srcdir)/lib/psych/stream.rb $(TIMESTAMP_DIR)/.RUBYLIBDIR.-.psych.time
+ $(Q) $(COPY) $(srcdir)/lib/psych/stream.rb $(@D)
+clean-rb-default::
+ -$(Q)$(RM) $(RUBYLIBDIR)/psych/stream.rb
+install-rb-default: $(RUBYLIBDIR)/psych/class_loader.rb
+$(RUBYLIBDIR)/psych/class_loader.rb: $(srcdir)/lib/psych/class_loader.rb $(TIMESTAMP_DIR)/.RUBYLIBDIR.-.psych.time
+ $(Q) $(COPY) $(srcdir)/lib/psych/class_loader.rb $(@D)
+clean-rb-default::
+ -$(Q)$(RM) $(RUBYLIBDIR)/psych/class_loader.rb
+install-rb-default: $(RUBYLIBDIR)/psych/visitors.rb
+$(RUBYLIBDIR)/psych/visitors.rb: $(srcdir)/lib/psych/visitors.rb $(TIMESTAMP_DIR)/.RUBYLIBDIR.-.psych.time
+ $(Q) $(COPY) $(srcdir)/lib/psych/visitors.rb $(@D)
+clean-rb-default::
+ -$(Q)$(RM) $(RUBYLIBDIR)/psych/visitors.rb
+install-rb-default: $(RUBYLIBDIR)/psych/exception.rb
+$(RUBYLIBDIR)/psych/exception.rb: $(srcdir)/lib/psych/exception.rb $(TIMESTAMP_DIR)/.RUBYLIBDIR.-.psych.time
+ $(Q) $(COPY) $(srcdir)/lib/psych/exception.rb $(@D)
+clean-rb-default::
+ -$(Q)$(RM) $(RUBYLIBDIR)/psych/exception.rb
+install-rb-default: $(RUBYLIBDIR)/psych/core_ext.rb
+$(RUBYLIBDIR)/psych/core_ext.rb: $(srcdir)/lib/psych/core_ext.rb $(TIMESTAMP_DIR)/.RUBYLIBDIR.-.psych.time
+ $(Q) $(COPY) $(srcdir)/lib/psych/core_ext.rb $(@D)
+clean-rb-default::
+ -$(Q)$(RM) $(RUBYLIBDIR)/psych/core_ext.rb
+install-rb-default: $(RUBYLIBDIR)/psych/streaming.rb
+$(RUBYLIBDIR)/psych/streaming.rb: $(srcdir)/lib/psych/streaming.rb $(TIMESTAMP_DIR)/.RUBYLIBDIR.-.psych.time
+ $(Q) $(COPY) $(srcdir)/lib/psych/streaming.rb $(@D)
+clean-rb-default::
+ -$(Q)$(RM) $(RUBYLIBDIR)/psych/streaming.rb
+install-rb-default: $(RUBYLIBDIR)/psych/tree_builder.rb
+$(RUBYLIBDIR)/psych/tree_builder.rb: $(srcdir)/lib/psych/tree_builder.rb $(TIMESTAMP_DIR)/.RUBYLIBDIR.-.psych.time
+ $(Q) $(COPY) $(srcdir)/lib/psych/tree_builder.rb $(@D)
+clean-rb-default::
+ -$(Q)$(RM) $(RUBYLIBDIR)/psych/tree_builder.rb
+install-rb-default: $(RUBYLIBDIR)/psych/parser.rb
+$(RUBYLIBDIR)/psych/parser.rb: $(srcdir)/lib/psych/parser.rb $(TIMESTAMP_DIR)/.RUBYLIBDIR.-.psych.time
+ $(Q) $(COPY) $(srcdir)/lib/psych/parser.rb $(@D)
+clean-rb-default::
+ -$(Q)$(RM) $(RUBYLIBDIR)/psych/parser.rb
+install-rb-default: $(RUBYLIBDIR)/psych/y.rb
+$(RUBYLIBDIR)/psych/y.rb: $(srcdir)/lib/psych/y.rb $(TIMESTAMP_DIR)/.RUBYLIBDIR.-.psych.time
+ $(Q) $(COPY) $(srcdir)/lib/psych/y.rb $(@D)
+clean-rb-default::
+ -$(Q)$(RM) $(RUBYLIBDIR)/psych/y.rb
+pre-install-rb-default: $(TIMESTAMP_DIR)/.RUBYLIBDIR.-.psych.-.handlers.time
+install-rb-default: $(RUBYLIBDIR)/psych/handlers/document_stream.rb
+$(RUBYLIBDIR)/psych/handlers/document_stream.rb: $(srcdir)/lib/psych/handlers/document_stream.rb $(TIMESTAMP_DIR)/.RUBYLIBDIR.-.psych.-.handlers.time
+ $(Q) $(COPY) $(srcdir)/lib/psych/handlers/document_stream.rb $(@D)
+clean-rb-default::
+ -$(Q)$(RM) $(RUBYLIBDIR)/psych/handlers/document_stream.rb
+install-rb-default: $(RUBYLIBDIR)/psych/handlers/recorder.rb
+$(RUBYLIBDIR)/psych/handlers/recorder.rb: $(srcdir)/lib/psych/handlers/recorder.rb $(TIMESTAMP_DIR)/.RUBYLIBDIR.-.psych.-.handlers.time
+ $(Q) $(COPY) $(srcdir)/lib/psych/handlers/recorder.rb $(@D)
+clean-rb-default::
+ -$(Q)$(RM) $(RUBYLIBDIR)/psych/handlers/recorder.rb
+pre-install-rb-default: $(TIMESTAMP_DIR)/.RUBYLIBDIR.-.psych.-.nodes.time
+install-rb-default: $(RUBYLIBDIR)/psych/nodes/document.rb
+$(RUBYLIBDIR)/psych/nodes/document.rb: $(srcdir)/lib/psych/nodes/document.rb $(TIMESTAMP_DIR)/.RUBYLIBDIR.-.psych.-.nodes.time
+ $(Q) $(COPY) $(srcdir)/lib/psych/nodes/document.rb $(@D)
+clean-rb-default::
+ -$(Q)$(RM) $(RUBYLIBDIR)/psych/nodes/document.rb
+install-rb-default: $(RUBYLIBDIR)/psych/nodes/mapping.rb
+$(RUBYLIBDIR)/psych/nodes/mapping.rb: $(srcdir)/lib/psych/nodes/mapping.rb $(TIMESTAMP_DIR)/.RUBYLIBDIR.-.psych.-.nodes.time
+ $(Q) $(COPY) $(srcdir)/lib/psych/nodes/mapping.rb $(@D)
+clean-rb-default::
+ -$(Q)$(RM) $(RUBYLIBDIR)/psych/nodes/mapping.rb
+install-rb-default: $(RUBYLIBDIR)/psych/nodes/stream.rb
+$(RUBYLIBDIR)/psych/nodes/stream.rb: $(srcdir)/lib/psych/nodes/stream.rb $(TIMESTAMP_DIR)/.RUBYLIBDIR.-.psych.-.nodes.time
+ $(Q) $(COPY) $(srcdir)/lib/psych/nodes/stream.rb $(@D)
+clean-rb-default::
+ -$(Q)$(RM) $(RUBYLIBDIR)/psych/nodes/stream.rb
+install-rb-default: $(RUBYLIBDIR)/psych/nodes/scalar.rb
+$(RUBYLIBDIR)/psych/nodes/scalar.rb: $(srcdir)/lib/psych/nodes/scalar.rb $(TIMESTAMP_DIR)/.RUBYLIBDIR.-.psych.-.nodes.time
+ $(Q) $(COPY) $(srcdir)/lib/psych/nodes/scalar.rb $(@D)
+clean-rb-default::
+ -$(Q)$(RM) $(RUBYLIBDIR)/psych/nodes/scalar.rb
+install-rb-default: $(RUBYLIBDIR)/psych/nodes/sequence.rb
+$(RUBYLIBDIR)/psych/nodes/sequence.rb: $(srcdir)/lib/psych/nodes/sequence.rb $(TIMESTAMP_DIR)/.RUBYLIBDIR.-.psych.-.nodes.time
+ $(Q) $(COPY) $(srcdir)/lib/psych/nodes/sequence.rb $(@D)
+clean-rb-default::
+ -$(Q)$(RM) $(RUBYLIBDIR)/psych/nodes/sequence.rb
+install-rb-default: $(RUBYLIBDIR)/psych/nodes/node.rb
+$(RUBYLIBDIR)/psych/nodes/node.rb: $(srcdir)/lib/psych/nodes/node.rb $(TIMESTAMP_DIR)/.RUBYLIBDIR.-.psych.-.nodes.time
+ $(Q) $(COPY) $(srcdir)/lib/psych/nodes/node.rb $(@D)
+clean-rb-default::
+ -$(Q)$(RM) $(RUBYLIBDIR)/psych/nodes/node.rb
+install-rb-default: $(RUBYLIBDIR)/psych/nodes/alias.rb
+$(RUBYLIBDIR)/psych/nodes/alias.rb: $(srcdir)/lib/psych/nodes/alias.rb $(TIMESTAMP_DIR)/.RUBYLIBDIR.-.psych.-.nodes.time
+ $(Q) $(COPY) $(srcdir)/lib/psych/nodes/alias.rb $(@D)
+clean-rb-default::
+ -$(Q)$(RM) $(RUBYLIBDIR)/psych/nodes/alias.rb
+pre-install-rb-default: $(TIMESTAMP_DIR)/.RUBYLIBDIR.-.psych.-.visitors.time
+install-rb-default: $(RUBYLIBDIR)/psych/visitors/to_ruby.rb
+$(RUBYLIBDIR)/psych/visitors/to_ruby.rb: $(srcdir)/lib/psych/visitors/to_ruby.rb $(TIMESTAMP_DIR)/.RUBYLIBDIR.-.psych.-.visitors.time
+ $(Q) $(COPY) $(srcdir)/lib/psych/visitors/to_ruby.rb $(@D)
+clean-rb-default::
+ -$(Q)$(RM) $(RUBYLIBDIR)/psych/visitors/to_ruby.rb
+install-rb-default: $(RUBYLIBDIR)/psych/visitors/visitor.rb
+$(RUBYLIBDIR)/psych/visitors/visitor.rb: $(srcdir)/lib/psych/visitors/visitor.rb $(TIMESTAMP_DIR)/.RUBYLIBDIR.-.psych.-.visitors.time
+ $(Q) $(COPY) $(srcdir)/lib/psych/visitors/visitor.rb $(@D)
+clean-rb-default::
+ -$(Q)$(RM) $(RUBYLIBDIR)/psych/visitors/visitor.rb
+install-rb-default: $(RUBYLIBDIR)/psych/visitors/yaml_tree.rb
+$(RUBYLIBDIR)/psych/visitors/yaml_tree.rb: $(srcdir)/lib/psych/visitors/yaml_tree.rb $(TIMESTAMP_DIR)/.RUBYLIBDIR.-.psych.-.visitors.time
+ $(Q) $(COPY) $(srcdir)/lib/psych/visitors/yaml_tree.rb $(@D)
+clean-rb-default::
+ -$(Q)$(RM) $(RUBYLIBDIR)/psych/visitors/yaml_tree.rb
+install-rb-default: $(RUBYLIBDIR)/psych/visitors/depth_first.rb
+$(RUBYLIBDIR)/psych/visitors/depth_first.rb: $(srcdir)/lib/psych/visitors/depth_first.rb $(TIMESTAMP_DIR)/.RUBYLIBDIR.-.psych.-.visitors.time
+ $(Q) $(COPY) $(srcdir)/lib/psych/visitors/depth_first.rb $(@D)
+clean-rb-default::
+ -$(Q)$(RM) $(RUBYLIBDIR)/psych/visitors/depth_first.rb
+install-rb-default: $(RUBYLIBDIR)/psych/visitors/emitter.rb
+$(RUBYLIBDIR)/psych/visitors/emitter.rb: $(srcdir)/lib/psych/visitors/emitter.rb $(TIMESTAMP_DIR)/.RUBYLIBDIR.-.psych.-.visitors.time
+ $(Q) $(COPY) $(srcdir)/lib/psych/visitors/emitter.rb $(@D)
+clean-rb-default::
+ -$(Q)$(RM) $(RUBYLIBDIR)/psych/visitors/emitter.rb
+install-rb-default: $(RUBYLIBDIR)/psych/visitors/json_tree.rb
+$(RUBYLIBDIR)/psych/visitors/json_tree.rb: $(srcdir)/lib/psych/visitors/json_tree.rb $(TIMESTAMP_DIR)/.RUBYLIBDIR.-.psych.-.visitors.time
+ $(Q) $(COPY) $(srcdir)/lib/psych/visitors/json_tree.rb $(@D)
+clean-rb-default::
+ -$(Q)$(RM) $(RUBYLIBDIR)/psych/visitors/json_tree.rb
+pre-install-rb-default: $(TIMESTAMP_DIR)/.RUBYLIBDIR.time
+install-rb-default: $(RUBYLIBDIR)/psych.rb
+$(RUBYLIBDIR)/psych.rb: $(srcdir)/lib/psych.rb $(TIMESTAMP_DIR)/.RUBYLIBDIR.time
+ $(Q) $(COPY) $(srcdir)/lib/psych.rb $(@D)
+clean-rb-default::
+ -$(Q)$(RM) $(RUBYLIBDIR)/psych.rb
+pre-install-rb-default:
+ $(ECHO) installing default psych libraries
+clean-rb-default::
+ -$(Q)$(RMDIRS) $(RUBYLIBDIR)/psych/json 2> /dev/null || true
+ -$(Q)$(RMDIRS) $(RUBYLIBDIR)/psych/handlers 2> /dev/null || true
+ -$(Q)$(RMDIRS) $(RUBYLIBDIR)/psych/nodes 2> /dev/null || true
+ -$(Q)$(RMDIRS) $(RUBYLIBDIR)/psych/visitors 2> /dev/null || true
+ -$(Q)$(RMDIRS) $(RUBYLIBDIR)/psych 2> /dev/null || true
+ -$(Q)$(RMDIRS) $(RUBYLIBDIR) 2> /dev/null || true
+$(TIMESTAMP_DIR)/.RUBYARCHDIR.time:
+ $(Q) $(MAKEDIRS) $(@D) $(RUBYARCHDIR)
+ $(Q) $(TOUCH) $@
+$(TIMESTAMP_DIR)/.RUBYLIBDIR.-.psych.-.json.time:
+ $(Q) $(MAKEDIRS) $(@D) $(RUBYLIBDIR)/psych/json
+ $(Q) $(TOUCH) $@
+$(TIMESTAMP_DIR)/.RUBYLIBDIR.-.psych.time:
+ $(Q) $(MAKEDIRS) $(@D) $(RUBYLIBDIR)/psych
+ $(Q) $(TOUCH) $@
+$(TIMESTAMP_DIR)/.RUBYLIBDIR.-.psych.-.handlers.time:
+ $(Q) $(MAKEDIRS) $(@D) $(RUBYLIBDIR)/psych/handlers
+ $(Q) $(TOUCH) $@
+$(TIMESTAMP_DIR)/.RUBYLIBDIR.-.psych.-.nodes.time:
+ $(Q) $(MAKEDIRS) $(@D) $(RUBYLIBDIR)/psych/nodes
+ $(Q) $(TOUCH) $@
+$(TIMESTAMP_DIR)/.RUBYLIBDIR.-.psych.-.visitors.time:
+ $(Q) $(MAKEDIRS) $(@D) $(RUBYLIBDIR)/psych/visitors
+ $(Q) $(TOUCH) $@
+$(TIMESTAMP_DIR)/.RUBYLIBDIR.time:
+ $(Q) $(MAKEDIRS) $(@D) $(RUBYLIBDIR)
+ $(Q) $(TOUCH) $@
+
+site-install: site-install-so site-install-rb
+site-install-so: install-so
+site-install-rb: install-rb
+
+.SUFFIXES: .c .m .cc .mm .cxx .cpp .o .S
+
+.cc.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<
+
+.cc.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -S $<
+
+.mm.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<
+
+.mm.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -S $<
+
+.cxx.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<
+
+.cxx.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -S $<
+
+.cpp.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<
+
+.cpp.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -S $<
+
+.c.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -c $<
+
+.c.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -S $<
+
+.m.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -c $<
+
+.m.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -S $<
+
+$(RUBYARCHDIR)/$(DLLIB): $(OBJS) Makefile $(TIMESTAMP_DIR)/.RUBYARCHDIR.time
+ $(ECHO) linking shared-object $(DLLIB)
+ -$(Q)$(RM) $(@)
+ $(Q) $(LDSHARED) -o $@ $(OBJS) $(LIBPATH) $(DLDFLAGS) $(LOCAL_LIBS) $(LIBS)
+
+$(STATIC_LIB): $(OBJS)
+ -$(Q)$(RM) $(@)
+ $(ECHO) linking static-library $(@)
+ $(Q) $(AR) cru $@ $(OBJS)
+ -$(Q)ranlib $(@) 2> /dev/null || true
+
+###
+$(OBJS): $(RUBY_EXTCONF_H)
+
+$(OBJS): $(HDRS) $(ruby_headers) \
+ $(hdrdir)/ruby/encoding.h \
+ $(hdrdir)/ruby/oniguruma.h
diff --git a/jni/ruby/ext/psych/depend b/jni/ruby/ext/psych/depend
new file mode 100644
index 0000000..79b6c53
--- /dev/null
+++ b/jni/ruby/ext/psych/depend
@@ -0,0 +1,3 @@
+$(OBJS): $(HDRS) $(ruby_headers) \
+ $(hdrdir)/ruby/encoding.h \
+ $(hdrdir)/ruby/oniguruma.h
diff --git a/jni/ruby/ext/psych/extconf.h b/jni/ruby/ext/psych/extconf.h
new file mode 100644
index 0000000..f5d6363
--- /dev/null
+++ b/jni/ruby/ext/psych/extconf.h
@@ -0,0 +1,14 @@
+#ifndef EXTCONF_H
+#define EXTCONF_H
+#define HAVE_DLFCN_H 1
+#define HAVE_INTTYPES_H 1
+#define HAVE_MEMORY_H 1
+#define HAVE_STDINT_H 1
+#define HAVE_STDLIB_H 1
+#define HAVE_STRINGS_H 1
+#define HAVE_STRING_H 1
+#define HAVE_SYS_STAT_H 1
+#define HAVE_SYS_TYPES_H 1
+#define HAVE_UNISTD_H 1
+#define HAVE_CONFIG_H 1
+#endif
diff --git a/jni/ruby/ext/psych/extconf.rb b/jni/ruby/ext/psych/extconf.rb
new file mode 100644
index 0000000..65e83a3
--- /dev/null
+++ b/jni/ruby/ext/psych/extconf.rb
@@ -0,0 +1,38 @@
+# -*- coding: us-ascii -*-
+require 'mkmf'
+require 'fileutils'
+
+# :stopdoc:
+
+dir_config 'libyaml'
+
+if enable_config("bundled-libyaml", false) || !(find_header('yaml.h') && find_library('yaml', 'yaml_get_version'))
+ # Embed libyaml since we could not find it.
+
+ $VPATH << "$(srcdir)/yaml"
+ $INCFLAGS << " -I$(srcdir)/yaml"
+
+ $srcs = Dir.glob("#{$srcdir}/{,yaml/}*.c").map {|n| File.basename(n)}
+
+ if have_macro("_WIN32")
+ $CPPFLAGS << " -DYAML_DECLARE_STATIC -DHAVE_CONFIG_H"
+ end
+
+ have_header 'dlfcn.h'
+ have_header 'inttypes.h'
+ have_header 'memory.h'
+ have_header 'stdint.h'
+ have_header 'stdlib.h'
+ have_header 'strings.h'
+ have_header 'string.h'
+ have_header 'sys/stat.h'
+ have_header 'sys/types.h'
+ have_header 'unistd.h'
+
+ find_header 'yaml.h'
+ have_header 'config.h'
+end
+
+create_makefile 'psych'
+
+# :startdoc:
diff --git a/jni/ruby/ext/psych/lib/psych.rb b/jni/ruby/ext/psych/lib/psych.rb
new file mode 100644
index 0000000..1933437
--- /dev/null
+++ b/jni/ruby/ext/psych/lib/psych.rb
@@ -0,0 +1,498 @@
+require 'psych.so'
+require 'psych/nodes'
+require 'psych/streaming'
+require 'psych/visitors'
+require 'psych/handler'
+require 'psych/tree_builder'
+require 'psych/parser'
+require 'psych/omap'
+require 'psych/set'
+require 'psych/coder'
+require 'psych/core_ext'
+require 'psych/deprecated'
+require 'psych/stream'
+require 'psych/json/tree_builder'
+require 'psych/json/stream'
+require 'psych/handlers/document_stream'
+require 'psych/class_loader'
+
+###
+# = Overview
+#
+# Psych is a YAML parser and emitter.
+# Psych leverages libyaml [Home page: http://pyyaml.org/wiki/LibYAML]
+# or [HG repo: https://bitbucket.org/xi/libyaml] for its YAML parsing
+# and emitting capabilities. In addition to wrapping libyaml, Psych also
+# knows how to serialize and de-serialize most Ruby objects to and from
+# the YAML format.
+#
+# = I NEED TO PARSE OR EMIT YAML RIGHT NOW!
+#
+# # Parse some YAML
+# Psych.load("--- foo") # => "foo"
+#
+# # Emit some YAML
+# Psych.dump("foo") # => "--- foo\n...\n"
+# { :a => 'b'}.to_yaml # => "---\n:a: b\n"
+#
+# Got more time on your hands? Keep on reading!
+#
+# == YAML Parsing
+#
+# Psych provides a range of interfaces for parsing a YAML document ranging from
+# low level to high level, depending on your parsing needs. At the lowest
+# level, is an event based parser. Mid level is access to the raw YAML AST,
+# and at the highest level is the ability to unmarshal YAML to Ruby objects.
+#
+# == YAML Emitting
+#
+# Psych provides a range of interfaces ranging from low to high level for
+# producing YAML documents. Very similar to the YAML parsing interfaces, Psych
+# provides at the lowest level, an event based system, mid-level is building
+# a YAML AST, and the highest level is converting a Ruby object straight to
+# a YAML document.
+#
+# == High-level API
+#
+# === Parsing
+#
+# The high level YAML parser provided by Psych simply takes YAML as input and
+# returns a Ruby data structure. For information on using the high level parser
+# see Psych.load
+#
+# ==== Reading from a string
+#
+# Psych.load("--- a") # => 'a'
+# Psych.load("---\n - a\n - b") # => ['a', 'b']
+#
+# ==== Reading from a file
+#
+# Psych.load_file("database.yml")
+#
+# ==== Exception handling
+#
+# begin
+# # The second argument changes only the exception contents
+# Psych.parse("--- `", "file.txt")
+# rescue Psych::SyntaxError => ex
+# ex.file # => 'file.txt'
+# ex.message # => "(file.txt): found character that cannot start any token"
+# end
+#
+# === Emitting
+#
+# The high level emitter has the easiest interface. Psych simply takes a Ruby
+# data structure and converts it to a YAML document. See Psych.dump for more
+# information on dumping a Ruby data structure.
+#
+# ==== Writing to a string
+#
+# # Dump an array, get back a YAML string
+# Psych.dump(['a', 'b']) # => "---\n- a\n- b\n"
+#
+# # Dump an array to an IO object
+# Psych.dump(['a', 'b'], StringIO.new) # => #<StringIO:0x000001009d0890>
+#
+# # Dump an array with indentation set
+# Psych.dump(['a', ['b']], :indentation => 3) # => "---\n- a\n- - b\n"
+#
+# # Dump an array to an IO with indentation set
+# Psych.dump(['a', ['b']], StringIO.new, :indentation => 3)
+#
+# ==== Writing to a file
+#
+# Currently there is no direct API for dumping Ruby structure to file:
+#
+# File.open('database.yml', 'w') do |file|
+# file.write(Psych.dump(['a', 'b']))
+# end
+#
+# == Mid-level API
+#
+# === Parsing
+#
+# Psych provides access to an AST produced from parsing a YAML document. This
+# tree is built using the Psych::Parser and Psych::TreeBuilder. The AST can
+# be examined and manipulated freely. Please see Psych::parse_stream,
+# Psych::Nodes, and Psych::Nodes::Node for more information on dealing with
+# YAML syntax trees.
+#
+# ==== Reading from a string
+#
+# # Returns Psych::Nodes::Stream
+# Psych.parse_stream("---\n - a\n - b")
+#
+# # Returns Psych::Nodes::Document
+# Psych.parse("---\n - a\n - b")
+#
+# ==== Reading from a file
+#
+# # Returns Psych::Nodes::Stream
+# Psych.parse_stream(File.read('database.yml'))
+#
+# # Returns Psych::Nodes::Document
+# Psych.parse_file('database.yml')
+#
+# ==== Exception handling
+#
+# begin
+# # The second argument changes only the exception contents
+# Psych.parse("--- `", "file.txt")
+# rescue Psych::SyntaxError => ex
+# ex.file # => 'file.txt'
+# ex.message # => "(file.txt): found character that cannot start any token"
+# end
+#
+# === Emitting
+#
+# At the mid level is building an AST. This AST is exactly the same as the AST
+# used when parsing a YAML document. Users can build an AST by hand and the
+# AST knows how to emit itself as a YAML document. See Psych::Nodes,
+# Psych::Nodes::Node, and Psych::TreeBuilder for more information on building
+# a YAML AST.
+#
+# ==== Writing to a string
+#
+# # We need Psych::Nodes::Stream (not Psych::Nodes::Document)
+# stream = Psych.parse_stream("---\n - a\n - b")
+#
+# stream.to_yaml # => "---\n- a\n- b\n"
+#
+# ==== Writing to a file
+#
+# # We need Psych::Nodes::Stream (not Psych::Nodes::Document)
+# stream = Psych.parse_stream(File.read('database.yml'))
+#
+# File.open('database.yml', 'w') do |file|
+# file.write(stream.to_yaml)
+# end
+#
+# == Low-level API
+#
+# === Parsing
+#
+# The lowest level parser should be used when the YAML input is already known,
+# and the developer does not want to pay the price of building an AST or
+# automatic detection and conversion to Ruby objects. See Psych::Parser for
+# more information on using the event based parser.
+#
+# ==== Reading to Psych::Nodes::Stream structure
+#
+# parser = Psych::Parser.new(TreeBuilder.new) # => #<Psych::Parser>
+# parser = Psych.parser # it's an alias for the above
+#
+# parser.parse("---\n - a\n - b") # => #<Psych::Parser>
+# parser.handler # => #<Psych::TreeBuilder>
+# parser.handler.root # => #<Psych::Nodes::Stream>
+#
+# ==== Receiving an events stream
+#
+# parser = Psych::Parser.new(Psych::Handlers::Recorder.new)
+#
+# parser.parse("---\n - a\n - b")
+# parser.events # => [list of [event, args] lists]
+# # event is one of: Psych::Handler::EVENTS
+# # args are the arguments passed to the event
+#
+# === Emitting
+#
+# The lowest level emitter is an event based system. Events are sent to a
+# Psych::Emitter object. That object knows how to convert the events to a YAML
+# document. This interface should be used when document format is known in
+# advance or speed is a concern. See Psych::Emitter for more information.
+#
+# ==== Writing to a Ruby structure
+#
+# Psych.parser.parse("--- a") # => #<Psych::Parser>
+#
+# parser.handler.first # => #<Psych::Nodes::Stream>
+# parser.handler.first.to_ruby # => ["a"]
+#
+# parser.handler.root.first # => #<Psych::Nodes::Document>
+# parser.handler.root.first.to_ruby # => "a"
+#
+# # You can instantiate an Emitter manually
+# Psych::Visitors::ToRuby.new.accept(parser.handler.root.first)
+# # => "a"
+
+module Psych
+ # The version is Psych you're using
+ VERSION = '2.0.8'
+
+ # The version of libyaml Psych is using
+ LIBYAML_VERSION = Psych.libyaml_version.join '.'
+
+ ###
+ # Load +yaml+ in to a Ruby data structure. If multiple documents are
+ # provided, the object contained in the first document will be returned.
+ # +filename+ will be used in the exception message if any exception is raised
+ # while parsing.
+ #
+ # Raises a Psych::SyntaxError when a YAML syntax error is detected.
+ #
+ # Example:
+ #
+ # Psych.load("--- a") # => 'a'
+ # Psych.load("---\n - a\n - b") # => ['a', 'b']
+ #
+ # begin
+ # Psych.load("--- `", "file.txt")
+ # rescue Psych::SyntaxError => ex
+ # ex.file # => 'file.txt'
+ # ex.message # => "(file.txt): found character that cannot start any token"
+ # end
+ def self.load yaml, filename = nil
+ result = parse(yaml, filename)
+ result ? result.to_ruby : result
+ end
+
+ ###
+ # Safely load the yaml string in +yaml+. By default, only the following
+ # classes are allowed to be deserialized:
+ #
+ # * TrueClass
+ # * FalseClass
+ # * NilClass
+ # * Numeric
+ # * String
+ # * Array
+ # * Hash
+ #
+ # Recursive data structures are not allowed by default. Arbitrary classes
+ # can be allowed by adding those classes to the +whitelist+. They are
+ # additive. For example, to allow Date deserialization:
+ #
+ # Psych.safe_load(yaml, [Date])
+ #
+ # Now the Date class can be loaded in addition to the classes listed above.
+ #
+ # Aliases can be explicitly allowed by changing the +aliases+ parameter.
+ # For example:
+ #
+ # x = []
+ # x << x
+ # yaml = Psych.dump x
+ # Psych.safe_load yaml # => raises an exception
+ # Psych.safe_load yaml, [], [], true # => loads the aliases
+ #
+ # A Psych::DisallowedClass exception will be raised if the yaml contains a
+ # class that isn't in the whitelist.
+ #
+ # A Psych::BadAlias exception will be raised if the yaml contains aliases
+ # but the +aliases+ parameter is set to false.
+ def self.safe_load yaml, whitelist_classes = [], whitelist_symbols = [], aliases = false, filename = nil
+ result = parse(yaml, filename)
+ return unless result
+
+ class_loader = ClassLoader::Restricted.new(whitelist_classes.map(&:to_s),
+ whitelist_symbols.map(&:to_s))
+ scanner = ScalarScanner.new class_loader
+ if aliases
+ visitor = Visitors::ToRuby.new scanner, class_loader
+ else
+ visitor = Visitors::NoAliasRuby.new scanner, class_loader
+ end
+ visitor.accept result
+ end
+
+ ###
+ # Parse a YAML string in +yaml+. Returns the Psych::Nodes::Document.
+ # +filename+ is used in the exception message if a Psych::SyntaxError is
+ # raised.
+ #
+ # Raises a Psych::SyntaxError when a YAML syntax error is detected.
+ #
+ # Example:
+ #
+ # Psych.parse("---\n - a\n - b") # => #<Psych::Nodes::Document:0x00>
+ #
+ # begin
+ # Psych.parse("--- `", "file.txt")
+ # rescue Psych::SyntaxError => ex
+ # ex.file # => 'file.txt'
+ # ex.message # => "(file.txt): found character that cannot start any token"
+ # end
+ #
+ # See Psych::Nodes for more information about YAML AST.
+ def self.parse yaml, filename = nil
+ parse_stream(yaml, filename) do |node|
+ return node
+ end
+ false
+ end
+
+ ###
+ # Parse a file at +filename+. Returns the Psych::Nodes::Document.
+ #
+ # Raises a Psych::SyntaxError when a YAML syntax error is detected.
+ def self.parse_file filename
+ File.open filename, 'r:bom|utf-8' do |f|
+ parse f, filename
+ end
+ end
+
+ ###
+ # Returns a default parser
+ def self.parser
+ Psych::Parser.new(TreeBuilder.new)
+ end
+
+ ###
+ # Parse a YAML string in +yaml+. Returns the Psych::Nodes::Stream.
+ # This method can handle multiple YAML documents contained in +yaml+.
+ # +filename+ is used in the exception message if a Psych::SyntaxError is
+ # raised.
+ #
+ # If a block is given, a Psych::Nodes::Document node will be yielded to the
+ # block as it's being parsed.
+ #
+ # Raises a Psych::SyntaxError when a YAML syntax error is detected.
+ #
+ # Example:
+ #
+ # Psych.parse_stream("---\n - a\n - b") # => #<Psych::Nodes::Stream:0x00>
+ #
+ # Psych.parse_stream("--- a\n--- b") do |node|
+ # node # => #<Psych::Nodes::Document:0x00>
+ # end
+ #
+ # begin
+ # Psych.parse_stream("--- `", "file.txt")
+ # rescue Psych::SyntaxError => ex
+ # ex.file # => 'file.txt'
+ # ex.message # => "(file.txt): found character that cannot start any token"
+ # end
+ #
+ # See Psych::Nodes for more information about YAML AST.
+ def self.parse_stream yaml, filename = nil, &block
+ if block_given?
+ parser = Psych::Parser.new(Handlers::DocumentStream.new(&block))
+ parser.parse yaml, filename
+ else
+ parser = self.parser
+ parser.parse yaml, filename
+ parser.handler.root
+ end
+ end
+
+ ###
+ # call-seq:
+ # Psych.dump(o) -> string of yaml
+ # Psych.dump(o, options) -> string of yaml
+ # Psych.dump(o, io) -> io object passed in
+ # Psych.dump(o, io, options) -> io object passed in
+ #
+ # Dump Ruby object +o+ to a YAML string. Optional +options+ may be passed in
+ # to control the output format. If an IO object is passed in, the YAML will
+ # be dumped to that IO object.
+ #
+ # Example:
+ #
+ # # Dump an array, get back a YAML string
+ # Psych.dump(['a', 'b']) # => "---\n- a\n- b\n"
+ #
+ # # Dump an array to an IO object
+ # Psych.dump(['a', 'b'], StringIO.new) # => #<StringIO:0x000001009d0890>
+ #
+ # # Dump an array with indentation set
+ # Psych.dump(['a', ['b']], :indentation => 3) # => "---\n- a\n- - b\n"
+ #
+ # # Dump an array to an IO with indentation set
+ # Psych.dump(['a', ['b']], StringIO.new, :indentation => 3)
+ def self.dump o, io = nil, options = {}
+ if Hash === io
+ options = io
+ io = nil
+ end
+
+ visitor = Psych::Visitors::YAMLTree.create options
+ visitor << o
+ visitor.tree.yaml io, options
+ end
+
+ ###
+ # Dump a list of objects as separate documents to a document stream.
+ #
+ # Example:
+ #
+ # Psych.dump_stream("foo\n ", {}) # => "--- ! \"foo\\n \"\n--- {}\n"
+ def self.dump_stream *objects
+ visitor = Psych::Visitors::YAMLTree.create({})
+ objects.each do |o|
+ visitor << o
+ end
+ visitor.tree.yaml
+ end
+
+ ###
+ # Dump Ruby +object+ to a JSON string.
+ def self.to_json object
+ visitor = Psych::Visitors::JSONTree.create
+ visitor << object
+ visitor.tree.yaml
+ end
+
+ ###
+ # Load multiple documents given in +yaml+. Returns the parsed documents
+ # as a list. If a block is given, each document will be converted to Ruby
+ # and passed to the block during parsing
+ #
+ # Example:
+ #
+ # Psych.load_stream("--- foo\n...\n--- bar\n...") # => ['foo', 'bar']
+ #
+ # list = []
+ # Psych.load_stream("--- foo\n...\n--- bar\n...") do |ruby|
+ # list << ruby
+ # end
+ # list # => ['foo', 'bar']
+ #
+ def self.load_stream yaml, filename = nil
+ if block_given?
+ parse_stream(yaml, filename) do |node|
+ yield node.to_ruby
+ end
+ else
+ parse_stream(yaml, filename).children.map { |child| child.to_ruby }
+ end
+ end
+
+ ###
+ # Load the document contained in +filename+. Returns the yaml contained in
+ # +filename+ as a Ruby object
+ def self.load_file filename
+ File.open(filename, 'r:bom|utf-8') { |f| self.load f, filename }
+ end
+
+ # :stopdoc:
+ @domain_types = {}
+ def self.add_domain_type domain, type_tag, &block
+ key = ['tag', domain, type_tag].join ':'
+ @domain_types[key] = [key, block]
+ @domain_types["tag:#{type_tag}"] = [key, block]
+ end
+
+ def self.add_builtin_type type_tag, &block
+ domain = 'yaml.org,2002'
+ key = ['tag', domain, type_tag].join ':'
+ @domain_types[key] = [key, block]
+ end
+
+ def self.remove_type type_tag
+ @domain_types.delete type_tag
+ end
+
+ @load_tags = {}
+ @dump_tags = {}
+ def self.add_tag tag, klass
+ @load_tags[tag] = klass.name
+ @dump_tags[klass] = tag
+ end
+
+ class << self
+ attr_accessor :load_tags
+ attr_accessor :dump_tags
+ attr_accessor :domain_types
+ end
+ # :startdoc:
+end
diff --git a/jni/ruby/ext/psych/lib/psych/class_loader.rb b/jni/ruby/ext/psych/lib/psych/class_loader.rb
new file mode 100644
index 0000000..46c6b93
--- /dev/null
+++ b/jni/ruby/ext/psych/lib/psych/class_loader.rb
@@ -0,0 +1,101 @@
+require 'psych/omap'
+require 'psych/set'
+
+module Psych
+ class ClassLoader # :nodoc:
+ BIG_DECIMAL = 'BigDecimal'
+ COMPLEX = 'Complex'
+ DATE = 'Date'
+ DATE_TIME = 'DateTime'
+ EXCEPTION = 'Exception'
+ OBJECT = 'Object'
+ PSYCH_OMAP = 'Psych::Omap'
+ PSYCH_SET = 'Psych::Set'
+ RANGE = 'Range'
+ RATIONAL = 'Rational'
+ REGEXP = 'Regexp'
+ STRUCT = 'Struct'
+ SYMBOL = 'Symbol'
+
+ def initialize
+ @cache = CACHE.dup
+ end
+
+ def load klassname
+ return nil if !klassname || klassname.empty?
+
+ find klassname
+ end
+
+ def symbolize sym
+ symbol
+ sym.to_sym
+ end
+
+ constants.each do |const|
+ konst = const_get const
+ define_method(const.to_s.downcase) do
+ load konst
+ end
+ end
+
+ private
+
+ def find klassname
+ @cache[klassname] ||= resolve(klassname)
+ end
+
+ def resolve klassname
+ name = klassname
+ retried = false
+
+ begin
+ path2class(name)
+ rescue ArgumentError, NameError => ex
+ unless retried
+ name = "Struct::#{name}"
+ retried = ex
+ retry
+ end
+ raise retried
+ end
+ end
+
+ CACHE = Hash[constants.map { |const|
+ val = const_get const
+ begin
+ [val, ::Object.const_get(val)]
+ rescue
+ nil
+ end
+ }.compact]
+
+ class Restricted < ClassLoader
+ def initialize classes, symbols
+ @classes = classes
+ @symbols = symbols
+ super()
+ end
+
+ def symbolize sym
+ return super if @symbols.empty?
+
+ if @symbols.include? sym
+ super
+ else
+ raise DisallowedClass, 'Symbol'
+ end
+ end
+
+ private
+
+ def find klassname
+ if @classes.include? klassname
+ super
+ else
+ raise DisallowedClass, klassname
+ end
+ end
+ end
+ end
+end
diff --git a/jni/ruby/ext/psych/lib/psych/coder.rb b/jni/ruby/ext/psych/lib/psych/coder.rb
new file mode 100644
index 0000000..2b830d2
--- /dev/null
+++ b/jni/ruby/ext/psych/lib/psych/coder.rb
@@ -0,0 +1,94 @@
+module Psych
+ ###
+ # If an object defines +encode_with+, then an instance of Psych::Coder will
+ # be passed to the method when the object is being serialized. The Coder
+ # automatically assumes a Psych::Nodes::Mapping is being emitted. Other
+ # objects like Sequence and Scalar may be emitted if +seq=+ or +scalar=+ are
+ # called, respectively.
+ class Coder
+ attr_accessor :tag, :style, :implicit, :object
+ attr_reader :type, :seq
+
+ def initialize tag
+ @map = {}
+ @seq = []
+ @implicit = false
+ @type = :map
+ @tag = tag
+ @style = Psych::Nodes::Mapping::BLOCK
+ @scalar = nil
+ @object = nil
+ end
+
+ def scalar *args
+ if args.length > 0
+ warn "#{caller[0]}: Coder#scalar(a,b,c) is deprecated" if $VERBOSE
+ @tag, @scalar, _ = args
+ @type = :scalar
+ end
+ @scalar
+ end
+
+ # Emit a map. The coder will be yielded to the block.
+ def map tag = @tag, style = @style
+ @tag = tag
+ @style = style
+ yield self if block_given?
+ @map
+ end
+
+ # Emit a scalar with +value+ and +tag+
+ def represent_scalar tag, value
+ self.tag = tag
+ self.scalar = value
+ end
+
+ # Emit a sequence with +list+ and +tag+
+ def represent_seq tag, list
+ @tag = tag
+ self.seq = list
+ end
+
+ # Emit a sequence with +map+ and +tag+
+ def represent_map tag, map
+ @tag = tag
+ self.map = map
+ end
+
+ # Emit an arbitrary object +obj+ and +tag+
+ def represent_object tag, obj
+ @tag = tag
+ @type = :object
+ @object = obj
+ end
+
+ # Emit a scalar with +value+
+ def scalar= value
+ @type = :scalar
+ @scalar = value
+ end
+
+ # Emit a map with +value+
+ def map= map
+ @type = :map
+ @map = map
+ end
+
+ def []= k, v
+ @type = :map
+ @map[k] = v
+ end
+ alias :add :[]=
+
+ def [] k
+ @type = :map
+ @map[k]
+ end
+
+ # Emit a sequence of +list+
+ def seq= list
+ @type = :seq
+ @seq = list
+ end
+ end
+end
diff --git a/jni/ruby/ext/psych/lib/psych/core_ext.rb b/jni/ruby/ext/psych/lib/psych/core_ext.rb
new file mode 100644
index 0000000..9c8134d
--- /dev/null
+++ b/jni/ruby/ext/psych/lib/psych/core_ext.rb
@@ -0,0 +1,35 @@
+class Object
+ def self.yaml_tag url
+ Psych.add_tag(url, self)
+ end
+
+ # FIXME: rename this to "to_yaml" when syck is removed
+
+ ###
+ # call-seq: to_yaml(options = {})
+ #
+ # Convert an object to YAML. See Psych.dump for more information on the
+ # available +options+.
+ def psych_to_yaml options = {}
+ Psych.dump self, options
+ end
+ remove_method :to_yaml rescue nil
+ alias :to_yaml :psych_to_yaml
+end
+
+class Module
+ def psych_yaml_as url
+ return if caller[0].end_with?('rubytypes.rb')
+ if $VERBOSE
+ warn "#{caller[0]}: yaml_as is deprecated, please use yaml_tag"
+ end
+ Psych.add_tag(url, self)
+ end
+
+ remove_method :yaml_as rescue nil
+ alias :yaml_as :psych_yaml_as
+end
+
+if defined?(::IRB)
+ require 'psych/y'
+end
diff --git a/jni/ruby/ext/psych/lib/psych/deprecated.rb b/jni/ruby/ext/psych/lib/psych/deprecated.rb
new file mode 100644
index 0000000..8c310b3
--- /dev/null
+++ b/jni/ruby/ext/psych/lib/psych/deprecated.rb
@@ -0,0 +1,85 @@
+require 'date'
+
+module Psych
+ DEPRECATED = __FILE__ # :nodoc:
+
+ module DeprecatedMethods # :nodoc:
+ attr_accessor :taguri
+ attr_accessor :to_yaml_style
+ end
+
+ def self.quick_emit thing, opts = {}, &block # :nodoc:
+ warn "#{caller[0]}: YAML.quick_emit is deprecated" if $VERBOSE && !caller[0].start_with?(File.dirname(__FILE__))
+ target = eval 'self', block.binding
+ target.extend DeprecatedMethods
+ metaclass = class << target; self; end
+ metaclass.send(:define_method, :encode_with) do |coder|
+ target.taguri = coder.tag
+ target.to_yaml_style = coder.style
+ block.call coder
+ end
+ target.psych_to_yaml unless opts[:nodump]
+ end
+
+ # This method is deprecated, use Psych.load_stream instead.
+ def self.load_documents yaml, &block
+ if $VERBOSE
+ warn "#{caller[0]}: load_documents is deprecated, use load_stream"
+ end
+ list = load_stream yaml
+ return list unless block_given?
+ list.each(&block)
+ end
+
+ def self.detect_implicit thing
+ warn "#{caller[0]}: detect_implicit is deprecated" if $VERBOSE
+ return '' unless String === thing
+ return 'null' if '' == thing
+ ss = ScalarScanner.new(ClassLoader.new)
+ ss.tokenize(thing).class.name.downcase
+ end
+
+ def self.add_ruby_type type_tag, &block
+ warn "#{caller[0]}: add_ruby_type is deprecated, use add_domain_type" if $VERBOSE
+ domain = 'ruby.yaml.org,2002'
+ key = ['tag', domain, type_tag].join ':'
+ @domain_types[key] = [key, block]
+ end
+
+ def self.add_private_type type_tag, &block
+ warn "#{caller[0]}: add_private_type is deprecated, use add_domain_type" if $VERBOSE
+ domain = 'x-private'
+ key = [domain, type_tag].join ':'
+ @domain_types[key] = [key, block]
+ end
+
+ def self.tagurize thing
+ warn "#{caller[0]}: add_private_type is deprecated, use add_domain_type" if $VERBOSE
+ return thing unless String === thing
+ "tag:yaml.org,2002:#{thing}"
+ end
+
+ def self.read_type_class type, reference
+ warn "#{caller[0]}: read_type_class is deprecated" if $VERBOSE
+ _, _, type, name = type.split ':', 4
+
+ reference = name.split('::').inject(reference) do |k,n|
+ k.const_get(n.to_sym)
+ end if name
+ [type, reference]
+ end
+
+ def self.object_maker klass, hash
+ warn "#{caller[0]}: object_maker is deprecated" if $VERBOSE
+ klass.allocate.tap do |obj|
+ hash.each { |k,v| obj.instance_variable_set(:"@#{k}", v) }
+ end
+ end
+end
+
+class Object
+ undef :to_yaml_properties rescue nil
+ def to_yaml_properties # :nodoc:
+ instance_variables
+ end
+end
diff --git a/jni/ruby/ext/psych/lib/psych/exception.rb b/jni/ruby/ext/psych/lib/psych/exception.rb
new file mode 100644
index 0000000..ce9d2ca
--- /dev/null
+++ b/jni/ruby/ext/psych/lib/psych/exception.rb
@@ -0,0 +1,13 @@
+module Psych
+ class Exception < RuntimeError
+ end
+
+ class BadAlias < Exception
+ end
+
+ class DisallowedClass < Exception
+ def initialize klass_name
+ super "Tried to load unspecified class: #{klass_name}"
+ end
+ end
+end
diff --git a/jni/ruby/ext/psych/lib/psych/handler.rb b/jni/ruby/ext/psych/lib/psych/handler.rb
new file mode 100644
index 0000000..c55afe7
--- /dev/null
+++ b/jni/ruby/ext/psych/lib/psych/handler.rb
@@ -0,0 +1,249 @@
+module Psych
+ ###
+ # Psych::Handler is an abstract base class that defines the events used
+ # when dealing with Psych::Parser. Clients who want to use Psych::Parser
+ # should implement a class that inherits from Psych::Handler and define
+ # events that they can handle.
+ #
+ # Psych::Handler defines all events that Psych::Parser can possibly send to
+ # event handlers.
+ #
+ # See Psych::Parser for more details
+ class Handler
+ ###
+ # Configuration options for dumping YAML.
+ class DumperOptions
+ attr_accessor :line_width, :indentation, :canonical
+
+ def initialize
+ @line_width = 0
+ @indentation = 2
+ @canonical = false
+ end
+ end
+
+ # Default dumping options
+ OPTIONS = DumperOptions.new
+
+ # Events that a Handler should respond to.
+ EVENTS = [ :alias,
+ :empty,
+ :end_document,
+ :end_mapping,
+ :end_sequence,
+ :end_stream,
+ :scalar,
+ :start_document,
+ :start_mapping,
+ :start_sequence,
+ :start_stream ]
+
+ ###
+ # Called with +encoding+ when the YAML stream starts. This method is
+ # called once per stream. A stream may contain multiple documents.
+ #
+ # See the constants in Psych::Parser for the possible values of +encoding+.
+ def start_stream encoding
+ end
+
+ ###
+ # Called when the document starts with the declared +version+,
+ # +tag_directives+, if the document is +implicit+.
+ #
+ # +version+ will be an array of integers indicating the YAML version being
+ # dealt with, +tag_directives+ is a list of tuples indicating the prefix
+ # and suffix of each tag, and +implicit+ is a boolean indicating whether
+ # the document is started implicitly.
+ #
+ # === Example
+ #
+ # Given the following YAML:
+ #
+ # %YAML 1.1
+ # %TAG ! tag:tenderlovemaking.com,2009:
+ # --- !squee
+ #
+ # The parameters for start_document must be this:
+ #
+ # version # => [1, 1]
+ # tag_directives # => [["!", "tag:tenderlovemaking.com,2009:"]]
+ # implicit # => false
+ def start_document version, tag_directives, implicit
+ end
+
+ ###
+ # Called with the document ends. +implicit+ is a boolean value indicating
+ # whether or not the document has an implicit ending.
+ #
+ # === Example
+ #
+ # Given the following YAML:
+ #
+ # ---
+ # hello world
+ #
+ # +implicit+ will be true. Given this YAML:
+ #
+ # ---
+ # hello world
+ # ...
+ #
+ # +implicit+ will be false.
+ def end_document implicit
+ end
+
+ ###
+ # Called when an alias is found to +anchor+. +anchor+ will be the name
+ # of the anchor found.
+ #
+ # === Example
+ #
+ # Here we have an example of an array that references itself in YAML:
+ #
+ # --- &ponies
+ # - first element
+ # - *ponies
+ #
+ # &ponies is the achor, *ponies is the alias. In this case, alias is
+ # called with "ponies".
+ def alias anchor
+ end
+
+ ###
+ # Called when a scalar +value+ is found. The scalar may have an
+ # +anchor+, a +tag+, be implicitly +plain+ or implicitly +quoted+
+ #
+ # +value+ is the string value of the scalar
+ # +anchor+ is an associated anchor or nil
+ # +tag+ is an associated tag or nil
+ # +plain+ is a boolean value
+ # +quoted+ is a boolean value
+ # +style+ is an integer idicating the string style
+ #
+ # See the constants in Psych::Nodes::Scalar for the possible values of
+ # +style+
+ #
+ # === Example
+ #
+ # Here is a YAML document that exercises most of the possible ways this
+ # method can be called:
+ #
+ # ---
+ # - !str "foo"
+ # - &anchor fun
+ # - many
+ # lines
+ # - |
+ # many
+ # newlines
+ #
+ # The above YAML document contains a list with four strings. Here are
+ # the parameters sent to this method in the same order:
+ #
+ # # value anchor tag plain quoted style
+ # ["foo", nil, "!str", false, false, 3 ]
+ # ["fun", "anchor", nil, true, false, 1 ]
+ # ["many lines", nil, nil, true, false, 1 ]
+ # ["many\nnewlines\n", nil, nil, false, true, 4 ]
+ #
+ def scalar value, anchor, tag, plain, quoted, style
+ end
+
+ ###
+ # Called when a sequence is started.
+ #
+ # +anchor+ is the anchor associated with the sequence or nil.
+ # +tag+ is the tag associated with the sequence or nil.
+ # +implicit+ a boolean indicating whether or not the sequence was implicitly
+ # started.
+ # +style+ is an integer indicating the list style.
+ #
+ # See the constants in Psych::Nodes::Sequence for the possible values of
+ # +style+.
+ #
+ # === Example
+ #
+ # Here is a YAML document that exercises most of the possible ways this
+ # method can be called:
+ #
+ # ---
+ # - !!seq [
+ # a
+ # ]
+ # - &pewpew
+ # - b
+ #
+ # The above YAML document consists of three lists, an outer list that
+ # contains two inner lists. Here is a matrix of the parameters sent
+ # to represent these lists:
+ #
+ # # anchor tag implicit style
+ # [nil, nil, true, 1 ]
+ # [nil, "tag:yaml.org,2002:seq", false, 2 ]
+ # ["pewpew", nil, true, 1 ]
+
+ def start_sequence anchor, tag, implicit, style
+ end
+
+ ###
+ # Called when a sequence ends.
+ def end_sequence
+ end
+
+ ###
+ # Called when a map starts.
+ #
+ # +anchor+ is the anchor associated with the map or +nil+.
+ # +tag+ is the tag associated with the map or +nil+.
+ # +implicit+ is a boolean indicating whether or not the map was implicitly
+ # started.
+ # +style+ is an integer indicating the mapping style.
+ #
+ # See the constants in Psych::Nodes::Mapping for the possible values of
+ # +style+.
+ #
+ # === Example
+ #
+ # Here is a YAML document that exercises most of the possible ways this
+ # method can be called:
+ #
+ # ---
+ # k: !!map { hello: world }
+ # v: &pewpew
+ # hello: world
+ #
+ # The above YAML document consists of three maps, an outer map that contains
+ # two inner maps. Below is a matrix of the parameters sent in order to
+ # represent these three maps:
+ #
+ # # anchor tag implicit style
+ # [nil, nil, true, 1 ]
+ # [nil, "tag:yaml.org,2002:map", false, 2 ]
+ # ["pewpew", nil, true, 1 ]
+
+ def start_mapping anchor, tag, implicit, style
+ end
+
+ ###
+ # Called when a map ends
+ def end_mapping
+ end
+
+ ###
+ # Called when an empty event happens. (Which, as far as I can tell, is
+ # never).
+ def empty
+ end
+
+ ###
+ # Called when the YAML stream ends
+ def end_stream
+ end
+
+ ###
+ # Is this handler a streaming handler?
+ def streaming?
+ false
+ end
+ end
+end
diff --git a/jni/ruby/ext/psych/lib/psych/handlers/document_stream.rb b/jni/ruby/ext/psych/lib/psych/handlers/document_stream.rb
new file mode 100644
index 0000000..e429993
--- /dev/null
+++ b/jni/ruby/ext/psych/lib/psych/handlers/document_stream.rb
@@ -0,0 +1,22 @@
+require 'psych/tree_builder'
+
+module Psych
+ module Handlers
+ class DocumentStream < Psych::TreeBuilder # :nodoc:
+ def initialize &block
+ super
+ @block = block
+ end
+
+ def start_document version, tag_directives, implicit
+ n = Nodes::Document.new version, tag_directives, implicit
+ push n
+ end
+
+ def end_document implicit_end = !streaming?
+ @last.implicit_end = implicit_end
+ @block.call pop
+ end
+ end
+ end
+end
diff --git a/jni/ruby/ext/psych/lib/psych/handlers/recorder.rb b/jni/ruby/ext/psych/lib/psych/handlers/recorder.rb
new file mode 100644
index 0000000..4eae62e
--- /dev/null
+++ b/jni/ruby/ext/psych/lib/psych/handlers/recorder.rb
@@ -0,0 +1,39 @@
+require 'psych/handler'
+
+module Psych
+ module Handlers
+ ###
+ # This handler will capture an event and record the event. Recorder events
+ # are available vial Psych::Handlers::Recorder#events.
+ #
+ # For example:
+ #
+ # recorder = Psych::Handlers::Recorder.new
+ # parser = Psych::Parser.new recorder
+ # parser.parse '--- foo'
+ #
+ # recorder.events # => [list of events]
+ #
+ # # Replay the events
+ #
+ # emitter = Psych::Emitter.new $stdout
+ # recorder.events.each do |m, args|
+ # emitter.send m, *args
+ # end
+
+ class Recorder < Psych::Handler
+ attr_reader :events
+
+ def initialize
+ @events = []
+ super
+ end
+
+ EVENTS.each do |event|
+ define_method event do |*args|
+ @events << [event, args]
+ end
+ end
+ end
+ end
+end
diff --git a/jni/ruby/ext/psych/lib/psych/json/ruby_events.rb b/jni/ruby/ext/psych/lib/psych/json/ruby_events.rb
new file mode 100644
index 0000000..6b73249
--- /dev/null
+++ b/jni/ruby/ext/psych/lib/psych/json/ruby_events.rb
@@ -0,0 +1,19 @@
+module Psych
+ module JSON
+ module RubyEvents # :nodoc:
+ def visit_Time o
+ formatted = format_time o
+ @emitter.scalar formatted, nil, nil, false, true, Nodes::Scalar::DOUBLE_QUOTED
+ end
+
+ def visit_DateTime o
+ visit_Time o.to_time
+ end
+
+ def visit_String o
+ @emitter.scalar o.to_s, nil, nil, false, true, Nodes::Scalar::DOUBLE_QUOTED
+ end
+ alias :visit_Symbol :visit_String
+ end
+ end
+end
diff --git a/jni/ruby/ext/psych/lib/psych/json/stream.rb b/jni/ruby/ext/psych/lib/psych/json/stream.rb
new file mode 100644
index 0000000..fe2a6e9
--- /dev/null
+++ b/jni/ruby/ext/psych/lib/psych/json/stream.rb
@@ -0,0 +1,16 @@
+require 'psych/json/ruby_events'
+require 'psych/json/yaml_events'
+
+module Psych
+ module JSON
+ class Stream < Psych::Visitors::JSONTree
+ include Psych::JSON::RubyEvents
+ include Psych::Streaming
+ extend Psych::Streaming::ClassMethods
+
+ class Emitter < Psych::Stream::Emitter # :nodoc:
+ include Psych::JSON::YAMLEvents
+ end
+ end
+ end
+end
diff --git a/jni/ruby/ext/psych/lib/psych/json/tree_builder.rb b/jni/ruby/ext/psych/lib/psych/json/tree_builder.rb
new file mode 100644
index 0000000..b799c93
--- /dev/null
+++ b/jni/ruby/ext/psych/lib/psych/json/tree_builder.rb
@@ -0,0 +1,12 @@
+require 'psych/json/yaml_events'
+
+module Psych
+ module JSON
+ ###
+ # Psych::JSON::TreeBuilder is an event based AST builder. Events are sent
+ # to an instance of Psych::JSON::TreeBuilder and a JSON AST is constructed.
+ class TreeBuilder < Psych::TreeBuilder
+ include Psych::JSON::YAMLEvents
+ end
+ end
+end
diff --git a/jni/ruby/ext/psych/lib/psych/json/yaml_events.rb b/jni/ruby/ext/psych/lib/psych/json/yaml_events.rb
new file mode 100644
index 0000000..d054d9b
--- /dev/null
+++ b/jni/ruby/ext/psych/lib/psych/json/yaml_events.rb
@@ -0,0 +1,29 @@
+module Psych
+ module JSON
+ module YAMLEvents # :nodoc:
+ def start_document version, tag_directives, implicit
+ super(version, tag_directives, !streaming?)
+ end
+
+ def end_document implicit_end = !streaming?
+ super(implicit_end)
+ end
+
+ def start_mapping anchor, tag, implicit, style
+ super(anchor, nil, true, Nodes::Mapping::FLOW)
+ end
+
+ def start_sequence anchor, tag, implicit, style
+ super(anchor, nil, true, Nodes::Sequence::FLOW)
+ end
+
+ def scalar value, anchor, tag, plain, quoted, style
+ if "tag:yaml.org,2002:null" == tag
+ super('null', nil, nil, true, false, Nodes::Scalar::PLAIN)
+ else
+ super
+ end
+ end
+ end
+ end
+end
diff --git a/jni/ruby/ext/psych/lib/psych/nodes.rb b/jni/ruby/ext/psych/lib/psych/nodes.rb
new file mode 100644
index 0000000..f3b33fe
--- /dev/null
+++ b/jni/ruby/ext/psych/lib/psych/nodes.rb
@@ -0,0 +1,77 @@
+require 'psych/nodes/node'
+require 'psych/nodes/stream'
+require 'psych/nodes/document'
+require 'psych/nodes/sequence'
+require 'psych/nodes/scalar'
+require 'psych/nodes/mapping'
+require 'psych/nodes/alias'
+
+module Psych
+ ###
+ # = Overview
+ #
+ # When using Psych.load to deserialize a YAML document, the document is
+ # translated to an intermediary AST. That intermediary AST is then
+ # translated in to a Ruby object graph.
+ #
+ # In the opposite direction, when using Psych.dump, the Ruby object graph is
+ # translated to an intermediary AST which is then converted to a YAML
+ # document.
+ #
+ # Psych::Nodes contains all of the classes that make up the nodes of a YAML
+ # AST. You can manually build an AST and use one of the visitors (see
+ # Psych::Visitors) to convert that AST to either a YAML document or to a
+ # Ruby object graph.
+ #
+ # Here is an example of building an AST that represents a list with one
+ # scalar:
+ #
+ # # Create our nodes
+ # stream = Psych::Nodes::Stream.new
+ # doc = Psych::Nodes::Document.new
+ # seq = Psych::Nodes::Sequence.new
+ # scalar = Psych::Nodes::Scalar.new('foo')
+ #
+ # # Build up our tree
+ # stream.children << doc
+ # doc.children << seq
+ # seq.children << scalar
+ #
+ # The stream is the root of the tree. We can then convert the tree to YAML:
+ #
+ # stream.to_yaml => "---\n- foo\n"
+ #
+ # Or convert it to Ruby:
+ #
+ # stream.to_ruby => [["foo"]]
+ #
+ # == YAML AST Requirements
+ #
+ # A valid YAML AST *must* have one Psych::Nodes::Stream at the root. A
+ # Psych::Nodes::Stream node must have 1 or more Psych::Nodes::Document nodes
+ # as children.
+ #
+ # Psych::Nodes::Document nodes must have one and *only* one child. That child
+ # may be one of:
+ #
+ # * Psych::Nodes::Sequence
+ # * Psych::Nodes::Mapping
+ # * Psych::Nodes::Scalar
+ #
+ # Psych::Nodes::Sequence and Psych::Nodes::Mapping nodes may have many
+ # children, but Psych::Nodes::Mapping nodes should have an even number of
+ # children.
+ #
+ # All of these are valid children for Psych::Nodes::Sequence and
+ # Psych::Nodes::Mapping nodes:
+ #
+ # * Psych::Nodes::Sequence
+ # * Psych::Nodes::Mapping
+ # * Psych::Nodes::Scalar
+ # * Psych::Nodes::Alias
+ #
+ # Psych::Nodes::Scalar and Psych::Nodes::Alias are both terminal nodes and
+ # should not have any children.
+ module Nodes
+ end
+end
diff --git a/jni/ruby/ext/psych/lib/psych/nodes/alias.rb b/jni/ruby/ext/psych/lib/psych/nodes/alias.rb
new file mode 100644
index 0000000..5bd4df1
--- /dev/null
+++ b/jni/ruby/ext/psych/lib/psych/nodes/alias.rb
@@ -0,0 +1,18 @@
+module Psych
+ module Nodes
+ ###
+ # This class represents a {YAML Alias}[http://yaml.org/spec/1.1/#alias].
+ # It points to an +anchor+.
+ #
+ # A Psych::Nodes::Alias is a terminal node and may have no children.
+ class Alias < Psych::Nodes::Node
+ # The anchor this alias links to
+ attr_accessor :anchor
+
+ # Create a new Alias that points to an +anchor+
+ def initialize anchor
+ @anchor = anchor
+ end
+ end
+ end
+end
diff --git a/jni/ruby/ext/psych/lib/psych/nodes/document.rb b/jni/ruby/ext/psych/lib/psych/nodes/document.rb
new file mode 100644
index 0000000..32014d6
--- /dev/null
+++ b/jni/ruby/ext/psych/lib/psych/nodes/document.rb
@@ -0,0 +1,60 @@
+module Psych
+ module Nodes
+ ###
+ # This represents a YAML Document. This node must be a child of
+ # Psych::Nodes::Stream. A Psych::Nodes::Document must have one child,
+ # and that child may be one of the following:
+ #
+ # * Psych::Nodes::Sequence
+ # * Psych::Nodes::Mapping
+ # * Psych::Nodes::Scalar
+ class Document < Psych::Nodes::Node
+ # The version of the YAML document
+ attr_accessor :version
+
+ # A list of tag directives for this document
+ attr_accessor :tag_directives
+
+ # Was this document implicitly created?
+ attr_accessor :implicit
+
+ # Is the end of the document implicit?
+ attr_accessor :implicit_end
+
+ ###
+ # Create a new Psych::Nodes::Document object.
+ #
+ # +version+ is a list indicating the YAML version.
+ # +tags_directives+ is a list of tag directive declarations
+ # +implicit+ is a flag indicating whether the document will be implicitly
+ # started.
+ #
+ # == Example:
+ # This creates a YAML document object that represents a YAML 1.1 document
+ # with one tag directive, and has an implicit start:
+ #
+ # Psych::Nodes::Document.new(
+ # [1,1],
+ # [["!", "tag:tenderlovemaking.com,2009:"]],
+ # true
+ # )
+ #
+ # == See Also
+ # See also Psych::Handler#start_document
+ def initialize version = [], tag_directives = [], implicit = false
+ super()
+ @version = version
+ @tag_directives = tag_directives
+ @implicit = implicit
+ @implicit_end = true
+ end
+
+ ###
+ # Returns the root node. A Document may only have one root node:
+ # http://yaml.org/spec/1.1/#id898031
+ def root
+ children.first
+ end
+ end
+ end
+end
diff --git a/jni/ruby/ext/psych/lib/psych/nodes/mapping.rb b/jni/ruby/ext/psych/lib/psych/nodes/mapping.rb
new file mode 100644
index 0000000..5ba95ce
--- /dev/null
+++ b/jni/ruby/ext/psych/lib/psych/nodes/mapping.rb
@@ -0,0 +1,56 @@
+module Psych
+ module Nodes
+ ###
+ # This class represents a {YAML Mapping}[http://yaml.org/spec/1.1/#mapping].
+ #
+ # A Psych::Nodes::Mapping node may have 0 or more children, but must have
+ # an even number of children. Here are the valid children a
+ # Psych::Nodes::Mapping node may have:
+ #
+ # * Psych::Nodes::Sequence
+ # * Psych::Nodes::Mapping
+ # * Psych::Nodes::Scalar
+ # * Psych::Nodes::Alias
+ class Mapping < Psych::Nodes::Node
+ # Any Map Style
+ ANY = 0
+
+ # Block Map Style
+ BLOCK = 1
+
+ # Flow Map Style
+ FLOW = 2
+
+ # The optional anchor for this mapping
+ attr_accessor :anchor
+
+ # The optional tag for this mapping
+ attr_accessor :tag
+
+ # Is this an implicit mapping?
+ attr_accessor :implicit
+
+ # The style of this mapping
+ attr_accessor :style
+
+ ###
+ # Create a new Psych::Nodes::Mapping object.
+ #
+ # +anchor+ is the anchor associated with the map or +nil+.
+ # +tag+ is the tag associated with the map or +nil+.
+ # +implicit+ is a boolean indicating whether or not the map was implicitly
+ # started.
+ # +style+ is an integer indicating the mapping style.
+ #
+ # == See Also
+ # See also Psych::Handler#start_mapping
+ def initialize anchor = nil, tag = nil, implicit = true, style = BLOCK
+ super()
+ @anchor = anchor
+ @tag = tag
+ @implicit = implicit
+ @style = style
+ end
+ end
+ end
+end
diff --git a/jni/ruby/ext/psych/lib/psych/nodes/node.rb b/jni/ruby/ext/psych/lib/psych/nodes/node.rb
new file mode 100644
index 0000000..83233a6
--- /dev/null
+++ b/jni/ruby/ext/psych/lib/psych/nodes/node.rb
@@ -0,0 +1,55 @@
+require 'stringio'
+require 'psych/class_loader'
+require 'psych/scalar_scanner'
+
+module Psych
+ module Nodes
+ ###
+ # The base class for any Node in a YAML parse tree. This class should
+ # never be instantiated.
+ class Node
+ include Enumerable
+
+ # The children of this node
+ attr_reader :children
+
+ # An associated tag
+ attr_reader :tag
+
+ # Create a new Psych::Nodes::Node
+ def initialize
+ @children = []
+ end
+
+ ###
+ # Iterate over each node in the tree. Yields each node to +block+ depth
+ # first.
+ def each &block
+ return enum_for :each unless block_given?
+ Visitors::DepthFirst.new(block).accept self
+ end
+
+ ###
+ # Convert this node to Ruby.
+ #
+ # See also Psych::Visitors::ToRuby
+ def to_ruby
+ Visitors::ToRuby.create.accept(self)
+ end
+ alias :transform :to_ruby
+
+ ###
+ # Convert this node to YAML.
+ #
+ # See also Psych::Visitors::Emitter
+ def yaml io = nil, options = {}
+ real_io = io || StringIO.new(''.encode('utf-8'))
+
+ Visitors::Emitter.new(real_io, options).accept self
+ return real_io.string unless io
+ io
+ end
+ alias :to_yaml :yaml
+ end
+ end
+end
diff --git a/jni/ruby/ext/psych/lib/psych/nodes/scalar.rb b/jni/ruby/ext/psych/lib/psych/nodes/scalar.rb
new file mode 100644
index 0000000..1b1b25b
--- /dev/null
+++ b/jni/ruby/ext/psych/lib/psych/nodes/scalar.rb
@@ -0,0 +1,67 @@
+module Psych
+ module Nodes
+ ###
+ # This class represents a {YAML Scalar}[http://yaml.org/spec/1.1/#id858081].
+ #
+ # This node type is a terminal node and should not have any children.
+ class Scalar < Psych::Nodes::Node
+ # Any style scalar, the emitter chooses
+ ANY = 0
+
+ # Plain scalar style
+ PLAIN = 1
+
+ # Single quoted style
+ SINGLE_QUOTED = 2
+
+ # Double quoted style
+ DOUBLE_QUOTED = 3
+
+ # Literal style
+ LITERAL = 4
+
+ # Folded style
+ FOLDED = 5
+
+ # The scalar value
+ attr_accessor :value
+
+ # The anchor value (if there is one)
+ attr_accessor :anchor
+
+ # The tag value (if there is one)
+ attr_accessor :tag
+
+ # Is this a plain scalar?
+ attr_accessor :plain
+
+ # Is this scalar quoted?
+ attr_accessor :quoted
+
+ # The style of this scalar
+ attr_accessor :style
+
+ ###
+ # Create a new Psych::Nodes::Scalar object.
+ #
+ # +value+ is the string value of the scalar
+ # +anchor+ is an associated anchor or nil
+ # +tag+ is an associated tag or nil
+ # +plain+ is a boolean value
+ # +quoted+ is a boolean value
+ # +style+ is an integer idicating the string style
+ #
+ # == See Also
+ #
+ # See also Psych::Handler#scalar
+ def initialize value, anchor = nil, tag = nil, plain = true, quoted = false, style = ANY
+ @value = value
+ @anchor = anchor
+ @tag = tag
+ @plain = plain
+ @quoted = quoted
+ @style = style
+ end
+ end
+ end
+end
diff --git a/jni/ruby/ext/psych/lib/psych/nodes/sequence.rb b/jni/ruby/ext/psych/lib/psych/nodes/sequence.rb
new file mode 100644
index 0000000..7e907fe
--- /dev/null
+++ b/jni/ruby/ext/psych/lib/psych/nodes/sequence.rb
@@ -0,0 +1,81 @@
+module Psych
+ module Nodes
+ ###
+ # This class represents a
+ # {YAML sequence}[http://yaml.org/spec/1.1/#sequence/syntax].
+ #
+ # A YAML sequence is basically a list, and looks like this:
+ #
+ # %YAML 1.1
+ # ---
+ # - I am
+ # - a Sequence
+ #
+ # A YAML sequence may have an anchor like this:
+ #
+ # %YAML 1.1
+ # ---
+ # &A [
+ # "This sequence",
+ # "has an anchor"
+ # ]
+ #
+ # A YAML sequence may also have a tag like this:
+ #
+ # %YAML 1.1
+ # ---
+ # !!seq [
+ # "This sequence",
+ # "has a tag"
+ # ]
+ #
+ # This class represents a sequence in a YAML document. A
+ # Psych::Nodes::Sequence node may have 0 or more children. Valid children
+ # for this node are:
+ #
+ # * Psych::Nodes::Sequence
+ # * Psych::Nodes::Mapping
+ # * Psych::Nodes::Scalar
+ # * Psych::Nodes::Alias
+ class Sequence < Psych::Nodes::Node
+ # Any Styles, emitter chooses
+ ANY = 0
+
+ # Block style sequence
+ BLOCK = 1
+
+ # Flow style sequence
+ FLOW = 2
+
+ # The anchor for this sequence (if any)
+ attr_accessor :anchor
+
+ # The tag name for this sequence (if any)
+ attr_accessor :tag
+
+ # Is this sequence started implicitly?
+ attr_accessor :implicit
+
+ # The sequence style used
+ attr_accessor :style
+
+ ###
+ # Create a new object representing a YAML sequence.
+ #
+ # +anchor+ is the anchor associated with the sequence or nil.
+ # +tag+ is the tag associated with the sequence or nil.
+ # +implicit+ a boolean indicating whether or not the sequence was
+ # implicitly started.
+ # +style+ is an integer indicating the list style.
+ #
+ # See Psych::Handler#start_sequence
+ def initialize anchor = nil, tag = nil, implicit = true, style = BLOCK
+ super()
+ @anchor = anchor
+ @tag = tag
+ @implicit = implicit
+ @style = style
+ end
+ end
+ end
+end
diff --git a/jni/ruby/ext/psych/lib/psych/nodes/stream.rb b/jni/ruby/ext/psych/lib/psych/nodes/stream.rb
new file mode 100644
index 0000000..7cf5e03
--- /dev/null
+++ b/jni/ruby/ext/psych/lib/psych/nodes/stream.rb
@@ -0,0 +1,37 @@
+module Psych
+ module Nodes
+ ###
+ # Represents a YAML stream. This is the root node for any YAML parse
+ # tree. This node must have one or more child nodes. The only valid
+ # child node for a Psych::Nodes::Stream node is Psych::Nodes::Document.
+ class Stream < Psych::Nodes::Node
+
+ # Encodings supported by Psych (and libyaml)
+
+ # Any encoding
+ ANY = Psych::Parser::ANY
+
+ # UTF-8 encoding
+ UTF8 = Psych::Parser::UTF8
+
+ # UTF-16LE encoding
+ UTF16LE = Psych::Parser::UTF16LE
+
+ # UTF-16BE encoding
+ UTF16BE = Psych::Parser::UTF16BE
+
+ # The encoding used for this stream
+ attr_accessor :encoding
+
+ ###
+ # Create a new Psych::Nodes::Stream node with an +encoding+ that
+ # defaults to Psych::Nodes::Stream::UTF8.
+ #
+ # See also Psych::Handler#start_stream
+ def initialize encoding = UTF8
+ super()
+ @encoding = encoding
+ end
+ end
+ end
+end
diff --git a/jni/ruby/ext/psych/lib/psych/omap.rb b/jni/ruby/ext/psych/lib/psych/omap.rb
new file mode 100644
index 0000000..6286270
--- /dev/null
+++ b/jni/ruby/ext/psych/lib/psych/omap.rb
@@ -0,0 +1,4 @@
+module Psych
+ class Omap < ::Hash
+ end
+end
diff --git a/jni/ruby/ext/psych/lib/psych/parser.rb b/jni/ruby/ext/psych/lib/psych/parser.rb
new file mode 100644
index 0000000..84085f1
--- /dev/null
+++ b/jni/ruby/ext/psych/lib/psych/parser.rb
@@ -0,0 +1,51 @@
+module Psych
+ ###
+ # YAML event parser class. This class parses a YAML document and calls
+ # events on the handler that is passed to the constructor. The events can
+ # be used for things such as constructing a YAML AST or deserializing YAML
+ # documents. It can even be fed back to Psych::Emitter to emit the same
+ # document that was parsed.
+ #
+ # See Psych::Handler for documentation on the events that Psych::Parser emits.
+ #
+ # Here is an example that prints out ever scalar found in a YAML document:
+ #
+ # # Handler for detecting scalar values
+ # class ScalarHandler < Psych::Handler
+ # def scalar value, anchor, tag, plain, quoted, style
+ # puts value
+ # end
+ # end
+ #
+ # parser = Psych::Parser.new(ScalarHandler.new)
+ # parser.parse(yaml_document)
+ #
+ # Here is an example that feeds the parser back in to Psych::Emitter. The
+ # YAML document is read from STDIN and written back out to STDERR:
+ #
+ # parser = Psych::Parser.new(Psych::Emitter.new($stderr))
+ # parser.parse($stdin)
+ #
+ # Psych uses Psych::Parser in combination with Psych::TreeBuilder to
+ # construct an AST of the parsed YAML document.
+
+ class Parser
+ class Mark < Struct.new(:index, :line, :column)
+ end
+
+ # The handler on which events will be called
+ attr_accessor :handler
+
+ # Set the encoding for this parser to +encoding+
+ attr_writer :external_encoding
+
+ ###
+ # Creates a new Psych::Parser instance with +handler+. YAML events will
+ # be called on +handler+. See Psych::Parser for more details.
+
+ def initialize handler = Handler.new
+ @handler = handler
+ @external_encoding = ANY
+ end
+ end
+end
diff --git a/jni/ruby/ext/psych/lib/psych/scalar_scanner.rb b/jni/ruby/ext/psych/lib/psych/scalar_scanner.rb
new file mode 100644
index 0000000..9300790
--- /dev/null
+++ b/jni/ruby/ext/psych/lib/psych/scalar_scanner.rb
@@ -0,0 +1,149 @@
+require 'strscan'
+
+module Psych
+ ###
+ # Scan scalars for built in types
+ class ScalarScanner
+ # Taken from http://yaml.org/type/timestamp.html
+ TIME = /^-?\d{4}-\d{1,2}-\d{1,2}(?:[Tt]|\s+)\d{1,2}:\d\d:\d\d(?:\.\d*)?(?:\s*(?:Z|[-+]\d{1,2}:?(?:\d\d)?))?$/
+
+ # Taken from http://yaml.org/type/float.html
+ FLOAT = /^(?:[-+]?([0-9][0-9_,]*)?\.[0-9]*([eE][-+][0-9]+)?(?# base 10)
+ |[-+]?[0-9][0-9_,]*(:[0-5]?[0-9])+\.[0-9_]*(?# base 60)
+ |[-+]?\.(inf|Inf|INF)(?# infinity)
+ |\.(nan|NaN|NAN)(?# not a number))$/x
+
+ # Taken from http://yaml.org/type/int.html
+ INTEGER = /^(?:[-+]?0b[0-1_]+ (?# base 2)
+ |[-+]?0[0-7_]+ (?# base 8)
+ |[-+]?(?:0|[1-9][0-9_]*) (?# base 10)
+ |[-+]?0x[0-9a-fA-F_]+ (?# base 16))$/x
+
+ attr_reader :class_loader
+
+ # Create a new scanner
+ def initialize class_loader
+ @string_cache = {}
+ @symbol_cache = {}
+ @class_loader = class_loader
+ end
+
+ # Tokenize +string+ returning the Ruby object
+ def tokenize string
+ return nil if string.empty?
+ return string if @string_cache.key?(string)
+ return @symbol_cache[string] if @symbol_cache.key?(string)
+
+ case string
+ # Check for a String type, being careful not to get caught by hash keys, hex values, and
+ # special floats (e.g., -.inf).
+ when /^[^\d\.:-]?[A-Za-z_\s!@#\$%\^&\*\(\)\{\}\<\>\|\/\\~;=]+/, /\n/
+ if string.length > 5
+ @string_cache[string] = true
+ return string
+ end
+
+ case string
+ when /^[^ytonf~]/i
+ @string_cache[string] = true
+ string
+ when '~', /^null$/i
+ nil
+ when /^(yes|true|on)$/i
+ true
+ when /^(no|false|off)$/i
+ false
+ else
+ @string_cache[string] = true
+ string
+ end
+ when TIME
+ begin
+ parse_time string
+ rescue ArgumentError
+ string
+ end
+ when /^\d{4}-(?:1[012]|0\d|\d)-(?:[12]\d|3[01]|0\d|\d)$/
+ require 'date'
+ begin
+ class_loader.date.strptime(string, '%Y-%m-%d')
+ rescue ArgumentError
+ string
+ end
+ when /^\.inf$/i
+ Float::INFINITY
+ when /^-\.inf$/i
+ -Float::INFINITY
+ when /^\.nan$/i
+ Float::NAN
+ when /^:./
+ if string =~ /^:(["'])(.*)\1/
+ @symbol_cache[string] = class_loader.symbolize($2.sub(/^:/, ''))
+ else
+ @symbol_cache[string] = class_loader.symbolize(string.sub(/^:/, ''))
+ end
+ when /^[-+]?[0-9][0-9_]*(:[0-5]?[0-9])+$/
+ i = 0
+ string.split(':').each_with_index do |n,e|
+ i += (n.to_i * 60 ** (e - 2).abs)
+ end
+ i
+ when /^[-+]?[0-9][0-9_]*(:[0-5]?[0-9])+\.[0-9_]*$/
+ i = 0
+ string.split(':').each_with_index do |n,e|
+ i += (n.to_f * 60 ** (e - 2).abs)
+ end
+ i
+ when FLOAT
+ if string =~ /\A[-+]?\.\Z/
+ @string_cache[string] = true
+ string
+ else
+ Float(string.gsub(/[,_]|\.$/, ''))
+ end
+ else
+ int = parse_int string.gsub(/[,_]/, '')
+ return int if int
+
+ @string_cache[string] = true
+ string
+ end
+ end
+
+ ###
+ # Parse and return an int from +string+
+ def parse_int string
+ return unless INTEGER === string
+ Integer(string)
+ end
+
+ ###
+ # Parse and return a Time from +string+
+ def parse_time string
+ klass = class_loader.load 'Time'
+
+ date, time = *(string.split(/[ tT]/, 2))
+ (yy, m, dd) = date.match(/^(-?\d{4})-(\d{1,2})-(\d{1,2})/).captures.map { |x| x.to_i }
+ md = time.match(/(\d+:\d+:\d+)(?:\.(\d*))?\s*(Z|[-+]\d+(:\d\d)?)?/)
+
+ (hh, mm, ss) = md[1].split(':').map { |x| x.to_i }
+ us = (md[2] ? Rational("0.#{md[2]}") : 0) * 1000000
+
+ time = klass.utc(yy, m, dd, hh, mm, ss, us)
+
+ return time if 'Z' == md[3]
+ return klass.at(time.to_i, us) unless md[3]
+
+ tz = md[3].match(/^([+\-]?\d{1,2})\:?(\d{1,2})?$/)[1..-1].compact.map { |digit| Integer(digit, 10) }
+ offset = tz.first * 3600
+
+ if offset < 0
+ offset -= ((tz[1] || 0) * 60)
+ else
+ offset += ((tz[1] || 0) * 60)
+ end
+
+ klass.at((time - offset).to_i, us)
+ end
+ end
+end
diff --git a/jni/ruby/ext/psych/lib/psych/set.rb b/jni/ruby/ext/psych/lib/psych/set.rb
new file mode 100644
index 0000000..6793a8e
--- /dev/null
+++ b/jni/ruby/ext/psych/lib/psych/set.rb
@@ -0,0 +1,4 @@
+module Psych
+ class Set < ::Hash
+ end
+end
diff --git a/jni/ruby/ext/psych/lib/psych/stream.rb b/jni/ruby/ext/psych/lib/psych/stream.rb
new file mode 100644
index 0000000..88c4c4c
--- /dev/null
+++ b/jni/ruby/ext/psych/lib/psych/stream.rb
@@ -0,0 +1,37 @@
+module Psych
+ ###
+ # Psych::Stream is a streaming YAML emitter. It will not buffer your YAML,
+ # but send it straight to an IO.
+ #
+ # Here is an example use:
+ #
+ # stream = Psych::Stream.new($stdout)
+ # stream.start
+ # stream.push({:foo => 'bar'})
+ # stream.finish
+ #
+ # YAML will be immediately emitted to $stdout with no buffering.
+ #
+ # Psych::Stream#start will take a block and ensure that Psych::Stream#finish
+ # is called, so you can do this form:
+ #
+ # stream = Psych::Stream.new($stdout)
+ # stream.start do |em|
+ # em.push(:foo => 'bar')
+ # end
+ #
+ class Stream < Psych::Visitors::YAMLTree
+ class Emitter < Psych::Emitter # :nodoc:
+ def end_document implicit_end = !streaming?
+ super
+ end
+
+ def streaming?
+ true
+ end
+ end
+
+ include Psych::Streaming
+ extend Psych::Streaming::ClassMethods
+ end
+end
diff --git a/jni/ruby/ext/psych/lib/psych/streaming.rb b/jni/ruby/ext/psych/lib/psych/streaming.rb
new file mode 100644
index 0000000..9d94eb5
--- /dev/null
+++ b/jni/ruby/ext/psych/lib/psych/streaming.rb
@@ -0,0 +1,27 @@
+module Psych
+ module Streaming
+ module ClassMethods
+ ###
+ # Create a new streaming emitter. Emitter will print to +io+. See
+ # Psych::Stream for an example.
+ def new io
+ emitter = const_get(:Emitter).new(io)
+ class_loader = ClassLoader.new
+ ss = ScalarScanner.new class_loader
+ super(emitter, ss, {})
+ end
+ end
+
+ ###
+ # Start streaming using +encoding+
+ def start encoding = Nodes::Stream::UTF8
+ super.tap { yield self if block_given? }
+ ensure
+ finish if block_given?
+ end
+
+ private
+ def register target, obj
+ end
+ end
+end
diff --git a/jni/ruby/ext/psych/lib/psych/syntax_error.rb b/jni/ruby/ext/psych/lib/psych/syntax_error.rb
new file mode 100644
index 0000000..e200ef0
--- /dev/null
+++ b/jni/ruby/ext/psych/lib/psych/syntax_error.rb
@@ -0,0 +1,21 @@
+require 'psych/exception'
+
+module Psych
+ class SyntaxError < Psych::Exception
+ attr_reader :file, :line, :column, :offset, :problem, :context
+
+ def initialize file, line, col, offset, problem, context
+ err = [problem, context].compact.join ' '
+ filename = file || '<unknown>'
+ message = "(%s): %s at line %d column %d" % [filename, err, line, col]
+
+ @file = file
+ @line = line
+ @column = col
+ @offset = offset
+ @problem = problem
+ @context = context
+ super(message)
+ end
+ end
+end
diff --git a/jni/ruby/ext/psych/lib/psych/tree_builder.rb b/jni/ruby/ext/psych/lib/psych/tree_builder.rb
new file mode 100644
index 0000000..c8f3447
--- /dev/null
+++ b/jni/ruby/ext/psych/lib/psych/tree_builder.rb
@@ -0,0 +1,96 @@
+require 'psych/handler'
+
+module Psych
+ ###
+ # This class works in conjunction with Psych::Parser to build an in-memory
+ # parse tree that represents a YAML document.
+ #
+ # == Example
+ #
+ # parser = Psych::Parser.new Psych::TreeBuilder.new
+ # parser.parse('--- foo')
+ # tree = parser.handler.root
+ #
+ # See Psych::Handler for documentation on the event methods used in this
+ # class.
+ class TreeBuilder < Psych::Handler
+ # Returns the root node for the built tree
+ attr_reader :root
+
+ # Create a new TreeBuilder instance
+ def initialize
+ @stack = []
+ @last = nil
+ @root = nil
+ end
+
+ %w{
+ Sequence
+ Mapping
+ }.each do |node|
+ class_eval %{
+ def start_#{node.downcase}(anchor, tag, implicit, style)
+ n = Nodes::#{node}.new(anchor, tag, implicit, style)
+ @last.children << n
+ push n
+ end
+
+ def end_#{node.downcase}
+ pop
+ end
+ }
+ end
+
+ ###
+ # Handles start_document events with +version+, +tag_directives+,
+ # and +implicit+ styling.
+ #
+ # See Psych::Handler#start_document
+ def start_document version, tag_directives, implicit
+ n = Nodes::Document.new version, tag_directives, implicit
+ @last.children << n
+ push n
+ end
+
+ ###
+ # Handles end_document events with +version+, +tag_directives+,
+ # and +implicit+ styling.
+ #
+ # See Psych::Handler#start_document
+ def end_document implicit_end = !streaming?
+ @last.implicit_end = implicit_end
+ pop
+ end
+
+ def start_stream encoding
+ @root = Nodes::Stream.new(encoding)
+ push @root
+ end
+
+ def end_stream
+ pop
+ end
+
+ def scalar value, anchor, tag, plain, quoted, style
+ s = Nodes::Scalar.new(value,anchor,tag,plain,quoted,style)
+ @last.children << s
+ s
+ end
+
+ def alias anchor
+ @last.children << Nodes::Alias.new(anchor)
+ end
+
+ private
+ def push value
+ @stack.push value
+ @last = value
+ end
+
+ def pop
+ x = @stack.pop
+ @last = @stack.last
+ x
+ end
+ end
+end
diff --git a/jni/ruby/ext/psych/lib/psych/visitors.rb b/jni/ruby/ext/psych/lib/psych/visitors.rb
new file mode 100644
index 0000000..cc98b10
--- /dev/null
+++ b/jni/ruby/ext/psych/lib/psych/visitors.rb
@@ -0,0 +1,6 @@
+require 'psych/visitors/visitor'
+require 'psych/visitors/to_ruby'
+require 'psych/visitors/emitter'
+require 'psych/visitors/yaml_tree'
+require 'psych/visitors/json_tree'
+require 'psych/visitors/depth_first'
diff --git a/jni/ruby/ext/psych/lib/psych/visitors/depth_first.rb b/jni/ruby/ext/psych/lib/psych/visitors/depth_first.rb
new file mode 100644
index 0000000..c6eb814
--- /dev/null
+++ b/jni/ruby/ext/psych/lib/psych/visitors/depth_first.rb
@@ -0,0 +1,26 @@
+module Psych
+ module Visitors
+ class DepthFirst < Psych::Visitors::Visitor
+ def initialize block
+ @block = block
+ end
+
+ private
+
+ def nary o
+ o.children.each { |x| visit x }
+ @block.call o
+ end
+ alias :visit_Psych_Nodes_Stream :nary
+ alias :visit_Psych_Nodes_Document :nary
+ alias :visit_Psych_Nodes_Sequence :nary
+ alias :visit_Psych_Nodes_Mapping :nary
+
+ def terminal o
+ @block.call o
+ end
+ alias :visit_Psych_Nodes_Scalar :terminal
+ alias :visit_Psych_Nodes_Alias :terminal
+ end
+ end
+end
diff --git a/jni/ruby/ext/psych/lib/psych/visitors/emitter.rb b/jni/ruby/ext/psych/lib/psych/visitors/emitter.rb
new file mode 100644
index 0000000..c886e50
--- /dev/null
+++ b/jni/ruby/ext/psych/lib/psych/visitors/emitter.rb
@@ -0,0 +1,51 @@
+module Psych
+ module Visitors
+ class Emitter < Psych::Visitors::Visitor
+ def initialize io, options = {}
+ opts = [:indentation, :canonical, :line_width].find_all { |opt|
+ options.key?(opt)
+ }
+
+ if opts.empty?
+ @handler = Psych::Emitter.new io
+ else
+ du = Handler::DumperOptions.new
+ opts.each { |option| du.send :"#{option}=", options[option] }
+ @handler = Psych::Emitter.new io, du
+ end
+ end
+
+ def visit_Psych_Nodes_Stream o
+ @handler.start_stream o.encoding
+ o.children.each { |c| accept c }
+ @handler.end_stream
+ end
+
+ def visit_Psych_Nodes_Document o
+ @handler.start_document o.version, o.tag_directives, o.implicit
+ o.children.each { |c| accept c }
+ @handler.end_document o.implicit_end
+ end
+
+ def visit_Psych_Nodes_Scalar o
+ @handler.scalar o.value, o.anchor, o.tag, o.plain, o.quoted, o.style
+ end
+
+ def visit_Psych_Nodes_Sequence o
+ @handler.start_sequence o.anchor, o.tag, o.implicit, o.style
+ o.children.each { |c| accept c }
+ @handler.end_sequence
+ end
+
+ def visit_Psych_Nodes_Mapping o
+ @handler.start_mapping o.anchor, o.tag, o.implicit, o.style
+ o.children.each { |c| accept c }
+ @handler.end_mapping
+ end
+
+ def visit_Psych_Nodes_Alias o
+ @handler.alias o.anchor
+ end
+ end
+ end
+end
diff --git a/jni/ruby/ext/psych/lib/psych/visitors/json_tree.rb b/jni/ruby/ext/psych/lib/psych/visitors/json_tree.rb
new file mode 100644
index 0000000..0127ac8
--- /dev/null
+++ b/jni/ruby/ext/psych/lib/psych/visitors/json_tree.rb
@@ -0,0 +1,24 @@
+require 'psych/json/ruby_events'
+
+module Psych
+ module Visitors
+ class JSONTree < YAMLTree
+ include Psych::JSON::RubyEvents
+
+ def self.create options = {}
+ emitter = Psych::JSON::TreeBuilder.new
+ class_loader = ClassLoader.new
+ ss = ScalarScanner.new class_loader
+ new(emitter, ss, options)
+ end
+
+ def accept target
+ if target.respond_to?(:encode_with)
+ dump_coder target
+ else
+ send(@dispatch_cache[target.class], target)
+ end
+ end
+ end
+ end
+end
diff --git a/jni/ruby/ext/psych/lib/psych/visitors/to_ruby.rb b/jni/ruby/ext/psych/lib/psych/visitors/to_ruby.rb
new file mode 100644
index 0000000..e696ebd
--- /dev/null
+++ b/jni/ruby/ext/psych/lib/psych/visitors/to_ruby.rb
@@ -0,0 +1,389 @@
+require 'psych/scalar_scanner'
+require 'psych/class_loader'
+require 'psych/exception'
+
+unless defined?(Regexp::NOENCODING)
+ Regexp::NOENCODING = 32
+end
+
+module Psych
+ module Visitors
+ ###
+ # This class walks a YAML AST, converting each node to Ruby
+ class ToRuby < Psych::Visitors::Visitor
+ def self.create
+ class_loader = ClassLoader.new
+ scanner = ScalarScanner.new class_loader
+ new(scanner, class_loader)
+ end
+
+ attr_reader :class_loader
+
+ def initialize ss, class_loader
+ super()
+ @st = {}
+ @ss = ss
+ @domain_types = Psych.domain_types
+ @class_loader = class_loader
+ end
+
+ def accept target
+ result = super
+ return result if @domain_types.empty? || !target.tag
+
+ key = target.tag.sub(/^[!\/]*/, '').sub(/(,\d+)\//, '\1:')
+ key = "tag:#{key}" unless key =~ /^(tag:|x-private)/
+
+ if @domain_types.key? key
+ value, block = @domain_types[key]
+ return block.call value, result
+ end
+
+ result
+ end
+
+ def deserialize o
+ if klass = resolve_class(Psych.load_tags[o.tag])
+ instance = klass.allocate
+
+ if instance.respond_to?(:init_with)
+ coder = Psych::Coder.new(o.tag)
+ coder.scalar = o.value
+ instance.init_with coder
+ end
+
+ return instance
+ end
+
+ return o.value if o.quoted
+ return @ss.tokenize(o.value) unless o.tag
+
+ case o.tag
+ when '!binary', 'tag:yaml.org,2002:binary'
+ o.value.unpack('m').first
+ when /^!(?:str|ruby\/string)(?::(.*))?/, 'tag:yaml.org,2002:str'
+ klass = resolve_class($1)
+ if klass
+ klass.allocate.replace o.value
+ else
+ o.value
+ end
+ when '!ruby/object:BigDecimal'
+ require 'bigdecimal'
+ class_loader.big_decimal._load o.value
+ when "!ruby/object:DateTime"
+ class_loader.date_time
+ require 'date'
+ @ss.parse_time(o.value).to_datetime
+ when '!ruby/encoding'
+ ::Encoding.find o.value
+ when "!ruby/object:Complex"
+ class_loader.complex
+ Complex(o.value)
+ when "!ruby/object:Rational"
+ class_loader.rational
+ Rational(o.value)
+ when "!ruby/class", "!ruby/module"
+ resolve_class o.value
+ when "tag:yaml.org,2002:float", "!float"
+ Float(@ss.tokenize(o.value))
+ when "!ruby/regexp"
+ klass = class_loader.regexp
+ o.value =~ /^\/(.*)\/([mixn]*)$/
+ source = $1
+ options = 0
+ lang = nil
+ ($2 || '').split('').each do |option|
+ case option
+ when 'x' then options |= Regexp::EXTENDED
+ when 'i' then options |= Regexp::IGNORECASE
+ when 'm' then options |= Regexp::MULTILINE
+ when 'n' then options |= Regexp::NOENCODING
+ else lang = option
+ end
+ end
+ klass.new(*[source, options, lang].compact)
+ when "!ruby/range"
+ klass = class_loader.range
+ args = o.value.split(/([.]{2,3})/, 2).map { |s|
+ accept Nodes::Scalar.new(s)
+ }
+ args.push(args.delete_at(1) == '...')
+ klass.new(*args)
+ when /^!ruby\/sym(bol)?:?(.*)?$/
+ class_loader.symbolize o.value
+ else
+ @ss.tokenize o.value
+ end
+ end
+ private :deserialize
+
+ def visit_Psych_Nodes_Scalar o
+ register o, deserialize(o)
+ end
+
+ def visit_Psych_Nodes_Sequence o
+ if klass = resolve_class(Psych.load_tags[o.tag])
+ instance = klass.allocate
+
+ if instance.respond_to?(:init_with)
+ coder = Psych::Coder.new(o.tag)
+ coder.seq = o.children.map { |c| accept c }
+ instance.init_with coder
+ end
+
+ return instance
+ end
+
+ case o.tag
+ when nil
+ register_empty(o)
+ when '!omap', 'tag:yaml.org,2002:omap'
+ map = register(o, Psych::Omap.new)
+ o.children.each { |a|
+ map[accept(a.children.first)] = accept a.children.last
+ }
+ map
+ when /^!(?:seq|ruby\/array):(.*)$/
+ klass = resolve_class($1)
+ list = register(o, klass.allocate)
+ o.children.each { |c| list.push accept c }
+ list
+ else
+ register_empty(o)
+ end
+ end
+
+ def visit_Psych_Nodes_Mapping o
+ if Psych.load_tags[o.tag]
+ return revive(resolve_class(Psych.load_tags[o.tag]), o)
+ end
+ return revive_hash(register(o, {}), o) unless o.tag
+
+ case o.tag
+ when /^!ruby\/struct:?(.*)?$/
+ klass = resolve_class($1) if $1
+
+ if klass
+ s = register(o, klass.allocate)
+
+ members = {}
+ struct_members = s.members.map { |x| class_loader.symbolize x }
+ o.children.each_slice(2) do |k,v|
+ member = accept(k)
+ value = accept(v)
+ if struct_members.include?(class_loader.symbolize(member))
+ s.send("#{member}=", value)
+ else
+ members[member.to_s.sub(/^@/, '')] = value
+ end
+ end
+ init_with(s, members, o)
+ else
+ klass = class_loader.struct
+ members = o.children.map { |c| accept c }
+ h = Hash[*members]
+ s = klass.new(*h.map { |k,v|
+ class_loader.symbolize k
+ }).new(*h.map { |k,v| v })
+ register(o, s)
+ s
+ end
+
+ when /^!ruby\/object:?(.*)?$/
+ name = $1 || 'Object'
+
+ if name == 'Complex'
+ class_loader.complex
+ h = Hash[*o.children.map { |c| accept c }]
+ register o, Complex(h['real'], h['image'])
+ elsif name == 'Rational'
+ class_loader.rational
+ h = Hash[*o.children.map { |c| accept c }]
+ register o, Rational(h['numerator'], h['denominator'])
+ elsif name == 'Hash'
+ revive_hash(register(o, {}), o)
+ else
+ obj = revive((resolve_class(name) || class_loader.object), o)
+ obj
+ end
+
+ when /^!(?:str|ruby\/string)(?::(.*))?/, 'tag:yaml.org,2002:str'
+ klass = resolve_class($1)
+ members = {}
+ string = nil
+
+ o.children.each_slice(2) do |k,v|
+ key = accept k
+ value = accept v
+
+ if key == 'str'
+ if klass
+ string = klass.allocate.replace value
+ else
+ string = value
+ end
+ register(o, string)
+ else
+ members[key] = value
+ end
+ end
+ init_with(string, members.map { |k,v| [k.to_s.sub(/^@/, ''),v] }, o)
+ when /^!ruby\/array:(.*)$/
+ klass = resolve_class($1)
+ list = register(o, klass.allocate)
+
+ members = Hash[o.children.map { |c| accept c }.each_slice(2).to_a]
+ list.replace members['internal']
+
+ members['ivars'].each do |ivar, v|
+ list.instance_variable_set ivar, v
+ end
+ list
+
+ when '!ruby/range'
+ klass = class_loader.range
+ h = Hash[*o.children.map { |c| accept c }]
+ register o, klass.new(h['begin'], h['end'], h['excl'])
+
+ when /^!ruby\/exception:?(.*)?$/
+ h = Hash[*o.children.map { |c| accept c }]
+
+ e = build_exception((resolve_class($1) || class_loader.exception),
+ h.delete('message'))
+ init_with(e, h, o)
+
+ when '!set', 'tag:yaml.org,2002:set'
+ set = class_loader.psych_set.new
+ @st[o.anchor] = set if o.anchor
+ o.children.each_slice(2) do |k,v|
+ set[accept(k)] = accept(v)
+ end
+ set
+
+ when /^!map:(.*)$/, /^!ruby\/hash:(.*)$/
+ revive_hash register(o, resolve_class($1).new), o
+
+ when '!omap', 'tag:yaml.org,2002:omap'
+ map = register(o, class_loader.psych_omap.new)
+ o.children.each_slice(2) do |l,r|
+ map[accept(l)] = accept r
+ end
+ map
+
+ when /^!ruby\/marshalable:(.*)$/
+ name = $1
+ klass = resolve_class(name)
+ obj = register(o, klass.allocate)
+
+ if obj.respond_to?(:init_with)
+ init_with(obj, revive_hash({}, o), o)
+ elsif obj.respond_to?(:marshal_load)
+ marshal_data = o.children.map(&method(:accept))
+ obj.marshal_load(marshal_data)
+ obj
+ else
+ raise ArgumentError, "Cannot deserialize #{name}"
+ end
+
+ else
+ revive_hash(register(o, {}), o)
+ end
+ end
+
+ def visit_Psych_Nodes_Document o
+ accept o.root
+ end
+
+ def visit_Psych_Nodes_Stream o
+ o.children.map { |c| accept c }
+ end
+
+ def visit_Psych_Nodes_Alias o
+ @st.fetch(o.anchor) { raise BadAlias, "Unknown alias: #{o.anchor}" }
+ end
+
+ private
+ def register node, object
+ @st[node.anchor] = object if node.anchor
+ object
+ end
+
+ def register_empty object
+ list = register(object, [])
+ object.children.each { |c| list.push accept c }
+ list
+ end
+
+ def revive_hash hash, o
+ o.children.each_slice(2) { |k,v|
+ key = accept(k)
+ val = accept(v)
+
+ if key == '<<' && k.tag != "tag:yaml.org,2002:str"
+ case v
+ when Nodes::Alias, Nodes::Mapping
+ begin
+ hash.merge! val
+ rescue TypeError
+ hash[key] = val
+ end
+ when Nodes::Sequence
+ begin
+ h = {}
+ val.reverse_each do |value|
+ h.merge! value
+ end
+ hash.merge! h
+ rescue TypeError
+ hash[key] = val
+ end
+ else
+ hash[key] = val
+ end
+ else
+ hash[key] = val
+ end
+
+ }
+ hash
+ end
+
+ def merge_key hash, key, val
+ end
+
+ def revive klass, node
+ s = register(node, klass.allocate)
+ init_with(s, revive_hash({}, node), node)
+ end
+
+ def init_with o, h, node
+ c = Psych::Coder.new(node.tag)
+ c.map = h
+
+ if o.respond_to?(:init_with)
+ o.init_with c
+ elsif o.respond_to?(:yaml_initialize)
+ if $VERBOSE
+ warn "Implementing #{o.class}#yaml_initialize is deprecated, please implement \"init_with(coder)\""
+ end
+ o.yaml_initialize c.tag, c.map
+ else
+ h.each { |k,v| o.instance_variable_set(:"@#{k}", v) }
+ end
+ o
+ end
+
+ # Convert +klassname+ to a Class
+ def resolve_class klassname
+ class_loader.load klassname
+ end
+ end
+
+ class NoAliasRuby < ToRuby
+ def visit_Psych_Nodes_Alias o
+ raise BadAlias, "Unknown alias: #{o.anchor}"
+ end
+ end
+ end
+end
diff --git a/jni/ruby/ext/psych/lib/psych/visitors/visitor.rb b/jni/ruby/ext/psych/lib/psych/visitors/visitor.rb
new file mode 100644
index 0000000..4d7772f
--- /dev/null
+++ b/jni/ruby/ext/psych/lib/psych/visitors/visitor.rb
@@ -0,0 +1,19 @@
+module Psych
+ module Visitors
+ class Visitor
+ def accept target
+ visit target
+ end
+
+ private
+
+ DISPATCH = Hash.new do |hash, klass|
+ hash[klass] = "visit_#{klass.name.gsub('::', '_')}"
+ end
+
+ def visit target
+ send DISPATCH[target.class], target
+ end
+ end
+ end
+end
diff --git a/jni/ruby/ext/psych/lib/psych/visitors/yaml_tree.rb b/jni/ruby/ext/psych/lib/psych/visitors/yaml_tree.rb
new file mode 100644
index 0000000..989e1f0
--- /dev/null
+++ b/jni/ruby/ext/psych/lib/psych/visitors/yaml_tree.rb
@@ -0,0 +1,565 @@
+require 'psych/tree_builder'
+require 'psych/scalar_scanner'
+require 'psych/class_loader'
+
+module Psych
+ module Visitors
+ ###
+ # YAMLTree builds a YAML ast given a Ruby object. For example:
+ #
+ # builder = Psych::Visitors::YAMLTree.new
+ # builder << { :foo => 'bar' }
+ # builder.tree # => #<Psych::Nodes::Stream .. }
+ #
+ class YAMLTree < Psych::Visitors::Visitor
+ class Registrar # :nodoc:
+ def initialize
+ @obj_to_id = {}
+ @obj_to_node = {}
+ @targets = []
+ @counter = 0
+ end
+
+ def register target, node
+ @targets << target
+ @obj_to_node[target.object_id] = node
+ end
+
+ def key? target
+ @obj_to_node.key? target.object_id
+ rescue NoMethodError
+ false
+ end
+
+ def id_for target
+ @obj_to_id[target.object_id] ||= (@counter += 1)
+ end
+
+ def node_for target
+ @obj_to_node[target.object_id]
+ end
+ end
+
+ attr_reader :started, :finished
+ alias :finished? :finished
+ alias :started? :started
+
+ def self.create options = {}, emitter = nil
+ emitter ||= TreeBuilder.new
+ class_loader = ClassLoader.new
+ ss = ScalarScanner.new class_loader
+ new(emitter, ss, options)
+ end
+
+ def self.new emitter = nil, ss = nil, options = nil
+ return super if emitter && ss && options
+
+ if $VERBOSE
+ warn "This API is deprecated, please pass an emitter, scalar scanner, and options or call #{self}.create() (#{caller.first})"
+ end
+ create emitter, ss
+ end
+
+ def initialize emitter, ss, options
+ super()
+ @started = false
+ @finished = false
+ @emitter = emitter
+ @st = Registrar.new
+ @ss = ss
+ @options = options
+ @coders = []
+
+ @dispatch_cache = Hash.new do |h,klass|
+ method = "visit_#{(klass.name || '').split('::').join('_')}"
+
+ method = respond_to?(method) ? method : h[klass.superclass]
+
+ raise(TypeError, "Can't dump #{target.class}") unless method
+
+ h[klass] = method
+ end
+ end
+
+ def start encoding = Nodes::Stream::UTF8
+ @emitter.start_stream(encoding).tap do
+ @started = true
+ end
+ end
+
+ def finish
+ @emitter.end_stream.tap do
+ @finished = true
+ end
+ end
+
+ def tree
+ finish unless finished?
+ @emitter.root
+ end
+
+ def push object
+ start unless started?
+ version = []
+ version = [1,1] if @options[:header]
+
+ case @options[:version]
+ when Array
+ version = @options[:version]
+ when String
+ version = @options[:version].split('.').map { |x| x.to_i }
+ else
+ version = [1,1]
+ end if @options.key? :version
+
+ @emitter.start_document version, [], false
+ accept object
+ @emitter.end_document !@emitter.streaming?
+ end
+ alias :<< :push
+
+ def accept target
+ # return any aliases we find
+ if @st.key? target
+ oid = @st.id_for target
+ node = @st.node_for target
+ anchor = oid.to_s
+ node.anchor = anchor
+ return @emitter.alias anchor
+ end
+
+ if target.respond_to?(:to_yaml)
+ begin
+ loc = target.method(:to_yaml).source_location.first
+ if loc !~ /(syck\/rubytypes.rb|psych\/core_ext.rb)/
+ unless target.respond_to?(:encode_with)
+ if $VERBOSE
+ warn "implementing to_yaml is deprecated, please implement \"encode_with\""
+ end
+
+ target.to_yaml(:nodump => true)
+ end
+ end
+ rescue
+ # public_method or source_location might be overridden,
+ # and it's OK to skip it since it's only to emit a warning
+ end
+ end
+
+ if target.respond_to?(:encode_with)
+ dump_coder target
+ else
+ send(@dispatch_cache[target.class], target)
+ end
+ end
+
+ def visit_Psych_Omap o
+ seq = @emitter.start_sequence(nil, '!omap', false, Nodes::Sequence::BLOCK)
+ register(o, seq)
+
+ o.each { |k,v| visit_Hash k => v }
+ @emitter.end_sequence
+ end
+
+ def visit_Encoding o
+ tag = "!ruby/encoding"
+ @emitter.scalar o.name, nil, tag, false, false, Nodes::Scalar::ANY
+ end
+
+ def visit_Object o
+ tag = Psych.dump_tags[o.class]
+ unless tag
+ klass = o.class == Object ? nil : o.class.name
+ tag = ['!ruby/object', klass].compact.join(':')
+ end
+
+ map = @emitter.start_mapping(nil, tag, false, Nodes::Mapping::BLOCK)
+ register(o, map)
+
+ dump_ivars o
+ @emitter.end_mapping
+ end
+
+ def visit_Struct o
+ tag = ['!ruby/struct', o.class.name].compact.join(':')
+
+ register o, @emitter.start_mapping(nil, tag, false, Nodes::Mapping::BLOCK)
+ o.members.each do |member|
+ @emitter.scalar member.to_s, nil, nil, true, false, Nodes::Scalar::ANY
+ accept o[member]
+ end
+
+ dump_ivars o
+
+ @emitter.end_mapping
+ end
+
+ def visit_Exception o
+ tag = ['!ruby/exception', o.class.name].join ':'
+
+ @emitter.start_mapping nil, tag, false, Nodes::Mapping::BLOCK
+
+ {
+ 'message' => private_iv_get(o, 'mesg'),
+ 'backtrace' => private_iv_get(o, 'backtrace'),
+ }.each do |k,v|
+ next unless v
+ @emitter.scalar k, nil, nil, true, false, Nodes::Scalar::ANY
+ accept v
+ end
+
+ dump_ivars o
+
+ @emitter.end_mapping
+ end
+
+ def visit_NameError o
+ tag = ['!ruby/exception', o.class.name].join ':'
+
+ @emitter.start_mapping nil, tag, false, Nodes::Mapping::BLOCK
+
+ {
+ 'message' => o.message.to_s,
+ 'backtrace' => private_iv_get(o, 'backtrace'),
+ }.each do |k,v|
+ next unless v
+ @emitter.scalar k, nil, nil, true, false, Nodes::Scalar::ANY
+ accept v
+ end
+
+ dump_ivars o
+
+ @emitter.end_mapping
+ end
+
+ def visit_Regexp o
+ register o, @emitter.scalar(o.inspect, nil, '!ruby/regexp', false, false, Nodes::Scalar::ANY)
+ end
+
+ def visit_DateTime o
+ formatted = if o.offset.zero?
+ o.strftime("%Y-%m-%d %H:%M:%S.%9N Z".freeze)
+ else
+ o.strftime("%Y-%m-%d %H:%M:%S.%9N %:z".freeze)
+ end
+ tag = '!ruby/object:DateTime'
+ register o, @emitter.scalar(formatted, nil, tag, false, false, Nodes::Scalar::ANY)
+ end
+
+ def visit_Time o
+ formatted = format_time o
+ register o, @emitter.scalar(formatted, nil, nil, true, false, Nodes::Scalar::ANY)
+ end
+
+ def visit_Rational o
+ register o, @emitter.start_mapping(nil, '!ruby/object:Rational', false, Nodes::Mapping::BLOCK)
+
+ [
+ 'denominator', o.denominator.to_s,
+ 'numerator', o.numerator.to_s
+ ].each do |m|
+ @emitter.scalar m, nil, nil, true, false, Nodes::Scalar::ANY
+ end
+
+ @emitter.end_mapping
+ end
+
+ def visit_Complex o
+ register o, @emitter.start_mapping(nil, '!ruby/object:Complex', false, Nodes::Mapping::BLOCK)
+
+ ['real', o.real.to_s, 'image', o.imag.to_s].each do |m|
+ @emitter.scalar m, nil, nil, true, false, Nodes::Scalar::ANY
+ end
+
+ @emitter.end_mapping
+ end
+
+ def visit_Integer o
+ @emitter.scalar o.to_s, nil, nil, true, false, Nodes::Scalar::ANY
+ end
+ alias :visit_TrueClass :visit_Integer
+ alias :visit_FalseClass :visit_Integer
+ alias :visit_Date :visit_Integer
+
+ def visit_Float o
+ if o.nan?
+ @emitter.scalar '.nan', nil, nil, true, false, Nodes::Scalar::ANY
+ elsif o.infinite?
+ @emitter.scalar((o.infinite? > 0 ? '.inf' : '-.inf'),
+ nil, nil, true, false, Nodes::Scalar::ANY)
+ else
+ @emitter.scalar o.to_s, nil, nil, true, false, Nodes::Scalar::ANY
+ end
+ end
+
+ def visit_BigDecimal o
+ @emitter.scalar o._dump, nil, '!ruby/object:BigDecimal', false, false, Nodes::Scalar::ANY
+ end
+
+ def visit_String o
+ plain = true
+ quote = true
+ style = Nodes::Scalar::PLAIN
+ tag = nil
+ str = o
+
+ if binary?(o)
+ str = [o].pack('m').chomp
+ tag = '!binary' # FIXME: change to below when syck is removed
+ #tag = 'tag:yaml.org,2002:binary'
+ style = Nodes::Scalar::LITERAL
+ plain = false
+ quote = false
+ elsif o =~ /\n/
+ style = Nodes::Scalar::LITERAL
+ elsif o == '<<'
+ style = Nodes::Scalar::SINGLE_QUOTED
+ tag = 'tag:yaml.org,2002:str'
+ plain = false
+ quote = false
+ elsif o =~ /^\W[^"]*$/
+ style = Nodes::Scalar::DOUBLE_QUOTED
+ else
+ unless String === @ss.tokenize(o)
+ style = Nodes::Scalar::SINGLE_QUOTED
+ end
+ end
+
+ ivars = find_ivars o
+
+ if ivars.empty?
+ unless o.class == ::String
+ tag = "!ruby/string:#{o.class}"
+ plain = false
+ quote = false
+ end
+ @emitter.scalar str, nil, tag, plain, quote, style
+ else
+ maptag = '!ruby/string'
+ maptag << ":#{o.class}" unless o.class == ::String
+
+ register o, @emitter.start_mapping(nil, maptag, false, Nodes::Mapping::BLOCK)
+ @emitter.scalar 'str', nil, nil, true, false, Nodes::Scalar::ANY
+ @emitter.scalar str, nil, tag, plain, quote, style
+
+ dump_ivars o
+
+ @emitter.end_mapping
+ end
+ end
+
+ def visit_Module o
+ raise TypeError, "can't dump anonymous module: #{o}" unless o.name
+ register o, @emitter.scalar(o.name, nil, '!ruby/module', false, false, Nodes::Scalar::SINGLE_QUOTED)
+ end
+
+ def visit_Class o
+ raise TypeError, "can't dump anonymous class: #{o}" unless o.name
+ register o, @emitter.scalar(o.name, nil, '!ruby/class', false, false, Nodes::Scalar::SINGLE_QUOTED)
+ end
+
+ def visit_Range o
+ register o, @emitter.start_mapping(nil, '!ruby/range', false, Nodes::Mapping::BLOCK)
+ ['begin', o.begin, 'end', o.end, 'excl', o.exclude_end?].each do |m|
+ accept m
+ end
+ @emitter.end_mapping
+ end
+
+ def visit_Hash o
+ tag = o.class == ::Hash ? nil : "!ruby/hash:#{o.class}"
+ implicit = !tag
+
+ register(o, @emitter.start_mapping(nil, tag, implicit, Psych::Nodes::Mapping::BLOCK))
+
+ o.each do |k,v|
+ accept k
+ accept v
+ end
+
+ @emitter.end_mapping
+ end
+
+ def visit_Psych_Set o
+ register(o, @emitter.start_mapping(nil, '!set', false, Psych::Nodes::Mapping::BLOCK))
+
+ o.each do |k,v|
+ accept k
+ accept v
+ end
+
+ @emitter.end_mapping
+ end
+
+ def visit_Array o
+ if o.class == ::Array
+ register o, @emitter.start_sequence(nil, nil, true, Nodes::Sequence::BLOCK)
+ o.each { |c| accept c }
+ @emitter.end_sequence
+ else
+ visit_array_subclass o
+ end
+ end
+
+ def visit_NilClass o
+ @emitter.scalar('', nil, 'tag:yaml.org,2002:null', true, false, Nodes::Scalar::ANY)
+ end
+
+ def visit_Symbol o
+ if o.empty?
+ @emitter.scalar "", nil, '!ruby/symbol', false, false, Nodes::Scalar::ANY
+ else
+ @emitter.scalar ":#{o}", nil, nil, true, false, Nodes::Scalar::ANY
+ end
+ end
+
+ def visit_BasicObject o
+ tag = Psych.dump_tags[o.class]
+ tag ||= "!ruby/marshalable:#{o.class.name}"
+
+ map = @emitter.start_mapping(nil, tag, false, Nodes::Mapping::BLOCK)
+ register(o, map)
+
+ o.marshal_dump.each(&method(:accept))
+
+ @emitter.end_mapping
+ end
+
+ private
+ # FIXME: Remove the index and count checks in Psych 3.0
+ NULL = "\x00"
+ BINARY_RANGE = "\x00-\x7F"
+ WS_RANGE = "^ -~\t\r\n"
+
+ def binary? string
+ (string.encoding == Encoding::ASCII_8BIT && !string.ascii_only?) ||
+ string.index(NULL) ||
+ string.count(BINARY_RANGE, WS_RANGE).fdiv(string.length) > 0.3
+ end
+
+ def visit_array_subclass o
+ tag = "!ruby/array:#{o.class}"
+ if o.instance_variables.empty?
+ node = @emitter.start_sequence(nil, tag, false, Nodes::Sequence::BLOCK)
+ register o, node
+ o.each { |c| accept c }
+ @emitter.end_sequence
+ else
+ node = @emitter.start_mapping(nil, tag, false, Nodes::Sequence::BLOCK)
+ register o, node
+
+ # Dump the internal list
+ accept 'internal'
+ @emitter.start_sequence(nil, nil, true, Nodes::Sequence::BLOCK)
+ o.each { |c| accept c }
+ @emitter.end_sequence
+
+ # Dump the ivars
+ accept 'ivars'
+ @emitter.start_mapping(nil, nil, true, Nodes::Sequence::BLOCK)
+ o.instance_variables.each do |ivar|
+ accept ivar
+ accept o.instance_variable_get ivar
+ end
+ @emitter.end_mapping
+
+ @emitter.end_mapping
+ end
+ end
+
+ def dump_list o
+ end
+
+ # '%:z' was no defined until 1.9.3
+ if RUBY_VERSION < '1.9.3'
+ def format_time time
+ formatted = time.strftime("%Y-%m-%d %H:%M:%S.%9N")
+
+ if time.utc?
+ formatted += " Z"
+ else
+ zone = time.strftime('%z')
+ formatted += " #{zone[0,3]}:#{zone[3,5]}"
+ end
+
+ formatted
+ end
+ else
+ def format_time time
+ if time.utc?
+ time.strftime("%Y-%m-%d %H:%M:%S.%9N Z")
+ else
+ time.strftime("%Y-%m-%d %H:%M:%S.%9N %:z")
+ end
+ end
+ end
+
+ # FIXME: remove this method once "to_yaml_properties" is removed
+ def find_ivars target
+ begin
+ loc = target.method(:to_yaml_properties).source_location.first
+ unless loc.start_with?(Psych::DEPRECATED) || loc.end_with?('rubytypes.rb')
+ if $VERBOSE
+ warn "#{loc}: to_yaml_properties is deprecated, please implement \"encode_with(coder)\""
+ end
+ return target.to_yaml_properties
+ end
+ rescue
+ # public_method or source_location might be overridden,
+ # and it's OK to skip it since it's only to emit a warning.
+ end
+
+ target.instance_variables
+ end
+
+ def register target, yaml_obj
+ @st.register target, yaml_obj
+ yaml_obj
+ end
+
+ def dump_coder o
+ @coders << o
+ tag = Psych.dump_tags[o.class]
+ unless tag
+ klass = o.class == Object ? nil : o.class.name
+ tag = ['!ruby/object', klass].compact.join(':')
+ end
+
+ c = Psych::Coder.new(tag)
+ o.encode_with(c)
+ emit_coder c
+ end
+
+ def emit_coder c
+ case c.type
+ when :scalar
+ @emitter.scalar c.scalar, nil, c.tag, c.tag.nil?, false, Nodes::Scalar::ANY
+ when :seq
+ @emitter.start_sequence nil, c.tag, c.tag.nil?, Nodes::Sequence::BLOCK
+ c.seq.each do |thing|
+ accept thing
+ end
+ @emitter.end_sequence
+ when :map
+ @emitter.start_mapping nil, c.tag, c.implicit, c.style
+ c.map.each do |k,v|
+ accept k
+ accept v
+ end
+ @emitter.end_mapping
+ when :object
+ accept c.object
+ end
+ end
+
+ def dump_ivars target
+ ivars = find_ivars target
+
+ ivars.each do |iv|
+ @emitter.scalar("#{iv.to_s.sub(/^@/, '')}", nil, nil, true, false, Nodes::Scalar::ANY)
+ accept target.instance_variable_get(iv)
+ end
+ end
+ end
+ end
+end
diff --git a/jni/ruby/ext/psych/lib/psych/y.rb b/jni/ruby/ext/psych/lib/psych/y.rb
new file mode 100644
index 0000000..d0e049d
--- /dev/null
+++ b/jni/ruby/ext/psych/lib/psych/y.rb
@@ -0,0 +1,9 @@
+module Kernel
+ ###
+ # An alias for Psych.dump_stream meant to be used with IRB.
+ def y *objects
+ puts Psych.dump_stream(*objects)
+ end
+ private :y
+end
+
diff --git a/jni/ruby/ext/psych/psych.c b/jni/ruby/ext/psych/psych.c
new file mode 100644
index 0000000..3bb59bf
--- /dev/null
+++ b/jni/ruby/ext/psych/psych.c
@@ -0,0 +1,34 @@
+#include <psych.h>
+
+/* call-seq: Psych.libyaml_version
+ *
+ * Returns the version of libyaml being used
+ */
+static VALUE libyaml_version(VALUE module)
+{
+ int major, minor, patch;
+ VALUE list[3];
+
+ yaml_get_version(&major, &minor, &patch);
+
+ list[0] = INT2NUM((long)major);
+ list[1] = INT2NUM((long)minor);
+ list[2] = INT2NUM((long)patch);
+
+ return rb_ary_new4((long)3, list);
+}
+
+VALUE mPsych;
+
+void Init_psych(void)
+{
+ mPsych = rb_define_module("Psych");
+
+ rb_define_singleton_method(mPsych, "libyaml_version", libyaml_version, 0);
+
+ Init_psych_parser();
+ Init_psych_emitter();
+ Init_psych_to_ruby();
+ Init_psych_yaml_tree();
+}
+/* vim: set noet sws=4 sw=4: */
diff --git a/jni/ruby/ext/psych/psych.gemspec b/jni/ruby/ext/psych/psych.gemspec
new file mode 100644
index 0000000..648eb79
--- /dev/null
+++ b/jni/ruby/ext/psych/psych.gemspec
@@ -0,0 +1,23 @@
+# -*- encoding: utf-8 -*-
+
+Gem::Specification.new do |s|
+ s.name = "psych"
+ s.version = "2.0.8"
+
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
+ s.require_paths = ["lib"]
+ s.authors = ["Aaron Patterson"]
+ s.date = "2014-12-05"
+ s.description = "Psych is a YAML parser and emitter. Psych leverages libyaml[http://pyyaml.org/wiki/LibYAML]\nfor its YAML parsing and emitting capabilities. In addition to wrapping\nlibyaml, Psych also knows how to serialize and de-serialize most Ruby objects\nto and from the YAML format."
+ s.email = ["aaron@tenderlovemaking.com"]
+ s.extensions = ["ext/psych/extconf.rb"]
+ s.extra_rdoc_files = ["CHANGELOG.rdoc", "README.rdoc"]
+ s.files = [".autotest", ".gemtest", "CHANGELOG.rdoc", "Manifest.txt", "README.rdoc", "Rakefile", "ext/psych/depend", "ext/psych/extconf.rb", "ext/psych/psych.c", "ext/psych/psych.h", "ext/psych/psych_emitter.c", "ext/psych/psych_emitter.h", "ext/psych/psych_parser.c", "ext/psych/psych_parser.h", "ext/psych/psych_to_ruby.c", "ext/psych/psych_to_ruby.h", "ext/psych/psych_yaml_tree.c", "ext/psych/psych_yaml_tree.h", "ext/psych/yaml/LICENSE", "ext/psych/yaml/api.c", "ext/psych/yaml/config.h", "ext/psych/yaml/dumper.c", "ext/psych/yaml/emitter.c", "ext/psych/yaml/loader.c", "ext/psych/yaml/parser.c", "ext/psych/yaml/reader.c", "ext/psych/yaml/scanner.c", "ext/psych/yaml/writer.c", "ext/psych/yaml/yaml.h", "ext/psych/yaml/yaml_private.h", "lib/psych.rb", "lib/psych/class_loader.rb", "lib/psych/coder.rb", "lib/psych/core_ext.rb", "lib/psych/deprecated.rb", "lib/psych/exception.rb", "lib/psych/handler.rb", "lib/psych/handlers/document_stream.rb", "lib/psych/handlers/recorder.rb", "lib/psych/json/ruby_events.rb", "lib/psych/json/stream.rb", "lib/psych/json/tree_builder.rb", "lib/psych/json/yaml_events.rb", "lib/psych/nodes.rb", "lib/psych/nodes/alias.rb", "lib/psych/nodes/document.rb", "lib/psych/nodes/mapping.rb", "lib/psych/nodes/node.rb", "lib/psych/nodes/scalar.rb", "lib/psych/nodes/sequence.rb", "lib/psych/nodes/stream.rb", "lib/psych/omap.rb", "lib/psych/parser.rb", "lib/psych/scalar_scanner.rb", "lib/psych/set.rb", "lib/psych/stream.rb", "lib/psych/streaming.rb", "lib/psych/syntax_error.rb", "lib/psych/tree_builder.rb", "lib/psych/visitors.rb", "lib/psych/visitors/depth_first.rb", "lib/psych/visitors/emitter.rb", "lib/psych/visitors/json_tree.rb", "lib/psych/visitors/to_ruby.rb", "lib/psych/visitors/visitor.rb", "lib/psych/visitors/yaml_tree.rb", "lib/psych/y.rb", "test/psych/handlers/test_recorder.rb", "test/psych/helper.rb", "test/psych/json/test_stream.rb", "test/psych/nodes/test_enumerable.rb", "test/psych/test_alias_and_anchor.rb", "test/psych/test_array.rb", "test/psych/test_boolean.rb", "test/psych/test_class.rb", "test/psych/test_coder.rb", "test/psych/test_date_time.rb", "test/psych/test_deprecated.rb", "test/psych/test_document.rb", "test/psych/test_emitter.rb", "test/psych/test_encoding.rb", "test/psych/test_exception.rb", "test/psych/test_hash.rb", "test/psych/test_json_tree.rb", "test/psych/test_marshalable.rb", "test/psych/test_merge_keys.rb", "test/psych/test_nil.rb", "test/psych/test_null.rb", "test/psych/test_numeric.rb", "test/psych/test_object.rb", "test/psych/test_object_references.rb", "test/psych/test_omap.rb", "test/psych/test_parser.rb", "test/psych/test_psych.rb", "test/psych/test_safe_load.rb", "test/psych/test_scalar.rb", "test/psych/test_scalar_scanner.rb", "test/psych/test_serialize_subclasses.rb", "test/psych/test_set.rb", "test/psych/test_stream.rb", "test/psych/test_string.rb", "test/psych/test_struct.rb", "test/psych/test_symbol.rb", "test/psych/test_tainted.rb", "test/psych/test_to_yaml_properties.rb", "test/psych/test_tree_builder.rb", "test/psych/test_yaml.rb", "test/psych/test_yamldbm.rb", "test/psych/test_yamlstore.rb", "test/psych/visitors/test_depth_first.rb", "test/psych/visitors/test_emitter.rb", "test/psych/visitors/test_to_ruby.rb", "test/psych/visitors/test_yaml_tree.rb"]
+ s.homepage = "http://github.com/tenderlove/psych"
+ s.licenses = ["MIT"]
+ s.rdoc_options = ["--main", "README.rdoc"]
+ s.required_ruby_version = Gem::Requirement.new(">= 1.9.2")
+ s.rubygems_version = "2.4.4"
+ s.summary = "Psych is a YAML parser and emitter"
+ s.test_files = ["test/psych/handlers/test_recorder.rb", "test/psych/json/test_stream.rb", "test/psych/nodes/test_enumerable.rb", "test/psych/test_alias_and_anchor.rb", "test/psych/test_array.rb", "test/psych/test_boolean.rb", "test/psych/test_class.rb", "test/psych/test_coder.rb", "test/psych/test_date_time.rb", "test/psych/test_deprecated.rb", "test/psych/test_document.rb", "test/psych/test_emitter.rb", "test/psych/test_encoding.rb", "test/psych/test_exception.rb", "test/psych/test_hash.rb", "test/psych/test_json_tree.rb", "test/psych/test_marshalable.rb", "test/psych/test_merge_keys.rb", "test/psych/test_nil.rb", "test/psych/test_null.rb", "test/psych/test_numeric.rb", "test/psych/test_object.rb", "test/psych/test_object_references.rb", "test/psych/test_omap.rb", "test/psych/test_parser.rb", "test/psych/test_psych.rb", "test/psych/test_safe_load.rb", "test/psych/test_scalar.rb", "test/psych/test_scalar_scanner.rb", "test/psych/test_serialize_subclasses.rb", "test/psych/test_set.rb", "test/psych/test_stream.rb", "test/psych/test_string.rb", "test/psych/test_struct.rb", "test/psych/test_symbol.rb", "test/psych/test_tainted.rb", "test/psych/test_to_yaml_properties.rb", "test/psych/test_tree_builder.rb", "test/psych/test_yaml.rb", "test/psych/test_yamldbm.rb", "test/psych/test_yamlstore.rb", "test/psych/visitors/test_depth_first.rb", "test/psych/visitors/test_emitter.rb", "test/psych/visitors/test_to_ruby.rb", "test/psych/visitors/test_yaml_tree.rb"]
+end
diff --git a/jni/ruby/ext/psych/psych.h b/jni/ruby/ext/psych/psych.h
new file mode 100644
index 0000000..1830ca4
--- /dev/null
+++ b/jni/ruby/ext/psych/psych.h
@@ -0,0 +1,20 @@
+#ifndef PSYCH_H
+#define PSYCH_H
+
+#include <ruby.h>
+
+#ifdef HAVE_RUBY_ENCODING_H
+#include <ruby/encoding.h>
+#endif
+
+#include <yaml.h>
+
+#include <psych_parser.h>
+#include <psych_emitter.h>
+#include <psych_to_ruby.h>
+#include <psych_yaml_tree.h>
+
+extern VALUE mPsych;
+
+
+#endif
diff --git a/jni/ruby/ext/psych/psych_emitter.c b/jni/ruby/ext/psych/psych_emitter.c
new file mode 100644
index 0000000..4ba2381
--- /dev/null
+++ b/jni/ruby/ext/psych/psych_emitter.c
@@ -0,0 +1,556 @@
+#include <psych.h>
+
+VALUE cPsychEmitter;
+static ID id_write;
+static ID id_line_width;
+static ID id_indentation;
+static ID id_canonical;
+
+static void emit(yaml_emitter_t * emitter, yaml_event_t * event)
+{
+ if(!yaml_emitter_emit(emitter, event))
+ rb_raise(rb_eRuntimeError, "%s", emitter->problem);
+}
+
+static int writer(void *ctx, unsigned char *buffer, size_t size)
+{
+ VALUE io = (VALUE)ctx;
+ VALUE str = rb_str_new((const char *)buffer, (long)size);
+ VALUE wrote = rb_funcall(io, id_write, 1, str);
+ return (int)NUM2INT(wrote);
+}
+
+static void dealloc(void * ptr)
+{
+ yaml_emitter_t * emitter;
+
+ emitter = (yaml_emitter_t *)ptr;
+ yaml_emitter_delete(emitter);
+ xfree(emitter);
+}
+
+#if 0
+static size_t memsize(const void *ptr)
+{
+ const yaml_emitter_t *emitter = ptr;
+ /* TODO: calculate emitter's size */
+ return 0;
+}
+#endif
+
+static const rb_data_type_t psych_emitter_type = {
+ "Psych/emitter",
+ {0, dealloc, 0,},
+ 0, 0,
+#ifdef RUBY_TYPED_FREE_IMMEDIATELY
+ RUBY_TYPED_FREE_IMMEDIATELY,
+#endif
+};
+
+static VALUE allocate(VALUE klass)
+{
+ yaml_emitter_t * emitter;
+
+ emitter = xmalloc(sizeof(yaml_emitter_t));
+
+ yaml_emitter_initialize(emitter);
+ yaml_emitter_set_unicode(emitter, 1);
+ yaml_emitter_set_indent(emitter, 2);
+
+ return TypedData_Wrap_Struct(klass, &psych_emitter_type, emitter);
+}
+
+/* call-seq: Psych::Emitter.new(io, options = Psych::Emitter::OPTIONS)
+ *
+ * Create a new Psych::Emitter that writes to +io+.
+ */
+static VALUE initialize(int argc, VALUE *argv, VALUE self)
+{
+ yaml_emitter_t * emitter;
+ VALUE io, options;
+ VALUE line_width;
+ VALUE indent;
+ VALUE canonical;
+
+ TypedData_Get_Struct(self, yaml_emitter_t, &psych_emitter_type, emitter);
+
+ if (rb_scan_args(argc, argv, "11", &io, &options) == 2) {
+ line_width = rb_funcall(options, id_line_width, 0);
+ indent = rb_funcall(options, id_indentation, 0);
+ canonical = rb_funcall(options, id_canonical, 0);
+
+ yaml_emitter_set_width(emitter, NUM2INT(line_width));
+ yaml_emitter_set_indent(emitter, NUM2INT(indent));
+ yaml_emitter_set_canonical(emitter, Qtrue == canonical ? 1 : 0);
+ }
+
+ yaml_emitter_set_output(emitter, writer, (void *)io);
+
+ return self;
+}
+
+/* call-seq: emitter.start_stream(encoding)
+ *
+ * Start a stream emission with +encoding+
+ *
+ * See Psych::Handler#start_stream
+ */
+static VALUE start_stream(VALUE self, VALUE encoding)
+{
+ yaml_emitter_t * emitter;
+ yaml_event_t event;
+ TypedData_Get_Struct(self, yaml_emitter_t, &psych_emitter_type, emitter);
+ Check_Type(encoding, T_FIXNUM);
+
+ yaml_stream_start_event_initialize(&event, (yaml_encoding_t)NUM2INT(encoding));
+
+ emit(emitter, &event);
+
+ return self;
+}
+
+/* call-seq: emitter.end_stream
+ *
+ * End a stream emission
+ *
+ * See Psych::Handler#end_stream
+ */
+static VALUE end_stream(VALUE self)
+{
+ yaml_emitter_t * emitter;
+ yaml_event_t event;
+ TypedData_Get_Struct(self, yaml_emitter_t, &psych_emitter_type, emitter);
+
+ yaml_stream_end_event_initialize(&event);
+
+ emit(emitter, &event);
+
+ return self;
+}
+
+/* call-seq: emitter.start_document(version, tags, implicit)
+ *
+ * Start a document emission with YAML +version+, +tags+, and an +implicit+
+ * start.
+ *
+ * See Psych::Handler#start_document
+ */
+static VALUE start_document(VALUE self, VALUE version, VALUE tags, VALUE imp)
+{
+ yaml_emitter_t * emitter;
+ yaml_tag_directive_t * head = NULL;
+ yaml_tag_directive_t * tail = NULL;
+ yaml_event_t event;
+ yaml_version_directive_t version_directive;
+ TypedData_Get_Struct(self, yaml_emitter_t, &psych_emitter_type, emitter);
+
+
+ Check_Type(version, T_ARRAY);
+
+ if(RARRAY_LEN(version) > 0) {
+ VALUE major = rb_ary_entry(version, (long)0);
+ VALUE minor = rb_ary_entry(version, (long)1);
+
+ version_directive.major = NUM2INT(major);
+ version_directive.minor = NUM2INT(minor);
+ }
+
+ if(RTEST(tags)) {
+ int i = 0;
+#ifdef HAVE_RUBY_ENCODING_H
+ rb_encoding * encoding = rb_utf8_encoding();
+#endif
+
+ Check_Type(tags, T_ARRAY);
+
+ head = xcalloc((size_t)RARRAY_LEN(tags), sizeof(yaml_tag_directive_t));
+ tail = head;
+
+ for(i = 0; i < RARRAY_LEN(tags); i++) {
+ VALUE tuple = RARRAY_PTR(tags)[i];
+ VALUE name;
+ VALUE value;
+
+ Check_Type(tuple, T_ARRAY);
+
+ if(RARRAY_LEN(tuple) < 2) {
+ xfree(head);
+ rb_raise(rb_eRuntimeError, "tag tuple must be of length 2");
+ }
+ name = RARRAY_PTR(tuple)[0];
+ value = RARRAY_PTR(tuple)[1];
+#ifdef HAVE_RUBY_ENCODING_H
+ name = rb_str_export_to_enc(name, encoding);
+ value = rb_str_export_to_enc(value, encoding);
+#endif
+
+ tail->handle = (yaml_char_t *)StringValuePtr(name);
+ tail->prefix = (yaml_char_t *)StringValuePtr(value);
+
+ tail++;
+ }
+ }
+
+ yaml_document_start_event_initialize(
+ &event,
+ (RARRAY_LEN(version) > 0) ? &version_directive : NULL,
+ head,
+ tail,
+ imp ? 1 : 0
+ );
+
+ emit(emitter, &event);
+
+ if(head) xfree(head);
+
+ return self;
+}
+
+/* call-seq: emitter.end_document(implicit)
+ *
+ * End a document emission with an +implicit+ ending.
+ *
+ * See Psych::Handler#end_document
+ */
+static VALUE end_document(VALUE self, VALUE imp)
+{
+ yaml_emitter_t * emitter;
+ yaml_event_t event;
+ TypedData_Get_Struct(self, yaml_emitter_t, &psych_emitter_type, emitter);
+
+ yaml_document_end_event_initialize(&event, imp ? 1 : 0);
+
+ emit(emitter, &event);
+
+ return self;
+}
+
+/* call-seq: emitter.scalar(value, anchor, tag, plain, quoted, style)
+ *
+ * Emit a scalar with +value+, +anchor+, +tag+, and a +plain+ or +quoted+
+ * string type with +style+.
+ *
+ * See Psych::Handler#scalar
+ */
+static VALUE scalar(
+ VALUE self,
+ VALUE value,
+ VALUE anchor,
+ VALUE tag,
+ VALUE plain,
+ VALUE quoted,
+ VALUE style
+ ) {
+ yaml_emitter_t * emitter;
+ yaml_event_t event;
+#ifdef HAVE_RUBY_ENCODING_H
+ rb_encoding *encoding;
+#endif
+ TypedData_Get_Struct(self, yaml_emitter_t, &psych_emitter_type, emitter);
+
+ Check_Type(value, T_STRING);
+
+#ifdef HAVE_RUBY_ENCODING_H
+ encoding = rb_utf8_encoding();
+
+ value = rb_str_export_to_enc(value, encoding);
+
+ if(!NIL_P(anchor)) {
+ Check_Type(anchor, T_STRING);
+ anchor = rb_str_export_to_enc(anchor, encoding);
+ }
+
+ if(!NIL_P(tag)) {
+ Check_Type(tag, T_STRING);
+ tag = rb_str_export_to_enc(tag, encoding);
+ }
+#endif
+
+ yaml_scalar_event_initialize(
+ &event,
+ (yaml_char_t *)(NIL_P(anchor) ? NULL : StringValuePtr(anchor)),
+ (yaml_char_t *)(NIL_P(tag) ? NULL : StringValuePtr(tag)),
+ (yaml_char_t*)StringValuePtr(value),
+ (int)RSTRING_LEN(value),
+ plain ? 1 : 0,
+ quoted ? 1 : 0,
+ (yaml_scalar_style_t)NUM2INT(style)
+ );
+
+ emit(emitter, &event);
+
+ return self;
+}
+
+/* call-seq: emitter.start_sequence(anchor, tag, implicit, style)
+ *
+ * Start emitting a sequence with +anchor+, a +tag+, +implicit+ sequence
+ * start and end, along with +style+.
+ *
+ * See Psych::Handler#start_sequence
+ */
+static VALUE start_sequence(
+ VALUE self,
+ VALUE anchor,
+ VALUE tag,
+ VALUE implicit,
+ VALUE style
+ ) {
+ yaml_emitter_t * emitter;
+ yaml_event_t event;
+
+#ifdef HAVE_RUBY_ENCODING_H
+ rb_encoding * encoding = rb_utf8_encoding();
+
+ if(!NIL_P(anchor)) {
+ Check_Type(anchor, T_STRING);
+ anchor = rb_str_export_to_enc(anchor, encoding);
+ }
+
+ if(!NIL_P(tag)) {
+ Check_Type(tag, T_STRING);
+ tag = rb_str_export_to_enc(tag, encoding);
+ }
+#endif
+
+ TypedData_Get_Struct(self, yaml_emitter_t, &psych_emitter_type, emitter);
+
+ yaml_sequence_start_event_initialize(
+ &event,
+ (yaml_char_t *)(NIL_P(anchor) ? NULL : StringValuePtr(anchor)),
+ (yaml_char_t *)(NIL_P(tag) ? NULL : StringValuePtr(tag)),
+ implicit ? 1 : 0,
+ (yaml_sequence_style_t)NUM2INT(style)
+ );
+
+ emit(emitter, &event);
+
+ return self;
+}
+
+/* call-seq: emitter.end_sequence
+ *
+ * End sequence emission.
+ *
+ * See Psych::Handler#end_sequence
+ */
+static VALUE end_sequence(VALUE self)
+{
+ yaml_emitter_t * emitter;
+ yaml_event_t event;
+ TypedData_Get_Struct(self, yaml_emitter_t, &psych_emitter_type, emitter);
+
+ yaml_sequence_end_event_initialize(&event);
+
+ emit(emitter, &event);
+
+ return self;
+}
+
+/* call-seq: emitter.start_mapping(anchor, tag, implicit, style)
+ *
+ * Start emitting a YAML map with +anchor+, +tag+, an +implicit+ start
+ * and end, and +style+.
+ *
+ * See Psych::Handler#start_mapping
+ */
+static VALUE start_mapping(
+ VALUE self,
+ VALUE anchor,
+ VALUE tag,
+ VALUE implicit,
+ VALUE style
+ ) {
+ yaml_emitter_t * emitter;
+ yaml_event_t event;
+#ifdef HAVE_RUBY_ENCODING_H
+ rb_encoding *encoding;
+#endif
+ TypedData_Get_Struct(self, yaml_emitter_t, &psych_emitter_type, emitter);
+
+#ifdef HAVE_RUBY_ENCODING_H
+ encoding = rb_utf8_encoding();
+
+ if(!NIL_P(anchor)) {
+ Check_Type(anchor, T_STRING);
+ anchor = rb_str_export_to_enc(anchor, encoding);
+ }
+
+ if(!NIL_P(tag)) {
+ Check_Type(tag, T_STRING);
+ tag = rb_str_export_to_enc(tag, encoding);
+ }
+#endif
+
+ yaml_mapping_start_event_initialize(
+ &event,
+ (yaml_char_t *)(NIL_P(anchor) ? NULL : StringValuePtr(anchor)),
+ (yaml_char_t *)(NIL_P(tag) ? NULL : StringValuePtr(tag)),
+ implicit ? 1 : 0,
+ (yaml_mapping_style_t)NUM2INT(style)
+ );
+
+ emit(emitter, &event);
+
+ return self;
+}
+
+/* call-seq: emitter.end_mapping
+ *
+ * Emit the end of a mapping.
+ *
+ * See Psych::Handler#end_mapping
+ */
+static VALUE end_mapping(VALUE self)
+{
+ yaml_emitter_t * emitter;
+ yaml_event_t event;
+ TypedData_Get_Struct(self, yaml_emitter_t, &psych_emitter_type, emitter);
+
+ yaml_mapping_end_event_initialize(&event);
+
+ emit(emitter, &event);
+
+ return self;
+}
+
+/* call-seq: emitter.alias(anchor)
+ *
+ * Emit an alias with +anchor+.
+ *
+ * See Psych::Handler#alias
+ */
+static VALUE alias(VALUE self, VALUE anchor)
+{
+ yaml_emitter_t * emitter;
+ yaml_event_t event;
+ TypedData_Get_Struct(self, yaml_emitter_t, &psych_emitter_type, emitter);
+
+#ifdef HAVE_RUBY_ENCODING_H
+ if(!NIL_P(anchor)) {
+ Check_Type(anchor, T_STRING);
+ anchor = rb_str_export_to_enc(anchor, rb_utf8_encoding());
+ }
+#endif
+
+ yaml_alias_event_initialize(
+ &event,
+ (yaml_char_t *)(NIL_P(anchor) ? NULL : StringValuePtr(anchor))
+ );
+
+ emit(emitter, &event);
+
+ return self;
+}
+
+/* call-seq: emitter.canonical = true
+ *
+ * Set the output style to canonical, or not.
+ */
+static VALUE set_canonical(VALUE self, VALUE style)
+{
+ yaml_emitter_t * emitter;
+ TypedData_Get_Struct(self, yaml_emitter_t, &psych_emitter_type, emitter);
+
+ yaml_emitter_set_canonical(emitter, Qtrue == style ? 1 : 0);
+
+ return style;
+}
+
+/* call-seq: emitter.canonical
+ *
+ * Get the output style, canonical or not.
+ */
+static VALUE canonical(VALUE self)
+{
+ yaml_emitter_t * emitter;
+ TypedData_Get_Struct(self, yaml_emitter_t, &psych_emitter_type, emitter);
+
+ return (emitter->canonical == 0) ? Qfalse : Qtrue;
+}
+
+/* call-seq: emitter.indentation = level
+ *
+ * Set the indentation level to +level+. The level must be less than 10 and
+ * greater than 1.
+ */
+static VALUE set_indentation(VALUE self, VALUE level)
+{
+ yaml_emitter_t * emitter;
+ TypedData_Get_Struct(self, yaml_emitter_t, &psych_emitter_type, emitter);
+
+ yaml_emitter_set_indent(emitter, NUM2INT(level));
+
+ return level;
+}
+
+/* call-seq: emitter.indentation
+ *
+ * Get the indentation level.
+ */
+static VALUE indentation(VALUE self)
+{
+ yaml_emitter_t * emitter;
+ TypedData_Get_Struct(self, yaml_emitter_t, &psych_emitter_type, emitter);
+
+ return INT2NUM(emitter->best_indent);
+}
+
+/* call-seq: emitter.line_width
+ *
+ * Get the preferred line width.
+ */
+static VALUE line_width(VALUE self)
+{
+ yaml_emitter_t * emitter;
+ TypedData_Get_Struct(self, yaml_emitter_t, &psych_emitter_type, emitter);
+
+ return INT2NUM(emitter->best_width);
+}
+
+/* call-seq: emitter.line_width = width
+ *
+ * Set the preferred line with to +width+.
+ */
+static VALUE set_line_width(VALUE self, VALUE width)
+{
+ yaml_emitter_t * emitter;
+ TypedData_Get_Struct(self, yaml_emitter_t, &psych_emitter_type, emitter);
+
+ yaml_emitter_set_width(emitter, NUM2INT(width));
+
+ return width;
+}
+
+void Init_psych_emitter(void)
+{
+ VALUE psych = rb_define_module("Psych");
+ VALUE handler = rb_define_class_under(psych, "Handler", rb_cObject);
+ cPsychEmitter = rb_define_class_under(psych, "Emitter", handler);
+
+ rb_define_alloc_func(cPsychEmitter, allocate);
+
+ rb_define_method(cPsychEmitter, "initialize", initialize, -1);
+ rb_define_method(cPsychEmitter, "start_stream", start_stream, 1);
+ rb_define_method(cPsychEmitter, "end_stream", end_stream, 0);
+ rb_define_method(cPsychEmitter, "start_document", start_document, 3);
+ rb_define_method(cPsychEmitter, "end_document", end_document, 1);
+ rb_define_method(cPsychEmitter, "scalar", scalar, 6);
+ rb_define_method(cPsychEmitter, "start_sequence", start_sequence, 4);
+ rb_define_method(cPsychEmitter, "end_sequence", end_sequence, 0);
+ rb_define_method(cPsychEmitter, "start_mapping", start_mapping, 4);
+ rb_define_method(cPsychEmitter, "end_mapping", end_mapping, 0);
+ rb_define_method(cPsychEmitter, "alias", alias, 1);
+ rb_define_method(cPsychEmitter, "canonical", canonical, 0);
+ rb_define_method(cPsychEmitter, "canonical=", set_canonical, 1);
+ rb_define_method(cPsychEmitter, "indentation", indentation, 0);
+ rb_define_method(cPsychEmitter, "indentation=", set_indentation, 1);
+ rb_define_method(cPsychEmitter, "line_width", line_width, 0);
+ rb_define_method(cPsychEmitter, "line_width=", set_line_width, 1);
+
+ id_write = rb_intern("write");
+ id_line_width = rb_intern("line_width");
+ id_indentation = rb_intern("indentation");
+ id_canonical = rb_intern("canonical");
+}
+/* vim: set noet sws=4 sw=4: */
diff --git a/jni/ruby/ext/psych/psych_emitter.h b/jni/ruby/ext/psych/psych_emitter.h
new file mode 100644
index 0000000..4c1482a
--- /dev/null
+++ b/jni/ruby/ext/psych/psych_emitter.h
@@ -0,0 +1,8 @@
+#ifndef PSYCH_EMITTER_H
+#define PSYCH_EMITTER_H
+
+#include <psych.h>
+
+void Init_psych_emitter(void);
+
+#endif
diff --git a/jni/ruby/ext/psych/psych_parser.c b/jni/ruby/ext/psych/psych_parser.c
new file mode 100644
index 0000000..faae460
--- /dev/null
+++ b/jni/ruby/ext/psych/psych_parser.c
@@ -0,0 +1,597 @@
+#include <psych.h>
+
+VALUE cPsychParser;
+VALUE ePsychSyntaxError;
+
+static ID id_read;
+static ID id_path;
+static ID id_empty;
+static ID id_start_stream;
+static ID id_end_stream;
+static ID id_start_document;
+static ID id_end_document;
+static ID id_alias;
+static ID id_scalar;
+static ID id_start_sequence;
+static ID id_end_sequence;
+static ID id_start_mapping;
+static ID id_end_mapping;
+
+#define PSYCH_TRANSCODE(_str, _yaml_enc, _internal_enc) \
+ do { \
+ rb_enc_associate_index((_str), (_yaml_enc)); \
+ if(_internal_enc) \
+ (_str) = rb_str_export_to_enc((_str), (_internal_enc)); \
+ } while (0)
+
+static int io_reader(void * data, unsigned char *buf, size_t size, size_t *read)
+{
+ VALUE io = (VALUE)data;
+ VALUE string = rb_funcall(io, id_read, 1, INT2NUM(size));
+
+ *read = 0;
+
+ if(! NIL_P(string)) {
+ void * str = (void *)StringValuePtr(string);
+ *read = (size_t)RSTRING_LEN(string);
+ memcpy(buf, str, *read);
+ }
+
+ return 1;
+}
+
+static void dealloc(void * ptr)
+{
+ yaml_parser_t * parser;
+
+ parser = (yaml_parser_t *)ptr;
+ yaml_parser_delete(parser);
+ xfree(parser);
+}
+
+#if 0
+static size_t memsize(const void *ptr)
+{
+ const yaml_parser_t *parser = ptr;
+ /* TODO: calculate parser's size */
+ return 0;
+}
+#endif
+
+static const rb_data_type_t psych_parser_type = {
+ "Psych/parser",
+ {0, dealloc, 0,},
+ 0, 0,
+#ifdef RUBY_TYPED_FREE_IMMEDIATELY
+ RUBY_TYPED_FREE_IMMEDIATELY,
+#endif
+};
+
+static VALUE allocate(VALUE klass)
+{
+ yaml_parser_t * parser;
+
+ parser = xmalloc(sizeof(yaml_parser_t));
+ yaml_parser_initialize(parser);
+
+ return TypedData_Wrap_Struct(klass, &psych_parser_type, parser);
+}
+
+static VALUE make_exception(yaml_parser_t * parser, VALUE path)
+{
+ size_t line, column;
+
+ line = parser->context_mark.line + 1;
+ column = parser->context_mark.column + 1;
+
+ return rb_funcall(ePsychSyntaxError, rb_intern("new"), 6,
+ path,
+ INT2NUM(line),
+ INT2NUM(column),
+ INT2NUM(parser->problem_offset),
+ parser->problem ? rb_usascii_str_new2(parser->problem) : Qnil,
+ parser->context ? rb_usascii_str_new2(parser->context) : Qnil);
+}
+
+#ifdef HAVE_RUBY_ENCODING_H
+static VALUE transcode_string(VALUE src, int * parser_encoding)
+{
+ int utf8 = rb_utf8_encindex();
+ int utf16le = rb_enc_find_index("UTF-16LE");
+ int utf16be = rb_enc_find_index("UTF-16BE");
+ int source_encoding = rb_enc_get_index(src);
+
+ if (source_encoding == utf8) {
+ *parser_encoding = YAML_UTF8_ENCODING;
+ return src;
+ }
+
+ if (source_encoding == utf16le) {
+ *parser_encoding = YAML_UTF16LE_ENCODING;
+ return src;
+ }
+
+ if (source_encoding == utf16be) {
+ *parser_encoding = YAML_UTF16BE_ENCODING;
+ return src;
+ }
+
+ src = rb_str_export_to_enc(src, rb_utf8_encoding());
+ RB_GC_GUARD(src);
+
+ *parser_encoding = YAML_UTF8_ENCODING;
+ return src;
+}
+
+static VALUE transcode_io(VALUE src, int * parser_encoding)
+{
+ VALUE io_external_encoding;
+ int io_external_enc_index;
+
+ io_external_encoding = rb_funcall(src, rb_intern("external_encoding"), 0);
+
+ /* if no encoding is returned, assume ascii8bit. */
+ if (NIL_P(io_external_encoding)) {
+ io_external_enc_index = rb_ascii8bit_encindex();
+ } else {
+ io_external_enc_index = rb_to_encoding_index(io_external_encoding);
+ }
+
+ /* Treat US-ASCII as utf_8 */
+ if (io_external_enc_index == rb_usascii_encindex()) {
+ *parser_encoding = YAML_UTF8_ENCODING;
+ return src;
+ }
+
+ if (io_external_enc_index == rb_utf8_encindex()) {
+ *parser_encoding = YAML_UTF8_ENCODING;
+ return src;
+ }
+
+ if (io_external_enc_index == rb_enc_find_index("UTF-16LE")) {
+ *parser_encoding = YAML_UTF16LE_ENCODING;
+ return src;
+ }
+
+ if (io_external_enc_index == rb_enc_find_index("UTF-16BE")) {
+ *parser_encoding = YAML_UTF16BE_ENCODING;
+ return src;
+ }
+
+ /* Just guess on ASCII-8BIT */
+ if (io_external_enc_index == rb_ascii8bit_encindex()) {
+ *parser_encoding = YAML_ANY_ENCODING;
+ return src;
+ }
+
+ /* If the external encoding is something we don't know how to handle,
+ * fall back to YAML_ANY_ENCODING. */
+ *parser_encoding = YAML_ANY_ENCODING;
+
+ return src;
+}
+
+#endif
+
+static VALUE protected_start_stream(VALUE pointer)
+{
+ VALUE *args = (VALUE *)pointer;
+ return rb_funcall(args[0], id_start_stream, 1, args[1]);
+}
+
+static VALUE protected_start_document(VALUE pointer)
+{
+ VALUE *args = (VALUE *)pointer;
+ return rb_funcall3(args[0], id_start_document, 3, args + 1);
+}
+
+static VALUE protected_end_document(VALUE pointer)
+{
+ VALUE *args = (VALUE *)pointer;
+ return rb_funcall(args[0], id_end_document, 1, args[1]);
+}
+
+static VALUE protected_alias(VALUE pointer)
+{
+ VALUE *args = (VALUE *)pointer;
+ return rb_funcall(args[0], id_alias, 1, args[1]);
+}
+
+static VALUE protected_scalar(VALUE pointer)
+{
+ VALUE *args = (VALUE *)pointer;
+ return rb_funcall3(args[0], id_scalar, 6, args + 1);
+}
+
+static VALUE protected_start_sequence(VALUE pointer)
+{
+ VALUE *args = (VALUE *)pointer;
+ return rb_funcall3(args[0], id_start_sequence, 4, args + 1);
+}
+
+static VALUE protected_end_sequence(VALUE handler)
+{
+ return rb_funcall(handler, id_end_sequence, 0);
+}
+
+static VALUE protected_start_mapping(VALUE pointer)
+{
+ VALUE *args = (VALUE *)pointer;
+ return rb_funcall3(args[0], id_start_mapping, 4, args + 1);
+}
+
+static VALUE protected_end_mapping(VALUE handler)
+{
+ return rb_funcall(handler, id_end_mapping, 0);
+}
+
+static VALUE protected_empty(VALUE handler)
+{
+ return rb_funcall(handler, id_empty, 0);
+}
+
+static VALUE protected_end_stream(VALUE handler)
+{
+ return rb_funcall(handler, id_end_stream, 0);
+}
+
+/*
+ * call-seq:
+ * parser.parse(yaml)
+ *
+ * Parse the YAML document contained in +yaml+. Events will be called on
+ * the handler set on the parser instance.
+ *
+ * See Psych::Parser and Psych::Parser#handler
+ */
+static VALUE parse(int argc, VALUE *argv, VALUE self)
+{
+ VALUE yaml, path;
+ yaml_parser_t * parser;
+ yaml_event_t event;
+ int done = 0;
+ int tainted = 0;
+ int state = 0;
+ int parser_encoding = YAML_ANY_ENCODING;
+#ifdef HAVE_RUBY_ENCODING_H
+ int encoding = rb_utf8_encindex();
+ rb_encoding * internal_enc = rb_default_internal_encoding();
+#endif
+ VALUE handler = rb_iv_get(self, "@handler");
+
+ if (rb_scan_args(argc, argv, "11", &yaml, &path) == 1) {
+ if(rb_respond_to(yaml, id_path))
+ path = rb_funcall(yaml, id_path, 0);
+ else
+ path = rb_str_new2("<unknown>");
+ }
+
+ TypedData_Get_Struct(self, yaml_parser_t, &psych_parser_type, parser);
+
+ yaml_parser_delete(parser);
+ yaml_parser_initialize(parser);
+
+ if (OBJ_TAINTED(yaml)) tainted = 1;
+
+ if (rb_respond_to(yaml, id_read)) {
+#ifdef HAVE_RUBY_ENCODING_H
+ yaml = transcode_io(yaml, &parser_encoding);
+ yaml_parser_set_encoding(parser, parser_encoding);
+#endif
+ yaml_parser_set_input(parser, io_reader, (void *)yaml);
+ if (RTEST(rb_obj_is_kind_of(yaml, rb_cIO))) tainted = 1;
+ } else {
+ StringValue(yaml);
+#ifdef HAVE_RUBY_ENCODING_H
+ yaml = transcode_string(yaml, &parser_encoding);
+ yaml_parser_set_encoding(parser, parser_encoding);
+#endif
+ yaml_parser_set_input_string(
+ parser,
+ (const unsigned char *)RSTRING_PTR(yaml),
+ (size_t)RSTRING_LEN(yaml)
+ );
+ }
+
+ while(!done) {
+ if(!yaml_parser_parse(parser, &event)) {
+ VALUE exception;
+
+ exception = make_exception(parser, path);
+ yaml_parser_delete(parser);
+ yaml_parser_initialize(parser);
+
+ rb_exc_raise(exception);
+ }
+
+ switch(event.type) {
+ case YAML_STREAM_START_EVENT:
+ {
+ VALUE args[2];
+
+ args[0] = handler;
+ args[1] = INT2NUM((long)event.data.stream_start.encoding);
+ rb_protect(protected_start_stream, (VALUE)args, &state);
+ }
+ break;
+ case YAML_DOCUMENT_START_EVENT:
+ {
+ VALUE args[4];
+ /* Get a list of tag directives (if any) */
+ VALUE tag_directives = rb_ary_new();
+ /* Grab the document version */
+ VALUE version = event.data.document_start.version_directive ?
+ rb_ary_new3(
+ (long)2,
+ INT2NUM((long)event.data.document_start.version_directive->major),
+ INT2NUM((long)event.data.document_start.version_directive->minor)
+ ) : rb_ary_new();
+
+ if(event.data.document_start.tag_directives.start) {
+ yaml_tag_directive_t *start =
+ event.data.document_start.tag_directives.start;
+ yaml_tag_directive_t *end =
+ event.data.document_start.tag_directives.end;
+ for(; start != end; start++) {
+ VALUE handle = Qnil;
+ VALUE prefix = Qnil;
+ if(start->handle) {
+ handle = rb_str_new2((const char *)start->handle);
+ if (tainted) OBJ_TAINT(handle);
+#ifdef HAVE_RUBY_ENCODING_H
+ PSYCH_TRANSCODE(handle, encoding, internal_enc);
+#endif
+ }
+
+ if(start->prefix) {
+ prefix = rb_str_new2((const char *)start->prefix);
+ if (tainted) OBJ_TAINT(prefix);
+#ifdef HAVE_RUBY_ENCODING_H
+ PSYCH_TRANSCODE(prefix, encoding, internal_enc);
+#endif
+ }
+
+ rb_ary_push(tag_directives, rb_ary_new3((long)2, handle, prefix));
+ }
+ }
+ args[0] = handler;
+ args[1] = version;
+ args[2] = tag_directives;
+ args[3] = event.data.document_start.implicit == 1 ? Qtrue : Qfalse;
+ rb_protect(protected_start_document, (VALUE)args, &state);
+ }
+ break;
+ case YAML_DOCUMENT_END_EVENT:
+ {
+ VALUE args[2];
+
+ args[0] = handler;
+ args[1] = event.data.document_end.implicit == 1 ? Qtrue : Qfalse;
+ rb_protect(protected_end_document, (VALUE)args, &state);
+ }
+ break;
+ case YAML_ALIAS_EVENT:
+ {
+ VALUE args[2];
+ VALUE alias = Qnil;
+ if(event.data.alias.anchor) {
+ alias = rb_str_new2((const char *)event.data.alias.anchor);
+ if (tainted) OBJ_TAINT(alias);
+#ifdef HAVE_RUBY_ENCODING_H
+ PSYCH_TRANSCODE(alias, encoding, internal_enc);
+#endif
+ }
+
+ args[0] = handler;
+ args[1] = alias;
+ rb_protect(protected_alias, (VALUE)args, &state);
+ }
+ break;
+ case YAML_SCALAR_EVENT:
+ {
+ VALUE args[7];
+ VALUE anchor = Qnil;
+ VALUE tag = Qnil;
+ VALUE plain_implicit, quoted_implicit, style;
+ VALUE val = rb_str_new(
+ (const char *)event.data.scalar.value,
+ (long)event.data.scalar.length
+ );
+ if (tainted) OBJ_TAINT(val);
+
+#ifdef HAVE_RUBY_ENCODING_H
+ PSYCH_TRANSCODE(val, encoding, internal_enc);
+#endif
+
+ if(event.data.scalar.anchor) {
+ anchor = rb_str_new2((const char *)event.data.scalar.anchor);
+ if (tainted) OBJ_TAINT(anchor);
+#ifdef HAVE_RUBY_ENCODING_H
+ PSYCH_TRANSCODE(anchor, encoding, internal_enc);
+#endif
+ }
+
+ if(event.data.scalar.tag) {
+ tag = rb_str_new2((const char *)event.data.scalar.tag);
+ if (tainted) OBJ_TAINT(tag);
+#ifdef HAVE_RUBY_ENCODING_H
+ PSYCH_TRANSCODE(tag, encoding, internal_enc);
+#endif
+ }
+
+ plain_implicit =
+ event.data.scalar.plain_implicit == 0 ? Qfalse : Qtrue;
+
+ quoted_implicit =
+ event.data.scalar.quoted_implicit == 0 ? Qfalse : Qtrue;
+
+ style = INT2NUM((long)event.data.scalar.style);
+
+ args[0] = handler;
+ args[1] = val;
+ args[2] = anchor;
+ args[3] = tag;
+ args[4] = plain_implicit;
+ args[5] = quoted_implicit;
+ args[6] = style;
+ rb_protect(protected_scalar, (VALUE)args, &state);
+ }
+ break;
+ case YAML_SEQUENCE_START_EVENT:
+ {
+ VALUE args[5];
+ VALUE anchor = Qnil;
+ VALUE tag = Qnil;
+ VALUE implicit, style;
+ if(event.data.sequence_start.anchor) {
+ anchor = rb_str_new2((const char *)event.data.sequence_start.anchor);
+ if (tainted) OBJ_TAINT(anchor);
+#ifdef HAVE_RUBY_ENCODING_H
+ PSYCH_TRANSCODE(anchor, encoding, internal_enc);
+#endif
+ }
+
+ tag = Qnil;
+ if(event.data.sequence_start.tag) {
+ tag = rb_str_new2((const char *)event.data.sequence_start.tag);
+ if (tainted) OBJ_TAINT(tag);
+#ifdef HAVE_RUBY_ENCODING_H
+ PSYCH_TRANSCODE(tag, encoding, internal_enc);
+#endif
+ }
+
+ implicit =
+ event.data.sequence_start.implicit == 0 ? Qfalse : Qtrue;
+
+ style = INT2NUM((long)event.data.sequence_start.style);
+
+ args[0] = handler;
+ args[1] = anchor;
+ args[2] = tag;
+ args[3] = implicit;
+ args[4] = style;
+
+ rb_protect(protected_start_sequence, (VALUE)args, &state);
+ }
+ break;
+ case YAML_SEQUENCE_END_EVENT:
+ rb_protect(protected_end_sequence, handler, &state);
+ break;
+ case YAML_MAPPING_START_EVENT:
+ {
+ VALUE args[5];
+ VALUE anchor = Qnil;
+ VALUE tag = Qnil;
+ VALUE implicit, style;
+ if(event.data.mapping_start.anchor) {
+ anchor = rb_str_new2((const char *)event.data.mapping_start.anchor);
+ if (tainted) OBJ_TAINT(anchor);
+#ifdef HAVE_RUBY_ENCODING_H
+ PSYCH_TRANSCODE(anchor, encoding, internal_enc);
+#endif
+ }
+
+ if(event.data.mapping_start.tag) {
+ tag = rb_str_new2((const char *)event.data.mapping_start.tag);
+ if (tainted) OBJ_TAINT(tag);
+#ifdef HAVE_RUBY_ENCODING_H
+ PSYCH_TRANSCODE(tag, encoding, internal_enc);
+#endif
+ }
+
+ implicit =
+ event.data.mapping_start.implicit == 0 ? Qfalse : Qtrue;
+
+ style = INT2NUM((long)event.data.mapping_start.style);
+
+ args[0] = handler;
+ args[1] = anchor;
+ args[2] = tag;
+ args[3] = implicit;
+ args[4] = style;
+
+ rb_protect(protected_start_mapping, (VALUE)args, &state);
+ }
+ break;
+ case YAML_MAPPING_END_EVENT:
+ rb_protect(protected_end_mapping, handler, &state);
+ break;
+ case YAML_NO_EVENT:
+ rb_protect(protected_empty, handler, &state);
+ break;
+ case YAML_STREAM_END_EVENT:
+ rb_protect(protected_end_stream, handler, &state);
+ done = 1;
+ break;
+ }
+ yaml_event_delete(&event);
+ if (state) rb_jump_tag(state);
+ }
+
+ return self;
+}
+
+/*
+ * call-seq:
+ * parser.mark # => #<Psych::Parser::Mark>
+ *
+ * Returns a Psych::Parser::Mark object that contains line, column, and index
+ * information.
+ */
+static VALUE mark(VALUE self)
+{
+ VALUE mark_klass;
+ VALUE args[3];
+ yaml_parser_t * parser;
+
+ TypedData_Get_Struct(self, yaml_parser_t, &psych_parser_type, parser);
+ mark_klass = rb_const_get_at(cPsychParser, rb_intern("Mark"));
+ args[0] = INT2NUM(parser->mark.index);
+ args[1] = INT2NUM(parser->mark.line);
+ args[2] = INT2NUM(parser->mark.column);
+
+ return rb_class_new_instance(3, args, mark_klass);
+}
+
+void Init_psych_parser(void)
+{
+#if 0
+ mPsych = rb_define_module("Psych");
+#endif
+
+ cPsychParser = rb_define_class_under(mPsych, "Parser", rb_cObject);
+ rb_define_alloc_func(cPsychParser, allocate);
+
+ /* Any encoding: Let the parser choose the encoding */
+ rb_define_const(cPsychParser, "ANY", INT2NUM(YAML_ANY_ENCODING));
+
+ /* UTF-8 Encoding */
+ rb_define_const(cPsychParser, "UTF8", INT2NUM(YAML_UTF8_ENCODING));
+
+ /* UTF-16-LE Encoding with BOM */
+ rb_define_const(cPsychParser, "UTF16LE", INT2NUM(YAML_UTF16LE_ENCODING));
+
+ /* UTF-16-BE Encoding with BOM */
+ rb_define_const(cPsychParser, "UTF16BE", INT2NUM(YAML_UTF16BE_ENCODING));
+
+ rb_require("psych/syntax_error");
+ ePsychSyntaxError = rb_const_get(mPsych, rb_intern("SyntaxError"));
+
+ rb_define_method(cPsychParser, "parse", parse, -1);
+ rb_define_method(cPsychParser, "mark", mark, 0);
+
+ id_read = rb_intern("read");
+ id_path = rb_intern("path");
+ id_empty = rb_intern("empty");
+ id_start_stream = rb_intern("start_stream");
+ id_end_stream = rb_intern("end_stream");
+ id_start_document = rb_intern("start_document");
+ id_end_document = rb_intern("end_document");
+ id_alias = rb_intern("alias");
+ id_scalar = rb_intern("scalar");
+ id_start_sequence = rb_intern("start_sequence");
+ id_end_sequence = rb_intern("end_sequence");
+ id_start_mapping = rb_intern("start_mapping");
+ id_end_mapping = rb_intern("end_mapping");
+}
+/* vim: set noet sws=4 sw=4: */
diff --git a/jni/ruby/ext/psych/psych_parser.h b/jni/ruby/ext/psych/psych_parser.h
new file mode 100644
index 0000000..beb3dd0
--- /dev/null
+++ b/jni/ruby/ext/psych/psych_parser.h
@@ -0,0 +1,6 @@
+#ifndef PSYCH_PARSER_H
+#define PSYCH_PARSER_H
+
+void Init_psych_parser(void);
+
+#endif
diff --git a/jni/ruby/ext/psych/psych_to_ruby.c b/jni/ruby/ext/psych/psych_to_ruby.c
new file mode 100644
index 0000000..3cc87a9
--- /dev/null
+++ b/jni/ruby/ext/psych/psych_to_ruby.c
@@ -0,0 +1,43 @@
+#include <psych.h>
+
+VALUE cPsychVisitorsToRuby;
+
+/* call-seq: vis.build_exception(klass, message)
+ *
+ * Create an exception with class +klass+ and +message+
+ */
+static VALUE build_exception(VALUE self, VALUE klass, VALUE mesg)
+{
+ VALUE e = rb_obj_alloc(klass);
+
+ rb_iv_set(e, "mesg", mesg);
+
+ return e;
+}
+
+/* call-seq: vis.path2class(path)
+ *
+ * Convert +path+ string to a class
+ */
+static VALUE path2class(VALUE self, VALUE path)
+{
+#ifdef HAVE_RUBY_ENCODING_H
+ return rb_path_to_class(path);
+#else
+ return rb_path2class(StringValuePtr(path));
+#endif
+}
+
+void Init_psych_to_ruby(void)
+{
+ VALUE psych = rb_define_module("Psych");
+ VALUE class_loader = rb_define_class_under(psych, "ClassLoader", rb_cObject);
+
+ VALUE visitors = rb_define_module_under(psych, "Visitors");
+ VALUE visitor = rb_define_class_under(visitors, "Visitor", rb_cObject);
+ cPsychVisitorsToRuby = rb_define_class_under(visitors, "ToRuby", visitor);
+
+ rb_define_private_method(cPsychVisitorsToRuby, "build_exception", build_exception, 2);
+ rb_define_private_method(class_loader, "path2class", path2class, 1);
+}
+/* vim: set noet sws=4 sw=4: */
diff --git a/jni/ruby/ext/psych/psych_to_ruby.h b/jni/ruby/ext/psych/psych_to_ruby.h
new file mode 100644
index 0000000..7b8e757
--- /dev/null
+++ b/jni/ruby/ext/psych/psych_to_ruby.h
@@ -0,0 +1,8 @@
+#ifndef PSYCH_TO_RUBY_H
+#define PSYCH_TO_RUBY_H
+
+#include <psych.h>
+
+void Init_psych_to_ruby(void);
+
+#endif
diff --git a/jni/ruby/ext/psych/psych_yaml_tree.c b/jni/ruby/ext/psych/psych_yaml_tree.c
new file mode 100644
index 0000000..bcf24d2
--- /dev/null
+++ b/jni/ruby/ext/psych/psych_yaml_tree.c
@@ -0,0 +1,24 @@
+#include <psych.h>
+
+VALUE cPsychVisitorsYamlTree;
+
+/*
+ * call-seq: private_iv_get(target, prop)
+ *
+ * Get the private instance variable +prop+ from +target+
+ */
+static VALUE private_iv_get(VALUE self, VALUE target, VALUE prop)
+{
+ return rb_attr_get(target, rb_intern(StringValuePtr(prop)));
+}
+
+void Init_psych_yaml_tree(void)
+{
+ VALUE psych = rb_define_module("Psych");
+ VALUE visitors = rb_define_module_under(psych, "Visitors");
+ VALUE visitor = rb_define_class_under(visitors, "Visitor", rb_cObject);
+ cPsychVisitorsYamlTree = rb_define_class_under(visitors, "YAMLTree", visitor);
+
+ rb_define_private_method(cPsychVisitorsYamlTree, "private_iv_get", private_iv_get, 2);
+}
+/* vim: set noet sws=4 sw=4: */
diff --git a/jni/ruby/ext/psych/psych_yaml_tree.h b/jni/ruby/ext/psych/psych_yaml_tree.h
new file mode 100644
index 0000000..4628a69
--- /dev/null
+++ b/jni/ruby/ext/psych/psych_yaml_tree.h
@@ -0,0 +1,8 @@
+#ifndef PSYCH_YAML_TREE_H
+#define PSYCH_YAML_TREE_H
+
+#include <psych.h>
+
+void Init_psych_yaml_tree(void);
+
+#endif
diff --git a/jni/ruby/ext/psych/yaml/LICENSE b/jni/ruby/ext/psych/yaml/LICENSE
new file mode 100644
index 0000000..050ced2
--- /dev/null
+++ b/jni/ruby/ext/psych/yaml/LICENSE
@@ -0,0 +1,19 @@
+Copyright (c) 2006 Kirill Simonov
+
+Permission is hereby granted, free of charge, to any person obtaining a copy of
+this software and associated documentation files (the "Software"), to deal in
+the Software without restriction, including without limitation the rights to
+use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
+of the Software, and to permit persons to whom the Software is furnished to do
+so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
diff --git a/jni/ruby/ext/psych/yaml/api.c b/jni/ruby/ext/psych/yaml/api.c
new file mode 100644
index 0000000..e0b9d97
--- /dev/null
+++ b/jni/ruby/ext/psych/yaml/api.c
@@ -0,0 +1,1415 @@
+
+#include "yaml_private.h"
+
+/*
+ * Get the library version.
+ */
+
+YAML_DECLARE(const char *)
+yaml_get_version_string(void)
+{
+ return YAML_VERSION_STRING;
+}
+
+/*
+ * Get the library version numbers.
+ */
+
+YAML_DECLARE(void)
+yaml_get_version(int *major, int *minor, int *patch)
+{
+ *major = YAML_VERSION_MAJOR;
+ *minor = YAML_VERSION_MINOR;
+ *patch = YAML_VERSION_PATCH;
+}
+
+/*
+ * Allocate a dynamic memory block.
+ */
+
+YAML_DECLARE(void *)
+yaml_malloc(size_t size)
+{
+ return malloc(size ? size : 1);
+}
+
+/*
+ * Reallocate a dynamic memory block.
+ */
+
+YAML_DECLARE(void *)
+yaml_realloc(void *ptr, size_t size)
+{
+ return ptr ? realloc(ptr, size ? size : 1) : malloc(size ? size : 1);
+}
+
+/*
+ * Free a dynamic memory block.
+ */
+
+YAML_DECLARE(void)
+yaml_free(void *ptr)
+{
+ if (ptr) free(ptr);
+}
+
+/*
+ * Duplicate a string.
+ */
+
+YAML_DECLARE(yaml_char_t *)
+yaml_strdup(const yaml_char_t *str)
+{
+ if (!str)
+ return NULL;
+
+ return (yaml_char_t *)strdup((char *)str);
+}
+
+/*
+ * Extend a string.
+ */
+
+YAML_DECLARE(int)
+yaml_string_extend(yaml_char_t **start,
+ yaml_char_t **pointer, yaml_char_t **end)
+{
+ yaml_char_t *new_start = yaml_realloc(*start, (*end - *start)*2);
+
+ if (!new_start) return 0;
+
+ memset(new_start + (*end - *start), 0, *end - *start);
+
+ *pointer = new_start + (*pointer - *start);
+ *end = new_start + (*end - *start)*2;
+ *start = new_start;
+
+ return 1;
+}
+
+/*
+ * Append a string B to a string A.
+ */
+
+YAML_DECLARE(int)
+yaml_string_join(
+ yaml_char_t **a_start, yaml_char_t **a_pointer, yaml_char_t **a_end,
+ yaml_char_t **b_start, yaml_char_t **b_pointer, yaml_char_t **b_end)
+{
+ if (*b_start == *b_pointer)
+ return 1;
+
+ while (*a_end - *a_pointer <= *b_pointer - *b_start) {
+ if (!yaml_string_extend(a_start, a_pointer, a_end))
+ return 0;
+ }
+
+ memcpy(*a_pointer, *b_start, *b_pointer - *b_start);
+ *a_pointer += *b_pointer - *b_start;
+
+ return 1;
+}
+
+/*
+ * Extend a stack.
+ */
+
+YAML_DECLARE(int)
+yaml_stack_extend(void **start, void **top, void **end)
+{
+ void *new_start = yaml_realloc(*start, ((char *)*end - (char *)*start)*2);
+
+ if (!new_start) return 0;
+
+ *top = (char *)new_start + ((char *)*top - (char *)*start);
+ *end = (char *)new_start + ((char *)*end - (char *)*start)*2;
+ *start = new_start;
+
+ return 1;
+}
+
+/*
+ * Extend or move a queue.
+ */
+
+YAML_DECLARE(int)
+yaml_queue_extend(void **start, void **head, void **tail, void **end)
+{
+ /* Check if we need to resize the queue. */
+
+ if (*start == *head && *tail == *end) {
+ void *new_start = yaml_realloc(*start,
+ ((char *)*end - (char *)*start)*2);
+
+ if (!new_start) return 0;
+
+ *head = (char *)new_start + ((char *)*head - (char *)*start);
+ *tail = (char *)new_start + ((char *)*tail - (char *)*start);
+ *end = (char *)new_start + ((char *)*end - (char *)*start)*2;
+ *start = new_start;
+ }
+
+ /* Check if we need to move the queue at the beginning of the buffer. */
+
+ if (*tail == *end) {
+ if (*head != *tail) {
+ memmove(*start, *head, (char *)*tail - (char *)*head);
+ }
+ *tail = (char *)*tail - (char *)*head + (char *)*start;
+ *head = *start;
+ }
+
+ return 1;
+}
+
+
+/*
+ * Create a new parser object.
+ */
+
+YAML_DECLARE(int)
+yaml_parser_initialize(yaml_parser_t *parser)
+{
+ assert(parser); /* Non-NULL parser object expected. */
+
+ memset(parser, 0, sizeof(yaml_parser_t));
+ if (!BUFFER_INIT(parser, parser->raw_buffer, INPUT_RAW_BUFFER_SIZE))
+ goto error;
+ if (!BUFFER_INIT(parser, parser->buffer, INPUT_BUFFER_SIZE))
+ goto error;
+ if (!QUEUE_INIT(parser, parser->tokens, INITIAL_QUEUE_SIZE))
+ goto error;
+ if (!STACK_INIT(parser, parser->indents, INITIAL_STACK_SIZE))
+ goto error;
+ if (!STACK_INIT(parser, parser->simple_keys, INITIAL_STACK_SIZE))
+ goto error;
+ if (!STACK_INIT(parser, parser->states, INITIAL_STACK_SIZE))
+ goto error;
+ if (!STACK_INIT(parser, parser->marks, INITIAL_STACK_SIZE))
+ goto error;
+ if (!STACK_INIT(parser, parser->tag_directives, INITIAL_STACK_SIZE))
+ goto error;
+
+ return 1;
+
+error:
+
+ BUFFER_DEL(parser, parser->raw_buffer);
+ BUFFER_DEL(parser, parser->buffer);
+ QUEUE_DEL(parser, parser->tokens);
+ STACK_DEL(parser, parser->indents);
+ STACK_DEL(parser, parser->simple_keys);
+ STACK_DEL(parser, parser->states);
+ STACK_DEL(parser, parser->marks);
+ STACK_DEL(parser, parser->tag_directives);
+
+ return 0;
+}
+
+/*
+ * Destroy a parser object.
+ */
+
+YAML_DECLARE(void)
+yaml_parser_delete(yaml_parser_t *parser)
+{
+ assert(parser); /* Non-NULL parser object expected. */
+
+ BUFFER_DEL(parser, parser->raw_buffer);
+ BUFFER_DEL(parser, parser->buffer);
+ while (!QUEUE_EMPTY(parser, parser->tokens)) {
+ yaml_token_delete(&DEQUEUE(parser, parser->tokens));
+ }
+ QUEUE_DEL(parser, parser->tokens);
+ STACK_DEL(parser, parser->indents);
+ STACK_DEL(parser, parser->simple_keys);
+ STACK_DEL(parser, parser->states);
+ STACK_DEL(parser, parser->marks);
+ while (!STACK_EMPTY(parser, parser->tag_directives)) {
+ yaml_tag_directive_t tag_directive = POP(parser, parser->tag_directives);
+ yaml_free(tag_directive.handle);
+ yaml_free(tag_directive.prefix);
+ }
+ STACK_DEL(parser, parser->tag_directives);
+
+ memset(parser, 0, sizeof(yaml_parser_t));
+}
+
+/*
+ * String read handler.
+ */
+
+static int
+yaml_string_read_handler(void *data, unsigned char *buffer, size_t size,
+ size_t *size_read)
+{
+ yaml_parser_t *parser = data;
+
+ if (parser->input.string.current == parser->input.string.end) {
+ *size_read = 0;
+ return 1;
+ }
+
+ if (size > (size_t)(parser->input.string.end
+ - parser->input.string.current)) {
+ size = parser->input.string.end - parser->input.string.current;
+ }
+
+ memcpy(buffer, parser->input.string.current, size);
+ parser->input.string.current += size;
+ *size_read = size;
+ return 1;
+}
+
+/*
+ * File read handler.
+ */
+
+static int
+yaml_file_read_handler(void *data, unsigned char *buffer, size_t size,
+ size_t *size_read)
+{
+ yaml_parser_t *parser = data;
+
+ *size_read = fread(buffer, 1, size, parser->input.file);
+ return !ferror(parser->input.file);
+}
+
+/*
+ * Set a string input.
+ */
+
+YAML_DECLARE(void)
+yaml_parser_set_input_string(yaml_parser_t *parser,
+ const unsigned char *input, size_t size)
+{
+ assert(parser); /* Non-NULL parser object expected. */
+ assert(!parser->read_handler); /* You can set the source only once. */
+ assert(input); /* Non-NULL input string expected. */
+
+ parser->read_handler = yaml_string_read_handler;
+ parser->read_handler_data = parser;
+
+ parser->input.string.start = input;
+ parser->input.string.current = input;
+ parser->input.string.end = input+size;
+}
+
+/*
+ * Set a file input.
+ */
+
+YAML_DECLARE(void)
+yaml_parser_set_input_file(yaml_parser_t *parser, FILE *file)
+{
+ assert(parser); /* Non-NULL parser object expected. */
+ assert(!parser->read_handler); /* You can set the source only once. */
+ assert(file); /* Non-NULL file object expected. */
+
+ parser->read_handler = yaml_file_read_handler;
+ parser->read_handler_data = parser;
+
+ parser->input.file = file;
+}
+
+/*
+ * Set a generic input.
+ */
+
+YAML_DECLARE(void)
+yaml_parser_set_input(yaml_parser_t *parser,
+ yaml_read_handler_t *handler, void *data)
+{
+ assert(parser); /* Non-NULL parser object expected. */
+ assert(!parser->read_handler); /* You can set the source only once. */
+ assert(handler); /* Non-NULL read handler expected. */
+
+ parser->read_handler = handler;
+ parser->read_handler_data = data;
+}
+
+/*
+ * Set the source encoding.
+ */
+
+YAML_DECLARE(void)
+yaml_parser_set_encoding(yaml_parser_t *parser, yaml_encoding_t encoding)
+{
+ assert(parser); /* Non-NULL parser object expected. */
+ assert(!parser->encoding); /* Encoding is already set or detected. */
+
+ parser->encoding = encoding;
+}
+
+/*
+ * Create a new emitter object.
+ */
+
+YAML_DECLARE(int)
+yaml_emitter_initialize(yaml_emitter_t *emitter)
+{
+ assert(emitter); /* Non-NULL emitter object expected. */
+
+ memset(emitter, 0, sizeof(yaml_emitter_t));
+ if (!BUFFER_INIT(emitter, emitter->buffer, OUTPUT_BUFFER_SIZE))
+ goto error;
+ if (!BUFFER_INIT(emitter, emitter->raw_buffer, OUTPUT_RAW_BUFFER_SIZE))
+ goto error;
+ if (!STACK_INIT(emitter, emitter->states, INITIAL_STACK_SIZE))
+ goto error;
+ if (!QUEUE_INIT(emitter, emitter->events, INITIAL_QUEUE_SIZE))
+ goto error;
+ if (!STACK_INIT(emitter, emitter->indents, INITIAL_STACK_SIZE))
+ goto error;
+ if (!STACK_INIT(emitter, emitter->tag_directives, INITIAL_STACK_SIZE))
+ goto error;
+
+ return 1;
+
+error:
+
+ BUFFER_DEL(emitter, emitter->buffer);
+ BUFFER_DEL(emitter, emitter->raw_buffer);
+ STACK_DEL(emitter, emitter->states);
+ QUEUE_DEL(emitter, emitter->events);
+ STACK_DEL(emitter, emitter->indents);
+ STACK_DEL(emitter, emitter->tag_directives);
+
+ return 0;
+}
+
+/*
+ * Destroy an emitter object.
+ */
+
+YAML_DECLARE(void)
+yaml_emitter_delete(yaml_emitter_t *emitter)
+{
+ assert(emitter); /* Non-NULL emitter object expected. */
+
+ BUFFER_DEL(emitter, emitter->buffer);
+ BUFFER_DEL(emitter, emitter->raw_buffer);
+ STACK_DEL(emitter, emitter->states);
+ while (!QUEUE_EMPTY(emitter, emitter->events)) {
+ yaml_event_delete(&DEQUEUE(emitter, emitter->events));
+ }
+ QUEUE_DEL(emitter, emitter->events);
+ STACK_DEL(emitter, emitter->indents);
+ while (!STACK_EMPTY(emitter, emitter->tag_directives)) {
+ yaml_tag_directive_t tag_directive = POP(emitter, emitter->tag_directives);
+ yaml_free(tag_directive.handle);
+ yaml_free(tag_directive.prefix);
+ }
+ STACK_DEL(emitter, emitter->tag_directives);
+ yaml_free(emitter->anchors);
+
+ memset(emitter, 0, sizeof(yaml_emitter_t));
+}
+
+/*
+ * String write handler.
+ */
+
+static int
+yaml_string_write_handler(void *data, unsigned char *buffer, size_t size)
+{
+ yaml_emitter_t *emitter = data;
+
+ if (emitter->output.string.size + *emitter->output.string.size_written
+ < size) {
+ memcpy(emitter->output.string.buffer
+ + *emitter->output.string.size_written,
+ buffer,
+ emitter->output.string.size
+ - *emitter->output.string.size_written);
+ *emitter->output.string.size_written = emitter->output.string.size;
+ return 0;
+ }
+
+ memcpy(emitter->output.string.buffer
+ + *emitter->output.string.size_written, buffer, size);
+ *emitter->output.string.size_written += size;
+ return 1;
+}
+
+/*
+ * File write handler.
+ */
+
+static int
+yaml_file_write_handler(void *data, unsigned char *buffer, size_t size)
+{
+ yaml_emitter_t *emitter = data;
+
+ return (fwrite(buffer, 1, size, emitter->output.file) == size);
+}
+/*
+ * Set a string output.
+ */
+
+YAML_DECLARE(void)
+yaml_emitter_set_output_string(yaml_emitter_t *emitter,
+ unsigned char *output, size_t size, size_t *size_written)
+{
+ assert(emitter); /* Non-NULL emitter object expected. */
+ assert(!emitter->write_handler); /* You can set the output only once. */
+ assert(output); /* Non-NULL output string expected. */
+
+ emitter->write_handler = yaml_string_write_handler;
+ emitter->write_handler_data = emitter;
+
+ emitter->output.string.buffer = output;
+ emitter->output.string.size = size;
+ emitter->output.string.size_written = size_written;
+ *size_written = 0;
+}
+
+/*
+ * Set a file output.
+ */
+
+YAML_DECLARE(void)
+yaml_emitter_set_output_file(yaml_emitter_t *emitter, FILE *file)
+{
+ assert(emitter); /* Non-NULL emitter object expected. */
+ assert(!emitter->write_handler); /* You can set the output only once. */
+ assert(file); /* Non-NULL file object expected. */
+
+ emitter->write_handler = yaml_file_write_handler;
+ emitter->write_handler_data = emitter;
+
+ emitter->output.file = file;
+}
+
+/*
+ * Set a generic output handler.
+ */
+
+YAML_DECLARE(void)
+yaml_emitter_set_output(yaml_emitter_t *emitter,
+ yaml_write_handler_t *handler, void *data)
+{
+ assert(emitter); /* Non-NULL emitter object expected. */
+ assert(!emitter->write_handler); /* You can set the output only once. */
+ assert(handler); /* Non-NULL handler object expected. */
+
+ emitter->write_handler = handler;
+ emitter->write_handler_data = data;
+}
+
+/*
+ * Set the output encoding.
+ */
+
+YAML_DECLARE(void)
+yaml_emitter_set_encoding(yaml_emitter_t *emitter, yaml_encoding_t encoding)
+{
+ assert(emitter); /* Non-NULL emitter object expected. */
+ assert(!emitter->encoding); /* You can set encoding only once. */
+
+ emitter->encoding = encoding;
+}
+
+/*
+ * Set the canonical output style.
+ */
+
+YAML_DECLARE(void)
+yaml_emitter_set_canonical(yaml_emitter_t *emitter, int canonical)
+{
+ assert(emitter); /* Non-NULL emitter object expected. */
+
+ emitter->canonical = (canonical != 0);
+}
+
+/*
+ * Set the indentation increment.
+ */
+
+YAML_DECLARE(void)
+yaml_emitter_set_indent(yaml_emitter_t *emitter, int indent)
+{
+ assert(emitter); /* Non-NULL emitter object expected. */
+
+ emitter->best_indent = (1 < indent && indent < 10) ? indent : 2;
+}
+
+/*
+ * Set the preferred line width.
+ */
+
+YAML_DECLARE(void)
+yaml_emitter_set_width(yaml_emitter_t *emitter, int width)
+{
+ assert(emitter); /* Non-NULL emitter object expected. */
+
+ emitter->best_width = (width >= 0) ? width : -1;
+}
+
+/*
+ * Set if unescaped non-ASCII characters are allowed.
+ */
+
+YAML_DECLARE(void)
+yaml_emitter_set_unicode(yaml_emitter_t *emitter, int unicode)
+{
+ assert(emitter); /* Non-NULL emitter object expected. */
+
+ emitter->unicode = (unicode != 0);
+}
+
+/*
+ * Set the preferred line break character.
+ */
+
+YAML_DECLARE(void)
+yaml_emitter_set_break(yaml_emitter_t *emitter, yaml_break_t line_break)
+{
+ assert(emitter); /* Non-NULL emitter object expected. */
+
+ emitter->line_break = line_break;
+}
+
+/*
+ * Destroy a token object.
+ */
+
+YAML_DECLARE(void)
+yaml_token_delete(yaml_token_t *token)
+{
+ assert(token); /* Non-NULL token object expected. */
+
+ switch (token->type)
+ {
+ case YAML_TAG_DIRECTIVE_TOKEN:
+ yaml_free(token->data.tag_directive.handle);
+ yaml_free(token->data.tag_directive.prefix);
+ break;
+
+ case YAML_ALIAS_TOKEN:
+ yaml_free(token->data.alias.value);
+ break;
+
+ case YAML_ANCHOR_TOKEN:
+ yaml_free(token->data.anchor.value);
+ break;
+
+ case YAML_TAG_TOKEN:
+ yaml_free(token->data.tag.handle);
+ yaml_free(token->data.tag.suffix);
+ break;
+
+ case YAML_SCALAR_TOKEN:
+ yaml_free(token->data.scalar.value);
+ break;
+
+ default:
+ break;
+ }
+
+ memset(token, 0, sizeof(yaml_token_t));
+}
+
+/*
+ * Check if a string is a valid UTF-8 sequence.
+ *
+ * Check 'reader.c' for more details on UTF-8 encoding.
+ */
+
+static int
+yaml_check_utf8(yaml_char_t *start, size_t length)
+{
+ yaml_char_t *end = start+length;
+ yaml_char_t *pointer = start;
+
+ while (pointer < end) {
+ unsigned char octet;
+ unsigned int width;
+ unsigned int value;
+ size_t k;
+
+ octet = pointer[0];
+ width = (octet & 0x80) == 0x00 ? 1 :
+ (octet & 0xE0) == 0xC0 ? 2 :
+ (octet & 0xF0) == 0xE0 ? 3 :
+ (octet & 0xF8) == 0xF0 ? 4 : 0;
+ value = (octet & 0x80) == 0x00 ? octet & 0x7F :
+ (octet & 0xE0) == 0xC0 ? octet & 0x1F :
+ (octet & 0xF0) == 0xE0 ? octet & 0x0F :
+ (octet & 0xF8) == 0xF0 ? octet & 0x07 : 0;
+ if (!width) return 0;
+ if (pointer+width > end) return 0;
+ for (k = 1; k < width; k ++) {
+ octet = pointer[k];
+ if ((octet & 0xC0) != 0x80) return 0;
+ value = (value << 6) + (octet & 0x3F);
+ }
+ if (!((width == 1) ||
+ (width == 2 && value >= 0x80) ||
+ (width == 3 && value >= 0x800) ||
+ (width == 4 && value >= 0x10000))) return 0;
+
+ pointer += width;
+ }
+
+ return 1;
+}
+
+/*
+ * Create STREAM-START.
+ */
+
+YAML_DECLARE(int)
+yaml_stream_start_event_initialize(yaml_event_t *event,
+ yaml_encoding_t encoding)
+{
+ yaml_mark_t mark = { 0, 0, 0 };
+
+ assert(event); /* Non-NULL event object is expected. */
+
+ STREAM_START_EVENT_INIT(*event, encoding, mark, mark);
+
+ return 1;
+}
+
+/*
+ * Create STREAM-END.
+ */
+
+YAML_DECLARE(int)
+yaml_stream_end_event_initialize(yaml_event_t *event)
+{
+ yaml_mark_t mark = { 0, 0, 0 };
+
+ assert(event); /* Non-NULL event object is expected. */
+
+ STREAM_END_EVENT_INIT(*event, mark, mark);
+
+ return 1;
+}
+
+/*
+ * Create DOCUMENT-START.
+ */
+
+YAML_DECLARE(int)
+yaml_document_start_event_initialize(yaml_event_t *event,
+ yaml_version_directive_t *version_directive,
+ yaml_tag_directive_t *tag_directives_start,
+ yaml_tag_directive_t *tag_directives_end,
+ int implicit)
+{
+ struct {
+ yaml_error_type_t error;
+ } context;
+ yaml_mark_t mark = { 0, 0, 0 };
+ yaml_version_directive_t *version_directive_copy = NULL;
+ struct {
+ yaml_tag_directive_t *start;
+ yaml_tag_directive_t *end;
+ yaml_tag_directive_t *top;
+ } tag_directives_copy = { NULL, NULL, NULL };
+ yaml_tag_directive_t value = { NULL, NULL };
+
+ assert(event); /* Non-NULL event object is expected. */
+ assert((tag_directives_start && tag_directives_end) ||
+ (tag_directives_start == tag_directives_end));
+ /* Valid tag directives are expected. */
+
+ if (version_directive) {
+ version_directive_copy = yaml_malloc(sizeof(yaml_version_directive_t));
+ if (!version_directive_copy) goto error;
+ version_directive_copy->major = version_directive->major;
+ version_directive_copy->minor = version_directive->minor;
+ }
+
+ if (tag_directives_start != tag_directives_end) {
+ yaml_tag_directive_t *tag_directive;
+ if (!STACK_INIT(&context, tag_directives_copy, INITIAL_STACK_SIZE))
+ goto error;
+ for (tag_directive = tag_directives_start;
+ tag_directive != tag_directives_end; tag_directive ++) {
+ assert(tag_directive->handle);
+ assert(tag_directive->prefix);
+ if (!yaml_check_utf8(tag_directive->handle,
+ strlen((char *)tag_directive->handle)))
+ goto error;
+ if (!yaml_check_utf8(tag_directive->prefix,
+ strlen((char *)tag_directive->prefix)))
+ goto error;
+ value.handle = yaml_strdup(tag_directive->handle);
+ value.prefix = yaml_strdup(tag_directive->prefix);
+ if (!value.handle || !value.prefix) goto error;
+ if (!PUSH(&context, tag_directives_copy, value))
+ goto error;
+ value.handle = NULL;
+ value.prefix = NULL;
+ }
+ }
+
+ DOCUMENT_START_EVENT_INIT(*event, version_directive_copy,
+ tag_directives_copy.start, tag_directives_copy.top,
+ implicit, mark, mark);
+
+ return 1;
+
+error:
+ yaml_free(version_directive_copy);
+ while (!STACK_EMPTY(context, tag_directives_copy)) {
+ yaml_tag_directive_t value = POP(context, tag_directives_copy);
+ yaml_free(value.handle);
+ yaml_free(value.prefix);
+ }
+ STACK_DEL(context, tag_directives_copy);
+ yaml_free(value.handle);
+ yaml_free(value.prefix);
+
+ return 0;
+}
+
+/*
+ * Create DOCUMENT-END.
+ */
+
+YAML_DECLARE(int)
+yaml_document_end_event_initialize(yaml_event_t *event, int implicit)
+{
+ yaml_mark_t mark = { 0, 0, 0 };
+
+ assert(event); /* Non-NULL emitter object is expected. */
+
+ DOCUMENT_END_EVENT_INIT(*event, implicit, mark, mark);
+
+ return 1;
+}
+
+/*
+ * Create ALIAS.
+ */
+
+YAML_DECLARE(int)
+yaml_alias_event_initialize(yaml_event_t *event, yaml_char_t *anchor)
+{
+ yaml_mark_t mark = { 0, 0, 0 };
+ yaml_char_t *anchor_copy = NULL;
+
+ assert(event); /* Non-NULL event object is expected. */
+ assert(anchor); /* Non-NULL anchor is expected. */
+
+ if (!yaml_check_utf8(anchor, strlen((char *)anchor))) return 0;
+
+ anchor_copy = yaml_strdup(anchor);
+ if (!anchor_copy)
+ return 0;
+
+ ALIAS_EVENT_INIT(*event, anchor_copy, mark, mark);
+
+ return 1;
+}
+
+/*
+ * Create SCALAR.
+ */
+
+YAML_DECLARE(int)
+yaml_scalar_event_initialize(yaml_event_t *event,
+ yaml_char_t *anchor, yaml_char_t *tag,
+ yaml_char_t *value, int length,
+ int plain_implicit, int quoted_implicit,
+ yaml_scalar_style_t style)
+{
+ yaml_mark_t mark = { 0, 0, 0 };
+ yaml_char_t *anchor_copy = NULL;
+ yaml_char_t *tag_copy = NULL;
+ yaml_char_t *value_copy = NULL;
+ size_t value_length;
+
+ assert(event); /* Non-NULL event object is expected. */
+ assert(value); /* Non-NULL anchor is expected. */
+
+ if (anchor) {
+ if (!yaml_check_utf8(anchor, strlen((char *)anchor))) goto error;
+ anchor_copy = yaml_strdup(anchor);
+ if (!anchor_copy) goto error;
+ }
+
+ if (tag) {
+ if (!yaml_check_utf8(tag, strlen((char *)tag))) goto error;
+ tag_copy = yaml_strdup(tag);
+ if (!tag_copy) goto error;
+ }
+
+ if (length < 0) {
+ value_length = strlen((char *)value);
+ }
+ else {
+ value_length = (size_t)length;
+ }
+
+ if (!yaml_check_utf8(value, value_length)) goto error;
+ value_copy = yaml_malloc(value_length+1);
+ if (!value_copy) goto error;
+ memcpy(value_copy, value, value_length);
+ value_copy[value_length] = '\0';
+
+ SCALAR_EVENT_INIT(*event, anchor_copy, tag_copy, value_copy, value_length,
+ plain_implicit, quoted_implicit, style, mark, mark);
+
+ return 1;
+
+error:
+ yaml_free(anchor_copy);
+ yaml_free(tag_copy);
+ yaml_free(value_copy);
+
+ return 0;
+}
+
+/*
+ * Create SEQUENCE-START.
+ */
+
+YAML_DECLARE(int)
+yaml_sequence_start_event_initialize(yaml_event_t *event,
+ yaml_char_t *anchor, yaml_char_t *tag, int implicit,
+ yaml_sequence_style_t style)
+{
+ yaml_mark_t mark = { 0, 0, 0 };
+ yaml_char_t *anchor_copy = NULL;
+ yaml_char_t *tag_copy = NULL;
+
+ assert(event); /* Non-NULL event object is expected. */
+
+ if (anchor) {
+ if (!yaml_check_utf8(anchor, strlen((char *)anchor))) goto error;
+ anchor_copy = yaml_strdup(anchor);
+ if (!anchor_copy) goto error;
+ }
+
+ if (tag) {
+ if (!yaml_check_utf8(tag, strlen((char *)tag))) goto error;
+ tag_copy = yaml_strdup(tag);
+ if (!tag_copy) goto error;
+ }
+
+ SEQUENCE_START_EVENT_INIT(*event, anchor_copy, tag_copy,
+ implicit, style, mark, mark);
+
+ return 1;
+
+error:
+ yaml_free(anchor_copy);
+ yaml_free(tag_copy);
+
+ return 0;
+}
+
+/*
+ * Create SEQUENCE-END.
+ */
+
+YAML_DECLARE(int)
+yaml_sequence_end_event_initialize(yaml_event_t *event)
+{
+ yaml_mark_t mark = { 0, 0, 0 };
+
+ assert(event); /* Non-NULL event object is expected. */
+
+ SEQUENCE_END_EVENT_INIT(*event, mark, mark);
+
+ return 1;
+}
+
+/*
+ * Create MAPPING-START.
+ */
+
+YAML_DECLARE(int)
+yaml_mapping_start_event_initialize(yaml_event_t *event,
+ yaml_char_t *anchor, yaml_char_t *tag, int implicit,
+ yaml_mapping_style_t style)
+{
+ yaml_mark_t mark = { 0, 0, 0 };
+ yaml_char_t *anchor_copy = NULL;
+ yaml_char_t *tag_copy = NULL;
+
+ assert(event); /* Non-NULL event object is expected. */
+
+ if (anchor) {
+ if (!yaml_check_utf8(anchor, strlen((char *)anchor))) goto error;
+ anchor_copy = yaml_strdup(anchor);
+ if (!anchor_copy) goto error;
+ }
+
+ if (tag) {
+ if (!yaml_check_utf8(tag, strlen((char *)tag))) goto error;
+ tag_copy = yaml_strdup(tag);
+ if (!tag_copy) goto error;
+ }
+
+ MAPPING_START_EVENT_INIT(*event, anchor_copy, tag_copy,
+ implicit, style, mark, mark);
+
+ return 1;
+
+error:
+ yaml_free(anchor_copy);
+ yaml_free(tag_copy);
+
+ return 0;
+}
+
+/*
+ * Create MAPPING-END.
+ */
+
+YAML_DECLARE(int)
+yaml_mapping_end_event_initialize(yaml_event_t *event)
+{
+ yaml_mark_t mark = { 0, 0, 0 };
+
+ assert(event); /* Non-NULL event object is expected. */
+
+ MAPPING_END_EVENT_INIT(*event, mark, mark);
+
+ return 1;
+}
+
+/*
+ * Destroy an event object.
+ */
+
+YAML_DECLARE(void)
+yaml_event_delete(yaml_event_t *event)
+{
+ yaml_tag_directive_t *tag_directive;
+
+ assert(event); /* Non-NULL event object expected. */
+
+ switch (event->type)
+ {
+ case YAML_DOCUMENT_START_EVENT:
+ yaml_free(event->data.document_start.version_directive);
+ for (tag_directive = event->data.document_start.tag_directives.start;
+ tag_directive != event->data.document_start.tag_directives.end;
+ tag_directive++) {
+ yaml_free(tag_directive->handle);
+ yaml_free(tag_directive->prefix);
+ }
+ yaml_free(event->data.document_start.tag_directives.start);
+ break;
+
+ case YAML_ALIAS_EVENT:
+ yaml_free(event->data.alias.anchor);
+ break;
+
+ case YAML_SCALAR_EVENT:
+ yaml_free(event->data.scalar.anchor);
+ yaml_free(event->data.scalar.tag);
+ yaml_free(event->data.scalar.value);
+ break;
+
+ case YAML_SEQUENCE_START_EVENT:
+ yaml_free(event->data.sequence_start.anchor);
+ yaml_free(event->data.sequence_start.tag);
+ break;
+
+ case YAML_MAPPING_START_EVENT:
+ yaml_free(event->data.mapping_start.anchor);
+ yaml_free(event->data.mapping_start.tag);
+ break;
+
+ default:
+ break;
+ }
+
+ memset(event, 0, sizeof(yaml_event_t));
+}
+
+/*
+ * Create a document object.
+ */
+
+YAML_DECLARE(int)
+yaml_document_initialize(yaml_document_t *document,
+ yaml_version_directive_t *version_directive,
+ yaml_tag_directive_t *tag_directives_start,
+ yaml_tag_directive_t *tag_directives_end,
+ int start_implicit, int end_implicit)
+{
+ struct {
+ yaml_error_type_t error;
+ } context;
+ struct {
+ yaml_node_t *start;
+ yaml_node_t *end;
+ yaml_node_t *top;
+ } nodes = { NULL, NULL, NULL };
+ yaml_version_directive_t *version_directive_copy = NULL;
+ struct {
+ yaml_tag_directive_t *start;
+ yaml_tag_directive_t *end;
+ yaml_tag_directive_t *top;
+ } tag_directives_copy = { NULL, NULL, NULL };
+ yaml_tag_directive_t value = { NULL, NULL };
+ yaml_mark_t mark = { 0, 0, 0 };
+
+ assert(document); /* Non-NULL document object is expected. */
+ assert((tag_directives_start && tag_directives_end) ||
+ (tag_directives_start == tag_directives_end));
+ /* Valid tag directives are expected. */
+
+ if (!STACK_INIT(&context, nodes, INITIAL_STACK_SIZE)) goto error;
+
+ if (version_directive) {
+ version_directive_copy = yaml_malloc(sizeof(yaml_version_directive_t));
+ if (!version_directive_copy) goto error;
+ version_directive_copy->major = version_directive->major;
+ version_directive_copy->minor = version_directive->minor;
+ }
+
+ if (tag_directives_start != tag_directives_end) {
+ yaml_tag_directive_t *tag_directive;
+ if (!STACK_INIT(&context, tag_directives_copy, INITIAL_STACK_SIZE))
+ goto error;
+ for (tag_directive = tag_directives_start;
+ tag_directive != tag_directives_end; tag_directive ++) {
+ assert(tag_directive->handle);
+ assert(tag_directive->prefix);
+ if (!yaml_check_utf8(tag_directive->handle,
+ strlen((char *)tag_directive->handle)))
+ goto error;
+ if (!yaml_check_utf8(tag_directive->prefix,
+ strlen((char *)tag_directive->prefix)))
+ goto error;
+ value.handle = yaml_strdup(tag_directive->handle);
+ value.prefix = yaml_strdup(tag_directive->prefix);
+ if (!value.handle || !value.prefix) goto error;
+ if (!PUSH(&context, tag_directives_copy, value))
+ goto error;
+ value.handle = NULL;
+ value.prefix = NULL;
+ }
+ }
+
+ DOCUMENT_INIT(*document, nodes.start, nodes.end, version_directive_copy,
+ tag_directives_copy.start, tag_directives_copy.top,
+ start_implicit, end_implicit, mark, mark);
+
+ return 1;
+
+error:
+ STACK_DEL(&context, nodes);
+ yaml_free(version_directive_copy);
+ while (!STACK_EMPTY(&context, tag_directives_copy)) {
+ yaml_tag_directive_t value = POP(&context, tag_directives_copy);
+ yaml_free(value.handle);
+ yaml_free(value.prefix);
+ }
+ STACK_DEL(&context, tag_directives_copy);
+ yaml_free(value.handle);
+ yaml_free(value.prefix);
+
+ return 0;
+}
+
+/*
+ * Destroy a document object.
+ */
+
+YAML_DECLARE(void)
+yaml_document_delete(yaml_document_t *document)
+{
+ struct {
+ yaml_error_type_t error;
+ } context;
+ yaml_tag_directive_t *tag_directive;
+
+ context.error = YAML_NO_ERROR; /* Eliminate a compliler warning. */
+
+ assert(document); /* Non-NULL document object is expected. */
+
+ while (!STACK_EMPTY(&context, document->nodes)) {
+ yaml_node_t node = POP(&context, document->nodes);
+ yaml_free(node.tag);
+ switch (node.type) {
+ case YAML_SCALAR_NODE:
+ yaml_free(node.data.scalar.value);
+ break;
+ case YAML_SEQUENCE_NODE:
+ STACK_DEL(&context, node.data.sequence.items);
+ break;
+ case YAML_MAPPING_NODE:
+ STACK_DEL(&context, node.data.mapping.pairs);
+ break;
+ default:
+ assert(0); /* Should not happen. */
+ }
+ }
+ STACK_DEL(&context, document->nodes);
+
+ yaml_free(document->version_directive);
+ for (tag_directive = document->tag_directives.start;
+ tag_directive != document->tag_directives.end;
+ tag_directive++) {
+ yaml_free(tag_directive->handle);
+ yaml_free(tag_directive->prefix);
+ }
+ yaml_free(document->tag_directives.start);
+
+ memset(document, 0, sizeof(yaml_document_t));
+}
+
+/**
+ * Get a document node.
+ */
+
+YAML_DECLARE(yaml_node_t *)
+yaml_document_get_node(yaml_document_t *document, int index)
+{
+ assert(document); /* Non-NULL document object is expected. */
+
+ if (index > 0 && document->nodes.start + index <= document->nodes.top) {
+ return document->nodes.start + index - 1;
+ }
+ return NULL;
+}
+
+/**
+ * Get the root object.
+ */
+
+YAML_DECLARE(yaml_node_t *)
+yaml_document_get_root_node(yaml_document_t *document)
+{
+ assert(document); /* Non-NULL document object is expected. */
+
+ if (document->nodes.top != document->nodes.start) {
+ return document->nodes.start;
+ }
+ return NULL;
+}
+
+/*
+ * Add a scalar node to a document.
+ */
+
+YAML_DECLARE(int)
+yaml_document_add_scalar(yaml_document_t *document,
+ yaml_char_t *tag, yaml_char_t *value, int length,
+ yaml_scalar_style_t style)
+{
+ struct {
+ yaml_error_type_t error;
+ } context;
+ yaml_mark_t mark = { 0, 0, 0 };
+ yaml_char_t *tag_copy = NULL;
+ yaml_char_t *value_copy = NULL;
+ yaml_node_t node;
+ size_t value_length;
+ ptrdiff_t ret;
+
+ assert(document); /* Non-NULL document object is expected. */
+ assert(value); /* Non-NULL value is expected. */
+
+ if (!tag) {
+ tag = (yaml_char_t *)YAML_DEFAULT_SCALAR_TAG;
+ }
+
+ if (!yaml_check_utf8(tag, strlen((char *)tag))) goto error;
+ tag_copy = yaml_strdup(tag);
+ if (!tag_copy) goto error;
+
+ if (length < 0) {
+ value_length = strlen((char *)value);
+ }
+ else {
+ value_length = (size_t)length;
+ }
+
+ if (!yaml_check_utf8(value, value_length)) goto error;
+ value_copy = yaml_malloc(value_length+1);
+ if (!value_copy) goto error;
+ memcpy(value_copy, value, value_length);
+ value_copy[value_length] = '\0';
+
+ SCALAR_NODE_INIT(node, tag_copy, value_copy, value_length, style, mark, mark);
+ if (!PUSH(&context, document->nodes, node)) goto error;
+
+ ret = document->nodes.top - document->nodes.start;
+#if PTRDIFF_MAX > INT_MAX
+ if (ret > INT_MAX) goto error;
+#endif
+ return (int)ret;
+
+error:
+ yaml_free(tag_copy);
+ yaml_free(value_copy);
+
+ return 0;
+}
+
+/*
+ * Add a sequence node to a document.
+ */
+
+YAML_DECLARE(int)
+yaml_document_add_sequence(yaml_document_t *document,
+ yaml_char_t *tag, yaml_sequence_style_t style)
+{
+ struct {
+ yaml_error_type_t error;
+ } context;
+ yaml_mark_t mark = { 0, 0, 0 };
+ yaml_char_t *tag_copy = NULL;
+ struct {
+ yaml_node_item_t *start;
+ yaml_node_item_t *end;
+ yaml_node_item_t *top;
+ } items = { NULL, NULL, NULL };
+ yaml_node_t node;
+ ptrdiff_t ret;
+
+ assert(document); /* Non-NULL document object is expected. */
+
+ if (!tag) {
+ tag = (yaml_char_t *)YAML_DEFAULT_SEQUENCE_TAG;
+ }
+
+ if (!yaml_check_utf8(tag, strlen((char *)tag))) goto error;
+ tag_copy = yaml_strdup(tag);
+ if (!tag_copy) goto error;
+
+ if (!STACK_INIT(&context, items, INITIAL_STACK_SIZE)) goto error;
+
+ SEQUENCE_NODE_INIT(node, tag_copy, items.start, items.end,
+ style, mark, mark);
+ if (!PUSH(&context, document->nodes, node)) goto error;
+
+ ret = document->nodes.top - document->nodes.start;
+#if PTRDIFF_MAX > INT_MAX
+ if (ret > INT_MAX) goto error;
+#endif
+ return (int)ret;
+
+error:
+ STACK_DEL(&context, items);
+ yaml_free(tag_copy);
+
+ return 0;
+}
+
+/*
+ * Add a mapping node to a document.
+ */
+
+YAML_DECLARE(int)
+yaml_document_add_mapping(yaml_document_t *document,
+ yaml_char_t *tag, yaml_mapping_style_t style)
+{
+ struct {
+ yaml_error_type_t error;
+ } context;
+ yaml_mark_t mark = { 0, 0, 0 };
+ yaml_char_t *tag_copy = NULL;
+ struct {
+ yaml_node_pair_t *start;
+ yaml_node_pair_t *end;
+ yaml_node_pair_t *top;
+ } pairs = { NULL, NULL, NULL };
+ yaml_node_t node;
+ ptrdiff_t ret;
+
+ assert(document); /* Non-NULL document object is expected. */
+
+ if (!tag) {
+ tag = (yaml_char_t *)YAML_DEFAULT_MAPPING_TAG;
+ }
+
+ if (!yaml_check_utf8(tag, strlen((char *)tag))) goto error;
+ tag_copy = yaml_strdup(tag);
+ if (!tag_copy) goto error;
+
+ if (!STACK_INIT(&context, pairs, INITIAL_STACK_SIZE)) goto error;
+
+ MAPPING_NODE_INIT(node, tag_copy, pairs.start, pairs.end,
+ style, mark, mark);
+ if (!PUSH(&context, document->nodes, node)) goto error;
+
+ ret = document->nodes.top - document->nodes.start;
+#if PTRDIFF_MAX > INT_MAX
+ if (ret > INT_MAX) goto error;
+#endif
+ return (int)ret;
+
+error:
+ STACK_DEL(&context, pairs);
+ yaml_free(tag_copy);
+
+ return 0;
+}
+
+/*
+ * Append an item to a sequence node.
+ */
+
+YAML_DECLARE(int)
+yaml_document_append_sequence_item(yaml_document_t *document,
+ int sequence, int item)
+{
+ struct {
+ yaml_error_type_t error;
+ } context;
+
+ assert(document); /* Non-NULL document is required. */
+ assert(sequence > 0
+ && document->nodes.start + sequence <= document->nodes.top);
+ /* Valid sequence id is required. */
+ assert(document->nodes.start[sequence-1].type == YAML_SEQUENCE_NODE);
+ /* A sequence node is required. */
+ assert(item > 0 && document->nodes.start + item <= document->nodes.top);
+ /* Valid item id is required. */
+
+ if (!PUSH(&context,
+ document->nodes.start[sequence-1].data.sequence.items, item))
+ return 0;
+
+ return 1;
+}
+
+/*
+ * Append a pair of a key and a value to a mapping node.
+ */
+
+YAML_DECLARE(int)
+yaml_document_append_mapping_pair(yaml_document_t *document,
+ int mapping, int key, int value)
+{
+ struct {
+ yaml_error_type_t error;
+ } context;
+
+ yaml_node_pair_t pair;
+
+ assert(document); /* Non-NULL document is required. */
+ assert(mapping > 0
+ && document->nodes.start + mapping <= document->nodes.top);
+ /* Valid mapping id is required. */
+ assert(document->nodes.start[mapping-1].type == YAML_MAPPING_NODE);
+ /* A mapping node is required. */
+ assert(key > 0 && document->nodes.start + key <= document->nodes.top);
+ /* Valid key id is required. */
+ assert(value > 0 && document->nodes.start + value <= document->nodes.top);
+ /* Valid value id is required. */
+
+ pair.key = key;
+ pair.value = value;
+
+ if (!PUSH(&context,
+ document->nodes.start[mapping-1].data.mapping.pairs, pair))
+ return 0;
+
+ return 1;
+}
+
+
diff --git a/jni/ruby/ext/psych/yaml/config.h b/jni/ruby/ext/psych/yaml/config.h
new file mode 100644
index 0000000..f54c27d
--- /dev/null
+++ b/jni/ruby/ext/psych/yaml/config.h
@@ -0,0 +1,10 @@
+#define PACKAGE_NAME "yaml"
+#define PACKAGE_TARNAME "yaml"
+#define PACKAGE_VERSION "0.1.6"
+#define PACKAGE_STRING "yaml 0.1.6"
+#define PACKAGE_BUGREPORT "http://pyyaml.org/newticket?component libyaml"
+#define PACKAGE_URL ""
+#define YAML_VERSION_MAJOR 0
+#define YAML_VERSION_MINOR 1
+#define YAML_VERSION_PATCH 6
+#define YAML_VERSION_STRING "0.1.6"
diff --git a/jni/ruby/ext/psych/yaml/dumper.c b/jni/ruby/ext/psych/yaml/dumper.c
new file mode 100644
index 0000000..203c6a7
--- /dev/null
+++ b/jni/ruby/ext/psych/yaml/dumper.c
@@ -0,0 +1,394 @@
+
+#include "yaml_private.h"
+
+/*
+ * API functions.
+ */
+
+YAML_DECLARE(int)
+yaml_emitter_open(yaml_emitter_t *emitter);
+
+YAML_DECLARE(int)
+yaml_emitter_close(yaml_emitter_t *emitter);
+
+YAML_DECLARE(int)
+yaml_emitter_dump(yaml_emitter_t *emitter, yaml_document_t *document);
+
+/*
+ * Clean up functions.
+ */
+
+static void
+yaml_emitter_delete_document_and_anchors(yaml_emitter_t *emitter);
+
+/*
+ * Anchor functions.
+ */
+
+static void
+yaml_emitter_anchor_node(yaml_emitter_t *emitter, int index);
+
+static yaml_char_t *
+yaml_emitter_generate_anchor(yaml_emitter_t *emitter, int anchor_id);
+
+
+/*
+ * Serialize functions.
+ */
+
+static int
+yaml_emitter_dump_node(yaml_emitter_t *emitter, int index);
+
+static int
+yaml_emitter_dump_alias(yaml_emitter_t *emitter, yaml_char_t *anchor);
+
+static int
+yaml_emitter_dump_scalar(yaml_emitter_t *emitter, yaml_node_t *node,
+ yaml_char_t *anchor);
+
+static int
+yaml_emitter_dump_sequence(yaml_emitter_t *emitter, yaml_node_t *node,
+ yaml_char_t *anchor);
+
+static int
+yaml_emitter_dump_mapping(yaml_emitter_t *emitter, yaml_node_t *node,
+ yaml_char_t *anchor);
+
+/*
+ * Issue a STREAM-START event.
+ */
+
+YAML_DECLARE(int)
+yaml_emitter_open(yaml_emitter_t *emitter)
+{
+ yaml_event_t event;
+ yaml_mark_t mark = { 0, 0, 0 };
+
+ assert(emitter); /* Non-NULL emitter object is required. */
+ assert(!emitter->opened); /* Emitter should not be opened yet. */
+
+ STREAM_START_EVENT_INIT(event, YAML_ANY_ENCODING, mark, mark);
+
+ if (!yaml_emitter_emit(emitter, &event)) {
+ return 0;
+ }
+
+ emitter->opened = 1;
+
+ return 1;
+}
+
+/*
+ * Issue a STREAM-END event.
+ */
+
+YAML_DECLARE(int)
+yaml_emitter_close(yaml_emitter_t *emitter)
+{
+ yaml_event_t event;
+ yaml_mark_t mark = { 0, 0, 0 };
+
+ assert(emitter); /* Non-NULL emitter object is required. */
+ assert(emitter->opened); /* Emitter should be opened. */
+
+ if (emitter->closed) return 1;
+
+ STREAM_END_EVENT_INIT(event, mark, mark);
+
+ if (!yaml_emitter_emit(emitter, &event)) {
+ return 0;
+ }
+
+ emitter->closed = 1;
+
+ return 1;
+}
+
+/*
+ * Dump a YAML document.
+ */
+
+YAML_DECLARE(int)
+yaml_emitter_dump(yaml_emitter_t *emitter, yaml_document_t *document)
+{
+ yaml_event_t event;
+ yaml_mark_t mark = { 0, 0, 0 };
+
+ assert(emitter); /* Non-NULL emitter object is required. */
+ assert(document); /* Non-NULL emitter object is expected. */
+
+ emitter->document = document;
+
+ if (!emitter->opened) {
+ if (!yaml_emitter_open(emitter)) goto error;
+ }
+
+ if (STACK_EMPTY(emitter, document->nodes)) {
+ if (!yaml_emitter_close(emitter)) goto error;
+ yaml_emitter_delete_document_and_anchors(emitter);
+ return 1;
+ }
+
+ assert(emitter->opened); /* Emitter should be opened. */
+
+ emitter->anchors = yaml_malloc(sizeof(*(emitter->anchors))
+ * (document->nodes.top - document->nodes.start));
+ if (!emitter->anchors) goto error;
+ memset(emitter->anchors, 0, sizeof(*(emitter->anchors))
+ * (document->nodes.top - document->nodes.start));
+
+ DOCUMENT_START_EVENT_INIT(event, document->version_directive,
+ document->tag_directives.start, document->tag_directives.end,
+ document->start_implicit, mark, mark);
+ if (!yaml_emitter_emit(emitter, &event)) goto error;
+
+ yaml_emitter_anchor_node(emitter, 1);
+ if (!yaml_emitter_dump_node(emitter, 1)) goto error;
+
+ DOCUMENT_END_EVENT_INIT(event, document->end_implicit, mark, mark);
+ if (!yaml_emitter_emit(emitter, &event)) goto error;
+
+ yaml_emitter_delete_document_and_anchors(emitter);
+
+ return 1;
+
+error:
+
+ yaml_emitter_delete_document_and_anchors(emitter);
+
+ return 0;
+}
+
+/*
+ * Clean up the emitter object after a document is dumped.
+ */
+
+static void
+yaml_emitter_delete_document_and_anchors(yaml_emitter_t *emitter)
+{
+ int index;
+
+ if (!emitter->anchors) {
+ yaml_document_delete(emitter->document);
+ emitter->document = NULL;
+ return;
+ }
+
+ for (index = 0; emitter->document->nodes.start + index
+ < emitter->document->nodes.top; index ++) {
+ yaml_node_t node = emitter->document->nodes.start[index];
+ if (!emitter->anchors[index].serialized) {
+ yaml_free(node.tag);
+ if (node.type == YAML_SCALAR_NODE) {
+ yaml_free(node.data.scalar.value);
+ }
+ }
+ if (node.type == YAML_SEQUENCE_NODE) {
+ STACK_DEL(emitter, node.data.sequence.items);
+ }
+ if (node.type == YAML_MAPPING_NODE) {
+ STACK_DEL(emitter, node.data.mapping.pairs);
+ }
+ }
+
+ STACK_DEL(emitter, emitter->document->nodes);
+ yaml_free(emitter->anchors);
+
+ emitter->anchors = NULL;
+ emitter->last_anchor_id = 0;
+ emitter->document = NULL;
+}
+
+/*
+ * Check the references of a node and assign the anchor id if needed.
+ */
+
+static void
+yaml_emitter_anchor_node(yaml_emitter_t *emitter, int index)
+{
+ yaml_node_t *node = emitter->document->nodes.start + index - 1;
+ yaml_node_item_t *item;
+ yaml_node_pair_t *pair;
+
+ emitter->anchors[index-1].references ++;
+
+ if (emitter->anchors[index-1].references == 1) {
+ switch (node->type) {
+ case YAML_SEQUENCE_NODE:
+ for (item = node->data.sequence.items.start;
+ item < node->data.sequence.items.top; item ++) {
+ yaml_emitter_anchor_node(emitter, *item);
+ }
+ break;
+ case YAML_MAPPING_NODE:
+ for (pair = node->data.mapping.pairs.start;
+ pair < node->data.mapping.pairs.top; pair ++) {
+ yaml_emitter_anchor_node(emitter, pair->key);
+ yaml_emitter_anchor_node(emitter, pair->value);
+ }
+ break;
+ default:
+ break;
+ }
+ }
+
+ else if (emitter->anchors[index-1].references == 2) {
+ emitter->anchors[index-1].anchor = (++ emitter->last_anchor_id);
+ }
+}
+
+/*
+ * Generate a textual representation for an anchor.
+ */
+
+#define ANCHOR_TEMPLATE "id%03d"
+#define ANCHOR_TEMPLATE_LENGTH 16
+
+static yaml_char_t *
+yaml_emitter_generate_anchor(yaml_emitter_t *emitter, int anchor_id)
+{
+ yaml_char_t *anchor = yaml_malloc(ANCHOR_TEMPLATE_LENGTH);
+
+ if (!anchor) return NULL;
+
+ sprintf((char *)anchor, ANCHOR_TEMPLATE, anchor_id);
+
+ return anchor;
+}
+
+/*
+ * Serialize a node.
+ */
+
+static int
+yaml_emitter_dump_node(yaml_emitter_t *emitter, int index)
+{
+ yaml_node_t *node = emitter->document->nodes.start + index - 1;
+ int anchor_id = emitter->anchors[index-1].anchor;
+ yaml_char_t *anchor = NULL;
+
+ if (anchor_id) {
+ anchor = yaml_emitter_generate_anchor(emitter, anchor_id);
+ if (!anchor) return 0;
+ }
+
+ if (emitter->anchors[index-1].serialized) {
+ return yaml_emitter_dump_alias(emitter, anchor);
+ }
+
+ emitter->anchors[index-1].serialized = 1;
+
+ switch (node->type) {
+ case YAML_SCALAR_NODE:
+ return yaml_emitter_dump_scalar(emitter, node, anchor);
+ case YAML_SEQUENCE_NODE:
+ return yaml_emitter_dump_sequence(emitter, node, anchor);
+ case YAML_MAPPING_NODE:
+ return yaml_emitter_dump_mapping(emitter, node, anchor);
+ default:
+ assert(0); /* Could not happen. */
+ break;
+ }
+
+ return 0; /* Could not happen. */
+}
+
+/*
+ * Serialize an alias.
+ */
+
+static int
+yaml_emitter_dump_alias(yaml_emitter_t *emitter, yaml_char_t *anchor)
+{
+ yaml_event_t event;
+ yaml_mark_t mark = { 0, 0, 0 };
+
+ ALIAS_EVENT_INIT(event, anchor, mark, mark);
+
+ return yaml_emitter_emit(emitter, &event);
+}
+
+/*
+ * Serialize a scalar.
+ */
+
+static int
+yaml_emitter_dump_scalar(yaml_emitter_t *emitter, yaml_node_t *node,
+ yaml_char_t *anchor)
+{
+ yaml_event_t event;
+ yaml_mark_t mark = { 0, 0, 0 };
+
+ int plain_implicit = (strcmp((char *)node->tag,
+ YAML_DEFAULT_SCALAR_TAG) == 0);
+ int quoted_implicit = (strcmp((char *)node->tag,
+ YAML_DEFAULT_SCALAR_TAG) == 0);
+
+ SCALAR_EVENT_INIT(event, anchor, node->tag, node->data.scalar.value,
+ node->data.scalar.length, plain_implicit, quoted_implicit,
+ node->data.scalar.style, mark, mark);
+
+ return yaml_emitter_emit(emitter, &event);
+}
+
+/*
+ * Serialize a sequence.
+ */
+
+static int
+yaml_emitter_dump_sequence(yaml_emitter_t *emitter, yaml_node_t *node,
+ yaml_char_t *anchor)
+{
+ yaml_event_t event;
+ yaml_mark_t mark = { 0, 0, 0 };
+
+ int implicit = (strcmp((char *)node->tag, YAML_DEFAULT_SEQUENCE_TAG) == 0);
+
+ yaml_node_item_t *item;
+
+ SEQUENCE_START_EVENT_INIT(event, anchor, node->tag, implicit,
+ node->data.sequence.style, mark, mark);
+ if (!yaml_emitter_emit(emitter, &event)) return 0;
+
+ for (item = node->data.sequence.items.start;
+ item < node->data.sequence.items.top; item ++) {
+ if (!yaml_emitter_dump_node(emitter, *item)) return 0;
+ }
+
+ SEQUENCE_END_EVENT_INIT(event, mark, mark);
+ if (!yaml_emitter_emit(emitter, &event)) return 0;
+
+ return 1;
+}
+
+/*
+ * Serialize a mapping.
+ */
+
+static int
+yaml_emitter_dump_mapping(yaml_emitter_t *emitter, yaml_node_t *node,
+ yaml_char_t *anchor)
+{
+ yaml_event_t event;
+ yaml_mark_t mark = { 0, 0, 0 };
+
+ int implicit = (strcmp((char *)node->tag, YAML_DEFAULT_MAPPING_TAG) == 0);
+
+ yaml_node_pair_t *pair;
+
+ MAPPING_START_EVENT_INIT(event, anchor, node->tag, implicit,
+ node->data.mapping.style, mark, mark);
+ if (!yaml_emitter_emit(emitter, &event)) return 0;
+
+ for (pair = node->data.mapping.pairs.start;
+ pair < node->data.mapping.pairs.top; pair ++) {
+ if (!yaml_emitter_dump_node(emitter, pair->key)) return 0;
+ if (!yaml_emitter_dump_node(emitter, pair->value)) return 0;
+ }
+
+ MAPPING_END_EVENT_INIT(event, mark, mark);
+ if (!yaml_emitter_emit(emitter, &event)) return 0;
+
+ return 1;
+}
+
diff --git a/jni/ruby/ext/psych/yaml/emitter.c b/jni/ruby/ext/psych/yaml/emitter.c
new file mode 100644
index 0000000..bf84faf
--- /dev/null
+++ b/jni/ruby/ext/psych/yaml/emitter.c
@@ -0,0 +1,2329 @@
+
+#include "yaml_private.h"
+
+/*
+ * Flush the buffer if needed.
+ */
+
+#define FLUSH(emitter) \
+ ((emitter->buffer.pointer+5 < emitter->buffer.end) \
+ || yaml_emitter_flush(emitter))
+
+/*
+ * Put a character to the output buffer.
+ */
+
+#define PUT(emitter,value) \
+ (FLUSH(emitter) \
+ && (*(emitter->buffer.pointer++) = (yaml_char_t)(value), \
+ emitter->column ++, \
+ 1))
+
+/*
+ * Put a line break to the output buffer.
+ */
+
+#define PUT_BREAK(emitter) \
+ (FLUSH(emitter) \
+ && ((emitter->line_break == YAML_CR_BREAK ? \
+ (*(emitter->buffer.pointer++) = (yaml_char_t) '\r') : \
+ emitter->line_break == YAML_LN_BREAK ? \
+ (*(emitter->buffer.pointer++) = (yaml_char_t) '\n') : \
+ emitter->line_break == YAML_CRLN_BREAK ? \
+ (*(emitter->buffer.pointer++) = (yaml_char_t) '\r', \
+ *(emitter->buffer.pointer++) = (yaml_char_t) '\n') : 0), \
+ emitter->column = 0, \
+ emitter->line ++, \
+ 1))
+
+/*
+ * Copy a character from a string into buffer.
+ */
+
+#define WRITE(emitter,string) \
+ (FLUSH(emitter) \
+ && (COPY(emitter->buffer,string), \
+ emitter->column ++, \
+ 1))
+
+/*
+ * Copy a line break character from a string into buffer.
+ */
+
+#define WRITE_BREAK(emitter,string) \
+ (FLUSH(emitter) \
+ && (CHECK(string,'\n') ? \
+ ((void)PUT_BREAK(emitter), \
+ string.pointer ++, \
+ 1) : \
+ (COPY(emitter->buffer,string), \
+ emitter->column = 0, \
+ emitter->line ++, \
+ 1)))
+
+/*
+ * API functions.
+ */
+
+YAML_DECLARE(int)
+yaml_emitter_emit(yaml_emitter_t *emitter, yaml_event_t *event);
+
+/*
+ * Utility functions.
+ */
+
+static int
+yaml_emitter_set_emitter_error(yaml_emitter_t *emitter, const char *problem);
+
+static int
+yaml_emitter_need_more_events(yaml_emitter_t *emitter);
+
+static int
+yaml_emitter_append_tag_directive(yaml_emitter_t *emitter,
+ yaml_tag_directive_t value, int allow_duplicates);
+
+static int
+yaml_emitter_increase_indent(yaml_emitter_t *emitter,
+ int flow, int indentless);
+
+/*
+ * State functions.
+ */
+
+static int
+yaml_emitter_state_machine(yaml_emitter_t *emitter, yaml_event_t *event);
+
+static int
+yaml_emitter_emit_stream_start(yaml_emitter_t *emitter,
+ yaml_event_t *event);
+
+static int
+yaml_emitter_emit_document_start(yaml_emitter_t *emitter,
+ yaml_event_t *event, int first);
+
+static int
+yaml_emitter_emit_document_content(yaml_emitter_t *emitter,
+ yaml_event_t *event);
+
+static int
+yaml_emitter_emit_document_end(yaml_emitter_t *emitter,
+ yaml_event_t *event);
+
+static int
+yaml_emitter_emit_flow_sequence_item(yaml_emitter_t *emitter,
+ yaml_event_t *event, int first);
+
+static int
+yaml_emitter_emit_flow_mapping_key(yaml_emitter_t *emitter,
+ yaml_event_t *event, int first);
+
+static int
+yaml_emitter_emit_flow_mapping_value(yaml_emitter_t *emitter,
+ yaml_event_t *event, int simple);
+
+static int
+yaml_emitter_emit_block_sequence_item(yaml_emitter_t *emitter,
+ yaml_event_t *event, int first);
+
+static int
+yaml_emitter_emit_block_mapping_key(yaml_emitter_t *emitter,
+ yaml_event_t *event, int first);
+
+static int
+yaml_emitter_emit_block_mapping_value(yaml_emitter_t *emitter,
+ yaml_event_t *event, int simple);
+
+static int
+yaml_emitter_emit_node(yaml_emitter_t *emitter, yaml_event_t *event,
+ int root, int sequence, int mapping, int simple_key);
+
+static int
+yaml_emitter_emit_alias(yaml_emitter_t *emitter, yaml_event_t *event);
+
+static int
+yaml_emitter_emit_scalar(yaml_emitter_t *emitter, yaml_event_t *event);
+
+static int
+yaml_emitter_emit_sequence_start(yaml_emitter_t *emitter, yaml_event_t *event);
+
+static int
+yaml_emitter_emit_mapping_start(yaml_emitter_t *emitter, yaml_event_t *event);
+
+/*
+ * Checkers.
+ */
+
+static int
+yaml_emitter_check_empty_document(yaml_emitter_t *emitter);
+
+static int
+yaml_emitter_check_empty_sequence(yaml_emitter_t *emitter);
+
+static int
+yaml_emitter_check_empty_mapping(yaml_emitter_t *emitter);
+
+static int
+yaml_emitter_check_simple_key(yaml_emitter_t *emitter);
+
+static int
+yaml_emitter_select_scalar_style(yaml_emitter_t *emitter, yaml_event_t *event);
+
+/*
+ * Processors.
+ */
+
+static int
+yaml_emitter_process_anchor(yaml_emitter_t *emitter);
+
+static int
+yaml_emitter_process_tag(yaml_emitter_t *emitter);
+
+static int
+yaml_emitter_process_scalar(yaml_emitter_t *emitter);
+
+/*
+ * Analyzers.
+ */
+
+static int
+yaml_emitter_analyze_version_directive(yaml_emitter_t *emitter,
+ yaml_version_directive_t version_directive);
+
+static int
+yaml_emitter_analyze_tag_directive(yaml_emitter_t *emitter,
+ yaml_tag_directive_t tag_directive);
+
+static int
+yaml_emitter_analyze_anchor(yaml_emitter_t *emitter,
+ yaml_char_t *anchor, int alias);
+
+static int
+yaml_emitter_analyze_tag(yaml_emitter_t *emitter,
+ yaml_char_t *tag);
+
+static int
+yaml_emitter_analyze_scalar(yaml_emitter_t *emitter,
+ yaml_char_t *value, size_t length);
+
+static int
+yaml_emitter_analyze_event(yaml_emitter_t *emitter,
+ yaml_event_t *event);
+
+/*
+ * Writers.
+ */
+
+static int
+yaml_emitter_write_bom(yaml_emitter_t *emitter);
+
+static int
+yaml_emitter_write_indent(yaml_emitter_t *emitter);
+
+static int
+yaml_emitter_write_indicator(yaml_emitter_t *emitter,
+ const char *indicator, int need_whitespace,
+ int is_whitespace, int is_indention);
+
+static int
+yaml_emitter_write_anchor(yaml_emitter_t *emitter,
+ yaml_char_t *value, size_t length);
+
+static int
+yaml_emitter_write_tag_handle(yaml_emitter_t *emitter,
+ yaml_char_t *value, size_t length);
+
+static int
+yaml_emitter_write_tag_content(yaml_emitter_t *emitter,
+ yaml_char_t *value, size_t length, int need_whitespace);
+
+static int
+yaml_emitter_write_plain_scalar(yaml_emitter_t *emitter,
+ yaml_char_t *value, size_t length, int allow_breaks);
+
+static int
+yaml_emitter_write_single_quoted_scalar(yaml_emitter_t *emitter,
+ yaml_char_t *value, size_t length, int allow_breaks);
+
+static int
+yaml_emitter_write_double_quoted_scalar(yaml_emitter_t *emitter,
+ yaml_char_t *value, size_t length, int allow_breaks);
+
+static int
+yaml_emitter_write_block_scalar_hints(yaml_emitter_t *emitter,
+ yaml_string_t string);
+
+static int
+yaml_emitter_write_literal_scalar(yaml_emitter_t *emitter,
+ yaml_char_t *value, size_t length);
+
+static int
+yaml_emitter_write_folded_scalar(yaml_emitter_t *emitter,
+ yaml_char_t *value, size_t length);
+
+/*
+ * Set an emitter error and return 0.
+ */
+
+static int
+yaml_emitter_set_emitter_error(yaml_emitter_t *emitter, const char *problem)
+{
+ emitter->error = YAML_EMITTER_ERROR;
+ emitter->problem = problem;
+
+ return 0;
+}
+
+/*
+ * Emit an event.
+ */
+
+YAML_DECLARE(int)
+yaml_emitter_emit(yaml_emitter_t *emitter, yaml_event_t *event)
+{
+ if (!ENQUEUE(emitter, emitter->events, *event)) {
+ yaml_event_delete(event);
+ return 0;
+ }
+
+ while (!yaml_emitter_need_more_events(emitter)) {
+ if (!yaml_emitter_analyze_event(emitter, emitter->events.head))
+ return 0;
+ if (!yaml_emitter_state_machine(emitter, emitter->events.head))
+ return 0;
+ yaml_event_delete(&DEQUEUE(emitter, emitter->events));
+ }
+
+ return 1;
+}
+
+/*
+ * Check if we need to accumulate more events before emitting.
+ *
+ * We accumulate extra
+ * - 1 event for DOCUMENT-START
+ * - 2 events for SEQUENCE-START
+ * - 3 events for MAPPING-START
+ */
+
+static int
+yaml_emitter_need_more_events(yaml_emitter_t *emitter)
+{
+ int level = 0;
+ int accumulate = 0;
+ yaml_event_t *event;
+
+ if (QUEUE_EMPTY(emitter, emitter->events))
+ return 1;
+
+ switch (emitter->events.head->type) {
+ case YAML_DOCUMENT_START_EVENT:
+ accumulate = 1;
+ break;
+ case YAML_SEQUENCE_START_EVENT:
+ accumulate = 2;
+ break;
+ case YAML_MAPPING_START_EVENT:
+ accumulate = 3;
+ break;
+ default:
+ return 0;
+ }
+
+ if (emitter->events.tail - emitter->events.head > accumulate)
+ return 0;
+
+ for (event = emitter->events.head; event != emitter->events.tail; event ++) {
+ switch (event->type) {
+ case YAML_STREAM_START_EVENT:
+ case YAML_DOCUMENT_START_EVENT:
+ case YAML_SEQUENCE_START_EVENT:
+ case YAML_MAPPING_START_EVENT:
+ level += 1;
+ break;
+ case YAML_STREAM_END_EVENT:
+ case YAML_DOCUMENT_END_EVENT:
+ case YAML_SEQUENCE_END_EVENT:
+ case YAML_MAPPING_END_EVENT:
+ level -= 1;
+ break;
+ default:
+ break;
+ }
+ if (!level)
+ return 0;
+ }
+
+ return 1;
+}
+
+/*
+ * Append a directive to the directives stack.
+ */
+
+static int
+yaml_emitter_append_tag_directive(yaml_emitter_t *emitter,
+ yaml_tag_directive_t value, int allow_duplicates)
+{
+ yaml_tag_directive_t *tag_directive;
+ yaml_tag_directive_t copy = { NULL, NULL };
+
+ for (tag_directive = emitter->tag_directives.start;
+ tag_directive != emitter->tag_directives.top; tag_directive ++) {
+ if (strcmp((char *)value.handle, (char *)tag_directive->handle) == 0) {
+ if (allow_duplicates)
+ return 1;
+ return yaml_emitter_set_emitter_error(emitter,
+ "duplicate %TAG directive");
+ }
+ }
+
+ copy.handle = yaml_strdup(value.handle);
+ copy.prefix = yaml_strdup(value.prefix);
+ if (!copy.handle || !copy.prefix) {
+ emitter->error = YAML_MEMORY_ERROR;
+ goto error;
+ }
+
+ if (!PUSH(emitter, emitter->tag_directives, copy))
+ goto error;
+
+ return 1;
+
+error:
+ yaml_free(copy.handle);
+ yaml_free(copy.prefix);
+ return 0;
+}
+
+/*
+ * Increase the indentation level.
+ */
+
+static int
+yaml_emitter_increase_indent(yaml_emitter_t *emitter,
+ int flow, int indentless)
+{
+ if (!PUSH(emitter, emitter->indents, emitter->indent))
+ return 0;
+
+ if (emitter->indent < 0) {
+ emitter->indent = flow ? emitter->best_indent : 0;
+ }
+ else if (!indentless) {
+ emitter->indent += emitter->best_indent;
+ }
+
+ return 1;
+}
+
+/*
+ * State dispatcher.
+ */
+
+static int
+yaml_emitter_state_machine(yaml_emitter_t *emitter, yaml_event_t *event)
+{
+ switch (emitter->state)
+ {
+ case YAML_EMIT_STREAM_START_STATE:
+ return yaml_emitter_emit_stream_start(emitter, event);
+
+ case YAML_EMIT_FIRST_DOCUMENT_START_STATE:
+ return yaml_emitter_emit_document_start(emitter, event, 1);
+
+ case YAML_EMIT_DOCUMENT_START_STATE:
+ return yaml_emitter_emit_document_start(emitter, event, 0);
+
+ case YAML_EMIT_DOCUMENT_CONTENT_STATE:
+ return yaml_emitter_emit_document_content(emitter, event);
+
+ case YAML_EMIT_DOCUMENT_END_STATE:
+ return yaml_emitter_emit_document_end(emitter, event);
+
+ case YAML_EMIT_FLOW_SEQUENCE_FIRST_ITEM_STATE:
+ return yaml_emitter_emit_flow_sequence_item(emitter, event, 1);
+
+ case YAML_EMIT_FLOW_SEQUENCE_ITEM_STATE:
+ return yaml_emitter_emit_flow_sequence_item(emitter, event, 0);
+
+ case YAML_EMIT_FLOW_MAPPING_FIRST_KEY_STATE:
+ return yaml_emitter_emit_flow_mapping_key(emitter, event, 1);
+
+ case YAML_EMIT_FLOW_MAPPING_KEY_STATE:
+ return yaml_emitter_emit_flow_mapping_key(emitter, event, 0);
+
+ case YAML_EMIT_FLOW_MAPPING_SIMPLE_VALUE_STATE:
+ return yaml_emitter_emit_flow_mapping_value(emitter, event, 1);
+
+ case YAML_EMIT_FLOW_MAPPING_VALUE_STATE:
+ return yaml_emitter_emit_flow_mapping_value(emitter, event, 0);
+
+ case YAML_EMIT_BLOCK_SEQUENCE_FIRST_ITEM_STATE:
+ return yaml_emitter_emit_block_sequence_item(emitter, event, 1);
+
+ case YAML_EMIT_BLOCK_SEQUENCE_ITEM_STATE:
+ return yaml_emitter_emit_block_sequence_item(emitter, event, 0);
+
+ case YAML_EMIT_BLOCK_MAPPING_FIRST_KEY_STATE:
+ return yaml_emitter_emit_block_mapping_key(emitter, event, 1);
+
+ case YAML_EMIT_BLOCK_MAPPING_KEY_STATE:
+ return yaml_emitter_emit_block_mapping_key(emitter, event, 0);
+
+ case YAML_EMIT_BLOCK_MAPPING_SIMPLE_VALUE_STATE:
+ return yaml_emitter_emit_block_mapping_value(emitter, event, 1);
+
+ case YAML_EMIT_BLOCK_MAPPING_VALUE_STATE:
+ return yaml_emitter_emit_block_mapping_value(emitter, event, 0);
+
+ case YAML_EMIT_END_STATE:
+ return yaml_emitter_set_emitter_error(emitter,
+ "expected nothing after STREAM-END");
+
+ default:
+ assert(1); /* Invalid state. */
+ }
+
+ return 0;
+}
+
+/*
+ * Expect STREAM-START.
+ */
+
+static int
+yaml_emitter_emit_stream_start(yaml_emitter_t *emitter,
+ yaml_event_t *event)
+{
+ if (event->type == YAML_STREAM_START_EVENT)
+ {
+ if (!emitter->encoding) {
+ emitter->encoding = event->data.stream_start.encoding;
+ }
+
+ if (!emitter->encoding) {
+ emitter->encoding = YAML_UTF8_ENCODING;
+ }
+
+ if (emitter->best_indent < 2 || emitter->best_indent > 9) {
+ emitter->best_indent = 2;
+ }
+
+ if (emitter->best_width >= 0
+ && emitter->best_width <= emitter->best_indent*2) {
+ emitter->best_width = 80;
+ }
+
+ if (emitter->best_width < 0) {
+ emitter->best_width = INT_MAX;
+ }
+
+ if (!emitter->line_break) {
+ emitter->line_break = YAML_LN_BREAK;
+ }
+
+ emitter->indent = -1;
+
+ emitter->line = 0;
+ emitter->column = 0;
+ emitter->whitespace = 1;
+ emitter->indention = 1;
+
+ if (emitter->encoding != YAML_UTF8_ENCODING) {
+ if (!yaml_emitter_write_bom(emitter))
+ return 0;
+ }
+
+ emitter->state = YAML_EMIT_FIRST_DOCUMENT_START_STATE;
+
+ return 1;
+ }
+
+ return yaml_emitter_set_emitter_error(emitter,
+ "expected STREAM-START");
+}
+
+/*
+ * Expect DOCUMENT-START or STREAM-END.
+ */
+
+static int
+yaml_emitter_emit_document_start(yaml_emitter_t *emitter,
+ yaml_event_t *event, int first)
+{
+ if (event->type == YAML_DOCUMENT_START_EVENT)
+ {
+ yaml_tag_directive_t default_tag_directives[] = {
+ {(yaml_char_t *)"!", (yaml_char_t *)"!"},
+ {(yaml_char_t *)"!!", (yaml_char_t *)"tag:yaml.org,2002:"},
+ {NULL, NULL}
+ };
+ yaml_tag_directive_t *tag_directive;
+ int implicit;
+
+ if (event->data.document_start.version_directive) {
+ if (!yaml_emitter_analyze_version_directive(emitter,
+ *event->data.document_start.version_directive))
+ return 0;
+ }
+
+ for (tag_directive = event->data.document_start.tag_directives.start;
+ tag_directive != event->data.document_start.tag_directives.end;
+ tag_directive ++) {
+ if (!yaml_emitter_analyze_tag_directive(emitter, *tag_directive))
+ return 0;
+ if (!yaml_emitter_append_tag_directive(emitter, *tag_directive, 0))
+ return 0;
+ }
+
+ for (tag_directive = default_tag_directives;
+ tag_directive->handle; tag_directive ++) {
+ if (!yaml_emitter_append_tag_directive(emitter, *tag_directive, 1))
+ return 0;
+ }
+
+ implicit = event->data.document_start.implicit;
+ if (!first || emitter->canonical) {
+ implicit = 0;
+ }
+
+ if ((event->data.document_start.version_directive ||
+ (event->data.document_start.tag_directives.start
+ != event->data.document_start.tag_directives.end)) &&
+ emitter->open_ended)
+ {
+ if (!yaml_emitter_write_indicator(emitter, "...", 1, 0, 0))
+ return 0;
+ if (!yaml_emitter_write_indent(emitter))
+ return 0;
+ }
+
+ if (event->data.document_start.version_directive) {
+ implicit = 0;
+ if (!yaml_emitter_write_indicator(emitter, "%YAML", 1, 0, 0))
+ return 0;
+ if (!yaml_emitter_write_indicator(emitter, "1.1", 1, 0, 0))
+ return 0;
+ if (!yaml_emitter_write_indent(emitter))
+ return 0;
+ }
+
+ if (event->data.document_start.tag_directives.start
+ != event->data.document_start.tag_directives.end) {
+ implicit = 0;
+ for (tag_directive = event->data.document_start.tag_directives.start;
+ tag_directive != event->data.document_start.tag_directives.end;
+ tag_directive ++) {
+ if (!yaml_emitter_write_indicator(emitter, "%TAG", 1, 0, 0))
+ return 0;
+ if (!yaml_emitter_write_tag_handle(emitter, tag_directive->handle,
+ strlen((char *)tag_directive->handle)))
+ return 0;
+ if (!yaml_emitter_write_tag_content(emitter, tag_directive->prefix,
+ strlen((char *)tag_directive->prefix), 1))
+ return 0;
+ if (!yaml_emitter_write_indent(emitter))
+ return 0;
+ }
+ }
+
+ if (yaml_emitter_check_empty_document(emitter)) {
+ implicit = 0;
+ }
+
+ if (!implicit) {
+ if (!yaml_emitter_write_indent(emitter))
+ return 0;
+ if (!yaml_emitter_write_indicator(emitter, "---", 1, 0, 0))
+ return 0;
+ if (emitter->canonical) {
+ if (!yaml_emitter_write_indent(emitter))
+ return 0;
+ }
+ }
+
+ emitter->state = YAML_EMIT_DOCUMENT_CONTENT_STATE;
+
+ return 1;
+ }
+
+ else if (event->type == YAML_STREAM_END_EVENT)
+ {
+ if (emitter->open_ended)
+ {
+ if (!yaml_emitter_write_indicator(emitter, "...", 1, 0, 0))
+ return 0;
+ if (!yaml_emitter_write_indent(emitter))
+ return 0;
+ }
+
+ if (!yaml_emitter_flush(emitter))
+ return 0;
+
+ emitter->state = YAML_EMIT_END_STATE;
+
+ return 1;
+ }
+
+ return yaml_emitter_set_emitter_error(emitter,
+ "expected DOCUMENT-START or STREAM-END");
+}
+
+/*
+ * Expect the root node.
+ */
+
+static int
+yaml_emitter_emit_document_content(yaml_emitter_t *emitter,
+ yaml_event_t *event)
+{
+ if (!PUSH(emitter, emitter->states, YAML_EMIT_DOCUMENT_END_STATE))
+ return 0;
+
+ return yaml_emitter_emit_node(emitter, event, 1, 0, 0, 0);
+}
+
+/*
+ * Expect DOCUMENT-END.
+ */
+
+static int
+yaml_emitter_emit_document_end(yaml_emitter_t *emitter,
+ yaml_event_t *event)
+{
+ if (event->type == YAML_DOCUMENT_END_EVENT)
+ {
+ if (!yaml_emitter_write_indent(emitter))
+ return 0;
+ if (!event->data.document_end.implicit) {
+ if (!yaml_emitter_write_indicator(emitter, "...", 1, 0, 0))
+ return 0;
+ if (!yaml_emitter_write_indent(emitter))
+ return 0;
+ }
+ if (!yaml_emitter_flush(emitter))
+ return 0;
+
+ emitter->state = YAML_EMIT_DOCUMENT_START_STATE;
+
+ while (!STACK_EMPTY(emitter, emitter->tag_directives)) {
+ yaml_tag_directive_t tag_directive = POP(emitter,
+ emitter->tag_directives);
+ yaml_free(tag_directive.handle);
+ yaml_free(tag_directive.prefix);
+ }
+
+ return 1;
+ }
+
+ return yaml_emitter_set_emitter_error(emitter,
+ "expected DOCUMENT-END");
+}
+
+/*
+ *
+ * Expect a flow item node.
+ */
+
+static int
+yaml_emitter_emit_flow_sequence_item(yaml_emitter_t *emitter,
+ yaml_event_t *event, int first)
+{
+ if (first)
+ {
+ if (!yaml_emitter_write_indicator(emitter, "[", 1, 1, 0))
+ return 0;
+ if (!yaml_emitter_increase_indent(emitter, 1, 0))
+ return 0;
+ emitter->flow_level ++;
+ }
+
+ if (event->type == YAML_SEQUENCE_END_EVENT)
+ {
+ emitter->flow_level --;
+ emitter->indent = POP(emitter, emitter->indents);
+ if (emitter->canonical && !first) {
+ if (!yaml_emitter_write_indicator(emitter, ",", 0, 0, 0))
+ return 0;
+ if (!yaml_emitter_write_indent(emitter))
+ return 0;
+ }
+ if (!yaml_emitter_write_indicator(emitter, "]", 0, 0, 0))
+ return 0;
+ emitter->state = POP(emitter, emitter->states);
+
+ return 1;
+ }
+
+ if (!first) {
+ if (!yaml_emitter_write_indicator(emitter, ",", 0, 0, 0))
+ return 0;
+ }
+
+ if (emitter->canonical || emitter->column > emitter->best_width) {
+ if (!yaml_emitter_write_indent(emitter))
+ return 0;
+ }
+ if (!PUSH(emitter, emitter->states, YAML_EMIT_FLOW_SEQUENCE_ITEM_STATE))
+ return 0;
+
+ return yaml_emitter_emit_node(emitter, event, 0, 1, 0, 0);
+}
+
+/*
+ * Expect a flow key node.
+ */
+
+static int
+yaml_emitter_emit_flow_mapping_key(yaml_emitter_t *emitter,
+ yaml_event_t *event, int first)
+{
+ if (first)
+ {
+ if (!yaml_emitter_write_indicator(emitter, "{", 1, 1, 0))
+ return 0;
+ if (!yaml_emitter_increase_indent(emitter, 1, 0))
+ return 0;
+ emitter->flow_level ++;
+ }
+
+ if (event->type == YAML_MAPPING_END_EVENT)
+ {
+ emitter->flow_level --;
+ emitter->indent = POP(emitter, emitter->indents);
+ if (emitter->canonical && !first) {
+ if (!yaml_emitter_write_indicator(emitter, ",", 0, 0, 0))
+ return 0;
+ if (!yaml_emitter_write_indent(emitter))
+ return 0;
+ }
+ if (!yaml_emitter_write_indicator(emitter, "}", 0, 0, 0))
+ return 0;
+ emitter->state = POP(emitter, emitter->states);
+
+ return 1;
+ }
+
+ if (!first) {
+ if (!yaml_emitter_write_indicator(emitter, ",", 0, 0, 0))
+ return 0;
+ }
+ if (emitter->canonical || emitter->column > emitter->best_width) {
+ if (!yaml_emitter_write_indent(emitter))
+ return 0;
+ }
+
+ if (!emitter->canonical && yaml_emitter_check_simple_key(emitter))
+ {
+ if (!PUSH(emitter, emitter->states,
+ YAML_EMIT_FLOW_MAPPING_SIMPLE_VALUE_STATE))
+ return 0;
+
+ return yaml_emitter_emit_node(emitter, event, 0, 0, 1, 1);
+ }
+ else
+ {
+ if (!yaml_emitter_write_indicator(emitter, "?", 1, 0, 0))
+ return 0;
+ if (!PUSH(emitter, emitter->states,
+ YAML_EMIT_FLOW_MAPPING_VALUE_STATE))
+ return 0;
+
+ return yaml_emitter_emit_node(emitter, event, 0, 0, 1, 0);
+ }
+}
+
+/*
+ * Expect a flow value node.
+ */
+
+static int
+yaml_emitter_emit_flow_mapping_value(yaml_emitter_t *emitter,
+ yaml_event_t *event, int simple)
+{
+ if (simple) {
+ if (!yaml_emitter_write_indicator(emitter, ":", 0, 0, 0))
+ return 0;
+ }
+ else {
+ if (emitter->canonical || emitter->column > emitter->best_width) {
+ if (!yaml_emitter_write_indent(emitter))
+ return 0;
+ }
+ if (!yaml_emitter_write_indicator(emitter, ":", 1, 0, 0))
+ return 0;
+ }
+ if (!PUSH(emitter, emitter->states, YAML_EMIT_FLOW_MAPPING_KEY_STATE))
+ return 0;
+ return yaml_emitter_emit_node(emitter, event, 0, 0, 1, 0);
+}
+
+/*
+ * Expect a block item node.
+ */
+
+static int
+yaml_emitter_emit_block_sequence_item(yaml_emitter_t *emitter,
+ yaml_event_t *event, int first)
+{
+ if (first)
+ {
+ if (!yaml_emitter_increase_indent(emitter, 0,
+ (emitter->mapping_context && !emitter->indention)))
+ return 0;
+ }
+
+ if (event->type == YAML_SEQUENCE_END_EVENT)
+ {
+ emitter->indent = POP(emitter, emitter->indents);
+ emitter->state = POP(emitter, emitter->states);
+
+ return 1;
+ }
+
+ if (!yaml_emitter_write_indent(emitter))
+ return 0;
+ if (!yaml_emitter_write_indicator(emitter, "-", 1, 0, 1))
+ return 0;
+ if (!PUSH(emitter, emitter->states,
+ YAML_EMIT_BLOCK_SEQUENCE_ITEM_STATE))
+ return 0;
+
+ return yaml_emitter_emit_node(emitter, event, 0, 1, 0, 0);
+}
+
+/*
+ * Expect a block key node.
+ */
+
+static int
+yaml_emitter_emit_block_mapping_key(yaml_emitter_t *emitter,
+ yaml_event_t *event, int first)
+{
+ if (first)
+ {
+ if (!yaml_emitter_increase_indent(emitter, 0, 0))
+ return 0;
+ }
+
+ if (event->type == YAML_MAPPING_END_EVENT)
+ {
+ emitter->indent = POP(emitter, emitter->indents);
+ emitter->state = POP(emitter, emitter->states);
+
+ return 1;
+ }
+
+ if (!yaml_emitter_write_indent(emitter))
+ return 0;
+
+ if (yaml_emitter_check_simple_key(emitter))
+ {
+ if (!PUSH(emitter, emitter->states,
+ YAML_EMIT_BLOCK_MAPPING_SIMPLE_VALUE_STATE))
+ return 0;
+
+ return yaml_emitter_emit_node(emitter, event, 0, 0, 1, 1);
+ }
+ else
+ {
+ if (!yaml_emitter_write_indicator(emitter, "?", 1, 0, 1))
+ return 0;
+ if (!PUSH(emitter, emitter->states,
+ YAML_EMIT_BLOCK_MAPPING_VALUE_STATE))
+ return 0;
+
+ return yaml_emitter_emit_node(emitter, event, 0, 0, 1, 0);
+ }
+}
+
+/*
+ * Expect a block value node.
+ */
+
+static int
+yaml_emitter_emit_block_mapping_value(yaml_emitter_t *emitter,
+ yaml_event_t *event, int simple)
+{
+ if (simple) {
+ if (!yaml_emitter_write_indicator(emitter, ":", 0, 0, 0))
+ return 0;
+ }
+ else {
+ if (!yaml_emitter_write_indent(emitter))
+ return 0;
+ if (!yaml_emitter_write_indicator(emitter, ":", 1, 0, 1))
+ return 0;
+ }
+ if (!PUSH(emitter, emitter->states,
+ YAML_EMIT_BLOCK_MAPPING_KEY_STATE))
+ return 0;
+
+ return yaml_emitter_emit_node(emitter, event, 0, 0, 1, 0);
+}
+
+/*
+ * Expect a node.
+ */
+
+static int
+yaml_emitter_emit_node(yaml_emitter_t *emitter, yaml_event_t *event,
+ int root, int sequence, int mapping, int simple_key)
+{
+ emitter->root_context = root;
+ emitter->sequence_context = sequence;
+ emitter->mapping_context = mapping;
+ emitter->simple_key_context = simple_key;
+
+ switch (event->type)
+ {
+ case YAML_ALIAS_EVENT:
+ return yaml_emitter_emit_alias(emitter, event);
+
+ case YAML_SCALAR_EVENT:
+ return yaml_emitter_emit_scalar(emitter, event);
+
+ case YAML_SEQUENCE_START_EVENT:
+ return yaml_emitter_emit_sequence_start(emitter, event);
+
+ case YAML_MAPPING_START_EVENT:
+ return yaml_emitter_emit_mapping_start(emitter, event);
+
+ default:
+ return yaml_emitter_set_emitter_error(emitter,
+ "expected SCALAR, SEQUENCE-START, MAPPING-START, or ALIAS");
+ }
+
+ return 0;
+}
+
+/*
+ * Expect ALIAS.
+ */
+
+static int
+yaml_emitter_emit_alias(yaml_emitter_t *emitter, yaml_event_t *event)
+{
+ if (!yaml_emitter_process_anchor(emitter))
+ return 0;
+ emitter->state = POP(emitter, emitter->states);
+
+ return 1;
+}
+
+/*
+ * Expect SCALAR.
+ */
+
+static int
+yaml_emitter_emit_scalar(yaml_emitter_t *emitter, yaml_event_t *event)
+{
+ if (!yaml_emitter_select_scalar_style(emitter, event))
+ return 0;
+ if (!yaml_emitter_process_anchor(emitter))
+ return 0;
+ if (!yaml_emitter_process_tag(emitter))
+ return 0;
+ if (!yaml_emitter_increase_indent(emitter, 1, 0))
+ return 0;
+ if (!yaml_emitter_process_scalar(emitter))
+ return 0;
+ emitter->indent = POP(emitter, emitter->indents);
+ emitter->state = POP(emitter, emitter->states);
+
+ return 1;
+}
+
+/*
+ * Expect SEQUENCE-START.
+ */
+
+static int
+yaml_emitter_emit_sequence_start(yaml_emitter_t *emitter, yaml_event_t *event)
+{
+ if (!yaml_emitter_process_anchor(emitter))
+ return 0;
+ if (!yaml_emitter_process_tag(emitter))
+ return 0;
+
+ if (emitter->flow_level || emitter->canonical
+ || event->data.sequence_start.style == YAML_FLOW_SEQUENCE_STYLE
+ || yaml_emitter_check_empty_sequence(emitter)) {
+ emitter->state = YAML_EMIT_FLOW_SEQUENCE_FIRST_ITEM_STATE;
+ }
+ else {
+ emitter->state = YAML_EMIT_BLOCK_SEQUENCE_FIRST_ITEM_STATE;
+ }
+
+ return 1;
+}
+
+/*
+ * Expect MAPPING-START.
+ */
+
+static int
+yaml_emitter_emit_mapping_start(yaml_emitter_t *emitter, yaml_event_t *event)
+{
+ if (!yaml_emitter_process_anchor(emitter))
+ return 0;
+ if (!yaml_emitter_process_tag(emitter))
+ return 0;
+
+ if (emitter->flow_level || emitter->canonical
+ || event->data.mapping_start.style == YAML_FLOW_MAPPING_STYLE
+ || yaml_emitter_check_empty_mapping(emitter)) {
+ emitter->state = YAML_EMIT_FLOW_MAPPING_FIRST_KEY_STATE;
+ }
+ else {
+ emitter->state = YAML_EMIT_BLOCK_MAPPING_FIRST_KEY_STATE;
+ }
+
+ return 1;
+}
+
+/*
+ * Check if the document content is an empty scalar.
+ */
+
+static int
+yaml_emitter_check_empty_document(yaml_emitter_t *emitter)
+{
+ return 0;
+}
+
+/*
+ * Check if the next events represent an empty sequence.
+ */
+
+static int
+yaml_emitter_check_empty_sequence(yaml_emitter_t *emitter)
+{
+ if (emitter->events.tail - emitter->events.head < 2)
+ return 0;
+
+ return (emitter->events.head[0].type == YAML_SEQUENCE_START_EVENT
+ && emitter->events.head[1].type == YAML_SEQUENCE_END_EVENT);
+}
+
+/*
+ * Check if the next events represent an empty mapping.
+ */
+
+static int
+yaml_emitter_check_empty_mapping(yaml_emitter_t *emitter)
+{
+ if (emitter->events.tail - emitter->events.head < 2)
+ return 0;
+
+ return (emitter->events.head[0].type == YAML_MAPPING_START_EVENT
+ && emitter->events.head[1].type == YAML_MAPPING_END_EVENT);
+}
+
+/*
+ * Check if the next node can be expressed as a simple key.
+ */
+
+static int
+yaml_emitter_check_simple_key(yaml_emitter_t *emitter)
+{
+ yaml_event_t *event = emitter->events.head;
+ size_t length = 0;
+
+ switch (event->type)
+ {
+ case YAML_ALIAS_EVENT:
+ length += emitter->anchor_data.anchor_length;
+ break;
+
+ case YAML_SCALAR_EVENT:
+ if (emitter->scalar_data.multiline)
+ return 0;
+ length += emitter->anchor_data.anchor_length
+ + emitter->tag_data.handle_length
+ + emitter->tag_data.suffix_length
+ + emitter->scalar_data.length;
+ break;
+
+ case YAML_SEQUENCE_START_EVENT:
+ if (!yaml_emitter_check_empty_sequence(emitter))
+ return 0;
+ length += emitter->anchor_data.anchor_length
+ + emitter->tag_data.handle_length
+ + emitter->tag_data.suffix_length;
+ break;
+
+ case YAML_MAPPING_START_EVENT:
+ if (!yaml_emitter_check_empty_mapping(emitter))
+ return 0;
+ length += emitter->anchor_data.anchor_length
+ + emitter->tag_data.handle_length
+ + emitter->tag_data.suffix_length;
+ break;
+
+ default:
+ return 0;
+ }
+
+ if (length > 128)
+ return 0;
+
+ return 1;
+}
+
+/*
+ * Determine an acceptable scalar style.
+ */
+
+static int
+yaml_emitter_select_scalar_style(yaml_emitter_t *emitter, yaml_event_t *event)
+{
+ yaml_scalar_style_t style = event->data.scalar.style;
+ int no_tag = (!emitter->tag_data.handle && !emitter->tag_data.suffix);
+
+ if (no_tag && !event->data.scalar.plain_implicit
+ && !event->data.scalar.quoted_implicit) {
+ return yaml_emitter_set_emitter_error(emitter,
+ "neither tag nor implicit flags are specified");
+ }
+
+ if (style == YAML_ANY_SCALAR_STYLE)
+ style = YAML_PLAIN_SCALAR_STYLE;
+
+ if (emitter->canonical)
+ style = YAML_DOUBLE_QUOTED_SCALAR_STYLE;
+
+ if (emitter->simple_key_context && emitter->scalar_data.multiline)
+ style = YAML_DOUBLE_QUOTED_SCALAR_STYLE;
+
+ if (style == YAML_PLAIN_SCALAR_STYLE)
+ {
+ if ((emitter->flow_level && !emitter->scalar_data.flow_plain_allowed)
+ || (!emitter->flow_level && !emitter->scalar_data.block_plain_allowed))
+ style = YAML_SINGLE_QUOTED_SCALAR_STYLE;
+ if (!emitter->scalar_data.length
+ && (emitter->flow_level || emitter->simple_key_context))
+ style = YAML_SINGLE_QUOTED_SCALAR_STYLE;
+ if (no_tag && !event->data.scalar.plain_implicit)
+ style = YAML_SINGLE_QUOTED_SCALAR_STYLE;
+ }
+
+ if (style == YAML_SINGLE_QUOTED_SCALAR_STYLE)
+ {
+ if (!emitter->scalar_data.single_quoted_allowed)
+ style = YAML_DOUBLE_QUOTED_SCALAR_STYLE;
+ }
+
+ if (style == YAML_LITERAL_SCALAR_STYLE || style == YAML_FOLDED_SCALAR_STYLE)
+ {
+ if (!emitter->scalar_data.block_allowed
+ || emitter->flow_level || emitter->simple_key_context)
+ style = YAML_DOUBLE_QUOTED_SCALAR_STYLE;
+ }
+
+ if (no_tag && !event->data.scalar.quoted_implicit
+ && style != YAML_PLAIN_SCALAR_STYLE)
+ {
+ emitter->tag_data.handle = (yaml_char_t *)"!";
+ emitter->tag_data.handle_length = 1;
+ }
+
+ emitter->scalar_data.style = style;
+
+ return 1;
+}
+
+/*
+ * Write an achor.
+ */
+
+static int
+yaml_emitter_process_anchor(yaml_emitter_t *emitter)
+{
+ if (!emitter->anchor_data.anchor)
+ return 1;
+
+ if (!yaml_emitter_write_indicator(emitter,
+ (emitter->anchor_data.alias ? "*" : "&"), 1, 0, 0))
+ return 0;
+
+ return yaml_emitter_write_anchor(emitter,
+ emitter->anchor_data.anchor, emitter->anchor_data.anchor_length);
+}
+
+/*
+ * Write a tag.
+ */
+
+static int
+yaml_emitter_process_tag(yaml_emitter_t *emitter)
+{
+ if (!emitter->tag_data.handle && !emitter->tag_data.suffix)
+ return 1;
+
+ if (emitter->tag_data.handle)
+ {
+ if (!yaml_emitter_write_tag_handle(emitter, emitter->tag_data.handle,
+ emitter->tag_data.handle_length))
+ return 0;
+ if (emitter->tag_data.suffix) {
+ if (!yaml_emitter_write_tag_content(emitter, emitter->tag_data.suffix,
+ emitter->tag_data.suffix_length, 0))
+ return 0;
+ }
+ }
+ else
+ {
+ if (!yaml_emitter_write_indicator(emitter, "!<", 1, 0, 0))
+ return 0;
+ if (!yaml_emitter_write_tag_content(emitter, emitter->tag_data.suffix,
+ emitter->tag_data.suffix_length, 0))
+ return 0;
+ if (!yaml_emitter_write_indicator(emitter, ">", 0, 0, 0))
+ return 0;
+ }
+
+ return 1;
+}
+
+/*
+ * Write a scalar.
+ */
+
+static int
+yaml_emitter_process_scalar(yaml_emitter_t *emitter)
+{
+ switch (emitter->scalar_data.style)
+ {
+ case YAML_PLAIN_SCALAR_STYLE:
+ return yaml_emitter_write_plain_scalar(emitter,
+ emitter->scalar_data.value, emitter->scalar_data.length,
+ !emitter->simple_key_context);
+
+ case YAML_SINGLE_QUOTED_SCALAR_STYLE:
+ return yaml_emitter_write_single_quoted_scalar(emitter,
+ emitter->scalar_data.value, emitter->scalar_data.length,
+ !emitter->simple_key_context);
+
+ case YAML_DOUBLE_QUOTED_SCALAR_STYLE:
+ return yaml_emitter_write_double_quoted_scalar(emitter,
+ emitter->scalar_data.value, emitter->scalar_data.length,
+ !emitter->simple_key_context);
+
+ case YAML_LITERAL_SCALAR_STYLE:
+ return yaml_emitter_write_literal_scalar(emitter,
+ emitter->scalar_data.value, emitter->scalar_data.length);
+
+ case YAML_FOLDED_SCALAR_STYLE:
+ return yaml_emitter_write_folded_scalar(emitter,
+ emitter->scalar_data.value, emitter->scalar_data.length);
+
+ default:
+ assert(1); /* Impossible. */
+ }
+
+ return 0;
+}
+
+/*
+ * Check if a %YAML directive is valid.
+ */
+
+static int
+yaml_emitter_analyze_version_directive(yaml_emitter_t *emitter,
+ yaml_version_directive_t version_directive)
+{
+ if (version_directive.major != 1 || version_directive.minor != 1) {
+ return yaml_emitter_set_emitter_error(emitter,
+ "incompatible %YAML directive");
+ }
+
+ return 1;
+}
+
+/*
+ * Check if a %TAG directive is valid.
+ */
+
+static int
+yaml_emitter_analyze_tag_directive(yaml_emitter_t *emitter,
+ yaml_tag_directive_t tag_directive)
+{
+ yaml_string_t handle;
+ yaml_string_t prefix;
+ size_t handle_length;
+ size_t prefix_length;
+
+ handle_length = strlen((char *)tag_directive.handle);
+ prefix_length = strlen((char *)tag_directive.prefix);
+ STRING_ASSIGN(handle, tag_directive.handle, handle_length);
+ STRING_ASSIGN(prefix, tag_directive.prefix, prefix_length);
+
+ if (handle.start == handle.end) {
+ return yaml_emitter_set_emitter_error(emitter,
+ "tag handle must not be empty");
+ }
+
+ if (handle.start[0] != '!') {
+ return yaml_emitter_set_emitter_error(emitter,
+ "tag handle must start with '!'");
+ }
+
+ if (handle.end[-1] != '!') {
+ return yaml_emitter_set_emitter_error(emitter,
+ "tag handle must end with '!'");
+ }
+
+ handle.pointer ++;
+
+ while (handle.pointer < handle.end-1) {
+ if (!IS_ALPHA(handle)) {
+ return yaml_emitter_set_emitter_error(emitter,
+ "tag handle must contain alphanumerical characters only");
+ }
+ MOVE(handle);
+ }
+
+ if (prefix.start == prefix.end) {
+ return yaml_emitter_set_emitter_error(emitter,
+ "tag prefix must not be empty");
+ }
+
+ return 1;
+}
+
+/*
+ * Check if an anchor is valid.
+ */
+
+static int
+yaml_emitter_analyze_anchor(yaml_emitter_t *emitter,
+ yaml_char_t *anchor, int alias)
+{
+ size_t anchor_length;
+ yaml_string_t string;
+
+ anchor_length = strlen((char *)anchor);
+ STRING_ASSIGN(string, anchor, anchor_length);
+
+ if (string.start == string.end) {
+ return yaml_emitter_set_emitter_error(emitter, alias ?
+ "alias value must not be empty" :
+ "anchor value must not be empty");
+ }
+
+ while (string.pointer != string.end) {
+ if (!IS_ALPHA(string)) {
+ return yaml_emitter_set_emitter_error(emitter, alias ?
+ "alias value must contain alphanumerical characters only" :
+ "anchor value must contain alphanumerical characters only");
+ }
+ MOVE(string);
+ }
+
+ emitter->anchor_data.anchor = string.start;
+ emitter->anchor_data.anchor_length = string.end - string.start;
+ emitter->anchor_data.alias = alias;
+
+ return 1;
+}
+
+/*
+ * Check if a tag is valid.
+ */
+
+static int
+yaml_emitter_analyze_tag(yaml_emitter_t *emitter,
+ yaml_char_t *tag)
+{
+ size_t tag_length;
+ yaml_string_t string;
+ yaml_tag_directive_t *tag_directive;
+
+ tag_length = strlen((char *)tag);
+ STRING_ASSIGN(string, tag, tag_length);
+
+ if (string.start == string.end) {
+ return yaml_emitter_set_emitter_error(emitter,
+ "tag value must not be empty");
+ }
+
+ for (tag_directive = emitter->tag_directives.start;
+ tag_directive != emitter->tag_directives.top; tag_directive ++) {
+ size_t prefix_length = strlen((char *)tag_directive->prefix);
+ if (prefix_length < (size_t)(string.end - string.start)
+ && strncmp((char *)tag_directive->prefix, (char *)string.start,
+ prefix_length) == 0)
+ {
+ emitter->tag_data.handle = tag_directive->handle;
+ emitter->tag_data.handle_length =
+ strlen((char *)tag_directive->handle);
+ emitter->tag_data.suffix = string.start + prefix_length;
+ emitter->tag_data.suffix_length =
+ (string.end - string.start) - prefix_length;
+ return 1;
+ }
+ }
+
+ emitter->tag_data.suffix = string.start;
+ emitter->tag_data.suffix_length = string.end - string.start;
+
+ return 1;
+}
+
+/*
+ * Check if a scalar is valid.
+ */
+
+static int
+yaml_emitter_analyze_scalar(yaml_emitter_t *emitter,
+ yaml_char_t *value, size_t length)
+{
+ yaml_string_t string;
+
+ int block_indicators = 0;
+ int flow_indicators = 0;
+ int line_breaks = 0;
+ int special_characters = 0;
+
+ int leading_space = 0;
+ int leading_break = 0;
+ int trailing_space = 0;
+ int trailing_break = 0;
+ int break_space = 0;
+ int space_break = 0;
+
+ int preceeded_by_whitespace = 0;
+ int followed_by_whitespace = 0;
+ int previous_space = 0;
+ int previous_break = 0;
+
+ STRING_ASSIGN(string, value, length);
+
+ emitter->scalar_data.value = value;
+ emitter->scalar_data.length = length;
+
+ if (string.start == string.end)
+ {
+ emitter->scalar_data.multiline = 0;
+ emitter->scalar_data.flow_plain_allowed = 0;
+ emitter->scalar_data.block_plain_allowed = 1;
+ emitter->scalar_data.single_quoted_allowed = 1;
+ emitter->scalar_data.block_allowed = 0;
+
+ return 1;
+ }
+
+ if ((CHECK_AT(string, '-', 0)
+ && CHECK_AT(string, '-', 1)
+ && CHECK_AT(string, '-', 2))
+ || (CHECK_AT(string, '.', 0)
+ && CHECK_AT(string, '.', 1)
+ && CHECK_AT(string, '.', 2))) {
+ block_indicators = 1;
+ flow_indicators = 1;
+ }
+
+ preceeded_by_whitespace = 1;
+ followed_by_whitespace = IS_BLANKZ_AT(string, WIDTH(string));
+
+ while (string.pointer != string.end)
+ {
+ if (string.start == string.pointer)
+ {
+ if (CHECK(string, '#') || CHECK(string, ',')
+ || CHECK(string, '[') || CHECK(string, ']')
+ || CHECK(string, '{') || CHECK(string, '}')
+ || CHECK(string, '&') || CHECK(string, '*')
+ || CHECK(string, '!') || CHECK(string, '|')
+ || CHECK(string, '>') || CHECK(string, '\'')
+ || CHECK(string, '"') || CHECK(string, '%')
+ || CHECK(string, '@') || CHECK(string, '`')) {
+ flow_indicators = 1;
+ block_indicators = 1;
+ }
+
+ if (CHECK(string, '?') || CHECK(string, ':')) {
+ flow_indicators = 1;
+ if (followed_by_whitespace) {
+ block_indicators = 1;
+ }
+ }
+
+ if (CHECK(string, '-') && followed_by_whitespace) {
+ flow_indicators = 1;
+ block_indicators = 1;
+ }
+ }
+ else
+ {
+ if (CHECK(string, ',') || CHECK(string, '?')
+ || CHECK(string, '[') || CHECK(string, ']')
+ || CHECK(string, '{') || CHECK(string, '}')) {
+ flow_indicators = 1;
+ }
+
+ if (CHECK(string, ':')) {
+ flow_indicators = 1;
+ if (followed_by_whitespace) {
+ block_indicators = 1;
+ }
+ }
+
+ if (CHECK(string, '#') && preceeded_by_whitespace) {
+ flow_indicators = 1;
+ block_indicators = 1;
+ }
+ }
+
+ if (!IS_PRINTABLE(string)
+ || (!IS_ASCII(string) && !emitter->unicode)) {
+ special_characters = 1;
+ }
+
+ if (IS_BREAK(string)) {
+ line_breaks = 1;
+ }
+
+ if (IS_SPACE(string))
+ {
+ if (string.start == string.pointer) {
+ leading_space = 1;
+ }
+ if (string.pointer+WIDTH(string) == string.end) {
+ trailing_space = 1;
+ }
+ if (previous_break) {
+ break_space = 1;
+ }
+ previous_space = 1;
+ previous_break = 0;
+ }
+ else if (IS_BREAK(string))
+ {
+ if (string.start == string.pointer) {
+ leading_break = 1;
+ }
+ if (string.pointer+WIDTH(string) == string.end) {
+ trailing_break = 1;
+ }
+ if (previous_space) {
+ space_break = 1;
+ }
+ previous_space = 0;
+ previous_break = 1;
+ }
+ else
+ {
+ previous_space = 0;
+ previous_break = 0;
+ }
+
+ preceeded_by_whitespace = IS_BLANKZ(string);
+ MOVE(string);
+ if (string.pointer != string.end) {
+ followed_by_whitespace = IS_BLANKZ_AT(string, WIDTH(string));
+ }
+ }
+
+ emitter->scalar_data.multiline = line_breaks;
+
+ emitter->scalar_data.flow_plain_allowed = 1;
+ emitter->scalar_data.block_plain_allowed = 1;
+ emitter->scalar_data.single_quoted_allowed = 1;
+ emitter->scalar_data.block_allowed = 1;
+
+ if (leading_space || leading_break || trailing_space || trailing_break) {
+ emitter->scalar_data.flow_plain_allowed = 0;
+ emitter->scalar_data.block_plain_allowed = 0;
+ }
+
+ if (trailing_space) {
+ emitter->scalar_data.block_allowed = 0;
+ }
+
+ if (break_space) {
+ emitter->scalar_data.flow_plain_allowed = 0;
+ emitter->scalar_data.block_plain_allowed = 0;
+ emitter->scalar_data.single_quoted_allowed = 0;
+ }
+
+ if (space_break || special_characters) {
+ emitter->scalar_data.flow_plain_allowed = 0;
+ emitter->scalar_data.block_plain_allowed = 0;
+ emitter->scalar_data.single_quoted_allowed = 0;
+ emitter->scalar_data.block_allowed = 0;
+ }
+
+ if (line_breaks) {
+ emitter->scalar_data.flow_plain_allowed = 0;
+ emitter->scalar_data.block_plain_allowed = 0;
+ }
+
+ if (flow_indicators) {
+ emitter->scalar_data.flow_plain_allowed = 0;
+ }
+
+ if (block_indicators) {
+ emitter->scalar_data.block_plain_allowed = 0;
+ }
+
+ return 1;
+}
+
+/*
+ * Check if the event data is valid.
+ */
+
+static int
+yaml_emitter_analyze_event(yaml_emitter_t *emitter,
+ yaml_event_t *event)
+{
+ emitter->anchor_data.anchor = NULL;
+ emitter->anchor_data.anchor_length = 0;
+ emitter->tag_data.handle = NULL;
+ emitter->tag_data.handle_length = 0;
+ emitter->tag_data.suffix = NULL;
+ emitter->tag_data.suffix_length = 0;
+ emitter->scalar_data.value = NULL;
+ emitter->scalar_data.length = 0;
+
+ switch (event->type)
+ {
+ case YAML_ALIAS_EVENT:
+ if (!yaml_emitter_analyze_anchor(emitter,
+ event->data.alias.anchor, 1))
+ return 0;
+ return 1;
+
+ case YAML_SCALAR_EVENT:
+ if (event->data.scalar.anchor) {
+ if (!yaml_emitter_analyze_anchor(emitter,
+ event->data.scalar.anchor, 0))
+ return 0;
+ }
+ if (event->data.scalar.tag && (emitter->canonical ||
+ (!event->data.scalar.plain_implicit
+ && !event->data.scalar.quoted_implicit))) {
+ if (!yaml_emitter_analyze_tag(emitter, event->data.scalar.tag))
+ return 0;
+ }
+ if (!yaml_emitter_analyze_scalar(emitter,
+ event->data.scalar.value, event->data.scalar.length))
+ return 0;
+ return 1;
+
+ case YAML_SEQUENCE_START_EVENT:
+ if (event->data.sequence_start.anchor) {
+ if (!yaml_emitter_analyze_anchor(emitter,
+ event->data.sequence_start.anchor, 0))
+ return 0;
+ }
+ if (event->data.sequence_start.tag && (emitter->canonical ||
+ !event->data.sequence_start.implicit)) {
+ if (!yaml_emitter_analyze_tag(emitter,
+ event->data.sequence_start.tag))
+ return 0;
+ }
+ return 1;
+
+ case YAML_MAPPING_START_EVENT:
+ if (event->data.mapping_start.anchor) {
+ if (!yaml_emitter_analyze_anchor(emitter,
+ event->data.mapping_start.anchor, 0))
+ return 0;
+ }
+ if (event->data.mapping_start.tag && (emitter->canonical ||
+ !event->data.mapping_start.implicit)) {
+ if (!yaml_emitter_analyze_tag(emitter,
+ event->data.mapping_start.tag))
+ return 0;
+ }
+ return 1;
+
+ default:
+ return 1;
+ }
+}
+
+/*
+ * Write the BOM character.
+ */
+
+static int
+yaml_emitter_write_bom(yaml_emitter_t *emitter)
+{
+ if (!FLUSH(emitter)) return 0;
+
+ *(emitter->buffer.pointer++) = (yaml_char_t) '\xEF';
+ *(emitter->buffer.pointer++) = (yaml_char_t) '\xBB';
+ *(emitter->buffer.pointer++) = (yaml_char_t) '\xBF';
+
+ return 1;
+}
+
+static int
+yaml_emitter_write_indent(yaml_emitter_t *emitter)
+{
+ int indent = (emitter->indent >= 0) ? emitter->indent : 0;
+
+ if (!emitter->indention || emitter->column > indent
+ || (emitter->column == indent && !emitter->whitespace)) {
+ if (!PUT_BREAK(emitter)) return 0;
+ }
+
+ while (emitter->column < indent) {
+ if (!PUT(emitter, ' ')) return 0;
+ }
+
+ emitter->whitespace = 1;
+ emitter->indention = 1;
+
+ return 1;
+}
+
+static int
+yaml_emitter_write_indicator(yaml_emitter_t *emitter,
+ const char *indicator, int need_whitespace,
+ int is_whitespace, int is_indention)
+{
+ size_t indicator_length;
+ yaml_string_t string;
+
+ indicator_length = strlen(indicator);
+ STRING_ASSIGN(string, (yaml_char_t *)indicator, indicator_length);
+
+ if (need_whitespace && !emitter->whitespace) {
+ if (!PUT(emitter, ' ')) return 0;
+ }
+
+ while (string.pointer != string.end) {
+ if (!WRITE(emitter, string)) return 0;
+ }
+
+ emitter->whitespace = is_whitespace;
+ emitter->indention = (emitter->indention && is_indention);
+ emitter->open_ended = 0;
+
+ return 1;
+}
+
+static int
+yaml_emitter_write_anchor(yaml_emitter_t *emitter,
+ yaml_char_t *value, size_t length)
+{
+ yaml_string_t string;
+ STRING_ASSIGN(string, value, length);
+
+ while (string.pointer != string.end) {
+ if (!WRITE(emitter, string)) return 0;
+ }
+
+ emitter->whitespace = 0;
+ emitter->indention = 0;
+
+ return 1;
+}
+
+static int
+yaml_emitter_write_tag_handle(yaml_emitter_t *emitter,
+ yaml_char_t *value, size_t length)
+{
+ yaml_string_t string;
+ STRING_ASSIGN(string, value, length);
+
+ if (!emitter->whitespace) {
+ if (!PUT(emitter, ' ')) return 0;
+ }
+
+ while (string.pointer != string.end) {
+ if (!WRITE(emitter, string)) return 0;
+ }
+
+ emitter->whitespace = 0;
+ emitter->indention = 0;
+
+ return 1;
+}
+
+static int
+yaml_emitter_write_tag_content(yaml_emitter_t *emitter,
+ yaml_char_t *value, size_t length,
+ int need_whitespace)
+{
+ yaml_string_t string;
+ STRING_ASSIGN(string, value, length);
+
+ if (need_whitespace && !emitter->whitespace) {
+ if (!PUT(emitter, ' ')) return 0;
+ }
+
+ while (string.pointer != string.end) {
+ if (IS_ALPHA(string)
+ || CHECK(string, ';') || CHECK(string, '/')
+ || CHECK(string, '?') || CHECK(string, ':')
+ || CHECK(string, '@') || CHECK(string, '&')
+ || CHECK(string, '=') || CHECK(string, '+')
+ || CHECK(string, '$') || CHECK(string, ',')
+ || CHECK(string, '_') || CHECK(string, '.')
+ || CHECK(string, '~') || CHECK(string, '*')
+ || CHECK(string, '\'') || CHECK(string, '(')
+ || CHECK(string, ')') || CHECK(string, '[')
+ || CHECK(string, ']')) {
+ if (!WRITE(emitter, string)) return 0;
+ }
+ else {
+ int width = WIDTH(string);
+ unsigned int value;
+ while (width --) {
+ value = *(string.pointer++);
+ if (!PUT(emitter, '%')) return 0;
+ if (!PUT(emitter, (value >> 4)
+ + ((value >> 4) < 10 ? '0' : 'A' - 10)))
+ return 0;
+ if (!PUT(emitter, (value & 0x0F)
+ + ((value & 0x0F) < 10 ? '0' : 'A' - 10)))
+ return 0;
+ }
+ }
+ }
+
+ emitter->whitespace = 0;
+ emitter->indention = 0;
+
+ return 1;
+}
+
+static int
+yaml_emitter_write_plain_scalar(yaml_emitter_t *emitter,
+ yaml_char_t *value, size_t length, int allow_breaks)
+{
+ yaml_string_t string;
+ int spaces = 0;
+ int breaks = 0;
+
+ STRING_ASSIGN(string, value, length);
+
+ if (!emitter->whitespace) {
+ if (!PUT(emitter, ' ')) return 0;
+ }
+
+ while (string.pointer != string.end)
+ {
+ if (IS_SPACE(string))
+ {
+ if (allow_breaks && !spaces
+ && emitter->column > emitter->best_width
+ && !IS_SPACE_AT(string, 1)) {
+ if (!yaml_emitter_write_indent(emitter)) return 0;
+ MOVE(string);
+ }
+ else {
+ if (!WRITE(emitter, string)) return 0;
+ }
+ spaces = 1;
+ }
+ else if (IS_BREAK(string))
+ {
+ if (!breaks && CHECK(string, '\n')) {
+ if (!PUT_BREAK(emitter)) return 0;
+ }
+ if (!WRITE_BREAK(emitter, string)) return 0;
+ emitter->indention = 1;
+ breaks = 1;
+ }
+ else
+ {
+ if (breaks) {
+ if (!yaml_emitter_write_indent(emitter)) return 0;
+ }
+ if (!WRITE(emitter, string)) return 0;
+ emitter->indention = 0;
+ spaces = 0;
+ breaks = 0;
+ }
+ }
+
+ emitter->whitespace = 0;
+ emitter->indention = 0;
+ if (emitter->root_context)
+ {
+ emitter->open_ended = 1;
+ }
+
+ return 1;
+}
+
+static int
+yaml_emitter_write_single_quoted_scalar(yaml_emitter_t *emitter,
+ yaml_char_t *value, size_t length, int allow_breaks)
+{
+ yaml_string_t string;
+ int spaces = 0;
+ int breaks = 0;
+
+ STRING_ASSIGN(string, value, length);
+
+ if (!yaml_emitter_write_indicator(emitter, "'", 1, 0, 0))
+ return 0;
+
+ while (string.pointer != string.end)
+ {
+ if (IS_SPACE(string))
+ {
+ if (allow_breaks && !spaces
+ && emitter->column > emitter->best_width
+ && string.pointer != string.start
+ && string.pointer != string.end - 1
+ && !IS_SPACE_AT(string, 1)) {
+ if (!yaml_emitter_write_indent(emitter)) return 0;
+ MOVE(string);
+ }
+ else {
+ if (!WRITE(emitter, string)) return 0;
+ }
+ spaces = 1;
+ }
+ else if (IS_BREAK(string))
+ {
+ if (!breaks && CHECK(string, '\n')) {
+ if (!PUT_BREAK(emitter)) return 0;
+ }
+ if (!WRITE_BREAK(emitter, string)) return 0;
+ emitter->indention = 1;
+ breaks = 1;
+ }
+ else
+ {
+ if (breaks) {
+ if (!yaml_emitter_write_indent(emitter)) return 0;
+ }
+ if (CHECK(string, '\'')) {
+ if (!PUT(emitter, '\'')) return 0;
+ }
+ if (!WRITE(emitter, string)) return 0;
+ emitter->indention = 0;
+ spaces = 0;
+ breaks = 0;
+ }
+ }
+
+ if (!yaml_emitter_write_indicator(emitter, "'", 0, 0, 0))
+ return 0;
+
+ emitter->whitespace = 0;
+ emitter->indention = 0;
+
+ return 1;
+}
+
+static int
+yaml_emitter_write_double_quoted_scalar(yaml_emitter_t *emitter,
+ yaml_char_t *value, size_t length, int allow_breaks)
+{
+ yaml_string_t string;
+ int spaces = 0;
+
+ STRING_ASSIGN(string, value, length);
+
+ if (!yaml_emitter_write_indicator(emitter, "\"", 1, 0, 0))
+ return 0;
+
+ while (string.pointer != string.end)
+ {
+ if (!IS_PRINTABLE(string) || (!emitter->unicode && !IS_ASCII(string))
+ || IS_BOM(string) || IS_BREAK(string)
+ || CHECK(string, '"') || CHECK(string, '\\'))
+ {
+ unsigned char octet;
+ unsigned int width;
+ unsigned int value;
+ int k;
+
+ octet = string.pointer[0];
+ width = (octet & 0x80) == 0x00 ? 1 :
+ (octet & 0xE0) == 0xC0 ? 2 :
+ (octet & 0xF0) == 0xE0 ? 3 :
+ (octet & 0xF8) == 0xF0 ? 4 : 0;
+ value = (octet & 0x80) == 0x00 ? octet & 0x7F :
+ (octet & 0xE0) == 0xC0 ? octet & 0x1F :
+ (octet & 0xF0) == 0xE0 ? octet & 0x0F :
+ (octet & 0xF8) == 0xF0 ? octet & 0x07 : 0;
+ for (k = 1; k < (int)width; k ++) {
+ octet = string.pointer[k];
+ value = (value << 6) + (octet & 0x3F);
+ }
+ string.pointer += width;
+
+ if (!PUT(emitter, '\\')) return 0;
+
+ switch (value)
+ {
+ case 0x00:
+ if (!PUT(emitter, '0')) return 0;
+ break;
+
+ case 0x07:
+ if (!PUT(emitter, 'a')) return 0;
+ break;
+
+ case 0x08:
+ if (!PUT(emitter, 'b')) return 0;
+ break;
+
+ case 0x09:
+ if (!PUT(emitter, 't')) return 0;
+ break;
+
+ case 0x0A:
+ if (!PUT(emitter, 'n')) return 0;
+ break;
+
+ case 0x0B:
+ if (!PUT(emitter, 'v')) return 0;
+ break;
+
+ case 0x0C:
+ if (!PUT(emitter, 'f')) return 0;
+ break;
+
+ case 0x0D:
+ if (!PUT(emitter, 'r')) return 0;
+ break;
+
+ case 0x1B:
+ if (!PUT(emitter, 'e')) return 0;
+ break;
+
+ case 0x22:
+ if (!PUT(emitter, '\"')) return 0;
+ break;
+
+ case 0x5C:
+ if (!PUT(emitter, '\\')) return 0;
+ break;
+
+ case 0x85:
+ if (!PUT(emitter, 'N')) return 0;
+ break;
+
+ case 0xA0:
+ if (!PUT(emitter, '_')) return 0;
+ break;
+
+ case 0x2028:
+ if (!PUT(emitter, 'L')) return 0;
+ break;
+
+ case 0x2029:
+ if (!PUT(emitter, 'P')) return 0;
+ break;
+
+ default:
+ if (value <= 0xFF) {
+ if (!PUT(emitter, 'x')) return 0;
+ width = 2;
+ }
+ else if (value <= 0xFFFF) {
+ if (!PUT(emitter, 'u')) return 0;
+ width = 4;
+ }
+ else {
+ if (!PUT(emitter, 'U')) return 0;
+ width = 8;
+ }
+ for (k = (width-1)*4; k >= 0; k -= 4) {
+ int digit = (value >> k) & 0x0F;
+ if (!PUT(emitter, digit + (digit < 10 ? '0' : 'A'-10)))
+ return 0;
+ }
+ }
+ spaces = 0;
+ }
+ else if (IS_SPACE(string))
+ {
+ if (allow_breaks && !spaces
+ && emitter->column > emitter->best_width
+ && string.pointer != string.start
+ && string.pointer != string.end - 1) {
+ if (!yaml_emitter_write_indent(emitter)) return 0;
+ if (IS_SPACE_AT(string, 1)) {
+ if (!PUT(emitter, '\\')) return 0;
+ }
+ MOVE(string);
+ }
+ else {
+ if (!WRITE(emitter, string)) return 0;
+ }
+ spaces = 1;
+ }
+ else
+ {
+ if (!WRITE(emitter, string)) return 0;
+ spaces = 0;
+ }
+ }
+
+ if (!yaml_emitter_write_indicator(emitter, "\"", 0, 0, 0))
+ return 0;
+
+ emitter->whitespace = 0;
+ emitter->indention = 0;
+
+ return 1;
+}
+
+static int
+yaml_emitter_write_block_scalar_hints(yaml_emitter_t *emitter,
+ yaml_string_t string)
+{
+ char indent_hint[2];
+ const char *chomp_hint = NULL;
+
+ if (IS_SPACE(string) || IS_BREAK(string))
+ {
+ indent_hint[0] = '0' + (char)emitter->best_indent;
+ indent_hint[1] = '\0';
+ if (!yaml_emitter_write_indicator(emitter, indent_hint, 0, 0, 0))
+ return 0;
+ }
+
+ emitter->open_ended = 0;
+
+ string.pointer = string.end;
+ if (string.start == string.pointer)
+ {
+ chomp_hint = "-";
+ }
+ else
+ {
+ do {
+ string.pointer --;
+ } while ((*string.pointer & 0xC0) == 0x80);
+ if (!IS_BREAK(string))
+ {
+ chomp_hint = "-";
+ }
+ else if (string.start == string.pointer)
+ {
+ chomp_hint = "+";
+ emitter->open_ended = 1;
+ }
+ else
+ {
+ do {
+ string.pointer --;
+ } while ((*string.pointer & 0xC0) == 0x80);
+ if (IS_BREAK(string))
+ {
+ chomp_hint = "+";
+ emitter->open_ended = 1;
+ }
+ }
+ }
+
+ if (chomp_hint)
+ {
+ if (!yaml_emitter_write_indicator(emitter, chomp_hint, 0, 0, 0))
+ return 0;
+ }
+
+ return 1;
+}
+
+static int
+yaml_emitter_write_literal_scalar(yaml_emitter_t *emitter,
+ yaml_char_t *value, size_t length)
+{
+ yaml_string_t string;
+ int breaks = 1;
+
+ STRING_ASSIGN(string, value, length);
+
+ if (!yaml_emitter_write_indicator(emitter, "|", 1, 0, 0))
+ return 0;
+ if (!yaml_emitter_write_block_scalar_hints(emitter, string))
+ return 0;
+ if (!PUT_BREAK(emitter)) return 0;
+ emitter->indention = 1;
+ emitter->whitespace = 1;
+
+ while (string.pointer != string.end)
+ {
+ if (IS_BREAK(string))
+ {
+ if (!WRITE_BREAK(emitter, string)) return 0;
+ emitter->indention = 1;
+ breaks = 1;
+ }
+ else
+ {
+ if (breaks) {
+ if (!yaml_emitter_write_indent(emitter)) return 0;
+ }
+ if (!WRITE(emitter, string)) return 0;
+ emitter->indention = 0;
+ breaks = 0;
+ }
+ }
+
+ return 1;
+}
+
+static int
+yaml_emitter_write_folded_scalar(yaml_emitter_t *emitter,
+ yaml_char_t *value, size_t length)
+{
+ yaml_string_t string;
+ int breaks = 1;
+ int leading_spaces = 1;
+
+ STRING_ASSIGN(string, value, length);
+
+ if (!yaml_emitter_write_indicator(emitter, ">", 1, 0, 0))
+ return 0;
+ if (!yaml_emitter_write_block_scalar_hints(emitter, string))
+ return 0;
+ if (!PUT_BREAK(emitter)) return 0;
+ emitter->indention = 1;
+ emitter->whitespace = 1;
+
+ while (string.pointer != string.end)
+ {
+ if (IS_BREAK(string))
+ {
+ if (!breaks && !leading_spaces && CHECK(string, '\n')) {
+ int k = 0;
+ while (IS_BREAK_AT(string, k)) {
+ k += WIDTH_AT(string, k);
+ }
+ if (!IS_BLANKZ_AT(string, k)) {
+ if (!PUT_BREAK(emitter)) return 0;
+ }
+ }
+ if (!WRITE_BREAK(emitter, string)) return 0;
+ emitter->indention = 1;
+ breaks = 1;
+ }
+ else
+ {
+ if (breaks) {
+ if (!yaml_emitter_write_indent(emitter)) return 0;
+ leading_spaces = IS_BLANK(string);
+ }
+ if (!breaks && IS_SPACE(string) && !IS_SPACE_AT(string, 1)
+ && emitter->column > emitter->best_width) {
+ if (!yaml_emitter_write_indent(emitter)) return 0;
+ MOVE(string);
+ }
+ else {
+ if (!WRITE(emitter, string)) return 0;
+ }
+ emitter->indention = 0;
+ breaks = 0;
+ }
+ }
+
+ return 1;
+}
+
diff --git a/jni/ruby/ext/psych/yaml/loader.c b/jni/ruby/ext/psych/yaml/loader.c
new file mode 100644
index 0000000..cb3ea93
--- /dev/null
+++ b/jni/ruby/ext/psych/yaml/loader.c
@@ -0,0 +1,459 @@
+
+#include "yaml_private.h"
+
+/*
+ * API functions.
+ */
+
+YAML_DECLARE(int)
+yaml_parser_load(yaml_parser_t *parser, yaml_document_t *document);
+
+/*
+ * Error handling.
+ */
+
+static int
+yaml_parser_set_composer_error(yaml_parser_t *parser,
+ const char *problem, yaml_mark_t problem_mark);
+
+static int
+yaml_parser_set_composer_error_context(yaml_parser_t *parser,
+ const char *context, yaml_mark_t context_mark,
+ const char *problem, yaml_mark_t problem_mark);
+
+
+/*
+ * Alias handling.
+ */
+
+static int
+yaml_parser_register_anchor(yaml_parser_t *parser,
+ int index, yaml_char_t *anchor);
+
+/*
+ * Clean up functions.
+ */
+
+static void
+yaml_parser_delete_aliases(yaml_parser_t *parser);
+
+/*
+ * Composer functions.
+ */
+
+static int
+yaml_parser_load_document(yaml_parser_t *parser, yaml_event_t *first_event);
+
+static int
+yaml_parser_load_node(yaml_parser_t *parser, yaml_event_t *first_event);
+
+static int
+yaml_parser_load_alias(yaml_parser_t *parser, yaml_event_t *first_event);
+
+static int
+yaml_parser_load_scalar(yaml_parser_t *parser, yaml_event_t *first_event);
+
+static int
+yaml_parser_load_sequence(yaml_parser_t *parser, yaml_event_t *first_event);
+
+static int
+yaml_parser_load_mapping(yaml_parser_t *parser, yaml_event_t *first_event);
+
+/*
+ * Load the next document of the stream.
+ */
+
+YAML_DECLARE(int)
+yaml_parser_load(yaml_parser_t *parser, yaml_document_t *document)
+{
+ yaml_event_t event;
+
+ assert(parser); /* Non-NULL parser object is expected. */
+ assert(document); /* Non-NULL document object is expected. */
+
+ memset(document, 0, sizeof(yaml_document_t));
+ if (!STACK_INIT(parser, document->nodes, INITIAL_STACK_SIZE))
+ goto error;
+
+ if (!parser->stream_start_produced) {
+ if (!yaml_parser_parse(parser, &event)) goto error;
+ assert(event.type == YAML_STREAM_START_EVENT);
+ /* STREAM-START is expected. */
+ }
+
+ if (parser->stream_end_produced) {
+ return 1;
+ }
+
+ if (!yaml_parser_parse(parser, &event)) goto error;
+ if (event.type == YAML_STREAM_END_EVENT) {
+ return 1;
+ }
+
+ if (!STACK_INIT(parser, parser->aliases, INITIAL_STACK_SIZE))
+ goto error;
+
+ parser->document = document;
+
+ if (!yaml_parser_load_document(parser, &event)) goto error;
+
+ yaml_parser_delete_aliases(parser);
+ parser->document = NULL;
+
+ return 1;
+
+error:
+
+ yaml_parser_delete_aliases(parser);
+ yaml_document_delete(document);
+ parser->document = NULL;
+
+ return 0;
+}
+
+/*
+ * Set composer error.
+ */
+
+static int
+yaml_parser_set_composer_error(yaml_parser_t *parser,
+ const char *problem, yaml_mark_t problem_mark)
+{
+ parser->error = YAML_COMPOSER_ERROR;
+ parser->problem = problem;
+ parser->problem_mark = problem_mark;
+
+ return 0;
+}
+
+/*
+ * Set composer error with context.
+ */
+
+static int
+yaml_parser_set_composer_error_context(yaml_parser_t *parser,
+ const char *context, yaml_mark_t context_mark,
+ const char *problem, yaml_mark_t problem_mark)
+{
+ parser->error = YAML_COMPOSER_ERROR;
+ parser->context = context;
+ parser->context_mark = context_mark;
+ parser->problem = problem;
+ parser->problem_mark = problem_mark;
+
+ return 0;
+}
+
+/*
+ * Delete the stack of aliases.
+ */
+
+static void
+yaml_parser_delete_aliases(yaml_parser_t *parser)
+{
+ while (!STACK_EMPTY(parser, parser->aliases)) {
+ yaml_free(POP(parser, parser->aliases).anchor);
+ }
+ STACK_DEL(parser, parser->aliases);
+}
+
+/*
+ * Compose a document object.
+ */
+
+static int
+yaml_parser_load_document(yaml_parser_t *parser, yaml_event_t *first_event)
+{
+ yaml_event_t event;
+
+ assert(first_event->type == YAML_DOCUMENT_START_EVENT);
+ /* DOCUMENT-START is expected. */
+
+ parser->document->version_directive
+ = first_event->data.document_start.version_directive;
+ parser->document->tag_directives.start
+ = first_event->data.document_start.tag_directives.start;
+ parser->document->tag_directives.end
+ = first_event->data.document_start.tag_directives.end;
+ parser->document->start_implicit
+ = first_event->data.document_start.implicit;
+ parser->document->start_mark = first_event->start_mark;
+
+ if (!yaml_parser_parse(parser, &event)) return 0;
+
+ if (!yaml_parser_load_node(parser, &event)) return 0;
+
+ if (!yaml_parser_parse(parser, &event)) return 0;
+ assert(event.type == YAML_DOCUMENT_END_EVENT);
+ /* DOCUMENT-END is expected. */
+
+ parser->document->end_implicit = event.data.document_end.implicit;
+ parser->document->end_mark = event.end_mark;
+
+ return 1;
+}
+
+/*
+ * Compose a node.
+ */
+
+static int
+yaml_parser_load_node(yaml_parser_t *parser, yaml_event_t *first_event)
+{
+ switch (first_event->type) {
+ case YAML_ALIAS_EVENT:
+ return yaml_parser_load_alias(parser, first_event);
+ case YAML_SCALAR_EVENT:
+ return yaml_parser_load_scalar(parser, first_event);
+ case YAML_SEQUENCE_START_EVENT:
+ return yaml_parser_load_sequence(parser, first_event);
+ case YAML_MAPPING_START_EVENT:
+ return yaml_parser_load_mapping(parser, first_event);
+ default:
+ assert(0); /* Could not happen. */
+ return 0;
+ }
+
+ return 0;
+}
+
+/*
+ * Add an anchor.
+ */
+
+static int
+yaml_parser_register_anchor(yaml_parser_t *parser,
+ int index, yaml_char_t *anchor)
+{
+ yaml_alias_data_t data;
+ yaml_alias_data_t *alias_data;
+
+ if (!anchor) return 1;
+
+ data.anchor = anchor;
+ data.index = index;
+ data.mark = parser->document->nodes.start[index-1].start_mark;
+
+ for (alias_data = parser->aliases.start;
+ alias_data != parser->aliases.top; alias_data ++) {
+ if (strcmp((char *)alias_data->anchor, (char *)anchor) == 0) {
+ yaml_free(anchor);
+ return yaml_parser_set_composer_error_context(parser,
+ "found duplicate anchor; first occurence",
+ alias_data->mark, "second occurence", data.mark);
+ }
+ }
+
+ if (!PUSH(parser, parser->aliases, data)) {
+ yaml_free(anchor);
+ return 0;
+ }
+
+ return 1;
+}
+
+/*
+ * Compose a node corresponding to an alias.
+ */
+
+static int
+yaml_parser_load_alias(yaml_parser_t *parser, yaml_event_t *first_event)
+{
+ yaml_char_t *anchor = first_event->data.alias.anchor;
+ yaml_alias_data_t *alias_data;
+
+ for (alias_data = parser->aliases.start;
+ alias_data != parser->aliases.top; alias_data ++) {
+ if (strcmp((char *)alias_data->anchor, (char *)anchor) == 0) {
+ yaml_free(anchor);
+ return alias_data->index;
+ }
+ }
+
+ yaml_free(anchor);
+ return yaml_parser_set_composer_error(parser, "found undefined alias",
+ first_event->start_mark);
+}
+
+/*
+ * Compose a scalar node.
+ */
+
+static int
+yaml_parser_load_scalar(yaml_parser_t *parser, yaml_event_t *first_event)
+{
+ yaml_node_t node;
+ ptrdiff_t node_index;
+ int index;
+ yaml_char_t *tag = first_event->data.scalar.tag;
+
+ if (!STACK_LIMIT(parser, parser->document->nodes, INT_MAX-1)) goto error;
+
+ if (!tag || strcmp((char *)tag, "!") == 0) {
+ yaml_free(tag);
+ tag = yaml_strdup((yaml_char_t *)YAML_DEFAULT_SCALAR_TAG);
+ if (!tag) goto error;
+ }
+
+ SCALAR_NODE_INIT(node, tag, first_event->data.scalar.value,
+ first_event->data.scalar.length, first_event->data.scalar.style,
+ first_event->start_mark, first_event->end_mark);
+
+ if (!PUSH(parser, parser->document->nodes, node)) goto error;
+
+ node_index = parser->document->nodes.top - parser->document->nodes.start;
+#if PTRDIFF_MAX > INT_MAX
+ if (node_index > INT_MAX) goto error;
+#endif
+ index = (int)node_index;
+
+ if (!yaml_parser_register_anchor(parser, index,
+ first_event->data.scalar.anchor)) return 0;
+
+ return index;
+
+error:
+ yaml_free(tag);
+ yaml_free(first_event->data.scalar.anchor);
+ yaml_free(first_event->data.scalar.value);
+ return 0;
+}
+
+/*
+ * Compose a sequence node.
+ */
+
+static int
+yaml_parser_load_sequence(yaml_parser_t *parser, yaml_event_t *first_event)
+{
+ yaml_event_t event;
+ yaml_node_t node;
+ struct {
+ yaml_node_item_t *start;
+ yaml_node_item_t *end;
+ yaml_node_item_t *top;
+ } items = { NULL, NULL, NULL };
+ int index, item_index;
+ ptrdiff_t node_index;
+ yaml_char_t *tag = first_event->data.sequence_start.tag;
+
+ if (!STACK_LIMIT(parser, parser->document->nodes, INT_MAX-1)) goto error;
+
+ if (!tag || strcmp((char *)tag, "!") == 0) {
+ yaml_free(tag);
+ tag = yaml_strdup((yaml_char_t *)YAML_DEFAULT_SEQUENCE_TAG);
+ if (!tag) goto error;
+ }
+
+ if (!STACK_INIT(parser, items, INITIAL_STACK_SIZE)) goto error;
+
+ SEQUENCE_NODE_INIT(node, tag, items.start, items.end,
+ first_event->data.sequence_start.style,
+ first_event->start_mark, first_event->end_mark);
+
+ if (!PUSH(parser, parser->document->nodes, node)) goto error;
+
+ node_index = parser->document->nodes.top - parser->document->nodes.start;
+#if PTRDIFF_MAX > INT_MAX
+ if (node_index > INT_MAX) goto error;
+#endif
+ index = (int)node_index;
+
+ if (!yaml_parser_register_anchor(parser, index,
+ first_event->data.sequence_start.anchor)) return 0;
+
+ if (!yaml_parser_parse(parser, &event)) return 0;
+
+ while (event.type != YAML_SEQUENCE_END_EVENT) {
+ if (!STACK_LIMIT(parser,
+ parser->document->nodes.start[index-1].data.sequence.items,
+ INT_MAX-1)) return 0;
+ item_index = yaml_parser_load_node(parser, &event);
+ if (!item_index) return 0;
+ if (!PUSH(parser,
+ parser->document->nodes.start[index-1].data.sequence.items,
+ item_index)) return 0;
+ if (!yaml_parser_parse(parser, &event)) return 0;
+ }
+
+ parser->document->nodes.start[index-1].end_mark = event.end_mark;
+
+ return index;
+
+error:
+ yaml_free(tag);
+ yaml_free(first_event->data.sequence_start.anchor);
+ return 0;
+}
+
+/*
+ * Compose a mapping node.
+ */
+
+static int
+yaml_parser_load_mapping(yaml_parser_t *parser, yaml_event_t *first_event)
+{
+ yaml_event_t event;
+ yaml_node_t node;
+ struct {
+ yaml_node_pair_t *start;
+ yaml_node_pair_t *end;
+ yaml_node_pair_t *top;
+ } pairs = { NULL, NULL, NULL };
+ int index;
+ ptrdiff_t node_index;
+ yaml_node_pair_t pair;
+ yaml_char_t *tag = first_event->data.mapping_start.tag;
+
+ if (!STACK_LIMIT(parser, parser->document->nodes, INT_MAX-1)) goto error;
+
+ if (!tag || strcmp((char *)tag, "!") == 0) {
+ yaml_free(tag);
+ tag = yaml_strdup((yaml_char_t *)YAML_DEFAULT_MAPPING_TAG);
+ if (!tag) goto error;
+ }
+
+ if (!STACK_INIT(parser, pairs, INITIAL_STACK_SIZE)) goto error;
+
+ MAPPING_NODE_INIT(node, tag, pairs.start, pairs.end,
+ first_event->data.mapping_start.style,
+ first_event->start_mark, first_event->end_mark);
+
+ if (!PUSH(parser, parser->document->nodes, node)) goto error;
+
+ node_index = parser->document->nodes.top - parser->document->nodes.start;
+#if PTRDIFF_MAX > INT_MAX
+ if (node_index > INT_MAX) goto error;
+#endif
+ index = (int)node_index;
+
+ if (!yaml_parser_register_anchor(parser, index,
+ first_event->data.mapping_start.anchor)) return 0;
+
+ if (!yaml_parser_parse(parser, &event)) return 0;
+
+ while (event.type != YAML_MAPPING_END_EVENT) {
+ if (!STACK_LIMIT(parser,
+ parser->document->nodes.start[index-1].data.mapping.pairs,
+ INT_MAX-1)) return 0;
+ pair.key = yaml_parser_load_node(parser, &event);
+ if (!pair.key) return 0;
+ if (!yaml_parser_parse(parser, &event)) return 0;
+ pair.value = yaml_parser_load_node(parser, &event);
+ if (!pair.value) return 0;
+ if (!PUSH(parser,
+ parser->document->nodes.start[index-1].data.mapping.pairs,
+ pair)) return 0;
+ if (!yaml_parser_parse(parser, &event)) return 0;
+ }
+
+ parser->document->nodes.start[index-1].end_mark = event.end_mark;
+
+ return index;
+
+error:
+ yaml_free(tag);
+ yaml_free(first_event->data.mapping_start.anchor);
+ return 0;
+}
+
diff --git a/jni/ruby/ext/psych/yaml/parser.c b/jni/ruby/ext/psych/yaml/parser.c
new file mode 100644
index 0000000..32671b2
--- /dev/null
+++ b/jni/ruby/ext/psych/yaml/parser.c
@@ -0,0 +1,1370 @@
+
+/*
+ * The parser implements the following grammar:
+ *
+ * stream ::= STREAM-START implicit_document? explicit_document* STREAM-END
+ * implicit_document ::= block_node DOCUMENT-END*
+ * explicit_document ::= DIRECTIVE* DOCUMENT-START block_node? DOCUMENT-END*
+ * block_node_or_indentless_sequence ::=
+ * ALIAS
+ * | properties (block_content | indentless_block_sequence)?
+ * | block_content
+ * | indentless_block_sequence
+ * block_node ::= ALIAS
+ * | properties block_content?
+ * | block_content
+ * flow_node ::= ALIAS
+ * | properties flow_content?
+ * | flow_content
+ * properties ::= TAG ANCHOR? | ANCHOR TAG?
+ * block_content ::= block_collection | flow_collection | SCALAR
+ * flow_content ::= flow_collection | SCALAR
+ * block_collection ::= block_sequence | block_mapping
+ * flow_collection ::= flow_sequence | flow_mapping
+ * block_sequence ::= BLOCK-SEQUENCE-START (BLOCK-ENTRY block_node?)* BLOCK-END
+ * indentless_sequence ::= (BLOCK-ENTRY block_node?)+
+ * block_mapping ::= BLOCK-MAPPING_START
+ * ((KEY block_node_or_indentless_sequence?)?
+ * (VALUE block_node_or_indentless_sequence?)?)*
+ * BLOCK-END
+ * flow_sequence ::= FLOW-SEQUENCE-START
+ * (flow_sequence_entry FLOW-ENTRY)*
+ * flow_sequence_entry?
+ * FLOW-SEQUENCE-END
+ * flow_sequence_entry ::= flow_node | KEY flow_node? (VALUE flow_node?)?
+ * flow_mapping ::= FLOW-MAPPING-START
+ * (flow_mapping_entry FLOW-ENTRY)*
+ * flow_mapping_entry?
+ * FLOW-MAPPING-END
+ * flow_mapping_entry ::= flow_node | KEY flow_node? (VALUE flow_node?)?
+ */
+
+#include "yaml_private.h"
+
+/*
+ * Peek the next token in the token queue.
+ */
+
+#define PEEK_TOKEN(parser) \
+ ((parser->token_available || yaml_parser_fetch_more_tokens(parser)) ? \
+ parser->tokens.head : NULL)
+
+/*
+ * Remove the next token from the queue (must be called after PEEK_TOKEN).
+ */
+
+#define SKIP_TOKEN(parser) \
+ (parser->token_available = 0, \
+ parser->tokens_parsed ++, \
+ parser->stream_end_produced = \
+ (parser->tokens.head->type == YAML_STREAM_END_TOKEN), \
+ parser->tokens.head ++)
+
+/*
+ * Public API declarations.
+ */
+
+YAML_DECLARE(int)
+yaml_parser_parse(yaml_parser_t *parser, yaml_event_t *event);
+
+/*
+ * Error handling.
+ */
+
+static int
+yaml_parser_set_parser_error(yaml_parser_t *parser,
+ const char *problem, yaml_mark_t problem_mark);
+
+static int
+yaml_parser_set_parser_error_context(yaml_parser_t *parser,
+ const char *context, yaml_mark_t context_mark,
+ const char *problem, yaml_mark_t problem_mark);
+
+/*
+ * State functions.
+ */
+
+static int
+yaml_parser_state_machine(yaml_parser_t *parser, yaml_event_t *event);
+
+static int
+yaml_parser_parse_stream_start(yaml_parser_t *parser, yaml_event_t *event);
+
+static int
+yaml_parser_parse_document_start(yaml_parser_t *parser, yaml_event_t *event,
+ int implicit);
+
+static int
+yaml_parser_parse_document_content(yaml_parser_t *parser, yaml_event_t *event);
+
+static int
+yaml_parser_parse_document_end(yaml_parser_t *parser, yaml_event_t *event);
+
+static int
+yaml_parser_parse_node(yaml_parser_t *parser, yaml_event_t *event,
+ int block, int indentless_sequence);
+
+static int
+yaml_parser_parse_block_sequence_entry(yaml_parser_t *parser,
+ yaml_event_t *event, int first);
+
+static int
+yaml_parser_parse_indentless_sequence_entry(yaml_parser_t *parser,
+ yaml_event_t *event);
+
+static int
+yaml_parser_parse_block_mapping_key(yaml_parser_t *parser,
+ yaml_event_t *event, int first);
+
+static int
+yaml_parser_parse_block_mapping_value(yaml_parser_t *parser,
+ yaml_event_t *event);
+
+static int
+yaml_parser_parse_flow_sequence_entry(yaml_parser_t *parser,
+ yaml_event_t *event, int first);
+
+static int
+yaml_parser_parse_flow_sequence_entry_mapping_key(yaml_parser_t *parser,
+ yaml_event_t *event);
+
+static int
+yaml_parser_parse_flow_sequence_entry_mapping_value(yaml_parser_t *parser,
+ yaml_event_t *event);
+
+static int
+yaml_parser_parse_flow_sequence_entry_mapping_end(yaml_parser_t *parser,
+ yaml_event_t *event);
+
+static int
+yaml_parser_parse_flow_mapping_key(yaml_parser_t *parser,
+ yaml_event_t *event, int first);
+
+static int
+yaml_parser_parse_flow_mapping_value(yaml_parser_t *parser,
+ yaml_event_t *event, int empty);
+
+/*
+ * Utility functions.
+ */
+
+static int
+yaml_parser_process_empty_scalar(yaml_parser_t *parser,
+ yaml_event_t *event, yaml_mark_t mark);
+
+static int
+yaml_parser_process_directives(yaml_parser_t *parser,
+ yaml_version_directive_t **version_directive_ref,
+ yaml_tag_directive_t **tag_directives_start_ref,
+ yaml_tag_directive_t **tag_directives_end_ref);
+
+static int
+yaml_parser_append_tag_directive(yaml_parser_t *parser,
+ yaml_tag_directive_t value, int allow_duplicates, yaml_mark_t mark);
+
+/*
+ * Get the next event.
+ */
+
+YAML_DECLARE(int)
+yaml_parser_parse(yaml_parser_t *parser, yaml_event_t *event)
+{
+ assert(parser); /* Non-NULL parser object is expected. */
+ assert(event); /* Non-NULL event object is expected. */
+
+ /* Erase the event object. */
+
+ memset(event, 0, sizeof(yaml_event_t));
+
+ /* No events after the end of the stream or error. */
+
+ if (parser->stream_end_produced || parser->error ||
+ parser->state == YAML_PARSE_END_STATE) {
+ return 1;
+ }
+
+ /* Generate the next event. */
+
+ return yaml_parser_state_machine(parser, event);
+}
+
+/*
+ * Set parser error.
+ */
+
+static int
+yaml_parser_set_parser_error(yaml_parser_t *parser,
+ const char *problem, yaml_mark_t problem_mark)
+{
+ parser->error = YAML_PARSER_ERROR;
+ parser->problem = problem;
+ parser->problem_mark = problem_mark;
+
+ return 0;
+}
+
+static int
+yaml_parser_set_parser_error_context(yaml_parser_t *parser,
+ const char *context, yaml_mark_t context_mark,
+ const char *problem, yaml_mark_t problem_mark)
+{
+ parser->error = YAML_PARSER_ERROR;
+ parser->context = context;
+ parser->context_mark = context_mark;
+ parser->problem = problem;
+ parser->problem_mark = problem_mark;
+
+ return 0;
+}
+
+
+/*
+ * State dispatcher.
+ */
+
+static int
+yaml_parser_state_machine(yaml_parser_t *parser, yaml_event_t *event)
+{
+ switch (parser->state)
+ {
+ case YAML_PARSE_STREAM_START_STATE:
+ return yaml_parser_parse_stream_start(parser, event);
+
+ case YAML_PARSE_IMPLICIT_DOCUMENT_START_STATE:
+ return yaml_parser_parse_document_start(parser, event, 1);
+
+ case YAML_PARSE_DOCUMENT_START_STATE:
+ return yaml_parser_parse_document_start(parser, event, 0);
+
+ case YAML_PARSE_DOCUMENT_CONTENT_STATE:
+ return yaml_parser_parse_document_content(parser, event);
+
+ case YAML_PARSE_DOCUMENT_END_STATE:
+ return yaml_parser_parse_document_end(parser, event);
+
+ case YAML_PARSE_BLOCK_NODE_STATE:
+ return yaml_parser_parse_node(parser, event, 1, 0);
+
+ case YAML_PARSE_BLOCK_NODE_OR_INDENTLESS_SEQUENCE_STATE:
+ return yaml_parser_parse_node(parser, event, 1, 1);
+
+ case YAML_PARSE_FLOW_NODE_STATE:
+ return yaml_parser_parse_node(parser, event, 0, 0);
+
+ case YAML_PARSE_BLOCK_SEQUENCE_FIRST_ENTRY_STATE:
+ return yaml_parser_parse_block_sequence_entry(parser, event, 1);
+
+ case YAML_PARSE_BLOCK_SEQUENCE_ENTRY_STATE:
+ return yaml_parser_parse_block_sequence_entry(parser, event, 0);
+
+ case YAML_PARSE_INDENTLESS_SEQUENCE_ENTRY_STATE:
+ return yaml_parser_parse_indentless_sequence_entry(parser, event);
+
+ case YAML_PARSE_BLOCK_MAPPING_FIRST_KEY_STATE:
+ return yaml_parser_parse_block_mapping_key(parser, event, 1);
+
+ case YAML_PARSE_BLOCK_MAPPING_KEY_STATE:
+ return yaml_parser_parse_block_mapping_key(parser, event, 0);
+
+ case YAML_PARSE_BLOCK_MAPPING_VALUE_STATE:
+ return yaml_parser_parse_block_mapping_value(parser, event);
+
+ case YAML_PARSE_FLOW_SEQUENCE_FIRST_ENTRY_STATE:
+ return yaml_parser_parse_flow_sequence_entry(parser, event, 1);
+
+ case YAML_PARSE_FLOW_SEQUENCE_ENTRY_STATE:
+ return yaml_parser_parse_flow_sequence_entry(parser, event, 0);
+
+ case YAML_PARSE_FLOW_SEQUENCE_ENTRY_MAPPING_KEY_STATE:
+ return yaml_parser_parse_flow_sequence_entry_mapping_key(parser, event);
+
+ case YAML_PARSE_FLOW_SEQUENCE_ENTRY_MAPPING_VALUE_STATE:
+ return yaml_parser_parse_flow_sequence_entry_mapping_value(parser, event);
+
+ case YAML_PARSE_FLOW_SEQUENCE_ENTRY_MAPPING_END_STATE:
+ return yaml_parser_parse_flow_sequence_entry_mapping_end(parser, event);
+
+ case YAML_PARSE_FLOW_MAPPING_FIRST_KEY_STATE:
+ return yaml_parser_parse_flow_mapping_key(parser, event, 1);
+
+ case YAML_PARSE_FLOW_MAPPING_KEY_STATE:
+ return yaml_parser_parse_flow_mapping_key(parser, event, 0);
+
+ case YAML_PARSE_FLOW_MAPPING_VALUE_STATE:
+ return yaml_parser_parse_flow_mapping_value(parser, event, 0);
+
+ case YAML_PARSE_FLOW_MAPPING_EMPTY_VALUE_STATE:
+ return yaml_parser_parse_flow_mapping_value(parser, event, 1);
+
+ default:
+ assert(1); /* Invalid state. */
+ }
+
+ return 0;
+}
+
+/*
+ * Parse the production:
+ * stream ::= STREAM-START implicit_document? explicit_document* STREAM-END
+ * ************
+ */
+
+static int
+yaml_parser_parse_stream_start(yaml_parser_t *parser, yaml_event_t *event)
+{
+ yaml_token_t *token;
+
+ token = PEEK_TOKEN(parser);
+ if (!token) return 0;
+
+ if (token->type != YAML_STREAM_START_TOKEN) {
+ return yaml_parser_set_parser_error(parser,
+ "did not find expected <stream-start>", token->start_mark);
+ }
+
+ parser->state = YAML_PARSE_IMPLICIT_DOCUMENT_START_STATE;
+ STREAM_START_EVENT_INIT(*event, token->data.stream_start.encoding,
+ token->start_mark, token->start_mark);
+ SKIP_TOKEN(parser);
+
+ return 1;
+}
+
+/*
+ * Parse the productions:
+ * implicit_document ::= block_node DOCUMENT-END*
+ * *
+ * explicit_document ::= DIRECTIVE* DOCUMENT-START block_node? DOCUMENT-END*
+ * *************************
+ */
+
+static int
+yaml_parser_parse_document_start(yaml_parser_t *parser, yaml_event_t *event,
+ int implicit)
+{
+ yaml_token_t *token;
+ yaml_version_directive_t *version_directive = NULL;
+ struct {
+ yaml_tag_directive_t *start;
+ yaml_tag_directive_t *end;
+ } tag_directives = { NULL, NULL };
+
+ token = PEEK_TOKEN(parser);
+ if (!token) return 0;
+
+ /* Parse extra document end indicators. */
+
+ if (!implicit)
+ {
+ while (token->type == YAML_DOCUMENT_END_TOKEN) {
+ SKIP_TOKEN(parser);
+ token = PEEK_TOKEN(parser);
+ if (!token) return 0;
+ }
+ }
+
+ /* Parse an implicit document. */
+
+ if (implicit && token->type != YAML_VERSION_DIRECTIVE_TOKEN &&
+ token->type != YAML_TAG_DIRECTIVE_TOKEN &&
+ token->type != YAML_DOCUMENT_START_TOKEN &&
+ token->type != YAML_STREAM_END_TOKEN)
+ {
+ if (!yaml_parser_process_directives(parser, NULL, NULL, NULL))
+ return 0;
+ if (!PUSH(parser, parser->states, YAML_PARSE_DOCUMENT_END_STATE))
+ return 0;
+ parser->state = YAML_PARSE_BLOCK_NODE_STATE;
+ DOCUMENT_START_EVENT_INIT(*event, NULL, NULL, NULL, 1,
+ token->start_mark, token->start_mark);
+ return 1;
+ }
+
+ /* Parse an explicit document. */
+
+ else if (token->type != YAML_STREAM_END_TOKEN)
+ {
+ yaml_mark_t start_mark, end_mark;
+ start_mark = token->start_mark;
+ if (!yaml_parser_process_directives(parser, &version_directive,
+ &tag_directives.start, &tag_directives.end))
+ return 0;
+ token = PEEK_TOKEN(parser);
+ if (!token) goto error;
+ if (token->type != YAML_DOCUMENT_START_TOKEN) {
+ yaml_parser_set_parser_error(parser,
+ "did not find expected <document start>", token->start_mark);
+ goto error;
+ }
+ if (!PUSH(parser, parser->states, YAML_PARSE_DOCUMENT_END_STATE))
+ goto error;
+ parser->state = YAML_PARSE_DOCUMENT_CONTENT_STATE;
+ end_mark = token->end_mark;
+ DOCUMENT_START_EVENT_INIT(*event, version_directive,
+ tag_directives.start, tag_directives.end, 0,
+ start_mark, end_mark);
+ SKIP_TOKEN(parser);
+ version_directive = NULL;
+ tag_directives.start = tag_directives.end = NULL;
+ return 1;
+ }
+
+ /* Parse the stream end. */
+
+ else
+ {
+ parser->state = YAML_PARSE_END_STATE;
+ STREAM_END_EVENT_INIT(*event, token->start_mark, token->end_mark);
+ SKIP_TOKEN(parser);
+ return 1;
+ }
+
+error:
+ yaml_free(version_directive);
+ while (tag_directives.start != tag_directives.end) {
+ yaml_free(tag_directives.end[-1].handle);
+ yaml_free(tag_directives.end[-1].prefix);
+ tag_directives.end --;
+ }
+ yaml_free(tag_directives.start);
+ return 0;
+}
+
+/*
+ * Parse the productions:
+ * explicit_document ::= DIRECTIVE* DOCUMENT-START block_node? DOCUMENT-END*
+ * ***********
+ */
+
+static int
+yaml_parser_parse_document_content(yaml_parser_t *parser, yaml_event_t *event)
+{
+ yaml_token_t *token;
+
+ token = PEEK_TOKEN(parser);
+ if (!token) return 0;
+
+ if (token->type == YAML_VERSION_DIRECTIVE_TOKEN ||
+ token->type == YAML_TAG_DIRECTIVE_TOKEN ||
+ token->type == YAML_DOCUMENT_START_TOKEN ||
+ token->type == YAML_DOCUMENT_END_TOKEN ||
+ token->type == YAML_STREAM_END_TOKEN) {
+ parser->state = POP(parser, parser->states);
+ return yaml_parser_process_empty_scalar(parser, event,
+ token->start_mark);
+ }
+ else {
+ return yaml_parser_parse_node(parser, event, 1, 0);
+ }
+}
+
+/*
+ * Parse the productions:
+ * implicit_document ::= block_node DOCUMENT-END*
+ * *************
+ * explicit_document ::= DIRECTIVE* DOCUMENT-START block_node? DOCUMENT-END*
+ * *************
+ */
+
+static int
+yaml_parser_parse_document_end(yaml_parser_t *parser, yaml_event_t *event)
+{
+ yaml_token_t *token;
+ yaml_mark_t start_mark, end_mark;
+ int implicit = 1;
+
+ token = PEEK_TOKEN(parser);
+ if (!token) return 0;
+
+ start_mark = end_mark = token->start_mark;
+
+ if (token->type == YAML_DOCUMENT_END_TOKEN) {
+ end_mark = token->end_mark;
+ SKIP_TOKEN(parser);
+ implicit = 0;
+ }
+
+ while (!STACK_EMPTY(parser, parser->tag_directives)) {
+ yaml_tag_directive_t tag_directive = POP(parser, parser->tag_directives);
+ yaml_free(tag_directive.handle);
+ yaml_free(tag_directive.prefix);
+ }
+
+ parser->state = YAML_PARSE_DOCUMENT_START_STATE;
+ DOCUMENT_END_EVENT_INIT(*event, implicit, start_mark, end_mark);
+
+ return 1;
+}
+
+/*
+ * Parse the productions:
+ * block_node_or_indentless_sequence ::=
+ * ALIAS
+ * *****
+ * | properties (block_content | indentless_block_sequence)?
+ * ********** *
+ * | block_content | indentless_block_sequence
+ * *
+ * block_node ::= ALIAS
+ * *****
+ * | properties block_content?
+ * ********** *
+ * | block_content
+ * *
+ * flow_node ::= ALIAS
+ * *****
+ * | properties flow_content?
+ * ********** *
+ * | flow_content
+ * *
+ * properties ::= TAG ANCHOR? | ANCHOR TAG?
+ * *************************
+ * block_content ::= block_collection | flow_collection | SCALAR
+ * ******
+ * flow_content ::= flow_collection | SCALAR
+ * ******
+ */
+
+static int
+yaml_parser_parse_node(yaml_parser_t *parser, yaml_event_t *event,
+ int block, int indentless_sequence)
+{
+ yaml_token_t *token;
+ yaml_char_t *anchor = NULL;
+ yaml_char_t *tag_handle = NULL;
+ yaml_char_t *tag_suffix = NULL;
+ yaml_char_t *tag = NULL;
+ yaml_mark_t start_mark, end_mark, tag_mark;
+ int implicit;
+
+ token = PEEK_TOKEN(parser);
+ if (!token) return 0;
+
+ if (token->type == YAML_ALIAS_TOKEN)
+ {
+ parser->state = POP(parser, parser->states);
+ ALIAS_EVENT_INIT(*event, token->data.alias.value,
+ token->start_mark, token->end_mark);
+ SKIP_TOKEN(parser);
+ return 1;
+ }
+
+ else
+ {
+ start_mark = end_mark = token->start_mark;
+
+ if (token->type == YAML_ANCHOR_TOKEN)
+ {
+ anchor = token->data.anchor.value;
+ start_mark = token->start_mark;
+ end_mark = token->end_mark;
+ SKIP_TOKEN(parser);
+ token = PEEK_TOKEN(parser);
+ if (!token) goto error;
+ if (token->type == YAML_TAG_TOKEN)
+ {
+ tag_handle = token->data.tag.handle;
+ tag_suffix = token->data.tag.suffix;
+ tag_mark = token->start_mark;
+ end_mark = token->end_mark;
+ SKIP_TOKEN(parser);
+ token = PEEK_TOKEN(parser);
+ if (!token) goto error;
+ }
+ }
+ else if (token->type == YAML_TAG_TOKEN)
+ {
+ tag_handle = token->data.tag.handle;
+ tag_suffix = token->data.tag.suffix;
+ start_mark = tag_mark = token->start_mark;
+ end_mark = token->end_mark;
+ SKIP_TOKEN(parser);
+ token = PEEK_TOKEN(parser);
+ if (!token) goto error;
+ if (token->type == YAML_ANCHOR_TOKEN)
+ {
+ anchor = token->data.anchor.value;
+ end_mark = token->end_mark;
+ SKIP_TOKEN(parser);
+ token = PEEK_TOKEN(parser);
+ if (!token) goto error;
+ }
+ }
+
+ if (tag_handle) {
+ if (!*tag_handle) {
+ tag = tag_suffix;
+ yaml_free(tag_handle);
+ tag_handle = tag_suffix = NULL;
+ }
+ else {
+ yaml_tag_directive_t *tag_directive;
+ for (tag_directive = parser->tag_directives.start;
+ tag_directive != parser->tag_directives.top;
+ tag_directive ++) {
+ if (strcmp((char *)tag_directive->handle, (char *)tag_handle) == 0) {
+ size_t prefix_len = strlen((char *)tag_directive->prefix);
+ size_t suffix_len = strlen((char *)tag_suffix);
+ tag = yaml_malloc(prefix_len+suffix_len+1);
+ if (!tag) {
+ parser->error = YAML_MEMORY_ERROR;
+ goto error;
+ }
+ memcpy(tag, tag_directive->prefix, prefix_len);
+ memcpy(tag+prefix_len, tag_suffix, suffix_len);
+ tag[prefix_len+suffix_len] = '\0';
+ yaml_free(tag_handle);
+ yaml_free(tag_suffix);
+ tag_handle = tag_suffix = NULL;
+ break;
+ }
+ }
+ if (!tag) {
+ yaml_parser_set_parser_error_context(parser,
+ "while parsing a node", start_mark,
+ "found undefined tag handle", tag_mark);
+ goto error;
+ }
+ }
+ }
+
+ implicit = (!tag || !*tag);
+ if (indentless_sequence && token->type == YAML_BLOCK_ENTRY_TOKEN) {
+ end_mark = token->end_mark;
+ parser->state = YAML_PARSE_INDENTLESS_SEQUENCE_ENTRY_STATE;
+ SEQUENCE_START_EVENT_INIT(*event, anchor, tag, implicit,
+ YAML_BLOCK_SEQUENCE_STYLE, start_mark, end_mark);
+ return 1;
+ }
+ else {
+ if (token->type == YAML_SCALAR_TOKEN) {
+ int plain_implicit = 0;
+ int quoted_implicit = 0;
+ end_mark = token->end_mark;
+ if ((token->data.scalar.style == YAML_PLAIN_SCALAR_STYLE && !tag)
+ || (tag && strcmp((char *)tag, "!") == 0)) {
+ plain_implicit = 1;
+ }
+ else if (!tag) {
+ quoted_implicit = 1;
+ }
+ parser->state = POP(parser, parser->states);
+ SCALAR_EVENT_INIT(*event, anchor, tag,
+ token->data.scalar.value, token->data.scalar.length,
+ plain_implicit, quoted_implicit,
+ token->data.scalar.style, start_mark, end_mark);
+ SKIP_TOKEN(parser);
+ return 1;
+ }
+ else if (token->type == YAML_FLOW_SEQUENCE_START_TOKEN) {
+ end_mark = token->end_mark;
+ parser->state = YAML_PARSE_FLOW_SEQUENCE_FIRST_ENTRY_STATE;
+ SEQUENCE_START_EVENT_INIT(*event, anchor, tag, implicit,
+ YAML_FLOW_SEQUENCE_STYLE, start_mark, end_mark);
+ return 1;
+ }
+ else if (token->type == YAML_FLOW_MAPPING_START_TOKEN) {
+ end_mark = token->end_mark;
+ parser->state = YAML_PARSE_FLOW_MAPPING_FIRST_KEY_STATE;
+ MAPPING_START_EVENT_INIT(*event, anchor, tag, implicit,
+ YAML_FLOW_MAPPING_STYLE, start_mark, end_mark);
+ return 1;
+ }
+ else if (block && token->type == YAML_BLOCK_SEQUENCE_START_TOKEN) {
+ end_mark = token->end_mark;
+ parser->state = YAML_PARSE_BLOCK_SEQUENCE_FIRST_ENTRY_STATE;
+ SEQUENCE_START_EVENT_INIT(*event, anchor, tag, implicit,
+ YAML_BLOCK_SEQUENCE_STYLE, start_mark, end_mark);
+ return 1;
+ }
+ else if (block && token->type == YAML_BLOCK_MAPPING_START_TOKEN) {
+ end_mark = token->end_mark;
+ parser->state = YAML_PARSE_BLOCK_MAPPING_FIRST_KEY_STATE;
+ MAPPING_START_EVENT_INIT(*event, anchor, tag, implicit,
+ YAML_BLOCK_MAPPING_STYLE, start_mark, end_mark);
+ return 1;
+ }
+ else if (anchor || tag) {
+ yaml_char_t *value = yaml_malloc(1);
+ if (!value) {
+ parser->error = YAML_MEMORY_ERROR;
+ goto error;
+ }
+ value[0] = '\0';
+ parser->state = POP(parser, parser->states);
+ SCALAR_EVENT_INIT(*event, anchor, tag, value, 0,
+ implicit, 0, YAML_PLAIN_SCALAR_STYLE,
+ start_mark, end_mark);
+ return 1;
+ }
+ else {
+ yaml_parser_set_parser_error_context(parser,
+ (block ? "while parsing a block node"
+ : "while parsing a flow node"), start_mark,
+ "did not find expected node content", token->start_mark);
+ goto error;
+ }
+ }
+ }
+
+error:
+ yaml_free(anchor);
+ yaml_free(tag_handle);
+ yaml_free(tag_suffix);
+ yaml_free(tag);
+
+ return 0;
+}
+
+/*
+ * Parse the productions:
+ * block_sequence ::= BLOCK-SEQUENCE-START (BLOCK-ENTRY block_node?)* BLOCK-END
+ * ******************** *********** * *********
+ */
+
+static int
+yaml_parser_parse_block_sequence_entry(yaml_parser_t *parser,
+ yaml_event_t *event, int first)
+{
+ yaml_token_t *token;
+
+ if (first) {
+ token = PEEK_TOKEN(parser);
+ if (!PUSH(parser, parser->marks, token->start_mark))
+ return 0;
+ SKIP_TOKEN(parser);
+ }
+
+ token = PEEK_TOKEN(parser);
+ if (!token) return 0;
+
+ if (token->type == YAML_BLOCK_ENTRY_TOKEN)
+ {
+ yaml_mark_t mark = token->end_mark;
+ SKIP_TOKEN(parser);
+ token = PEEK_TOKEN(parser);
+ if (!token) return 0;
+ if (token->type != YAML_BLOCK_ENTRY_TOKEN &&
+ token->type != YAML_BLOCK_END_TOKEN) {
+ if (!PUSH(parser, parser->states,
+ YAML_PARSE_BLOCK_SEQUENCE_ENTRY_STATE))
+ return 0;
+ return yaml_parser_parse_node(parser, event, 1, 0);
+ }
+ else {
+ parser->state = YAML_PARSE_BLOCK_SEQUENCE_ENTRY_STATE;
+ return yaml_parser_process_empty_scalar(parser, event, mark);
+ }
+ }
+
+ else if (token->type == YAML_BLOCK_END_TOKEN)
+ {
+ parser->state = POP(parser, parser->states);
+ (void)POP(parser, parser->marks);
+ SEQUENCE_END_EVENT_INIT(*event, token->start_mark, token->end_mark);
+ SKIP_TOKEN(parser);
+ return 1;
+ }
+
+ else
+ {
+ return yaml_parser_set_parser_error_context(parser,
+ "while parsing a block collection", POP(parser, parser->marks),
+ "did not find expected '-' indicator", token->start_mark);
+ }
+}
+
+/*
+ * Parse the productions:
+ * indentless_sequence ::= (BLOCK-ENTRY block_node?)+
+ * *********** *
+ */
+
+static int
+yaml_parser_parse_indentless_sequence_entry(yaml_parser_t *parser,
+ yaml_event_t *event)
+{
+ yaml_token_t *token;
+
+ token = PEEK_TOKEN(parser);
+ if (!token) return 0;
+
+ if (token->type == YAML_BLOCK_ENTRY_TOKEN)
+ {
+ yaml_mark_t mark = token->end_mark;
+ SKIP_TOKEN(parser);
+ token = PEEK_TOKEN(parser);
+ if (!token) return 0;
+ if (token->type != YAML_BLOCK_ENTRY_TOKEN &&
+ token->type != YAML_KEY_TOKEN &&
+ token->type != YAML_VALUE_TOKEN &&
+ token->type != YAML_BLOCK_END_TOKEN) {
+ if (!PUSH(parser, parser->states,
+ YAML_PARSE_INDENTLESS_SEQUENCE_ENTRY_STATE))
+ return 0;
+ return yaml_parser_parse_node(parser, event, 1, 0);
+ }
+ else {
+ parser->state = YAML_PARSE_INDENTLESS_SEQUENCE_ENTRY_STATE;
+ return yaml_parser_process_empty_scalar(parser, event, mark);
+ }
+ }
+
+ else
+ {
+ parser->state = POP(parser, parser->states);
+ SEQUENCE_END_EVENT_INIT(*event, token->start_mark, token->start_mark);
+ return 1;
+ }
+}
+
+/*
+ * Parse the productions:
+ * block_mapping ::= BLOCK-MAPPING_START
+ * *******************
+ * ((KEY block_node_or_indentless_sequence?)?
+ * *** *
+ * (VALUE block_node_or_indentless_sequence?)?)*
+ *
+ * BLOCK-END
+ * *********
+ */
+
+static int
+yaml_parser_parse_block_mapping_key(yaml_parser_t *parser,
+ yaml_event_t *event, int first)
+{
+ yaml_token_t *token;
+
+ if (first) {
+ token = PEEK_TOKEN(parser);
+ if (!PUSH(parser, parser->marks, token->start_mark))
+ return 0;
+ SKIP_TOKEN(parser);
+ }
+
+ token = PEEK_TOKEN(parser);
+ if (!token) return 0;
+
+ if (token->type == YAML_KEY_TOKEN)
+ {
+ yaml_mark_t mark = token->end_mark;
+ SKIP_TOKEN(parser);
+ token = PEEK_TOKEN(parser);
+ if (!token) return 0;
+ if (token->type != YAML_KEY_TOKEN &&
+ token->type != YAML_VALUE_TOKEN &&
+ token->type != YAML_BLOCK_END_TOKEN) {
+ if (!PUSH(parser, parser->states,
+ YAML_PARSE_BLOCK_MAPPING_VALUE_STATE))
+ return 0;
+ return yaml_parser_parse_node(parser, event, 1, 1);
+ }
+ else {
+ parser->state = YAML_PARSE_BLOCK_MAPPING_VALUE_STATE;
+ return yaml_parser_process_empty_scalar(parser, event, mark);
+ }
+ }
+
+ else if (token->type == YAML_BLOCK_END_TOKEN)
+ {
+ parser->state = POP(parser, parser->states);
+ (void)POP(parser, parser->marks);
+ MAPPING_END_EVENT_INIT(*event, token->start_mark, token->end_mark);
+ SKIP_TOKEN(parser);
+ return 1;
+ }
+
+ else
+ {
+ return yaml_parser_set_parser_error_context(parser,
+ "while parsing a block mapping", POP(parser, parser->marks),
+ "did not find expected key", token->start_mark);
+ }
+}
+
+/*
+ * Parse the productions:
+ * block_mapping ::= BLOCK-MAPPING_START
+ *
+ * ((KEY block_node_or_indentless_sequence?)?
+ *
+ * (VALUE block_node_or_indentless_sequence?)?)*
+ * ***** *
+ * BLOCK-END
+ *
+ */
+
+static int
+yaml_parser_parse_block_mapping_value(yaml_parser_t *parser,
+ yaml_event_t *event)
+{
+ yaml_token_t *token;
+
+ token = PEEK_TOKEN(parser);
+ if (!token) return 0;
+
+ if (token->type == YAML_VALUE_TOKEN)
+ {
+ yaml_mark_t mark = token->end_mark;
+ SKIP_TOKEN(parser);
+ token = PEEK_TOKEN(parser);
+ if (!token) return 0;
+ if (token->type != YAML_KEY_TOKEN &&
+ token->type != YAML_VALUE_TOKEN &&
+ token->type != YAML_BLOCK_END_TOKEN) {
+ if (!PUSH(parser, parser->states,
+ YAML_PARSE_BLOCK_MAPPING_KEY_STATE))
+ return 0;
+ return yaml_parser_parse_node(parser, event, 1, 1);
+ }
+ else {
+ parser->state = YAML_PARSE_BLOCK_MAPPING_KEY_STATE;
+ return yaml_parser_process_empty_scalar(parser, event, mark);
+ }
+ }
+
+ else
+ {
+ parser->state = YAML_PARSE_BLOCK_MAPPING_KEY_STATE;
+ return yaml_parser_process_empty_scalar(parser, event, token->start_mark);
+ }
+}
+
+/*
+ * Parse the productions:
+ * flow_sequence ::= FLOW-SEQUENCE-START
+ * *******************
+ * (flow_sequence_entry FLOW-ENTRY)*
+ * * **********
+ * flow_sequence_entry?
+ * *
+ * FLOW-SEQUENCE-END
+ * *****************
+ * flow_sequence_entry ::= flow_node | KEY flow_node? (VALUE flow_node?)?
+ * *
+ */
+
+static int
+yaml_parser_parse_flow_sequence_entry(yaml_parser_t *parser,
+ yaml_event_t *event, int first)
+{
+ yaml_token_t *token;
+
+ if (first) {
+ token = PEEK_TOKEN(parser);
+ if (!PUSH(parser, parser->marks, token->start_mark))
+ return 0;
+ SKIP_TOKEN(parser);
+ }
+
+ token = PEEK_TOKEN(parser);
+ if (!token) return 0;
+
+ if (token->type != YAML_FLOW_SEQUENCE_END_TOKEN)
+ {
+ if (!first) {
+ if (token->type == YAML_FLOW_ENTRY_TOKEN) {
+ SKIP_TOKEN(parser);
+ token = PEEK_TOKEN(parser);
+ if (!token) return 0;
+ }
+ else {
+ return yaml_parser_set_parser_error_context(parser,
+ "while parsing a flow sequence", POP(parser, parser->marks),
+ "did not find expected ',' or ']'", token->start_mark);
+ }
+ }
+
+ if (token->type == YAML_KEY_TOKEN) {
+ parser->state = YAML_PARSE_FLOW_SEQUENCE_ENTRY_MAPPING_KEY_STATE;
+ MAPPING_START_EVENT_INIT(*event, NULL, NULL,
+ 1, YAML_FLOW_MAPPING_STYLE,
+ token->start_mark, token->end_mark);
+ SKIP_TOKEN(parser);
+ return 1;
+ }
+
+ else if (token->type != YAML_FLOW_SEQUENCE_END_TOKEN) {
+ if (!PUSH(parser, parser->states,
+ YAML_PARSE_FLOW_SEQUENCE_ENTRY_STATE))
+ return 0;
+ return yaml_parser_parse_node(parser, event, 0, 0);
+ }
+ }
+
+ parser->state = POP(parser, parser->states);
+ (void)POP(parser, parser->marks);
+ SEQUENCE_END_EVENT_INIT(*event, token->start_mark, token->end_mark);
+ SKIP_TOKEN(parser);
+ return 1;
+}
+
+/*
+ * Parse the productions:
+ * flow_sequence_entry ::= flow_node | KEY flow_node? (VALUE flow_node?)?
+ * *** *
+ */
+
+static int
+yaml_parser_parse_flow_sequence_entry_mapping_key(yaml_parser_t *parser,
+ yaml_event_t *event)
+{
+ yaml_token_t *token;
+
+ token = PEEK_TOKEN(parser);
+ if (!token) return 0;
+
+ if (token->type != YAML_VALUE_TOKEN && token->type != YAML_FLOW_ENTRY_TOKEN
+ && token->type != YAML_FLOW_SEQUENCE_END_TOKEN) {
+ if (!PUSH(parser, parser->states,
+ YAML_PARSE_FLOW_SEQUENCE_ENTRY_MAPPING_VALUE_STATE))
+ return 0;
+ return yaml_parser_parse_node(parser, event, 0, 0);
+ }
+ else {
+ yaml_mark_t mark = token->end_mark;
+ SKIP_TOKEN(parser);
+ parser->state = YAML_PARSE_FLOW_SEQUENCE_ENTRY_MAPPING_VALUE_STATE;
+ return yaml_parser_process_empty_scalar(parser, event, mark);
+ }
+}
+
+/*
+ * Parse the productions:
+ * flow_sequence_entry ::= flow_node | KEY flow_node? (VALUE flow_node?)?
+ * ***** *
+ */
+
+static int
+yaml_parser_parse_flow_sequence_entry_mapping_value(yaml_parser_t *parser,
+ yaml_event_t *event)
+{
+ yaml_token_t *token;
+
+ token = PEEK_TOKEN(parser);
+ if (!token) return 0;
+
+ if (token->type == YAML_VALUE_TOKEN) {
+ SKIP_TOKEN(parser);
+ token = PEEK_TOKEN(parser);
+ if (!token) return 0;
+ if (token->type != YAML_FLOW_ENTRY_TOKEN
+ && token->type != YAML_FLOW_SEQUENCE_END_TOKEN) {
+ if (!PUSH(parser, parser->states,
+ YAML_PARSE_FLOW_SEQUENCE_ENTRY_MAPPING_END_STATE))
+ return 0;
+ return yaml_parser_parse_node(parser, event, 0, 0);
+ }
+ }
+ parser->state = YAML_PARSE_FLOW_SEQUENCE_ENTRY_MAPPING_END_STATE;
+ return yaml_parser_process_empty_scalar(parser, event, token->start_mark);
+}
+
+/*
+ * Parse the productions:
+ * flow_sequence_entry ::= flow_node | KEY flow_node? (VALUE flow_node?)?
+ * *
+ */
+
+static int
+yaml_parser_parse_flow_sequence_entry_mapping_end(yaml_parser_t *parser,
+ yaml_event_t *event)
+{
+ yaml_token_t *token;
+
+ token = PEEK_TOKEN(parser);
+ if (!token) return 0;
+
+ parser->state = YAML_PARSE_FLOW_SEQUENCE_ENTRY_STATE;
+
+ MAPPING_END_EVENT_INIT(*event, token->start_mark, token->start_mark);
+ return 1;
+}
+
+/*
+ * Parse the productions:
+ * flow_mapping ::= FLOW-MAPPING-START
+ * ******************
+ * (flow_mapping_entry FLOW-ENTRY)*
+ * * **********
+ * flow_mapping_entry?
+ * ******************
+ * FLOW-MAPPING-END
+ * ****************
+ * flow_mapping_entry ::= flow_node | KEY flow_node? (VALUE flow_node?)?
+ * * *** *
+ */
+
+static int
+yaml_parser_parse_flow_mapping_key(yaml_parser_t *parser,
+ yaml_event_t *event, int first)
+{
+ yaml_token_t *token;
+
+ if (first) {
+ token = PEEK_TOKEN(parser);
+ if (!PUSH(parser, parser->marks, token->start_mark))
+ return 0;
+ SKIP_TOKEN(parser);
+ }
+
+ token = PEEK_TOKEN(parser);
+ if (!token) return 0;
+
+ if (token->type != YAML_FLOW_MAPPING_END_TOKEN)
+ {
+ if (!first) {
+ if (token->type == YAML_FLOW_ENTRY_TOKEN) {
+ SKIP_TOKEN(parser);
+ token = PEEK_TOKEN(parser);
+ if (!token) return 0;
+ }
+ else {
+ return yaml_parser_set_parser_error_context(parser,
+ "while parsing a flow mapping", POP(parser, parser->marks),
+ "did not find expected ',' or '}'", token->start_mark);
+ }
+ }
+
+ if (token->type == YAML_KEY_TOKEN) {
+ SKIP_TOKEN(parser);
+ token = PEEK_TOKEN(parser);
+ if (!token) return 0;
+ if (token->type != YAML_VALUE_TOKEN
+ && token->type != YAML_FLOW_ENTRY_TOKEN
+ && token->type != YAML_FLOW_MAPPING_END_TOKEN) {
+ if (!PUSH(parser, parser->states,
+ YAML_PARSE_FLOW_MAPPING_VALUE_STATE))
+ return 0;
+ return yaml_parser_parse_node(parser, event, 0, 0);
+ }
+ else {
+ parser->state = YAML_PARSE_FLOW_MAPPING_VALUE_STATE;
+ return yaml_parser_process_empty_scalar(parser, event,
+ token->start_mark);
+ }
+ }
+ else if (token->type != YAML_FLOW_MAPPING_END_TOKEN) {
+ if (!PUSH(parser, parser->states,
+ YAML_PARSE_FLOW_MAPPING_EMPTY_VALUE_STATE))
+ return 0;
+ return yaml_parser_parse_node(parser, event, 0, 0);
+ }
+ }
+
+ parser->state = POP(parser, parser->states);
+ (void)POP(parser, parser->marks);
+ MAPPING_END_EVENT_INIT(*event, token->start_mark, token->end_mark);
+ SKIP_TOKEN(parser);
+ return 1;
+}
+
+/*
+ * Parse the productions:
+ * flow_mapping_entry ::= flow_node | KEY flow_node? (VALUE flow_node?)?
+ * * ***** *
+ */
+
+static int
+yaml_parser_parse_flow_mapping_value(yaml_parser_t *parser,
+ yaml_event_t *event, int empty)
+{
+ yaml_token_t *token;
+
+ token = PEEK_TOKEN(parser);
+ if (!token) return 0;
+
+ if (empty) {
+ parser->state = YAML_PARSE_FLOW_MAPPING_KEY_STATE;
+ return yaml_parser_process_empty_scalar(parser, event,
+ token->start_mark);
+ }
+
+ if (token->type == YAML_VALUE_TOKEN) {
+ SKIP_TOKEN(parser);
+ token = PEEK_TOKEN(parser);
+ if (!token) return 0;
+ if (token->type != YAML_FLOW_ENTRY_TOKEN
+ && token->type != YAML_FLOW_MAPPING_END_TOKEN) {
+ if (!PUSH(parser, parser->states,
+ YAML_PARSE_FLOW_MAPPING_KEY_STATE))
+ return 0;
+ return yaml_parser_parse_node(parser, event, 0, 0);
+ }
+ }
+
+ parser->state = YAML_PARSE_FLOW_MAPPING_KEY_STATE;
+ return yaml_parser_process_empty_scalar(parser, event, token->start_mark);
+}
+
+/*
+ * Generate an empty scalar event.
+ */
+
+static int
+yaml_parser_process_empty_scalar(yaml_parser_t *parser, yaml_event_t *event,
+ yaml_mark_t mark)
+{
+ yaml_char_t *value;
+
+ value = yaml_malloc(1);
+ if (!value) {
+ parser->error = YAML_MEMORY_ERROR;
+ return 0;
+ }
+ value[0] = '\0';
+
+ SCALAR_EVENT_INIT(*event, NULL, NULL, value, 0,
+ 1, 0, YAML_PLAIN_SCALAR_STYLE, mark, mark);
+
+ return 1;
+}
+
+/*
+ * Parse directives.
+ */
+
+static int
+yaml_parser_process_directives(yaml_parser_t *parser,
+ yaml_version_directive_t **version_directive_ref,
+ yaml_tag_directive_t **tag_directives_start_ref,
+ yaml_tag_directive_t **tag_directives_end_ref)
+{
+ yaml_tag_directive_t default_tag_directives[] = {
+ {(yaml_char_t *)"!", (yaml_char_t *)"!"},
+ {(yaml_char_t *)"!!", (yaml_char_t *)"tag:yaml.org,2002:"},
+ {NULL, NULL}
+ };
+ yaml_tag_directive_t *default_tag_directive;
+ yaml_version_directive_t *version_directive = NULL;
+ struct {
+ yaml_tag_directive_t *start;
+ yaml_tag_directive_t *end;
+ yaml_tag_directive_t *top;
+ } tag_directives = { NULL, NULL, NULL };
+ yaml_token_t *token;
+
+ if (!STACK_INIT(parser, tag_directives, INITIAL_STACK_SIZE))
+ goto error;
+
+ token = PEEK_TOKEN(parser);
+ if (!token) goto error;
+
+ while (token->type == YAML_VERSION_DIRECTIVE_TOKEN ||
+ token->type == YAML_TAG_DIRECTIVE_TOKEN)
+ {
+ if (token->type == YAML_VERSION_DIRECTIVE_TOKEN) {
+ if (version_directive) {
+ yaml_parser_set_parser_error(parser,
+ "found duplicate %YAML directive", token->start_mark);
+ goto error;
+ }
+ if (token->data.version_directive.major != 1
+ || token->data.version_directive.minor != 1) {
+ yaml_parser_set_parser_error(parser,
+ "found incompatible YAML document", token->start_mark);
+ goto error;
+ }
+ version_directive = yaml_malloc(sizeof(yaml_version_directive_t));
+ if (!version_directive) {
+ parser->error = YAML_MEMORY_ERROR;
+ goto error;
+ }
+ version_directive->major = token->data.version_directive.major;
+ version_directive->minor = token->data.version_directive.minor;
+ }
+
+ else if (token->type == YAML_TAG_DIRECTIVE_TOKEN) {
+ yaml_tag_directive_t value;
+ value.handle = token->data.tag_directive.handle;
+ value.prefix = token->data.tag_directive.prefix;
+
+ if (!yaml_parser_append_tag_directive(parser, value, 0,
+ token->start_mark))
+ goto error;
+ if (!PUSH(parser, tag_directives, value))
+ goto error;
+ }
+
+ SKIP_TOKEN(parser);
+ token = PEEK_TOKEN(parser);
+ if (!token) goto error;
+ }
+
+ for (default_tag_directive = default_tag_directives;
+ default_tag_directive->handle; default_tag_directive++) {
+ if (!yaml_parser_append_tag_directive(parser, *default_tag_directive, 1,
+ token->start_mark))
+ goto error;
+ }
+
+ if (version_directive_ref) {
+ *version_directive_ref = version_directive;
+ }
+ if (tag_directives_start_ref) {
+ if (STACK_EMPTY(parser, tag_directives)) {
+ *tag_directives_start_ref = *tag_directives_end_ref = NULL;
+ STACK_DEL(parser, tag_directives);
+ }
+ else {
+ *tag_directives_start_ref = tag_directives.start;
+ *tag_directives_end_ref = tag_directives.top;
+ }
+ }
+ else {
+ STACK_DEL(parser, tag_directives);
+ }
+
+ return 1;
+
+error:
+ yaml_free(version_directive);
+ while (!STACK_EMPTY(parser, tag_directives)) {
+ yaml_tag_directive_t tag_directive = POP(parser, tag_directives);
+ yaml_free(tag_directive.handle);
+ yaml_free(tag_directive.prefix);
+ }
+ STACK_DEL(parser, tag_directives);
+ return 0;
+}
+
+/*
+ * Append a tag directive to the directives stack.
+ */
+
+static int
+yaml_parser_append_tag_directive(yaml_parser_t *parser,
+ yaml_tag_directive_t value, int allow_duplicates, yaml_mark_t mark)
+{
+ yaml_tag_directive_t *tag_directive;
+ yaml_tag_directive_t copy = { NULL, NULL };
+
+ for (tag_directive = parser->tag_directives.start;
+ tag_directive != parser->tag_directives.top; tag_directive ++) {
+ if (strcmp((char *)value.handle, (char *)tag_directive->handle) == 0) {
+ if (allow_duplicates)
+ return 1;
+ return yaml_parser_set_parser_error(parser,
+ "found duplicate %TAG directive", mark);
+ }
+ }
+
+ copy.handle = yaml_strdup(value.handle);
+ copy.prefix = yaml_strdup(value.prefix);
+ if (!copy.handle || !copy.prefix) {
+ parser->error = YAML_MEMORY_ERROR;
+ goto error;
+ }
+
+ if (!PUSH(parser, parser->tag_directives, copy))
+ goto error;
+
+ return 1;
+
+error:
+ yaml_free(copy.handle);
+ yaml_free(copy.prefix);
+ return 0;
+}
+
diff --git a/jni/ruby/ext/psych/yaml/reader.c b/jni/ruby/ext/psych/yaml/reader.c
new file mode 100644
index 0000000..f1a06de
--- /dev/null
+++ b/jni/ruby/ext/psych/yaml/reader.c
@@ -0,0 +1,469 @@
+
+#include "yaml_private.h"
+
+/*
+ * Declarations.
+ */
+
+static int
+yaml_parser_set_reader_error(yaml_parser_t *parser, const char *problem,
+ size_t offset, int value);
+
+static int
+yaml_parser_update_raw_buffer(yaml_parser_t *parser);
+
+static int
+yaml_parser_determine_encoding(yaml_parser_t *parser);
+
+YAML_DECLARE(int)
+yaml_parser_update_buffer(yaml_parser_t *parser, size_t length);
+
+/*
+ * Set the reader error and return 0.
+ */
+
+static int
+yaml_parser_set_reader_error(yaml_parser_t *parser, const char *problem,
+ size_t offset, int value)
+{
+ parser->error = YAML_READER_ERROR;
+ parser->problem = problem;
+ parser->problem_offset = offset;
+ parser->problem_value = value;
+
+ return 0;
+}
+
+/*
+ * Byte order marks.
+ */
+
+#define BOM_UTF8 "\xef\xbb\xbf"
+#define BOM_UTF16LE "\xff\xfe"
+#define BOM_UTF16BE "\xfe\xff"
+
+/*
+ * Determine the input stream encoding by checking the BOM symbol. If no BOM is
+ * found, the UTF-8 encoding is assumed. Return 1 on success, 0 on failure.
+ */
+
+static int
+yaml_parser_determine_encoding(yaml_parser_t *parser)
+{
+ /* Ensure that we had enough bytes in the raw buffer. */
+
+ while (!parser->eof
+ && parser->raw_buffer.last - parser->raw_buffer.pointer < 3) {
+ if (!yaml_parser_update_raw_buffer(parser)) {
+ return 0;
+ }
+ }
+
+ /* Determine the encoding. */
+
+ if (parser->raw_buffer.last - parser->raw_buffer.pointer >= 2
+ && !memcmp(parser->raw_buffer.pointer, BOM_UTF16LE, 2)) {
+ parser->encoding = YAML_UTF16LE_ENCODING;
+ parser->raw_buffer.pointer += 2;
+ parser->offset += 2;
+ }
+ else if (parser->raw_buffer.last - parser->raw_buffer.pointer >= 2
+ && !memcmp(parser->raw_buffer.pointer, BOM_UTF16BE, 2)) {
+ parser->encoding = YAML_UTF16BE_ENCODING;
+ parser->raw_buffer.pointer += 2;
+ parser->offset += 2;
+ }
+ else if (parser->raw_buffer.last - parser->raw_buffer.pointer >= 3
+ && !memcmp(parser->raw_buffer.pointer, BOM_UTF8, 3)) {
+ parser->encoding = YAML_UTF8_ENCODING;
+ parser->raw_buffer.pointer += 3;
+ parser->offset += 3;
+ }
+ else {
+ parser->encoding = YAML_UTF8_ENCODING;
+ }
+
+ return 1;
+}
+
+/*
+ * Update the raw buffer.
+ */
+
+static int
+yaml_parser_update_raw_buffer(yaml_parser_t *parser)
+{
+ size_t size_read = 0;
+
+ /* Return if the raw buffer is full. */
+
+ if (parser->raw_buffer.start == parser->raw_buffer.pointer
+ && parser->raw_buffer.last == parser->raw_buffer.end)
+ return 1;
+
+ /* Return on EOF. */
+
+ if (parser->eof) return 1;
+
+ /* Move the remaining bytes in the raw buffer to the beginning. */
+
+ if (parser->raw_buffer.start < parser->raw_buffer.pointer
+ && parser->raw_buffer.pointer < parser->raw_buffer.last) {
+ memmove(parser->raw_buffer.start, parser->raw_buffer.pointer,
+ parser->raw_buffer.last - parser->raw_buffer.pointer);
+ }
+ parser->raw_buffer.last -=
+ parser->raw_buffer.pointer - parser->raw_buffer.start;
+ parser->raw_buffer.pointer = parser->raw_buffer.start;
+
+ /* Call the read handler to fill the buffer. */
+
+ if (!parser->read_handler(parser->read_handler_data, parser->raw_buffer.last,
+ parser->raw_buffer.end - parser->raw_buffer.last, &size_read)) {
+ return yaml_parser_set_reader_error(parser, "input error",
+ parser->offset, -1);
+ }
+ parser->raw_buffer.last += size_read;
+ if (!size_read) {
+ parser->eof = 1;
+ }
+
+ return 1;
+}
+
+/*
+ * Ensure that the buffer contains at least `length` characters.
+ * Return 1 on success, 0 on failure.
+ *
+ * The length is supposed to be significantly less that the buffer size.
+ */
+
+YAML_DECLARE(int)
+yaml_parser_update_buffer(yaml_parser_t *parser, size_t length)
+{
+ int first = 1;
+
+ assert(parser->read_handler); /* Read handler must be set. */
+
+ /* If the EOF flag is set and the raw buffer is empty, do nothing. */
+
+ if (parser->eof && parser->raw_buffer.pointer == parser->raw_buffer.last)
+ return 1;
+
+ /* Return if the buffer contains enough characters. */
+
+ if (parser->unread >= length)
+ return 1;
+
+ /* Determine the input encoding if it is not known yet. */
+
+ if (!parser->encoding) {
+ if (!yaml_parser_determine_encoding(parser))
+ return 0;
+ }
+
+ /* Move the unread characters to the beginning of the buffer. */
+
+ if (parser->buffer.start < parser->buffer.pointer
+ && parser->buffer.pointer < parser->buffer.last) {
+ size_t size = parser->buffer.last - parser->buffer.pointer;
+ memmove(parser->buffer.start, parser->buffer.pointer, size);
+ parser->buffer.pointer = parser->buffer.start;
+ parser->buffer.last = parser->buffer.start + size;
+ }
+ else if (parser->buffer.pointer == parser->buffer.last) {
+ parser->buffer.pointer = parser->buffer.start;
+ parser->buffer.last = parser->buffer.start;
+ }
+
+ /* Fill the buffer until it has enough characters. */
+
+ while (parser->unread < length)
+ {
+ /* Fill the raw buffer if necessary. */
+
+ if (!first || parser->raw_buffer.pointer == parser->raw_buffer.last) {
+ if (!yaml_parser_update_raw_buffer(parser)) return 0;
+ }
+ first = 0;
+
+ /* Decode the raw buffer. */
+
+ while (parser->raw_buffer.pointer != parser->raw_buffer.last)
+ {
+ unsigned int value = 0, value2 = 0;
+ int incomplete = 0;
+ unsigned char octet;
+ unsigned int width = 0;
+ int low, high;
+ size_t k;
+ size_t raw_unread = parser->raw_buffer.last - parser->raw_buffer.pointer;
+
+ /* Decode the next character. */
+
+ switch (parser->encoding)
+ {
+ case YAML_UTF8_ENCODING:
+
+ /*
+ * Decode a UTF-8 character. Check RFC 3629
+ * (http://www.ietf.org/rfc/rfc3629.txt) for more details.
+ *
+ * The following table (taken from the RFC) is used for
+ * decoding.
+ *
+ * Char. number range | UTF-8 octet sequence
+ * (hexadecimal) | (binary)
+ * --------------------+------------------------------------
+ * 0000 0000-0000 007F | 0xxxxxxx
+ * 0000 0080-0000 07FF | 110xxxxx 10xxxxxx
+ * 0000 0800-0000 FFFF | 1110xxxx 10xxxxxx 10xxxxxx
+ * 0001 0000-0010 FFFF | 11110xxx 10xxxxxx 10xxxxxx 10xxxxxx
+ *
+ * Additionally, the characters in the range 0xD800-0xDFFF
+ * are prohibited as they are reserved for use with UTF-16
+ * surrogate pairs.
+ */
+
+ /* Determine the length of the UTF-8 sequence. */
+
+ octet = parser->raw_buffer.pointer[0];
+ width = (octet & 0x80) == 0x00 ? 1 :
+ (octet & 0xE0) == 0xC0 ? 2 :
+ (octet & 0xF0) == 0xE0 ? 3 :
+ (octet & 0xF8) == 0xF0 ? 4 : 0;
+
+ /* Check if the leading octet is valid. */
+
+ if (!width)
+ return yaml_parser_set_reader_error(parser,
+ "invalid leading UTF-8 octet",
+ parser->offset, octet);
+
+ /* Check if the raw buffer contains an incomplete character. */
+
+ if (width > raw_unread) {
+ if (parser->eof) {
+ return yaml_parser_set_reader_error(parser,
+ "incomplete UTF-8 octet sequence",
+ parser->offset, -1);
+ }
+ incomplete = 1;
+ break;
+ }
+
+ /* Decode the leading octet. */
+
+ value = (octet & 0x80) == 0x00 ? octet & 0x7F :
+ (octet & 0xE0) == 0xC0 ? octet & 0x1F :
+ (octet & 0xF0) == 0xE0 ? octet & 0x0F :
+ (octet & 0xF8) == 0xF0 ? octet & 0x07 : 0;
+
+ /* Check and decode the trailing octets. */
+
+ for (k = 1; k < width; k ++)
+ {
+ octet = parser->raw_buffer.pointer[k];
+
+ /* Check if the octet is valid. */
+
+ if ((octet & 0xC0) != 0x80)
+ return yaml_parser_set_reader_error(parser,
+ "invalid trailing UTF-8 octet",
+ parser->offset+k, octet);
+
+ /* Decode the octet. */
+
+ value = (value << 6) + (octet & 0x3F);
+ }
+
+ /* Check the length of the sequence against the value. */
+
+ if (!((width == 1) ||
+ (width == 2 && value >= 0x80) ||
+ (width == 3 && value >= 0x800) ||
+ (width == 4 && value >= 0x10000)))
+ return yaml_parser_set_reader_error(parser,
+ "invalid length of a UTF-8 sequence",
+ parser->offset, -1);
+
+ /* Check the range of the value. */
+
+ if ((value >= 0xD800 && value <= 0xDFFF) || value > 0x10FFFF)
+ return yaml_parser_set_reader_error(parser,
+ "invalid Unicode character",
+ parser->offset, value);
+
+ break;
+
+ case YAML_UTF16LE_ENCODING:
+ case YAML_UTF16BE_ENCODING:
+
+ low = (parser->encoding == YAML_UTF16LE_ENCODING ? 0 : 1);
+ high = (parser->encoding == YAML_UTF16LE_ENCODING ? 1 : 0);
+
+ /*
+ * The UTF-16 encoding is not as simple as one might
+ * naively think. Check RFC 2781
+ * (http://www.ietf.org/rfc/rfc2781.txt).
+ *
+ * Normally, two subsequent bytes describe a Unicode
+ * character. However a special technique (called a
+ * surrogate pair) is used for specifying character
+ * values larger than 0xFFFF.
+ *
+ * A surrogate pair consists of two pseudo-characters:
+ * high surrogate area (0xD800-0xDBFF)
+ * low surrogate area (0xDC00-0xDFFF)
+ *
+ * The following formulas are used for decoding
+ * and encoding characters using surrogate pairs:
+ *
+ * U = U' + 0x10000 (0x01 00 00 <= U <= 0x10 FF FF)
+ * U' = yyyyyyyyyyxxxxxxxxxx (0 <= U' <= 0x0F FF FF)
+ * W1 = 110110yyyyyyyyyy
+ * W2 = 110111xxxxxxxxxx
+ *
+ * where U is the character value, W1 is the high surrogate
+ * area, W2 is the low surrogate area.
+ */
+
+ /* Check for incomplete UTF-16 character. */
+
+ if (raw_unread < 2) {
+ if (parser->eof) {
+ return yaml_parser_set_reader_error(parser,
+ "incomplete UTF-16 character",
+ parser->offset, -1);
+ }
+ incomplete = 1;
+ break;
+ }
+
+ /* Get the character. */
+
+ value = parser->raw_buffer.pointer[low]
+ + (parser->raw_buffer.pointer[high] << 8);
+
+ /* Check for unexpected low surrogate area. */
+
+ if ((value & 0xFC00) == 0xDC00)
+ return yaml_parser_set_reader_error(parser,
+ "unexpected low surrogate area",
+ parser->offset, value);
+
+ /* Check for a high surrogate area. */
+
+ if ((value & 0xFC00) == 0xD800) {
+
+ width = 4;
+
+ /* Check for incomplete surrogate pair. */
+
+ if (raw_unread < 4) {
+ if (parser->eof) {
+ return yaml_parser_set_reader_error(parser,
+ "incomplete UTF-16 surrogate pair",
+ parser->offset, -1);
+ }
+ incomplete = 1;
+ break;
+ }
+
+ /* Get the next character. */
+
+ value2 = parser->raw_buffer.pointer[low+2]
+ + (parser->raw_buffer.pointer[high+2] << 8);
+
+ /* Check for a low surrogate area. */
+
+ if ((value2 & 0xFC00) != 0xDC00)
+ return yaml_parser_set_reader_error(parser,
+ "expected low surrogate area",
+ parser->offset+2, value2);
+
+ /* Generate the value of the surrogate pair. */
+
+ value = 0x10000 + ((value & 0x3FF) << 10) + (value2 & 0x3FF);
+ }
+
+ else {
+ width = 2;
+ }
+
+ break;
+
+ default:
+ assert(1); /* Impossible. */
+ }
+
+ /* Check if the raw buffer contains enough bytes to form a character. */
+
+ if (incomplete) break;
+
+ /*
+ * Check if the character is in the allowed range:
+ * #x9 | #xA | #xD | [#x20-#x7E] (8 bit)
+ * | #x85 | [#xA0-#xD7FF] | [#xE000-#xFFFD] (16 bit)
+ * | [#x10000-#x10FFFF] (32 bit)
+ */
+
+ if (! (value == 0x09 || value == 0x0A || value == 0x0D
+ || (value >= 0x20 && value <= 0x7E)
+ || (value == 0x85) || (value >= 0xA0 && value <= 0xD7FF)
+ || (value >= 0xE000 && value <= 0xFFFD)
+ || (value >= 0x10000 && value <= 0x10FFFF)))
+ return yaml_parser_set_reader_error(parser,
+ "control characters are not allowed",
+ parser->offset, value);
+
+ /* Move the raw pointers. */
+
+ parser->raw_buffer.pointer += width;
+ parser->offset += width;
+
+ /* Finally put the character into the buffer. */
+
+ /* 0000 0000-0000 007F -> 0xxxxxxx */
+ if (value <= 0x7F) {
+ *(parser->buffer.last++) = value;
+ }
+ /* 0000 0080-0000 07FF -> 110xxxxx 10xxxxxx */
+ else if (value <= 0x7FF) {
+ *(parser->buffer.last++) = 0xC0 + (value >> 6);
+ *(parser->buffer.last++) = 0x80 + (value & 0x3F);
+ }
+ /* 0000 0800-0000 FFFF -> 1110xxxx 10xxxxxx 10xxxxxx */
+ else if (value <= 0xFFFF) {
+ *(parser->buffer.last++) = 0xE0 + (value >> 12);
+ *(parser->buffer.last++) = 0x80 + ((value >> 6) & 0x3F);
+ *(parser->buffer.last++) = 0x80 + (value & 0x3F);
+ }
+ /* 0001 0000-0010 FFFF -> 11110xxx 10xxxxxx 10xxxxxx 10xxxxxx */
+ else {
+ *(parser->buffer.last++) = 0xF0 + (value >> 18);
+ *(parser->buffer.last++) = 0x80 + ((value >> 12) & 0x3F);
+ *(parser->buffer.last++) = 0x80 + ((value >> 6) & 0x3F);
+ *(parser->buffer.last++) = 0x80 + (value & 0x3F);
+ }
+
+ parser->unread ++;
+ }
+
+ /* On EOF, put NUL into the buffer and return. */
+
+ if (parser->eof) {
+ *(parser->buffer.last++) = '\0';
+ parser->unread ++;
+ return 1;
+ }
+
+ }
+
+ if (parser->offset >= PTRDIFF_MAX)
+ return yaml_parser_set_reader_error(parser, "input is too long",
+ PTRDIFF_MAX, -1);
+
+ return 1;
+}
+
diff --git a/jni/ruby/ext/psych/yaml/scanner.c b/jni/ruby/ext/psych/yaml/scanner.c
new file mode 100644
index 0000000..08ad8ed
--- /dev/null
+++ b/jni/ruby/ext/psych/yaml/scanner.c
@@ -0,0 +1,3583 @@
+
+/*
+ * Introduction
+ * ************
+ *
+ * The following notes assume that you are familiar with the YAML specification
+ * (http://yaml.org/spec/cvs/current.html). We mostly follow it, although in
+ * some cases we are less restrictive that it requires.
+ *
+ * The process of transforming a YAML stream into a sequence of events is
+ * divided on two steps: Scanning and Parsing.
+ *
+ * The Scanner transforms the input stream into a sequence of tokens, while the
+ * parser transform the sequence of tokens produced by the Scanner into a
+ * sequence of parsing events.
+ *
+ * The Scanner is rather clever and complicated. The Parser, on the contrary,
+ * is a straightforward implementation of a recursive-descendant parser (or,
+ * LL(1) parser, as it is usually called).
+ *
+ * Actually there are two issues of Scanning that might be called "clever", the
+ * rest is quite straightforward. The issues are "block collection start" and
+ * "simple keys". Both issues are explained below in details.
+ *
+ * Here the Scanning step is explained and implemented. We start with the list
+ * of all the tokens produced by the Scanner together with short descriptions.
+ *
+ * Now, tokens:
+ *
+ * STREAM-START(encoding) # The stream start.
+ * STREAM-END # The stream end.
+ * VERSION-DIRECTIVE(major,minor) # The '%YAML' directive.
+ * TAG-DIRECTIVE(handle,prefix) # The '%TAG' directive.
+ * DOCUMENT-START # '---'
+ * DOCUMENT-END # '...'
+ * BLOCK-SEQUENCE-START # Indentation increase denoting a block
+ * BLOCK-MAPPING-START # sequence or a block mapping.
+ * BLOCK-END # Indentation decrease.
+ * FLOW-SEQUENCE-START # '['
+ * FLOW-SEQUENCE-END # ']'
+ * BLOCK-SEQUENCE-START # '{'
+ * BLOCK-SEQUENCE-END # '}'
+ * BLOCK-ENTRY # '-'
+ * FLOW-ENTRY # ','
+ * KEY # '?' or nothing (simple keys).
+ * VALUE # ':'
+ * ALIAS(anchor) # '*anchor'
+ * ANCHOR(anchor) # '&anchor'
+ * TAG(handle,suffix) # '!handle!suffix'
+ * SCALAR(value,style) # A scalar.
+ *
+ * The following two tokens are "virtual" tokens denoting the beginning and the
+ * end of the stream:
+ *
+ * STREAM-START(encoding)
+ * STREAM-END
+ *
+ * We pass the information about the input stream encoding with the
+ * STREAM-START token.
+ *
+ * The next two tokens are responsible for tags:
+ *
+ * VERSION-DIRECTIVE(major,minor)
+ * TAG-DIRECTIVE(handle,prefix)
+ *
+ * Example:
+ *
+ * %YAML 1.1
+ * %TAG ! !foo
+ * %TAG !yaml! tag:yaml.org,2002:
+ * ---
+ *
+ * The corresponding sequence of tokens:
+ *
+ * STREAM-START(utf-8)
+ * VERSION-DIRECTIVE(1,1)
+ * TAG-DIRECTIVE("!","!foo")
+ * TAG-DIRECTIVE("!yaml","tag:yaml.org,2002:")
+ * DOCUMENT-START
+ * STREAM-END
+ *
+ * Note that the VERSION-DIRECTIVE and TAG-DIRECTIVE tokens occupy a whole
+ * line.
+ *
+ * The document start and end indicators are represented by:
+ *
+ * DOCUMENT-START
+ * DOCUMENT-END
+ *
+ * Note that if a YAML stream contains an implicit document (without '---'
+ * and '...' indicators), no DOCUMENT-START and DOCUMENT-END tokens will be
+ * produced.
+ *
+ * In the following examples, we present whole documents together with the
+ * produced tokens.
+ *
+ * 1. An implicit document:
+ *
+ * 'a scalar'
+ *
+ * Tokens:
+ *
+ * STREAM-START(utf-8)
+ * SCALAR("a scalar",single-quoted)
+ * STREAM-END
+ *
+ * 2. An explicit document:
+ *
+ * ---
+ * 'a scalar'
+ * ...
+ *
+ * Tokens:
+ *
+ * STREAM-START(utf-8)
+ * DOCUMENT-START
+ * SCALAR("a scalar",single-quoted)
+ * DOCUMENT-END
+ * STREAM-END
+ *
+ * 3. Several documents in a stream:
+ *
+ * 'a scalar'
+ * ---
+ * 'another scalar'
+ * ---
+ * 'yet another scalar'
+ *
+ * Tokens:
+ *
+ * STREAM-START(utf-8)
+ * SCALAR("a scalar",single-quoted)
+ * DOCUMENT-START
+ * SCALAR("another scalar",single-quoted)
+ * DOCUMENT-START
+ * SCALAR("yet another scalar",single-quoted)
+ * STREAM-END
+ *
+ * We have already introduced the SCALAR token above. The following tokens are
+ * used to describe aliases, anchors, tag, and scalars:
+ *
+ * ALIAS(anchor)
+ * ANCHOR(anchor)
+ * TAG(handle,suffix)
+ * SCALAR(value,style)
+ *
+ * The following series of examples illustrate the usage of these tokens:
+ *
+ * 1. A recursive sequence:
+ *
+ * &A [ *A ]
+ *
+ * Tokens:
+ *
+ * STREAM-START(utf-8)
+ * ANCHOR("A")
+ * FLOW-SEQUENCE-START
+ * ALIAS("A")
+ * FLOW-SEQUENCE-END
+ * STREAM-END
+ *
+ * 2. A tagged scalar:
+ *
+ * !!float "3.14" # A good approximation.
+ *
+ * Tokens:
+ *
+ * STREAM-START(utf-8)
+ * TAG("!!","float")
+ * SCALAR("3.14",double-quoted)
+ * STREAM-END
+ *
+ * 3. Various scalar styles:
+ *
+ * --- # Implicit empty plain scalars do not produce tokens.
+ * --- a plain scalar
+ * --- 'a single-quoted scalar'
+ * --- "a double-quoted scalar"
+ * --- |-
+ * a literal scalar
+ * --- >-
+ * a folded
+ * scalar
+ *
+ * Tokens:
+ *
+ * STREAM-START(utf-8)
+ * DOCUMENT-START
+ * DOCUMENT-START
+ * SCALAR("a plain scalar",plain)
+ * DOCUMENT-START
+ * SCALAR("a single-quoted scalar",single-quoted)
+ * DOCUMENT-START
+ * SCALAR("a double-quoted scalar",double-quoted)
+ * DOCUMENT-START
+ * SCALAR("a literal scalar",literal)
+ * DOCUMENT-START
+ * SCALAR("a folded scalar",folded)
+ * STREAM-END
+ *
+ * Now it's time to review collection-related tokens. We will start with
+ * flow collections:
+ *
+ * FLOW-SEQUENCE-START
+ * FLOW-SEQUENCE-END
+ * FLOW-MAPPING-START
+ * FLOW-MAPPING-END
+ * FLOW-ENTRY
+ * KEY
+ * VALUE
+ *
+ * The tokens FLOW-SEQUENCE-START, FLOW-SEQUENCE-END, FLOW-MAPPING-START, and
+ * FLOW-MAPPING-END represent the indicators '[', ']', '{', and '}'
+ * correspondingly. FLOW-ENTRY represent the ',' indicator. Finally the
+ * indicators '?' and ':', which are used for denoting mapping keys and values,
+ * are represented by the KEY and VALUE tokens.
+ *
+ * The following examples show flow collections:
+ *
+ * 1. A flow sequence:
+ *
+ * [item 1, item 2, item 3]
+ *
+ * Tokens:
+ *
+ * STREAM-START(utf-8)
+ * FLOW-SEQUENCE-START
+ * SCALAR("item 1",plain)
+ * FLOW-ENTRY
+ * SCALAR("item 2",plain)
+ * FLOW-ENTRY
+ * SCALAR("item 3",plain)
+ * FLOW-SEQUENCE-END
+ * STREAM-END
+ *
+ * 2. A flow mapping:
+ *
+ * {
+ * a simple key: a value, # Note that the KEY token is produced.
+ * ? a complex key: another value,
+ * }
+ *
+ * Tokens:
+ *
+ * STREAM-START(utf-8)
+ * FLOW-MAPPING-START
+ * KEY
+ * SCALAR("a simple key",plain)
+ * VALUE
+ * SCALAR("a value",plain)
+ * FLOW-ENTRY
+ * KEY
+ * SCALAR("a complex key",plain)
+ * VALUE
+ * SCALAR("another value",plain)
+ * FLOW-ENTRY
+ * FLOW-MAPPING-END
+ * STREAM-END
+ *
+ * A simple key is a key which is not denoted by the '?' indicator. Note that
+ * the Scanner still produce the KEY token whenever it encounters a simple key.
+ *
+ * For scanning block collections, the following tokens are used (note that we
+ * repeat KEY and VALUE here):
+ *
+ * BLOCK-SEQUENCE-START
+ * BLOCK-MAPPING-START
+ * BLOCK-END
+ * BLOCK-ENTRY
+ * KEY
+ * VALUE
+ *
+ * The tokens BLOCK-SEQUENCE-START and BLOCK-MAPPING-START denote indentation
+ * increase that precedes a block collection (cf. the INDENT token in Python).
+ * The token BLOCK-END denote indentation decrease that ends a block collection
+ * (cf. the DEDENT token in Python). However YAML has some syntax pecularities
+ * that makes detections of these tokens more complex.
+ *
+ * The tokens BLOCK-ENTRY, KEY, and VALUE are used to represent the indicators
+ * '-', '?', and ':' correspondingly.
+ *
+ * The following examples show how the tokens BLOCK-SEQUENCE-START,
+ * BLOCK-MAPPING-START, and BLOCK-END are emitted by the Scanner:
+ *
+ * 1. Block sequences:
+ *
+ * - item 1
+ * - item 2
+ * -
+ * - item 3.1
+ * - item 3.2
+ * -
+ * key 1: value 1
+ * key 2: value 2
+ *
+ * Tokens:
+ *
+ * STREAM-START(utf-8)
+ * BLOCK-SEQUENCE-START
+ * BLOCK-ENTRY
+ * SCALAR("item 1",plain)
+ * BLOCK-ENTRY
+ * SCALAR("item 2",plain)
+ * BLOCK-ENTRY
+ * BLOCK-SEQUENCE-START
+ * BLOCK-ENTRY
+ * SCALAR("item 3.1",plain)
+ * BLOCK-ENTRY
+ * SCALAR("item 3.2",plain)
+ * BLOCK-END
+ * BLOCK-ENTRY
+ * BLOCK-MAPPING-START
+ * KEY
+ * SCALAR("key 1",plain)
+ * VALUE
+ * SCALAR("value 1",plain)
+ * KEY
+ * SCALAR("key 2",plain)
+ * VALUE
+ * SCALAR("value 2",plain)
+ * BLOCK-END
+ * BLOCK-END
+ * STREAM-END
+ *
+ * 2. Block mappings:
+ *
+ * a simple key: a value # The KEY token is produced here.
+ * ? a complex key
+ * : another value
+ * a mapping:
+ * key 1: value 1
+ * key 2: value 2
+ * a sequence:
+ * - item 1
+ * - item 2
+ *
+ * Tokens:
+ *
+ * STREAM-START(utf-8)
+ * BLOCK-MAPPING-START
+ * KEY
+ * SCALAR("a simple key",plain)
+ * VALUE
+ * SCALAR("a value",plain)
+ * KEY
+ * SCALAR("a complex key",plain)
+ * VALUE
+ * SCALAR("another value",plain)
+ * KEY
+ * SCALAR("a mapping",plain)
+ * BLOCK-MAPPING-START
+ * KEY
+ * SCALAR("key 1",plain)
+ * VALUE
+ * SCALAR("value 1",plain)
+ * KEY
+ * SCALAR("key 2",plain)
+ * VALUE
+ * SCALAR("value 2",plain)
+ * BLOCK-END
+ * KEY
+ * SCALAR("a sequence",plain)
+ * VALUE
+ * BLOCK-SEQUENCE-START
+ * BLOCK-ENTRY
+ * SCALAR("item 1",plain)
+ * BLOCK-ENTRY
+ * SCALAR("item 2",plain)
+ * BLOCK-END
+ * BLOCK-END
+ * STREAM-END
+ *
+ * YAML does not always require to start a new block collection from a new
+ * line. If the current line contains only '-', '?', and ':' indicators, a new
+ * block collection may start at the current line. The following examples
+ * illustrate this case:
+ *
+ * 1. Collections in a sequence:
+ *
+ * - - item 1
+ * - item 2
+ * - key 1: value 1
+ * key 2: value 2
+ * - ? complex key
+ * : complex value
+ *
+ * Tokens:
+ *
+ * STREAM-START(utf-8)
+ * BLOCK-SEQUENCE-START
+ * BLOCK-ENTRY
+ * BLOCK-SEQUENCE-START
+ * BLOCK-ENTRY
+ * SCALAR("item 1",plain)
+ * BLOCK-ENTRY
+ * SCALAR("item 2",plain)
+ * BLOCK-END
+ * BLOCK-ENTRY
+ * BLOCK-MAPPING-START
+ * KEY
+ * SCALAR("key 1",plain)
+ * VALUE
+ * SCALAR("value 1",plain)
+ * KEY
+ * SCALAR("key 2",plain)
+ * VALUE
+ * SCALAR("value 2",plain)
+ * BLOCK-END
+ * BLOCK-ENTRY
+ * BLOCK-MAPPING-START
+ * KEY
+ * SCALAR("complex key")
+ * VALUE
+ * SCALAR("complex value")
+ * BLOCK-END
+ * BLOCK-END
+ * STREAM-END
+ *
+ * 2. Collections in a mapping:
+ *
+ * ? a sequence
+ * : - item 1
+ * - item 2
+ * ? a mapping
+ * : key 1: value 1
+ * key 2: value 2
+ *
+ * Tokens:
+ *
+ * STREAM-START(utf-8)
+ * BLOCK-MAPPING-START
+ * KEY
+ * SCALAR("a sequence",plain)
+ * VALUE
+ * BLOCK-SEQUENCE-START
+ * BLOCK-ENTRY
+ * SCALAR("item 1",plain)
+ * BLOCK-ENTRY
+ * SCALAR("item 2",plain)
+ * BLOCK-END
+ * KEY
+ * SCALAR("a mapping",plain)
+ * VALUE
+ * BLOCK-MAPPING-START
+ * KEY
+ * SCALAR("key 1",plain)
+ * VALUE
+ * SCALAR("value 1",plain)
+ * KEY
+ * SCALAR("key 2",plain)
+ * VALUE
+ * SCALAR("value 2",plain)
+ * BLOCK-END
+ * BLOCK-END
+ * STREAM-END
+ *
+ * YAML also permits non-indented sequences if they are included into a block
+ * mapping. In this case, the token BLOCK-SEQUENCE-START is not produced:
+ *
+ * key:
+ * - item 1 # BLOCK-SEQUENCE-START is NOT produced here.
+ * - item 2
+ *
+ * Tokens:
+ *
+ * STREAM-START(utf-8)
+ * BLOCK-MAPPING-START
+ * KEY
+ * SCALAR("key",plain)
+ * VALUE
+ * BLOCK-ENTRY
+ * SCALAR("item 1",plain)
+ * BLOCK-ENTRY
+ * SCALAR("item 2",plain)
+ * BLOCK-END
+ */
+
+#include "yaml_private.h"
+
+/*
+ * Ensure that the buffer contains the required number of characters.
+ * Return 1 on success, 0 on failure (reader error or memory error).
+ */
+
+#define CACHE(parser,length) \
+ (parser->unread >= (length) \
+ ? 1 \
+ : yaml_parser_update_buffer(parser, (length)))
+
+/*
+ * Advance the buffer pointer.
+ */
+
+#define SKIP(parser) \
+ (parser->mark.index ++, \
+ parser->mark.column ++, \
+ parser->unread --, \
+ parser->buffer.pointer += WIDTH(parser->buffer))
+
+#define SKIP_LINE(parser) \
+ (IS_CRLF(parser->buffer) ? \
+ (parser->mark.index += 2, \
+ parser->mark.column = 0, \
+ parser->mark.line ++, \
+ parser->unread -= 2, \
+ parser->buffer.pointer += 2) : \
+ IS_BREAK(parser->buffer) ? \
+ (parser->mark.index ++, \
+ parser->mark.column = 0, \
+ parser->mark.line ++, \
+ parser->unread --, \
+ parser->buffer.pointer += WIDTH(parser->buffer)) : 0)
+
+/*
+ * Copy a character to a string buffer and advance pointers.
+ */
+
+#define READ(parser,string) \
+ (STRING_EXTEND(parser,string) ? \
+ (COPY(string,parser->buffer), \
+ parser->mark.index ++, \
+ parser->mark.column ++, \
+ parser->unread --, \
+ 1) : 0)
+
+/*
+ * Copy a line break character to a string buffer and advance pointers.
+ */
+
+#define READ_LINE(parser,string) \
+ (STRING_EXTEND(parser,string) ? \
+ (((CHECK_AT(parser->buffer,'\r',0) \
+ && CHECK_AT(parser->buffer,'\n',1)) ? /* CR LF -> LF */ \
+ (*((string).pointer++) = (yaml_char_t) '\n', \
+ parser->buffer.pointer += 2, \
+ parser->mark.index += 2, \
+ parser->mark.column = 0, \
+ parser->mark.line ++, \
+ parser->unread -= 2) : \
+ (CHECK_AT(parser->buffer,'\r',0) \
+ || CHECK_AT(parser->buffer,'\n',0)) ? /* CR|LF -> LF */ \
+ (*((string).pointer++) = (yaml_char_t) '\n', \
+ parser->buffer.pointer ++, \
+ parser->mark.index ++, \
+ parser->mark.column = 0, \
+ parser->mark.line ++, \
+ parser->unread --) : \
+ (CHECK_AT(parser->buffer,'\xC2',0) \
+ && CHECK_AT(parser->buffer,'\x85',1)) ? /* NEL -> LF */ \
+ (*((string).pointer++) = (yaml_char_t) '\n', \
+ parser->buffer.pointer += 2, \
+ parser->mark.index ++, \
+ parser->mark.column = 0, \
+ parser->mark.line ++, \
+ parser->unread --) : \
+ (CHECK_AT(parser->buffer,'\xE2',0) && \
+ CHECK_AT(parser->buffer,'\x80',1) && \
+ (CHECK_AT(parser->buffer,'\xA8',2) || \
+ CHECK_AT(parser->buffer,'\xA9',2))) ? /* LS|PS -> LS|PS */ \
+ (*((string).pointer++) = *(parser->buffer.pointer++), \
+ *((string).pointer++) = *(parser->buffer.pointer++), \
+ *((string).pointer++) = *(parser->buffer.pointer++), \
+ parser->mark.index ++, \
+ parser->mark.column = 0, \
+ parser->mark.line ++, \
+ parser->unread --) : 0), \
+ 1) : 0)
+
+/*
+ * Public API declarations.
+ */
+
+YAML_DECLARE(int)
+yaml_parser_scan(yaml_parser_t *parser, yaml_token_t *token);
+
+/*
+ * Error handling.
+ */
+
+static int
+yaml_parser_set_scanner_error(yaml_parser_t *parser, const char *context,
+ yaml_mark_t context_mark, const char *problem);
+
+/*
+ * High-level token API.
+ */
+
+YAML_DECLARE(int)
+yaml_parser_fetch_more_tokens(yaml_parser_t *parser);
+
+static int
+yaml_parser_fetch_next_token(yaml_parser_t *parser);
+
+/*
+ * Potential simple keys.
+ */
+
+static int
+yaml_parser_stale_simple_keys(yaml_parser_t *parser);
+
+static int
+yaml_parser_save_simple_key(yaml_parser_t *parser);
+
+static int
+yaml_parser_remove_simple_key(yaml_parser_t *parser);
+
+static int
+yaml_parser_increase_flow_level(yaml_parser_t *parser);
+
+static int
+yaml_parser_decrease_flow_level(yaml_parser_t *parser);
+
+/*
+ * Indentation treatment.
+ */
+
+static int
+yaml_parser_roll_indent(yaml_parser_t *parser, ptrdiff_t column,
+ ptrdiff_t number, yaml_token_type_t type, yaml_mark_t mark);
+
+static int
+yaml_parser_unroll_indent(yaml_parser_t *parser, ptrdiff_t column);
+
+/*
+ * Token fetchers.
+ */
+
+static int
+yaml_parser_fetch_stream_start(yaml_parser_t *parser);
+
+static int
+yaml_parser_fetch_stream_end(yaml_parser_t *parser);
+
+static int
+yaml_parser_fetch_directive(yaml_parser_t *parser);
+
+static int
+yaml_parser_fetch_document_indicator(yaml_parser_t *parser,
+ yaml_token_type_t type);
+
+static int
+yaml_parser_fetch_flow_collection_start(yaml_parser_t *parser,
+ yaml_token_type_t type);
+
+static int
+yaml_parser_fetch_flow_collection_end(yaml_parser_t *parser,
+ yaml_token_type_t type);
+
+static int
+yaml_parser_fetch_flow_entry(yaml_parser_t *parser);
+
+static int
+yaml_parser_fetch_block_entry(yaml_parser_t *parser);
+
+static int
+yaml_parser_fetch_key(yaml_parser_t *parser);
+
+static int
+yaml_parser_fetch_value(yaml_parser_t *parser);
+
+static int
+yaml_parser_fetch_anchor(yaml_parser_t *parser, yaml_token_type_t type);
+
+static int
+yaml_parser_fetch_tag(yaml_parser_t *parser);
+
+static int
+yaml_parser_fetch_block_scalar(yaml_parser_t *parser, int literal);
+
+static int
+yaml_parser_fetch_flow_scalar(yaml_parser_t *parser, int single);
+
+static int
+yaml_parser_fetch_plain_scalar(yaml_parser_t *parser);
+
+/*
+ * Token scanners.
+ */
+
+static int
+yaml_parser_scan_to_next_token(yaml_parser_t *parser);
+
+static int
+yaml_parser_scan_directive(yaml_parser_t *parser, yaml_token_t *token);
+
+static int
+yaml_parser_scan_directive_name(yaml_parser_t *parser,
+ yaml_mark_t start_mark, yaml_char_t **name);
+
+static int
+yaml_parser_scan_version_directive_value(yaml_parser_t *parser,
+ yaml_mark_t start_mark, int *major, int *minor);
+
+static int
+yaml_parser_scan_version_directive_number(yaml_parser_t *parser,
+ yaml_mark_t start_mark, int *number);
+
+static int
+yaml_parser_scan_tag_directive_value(yaml_parser_t *parser,
+ yaml_mark_t mark, yaml_char_t **handle, yaml_char_t **prefix);
+
+static int
+yaml_parser_scan_anchor(yaml_parser_t *parser, yaml_token_t *token,
+ yaml_token_type_t type);
+
+static int
+yaml_parser_scan_tag(yaml_parser_t *parser, yaml_token_t *token);
+
+static int
+yaml_parser_scan_tag_handle(yaml_parser_t *parser, int directive,
+ yaml_mark_t start_mark, yaml_char_t **handle);
+
+static int
+yaml_parser_scan_tag_uri(yaml_parser_t *parser, int directive,
+ yaml_char_t *head, yaml_mark_t start_mark, yaml_char_t **uri);
+
+static int
+yaml_parser_scan_uri_escapes(yaml_parser_t *parser, int directive,
+ yaml_mark_t start_mark, yaml_string_t *string);
+
+static int
+yaml_parser_scan_block_scalar(yaml_parser_t *parser, yaml_token_t *token,
+ int literal);
+
+static int
+yaml_parser_scan_block_scalar_breaks(yaml_parser_t *parser,
+ int *indent, yaml_string_t *breaks,
+ yaml_mark_t start_mark, yaml_mark_t *end_mark);
+
+static int
+yaml_parser_scan_flow_scalar(yaml_parser_t *parser, yaml_token_t *token,
+ int single);
+
+static int
+yaml_parser_scan_plain_scalar(yaml_parser_t *parser, yaml_token_t *token);
+
+/*
+ * Get the next token.
+ */
+
+YAML_DECLARE(int)
+yaml_parser_scan(yaml_parser_t *parser, yaml_token_t *token)
+{
+ assert(parser); /* Non-NULL parser object is expected. */
+ assert(token); /* Non-NULL token object is expected. */
+
+ /* Erase the token object. */
+
+ memset(token, 0, sizeof(yaml_token_t));
+
+ /* No tokens after STREAM-END or error. */
+
+ if (parser->stream_end_produced || parser->error) {
+ return 1;
+ }
+
+ /* Ensure that the tokens queue contains enough tokens. */
+
+ if (!parser->token_available) {
+ if (!yaml_parser_fetch_more_tokens(parser))
+ return 0;
+ }
+
+ /* Fetch the next token from the queue. */
+
+ *token = DEQUEUE(parser, parser->tokens);
+ parser->token_available = 0;
+ parser->tokens_parsed ++;
+
+ if (token->type == YAML_STREAM_END_TOKEN) {
+ parser->stream_end_produced = 1;
+ }
+
+ return 1;
+}
+
+/*
+ * Set the scanner error and return 0.
+ */
+
+static int
+yaml_parser_set_scanner_error(yaml_parser_t *parser, const char *context,
+ yaml_mark_t context_mark, const char *problem)
+{
+ parser->error = YAML_SCANNER_ERROR;
+ parser->context = context;
+ parser->context_mark = context_mark;
+ parser->problem = problem;
+ parser->problem_mark = parser->mark;
+
+ return 0;
+}
+
+/*
+ * Ensure that the tokens queue contains at least one token which can be
+ * returned to the Parser.
+ */
+
+YAML_DECLARE(int)
+yaml_parser_fetch_more_tokens(yaml_parser_t *parser)
+{
+ int need_more_tokens;
+
+ /* While we need more tokens to fetch, do it. */
+
+ while (1)
+ {
+ /*
+ * Check if we really need to fetch more tokens.
+ */
+
+ need_more_tokens = 0;
+
+ if (parser->tokens.head == parser->tokens.tail)
+ {
+ /* Queue is empty. */
+
+ need_more_tokens = 1;
+ }
+ else
+ {
+ yaml_simple_key_t *simple_key;
+
+ /* Check if any potential simple key may occupy the head position. */
+
+ if (!yaml_parser_stale_simple_keys(parser))
+ return 0;
+
+ for (simple_key = parser->simple_keys.start;
+ simple_key != parser->simple_keys.top; simple_key++) {
+ if (simple_key->possible
+ && simple_key->token_number == parser->tokens_parsed) {
+ need_more_tokens = 1;
+ break;
+ }
+ }
+ }
+
+ /* We are finished. */
+
+ if (!need_more_tokens)
+ break;
+
+ /* Fetch the next token. */
+
+ if (!yaml_parser_fetch_next_token(parser))
+ return 0;
+ }
+
+ parser->token_available = 1;
+
+ return 1;
+}
+
+/*
+ * The dispatcher for token fetchers.
+ */
+
+static int
+yaml_parser_fetch_next_token(yaml_parser_t *parser)
+{
+ /* Ensure that the buffer is initialized. */
+
+ if (!CACHE(parser, 1))
+ return 0;
+
+ /* Check if we just started scanning. Fetch STREAM-START then. */
+
+ if (!parser->stream_start_produced)
+ return yaml_parser_fetch_stream_start(parser);
+
+ /* Eat whitespaces and comments until we reach the next token. */
+
+ if (!yaml_parser_scan_to_next_token(parser))
+ return 0;
+
+ /* Remove obsolete potential simple keys. */
+
+ if (!yaml_parser_stale_simple_keys(parser))
+ return 0;
+
+ /* Check the indentation level against the current column. */
+
+ if (!yaml_parser_unroll_indent(parser, parser->mark.column))
+ return 0;
+
+ /*
+ * Ensure that the buffer contains at least 4 characters. 4 is the length
+ * of the longest indicators ('--- ' and '... ').
+ */
+
+ if (!CACHE(parser, 4))
+ return 0;
+
+ /* Is it the end of the stream? */
+
+ if (IS_Z(parser->buffer))
+ return yaml_parser_fetch_stream_end(parser);
+
+ /* Is it a directive? */
+
+ if (parser->mark.column == 0 && CHECK(parser->buffer, '%'))
+ return yaml_parser_fetch_directive(parser);
+
+ /* Is it the document start indicator? */
+
+ if (parser->mark.column == 0
+ && CHECK_AT(parser->buffer, '-', 0)
+ && CHECK_AT(parser->buffer, '-', 1)
+ && CHECK_AT(parser->buffer, '-', 2)
+ && IS_BLANKZ_AT(parser->buffer, 3))
+ return yaml_parser_fetch_document_indicator(parser,
+ YAML_DOCUMENT_START_TOKEN);
+
+ /* Is it the document end indicator? */
+
+ if (parser->mark.column == 0
+ && CHECK_AT(parser->buffer, '.', 0)
+ && CHECK_AT(parser->buffer, '.', 1)
+ && CHECK_AT(parser->buffer, '.', 2)
+ && IS_BLANKZ_AT(parser->buffer, 3))
+ return yaml_parser_fetch_document_indicator(parser,
+ YAML_DOCUMENT_END_TOKEN);
+
+ /* Is it the flow sequence start indicator? */
+
+ if (CHECK(parser->buffer, '['))
+ return yaml_parser_fetch_flow_collection_start(parser,
+ YAML_FLOW_SEQUENCE_START_TOKEN);
+
+ /* Is it the flow mapping start indicator? */
+
+ if (CHECK(parser->buffer, '{'))
+ return yaml_parser_fetch_flow_collection_start(parser,
+ YAML_FLOW_MAPPING_START_TOKEN);
+
+ /* Is it the flow sequence end indicator? */
+
+ if (CHECK(parser->buffer, ']'))
+ return yaml_parser_fetch_flow_collection_end(parser,
+ YAML_FLOW_SEQUENCE_END_TOKEN);
+
+ /* Is it the flow mapping end indicator? */
+
+ if (CHECK(parser->buffer, '}'))
+ return yaml_parser_fetch_flow_collection_end(parser,
+ YAML_FLOW_MAPPING_END_TOKEN);
+
+ /* Is it the flow entry indicator? */
+
+ if (CHECK(parser->buffer, ','))
+ return yaml_parser_fetch_flow_entry(parser);
+
+ /* Is it the block entry indicator? */
+
+ if (CHECK(parser->buffer, '-') && IS_BLANKZ_AT(parser->buffer, 1))
+ return yaml_parser_fetch_block_entry(parser);
+
+ /* Is it the key indicator? */
+
+ if (CHECK(parser->buffer, '?')
+ && (parser->flow_level || IS_BLANKZ_AT(parser->buffer, 1)))
+ return yaml_parser_fetch_key(parser);
+
+ /* Is it the value indicator? */
+
+ if (CHECK(parser->buffer, ':')
+ && (parser->flow_level || IS_BLANKZ_AT(parser->buffer, 1)))
+ return yaml_parser_fetch_value(parser);
+
+ /* Is it an alias? */
+
+ if (CHECK(parser->buffer, '*'))
+ return yaml_parser_fetch_anchor(parser, YAML_ALIAS_TOKEN);
+
+ /* Is it an anchor? */
+
+ if (CHECK(parser->buffer, '&'))
+ return yaml_parser_fetch_anchor(parser, YAML_ANCHOR_TOKEN);
+
+ /* Is it a tag? */
+
+ if (CHECK(parser->buffer, '!'))
+ return yaml_parser_fetch_tag(parser);
+
+ /* Is it a literal scalar? */
+
+ if (CHECK(parser->buffer, '|') && !parser->flow_level)
+ return yaml_parser_fetch_block_scalar(parser, 1);
+
+ /* Is it a folded scalar? */
+
+ if (CHECK(parser->buffer, '>') && !parser->flow_level)
+ return yaml_parser_fetch_block_scalar(parser, 0);
+
+ /* Is it a single-quoted scalar? */
+
+ if (CHECK(parser->buffer, '\''))
+ return yaml_parser_fetch_flow_scalar(parser, 1);
+
+ /* Is it a double-quoted scalar? */
+
+ if (CHECK(parser->buffer, '"'))
+ return yaml_parser_fetch_flow_scalar(parser, 0);
+
+ /*
+ * Is it a plain scalar?
+ *
+ * A plain scalar may start with any non-blank characters except
+ *
+ * '-', '?', ':', ',', '[', ']', '{', '}',
+ * '#', '&', '*', '!', '|', '>', '\'', '\"',
+ * '%', '@', '`'.
+ *
+ * In the block context (and, for the '-' indicator, in the flow context
+ * too), it may also start with the characters
+ *
+ * '-', '?', ':'
+ *
+ * if it is followed by a non-space character.
+ *
+ * The last rule is more restrictive than the specification requires.
+ */
+
+ if (!(IS_BLANKZ(parser->buffer) || CHECK(parser->buffer, '-')
+ || CHECK(parser->buffer, '?') || CHECK(parser->buffer, ':')
+ || CHECK(parser->buffer, ',') || CHECK(parser->buffer, '[')
+ || CHECK(parser->buffer, ']') || CHECK(parser->buffer, '{')
+ || CHECK(parser->buffer, '}') || CHECK(parser->buffer, '#')
+ || CHECK(parser->buffer, '&') || CHECK(parser->buffer, '*')
+ || CHECK(parser->buffer, '!') || CHECK(parser->buffer, '|')
+ || CHECK(parser->buffer, '>') || CHECK(parser->buffer, '\'')
+ || CHECK(parser->buffer, '"') || CHECK(parser->buffer, '%')
+ || CHECK(parser->buffer, '@') || CHECK(parser->buffer, '`')) ||
+ (CHECK(parser->buffer, '-') && !IS_BLANK_AT(parser->buffer, 1)) ||
+ (!parser->flow_level &&
+ (CHECK(parser->buffer, '?') || CHECK(parser->buffer, ':'))
+ && !IS_BLANKZ_AT(parser->buffer, 1)))
+ return yaml_parser_fetch_plain_scalar(parser);
+
+ /*
+ * If we don't determine the token type so far, it is an error.
+ */
+
+ return yaml_parser_set_scanner_error(parser,
+ "while scanning for the next token", parser->mark,
+ "found character that cannot start any token");
+}
+
+/*
+ * Check the list of potential simple keys and remove the positions that
+ * cannot contain simple keys anymore.
+ */
+
+static int
+yaml_parser_stale_simple_keys(yaml_parser_t *parser)
+{
+ yaml_simple_key_t *simple_key;
+
+ /* Check for a potential simple key for each flow level. */
+
+ for (simple_key = parser->simple_keys.start;
+ simple_key != parser->simple_keys.top; simple_key ++)
+ {
+ /*
+ * The specification requires that a simple key
+ *
+ * - is limited to a single line,
+ * - is shorter than 1024 characters.
+ */
+
+ if (simple_key->possible
+ && (simple_key->mark.line < parser->mark.line
+ || simple_key->mark.index+1024 < parser->mark.index)) {
+
+ /* Check if the potential simple key to be removed is required. */
+
+ if (simple_key->required) {
+ return yaml_parser_set_scanner_error(parser,
+ "while scanning a simple key", simple_key->mark,
+ "could not find expected ':'");
+ }
+
+ simple_key->possible = 0;
+ }
+ }
+
+ return 1;
+}
+
+/*
+ * Check if a simple key may start at the current position and add it if
+ * needed.
+ */
+
+static int
+yaml_parser_save_simple_key(yaml_parser_t *parser)
+{
+ /*
+ * A simple key is required at the current position if the scanner is in
+ * the block context and the current column coincides with the indentation
+ * level.
+ */
+
+ int required = (!parser->flow_level
+ && parser->indent == (ptrdiff_t)parser->mark.column);
+
+ /*
+ * A simple key is required only when it is the first token in the current
+ * line. Therefore it is always allowed. But we add a check anyway.
+ */
+
+ assert(parser->simple_key_allowed || !required); /* Impossible. */
+
+ /*
+ * If the current position may start a simple key, save it.
+ */
+
+ if (parser->simple_key_allowed)
+ {
+ yaml_simple_key_t simple_key;
+ simple_key.possible = 1;
+ simple_key.required = required;
+ simple_key.token_number =
+ parser->tokens_parsed + (parser->tokens.tail - parser->tokens.head);
+ simple_key.mark = parser->mark;
+
+ if (!yaml_parser_remove_simple_key(parser)) return 0;
+
+ *(parser->simple_keys.top-1) = simple_key;
+ }
+
+ return 1;
+}
+
+/*
+ * Remove a potential simple key at the current flow level.
+ */
+
+static int
+yaml_parser_remove_simple_key(yaml_parser_t *parser)
+{
+ yaml_simple_key_t *simple_key = parser->simple_keys.top-1;
+
+ if (simple_key->possible)
+ {
+ /* If the key is required, it is an error. */
+
+ if (simple_key->required) {
+ return yaml_parser_set_scanner_error(parser,
+ "while scanning a simple key", simple_key->mark,
+ "could not find expected ':'");
+ }
+ }
+
+ /* Remove the key from the stack. */
+
+ simple_key->possible = 0;
+
+ return 1;
+}
+
+/*
+ * Increase the flow level and resize the simple key list if needed.
+ */
+
+static int
+yaml_parser_increase_flow_level(yaml_parser_t *parser)
+{
+ yaml_simple_key_t empty_simple_key = { 0, 0, 0, { 0, 0, 0 } };
+
+ /* Reset the simple key on the next level. */
+
+ if (!PUSH(parser, parser->simple_keys, empty_simple_key))
+ return 0;
+
+ /* Increase the flow level. */
+
+ if (parser->flow_level == INT_MAX) {
+ parser->error = YAML_MEMORY_ERROR;
+ return 0;
+ }
+
+ parser->flow_level++;
+
+ return 1;
+}
+
+/*
+ * Decrease the flow level.
+ */
+
+static int
+yaml_parser_decrease_flow_level(yaml_parser_t *parser)
+{
+ if (parser->flow_level) {
+ parser->flow_level --;
+ (void)POP(parser, parser->simple_keys);
+ }
+
+ return 1;
+}
+
+/*
+ * Push the current indentation level to the stack and set the new level
+ * the current column is greater than the indentation level. In this case,
+ * append or insert the specified token into the token queue.
+ *
+ */
+
+static int
+yaml_parser_roll_indent(yaml_parser_t *parser, ptrdiff_t column,
+ ptrdiff_t number, yaml_token_type_t type, yaml_mark_t mark)
+{
+ yaml_token_t token;
+
+ /* In the flow context, do nothing. */
+
+ if (parser->flow_level)
+ return 1;
+
+ if (parser->indent < column)
+ {
+ /*
+ * Push the current indentation level to the stack and set the new
+ * indentation level.
+ */
+
+ if (!PUSH(parser, parser->indents, parser->indent))
+ return 0;
+
+#if PTRDIFF_MAX > INT_MAX
+ if (column > INT_MAX) {
+ parser->error = YAML_MEMORY_ERROR;
+ return 0;
+ }
+#endif
+
+ parser->indent = (int)column;
+
+ /* Create a token and insert it into the queue. */
+
+ TOKEN_INIT(token, type, mark, mark);
+
+ if (number == -1) {
+ if (!ENQUEUE(parser, parser->tokens, token))
+ return 0;
+ }
+ else {
+ if (!QUEUE_INSERT(parser,
+ parser->tokens, number - parser->tokens_parsed, token))
+ return 0;
+ }
+ }
+
+ return 1;
+}
+
+/*
+ * Pop indentation levels from the indents stack until the current level
+ * becomes less or equal to the column. For each intendation level, append
+ * the BLOCK-END token.
+ */
+
+
+static int
+yaml_parser_unroll_indent(yaml_parser_t *parser, ptrdiff_t column)
+{
+ yaml_token_t token;
+
+ /* In the flow context, do nothing. */
+
+ if (parser->flow_level)
+ return 1;
+
+ /* Loop through the intendation levels in the stack. */
+
+ while (parser->indent > column)
+ {
+ /* Create a token and append it to the queue. */
+
+ TOKEN_INIT(token, YAML_BLOCK_END_TOKEN, parser->mark, parser->mark);
+
+ if (!ENQUEUE(parser, parser->tokens, token))
+ return 0;
+
+ /* Pop the indentation level. */
+
+ parser->indent = POP(parser, parser->indents);
+ }
+
+ return 1;
+}
+
+/*
+ * Initialize the scanner and produce the STREAM-START token.
+ */
+
+static int
+yaml_parser_fetch_stream_start(yaml_parser_t *parser)
+{
+ yaml_simple_key_t simple_key = { 0, 0, 0, { 0, 0, 0 } };
+ yaml_token_t token;
+
+ /* Set the initial indentation. */
+
+ parser->indent = -1;
+
+ /* Initialize the simple key stack. */
+
+ if (!PUSH(parser, parser->simple_keys, simple_key))
+ return 0;
+
+ /* A simple key is allowed at the beginning of the stream. */
+
+ parser->simple_key_allowed = 1;
+
+ /* We have started. */
+
+ parser->stream_start_produced = 1;
+
+ /* Create the STREAM-START token and append it to the queue. */
+
+ STREAM_START_TOKEN_INIT(token, parser->encoding,
+ parser->mark, parser->mark);
+
+ if (!ENQUEUE(parser, parser->tokens, token))
+ return 0;
+
+ return 1;
+}
+
+/*
+ * Produce the STREAM-END token and shut down the scanner.
+ */
+
+static int
+yaml_parser_fetch_stream_end(yaml_parser_t *parser)
+{
+ yaml_token_t token;
+
+ /* Force new line. */
+
+ if (parser->mark.column != 0) {
+ parser->mark.column = 0;
+ parser->mark.line ++;
+ }
+
+ /* Reset the indentation level. */
+
+ if (!yaml_parser_unroll_indent(parser, -1))
+ return 0;
+
+ /* Reset simple keys. */
+
+ if (!yaml_parser_remove_simple_key(parser))
+ return 0;
+
+ parser->simple_key_allowed = 0;
+
+ /* Create the STREAM-END token and append it to the queue. */
+
+ STREAM_END_TOKEN_INIT(token, parser->mark, parser->mark);
+
+ if (!ENQUEUE(parser, parser->tokens, token))
+ return 0;
+
+ return 1;
+}
+
+/*
+ * Produce a VERSION-DIRECTIVE or TAG-DIRECTIVE token.
+ */
+
+static int
+yaml_parser_fetch_directive(yaml_parser_t *parser)
+{
+ yaml_token_t token;
+
+ /* Reset the indentation level. */
+
+ if (!yaml_parser_unroll_indent(parser, -1))
+ return 0;
+
+ /* Reset simple keys. */
+
+ if (!yaml_parser_remove_simple_key(parser))
+ return 0;
+
+ parser->simple_key_allowed = 0;
+
+ /* Create the YAML-DIRECTIVE or TAG-DIRECTIVE token. */
+
+ if (!yaml_parser_scan_directive(parser, &token))
+ return 0;
+
+ /* Append the token to the queue. */
+
+ if (!ENQUEUE(parser, parser->tokens, token)) {
+ yaml_token_delete(&token);
+ return 0;
+ }
+
+ return 1;
+}
+
+/*
+ * Produce the DOCUMENT-START or DOCUMENT-END token.
+ */
+
+static int
+yaml_parser_fetch_document_indicator(yaml_parser_t *parser,
+ yaml_token_type_t type)
+{
+ yaml_mark_t start_mark, end_mark;
+ yaml_token_t token;
+
+ /* Reset the indentation level. */
+
+ if (!yaml_parser_unroll_indent(parser, -1))
+ return 0;
+
+ /* Reset simple keys. */
+
+ if (!yaml_parser_remove_simple_key(parser))
+ return 0;
+
+ parser->simple_key_allowed = 0;
+
+ /* Consume the token. */
+
+ start_mark = parser->mark;
+
+ SKIP(parser);
+ SKIP(parser);
+ SKIP(parser);
+
+ end_mark = parser->mark;
+
+ /* Create the DOCUMENT-START or DOCUMENT-END token. */
+
+ TOKEN_INIT(token, type, start_mark, end_mark);
+
+ /* Append the token to the queue. */
+
+ if (!ENQUEUE(parser, parser->tokens, token))
+ return 0;
+
+ return 1;
+}
+
+/*
+ * Produce the FLOW-SEQUENCE-START or FLOW-MAPPING-START token.
+ */
+
+static int
+yaml_parser_fetch_flow_collection_start(yaml_parser_t *parser,
+ yaml_token_type_t type)
+{
+ yaml_mark_t start_mark, end_mark;
+ yaml_token_t token;
+
+ /* The indicators '[' and '{' may start a simple key. */
+
+ if (!yaml_parser_save_simple_key(parser))
+ return 0;
+
+ /* Increase the flow level. */
+
+ if (!yaml_parser_increase_flow_level(parser))
+ return 0;
+
+ /* A simple key may follow the indicators '[' and '{'. */
+
+ parser->simple_key_allowed = 1;
+
+ /* Consume the token. */
+
+ start_mark = parser->mark;
+ SKIP(parser);
+ end_mark = parser->mark;
+
+ /* Create the FLOW-SEQUENCE-START of FLOW-MAPPING-START token. */
+
+ TOKEN_INIT(token, type, start_mark, end_mark);
+
+ /* Append the token to the queue. */
+
+ if (!ENQUEUE(parser, parser->tokens, token))
+ return 0;
+
+ return 1;
+}
+
+/*
+ * Produce the FLOW-SEQUENCE-END or FLOW-MAPPING-END token.
+ */
+
+static int
+yaml_parser_fetch_flow_collection_end(yaml_parser_t *parser,
+ yaml_token_type_t type)
+{
+ yaml_mark_t start_mark, end_mark;
+ yaml_token_t token;
+
+ /* Reset any potential simple key on the current flow level. */
+
+ if (!yaml_parser_remove_simple_key(parser))
+ return 0;
+
+ /* Decrease the flow level. */
+
+ if (!yaml_parser_decrease_flow_level(parser))
+ return 0;
+
+ /* No simple keys after the indicators ']' and '}'. */
+
+ parser->simple_key_allowed = 0;
+
+ /* Consume the token. */
+
+ start_mark = parser->mark;
+ SKIP(parser);
+ end_mark = parser->mark;
+
+ /* Create the FLOW-SEQUENCE-END of FLOW-MAPPING-END token. */
+
+ TOKEN_INIT(token, type, start_mark, end_mark);
+
+ /* Append the token to the queue. */
+
+ if (!ENQUEUE(parser, parser->tokens, token))
+ return 0;
+
+ return 1;
+}
+
+/*
+ * Produce the FLOW-ENTRY token.
+ */
+
+static int
+yaml_parser_fetch_flow_entry(yaml_parser_t *parser)
+{
+ yaml_mark_t start_mark, end_mark;
+ yaml_token_t token;
+
+ /* Reset any potential simple keys on the current flow level. */
+
+ if (!yaml_parser_remove_simple_key(parser))
+ return 0;
+
+ /* Simple keys are allowed after ','. */
+
+ parser->simple_key_allowed = 1;
+
+ /* Consume the token. */
+
+ start_mark = parser->mark;
+ SKIP(parser);
+ end_mark = parser->mark;
+
+ /* Create the FLOW-ENTRY token and append it to the queue. */
+
+ TOKEN_INIT(token, YAML_FLOW_ENTRY_TOKEN, start_mark, end_mark);
+
+ if (!ENQUEUE(parser, parser->tokens, token))
+ return 0;
+
+ return 1;
+}
+
+/*
+ * Produce the BLOCK-ENTRY token.
+ */
+
+static int
+yaml_parser_fetch_block_entry(yaml_parser_t *parser)
+{
+ yaml_mark_t start_mark, end_mark;
+ yaml_token_t token;
+
+ /* Check if the scanner is in the block context. */
+
+ if (!parser->flow_level)
+ {
+ /* Check if we are allowed to start a new entry. */
+
+ if (!parser->simple_key_allowed) {
+ return yaml_parser_set_scanner_error(parser, NULL, parser->mark,
+ "block sequence entries are not allowed in this context");
+ }
+
+ /* Add the BLOCK-SEQUENCE-START token if needed. */
+
+ if (!yaml_parser_roll_indent(parser, parser->mark.column, -1,
+ YAML_BLOCK_SEQUENCE_START_TOKEN, parser->mark))
+ return 0;
+ }
+ else
+ {
+ /*
+ * It is an error for the '-' indicator to occur in the flow context,
+ * but we let the Parser detect and report about it because the Parser
+ * is able to point to the context.
+ */
+ }
+
+ /* Reset any potential simple keys on the current flow level. */
+
+ if (!yaml_parser_remove_simple_key(parser))
+ return 0;
+
+ /* Simple keys are allowed after '-'. */
+
+ parser->simple_key_allowed = 1;
+
+ /* Consume the token. */
+
+ start_mark = parser->mark;
+ SKIP(parser);
+ end_mark = parser->mark;
+
+ /* Create the BLOCK-ENTRY token and append it to the queue. */
+
+ TOKEN_INIT(token, YAML_BLOCK_ENTRY_TOKEN, start_mark, end_mark);
+
+ if (!ENQUEUE(parser, parser->tokens, token))
+ return 0;
+
+ return 1;
+}
+
+/*
+ * Produce the KEY token.
+ */
+
+static int
+yaml_parser_fetch_key(yaml_parser_t *parser)
+{
+ yaml_mark_t start_mark, end_mark;
+ yaml_token_t token;
+
+ /* In the block context, additional checks are required. */
+
+ if (!parser->flow_level)
+ {
+ /* Check if we are allowed to start a new key (not nessesary simple). */
+
+ if (!parser->simple_key_allowed) {
+ return yaml_parser_set_scanner_error(parser, NULL, parser->mark,
+ "mapping keys are not allowed in this context");
+ }
+
+ /* Add the BLOCK-MAPPING-START token if needed. */
+
+ if (!yaml_parser_roll_indent(parser, parser->mark.column, -1,
+ YAML_BLOCK_MAPPING_START_TOKEN, parser->mark))
+ return 0;
+ }
+
+ /* Reset any potential simple keys on the current flow level. */
+
+ if (!yaml_parser_remove_simple_key(parser))
+ return 0;
+
+ /* Simple keys are allowed after '?' in the block context. */
+
+ parser->simple_key_allowed = (!parser->flow_level);
+
+ /* Consume the token. */
+
+ start_mark = parser->mark;
+ SKIP(parser);
+ end_mark = parser->mark;
+
+ /* Create the KEY token and append it to the queue. */
+
+ TOKEN_INIT(token, YAML_KEY_TOKEN, start_mark, end_mark);
+
+ if (!ENQUEUE(parser, parser->tokens, token))
+ return 0;
+
+ return 1;
+}
+
+/*
+ * Produce the VALUE token.
+ */
+
+static int
+yaml_parser_fetch_value(yaml_parser_t *parser)
+{
+ yaml_mark_t start_mark, end_mark;
+ yaml_token_t token;
+ yaml_simple_key_t *simple_key = parser->simple_keys.top-1;
+
+ /* Have we found a simple key? */
+
+ if (simple_key->possible)
+ {
+
+ /* Create the KEY token and insert it into the queue. */
+
+ TOKEN_INIT(token, YAML_KEY_TOKEN, simple_key->mark, simple_key->mark);
+
+ if (!QUEUE_INSERT(parser, parser->tokens,
+ simple_key->token_number - parser->tokens_parsed, token))
+ return 0;
+
+ /* In the block context, we may need to add the BLOCK-MAPPING-START token. */
+
+ if (!yaml_parser_roll_indent(parser, simple_key->mark.column,
+ simple_key->token_number,
+ YAML_BLOCK_MAPPING_START_TOKEN, simple_key->mark))
+ return 0;
+
+ /* Remove the simple key. */
+
+ simple_key->possible = 0;
+
+ /* A simple key cannot follow another simple key. */
+
+ parser->simple_key_allowed = 0;
+ }
+ else
+ {
+ /* The ':' indicator follows a complex key. */
+
+ /* In the block context, extra checks are required. */
+
+ if (!parser->flow_level)
+ {
+ /* Check if we are allowed to start a complex value. */
+
+ if (!parser->simple_key_allowed) {
+ return yaml_parser_set_scanner_error(parser, NULL, parser->mark,
+ "mapping values are not allowed in this context");
+ }
+
+ /* Add the BLOCK-MAPPING-START token if needed. */
+
+ if (!yaml_parser_roll_indent(parser, parser->mark.column, -1,
+ YAML_BLOCK_MAPPING_START_TOKEN, parser->mark))
+ return 0;
+ }
+
+ /* Simple keys after ':' are allowed in the block context. */
+
+ parser->simple_key_allowed = (!parser->flow_level);
+ }
+
+ /* Consume the token. */
+
+ start_mark = parser->mark;
+ SKIP(parser);
+ end_mark = parser->mark;
+
+ /* Create the VALUE token and append it to the queue. */
+
+ TOKEN_INIT(token, YAML_VALUE_TOKEN, start_mark, end_mark);
+
+ if (!ENQUEUE(parser, parser->tokens, token))
+ return 0;
+
+ return 1;
+}
+
+/*
+ * Produce the ALIAS or ANCHOR token.
+ */
+
+static int
+yaml_parser_fetch_anchor(yaml_parser_t *parser, yaml_token_type_t type)
+{
+ yaml_token_t token;
+
+ /* An anchor or an alias could be a simple key. */
+
+ if (!yaml_parser_save_simple_key(parser))
+ return 0;
+
+ /* A simple key cannot follow an anchor or an alias. */
+
+ parser->simple_key_allowed = 0;
+
+ /* Create the ALIAS or ANCHOR token and append it to the queue. */
+
+ if (!yaml_parser_scan_anchor(parser, &token, type))
+ return 0;
+
+ if (!ENQUEUE(parser, parser->tokens, token)) {
+ yaml_token_delete(&token);
+ return 0;
+ }
+ return 1;
+}
+
+/*
+ * Produce the TAG token.
+ */
+
+static int
+yaml_parser_fetch_tag(yaml_parser_t *parser)
+{
+ yaml_token_t token;
+
+ /* A tag could be a simple key. */
+
+ if (!yaml_parser_save_simple_key(parser))
+ return 0;
+
+ /* A simple key cannot follow a tag. */
+
+ parser->simple_key_allowed = 0;
+
+ /* Create the TAG token and append it to the queue. */
+
+ if (!yaml_parser_scan_tag(parser, &token))
+ return 0;
+
+ if (!ENQUEUE(parser, parser->tokens, token)) {
+ yaml_token_delete(&token);
+ return 0;
+ }
+
+ return 1;
+}
+
+/*
+ * Produce the SCALAR(...,literal) or SCALAR(...,folded) tokens.
+ */
+
+static int
+yaml_parser_fetch_block_scalar(yaml_parser_t *parser, int literal)
+{
+ yaml_token_t token;
+
+ /* Remove any potential simple keys. */
+
+ if (!yaml_parser_remove_simple_key(parser))
+ return 0;
+
+ /* A simple key may follow a block scalar. */
+
+ parser->simple_key_allowed = 1;
+
+ /* Create the SCALAR token and append it to the queue. */
+
+ if (!yaml_parser_scan_block_scalar(parser, &token, literal))
+ return 0;
+
+ if (!ENQUEUE(parser, parser->tokens, token)) {
+ yaml_token_delete(&token);
+ return 0;
+ }
+
+ return 1;
+}
+
+/*
+ * Produce the SCALAR(...,single-quoted) or SCALAR(...,double-quoted) tokens.
+ */
+
+static int
+yaml_parser_fetch_flow_scalar(yaml_parser_t *parser, int single)
+{
+ yaml_token_t token;
+
+ /* A plain scalar could be a simple key. */
+
+ if (!yaml_parser_save_simple_key(parser))
+ return 0;
+
+ /* A simple key cannot follow a flow scalar. */
+
+ parser->simple_key_allowed = 0;
+
+ /* Create the SCALAR token and append it to the queue. */
+
+ if (!yaml_parser_scan_flow_scalar(parser, &token, single))
+ return 0;
+
+ if (!ENQUEUE(parser, parser->tokens, token)) {
+ yaml_token_delete(&token);
+ return 0;
+ }
+
+ return 1;
+}
+
+/*
+ * Produce the SCALAR(...,plain) token.
+ */
+
+static int
+yaml_parser_fetch_plain_scalar(yaml_parser_t *parser)
+{
+ yaml_token_t token;
+
+ /* A plain scalar could be a simple key. */
+
+ if (!yaml_parser_save_simple_key(parser))
+ return 0;
+
+ /* A simple key cannot follow a flow scalar. */
+
+ parser->simple_key_allowed = 0;
+
+ /* Create the SCALAR token and append it to the queue. */
+
+ if (!yaml_parser_scan_plain_scalar(parser, &token))
+ return 0;
+
+ if (!ENQUEUE(parser, parser->tokens, token)) {
+ yaml_token_delete(&token);
+ return 0;
+ }
+
+ return 1;
+}
+
+/*
+ * Eat whitespaces and comments until the next token is found.
+ */
+
+static int
+yaml_parser_scan_to_next_token(yaml_parser_t *parser)
+{
+ /* Until the next token is not found. */
+
+ while (1)
+ {
+ /* Allow the BOM mark to start a line. */
+
+ if (!CACHE(parser, 1)) return 0;
+
+ if (parser->mark.column == 0 && IS_BOM(parser->buffer))
+ SKIP(parser);
+
+ /*
+ * Eat whitespaces.
+ *
+ * Tabs are allowed:
+ *
+ * - in the flow context;
+ * - in the block context, but not at the beginning of the line or
+ * after '-', '?', or ':' (complex value).
+ */
+
+ if (!CACHE(parser, 1)) return 0;
+
+ while (CHECK(parser->buffer,' ') ||
+ ((parser->flow_level || !parser->simple_key_allowed) &&
+ CHECK(parser->buffer, '\t'))) {
+ SKIP(parser);
+ if (!CACHE(parser, 1)) return 0;
+ }
+
+ /* Eat a comment until a line break. */
+
+ if (CHECK(parser->buffer, '#')) {
+ while (!IS_BREAKZ(parser->buffer)) {
+ SKIP(parser);
+ if (!CACHE(parser, 1)) return 0;
+ }
+ }
+
+ /* If it is a line break, eat it. */
+
+ if (IS_BREAK(parser->buffer))
+ {
+ if (!CACHE(parser, 2)) return 0;
+ SKIP_LINE(parser);
+
+ /* In the block context, a new line may start a simple key. */
+
+ if (!parser->flow_level) {
+ parser->simple_key_allowed = 1;
+ }
+ }
+ else
+ {
+ /* We have found a token. */
+
+ break;
+ }
+ }
+
+ return 1;
+}
+
+/*
+ * Scan a YAML-DIRECTIVE or TAG-DIRECTIVE token.
+ *
+ * Scope:
+ * %YAML 1.1 # a comment \n
+ * ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+ * %TAG !yaml! tag:yaml.org,2002: \n
+ * ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+ */
+
+int
+yaml_parser_scan_directive(yaml_parser_t *parser, yaml_token_t *token)
+{
+ yaml_mark_t start_mark, end_mark;
+ yaml_char_t *name = NULL;
+ int major, minor;
+ yaml_char_t *handle = NULL, *prefix = NULL;
+
+ /* Eat '%'. */
+
+ start_mark = parser->mark;
+
+ SKIP(parser);
+
+ /* Scan the directive name. */
+
+ if (!yaml_parser_scan_directive_name(parser, start_mark, &name))
+ goto error;
+
+ /* Is it a YAML directive? */
+
+ if (strcmp((char *)name, "YAML") == 0)
+ {
+ /* Scan the VERSION directive value. */
+
+ if (!yaml_parser_scan_version_directive_value(parser, start_mark,
+ &major, &minor))
+ goto error;
+
+ end_mark = parser->mark;
+
+ /* Create a VERSION-DIRECTIVE token. */
+
+ VERSION_DIRECTIVE_TOKEN_INIT(*token, major, minor,
+ start_mark, end_mark);
+ }
+
+ /* Is it a TAG directive? */
+
+ else if (strcmp((char *)name, "TAG") == 0)
+ {
+ /* Scan the TAG directive value. */
+
+ if (!yaml_parser_scan_tag_directive_value(parser, start_mark,
+ &handle, &prefix))
+ goto error;
+
+ end_mark = parser->mark;
+
+ /* Create a TAG-DIRECTIVE token. */
+
+ TAG_DIRECTIVE_TOKEN_INIT(*token, handle, prefix,
+ start_mark, end_mark);
+ }
+
+ /* Unknown directive. */
+
+ else
+ {
+ yaml_parser_set_scanner_error(parser, "while scanning a directive",
+ start_mark, "found uknown directive name");
+ goto error;
+ }
+
+ /* Eat the rest of the line including any comments. */
+
+ if (!CACHE(parser, 1)) goto error;
+
+ while (IS_BLANK(parser->buffer)) {
+ SKIP(parser);
+ if (!CACHE(parser, 1)) goto error;
+ }
+
+ if (CHECK(parser->buffer, '#')) {
+ while (!IS_BREAKZ(parser->buffer)) {
+ SKIP(parser);
+ if (!CACHE(parser, 1)) goto error;
+ }
+ }
+
+ /* Check if we are at the end of the line. */
+
+ if (!IS_BREAKZ(parser->buffer)) {
+ yaml_parser_set_scanner_error(parser, "while scanning a directive",
+ start_mark, "did not find expected comment or line break");
+ goto error;
+ }
+
+ /* Eat a line break. */
+
+ if (IS_BREAK(parser->buffer)) {
+ if (!CACHE(parser, 2)) goto error;
+ SKIP_LINE(parser);
+ }
+
+ yaml_free(name);
+
+ return 1;
+
+error:
+ yaml_free(prefix);
+ yaml_free(handle);
+ yaml_free(name);
+ return 0;
+}
+
+/*
+ * Scan the directive name.
+ *
+ * Scope:
+ * %YAML 1.1 # a comment \n
+ * ^^^^
+ * %TAG !yaml! tag:yaml.org,2002: \n
+ * ^^^
+ */
+
+static int
+yaml_parser_scan_directive_name(yaml_parser_t *parser,
+ yaml_mark_t start_mark, yaml_char_t **name)
+{
+ yaml_string_t string = NULL_STRING;
+
+ if (!STRING_INIT(parser, string, INITIAL_STRING_SIZE)) goto error;
+
+ /* Consume the directive name. */
+
+ if (!CACHE(parser, 1)) goto error;
+
+ while (IS_ALPHA(parser->buffer))
+ {
+ if (!READ(parser, string)) goto error;
+ if (!CACHE(parser, 1)) goto error;
+ }
+
+ /* Check if the name is empty. */
+
+ if (string.start == string.pointer) {
+ yaml_parser_set_scanner_error(parser, "while scanning a directive",
+ start_mark, "could not find expected directive name");
+ goto error;
+ }
+
+ /* Check for an blank character after the name. */
+
+ if (!IS_BLANKZ(parser->buffer)) {
+ yaml_parser_set_scanner_error(parser, "while scanning a directive",
+ start_mark, "found unexpected non-alphabetical character");
+ goto error;
+ }
+
+ *name = string.start;
+
+ return 1;
+
+error:
+ STRING_DEL(parser, string);
+ return 0;
+}
+
+/*
+ * Scan the value of VERSION-DIRECTIVE.
+ *
+ * Scope:
+ * %YAML 1.1 # a comment \n
+ * ^^^^^^
+ */
+
+static int
+yaml_parser_scan_version_directive_value(yaml_parser_t *parser,
+ yaml_mark_t start_mark, int *major, int *minor)
+{
+ /* Eat whitespaces. */
+
+ if (!CACHE(parser, 1)) return 0;
+
+ while (IS_BLANK(parser->buffer)) {
+ SKIP(parser);
+ if (!CACHE(parser, 1)) return 0;
+ }
+
+ /* Consume the major version number. */
+
+ if (!yaml_parser_scan_version_directive_number(parser, start_mark, major))
+ return 0;
+
+ /* Eat '.'. */
+
+ if (!CHECK(parser->buffer, '.')) {
+ return yaml_parser_set_scanner_error(parser, "while scanning a %YAML directive",
+ start_mark, "did not find expected digit or '.' character");
+ }
+
+ SKIP(parser);
+
+ /* Consume the minor version number. */
+
+ if (!yaml_parser_scan_version_directive_number(parser, start_mark, minor))
+ return 0;
+
+ return 1;
+}
+
+#define MAX_NUMBER_LENGTH 9
+
+/*
+ * Scan the version number of VERSION-DIRECTIVE.
+ *
+ * Scope:
+ * %YAML 1.1 # a comment \n
+ * ^
+ * %YAML 1.1 # a comment \n
+ * ^
+ */
+
+static int
+yaml_parser_scan_version_directive_number(yaml_parser_t *parser,
+ yaml_mark_t start_mark, int *number)
+{
+ int value = 0;
+ size_t length = 0;
+
+ /* Repeat while the next character is digit. */
+
+ if (!CACHE(parser, 1)) return 0;
+
+ while (IS_DIGIT(parser->buffer))
+ {
+ /* Check if the number is too long. */
+
+ if (++length > MAX_NUMBER_LENGTH) {
+ return yaml_parser_set_scanner_error(parser, "while scanning a %YAML directive",
+ start_mark, "found extremely long version number");
+ }
+
+ value = value*10 + AS_DIGIT(parser->buffer);
+
+ SKIP(parser);
+
+ if (!CACHE(parser, 1)) return 0;
+ }
+
+ /* Check if the number was present. */
+
+ if (!length) {
+ return yaml_parser_set_scanner_error(parser, "while scanning a %YAML directive",
+ start_mark, "did not find expected version number");
+ }
+
+ *number = value;
+
+ return 1;
+}
+
+/*
+ * Scan the value of a TAG-DIRECTIVE token.
+ *
+ * Scope:
+ * %TAG !yaml! tag:yaml.org,2002: \n
+ * ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+ */
+
+static int
+yaml_parser_scan_tag_directive_value(yaml_parser_t *parser,
+ yaml_mark_t start_mark, yaml_char_t **handle, yaml_char_t **prefix)
+{
+ yaml_char_t *handle_value = NULL;
+ yaml_char_t *prefix_value = NULL;
+
+ /* Eat whitespaces. */
+
+ if (!CACHE(parser, 1)) goto error;
+
+ while (IS_BLANK(parser->buffer)) {
+ SKIP(parser);
+ if (!CACHE(parser, 1)) goto error;
+ }
+
+ /* Scan a handle. */
+
+ if (!yaml_parser_scan_tag_handle(parser, 1, start_mark, &handle_value))
+ goto error;
+
+ /* Expect a whitespace. */
+
+ if (!CACHE(parser, 1)) goto error;
+
+ if (!IS_BLANK(parser->buffer)) {
+ yaml_parser_set_scanner_error(parser, "while scanning a %TAG directive",
+ start_mark, "did not find expected whitespace");
+ goto error;
+ }
+
+ /* Eat whitespaces. */
+
+ while (IS_BLANK(parser->buffer)) {
+ SKIP(parser);
+ if (!CACHE(parser, 1)) goto error;
+ }
+
+ /* Scan a prefix. */
+
+ if (!yaml_parser_scan_tag_uri(parser, 1, NULL, start_mark, &prefix_value))
+ goto error;
+
+ /* Expect a whitespace or line break. */
+
+ if (!CACHE(parser, 1)) goto error;
+
+ if (!IS_BLANKZ(parser->buffer)) {
+ yaml_parser_set_scanner_error(parser, "while scanning a %TAG directive",
+ start_mark, "did not find expected whitespace or line break");
+ goto error;
+ }
+
+ *handle = handle_value;
+ *prefix = prefix_value;
+
+ return 1;
+
+error:
+ yaml_free(handle_value);
+ yaml_free(prefix_value);
+ return 0;
+}
+
+static int
+yaml_parser_scan_anchor(yaml_parser_t *parser, yaml_token_t *token,
+ yaml_token_type_t type)
+{
+ int length = 0;
+ yaml_mark_t start_mark, end_mark;
+ yaml_string_t string = NULL_STRING;
+
+ if (!STRING_INIT(parser, string, INITIAL_STRING_SIZE)) goto error;
+
+ /* Eat the indicator character. */
+
+ start_mark = parser->mark;
+
+ SKIP(parser);
+
+ /* Consume the value. */
+
+ if (!CACHE(parser, 1)) goto error;
+
+ while (IS_ALPHA(parser->buffer)) {
+ if (!READ(parser, string)) goto error;
+ if (!CACHE(parser, 1)) goto error;
+ length ++;
+ }
+
+ end_mark = parser->mark;
+
+ /*
+ * Check if length of the anchor is greater than 0 and it is followed by
+ * a whitespace character or one of the indicators:
+ *
+ * '?', ':', ',', ']', '}', '%', '@', '`'.
+ */
+
+ if (!length || !(IS_BLANKZ(parser->buffer) || CHECK(parser->buffer, '?')
+ || CHECK(parser->buffer, ':') || CHECK(parser->buffer, ',')
+ || CHECK(parser->buffer, ']') || CHECK(parser->buffer, '}')
+ || CHECK(parser->buffer, '%') || CHECK(parser->buffer, '@')
+ || CHECK(parser->buffer, '`'))) {
+ yaml_parser_set_scanner_error(parser, type == YAML_ANCHOR_TOKEN ?
+ "while scanning an anchor" : "while scanning an alias", start_mark,
+ "did not find expected alphabetic or numeric character");
+ goto error;
+ }
+
+ /* Create a token. */
+
+ if (type == YAML_ANCHOR_TOKEN) {
+ ANCHOR_TOKEN_INIT(*token, string.start, start_mark, end_mark);
+ }
+ else {
+ ALIAS_TOKEN_INIT(*token, string.start, start_mark, end_mark);
+ }
+
+ return 1;
+
+error:
+ STRING_DEL(parser, string);
+ return 0;
+}
+
+/*
+ * Scan a TAG token.
+ */
+
+static int
+yaml_parser_scan_tag(yaml_parser_t *parser, yaml_token_t *token)
+{
+ yaml_char_t *handle = NULL;
+ yaml_char_t *suffix = NULL;
+ yaml_mark_t start_mark, end_mark;
+
+ start_mark = parser->mark;
+
+ /* Check if the tag is in the canonical form. */
+
+ if (!CACHE(parser, 2)) goto error;
+
+ if (CHECK_AT(parser->buffer, '<', 1))
+ {
+ /* Set the handle to '' */
+
+ handle = yaml_malloc(1);
+ if (!handle) goto error;
+ handle[0] = '\0';
+
+ /* Eat '!<' */
+
+ SKIP(parser);
+ SKIP(parser);
+
+ /* Consume the tag value. */
+
+ if (!yaml_parser_scan_tag_uri(parser, 0, NULL, start_mark, &suffix))
+ goto error;
+
+ /* Check for '>' and eat it. */
+
+ if (!CHECK(parser->buffer, '>')) {
+ yaml_parser_set_scanner_error(parser, "while scanning a tag",
+ start_mark, "did not find the expected '>'");
+ goto error;
+ }
+
+ SKIP(parser);
+ }
+ else
+ {
+ /* The tag has either the '!suffix' or the '!handle!suffix' form. */
+
+ /* First, try to scan a handle. */
+
+ if (!yaml_parser_scan_tag_handle(parser, 0, start_mark, &handle))
+ goto error;
+
+ /* Check if it is, indeed, handle. */
+
+ if (handle[0] == '!' && handle[1] != '\0' && handle[strlen((char *)handle)-1] == '!')
+ {
+ /* Scan the suffix now. */
+
+ if (!yaml_parser_scan_tag_uri(parser, 0, NULL, start_mark, &suffix))
+ goto error;
+ }
+ else
+ {
+ /* It wasn't a handle after all. Scan the rest of the tag. */
+
+ if (!yaml_parser_scan_tag_uri(parser, 0, handle, start_mark, &suffix))
+ goto error;
+
+ /* Set the handle to '!'. */
+
+ yaml_free(handle);
+ handle = yaml_malloc(2);
+ if (!handle) goto error;
+ handle[0] = '!';
+ handle[1] = '\0';
+
+ /*
+ * A special case: the '!' tag. Set the handle to '' and the
+ * suffix to '!'.
+ */
+
+ if (suffix[0] == '\0') {
+ yaml_char_t *tmp = handle;
+ handle = suffix;
+ suffix = tmp;
+ }
+ }
+ }
+
+ /* Check the character which ends the tag. */
+
+ if (!CACHE(parser, 1)) goto error;
+
+ if (!IS_BLANKZ(parser->buffer)) {
+ yaml_parser_set_scanner_error(parser, "while scanning a tag",
+ start_mark, "did not find expected whitespace or line break");
+ goto error;
+ }
+
+ end_mark = parser->mark;
+
+ /* Create a token. */
+
+ TAG_TOKEN_INIT(*token, handle, suffix, start_mark, end_mark);
+
+ return 1;
+
+error:
+ yaml_free(handle);
+ yaml_free(suffix);
+ return 0;
+}
+
+/*
+ * Scan a tag handle.
+ */
+
+static int
+yaml_parser_scan_tag_handle(yaml_parser_t *parser, int directive,
+ yaml_mark_t start_mark, yaml_char_t **handle)
+{
+ yaml_string_t string = NULL_STRING;
+
+ if (!STRING_INIT(parser, string, INITIAL_STRING_SIZE)) goto error;
+
+ /* Check the initial '!' character. */
+
+ if (!CACHE(parser, 1)) goto error;
+
+ if (!CHECK(parser->buffer, '!')) {
+ yaml_parser_set_scanner_error(parser, directive ?
+ "while scanning a tag directive" : "while scanning a tag",
+ start_mark, "did not find expected '!'");
+ goto error;
+ }
+
+ /* Copy the '!' character. */
+
+ if (!READ(parser, string)) goto error;
+
+ /* Copy all subsequent alphabetical and numerical characters. */
+
+ if (!CACHE(parser, 1)) goto error;
+
+ while (IS_ALPHA(parser->buffer))
+ {
+ if (!READ(parser, string)) goto error;
+ if (!CACHE(parser, 1)) goto error;
+ }
+
+ /* Check if the trailing character is '!' and copy it. */
+
+ if (CHECK(parser->buffer, '!'))
+ {
+ if (!READ(parser, string)) goto error;
+ }
+ else
+ {
+ /*
+ * It's either the '!' tag or not really a tag handle. If it's a %TAG
+ * directive, it's an error. If it's a tag token, it must be a part of
+ * URI.
+ */
+
+ if (directive && !(string.start[0] == '!' && string.start[1] == '\0')) {
+ yaml_parser_set_scanner_error(parser, "while parsing a tag directive",
+ start_mark, "did not find expected '!'");
+ goto error;
+ }
+ }
+
+ *handle = string.start;
+
+ return 1;
+
+error:
+ STRING_DEL(parser, string);
+ return 0;
+}
+
+/*
+ * Scan a tag.
+ */
+
+static int
+yaml_parser_scan_tag_uri(yaml_parser_t *parser, int directive,
+ yaml_char_t *head, yaml_mark_t start_mark, yaml_char_t **uri)
+{
+ size_t length = head ? strlen((char *)head) : 0;
+ yaml_string_t string = NULL_STRING;
+
+ if (!STRING_INIT(parser, string, INITIAL_STRING_SIZE)) goto error;
+
+ /* Resize the string to include the head. */
+
+ while ((size_t)(string.end - string.start) <= length) {
+ if (!yaml_string_extend(&string.start, &string.pointer, &string.end)) {
+ parser->error = YAML_MEMORY_ERROR;
+ goto error;
+ }
+ }
+
+ /*
+ * Copy the head if needed.
+ *
+ * Note that we don't copy the leading '!' character.
+ */
+
+ if (length > 1) {
+ memcpy(string.start, head+1, length-1);
+ string.pointer += length-1;
+ }
+
+ /* Scan the tag. */
+
+ if (!CACHE(parser, 1)) goto error;
+
+ /*
+ * The set of characters that may appear in URI is as follows:
+ *
+ * '0'-'9', 'A'-'Z', 'a'-'z', '_', '-', ';', '/', '?', ':', '@', '&',
+ * '=', '+', '$', ',', '.', '!', '~', '*', '\'', '(', ')', '[', ']',
+ * '%'.
+ */
+
+ while (IS_ALPHA(parser->buffer) || CHECK(parser->buffer, ';')
+ || CHECK(parser->buffer, '/') || CHECK(parser->buffer, '?')
+ || CHECK(parser->buffer, ':') || CHECK(parser->buffer, '@')
+ || CHECK(parser->buffer, '&') || CHECK(parser->buffer, '=')
+ || CHECK(parser->buffer, '+') || CHECK(parser->buffer, '$')
+ || CHECK(parser->buffer, ',') || CHECK(parser->buffer, '.')
+ || CHECK(parser->buffer, '!') || CHECK(parser->buffer, '~')
+ || CHECK(parser->buffer, '*') || CHECK(parser->buffer, '\'')
+ || CHECK(parser->buffer, '(') || CHECK(parser->buffer, ')')
+ || CHECK(parser->buffer, '[') || CHECK(parser->buffer, ']')
+ || CHECK(parser->buffer, '%'))
+ {
+ /* Check if it is a URI-escape sequence. */
+
+ if (CHECK(parser->buffer, '%')) {
+ if (!STRING_EXTEND(parser, string))
+ goto error;
+
+ if (!yaml_parser_scan_uri_escapes(parser,
+ directive, start_mark, &string)) goto error;
+ }
+ else {
+ if (!READ(parser, string)) goto error;
+ }
+
+ length ++;
+ if (!CACHE(parser, 1)) goto error;
+ }
+
+ /* Check if the tag is non-empty. */
+
+ if (!length) {
+ if (!STRING_EXTEND(parser, string))
+ goto error;
+
+ yaml_parser_set_scanner_error(parser, directive ?
+ "while parsing a %TAG directive" : "while parsing a tag",
+ start_mark, "did not find expected tag URI");
+ goto error;
+ }
+
+ *uri = string.start;
+
+ return 1;
+
+error:
+ STRING_DEL(parser, string);
+ return 0;
+}
+
+/*
+ * Decode an URI-escape sequence corresponding to a single UTF-8 character.
+ */
+
+static int
+yaml_parser_scan_uri_escapes(yaml_parser_t *parser, int directive,
+ yaml_mark_t start_mark, yaml_string_t *string)
+{
+ int width = 0;
+
+ /* Decode the required number of characters. */
+
+ do {
+
+ unsigned char octet = 0;
+
+ /* Check for a URI-escaped octet. */
+
+ if (!CACHE(parser, 3)) return 0;
+
+ if (!(CHECK(parser->buffer, '%')
+ && IS_HEX_AT(parser->buffer, 1)
+ && IS_HEX_AT(parser->buffer, 2))) {
+ return yaml_parser_set_scanner_error(parser, directive ?
+ "while parsing a %TAG directive" : "while parsing a tag",
+ start_mark, "did not find URI escaped octet");
+ }
+
+ /* Get the octet. */
+
+ octet = (AS_HEX_AT(parser->buffer, 1) << 4) + AS_HEX_AT(parser->buffer, 2);
+
+ /* If it is the leading octet, determine the length of the UTF-8 sequence. */
+
+ if (!width)
+ {
+ width = (octet & 0x80) == 0x00 ? 1 :
+ (octet & 0xE0) == 0xC0 ? 2 :
+ (octet & 0xF0) == 0xE0 ? 3 :
+ (octet & 0xF8) == 0xF0 ? 4 : 0;
+ if (!width) {
+ return yaml_parser_set_scanner_error(parser, directive ?
+ "while parsing a %TAG directive" : "while parsing a tag",
+ start_mark, "found an incorrect leading UTF-8 octet");
+ }
+ }
+ else
+ {
+ /* Check if the trailing octet is correct. */
+
+ if ((octet & 0xC0) != 0x80) {
+ return yaml_parser_set_scanner_error(parser, directive ?
+ "while parsing a %TAG directive" : "while parsing a tag",
+ start_mark, "found an incorrect trailing UTF-8 octet");
+ }
+ }
+
+ /* Copy the octet and move the pointers. */
+
+ *(string->pointer++) = octet;
+ SKIP(parser);
+ SKIP(parser);
+ SKIP(parser);
+
+ } while (--width);
+
+ return 1;
+}
+
+/*
+ * Scan a block scalar.
+ */
+
+static int
+yaml_parser_scan_block_scalar(yaml_parser_t *parser, yaml_token_t *token,
+ int literal)
+{
+ yaml_mark_t start_mark;
+ yaml_mark_t end_mark;
+ yaml_string_t string = NULL_STRING;
+ yaml_string_t leading_break = NULL_STRING;
+ yaml_string_t trailing_breaks = NULL_STRING;
+ int chomping = 0;
+ int increment = 0;
+ int indent = 0;
+ int leading_blank = 0;
+ int trailing_blank = 0;
+
+ if (!STRING_INIT(parser, string, INITIAL_STRING_SIZE)) goto error;
+ if (!STRING_INIT(parser, leading_break, INITIAL_STRING_SIZE)) goto error;
+ if (!STRING_INIT(parser, trailing_breaks, INITIAL_STRING_SIZE)) goto error;
+
+ /* Eat the indicator '|' or '>'. */
+
+ start_mark = parser->mark;
+
+ SKIP(parser);
+
+ /* Scan the additional block scalar indicators. */
+
+ if (!CACHE(parser, 1)) goto error;
+
+ /* Check for a chomping indicator. */
+
+ if (CHECK(parser->buffer, '+') || CHECK(parser->buffer, '-'))
+ {
+ /* Set the chomping method and eat the indicator. */
+
+ chomping = CHECK(parser->buffer, '+') ? +1 : -1;
+
+ SKIP(parser);
+
+ /* Check for an indentation indicator. */
+
+ if (!CACHE(parser, 1)) goto error;
+
+ if (IS_DIGIT(parser->buffer))
+ {
+ /* Check that the intendation is greater than 0. */
+
+ if (CHECK(parser->buffer, '0')) {
+ yaml_parser_set_scanner_error(parser, "while scanning a block scalar",
+ start_mark, "found an intendation indicator equal to 0");
+ goto error;
+ }
+
+ /* Get the intendation level and eat the indicator. */
+
+ increment = AS_DIGIT(parser->buffer);
+
+ SKIP(parser);
+ }
+ }
+
+ /* Do the same as above, but in the opposite order. */
+
+ else if (IS_DIGIT(parser->buffer))
+ {
+ if (CHECK(parser->buffer, '0')) {
+ yaml_parser_set_scanner_error(parser, "while scanning a block scalar",
+ start_mark, "found an intendation indicator equal to 0");
+ goto error;
+ }
+
+ increment = AS_DIGIT(parser->buffer);
+
+ SKIP(parser);
+
+ if (!CACHE(parser, 1)) goto error;
+
+ if (CHECK(parser->buffer, '+') || CHECK(parser->buffer, '-')) {
+ chomping = CHECK(parser->buffer, '+') ? +1 : -1;
+
+ SKIP(parser);
+ }
+ }
+
+ /* Eat whitespaces and comments to the end of the line. */
+
+ if (!CACHE(parser, 1)) goto error;
+
+ while (IS_BLANK(parser->buffer)) {
+ SKIP(parser);
+ if (!CACHE(parser, 1)) goto error;
+ }
+
+ if (CHECK(parser->buffer, '#')) {
+ while (!IS_BREAKZ(parser->buffer)) {
+ SKIP(parser);
+ if (!CACHE(parser, 1)) goto error;
+ }
+ }
+
+ /* Check if we are at the end of the line. */
+
+ if (!IS_BREAKZ(parser->buffer)) {
+ yaml_parser_set_scanner_error(parser, "while scanning a block scalar",
+ start_mark, "did not find expected comment or line break");
+ goto error;
+ }
+
+ /* Eat a line break. */
+
+ if (IS_BREAK(parser->buffer)) {
+ if (!CACHE(parser, 2)) goto error;
+ SKIP_LINE(parser);
+ }
+
+ end_mark = parser->mark;
+
+ /* Set the intendation level if it was specified. */
+
+ if (increment) {
+ indent = parser->indent >= 0 ? parser->indent+increment : increment;
+ }
+
+ /* Scan the leading line breaks and determine the indentation level if needed. */
+
+ if (!yaml_parser_scan_block_scalar_breaks(parser, &indent, &trailing_breaks,
+ start_mark, &end_mark)) goto error;
+
+ /* Scan the block scalar content. */
+
+ if (!CACHE(parser, 1)) goto error;
+
+ while ((int)parser->mark.column == indent && !IS_Z(parser->buffer))
+ {
+ /*
+ * We are at the beginning of a non-empty line.
+ */
+
+ /* Is it a trailing whitespace? */
+
+ trailing_blank = IS_BLANK(parser->buffer);
+
+ /* Check if we need to fold the leading line break. */
+
+ if (!literal && (*leading_break.start == '\n')
+ && !leading_blank && !trailing_blank)
+ {
+ /* Do we need to join the lines by space? */
+
+ if (*trailing_breaks.start == '\0') {
+ if (!STRING_EXTEND(parser, string)) goto error;
+ *(string.pointer ++) = ' ';
+ }
+
+ CLEAR(parser, leading_break);
+ }
+ else {
+ if (!JOIN(parser, string, leading_break)) goto error;
+ CLEAR(parser, leading_break);
+ }
+
+ /* Append the remaining line breaks. */
+
+ if (!JOIN(parser, string, trailing_breaks)) goto error;
+ CLEAR(parser, trailing_breaks);
+
+ /* Is it a leading whitespace? */
+
+ leading_blank = IS_BLANK(parser->buffer);
+
+ /* Consume the current line. */
+
+ while (!IS_BREAKZ(parser->buffer)) {
+ if (!READ(parser, string)) goto error;
+ if (!CACHE(parser, 1)) goto error;
+ }
+
+ /* Consume the line break. */
+
+ if (!CACHE(parser, 2)) goto error;
+
+ if (!READ_LINE(parser, leading_break)) goto error;
+
+ /* Eat the following intendation spaces and line breaks. */
+
+ if (!yaml_parser_scan_block_scalar_breaks(parser,
+ &indent, &trailing_breaks, start_mark, &end_mark)) goto error;
+ }
+
+ /* Chomp the tail. */
+
+ if (chomping != -1) {
+ if (!JOIN(parser, string, leading_break)) goto error;
+ }
+ if (chomping == 1) {
+ if (!JOIN(parser, string, trailing_breaks)) goto error;
+ }
+
+ /* Create a token. */
+
+ SCALAR_TOKEN_INIT(*token, string.start, string.pointer-string.start,
+ literal ? YAML_LITERAL_SCALAR_STYLE : YAML_FOLDED_SCALAR_STYLE,
+ start_mark, end_mark);
+
+ STRING_DEL(parser, leading_break);
+ STRING_DEL(parser, trailing_breaks);
+
+ return 1;
+
+error:
+ STRING_DEL(parser, string);
+ STRING_DEL(parser, leading_break);
+ STRING_DEL(parser, trailing_breaks);
+
+ return 0;
+}
+
+/*
+ * Scan intendation spaces and line breaks for a block scalar. Determine the
+ * intendation level if needed.
+ */
+
+static int
+yaml_parser_scan_block_scalar_breaks(yaml_parser_t *parser,
+ int *indent, yaml_string_t *breaks,
+ yaml_mark_t start_mark, yaml_mark_t *end_mark)
+{
+ int max_indent = 0;
+
+ *end_mark = parser->mark;
+
+ /* Eat the intendation spaces and line breaks. */
+
+ while (1)
+ {
+ /* Eat the intendation spaces. */
+
+ if (!CACHE(parser, 1)) return 0;
+
+ while ((!*indent || (int)parser->mark.column < *indent)
+ && IS_SPACE(parser->buffer)) {
+ SKIP(parser);
+ if (!CACHE(parser, 1)) return 0;
+ }
+
+ if ((int)parser->mark.column > max_indent)
+ max_indent = (int)parser->mark.column;
+
+ /* Check for a tab character messing the intendation. */
+
+ if ((!*indent || (int)parser->mark.column < *indent)
+ && IS_TAB(parser->buffer)) {
+ return yaml_parser_set_scanner_error(parser, "while scanning a block scalar",
+ start_mark, "found a tab character where an intendation space is expected");
+ }
+
+ /* Have we found a non-empty line? */
+
+ if (!IS_BREAK(parser->buffer)) break;
+
+ /* Consume the line break. */
+
+ if (!CACHE(parser, 2)) return 0;
+ if (!READ_LINE(parser, *breaks)) return 0;
+ *end_mark = parser->mark;
+ }
+
+ /* Determine the indentation level if needed. */
+
+ if (!*indent) {
+ *indent = max_indent;
+ if (*indent < parser->indent + 1)
+ *indent = parser->indent + 1;
+ if (*indent < 1)
+ *indent = 1;
+ }
+
+ return 1;
+}
+
+/*
+ * Scan a quoted scalar.
+ */
+
+static int
+yaml_parser_scan_flow_scalar(yaml_parser_t *parser, yaml_token_t *token,
+ int single)
+{
+ yaml_mark_t start_mark;
+ yaml_mark_t end_mark;
+ yaml_string_t string = NULL_STRING;
+ yaml_string_t leading_break = NULL_STRING;
+ yaml_string_t trailing_breaks = NULL_STRING;
+ yaml_string_t whitespaces = NULL_STRING;
+ int leading_blanks;
+
+ if (!STRING_INIT(parser, string, INITIAL_STRING_SIZE)) goto error;
+ if (!STRING_INIT(parser, leading_break, INITIAL_STRING_SIZE)) goto error;
+ if (!STRING_INIT(parser, trailing_breaks, INITIAL_STRING_SIZE)) goto error;
+ if (!STRING_INIT(parser, whitespaces, INITIAL_STRING_SIZE)) goto error;
+
+ /* Eat the left quote. */
+
+ start_mark = parser->mark;
+
+ SKIP(parser);
+
+ /* Consume the content of the quoted scalar. */
+
+ while (1)
+ {
+ /* Check that there are no document indicators at the beginning of the line. */
+
+ if (!CACHE(parser, 4)) goto error;
+
+ if (parser->mark.column == 0 &&
+ ((CHECK_AT(parser->buffer, '-', 0) &&
+ CHECK_AT(parser->buffer, '-', 1) &&
+ CHECK_AT(parser->buffer, '-', 2)) ||
+ (CHECK_AT(parser->buffer, '.', 0) &&
+ CHECK_AT(parser->buffer, '.', 1) &&
+ CHECK_AT(parser->buffer, '.', 2))) &&
+ IS_BLANKZ_AT(parser->buffer, 3))
+ {
+ yaml_parser_set_scanner_error(parser, "while scanning a quoted scalar",
+ start_mark, "found unexpected document indicator");
+ goto error;
+ }
+
+ /* Check for EOF. */
+
+ if (IS_Z(parser->buffer)) {
+ yaml_parser_set_scanner_error(parser, "while scanning a quoted scalar",
+ start_mark, "found unexpected end of stream");
+ goto error;
+ }
+
+ /* Consume non-blank characters. */
+
+ if (!CACHE(parser, 2)) goto error;
+
+ leading_blanks = 0;
+
+ while (!IS_BLANKZ(parser->buffer))
+ {
+ /* Check for an escaped single quote. */
+
+ if (single && CHECK_AT(parser->buffer, '\'', 0)
+ && CHECK_AT(parser->buffer, '\'', 1))
+ {
+ if (!STRING_EXTEND(parser, string)) goto error;
+ *(string.pointer++) = '\'';
+ SKIP(parser);
+ SKIP(parser);
+ }
+
+ /* Check for the right quote. */
+
+ else if (CHECK(parser->buffer, single ? '\'' : '"'))
+ {
+ break;
+ }
+
+ /* Check for an escaped line break. */
+
+ else if (!single && CHECK(parser->buffer, '\\')
+ && IS_BREAK_AT(parser->buffer, 1))
+ {
+ if (!CACHE(parser, 3)) goto error;
+ SKIP(parser);
+ SKIP_LINE(parser);
+ leading_blanks = 1;
+ break;
+ }
+
+ /* Check for an escape sequence. */
+
+ else if (!single && CHECK(parser->buffer, '\\'))
+ {
+ size_t code_length = 0;
+
+ if (!STRING_EXTEND(parser, string)) goto error;
+
+ /* Check the escape character. */
+
+ switch (parser->buffer.pointer[1])
+ {
+ case '0':
+ *(string.pointer++) = '\0';
+ break;
+
+ case 'a':
+ *(string.pointer++) = '\x07';
+ break;
+
+ case 'b':
+ *(string.pointer++) = '\x08';
+ break;
+
+ case 't':
+ case '\t':
+ *(string.pointer++) = '\x09';
+ break;
+
+ case 'n':
+ *(string.pointer++) = '\x0A';
+ break;
+
+ case 'v':
+ *(string.pointer++) = '\x0B';
+ break;
+
+ case 'f':
+ *(string.pointer++) = '\x0C';
+ break;
+
+ case 'r':
+ *(string.pointer++) = '\x0D';
+ break;
+
+ case 'e':
+ *(string.pointer++) = '\x1B';
+ break;
+
+ case ' ':
+ *(string.pointer++) = '\x20';
+ break;
+
+ case '"':
+ *(string.pointer++) = '"';
+ break;
+
+ case '\'':
+ *(string.pointer++) = '\'';
+ break;
+
+ case '\\':
+ *(string.pointer++) = '\\';
+ break;
+
+ case 'N': /* NEL (#x85) */
+ *(string.pointer++) = '\xC2';
+ *(string.pointer++) = '\x85';
+ break;
+
+ case '_': /* #xA0 */
+ *(string.pointer++) = '\xC2';
+ *(string.pointer++) = '\xA0';
+ break;
+
+ case 'L': /* LS (#x2028) */
+ *(string.pointer++) = '\xE2';
+ *(string.pointer++) = '\x80';
+ *(string.pointer++) = '\xA8';
+ break;
+
+ case 'P': /* PS (#x2029) */
+ *(string.pointer++) = '\xE2';
+ *(string.pointer++) = '\x80';
+ *(string.pointer++) = '\xA9';
+ break;
+
+ case 'x':
+ code_length = 2;
+ break;
+
+ case 'u':
+ code_length = 4;
+ break;
+
+ case 'U':
+ code_length = 8;
+ break;
+
+ default:
+ yaml_parser_set_scanner_error(parser, "while parsing a quoted scalar",
+ start_mark, "found unknown escape character");
+ goto error;
+ }
+
+ SKIP(parser);
+ SKIP(parser);
+
+ /* Consume an arbitrary escape code. */
+
+ if (code_length)
+ {
+ unsigned int value = 0;
+ size_t k;
+
+ /* Scan the character value. */
+
+ if (!CACHE(parser, code_length)) goto error;
+
+ for (k = 0; k < code_length; k ++) {
+ if (!IS_HEX_AT(parser->buffer, k)) {
+ yaml_parser_set_scanner_error(parser, "while parsing a quoted scalar",
+ start_mark, "did not find expected hexdecimal number");
+ goto error;
+ }
+ value = (value << 4) + AS_HEX_AT(parser->buffer, k);
+ }
+
+ /* Check the value and write the character. */
+
+ if ((value >= 0xD800 && value <= 0xDFFF) || value > 0x10FFFF) {
+ yaml_parser_set_scanner_error(parser, "while parsing a quoted scalar",
+ start_mark, "found invalid Unicode character escape code");
+ goto error;
+ }
+
+ if (value <= 0x7F) {
+ *(string.pointer++) = value;
+ }
+ else if (value <= 0x7FF) {
+ *(string.pointer++) = 0xC0 + (value >> 6);
+ *(string.pointer++) = 0x80 + (value & 0x3F);
+ }
+ else if (value <= 0xFFFF) {
+ *(string.pointer++) = 0xE0 + (value >> 12);
+ *(string.pointer++) = 0x80 + ((value >> 6) & 0x3F);
+ *(string.pointer++) = 0x80 + (value & 0x3F);
+ }
+ else {
+ *(string.pointer++) = 0xF0 + (value >> 18);
+ *(string.pointer++) = 0x80 + ((value >> 12) & 0x3F);
+ *(string.pointer++) = 0x80 + ((value >> 6) & 0x3F);
+ *(string.pointer++) = 0x80 + (value & 0x3F);
+ }
+
+ /* Advance the pointer. */
+
+ for (k = 0; k < code_length; k ++) {
+ SKIP(parser);
+ }
+ }
+ }
+
+ else
+ {
+ /* It is a non-escaped non-blank character. */
+
+ if (!READ(parser, string)) goto error;
+ }
+
+ if (!CACHE(parser, 2)) goto error;
+ }
+
+ /* Check if we are at the end of the scalar. */
+
+ if (CHECK(parser->buffer, single ? '\'' : '"'))
+ break;
+
+ /* Consume blank characters. */
+
+ if (!CACHE(parser, 1)) goto error;
+
+ while (IS_BLANK(parser->buffer) || IS_BREAK(parser->buffer))
+ {
+ if (IS_BLANK(parser->buffer))
+ {
+ /* Consume a space or a tab character. */
+
+ if (!leading_blanks) {
+ if (!READ(parser, whitespaces)) goto error;
+ }
+ else {
+ SKIP(parser);
+ }
+ }
+ else
+ {
+ if (!CACHE(parser, 2)) goto error;
+
+ /* Check if it is a first line break. */
+
+ if (!leading_blanks)
+ {
+ CLEAR(parser, whitespaces);
+ if (!READ_LINE(parser, leading_break)) goto error;
+ leading_blanks = 1;
+ }
+ else
+ {
+ if (!READ_LINE(parser, trailing_breaks)) goto error;
+ }
+ }
+ if (!CACHE(parser, 1)) goto error;
+ }
+
+ /* Join the whitespaces or fold line breaks. */
+
+ if (leading_blanks)
+ {
+ /* Do we need to fold line breaks? */
+
+ if (leading_break.start[0] == '\n') {
+ if (trailing_breaks.start[0] == '\0') {
+ if (!STRING_EXTEND(parser, string)) goto error;
+ *(string.pointer++) = ' ';
+ }
+ else {
+ if (!JOIN(parser, string, trailing_breaks)) goto error;
+ CLEAR(parser, trailing_breaks);
+ }
+ CLEAR(parser, leading_break);
+ }
+ else {
+ if (!JOIN(parser, string, leading_break)) goto error;
+ if (!JOIN(parser, string, trailing_breaks)) goto error;
+ CLEAR(parser, leading_break);
+ CLEAR(parser, trailing_breaks);
+ }
+ }
+ else
+ {
+ if (!JOIN(parser, string, whitespaces)) goto error;
+ CLEAR(parser, whitespaces);
+ }
+ }
+
+ /* Eat the right quote. */
+
+ SKIP(parser);
+
+ end_mark = parser->mark;
+
+ /* Create a token. */
+
+ SCALAR_TOKEN_INIT(*token, string.start, string.pointer-string.start,
+ single ? YAML_SINGLE_QUOTED_SCALAR_STYLE : YAML_DOUBLE_QUOTED_SCALAR_STYLE,
+ start_mark, end_mark);
+
+ STRING_DEL(parser, leading_break);
+ STRING_DEL(parser, trailing_breaks);
+ STRING_DEL(parser, whitespaces);
+
+ return 1;
+
+error:
+ STRING_DEL(parser, string);
+ STRING_DEL(parser, leading_break);
+ STRING_DEL(parser, trailing_breaks);
+ STRING_DEL(parser, whitespaces);
+
+ return 0;
+}
+
+/*
+ * Scan a plain scalar.
+ */
+
+static int
+yaml_parser_scan_plain_scalar(yaml_parser_t *parser, yaml_token_t *token)
+{
+ yaml_mark_t start_mark;
+ yaml_mark_t end_mark;
+ yaml_string_t string = NULL_STRING;
+ yaml_string_t leading_break = NULL_STRING;
+ yaml_string_t trailing_breaks = NULL_STRING;
+ yaml_string_t whitespaces = NULL_STRING;
+ int leading_blanks = 0;
+ int indent = parser->indent+1;
+
+ if (!STRING_INIT(parser, string, INITIAL_STRING_SIZE)) goto error;
+ if (!STRING_INIT(parser, leading_break, INITIAL_STRING_SIZE)) goto error;
+ if (!STRING_INIT(parser, trailing_breaks, INITIAL_STRING_SIZE)) goto error;
+ if (!STRING_INIT(parser, whitespaces, INITIAL_STRING_SIZE)) goto error;
+
+ start_mark = end_mark = parser->mark;
+
+ /* Consume the content of the plain scalar. */
+
+ while (1)
+ {
+ /* Check for a document indicator. */
+
+ if (!CACHE(parser, 4)) goto error;
+
+ if (parser->mark.column == 0 &&
+ ((CHECK_AT(parser->buffer, '-', 0) &&
+ CHECK_AT(parser->buffer, '-', 1) &&
+ CHECK_AT(parser->buffer, '-', 2)) ||
+ (CHECK_AT(parser->buffer, '.', 0) &&
+ CHECK_AT(parser->buffer, '.', 1) &&
+ CHECK_AT(parser->buffer, '.', 2))) &&
+ IS_BLANKZ_AT(parser->buffer, 3)) break;
+
+ /* Check for a comment. */
+
+ if (CHECK(parser->buffer, '#'))
+ break;
+
+ /* Consume non-blank characters. */
+
+ while (!IS_BLANKZ(parser->buffer))
+ {
+ /* Check for 'x:x' in the flow context. TODO: Fix the test "spec-08-13". */
+
+ if (parser->flow_level
+ && CHECK(parser->buffer, ':')
+ && !IS_BLANKZ_AT(parser->buffer, 1)) {
+ yaml_parser_set_scanner_error(parser, "while scanning a plain scalar",
+ start_mark, "found unexpected ':'");
+ goto error;
+ }
+
+ /* Check for indicators that may end a plain scalar. */
+
+ if ((CHECK(parser->buffer, ':') && IS_BLANKZ_AT(parser->buffer, 1))
+ || (parser->flow_level &&
+ (CHECK(parser->buffer, ',') || CHECK(parser->buffer, ':')
+ || CHECK(parser->buffer, '?') || CHECK(parser->buffer, '[')
+ || CHECK(parser->buffer, ']') || CHECK(parser->buffer, '{')
+ || CHECK(parser->buffer, '}'))))
+ break;
+
+ /* Check if we need to join whitespaces and breaks. */
+
+ if (leading_blanks || whitespaces.start != whitespaces.pointer)
+ {
+ if (leading_blanks)
+ {
+ /* Do we need to fold line breaks? */
+
+ if (leading_break.start[0] == '\n') {
+ if (trailing_breaks.start[0] == '\0') {
+ if (!STRING_EXTEND(parser, string)) goto error;
+ *(string.pointer++) = ' ';
+ }
+ else {
+ if (!JOIN(parser, string, trailing_breaks)) goto error;
+ CLEAR(parser, trailing_breaks);
+ }
+ CLEAR(parser, leading_break);
+ }
+ else {
+ if (!JOIN(parser, string, leading_break)) goto error;
+ if (!JOIN(parser, string, trailing_breaks)) goto error;
+ CLEAR(parser, leading_break);
+ CLEAR(parser, trailing_breaks);
+ }
+
+ leading_blanks = 0;
+ }
+ else
+ {
+ if (!JOIN(parser, string, whitespaces)) goto error;
+ CLEAR(parser, whitespaces);
+ }
+ }
+
+ /* Copy the character. */
+
+ if (!READ(parser, string)) goto error;
+
+ end_mark = parser->mark;
+
+ if (!CACHE(parser, 2)) goto error;
+ }
+
+ /* Is it the end? */
+
+ if (!(IS_BLANK(parser->buffer) || IS_BREAK(parser->buffer)))
+ break;
+
+ /* Consume blank characters. */
+
+ if (!CACHE(parser, 1)) goto error;
+
+ while (IS_BLANK(parser->buffer) || IS_BREAK(parser->buffer))
+ {
+ if (IS_BLANK(parser->buffer))
+ {
+ /* Check for tab character that abuse intendation. */
+
+ if (leading_blanks && (int)parser->mark.column < indent
+ && IS_TAB(parser->buffer)) {
+ yaml_parser_set_scanner_error(parser, "while scanning a plain scalar",
+ start_mark, "found a tab character that violate intendation");
+ goto error;
+ }
+
+ /* Consume a space or a tab character. */
+
+ if (!leading_blanks) {
+ if (!READ(parser, whitespaces)) goto error;
+ }
+ else {
+ SKIP(parser);
+ }
+ }
+ else
+ {
+ if (!CACHE(parser, 2)) goto error;
+
+ /* Check if it is a first line break. */
+
+ if (!leading_blanks)
+ {
+ CLEAR(parser, whitespaces);
+ if (!READ_LINE(parser, leading_break)) goto error;
+ leading_blanks = 1;
+ }
+ else
+ {
+ if (!READ_LINE(parser, trailing_breaks)) goto error;
+ }
+ }
+ if (!CACHE(parser, 1)) goto error;
+ }
+
+ /* Check intendation level. */
+
+ if (!parser->flow_level && (int)parser->mark.column < indent)
+ break;
+ }
+
+ /* Create a token. */
+
+ SCALAR_TOKEN_INIT(*token, string.start, string.pointer-string.start,
+ YAML_PLAIN_SCALAR_STYLE, start_mark, end_mark);
+
+ /* Note that we change the 'simple_key_allowed' flag. */
+
+ if (leading_blanks) {
+ parser->simple_key_allowed = 1;
+ }
+
+ STRING_DEL(parser, leading_break);
+ STRING_DEL(parser, trailing_breaks);
+ STRING_DEL(parser, whitespaces);
+
+ return 1;
+
+error:
+ STRING_DEL(parser, string);
+ STRING_DEL(parser, leading_break);
+ STRING_DEL(parser, trailing_breaks);
+ STRING_DEL(parser, whitespaces);
+
+ return 0;
+}
+
diff --git a/jni/ruby/ext/psych/yaml/writer.c b/jni/ruby/ext/psych/yaml/writer.c
new file mode 100644
index 0000000..5d57f39
--- /dev/null
+++ b/jni/ruby/ext/psych/yaml/writer.c
@@ -0,0 +1,141 @@
+
+#include "yaml_private.h"
+
+/*
+ * Declarations.
+ */
+
+static int
+yaml_emitter_set_writer_error(yaml_emitter_t *emitter, const char *problem);
+
+YAML_DECLARE(int)
+yaml_emitter_flush(yaml_emitter_t *emitter);
+
+/*
+ * Set the writer error and return 0.
+ */
+
+static int
+yaml_emitter_set_writer_error(yaml_emitter_t *emitter, const char *problem)
+{
+ emitter->error = YAML_WRITER_ERROR;
+ emitter->problem = problem;
+
+ return 0;
+}
+
+/*
+ * Flush the output buffer.
+ */
+
+YAML_DECLARE(int)
+yaml_emitter_flush(yaml_emitter_t *emitter)
+{
+ int low, high;
+
+ assert(emitter); /* Non-NULL emitter object is expected. */
+ assert(emitter->write_handler); /* Write handler must be set. */
+ assert(emitter->encoding); /* Output encoding must be set. */
+
+ emitter->buffer.last = emitter->buffer.pointer;
+ emitter->buffer.pointer = emitter->buffer.start;
+
+ /* Check if the buffer is empty. */
+
+ if (emitter->buffer.start == emitter->buffer.last) {
+ return 1;
+ }
+
+ /* If the output encoding is UTF-8, we don't need to recode the buffer. */
+
+ if (emitter->encoding == YAML_UTF8_ENCODING)
+ {
+ if (emitter->write_handler(emitter->write_handler_data,
+ emitter->buffer.start,
+ emitter->buffer.last - emitter->buffer.start)) {
+ emitter->buffer.last = emitter->buffer.start;
+ emitter->buffer.pointer = emitter->buffer.start;
+ return 1;
+ }
+ else {
+ return yaml_emitter_set_writer_error(emitter, "write error");
+ }
+ }
+
+ /* Recode the buffer into the raw buffer. */
+
+ low = (emitter->encoding == YAML_UTF16LE_ENCODING ? 0 : 1);
+ high = (emitter->encoding == YAML_UTF16LE_ENCODING ? 1 : 0);
+
+ while (emitter->buffer.pointer != emitter->buffer.last)
+ {
+ unsigned char octet;
+ unsigned int width;
+ unsigned int value;
+ size_t k;
+
+ /*
+ * See the "reader.c" code for more details on UTF-8 encoding. Note
+ * that we assume that the buffer contains a valid UTF-8 sequence.
+ */
+
+ /* Read the next UTF-8 character. */
+
+ octet = emitter->buffer.pointer[0];
+
+ width = (octet & 0x80) == 0x00 ? 1 :
+ (octet & 0xE0) == 0xC0 ? 2 :
+ (octet & 0xF0) == 0xE0 ? 3 :
+ (octet & 0xF8) == 0xF0 ? 4 : 0;
+
+ value = (octet & 0x80) == 0x00 ? octet & 0x7F :
+ (octet & 0xE0) == 0xC0 ? octet & 0x1F :
+ (octet & 0xF0) == 0xE0 ? octet & 0x0F :
+ (octet & 0xF8) == 0xF0 ? octet & 0x07 : 0;
+
+ for (k = 1; k < width; k ++) {
+ octet = emitter->buffer.pointer[k];
+ value = (value << 6) + (octet & 0x3F);
+ }
+
+ emitter->buffer.pointer += width;
+
+ /* Write the character. */
+
+ if (value < 0x10000)
+ {
+ emitter->raw_buffer.last[high] = value >> 8;
+ emitter->raw_buffer.last[low] = value & 0xFF;
+
+ emitter->raw_buffer.last += 2;
+ }
+ else
+ {
+ /* Write the character using a surrogate pair (check "reader.c"). */
+
+ value -= 0x10000;
+ emitter->raw_buffer.last[high] = 0xD8 + (value >> 18);
+ emitter->raw_buffer.last[low] = (value >> 10) & 0xFF;
+ emitter->raw_buffer.last[high+2] = 0xDC + ((value >> 8) & 0xFF);
+ emitter->raw_buffer.last[low+2] = value & 0xFF;
+
+ emitter->raw_buffer.last += 4;
+ }
+ }
+
+ /* Write the raw buffer. */
+
+ if (emitter->write_handler(emitter->write_handler_data,
+ emitter->raw_buffer.start,
+ emitter->raw_buffer.last - emitter->raw_buffer.start)) {
+ emitter->buffer.last = emitter->buffer.start;
+ emitter->buffer.pointer = emitter->buffer.start;
+ emitter->raw_buffer.last = emitter->raw_buffer.start;
+ emitter->raw_buffer.pointer = emitter->raw_buffer.start;
+ return 1;
+ }
+ else {
+ return yaml_emitter_set_writer_error(emitter, "write error");
+ }
+}
+
diff --git a/jni/ruby/ext/psych/yaml/yaml.h b/jni/ruby/ext/psych/yaml/yaml.h
new file mode 100644
index 0000000..f33a152
--- /dev/null
+++ b/jni/ruby/ext/psych/yaml/yaml.h
@@ -0,0 +1,1971 @@
+/**
+ * @file yaml.h
+ * @brief Public interface for libyaml.
+ *
+ * Include the header file with the code:
+ * @code
+ * #include <yaml.h>
+ * @endcode
+ */
+
+#ifndef YAML_H
+#define YAML_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+
+/**
+ * @defgroup export Export Definitions
+ * @{
+ */
+
+/** The public API declaration. */
+
+#ifdef _WIN32
+# if defined(YAML_DECLARE_STATIC)
+# define YAML_DECLARE(type) type
+# elif defined(YAML_DECLARE_EXPORT)
+# define YAML_DECLARE(type) __declspec(dllexport) type
+# else
+# define YAML_DECLARE(type) __declspec(dllimport) type
+# endif
+#else
+# define YAML_DECLARE(type) type
+#endif
+
+/** @} */
+
+/**
+ * @defgroup version Version Information
+ * @{
+ */
+
+/**
+ * Get the library version as a string.
+ *
+ * @returns The function returns the pointer to a static string of the form
+ * @c "X.Y.Z", where @c X is the major version number, @c Y is a minor version
+ * number, and @c Z is the patch version number.
+ */
+
+YAML_DECLARE(const char *)
+yaml_get_version_string(void);
+
+/**
+ * Get the library version numbers.
+ *
+ * @param[out] major Major version number.
+ * @param[out] minor Minor version number.
+ * @param[out] patch Patch version number.
+ */
+
+YAML_DECLARE(void)
+yaml_get_version(int *major, int *minor, int *patch);
+
+/** @} */
+
+/**
+ * @defgroup basic Basic Types
+ * @{
+ */
+
+/** The character type (UTF-8 octet). */
+typedef unsigned char yaml_char_t;
+
+/** The version directive data. */
+typedef struct yaml_version_directive_s {
+ /** The major version number. */
+ int major;
+ /** The minor version number. */
+ int minor;
+} yaml_version_directive_t;
+
+/** The tag directive data. */
+typedef struct yaml_tag_directive_s {
+ /** The tag handle. */
+ yaml_char_t *handle;
+ /** The tag prefix. */
+ yaml_char_t *prefix;
+} yaml_tag_directive_t;
+
+/** The stream encoding. */
+typedef enum yaml_encoding_e {
+ /** Let the parser choose the encoding. */
+ YAML_ANY_ENCODING,
+ /** The default UTF-8 encoding. */
+ YAML_UTF8_ENCODING,
+ /** The UTF-16-LE encoding with BOM. */
+ YAML_UTF16LE_ENCODING,
+ /** The UTF-16-BE encoding with BOM. */
+ YAML_UTF16BE_ENCODING
+} yaml_encoding_t;
+
+/** Line break types. */
+
+typedef enum yaml_break_e {
+ /** Let the parser choose the break type. */
+ YAML_ANY_BREAK,
+ /** Use CR for line breaks (Mac style). */
+ YAML_CR_BREAK,
+ /** Use LN for line breaks (Unix style). */
+ YAML_LN_BREAK,
+ /** Use CR LN for line breaks (DOS style). */
+ YAML_CRLN_BREAK
+} yaml_break_t;
+
+/** Many bad things could happen with the parser and emitter. */
+typedef enum yaml_error_type_e {
+ /** No error is produced. */
+ YAML_NO_ERROR,
+
+ /** Cannot allocate or reallocate a block of memory. */
+ YAML_MEMORY_ERROR,
+
+ /** Cannot read or decode the input stream. */
+ YAML_READER_ERROR,
+ /** Cannot scan the input stream. */
+ YAML_SCANNER_ERROR,
+ /** Cannot parse the input stream. */
+ YAML_PARSER_ERROR,
+ /** Cannot compose a YAML document. */
+ YAML_COMPOSER_ERROR,
+
+ /** Cannot write to the output stream. */
+ YAML_WRITER_ERROR,
+ /** Cannot emit a YAML stream. */
+ YAML_EMITTER_ERROR
+} yaml_error_type_t;
+
+/** The pointer position. */
+typedef struct yaml_mark_s {
+ /** The position index. */
+ size_t index;
+
+ /** The position line. */
+ size_t line;
+
+ /** The position column. */
+ size_t column;
+} yaml_mark_t;
+
+/** @} */
+
+/**
+ * @defgroup styles Node Styles
+ * @{
+ */
+
+/** Scalar styles. */
+typedef enum yaml_scalar_style_e {
+ /** Let the emitter choose the style. */
+ YAML_ANY_SCALAR_STYLE,
+
+ /** The plain scalar style. */
+ YAML_PLAIN_SCALAR_STYLE,
+
+ /** The single-quoted scalar style. */
+ YAML_SINGLE_QUOTED_SCALAR_STYLE,
+ /** The double-quoted scalar style. */
+ YAML_DOUBLE_QUOTED_SCALAR_STYLE,
+
+ /** The literal scalar style. */
+ YAML_LITERAL_SCALAR_STYLE,
+ /** The folded scalar style. */
+ YAML_FOLDED_SCALAR_STYLE
+} yaml_scalar_style_t;
+
+/** Sequence styles. */
+typedef enum yaml_sequence_style_e {
+ /** Let the emitter choose the style. */
+ YAML_ANY_SEQUENCE_STYLE,
+
+ /** The block sequence style. */
+ YAML_BLOCK_SEQUENCE_STYLE,
+ /** The flow sequence style. */
+ YAML_FLOW_SEQUENCE_STYLE
+} yaml_sequence_style_t;
+
+/** Mapping styles. */
+typedef enum yaml_mapping_style_e {
+ /** Let the emitter choose the style. */
+ YAML_ANY_MAPPING_STYLE,
+
+ /** The block mapping style. */
+ YAML_BLOCK_MAPPING_STYLE,
+ /** The flow mapping style. */
+ YAML_FLOW_MAPPING_STYLE
+/* YAML_FLOW_SET_MAPPING_STYLE */
+} yaml_mapping_style_t;
+
+/** @} */
+
+/**
+ * @defgroup tokens Tokens
+ * @{
+ */
+
+/** Token types. */
+typedef enum yaml_token_type_e {
+ /** An empty token. */
+ YAML_NO_TOKEN,
+
+ /** A STREAM-START token. */
+ YAML_STREAM_START_TOKEN,
+ /** A STREAM-END token. */
+ YAML_STREAM_END_TOKEN,
+
+ /** A VERSION-DIRECTIVE token. */
+ YAML_VERSION_DIRECTIVE_TOKEN,
+ /** A TAG-DIRECTIVE token. */
+ YAML_TAG_DIRECTIVE_TOKEN,
+ /** A DOCUMENT-START token. */
+ YAML_DOCUMENT_START_TOKEN,
+ /** A DOCUMENT-END token. */
+ YAML_DOCUMENT_END_TOKEN,
+
+ /** A BLOCK-SEQUENCE-START token. */
+ YAML_BLOCK_SEQUENCE_START_TOKEN,
+ /** A BLOCK-SEQUENCE-END token. */
+ YAML_BLOCK_MAPPING_START_TOKEN,
+ /** A BLOCK-END token. */
+ YAML_BLOCK_END_TOKEN,
+
+ /** A FLOW-SEQUENCE-START token. */
+ YAML_FLOW_SEQUENCE_START_TOKEN,
+ /** A FLOW-SEQUENCE-END token. */
+ YAML_FLOW_SEQUENCE_END_TOKEN,
+ /** A FLOW-MAPPING-START token. */
+ YAML_FLOW_MAPPING_START_TOKEN,
+ /** A FLOW-MAPPING-END token. */
+ YAML_FLOW_MAPPING_END_TOKEN,
+
+ /** A BLOCK-ENTRY token. */
+ YAML_BLOCK_ENTRY_TOKEN,
+ /** A FLOW-ENTRY token. */
+ YAML_FLOW_ENTRY_TOKEN,
+ /** A KEY token. */
+ YAML_KEY_TOKEN,
+ /** A VALUE token. */
+ YAML_VALUE_TOKEN,
+
+ /** An ALIAS token. */
+ YAML_ALIAS_TOKEN,
+ /** An ANCHOR token. */
+ YAML_ANCHOR_TOKEN,
+ /** A TAG token. */
+ YAML_TAG_TOKEN,
+ /** A SCALAR token. */
+ YAML_SCALAR_TOKEN
+} yaml_token_type_t;
+
+/** The token structure. */
+typedef struct yaml_token_s {
+
+ /** The token type. */
+ yaml_token_type_t type;
+
+ /** The token data. */
+ union {
+
+ /** The stream start (for @c YAML_STREAM_START_TOKEN). */
+ struct {
+ /** The stream encoding. */
+ yaml_encoding_t encoding;
+ } stream_start;
+
+ /** The alias (for @c YAML_ALIAS_TOKEN). */
+ struct {
+ /** The alias value. */
+ yaml_char_t *value;
+ } alias;
+
+ /** The anchor (for @c YAML_ANCHOR_TOKEN). */
+ struct {
+ /** The anchor value. */
+ yaml_char_t *value;
+ } anchor;
+
+ /** The tag (for @c YAML_TAG_TOKEN). */
+ struct {
+ /** The tag handle. */
+ yaml_char_t *handle;
+ /** The tag suffix. */
+ yaml_char_t *suffix;
+ } tag;
+
+ /** The scalar value (for @c YAML_SCALAR_TOKEN). */
+ struct {
+ /** The scalar value. */
+ yaml_char_t *value;
+ /** The length of the scalar value. */
+ size_t length;
+ /** The scalar style. */
+ yaml_scalar_style_t style;
+ } scalar;
+
+ /** The version directive (for @c YAML_VERSION_DIRECTIVE_TOKEN). */
+ struct {
+ /** The major version number. */
+ int major;
+ /** The minor version number. */
+ int minor;
+ } version_directive;
+
+ /** The tag directive (for @c YAML_TAG_DIRECTIVE_TOKEN). */
+ struct {
+ /** The tag handle. */
+ yaml_char_t *handle;
+ /** The tag prefix. */
+ yaml_char_t *prefix;
+ } tag_directive;
+
+ } data;
+
+ /** The beginning of the token. */
+ yaml_mark_t start_mark;
+ /** The end of the token. */
+ yaml_mark_t end_mark;
+
+} yaml_token_t;
+
+/**
+ * Free any memory allocated for a token object.
+ *
+ * @param[in,out] token A token object.
+ */
+
+YAML_DECLARE(void)
+yaml_token_delete(yaml_token_t *token);
+
+/** @} */
+
+/**
+ * @defgroup events Events
+ * @{
+ */
+
+/** Event types. */
+typedef enum yaml_event_type_e {
+ /** An empty event. */
+ YAML_NO_EVENT,
+
+ /** A STREAM-START event. */
+ YAML_STREAM_START_EVENT,
+ /** A STREAM-END event. */
+ YAML_STREAM_END_EVENT,
+
+ /** A DOCUMENT-START event. */
+ YAML_DOCUMENT_START_EVENT,
+ /** A DOCUMENT-END event. */
+ YAML_DOCUMENT_END_EVENT,
+
+ /** An ALIAS event. */
+ YAML_ALIAS_EVENT,
+ /** A SCALAR event. */
+ YAML_SCALAR_EVENT,
+
+ /** A SEQUENCE-START event. */
+ YAML_SEQUENCE_START_EVENT,
+ /** A SEQUENCE-END event. */
+ YAML_SEQUENCE_END_EVENT,
+
+ /** A MAPPING-START event. */
+ YAML_MAPPING_START_EVENT,
+ /** A MAPPING-END event. */
+ YAML_MAPPING_END_EVENT
+} yaml_event_type_t;
+
+/** The event structure. */
+typedef struct yaml_event_s {
+
+ /** The event type. */
+ yaml_event_type_t type;
+
+ /** The event data. */
+ union {
+
+ /** The stream parameters (for @c YAML_STREAM_START_EVENT). */
+ struct {
+ /** The document encoding. */
+ yaml_encoding_t encoding;
+ } stream_start;
+
+ /** The document parameters (for @c YAML_DOCUMENT_START_EVENT). */
+ struct {
+ /** The version directive. */
+ yaml_version_directive_t *version_directive;
+
+ /** The list of tag directives. */
+ struct {
+ /** The beginning of the tag directives list. */
+ yaml_tag_directive_t *start;
+ /** The end of the tag directives list. */
+ yaml_tag_directive_t *end;
+ } tag_directives;
+
+ /** Is the document indicator implicit? */
+ int implicit;
+ } document_start;
+
+ /** The document end parameters (for @c YAML_DOCUMENT_END_EVENT). */
+ struct {
+ /** Is the document end indicator implicit? */
+ int implicit;
+ } document_end;
+
+ /** The alias parameters (for @c YAML_ALIAS_EVENT). */
+ struct {
+ /** The anchor. */
+ yaml_char_t *anchor;
+ } alias;
+
+ /** The scalar parameters (for @c YAML_SCALAR_EVENT). */
+ struct {
+ /** The anchor. */
+ yaml_char_t *anchor;
+ /** The tag. */
+ yaml_char_t *tag;
+ /** The scalar value. */
+ yaml_char_t *value;
+ /** The length of the scalar value. */
+ size_t length;
+ /** Is the tag optional for the plain style? */
+ int plain_implicit;
+ /** Is the tag optional for any non-plain style? */
+ int quoted_implicit;
+ /** The scalar style. */
+ yaml_scalar_style_t style;
+ } scalar;
+
+ /** The sequence parameters (for @c YAML_SEQUENCE_START_EVENT). */
+ struct {
+ /** The anchor. */
+ yaml_char_t *anchor;
+ /** The tag. */
+ yaml_char_t *tag;
+ /** Is the tag optional? */
+ int implicit;
+ /** The sequence style. */
+ yaml_sequence_style_t style;
+ } sequence_start;
+
+ /** The mapping parameters (for @c YAML_MAPPING_START_EVENT). */
+ struct {
+ /** The anchor. */
+ yaml_char_t *anchor;
+ /** The tag. */
+ yaml_char_t *tag;
+ /** Is the tag optional? */
+ int implicit;
+ /** The mapping style. */
+ yaml_mapping_style_t style;
+ } mapping_start;
+
+ } data;
+
+ /** The beginning of the event. */
+ yaml_mark_t start_mark;
+ /** The end of the event. */
+ yaml_mark_t end_mark;
+
+} yaml_event_t;
+
+/**
+ * Create the STREAM-START event.
+ *
+ * @param[out] event An empty event object.
+ * @param[in] encoding The stream encoding.
+ *
+ * @returns @c 1 if the function succeeded, @c 0 on error.
+ */
+
+YAML_DECLARE(int)
+yaml_stream_start_event_initialize(yaml_event_t *event,
+ yaml_encoding_t encoding);
+
+/**
+ * Create the STREAM-END event.
+ *
+ * @param[out] event An empty event object.
+ *
+ * @returns @c 1 if the function succeeded, @c 0 on error.
+ */
+
+YAML_DECLARE(int)
+yaml_stream_end_event_initialize(yaml_event_t *event);
+
+/**
+ * Create the DOCUMENT-START event.
+ *
+ * The @a implicit argument is considered as a stylistic parameter and may be
+ * ignored by the emitter.
+ *
+ * @param[out] event An empty event object.
+ * @param[in] version_directive The %YAML directive value or
+ * @c NULL.
+ * @param[in] tag_directives_start The beginning of the %TAG
+ * directives list.
+ * @param[in] tag_directives_end The end of the %TAG directives
+ * list.
+ * @param[in] implicit If the document start indicator is
+ * implicit.
+ *
+ * @returns @c 1 if the function succeeded, @c 0 on error.
+ */
+
+YAML_DECLARE(int)
+yaml_document_start_event_initialize(yaml_event_t *event,
+ yaml_version_directive_t *version_directive,
+ yaml_tag_directive_t *tag_directives_start,
+ yaml_tag_directive_t *tag_directives_end,
+ int implicit);
+
+/**
+ * Create the DOCUMENT-END event.
+ *
+ * The @a implicit argument is considered as a stylistic parameter and may be
+ * ignored by the emitter.
+ *
+ * @param[out] event An empty event object.
+ * @param[in] implicit If the document end indicator is implicit.
+ *
+ * @returns @c 1 if the function succeeded, @c 0 on error.
+ */
+
+YAML_DECLARE(int)
+yaml_document_end_event_initialize(yaml_event_t *event, int implicit);
+
+/**
+ * Create an ALIAS event.
+ *
+ * @param[out] event An empty event object.
+ * @param[in] anchor The anchor value.
+ *
+ * @returns @c 1 if the function succeeded, @c 0 on error.
+ */
+
+YAML_DECLARE(int)
+yaml_alias_event_initialize(yaml_event_t *event, yaml_char_t *anchor);
+
+/**
+ * Create a SCALAR event.
+ *
+ * The @a style argument may be ignored by the emitter.
+ *
+ * Either the @a tag attribute or one of the @a plain_implicit and
+ * @a quoted_implicit flags must be set.
+ *
+ * @param[out] event An empty event object.
+ * @param[in] anchor The scalar anchor or @c NULL.
+ * @param[in] tag The scalar tag or @c NULL.
+ * @param[in] value The scalar value.
+ * @param[in] length The length of the scalar value.
+ * @param[in] plain_implicit If the tag may be omitted for the plain
+ * style.
+ * @param[in] quoted_implicit If the tag may be omitted for any
+ * non-plain style.
+ * @param[in] style The scalar style.
+ *
+ * @returns @c 1 if the function succeeded, @c 0 on error.
+ */
+
+YAML_DECLARE(int)
+yaml_scalar_event_initialize(yaml_event_t *event,
+ yaml_char_t *anchor, yaml_char_t *tag,
+ yaml_char_t *value, int length,
+ int plain_implicit, int quoted_implicit,
+ yaml_scalar_style_t style);
+
+/**
+ * Create a SEQUENCE-START event.
+ *
+ * The @a style argument may be ignored by the emitter.
+ *
+ * Either the @a tag attribute or the @a implicit flag must be set.
+ *
+ * @param[out] event An empty event object.
+ * @param[in] anchor The sequence anchor or @c NULL.
+ * @param[in] tag The sequence tag or @c NULL.
+ * @param[in] implicit If the tag may be omitted.
+ * @param[in] style The sequence style.
+ *
+ * @returns @c 1 if the function succeeded, @c 0 on error.
+ */
+
+YAML_DECLARE(int)
+yaml_sequence_start_event_initialize(yaml_event_t *event,
+ yaml_char_t *anchor, yaml_char_t *tag, int implicit,
+ yaml_sequence_style_t style);
+
+/**
+ * Create a SEQUENCE-END event.
+ *
+ * @param[out] event An empty event object.
+ *
+ * @returns @c 1 if the function succeeded, @c 0 on error.
+ */
+
+YAML_DECLARE(int)
+yaml_sequence_end_event_initialize(yaml_event_t *event);
+
+/**
+ * Create a MAPPING-START event.
+ *
+ * The @a style argument may be ignored by the emitter.
+ *
+ * Either the @a tag attribute or the @a implicit flag must be set.
+ *
+ * @param[out] event An empty event object.
+ * @param[in] anchor The mapping anchor or @c NULL.
+ * @param[in] tag The mapping tag or @c NULL.
+ * @param[in] implicit If the tag may be omitted.
+ * @param[in] style The mapping style.
+ *
+ * @returns @c 1 if the function succeeded, @c 0 on error.
+ */
+
+YAML_DECLARE(int)
+yaml_mapping_start_event_initialize(yaml_event_t *event,
+ yaml_char_t *anchor, yaml_char_t *tag, int implicit,
+ yaml_mapping_style_t style);
+
+/**
+ * Create a MAPPING-END event.
+ *
+ * @param[out] event An empty event object.
+ *
+ * @returns @c 1 if the function succeeded, @c 0 on error.
+ */
+
+YAML_DECLARE(int)
+yaml_mapping_end_event_initialize(yaml_event_t *event);
+
+/**
+ * Free any memory allocated for an event object.
+ *
+ * @param[in,out] event An event object.
+ */
+
+YAML_DECLARE(void)
+yaml_event_delete(yaml_event_t *event);
+
+/** @} */
+
+/**
+ * @defgroup nodes Nodes
+ * @{
+ */
+
+/** The tag @c !!null with the only possible value: @c null. */
+#define YAML_NULL_TAG "tag:yaml.org,2002:null"
+/** The tag @c !!bool with the values: @c true and @c falce. */
+#define YAML_BOOL_TAG "tag:yaml.org,2002:bool"
+/** The tag @c !!str for string values. */
+#define YAML_STR_TAG "tag:yaml.org,2002:str"
+/** The tag @c !!int for integer values. */
+#define YAML_INT_TAG "tag:yaml.org,2002:int"
+/** The tag @c !!float for float values. */
+#define YAML_FLOAT_TAG "tag:yaml.org,2002:float"
+/** The tag @c !!timestamp for date and time values. */
+#define YAML_TIMESTAMP_TAG "tag:yaml.org,2002:timestamp"
+
+/** The tag @c !!seq is used to denote sequences. */
+#define YAML_SEQ_TAG "tag:yaml.org,2002:seq"
+/** The tag @c !!map is used to denote mapping. */
+#define YAML_MAP_TAG "tag:yaml.org,2002:map"
+
+/** The default scalar tag is @c !!str. */
+#define YAML_DEFAULT_SCALAR_TAG YAML_STR_TAG
+/** The default sequence tag is @c !!seq. */
+#define YAML_DEFAULT_SEQUENCE_TAG YAML_SEQ_TAG
+/** The default mapping tag is @c !!map. */
+#define YAML_DEFAULT_MAPPING_TAG YAML_MAP_TAG
+
+/** Node types. */
+typedef enum yaml_node_type_e {
+ /** An empty node. */
+ YAML_NO_NODE,
+
+ /** A scalar node. */
+ YAML_SCALAR_NODE,
+ /** A sequence node. */
+ YAML_SEQUENCE_NODE,
+ /** A mapping node. */
+ YAML_MAPPING_NODE
+} yaml_node_type_t;
+
+/** The forward definition of a document node structure. */
+typedef struct yaml_node_s yaml_node_t;
+
+/** An element of a sequence node. */
+typedef int yaml_node_item_t;
+
+/** An element of a mapping node. */
+typedef struct yaml_node_pair_s {
+ /** The key of the element. */
+ int key;
+ /** The value of the element. */
+ int value;
+} yaml_node_pair_t;
+
+/** The node structure. */
+struct yaml_node_s {
+
+ /** The node type. */
+ yaml_node_type_t type;
+
+ /** The node tag. */
+ yaml_char_t *tag;
+
+ /** The node data. */
+ union {
+
+ /** The scalar parameters (for @c YAML_SCALAR_NODE). */
+ struct {
+ /** The scalar value. */
+ yaml_char_t *value;
+ /** The length of the scalar value. */
+ size_t length;
+ /** The scalar style. */
+ yaml_scalar_style_t style;
+ } scalar;
+
+ /** The sequence parameters (for @c YAML_SEQUENCE_NODE). */
+ struct {
+ /** The stack of sequence items. */
+ struct {
+ /** The beginning of the stack. */
+ yaml_node_item_t *start;
+ /** The end of the stack. */
+ yaml_node_item_t *end;
+ /** The top of the stack. */
+ yaml_node_item_t *top;
+ } items;
+ /** The sequence style. */
+ yaml_sequence_style_t style;
+ } sequence;
+
+ /** The mapping parameters (for @c YAML_MAPPING_NODE). */
+ struct {
+ /** The stack of mapping pairs (key, value). */
+ struct {
+ /** The beginning of the stack. */
+ yaml_node_pair_t *start;
+ /** The end of the stack. */
+ yaml_node_pair_t *end;
+ /** The top of the stack. */
+ yaml_node_pair_t *top;
+ } pairs;
+ /** The mapping style. */
+ yaml_mapping_style_t style;
+ } mapping;
+
+ } data;
+
+ /** The beginning of the node. */
+ yaml_mark_t start_mark;
+ /** The end of the node. */
+ yaml_mark_t end_mark;
+
+};
+
+/** The document structure. */
+typedef struct yaml_document_s {
+
+ /** The document nodes. */
+ struct {
+ /** The beginning of the stack. */
+ yaml_node_t *start;
+ /** The end of the stack. */
+ yaml_node_t *end;
+ /** The top of the stack. */
+ yaml_node_t *top;
+ } nodes;
+
+ /** The version directive. */
+ yaml_version_directive_t *version_directive;
+
+ /** The list of tag directives. */
+ struct {
+ /** The beginning of the tag directives list. */
+ yaml_tag_directive_t *start;
+ /** The end of the tag directives list. */
+ yaml_tag_directive_t *end;
+ } tag_directives;
+
+ /** Is the document start indicator implicit? */
+ int start_implicit;
+ /** Is the document end indicator implicit? */
+ int end_implicit;
+
+ /** The beginning of the document. */
+ yaml_mark_t start_mark;
+ /** The end of the document. */
+ yaml_mark_t end_mark;
+
+} yaml_document_t;
+
+/**
+ * Create a YAML document.
+ *
+ * @param[out] document An empty document object.
+ * @param[in] version_directive The %YAML directive value or
+ * @c NULL.
+ * @param[in] tag_directives_start The beginning of the %TAG
+ * directives list.
+ * @param[in] tag_directives_end The end of the %TAG directives
+ * list.
+ * @param[in] start_implicit If the document start indicator is
+ * implicit.
+ * @param[in] end_implicit If the document end indicator is
+ * implicit.
+ *
+ * @returns @c 1 if the function succeeded, @c 0 on error.
+ */
+
+YAML_DECLARE(int)
+yaml_document_initialize(yaml_document_t *document,
+ yaml_version_directive_t *version_directive,
+ yaml_tag_directive_t *tag_directives_start,
+ yaml_tag_directive_t *tag_directives_end,
+ int start_implicit, int end_implicit);
+
+/**
+ * Delete a YAML document and all its nodes.
+ *
+ * @param[in,out] document A document object.
+ */
+
+YAML_DECLARE(void)
+yaml_document_delete(yaml_document_t *document);
+
+/**
+ * Get a node of a YAML document.
+ *
+ * The pointer returned by this function is valid until any of the functions
+ * modifying the documents are called.
+ *
+ * @param[in] document A document object.
+ * @param[in] index The node id.
+ *
+ * @returns the node objct or @c NULL if @c node_id is out of range.
+ */
+
+YAML_DECLARE(yaml_node_t *)
+yaml_document_get_node(yaml_document_t *document, int index);
+
+/**
+ * Get the root of a YAML document node.
+ *
+ * The root object is the first object added to the document.
+ *
+ * The pointer returned by this function is valid until any of the functions
+ * modifying the documents are called.
+ *
+ * An empty document produced by the parser signifies the end of a YAML
+ * stream.
+ *
+ * @param[in] document A document object.
+ *
+ * @returns the node object or @c NULL if the document is empty.
+ */
+
+YAML_DECLARE(yaml_node_t *)
+yaml_document_get_root_node(yaml_document_t *document);
+
+/**
+ * Create a SCALAR node and attach it to the document.
+ *
+ * The @a style argument may be ignored by the emitter.
+ *
+ * @param[in,out] document A document object.
+ * @param[in] tag The scalar tag.
+ * @param[in] value The scalar value.
+ * @param[in] length The length of the scalar value.
+ * @param[in] style The scalar style.
+ *
+ * @returns the node id or @c 0 on error.
+ */
+
+YAML_DECLARE(int)
+yaml_document_add_scalar(yaml_document_t *document,
+ yaml_char_t *tag, yaml_char_t *value, int length,
+ yaml_scalar_style_t style);
+
+/**
+ * Create a SEQUENCE node and attach it to the document.
+ *
+ * The @a style argument may be ignored by the emitter.
+ *
+ * @param[in,out] document A document object.
+ * @param[in] tag The sequence tag.
+ * @param[in] style The sequence style.
+ *
+ * @returns the node id or @c 0 on error.
+ */
+
+YAML_DECLARE(int)
+yaml_document_add_sequence(yaml_document_t *document,
+ yaml_char_t *tag, yaml_sequence_style_t style);
+
+/**
+ * Create a MAPPING node and attach it to the document.
+ *
+ * The @a style argument may be ignored by the emitter.
+ *
+ * @param[in,out] document A document object.
+ * @param[in] tag The sequence tag.
+ * @param[in] style The sequence style.
+ *
+ * @returns the node id or @c 0 on error.
+ */
+
+YAML_DECLARE(int)
+yaml_document_add_mapping(yaml_document_t *document,
+ yaml_char_t *tag, yaml_mapping_style_t style);
+
+/**
+ * Add an item to a SEQUENCE node.
+ *
+ * @param[in,out] document A document object.
+ * @param[in] sequence The sequence node id.
+ * @param[in] item The item node id.
+*
+ * @returns @c 1 if the function succeeded, @c 0 on error.
+ */
+
+YAML_DECLARE(int)
+yaml_document_append_sequence_item(yaml_document_t *document,
+ int sequence, int item);
+
+/**
+ * Add a pair of a key and a value to a MAPPING node.
+ *
+ * @param[in,out] document A document object.
+ * @param[in] mapping The mapping node id.
+ * @param[in] key The key node id.
+ * @param[in] value The value node id.
+*
+ * @returns @c 1 if the function succeeded, @c 0 on error.
+ */
+
+YAML_DECLARE(int)
+yaml_document_append_mapping_pair(yaml_document_t *document,
+ int mapping, int key, int value);
+
+/** @} */
+
+/**
+ * @defgroup parser Parser Definitions
+ * @{
+ */
+
+/**
+ * The prototype of a read handler.
+ *
+ * The read handler is called when the parser needs to read more bytes from the
+ * source. The handler should write not more than @a size bytes to the @a
+ * buffer. The number of written bytes should be set to the @a length variable.
+ *
+ * @param[in,out] data A pointer to an application data specified by
+ * yaml_parser_set_input().
+ * @param[out] buffer The buffer to write the data from the source.
+ * @param[in] size The size of the buffer.
+ * @param[out] size_read The actual number of bytes read from the source.
+ *
+ * @returns On success, the handler should return @c 1. If the handler failed,
+ * the returned value should be @c 0. On EOF, the handler should set the
+ * @a size_read to @c 0 and return @c 1.
+ */
+
+typedef int yaml_read_handler_t(void *data, unsigned char *buffer, size_t size,
+ size_t *size_read);
+
+/**
+ * This structure holds information about a potential simple key.
+ */
+
+typedef struct yaml_simple_key_s {
+ /** Is a simple key possible? */
+ int possible;
+
+ /** Is a simple key required? */
+ int required;
+
+ /** The number of the token. */
+ size_t token_number;
+
+ /** The position mark. */
+ yaml_mark_t mark;
+} yaml_simple_key_t;
+
+/**
+ * The states of the parser.
+ */
+typedef enum yaml_parser_state_e {
+ /** Expect STREAM-START. */
+ YAML_PARSE_STREAM_START_STATE,
+ /** Expect the beginning of an implicit document. */
+ YAML_PARSE_IMPLICIT_DOCUMENT_START_STATE,
+ /** Expect DOCUMENT-START. */
+ YAML_PARSE_DOCUMENT_START_STATE,
+ /** Expect the content of a document. */
+ YAML_PARSE_DOCUMENT_CONTENT_STATE,
+ /** Expect DOCUMENT-END. */
+ YAML_PARSE_DOCUMENT_END_STATE,
+ /** Expect a block node. */
+ YAML_PARSE_BLOCK_NODE_STATE,
+ /** Expect a block node or indentless sequence. */
+ YAML_PARSE_BLOCK_NODE_OR_INDENTLESS_SEQUENCE_STATE,
+ /** Expect a flow node. */
+ YAML_PARSE_FLOW_NODE_STATE,
+ /** Expect the first entry of a block sequence. */
+ YAML_PARSE_BLOCK_SEQUENCE_FIRST_ENTRY_STATE,
+ /** Expect an entry of a block sequence. */
+ YAML_PARSE_BLOCK_SEQUENCE_ENTRY_STATE,
+ /** Expect an entry of an indentless sequence. */
+ YAML_PARSE_INDENTLESS_SEQUENCE_ENTRY_STATE,
+ /** Expect the first key of a block mapping. */
+ YAML_PARSE_BLOCK_MAPPING_FIRST_KEY_STATE,
+ /** Expect a block mapping key. */
+ YAML_PARSE_BLOCK_MAPPING_KEY_STATE,
+ /** Expect a block mapping value. */
+ YAML_PARSE_BLOCK_MAPPING_VALUE_STATE,
+ /** Expect the first entry of a flow sequence. */
+ YAML_PARSE_FLOW_SEQUENCE_FIRST_ENTRY_STATE,
+ /** Expect an entry of a flow sequence. */
+ YAML_PARSE_FLOW_SEQUENCE_ENTRY_STATE,
+ /** Expect a key of an ordered mapping. */
+ YAML_PARSE_FLOW_SEQUENCE_ENTRY_MAPPING_KEY_STATE,
+ /** Expect a value of an ordered mapping. */
+ YAML_PARSE_FLOW_SEQUENCE_ENTRY_MAPPING_VALUE_STATE,
+ /** Expect the and of an ordered mapping entry. */
+ YAML_PARSE_FLOW_SEQUENCE_ENTRY_MAPPING_END_STATE,
+ /** Expect the first key of a flow mapping. */
+ YAML_PARSE_FLOW_MAPPING_FIRST_KEY_STATE,
+ /** Expect a key of a flow mapping. */
+ YAML_PARSE_FLOW_MAPPING_KEY_STATE,
+ /** Expect a value of a flow mapping. */
+ YAML_PARSE_FLOW_MAPPING_VALUE_STATE,
+ /** Expect an empty value of a flow mapping. */
+ YAML_PARSE_FLOW_MAPPING_EMPTY_VALUE_STATE,
+ /** Expect nothing. */
+ YAML_PARSE_END_STATE
+} yaml_parser_state_t;
+
+/**
+ * This structure holds aliases data.
+ */
+
+typedef struct yaml_alias_data_s {
+ /** The anchor. */
+ yaml_char_t *anchor;
+ /** The node id. */
+ int index;
+ /** The anchor mark. */
+ yaml_mark_t mark;
+} yaml_alias_data_t;
+
+/**
+ * The parser structure.
+ *
+ * All members are internal. Manage the structure using the @c yaml_parser_
+ * family of functions.
+ */
+
+typedef struct yaml_parser_s {
+
+ /**
+ * @name Error handling
+ * @{
+ */
+
+ /** Error type. */
+ yaml_error_type_t error;
+ /** Error description. */
+ const char *problem;
+ /** The byte about which the problem occurred. */
+ size_t problem_offset;
+ /** The problematic value (@c -1 is none). */
+ int problem_value;
+ /** The problem position. */
+ yaml_mark_t problem_mark;
+ /** The error context. */
+ const char *context;
+ /** The context position. */
+ yaml_mark_t context_mark;
+
+ /**
+ * @}
+ */
+
+ /**
+ * @name Reader stuff
+ * @{
+ */
+
+ /** Read handler. */
+ yaml_read_handler_t *read_handler;
+
+ /** A pointer for passing to the read handler. */
+ void *read_handler_data;
+
+ /** Standard (string or file) input data. */
+ union {
+ /** String input data. */
+ struct {
+ /** The string start pointer. */
+ const unsigned char *start;
+ /** The string end pointer. */
+ const unsigned char *end;
+ /** The string current position. */
+ const unsigned char *current;
+ } string;
+
+ /** File input data. */
+ FILE *file;
+ } input;
+
+ /** EOF flag */
+ int eof;
+
+ /** The working buffer. */
+ struct {
+ /** The beginning of the buffer. */
+ yaml_char_t *start;
+ /** The end of the buffer. */
+ yaml_char_t *end;
+ /** The current position of the buffer. */
+ yaml_char_t *pointer;
+ /** The last filled position of the buffer. */
+ yaml_char_t *last;
+ } buffer;
+
+ /* The number of unread characters in the buffer. */
+ size_t unread;
+
+ /** The raw buffer. */
+ struct {
+ /** The beginning of the buffer. */
+ unsigned char *start;
+ /** The end of the buffer. */
+ unsigned char *end;
+ /** The current position of the buffer. */
+ unsigned char *pointer;
+ /** The last filled position of the buffer. */
+ unsigned char *last;
+ } raw_buffer;
+
+ /** The input encoding. */
+ yaml_encoding_t encoding;
+
+ /** The offset of the current position (in bytes). */
+ size_t offset;
+
+ /** The mark of the current position. */
+ yaml_mark_t mark;
+
+ /**
+ * @}
+ */
+
+ /**
+ * @name Scanner stuff
+ * @{
+ */
+
+ /** Have we started to scan the input stream? */
+ int stream_start_produced;
+
+ /** Have we reached the end of the input stream? */
+ int stream_end_produced;
+
+ /** The number of unclosed '[' and '{' indicators. */
+ int flow_level;
+
+ /** The tokens queue. */
+ struct {
+ /** The beginning of the tokens queue. */
+ yaml_token_t *start;
+ /** The end of the tokens queue. */
+ yaml_token_t *end;
+ /** The head of the tokens queue. */
+ yaml_token_t *head;
+ /** The tail of the tokens queue. */
+ yaml_token_t *tail;
+ } tokens;
+
+ /** The number of tokens fetched from the queue. */
+ size_t tokens_parsed;
+
+ /* Does the tokens queue contain a token ready for dequeueing. */
+ int token_available;
+
+ /** The indentation levels stack. */
+ struct {
+ /** The beginning of the stack. */
+ int *start;
+ /** The end of the stack. */
+ int *end;
+ /** The top of the stack. */
+ int *top;
+ } indents;
+
+ /** The current indentation level. */
+ int indent;
+
+ /** May a simple key occur at the current position? */
+ int simple_key_allowed;
+
+ /** The stack of simple keys. */
+ struct {
+ /** The beginning of the stack. */
+ yaml_simple_key_t *start;
+ /** The end of the stack. */
+ yaml_simple_key_t *end;
+ /** The top of the stack. */
+ yaml_simple_key_t *top;
+ } simple_keys;
+
+ /**
+ * @}
+ */
+
+ /**
+ * @name Parser stuff
+ * @{
+ */
+
+ /** The parser states stack. */
+ struct {
+ /** The beginning of the stack. */
+ yaml_parser_state_t *start;
+ /** The end of the stack. */
+ yaml_parser_state_t *end;
+ /** The top of the stack. */
+ yaml_parser_state_t *top;
+ } states;
+
+ /** The current parser state. */
+ yaml_parser_state_t state;
+
+ /** The stack of marks. */
+ struct {
+ /** The beginning of the stack. */
+ yaml_mark_t *start;
+ /** The end of the stack. */
+ yaml_mark_t *end;
+ /** The top of the stack. */
+ yaml_mark_t *top;
+ } marks;
+
+ /** The list of TAG directives. */
+ struct {
+ /** The beginning of the list. */
+ yaml_tag_directive_t *start;
+ /** The end of the list. */
+ yaml_tag_directive_t *end;
+ /** The top of the list. */
+ yaml_tag_directive_t *top;
+ } tag_directives;
+
+ /**
+ * @}
+ */
+
+ /**
+ * @name Dumper stuff
+ * @{
+ */
+
+ /** The alias data. */
+ struct {
+ /** The beginning of the list. */
+ yaml_alias_data_t *start;
+ /** The end of the list. */
+ yaml_alias_data_t *end;
+ /** The top of the list. */
+ yaml_alias_data_t *top;
+ } aliases;
+
+ /** The currently parsed document. */
+ yaml_document_t *document;
+
+ /**
+ * @}
+ */
+
+} yaml_parser_t;
+
+/**
+ * Initialize a parser.
+ *
+ * This function creates a new parser object. An application is responsible
+ * for destroying the object using the yaml_parser_delete() function.
+ *
+ * @param[out] parser An empty parser object.
+ *
+ * @returns @c 1 if the function succeeded, @c 0 on error.
+ */
+
+YAML_DECLARE(int)
+yaml_parser_initialize(yaml_parser_t *parser);
+
+/**
+ * Destroy a parser.
+ *
+ * @param[in,out] parser A parser object.
+ */
+
+YAML_DECLARE(void)
+yaml_parser_delete(yaml_parser_t *parser);
+
+/**
+ * Set a string input.
+ *
+ * Note that the @a input pointer must be valid while the @a parser object
+ * exists. The application is responsible for destroing @a input after
+ * destroying the @a parser.
+ *
+ * @param[in,out] parser A parser object.
+ * @param[in] input A source data.
+ * @param[in] size The length of the source data in bytes.
+ */
+
+YAML_DECLARE(void)
+yaml_parser_set_input_string(yaml_parser_t *parser,
+ const unsigned char *input, size_t size);
+
+/**
+ * Set a file input.
+ *
+ * @a file should be a file object open for reading. The application is
+ * responsible for closing the @a file.
+ *
+ * @param[in,out] parser A parser object.
+ * @param[in] file An open file.
+ */
+
+YAML_DECLARE(void)
+yaml_parser_set_input_file(yaml_parser_t *parser, FILE *file);
+
+/**
+ * Set a generic input handler.
+ *
+ * @param[in,out] parser A parser object.
+ * @param[in] handler A read handler.
+ * @param[in] data Any application data for passing to the read
+ * handler.
+ */
+
+YAML_DECLARE(void)
+yaml_parser_set_input(yaml_parser_t *parser,
+ yaml_read_handler_t *handler, void *data);
+
+/**
+ * Set the source encoding.
+ *
+ * @param[in,out] parser A parser object.
+ * @param[in] encoding The source encoding.
+ */
+
+YAML_DECLARE(void)
+yaml_parser_set_encoding(yaml_parser_t *parser, yaml_encoding_t encoding);
+
+/**
+ * Scan the input stream and produce the next token.
+ *
+ * Call the function subsequently to produce a sequence of tokens corresponding
+ * to the input stream. The initial token has the type
+ * @c YAML_STREAM_START_TOKEN while the ending token has the type
+ * @c YAML_STREAM_END_TOKEN.
+ *
+ * An application is responsible for freeing any buffers associated with the
+ * produced token object using the @c yaml_token_delete function.
+ *
+ * An application must not alternate the calls of yaml_parser_scan() with the
+ * calls of yaml_parser_parse() or yaml_parser_load(). Doing this will break
+ * the parser.
+ *
+ * @param[in,out] parser A parser object.
+ * @param[out] token An empty token object.
+ *
+ * @returns @c 1 if the function succeeded, @c 0 on error.
+ */
+
+YAML_DECLARE(int)
+yaml_parser_scan(yaml_parser_t *parser, yaml_token_t *token);
+
+/**
+ * Parse the input stream and produce the next parsing event.
+ *
+ * Call the function subsequently to produce a sequence of events corresponding
+ * to the input stream. The initial event has the type
+ * @c YAML_STREAM_START_EVENT while the ending event has the type
+ * @c YAML_STREAM_END_EVENT.
+ *
+ * An application is responsible for freeing any buffers associated with the
+ * produced event object using the yaml_event_delete() function.
+ *
+ * An application must not alternate the calls of yaml_parser_parse() with the
+ * calls of yaml_parser_scan() or yaml_parser_load(). Doing this will break the
+ * parser.
+ *
+ * @param[in,out] parser A parser object.
+ * @param[out] event An empty event object.
+ *
+ * @returns @c 1 if the function succeeded, @c 0 on error.
+ */
+
+YAML_DECLARE(int)
+yaml_parser_parse(yaml_parser_t *parser, yaml_event_t *event);
+
+/**
+ * Parse the input stream and produce the next YAML document.
+ *
+ * Call this function subsequently to produce a sequence of documents
+ * constituting the input stream.
+ *
+ * If the produced document has no root node, it means that the document
+ * end has been reached.
+ *
+ * An application is responsible for freeing any data associated with the
+ * produced document object using the yaml_document_delete() function.
+ *
+ * An application must not alternate the calls of yaml_parser_load() with the
+ * calls of yaml_parser_scan() or yaml_parser_parse(). Doing this will break
+ * the parser.
+ *
+ * @param[in,out] parser A parser object.
+ * @param[out] document An empty document object.
+ *
+ * @return @c 1 if the function succeeded, @c 0 on error.
+ */
+
+YAML_DECLARE(int)
+yaml_parser_load(yaml_parser_t *parser, yaml_document_t *document);
+
+/** @} */
+
+/**
+ * @defgroup emitter Emitter Definitions
+ * @{
+ */
+
+/**
+ * The prototype of a write handler.
+ *
+ * The write handler is called when the emitter needs to flush the accumulated
+ * characters to the output. The handler should write @a size bytes of the
+ * @a buffer to the output.
+ *
+ * @param[in,out] data A pointer to an application data specified by
+ * yaml_emitter_set_output().
+ * @param[in] buffer The buffer with bytes to be written.
+ * @param[in] size The size of the buffer.
+ *
+ * @returns On success, the handler should return @c 1. If the handler failed,
+ * the returned value should be @c 0.
+ */
+
+typedef int yaml_write_handler_t(void *data, unsigned char *buffer, size_t size);
+
+/** The emitter states. */
+typedef enum yaml_emitter_state_e {
+ /** Expect STREAM-START. */
+ YAML_EMIT_STREAM_START_STATE,
+ /** Expect the first DOCUMENT-START or STREAM-END. */
+ YAML_EMIT_FIRST_DOCUMENT_START_STATE,
+ /** Expect DOCUMENT-START or STREAM-END. */
+ YAML_EMIT_DOCUMENT_START_STATE,
+ /** Expect the content of a document. */
+ YAML_EMIT_DOCUMENT_CONTENT_STATE,
+ /** Expect DOCUMENT-END. */
+ YAML_EMIT_DOCUMENT_END_STATE,
+ /** Expect the first item of a flow sequence. */
+ YAML_EMIT_FLOW_SEQUENCE_FIRST_ITEM_STATE,
+ /** Expect an item of a flow sequence. */
+ YAML_EMIT_FLOW_SEQUENCE_ITEM_STATE,
+ /** Expect the first key of a flow mapping. */
+ YAML_EMIT_FLOW_MAPPING_FIRST_KEY_STATE,
+ /** Expect a key of a flow mapping. */
+ YAML_EMIT_FLOW_MAPPING_KEY_STATE,
+ /** Expect a value for a simple key of a flow mapping. */
+ YAML_EMIT_FLOW_MAPPING_SIMPLE_VALUE_STATE,
+ /** Expect a value of a flow mapping. */
+ YAML_EMIT_FLOW_MAPPING_VALUE_STATE,
+ /** Expect the first item of a block sequence. */
+ YAML_EMIT_BLOCK_SEQUENCE_FIRST_ITEM_STATE,
+ /** Expect an item of a block sequence. */
+ YAML_EMIT_BLOCK_SEQUENCE_ITEM_STATE,
+ /** Expect the first key of a block mapping. */
+ YAML_EMIT_BLOCK_MAPPING_FIRST_KEY_STATE,
+ /** Expect the key of a block mapping. */
+ YAML_EMIT_BLOCK_MAPPING_KEY_STATE,
+ /** Expect a value for a simple key of a block mapping. */
+ YAML_EMIT_BLOCK_MAPPING_SIMPLE_VALUE_STATE,
+ /** Expect a value of a block mapping. */
+ YAML_EMIT_BLOCK_MAPPING_VALUE_STATE,
+ /** Expect nothing. */
+ YAML_EMIT_END_STATE
+} yaml_emitter_state_t;
+
+/**
+ * The emitter structure.
+ *
+ * All members are internal. Manage the structure using the @c yaml_emitter_
+ * family of functions.
+ */
+
+typedef struct yaml_emitter_s {
+
+ /**
+ * @name Error handling
+ * @{
+ */
+
+ /** Error type. */
+ yaml_error_type_t error;
+ /** Error description. */
+ const char *problem;
+
+ /**
+ * @}
+ */
+
+ /**
+ * @name Writer stuff
+ * @{
+ */
+
+ /** Write handler. */
+ yaml_write_handler_t *write_handler;
+
+ /** A pointer for passing to the white handler. */
+ void *write_handler_data;
+
+ /** Standard (string or file) output data. */
+ union {
+ /** String output data. */
+ struct {
+ /** The buffer pointer. */
+ unsigned char *buffer;
+ /** The buffer size. */
+ size_t size;
+ /** The number of written bytes. */
+ size_t *size_written;
+ } string;
+
+ /** File output data. */
+ FILE *file;
+ } output;
+
+ /** The working buffer. */
+ struct {
+ /** The beginning of the buffer. */
+ yaml_char_t *start;
+ /** The end of the buffer. */
+ yaml_char_t *end;
+ /** The current position of the buffer. */
+ yaml_char_t *pointer;
+ /** The last filled position of the buffer. */
+ yaml_char_t *last;
+ } buffer;
+
+ /** The raw buffer. */
+ struct {
+ /** The beginning of the buffer. */
+ unsigned char *start;
+ /** The end of the buffer. */
+ unsigned char *end;
+ /** The current position of the buffer. */
+ unsigned char *pointer;
+ /** The last filled position of the buffer. */
+ unsigned char *last;
+ } raw_buffer;
+
+ /** The stream encoding. */
+ yaml_encoding_t encoding;
+
+ /**
+ * @}
+ */
+
+ /**
+ * @name Emitter stuff
+ * @{
+ */
+
+ /** If the output is in the canonical style? */
+ int canonical;
+ /** The number of indentation spaces. */
+ int best_indent;
+ /** The preferred width of the output lines. */
+ int best_width;
+ /** Allow unescaped non-ASCII characters? */
+ int unicode;
+ /** The preferred line break. */
+ yaml_break_t line_break;
+
+ /** The stack of states. */
+ struct {
+ /** The beginning of the stack. */
+ yaml_emitter_state_t *start;
+ /** The end of the stack. */
+ yaml_emitter_state_t *end;
+ /** The top of the stack. */
+ yaml_emitter_state_t *top;
+ } states;
+
+ /** The current emitter state. */
+ yaml_emitter_state_t state;
+
+ /** The event queue. */
+ struct {
+ /** The beginning of the event queue. */
+ yaml_event_t *start;
+ /** The end of the event queue. */
+ yaml_event_t *end;
+ /** The head of the event queue. */
+ yaml_event_t *head;
+ /** The tail of the event queue. */
+ yaml_event_t *tail;
+ } events;
+
+ /** The stack of indentation levels. */
+ struct {
+ /** The beginning of the stack. */
+ int *start;
+ /** The end of the stack. */
+ int *end;
+ /** The top of the stack. */
+ int *top;
+ } indents;
+
+ /** The list of tag directives. */
+ struct {
+ /** The beginning of the list. */
+ yaml_tag_directive_t *start;
+ /** The end of the list. */
+ yaml_tag_directive_t *end;
+ /** The top of the list. */
+ yaml_tag_directive_t *top;
+ } tag_directives;
+
+ /** The current indentation level. */
+ int indent;
+
+ /** The current flow level. */
+ int flow_level;
+
+ /** Is it the document root context? */
+ int root_context;
+ /** Is it a sequence context? */
+ int sequence_context;
+ /** Is it a mapping context? */
+ int mapping_context;
+ /** Is it a simple mapping key context? */
+ int simple_key_context;
+
+ /** The current line. */
+ int line;
+ /** The current column. */
+ int column;
+ /** If the last character was a whitespace? */
+ int whitespace;
+ /** If the last character was an indentation character (' ', '-', '?', ':')? */
+ int indention;
+ /** If an explicit document end is required? */
+ int open_ended;
+
+ /** Anchor analysis. */
+ struct {
+ /** The anchor value. */
+ yaml_char_t *anchor;
+ /** The anchor length. */
+ size_t anchor_length;
+ /** Is it an alias? */
+ int alias;
+ } anchor_data;
+
+ /** Tag analysis. */
+ struct {
+ /** The tag handle. */
+ yaml_char_t *handle;
+ /** The tag handle length. */
+ size_t handle_length;
+ /** The tag suffix. */
+ yaml_char_t *suffix;
+ /** The tag suffix length. */
+ size_t suffix_length;
+ } tag_data;
+
+ /** Scalar analysis. */
+ struct {
+ /** The scalar value. */
+ yaml_char_t *value;
+ /** The scalar length. */
+ size_t length;
+ /** Does the scalar contain line breaks? */
+ int multiline;
+ /** Can the scalar be expessed in the flow plain style? */
+ int flow_plain_allowed;
+ /** Can the scalar be expressed in the block plain style? */
+ int block_plain_allowed;
+ /** Can the scalar be expressed in the single quoted style? */
+ int single_quoted_allowed;
+ /** Can the scalar be expressed in the literal or folded styles? */
+ int block_allowed;
+ /** The output style. */
+ yaml_scalar_style_t style;
+ } scalar_data;
+
+ /**
+ * @}
+ */
+
+ /**
+ * @name Dumper stuff
+ * @{
+ */
+
+ /** If the stream was already opened? */
+ int opened;
+ /** If the stream was already closed? */
+ int closed;
+
+ /** The information associated with the document nodes. */
+ struct {
+ /** The number of references. */
+ int references;
+ /** The anchor id. */
+ int anchor;
+ /** If the node has been emitted? */
+ int serialized;
+ } *anchors;
+
+ /** The last assigned anchor id. */
+ int last_anchor_id;
+
+ /** The currently emitted document. */
+ yaml_document_t *document;
+
+ /**
+ * @}
+ */
+
+} yaml_emitter_t;
+
+/**
+ * Initialize an emitter.
+ *
+ * This function creates a new emitter object. An application is responsible
+ * for destroying the object using the yaml_emitter_delete() function.
+ *
+ * @param[out] emitter An empty parser object.
+ *
+ * @returns @c 1 if the function succeeded, @c 0 on error.
+ */
+
+YAML_DECLARE(int)
+yaml_emitter_initialize(yaml_emitter_t *emitter);
+
+/**
+ * Destroy an emitter.
+ *
+ * @param[in,out] emitter An emitter object.
+ */
+
+YAML_DECLARE(void)
+yaml_emitter_delete(yaml_emitter_t *emitter);
+
+/**
+ * Set a string output.
+ *
+ * The emitter will write the output characters to the @a output buffer of the
+ * size @a size. The emitter will set @a size_written to the number of written
+ * bytes. If the buffer is smaller than required, the emitter produces the
+ * YAML_WRITE_ERROR error.
+ *
+ * @param[in,out] emitter An emitter object.
+ * @param[in] output An output buffer.
+ * @param[in] size The buffer size.
+ * @param[in] size_written The pointer to save the number of written
+ * bytes.
+ */
+
+YAML_DECLARE(void)
+yaml_emitter_set_output_string(yaml_emitter_t *emitter,
+ unsigned char *output, size_t size, size_t *size_written);
+
+/**
+ * Set a file output.
+ *
+ * @a file should be a file object open for writing. The application is
+ * responsible for closing the @a file.
+ *
+ * @param[in,out] emitter An emitter object.
+ * @param[in] file An open file.
+ */
+
+YAML_DECLARE(void)
+yaml_emitter_set_output_file(yaml_emitter_t *emitter, FILE *file);
+
+/**
+ * Set a generic output handler.
+ *
+ * @param[in,out] emitter An emitter object.
+ * @param[in] handler A write handler.
+ * @param[in] data Any application data for passing to the write
+ * handler.
+ */
+
+YAML_DECLARE(void)
+yaml_emitter_set_output(yaml_emitter_t *emitter,
+ yaml_write_handler_t *handler, void *data);
+
+/**
+ * Set the output encoding.
+ *
+ * @param[in,out] emitter An emitter object.
+ * @param[in] encoding The output encoding.
+ */
+
+YAML_DECLARE(void)
+yaml_emitter_set_encoding(yaml_emitter_t *emitter, yaml_encoding_t encoding);
+
+/**
+ * Set if the output should be in the "canonical" format as in the YAML
+ * specification.
+ *
+ * @param[in,out] emitter An emitter object.
+ * @param[in] canonical If the output is canonical.
+ */
+
+YAML_DECLARE(void)
+yaml_emitter_set_canonical(yaml_emitter_t *emitter, int canonical);
+
+/**
+ * Set the indentation increment.
+ *
+ * @param[in,out] emitter An emitter object.
+ * @param[in] indent The indentation increment (1 < . < 10).
+ */
+
+YAML_DECLARE(void)
+yaml_emitter_set_indent(yaml_emitter_t *emitter, int indent);
+
+/**
+ * Set the preferred line width. @c -1 means unlimited.
+ *
+ * @param[in,out] emitter An emitter object.
+ * @param[in] width The preferred line width.
+ */
+
+YAML_DECLARE(void)
+yaml_emitter_set_width(yaml_emitter_t *emitter, int width);
+
+/**
+ * Set if unescaped non-ASCII characters are allowed.
+ *
+ * @param[in,out] emitter An emitter object.
+ * @param[in] unicode If unescaped Unicode characters are allowed.
+ */
+
+YAML_DECLARE(void)
+yaml_emitter_set_unicode(yaml_emitter_t *emitter, int unicode);
+
+/**
+ * Set the preferred line break.
+ *
+ * @param[in,out] emitter An emitter object.
+ * @param[in] line_break The preferred line break.
+ */
+
+YAML_DECLARE(void)
+yaml_emitter_set_break(yaml_emitter_t *emitter, yaml_break_t line_break);
+
+/**
+ * Emit an event.
+ *
+ * The event object may be generated using the yaml_parser_parse() function.
+ * The emitter takes the responsibility for the event object and destroys its
+ * content after it is emitted. The event object is destroyed even if the
+ * function fails.
+ *
+ * @param[in,out] emitter An emitter object.
+ * @param[in,out] event An event object.
+ *
+ * @returns @c 1 if the function succeeded, @c 0 on error.
+ */
+
+YAML_DECLARE(int)
+yaml_emitter_emit(yaml_emitter_t *emitter, yaml_event_t *event);
+
+/**
+ * Start a YAML stream.
+ *
+ * This function should be used before yaml_emitter_dump() is called.
+ *
+ * @param[in,out] emitter An emitter object.
+ *
+ * @returns @c 1 if the function succeeded, @c 0 on error.
+ */
+
+YAML_DECLARE(int)
+yaml_emitter_open(yaml_emitter_t *emitter);
+
+/**
+ * Finish a YAML stream.
+ *
+ * This function should be used after yaml_emitter_dump() is called.
+ *
+ * @param[in,out] emitter An emitter object.
+ *
+ * @returns @c 1 if the function succeeded, @c 0 on error.
+ */
+
+YAML_DECLARE(int)
+yaml_emitter_close(yaml_emitter_t *emitter);
+
+/**
+ * Emit a YAML document.
+ *
+ * The documen object may be generated using the yaml_parser_load() function
+ * or the yaml_document_initialize() function. The emitter takes the
+ * responsibility for the document object and destoys its content after
+ * it is emitted. The document object is destroyedeven if the function fails.
+ *
+ * @param[in,out] emitter An emitter object.
+ * @param[in,out] document A document object.
+ *
+ * @returns @c 1 if the function succeeded, @c 0 on error.
+ */
+
+YAML_DECLARE(int)
+yaml_emitter_dump(yaml_emitter_t *emitter, yaml_document_t *document);
+
+/**
+ * Flush the accumulated characters to the output.
+ *
+ * @param[in,out] emitter An emitter object.
+ *
+ * @returns @c 1 if the function succeeded, @c 0 on error.
+ */
+
+YAML_DECLARE(int)
+yaml_emitter_flush(yaml_emitter_t *emitter);
+
+/** @} */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* #ifndef YAML_H */
+
diff --git a/jni/ruby/ext/psych/yaml/yaml_private.h b/jni/ruby/ext/psych/yaml/yaml_private.h
new file mode 100644
index 0000000..944499c
--- /dev/null
+++ b/jni/ruby/ext/psych/yaml/yaml_private.h
@@ -0,0 +1,664 @@
+#ifdef RUBY_EXTCONF_H
+#include RUBY_EXTCONF_H
+#endif
+
+#if HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <yaml.h>
+
+#include <assert.h>
+#include <limits.h>
+#include <stddef.h>
+
+#ifndef _MSC_VER
+#include <stdint.h>
+#else
+#ifdef _WIN64
+#define PTRDIFF_MAX _I64_MAX
+#else
+#define PTRDIFF_MAX INT_MAX
+#endif
+#endif
+
+/*
+ * Memory management.
+ */
+
+YAML_DECLARE(void *)
+yaml_malloc(size_t size);
+
+YAML_DECLARE(void *)
+yaml_realloc(void *ptr, size_t size);
+
+YAML_DECLARE(void)
+yaml_free(void *ptr);
+
+YAML_DECLARE(yaml_char_t *)
+yaml_strdup(const yaml_char_t *);
+
+/*
+ * Reader: Ensure that the buffer contains at least `length` characters.
+ */
+
+YAML_DECLARE(int)
+yaml_parser_update_buffer(yaml_parser_t *parser, size_t length);
+
+/*
+ * Scanner: Ensure that the token stack contains at least one token ready.
+ */
+
+YAML_DECLARE(int)
+yaml_parser_fetch_more_tokens(yaml_parser_t *parser);
+
+/*
+ * The size of the input raw buffer.
+ */
+
+#define INPUT_RAW_BUFFER_SIZE 16384
+
+/*
+ * The size of the input buffer.
+ *
+ * It should be possible to decode the whole raw buffer.
+ */
+
+#define INPUT_BUFFER_SIZE (INPUT_RAW_BUFFER_SIZE*3)
+
+/*
+ * The size of the output buffer.
+ */
+
+#define OUTPUT_BUFFER_SIZE 16384
+
+/*
+ * The size of the output raw buffer.
+ *
+ * It should be possible to encode the whole output buffer.
+ */
+
+#define OUTPUT_RAW_BUFFER_SIZE (OUTPUT_BUFFER_SIZE*2+2)
+
+/*
+ * The size of other stacks and queues.
+ */
+
+#define INITIAL_STACK_SIZE 16
+#define INITIAL_QUEUE_SIZE 16
+#define INITIAL_STRING_SIZE 16
+
+/*
+ * Buffer management.
+ */
+
+#define BUFFER_INIT(context,buffer,size) \
+ (((buffer).start = yaml_malloc(size)) ? \
+ ((buffer).last = (buffer).pointer = (buffer).start, \
+ (buffer).end = (buffer).start+(size), \
+ 1) : \
+ ((context)->error = YAML_MEMORY_ERROR, \
+ 0))
+
+#define BUFFER_DEL(context,buffer) \
+ (yaml_free((buffer).start), \
+ (buffer).start = (buffer).pointer = (buffer).end = 0)
+
+/*
+ * String management.
+ */
+
+typedef struct {
+ yaml_char_t *start;
+ yaml_char_t *end;
+ yaml_char_t *pointer;
+} yaml_string_t;
+
+YAML_DECLARE(int)
+yaml_string_extend(yaml_char_t **start,
+ yaml_char_t **pointer, yaml_char_t **end);
+
+YAML_DECLARE(int)
+yaml_string_join(
+ yaml_char_t **a_start, yaml_char_t **a_pointer, yaml_char_t **a_end,
+ yaml_char_t **b_start, yaml_char_t **b_pointer, yaml_char_t **b_end);
+
+#define NULL_STRING { NULL, NULL, NULL }
+
+#define STRING(string,length) { (string), (string)+(length), (string) }
+
+#define STRING_ASSIGN(value,string,length) \
+ ((value).start = (string), \
+ (value).end = (string)+(length), \
+ (value).pointer = (string))
+
+#define STRING_INIT(context,string,size) \
+ (((string).start = yaml_malloc(size)) ? \
+ ((string).pointer = (string).start, \
+ (string).end = (string).start+(size), \
+ memset((string).start, 0, (size)), \
+ 1) : \
+ ((context)->error = YAML_MEMORY_ERROR, \
+ 0))
+
+#define STRING_DEL(context,string) \
+ (yaml_free((string).start), \
+ (string).start = (string).pointer = (string).end = 0)
+
+#define STRING_EXTEND(context,string) \
+ ((((string).pointer+5 < (string).end) \
+ || yaml_string_extend(&(string).start, \
+ &(string).pointer, &(string).end)) ? \
+ 1 : \
+ ((context)->error = YAML_MEMORY_ERROR, \
+ 0))
+
+#define CLEAR(context,string) \
+ ((string).pointer = (string).start, \
+ memset((string).start, 0, (string).end-(string).start))
+
+#define JOIN(context,string_a,string_b) \
+ ((yaml_string_join(&(string_a).start, &(string_a).pointer, \
+ &(string_a).end, &(string_b).start, \
+ &(string_b).pointer, &(string_b).end)) ? \
+ ((string_b).pointer = (string_b).start, \
+ 1) : \
+ ((context)->error = YAML_MEMORY_ERROR, \
+ 0))
+
+/*
+ * String check operations.
+ */
+
+/*
+ * Check the octet at the specified position.
+ */
+
+#define CHECK_AT(string,octet,offset) \
+ ((string).pointer[offset] == (yaml_char_t)(octet))
+
+/*
+ * Check the current octet in the buffer.
+ */
+
+#define CHECK(string,octet) CHECK_AT((string),(octet),0)
+
+/*
+ * Check if the character at the specified position is an alphabetical
+ * character, a digit, '_', or '-'.
+ */
+
+#define IS_ALPHA_AT(string,offset) \
+ (((string).pointer[offset] >= (yaml_char_t) '0' && \
+ (string).pointer[offset] <= (yaml_char_t) '9') || \
+ ((string).pointer[offset] >= (yaml_char_t) 'A' && \
+ (string).pointer[offset] <= (yaml_char_t) 'Z') || \
+ ((string).pointer[offset] >= (yaml_char_t) 'a' && \
+ (string).pointer[offset] <= (yaml_char_t) 'z') || \
+ (string).pointer[offset] == '_' || \
+ (string).pointer[offset] == '-')
+
+#define IS_ALPHA(string) IS_ALPHA_AT((string),0)
+
+/*
+ * Check if the character at the specified position is a digit.
+ */
+
+#define IS_DIGIT_AT(string,offset) \
+ (((string).pointer[offset] >= (yaml_char_t) '0' && \
+ (string).pointer[offset] <= (yaml_char_t) '9'))
+
+#define IS_DIGIT(string) IS_DIGIT_AT((string),0)
+
+/*
+ * Get the value of a digit.
+ */
+
+#define AS_DIGIT_AT(string,offset) \
+ ((string).pointer[offset] - (yaml_char_t) '0')
+
+#define AS_DIGIT(string) AS_DIGIT_AT((string),0)
+
+/*
+ * Check if the character at the specified position is a hex-digit.
+ */
+
+#define IS_HEX_AT(string,offset) \
+ (((string).pointer[offset] >= (yaml_char_t) '0' && \
+ (string).pointer[offset] <= (yaml_char_t) '9') || \
+ ((string).pointer[offset] >= (yaml_char_t) 'A' && \
+ (string).pointer[offset] <= (yaml_char_t) 'F') || \
+ ((string).pointer[offset] >= (yaml_char_t) 'a' && \
+ (string).pointer[offset] <= (yaml_char_t) 'f'))
+
+#define IS_HEX(string) IS_HEX_AT((string),0)
+
+/*
+ * Get the value of a hex-digit.
+ */
+
+#define AS_HEX_AT(string,offset) \
+ (((string).pointer[offset] >= (yaml_char_t) 'A' && \
+ (string).pointer[offset] <= (yaml_char_t) 'F') ? \
+ ((string).pointer[offset] - (yaml_char_t) 'A' + 10) : \
+ ((string).pointer[offset] >= (yaml_char_t) 'a' && \
+ (string).pointer[offset] <= (yaml_char_t) 'f') ? \
+ ((string).pointer[offset] - (yaml_char_t) 'a' + 10) : \
+ ((string).pointer[offset] - (yaml_char_t) '0'))
+
+#define AS_HEX(string) AS_HEX_AT((string),0)
+
+/*
+ * Check if the character is ASCII.
+ */
+
+#define IS_ASCII_AT(string,offset) \
+ ((string).pointer[offset] <= (yaml_char_t) '\x7F')
+
+#define IS_ASCII(string) IS_ASCII_AT((string),0)
+
+/*
+ * Check if the character can be printed unescaped.
+ */
+
+#define IS_PRINTABLE_AT(string,offset) \
+ (((string).pointer[offset] == 0x0A) /* . == #x0A */ \
+ || ((string).pointer[offset] >= 0x20 /* #x20 <= . <= #x7E */ \
+ && (string).pointer[offset] <= 0x7E) \
+ || ((string).pointer[offset] == 0xC2 /* #0xA0 <= . <= #xD7FF */ \
+ && (string).pointer[offset+1] >= 0xA0) \
+ || ((string).pointer[offset] > 0xC2 \
+ && (string).pointer[offset] < 0xED) \
+ || ((string).pointer[offset] == 0xED \
+ && (string).pointer[offset+1] < 0xA0) \
+ || ((string).pointer[offset] == 0xEE) \
+ || ((string).pointer[offset] == 0xEF /* #xE000 <= . <= #xFFFD */ \
+ && !((string).pointer[offset+1] == 0xBB /* && . != #xFEFF */ \
+ && (string).pointer[offset+2] == 0xBF) \
+ && !((string).pointer[offset+1] == 0xBF \
+ && ((string).pointer[offset+2] == 0xBE \
+ || (string).pointer[offset+2] == 0xBF))))
+
+#define IS_PRINTABLE(string) IS_PRINTABLE_AT((string),0)
+
+/*
+ * Check if the character at the specified position is NUL.
+ */
+
+#define IS_Z_AT(string,offset) CHECK_AT((string),'\0',(offset))
+
+#define IS_Z(string) IS_Z_AT((string),0)
+
+/*
+ * Check if the character at the specified position is BOM.
+ */
+
+#define IS_BOM_AT(string,offset) \
+ (CHECK_AT((string),'\xEF',(offset)) \
+ && CHECK_AT((string),'\xBB',(offset)+1) \
+ && CHECK_AT((string),'\xBF',(offset)+2)) /* BOM (#xFEFF) */
+
+#define IS_BOM(string) IS_BOM_AT(string,0)
+
+/*
+ * Check if the character at the specified position is space.
+ */
+
+#define IS_SPACE_AT(string,offset) CHECK_AT((string),' ',(offset))
+
+#define IS_SPACE(string) IS_SPACE_AT((string),0)
+
+/*
+ * Check if the character at the specified position is tab.
+ */
+
+#define IS_TAB_AT(string,offset) CHECK_AT((string),'\t',(offset))
+
+#define IS_TAB(string) IS_TAB_AT((string),0)
+
+/*
+ * Check if the character at the specified position is blank (space or tab).
+ */
+
+#define IS_BLANK_AT(string,offset) \
+ (IS_SPACE_AT((string),(offset)) || IS_TAB_AT((string),(offset)))
+
+#define IS_BLANK(string) IS_BLANK_AT((string),0)
+
+/*
+ * Check if the character at the specified position is a line break.
+ */
+
+#define IS_BREAK_AT(string,offset) \
+ (CHECK_AT((string),'\r',(offset)) /* CR (#xD)*/ \
+ || CHECK_AT((string),'\n',(offset)) /* LF (#xA) */ \
+ || (CHECK_AT((string),'\xC2',(offset)) \
+ && CHECK_AT((string),'\x85',(offset)+1)) /* NEL (#x85) */ \
+ || (CHECK_AT((string),'\xE2',(offset)) \
+ && CHECK_AT((string),'\x80',(offset)+1) \
+ && CHECK_AT((string),'\xA8',(offset)+2)) /* LS (#x2028) */ \
+ || (CHECK_AT((string),'\xE2',(offset)) \
+ && CHECK_AT((string),'\x80',(offset)+1) \
+ && CHECK_AT((string),'\xA9',(offset)+2))) /* PS (#x2029) */
+
+#define IS_BREAK(string) IS_BREAK_AT((string),0)
+
+#define IS_CRLF_AT(string,offset) \
+ (CHECK_AT((string),'\r',(offset)) && CHECK_AT((string),'\n',(offset)+1))
+
+#define IS_CRLF(string) IS_CRLF_AT((string),0)
+
+/*
+ * Check if the character is a line break or NUL.
+ */
+
+#define IS_BREAKZ_AT(string,offset) \
+ (IS_BREAK_AT((string),(offset)) || IS_Z_AT((string),(offset)))
+
+#define IS_BREAKZ(string) IS_BREAKZ_AT((string),0)
+
+/*
+ * Check if the character is a line break, space, or NUL.
+ */
+
+#define IS_SPACEZ_AT(string,offset) \
+ (IS_SPACE_AT((string),(offset)) || IS_BREAKZ_AT((string),(offset)))
+
+#define IS_SPACEZ(string) IS_SPACEZ_AT((string),0)
+
+/*
+ * Check if the character is a line break, space, tab, or NUL.
+ */
+
+#define IS_BLANKZ_AT(string,offset) \
+ (IS_BLANK_AT((string),(offset)) || IS_BREAKZ_AT((string),(offset)))
+
+#define IS_BLANKZ(string) IS_BLANKZ_AT((string),0)
+
+/*
+ * Determine the width of the character.
+ */
+
+#define WIDTH_AT(string,offset) \
+ (((string).pointer[offset] & 0x80) == 0x00 ? 1 : \
+ ((string).pointer[offset] & 0xE0) == 0xC0 ? 2 : \
+ ((string).pointer[offset] & 0xF0) == 0xE0 ? 3 : \
+ ((string).pointer[offset] & 0xF8) == 0xF0 ? 4 : 0)
+
+#define WIDTH(string) WIDTH_AT((string),0)
+
+/*
+ * Move the string pointer to the next character.
+ */
+
+#define MOVE(string) ((string).pointer += WIDTH((string)))
+
+/*
+ * Copy a character and move the pointers of both strings.
+ */
+
+#define COPY(string_a,string_b) \
+ ((*(string_b).pointer & 0x80) == 0x00 ? \
+ (*((string_a).pointer++) = *((string_b).pointer++)) : \
+ (*(string_b).pointer & 0xE0) == 0xC0 ? \
+ (*((string_a).pointer++) = *((string_b).pointer++), \
+ *((string_a).pointer++) = *((string_b).pointer++)) : \
+ (*(string_b).pointer & 0xF0) == 0xE0 ? \
+ (*((string_a).pointer++) = *((string_b).pointer++), \
+ *((string_a).pointer++) = *((string_b).pointer++), \
+ *((string_a).pointer++) = *((string_b).pointer++)) : \
+ (*(string_b).pointer & 0xF8) == 0xF0 ? \
+ (*((string_a).pointer++) = *((string_b).pointer++), \
+ *((string_a).pointer++) = *((string_b).pointer++), \
+ *((string_a).pointer++) = *((string_b).pointer++), \
+ *((string_a).pointer++) = *((string_b).pointer++)) : 0)
+
+/*
+ * Stack and queue management.
+ */
+
+YAML_DECLARE(int)
+yaml_stack_extend(void **start, void **top, void **end);
+
+YAML_DECLARE(int)
+yaml_queue_extend(void **start, void **head, void **tail, void **end);
+
+#define STACK_INIT(context,stack,size) \
+ (((stack).start = yaml_malloc((size)*sizeof(*(stack).start))) ? \
+ ((stack).top = (stack).start, \
+ (stack).end = (stack).start+(size), \
+ 1) : \
+ ((context)->error = YAML_MEMORY_ERROR, \
+ 0))
+
+#define STACK_DEL(context,stack) \
+ (yaml_free((stack).start), \
+ (stack).start = (stack).top = (stack).end = 0)
+
+#define STACK_EMPTY(context,stack) \
+ ((void)(context), \
+ ((stack).start == (stack).top))
+
+#define STACK_LIMIT(context,stack,size) \
+ ((stack).top - (stack).start < (size) ? \
+ 1 : \
+ ((context)->error = YAML_MEMORY_ERROR, \
+ 0))
+
+#define PUSH(context,stack,value) \
+ (((stack).top != (stack).end \
+ || yaml_stack_extend((void **)&(stack).start, \
+ (void **)&(stack).top, (void **)&(stack).end)) ? \
+ (*((stack).top++) = value, \
+ 1) : \
+ ((context)->error = YAML_MEMORY_ERROR, \
+ 0))
+
+#define POP(context,stack) \
+ (*(--(stack).top))
+
+#define QUEUE_INIT(context,queue,size) \
+ (((queue).start = yaml_malloc((size)*sizeof(*(queue).start))) ? \
+ ((queue).head = (queue).tail = (queue).start, \
+ (queue).end = (queue).start+(size), \
+ 1) : \
+ ((context)->error = YAML_MEMORY_ERROR, \
+ 0))
+
+#define QUEUE_DEL(context,queue) \
+ (yaml_free((queue).start), \
+ (queue).start = (queue).head = (queue).tail = (queue).end = 0)
+
+#define QUEUE_EMPTY(context,queue) \
+ ((queue).head == (queue).tail)
+
+#define ENQUEUE(context,queue,value) \
+ (((queue).tail != (queue).end \
+ || yaml_queue_extend((void **)&(queue).start, (void **)&(queue).head, \
+ (void **)&(queue).tail, (void **)&(queue).end)) ? \
+ (*((queue).tail++) = value, \
+ 1) : \
+ ((context)->error = YAML_MEMORY_ERROR, \
+ 0))
+
+#define DEQUEUE(context,queue) \
+ (*((queue).head++))
+
+#define QUEUE_INSERT(context,queue,index,value) \
+ (((queue).tail != (queue).end \
+ || yaml_queue_extend((void **)&(queue).start, (void **)&(queue).head, \
+ (void **)&(queue).tail, (void **)&(queue).end)) ? \
+ (memmove((queue).head+(index)+1,(queue).head+(index), \
+ ((queue).tail-(queue).head-(index))*sizeof(*(queue).start)), \
+ *((queue).head+(index)) = value, \
+ (queue).tail++, \
+ 1) : \
+ ((context)->error = YAML_MEMORY_ERROR, \
+ 0))
+
+/*
+ * Token initializers.
+ */
+
+#define TOKEN_INIT(token,token_type,token_start_mark,token_end_mark) \
+ (memset(&(token), 0, sizeof(yaml_token_t)), \
+ (token).type = (token_type), \
+ (token).start_mark = (token_start_mark), \
+ (token).end_mark = (token_end_mark))
+
+#define STREAM_START_TOKEN_INIT(token,token_encoding,start_mark,end_mark) \
+ (TOKEN_INIT((token),YAML_STREAM_START_TOKEN,(start_mark),(end_mark)), \
+ (token).data.stream_start.encoding = (token_encoding))
+
+#define STREAM_END_TOKEN_INIT(token,start_mark,end_mark) \
+ (TOKEN_INIT((token),YAML_STREAM_END_TOKEN,(start_mark),(end_mark)))
+
+#define ALIAS_TOKEN_INIT(token,token_value,start_mark,end_mark) \
+ (TOKEN_INIT((token),YAML_ALIAS_TOKEN,(start_mark),(end_mark)), \
+ (token).data.alias.value = (token_value))
+
+#define ANCHOR_TOKEN_INIT(token,token_value,start_mark,end_mark) \
+ (TOKEN_INIT((token),YAML_ANCHOR_TOKEN,(start_mark),(end_mark)), \
+ (token).data.anchor.value = (token_value))
+
+#define TAG_TOKEN_INIT(token,token_handle,token_suffix,start_mark,end_mark) \
+ (TOKEN_INIT((token),YAML_TAG_TOKEN,(start_mark),(end_mark)), \
+ (token).data.tag.handle = (token_handle), \
+ (token).data.tag.suffix = (token_suffix))
+
+#define SCALAR_TOKEN_INIT(token,token_value,token_length,token_style,start_mark,end_mark) \
+ (TOKEN_INIT((token),YAML_SCALAR_TOKEN,(start_mark),(end_mark)), \
+ (token).data.scalar.value = (token_value), \
+ (token).data.scalar.length = (token_length), \
+ (token).data.scalar.style = (token_style))
+
+#define VERSION_DIRECTIVE_TOKEN_INIT(token,token_major,token_minor,start_mark,end_mark) \
+ (TOKEN_INIT((token),YAML_VERSION_DIRECTIVE_TOKEN,(start_mark),(end_mark)), \
+ (token).data.version_directive.major = (token_major), \
+ (token).data.version_directive.minor = (token_minor))
+
+#define TAG_DIRECTIVE_TOKEN_INIT(token,token_handle,token_prefix,start_mark,end_mark) \
+ (TOKEN_INIT((token),YAML_TAG_DIRECTIVE_TOKEN,(start_mark),(end_mark)), \
+ (token).data.tag_directive.handle = (token_handle), \
+ (token).data.tag_directive.prefix = (token_prefix))
+
+/*
+ * Event initializers.
+ */
+
+#define EVENT_INIT(event,event_type,event_start_mark,event_end_mark) \
+ (memset(&(event), 0, sizeof(yaml_event_t)), \
+ (event).type = (event_type), \
+ (event).start_mark = (event_start_mark), \
+ (event).end_mark = (event_end_mark))
+
+#define STREAM_START_EVENT_INIT(event,event_encoding,start_mark,end_mark) \
+ (EVENT_INIT((event),YAML_STREAM_START_EVENT,(start_mark),(end_mark)), \
+ (event).data.stream_start.encoding = (event_encoding))
+
+#define STREAM_END_EVENT_INIT(event,start_mark,end_mark) \
+ (EVENT_INIT((event),YAML_STREAM_END_EVENT,(start_mark),(end_mark)))
+
+#define DOCUMENT_START_EVENT_INIT(event,event_version_directive, \
+ event_tag_directives_start,event_tag_directives_end,event_implicit,start_mark,end_mark) \
+ (EVENT_INIT((event),YAML_DOCUMENT_START_EVENT,(start_mark),(end_mark)), \
+ (event).data.document_start.version_directive = (event_version_directive), \
+ (event).data.document_start.tag_directives.start = (event_tag_directives_start), \
+ (event).data.document_start.tag_directives.end = (event_tag_directives_end), \
+ (event).data.document_start.implicit = (event_implicit))
+
+#define DOCUMENT_END_EVENT_INIT(event,event_implicit,start_mark,end_mark) \
+ (EVENT_INIT((event),YAML_DOCUMENT_END_EVENT,(start_mark),(end_mark)), \
+ (event).data.document_end.implicit = (event_implicit))
+
+#define ALIAS_EVENT_INIT(event,event_anchor,start_mark,end_mark) \
+ (EVENT_INIT((event),YAML_ALIAS_EVENT,(start_mark),(end_mark)), \
+ (event).data.alias.anchor = (event_anchor))
+
+#define SCALAR_EVENT_INIT(event,event_anchor,event_tag,event_value,event_length, \
+ event_plain_implicit, event_quoted_implicit,event_style,start_mark,end_mark) \
+ (EVENT_INIT((event),YAML_SCALAR_EVENT,(start_mark),(end_mark)), \
+ (event).data.scalar.anchor = (event_anchor), \
+ (event).data.scalar.tag = (event_tag), \
+ (event).data.scalar.value = (event_value), \
+ (event).data.scalar.length = (event_length), \
+ (event).data.scalar.plain_implicit = (event_plain_implicit), \
+ (event).data.scalar.quoted_implicit = (event_quoted_implicit), \
+ (event).data.scalar.style = (event_style))
+
+#define SEQUENCE_START_EVENT_INIT(event,event_anchor,event_tag, \
+ event_implicit,event_style,start_mark,end_mark) \
+ (EVENT_INIT((event),YAML_SEQUENCE_START_EVENT,(start_mark),(end_mark)), \
+ (event).data.sequence_start.anchor = (event_anchor), \
+ (event).data.sequence_start.tag = (event_tag), \
+ (event).data.sequence_start.implicit = (event_implicit), \
+ (event).data.sequence_start.style = (event_style))
+
+#define SEQUENCE_END_EVENT_INIT(event,start_mark,end_mark) \
+ (EVENT_INIT((event),YAML_SEQUENCE_END_EVENT,(start_mark),(end_mark)))
+
+#define MAPPING_START_EVENT_INIT(event,event_anchor,event_tag, \
+ event_implicit,event_style,start_mark,end_mark) \
+ (EVENT_INIT((event),YAML_MAPPING_START_EVENT,(start_mark),(end_mark)), \
+ (event).data.mapping_start.anchor = (event_anchor), \
+ (event).data.mapping_start.tag = (event_tag), \
+ (event).data.mapping_start.implicit = (event_implicit), \
+ (event).data.mapping_start.style = (event_style))
+
+#define MAPPING_END_EVENT_INIT(event,start_mark,end_mark) \
+ (EVENT_INIT((event),YAML_MAPPING_END_EVENT,(start_mark),(end_mark)))
+
+/*
+ * Document initializer.
+ */
+
+#define DOCUMENT_INIT(document,document_nodes_start,document_nodes_end, \
+ document_version_directive,document_tag_directives_start, \
+ document_tag_directives_end,document_start_implicit, \
+ document_end_implicit,document_start_mark,document_end_mark) \
+ (memset(&(document), 0, sizeof(yaml_document_t)), \
+ (document).nodes.start = (document_nodes_start), \
+ (document).nodes.end = (document_nodes_end), \
+ (document).nodes.top = (document_nodes_start), \
+ (document).version_directive = (document_version_directive), \
+ (document).tag_directives.start = (document_tag_directives_start), \
+ (document).tag_directives.end = (document_tag_directives_end), \
+ (document).start_implicit = (document_start_implicit), \
+ (document).end_implicit = (document_end_implicit), \
+ (document).start_mark = (document_start_mark), \
+ (document).end_mark = (document_end_mark))
+
+/*
+ * Node initializers.
+ */
+
+#define NODE_INIT(node,node_type,node_tag,node_start_mark,node_end_mark) \
+ (memset(&(node), 0, sizeof(yaml_node_t)), \
+ (node).type = (node_type), \
+ (node).tag = (node_tag), \
+ (node).start_mark = (node_start_mark), \
+ (node).end_mark = (node_end_mark))
+
+#define SCALAR_NODE_INIT(node,node_tag,node_value,node_length, \
+ node_style,start_mark,end_mark) \
+ (NODE_INIT((node),YAML_SCALAR_NODE,(node_tag),(start_mark),(end_mark)), \
+ (node).data.scalar.value = (node_value), \
+ (node).data.scalar.length = (node_length), \
+ (node).data.scalar.style = (node_style))
+
+#define SEQUENCE_NODE_INIT(node,node_tag,node_items_start,node_items_end, \
+ node_style,start_mark,end_mark) \
+ (NODE_INIT((node),YAML_SEQUENCE_NODE,(node_tag),(start_mark),(end_mark)), \
+ (node).data.sequence.items.start = (node_items_start), \
+ (node).data.sequence.items.end = (node_items_end), \
+ (node).data.sequence.items.top = (node_items_start), \
+ (node).data.sequence.style = (node_style))
+
+#define MAPPING_NODE_INIT(node,node_tag,node_pairs_start,node_pairs_end, \
+ node_style,start_mark,end_mark) \
+ (NODE_INIT((node),YAML_MAPPING_NODE,(node_tag),(start_mark),(end_mark)), \
+ (node).data.mapping.pairs.start = (node_pairs_start), \
+ (node).data.mapping.pairs.end = (node_pairs_end), \
+ (node).data.mapping.pairs.top = (node_pairs_start), \
+ (node).data.mapping.style = (node_style))
+
diff --git a/jni/ruby/ext/pty/Makefile b/jni/ruby/ext/pty/Makefile
new file mode 100644
index 0000000..b4d6b8f
--- /dev/null
+++ b/jni/ruby/ext/pty/Makefile
@@ -0,0 +1,297 @@
+
+SHELL = /bin/sh
+
+# V=0 quiet, V=1 verbose. other values don't work.
+V = 0
+Q1 = $(V:1=)
+Q = $(Q1:0=@)
+ECHO1 = $(V:1=@:)
+ECHO = $(ECHO1:0=@echo)
+NULLCMD = :
+
+#### Start of system configuration section. ####
+top_srcdir = $(topdir)/.
+srcdir = $(top_srcdir)/ext/pty
+topdir = ../..
+hdrdir = $(top_srcdir)/include
+arch_hdrdir = $(extout)/include/$(arch)
+PATH_SEPARATOR = :
+VPATH = $(srcdir):$(arch_hdrdir)/ruby:$(hdrdir)/ruby
+RUBYLIB =
+RUBYOPT = -
+prefix = $(DESTDIR)/usr/local
+rubysitearchprefix = $(rubylibprefix)/$(sitearch)
+rubyarchprefix = $(rubylibprefix)/$(arch)
+rubylibprefix = $(libdir)/$(RUBY_BASE_NAME)
+exec_prefix = $(prefix)
+vendorarchhdrdir = $(vendorhdrdir)/$(sitearch)
+sitearchhdrdir = $(sitehdrdir)/$(sitearch)
+rubyarchhdrdir = $(rubyhdrdir)/$(arch)
+vendorhdrdir = $(rubyhdrdir)/vendor_ruby
+sitehdrdir = $(rubyhdrdir)/site_ruby
+rubyhdrdir = $(includedir)/$(RUBY_VERSION_NAME)
+vendorarchdir = $(vendorlibdir)/$(sitearch)
+vendorlibdir = $(vendordir)/$(ruby_version)
+vendordir = $(rubylibprefix)/vendor_ruby
+sitearchdir = $(sitelibdir)/$(sitearch)
+sitelibdir = $(sitedir)/$(ruby_version)
+sitedir = $(rubylibprefix)/site_ruby
+rubyarchdir = $(rubylibdir)/$(arch)
+rubylibdir = $(rubylibprefix)/$(ruby_version)
+sitearchincludedir = $(includedir)/$(sitearch)
+archincludedir = $(includedir)/$(arch)
+sitearchlibdir = $(libdir)/$(sitearch)
+archlibdir = $(libdir)/$(arch)
+ridir = $(datarootdir)/$(RI_BASE_NAME)
+mandir = $(datarootdir)/man
+localedir = $(datarootdir)/locale
+libdir = $(exec_prefix)/lib
+psdir = $(docdir)
+pdfdir = $(docdir)
+dvidir = $(docdir)
+htmldir = $(docdir)
+infodir = $(datarootdir)/info
+docdir = $(datarootdir)/doc/$(PACKAGE)
+oldincludedir = $(DESTDIR)/usr/include
+includedir = $(prefix)/include
+localstatedir = $(prefix)/var
+sharedstatedir = $(prefix)/com
+sysconfdir = $(prefix)/etc
+datadir = $(datarootdir)
+datarootdir = $(prefix)/share
+libexecdir = $(exec_prefix)/libexec
+sbindir = $(exec_prefix)/sbin
+bindir = $(exec_prefix)/bin
+archdir = $(rubyarchdir)
+
+
+CC = gcc
+CXX = g++
+LIBRUBY = $(LIBRUBY_SO)
+LIBRUBY_A = lib$(RUBY_SO_NAME)-static.a
+LIBRUBYARG_SHARED = -Wl,-R$(libdir) -L$(libdir) -l$(RUBY_SO_NAME)
+LIBRUBYARG_STATIC = -Wl,-R$(libdir) -L$(libdir) -l$(RUBY_SO_NAME)-static
+empty =
+OUTFLAG = -o $(empty)
+COUTFLAG = -o $(empty)
+
+RUBY_EXTCONF_H = extconf.h
+cflags = $(optflags) $(debugflags) $(warnflags)
+optflags = -O3 -fno-fast-math
+debugflags = -ggdb3
+warnflags = -Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wunused-variable -Wpointer-arith -Wwrite-strings -Wdeclaration-after-statement -Wimplicit-function-declaration -Wdeprecated-declarations -Wno-packed-bitfield-compat
+CCDLFLAGS = -fPIC
+CFLAGS = $(CCDLFLAGS) $(cflags) -fPIC $(ARCH_FLAG)
+INCFLAGS = -I. -I$(arch_hdrdir) -I$(hdrdir) -I$(srcdir) -I$(topdir) -I$(top_srcdir)
+DEFS =
+CPPFLAGS = -DRUBY_EXTCONF_H=\"$(RUBY_EXTCONF_H)\" $(DEFS) $(cppflags)
+CXXFLAGS = $(CCDLFLAGS) $(cxxflags) $(ARCH_FLAG)
+ldflags = -L. -fstack-protector -rdynamic -Wl,-export-dynamic
+dldflags =
+ARCH_FLAG =
+DLDFLAGS = $(ldflags) $(dldflags) $(ARCH_FLAG)
+LDSHARED = $(CC) -shared
+LDSHAREDXX = $(CXX) -shared
+AR = ar
+EXEEXT =
+
+RUBY_INSTALL_NAME = $(RUBY_BASE_NAME)
+RUBY_SO_NAME = ruby
+RUBYW_INSTALL_NAME =
+RUBY_VERSION_NAME = $(RUBY_BASE_NAME)-$(ruby_version)
+RUBYW_BASE_NAME = rubyw
+RUBY_BASE_NAME = ruby
+
+arch = x86_64-linux
+sitearch = $(arch)
+ruby_version = 2.2.0
+ruby = $(topdir)/miniruby -I'$(topdir)' -I'$(top_srcdir)/lib' -I'$(extout)/$(arch)' -I'$(extout)/common'
+RUBY = $(ruby)
+ruby_headers = $(hdrdir)/ruby.h $(hdrdir)/ruby/ruby.h $(hdrdir)/ruby/defines.h $(hdrdir)/ruby/missing.h $(hdrdir)/ruby/intern.h $(hdrdir)/ruby/st.h $(hdrdir)/ruby/subst.h $(arch_hdrdir)/ruby/config.h $(RUBY_EXTCONF_H)
+
+RM = rm -f
+RM_RF = $(RUBY) -run -e rm -- -rf
+RMDIRS = rmdir --ignore-fail-on-non-empty -p
+MAKEDIRS = /bin/mkdir -p
+INSTALL = /usr/bin/install -c
+INSTALL_PROG = $(INSTALL) -m 0755
+INSTALL_DATA = $(INSTALL) -m 644
+COPY = cp
+TOUCH = exit >
+
+#### End of system configuration section. ####
+
+preload =
+
+libpath = . $(topdir)
+LIBPATH = -L. -L$(topdir)
+DEFFILE =
+
+CLEANFILES = mkmf.log
+DISTCLEANFILES =
+DISTCLEANDIRS =
+
+extout = $(topdir)/.ext
+extout_prefix = $(extout)$(target_prefix)/
+target_prefix =
+LOCAL_LIBS =
+LIBS = $(LIBRUBYARG_SHARED) -lutil -lpthread -lgmp -ldl -lcrypt -lm -lc
+ORIG_SRCS = pty.c
+SRCS = $(ORIG_SRCS)
+OBJS = pty.o
+HDRS = $(srcdir)/extconf.h
+TARGET = pty
+TARGET_NAME = pty
+TARGET_ENTRY = Init_$(TARGET_NAME)
+DLLIB = $(TARGET).so
+EXTSTATIC =
+STATIC_LIB = $(TARGET).a
+
+TIMESTAMP_DIR = $(extout)/.timestamp
+BINDIR = $(extout)/bin
+RUBYCOMMONDIR = $(extout)/common
+RUBYLIBDIR = $(RUBYCOMMONDIR)$(target_prefix)
+RUBYARCHDIR = $(extout)/$(arch)$(target_prefix)
+HDRDIR = $(extout)/include/ruby$(target_prefix)
+ARCHHDRDIR = $(extout)/include/$(arch)/ruby$(target_prefix)
+
+TARGET_SO = $(RUBYARCHDIR)/$(DLLIB)
+CLEANLIBS = $(RUBYARCHDIR)/$(TARGET).so
+CLEANOBJS = *.o *.bak
+
+all: install
+static: all
+.PHONY: all install static install-so install-rb
+.PHONY: clean clean-so clean-static clean-rb
+
+clean-static::
+clean-rb-default::
+clean-rb::
+clean-so::
+clean: clean-so clean-static clean-rb-default clean-rb
+ -$(Q)$(RM) $(CLEANLIBS) $(CLEANOBJS) $(CLEANFILES) .*.time
+
+distclean-rb-default::
+distclean-rb::
+distclean-so::
+distclean-static::
+distclean: clean distclean-so distclean-static distclean-rb-default distclean-rb
+ -$(Q)$(RM) Makefile $(RUBY_EXTCONF_H) conftest.* mkmf.log
+ -$(Q)$(RM) core ruby$(EXEEXT) *~ $(DISTCLEANFILES)
+ -$(Q)$(RMDIRS) $(DISTCLEANDIRS) 2> /dev/null || true
+
+realclean: distclean
+install: install-so install-rb
+
+install-so: $(RUBYARCHDIR)/$(DLLIB)
+clean-so::
+ -$(Q)$(RM) $(RUBYARCHDIR)/$(DLLIB)
+ -$(Q)$(RMDIRS) $(RUBYARCHDIR) 2> /dev/null || true
+clean-static::
+ -$(Q)$(RM) $(STATIC_LIB)
+install-rb: pre-install-rb install-rb-default
+install-rb-default: pre-install-rb-default
+pre-install-rb: Makefile
+pre-install-rb-default: Makefile
+pre-install-rb-default: $(TIMESTAMP_DIR)/.RUBYLIBDIR.time
+install-rb-default: $(RUBYLIBDIR)/expect.rb
+$(RUBYLIBDIR)/expect.rb: $(srcdir)/lib/expect.rb $(TIMESTAMP_DIR)/.RUBYLIBDIR.time
+ $(Q) $(COPY) $(srcdir)/lib/expect.rb $(@D)
+clean-rb-default::
+ -$(Q)$(RM) $(RUBYLIBDIR)/expect.rb
+pre-install-rb-default:
+ $(ECHO) installing default pty libraries
+clean-rb-default::
+ -$(Q)$(RMDIRS) $(RUBYLIBDIR) 2> /dev/null || true
+$(TIMESTAMP_DIR)/.RUBYARCHDIR.time:
+ $(Q) $(MAKEDIRS) $(@D) $(RUBYARCHDIR)
+ $(Q) $(TOUCH) $@
+$(TIMESTAMP_DIR)/.RUBYLIBDIR.time:
+ $(Q) $(MAKEDIRS) $(@D) $(RUBYLIBDIR)
+ $(Q) $(TOUCH) $@
+
+site-install: site-install-so site-install-rb
+site-install-so: install-so
+site-install-rb: install-rb
+
+.SUFFIXES: .c .m .cc .mm .cxx .cpp .o .S
+
+.cc.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<
+
+.cc.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -S $<
+
+.mm.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<
+
+.mm.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -S $<
+
+.cxx.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<
+
+.cxx.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -S $<
+
+.cpp.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<
+
+.cpp.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -S $<
+
+.c.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -c $<
+
+.c.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -S $<
+
+.m.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -c $<
+
+.m.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -S $<
+
+$(RUBYARCHDIR)/$(DLLIB): $(OBJS) Makefile $(TIMESTAMP_DIR)/.RUBYARCHDIR.time
+ $(ECHO) linking shared-object $(DLLIB)
+ -$(Q)$(RM) $(@)
+ $(Q) $(LDSHARED) -o $@ $(OBJS) $(LIBPATH) $(DLDFLAGS) $(LOCAL_LIBS) $(LIBS)
+
+$(STATIC_LIB): $(OBJS)
+ -$(Q)$(RM) $(@)
+ $(ECHO) linking static-library $(@)
+ $(Q) $(AR) cru $@ $(OBJS)
+ -$(Q)ranlib $(@) 2> /dev/null || true
+
+###
+$(OBJS): $(RUBY_EXTCONF_H)
+
+# AUTOGENERATED DEPENDENCIES START
+pty.o: $(RUBY_EXTCONF_H)
+pty.o: $(arch_hdrdir)/ruby/config.h
+pty.o: $(hdrdir)/ruby/defines.h
+pty.o: $(hdrdir)/ruby/encoding.h
+pty.o: $(hdrdir)/ruby/intern.h
+pty.o: $(hdrdir)/ruby/io.h
+pty.o: $(hdrdir)/ruby/missing.h
+pty.o: $(hdrdir)/ruby/oniguruma.h
+pty.o: $(hdrdir)/ruby/ruby.h
+pty.o: $(hdrdir)/ruby/st.h
+pty.o: $(hdrdir)/ruby/subst.h
+pty.o: $(hdrdir)/ruby/util.h
+pty.o: $(top_srcdir)/include/ruby.h
+pty.o: $(top_srcdir)/internal.h
+pty.o: pty.c
+# AUTOGENERATED DEPENDENCIES END
diff --git a/jni/ruby/ext/pty/depend b/jni/ruby/ext/pty/depend
new file mode 100644
index 0000000..a1982af
--- /dev/null
+++ b/jni/ruby/ext/pty/depend
@@ -0,0 +1,17 @@
+# AUTOGENERATED DEPENDENCIES START
+pty.o: $(RUBY_EXTCONF_H)
+pty.o: $(arch_hdrdir)/ruby/config.h
+pty.o: $(hdrdir)/ruby/defines.h
+pty.o: $(hdrdir)/ruby/encoding.h
+pty.o: $(hdrdir)/ruby/intern.h
+pty.o: $(hdrdir)/ruby/io.h
+pty.o: $(hdrdir)/ruby/missing.h
+pty.o: $(hdrdir)/ruby/oniguruma.h
+pty.o: $(hdrdir)/ruby/ruby.h
+pty.o: $(hdrdir)/ruby/st.h
+pty.o: $(hdrdir)/ruby/subst.h
+pty.o: $(hdrdir)/ruby/util.h
+pty.o: $(top_srcdir)/include/ruby.h
+pty.o: $(top_srcdir)/internal.h
+pty.o: pty.c
+# AUTOGENERATED DEPENDENCIES END
diff --git a/jni/ruby/ext/pty/extconf.h b/jni/ruby/ext/pty/extconf.h
new file mode 100644
index 0000000..5225ad4
--- /dev/null
+++ b/jni/ruby/ext/pty/extconf.h
@@ -0,0 +1,7 @@
+#ifndef EXTCONF_H
+#define EXTCONF_H
+#define HAVE_SYS_STROPTS_H 1
+#define HAVE_SETRESUID 1
+#define HAVE_PTY_H 1
+#define HAVE_POSIX_OPENPT 1
+#endif
diff --git a/jni/ruby/ext/pty/extconf.rb b/jni/ruby/ext/pty/extconf.rb
new file mode 100644
index 0000000..1db9f6e
--- /dev/null
+++ b/jni/ruby/ext/pty/extconf.rb
@@ -0,0 +1,19 @@
+require 'mkmf'
+
+$INCFLAGS << " -I$(topdir) -I$(top_srcdir)"
+
+if /mswin|mingw|bccwin|nacl/ !~ RUBY_PLATFORM
+ have_header("sys/stropts.h")
+ have_func("setresuid")
+ have_header("libutil.h")
+ have_header("util.h") # OpenBSD openpty
+ have_header("pty.h")
+ have_library("util", "openpty")
+ if have_func("posix_openpt") or
+ have_func("openpty") or
+ have_func("_getpty") or
+ have_func("ptsname") or
+ have_func("ioctl")
+ create_makefile('pty')
+ end
+end
diff --git a/jni/ruby/ext/pty/lib/expect.rb b/jni/ruby/ext/pty/lib/expect.rb
new file mode 100644
index 0000000..c3f3925
--- /dev/null
+++ b/jni/ruby/ext/pty/lib/expect.rb
@@ -0,0 +1,71 @@
+$expect_verbose = false
+
+# Expect library adds the IO instance method #expect, which does similar act to
+# tcl's expect extension.
+#
+# In order to use this method, you must require expect:
+#
+# require 'expect'
+#
+# Please see #expect for usage.
+class IO
+ # call-seq:
+ # IO#expect(pattern,timeout=9999999) -> Array
+ # IO#expect(pattern,timeout=9999999) { |result| ... } -> nil
+ #
+ # Reads from the IO until the given +pattern+ matches or the +timeout+ is over.
+ #
+ # It returns an array with the read buffer, followed by the matches.
+ # If a block is given, the result is yielded to the block and returns nil.
+ #
+ # When called without a block, it waits until the input that matches the
+ # given +pattern+ is obtained from the IO or the time specified as the
+ # timeout passes. An array is returned when the pattern is obtained from the
+ # IO. The first element of the array is the entire string obtained from the
+ # IO until the pattern matches, followed by elements indicating which the
+ # pattern which matched to the anchor in the regular expression.
+ #
+ # The optional timeout parameter defines, in seconds, the total time to wait
+ # for the pattern. If the timeout expires or eof is found, nil is returned
+ # or yielded. However, the buffer in a timeout session is kept for the next
+ # expect call. The default timeout is 9999999 seconds.
+ def expect(pat,timeout=9999999)
+ buf = ''
+ case pat
+ when String
+ e_pat = Regexp.new(Regexp.quote(pat))
+ when Regexp
+ e_pat = pat
+ else
+ raise TypeError, "unsupported pattern class: #{pat.class}"
+ end
+ @unusedBuf ||= ''
+ while true
+ if not @unusedBuf.empty?
+ c = @unusedBuf.slice!(0).chr
+ elsif !IO.select([self],nil,nil,timeout) or eof? then
+ result = nil
+ @unusedBuf = buf
+ break
+ else
+ c = getc.chr
+ end
+ buf << c
+ if $expect_verbose
+ STDOUT.print c
+ STDOUT.flush
+ end
+ if mat=e_pat.match(buf) then
+ result = [buf,*mat.to_a[1..-1]]
+ break
+ end
+ end
+ if block_given? then
+ yield result
+ else
+ return result
+ end
+ nil
+ end
+end
+
diff --git a/jni/ruby/ext/pty/pty.c b/jni/ruby/ext/pty/pty.c
new file mode 100644
index 0000000..631adb2
--- /dev/null
+++ b/jni/ruby/ext/pty/pty.c
@@ -0,0 +1,758 @@
+#include "ruby/config.h"
+#ifdef RUBY_EXTCONF_H
+#include RUBY_EXTCONF_H
+#endif
+#include <stdlib.h>
+#include <stdio.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <sys/file.h>
+#include <fcntl.h>
+#include <errno.h>
+#include <pwd.h>
+#ifdef HAVE_SYS_IOCTL_H
+#include <sys/ioctl.h>
+#endif
+#ifdef HAVE_LIBUTIL_H
+#include <libutil.h>
+#endif
+#ifdef HAVE_UTIL_H
+#include <util.h>
+#endif
+#ifdef HAVE_PTY_H
+#include <pty.h>
+#endif
+#if defined(HAVE_SYS_PARAM_H)
+ /* for __FreeBSD_version */
+# include <sys/param.h>
+#endif
+#ifdef HAVE_SYS_WAIT_H
+#include <sys/wait.h>
+#else
+#define WIFSTOPPED(status) (((status) & 0xff) == 0x7f)
+#endif
+#include <ctype.h>
+
+#include "internal.h"
+#include "ruby/io.h"
+#include "ruby/util.h"
+
+#include <signal.h>
+#ifdef HAVE_SYS_STROPTS_H
+#include <sys/stropts.h>
+#endif
+
+#ifdef HAVE_UNISTD_H
+#include <unistd.h>
+#endif
+
+#define DEVICELEN 16
+
+#ifndef HAVE_SETEUID
+# ifdef HAVE_SETREUID
+# define seteuid(e) setreuid(-1, (e))
+# else /* NOT HAVE_SETREUID */
+# ifdef HAVE_SETRESUID
+# define seteuid(e) setresuid(-1, (e), -1)
+# else /* NOT HAVE_SETRESUID */
+ /* I can't set euid. (;_;) */
+# endif /* HAVE_SETRESUID */
+# endif /* HAVE_SETREUID */
+#endif /* NO_SETEUID */
+
+static VALUE eChildExited;
+
+/* Returns the exit status of the child for which PTY#check
+ * raised this exception
+ */
+static VALUE
+echild_status(VALUE self)
+{
+ return rb_ivar_get(self, rb_intern("status"));
+}
+
+struct pty_info {
+ int fd;
+ rb_pid_t child_pid;
+};
+
+static void getDevice(int*, int*, char [DEVICELEN], int);
+
+struct child_info {
+ int master, slave;
+ char *slavename;
+ VALUE execarg_obj;
+ struct rb_execarg *eargp;
+};
+
+static int
+chfunc(void *data, char *errbuf, size_t errbuf_len)
+{
+ struct child_info *carg = data;
+ int master = carg->master;
+ int slave = carg->slave;
+
+#define ERROR_EXIT(str) do { \
+ strlcpy(errbuf, (str), errbuf_len); \
+ return -1; \
+ } while (0)
+
+ /*
+ * Set free from process group and controlling terminal
+ */
+#ifdef HAVE_SETSID
+ (void) setsid();
+#else /* HAS_SETSID */
+# ifdef HAVE_SETPGRP
+# ifdef SETGRP_VOID
+ if (setpgrp() == -1)
+ ERROR_EXIT("setpgrp()");
+# else /* SETGRP_VOID */
+ if (setpgrp(0, getpid()) == -1)
+ ERROR_EXIT("setpgrp()");
+ {
+ int i = rb_cloexec_open("/dev/tty", O_RDONLY, 0);
+ if (i < 0) ERROR_EXIT("/dev/tty");
+ rb_update_max_fd(i);
+ if (ioctl(i, TIOCNOTTY, (char *)0))
+ ERROR_EXIT("ioctl(TIOCNOTTY)");
+ close(i);
+ }
+# endif /* SETGRP_VOID */
+# endif /* HAVE_SETPGRP */
+#endif /* HAS_SETSID */
+
+ /*
+ * obtain new controlling terminal
+ */
+#if defined(TIOCSCTTY)
+ close(master);
+ (void) ioctl(slave, TIOCSCTTY, (char *)0);
+ /* errors ignored for sun */
+#else
+ close(slave);
+ slave = rb_cloexec_open(carg->slavename, O_RDWR, 0);
+ if (slave < 0) {
+ ERROR_EXIT("open: pty slave");
+ }
+ rb_update_max_fd(slave);
+ close(master);
+#endif
+ dup2(slave,0);
+ dup2(slave,1);
+ dup2(slave,2);
+ close(slave);
+#if defined(HAVE_SETEUID) || defined(HAVE_SETREUID) || defined(HAVE_SETRESUID)
+ if (seteuid(getuid())) ERROR_EXIT("seteuid()");
+#endif
+
+ return rb_exec_async_signal_safe(carg->eargp, errbuf, sizeof(errbuf_len));
+#undef ERROR_EXIT
+}
+
+static void
+establishShell(int argc, VALUE *argv, struct pty_info *info,
+ char SlaveName[DEVICELEN])
+{
+ int master, slave, status = 0;
+ rb_pid_t pid;
+ char *p, *getenv();
+ struct passwd *pwent;
+ VALUE v;
+ struct child_info carg;
+ char errbuf[32];
+
+ if (argc == 0) {
+ const char *shellname;
+
+ if ((p = getenv("SHELL")) != NULL) {
+ shellname = p;
+ }
+ else {
+ pwent = getpwuid(getuid());
+ if (pwent && pwent->pw_shell)
+ shellname = pwent->pw_shell;
+ else
+ shellname = "/bin/sh";
+ }
+ v = rb_str_new2(shellname);
+ argc = 1;
+ argv = &v;
+ }
+
+ carg.execarg_obj = rb_execarg_new(argc, argv, 1);
+ carg.eargp = rb_execarg_get(carg.execarg_obj);
+ rb_execarg_fixup(carg.execarg_obj);
+
+ getDevice(&master, &slave, SlaveName, 0);
+
+ carg.master = master;
+ carg.slave = slave;
+ carg.slavename = SlaveName;
+ errbuf[0] = '\0';
+ pid = rb_fork_async_signal_safe(&status, chfunc, &carg, Qnil, errbuf, sizeof(errbuf));
+
+ if (pid < 0) {
+ int e = errno;
+ close(master);
+ close(slave);
+ errno = e;
+ if (status) rb_jump_tag(status);
+ rb_sys_fail(errbuf[0] ? errbuf : "fork failed");
+ }
+
+ close(slave);
+
+ info->child_pid = pid;
+ info->fd = master;
+
+ RB_GC_GUARD(carg.execarg_obj);
+}
+
+static int
+no_mesg(char *slavedevice, int nomesg)
+{
+ if (nomesg)
+ return chmod(slavedevice, 0600);
+ else
+ return 0;
+}
+
+static int
+get_device_once(int *master, int *slave, char SlaveName[DEVICELEN], int nomesg, int fail)
+{
+#if defined(HAVE_POSIX_OPENPT)
+ /* Unix98 PTY */
+ int masterfd = -1, slavefd = -1;
+ char *slavedevice;
+ struct sigaction dfl, old;
+
+ dfl.sa_handler = SIG_DFL;
+ dfl.sa_flags = 0;
+ sigemptyset(&dfl.sa_mask);
+
+#if defined(__sun) || (defined(__FreeBSD__) && __FreeBSD_version < 902000)
+ /* workaround for Solaris 10: grantpt() doesn't work if FD_CLOEXEC is set. [ruby-dev:44688] */
+ /* FreeBSD 9.2 or later supports O_CLOEXEC
+ * http://www.freebsd.org/cgi/query-pr.cgi?pr=162374 */
+ if ((masterfd = posix_openpt(O_RDWR|O_NOCTTY)) == -1) goto error;
+ if (sigaction(SIGCHLD, &dfl, &old) == -1) goto error;
+ if (grantpt(masterfd) == -1) goto grantpt_error;
+ rb_fd_fix_cloexec(masterfd);
+#else
+ {
+ int flags = O_RDWR|O_NOCTTY;
+# if defined(O_CLOEXEC)
+ /* glibc posix_openpt() in GNU/Linux calls open("/dev/ptmx", flags) internally.
+ * So version dependency on GNU/Linux is same as O_CLOEXEC with open().
+ * O_CLOEXEC is available since Linux 2.6.23. Linux 2.6.18 silently ignore it. */
+ flags |= O_CLOEXEC;
+# endif
+ if ((masterfd = posix_openpt(flags)) == -1) goto error;
+ }
+ rb_fd_fix_cloexec(masterfd);
+ if (sigaction(SIGCHLD, &dfl, &old) == -1) goto error;
+ if (grantpt(masterfd) == -1) goto grantpt_error;
+#endif
+ if (sigaction(SIGCHLD, &old, NULL) == -1) goto error;
+ if (unlockpt(masterfd) == -1) goto error;
+ if ((slavedevice = ptsname(masterfd)) == NULL) goto error;
+ if (no_mesg(slavedevice, nomesg) == -1) goto error;
+ if ((slavefd = rb_cloexec_open(slavedevice, O_RDWR|O_NOCTTY, 0)) == -1) goto error;
+ rb_update_max_fd(slavefd);
+
+#if defined(I_PUSH) && !defined(__linux__) && !defined(_AIX)
+ if (ioctl(slavefd, I_PUSH, "ptem") == -1) goto error;
+ if (ioctl(slavefd, I_PUSH, "ldterm") == -1) goto error;
+ if (ioctl(slavefd, I_PUSH, "ttcompat") == -1) goto error;
+#endif
+
+ *master = masterfd;
+ *slave = slavefd;
+ strlcpy(SlaveName, slavedevice, DEVICELEN);
+ return 0;
+
+ grantpt_error:
+ sigaction(SIGCHLD, &old, NULL);
+ error:
+ if (slavefd != -1) close(slavefd);
+ if (masterfd != -1) close(masterfd);
+ if (fail) {
+ rb_raise(rb_eRuntimeError, "can't get Master/Slave device");
+ }
+ return -1;
+#elif defined HAVE_OPENPTY
+/*
+ * Use openpty(3) of 4.3BSD Reno and later,
+ * or the same interface function.
+ */
+ if (openpty(master, slave, SlaveName,
+ (struct termios *)0, (struct winsize *)0) == -1) {
+ if (!fail) return -1;
+ rb_raise(rb_eRuntimeError, "openpty() failed");
+ }
+ rb_fd_fix_cloexec(*master);
+ rb_fd_fix_cloexec(*slave);
+ if (no_mesg(SlaveName, nomesg) == -1) {
+ if (!fail) return -1;
+ rb_raise(rb_eRuntimeError, "can't chmod slave pty");
+ }
+
+ return 0;
+
+#elif defined HAVE__GETPTY
+ /* SGI IRIX */
+ char *name;
+ mode_t mode = nomesg ? 0600 : 0622;
+
+ if (!(name = _getpty(master, O_RDWR, mode, 0))) {
+ if (!fail) return -1;
+ rb_raise(rb_eRuntimeError, "_getpty() failed");
+ }
+ rb_fd_fix_cloexec(*master);
+
+ *slave = rb_cloexec_open(name, O_RDWR, 0);
+ /* error check? */
+ rb_update_max_fd(*slave);
+ strlcpy(SlaveName, name, DEVICELEN);
+
+ return 0;
+#elif defined(HAVE_PTSNAME)
+ /* System V */
+ int masterfd = -1, slavefd = -1;
+ char *slavedevice;
+ void (*s)();
+
+ extern char *ptsname(int);
+ extern int unlockpt(int);
+ extern int grantpt(int);
+
+#if defined(__sun)
+ /* workaround for Solaris 10: grantpt() doesn't work if FD_CLOEXEC is set. [ruby-dev:44688] */
+ if((masterfd = open("/dev/ptmx", O_RDWR, 0)) == -1) goto error;
+ s = signal(SIGCHLD, SIG_DFL);
+ if(grantpt(masterfd) == -1) goto error;
+ rb_fd_fix_cloexec(masterfd);
+#else
+ if((masterfd = rb_cloexec_open("/dev/ptmx", O_RDWR, 0)) == -1) goto error;
+ rb_update_max_fd(masterfd);
+ s = signal(SIGCHLD, SIG_DFL);
+ if(grantpt(masterfd) == -1) goto error;
+#endif
+ signal(SIGCHLD, s);
+ if(unlockpt(masterfd) == -1) goto error;
+ if((slavedevice = ptsname(masterfd)) == NULL) goto error;
+ if (no_mesg(slavedevice, nomesg) == -1) goto error;
+ if((slavefd = rb_cloexec_open(slavedevice, O_RDWR, 0)) == -1) goto error;
+ rb_update_max_fd(slavefd);
+#if defined(I_PUSH) && !defined(__linux__) && !defined(_AIX)
+ if(ioctl(slavefd, I_PUSH, "ptem") == -1) goto error;
+ if(ioctl(slavefd, I_PUSH, "ldterm") == -1) goto error;
+ ioctl(slavefd, I_PUSH, "ttcompat");
+#endif
+ *master = masterfd;
+ *slave = slavefd;
+ strlcpy(SlaveName, slavedevice, DEVICELEN);
+ return 0;
+
+ error:
+ if (slavefd != -1) close(slavefd);
+ if (masterfd != -1) close(masterfd);
+ if (fail) rb_raise(rb_eRuntimeError, "can't get Master/Slave device");
+ return -1;
+#else
+ /* BSD */
+ int masterfd = -1, slavefd = -1;
+ const char *const *p;
+ char MasterName[DEVICELEN];
+
+#if defined(__hpux)
+ static const char MasterDevice[] = "/dev/ptym/pty%s";
+ static const char SlaveDevice[] = "/dev/pty/tty%s";
+ static const char *const deviceNo[] = {
+ "p0","p1","p2","p3","p4","p5","p6","p7",
+ "p8","p9","pa","pb","pc","pd","pe","pf",
+ "q0","q1","q2","q3","q4","q5","q6","q7",
+ "q8","q9","qa","qb","qc","qd","qe","qf",
+ "r0","r1","r2","r3","r4","r5","r6","r7",
+ "r8","r9","ra","rb","rc","rd","re","rf",
+ "s0","s1","s2","s3","s4","s5","s6","s7",
+ "s8","s9","sa","sb","sc","sd","se","sf",
+ "t0","t1","t2","t3","t4","t5","t6","t7",
+ "t8","t9","ta","tb","tc","td","te","tf",
+ "u0","u1","u2","u3","u4","u5","u6","u7",
+ "u8","u9","ua","ub","uc","ud","ue","uf",
+ "v0","v1","v2","v3","v4","v5","v6","v7",
+ "v8","v9","va","vb","vc","vd","ve","vf",
+ "w0","w1","w2","w3","w4","w5","w6","w7",
+ "w8","w9","wa","wb","wc","wd","we","wf",
+ 0
+ };
+#elif defined(_IBMESA) /* AIX/ESA */
+ static const char MasterDevice[] = "/dev/ptyp%s";
+ static const char SlaveDevice[] = "/dev/ttyp%s";
+ static const char *const deviceNo[] = {
+ "00","01","02","03","04","05","06","07","08","09","0a","0b","0c","0d","0e","0f",
+ "10","11","12","13","14","15","16","17","18","19","1a","1b","1c","1d","1e","1f",
+ "20","21","22","23","24","25","26","27","28","29","2a","2b","2c","2d","2e","2f",
+ "30","31","32","33","34","35","36","37","38","39","3a","3b","3c","3d","3e","3f",
+ "40","41","42","43","44","45","46","47","48","49","4a","4b","4c","4d","4e","4f",
+ "50","51","52","53","54","55","56","57","58","59","5a","5b","5c","5d","5e","5f",
+ "60","61","62","63","64","65","66","67","68","69","6a","6b","6c","6d","6e","6f",
+ "70","71","72","73","74","75","76","77","78","79","7a","7b","7c","7d","7e","7f",
+ "80","81","82","83","84","85","86","87","88","89","8a","8b","8c","8d","8e","8f",
+ "90","91","92","93","94","95","96","97","98","99","9a","9b","9c","9d","9e","9f",
+ "a0","a1","a2","a3","a4","a5","a6","a7","a8","a9","aa","ab","ac","ad","ae","af",
+ "b0","b1","b2","b3","b4","b5","b6","b7","b8","b9","ba","bb","bc","bd","be","bf",
+ "c0","c1","c2","c3","c4","c5","c6","c7","c8","c9","ca","cb","cc","cd","ce","cf",
+ "d0","d1","d2","d3","d4","d5","d6","d7","d8","d9","da","db","dc","dd","de","df",
+ "e0","e1","e2","e3","e4","e5","e6","e7","e8","e9","ea","eb","ec","ed","ee","ef",
+ "f0","f1","f2","f3","f4","f5","f6","f7","f8","f9","fa","fb","fc","fd","fe","ff",
+ 0
+ };
+#else /* 4.2BSD */
+ static const char MasterDevice[] = "/dev/pty%s";
+ static const char SlaveDevice[] = "/dev/tty%s";
+ static const char *const deviceNo[] = {
+ "p0","p1","p2","p3","p4","p5","p6","p7",
+ "p8","p9","pa","pb","pc","pd","pe","pf",
+ "q0","q1","q2","q3","q4","q5","q6","q7",
+ "q8","q9","qa","qb","qc","qd","qe","qf",
+ "r0","r1","r2","r3","r4","r5","r6","r7",
+ "r8","r9","ra","rb","rc","rd","re","rf",
+ "s0","s1","s2","s3","s4","s5","s6","s7",
+ "s8","s9","sa","sb","sc","sd","se","sf",
+ 0
+ };
+#endif
+ for (p = deviceNo; *p != NULL; p++) {
+ snprintf(MasterName, sizeof MasterName, MasterDevice, *p);
+ if ((masterfd = rb_cloexec_open(MasterName,O_RDWR,0)) >= 0) {
+ rb_update_max_fd(masterfd);
+ *master = masterfd;
+ snprintf(SlaveName, DEVICELEN, SlaveDevice, *p);
+ if ((slavefd = rb_cloexec_open(SlaveName,O_RDWR,0)) >= 0) {
+ rb_update_max_fd(slavefd);
+ *slave = slavefd;
+ if (chown(SlaveName, getuid(), getgid()) != 0) goto error;
+ if (chmod(SlaveName, nomesg ? 0600 : 0622) != 0) goto error;
+ return 0;
+ }
+ close(masterfd);
+ }
+ }
+ error:
+ if (slavefd != -1) close(slavefd);
+ if (masterfd != -1) close(masterfd);
+ if (fail) rb_raise(rb_eRuntimeError, "can't get %s", SlaveName);
+ return -1;
+#endif
+}
+
+static void
+getDevice(int *master, int *slave, char SlaveName[DEVICELEN], int nomesg)
+{
+ if (get_device_once(master, slave, SlaveName, nomesg, 0)) {
+ rb_gc();
+ get_device_once(master, slave, SlaveName, nomesg, 1);
+ }
+}
+
+static VALUE
+pty_close_pty(VALUE assoc)
+{
+ VALUE io;
+ int i;
+
+ for (i = 0; i < 2; i++) {
+ io = rb_ary_entry(assoc, i);
+ if (RB_TYPE_P(io, T_FILE) && 0 <= RFILE(io)->fptr->fd)
+ rb_io_close(io);
+ }
+ return Qnil;
+}
+
+/*
+ * call-seq:
+ * PTY.open => [master_io, slave_file]
+ * PTY.open {|master_io, slave_file| ... } => block value
+ *
+ * Allocates a pty (pseudo-terminal).
+ *
+ * In the block form, yields two arguments <tt>master_io, slave_file</tt>
+ * and the value of the block is returned from +open+.
+ *
+ * The IO and File are both closed after the block completes if they haven't
+ * been already closed.
+ *
+ * PTY.open {|master, slave|
+ * p master #=> #<IO:masterpty:/dev/pts/1>
+ * p slave #=> #<File:/dev/pts/1>
+ * p slave.path #=> "/dev/pts/1"
+ * }
+ *
+ * In the non-block form, returns a two element array, <tt>[master_io,
+ * slave_file]</tt>.
+ *
+ * master, slave = PTY.open
+ * # do something with master for IO, or the slave file
+ *
+ * The arguments in both forms are:
+ *
+ * +master_io+:: the master of the pty, as an IO.
+ * +slave_file+:: the slave of the pty, as a File. The path to the
+ * terminal device is available via +slave_file.path+
+ *
+ */
+static VALUE
+pty_open(VALUE klass)
+{
+ int master_fd, slave_fd;
+ char slavename[DEVICELEN];
+ VALUE master_io, slave_file;
+ rb_io_t *master_fptr, *slave_fptr;
+ VALUE assoc;
+
+ getDevice(&master_fd, &slave_fd, slavename, 1);
+
+ master_io = rb_obj_alloc(rb_cIO);
+ MakeOpenFile(master_io, master_fptr);
+ master_fptr->mode = FMODE_READWRITE | FMODE_SYNC | FMODE_DUPLEX;
+ master_fptr->fd = master_fd;
+ master_fptr->pathv = rb_obj_freeze(rb_sprintf("masterpty:%s", slavename));
+
+ slave_file = rb_obj_alloc(rb_cFile);
+ MakeOpenFile(slave_file, slave_fptr);
+ slave_fptr->mode = FMODE_READWRITE | FMODE_SYNC | FMODE_DUPLEX | FMODE_TTY;
+ slave_fptr->fd = slave_fd;
+ slave_fptr->pathv = rb_obj_freeze(rb_str_new_cstr(slavename));
+
+ assoc = rb_assoc_new(master_io, slave_file);
+ if (rb_block_given_p()) {
+ return rb_ensure(rb_yield, assoc, pty_close_pty, assoc);
+ }
+ return assoc;
+}
+
+static VALUE
+pty_detach_process(struct pty_info *info)
+{
+#ifdef WNOHANG
+ int st;
+ if (rb_waitpid(info->child_pid, &st, WNOHANG) <= 0)
+ return Qnil;
+#endif
+ rb_detach_process(info->child_pid);
+ return Qnil;
+}
+
+/*
+ * call-seq:
+ * PTY.spawn(command_line) { |r, w, pid| ... }
+ * PTY.spawn(command_line) => [r, w, pid]
+ * PTY.spawn(command, arguments, ...) { |r, w, pid| ... }
+ * PTY.spawn(command, arguments, ...) => [r, w, pid]
+ *
+ * Spawns the specified command on a newly allocated pty. You can also use the
+ * alias ::getpty.
+ *
+ * The command's controlling tty is set to the slave device of the pty
+ * and its standard input/output/error is redirected to the slave device.
+ *
+ * +command+ and +command_line+ are the full commands to run, given a String.
+ * Any additional +arguments+ will be passed to the command.
+ *
+ * === Return values
+ *
+ * In the non-block form this returns an array of size three,
+ * <tt>[r, w, pid]</tt>.
+ *
+ * In the block form these same values will be yielded to the block:
+ *
+ * +r+:: A readable IO that that contains the command's
+ * standard output and standard error
+ * +w+:: A writable IO that is the command's standard input
+ * +pid+:: The process identifier for the command.
+ */
+static VALUE
+pty_getpty(int argc, VALUE *argv, VALUE self)
+{
+ VALUE res;
+ struct pty_info info;
+ rb_io_t *wfptr,*rfptr;
+ VALUE rport = rb_obj_alloc(rb_cFile);
+ VALUE wport = rb_obj_alloc(rb_cFile);
+ char SlaveName[DEVICELEN];
+
+ MakeOpenFile(rport, rfptr);
+ MakeOpenFile(wport, wfptr);
+
+ establishShell(argc, argv, &info, SlaveName);
+
+ rfptr->mode = rb_io_modestr_fmode("r");
+ rfptr->fd = info.fd;
+ rfptr->pathv = rb_obj_freeze(rb_str_new_cstr(SlaveName));
+
+ wfptr->mode = rb_io_modestr_fmode("w") | FMODE_SYNC;
+ wfptr->fd = rb_cloexec_dup(info.fd);
+ if (wfptr->fd == -1)
+ rb_sys_fail("dup()");
+ rb_update_max_fd(wfptr->fd);
+ wfptr->pathv = rfptr->pathv;
+
+ res = rb_ary_new2(3);
+ rb_ary_store(res,0,(VALUE)rport);
+ rb_ary_store(res,1,(VALUE)wport);
+ rb_ary_store(res,2,PIDT2NUM(info.child_pid));
+
+ if (rb_block_given_p()) {
+ rb_ensure(rb_yield, res, pty_detach_process, (VALUE)&info);
+ return Qnil;
+ }
+ return res;
+}
+
+NORETURN(static void raise_from_check(rb_pid_t pid, int status));
+static void
+raise_from_check(rb_pid_t pid, int status)
+{
+ const char *state;
+ VALUE msg;
+ VALUE exc;
+
+#if defined(WIFSTOPPED)
+#elif defined(IF_STOPPED)
+#define WIFSTOPPED(status) IF_STOPPED(status)
+#else
+---->> Either IF_STOPPED or WIFSTOPPED is needed <<----
+#endif /* WIFSTOPPED | IF_STOPPED */
+ if (WIFSTOPPED(status)) { /* suspend */
+ state = "stopped";
+ }
+ else if (kill(pid, 0) == 0) {
+ state = "changed";
+ }
+ else {
+ state = "exited";
+ }
+ msg = rb_sprintf("pty - %s: %ld", state, (long)pid);
+ exc = rb_exc_new_str(eChildExited, msg);
+ rb_iv_set(exc, "status", rb_last_status_get());
+ rb_exc_raise(exc);
+}
+
+/*
+ * call-seq:
+ * PTY.check(pid, raise = false) => Process::Status or nil
+ * PTY.check(pid, true) => nil or raises PTY::ChildExited
+ *
+ * Checks the status of the child process specified by +pid+.
+ * Returns +nil+ if the process is still alive.
+ *
+ * If the process is not alive, and +raise+ was true, a PTY::ChildExited
+ * exception will be raised. Otherwise it will return a Process::Status
+ * instance.
+ *
+ * +pid+:: The process id of the process to check
+ * +raise+:: If +true+ and the process identified by +pid+ is no longer
+ * alive a PTY::ChildExited is raised.
+ *
+ */
+static VALUE
+pty_check(int argc, VALUE *argv, VALUE self)
+{
+ VALUE pid, exc;
+ rb_pid_t cpid;
+ int status;
+
+ rb_scan_args(argc, argv, "11", &pid, &exc);
+ cpid = rb_waitpid(NUM2PIDT(pid), &status, WNOHANG|WUNTRACED);
+ if (cpid == -1 || cpid == 0) return Qnil;
+
+ if (!RTEST(exc)) return rb_last_status_get();
+ raise_from_check(cpid, status);
+
+ UNREACHABLE;
+}
+
+static VALUE cPTY;
+
+/*
+ * Document-class: PTY::ChildExited
+ *
+ * Thrown when PTY::check is called for a pid that represents a process that
+ * has exited.
+ */
+
+/*
+ * Document-class: PTY
+ *
+ * Creates and managed pseudo terminals (PTYs). See also
+ * http://en.wikipedia.org/wiki/Pseudo_terminal
+ *
+ * PTY allows you to allocate new terminals using ::open or ::spawn a new
+ * terminal with a specific command.
+ *
+ * == Example
+ *
+ * In this example we will change the buffering type in the +factor+ command,
+ * assuming that factor uses stdio for stdout buffering.
+ *
+ * If IO.pipe is used instead of PTY.open, this code deadlocks because factor's
+ * stdout is fully buffered.
+ *
+ * # start by requiring the standard library PTY
+ * require 'pty'
+ *
+ * master, slave = PTY.open
+ * read, write = IO.pipe
+ * pid = spawn("factor", :in=>read, :out=>slave)
+ * read.close # we dont need the read
+ * slave.close # or the slave
+ *
+ * # pipe "42" to the factor command
+ * write.puts "42"
+ * # output the response from factor
+ * p master.gets #=> "42: 2 3 7\n"
+ *
+ * # pipe "144" to factor and print out the response
+ * write.puts "144"
+ * p master.gets #=> "144: 2 2 2 2 3 3\n"
+ * write.close # close the pipe
+ *
+ * # The result of read operation when pty slave is closed is platform
+ * # dependent.
+ * ret = begin
+ * m.gets # FreeBSD returns nil.
+ * rescue Errno::EIO # GNU/Linux raises EIO.
+ * nil
+ * end
+ * p ret #=> nil
+ *
+ * == License
+ *
+ * C) Copyright 1998 by Akinori Ito.
+ *
+ * This software may be redistributed freely for this purpose, in full
+ * or in part, provided that this entire copyright notice is included
+ * on any copies of this software and applications and derivations thereof.
+ *
+ * This software is provided on an "as is" basis, without warranty of any
+ * kind, either expressed or implied, as to any matter including, but not
+ * limited to warranty of fitness of purpose, or merchantability, or
+ * results obtained from use of this software.
+ */
+
+void
+Init_pty(void)
+{
+ cPTY = rb_define_module("PTY");
+ /* :nodoc: */
+ rb_define_module_function(cPTY,"getpty",pty_getpty,-1);
+ rb_define_module_function(cPTY,"spawn",pty_getpty,-1);
+ rb_define_singleton_method(cPTY,"check",pty_check,-1);
+ rb_define_singleton_method(cPTY,"open",pty_open,0);
+
+ eChildExited = rb_define_class_under(cPTY,"ChildExited",rb_eRuntimeError);
+ rb_define_method(eChildExited,"status",echild_status,0);
+}
diff --git a/jni/ruby/ext/racc/cparse/Makefile b/jni/ruby/ext/racc/cparse/Makefile
new file mode 100644
index 0000000..ca5e412
--- /dev/null
+++ b/jni/ruby/ext/racc/cparse/Makefile
@@ -0,0 +1,267 @@
+
+SHELL = /bin/sh
+
+# V=0 quiet, V=1 verbose. other values don't work.
+V = 0
+Q1 = $(V:1=)
+Q = $(Q1:0=@)
+ECHO1 = $(V:1=@:)
+ECHO = $(ECHO1:0=@echo)
+NULLCMD = :
+
+#### Start of system configuration section. ####
+top_srcdir = $(topdir)/.
+srcdir = $(top_srcdir)/ext/racc/cparse
+topdir = ../../..
+hdrdir = $(top_srcdir)/include
+arch_hdrdir = $(extout)/include/$(arch)
+PATH_SEPARATOR = :
+VPATH = $(srcdir):$(arch_hdrdir)/ruby:$(hdrdir)/ruby
+RUBYLIB =
+RUBYOPT = -
+prefix = $(DESTDIR)/usr/local
+rubysitearchprefix = $(rubylibprefix)/$(sitearch)
+rubyarchprefix = $(rubylibprefix)/$(arch)
+rubylibprefix = $(libdir)/$(RUBY_BASE_NAME)
+exec_prefix = $(prefix)
+vendorarchhdrdir = $(vendorhdrdir)/$(sitearch)
+sitearchhdrdir = $(sitehdrdir)/$(sitearch)
+rubyarchhdrdir = $(rubyhdrdir)/$(arch)
+vendorhdrdir = $(rubyhdrdir)/vendor_ruby
+sitehdrdir = $(rubyhdrdir)/site_ruby
+rubyhdrdir = $(includedir)/$(RUBY_VERSION_NAME)
+vendorarchdir = $(vendorlibdir)/$(sitearch)
+vendorlibdir = $(vendordir)/$(ruby_version)
+vendordir = $(rubylibprefix)/vendor_ruby
+sitearchdir = $(sitelibdir)/$(sitearch)
+sitelibdir = $(sitedir)/$(ruby_version)
+sitedir = $(rubylibprefix)/site_ruby
+rubyarchdir = $(rubylibdir)/$(arch)
+rubylibdir = $(rubylibprefix)/$(ruby_version)
+sitearchincludedir = $(includedir)/$(sitearch)
+archincludedir = $(includedir)/$(arch)
+sitearchlibdir = $(libdir)/$(sitearch)
+archlibdir = $(libdir)/$(arch)
+ridir = $(datarootdir)/$(RI_BASE_NAME)
+mandir = $(datarootdir)/man
+localedir = $(datarootdir)/locale
+libdir = $(exec_prefix)/lib
+psdir = $(docdir)
+pdfdir = $(docdir)
+dvidir = $(docdir)
+htmldir = $(docdir)
+infodir = $(datarootdir)/info
+docdir = $(datarootdir)/doc/$(PACKAGE)
+oldincludedir = $(DESTDIR)/usr/include
+includedir = $(prefix)/include
+localstatedir = $(prefix)/var
+sharedstatedir = $(prefix)/com
+sysconfdir = $(prefix)/etc
+datadir = $(datarootdir)
+datarootdir = $(prefix)/share
+libexecdir = $(exec_prefix)/libexec
+sbindir = $(exec_prefix)/sbin
+bindir = $(exec_prefix)/bin
+archdir = $(rubyarchdir)
+
+
+CC = gcc
+CXX = g++
+LIBRUBY = $(LIBRUBY_SO)
+LIBRUBY_A = lib$(RUBY_SO_NAME)-static.a
+LIBRUBYARG_SHARED = -Wl,-R$(libdir) -L$(libdir) -l$(RUBY_SO_NAME)
+LIBRUBYARG_STATIC = -Wl,-R$(libdir) -L$(libdir) -l$(RUBY_SO_NAME)-static
+empty =
+OUTFLAG = -o $(empty)
+COUTFLAG = -o $(empty)
+
+RUBY_EXTCONF_H = extconf.h
+cflags = $(optflags) $(debugflags) $(warnflags)
+optflags = -O3 -fno-fast-math
+debugflags = -ggdb3
+warnflags = -Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wunused-variable -Wpointer-arith -Wwrite-strings -Wdeclaration-after-statement -Wimplicit-function-declaration -Wdeprecated-declarations -Wno-packed-bitfield-compat
+CCDLFLAGS = -fPIC
+CFLAGS = $(CCDLFLAGS) $(cflags) -fPIC $(ARCH_FLAG)
+INCFLAGS = -I. -I$(arch_hdrdir) -I$(hdrdir) -I$(srcdir)
+DEFS =
+CPPFLAGS = -DRUBY_EXTCONF_H=\"$(RUBY_EXTCONF_H)\" $(DEFS) $(cppflags)
+CXXFLAGS = $(CCDLFLAGS) $(cxxflags) $(ARCH_FLAG)
+ldflags = -L. -fstack-protector -rdynamic -Wl,-export-dynamic
+dldflags =
+ARCH_FLAG =
+DLDFLAGS = $(ldflags) $(dldflags) $(ARCH_FLAG)
+LDSHARED = $(CC) -shared
+LDSHAREDXX = $(CXX) -shared
+AR = ar
+EXEEXT =
+
+RUBY_INSTALL_NAME = $(RUBY_BASE_NAME)
+RUBY_SO_NAME = ruby
+RUBYW_INSTALL_NAME =
+RUBY_VERSION_NAME = $(RUBY_BASE_NAME)-$(ruby_version)
+RUBYW_BASE_NAME = rubyw
+RUBY_BASE_NAME = ruby
+
+arch = x86_64-linux
+sitearch = $(arch)
+ruby_version = 2.2.0
+ruby = $(topdir)/miniruby -I'$(topdir)' -I'$(top_srcdir)/lib' -I'$(extout)/$(arch)' -I'$(extout)/common'
+RUBY = $(ruby)
+ruby_headers = $(hdrdir)/ruby.h $(hdrdir)/ruby/ruby.h $(hdrdir)/ruby/defines.h $(hdrdir)/ruby/missing.h $(hdrdir)/ruby/intern.h $(hdrdir)/ruby/st.h $(hdrdir)/ruby/subst.h $(arch_hdrdir)/ruby/config.h $(RUBY_EXTCONF_H)
+
+RM = rm -f
+RM_RF = $(RUBY) -run -e rm -- -rf
+RMDIRS = rmdir --ignore-fail-on-non-empty -p
+MAKEDIRS = /bin/mkdir -p
+INSTALL = /usr/bin/install -c
+INSTALL_PROG = $(INSTALL) -m 0755
+INSTALL_DATA = $(INSTALL) -m 644
+COPY = cp
+TOUCH = exit >
+
+#### End of system configuration section. ####
+
+preload =
+
+libpath = . $(topdir)
+LIBPATH = -L. -L$(topdir)
+DEFFILE =
+
+CLEANFILES = mkmf.log
+DISTCLEANFILES =
+DISTCLEANDIRS =
+
+extout = $(topdir)/.ext
+extout_prefix = $(extout)$(target_prefix)/
+target_prefix = /racc
+LOCAL_LIBS =
+LIBS = $(LIBRUBYARG_SHARED) -lpthread -lgmp -ldl -lcrypt -lm -lc
+ORIG_SRCS = cparse.c
+SRCS = $(ORIG_SRCS)
+OBJS = cparse.o
+HDRS = $(srcdir)/extconf.h
+TARGET = cparse
+TARGET_NAME = cparse
+TARGET_ENTRY = Init_$(TARGET_NAME)
+DLLIB = $(TARGET).so
+EXTSTATIC =
+STATIC_LIB = $(TARGET).a
+
+TIMESTAMP_DIR = $(extout)/.timestamp
+BINDIR = $(extout)/bin
+RUBYCOMMONDIR = $(extout)/common
+RUBYLIBDIR = $(RUBYCOMMONDIR)$(target_prefix)
+RUBYARCHDIR = $(extout)/$(arch)$(target_prefix)
+HDRDIR = $(extout)/include/ruby$(target_prefix)
+ARCHHDRDIR = $(extout)/include/$(arch)/ruby$(target_prefix)
+
+TARGET_SO = $(RUBYARCHDIR)/$(DLLIB)
+CLEANLIBS = $(RUBYARCHDIR)/$(TARGET).so
+CLEANOBJS = *.o *.bak
+
+all: install
+static: all
+.PHONY: all install static install-so install-rb
+.PHONY: clean clean-so clean-static clean-rb
+
+clean-static::
+clean-rb-default::
+clean-rb::
+clean-so::
+clean: clean-so clean-static clean-rb-default clean-rb
+ -$(Q)$(RM) $(CLEANLIBS) $(CLEANOBJS) $(CLEANFILES) .*.time
+
+distclean-rb-default::
+distclean-rb::
+distclean-so::
+distclean-static::
+distclean: clean distclean-so distclean-static distclean-rb-default distclean-rb
+ -$(Q)$(RM) Makefile $(RUBY_EXTCONF_H) conftest.* mkmf.log
+ -$(Q)$(RM) core ruby$(EXEEXT) *~ $(DISTCLEANFILES)
+ -$(Q)$(RMDIRS) $(DISTCLEANDIRS) 2> /dev/null || true
+
+realclean: distclean
+install: install-so install-rb
+
+install-so: $(RUBYARCHDIR)/$(DLLIB)
+clean-so::
+ -$(Q)$(RM) $(RUBYARCHDIR)/$(DLLIB)
+ -$(Q)$(RMDIRS) $(RUBYARCHDIR) 2> /dev/null || true
+clean-static::
+ -$(Q)$(RM) $(STATIC_LIB)
+install-rb: pre-install-rb install-rb-default
+install-rb-default: pre-install-rb-default
+pre-install-rb: Makefile
+pre-install-rb-default: Makefile
+pre-install-rb-default:
+ @$(NULLCMD)
+$(TIMESTAMP_DIR)/.RUBYARCHDIR.-.racc.time:
+ $(Q) $(MAKEDIRS) $(@D) $(RUBYARCHDIR)
+ $(Q) $(TOUCH) $@
+
+site-install: site-install-so site-install-rb
+site-install-so: install-so
+site-install-rb: install-rb
+
+.SUFFIXES: .c .m .cc .mm .cxx .cpp .o .S
+
+.cc.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<
+
+.cc.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -S $<
+
+.mm.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<
+
+.mm.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -S $<
+
+.cxx.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<
+
+.cxx.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -S $<
+
+.cpp.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<
+
+.cpp.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -S $<
+
+.c.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -c $<
+
+.c.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -S $<
+
+.m.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -c $<
+
+.m.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -S $<
+
+$(RUBYARCHDIR)/$(DLLIB): $(OBJS) Makefile $(TIMESTAMP_DIR)/.RUBYARCHDIR.-.racc.time
+ $(ECHO) linking shared-object racc/$(DLLIB)
+ -$(Q)$(RM) $(@)
+ $(Q) $(LDSHARED) -o $@ $(OBJS) $(LIBPATH) $(DLDFLAGS) $(LOCAL_LIBS) $(LIBS)
+
+$(STATIC_LIB): $(OBJS)
+ -$(Q)$(RM) $(@)
+ $(ECHO) linking static-library $(@)
+ $(Q) $(AR) cru $@ $(OBJS)
+ -$(Q)ranlib $(@) 2> /dev/null || true
+
+$(OBJS): $(HDRS) $(ruby_headers)
diff --git a/jni/ruby/ext/racc/cparse/README b/jni/ruby/ext/racc/cparse/README
new file mode 100644
index 0000000..7771108
--- /dev/null
+++ b/jni/ruby/ext/racc/cparse/README
@@ -0,0 +1,11 @@
+Racc Runtime README
+===================
+
+This directory contains a runtime library of
+Racc parser generator. If you want to generate
+your own parser, you must get Racc full package.
+Get it from:
+
+ - http://i.loveruby.net/en/projects/racc
+ - https://github.com/tenderlove/racc
+
diff --git a/jni/ruby/ext/racc/cparse/cparse.c b/jni/ruby/ext/racc/cparse/cparse.c
new file mode 100644
index 0000000..b4429ed
--- /dev/null
+++ b/jni/ruby/ext/racc/cparse/cparse.c
@@ -0,0 +1,857 @@
+/*
+
+ cparse.c -- Racc Runtime Core
+
+ Copyright (c) 1999-2006 Minero Aoki
+
+ This library is free software.
+ You can distribute/modify this program under the same terms of ruby.
+
+ $originalId: cparse.c,v 1.8 2006/07/06 11:39:46 aamine Exp $
+
+*/
+
+#include "ruby/ruby.h"
+
+#ifndef FALSE
+#define FALSE 0
+#endif
+#ifndef TRUE
+#define TRUE 1
+#endif
+
+/* -----------------------------------------------------------------------
+ Important Constants
+----------------------------------------------------------------------- */
+
+#define RACC_VERSION "1.4.5"
+
+#define DEFAULT_TOKEN -1
+#define ERROR_TOKEN 1
+#define FINAL_TOKEN 0
+
+#define vDEFAULT_TOKEN INT2FIX(DEFAULT_TOKEN)
+#define vERROR_TOKEN INT2FIX(ERROR_TOKEN)
+#define vFINAL_TOKEN INT2FIX(FINAL_TOKEN)
+
+/* -----------------------------------------------------------------------
+ File Local Variables
+----------------------------------------------------------------------- */
+
+static VALUE RaccBug;
+static VALUE CparseParams;
+
+static ID id_yydebug;
+static ID id_nexttoken;
+static ID id_onerror;
+static ID id_noreduce;
+static ID id_errstatus;
+
+static ID id_d_shift;
+static ID id_d_reduce;
+static ID id_d_accept;
+static ID id_d_read_token;
+static ID id_d_next_state;
+static ID id_d_e_pop;
+
+/* -----------------------------------------------------------------------
+ Utils
+----------------------------------------------------------------------- */
+
+/* For backward compatibility */
+#ifndef ID2SYM
+# define ID2SYM(i) ULONG2NUM(i)
+#endif
+#ifndef SYM2ID
+# define SYM2ID(v) ((ID)NUM2ULONG(v))
+#endif
+#ifndef SYMBOL_P
+# define SYMBOL_P(v) FIXNUM_P(v)
+#endif
+#ifndef LONG2NUM
+# define LONG2NUM(i) INT2NUM(i)
+#endif
+
+static ID value_to_id _((VALUE v));
+static inline long num_to_long _((VALUE n));
+
+static ID
+value_to_id(VALUE v)
+{
+ if (! SYMBOL_P(v)) {
+ rb_raise(rb_eTypeError, "not symbol");
+ }
+ return SYM2ID(v);
+}
+
+static inline long
+num_to_long(VALUE n)
+{
+ return NUM2LONG(n);
+}
+
+#define AREF(s, idx) \
+ ((0 <= idx && idx < RARRAY_LEN(s)) ? rb_ary_entry(s, idx) : Qnil)
+
+/* -----------------------------------------------------------------------
+ Parser Stack Interfaces
+----------------------------------------------------------------------- */
+
+static VALUE get_stack_tail _((VALUE stack, long len));
+static void cut_stack_tail _((VALUE stack, long len));
+
+static VALUE
+get_stack_tail(VALUE stack, long len)
+{
+ if (len < 0) return Qnil; /* system error */
+ if (len > RARRAY_LEN(stack)) len = RARRAY_LEN(stack);
+ return rb_ary_subseq(stack, RARRAY_LEN(stack) - len, len);
+}
+
+static void
+cut_stack_tail(VALUE stack, long len)
+{
+ while (len > 0) {
+ rb_ary_pop(stack);
+ len--;
+ }
+}
+
+#define STACK_INIT_LEN 64
+#define NEW_STACK() rb_ary_new2(STACK_INIT_LEN)
+#define PUSH(s, i) rb_ary_store(s, RARRAY_LEN(s), i)
+#define POP(s) rb_ary_pop(s)
+#define LAST_I(s) \
+ ((RARRAY_LEN(s) > 0) ? rb_ary_entry(s, RARRAY_LEN(s) - 1) : Qnil)
+#define GET_TAIL(s, len) get_stack_tail(s, len)
+#define CUT_TAIL(s, len) cut_stack_tail(s, len)
+
+/* -----------------------------------------------------------------------
+ struct cparse_params
+----------------------------------------------------------------------- */
+
+struct cparse_params {
+ VALUE value_v; /* VALUE version of this struct */
+
+ VALUE parser; /* parser object */
+
+ int lex_is_iterator;
+ VALUE lexer; /* scanner object */
+ ID lexmid; /* name of scanner method (must be an iterator) */
+
+ /* State transition tables (immutable)
+ Data structure is from Dragon Book 4.9 */
+ /* action table */
+ VALUE action_table;
+ VALUE action_check;
+ VALUE action_default;
+ VALUE action_pointer;
+ /* goto table */
+ VALUE goto_table;
+ VALUE goto_check;
+ VALUE goto_default;
+ VALUE goto_pointer;
+
+ long nt_base; /* NonTerminal BASE index */
+ VALUE reduce_table; /* reduce data table */
+ VALUE token_table; /* token conversion table */
+
+ /* parser stacks and parameters */
+ VALUE state;
+ long curstate;
+ VALUE vstack;
+ VALUE tstack;
+ VALUE t;
+ long shift_n;
+ long reduce_n;
+ long ruleno;
+
+ long errstatus; /* nonzero in error recovering mode */
+ long nerr; /* number of error */
+
+ int use_result_var;
+
+ VALUE retval; /* return value of parser routine */
+ long fin; /* parse result status */
+#define CP_FIN_ACCEPT 1
+#define CP_FIN_EOT 2
+#define CP_FIN_CANTPOP 3
+
+ int debug; /* user level debug */
+ int sys_debug; /* system level debug */
+
+ long i; /* table index */
+};
+
+/* -----------------------------------------------------------------------
+ Parser Main Routines
+----------------------------------------------------------------------- */
+
+static VALUE racc_cparse _((VALUE parser, VALUE arg, VALUE sysdebug));
+static VALUE racc_yyparse _((VALUE parser, VALUE lexer, VALUE lexmid,
+ VALUE arg, VALUE sysdebug));
+
+static void call_lexer _((struct cparse_params *v));
+static VALUE lexer_i _((RB_BLOCK_CALL_FUNC_ARGLIST(block_args, data)));
+
+static VALUE assert_array _((VALUE a));
+static long assert_integer _((VALUE n));
+static VALUE assert_hash _((VALUE h));
+static VALUE initialize_params _((VALUE vparams, VALUE parser, VALUE arg,
+ VALUE lexer, VALUE lexmid));
+static void cparse_params_mark _((void *ptr));
+static size_t cparse_params_memsize _((const void *ptr));
+
+static void parse_main _((struct cparse_params *v,
+ VALUE tok, VALUE val, int resume));
+static void extract_user_token _((struct cparse_params *v,
+ VALUE block_args, VALUE *tok, VALUE *val));
+static void shift _((struct cparse_params* v, long act, VALUE tok, VALUE val));
+static int reduce _((struct cparse_params* v, long act));
+static VALUE reduce0 _((VALUE block_args, VALUE data, VALUE self));
+
+#ifdef DEBUG
+# define D_puts(msg) if (v->sys_debug) puts(msg)
+# define D_printf(fmt,arg) if (v->sys_debug) printf(fmt,arg)
+#else
+# define D_puts(msg)
+# define D_printf(fmt,arg)
+#endif
+
+#undef RUBY_UNTYPED_DATA_WARNING
+#define RUBY_UNTYPED_DATA_WARNING 1
+
+static const rb_data_type_t cparse_params_type = {
+ "racc/cparse",
+ {
+ cparse_params_mark,
+ RUBY_TYPED_DEFAULT_FREE,
+ cparse_params_memsize,
+ },
+#ifdef RUBY_TYPED_FREE_IMMEDIATELY
+ 0, 0,
+ RUBY_TYPED_FREE_IMMEDIATELY,
+#endif
+};
+
+static VALUE
+racc_cparse(VALUE parser, VALUE arg, VALUE sysdebug)
+{
+ VALUE vparams;
+ struct cparse_params *v;
+
+ vparams = TypedData_Make_Struct(CparseParams, struct cparse_params,
+ &cparse_params_type, v);
+ D_puts("starting cparse");
+ v->sys_debug = RTEST(sysdebug);
+ vparams = initialize_params(vparams, parser, arg, Qnil, Qnil);
+ v->lex_is_iterator = FALSE;
+ parse_main(v, Qnil, Qnil, 0);
+
+ RB_GC_GUARD(vparams);
+ return v->retval;
+}
+
+static VALUE
+racc_yyparse(VALUE parser, VALUE lexer, VALUE lexmid, VALUE arg, VALUE sysdebug)
+{
+ VALUE vparams;
+ struct cparse_params *v;
+
+ vparams = TypedData_Make_Struct(CparseParams, struct cparse_params,
+ &cparse_params_type, v);
+ v->sys_debug = RTEST(sysdebug);
+ D_puts("start C yyparse");
+ vparams = initialize_params(vparams, parser, arg, lexer, lexmid);
+ v->lex_is_iterator = TRUE;
+ D_puts("params initialized");
+ parse_main(v, Qnil, Qnil, 0);
+ call_lexer(v);
+ if (!v->fin) {
+ rb_raise(rb_eArgError, "%s() is finished before EndOfToken",
+ rb_id2name(v->lexmid));
+ }
+
+ RB_GC_GUARD(vparams);
+ return v->retval;
+}
+
+#ifdef HAVE_RB_BLOCK_CALL
+static void
+call_lexer(struct cparse_params *v)
+{
+ rb_block_call(v->lexer, v->lexmid, 0, NULL, lexer_i, v->value_v);
+}
+#else
+static VALUE
+lexer_iter(VALUE data)
+{
+ struct cparse_params *v = rb_check_typeddata(data, &cparse_params_type);
+
+ rb_funcall(v->lexer, v->lexmid, 0);
+ return Qnil;
+}
+
+static void
+call_lexer(struct cparse_params *v)
+{
+ rb_iterate(lexer_iter, v->value_v, lexer_i, v->value_v);
+}
+#endif
+
+static VALUE
+lexer_i(RB_BLOCK_CALL_FUNC_ARGLIST(block_args, data))
+{
+ struct cparse_params *v = rb_check_typeddata(data, &cparse_params_type);
+ VALUE tok, val;
+
+ if (v->fin)
+ rb_raise(rb_eArgError, "extra token after EndOfToken");
+ extract_user_token(v, block_args, &tok, &val);
+ parse_main(v, tok, val, 1);
+ if (v->fin && v->fin != CP_FIN_ACCEPT)
+ rb_iter_break();
+ return Qnil;
+}
+
+static VALUE
+assert_array(VALUE a)
+{
+ Check_Type(a, T_ARRAY);
+ return a;
+}
+
+static VALUE
+assert_hash(VALUE h)
+{
+ Check_Type(h, T_HASH);
+ return h;
+}
+
+static long
+assert_integer(VALUE n)
+{
+ return NUM2LONG(n);
+}
+
+static VALUE
+initialize_params(VALUE vparams, VALUE parser, VALUE arg, VALUE lexer, VALUE lexmid)
+{
+ struct cparse_params *v = rb_check_typeddata(vparams, &cparse_params_type);
+
+ v->value_v = vparams;
+ v->parser = parser;
+ v->lexer = lexer;
+ if (! NIL_P(lexmid))
+ v->lexmid = value_to_id(lexmid);
+
+ v->debug = RTEST(rb_ivar_get(parser, id_yydebug));
+
+ Check_Type(arg, T_ARRAY);
+ if (!(13 <= RARRAY_LEN(arg) && RARRAY_LEN(arg) <= 14))
+ rb_raise(RaccBug, "[Racc Bug] wrong arg.size %ld", RARRAY_LEN(arg));
+ v->action_table = assert_array (rb_ary_entry(arg, 0));
+ v->action_check = assert_array (rb_ary_entry(arg, 1));
+ v->action_default = assert_array (rb_ary_entry(arg, 2));
+ v->action_pointer = assert_array (rb_ary_entry(arg, 3));
+ v->goto_table = assert_array (rb_ary_entry(arg, 4));
+ v->goto_check = assert_array (rb_ary_entry(arg, 5));
+ v->goto_default = assert_array (rb_ary_entry(arg, 6));
+ v->goto_pointer = assert_array (rb_ary_entry(arg, 7));
+ v->nt_base = assert_integer(rb_ary_entry(arg, 8));
+ v->reduce_table = assert_array (rb_ary_entry(arg, 9));
+ v->token_table = assert_hash (rb_ary_entry(arg, 10));
+ v->shift_n = assert_integer(rb_ary_entry(arg, 11));
+ v->reduce_n = assert_integer(rb_ary_entry(arg, 12));
+ if (RARRAY_LEN(arg) > 13) {
+ v->use_result_var = RTEST(rb_ary_entry(arg, 13));
+ }
+ else {
+ v->use_result_var = TRUE;
+ }
+
+ v->tstack = v->debug ? NEW_STACK() : Qnil;
+ v->vstack = NEW_STACK();
+ v->state = NEW_STACK();
+ v->curstate = 0;
+ PUSH(v->state, INT2FIX(0));
+ v->t = INT2FIX(FINAL_TOKEN + 1); /* must not init to FINAL_TOKEN */
+ v->nerr = 0;
+ v->errstatus = 0;
+ rb_ivar_set(parser, id_errstatus, LONG2NUM(v->errstatus));
+
+ v->retval = Qnil;
+ v->fin = 0;
+
+ v->lex_is_iterator = FALSE;
+
+ rb_iv_set(parser, "@vstack", v->vstack);
+ if (v->debug) {
+ rb_iv_set(parser, "@tstack", v->tstack);
+ }
+ else {
+ rb_iv_set(parser, "@tstack", Qnil);
+ }
+
+ return vparams;
+}
+
+static void
+cparse_params_mark(void *ptr)
+{
+ struct cparse_params *v = (struct cparse_params*)ptr;
+
+ rb_gc_mark(v->value_v);
+ rb_gc_mark(v->parser);
+ rb_gc_mark(v->lexer);
+ rb_gc_mark(v->action_table);
+ rb_gc_mark(v->action_check);
+ rb_gc_mark(v->action_default);
+ rb_gc_mark(v->action_pointer);
+ rb_gc_mark(v->goto_table);
+ rb_gc_mark(v->goto_check);
+ rb_gc_mark(v->goto_default);
+ rb_gc_mark(v->goto_pointer);
+ rb_gc_mark(v->reduce_table);
+ rb_gc_mark(v->token_table);
+ rb_gc_mark(v->state);
+ rb_gc_mark(v->vstack);
+ rb_gc_mark(v->tstack);
+ rb_gc_mark(v->t);
+ rb_gc_mark(v->retval);
+}
+
+static size_t
+cparse_params_memsize(const void *ptr)
+{
+ return sizeof(struct cparse_params);
+}
+
+static void
+extract_user_token(struct cparse_params *v, VALUE block_args,
+ VALUE *tok, VALUE *val)
+{
+ if (NIL_P(block_args)) {
+ /* EOF */
+ *tok = Qfalse;
+ *val = rb_str_new("$", 1);
+ return;
+ }
+
+ if (!RB_TYPE_P(block_args, T_ARRAY)) {
+ rb_raise(rb_eTypeError,
+ "%s() %s %"PRIsVALUE" (must be Array[2])",
+ v->lex_is_iterator ? rb_id2name(v->lexmid) : "next_token",
+ v->lex_is_iterator ? "yielded" : "returned",
+ rb_obj_class(block_args));
+ }
+ if (RARRAY_LEN(block_args) != 2) {
+ rb_raise(rb_eArgError,
+ "%s() %s wrong size of array (%ld for 2)",
+ v->lex_is_iterator ? rb_id2name(v->lexmid) : "next_token",
+ v->lex_is_iterator ? "yielded" : "returned",
+ RARRAY_LEN(block_args));
+ }
+ *tok = AREF(block_args, 0);
+ *val = AREF(block_args, 1);
+}
+
+#define SHIFT(v,act,tok,val) shift(v,act,tok,val)
+#define REDUCE(v,act) do {\
+ switch (reduce(v,act)) { \
+ case 0: /* normal */ \
+ break; \
+ case 1: /* yyerror */ \
+ goto user_yyerror; \
+ case 2: /* yyaccept */ \
+ D_puts("u accept"); \
+ goto accept; \
+ default: \
+ break; \
+ } \
+} while (0)
+
+static void
+parse_main(struct cparse_params *v, VALUE tok, VALUE val, int resume)
+{
+ long i; /* table index */
+ long act; /* action type */
+ VALUE act_value; /* action type, VALUE version */
+ int read_next = 1; /* true if we need to read next token */
+ VALUE tmp;
+
+ if (resume)
+ goto resume;
+
+ while (1) {
+ D_puts("");
+ D_puts("---- enter new loop ----");
+ D_puts("");
+
+ D_printf("(act) k1=%ld\n", v->curstate);
+ tmp = AREF(v->action_pointer, v->curstate);
+ if (NIL_P(tmp)) goto notfound;
+ D_puts("(act) pointer[k1] ok");
+ i = NUM2LONG(tmp);
+
+ D_printf("read_next=%d\n", read_next);
+ if (read_next && (v->t != vFINAL_TOKEN)) {
+ if (v->lex_is_iterator) {
+ D_puts("resuming...");
+ if (v->fin) rb_raise(rb_eArgError, "token given after EOF");
+ v->i = i; /* save i */
+ return;
+ resume:
+ D_puts("resumed");
+ i = v->i; /* load i */
+ }
+ else {
+ D_puts("next_token");
+ tmp = rb_funcall(v->parser, id_nexttoken, 0);
+ extract_user_token(v, tmp, &tok, &val);
+ }
+ /* convert token */
+ v->t = rb_hash_aref(v->token_table, tok);
+ if (NIL_P(v->t)) {
+ v->t = vERROR_TOKEN;
+ }
+ D_printf("(act) t(k2)=%ld\n", NUM2LONG(v->t));
+ if (v->debug) {
+ rb_funcall(v->parser, id_d_read_token,
+ 3, v->t, tok, val);
+ }
+ }
+ read_next = 0;
+
+ i += NUM2LONG(v->t);
+ D_printf("(act) i=%ld\n", i);
+ if (i < 0) goto notfound;
+
+ act_value = AREF(v->action_table, i);
+ if (NIL_P(act_value)) goto notfound;
+ act = NUM2LONG(act_value);
+ D_printf("(act) table[i]=%ld\n", act);
+
+ tmp = AREF(v->action_check, i);
+ if (NIL_P(tmp)) goto notfound;
+ if (NUM2LONG(tmp) != v->curstate) goto notfound;
+ D_printf("(act) check[i]=%ld\n", NUM2LONG(tmp));
+
+ D_puts("(act) found");
+ act_fixed:
+ D_printf("act=%ld\n", act);
+ goto handle_act;
+
+ notfound:
+ D_puts("(act) not found: use default");
+ act_value = AREF(v->action_default, v->curstate);
+ act = NUM2LONG(act_value);
+ goto act_fixed;
+
+
+ handle_act:
+ if (act > 0 && act < v->shift_n) {
+ D_puts("shift");
+ if (v->errstatus > 0) {
+ v->errstatus--;
+ rb_ivar_set(v->parser, id_errstatus, LONG2NUM(v->errstatus));
+ }
+ SHIFT(v, act, v->t, val);
+ read_next = 1;
+ }
+ else if (act < 0 && act > -(v->reduce_n)) {
+ D_puts("reduce");
+ REDUCE(v, act);
+ }
+ else if (act == -(v->reduce_n)) {
+ goto error;
+ error_recovered:
+ ; /* goto label requires stmt */
+ }
+ else if (act == v->shift_n) {
+ D_puts("accept");
+ goto accept;
+ }
+ else {
+ rb_raise(RaccBug, "[Racc Bug] unknown act value %ld", act);
+ }
+
+ if (v->debug) {
+ rb_funcall(v->parser, id_d_next_state,
+ 2, LONG2NUM(v->curstate), v->state);
+ }
+ }
+ /* not reach */
+
+
+ accept:
+ if (v->debug) rb_funcall(v->parser, id_d_accept, 0);
+ v->retval = rb_ary_entry(v->vstack, 0);
+ v->fin = CP_FIN_ACCEPT;
+ return;
+
+
+ error:
+ D_printf("error detected, status=%ld\n", v->errstatus);
+ if (v->errstatus == 0) {
+ v->nerr++;
+ rb_funcall(v->parser, id_onerror,
+ 3, v->t, val, v->vstack);
+ }
+ user_yyerror:
+ if (v->errstatus == 3) {
+ if (v->t == vFINAL_TOKEN) {
+ v->retval = Qfalse;
+ v->fin = CP_FIN_EOT;
+ return;
+ }
+ read_next = 1;
+ }
+ v->errstatus = 3;
+ rb_ivar_set(v->parser, id_errstatus, LONG2NUM(v->errstatus));
+
+ /* check if we can shift/reduce error token */
+ D_printf("(err) k1=%ld\n", v->curstate);
+ D_printf("(err) k2=%d (error)\n", ERROR_TOKEN);
+ while (1) {
+ tmp = AREF(v->action_pointer, v->curstate);
+ if (NIL_P(tmp)) goto error_pop;
+ D_puts("(err) pointer[k1] ok");
+
+ i = NUM2LONG(tmp) + ERROR_TOKEN;
+ D_printf("(err) i=%ld\n", i);
+ if (i < 0) goto error_pop;
+
+ act_value = AREF(v->action_table, i);
+ if (NIL_P(act_value)) {
+ D_puts("(err) table[i] == nil");
+ goto error_pop;
+ }
+ act = NUM2LONG(act_value);
+ D_printf("(err) table[i]=%ld\n", act);
+
+ tmp = AREF(v->action_check, i);
+ if (NIL_P(tmp)) {
+ D_puts("(err) check[i] == nil");
+ goto error_pop;
+ }
+ if (NUM2LONG(tmp) != v->curstate) {
+ D_puts("(err) check[i] != k1");
+ goto error_pop;
+ }
+
+ D_puts("(err) found: can handle error token");
+ break;
+
+ error_pop:
+ D_puts("(err) act not found: can't handle error token; pop");
+
+ if (RARRAY_LEN(v->state) <= 1) {
+ v->retval = Qnil;
+ v->fin = CP_FIN_CANTPOP;
+ return;
+ }
+ POP(v->state);
+ POP(v->vstack);
+ v->curstate = num_to_long(LAST_I(v->state));
+ if (v->debug) {
+ POP(v->tstack);
+ rb_funcall(v->parser, id_d_e_pop,
+ 3, v->state, v->tstack, v->vstack);
+ }
+ }
+
+ /* shift/reduce error token */
+ if (act > 0 && act < v->shift_n) {
+ D_puts("e shift");
+ SHIFT(v, act, ERROR_TOKEN, val);
+ }
+ else if (act < 0 && act > -(v->reduce_n)) {
+ D_puts("e reduce");
+ REDUCE(v, act);
+ }
+ else if (act == v->shift_n) {
+ D_puts("e accept");
+ goto accept;
+ }
+ else {
+ rb_raise(RaccBug, "[Racc Bug] unknown act value %ld", act);
+ }
+ goto error_recovered;
+}
+
+static void
+shift(struct cparse_params *v, long act, VALUE tok, VALUE val)
+{
+ PUSH(v->vstack, val);
+ if (v->debug) {
+ PUSH(v->tstack, tok);
+ rb_funcall(v->parser, id_d_shift,
+ 3, tok, v->tstack, v->vstack);
+ }
+ v->curstate = act;
+ PUSH(v->state, LONG2NUM(v->curstate));
+}
+
+static int
+reduce(struct cparse_params *v, long act)
+{
+ VALUE code;
+ v->ruleno = -act * 3;
+ code = rb_catch("racc_jump", reduce0, v->value_v);
+ v->errstatus = num_to_long(rb_ivar_get(v->parser, id_errstatus));
+ return NUM2INT(code);
+}
+
+static VALUE
+reduce0(VALUE val, VALUE data, VALUE self)
+{
+ struct cparse_params *v = rb_check_typeddata(data, &cparse_params_type);
+ VALUE reduce_to, reduce_len, method_id;
+ long len;
+ ID mid;
+ VALUE tmp, tmp_t = Qundef, tmp_v = Qundef;
+ long i, k1, k2;
+ VALUE goto_state;
+
+ reduce_len = rb_ary_entry(v->reduce_table, v->ruleno);
+ reduce_to = rb_ary_entry(v->reduce_table, v->ruleno+1);
+ method_id = rb_ary_entry(v->reduce_table, v->ruleno+2);
+ len = NUM2LONG(reduce_len);
+ mid = value_to_id(method_id);
+
+ /* call action */
+ if (len == 0) {
+ tmp = Qnil;
+ if (mid != id_noreduce)
+ tmp_v = rb_ary_new();
+ if (v->debug)
+ tmp_t = rb_ary_new();
+ }
+ else {
+ if (mid != id_noreduce) {
+ tmp_v = GET_TAIL(v->vstack, len);
+ tmp = rb_ary_entry(tmp_v, 0);
+ }
+ else {
+ tmp = rb_ary_entry(v->vstack, RARRAY_LEN(v->vstack) - len);
+ }
+ CUT_TAIL(v->vstack, len);
+ if (v->debug) {
+ tmp_t = GET_TAIL(v->tstack, len);
+ CUT_TAIL(v->tstack, len);
+ }
+ CUT_TAIL(v->state, len);
+ }
+ if (mid != id_noreduce) {
+ if (v->use_result_var) {
+ tmp = rb_funcall(v->parser, mid,
+ 3, tmp_v, v->vstack, tmp);
+ }
+ else {
+ tmp = rb_funcall(v->parser, mid,
+ 2, tmp_v, v->vstack);
+ }
+ }
+
+ /* then push result */
+ PUSH(v->vstack, tmp);
+ if (v->debug) {
+ PUSH(v->tstack, reduce_to);
+ rb_funcall(v->parser, id_d_reduce,
+ 4, tmp_t, reduce_to, v->tstack, v->vstack);
+ }
+
+ /* calculate transition state */
+ if (RARRAY_LEN(v->state) == 0)
+ rb_raise(RaccBug, "state stack unexpectedly empty");
+ k2 = num_to_long(LAST_I(v->state));
+ k1 = num_to_long(reduce_to) - v->nt_base;
+ D_printf("(goto) k1=%ld\n", k1);
+ D_printf("(goto) k2=%ld\n", k2);
+
+ tmp = AREF(v->goto_pointer, k1);
+ if (NIL_P(tmp)) goto notfound;
+
+ i = NUM2LONG(tmp) + k2;
+ D_printf("(goto) i=%ld\n", i);
+ if (i < 0) goto notfound;
+
+ goto_state = AREF(v->goto_table, i);
+ if (NIL_P(goto_state)) {
+ D_puts("(goto) table[i] == nil");
+ goto notfound;
+ }
+ D_printf("(goto) table[i]=%ld (goto_state)\n", NUM2LONG(goto_state));
+
+ tmp = AREF(v->goto_check, i);
+ if (NIL_P(tmp)) {
+ D_puts("(goto) check[i] == nil");
+ goto notfound;
+ }
+ if (tmp != LONG2NUM(k1)) {
+ D_puts("(goto) check[i] != table[i]");
+ goto notfound;
+ }
+ D_printf("(goto) check[i]=%ld\n", NUM2LONG(tmp));
+
+ D_puts("(goto) found");
+ transit:
+ PUSH(v->state, goto_state);
+ v->curstate = NUM2LONG(goto_state);
+ return INT2FIX(0);
+
+ notfound:
+ D_puts("(goto) not found: use default");
+ /* overwrite `goto-state' by default value */
+ goto_state = AREF(v->goto_default, k1);
+ goto transit;
+}
+
+/* -----------------------------------------------------------------------
+ Ruby Interface
+----------------------------------------------------------------------- */
+
+void
+Init_cparse(void)
+{
+#undef rb_intern
+#define rb_intern(str) rb_intern_const(str)
+ VALUE Racc, Parser;
+ ID id_racc = rb_intern("Racc");
+
+ if (rb_const_defined(rb_cObject, id_racc)) {
+ Racc = rb_const_get(rb_cObject, id_racc);
+ Parser = rb_const_get_at(Racc, rb_intern("Parser"));
+ }
+ else {
+ Racc = rb_define_module("Racc");
+ Parser = rb_define_class_under(Racc, "Parser", rb_cObject);
+ }
+ rb_define_private_method(Parser, "_racc_do_parse_c", racc_cparse, 2);
+ rb_define_private_method(Parser, "_racc_yyparse_c", racc_yyparse, 4);
+ rb_define_const(Parser, "Racc_Runtime_Core_Version_C",
+ rb_str_new2(RACC_VERSION));
+ rb_define_const(Parser, "Racc_Runtime_Core_Id_C",
+ rb_str_new2("$originalId: cparse.c,v 1.8 2006/07/06 11:39:46 aamine Exp $"));
+
+ CparseParams = rb_define_class_under(Racc, "CparseParams", rb_cObject);
+ rb_undef_alloc_func(CparseParams);
+ rb_undef_method(CparseParams, "initialize");
+ rb_undef_method(CparseParams, "initialize_copy");
+
+ RaccBug = rb_eRuntimeError;
+
+ id_yydebug = rb_intern("@yydebug");
+ id_nexttoken = rb_intern("next_token");
+ id_onerror = rb_intern("on_error");
+ id_noreduce = rb_intern("_reduce_none");
+ id_errstatus = rb_intern("@racc_error_status");
+
+ id_d_shift = rb_intern("racc_shift");
+ id_d_reduce = rb_intern("racc_reduce");
+ id_d_accept = rb_intern("racc_accept");
+ id_d_read_token = rb_intern("racc_read_token");
+ id_d_next_state = rb_intern("racc_next_state");
+ id_d_e_pop = rb_intern("racc_e_pop");
+}
diff --git a/jni/ruby/ext/racc/cparse/extconf.h b/jni/ruby/ext/racc/cparse/extconf.h
new file mode 100644
index 0000000..3ab91fd
--- /dev/null
+++ b/jni/ruby/ext/racc/cparse/extconf.h
@@ -0,0 +1,4 @@
+#ifndef EXTCONF_H
+#define EXTCONF_H
+#define HAVE_RB_BLOCK_CALL 1
+#endif
diff --git a/jni/ruby/ext/racc/cparse/extconf.rb b/jni/ruby/ext/racc/cparse/extconf.rb
new file mode 100644
index 0000000..5d90357
--- /dev/null
+++ b/jni/ruby/ext/racc/cparse/extconf.rb
@@ -0,0 +1,5 @@
+# $Id: extconf.rb 25189 2009-10-02 12:04:37Z akr $
+
+require 'mkmf'
+have_func('rb_block_call', 'ruby/ruby.h')
+create_makefile 'racc/cparse'
diff --git a/jni/ruby/ext/rbconfig/sizeof/Makefile b/jni/ruby/ext/rbconfig/sizeof/Makefile
new file mode 100644
index 0000000..80e4bb8
--- /dev/null
+++ b/jni/ruby/ext/rbconfig/sizeof/Makefile
@@ -0,0 +1,284 @@
+
+SHELL = /bin/sh
+
+# V=0 quiet, V=1 verbose. other values don't work.
+V = 0
+Q1 = $(V:1=)
+Q = $(Q1:0=@)
+ECHO1 = $(V:1=@:)
+ECHO = $(ECHO1:0=@echo)
+NULLCMD = :
+
+#### Start of system configuration section. ####
+top_srcdir = $(topdir)/.
+srcdir = $(top_srcdir)/ext/rbconfig/sizeof
+topdir = ../../..
+hdrdir = $(top_srcdir)/include
+arch_hdrdir = $(extout)/include/$(arch)
+PATH_SEPARATOR = :
+VPATH = $(srcdir):$(arch_hdrdir)/ruby:$(hdrdir)/ruby
+RUBYLIB =
+RUBYOPT = -
+prefix = $(DESTDIR)/usr/local
+rubysitearchprefix = $(rubylibprefix)/$(sitearch)
+rubyarchprefix = $(rubylibprefix)/$(arch)
+rubylibprefix = $(libdir)/$(RUBY_BASE_NAME)
+exec_prefix = $(prefix)
+vendorarchhdrdir = $(vendorhdrdir)/$(sitearch)
+sitearchhdrdir = $(sitehdrdir)/$(sitearch)
+rubyarchhdrdir = $(rubyhdrdir)/$(arch)
+vendorhdrdir = $(rubyhdrdir)/vendor_ruby
+sitehdrdir = $(rubyhdrdir)/site_ruby
+rubyhdrdir = $(includedir)/$(RUBY_VERSION_NAME)
+vendorarchdir = $(vendorlibdir)/$(sitearch)
+vendorlibdir = $(vendordir)/$(ruby_version)
+vendordir = $(rubylibprefix)/vendor_ruby
+sitearchdir = $(sitelibdir)/$(sitearch)
+sitelibdir = $(sitedir)/$(ruby_version)
+sitedir = $(rubylibprefix)/site_ruby
+rubyarchdir = $(rubylibdir)/$(arch)
+rubylibdir = $(rubylibprefix)/$(ruby_version)
+sitearchincludedir = $(includedir)/$(sitearch)
+archincludedir = $(includedir)/$(arch)
+sitearchlibdir = $(libdir)/$(sitearch)
+archlibdir = $(libdir)/$(arch)
+ridir = $(datarootdir)/$(RI_BASE_NAME)
+mandir = $(datarootdir)/man
+localedir = $(datarootdir)/locale
+libdir = $(exec_prefix)/lib
+psdir = $(docdir)
+pdfdir = $(docdir)
+dvidir = $(docdir)
+htmldir = $(docdir)
+infodir = $(datarootdir)/info
+docdir = $(datarootdir)/doc/$(PACKAGE)
+oldincludedir = $(DESTDIR)/usr/include
+includedir = $(prefix)/include
+localstatedir = $(prefix)/var
+sharedstatedir = $(prefix)/com
+sysconfdir = $(prefix)/etc
+datadir = $(datarootdir)
+datarootdir = $(prefix)/share
+libexecdir = $(exec_prefix)/libexec
+sbindir = $(exec_prefix)/sbin
+bindir = $(exec_prefix)/bin
+archdir = $(rubyarchdir)
+
+
+CC = gcc
+CXX = g++
+LIBRUBY = $(LIBRUBY_SO)
+LIBRUBY_A = lib$(RUBY_SO_NAME)-static.a
+LIBRUBYARG_SHARED = -Wl,-R$(libdir) -L$(libdir) -l$(RUBY_SO_NAME)
+LIBRUBYARG_STATIC = -Wl,-R$(libdir) -L$(libdir) -l$(RUBY_SO_NAME)-static
+empty =
+OUTFLAG = -o $(empty)
+COUTFLAG = -o $(empty)
+
+RUBY_EXTCONF_H = extconf.h
+cflags = $(optflags) $(debugflags) $(warnflags)
+optflags = -O3 -fno-fast-math
+debugflags = -ggdb3
+warnflags = -Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wunused-variable -Wpointer-arith -Wwrite-strings -Wdeclaration-after-statement -Wimplicit-function-declaration -Wdeprecated-declarations -Wno-packed-bitfield-compat
+CCDLFLAGS = -fPIC
+CFLAGS = $(CCDLFLAGS) $(cflags) -fPIC $(ARCH_FLAG)
+INCFLAGS = -I. -I$(arch_hdrdir) -I$(hdrdir) -I$(srcdir)
+DEFS =
+CPPFLAGS = -DRUBY_EXTCONF_H=\"$(RUBY_EXTCONF_H)\" $(DEFS) $(cppflags)
+CXXFLAGS = $(CCDLFLAGS) $(cxxflags) $(ARCH_FLAG)
+ldflags = -L. -fstack-protector -rdynamic -Wl,-export-dynamic
+dldflags =
+ARCH_FLAG =
+DLDFLAGS = $(ldflags) $(dldflags) $(ARCH_FLAG)
+LDSHARED = $(CC) -shared
+LDSHAREDXX = $(CXX) -shared
+AR = ar
+EXEEXT =
+
+RUBY_INSTALL_NAME = $(RUBY_BASE_NAME)
+RUBY_SO_NAME = ruby
+RUBYW_INSTALL_NAME =
+RUBY_VERSION_NAME = $(RUBY_BASE_NAME)-$(ruby_version)
+RUBYW_BASE_NAME = rubyw
+RUBY_BASE_NAME = ruby
+
+arch = x86_64-linux
+sitearch = $(arch)
+ruby_version = 2.2.0
+ruby = $(topdir)/miniruby -I'$(topdir)' -I'$(top_srcdir)/lib' -I'$(extout)/$(arch)' -I'$(extout)/common'
+RUBY = $(ruby)
+ruby_headers = $(hdrdir)/ruby.h $(hdrdir)/ruby/ruby.h $(hdrdir)/ruby/defines.h $(hdrdir)/ruby/missing.h $(hdrdir)/ruby/intern.h $(hdrdir)/ruby/st.h $(hdrdir)/ruby/subst.h $(arch_hdrdir)/ruby/config.h $(RUBY_EXTCONF_H)
+
+RM = rm -f
+RM_RF = $(RUBY) -run -e rm -- -rf
+RMDIRS = rmdir --ignore-fail-on-non-empty -p
+MAKEDIRS = /bin/mkdir -p
+INSTALL = /usr/bin/install -c
+INSTALL_PROG = $(INSTALL) -m 0755
+INSTALL_DATA = $(INSTALL) -m 644
+COPY = cp
+TOUCH = exit >
+
+#### End of system configuration section. ####
+
+preload =
+
+libpath = . $(topdir)
+LIBPATH = -L. -L$(topdir)
+DEFFILE =
+
+CLEANFILES = mkmf.log
+DISTCLEANFILES = sizes.c
+DISTCLEANDIRS =
+
+extout = $(topdir)/.ext
+extout_prefix = $(extout)$(target_prefix)/
+target_prefix = /rbconfig
+LOCAL_LIBS =
+LIBS = $(LIBRUBYARG_SHARED) -lpthread -lgmp -ldl -lcrypt -lm -lc
+ORIG_SRCS = sizes.c
+SRCS = $(ORIG_SRCS) sizes.c
+OBJS = sizes.o
+HDRS = $(srcdir)/extconf.h
+TARGET = sizeof
+TARGET_NAME = sizeof
+TARGET_ENTRY = Init_$(TARGET_NAME)
+DLLIB = $(TARGET).so
+EXTSTATIC =
+STATIC_LIB = $(TARGET).a
+
+TIMESTAMP_DIR = $(extout)/.timestamp
+BINDIR = $(extout)/bin
+RUBYCOMMONDIR = $(extout)/common
+RUBYLIBDIR = $(RUBYCOMMONDIR)$(target_prefix)
+RUBYARCHDIR = $(extout)/$(arch)$(target_prefix)
+HDRDIR = $(extout)/include/ruby$(target_prefix)
+ARCHHDRDIR = $(extout)/include/$(arch)/ruby$(target_prefix)
+
+TARGET_SO = $(RUBYARCHDIR)/$(DLLIB)
+CLEANLIBS = $(RUBYARCHDIR)/$(TARGET).so
+CLEANOBJS = *.o *.bak
+
+all: install
+static: all
+.PHONY: all install static install-so install-rb
+.PHONY: clean clean-so clean-static clean-rb
+
+clean-static::
+clean-rb-default::
+clean-rb::
+clean-so::
+clean: clean-so clean-static clean-rb-default clean-rb
+ -$(Q)$(RM) $(CLEANLIBS) $(CLEANOBJS) $(CLEANFILES) .*.time
+
+distclean-rb-default::
+distclean-rb::
+distclean-so::
+distclean-static::
+distclean: clean distclean-so distclean-static distclean-rb-default distclean-rb
+ -$(Q)$(RM) Makefile $(RUBY_EXTCONF_H) conftest.* mkmf.log
+ -$(Q)$(RM) core ruby$(EXEEXT) *~ $(DISTCLEANFILES)
+ -$(Q)$(RMDIRS) $(DISTCLEANDIRS) 2> /dev/null || true
+
+realclean: distclean
+install: install-so install-rb
+
+install-so: $(RUBYARCHDIR)/$(DLLIB)
+clean-so::
+ -$(Q)$(RM) $(RUBYARCHDIR)/$(DLLIB)
+ -$(Q)$(RMDIRS) $(RUBYARCHDIR) 2> /dev/null || true
+clean-static::
+ -$(Q)$(RM) $(STATIC_LIB)
+install-rb: pre-install-rb install-rb-default
+install-rb-default: pre-install-rb-default
+pre-install-rb: Makefile
+pre-install-rb-default: Makefile
+pre-install-rb-default:
+ @$(NULLCMD)
+$(TIMESTAMP_DIR)/.RUBYARCHDIR.-.rbconfig.time:
+ $(Q) $(MAKEDIRS) $(@D) $(RUBYARCHDIR)
+ $(Q) $(TOUCH) $@
+
+site-install: site-install-so site-install-rb
+site-install-so: install-so
+site-install-rb: install-rb
+
+.SUFFIXES: .c .m .cc .mm .cxx .cpp .o .S
+
+.cc.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<
+
+.cc.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -S $<
+
+.mm.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<
+
+.mm.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -S $<
+
+.cxx.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<
+
+.cxx.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -S $<
+
+.cpp.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<
+
+.cpp.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -S $<
+
+.c.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -c $<
+
+.c.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -S $<
+
+.m.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -c $<
+
+.m.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -S $<
+
+$(RUBYARCHDIR)/$(DLLIB): $(OBJS) Makefile $(TIMESTAMP_DIR)/.RUBYARCHDIR.-.rbconfig.time
+ $(ECHO) linking shared-object rbconfig/$(DLLIB)
+ -$(Q)$(RM) $(@)
+ $(Q) $(LDSHARED) -o $@ $(OBJS) $(LIBPATH) $(DLDFLAGS) $(LOCAL_LIBS) $(LIBS)
+
+$(STATIC_LIB): $(OBJS)
+ -$(Q)$(RM) $(@)
+ $(ECHO) linking static-library $(@)
+ $(Q) $(AR) cru $@ $(OBJS)
+ -$(Q)ranlib $(@) 2> /dev/null || true
+
+###
+$(OBJS): $(RUBY_EXTCONF_H)
+
+sizes.c: $(top_srcdir)/tool/generic_erb.rb $(top_srcdir)/template/sizes.c.tmpl $(top_srcdir)/configure.in
+ $(Q) $(RUBY) $(top_srcdir)/tool/generic_erb.rb --output=$@ \
+ $(top_srcdir)/template/sizes.c.tmpl $(top_srcdir)/configure.in
+
+# AUTOGENERATED DEPENDENCIES START
+sizes.o: $(RUBY_EXTCONF_H)
+sizes.o: $(arch_hdrdir)/ruby/config.h
+sizes.o: $(hdrdir)/ruby/defines.h
+sizes.o: $(hdrdir)/ruby/intern.h
+sizes.o: $(hdrdir)/ruby/missing.h
+sizes.o: $(hdrdir)/ruby/ruby.h
+sizes.o: $(hdrdir)/ruby/st.h
+sizes.o: $(hdrdir)/ruby/subst.h
+sizes.o: sizes.c
+# AUTOGENERATED DEPENDENCIES END
diff --git a/jni/ruby/ext/rbconfig/sizeof/depend b/jni/ruby/ext/rbconfig/sizeof/depend
new file mode 100644
index 0000000..1bcaa9c
--- /dev/null
+++ b/jni/ruby/ext/rbconfig/sizeof/depend
@@ -0,0 +1,15 @@
+sizes.c: $(top_srcdir)/tool/generic_erb.rb $(top_srcdir)/template/sizes.c.tmpl $(top_srcdir)/configure.in
+ $(Q) $(RUBY) $(top_srcdir)/tool/generic_erb.rb --output=$@ \
+ $(top_srcdir)/template/sizes.c.tmpl $(top_srcdir)/configure.in
+
+# AUTOGENERATED DEPENDENCIES START
+sizes.o: $(RUBY_EXTCONF_H)
+sizes.o: $(arch_hdrdir)/ruby/config.h
+sizes.o: $(hdrdir)/ruby/defines.h
+sizes.o: $(hdrdir)/ruby/intern.h
+sizes.o: $(hdrdir)/ruby/missing.h
+sizes.o: $(hdrdir)/ruby/ruby.h
+sizes.o: $(hdrdir)/ruby/st.h
+sizes.o: $(hdrdir)/ruby/subst.h
+sizes.o: {$(VPATH)}sizes.c
+# AUTOGENERATED DEPENDENCIES END
diff --git a/jni/ruby/ext/rbconfig/sizeof/extconf.h b/jni/ruby/ext/rbconfig/sizeof/extconf.h
new file mode 100644
index 0000000..cda0cc8
--- /dev/null
+++ b/jni/ruby/ext/rbconfig/sizeof/extconf.h
@@ -0,0 +1,3 @@
+#ifndef EXTCONF_H
+#define EXTCONF_H
+#endif
diff --git a/jni/ruby/ext/rbconfig/sizeof/extconf.rb b/jni/ruby/ext/rbconfig/sizeof/extconf.rb
new file mode 100644
index 0000000..ac66b6a
--- /dev/null
+++ b/jni/ruby/ext/rbconfig/sizeof/extconf.rb
@@ -0,0 +1,3 @@
+$srcs = %w[sizes.c]
+$distcleanfiles.concat($srcs)
+create_makefile('rbconfig/sizeof')
diff --git a/jni/ruby/ext/rbconfig/sizeof/sizes.c b/jni/ruby/ext/rbconfig/sizeof/sizes.c
new file mode 100644
index 0000000..3e3b259
--- /dev/null
+++ b/jni/ruby/ext/rbconfig/sizeof/sizes.c
@@ -0,0 +1,55 @@
+#include "ruby/ruby.h"
+
+void
+Init_sizeof(void)
+{
+ VALUE s = rb_hash_new();
+ rb_define_const(rb_define_module("RbConfig"), "SIZEOF", s);
+
+#define DEFINE(type, size) rb_hash_aset(s, rb_str_new_cstr(#type), INT2FIX(SIZEOF_##size));
+
+#if SIZEOF_INT != 0
+ DEFINE(int, INT);
+#endif
+#if SIZEOF_SHORT != 0
+ DEFINE(short, SHORT);
+#endif
+#if SIZEOF_LONG != 0
+ DEFINE(long, LONG);
+#endif
+#if SIZEOF_LONG_LONG != 0 && defined(HAVE_TRUE_LONG_LONG)
+ DEFINE(long long, LONG_LONG);
+#endif
+#if SIZEOF___INT64 != 0
+ DEFINE(__int64, __INT64);
+#endif
+#if SIZEOF___INT128 != 0
+ DEFINE(__int128, __INT128);
+#endif
+#if SIZEOF_OFF_T != 0
+ DEFINE(off_t, OFF_T);
+#endif
+#if SIZEOF_VOIDP != 0
+ DEFINE(void*, VOIDP);
+#endif
+#if SIZEOF_FLOAT != 0
+ DEFINE(float, FLOAT);
+#endif
+#if SIZEOF_DOUBLE != 0
+ DEFINE(double, DOUBLE);
+#endif
+#if SIZEOF_TIME_T != 0
+ DEFINE(time_t, TIME_T);
+#endif
+#if SIZEOF_CLOCK_T != 0
+ DEFINE(clock_t, CLOCK_T);
+#endif
+#if SIZEOF_SIZE_T != 0
+ DEFINE(size_t, SIZE_T);
+#endif
+#if SIZEOF_PTRDIFF_T != 0
+ DEFINE(ptrdiff_t, PTRDIFF_T);
+#endif
+
+#undef DEFINE
+}
diff --git a/jni/ruby/ext/readline/Makefile b/jni/ruby/ext/readline/Makefile
new file mode 100644
index 0000000..5d9aeba
--- /dev/null
+++ b/jni/ruby/ext/readline/Makefile
@@ -0,0 +1,150 @@
+# ***DUMMY MAKEFILE***
+
+SHELL = /bin/sh
+
+# V=0 quiet, V=1 verbose. other values don't work.
+V = 0
+Q1 = $(V:1=)
+Q = $(Q1:0=@)
+ECHO1 = $(V:1=@:)
+ECHO = $(ECHO1:0=@echo)
+NULLCMD = :
+
+#### Start of system configuration section. ####
+top_srcdir = $(topdir)/.
+srcdir = $(top_srcdir)/ext/readline
+topdir = ../..
+hdrdir = $(top_srcdir)/include
+arch_hdrdir = $(extout)/include/$(arch)
+PATH_SEPARATOR = :
+VPATH = $(srcdir):$(arch_hdrdir)/ruby:$(hdrdir)/ruby
+RUBYLIB =
+RUBYOPT = -
+prefix = $(DESTDIR)/usr/local
+rubysitearchprefix = $(rubylibprefix)/$(sitearch)
+rubyarchprefix = $(rubylibprefix)/$(arch)
+rubylibprefix = $(libdir)/$(RUBY_BASE_NAME)
+exec_prefix = $(prefix)
+vendorarchhdrdir = $(vendorhdrdir)/$(sitearch)
+sitearchhdrdir = $(sitehdrdir)/$(sitearch)
+rubyarchhdrdir = $(rubyhdrdir)/$(arch)
+vendorhdrdir = $(rubyhdrdir)/vendor_ruby
+sitehdrdir = $(rubyhdrdir)/site_ruby
+rubyhdrdir = $(includedir)/$(RUBY_VERSION_NAME)
+vendorarchdir = $(vendorlibdir)/$(sitearch)
+vendorlibdir = $(vendordir)/$(ruby_version)
+vendordir = $(rubylibprefix)/vendor_ruby
+sitearchdir = $(sitelibdir)/$(sitearch)
+sitelibdir = $(sitedir)/$(ruby_version)
+sitedir = $(rubylibprefix)/site_ruby
+rubyarchdir = $(rubylibdir)/$(arch)
+rubylibdir = $(rubylibprefix)/$(ruby_version)
+sitearchincludedir = $(includedir)/$(sitearch)
+archincludedir = $(includedir)/$(arch)
+sitearchlibdir = $(libdir)/$(sitearch)
+archlibdir = $(libdir)/$(arch)
+ridir = $(datarootdir)/$(RI_BASE_NAME)
+mandir = $(datarootdir)/man
+localedir = $(datarootdir)/locale
+libdir = $(exec_prefix)/lib
+psdir = $(docdir)
+pdfdir = $(docdir)
+dvidir = $(docdir)
+htmldir = $(docdir)
+infodir = $(datarootdir)/info
+docdir = $(datarootdir)/doc/$(PACKAGE)
+oldincludedir = $(DESTDIR)/usr/include
+includedir = $(prefix)/include
+localstatedir = $(prefix)/var
+sharedstatedir = $(prefix)/com
+sysconfdir = $(prefix)/etc
+datadir = $(datarootdir)
+datarootdir = $(prefix)/share
+libexecdir = $(exec_prefix)/libexec
+sbindir = $(exec_prefix)/sbin
+bindir = $(exec_prefix)/bin
+archdir = $(rubyarchdir)
+
+
+CC = gcc
+CXX = g++
+LIBRUBY = $(LIBRUBY_SO)
+LIBRUBY_A = lib$(RUBY_SO_NAME)-static.a
+LIBRUBYARG_SHARED = -Wl,-R$(libdir) -L$(libdir) -l$(RUBY_SO_NAME)
+LIBRUBYARG_STATIC = -Wl,-R$(libdir) -L$(libdir) -l$(RUBY_SO_NAME)-static
+empty =
+OUTFLAG = -o $(empty)
+COUTFLAG = -o $(empty)
+
+RUBY_EXTCONF_H =
+cflags = $(optflags) $(debugflags) $(warnflags)
+optflags = -O3 -fno-fast-math
+debugflags = -ggdb3
+warnflags = -Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wunused-variable -Wpointer-arith -Wwrite-strings -Wdeclaration-after-statement -Wimplicit-function-declaration -Wdeprecated-declarations -Wno-packed-bitfield-compat
+CCDLFLAGS = -fPIC
+CFLAGS = $(CCDLFLAGS) $(cflags) -fPIC $(ARCH_FLAG)
+INCFLAGS = -I. -I$(arch_hdrdir) -I$(hdrdir) -I$(srcdir)
+DEFS =
+CPPFLAGS = $(DEFS) $(cppflags)
+CXXFLAGS = $(CCDLFLAGS) $(cxxflags) $(ARCH_FLAG)
+ldflags = -L. -fstack-protector -rdynamic -Wl,-export-dynamic
+dldflags =
+ARCH_FLAG =
+DLDFLAGS = $(ldflags) $(dldflags) $(ARCH_FLAG)
+LDSHARED = $(CC) -shared
+LDSHAREDXX = $(CXX) -shared
+AR = ar
+EXEEXT =
+
+RUBY_INSTALL_NAME = $(RUBY_BASE_NAME)
+RUBY_SO_NAME = ruby
+RUBYW_INSTALL_NAME =
+RUBY_VERSION_NAME = $(RUBY_BASE_NAME)-$(ruby_version)
+RUBYW_BASE_NAME = rubyw
+RUBY_BASE_NAME = ruby
+
+arch = x86_64-linux
+sitearch = $(arch)
+ruby_version = 2.2.0
+ruby = $(topdir)/miniruby -I'$(topdir)' -I'$(top_srcdir)/lib' -I'$(extout)/$(arch)' -I'$(extout)/common'
+RUBY = $(ruby)
+ruby_headers = $(hdrdir)/ruby.h $(hdrdir)/ruby/ruby.h $(hdrdir)/ruby/defines.h $(hdrdir)/ruby/missing.h $(hdrdir)/ruby/intern.h $(hdrdir)/ruby/st.h $(hdrdir)/ruby/subst.h $(arch_hdrdir)/ruby/config.h
+
+RM = rm -f
+RM_RF = $(RUBY) -run -e rm -- -rf
+RMDIRS = rmdir --ignore-fail-on-non-empty -p
+MAKEDIRS = /bin/mkdir -p
+INSTALL = /usr/bin/install -c
+INSTALL_PROG = $(INSTALL) -m 0755
+INSTALL_DATA = $(INSTALL) -m 644
+COPY = cp
+TOUCH = exit >
+
+#### End of system configuration section. ####
+
+preload =
+CLEANFILES = mkmf.log
+DISTCLEANFILES =
+
+all install static install-so install-rb: Makefile
+.PHONY: all install static install-so install-rb
+.PHONY: clean clean-so clean-static clean-rb
+
+
+clean-static::
+clean-rb-default::
+clean-rb::
+clean-so::
+clean: clean-so clean-static clean-rb-default clean-rb
+ -$(Q)$(RM) $(CLEANLIBS) $(CLEANOBJS) $(CLEANFILES) .*.time
+
+distclean-rb-default::
+distclean-rb::
+distclean-so::
+distclean-static::
+distclean: clean distclean-so distclean-static distclean-rb-default distclean-rb
+ -$(Q)$(RM) Makefile $(RUBY_EXTCONF_H) conftest.* mkmf.log
+ -$(Q)$(RM) core ruby$(EXEEXT) *~ $(DISTCLEANFILES)
+ -$(Q)$(RMDIRS) $(DISTCLEANDIRS) 2> /dev/null || true
+
+realclean: distclean
diff --git a/jni/ruby/ext/readline/README b/jni/ruby/ext/readline/README
new file mode 100644
index 0000000..57c51b5
--- /dev/null
+++ b/jni/ruby/ext/readline/README
@@ -0,0 +1,10 @@
+The Readline module provides interface for GNU Readline.
+This module defines a number of methods to facilitate completion
+and accesses input history from the Ruby interpreter.
+This module supported Edit Line(libedit) too.
+libedit is compatible with GNU Readline.
+
+GNU Readline:: http://www.gnu.org/directory/readline.html
+libedit:: http://www.thrysoee.dk/editline/
+
+See RDoc for Readline module.
diff --git a/jni/ruby/ext/readline/README.ja b/jni/ruby/ext/readline/README.ja
new file mode 100644
index 0000000..57a6ee4
--- /dev/null
+++ b/jni/ruby/ext/readline/README.ja
@@ -0,0 +1,386 @@
+GNU Readline ã«ã‚ˆã‚‹ã‚³ãƒžãƒ³ãƒ‰ãƒ©ã‚¤ãƒ³å…¥åŠ›ã‚¤ãƒ³ã‚¿ãƒ•ã‚§ãƒ¼ã‚¹ã‚’æä¾›ã™ã‚‹ãƒ¢ã‚¸ãƒ¥ãƒ¼ãƒ«
+ã§ã™ã€‚GNU Readline ã®äº’æ›ãƒ©ã‚¤ãƒ–ラリã®ã²ã¨ã¤ã§ã‚ã‚‹ Edit Line(libedit) ã‚‚
+サãƒãƒ¼ãƒˆã—ã¦ã„ã¾ã™ã€‚
+
+GNU Readline:: http://www.gnu.org/directory/readline.html
+libedit:: http://www.thrysoee.dk/editline/
+
+Readline.readline を使用ã—ã¦ãƒ¦ãƒ¼ã‚¶ã‹ã‚‰ã®å…¥åŠ›ã‚’å–å¾—ã§ãã¾ã™ã€‚ã“ã®ã¨ãã€
+GNU Readline ã®ã‚ˆã†ã«å…¥åŠ›ã®è£œå®Œã‚„Emacs ã®ã‚ˆã†ãªã‚­ãƒ¼æ“作ãªã©ãŒã§ãã¾ã™ã€‚
+
+ require "readline"
+ while buf = Readline.readline("> ", true)
+ p buf
+ end
+
+ユーザãŒå…¥åŠ›ã—ãŸå†…容を履歴(以下ã€ãƒ’ストリ)ã¨ã—ã¦è¨˜éŒ²ã™ã‚‹ã“ã¨ãŒã§ãã¾ã™ã€‚
+定数 Readline::HISTORY を使用ã—ã¦ãƒ’ストリã«ã‚¢ã‚¯ã‚»ã‚¹ã§ãã¾ã™ã€‚
+
+ require "readline"
+ while buf = Readline.readline("> ", true)
+ p Readline::HISTORY.to_a
+ print("-> ", buf, "\n")
+ end
+
+使用ã™ã‚‹ãƒ©ã‚¤ãƒ–ラリã«ã‚ˆã‚Šã€ã„ãã¤ã‹ã®ãƒ¡ã‚½ãƒƒãƒ‰ã§ä¾‹å¤– NotImplementedError
+ãŒç™ºç”Ÿã—ã¾ã™ã€‚
+
+== Readline モジュール
+
+=== モジュール関数
+
+readline([prompt, [add_hist]]) -> String | nil
+
+ prompt を出力ã—ã€ãƒ¦ãƒ¼ã‚¶ã‹ã‚‰ã®ã‚­ãƒ¼å…¥åŠ›ã‚’å¾…ã¡ã¾ã™ã€‚
+ エンターキーã®æŠ¼ä¸‹ãªã©ã§ãƒ¦ãƒ¼ã‚¶ãŒæ–‡å­—列を入力ã—終ãˆã‚‹ã¨ã€
+ 入力ã—ãŸæ–‡å­—列を返ã—ã¾ã™ã€‚
+ ã“ã®ã¨ãã€add_hist ㌠true ã§ã‚ã‚Œã°ã€å…¥åŠ›ã—ãŸæ–‡å­—列をヒストリã«è¿½åŠ ã—ã¾ã™ã€‚
+
+ 何も入力ã—ã¦ã„ãªã„状態㧠EOF(UNIX ã§ã¯ ^D) を入力ã™ã‚‹ãªã©ã§ã€
+ ユーザã‹ã‚‰ã®å…¥åŠ›ãŒãªã„å ´åˆã¯ nil ã‚’è¿”ã—ã¾ã™ã€‚
+
+ 次ã®æ¡ä»¶ã‚’å…¨ã¦æº€ãŸã™å ´åˆã€ä¾‹å¤– IOError ãŒç™ºç”Ÿã—ã¾ã™ã€‚
+ 1. 標準入力㌠tty ã§ãªã„。
+ 2. 標準入力をクローズã—ã¦ã„る。(isatty(2) ã® errno ㌠EBADF ã§ã‚る。)
+
+ 本メソッドã¯ã‚¹ãƒ¬ãƒƒãƒ‰ã«å¯¾å¿œã—ã¦ã„ã¾ã™ã€‚
+ 入力待ã¡çŠ¶æ…‹ã®ã¨ãã¯ã‚¹ãƒ¬ãƒƒãƒ‰ã‚³ãƒ³ãƒ†ã‚­ã‚¹ãƒˆã®åˆ‡æ›¿ãˆãŒç™ºç”Ÿã—ã¾ã™ã€‚
+
+ 入力時ã«ã¯è¡Œå†…編集ãŒå¯èƒ½ã§ã€vi モード㨠Emacs モードãŒç”¨æ„ã•ã‚Œã¦ã„ã¾ã™ã€‚
+ デフォルト㯠Emacs モードã§ã™ã€‚
+
+ 本メソッドã«ã¯æ³¨æ„事項ãŒã‚ã‚Šã¾ã™ã€‚
+ 入力待ã¡ã®çŠ¶æ…‹ã§ ^C ã™ã‚‹ã¨ ruby インタプリタãŒçµ‚了ã—ã€ç«¯æœ«çŠ¶æ…‹ã‚’復帰ã—ã¾ã›ã‚“。
+ ã“れを回é¿ã™ã‚‹ãŸã‚ã®ä¾‹ã‚’3ã¤æŒ™ã’ã¾ã™ã€‚
+
+ * ^Cã«ã‚ˆã‚‹Interrupt例外を補足ã—ã¦ã€ç«¯æœ«çŠ¶æ…‹ã‚’復帰ã—ã¾ã™:
+
+ require "readline"
+
+ stty_save = `stty -g`.chomp
+ begin
+ while buf = Readline.readline
+ p buf
+ end
+ rescue Interrupt
+ system("stty", stty_save)
+ exit
+ end
+ end
+ end
+
+ * INTシグナルを補足ã—ã¦ã€ç«¯æœ«çŠ¶æ…‹ã‚’復帰ã—ã¾ã™:
+
+ require "readline"
+
+ stty_save = `stty -g`.chomp
+ trap("INT") { system "stty", stty_save; exit }
+
+ while buf = Readline.readline
+ p buf
+ end
+
+ * å˜ã« ^C を無視ã™ã‚‹æ–¹æ³•ã‚‚ã‚ã‚Šã¾ã™:
+
+ require "readline"
+
+ trap("INT", "SIG_IGN")
+
+ while buf = Readline.readline
+ p buf
+ end
+
+ 入力履歴 Readline::HISTORY を使用ã—ã¦ã€ç©ºè¡Œã‚„ç›´å‰ã®å…¥åŠ›ã¨åŒã˜å†…容ã¯å…¥åŠ›
+ 履歴ã«æ®‹ã•ãªã„ã¨ã„ã†ã“ã¨ã‚‚ã§ãã¾ã™ã€‚
+
+ require "readline"
+
+ while buf = Readline.readline("> ", true)
+ # p Readline::HISTORY.to_a
+ Readline::HISTORY.pop if /^\s*$/ =~ buf
+
+ begin
+ if Readline::HISTORY[Readline::HISTORY.length-2] == buf
+ Readline::HISTORY.pop
+ end
+ rescue IndexError
+ end
+
+ # p Readline::HISTORY.to_a
+ print "-> ", buf, "\n"
+ end
+
+=== クラスメソッド
+
+Readline.input = input
+
+ Readline.readline メソッドã§ä½¿ç”¨ã™ã‚‹å…¥åŠ›ç”¨ã® File オブジェクト input
+ を指定ã—ã¾ã™ã€‚
+
+Readline.output = output
+
+ Readline.readline メソッドã§ä½¿ç”¨ã™ã‚‹å‡ºåŠ›ç”¨ã® File オブジェクト
+ output を指定ã—ã¾ã™ã€‚
+
+Readline.completion_proc = proc
+
+ ユーザã‹ã‚‰ã®å…¥åŠ›ã‚’補完ã™ã‚‹æ™‚ã®å€™è£œã‚’å–å¾—ã™ã‚‹ Proc オブジェクト proc ã‚’
+ 指定ã—ã¾ã™ã€‚proc ã¯ã€æ¬¡ã®ã‚‚ã®ã‚’想定ã—ã¦ã„ã¾ã™ã€‚
+ 1. call メソッドをæŒã¡ã¾ã™ã€‚
+ call メソッドをæŒãŸãªã„å ´åˆã€ä¾‹å¤– ArgumentError ãŒç™ºç”Ÿã—ã¾ã™ã€‚
+ 2. 引数ã«ãƒ¦ãƒ¼ã‚¶ã‹ã‚‰ã®å…¥åŠ›æ–‡å­—列(注1)ã‚’å–ã‚Šã¾ã™ã€‚
+ 3. 候補ã®æ–‡å­—列ã®é…列を返ã—ã¾ã™ã€‚
+
+ 注1:「/var/lib /vã€ã®å¾Œã§è£œå®Œã‚’è¡Œã†ã¨ã€
+ デフォルトã§ã¯ proc ã®å¼•æ•°ã«ã€Œ/vã€ãŒæ¸¡ã•ã‚Œã¾ã™ã€‚
+ ã“ã®ã‚ˆã†ã«ã€ãƒ¦ãƒ¼ã‚¶ãŒå…¥åŠ›ã—ãŸæ–‡å­—列を
+ Readline.completer_word_break_characters ã«å«ã¾ã‚Œã‚‹æ–‡å­—ã§åŒºåˆ‡ã£ãŸã‚‚
+ ã®ã‚’å˜èªžã¨ã™ã‚‹ã¨ã€ã‚«ãƒ¼ã‚½ãƒ«ãŒã‚ã‚‹å˜èªžã®æœ€åˆã®æ–‡å­—ã‹ã‚‰ç¾åœ¨ã®ã‚«ãƒ¼ã‚½ãƒ«ä½
+ ç½®ã¾ã§ã®æ–‡å­—列㌠proc ã®å¼•æ•°ã«æ¸¡ã•ã‚Œã¾ã™ã€‚
+
+Readline.completion_proc -> proc
+
+ ユーザã‹ã‚‰ã®å…¥åŠ›ã‚’補完ã™ã‚‹æ™‚ã®å€™è£œã‚’å–å¾—ã™ã‚‹ Proc オブジェクト proc
+ ã‚’å–å¾—ã—ã¾ã™ã€‚
+
+Readline.completion_case_fold = bool
+
+ ユーザã®å…¥åŠ›ã‚’補完ã™ã‚‹éš›ã€å¤§æ–‡å­—ã¨å°æ–‡å­—を区別ã™ã‚‹ï¼ã—ãªã„を指定ã—ã¾ã™ã€‚
+ bool ãŒçœŸãªã‚‰ã°åŒºåˆ¥ã—ã¾ã›ã‚“。bool ãŒå½ãªã‚‰ã°åŒºåˆ¥ã—ã¾ã™ã€‚
+
+Readline.completion_case_fold -> bool
+
+ ユーザã®å…¥åŠ›ã‚’補完ã™ã‚‹éš›ã€å¤§æ–‡å­—ã¨å°æ–‡å­—を区別ã™ã‚‹ï¼ã—ãªã„ã‚’å–å¾—ã—ã¾ã™ã€‚
+ bool ãŒçœŸãªã‚‰ã°åŒºåˆ¥ã—ã¾ã›ã‚“。bool ãŒå½ãªã‚‰ã°åŒºåˆ¥ã—ã¾ã™ã€‚
+
+ ãªãŠã€Readline.completion_case_fold= メソッドã§æŒ‡å®šã—ãŸã‚ªãƒ–ジェクトを
+ ãã®ã¾ã¾å–å¾—ã™ã‚‹ã®ã§ã€æ¬¡ã®ã‚ˆã†ãªå‹•ä½œã‚’ã—ã¾ã™ã€‚
+
+ require "readline"
+
+ Readline.completion_case_fold = "This is a String."
+ p Readline.completion_case_fold # => "This is a String."
+
+Readline.line_buffer -> string
+
+ 入力中ã®è¡Œå…¨ä½“ã‚’è¿”ã—ã¾ã™ã€‚complete_proc ã®ä¸­ã§ä½¿ç”¨ã™ã‚‹ã“ã¨ã‚’想定ã—
+ ã¦ã„ã¾ã™ã€‚Readline.line_buffer ã®é•·ã•ã¯ GNU Readline ã® rl_end 変数ã®
+ 値ã¨ä¸€è‡´ã—ã¾ã™ã€‚
+
+Readline.point -> int
+
+ ç¾åœ¨ã®ã‚«ãƒ¼ã‚½ãƒ«ã®ä½ç½®ã‚’è¿”ã—ã¾ã™ã€‚
+ Readline モジュールã¯è£œå®Œå¯¾è±¡ã®å˜èªžã®é–‹å§‹ä½ç½®ã®æƒ…報をæä¾›ã—ã¦ã„ã¾ã›ã‚“。
+ ã—ã‹ã—ãªãŒã‚‰ã€ completion_proc ã®ä¸­ã§å…¥åŠ›ã—ãŸå˜èªž text ã¨
+ Readline.point を使用ã™ã‚‹ã“ã¨ã§é–‹å§‹ä½ç½®ã‚’å°Žãã“ã¨ãŒã§ãã¾ã™ã€‚
+
+ 開始ä½ç½® = 入力ã—ãŸå˜èªžã®é•·ã• - Readline.point
+
+Readline.vi_editing_mode -> nil
+
+ 編集モードを vi モードã«ã—ã¾ã™ã€‚
+ vi モードã®è©³ç´°ã¯ã€GNU Readline ã®ãƒžãƒ‹ãƒ¥ã‚¢ãƒ«ã‚’å‚ç…§ã—ã¦ãã ã•ã„。
+
+ サãƒãƒ¼ãƒˆã—ã¦ã„ãªã„環境ã§ã¯ã€ä¾‹å¤– NotImplementedError ãŒç™ºç”Ÿã—ã¾ã™ã€‚
+
+Readline.vi_editing_mode? -> bool
+
+ 編集モード㌠vi モードã®å ´åˆã€true ã‚’è¿”ã—ã¾ã™ã€‚ãã†ã§ãªã‘れ㰠false
+ ã‚’è¿”ã—ã¾ã™ã€‚
+
+ サãƒãƒ¼ãƒˆã—ã¦ã„ãªã„環境ã§ã¯ã€ä¾‹å¤– NotImplementedError ãŒç™ºç”Ÿã—ã¾ã™ã€‚
+
+Readline.emacs_editing_mode -> nil
+
+ 編集モードを Emacs モードã«ã—ã¾ã™ã€‚
+ デフォルト㯠Emacs モードã§ã™ã€‚
+ Emacs モードã®è©³ç´°ã¯ã€GNU Readline ã®ãƒžãƒ‹ãƒ¥ã‚¢ãƒ«ã‚’å‚ç…§ã—ã¦ãã ã•ã„。
+
+ サãƒãƒ¼ãƒˆã—ã¦ã„ãªã„環境ã§ã¯ã€ä¾‹å¤– NotImplementedError ãŒç™ºç”Ÿã—ã¾ã™ã€‚
+
+Readline.emacs_editing_mode? -> bool
+
+ 編集モード㌠Emacs モードã®å ´åˆã€true ã‚’è¿”ã—ã¾ã™ã€‚ãã†ã§ãªã‘れ㰠false
+ ã‚’è¿”ã—ã¾ã™ã€‚
+
+ サãƒãƒ¼ãƒˆã—ã¦ã„ãªã„環境ã§ã¯ã€ä¾‹å¤– NotImplementedError ãŒç™ºç”Ÿã—ã¾ã™ã€‚
+
+Readline.completion_append_character = char
+
+ ユーザã®å…¥åŠ›ã®è£œå®ŒãŒå®Œäº†ã—ãŸå ´åˆã«ã€æœ€å¾Œã«ä»˜åŠ ã™ã‚‹æ–‡å­— char を指定ã—
+ ã¾ã™ã€‚åŠè§’スペース「" "ã€ãªã©ã®å˜èªžã‚’区切る文字を指定ã™ã‚Œã°ã€é€£ç¶šã—ã¦
+ 入力ã™ã‚‹éš›ã«ä¾¿åˆ©ã§ã™ã€‚
+
+ 使用例:
+
+ require "readline"
+
+ Readline.readline("> ", true)
+ Readline.completion_append_character = " "
+
+ 実行例:
+
+ >
+ ã“ã“㧠"/var/li" を入力ã—ã¾ã™ã€‚
+
+ > /var/li
+ ã“ã“㧠TAB キーを入力ã—ã¾ã™ã€‚
+
+ > /var/lib
+ "b" ãŒè£œå®Œã•ã‚Œã€æœ€å¾Œã« " " ãŒè¿½åŠ ã•ã‚Œã‚‹ã®ã§ã€"/usr" を連続ã—ã¦å…¥åŠ›ã§ãã¾ã™ã€‚
+
+ > /var/lib /usr
+
+ ãªãŠã€1文字ã—ã‹æŒ‡å®šã™ã‚‹ã“ã¨ã¯ã§ãã¾ã›ã‚“。
+ 例ãˆã°ã€"string"を指定ã—ãŸå ´åˆã¯æœ€åˆã®æ–‡å­—ã§ã‚ã‚‹"s"ã ã‘を使用ã—ã¾ã™ã€‚
+
+ require "readline"
+
+ Readline.completion_append_character = "string"
+ p Readline.completion_append_character # => "s"
+
+ サãƒãƒ¼ãƒˆã—ã¦ã„ãªã„環境ã§ã¯ã€ä¾‹å¤– NotImplementedError ãŒç™ºç”Ÿã—ã¾ã™ã€‚
+
+Readline.completion_append_character -> char
+
+ ユーザã®å…¥åŠ›ã®è£œå®ŒãŒå®Œäº†ã—ãŸå ´åˆã«ã€æœ€å¾Œã«ä»˜åŠ ã™ã‚‹æ–‡å­—ã‚’å–å¾—ã—ã¾ã™ã€‚
+ デフォルトã¯ç©ºç™½ (" ") ã§ã™ã€‚
+
+ サãƒãƒ¼ãƒˆã—ã¦ã„ãªã„環境ã§ã¯ã€ä¾‹å¤– NotImplementedError ãŒç™ºç”Ÿã—ã¾ã™ã€‚
+
+Readline.basic_word_break_characters = string
+
+ ユーザã®å…¥åŠ›ã®è£œå®Œã‚’è¡Œã†éš›ã€å˜èªžã®åŒºåˆ‡ã‚Šã‚’示ã™è¤‡æ•°ã®æ–‡å­—ã§æ§‹æˆã•ã‚Œã‚‹
+ 文字列 string を指定ã—ã¾ã™ã€‚
+
+ GNU Readline ã®ãƒ‡ãƒ•ã‚©ãƒ«ãƒˆã®å€¤ã¯ã€Bash ã®è£œå®Œå‡¦ç†ã§ä½¿ç”¨ã—ã¦ã„る文字列
+ " \t\n\"\\'`@$><=;|&{(" (スペースをå«ã‚€) ã«ãªã£ã¦ã„ã¾ã™ã€‚
+
+ サãƒãƒ¼ãƒˆã—ã¦ã„ãªã„環境ã§ã¯ã€ä¾‹å¤– NotImplementedError ãŒç™ºç”Ÿã—ã¾ã™ã€‚
+
+Readline.basic_word_break_characters -> string
+
+ ユーザã®å…¥åŠ›ã®è£œå®Œã‚’è¡Œã†éš›ã€å˜èªžã®åŒºåˆ‡ã‚Šã‚’示ã™è¤‡æ•°ã®æ–‡å­—ã§æ§‹æˆã•ã‚Œã‚‹
+ 文字列をå–å¾—ã—ã¾ã™ã€‚
+
+ サãƒãƒ¼ãƒˆã—ã¦ã„ãªã„環境ã§ã¯ã€ä¾‹å¤– NotImplementedError ãŒç™ºç”Ÿã—ã¾ã™ã€‚
+
+Readline.completer_word_break_characters = string
+
+ ユーザã®å…¥åŠ›ã®è£œå®Œã‚’è¡Œã†éš›ã€å˜èªžã®åŒºåˆ‡ã‚Šã‚’示ã™è¤‡æ•°ã®æ–‡å­—ã§æ§‹æˆã•ã‚Œã‚‹
+ 文字列 string を指定ã—ã¾ã™ã€‚
+ Readline.basic_word_break_characters= ã¨ã®é•ã„ã¯ã€
+ GNU Readline ã® rl_complete_internal 関数ã§ä½¿ç”¨ã•ã‚Œã‚‹ã“ã¨ã§ã™ã€‚
+
+ GNU Readline ã®ãƒ‡ãƒ•ã‚©ãƒ«ãƒˆã®å€¤ã¯ã€
+ Readline.basic_word_break_characters ã¨åŒã˜ã§ã™ã€‚
+
+ サãƒãƒ¼ãƒˆã—ã¦ã„ãªã„環境ã§ã¯ã€ä¾‹å¤– NotImplementedError ãŒç™ºç”Ÿã—ã¾ã™ã€‚
+
+Readline.completer_word_break_characters -> string
+
+ ユーザã®å…¥åŠ›ã®è£œå®Œã‚’è¡Œã†éš›ã€å˜èªžã®åŒºåˆ‡ã‚Šã‚’示ã™è¤‡æ•°ã®æ–‡å­—ã§æ§‹æˆã•ã‚ŒãŸ
+ 文字列をå–å¾—ã—ã¾ã™ã€‚
+
+ サãƒãƒ¼ãƒˆã—ã¦ã„ãªã„環境ã§ã¯ã€ä¾‹å¤– NotImplementedError ãŒç™ºç”Ÿã—ã¾ã™ã€‚
+
+Readline.basic_quote_characters = string
+
+ スペースãªã©ã®å˜èªžã®åŒºåˆ‡ã‚Šã‚’クオートã™ã‚‹ãŸã‚ã®è¤‡æ•°ã®æ–‡å­—ã§æ§‹æˆã•ã‚Œã‚‹
+ 文字列 string を指定ã—ã¾ã™ã€‚
+
+ サãƒãƒ¼ãƒˆã—ã¦ã„ãªã„環境ã§ã¯ã€ä¾‹å¤– NotImplementedError ãŒç™ºç”Ÿã—ã¾ã™ã€‚
+
+Readline.basic_quote_characters -> string
+
+ スペースãªã©ã®å˜èªžã®åŒºåˆ‡ã‚Šã‚’クオートã™ã‚‹ãŸã‚ã®è¤‡æ•°ã®æ–‡å­—ã§æ§‹æˆã•ã‚Œã‚‹
+ 文字列をå–å¾—ã—ã¾ã™ã€‚
+
+ サãƒãƒ¼ãƒˆã—ã¦ã„ãªã„環境ã§ã¯ã€ä¾‹å¤– NotImplementedError ãŒç™ºç”Ÿã—ã¾ã™ã€‚
+
+Readline.completer_quote_characters = string
+
+ ユーザã®å…¥åŠ›ã®è£œå®Œã‚’è¡Œã†éš›ã€ã‚¹ãƒšãƒ¼ã‚¹ãªã©ã®å˜èªžã®åŒºåˆ‡ã‚Šã‚’
+ クオートã™ã‚‹ãŸã‚ã®è¤‡æ•°ã®æ–‡å­—ã§æ§‹æˆã•ã‚Œã‚‹æ–‡å­—列 string を指定ã—ã¾ã™ã€‚
+ 指定ã—ãŸæ–‡å­—ã®é–“ã§ã¯ã€Readline.completer_word_break_characters=
+ ã§æŒ‡å®šã—ãŸæ–‡å­—列ã«å«ã¾ã‚Œã‚‹æ–‡å­—ã‚‚ã€æ™®é€šã®æ–‡å­—列ã¨ã—ã¦æ‰±ã‚ã‚Œã¾ã™ã€‚
+
+ サãƒãƒ¼ãƒˆã—ã¦ã„ãªã„環境ã§ã¯ã€ä¾‹å¤– NotImplementedError ãŒç™ºç”Ÿã—ã¾ã™ã€‚
+
+Readline.completer_quote_characters -> string
+
+ ユーザã®å…¥åŠ›ã®è£œå®Œã‚’è¡Œã†éš›ã€ã‚¹ãƒšãƒ¼ã‚¹ãªã©ã®å˜èªžã®åŒºåˆ‡ã‚Šã‚’
+ クオートã™ã‚‹ãŸã‚ã®è¤‡æ•°ã®æ–‡å­—ã§æ§‹æˆã•ã‚Œã‚‹æ–‡å­—列をå–å¾—ã—ã¾ã™ã€‚
+
+ サãƒãƒ¼ãƒˆã—ã¦ã„ãªã„環境ã§ã¯ã€ä¾‹å¤– NotImplementedError ãŒç™ºç”Ÿã—ã¾ã™ã€‚
+
+Readline.filename_quote_characters = string
+
+ ユーザã®å…¥åŠ›æ™‚ã«ãƒ•ã‚¡ã‚¤ãƒ«åã®è£œå®Œã‚’è¡Œã†éš›ã€ã‚¹ãƒšãƒ¼ã‚¹ãªã©ã®å˜èªžã®åŒºåˆ‡ã‚Šã‚’
+ クオートã™ã‚‹ãŸã‚ã®è¤‡æ•°ã®æ–‡å­—ã§æ§‹æˆã•ã‚Œã‚‹æ–‡å­—列 string を指定ã—ã¾ã™ã€‚
+
+ GNU Readline ã®ãƒ‡ãƒ•ã‚©ãƒ«ãƒˆå€¤ã¯ nil ã§ã™ã€‚
+
+ サãƒãƒ¼ãƒˆã—ã¦ã„ãªã„環境ã§ã¯ã€ä¾‹å¤– NotImplementedError ãŒç™ºç”Ÿã—ã¾ã™ã€‚
+
+Readline.filename_quote_characters -> string
+
+ ユーザã®å…¥åŠ›æ™‚ã«ãƒ•ã‚¡ã‚¤ãƒ«åã®è£œå®Œã‚’è¡Œã†éš›ã€ã‚¹ãƒšãƒ¼ã‚¹ãªã©ã®å˜èªžã®åŒºåˆ‡ã‚Šã‚’
+ クオートã™ã‚‹ãŸã‚ã®è¤‡æ•°ã®æ–‡å­—ã§æ§‹æˆã•ã‚Œã‚‹æ–‡å­—列をå–å¾—ã—ã¾ã™ã€‚
+
+ サãƒãƒ¼ãƒˆã—ã¦ã„ãªã„環境ã§ã¯ã€ä¾‹å¤– NotImplementedError ãŒç™ºç”Ÿã—ã¾ã™ã€‚
+
+=== クラス定数
+
+HISTORY
+
+ 定数 HISTORY を使用ã—ã¦ãƒ’ストリã«ã‚¢ã‚¯ã‚»ã‚¹ã§ãã¾ã™ã€‚
+ Enumerable モジュールを extend ã—ã¦ãŠã‚Šã€
+ é…列ã®ã‚ˆã†ã«æŒ¯ã‚‹èˆžã†ã“ã¨ãŒã§ãã¾ã™ã€‚
+ 例ãˆã°ã€HISTORY[4] ã«ã‚ˆã‚Š 5 番目ã«å…¥åŠ›ã—ãŸå†…容をå–り出ã™ã“ã¨ãŒã§ãã¾ã™ã€‚
+
+ require "readline"
+
+ Readline::HISTORY.push("a", "b", "c", "d", "e")
+ p Readline::HISTORY[4] # => "e"
+
+ 実装ã—ã¦ã„るメソッドを次ã«æŒ™ã’ã¾ã™ã€‚
+ * HISTORY.to_s -> "HISTORY"
+ * HISTORY[index] -> string
+ * HISTORY[index] = string
+ * HISTORY.push(string[, string, ...]) -> self
+ * HISTORY << string -> self
+ * HISTORY.pop -> string
+ * HISTORY.shift -> string
+ * HISTORY.each -> Enumerator
+ * HISTORY.each { |i| } -> [string]
+ * HISTORY.length -> Integer
+ * HISTORY.empty? -> true or false
+ * HISTORY.delete_at(index) -> string
+ * HISTORY.clear -> self
+
+ サãƒãƒ¼ãƒˆã—ã¦ã„ãªã„環境ã§ã¯ã€æ¬¡ã®ãƒ¡ã‚½ãƒƒãƒ‰ã§ä¾‹å¤– NotImplementedError ãŒ
+ 発生ã—ã¾ã™ã€‚
+ * HISTORY[index] = string
+ * HISTORY.pop -> string
+ * HISTORY.shift -> string
+ * HISTORY.delete_at(index) -> string
+ * HISTORY.clear -> self
+
+FILENAME_COMPLETION_PROC
+
+ ファイルåã®è£œå®Œã‚’行ㆠcall メソッドをæŒã¤ã‚ªãƒ–ジェクトã§ã™ã€‚
+
+ Readline.completion_proc= ã«ã‚ˆã‚Šã€ãƒ¦ãƒ¼ã‚¶ã®å…¥åŠ›æ™‚ã«ãƒ•ã‚¡ã‚¤ãƒ«åã®è£œå®Œã‚’
+ è¡Œã†ã‚ˆã†ã«è¨­å®šã™ã‚‹ãŸã‚ã«ä½¿ç”¨ã™ã‚‹ã“ã¨ã‚’想定ã—ã¦ã¾ã™ã€‚
+
+USERNAME_COMPLETION_PROC
+
+ ユーザåã®è£œå®Œã‚’行ㆠcall メソッドをæŒã¤ã‚ªãƒ–ジェクトã§ã™ã€‚
+
+ Readline.completion_proc= ã«ã‚ˆã‚Šã€ãƒ¦ãƒ¼ã‚¶ã®å…¥åŠ›æ™‚ã«ãƒ¦ãƒ¼ã‚¶åã®è£œå®Œã‚’è¡Œ
+ ã†ã‚ˆã†ã«è¨­å®šã™ã‚‹ãŸã‚ã«ä½¿ç”¨ã™ã‚‹ã“ã¨ã‚’想定ã—ã¦ã¾ã™ã€‚
+
+VERSION
+
+ 使用ã—ã¦ã„ã‚‹ GNU Readline ã¾ãŸã¯ libedit ã®ãƒãƒ¼ã‚¸ãƒ§ãƒ³ã§ã™ã€‚
diff --git a/jni/ruby/ext/readline/depend b/jni/ruby/ext/readline/depend
new file mode 100644
index 0000000..26777f2
--- /dev/null
+++ b/jni/ruby/ext/readline/depend
@@ -0,0 +1,17 @@
+# AUTOGENERATED DEPENDENCIES START
+readline.o: $(RUBY_EXTCONF_H)
+readline.o: $(arch_hdrdir)/ruby/config.h
+readline.o: $(hdrdir)/ruby/defines.h
+readline.o: $(hdrdir)/ruby/encoding.h
+readline.o: $(hdrdir)/ruby/intern.h
+readline.o: $(hdrdir)/ruby/io.h
+readline.o: $(hdrdir)/ruby/missing.h
+readline.o: $(hdrdir)/ruby/oniguruma.h
+readline.o: $(hdrdir)/ruby/ruby.h
+readline.o: $(hdrdir)/ruby/st.h
+readline.o: $(hdrdir)/ruby/subst.h
+readline.o: $(hdrdir)/ruby/thread.h
+readline.o: $(top_srcdir)/include/ruby.h
+readline.o: $(top_srcdir)/internal.h
+readline.o: readline.c
+# AUTOGENERATED DEPENDENCIES END
diff --git a/jni/ruby/ext/readline/extconf.rb b/jni/ruby/ext/readline/extconf.rb
new file mode 100644
index 0000000..c79370b
--- /dev/null
+++ b/jni/ruby/ext/readline/extconf.rb
@@ -0,0 +1,109 @@
+require "mkmf"
+
+readline = Struct.new(:headers, :extra_check).new(["stdio.h"])
+
+def readline.have_header(header)
+ if super(header, &extra_check)
+ headers.push(header)
+ return true
+ else
+ return false
+ end
+end
+
+def readline.have_var(var)
+ return super(var, headers)
+end
+
+def readline.have_func(func)
+ return super(func, headers)
+end
+
+def readline.have_type(type)
+ return super(type, headers)
+end
+
+dir_config('curses')
+dir_config('ncurses')
+dir_config('termcap')
+dir_config("readline")
+enable_libedit = enable_config("libedit")
+
+have_library("user32", nil) if /cygwin/ === RUBY_PLATFORM
+have_library("ncurses", "tgetnum") ||
+ have_library("termcap", "tgetnum") ||
+ have_library("curses", "tgetnum")
+
+case enable_libedit
+when true
+ # --enable-libedit
+ unless (readline.have_header("editline/readline.h") ||
+ readline.have_header("readline/readline.h")) &&
+ have_library("edit", "readline")
+ raise "libedit not found"
+ end
+when false
+ # --disable-libedit
+ unless ((readline.have_header("readline/readline.h") &&
+ readline.have_header("readline/history.h")) &&
+ have_library("readline", "readline"))
+ raise "readline not found"
+ end
+else
+ # does not specify
+ unless ((readline.have_header("readline/readline.h") &&
+ readline.have_header("readline/history.h")) &&
+ (have_library("readline", "readline") ||
+ have_library("edit", "readline"))) ||
+ (readline.have_header("editline/readline.h") &&
+ have_library("edit", "readline"))
+ raise "readline nor libedit not found"
+ end
+end
+
+readline.have_func("rl_getc")
+readline.have_func("rl_getc_function")
+readline.have_func("rl_filename_completion_function")
+readline.have_func("rl_username_completion_function")
+readline.have_func("rl_completion_matches")
+readline.have_func("rl_refresh_line")
+readline.have_var("rl_deprep_term_function")
+readline.have_var("rl_completion_append_character")
+readline.have_var("rl_basic_word_break_characters")
+readline.have_var("rl_completer_word_break_characters")
+readline.have_var("rl_basic_quote_characters")
+readline.have_var("rl_completer_quote_characters")
+readline.have_var("rl_filename_quote_characters")
+readline.have_var("rl_attempted_completion_over")
+readline.have_var("rl_library_version")
+readline.have_var("rl_editing_mode")
+readline.have_var("rl_line_buffer")
+readline.have_var("rl_point")
+# workaround for native windows.
+/mswin|bccwin|mingw/ !~ RUBY_PLATFORM && readline.have_var("rl_event_hook")
+/mswin|bccwin|mingw/ !~ RUBY_PLATFORM && readline.have_var("rl_catch_sigwinch")
+/mswin|bccwin|mingw/ !~ RUBY_PLATFORM && readline.have_var("rl_catch_signals")
+readline.have_var("rl_pre_input_hook")
+readline.have_var("rl_special_prefixes")
+readline.have_func("rl_cleanup_after_signal")
+readline.have_func("rl_free_line_state")
+readline.have_func("rl_clear_signals")
+readline.have_func("rl_set_screen_size")
+readline.have_func("rl_get_screen_size")
+readline.have_func("rl_vi_editing_mode")
+readline.have_func("rl_emacs_editing_mode")
+readline.have_func("replace_history_entry")
+readline.have_func("remove_history")
+readline.have_func("clear_history")
+readline.have_func("rl_redisplay")
+readline.have_func("rl_insert_text")
+readline.have_func("rl_delete_text")
+unless readline.have_type("rl_hook_func_t*")
+ # rl_hook_func_t is available since readline-4.2 (2001).
+ # Function is removed at readline-6.3 (2014).
+ # However, editline (NetBSD 6.1.3, 2014) doesn't have rl_hook_func_t.
+ $defs << "-Drl_hook_func_t=Function"
+end
+
+$INCFLAGS << " -I$(top_srcdir)"
+create_makefile("readline")
diff --git a/jni/ruby/ext/readline/readline.c b/jni/ruby/ext/readline/readline.c
new file mode 100644
index 0000000..835e346
--- /dev/null
+++ b/jni/ruby/ext/readline/readline.c
@@ -0,0 +1,1996 @@
+/************************************************
+
+ readline.c - GNU Readline module
+
+ $Author: naruse $
+ created at: Wed Jan 20 13:59:32 JST 1999
+
+ Copyright (C) 1997-2008 Shugo Maeda
+ Copyright (C) 2008-2013 Kouji Takao
+
+ $Id: readline.c 49299 2015-01-17 07:50:07Z naruse $
+
+ Contact:
+ - Kouji Takao <kouji dot takao at gmail dot com> (current maintainer)
+
+************************************************/
+
+#ifdef RUBY_EXTCONF_H
+#include RUBY_EXTCONF_H
+#endif
+
+#include "ruby/config.h"
+#include <errno.h>
+#include <stdio.h>
+#include <string.h>
+#ifdef HAVE_READLINE_READLINE_H
+#include <readline/readline.h>
+#endif
+#ifdef HAVE_READLINE_HISTORY_H
+#include <readline/history.h>
+#endif
+#ifdef HAVE_EDITLINE_READLINE_H
+#include <editline/readline.h>
+#endif
+
+#include "internal.h"
+#include "ruby/io.h"
+#include "ruby/thread.h"
+
+#ifdef HAVE_UNISTD_H
+#include <unistd.h>
+#endif
+
+#ifdef HAVE_SYS_STAT_H
+#include <sys/stat.h>
+#endif
+
+static VALUE mReadline;
+
+#define EDIT_LINE_LIBRARY_VERSION "EditLine wrapper"
+#ifndef USE_INSERT_IGNORE_ESCAPE
+# if !defined(HAVE_EDITLINE_READLINE_H) && defined(RL_PROMPT_START_IGNORE) && defined(RL_PROMPT_END_IGNORE)
+# define USE_INSERT_IGNORE_ESCAPE 1
+# else
+# define USE_INSERT_IGNORE_ESCAPE 0
+# endif
+#endif
+
+#define COMPLETION_PROC "completion_proc"
+#define COMPLETION_CASE_FOLD "completion_case_fold"
+static ID completion_proc, completion_case_fold;
+#if USE_INSERT_IGNORE_ESCAPE
+static ID id_orig_prompt, id_last_prompt;
+#endif
+#if defined(HAVE_RL_PRE_INPUT_HOOK)
+static ID id_pre_input_hook;
+#endif
+#if defined(HAVE_RL_SPECIAL_PREFIXES)
+static ID id_special_prefixes;
+#endif
+
+#ifndef HAVE_RL_FILENAME_COMPLETION_FUNCTION
+# define rl_filename_completion_function filename_completion_function
+#endif
+#ifndef HAVE_RL_USERNAME_COMPLETION_FUNCTION
+# define rl_username_completion_function username_completion_function
+#endif
+#ifndef HAVE_RL_COMPLETION_MATCHES
+# define rl_completion_matches completion_matches
+#endif
+
+static int (*history_get_offset_func)(int);
+static int (*history_replace_offset_func)(int);
+#ifdef HAVE_RL_COMPLETION_APPEND_CHARACTER
+static int readline_completion_append_character;
+#endif
+
+static char **readline_attempted_completion_function(const char *text,
+ int start, int end);
+
+#define OutputStringValue(str) do {\
+ SafeStringValue(str);\
+ (str) = rb_str_conv_enc((str), rb_enc_get(str), rb_locale_encoding());\
+} while (0)\
+
+
+/*
+ * Document-class: Readline
+ *
+ * The Readline module provides interface for GNU Readline.
+ * This module defines a number of methods to facilitate completion
+ * and accesses input history from the Ruby interpreter.
+ * This module supported Edit Line(libedit) too.
+ * libedit is compatible with GNU Readline.
+ *
+ * GNU Readline:: http://www.gnu.org/directory/readline.html
+ * libedit:: http://www.thrysoee.dk/editline/
+ *
+ * Reads one inputted line with line edit by Readline.readline method.
+ * At this time, the facilitatation completion and the key
+ * bind like Emacs can be operated like GNU Readline.
+ *
+ * require "readline"
+ * while buf = Readline.readline("> ", true)
+ * p buf
+ * end
+ *
+ * The content that the user input can be recorded to the history.
+ * The history can be accessed by Readline::HISTORY constant.
+ *
+ * require "readline"
+ * while buf = Readline.readline("> ", true)
+ * p Readline::HISTORY.to_a
+ * print("-> ", buf, "\n")
+ * end
+ *
+ * Documented by Kouji Takao <kouji dot takao at gmail dot com>.
+ */
+
+static VALUE readline_instream;
+static VALUE readline_outstream;
+static FILE *readline_rl_instream;
+static FILE *readline_rl_outstream;
+
+#if defined HAVE_RL_GETC_FUNCTION
+
+#ifndef HAVE_RL_GETC
+#define rl_getc(f) EOF
+#endif
+
+struct getc_struct {
+ FILE *input;
+ int fd;
+ int ret;
+ int err;
+};
+
+static int
+getc_body(struct getc_struct *p)
+{
+ char ch;
+ ssize_t ss;
+
+#if defined(_WIN32)
+ {
+ INPUT_RECORD ir;
+ int n;
+ static int prior_key = '0';
+ for (;;) {
+ if (prior_key > 0xff) {
+ prior_key = rl_getc(p->input);
+ return prior_key;
+ }
+ if (PeekConsoleInput((HANDLE)_get_osfhandle(p->fd), &ir, 1, &n)) {
+ if (n == 1) {
+ if (ir.EventType == KEY_EVENT && ir.Event.KeyEvent.bKeyDown) {
+ prior_key = rl_getc(p->input);
+ return prior_key;
+ } else {
+ ReadConsoleInput((HANDLE)_get_osfhandle(p->fd), &ir, 1, &n);
+ }
+ } else {
+ HANDLE h = (HANDLE)_get_osfhandle(p->fd);
+ rb_w32_wait_events(&h, 1, INFINITE);
+ }
+ } else {
+ break;
+ }
+ }
+ }
+#endif
+
+ ss = read(p->fd, &ch, 1);
+ if (ss == 0) {
+ errno = 0;
+ return EOF;
+ }
+ if (ss != 1)
+ return EOF;
+ return (unsigned char)ch;
+}
+
+static void *
+getc_func(void *data1)
+{
+ struct getc_struct *p = data1;
+ errno = 0;
+ p->ret = getc_body(p);
+ p->err = errno;
+ return NULL;
+}
+
+static int
+readline_getc(FILE *input)
+{
+ struct getc_struct data;
+ if (input == NULL) /* editline may give NULL as input. */
+ input = stdin;
+ data.input = input;
+ data.fd = fileno(input);
+ again:
+ data.ret = EOF;
+ data.err = EINTR; /* getc_func is not called if already interrupted. */
+ rb_thread_call_without_gvl2(getc_func, &data, RUBY_UBF_IO, NULL);
+ if (data.ret == EOF) {
+ if (data.err == 0) {
+ return EOF;
+ }
+ if (data.err == EINTR) {
+ rb_thread_check_ints();
+ goto again;
+ }
+ if (data.err == EWOULDBLOCK || data.err == EAGAIN) {
+ int ret;
+ if (fileno(input) != data.fd)
+ rb_bug("readline_getc: input closed unexpectedly or memory corrupted");
+ ret = rb_wait_for_single_fd(data.fd, RB_WAITFD_IN, NULL);
+ if (ret != -1 || errno == EINTR)
+ goto again;
+ rb_sys_fail("rb_wait_for_single_fd");
+ }
+ errno = data.err;
+ rb_sys_fail("read");
+ }
+ return data.ret;
+}
+
+#elif defined HAVE_RL_EVENT_HOOK
+#define BUSY_WAIT 0
+
+static int readline_event(void);
+static int
+readline_event(void)
+{
+#if BUSY_WAIT
+ rb_thread_schedule();
+#else
+ rb_wait_for_single_fd(fileno(rl_instream), RB_WAITFD_IN, NULL);
+ return 0;
+#endif
+}
+#endif
+
+#if USE_INSERT_IGNORE_ESCAPE
+static VALUE
+insert_ignore_escape(VALUE self, VALUE prompt)
+{
+ VALUE last_prompt, orig_prompt = rb_attr_get(self, id_orig_prompt);
+ int ignoring = 0;
+ const char *s0, *s, *e;
+ long len;
+ static const char ignore_code[2] = {RL_PROMPT_START_IGNORE, RL_PROMPT_END_IGNORE};
+
+ prompt = rb_str_new_shared(prompt);
+ last_prompt = rb_attr_get(self, id_last_prompt);
+ if (orig_prompt == prompt) return last_prompt;
+ len = RSTRING_LEN(prompt);
+ if (NIL_P(last_prompt)) {
+ last_prompt = rb_str_tmp_new(len);
+ }
+
+ s = s0 = RSTRING_PTR(prompt);
+ e = s0 + len;
+ rb_str_set_len(last_prompt, 0);
+ while (s < e && *s) {
+ switch (*s) {
+ case RL_PROMPT_START_IGNORE:
+ ignoring = -1;
+ rb_str_cat(last_prompt, s0, ++s - s0);
+ s0 = s;
+ break;
+ case RL_PROMPT_END_IGNORE:
+ ignoring = 0;
+ rb_str_cat(last_prompt, s0, ++s - s0);
+ s0 = s;
+ break;
+ case '\033':
+ if (++s < e && *s == '[') {
+ rb_str_cat(last_prompt, s0, s - s0 - 1);
+ s0 = s - 1;
+ while (++s < e && *s) {
+ if (ISALPHA(*(unsigned char *)s)) {
+ if (!ignoring) {
+ ignoring = 1;
+ rb_str_cat(last_prompt, ignore_code+0, 1);
+ }
+ rb_str_cat(last_prompt, s0, ++s - s0);
+ s0 = s;
+ break;
+ }
+ else if (!(('0' <= *s && *s <= '9') || *s == ';')) {
+ break;
+ }
+ }
+ }
+ break;
+ default:
+ if (ignoring > 0) {
+ ignoring = 0;
+ rb_str_cat(last_prompt, ignore_code+1, 1);
+ }
+ s++;
+ break;
+ }
+ }
+ if (ignoring > 0) {
+ ignoring = 0;
+ rb_str_cat(last_prompt, ignore_code+1, 1);
+ }
+ rb_str_cat(last_prompt, s0, s - s0);
+
+ rb_ivar_set(self, id_orig_prompt, prompt);
+ rb_ivar_set(self, id_last_prompt, last_prompt);
+
+ return last_prompt;
+}
+#endif
+
+static VALUE
+readline_get(VALUE prompt)
+{
+#ifdef HAVE_RL_COMPLETION_APPEND_CHARACTER
+ readline_completion_append_character = rl_completion_append_character;
+#endif
+ return (VALUE)readline((char *)prompt);
+}
+
+static void
+clear_rl_instream(void)
+{
+ if (readline_rl_instream) {
+ fclose(readline_rl_instream);
+ if (rl_instream == readline_rl_instream)
+ rl_instream = NULL;
+ readline_rl_instream = NULL;
+ }
+ readline_instream = Qfalse;
+}
+
+static void
+clear_rl_outstream(void)
+{
+ if (readline_rl_outstream) {
+ fclose(readline_rl_outstream);
+ if (rl_outstream == readline_rl_outstream)
+ rl_outstream = NULL;
+ readline_rl_outstream = NULL;
+ }
+ readline_outstream = Qfalse;
+}
+
+static void
+prepare_readline(void)
+{
+ static int initialized = 0;
+ if (!initialized) {
+ rl_initialize();
+ initialized = 1;
+ }
+
+ if (readline_instream) {
+ rb_io_t *ifp;
+ rb_io_check_initialized(ifp = RFILE(rb_io_taint_check(readline_instream))->fptr);
+ if (ifp->fd < 0) {
+ clear_rl_instream();
+ rb_raise(rb_eIOError, "closed readline input");
+ }
+ }
+
+ if (readline_outstream) {
+ rb_io_t *ofp;
+ rb_io_check_initialized(ofp = RFILE(rb_io_taint_check(readline_outstream))->fptr);
+ if (ofp->fd < 0) {
+ clear_rl_outstream();
+ rb_raise(rb_eIOError, "closed readline output");
+ }
+ }
+}
+
+/*
+ * call-seq:
+ * Readline.readline(prompt = "", add_hist = false) -> string or nil
+ *
+ * Shows the +prompt+ and reads the inputted line with line editing.
+ * The inputted line is added to the history if +add_hist+ is true.
+ *
+ * Returns nil when the inputted line is empty and user inputs EOF
+ * (Presses ^D on UNIX).
+ *
+ * Raises IOError exception if one of below conditions are satisfied.
+ * 1. stdin was closed.
+ * 2. stdout was closed.
+ *
+ * This method supports thread. Switches the thread context when waits
+ * inputting line.
+ *
+ * Supports line edit when inputs line. Provides VI and Emacs editing mode.
+ * Default is Emacs editing mode.
+ *
+ * NOTE: Terminates ruby interpreter and does not return the terminal
+ * status after user pressed '^C' when wait inputting line.
+ * Give 3 examples that avoid it.
+ *
+ * * Catches the Interrupt exception by pressed ^C after returns
+ * terminal status:
+ *
+ * require "readline"
+ *
+ * stty_save = `stty -g`.chomp
+ * begin
+ * while buf = Readline.readline
+ * p buf
+ * end
+ * rescue Interrupt
+ * system("stty", stty_save)
+ * exit
+ * end
+ * end
+ * end
+ *
+ * * Catches the INT signal by pressed ^C after returns terminal
+ * status:
+ *
+ * require "readline"
+ *
+ * stty_save = `stty -g`.chomp
+ * trap("INT") { system "stty", stty_save; exit }
+ *
+ * while buf = Readline.readline
+ * p buf
+ * end
+ *
+ * * Ignores pressing ^C:
+ *
+ * require "readline"
+ *
+ * trap("INT", "SIG_IGN")
+ *
+ * while buf = Readline.readline
+ * p buf
+ * end
+ *
+ * Can make as follows with Readline::HISTORY constant.
+ * It does not record to the history if the inputted line is empty or
+ * the same it as last one.
+ *
+ * require "readline"
+ *
+ * while buf = Readline.readline("> ", true)
+ * # p Readline::HISTORY.to_a
+ * Readline::HISTORY.pop if /^\s*$/ =~ buf
+ *
+ * begin
+ * if Readline::HISTORY[Readline::HISTORY.length-2] == buf
+ * Readline::HISTORY.pop
+ * end
+ * rescue IndexError
+ * end
+ *
+ * # p Readline::HISTORY.to_a
+ * print "-> ", buf, "\n"
+ * end
+ */
+static VALUE
+readline_readline(int argc, VALUE *argv, VALUE self)
+{
+ VALUE tmp, add_hist, result;
+ char *prompt = NULL;
+ char *buff;
+ int status;
+
+ if (rb_scan_args(argc, argv, "02", &tmp, &add_hist) > 0) {
+ OutputStringValue(tmp);
+#if USE_INSERT_IGNORE_ESCAPE
+ tmp = insert_ignore_escape(self, tmp);
+ rb_str_locktmp(tmp);
+#endif
+ prompt = RSTRING_PTR(tmp);
+ }
+
+ prepare_readline();
+
+#ifdef _WIN32
+ rl_prep_terminal(1);
+#endif
+ buff = (char*)rb_protect(readline_get, (VALUE)prompt, &status);
+#if USE_INSERT_IGNORE_ESCAPE
+ if (prompt) {
+ rb_str_unlocktmp(tmp);
+ }
+#endif
+ if (status) {
+#if defined HAVE_RL_CLEANUP_AFTER_SIGNAL
+ /* restore terminal mode and signal handler*/
+#if defined HAVE_RL_FREE_LINE_STATE
+ rl_free_line_state();
+#endif
+ rl_cleanup_after_signal();
+#elif defined HAVE_RL_DEPREP_TERM_FUNCTION
+ /* restore terminal mode */
+ if (rl_deprep_term_function != NULL) /* NULL in libedit. [ruby-dev:29116] */
+ (*rl_deprep_term_function)();
+ else
+#else
+ rl_deprep_terminal();
+#endif
+ rb_jump_tag(status);
+ }
+
+ if (RTEST(add_hist) && buff) {
+ add_history(buff);
+ }
+ if (buff) {
+ result = rb_locale_str_new_cstr(buff);
+ }
+ else
+ result = Qnil;
+ if (buff) free(buff);
+ return result;
+}
+
+/*
+ * call-seq:
+ * Readline.input = input
+ *
+ * Specifies a File object +input+ that is input stream for
+ * Readline.readline method.
+ */
+static VALUE
+readline_s_set_input(VALUE self, VALUE input)
+{
+ rb_io_t *ifp;
+ int fd;
+ FILE *f;
+
+ if (NIL_P(input)) {
+ clear_rl_instream();
+ }
+ else {
+ Check_Type(input, T_FILE);
+ GetOpenFile(input, ifp);
+ clear_rl_instream();
+ fd = rb_cloexec_dup(ifp->fd);
+ if (fd == -1)
+ rb_sys_fail("dup");
+ f = fdopen(fd, "r");
+ if (f == NULL) {
+ int save_errno = errno;
+ close(fd);
+ errno = save_errno;
+ rb_sys_fail("fdopen");
+ }
+ rl_instream = readline_rl_instream = f;
+ readline_instream = input;
+ }
+ return input;
+}
+
+/*
+ * call-seq:
+ * Readline.output = output
+ *
+ * Specifies a File object +output+ that is output stream for
+ * Readline.readline method.
+ */
+static VALUE
+readline_s_set_output(VALUE self, VALUE output)
+{
+ rb_io_t *ofp;
+ int fd;
+ FILE *f;
+
+ if (NIL_P(output)) {
+ clear_rl_outstream();
+ }
+ else {
+ Check_Type(output, T_FILE);
+ GetOpenFile(output, ofp);
+ clear_rl_outstream();
+ fd = rb_cloexec_dup(ofp->fd);
+ if (fd == -1)
+ rb_sys_fail("dup");
+ f = fdopen(fd, "w");
+ if (f == NULL) {
+ int save_errno = errno;
+ close(fd);
+ errno = save_errno;
+ rb_sys_fail("fdopen");
+ }
+ rl_outstream = readline_rl_outstream = f;
+ readline_outstream = output;
+ }
+ return output;
+}
+
+#if defined(HAVE_RL_PRE_INPUT_HOOK)
+/*
+ * call-seq:
+ * Readline.pre_input_hook = proc
+ *
+ * Specifies a Proc object +proc+ to call after the first prompt has
+ * been printed and just before readline starts reading input
+ * characters.
+ *
+ * See GNU Readline's rl_pre_input_hook variable.
+ *
+ * Raises ArgumentError if +proc+ does not respond to the call method.
+ *
+ * Raises NotImplementedError if the using readline library does not support.
+ */
+static VALUE
+readline_s_set_pre_input_hook(VALUE self, VALUE proc)
+{
+ if (!NIL_P(proc) && !rb_respond_to(proc, rb_intern("call")))
+ rb_raise(rb_eArgError, "argument must respond to `call'");
+ return rb_ivar_set(mReadline, id_pre_input_hook, proc);
+}
+
+/*
+ * call-seq:
+ * Readline.pre_input_hook -> proc
+ *
+ * Returns a Proc object +proc+ to call after the first prompt has
+ * been printed and just before readline starts reading input
+ * characters. The default is nil.
+ *
+ * Raises NotImplementedError if the using readline library does not support.
+ */
+static VALUE
+readline_s_get_pre_input_hook(VALUE self)
+{
+ return rb_attr_get(mReadline, id_pre_input_hook);
+}
+
+static int
+readline_pre_input_hook(void)
+{
+ VALUE proc;
+
+ proc = rb_attr_get(mReadline, id_pre_input_hook);
+ if (!NIL_P(proc))
+ rb_funcall(proc, rb_intern("call"), 0);
+ return 0;
+}
+#else
+#define readline_s_set_pre_input_hook rb_f_notimplement
+#define readline_s_get_pre_input_hook rb_f_notimplement
+#endif
+
+#if defined(HAVE_RL_INSERT_TEXT)
+/*
+ * call-seq:
+ * Readline.insert_text(string) -> self
+ *
+ * Insert text into the line at the current cursor position.
+ *
+ * See GNU Readline's rl_insert_text function.
+ *
+ * Raises NotImplementedError if the using readline library does not support.
+ */
+static VALUE
+readline_s_insert_text(VALUE self, VALUE str)
+{
+ OutputStringValue(str);
+ rl_insert_text(RSTRING_PTR(str));
+ return self;
+}
+#else
+#define readline_s_insert_text rb_f_notimplement
+#endif
+
+#if defined(HAVE_RL_DELETE_TEXT)
+/*
+ * call-seq:
+ * Readline.delete_text([start[, length]]) -> self
+ * Readline.delete_text(start..end) -> self
+ * Readline.delete_text() -> self
+ *
+ * Delete text between start and end in the current line.
+ *
+ * See GNU Readline's rl_delete_text function.
+ *
+ * Raises NotImplementedError if the using readline library does not support.
+ */
+static VALUE
+readline_s_delete_text(int argc, VALUE *argv, VALUE self)
+{
+ rb_check_arity(argc, 0, 2);
+ if (rl_line_buffer) {
+ char *p, *ptr = rl_line_buffer;
+ long beg = 0, len = strlen(rl_line_buffer);
+ struct RString fakestr;
+ VALUE str = rb_setup_fake_str(&fakestr, ptr, len, rb_locale_encoding());
+ OBJ_FREEZE(str);
+ if (argc == 2) {
+ beg = NUM2LONG(argv[0]);
+ len = NUM2LONG(argv[1]);
+ num_pos:
+ p = rb_str_subpos(str, beg, &len);
+ if (!p) rb_raise(rb_eArgError, "invalid index");
+ beg = p - ptr;
+ }
+ else if (argc == 1) {
+ len = rb_str_strlen(str);
+ if (!rb_range_beg_len(argv[0], &beg, &len, len, 1)) {
+ beg = NUM2LONG(argv[0]);
+ goto num_pos;
+ }
+ }
+ rl_delete_text(rb_long2int(beg), rb_long2int(beg + len));
+ }
+ return self;
+}
+#else
+#define readline_s_delete_text rb_f_notimplement
+#endif
+
+#if defined(HAVE_RL_REDISPLAY)
+/*
+ * call-seq:
+ * Readline.redisplay -> self
+ *
+ * Change what's displayed on the screen to reflect the current
+ * contents.
+ *
+ * See GNU Readline's rl_redisplay function.
+ *
+ * Raises NotImplementedError if the using readline library does not support.
+ */
+static VALUE
+readline_s_redisplay(VALUE self)
+{
+ rl_redisplay();
+ return self;
+}
+#else
+#define readline_s_redisplay rb_f_notimplement
+#endif
+
+/*
+ * call-seq:
+ * Readline.completion_proc = proc
+ *
+ * Specifies a Proc object +proc+ to determine completion behavior. It
+ * should take input string and return an array of completion candidates.
+ *
+ * The default completion is used if +proc+ is nil.
+ *
+ * The String that is passed to the Proc depends on the
+ * Readline.completer_word_break_characters property. By default the word
+ * under the cursor is passed to the Proc. For example, if the input is "foo
+ * bar" then only "bar" would be passed to the completion Proc.
+ *
+ * Upon successful completion the Readline.completion_append_character will be
+ * appended to the input so the user can start working on their next argument.
+ *
+ * = Examples
+ *
+ * == Completion for a Static List
+ *
+ * require 'readline'
+ *
+ * LIST = [
+ * 'search', 'download', 'open',
+ * 'help', 'history', 'quit',
+ * 'url', 'next', 'clear',
+ * 'prev', 'past'
+ * ].sort
+ *
+ * comp = proc { |s| LIST.grep(/^#{Regexp.escape(s)}/) }
+ *
+ * Readline.completion_append_character = " "
+ * Readline.completion_proc = comp
+ *
+ * while line = Readline.readline('> ', true)
+ * p line
+ * end
+ *
+ * == Completion For Directory Contents
+ *
+ * require 'readline'
+ *
+ * Readline.completion_append_character = " "
+ * Readline.completion_proc = Proc.new do |str|
+ * Dir[str+'*'].grep(/^#{Regexp.escape(str)}/)
+ * end
+ *
+ * while line = Readline.readline('> ', true)
+ * p line
+ * end
+ *
+ * = Autocomplete strategies
+ *
+ * When working with auto-complete there are some strategies that work well.
+ * To get some ideas you can take a look at the
+ * completion.rb[http://svn.ruby-lang.org/repos/ruby/trunk/lib/irb/completion.rb]
+ * file for irb.
+ *
+ * The common strategy is to take a list of possible completions and filter it
+ * down to those completions that start with the user input. In the above
+ * examples Enumerator.grep is used. The input is escaped to prevent Regexp
+ * special characters from interfering with the matching.
+ *
+ * It may also be helpful to use the Abbrev library to generate completions.
+ *
+ * Raises ArgumentError if +proc+ does not respond to the call method.
+ */
+static VALUE
+readline_s_set_completion_proc(VALUE self, VALUE proc)
+{
+ if (!NIL_P(proc) && !rb_respond_to(proc, rb_intern("call")))
+ rb_raise(rb_eArgError, "argument must respond to `call'");
+ return rb_ivar_set(mReadline, completion_proc, proc);
+}
+
+/*
+ * call-seq:
+ * Readline.completion_proc -> proc
+ *
+ * Returns the completion Proc object.
+ */
+static VALUE
+readline_s_get_completion_proc(VALUE self)
+{
+ return rb_attr_get(mReadline, completion_proc);
+}
+
+/*
+ * call-seq:
+ * Readline.completion_case_fold = bool
+ *
+ * Sets whether or not to ignore case on completion.
+ */
+static VALUE
+readline_s_set_completion_case_fold(VALUE self, VALUE val)
+{
+ return rb_ivar_set(mReadline, completion_case_fold, val);
+}
+
+/*
+ * call-seq:
+ * Readline.completion_case_fold -> bool
+ *
+ * Returns true if completion ignores case. If no, returns false.
+ *
+ * NOTE: Returns the same object that is specified by
+ * Readline.completion_case_fold= method.
+ *
+ * require "readline"
+ *
+ * Readline.completion_case_fold = "This is a String."
+ * p Readline.completion_case_fold # => "This is a String."
+ */
+static VALUE
+readline_s_get_completion_case_fold(VALUE self)
+{
+ return rb_attr_get(mReadline, completion_case_fold);
+}
+
+#ifdef HAVE_RL_LINE_BUFFER
+/*
+ * call-seq:
+ * Readline.line_buffer -> string
+ *
+ * Returns the full line that is being edited. This is useful from
+ * within the complete_proc for determining the context of the
+ * completion request.
+ *
+ * The length of +Readline.line_buffer+ and GNU Readline's rl_end are
+ * same.
+ *
+ * Raises NotImplementedError if the using readline library does not support.
+ */
+static VALUE
+readline_s_get_line_buffer(VALUE self)
+{
+ if (rl_line_buffer == NULL)
+ return Qnil;
+ return rb_locale_str_new_cstr(rl_line_buffer);
+}
+#else
+#define readline_s_get_line_buffer rb_f_notimplement
+#endif
+
+#ifdef HAVE_RL_POINT
+/*
+ * call-seq:
+ * Readline.point -> int
+ *
+ * Returns the index of the current cursor position in
+ * +Readline.line_buffer+.
+ *
+ * The index in +Readline.line_buffer+ which matches the start of
+ * input-string passed to completion_proc is computed by subtracting
+ * the length of input-string from +Readline.point+.
+ *
+ * start = (the length of input-string) - Readline.point
+ *
+ * Raises NotImplementedError if the using readline library does not support.
+ */
+static VALUE
+readline_s_get_point(VALUE self)
+{
+ return INT2NUM(rl_point);
+}
+
+/*
+ * call-seq:
+ * Readline.point = int
+ *
+ * Set the index of the current cursor position in
+ * +Readline.line_buffer+.
+ *
+ * Raises NotImplementedError if the using readline library does not support.
+ *
+ * See +Readline.point+.
+ */
+static VALUE
+readline_s_set_point(VALUE self, VALUE pos)
+{
+ rl_point = NUM2INT(pos);
+ return pos;
+}
+#else
+#define readline_s_get_point rb_f_notimplement
+#define readline_s_set_point rb_f_notimplement
+#endif
+
+static char **
+readline_attempted_completion_function(const char *text, int start, int end)
+{
+ VALUE proc, ary, temp;
+ char **result;
+ int case_fold;
+ long i, matches;
+ rb_encoding *enc;
+ VALUE encobj;
+
+ proc = rb_attr_get(mReadline, completion_proc);
+ if (NIL_P(proc))
+ return NULL;
+#ifdef HAVE_RL_COMPLETION_APPEND_CHARACTER
+ rl_completion_append_character = readline_completion_append_character;
+#endif
+#ifdef HAVE_RL_ATTEMPTED_COMPLETION_OVER
+ rl_attempted_completion_over = 1;
+#endif
+ case_fold = RTEST(rb_attr_get(mReadline, completion_case_fold));
+ ary = rb_funcall(proc, rb_intern("call"), 1, rb_locale_str_new_cstr(text));
+ if (!RB_TYPE_P(ary, T_ARRAY))
+ ary = rb_Array(ary);
+ matches = RARRAY_LEN(ary);
+ if (matches == 0) return NULL;
+ result = (char**)malloc((matches + 2)*sizeof(char*));
+ if (result == NULL) rb_memerror();
+ enc = rb_locale_encoding();
+ encobj = rb_enc_from_encoding(enc);
+ for (i = 0; i < matches; i++) {
+ temp = rb_obj_as_string(RARRAY_PTR(ary)[i]);
+ StringValueCStr(temp); /* must be NUL-terminated */
+ rb_enc_check(encobj, temp);
+ result[i + 1] = (char*)malloc(RSTRING_LEN(temp) + 1);
+ if (result[i + 1] == NULL) rb_memerror();
+ strcpy(result[i + 1], RSTRING_PTR(temp));
+ }
+ result[matches + 1] = NULL;
+
+ if (matches == 1) {
+ result[0] = strdup(result[1]);
+ }
+ else {
+ const char *result1 = result[1];
+ long low = strlen(result1);
+
+ for (i = 1; i < matches; ++i) {
+ register int c1, c2;
+ long i1, i2, l2;
+ int n1, n2;
+ const char *p2 = result[i + 1];
+
+ l2 = strlen(p2);
+ for (i1 = i2 = 0; i1 < low && i2 < l2; i1 += n1, i2 += n2) {
+ c1 = rb_enc_codepoint_len(result1 + i1, result1 + low, &n1, enc);
+ c2 = rb_enc_codepoint_len(p2 + i2, p2 + l2, &n2, enc);
+ if (case_fold) {
+ c1 = rb_tolower(c1);
+ c2 = rb_tolower(c2);
+ }
+ if (c1 != c2) break;
+ }
+
+ low = i1;
+ }
+ result[0] = (char*)malloc(low + 1);
+ if (result[0] == NULL) rb_memerror();
+ strncpy(result[0], result[1], low);
+ result[0][low] = '\0';
+ }
+
+ return result;
+}
+
+#ifdef HAVE_RL_SET_SCREEN_SIZE
+/*
+ * call-seq:
+ * Readline.set_screen_size(rows, columns) -> self
+ *
+ * Set terminal size to +rows+ and +columns+.
+ *
+ * See GNU Readline's rl_set_screen_size function.
+ *
+ * Raises NotImplementedError if the using readline library does not support.
+ */
+static VALUE
+readline_s_set_screen_size(VALUE self, VALUE rows, VALUE columns)
+{
+ rl_set_screen_size(NUM2INT(rows), NUM2INT(columns));
+ return self;
+}
+#else
+#define readline_s_set_screen_size rb_f_notimplement
+#endif
+
+#ifdef HAVE_RL_GET_SCREEN_SIZE
+/*
+ * call-seq:
+ * Readline.get_screen_size -> [rows, columns]
+ *
+ * Returns the terminal's rows and columns.
+ *
+ * See GNU Readline's rl_get_screen_size function.
+ *
+ * Raises NotImplementedError if the using readline library does not support.
+ */
+static VALUE
+readline_s_get_screen_size(VALUE self)
+{
+ int rows, columns;
+ VALUE res;
+
+ rl_get_screen_size(&rows, &columns);
+ res = rb_ary_new();
+ rb_ary_push(res, INT2NUM(rows));
+ rb_ary_push(res, INT2NUM(columns));
+ return res;
+}
+#else
+#define readline_s_get_screen_size rb_f_notimplement
+#endif
+
+#ifdef HAVE_RL_VI_EDITING_MODE
+/*
+ * call-seq:
+ * Readline.vi_editing_mode -> nil
+ *
+ * Specifies VI editing mode. See the manual of GNU Readline for
+ * details of VI editing mode.
+ *
+ * Raises NotImplementedError if the using readline library does not support.
+ */
+static VALUE
+readline_s_vi_editing_mode(VALUE self)
+{
+ rl_vi_editing_mode(1,0);
+ return Qnil;
+}
+#else
+#define readline_s_vi_editing_mode rb_f_notimplement
+#endif
+
+#ifdef HAVE_RL_EDITING_MODE
+/*
+ * call-seq:
+ * Readline.vi_editing_mode? -> bool
+ *
+ * Returns true if vi mode is active. Returns false if not.
+ *
+ * Raises NotImplementedError if the using readline library does not support.
+ */
+static VALUE
+readline_s_vi_editing_mode_p(VALUE self)
+{
+ return rl_editing_mode == 0 ? Qtrue : Qfalse;
+}
+#else
+#define readline_s_vi_editing_mode_p rb_f_notimplement
+#endif
+
+#ifdef HAVE_RL_EMACS_EDITING_MODE
+/*
+ * call-seq:
+ * Readline.emacs_editing_mode -> nil
+ *
+ * Specifies Emacs editing mode. The default is this mode. See the
+ * manual of GNU Readline for details of Emacs editing mode.
+ *
+ * Raises NotImplementedError if the using readline library does not support.
+ */
+static VALUE
+readline_s_emacs_editing_mode(VALUE self)
+{
+ rl_emacs_editing_mode(1,0);
+ return Qnil;
+}
+#else
+#define readline_s_emacs_editing_mode rb_f_notimplement
+#endif
+
+#ifdef HAVE_RL_EDITING_MODE
+/*
+ * call-seq:
+ * Readline.emacs_editing_mode? -> bool
+ *
+ * Returns true if emacs mode is active. Returns false if not.
+ *
+ * Raises NotImplementedError if the using readline library does not support.
+ */
+static VALUE
+readline_s_emacs_editing_mode_p(VALUE self)
+{
+ return rl_editing_mode == 1 ? Qtrue : Qfalse;
+}
+#else
+#define readline_s_emacs_editing_mode_p rb_f_notimplement
+#endif
+
+#ifdef HAVE_RL_COMPLETION_APPEND_CHARACTER
+/*
+ * call-seq:
+ * Readline.completion_append_character = char
+ *
+ * Specifies a character to be appended on completion.
+ * Nothing will be appended if an empty string ("") or nil is
+ * specified.
+ *
+ * For example:
+ * require "readline"
+ *
+ * Readline.readline("> ", true)
+ * Readline.completion_append_character = " "
+ *
+ * Result:
+ * >
+ * Input "/var/li".
+ *
+ * > /var/li
+ * Press TAB key.
+ *
+ * > /var/lib
+ * Completes "b" and appends " ". So, you can continuously input "/usr".
+ *
+ * > /var/lib /usr
+ *
+ * NOTE: Only one character can be specified. When "string" is
+ * specified, sets only "s" that is the first.
+ *
+ * require "readline"
+ *
+ * Readline.completion_append_character = "string"
+ * p Readline.completion_append_character # => "s"
+ *
+ * Raises NotImplementedError if the using readline library does not support.
+ */
+static VALUE
+readline_s_set_completion_append_character(VALUE self, VALUE str)
+{
+ if (NIL_P(str)) {
+ rl_completion_append_character = '\0';
+ }
+ else {
+ OutputStringValue(str);
+ if (RSTRING_LEN(str) == 0) {
+ rl_completion_append_character = '\0';
+ } else {
+ rl_completion_append_character = RSTRING_PTR(str)[0];
+ }
+ }
+ return self;
+}
+#else
+#define readline_s_set_completion_append_character rb_f_notimplement
+#endif
+
+#ifdef HAVE_RL_COMPLETION_APPEND_CHARACTER
+/*
+ * call-seq:
+ * Readline.completion_append_character -> char
+ *
+ * Returns a string containing a character to be appended on
+ * completion. The default is a space (" ").
+ *
+ * Raises NotImplementedError if the using readline library does not support.
+ */
+static VALUE
+readline_s_get_completion_append_character(VALUE self)
+{
+ char buf[1];
+
+ if (rl_completion_append_character == '\0')
+ return Qnil;
+
+ buf[0] = (char) rl_completion_append_character;
+ return rb_locale_str_new(buf, 1);
+}
+#else
+#define readline_s_get_completion_append_character rb_f_notimplement
+#endif
+
+#ifdef HAVE_RL_BASIC_WORD_BREAK_CHARACTERS
+/*
+ * call-seq:
+ * Readline.basic_word_break_characters = string
+ *
+ * Sets the basic list of characters that signal a break between words
+ * for the completer routine. The default is the characters which
+ * break words for completion in Bash: " \t\n\"\\'`@$><=;|&{(".
+ *
+ * Raises NotImplementedError if the using readline library does not support.
+ */
+static VALUE
+readline_s_set_basic_word_break_characters(VALUE self, VALUE str)
+{
+ static char *basic_word_break_characters = NULL;
+
+ OutputStringValue(str);
+ if (basic_word_break_characters == NULL) {
+ basic_word_break_characters =
+ ALLOC_N(char, RSTRING_LEN(str) + 1);
+ }
+ else {
+ REALLOC_N(basic_word_break_characters, char, RSTRING_LEN(str) + 1);
+ }
+ strncpy(basic_word_break_characters,
+ RSTRING_PTR(str), RSTRING_LEN(str));
+ basic_word_break_characters[RSTRING_LEN(str)] = '\0';
+ rl_basic_word_break_characters = basic_word_break_characters;
+ return self;
+}
+#else
+#define readline_s_set_basic_word_break_characters rb_f_notimplement
+#endif
+
+#ifdef HAVE_RL_BASIC_WORD_BREAK_CHARACTERS
+/*
+ * call-seq:
+ * Readline.basic_word_break_characters -> string
+ *
+ * Gets the basic list of characters that signal a break between words
+ * for the completer routine.
+ *
+ * Raises NotImplementedError if the using readline library does not support.
+ */
+static VALUE
+readline_s_get_basic_word_break_characters(VALUE self, VALUE str)
+{
+ if (rl_basic_word_break_characters == NULL)
+ return Qnil;
+ return rb_locale_str_new_cstr(rl_basic_word_break_characters);
+}
+#else
+#define readline_s_get_basic_word_break_characters rb_f_notimplement
+#endif
+
+#ifdef HAVE_RL_COMPLETER_WORD_BREAK_CHARACTERS
+/*
+ * call-seq:
+ * Readline.completer_word_break_characters = string
+ *
+ * Sets the basic list of characters that signal a break between words
+ * for rl_complete_internal(). The default is the value of
+ * Readline.basic_word_break_characters.
+ *
+ * Raises NotImplementedError if the using readline library does not support.
+ */
+static VALUE
+readline_s_set_completer_word_break_characters(VALUE self, VALUE str)
+{
+ static char *completer_word_break_characters = NULL;
+
+ OutputStringValue(str);
+ if (completer_word_break_characters == NULL) {
+ completer_word_break_characters =
+ ALLOC_N(char, RSTRING_LEN(str) + 1);
+ }
+ else {
+ REALLOC_N(completer_word_break_characters, char, RSTRING_LEN(str) + 1);
+ }
+ strncpy(completer_word_break_characters,
+ RSTRING_PTR(str), RSTRING_LEN(str));
+ completer_word_break_characters[RSTRING_LEN(str)] = '\0';
+ rl_completer_word_break_characters = completer_word_break_characters;
+ return self;
+}
+#else
+#define readline_s_set_completer_word_break_characters rb_f_notimplement
+#endif
+
+#ifdef HAVE_RL_COMPLETER_WORD_BREAK_CHARACTERS
+/*
+ * call-seq:
+ * Readline.completer_word_break_characters -> string
+ *
+ * Gets the basic list of characters that signal a break between words
+ * for rl_complete_internal().
+ *
+ * Raises NotImplementedError if the using readline library does not support.
+ */
+static VALUE
+readline_s_get_completer_word_break_characters(VALUE self, VALUE str)
+{
+ if (rl_completer_word_break_characters == NULL)
+ return Qnil;
+ return rb_locale_str_new_cstr(rl_completer_word_break_characters);
+}
+#else
+#define readline_s_get_completer_word_break_characters rb_f_notimplement
+#endif
+
+#if defined(HAVE_RL_SPECIAL_PREFIXES)
+/*
+ * call-seq:
+ * Readline.special_prefixes = string
+ *
+ * Sets the list of characters that are word break characters, but
+ * should be left in text when it is passed to the completion
+ * function. Programs can use this to help determine what kind of
+ * completing to do. For instance, Bash sets this variable to "$@" so
+ * that it can complete shell variables and hostnames.
+ *
+ * See GNU Readline's rl_special_prefixes variable.
+ *
+ * Raises NotImplementedError if the using readline library does not support.
+ */
+static VALUE
+readline_s_set_special_prefixes(VALUE self, VALUE str)
+{
+ if (!NIL_P(str)) {
+ OutputStringValue(str);
+ str = rb_str_dup_frozen(str);
+ rb_obj_hide(str);
+ }
+ rb_ivar_set(mReadline, id_special_prefixes, str);
+ if (NIL_P(str)) {
+ rl_special_prefixes = NULL;
+ }
+ else {
+ rl_special_prefixes = RSTRING_PTR(str);
+ }
+ return self;
+}
+
+/*
+ * call-seq:
+ * Readline.special_prefixes -> string
+ *
+ * Gets the list of characters that are word break characters, but
+ * should be left in text when it is passed to the completion
+ * function.
+ *
+ * See GNU Readline's rl_special_prefixes variable.
+ *
+ * Raises NotImplementedError if the using readline library does not support.
+ */
+static VALUE
+readline_s_get_special_prefixes(VALUE self)
+{
+ VALUE str;
+ if (rl_special_prefixes == NULL) return Qnil;
+ str = rb_ivar_get(mReadline, id_special_prefixes);
+ if (!NIL_P(str)) {
+ str = rb_str_dup_frozen(str);
+ rb_obj_reveal(str, rb_cString);
+ }
+ return str;
+}
+#else
+#define readline_s_set_special_prefixes rb_f_notimplement
+#define readline_s_get_special_prefixes rb_f_notimplement
+#endif
+
+#ifdef HAVE_RL_BASIC_QUOTE_CHARACTERS
+/*
+ * call-seq:
+ * Readline.basic_quote_characters = string
+ *
+ * Sets a list of quote characters which can cause a word break.
+ *
+ * Raises NotImplementedError if the using readline library does not support.
+ */
+static VALUE
+readline_s_set_basic_quote_characters(VALUE self, VALUE str)
+{
+ static char *basic_quote_characters = NULL;
+
+ OutputStringValue(str);
+ if (basic_quote_characters == NULL) {
+ basic_quote_characters =
+ ALLOC_N(char, RSTRING_LEN(str) + 1);
+ }
+ else {
+ REALLOC_N(basic_quote_characters, char, RSTRING_LEN(str) + 1);
+ }
+ strncpy(basic_quote_characters,
+ RSTRING_PTR(str), RSTRING_LEN(str));
+ basic_quote_characters[RSTRING_LEN(str)] = '\0';
+ rl_basic_quote_characters = basic_quote_characters;
+
+ return self;
+}
+#else
+#define readline_s_set_basic_quote_characters rb_f_notimplement
+#endif
+
+#ifdef HAVE_RL_BASIC_QUOTE_CHARACTERS
+/*
+ * call-seq:
+ * Readline.basic_quote_characters -> string
+ *
+ * Gets a list of quote characters which can cause a word break.
+ *
+ * Raises NotImplementedError if the using readline library does not support.
+ */
+static VALUE
+readline_s_get_basic_quote_characters(VALUE self, VALUE str)
+{
+ if (rl_basic_quote_characters == NULL)
+ return Qnil;
+ return rb_locale_str_new_cstr(rl_basic_quote_characters);
+}
+#else
+#define readline_s_get_basic_quote_characters rb_f_notimplement
+#endif
+
+#ifdef HAVE_RL_COMPLETER_QUOTE_CHARACTERS
+/*
+ * call-seq:
+ * Readline.completer_quote_characters = string
+ *
+ * Sets a list of characters which can be used to quote a substring of
+ * the line. Completion occurs on the entire substring, and within
+ * the substring Readline.completer_word_break_characters are treated
+ * as any other character, unless they also appear within this list.
+ *
+ * Raises NotImplementedError if the using readline library does not support.
+ */
+static VALUE
+readline_s_set_completer_quote_characters(VALUE self, VALUE str)
+{
+ static char *completer_quote_characters = NULL;
+
+ OutputStringValue(str);
+ if (completer_quote_characters == NULL) {
+ completer_quote_characters =
+ ALLOC_N(char, RSTRING_LEN(str) + 1);
+ }
+ else {
+ REALLOC_N(completer_quote_characters, char, RSTRING_LEN(str) + 1);
+ }
+ strncpy(completer_quote_characters, RSTRING_PTR(str), RSTRING_LEN(str));
+ completer_quote_characters[RSTRING_LEN(str)] = '\0';
+ rl_completer_quote_characters = completer_quote_characters;
+
+ return self;
+}
+#else
+#define readline_s_set_completer_quote_characters rb_f_notimplement
+#endif
+
+#ifdef HAVE_RL_COMPLETER_QUOTE_CHARACTERS
+/*
+ * call-seq:
+ * Readline.completer_quote_characters -> string
+ *
+ * Gets a list of characters which can be used to quote a substring of
+ * the line.
+ *
+ * Raises NotImplementedError if the using readline library does not support.
+ */
+static VALUE
+readline_s_get_completer_quote_characters(VALUE self, VALUE str)
+{
+ if (rl_completer_quote_characters == NULL)
+ return Qnil;
+ return rb_locale_str_new_cstr(rl_completer_quote_characters);
+}
+#else
+#define readline_s_get_completer_quote_characters rb_f_notimplement
+#endif
+
+#ifdef HAVE_RL_FILENAME_QUOTE_CHARACTERS
+/*
+ * call-seq:
+ * Readline.filename_quote_characters = string
+ *
+ * Sets a list of characters that cause a filename to be quoted by the completer
+ * when they appear in a completed filename. The default is nil.
+ *
+ * Raises NotImplementedError if the using readline library does not support.
+ */
+static VALUE
+readline_s_set_filename_quote_characters(VALUE self, VALUE str)
+{
+ static char *filename_quote_characters = NULL;
+
+ OutputStringValue(str);
+ if (filename_quote_characters == NULL) {
+ filename_quote_characters =
+ ALLOC_N(char, RSTRING_LEN(str) + 1);
+ }
+ else {
+ REALLOC_N(filename_quote_characters, char, RSTRING_LEN(str) + 1);
+ }
+ strncpy(filename_quote_characters, RSTRING_PTR(str), RSTRING_LEN(str));
+ filename_quote_characters[RSTRING_LEN(str)] = '\0';
+ rl_filename_quote_characters = filename_quote_characters;
+
+ return self;
+}
+#else
+#define readline_s_set_filename_quote_characters rb_f_notimplement
+#endif
+
+#ifdef HAVE_RL_FILENAME_QUOTE_CHARACTERS
+/*
+ * call-seq:
+ * Readline.filename_quote_characters -> string
+ *
+ * Gets a list of characters that cause a filename to be quoted by the completer
+ * when they appear in a completed filename.
+ *
+ * Raises NotImplementedError if the using readline library does not support.
+ */
+static VALUE
+readline_s_get_filename_quote_characters(VALUE self, VALUE str)
+{
+ if (rl_filename_quote_characters == NULL)
+ return Qnil;
+ return rb_locale_str_new_cstr(rl_filename_quote_characters);
+}
+#else
+#define readline_s_get_filename_quote_characters rb_f_notimplement
+#endif
+
+#ifdef HAVE_RL_REFRESH_LINE
+/*
+ * call-seq:
+ * Readline.refresh_line -> nil
+ *
+ * Clear the current input line.
+ */
+static VALUE
+readline_s_refresh_line(VALUE self)
+{
+ prepare_readline();
+ rl_refresh_line(0, 0);
+ return Qnil;
+}
+#else
+#define readline_s_refresh_line rb_f_notimplement
+#endif
+
+static VALUE
+hist_to_s(VALUE self)
+{
+ return rb_str_new_cstr("HISTORY");
+}
+
+static int
+history_get_offset_history_base(int offset)
+{
+ return history_base + offset;
+}
+
+static int
+history_get_offset_0(int offset)
+{
+ return offset;
+}
+
+static VALUE
+hist_get(VALUE self, VALUE index)
+{
+ HIST_ENTRY *entry = NULL;
+ int i;
+
+ i = NUM2INT(index);
+ if (i < 0) {
+ i += history_length;
+ }
+ if (i >= 0) {
+ entry = history_get(history_get_offset_func(i));
+ }
+ if (entry == NULL) {
+ rb_raise(rb_eIndexError, "invalid index");
+ }
+ return rb_locale_str_new_cstr(entry->line);
+}
+
+#ifdef HAVE_REPLACE_HISTORY_ENTRY
+static VALUE
+hist_set(VALUE self, VALUE index, VALUE str)
+{
+ HIST_ENTRY *entry = NULL;
+ int i;
+
+ i = NUM2INT(index);
+ OutputStringValue(str);
+ if (i < 0) {
+ i += history_length;
+ }
+ if (i >= 0) {
+ entry = replace_history_entry(history_replace_offset_func(i), RSTRING_PTR(str), NULL);
+ }
+ if (entry == NULL) {
+ rb_raise(rb_eIndexError, "invalid index");
+ }
+ return str;
+}
+#else
+#define hist_set rb_f_notimplement
+#endif
+
+static VALUE
+hist_push(VALUE self, VALUE str)
+{
+ OutputStringValue(str);
+ add_history(RSTRING_PTR(str));
+ return self;
+}
+
+static VALUE
+hist_push_method(int argc, VALUE *argv, VALUE self)
+{
+ VALUE str;
+
+ while (argc--) {
+ str = *argv++;
+ OutputStringValue(str);
+ add_history(RSTRING_PTR(str));
+ }
+ return self;
+}
+
+static VALUE
+rb_remove_history(int index)
+{
+#ifdef HAVE_REMOVE_HISTORY
+ HIST_ENTRY *entry;
+ VALUE val;
+
+ entry = remove_history(index);
+ if (entry) {
+ val = rb_locale_str_new_cstr(entry->line);
+ free((void *) entry->line);
+ free(entry);
+ return val;
+ }
+ return Qnil;
+#else
+ rb_notimplement();
+
+ UNREACHABLE;
+#endif
+}
+
+static VALUE
+hist_pop(VALUE self)
+{
+ if (history_length > 0) {
+ return rb_remove_history(history_length - 1);
+ } else {
+ return Qnil;
+ }
+}
+
+static VALUE
+hist_shift(VALUE self)
+{
+ if (history_length > 0) {
+ return rb_remove_history(0);
+ } else {
+ return Qnil;
+ }
+}
+
+static VALUE
+hist_each(VALUE self)
+{
+ HIST_ENTRY *entry;
+ int i;
+
+ RETURN_ENUMERATOR(self, 0, 0);
+
+ for (i = 0; i < history_length; i++) {
+ entry = history_get(history_get_offset_func(i));
+ if (entry == NULL)
+ break;
+ rb_yield(rb_locale_str_new_cstr(entry->line));
+ }
+ return self;
+}
+
+static VALUE
+hist_length(VALUE self)
+{
+ return INT2NUM(history_length);
+}
+
+static VALUE
+hist_empty_p(VALUE self)
+{
+ return history_length == 0 ? Qtrue : Qfalse;
+}
+
+static VALUE
+hist_delete_at(VALUE self, VALUE index)
+{
+ int i;
+
+ i = NUM2INT(index);
+ if (i < 0)
+ i += history_length;
+ if (i < 0 || i > history_length - 1) {
+ rb_raise(rb_eIndexError, "invalid index");
+ }
+ return rb_remove_history(i);
+}
+
+#ifdef HAVE_CLEAR_HISTORY
+static VALUE
+hist_clear(VALUE self)
+{
+ clear_history();
+ return self;
+}
+#else
+#define hist_clear rb_f_notimplement
+#endif
+
+static VALUE
+filename_completion_proc_call(VALUE self, VALUE str)
+{
+ VALUE result;
+ char **matches;
+ int i;
+
+ matches = rl_completion_matches(StringValuePtr(str),
+ rl_filename_completion_function);
+ if (matches) {
+ result = rb_ary_new();
+ for (i = 0; matches[i]; i++) {
+ rb_ary_push(result, rb_locale_str_new_cstr(matches[i]));
+ free(matches[i]);
+ }
+ free(matches);
+ if (RARRAY_LEN(result) >= 2)
+ rb_ary_shift(result);
+ }
+ else {
+ result = Qnil;
+ }
+ return result;
+}
+
+static VALUE
+username_completion_proc_call(VALUE self, VALUE str)
+{
+ VALUE result;
+ char **matches;
+ int i;
+
+ matches = rl_completion_matches(StringValuePtr(str),
+ rl_username_completion_function);
+ if (matches) {
+ result = rb_ary_new();
+ for (i = 0; matches[i]; i++) {
+ rb_ary_push(result, rb_locale_str_new_cstr(matches[i]));
+ free(matches[i]);
+ }
+ free(matches);
+ if (RARRAY_LEN(result) >= 2)
+ rb_ary_shift(result);
+ }
+ else {
+ result = Qnil;
+ }
+ return result;
+}
+
+void
+Init_readline(void)
+{
+ VALUE history, fcomp, ucomp, version;
+
+ /* Allow conditional parsing of the ~/.inputrc file. */
+ rl_readline_name = (char *)"Ruby";
+
+#if defined HAVE_RL_GETC_FUNCTION
+ /* libedit check rl_getc_function only when rl_initialize() is called, */
+ /* and using_history() call rl_initialize(). */
+ /* This assignment should be placed before using_history() */
+ rl_getc_function = readline_getc;
+#elif defined HAVE_RL_EVENT_HOOK
+ rl_event_hook = readline_event;
+#endif
+
+ using_history();
+
+ completion_proc = rb_intern(COMPLETION_PROC);
+ completion_case_fold = rb_intern(COMPLETION_CASE_FOLD);
+#if defined(HAVE_RL_PRE_INPUT_HOOK)
+ id_pre_input_hook = rb_intern("pre_input_hook");
+#endif
+#if defined(HAVE_RL_SPECIAL_PREFIXES)
+ id_special_prefixes = rb_intern("special_prefixes");
+#endif
+
+ mReadline = rb_define_module("Readline");
+ rb_define_module_function(mReadline, "readline",
+ readline_readline, -1);
+ rb_define_singleton_method(mReadline, "input=",
+ readline_s_set_input, 1);
+ rb_define_singleton_method(mReadline, "output=",
+ readline_s_set_output, 1);
+ rb_define_singleton_method(mReadline, "completion_proc=",
+ readline_s_set_completion_proc, 1);
+ rb_define_singleton_method(mReadline, "completion_proc",
+ readline_s_get_completion_proc, 0);
+ rb_define_singleton_method(mReadline, "completion_case_fold=",
+ readline_s_set_completion_case_fold, 1);
+ rb_define_singleton_method(mReadline, "completion_case_fold",
+ readline_s_get_completion_case_fold, 0);
+ rb_define_singleton_method(mReadline, "line_buffer",
+ readline_s_get_line_buffer, 0);
+ rb_define_singleton_method(mReadline, "point",
+ readline_s_get_point, 0);
+ rb_define_singleton_method(mReadline, "point=",
+ readline_s_set_point, 1);
+ rb_define_singleton_method(mReadline, "set_screen_size",
+ readline_s_set_screen_size, 2);
+ rb_define_singleton_method(mReadline, "get_screen_size",
+ readline_s_get_screen_size, 0);
+ rb_define_singleton_method(mReadline, "vi_editing_mode",
+ readline_s_vi_editing_mode, 0);
+ rb_define_singleton_method(mReadline, "vi_editing_mode?",
+ readline_s_vi_editing_mode_p, 0);
+ rb_define_singleton_method(mReadline, "emacs_editing_mode",
+ readline_s_emacs_editing_mode, 0);
+ rb_define_singleton_method(mReadline, "emacs_editing_mode?",
+ readline_s_emacs_editing_mode_p, 0);
+ rb_define_singleton_method(mReadline, "completion_append_character=",
+ readline_s_set_completion_append_character, 1);
+ rb_define_singleton_method(mReadline, "completion_append_character",
+ readline_s_get_completion_append_character, 0);
+ rb_define_singleton_method(mReadline, "basic_word_break_characters=",
+ readline_s_set_basic_word_break_characters, 1);
+ rb_define_singleton_method(mReadline, "basic_word_break_characters",
+ readline_s_get_basic_word_break_characters, 0);
+ rb_define_singleton_method(mReadline, "completer_word_break_characters=",
+ readline_s_set_completer_word_break_characters, 1);
+ rb_define_singleton_method(mReadline, "completer_word_break_characters",
+ readline_s_get_completer_word_break_characters, 0);
+ rb_define_singleton_method(mReadline, "basic_quote_characters=",
+ readline_s_set_basic_quote_characters, 1);
+ rb_define_singleton_method(mReadline, "basic_quote_characters",
+ readline_s_get_basic_quote_characters, 0);
+ rb_define_singleton_method(mReadline, "completer_quote_characters=",
+ readline_s_set_completer_quote_characters, 1);
+ rb_define_singleton_method(mReadline, "completer_quote_characters",
+ readline_s_get_completer_quote_characters, 0);
+ rb_define_singleton_method(mReadline, "filename_quote_characters=",
+ readline_s_set_filename_quote_characters, 1);
+ rb_define_singleton_method(mReadline, "filename_quote_characters",
+ readline_s_get_filename_quote_characters, 0);
+ rb_define_singleton_method(mReadline, "refresh_line",
+ readline_s_refresh_line, 0);
+ rb_define_singleton_method(mReadline, "pre_input_hook=",
+ readline_s_set_pre_input_hook, 1);
+ rb_define_singleton_method(mReadline, "pre_input_hook",
+ readline_s_get_pre_input_hook, 0);
+ rb_define_singleton_method(mReadline, "insert_text",
+ readline_s_insert_text, 1);
+ rb_define_singleton_method(mReadline, "delete_text",
+ readline_s_delete_text, -1);
+ rb_define_singleton_method(mReadline, "redisplay",
+ readline_s_redisplay, 0);
+ rb_define_singleton_method(mReadline, "special_prefixes=",
+ readline_s_set_special_prefixes, 1);
+ rb_define_singleton_method(mReadline, "special_prefixes",
+ readline_s_get_special_prefixes, 0);
+
+#if USE_INSERT_IGNORE_ESCAPE
+ CONST_ID(id_orig_prompt, "orig_prompt");
+ CONST_ID(id_last_prompt, "last_prompt");
+#endif
+
+ history = rb_obj_alloc(rb_cObject);
+ rb_extend_object(history, rb_mEnumerable);
+ rb_define_singleton_method(history,"to_s", hist_to_s, 0);
+ rb_define_singleton_method(history,"[]", hist_get, 1);
+ rb_define_singleton_method(history,"[]=", hist_set, 2);
+ rb_define_singleton_method(history,"<<", hist_push, 1);
+ rb_define_singleton_method(history,"push", hist_push_method, -1);
+ rb_define_singleton_method(history,"pop", hist_pop, 0);
+ rb_define_singleton_method(history,"shift", hist_shift, 0);
+ rb_define_singleton_method(history,"each", hist_each, 0);
+ rb_define_singleton_method(history,"length", hist_length, 0);
+ rb_define_singleton_method(history,"size", hist_length, 0);
+ rb_define_singleton_method(history,"empty?", hist_empty_p, 0);
+ rb_define_singleton_method(history,"delete_at", hist_delete_at, 1);
+ rb_define_singleton_method(history,"clear", hist_clear, 0);
+
+ /*
+ * The history buffer. It extends Enumerable module, so it behaves
+ * just like an array.
+ * For example, gets the fifth content that the user input by
+ * HISTORY[4].
+ */
+ rb_define_const(mReadline, "HISTORY", history);
+
+ fcomp = rb_obj_alloc(rb_cObject);
+ rb_define_singleton_method(fcomp, "call",
+ filename_completion_proc_call, 1);
+ /*
+ * The Object with the call method that is a completion for filename.
+ * This is sets by Readline.completion_proc= method.
+ */
+ rb_define_const(mReadline, "FILENAME_COMPLETION_PROC", fcomp);
+
+ ucomp = rb_obj_alloc(rb_cObject);
+ rb_define_singleton_method(ucomp, "call",
+ username_completion_proc_call, 1);
+ /*
+ * The Object with the call method that is a completion for usernames.
+ * This is sets by Readline.completion_proc= method.
+ */
+ rb_define_const(mReadline, "USERNAME_COMPLETION_PROC", ucomp);
+ history_get_offset_func = history_get_offset_history_base;
+ history_replace_offset_func = history_get_offset_0;
+#if defined HAVE_RL_LIBRARY_VERSION
+ version = rb_str_new_cstr(rl_library_version);
+#if defined HAVE_CLEAR_HISTORY || defined HAVE_REMOVE_HISTORY
+ if (strncmp(rl_library_version, EDIT_LINE_LIBRARY_VERSION,
+ strlen(EDIT_LINE_LIBRARY_VERSION)) == 0) {
+ add_history("1");
+ if (history_get(history_get_offset_func(0)) == NULL) {
+ history_get_offset_func = history_get_offset_0;
+ }
+#ifdef HAVE_REPLACE_HISTORY_ENTRY
+ if (replace_history_entry(0, "a", NULL) == NULL) {
+ history_replace_offset_func = history_get_offset_history_base;
+ }
+#endif
+#ifdef HAVE_CLEAR_HISTORY
+ clear_history();
+#else
+ {
+ HIST_ENTRY *entry = remove_history(0);
+ if (entry) {
+ free((char *)entry->line);
+ free(entry);
+ }
+ }
+#endif
+ }
+#endif
+#else
+ version = rb_str_new_cstr("2.0 or prior version");
+#endif
+ /* Version string of GNU Readline or libedit. */
+ rb_define_const(mReadline, "VERSION", version);
+
+ rl_attempted_completion_function = readline_attempted_completion_function;
+#if defined(HAVE_RL_PRE_INPUT_HOOK)
+ rl_pre_input_hook = (rl_hook_func_t *)readline_pre_input_hook;
+#endif
+#ifdef HAVE_RL_CATCH_SIGNALS
+ rl_catch_signals = 0;
+#endif
+#ifdef HAVE_RL_CLEAR_SIGNALS
+ rl_clear_signals();
+#endif
+
+ rb_gc_register_address(&readline_instream);
+ rb_gc_register_address(&readline_outstream);
+}
diff --git a/jni/ruby/ext/ripper/Makefile b/jni/ruby/ext/ripper/Makefile
new file mode 100644
index 0000000..f21b954
--- /dev/null
+++ b/jni/ruby/ext/ripper/Makefile
@@ -0,0 +1,378 @@
+
+SHELL = /bin/sh
+
+# V=0 quiet, V=1 verbose. other values don't work.
+V = 0
+Q1 = $(V:1=)
+Q = $(Q1:0=@)
+ECHO1 = $(V:1=@:)
+ECHO = $(ECHO1:0=@echo)
+NULLCMD = :
+
+#### Start of system configuration section. ####
+top_srcdir = $(topdir)/.
+srcdir = $(top_srcdir)/ext/ripper
+topdir = ../..
+hdrdir = $(top_srcdir)/include
+arch_hdrdir = $(extout)/include/$(arch)
+PATH_SEPARATOR = :
+VPATH = $(srcdir):$(arch_hdrdir)/ruby:$(hdrdir)/ruby:$(topdir):$(top_srcdir)
+RUBYLIB =
+RUBYOPT = -
+prefix = $(DESTDIR)/usr/local
+rubysitearchprefix = $(rubylibprefix)/$(sitearch)
+rubyarchprefix = $(rubylibprefix)/$(arch)
+rubylibprefix = $(libdir)/$(RUBY_BASE_NAME)
+exec_prefix = $(prefix)
+vendorarchhdrdir = $(vendorhdrdir)/$(sitearch)
+sitearchhdrdir = $(sitehdrdir)/$(sitearch)
+rubyarchhdrdir = $(rubyhdrdir)/$(arch)
+vendorhdrdir = $(rubyhdrdir)/vendor_ruby
+sitehdrdir = $(rubyhdrdir)/site_ruby
+rubyhdrdir = $(includedir)/$(RUBY_VERSION_NAME)
+vendorarchdir = $(vendorlibdir)/$(sitearch)
+vendorlibdir = $(vendordir)/$(ruby_version)
+vendordir = $(rubylibprefix)/vendor_ruby
+sitearchdir = $(sitelibdir)/$(sitearch)
+sitelibdir = $(sitedir)/$(ruby_version)
+sitedir = $(rubylibprefix)/site_ruby
+rubyarchdir = $(rubylibdir)/$(arch)
+rubylibdir = $(rubylibprefix)/$(ruby_version)
+sitearchincludedir = $(includedir)/$(sitearch)
+archincludedir = $(includedir)/$(arch)
+sitearchlibdir = $(libdir)/$(sitearch)
+archlibdir = $(libdir)/$(arch)
+ridir = $(datarootdir)/$(RI_BASE_NAME)
+mandir = $(datarootdir)/man
+localedir = $(datarootdir)/locale
+libdir = $(exec_prefix)/lib
+psdir = $(docdir)
+pdfdir = $(docdir)
+dvidir = $(docdir)
+htmldir = $(docdir)
+infodir = $(datarootdir)/info
+docdir = $(datarootdir)/doc/$(PACKAGE)
+oldincludedir = $(DESTDIR)/usr/include
+includedir = $(prefix)/include
+localstatedir = $(prefix)/var
+sharedstatedir = $(prefix)/com
+sysconfdir = $(prefix)/etc
+datadir = $(datarootdir)
+datarootdir = $(prefix)/share
+libexecdir = $(exec_prefix)/libexec
+sbindir = $(exec_prefix)/sbin
+bindir = $(exec_prefix)/bin
+archdir = $(rubyarchdir)
+
+
+CC = gcc
+CXX = g++
+LIBRUBY = $(LIBRUBY_SO)
+LIBRUBY_A = lib$(RUBY_SO_NAME)-static.a
+LIBRUBYARG_SHARED = -Wl,-R$(libdir) -L$(libdir) -l$(RUBY_SO_NAME)
+LIBRUBYARG_STATIC = -Wl,-R$(libdir) -L$(libdir) -l$(RUBY_SO_NAME)-static
+empty =
+OUTFLAG = -o $(empty)
+COUTFLAG = -o $(empty)
+
+RUBY_EXTCONF_H = extconf.h
+cflags = $(optflags) $(debugflags) $(warnflags)
+optflags = -O3 -fno-fast-math
+debugflags = -ggdb3
+warnflags = -Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wunused-variable -Wpointer-arith -Wwrite-strings -Wdeclaration-after-statement -Wimplicit-function-declaration -Wdeprecated-declarations -Wno-packed-bitfield-compat
+CCDLFLAGS = -fPIC
+CFLAGS = $(CCDLFLAGS) $(cflags) -fPIC $(ARCH_FLAG)
+INCFLAGS = -I. -I$(arch_hdrdir) -I$(hdrdir) -I$(srcdir) -I$(topdir) -I$(top_srcdir)
+DEFS =
+CPPFLAGS = -DRUBY_EXTCONF_H=\"$(RUBY_EXTCONF_H)\" $(DEFS) $(cppflags)
+CXXFLAGS = $(CCDLFLAGS) $(cxxflags) $(ARCH_FLAG)
+ldflags = -L. -fstack-protector -rdynamic -Wl,-export-dynamic
+dldflags =
+ARCH_FLAG =
+DLDFLAGS = $(ldflags) $(dldflags) $(ARCH_FLAG)
+LDSHARED = $(CC) -shared
+LDSHAREDXX = $(CXX) -shared
+AR = ar
+EXEEXT =
+
+RUBY_INSTALL_NAME = $(RUBY_BASE_NAME)
+RUBY_SO_NAME = ruby
+RUBYW_INSTALL_NAME =
+RUBY_VERSION_NAME = $(RUBY_BASE_NAME)-$(ruby_version)
+RUBYW_BASE_NAME = rubyw
+RUBY_BASE_NAME = ruby
+
+arch = x86_64-linux
+sitearch = $(arch)
+ruby_version = 2.2.0
+ruby = $(topdir)/miniruby -I'$(topdir)' -I'$(top_srcdir)/lib' -I'$(extout)/$(arch)' -I'$(extout)/common'
+RUBY = $(ruby)
+ruby_headers = $(hdrdir)/ruby.h $(hdrdir)/ruby/ruby.h $(hdrdir)/ruby/defines.h $(hdrdir)/ruby/missing.h $(hdrdir)/ruby/intern.h $(hdrdir)/ruby/st.h $(hdrdir)/ruby/subst.h $(arch_hdrdir)/ruby/config.h $(RUBY_EXTCONF_H)
+
+RM = rm -f
+RM_RF = $(RUBY) -run -e rm -- -rf
+RMDIRS = rmdir --ignore-fail-on-non-empty -p
+MAKEDIRS = /bin/mkdir -p
+INSTALL = /usr/bin/install -c
+INSTALL_PROG = $(INSTALL) -m 0755
+INSTALL_DATA = $(INSTALL) -m 644
+COPY = cp
+TOUCH = exit >
+
+#### End of system configuration section. ####
+
+preload =
+
+libpath = . $(topdir)
+LIBPATH = -L. -L$(topdir)
+DEFFILE =
+
+CLEANFILES = mkmf.log ripper.y ripper.c ripper.E ripper.output y.output eventids1.c eventids2table.c
+DISTCLEANFILES =
+DISTCLEANDIRS =
+
+extout = $(topdir)/.ext
+extout_prefix = $(extout)$(target_prefix)/
+target_prefix =
+LOCAL_LIBS =
+LIBS = $(LIBRUBYARG_SHARED) -lpthread -lgmp -ldl -lcrypt -lm -lc
+ORIG_SRCS = eventids2.c
+SRCS = $(ORIG_SRCS) ripper.c
+OBJS = ripper.o
+HDRS = $(srcdir)/extconf.h
+TARGET = ripper
+TARGET_NAME = ripper
+TARGET_ENTRY = Init_$(TARGET_NAME)
+DLLIB = $(TARGET).so
+EXTSTATIC =
+STATIC_LIB =
+
+TIMESTAMP_DIR = $(extout)/.timestamp
+BINDIR = $(extout)/bin
+RUBYCOMMONDIR = $(extout)/common
+RUBYLIBDIR = $(RUBYCOMMONDIR)$(target_prefix)
+RUBYARCHDIR = $(extout)/$(arch)$(target_prefix)
+HDRDIR = $(extout)/include/ruby$(target_prefix)
+ARCHHDRDIR = $(extout)/include/$(arch)/ruby$(target_prefix)
+
+TARGET_SO = $(RUBYARCHDIR)/$(DLLIB)
+CLEANLIBS = $(RUBYARCHDIR)/$(TARGET).so
+CLEANOBJS = *.o *.bak
+
+all: install
+static: all
+.PHONY: all install static install-so install-rb
+.PHONY: clean clean-so clean-static clean-rb
+
+clean-static::
+clean-rb-default::
+clean-rb::
+clean-so::
+clean: clean-so clean-static clean-rb-default clean-rb
+ -$(Q)$(RM) $(CLEANLIBS) $(CLEANOBJS) $(CLEANFILES) .*.time
+
+distclean-rb-default::
+distclean-rb::
+distclean-so::
+distclean-static::
+distclean: clean distclean-so distclean-static distclean-rb-default distclean-rb
+ -$(Q)$(RM) Makefile $(RUBY_EXTCONF_H) conftest.* mkmf.log
+ -$(Q)$(RM) core ruby$(EXEEXT) *~ $(DISTCLEANFILES)
+ -$(Q)$(RMDIRS) $(DISTCLEANDIRS) 2> /dev/null || true
+
+realclean: distclean
+install: install-so install-rb
+
+install-so: $(RUBYARCHDIR)/$(DLLIB)
+clean-so::
+ -$(Q)$(RM) $(RUBYARCHDIR)/$(DLLIB)
+ -$(Q)$(RMDIRS) $(RUBYARCHDIR) 2> /dev/null || true
+clean-static::
+ -$(Q)$(RM) $(STATIC_LIB)
+install-rb: pre-install-rb install-rb-default
+install-rb-default: pre-install-rb-default
+pre-install-rb: Makefile
+pre-install-rb-default: Makefile
+pre-install-rb-default: $(TIMESTAMP_DIR)/.RUBYLIBDIR.-.ripper.time
+install-rb-default: $(RUBYLIBDIR)/ripper/lexer.rb
+$(RUBYLIBDIR)/ripper/lexer.rb: $(srcdir)/lib/ripper/lexer.rb $(TIMESTAMP_DIR)/.RUBYLIBDIR.-.ripper.time
+ $(Q) $(COPY) $(srcdir)/lib/ripper/lexer.rb $(@D)
+clean-rb-default::
+ -$(Q)$(RM) $(RUBYLIBDIR)/ripper/lexer.rb
+install-rb-default: $(RUBYLIBDIR)/ripper/core.rb
+$(RUBYLIBDIR)/ripper/core.rb: $(srcdir)/lib/ripper/core.rb $(TIMESTAMP_DIR)/.RUBYLIBDIR.-.ripper.time
+ $(Q) $(COPY) $(srcdir)/lib/ripper/core.rb $(@D)
+clean-rb-default::
+ -$(Q)$(RM) $(RUBYLIBDIR)/ripper/core.rb
+install-rb-default: $(RUBYLIBDIR)/ripper/filter.rb
+$(RUBYLIBDIR)/ripper/filter.rb: $(srcdir)/lib/ripper/filter.rb $(TIMESTAMP_DIR)/.RUBYLIBDIR.-.ripper.time
+ $(Q) $(COPY) $(srcdir)/lib/ripper/filter.rb $(@D)
+clean-rb-default::
+ -$(Q)$(RM) $(RUBYLIBDIR)/ripper/filter.rb
+install-rb-default: $(RUBYLIBDIR)/ripper/sexp.rb
+$(RUBYLIBDIR)/ripper/sexp.rb: $(srcdir)/lib/ripper/sexp.rb $(TIMESTAMP_DIR)/.RUBYLIBDIR.-.ripper.time
+ $(Q) $(COPY) $(srcdir)/lib/ripper/sexp.rb $(@D)
+clean-rb-default::
+ -$(Q)$(RM) $(RUBYLIBDIR)/ripper/sexp.rb
+pre-install-rb-default: $(TIMESTAMP_DIR)/.RUBYLIBDIR.time
+install-rb-default: $(RUBYLIBDIR)/ripper.rb
+$(RUBYLIBDIR)/ripper.rb: $(srcdir)/lib/ripper.rb $(TIMESTAMP_DIR)/.RUBYLIBDIR.time
+ $(Q) $(COPY) $(srcdir)/lib/ripper.rb $(@D)
+clean-rb-default::
+ -$(Q)$(RM) $(RUBYLIBDIR)/ripper.rb
+pre-install-rb-default:
+ $(ECHO) installing default ripper libraries
+clean-rb-default::
+ -$(Q)$(RMDIRS) $(RUBYLIBDIR)/ripper 2> /dev/null || true
+ -$(Q)$(RMDIRS) $(RUBYLIBDIR) 2> /dev/null || true
+$(TIMESTAMP_DIR)/.RUBYARCHDIR.time:
+ $(Q) $(MAKEDIRS) $(@D) $(RUBYARCHDIR)
+ $(Q) $(TOUCH) $@
+$(TIMESTAMP_DIR)/.RUBYLIBDIR.-.ripper.time:
+ $(Q) $(MAKEDIRS) $(@D) $(RUBYLIBDIR)/ripper
+ $(Q) $(TOUCH) $@
+$(TIMESTAMP_DIR)/.RUBYLIBDIR.time:
+ $(Q) $(MAKEDIRS) $(@D) $(RUBYLIBDIR)
+ $(Q) $(TOUCH) $@
+
+site-install: site-install-so site-install-rb
+site-install-so: install-so
+site-install-rb: install-rb
+
+.SUFFIXES: .c .m .cc .mm .cxx .cpp .o .S
+
+.cc.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<
+
+.cc.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -S $<
+
+.mm.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<
+
+.mm.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -S $<
+
+.cxx.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<
+
+.cxx.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -S $<
+
+.cpp.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<
+
+.cpp.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -S $<
+
+.c.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -c $<
+
+.c.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -S $<
+
+.m.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -c $<
+
+.m.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -S $<
+
+$(RUBYARCHDIR)/$(DLLIB): $(OBJS) Makefile $(TIMESTAMP_DIR)/.RUBYARCHDIR.time
+ $(ECHO) linking shared-object $(DLLIB)
+ -$(Q)$(RM) $(@)
+ $(Q) $(LDSHARED) -o $@ $(OBJS) $(LIBPATH) $(DLDFLAGS) $(LOCAL_LIBS) $(LIBS)
+
+
+
+###
+$(OBJS): $(RUBY_EXTCONF_H)
+
+.SUFFIXES: .y .c
+
+GEN = $(srcdir)/tools/generate.rb
+SRC1 = $(top_srcdir)/parse.y
+SRC2 = $(srcdir)/eventids2.c
+BISON = bison
+
+.SUFFIXES: .y
+
+src: ripper.c eventids1.c eventids2table.c
+
+ripper.o: ripper.c
+
+.y.c:
+ $(ECHO) compiling compiler $<
+ $(Q) $(BISON) -t -v -oy.tab.c $<
+ $(Q) sed -f $(top_srcdir)/tool/ytab.sed -e "/^#/s!y\.tab\.c!$@!" y.tab.c > $@
+ @$(RM) y.tab.c
+
+all: check
+static: check
+
+ripper.y: $(srcdir)/tools/preproc.rb $(top_srcdir)/parse.y
+ $(ECHO) extracting $@ from $(top_srcdir)/parse.y
+ $(Q) $(RUBY) $(top_srcdir)/tool/id2token.rb --path-separator=.$(PATH_SEPARATOR)./ --vpath=$(VPATH) id.h $(top_srcdir)/parse.y > ripper.tmp.y
+ $(Q) $(RUBY) $(srcdir)/tools/preproc.rb ripper.tmp.y --output=$@
+ $(Q) $(RM) ripper.tmp.y
+
+check: $(GEN) $(SRC1) $(SRC2)
+ $(ECHO) checking $(SRC1) and $(SRC2)
+ $(Q) $(RUBY) $(GEN) --mode=check --ids1src=$(SRC1) --ids2src=$(SRC2)
+
+eventids1.c: $(srcdir)/tools/generate.rb $(SRC1)
+ $(ECHO) generating $@ from $(SRC1)
+ $(Q) $(RUBY) $(GEN) --mode=eventids1 --ids1src=$(SRC1) --output=$@
+
+eventids2table.c: $(srcdir)/tools/generate.rb $(SRC2)
+ $(ECHO) generating $@ from $(SRC2)
+ $(Q) $(RUBY) $(GEN) --mode=eventids2table --ids2src=$(SRC2) --output=$@
+
+# Entries for Ripper maintainer
+
+preproc: ripper.E
+ripper.E: ripper.c
+ $(ECHO) preprocessing ripper.c
+ $(Q) $(CC) -E $(CPPFLAGS) ripper.c | $(RUBY) $(srcdir)/tools/strip.rb > $@
+
+# AUTOGENERATED DEPENDENCIES START
+ripper.o: $(RUBY_EXTCONF_H)
+ripper.o: $(arch_hdrdir)/ruby/config.h
+ripper.o: $(hdrdir)/ruby/defines.h
+ripper.o: $(hdrdir)/ruby/encoding.h
+ripper.o: $(hdrdir)/ruby/intern.h
+ripper.o: $(hdrdir)/ruby/io.h
+ripper.o: $(hdrdir)/ruby/missing.h
+ripper.o: $(hdrdir)/ruby/oniguruma.h
+ripper.o: $(hdrdir)/ruby/regex.h
+ripper.o: $(hdrdir)/ruby/ruby.h
+ripper.o: $(hdrdir)/ruby/st.h
+ripper.o: $(hdrdir)/ruby/subst.h
+ripper.o: $(hdrdir)/ruby/util.h
+ripper.o: $(top_srcdir)/include/ruby.h
+ripper.o: $(top_srcdir)/internal.h
+ripper.o: $(top_srcdir)/node.h
+ripper.o: $(top_srcdir)/regenc.h
+ripper.o: $(top_srcdir)/symbol.h
+ripper.o: $(top_srcdir)/vm_opts.h
+ripper.o: ../../probes.h
+ripper.o: eventids2.c
+ripper.o: ripper.y
+ripper.o: eventids1.c
+ripper.o: eventids2table.c
+ripper.o: id.h
+ripper.o: lex.c
+ripper.o: parse.h
+ripper.o: ripper.c
+# AUTOGENERATED DEPENDENCIES END
diff --git a/jni/ruby/ext/ripper/README b/jni/ruby/ext/ripper/README
new file mode 100644
index 0000000..2ae2470
--- /dev/null
+++ b/jni/ruby/ext/ripper/README
@@ -0,0 +1,30 @@
+Ripper README
+=============
+
+ Ripper is a Ruby script parser. You can get information
+ by event-based style from the parser.
+
+ !! WARNING !!
+
+ Ripper is still early-alpha version.
+ I never assure any kind of backward compatibility.
+
+Requirements
+------------
+
+ * ruby 1.9 (support CVS HEAD only)
+ * bison 1.28 or later (Other yaccs do not work)
+
+Usage
+-----
+
+ See test/ripper/* and sample/ripper/*.
+
+License
+-------
+
+ Ruby License.
+
+ Minero Aoki
+ aamine@loveruby.net
+ http://i.loveruby.net
diff --git a/jni/ruby/ext/ripper/depend b/jni/ruby/ext/ripper/depend
new file mode 100644
index 0000000..64236cd
--- /dev/null
+++ b/jni/ruby/ext/ripper/depend
@@ -0,0 +1,75 @@
+GEN = $(srcdir)/tools/generate.rb
+SRC1 = $(top_srcdir)/parse.y
+SRC2 = $(srcdir)/eventids2.c
+BISON = bison
+
+.SUFFIXES: .y
+
+src: ripper.c eventids1.c eventids2table.c
+
+ripper.o: ripper.c
+
+.y.c:
+ $(ECHO) compiling compiler $<
+ $(Q) $(BISON) -t -v -oy.tab.c $<
+ $(Q) sed -f $(top_srcdir)/tool/ytab.sed -e "/^#/s!y\.tab\.c!$@!" y.tab.c > $@
+ @$(RM) y.tab.c
+
+all: check
+static: check
+
+ripper.y: $(srcdir)/tools/preproc.rb $(top_srcdir)/parse.y
+ $(ECHO) extracting $@ from $(top_srcdir)/parse.y
+ $(Q) $(RUBY) $(top_srcdir)/tool/id2token.rb --path-separator=.$(PATH_SEPARATOR)./ --vpath=$(VPATH) id.h $(top_srcdir)/parse.y > ripper.tmp.y
+ $(Q) $(RUBY) $(srcdir)/tools/preproc.rb ripper.tmp.y --output=$@
+ $(Q) $(RM) ripper.tmp.y
+
+check: $(GEN) $(SRC1) $(SRC2)
+ $(ECHO) checking $(SRC1) and $(SRC2)
+ $(Q) $(RUBY) $(GEN) --mode=check --ids1src=$(SRC1) --ids2src=$(SRC2)
+
+eventids1.c: $(srcdir)/tools/generate.rb $(SRC1)
+ $(ECHO) generating $@ from $(SRC1)
+ $(Q) $(RUBY) $(GEN) --mode=eventids1 --ids1src=$(SRC1) --output=$@
+
+eventids2table.c: $(srcdir)/tools/generate.rb $(SRC2)
+ $(ECHO) generating $@ from $(SRC2)
+ $(Q) $(RUBY) $(GEN) --mode=eventids2table --ids2src=$(SRC2) --output=$@
+
+# Entries for Ripper maintainer
+
+preproc: ripper.E
+ripper.E: ripper.c
+ $(ECHO) preprocessing ripper.c
+ $(Q) $(CC) -E $(CPPFLAGS) ripper.c | $(RUBY) $(srcdir)/tools/strip.rb > $@
+
+# AUTOGENERATED DEPENDENCIES START
+ripper.o: $(RUBY_EXTCONF_H)
+ripper.o: $(arch_hdrdir)/ruby/config.h
+ripper.o: $(hdrdir)/ruby/defines.h
+ripper.o: $(hdrdir)/ruby/encoding.h
+ripper.o: $(hdrdir)/ruby/intern.h
+ripper.o: $(hdrdir)/ruby/io.h
+ripper.o: $(hdrdir)/ruby/missing.h
+ripper.o: $(hdrdir)/ruby/oniguruma.h
+ripper.o: $(hdrdir)/ruby/regex.h
+ripper.o: $(hdrdir)/ruby/ruby.h
+ripper.o: $(hdrdir)/ruby/st.h
+ripper.o: $(hdrdir)/ruby/subst.h
+ripper.o: $(hdrdir)/ruby/util.h
+ripper.o: $(top_srcdir)/include/ruby.h
+ripper.o: $(top_srcdir)/internal.h
+ripper.o: $(top_srcdir)/node.h
+ripper.o: $(top_srcdir)/regenc.h
+ripper.o: $(top_srcdir)/symbol.h
+ripper.o: $(top_srcdir)/vm_opts.h
+ripper.o: ../../probes.h
+ripper.o: eventids2.c
+ripper.o: ripper.y
+ripper.o: {$(VPATH)}eventids1.c
+ripper.o: {$(VPATH)}eventids2table.c
+ripper.o: {$(VPATH)}id.h
+ripper.o: {$(VPATH)}lex.c
+ripper.o: {$(VPATH)}parse.h
+ripper.o: {$(VPATH)}ripper.c
+# AUTOGENERATED DEPENDENCIES END
diff --git a/jni/ruby/ext/ripper/eventids2.c b/jni/ruby/ext/ripper/eventids2.c
new file mode 100644
index 0000000..abbe584
--- /dev/null
+++ b/jni/ruby/ext/ripper/eventids2.c
@@ -0,0 +1,305 @@
+#define tIGNORED_NL (tLAST_TOKEN + 1)
+#define tCOMMENT (tLAST_TOKEN + 2)
+#define tEMBDOC_BEG (tLAST_TOKEN + 3)
+#define tEMBDOC (tLAST_TOKEN + 4)
+#define tEMBDOC_END (tLAST_TOKEN + 5)
+#define tSP (tLAST_TOKEN + 6)
+#define tHEREDOC_BEG (tLAST_TOKEN + 7)
+#define tHEREDOC_END (tLAST_TOKEN + 8)
+#define k__END__ (tLAST_TOKEN + 9)
+
+typedef struct {
+ ID ripper_id_backref;
+ ID ripper_id_backtick;
+ ID ripper_id_comma;
+ ID ripper_id_const;
+ ID ripper_id_cvar;
+ ID ripper_id_embexpr_beg;
+ ID ripper_id_embexpr_end;
+ ID ripper_id_embvar;
+ ID ripper_id_float;
+ ID ripper_id_gvar;
+ ID ripper_id_ident;
+ ID ripper_id_imaginary;
+ ID ripper_id_int;
+ ID ripper_id_ivar;
+ ID ripper_id_kw;
+ ID ripper_id_lbrace;
+ ID ripper_id_lbracket;
+ ID ripper_id_lparen;
+ ID ripper_id_nl;
+ ID ripper_id_op;
+ ID ripper_id_period;
+ ID ripper_id_rbrace;
+ ID ripper_id_rbracket;
+ ID ripper_id_rparen;
+ ID ripper_id_semicolon;
+ ID ripper_id_symbeg;
+ ID ripper_id_tstring_beg;
+ ID ripper_id_tstring_content;
+ ID ripper_id_tstring_end;
+ ID ripper_id_words_beg;
+ ID ripper_id_qwords_beg;
+ ID ripper_id_qsymbols_beg;
+ ID ripper_id_symbols_beg;
+ ID ripper_id_words_sep;
+ ID ripper_id_rational;
+ ID ripper_id_regexp_beg;
+ ID ripper_id_regexp_end;
+ ID ripper_id_label;
+ ID ripper_id_label_end;
+ ID ripper_id_tlambda;
+ ID ripper_id_tlambeg;
+
+ ID ripper_id_ignored_nl;
+ ID ripper_id_comment;
+ ID ripper_id_embdoc_beg;
+ ID ripper_id_embdoc;
+ ID ripper_id_embdoc_end;
+ ID ripper_id_sp;
+ ID ripper_id_heredoc_beg;
+ ID ripper_id_heredoc_end;
+ ID ripper_id___end__;
+ ID ripper_id_CHAR;
+} ripper_scanner_ids_t;
+
+static ripper_scanner_ids_t ripper_scanner_ids;
+
+#include "eventids2table.c"
+
+static void
+ripper_init_eventids2(void)
+{
+#define set_id2(name) ripper_scanner_ids.ripper_id_##name = rb_intern_const("on_"#name)
+ set_id2(backref);
+ set_id2(backtick);
+ set_id2(comma);
+ set_id2(const);
+ set_id2(cvar);
+ set_id2(embexpr_beg);
+ set_id2(embexpr_end);
+ set_id2(embvar);
+ set_id2(float);
+ set_id2(gvar);
+ set_id2(ident);
+ set_id2(imaginary);
+ set_id2(int);
+ set_id2(ivar);
+ set_id2(kw);
+ set_id2(lbrace);
+ set_id2(lbracket);
+ set_id2(lparen);
+ set_id2(nl);
+ set_id2(op);
+ set_id2(period);
+ set_id2(rbrace);
+ set_id2(rbracket);
+ set_id2(rparen);
+ set_id2(semicolon);
+ set_id2(symbeg);
+ set_id2(tstring_beg);
+ set_id2(tstring_content);
+ set_id2(tstring_end);
+ set_id2(words_beg);
+ set_id2(qwords_beg);
+ set_id2(qsymbols_beg);
+ set_id2(symbols_beg);
+ set_id2(words_sep);
+ set_id2(rational);
+ set_id2(regexp_beg);
+ set_id2(regexp_end);
+ set_id2(label);
+ set_id2(label_end);
+ set_id2(tlambda);
+ set_id2(tlambeg);
+
+ set_id2(ignored_nl);
+ set_id2(comment);
+ set_id2(embdoc_beg);
+ set_id2(embdoc);
+ set_id2(embdoc_end);
+ set_id2(sp);
+ set_id2(heredoc_beg);
+ set_id2(heredoc_end);
+ set_id2(__end__);
+ set_id2(CHAR);
+}
+
+STATIC_ASSERT(k__END___range, k__END__ < SHRT_MAX);
+STATIC_ASSERT(ripper_scanner_ids_size, sizeof(ripper_scanner_ids) < SHRT_MAX);
+#define O(member) (int)offsetof(ripper_scanner_ids_t, ripper_id_##member)
+
+static const struct token_assoc {
+ unsigned short token;
+ unsigned short id_offset;
+} token_to_eventid[] = {
+ {' ', O(words_sep)},
+ {'!', O(op)},
+ {'%', O(op)},
+ {'&', O(op)},
+ {'*', O(op)},
+ {'+', O(op)},
+ {'-', O(op)},
+ {'/', O(op)},
+ {'<', O(op)},
+ {'=', O(op)},
+ {'>', O(op)},
+ {'?', O(op)},
+ {'^', O(op)},
+ {'|', O(op)},
+ {'~', O(op)},
+ {':', O(op)},
+ {',', O(comma)},
+ {'.', O(period)},
+ {';', O(semicolon)},
+ {'`', O(backtick)},
+ {'\n', O(nl)},
+ {keyword_alias, O(kw)},
+ {keyword_and, O(kw)},
+ {keyword_begin, O(kw)},
+ {keyword_break, O(kw)},
+ {keyword_case, O(kw)},
+ {keyword_class, O(kw)},
+ {keyword_def, O(kw)},
+ {keyword_defined, O(kw)},
+ {keyword_do, O(kw)},
+ {keyword_do_block, O(kw)},
+ {keyword_do_cond, O(kw)},
+ {keyword_else, O(kw)},
+ {keyword_elsif, O(kw)},
+ {keyword_end, O(kw)},
+ {keyword_ensure, O(kw)},
+ {keyword_false, O(kw)},
+ {keyword_for, O(kw)},
+ {keyword_if, O(kw)},
+ {modifier_if, O(kw)},
+ {keyword_in, O(kw)},
+ {keyword_module, O(kw)},
+ {keyword_next, O(kw)},
+ {keyword_nil, O(kw)},
+ {keyword_not, O(kw)},
+ {keyword_or, O(kw)},
+ {keyword_redo, O(kw)},
+ {keyword_rescue, O(kw)},
+ {modifier_rescue, O(kw)},
+ {keyword_retry, O(kw)},
+ {keyword_return, O(kw)},
+ {keyword_self, O(kw)},
+ {keyword_super, O(kw)},
+ {keyword_then, O(kw)},
+ {keyword_true, O(kw)},
+ {keyword_undef, O(kw)},
+ {keyword_unless, O(kw)},
+ {modifier_unless, O(kw)},
+ {keyword_until, O(kw)},
+ {modifier_until, O(kw)},
+ {keyword_when, O(kw)},
+ {keyword_while, O(kw)},
+ {modifier_while, O(kw)},
+ {keyword_yield, O(kw)},
+ {keyword__FILE__, O(kw)},
+ {keyword__LINE__, O(kw)},
+ {keyword__ENCODING__, O(kw)},
+ {keyword_BEGIN, O(kw)},
+ {keyword_END, O(kw)},
+ {keyword_do_LAMBDA, O(kw)},
+ {tAMPER, O(op)},
+ {tANDOP, O(op)},
+ {tAREF, O(op)},
+ {tASET, O(op)},
+ {tASSOC, O(op)},
+ {tBACK_REF, O(backref)},
+ {tCHAR, O(CHAR)},
+ {tCMP, O(op)},
+ {tCOLON2, O(op)},
+ {tCOLON3, O(op)},
+ {tCONSTANT, O(const)},
+ {tCVAR, O(cvar)},
+ {tDOT2, O(op)},
+ {tDOT3, O(op)},
+ {tEQ, O(op)},
+ {tEQQ, O(op)},
+ {tFID, O(ident)},
+ {tFLOAT, O(float)},
+ {tGEQ, O(op)},
+ {tGVAR, O(gvar)},
+ {tIDENTIFIER, O(ident)},
+ {tIMAGINARY, O(imaginary)},
+ {tINTEGER, O(int)},
+ {tIVAR, O(ivar)},
+ {tLBRACE, O(lbrace)},
+ {tLBRACE_ARG, O(lbrace)},
+ {'{', O(lbrace)},
+ {'}', O(rbrace)},
+ {tLBRACK, O(lbracket)},
+ {'[', O(lbracket)},
+ {']', O(rbracket)},
+ {tLEQ, O(op)},
+ {tLPAREN, O(lparen)},
+ {tLPAREN_ARG, O(lparen)},
+ {'(', O(lparen)},
+ {')', O(rparen)},
+ {tLSHFT, O(op)},
+ {tMATCH, O(op)},
+ {tNEQ, O(op)},
+ {tNMATCH, O(op)},
+ {tNTH_REF, O(backref)},
+ {tOP_ASGN, O(op)},
+ {tOROP, O(op)},
+ {tPOW, O(op)},
+ {tQWORDS_BEG, O(qwords_beg)},
+ {tQSYMBOLS_BEG, O(qsymbols_beg)},
+ {tSYMBOLS_BEG, O(symbols_beg)},
+ {tRATIONAL, O(rational)},
+ {tREGEXP_BEG, O(regexp_beg)},
+ {tREGEXP_END, O(regexp_end)},
+ {tRPAREN, O(rparen)},
+ {tRSHFT, O(op)},
+ {tSTAR, O(op)},
+ {tDSTAR, O(op)},
+ {tSTRING_BEG, O(tstring_beg)},
+ {tSTRING_CONTENT, O(tstring_content)},
+ {tSTRING_DBEG, O(embexpr_beg)},
+ {tSTRING_DEND, O(embexpr_end)},
+ {tSTRING_DVAR, O(embvar)},
+ {tSTRING_END, O(tstring_end)},
+ {tSYMBEG, O(symbeg)},
+ {tUMINUS, O(op)},
+ {tUMINUS_NUM, O(op)},
+ {tUPLUS, O(op)},
+ {tWORDS_BEG, O(words_beg)},
+ {tXSTRING_BEG, O(backtick)},
+ {tLABEL, O(label)},
+ {tLABEL_END, O(label_end)},
+ {tLAMBDA, O(tlambda)},
+ {tLAMBEG, O(tlambeg)},
+
+ /* ripper specific tokens */
+ {tIGNORED_NL, O(ignored_nl)},
+ {tCOMMENT, O(comment)},
+ {tEMBDOC_BEG, O(embdoc_beg)},
+ {tEMBDOC, O(embdoc)},
+ {tEMBDOC_END, O(embdoc_end)},
+ {tSP, O(sp)},
+ {tHEREDOC_BEG, O(heredoc_beg)},
+ {tHEREDOC_END, O(heredoc_end)},
+ {k__END__, O(__end__)},
+};
+
+static ID
+ripper_token2eventid(int tok)
+{
+ int i;
+
+ for (i = 0; i < numberof(token_to_eventid); i++) {
+ const struct token_assoc *const a = &token_to_eventid[i];
+ if (a->token == tok)
+ return *(const ID *)((const char *)&ripper_scanner_ids + a->id_offset);
+ }
+ if (tok < 256) {
+ return ripper_scanner_ids.ripper_id_CHAR;
+ }
+ rb_raise(rb_eRuntimeError, "[Ripper FATAL] unknown token %d", tok);
+
+ UNREACHABLE;
+}
diff --git a/jni/ruby/ext/ripper/extconf.h b/jni/ruby/ext/ripper/extconf.h
new file mode 100644
index 0000000..3b1b5a0
--- /dev/null
+++ b/jni/ruby/ext/ripper/extconf.h
@@ -0,0 +1,4 @@
+#ifndef EXTCONF_H
+#define EXTCONF_H
+#define RIPPER 1
+#endif
diff --git a/jni/ruby/ext/ripper/extconf.rb b/jni/ruby/ext/ripper/extconf.rb
new file mode 100644
index 0000000..db54e5c
--- /dev/null
+++ b/jni/ruby/ext/ripper/extconf.rb
@@ -0,0 +1,21 @@
+#!ruby -s
+
+require 'mkmf'
+require 'rbconfig'
+
+def main
+ unless find_executable('bison')
+ unless File.exist?('ripper.c') or File.exist?("#{$srcdir}/ripper.c")
+ raise 'missing bison; abort'
+ end
+ end
+ $objs = %w(ripper.o)
+ $cleanfiles.concat %w(ripper.y ripper.c ripper.E ripper.output y.output eventids1.c eventids2table.c)
+ $defs << '-DRIPPER'
+ $defs << '-DRIPPER_DEBUG' if $debug
+ $VPATH << '$(topdir)' << '$(top_srcdir)'
+ $INCFLAGS << ' -I$(topdir) -I$(top_srcdir)'
+ create_makefile 'ripper'
+end
+
+main
diff --git a/jni/ruby/ext/ripper/lib/ripper.rb b/jni/ruby/ext/ripper/lib/ripper.rb
new file mode 100644
index 0000000..542bd40
--- /dev/null
+++ b/jni/ruby/ext/ripper/lib/ripper.rb
@@ -0,0 +1,73 @@
+require 'ripper/core'
+require 'ripper/lexer'
+require 'ripper/filter'
+require 'ripper/sexp'
+
+# Ripper is a Ruby script parser.
+#
+# You can get information from the parser with event-based style.
+# Information such as abstract syntax trees or simple lexical analysis of the
+# Ruby program.
+#
+# == Usage
+#
+# Ripper provides an easy interface for parsing your program into a symbolic
+# expression tree (or S-expression).
+#
+# Understanding the output of the parser may come as a challenge, it's
+# recommended you use PP to format the output for legibility.
+#
+# require 'ripper'
+# require 'pp'
+#
+# pp Ripper.sexp('def hello(world) "Hello, #{world}!"; end')
+# #=> [:program,
+# [[:def,
+# [:@ident, "hello", [1, 4]],
+# [:paren,
+# [:params, [[:@ident, "world", [1, 10]]], nil, nil, nil, nil, nil, nil]],
+# [:bodystmt,
+# [[:string_literal,
+# [:string_content,
+# [:@tstring_content, "Hello, ", [1, 18]],
+# [:string_embexpr, [[:var_ref, [:@ident, "world", [1, 27]]]]],
+# [:@tstring_content, "!", [1, 33]]]]],
+# nil,
+# nil,
+# nil]]]]
+#
+# You can see in the example above, the expression starts with +:program+.
+#
+# From here, a method definition at +:def+, followed by the method's identifier
+# <code>:@ident</code>. After the method's identifier comes the parentheses
+# +:paren+ and the method parameters under +:params+.
+#
+# Next is the method body, starting at +:bodystmt+ (+stmt+ meaning statement),
+# which contains the full definition of the method.
+#
+# In our case, we're simply returning a String, so next we have the
+# +:string_literal+ expression.
+#
+# Within our +:string_literal+ you'll notice two <code>@tstring_content</code>,
+# this is the literal part for <code>Hello, </code> and <code>!</code>. Between
+# the two <code>@tstring_content</code> statements is a +:string_embexpr+,
+# where _embexpr_ is an embedded expression. Our expression consists of a local
+# variable, or +var_ref+, with the identifier (<code>@ident</code>) of +world+.
+#
+# == Resources
+#
+# * {Ruby Inside}[http://www.rubyinside.com/using-ripper-to-see-how-ruby-is-parsing-your-code-5270.html]
+#
+# == Requirements
+#
+# * ruby 1.9 (support CVS HEAD only)
+# * bison 1.28 or later (Other yaccs do not work)
+#
+# == License
+#
+# Ruby License.
+#
+# Minero Aoki
+# aamine@loveruby.net
+# http://i.loveruby.net
+class Ripper; end
diff --git a/jni/ruby/ext/ripper/lib/ripper/core.rb b/jni/ruby/ext/ripper/lib/ripper/core.rb
new file mode 100644
index 0000000..008ec53
--- /dev/null
+++ b/jni/ruby/ext/ripper/lib/ripper/core.rb
@@ -0,0 +1,70 @@
+#
+# $Id: core.rb 36954 2012-09-12 23:04:41Z zzak $
+#
+# Copyright (c) 2003-2005 Minero Aoki
+#
+# This program is free software.
+# You can distribute and/or modify this program under the Ruby License.
+# For details of Ruby License, see ruby/COPYING.
+#
+
+require 'ripper.so'
+
+class Ripper
+
+ # Parses the given Ruby program read from +src+.
+ # +src+ must be a String or an IO or a object with a #gets method.
+ def Ripper.parse(src, filename = '(ripper)', lineno = 1)
+ new(src, filename, lineno).parse
+ end
+
+ # This array contains name of parser events.
+ PARSER_EVENTS = PARSER_EVENT_TABLE.keys
+
+ # This array contains name of scanner events.
+ SCANNER_EVENTS = SCANNER_EVENT_TABLE.keys
+
+ # This array contains name of all ripper events.
+ EVENTS = PARSER_EVENTS + SCANNER_EVENTS
+
+ private
+
+ #
+ # Parser Events
+ #
+
+ PARSER_EVENT_TABLE.each do |id, arity|
+ module_eval(<<-End, __FILE__, __LINE__ + 1)
+ def on_#{id}(#{ ('a'..'z').to_a[0, arity].join(', ') })
+ #{arity == 0 ? 'nil' : 'a'}
+ end
+ End
+ end
+
+ # This method is called when weak warning is produced by the parser.
+ # +fmt+ and +args+ is printf style.
+ def warn(fmt, *args)
+ end
+
+ # This method is called when strong warning is produced by the parser.
+ # +fmt+ and +args+ is printf style.
+ def warning(fmt, *args)
+ end
+
+ # This method is called when the parser found syntax error.
+ def compile_error(msg)
+ end
+
+ #
+ # Scanner Events
+ #
+
+ SCANNER_EVENTS.each do |id|
+ module_eval(<<-End, __FILE__, __LINE__ + 1)
+ def on_#{id}(token)
+ token
+ end
+ End
+ end
+
+end
diff --git a/jni/ruby/ext/ripper/lib/ripper/filter.rb b/jni/ruby/ext/ripper/lib/ripper/filter.rb
new file mode 100644
index 0000000..b30b085
--- /dev/null
+++ b/jni/ruby/ext/ripper/lib/ripper/filter.rb
@@ -0,0 +1,77 @@
+#
+# $Id: filter.rb 36954 2012-09-12 23:04:41Z zzak $
+#
+# Copyright (c) 2004,2005 Minero Aoki
+#
+# This program is free software.
+# You can distribute and/or modify this program under the Ruby License.
+# For details of Ruby License, see ruby/COPYING.
+#
+
+require 'ripper/lexer'
+
+class Ripper
+
+ # This class handles only scanner events,
+ # which are dispatched in the 'right' order (same with input).
+ class Filter
+
+ # Creates a new Ripper::Filter instance, passes parameters +src+,
+ # +filename+, and +lineno+ to Ripper::Lexer.new
+ #
+ # The lexer is for internal use only.
+ def initialize(src, filename = '-', lineno = 1)
+ @__lexer = Lexer.new(src, filename, lineno)
+ @__line = nil
+ @__col = nil
+ end
+
+ # The file name of the input.
+ def filename
+ @__lexer.filename
+ end
+
+ # The line number of the current token.
+ # This value starts from 1.
+ # This method is valid only in event handlers.
+ def lineno
+ @__line
+ end
+
+ # The column number of the current token.
+ # This value starts from 0.
+ # This method is valid only in event handlers.
+ def column
+ @__col
+ end
+
+ # Starts the parser.
+ # +init+ is a data accumulator and is passed to the next event handler (as
+ # of Enumerable#inject).
+ def parse(init = nil)
+ data = init
+ @__lexer.lex.each do |pos, event, tok|
+ @__line, @__col = *pos
+ data = if respond_to?(event, true)
+ then __send__(event, tok, data)
+ else on_default(event, tok, data)
+ end
+ end
+ data
+ end
+
+ private
+
+ # This method is called when some event handler is undefined.
+ # +event+ is :on_XXX, +token+ is the scanned token, and +data+ is a data
+ # accumulator.
+ #
+ # The return value of this method is passed to the next event handler (as
+ # of Enumerable#inject).
+ def on_default(event, token, data)
+ data
+ end
+
+ end
+
+end
diff --git a/jni/ruby/ext/ripper/lib/ripper/lexer.rb b/jni/ruby/ext/ripper/lib/ripper/lexer.rb
new file mode 100644
index 0000000..38b2087
--- /dev/null
+++ b/jni/ruby/ext/ripper/lib/ripper/lexer.rb
@@ -0,0 +1,186 @@
+#
+# $Id: lexer.rb 44878 2014-02-07 12:57:44Z zzak $
+#
+# Copyright (c) 2004,2005 Minero Aoki
+#
+# This program is free software.
+# You can distribute and/or modify this program under the Ruby License.
+# For details of Ruby License, see ruby/COPYING.
+#
+
+require 'ripper/core'
+
+class Ripper
+
+ # Tokenizes the Ruby program and returns an array of strings.
+ #
+ # p Ripper.tokenize("def m(a) nil end")
+ # # => ["def", " ", "m", "(", "a", ")", " ", "nil", " ", "end"]
+ #
+ def Ripper.tokenize(src, filename = '-', lineno = 1)
+ Lexer.new(src, filename, lineno).tokenize
+ end
+
+ # Tokenizes the Ruby program and returns an array of an array,
+ # which is formatted like <code>[[lineno, column], type, token]</code>.
+ #
+ # require 'ripper'
+ # require 'pp'
+ #
+ # pp Ripper.lex("def m(a) nil end")
+ # #=> [[[1, 0], :on_kw, "def"],
+ # [[1, 3], :on_sp, " " ],
+ # [[1, 4], :on_ident, "m" ],
+ # [[1, 5], :on_lparen, "(" ],
+ # [[1, 6], :on_ident, "a" ],
+ # [[1, 7], :on_rparen, ")" ],
+ # [[1, 8], :on_sp, " " ],
+ # [[1, 9], :on_kw, "nil"],
+ # [[1, 12], :on_sp, " " ],
+ # [[1, 13], :on_kw, "end"]]
+ #
+ def Ripper.lex(src, filename = '-', lineno = 1)
+ Lexer.new(src, filename, lineno).lex
+ end
+
+ class Lexer < ::Ripper #:nodoc: internal use only
+ def tokenize
+ lex().map {|pos, event, tok| tok }
+ end
+
+ def lex
+ parse().sort_by {|pos, event, tok| pos }
+ end
+
+ def parse
+ @buf = []
+ super
+ @buf
+ end
+
+ private
+
+ SCANNER_EVENTS.each do |event|
+ module_eval(<<-End, __FILE__+'/module_eval', __LINE__ + 1)
+ def on_#{event}(tok)
+ @buf.push [[lineno(), column()], :on_#{event}, tok]
+ end
+ End
+ end
+ end
+
+ # [EXPERIMENTAL]
+ # Parses +src+ and return a string which was matched to +pattern+.
+ # +pattern+ should be described as Regexp.
+ #
+ # require 'ripper'
+ #
+ # p Ripper.slice('def m(a) nil end', 'ident') #=> "m"
+ # p Ripper.slice('def m(a) nil end', '[ident lparen rparen]+') #=> "m(a)"
+ # p Ripper.slice("<<EOS\nstring\nEOS",
+ # 'heredoc_beg nl $(tstring_content*) heredoc_end', 1)
+ # #=> "string\n"
+ #
+ def Ripper.slice(src, pattern, n = 0)
+ if m = token_match(src, pattern)
+ then m.string(n)
+ else nil
+ end
+ end
+
+ def Ripper.token_match(src, pattern) #:nodoc:
+ TokenPattern.compile(pattern).match(src)
+ end
+
+ class TokenPattern #:nodoc:
+
+ class Error < ::StandardError # :nodoc:
+ end
+ class CompileError < Error # :nodoc:
+ end
+ class MatchError < Error # :nodoc:
+ end
+
+ class << self
+ alias compile new
+ end
+
+ def initialize(pattern)
+ @source = pattern
+ @re = compile(pattern)
+ end
+
+ def match(str)
+ match_list(::Ripper.lex(str))
+ end
+
+ def match_list(tokens)
+ if m = @re.match(map_tokens(tokens))
+ then MatchData.new(tokens, m)
+ else nil
+ end
+ end
+
+ private
+
+ def compile(pattern)
+ if m = /[^\w\s$()\[\]{}?*+\.]/.match(pattern)
+ raise CompileError, "invalid char in pattern: #{m[0].inspect}"
+ end
+ buf = ''
+ pattern.scan(/(?:\w+|\$\(|[()\[\]\{\}?*+\.]+)/) do |tok|
+ case tok
+ when /\w/
+ buf.concat map_token(tok)
+ when '$('
+ buf.concat '('
+ when '('
+ buf.concat '(?:'
+ when /[?*\[\])\.]/
+ buf.concat tok
+ else
+ raise 'must not happen'
+ end
+ end
+ Regexp.compile(buf)
+ rescue RegexpError => err
+ raise CompileError, err.message
+ end
+
+ def map_tokens(tokens)
+ tokens.map {|pos,type,str| map_token(type.to_s.sub(/\Aon_/,'')) }.join
+ end
+
+ MAP = {}
+ seed = ('a'..'z').to_a + ('A'..'Z').to_a + ('0'..'9').to_a
+ SCANNER_EVENT_TABLE.each do |ev, |
+ raise CompileError, "[RIPPER FATAL] too many system token" if seed.empty?
+ MAP[ev.to_s.sub(/\Aon_/,'')] = seed.shift
+ end
+
+ def map_token(tok)
+ MAP[tok] or raise CompileError, "unknown token: #{tok}"
+ end
+
+ class MatchData # :nodoc:
+ def initialize(tokens, match)
+ @tokens = tokens
+ @match = match
+ end
+
+ def string(n = 0)
+ return nil unless @match
+ match(n).join
+ end
+
+ private
+
+ def match(n = 0)
+ return [] unless @match
+ @tokens[@match.begin(n)...@match.end(n)].map {|pos,type,str| str }
+ end
+ end
+
+ end
+
+end
diff --git a/jni/ruby/ext/ripper/lib/ripper/sexp.rb b/jni/ruby/ext/ripper/lib/ripper/sexp.rb
new file mode 100644
index 0000000..514a585
--- /dev/null
+++ b/jni/ruby/ext/ripper/lib/ripper/sexp.rb
@@ -0,0 +1,118 @@
+#
+# $Id: sexp.rb 48144 2014-10-26 03:24:18Z nobu $
+#
+# Copyright (c) 2004,2005 Minero Aoki
+#
+# This program is free software.
+# You can distribute and/or modify this program under the Ruby License.
+# For details of Ruby License, see ruby/COPYING.
+#
+
+require 'ripper/core'
+
+class Ripper
+
+ # [EXPERIMENTAL]
+ # Parses +src+ and create S-exp tree.
+ # Returns more readable tree rather than Ripper.sexp_raw.
+ # This method is mainly for developer use.
+ #
+ # require 'ripper'
+ # require 'pp'
+ #
+ # pp Ripper.sexp("def m(a) nil end")
+ # #=> [:program,
+ # [[:def,
+ # [:@ident, "m", [1, 4]],
+ # [:paren, [:params, [[:@ident, "a", [1, 6]]], nil, nil, nil, nil]],
+ # [:bodystmt, [[:var_ref, [:@kw, "nil", [1, 9]]]], nil, nil, nil]]]]
+ #
+ def Ripper.sexp(src, filename = '-', lineno = 1)
+ builder = SexpBuilderPP.new(src, filename, lineno)
+ sexp = builder.parse
+ sexp unless builder.error?
+ end
+
+ # [EXPERIMENTAL]
+ # Parses +src+ and create S-exp tree.
+ # This method is mainly for developer use.
+ #
+ # require 'ripper'
+ # require 'pp'
+ #
+ # pp Ripper.sexp_raw("def m(a) nil end")
+ # #=> [:program,
+ # [:stmts_add,
+ # [:stmts_new],
+ # [:def,
+ # [:@ident, "m", [1, 4]],
+ # [:paren, [:params, [[:@ident, "a", [1, 6]]], nil, nil, nil]],
+ # [:bodystmt,
+ # [:stmts_add, [:stmts_new], [:var_ref, [:@kw, "nil", [1, 9]]]],
+ # nil,
+ # nil,
+ # nil]]]]
+ #
+ def Ripper.sexp_raw(src, filename = '-', lineno = 1)
+ builder = SexpBuilder.new(src, filename, lineno)
+ sexp = builder.parse
+ sexp unless builder.error?
+ end
+
+ class SexpBuilderPP < ::Ripper #:nodoc:
+ private
+
+ PARSER_EVENT_TABLE.each do |event, arity|
+ if /_new\z/ =~ event.to_s and arity == 0
+ module_eval(<<-End, __FILE__, __LINE__ + 1)
+ def on_#{event}
+ []
+ end
+ End
+ elsif /_add\z/ =~ event.to_s
+ module_eval(<<-End, __FILE__, __LINE__ + 1)
+ def on_#{event}(list, item)
+ list.push item
+ list
+ end
+ End
+ else
+ module_eval(<<-End, __FILE__, __LINE__ + 1)
+ def on_#{event}(*args)
+ [:#{event}, *args]
+ end
+ End
+ end
+ end
+
+ SCANNER_EVENTS.each do |event|
+ module_eval(<<-End, __FILE__, __LINE__ + 1)
+ def on_#{event}(tok)
+ [:@#{event}, tok, [lineno(), column()]]
+ end
+ End
+ end
+ end
+
+ class SexpBuilder < ::Ripper #:nodoc:
+ private
+
+ PARSER_EVENTS.each do |event|
+ module_eval(<<-End, __FILE__, __LINE__ + 1)
+ def on_#{event}(*args)
+ args.unshift :#{event}
+ args
+ end
+ End
+ end
+
+ SCANNER_EVENTS.each do |event|
+ module_eval(<<-End, __FILE__, __LINE__ + 1)
+ def on_#{event}(tok)
+ [:@#{event}, tok, [lineno(), column()]]
+ end
+ End
+ end
+ end
+
+end
diff --git a/jni/ruby/ext/ripper/tools/generate-param-macros.rb b/jni/ruby/ext/ripper/tools/generate-param-macros.rb
new file mode 100755
index 0000000..b19f6e8
--- /dev/null
+++ b/jni/ruby/ext/ripper/tools/generate-param-macros.rb
@@ -0,0 +1,14 @@
+off = true
+ARGF.each do |line|
+ case line
+ when /RIPPER_PARAMS_DECL_BEGIN/
+ off = false
+ when /RIPPER_PARAMS_DECL_END/
+ exit
+ when /ripper/
+ next if off
+ var = line.scan(/\w+/).last or next
+ base = var.sub(/ripper_/, '')
+ puts %"\#define #{base}\t\t(parser->ripper_#{base})"
+ end
+end
diff --git a/jni/ruby/ext/ripper/tools/generate.rb b/jni/ruby/ext/ripper/tools/generate.rb
new file mode 100755
index 0000000..d9c9ae1
--- /dev/null
+++ b/jni/ruby/ext/ripper/tools/generate.rb
@@ -0,0 +1,161 @@
+# $Id: generate.rb 48169 2014-10-28 02:53:24Z nobu $
+
+require 'optparse'
+
+def main
+ mode = nil
+ ids1src = nil
+ ids2src = nil
+ output = nil
+
+ parser = @parser = OptionParser.new
+ parser.banner = "Usage: #{File.basename($0)} --mode=MODE [--ids1src=PATH] [--ids2src=PATH] [--output=PATH]"
+ parser.on('--mode=MODE', 'check, eventids1, or eventids2table.') {|m|
+ mode = m
+ }
+ parser.on('--ids1src=PATH', 'A source file of event-IDs 1 (parse.y).') {|path|
+ ids1src = path
+ }
+ parser.on('--ids2src=PATH', 'A source file of event-IDs 2 (eventids2.c).') {|path|
+ ids2src = path
+ }
+ parser.on('--output=PATH', 'An output file.') {|path|
+ output = path
+ }
+ parser.on('--help', 'Prints this message and quit.') {
+ puts parser.help
+ exit true
+ }
+ begin
+ parser.parse!
+ rescue OptionParser::ParseError => err
+ usage err.message
+ end
+ usage 'no mode given' unless mode
+ case mode
+ when 'check'
+ usage 'no --ids1src' unless ids1src
+ usage 'no --ids2src' unless ids2src
+ h = read_ids1_with_locations(ids1src)
+ check_arity h
+ ids2 = read_ids2(ids2src)
+ common = h.keys & ids2
+ unless common.empty?
+ abort "event crash: #{common.join(' ')}"
+ end
+ exit 0
+ when 'eventids1'
+ usage 'no --ids1src' unless ids1src
+ result = generate_eventids1(read_ids1(ids1src))
+ when 'eventids2table'
+ usage 'no --ids2src' unless ids2src
+ result = generate_eventids2_table(read_ids2(ids2src))
+ end
+ if output
+ File.open(output, 'w') {|f|
+ f.write result
+ }
+ else
+ puts result
+ end
+end
+
+def usage(msg)
+ $stderr.puts msg
+ $stderr.puts @parser.help
+ exit false
+end
+
+def generate_eventids1(ids)
+ buf = ""
+ buf << %Q[static struct {\n]
+ ids.each do |id, arity|
+ buf << %Q[ ID id_#{id};\n]
+ end
+ buf << %Q[} ripper_parser_ids;\n]
+ buf << %Q[\n]
+ ids.each do |id, arity|
+ buf << %Q[#define ripper_id_#{id} ripper_parser_ids.id_#{id}\n]
+ end
+ buf << %Q[\n]
+ buf << %Q[static void\n]
+ buf << %Q[ripper_init_eventids1(void)\n]
+ buf << %Q[{\n]
+ buf << %Q[#define set_id1(name) ripper_id_##name = rb_intern_const("on_"#name)\n]
+ ids.each do |id, arity|
+ buf << %Q[ set_id1(#{id});\n]
+ end
+ buf << %Q[}\n]
+ buf << %Q[\n]
+ buf << %Q[static void\n]
+ buf << %Q[ripper_init_eventids1_table(VALUE self)\n]
+ buf << %Q[{\n]
+ buf << %Q[ VALUE h = rb_hash_new();\n]
+ buf << %Q[ rb_define_const(self, "PARSER_EVENT_TABLE", h);\n]
+ ids.each do |id, arity|
+ buf << %Q[ rb_hash_aset(h, intern_sym("#{id}"), INT2FIX(#{arity}));\n]
+ end
+ buf << %Q[}\n]
+ buf
+end
+
+def generate_eventids2_table(ids)
+ buf = ""
+ buf << %Q[static void\n]
+ buf << %Q[ripper_init_eventids2_table(VALUE self)\n]
+ buf << %Q[{\n]
+ buf << %Q[ VALUE h = rb_hash_new();\n]
+ buf << %Q[ rb_define_const(self, "SCANNER_EVENT_TABLE", h);\n]
+ ids.each do |id|
+ buf << %Q[ rb_hash_aset(h, intern_sym("#{id}"), INT2FIX(1));\n]
+ end
+ buf << %Q[}\n]
+ buf
+end
+
+def read_ids1(path)
+ strip_locations(read_ids1_with_locations(path))
+end
+
+def strip_locations(h)
+ h.map {|event, list| [event, list.first[1]] }\
+ .sort_by {|event, arity| event.to_s }
+end
+
+def check_arity(h)
+ invalid = false
+ h.each do |event, list|
+ unless list.map {|line, arity| arity }.uniq.size == 1
+ invalid = true
+ locations = list.map {|line, a| "#{line}:#{a}" }.join(', ')
+ $stderr.puts "arity crash [event=#{event}]: #{locations}"
+ end
+ end
+ abort if invalid
+end
+
+def read_ids1_with_locations(path)
+ h = {}
+ File.open(path) {|f|
+ f.each do |line|
+ next if /\A\#\s*define\s+dispatch/ =~ line
+ next if /ripper_dispatch/ =~ line
+ line.scan(/\bdispatch(\d)\((\w+)/) do |arity, event|
+ (h[event] ||= []).push [f.lineno, arity.to_i]
+ end
+ end
+ }
+ h
+end
+
+def read_ids2(path)
+ src = File.open(path) {|f| f.read}
+ ids2 = src.scan(/ID\s+ripper_id_(\w+)/).flatten.uniq.sort
+ diff = src.scan(/set_id2\((\w+)\);/).flatten - ids2
+ unless diff.empty?
+ abort "missing scanner IDs: #{diff}"
+ end
+ return ids2
+end
+
+main
diff --git a/jni/ruby/ext/ripper/tools/preproc.rb b/jni/ruby/ext/ripper/tools/preproc.rb
new file mode 100755
index 0000000..b2c4461
--- /dev/null
+++ b/jni/ruby/ext/ripper/tools/preproc.rb
@@ -0,0 +1,91 @@
+# $Id: preproc.rb 25189 2009-10-02 12:04:37Z akr $
+
+require 'optparse'
+
+def main
+ output = nil
+ parser = OptionParser.new
+ parser.banner = "Usage: #{File.basename($0)} [--output=PATH] <parse.y>"
+ parser.on('--output=PATH', 'An output file.') {|path|
+ output = path
+ }
+ parser.on('--help', 'Prints this message and quit.') {
+ puts parser.help
+ exit true
+ }
+ begin
+ parser.parse!
+ rescue OptionParser::ParseError => err
+ $stderr.puts err.message
+ $stderr.puts parser.help
+ exit false
+ end
+ unless ARGV.size == 1
+ abort "wrong number of arguments (#{ARGV.size} for 1)"
+ end
+ out = ""
+ File.open(ARGV[0]) {|f|
+ prelude f, out
+ grammar f, out
+ usercode f, out
+ }
+ if output
+ File.open(output, 'w') {|f|
+ f.write out
+ }
+ else
+ print out
+ end
+end
+
+def prelude(f, out)
+ while line = f.gets
+ case line
+ when %r</\*%%%\*/>
+ out << '/*' << $/
+ when %r</\*%>
+ out << '*/' << $/
+ when %r<%\*/>
+ out << $/
+ when /\A%%/
+ out << '%%' << $/
+ return
+ when /\A%token/
+ out << line.sub(/<\w+>/, '<val>')
+ when /\A%type/
+ out << line.sub(/<\w+>/, '<val>')
+ else
+ out << line
+ end
+ end
+end
+
+def grammar(f, out)
+ while line = f.gets
+ case line
+ when %r</\*%%%\*/>
+ out << '#if 0' << $/
+ when %r</\*%c%\*/>
+ out << '/*' << $/
+ when %r</\*%c>
+ out << '*/' << $/
+ when %r</\*%>
+ out << '#endif' << $/
+ when %r<%\*/>
+ out << $/
+ when /\A%%/
+ out << '%%' << $/
+ return
+ else
+ out << line
+ end
+ end
+end
+
+def usercode(f, out)
+ while line = f.gets
+ out << line
+ end
+end
+
+main
diff --git a/jni/ruby/ext/ripper/tools/strip.rb b/jni/ruby/ext/ripper/tools/strip.rb
new file mode 100755
index 0000000..99413c3
--- /dev/null
+++ b/jni/ruby/ext/ripper/tools/strip.rb
@@ -0,0 +1,12 @@
+last_is_void = false
+ARGF.each do |line|
+ if line.strip.empty?
+ #puts() unless last_is_void
+ last_is_void = true
+ elsif /\A\#/ === line
+ ;
+ else
+ print line
+ last_is_void = false
+ end
+end
diff --git a/jni/ruby/ext/sdbm/Makefile b/jni/ruby/ext/sdbm/Makefile
new file mode 100644
index 0000000..16cc9d2
--- /dev/null
+++ b/jni/ruby/ext/sdbm/Makefile
@@ -0,0 +1,288 @@
+
+SHELL = /bin/sh
+
+# V=0 quiet, V=1 verbose. other values don't work.
+V = 0
+Q1 = $(V:1=)
+Q = $(Q1:0=@)
+ECHO1 = $(V:1=@:)
+ECHO = $(ECHO1:0=@echo)
+NULLCMD = :
+
+#### Start of system configuration section. ####
+top_srcdir = $(topdir)/.
+srcdir = $(top_srcdir)/ext/sdbm
+topdir = ../..
+hdrdir = $(top_srcdir)/include
+arch_hdrdir = $(extout)/include/$(arch)
+PATH_SEPARATOR = :
+VPATH = $(srcdir):$(arch_hdrdir)/ruby:$(hdrdir)/ruby
+RUBYLIB =
+RUBYOPT = -
+prefix = $(DESTDIR)/usr/local
+rubysitearchprefix = $(rubylibprefix)/$(sitearch)
+rubyarchprefix = $(rubylibprefix)/$(arch)
+rubylibprefix = $(libdir)/$(RUBY_BASE_NAME)
+exec_prefix = $(prefix)
+vendorarchhdrdir = $(vendorhdrdir)/$(sitearch)
+sitearchhdrdir = $(sitehdrdir)/$(sitearch)
+rubyarchhdrdir = $(rubyhdrdir)/$(arch)
+vendorhdrdir = $(rubyhdrdir)/vendor_ruby
+sitehdrdir = $(rubyhdrdir)/site_ruby
+rubyhdrdir = $(includedir)/$(RUBY_VERSION_NAME)
+vendorarchdir = $(vendorlibdir)/$(sitearch)
+vendorlibdir = $(vendordir)/$(ruby_version)
+vendordir = $(rubylibprefix)/vendor_ruby
+sitearchdir = $(sitelibdir)/$(sitearch)
+sitelibdir = $(sitedir)/$(ruby_version)
+sitedir = $(rubylibprefix)/site_ruby
+rubyarchdir = $(rubylibdir)/$(arch)
+rubylibdir = $(rubylibprefix)/$(ruby_version)
+sitearchincludedir = $(includedir)/$(sitearch)
+archincludedir = $(includedir)/$(arch)
+sitearchlibdir = $(libdir)/$(sitearch)
+archlibdir = $(libdir)/$(arch)
+ridir = $(datarootdir)/$(RI_BASE_NAME)
+mandir = $(datarootdir)/man
+localedir = $(datarootdir)/locale
+libdir = $(exec_prefix)/lib
+psdir = $(docdir)
+pdfdir = $(docdir)
+dvidir = $(docdir)
+htmldir = $(docdir)
+infodir = $(datarootdir)/info
+docdir = $(datarootdir)/doc/$(PACKAGE)
+oldincludedir = $(DESTDIR)/usr/include
+includedir = $(prefix)/include
+localstatedir = $(prefix)/var
+sharedstatedir = $(prefix)/com
+sysconfdir = $(prefix)/etc
+datadir = $(datarootdir)
+datarootdir = $(prefix)/share
+libexecdir = $(exec_prefix)/libexec
+sbindir = $(exec_prefix)/sbin
+bindir = $(exec_prefix)/bin
+archdir = $(rubyarchdir)
+
+
+CC = gcc
+CXX = g++
+LIBRUBY = $(LIBRUBY_SO)
+LIBRUBY_A = lib$(RUBY_SO_NAME)-static.a
+LIBRUBYARG_SHARED = -Wl,-R$(libdir) -L$(libdir) -l$(RUBY_SO_NAME)
+LIBRUBYARG_STATIC = -Wl,-R$(libdir) -L$(libdir) -l$(RUBY_SO_NAME)-static
+empty =
+OUTFLAG = -o $(empty)
+COUTFLAG = -o $(empty)
+
+RUBY_EXTCONF_H = extconf.h
+cflags = $(optflags) $(debugflags) $(warnflags)
+optflags = -O3 -fno-fast-math
+debugflags = -ggdb3
+warnflags = -Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wunused-variable -Wpointer-arith -Wwrite-strings -Wdeclaration-after-statement -Wimplicit-function-declaration -Wdeprecated-declarations -Wno-packed-bitfield-compat
+CCDLFLAGS = -fPIC
+CFLAGS = $(CCDLFLAGS) $(cflags) -fPIC $(ARCH_FLAG)
+INCFLAGS = -I. -I$(arch_hdrdir) -I$(hdrdir) -I$(srcdir)
+DEFS =
+CPPFLAGS = -DRUBY_EXTCONF_H=\"$(RUBY_EXTCONF_H)\" $(DEFS) $(cppflags)
+CXXFLAGS = $(CCDLFLAGS) $(cxxflags) $(ARCH_FLAG)
+ldflags = -L. -fstack-protector -rdynamic -Wl,-export-dynamic
+dldflags =
+ARCH_FLAG =
+DLDFLAGS = $(ldflags) $(dldflags) $(ARCH_FLAG)
+LDSHARED = $(CC) -shared
+LDSHAREDXX = $(CXX) -shared
+AR = ar
+EXEEXT =
+
+RUBY_INSTALL_NAME = $(RUBY_BASE_NAME)
+RUBY_SO_NAME = ruby
+RUBYW_INSTALL_NAME =
+RUBY_VERSION_NAME = $(RUBY_BASE_NAME)-$(ruby_version)
+RUBYW_BASE_NAME = rubyw
+RUBY_BASE_NAME = ruby
+
+arch = x86_64-linux
+sitearch = $(arch)
+ruby_version = 2.2.0
+ruby = $(topdir)/miniruby -I'$(topdir)' -I'$(top_srcdir)/lib' -I'$(extout)/$(arch)' -I'$(extout)/common'
+RUBY = $(ruby)
+ruby_headers = $(hdrdir)/ruby.h $(hdrdir)/ruby/ruby.h $(hdrdir)/ruby/defines.h $(hdrdir)/ruby/missing.h $(hdrdir)/ruby/intern.h $(hdrdir)/ruby/st.h $(hdrdir)/ruby/subst.h $(arch_hdrdir)/ruby/config.h $(RUBY_EXTCONF_H)
+
+RM = rm -f
+RM_RF = $(RUBY) -run -e rm -- -rf
+RMDIRS = rmdir --ignore-fail-on-non-empty -p
+MAKEDIRS = /bin/mkdir -p
+INSTALL = /usr/bin/install -c
+INSTALL_PROG = $(INSTALL) -m 0755
+INSTALL_DATA = $(INSTALL) -m 644
+COPY = cp
+TOUCH = exit >
+
+#### End of system configuration section. ####
+
+preload =
+
+libpath = . $(topdir)
+LIBPATH = -L. -L$(topdir)
+DEFFILE =
+
+CLEANFILES = mkmf.log
+DISTCLEANFILES =
+DISTCLEANDIRS =
+
+extout = $(topdir)/.ext
+extout_prefix = $(extout)$(target_prefix)/
+target_prefix =
+LOCAL_LIBS =
+LIBS = $(LIBRUBYARG_SHARED) -lpthread -lgmp -ldl -lcrypt -lm -lc
+ORIG_SRCS = _sdbm.c init.c
+SRCS = $(ORIG_SRCS)
+OBJS = _sdbm.o init.o
+HDRS = $(srcdir)/sdbm.h $(srcdir)/extconf.h
+TARGET = sdbm
+TARGET_NAME = sdbm
+TARGET_ENTRY = Init_$(TARGET_NAME)
+DLLIB = $(TARGET).so
+EXTSTATIC =
+STATIC_LIB = $(TARGET).a
+
+TIMESTAMP_DIR = $(extout)/.timestamp
+BINDIR = $(extout)/bin
+RUBYCOMMONDIR = $(extout)/common
+RUBYLIBDIR = $(RUBYCOMMONDIR)$(target_prefix)
+RUBYARCHDIR = $(extout)/$(arch)$(target_prefix)
+HDRDIR = $(extout)/include/ruby$(target_prefix)
+ARCHHDRDIR = $(extout)/include/$(arch)/ruby$(target_prefix)
+
+TARGET_SO = $(RUBYARCHDIR)/$(DLLIB)
+CLEANLIBS = $(RUBYARCHDIR)/$(TARGET).so
+CLEANOBJS = *.o *.bak
+
+all: install
+static: all
+.PHONY: all install static install-so install-rb
+.PHONY: clean clean-so clean-static clean-rb
+
+clean-static::
+clean-rb-default::
+clean-rb::
+clean-so::
+clean: clean-so clean-static clean-rb-default clean-rb
+ -$(Q)$(RM) $(CLEANLIBS) $(CLEANOBJS) $(CLEANFILES) .*.time
+
+distclean-rb-default::
+distclean-rb::
+distclean-so::
+distclean-static::
+distclean: clean distclean-so distclean-static distclean-rb-default distclean-rb
+ -$(Q)$(RM) Makefile $(RUBY_EXTCONF_H) conftest.* mkmf.log
+ -$(Q)$(RM) core ruby$(EXEEXT) *~ $(DISTCLEANFILES)
+ -$(Q)$(RMDIRS) $(DISTCLEANDIRS) 2> /dev/null || true
+
+realclean: distclean
+install: install-so install-rb
+
+install-so: $(RUBYARCHDIR)/$(DLLIB)
+clean-so::
+ -$(Q)$(RM) $(RUBYARCHDIR)/$(DLLIB)
+ -$(Q)$(RMDIRS) $(RUBYARCHDIR) 2> /dev/null || true
+clean-static::
+ -$(Q)$(RM) $(STATIC_LIB)
+install-rb: pre-install-rb install-rb-default
+install-rb-default: pre-install-rb-default
+pre-install-rb: Makefile
+pre-install-rb-default: Makefile
+pre-install-rb-default:
+ @$(NULLCMD)
+$(TIMESTAMP_DIR)/.RUBYARCHDIR.time:
+ $(Q) $(MAKEDIRS) $(@D) $(RUBYARCHDIR)
+ $(Q) $(TOUCH) $@
+
+site-install: site-install-so site-install-rb
+site-install-so: install-so
+site-install-rb: install-rb
+
+.SUFFIXES: .c .m .cc .mm .cxx .cpp .o .S
+
+.cc.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<
+
+.cc.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -S $<
+
+.mm.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<
+
+.mm.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -S $<
+
+.cxx.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<
+
+.cxx.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -S $<
+
+.cpp.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<
+
+.cpp.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -S $<
+
+.c.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -c $<
+
+.c.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -S $<
+
+.m.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -c $<
+
+.m.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -S $<
+
+$(RUBYARCHDIR)/$(DLLIB): $(OBJS) Makefile $(TIMESTAMP_DIR)/.RUBYARCHDIR.time
+ $(ECHO) linking shared-object $(DLLIB)
+ -$(Q)$(RM) $(@)
+ $(Q) $(LDSHARED) -o $@ $(OBJS) $(LIBPATH) $(DLDFLAGS) $(LOCAL_LIBS) $(LIBS)
+
+$(STATIC_LIB): $(OBJS)
+ -$(Q)$(RM) $(@)
+ $(ECHO) linking static-library $(@)
+ $(Q) $(AR) cru $@ $(OBJS)
+ -$(Q)ranlib $(@) 2> /dev/null || true
+
+###
+$(OBJS): $(RUBY_EXTCONF_H)
+
+# AUTOGENERATED DEPENDENCIES START
+_sdbm.o: $(RUBY_EXTCONF_H)
+_sdbm.o: $(arch_hdrdir)/ruby/config.h
+_sdbm.o: $(hdrdir)/ruby/defines.h
+_sdbm.o: $(hdrdir)/ruby/missing.h
+_sdbm.o: _sdbm.c
+_sdbm.o: sdbm.h
+init.o: $(RUBY_EXTCONF_H)
+init.o: $(arch_hdrdir)/ruby/config.h
+init.o: $(hdrdir)/ruby/defines.h
+init.o: $(hdrdir)/ruby/intern.h
+init.o: $(hdrdir)/ruby/missing.h
+init.o: $(hdrdir)/ruby/ruby.h
+init.o: $(hdrdir)/ruby/st.h
+init.o: $(hdrdir)/ruby/subst.h
+init.o: $(top_srcdir)/include/ruby.h
+init.o: init.c
+init.o: sdbm.h
+# AUTOGENERATED DEPENDENCIES END
diff --git a/jni/ruby/ext/sdbm/_sdbm.c b/jni/ruby/ext/sdbm/_sdbm.c
new file mode 100644
index 0000000..d810bef
--- /dev/null
+++ b/jni/ruby/ext/sdbm/_sdbm.c
@@ -0,0 +1,952 @@
+/*
+ * sdbm - ndbm work-alike hashed database library
+ * based on Per-Aake Larson's Dynamic Hashing algorithms. BIT 18 (1978).
+ * author: oz@nexus.yorku.ca
+ * status: public domain.
+ *
+ * core routines
+ */
+
+#include "ruby/ruby.h"
+
+#ifdef HAVE_UNISTD_H
+#include <unistd.h>
+#endif
+
+#include "sdbm.h"
+
+/*
+ * sdbm - ndbm work-alike hashed database library
+ * tuning and portability constructs [not nearly enough]
+ * author: oz@nexus.yorku.ca
+ */
+
+#define BYTESIZ 8
+
+#ifdef BSD42
+#define SEEK_SET L_SET
+#define memset(s,c,n) bzero((s), (n)) /* only when c is zero */
+#define memcpy(s1,s2,n) bcopy((s2), (s1), (n))
+#define memcmp(s1,s2,n) bcmp((s1),(s2),(n))
+#endif
+
+/*
+ * important tuning parms (hah)
+ */
+
+#ifndef SEEDUPS
+#define SEEDUPS 1 /* always detect duplicates */
+#endif
+#ifndef BADMESS
+#define BADMESS 1 /* generate a message for worst case:
+ cannot make room after SPLTMAX splits */
+#endif
+
+/*
+ * misc
+ */
+#ifdef DEBUG
+#define debug(x) printf x
+#else
+#define debug(x)
+#endif
+
+#ifdef BIG_E
+#define GET_SHORT(p, i) (((unsigned)((unsigned char *)(p))[(i)*2] << 8) + (((unsigned char *)(p))[(i)*2 + 1]))
+#define PUT_SHORT(p, i, s) (((unsigned char *)(p))[(i)*2] = (unsigned char)((s) >> 8), ((unsigned char *)(p))[(i)*2 + 1] = (unsigned char)(s))
+#else
+#define GET_SHORT(p, i) ((p)[(i)])
+#define PUT_SHORT(p, i, s) ((p)[(i)] = (s))
+#endif
+
+/*#include "pair.h"*/
+static int fitpair proto((char *, int));
+static void putpair proto((char *, datum, datum));
+static datum getpair proto((char *, datum));
+static int delpair proto((char *, datum));
+static int chkpage proto((char *));
+static datum getnkey proto((char *, int));
+static void splpage proto((char *, char *, long));
+#if SEEDUPS
+static int duppair proto((char *, datum));
+#endif
+
+#include <stdio.h>
+#include <stdlib.h>
+#ifdef DOSISH
+#include <io.h>
+#endif
+#include <sys/types.h>
+#include <sys/stat.h>
+#ifdef BSD42
+#include <sys/file.h>
+#else
+#include <fcntl.h>
+/*#include <memory.h>*/
+#endif
+#ifndef O_BINARY
+#define O_BINARY 0
+#endif
+
+#include <errno.h>
+#ifndef EPERM
+#define EPERM EACCES
+#endif
+#include <string.h>
+
+#ifdef __STDC__
+#include <stddef.h>
+#endif
+
+#ifndef NULL
+#define NULL 0
+#endif
+
+/*
+ * externals
+ */
+#if !defined(__sun) && !defined(_WIN32) && !defined(__CYGWIN__) && !defined(errno)
+extern int errno;
+#endif
+
+/*
+ * forward
+ */
+static int getdbit proto((DBM *, long));
+static int setdbit proto((DBM *, long));
+static int getpage proto((DBM *, long));
+static datum getnext proto((DBM *));
+static int makroom proto((DBM *, long, int));
+
+/*
+ * useful macros
+ */
+#define bad(x) ((x).dptr == NULL || (x).dsize < 0)
+#define exhash(item) sdbm_hash((item).dptr, (item).dsize)
+#define ioerr(db) ((db)->flags |= DBM_IOERR)
+
+#define OFF_PAG(off) (long) (off) * PBLKSIZ
+#define OFF_DIR(off) (long) (off) * DBLKSIZ
+
+static long masks[] = {
+ 000000000000L, 000000000001L, 000000000003L,
+ 000000000007L, 000000000017L, 000000000037L,
+ 000000000077L, 000000000177L, 000000000377L,
+ 000000000777L, 000000001777L, 000000003777L,
+ 000000007777L, 000000017777L, 000000037777L,
+ 000000077777L, 000000177777L, 000000377777L,
+ 000000777777L, 000001777777L, 000003777777L,
+ 000007777777L, 000017777777L, 000037777777L,
+ 000077777777L, 000177777777L, 000377777777L,
+ 000777777777L, 001777777777L, 003777777777L,
+ 007777777777L, 017777777777L
+};
+
+datum nullitem = {NULL, 0};
+
+DBM *
+sdbm_open(register char *file, register int flags, register int mode)
+{
+ register DBM *db;
+ register char *dirname;
+ register char *pagname;
+ register size_t n;
+
+ if (file == NULL || !*file)
+ return errno = EINVAL, (DBM *) NULL;
+/*
+ * need space for two separate filenames
+ */
+ n = strlen(file) * 2 + strlen(DIRFEXT) + strlen(PAGFEXT) + 2;
+
+ if ((dirname = malloc(n)) == NULL)
+ return errno = ENOMEM, (DBM *) NULL;
+/*
+ * build the file names
+ */
+ dirname = strcat(strcpy(dirname, file), DIRFEXT);
+ pagname = strcpy(dirname + strlen(dirname) + 1, file);
+ pagname = strcat(pagname, PAGFEXT);
+
+ db = sdbm_prep(dirname, pagname, flags, mode);
+ free((char *) dirname);
+ return db;
+}
+
+static int
+fd_set_cloexec(int fd)
+{
+ /* MinGW don't have F_GETFD and FD_CLOEXEC. [ruby-core:40281] */
+#ifdef F_GETFD
+ int flags, ret;
+ flags = fcntl(fd, F_GETFD); /* should not fail except EBADF. */
+ if (flags == -1) {
+ return -1;
+ }
+ if (2 < fd) {
+ if (!(flags & FD_CLOEXEC)) {
+ flags |= FD_CLOEXEC;
+ ret = fcntl(fd, F_SETFD, flags);
+ if (ret == -1) {
+ return -1;
+ }
+ }
+ }
+#endif
+ return 0;
+}
+
+DBM *
+sdbm_prep(char *dirname, char *pagname, int flags, int mode)
+{
+ register DBM *db;
+ struct stat dstat;
+
+ if ((db = (DBM *) malloc(sizeof(DBM))) == NULL)
+ return errno = ENOMEM, (DBM *) NULL;
+
+ db->pagf = -1;
+ db->dirf = -1;
+ db->flags = 0;
+ db->hmask = 0;
+ db->blkptr = 0;
+ db->keyptr = 0;
+/*
+ * adjust user flags so that WRONLY becomes RDWR,
+ * as required by this package. Also set our internal
+ * flag for RDONLY.
+ */
+ if (flags & O_WRONLY)
+ flags = (flags & ~O_WRONLY) | O_RDWR;
+ if (flags & O_RDONLY)
+ db->flags = DBM_RDONLY;
+/*
+ * open the files in sequence, and stat the dirfile.
+ * If we fail anywhere, undo everything, return NULL.
+ */
+ flags |= O_BINARY;
+#ifdef O_CLOEXEC
+ flags |= O_CLOEXEC;
+#endif
+
+ if ((db->pagf = open(pagname, flags, mode)) == -1) goto err;
+ if (fd_set_cloexec(db->pagf) == -1) goto err;
+ if ((db->dirf = open(dirname, flags, mode)) == -1) goto err;
+ if (fd_set_cloexec(db->dirf) == -1) goto err;
+/*
+ * need the dirfile size to establish max bit number.
+ */
+ if (fstat(db->dirf, &dstat) == -1) goto err;
+/*
+ * zero size: either a fresh database, or one with a single,
+ * unsplit data page: dirpage is all zeros.
+ */
+ db->dirbno = (!dstat.st_size) ? 0 : -1;
+ db->pagbno = -1;
+ db->maxbno = dstat.st_size * (long) BYTESIZ;
+
+ (void) memset(db->pagbuf, 0, PBLKSIZ);
+ (void) memset(db->dirbuf, 0, DBLKSIZ);
+/*
+ * success
+ */
+ return db;
+
+ err:
+ if (db->pagf != -1)
+ (void) close(db->pagf);
+ if (db->dirf != -1)
+ (void) close(db->dirf);
+ free((char *) db);
+ return (DBM *) NULL;
+}
+
+void
+sdbm_close(register DBM *db)
+{
+ if (db == NULL)
+ errno = EINVAL;
+ else {
+ (void) close(db->dirf);
+ (void) close(db->pagf);
+ free((char *) db);
+ }
+}
+
+datum
+sdbm_fetch(register DBM *db, datum key)
+{
+ if (db == NULL || bad(key))
+ return errno = EINVAL, nullitem;
+
+ if (getpage(db, exhash(key)))
+ return getpair(db->pagbuf, key);
+
+ return ioerr(db), nullitem;
+}
+
+int
+sdbm_delete(register DBM *db, datum key)
+{
+ if (db == NULL || bad(key))
+ return errno = EINVAL, -1;
+ if (sdbm_rdonly(db))
+ return errno = EPERM, -1;
+
+ if (getpage(db, exhash(key))) {
+ if (!delpair(db->pagbuf, key))
+ return -1;
+/*
+ * update the page file
+ */
+ if (lseek(db->pagf, OFF_PAG(db->pagbno), SEEK_SET) < 0
+ || write(db->pagf, db->pagbuf, PBLKSIZ) < 0)
+ return ioerr(db), -1;
+
+ return 0;
+ }
+
+ return ioerr(db), -1;
+}
+
+int
+sdbm_store(register DBM *db, datum key, datum val, int flags)
+{
+ int need;
+ register long hash;
+
+ if (db == NULL || bad(key))
+ return errno = EINVAL, -1;
+ if (sdbm_rdonly(db))
+ return errno = EPERM, -1;
+
+ need = key.dsize + val.dsize;
+/*
+ * is the pair too big (or too small) for this database ??
+ */
+ if (need < 0 || need > PAIRMAX)
+ return errno = EINVAL, -1;
+
+ if (getpage(db, (hash = exhash(key)))) {
+/*
+ * if we need to replace, delete the key/data pair
+ * first. If it is not there, ignore.
+ */
+ if (flags == DBM_REPLACE)
+ (void) delpair(db->pagbuf, key);
+#if SEEDUPS
+ else if (duppair(db->pagbuf, key))
+ return 1;
+#endif
+/*
+ * if we do not have enough room, we have to split.
+ */
+ if (!fitpair(db->pagbuf, need))
+ if (!makroom(db, hash, need))
+ return ioerr(db), -1;
+/*
+ * we have enough room or split is successful. insert the key,
+ * and update the page file.
+ */
+ (void) putpair(db->pagbuf, key, val);
+
+ if (lseek(db->pagf, OFF_PAG(db->pagbno), SEEK_SET) < 0
+ || write(db->pagf, db->pagbuf, PBLKSIZ) < 0)
+ return ioerr(db), -1;
+ /*
+ * success
+ */
+ return 0;
+ }
+
+ return ioerr(db), -1;
+}
+
+/*
+ * makroom - make room by splitting the overfull page
+ * this routine will attempt to make room for SPLTMAX times before
+ * giving up.
+ */
+static int
+makroom(register DBM *db, long int hash, int need)
+{
+ long newp;
+ char twin[PBLKSIZ];
+#if defined _WIN32 && !defined __CYGWIN__
+ char zer[PBLKSIZ];
+ long oldtail;
+#endif
+ char *pag = db->pagbuf;
+ char *new = twin;
+ register int smax = SPLTMAX;
+
+ do {
+/*
+ * split the current page
+ */
+ (void) splpage(pag, new, db->hmask + 1);
+/*
+ * address of the new page
+ */
+ newp = (hash & db->hmask) | (db->hmask + 1);
+ debug(("newp: %ld\n", newp));
+/*
+ * write delay, read avoidance/cache shuffle:
+ * select the page for incoming pair: if key is to go to the new page,
+ * write out the previous one, and copy the new one over, thus making
+ * it the current page. If not, simply write the new page, and we are
+ * still looking at the page of interest. current page is not updated
+ * here, as sdbm_store will do so, after it inserts the incoming pair.
+ */
+
+#if defined _WIN32 && !defined __CYGWIN__
+ /*
+ * Fill hole with 0 if made it.
+ * (hole is NOT read as 0)
+ */
+ oldtail = lseek(db->pagf, 0L, SEEK_END);
+ memset(zer, 0, PBLKSIZ);
+ while (OFF_PAG(newp) > oldtail) {
+ if (lseek(db->pagf, 0L, SEEK_END) < 0 ||
+ write(db->pagf, zer, PBLKSIZ) < 0) {
+
+ return 0;
+ }
+ oldtail += PBLKSIZ;
+ }
+#endif
+
+ if (hash & (db->hmask + 1)) {
+ if (lseek(db->pagf, OFF_PAG(db->pagbno), SEEK_SET) < 0
+ || write(db->pagf, db->pagbuf, PBLKSIZ) < 0)
+ return 0;
+ db->pagbno = newp;
+ (void) memcpy(pag, new, PBLKSIZ);
+ }
+ else if (lseek(db->pagf, OFF_PAG(newp), SEEK_SET) < 0
+ || write(db->pagf, new, PBLKSIZ) < 0)
+ return 0;
+
+ if (!setdbit(db, db->curbit))
+ return 0;
+/*
+ * see if we have enough room now
+ */
+ if (fitpair(pag, need))
+ return 1;
+/*
+ * try again... update curbit and hmask as getpage would have
+ * done. because of our update of the current page, we do not
+ * need to read in anything. BUT we have to write the current
+ * [deferred] page out, as the window of failure is too great.
+ */
+ db->curbit = 2 * db->curbit +
+ ((hash & (db->hmask + 1)) ? 2 : 1);
+ db->hmask |= (db->hmask + 1);
+
+ if (lseek(db->pagf, OFF_PAG(db->pagbno), SEEK_SET) < 0
+ || write(db->pagf, db->pagbuf, PBLKSIZ) < 0)
+ return 0;
+
+ } while (--smax);
+/*
+ * if we are here, this is real bad news. After SPLTMAX splits,
+ * we still cannot fit the key. say goodnight.
+ */
+#if BADMESS
+ (void) (write(2, "sdbm: cannot insert after SPLTMAX attempts.\n", 44) < 0);
+#endif
+ return 0;
+
+}
+
+/*
+ * the following two routines will break if
+ * deletions aren't taken into account. (ndbm bug)
+ */
+datum
+sdbm_firstkey(register DBM *db)
+{
+ if (db == NULL)
+ return errno = EINVAL, nullitem;
+/*
+ * start at page 0
+ */
+ (void) memset(db->pagbuf, 0, PBLKSIZ);
+ if (lseek(db->pagf, OFF_PAG(0), SEEK_SET) < 0
+ || read(db->pagf, db->pagbuf, PBLKSIZ) < 0)
+ return ioerr(db), nullitem;
+ db->pagbno = 0;
+ db->blkptr = 0;
+ db->keyptr = 0;
+
+ return getnext(db);
+}
+
+datum
+sdbm_nextkey(register DBM *db)
+{
+ if (db == NULL)
+ return errno = EINVAL, nullitem;
+ return getnext(db);
+}
+
+/*
+ * all important binary trie traversal
+ */
+static int
+getpage(register DBM *db, register long int hash)
+{
+ register int hbit;
+ register long dbit;
+ register long pagb;
+
+ dbit = 0;
+ hbit = 0;
+ while (dbit < db->maxbno && getdbit(db, dbit))
+ dbit = 2 * dbit + ((hash & ((long) 1 << hbit++)) ? 2 : 1);
+
+ debug(("dbit: %d...", dbit));
+
+ db->curbit = dbit;
+ db->hmask = masks[hbit];
+
+ pagb = hash & db->hmask;
+/*
+ * see if the block we need is already in memory.
+ * note: this lookaside cache has about 10% hit rate.
+ */
+ if (pagb != db->pagbno) {
+/*
+ * note: here, we assume a "hole" is read as 0s.
+ * if not, must zero pagbuf first.
+ */
+ (void) memset(db->pagbuf, 0, PBLKSIZ);
+
+ if (lseek(db->pagf, OFF_PAG(pagb), SEEK_SET) < 0
+ || read(db->pagf, db->pagbuf, PBLKSIZ) < 0)
+ return 0;
+ if (!chkpage(db->pagbuf)) {
+ return 0;
+ }
+ db->pagbno = pagb;
+
+ debug(("pag read: %d\n", pagb));
+ }
+ return 1;
+}
+
+static int
+getdbit(register DBM *db, register long int dbit)
+{
+ register long c;
+ register long dirb;
+
+ c = dbit / BYTESIZ;
+ dirb = c / DBLKSIZ;
+
+ if (dirb != db->dirbno) {
+ if (lseek(db->dirf, OFF_DIR(dirb), SEEK_SET) < 0
+ || read(db->dirf, db->dirbuf, DBLKSIZ) < 0)
+ return 0;
+ db->dirbno = dirb;
+
+ debug(("dir read: %d\n", dirb));
+ }
+
+ return db->dirbuf[c % DBLKSIZ] & (1 << (dbit % BYTESIZ));
+}
+
+static int
+setdbit(register DBM *db, register long int dbit)
+{
+ register long c;
+ register long dirb;
+
+ c = dbit / BYTESIZ;
+ dirb = c / DBLKSIZ;
+
+ if (dirb != db->dirbno) {
+ if (lseek(db->dirf, OFF_DIR(dirb), SEEK_SET) < 0
+ || read(db->dirf, db->dirbuf, DBLKSIZ) < 0)
+ return 0;
+ db->dirbno = dirb;
+
+ debug(("dir read: %d\n", dirb));
+ }
+
+ db->dirbuf[c % DBLKSIZ] |= (1 << (dbit % BYTESIZ));
+
+ if (dbit >= db->maxbno)
+ db->maxbno += (long) DBLKSIZ * BYTESIZ;
+
+ if (lseek(db->dirf, OFF_DIR(dirb), SEEK_SET) < 0
+ || write(db->dirf, db->dirbuf, DBLKSIZ) < 0)
+ return 0;
+
+ return 1;
+}
+
+/*
+ * getnext - get the next key in the page, and if done with
+ * the page, try the next page in sequence
+ */
+static datum
+getnext(register DBM *db)
+{
+ datum key;
+
+ for (;;) {
+ db->keyptr++;
+ key = getnkey(db->pagbuf, db->keyptr);
+ if (key.dptr != NULL)
+ return key;
+/*
+ * we either run out, or there is nothing on this page..
+ * try the next one... If we lost our position on the
+ * file, we will have to seek.
+ */
+ db->keyptr = 0;
+ if (db->pagbno != db->blkptr++)
+ if (lseek(db->pagf, OFF_PAG(db->blkptr), SEEK_SET) < 0)
+ break;
+ db->pagbno = db->blkptr;
+ if (read(db->pagf, db->pagbuf, PBLKSIZ) <= 0)
+ break;
+ if (!chkpage(db->pagbuf)) {
+ break;
+ }
+ }
+
+ return ioerr(db), nullitem;
+}
+
+/* pair.c */
+/*
+ * sdbm - ndbm work-alike hashed database library
+ * based on Per-Aake Larson's Dynamic Hashing algorithms. BIT 18 (1978).
+ * author: oz@nexus.yorku.ca
+ * status: public domain.
+ *
+ * page-level routines
+ */
+
+#ifndef BSD42
+/*#include <memory.h>*/
+#endif
+
+#define exhash(item) sdbm_hash((item).dptr, (item).dsize)
+
+/*
+ * forward
+ */
+static int seepair proto((char *, int, char *, int));
+
+/*
+ * page format:
+ * +------------------------------+
+ * ino | n | keyoff | datoff | keyoff |
+ * +------------+--------+--------+
+ * | datoff | - - - ----> |
+ * +--------+---------------------+
+ * | F R E E A R E A |
+ * +--------------+---------------+
+ * | <---- - - - | data |
+ * +--------+-----+----+----------+
+ * | key | data | key |
+ * +--------+----------+----------+
+ *
+ * calculating the offsets for free area: if the number
+ * of entries (ino[0]) is zero, the offset to the END of
+ * the free area is the block size. Otherwise, it is the
+ * nth (ino[ino[0]]) entry's offset.
+ */
+
+static int
+fitpair(char *pag, int need)
+{
+ register int n;
+ register int off;
+ register int free;
+ register short *ino = (short *) pag;
+
+ off = ((n = GET_SHORT(ino,0)) > 0) ? GET_SHORT(ino,n) : PBLKSIZ;
+ free = off - (n + 1) * (int)sizeof(short);
+ need += 2 * (int)sizeof(short);
+
+ debug(("free %d need %d\n", free, need));
+
+ return need <= free;
+}
+
+static void
+putpair(char *pag, datum key, datum val)
+{
+ register int n;
+ register int off;
+ register short *ino = (short *) pag;
+
+ off = ((n = GET_SHORT(ino,0)) > 0) ? GET_SHORT(ino,n) : PBLKSIZ;
+/*
+ * enter the key first
+ */
+ off -= key.dsize;
+ if (key.dsize)
+ (void) memcpy(pag + off, key.dptr, key.dsize);
+ PUT_SHORT(ino,n + 1,off);
+/*
+ * now the data
+ */
+ off -= val.dsize;
+ if (val.dsize)
+ (void) memcpy(pag + off, val.dptr, val.dsize);
+ PUT_SHORT(ino,n + 2,off);
+/*
+ * adjust item count
+ */
+ PUT_SHORT(ino,0,GET_SHORT(ino,0) + 2);
+}
+
+static datum
+getpair(char *pag, datum key)
+{
+ register int i;
+ register int n;
+ datum val;
+ register short *ino = (short *) pag;
+
+ if ((n = GET_SHORT(ino,0)) == 0)
+ return nullitem;
+
+ if ((i = seepair(pag, n, key.dptr, key.dsize)) == 0)
+ return nullitem;
+
+ val.dptr = pag + GET_SHORT(ino,i + 1);
+ val.dsize = GET_SHORT(ino,i) - GET_SHORT(ino,i + 1);
+ return val;
+}
+
+#if SEEDUPS
+static int
+duppair(char *pag, datum key)
+{
+ register short *ino = (short *) pag;
+ return GET_SHORT(ino,0) > 0 &&
+ seepair(pag, GET_SHORT(ino,0), key.dptr, key.dsize) > 0;
+}
+#endif
+
+static datum
+getnkey(char *pag, int num)
+{
+ datum key;
+ register int off;
+ register short *ino = (short *) pag;
+
+ num = num * 2 - 1;
+ if (GET_SHORT(ino,0) == 0 || num > GET_SHORT(ino,0))
+ return nullitem;
+
+ off = (num > 1) ? GET_SHORT(ino,num - 1) : PBLKSIZ;
+
+ key.dptr = pag + GET_SHORT(ino,num);
+ key.dsize = off - GET_SHORT(ino,num);
+
+ return key;
+}
+
+static int
+delpair(char *pag, datum key)
+{
+ register int n;
+ register int i;
+ register short *ino = (short *) pag;
+
+ if ((n = GET_SHORT(ino,0)) == 0)
+ return 0;
+
+ if ((i = seepair(pag, n, key.dptr, key.dsize)) == 0)
+ return 0;
+/*
+ * found the key. if it is the last entry
+ * [i.e. i == n - 1] we just adjust the entry count.
+ * hard case: move all data down onto the deleted pair,
+ * shift offsets onto deleted offsets, and adjust them.
+ * [note: 0 < i < n]
+ */
+ if (i < n - 1) {
+ register int m;
+ register char *dst = pag + (i == 1 ? PBLKSIZ : GET_SHORT(ino,i - 1));
+ register char *src = pag + GET_SHORT(ino,i + 1);
+ register ptrdiff_t zoo = dst - src;
+
+ debug(("free-up %"PRIdPTRDIFF" ", zoo));
+/*
+ * shift data/keys down
+ */
+ m = GET_SHORT(ino,i + 1) - GET_SHORT(ino,n);
+#ifdef DUFF
+#define MOVB *--dst = *--src
+
+ if (m > 0) {
+ register int loop = (m + 8 - 1) >> 3;
+
+ switch (m & (8 - 1)) {
+ case 0: do {
+ MOVB; case 7: MOVB;
+ case 6: MOVB; case 5: MOVB;
+ case 4: MOVB; case 3: MOVB;
+ case 2: MOVB; case 1: MOVB;
+ } while (--loop);
+ }
+ }
+#else
+#ifdef MEMMOVE
+ memmove(dst-m, src-m, m);
+#else
+ while (m--)
+ *--dst = *--src;
+#endif
+#endif
+/*
+ * adjust offset index up
+ */
+ while (i < n - 1) {
+ PUT_SHORT(ino,i, GET_SHORT(ino,i + 2) + zoo);
+ i++;
+ }
+ }
+ PUT_SHORT(ino, 0, GET_SHORT(ino, 0) - 2);
+ return 1;
+}
+
+/*
+ * search for the key in the page.
+ * return offset index in the range 0 < i < n.
+ * return 0 if not found.
+ */
+static int
+seepair(char *pag, register int n, register char *key, register int siz)
+{
+ register int i;
+ register int off = PBLKSIZ;
+ register short *ino = (short *) pag;
+
+ for (i = 1; i < n; i += 2) {
+ if (siz == off - GET_SHORT(ino,i) &&
+ memcmp(key, pag + GET_SHORT(ino,i), siz) == 0)
+ return i;
+ off = GET_SHORT(ino,i + 1);
+ }
+ return 0;
+}
+
+static void
+splpage(char *pag, char *new, long int sbit)
+{
+ datum key;
+ datum val;
+
+ register int n;
+ register int off = PBLKSIZ;
+ char cur[PBLKSIZ];
+ register short *ino = (short *) cur;
+
+ (void) memcpy(cur, pag, PBLKSIZ);
+ (void) memset(pag, 0, PBLKSIZ);
+ (void) memset(new, 0, PBLKSIZ);
+
+ n = GET_SHORT(ino,0);
+ for (ino++; n > 0; ino += 2) {
+ key.dptr = cur + GET_SHORT(ino,0);
+ key.dsize = off - GET_SHORT(ino,0);
+ val.dptr = cur + GET_SHORT(ino,1);
+ val.dsize = GET_SHORT(ino,0) - GET_SHORT(ino,1);
+/*
+ * select the page pointer (by looking at sbit) and insert
+ */
+ (void) putpair((exhash(key) & sbit) ? new : pag, key, val);
+
+ off = GET_SHORT(ino,1);
+ n -= 2;
+ }
+
+ debug(("%d split %d/%d\n", ((short *) cur)[0] / 2,
+ ((short *) new)[0] / 2,
+ ((short *) pag)[0] / 2));
+}
+
+/*
+ * check page sanity:
+ * number of entries should be something
+ * reasonable, and all offsets in the index should be in order.
+ * this could be made more rigorous.
+ */
+static int
+chkpage(char *pag)
+{
+ register int n;
+ register int off;
+ register short *ino = (short *) pag;
+
+ if ((n = GET_SHORT(ino,0)) < 0 || n > PBLKSIZ / (int)sizeof(short))
+ return 0;
+
+ if (n > 0) {
+ off = PBLKSIZ;
+ for (ino++; n > 0; ino += 2) {
+ if (GET_SHORT(ino,0) > off || GET_SHORT(ino,1) > off ||
+ GET_SHORT(ino,1) > GET_SHORT(ino,0))
+ return 0;
+ off = GET_SHORT(ino,1);
+ n -= 2;
+ }
+ }
+ return 1;
+}
+
+/* hash.c */
+/*
+ * sdbm - ndbm work-alike hashed database library
+ * based on Per-Aake Larson's Dynamic Hashing algorithms. BIT 18 (1978).
+ * author: oz@nexus.yorku.ca
+ * status: public domain. keep it that way.
+ *
+ * hashing routine
+ */
+
+/*
+ * polynomial conversion ignoring overflows
+ * [this seems to work remarkably well, in fact better
+ * then the ndbm hash function. Replace at your own risk]
+ * use: 65599 nice.
+ * 65587 even better.
+ */
+long
+sdbm_hash(register char *str, register int len)
+{
+ register unsigned long n = 0;
+
+#ifdef DUFF
+
+#define HASHC n = *str++ + 65599 * n
+
+ if (len > 0) {
+ register int loop = (len + 8 - 1) >> 3;
+
+ switch(len & (8 - 1)) {
+ case 0: do {
+ HASHC; case 7: HASHC;
+ case 6: HASHC; case 5: HASHC;
+ case 4: HASHC; case 3: HASHC;
+ case 2: HASHC; case 1: HASHC;
+ } while (--loop);
+ }
+
+ }
+#else
+ while (len--)
+ n = ((*str++) & 255) + 65587L * n;
+#endif
+ return n;
+}
diff --git a/jni/ruby/ext/sdbm/depend b/jni/ruby/ext/sdbm/depend
new file mode 100644
index 0000000..b8f5513
--- /dev/null
+++ b/jni/ruby/ext/sdbm/depend
@@ -0,0 +1,19 @@
+# AUTOGENERATED DEPENDENCIES START
+_sdbm.o: $(RUBY_EXTCONF_H)
+_sdbm.o: $(arch_hdrdir)/ruby/config.h
+_sdbm.o: $(hdrdir)/ruby/defines.h
+_sdbm.o: $(hdrdir)/ruby/missing.h
+_sdbm.o: _sdbm.c
+_sdbm.o: sdbm.h
+init.o: $(RUBY_EXTCONF_H)
+init.o: $(arch_hdrdir)/ruby/config.h
+init.o: $(hdrdir)/ruby/defines.h
+init.o: $(hdrdir)/ruby/intern.h
+init.o: $(hdrdir)/ruby/missing.h
+init.o: $(hdrdir)/ruby/ruby.h
+init.o: $(hdrdir)/ruby/st.h
+init.o: $(hdrdir)/ruby/subst.h
+init.o: $(top_srcdir)/include/ruby.h
+init.o: init.c
+init.o: sdbm.h
+# AUTOGENERATED DEPENDENCIES END
diff --git a/jni/ruby/ext/sdbm/extconf.h b/jni/ruby/ext/sdbm/extconf.h
new file mode 100644
index 0000000..6df6e45
--- /dev/null
+++ b/jni/ruby/ext/sdbm/extconf.h
@@ -0,0 +1,4 @@
+#ifndef EXTCONF_H
+#define EXTCONF_H
+#define BADMESS 0
+#endif
diff --git a/jni/ruby/ext/sdbm/extconf.rb b/jni/ruby/ext/sdbm/extconf.rb
new file mode 100644
index 0000000..67796fb
--- /dev/null
+++ b/jni/ruby/ext/sdbm/extconf.rb
@@ -0,0 +1,4 @@
+require 'mkmf'
+
+$defs << "-D""BADMESS=0"
+create_makefile("sdbm")
diff --git a/jni/ruby/ext/sdbm/init.c b/jni/ruby/ext/sdbm/init.c
new file mode 100644
index 0000000..e9ae766
--- /dev/null
+++ b/jni/ruby/ext/sdbm/init.c
@@ -0,0 +1,1065 @@
+/************************************************
+
+ sdbminit.c -
+
+ $Author: nobu $
+ created at: Fri May 7 08:34:24 JST 1999
+
+ Copyright (C) 1995-2001 Yukihiro Matsumoto
+
+************************************************/
+
+#include "ruby.h"
+
+#include "sdbm.h"
+#include <fcntl.h>
+#include <errno.h>
+
+/*
+ * Document-class: SDBM
+ *
+ * SDBM provides a simple file-based key-value store, which can only store
+ * String keys and values.
+ *
+ * Note that Ruby comes with the source code for SDBM, while the DBM and GDBM
+ * standard libraries rely on external libraries and headers.
+ *
+ * === Examples
+ *
+ * Insert values:
+ *
+ * require 'sdbm'
+ *
+ * SDBM.open 'my_database' do |db|
+ * db['apple'] = 'fruit'
+ * db['pear'] = 'fruit'
+ * db['carrot'] = 'vegetable'
+ * db['tomato'] = 'vegetable'
+ * end
+ *
+ * Bulk update:
+ *
+ * require 'sdbm'
+ *
+ * SDBM.open 'my_database' do |db|
+ * db.update('peach' => 'fruit', 'tomato' => 'fruit')
+ * end
+ *
+ * Retrieve values:
+ *
+ * require 'sdbm'
+ *
+ * SDBM.open 'my_database' do |db|
+ * db.each do |key, value|
+ * puts "Key: #{key}, Value: #{value}"
+ * end
+ * end
+ *
+ * Outputs:
+ *
+ * Key: apple, Value: fruit
+ * Key: pear, Value: fruit
+ * Key: carrot, Value: vegetable
+ * Key: peach, Value: fruit
+ * Key: tomato, Value: fruit
+ */
+
+static VALUE rb_cDBM, rb_eDBMError;
+
+struct dbmdata {
+ int di_size;
+ DBM *di_dbm;
+};
+
+static void
+closed_sdbm(void)
+{
+ rb_raise(rb_eDBMError, "closed SDBM file");
+}
+
+#define GetDBM(obj, dbmp) do {\
+ TypedData_Get_Struct((obj), struct dbmdata, &sdbm_type, (dbmp));\
+ if ((dbmp) == 0) closed_sdbm();\
+ if ((dbmp)->di_dbm == 0) closed_sdbm();\
+} while (0)
+
+#define GetDBM2(obj, dbmp, dbm) do {\
+ GetDBM((obj), (dbmp));\
+ (dbm) = (dbmp)->di_dbm;\
+} while (0)
+
+static void
+free_sdbm(void *ptr)
+{
+ struct dbmdata *dbmp = ptr;
+
+ if (dbmp->di_dbm) sdbm_close(dbmp->di_dbm);
+ ruby_xfree(dbmp);
+}
+
+static size_t
+memsize_dbm(const void *ptr)
+{
+ size_t size = 0;
+ const struct dbmdata *dbmp = ptr;
+ if (dbmp) {
+ size += sizeof(*dbmp);
+ if (dbmp->di_dbm) size += sizeof(DBM);
+ }
+ return size;
+}
+
+static const rb_data_type_t sdbm_type = {
+ "sdbm",
+ {0, free_sdbm, memsize_dbm,},
+ 0, 0,
+ RUBY_TYPED_FREE_IMMEDIATELY,
+};
+
+/*
+ * call-seq:
+ * sdbm.close -> nil
+ *
+ * Closes the database file.
+ *
+ * Raises SDBMError if the database is already closed.
+ */
+static VALUE
+fsdbm_close(VALUE obj)
+{
+ struct dbmdata *dbmp;
+
+ GetDBM(obj, dbmp);
+ sdbm_close(dbmp->di_dbm);
+ dbmp->di_dbm = 0;
+
+ return Qnil;
+}
+
+/*
+ * call-seq:
+ * sdbm.closed? -> true or false
+ *
+ * Returns +true+ if the database is closed.
+ */
+static VALUE
+fsdbm_closed(VALUE obj)
+{
+ struct dbmdata *dbmp;
+
+ TypedData_Get_Struct(obj, struct dbmdata, &sdbm_type, dbmp);
+ if (dbmp == 0)
+ return Qtrue;
+ if (dbmp->di_dbm == 0)
+ return Qtrue;
+
+ return Qfalse;
+}
+
+static VALUE
+fsdbm_alloc(VALUE klass)
+{
+ return TypedData_Wrap_Struct(klass, &sdbm_type, 0);
+}
+/*
+ * call-seq:
+ * SDBM.new(filename, mode = 0666)
+ *
+ * Creates a new database handle by opening the given +filename+. SDBM actually
+ * uses two physical files, with extensions '.dir' and '.pag'. These extensions
+ * will automatically be appended to the +filename+.
+ *
+ * If the file does not exist, a new file will be created using the given
+ * +mode+, unless +mode+ is explicitly set to nil. In the latter case, no
+ * database will be created.
+ *
+ * If the file exists, it will be opened in read/write mode. If this fails, it
+ * will be opened in read-only mode.
+ */
+static VALUE
+fsdbm_initialize(int argc, VALUE *argv, VALUE obj)
+{
+ volatile VALUE file;
+ VALUE vmode;
+ DBM *dbm;
+ struct dbmdata *dbmp;
+ int mode;
+
+ if (rb_scan_args(argc, argv, "11", &file, &vmode) == 1) {
+ mode = 0666; /* default value */
+ }
+ else if (NIL_P(vmode)) {
+ mode = -1; /* return nil if DB not exist */
+ }
+ else {
+ mode = NUM2INT(vmode);
+ }
+ FilePathValue(file);
+
+ dbm = 0;
+ if (mode >= 0)
+ dbm = sdbm_open(RSTRING_PTR(file), O_RDWR|O_CREAT, mode);
+ if (!dbm)
+ dbm = sdbm_open(RSTRING_PTR(file), O_RDWR, 0);
+ if (!dbm)
+ dbm = sdbm_open(RSTRING_PTR(file), O_RDONLY, 0);
+
+ if (!dbm) {
+ if (mode == -1) return Qnil;
+ rb_sys_fail_str(file);
+ }
+
+ dbmp = ALLOC(struct dbmdata);
+ DATA_PTR(obj) = dbmp;
+ dbmp->di_dbm = dbm;
+ dbmp->di_size = -1;
+
+ return obj;
+}
+
+/*
+ * call-seq:
+ * SDBM.open(filename, mode = 0666)
+ * SDBM.open(filename, mode = 0666) { |sdbm| ... }
+ *
+ * If called without a block, this is the same as SDBM.new.
+ *
+ * If a block is given, the new database will be passed to the block and
+ * will be safely closed after the block has executed.
+ *
+ * Example:
+ *
+ * require 'sdbm'
+ *
+ * SDBM.open('my_database') do |db|
+ * db['hello'] = 'world'
+ * end
+ */
+static VALUE
+fsdbm_s_open(int argc, VALUE *argv, VALUE klass)
+{
+ VALUE obj = fsdbm_alloc(klass);
+
+ if (NIL_P(fsdbm_initialize(argc, argv, obj))) {
+ return Qnil;
+ }
+
+ if (rb_block_given_p()) {
+ return rb_ensure(rb_yield, obj, fsdbm_close, obj);
+ }
+
+ return obj;
+}
+
+static VALUE
+fsdbm_fetch(VALUE obj, VALUE keystr, VALUE ifnone)
+{
+ datum key, value;
+ struct dbmdata *dbmp;
+ DBM *dbm;
+
+ ExportStringValue(keystr);
+ key.dptr = RSTRING_PTR(keystr);
+ key.dsize = RSTRING_LENINT(keystr);
+
+ GetDBM2(obj, dbmp, dbm);
+ value = sdbm_fetch(dbm, key);
+ if (value.dptr == 0) {
+ if (ifnone == Qnil && rb_block_given_p())
+ return rb_yield(rb_external_str_new(key.dptr, key.dsize));
+ return ifnone;
+ }
+ return rb_external_str_new(value.dptr, value.dsize);
+}
+
+/*
+ * call-seq:
+ * sdbm[key] -> value or nil
+ *
+ * Returns the +value+ in the database associated with the given +key+ string.
+ *
+ * If no value is found, returns +nil+.
+ */
+static VALUE
+fsdbm_aref(VALUE obj, VALUE keystr)
+{
+ return fsdbm_fetch(obj, keystr, Qnil);
+}
+
+/*
+ * call-seq:
+ * sdbm.fetch(key) -> value or nil
+ * sdbm.fetch(key) { |key| ... }
+ *
+ * Returns the +value+ in the database associated with the given +key+ string.
+ *
+ * If a block is provided, the block will be called when there is no
+ * +value+ associated with the given +key+. The +key+ will be passed in as an
+ * argument to the block.
+ *
+ * If no block is provided and no value is associated with the given +key+,
+ * then an IndexError will be raised.
+ */
+static VALUE
+fsdbm_fetch_m(int argc, VALUE *argv, VALUE obj)
+{
+ VALUE keystr, valstr, ifnone;
+
+ rb_scan_args(argc, argv, "11", &keystr, &ifnone);
+ valstr = fsdbm_fetch(obj, keystr, ifnone);
+ if (argc == 1 && !rb_block_given_p() && NIL_P(valstr))
+ rb_raise(rb_eIndexError, "key not found");
+
+ return valstr;
+}
+
+/*
+ * call-seq:
+ * sdbm.key(value) -> key
+ *
+ * Returns the +key+ associated with the given +value+. If more than one
+ * +key+ corresponds to the given +value+, then the first key to be found
+ * will be returned. If no keys are found, +nil+ will be returned.
+ */
+static VALUE
+fsdbm_key(VALUE obj, VALUE valstr)
+{
+ datum key, val;
+ struct dbmdata *dbmp;
+ DBM *dbm;
+
+ ExportStringValue(valstr);
+ val.dptr = RSTRING_PTR(valstr);
+ val.dsize = RSTRING_LENINT(valstr);
+
+ GetDBM2(obj, dbmp, dbm);
+ for (key = sdbm_firstkey(dbm); key.dptr; key = sdbm_nextkey(dbm)) {
+ val = sdbm_fetch(dbm, key);
+ if (val.dsize == RSTRING_LEN(valstr) &&
+ memcmp(val.dptr, RSTRING_PTR(valstr), val.dsize) == 0)
+ return rb_external_str_new(key.dptr, key.dsize);
+ }
+ return Qnil;
+}
+
+/*
+ * :nodoc:
+ */
+static VALUE
+fsdbm_index(VALUE hash, VALUE value)
+{
+ rb_warn("SDBM#index is deprecated; use SDBM#key");
+ return fsdbm_key(hash, value);
+}
+
+/* call-seq:
+ * sdbm.select { |key, value| ... } -> Array
+ *
+ * Returns a new Array of key-value pairs for which the block returns +true+.
+ *
+ * Example:
+ *
+ * require 'sdbm'
+ *
+ * SDBM.open 'my_database' do |db|
+ * db['apple'] = 'fruit'
+ * db['pear'] = 'fruit'
+ * db['spinach'] = 'vegetable'
+ *
+ * veggies = db.select do |key, value|
+ * value == 'vegetable'
+ * end #=> [["apple", "fruit"], ["pear", "fruit"]]
+ * end
+ */
+static VALUE
+fsdbm_select(VALUE obj)
+{
+ VALUE new = rb_ary_new();
+ datum key, val;
+ DBM *dbm;
+ struct dbmdata *dbmp;
+
+ GetDBM2(obj, dbmp, dbm);
+ for (key = sdbm_firstkey(dbm); key.dptr; key = sdbm_nextkey(dbm)) {
+ VALUE assoc, v;
+ val = sdbm_fetch(dbm, key);
+ assoc = rb_assoc_new(rb_external_str_new(key.dptr, key.dsize),
+ rb_external_str_new(val.dptr, val.dsize));
+ v = rb_yield(assoc);
+ if (RTEST(v)) {
+ rb_ary_push(new, assoc);
+ }
+ GetDBM2(obj, dbmp, dbm);
+ }
+
+ return new;
+}
+
+/* call-seq:
+ * sdbm.values_at(key, ...) -> Array
+ *
+ * Returns an Array of values corresponding to the given keys.
+ */
+static VALUE
+fsdbm_values_at(int argc, VALUE *argv, VALUE obj)
+{
+ VALUE new = rb_ary_new2(argc);
+ int i;
+
+ for (i=0; i<argc; i++) {
+ rb_ary_push(new, fsdbm_fetch(obj, argv[i], Qnil));
+ }
+
+ return new;
+}
+
+static void
+fdbm_modify(VALUE obj)
+{
+ if (OBJ_FROZEN(obj)) rb_error_frozen("SDBM");
+}
+
+/*
+ * call-seq:
+ * sdbm.delete(key) -> value or nil
+ * sdbm.delete(key) { |key, value| ... }
+ *
+ * Deletes the key-value pair corresponding to the given +key+. If the
+ * +key+ exists, the deleted value will be returned, otherwise +nil+.
+ *
+ * If a block is provided, the deleted +key+ and +value+ will be passed to
+ * the block as arguments. If the +key+ does not exist in the database, the
+ * value will be +nil+.
+ */
+static VALUE
+fsdbm_delete(VALUE obj, VALUE keystr)
+{
+ datum key, value;
+ struct dbmdata *dbmp;
+ DBM *dbm;
+ VALUE valstr;
+
+ fdbm_modify(obj);
+ ExportStringValue(keystr);
+ key.dptr = RSTRING_PTR(keystr);
+ key.dsize = RSTRING_LENINT(keystr);
+
+ GetDBM2(obj, dbmp, dbm);
+ dbmp->di_size = -1;
+
+ value = sdbm_fetch(dbm, key);
+ if (value.dptr == 0) {
+ if (rb_block_given_p()) return rb_yield(keystr);
+ return Qnil;
+ }
+
+ /* need to save value before sdbm_delete() */
+ valstr = rb_external_str_new(value.dptr, value.dsize);
+
+ if (sdbm_delete(dbm, key)) {
+ dbmp->di_size = -1;
+ rb_raise(rb_eDBMError, "dbm_delete failed");
+ }
+ else if (dbmp->di_size >= 0) {
+ dbmp->di_size--;
+ }
+ return valstr;
+}
+
+/*
+ * call-seq:
+ * sdbm.shift -> Array or nil
+ *
+ * Removes a key-value pair from the database and returns them as an
+ * Array. If the database is empty, returns +nil+.
+ */
+static VALUE
+fsdbm_shift(VALUE obj)
+{
+ datum key, val;
+ struct dbmdata *dbmp;
+ DBM *dbm;
+ VALUE keystr, valstr;
+
+ fdbm_modify(obj);
+ GetDBM2(obj, dbmp, dbm);
+ key = sdbm_firstkey(dbm);
+ if (!key.dptr) return Qnil;
+ val = sdbm_fetch(dbm, key);
+ keystr = rb_external_str_new(key.dptr, key.dsize);
+ valstr = rb_external_str_new(val.dptr, val.dsize);
+ sdbm_delete(dbm, key);
+ if (dbmp->di_size >= 0) {
+ dbmp->di_size--;
+ }
+
+ return rb_assoc_new(keystr, valstr);
+}
+
+/*
+ * call-seq:
+ * sdbm.delete_if { |key, value| ... } -> self
+ * sdbm.reject! { |key, value| ... } -> self
+ *
+ * Iterates over the key-value pairs in the database, deleting those for
+ * which the block returns +true+.
+ */
+static VALUE
+fsdbm_delete_if(VALUE obj)
+{
+ datum key, val;
+ struct dbmdata *dbmp;
+ DBM *dbm;
+ VALUE keystr, valstr;
+ VALUE ret, ary = rb_ary_new();
+ int i, status = 0, n;
+
+ fdbm_modify(obj);
+ GetDBM2(obj, dbmp, dbm);
+ n = dbmp->di_size;
+ dbmp->di_size = -1;
+ for (key = sdbm_firstkey(dbm); key.dptr; key = sdbm_nextkey(dbm)) {
+ val = sdbm_fetch(dbm, key);
+ keystr = rb_external_str_new(key.dptr, key.dsize);
+ valstr = rb_external_str_new(val.dptr, val.dsize);
+ ret = rb_protect(rb_yield, rb_assoc_new(rb_str_dup(keystr), valstr), &status);
+ if (status != 0) break;
+ if (RTEST(ret)) rb_ary_push(ary, keystr);
+ GetDBM2(obj, dbmp, dbm);
+ }
+
+ for (i = 0; i < RARRAY_LEN(ary); i++) {
+ keystr = RARRAY_PTR(ary)[i];
+ ExportStringValue(keystr);
+ key.dptr = RSTRING_PTR(keystr);
+ key.dsize = RSTRING_LENINT(keystr);
+ if (sdbm_delete(dbm, key)) {
+ rb_raise(rb_eDBMError, "sdbm_delete failed");
+ }
+ }
+ if (status) rb_jump_tag(status);
+ if (n > 0) dbmp->di_size = n - RARRAY_LENINT(ary);
+
+ return obj;
+}
+
+/*
+ * call-seq:
+ * sdbm.clear -> self
+ *
+ * Deletes all data from the database.
+ */
+static VALUE
+fsdbm_clear(VALUE obj)
+{
+ datum key;
+ struct dbmdata *dbmp;
+ DBM *dbm;
+
+ fdbm_modify(obj);
+ GetDBM2(obj, dbmp, dbm);
+ dbmp->di_size = -1;
+ while (key = sdbm_firstkey(dbm), key.dptr) {
+ if (sdbm_delete(dbm, key)) {
+ rb_raise(rb_eDBMError, "sdbm_delete failed");
+ }
+ }
+ dbmp->di_size = 0;
+
+ return obj;
+}
+
+/*
+ * call-seq:
+ * sdbm.invert -> Hash
+ *
+ * Returns a Hash in which the key-value pairs have been inverted.
+ *
+ * Example:
+ *
+ * require 'sdbm'
+ *
+ * SDBM.open 'my_database' do |db|
+ * db.update('apple' => 'fruit', 'spinach' => 'vegetable')
+ *
+ * db.invert #=> {"fruit" => "apple", "vegetable" => "spinach"}
+ * end
+ */
+static VALUE
+fsdbm_invert(VALUE obj)
+{
+ datum key, val;
+ struct dbmdata *dbmp;
+ DBM *dbm;
+ VALUE keystr, valstr;
+ VALUE hash = rb_hash_new();
+
+ GetDBM2(obj, dbmp, dbm);
+ for (key = sdbm_firstkey(dbm); key.dptr; key = sdbm_nextkey(dbm)) {
+ val = sdbm_fetch(dbm, key);
+ keystr = rb_external_str_new(key.dptr, key.dsize);
+ valstr = rb_external_str_new(val.dptr, val.dsize);
+ rb_hash_aset(hash, valstr, keystr);
+ }
+ return hash;
+}
+
+/*
+ * call-seq:
+ * sdbm[key] = value -> value
+ * sdbm.store(key, value) -> value
+ *
+ * Stores a new +value+ in the database with the given +key+ as an index.
+ *
+ * If the +key+ already exists, this will update the +value+ associated with
+ * the +key+.
+ *
+ * Returns the given +value+.
+ */
+static VALUE
+fsdbm_store(VALUE obj, VALUE keystr, VALUE valstr)
+{
+ datum key, val;
+ struct dbmdata *dbmp;
+ DBM *dbm;
+
+ if (valstr == Qnil) {
+ fsdbm_delete(obj, keystr);
+ return Qnil;
+ }
+
+ fdbm_modify(obj);
+ ExportStringValue(keystr);
+ ExportStringValue(valstr);
+
+ key.dptr = RSTRING_PTR(keystr);
+ key.dsize = RSTRING_LENINT(keystr);
+
+ val.dptr = RSTRING_PTR(valstr);
+ val.dsize = RSTRING_LENINT(valstr);
+
+ GetDBM2(obj, dbmp, dbm);
+ dbmp->di_size = -1;
+ if (sdbm_store(dbm, key, val, DBM_REPLACE)) {
+#ifdef HAVE_DBM_CLAERERR
+ sdbm_clearerr(dbm);
+#endif
+ if (errno == EPERM) rb_sys_fail(0);
+ rb_raise(rb_eDBMError, "sdbm_store failed");
+ }
+
+ return valstr;
+}
+
+static VALUE
+update_i(RB_BLOCK_CALL_FUNC_ARGLIST(pair, dbm))
+{
+ Check_Type(pair, T_ARRAY);
+ if (RARRAY_LEN(pair) < 2) {
+ rb_raise(rb_eArgError, "pair must be [key, value]");
+ }
+ fsdbm_store(dbm, RARRAY_PTR(pair)[0], RARRAY_PTR(pair)[1]);
+ return Qnil;
+}
+
+/*
+ * call-seq:
+ * sdbm.update(pairs) -> self
+ *
+ * Insert or update key-value pairs.
+ *
+ * This method will work with any object which implements an each_pair
+ * method, such as a Hash.
+ */
+static VALUE
+fsdbm_update(VALUE obj, VALUE other)
+{
+ rb_block_call(other, rb_intern("each_pair"), 0, 0, update_i, obj);
+ return obj;
+}
+
+/*
+ * call-seq:
+ * sdbm.replace(pairs) -> self
+ *
+ * Empties the database, then inserts the given key-value pairs.
+ *
+ * This method will work with any object which implements an each_pair
+ * method, such as a Hash.
+ */
+static VALUE
+fsdbm_replace(VALUE obj, VALUE other)
+{
+ fsdbm_clear(obj);
+ rb_block_call(other, rb_intern("each_pair"), 0, 0, update_i, obj);
+ return obj;
+}
+
+/*
+ * call-seq:
+ * sdbm.length -> integer
+ * sdbm.size -> integer
+ *
+ * Returns the number of keys in the database.
+ */
+static VALUE
+fsdbm_length(VALUE obj)
+{
+ datum key;
+ struct dbmdata *dbmp;
+ DBM *dbm;
+ int i = 0;
+
+ GetDBM2(obj, dbmp, dbm);
+ if (dbmp->di_size > 0) return INT2FIX(dbmp->di_size);
+
+ for (key = sdbm_firstkey(dbm); key.dptr; key = sdbm_nextkey(dbm)) {
+ i++;
+ }
+ dbmp->di_size = i;
+
+ return INT2FIX(i);
+}
+
+/*
+ * call-seq:
+ * sdbm.empty? -> true or false
+ *
+ * Returns +true+ if the database is empty.
+ */
+static VALUE
+fsdbm_empty_p(VALUE obj)
+{
+ datum key;
+ struct dbmdata *dbmp;
+ DBM *dbm;
+
+ GetDBM(obj, dbmp);
+ if (dbmp->di_size < 0) {
+ dbm = dbmp->di_dbm;
+
+ for (key = sdbm_firstkey(dbm); key.dptr; key = sdbm_nextkey(dbm)) {
+ return Qfalse;
+ }
+ }
+ else {
+ if (dbmp->di_size)
+ return Qfalse;
+ }
+ return Qtrue;
+}
+
+/*
+ * call-seq:
+ * sdbm.each_value
+ * sdbm.each_value { |value| ... }
+ *
+ * Iterates over each +value+ in the database.
+ *
+ * If no block is given, returns an Enumerator.
+ */
+static VALUE
+fsdbm_each_value(VALUE obj)
+{
+ datum key, val;
+ struct dbmdata *dbmp;
+ DBM *dbm;
+
+ RETURN_ENUMERATOR(obj, 0, 0);
+
+ GetDBM2(obj, dbmp, dbm);
+ for (key = sdbm_firstkey(dbm); key.dptr; key = sdbm_nextkey(dbm)) {
+ val = sdbm_fetch(dbm, key);
+ rb_yield(rb_external_str_new(val.dptr, val.dsize));
+ GetDBM2(obj, dbmp, dbm);
+ }
+ return obj;
+}
+
+/*
+ * call-seq:
+ * sdbm.each_key
+ * sdbm.each_key { |key| ... }
+ *
+ * Iterates over each +key+ in the database.
+ *
+ * If no block is given, returns an Enumerator.
+ */
+static VALUE
+fsdbm_each_key(VALUE obj)
+{
+ datum key;
+ struct dbmdata *dbmp;
+ DBM *dbm;
+
+ RETURN_ENUMERATOR(obj, 0, 0);
+
+ GetDBM2(obj, dbmp, dbm);
+ for (key = sdbm_firstkey(dbm); key.dptr; key = sdbm_nextkey(dbm)) {
+ rb_yield(rb_external_str_new(key.dptr, key.dsize));
+ GetDBM2(obj, dbmp, dbm);
+ }
+ return obj;
+}
+
+/*
+ * call-seq:
+ * sdbm.each
+ * sdbm.each { |key, value| ... }
+ * sdbm.each_pair
+ * sdbm.each_pair { |key, value| ... }
+ *
+ * Iterates over each key-value pair in the database.
+ *
+ * If no block is given, returns an Enumerator.
+ */
+static VALUE
+fsdbm_each_pair(VALUE obj)
+{
+ datum key, val;
+ DBM *dbm;
+ struct dbmdata *dbmp;
+ VALUE keystr, valstr;
+
+ RETURN_ENUMERATOR(obj, 0, 0);
+
+ GetDBM2(obj, dbmp, dbm);
+ for (key = sdbm_firstkey(dbm); key.dptr; key = sdbm_nextkey(dbm)) {
+ val = sdbm_fetch(dbm, key);
+ keystr = rb_external_str_new(key.dptr, key.dsize);
+ valstr = rb_external_str_new(val.dptr, val.dsize);
+ rb_yield(rb_assoc_new(keystr, valstr));
+ GetDBM2(obj, dbmp, dbm);
+ }
+
+ return obj;
+}
+
+/*
+ * call-seq:
+ * sdbm.keys -> Array
+ *
+ * Returns a new Array containing the keys in the database.
+ */
+static VALUE
+fsdbm_keys(VALUE obj)
+{
+ datum key;
+ struct dbmdata *dbmp;
+ DBM *dbm;
+ VALUE ary;
+
+ GetDBM2(obj, dbmp, dbm);
+ ary = rb_ary_new();
+ for (key = sdbm_firstkey(dbm); key.dptr; key = sdbm_nextkey(dbm)) {
+ rb_ary_push(ary, rb_external_str_new(key.dptr, key.dsize));
+ }
+
+ return ary;
+}
+
+/*
+ * call-seq:
+ * sdbm.values -> Array
+ *
+ * Returns a new Array containing the values in the database.
+ */
+static VALUE
+fsdbm_values(VALUE obj)
+{
+ datum key, val;
+ struct dbmdata *dbmp;
+ DBM *dbm;
+ VALUE ary;
+
+ GetDBM2(obj, dbmp, dbm);
+ ary = rb_ary_new();
+ for (key = sdbm_firstkey(dbm); key.dptr; key = sdbm_nextkey(dbm)) {
+ val = sdbm_fetch(dbm, key);
+ rb_ary_push(ary, rb_external_str_new(val.dptr, val.dsize));
+ }
+
+ return ary;
+}
+
+/*
+ * call-seq:
+ * sdbm.include?(key) -> true or false
+ * sdbm.key?(key) -> true or false
+ * sdbm.member?(key) -> true or false
+ * sdbm.has_key?(key) -> true or false
+ *
+ * Returns +true+ if the database contains the given +key+.
+ */
+static VALUE
+fsdbm_has_key(VALUE obj, VALUE keystr)
+{
+ datum key, val;
+ struct dbmdata *dbmp;
+ DBM *dbm;
+
+ ExportStringValue(keystr);
+ key.dptr = RSTRING_PTR(keystr);
+ key.dsize = RSTRING_LENINT(keystr);
+
+ GetDBM2(obj, dbmp, dbm);
+ val = sdbm_fetch(dbm, key);
+ if (val.dptr) return Qtrue;
+ return Qfalse;
+}
+
+/*
+ * call-seq:
+ * sdbm.value?(key) -> true or false
+ * sdbm.has_value?(key) -> true or false
+ *
+ * Returns +true+ if the database contains the given +value+.
+ */
+static VALUE
+fsdbm_has_value(VALUE obj, VALUE valstr)
+{
+ datum key, val;
+ struct dbmdata *dbmp;
+ DBM *dbm;
+
+ ExportStringValue(valstr);
+ val.dptr = RSTRING_PTR(valstr);
+ val.dsize = RSTRING_LENINT(valstr);
+
+ GetDBM2(obj, dbmp, dbm);
+ for (key = sdbm_firstkey(dbm); key.dptr; key = sdbm_nextkey(dbm)) {
+ val = sdbm_fetch(dbm, key);
+ if (val.dsize == RSTRING_LENINT(valstr) &&
+ memcmp(val.dptr, RSTRING_PTR(valstr), val.dsize) == 0)
+ return Qtrue;
+ }
+ return Qfalse;
+}
+
+/*
+ * call-seq:
+ * sdbm.to_a -> Array
+ *
+ * Returns a new Array containing each key-value pair in the database.
+ *
+ * Example:
+ *
+ * require 'sdbm'
+ *
+ * SDBM.open 'my_database' do |db|
+ * db.update('apple' => 'fruit', 'spinach' => 'vegetable')
+ *
+ * db.to_a #=> [["apple", "fruit"], ["spinach", "vegetable"]]
+ * end
+ */
+static VALUE
+fsdbm_to_a(VALUE obj)
+{
+ datum key, val;
+ struct dbmdata *dbmp;
+ DBM *dbm;
+ VALUE ary;
+
+ GetDBM2(obj, dbmp, dbm);
+ ary = rb_ary_new();
+ for (key = sdbm_firstkey(dbm); key.dptr; key = sdbm_nextkey(dbm)) {
+ val = sdbm_fetch(dbm, key);
+ rb_ary_push(ary, rb_assoc_new(rb_external_str_new(key.dptr, key.dsize),
+ rb_external_str_new(val.dptr, val.dsize)));
+ }
+
+ return ary;
+}
+
+/*
+ * call-seq:
+ * sdbm.to_hash -> Hash
+ *
+ * Returns a new Hash containing each key-value pair in the database.
+ */
+static VALUE
+fsdbm_to_hash(VALUE obj)
+{
+ datum key, val;
+ struct dbmdata *dbmp;
+ DBM *dbm;
+ VALUE hash;
+
+ GetDBM2(obj, dbmp, dbm);
+ hash = rb_hash_new();
+ for (key = sdbm_firstkey(dbm); key.dptr; key = sdbm_nextkey(dbm)) {
+ val = sdbm_fetch(dbm, key);
+ rb_hash_aset(hash, rb_external_str_new(key.dptr, key.dsize),
+ rb_external_str_new(val.dptr, val.dsize));
+ }
+
+ return hash;
+}
+
+/*
+ * call-seq:
+ * sdbm.reject { |key, value| ... } -> Hash
+ *
+ * Creates a new Hash using the key-value pairs from the database, then
+ * calls Hash#reject with the given block, which returns a Hash with
+ * only the key-value pairs for which the block returns +false+.
+ */
+static VALUE
+fsdbm_reject(VALUE obj)
+{
+ return rb_hash_delete_if(fsdbm_to_hash(obj));
+}
+
+void
+Init_sdbm(void)
+{
+ rb_cDBM = rb_define_class("SDBM", rb_cObject);
+ rb_eDBMError = rb_define_class("SDBMError", rb_eStandardError);
+ /* Document-class: SDBMError
+ * Exception class used to return errors from the sdbm library.
+ */
+ rb_include_module(rb_cDBM, rb_mEnumerable);
+
+ rb_define_alloc_func(rb_cDBM, fsdbm_alloc);
+ rb_define_singleton_method(rb_cDBM, "open", fsdbm_s_open, -1);
+
+ rb_define_method(rb_cDBM, "initialize", fsdbm_initialize, -1);
+ rb_define_method(rb_cDBM, "close", fsdbm_close, 0);
+ rb_define_method(rb_cDBM, "closed?", fsdbm_closed, 0);
+ rb_define_method(rb_cDBM, "[]", fsdbm_aref, 1);
+ rb_define_method(rb_cDBM, "fetch", fsdbm_fetch_m, -1);
+ rb_define_method(rb_cDBM, "[]=", fsdbm_store, 2);
+ rb_define_method(rb_cDBM, "store", fsdbm_store, 2);
+ rb_define_method(rb_cDBM, "index", fsdbm_index, 1);
+ rb_define_method(rb_cDBM, "key", fsdbm_key, 1);
+ rb_define_method(rb_cDBM, "select", fsdbm_select, 0);
+ rb_define_method(rb_cDBM, "values_at", fsdbm_values_at, -1);
+ rb_define_method(rb_cDBM, "length", fsdbm_length, 0);
+ rb_define_method(rb_cDBM, "size", fsdbm_length, 0);
+ rb_define_method(rb_cDBM, "empty?", fsdbm_empty_p, 0);
+ rb_define_method(rb_cDBM, "each", fsdbm_each_pair, 0);
+ rb_define_method(rb_cDBM, "each_value", fsdbm_each_value, 0);
+ rb_define_method(rb_cDBM, "each_key", fsdbm_each_key, 0);
+ rb_define_method(rb_cDBM, "each_pair", fsdbm_each_pair, 0);
+ rb_define_method(rb_cDBM, "keys", fsdbm_keys, 0);
+ rb_define_method(rb_cDBM, "values", fsdbm_values, 0);
+ rb_define_method(rb_cDBM, "shift", fsdbm_shift, 0);
+ rb_define_method(rb_cDBM, "delete", fsdbm_delete, 1);
+ rb_define_method(rb_cDBM, "delete_if", fsdbm_delete_if, 0);
+ rb_define_method(rb_cDBM, "reject!", fsdbm_delete_if, 0);
+ rb_define_method(rb_cDBM, "reject", fsdbm_reject, 0);
+ rb_define_method(rb_cDBM, "clear", fsdbm_clear, 0);
+ rb_define_method(rb_cDBM,"invert", fsdbm_invert, 0);
+ rb_define_method(rb_cDBM,"update", fsdbm_update, 1);
+ rb_define_method(rb_cDBM,"replace", fsdbm_replace, 1);
+
+ rb_define_method(rb_cDBM, "has_key?", fsdbm_has_key, 1);
+ rb_define_method(rb_cDBM, "include?", fsdbm_has_key, 1);
+ rb_define_method(rb_cDBM, "key?", fsdbm_has_key, 1);
+ rb_define_method(rb_cDBM, "member?", fsdbm_has_key, 1);
+ rb_define_method(rb_cDBM, "has_value?", fsdbm_has_value, 1);
+ rb_define_method(rb_cDBM, "value?", fsdbm_has_value, 1);
+
+ rb_define_method(rb_cDBM, "to_a", fsdbm_to_a, 0);
+ rb_define_method(rb_cDBM, "to_hash", fsdbm_to_hash, 0);
+}
diff --git a/jni/ruby/ext/sdbm/sdbm.h b/jni/ruby/ext/sdbm/sdbm.h
new file mode 100644
index 0000000..c3b53c4
--- /dev/null
+++ b/jni/ruby/ext/sdbm/sdbm.h
@@ -0,0 +1,86 @@
+/*
+ * sdbm - ndbm work-alike hashed database library
+ * based on Per-Ake Larson's Dynamic Hashing algorithms. BIT 18 (1978).
+ * author: oz@nexus.yorku.ca
+ * status: public domain.
+ */
+#ifndef _SDBM_H_
+#define _SDBM_H_
+
+#include <stdio.h>
+
+#define DBLKSIZ 4096
+#define PBLKSIZ 1024
+#define PAIRMAX 1008 /* arbitrary on PBLKSIZ-N */
+#define SPLTMAX 10 /* maximum allowed splits */
+ /* for a single insertion */
+#define DIRFEXT ".dir"
+#define PAGFEXT ".pag"
+
+typedef struct {
+ int dirf; /* directory file descriptor */
+ int pagf; /* page file descriptor */
+ int flags; /* status/error flags, see below */
+ int keyptr; /* current key for nextkey */
+ off_t maxbno; /* size of dirfile in bits */
+ long curbit; /* current bit number */
+ long hmask; /* current hash mask */
+ long blkptr; /* current block for nextkey */
+ long blkno; /* current page to read/write */
+ long pagbno; /* current page in pagbuf */
+ char pagbuf[PBLKSIZ]; /* page file block buffer */
+ long dirbno; /* current block in dirbuf */
+ char dirbuf[DBLKSIZ]; /* directory file block buffer */
+} DBM;
+
+#define DBM_RDONLY 0x1 /* data base open read-only */
+#define DBM_IOERR 0x2 /* data base I/O error */
+
+/*
+ * utility macros
+ */
+#define sdbm_rdonly(db) ((db)->flags & DBM_RDONLY)
+#define sdbm_error(db) ((db)->flags & DBM_IOERR)
+
+#define sdbm_clearerr(db) ((db)->flags &= ~DBM_IOERR) /* ouch */
+
+#define sdbm_dirfno(db) ((db)->dirf)
+#define sdbm_pagfno(db) ((db)->pagf)
+
+typedef struct {
+ char *dptr;
+ int dsize;
+} datum;
+
+extern datum nullitem;
+
+#if defined(__STDC__)
+#define proto(p) p
+#else
+#define proto(p) ()
+#endif
+
+/*
+ * flags to sdbm_store
+ */
+#define DBM_INSERT 0
+#define DBM_REPLACE 1
+
+/*
+ * ndbm interface
+ */
+extern DBM *sdbm_open proto((char *, int, int));
+extern void sdbm_close proto((DBM *));
+extern datum sdbm_fetch proto((DBM *, datum));
+extern int sdbm_delete proto((DBM *, datum));
+extern int sdbm_store proto((DBM *, datum, datum, int));
+extern datum sdbm_firstkey proto((DBM *));
+extern datum sdbm_nextkey proto((DBM *));
+
+/*
+ * other
+ */
+extern DBM *sdbm_prep proto((char *, char *, int, int));
+extern long sdbm_hash proto((char *, int));
+
+#endif /* _SDBM_H_ */
diff --git a/jni/ruby/ext/socket/.document b/jni/ruby/ext/socket/.document
new file mode 100644
index 0000000..53cfac0
--- /dev/null
+++ b/jni/ruby/ext/socket/.document
@@ -0,0 +1,17 @@
+ancdata.c
+basicsocket.c
+constants.c
+constdefs.c
+ifaddr.c
+init.c
+ipsocket.c
+option.c
+raddrinfo.c
+socket.c
+sockssocket.c
+tcpserver.c
+tcpsocket.c
+udpsocket.c
+unixserver.c
+unixsocket.c
+lib
diff --git a/jni/ruby/ext/socket/Makefile b/jni/ruby/ext/socket/Makefile
new file mode 100644
index 0000000..4d4d6eb
--- /dev/null
+++ b/jni/ruby/ext/socket/Makefile
@@ -0,0 +1,571 @@
+
+SHELL = /bin/sh
+
+# V=0 quiet, V=1 verbose. other values don't work.
+V = 0
+Q1 = $(V:1=)
+Q = $(Q1:0=@)
+ECHO1 = $(V:1=@:)
+ECHO = $(ECHO1:0=@echo)
+NULLCMD = :
+
+#### Start of system configuration section. ####
+top_srcdir = $(topdir)/.
+srcdir = $(top_srcdir)/ext/socket
+topdir = ../..
+hdrdir = $(top_srcdir)/include
+arch_hdrdir = $(extout)/include/$(arch)
+PATH_SEPARATOR = :
+VPATH = $(srcdir):$(arch_hdrdir)/ruby:$(hdrdir)/ruby
+RUBYLIB =
+RUBYOPT = -
+prefix = $(DESTDIR)/usr/local
+rubysitearchprefix = $(rubylibprefix)/$(sitearch)
+rubyarchprefix = $(rubylibprefix)/$(arch)
+rubylibprefix = $(libdir)/$(RUBY_BASE_NAME)
+exec_prefix = $(prefix)
+vendorarchhdrdir = $(vendorhdrdir)/$(sitearch)
+sitearchhdrdir = $(sitehdrdir)/$(sitearch)
+rubyarchhdrdir = $(rubyhdrdir)/$(arch)
+vendorhdrdir = $(rubyhdrdir)/vendor_ruby
+sitehdrdir = $(rubyhdrdir)/site_ruby
+rubyhdrdir = $(includedir)/$(RUBY_VERSION_NAME)
+vendorarchdir = $(vendorlibdir)/$(sitearch)
+vendorlibdir = $(vendordir)/$(ruby_version)
+vendordir = $(rubylibprefix)/vendor_ruby
+sitearchdir = $(sitelibdir)/$(sitearch)
+sitelibdir = $(sitedir)/$(ruby_version)
+sitedir = $(rubylibprefix)/site_ruby
+rubyarchdir = $(rubylibdir)/$(arch)
+rubylibdir = $(rubylibprefix)/$(ruby_version)
+sitearchincludedir = $(includedir)/$(sitearch)
+archincludedir = $(includedir)/$(arch)
+sitearchlibdir = $(libdir)/$(sitearch)
+archlibdir = $(libdir)/$(arch)
+ridir = $(datarootdir)/$(RI_BASE_NAME)
+mandir = $(datarootdir)/man
+localedir = $(datarootdir)/locale
+libdir = $(exec_prefix)/lib
+psdir = $(docdir)
+pdfdir = $(docdir)
+dvidir = $(docdir)
+htmldir = $(docdir)
+infodir = $(datarootdir)/info
+docdir = $(datarootdir)/doc/$(PACKAGE)
+oldincludedir = $(DESTDIR)/usr/include
+includedir = $(prefix)/include
+localstatedir = $(prefix)/var
+sharedstatedir = $(prefix)/com
+sysconfdir = $(prefix)/etc
+datadir = $(datarootdir)
+datarootdir = $(prefix)/share
+libexecdir = $(exec_prefix)/libexec
+sbindir = $(exec_prefix)/sbin
+bindir = $(exec_prefix)/bin
+archdir = $(rubyarchdir)
+
+
+CC = gcc
+CXX = g++
+LIBRUBY = $(LIBRUBY_SO)
+LIBRUBY_A = lib$(RUBY_SO_NAME)-static.a
+LIBRUBYARG_SHARED = -Wl,-R$(libdir) -L$(libdir) -l$(RUBY_SO_NAME)
+LIBRUBYARG_STATIC = -Wl,-R$(libdir) -L$(libdir) -l$(RUBY_SO_NAME)-static
+empty =
+OUTFLAG = -o $(empty)
+COUTFLAG = -o $(empty)
+
+RUBY_EXTCONF_H = extconf.h
+cflags = $(optflags) $(debugflags) $(warnflags)
+optflags = -O3 -fno-fast-math
+debugflags = -ggdb3
+warnflags = -Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wunused-variable -Wpointer-arith -Wwrite-strings -Wdeclaration-after-statement -Wimplicit-function-declaration -Wdeprecated-declarations -Wno-packed-bitfield-compat
+CCDLFLAGS = -fPIC
+CFLAGS = $(CCDLFLAGS) $(cflags) -fPIC $(ARCH_FLAG)
+INCFLAGS = -I. -I$(arch_hdrdir) -I$(hdrdir) -I$(srcdir) -I$(topdir) -I$(top_srcdir)
+DEFS =
+CPPFLAGS = -DRUBY_EXTCONF_H=\"$(RUBY_EXTCONF_H)\" $(DEFS) $(cppflags)
+CXXFLAGS = $(CCDLFLAGS) $(cxxflags) $(ARCH_FLAG)
+ldflags = -L. -fstack-protector -rdynamic -Wl,-export-dynamic
+dldflags =
+ARCH_FLAG =
+DLDFLAGS = $(ldflags) $(dldflags) $(ARCH_FLAG)
+LDSHARED = $(CC) -shared
+LDSHAREDXX = $(CXX) -shared
+AR = ar
+EXEEXT =
+
+RUBY_INSTALL_NAME = $(RUBY_BASE_NAME)
+RUBY_SO_NAME = ruby
+RUBYW_INSTALL_NAME =
+RUBY_VERSION_NAME = $(RUBY_BASE_NAME)-$(ruby_version)
+RUBYW_BASE_NAME = rubyw
+RUBY_BASE_NAME = ruby
+
+arch = x86_64-linux
+sitearch = $(arch)
+ruby_version = 2.2.0
+ruby = $(topdir)/miniruby -I'$(topdir)' -I'$(top_srcdir)/lib' -I'$(extout)/$(arch)' -I'$(extout)/common'
+RUBY = $(ruby)
+ruby_headers = $(hdrdir)/ruby.h $(hdrdir)/ruby/ruby.h $(hdrdir)/ruby/defines.h $(hdrdir)/ruby/missing.h $(hdrdir)/ruby/intern.h $(hdrdir)/ruby/st.h $(hdrdir)/ruby/subst.h $(arch_hdrdir)/ruby/config.h $(RUBY_EXTCONF_H)
+
+RM = rm -f
+RM_RF = $(RUBY) -run -e rm -- -rf
+RMDIRS = rmdir --ignore-fail-on-non-empty -p
+MAKEDIRS = /bin/mkdir -p
+INSTALL = /usr/bin/install -c
+INSTALL_PROG = $(INSTALL) -m 0755
+INSTALL_DATA = $(INSTALL) -m 644
+COPY = cp
+TOUCH = exit >
+
+#### End of system configuration section. ####
+
+preload =
+
+libpath = . $(topdir)
+LIBPATH = -L. -L$(topdir)
+DEFFILE =
+
+CLEANFILES = mkmf.log
+DISTCLEANFILES = constants.h constdefs.*
+DISTCLEANDIRS =
+
+extout = $(topdir)/.ext
+extout_prefix = $(extout)$(target_prefix)/
+target_prefix =
+LOCAL_LIBS =
+LIBS = $(LIBRUBYARG_SHARED) -lpthread -lgmp -ldl -lcrypt -lm -lc
+ORIG_SRCS = unixsocket.c constdefs.c basicsocket.c getaddrinfo.c sockssocket.c option.c tcpserver.c ifaddr.c constants.c socket.c init.c getnameinfo.c udpsocket.c ipsocket.c ancdata.c unixserver.c tcpsocket.c raddrinfo.c
+SRCS = $(ORIG_SRCS) init.c constants.c basicsocket.c socket.c ipsocket.c tcpsocket.c tcpserver.c sockssocket.c udpsocket.c unixsocket.c unixserver.c option.c ancdata.c raddrinfo.c ifaddr.c
+OBJS = init.o constants.o basicsocket.o socket.o ipsocket.o tcpsocket.o tcpserver.o sockssocket.o udpsocket.o unixsocket.o unixserver.o option.o ancdata.o raddrinfo.o ifaddr.o
+HDRS = $(srcdir)/addrinfo.h $(srcdir)/sockport.h $(srcdir)/extconf.h $(srcdir)/constdefs.h $(srcdir)/rubysocket.h
+TARGET = socket
+TARGET_NAME = socket
+TARGET_ENTRY = Init_$(TARGET_NAME)
+DLLIB = $(TARGET).so
+EXTSTATIC =
+STATIC_LIB =
+
+TIMESTAMP_DIR = $(extout)/.timestamp
+BINDIR = $(extout)/bin
+RUBYCOMMONDIR = $(extout)/common
+RUBYLIBDIR = $(RUBYCOMMONDIR)$(target_prefix)
+RUBYARCHDIR = $(extout)/$(arch)$(target_prefix)
+HDRDIR = $(extout)/include/ruby$(target_prefix)
+ARCHHDRDIR = $(extout)/include/$(arch)/ruby$(target_prefix)
+
+TARGET_SO = $(RUBYARCHDIR)/$(DLLIB)
+CLEANLIBS = $(RUBYARCHDIR)/$(TARGET).so
+CLEANOBJS = *.o *.bak
+
+all: install
+static: all
+.PHONY: all install static install-so install-rb
+.PHONY: clean clean-so clean-static clean-rb
+
+clean-static::
+clean-rb-default::
+clean-rb::
+clean-so::
+clean: clean-so clean-static clean-rb-default clean-rb
+ -$(Q)$(RM) $(CLEANLIBS) $(CLEANOBJS) $(CLEANFILES) .*.time
+
+distclean-rb-default::
+distclean-rb::
+distclean-so::
+distclean-static::
+distclean: clean distclean-so distclean-static distclean-rb-default distclean-rb
+ -$(Q)$(RM) Makefile $(RUBY_EXTCONF_H) conftest.* mkmf.log
+ -$(Q)$(RM) core ruby$(EXEEXT) *~ $(DISTCLEANFILES)
+ -$(Q)$(RMDIRS) $(DISTCLEANDIRS) 2> /dev/null || true
+
+realclean: distclean
+install: install-so install-rb
+
+install-so: $(RUBYARCHDIR)/$(DLLIB)
+clean-so::
+ -$(Q)$(RM) $(RUBYARCHDIR)/$(DLLIB)
+ -$(Q)$(RMDIRS) $(RUBYARCHDIR) 2> /dev/null || true
+clean-static::
+ -$(Q)$(RM) $(STATIC_LIB)
+install-rb: pre-install-rb install-rb-default
+install-rb-default: pre-install-rb-default
+pre-install-rb: Makefile
+pre-install-rb-default: Makefile
+pre-install-rb-default: $(TIMESTAMP_DIR)/.RUBYLIBDIR.time
+install-rb-default: $(RUBYLIBDIR)/socket.rb
+$(RUBYLIBDIR)/socket.rb: $(srcdir)/lib/socket.rb $(TIMESTAMP_DIR)/.RUBYLIBDIR.time
+ $(Q) $(COPY) $(srcdir)/lib/socket.rb $(@D)
+clean-rb-default::
+ -$(Q)$(RM) $(RUBYLIBDIR)/socket.rb
+pre-install-rb-default:
+ $(ECHO) installing default socket libraries
+clean-rb-default::
+ -$(Q)$(RMDIRS) $(RUBYLIBDIR) 2> /dev/null || true
+$(TIMESTAMP_DIR)/.RUBYARCHDIR.time:
+ $(Q) $(MAKEDIRS) $(@D) $(RUBYARCHDIR)
+ $(Q) $(TOUCH) $@
+$(TIMESTAMP_DIR)/.RUBYLIBDIR.time:
+ $(Q) $(MAKEDIRS) $(@D) $(RUBYLIBDIR)
+ $(Q) $(TOUCH) $@
+
+site-install: site-install-so site-install-rb
+site-install-so: install-so
+site-install-rb: install-rb
+
+.SUFFIXES: .c .m .cc .mm .cxx .cpp .o .S
+
+.cc.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<
+
+.cc.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -S $<
+
+.mm.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<
+
+.mm.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -S $<
+
+.cxx.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<
+
+.cxx.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -S $<
+
+.cpp.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<
+
+.cpp.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -S $<
+
+.c.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -c $<
+
+.c.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -S $<
+
+.m.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -c $<
+
+.m.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -S $<
+
+$(RUBYARCHDIR)/$(DLLIB): $(OBJS) Makefile $(TIMESTAMP_DIR)/.RUBYARCHDIR.time
+ $(ECHO) linking shared-object $(DLLIB)
+ -$(Q)$(RM) $(@)
+ $(Q) $(LDSHARED) -o $@ $(OBJS) $(LIBPATH) $(DLDFLAGS) $(LOCAL_LIBS) $(LIBS)
+
+
+
+###
+$(OBJS): $(RUBY_EXTCONF_H)
+
+getnameinfo.o: getnameinfo.c $(arch_hdrdir)/ruby/config.h addrinfo.h sockport.h
+getaddrinfo.o: getaddrinfo.c $(arch_hdrdir)/ruby/config.h addrinfo.h sockport.h
+
+constdefs.h constdefs.c : $(srcdir)/mkconstants.rb
+ @echo "generating constant definitions"
+ @$(RUBY) $(srcdir)/mkconstants.rb -H constdefs.h -o constdefs.c
+
+# AUTOGENERATED DEPENDENCIES START
+ancdata.o: $(RUBY_EXTCONF_H)
+ancdata.o: $(arch_hdrdir)/ruby/config.h
+ancdata.o: $(hdrdir)/ruby/defines.h
+ancdata.o: $(hdrdir)/ruby/encoding.h
+ancdata.o: $(hdrdir)/ruby/intern.h
+ancdata.o: $(hdrdir)/ruby/io.h
+ancdata.o: $(hdrdir)/ruby/missing.h
+ancdata.o: $(hdrdir)/ruby/oniguruma.h
+ancdata.o: $(hdrdir)/ruby/ruby.h
+ancdata.o: $(hdrdir)/ruby/st.h
+ancdata.o: $(hdrdir)/ruby/subst.h
+ancdata.o: $(hdrdir)/ruby/thread.h
+ancdata.o: $(hdrdir)/ruby/util.h
+ancdata.o: $(top_srcdir)/include/ruby.h
+ancdata.o: $(top_srcdir)/internal.h
+ancdata.o: ancdata.c
+ancdata.o: constdefs.h
+ancdata.o: rubysocket.h
+ancdata.o: sockport.h
+basicsocket.o: $(RUBY_EXTCONF_H)
+basicsocket.o: $(arch_hdrdir)/ruby/config.h
+basicsocket.o: $(hdrdir)/ruby/defines.h
+basicsocket.o: $(hdrdir)/ruby/encoding.h
+basicsocket.o: $(hdrdir)/ruby/intern.h
+basicsocket.o: $(hdrdir)/ruby/io.h
+basicsocket.o: $(hdrdir)/ruby/missing.h
+basicsocket.o: $(hdrdir)/ruby/oniguruma.h
+basicsocket.o: $(hdrdir)/ruby/ruby.h
+basicsocket.o: $(hdrdir)/ruby/st.h
+basicsocket.o: $(hdrdir)/ruby/subst.h
+basicsocket.o: $(hdrdir)/ruby/thread.h
+basicsocket.o: $(hdrdir)/ruby/util.h
+basicsocket.o: $(top_srcdir)/include/ruby.h
+basicsocket.o: $(top_srcdir)/internal.h
+basicsocket.o: basicsocket.c
+basicsocket.o: constdefs.h
+basicsocket.o: rubysocket.h
+basicsocket.o: sockport.h
+constants.o: $(RUBY_EXTCONF_H)
+constants.o: $(arch_hdrdir)/ruby/config.h
+constants.o: $(hdrdir)/ruby/defines.h
+constants.o: $(hdrdir)/ruby/encoding.h
+constants.o: $(hdrdir)/ruby/intern.h
+constants.o: $(hdrdir)/ruby/io.h
+constants.o: $(hdrdir)/ruby/missing.h
+constants.o: $(hdrdir)/ruby/oniguruma.h
+constants.o: $(hdrdir)/ruby/ruby.h
+constants.o: $(hdrdir)/ruby/st.h
+constants.o: $(hdrdir)/ruby/subst.h
+constants.o: $(hdrdir)/ruby/thread.h
+constants.o: $(hdrdir)/ruby/util.h
+constants.o: $(top_srcdir)/include/ruby.h
+constants.o: $(top_srcdir)/internal.h
+constants.o: constants.c
+constants.o: constdefs.c
+constants.o: constdefs.h
+constants.o: rubysocket.h
+constants.o: sockport.h
+ifaddr.o: $(RUBY_EXTCONF_H)
+ifaddr.o: $(arch_hdrdir)/ruby/config.h
+ifaddr.o: $(hdrdir)/ruby/defines.h
+ifaddr.o: $(hdrdir)/ruby/encoding.h
+ifaddr.o: $(hdrdir)/ruby/intern.h
+ifaddr.o: $(hdrdir)/ruby/io.h
+ifaddr.o: $(hdrdir)/ruby/missing.h
+ifaddr.o: $(hdrdir)/ruby/oniguruma.h
+ifaddr.o: $(hdrdir)/ruby/ruby.h
+ifaddr.o: $(hdrdir)/ruby/st.h
+ifaddr.o: $(hdrdir)/ruby/subst.h
+ifaddr.o: $(hdrdir)/ruby/thread.h
+ifaddr.o: $(hdrdir)/ruby/util.h
+ifaddr.o: $(top_srcdir)/include/ruby.h
+ifaddr.o: $(top_srcdir)/internal.h
+ifaddr.o: constdefs.h
+ifaddr.o: ifaddr.c
+ifaddr.o: rubysocket.h
+ifaddr.o: sockport.h
+init.o: $(RUBY_EXTCONF_H)
+init.o: $(arch_hdrdir)/ruby/config.h
+init.o: $(hdrdir)/ruby/defines.h
+init.o: $(hdrdir)/ruby/encoding.h
+init.o: $(hdrdir)/ruby/intern.h
+init.o: $(hdrdir)/ruby/io.h
+init.o: $(hdrdir)/ruby/missing.h
+init.o: $(hdrdir)/ruby/oniguruma.h
+init.o: $(hdrdir)/ruby/ruby.h
+init.o: $(hdrdir)/ruby/st.h
+init.o: $(hdrdir)/ruby/subst.h
+init.o: $(hdrdir)/ruby/thread.h
+init.o: $(hdrdir)/ruby/util.h
+init.o: $(top_srcdir)/include/ruby.h
+init.o: $(top_srcdir)/internal.h
+init.o: constdefs.h
+init.o: init.c
+init.o: rubysocket.h
+init.o: sockport.h
+ipsocket.o: $(RUBY_EXTCONF_H)
+ipsocket.o: $(arch_hdrdir)/ruby/config.h
+ipsocket.o: $(hdrdir)/ruby/defines.h
+ipsocket.o: $(hdrdir)/ruby/encoding.h
+ipsocket.o: $(hdrdir)/ruby/intern.h
+ipsocket.o: $(hdrdir)/ruby/io.h
+ipsocket.o: $(hdrdir)/ruby/missing.h
+ipsocket.o: $(hdrdir)/ruby/oniguruma.h
+ipsocket.o: $(hdrdir)/ruby/ruby.h
+ipsocket.o: $(hdrdir)/ruby/st.h
+ipsocket.o: $(hdrdir)/ruby/subst.h
+ipsocket.o: $(hdrdir)/ruby/thread.h
+ipsocket.o: $(hdrdir)/ruby/util.h
+ipsocket.o: $(top_srcdir)/include/ruby.h
+ipsocket.o: $(top_srcdir)/internal.h
+ipsocket.o: constdefs.h
+ipsocket.o: ipsocket.c
+ipsocket.o: rubysocket.h
+ipsocket.o: sockport.h
+option.o: $(RUBY_EXTCONF_H)
+option.o: $(arch_hdrdir)/ruby/config.h
+option.o: $(hdrdir)/ruby/defines.h
+option.o: $(hdrdir)/ruby/encoding.h
+option.o: $(hdrdir)/ruby/intern.h
+option.o: $(hdrdir)/ruby/io.h
+option.o: $(hdrdir)/ruby/missing.h
+option.o: $(hdrdir)/ruby/oniguruma.h
+option.o: $(hdrdir)/ruby/ruby.h
+option.o: $(hdrdir)/ruby/st.h
+option.o: $(hdrdir)/ruby/subst.h
+option.o: $(hdrdir)/ruby/thread.h
+option.o: $(hdrdir)/ruby/util.h
+option.o: $(top_srcdir)/include/ruby.h
+option.o: $(top_srcdir)/internal.h
+option.o: constdefs.h
+option.o: option.c
+option.o: rubysocket.h
+option.o: sockport.h
+raddrinfo.o: $(RUBY_EXTCONF_H)
+raddrinfo.o: $(arch_hdrdir)/ruby/config.h
+raddrinfo.o: $(hdrdir)/ruby/defines.h
+raddrinfo.o: $(hdrdir)/ruby/encoding.h
+raddrinfo.o: $(hdrdir)/ruby/intern.h
+raddrinfo.o: $(hdrdir)/ruby/io.h
+raddrinfo.o: $(hdrdir)/ruby/missing.h
+raddrinfo.o: $(hdrdir)/ruby/oniguruma.h
+raddrinfo.o: $(hdrdir)/ruby/ruby.h
+raddrinfo.o: $(hdrdir)/ruby/st.h
+raddrinfo.o: $(hdrdir)/ruby/subst.h
+raddrinfo.o: $(hdrdir)/ruby/thread.h
+raddrinfo.o: $(hdrdir)/ruby/util.h
+raddrinfo.o: $(top_srcdir)/include/ruby.h
+raddrinfo.o: $(top_srcdir)/internal.h
+raddrinfo.o: constdefs.h
+raddrinfo.o: raddrinfo.c
+raddrinfo.o: rubysocket.h
+raddrinfo.o: sockport.h
+socket.o: $(RUBY_EXTCONF_H)
+socket.o: $(arch_hdrdir)/ruby/config.h
+socket.o: $(hdrdir)/ruby/defines.h
+socket.o: $(hdrdir)/ruby/encoding.h
+socket.o: $(hdrdir)/ruby/intern.h
+socket.o: $(hdrdir)/ruby/io.h
+socket.o: $(hdrdir)/ruby/missing.h
+socket.o: $(hdrdir)/ruby/oniguruma.h
+socket.o: $(hdrdir)/ruby/ruby.h
+socket.o: $(hdrdir)/ruby/st.h
+socket.o: $(hdrdir)/ruby/subst.h
+socket.o: $(hdrdir)/ruby/thread.h
+socket.o: $(hdrdir)/ruby/util.h
+socket.o: $(top_srcdir)/include/ruby.h
+socket.o: $(top_srcdir)/internal.h
+socket.o: constdefs.h
+socket.o: rubysocket.h
+socket.o: socket.c
+socket.o: sockport.h
+sockssocket.o: $(RUBY_EXTCONF_H)
+sockssocket.o: $(arch_hdrdir)/ruby/config.h
+sockssocket.o: $(hdrdir)/ruby/defines.h
+sockssocket.o: $(hdrdir)/ruby/encoding.h
+sockssocket.o: $(hdrdir)/ruby/intern.h
+sockssocket.o: $(hdrdir)/ruby/io.h
+sockssocket.o: $(hdrdir)/ruby/missing.h
+sockssocket.o: $(hdrdir)/ruby/oniguruma.h
+sockssocket.o: $(hdrdir)/ruby/ruby.h
+sockssocket.o: $(hdrdir)/ruby/st.h
+sockssocket.o: $(hdrdir)/ruby/subst.h
+sockssocket.o: $(hdrdir)/ruby/thread.h
+sockssocket.o: $(hdrdir)/ruby/util.h
+sockssocket.o: $(top_srcdir)/include/ruby.h
+sockssocket.o: $(top_srcdir)/internal.h
+sockssocket.o: constdefs.h
+sockssocket.o: rubysocket.h
+sockssocket.o: sockport.h
+sockssocket.o: sockssocket.c
+tcpserver.o: $(RUBY_EXTCONF_H)
+tcpserver.o: $(arch_hdrdir)/ruby/config.h
+tcpserver.o: $(hdrdir)/ruby/defines.h
+tcpserver.o: $(hdrdir)/ruby/encoding.h
+tcpserver.o: $(hdrdir)/ruby/intern.h
+tcpserver.o: $(hdrdir)/ruby/io.h
+tcpserver.o: $(hdrdir)/ruby/missing.h
+tcpserver.o: $(hdrdir)/ruby/oniguruma.h
+tcpserver.o: $(hdrdir)/ruby/ruby.h
+tcpserver.o: $(hdrdir)/ruby/st.h
+tcpserver.o: $(hdrdir)/ruby/subst.h
+tcpserver.o: $(hdrdir)/ruby/thread.h
+tcpserver.o: $(hdrdir)/ruby/util.h
+tcpserver.o: $(top_srcdir)/include/ruby.h
+tcpserver.o: $(top_srcdir)/internal.h
+tcpserver.o: constdefs.h
+tcpserver.o: rubysocket.h
+tcpserver.o: sockport.h
+tcpserver.o: tcpserver.c
+tcpsocket.o: $(RUBY_EXTCONF_H)
+tcpsocket.o: $(arch_hdrdir)/ruby/config.h
+tcpsocket.o: $(hdrdir)/ruby/defines.h
+tcpsocket.o: $(hdrdir)/ruby/encoding.h
+tcpsocket.o: $(hdrdir)/ruby/intern.h
+tcpsocket.o: $(hdrdir)/ruby/io.h
+tcpsocket.o: $(hdrdir)/ruby/missing.h
+tcpsocket.o: $(hdrdir)/ruby/oniguruma.h
+tcpsocket.o: $(hdrdir)/ruby/ruby.h
+tcpsocket.o: $(hdrdir)/ruby/st.h
+tcpsocket.o: $(hdrdir)/ruby/subst.h
+tcpsocket.o: $(hdrdir)/ruby/thread.h
+tcpsocket.o: $(hdrdir)/ruby/util.h
+tcpsocket.o: $(top_srcdir)/include/ruby.h
+tcpsocket.o: $(top_srcdir)/internal.h
+tcpsocket.o: constdefs.h
+tcpsocket.o: rubysocket.h
+tcpsocket.o: sockport.h
+tcpsocket.o: tcpsocket.c
+udpsocket.o: $(RUBY_EXTCONF_H)
+udpsocket.o: $(arch_hdrdir)/ruby/config.h
+udpsocket.o: $(hdrdir)/ruby/defines.h
+udpsocket.o: $(hdrdir)/ruby/encoding.h
+udpsocket.o: $(hdrdir)/ruby/intern.h
+udpsocket.o: $(hdrdir)/ruby/io.h
+udpsocket.o: $(hdrdir)/ruby/missing.h
+udpsocket.o: $(hdrdir)/ruby/oniguruma.h
+udpsocket.o: $(hdrdir)/ruby/ruby.h
+udpsocket.o: $(hdrdir)/ruby/st.h
+udpsocket.o: $(hdrdir)/ruby/subst.h
+udpsocket.o: $(hdrdir)/ruby/thread.h
+udpsocket.o: $(hdrdir)/ruby/util.h
+udpsocket.o: $(top_srcdir)/include/ruby.h
+udpsocket.o: $(top_srcdir)/internal.h
+udpsocket.o: constdefs.h
+udpsocket.o: rubysocket.h
+udpsocket.o: sockport.h
+udpsocket.o: udpsocket.c
+unixserver.o: $(RUBY_EXTCONF_H)
+unixserver.o: $(arch_hdrdir)/ruby/config.h
+unixserver.o: $(hdrdir)/ruby/defines.h
+unixserver.o: $(hdrdir)/ruby/encoding.h
+unixserver.o: $(hdrdir)/ruby/intern.h
+unixserver.o: $(hdrdir)/ruby/io.h
+unixserver.o: $(hdrdir)/ruby/missing.h
+unixserver.o: $(hdrdir)/ruby/oniguruma.h
+unixserver.o: $(hdrdir)/ruby/ruby.h
+unixserver.o: $(hdrdir)/ruby/st.h
+unixserver.o: $(hdrdir)/ruby/subst.h
+unixserver.o: $(hdrdir)/ruby/thread.h
+unixserver.o: $(hdrdir)/ruby/util.h
+unixserver.o: $(top_srcdir)/include/ruby.h
+unixserver.o: $(top_srcdir)/internal.h
+unixserver.o: constdefs.h
+unixserver.o: rubysocket.h
+unixserver.o: sockport.h
+unixserver.o: unixserver.c
+unixsocket.o: $(RUBY_EXTCONF_H)
+unixsocket.o: $(arch_hdrdir)/ruby/config.h
+unixsocket.o: $(hdrdir)/ruby/defines.h
+unixsocket.o: $(hdrdir)/ruby/encoding.h
+unixsocket.o: $(hdrdir)/ruby/intern.h
+unixsocket.o: $(hdrdir)/ruby/io.h
+unixsocket.o: $(hdrdir)/ruby/missing.h
+unixsocket.o: $(hdrdir)/ruby/oniguruma.h
+unixsocket.o: $(hdrdir)/ruby/ruby.h
+unixsocket.o: $(hdrdir)/ruby/st.h
+unixsocket.o: $(hdrdir)/ruby/subst.h
+unixsocket.o: $(hdrdir)/ruby/thread.h
+unixsocket.o: $(hdrdir)/ruby/util.h
+unixsocket.o: $(top_srcdir)/include/ruby.h
+unixsocket.o: $(top_srcdir)/internal.h
+unixsocket.o: constdefs.h
+unixsocket.o: rubysocket.h
+unixsocket.o: sockport.h
+unixsocket.o: unixsocket.c
+# AUTOGENERATED DEPENDENCIES END
diff --git a/jni/ruby/ext/socket/addrinfo.h b/jni/ruby/ext/socket/addrinfo.h
new file mode 100644
index 0000000..f0b977d
--- /dev/null
+++ b/jni/ruby/ext/socket/addrinfo.h
@@ -0,0 +1,189 @@
+/*
+ * Copyright (C) 1995, 1996, 1997, 1998, and 1999 WIDE Project.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the project nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#ifndef ADDR_INFO_H
+#define ADDR_INFO_H
+
+/* special compatibility hack */
+#undef EAI_ADDRFAMILY
+#undef EAI_AGAIN
+#undef EAI_BADFLAGS
+#undef EAI_FAIL
+#undef EAI_FAMILY
+#undef EAI_MEMORY
+#undef EAI_NODATA
+#undef EAI_NONAME
+#undef EAI_SERVICE
+#undef EAI_SOCKTYPE
+#undef EAI_SYSTEM
+#undef EAI_BADHINTS
+#undef EAI_PROTOCOL
+#undef EAI_MAX
+
+#undef AI_PASSIVE
+#undef AI_CANONNAME
+#undef AI_NUMERICHOST
+#undef AI_NUMERICSERV
+#undef AI_ALL
+#undef AI_ADDRCONFIG
+#undef AI_V4MAPPED
+#undef AI_DEFAULT
+
+#undef NI_NOFQDN
+#undef NI_NUMERICHOST
+#undef NI_NAMEREQD
+#undef NI_NUMERICSERV
+#undef NI_DGRAM
+
+#ifndef __P
+# ifdef HAVE_PROTOTYPES
+# define __P(args) args
+# else
+# define __P(args) ()
+# endif
+#endif
+
+/* special compatibility hack -- end*/
+
+
+/*
+ * Error return codes from getaddrinfo()
+ */
+#define EAI_ADDRFAMILY 1 /* address family for hostname not supported */
+#define EAI_AGAIN 2 /* temporary failure in name resolution */
+#define EAI_BADFLAGS 3 /* invalid value for ai_flags */
+#define EAI_FAIL 4 /* non-recoverable failure in name resolution */
+#define EAI_FAMILY 5 /* ai_family not supported */
+#define EAI_MEMORY 6 /* memory allocation failure */
+#define EAI_NODATA 7 /* no address associated with hostname */
+#define EAI_NONAME 8 /* hostname nor servname provided, or not known */
+#define EAI_SERVICE 9 /* servname not supported for ai_socktype */
+#define EAI_SOCKTYPE 10 /* ai_socktype not supported */
+#define EAI_SYSTEM 11 /* system error returned in errno */
+#define EAI_BADHINTS 12
+#define EAI_PROTOCOL 13
+#define EAI_MAX 14
+
+/*
+ * Flag values for getaddrinfo()
+ */
+#define AI_PASSIVE 0x00000001 /* get address to use bind() */
+#define AI_CANONNAME 0x00000002 /* fill ai_canonname */
+#define AI_NUMERICHOST 0x00000004 /* prevent name resolution */
+#define AI_NUMERICSERV 0x00000008 /* prevent service name resolution */
+/* valid flags for addrinfo */
+#ifndef __HAIKU__
+#undef AI_MASK
+#define AI_MASK (AI_PASSIVE | AI_CANONNAME | AI_NUMERICHOST | AI_NUMERICSERV)
+#endif
+
+#define AI_ALL 0x00000100 /* IPv6 and IPv4-mapped (with AI_V4MAPPED) */
+#define AI_V4MAPPED_CFG 0x00000200 /* accept IPv4-mapped if kernel supports */
+#define AI_ADDRCONFIG 0x00000400 /* only if any address is assigned */
+#define AI_V4MAPPED 0x00000800 /* accept IPv4-mapped IPv6 address */
+/* special recommended flags for getipnodebyname */
+#define AI_DEFAULT (AI_V4MAPPED_CFG | AI_ADDRCONFIG)
+
+/*
+ * Constants for getnameinfo()
+ */
+#ifndef NI_MAXHOST
+#define NI_MAXHOST 1025
+#define NI_MAXSERV 32
+#endif
+
+/*
+ * Flag values for getnameinfo()
+ */
+#define NI_NOFQDN 0x00000001
+#define NI_NUMERICHOST 0x00000002
+#define NI_NAMEREQD 0x00000004
+#define NI_NUMERICSERV 0x00000008
+#define NI_DGRAM 0x00000010
+
+#ifndef HAVE_TYPE_STRUCT_ADDRINFO
+struct addrinfo {
+ int ai_flags; /* AI_PASSIVE, AI_CANONNAME */
+ int ai_family; /* PF_xxx */
+ int ai_socktype; /* SOCK_xxx */
+ int ai_protocol; /* 0 or IPPROTO_xxx for IPv4 and IPv6 */
+ size_t ai_addrlen; /* length of ai_addr */
+ char *ai_canonname; /* canonical name for hostname */
+ struct sockaddr *ai_addr; /* binary address */
+ struct addrinfo *ai_next; /* next structure in linked list */
+};
+#endif
+
+#ifndef HAVE_GETADDRINFO
+#undef getaddrinfo
+#define getaddrinfo getaddrinfo__compat
+#endif
+#ifndef HAVE_GETNAMEINFO
+#undef getnameinfo
+#define getnameinfo getnameinfo__compat
+#endif
+#ifndef HAVE_FREEHOSTENT
+#undef freehostent
+#define freehostent freehostent__compat
+#endif
+#ifndef HAVE_FREEADDRINFO
+#undef freeaddrinfo
+#define freeaddrinfo freeaddrinfo__compat
+#endif
+
+extern int getaddrinfo __P((
+ const char *hostname, const char *servname,
+ const struct addrinfo *hints,
+ struct addrinfo **res));
+
+extern int getnameinfo __P((
+ const struct sockaddr *sa,
+ socklen_t salen,
+ char *host,
+ socklen_t hostlen,
+ char *serv,
+ socklen_t servlen,
+ int flags));
+
+extern void freehostent __P((struct hostent *));
+extern void freeaddrinfo __P((struct addrinfo *));
+extern
+#ifdef GAI_STRERROR_CONST
+const
+#endif
+char *gai_strerror __P((int));
+
+/* In case there is no definition of offsetof() provided - though any proper
+Standard C system should have one. */
+
+#ifndef offsetof
+#define offsetof(p_type,field) ((size_t)&(((p_type *)0)->field))
+#endif
+
+#endif
diff --git a/jni/ruby/ext/socket/ancdata.c b/jni/ruby/ext/socket/ancdata.c
new file mode 100644
index 0000000..b69417e
--- /dev/null
+++ b/jni/ruby/ext/socket/ancdata.c
@@ -0,0 +1,1842 @@
+#include "rubysocket.h"
+
+#include <time.h>
+
+int rsock_cmsg_cloexec_state = -1; /* <0: unknown, 0: ignored, >0: working */
+
+#if defined(HAVE_STRUCT_MSGHDR_MSG_CONTROL)
+static VALUE rb_cAncillaryData;
+
+static VALUE
+constant_to_sym(int constant, ID (*intern_const)(int))
+{
+ ID name = intern_const(constant);
+ if (name) {
+ return ID2SYM(name);
+ }
+
+ return INT2NUM(constant);
+}
+
+static VALUE
+ip_cmsg_type_to_sym(int level, int cmsg_type)
+{
+ switch (level) {
+ case SOL_SOCKET:
+ return constant_to_sym(cmsg_type, rsock_intern_scm_optname);
+ case IPPROTO_IP:
+ return constant_to_sym(cmsg_type, rsock_intern_ip_optname);
+#ifdef IPPROTO_IPV6
+ case IPPROTO_IPV6:
+ return constant_to_sym(cmsg_type, rsock_intern_ipv6_optname);
+#endif
+ case IPPROTO_TCP:
+ return constant_to_sym(cmsg_type, rsock_intern_tcp_optname);
+ case IPPROTO_UDP:
+ return constant_to_sym(cmsg_type, rsock_intern_udp_optname);
+ default:
+ return INT2NUM(cmsg_type);
+ }
+}
+
+/*
+ * call-seq:
+ * Socket::AncillaryData.new(family, cmsg_level, cmsg_type, cmsg_data) -> ancillarydata
+ *
+ * _family_ should be an integer, a string or a symbol.
+ * - Socket::AF_INET, "AF_INET", "INET", :AF_INET, :INET
+ * - Socket::AF_UNIX, "AF_UNIX", "UNIX", :AF_UNIX, :UNIX
+ * - etc.
+ *
+ * _cmsg_level_ should be an integer, a string or a symbol.
+ * - Socket::SOL_SOCKET, "SOL_SOCKET", "SOCKET", :SOL_SOCKET and :SOCKET
+ * - Socket::IPPROTO_IP, "IP" and :IP
+ * - Socket::IPPROTO_IPV6, "IPV6" and :IPV6
+ * - Socket::IPPROTO_TCP, "TCP" and :TCP
+ * - etc.
+ *
+ * _cmsg_type_ should be an integer, a string or a symbol.
+ * If a string/symbol is specified, it is interpreted depend on _cmsg_level_.
+ * - Socket::SCM_RIGHTS, "SCM_RIGHTS", "RIGHTS", :SCM_RIGHTS, :RIGHTS for SOL_SOCKET
+ * - Socket::IP_RECVTTL, "RECVTTL" and :RECVTTL for IPPROTO_IP
+ * - Socket::IPV6_PKTINFO, "PKTINFO" and :PKTINFO for IPPROTO_IPV6
+ * - etc.
+ *
+ * _cmsg_data_ should be a string.
+ *
+ * p Socket::AncillaryData.new(:INET, :TCP, :NODELAY, "")
+ * #=> #<Socket::AncillaryData: INET TCP NODELAY "">
+ *
+ * p Socket::AncillaryData.new(:INET6, :IPV6, :PKTINFO, "")
+ * #=> #<Socket::AncillaryData: INET6 IPV6 PKTINFO "">
+ *
+ */
+static VALUE
+ancillary_initialize(VALUE self, VALUE vfamily, VALUE vlevel, VALUE vtype, VALUE data)
+{
+ int family = rsock_family_arg(vfamily);
+ int level = rsock_level_arg(family, vlevel);
+ int type = rsock_cmsg_type_arg(family, level, vtype);
+ StringValue(data);
+ rb_ivar_set(self, rb_intern("family"), INT2NUM(family));
+ rb_ivar_set(self, rb_intern("level"), INT2NUM(level));
+ rb_ivar_set(self, rb_intern("type"), INT2NUM(type));
+ rb_ivar_set(self, rb_intern("data"), data);
+ return self;
+}
+
+static VALUE
+ancdata_new(int family, int level, int type, VALUE data)
+{
+ NEWOBJ_OF(obj, struct RObject, rb_cAncillaryData, T_OBJECT);
+ StringValue(data);
+ ancillary_initialize((VALUE)obj, INT2NUM(family), INT2NUM(level), INT2NUM(type), data);
+ return (VALUE)obj;
+}
+
+static int
+ancillary_family(VALUE self)
+{
+ VALUE v = rb_attr_get(self, rb_intern("family"));
+ return NUM2INT(v);
+}
+
+/*
+ * call-seq:
+ * ancillarydata.family => integer
+ *
+ * returns the socket family as an integer.
+ *
+ * p Socket::AncillaryData.new(:INET6, :IPV6, :PKTINFO, "").family
+ * #=> 10
+ */
+static VALUE
+ancillary_family_m(VALUE self)
+{
+ return INT2NUM(ancillary_family(self));
+}
+
+static int
+ancillary_level(VALUE self)
+{
+ VALUE v = rb_attr_get(self, rb_intern("level"));
+ return NUM2INT(v);
+}
+
+/*
+ * call-seq:
+ * ancillarydata.level => integer
+ *
+ * returns the cmsg level as an integer.
+ *
+ * p Socket::AncillaryData.new(:INET6, :IPV6, :PKTINFO, "").level
+ * #=> 41
+ */
+static VALUE
+ancillary_level_m(VALUE self)
+{
+ return INT2NUM(ancillary_level(self));
+}
+
+static int
+ancillary_type(VALUE self)
+{
+ VALUE v = rb_attr_get(self, rb_intern("type"));
+ return NUM2INT(v);
+}
+
+/*
+ * call-seq:
+ * ancillarydata.type => integer
+ *
+ * returns the cmsg type as an integer.
+ *
+ * p Socket::AncillaryData.new(:INET6, :IPV6, :PKTINFO, "").type
+ * #=> 2
+ */
+static VALUE
+ancillary_type_m(VALUE self)
+{
+ return INT2NUM(ancillary_type(self));
+}
+
+/*
+ * call-seq:
+ * ancillarydata.data => string
+ *
+ * returns the cmsg data as a string.
+ *
+ * p Socket::AncillaryData.new(:INET6, :IPV6, :PKTINFO, "").data
+ * #=> ""
+ */
+static VALUE
+ancillary_data(VALUE self)
+{
+ VALUE v = rb_attr_get(self, rb_intern("data"));
+ StringValue(v);
+ return v;
+}
+
+#ifdef SCM_RIGHTS
+/*
+ * call-seq:
+ * Socket::AncillaryData.unix_rights(io1, io2, ...) => ancillarydata
+ *
+ * Creates a new Socket::AncillaryData object which contains file descriptors as data.
+ *
+ * p Socket::AncillaryData.unix_rights(STDERR)
+ * #=> #<Socket::AncillaryData: UNIX SOCKET RIGHTS 2>
+ */
+static VALUE
+ancillary_s_unix_rights(int argc, VALUE *argv, VALUE klass)
+{
+ VALUE result, str, ary;
+ int i;
+
+ ary = rb_ary_new();
+
+ for (i = 0 ; i < argc; i++) {
+ VALUE obj = argv[i];
+ if (!RB_TYPE_P(obj, T_FILE)) {
+ rb_raise(rb_eTypeError, "IO expected");
+ }
+ rb_ary_push(ary, obj);
+ }
+
+ str = rb_str_buf_new(sizeof(int) * argc);
+
+ for (i = 0 ; i < argc; i++) {
+ VALUE obj = RARRAY_PTR(ary)[i];
+ rb_io_t *fptr;
+ int fd;
+ GetOpenFile(obj, fptr);
+ fd = fptr->fd;
+ rb_str_buf_cat(str, (char *)&fd, sizeof(int));
+ }
+
+ result = ancdata_new(AF_UNIX, SOL_SOCKET, SCM_RIGHTS, str);
+ rb_ivar_set(result, rb_intern("unix_rights"), ary);
+ return result;
+}
+#else
+#define ancillary_s_unix_rights rb_f_notimplement
+#endif
+
+#ifdef SCM_RIGHTS
+/*
+ * call-seq:
+ * ancillarydata.unix_rights => array-of-IOs or nil
+ *
+ * returns the array of IO objects for SCM_RIGHTS control message in UNIX domain socket.
+ *
+ * The class of the IO objects in the array is IO or Socket.
+ *
+ * The array is attached to _ancillarydata_ when it is instantiated.
+ * For example, BasicSocket#recvmsg attach the array when
+ * receives a SCM_RIGHTS control message and :scm_rights=>true option is given.
+ *
+ * # recvmsg needs :scm_rights=>true for unix_rights
+ * s1, s2 = UNIXSocket.pair
+ * p s1 #=> #<UNIXSocket:fd 3>
+ * s1.sendmsg "stdin and a socket", 0, nil, Socket::AncillaryData.unix_rights(STDIN, s1)
+ * _, _, _, ctl = s2.recvmsg(:scm_rights=>true)
+ * p ctl #=> #<Socket::AncillaryData: UNIX SOCKET RIGHTS 6 7>
+ * p ctl.unix_rights #=> [#<IO:fd 6>, #<Socket:fd 7>]
+ * p File.identical?(STDIN, ctl.unix_rights[0]) #=> true
+ * p File.identical?(s1, ctl.unix_rights[1]) #=> true
+ *
+ * # If :scm_rights=>true is not given, unix_rights returns nil
+ * s1, s2 = UNIXSocket.pair
+ * s1.sendmsg "stdin and a socket", 0, nil, Socket::AncillaryData.unix_rights(STDIN, s1)
+ * _, _, _, ctl = s2.recvmsg
+ * p ctl #=> #<Socket::AncillaryData: UNIX SOCKET RIGHTS 6 7>
+ * p ctl.unix_rights #=> nil
+ *
+ */
+static VALUE
+ancillary_unix_rights(VALUE self)
+{
+ int level, type;
+
+ level = ancillary_level(self);
+ type = ancillary_type(self);
+
+ if (level != SOL_SOCKET || type != SCM_RIGHTS)
+ rb_raise(rb_eTypeError, "SCM_RIGHTS ancillary data expected");
+
+ return rb_attr_get(self, rb_intern("unix_rights"));
+}
+#else
+#define ancillary_unix_rights rb_f_notimplement
+#endif
+
+#if defined(SCM_TIMESTAMP) || defined(SCM_TIMESTAMPNS) || defined(SCM_BINTIME)
+/*
+ * call-seq:
+ * ancillarydata.timestamp => time
+ *
+ * returns the timestamp as a time object.
+ *
+ * _ancillarydata_ should be one of following type:
+ * - SOL_SOCKET/SCM_TIMESTAMP (microsecond) GNU/Linux, FreeBSD, NetBSD, OpenBSD, Solaris, MacOS X
+ * - SOL_SOCKET/SCM_TIMESTAMPNS (nanosecond) GNU/Linux
+ * - SOL_SOCKET/SCM_BINTIME (2**(-64) second) FreeBSD
+ *
+ * Addrinfo.udp("127.0.0.1", 0).bind {|s1|
+ * Addrinfo.udp("127.0.0.1", 0).bind {|s2|
+ * s1.setsockopt(:SOCKET, :TIMESTAMP, true)
+ * s2.send "a", 0, s1.local_address
+ * ctl = s1.recvmsg.last
+ * p ctl #=> #<Socket::AncillaryData: INET SOCKET TIMESTAMP 2009-02-24 17:35:46.775581>
+ * t = ctl.timestamp
+ * p t #=> 2009-02-24 17:35:46 +0900
+ * p t.usec #=> 775581
+ * p t.nsec #=> 775581000
+ * }
+ * }
+ *
+ */
+static VALUE
+ancillary_timestamp(VALUE self)
+{
+ int level, type;
+ VALUE data;
+ VALUE result = Qnil;
+
+ level = ancillary_level(self);
+ type = ancillary_type(self);
+ data = ancillary_data(self);
+
+# ifdef SCM_TIMESTAMP
+ if (level == SOL_SOCKET && type == SCM_TIMESTAMP &&
+ RSTRING_LEN(data) == sizeof(struct timeval)) {
+ struct timeval tv;
+ memcpy((char*)&tv, RSTRING_PTR(data), sizeof(tv));
+ result = rb_time_new(tv.tv_sec, tv.tv_usec);
+ }
+# endif
+
+# ifdef SCM_TIMESTAMPNS
+ if (level == SOL_SOCKET && type == SCM_TIMESTAMPNS &&
+ RSTRING_LEN(data) == sizeof(struct timespec)) {
+ struct timespec ts;
+ memcpy((char*)&ts, RSTRING_PTR(data), sizeof(ts));
+ result = rb_time_nano_new(ts.tv_sec, ts.tv_nsec);
+ }
+# endif
+
+#define add(x,y) (rb_funcall((x), '+', 1, (y)))
+#define mul(x,y) (rb_funcall((x), '*', 1, (y)))
+#define quo(x,y) (rb_funcall((x), rb_intern("quo"), 1, (y)))
+
+# ifdef SCM_BINTIME
+ if (level == SOL_SOCKET && type == SCM_BINTIME &&
+ RSTRING_LEN(data) == sizeof(struct bintime)) {
+ struct bintime bt;
+ VALUE d, timev;
+ memcpy((char*)&bt, RSTRING_PTR(data), sizeof(bt));
+ d = ULL2NUM(0x100000000ULL);
+ d = mul(d,d);
+ timev = add(TIMET2NUM(bt.sec), quo(ULL2NUM(bt.frac), d));
+ result = rb_time_num_new(timev, Qnil);
+ }
+# endif
+
+ if (result == Qnil)
+ rb_raise(rb_eTypeError, "timestamp ancillary data expected");
+
+ return result;
+}
+#else
+#define ancillary_timestamp rb_f_notimplement
+#endif
+
+/*
+ * call-seq:
+ * Socket::AncillaryData.int(family, cmsg_level, cmsg_type, integer) => ancillarydata
+ *
+ * Creates a new Socket::AncillaryData object which contains a int as data.
+ *
+ * The size and endian is dependent on the host.
+ *
+ * p Socket::AncillaryData.int(:UNIX, :SOCKET, :RIGHTS, STDERR.fileno)
+ * #=> #<Socket::AncillaryData: UNIX SOCKET RIGHTS 2>
+ */
+static VALUE
+ancillary_s_int(VALUE klass, VALUE vfamily, VALUE vlevel, VALUE vtype, VALUE integer)
+{
+ int family = rsock_family_arg(vfamily);
+ int level = rsock_level_arg(family, vlevel);
+ int type = rsock_cmsg_type_arg(family, level, vtype);
+ int i = NUM2INT(integer);
+ return ancdata_new(family, level, type, rb_str_new((char*)&i, sizeof(i)));
+}
+
+/*
+ * call-seq:
+ * ancillarydata.int => integer
+ *
+ * Returns the data in _ancillarydata_ as an int.
+ *
+ * The size and endian is dependent on the host.
+ *
+ * ancdata = Socket::AncillaryData.int(:UNIX, :SOCKET, :RIGHTS, STDERR.fileno)
+ * p ancdata.int #=> 2
+ */
+static VALUE
+ancillary_int(VALUE self)
+{
+ VALUE data;
+ int i;
+ data = ancillary_data(self);
+ if (RSTRING_LEN(data) != sizeof(int))
+ rb_raise(rb_eTypeError, "size differ. expected as sizeof(int)=%d but %ld", (int)sizeof(int), (long)RSTRING_LEN(data));
+ memcpy((char*)&i, RSTRING_PTR(data), sizeof(int));
+ return INT2NUM(i);
+}
+
+#if defined(IPPROTO_IP) && defined(IP_PKTINFO) && defined(HAVE_STRUCT_IN_PKTINFO_IPI_SPEC_DST) /* GNU/Linux */
+/*
+ * call-seq:
+ * Socket::AncillaryData.ip_pktinfo(addr, ifindex) => ancdata
+ * Socket::AncillaryData.ip_pktinfo(addr, ifindex, spec_dst) => ancdata
+ *
+ * Returns new ancillary data for IP_PKTINFO.
+ *
+ * If spec_dst is not given, addr is used.
+ *
+ * IP_PKTINFO is not standard.
+ *
+ * Supported platform: GNU/Linux
+ *
+ * addr = Addrinfo.ip("127.0.0.1")
+ * ifindex = 0
+ * spec_dst = Addrinfo.ip("127.0.0.1")
+ * p Socket::AncillaryData.ip_pktinfo(addr, ifindex, spec_dst)
+ * #=> #<Socket::AncillaryData: INET IP PKTINFO 127.0.0.1 ifindex:0 spec_dst:127.0.0.1>
+ *
+ */
+static VALUE
+ancillary_s_ip_pktinfo(int argc, VALUE *argv, VALUE self)
+{
+ VALUE v_addr, v_ifindex, v_spec_dst;
+ unsigned int ifindex;
+ struct sockaddr_in sa;
+ struct in_pktinfo pktinfo;
+
+ rb_scan_args(argc, argv, "21", &v_addr, &v_ifindex, &v_spec_dst);
+
+ SockAddrStringValue(v_addr);
+ ifindex = NUM2UINT(v_ifindex);
+ if (NIL_P(v_spec_dst))
+ v_spec_dst = v_addr;
+ else
+ SockAddrStringValue(v_spec_dst);
+
+ memset(&pktinfo, 0, sizeof(pktinfo));
+
+ memset(&sa, 0, sizeof(sa));
+ if (RSTRING_LEN(v_addr) != sizeof(sa))
+ rb_raise(rb_eArgError, "addr size different to AF_INET sockaddr");
+ memcpy(&sa, RSTRING_PTR(v_addr), sizeof(sa));
+ if (sa.sin_family != AF_INET)
+ rb_raise(rb_eArgError, "addr is not AF_INET sockaddr");
+ memcpy(&pktinfo.ipi_addr, &sa.sin_addr, sizeof(pktinfo.ipi_addr));
+
+ pktinfo.ipi_ifindex = ifindex;
+
+ memset(&sa, 0, sizeof(sa));
+ if (RSTRING_LEN(v_spec_dst) != sizeof(sa))
+ rb_raise(rb_eArgError, "spec_dat size different to AF_INET sockaddr");
+ memcpy(&sa, RSTRING_PTR(v_spec_dst), sizeof(sa));
+ if (sa.sin_family != AF_INET)
+ rb_raise(rb_eArgError, "spec_dst is not AF_INET sockaddr");
+ memcpy(&pktinfo.ipi_spec_dst, &sa.sin_addr, sizeof(pktinfo.ipi_spec_dst));
+
+ return ancdata_new(AF_INET, IPPROTO_IP, IP_PKTINFO, rb_str_new((char *)&pktinfo, sizeof(pktinfo)));
+}
+#else
+#define ancillary_s_ip_pktinfo rb_f_notimplement
+#endif
+
+#if defined(IPPROTO_IP) && defined(IP_PKTINFO) && defined(HAVE_STRUCT_IN_PKTINFO_IPI_SPEC_DST) /* GNU/Linux */
+/*
+ * call-seq:
+ * ancdata.ip_pktinfo => [addr, ifindex, spec_dst]
+ *
+ * Extracts addr, ifindex and spec_dst from IP_PKTINFO ancillary data.
+ *
+ * IP_PKTINFO is not standard.
+ *
+ * Supported platform: GNU/Linux
+ *
+ * addr = Addrinfo.ip("127.0.0.1")
+ * ifindex = 0
+ * spec_dest = Addrinfo.ip("127.0.0.1")
+ * ancdata = Socket::AncillaryData.ip_pktinfo(addr, ifindex, spec_dest)
+ * p ancdata.ip_pktinfo
+ * #=> [#<Addrinfo: 127.0.0.1>, 0, #<Addrinfo: 127.0.0.1>]
+ *
+ *
+ */
+static VALUE
+ancillary_ip_pktinfo(VALUE self)
+{
+ int level, type;
+ VALUE data;
+ struct in_pktinfo pktinfo;
+ struct sockaddr_in sa;
+ VALUE v_spec_dst, v_addr;
+
+ level = ancillary_level(self);
+ type = ancillary_type(self);
+ data = ancillary_data(self);
+
+ if (level != IPPROTO_IP || type != IP_PKTINFO ||
+ RSTRING_LEN(data) != sizeof(struct in_pktinfo)) {
+ rb_raise(rb_eTypeError, "IP_PKTINFO ancillary data expected");
+ }
+
+ memcpy(&pktinfo, RSTRING_PTR(data), sizeof(struct in_pktinfo));
+ memset(&sa, 0, sizeof(sa));
+
+ sa.sin_family = AF_INET;
+ memcpy(&sa.sin_addr, &pktinfo.ipi_addr, sizeof(sa.sin_addr));
+ v_addr = rsock_addrinfo_new((struct sockaddr *)&sa, sizeof(sa), PF_INET, 0, 0, Qnil, Qnil);
+
+ sa.sin_family = AF_INET;
+ memcpy(&sa.sin_addr, &pktinfo.ipi_spec_dst, sizeof(sa.sin_addr));
+ v_spec_dst = rsock_addrinfo_new((struct sockaddr *)&sa, sizeof(sa), PF_INET, 0, 0, Qnil, Qnil);
+
+ return rb_ary_new3(3, v_addr, UINT2NUM(pktinfo.ipi_ifindex), v_spec_dst);
+}
+#else
+#define ancillary_ip_pktinfo rb_f_notimplement
+#endif
+
+#if defined(IPPROTO_IPV6) && defined(IPV6_PKTINFO) /* IPv6 RFC3542 */
+/*
+ * call-seq:
+ * Socket::AncillaryData.ipv6_pktinfo(addr, ifindex) => ancdata
+ *
+ * Returns new ancillary data for IPV6_PKTINFO.
+ *
+ * IPV6_PKTINFO is defined by RFC 3542.
+ *
+ * addr = Addrinfo.ip("::1")
+ * ifindex = 0
+ * p Socket::AncillaryData.ipv6_pktinfo(addr, ifindex)
+ * #=> #<Socket::AncillaryData: INET6 IPV6 PKTINFO ::1 ifindex:0>
+ *
+ */
+static VALUE
+ancillary_s_ipv6_pktinfo(VALUE self, VALUE v_addr, VALUE v_ifindex)
+{
+ unsigned int ifindex;
+ struct sockaddr_in6 sa;
+ struct in6_pktinfo pktinfo;
+
+ SockAddrStringValue(v_addr);
+ ifindex = NUM2UINT(v_ifindex);
+
+ memset(&pktinfo, 0, sizeof(pktinfo));
+
+ memset(&sa, 0, sizeof(sa));
+ if (RSTRING_LEN(v_addr) != sizeof(sa))
+ rb_raise(rb_eArgError, "addr size different to AF_INET6 sockaddr");
+ memcpy(&sa, RSTRING_PTR(v_addr), sizeof(sa));
+ if (sa.sin6_family != AF_INET6)
+ rb_raise(rb_eArgError, "addr is not AF_INET6 sockaddr");
+ memcpy(&pktinfo.ipi6_addr, &sa.sin6_addr, sizeof(pktinfo.ipi6_addr));
+
+ pktinfo.ipi6_ifindex = ifindex;
+
+ return ancdata_new(AF_INET6, IPPROTO_IPV6, IPV6_PKTINFO, rb_str_new((char *)&pktinfo, sizeof(pktinfo)));
+}
+#else
+#define ancillary_s_ipv6_pktinfo rb_f_notimplement
+#endif
+
+#if defined(IPPROTO_IPV6) && defined(IPV6_PKTINFO) /* IPv6 RFC3542 */
+static void
+extract_ipv6_pktinfo(VALUE self, struct in6_pktinfo *pktinfo_ptr, struct sockaddr_in6 *sa_ptr)
+{
+ int level, type;
+ VALUE data;
+
+ level = ancillary_level(self);
+ type = ancillary_type(self);
+ data = ancillary_data(self);
+
+ if (level != IPPROTO_IPV6 || type != IPV6_PKTINFO ||
+ RSTRING_LEN(data) != sizeof(struct in6_pktinfo)) {
+ rb_raise(rb_eTypeError, "IPV6_PKTINFO ancillary data expected");
+ }
+
+ memcpy(pktinfo_ptr, RSTRING_PTR(data), sizeof(*pktinfo_ptr));
+
+ INIT_SOCKADDR((struct sockaddr *)sa_ptr, AF_INET6, sizeof(*sa_ptr));
+ memcpy(&sa_ptr->sin6_addr, &pktinfo_ptr->ipi6_addr, sizeof(sa_ptr->sin6_addr));
+ if (IN6_IS_ADDR_LINKLOCAL(&sa_ptr->sin6_addr))
+ sa_ptr->sin6_scope_id = pktinfo_ptr->ipi6_ifindex;
+}
+#endif
+
+#if defined(IPPROTO_IPV6) && defined(IPV6_PKTINFO) /* IPv6 RFC3542 */
+/*
+ * call-seq:
+ * ancdata.ipv6_pktinfo => [addr, ifindex]
+ *
+ * Extracts addr and ifindex from IPV6_PKTINFO ancillary data.
+ *
+ * IPV6_PKTINFO is defined by RFC 3542.
+ *
+ * addr = Addrinfo.ip("::1")
+ * ifindex = 0
+ * ancdata = Socket::AncillaryData.ipv6_pktinfo(addr, ifindex)
+ * p ancdata.ipv6_pktinfo #=> [#<Addrinfo: ::1>, 0]
+ *
+ */
+static VALUE
+ancillary_ipv6_pktinfo(VALUE self)
+{
+ struct in6_pktinfo pktinfo;
+ struct sockaddr_in6 sa;
+ VALUE v_addr;
+
+ extract_ipv6_pktinfo(self, &pktinfo, &sa);
+ v_addr = rsock_addrinfo_new((struct sockaddr *)&sa, (socklen_t)sizeof(sa), PF_INET6, 0, 0, Qnil, Qnil);
+ return rb_ary_new3(2, v_addr, UINT2NUM(pktinfo.ipi6_ifindex));
+}
+#else
+#define ancillary_ipv6_pktinfo rb_f_notimplement
+#endif
+
+#if defined(IPPROTO_IPV6) && defined(IPV6_PKTINFO) /* IPv6 RFC3542 */
+/*
+ * call-seq:
+ * ancdata.ipv6_pktinfo_addr => addr
+ *
+ * Extracts addr from IPV6_PKTINFO ancillary data.
+ *
+ * IPV6_PKTINFO is defined by RFC 3542.
+ *
+ * addr = Addrinfo.ip("::1")
+ * ifindex = 0
+ * ancdata = Socket::AncillaryData.ipv6_pktinfo(addr, ifindex)
+ * p ancdata.ipv6_pktinfo_addr #=> #<Addrinfo: ::1>
+ *
+ */
+static VALUE
+ancillary_ipv6_pktinfo_addr(VALUE self)
+{
+ struct in6_pktinfo pktinfo;
+ struct sockaddr_in6 sa;
+ extract_ipv6_pktinfo(self, &pktinfo, &sa);
+ return rsock_addrinfo_new((struct sockaddr *)&sa, (socklen_t)sizeof(sa), PF_INET6, 0, 0, Qnil, Qnil);
+}
+#else
+#define ancillary_ipv6_pktinfo_addr rb_f_notimplement
+#endif
+
+#if defined(IPPROTO_IPV6) && defined(IPV6_PKTINFO) /* IPv6 RFC3542 */
+/*
+ * call-seq:
+ * ancdata.ipv6_pktinfo_ifindex => addr
+ *
+ * Extracts ifindex from IPV6_PKTINFO ancillary data.
+ *
+ * IPV6_PKTINFO is defined by RFC 3542.
+ *
+ * addr = Addrinfo.ip("::1")
+ * ifindex = 0
+ * ancdata = Socket::AncillaryData.ipv6_pktinfo(addr, ifindex)
+ * p ancdata.ipv6_pktinfo_ifindex #=> 0
+ *
+ */
+static VALUE
+ancillary_ipv6_pktinfo_ifindex(VALUE self)
+{
+ struct in6_pktinfo pktinfo;
+ struct sockaddr_in6 sa;
+ extract_ipv6_pktinfo(self, &pktinfo, &sa);
+ return UINT2NUM(pktinfo.ipi6_ifindex);
+}
+#else
+#define ancillary_ipv6_pktinfo_ifindex rb_f_notimplement
+#endif
+
+#if defined(SOL_SOCKET) && defined(SCM_RIGHTS) /* 4.4BSD */
+static int
+anc_inspect_socket_rights(int level, int type, VALUE data, VALUE ret)
+{
+ if (level == SOL_SOCKET && type == SCM_RIGHTS &&
+ 0 < RSTRING_LEN(data) && (RSTRING_LEN(data) % sizeof(int) == 0)) {
+ long off;
+ for (off = 0; off < RSTRING_LEN(data); off += sizeof(int)) {
+ int fd;
+ memcpy((char*)&fd, RSTRING_PTR(data)+off, sizeof(int));
+ rb_str_catf(ret, " %d", fd);
+ }
+ return 1;
+ }
+ else {
+ return 0;
+ }
+}
+#endif
+
+#if defined(SCM_CREDENTIALS) /* GNU/Linux */
+static int
+anc_inspect_passcred_credentials(int level, int type, VALUE data, VALUE ret)
+{
+ if (level == SOL_SOCKET && type == SCM_CREDENTIALS &&
+ RSTRING_LEN(data) == sizeof(struct ucred)) {
+ struct ucred cred;
+ memcpy(&cred, RSTRING_PTR(data), sizeof(struct ucred));
+ rb_str_catf(ret, " pid=%u uid=%u gid=%u", cred.pid, cred.uid, cred.gid);
+ rb_str_cat2(ret, " (ucred)");
+ return 1;
+ }
+ else {
+ return 0;
+ }
+}
+#endif
+
+#if defined(SCM_CREDS)
+#define INSPECT_SCM_CREDS
+static int
+anc_inspect_socket_creds(int level, int type, VALUE data, VALUE ret)
+{
+ if (level != SOL_SOCKET && type != SCM_CREDS)
+ return 0;
+
+ /*
+ * FreeBSD has struct cmsgcred and struct sockcred.
+ * They use both SOL_SOCKET/SCM_CREDS in the ancillary message.
+ * They are not ambiguous from the view of the caller
+ * because struct sockcred is sent if and only if the caller sets LOCAL_CREDS socket option.
+ * But inspect method doesn't know it.
+ * So they are ambiguous from the view of inspect.
+ * This function distinguish them by the size of the ancillary message.
+ * This heuristics works well except when sc_ngroups == CMGROUP_MAX.
+ */
+
+#if defined(HAVE_TYPE_STRUCT_CMSGCRED) /* FreeBSD */
+ if (RSTRING_LEN(data) == sizeof(struct cmsgcred)) {
+ struct cmsgcred cred;
+ memcpy(&cred, RSTRING_PTR(data), sizeof(struct cmsgcred));
+ rb_str_catf(ret, " pid=%u", cred.cmcred_pid);
+ rb_str_catf(ret, " uid=%u", cred.cmcred_uid);
+ rb_str_catf(ret, " euid=%u", cred.cmcred_euid);
+ rb_str_catf(ret, " gid=%u", cred.cmcred_gid);
+ if (cred.cmcred_ngroups) {
+ int i;
+ const char *sep = " groups=";
+ for (i = 0; i < cred.cmcred_ngroups; i++) {
+ rb_str_catf(ret, "%s%u", sep, cred.cmcred_groups[i]);
+ sep = ",";
+ }
+ }
+ rb_str_cat2(ret, " (cmsgcred)");
+ return 1;
+ }
+#endif
+#if defined(HAVE_TYPE_STRUCT_SOCKCRED) /* FreeBSD, NetBSD */
+ if ((size_t)RSTRING_LEN(data) >= SOCKCREDSIZE(0)) {
+ struct sockcred cred0, *cred;
+ memcpy(&cred0, RSTRING_PTR(data), SOCKCREDSIZE(0));
+ if ((size_t)RSTRING_LEN(data) == SOCKCREDSIZE(cred0.sc_ngroups)) {
+ cred = (struct sockcred *)ALLOCA_N(char, SOCKCREDSIZE(cred0.sc_ngroups));
+ memcpy(cred, RSTRING_PTR(data), SOCKCREDSIZE(cred0.sc_ngroups));
+ rb_str_catf(ret, " uid=%u", cred->sc_uid);
+ rb_str_catf(ret, " euid=%u", cred->sc_euid);
+ rb_str_catf(ret, " gid=%u", cred->sc_gid);
+ rb_str_catf(ret, " egid=%u", cred->sc_egid);
+ if (cred0.sc_ngroups) {
+ int i;
+ const char *sep = " groups=";
+ for (i = 0; i < cred0.sc_ngroups; i++) {
+ rb_str_catf(ret, "%s%u", sep, cred->sc_groups[i]);
+ sep = ",";
+ }
+ }
+ rb_str_cat2(ret, " (sockcred)");
+ return 1;
+ }
+ }
+#endif
+ return 0;
+}
+#endif
+
+#if defined(IPPROTO_IP) && defined(IP_RECVDSTADDR) /* 4.4BSD */
+static int
+anc_inspect_ip_recvdstaddr(int level, int type, VALUE data, VALUE ret)
+{
+ if (level == IPPROTO_IP && type == IP_RECVDSTADDR &&
+ RSTRING_LEN(data) == sizeof(struct in_addr)) {
+ struct in_addr addr;
+ char addrbuf[INET_ADDRSTRLEN];
+ memcpy(&addr, RSTRING_PTR(data), sizeof(addr));
+ if (inet_ntop(AF_INET, &addr, addrbuf, (socklen_t)sizeof(addrbuf)) == NULL)
+ rb_str_cat2(ret, " invalid-address");
+ else
+ rb_str_catf(ret, " %s", addrbuf);
+ return 1;
+ }
+ else {
+ return 0;
+ }
+}
+#endif
+
+#if defined(IPPROTO_IP) && defined(IP_PKTINFO) && defined(HAVE_STRUCT_IN_PKTINFO_IPI_SPEC_DST) /* GNU/Linux */
+static int
+anc_inspect_ip_pktinfo(int level, int type, VALUE data, VALUE ret)
+{
+ if (level == IPPROTO_IP && type == IP_PKTINFO &&
+ RSTRING_LEN(data) == sizeof(struct in_pktinfo)) {
+ struct in_pktinfo pktinfo;
+ char buf[INET_ADDRSTRLEN > IFNAMSIZ ? INET_ADDRSTRLEN : IFNAMSIZ];
+ memcpy(&pktinfo, RSTRING_PTR(data), sizeof(pktinfo));
+ if (inet_ntop(AF_INET, &pktinfo.ipi_addr, buf, sizeof(buf)) == NULL)
+ rb_str_cat2(ret, " invalid-address");
+ else
+ rb_str_catf(ret, " %s", buf);
+ if (if_indextoname(pktinfo.ipi_ifindex, buf) == NULL)
+ rb_str_catf(ret, " ifindex:%d", pktinfo.ipi_ifindex);
+ else
+ rb_str_catf(ret, " %s", buf);
+ if (inet_ntop(AF_INET, &pktinfo.ipi_spec_dst, buf, sizeof(buf)) == NULL)
+ rb_str_cat2(ret, " spec_dst:invalid-address");
+ else
+ rb_str_catf(ret, " spec_dst:%s", buf);
+ return 1;
+ }
+ else {
+ return 0;
+ }
+}
+#endif
+
+#if defined(IPPROTO_IPV6) && defined(IPV6_PKTINFO) && defined(HAVE_TYPE_STRUCT_IN6_PKTINFO) /* IPv6 RFC3542 */
+static int
+anc_inspect_ipv6_pktinfo(int level, int type, VALUE data, VALUE ret)
+{
+ if (level == IPPROTO_IPV6 && type == IPV6_PKTINFO &&
+ RSTRING_LEN(data) == sizeof(struct in6_pktinfo)) {
+ struct in6_pktinfo *pktinfo = (struct in6_pktinfo *)RSTRING_PTR(data);
+ struct in6_addr addr;
+ unsigned int ifindex;
+ char addrbuf[INET6_ADDRSTRLEN], ifbuf[IFNAMSIZ];
+ memcpy(&addr, &pktinfo->ipi6_addr, sizeof(addr));
+ memcpy(&ifindex, &pktinfo->ipi6_ifindex, sizeof(ifindex));
+ if (inet_ntop(AF_INET6, &addr, addrbuf, (socklen_t)sizeof(addrbuf)) == NULL)
+ rb_str_cat2(ret, " invalid-address");
+ else
+ rb_str_catf(ret, " %s", addrbuf);
+ if (if_indextoname(ifindex, ifbuf) == NULL)
+ rb_str_catf(ret, " ifindex:%d", ifindex);
+ else
+ rb_str_catf(ret, " %s", ifbuf);
+ return 1;
+ }
+ else {
+ return 0;
+ }
+}
+#endif
+
+#if defined(SCM_TIMESTAMP) /* GNU/Linux, FreeBSD, NetBSD, OpenBSD, MacOS X, Solaris */
+static int
+inspect_timeval_as_abstime(int level, int optname, VALUE data, VALUE ret)
+{
+ if (RSTRING_LEN(data) == sizeof(struct timeval)) {
+ struct timeval tv;
+ time_t time;
+ struct tm tm;
+ char buf[32];
+ memcpy((char*)&tv, RSTRING_PTR(data), sizeof(tv));
+ time = tv.tv_sec;
+ tm = *localtime(&time);
+ strftime(buf, sizeof(buf), "%Y-%m-%d %H:%M:%S", &tm);
+ rb_str_catf(ret, " %s.%06ld", buf, (long)tv.tv_usec);
+ return 1;
+ }
+ else {
+ return 0;
+ }
+}
+#endif
+
+#if defined(SCM_TIMESTAMPNS) /* GNU/Linux */
+static int
+inspect_timespec_as_abstime(int level, int optname, VALUE data, VALUE ret)
+{
+ if (RSTRING_LEN(data) == sizeof(struct timespec)) {
+ struct timespec ts;
+ struct tm tm;
+ char buf[32];
+ memcpy((char*)&ts, RSTRING_PTR(data), sizeof(ts));
+ tm = *localtime(&ts.tv_sec);
+ strftime(buf, sizeof(buf), "%Y-%m-%d %H:%M:%S", &tm);
+ rb_str_catf(ret, " %s.%09ld", buf, (long)ts.tv_nsec);
+ return 1;
+ }
+ else {
+ return 0;
+ }
+}
+#endif
+
+#if defined(SCM_BINTIME) /* FreeBSD */
+static int
+inspect_bintime_as_abstime(int level, int optname, VALUE data, VALUE ret)
+{
+ if (RSTRING_LEN(data) == sizeof(struct bintime)) {
+ struct bintime bt;
+ struct tm tm;
+ uint64_t frac_h, frac_l;
+ uint64_t scale_h, scale_l;
+ uint64_t tmp1, tmp2;
+ uint64_t res_h, res_l;
+ char buf[32];
+ memcpy((char*)&bt, RSTRING_PTR(data), sizeof(bt));
+ tm = *localtime(&bt.sec);
+ strftime(buf, sizeof(buf), "%Y-%m-%d %H:%M:%S", &tm);
+
+ /* res_h = frac * 10**19 / 2**64 */
+
+ frac_h = bt.frac >> 32;
+ frac_l = bt.frac & 0xffffffff;
+
+ scale_h = 0x8ac72304; /* 0x8ac7230489e80000 == 10**19 */
+ scale_l = 0x89e80000;
+
+ res_h = frac_h * scale_h;
+ res_l = frac_l * scale_l;
+
+ tmp1 = frac_h * scale_l;
+ res_h += tmp1 >> 32;
+ tmp2 = res_l;
+ res_l += tmp1 & 0xffffffff;
+ if (res_l < tmp2) res_h++;
+
+ tmp1 = frac_l * scale_h;
+ res_h += tmp1 >> 32;
+ tmp2 = res_l;
+ res_l += tmp1 & 0xffffffff;
+ if (res_l < tmp2) res_h++;
+
+ rb_str_catf(ret, " %s.%019"PRIu64, buf, res_h);
+ return 1;
+ }
+ else {
+ return 0;
+ }
+}
+#endif
+
+/*
+ * call-seq:
+ * ancillarydata.inspect => string
+ *
+ * returns a string which shows ancillarydata in human-readable form.
+ *
+ * p Socket::AncillaryData.new(:INET6, :IPV6, :PKTINFO, "").inspect
+ * #=> "#<Socket::AncillaryData: INET6 IPV6 PKTINFO \"\">"
+ */
+static VALUE
+ancillary_inspect(VALUE self)
+{
+ VALUE ret;
+ int family, level, type;
+ VALUE data;
+ ID family_id, level_id, type_id;
+ VALUE vtype;
+ int inspected;
+
+ family = ancillary_family(self);
+ level = ancillary_level(self);
+ type = ancillary_type(self);
+ data = ancillary_data(self);
+
+ ret = rb_sprintf("#<%s:", rb_obj_classname(self));
+
+ family_id = rsock_intern_family_noprefix(family);
+ if (family_id)
+ rb_str_catf(ret, " %s", rb_id2name(family_id));
+ else
+ rb_str_catf(ret, " family:%d", family);
+
+ if (level == SOL_SOCKET) {
+ rb_str_cat2(ret, " SOCKET");
+
+ type_id = rsock_intern_scm_optname(type);
+ if (type_id)
+ rb_str_catf(ret, " %s", rb_id2name(type_id));
+ else
+ rb_str_catf(ret, " cmsg_type:%d", type);
+ }
+ else if (IS_IP_FAMILY(family)) {
+ level_id = rsock_intern_iplevel(level);
+ if (level_id)
+ rb_str_catf(ret, " %s", rb_id2name(level_id));
+ else
+ rb_str_catf(ret, " cmsg_level:%d", level);
+
+ vtype = ip_cmsg_type_to_sym(level, type);
+ if (SYMBOL_P(vtype))
+ rb_str_catf(ret, " %s", rb_id2name(SYM2ID(vtype)));
+ else
+ rb_str_catf(ret, " cmsg_type:%d", type);
+ }
+ else {
+ rb_str_catf(ret, " cmsg_level:%d", level);
+ rb_str_catf(ret, " cmsg_type:%d", type);
+ }
+
+ inspected = 0;
+
+ if (level == SOL_SOCKET)
+ family = AF_UNSPEC;
+
+ switch (family) {
+ case AF_UNSPEC:
+ switch (level) {
+# if defined(SOL_SOCKET)
+ case SOL_SOCKET:
+ switch (type) {
+# if defined(SCM_TIMESTAMP) /* GNU/Linux, FreeBSD, NetBSD, OpenBSD, MacOS X, Solaris */
+ case SCM_TIMESTAMP: inspected = inspect_timeval_as_abstime(level, type, data, ret); break;
+# endif
+# if defined(SCM_TIMESTAMPNS) /* GNU/Linux */
+ case SCM_TIMESTAMPNS: inspected = inspect_timespec_as_abstime(level, type, data, ret); break;
+# endif
+# if defined(SCM_BINTIME) /* FreeBSD */
+ case SCM_BINTIME: inspected = inspect_bintime_as_abstime(level, type, data, ret); break;
+# endif
+# if defined(SCM_RIGHTS) /* 4.4BSD */
+ case SCM_RIGHTS: inspected = anc_inspect_socket_rights(level, type, data, ret); break;
+# endif
+# if defined(SCM_CREDENTIALS) /* GNU/Linux */
+ case SCM_CREDENTIALS: inspected = anc_inspect_passcred_credentials(level, type, data, ret); break;
+# endif
+# if defined(INSPECT_SCM_CREDS) /* NetBSD */
+ case SCM_CREDS: inspected = anc_inspect_socket_creds(level, type, data, ret); break;
+# endif
+ }
+ break;
+# endif
+ }
+ break;
+
+ case AF_INET:
+#ifdef INET6
+ case AF_INET6:
+#endif
+ switch (level) {
+# if defined(IPPROTO_IP)
+ case IPPROTO_IP:
+ switch (type) {
+# if defined(IP_RECVDSTADDR) /* 4.4BSD */
+ case IP_RECVDSTADDR: inspected = anc_inspect_ip_recvdstaddr(level, type, data, ret); break;
+# endif
+# if defined(IP_PKTINFO) && defined(HAVE_STRUCT_IN_PKTINFO_IPI_SPEC_DST) /* GNU/Linux */
+ case IP_PKTINFO: inspected = anc_inspect_ip_pktinfo(level, type, data, ret); break;
+# endif
+ }
+ break;
+# endif
+
+# if defined(IPPROTO_IPV6)
+ case IPPROTO_IPV6:
+ switch (type) {
+# if defined(IPV6_PKTINFO) && defined(HAVE_TYPE_STRUCT_IN6_PKTINFO) /* RFC 3542 */
+ case IPV6_PKTINFO: inspected = anc_inspect_ipv6_pktinfo(level, type, data, ret); break;
+# endif
+ }
+ break;
+# endif
+ }
+ break;
+ }
+
+ if (!inspected) {
+ rb_str_cat2(ret, " ");
+ rb_str_append(ret, rb_str_dump(data));
+ }
+
+ rb_str_cat2(ret, ">");
+
+ return ret;
+}
+
+/*
+ * call-seq:
+ * ancillarydata.cmsg_is?(level, type) => true or false
+ *
+ * tests the level and type of _ancillarydata_.
+ *
+ * ancdata = Socket::AncillaryData.new(:INET6, :IPV6, :PKTINFO, "")
+ * ancdata.cmsg_is?(Socket::IPPROTO_IPV6, Socket::IPV6_PKTINFO) #=> true
+ * ancdata.cmsg_is?(:IPV6, :PKTINFO) #=> true
+ * ancdata.cmsg_is?(:IP, :PKTINFO) #=> false
+ * ancdata.cmsg_is?(:SOCKET, :RIGHTS) #=> false
+ */
+static VALUE
+ancillary_cmsg_is_p(VALUE self, VALUE vlevel, VALUE vtype)
+{
+ int family = ancillary_family(self);
+ int level = rsock_level_arg(family, vlevel);
+ int type = rsock_cmsg_type_arg(family, level, vtype);
+
+ if (ancillary_level(self) == level &&
+ ancillary_type(self) == type)
+ return Qtrue;
+ else
+ return Qfalse;
+}
+
+#endif
+
+#if defined(HAVE_SENDMSG)
+struct sendmsg_args_struct {
+ int fd;
+ int flags;
+ const struct msghdr *msg;
+};
+
+static void *
+nogvl_sendmsg_func(void *ptr)
+{
+ struct sendmsg_args_struct *args = ptr;
+ return (void *)(VALUE)sendmsg(args->fd, args->msg, args->flags);
+}
+
+static ssize_t
+rb_sendmsg(int fd, const struct msghdr *msg, int flags)
+{
+ struct sendmsg_args_struct args;
+ args.fd = fd;
+ args.msg = msg;
+ args.flags = flags;
+ return (ssize_t)rb_thread_call_without_gvl(nogvl_sendmsg_func, &args, RUBY_UBF_IO, 0);
+}
+
+static VALUE
+bsock_sendmsg_internal(int argc, VALUE *argv, VALUE sock, int nonblock)
+{
+ rb_io_t *fptr;
+ VALUE data, vflags, dest_sockaddr;
+ int controls_num;
+ struct msghdr mh;
+ struct iovec iov;
+#if defined(HAVE_STRUCT_MSGHDR_MSG_CONTROL)
+ VALUE controls_str = 0;
+ VALUE *controls_ptr = NULL;
+ int family;
+#endif
+ int flags;
+ ssize_t ss;
+
+ GetOpenFile(sock, fptr);
+#if defined(HAVE_STRUCT_MSGHDR_MSG_CONTROL)
+ family = rsock_getfamily(fptr->fd);
+#endif
+
+ data = vflags = dest_sockaddr = Qnil;
+
+ if (argc == 0)
+ rb_raise(rb_eArgError, "mesg argument required");
+ data = argv[0];
+ if (1 < argc) vflags = argv[1];
+ if (2 < argc) dest_sockaddr = argv[2];
+ controls_num = 3 < argc ? argc - 3 : 0;
+#if defined(HAVE_STRUCT_MSGHDR_MSG_CONTROL)
+ if (3 < argc) { controls_ptr = &argv[3]; }
+#endif
+
+ StringValue(data);
+
+ if (controls_num) {
+#if defined(HAVE_STRUCT_MSGHDR_MSG_CONTROL)
+ int i;
+ size_t last_pad = 0;
+#if defined(__NetBSD__)
+ int last_level = 0;
+ int last_type = 0;
+#endif
+ controls_str = rb_str_tmp_new(0);
+ for (i = 0; i < controls_num; i++) {
+ VALUE elt = controls_ptr[i], v;
+ VALUE vlevel, vtype;
+ int level, type;
+ VALUE cdata;
+ long oldlen;
+ struct cmsghdr cmh;
+ char *cmsg;
+ size_t cspace;
+ v = rb_check_convert_type(elt, T_ARRAY, "Array", "to_ary");
+ if (!NIL_P(v)) {
+ elt = v;
+ if (RARRAY_LEN(elt) != 3)
+ rb_raise(rb_eArgError, "an element of controls should be 3-elements array");
+ vlevel = rb_ary_entry(elt, 0);
+ vtype = rb_ary_entry(elt, 1);
+ cdata = rb_ary_entry(elt, 2);
+ }
+ else {
+ vlevel = rb_funcall(elt, rb_intern("level"), 0);
+ vtype = rb_funcall(elt, rb_intern("type"), 0);
+ cdata = rb_funcall(elt, rb_intern("data"), 0);
+ }
+ level = rsock_level_arg(family, vlevel);
+ type = rsock_cmsg_type_arg(family, level, vtype);
+ StringValue(cdata);
+ oldlen = RSTRING_LEN(controls_str);
+ cspace = CMSG_SPACE(RSTRING_LEN(cdata));
+ rb_str_resize(controls_str, oldlen + cspace);
+ cmsg = RSTRING_PTR(controls_str)+oldlen;
+ memset((char *)cmsg, 0, cspace);
+ memset((char *)&cmh, 0, sizeof(cmh));
+ cmh.cmsg_level = level;
+ cmh.cmsg_type = type;
+ cmh.cmsg_len = (socklen_t)CMSG_LEN(RSTRING_LEN(cdata));
+ MEMCPY(cmsg, &cmh, char, sizeof(cmh));
+ MEMCPY(cmsg+((char*)CMSG_DATA(&cmh)-(char*)&cmh), RSTRING_PTR(cdata), char, RSTRING_LEN(cdata));
+#if defined(__NetBSD__)
+ last_level = cmh.cmsg_level;
+ last_type = cmh.cmsg_type;
+#endif
+ last_pad = cspace - cmh.cmsg_len;
+ }
+ if (last_pad) {
+ /*
+ * This code removes the last padding from msg_controllen.
+ *
+ * 4.3BSD-Reno reject the padding for SCM_RIGHTS. (There was no 64bit environments in those days?)
+ * RFC 2292 require the padding.
+ * RFC 3542 relaxes the condition - implementation must accept both as valid.
+ *
+ * Actual problems:
+ *
+ * - NetBSD 4.0.1
+ * SCM_RIGHTS with padding causes EINVAL
+ * IPV6_PKTINFO without padding causes "page fault trap"
+ * http://www.netbsd.org/cgi-bin/query-pr-single.pl?number=40661
+ *
+ * - OpenBSD 4.4
+ * IPV6_PKTINFO without padding causes EINVAL
+ *
+ * Basically, msg_controllen should contains the padding.
+ * So the padding is removed only if a problem really exists.
+ */
+#if defined(__NetBSD__)
+ if (last_level == SOL_SOCKET && last_type == SCM_RIGHTS)
+ rb_str_set_len(controls_str, RSTRING_LEN(controls_str)-last_pad);
+#endif
+ }
+#else
+ rb_raise(rb_eNotImpError, "control message for sendmsg is unimplemented");
+#endif
+ }
+
+ flags = NIL_P(vflags) ? 0 : NUM2INT(vflags);
+#ifdef MSG_DONTWAIT
+ if (nonblock)
+ flags |= MSG_DONTWAIT;
+#endif
+
+ if (!NIL_P(dest_sockaddr))
+ SockAddrStringValue(dest_sockaddr);
+
+ rb_io_check_closed(fptr);
+
+ retry:
+ memset(&mh, 0, sizeof(mh));
+ if (!NIL_P(dest_sockaddr)) {
+ mh.msg_name = RSTRING_PTR(dest_sockaddr);
+ mh.msg_namelen = RSTRING_SOCKLEN(dest_sockaddr);
+ }
+ mh.msg_iovlen = 1;
+ mh.msg_iov = &iov;
+ iov.iov_base = RSTRING_PTR(data);
+ iov.iov_len = RSTRING_LEN(data);
+#if defined(HAVE_STRUCT_MSGHDR_MSG_CONTROL)
+ if (controls_str) {
+ mh.msg_control = RSTRING_PTR(controls_str);
+ mh.msg_controllen = RSTRING_SOCKLEN(controls_str);
+ }
+ else {
+ mh.msg_control = NULL;
+ mh.msg_controllen = 0;
+ }
+#endif
+
+ rb_io_check_closed(fptr);
+ if (nonblock)
+ rb_io_set_nonblock(fptr);
+
+ ss = rb_sendmsg(fptr->fd, &mh, flags);
+
+ if (ss == -1) {
+ if (!nonblock && rb_io_wait_writable(fptr->fd)) {
+ rb_io_check_closed(fptr);
+ goto retry;
+ }
+ if (nonblock && (errno == EWOULDBLOCK || errno == EAGAIN))
+ rb_readwrite_sys_fail(RB_IO_WAIT_WRITABLE, "sendmsg(2) would block");
+ rb_sys_fail("sendmsg(2)");
+ }
+#if defined(HAVE_STRUCT_MSGHDR_MSG_CONTROL)
+ RB_GC_GUARD(controls_str);
+#endif
+
+ return SSIZET2NUM(ss);
+}
+#endif
+
+#if defined(HAVE_SENDMSG)
+/*
+ * call-seq:
+ * basicsocket.sendmsg(mesg, flags=0, dest_sockaddr=nil, *controls) => numbytes_sent
+ *
+ * sendmsg sends a message using sendmsg(2) system call in blocking manner.
+ *
+ * _mesg_ is a string to send.
+ *
+ * _flags_ is bitwise OR of MSG_* constants such as Socket::MSG_OOB.
+ *
+ * _dest_sockaddr_ is a destination socket address for connection-less socket.
+ * It should be a sockaddr such as a result of Socket.sockaddr_in.
+ * An Addrinfo object can be used too.
+ *
+ * _controls_ is a list of ancillary data.
+ * The element of _controls_ should be Socket::AncillaryData or
+ * 3-elements array.
+ * The 3-element array should contains cmsg_level, cmsg_type and data.
+ *
+ * The return value, _numbytes_sent_ is an integer which is the number of bytes sent.
+ *
+ * sendmsg can be used to implement send_io as follows:
+ *
+ * # use Socket::AncillaryData.
+ * ancdata = Socket::AncillaryData.int(:UNIX, :SOCKET, :RIGHTS, io.fileno)
+ * sock.sendmsg("a", 0, nil, ancdata)
+ *
+ * # use 3-element array.
+ * ancdata = [:SOCKET, :RIGHTS, [io.fileno].pack("i!")]
+ * sock.sendmsg("\0", 0, nil, ancdata)
+ *
+ */
+VALUE
+rsock_bsock_sendmsg(int argc, VALUE *argv, VALUE sock)
+{
+ return bsock_sendmsg_internal(argc, argv, sock, 0);
+}
+#endif
+
+#if defined(HAVE_SENDMSG)
+/*
+ * call-seq:
+ * basicsocket.sendmsg_nonblock(mesg, flags=0, dest_sockaddr=nil, *controls) => numbytes_sent
+ *
+ * sendmsg_nonblock sends a message using sendmsg(2) system call in non-blocking manner.
+ *
+ * It is similar to BasicSocket#sendmsg
+ * but the non-blocking flag is set before the system call
+ * and it doesn't retry the system call.
+ *
+ */
+VALUE
+rsock_bsock_sendmsg_nonblock(int argc, VALUE *argv, VALUE sock)
+{
+ return bsock_sendmsg_internal(argc, argv, sock, 1);
+}
+#endif
+
+#if defined(HAVE_RECVMSG)
+struct recvmsg_args_struct {
+ int fd;
+ int flags;
+ struct msghdr *msg;
+};
+
+ssize_t
+rsock_recvmsg(int socket, struct msghdr *message, int flags)
+{
+ ssize_t ret;
+ socklen_t len0;
+#ifdef MSG_CMSG_CLOEXEC
+ /* MSG_CMSG_CLOEXEC is available since Linux 2.6.23. Linux 2.6.18 silently ignore it. */
+ flags |= MSG_CMSG_CLOEXEC;
+#endif
+ len0 = message->msg_namelen;
+ ret = recvmsg(socket, message, flags);
+ if (ret != -1 && len0 < message->msg_namelen)
+ message->msg_namelen = len0;
+ return ret;
+}
+
+static void *
+nogvl_recvmsg_func(void *ptr)
+{
+ struct recvmsg_args_struct *args = ptr;
+ int flags = args->flags;
+ return (void *)rsock_recvmsg(args->fd, args->msg, flags);
+}
+
+static ssize_t
+rb_recvmsg(int fd, struct msghdr *msg, int flags)
+{
+ struct recvmsg_args_struct args;
+ args.fd = fd;
+ args.msg = msg;
+ args.flags = flags;
+ return (ssize_t)rb_thread_call_without_gvl(nogvl_recvmsg_func, &args, RUBY_UBF_IO, 0);
+}
+
+#if defined(HAVE_STRUCT_MSGHDR_MSG_CONTROL)
+static void
+discard_cmsg(struct cmsghdr *cmh, char *msg_end, int msg_peek_p)
+{
+# if !defined(FD_PASSING_WORK_WITH_RECVMSG_MSG_PEEK)
+ /*
+ * FreeBSD 8.2.0, NetBSD 5 and MacOS X Snow Leopard doesn't
+ * allocate fds by recvmsg with MSG_PEEK.
+ * [ruby-dev:44189]
+ * http://bugs.ruby-lang.org/issues/5075
+ *
+ * Linux 2.6.38 allocate fds by recvmsg with MSG_PEEK.
+ */
+ if (msg_peek_p)
+ return;
+# endif
+ if (cmh->cmsg_level == SOL_SOCKET && cmh->cmsg_type == SCM_RIGHTS) {
+ int *fdp = (int *)CMSG_DATA(cmh);
+ int *end = (int *)((char *)cmh + cmh->cmsg_len);
+ while ((char *)fdp + sizeof(int) <= (char *)end &&
+ (char *)fdp + sizeof(int) <= msg_end) {
+ rb_update_max_fd(*fdp);
+ close(*fdp);
+ fdp++;
+ }
+ }
+}
+#endif
+
+void
+rsock_discard_cmsg_resource(struct msghdr *mh, int msg_peek_p)
+{
+#if defined(HAVE_STRUCT_MSGHDR_MSG_CONTROL)
+ struct cmsghdr *cmh;
+ char *msg_end;
+
+ if (mh->msg_controllen == 0)
+ return;
+
+ msg_end = (char *)mh->msg_control + mh->msg_controllen;
+
+ for (cmh = CMSG_FIRSTHDR(mh); cmh != NULL; cmh = CMSG_NXTHDR(mh, cmh)) {
+ discard_cmsg(cmh, msg_end, msg_peek_p);
+ }
+#endif
+}
+
+#if defined(HAVE_STRUCT_MSGHDR_MSG_CONTROL)
+static void
+make_io_for_unix_rights(VALUE ctl, struct cmsghdr *cmh, char *msg_end)
+{
+ if (cmh->cmsg_level == SOL_SOCKET && cmh->cmsg_type == SCM_RIGHTS) {
+ int *fdp, *end;
+ VALUE ary = rb_ary_new();
+ rb_ivar_set(ctl, rb_intern("unix_rights"), ary);
+ fdp = (int *)CMSG_DATA(cmh);
+ end = (int *)((char *)cmh + cmh->cmsg_len);
+ while ((char *)fdp + sizeof(int) <= (char *)end &&
+ (char *)fdp + sizeof(int) <= msg_end) {
+ int fd = *fdp;
+ struct stat stbuf;
+ VALUE io;
+ if (fstat(fd, &stbuf) == -1)
+ rb_raise(rb_eSocket, "invalid fd in SCM_RIGHTS");
+ rb_update_max_fd(fd);
+ if (rsock_cmsg_cloexec_state < 0)
+ rsock_cmsg_cloexec_state = rsock_detect_cloexec(fd);
+ if (rsock_cmsg_cloexec_state == 0 || fd <= 2)
+ rb_maygvl_fd_fix_cloexec(fd);
+ if (S_ISSOCK(stbuf.st_mode))
+ io = rsock_init_sock(rb_obj_alloc(rb_cSocket), fd);
+ else
+ io = rb_io_fdopen(fd, O_RDWR, NULL);
+ ary = rb_attr_get(ctl, rb_intern("unix_rights"));
+ rb_ary_push(ary, io);
+ fdp++;
+ }
+ OBJ_FREEZE(ary);
+ }
+}
+#endif
+
+static VALUE
+bsock_recvmsg_internal(int argc, VALUE *argv, VALUE sock, int nonblock)
+{
+ rb_io_t *fptr;
+ VALUE vmaxdatlen, vmaxctllen, vflags;
+ VALUE vopts;
+ int grow_buffer;
+ size_t maxdatlen;
+ int flags, orig_flags;
+ struct msghdr mh;
+ struct iovec iov;
+ union_sockaddr namebuf;
+ char datbuf0[4096], *datbuf;
+ VALUE dat_str = Qnil;
+ VALUE ret;
+ ssize_t ss;
+ int request_scm_rights;
+#if defined(HAVE_STRUCT_MSGHDR_MSG_CONTROL)
+ struct cmsghdr *cmh;
+ size_t maxctllen;
+ union {
+ char bytes[4096];
+ struct cmsghdr align;
+ } ctlbuf0;
+ char *ctlbuf;
+ VALUE ctl_str = Qnil;
+ int family;
+ int gc_done = 0;
+#endif
+
+
+ rb_scan_args(argc, argv, "03:", &vmaxdatlen, &vflags, &vmaxctllen, &vopts);
+
+ maxdatlen = NIL_P(vmaxdatlen) ? sizeof(datbuf0) : NUM2SIZET(vmaxdatlen);
+#if defined(HAVE_STRUCT_MSGHDR_MSG_CONTROL)
+ maxctllen = NIL_P(vmaxctllen) ? sizeof(ctlbuf0) : NUM2SIZET(vmaxctllen);
+#else
+ if (!NIL_P(vmaxctllen))
+ rb_raise(rb_eArgError, "control message not supported");
+#endif
+ flags = NIL_P(vflags) ? 0 : NUM2INT(vflags);
+#ifdef MSG_DONTWAIT
+ if (nonblock)
+ flags |= MSG_DONTWAIT;
+#endif
+ orig_flags = flags;
+
+ grow_buffer = NIL_P(vmaxdatlen) || NIL_P(vmaxctllen);
+
+ request_scm_rights = 0;
+ if (!NIL_P(vopts) && RTEST(rb_hash_aref(vopts, ID2SYM(rb_intern("scm_rights")))))
+ request_scm_rights = 1;
+#if !defined(HAVE_STRUCT_MSGHDR_MSG_CONTROL)
+ if (request_scm_rights)
+ rb_raise(rb_eNotImpError, "control message for recvmsg is unimplemented");
+#endif
+
+ GetOpenFile(sock, fptr);
+ if (rb_io_read_pending(fptr)) {
+ rb_raise(rb_eIOError, "recvmsg for buffered IO");
+ }
+
+#if !defined(HAVE_STRUCT_MSGHDR_MSG_CONTROL)
+ if (grow_buffer) {
+ int socktype;
+ socklen_t optlen = (socklen_t)sizeof(socktype);
+ if (getsockopt(fptr->fd, SOL_SOCKET, SO_TYPE, (void*)&socktype, &optlen) == -1) {
+ rb_sys_fail("getsockopt(SO_TYPE)");
+ }
+ if (socktype == SOCK_STREAM)
+ grow_buffer = 0;
+ }
+#endif
+
+ retry:
+ if (maxdatlen <= sizeof(datbuf0))
+ datbuf = datbuf0;
+ else {
+ if (NIL_P(dat_str))
+ dat_str = rb_str_tmp_new(maxdatlen);
+ else
+ rb_str_resize(dat_str, maxdatlen);
+ datbuf = RSTRING_PTR(dat_str);
+ }
+
+#if defined(HAVE_STRUCT_MSGHDR_MSG_CONTROL)
+ if (maxctllen <= sizeof(ctlbuf0))
+ ctlbuf = ctlbuf0.bytes;
+ else {
+ if (NIL_P(ctl_str))
+ ctl_str = rb_str_tmp_new(maxctllen);
+ else
+ rb_str_resize(ctl_str, maxctllen);
+ ctlbuf = RSTRING_PTR(ctl_str);
+ }
+#endif
+
+ memset(&mh, 0, sizeof(mh));
+
+ memset(&namebuf, 0, sizeof(namebuf));
+ mh.msg_name = &namebuf.addr;
+ mh.msg_namelen = (socklen_t)sizeof(namebuf);
+
+ mh.msg_iov = &iov;
+ mh.msg_iovlen = 1;
+ iov.iov_base = datbuf;
+ iov.iov_len = maxdatlen;
+
+#if defined(HAVE_STRUCT_MSGHDR_MSG_CONTROL)
+ mh.msg_control = ctlbuf;
+ mh.msg_controllen = (socklen_t)maxctllen;
+#endif
+
+ if (grow_buffer)
+ flags |= MSG_PEEK;
+
+ rb_io_check_closed(fptr);
+ if (nonblock)
+ rb_io_set_nonblock(fptr);
+
+ ss = rb_recvmsg(fptr->fd, &mh, flags);
+
+ if (ss == -1) {
+ if (!nonblock && rb_io_wait_readable(fptr->fd)) {
+ rb_io_check_closed(fptr);
+ goto retry;
+ }
+ if (nonblock && (errno == EWOULDBLOCK || errno == EAGAIN))
+ rb_readwrite_sys_fail(RB_IO_WAIT_READABLE, "recvmsg(2) would block");
+#if defined(HAVE_STRUCT_MSGHDR_MSG_CONTROL)
+ if (!gc_done && (errno == EMFILE || errno == EMSGSIZE)) {
+ /*
+ * When SCM_RIGHTS hit the file descriptors limit:
+ * - Linux 2.6.18 causes success with MSG_CTRUNC
+ * - MacOS X 10.4 causes EMSGSIZE (and lost file descriptors?)
+ * - Solaris 11 causes EMFILE
+ */
+ gc_and_retry:
+ rb_gc();
+ gc_done = 1;
+ goto retry;
+ }
+#endif
+ rb_sys_fail("recvmsg(2)");
+ }
+
+ if (grow_buffer) {
+ int grown = 0;
+#if defined(HAVE_STRUCT_MSGHDR_MSG_CONTROL)
+ if (NIL_P(vmaxdatlen) && (mh.msg_flags & MSG_TRUNC)) {
+ if (SIZE_MAX/2 < maxdatlen)
+ rb_raise(rb_eArgError, "max data length too big");
+ maxdatlen *= 2;
+ grown = 1;
+ }
+ if (NIL_P(vmaxctllen) && (mh.msg_flags & MSG_CTRUNC)) {
+#define BIG_ENOUGH_SPACE 65536
+ if (BIG_ENOUGH_SPACE < maxctllen &&
+ (socklen_t)mh.msg_controllen < (socklen_t)(maxctllen - BIG_ENOUGH_SPACE)) {
+ /* there are big space bug truncated.
+ * file descriptors limit? */
+ if (!gc_done) {
+ rsock_discard_cmsg_resource(&mh, (flags & MSG_PEEK) != 0);
+ goto gc_and_retry;
+ }
+ }
+ else {
+ if (SIZE_MAX/2 < maxctllen)
+ rb_raise(rb_eArgError, "max control message length too big");
+ maxctllen *= 2;
+ grown = 1;
+ }
+#undef BIG_ENOUGH_SPACE
+ }
+#else
+ if (NIL_P(vmaxdatlen) && ss != -1 && ss == (ssize_t)iov.iov_len) {
+ if (SIZE_MAX/2 < maxdatlen)
+ rb_raise(rb_eArgError, "max data length too big");
+ maxdatlen *= 2;
+ grown = 1;
+ }
+#endif
+ if (grown) {
+ rsock_discard_cmsg_resource(&mh, (flags & MSG_PEEK) != 0);
+ goto retry;
+ }
+ else {
+ grow_buffer = 0;
+ if (flags != orig_flags) {
+ rsock_discard_cmsg_resource(&mh, (flags & MSG_PEEK) != 0);
+ flags = orig_flags;
+ goto retry;
+ }
+ }
+ }
+
+ if (NIL_P(dat_str))
+ dat_str = rb_tainted_str_new(datbuf, ss);
+ else {
+ rb_str_resize(dat_str, ss);
+ OBJ_TAINT(dat_str);
+ rb_obj_reveal(dat_str, rb_cString);
+ }
+
+ ret = rb_ary_new3(3, dat_str,
+ rsock_io_socket_addrinfo(sock, mh.msg_name, mh.msg_namelen),
+#if defined(HAVE_STRUCT_MSGHDR_MSG_CONTROL)
+ INT2NUM(mh.msg_flags)
+#else
+ Qnil
+#endif
+ );
+
+#if defined(HAVE_STRUCT_MSGHDR_MSG_CONTROL)
+ family = rsock_getfamily(fptr->fd);
+ if (mh.msg_controllen) {
+ char *msg_end = (char *)mh.msg_control + mh.msg_controllen;
+ for (cmh = CMSG_FIRSTHDR(&mh); cmh != NULL; cmh = CMSG_NXTHDR(&mh, cmh)) {
+ VALUE ctl;
+ char *ctl_end;
+ size_t clen;
+ if (cmh->cmsg_len == 0) {
+ rb_raise(rb_eTypeError, "invalid control message (cmsg_len == 0)");
+ }
+ ctl_end = (char*)cmh + cmh->cmsg_len;
+ clen = (ctl_end <= msg_end ? ctl_end : msg_end) - (char*)CMSG_DATA(cmh);
+ ctl = ancdata_new(family, cmh->cmsg_level, cmh->cmsg_type, rb_tainted_str_new((char*)CMSG_DATA(cmh), clen));
+ if (request_scm_rights)
+ make_io_for_unix_rights(ctl, cmh, msg_end);
+ else
+ discard_cmsg(cmh, msg_end, (flags & MSG_PEEK) != 0);
+ rb_ary_push(ret, ctl);
+ }
+ RB_GC_GUARD(ctl_str);
+ }
+#endif
+
+ return ret;
+}
+#endif
+
+#if defined(HAVE_RECVMSG)
+/*
+ * call-seq:
+ * basicsocket.recvmsg(maxmesglen=nil, flags=0, maxcontrollen=nil, opts={}) => [mesg, sender_addrinfo, rflags, *controls]
+ *
+ * recvmsg receives a message using recvmsg(2) system call in blocking manner.
+ *
+ * _maxmesglen_ is the maximum length of mesg to receive.
+ *
+ * _flags_ is bitwise OR of MSG_* constants such as Socket::MSG_PEEK.
+ *
+ * _maxcontrollen_ is the maximum length of controls (ancillary data) to receive.
+ *
+ * _opts_ is option hash.
+ * Currently :scm_rights=>bool is the only option.
+ *
+ * :scm_rights option specifies that application expects SCM_RIGHTS control message.
+ * If the value is nil or false, application don't expects SCM_RIGHTS control message.
+ * In this case, recvmsg closes the passed file descriptors immediately.
+ * This is the default behavior.
+ *
+ * If :scm_rights value is neither nil nor false, application expects SCM_RIGHTS control message.
+ * In this case, recvmsg creates IO objects for each file descriptors for
+ * Socket::AncillaryData#unix_rights method.
+ *
+ * The return value is 4-elements array.
+ *
+ * _mesg_ is a string of the received message.
+ *
+ * _sender_addrinfo_ is a sender socket address for connection-less socket.
+ * It is an Addrinfo object.
+ * For connection-oriented socket such as TCP, sender_addrinfo is platform dependent.
+ *
+ * _rflags_ is a flags on the received message which is bitwise OR of MSG_* constants such as Socket::MSG_TRUNC.
+ * It will be nil if the system uses 4.3BSD style old recvmsg system call.
+ *
+ * _controls_ is ancillary data which is an array of Socket::AncillaryData objects such as:
+ *
+ * #<Socket::AncillaryData: AF_UNIX SOCKET RIGHTS 7>
+ *
+ * _maxmesglen_ and _maxcontrollen_ can be nil.
+ * In that case, the buffer will be grown until the message is not truncated.
+ * Internally, MSG_PEEK is used and MSG_TRUNC/MSG_CTRUNC are checked.
+ *
+ * recvmsg can be used to implement recv_io as follows:
+ *
+ * mesg, sender_sockaddr, rflags, *controls = sock.recvmsg(:scm_rights=>true)
+ * controls.each {|ancdata|
+ * if ancdata.cmsg_is?(:SOCKET, :RIGHTS)
+ * return ancdata.unix_rights[0]
+ * end
+ * }
+ *
+ */
+VALUE
+rsock_bsock_recvmsg(int argc, VALUE *argv, VALUE sock)
+{
+ return bsock_recvmsg_internal(argc, argv, sock, 0);
+}
+#endif
+
+#if defined(HAVE_RECVMSG)
+/*
+ * call-seq:
+ * basicsocket.recvmsg_nonblock(maxdatalen=nil, flags=0, maxcontrollen=nil, opts={}) => [data, sender_addrinfo, rflags, *controls]
+ *
+ * recvmsg receives a message using recvmsg(2) system call in non-blocking manner.
+ *
+ * It is similar to BasicSocket#recvmsg
+ * but non-blocking flag is set before the system call
+ * and it doesn't retry the system call.
+ *
+ */
+VALUE
+rsock_bsock_recvmsg_nonblock(int argc, VALUE *argv, VALUE sock)
+{
+ return bsock_recvmsg_internal(argc, argv, sock, 1);
+}
+#endif
+
+void
+rsock_init_ancdata(void)
+{
+#if defined(HAVE_STRUCT_MSGHDR_MSG_CONTROL)
+ /*
+ * Document-class: Socket::AncillaryData
+ *
+ * Socket::AncillaryData represents the ancillary data (control information)
+ * used by sendmsg and recvmsg system call. It contains socket #family,
+ * control message (cmsg) #level, cmsg #type and cmsg #data.
+ */
+ rb_cAncillaryData = rb_define_class_under(rb_cSocket, "AncillaryData", rb_cObject);
+ rb_define_method(rb_cAncillaryData, "initialize", ancillary_initialize, 4);
+ rb_define_method(rb_cAncillaryData, "inspect", ancillary_inspect, 0);
+ rb_define_method(rb_cAncillaryData, "family", ancillary_family_m, 0);
+ rb_define_method(rb_cAncillaryData, "level", ancillary_level_m, 0);
+ rb_define_method(rb_cAncillaryData, "type", ancillary_type_m, 0);
+ rb_define_method(rb_cAncillaryData, "data", ancillary_data, 0);
+
+ rb_define_method(rb_cAncillaryData, "cmsg_is?", ancillary_cmsg_is_p, 2);
+
+ rb_define_singleton_method(rb_cAncillaryData, "int", ancillary_s_int, 4);
+ rb_define_method(rb_cAncillaryData, "int", ancillary_int, 0);
+
+ rb_define_singleton_method(rb_cAncillaryData, "unix_rights", ancillary_s_unix_rights, -1);
+ rb_define_method(rb_cAncillaryData, "unix_rights", ancillary_unix_rights, 0);
+
+ rb_define_method(rb_cAncillaryData, "timestamp", ancillary_timestamp, 0);
+
+ rb_define_singleton_method(rb_cAncillaryData, "ip_pktinfo", ancillary_s_ip_pktinfo, -1);
+ rb_define_method(rb_cAncillaryData, "ip_pktinfo", ancillary_ip_pktinfo, 0);
+
+ rb_define_singleton_method(rb_cAncillaryData, "ipv6_pktinfo", ancillary_s_ipv6_pktinfo, 2);
+ rb_define_method(rb_cAncillaryData, "ipv6_pktinfo", ancillary_ipv6_pktinfo, 0);
+ rb_define_method(rb_cAncillaryData, "ipv6_pktinfo_addr", ancillary_ipv6_pktinfo_addr, 0);
+ rb_define_method(rb_cAncillaryData, "ipv6_pktinfo_ifindex", ancillary_ipv6_pktinfo_ifindex, 0);
+#endif
+}
diff --git a/jni/ruby/ext/socket/basicsocket.c b/jni/ruby/ext/socket/basicsocket.c
new file mode 100644
index 0000000..5455977
--- /dev/null
+++ b/jni/ruby/ext/socket/basicsocket.c
@@ -0,0 +1,767 @@
+/************************************************
+
+ basicsocket.c -
+
+ created at: Thu Mar 31 12:21:29 JST 1994
+
+ Copyright (C) 1993-2007 Yukihiro Matsumoto
+
+************************************************/
+
+#include "rubysocket.h"
+
+/*
+ * call-seq:
+ * BasicSocket.for_fd(fd) => basicsocket
+ *
+ * Returns a socket object which contains the file descriptor, _fd_.
+ *
+ * # If invoked by inetd, STDIN/STDOUT/STDERR is a socket.
+ * STDIN_SOCK = Socket.for_fd(STDIN.fileno)
+ * p STDIN_SOCK.remote_address
+ *
+ */
+static VALUE
+bsock_s_for_fd(VALUE klass, VALUE fd)
+{
+ rb_io_t *fptr;
+ VALUE sock = rsock_init_sock(rb_obj_alloc(klass), NUM2INT(fd));
+
+ GetOpenFile(sock, fptr);
+
+ return sock;
+}
+
+/*
+ * call-seq:
+ * basicsocket.shutdown([how]) => 0
+ *
+ * Calls shutdown(2) system call.
+ *
+ * s.shutdown(Socket::SHUT_RD) disallows further read.
+ *
+ * s.shutdown(Socket::SHUT_WR) disallows further write.
+ *
+ * s.shutdown(Socket::SHUT_RDWR) disallows further read and write.
+ *
+ * _how_ can be symbol or string:
+ * - :RD, :SHUT_RD, "RD" and "SHUT_RD" are accepted as Socket::SHUT_RD.
+ * - :WR, :SHUT_WR, "WR" and "SHUT_WR" are accepted as Socket::SHUT_WR.
+ * - :RDWR, :SHUT_RDWR, "RDWR" and "SHUT_RDWR" are accepted as Socket::SHUT_RDWR.
+ *
+ * UNIXSocket.pair {|s1, s2|
+ * s1.puts "ping"
+ * s1.shutdown(:WR)
+ * p s2.read #=> "ping\n"
+ * s2.puts "pong"
+ * s2.close
+ * p s1.read #=> "pong\n"
+ * }
+ *
+ */
+static VALUE
+bsock_shutdown(int argc, VALUE *argv, VALUE sock)
+{
+ VALUE howto;
+ int how;
+ rb_io_t *fptr;
+
+ rb_scan_args(argc, argv, "01", &howto);
+ if (howto == Qnil)
+ how = SHUT_RDWR;
+ else {
+ how = rsock_shutdown_how_arg(howto);
+ if (how != SHUT_WR && how != SHUT_RD && how != SHUT_RDWR) {
+ rb_raise(rb_eArgError, "`how' should be either :SHUT_RD, :SHUT_WR, :SHUT_RDWR");
+ }
+ }
+ GetOpenFile(sock, fptr);
+ if (shutdown(fptr->fd, how) == -1)
+ rb_sys_fail("shutdown(2)");
+
+ return INT2FIX(0);
+}
+
+/*
+ * call-seq:
+ * basicsocket.close_read => nil
+ *
+ * Disallows further read using shutdown system call.
+ *
+ * s1, s2 = UNIXSocket.pair
+ * s1.close_read
+ * s2.puts #=> Broken pipe (Errno::EPIPE)
+ */
+static VALUE
+bsock_close_read(VALUE sock)
+{
+ rb_io_t *fptr;
+
+ GetOpenFile(sock, fptr);
+ shutdown(fptr->fd, 0);
+ if (!(fptr->mode & FMODE_WRITABLE)) {
+ return rb_io_close(sock);
+ }
+ fptr->mode &= ~FMODE_READABLE;
+
+ return Qnil;
+}
+
+/*
+ * call-seq:
+ * basicsocket.close_write => nil
+ *
+ * Disallows further write using shutdown system call.
+ *
+ * UNIXSocket.pair {|s1, s2|
+ * s1.print "ping"
+ * s1.close_write
+ * p s2.read #=> "ping"
+ * s2.print "pong"
+ * s2.close
+ * p s1.read #=> "pong"
+ * }
+ */
+static VALUE
+bsock_close_write(VALUE sock)
+{
+ rb_io_t *fptr;
+
+ GetOpenFile(sock, fptr);
+ if (!(fptr->mode & FMODE_READABLE)) {
+ return rb_io_close(sock);
+ }
+ shutdown(fptr->fd, 1);
+ fptr->mode &= ~FMODE_WRITABLE;
+
+ return Qnil;
+}
+
+/*
+ * Document-method: setsockopt
+ * call-seq:
+ * setsockopt(level, optname, optval)
+ * setsockopt(socketoption)
+ *
+ * Sets a socket option. These are protocol and system specific, see your
+ * local system documentation for details.
+ *
+ * === Parameters
+ * * +level+ is an integer, usually one of the SOL_ constants such as
+ * Socket::SOL_SOCKET, or a protocol level.
+ * A string or symbol of the name, possibly without prefix, is also
+ * accepted.
+ * * +optname+ is an integer, usually one of the SO_ constants, such
+ * as Socket::SO_REUSEADDR.
+ * A string or symbol of the name, possibly without prefix, is also
+ * accepted.
+ * * +optval+ is the value of the option, it is passed to the underlying
+ * setsockopt() as a pointer to a certain number of bytes. How this is
+ * done depends on the type:
+ * - Fixnum: value is assigned to an int, and a pointer to the int is
+ * passed, with length of sizeof(int).
+ * - true or false: 1 or 0 (respectively) is assigned to an int, and the
+ * int is passed as for a Fixnum. Note that +false+ must be passed,
+ * not +nil+.
+ * - String: the string's data and length is passed to the socket.
+ * * +socketoption+ is an instance of Socket::Option
+ *
+ * === Examples
+ *
+ * Some socket options are integers with boolean values, in this case
+ * #setsockopt could be called like this:
+ * sock.setsockopt(:SOCKET, :REUSEADDR, true)
+ * sock.setsockopt(Socket::SOL_SOCKET,Socket::SO_REUSEADDR, true)
+ * sock.setsockopt(Socket::Option.bool(:INET, :SOCKET, :REUSEADDR, true))
+ *
+ * Some socket options are integers with numeric values, in this case
+ * #setsockopt could be called like this:
+ * sock.setsockopt(:IP, :TTL, 255)
+ * sock.setsockopt(Socket::IPPROTO_IP, Socket::IP_TTL, 255)
+ * sock.setsockopt(Socket::Option.int(:INET, :IP, :TTL, 255))
+ *
+ * Option values may be structs. Passing them can be complex as it involves
+ * examining your system headers to determine the correct definition. An
+ * example is an +ip_mreq+, which may be defined in your system headers as:
+ * struct ip_mreq {
+ * struct in_addr imr_multiaddr;
+ * struct in_addr imr_interface;
+ * };
+ *
+ * In this case #setsockopt could be called like this:
+ * optval = IPAddr.new("224.0.0.251").hton +
+ * IPAddr.new(Socket::INADDR_ANY, Socket::AF_INET).hton
+ * sock.setsockopt(Socket::IPPROTO_IP, Socket::IP_ADD_MEMBERSHIP, optval)
+ *
+*/
+static VALUE
+bsock_setsockopt(int argc, VALUE *argv, VALUE sock)
+{
+ VALUE lev, optname, val;
+ int family, level, option;
+ rb_io_t *fptr;
+ int i;
+ char *v;
+ int vlen;
+
+ if (argc == 1) {
+ lev = rb_funcall(argv[0], rb_intern("level"), 0);
+ optname = rb_funcall(argv[0], rb_intern("optname"), 0);
+ val = rb_funcall(argv[0], rb_intern("data"), 0);
+ }
+ else {
+ rb_scan_args(argc, argv, "30", &lev, &optname, &val);
+ }
+
+ rb_secure(2);
+ GetOpenFile(sock, fptr);
+ family = rsock_getfamily(fptr->fd);
+ level = rsock_level_arg(family, lev);
+ option = rsock_optname_arg(family, level, optname);
+
+ switch (TYPE(val)) {
+ case T_FIXNUM:
+ i = FIX2INT(val);
+ goto numval;
+ case T_FALSE:
+ i = 0;
+ goto numval;
+ case T_TRUE:
+ i = 1;
+ numval:
+ v = (char*)&i; vlen = (int)sizeof(i);
+ break;
+ default:
+ StringValue(val);
+ v = RSTRING_PTR(val);
+ vlen = RSTRING_SOCKLEN(val);
+ break;
+ }
+
+ rb_io_check_closed(fptr);
+ if (setsockopt(fptr->fd, level, option, v, vlen) < 0)
+ rsock_sys_fail_path("setsockopt(2)", fptr->pathv);
+
+ return INT2FIX(0);
+}
+
+#if !defined(__BEOS__)
+/*
+ * Document-method: getsockopt
+ * call-seq:
+ * getsockopt(level, optname) => socketoption
+ *
+ * Gets a socket option. These are protocol and system specific, see your
+ * local system documentation for details. The option is returned as
+ * a Socket::Option object.
+ *
+ * === Parameters
+ * * +level+ is an integer, usually one of the SOL_ constants such as
+ * Socket::SOL_SOCKET, or a protocol level.
+ * A string or symbol of the name, possibly without prefix, is also
+ * accepted.
+ * * +optname+ is an integer, usually one of the SO_ constants, such
+ * as Socket::SO_REUSEADDR.
+ * A string or symbol of the name, possibly without prefix, is also
+ * accepted.
+ *
+ * === Examples
+ *
+ * Some socket options are integers with boolean values, in this case
+ * #getsockopt could be called like this:
+ *
+ * reuseaddr = sock.getsockopt(:SOCKET, :REUSEADDR).bool
+ *
+ * optval = sock.getsockopt(Socket::SOL_SOCKET,Socket::SO_REUSEADDR)
+ * optval = optval.unpack "i"
+ * reuseaddr = optval[0] == 0 ? false : true
+ *
+ * Some socket options are integers with numeric values, in this case
+ * #getsockopt could be called like this:
+ *
+ * ipttl = sock.getsockopt(:IP, :TTL).int
+ *
+ * optval = sock.getsockopt(Socket::IPPROTO_IP, Socket::IP_TTL)
+ * ipttl = optval.unpack("i")[0]
+ *
+ * Option values may be structs. Decoding them can be complex as it involves
+ * examining your system headers to determine the correct definition. An
+ * example is a +struct linger+, which may be defined in your system headers
+ * as:
+ * struct linger {
+ * int l_onoff;
+ * int l_linger;
+ * };
+ *
+ * In this case #getsockopt could be called like this:
+ *
+ * # Socket::Option knows linger structure.
+ * onoff, linger = sock.getsockopt(:SOCKET, :LINGER).linger
+ *
+ * optval = sock.getsockopt(Socket::SOL_SOCKET, Socket::SO_LINGER)
+ * onoff, linger = optval.unpack "ii"
+ * onoff = onoff == 0 ? false : true
+*/
+static VALUE
+bsock_getsockopt(VALUE sock, VALUE lev, VALUE optname)
+{
+ int level, option;
+ socklen_t len;
+ char *buf;
+ rb_io_t *fptr;
+ int family;
+
+ GetOpenFile(sock, fptr);
+ family = rsock_getfamily(fptr->fd);
+ level = rsock_level_arg(family, lev);
+ option = rsock_optname_arg(family, level, optname);
+ len = 256;
+ buf = ALLOCA_N(char,len);
+
+ rb_io_check_closed(fptr);
+
+ if (getsockopt(fptr->fd, level, option, buf, &len) < 0)
+ rsock_sys_fail_path("getsockopt(2)", fptr->pathv);
+
+ return rsock_sockopt_new(family, level, option, rb_str_new(buf, len));
+}
+#else
+#define bsock_getsockopt rb_f_notimplement
+#endif
+
+/*
+ * call-seq:
+ * basicsocket.getsockname => sockaddr
+ *
+ * Returns the local address of the socket as a sockaddr string.
+ *
+ * TCPServer.open("127.0.0.1", 15120) {|serv|
+ * p serv.getsockname #=> "\x02\x00;\x10\x7F\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00\x00"
+ * }
+ *
+ * If Addrinfo object is preferred over the binary string,
+ * use BasicSocket#local_address.
+ */
+static VALUE
+bsock_getsockname(VALUE sock)
+{
+ union_sockaddr buf;
+ socklen_t len = (socklen_t)sizeof buf;
+ socklen_t len0 = len;
+ rb_io_t *fptr;
+
+ GetOpenFile(sock, fptr);
+ if (getsockname(fptr->fd, &buf.addr, &len) < 0)
+ rb_sys_fail("getsockname(2)");
+ if (len0 < len) len = len0;
+ return rb_str_new((char*)&buf, len);
+}
+
+/*
+ * call-seq:
+ * basicsocket.getpeername => sockaddr
+ *
+ * Returns the remote address of the socket as a sockaddr string.
+ *
+ * TCPServer.open("127.0.0.1", 1440) {|serv|
+ * c = TCPSocket.new("127.0.0.1", 1440)
+ * s = serv.accept
+ * p s.getpeername #=> "\x02\x00\x82u\x7F\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00\x00"
+ * }
+ *
+ * If Addrinfo object is preferred over the binary string,
+ * use BasicSocket#remote_address.
+ *
+ */
+static VALUE
+bsock_getpeername(VALUE sock)
+{
+ union_sockaddr buf;
+ socklen_t len = (socklen_t)sizeof buf;
+ socklen_t len0 = len;
+ rb_io_t *fptr;
+
+ GetOpenFile(sock, fptr);
+ if (getpeername(fptr->fd, &buf.addr, &len) < 0)
+ rb_sys_fail("getpeername(2)");
+ if (len0 < len) len = len0;
+ return rb_str_new((char*)&buf, len);
+}
+
+#if defined(HAVE_GETPEEREID) || defined(SO_PEERCRED) || defined(HAVE_GETPEERUCRED)
+/*
+ * call-seq:
+ * basicsocket.getpeereid => [euid, egid]
+ *
+ * Returns the user and group on the peer of the UNIX socket.
+ * The result is a two element array which contains the effective uid and the effective gid.
+ *
+ * Socket.unix_server_loop("/tmp/sock") {|s|
+ * begin
+ * euid, egid = s.getpeereid
+ *
+ * # Check the connected client is myself or not.
+ * next if euid != Process.uid
+ *
+ * # do something about my resource.
+ *
+ * ensure
+ * s.close
+ * end
+ * }
+ *
+ */
+static VALUE
+bsock_getpeereid(VALUE self)
+{
+#if defined(HAVE_GETPEEREID)
+ rb_io_t *fptr;
+ uid_t euid;
+ gid_t egid;
+ GetOpenFile(self, fptr);
+ if (getpeereid(fptr->fd, &euid, &egid) == -1)
+ rb_sys_fail("getpeereid(3)");
+ return rb_assoc_new(UIDT2NUM(euid), GIDT2NUM(egid));
+#elif defined(SO_PEERCRED) /* GNU/Linux */
+ rb_io_t *fptr;
+ struct ucred cred;
+ socklen_t len = sizeof(cred);
+ GetOpenFile(self, fptr);
+ if (getsockopt(fptr->fd, SOL_SOCKET, SO_PEERCRED, &cred, &len) == -1)
+ rb_sys_fail("getsockopt(SO_PEERCRED)");
+ return rb_assoc_new(UIDT2NUM(cred.uid), GIDT2NUM(cred.gid));
+#elif defined(HAVE_GETPEERUCRED) /* Solaris */
+ rb_io_t *fptr;
+ ucred_t *uc = NULL;
+ VALUE ret;
+ GetOpenFile(self, fptr);
+ if (getpeerucred(fptr->fd, &uc) == -1)
+ rb_sys_fail("getpeerucred(3C)");
+ ret = rb_assoc_new(UIDT2NUM(ucred_geteuid(uc)), GIDT2NUM(ucred_getegid(uc)));
+ ucred_free(uc);
+ return ret;
+#endif
+}
+#else
+#define bsock_getpeereid rb_f_notimplement
+#endif
+
+/*
+ * call-seq:
+ * bsock.local_address => addrinfo
+ *
+ * Returns an Addrinfo object for local address obtained by getsockname.
+ *
+ * Note that addrinfo.protocol is filled by 0.
+ *
+ * TCPSocket.open("www.ruby-lang.org", 80) {|s|
+ * p s.local_address #=> #<Addrinfo: 192.168.0.129:36873 TCP>
+ * }
+ *
+ * TCPServer.open("127.0.0.1", 1512) {|serv|
+ * p serv.local_address #=> #<Addrinfo: 127.0.0.1:1512 TCP>
+ * }
+ *
+ */
+static VALUE
+bsock_local_address(VALUE sock)
+{
+ union_sockaddr buf;
+ socklen_t len = (socklen_t)sizeof buf;
+ socklen_t len0 = len;
+ rb_io_t *fptr;
+
+ GetOpenFile(sock, fptr);
+ if (getsockname(fptr->fd, &buf.addr, &len) < 0)
+ rb_sys_fail("getsockname(2)");
+ if (len0 < len) len = len0;
+ return rsock_fd_socket_addrinfo(fptr->fd, &buf.addr, len);
+}
+
+/*
+ * call-seq:
+ * bsock.remote_address => addrinfo
+ *
+ * Returns an Addrinfo object for remote address obtained by getpeername.
+ *
+ * Note that addrinfo.protocol is filled by 0.
+ *
+ * TCPSocket.open("www.ruby-lang.org", 80) {|s|
+ * p s.remote_address #=> #<Addrinfo: 221.186.184.68:80 TCP>
+ * }
+ *
+ * TCPServer.open("127.0.0.1", 1728) {|serv|
+ * c = TCPSocket.new("127.0.0.1", 1728)
+ * s = serv.accept
+ * p s.remote_address #=> #<Addrinfo: 127.0.0.1:36504 TCP>
+ * }
+ *
+ */
+static VALUE
+bsock_remote_address(VALUE sock)
+{
+ union_sockaddr buf;
+ socklen_t len = (socklen_t)sizeof buf;
+ socklen_t len0 = len;
+ rb_io_t *fptr;
+
+ GetOpenFile(sock, fptr);
+ if (getpeername(fptr->fd, &buf.addr, &len) < 0)
+ rb_sys_fail("getpeername(2)");
+ if (len0 < len) len = len0;
+ return rsock_fd_socket_addrinfo(fptr->fd, &buf.addr, len);
+}
+
+/*
+ * call-seq:
+ * basicsocket.send(mesg, flags [, dest_sockaddr]) => numbytes_sent
+ *
+ * send _mesg_ via _basicsocket_.
+ *
+ * _mesg_ should be a string.
+ *
+ * _flags_ should be a bitwise OR of Socket::MSG_* constants.
+ *
+ * _dest_sockaddr_ should be a packed sockaddr string or an addrinfo.
+ *
+ * TCPSocket.open("localhost", 80) {|s|
+ * s.send "GET / HTTP/1.0\r\n\r\n", 0
+ * p s.read
+ * }
+ */
+VALUE
+rsock_bsock_send(int argc, VALUE *argv, VALUE sock)
+{
+ struct rsock_send_arg arg;
+ VALUE flags, to;
+ rb_io_t *fptr;
+ int n;
+ rb_blocking_function_t *func;
+
+ rb_scan_args(argc, argv, "21", &arg.mesg, &flags, &to);
+
+ StringValue(arg.mesg);
+ if (!NIL_P(to)) {
+ SockAddrStringValue(to);
+ to = rb_str_new4(to);
+ arg.to = (struct sockaddr *)RSTRING_PTR(to);
+ arg.tolen = RSTRING_SOCKLEN(to);
+ func = rsock_sendto_blocking;
+ }
+ else {
+ func = rsock_send_blocking;
+ }
+ GetOpenFile(sock, fptr);
+ arg.fd = fptr->fd;
+ arg.flags = NUM2INT(flags);
+ while (rsock_maybe_fd_writable(arg.fd),
+ (n = (int)BLOCKING_REGION_FD(func, &arg)) < 0) {
+ if (rb_io_wait_writable(arg.fd)) {
+ continue;
+ }
+ rb_sys_fail("send(2)");
+ }
+ return INT2FIX(n);
+}
+
+/*
+ * call-seq:
+ * basicsocket.do_not_reverse_lookup => true or false
+ *
+ * Gets the do_not_reverse_lookup flag of _basicsocket_.
+ *
+ * TCPSocket.open("www.ruby-lang.org", 80) {|sock|
+ * p sock.do_not_reverse_lookup #=> false
+ * p sock.peeraddr #=> ["AF_INET", 80, "carbon.ruby-lang.org", "221.186.184.68"]
+ * sock.do_not_reverse_lookup = true
+ * p sock.peeraddr #=> ["AF_INET", 80, "221.186.184.68", "221.186.184.68"]
+ * }
+ */
+static VALUE
+bsock_do_not_reverse_lookup(VALUE sock)
+{
+ rb_io_t *fptr;
+
+ GetOpenFile(sock, fptr);
+ return (fptr->mode & FMODE_NOREVLOOKUP) ? Qtrue : Qfalse;
+}
+
+/*
+ * call-seq:
+ * basicsocket.do_not_reverse_lookup = bool
+ *
+ * Sets the do_not_reverse_lookup flag of _basicsocket_.
+ *
+ * BasicSocket.do_not_reverse_lookup = false
+ * p TCPSocket.new("127.0.0.1", 80).do_not_reverse_lookup #=> false
+ * BasicSocket.do_not_reverse_lookup = true
+ * p TCPSocket.new("127.0.0.1", 80).do_not_reverse_lookup #=> true
+ *
+ */
+static VALUE
+bsock_do_not_reverse_lookup_set(VALUE sock, VALUE state)
+{
+ rb_io_t *fptr;
+
+ GetOpenFile(sock, fptr);
+ if (RTEST(state)) {
+ fptr->mode |= FMODE_NOREVLOOKUP;
+ }
+ else {
+ fptr->mode &= ~FMODE_NOREVLOOKUP;
+ }
+ return sock;
+}
+
+/*
+ * call-seq:
+ * basicsocket.recv(maxlen) => mesg
+ * basicsocket.recv(maxlen, flags) => mesg
+ *
+ * Receives a message.
+ *
+ * _maxlen_ is the maximum number of bytes to receive.
+ *
+ * _flags_ should be a bitwise OR of Socket::MSG_* constants.
+ *
+ * UNIXSocket.pair {|s1, s2|
+ * s1.puts "Hello World"
+ * p s2.recv(4) #=> "Hell"
+ * p s2.recv(4, Socket::MSG_PEEK) #=> "o Wo"
+ * p s2.recv(4) #=> "o Wo"
+ * p s2.recv(10) #=> "rld\n"
+ * }
+ */
+static VALUE
+bsock_recv(int argc, VALUE *argv, VALUE sock)
+{
+ return rsock_s_recvfrom(sock, argc, argv, RECV_RECV);
+}
+
+/*
+ * call-seq:
+ * basicsocket.recv_nonblock(maxlen) => mesg
+ * basicsocket.recv_nonblock(maxlen, flags) => mesg
+ *
+ * Receives up to _maxlen_ bytes from +socket+ using recvfrom(2) after
+ * O_NONBLOCK is set for the underlying file descriptor.
+ * _flags_ is zero or more of the +MSG_+ options.
+ * The result, _mesg_, is the data received.
+ *
+ * When recvfrom(2) returns 0, Socket#recv_nonblock returns
+ * an empty string as data.
+ * The meaning depends on the socket: EOF on TCP, empty packet on UDP, etc.
+ *
+ * === Parameters
+ * * +maxlen+ - the number of bytes to receive from the socket
+ * * +flags+ - zero or more of the +MSG_+ options
+ *
+ * === Example
+ * serv = TCPServer.new("127.0.0.1", 0)
+ * af, port, host, addr = serv.addr
+ * c = TCPSocket.new(addr, port)
+ * s = serv.accept
+ * c.send "aaa", 0
+ * begin # emulate blocking recv.
+ * p s.recv_nonblock(10) #=> "aaa"
+ * rescue IO::WaitReadable
+ * IO.select([s])
+ * retry
+ * end
+ *
+ * Refer to Socket#recvfrom for the exceptions that may be thrown if the call
+ * to _recv_nonblock_ fails.
+ *
+ * BasicSocket#recv_nonblock may raise any error corresponding to recvfrom(2) failure,
+ * including Errno::EWOULDBLOCK.
+ *
+ * If the exception is Errno::EWOULDBLOCK or Errno::AGAIN,
+ * it is extended by IO::WaitReadable.
+ * So IO::WaitReadable can be used to rescue the exceptions for retrying recv_nonblock.
+ *
+ * === See
+ * * Socket#recvfrom
+ */
+
+static VALUE
+bsock_recv_nonblock(int argc, VALUE *argv, VALUE sock)
+{
+ return rsock_s_recvfrom_nonblock(sock, argc, argv, RECV_RECV);
+}
+
+/*
+ * call-seq:
+ * BasicSocket.do_not_reverse_lookup => true or false
+ *
+ * Gets the global do_not_reverse_lookup flag.
+ *
+ * BasicSocket.do_not_reverse_lookup #=> false
+ */
+static VALUE
+bsock_do_not_rev_lookup(void)
+{
+ return rsock_do_not_reverse_lookup?Qtrue:Qfalse;
+}
+
+/*
+ * call-seq:
+ * BasicSocket.do_not_reverse_lookup = bool
+ *
+ * Sets the global do_not_reverse_lookup flag.
+ *
+ * The flag is used for initial value of do_not_reverse_lookup for each socket.
+ *
+ * s1 = TCPSocket.new("localhost", 80)
+ * p s1.do_not_reverse_lookup #=> true
+ * BasicSocket.do_not_reverse_lookup = false
+ * s2 = TCPSocket.new("localhost", 80)
+ * p s2.do_not_reverse_lookup #=> false
+ * p s1.do_not_reverse_lookup #=> true
+ *
+ */
+static VALUE
+bsock_do_not_rev_lookup_set(VALUE self, VALUE val)
+{
+ rsock_do_not_reverse_lookup = RTEST(val);
+ return val;
+}
+
+void
+rsock_init_basicsocket(void)
+{
+ /*
+ * Document-class: BasicSocket < IO
+ *
+ * BasicSocket is the super class for all the Socket classes.
+ */
+ rb_cBasicSocket = rb_define_class("BasicSocket", rb_cIO);
+ rb_undef_method(rb_cBasicSocket, "initialize");
+
+ rb_define_singleton_method(rb_cBasicSocket, "do_not_reverse_lookup",
+ bsock_do_not_rev_lookup, 0);
+ rb_define_singleton_method(rb_cBasicSocket, "do_not_reverse_lookup=",
+ bsock_do_not_rev_lookup_set, 1);
+ rb_define_singleton_method(rb_cBasicSocket, "for_fd", bsock_s_for_fd, 1);
+
+ rb_define_method(rb_cBasicSocket, "close_read", bsock_close_read, 0);
+ rb_define_method(rb_cBasicSocket, "close_write", bsock_close_write, 0);
+ rb_define_method(rb_cBasicSocket, "shutdown", bsock_shutdown, -1);
+ rb_define_method(rb_cBasicSocket, "setsockopt", bsock_setsockopt, -1);
+ rb_define_method(rb_cBasicSocket, "getsockopt", bsock_getsockopt, 2);
+ rb_define_method(rb_cBasicSocket, "getsockname", bsock_getsockname, 0);
+ rb_define_method(rb_cBasicSocket, "getpeername", bsock_getpeername, 0);
+ rb_define_method(rb_cBasicSocket, "getpeereid", bsock_getpeereid, 0);
+ rb_define_method(rb_cBasicSocket, "local_address", bsock_local_address, 0);
+ rb_define_method(rb_cBasicSocket, "remote_address", bsock_remote_address, 0);
+ rb_define_method(rb_cBasicSocket, "send", rsock_bsock_send, -1);
+ rb_define_method(rb_cBasicSocket, "recv", bsock_recv, -1);
+ rb_define_method(rb_cBasicSocket, "recv_nonblock", bsock_recv_nonblock, -1);
+ rb_define_method(rb_cBasicSocket, "do_not_reverse_lookup", bsock_do_not_reverse_lookup, 0);
+ rb_define_method(rb_cBasicSocket, "do_not_reverse_lookup=", bsock_do_not_reverse_lookup_set, 1);
+
+ rb_define_method(rb_cBasicSocket, "sendmsg", rsock_bsock_sendmsg, -1); /* in ancdata.c */
+ rb_define_method(rb_cBasicSocket, "sendmsg_nonblock", rsock_bsock_sendmsg_nonblock, -1); /* in ancdata.c */
+ rb_define_method(rb_cBasicSocket, "recvmsg", rsock_bsock_recvmsg, -1); /* in ancdata.c */
+ rb_define_method(rb_cBasicSocket, "recvmsg_nonblock", rsock_bsock_recvmsg_nonblock, -1); /* in ancdata.c */
+
+}
diff --git a/jni/ruby/ext/socket/constants.c b/jni/ruby/ext/socket/constants.c
new file mode 100644
index 0000000..bab27b2
--- /dev/null
+++ b/jni/ruby/ext/socket/constants.c
@@ -0,0 +1,145 @@
+/************************************************
+
+ constants.c -
+
+ created at: Thu Mar 31 12:21:29 JST 1994
+
+ Copyright (C) 1993-2007 Yukihiro Matsumoto
+
+************************************************/
+
+#include "rubysocket.h"
+
+static VALUE rb_mSockConst;
+
+#include "constdefs.c"
+
+static int
+constant_arg(VALUE arg, int (*str_to_int)(const char*, long, int*), const char *errmsg)
+{
+ VALUE tmp;
+ char *ptr;
+ int ret;
+
+ if (SYMBOL_P(arg)) {
+ arg = rb_sym_to_s(arg);
+ goto str;
+ }
+ else if (!NIL_P(tmp = rb_check_string_type(arg))) {
+ arg = tmp;
+ str:
+ rb_check_safe_obj(arg);
+ ptr = RSTRING_PTR(arg);
+ if (str_to_int(ptr, RSTRING_LEN(arg), &ret) == -1)
+ rb_raise(rb_eSocket, "%s: %s", errmsg, ptr);
+ }
+ else {
+ ret = NUM2INT(arg);
+ }
+ return ret;
+}
+
+int
+rsock_family_arg(VALUE domain)
+{
+ /* convert AF_INET, etc. */
+ return constant_arg(domain, rsock_family_to_int, "unknown socket domain");
+}
+
+int
+rsock_socktype_arg(VALUE type)
+{
+ /* convert SOCK_STREAM, etc. */
+ return constant_arg(type, rsock_socktype_to_int, "unknown socket type");
+}
+
+int
+rsock_level_arg(int family, VALUE level)
+{
+ /* convert SOL_SOCKET, IPPROTO_TCP, etc. */
+ if (IS_IP_FAMILY(family)) {
+ return constant_arg(level, rsock_ip_level_to_int, "unknown protocol level");
+ }
+ else {
+ return constant_arg(level, rsock_unknown_level_to_int, "unknown protocol level");
+ }
+}
+
+int
+rsock_optname_arg(int family, int level, VALUE optname)
+{
+ if (IS_IP_FAMILY(family)) {
+ switch (level) {
+ case SOL_SOCKET:
+ return constant_arg(optname, rsock_so_optname_to_int, "unknown socket level option name");
+ case IPPROTO_IP:
+ return constant_arg(optname, rsock_ip_optname_to_int, "unknown IP level option name");
+#ifdef IPPROTO_IPV6
+ case IPPROTO_IPV6:
+ return constant_arg(optname, rsock_ipv6_optname_to_int, "unknown IPv6 level option name");
+#endif
+ case IPPROTO_TCP:
+ return constant_arg(optname, rsock_tcp_optname_to_int, "unknown TCP level option name");
+ case IPPROTO_UDP:
+ return constant_arg(optname, rsock_udp_optname_to_int, "unknown UDP level option name");
+ default:
+ return NUM2INT(optname);
+ }
+ }
+ else {
+ switch (level) {
+ case SOL_SOCKET:
+ return constant_arg(optname, rsock_so_optname_to_int, "unknown socket level option name");
+ default:
+ return NUM2INT(optname);
+ }
+ }
+}
+
+int
+rsock_cmsg_type_arg(int family, int level, VALUE type)
+{
+ if (IS_IP_FAMILY(family)) {
+ switch (level) {
+ case SOL_SOCKET:
+ return constant_arg(type, rsock_scm_optname_to_int, "unknown UNIX control message");
+ case IPPROTO_IP:
+ return constant_arg(type, rsock_ip_optname_to_int, "unknown IP control message");
+#ifdef IPPROTO_IPV6
+ case IPPROTO_IPV6:
+ return constant_arg(type, rsock_ipv6_optname_to_int, "unknown IPv6 control message");
+#endif
+ case IPPROTO_TCP:
+ return constant_arg(type, rsock_tcp_optname_to_int, "unknown TCP control message");
+ case IPPROTO_UDP:
+ return constant_arg(type, rsock_udp_optname_to_int, "unknown UDP control message");
+ default:
+ return NUM2INT(type);
+ }
+ }
+ else {
+ switch (level) {
+ case SOL_SOCKET:
+ return constant_arg(type, rsock_scm_optname_to_int, "unknown UNIX control message");
+ default:
+ return NUM2INT(type);
+ }
+ }
+}
+
+int
+rsock_shutdown_how_arg(VALUE how)
+{
+ /* convert SHUT_RD, SHUT_WR, SHUT_RDWR. */
+ return constant_arg(how, rsock_shutdown_how_to_int, "unknown shutdown argument");
+}
+
+/*
+ * Socket::Constants module
+ */
+void
+rsock_init_socket_constants(void)
+{
+ /* constants */
+ init_constants();
+}
diff --git a/jni/ruby/ext/socket/constdefs.c b/jni/ruby/ext/socket/constdefs.c
new file mode 100644
index 0000000..18136ba
--- /dev/null
+++ b/jni/ruby/ext/socket/constdefs.c
@@ -0,0 +1,6852 @@
+/* autogenerated file */
+
+static st_table *rsock_intern_family_hash;
+static st_table *rsock_intern_family_noprefix_hash;
+static st_table *rsock_intern_protocol_family_hash;
+static st_table *rsock_intern_socktype_hash;
+static st_table *rsock_intern_ipproto_hash;
+static st_table *rsock_intern_iplevel_hash;
+static st_table *rsock_intern_so_optname_hash;
+static st_table *rsock_intern_ip_optname_hash;
+static st_table *rsock_intern_ipv6_optname_hash;
+static st_table *rsock_intern_tcp_optname_hash;
+static st_table *rsock_intern_udp_optname_hash;
+static st_table *rsock_intern_scm_optname_hash;
+static st_table *rsock_intern_local_optname_hash;
+
+#ifdef HAVE_LONG_LONG
+#define INTEGER2NUM(n) \
+ (FIXNUM_MAX < (n) ? ULL2NUM(n) : \
+ FIXNUM_MIN > (LONG_LONG)(n) ? LL2NUM(n) : \
+ LONG2FIX(n))
+#else
+#define INTEGER2NUM(n) \
+ (FIXNUM_MAX < (n) ? ULONG2NUM(n) : \
+ FIXNUM_MIN > (long)(n) ? LONG2NUM(n) : \
+ LONG2FIX(n))
+#endif
+
+static void
+init_constants(void)
+{
+ /*
+ * Document-module: Socket::Constants
+ *
+ * Socket::Constants provides socket-related constants. All possible
+ * socket constants are listed in the documentation but they may not all
+ * be present on your platform.
+ *
+ * If the underlying platform doesn't define a constant the corresponding
+ * Ruby constant is not defined.
+ *
+ */
+ rb_mSockConst = rb_define_module_under(rb_cSocket, "Constants");
+
+#if defined(SOCK_STREAM)
+ /* A stream socket provides a sequenced, reliable two-way connection for a byte stream */
+ rb_define_const(rb_cSocket, "SOCK_STREAM", INTEGER2NUM(SOCK_STREAM));
+ /* A stream socket provides a sequenced, reliable two-way connection for a byte stream */
+ rb_define_const(rb_mSockConst, "SOCK_STREAM", INTEGER2NUM(SOCK_STREAM));
+#endif
+#if defined(SOCK_DGRAM)
+ /* A datagram socket provides connectionless, unreliable messaging */
+ rb_define_const(rb_cSocket, "SOCK_DGRAM", INTEGER2NUM(SOCK_DGRAM));
+ /* A datagram socket provides connectionless, unreliable messaging */
+ rb_define_const(rb_mSockConst, "SOCK_DGRAM", INTEGER2NUM(SOCK_DGRAM));
+#endif
+#if defined(SOCK_RAW)
+ /* A raw socket provides low-level access for direct access or implementing network protocols */
+ rb_define_const(rb_cSocket, "SOCK_RAW", INTEGER2NUM(SOCK_RAW));
+ /* A raw socket provides low-level access for direct access or implementing network protocols */
+ rb_define_const(rb_mSockConst, "SOCK_RAW", INTEGER2NUM(SOCK_RAW));
+#endif
+#if defined(SOCK_RDM)
+ /* A reliable datagram socket provides reliable delivery of messages */
+ rb_define_const(rb_cSocket, "SOCK_RDM", INTEGER2NUM(SOCK_RDM));
+ /* A reliable datagram socket provides reliable delivery of messages */
+ rb_define_const(rb_mSockConst, "SOCK_RDM", INTEGER2NUM(SOCK_RDM));
+#endif
+#if defined(SOCK_SEQPACKET)
+ /* A sequential packet socket provides sequenced, reliable two-way connection for datagrams */
+ rb_define_const(rb_cSocket, "SOCK_SEQPACKET", INTEGER2NUM(SOCK_SEQPACKET));
+ /* A sequential packet socket provides sequenced, reliable two-way connection for datagrams */
+ rb_define_const(rb_mSockConst, "SOCK_SEQPACKET", INTEGER2NUM(SOCK_SEQPACKET));
+#endif
+#if defined(SOCK_PACKET)
+ /* Device-level packet access */
+ rb_define_const(rb_cSocket, "SOCK_PACKET", INTEGER2NUM(SOCK_PACKET));
+ /* Device-level packet access */
+ rb_define_const(rb_mSockConst, "SOCK_PACKET", INTEGER2NUM(SOCK_PACKET));
+#endif
+#if defined(AF_UNSPEC)
+ /* Unspecified protocol, any supported address family */
+ rb_define_const(rb_cSocket, "AF_UNSPEC", INTEGER2NUM(AF_UNSPEC));
+ /* Unspecified protocol, any supported address family */
+ rb_define_const(rb_mSockConst, "AF_UNSPEC", INTEGER2NUM(AF_UNSPEC));
+#endif
+#if defined(PF_UNSPEC)
+ /* Unspecified protocol, any supported address family */
+ rb_define_const(rb_cSocket, "PF_UNSPEC", INTEGER2NUM(PF_UNSPEC));
+ /* Unspecified protocol, any supported address family */
+ rb_define_const(rb_mSockConst, "PF_UNSPEC", INTEGER2NUM(PF_UNSPEC));
+#endif
+#if defined(AF_INET)
+ /* IPv4 protocol */
+ rb_define_const(rb_cSocket, "AF_INET", INTEGER2NUM(AF_INET));
+ /* IPv4 protocol */
+ rb_define_const(rb_mSockConst, "AF_INET", INTEGER2NUM(AF_INET));
+#endif
+#if defined(PF_INET)
+ /* IPv4 protocol */
+ rb_define_const(rb_cSocket, "PF_INET", INTEGER2NUM(PF_INET));
+ /* IPv4 protocol */
+ rb_define_const(rb_mSockConst, "PF_INET", INTEGER2NUM(PF_INET));
+#endif
+#if defined(INET6)
+#if defined(AF_INET6)
+ /* IPv6 protocol */
+ rb_define_const(rb_cSocket, "AF_INET6", INTEGER2NUM(AF_INET6));
+ /* IPv6 protocol */
+ rb_define_const(rb_mSockConst, "AF_INET6", INTEGER2NUM(AF_INET6));
+#endif
+#endif
+#if defined(INET6)
+#if defined(PF_INET6)
+ /* IPv6 protocol */
+ rb_define_const(rb_cSocket, "PF_INET6", INTEGER2NUM(PF_INET6));
+ /* IPv6 protocol */
+ rb_define_const(rb_mSockConst, "PF_INET6", INTEGER2NUM(PF_INET6));
+#endif
+#endif
+#if defined(AF_UNIX)
+ /* UNIX sockets */
+ rb_define_const(rb_cSocket, "AF_UNIX", INTEGER2NUM(AF_UNIX));
+ /* UNIX sockets */
+ rb_define_const(rb_mSockConst, "AF_UNIX", INTEGER2NUM(AF_UNIX));
+#endif
+#if defined(PF_UNIX)
+ /* UNIX sockets */
+ rb_define_const(rb_cSocket, "PF_UNIX", INTEGER2NUM(PF_UNIX));
+ /* UNIX sockets */
+ rb_define_const(rb_mSockConst, "PF_UNIX", INTEGER2NUM(PF_UNIX));
+#endif
+#if defined(AF_AX25)
+ /* AX.25 protocol */
+ rb_define_const(rb_cSocket, "AF_AX25", INTEGER2NUM(AF_AX25));
+ /* AX.25 protocol */
+ rb_define_const(rb_mSockConst, "AF_AX25", INTEGER2NUM(AF_AX25));
+#endif
+#if defined(PF_AX25)
+ /* AX.25 protocol */
+ rb_define_const(rb_cSocket, "PF_AX25", INTEGER2NUM(PF_AX25));
+ /* AX.25 protocol */
+ rb_define_const(rb_mSockConst, "PF_AX25", INTEGER2NUM(PF_AX25));
+#endif
+#if defined(AF_IPX)
+ /* IPX protocol */
+ rb_define_const(rb_cSocket, "AF_IPX", INTEGER2NUM(AF_IPX));
+ /* IPX protocol */
+ rb_define_const(rb_mSockConst, "AF_IPX", INTEGER2NUM(AF_IPX));
+#endif
+#if defined(PF_IPX)
+ /* IPX protocol */
+ rb_define_const(rb_cSocket, "PF_IPX", INTEGER2NUM(PF_IPX));
+ /* IPX protocol */
+ rb_define_const(rb_mSockConst, "PF_IPX", INTEGER2NUM(PF_IPX));
+#endif
+#if defined(AF_APPLETALK)
+ /* AppleTalk protocol */
+ rb_define_const(rb_cSocket, "AF_APPLETALK", INTEGER2NUM(AF_APPLETALK));
+ /* AppleTalk protocol */
+ rb_define_const(rb_mSockConst, "AF_APPLETALK", INTEGER2NUM(AF_APPLETALK));
+#endif
+#if defined(PF_APPLETALK)
+ /* AppleTalk protocol */
+ rb_define_const(rb_cSocket, "PF_APPLETALK", INTEGER2NUM(PF_APPLETALK));
+ /* AppleTalk protocol */
+ rb_define_const(rb_mSockConst, "PF_APPLETALK", INTEGER2NUM(PF_APPLETALK));
+#endif
+#if defined(AF_LOCAL)
+ /* Host-internal protocols */
+ rb_define_const(rb_cSocket, "AF_LOCAL", INTEGER2NUM(AF_LOCAL));
+ /* Host-internal protocols */
+ rb_define_const(rb_mSockConst, "AF_LOCAL", INTEGER2NUM(AF_LOCAL));
+#endif
+#if defined(PF_LOCAL)
+ /* Host-internal protocols */
+ rb_define_const(rb_cSocket, "PF_LOCAL", INTEGER2NUM(PF_LOCAL));
+ /* Host-internal protocols */
+ rb_define_const(rb_mSockConst, "PF_LOCAL", INTEGER2NUM(PF_LOCAL));
+#endif
+#if defined(AF_IMPLINK)
+ /* ARPANET IMP protocol */
+ rb_define_const(rb_cSocket, "AF_IMPLINK", INTEGER2NUM(AF_IMPLINK));
+ /* ARPANET IMP protocol */
+ rb_define_const(rb_mSockConst, "AF_IMPLINK", INTEGER2NUM(AF_IMPLINK));
+#endif
+#if defined(PF_IMPLINK)
+ /* ARPANET IMP protocol */
+ rb_define_const(rb_cSocket, "PF_IMPLINK", INTEGER2NUM(PF_IMPLINK));
+ /* ARPANET IMP protocol */
+ rb_define_const(rb_mSockConst, "PF_IMPLINK", INTEGER2NUM(PF_IMPLINK));
+#endif
+#if defined(AF_PUP)
+ /* PARC Universal Packet protocol */
+ rb_define_const(rb_cSocket, "AF_PUP", INTEGER2NUM(AF_PUP));
+ /* PARC Universal Packet protocol */
+ rb_define_const(rb_mSockConst, "AF_PUP", INTEGER2NUM(AF_PUP));
+#endif
+#if defined(PF_PUP)
+ /* PARC Universal Packet protocol */
+ rb_define_const(rb_cSocket, "PF_PUP", INTEGER2NUM(PF_PUP));
+ /* PARC Universal Packet protocol */
+ rb_define_const(rb_mSockConst, "PF_PUP", INTEGER2NUM(PF_PUP));
+#endif
+#if defined(AF_CHAOS)
+ /* MIT CHAOS protocols */
+ rb_define_const(rb_cSocket, "AF_CHAOS", INTEGER2NUM(AF_CHAOS));
+ /* MIT CHAOS protocols */
+ rb_define_const(rb_mSockConst, "AF_CHAOS", INTEGER2NUM(AF_CHAOS));
+#endif
+#if defined(PF_CHAOS)
+ /* MIT CHAOS protocols */
+ rb_define_const(rb_cSocket, "PF_CHAOS", INTEGER2NUM(PF_CHAOS));
+ /* MIT CHAOS protocols */
+ rb_define_const(rb_mSockConst, "PF_CHAOS", INTEGER2NUM(PF_CHAOS));
+#endif
+#if defined(AF_NS)
+ /* XEROX NS protocols */
+ rb_define_const(rb_cSocket, "AF_NS", INTEGER2NUM(AF_NS));
+ /* XEROX NS protocols */
+ rb_define_const(rb_mSockConst, "AF_NS", INTEGER2NUM(AF_NS));
+#endif
+#if defined(PF_NS)
+ /* XEROX NS protocols */
+ rb_define_const(rb_cSocket, "PF_NS", INTEGER2NUM(PF_NS));
+ /* XEROX NS protocols */
+ rb_define_const(rb_mSockConst, "PF_NS", INTEGER2NUM(PF_NS));
+#endif
+#if defined(AF_ISO)
+ /* ISO Open Systems Interconnection protocols */
+ rb_define_const(rb_cSocket, "AF_ISO", INTEGER2NUM(AF_ISO));
+ /* ISO Open Systems Interconnection protocols */
+ rb_define_const(rb_mSockConst, "AF_ISO", INTEGER2NUM(AF_ISO));
+#endif
+#if defined(PF_ISO)
+ /* ISO Open Systems Interconnection protocols */
+ rb_define_const(rb_cSocket, "PF_ISO", INTEGER2NUM(PF_ISO));
+ /* ISO Open Systems Interconnection protocols */
+ rb_define_const(rb_mSockConst, "PF_ISO", INTEGER2NUM(PF_ISO));
+#endif
+#if defined(AF_OSI)
+ /* ISO Open Systems Interconnection protocols */
+ rb_define_const(rb_cSocket, "AF_OSI", INTEGER2NUM(AF_OSI));
+ /* ISO Open Systems Interconnection protocols */
+ rb_define_const(rb_mSockConst, "AF_OSI", INTEGER2NUM(AF_OSI));
+#endif
+#if defined(PF_OSI)
+ /* ISO Open Systems Interconnection protocols */
+ rb_define_const(rb_cSocket, "PF_OSI", INTEGER2NUM(PF_OSI));
+ /* ISO Open Systems Interconnection protocols */
+ rb_define_const(rb_mSockConst, "PF_OSI", INTEGER2NUM(PF_OSI));
+#endif
+#if defined(AF_ECMA)
+ /* European Computer Manufacturers protocols */
+ rb_define_const(rb_cSocket, "AF_ECMA", INTEGER2NUM(AF_ECMA));
+ /* European Computer Manufacturers protocols */
+ rb_define_const(rb_mSockConst, "AF_ECMA", INTEGER2NUM(AF_ECMA));
+#endif
+#if defined(PF_ECMA)
+ /* European Computer Manufacturers protocols */
+ rb_define_const(rb_cSocket, "PF_ECMA", INTEGER2NUM(PF_ECMA));
+ /* European Computer Manufacturers protocols */
+ rb_define_const(rb_mSockConst, "PF_ECMA", INTEGER2NUM(PF_ECMA));
+#endif
+#if defined(AF_DATAKIT)
+ /* Datakit protocol */
+ rb_define_const(rb_cSocket, "AF_DATAKIT", INTEGER2NUM(AF_DATAKIT));
+ /* Datakit protocol */
+ rb_define_const(rb_mSockConst, "AF_DATAKIT", INTEGER2NUM(AF_DATAKIT));
+#endif
+#if defined(PF_DATAKIT)
+ /* Datakit protocol */
+ rb_define_const(rb_cSocket, "PF_DATAKIT", INTEGER2NUM(PF_DATAKIT));
+ /* Datakit protocol */
+ rb_define_const(rb_mSockConst, "PF_DATAKIT", INTEGER2NUM(PF_DATAKIT));
+#endif
+#if defined(AF_CCITT)
+ /* CCITT (now ITU-T) protocols */
+ rb_define_const(rb_cSocket, "AF_CCITT", INTEGER2NUM(AF_CCITT));
+ /* CCITT (now ITU-T) protocols */
+ rb_define_const(rb_mSockConst, "AF_CCITT", INTEGER2NUM(AF_CCITT));
+#endif
+#if defined(PF_CCITT)
+ /* CCITT (now ITU-T) protocols */
+ rb_define_const(rb_cSocket, "PF_CCITT", INTEGER2NUM(PF_CCITT));
+ /* CCITT (now ITU-T) protocols */
+ rb_define_const(rb_mSockConst, "PF_CCITT", INTEGER2NUM(PF_CCITT));
+#endif
+#if defined(AF_SNA)
+ /* IBM SNA protocol */
+ rb_define_const(rb_cSocket, "AF_SNA", INTEGER2NUM(AF_SNA));
+ /* IBM SNA protocol */
+ rb_define_const(rb_mSockConst, "AF_SNA", INTEGER2NUM(AF_SNA));
+#endif
+#if defined(PF_SNA)
+ /* IBM SNA protocol */
+ rb_define_const(rb_cSocket, "PF_SNA", INTEGER2NUM(PF_SNA));
+ /* IBM SNA protocol */
+ rb_define_const(rb_mSockConst, "PF_SNA", INTEGER2NUM(PF_SNA));
+#endif
+#if defined(AF_DEC)
+ /* DECnet protocol */
+ rb_define_const(rb_cSocket, "AF_DEC", INTEGER2NUM(AF_DEC));
+ /* DECnet protocol */
+ rb_define_const(rb_mSockConst, "AF_DEC", INTEGER2NUM(AF_DEC));
+#endif
+#if defined(PF_DEC)
+ /* DECnet protocol */
+ rb_define_const(rb_cSocket, "PF_DEC", INTEGER2NUM(PF_DEC));
+ /* DECnet protocol */
+ rb_define_const(rb_mSockConst, "PF_DEC", INTEGER2NUM(PF_DEC));
+#endif
+#if defined(AF_DLI)
+ /* DEC Direct Data Link Interface protocol */
+ rb_define_const(rb_cSocket, "AF_DLI", INTEGER2NUM(AF_DLI));
+ /* DEC Direct Data Link Interface protocol */
+ rb_define_const(rb_mSockConst, "AF_DLI", INTEGER2NUM(AF_DLI));
+#endif
+#if defined(PF_DLI)
+ /* DEC Direct Data Link Interface protocol */
+ rb_define_const(rb_cSocket, "PF_DLI", INTEGER2NUM(PF_DLI));
+ /* DEC Direct Data Link Interface protocol */
+ rb_define_const(rb_mSockConst, "PF_DLI", INTEGER2NUM(PF_DLI));
+#endif
+#if defined(AF_LAT)
+ /* Local Area Transport protocol */
+ rb_define_const(rb_cSocket, "AF_LAT", INTEGER2NUM(AF_LAT));
+ /* Local Area Transport protocol */
+ rb_define_const(rb_mSockConst, "AF_LAT", INTEGER2NUM(AF_LAT));
+#endif
+#if defined(PF_LAT)
+ /* Local Area Transport protocol */
+ rb_define_const(rb_cSocket, "PF_LAT", INTEGER2NUM(PF_LAT));
+ /* Local Area Transport protocol */
+ rb_define_const(rb_mSockConst, "PF_LAT", INTEGER2NUM(PF_LAT));
+#endif
+#if defined(AF_HYLINK)
+ /* NSC Hyperchannel protocol */
+ rb_define_const(rb_cSocket, "AF_HYLINK", INTEGER2NUM(AF_HYLINK));
+ /* NSC Hyperchannel protocol */
+ rb_define_const(rb_mSockConst, "AF_HYLINK", INTEGER2NUM(AF_HYLINK));
+#endif
+#if defined(PF_HYLINK)
+ /* NSC Hyperchannel protocol */
+ rb_define_const(rb_cSocket, "PF_HYLINK", INTEGER2NUM(PF_HYLINK));
+ /* NSC Hyperchannel protocol */
+ rb_define_const(rb_mSockConst, "PF_HYLINK", INTEGER2NUM(PF_HYLINK));
+#endif
+#if defined(AF_ROUTE)
+ /* Internal routing protocol */
+ rb_define_const(rb_cSocket, "AF_ROUTE", INTEGER2NUM(AF_ROUTE));
+ /* Internal routing protocol */
+ rb_define_const(rb_mSockConst, "AF_ROUTE", INTEGER2NUM(AF_ROUTE));
+#endif
+#if defined(PF_ROUTE)
+ /* Internal routing protocol */
+ rb_define_const(rb_cSocket, "PF_ROUTE", INTEGER2NUM(PF_ROUTE));
+ /* Internal routing protocol */
+ rb_define_const(rb_mSockConst, "PF_ROUTE", INTEGER2NUM(PF_ROUTE));
+#endif
+#if defined(AF_LINK)
+ /* Link layer interface */
+ rb_define_const(rb_cSocket, "AF_LINK", INTEGER2NUM(AF_LINK));
+ /* Link layer interface */
+ rb_define_const(rb_mSockConst, "AF_LINK", INTEGER2NUM(AF_LINK));
+#endif
+#if defined(PF_LINK)
+ /* Link layer interface */
+ rb_define_const(rb_cSocket, "PF_LINK", INTEGER2NUM(PF_LINK));
+ /* Link layer interface */
+ rb_define_const(rb_mSockConst, "PF_LINK", INTEGER2NUM(PF_LINK));
+#endif
+#if defined(AF_COIP)
+ /* Connection-oriented IP */
+ rb_define_const(rb_cSocket, "AF_COIP", INTEGER2NUM(AF_COIP));
+ /* Connection-oriented IP */
+ rb_define_const(rb_mSockConst, "AF_COIP", INTEGER2NUM(AF_COIP));
+#endif
+#if defined(PF_COIP)
+ /* Connection-oriented IP */
+ rb_define_const(rb_cSocket, "PF_COIP", INTEGER2NUM(PF_COIP));
+ /* Connection-oriented IP */
+ rb_define_const(rb_mSockConst, "PF_COIP", INTEGER2NUM(PF_COIP));
+#endif
+#if defined(AF_CNT)
+ /* Computer Network Technology */
+ rb_define_const(rb_cSocket, "AF_CNT", INTEGER2NUM(AF_CNT));
+ /* Computer Network Technology */
+ rb_define_const(rb_mSockConst, "AF_CNT", INTEGER2NUM(AF_CNT));
+#endif
+#if defined(PF_CNT)
+ /* Computer Network Technology */
+ rb_define_const(rb_cSocket, "PF_CNT", INTEGER2NUM(PF_CNT));
+ /* Computer Network Technology */
+ rb_define_const(rb_mSockConst, "PF_CNT", INTEGER2NUM(PF_CNT));
+#endif
+#if defined(AF_SIP)
+ /* Simple Internet Protocol */
+ rb_define_const(rb_cSocket, "AF_SIP", INTEGER2NUM(AF_SIP));
+ /* Simple Internet Protocol */
+ rb_define_const(rb_mSockConst, "AF_SIP", INTEGER2NUM(AF_SIP));
+#endif
+#if defined(PF_SIP)
+ /* Simple Internet Protocol */
+ rb_define_const(rb_cSocket, "PF_SIP", INTEGER2NUM(PF_SIP));
+ /* Simple Internet Protocol */
+ rb_define_const(rb_mSockConst, "PF_SIP", INTEGER2NUM(PF_SIP));
+#endif
+#if defined(AF_NDRV)
+ /* Network driver raw access */
+ rb_define_const(rb_cSocket, "AF_NDRV", INTEGER2NUM(AF_NDRV));
+ /* Network driver raw access */
+ rb_define_const(rb_mSockConst, "AF_NDRV", INTEGER2NUM(AF_NDRV));
+#endif
+#if defined(PF_NDRV)
+ /* Network driver raw access */
+ rb_define_const(rb_cSocket, "PF_NDRV", INTEGER2NUM(PF_NDRV));
+ /* Network driver raw access */
+ rb_define_const(rb_mSockConst, "PF_NDRV", INTEGER2NUM(PF_NDRV));
+#endif
+#if defined(AF_ISDN)
+ /* Integrated Services Digital Network */
+ rb_define_const(rb_cSocket, "AF_ISDN", INTEGER2NUM(AF_ISDN));
+ /* Integrated Services Digital Network */
+ rb_define_const(rb_mSockConst, "AF_ISDN", INTEGER2NUM(AF_ISDN));
+#endif
+#if defined(PF_ISDN)
+ /* Integrated Services Digital Network */
+ rb_define_const(rb_cSocket, "PF_ISDN", INTEGER2NUM(PF_ISDN));
+ /* Integrated Services Digital Network */
+ rb_define_const(rb_mSockConst, "PF_ISDN", INTEGER2NUM(PF_ISDN));
+#endif
+#if defined(AF_NATM)
+ /* Native ATM access */
+ rb_define_const(rb_cSocket, "AF_NATM", INTEGER2NUM(AF_NATM));
+ /* Native ATM access */
+ rb_define_const(rb_mSockConst, "AF_NATM", INTEGER2NUM(AF_NATM));
+#endif
+#if defined(PF_NATM)
+ /* Native ATM access */
+ rb_define_const(rb_cSocket, "PF_NATM", INTEGER2NUM(PF_NATM));
+ /* Native ATM access */
+ rb_define_const(rb_mSockConst, "PF_NATM", INTEGER2NUM(PF_NATM));
+#endif
+#if defined(AF_SYSTEM)
+ /* */
+ rb_define_const(rb_cSocket, "AF_SYSTEM", INTEGER2NUM(AF_SYSTEM));
+ /* */
+ rb_define_const(rb_mSockConst, "AF_SYSTEM", INTEGER2NUM(AF_SYSTEM));
+#endif
+#if defined(PF_SYSTEM)
+ /* */
+ rb_define_const(rb_cSocket, "PF_SYSTEM", INTEGER2NUM(PF_SYSTEM));
+ /* */
+ rb_define_const(rb_mSockConst, "PF_SYSTEM", INTEGER2NUM(PF_SYSTEM));
+#endif
+#if defined(AF_NETBIOS)
+ /* NetBIOS */
+ rb_define_const(rb_cSocket, "AF_NETBIOS", INTEGER2NUM(AF_NETBIOS));
+ /* NetBIOS */
+ rb_define_const(rb_mSockConst, "AF_NETBIOS", INTEGER2NUM(AF_NETBIOS));
+#endif
+#if defined(PF_NETBIOS)
+ /* NetBIOS */
+ rb_define_const(rb_cSocket, "PF_NETBIOS", INTEGER2NUM(PF_NETBIOS));
+ /* NetBIOS */
+ rb_define_const(rb_mSockConst, "PF_NETBIOS", INTEGER2NUM(PF_NETBIOS));
+#endif
+#if defined(AF_PPP)
+ /* Point-to-Point Protocol */
+ rb_define_const(rb_cSocket, "AF_PPP", INTEGER2NUM(AF_PPP));
+ /* Point-to-Point Protocol */
+ rb_define_const(rb_mSockConst, "AF_PPP", INTEGER2NUM(AF_PPP));
+#endif
+#if defined(PF_PPP)
+ /* Point-to-Point Protocol */
+ rb_define_const(rb_cSocket, "PF_PPP", INTEGER2NUM(PF_PPP));
+ /* Point-to-Point Protocol */
+ rb_define_const(rb_mSockConst, "PF_PPP", INTEGER2NUM(PF_PPP));
+#endif
+#if defined(AF_ATM)
+ /* Asynchronous Transfer Mode */
+ rb_define_const(rb_cSocket, "AF_ATM", INTEGER2NUM(AF_ATM));
+ /* Asynchronous Transfer Mode */
+ rb_define_const(rb_mSockConst, "AF_ATM", INTEGER2NUM(AF_ATM));
+#endif
+#if defined(PF_ATM)
+ /* Asynchronous Transfer Mode */
+ rb_define_const(rb_cSocket, "PF_ATM", INTEGER2NUM(PF_ATM));
+ /* Asynchronous Transfer Mode */
+ rb_define_const(rb_mSockConst, "PF_ATM", INTEGER2NUM(PF_ATM));
+#endif
+#if defined(AF_NETGRAPH)
+ /* Netgraph sockets */
+ rb_define_const(rb_cSocket, "AF_NETGRAPH", INTEGER2NUM(AF_NETGRAPH));
+ /* Netgraph sockets */
+ rb_define_const(rb_mSockConst, "AF_NETGRAPH", INTEGER2NUM(AF_NETGRAPH));
+#endif
+#if defined(PF_NETGRAPH)
+ /* Netgraph sockets */
+ rb_define_const(rb_cSocket, "PF_NETGRAPH", INTEGER2NUM(PF_NETGRAPH));
+ /* Netgraph sockets */
+ rb_define_const(rb_mSockConst, "PF_NETGRAPH", INTEGER2NUM(PF_NETGRAPH));
+#endif
+#if defined(AF_MAX)
+ /* Maximum address family for this platform */
+ rb_define_const(rb_cSocket, "AF_MAX", INTEGER2NUM(AF_MAX));
+ /* Maximum address family for this platform */
+ rb_define_const(rb_mSockConst, "AF_MAX", INTEGER2NUM(AF_MAX));
+#endif
+#if defined(PF_MAX)
+ /* Maximum address family for this platform */
+ rb_define_const(rb_cSocket, "PF_MAX", INTEGER2NUM(PF_MAX));
+ /* Maximum address family for this platform */
+ rb_define_const(rb_mSockConst, "PF_MAX", INTEGER2NUM(PF_MAX));
+#endif
+#if defined(AF_PACKET)
+ /* Direct link-layer access */
+ rb_define_const(rb_cSocket, "AF_PACKET", INTEGER2NUM(AF_PACKET));
+ /* Direct link-layer access */
+ rb_define_const(rb_mSockConst, "AF_PACKET", INTEGER2NUM(AF_PACKET));
+#endif
+#if defined(PF_PACKET)
+ /* Direct link-layer access */
+ rb_define_const(rb_cSocket, "PF_PACKET", INTEGER2NUM(PF_PACKET));
+ /* Direct link-layer access */
+ rb_define_const(rb_mSockConst, "PF_PACKET", INTEGER2NUM(PF_PACKET));
+#endif
+#if defined(AF_E164)
+ /* CCITT (ITU-T) E.164 recommendation */
+ rb_define_const(rb_cSocket, "AF_E164", INTEGER2NUM(AF_E164));
+ /* CCITT (ITU-T) E.164 recommendation */
+ rb_define_const(rb_mSockConst, "AF_E164", INTEGER2NUM(AF_E164));
+#endif
+#if defined(PF_XTP)
+ /* eXpress Transfer Protocol */
+ rb_define_const(rb_cSocket, "PF_XTP", INTEGER2NUM(PF_XTP));
+ /* eXpress Transfer Protocol */
+ rb_define_const(rb_mSockConst, "PF_XTP", INTEGER2NUM(PF_XTP));
+#endif
+#if defined(PF_RTIP)
+ /* */
+ rb_define_const(rb_cSocket, "PF_RTIP", INTEGER2NUM(PF_RTIP));
+ /* */
+ rb_define_const(rb_mSockConst, "PF_RTIP", INTEGER2NUM(PF_RTIP));
+#endif
+#if defined(PF_PIP)
+ /* */
+ rb_define_const(rb_cSocket, "PF_PIP", INTEGER2NUM(PF_PIP));
+ /* */
+ rb_define_const(rb_mSockConst, "PF_PIP", INTEGER2NUM(PF_PIP));
+#endif
+#if defined(PF_KEY)
+ /* */
+ rb_define_const(rb_cSocket, "PF_KEY", INTEGER2NUM(PF_KEY));
+ /* */
+ rb_define_const(rb_mSockConst, "PF_KEY", INTEGER2NUM(PF_KEY));
+#endif
+#if defined(MSG_OOB)
+ /* Process out-of-band data */
+ rb_define_const(rb_cSocket, "MSG_OOB", INTEGER2NUM(MSG_OOB));
+ /* Process out-of-band data */
+ rb_define_const(rb_mSockConst, "MSG_OOB", INTEGER2NUM(MSG_OOB));
+#endif
+#if defined(MSG_PEEK)
+ /* Peek at incoming message */
+ rb_define_const(rb_cSocket, "MSG_PEEK", INTEGER2NUM(MSG_PEEK));
+ /* Peek at incoming message */
+ rb_define_const(rb_mSockConst, "MSG_PEEK", INTEGER2NUM(MSG_PEEK));
+#endif
+#if defined(MSG_DONTROUTE)
+ /* Send without using the routing tables */
+ rb_define_const(rb_cSocket, "MSG_DONTROUTE", INTEGER2NUM(MSG_DONTROUTE));
+ /* Send without using the routing tables */
+ rb_define_const(rb_mSockConst, "MSG_DONTROUTE", INTEGER2NUM(MSG_DONTROUTE));
+#endif
+#if defined(MSG_EOR)
+ /* Data completes record */
+ rb_define_const(rb_cSocket, "MSG_EOR", INTEGER2NUM(MSG_EOR));
+ /* Data completes record */
+ rb_define_const(rb_mSockConst, "MSG_EOR", INTEGER2NUM(MSG_EOR));
+#endif
+#if defined(MSG_TRUNC)
+ /* Data discarded before delivery */
+ rb_define_const(rb_cSocket, "MSG_TRUNC", INTEGER2NUM(MSG_TRUNC));
+ /* Data discarded before delivery */
+ rb_define_const(rb_mSockConst, "MSG_TRUNC", INTEGER2NUM(MSG_TRUNC));
+#endif
+#if defined(MSG_CTRUNC)
+ /* Control data lost before delivery */
+ rb_define_const(rb_cSocket, "MSG_CTRUNC", INTEGER2NUM(MSG_CTRUNC));
+ /* Control data lost before delivery */
+ rb_define_const(rb_mSockConst, "MSG_CTRUNC", INTEGER2NUM(MSG_CTRUNC));
+#endif
+#if defined(MSG_WAITALL)
+ /* Wait for full request or error */
+ rb_define_const(rb_cSocket, "MSG_WAITALL", INTEGER2NUM(MSG_WAITALL));
+ /* Wait for full request or error */
+ rb_define_const(rb_mSockConst, "MSG_WAITALL", INTEGER2NUM(MSG_WAITALL));
+#endif
+#if defined(MSG_DONTWAIT)
+ /* This message should be non-blocking */
+ rb_define_const(rb_cSocket, "MSG_DONTWAIT", INTEGER2NUM(MSG_DONTWAIT));
+ /* This message should be non-blocking */
+ rb_define_const(rb_mSockConst, "MSG_DONTWAIT", INTEGER2NUM(MSG_DONTWAIT));
+#endif
+#if defined(MSG_EOF)
+ /* Data completes connection */
+ rb_define_const(rb_cSocket, "MSG_EOF", INTEGER2NUM(MSG_EOF));
+ /* Data completes connection */
+ rb_define_const(rb_mSockConst, "MSG_EOF", INTEGER2NUM(MSG_EOF));
+#endif
+#if defined(MSG_FLUSH)
+ /* Start of a hold sequence. Dumps to so_temp */
+ rb_define_const(rb_cSocket, "MSG_FLUSH", INTEGER2NUM(MSG_FLUSH));
+ /* Start of a hold sequence. Dumps to so_temp */
+ rb_define_const(rb_mSockConst, "MSG_FLUSH", INTEGER2NUM(MSG_FLUSH));
+#endif
+#if defined(MSG_HOLD)
+ /* Hold fragment in so_temp */
+ rb_define_const(rb_cSocket, "MSG_HOLD", INTEGER2NUM(MSG_HOLD));
+ /* Hold fragment in so_temp */
+ rb_define_const(rb_mSockConst, "MSG_HOLD", INTEGER2NUM(MSG_HOLD));
+#endif
+#if defined(MSG_SEND)
+ /* Send the packet in so_temp */
+ rb_define_const(rb_cSocket, "MSG_SEND", INTEGER2NUM(MSG_SEND));
+ /* Send the packet in so_temp */
+ rb_define_const(rb_mSockConst, "MSG_SEND", INTEGER2NUM(MSG_SEND));
+#endif
+#if defined(MSG_HAVEMORE)
+ /* Data ready to be read */
+ rb_define_const(rb_cSocket, "MSG_HAVEMORE", INTEGER2NUM(MSG_HAVEMORE));
+ /* Data ready to be read */
+ rb_define_const(rb_mSockConst, "MSG_HAVEMORE", INTEGER2NUM(MSG_HAVEMORE));
+#endif
+#if defined(MSG_RCVMORE)
+ /* Data remains in the current packet */
+ rb_define_const(rb_cSocket, "MSG_RCVMORE", INTEGER2NUM(MSG_RCVMORE));
+ /* Data remains in the current packet */
+ rb_define_const(rb_mSockConst, "MSG_RCVMORE", INTEGER2NUM(MSG_RCVMORE));
+#endif
+#if defined(MSG_COMPAT)
+ /* End of record */
+ rb_define_const(rb_cSocket, "MSG_COMPAT", INTEGER2NUM(MSG_COMPAT));
+ /* End of record */
+ rb_define_const(rb_mSockConst, "MSG_COMPAT", INTEGER2NUM(MSG_COMPAT));
+#endif
+#if defined(MSG_PROXY)
+ /* Wait for full request */
+ rb_define_const(rb_cSocket, "MSG_PROXY", INTEGER2NUM(MSG_PROXY));
+ /* Wait for full request */
+ rb_define_const(rb_mSockConst, "MSG_PROXY", INTEGER2NUM(MSG_PROXY));
+#endif
+#if defined(MSG_FIN)
+ /* */
+ rb_define_const(rb_cSocket, "MSG_FIN", INTEGER2NUM(MSG_FIN));
+ /* */
+ rb_define_const(rb_mSockConst, "MSG_FIN", INTEGER2NUM(MSG_FIN));
+#endif
+#if defined(MSG_SYN)
+ /* */
+ rb_define_const(rb_cSocket, "MSG_SYN", INTEGER2NUM(MSG_SYN));
+ /* */
+ rb_define_const(rb_mSockConst, "MSG_SYN", INTEGER2NUM(MSG_SYN));
+#endif
+#if defined(MSG_CONFIRM)
+ /* Confirm path validity */
+ rb_define_const(rb_cSocket, "MSG_CONFIRM", INTEGER2NUM(MSG_CONFIRM));
+ /* Confirm path validity */
+ rb_define_const(rb_mSockConst, "MSG_CONFIRM", INTEGER2NUM(MSG_CONFIRM));
+#endif
+#if defined(MSG_RST)
+ /* */
+ rb_define_const(rb_cSocket, "MSG_RST", INTEGER2NUM(MSG_RST));
+ /* */
+ rb_define_const(rb_mSockConst, "MSG_RST", INTEGER2NUM(MSG_RST));
+#endif
+#if defined(MSG_ERRQUEUE)
+ /* Fetch message from error queue */
+ rb_define_const(rb_cSocket, "MSG_ERRQUEUE", INTEGER2NUM(MSG_ERRQUEUE));
+ /* Fetch message from error queue */
+ rb_define_const(rb_mSockConst, "MSG_ERRQUEUE", INTEGER2NUM(MSG_ERRQUEUE));
+#endif
+#if defined(MSG_NOSIGNAL)
+ /* Do not generate SIGPIPE */
+ rb_define_const(rb_cSocket, "MSG_NOSIGNAL", INTEGER2NUM(MSG_NOSIGNAL));
+ /* Do not generate SIGPIPE */
+ rb_define_const(rb_mSockConst, "MSG_NOSIGNAL", INTEGER2NUM(MSG_NOSIGNAL));
+#endif
+#if defined(MSG_MORE)
+ /* Sender will send more */
+ rb_define_const(rb_cSocket, "MSG_MORE", INTEGER2NUM(MSG_MORE));
+ /* Sender will send more */
+ rb_define_const(rb_mSockConst, "MSG_MORE", INTEGER2NUM(MSG_MORE));
+#endif
+#if defined(MSG_FASTOPEN)
+ /* Reduce step of the handshake process */
+ rb_define_const(rb_cSocket, "MSG_FASTOPEN", INTEGER2NUM(MSG_FASTOPEN));
+ /* Reduce step of the handshake process */
+ rb_define_const(rb_mSockConst, "MSG_FASTOPEN", INTEGER2NUM(MSG_FASTOPEN));
+#endif
+#if defined(SOL_SOCKET)
+ /* Socket-level options */
+ rb_define_const(rb_cSocket, "SOL_SOCKET", INTEGER2NUM(SOL_SOCKET));
+ /* Socket-level options */
+ rb_define_const(rb_mSockConst, "SOL_SOCKET", INTEGER2NUM(SOL_SOCKET));
+#endif
+#if defined(SOL_IP)
+ /* IP socket options */
+ rb_define_const(rb_cSocket, "SOL_IP", INTEGER2NUM(SOL_IP));
+ /* IP socket options */
+ rb_define_const(rb_mSockConst, "SOL_IP", INTEGER2NUM(SOL_IP));
+#endif
+#if defined(SOL_IPX)
+ /* IPX socket options */
+ rb_define_const(rb_cSocket, "SOL_IPX", INTEGER2NUM(SOL_IPX));
+ /* IPX socket options */
+ rb_define_const(rb_mSockConst, "SOL_IPX", INTEGER2NUM(SOL_IPX));
+#endif
+#if defined(SOL_AX25)
+ /* AX.25 socket options */
+ rb_define_const(rb_cSocket, "SOL_AX25", INTEGER2NUM(SOL_AX25));
+ /* AX.25 socket options */
+ rb_define_const(rb_mSockConst, "SOL_AX25", INTEGER2NUM(SOL_AX25));
+#endif
+#if defined(SOL_ATALK)
+ /* AppleTalk socket options */
+ rb_define_const(rb_cSocket, "SOL_ATALK", INTEGER2NUM(SOL_ATALK));
+ /* AppleTalk socket options */
+ rb_define_const(rb_mSockConst, "SOL_ATALK", INTEGER2NUM(SOL_ATALK));
+#endif
+#if defined(SOL_TCP)
+ /* TCP socket options */
+ rb_define_const(rb_cSocket, "SOL_TCP", INTEGER2NUM(SOL_TCP));
+ /* TCP socket options */
+ rb_define_const(rb_mSockConst, "SOL_TCP", INTEGER2NUM(SOL_TCP));
+#endif
+#if defined(SOL_UDP)
+ /* UDP socket options */
+ rb_define_const(rb_cSocket, "SOL_UDP", INTEGER2NUM(SOL_UDP));
+ /* UDP socket options */
+ rb_define_const(rb_mSockConst, "SOL_UDP", INTEGER2NUM(SOL_UDP));
+#endif
+#if defined(IPPROTO_IP)
+ /* Dummy protocol for IP */
+ rb_define_const(rb_cSocket, "IPPROTO_IP", INTEGER2NUM(IPPROTO_IP));
+ /* Dummy protocol for IP */
+ rb_define_const(rb_mSockConst, "IPPROTO_IP", INTEGER2NUM(IPPROTO_IP));
+#endif
+#if defined(IPPROTO_ICMP)
+ /* Control message protocol */
+ rb_define_const(rb_cSocket, "IPPROTO_ICMP", INTEGER2NUM(IPPROTO_ICMP));
+ /* Control message protocol */
+ rb_define_const(rb_mSockConst, "IPPROTO_ICMP", INTEGER2NUM(IPPROTO_ICMP));
+#endif
+#if defined(IPPROTO_IGMP)
+ /* Group Management Protocol */
+ rb_define_const(rb_cSocket, "IPPROTO_IGMP", INTEGER2NUM(IPPROTO_IGMP));
+ /* Group Management Protocol */
+ rb_define_const(rb_mSockConst, "IPPROTO_IGMP", INTEGER2NUM(IPPROTO_IGMP));
+#endif
+#if defined(IPPROTO_GGP)
+ /* Gateway to Gateway Protocol */
+ rb_define_const(rb_cSocket, "IPPROTO_GGP", INTEGER2NUM(IPPROTO_GGP));
+ /* Gateway to Gateway Protocol */
+ rb_define_const(rb_mSockConst, "IPPROTO_GGP", INTEGER2NUM(IPPROTO_GGP));
+#endif
+#if defined(IPPROTO_TCP)
+ /* TCP */
+ rb_define_const(rb_cSocket, "IPPROTO_TCP", INTEGER2NUM(IPPROTO_TCP));
+ /* TCP */
+ rb_define_const(rb_mSockConst, "IPPROTO_TCP", INTEGER2NUM(IPPROTO_TCP));
+#endif
+#if defined(IPPROTO_EGP)
+ /* Exterior Gateway Protocol */
+ rb_define_const(rb_cSocket, "IPPROTO_EGP", INTEGER2NUM(IPPROTO_EGP));
+ /* Exterior Gateway Protocol */
+ rb_define_const(rb_mSockConst, "IPPROTO_EGP", INTEGER2NUM(IPPROTO_EGP));
+#endif
+#if defined(IPPROTO_PUP)
+ /* PARC Universal Packet protocol */
+ rb_define_const(rb_cSocket, "IPPROTO_PUP", INTEGER2NUM(IPPROTO_PUP));
+ /* PARC Universal Packet protocol */
+ rb_define_const(rb_mSockConst, "IPPROTO_PUP", INTEGER2NUM(IPPROTO_PUP));
+#endif
+#if defined(IPPROTO_UDP)
+ /* UDP */
+ rb_define_const(rb_cSocket, "IPPROTO_UDP", INTEGER2NUM(IPPROTO_UDP));
+ /* UDP */
+ rb_define_const(rb_mSockConst, "IPPROTO_UDP", INTEGER2NUM(IPPROTO_UDP));
+#endif
+#if defined(IPPROTO_IDP)
+ /* XNS IDP */
+ rb_define_const(rb_cSocket, "IPPROTO_IDP", INTEGER2NUM(IPPROTO_IDP));
+ /* XNS IDP */
+ rb_define_const(rb_mSockConst, "IPPROTO_IDP", INTEGER2NUM(IPPROTO_IDP));
+#endif
+#if defined(IPPROTO_HELLO)
+ /* "hello" routing protocol */
+ rb_define_const(rb_cSocket, "IPPROTO_HELLO", INTEGER2NUM(IPPROTO_HELLO));
+ /* "hello" routing protocol */
+ rb_define_const(rb_mSockConst, "IPPROTO_HELLO", INTEGER2NUM(IPPROTO_HELLO));
+#endif
+#if defined(IPPROTO_ND)
+ /* Sun net disk protocol */
+ rb_define_const(rb_cSocket, "IPPROTO_ND", INTEGER2NUM(IPPROTO_ND));
+ /* Sun net disk protocol */
+ rb_define_const(rb_mSockConst, "IPPROTO_ND", INTEGER2NUM(IPPROTO_ND));
+#endif
+#if defined(IPPROTO_TP)
+ /* ISO transport protocol class 4 */
+ rb_define_const(rb_cSocket, "IPPROTO_TP", INTEGER2NUM(IPPROTO_TP));
+ /* ISO transport protocol class 4 */
+ rb_define_const(rb_mSockConst, "IPPROTO_TP", INTEGER2NUM(IPPROTO_TP));
+#endif
+#if defined(IPPROTO_XTP)
+ /* Xpress Transport Protocol */
+ rb_define_const(rb_cSocket, "IPPROTO_XTP", INTEGER2NUM(IPPROTO_XTP));
+ /* Xpress Transport Protocol */
+ rb_define_const(rb_mSockConst, "IPPROTO_XTP", INTEGER2NUM(IPPROTO_XTP));
+#endif
+#if defined(IPPROTO_EON)
+ /* ISO cnlp */
+ rb_define_const(rb_cSocket, "IPPROTO_EON", INTEGER2NUM(IPPROTO_EON));
+ /* ISO cnlp */
+ rb_define_const(rb_mSockConst, "IPPROTO_EON", INTEGER2NUM(IPPROTO_EON));
+#endif
+#if defined(IPPROTO_BIP)
+ /* */
+ rb_define_const(rb_cSocket, "IPPROTO_BIP", INTEGER2NUM(IPPROTO_BIP));
+ /* */
+ rb_define_const(rb_mSockConst, "IPPROTO_BIP", INTEGER2NUM(IPPROTO_BIP));
+#endif
+#if defined(IPPROTO_AH)
+ /* IP6 auth header */
+ rb_define_const(rb_cSocket, "IPPROTO_AH", INTEGER2NUM(IPPROTO_AH));
+ /* IP6 auth header */
+ rb_define_const(rb_mSockConst, "IPPROTO_AH", INTEGER2NUM(IPPROTO_AH));
+#endif
+#if defined(IPPROTO_DSTOPTS)
+ /* IP6 destination option */
+ rb_define_const(rb_cSocket, "IPPROTO_DSTOPTS", INTEGER2NUM(IPPROTO_DSTOPTS));
+ /* IP6 destination option */
+ rb_define_const(rb_mSockConst, "IPPROTO_DSTOPTS", INTEGER2NUM(IPPROTO_DSTOPTS));
+#endif
+#if defined(IPPROTO_ESP)
+ /* IP6 Encapsulated Security Payload */
+ rb_define_const(rb_cSocket, "IPPROTO_ESP", INTEGER2NUM(IPPROTO_ESP));
+ /* IP6 Encapsulated Security Payload */
+ rb_define_const(rb_mSockConst, "IPPROTO_ESP", INTEGER2NUM(IPPROTO_ESP));
+#endif
+#if defined(IPPROTO_FRAGMENT)
+ /* IP6 fragmentation header */
+ rb_define_const(rb_cSocket, "IPPROTO_FRAGMENT", INTEGER2NUM(IPPROTO_FRAGMENT));
+ /* IP6 fragmentation header */
+ rb_define_const(rb_mSockConst, "IPPROTO_FRAGMENT", INTEGER2NUM(IPPROTO_FRAGMENT));
+#endif
+#if defined(IPPROTO_HOPOPTS)
+ /* IP6 hop-by-hop options */
+ rb_define_const(rb_cSocket, "IPPROTO_HOPOPTS", INTEGER2NUM(IPPROTO_HOPOPTS));
+ /* IP6 hop-by-hop options */
+ rb_define_const(rb_mSockConst, "IPPROTO_HOPOPTS", INTEGER2NUM(IPPROTO_HOPOPTS));
+#endif
+#if defined(IPPROTO_ICMPV6)
+ /* ICMP6 */
+ rb_define_const(rb_cSocket, "IPPROTO_ICMPV6", INTEGER2NUM(IPPROTO_ICMPV6));
+ /* ICMP6 */
+ rb_define_const(rb_mSockConst, "IPPROTO_ICMPV6", INTEGER2NUM(IPPROTO_ICMPV6));
+#endif
+#if defined(IPPROTO_IPV6)
+ /* IP6 header */
+ rb_define_const(rb_cSocket, "IPPROTO_IPV6", INTEGER2NUM(IPPROTO_IPV6));
+ /* IP6 header */
+ rb_define_const(rb_mSockConst, "IPPROTO_IPV6", INTEGER2NUM(IPPROTO_IPV6));
+#endif
+#if defined(IPPROTO_NONE)
+ /* IP6 no next header */
+ rb_define_const(rb_cSocket, "IPPROTO_NONE", INTEGER2NUM(IPPROTO_NONE));
+ /* IP6 no next header */
+ rb_define_const(rb_mSockConst, "IPPROTO_NONE", INTEGER2NUM(IPPROTO_NONE));
+#endif
+#if defined(IPPROTO_ROUTING)
+ /* IP6 routing header */
+ rb_define_const(rb_cSocket, "IPPROTO_ROUTING", INTEGER2NUM(IPPROTO_ROUTING));
+ /* IP6 routing header */
+ rb_define_const(rb_mSockConst, "IPPROTO_ROUTING", INTEGER2NUM(IPPROTO_ROUTING));
+#endif
+#if defined(IPPROTO_RAW)
+ /* Raw IP packet */
+ rb_define_const(rb_cSocket, "IPPROTO_RAW", INTEGER2NUM(IPPROTO_RAW));
+ /* Raw IP packet */
+ rb_define_const(rb_mSockConst, "IPPROTO_RAW", INTEGER2NUM(IPPROTO_RAW));
+#endif
+#if defined(IPPROTO_MAX)
+ /* Maximum IPPROTO constant */
+ rb_define_const(rb_cSocket, "IPPROTO_MAX", INTEGER2NUM(IPPROTO_MAX));
+ /* Maximum IPPROTO constant */
+ rb_define_const(rb_mSockConst, "IPPROTO_MAX", INTEGER2NUM(IPPROTO_MAX));
+#endif
+#if defined(IPPORT_RESERVED)
+ /* Default minimum address for bind or connect */
+ rb_define_const(rb_cSocket, "IPPORT_RESERVED", INTEGER2NUM(IPPORT_RESERVED));
+ /* Default minimum address for bind or connect */
+ rb_define_const(rb_mSockConst, "IPPORT_RESERVED", INTEGER2NUM(IPPORT_RESERVED));
+#endif
+#if defined(IPPORT_USERRESERVED)
+ /* Default maximum address for bind or connect */
+ rb_define_const(rb_cSocket, "IPPORT_USERRESERVED", INTEGER2NUM(IPPORT_USERRESERVED));
+ /* Default maximum address for bind or connect */
+ rb_define_const(rb_mSockConst, "IPPORT_USERRESERVED", INTEGER2NUM(IPPORT_USERRESERVED));
+#endif
+#if defined(INADDR_ANY)
+ /* A socket bound to INADDR_ANY receives packets from all interfaces and sends from the default IP address */
+ rb_define_const(rb_cSocket, "INADDR_ANY", INTEGER2NUM(INADDR_ANY));
+ /* A socket bound to INADDR_ANY receives packets from all interfaces and sends from the default IP address */
+ rb_define_const(rb_mSockConst, "INADDR_ANY", INTEGER2NUM(INADDR_ANY));
+#endif
+#if defined(INADDR_BROADCAST)
+ /* The network broadcast address */
+ rb_define_const(rb_cSocket, "INADDR_BROADCAST", INTEGER2NUM(INADDR_BROADCAST));
+ /* The network broadcast address */
+ rb_define_const(rb_mSockConst, "INADDR_BROADCAST", INTEGER2NUM(INADDR_BROADCAST));
+#endif
+#if defined(INADDR_LOOPBACK)
+ /* The loopback address */
+ rb_define_const(rb_cSocket, "INADDR_LOOPBACK", INTEGER2NUM(INADDR_LOOPBACK));
+ /* The loopback address */
+ rb_define_const(rb_mSockConst, "INADDR_LOOPBACK", INTEGER2NUM(INADDR_LOOPBACK));
+#endif
+#if defined(INADDR_UNSPEC_GROUP)
+ /* The reserved multicast group */
+ rb_define_const(rb_cSocket, "INADDR_UNSPEC_GROUP", INTEGER2NUM(INADDR_UNSPEC_GROUP));
+ /* The reserved multicast group */
+ rb_define_const(rb_mSockConst, "INADDR_UNSPEC_GROUP", INTEGER2NUM(INADDR_UNSPEC_GROUP));
+#endif
+#if defined(INADDR_ALLHOSTS_GROUP)
+ /* Multicast group for all systems on this subset */
+ rb_define_const(rb_cSocket, "INADDR_ALLHOSTS_GROUP", INTEGER2NUM(INADDR_ALLHOSTS_GROUP));
+ /* Multicast group for all systems on this subset */
+ rb_define_const(rb_mSockConst, "INADDR_ALLHOSTS_GROUP", INTEGER2NUM(INADDR_ALLHOSTS_GROUP));
+#endif
+#if defined(INADDR_MAX_LOCAL_GROUP)
+ /* The last local network multicast group */
+ rb_define_const(rb_cSocket, "INADDR_MAX_LOCAL_GROUP", INTEGER2NUM(INADDR_MAX_LOCAL_GROUP));
+ /* The last local network multicast group */
+ rb_define_const(rb_mSockConst, "INADDR_MAX_LOCAL_GROUP", INTEGER2NUM(INADDR_MAX_LOCAL_GROUP));
+#endif
+#if defined(INADDR_NONE)
+ /* A bitmask for matching no valid IP address */
+ rb_define_const(rb_cSocket, "INADDR_NONE", INTEGER2NUM(INADDR_NONE));
+ /* A bitmask for matching no valid IP address */
+ rb_define_const(rb_mSockConst, "INADDR_NONE", INTEGER2NUM(INADDR_NONE));
+#endif
+#if defined(IP_OPTIONS)
+ /* IP options to be included in packets */
+ rb_define_const(rb_cSocket, "IP_OPTIONS", INTEGER2NUM(IP_OPTIONS));
+ /* IP options to be included in packets */
+ rb_define_const(rb_mSockConst, "IP_OPTIONS", INTEGER2NUM(IP_OPTIONS));
+#endif
+#if defined(IP_HDRINCL)
+ /* Header is included with data */
+ rb_define_const(rb_cSocket, "IP_HDRINCL", INTEGER2NUM(IP_HDRINCL));
+ /* Header is included with data */
+ rb_define_const(rb_mSockConst, "IP_HDRINCL", INTEGER2NUM(IP_HDRINCL));
+#endif
+#if defined(IP_TOS)
+ /* IP type-of-service */
+ rb_define_const(rb_cSocket, "IP_TOS", INTEGER2NUM(IP_TOS));
+ /* IP type-of-service */
+ rb_define_const(rb_mSockConst, "IP_TOS", INTEGER2NUM(IP_TOS));
+#endif
+#if defined(IP_TTL)
+ /* IP time-to-live */
+ rb_define_const(rb_cSocket, "IP_TTL", INTEGER2NUM(IP_TTL));
+ /* IP time-to-live */
+ rb_define_const(rb_mSockConst, "IP_TTL", INTEGER2NUM(IP_TTL));
+#endif
+#if defined(IP_RECVOPTS)
+ /* Receive all IP options with datagram */
+ rb_define_const(rb_cSocket, "IP_RECVOPTS", INTEGER2NUM(IP_RECVOPTS));
+ /* Receive all IP options with datagram */
+ rb_define_const(rb_mSockConst, "IP_RECVOPTS", INTEGER2NUM(IP_RECVOPTS));
+#endif
+#if defined(IP_RECVRETOPTS)
+ /* Receive all IP options for response */
+ rb_define_const(rb_cSocket, "IP_RECVRETOPTS", INTEGER2NUM(IP_RECVRETOPTS));
+ /* Receive all IP options for response */
+ rb_define_const(rb_mSockConst, "IP_RECVRETOPTS", INTEGER2NUM(IP_RECVRETOPTS));
+#endif
+#if defined(IP_RECVDSTADDR)
+ /* Receive IP destination address with datagram */
+ rb_define_const(rb_cSocket, "IP_RECVDSTADDR", INTEGER2NUM(IP_RECVDSTADDR));
+ /* Receive IP destination address with datagram */
+ rb_define_const(rb_mSockConst, "IP_RECVDSTADDR", INTEGER2NUM(IP_RECVDSTADDR));
+#endif
+#if defined(IP_RETOPTS)
+ /* IP options to be included in datagrams */
+ rb_define_const(rb_cSocket, "IP_RETOPTS", INTEGER2NUM(IP_RETOPTS));
+ /* IP options to be included in datagrams */
+ rb_define_const(rb_mSockConst, "IP_RETOPTS", INTEGER2NUM(IP_RETOPTS));
+#endif
+#if defined(IP_MINTTL)
+ /* Minimum TTL allowed for received packets */
+ rb_define_const(rb_cSocket, "IP_MINTTL", INTEGER2NUM(IP_MINTTL));
+ /* Minimum TTL allowed for received packets */
+ rb_define_const(rb_mSockConst, "IP_MINTTL", INTEGER2NUM(IP_MINTTL));
+#endif
+#if defined(IP_DONTFRAG)
+ /* Don't fragment packets */
+ rb_define_const(rb_cSocket, "IP_DONTFRAG", INTEGER2NUM(IP_DONTFRAG));
+ /* Don't fragment packets */
+ rb_define_const(rb_mSockConst, "IP_DONTFRAG", INTEGER2NUM(IP_DONTFRAG));
+#endif
+#if defined(IP_SENDSRCADDR)
+ /* Source address for outgoing UDP datagrams */
+ rb_define_const(rb_cSocket, "IP_SENDSRCADDR", INTEGER2NUM(IP_SENDSRCADDR));
+ /* Source address for outgoing UDP datagrams */
+ rb_define_const(rb_mSockConst, "IP_SENDSRCADDR", INTEGER2NUM(IP_SENDSRCADDR));
+#endif
+#if defined(IP_ONESBCAST)
+ /* Force outgoing broadcast datagrams to have the undirected broadcast address */
+ rb_define_const(rb_cSocket, "IP_ONESBCAST", INTEGER2NUM(IP_ONESBCAST));
+ /* Force outgoing broadcast datagrams to have the undirected broadcast address */
+ rb_define_const(rb_mSockConst, "IP_ONESBCAST", INTEGER2NUM(IP_ONESBCAST));
+#endif
+#if defined(IP_RECVTTL)
+ /* Receive IP TTL with datagrams */
+ rb_define_const(rb_cSocket, "IP_RECVTTL", INTEGER2NUM(IP_RECVTTL));
+ /* Receive IP TTL with datagrams */
+ rb_define_const(rb_mSockConst, "IP_RECVTTL", INTEGER2NUM(IP_RECVTTL));
+#endif
+#if defined(IP_RECVIF)
+ /* Receive interface information with datagrams */
+ rb_define_const(rb_cSocket, "IP_RECVIF", INTEGER2NUM(IP_RECVIF));
+ /* Receive interface information with datagrams */
+ rb_define_const(rb_mSockConst, "IP_RECVIF", INTEGER2NUM(IP_RECVIF));
+#endif
+#if defined(IP_RECVSLLA)
+ /* Receive link-layer address with datagrams */
+ rb_define_const(rb_cSocket, "IP_RECVSLLA", INTEGER2NUM(IP_RECVSLLA));
+ /* Receive link-layer address with datagrams */
+ rb_define_const(rb_mSockConst, "IP_RECVSLLA", INTEGER2NUM(IP_RECVSLLA));
+#endif
+#if defined(IP_PORTRANGE)
+ /* Set the port range for sockets with unspecified port numbers */
+ rb_define_const(rb_cSocket, "IP_PORTRANGE", INTEGER2NUM(IP_PORTRANGE));
+ /* Set the port range for sockets with unspecified port numbers */
+ rb_define_const(rb_mSockConst, "IP_PORTRANGE", INTEGER2NUM(IP_PORTRANGE));
+#endif
+#if defined(IP_MULTICAST_IF)
+ /* IP multicast interface */
+ rb_define_const(rb_cSocket, "IP_MULTICAST_IF", INTEGER2NUM(IP_MULTICAST_IF));
+ /* IP multicast interface */
+ rb_define_const(rb_mSockConst, "IP_MULTICAST_IF", INTEGER2NUM(IP_MULTICAST_IF));
+#endif
+#if defined(IP_MULTICAST_TTL)
+ /* IP multicast TTL */
+ rb_define_const(rb_cSocket, "IP_MULTICAST_TTL", INTEGER2NUM(IP_MULTICAST_TTL));
+ /* IP multicast TTL */
+ rb_define_const(rb_mSockConst, "IP_MULTICAST_TTL", INTEGER2NUM(IP_MULTICAST_TTL));
+#endif
+#if defined(IP_MULTICAST_LOOP)
+ /* IP multicast loopback */
+ rb_define_const(rb_cSocket, "IP_MULTICAST_LOOP", INTEGER2NUM(IP_MULTICAST_LOOP));
+ /* IP multicast loopback */
+ rb_define_const(rb_mSockConst, "IP_MULTICAST_LOOP", INTEGER2NUM(IP_MULTICAST_LOOP));
+#endif
+#if defined(IP_ADD_MEMBERSHIP)
+ /* Add a multicast group membership */
+ rb_define_const(rb_cSocket, "IP_ADD_MEMBERSHIP", INTEGER2NUM(IP_ADD_MEMBERSHIP));
+ /* Add a multicast group membership */
+ rb_define_const(rb_mSockConst, "IP_ADD_MEMBERSHIP", INTEGER2NUM(IP_ADD_MEMBERSHIP));
+#endif
+#if defined(IP_DROP_MEMBERSHIP)
+ /* Drop a multicast group membership */
+ rb_define_const(rb_cSocket, "IP_DROP_MEMBERSHIP", INTEGER2NUM(IP_DROP_MEMBERSHIP));
+ /* Drop a multicast group membership */
+ rb_define_const(rb_mSockConst, "IP_DROP_MEMBERSHIP", INTEGER2NUM(IP_DROP_MEMBERSHIP));
+#endif
+#if defined(IP_DEFAULT_MULTICAST_TTL)
+ /* Default multicast TTL */
+ rb_define_const(rb_cSocket, "IP_DEFAULT_MULTICAST_TTL", INTEGER2NUM(IP_DEFAULT_MULTICAST_TTL));
+ /* Default multicast TTL */
+ rb_define_const(rb_mSockConst, "IP_DEFAULT_MULTICAST_TTL", INTEGER2NUM(IP_DEFAULT_MULTICAST_TTL));
+#endif
+#if defined(IP_DEFAULT_MULTICAST_LOOP)
+ /* Default multicast loopback */
+ rb_define_const(rb_cSocket, "IP_DEFAULT_MULTICAST_LOOP", INTEGER2NUM(IP_DEFAULT_MULTICAST_LOOP));
+ /* Default multicast loopback */
+ rb_define_const(rb_mSockConst, "IP_DEFAULT_MULTICAST_LOOP", INTEGER2NUM(IP_DEFAULT_MULTICAST_LOOP));
+#endif
+#if defined(IP_MAX_MEMBERSHIPS)
+ /* Maximum number multicast groups a socket can join */
+ rb_define_const(rb_cSocket, "IP_MAX_MEMBERSHIPS", INTEGER2NUM(IP_MAX_MEMBERSHIPS));
+ /* Maximum number multicast groups a socket can join */
+ rb_define_const(rb_mSockConst, "IP_MAX_MEMBERSHIPS", INTEGER2NUM(IP_MAX_MEMBERSHIPS));
+#endif
+#if defined(IP_ROUTER_ALERT)
+ /* Notify transit routers to more closely examine the contents of an IP packet */
+ rb_define_const(rb_cSocket, "IP_ROUTER_ALERT", INTEGER2NUM(IP_ROUTER_ALERT));
+ /* Notify transit routers to more closely examine the contents of an IP packet */
+ rb_define_const(rb_mSockConst, "IP_ROUTER_ALERT", INTEGER2NUM(IP_ROUTER_ALERT));
+#endif
+#if defined(IP_PKTINFO)
+ /* Receive packet information with datagrams */
+ rb_define_const(rb_cSocket, "IP_PKTINFO", INTEGER2NUM(IP_PKTINFO));
+ /* Receive packet information with datagrams */
+ rb_define_const(rb_mSockConst, "IP_PKTINFO", INTEGER2NUM(IP_PKTINFO));
+#endif
+#if defined(IP_PKTOPTIONS)
+ /* Receive packet options with datagrams */
+ rb_define_const(rb_cSocket, "IP_PKTOPTIONS", INTEGER2NUM(IP_PKTOPTIONS));
+ /* Receive packet options with datagrams */
+ rb_define_const(rb_mSockConst, "IP_PKTOPTIONS", INTEGER2NUM(IP_PKTOPTIONS));
+#endif
+#if defined(IP_MTU_DISCOVER)
+ /* Path MTU discovery */
+ rb_define_const(rb_cSocket, "IP_MTU_DISCOVER", INTEGER2NUM(IP_MTU_DISCOVER));
+ /* Path MTU discovery */
+ rb_define_const(rb_mSockConst, "IP_MTU_DISCOVER", INTEGER2NUM(IP_MTU_DISCOVER));
+#endif
+#if defined(IP_RECVERR)
+ /* Enable extended reliable error message passing */
+ rb_define_const(rb_cSocket, "IP_RECVERR", INTEGER2NUM(IP_RECVERR));
+ /* Enable extended reliable error message passing */
+ rb_define_const(rb_mSockConst, "IP_RECVERR", INTEGER2NUM(IP_RECVERR));
+#endif
+#if defined(IP_RECVTOS)
+ /* Receive TOS with incoming packets */
+ rb_define_const(rb_cSocket, "IP_RECVTOS", INTEGER2NUM(IP_RECVTOS));
+ /* Receive TOS with incoming packets */
+ rb_define_const(rb_mSockConst, "IP_RECVTOS", INTEGER2NUM(IP_RECVTOS));
+#endif
+#if defined(IP_MTU)
+ /* The Maximum Transmission Unit of the socket */
+ rb_define_const(rb_cSocket, "IP_MTU", INTEGER2NUM(IP_MTU));
+ /* The Maximum Transmission Unit of the socket */
+ rb_define_const(rb_mSockConst, "IP_MTU", INTEGER2NUM(IP_MTU));
+#endif
+#if defined(IP_FREEBIND)
+ /* Allow binding to nonexistent IP addresses */
+ rb_define_const(rb_cSocket, "IP_FREEBIND", INTEGER2NUM(IP_FREEBIND));
+ /* Allow binding to nonexistent IP addresses */
+ rb_define_const(rb_mSockConst, "IP_FREEBIND", INTEGER2NUM(IP_FREEBIND));
+#endif
+#if defined(IP_IPSEC_POLICY)
+ /* IPsec security policy */
+ rb_define_const(rb_cSocket, "IP_IPSEC_POLICY", INTEGER2NUM(IP_IPSEC_POLICY));
+ /* IPsec security policy */
+ rb_define_const(rb_mSockConst, "IP_IPSEC_POLICY", INTEGER2NUM(IP_IPSEC_POLICY));
+#endif
+#if defined(IP_XFRM_POLICY)
+ /* */
+ rb_define_const(rb_cSocket, "IP_XFRM_POLICY", INTEGER2NUM(IP_XFRM_POLICY));
+ /* */
+ rb_define_const(rb_mSockConst, "IP_XFRM_POLICY", INTEGER2NUM(IP_XFRM_POLICY));
+#endif
+#if defined(IP_PASSSEC)
+ /* Retrieve security context with datagram */
+ rb_define_const(rb_cSocket, "IP_PASSSEC", INTEGER2NUM(IP_PASSSEC));
+ /* Retrieve security context with datagram */
+ rb_define_const(rb_mSockConst, "IP_PASSSEC", INTEGER2NUM(IP_PASSSEC));
+#endif
+#if defined(IP_TRANSPARENT)
+ /* Transparent proxy */
+ rb_define_const(rb_cSocket, "IP_TRANSPARENT", INTEGER2NUM(IP_TRANSPARENT));
+ /* Transparent proxy */
+ rb_define_const(rb_mSockConst, "IP_TRANSPARENT", INTEGER2NUM(IP_TRANSPARENT));
+#endif
+#if defined(IP_PMTUDISC_DONT)
+ /* Never send DF frames */
+ rb_define_const(rb_cSocket, "IP_PMTUDISC_DONT", INTEGER2NUM(IP_PMTUDISC_DONT));
+ /* Never send DF frames */
+ rb_define_const(rb_mSockConst, "IP_PMTUDISC_DONT", INTEGER2NUM(IP_PMTUDISC_DONT));
+#endif
+#if defined(IP_PMTUDISC_WANT)
+ /* Use per-route hints */
+ rb_define_const(rb_cSocket, "IP_PMTUDISC_WANT", INTEGER2NUM(IP_PMTUDISC_WANT));
+ /* Use per-route hints */
+ rb_define_const(rb_mSockConst, "IP_PMTUDISC_WANT", INTEGER2NUM(IP_PMTUDISC_WANT));
+#endif
+#if defined(IP_PMTUDISC_DO)
+ /* Always send DF frames */
+ rb_define_const(rb_cSocket, "IP_PMTUDISC_DO", INTEGER2NUM(IP_PMTUDISC_DO));
+ /* Always send DF frames */
+ rb_define_const(rb_mSockConst, "IP_PMTUDISC_DO", INTEGER2NUM(IP_PMTUDISC_DO));
+#endif
+#if defined(IP_UNBLOCK_SOURCE)
+ /* Unblock IPv4 multicast packets with a give source address */
+ rb_define_const(rb_cSocket, "IP_UNBLOCK_SOURCE", INTEGER2NUM(IP_UNBLOCK_SOURCE));
+ /* Unblock IPv4 multicast packets with a give source address */
+ rb_define_const(rb_mSockConst, "IP_UNBLOCK_SOURCE", INTEGER2NUM(IP_UNBLOCK_SOURCE));
+#endif
+#if defined(IP_BLOCK_SOURCE)
+ /* Block IPv4 multicast packets with a give source address */
+ rb_define_const(rb_cSocket, "IP_BLOCK_SOURCE", INTEGER2NUM(IP_BLOCK_SOURCE));
+ /* Block IPv4 multicast packets with a give source address */
+ rb_define_const(rb_mSockConst, "IP_BLOCK_SOURCE", INTEGER2NUM(IP_BLOCK_SOURCE));
+#endif
+#if defined(IP_ADD_SOURCE_MEMBERSHIP)
+ /* Add a multicast group membership */
+ rb_define_const(rb_cSocket, "IP_ADD_SOURCE_MEMBERSHIP", INTEGER2NUM(IP_ADD_SOURCE_MEMBERSHIP));
+ /* Add a multicast group membership */
+ rb_define_const(rb_mSockConst, "IP_ADD_SOURCE_MEMBERSHIP", INTEGER2NUM(IP_ADD_SOURCE_MEMBERSHIP));
+#endif
+#if defined(IP_DROP_SOURCE_MEMBERSHIP)
+ /* Drop a multicast group membership */
+ rb_define_const(rb_cSocket, "IP_DROP_SOURCE_MEMBERSHIP", INTEGER2NUM(IP_DROP_SOURCE_MEMBERSHIP));
+ /* Drop a multicast group membership */
+ rb_define_const(rb_mSockConst, "IP_DROP_SOURCE_MEMBERSHIP", INTEGER2NUM(IP_DROP_SOURCE_MEMBERSHIP));
+#endif
+#if defined(IP_MSFILTER)
+ /* Multicast source filtering */
+ rb_define_const(rb_cSocket, "IP_MSFILTER", INTEGER2NUM(IP_MSFILTER));
+ /* Multicast source filtering */
+ rb_define_const(rb_mSockConst, "IP_MSFILTER", INTEGER2NUM(IP_MSFILTER));
+#endif
+#if defined(MCAST_JOIN_GROUP)
+ /* Join a multicast group */
+ rb_define_const(rb_cSocket, "MCAST_JOIN_GROUP", INTEGER2NUM(MCAST_JOIN_GROUP));
+ /* Join a multicast group */
+ rb_define_const(rb_mSockConst, "MCAST_JOIN_GROUP", INTEGER2NUM(MCAST_JOIN_GROUP));
+#endif
+#if defined(MCAST_BLOCK_SOURCE)
+ /* Block multicast packets from this source */
+ rb_define_const(rb_cSocket, "MCAST_BLOCK_SOURCE", INTEGER2NUM(MCAST_BLOCK_SOURCE));
+ /* Block multicast packets from this source */
+ rb_define_const(rb_mSockConst, "MCAST_BLOCK_SOURCE", INTEGER2NUM(MCAST_BLOCK_SOURCE));
+#endif
+#if defined(MCAST_UNBLOCK_SOURCE)
+ /* Unblock multicast packets from this source */
+ rb_define_const(rb_cSocket, "MCAST_UNBLOCK_SOURCE", INTEGER2NUM(MCAST_UNBLOCK_SOURCE));
+ /* Unblock multicast packets from this source */
+ rb_define_const(rb_mSockConst, "MCAST_UNBLOCK_SOURCE", INTEGER2NUM(MCAST_UNBLOCK_SOURCE));
+#endif
+#if defined(MCAST_LEAVE_GROUP)
+ /* Leave a multicast group */
+ rb_define_const(rb_cSocket, "MCAST_LEAVE_GROUP", INTEGER2NUM(MCAST_LEAVE_GROUP));
+ /* Leave a multicast group */
+ rb_define_const(rb_mSockConst, "MCAST_LEAVE_GROUP", INTEGER2NUM(MCAST_LEAVE_GROUP));
+#endif
+#if defined(MCAST_JOIN_SOURCE_GROUP)
+ /* Join a multicast source group */
+ rb_define_const(rb_cSocket, "MCAST_JOIN_SOURCE_GROUP", INTEGER2NUM(MCAST_JOIN_SOURCE_GROUP));
+ /* Join a multicast source group */
+ rb_define_const(rb_mSockConst, "MCAST_JOIN_SOURCE_GROUP", INTEGER2NUM(MCAST_JOIN_SOURCE_GROUP));
+#endif
+#if defined(MCAST_LEAVE_SOURCE_GROUP)
+ /* Leave a multicast source group */
+ rb_define_const(rb_cSocket, "MCAST_LEAVE_SOURCE_GROUP", INTEGER2NUM(MCAST_LEAVE_SOURCE_GROUP));
+ /* Leave a multicast source group */
+ rb_define_const(rb_mSockConst, "MCAST_LEAVE_SOURCE_GROUP", INTEGER2NUM(MCAST_LEAVE_SOURCE_GROUP));
+#endif
+#if defined(MCAST_MSFILTER)
+ /* Multicast source filtering */
+ rb_define_const(rb_cSocket, "MCAST_MSFILTER", INTEGER2NUM(MCAST_MSFILTER));
+ /* Multicast source filtering */
+ rb_define_const(rb_mSockConst, "MCAST_MSFILTER", INTEGER2NUM(MCAST_MSFILTER));
+#endif
+#if defined(MCAST_EXCLUDE)
+ /* Exclusive multicast source filter */
+ rb_define_const(rb_cSocket, "MCAST_EXCLUDE", INTEGER2NUM(MCAST_EXCLUDE));
+ /* Exclusive multicast source filter */
+ rb_define_const(rb_mSockConst, "MCAST_EXCLUDE", INTEGER2NUM(MCAST_EXCLUDE));
+#endif
+#if defined(MCAST_INCLUDE)
+ /* Inclusive multicast source filter */
+ rb_define_const(rb_cSocket, "MCAST_INCLUDE", INTEGER2NUM(MCAST_INCLUDE));
+ /* Inclusive multicast source filter */
+ rb_define_const(rb_mSockConst, "MCAST_INCLUDE", INTEGER2NUM(MCAST_INCLUDE));
+#endif
+#if defined(SO_DEBUG)
+ /* Debug info recording */
+ rb_define_const(rb_cSocket, "SO_DEBUG", INTEGER2NUM(SO_DEBUG));
+ /* Debug info recording */
+ rb_define_const(rb_mSockConst, "SO_DEBUG", INTEGER2NUM(SO_DEBUG));
+#endif
+#if defined(SO_REUSEADDR)
+ /* Allow local address reuse */
+ rb_define_const(rb_cSocket, "SO_REUSEADDR", INTEGER2NUM(SO_REUSEADDR));
+ /* Allow local address reuse */
+ rb_define_const(rb_mSockConst, "SO_REUSEADDR", INTEGER2NUM(SO_REUSEADDR));
+#endif
+#if defined(SO_REUSEPORT)
+ /* Allow local address and port reuse */
+ rb_define_const(rb_cSocket, "SO_REUSEPORT", INTEGER2NUM(SO_REUSEPORT));
+ /* Allow local address and port reuse */
+ rb_define_const(rb_mSockConst, "SO_REUSEPORT", INTEGER2NUM(SO_REUSEPORT));
+#endif
+#if defined(SO_TYPE)
+ /* Get the socket type */
+ rb_define_const(rb_cSocket, "SO_TYPE", INTEGER2NUM(SO_TYPE));
+ /* Get the socket type */
+ rb_define_const(rb_mSockConst, "SO_TYPE", INTEGER2NUM(SO_TYPE));
+#endif
+#if defined(SO_ERROR)
+ /* Get and clear the error status */
+ rb_define_const(rb_cSocket, "SO_ERROR", INTEGER2NUM(SO_ERROR));
+ /* Get and clear the error status */
+ rb_define_const(rb_mSockConst, "SO_ERROR", INTEGER2NUM(SO_ERROR));
+#endif
+#if defined(SO_DONTROUTE)
+ /* Use interface addresses */
+ rb_define_const(rb_cSocket, "SO_DONTROUTE", INTEGER2NUM(SO_DONTROUTE));
+ /* Use interface addresses */
+ rb_define_const(rb_mSockConst, "SO_DONTROUTE", INTEGER2NUM(SO_DONTROUTE));
+#endif
+#if defined(SO_BROADCAST)
+ /* Permit sending of broadcast messages */
+ rb_define_const(rb_cSocket, "SO_BROADCAST", INTEGER2NUM(SO_BROADCAST));
+ /* Permit sending of broadcast messages */
+ rb_define_const(rb_mSockConst, "SO_BROADCAST", INTEGER2NUM(SO_BROADCAST));
+#endif
+#if defined(SO_SNDBUF)
+ /* Send buffer size */
+ rb_define_const(rb_cSocket, "SO_SNDBUF", INTEGER2NUM(SO_SNDBUF));
+ /* Send buffer size */
+ rb_define_const(rb_mSockConst, "SO_SNDBUF", INTEGER2NUM(SO_SNDBUF));
+#endif
+#if defined(SO_RCVBUF)
+ /* Receive buffer size */
+ rb_define_const(rb_cSocket, "SO_RCVBUF", INTEGER2NUM(SO_RCVBUF));
+ /* Receive buffer size */
+ rb_define_const(rb_mSockConst, "SO_RCVBUF", INTEGER2NUM(SO_RCVBUF));
+#endif
+#if defined(SO_SNDBUFFORCE)
+ /* Send buffer size without wmem_max limit (Linux 2.6.14) */
+ rb_define_const(rb_cSocket, "SO_SNDBUFFORCE", INTEGER2NUM(SO_SNDBUFFORCE));
+ /* Send buffer size without wmem_max limit (Linux 2.6.14) */
+ rb_define_const(rb_mSockConst, "SO_SNDBUFFORCE", INTEGER2NUM(SO_SNDBUFFORCE));
+#endif
+#if defined(SO_RCVBUFFORCE)
+ /* Receive buffer size without rmem_max limit (Linux 2.6.14) */
+ rb_define_const(rb_cSocket, "SO_RCVBUFFORCE", INTEGER2NUM(SO_RCVBUFFORCE));
+ /* Receive buffer size without rmem_max limit (Linux 2.6.14) */
+ rb_define_const(rb_mSockConst, "SO_RCVBUFFORCE", INTEGER2NUM(SO_RCVBUFFORCE));
+#endif
+#if defined(SO_KEEPALIVE)
+ /* Keep connections alive */
+ rb_define_const(rb_cSocket, "SO_KEEPALIVE", INTEGER2NUM(SO_KEEPALIVE));
+ /* Keep connections alive */
+ rb_define_const(rb_mSockConst, "SO_KEEPALIVE", INTEGER2NUM(SO_KEEPALIVE));
+#endif
+#if defined(SO_OOBINLINE)
+ /* Leave received out-of-band data in-line */
+ rb_define_const(rb_cSocket, "SO_OOBINLINE", INTEGER2NUM(SO_OOBINLINE));
+ /* Leave received out-of-band data in-line */
+ rb_define_const(rb_mSockConst, "SO_OOBINLINE", INTEGER2NUM(SO_OOBINLINE));
+#endif
+#if defined(SO_NO_CHECK)
+ /* Disable checksums */
+ rb_define_const(rb_cSocket, "SO_NO_CHECK", INTEGER2NUM(SO_NO_CHECK));
+ /* Disable checksums */
+ rb_define_const(rb_mSockConst, "SO_NO_CHECK", INTEGER2NUM(SO_NO_CHECK));
+#endif
+#if defined(SO_PRIORITY)
+ /* The protocol-defined priority for all packets on this socket */
+ rb_define_const(rb_cSocket, "SO_PRIORITY", INTEGER2NUM(SO_PRIORITY));
+ /* The protocol-defined priority for all packets on this socket */
+ rb_define_const(rb_mSockConst, "SO_PRIORITY", INTEGER2NUM(SO_PRIORITY));
+#endif
+#if defined(SO_LINGER)
+ /* Linger on close if data is present */
+ rb_define_const(rb_cSocket, "SO_LINGER", INTEGER2NUM(SO_LINGER));
+ /* Linger on close if data is present */
+ rb_define_const(rb_mSockConst, "SO_LINGER", INTEGER2NUM(SO_LINGER));
+#endif
+#if defined(SO_PASSCRED)
+ /* Receive SCM_CREDENTIALS messages */
+ rb_define_const(rb_cSocket, "SO_PASSCRED", INTEGER2NUM(SO_PASSCRED));
+ /* Receive SCM_CREDENTIALS messages */
+ rb_define_const(rb_mSockConst, "SO_PASSCRED", INTEGER2NUM(SO_PASSCRED));
+#endif
+#if defined(SO_PEERCRED)
+ /* The credentials of the foreign process connected to this socket */
+ rb_define_const(rb_cSocket, "SO_PEERCRED", INTEGER2NUM(SO_PEERCRED));
+ /* The credentials of the foreign process connected to this socket */
+ rb_define_const(rb_mSockConst, "SO_PEERCRED", INTEGER2NUM(SO_PEERCRED));
+#endif
+#if defined(SO_RCVLOWAT)
+ /* Receive low-water mark */
+ rb_define_const(rb_cSocket, "SO_RCVLOWAT", INTEGER2NUM(SO_RCVLOWAT));
+ /* Receive low-water mark */
+ rb_define_const(rb_mSockConst, "SO_RCVLOWAT", INTEGER2NUM(SO_RCVLOWAT));
+#endif
+#if defined(SO_SNDLOWAT)
+ /* Send low-water mark */
+ rb_define_const(rb_cSocket, "SO_SNDLOWAT", INTEGER2NUM(SO_SNDLOWAT));
+ /* Send low-water mark */
+ rb_define_const(rb_mSockConst, "SO_SNDLOWAT", INTEGER2NUM(SO_SNDLOWAT));
+#endif
+#if defined(SO_RCVTIMEO)
+ /* Receive timeout */
+ rb_define_const(rb_cSocket, "SO_RCVTIMEO", INTEGER2NUM(SO_RCVTIMEO));
+ /* Receive timeout */
+ rb_define_const(rb_mSockConst, "SO_RCVTIMEO", INTEGER2NUM(SO_RCVTIMEO));
+#endif
+#if defined(SO_SNDTIMEO)
+ /* Send timeout */
+ rb_define_const(rb_cSocket, "SO_SNDTIMEO", INTEGER2NUM(SO_SNDTIMEO));
+ /* Send timeout */
+ rb_define_const(rb_mSockConst, "SO_SNDTIMEO", INTEGER2NUM(SO_SNDTIMEO));
+#endif
+#if defined(SO_ACCEPTCONN)
+ /* Socket has had listen() called on it */
+ rb_define_const(rb_cSocket, "SO_ACCEPTCONN", INTEGER2NUM(SO_ACCEPTCONN));
+ /* Socket has had listen() called on it */
+ rb_define_const(rb_mSockConst, "SO_ACCEPTCONN", INTEGER2NUM(SO_ACCEPTCONN));
+#endif
+#if defined(SO_USELOOPBACK)
+ /* Bypass hardware when possible */
+ rb_define_const(rb_cSocket, "SO_USELOOPBACK", INTEGER2NUM(SO_USELOOPBACK));
+ /* Bypass hardware when possible */
+ rb_define_const(rb_mSockConst, "SO_USELOOPBACK", INTEGER2NUM(SO_USELOOPBACK));
+#endif
+#if defined(SO_ACCEPTFILTER)
+ /* There is an accept filter */
+ rb_define_const(rb_cSocket, "SO_ACCEPTFILTER", INTEGER2NUM(SO_ACCEPTFILTER));
+ /* There is an accept filter */
+ rb_define_const(rb_mSockConst, "SO_ACCEPTFILTER", INTEGER2NUM(SO_ACCEPTFILTER));
+#endif
+#if defined(SO_DONTTRUNC)
+ /* Retain unread data */
+ rb_define_const(rb_cSocket, "SO_DONTTRUNC", INTEGER2NUM(SO_DONTTRUNC));
+ /* Retain unread data */
+ rb_define_const(rb_mSockConst, "SO_DONTTRUNC", INTEGER2NUM(SO_DONTTRUNC));
+#endif
+#if defined(SO_WANTMORE)
+ /* Give a hint when more data is ready */
+ rb_define_const(rb_cSocket, "SO_WANTMORE", INTEGER2NUM(SO_WANTMORE));
+ /* Give a hint when more data is ready */
+ rb_define_const(rb_mSockConst, "SO_WANTMORE", INTEGER2NUM(SO_WANTMORE));
+#endif
+#if defined(SO_WANTOOBFLAG)
+ /* OOB data is wanted in MSG_FLAG on receive */
+ rb_define_const(rb_cSocket, "SO_WANTOOBFLAG", INTEGER2NUM(SO_WANTOOBFLAG));
+ /* OOB data is wanted in MSG_FLAG on receive */
+ rb_define_const(rb_mSockConst, "SO_WANTOOBFLAG", INTEGER2NUM(SO_WANTOOBFLAG));
+#endif
+#if defined(SO_NREAD)
+ /* Get first packet byte count */
+ rb_define_const(rb_cSocket, "SO_NREAD", INTEGER2NUM(SO_NREAD));
+ /* Get first packet byte count */
+ rb_define_const(rb_mSockConst, "SO_NREAD", INTEGER2NUM(SO_NREAD));
+#endif
+#if defined(SO_NKE)
+ /* Install socket-level Network Kernel Extension */
+ rb_define_const(rb_cSocket, "SO_NKE", INTEGER2NUM(SO_NKE));
+ /* Install socket-level Network Kernel Extension */
+ rb_define_const(rb_mSockConst, "SO_NKE", INTEGER2NUM(SO_NKE));
+#endif
+#if defined(SO_NOSIGPIPE)
+ /* Don't SIGPIPE on EPIPE */
+ rb_define_const(rb_cSocket, "SO_NOSIGPIPE", INTEGER2NUM(SO_NOSIGPIPE));
+ /* Don't SIGPIPE on EPIPE */
+ rb_define_const(rb_mSockConst, "SO_NOSIGPIPE", INTEGER2NUM(SO_NOSIGPIPE));
+#endif
+#if defined(SO_SECURITY_AUTHENTICATION)
+ /* */
+ rb_define_const(rb_cSocket, "SO_SECURITY_AUTHENTICATION", INTEGER2NUM(SO_SECURITY_AUTHENTICATION));
+ /* */
+ rb_define_const(rb_mSockConst, "SO_SECURITY_AUTHENTICATION", INTEGER2NUM(SO_SECURITY_AUTHENTICATION));
+#endif
+#if defined(SO_SECURITY_ENCRYPTION_TRANSPORT)
+ /* */
+ rb_define_const(rb_cSocket, "SO_SECURITY_ENCRYPTION_TRANSPORT", INTEGER2NUM(SO_SECURITY_ENCRYPTION_TRANSPORT));
+ /* */
+ rb_define_const(rb_mSockConst, "SO_SECURITY_ENCRYPTION_TRANSPORT", INTEGER2NUM(SO_SECURITY_ENCRYPTION_TRANSPORT));
+#endif
+#if defined(SO_SECURITY_ENCRYPTION_NETWORK)
+ /* */
+ rb_define_const(rb_cSocket, "SO_SECURITY_ENCRYPTION_NETWORK", INTEGER2NUM(SO_SECURITY_ENCRYPTION_NETWORK));
+ /* */
+ rb_define_const(rb_mSockConst, "SO_SECURITY_ENCRYPTION_NETWORK", INTEGER2NUM(SO_SECURITY_ENCRYPTION_NETWORK));
+#endif
+#if defined(SO_BINDTODEVICE)
+ /* Only send packets from the given interface */
+ rb_define_const(rb_cSocket, "SO_BINDTODEVICE", INTEGER2NUM(SO_BINDTODEVICE));
+ /* Only send packets from the given interface */
+ rb_define_const(rb_mSockConst, "SO_BINDTODEVICE", INTEGER2NUM(SO_BINDTODEVICE));
+#endif
+#if defined(SO_ATTACH_FILTER)
+ /* Attach an accept filter */
+ rb_define_const(rb_cSocket, "SO_ATTACH_FILTER", INTEGER2NUM(SO_ATTACH_FILTER));
+ /* Attach an accept filter */
+ rb_define_const(rb_mSockConst, "SO_ATTACH_FILTER", INTEGER2NUM(SO_ATTACH_FILTER));
+#endif
+#if defined(SO_DETACH_FILTER)
+ /* Detach an accept filter */
+ rb_define_const(rb_cSocket, "SO_DETACH_FILTER", INTEGER2NUM(SO_DETACH_FILTER));
+ /* Detach an accept filter */
+ rb_define_const(rb_mSockConst, "SO_DETACH_FILTER", INTEGER2NUM(SO_DETACH_FILTER));
+#endif
+#if defined(SO_GET_FILTER)
+ /* Obtain filter set by SO_ATTACH_FILTER (Linux 3.8) */
+ rb_define_const(rb_cSocket, "SO_GET_FILTER", INTEGER2NUM(SO_GET_FILTER));
+ /* Obtain filter set by SO_ATTACH_FILTER (Linux 3.8) */
+ rb_define_const(rb_mSockConst, "SO_GET_FILTER", INTEGER2NUM(SO_GET_FILTER));
+#endif
+#if defined(SO_PEERNAME)
+ /* Name of the connecting user */
+ rb_define_const(rb_cSocket, "SO_PEERNAME", INTEGER2NUM(SO_PEERNAME));
+ /* Name of the connecting user */
+ rb_define_const(rb_mSockConst, "SO_PEERNAME", INTEGER2NUM(SO_PEERNAME));
+#endif
+#if defined(SO_TIMESTAMP)
+ /* Receive timestamp with datagrams (timeval) */
+ rb_define_const(rb_cSocket, "SO_TIMESTAMP", INTEGER2NUM(SO_TIMESTAMP));
+ /* Receive timestamp with datagrams (timeval) */
+ rb_define_const(rb_mSockConst, "SO_TIMESTAMP", INTEGER2NUM(SO_TIMESTAMP));
+#endif
+#if defined(SO_TIMESTAMPNS)
+ /* Receive nanosecond timestamp with datagrams (timespec) */
+ rb_define_const(rb_cSocket, "SO_TIMESTAMPNS", INTEGER2NUM(SO_TIMESTAMPNS));
+ /* Receive nanosecond timestamp with datagrams (timespec) */
+ rb_define_const(rb_mSockConst, "SO_TIMESTAMPNS", INTEGER2NUM(SO_TIMESTAMPNS));
+#endif
+#if defined(SO_BINTIME)
+ /* Receive timestamp with datagrams (bintime) */
+ rb_define_const(rb_cSocket, "SO_BINTIME", INTEGER2NUM(SO_BINTIME));
+ /* Receive timestamp with datagrams (bintime) */
+ rb_define_const(rb_mSockConst, "SO_BINTIME", INTEGER2NUM(SO_BINTIME));
+#endif
+#if defined(SO_RECVUCRED)
+ /* Receive user credentials with datagram */
+ rb_define_const(rb_cSocket, "SO_RECVUCRED", INTEGER2NUM(SO_RECVUCRED));
+ /* Receive user credentials with datagram */
+ rb_define_const(rb_mSockConst, "SO_RECVUCRED", INTEGER2NUM(SO_RECVUCRED));
+#endif
+#if defined(SO_MAC_EXEMPT)
+ /* Mandatory Access Control exemption for unlabeled peers */
+ rb_define_const(rb_cSocket, "SO_MAC_EXEMPT", INTEGER2NUM(SO_MAC_EXEMPT));
+ /* Mandatory Access Control exemption for unlabeled peers */
+ rb_define_const(rb_mSockConst, "SO_MAC_EXEMPT", INTEGER2NUM(SO_MAC_EXEMPT));
+#endif
+#if defined(SO_ALLZONES)
+ /* Bypass zone boundaries */
+ rb_define_const(rb_cSocket, "SO_ALLZONES", INTEGER2NUM(SO_ALLZONES));
+ /* Bypass zone boundaries */
+ rb_define_const(rb_mSockConst, "SO_ALLZONES", INTEGER2NUM(SO_ALLZONES));
+#endif
+#if defined(SO_PEERSEC)
+ /* Obtain the security credentials (Linux 2.6.2) */
+ rb_define_const(rb_cSocket, "SO_PEERSEC", INTEGER2NUM(SO_PEERSEC));
+ /* Obtain the security credentials (Linux 2.6.2) */
+ rb_define_const(rb_mSockConst, "SO_PEERSEC", INTEGER2NUM(SO_PEERSEC));
+#endif
+#if defined(SO_PASSSEC)
+ /* Toggle security context passing (Linux 2.6.18) */
+ rb_define_const(rb_cSocket, "SO_PASSSEC", INTEGER2NUM(SO_PASSSEC));
+ /* Toggle security context passing (Linux 2.6.18) */
+ rb_define_const(rb_mSockConst, "SO_PASSSEC", INTEGER2NUM(SO_PASSSEC));
+#endif
+#if defined(SO_MARK)
+ /* Set the mark for mark-based routing (Linux 2.6.25) */
+ rb_define_const(rb_cSocket, "SO_MARK", INTEGER2NUM(SO_MARK));
+ /* Set the mark for mark-based routing (Linux 2.6.25) */
+ rb_define_const(rb_mSockConst, "SO_MARK", INTEGER2NUM(SO_MARK));
+#endif
+#if defined(SO_TIMESTAMPING)
+ /* Time stamping of incoming and outgoing packets (Linux 2.6.30) */
+ rb_define_const(rb_cSocket, "SO_TIMESTAMPING", INTEGER2NUM(SO_TIMESTAMPING));
+ /* Time stamping of incoming and outgoing packets (Linux 2.6.30) */
+ rb_define_const(rb_mSockConst, "SO_TIMESTAMPING", INTEGER2NUM(SO_TIMESTAMPING));
+#endif
+#if defined(SO_PROTOCOL)
+ /* Protocol given for socket() (Linux 2.6.32) */
+ rb_define_const(rb_cSocket, "SO_PROTOCOL", INTEGER2NUM(SO_PROTOCOL));
+ /* Protocol given for socket() (Linux 2.6.32) */
+ rb_define_const(rb_mSockConst, "SO_PROTOCOL", INTEGER2NUM(SO_PROTOCOL));
+#endif
+#if defined(SO_DOMAIN)
+ /* Domain given for socket() (Linux 2.6.32) */
+ rb_define_const(rb_cSocket, "SO_DOMAIN", INTEGER2NUM(SO_DOMAIN));
+ /* Domain given for socket() (Linux 2.6.32) */
+ rb_define_const(rb_mSockConst, "SO_DOMAIN", INTEGER2NUM(SO_DOMAIN));
+#endif
+#if defined(SO_RXQ_OVFL)
+ /* Toggle cmsg for number of packets dropped (Linux 2.6.33) */
+ rb_define_const(rb_cSocket, "SO_RXQ_OVFL", INTEGER2NUM(SO_RXQ_OVFL));
+ /* Toggle cmsg for number of packets dropped (Linux 2.6.33) */
+ rb_define_const(rb_mSockConst, "SO_RXQ_OVFL", INTEGER2NUM(SO_RXQ_OVFL));
+#endif
+#if defined(SO_WIFI_STATUS)
+ /* Toggle cmsg for wifi status (Linux 3.3) */
+ rb_define_const(rb_cSocket, "SO_WIFI_STATUS", INTEGER2NUM(SO_WIFI_STATUS));
+ /* Toggle cmsg for wifi status (Linux 3.3) */
+ rb_define_const(rb_mSockConst, "SO_WIFI_STATUS", INTEGER2NUM(SO_WIFI_STATUS));
+#endif
+#if defined(SO_PEEK_OFF)
+ /* Set the peek offset (Linux 3.4) */
+ rb_define_const(rb_cSocket, "SO_PEEK_OFF", INTEGER2NUM(SO_PEEK_OFF));
+ /* Set the peek offset (Linux 3.4) */
+ rb_define_const(rb_mSockConst, "SO_PEEK_OFF", INTEGER2NUM(SO_PEEK_OFF));
+#endif
+#if defined(SO_NOFCS)
+ /* Set netns of a socket (Linux 3.4) */
+ rb_define_const(rb_cSocket, "SO_NOFCS", INTEGER2NUM(SO_NOFCS));
+ /* Set netns of a socket (Linux 3.4) */
+ rb_define_const(rb_mSockConst, "SO_NOFCS", INTEGER2NUM(SO_NOFCS));
+#endif
+#if defined(SO_LOCK_FILTER)
+ /* Lock the filter attached to a socket (Linux 3.9) */
+ rb_define_const(rb_cSocket, "SO_LOCK_FILTER", INTEGER2NUM(SO_LOCK_FILTER));
+ /* Lock the filter attached to a socket (Linux 3.9) */
+ rb_define_const(rb_mSockConst, "SO_LOCK_FILTER", INTEGER2NUM(SO_LOCK_FILTER));
+#endif
+#if defined(SO_SELECT_ERR_QUEUE)
+ /* Make select() detect socket error queue with errorfds (Linux 3.10) */
+ rb_define_const(rb_cSocket, "SO_SELECT_ERR_QUEUE", INTEGER2NUM(SO_SELECT_ERR_QUEUE));
+ /* Make select() detect socket error queue with errorfds (Linux 3.10) */
+ rb_define_const(rb_mSockConst, "SO_SELECT_ERR_QUEUE", INTEGER2NUM(SO_SELECT_ERR_QUEUE));
+#endif
+#if defined(SO_BUSY_POLL)
+ /* Set the threshold in microseconds for low latency polling (Linux 3.11) */
+ rb_define_const(rb_cSocket, "SO_BUSY_POLL", INTEGER2NUM(SO_BUSY_POLL));
+ /* Set the threshold in microseconds for low latency polling (Linux 3.11) */
+ rb_define_const(rb_mSockConst, "SO_BUSY_POLL", INTEGER2NUM(SO_BUSY_POLL));
+#endif
+#if defined(SO_MAX_PACING_RATE)
+ /* Cap the rate computed by transport layer. [bytes per second] (Linux 3.13) */
+ rb_define_const(rb_cSocket, "SO_MAX_PACING_RATE", INTEGER2NUM(SO_MAX_PACING_RATE));
+ /* Cap the rate computed by transport layer. [bytes per second] (Linux 3.13) */
+ rb_define_const(rb_mSockConst, "SO_MAX_PACING_RATE", INTEGER2NUM(SO_MAX_PACING_RATE));
+#endif
+#if defined(SO_BPF_EXTENSIONS)
+ /* Query supported BPF extensions (Linux 3.14) */
+ rb_define_const(rb_cSocket, "SO_BPF_EXTENSIONS", INTEGER2NUM(SO_BPF_EXTENSIONS));
+ /* Query supported BPF extensions (Linux 3.14) */
+ rb_define_const(rb_mSockConst, "SO_BPF_EXTENSIONS", INTEGER2NUM(SO_BPF_EXTENSIONS));
+#endif
+#if defined(SOPRI_INTERACTIVE)
+ /* Interactive socket priority */
+ rb_define_const(rb_cSocket, "SOPRI_INTERACTIVE", INTEGER2NUM(SOPRI_INTERACTIVE));
+ /* Interactive socket priority */
+ rb_define_const(rb_mSockConst, "SOPRI_INTERACTIVE", INTEGER2NUM(SOPRI_INTERACTIVE));
+#endif
+#if defined(SOPRI_NORMAL)
+ /* Normal socket priority */
+ rb_define_const(rb_cSocket, "SOPRI_NORMAL", INTEGER2NUM(SOPRI_NORMAL));
+ /* Normal socket priority */
+ rb_define_const(rb_mSockConst, "SOPRI_NORMAL", INTEGER2NUM(SOPRI_NORMAL));
+#endif
+#if defined(SOPRI_BACKGROUND)
+ /* Background socket priority */
+ rb_define_const(rb_cSocket, "SOPRI_BACKGROUND", INTEGER2NUM(SOPRI_BACKGROUND));
+ /* Background socket priority */
+ rb_define_const(rb_mSockConst, "SOPRI_BACKGROUND", INTEGER2NUM(SOPRI_BACKGROUND));
+#endif
+#if defined(IPX_TYPE)
+ /* */
+ rb_define_const(rb_cSocket, "IPX_TYPE", INTEGER2NUM(IPX_TYPE));
+ /* */
+ rb_define_const(rb_mSockConst, "IPX_TYPE", INTEGER2NUM(IPX_TYPE));
+#endif
+#if defined(TCP_NODELAY)
+ /* Don't delay sending to coalesce packets */
+ rb_define_const(rb_cSocket, "TCP_NODELAY", INTEGER2NUM(TCP_NODELAY));
+ /* Don't delay sending to coalesce packets */
+ rb_define_const(rb_mSockConst, "TCP_NODELAY", INTEGER2NUM(TCP_NODELAY));
+#endif
+#if defined(TCP_MAXSEG)
+ /* Set maximum segment size */
+ rb_define_const(rb_cSocket, "TCP_MAXSEG", INTEGER2NUM(TCP_MAXSEG));
+ /* Set maximum segment size */
+ rb_define_const(rb_mSockConst, "TCP_MAXSEG", INTEGER2NUM(TCP_MAXSEG));
+#endif
+#if defined(TCP_CORK)
+ /* Don't send partial frames (Linux 2.2, glibc 2.2) */
+ rb_define_const(rb_cSocket, "TCP_CORK", INTEGER2NUM(TCP_CORK));
+ /* Don't send partial frames (Linux 2.2, glibc 2.2) */
+ rb_define_const(rb_mSockConst, "TCP_CORK", INTEGER2NUM(TCP_CORK));
+#endif
+#if defined(TCP_DEFER_ACCEPT)
+ /* Don't notify a listening socket until data is ready (Linux 2.4, glibc 2.2) */
+ rb_define_const(rb_cSocket, "TCP_DEFER_ACCEPT", INTEGER2NUM(TCP_DEFER_ACCEPT));
+ /* Don't notify a listening socket until data is ready (Linux 2.4, glibc 2.2) */
+ rb_define_const(rb_mSockConst, "TCP_DEFER_ACCEPT", INTEGER2NUM(TCP_DEFER_ACCEPT));
+#endif
+#if defined(TCP_INFO)
+ /* Retrieve information about this socket (Linux 2.4, glibc 2.2) */
+ rb_define_const(rb_cSocket, "TCP_INFO", INTEGER2NUM(TCP_INFO));
+ /* Retrieve information about this socket (Linux 2.4, glibc 2.2) */
+ rb_define_const(rb_mSockConst, "TCP_INFO", INTEGER2NUM(TCP_INFO));
+#endif
+#if defined(TCP_KEEPCNT)
+ /* Maximum number of keepalive probes allowed before dropping a connection (Linux 2.4, glibc 2.2) */
+ rb_define_const(rb_cSocket, "TCP_KEEPCNT", INTEGER2NUM(TCP_KEEPCNT));
+ /* Maximum number of keepalive probes allowed before dropping a connection (Linux 2.4, glibc 2.2) */
+ rb_define_const(rb_mSockConst, "TCP_KEEPCNT", INTEGER2NUM(TCP_KEEPCNT));
+#endif
+#if defined(TCP_KEEPIDLE)
+ /* Idle time before keepalive probes are sent (Linux 2.4, glibc 2.2) */
+ rb_define_const(rb_cSocket, "TCP_KEEPIDLE", INTEGER2NUM(TCP_KEEPIDLE));
+ /* Idle time before keepalive probes are sent (Linux 2.4, glibc 2.2) */
+ rb_define_const(rb_mSockConst, "TCP_KEEPIDLE", INTEGER2NUM(TCP_KEEPIDLE));
+#endif
+#if defined(TCP_KEEPINTVL)
+ /* Time between keepalive probes (Linux 2.4, glibc 2.2) */
+ rb_define_const(rb_cSocket, "TCP_KEEPINTVL", INTEGER2NUM(TCP_KEEPINTVL));
+ /* Time between keepalive probes (Linux 2.4, glibc 2.2) */
+ rb_define_const(rb_mSockConst, "TCP_KEEPINTVL", INTEGER2NUM(TCP_KEEPINTVL));
+#endif
+#if defined(TCP_LINGER2)
+ /* Lifetime of orphaned FIN_WAIT2 sockets (Linux 2.4, glibc 2.2) */
+ rb_define_const(rb_cSocket, "TCP_LINGER2", INTEGER2NUM(TCP_LINGER2));
+ /* Lifetime of orphaned FIN_WAIT2 sockets (Linux 2.4, glibc 2.2) */
+ rb_define_const(rb_mSockConst, "TCP_LINGER2", INTEGER2NUM(TCP_LINGER2));
+#endif
+#if defined(TCP_MD5SIG)
+ /* Use MD5 digests (RFC2385, Linux 2.6.20, glibc 2.7) */
+ rb_define_const(rb_cSocket, "TCP_MD5SIG", INTEGER2NUM(TCP_MD5SIG));
+ /* Use MD5 digests (RFC2385, Linux 2.6.20, glibc 2.7) */
+ rb_define_const(rb_mSockConst, "TCP_MD5SIG", INTEGER2NUM(TCP_MD5SIG));
+#endif
+#if defined(TCP_NOOPT)
+ /* Don't use TCP options */
+ rb_define_const(rb_cSocket, "TCP_NOOPT", INTEGER2NUM(TCP_NOOPT));
+ /* Don't use TCP options */
+ rb_define_const(rb_mSockConst, "TCP_NOOPT", INTEGER2NUM(TCP_NOOPT));
+#endif
+#if defined(TCP_NOPUSH)
+ /* Don't push the last block of write */
+ rb_define_const(rb_cSocket, "TCP_NOPUSH", INTEGER2NUM(TCP_NOPUSH));
+ /* Don't push the last block of write */
+ rb_define_const(rb_mSockConst, "TCP_NOPUSH", INTEGER2NUM(TCP_NOPUSH));
+#endif
+#if defined(TCP_QUICKACK)
+ /* Enable quickack mode (Linux 2.4.4, glibc 2.3) */
+ rb_define_const(rb_cSocket, "TCP_QUICKACK", INTEGER2NUM(TCP_QUICKACK));
+ /* Enable quickack mode (Linux 2.4.4, glibc 2.3) */
+ rb_define_const(rb_mSockConst, "TCP_QUICKACK", INTEGER2NUM(TCP_QUICKACK));
+#endif
+#if defined(TCP_SYNCNT)
+ /* Number of SYN retransmits before a connection is dropped (Linux 2.4, glibc 2.2) */
+ rb_define_const(rb_cSocket, "TCP_SYNCNT", INTEGER2NUM(TCP_SYNCNT));
+ /* Number of SYN retransmits before a connection is dropped (Linux 2.4, glibc 2.2) */
+ rb_define_const(rb_mSockConst, "TCP_SYNCNT", INTEGER2NUM(TCP_SYNCNT));
+#endif
+#if defined(TCP_WINDOW_CLAMP)
+ /* Clamp the size of the advertised window (Linux 2.4, glibc 2.2) */
+ rb_define_const(rb_cSocket, "TCP_WINDOW_CLAMP", INTEGER2NUM(TCP_WINDOW_CLAMP));
+ /* Clamp the size of the advertised window (Linux 2.4, glibc 2.2) */
+ rb_define_const(rb_mSockConst, "TCP_WINDOW_CLAMP", INTEGER2NUM(TCP_WINDOW_CLAMP));
+#endif
+#if defined(TCP_FASTOPEN)
+ /* Reduce step of the handshake process (Linux 3.7, glibc 2.18) */
+ rb_define_const(rb_cSocket, "TCP_FASTOPEN", INTEGER2NUM(TCP_FASTOPEN));
+ /* Reduce step of the handshake process (Linux 3.7, glibc 2.18) */
+ rb_define_const(rb_mSockConst, "TCP_FASTOPEN", INTEGER2NUM(TCP_FASTOPEN));
+#endif
+#if defined(TCP_CONGESTION)
+ /* TCP congestion control algorithm (Linux 2.6.13, glibc 2.6) */
+ rb_define_const(rb_cSocket, "TCP_CONGESTION", INTEGER2NUM(TCP_CONGESTION));
+ /* TCP congestion control algorithm (Linux 2.6.13, glibc 2.6) */
+ rb_define_const(rb_mSockConst, "TCP_CONGESTION", INTEGER2NUM(TCP_CONGESTION));
+#endif
+#if defined(TCP_COOKIE_TRANSACTIONS)
+ /* TCP Cookie Transactions (Linux 2.6.33, glibc 2.18) */
+ rb_define_const(rb_cSocket, "TCP_COOKIE_TRANSACTIONS", INTEGER2NUM(TCP_COOKIE_TRANSACTIONS));
+ /* TCP Cookie Transactions (Linux 2.6.33, glibc 2.18) */
+ rb_define_const(rb_mSockConst, "TCP_COOKIE_TRANSACTIONS", INTEGER2NUM(TCP_COOKIE_TRANSACTIONS));
+#endif
+#if defined(TCP_QUEUE_SEQ)
+ /* Sequence of a queue for repair mode (Linux 3.5, glibc 2.18) */
+ rb_define_const(rb_cSocket, "TCP_QUEUE_SEQ", INTEGER2NUM(TCP_QUEUE_SEQ));
+ /* Sequence of a queue for repair mode (Linux 3.5, glibc 2.18) */
+ rb_define_const(rb_mSockConst, "TCP_QUEUE_SEQ", INTEGER2NUM(TCP_QUEUE_SEQ));
+#endif
+#if defined(TCP_REPAIR)
+ /* Repair mode (Linux 3.5, glibc 2.18) */
+ rb_define_const(rb_cSocket, "TCP_REPAIR", INTEGER2NUM(TCP_REPAIR));
+ /* Repair mode (Linux 3.5, glibc 2.18) */
+ rb_define_const(rb_mSockConst, "TCP_REPAIR", INTEGER2NUM(TCP_REPAIR));
+#endif
+#if defined(TCP_REPAIR_OPTIONS)
+ /* Options for repair mode (Linux 3.5, glibc 2.18) */
+ rb_define_const(rb_cSocket, "TCP_REPAIR_OPTIONS", INTEGER2NUM(TCP_REPAIR_OPTIONS));
+ /* Options for repair mode (Linux 3.5, glibc 2.18) */
+ rb_define_const(rb_mSockConst, "TCP_REPAIR_OPTIONS", INTEGER2NUM(TCP_REPAIR_OPTIONS));
+#endif
+#if defined(TCP_REPAIR_QUEUE)
+ /* Queue for repair mode (Linux 3.5, glibc 2.18) */
+ rb_define_const(rb_cSocket, "TCP_REPAIR_QUEUE", INTEGER2NUM(TCP_REPAIR_QUEUE));
+ /* Queue for repair mode (Linux 3.5, glibc 2.18) */
+ rb_define_const(rb_mSockConst, "TCP_REPAIR_QUEUE", INTEGER2NUM(TCP_REPAIR_QUEUE));
+#endif
+#if defined(TCP_THIN_DUPACK)
+ /* Duplicated acknowledgments handling for thin-streams (Linux 2.6.34, glibc 2.18) */
+ rb_define_const(rb_cSocket, "TCP_THIN_DUPACK", INTEGER2NUM(TCP_THIN_DUPACK));
+ /* Duplicated acknowledgments handling for thin-streams (Linux 2.6.34, glibc 2.18) */
+ rb_define_const(rb_mSockConst, "TCP_THIN_DUPACK", INTEGER2NUM(TCP_THIN_DUPACK));
+#endif
+#if defined(TCP_THIN_LINEAR_TIMEOUTS)
+ /* Linear timeouts for thin-streams (Linux 2.6.34, glibc 2.18) */
+ rb_define_const(rb_cSocket, "TCP_THIN_LINEAR_TIMEOUTS", INTEGER2NUM(TCP_THIN_LINEAR_TIMEOUTS));
+ /* Linear timeouts for thin-streams (Linux 2.6.34, glibc 2.18) */
+ rb_define_const(rb_mSockConst, "TCP_THIN_LINEAR_TIMEOUTS", INTEGER2NUM(TCP_THIN_LINEAR_TIMEOUTS));
+#endif
+#if defined(TCP_TIMESTAMP)
+ /* TCP timestamp (Linux 3.9, glibc 2.18) */
+ rb_define_const(rb_cSocket, "TCP_TIMESTAMP", INTEGER2NUM(TCP_TIMESTAMP));
+ /* TCP timestamp (Linux 3.9, glibc 2.18) */
+ rb_define_const(rb_mSockConst, "TCP_TIMESTAMP", INTEGER2NUM(TCP_TIMESTAMP));
+#endif
+#if defined(TCP_USER_TIMEOUT)
+ /* Max timeout before a TCP connection is aborted (Linux 2.6.37, glibc 2.18) */
+ rb_define_const(rb_cSocket, "TCP_USER_TIMEOUT", INTEGER2NUM(TCP_USER_TIMEOUT));
+ /* Max timeout before a TCP connection is aborted (Linux 2.6.37, glibc 2.18) */
+ rb_define_const(rb_mSockConst, "TCP_USER_TIMEOUT", INTEGER2NUM(TCP_USER_TIMEOUT));
+#endif
+#if defined(UDP_CORK)
+ /* Don't send partial frames (Linux 2.5.44, glibc 2.11) */
+ rb_define_const(rb_cSocket, "UDP_CORK", INTEGER2NUM(UDP_CORK));
+ /* Don't send partial frames (Linux 2.5.44, glibc 2.11) */
+ rb_define_const(rb_mSockConst, "UDP_CORK", INTEGER2NUM(UDP_CORK));
+#endif
+#if defined(EAI_ADDRFAMILY)
+ /* Address family for hostname not supported */
+ rb_define_const(rb_cSocket, "EAI_ADDRFAMILY", INTEGER2NUM(EAI_ADDRFAMILY));
+ /* Address family for hostname not supported */
+ rb_define_const(rb_mSockConst, "EAI_ADDRFAMILY", INTEGER2NUM(EAI_ADDRFAMILY));
+#endif
+#if defined(EAI_AGAIN)
+ /* Temporary failure in name resolution */
+ rb_define_const(rb_cSocket, "EAI_AGAIN", INTEGER2NUM(EAI_AGAIN));
+ /* Temporary failure in name resolution */
+ rb_define_const(rb_mSockConst, "EAI_AGAIN", INTEGER2NUM(EAI_AGAIN));
+#endif
+#if defined(EAI_BADFLAGS)
+ /* Invalid flags */
+ rb_define_const(rb_cSocket, "EAI_BADFLAGS", INTEGER2NUM(EAI_BADFLAGS));
+ /* Invalid flags */
+ rb_define_const(rb_mSockConst, "EAI_BADFLAGS", INTEGER2NUM(EAI_BADFLAGS));
+#endif
+#if defined(EAI_FAIL)
+ /* Non-recoverable failure in name resolution */
+ rb_define_const(rb_cSocket, "EAI_FAIL", INTEGER2NUM(EAI_FAIL));
+ /* Non-recoverable failure in name resolution */
+ rb_define_const(rb_mSockConst, "EAI_FAIL", INTEGER2NUM(EAI_FAIL));
+#endif
+#if defined(EAI_FAMILY)
+ /* Address family not supported */
+ rb_define_const(rb_cSocket, "EAI_FAMILY", INTEGER2NUM(EAI_FAMILY));
+ /* Address family not supported */
+ rb_define_const(rb_mSockConst, "EAI_FAMILY", INTEGER2NUM(EAI_FAMILY));
+#endif
+#if defined(EAI_MEMORY)
+ /* Memory allocation failure */
+ rb_define_const(rb_cSocket, "EAI_MEMORY", INTEGER2NUM(EAI_MEMORY));
+ /* Memory allocation failure */
+ rb_define_const(rb_mSockConst, "EAI_MEMORY", INTEGER2NUM(EAI_MEMORY));
+#endif
+#if defined(EAI_NODATA)
+ /* No address associated with hostname */
+ rb_define_const(rb_cSocket, "EAI_NODATA", INTEGER2NUM(EAI_NODATA));
+ /* No address associated with hostname */
+ rb_define_const(rb_mSockConst, "EAI_NODATA", INTEGER2NUM(EAI_NODATA));
+#endif
+#if defined(EAI_NONAME)
+ /* Hostname nor servname, or not known */
+ rb_define_const(rb_cSocket, "EAI_NONAME", INTEGER2NUM(EAI_NONAME));
+ /* Hostname nor servname, or not known */
+ rb_define_const(rb_mSockConst, "EAI_NONAME", INTEGER2NUM(EAI_NONAME));
+#endif
+#if defined(EAI_OVERFLOW)
+ /* Argument buffer overflow */
+ rb_define_const(rb_cSocket, "EAI_OVERFLOW", INTEGER2NUM(EAI_OVERFLOW));
+ /* Argument buffer overflow */
+ rb_define_const(rb_mSockConst, "EAI_OVERFLOW", INTEGER2NUM(EAI_OVERFLOW));
+#endif
+#if defined(EAI_SERVICE)
+ /* Servname not supported for socket type */
+ rb_define_const(rb_cSocket, "EAI_SERVICE", INTEGER2NUM(EAI_SERVICE));
+ /* Servname not supported for socket type */
+ rb_define_const(rb_mSockConst, "EAI_SERVICE", INTEGER2NUM(EAI_SERVICE));
+#endif
+#if defined(EAI_SOCKTYPE)
+ /* Socket type not supported */
+ rb_define_const(rb_cSocket, "EAI_SOCKTYPE", INTEGER2NUM(EAI_SOCKTYPE));
+ /* Socket type not supported */
+ rb_define_const(rb_mSockConst, "EAI_SOCKTYPE", INTEGER2NUM(EAI_SOCKTYPE));
+#endif
+#if defined(EAI_SYSTEM)
+ /* System error returned in errno */
+ rb_define_const(rb_cSocket, "EAI_SYSTEM", INTEGER2NUM(EAI_SYSTEM));
+ /* System error returned in errno */
+ rb_define_const(rb_mSockConst, "EAI_SYSTEM", INTEGER2NUM(EAI_SYSTEM));
+#endif
+#if defined(EAI_BADHINTS)
+ /* Invalid value for hints */
+ rb_define_const(rb_cSocket, "EAI_BADHINTS", INTEGER2NUM(EAI_BADHINTS));
+ /* Invalid value for hints */
+ rb_define_const(rb_mSockConst, "EAI_BADHINTS", INTEGER2NUM(EAI_BADHINTS));
+#endif
+#if defined(EAI_PROTOCOL)
+ /* Resolved protocol is unknown */
+ rb_define_const(rb_cSocket, "EAI_PROTOCOL", INTEGER2NUM(EAI_PROTOCOL));
+ /* Resolved protocol is unknown */
+ rb_define_const(rb_mSockConst, "EAI_PROTOCOL", INTEGER2NUM(EAI_PROTOCOL));
+#endif
+#if defined(EAI_MAX)
+ /* Maximum error code from getaddrinfo */
+ rb_define_const(rb_cSocket, "EAI_MAX", INTEGER2NUM(EAI_MAX));
+ /* Maximum error code from getaddrinfo */
+ rb_define_const(rb_mSockConst, "EAI_MAX", INTEGER2NUM(EAI_MAX));
+#endif
+#if defined(AI_PASSIVE)
+ /* Get address to use with bind() */
+ rb_define_const(rb_cSocket, "AI_PASSIVE", INTEGER2NUM(AI_PASSIVE));
+ /* Get address to use with bind() */
+ rb_define_const(rb_mSockConst, "AI_PASSIVE", INTEGER2NUM(AI_PASSIVE));
+#endif
+#if defined(AI_CANONNAME)
+ /* Fill in the canonical name */
+ rb_define_const(rb_cSocket, "AI_CANONNAME", INTEGER2NUM(AI_CANONNAME));
+ /* Fill in the canonical name */
+ rb_define_const(rb_mSockConst, "AI_CANONNAME", INTEGER2NUM(AI_CANONNAME));
+#endif
+#if defined(AI_NUMERICHOST)
+ /* Prevent host name resolution */
+ rb_define_const(rb_cSocket, "AI_NUMERICHOST", INTEGER2NUM(AI_NUMERICHOST));
+ /* Prevent host name resolution */
+ rb_define_const(rb_mSockConst, "AI_NUMERICHOST", INTEGER2NUM(AI_NUMERICHOST));
+#endif
+#if defined(AI_NUMERICSERV)
+ /* Prevent service name resolution */
+ rb_define_const(rb_cSocket, "AI_NUMERICSERV", INTEGER2NUM(AI_NUMERICSERV));
+ /* Prevent service name resolution */
+ rb_define_const(rb_mSockConst, "AI_NUMERICSERV", INTEGER2NUM(AI_NUMERICSERV));
+#endif
+#if defined(AI_MASK)
+ /* Valid flag mask for getaddrinfo (not for application use) */
+ rb_define_const(rb_cSocket, "AI_MASK", INTEGER2NUM(AI_MASK));
+ /* Valid flag mask for getaddrinfo (not for application use) */
+ rb_define_const(rb_mSockConst, "AI_MASK", INTEGER2NUM(AI_MASK));
+#endif
+#if defined(AI_ALL)
+ /* Allow all addresses */
+ rb_define_const(rb_cSocket, "AI_ALL", INTEGER2NUM(AI_ALL));
+ /* Allow all addresses */
+ rb_define_const(rb_mSockConst, "AI_ALL", INTEGER2NUM(AI_ALL));
+#endif
+#if defined(AI_V4MAPPED_CFG)
+ /* Accept IPv4 mapped addresses if the kernel supports it */
+ rb_define_const(rb_cSocket, "AI_V4MAPPED_CFG", INTEGER2NUM(AI_V4MAPPED_CFG));
+ /* Accept IPv4 mapped addresses if the kernel supports it */
+ rb_define_const(rb_mSockConst, "AI_V4MAPPED_CFG", INTEGER2NUM(AI_V4MAPPED_CFG));
+#endif
+#if defined(AI_ADDRCONFIG)
+ /* Accept only if any address is assigned */
+ rb_define_const(rb_cSocket, "AI_ADDRCONFIG", INTEGER2NUM(AI_ADDRCONFIG));
+ /* Accept only if any address is assigned */
+ rb_define_const(rb_mSockConst, "AI_ADDRCONFIG", INTEGER2NUM(AI_ADDRCONFIG));
+#endif
+#if defined(AI_V4MAPPED)
+ /* Accept IPv4-mapped IPv6 addresses */
+ rb_define_const(rb_cSocket, "AI_V4MAPPED", INTEGER2NUM(AI_V4MAPPED));
+ /* Accept IPv4-mapped IPv6 addresses */
+ rb_define_const(rb_mSockConst, "AI_V4MAPPED", INTEGER2NUM(AI_V4MAPPED));
+#endif
+#if defined(AI_DEFAULT)
+ /* Default flags for getaddrinfo */
+ rb_define_const(rb_cSocket, "AI_DEFAULT", INTEGER2NUM(AI_DEFAULT));
+ /* Default flags for getaddrinfo */
+ rb_define_const(rb_mSockConst, "AI_DEFAULT", INTEGER2NUM(AI_DEFAULT));
+#endif
+#if defined(NI_MAXHOST)
+ /* Maximum length of a hostname */
+ rb_define_const(rb_cSocket, "NI_MAXHOST", INTEGER2NUM(NI_MAXHOST));
+ /* Maximum length of a hostname */
+ rb_define_const(rb_mSockConst, "NI_MAXHOST", INTEGER2NUM(NI_MAXHOST));
+#endif
+#if defined(NI_MAXSERV)
+ /* Maximum length of a service name */
+ rb_define_const(rb_cSocket, "NI_MAXSERV", INTEGER2NUM(NI_MAXSERV));
+ /* Maximum length of a service name */
+ rb_define_const(rb_mSockConst, "NI_MAXSERV", INTEGER2NUM(NI_MAXSERV));
+#endif
+#if defined(NI_NOFQDN)
+ /* An FQDN is not required for local hosts, return only the local part */
+ rb_define_const(rb_cSocket, "NI_NOFQDN", INTEGER2NUM(NI_NOFQDN));
+ /* An FQDN is not required for local hosts, return only the local part */
+ rb_define_const(rb_mSockConst, "NI_NOFQDN", INTEGER2NUM(NI_NOFQDN));
+#endif
+#if defined(NI_NUMERICHOST)
+ /* Return a numeric address */
+ rb_define_const(rb_cSocket, "NI_NUMERICHOST", INTEGER2NUM(NI_NUMERICHOST));
+ /* Return a numeric address */
+ rb_define_const(rb_mSockConst, "NI_NUMERICHOST", INTEGER2NUM(NI_NUMERICHOST));
+#endif
+#if defined(NI_NAMEREQD)
+ /* A name is required */
+ rb_define_const(rb_cSocket, "NI_NAMEREQD", INTEGER2NUM(NI_NAMEREQD));
+ /* A name is required */
+ rb_define_const(rb_mSockConst, "NI_NAMEREQD", INTEGER2NUM(NI_NAMEREQD));
+#endif
+#if defined(NI_NUMERICSERV)
+ /* Return the service name as a digit string */
+ rb_define_const(rb_cSocket, "NI_NUMERICSERV", INTEGER2NUM(NI_NUMERICSERV));
+ /* Return the service name as a digit string */
+ rb_define_const(rb_mSockConst, "NI_NUMERICSERV", INTEGER2NUM(NI_NUMERICSERV));
+#endif
+#if defined(NI_DGRAM)
+ /* The service specified is a datagram service (looks up UDP ports) */
+ rb_define_const(rb_cSocket, "NI_DGRAM", INTEGER2NUM(NI_DGRAM));
+ /* The service specified is a datagram service (looks up UDP ports) */
+ rb_define_const(rb_mSockConst, "NI_DGRAM", INTEGER2NUM(NI_DGRAM));
+#endif
+#if defined(SHUT_RD)
+ /* Shut down the reading side of the socket */
+ rb_define_const(rb_cSocket, "SHUT_RD", INTEGER2NUM(SHUT_RD));
+ /* Shut down the reading side of the socket */
+ rb_define_const(rb_mSockConst, "SHUT_RD", INTEGER2NUM(SHUT_RD));
+#endif
+#if defined(SHUT_WR)
+ /* Shut down the writing side of the socket */
+ rb_define_const(rb_cSocket, "SHUT_WR", INTEGER2NUM(SHUT_WR));
+ /* Shut down the writing side of the socket */
+ rb_define_const(rb_mSockConst, "SHUT_WR", INTEGER2NUM(SHUT_WR));
+#endif
+#if defined(SHUT_RDWR)
+ /* Shut down the both sides of the socket */
+ rb_define_const(rb_cSocket, "SHUT_RDWR", INTEGER2NUM(SHUT_RDWR));
+ /* Shut down the both sides of the socket */
+ rb_define_const(rb_mSockConst, "SHUT_RDWR", INTEGER2NUM(SHUT_RDWR));
+#endif
+#if defined(INET6)
+#if defined(IPV6_JOIN_GROUP)
+ /* Join a group membership */
+ rb_define_const(rb_cSocket, "IPV6_JOIN_GROUP", INTEGER2NUM(IPV6_JOIN_GROUP));
+ /* Join a group membership */
+ rb_define_const(rb_mSockConst, "IPV6_JOIN_GROUP", INTEGER2NUM(IPV6_JOIN_GROUP));
+#endif
+#endif
+#if defined(INET6)
+#if defined(IPV6_LEAVE_GROUP)
+ /* Leave a group membership */
+ rb_define_const(rb_cSocket, "IPV6_LEAVE_GROUP", INTEGER2NUM(IPV6_LEAVE_GROUP));
+ /* Leave a group membership */
+ rb_define_const(rb_mSockConst, "IPV6_LEAVE_GROUP", INTEGER2NUM(IPV6_LEAVE_GROUP));
+#endif
+#endif
+#if defined(INET6)
+#if defined(IPV6_MULTICAST_HOPS)
+ /* IP6 multicast hops */
+ rb_define_const(rb_cSocket, "IPV6_MULTICAST_HOPS", INTEGER2NUM(IPV6_MULTICAST_HOPS));
+ /* IP6 multicast hops */
+ rb_define_const(rb_mSockConst, "IPV6_MULTICAST_HOPS", INTEGER2NUM(IPV6_MULTICAST_HOPS));
+#endif
+#endif
+#if defined(INET6)
+#if defined(IPV6_MULTICAST_IF)
+ /* IP6 multicast interface */
+ rb_define_const(rb_cSocket, "IPV6_MULTICAST_IF", INTEGER2NUM(IPV6_MULTICAST_IF));
+ /* IP6 multicast interface */
+ rb_define_const(rb_mSockConst, "IPV6_MULTICAST_IF", INTEGER2NUM(IPV6_MULTICAST_IF));
+#endif
+#endif
+#if defined(INET6)
+#if defined(IPV6_MULTICAST_LOOP)
+ /* IP6 multicast loopback */
+ rb_define_const(rb_cSocket, "IPV6_MULTICAST_LOOP", INTEGER2NUM(IPV6_MULTICAST_LOOP));
+ /* IP6 multicast loopback */
+ rb_define_const(rb_mSockConst, "IPV6_MULTICAST_LOOP", INTEGER2NUM(IPV6_MULTICAST_LOOP));
+#endif
+#endif
+#if defined(INET6)
+#if defined(IPV6_UNICAST_HOPS)
+ /* IP6 unicast hops */
+ rb_define_const(rb_cSocket, "IPV6_UNICAST_HOPS", INTEGER2NUM(IPV6_UNICAST_HOPS));
+ /* IP6 unicast hops */
+ rb_define_const(rb_mSockConst, "IPV6_UNICAST_HOPS", INTEGER2NUM(IPV6_UNICAST_HOPS));
+#endif
+#endif
+#if defined(INET6)
+#if defined(IPV6_V6ONLY)
+ /* Only bind IPv6 with a wildcard bind */
+ rb_define_const(rb_cSocket, "IPV6_V6ONLY", INTEGER2NUM(IPV6_V6ONLY));
+ /* Only bind IPv6 with a wildcard bind */
+ rb_define_const(rb_mSockConst, "IPV6_V6ONLY", INTEGER2NUM(IPV6_V6ONLY));
+#endif
+#endif
+#if defined(INET6)
+#if defined(IPV6_CHECKSUM)
+ /* Checksum offset for raw sockets */
+ rb_define_const(rb_cSocket, "IPV6_CHECKSUM", INTEGER2NUM(IPV6_CHECKSUM));
+ /* Checksum offset for raw sockets */
+ rb_define_const(rb_mSockConst, "IPV6_CHECKSUM", INTEGER2NUM(IPV6_CHECKSUM));
+#endif
+#endif
+#if defined(INET6)
+#if defined(IPV6_DONTFRAG)
+ /* Don't fragment packets */
+ rb_define_const(rb_cSocket, "IPV6_DONTFRAG", INTEGER2NUM(IPV6_DONTFRAG));
+ /* Don't fragment packets */
+ rb_define_const(rb_mSockConst, "IPV6_DONTFRAG", INTEGER2NUM(IPV6_DONTFRAG));
+#endif
+#endif
+#if defined(INET6)
+#if defined(IPV6_DSTOPTS)
+ /* Destination option */
+ rb_define_const(rb_cSocket, "IPV6_DSTOPTS", INTEGER2NUM(IPV6_DSTOPTS));
+ /* Destination option */
+ rb_define_const(rb_mSockConst, "IPV6_DSTOPTS", INTEGER2NUM(IPV6_DSTOPTS));
+#endif
+#endif
+#if defined(INET6)
+#if defined(IPV6_HOPLIMIT)
+ /* Hop limit */
+ rb_define_const(rb_cSocket, "IPV6_HOPLIMIT", INTEGER2NUM(IPV6_HOPLIMIT));
+ /* Hop limit */
+ rb_define_const(rb_mSockConst, "IPV6_HOPLIMIT", INTEGER2NUM(IPV6_HOPLIMIT));
+#endif
+#endif
+#if defined(INET6)
+#if defined(IPV6_HOPOPTS)
+ /* Hop-by-hop option */
+ rb_define_const(rb_cSocket, "IPV6_HOPOPTS", INTEGER2NUM(IPV6_HOPOPTS));
+ /* Hop-by-hop option */
+ rb_define_const(rb_mSockConst, "IPV6_HOPOPTS", INTEGER2NUM(IPV6_HOPOPTS));
+#endif
+#endif
+#if defined(INET6)
+#if defined(IPV6_NEXTHOP)
+ /* Next hop address */
+ rb_define_const(rb_cSocket, "IPV6_NEXTHOP", INTEGER2NUM(IPV6_NEXTHOP));
+ /* Next hop address */
+ rb_define_const(rb_mSockConst, "IPV6_NEXTHOP", INTEGER2NUM(IPV6_NEXTHOP));
+#endif
+#endif
+#if defined(INET6)
+#if defined(IPV6_PATHMTU)
+ /* Retrieve current path MTU */
+ rb_define_const(rb_cSocket, "IPV6_PATHMTU", INTEGER2NUM(IPV6_PATHMTU));
+ /* Retrieve current path MTU */
+ rb_define_const(rb_mSockConst, "IPV6_PATHMTU", INTEGER2NUM(IPV6_PATHMTU));
+#endif
+#endif
+#if defined(INET6)
+#if defined(IPV6_PKTINFO)
+ /* Receive packet information with datagram */
+ rb_define_const(rb_cSocket, "IPV6_PKTINFO", INTEGER2NUM(IPV6_PKTINFO));
+ /* Receive packet information with datagram */
+ rb_define_const(rb_mSockConst, "IPV6_PKTINFO", INTEGER2NUM(IPV6_PKTINFO));
+#endif
+#endif
+#if defined(INET6)
+#if defined(IPV6_RECVDSTOPTS)
+ /* Receive all IP6 options for response */
+ rb_define_const(rb_cSocket, "IPV6_RECVDSTOPTS", INTEGER2NUM(IPV6_RECVDSTOPTS));
+ /* Receive all IP6 options for response */
+ rb_define_const(rb_mSockConst, "IPV6_RECVDSTOPTS", INTEGER2NUM(IPV6_RECVDSTOPTS));
+#endif
+#endif
+#if defined(INET6)
+#if defined(IPV6_RECVHOPLIMIT)
+ /* Receive hop limit with datagram */
+ rb_define_const(rb_cSocket, "IPV6_RECVHOPLIMIT", INTEGER2NUM(IPV6_RECVHOPLIMIT));
+ /* Receive hop limit with datagram */
+ rb_define_const(rb_mSockConst, "IPV6_RECVHOPLIMIT", INTEGER2NUM(IPV6_RECVHOPLIMIT));
+#endif
+#endif
+#if defined(INET6)
+#if defined(IPV6_RECVHOPOPTS)
+ /* Receive hop-by-hop options */
+ rb_define_const(rb_cSocket, "IPV6_RECVHOPOPTS", INTEGER2NUM(IPV6_RECVHOPOPTS));
+ /* Receive hop-by-hop options */
+ rb_define_const(rb_mSockConst, "IPV6_RECVHOPOPTS", INTEGER2NUM(IPV6_RECVHOPOPTS));
+#endif
+#endif
+#if defined(INET6)
+#if defined(IPV6_RECVPKTINFO)
+ /* Receive destination IP address and incoming interface */
+ rb_define_const(rb_cSocket, "IPV6_RECVPKTINFO", INTEGER2NUM(IPV6_RECVPKTINFO));
+ /* Receive destination IP address and incoming interface */
+ rb_define_const(rb_mSockConst, "IPV6_RECVPKTINFO", INTEGER2NUM(IPV6_RECVPKTINFO));
+#endif
+#endif
+#if defined(INET6)
+#if defined(IPV6_RECVRTHDR)
+ /* Receive routing header */
+ rb_define_const(rb_cSocket, "IPV6_RECVRTHDR", INTEGER2NUM(IPV6_RECVRTHDR));
+ /* Receive routing header */
+ rb_define_const(rb_mSockConst, "IPV6_RECVRTHDR", INTEGER2NUM(IPV6_RECVRTHDR));
+#endif
+#endif
+#if defined(INET6)
+#if defined(IPV6_RECVTCLASS)
+ /* Receive traffic class */
+ rb_define_const(rb_cSocket, "IPV6_RECVTCLASS", INTEGER2NUM(IPV6_RECVTCLASS));
+ /* Receive traffic class */
+ rb_define_const(rb_mSockConst, "IPV6_RECVTCLASS", INTEGER2NUM(IPV6_RECVTCLASS));
+#endif
+#endif
+#if defined(INET6)
+#if defined(IPV6_RTHDR)
+ /* Allows removal of sticky routing headers */
+ rb_define_const(rb_cSocket, "IPV6_RTHDR", INTEGER2NUM(IPV6_RTHDR));
+ /* Allows removal of sticky routing headers */
+ rb_define_const(rb_mSockConst, "IPV6_RTHDR", INTEGER2NUM(IPV6_RTHDR));
+#endif
+#endif
+#if defined(INET6)
+#if defined(IPV6_RTHDRDSTOPTS)
+ /* Allows removal of sticky destination options header */
+ rb_define_const(rb_cSocket, "IPV6_RTHDRDSTOPTS", INTEGER2NUM(IPV6_RTHDRDSTOPTS));
+ /* Allows removal of sticky destination options header */
+ rb_define_const(rb_mSockConst, "IPV6_RTHDRDSTOPTS", INTEGER2NUM(IPV6_RTHDRDSTOPTS));
+#endif
+#endif
+#if defined(INET6)
+#if defined(IPV6_RTHDR_TYPE_0)
+ /* Routing header type 0 */
+ rb_define_const(rb_cSocket, "IPV6_RTHDR_TYPE_0", INTEGER2NUM(IPV6_RTHDR_TYPE_0));
+ /* Routing header type 0 */
+ rb_define_const(rb_mSockConst, "IPV6_RTHDR_TYPE_0", INTEGER2NUM(IPV6_RTHDR_TYPE_0));
+#endif
+#endif
+#if defined(INET6)
+#if defined(IPV6_RECVPATHMTU)
+ /* Receive current path MTU with datagram */
+ rb_define_const(rb_cSocket, "IPV6_RECVPATHMTU", INTEGER2NUM(IPV6_RECVPATHMTU));
+ /* Receive current path MTU with datagram */
+ rb_define_const(rb_mSockConst, "IPV6_RECVPATHMTU", INTEGER2NUM(IPV6_RECVPATHMTU));
+#endif
+#endif
+#if defined(INET6)
+#if defined(IPV6_TCLASS)
+ /* Specify the traffic class */
+ rb_define_const(rb_cSocket, "IPV6_TCLASS", INTEGER2NUM(IPV6_TCLASS));
+ /* Specify the traffic class */
+ rb_define_const(rb_mSockConst, "IPV6_TCLASS", INTEGER2NUM(IPV6_TCLASS));
+#endif
+#endif
+#if defined(INET6)
+#if defined(IPV6_USE_MIN_MTU)
+ /* Use the minimum MTU size */
+ rb_define_const(rb_cSocket, "IPV6_USE_MIN_MTU", INTEGER2NUM(IPV6_USE_MIN_MTU));
+ /* Use the minimum MTU size */
+ rb_define_const(rb_mSockConst, "IPV6_USE_MIN_MTU", INTEGER2NUM(IPV6_USE_MIN_MTU));
+#endif
+#endif
+#if defined(INET_ADDRSTRLEN)
+ /* Maximum length of an IPv4 address string */
+ rb_define_const(rb_cSocket, "INET_ADDRSTRLEN", INTEGER2NUM(INET_ADDRSTRLEN));
+ /* Maximum length of an IPv4 address string */
+ rb_define_const(rb_mSockConst, "INET_ADDRSTRLEN", INTEGER2NUM(INET_ADDRSTRLEN));
+#endif
+#if defined(INET6_ADDRSTRLEN)
+ /* Maximum length of an IPv6 address string */
+ rb_define_const(rb_cSocket, "INET6_ADDRSTRLEN", INTEGER2NUM(INET6_ADDRSTRLEN));
+ /* Maximum length of an IPv6 address string */
+ rb_define_const(rb_mSockConst, "INET6_ADDRSTRLEN", INTEGER2NUM(INET6_ADDRSTRLEN));
+#endif
+#if defined(IFNAMSIZ)
+ /* Maximum interface name size */
+ rb_define_const(rb_cSocket, "IFNAMSIZ", INTEGER2NUM(IFNAMSIZ));
+ /* Maximum interface name size */
+ rb_define_const(rb_mSockConst, "IFNAMSIZ", INTEGER2NUM(IFNAMSIZ));
+#endif
+#if defined(IF_NAMESIZE)
+ /* Maximum interface name size */
+ rb_define_const(rb_cSocket, "IF_NAMESIZE", INTEGER2NUM(IF_NAMESIZE));
+ /* Maximum interface name size */
+ rb_define_const(rb_mSockConst, "IF_NAMESIZE", INTEGER2NUM(IF_NAMESIZE));
+#endif
+#if defined(SOMAXCONN)
+ /* Maximum connection requests that may be queued for a socket */
+ rb_define_const(rb_cSocket, "SOMAXCONN", INTEGER2NUM(SOMAXCONN));
+ /* Maximum connection requests that may be queued for a socket */
+ rb_define_const(rb_mSockConst, "SOMAXCONN", INTEGER2NUM(SOMAXCONN));
+#endif
+#if defined(SCM_RIGHTS)
+ /* Access rights */
+ rb_define_const(rb_cSocket, "SCM_RIGHTS", INTEGER2NUM(SCM_RIGHTS));
+ /* Access rights */
+ rb_define_const(rb_mSockConst, "SCM_RIGHTS", INTEGER2NUM(SCM_RIGHTS));
+#endif
+#if defined(SCM_TIMESTAMP)
+ /* Timestamp (timeval) */
+ rb_define_const(rb_cSocket, "SCM_TIMESTAMP", INTEGER2NUM(SCM_TIMESTAMP));
+ /* Timestamp (timeval) */
+ rb_define_const(rb_mSockConst, "SCM_TIMESTAMP", INTEGER2NUM(SCM_TIMESTAMP));
+#endif
+#if defined(SCM_TIMESTAMPNS)
+ /* Timespec (timespec) */
+ rb_define_const(rb_cSocket, "SCM_TIMESTAMPNS", INTEGER2NUM(SCM_TIMESTAMPNS));
+ /* Timespec (timespec) */
+ rb_define_const(rb_mSockConst, "SCM_TIMESTAMPNS", INTEGER2NUM(SCM_TIMESTAMPNS));
+#endif
+#if defined(SCM_TIMESTAMPING)
+ /* Timestamp (timespec list) (Linux 2.6.30) */
+ rb_define_const(rb_cSocket, "SCM_TIMESTAMPING", INTEGER2NUM(SCM_TIMESTAMPING));
+ /* Timestamp (timespec list) (Linux 2.6.30) */
+ rb_define_const(rb_mSockConst, "SCM_TIMESTAMPING", INTEGER2NUM(SCM_TIMESTAMPING));
+#endif
+#if defined(SCM_BINTIME)
+ /* Timestamp (bintime) */
+ rb_define_const(rb_cSocket, "SCM_BINTIME", INTEGER2NUM(SCM_BINTIME));
+ /* Timestamp (bintime) */
+ rb_define_const(rb_mSockConst, "SCM_BINTIME", INTEGER2NUM(SCM_BINTIME));
+#endif
+#if defined(SCM_CREDENTIALS)
+ /* The sender's credentials */
+ rb_define_const(rb_cSocket, "SCM_CREDENTIALS", INTEGER2NUM(SCM_CREDENTIALS));
+ /* The sender's credentials */
+ rb_define_const(rb_mSockConst, "SCM_CREDENTIALS", INTEGER2NUM(SCM_CREDENTIALS));
+#endif
+#if defined(SCM_CREDS)
+ /* Process credentials */
+ rb_define_const(rb_cSocket, "SCM_CREDS", INTEGER2NUM(SCM_CREDS));
+ /* Process credentials */
+ rb_define_const(rb_mSockConst, "SCM_CREDS", INTEGER2NUM(SCM_CREDS));
+#endif
+#if defined(SCM_UCRED)
+ /* User credentials */
+ rb_define_const(rb_cSocket, "SCM_UCRED", INTEGER2NUM(SCM_UCRED));
+ /* User credentials */
+ rb_define_const(rb_mSockConst, "SCM_UCRED", INTEGER2NUM(SCM_UCRED));
+#endif
+#if defined(SCM_WIFI_STATUS)
+ /* Wifi status (Linux 3.3) */
+ rb_define_const(rb_cSocket, "SCM_WIFI_STATUS", INTEGER2NUM(SCM_WIFI_STATUS));
+ /* Wifi status (Linux 3.3) */
+ rb_define_const(rb_mSockConst, "SCM_WIFI_STATUS", INTEGER2NUM(SCM_WIFI_STATUS));
+#endif
+#if defined(LOCAL_PEERCRED)
+ /* Retrieve peer credentials */
+ rb_define_const(rb_cSocket, "LOCAL_PEERCRED", INTEGER2NUM(LOCAL_PEERCRED));
+ /* Retrieve peer credentials */
+ rb_define_const(rb_mSockConst, "LOCAL_PEERCRED", INTEGER2NUM(LOCAL_PEERCRED));
+#endif
+#if defined(LOCAL_CREDS)
+ /* Pass credentials to receiver */
+ rb_define_const(rb_cSocket, "LOCAL_CREDS", INTEGER2NUM(LOCAL_CREDS));
+ /* Pass credentials to receiver */
+ rb_define_const(rb_mSockConst, "LOCAL_CREDS", INTEGER2NUM(LOCAL_CREDS));
+#endif
+#if defined(LOCAL_CONNWAIT)
+ /* Connect blocks until accepted */
+ rb_define_const(rb_cSocket, "LOCAL_CONNWAIT", INTEGER2NUM(LOCAL_CONNWAIT));
+ /* Connect blocks until accepted */
+ rb_define_const(rb_mSockConst, "LOCAL_CONNWAIT", INTEGER2NUM(LOCAL_CONNWAIT));
+#endif
+#if defined(IFF_802_1Q_VLAN)
+ /* 802.1Q VLAN device */
+ rb_define_const(rb_cSocket, "IFF_802_1Q_VLAN", INTEGER2NUM(IFF_802_1Q_VLAN));
+ /* 802.1Q VLAN device */
+ rb_define_const(rb_mSockConst, "IFF_802_1Q_VLAN", INTEGER2NUM(IFF_802_1Q_VLAN));
+#endif
+#if defined(IFF_ALLMULTI)
+ /* receive all multicast packets */
+ rb_define_const(rb_cSocket, "IFF_ALLMULTI", INTEGER2NUM(IFF_ALLMULTI));
+ /* receive all multicast packets */
+ rb_define_const(rb_mSockConst, "IFF_ALLMULTI", INTEGER2NUM(IFF_ALLMULTI));
+#endif
+#if defined(IFF_ALTPHYS)
+ /* use alternate physical connection */
+ rb_define_const(rb_cSocket, "IFF_ALTPHYS", INTEGER2NUM(IFF_ALTPHYS));
+ /* use alternate physical connection */
+ rb_define_const(rb_mSockConst, "IFF_ALTPHYS", INTEGER2NUM(IFF_ALTPHYS));
+#endif
+#if defined(IFF_AUTOMEDIA)
+ /* auto media select active */
+ rb_define_const(rb_cSocket, "IFF_AUTOMEDIA", INTEGER2NUM(IFF_AUTOMEDIA));
+ /* auto media select active */
+ rb_define_const(rb_mSockConst, "IFF_AUTOMEDIA", INTEGER2NUM(IFF_AUTOMEDIA));
+#endif
+#if defined(IFF_BONDING)
+ /* bonding master or slave */
+ rb_define_const(rb_cSocket, "IFF_BONDING", INTEGER2NUM(IFF_BONDING));
+ /* bonding master or slave */
+ rb_define_const(rb_mSockConst, "IFF_BONDING", INTEGER2NUM(IFF_BONDING));
+#endif
+#if defined(IFF_BRIDGE_PORT)
+ /* device used as bridge port */
+ rb_define_const(rb_cSocket, "IFF_BRIDGE_PORT", INTEGER2NUM(IFF_BRIDGE_PORT));
+ /* device used as bridge port */
+ rb_define_const(rb_mSockConst, "IFF_BRIDGE_PORT", INTEGER2NUM(IFF_BRIDGE_PORT));
+#endif
+#if defined(IFF_BROADCAST)
+ /* broadcast address valid */
+ rb_define_const(rb_cSocket, "IFF_BROADCAST", INTEGER2NUM(IFF_BROADCAST));
+ /* broadcast address valid */
+ rb_define_const(rb_mSockConst, "IFF_BROADCAST", INTEGER2NUM(IFF_BROADCAST));
+#endif
+#if defined(IFF_CANTCONFIG)
+ /* unconfigurable using ioctl(2) */
+ rb_define_const(rb_cSocket, "IFF_CANTCONFIG", INTEGER2NUM(IFF_CANTCONFIG));
+ /* unconfigurable using ioctl(2) */
+ rb_define_const(rb_mSockConst, "IFF_CANTCONFIG", INTEGER2NUM(IFF_CANTCONFIG));
+#endif
+#if defined(IFF_DEBUG)
+ /* turn on debugging */
+ rb_define_const(rb_cSocket, "IFF_DEBUG", INTEGER2NUM(IFF_DEBUG));
+ /* turn on debugging */
+ rb_define_const(rb_mSockConst, "IFF_DEBUG", INTEGER2NUM(IFF_DEBUG));
+#endif
+#if defined(IFF_DISABLE_NETPOLL)
+ /* disable netpoll at run-time */
+ rb_define_const(rb_cSocket, "IFF_DISABLE_NETPOLL", INTEGER2NUM(IFF_DISABLE_NETPOLL));
+ /* disable netpoll at run-time */
+ rb_define_const(rb_mSockConst, "IFF_DISABLE_NETPOLL", INTEGER2NUM(IFF_DISABLE_NETPOLL));
+#endif
+#if defined(IFF_DONT_BRIDGE)
+ /* disallow bridging this ether dev */
+ rb_define_const(rb_cSocket, "IFF_DONT_BRIDGE", INTEGER2NUM(IFF_DONT_BRIDGE));
+ /* disallow bridging this ether dev */
+ rb_define_const(rb_mSockConst, "IFF_DONT_BRIDGE", INTEGER2NUM(IFF_DONT_BRIDGE));
+#endif
+#if defined(IFF_DORMANT)
+ /* driver signals dormant */
+ rb_define_const(rb_cSocket, "IFF_DORMANT", INTEGER2NUM(IFF_DORMANT));
+ /* driver signals dormant */
+ rb_define_const(rb_mSockConst, "IFF_DORMANT", INTEGER2NUM(IFF_DORMANT));
+#endif
+#if defined(IFF_DRV_OACTIVE)
+ /* tx hardware queue is full */
+ rb_define_const(rb_cSocket, "IFF_DRV_OACTIVE", INTEGER2NUM(IFF_DRV_OACTIVE));
+ /* tx hardware queue is full */
+ rb_define_const(rb_mSockConst, "IFF_DRV_OACTIVE", INTEGER2NUM(IFF_DRV_OACTIVE));
+#endif
+#if defined(IFF_DRV_RUNNING)
+ /* resources allocated */
+ rb_define_const(rb_cSocket, "IFF_DRV_RUNNING", INTEGER2NUM(IFF_DRV_RUNNING));
+ /* resources allocated */
+ rb_define_const(rb_mSockConst, "IFF_DRV_RUNNING", INTEGER2NUM(IFF_DRV_RUNNING));
+#endif
+#if defined(IFF_DYING)
+ /* interface is winding down */
+ rb_define_const(rb_cSocket, "IFF_DYING", INTEGER2NUM(IFF_DYING));
+ /* interface is winding down */
+ rb_define_const(rb_mSockConst, "IFF_DYING", INTEGER2NUM(IFF_DYING));
+#endif
+#if defined(IFF_DYNAMIC)
+ /* dialup device with changing addresses */
+ rb_define_const(rb_cSocket, "IFF_DYNAMIC", INTEGER2NUM(IFF_DYNAMIC));
+ /* dialup device with changing addresses */
+ rb_define_const(rb_mSockConst, "IFF_DYNAMIC", INTEGER2NUM(IFF_DYNAMIC));
+#endif
+#if defined(IFF_EBRIDGE)
+ /* ethernet bridging device */
+ rb_define_const(rb_cSocket, "IFF_EBRIDGE", INTEGER2NUM(IFF_EBRIDGE));
+ /* ethernet bridging device */
+ rb_define_const(rb_mSockConst, "IFF_EBRIDGE", INTEGER2NUM(IFF_EBRIDGE));
+#endif
+#if defined(IFF_ECHO)
+ /* echo sent packets */
+ rb_define_const(rb_cSocket, "IFF_ECHO", INTEGER2NUM(IFF_ECHO));
+ /* echo sent packets */
+ rb_define_const(rb_mSockConst, "IFF_ECHO", INTEGER2NUM(IFF_ECHO));
+#endif
+#if defined(IFF_ISATAP)
+ /* ISATAP interface (RFC4214) */
+ rb_define_const(rb_cSocket, "IFF_ISATAP", INTEGER2NUM(IFF_ISATAP));
+ /* ISATAP interface (RFC4214) */
+ rb_define_const(rb_mSockConst, "IFF_ISATAP", INTEGER2NUM(IFF_ISATAP));
+#endif
+#if defined(IFF_LINK0)
+ /* per link layer defined bit 0 */
+ rb_define_const(rb_cSocket, "IFF_LINK0", INTEGER2NUM(IFF_LINK0));
+ /* per link layer defined bit 0 */
+ rb_define_const(rb_mSockConst, "IFF_LINK0", INTEGER2NUM(IFF_LINK0));
+#endif
+#if defined(IFF_LINK1)
+ /* per link layer defined bit 1 */
+ rb_define_const(rb_cSocket, "IFF_LINK1", INTEGER2NUM(IFF_LINK1));
+ /* per link layer defined bit 1 */
+ rb_define_const(rb_mSockConst, "IFF_LINK1", INTEGER2NUM(IFF_LINK1));
+#endif
+#if defined(IFF_LINK2)
+ /* per link layer defined bit 2 */
+ rb_define_const(rb_cSocket, "IFF_LINK2", INTEGER2NUM(IFF_LINK2));
+ /* per link layer defined bit 2 */
+ rb_define_const(rb_mSockConst, "IFF_LINK2", INTEGER2NUM(IFF_LINK2));
+#endif
+#if defined(IFF_LIVE_ADDR_CHANGE)
+ /* hardware address change when it's running */
+ rb_define_const(rb_cSocket, "IFF_LIVE_ADDR_CHANGE", INTEGER2NUM(IFF_LIVE_ADDR_CHANGE));
+ /* hardware address change when it's running */
+ rb_define_const(rb_mSockConst, "IFF_LIVE_ADDR_CHANGE", INTEGER2NUM(IFF_LIVE_ADDR_CHANGE));
+#endif
+#if defined(IFF_LOOPBACK)
+ /* loopback net */
+ rb_define_const(rb_cSocket, "IFF_LOOPBACK", INTEGER2NUM(IFF_LOOPBACK));
+ /* loopback net */
+ rb_define_const(rb_mSockConst, "IFF_LOOPBACK", INTEGER2NUM(IFF_LOOPBACK));
+#endif
+#if defined(IFF_LOWER_UP)
+ /* driver signals L1 up */
+ rb_define_const(rb_cSocket, "IFF_LOWER_UP", INTEGER2NUM(IFF_LOWER_UP));
+ /* driver signals L1 up */
+ rb_define_const(rb_mSockConst, "IFF_LOWER_UP", INTEGER2NUM(IFF_LOWER_UP));
+#endif
+#if defined(IFF_MACVLAN_PORT)
+ /* device used as macvlan port */
+ rb_define_const(rb_cSocket, "IFF_MACVLAN_PORT", INTEGER2NUM(IFF_MACVLAN_PORT));
+ /* device used as macvlan port */
+ rb_define_const(rb_mSockConst, "IFF_MACVLAN_PORT", INTEGER2NUM(IFF_MACVLAN_PORT));
+#endif
+#if defined(IFF_MASTER)
+ /* master of a load balancer */
+ rb_define_const(rb_cSocket, "IFF_MASTER", INTEGER2NUM(IFF_MASTER));
+ /* master of a load balancer */
+ rb_define_const(rb_mSockConst, "IFF_MASTER", INTEGER2NUM(IFF_MASTER));
+#endif
+#if defined(IFF_MASTER_8023AD)
+ /* bonding master, 802.3ad. */
+ rb_define_const(rb_cSocket, "IFF_MASTER_8023AD", INTEGER2NUM(IFF_MASTER_8023AD));
+ /* bonding master, 802.3ad. */
+ rb_define_const(rb_mSockConst, "IFF_MASTER_8023AD", INTEGER2NUM(IFF_MASTER_8023AD));
+#endif
+#if defined(IFF_MASTER_ALB)
+ /* bonding master, balance-alb. */
+ rb_define_const(rb_cSocket, "IFF_MASTER_ALB", INTEGER2NUM(IFF_MASTER_ALB));
+ /* bonding master, balance-alb. */
+ rb_define_const(rb_mSockConst, "IFF_MASTER_ALB", INTEGER2NUM(IFF_MASTER_ALB));
+#endif
+#if defined(IFF_MASTER_ARPMON)
+ /* bonding master, ARP mon in use */
+ rb_define_const(rb_cSocket, "IFF_MASTER_ARPMON", INTEGER2NUM(IFF_MASTER_ARPMON));
+ /* bonding master, ARP mon in use */
+ rb_define_const(rb_mSockConst, "IFF_MASTER_ARPMON", INTEGER2NUM(IFF_MASTER_ARPMON));
+#endif
+#if defined(IFF_MONITOR)
+ /* user-requested monitor mode */
+ rb_define_const(rb_cSocket, "IFF_MONITOR", INTEGER2NUM(IFF_MONITOR));
+ /* user-requested monitor mode */
+ rb_define_const(rb_mSockConst, "IFF_MONITOR", INTEGER2NUM(IFF_MONITOR));
+#endif
+#if defined(IFF_MULTICAST)
+ /* supports multicast */
+ rb_define_const(rb_cSocket, "IFF_MULTICAST", INTEGER2NUM(IFF_MULTICAST));
+ /* supports multicast */
+ rb_define_const(rb_mSockConst, "IFF_MULTICAST", INTEGER2NUM(IFF_MULTICAST));
+#endif
+#if defined(IFF_NOARP)
+ /* no address resolution protocol */
+ rb_define_const(rb_cSocket, "IFF_NOARP", INTEGER2NUM(IFF_NOARP));
+ /* no address resolution protocol */
+ rb_define_const(rb_mSockConst, "IFF_NOARP", INTEGER2NUM(IFF_NOARP));
+#endif
+#if defined(IFF_NOTRAILERS)
+ /* avoid use of trailers */
+ rb_define_const(rb_cSocket, "IFF_NOTRAILERS", INTEGER2NUM(IFF_NOTRAILERS));
+ /* avoid use of trailers */
+ rb_define_const(rb_mSockConst, "IFF_NOTRAILERS", INTEGER2NUM(IFF_NOTRAILERS));
+#endif
+#if defined(IFF_OACTIVE)
+ /* transmission in progress */
+ rb_define_const(rb_cSocket, "IFF_OACTIVE", INTEGER2NUM(IFF_OACTIVE));
+ /* transmission in progress */
+ rb_define_const(rb_mSockConst, "IFF_OACTIVE", INTEGER2NUM(IFF_OACTIVE));
+#endif
+#if defined(IFF_OVS_DATAPATH)
+ /* device used as Open vSwitch datapath port */
+ rb_define_const(rb_cSocket, "IFF_OVS_DATAPATH", INTEGER2NUM(IFF_OVS_DATAPATH));
+ /* device used as Open vSwitch datapath port */
+ rb_define_const(rb_mSockConst, "IFF_OVS_DATAPATH", INTEGER2NUM(IFF_OVS_DATAPATH));
+#endif
+#if defined(IFF_POINTOPOINT)
+ /* point-to-point link */
+ rb_define_const(rb_cSocket, "IFF_POINTOPOINT", INTEGER2NUM(IFF_POINTOPOINT));
+ /* point-to-point link */
+ rb_define_const(rb_mSockConst, "IFF_POINTOPOINT", INTEGER2NUM(IFF_POINTOPOINT));
+#endif
+#if defined(IFF_PORTSEL)
+ /* can set media type */
+ rb_define_const(rb_cSocket, "IFF_PORTSEL", INTEGER2NUM(IFF_PORTSEL));
+ /* can set media type */
+ rb_define_const(rb_mSockConst, "IFF_PORTSEL", INTEGER2NUM(IFF_PORTSEL));
+#endif
+#if defined(IFF_PPROMISC)
+ /* user-requested promisc mode */
+ rb_define_const(rb_cSocket, "IFF_PPROMISC", INTEGER2NUM(IFF_PPROMISC));
+ /* user-requested promisc mode */
+ rb_define_const(rb_mSockConst, "IFF_PPROMISC", INTEGER2NUM(IFF_PPROMISC));
+#endif
+#if defined(IFF_PROMISC)
+ /* receive all packets */
+ rb_define_const(rb_cSocket, "IFF_PROMISC", INTEGER2NUM(IFF_PROMISC));
+ /* receive all packets */
+ rb_define_const(rb_mSockConst, "IFF_PROMISC", INTEGER2NUM(IFF_PROMISC));
+#endif
+#if defined(IFF_RENAMING)
+ /* interface is being renamed */
+ rb_define_const(rb_cSocket, "IFF_RENAMING", INTEGER2NUM(IFF_RENAMING));
+ /* interface is being renamed */
+ rb_define_const(rb_mSockConst, "IFF_RENAMING", INTEGER2NUM(IFF_RENAMING));
+#endif
+#if defined(IFF_ROUTE)
+ /* routing entry installed */
+ rb_define_const(rb_cSocket, "IFF_ROUTE", INTEGER2NUM(IFF_ROUTE));
+ /* routing entry installed */
+ rb_define_const(rb_mSockConst, "IFF_ROUTE", INTEGER2NUM(IFF_ROUTE));
+#endif
+#if defined(IFF_RUNNING)
+ /* resources allocated */
+ rb_define_const(rb_cSocket, "IFF_RUNNING", INTEGER2NUM(IFF_RUNNING));
+ /* resources allocated */
+ rb_define_const(rb_mSockConst, "IFF_RUNNING", INTEGER2NUM(IFF_RUNNING));
+#endif
+#if defined(IFF_SIMPLEX)
+ /* can't hear own transmissions */
+ rb_define_const(rb_cSocket, "IFF_SIMPLEX", INTEGER2NUM(IFF_SIMPLEX));
+ /* can't hear own transmissions */
+ rb_define_const(rb_mSockConst, "IFF_SIMPLEX", INTEGER2NUM(IFF_SIMPLEX));
+#endif
+#if defined(IFF_SLAVE)
+ /* slave of a load balancer */
+ rb_define_const(rb_cSocket, "IFF_SLAVE", INTEGER2NUM(IFF_SLAVE));
+ /* slave of a load balancer */
+ rb_define_const(rb_mSockConst, "IFF_SLAVE", INTEGER2NUM(IFF_SLAVE));
+#endif
+#if defined(IFF_SLAVE_INACTIVE)
+ /* bonding slave not the curr. active */
+ rb_define_const(rb_cSocket, "IFF_SLAVE_INACTIVE", INTEGER2NUM(IFF_SLAVE_INACTIVE));
+ /* bonding slave not the curr. active */
+ rb_define_const(rb_mSockConst, "IFF_SLAVE_INACTIVE", INTEGER2NUM(IFF_SLAVE_INACTIVE));
+#endif
+#if defined(IFF_SLAVE_NEEDARP)
+ /* need ARPs for validation */
+ rb_define_const(rb_cSocket, "IFF_SLAVE_NEEDARP", INTEGER2NUM(IFF_SLAVE_NEEDARP));
+ /* need ARPs for validation */
+ rb_define_const(rb_mSockConst, "IFF_SLAVE_NEEDARP", INTEGER2NUM(IFF_SLAVE_NEEDARP));
+#endif
+#if defined(IFF_SMART)
+ /* interface manages own routes */
+ rb_define_const(rb_cSocket, "IFF_SMART", INTEGER2NUM(IFF_SMART));
+ /* interface manages own routes */
+ rb_define_const(rb_mSockConst, "IFF_SMART", INTEGER2NUM(IFF_SMART));
+#endif
+#if defined(IFF_STATICARP)
+ /* static ARP */
+ rb_define_const(rb_cSocket, "IFF_STATICARP", INTEGER2NUM(IFF_STATICARP));
+ /* static ARP */
+ rb_define_const(rb_mSockConst, "IFF_STATICARP", INTEGER2NUM(IFF_STATICARP));
+#endif
+#if defined(IFF_SUPP_NOFCS)
+ /* sending custom FCS */
+ rb_define_const(rb_cSocket, "IFF_SUPP_NOFCS", INTEGER2NUM(IFF_SUPP_NOFCS));
+ /* sending custom FCS */
+ rb_define_const(rb_mSockConst, "IFF_SUPP_NOFCS", INTEGER2NUM(IFF_SUPP_NOFCS));
+#endif
+#if defined(IFF_TEAM_PORT)
+ /* used as team port */
+ rb_define_const(rb_cSocket, "IFF_TEAM_PORT", INTEGER2NUM(IFF_TEAM_PORT));
+ /* used as team port */
+ rb_define_const(rb_mSockConst, "IFF_TEAM_PORT", INTEGER2NUM(IFF_TEAM_PORT));
+#endif
+#if defined(IFF_TX_SKB_SHARING)
+ /* sharing skbs on transmit */
+ rb_define_const(rb_cSocket, "IFF_TX_SKB_SHARING", INTEGER2NUM(IFF_TX_SKB_SHARING));
+ /* sharing skbs on transmit */
+ rb_define_const(rb_mSockConst, "IFF_TX_SKB_SHARING", INTEGER2NUM(IFF_TX_SKB_SHARING));
+#endif
+#if defined(IFF_UNICAST_FLT)
+ /* unicast filtering */
+ rb_define_const(rb_cSocket, "IFF_UNICAST_FLT", INTEGER2NUM(IFF_UNICAST_FLT));
+ /* unicast filtering */
+ rb_define_const(rb_mSockConst, "IFF_UNICAST_FLT", INTEGER2NUM(IFF_UNICAST_FLT));
+#endif
+#if defined(IFF_UP)
+ /* interface is up */
+ rb_define_const(rb_cSocket, "IFF_UP", INTEGER2NUM(IFF_UP));
+ /* interface is up */
+ rb_define_const(rb_mSockConst, "IFF_UP", INTEGER2NUM(IFF_UP));
+#endif
+#if defined(IFF_WAN_HDLC)
+ /* WAN HDLC device */
+ rb_define_const(rb_cSocket, "IFF_WAN_HDLC", INTEGER2NUM(IFF_WAN_HDLC));
+ /* WAN HDLC device */
+ rb_define_const(rb_mSockConst, "IFF_WAN_HDLC", INTEGER2NUM(IFF_WAN_HDLC));
+#endif
+#if defined(IFF_XMIT_DST_RELEASE)
+ /* dev_hard_start_xmit() is allowed to release skb->dst */
+ rb_define_const(rb_cSocket, "IFF_XMIT_DST_RELEASE", INTEGER2NUM(IFF_XMIT_DST_RELEASE));
+ /* dev_hard_start_xmit() is allowed to release skb->dst */
+ rb_define_const(rb_mSockConst, "IFF_XMIT_DST_RELEASE", INTEGER2NUM(IFF_XMIT_DST_RELEASE));
+#endif
+#if defined(IFF_VOLATILE)
+ /* volatile flags */
+ rb_define_const(rb_cSocket, "IFF_VOLATILE", INTEGER2NUM(IFF_VOLATILE));
+ /* volatile flags */
+ rb_define_const(rb_mSockConst, "IFF_VOLATILE", INTEGER2NUM(IFF_VOLATILE));
+#endif
+#if defined(IFF_CANTCHANGE)
+ /* flags not changeable */
+ rb_define_const(rb_cSocket, "IFF_CANTCHANGE", INTEGER2NUM(IFF_CANTCHANGE));
+ /* flags not changeable */
+ rb_define_const(rb_mSockConst, "IFF_CANTCHANGE", INTEGER2NUM(IFF_CANTCHANGE));
+#endif
+
+ rsock_intern_family_hash = st_init_numtable();
+#ifdef AF_E164
+ st_insert(rsock_intern_family_hash, (st_data_t)AF_E164, (st_data_t)rb_intern2("AF_E164", 7));
+#endif
+#ifdef AF_PACKET
+ st_insert(rsock_intern_family_hash, (st_data_t)AF_PACKET, (st_data_t)rb_intern2("AF_PACKET", 9));
+#endif
+#ifdef AF_MAX
+ st_insert(rsock_intern_family_hash, (st_data_t)AF_MAX, (st_data_t)rb_intern2("AF_MAX", 6));
+#endif
+#ifdef AF_NETGRAPH
+ st_insert(rsock_intern_family_hash, (st_data_t)AF_NETGRAPH, (st_data_t)rb_intern2("AF_NETGRAPH", 11));
+#endif
+#ifdef AF_ATM
+ st_insert(rsock_intern_family_hash, (st_data_t)AF_ATM, (st_data_t)rb_intern2("AF_ATM", 6));
+#endif
+#ifdef AF_PPP
+ st_insert(rsock_intern_family_hash, (st_data_t)AF_PPP, (st_data_t)rb_intern2("AF_PPP", 6));
+#endif
+#ifdef AF_NETBIOS
+ st_insert(rsock_intern_family_hash, (st_data_t)AF_NETBIOS, (st_data_t)rb_intern2("AF_NETBIOS", 10));
+#endif
+#ifdef AF_SYSTEM
+ st_insert(rsock_intern_family_hash, (st_data_t)AF_SYSTEM, (st_data_t)rb_intern2("AF_SYSTEM", 9));
+#endif
+#ifdef AF_NATM
+ st_insert(rsock_intern_family_hash, (st_data_t)AF_NATM, (st_data_t)rb_intern2("AF_NATM", 7));
+#endif
+#ifdef AF_ISDN
+ st_insert(rsock_intern_family_hash, (st_data_t)AF_ISDN, (st_data_t)rb_intern2("AF_ISDN", 7));
+#endif
+#ifdef AF_NDRV
+ st_insert(rsock_intern_family_hash, (st_data_t)AF_NDRV, (st_data_t)rb_intern2("AF_NDRV", 7));
+#endif
+#ifdef AF_SIP
+ st_insert(rsock_intern_family_hash, (st_data_t)AF_SIP, (st_data_t)rb_intern2("AF_SIP", 6));
+#endif
+#ifdef AF_CNT
+ st_insert(rsock_intern_family_hash, (st_data_t)AF_CNT, (st_data_t)rb_intern2("AF_CNT", 6));
+#endif
+#ifdef AF_COIP
+ st_insert(rsock_intern_family_hash, (st_data_t)AF_COIP, (st_data_t)rb_intern2("AF_COIP", 7));
+#endif
+#ifdef AF_LINK
+ st_insert(rsock_intern_family_hash, (st_data_t)AF_LINK, (st_data_t)rb_intern2("AF_LINK", 7));
+#endif
+#ifdef AF_ROUTE
+ st_insert(rsock_intern_family_hash, (st_data_t)AF_ROUTE, (st_data_t)rb_intern2("AF_ROUTE", 8));
+#endif
+#ifdef AF_HYLINK
+ st_insert(rsock_intern_family_hash, (st_data_t)AF_HYLINK, (st_data_t)rb_intern2("AF_HYLINK", 9));
+#endif
+#ifdef AF_LAT
+ st_insert(rsock_intern_family_hash, (st_data_t)AF_LAT, (st_data_t)rb_intern2("AF_LAT", 6));
+#endif
+#ifdef AF_DLI
+ st_insert(rsock_intern_family_hash, (st_data_t)AF_DLI, (st_data_t)rb_intern2("AF_DLI", 6));
+#endif
+#ifdef AF_DEC
+ st_insert(rsock_intern_family_hash, (st_data_t)AF_DEC, (st_data_t)rb_intern2("AF_DEC", 6));
+#endif
+#ifdef AF_SNA
+ st_insert(rsock_intern_family_hash, (st_data_t)AF_SNA, (st_data_t)rb_intern2("AF_SNA", 6));
+#endif
+#ifdef AF_CCITT
+ st_insert(rsock_intern_family_hash, (st_data_t)AF_CCITT, (st_data_t)rb_intern2("AF_CCITT", 8));
+#endif
+#ifdef AF_DATAKIT
+ st_insert(rsock_intern_family_hash, (st_data_t)AF_DATAKIT, (st_data_t)rb_intern2("AF_DATAKIT", 10));
+#endif
+#ifdef AF_ECMA
+ st_insert(rsock_intern_family_hash, (st_data_t)AF_ECMA, (st_data_t)rb_intern2("AF_ECMA", 7));
+#endif
+#ifdef AF_OSI
+ st_insert(rsock_intern_family_hash, (st_data_t)AF_OSI, (st_data_t)rb_intern2("AF_OSI", 6));
+#endif
+#ifdef AF_ISO
+ st_insert(rsock_intern_family_hash, (st_data_t)AF_ISO, (st_data_t)rb_intern2("AF_ISO", 6));
+#endif
+#ifdef AF_NS
+ st_insert(rsock_intern_family_hash, (st_data_t)AF_NS, (st_data_t)rb_intern2("AF_NS", 5));
+#endif
+#ifdef AF_CHAOS
+ st_insert(rsock_intern_family_hash, (st_data_t)AF_CHAOS, (st_data_t)rb_intern2("AF_CHAOS", 8));
+#endif
+#ifdef AF_PUP
+ st_insert(rsock_intern_family_hash, (st_data_t)AF_PUP, (st_data_t)rb_intern2("AF_PUP", 6));
+#endif
+#ifdef AF_IMPLINK
+ st_insert(rsock_intern_family_hash, (st_data_t)AF_IMPLINK, (st_data_t)rb_intern2("AF_IMPLINK", 10));
+#endif
+#ifdef AF_LOCAL
+ st_insert(rsock_intern_family_hash, (st_data_t)AF_LOCAL, (st_data_t)rb_intern2("AF_LOCAL", 8));
+#endif
+#ifdef AF_APPLETALK
+ st_insert(rsock_intern_family_hash, (st_data_t)AF_APPLETALK, (st_data_t)rb_intern2("AF_APPLETALK", 12));
+#endif
+#ifdef AF_IPX
+ st_insert(rsock_intern_family_hash, (st_data_t)AF_IPX, (st_data_t)rb_intern2("AF_IPX", 6));
+#endif
+#ifdef AF_AX25
+ st_insert(rsock_intern_family_hash, (st_data_t)AF_AX25, (st_data_t)rb_intern2("AF_AX25", 7));
+#endif
+#ifdef AF_UNIX
+ st_insert(rsock_intern_family_hash, (st_data_t)AF_UNIX, (st_data_t)rb_intern2("AF_UNIX", 7));
+#endif
+#ifdef AF_INET6
+ st_insert(rsock_intern_family_hash, (st_data_t)AF_INET6, (st_data_t)rb_intern2("AF_INET6", 8));
+#endif
+#ifdef AF_INET
+ st_insert(rsock_intern_family_hash, (st_data_t)AF_INET, (st_data_t)rb_intern2("AF_INET", 7));
+#endif
+#ifdef AF_UNSPEC
+ st_insert(rsock_intern_family_hash, (st_data_t)AF_UNSPEC, (st_data_t)rb_intern2("AF_UNSPEC", 9));
+#endif
+
+ rsock_intern_family_noprefix_hash = st_init_numtable();
+#ifdef AF_E164
+ st_insert(rsock_intern_family_noprefix_hash, (st_data_t)AF_E164, (st_data_t)rb_intern2("AF_E164", 7));
+#endif
+#ifdef AF_PACKET
+ st_insert(rsock_intern_family_noprefix_hash, (st_data_t)AF_PACKET, (st_data_t)rb_intern2("AF_PACKET", 9));
+#endif
+#ifdef AF_MAX
+ st_insert(rsock_intern_family_noprefix_hash, (st_data_t)AF_MAX, (st_data_t)rb_intern2("AF_MAX", 6));
+#endif
+#ifdef AF_NETGRAPH
+ st_insert(rsock_intern_family_noprefix_hash, (st_data_t)AF_NETGRAPH, (st_data_t)rb_intern2("AF_NETGRAPH", 11));
+#endif
+#ifdef AF_ATM
+ st_insert(rsock_intern_family_noprefix_hash, (st_data_t)AF_ATM, (st_data_t)rb_intern2("AF_ATM", 6));
+#endif
+#ifdef AF_PPP
+ st_insert(rsock_intern_family_noprefix_hash, (st_data_t)AF_PPP, (st_data_t)rb_intern2("AF_PPP", 6));
+#endif
+#ifdef AF_NETBIOS
+ st_insert(rsock_intern_family_noprefix_hash, (st_data_t)AF_NETBIOS, (st_data_t)rb_intern2("AF_NETBIOS", 10));
+#endif
+#ifdef AF_SYSTEM
+ st_insert(rsock_intern_family_noprefix_hash, (st_data_t)AF_SYSTEM, (st_data_t)rb_intern2("AF_SYSTEM", 9));
+#endif
+#ifdef AF_NATM
+ st_insert(rsock_intern_family_noprefix_hash, (st_data_t)AF_NATM, (st_data_t)rb_intern2("AF_NATM", 7));
+#endif
+#ifdef AF_ISDN
+ st_insert(rsock_intern_family_noprefix_hash, (st_data_t)AF_ISDN, (st_data_t)rb_intern2("AF_ISDN", 7));
+#endif
+#ifdef AF_NDRV
+ st_insert(rsock_intern_family_noprefix_hash, (st_data_t)AF_NDRV, (st_data_t)rb_intern2("AF_NDRV", 7));
+#endif
+#ifdef AF_SIP
+ st_insert(rsock_intern_family_noprefix_hash, (st_data_t)AF_SIP, (st_data_t)rb_intern2("AF_SIP", 6));
+#endif
+#ifdef AF_CNT
+ st_insert(rsock_intern_family_noprefix_hash, (st_data_t)AF_CNT, (st_data_t)rb_intern2("AF_CNT", 6));
+#endif
+#ifdef AF_COIP
+ st_insert(rsock_intern_family_noprefix_hash, (st_data_t)AF_COIP, (st_data_t)rb_intern2("AF_COIP", 7));
+#endif
+#ifdef AF_LINK
+ st_insert(rsock_intern_family_noprefix_hash, (st_data_t)AF_LINK, (st_data_t)rb_intern2("AF_LINK", 7));
+#endif
+#ifdef AF_ROUTE
+ st_insert(rsock_intern_family_noprefix_hash, (st_data_t)AF_ROUTE, (st_data_t)rb_intern2("AF_ROUTE", 8));
+#endif
+#ifdef AF_HYLINK
+ st_insert(rsock_intern_family_noprefix_hash, (st_data_t)AF_HYLINK, (st_data_t)rb_intern2("AF_HYLINK", 9));
+#endif
+#ifdef AF_LAT
+ st_insert(rsock_intern_family_noprefix_hash, (st_data_t)AF_LAT, (st_data_t)rb_intern2("AF_LAT", 6));
+#endif
+#ifdef AF_DLI
+ st_insert(rsock_intern_family_noprefix_hash, (st_data_t)AF_DLI, (st_data_t)rb_intern2("AF_DLI", 6));
+#endif
+#ifdef AF_DEC
+ st_insert(rsock_intern_family_noprefix_hash, (st_data_t)AF_DEC, (st_data_t)rb_intern2("AF_DEC", 6));
+#endif
+#ifdef AF_SNA
+ st_insert(rsock_intern_family_noprefix_hash, (st_data_t)AF_SNA, (st_data_t)rb_intern2("AF_SNA", 6));
+#endif
+#ifdef AF_CCITT
+ st_insert(rsock_intern_family_noprefix_hash, (st_data_t)AF_CCITT, (st_data_t)rb_intern2("AF_CCITT", 8));
+#endif
+#ifdef AF_DATAKIT
+ st_insert(rsock_intern_family_noprefix_hash, (st_data_t)AF_DATAKIT, (st_data_t)rb_intern2("AF_DATAKIT", 10));
+#endif
+#ifdef AF_ECMA
+ st_insert(rsock_intern_family_noprefix_hash, (st_data_t)AF_ECMA, (st_data_t)rb_intern2("AF_ECMA", 7));
+#endif
+#ifdef AF_OSI
+ st_insert(rsock_intern_family_noprefix_hash, (st_data_t)AF_OSI, (st_data_t)rb_intern2("AF_OSI", 6));
+#endif
+#ifdef AF_ISO
+ st_insert(rsock_intern_family_noprefix_hash, (st_data_t)AF_ISO, (st_data_t)rb_intern2("AF_ISO", 6));
+#endif
+#ifdef AF_NS
+ st_insert(rsock_intern_family_noprefix_hash, (st_data_t)AF_NS, (st_data_t)rb_intern2("AF_NS", 5));
+#endif
+#ifdef AF_CHAOS
+ st_insert(rsock_intern_family_noprefix_hash, (st_data_t)AF_CHAOS, (st_data_t)rb_intern2("AF_CHAOS", 8));
+#endif
+#ifdef AF_PUP
+ st_insert(rsock_intern_family_noprefix_hash, (st_data_t)AF_PUP, (st_data_t)rb_intern2("AF_PUP", 6));
+#endif
+#ifdef AF_IMPLINK
+ st_insert(rsock_intern_family_noprefix_hash, (st_data_t)AF_IMPLINK, (st_data_t)rb_intern2("AF_IMPLINK", 10));
+#endif
+#ifdef AF_LOCAL
+ st_insert(rsock_intern_family_noprefix_hash, (st_data_t)AF_LOCAL, (st_data_t)rb_intern2("AF_LOCAL", 8));
+#endif
+#ifdef AF_APPLETALK
+ st_insert(rsock_intern_family_noprefix_hash, (st_data_t)AF_APPLETALK, (st_data_t)rb_intern2("AF_APPLETALK", 12));
+#endif
+#ifdef AF_IPX
+ st_insert(rsock_intern_family_noprefix_hash, (st_data_t)AF_IPX, (st_data_t)rb_intern2("AF_IPX", 6));
+#endif
+#ifdef AF_AX25
+ st_insert(rsock_intern_family_noprefix_hash, (st_data_t)AF_AX25, (st_data_t)rb_intern2("AF_AX25", 7));
+#endif
+#ifdef AF_UNIX
+ st_insert(rsock_intern_family_noprefix_hash, (st_data_t)AF_UNIX, (st_data_t)rb_intern2("AF_UNIX", 7));
+#endif
+#ifdef AF_INET6
+ st_insert(rsock_intern_family_noprefix_hash, (st_data_t)AF_INET6, (st_data_t)rb_intern2("AF_INET6", 8));
+#endif
+#ifdef AF_INET
+ st_insert(rsock_intern_family_noprefix_hash, (st_data_t)AF_INET, (st_data_t)rb_intern2("AF_INET", 7));
+#endif
+#ifdef AF_UNSPEC
+ st_insert(rsock_intern_family_noprefix_hash, (st_data_t)AF_UNSPEC, (st_data_t)rb_intern2("AF_UNSPEC", 9));
+#endif
+#ifdef AF_E164
+ st_insert(rsock_intern_family_noprefix_hash, (st_data_t)AF_E164, (st_data_t)rb_intern2("E164", 4));
+#endif
+#ifdef AF_PACKET
+ st_insert(rsock_intern_family_noprefix_hash, (st_data_t)AF_PACKET, (st_data_t)rb_intern2("PACKET", 6));
+#endif
+#ifdef AF_MAX
+ st_insert(rsock_intern_family_noprefix_hash, (st_data_t)AF_MAX, (st_data_t)rb_intern2("MAX", 3));
+#endif
+#ifdef AF_NETGRAPH
+ st_insert(rsock_intern_family_noprefix_hash, (st_data_t)AF_NETGRAPH, (st_data_t)rb_intern2("NETGRAPH", 8));
+#endif
+#ifdef AF_ATM
+ st_insert(rsock_intern_family_noprefix_hash, (st_data_t)AF_ATM, (st_data_t)rb_intern2("ATM", 3));
+#endif
+#ifdef AF_PPP
+ st_insert(rsock_intern_family_noprefix_hash, (st_data_t)AF_PPP, (st_data_t)rb_intern2("PPP", 3));
+#endif
+#ifdef AF_NETBIOS
+ st_insert(rsock_intern_family_noprefix_hash, (st_data_t)AF_NETBIOS, (st_data_t)rb_intern2("NETBIOS", 7));
+#endif
+#ifdef AF_SYSTEM
+ st_insert(rsock_intern_family_noprefix_hash, (st_data_t)AF_SYSTEM, (st_data_t)rb_intern2("SYSTEM", 6));
+#endif
+#ifdef AF_NATM
+ st_insert(rsock_intern_family_noprefix_hash, (st_data_t)AF_NATM, (st_data_t)rb_intern2("NATM", 4));
+#endif
+#ifdef AF_ISDN
+ st_insert(rsock_intern_family_noprefix_hash, (st_data_t)AF_ISDN, (st_data_t)rb_intern2("ISDN", 4));
+#endif
+#ifdef AF_NDRV
+ st_insert(rsock_intern_family_noprefix_hash, (st_data_t)AF_NDRV, (st_data_t)rb_intern2("NDRV", 4));
+#endif
+#ifdef AF_SIP
+ st_insert(rsock_intern_family_noprefix_hash, (st_data_t)AF_SIP, (st_data_t)rb_intern2("SIP", 3));
+#endif
+#ifdef AF_CNT
+ st_insert(rsock_intern_family_noprefix_hash, (st_data_t)AF_CNT, (st_data_t)rb_intern2("CNT", 3));
+#endif
+#ifdef AF_COIP
+ st_insert(rsock_intern_family_noprefix_hash, (st_data_t)AF_COIP, (st_data_t)rb_intern2("COIP", 4));
+#endif
+#ifdef AF_LINK
+ st_insert(rsock_intern_family_noprefix_hash, (st_data_t)AF_LINK, (st_data_t)rb_intern2("LINK", 4));
+#endif
+#ifdef AF_ROUTE
+ st_insert(rsock_intern_family_noprefix_hash, (st_data_t)AF_ROUTE, (st_data_t)rb_intern2("ROUTE", 5));
+#endif
+#ifdef AF_HYLINK
+ st_insert(rsock_intern_family_noprefix_hash, (st_data_t)AF_HYLINK, (st_data_t)rb_intern2("HYLINK", 6));
+#endif
+#ifdef AF_LAT
+ st_insert(rsock_intern_family_noprefix_hash, (st_data_t)AF_LAT, (st_data_t)rb_intern2("LAT", 3));
+#endif
+#ifdef AF_DLI
+ st_insert(rsock_intern_family_noprefix_hash, (st_data_t)AF_DLI, (st_data_t)rb_intern2("DLI", 3));
+#endif
+#ifdef AF_DEC
+ st_insert(rsock_intern_family_noprefix_hash, (st_data_t)AF_DEC, (st_data_t)rb_intern2("DEC", 3));
+#endif
+#ifdef AF_SNA
+ st_insert(rsock_intern_family_noprefix_hash, (st_data_t)AF_SNA, (st_data_t)rb_intern2("SNA", 3));
+#endif
+#ifdef AF_CCITT
+ st_insert(rsock_intern_family_noprefix_hash, (st_data_t)AF_CCITT, (st_data_t)rb_intern2("CCITT", 5));
+#endif
+#ifdef AF_DATAKIT
+ st_insert(rsock_intern_family_noprefix_hash, (st_data_t)AF_DATAKIT, (st_data_t)rb_intern2("DATAKIT", 7));
+#endif
+#ifdef AF_ECMA
+ st_insert(rsock_intern_family_noprefix_hash, (st_data_t)AF_ECMA, (st_data_t)rb_intern2("ECMA", 4));
+#endif
+#ifdef AF_OSI
+ st_insert(rsock_intern_family_noprefix_hash, (st_data_t)AF_OSI, (st_data_t)rb_intern2("OSI", 3));
+#endif
+#ifdef AF_ISO
+ st_insert(rsock_intern_family_noprefix_hash, (st_data_t)AF_ISO, (st_data_t)rb_intern2("ISO", 3));
+#endif
+#ifdef AF_NS
+ st_insert(rsock_intern_family_noprefix_hash, (st_data_t)AF_NS, (st_data_t)rb_intern2("NS", 2));
+#endif
+#ifdef AF_CHAOS
+ st_insert(rsock_intern_family_noprefix_hash, (st_data_t)AF_CHAOS, (st_data_t)rb_intern2("CHAOS", 5));
+#endif
+#ifdef AF_PUP
+ st_insert(rsock_intern_family_noprefix_hash, (st_data_t)AF_PUP, (st_data_t)rb_intern2("PUP", 3));
+#endif
+#ifdef AF_IMPLINK
+ st_insert(rsock_intern_family_noprefix_hash, (st_data_t)AF_IMPLINK, (st_data_t)rb_intern2("IMPLINK", 7));
+#endif
+#ifdef AF_LOCAL
+ st_insert(rsock_intern_family_noprefix_hash, (st_data_t)AF_LOCAL, (st_data_t)rb_intern2("LOCAL", 5));
+#endif
+#ifdef AF_APPLETALK
+ st_insert(rsock_intern_family_noprefix_hash, (st_data_t)AF_APPLETALK, (st_data_t)rb_intern2("APPLETALK", 9));
+#endif
+#ifdef AF_IPX
+ st_insert(rsock_intern_family_noprefix_hash, (st_data_t)AF_IPX, (st_data_t)rb_intern2("IPX", 3));
+#endif
+#ifdef AF_AX25
+ st_insert(rsock_intern_family_noprefix_hash, (st_data_t)AF_AX25, (st_data_t)rb_intern2("AX25", 4));
+#endif
+#ifdef AF_UNIX
+ st_insert(rsock_intern_family_noprefix_hash, (st_data_t)AF_UNIX, (st_data_t)rb_intern2("UNIX", 4));
+#endif
+#ifdef AF_INET6
+ st_insert(rsock_intern_family_noprefix_hash, (st_data_t)AF_INET6, (st_data_t)rb_intern2("INET6", 5));
+#endif
+#ifdef AF_INET
+ st_insert(rsock_intern_family_noprefix_hash, (st_data_t)AF_INET, (st_data_t)rb_intern2("INET", 4));
+#endif
+#ifdef AF_UNSPEC
+ st_insert(rsock_intern_family_noprefix_hash, (st_data_t)AF_UNSPEC, (st_data_t)rb_intern2("UNSPEC", 6));
+#endif
+
+ rsock_intern_protocol_family_hash = st_init_numtable();
+#ifdef PF_KEY
+ st_insert(rsock_intern_protocol_family_hash, (st_data_t)PF_KEY, (st_data_t)rb_intern2("PF_KEY", 6));
+#endif
+#ifdef PF_PIP
+ st_insert(rsock_intern_protocol_family_hash, (st_data_t)PF_PIP, (st_data_t)rb_intern2("PF_PIP", 6));
+#endif
+#ifdef PF_RTIP
+ st_insert(rsock_intern_protocol_family_hash, (st_data_t)PF_RTIP, (st_data_t)rb_intern2("PF_RTIP", 7));
+#endif
+#ifdef PF_XTP
+ st_insert(rsock_intern_protocol_family_hash, (st_data_t)PF_XTP, (st_data_t)rb_intern2("PF_XTP", 6));
+#endif
+#ifdef PF_PACKET
+ st_insert(rsock_intern_protocol_family_hash, (st_data_t)PF_PACKET, (st_data_t)rb_intern2("PF_PACKET", 9));
+#endif
+#ifdef PF_MAX
+ st_insert(rsock_intern_protocol_family_hash, (st_data_t)PF_MAX, (st_data_t)rb_intern2("PF_MAX", 6));
+#endif
+#ifdef PF_NETGRAPH
+ st_insert(rsock_intern_protocol_family_hash, (st_data_t)PF_NETGRAPH, (st_data_t)rb_intern2("PF_NETGRAPH", 11));
+#endif
+#ifdef PF_ATM
+ st_insert(rsock_intern_protocol_family_hash, (st_data_t)PF_ATM, (st_data_t)rb_intern2("PF_ATM", 6));
+#endif
+#ifdef PF_PPP
+ st_insert(rsock_intern_protocol_family_hash, (st_data_t)PF_PPP, (st_data_t)rb_intern2("PF_PPP", 6));
+#endif
+#ifdef PF_NETBIOS
+ st_insert(rsock_intern_protocol_family_hash, (st_data_t)PF_NETBIOS, (st_data_t)rb_intern2("PF_NETBIOS", 10));
+#endif
+#ifdef PF_SYSTEM
+ st_insert(rsock_intern_protocol_family_hash, (st_data_t)PF_SYSTEM, (st_data_t)rb_intern2("PF_SYSTEM", 9));
+#endif
+#ifdef PF_NATM
+ st_insert(rsock_intern_protocol_family_hash, (st_data_t)PF_NATM, (st_data_t)rb_intern2("PF_NATM", 7));
+#endif
+#ifdef PF_ISDN
+ st_insert(rsock_intern_protocol_family_hash, (st_data_t)PF_ISDN, (st_data_t)rb_intern2("PF_ISDN", 7));
+#endif
+#ifdef PF_NDRV
+ st_insert(rsock_intern_protocol_family_hash, (st_data_t)PF_NDRV, (st_data_t)rb_intern2("PF_NDRV", 7));
+#endif
+#ifdef PF_SIP
+ st_insert(rsock_intern_protocol_family_hash, (st_data_t)PF_SIP, (st_data_t)rb_intern2("PF_SIP", 6));
+#endif
+#ifdef PF_CNT
+ st_insert(rsock_intern_protocol_family_hash, (st_data_t)PF_CNT, (st_data_t)rb_intern2("PF_CNT", 6));
+#endif
+#ifdef PF_COIP
+ st_insert(rsock_intern_protocol_family_hash, (st_data_t)PF_COIP, (st_data_t)rb_intern2("PF_COIP", 7));
+#endif
+#ifdef PF_LINK
+ st_insert(rsock_intern_protocol_family_hash, (st_data_t)PF_LINK, (st_data_t)rb_intern2("PF_LINK", 7));
+#endif
+#ifdef PF_ROUTE
+ st_insert(rsock_intern_protocol_family_hash, (st_data_t)PF_ROUTE, (st_data_t)rb_intern2("PF_ROUTE", 8));
+#endif
+#ifdef PF_HYLINK
+ st_insert(rsock_intern_protocol_family_hash, (st_data_t)PF_HYLINK, (st_data_t)rb_intern2("PF_HYLINK", 9));
+#endif
+#ifdef PF_LAT
+ st_insert(rsock_intern_protocol_family_hash, (st_data_t)PF_LAT, (st_data_t)rb_intern2("PF_LAT", 6));
+#endif
+#ifdef PF_DLI
+ st_insert(rsock_intern_protocol_family_hash, (st_data_t)PF_DLI, (st_data_t)rb_intern2("PF_DLI", 6));
+#endif
+#ifdef PF_DEC
+ st_insert(rsock_intern_protocol_family_hash, (st_data_t)PF_DEC, (st_data_t)rb_intern2("PF_DEC", 6));
+#endif
+#ifdef PF_SNA
+ st_insert(rsock_intern_protocol_family_hash, (st_data_t)PF_SNA, (st_data_t)rb_intern2("PF_SNA", 6));
+#endif
+#ifdef PF_CCITT
+ st_insert(rsock_intern_protocol_family_hash, (st_data_t)PF_CCITT, (st_data_t)rb_intern2("PF_CCITT", 8));
+#endif
+#ifdef PF_DATAKIT
+ st_insert(rsock_intern_protocol_family_hash, (st_data_t)PF_DATAKIT, (st_data_t)rb_intern2("PF_DATAKIT", 10));
+#endif
+#ifdef PF_ECMA
+ st_insert(rsock_intern_protocol_family_hash, (st_data_t)PF_ECMA, (st_data_t)rb_intern2("PF_ECMA", 7));
+#endif
+#ifdef PF_OSI
+ st_insert(rsock_intern_protocol_family_hash, (st_data_t)PF_OSI, (st_data_t)rb_intern2("PF_OSI", 6));
+#endif
+#ifdef PF_ISO
+ st_insert(rsock_intern_protocol_family_hash, (st_data_t)PF_ISO, (st_data_t)rb_intern2("PF_ISO", 6));
+#endif
+#ifdef PF_NS
+ st_insert(rsock_intern_protocol_family_hash, (st_data_t)PF_NS, (st_data_t)rb_intern2("PF_NS", 5));
+#endif
+#ifdef PF_CHAOS
+ st_insert(rsock_intern_protocol_family_hash, (st_data_t)PF_CHAOS, (st_data_t)rb_intern2("PF_CHAOS", 8));
+#endif
+#ifdef PF_PUP
+ st_insert(rsock_intern_protocol_family_hash, (st_data_t)PF_PUP, (st_data_t)rb_intern2("PF_PUP", 6));
+#endif
+#ifdef PF_IMPLINK
+ st_insert(rsock_intern_protocol_family_hash, (st_data_t)PF_IMPLINK, (st_data_t)rb_intern2("PF_IMPLINK", 10));
+#endif
+#ifdef PF_LOCAL
+ st_insert(rsock_intern_protocol_family_hash, (st_data_t)PF_LOCAL, (st_data_t)rb_intern2("PF_LOCAL", 8));
+#endif
+#ifdef PF_APPLETALK
+ st_insert(rsock_intern_protocol_family_hash, (st_data_t)PF_APPLETALK, (st_data_t)rb_intern2("PF_APPLETALK", 12));
+#endif
+#ifdef PF_IPX
+ st_insert(rsock_intern_protocol_family_hash, (st_data_t)PF_IPX, (st_data_t)rb_intern2("PF_IPX", 6));
+#endif
+#ifdef PF_AX25
+ st_insert(rsock_intern_protocol_family_hash, (st_data_t)PF_AX25, (st_data_t)rb_intern2("PF_AX25", 7));
+#endif
+#ifdef PF_UNIX
+ st_insert(rsock_intern_protocol_family_hash, (st_data_t)PF_UNIX, (st_data_t)rb_intern2("PF_UNIX", 7));
+#endif
+#ifdef PF_INET6
+ st_insert(rsock_intern_protocol_family_hash, (st_data_t)PF_INET6, (st_data_t)rb_intern2("PF_INET6", 8));
+#endif
+#ifdef PF_INET
+ st_insert(rsock_intern_protocol_family_hash, (st_data_t)PF_INET, (st_data_t)rb_intern2("PF_INET", 7));
+#endif
+#ifdef PF_UNSPEC
+ st_insert(rsock_intern_protocol_family_hash, (st_data_t)PF_UNSPEC, (st_data_t)rb_intern2("PF_UNSPEC", 9));
+#endif
+
+ rsock_intern_socktype_hash = st_init_numtable();
+#ifdef SOCK_PACKET
+ st_insert(rsock_intern_socktype_hash, (st_data_t)SOCK_PACKET, (st_data_t)rb_intern2("SOCK_PACKET", 11));
+#endif
+#ifdef SOCK_SEQPACKET
+ st_insert(rsock_intern_socktype_hash, (st_data_t)SOCK_SEQPACKET, (st_data_t)rb_intern2("SOCK_SEQPACKET", 14));
+#endif
+#ifdef SOCK_RDM
+ st_insert(rsock_intern_socktype_hash, (st_data_t)SOCK_RDM, (st_data_t)rb_intern2("SOCK_RDM", 8));
+#endif
+#ifdef SOCK_RAW
+ st_insert(rsock_intern_socktype_hash, (st_data_t)SOCK_RAW, (st_data_t)rb_intern2("SOCK_RAW", 8));
+#endif
+#ifdef SOCK_DGRAM
+ st_insert(rsock_intern_socktype_hash, (st_data_t)SOCK_DGRAM, (st_data_t)rb_intern2("SOCK_DGRAM", 10));
+#endif
+#ifdef SOCK_STREAM
+ st_insert(rsock_intern_socktype_hash, (st_data_t)SOCK_STREAM, (st_data_t)rb_intern2("SOCK_STREAM", 11));
+#endif
+
+ rsock_intern_ipproto_hash = st_init_numtable();
+#ifdef IPPROTO_MAX
+ st_insert(rsock_intern_ipproto_hash, (st_data_t)IPPROTO_MAX, (st_data_t)rb_intern2("IPPROTO_MAX", 11));
+#endif
+#ifdef IPPROTO_RAW
+ st_insert(rsock_intern_ipproto_hash, (st_data_t)IPPROTO_RAW, (st_data_t)rb_intern2("IPPROTO_RAW", 11));
+#endif
+#ifdef IPPROTO_ROUTING
+ st_insert(rsock_intern_ipproto_hash, (st_data_t)IPPROTO_ROUTING, (st_data_t)rb_intern2("IPPROTO_ROUTING", 15));
+#endif
+#ifdef IPPROTO_NONE
+ st_insert(rsock_intern_ipproto_hash, (st_data_t)IPPROTO_NONE, (st_data_t)rb_intern2("IPPROTO_NONE", 12));
+#endif
+#ifdef IPPROTO_IPV6
+ st_insert(rsock_intern_ipproto_hash, (st_data_t)IPPROTO_IPV6, (st_data_t)rb_intern2("IPPROTO_IPV6", 12));
+#endif
+#ifdef IPPROTO_ICMPV6
+ st_insert(rsock_intern_ipproto_hash, (st_data_t)IPPROTO_ICMPV6, (st_data_t)rb_intern2("IPPROTO_ICMPV6", 14));
+#endif
+#ifdef IPPROTO_HOPOPTS
+ st_insert(rsock_intern_ipproto_hash, (st_data_t)IPPROTO_HOPOPTS, (st_data_t)rb_intern2("IPPROTO_HOPOPTS", 15));
+#endif
+#ifdef IPPROTO_FRAGMENT
+ st_insert(rsock_intern_ipproto_hash, (st_data_t)IPPROTO_FRAGMENT, (st_data_t)rb_intern2("IPPROTO_FRAGMENT", 16));
+#endif
+#ifdef IPPROTO_ESP
+ st_insert(rsock_intern_ipproto_hash, (st_data_t)IPPROTO_ESP, (st_data_t)rb_intern2("IPPROTO_ESP", 11));
+#endif
+#ifdef IPPROTO_DSTOPTS
+ st_insert(rsock_intern_ipproto_hash, (st_data_t)IPPROTO_DSTOPTS, (st_data_t)rb_intern2("IPPROTO_DSTOPTS", 15));
+#endif
+#ifdef IPPROTO_AH
+ st_insert(rsock_intern_ipproto_hash, (st_data_t)IPPROTO_AH, (st_data_t)rb_intern2("IPPROTO_AH", 10));
+#endif
+#ifdef IPPROTO_BIP
+ st_insert(rsock_intern_ipproto_hash, (st_data_t)IPPROTO_BIP, (st_data_t)rb_intern2("IPPROTO_BIP", 11));
+#endif
+#ifdef IPPROTO_EON
+ st_insert(rsock_intern_ipproto_hash, (st_data_t)IPPROTO_EON, (st_data_t)rb_intern2("IPPROTO_EON", 11));
+#endif
+#ifdef IPPROTO_XTP
+ st_insert(rsock_intern_ipproto_hash, (st_data_t)IPPROTO_XTP, (st_data_t)rb_intern2("IPPROTO_XTP", 11));
+#endif
+#ifdef IPPROTO_TP
+ st_insert(rsock_intern_ipproto_hash, (st_data_t)IPPROTO_TP, (st_data_t)rb_intern2("IPPROTO_TP", 10));
+#endif
+#ifdef IPPROTO_ND
+ st_insert(rsock_intern_ipproto_hash, (st_data_t)IPPROTO_ND, (st_data_t)rb_intern2("IPPROTO_ND", 10));
+#endif
+#ifdef IPPROTO_HELLO
+ st_insert(rsock_intern_ipproto_hash, (st_data_t)IPPROTO_HELLO, (st_data_t)rb_intern2("IPPROTO_HELLO", 13));
+#endif
+#ifdef IPPROTO_IDP
+ st_insert(rsock_intern_ipproto_hash, (st_data_t)IPPROTO_IDP, (st_data_t)rb_intern2("IPPROTO_IDP", 11));
+#endif
+#ifdef IPPROTO_UDP
+ st_insert(rsock_intern_ipproto_hash, (st_data_t)IPPROTO_UDP, (st_data_t)rb_intern2("IPPROTO_UDP", 11));
+#endif
+#ifdef IPPROTO_PUP
+ st_insert(rsock_intern_ipproto_hash, (st_data_t)IPPROTO_PUP, (st_data_t)rb_intern2("IPPROTO_PUP", 11));
+#endif
+#ifdef IPPROTO_EGP
+ st_insert(rsock_intern_ipproto_hash, (st_data_t)IPPROTO_EGP, (st_data_t)rb_intern2("IPPROTO_EGP", 11));
+#endif
+#ifdef IPPROTO_TCP
+ st_insert(rsock_intern_ipproto_hash, (st_data_t)IPPROTO_TCP, (st_data_t)rb_intern2("IPPROTO_TCP", 11));
+#endif
+#ifdef IPPROTO_GGP
+ st_insert(rsock_intern_ipproto_hash, (st_data_t)IPPROTO_GGP, (st_data_t)rb_intern2("IPPROTO_GGP", 11));
+#endif
+#ifdef IPPROTO_IGMP
+ st_insert(rsock_intern_ipproto_hash, (st_data_t)IPPROTO_IGMP, (st_data_t)rb_intern2("IPPROTO_IGMP", 12));
+#endif
+#ifdef IPPROTO_ICMP
+ st_insert(rsock_intern_ipproto_hash, (st_data_t)IPPROTO_ICMP, (st_data_t)rb_intern2("IPPROTO_ICMP", 12));
+#endif
+#ifdef IPPROTO_IP
+ st_insert(rsock_intern_ipproto_hash, (st_data_t)IPPROTO_IP, (st_data_t)rb_intern2("IPPROTO_IP", 10));
+#endif
+
+ rsock_intern_iplevel_hash = st_init_numtable();
+#ifdef IPPROTO_MAX
+ st_insert(rsock_intern_iplevel_hash, (st_data_t)IPPROTO_MAX, (st_data_t)rb_intern2("IPPROTO_MAX", 11));
+#endif
+#ifdef IPPROTO_RAW
+ st_insert(rsock_intern_iplevel_hash, (st_data_t)IPPROTO_RAW, (st_data_t)rb_intern2("IPPROTO_RAW", 11));
+#endif
+#ifdef IPPROTO_ROUTING
+ st_insert(rsock_intern_iplevel_hash, (st_data_t)IPPROTO_ROUTING, (st_data_t)rb_intern2("IPPROTO_ROUTING", 15));
+#endif
+#ifdef IPPROTO_NONE
+ st_insert(rsock_intern_iplevel_hash, (st_data_t)IPPROTO_NONE, (st_data_t)rb_intern2("IPPROTO_NONE", 12));
+#endif
+#ifdef IPPROTO_IPV6
+ st_insert(rsock_intern_iplevel_hash, (st_data_t)IPPROTO_IPV6, (st_data_t)rb_intern2("IPPROTO_IPV6", 12));
+#endif
+#ifdef IPPROTO_ICMPV6
+ st_insert(rsock_intern_iplevel_hash, (st_data_t)IPPROTO_ICMPV6, (st_data_t)rb_intern2("IPPROTO_ICMPV6", 14));
+#endif
+#ifdef IPPROTO_HOPOPTS
+ st_insert(rsock_intern_iplevel_hash, (st_data_t)IPPROTO_HOPOPTS, (st_data_t)rb_intern2("IPPROTO_HOPOPTS", 15));
+#endif
+#ifdef IPPROTO_FRAGMENT
+ st_insert(rsock_intern_iplevel_hash, (st_data_t)IPPROTO_FRAGMENT, (st_data_t)rb_intern2("IPPROTO_FRAGMENT", 16));
+#endif
+#ifdef IPPROTO_ESP
+ st_insert(rsock_intern_iplevel_hash, (st_data_t)IPPROTO_ESP, (st_data_t)rb_intern2("IPPROTO_ESP", 11));
+#endif
+#ifdef IPPROTO_DSTOPTS
+ st_insert(rsock_intern_iplevel_hash, (st_data_t)IPPROTO_DSTOPTS, (st_data_t)rb_intern2("IPPROTO_DSTOPTS", 15));
+#endif
+#ifdef IPPROTO_AH
+ st_insert(rsock_intern_iplevel_hash, (st_data_t)IPPROTO_AH, (st_data_t)rb_intern2("IPPROTO_AH", 10));
+#endif
+#ifdef IPPROTO_BIP
+ st_insert(rsock_intern_iplevel_hash, (st_data_t)IPPROTO_BIP, (st_data_t)rb_intern2("IPPROTO_BIP", 11));
+#endif
+#ifdef IPPROTO_EON
+ st_insert(rsock_intern_iplevel_hash, (st_data_t)IPPROTO_EON, (st_data_t)rb_intern2("IPPROTO_EON", 11));
+#endif
+#ifdef IPPROTO_XTP
+ st_insert(rsock_intern_iplevel_hash, (st_data_t)IPPROTO_XTP, (st_data_t)rb_intern2("IPPROTO_XTP", 11));
+#endif
+#ifdef IPPROTO_TP
+ st_insert(rsock_intern_iplevel_hash, (st_data_t)IPPROTO_TP, (st_data_t)rb_intern2("IPPROTO_TP", 10));
+#endif
+#ifdef IPPROTO_ND
+ st_insert(rsock_intern_iplevel_hash, (st_data_t)IPPROTO_ND, (st_data_t)rb_intern2("IPPROTO_ND", 10));
+#endif
+#ifdef IPPROTO_HELLO
+ st_insert(rsock_intern_iplevel_hash, (st_data_t)IPPROTO_HELLO, (st_data_t)rb_intern2("IPPROTO_HELLO", 13));
+#endif
+#ifdef IPPROTO_IDP
+ st_insert(rsock_intern_iplevel_hash, (st_data_t)IPPROTO_IDP, (st_data_t)rb_intern2("IPPROTO_IDP", 11));
+#endif
+#ifdef IPPROTO_UDP
+ st_insert(rsock_intern_iplevel_hash, (st_data_t)IPPROTO_UDP, (st_data_t)rb_intern2("IPPROTO_UDP", 11));
+#endif
+#ifdef IPPROTO_PUP
+ st_insert(rsock_intern_iplevel_hash, (st_data_t)IPPROTO_PUP, (st_data_t)rb_intern2("IPPROTO_PUP", 11));
+#endif
+#ifdef IPPROTO_EGP
+ st_insert(rsock_intern_iplevel_hash, (st_data_t)IPPROTO_EGP, (st_data_t)rb_intern2("IPPROTO_EGP", 11));
+#endif
+#ifdef IPPROTO_TCP
+ st_insert(rsock_intern_iplevel_hash, (st_data_t)IPPROTO_TCP, (st_data_t)rb_intern2("IPPROTO_TCP", 11));
+#endif
+#ifdef IPPROTO_GGP
+ st_insert(rsock_intern_iplevel_hash, (st_data_t)IPPROTO_GGP, (st_data_t)rb_intern2("IPPROTO_GGP", 11));
+#endif
+#ifdef IPPROTO_IGMP
+ st_insert(rsock_intern_iplevel_hash, (st_data_t)IPPROTO_IGMP, (st_data_t)rb_intern2("IPPROTO_IGMP", 12));
+#endif
+#ifdef IPPROTO_ICMP
+ st_insert(rsock_intern_iplevel_hash, (st_data_t)IPPROTO_ICMP, (st_data_t)rb_intern2("IPPROTO_ICMP", 12));
+#endif
+#ifdef IPPROTO_IP
+ st_insert(rsock_intern_iplevel_hash, (st_data_t)IPPROTO_IP, (st_data_t)rb_intern2("IPPROTO_IP", 10));
+#endif
+#ifdef SOL_SOCKET
+ st_insert(rsock_intern_iplevel_hash, (st_data_t)SOL_SOCKET, (st_data_t)rb_intern2("SOL_SOCKET", 10));
+#endif
+#ifdef IPPROTO_MAX
+ st_insert(rsock_intern_iplevel_hash, (st_data_t)IPPROTO_MAX, (st_data_t)rb_intern2("MAX", 3));
+#endif
+#ifdef IPPROTO_RAW
+ st_insert(rsock_intern_iplevel_hash, (st_data_t)IPPROTO_RAW, (st_data_t)rb_intern2("RAW", 3));
+#endif
+#ifdef IPPROTO_ROUTING
+ st_insert(rsock_intern_iplevel_hash, (st_data_t)IPPROTO_ROUTING, (st_data_t)rb_intern2("ROUTING", 7));
+#endif
+#ifdef IPPROTO_NONE
+ st_insert(rsock_intern_iplevel_hash, (st_data_t)IPPROTO_NONE, (st_data_t)rb_intern2("NONE", 4));
+#endif
+#ifdef IPPROTO_IPV6
+ st_insert(rsock_intern_iplevel_hash, (st_data_t)IPPROTO_IPV6, (st_data_t)rb_intern2("IPV6", 4));
+#endif
+#ifdef IPPROTO_ICMPV6
+ st_insert(rsock_intern_iplevel_hash, (st_data_t)IPPROTO_ICMPV6, (st_data_t)rb_intern2("ICMPV6", 6));
+#endif
+#ifdef IPPROTO_HOPOPTS
+ st_insert(rsock_intern_iplevel_hash, (st_data_t)IPPROTO_HOPOPTS, (st_data_t)rb_intern2("HOPOPTS", 7));
+#endif
+#ifdef IPPROTO_FRAGMENT
+ st_insert(rsock_intern_iplevel_hash, (st_data_t)IPPROTO_FRAGMENT, (st_data_t)rb_intern2("FRAGMENT", 8));
+#endif
+#ifdef IPPROTO_ESP
+ st_insert(rsock_intern_iplevel_hash, (st_data_t)IPPROTO_ESP, (st_data_t)rb_intern2("ESP", 3));
+#endif
+#ifdef IPPROTO_DSTOPTS
+ st_insert(rsock_intern_iplevel_hash, (st_data_t)IPPROTO_DSTOPTS, (st_data_t)rb_intern2("DSTOPTS", 7));
+#endif
+#ifdef IPPROTO_AH
+ st_insert(rsock_intern_iplevel_hash, (st_data_t)IPPROTO_AH, (st_data_t)rb_intern2("AH", 2));
+#endif
+#ifdef IPPROTO_BIP
+ st_insert(rsock_intern_iplevel_hash, (st_data_t)IPPROTO_BIP, (st_data_t)rb_intern2("BIP", 3));
+#endif
+#ifdef IPPROTO_EON
+ st_insert(rsock_intern_iplevel_hash, (st_data_t)IPPROTO_EON, (st_data_t)rb_intern2("EON", 3));
+#endif
+#ifdef IPPROTO_XTP
+ st_insert(rsock_intern_iplevel_hash, (st_data_t)IPPROTO_XTP, (st_data_t)rb_intern2("XTP", 3));
+#endif
+#ifdef IPPROTO_TP
+ st_insert(rsock_intern_iplevel_hash, (st_data_t)IPPROTO_TP, (st_data_t)rb_intern2("TP", 2));
+#endif
+#ifdef IPPROTO_ND
+ st_insert(rsock_intern_iplevel_hash, (st_data_t)IPPROTO_ND, (st_data_t)rb_intern2("ND", 2));
+#endif
+#ifdef IPPROTO_HELLO
+ st_insert(rsock_intern_iplevel_hash, (st_data_t)IPPROTO_HELLO, (st_data_t)rb_intern2("HELLO", 5));
+#endif
+#ifdef IPPROTO_IDP
+ st_insert(rsock_intern_iplevel_hash, (st_data_t)IPPROTO_IDP, (st_data_t)rb_intern2("IDP", 3));
+#endif
+#ifdef IPPROTO_UDP
+ st_insert(rsock_intern_iplevel_hash, (st_data_t)IPPROTO_UDP, (st_data_t)rb_intern2("UDP", 3));
+#endif
+#ifdef IPPROTO_PUP
+ st_insert(rsock_intern_iplevel_hash, (st_data_t)IPPROTO_PUP, (st_data_t)rb_intern2("PUP", 3));
+#endif
+#ifdef IPPROTO_EGP
+ st_insert(rsock_intern_iplevel_hash, (st_data_t)IPPROTO_EGP, (st_data_t)rb_intern2("EGP", 3));
+#endif
+#ifdef IPPROTO_TCP
+ st_insert(rsock_intern_iplevel_hash, (st_data_t)IPPROTO_TCP, (st_data_t)rb_intern2("TCP", 3));
+#endif
+#ifdef IPPROTO_GGP
+ st_insert(rsock_intern_iplevel_hash, (st_data_t)IPPROTO_GGP, (st_data_t)rb_intern2("GGP", 3));
+#endif
+#ifdef IPPROTO_IGMP
+ st_insert(rsock_intern_iplevel_hash, (st_data_t)IPPROTO_IGMP, (st_data_t)rb_intern2("IGMP", 4));
+#endif
+#ifdef IPPROTO_ICMP
+ st_insert(rsock_intern_iplevel_hash, (st_data_t)IPPROTO_ICMP, (st_data_t)rb_intern2("ICMP", 4));
+#endif
+#ifdef IPPROTO_IP
+ st_insert(rsock_intern_iplevel_hash, (st_data_t)IPPROTO_IP, (st_data_t)rb_intern2("IP", 2));
+#endif
+#ifdef SOL_SOCKET
+ st_insert(rsock_intern_iplevel_hash, (st_data_t)SOL_SOCKET, (st_data_t)rb_intern2("SOCKET", 6));
+#endif
+
+ rsock_intern_so_optname_hash = st_init_numtable();
+#ifdef SO_BPF_EXTENSIONS
+ st_insert(rsock_intern_so_optname_hash, (st_data_t)SO_BPF_EXTENSIONS, (st_data_t)rb_intern2("SO_BPF_EXTENSIONS", 17));
+#endif
+#ifdef SO_MAX_PACING_RATE
+ st_insert(rsock_intern_so_optname_hash, (st_data_t)SO_MAX_PACING_RATE, (st_data_t)rb_intern2("SO_MAX_PACING_RATE", 18));
+#endif
+#ifdef SO_BUSY_POLL
+ st_insert(rsock_intern_so_optname_hash, (st_data_t)SO_BUSY_POLL, (st_data_t)rb_intern2("SO_BUSY_POLL", 12));
+#endif
+#ifdef SO_SELECT_ERR_QUEUE
+ st_insert(rsock_intern_so_optname_hash, (st_data_t)SO_SELECT_ERR_QUEUE, (st_data_t)rb_intern2("SO_SELECT_ERR_QUEUE", 19));
+#endif
+#ifdef SO_LOCK_FILTER
+ st_insert(rsock_intern_so_optname_hash, (st_data_t)SO_LOCK_FILTER, (st_data_t)rb_intern2("SO_LOCK_FILTER", 14));
+#endif
+#ifdef SO_NOFCS
+ st_insert(rsock_intern_so_optname_hash, (st_data_t)SO_NOFCS, (st_data_t)rb_intern2("SO_NOFCS", 8));
+#endif
+#ifdef SO_PEEK_OFF
+ st_insert(rsock_intern_so_optname_hash, (st_data_t)SO_PEEK_OFF, (st_data_t)rb_intern2("SO_PEEK_OFF", 11));
+#endif
+#ifdef SO_WIFI_STATUS
+ st_insert(rsock_intern_so_optname_hash, (st_data_t)SO_WIFI_STATUS, (st_data_t)rb_intern2("SO_WIFI_STATUS", 14));
+#endif
+#ifdef SO_RXQ_OVFL
+ st_insert(rsock_intern_so_optname_hash, (st_data_t)SO_RXQ_OVFL, (st_data_t)rb_intern2("SO_RXQ_OVFL", 11));
+#endif
+#ifdef SO_DOMAIN
+ st_insert(rsock_intern_so_optname_hash, (st_data_t)SO_DOMAIN, (st_data_t)rb_intern2("SO_DOMAIN", 9));
+#endif
+#ifdef SO_PROTOCOL
+ st_insert(rsock_intern_so_optname_hash, (st_data_t)SO_PROTOCOL, (st_data_t)rb_intern2("SO_PROTOCOL", 11));
+#endif
+#ifdef SO_TIMESTAMPING
+ st_insert(rsock_intern_so_optname_hash, (st_data_t)SO_TIMESTAMPING, (st_data_t)rb_intern2("SO_TIMESTAMPING", 15));
+#endif
+#ifdef SO_MARK
+ st_insert(rsock_intern_so_optname_hash, (st_data_t)SO_MARK, (st_data_t)rb_intern2("SO_MARK", 7));
+#endif
+#ifdef SO_PASSSEC
+ st_insert(rsock_intern_so_optname_hash, (st_data_t)SO_PASSSEC, (st_data_t)rb_intern2("SO_PASSSEC", 10));
+#endif
+#ifdef SO_PEERSEC
+ st_insert(rsock_intern_so_optname_hash, (st_data_t)SO_PEERSEC, (st_data_t)rb_intern2("SO_PEERSEC", 10));
+#endif
+#ifdef SO_ALLZONES
+ st_insert(rsock_intern_so_optname_hash, (st_data_t)SO_ALLZONES, (st_data_t)rb_intern2("SO_ALLZONES", 11));
+#endif
+#ifdef SO_MAC_EXEMPT
+ st_insert(rsock_intern_so_optname_hash, (st_data_t)SO_MAC_EXEMPT, (st_data_t)rb_intern2("SO_MAC_EXEMPT", 13));
+#endif
+#ifdef SO_RECVUCRED
+ st_insert(rsock_intern_so_optname_hash, (st_data_t)SO_RECVUCRED, (st_data_t)rb_intern2("SO_RECVUCRED", 12));
+#endif
+#ifdef SO_BINTIME
+ st_insert(rsock_intern_so_optname_hash, (st_data_t)SO_BINTIME, (st_data_t)rb_intern2("SO_BINTIME", 10));
+#endif
+#ifdef SO_TIMESTAMPNS
+ st_insert(rsock_intern_so_optname_hash, (st_data_t)SO_TIMESTAMPNS, (st_data_t)rb_intern2("SO_TIMESTAMPNS", 14));
+#endif
+#ifdef SO_TIMESTAMP
+ st_insert(rsock_intern_so_optname_hash, (st_data_t)SO_TIMESTAMP, (st_data_t)rb_intern2("SO_TIMESTAMP", 12));
+#endif
+#ifdef SO_PEERNAME
+ st_insert(rsock_intern_so_optname_hash, (st_data_t)SO_PEERNAME, (st_data_t)rb_intern2("SO_PEERNAME", 11));
+#endif
+#ifdef SO_GET_FILTER
+ st_insert(rsock_intern_so_optname_hash, (st_data_t)SO_GET_FILTER, (st_data_t)rb_intern2("SO_GET_FILTER", 13));
+#endif
+#ifdef SO_DETACH_FILTER
+ st_insert(rsock_intern_so_optname_hash, (st_data_t)SO_DETACH_FILTER, (st_data_t)rb_intern2("SO_DETACH_FILTER", 16));
+#endif
+#ifdef SO_ATTACH_FILTER
+ st_insert(rsock_intern_so_optname_hash, (st_data_t)SO_ATTACH_FILTER, (st_data_t)rb_intern2("SO_ATTACH_FILTER", 16));
+#endif
+#ifdef SO_BINDTODEVICE
+ st_insert(rsock_intern_so_optname_hash, (st_data_t)SO_BINDTODEVICE, (st_data_t)rb_intern2("SO_BINDTODEVICE", 15));
+#endif
+#ifdef SO_SECURITY_ENCRYPTION_NETWORK
+ st_insert(rsock_intern_so_optname_hash, (st_data_t)SO_SECURITY_ENCRYPTION_NETWORK, (st_data_t)rb_intern2("SO_SECURITY_ENCRYPTION_NETWORK", 30));
+#endif
+#ifdef SO_SECURITY_ENCRYPTION_TRANSPORT
+ st_insert(rsock_intern_so_optname_hash, (st_data_t)SO_SECURITY_ENCRYPTION_TRANSPORT, (st_data_t)rb_intern2("SO_SECURITY_ENCRYPTION_TRANSPORT", 32));
+#endif
+#ifdef SO_SECURITY_AUTHENTICATION
+ st_insert(rsock_intern_so_optname_hash, (st_data_t)SO_SECURITY_AUTHENTICATION, (st_data_t)rb_intern2("SO_SECURITY_AUTHENTICATION", 26));
+#endif
+#ifdef SO_NOSIGPIPE
+ st_insert(rsock_intern_so_optname_hash, (st_data_t)SO_NOSIGPIPE, (st_data_t)rb_intern2("SO_NOSIGPIPE", 12));
+#endif
+#ifdef SO_NKE
+ st_insert(rsock_intern_so_optname_hash, (st_data_t)SO_NKE, (st_data_t)rb_intern2("SO_NKE", 6));
+#endif
+#ifdef SO_NREAD
+ st_insert(rsock_intern_so_optname_hash, (st_data_t)SO_NREAD, (st_data_t)rb_intern2("SO_NREAD", 8));
+#endif
+#ifdef SO_WANTOOBFLAG
+ st_insert(rsock_intern_so_optname_hash, (st_data_t)SO_WANTOOBFLAG, (st_data_t)rb_intern2("SO_WANTOOBFLAG", 14));
+#endif
+#ifdef SO_WANTMORE
+ st_insert(rsock_intern_so_optname_hash, (st_data_t)SO_WANTMORE, (st_data_t)rb_intern2("SO_WANTMORE", 11));
+#endif
+#ifdef SO_DONTTRUNC
+ st_insert(rsock_intern_so_optname_hash, (st_data_t)SO_DONTTRUNC, (st_data_t)rb_intern2("SO_DONTTRUNC", 12));
+#endif
+#ifdef SO_ACCEPTFILTER
+ st_insert(rsock_intern_so_optname_hash, (st_data_t)SO_ACCEPTFILTER, (st_data_t)rb_intern2("SO_ACCEPTFILTER", 15));
+#endif
+#ifdef SO_USELOOPBACK
+ st_insert(rsock_intern_so_optname_hash, (st_data_t)SO_USELOOPBACK, (st_data_t)rb_intern2("SO_USELOOPBACK", 14));
+#endif
+#ifdef SO_ACCEPTCONN
+ st_insert(rsock_intern_so_optname_hash, (st_data_t)SO_ACCEPTCONN, (st_data_t)rb_intern2("SO_ACCEPTCONN", 13));
+#endif
+#ifdef SO_SNDTIMEO
+ st_insert(rsock_intern_so_optname_hash, (st_data_t)SO_SNDTIMEO, (st_data_t)rb_intern2("SO_SNDTIMEO", 11));
+#endif
+#ifdef SO_RCVTIMEO
+ st_insert(rsock_intern_so_optname_hash, (st_data_t)SO_RCVTIMEO, (st_data_t)rb_intern2("SO_RCVTIMEO", 11));
+#endif
+#ifdef SO_SNDLOWAT
+ st_insert(rsock_intern_so_optname_hash, (st_data_t)SO_SNDLOWAT, (st_data_t)rb_intern2("SO_SNDLOWAT", 11));
+#endif
+#ifdef SO_RCVLOWAT
+ st_insert(rsock_intern_so_optname_hash, (st_data_t)SO_RCVLOWAT, (st_data_t)rb_intern2("SO_RCVLOWAT", 11));
+#endif
+#ifdef SO_PEERCRED
+ st_insert(rsock_intern_so_optname_hash, (st_data_t)SO_PEERCRED, (st_data_t)rb_intern2("SO_PEERCRED", 11));
+#endif
+#ifdef SO_PASSCRED
+ st_insert(rsock_intern_so_optname_hash, (st_data_t)SO_PASSCRED, (st_data_t)rb_intern2("SO_PASSCRED", 11));
+#endif
+#ifdef SO_LINGER
+ st_insert(rsock_intern_so_optname_hash, (st_data_t)SO_LINGER, (st_data_t)rb_intern2("SO_LINGER", 9));
+#endif
+#ifdef SO_PRIORITY
+ st_insert(rsock_intern_so_optname_hash, (st_data_t)SO_PRIORITY, (st_data_t)rb_intern2("SO_PRIORITY", 11));
+#endif
+#ifdef SO_NO_CHECK
+ st_insert(rsock_intern_so_optname_hash, (st_data_t)SO_NO_CHECK, (st_data_t)rb_intern2("SO_NO_CHECK", 11));
+#endif
+#ifdef SO_OOBINLINE
+ st_insert(rsock_intern_so_optname_hash, (st_data_t)SO_OOBINLINE, (st_data_t)rb_intern2("SO_OOBINLINE", 12));
+#endif
+#ifdef SO_KEEPALIVE
+ st_insert(rsock_intern_so_optname_hash, (st_data_t)SO_KEEPALIVE, (st_data_t)rb_intern2("SO_KEEPALIVE", 12));
+#endif
+#ifdef SO_RCVBUFFORCE
+ st_insert(rsock_intern_so_optname_hash, (st_data_t)SO_RCVBUFFORCE, (st_data_t)rb_intern2("SO_RCVBUFFORCE", 14));
+#endif
+#ifdef SO_SNDBUFFORCE
+ st_insert(rsock_intern_so_optname_hash, (st_data_t)SO_SNDBUFFORCE, (st_data_t)rb_intern2("SO_SNDBUFFORCE", 14));
+#endif
+#ifdef SO_RCVBUF
+ st_insert(rsock_intern_so_optname_hash, (st_data_t)SO_RCVBUF, (st_data_t)rb_intern2("SO_RCVBUF", 9));
+#endif
+#ifdef SO_SNDBUF
+ st_insert(rsock_intern_so_optname_hash, (st_data_t)SO_SNDBUF, (st_data_t)rb_intern2("SO_SNDBUF", 9));
+#endif
+#ifdef SO_BROADCAST
+ st_insert(rsock_intern_so_optname_hash, (st_data_t)SO_BROADCAST, (st_data_t)rb_intern2("SO_BROADCAST", 12));
+#endif
+#ifdef SO_DONTROUTE
+ st_insert(rsock_intern_so_optname_hash, (st_data_t)SO_DONTROUTE, (st_data_t)rb_intern2("SO_DONTROUTE", 12));
+#endif
+#ifdef SO_ERROR
+ st_insert(rsock_intern_so_optname_hash, (st_data_t)SO_ERROR, (st_data_t)rb_intern2("SO_ERROR", 8));
+#endif
+#ifdef SO_TYPE
+ st_insert(rsock_intern_so_optname_hash, (st_data_t)SO_TYPE, (st_data_t)rb_intern2("SO_TYPE", 7));
+#endif
+#ifdef SO_REUSEPORT
+ st_insert(rsock_intern_so_optname_hash, (st_data_t)SO_REUSEPORT, (st_data_t)rb_intern2("SO_REUSEPORT", 12));
+#endif
+#ifdef SO_REUSEADDR
+ st_insert(rsock_intern_so_optname_hash, (st_data_t)SO_REUSEADDR, (st_data_t)rb_intern2("SO_REUSEADDR", 12));
+#endif
+#ifdef SO_DEBUG
+ st_insert(rsock_intern_so_optname_hash, (st_data_t)SO_DEBUG, (st_data_t)rb_intern2("SO_DEBUG", 8));
+#endif
+#ifdef SO_BPF_EXTENSIONS
+ st_insert(rsock_intern_so_optname_hash, (st_data_t)SO_BPF_EXTENSIONS, (st_data_t)rb_intern2("BPF_EXTENSIONS", 14));
+#endif
+#ifdef SO_MAX_PACING_RATE
+ st_insert(rsock_intern_so_optname_hash, (st_data_t)SO_MAX_PACING_RATE, (st_data_t)rb_intern2("MAX_PACING_RATE", 15));
+#endif
+#ifdef SO_BUSY_POLL
+ st_insert(rsock_intern_so_optname_hash, (st_data_t)SO_BUSY_POLL, (st_data_t)rb_intern2("BUSY_POLL", 9));
+#endif
+#ifdef SO_SELECT_ERR_QUEUE
+ st_insert(rsock_intern_so_optname_hash, (st_data_t)SO_SELECT_ERR_QUEUE, (st_data_t)rb_intern2("SELECT_ERR_QUEUE", 16));
+#endif
+#ifdef SO_LOCK_FILTER
+ st_insert(rsock_intern_so_optname_hash, (st_data_t)SO_LOCK_FILTER, (st_data_t)rb_intern2("LOCK_FILTER", 11));
+#endif
+#ifdef SO_NOFCS
+ st_insert(rsock_intern_so_optname_hash, (st_data_t)SO_NOFCS, (st_data_t)rb_intern2("NOFCS", 5));
+#endif
+#ifdef SO_PEEK_OFF
+ st_insert(rsock_intern_so_optname_hash, (st_data_t)SO_PEEK_OFF, (st_data_t)rb_intern2("PEEK_OFF", 8));
+#endif
+#ifdef SO_WIFI_STATUS
+ st_insert(rsock_intern_so_optname_hash, (st_data_t)SO_WIFI_STATUS, (st_data_t)rb_intern2("WIFI_STATUS", 11));
+#endif
+#ifdef SO_RXQ_OVFL
+ st_insert(rsock_intern_so_optname_hash, (st_data_t)SO_RXQ_OVFL, (st_data_t)rb_intern2("RXQ_OVFL", 8));
+#endif
+#ifdef SO_DOMAIN
+ st_insert(rsock_intern_so_optname_hash, (st_data_t)SO_DOMAIN, (st_data_t)rb_intern2("DOMAIN", 6));
+#endif
+#ifdef SO_PROTOCOL
+ st_insert(rsock_intern_so_optname_hash, (st_data_t)SO_PROTOCOL, (st_data_t)rb_intern2("PROTOCOL", 8));
+#endif
+#ifdef SO_TIMESTAMPING
+ st_insert(rsock_intern_so_optname_hash, (st_data_t)SO_TIMESTAMPING, (st_data_t)rb_intern2("TIMESTAMPING", 12));
+#endif
+#ifdef SO_MARK
+ st_insert(rsock_intern_so_optname_hash, (st_data_t)SO_MARK, (st_data_t)rb_intern2("MARK", 4));
+#endif
+#ifdef SO_PASSSEC
+ st_insert(rsock_intern_so_optname_hash, (st_data_t)SO_PASSSEC, (st_data_t)rb_intern2("PASSSEC", 7));
+#endif
+#ifdef SO_PEERSEC
+ st_insert(rsock_intern_so_optname_hash, (st_data_t)SO_PEERSEC, (st_data_t)rb_intern2("PEERSEC", 7));
+#endif
+#ifdef SO_ALLZONES
+ st_insert(rsock_intern_so_optname_hash, (st_data_t)SO_ALLZONES, (st_data_t)rb_intern2("ALLZONES", 8));
+#endif
+#ifdef SO_MAC_EXEMPT
+ st_insert(rsock_intern_so_optname_hash, (st_data_t)SO_MAC_EXEMPT, (st_data_t)rb_intern2("MAC_EXEMPT", 10));
+#endif
+#ifdef SO_RECVUCRED
+ st_insert(rsock_intern_so_optname_hash, (st_data_t)SO_RECVUCRED, (st_data_t)rb_intern2("RECVUCRED", 9));
+#endif
+#ifdef SO_BINTIME
+ st_insert(rsock_intern_so_optname_hash, (st_data_t)SO_BINTIME, (st_data_t)rb_intern2("BINTIME", 7));
+#endif
+#ifdef SO_TIMESTAMPNS
+ st_insert(rsock_intern_so_optname_hash, (st_data_t)SO_TIMESTAMPNS, (st_data_t)rb_intern2("TIMESTAMPNS", 11));
+#endif
+#ifdef SO_TIMESTAMP
+ st_insert(rsock_intern_so_optname_hash, (st_data_t)SO_TIMESTAMP, (st_data_t)rb_intern2("TIMESTAMP", 9));
+#endif
+#ifdef SO_PEERNAME
+ st_insert(rsock_intern_so_optname_hash, (st_data_t)SO_PEERNAME, (st_data_t)rb_intern2("PEERNAME", 8));
+#endif
+#ifdef SO_GET_FILTER
+ st_insert(rsock_intern_so_optname_hash, (st_data_t)SO_GET_FILTER, (st_data_t)rb_intern2("GET_FILTER", 10));
+#endif
+#ifdef SO_DETACH_FILTER
+ st_insert(rsock_intern_so_optname_hash, (st_data_t)SO_DETACH_FILTER, (st_data_t)rb_intern2("DETACH_FILTER", 13));
+#endif
+#ifdef SO_ATTACH_FILTER
+ st_insert(rsock_intern_so_optname_hash, (st_data_t)SO_ATTACH_FILTER, (st_data_t)rb_intern2("ATTACH_FILTER", 13));
+#endif
+#ifdef SO_BINDTODEVICE
+ st_insert(rsock_intern_so_optname_hash, (st_data_t)SO_BINDTODEVICE, (st_data_t)rb_intern2("BINDTODEVICE", 12));
+#endif
+#ifdef SO_SECURITY_ENCRYPTION_NETWORK
+ st_insert(rsock_intern_so_optname_hash, (st_data_t)SO_SECURITY_ENCRYPTION_NETWORK, (st_data_t)rb_intern2("SECURITY_ENCRYPTION_NETWORK", 27));
+#endif
+#ifdef SO_SECURITY_ENCRYPTION_TRANSPORT
+ st_insert(rsock_intern_so_optname_hash, (st_data_t)SO_SECURITY_ENCRYPTION_TRANSPORT, (st_data_t)rb_intern2("SECURITY_ENCRYPTION_TRANSPORT", 29));
+#endif
+#ifdef SO_SECURITY_AUTHENTICATION
+ st_insert(rsock_intern_so_optname_hash, (st_data_t)SO_SECURITY_AUTHENTICATION, (st_data_t)rb_intern2("SECURITY_AUTHENTICATION", 23));
+#endif
+#ifdef SO_NOSIGPIPE
+ st_insert(rsock_intern_so_optname_hash, (st_data_t)SO_NOSIGPIPE, (st_data_t)rb_intern2("NOSIGPIPE", 9));
+#endif
+#ifdef SO_NKE
+ st_insert(rsock_intern_so_optname_hash, (st_data_t)SO_NKE, (st_data_t)rb_intern2("NKE", 3));
+#endif
+#ifdef SO_NREAD
+ st_insert(rsock_intern_so_optname_hash, (st_data_t)SO_NREAD, (st_data_t)rb_intern2("NREAD", 5));
+#endif
+#ifdef SO_WANTOOBFLAG
+ st_insert(rsock_intern_so_optname_hash, (st_data_t)SO_WANTOOBFLAG, (st_data_t)rb_intern2("WANTOOBFLAG", 11));
+#endif
+#ifdef SO_WANTMORE
+ st_insert(rsock_intern_so_optname_hash, (st_data_t)SO_WANTMORE, (st_data_t)rb_intern2("WANTMORE", 8));
+#endif
+#ifdef SO_DONTTRUNC
+ st_insert(rsock_intern_so_optname_hash, (st_data_t)SO_DONTTRUNC, (st_data_t)rb_intern2("DONTTRUNC", 9));
+#endif
+#ifdef SO_ACCEPTFILTER
+ st_insert(rsock_intern_so_optname_hash, (st_data_t)SO_ACCEPTFILTER, (st_data_t)rb_intern2("ACCEPTFILTER", 12));
+#endif
+#ifdef SO_USELOOPBACK
+ st_insert(rsock_intern_so_optname_hash, (st_data_t)SO_USELOOPBACK, (st_data_t)rb_intern2("USELOOPBACK", 11));
+#endif
+#ifdef SO_ACCEPTCONN
+ st_insert(rsock_intern_so_optname_hash, (st_data_t)SO_ACCEPTCONN, (st_data_t)rb_intern2("ACCEPTCONN", 10));
+#endif
+#ifdef SO_SNDTIMEO
+ st_insert(rsock_intern_so_optname_hash, (st_data_t)SO_SNDTIMEO, (st_data_t)rb_intern2("SNDTIMEO", 8));
+#endif
+#ifdef SO_RCVTIMEO
+ st_insert(rsock_intern_so_optname_hash, (st_data_t)SO_RCVTIMEO, (st_data_t)rb_intern2("RCVTIMEO", 8));
+#endif
+#ifdef SO_SNDLOWAT
+ st_insert(rsock_intern_so_optname_hash, (st_data_t)SO_SNDLOWAT, (st_data_t)rb_intern2("SNDLOWAT", 8));
+#endif
+#ifdef SO_RCVLOWAT
+ st_insert(rsock_intern_so_optname_hash, (st_data_t)SO_RCVLOWAT, (st_data_t)rb_intern2("RCVLOWAT", 8));
+#endif
+#ifdef SO_PEERCRED
+ st_insert(rsock_intern_so_optname_hash, (st_data_t)SO_PEERCRED, (st_data_t)rb_intern2("PEERCRED", 8));
+#endif
+#ifdef SO_PASSCRED
+ st_insert(rsock_intern_so_optname_hash, (st_data_t)SO_PASSCRED, (st_data_t)rb_intern2("PASSCRED", 8));
+#endif
+#ifdef SO_LINGER
+ st_insert(rsock_intern_so_optname_hash, (st_data_t)SO_LINGER, (st_data_t)rb_intern2("LINGER", 6));
+#endif
+#ifdef SO_PRIORITY
+ st_insert(rsock_intern_so_optname_hash, (st_data_t)SO_PRIORITY, (st_data_t)rb_intern2("PRIORITY", 8));
+#endif
+#ifdef SO_NO_CHECK
+ st_insert(rsock_intern_so_optname_hash, (st_data_t)SO_NO_CHECK, (st_data_t)rb_intern2("NO_CHECK", 8));
+#endif
+#ifdef SO_OOBINLINE
+ st_insert(rsock_intern_so_optname_hash, (st_data_t)SO_OOBINLINE, (st_data_t)rb_intern2("OOBINLINE", 9));
+#endif
+#ifdef SO_KEEPALIVE
+ st_insert(rsock_intern_so_optname_hash, (st_data_t)SO_KEEPALIVE, (st_data_t)rb_intern2("KEEPALIVE", 9));
+#endif
+#ifdef SO_RCVBUFFORCE
+ st_insert(rsock_intern_so_optname_hash, (st_data_t)SO_RCVBUFFORCE, (st_data_t)rb_intern2("RCVBUFFORCE", 11));
+#endif
+#ifdef SO_SNDBUFFORCE
+ st_insert(rsock_intern_so_optname_hash, (st_data_t)SO_SNDBUFFORCE, (st_data_t)rb_intern2("SNDBUFFORCE", 11));
+#endif
+#ifdef SO_RCVBUF
+ st_insert(rsock_intern_so_optname_hash, (st_data_t)SO_RCVBUF, (st_data_t)rb_intern2("RCVBUF", 6));
+#endif
+#ifdef SO_SNDBUF
+ st_insert(rsock_intern_so_optname_hash, (st_data_t)SO_SNDBUF, (st_data_t)rb_intern2("SNDBUF", 6));
+#endif
+#ifdef SO_BROADCAST
+ st_insert(rsock_intern_so_optname_hash, (st_data_t)SO_BROADCAST, (st_data_t)rb_intern2("BROADCAST", 9));
+#endif
+#ifdef SO_DONTROUTE
+ st_insert(rsock_intern_so_optname_hash, (st_data_t)SO_DONTROUTE, (st_data_t)rb_intern2("DONTROUTE", 9));
+#endif
+#ifdef SO_ERROR
+ st_insert(rsock_intern_so_optname_hash, (st_data_t)SO_ERROR, (st_data_t)rb_intern2("ERROR", 5));
+#endif
+#ifdef SO_TYPE
+ st_insert(rsock_intern_so_optname_hash, (st_data_t)SO_TYPE, (st_data_t)rb_intern2("TYPE", 4));
+#endif
+#ifdef SO_REUSEPORT
+ st_insert(rsock_intern_so_optname_hash, (st_data_t)SO_REUSEPORT, (st_data_t)rb_intern2("REUSEPORT", 9));
+#endif
+#ifdef SO_REUSEADDR
+ st_insert(rsock_intern_so_optname_hash, (st_data_t)SO_REUSEADDR, (st_data_t)rb_intern2("REUSEADDR", 9));
+#endif
+#ifdef SO_DEBUG
+ st_insert(rsock_intern_so_optname_hash, (st_data_t)SO_DEBUG, (st_data_t)rb_intern2("DEBUG", 5));
+#endif
+
+ rsock_intern_ip_optname_hash = st_init_numtable();
+#ifdef IP_MSFILTER
+ st_insert(rsock_intern_ip_optname_hash, (st_data_t)IP_MSFILTER, (st_data_t)rb_intern2("IP_MSFILTER", 11));
+#endif
+#ifdef IP_DROP_SOURCE_MEMBERSHIP
+ st_insert(rsock_intern_ip_optname_hash, (st_data_t)IP_DROP_SOURCE_MEMBERSHIP, (st_data_t)rb_intern2("IP_DROP_SOURCE_MEMBERSHIP", 25));
+#endif
+#ifdef IP_ADD_SOURCE_MEMBERSHIP
+ st_insert(rsock_intern_ip_optname_hash, (st_data_t)IP_ADD_SOURCE_MEMBERSHIP, (st_data_t)rb_intern2("IP_ADD_SOURCE_MEMBERSHIP", 24));
+#endif
+#ifdef IP_BLOCK_SOURCE
+ st_insert(rsock_intern_ip_optname_hash, (st_data_t)IP_BLOCK_SOURCE, (st_data_t)rb_intern2("IP_BLOCK_SOURCE", 15));
+#endif
+#ifdef IP_UNBLOCK_SOURCE
+ st_insert(rsock_intern_ip_optname_hash, (st_data_t)IP_UNBLOCK_SOURCE, (st_data_t)rb_intern2("IP_UNBLOCK_SOURCE", 17));
+#endif
+#ifdef IP_PMTUDISC_DO
+ st_insert(rsock_intern_ip_optname_hash, (st_data_t)IP_PMTUDISC_DO, (st_data_t)rb_intern2("IP_PMTUDISC_DO", 14));
+#endif
+#ifdef IP_PMTUDISC_WANT
+ st_insert(rsock_intern_ip_optname_hash, (st_data_t)IP_PMTUDISC_WANT, (st_data_t)rb_intern2("IP_PMTUDISC_WANT", 16));
+#endif
+#ifdef IP_PMTUDISC_DONT
+ st_insert(rsock_intern_ip_optname_hash, (st_data_t)IP_PMTUDISC_DONT, (st_data_t)rb_intern2("IP_PMTUDISC_DONT", 16));
+#endif
+#ifdef IP_TRANSPARENT
+ st_insert(rsock_intern_ip_optname_hash, (st_data_t)IP_TRANSPARENT, (st_data_t)rb_intern2("IP_TRANSPARENT", 14));
+#endif
+#ifdef IP_PASSSEC
+ st_insert(rsock_intern_ip_optname_hash, (st_data_t)IP_PASSSEC, (st_data_t)rb_intern2("IP_PASSSEC", 10));
+#endif
+#ifdef IP_XFRM_POLICY
+ st_insert(rsock_intern_ip_optname_hash, (st_data_t)IP_XFRM_POLICY, (st_data_t)rb_intern2("IP_XFRM_POLICY", 14));
+#endif
+#ifdef IP_IPSEC_POLICY
+ st_insert(rsock_intern_ip_optname_hash, (st_data_t)IP_IPSEC_POLICY, (st_data_t)rb_intern2("IP_IPSEC_POLICY", 15));
+#endif
+#ifdef IP_FREEBIND
+ st_insert(rsock_intern_ip_optname_hash, (st_data_t)IP_FREEBIND, (st_data_t)rb_intern2("IP_FREEBIND", 11));
+#endif
+#ifdef IP_MTU
+ st_insert(rsock_intern_ip_optname_hash, (st_data_t)IP_MTU, (st_data_t)rb_intern2("IP_MTU", 6));
+#endif
+#ifdef IP_RECVTOS
+ st_insert(rsock_intern_ip_optname_hash, (st_data_t)IP_RECVTOS, (st_data_t)rb_intern2("IP_RECVTOS", 10));
+#endif
+#ifdef IP_RECVERR
+ st_insert(rsock_intern_ip_optname_hash, (st_data_t)IP_RECVERR, (st_data_t)rb_intern2("IP_RECVERR", 10));
+#endif
+#ifdef IP_MTU_DISCOVER
+ st_insert(rsock_intern_ip_optname_hash, (st_data_t)IP_MTU_DISCOVER, (st_data_t)rb_intern2("IP_MTU_DISCOVER", 15));
+#endif
+#ifdef IP_PKTOPTIONS
+ st_insert(rsock_intern_ip_optname_hash, (st_data_t)IP_PKTOPTIONS, (st_data_t)rb_intern2("IP_PKTOPTIONS", 13));
+#endif
+#ifdef IP_PKTINFO
+ st_insert(rsock_intern_ip_optname_hash, (st_data_t)IP_PKTINFO, (st_data_t)rb_intern2("IP_PKTINFO", 10));
+#endif
+#ifdef IP_ROUTER_ALERT
+ st_insert(rsock_intern_ip_optname_hash, (st_data_t)IP_ROUTER_ALERT, (st_data_t)rb_intern2("IP_ROUTER_ALERT", 15));
+#endif
+#ifdef IP_MAX_MEMBERSHIPS
+ st_insert(rsock_intern_ip_optname_hash, (st_data_t)IP_MAX_MEMBERSHIPS, (st_data_t)rb_intern2("IP_MAX_MEMBERSHIPS", 18));
+#endif
+#ifdef IP_DEFAULT_MULTICAST_LOOP
+ st_insert(rsock_intern_ip_optname_hash, (st_data_t)IP_DEFAULT_MULTICAST_LOOP, (st_data_t)rb_intern2("IP_DEFAULT_MULTICAST_LOOP", 25));
+#endif
+#ifdef IP_DEFAULT_MULTICAST_TTL
+ st_insert(rsock_intern_ip_optname_hash, (st_data_t)IP_DEFAULT_MULTICAST_TTL, (st_data_t)rb_intern2("IP_DEFAULT_MULTICAST_TTL", 24));
+#endif
+#ifdef IP_DROP_MEMBERSHIP
+ st_insert(rsock_intern_ip_optname_hash, (st_data_t)IP_DROP_MEMBERSHIP, (st_data_t)rb_intern2("IP_DROP_MEMBERSHIP", 18));
+#endif
+#ifdef IP_ADD_MEMBERSHIP
+ st_insert(rsock_intern_ip_optname_hash, (st_data_t)IP_ADD_MEMBERSHIP, (st_data_t)rb_intern2("IP_ADD_MEMBERSHIP", 17));
+#endif
+#ifdef IP_MULTICAST_LOOP
+ st_insert(rsock_intern_ip_optname_hash, (st_data_t)IP_MULTICAST_LOOP, (st_data_t)rb_intern2("IP_MULTICAST_LOOP", 17));
+#endif
+#ifdef IP_MULTICAST_TTL
+ st_insert(rsock_intern_ip_optname_hash, (st_data_t)IP_MULTICAST_TTL, (st_data_t)rb_intern2("IP_MULTICAST_TTL", 16));
+#endif
+#ifdef IP_MULTICAST_IF
+ st_insert(rsock_intern_ip_optname_hash, (st_data_t)IP_MULTICAST_IF, (st_data_t)rb_intern2("IP_MULTICAST_IF", 15));
+#endif
+#ifdef IP_PORTRANGE
+ st_insert(rsock_intern_ip_optname_hash, (st_data_t)IP_PORTRANGE, (st_data_t)rb_intern2("IP_PORTRANGE", 12));
+#endif
+#ifdef IP_RECVSLLA
+ st_insert(rsock_intern_ip_optname_hash, (st_data_t)IP_RECVSLLA, (st_data_t)rb_intern2("IP_RECVSLLA", 11));
+#endif
+#ifdef IP_RECVIF
+ st_insert(rsock_intern_ip_optname_hash, (st_data_t)IP_RECVIF, (st_data_t)rb_intern2("IP_RECVIF", 9));
+#endif
+#ifdef IP_RECVTTL
+ st_insert(rsock_intern_ip_optname_hash, (st_data_t)IP_RECVTTL, (st_data_t)rb_intern2("IP_RECVTTL", 10));
+#endif
+#ifdef IP_ONESBCAST
+ st_insert(rsock_intern_ip_optname_hash, (st_data_t)IP_ONESBCAST, (st_data_t)rb_intern2("IP_ONESBCAST", 12));
+#endif
+#ifdef IP_SENDSRCADDR
+ st_insert(rsock_intern_ip_optname_hash, (st_data_t)IP_SENDSRCADDR, (st_data_t)rb_intern2("IP_SENDSRCADDR", 14));
+#endif
+#ifdef IP_DONTFRAG
+ st_insert(rsock_intern_ip_optname_hash, (st_data_t)IP_DONTFRAG, (st_data_t)rb_intern2("IP_DONTFRAG", 11));
+#endif
+#ifdef IP_MINTTL
+ st_insert(rsock_intern_ip_optname_hash, (st_data_t)IP_MINTTL, (st_data_t)rb_intern2("IP_MINTTL", 9));
+#endif
+#ifdef IP_RETOPTS
+ st_insert(rsock_intern_ip_optname_hash, (st_data_t)IP_RETOPTS, (st_data_t)rb_intern2("IP_RETOPTS", 10));
+#endif
+#ifdef IP_RECVDSTADDR
+ st_insert(rsock_intern_ip_optname_hash, (st_data_t)IP_RECVDSTADDR, (st_data_t)rb_intern2("IP_RECVDSTADDR", 14));
+#endif
+#ifdef IP_RECVRETOPTS
+ st_insert(rsock_intern_ip_optname_hash, (st_data_t)IP_RECVRETOPTS, (st_data_t)rb_intern2("IP_RECVRETOPTS", 14));
+#endif
+#ifdef IP_RECVOPTS
+ st_insert(rsock_intern_ip_optname_hash, (st_data_t)IP_RECVOPTS, (st_data_t)rb_intern2("IP_RECVOPTS", 11));
+#endif
+#ifdef IP_TTL
+ st_insert(rsock_intern_ip_optname_hash, (st_data_t)IP_TTL, (st_data_t)rb_intern2("IP_TTL", 6));
+#endif
+#ifdef IP_TOS
+ st_insert(rsock_intern_ip_optname_hash, (st_data_t)IP_TOS, (st_data_t)rb_intern2("IP_TOS", 6));
+#endif
+#ifdef IP_HDRINCL
+ st_insert(rsock_intern_ip_optname_hash, (st_data_t)IP_HDRINCL, (st_data_t)rb_intern2("IP_HDRINCL", 10));
+#endif
+#ifdef IP_OPTIONS
+ st_insert(rsock_intern_ip_optname_hash, (st_data_t)IP_OPTIONS, (st_data_t)rb_intern2("IP_OPTIONS", 10));
+#endif
+#ifdef IP_MSFILTER
+ st_insert(rsock_intern_ip_optname_hash, (st_data_t)IP_MSFILTER, (st_data_t)rb_intern2("MSFILTER", 8));
+#endif
+#ifdef IP_DROP_SOURCE_MEMBERSHIP
+ st_insert(rsock_intern_ip_optname_hash, (st_data_t)IP_DROP_SOURCE_MEMBERSHIP, (st_data_t)rb_intern2("DROP_SOURCE_MEMBERSHIP", 22));
+#endif
+#ifdef IP_ADD_SOURCE_MEMBERSHIP
+ st_insert(rsock_intern_ip_optname_hash, (st_data_t)IP_ADD_SOURCE_MEMBERSHIP, (st_data_t)rb_intern2("ADD_SOURCE_MEMBERSHIP", 21));
+#endif
+#ifdef IP_BLOCK_SOURCE
+ st_insert(rsock_intern_ip_optname_hash, (st_data_t)IP_BLOCK_SOURCE, (st_data_t)rb_intern2("BLOCK_SOURCE", 12));
+#endif
+#ifdef IP_UNBLOCK_SOURCE
+ st_insert(rsock_intern_ip_optname_hash, (st_data_t)IP_UNBLOCK_SOURCE, (st_data_t)rb_intern2("UNBLOCK_SOURCE", 14));
+#endif
+#ifdef IP_PMTUDISC_DO
+ st_insert(rsock_intern_ip_optname_hash, (st_data_t)IP_PMTUDISC_DO, (st_data_t)rb_intern2("PMTUDISC_DO", 11));
+#endif
+#ifdef IP_PMTUDISC_WANT
+ st_insert(rsock_intern_ip_optname_hash, (st_data_t)IP_PMTUDISC_WANT, (st_data_t)rb_intern2("PMTUDISC_WANT", 13));
+#endif
+#ifdef IP_PMTUDISC_DONT
+ st_insert(rsock_intern_ip_optname_hash, (st_data_t)IP_PMTUDISC_DONT, (st_data_t)rb_intern2("PMTUDISC_DONT", 13));
+#endif
+#ifdef IP_TRANSPARENT
+ st_insert(rsock_intern_ip_optname_hash, (st_data_t)IP_TRANSPARENT, (st_data_t)rb_intern2("TRANSPARENT", 11));
+#endif
+#ifdef IP_PASSSEC
+ st_insert(rsock_intern_ip_optname_hash, (st_data_t)IP_PASSSEC, (st_data_t)rb_intern2("PASSSEC", 7));
+#endif
+#ifdef IP_XFRM_POLICY
+ st_insert(rsock_intern_ip_optname_hash, (st_data_t)IP_XFRM_POLICY, (st_data_t)rb_intern2("XFRM_POLICY", 11));
+#endif
+#ifdef IP_IPSEC_POLICY
+ st_insert(rsock_intern_ip_optname_hash, (st_data_t)IP_IPSEC_POLICY, (st_data_t)rb_intern2("IPSEC_POLICY", 12));
+#endif
+#ifdef IP_FREEBIND
+ st_insert(rsock_intern_ip_optname_hash, (st_data_t)IP_FREEBIND, (st_data_t)rb_intern2("FREEBIND", 8));
+#endif
+#ifdef IP_MTU
+ st_insert(rsock_intern_ip_optname_hash, (st_data_t)IP_MTU, (st_data_t)rb_intern2("MTU", 3));
+#endif
+#ifdef IP_RECVTOS
+ st_insert(rsock_intern_ip_optname_hash, (st_data_t)IP_RECVTOS, (st_data_t)rb_intern2("RECVTOS", 7));
+#endif
+#ifdef IP_RECVERR
+ st_insert(rsock_intern_ip_optname_hash, (st_data_t)IP_RECVERR, (st_data_t)rb_intern2("RECVERR", 7));
+#endif
+#ifdef IP_MTU_DISCOVER
+ st_insert(rsock_intern_ip_optname_hash, (st_data_t)IP_MTU_DISCOVER, (st_data_t)rb_intern2("MTU_DISCOVER", 12));
+#endif
+#ifdef IP_PKTOPTIONS
+ st_insert(rsock_intern_ip_optname_hash, (st_data_t)IP_PKTOPTIONS, (st_data_t)rb_intern2("PKTOPTIONS", 10));
+#endif
+#ifdef IP_PKTINFO
+ st_insert(rsock_intern_ip_optname_hash, (st_data_t)IP_PKTINFO, (st_data_t)rb_intern2("PKTINFO", 7));
+#endif
+#ifdef IP_ROUTER_ALERT
+ st_insert(rsock_intern_ip_optname_hash, (st_data_t)IP_ROUTER_ALERT, (st_data_t)rb_intern2("ROUTER_ALERT", 12));
+#endif
+#ifdef IP_MAX_MEMBERSHIPS
+ st_insert(rsock_intern_ip_optname_hash, (st_data_t)IP_MAX_MEMBERSHIPS, (st_data_t)rb_intern2("MAX_MEMBERSHIPS", 15));
+#endif
+#ifdef IP_DEFAULT_MULTICAST_LOOP
+ st_insert(rsock_intern_ip_optname_hash, (st_data_t)IP_DEFAULT_MULTICAST_LOOP, (st_data_t)rb_intern2("DEFAULT_MULTICAST_LOOP", 22));
+#endif
+#ifdef IP_DEFAULT_MULTICAST_TTL
+ st_insert(rsock_intern_ip_optname_hash, (st_data_t)IP_DEFAULT_MULTICAST_TTL, (st_data_t)rb_intern2("DEFAULT_MULTICAST_TTL", 21));
+#endif
+#ifdef IP_DROP_MEMBERSHIP
+ st_insert(rsock_intern_ip_optname_hash, (st_data_t)IP_DROP_MEMBERSHIP, (st_data_t)rb_intern2("DROP_MEMBERSHIP", 15));
+#endif
+#ifdef IP_ADD_MEMBERSHIP
+ st_insert(rsock_intern_ip_optname_hash, (st_data_t)IP_ADD_MEMBERSHIP, (st_data_t)rb_intern2("ADD_MEMBERSHIP", 14));
+#endif
+#ifdef IP_MULTICAST_LOOP
+ st_insert(rsock_intern_ip_optname_hash, (st_data_t)IP_MULTICAST_LOOP, (st_data_t)rb_intern2("MULTICAST_LOOP", 14));
+#endif
+#ifdef IP_MULTICAST_TTL
+ st_insert(rsock_intern_ip_optname_hash, (st_data_t)IP_MULTICAST_TTL, (st_data_t)rb_intern2("MULTICAST_TTL", 13));
+#endif
+#ifdef IP_MULTICAST_IF
+ st_insert(rsock_intern_ip_optname_hash, (st_data_t)IP_MULTICAST_IF, (st_data_t)rb_intern2("MULTICAST_IF", 12));
+#endif
+#ifdef IP_PORTRANGE
+ st_insert(rsock_intern_ip_optname_hash, (st_data_t)IP_PORTRANGE, (st_data_t)rb_intern2("PORTRANGE", 9));
+#endif
+#ifdef IP_RECVSLLA
+ st_insert(rsock_intern_ip_optname_hash, (st_data_t)IP_RECVSLLA, (st_data_t)rb_intern2("RECVSLLA", 8));
+#endif
+#ifdef IP_RECVIF
+ st_insert(rsock_intern_ip_optname_hash, (st_data_t)IP_RECVIF, (st_data_t)rb_intern2("RECVIF", 6));
+#endif
+#ifdef IP_RECVTTL
+ st_insert(rsock_intern_ip_optname_hash, (st_data_t)IP_RECVTTL, (st_data_t)rb_intern2("RECVTTL", 7));
+#endif
+#ifdef IP_ONESBCAST
+ st_insert(rsock_intern_ip_optname_hash, (st_data_t)IP_ONESBCAST, (st_data_t)rb_intern2("ONESBCAST", 9));
+#endif
+#ifdef IP_SENDSRCADDR
+ st_insert(rsock_intern_ip_optname_hash, (st_data_t)IP_SENDSRCADDR, (st_data_t)rb_intern2("SENDSRCADDR", 11));
+#endif
+#ifdef IP_DONTFRAG
+ st_insert(rsock_intern_ip_optname_hash, (st_data_t)IP_DONTFRAG, (st_data_t)rb_intern2("DONTFRAG", 8));
+#endif
+#ifdef IP_MINTTL
+ st_insert(rsock_intern_ip_optname_hash, (st_data_t)IP_MINTTL, (st_data_t)rb_intern2("MINTTL", 6));
+#endif
+#ifdef IP_RETOPTS
+ st_insert(rsock_intern_ip_optname_hash, (st_data_t)IP_RETOPTS, (st_data_t)rb_intern2("RETOPTS", 7));
+#endif
+#ifdef IP_RECVDSTADDR
+ st_insert(rsock_intern_ip_optname_hash, (st_data_t)IP_RECVDSTADDR, (st_data_t)rb_intern2("RECVDSTADDR", 11));
+#endif
+#ifdef IP_RECVRETOPTS
+ st_insert(rsock_intern_ip_optname_hash, (st_data_t)IP_RECVRETOPTS, (st_data_t)rb_intern2("RECVRETOPTS", 11));
+#endif
+#ifdef IP_RECVOPTS
+ st_insert(rsock_intern_ip_optname_hash, (st_data_t)IP_RECVOPTS, (st_data_t)rb_intern2("RECVOPTS", 8));
+#endif
+#ifdef IP_TTL
+ st_insert(rsock_intern_ip_optname_hash, (st_data_t)IP_TTL, (st_data_t)rb_intern2("TTL", 3));
+#endif
+#ifdef IP_TOS
+ st_insert(rsock_intern_ip_optname_hash, (st_data_t)IP_TOS, (st_data_t)rb_intern2("TOS", 3));
+#endif
+#ifdef IP_HDRINCL
+ st_insert(rsock_intern_ip_optname_hash, (st_data_t)IP_HDRINCL, (st_data_t)rb_intern2("HDRINCL", 7));
+#endif
+#ifdef IP_OPTIONS
+ st_insert(rsock_intern_ip_optname_hash, (st_data_t)IP_OPTIONS, (st_data_t)rb_intern2("OPTIONS", 7));
+#endif
+
+ rsock_intern_ipv6_optname_hash = st_init_numtable();
+#ifdef IPV6_USE_MIN_MTU
+ st_insert(rsock_intern_ipv6_optname_hash, (st_data_t)IPV6_USE_MIN_MTU, (st_data_t)rb_intern2("IPV6_USE_MIN_MTU", 16));
+#endif
+#ifdef IPV6_TCLASS
+ st_insert(rsock_intern_ipv6_optname_hash, (st_data_t)IPV6_TCLASS, (st_data_t)rb_intern2("IPV6_TCLASS", 11));
+#endif
+#ifdef IPV6_RECVPATHMTU
+ st_insert(rsock_intern_ipv6_optname_hash, (st_data_t)IPV6_RECVPATHMTU, (st_data_t)rb_intern2("IPV6_RECVPATHMTU", 16));
+#endif
+#ifdef IPV6_RTHDR_TYPE_0
+ st_insert(rsock_intern_ipv6_optname_hash, (st_data_t)IPV6_RTHDR_TYPE_0, (st_data_t)rb_intern2("IPV6_RTHDR_TYPE_0", 17));
+#endif
+#ifdef IPV6_RTHDRDSTOPTS
+ st_insert(rsock_intern_ipv6_optname_hash, (st_data_t)IPV6_RTHDRDSTOPTS, (st_data_t)rb_intern2("IPV6_RTHDRDSTOPTS", 17));
+#endif
+#ifdef IPV6_RTHDR
+ st_insert(rsock_intern_ipv6_optname_hash, (st_data_t)IPV6_RTHDR, (st_data_t)rb_intern2("IPV6_RTHDR", 10));
+#endif
+#ifdef IPV6_RECVTCLASS
+ st_insert(rsock_intern_ipv6_optname_hash, (st_data_t)IPV6_RECVTCLASS, (st_data_t)rb_intern2("IPV6_RECVTCLASS", 15));
+#endif
+#ifdef IPV6_RECVRTHDR
+ st_insert(rsock_intern_ipv6_optname_hash, (st_data_t)IPV6_RECVRTHDR, (st_data_t)rb_intern2("IPV6_RECVRTHDR", 14));
+#endif
+#ifdef IPV6_RECVPKTINFO
+ st_insert(rsock_intern_ipv6_optname_hash, (st_data_t)IPV6_RECVPKTINFO, (st_data_t)rb_intern2("IPV6_RECVPKTINFO", 16));
+#endif
+#ifdef IPV6_RECVHOPOPTS
+ st_insert(rsock_intern_ipv6_optname_hash, (st_data_t)IPV6_RECVHOPOPTS, (st_data_t)rb_intern2("IPV6_RECVHOPOPTS", 16));
+#endif
+#ifdef IPV6_RECVHOPLIMIT
+ st_insert(rsock_intern_ipv6_optname_hash, (st_data_t)IPV6_RECVHOPLIMIT, (st_data_t)rb_intern2("IPV6_RECVHOPLIMIT", 17));
+#endif
+#ifdef IPV6_RECVDSTOPTS
+ st_insert(rsock_intern_ipv6_optname_hash, (st_data_t)IPV6_RECVDSTOPTS, (st_data_t)rb_intern2("IPV6_RECVDSTOPTS", 16));
+#endif
+#ifdef IPV6_PKTINFO
+ st_insert(rsock_intern_ipv6_optname_hash, (st_data_t)IPV6_PKTINFO, (st_data_t)rb_intern2("IPV6_PKTINFO", 12));
+#endif
+#ifdef IPV6_PATHMTU
+ st_insert(rsock_intern_ipv6_optname_hash, (st_data_t)IPV6_PATHMTU, (st_data_t)rb_intern2("IPV6_PATHMTU", 12));
+#endif
+#ifdef IPV6_NEXTHOP
+ st_insert(rsock_intern_ipv6_optname_hash, (st_data_t)IPV6_NEXTHOP, (st_data_t)rb_intern2("IPV6_NEXTHOP", 12));
+#endif
+#ifdef IPV6_HOPOPTS
+ st_insert(rsock_intern_ipv6_optname_hash, (st_data_t)IPV6_HOPOPTS, (st_data_t)rb_intern2("IPV6_HOPOPTS", 12));
+#endif
+#ifdef IPV6_HOPLIMIT
+ st_insert(rsock_intern_ipv6_optname_hash, (st_data_t)IPV6_HOPLIMIT, (st_data_t)rb_intern2("IPV6_HOPLIMIT", 13));
+#endif
+#ifdef IPV6_DSTOPTS
+ st_insert(rsock_intern_ipv6_optname_hash, (st_data_t)IPV6_DSTOPTS, (st_data_t)rb_intern2("IPV6_DSTOPTS", 12));
+#endif
+#ifdef IPV6_DONTFRAG
+ st_insert(rsock_intern_ipv6_optname_hash, (st_data_t)IPV6_DONTFRAG, (st_data_t)rb_intern2("IPV6_DONTFRAG", 13));
+#endif
+#ifdef IPV6_CHECKSUM
+ st_insert(rsock_intern_ipv6_optname_hash, (st_data_t)IPV6_CHECKSUM, (st_data_t)rb_intern2("IPV6_CHECKSUM", 13));
+#endif
+#ifdef IPV6_V6ONLY
+ st_insert(rsock_intern_ipv6_optname_hash, (st_data_t)IPV6_V6ONLY, (st_data_t)rb_intern2("IPV6_V6ONLY", 11));
+#endif
+#ifdef IPV6_UNICAST_HOPS
+ st_insert(rsock_intern_ipv6_optname_hash, (st_data_t)IPV6_UNICAST_HOPS, (st_data_t)rb_intern2("IPV6_UNICAST_HOPS", 17));
+#endif
+#ifdef IPV6_MULTICAST_LOOP
+ st_insert(rsock_intern_ipv6_optname_hash, (st_data_t)IPV6_MULTICAST_LOOP, (st_data_t)rb_intern2("IPV6_MULTICAST_LOOP", 19));
+#endif
+#ifdef IPV6_MULTICAST_IF
+ st_insert(rsock_intern_ipv6_optname_hash, (st_data_t)IPV6_MULTICAST_IF, (st_data_t)rb_intern2("IPV6_MULTICAST_IF", 17));
+#endif
+#ifdef IPV6_MULTICAST_HOPS
+ st_insert(rsock_intern_ipv6_optname_hash, (st_data_t)IPV6_MULTICAST_HOPS, (st_data_t)rb_intern2("IPV6_MULTICAST_HOPS", 19));
+#endif
+#ifdef IPV6_LEAVE_GROUP
+ st_insert(rsock_intern_ipv6_optname_hash, (st_data_t)IPV6_LEAVE_GROUP, (st_data_t)rb_intern2("IPV6_LEAVE_GROUP", 16));
+#endif
+#ifdef IPV6_JOIN_GROUP
+ st_insert(rsock_intern_ipv6_optname_hash, (st_data_t)IPV6_JOIN_GROUP, (st_data_t)rb_intern2("IPV6_JOIN_GROUP", 15));
+#endif
+#ifdef IPV6_USE_MIN_MTU
+ st_insert(rsock_intern_ipv6_optname_hash, (st_data_t)IPV6_USE_MIN_MTU, (st_data_t)rb_intern2("USE_MIN_MTU", 11));
+#endif
+#ifdef IPV6_TCLASS
+ st_insert(rsock_intern_ipv6_optname_hash, (st_data_t)IPV6_TCLASS, (st_data_t)rb_intern2("TCLASS", 6));
+#endif
+#ifdef IPV6_RECVPATHMTU
+ st_insert(rsock_intern_ipv6_optname_hash, (st_data_t)IPV6_RECVPATHMTU, (st_data_t)rb_intern2("RECVPATHMTU", 11));
+#endif
+#ifdef IPV6_RTHDR_TYPE_0
+ st_insert(rsock_intern_ipv6_optname_hash, (st_data_t)IPV6_RTHDR_TYPE_0, (st_data_t)rb_intern2("RTHDR_TYPE_0", 12));
+#endif
+#ifdef IPV6_RTHDRDSTOPTS
+ st_insert(rsock_intern_ipv6_optname_hash, (st_data_t)IPV6_RTHDRDSTOPTS, (st_data_t)rb_intern2("RTHDRDSTOPTS", 12));
+#endif
+#ifdef IPV6_RTHDR
+ st_insert(rsock_intern_ipv6_optname_hash, (st_data_t)IPV6_RTHDR, (st_data_t)rb_intern2("RTHDR", 5));
+#endif
+#ifdef IPV6_RECVTCLASS
+ st_insert(rsock_intern_ipv6_optname_hash, (st_data_t)IPV6_RECVTCLASS, (st_data_t)rb_intern2("RECVTCLASS", 10));
+#endif
+#ifdef IPV6_RECVRTHDR
+ st_insert(rsock_intern_ipv6_optname_hash, (st_data_t)IPV6_RECVRTHDR, (st_data_t)rb_intern2("RECVRTHDR", 9));
+#endif
+#ifdef IPV6_RECVPKTINFO
+ st_insert(rsock_intern_ipv6_optname_hash, (st_data_t)IPV6_RECVPKTINFO, (st_data_t)rb_intern2("RECVPKTINFO", 11));
+#endif
+#ifdef IPV6_RECVHOPOPTS
+ st_insert(rsock_intern_ipv6_optname_hash, (st_data_t)IPV6_RECVHOPOPTS, (st_data_t)rb_intern2("RECVHOPOPTS", 11));
+#endif
+#ifdef IPV6_RECVHOPLIMIT
+ st_insert(rsock_intern_ipv6_optname_hash, (st_data_t)IPV6_RECVHOPLIMIT, (st_data_t)rb_intern2("RECVHOPLIMIT", 12));
+#endif
+#ifdef IPV6_RECVDSTOPTS
+ st_insert(rsock_intern_ipv6_optname_hash, (st_data_t)IPV6_RECVDSTOPTS, (st_data_t)rb_intern2("RECVDSTOPTS", 11));
+#endif
+#ifdef IPV6_PKTINFO
+ st_insert(rsock_intern_ipv6_optname_hash, (st_data_t)IPV6_PKTINFO, (st_data_t)rb_intern2("PKTINFO", 7));
+#endif
+#ifdef IPV6_PATHMTU
+ st_insert(rsock_intern_ipv6_optname_hash, (st_data_t)IPV6_PATHMTU, (st_data_t)rb_intern2("PATHMTU", 7));
+#endif
+#ifdef IPV6_NEXTHOP
+ st_insert(rsock_intern_ipv6_optname_hash, (st_data_t)IPV6_NEXTHOP, (st_data_t)rb_intern2("NEXTHOP", 7));
+#endif
+#ifdef IPV6_HOPOPTS
+ st_insert(rsock_intern_ipv6_optname_hash, (st_data_t)IPV6_HOPOPTS, (st_data_t)rb_intern2("HOPOPTS", 7));
+#endif
+#ifdef IPV6_HOPLIMIT
+ st_insert(rsock_intern_ipv6_optname_hash, (st_data_t)IPV6_HOPLIMIT, (st_data_t)rb_intern2("HOPLIMIT", 8));
+#endif
+#ifdef IPV6_DSTOPTS
+ st_insert(rsock_intern_ipv6_optname_hash, (st_data_t)IPV6_DSTOPTS, (st_data_t)rb_intern2("DSTOPTS", 7));
+#endif
+#ifdef IPV6_DONTFRAG
+ st_insert(rsock_intern_ipv6_optname_hash, (st_data_t)IPV6_DONTFRAG, (st_data_t)rb_intern2("DONTFRAG", 8));
+#endif
+#ifdef IPV6_CHECKSUM
+ st_insert(rsock_intern_ipv6_optname_hash, (st_data_t)IPV6_CHECKSUM, (st_data_t)rb_intern2("CHECKSUM", 8));
+#endif
+#ifdef IPV6_V6ONLY
+ st_insert(rsock_intern_ipv6_optname_hash, (st_data_t)IPV6_V6ONLY, (st_data_t)rb_intern2("V6ONLY", 6));
+#endif
+#ifdef IPV6_UNICAST_HOPS
+ st_insert(rsock_intern_ipv6_optname_hash, (st_data_t)IPV6_UNICAST_HOPS, (st_data_t)rb_intern2("UNICAST_HOPS", 12));
+#endif
+#ifdef IPV6_MULTICAST_LOOP
+ st_insert(rsock_intern_ipv6_optname_hash, (st_data_t)IPV6_MULTICAST_LOOP, (st_data_t)rb_intern2("MULTICAST_LOOP", 14));
+#endif
+#ifdef IPV6_MULTICAST_IF
+ st_insert(rsock_intern_ipv6_optname_hash, (st_data_t)IPV6_MULTICAST_IF, (st_data_t)rb_intern2("MULTICAST_IF", 12));
+#endif
+#ifdef IPV6_MULTICAST_HOPS
+ st_insert(rsock_intern_ipv6_optname_hash, (st_data_t)IPV6_MULTICAST_HOPS, (st_data_t)rb_intern2("MULTICAST_HOPS", 14));
+#endif
+#ifdef IPV6_LEAVE_GROUP
+ st_insert(rsock_intern_ipv6_optname_hash, (st_data_t)IPV6_LEAVE_GROUP, (st_data_t)rb_intern2("LEAVE_GROUP", 11));
+#endif
+#ifdef IPV6_JOIN_GROUP
+ st_insert(rsock_intern_ipv6_optname_hash, (st_data_t)IPV6_JOIN_GROUP, (st_data_t)rb_intern2("JOIN_GROUP", 10));
+#endif
+
+ rsock_intern_tcp_optname_hash = st_init_numtable();
+#ifdef TCP_USER_TIMEOUT
+ st_insert(rsock_intern_tcp_optname_hash, (st_data_t)TCP_USER_TIMEOUT, (st_data_t)rb_intern2("TCP_USER_TIMEOUT", 16));
+#endif
+#ifdef TCP_TIMESTAMP
+ st_insert(rsock_intern_tcp_optname_hash, (st_data_t)TCP_TIMESTAMP, (st_data_t)rb_intern2("TCP_TIMESTAMP", 13));
+#endif
+#ifdef TCP_THIN_LINEAR_TIMEOUTS
+ st_insert(rsock_intern_tcp_optname_hash, (st_data_t)TCP_THIN_LINEAR_TIMEOUTS, (st_data_t)rb_intern2("TCP_THIN_LINEAR_TIMEOUTS", 24));
+#endif
+#ifdef TCP_THIN_DUPACK
+ st_insert(rsock_intern_tcp_optname_hash, (st_data_t)TCP_THIN_DUPACK, (st_data_t)rb_intern2("TCP_THIN_DUPACK", 15));
+#endif
+#ifdef TCP_REPAIR_QUEUE
+ st_insert(rsock_intern_tcp_optname_hash, (st_data_t)TCP_REPAIR_QUEUE, (st_data_t)rb_intern2("TCP_REPAIR_QUEUE", 16));
+#endif
+#ifdef TCP_REPAIR_OPTIONS
+ st_insert(rsock_intern_tcp_optname_hash, (st_data_t)TCP_REPAIR_OPTIONS, (st_data_t)rb_intern2("TCP_REPAIR_OPTIONS", 18));
+#endif
+#ifdef TCP_REPAIR
+ st_insert(rsock_intern_tcp_optname_hash, (st_data_t)TCP_REPAIR, (st_data_t)rb_intern2("TCP_REPAIR", 10));
+#endif
+#ifdef TCP_QUEUE_SEQ
+ st_insert(rsock_intern_tcp_optname_hash, (st_data_t)TCP_QUEUE_SEQ, (st_data_t)rb_intern2("TCP_QUEUE_SEQ", 13));
+#endif
+#ifdef TCP_COOKIE_TRANSACTIONS
+ st_insert(rsock_intern_tcp_optname_hash, (st_data_t)TCP_COOKIE_TRANSACTIONS, (st_data_t)rb_intern2("TCP_COOKIE_TRANSACTIONS", 23));
+#endif
+#ifdef TCP_CONGESTION
+ st_insert(rsock_intern_tcp_optname_hash, (st_data_t)TCP_CONGESTION, (st_data_t)rb_intern2("TCP_CONGESTION", 14));
+#endif
+#ifdef TCP_FASTOPEN
+ st_insert(rsock_intern_tcp_optname_hash, (st_data_t)TCP_FASTOPEN, (st_data_t)rb_intern2("TCP_FASTOPEN", 12));
+#endif
+#ifdef TCP_WINDOW_CLAMP
+ st_insert(rsock_intern_tcp_optname_hash, (st_data_t)TCP_WINDOW_CLAMP, (st_data_t)rb_intern2("TCP_WINDOW_CLAMP", 16));
+#endif
+#ifdef TCP_SYNCNT
+ st_insert(rsock_intern_tcp_optname_hash, (st_data_t)TCP_SYNCNT, (st_data_t)rb_intern2("TCP_SYNCNT", 10));
+#endif
+#ifdef TCP_QUICKACK
+ st_insert(rsock_intern_tcp_optname_hash, (st_data_t)TCP_QUICKACK, (st_data_t)rb_intern2("TCP_QUICKACK", 12));
+#endif
+#ifdef TCP_NOPUSH
+ st_insert(rsock_intern_tcp_optname_hash, (st_data_t)TCP_NOPUSH, (st_data_t)rb_intern2("TCP_NOPUSH", 10));
+#endif
+#ifdef TCP_NOOPT
+ st_insert(rsock_intern_tcp_optname_hash, (st_data_t)TCP_NOOPT, (st_data_t)rb_intern2("TCP_NOOPT", 9));
+#endif
+#ifdef TCP_MD5SIG
+ st_insert(rsock_intern_tcp_optname_hash, (st_data_t)TCP_MD5SIG, (st_data_t)rb_intern2("TCP_MD5SIG", 10));
+#endif
+#ifdef TCP_LINGER2
+ st_insert(rsock_intern_tcp_optname_hash, (st_data_t)TCP_LINGER2, (st_data_t)rb_intern2("TCP_LINGER2", 11));
+#endif
+#ifdef TCP_KEEPINTVL
+ st_insert(rsock_intern_tcp_optname_hash, (st_data_t)TCP_KEEPINTVL, (st_data_t)rb_intern2("TCP_KEEPINTVL", 13));
+#endif
+#ifdef TCP_KEEPIDLE
+ st_insert(rsock_intern_tcp_optname_hash, (st_data_t)TCP_KEEPIDLE, (st_data_t)rb_intern2("TCP_KEEPIDLE", 12));
+#endif
+#ifdef TCP_KEEPCNT
+ st_insert(rsock_intern_tcp_optname_hash, (st_data_t)TCP_KEEPCNT, (st_data_t)rb_intern2("TCP_KEEPCNT", 11));
+#endif
+#ifdef TCP_INFO
+ st_insert(rsock_intern_tcp_optname_hash, (st_data_t)TCP_INFO, (st_data_t)rb_intern2("TCP_INFO", 8));
+#endif
+#ifdef TCP_DEFER_ACCEPT
+ st_insert(rsock_intern_tcp_optname_hash, (st_data_t)TCP_DEFER_ACCEPT, (st_data_t)rb_intern2("TCP_DEFER_ACCEPT", 16));
+#endif
+#ifdef TCP_CORK
+ st_insert(rsock_intern_tcp_optname_hash, (st_data_t)TCP_CORK, (st_data_t)rb_intern2("TCP_CORK", 8));
+#endif
+#ifdef TCP_MAXSEG
+ st_insert(rsock_intern_tcp_optname_hash, (st_data_t)TCP_MAXSEG, (st_data_t)rb_intern2("TCP_MAXSEG", 10));
+#endif
+#ifdef TCP_NODELAY
+ st_insert(rsock_intern_tcp_optname_hash, (st_data_t)TCP_NODELAY, (st_data_t)rb_intern2("TCP_NODELAY", 11));
+#endif
+#ifdef TCP_USER_TIMEOUT
+ st_insert(rsock_intern_tcp_optname_hash, (st_data_t)TCP_USER_TIMEOUT, (st_data_t)rb_intern2("USER_TIMEOUT", 12));
+#endif
+#ifdef TCP_TIMESTAMP
+ st_insert(rsock_intern_tcp_optname_hash, (st_data_t)TCP_TIMESTAMP, (st_data_t)rb_intern2("TIMESTAMP", 9));
+#endif
+#ifdef TCP_THIN_LINEAR_TIMEOUTS
+ st_insert(rsock_intern_tcp_optname_hash, (st_data_t)TCP_THIN_LINEAR_TIMEOUTS, (st_data_t)rb_intern2("THIN_LINEAR_TIMEOUTS", 20));
+#endif
+#ifdef TCP_THIN_DUPACK
+ st_insert(rsock_intern_tcp_optname_hash, (st_data_t)TCP_THIN_DUPACK, (st_data_t)rb_intern2("THIN_DUPACK", 11));
+#endif
+#ifdef TCP_REPAIR_QUEUE
+ st_insert(rsock_intern_tcp_optname_hash, (st_data_t)TCP_REPAIR_QUEUE, (st_data_t)rb_intern2("REPAIR_QUEUE", 12));
+#endif
+#ifdef TCP_REPAIR_OPTIONS
+ st_insert(rsock_intern_tcp_optname_hash, (st_data_t)TCP_REPAIR_OPTIONS, (st_data_t)rb_intern2("REPAIR_OPTIONS", 14));
+#endif
+#ifdef TCP_REPAIR
+ st_insert(rsock_intern_tcp_optname_hash, (st_data_t)TCP_REPAIR, (st_data_t)rb_intern2("REPAIR", 6));
+#endif
+#ifdef TCP_QUEUE_SEQ
+ st_insert(rsock_intern_tcp_optname_hash, (st_data_t)TCP_QUEUE_SEQ, (st_data_t)rb_intern2("QUEUE_SEQ", 9));
+#endif
+#ifdef TCP_COOKIE_TRANSACTIONS
+ st_insert(rsock_intern_tcp_optname_hash, (st_data_t)TCP_COOKIE_TRANSACTIONS, (st_data_t)rb_intern2("COOKIE_TRANSACTIONS", 19));
+#endif
+#ifdef TCP_CONGESTION
+ st_insert(rsock_intern_tcp_optname_hash, (st_data_t)TCP_CONGESTION, (st_data_t)rb_intern2("CONGESTION", 10));
+#endif
+#ifdef TCP_FASTOPEN
+ st_insert(rsock_intern_tcp_optname_hash, (st_data_t)TCP_FASTOPEN, (st_data_t)rb_intern2("FASTOPEN", 8));
+#endif
+#ifdef TCP_WINDOW_CLAMP
+ st_insert(rsock_intern_tcp_optname_hash, (st_data_t)TCP_WINDOW_CLAMP, (st_data_t)rb_intern2("WINDOW_CLAMP", 12));
+#endif
+#ifdef TCP_SYNCNT
+ st_insert(rsock_intern_tcp_optname_hash, (st_data_t)TCP_SYNCNT, (st_data_t)rb_intern2("SYNCNT", 6));
+#endif
+#ifdef TCP_QUICKACK
+ st_insert(rsock_intern_tcp_optname_hash, (st_data_t)TCP_QUICKACK, (st_data_t)rb_intern2("QUICKACK", 8));
+#endif
+#ifdef TCP_NOPUSH
+ st_insert(rsock_intern_tcp_optname_hash, (st_data_t)TCP_NOPUSH, (st_data_t)rb_intern2("NOPUSH", 6));
+#endif
+#ifdef TCP_NOOPT
+ st_insert(rsock_intern_tcp_optname_hash, (st_data_t)TCP_NOOPT, (st_data_t)rb_intern2("NOOPT", 5));
+#endif
+#ifdef TCP_MD5SIG
+ st_insert(rsock_intern_tcp_optname_hash, (st_data_t)TCP_MD5SIG, (st_data_t)rb_intern2("MD5SIG", 6));
+#endif
+#ifdef TCP_LINGER2
+ st_insert(rsock_intern_tcp_optname_hash, (st_data_t)TCP_LINGER2, (st_data_t)rb_intern2("LINGER2", 7));
+#endif
+#ifdef TCP_KEEPINTVL
+ st_insert(rsock_intern_tcp_optname_hash, (st_data_t)TCP_KEEPINTVL, (st_data_t)rb_intern2("KEEPINTVL", 9));
+#endif
+#ifdef TCP_KEEPIDLE
+ st_insert(rsock_intern_tcp_optname_hash, (st_data_t)TCP_KEEPIDLE, (st_data_t)rb_intern2("KEEPIDLE", 8));
+#endif
+#ifdef TCP_KEEPCNT
+ st_insert(rsock_intern_tcp_optname_hash, (st_data_t)TCP_KEEPCNT, (st_data_t)rb_intern2("KEEPCNT", 7));
+#endif
+#ifdef TCP_INFO
+ st_insert(rsock_intern_tcp_optname_hash, (st_data_t)TCP_INFO, (st_data_t)rb_intern2("INFO", 4));
+#endif
+#ifdef TCP_DEFER_ACCEPT
+ st_insert(rsock_intern_tcp_optname_hash, (st_data_t)TCP_DEFER_ACCEPT, (st_data_t)rb_intern2("DEFER_ACCEPT", 12));
+#endif
+#ifdef TCP_CORK
+ st_insert(rsock_intern_tcp_optname_hash, (st_data_t)TCP_CORK, (st_data_t)rb_intern2("CORK", 4));
+#endif
+#ifdef TCP_MAXSEG
+ st_insert(rsock_intern_tcp_optname_hash, (st_data_t)TCP_MAXSEG, (st_data_t)rb_intern2("MAXSEG", 6));
+#endif
+#ifdef TCP_NODELAY
+ st_insert(rsock_intern_tcp_optname_hash, (st_data_t)TCP_NODELAY, (st_data_t)rb_intern2("NODELAY", 7));
+#endif
+
+ rsock_intern_udp_optname_hash = st_init_numtable();
+#ifdef UDP_CORK
+ st_insert(rsock_intern_udp_optname_hash, (st_data_t)UDP_CORK, (st_data_t)rb_intern2("UDP_CORK", 8));
+#endif
+#ifdef UDP_CORK
+ st_insert(rsock_intern_udp_optname_hash, (st_data_t)UDP_CORK, (st_data_t)rb_intern2("CORK", 4));
+#endif
+
+ rsock_intern_scm_optname_hash = st_init_numtable();
+#ifdef SCM_WIFI_STATUS
+ st_insert(rsock_intern_scm_optname_hash, (st_data_t)SCM_WIFI_STATUS, (st_data_t)rb_intern2("SCM_WIFI_STATUS", 15));
+#endif
+#ifdef SCM_UCRED
+ st_insert(rsock_intern_scm_optname_hash, (st_data_t)SCM_UCRED, (st_data_t)rb_intern2("SCM_UCRED", 9));
+#endif
+#ifdef SCM_CREDS
+ st_insert(rsock_intern_scm_optname_hash, (st_data_t)SCM_CREDS, (st_data_t)rb_intern2("SCM_CREDS", 9));
+#endif
+#ifdef SCM_CREDENTIALS
+ st_insert(rsock_intern_scm_optname_hash, (st_data_t)SCM_CREDENTIALS, (st_data_t)rb_intern2("SCM_CREDENTIALS", 15));
+#endif
+#ifdef SCM_BINTIME
+ st_insert(rsock_intern_scm_optname_hash, (st_data_t)SCM_BINTIME, (st_data_t)rb_intern2("SCM_BINTIME", 11));
+#endif
+#ifdef SCM_TIMESTAMPING
+ st_insert(rsock_intern_scm_optname_hash, (st_data_t)SCM_TIMESTAMPING, (st_data_t)rb_intern2("SCM_TIMESTAMPING", 16));
+#endif
+#ifdef SCM_TIMESTAMPNS
+ st_insert(rsock_intern_scm_optname_hash, (st_data_t)SCM_TIMESTAMPNS, (st_data_t)rb_intern2("SCM_TIMESTAMPNS", 15));
+#endif
+#ifdef SCM_TIMESTAMP
+ st_insert(rsock_intern_scm_optname_hash, (st_data_t)SCM_TIMESTAMP, (st_data_t)rb_intern2("SCM_TIMESTAMP", 13));
+#endif
+#ifdef SCM_RIGHTS
+ st_insert(rsock_intern_scm_optname_hash, (st_data_t)SCM_RIGHTS, (st_data_t)rb_intern2("SCM_RIGHTS", 10));
+#endif
+#ifdef SCM_WIFI_STATUS
+ st_insert(rsock_intern_scm_optname_hash, (st_data_t)SCM_WIFI_STATUS, (st_data_t)rb_intern2("WIFI_STATUS", 11));
+#endif
+#ifdef SCM_UCRED
+ st_insert(rsock_intern_scm_optname_hash, (st_data_t)SCM_UCRED, (st_data_t)rb_intern2("UCRED", 5));
+#endif
+#ifdef SCM_CREDS
+ st_insert(rsock_intern_scm_optname_hash, (st_data_t)SCM_CREDS, (st_data_t)rb_intern2("CREDS", 5));
+#endif
+#ifdef SCM_CREDENTIALS
+ st_insert(rsock_intern_scm_optname_hash, (st_data_t)SCM_CREDENTIALS, (st_data_t)rb_intern2("CREDENTIALS", 11));
+#endif
+#ifdef SCM_BINTIME
+ st_insert(rsock_intern_scm_optname_hash, (st_data_t)SCM_BINTIME, (st_data_t)rb_intern2("BINTIME", 7));
+#endif
+#ifdef SCM_TIMESTAMPING
+ st_insert(rsock_intern_scm_optname_hash, (st_data_t)SCM_TIMESTAMPING, (st_data_t)rb_intern2("TIMESTAMPING", 12));
+#endif
+#ifdef SCM_TIMESTAMPNS
+ st_insert(rsock_intern_scm_optname_hash, (st_data_t)SCM_TIMESTAMPNS, (st_data_t)rb_intern2("TIMESTAMPNS", 11));
+#endif
+#ifdef SCM_TIMESTAMP
+ st_insert(rsock_intern_scm_optname_hash, (st_data_t)SCM_TIMESTAMP, (st_data_t)rb_intern2("TIMESTAMP", 9));
+#endif
+#ifdef SCM_RIGHTS
+ st_insert(rsock_intern_scm_optname_hash, (st_data_t)SCM_RIGHTS, (st_data_t)rb_intern2("RIGHTS", 6));
+#endif
+
+ rsock_intern_local_optname_hash = st_init_numtable();
+#ifdef LOCAL_CONNWAIT
+ st_insert(rsock_intern_local_optname_hash, (st_data_t)LOCAL_CONNWAIT, (st_data_t)rb_intern2("LOCAL_CONNWAIT", 14));
+#endif
+#ifdef LOCAL_CREDS
+ st_insert(rsock_intern_local_optname_hash, (st_data_t)LOCAL_CREDS, (st_data_t)rb_intern2("LOCAL_CREDS", 11));
+#endif
+#ifdef LOCAL_PEERCRED
+ st_insert(rsock_intern_local_optname_hash, (st_data_t)LOCAL_PEERCRED, (st_data_t)rb_intern2("LOCAL_PEERCRED", 14));
+#endif
+#ifdef LOCAL_CONNWAIT
+ st_insert(rsock_intern_local_optname_hash, (st_data_t)LOCAL_CONNWAIT, (st_data_t)rb_intern2("CONNWAIT", 8));
+#endif
+#ifdef LOCAL_CREDS
+ st_insert(rsock_intern_local_optname_hash, (st_data_t)LOCAL_CREDS, (st_data_t)rb_intern2("CREDS", 5));
+#endif
+#ifdef LOCAL_PEERCRED
+ st_insert(rsock_intern_local_optname_hash, (st_data_t)LOCAL_PEERCRED, (st_data_t)rb_intern2("PEERCRED", 8));
+#endif
+
+}
+
+int
+rsock_family_to_int(const char *str, long len, int *valp)
+{
+ switch (len) {
+ case 2:
+#ifdef AF_NS
+ if (memcmp(str, "NS", 2) == 0) { *valp = AF_NS; return 0; }
+#endif
+ return -1;
+
+ case 3:
+#ifdef AF_IPX
+ if (memcmp(str, "IPX", 3) == 0) { *valp = AF_IPX; return 0; }
+#endif
+#ifdef AF_PUP
+ if (memcmp(str, "PUP", 3) == 0) { *valp = AF_PUP; return 0; }
+#endif
+#ifdef AF_ISO
+ if (memcmp(str, "ISO", 3) == 0) { *valp = AF_ISO; return 0; }
+#endif
+#ifdef AF_OSI
+ if (memcmp(str, "OSI", 3) == 0) { *valp = AF_OSI; return 0; }
+#endif
+#ifdef AF_SNA
+ if (memcmp(str, "SNA", 3) == 0) { *valp = AF_SNA; return 0; }
+#endif
+#ifdef AF_DEC
+ if (memcmp(str, "DEC", 3) == 0) { *valp = AF_DEC; return 0; }
+#endif
+#ifdef AF_DLI
+ if (memcmp(str, "DLI", 3) == 0) { *valp = AF_DLI; return 0; }
+#endif
+#ifdef AF_LAT
+ if (memcmp(str, "LAT", 3) == 0) { *valp = AF_LAT; return 0; }
+#endif
+#ifdef AF_CNT
+ if (memcmp(str, "CNT", 3) == 0) { *valp = AF_CNT; return 0; }
+#endif
+#ifdef AF_SIP
+ if (memcmp(str, "SIP", 3) == 0) { *valp = AF_SIP; return 0; }
+#endif
+#ifdef AF_PPP
+ if (memcmp(str, "PPP", 3) == 0) { *valp = AF_PPP; return 0; }
+#endif
+#ifdef AF_ATM
+ if (memcmp(str, "ATM", 3) == 0) { *valp = AF_ATM; return 0; }
+#endif
+#ifdef AF_MAX
+ if (memcmp(str, "MAX", 3) == 0) { *valp = AF_MAX; return 0; }
+#endif
+ return -1;
+
+ case 4:
+#ifdef AF_INET
+ if (memcmp(str, "INET", 4) == 0) { *valp = AF_INET; return 0; }
+#endif
+#ifdef AF_UNIX
+ if (memcmp(str, "UNIX", 4) == 0) { *valp = AF_UNIX; return 0; }
+#endif
+#ifdef AF_AX25
+ if (memcmp(str, "AX25", 4) == 0) { *valp = AF_AX25; return 0; }
+#endif
+#ifdef AF_ECMA
+ if (memcmp(str, "ECMA", 4) == 0) { *valp = AF_ECMA; return 0; }
+#endif
+#ifdef AF_LINK
+ if (memcmp(str, "LINK", 4) == 0) { *valp = AF_LINK; return 0; }
+#endif
+#ifdef AF_COIP
+ if (memcmp(str, "COIP", 4) == 0) { *valp = AF_COIP; return 0; }
+#endif
+#ifdef AF_NDRV
+ if (memcmp(str, "NDRV", 4) == 0) { *valp = AF_NDRV; return 0; }
+#endif
+#ifdef AF_ISDN
+ if (memcmp(str, "ISDN", 4) == 0) { *valp = AF_ISDN; return 0; }
+#endif
+#ifdef AF_NATM
+ if (memcmp(str, "NATM", 4) == 0) { *valp = AF_NATM; return 0; }
+#endif
+#ifdef AF_E164
+ if (memcmp(str, "E164", 4) == 0) { *valp = AF_E164; return 0; }
+#endif
+ return -1;
+
+ case 5:
+#ifdef AF_NS
+ if (memcmp(str, "AF_NS", 5) == 0) { *valp = AF_NS; return 0; }
+#endif
+#ifdef PF_NS
+ if (memcmp(str, "PF_NS", 5) == 0) { *valp = PF_NS; return 0; }
+#endif
+#ifdef AF_INET6
+ if (memcmp(str, "INET6", 5) == 0) { *valp = AF_INET6; return 0; }
+#endif
+#ifdef AF_LOCAL
+ if (memcmp(str, "LOCAL", 5) == 0) { *valp = AF_LOCAL; return 0; }
+#endif
+#ifdef AF_CHAOS
+ if (memcmp(str, "CHAOS", 5) == 0) { *valp = AF_CHAOS; return 0; }
+#endif
+#ifdef AF_CCITT
+ if (memcmp(str, "CCITT", 5) == 0) { *valp = AF_CCITT; return 0; }
+#endif
+#ifdef AF_ROUTE
+ if (memcmp(str, "ROUTE", 5) == 0) { *valp = AF_ROUTE; return 0; }
+#endif
+ return -1;
+
+ case 6:
+#ifdef AF_IPX
+ if (memcmp(str, "AF_IPX", 6) == 0) { *valp = AF_IPX; return 0; }
+#endif
+#ifdef PF_IPX
+ if (memcmp(str, "PF_IPX", 6) == 0) { *valp = PF_IPX; return 0; }
+#endif
+#ifdef AF_PUP
+ if (memcmp(str, "AF_PUP", 6) == 0) { *valp = AF_PUP; return 0; }
+#endif
+#ifdef PF_PUP
+ if (memcmp(str, "PF_PUP", 6) == 0) { *valp = PF_PUP; return 0; }
+#endif
+#ifdef AF_ISO
+ if (memcmp(str, "AF_ISO", 6) == 0) { *valp = AF_ISO; return 0; }
+#endif
+#ifdef PF_ISO
+ if (memcmp(str, "PF_ISO", 6) == 0) { *valp = PF_ISO; return 0; }
+#endif
+#ifdef AF_OSI
+ if (memcmp(str, "AF_OSI", 6) == 0) { *valp = AF_OSI; return 0; }
+#endif
+#ifdef PF_OSI
+ if (memcmp(str, "PF_OSI", 6) == 0) { *valp = PF_OSI; return 0; }
+#endif
+#ifdef AF_SNA
+ if (memcmp(str, "AF_SNA", 6) == 0) { *valp = AF_SNA; return 0; }
+#endif
+#ifdef PF_SNA
+ if (memcmp(str, "PF_SNA", 6) == 0) { *valp = PF_SNA; return 0; }
+#endif
+#ifdef AF_DEC
+ if (memcmp(str, "AF_DEC", 6) == 0) { *valp = AF_DEC; return 0; }
+#endif
+#ifdef PF_DEC
+ if (memcmp(str, "PF_DEC", 6) == 0) { *valp = PF_DEC; return 0; }
+#endif
+#ifdef AF_DLI
+ if (memcmp(str, "AF_DLI", 6) == 0) { *valp = AF_DLI; return 0; }
+#endif
+#ifdef PF_DLI
+ if (memcmp(str, "PF_DLI", 6) == 0) { *valp = PF_DLI; return 0; }
+#endif
+#ifdef AF_LAT
+ if (memcmp(str, "AF_LAT", 6) == 0) { *valp = AF_LAT; return 0; }
+#endif
+#ifdef PF_LAT
+ if (memcmp(str, "PF_LAT", 6) == 0) { *valp = PF_LAT; return 0; }
+#endif
+#ifdef AF_CNT
+ if (memcmp(str, "AF_CNT", 6) == 0) { *valp = AF_CNT; return 0; }
+#endif
+#ifdef PF_CNT
+ if (memcmp(str, "PF_CNT", 6) == 0) { *valp = PF_CNT; return 0; }
+#endif
+#ifdef AF_SIP
+ if (memcmp(str, "AF_SIP", 6) == 0) { *valp = AF_SIP; return 0; }
+#endif
+#ifdef PF_SIP
+ if (memcmp(str, "PF_SIP", 6) == 0) { *valp = PF_SIP; return 0; }
+#endif
+#ifdef AF_PPP
+ if (memcmp(str, "AF_PPP", 6) == 0) { *valp = AF_PPP; return 0; }
+#endif
+#ifdef PF_PPP
+ if (memcmp(str, "PF_PPP", 6) == 0) { *valp = PF_PPP; return 0; }
+#endif
+#ifdef AF_ATM
+ if (memcmp(str, "AF_ATM", 6) == 0) { *valp = AF_ATM; return 0; }
+#endif
+#ifdef PF_ATM
+ if (memcmp(str, "PF_ATM", 6) == 0) { *valp = PF_ATM; return 0; }
+#endif
+#ifdef AF_MAX
+ if (memcmp(str, "AF_MAX", 6) == 0) { *valp = AF_MAX; return 0; }
+#endif
+#ifdef PF_MAX
+ if (memcmp(str, "PF_MAX", 6) == 0) { *valp = PF_MAX; return 0; }
+#endif
+#ifdef PF_XTP
+ if (memcmp(str, "PF_XTP", 6) == 0) { *valp = PF_XTP; return 0; }
+#endif
+#ifdef PF_PIP
+ if (memcmp(str, "PF_PIP", 6) == 0) { *valp = PF_PIP; return 0; }
+#endif
+#ifdef PF_KEY
+ if (memcmp(str, "PF_KEY", 6) == 0) { *valp = PF_KEY; return 0; }
+#endif
+#ifdef AF_UNSPEC
+ if (memcmp(str, "UNSPEC", 6) == 0) { *valp = AF_UNSPEC; return 0; }
+#endif
+#ifdef AF_HYLINK
+ if (memcmp(str, "HYLINK", 6) == 0) { *valp = AF_HYLINK; return 0; }
+#endif
+#ifdef AF_SYSTEM
+ if (memcmp(str, "SYSTEM", 6) == 0) { *valp = AF_SYSTEM; return 0; }
+#endif
+#ifdef AF_PACKET
+ if (memcmp(str, "PACKET", 6) == 0) { *valp = AF_PACKET; return 0; }
+#endif
+ return -1;
+
+ case 7:
+#ifdef AF_INET
+ if (memcmp(str, "AF_INET", 7) == 0) { *valp = AF_INET; return 0; }
+#endif
+#ifdef PF_INET
+ if (memcmp(str, "PF_INET", 7) == 0) { *valp = PF_INET; return 0; }
+#endif
+#ifdef AF_UNIX
+ if (memcmp(str, "AF_UNIX", 7) == 0) { *valp = AF_UNIX; return 0; }
+#endif
+#ifdef PF_UNIX
+ if (memcmp(str, "PF_UNIX", 7) == 0) { *valp = PF_UNIX; return 0; }
+#endif
+#ifdef AF_AX25
+ if (memcmp(str, "AF_AX25", 7) == 0) { *valp = AF_AX25; return 0; }
+#endif
+#ifdef PF_AX25
+ if (memcmp(str, "PF_AX25", 7) == 0) { *valp = PF_AX25; return 0; }
+#endif
+#ifdef AF_ECMA
+ if (memcmp(str, "AF_ECMA", 7) == 0) { *valp = AF_ECMA; return 0; }
+#endif
+#ifdef PF_ECMA
+ if (memcmp(str, "PF_ECMA", 7) == 0) { *valp = PF_ECMA; return 0; }
+#endif
+#ifdef AF_LINK
+ if (memcmp(str, "AF_LINK", 7) == 0) { *valp = AF_LINK; return 0; }
+#endif
+#ifdef PF_LINK
+ if (memcmp(str, "PF_LINK", 7) == 0) { *valp = PF_LINK; return 0; }
+#endif
+#ifdef AF_COIP
+ if (memcmp(str, "AF_COIP", 7) == 0) { *valp = AF_COIP; return 0; }
+#endif
+#ifdef PF_COIP
+ if (memcmp(str, "PF_COIP", 7) == 0) { *valp = PF_COIP; return 0; }
+#endif
+#ifdef AF_NDRV
+ if (memcmp(str, "AF_NDRV", 7) == 0) { *valp = AF_NDRV; return 0; }
+#endif
+#ifdef PF_NDRV
+ if (memcmp(str, "PF_NDRV", 7) == 0) { *valp = PF_NDRV; return 0; }
+#endif
+#ifdef AF_ISDN
+ if (memcmp(str, "AF_ISDN", 7) == 0) { *valp = AF_ISDN; return 0; }
+#endif
+#ifdef PF_ISDN
+ if (memcmp(str, "PF_ISDN", 7) == 0) { *valp = PF_ISDN; return 0; }
+#endif
+#ifdef AF_NATM
+ if (memcmp(str, "AF_NATM", 7) == 0) { *valp = AF_NATM; return 0; }
+#endif
+#ifdef PF_NATM
+ if (memcmp(str, "PF_NATM", 7) == 0) { *valp = PF_NATM; return 0; }
+#endif
+#ifdef AF_E164
+ if (memcmp(str, "AF_E164", 7) == 0) { *valp = AF_E164; return 0; }
+#endif
+#ifdef PF_RTIP
+ if (memcmp(str, "PF_RTIP", 7) == 0) { *valp = PF_RTIP; return 0; }
+#endif
+#ifdef AF_IMPLINK
+ if (memcmp(str, "IMPLINK", 7) == 0) { *valp = AF_IMPLINK; return 0; }
+#endif
+#ifdef AF_DATAKIT
+ if (memcmp(str, "DATAKIT", 7) == 0) { *valp = AF_DATAKIT; return 0; }
+#endif
+#ifdef AF_NETBIOS
+ if (memcmp(str, "NETBIOS", 7) == 0) { *valp = AF_NETBIOS; return 0; }
+#endif
+ return -1;
+
+ case 8:
+#ifdef AF_INET6
+ if (memcmp(str, "AF_INET6", 8) == 0) { *valp = AF_INET6; return 0; }
+#endif
+#ifdef PF_INET6
+ if (memcmp(str, "PF_INET6", 8) == 0) { *valp = PF_INET6; return 0; }
+#endif
+#ifdef AF_LOCAL
+ if (memcmp(str, "AF_LOCAL", 8) == 0) { *valp = AF_LOCAL; return 0; }
+#endif
+#ifdef PF_LOCAL
+ if (memcmp(str, "PF_LOCAL", 8) == 0) { *valp = PF_LOCAL; return 0; }
+#endif
+#ifdef AF_CHAOS
+ if (memcmp(str, "AF_CHAOS", 8) == 0) { *valp = AF_CHAOS; return 0; }
+#endif
+#ifdef PF_CHAOS
+ if (memcmp(str, "PF_CHAOS", 8) == 0) { *valp = PF_CHAOS; return 0; }
+#endif
+#ifdef AF_CCITT
+ if (memcmp(str, "AF_CCITT", 8) == 0) { *valp = AF_CCITT; return 0; }
+#endif
+#ifdef PF_CCITT
+ if (memcmp(str, "PF_CCITT", 8) == 0) { *valp = PF_CCITT; return 0; }
+#endif
+#ifdef AF_ROUTE
+ if (memcmp(str, "AF_ROUTE", 8) == 0) { *valp = AF_ROUTE; return 0; }
+#endif
+#ifdef PF_ROUTE
+ if (memcmp(str, "PF_ROUTE", 8) == 0) { *valp = PF_ROUTE; return 0; }
+#endif
+#ifdef AF_NETGRAPH
+ if (memcmp(str, "NETGRAPH", 8) == 0) { *valp = AF_NETGRAPH; return 0; }
+#endif
+ return -1;
+
+ case 9:
+#ifdef AF_UNSPEC
+ if (memcmp(str, "AF_UNSPEC", 9) == 0) { *valp = AF_UNSPEC; return 0; }
+#endif
+#ifdef PF_UNSPEC
+ if (memcmp(str, "PF_UNSPEC", 9) == 0) { *valp = PF_UNSPEC; return 0; }
+#endif
+#ifdef AF_HYLINK
+ if (memcmp(str, "AF_HYLINK", 9) == 0) { *valp = AF_HYLINK; return 0; }
+#endif
+#ifdef PF_HYLINK
+ if (memcmp(str, "PF_HYLINK", 9) == 0) { *valp = PF_HYLINK; return 0; }
+#endif
+#ifdef AF_SYSTEM
+ if (memcmp(str, "AF_SYSTEM", 9) == 0) { *valp = AF_SYSTEM; return 0; }
+#endif
+#ifdef PF_SYSTEM
+ if (memcmp(str, "PF_SYSTEM", 9) == 0) { *valp = PF_SYSTEM; return 0; }
+#endif
+#ifdef AF_PACKET
+ if (memcmp(str, "AF_PACKET", 9) == 0) { *valp = AF_PACKET; return 0; }
+#endif
+#ifdef PF_PACKET
+ if (memcmp(str, "PF_PACKET", 9) == 0) { *valp = PF_PACKET; return 0; }
+#endif
+#ifdef AF_APPLETALK
+ if (memcmp(str, "APPLETALK", 9) == 0) { *valp = AF_APPLETALK; return 0; }
+#endif
+ return -1;
+
+ case 10:
+#ifdef AF_IMPLINK
+ if (memcmp(str, "AF_IMPLINK", 10) == 0) { *valp = AF_IMPLINK; return 0; }
+#endif
+#ifdef PF_IMPLINK
+ if (memcmp(str, "PF_IMPLINK", 10) == 0) { *valp = PF_IMPLINK; return 0; }
+#endif
+#ifdef AF_DATAKIT
+ if (memcmp(str, "AF_DATAKIT", 10) == 0) { *valp = AF_DATAKIT; return 0; }
+#endif
+#ifdef PF_DATAKIT
+ if (memcmp(str, "PF_DATAKIT", 10) == 0) { *valp = PF_DATAKIT; return 0; }
+#endif
+#ifdef AF_NETBIOS
+ if (memcmp(str, "AF_NETBIOS", 10) == 0) { *valp = AF_NETBIOS; return 0; }
+#endif
+#ifdef PF_NETBIOS
+ if (memcmp(str, "PF_NETBIOS", 10) == 0) { *valp = PF_NETBIOS; return 0; }
+#endif
+ return -1;
+
+ case 11:
+#ifdef AF_NETGRAPH
+ if (memcmp(str, "AF_NETGRAPH", 11) == 0) { *valp = AF_NETGRAPH; return 0; }
+#endif
+#ifdef PF_NETGRAPH
+ if (memcmp(str, "PF_NETGRAPH", 11) == 0) { *valp = PF_NETGRAPH; return 0; }
+#endif
+ return -1;
+
+ case 12:
+#ifdef AF_APPLETALK
+ if (memcmp(str, "AF_APPLETALK", 12) == 0) { *valp = AF_APPLETALK; return 0; }
+#endif
+#ifdef PF_APPLETALK
+ if (memcmp(str, "PF_APPLETALK", 12) == 0) { *valp = PF_APPLETALK; return 0; }
+#endif
+ return -1;
+
+ default:
+ return -1;
+ }
+}
+
+
+int
+rsock_socktype_to_int(const char *str, long len, int *valp)
+{
+ switch (len) {
+ case 3:
+#ifdef SOCK_RAW
+ if (memcmp(str, "RAW", 3) == 0) { *valp = SOCK_RAW; return 0; }
+#endif
+#ifdef SOCK_RDM
+ if (memcmp(str, "RDM", 3) == 0) { *valp = SOCK_RDM; return 0; }
+#endif
+ return -1;
+
+ case 5:
+#ifdef SOCK_DGRAM
+ if (memcmp(str, "DGRAM", 5) == 0) { *valp = SOCK_DGRAM; return 0; }
+#endif
+ return -1;
+
+ case 6:
+#ifdef SOCK_STREAM
+ if (memcmp(str, "STREAM", 6) == 0) { *valp = SOCK_STREAM; return 0; }
+#endif
+#ifdef SOCK_PACKET
+ if (memcmp(str, "PACKET", 6) == 0) { *valp = SOCK_PACKET; return 0; }
+#endif
+ return -1;
+
+ case 8:
+#ifdef SOCK_RAW
+ if (memcmp(str, "SOCK_RAW", 8) == 0) { *valp = SOCK_RAW; return 0; }
+#endif
+#ifdef SOCK_RDM
+ if (memcmp(str, "SOCK_RDM", 8) == 0) { *valp = SOCK_RDM; return 0; }
+#endif
+ return -1;
+
+ case 9:
+#ifdef SOCK_SEQPACKET
+ if (memcmp(str, "SEQPACKET", 9) == 0) { *valp = SOCK_SEQPACKET; return 0; }
+#endif
+ return -1;
+
+ case 10:
+#ifdef SOCK_DGRAM
+ if (memcmp(str, "SOCK_DGRAM", 10) == 0) { *valp = SOCK_DGRAM; return 0; }
+#endif
+ return -1;
+
+ case 11:
+#ifdef SOCK_STREAM
+ if (memcmp(str, "SOCK_STREAM", 11) == 0) { *valp = SOCK_STREAM; return 0; }
+#endif
+#ifdef SOCK_PACKET
+ if (memcmp(str, "SOCK_PACKET", 11) == 0) { *valp = SOCK_PACKET; return 0; }
+#endif
+ return -1;
+
+ case 14:
+#ifdef SOCK_SEQPACKET
+ if (memcmp(str, "SOCK_SEQPACKET", 14) == 0) { *valp = SOCK_SEQPACKET; return 0; }
+#endif
+ return -1;
+
+ default:
+ return -1;
+ }
+}
+
+
+int
+rsock_ipproto_to_int(const char *str, long len, int *valp)
+{
+ switch (len) {
+ case 2:
+#ifdef IPPROTO_IP
+ if (memcmp(str, "IP", 2) == 0) { *valp = IPPROTO_IP; return 0; }
+#endif
+#ifdef IPPROTO_ND
+ if (memcmp(str, "ND", 2) == 0) { *valp = IPPROTO_ND; return 0; }
+#endif
+#ifdef IPPROTO_TP
+ if (memcmp(str, "TP", 2) == 0) { *valp = IPPROTO_TP; return 0; }
+#endif
+#ifdef IPPROTO_AH
+ if (memcmp(str, "AH", 2) == 0) { *valp = IPPROTO_AH; return 0; }
+#endif
+ return -1;
+
+ case 3:
+#ifdef IPPROTO_GGP
+ if (memcmp(str, "GGP", 3) == 0) { *valp = IPPROTO_GGP; return 0; }
+#endif
+#ifdef IPPROTO_TCP
+ if (memcmp(str, "TCP", 3) == 0) { *valp = IPPROTO_TCP; return 0; }
+#endif
+#ifdef IPPROTO_EGP
+ if (memcmp(str, "EGP", 3) == 0) { *valp = IPPROTO_EGP; return 0; }
+#endif
+#ifdef IPPROTO_PUP
+ if (memcmp(str, "PUP", 3) == 0) { *valp = IPPROTO_PUP; return 0; }
+#endif
+#ifdef IPPROTO_UDP
+ if (memcmp(str, "UDP", 3) == 0) { *valp = IPPROTO_UDP; return 0; }
+#endif
+#ifdef IPPROTO_IDP
+ if (memcmp(str, "IDP", 3) == 0) { *valp = IPPROTO_IDP; return 0; }
+#endif
+#ifdef IPPROTO_XTP
+ if (memcmp(str, "XTP", 3) == 0) { *valp = IPPROTO_XTP; return 0; }
+#endif
+#ifdef IPPROTO_EON
+ if (memcmp(str, "EON", 3) == 0) { *valp = IPPROTO_EON; return 0; }
+#endif
+#ifdef IPPROTO_BIP
+ if (memcmp(str, "BIP", 3) == 0) { *valp = IPPROTO_BIP; return 0; }
+#endif
+#ifdef IPPROTO_ESP
+ if (memcmp(str, "ESP", 3) == 0) { *valp = IPPROTO_ESP; return 0; }
+#endif
+#ifdef IPPROTO_RAW
+ if (memcmp(str, "RAW", 3) == 0) { *valp = IPPROTO_RAW; return 0; }
+#endif
+#ifdef IPPROTO_MAX
+ if (memcmp(str, "MAX", 3) == 0) { *valp = IPPROTO_MAX; return 0; }
+#endif
+ return -1;
+
+ case 4:
+#ifdef IPPROTO_ICMP
+ if (memcmp(str, "ICMP", 4) == 0) { *valp = IPPROTO_ICMP; return 0; }
+#endif
+#ifdef IPPROTO_IGMP
+ if (memcmp(str, "IGMP", 4) == 0) { *valp = IPPROTO_IGMP; return 0; }
+#endif
+#ifdef IPPROTO_IPV6
+ if (memcmp(str, "IPV6", 4) == 0) { *valp = IPPROTO_IPV6; return 0; }
+#endif
+#ifdef IPPROTO_NONE
+ if (memcmp(str, "NONE", 4) == 0) { *valp = IPPROTO_NONE; return 0; }
+#endif
+ return -1;
+
+ case 5:
+#ifdef IPPROTO_HELLO
+ if (memcmp(str, "HELLO", 5) == 0) { *valp = IPPROTO_HELLO; return 0; }
+#endif
+ return -1;
+
+ case 6:
+#ifdef IPPROTO_ICMPV6
+ if (memcmp(str, "ICMPV6", 6) == 0) { *valp = IPPROTO_ICMPV6; return 0; }
+#endif
+ return -1;
+
+ case 7:
+#ifdef IPPROTO_DSTOPTS
+ if (memcmp(str, "DSTOPTS", 7) == 0) { *valp = IPPROTO_DSTOPTS; return 0; }
+#endif
+#ifdef IPPROTO_HOPOPTS
+ if (memcmp(str, "HOPOPTS", 7) == 0) { *valp = IPPROTO_HOPOPTS; return 0; }
+#endif
+#ifdef IPPROTO_ROUTING
+ if (memcmp(str, "ROUTING", 7) == 0) { *valp = IPPROTO_ROUTING; return 0; }
+#endif
+ return -1;
+
+ case 8:
+#ifdef IPPROTO_FRAGMENT
+ if (memcmp(str, "FRAGMENT", 8) == 0) { *valp = IPPROTO_FRAGMENT; return 0; }
+#endif
+ return -1;
+
+ case 10:
+#ifdef IPPROTO_IP
+ if (memcmp(str, "IPPROTO_IP", 10) == 0) { *valp = IPPROTO_IP; return 0; }
+#endif
+#ifdef IPPROTO_ND
+ if (memcmp(str, "IPPROTO_ND", 10) == 0) { *valp = IPPROTO_ND; return 0; }
+#endif
+#ifdef IPPROTO_TP
+ if (memcmp(str, "IPPROTO_TP", 10) == 0) { *valp = IPPROTO_TP; return 0; }
+#endif
+#ifdef IPPROTO_AH
+ if (memcmp(str, "IPPROTO_AH", 10) == 0) { *valp = IPPROTO_AH; return 0; }
+#endif
+ return -1;
+
+ case 11:
+#ifdef IPPROTO_GGP
+ if (memcmp(str, "IPPROTO_GGP", 11) == 0) { *valp = IPPROTO_GGP; return 0; }
+#endif
+#ifdef IPPROTO_TCP
+ if (memcmp(str, "IPPROTO_TCP", 11) == 0) { *valp = IPPROTO_TCP; return 0; }
+#endif
+#ifdef IPPROTO_EGP
+ if (memcmp(str, "IPPROTO_EGP", 11) == 0) { *valp = IPPROTO_EGP; return 0; }
+#endif
+#ifdef IPPROTO_PUP
+ if (memcmp(str, "IPPROTO_PUP", 11) == 0) { *valp = IPPROTO_PUP; return 0; }
+#endif
+#ifdef IPPROTO_UDP
+ if (memcmp(str, "IPPROTO_UDP", 11) == 0) { *valp = IPPROTO_UDP; return 0; }
+#endif
+#ifdef IPPROTO_IDP
+ if (memcmp(str, "IPPROTO_IDP", 11) == 0) { *valp = IPPROTO_IDP; return 0; }
+#endif
+#ifdef IPPROTO_XTP
+ if (memcmp(str, "IPPROTO_XTP", 11) == 0) { *valp = IPPROTO_XTP; return 0; }
+#endif
+#ifdef IPPROTO_EON
+ if (memcmp(str, "IPPROTO_EON", 11) == 0) { *valp = IPPROTO_EON; return 0; }
+#endif
+#ifdef IPPROTO_BIP
+ if (memcmp(str, "IPPROTO_BIP", 11) == 0) { *valp = IPPROTO_BIP; return 0; }
+#endif
+#ifdef IPPROTO_ESP
+ if (memcmp(str, "IPPROTO_ESP", 11) == 0) { *valp = IPPROTO_ESP; return 0; }
+#endif
+#ifdef IPPROTO_RAW
+ if (memcmp(str, "IPPROTO_RAW", 11) == 0) { *valp = IPPROTO_RAW; return 0; }
+#endif
+#ifdef IPPROTO_MAX
+ if (memcmp(str, "IPPROTO_MAX", 11) == 0) { *valp = IPPROTO_MAX; return 0; }
+#endif
+ return -1;
+
+ case 12:
+#ifdef IPPROTO_ICMP
+ if (memcmp(str, "IPPROTO_ICMP", 12) == 0) { *valp = IPPROTO_ICMP; return 0; }
+#endif
+#ifdef IPPROTO_IGMP
+ if (memcmp(str, "IPPROTO_IGMP", 12) == 0) { *valp = IPPROTO_IGMP; return 0; }
+#endif
+#ifdef IPPROTO_IPV6
+ if (memcmp(str, "IPPROTO_IPV6", 12) == 0) { *valp = IPPROTO_IPV6; return 0; }
+#endif
+#ifdef IPPROTO_NONE
+ if (memcmp(str, "IPPROTO_NONE", 12) == 0) { *valp = IPPROTO_NONE; return 0; }
+#endif
+ return -1;
+
+ case 13:
+#ifdef IPPROTO_HELLO
+ if (memcmp(str, "IPPROTO_HELLO", 13) == 0) { *valp = IPPROTO_HELLO; return 0; }
+#endif
+ return -1;
+
+ case 14:
+#ifdef IPPROTO_ICMPV6
+ if (memcmp(str, "IPPROTO_ICMPV6", 14) == 0) { *valp = IPPROTO_ICMPV6; return 0; }
+#endif
+ return -1;
+
+ case 15:
+#ifdef IPPROTO_DSTOPTS
+ if (memcmp(str, "IPPROTO_DSTOPTS", 15) == 0) { *valp = IPPROTO_DSTOPTS; return 0; }
+#endif
+#ifdef IPPROTO_HOPOPTS
+ if (memcmp(str, "IPPROTO_HOPOPTS", 15) == 0) { *valp = IPPROTO_HOPOPTS; return 0; }
+#endif
+#ifdef IPPROTO_ROUTING
+ if (memcmp(str, "IPPROTO_ROUTING", 15) == 0) { *valp = IPPROTO_ROUTING; return 0; }
+#endif
+ return -1;
+
+ case 16:
+#ifdef IPPROTO_FRAGMENT
+ if (memcmp(str, "IPPROTO_FRAGMENT", 16) == 0) { *valp = IPPROTO_FRAGMENT; return 0; }
+#endif
+ return -1;
+
+ default:
+ return -1;
+ }
+}
+
+
+int
+rsock_unknown_level_to_int(const char *str, long len, int *valp)
+{
+ switch (len) {
+ case 6:
+#ifdef SOL_SOCKET
+ if (memcmp(str, "SOCKET", 6) == 0) { *valp = SOL_SOCKET; return 0; }
+#endif
+ return -1;
+
+ case 10:
+#ifdef SOL_SOCKET
+ if (memcmp(str, "SOL_SOCKET", 10) == 0) { *valp = SOL_SOCKET; return 0; }
+#endif
+ return -1;
+
+ default:
+ return -1;
+ }
+}
+
+
+int
+rsock_ip_level_to_int(const char *str, long len, int *valp)
+{
+ switch (len) {
+ case 2:
+#ifdef IPPROTO_IP
+ if (memcmp(str, "IP", 2) == 0) { *valp = IPPROTO_IP; return 0; }
+#endif
+#ifdef IPPROTO_ND
+ if (memcmp(str, "ND", 2) == 0) { *valp = IPPROTO_ND; return 0; }
+#endif
+#ifdef IPPROTO_TP
+ if (memcmp(str, "TP", 2) == 0) { *valp = IPPROTO_TP; return 0; }
+#endif
+#ifdef IPPROTO_AH
+ if (memcmp(str, "AH", 2) == 0) { *valp = IPPROTO_AH; return 0; }
+#endif
+ return -1;
+
+ case 3:
+#ifdef IPPROTO_GGP
+ if (memcmp(str, "GGP", 3) == 0) { *valp = IPPROTO_GGP; return 0; }
+#endif
+#ifdef IPPROTO_TCP
+ if (memcmp(str, "TCP", 3) == 0) { *valp = IPPROTO_TCP; return 0; }
+#endif
+#ifdef IPPROTO_EGP
+ if (memcmp(str, "EGP", 3) == 0) { *valp = IPPROTO_EGP; return 0; }
+#endif
+#ifdef IPPROTO_PUP
+ if (memcmp(str, "PUP", 3) == 0) { *valp = IPPROTO_PUP; return 0; }
+#endif
+#ifdef IPPROTO_UDP
+ if (memcmp(str, "UDP", 3) == 0) { *valp = IPPROTO_UDP; return 0; }
+#endif
+#ifdef IPPROTO_IDP
+ if (memcmp(str, "IDP", 3) == 0) { *valp = IPPROTO_IDP; return 0; }
+#endif
+#ifdef IPPROTO_XTP
+ if (memcmp(str, "XTP", 3) == 0) { *valp = IPPROTO_XTP; return 0; }
+#endif
+#ifdef IPPROTO_EON
+ if (memcmp(str, "EON", 3) == 0) { *valp = IPPROTO_EON; return 0; }
+#endif
+#ifdef IPPROTO_BIP
+ if (memcmp(str, "BIP", 3) == 0) { *valp = IPPROTO_BIP; return 0; }
+#endif
+#ifdef IPPROTO_ESP
+ if (memcmp(str, "ESP", 3) == 0) { *valp = IPPROTO_ESP; return 0; }
+#endif
+#ifdef IPPROTO_RAW
+ if (memcmp(str, "RAW", 3) == 0) { *valp = IPPROTO_RAW; return 0; }
+#endif
+#ifdef IPPROTO_MAX
+ if (memcmp(str, "MAX", 3) == 0) { *valp = IPPROTO_MAX; return 0; }
+#endif
+ return -1;
+
+ case 4:
+#ifdef IPPROTO_ICMP
+ if (memcmp(str, "ICMP", 4) == 0) { *valp = IPPROTO_ICMP; return 0; }
+#endif
+#ifdef IPPROTO_IGMP
+ if (memcmp(str, "IGMP", 4) == 0) { *valp = IPPROTO_IGMP; return 0; }
+#endif
+#ifdef IPPROTO_IPV6
+ if (memcmp(str, "IPV6", 4) == 0) { *valp = IPPROTO_IPV6; return 0; }
+#endif
+#ifdef IPPROTO_NONE
+ if (memcmp(str, "NONE", 4) == 0) { *valp = IPPROTO_NONE; return 0; }
+#endif
+ return -1;
+
+ case 5:
+#ifdef IPPROTO_HELLO
+ if (memcmp(str, "HELLO", 5) == 0) { *valp = IPPROTO_HELLO; return 0; }
+#endif
+ return -1;
+
+ case 6:
+#ifdef SOL_SOCKET
+ if (memcmp(str, "SOCKET", 6) == 0) { *valp = SOL_SOCKET; return 0; }
+#endif
+#ifdef IPPROTO_ICMPV6
+ if (memcmp(str, "ICMPV6", 6) == 0) { *valp = IPPROTO_ICMPV6; return 0; }
+#endif
+ return -1;
+
+ case 7:
+#ifdef IPPROTO_DSTOPTS
+ if (memcmp(str, "DSTOPTS", 7) == 0) { *valp = IPPROTO_DSTOPTS; return 0; }
+#endif
+#ifdef IPPROTO_HOPOPTS
+ if (memcmp(str, "HOPOPTS", 7) == 0) { *valp = IPPROTO_HOPOPTS; return 0; }
+#endif
+#ifdef IPPROTO_ROUTING
+ if (memcmp(str, "ROUTING", 7) == 0) { *valp = IPPROTO_ROUTING; return 0; }
+#endif
+ return -1;
+
+ case 8:
+#ifdef IPPROTO_FRAGMENT
+ if (memcmp(str, "FRAGMENT", 8) == 0) { *valp = IPPROTO_FRAGMENT; return 0; }
+#endif
+ return -1;
+
+ case 10:
+#ifdef SOL_SOCKET
+ if (memcmp(str, "SOL_SOCKET", 10) == 0) { *valp = SOL_SOCKET; return 0; }
+#endif
+#ifdef IPPROTO_IP
+ if (memcmp(str, "IPPROTO_IP", 10) == 0) { *valp = IPPROTO_IP; return 0; }
+#endif
+#ifdef IPPROTO_ND
+ if (memcmp(str, "IPPROTO_ND", 10) == 0) { *valp = IPPROTO_ND; return 0; }
+#endif
+#ifdef IPPROTO_TP
+ if (memcmp(str, "IPPROTO_TP", 10) == 0) { *valp = IPPROTO_TP; return 0; }
+#endif
+#ifdef IPPROTO_AH
+ if (memcmp(str, "IPPROTO_AH", 10) == 0) { *valp = IPPROTO_AH; return 0; }
+#endif
+ return -1;
+
+ case 11:
+#ifdef IPPROTO_GGP
+ if (memcmp(str, "IPPROTO_GGP", 11) == 0) { *valp = IPPROTO_GGP; return 0; }
+#endif
+#ifdef IPPROTO_TCP
+ if (memcmp(str, "IPPROTO_TCP", 11) == 0) { *valp = IPPROTO_TCP; return 0; }
+#endif
+#ifdef IPPROTO_EGP
+ if (memcmp(str, "IPPROTO_EGP", 11) == 0) { *valp = IPPROTO_EGP; return 0; }
+#endif
+#ifdef IPPROTO_PUP
+ if (memcmp(str, "IPPROTO_PUP", 11) == 0) { *valp = IPPROTO_PUP; return 0; }
+#endif
+#ifdef IPPROTO_UDP
+ if (memcmp(str, "IPPROTO_UDP", 11) == 0) { *valp = IPPROTO_UDP; return 0; }
+#endif
+#ifdef IPPROTO_IDP
+ if (memcmp(str, "IPPROTO_IDP", 11) == 0) { *valp = IPPROTO_IDP; return 0; }
+#endif
+#ifdef IPPROTO_XTP
+ if (memcmp(str, "IPPROTO_XTP", 11) == 0) { *valp = IPPROTO_XTP; return 0; }
+#endif
+#ifdef IPPROTO_EON
+ if (memcmp(str, "IPPROTO_EON", 11) == 0) { *valp = IPPROTO_EON; return 0; }
+#endif
+#ifdef IPPROTO_BIP
+ if (memcmp(str, "IPPROTO_BIP", 11) == 0) { *valp = IPPROTO_BIP; return 0; }
+#endif
+#ifdef IPPROTO_ESP
+ if (memcmp(str, "IPPROTO_ESP", 11) == 0) { *valp = IPPROTO_ESP; return 0; }
+#endif
+#ifdef IPPROTO_RAW
+ if (memcmp(str, "IPPROTO_RAW", 11) == 0) { *valp = IPPROTO_RAW; return 0; }
+#endif
+#ifdef IPPROTO_MAX
+ if (memcmp(str, "IPPROTO_MAX", 11) == 0) { *valp = IPPROTO_MAX; return 0; }
+#endif
+ return -1;
+
+ case 12:
+#ifdef IPPROTO_ICMP
+ if (memcmp(str, "IPPROTO_ICMP", 12) == 0) { *valp = IPPROTO_ICMP; return 0; }
+#endif
+#ifdef IPPROTO_IGMP
+ if (memcmp(str, "IPPROTO_IGMP", 12) == 0) { *valp = IPPROTO_IGMP; return 0; }
+#endif
+#ifdef IPPROTO_IPV6
+ if (memcmp(str, "IPPROTO_IPV6", 12) == 0) { *valp = IPPROTO_IPV6; return 0; }
+#endif
+#ifdef IPPROTO_NONE
+ if (memcmp(str, "IPPROTO_NONE", 12) == 0) { *valp = IPPROTO_NONE; return 0; }
+#endif
+ return -1;
+
+ case 13:
+#ifdef IPPROTO_HELLO
+ if (memcmp(str, "IPPROTO_HELLO", 13) == 0) { *valp = IPPROTO_HELLO; return 0; }
+#endif
+ return -1;
+
+ case 14:
+#ifdef IPPROTO_ICMPV6
+ if (memcmp(str, "IPPROTO_ICMPV6", 14) == 0) { *valp = IPPROTO_ICMPV6; return 0; }
+#endif
+ return -1;
+
+ case 15:
+#ifdef IPPROTO_DSTOPTS
+ if (memcmp(str, "IPPROTO_DSTOPTS", 15) == 0) { *valp = IPPROTO_DSTOPTS; return 0; }
+#endif
+#ifdef IPPROTO_HOPOPTS
+ if (memcmp(str, "IPPROTO_HOPOPTS", 15) == 0) { *valp = IPPROTO_HOPOPTS; return 0; }
+#endif
+#ifdef IPPROTO_ROUTING
+ if (memcmp(str, "IPPROTO_ROUTING", 15) == 0) { *valp = IPPROTO_ROUTING; return 0; }
+#endif
+ return -1;
+
+ case 16:
+#ifdef IPPROTO_FRAGMENT
+ if (memcmp(str, "IPPROTO_FRAGMENT", 16) == 0) { *valp = IPPROTO_FRAGMENT; return 0; }
+#endif
+ return -1;
+
+ default:
+ return -1;
+ }
+}
+
+
+int
+rsock_so_optname_to_int(const char *str, long len, int *valp)
+{
+ switch (len) {
+ case 3:
+#ifdef SO_NKE
+ if (memcmp(str, "NKE", 3) == 0) { *valp = SO_NKE; return 0; }
+#endif
+ return -1;
+
+ case 4:
+#ifdef SO_TYPE
+ if (memcmp(str, "TYPE", 4) == 0) { *valp = SO_TYPE; return 0; }
+#endif
+#ifdef SO_MARK
+ if (memcmp(str, "MARK", 4) == 0) { *valp = SO_MARK; return 0; }
+#endif
+ return -1;
+
+ case 5:
+#ifdef SO_DEBUG
+ if (memcmp(str, "DEBUG", 5) == 0) { *valp = SO_DEBUG; return 0; }
+#endif
+#ifdef SO_ERROR
+ if (memcmp(str, "ERROR", 5) == 0) { *valp = SO_ERROR; return 0; }
+#endif
+#ifdef SO_NREAD
+ if (memcmp(str, "NREAD", 5) == 0) { *valp = SO_NREAD; return 0; }
+#endif
+#ifdef SO_NOFCS
+ if (memcmp(str, "NOFCS", 5) == 0) { *valp = SO_NOFCS; return 0; }
+#endif
+ return -1;
+
+ case 6:
+#ifdef SO_NKE
+ if (memcmp(str, "SO_NKE", 6) == 0) { *valp = SO_NKE; return 0; }
+#endif
+#ifdef SO_SNDBUF
+ if (memcmp(str, "SNDBUF", 6) == 0) { *valp = SO_SNDBUF; return 0; }
+#endif
+#ifdef SO_RCVBUF
+ if (memcmp(str, "RCVBUF", 6) == 0) { *valp = SO_RCVBUF; return 0; }
+#endif
+#ifdef SO_LINGER
+ if (memcmp(str, "LINGER", 6) == 0) { *valp = SO_LINGER; return 0; }
+#endif
+#ifdef SO_DOMAIN
+ if (memcmp(str, "DOMAIN", 6) == 0) { *valp = SO_DOMAIN; return 0; }
+#endif
+ return -1;
+
+ case 7:
+#ifdef SO_TYPE
+ if (memcmp(str, "SO_TYPE", 7) == 0) { *valp = SO_TYPE; return 0; }
+#endif
+#ifdef SO_MARK
+ if (memcmp(str, "SO_MARK", 7) == 0) { *valp = SO_MARK; return 0; }
+#endif
+#ifdef SO_BINTIME
+ if (memcmp(str, "BINTIME", 7) == 0) { *valp = SO_BINTIME; return 0; }
+#endif
+#ifdef SO_PEERSEC
+ if (memcmp(str, "PEERSEC", 7) == 0) { *valp = SO_PEERSEC; return 0; }
+#endif
+#ifdef SO_PASSSEC
+ if (memcmp(str, "PASSSEC", 7) == 0) { *valp = SO_PASSSEC; return 0; }
+#endif
+ return -1;
+
+ case 8:
+#ifdef SO_DEBUG
+ if (memcmp(str, "SO_DEBUG", 8) == 0) { *valp = SO_DEBUG; return 0; }
+#endif
+#ifdef SO_ERROR
+ if (memcmp(str, "SO_ERROR", 8) == 0) { *valp = SO_ERROR; return 0; }
+#endif
+#ifdef SO_NREAD
+ if (memcmp(str, "SO_NREAD", 8) == 0) { *valp = SO_NREAD; return 0; }
+#endif
+#ifdef SO_NOFCS
+ if (memcmp(str, "SO_NOFCS", 8) == 0) { *valp = SO_NOFCS; return 0; }
+#endif
+#ifdef SO_NO_CHECK
+ if (memcmp(str, "NO_CHECK", 8) == 0) { *valp = SO_NO_CHECK; return 0; }
+#endif
+#ifdef SO_PRIORITY
+ if (memcmp(str, "PRIORITY", 8) == 0) { *valp = SO_PRIORITY; return 0; }
+#endif
+#ifdef SO_PASSCRED
+ if (memcmp(str, "PASSCRED", 8) == 0) { *valp = SO_PASSCRED; return 0; }
+#endif
+#ifdef SO_PEERCRED
+ if (memcmp(str, "PEERCRED", 8) == 0) { *valp = SO_PEERCRED; return 0; }
+#endif
+#ifdef SO_RCVLOWAT
+ if (memcmp(str, "RCVLOWAT", 8) == 0) { *valp = SO_RCVLOWAT; return 0; }
+#endif
+#ifdef SO_SNDLOWAT
+ if (memcmp(str, "SNDLOWAT", 8) == 0) { *valp = SO_SNDLOWAT; return 0; }
+#endif
+#ifdef SO_RCVTIMEO
+ if (memcmp(str, "RCVTIMEO", 8) == 0) { *valp = SO_RCVTIMEO; return 0; }
+#endif
+#ifdef SO_SNDTIMEO
+ if (memcmp(str, "SNDTIMEO", 8) == 0) { *valp = SO_SNDTIMEO; return 0; }
+#endif
+#ifdef SO_WANTMORE
+ if (memcmp(str, "WANTMORE", 8) == 0) { *valp = SO_WANTMORE; return 0; }
+#endif
+#ifdef SO_PEERNAME
+ if (memcmp(str, "PEERNAME", 8) == 0) { *valp = SO_PEERNAME; return 0; }
+#endif
+#ifdef SO_ALLZONES
+ if (memcmp(str, "ALLZONES", 8) == 0) { *valp = SO_ALLZONES; return 0; }
+#endif
+#ifdef SO_PROTOCOL
+ if (memcmp(str, "PROTOCOL", 8) == 0) { *valp = SO_PROTOCOL; return 0; }
+#endif
+#ifdef SO_RXQ_OVFL
+ if (memcmp(str, "RXQ_OVFL", 8) == 0) { *valp = SO_RXQ_OVFL; return 0; }
+#endif
+#ifdef SO_PEEK_OFF
+ if (memcmp(str, "PEEK_OFF", 8) == 0) { *valp = SO_PEEK_OFF; return 0; }
+#endif
+ return -1;
+
+ case 9:
+#ifdef SO_SNDBUF
+ if (memcmp(str, "SO_SNDBUF", 9) == 0) { *valp = SO_SNDBUF; return 0; }
+#endif
+#ifdef SO_RCVBUF
+ if (memcmp(str, "SO_RCVBUF", 9) == 0) { *valp = SO_RCVBUF; return 0; }
+#endif
+#ifdef SO_LINGER
+ if (memcmp(str, "SO_LINGER", 9) == 0) { *valp = SO_LINGER; return 0; }
+#endif
+#ifdef SO_DOMAIN
+ if (memcmp(str, "SO_DOMAIN", 9) == 0) { *valp = SO_DOMAIN; return 0; }
+#endif
+#ifdef SO_REUSEADDR
+ if (memcmp(str, "REUSEADDR", 9) == 0) { *valp = SO_REUSEADDR; return 0; }
+#endif
+#ifdef SO_REUSEPORT
+ if (memcmp(str, "REUSEPORT", 9) == 0) { *valp = SO_REUSEPORT; return 0; }
+#endif
+#ifdef SO_DONTROUTE
+ if (memcmp(str, "DONTROUTE", 9) == 0) { *valp = SO_DONTROUTE; return 0; }
+#endif
+#ifdef SO_BROADCAST
+ if (memcmp(str, "BROADCAST", 9) == 0) { *valp = SO_BROADCAST; return 0; }
+#endif
+#ifdef SO_KEEPALIVE
+ if (memcmp(str, "KEEPALIVE", 9) == 0) { *valp = SO_KEEPALIVE; return 0; }
+#endif
+#ifdef SO_OOBINLINE
+ if (memcmp(str, "OOBINLINE", 9) == 0) { *valp = SO_OOBINLINE; return 0; }
+#endif
+#ifdef SO_DONTTRUNC
+ if (memcmp(str, "DONTTRUNC", 9) == 0) { *valp = SO_DONTTRUNC; return 0; }
+#endif
+#ifdef SO_NOSIGPIPE
+ if (memcmp(str, "NOSIGPIPE", 9) == 0) { *valp = SO_NOSIGPIPE; return 0; }
+#endif
+#ifdef SO_TIMESTAMP
+ if (memcmp(str, "TIMESTAMP", 9) == 0) { *valp = SO_TIMESTAMP; return 0; }
+#endif
+#ifdef SO_RECVUCRED
+ if (memcmp(str, "RECVUCRED", 9) == 0) { *valp = SO_RECVUCRED; return 0; }
+#endif
+#ifdef SO_BUSY_POLL
+ if (memcmp(str, "BUSY_POLL", 9) == 0) { *valp = SO_BUSY_POLL; return 0; }
+#endif
+ return -1;
+
+ case 10:
+#ifdef SO_BINTIME
+ if (memcmp(str, "SO_BINTIME", 10) == 0) { *valp = SO_BINTIME; return 0; }
+#endif
+#ifdef SO_PEERSEC
+ if (memcmp(str, "SO_PEERSEC", 10) == 0) { *valp = SO_PEERSEC; return 0; }
+#endif
+#ifdef SO_PASSSEC
+ if (memcmp(str, "SO_PASSSEC", 10) == 0) { *valp = SO_PASSSEC; return 0; }
+#endif
+#ifdef SO_ACCEPTCONN
+ if (memcmp(str, "ACCEPTCONN", 10) == 0) { *valp = SO_ACCEPTCONN; return 0; }
+#endif
+#ifdef SO_GET_FILTER
+ if (memcmp(str, "GET_FILTER", 10) == 0) { *valp = SO_GET_FILTER; return 0; }
+#endif
+#ifdef SO_MAC_EXEMPT
+ if (memcmp(str, "MAC_EXEMPT", 10) == 0) { *valp = SO_MAC_EXEMPT; return 0; }
+#endif
+ return -1;
+
+ case 11:
+#ifdef SO_NO_CHECK
+ if (memcmp(str, "SO_NO_CHECK", 11) == 0) { *valp = SO_NO_CHECK; return 0; }
+#endif
+#ifdef SO_PRIORITY
+ if (memcmp(str, "SO_PRIORITY", 11) == 0) { *valp = SO_PRIORITY; return 0; }
+#endif
+#ifdef SO_PASSCRED
+ if (memcmp(str, "SO_PASSCRED", 11) == 0) { *valp = SO_PASSCRED; return 0; }
+#endif
+#ifdef SO_PEERCRED
+ if (memcmp(str, "SO_PEERCRED", 11) == 0) { *valp = SO_PEERCRED; return 0; }
+#endif
+#ifdef SO_RCVLOWAT
+ if (memcmp(str, "SO_RCVLOWAT", 11) == 0) { *valp = SO_RCVLOWAT; return 0; }
+#endif
+#ifdef SO_SNDLOWAT
+ if (memcmp(str, "SO_SNDLOWAT", 11) == 0) { *valp = SO_SNDLOWAT; return 0; }
+#endif
+#ifdef SO_RCVTIMEO
+ if (memcmp(str, "SO_RCVTIMEO", 11) == 0) { *valp = SO_RCVTIMEO; return 0; }
+#endif
+#ifdef SO_SNDTIMEO
+ if (memcmp(str, "SO_SNDTIMEO", 11) == 0) { *valp = SO_SNDTIMEO; return 0; }
+#endif
+#ifdef SO_WANTMORE
+ if (memcmp(str, "SO_WANTMORE", 11) == 0) { *valp = SO_WANTMORE; return 0; }
+#endif
+#ifdef SO_PEERNAME
+ if (memcmp(str, "SO_PEERNAME", 11) == 0) { *valp = SO_PEERNAME; return 0; }
+#endif
+#ifdef SO_ALLZONES
+ if (memcmp(str, "SO_ALLZONES", 11) == 0) { *valp = SO_ALLZONES; return 0; }
+#endif
+#ifdef SO_PROTOCOL
+ if (memcmp(str, "SO_PROTOCOL", 11) == 0) { *valp = SO_PROTOCOL; return 0; }
+#endif
+#ifdef SO_RXQ_OVFL
+ if (memcmp(str, "SO_RXQ_OVFL", 11) == 0) { *valp = SO_RXQ_OVFL; return 0; }
+#endif
+#ifdef SO_PEEK_OFF
+ if (memcmp(str, "SO_PEEK_OFF", 11) == 0) { *valp = SO_PEEK_OFF; return 0; }
+#endif
+#ifdef SO_SNDBUFFORCE
+ if (memcmp(str, "SNDBUFFORCE", 11) == 0) { *valp = SO_SNDBUFFORCE; return 0; }
+#endif
+#ifdef SO_RCVBUFFORCE
+ if (memcmp(str, "RCVBUFFORCE", 11) == 0) { *valp = SO_RCVBUFFORCE; return 0; }
+#endif
+#ifdef SO_USELOOPBACK
+ if (memcmp(str, "USELOOPBACK", 11) == 0) { *valp = SO_USELOOPBACK; return 0; }
+#endif
+#ifdef SO_WANTOOBFLAG
+ if (memcmp(str, "WANTOOBFLAG", 11) == 0) { *valp = SO_WANTOOBFLAG; return 0; }
+#endif
+#ifdef SO_TIMESTAMPNS
+ if (memcmp(str, "TIMESTAMPNS", 11) == 0) { *valp = SO_TIMESTAMPNS; return 0; }
+#endif
+#ifdef SO_WIFI_STATUS
+ if (memcmp(str, "WIFI_STATUS", 11) == 0) { *valp = SO_WIFI_STATUS; return 0; }
+#endif
+#ifdef SO_LOCK_FILTER
+ if (memcmp(str, "LOCK_FILTER", 11) == 0) { *valp = SO_LOCK_FILTER; return 0; }
+#endif
+ return -1;
+
+ case 12:
+#ifdef SO_REUSEADDR
+ if (memcmp(str, "SO_REUSEADDR", 12) == 0) { *valp = SO_REUSEADDR; return 0; }
+#endif
+#ifdef SO_REUSEPORT
+ if (memcmp(str, "SO_REUSEPORT", 12) == 0) { *valp = SO_REUSEPORT; return 0; }
+#endif
+#ifdef SO_DONTROUTE
+ if (memcmp(str, "SO_DONTROUTE", 12) == 0) { *valp = SO_DONTROUTE; return 0; }
+#endif
+#ifdef SO_BROADCAST
+ if (memcmp(str, "SO_BROADCAST", 12) == 0) { *valp = SO_BROADCAST; return 0; }
+#endif
+#ifdef SO_KEEPALIVE
+ if (memcmp(str, "SO_KEEPALIVE", 12) == 0) { *valp = SO_KEEPALIVE; return 0; }
+#endif
+#ifdef SO_OOBINLINE
+ if (memcmp(str, "SO_OOBINLINE", 12) == 0) { *valp = SO_OOBINLINE; return 0; }
+#endif
+#ifdef SO_DONTTRUNC
+ if (memcmp(str, "SO_DONTTRUNC", 12) == 0) { *valp = SO_DONTTRUNC; return 0; }
+#endif
+#ifdef SO_NOSIGPIPE
+ if (memcmp(str, "SO_NOSIGPIPE", 12) == 0) { *valp = SO_NOSIGPIPE; return 0; }
+#endif
+#ifdef SO_TIMESTAMP
+ if (memcmp(str, "SO_TIMESTAMP", 12) == 0) { *valp = SO_TIMESTAMP; return 0; }
+#endif
+#ifdef SO_RECVUCRED
+ if (memcmp(str, "SO_RECVUCRED", 12) == 0) { *valp = SO_RECVUCRED; return 0; }
+#endif
+#ifdef SO_BUSY_POLL
+ if (memcmp(str, "SO_BUSY_POLL", 12) == 0) { *valp = SO_BUSY_POLL; return 0; }
+#endif
+#ifdef SO_ACCEPTFILTER
+ if (memcmp(str, "ACCEPTFILTER", 12) == 0) { *valp = SO_ACCEPTFILTER; return 0; }
+#endif
+#ifdef SO_BINDTODEVICE
+ if (memcmp(str, "BINDTODEVICE", 12) == 0) { *valp = SO_BINDTODEVICE; return 0; }
+#endif
+#ifdef SO_TIMESTAMPING
+ if (memcmp(str, "TIMESTAMPING", 12) == 0) { *valp = SO_TIMESTAMPING; return 0; }
+#endif
+ return -1;
+
+ case 13:
+#ifdef SO_ACCEPTCONN
+ if (memcmp(str, "SO_ACCEPTCONN", 13) == 0) { *valp = SO_ACCEPTCONN; return 0; }
+#endif
+#ifdef SO_GET_FILTER
+ if (memcmp(str, "SO_GET_FILTER", 13) == 0) { *valp = SO_GET_FILTER; return 0; }
+#endif
+#ifdef SO_MAC_EXEMPT
+ if (memcmp(str, "SO_MAC_EXEMPT", 13) == 0) { *valp = SO_MAC_EXEMPT; return 0; }
+#endif
+#ifdef SO_ATTACH_FILTER
+ if (memcmp(str, "ATTACH_FILTER", 13) == 0) { *valp = SO_ATTACH_FILTER; return 0; }
+#endif
+#ifdef SO_DETACH_FILTER
+ if (memcmp(str, "DETACH_FILTER", 13) == 0) { *valp = SO_DETACH_FILTER; return 0; }
+#endif
+ return -1;
+
+ case 14:
+#ifdef SO_SNDBUFFORCE
+ if (memcmp(str, "SO_SNDBUFFORCE", 14) == 0) { *valp = SO_SNDBUFFORCE; return 0; }
+#endif
+#ifdef SO_RCVBUFFORCE
+ if (memcmp(str, "SO_RCVBUFFORCE", 14) == 0) { *valp = SO_RCVBUFFORCE; return 0; }
+#endif
+#ifdef SO_USELOOPBACK
+ if (memcmp(str, "SO_USELOOPBACK", 14) == 0) { *valp = SO_USELOOPBACK; return 0; }
+#endif
+#ifdef SO_WANTOOBFLAG
+ if (memcmp(str, "SO_WANTOOBFLAG", 14) == 0) { *valp = SO_WANTOOBFLAG; return 0; }
+#endif
+#ifdef SO_TIMESTAMPNS
+ if (memcmp(str, "SO_TIMESTAMPNS", 14) == 0) { *valp = SO_TIMESTAMPNS; return 0; }
+#endif
+#ifdef SO_WIFI_STATUS
+ if (memcmp(str, "SO_WIFI_STATUS", 14) == 0) { *valp = SO_WIFI_STATUS; return 0; }
+#endif
+#ifdef SO_LOCK_FILTER
+ if (memcmp(str, "SO_LOCK_FILTER", 14) == 0) { *valp = SO_LOCK_FILTER; return 0; }
+#endif
+#ifdef SO_BPF_EXTENSIONS
+ if (memcmp(str, "BPF_EXTENSIONS", 14) == 0) { *valp = SO_BPF_EXTENSIONS; return 0; }
+#endif
+ return -1;
+
+ case 15:
+#ifdef SO_ACCEPTFILTER
+ if (memcmp(str, "SO_ACCEPTFILTER", 15) == 0) { *valp = SO_ACCEPTFILTER; return 0; }
+#endif
+#ifdef SO_BINDTODEVICE
+ if (memcmp(str, "SO_BINDTODEVICE", 15) == 0) { *valp = SO_BINDTODEVICE; return 0; }
+#endif
+#ifdef SO_TIMESTAMPING
+ if (memcmp(str, "SO_TIMESTAMPING", 15) == 0) { *valp = SO_TIMESTAMPING; return 0; }
+#endif
+#ifdef SO_MAX_PACING_RATE
+ if (memcmp(str, "MAX_PACING_RATE", 15) == 0) { *valp = SO_MAX_PACING_RATE; return 0; }
+#endif
+ return -1;
+
+ case 16:
+#ifdef SO_ATTACH_FILTER
+ if (memcmp(str, "SO_ATTACH_FILTER", 16) == 0) { *valp = SO_ATTACH_FILTER; return 0; }
+#endif
+#ifdef SO_DETACH_FILTER
+ if (memcmp(str, "SO_DETACH_FILTER", 16) == 0) { *valp = SO_DETACH_FILTER; return 0; }
+#endif
+#ifdef SO_SELECT_ERR_QUEUE
+ if (memcmp(str, "SELECT_ERR_QUEUE", 16) == 0) { *valp = SO_SELECT_ERR_QUEUE; return 0; }
+#endif
+ return -1;
+
+ case 17:
+#ifdef SO_BPF_EXTENSIONS
+ if (memcmp(str, "SO_BPF_EXTENSIONS", 17) == 0) { *valp = SO_BPF_EXTENSIONS; return 0; }
+#endif
+ return -1;
+
+ case 18:
+#ifdef SO_MAX_PACING_RATE
+ if (memcmp(str, "SO_MAX_PACING_RATE", 18) == 0) { *valp = SO_MAX_PACING_RATE; return 0; }
+#endif
+ return -1;
+
+ case 19:
+#ifdef SO_SELECT_ERR_QUEUE
+ if (memcmp(str, "SO_SELECT_ERR_QUEUE", 19) == 0) { *valp = SO_SELECT_ERR_QUEUE; return 0; }
+#endif
+ return -1;
+
+ case 23:
+#ifdef SO_SECURITY_AUTHENTICATION
+ if (memcmp(str, "SECURITY_AUTHENTICATION", 23) == 0) { *valp = SO_SECURITY_AUTHENTICATION; return 0; }
+#endif
+ return -1;
+
+ case 26:
+#ifdef SO_SECURITY_AUTHENTICATION
+ if (memcmp(str, "SO_SECURITY_AUTHENTICATION", 26) == 0) { *valp = SO_SECURITY_AUTHENTICATION; return 0; }
+#endif
+ return -1;
+
+ case 27:
+#ifdef SO_SECURITY_ENCRYPTION_NETWORK
+ if (memcmp(str, "SECURITY_ENCRYPTION_NETWORK", 27) == 0) { *valp = SO_SECURITY_ENCRYPTION_NETWORK; return 0; }
+#endif
+ return -1;
+
+ case 29:
+#ifdef SO_SECURITY_ENCRYPTION_TRANSPORT
+ if (memcmp(str, "SECURITY_ENCRYPTION_TRANSPORT", 29) == 0) { *valp = SO_SECURITY_ENCRYPTION_TRANSPORT; return 0; }
+#endif
+ return -1;
+
+ case 30:
+#ifdef SO_SECURITY_ENCRYPTION_NETWORK
+ if (memcmp(str, "SO_SECURITY_ENCRYPTION_NETWORK", 30) == 0) { *valp = SO_SECURITY_ENCRYPTION_NETWORK; return 0; }
+#endif
+ return -1;
+
+ case 32:
+#ifdef SO_SECURITY_ENCRYPTION_TRANSPORT
+ if (memcmp(str, "SO_SECURITY_ENCRYPTION_TRANSPORT", 32) == 0) { *valp = SO_SECURITY_ENCRYPTION_TRANSPORT; return 0; }
+#endif
+ return -1;
+
+ default:
+ return -1;
+ }
+}
+
+
+int
+rsock_ip_optname_to_int(const char *str, long len, int *valp)
+{
+ switch (len) {
+ case 3:
+#ifdef IP_TOS
+ if (memcmp(str, "TOS", 3) == 0) { *valp = IP_TOS; return 0; }
+#endif
+#ifdef IP_TTL
+ if (memcmp(str, "TTL", 3) == 0) { *valp = IP_TTL; return 0; }
+#endif
+#ifdef IP_MTU
+ if (memcmp(str, "MTU", 3) == 0) { *valp = IP_MTU; return 0; }
+#endif
+ return -1;
+
+ case 6:
+#ifdef IP_TOS
+ if (memcmp(str, "IP_TOS", 6) == 0) { *valp = IP_TOS; return 0; }
+#endif
+#ifdef IP_TTL
+ if (memcmp(str, "IP_TTL", 6) == 0) { *valp = IP_TTL; return 0; }
+#endif
+#ifdef IP_MTU
+ if (memcmp(str, "IP_MTU", 6) == 0) { *valp = IP_MTU; return 0; }
+#endif
+#ifdef IP_MINTTL
+ if (memcmp(str, "MINTTL", 6) == 0) { *valp = IP_MINTTL; return 0; }
+#endif
+#ifdef IP_RECVIF
+ if (memcmp(str, "RECVIF", 6) == 0) { *valp = IP_RECVIF; return 0; }
+#endif
+ return -1;
+
+ case 7:
+#ifdef IP_OPTIONS
+ if (memcmp(str, "OPTIONS", 7) == 0) { *valp = IP_OPTIONS; return 0; }
+#endif
+#ifdef IP_HDRINCL
+ if (memcmp(str, "HDRINCL", 7) == 0) { *valp = IP_HDRINCL; return 0; }
+#endif
+#ifdef IP_RETOPTS
+ if (memcmp(str, "RETOPTS", 7) == 0) { *valp = IP_RETOPTS; return 0; }
+#endif
+#ifdef IP_RECVTTL
+ if (memcmp(str, "RECVTTL", 7) == 0) { *valp = IP_RECVTTL; return 0; }
+#endif
+#ifdef IP_PKTINFO
+ if (memcmp(str, "PKTINFO", 7) == 0) { *valp = IP_PKTINFO; return 0; }
+#endif
+#ifdef IP_RECVERR
+ if (memcmp(str, "RECVERR", 7) == 0) { *valp = IP_RECVERR; return 0; }
+#endif
+#ifdef IP_RECVTOS
+ if (memcmp(str, "RECVTOS", 7) == 0) { *valp = IP_RECVTOS; return 0; }
+#endif
+#ifdef IP_PASSSEC
+ if (memcmp(str, "PASSSEC", 7) == 0) { *valp = IP_PASSSEC; return 0; }
+#endif
+ return -1;
+
+ case 8:
+#ifdef IP_RECVOPTS
+ if (memcmp(str, "RECVOPTS", 8) == 0) { *valp = IP_RECVOPTS; return 0; }
+#endif
+#ifdef IP_DONTFRAG
+ if (memcmp(str, "DONTFRAG", 8) == 0) { *valp = IP_DONTFRAG; return 0; }
+#endif
+#ifdef IP_RECVSLLA
+ if (memcmp(str, "RECVSLLA", 8) == 0) { *valp = IP_RECVSLLA; return 0; }
+#endif
+#ifdef IP_FREEBIND
+ if (memcmp(str, "FREEBIND", 8) == 0) { *valp = IP_FREEBIND; return 0; }
+#endif
+#ifdef IP_MSFILTER
+ if (memcmp(str, "MSFILTER", 8) == 0) { *valp = IP_MSFILTER; return 0; }
+#endif
+ return -1;
+
+ case 9:
+#ifdef IP_MINTTL
+ if (memcmp(str, "IP_MINTTL", 9) == 0) { *valp = IP_MINTTL; return 0; }
+#endif
+#ifdef IP_RECVIF
+ if (memcmp(str, "IP_RECVIF", 9) == 0) { *valp = IP_RECVIF; return 0; }
+#endif
+#ifdef IP_ONESBCAST
+ if (memcmp(str, "ONESBCAST", 9) == 0) { *valp = IP_ONESBCAST; return 0; }
+#endif
+#ifdef IP_PORTRANGE
+ if (memcmp(str, "PORTRANGE", 9) == 0) { *valp = IP_PORTRANGE; return 0; }
+#endif
+ return -1;
+
+ case 10:
+#ifdef IP_OPTIONS
+ if (memcmp(str, "IP_OPTIONS", 10) == 0) { *valp = IP_OPTIONS; return 0; }
+#endif
+#ifdef IP_HDRINCL
+ if (memcmp(str, "IP_HDRINCL", 10) == 0) { *valp = IP_HDRINCL; return 0; }
+#endif
+#ifdef IP_RETOPTS
+ if (memcmp(str, "IP_RETOPTS", 10) == 0) { *valp = IP_RETOPTS; return 0; }
+#endif
+#ifdef IP_RECVTTL
+ if (memcmp(str, "IP_RECVTTL", 10) == 0) { *valp = IP_RECVTTL; return 0; }
+#endif
+#ifdef IP_PKTINFO
+ if (memcmp(str, "IP_PKTINFO", 10) == 0) { *valp = IP_PKTINFO; return 0; }
+#endif
+#ifdef IP_RECVERR
+ if (memcmp(str, "IP_RECVERR", 10) == 0) { *valp = IP_RECVERR; return 0; }
+#endif
+#ifdef IP_RECVTOS
+ if (memcmp(str, "IP_RECVTOS", 10) == 0) { *valp = IP_RECVTOS; return 0; }
+#endif
+#ifdef IP_PASSSEC
+ if (memcmp(str, "IP_PASSSEC", 10) == 0) { *valp = IP_PASSSEC; return 0; }
+#endif
+#ifdef IP_PKTOPTIONS
+ if (memcmp(str, "PKTOPTIONS", 10) == 0) { *valp = IP_PKTOPTIONS; return 0; }
+#endif
+ return -1;
+
+ case 11:
+#ifdef IP_RECVOPTS
+ if (memcmp(str, "IP_RECVOPTS", 11) == 0) { *valp = IP_RECVOPTS; return 0; }
+#endif
+#ifdef IP_DONTFRAG
+ if (memcmp(str, "IP_DONTFRAG", 11) == 0) { *valp = IP_DONTFRAG; return 0; }
+#endif
+#ifdef IP_RECVSLLA
+ if (memcmp(str, "IP_RECVSLLA", 11) == 0) { *valp = IP_RECVSLLA; return 0; }
+#endif
+#ifdef IP_FREEBIND
+ if (memcmp(str, "IP_FREEBIND", 11) == 0) { *valp = IP_FREEBIND; return 0; }
+#endif
+#ifdef IP_MSFILTER
+ if (memcmp(str, "IP_MSFILTER", 11) == 0) { *valp = IP_MSFILTER; return 0; }
+#endif
+#ifdef IP_RECVRETOPTS
+ if (memcmp(str, "RECVRETOPTS", 11) == 0) { *valp = IP_RECVRETOPTS; return 0; }
+#endif
+#ifdef IP_RECVDSTADDR
+ if (memcmp(str, "RECVDSTADDR", 11) == 0) { *valp = IP_RECVDSTADDR; return 0; }
+#endif
+#ifdef IP_SENDSRCADDR
+ if (memcmp(str, "SENDSRCADDR", 11) == 0) { *valp = IP_SENDSRCADDR; return 0; }
+#endif
+#ifdef IP_XFRM_POLICY
+ if (memcmp(str, "XFRM_POLICY", 11) == 0) { *valp = IP_XFRM_POLICY; return 0; }
+#endif
+#ifdef IP_TRANSPARENT
+ if (memcmp(str, "TRANSPARENT", 11) == 0) { *valp = IP_TRANSPARENT; return 0; }
+#endif
+#ifdef IP_PMTUDISC_DO
+ if (memcmp(str, "PMTUDISC_DO", 11) == 0) { *valp = IP_PMTUDISC_DO; return 0; }
+#endif
+ return -1;
+
+ case 12:
+#ifdef IP_ONESBCAST
+ if (memcmp(str, "IP_ONESBCAST", 12) == 0) { *valp = IP_ONESBCAST; return 0; }
+#endif
+#ifdef IP_PORTRANGE
+ if (memcmp(str, "IP_PORTRANGE", 12) == 0) { *valp = IP_PORTRANGE; return 0; }
+#endif
+#ifdef IP_MULTICAST_IF
+ if (memcmp(str, "MULTICAST_IF", 12) == 0) { *valp = IP_MULTICAST_IF; return 0; }
+#endif
+#ifdef IP_ROUTER_ALERT
+ if (memcmp(str, "ROUTER_ALERT", 12) == 0) { *valp = IP_ROUTER_ALERT; return 0; }
+#endif
+#ifdef IP_MTU_DISCOVER
+ if (memcmp(str, "MTU_DISCOVER", 12) == 0) { *valp = IP_MTU_DISCOVER; return 0; }
+#endif
+#ifdef IP_IPSEC_POLICY
+ if (memcmp(str, "IPSEC_POLICY", 12) == 0) { *valp = IP_IPSEC_POLICY; return 0; }
+#endif
+#ifdef IP_BLOCK_SOURCE
+ if (memcmp(str, "BLOCK_SOURCE", 12) == 0) { *valp = IP_BLOCK_SOURCE; return 0; }
+#endif
+ return -1;
+
+ case 13:
+#ifdef IP_PKTOPTIONS
+ if (memcmp(str, "IP_PKTOPTIONS", 13) == 0) { *valp = IP_PKTOPTIONS; return 0; }
+#endif
+#ifdef IP_MULTICAST_TTL
+ if (memcmp(str, "MULTICAST_TTL", 13) == 0) { *valp = IP_MULTICAST_TTL; return 0; }
+#endif
+#ifdef IP_PMTUDISC_DONT
+ if (memcmp(str, "PMTUDISC_DONT", 13) == 0) { *valp = IP_PMTUDISC_DONT; return 0; }
+#endif
+#ifdef IP_PMTUDISC_WANT
+ if (memcmp(str, "PMTUDISC_WANT", 13) == 0) { *valp = IP_PMTUDISC_WANT; return 0; }
+#endif
+ return -1;
+
+ case 14:
+#ifdef IP_RECVRETOPTS
+ if (memcmp(str, "IP_RECVRETOPTS", 14) == 0) { *valp = IP_RECVRETOPTS; return 0; }
+#endif
+#ifdef IP_RECVDSTADDR
+ if (memcmp(str, "IP_RECVDSTADDR", 14) == 0) { *valp = IP_RECVDSTADDR; return 0; }
+#endif
+#ifdef IP_SENDSRCADDR
+ if (memcmp(str, "IP_SENDSRCADDR", 14) == 0) { *valp = IP_SENDSRCADDR; return 0; }
+#endif
+#ifdef IP_XFRM_POLICY
+ if (memcmp(str, "IP_XFRM_POLICY", 14) == 0) { *valp = IP_XFRM_POLICY; return 0; }
+#endif
+#ifdef IP_TRANSPARENT
+ if (memcmp(str, "IP_TRANSPARENT", 14) == 0) { *valp = IP_TRANSPARENT; return 0; }
+#endif
+#ifdef IP_PMTUDISC_DO
+ if (memcmp(str, "IP_PMTUDISC_DO", 14) == 0) { *valp = IP_PMTUDISC_DO; return 0; }
+#endif
+#ifdef IP_MULTICAST_LOOP
+ if (memcmp(str, "MULTICAST_LOOP", 14) == 0) { *valp = IP_MULTICAST_LOOP; return 0; }
+#endif
+#ifdef IP_ADD_MEMBERSHIP
+ if (memcmp(str, "ADD_MEMBERSHIP", 14) == 0) { *valp = IP_ADD_MEMBERSHIP; return 0; }
+#endif
+#ifdef IP_UNBLOCK_SOURCE
+ if (memcmp(str, "UNBLOCK_SOURCE", 14) == 0) { *valp = IP_UNBLOCK_SOURCE; return 0; }
+#endif
+ return -1;
+
+ case 15:
+#ifdef IP_MULTICAST_IF
+ if (memcmp(str, "IP_MULTICAST_IF", 15) == 0) { *valp = IP_MULTICAST_IF; return 0; }
+#endif
+#ifdef IP_ROUTER_ALERT
+ if (memcmp(str, "IP_ROUTER_ALERT", 15) == 0) { *valp = IP_ROUTER_ALERT; return 0; }
+#endif
+#ifdef IP_MTU_DISCOVER
+ if (memcmp(str, "IP_MTU_DISCOVER", 15) == 0) { *valp = IP_MTU_DISCOVER; return 0; }
+#endif
+#ifdef IP_IPSEC_POLICY
+ if (memcmp(str, "IP_IPSEC_POLICY", 15) == 0) { *valp = IP_IPSEC_POLICY; return 0; }
+#endif
+#ifdef IP_BLOCK_SOURCE
+ if (memcmp(str, "IP_BLOCK_SOURCE", 15) == 0) { *valp = IP_BLOCK_SOURCE; return 0; }
+#endif
+#ifdef IP_DROP_MEMBERSHIP
+ if (memcmp(str, "DROP_MEMBERSHIP", 15) == 0) { *valp = IP_DROP_MEMBERSHIP; return 0; }
+#endif
+#ifdef IP_MAX_MEMBERSHIPS
+ if (memcmp(str, "MAX_MEMBERSHIPS", 15) == 0) { *valp = IP_MAX_MEMBERSHIPS; return 0; }
+#endif
+ return -1;
+
+ case 16:
+#ifdef IP_MULTICAST_TTL
+ if (memcmp(str, "IP_MULTICAST_TTL", 16) == 0) { *valp = IP_MULTICAST_TTL; return 0; }
+#endif
+#ifdef IP_PMTUDISC_DONT
+ if (memcmp(str, "IP_PMTUDISC_DONT", 16) == 0) { *valp = IP_PMTUDISC_DONT; return 0; }
+#endif
+#ifdef IP_PMTUDISC_WANT
+ if (memcmp(str, "IP_PMTUDISC_WANT", 16) == 0) { *valp = IP_PMTUDISC_WANT; return 0; }
+#endif
+ return -1;
+
+ case 17:
+#ifdef IP_MULTICAST_LOOP
+ if (memcmp(str, "IP_MULTICAST_LOOP", 17) == 0) { *valp = IP_MULTICAST_LOOP; return 0; }
+#endif
+#ifdef IP_ADD_MEMBERSHIP
+ if (memcmp(str, "IP_ADD_MEMBERSHIP", 17) == 0) { *valp = IP_ADD_MEMBERSHIP; return 0; }
+#endif
+#ifdef IP_UNBLOCK_SOURCE
+ if (memcmp(str, "IP_UNBLOCK_SOURCE", 17) == 0) { *valp = IP_UNBLOCK_SOURCE; return 0; }
+#endif
+ return -1;
+
+ case 18:
+#ifdef IP_DROP_MEMBERSHIP
+ if (memcmp(str, "IP_DROP_MEMBERSHIP", 18) == 0) { *valp = IP_DROP_MEMBERSHIP; return 0; }
+#endif
+#ifdef IP_MAX_MEMBERSHIPS
+ if (memcmp(str, "IP_MAX_MEMBERSHIPS", 18) == 0) { *valp = IP_MAX_MEMBERSHIPS; return 0; }
+#endif
+ return -1;
+
+ case 21:
+#ifdef IP_DEFAULT_MULTICAST_TTL
+ if (memcmp(str, "DEFAULT_MULTICAST_TTL", 21) == 0) { *valp = IP_DEFAULT_MULTICAST_TTL; return 0; }
+#endif
+#ifdef IP_ADD_SOURCE_MEMBERSHIP
+ if (memcmp(str, "ADD_SOURCE_MEMBERSHIP", 21) == 0) { *valp = IP_ADD_SOURCE_MEMBERSHIP; return 0; }
+#endif
+ return -1;
+
+ case 22:
+#ifdef IP_DEFAULT_MULTICAST_LOOP
+ if (memcmp(str, "DEFAULT_MULTICAST_LOOP", 22) == 0) { *valp = IP_DEFAULT_MULTICAST_LOOP; return 0; }
+#endif
+#ifdef IP_DROP_SOURCE_MEMBERSHIP
+ if (memcmp(str, "DROP_SOURCE_MEMBERSHIP", 22) == 0) { *valp = IP_DROP_SOURCE_MEMBERSHIP; return 0; }
+#endif
+ return -1;
+
+ case 24:
+#ifdef IP_DEFAULT_MULTICAST_TTL
+ if (memcmp(str, "IP_DEFAULT_MULTICAST_TTL", 24) == 0) { *valp = IP_DEFAULT_MULTICAST_TTL; return 0; }
+#endif
+#ifdef IP_ADD_SOURCE_MEMBERSHIP
+ if (memcmp(str, "IP_ADD_SOURCE_MEMBERSHIP", 24) == 0) { *valp = IP_ADD_SOURCE_MEMBERSHIP; return 0; }
+#endif
+ return -1;
+
+ case 25:
+#ifdef IP_DEFAULT_MULTICAST_LOOP
+ if (memcmp(str, "IP_DEFAULT_MULTICAST_LOOP", 25) == 0) { *valp = IP_DEFAULT_MULTICAST_LOOP; return 0; }
+#endif
+#ifdef IP_DROP_SOURCE_MEMBERSHIP
+ if (memcmp(str, "IP_DROP_SOURCE_MEMBERSHIP", 25) == 0) { *valp = IP_DROP_SOURCE_MEMBERSHIP; return 0; }
+#endif
+ return -1;
+
+ default:
+ return -1;
+ }
+}
+
+
+#ifdef IPPROTO_IPV6
+int
+rsock_ipv6_optname_to_int(const char *str, long len, int *valp)
+{
+ switch (len) {
+ case 5:
+#ifdef IPV6_RTHDR
+ if (memcmp(str, "RTHDR", 5) == 0) { *valp = IPV6_RTHDR; return 0; }
+#endif
+ return -1;
+
+ case 6:
+#ifdef IPV6_V6ONLY
+ if (memcmp(str, "V6ONLY", 6) == 0) { *valp = IPV6_V6ONLY; return 0; }
+#endif
+#ifdef IPV6_TCLASS
+ if (memcmp(str, "TCLASS", 6) == 0) { *valp = IPV6_TCLASS; return 0; }
+#endif
+ return -1;
+
+ case 7:
+#ifdef IPV6_DSTOPTS
+ if (memcmp(str, "DSTOPTS", 7) == 0) { *valp = IPV6_DSTOPTS; return 0; }
+#endif
+#ifdef IPV6_HOPOPTS
+ if (memcmp(str, "HOPOPTS", 7) == 0) { *valp = IPV6_HOPOPTS; return 0; }
+#endif
+#ifdef IPV6_NEXTHOP
+ if (memcmp(str, "NEXTHOP", 7) == 0) { *valp = IPV6_NEXTHOP; return 0; }
+#endif
+#ifdef IPV6_PATHMTU
+ if (memcmp(str, "PATHMTU", 7) == 0) { *valp = IPV6_PATHMTU; return 0; }
+#endif
+#ifdef IPV6_PKTINFO
+ if (memcmp(str, "PKTINFO", 7) == 0) { *valp = IPV6_PKTINFO; return 0; }
+#endif
+ return -1;
+
+ case 8:
+#ifdef IPV6_CHECKSUM
+ if (memcmp(str, "CHECKSUM", 8) == 0) { *valp = IPV6_CHECKSUM; return 0; }
+#endif
+#ifdef IPV6_DONTFRAG
+ if (memcmp(str, "DONTFRAG", 8) == 0) { *valp = IPV6_DONTFRAG; return 0; }
+#endif
+#ifdef IPV6_HOPLIMIT
+ if (memcmp(str, "HOPLIMIT", 8) == 0) { *valp = IPV6_HOPLIMIT; return 0; }
+#endif
+ return -1;
+
+ case 9:
+#ifdef IPV6_RECVRTHDR
+ if (memcmp(str, "RECVRTHDR", 9) == 0) { *valp = IPV6_RECVRTHDR; return 0; }
+#endif
+ return -1;
+
+ case 10:
+#ifdef IPV6_RTHDR
+ if (memcmp(str, "IPV6_RTHDR", 10) == 0) { *valp = IPV6_RTHDR; return 0; }
+#endif
+#ifdef IPV6_JOIN_GROUP
+ if (memcmp(str, "JOIN_GROUP", 10) == 0) { *valp = IPV6_JOIN_GROUP; return 0; }
+#endif
+#ifdef IPV6_RECVTCLASS
+ if (memcmp(str, "RECVTCLASS", 10) == 0) { *valp = IPV6_RECVTCLASS; return 0; }
+#endif
+ return -1;
+
+ case 11:
+#ifdef IPV6_V6ONLY
+ if (memcmp(str, "IPV6_V6ONLY", 11) == 0) { *valp = IPV6_V6ONLY; return 0; }
+#endif
+#ifdef IPV6_TCLASS
+ if (memcmp(str, "IPV6_TCLASS", 11) == 0) { *valp = IPV6_TCLASS; return 0; }
+#endif
+#ifdef IPV6_LEAVE_GROUP
+ if (memcmp(str, "LEAVE_GROUP", 11) == 0) { *valp = IPV6_LEAVE_GROUP; return 0; }
+#endif
+#ifdef IPV6_RECVDSTOPTS
+ if (memcmp(str, "RECVDSTOPTS", 11) == 0) { *valp = IPV6_RECVDSTOPTS; return 0; }
+#endif
+#ifdef IPV6_RECVHOPOPTS
+ if (memcmp(str, "RECVHOPOPTS", 11) == 0) { *valp = IPV6_RECVHOPOPTS; return 0; }
+#endif
+#ifdef IPV6_RECVPKTINFO
+ if (memcmp(str, "RECVPKTINFO", 11) == 0) { *valp = IPV6_RECVPKTINFO; return 0; }
+#endif
+#ifdef IPV6_RECVPATHMTU
+ if (memcmp(str, "RECVPATHMTU", 11) == 0) { *valp = IPV6_RECVPATHMTU; return 0; }
+#endif
+#ifdef IPV6_USE_MIN_MTU
+ if (memcmp(str, "USE_MIN_MTU", 11) == 0) { *valp = IPV6_USE_MIN_MTU; return 0; }
+#endif
+ return -1;
+
+ case 12:
+#ifdef IPV6_DSTOPTS
+ if (memcmp(str, "IPV6_DSTOPTS", 12) == 0) { *valp = IPV6_DSTOPTS; return 0; }
+#endif
+#ifdef IPV6_HOPOPTS
+ if (memcmp(str, "IPV6_HOPOPTS", 12) == 0) { *valp = IPV6_HOPOPTS; return 0; }
+#endif
+#ifdef IPV6_NEXTHOP
+ if (memcmp(str, "IPV6_NEXTHOP", 12) == 0) { *valp = IPV6_NEXTHOP; return 0; }
+#endif
+#ifdef IPV6_PATHMTU
+ if (memcmp(str, "IPV6_PATHMTU", 12) == 0) { *valp = IPV6_PATHMTU; return 0; }
+#endif
+#ifdef IPV6_PKTINFO
+ if (memcmp(str, "IPV6_PKTINFO", 12) == 0) { *valp = IPV6_PKTINFO; return 0; }
+#endif
+#ifdef IPV6_MULTICAST_IF
+ if (memcmp(str, "MULTICAST_IF", 12) == 0) { *valp = IPV6_MULTICAST_IF; return 0; }
+#endif
+#ifdef IPV6_UNICAST_HOPS
+ if (memcmp(str, "UNICAST_HOPS", 12) == 0) { *valp = IPV6_UNICAST_HOPS; return 0; }
+#endif
+#ifdef IPV6_RECVHOPLIMIT
+ if (memcmp(str, "RECVHOPLIMIT", 12) == 0) { *valp = IPV6_RECVHOPLIMIT; return 0; }
+#endif
+#ifdef IPV6_RTHDRDSTOPTS
+ if (memcmp(str, "RTHDRDSTOPTS", 12) == 0) { *valp = IPV6_RTHDRDSTOPTS; return 0; }
+#endif
+#ifdef IPV6_RTHDR_TYPE_0
+ if (memcmp(str, "RTHDR_TYPE_0", 12) == 0) { *valp = IPV6_RTHDR_TYPE_0; return 0; }
+#endif
+ return -1;
+
+ case 13:
+#ifdef IPV6_CHECKSUM
+ if (memcmp(str, "IPV6_CHECKSUM", 13) == 0) { *valp = IPV6_CHECKSUM; return 0; }
+#endif
+#ifdef IPV6_DONTFRAG
+ if (memcmp(str, "IPV6_DONTFRAG", 13) == 0) { *valp = IPV6_DONTFRAG; return 0; }
+#endif
+#ifdef IPV6_HOPLIMIT
+ if (memcmp(str, "IPV6_HOPLIMIT", 13) == 0) { *valp = IPV6_HOPLIMIT; return 0; }
+#endif
+ return -1;
+
+ case 14:
+#ifdef IPV6_RECVRTHDR
+ if (memcmp(str, "IPV6_RECVRTHDR", 14) == 0) { *valp = IPV6_RECVRTHDR; return 0; }
+#endif
+#ifdef IPV6_MULTICAST_HOPS
+ if (memcmp(str, "MULTICAST_HOPS", 14) == 0) { *valp = IPV6_MULTICAST_HOPS; return 0; }
+#endif
+#ifdef IPV6_MULTICAST_LOOP
+ if (memcmp(str, "MULTICAST_LOOP", 14) == 0) { *valp = IPV6_MULTICAST_LOOP; return 0; }
+#endif
+ return -1;
+
+ case 15:
+#ifdef IPV6_JOIN_GROUP
+ if (memcmp(str, "IPV6_JOIN_GROUP", 15) == 0) { *valp = IPV6_JOIN_GROUP; return 0; }
+#endif
+#ifdef IPV6_RECVTCLASS
+ if (memcmp(str, "IPV6_RECVTCLASS", 15) == 0) { *valp = IPV6_RECVTCLASS; return 0; }
+#endif
+ return -1;
+
+ case 16:
+#ifdef IPV6_LEAVE_GROUP
+ if (memcmp(str, "IPV6_LEAVE_GROUP", 16) == 0) { *valp = IPV6_LEAVE_GROUP; return 0; }
+#endif
+#ifdef IPV6_RECVDSTOPTS
+ if (memcmp(str, "IPV6_RECVDSTOPTS", 16) == 0) { *valp = IPV6_RECVDSTOPTS; return 0; }
+#endif
+#ifdef IPV6_RECVHOPOPTS
+ if (memcmp(str, "IPV6_RECVHOPOPTS", 16) == 0) { *valp = IPV6_RECVHOPOPTS; return 0; }
+#endif
+#ifdef IPV6_RECVPKTINFO
+ if (memcmp(str, "IPV6_RECVPKTINFO", 16) == 0) { *valp = IPV6_RECVPKTINFO; return 0; }
+#endif
+#ifdef IPV6_RECVPATHMTU
+ if (memcmp(str, "IPV6_RECVPATHMTU", 16) == 0) { *valp = IPV6_RECVPATHMTU; return 0; }
+#endif
+#ifdef IPV6_USE_MIN_MTU
+ if (memcmp(str, "IPV6_USE_MIN_MTU", 16) == 0) { *valp = IPV6_USE_MIN_MTU; return 0; }
+#endif
+ return -1;
+
+ case 17:
+#ifdef IPV6_MULTICAST_IF
+ if (memcmp(str, "IPV6_MULTICAST_IF", 17) == 0) { *valp = IPV6_MULTICAST_IF; return 0; }
+#endif
+#ifdef IPV6_UNICAST_HOPS
+ if (memcmp(str, "IPV6_UNICAST_HOPS", 17) == 0) { *valp = IPV6_UNICAST_HOPS; return 0; }
+#endif
+#ifdef IPV6_RECVHOPLIMIT
+ if (memcmp(str, "IPV6_RECVHOPLIMIT", 17) == 0) { *valp = IPV6_RECVHOPLIMIT; return 0; }
+#endif
+#ifdef IPV6_RTHDRDSTOPTS
+ if (memcmp(str, "IPV6_RTHDRDSTOPTS", 17) == 0) { *valp = IPV6_RTHDRDSTOPTS; return 0; }
+#endif
+#ifdef IPV6_RTHDR_TYPE_0
+ if (memcmp(str, "IPV6_RTHDR_TYPE_0", 17) == 0) { *valp = IPV6_RTHDR_TYPE_0; return 0; }
+#endif
+ return -1;
+
+ case 19:
+#ifdef IPV6_MULTICAST_HOPS
+ if (memcmp(str, "IPV6_MULTICAST_HOPS", 19) == 0) { *valp = IPV6_MULTICAST_HOPS; return 0; }
+#endif
+#ifdef IPV6_MULTICAST_LOOP
+ if (memcmp(str, "IPV6_MULTICAST_LOOP", 19) == 0) { *valp = IPV6_MULTICAST_LOOP; return 0; }
+#endif
+ return -1;
+
+ default:
+ return -1;
+ }
+}
+
+#endif
+
+int
+rsock_tcp_optname_to_int(const char *str, long len, int *valp)
+{
+ switch (len) {
+ case 4:
+#ifdef TCP_CORK
+ if (memcmp(str, "CORK", 4) == 0) { *valp = TCP_CORK; return 0; }
+#endif
+#ifdef TCP_INFO
+ if (memcmp(str, "INFO", 4) == 0) { *valp = TCP_INFO; return 0; }
+#endif
+ return -1;
+
+ case 5:
+#ifdef TCP_NOOPT
+ if (memcmp(str, "NOOPT", 5) == 0) { *valp = TCP_NOOPT; return 0; }
+#endif
+ return -1;
+
+ case 6:
+#ifdef TCP_MAXSEG
+ if (memcmp(str, "MAXSEG", 6) == 0) { *valp = TCP_MAXSEG; return 0; }
+#endif
+#ifdef TCP_MD5SIG
+ if (memcmp(str, "MD5SIG", 6) == 0) { *valp = TCP_MD5SIG; return 0; }
+#endif
+#ifdef TCP_NOPUSH
+ if (memcmp(str, "NOPUSH", 6) == 0) { *valp = TCP_NOPUSH; return 0; }
+#endif
+#ifdef TCP_SYNCNT
+ if (memcmp(str, "SYNCNT", 6) == 0) { *valp = TCP_SYNCNT; return 0; }
+#endif
+#ifdef TCP_REPAIR
+ if (memcmp(str, "REPAIR", 6) == 0) { *valp = TCP_REPAIR; return 0; }
+#endif
+ return -1;
+
+ case 7:
+#ifdef TCP_NODELAY
+ if (memcmp(str, "NODELAY", 7) == 0) { *valp = TCP_NODELAY; return 0; }
+#endif
+#ifdef TCP_KEEPCNT
+ if (memcmp(str, "KEEPCNT", 7) == 0) { *valp = TCP_KEEPCNT; return 0; }
+#endif
+#ifdef TCP_LINGER2
+ if (memcmp(str, "LINGER2", 7) == 0) { *valp = TCP_LINGER2; return 0; }
+#endif
+ return -1;
+
+ case 8:
+#ifdef TCP_CORK
+ if (memcmp(str, "TCP_CORK", 8) == 0) { *valp = TCP_CORK; return 0; }
+#endif
+#ifdef TCP_INFO
+ if (memcmp(str, "TCP_INFO", 8) == 0) { *valp = TCP_INFO; return 0; }
+#endif
+#ifdef TCP_KEEPIDLE
+ if (memcmp(str, "KEEPIDLE", 8) == 0) { *valp = TCP_KEEPIDLE; return 0; }
+#endif
+#ifdef TCP_QUICKACK
+ if (memcmp(str, "QUICKACK", 8) == 0) { *valp = TCP_QUICKACK; return 0; }
+#endif
+#ifdef TCP_FASTOPEN
+ if (memcmp(str, "FASTOPEN", 8) == 0) { *valp = TCP_FASTOPEN; return 0; }
+#endif
+ return -1;
+
+ case 9:
+#ifdef TCP_NOOPT
+ if (memcmp(str, "TCP_NOOPT", 9) == 0) { *valp = TCP_NOOPT; return 0; }
+#endif
+#ifdef TCP_KEEPINTVL
+ if (memcmp(str, "KEEPINTVL", 9) == 0) { *valp = TCP_KEEPINTVL; return 0; }
+#endif
+#ifdef TCP_QUEUE_SEQ
+ if (memcmp(str, "QUEUE_SEQ", 9) == 0) { *valp = TCP_QUEUE_SEQ; return 0; }
+#endif
+#ifdef TCP_TIMESTAMP
+ if (memcmp(str, "TIMESTAMP", 9) == 0) { *valp = TCP_TIMESTAMP; return 0; }
+#endif
+ return -1;
+
+ case 10:
+#ifdef TCP_MAXSEG
+ if (memcmp(str, "TCP_MAXSEG", 10) == 0) { *valp = TCP_MAXSEG; return 0; }
+#endif
+#ifdef TCP_MD5SIG
+ if (memcmp(str, "TCP_MD5SIG", 10) == 0) { *valp = TCP_MD5SIG; return 0; }
+#endif
+#ifdef TCP_NOPUSH
+ if (memcmp(str, "TCP_NOPUSH", 10) == 0) { *valp = TCP_NOPUSH; return 0; }
+#endif
+#ifdef TCP_SYNCNT
+ if (memcmp(str, "TCP_SYNCNT", 10) == 0) { *valp = TCP_SYNCNT; return 0; }
+#endif
+#ifdef TCP_REPAIR
+ if (memcmp(str, "TCP_REPAIR", 10) == 0) { *valp = TCP_REPAIR; return 0; }
+#endif
+#ifdef TCP_CONGESTION
+ if (memcmp(str, "CONGESTION", 10) == 0) { *valp = TCP_CONGESTION; return 0; }
+#endif
+ return -1;
+
+ case 11:
+#ifdef TCP_NODELAY
+ if (memcmp(str, "TCP_NODELAY", 11) == 0) { *valp = TCP_NODELAY; return 0; }
+#endif
+#ifdef TCP_KEEPCNT
+ if (memcmp(str, "TCP_KEEPCNT", 11) == 0) { *valp = TCP_KEEPCNT; return 0; }
+#endif
+#ifdef TCP_LINGER2
+ if (memcmp(str, "TCP_LINGER2", 11) == 0) { *valp = TCP_LINGER2; return 0; }
+#endif
+#ifdef TCP_THIN_DUPACK
+ if (memcmp(str, "THIN_DUPACK", 11) == 0) { *valp = TCP_THIN_DUPACK; return 0; }
+#endif
+ return -1;
+
+ case 12:
+#ifdef TCP_KEEPIDLE
+ if (memcmp(str, "TCP_KEEPIDLE", 12) == 0) { *valp = TCP_KEEPIDLE; return 0; }
+#endif
+#ifdef TCP_QUICKACK
+ if (memcmp(str, "TCP_QUICKACK", 12) == 0) { *valp = TCP_QUICKACK; return 0; }
+#endif
+#ifdef TCP_FASTOPEN
+ if (memcmp(str, "TCP_FASTOPEN", 12) == 0) { *valp = TCP_FASTOPEN; return 0; }
+#endif
+#ifdef TCP_DEFER_ACCEPT
+ if (memcmp(str, "DEFER_ACCEPT", 12) == 0) { *valp = TCP_DEFER_ACCEPT; return 0; }
+#endif
+#ifdef TCP_WINDOW_CLAMP
+ if (memcmp(str, "WINDOW_CLAMP", 12) == 0) { *valp = TCP_WINDOW_CLAMP; return 0; }
+#endif
+#ifdef TCP_REPAIR_QUEUE
+ if (memcmp(str, "REPAIR_QUEUE", 12) == 0) { *valp = TCP_REPAIR_QUEUE; return 0; }
+#endif
+#ifdef TCP_USER_TIMEOUT
+ if (memcmp(str, "USER_TIMEOUT", 12) == 0) { *valp = TCP_USER_TIMEOUT; return 0; }
+#endif
+ return -1;
+
+ case 13:
+#ifdef TCP_KEEPINTVL
+ if (memcmp(str, "TCP_KEEPINTVL", 13) == 0) { *valp = TCP_KEEPINTVL; return 0; }
+#endif
+#ifdef TCP_QUEUE_SEQ
+ if (memcmp(str, "TCP_QUEUE_SEQ", 13) == 0) { *valp = TCP_QUEUE_SEQ; return 0; }
+#endif
+#ifdef TCP_TIMESTAMP
+ if (memcmp(str, "TCP_TIMESTAMP", 13) == 0) { *valp = TCP_TIMESTAMP; return 0; }
+#endif
+ return -1;
+
+ case 14:
+#ifdef TCP_CONGESTION
+ if (memcmp(str, "TCP_CONGESTION", 14) == 0) { *valp = TCP_CONGESTION; return 0; }
+#endif
+#ifdef TCP_REPAIR_OPTIONS
+ if (memcmp(str, "REPAIR_OPTIONS", 14) == 0) { *valp = TCP_REPAIR_OPTIONS; return 0; }
+#endif
+ return -1;
+
+ case 15:
+#ifdef TCP_THIN_DUPACK
+ if (memcmp(str, "TCP_THIN_DUPACK", 15) == 0) { *valp = TCP_THIN_DUPACK; return 0; }
+#endif
+ return -1;
+
+ case 16:
+#ifdef TCP_DEFER_ACCEPT
+ if (memcmp(str, "TCP_DEFER_ACCEPT", 16) == 0) { *valp = TCP_DEFER_ACCEPT; return 0; }
+#endif
+#ifdef TCP_WINDOW_CLAMP
+ if (memcmp(str, "TCP_WINDOW_CLAMP", 16) == 0) { *valp = TCP_WINDOW_CLAMP; return 0; }
+#endif
+#ifdef TCP_REPAIR_QUEUE
+ if (memcmp(str, "TCP_REPAIR_QUEUE", 16) == 0) { *valp = TCP_REPAIR_QUEUE; return 0; }
+#endif
+#ifdef TCP_USER_TIMEOUT
+ if (memcmp(str, "TCP_USER_TIMEOUT", 16) == 0) { *valp = TCP_USER_TIMEOUT; return 0; }
+#endif
+ return -1;
+
+ case 18:
+#ifdef TCP_REPAIR_OPTIONS
+ if (memcmp(str, "TCP_REPAIR_OPTIONS", 18) == 0) { *valp = TCP_REPAIR_OPTIONS; return 0; }
+#endif
+ return -1;
+
+ case 19:
+#ifdef TCP_COOKIE_TRANSACTIONS
+ if (memcmp(str, "COOKIE_TRANSACTIONS", 19) == 0) { *valp = TCP_COOKIE_TRANSACTIONS; return 0; }
+#endif
+ return -1;
+
+ case 20:
+#ifdef TCP_THIN_LINEAR_TIMEOUTS
+ if (memcmp(str, "THIN_LINEAR_TIMEOUTS", 20) == 0) { *valp = TCP_THIN_LINEAR_TIMEOUTS; return 0; }
+#endif
+ return -1;
+
+ case 23:
+#ifdef TCP_COOKIE_TRANSACTIONS
+ if (memcmp(str, "TCP_COOKIE_TRANSACTIONS", 23) == 0) { *valp = TCP_COOKIE_TRANSACTIONS; return 0; }
+#endif
+ return -1;
+
+ case 24:
+#ifdef TCP_THIN_LINEAR_TIMEOUTS
+ if (memcmp(str, "TCP_THIN_LINEAR_TIMEOUTS", 24) == 0) { *valp = TCP_THIN_LINEAR_TIMEOUTS; return 0; }
+#endif
+ return -1;
+
+ default:
+ return -1;
+ }
+}
+
+
+int
+rsock_udp_optname_to_int(const char *str, long len, int *valp)
+{
+ switch (len) {
+ case 4:
+#ifdef UDP_CORK
+ if (memcmp(str, "CORK", 4) == 0) { *valp = UDP_CORK; return 0; }
+#endif
+ return -1;
+
+ case 8:
+#ifdef UDP_CORK
+ if (memcmp(str, "UDP_CORK", 8) == 0) { *valp = UDP_CORK; return 0; }
+#endif
+ return -1;
+
+ default:
+ return -1;
+ }
+}
+
+
+int
+rsock_shutdown_how_to_int(const char *str, long len, int *valp)
+{
+ switch (len) {
+ case 2:
+#ifdef SHUT_RD
+ if (memcmp(str, "RD", 2) == 0) { *valp = SHUT_RD; return 0; }
+#endif
+#ifdef SHUT_WR
+ if (memcmp(str, "WR", 2) == 0) { *valp = SHUT_WR; return 0; }
+#endif
+ return -1;
+
+ case 4:
+#ifdef SHUT_RDWR
+ if (memcmp(str, "RDWR", 4) == 0) { *valp = SHUT_RDWR; return 0; }
+#endif
+ return -1;
+
+ case 7:
+#ifdef SHUT_RD
+ if (memcmp(str, "SHUT_RD", 7) == 0) { *valp = SHUT_RD; return 0; }
+#endif
+#ifdef SHUT_WR
+ if (memcmp(str, "SHUT_WR", 7) == 0) { *valp = SHUT_WR; return 0; }
+#endif
+ return -1;
+
+ case 9:
+#ifdef SHUT_RDWR
+ if (memcmp(str, "SHUT_RDWR", 9) == 0) { *valp = SHUT_RDWR; return 0; }
+#endif
+ return -1;
+
+ default:
+ return -1;
+ }
+}
+
+
+int
+rsock_scm_optname_to_int(const char *str, long len, int *valp)
+{
+ switch (len) {
+ case 5:
+#ifdef SCM_CREDS
+ if (memcmp(str, "CREDS", 5) == 0) { *valp = SCM_CREDS; return 0; }
+#endif
+#ifdef SCM_UCRED
+ if (memcmp(str, "UCRED", 5) == 0) { *valp = SCM_UCRED; return 0; }
+#endif
+ return -1;
+
+ case 6:
+#ifdef SCM_RIGHTS
+ if (memcmp(str, "RIGHTS", 6) == 0) { *valp = SCM_RIGHTS; return 0; }
+#endif
+ return -1;
+
+ case 7:
+#ifdef SCM_BINTIME
+ if (memcmp(str, "BINTIME", 7) == 0) { *valp = SCM_BINTIME; return 0; }
+#endif
+ return -1;
+
+ case 9:
+#ifdef SCM_CREDS
+ if (memcmp(str, "SCM_CREDS", 9) == 0) { *valp = SCM_CREDS; return 0; }
+#endif
+#ifdef SCM_UCRED
+ if (memcmp(str, "SCM_UCRED", 9) == 0) { *valp = SCM_UCRED; return 0; }
+#endif
+#ifdef SCM_TIMESTAMP
+ if (memcmp(str, "TIMESTAMP", 9) == 0) { *valp = SCM_TIMESTAMP; return 0; }
+#endif
+ return -1;
+
+ case 10:
+#ifdef SCM_RIGHTS
+ if (memcmp(str, "SCM_RIGHTS", 10) == 0) { *valp = SCM_RIGHTS; return 0; }
+#endif
+ return -1;
+
+ case 11:
+#ifdef SCM_BINTIME
+ if (memcmp(str, "SCM_BINTIME", 11) == 0) { *valp = SCM_BINTIME; return 0; }
+#endif
+#ifdef SCM_TIMESTAMPNS
+ if (memcmp(str, "TIMESTAMPNS", 11) == 0) { *valp = SCM_TIMESTAMPNS; return 0; }
+#endif
+#ifdef SCM_CREDENTIALS
+ if (memcmp(str, "CREDENTIALS", 11) == 0) { *valp = SCM_CREDENTIALS; return 0; }
+#endif
+#ifdef SCM_WIFI_STATUS
+ if (memcmp(str, "WIFI_STATUS", 11) == 0) { *valp = SCM_WIFI_STATUS; return 0; }
+#endif
+ return -1;
+
+ case 12:
+#ifdef SCM_TIMESTAMPING
+ if (memcmp(str, "TIMESTAMPING", 12) == 0) { *valp = SCM_TIMESTAMPING; return 0; }
+#endif
+ return -1;
+
+ case 13:
+#ifdef SCM_TIMESTAMP
+ if (memcmp(str, "SCM_TIMESTAMP", 13) == 0) { *valp = SCM_TIMESTAMP; return 0; }
+#endif
+ return -1;
+
+ case 15:
+#ifdef SCM_TIMESTAMPNS
+ if (memcmp(str, "SCM_TIMESTAMPNS", 15) == 0) { *valp = SCM_TIMESTAMPNS; return 0; }
+#endif
+#ifdef SCM_CREDENTIALS
+ if (memcmp(str, "SCM_CREDENTIALS", 15) == 0) { *valp = SCM_CREDENTIALS; return 0; }
+#endif
+#ifdef SCM_WIFI_STATUS
+ if (memcmp(str, "SCM_WIFI_STATUS", 15) == 0) { *valp = SCM_WIFI_STATUS; return 0; }
+#endif
+ return -1;
+
+ case 16:
+#ifdef SCM_TIMESTAMPING
+ if (memcmp(str, "SCM_TIMESTAMPING", 16) == 0) { *valp = SCM_TIMESTAMPING; return 0; }
+#endif
+ return -1;
+
+ default:
+ return -1;
+ }
+}
+
+
+
+ID
+rsock_intern_family(int val)
+{
+ st_data_t name;
+ if (st_lookup(rsock_intern_family_hash, (st_data_t)val, &name))
+ return (ID)name;
+ return 0;
+}
+
+ID
+rsock_intern_family_noprefix(int val)
+{
+ st_data_t name;
+ if (st_lookup(rsock_intern_family_noprefix_hash, (st_data_t)val, &name))
+ return (ID)name;
+ return 0;
+}
+
+ID
+rsock_intern_protocol_family(int val)
+{
+ st_data_t name;
+ if (st_lookup(rsock_intern_protocol_family_hash, (st_data_t)val, &name))
+ return (ID)name;
+ return 0;
+}
+
+ID
+rsock_intern_socktype(int val)
+{
+ st_data_t name;
+ if (st_lookup(rsock_intern_socktype_hash, (st_data_t)val, &name))
+ return (ID)name;
+ return 0;
+}
+
+ID
+rsock_intern_ipproto(int val)
+{
+ st_data_t name;
+ if (st_lookup(rsock_intern_ipproto_hash, (st_data_t)val, &name))
+ return (ID)name;
+ return 0;
+}
+
+ID
+rsock_intern_iplevel(int val)
+{
+ st_data_t name;
+ if (st_lookup(rsock_intern_iplevel_hash, (st_data_t)val, &name))
+ return (ID)name;
+ return 0;
+}
+
+ID
+rsock_intern_so_optname(int val)
+{
+ st_data_t name;
+ if (st_lookup(rsock_intern_so_optname_hash, (st_data_t)val, &name))
+ return (ID)name;
+ return 0;
+}
+
+ID
+rsock_intern_ip_optname(int val)
+{
+ st_data_t name;
+ if (st_lookup(rsock_intern_ip_optname_hash, (st_data_t)val, &name))
+ return (ID)name;
+ return 0;
+}
+
+ID
+rsock_intern_ipv6_optname(int val)
+{
+ st_data_t name;
+ if (st_lookup(rsock_intern_ipv6_optname_hash, (st_data_t)val, &name))
+ return (ID)name;
+ return 0;
+}
+
+ID
+rsock_intern_tcp_optname(int val)
+{
+ st_data_t name;
+ if (st_lookup(rsock_intern_tcp_optname_hash, (st_data_t)val, &name))
+ return (ID)name;
+ return 0;
+}
+
+ID
+rsock_intern_udp_optname(int val)
+{
+ st_data_t name;
+ if (st_lookup(rsock_intern_udp_optname_hash, (st_data_t)val, &name))
+ return (ID)name;
+ return 0;
+}
+
+ID
+rsock_intern_scm_optname(int val)
+{
+ st_data_t name;
+ if (st_lookup(rsock_intern_scm_optname_hash, (st_data_t)val, &name))
+ return (ID)name;
+ return 0;
+}
+
+ID
+rsock_intern_local_optname(int val)
+{
+ st_data_t name;
+ if (st_lookup(rsock_intern_local_optname_hash, (st_data_t)val, &name))
+ return (ID)name;
+ return 0;
+}
+
+
diff --git a/jni/ruby/ext/socket/constdefs.h b/jni/ruby/ext/socket/constdefs.h
new file mode 100644
index 0000000..b88eb84
--- /dev/null
+++ b/jni/ruby/ext/socket/constdefs.h
@@ -0,0 +1,2254 @@
+/* autogenerated file */
+#if !defined(SOCK_STREAM)
+# if defined(HAVE_CONST_SOCK_STREAM)
+# define SOCK_STREAM SOCK_STREAM
+# endif
+#endif
+#if !defined(SOCK_DGRAM)
+# if defined(HAVE_CONST_SOCK_DGRAM)
+# define SOCK_DGRAM SOCK_DGRAM
+# endif
+#endif
+#if !defined(SOCK_RAW)
+# if defined(HAVE_CONST_SOCK_RAW)
+# define SOCK_RAW SOCK_RAW
+# endif
+#endif
+#if !defined(SOCK_RDM)
+# if defined(HAVE_CONST_SOCK_RDM)
+# define SOCK_RDM SOCK_RDM
+# endif
+#endif
+#if !defined(SOCK_SEQPACKET)
+# if defined(HAVE_CONST_SOCK_SEQPACKET)
+# define SOCK_SEQPACKET SOCK_SEQPACKET
+# endif
+#endif
+#if !defined(SOCK_PACKET)
+# if defined(HAVE_CONST_SOCK_PACKET)
+# define SOCK_PACKET SOCK_PACKET
+# endif
+#endif
+#if !defined(AF_UNSPEC)
+# if defined(HAVE_CONST_AF_UNSPEC)
+# define AF_UNSPEC AF_UNSPEC
+# endif
+#endif
+#if !defined(PF_UNSPEC)
+# if defined(HAVE_CONST_PF_UNSPEC)
+# define PF_UNSPEC PF_UNSPEC
+# endif
+#endif
+#if !defined(AF_INET)
+# if defined(HAVE_CONST_AF_INET)
+# define AF_INET AF_INET
+# endif
+#endif
+#if !defined(PF_INET)
+# if defined(HAVE_CONST_PF_INET)
+# define PF_INET PF_INET
+# endif
+#endif
+#if !defined(AF_INET6)
+# if defined(HAVE_CONST_AF_INET6)
+# define AF_INET6 AF_INET6
+# endif
+#endif
+#if !defined(PF_INET6)
+# if defined(HAVE_CONST_PF_INET6)
+# define PF_INET6 PF_INET6
+# endif
+#endif
+#if !defined(AF_UNIX)
+# if defined(HAVE_CONST_AF_UNIX)
+# define AF_UNIX AF_UNIX
+# endif
+#endif
+#if !defined(PF_UNIX)
+# if defined(HAVE_CONST_PF_UNIX)
+# define PF_UNIX PF_UNIX
+# endif
+#endif
+#if !defined(AF_AX25)
+# if defined(HAVE_CONST_AF_AX25)
+# define AF_AX25 AF_AX25
+# endif
+#endif
+#if !defined(PF_AX25)
+# if defined(HAVE_CONST_PF_AX25)
+# define PF_AX25 PF_AX25
+# endif
+#endif
+#if !defined(AF_IPX)
+# if defined(HAVE_CONST_AF_IPX)
+# define AF_IPX AF_IPX
+# endif
+#endif
+#if !defined(PF_IPX)
+# if defined(HAVE_CONST_PF_IPX)
+# define PF_IPX PF_IPX
+# endif
+#endif
+#if !defined(AF_APPLETALK)
+# if defined(HAVE_CONST_AF_APPLETALK)
+# define AF_APPLETALK AF_APPLETALK
+# endif
+#endif
+#if !defined(PF_APPLETALK)
+# if defined(HAVE_CONST_PF_APPLETALK)
+# define PF_APPLETALK PF_APPLETALK
+# endif
+#endif
+#if !defined(AF_LOCAL)
+# if defined(HAVE_CONST_AF_LOCAL)
+# define AF_LOCAL AF_LOCAL
+# endif
+#endif
+#if !defined(PF_LOCAL)
+# if defined(HAVE_CONST_PF_LOCAL)
+# define PF_LOCAL PF_LOCAL
+# endif
+#endif
+#if !defined(AF_IMPLINK)
+# if defined(HAVE_CONST_AF_IMPLINK)
+# define AF_IMPLINK AF_IMPLINK
+# endif
+#endif
+#if !defined(PF_IMPLINK)
+# if defined(HAVE_CONST_PF_IMPLINK)
+# define PF_IMPLINK PF_IMPLINK
+# endif
+#endif
+#if !defined(AF_PUP)
+# if defined(HAVE_CONST_AF_PUP)
+# define AF_PUP AF_PUP
+# endif
+#endif
+#if !defined(PF_PUP)
+# if defined(HAVE_CONST_PF_PUP)
+# define PF_PUP PF_PUP
+# endif
+#endif
+#if !defined(AF_CHAOS)
+# if defined(HAVE_CONST_AF_CHAOS)
+# define AF_CHAOS AF_CHAOS
+# endif
+#endif
+#if !defined(PF_CHAOS)
+# if defined(HAVE_CONST_PF_CHAOS)
+# define PF_CHAOS PF_CHAOS
+# endif
+#endif
+#if !defined(AF_NS)
+# if defined(HAVE_CONST_AF_NS)
+# define AF_NS AF_NS
+# endif
+#endif
+#if !defined(PF_NS)
+# if defined(HAVE_CONST_PF_NS)
+# define PF_NS PF_NS
+# endif
+#endif
+#if !defined(AF_ISO)
+# if defined(HAVE_CONST_AF_ISO)
+# define AF_ISO AF_ISO
+# endif
+#endif
+#if !defined(PF_ISO)
+# if defined(HAVE_CONST_PF_ISO)
+# define PF_ISO PF_ISO
+# endif
+#endif
+#if !defined(AF_OSI)
+# if defined(HAVE_CONST_AF_OSI)
+# define AF_OSI AF_OSI
+# endif
+#endif
+#if !defined(PF_OSI)
+# if defined(HAVE_CONST_PF_OSI)
+# define PF_OSI PF_OSI
+# endif
+#endif
+#if !defined(AF_ECMA)
+# if defined(HAVE_CONST_AF_ECMA)
+# define AF_ECMA AF_ECMA
+# endif
+#endif
+#if !defined(PF_ECMA)
+# if defined(HAVE_CONST_PF_ECMA)
+# define PF_ECMA PF_ECMA
+# endif
+#endif
+#if !defined(AF_DATAKIT)
+# if defined(HAVE_CONST_AF_DATAKIT)
+# define AF_DATAKIT AF_DATAKIT
+# endif
+#endif
+#if !defined(PF_DATAKIT)
+# if defined(HAVE_CONST_PF_DATAKIT)
+# define PF_DATAKIT PF_DATAKIT
+# endif
+#endif
+#if !defined(AF_CCITT)
+# if defined(HAVE_CONST_AF_CCITT)
+# define AF_CCITT AF_CCITT
+# endif
+#endif
+#if !defined(PF_CCITT)
+# if defined(HAVE_CONST_PF_CCITT)
+# define PF_CCITT PF_CCITT
+# endif
+#endif
+#if !defined(AF_SNA)
+# if defined(HAVE_CONST_AF_SNA)
+# define AF_SNA AF_SNA
+# endif
+#endif
+#if !defined(PF_SNA)
+# if defined(HAVE_CONST_PF_SNA)
+# define PF_SNA PF_SNA
+# endif
+#endif
+#if !defined(AF_DEC)
+# if defined(HAVE_CONST_AF_DEC)
+# define AF_DEC AF_DEC
+# endif
+#endif
+#if !defined(PF_DEC)
+# if defined(HAVE_CONST_PF_DEC)
+# define PF_DEC PF_DEC
+# endif
+#endif
+#if !defined(AF_DLI)
+# if defined(HAVE_CONST_AF_DLI)
+# define AF_DLI AF_DLI
+# endif
+#endif
+#if !defined(PF_DLI)
+# if defined(HAVE_CONST_PF_DLI)
+# define PF_DLI PF_DLI
+# endif
+#endif
+#if !defined(AF_LAT)
+# if defined(HAVE_CONST_AF_LAT)
+# define AF_LAT AF_LAT
+# endif
+#endif
+#if !defined(PF_LAT)
+# if defined(HAVE_CONST_PF_LAT)
+# define PF_LAT PF_LAT
+# endif
+#endif
+#if !defined(AF_HYLINK)
+# if defined(HAVE_CONST_AF_HYLINK)
+# define AF_HYLINK AF_HYLINK
+# endif
+#endif
+#if !defined(PF_HYLINK)
+# if defined(HAVE_CONST_PF_HYLINK)
+# define PF_HYLINK PF_HYLINK
+# endif
+#endif
+#if !defined(AF_ROUTE)
+# if defined(HAVE_CONST_AF_ROUTE)
+# define AF_ROUTE AF_ROUTE
+# endif
+#endif
+#if !defined(PF_ROUTE)
+# if defined(HAVE_CONST_PF_ROUTE)
+# define PF_ROUTE PF_ROUTE
+# endif
+#endif
+#if !defined(AF_LINK)
+# if defined(HAVE_CONST_AF_LINK)
+# define AF_LINK AF_LINK
+# endif
+#endif
+#if !defined(PF_LINK)
+# if defined(HAVE_CONST_PF_LINK)
+# define PF_LINK PF_LINK
+# endif
+#endif
+#if !defined(AF_COIP)
+# if defined(HAVE_CONST_AF_COIP)
+# define AF_COIP AF_COIP
+# endif
+#endif
+#if !defined(PF_COIP)
+# if defined(HAVE_CONST_PF_COIP)
+# define PF_COIP PF_COIP
+# endif
+#endif
+#if !defined(AF_CNT)
+# if defined(HAVE_CONST_AF_CNT)
+# define AF_CNT AF_CNT
+# endif
+#endif
+#if !defined(PF_CNT)
+# if defined(HAVE_CONST_PF_CNT)
+# define PF_CNT PF_CNT
+# endif
+#endif
+#if !defined(AF_SIP)
+# if defined(HAVE_CONST_AF_SIP)
+# define AF_SIP AF_SIP
+# endif
+#endif
+#if !defined(PF_SIP)
+# if defined(HAVE_CONST_PF_SIP)
+# define PF_SIP PF_SIP
+# endif
+#endif
+#if !defined(AF_NDRV)
+# if defined(HAVE_CONST_AF_NDRV)
+# define AF_NDRV AF_NDRV
+# endif
+#endif
+#if !defined(PF_NDRV)
+# if defined(HAVE_CONST_PF_NDRV)
+# define PF_NDRV PF_NDRV
+# endif
+#endif
+#if !defined(AF_ISDN)
+# if defined(HAVE_CONST_AF_ISDN)
+# define AF_ISDN AF_ISDN
+# endif
+#endif
+#if !defined(PF_ISDN)
+# if defined(HAVE_CONST_PF_ISDN)
+# define PF_ISDN PF_ISDN
+# endif
+#endif
+#if !defined(AF_NATM)
+# if defined(HAVE_CONST_AF_NATM)
+# define AF_NATM AF_NATM
+# endif
+#endif
+#if !defined(PF_NATM)
+# if defined(HAVE_CONST_PF_NATM)
+# define PF_NATM PF_NATM
+# endif
+#endif
+#if !defined(AF_SYSTEM)
+# if defined(HAVE_CONST_AF_SYSTEM)
+# define AF_SYSTEM AF_SYSTEM
+# endif
+#endif
+#if !defined(PF_SYSTEM)
+# if defined(HAVE_CONST_PF_SYSTEM)
+# define PF_SYSTEM PF_SYSTEM
+# endif
+#endif
+#if !defined(AF_NETBIOS)
+# if defined(HAVE_CONST_AF_NETBIOS)
+# define AF_NETBIOS AF_NETBIOS
+# endif
+#endif
+#if !defined(PF_NETBIOS)
+# if defined(HAVE_CONST_PF_NETBIOS)
+# define PF_NETBIOS PF_NETBIOS
+# endif
+#endif
+#if !defined(AF_PPP)
+# if defined(HAVE_CONST_AF_PPP)
+# define AF_PPP AF_PPP
+# endif
+#endif
+#if !defined(PF_PPP)
+# if defined(HAVE_CONST_PF_PPP)
+# define PF_PPP PF_PPP
+# endif
+#endif
+#if !defined(AF_ATM)
+# if defined(HAVE_CONST_AF_ATM)
+# define AF_ATM AF_ATM
+# endif
+#endif
+#if !defined(PF_ATM)
+# if defined(HAVE_CONST_PF_ATM)
+# define PF_ATM PF_ATM
+# endif
+#endif
+#if !defined(AF_NETGRAPH)
+# if defined(HAVE_CONST_AF_NETGRAPH)
+# define AF_NETGRAPH AF_NETGRAPH
+# endif
+#endif
+#if !defined(PF_NETGRAPH)
+# if defined(HAVE_CONST_PF_NETGRAPH)
+# define PF_NETGRAPH PF_NETGRAPH
+# endif
+#endif
+#if !defined(AF_MAX)
+# if defined(HAVE_CONST_AF_MAX)
+# define AF_MAX AF_MAX
+# endif
+#endif
+#if !defined(PF_MAX)
+# if defined(HAVE_CONST_PF_MAX)
+# define PF_MAX PF_MAX
+# endif
+#endif
+#if !defined(AF_PACKET)
+# if defined(HAVE_CONST_AF_PACKET)
+# define AF_PACKET AF_PACKET
+# endif
+#endif
+#if !defined(PF_PACKET)
+# if defined(HAVE_CONST_PF_PACKET)
+# define PF_PACKET PF_PACKET
+# endif
+#endif
+#if !defined(AF_E164)
+# if defined(HAVE_CONST_AF_E164)
+# define AF_E164 AF_E164
+# endif
+#endif
+#if !defined(PF_XTP)
+# if defined(HAVE_CONST_PF_XTP)
+# define PF_XTP PF_XTP
+# endif
+#endif
+#if !defined(PF_RTIP)
+# if defined(HAVE_CONST_PF_RTIP)
+# define PF_RTIP PF_RTIP
+# endif
+#endif
+#if !defined(PF_PIP)
+# if defined(HAVE_CONST_PF_PIP)
+# define PF_PIP PF_PIP
+# endif
+#endif
+#if !defined(PF_KEY)
+# if defined(HAVE_CONST_PF_KEY)
+# define PF_KEY PF_KEY
+# endif
+#endif
+#if !defined(MSG_OOB)
+# if defined(HAVE_CONST_MSG_OOB)
+# define MSG_OOB MSG_OOB
+# endif
+#endif
+#if !defined(MSG_PEEK)
+# if defined(HAVE_CONST_MSG_PEEK)
+# define MSG_PEEK MSG_PEEK
+# endif
+#endif
+#if !defined(MSG_DONTROUTE)
+# if defined(HAVE_CONST_MSG_DONTROUTE)
+# define MSG_DONTROUTE MSG_DONTROUTE
+# endif
+#endif
+#if !defined(MSG_EOR)
+# if defined(HAVE_CONST_MSG_EOR)
+# define MSG_EOR MSG_EOR
+# endif
+#endif
+#if !defined(MSG_TRUNC)
+# if defined(HAVE_CONST_MSG_TRUNC)
+# define MSG_TRUNC MSG_TRUNC
+# endif
+#endif
+#if !defined(MSG_CTRUNC)
+# if defined(HAVE_CONST_MSG_CTRUNC)
+# define MSG_CTRUNC MSG_CTRUNC
+# endif
+#endif
+#if !defined(MSG_WAITALL)
+# if defined(HAVE_CONST_MSG_WAITALL)
+# define MSG_WAITALL MSG_WAITALL
+# endif
+#endif
+#if !defined(MSG_DONTWAIT)
+# if defined(HAVE_CONST_MSG_DONTWAIT)
+# define MSG_DONTWAIT MSG_DONTWAIT
+# endif
+#endif
+#if !defined(MSG_EOF)
+# if defined(HAVE_CONST_MSG_EOF)
+# define MSG_EOF MSG_EOF
+# endif
+#endif
+#if !defined(MSG_FLUSH)
+# if defined(HAVE_CONST_MSG_FLUSH)
+# define MSG_FLUSH MSG_FLUSH
+# endif
+#endif
+#if !defined(MSG_HOLD)
+# if defined(HAVE_CONST_MSG_HOLD)
+# define MSG_HOLD MSG_HOLD
+# endif
+#endif
+#if !defined(MSG_SEND)
+# if defined(HAVE_CONST_MSG_SEND)
+# define MSG_SEND MSG_SEND
+# endif
+#endif
+#if !defined(MSG_HAVEMORE)
+# if defined(HAVE_CONST_MSG_HAVEMORE)
+# define MSG_HAVEMORE MSG_HAVEMORE
+# endif
+#endif
+#if !defined(MSG_RCVMORE)
+# if defined(HAVE_CONST_MSG_RCVMORE)
+# define MSG_RCVMORE MSG_RCVMORE
+# endif
+#endif
+#if !defined(MSG_COMPAT)
+# if defined(HAVE_CONST_MSG_COMPAT)
+# define MSG_COMPAT MSG_COMPAT
+# endif
+#endif
+#if !defined(MSG_PROXY)
+# if defined(HAVE_CONST_MSG_PROXY)
+# define MSG_PROXY MSG_PROXY
+# endif
+#endif
+#if !defined(MSG_FIN)
+# if defined(HAVE_CONST_MSG_FIN)
+# define MSG_FIN MSG_FIN
+# endif
+#endif
+#if !defined(MSG_SYN)
+# if defined(HAVE_CONST_MSG_SYN)
+# define MSG_SYN MSG_SYN
+# endif
+#endif
+#if !defined(MSG_CONFIRM)
+# if defined(HAVE_CONST_MSG_CONFIRM)
+# define MSG_CONFIRM MSG_CONFIRM
+# endif
+#endif
+#if !defined(MSG_RST)
+# if defined(HAVE_CONST_MSG_RST)
+# define MSG_RST MSG_RST
+# endif
+#endif
+#if !defined(MSG_ERRQUEUE)
+# if defined(HAVE_CONST_MSG_ERRQUEUE)
+# define MSG_ERRQUEUE MSG_ERRQUEUE
+# endif
+#endif
+#if !defined(MSG_NOSIGNAL)
+# if defined(HAVE_CONST_MSG_NOSIGNAL)
+# define MSG_NOSIGNAL MSG_NOSIGNAL
+# endif
+#endif
+#if !defined(MSG_MORE)
+# if defined(HAVE_CONST_MSG_MORE)
+# define MSG_MORE MSG_MORE
+# endif
+#endif
+#if !defined(MSG_FASTOPEN)
+# if defined(HAVE_CONST_MSG_FASTOPEN)
+# define MSG_FASTOPEN MSG_FASTOPEN
+# endif
+#endif
+#if !defined(SOL_SOCKET)
+# if defined(HAVE_CONST_SOL_SOCKET)
+# define SOL_SOCKET SOL_SOCKET
+# endif
+#endif
+#if !defined(SOL_IP)
+# if defined(HAVE_CONST_SOL_IP)
+# define SOL_IP SOL_IP
+# endif
+#endif
+#if !defined(SOL_IPX)
+# if defined(HAVE_CONST_SOL_IPX)
+# define SOL_IPX SOL_IPX
+# endif
+#endif
+#if !defined(SOL_AX25)
+# if defined(HAVE_CONST_SOL_AX25)
+# define SOL_AX25 SOL_AX25
+# endif
+#endif
+#if !defined(SOL_ATALK)
+# if defined(HAVE_CONST_SOL_ATALK)
+# define SOL_ATALK SOL_ATALK
+# endif
+#endif
+#if !defined(SOL_TCP)
+# if defined(HAVE_CONST_SOL_TCP)
+# define SOL_TCP SOL_TCP
+# endif
+#endif
+#if !defined(SOL_UDP)
+# if defined(HAVE_CONST_SOL_UDP)
+# define SOL_UDP SOL_UDP
+# endif
+#endif
+#if !defined(IPPROTO_IP)
+# if defined(HAVE_CONST_IPPROTO_IP)
+# define IPPROTO_IP IPPROTO_IP
+# else
+# define IPPROTO_IP 0
+# endif
+#endif
+#if !defined(IPPROTO_ICMP)
+# if defined(HAVE_CONST_IPPROTO_ICMP)
+# define IPPROTO_ICMP IPPROTO_ICMP
+# else
+# define IPPROTO_ICMP 1
+# endif
+#endif
+#if !defined(IPPROTO_IGMP)
+# if defined(HAVE_CONST_IPPROTO_IGMP)
+# define IPPROTO_IGMP IPPROTO_IGMP
+# endif
+#endif
+#if !defined(IPPROTO_GGP)
+# if defined(HAVE_CONST_IPPROTO_GGP)
+# define IPPROTO_GGP IPPROTO_GGP
+# endif
+#endif
+#if !defined(IPPROTO_TCP)
+# if defined(HAVE_CONST_IPPROTO_TCP)
+# define IPPROTO_TCP IPPROTO_TCP
+# else
+# define IPPROTO_TCP 6
+# endif
+#endif
+#if !defined(IPPROTO_EGP)
+# if defined(HAVE_CONST_IPPROTO_EGP)
+# define IPPROTO_EGP IPPROTO_EGP
+# endif
+#endif
+#if !defined(IPPROTO_PUP)
+# if defined(HAVE_CONST_IPPROTO_PUP)
+# define IPPROTO_PUP IPPROTO_PUP
+# endif
+#endif
+#if !defined(IPPROTO_UDP)
+# if defined(HAVE_CONST_IPPROTO_UDP)
+# define IPPROTO_UDP IPPROTO_UDP
+# else
+# define IPPROTO_UDP 17
+# endif
+#endif
+#if !defined(IPPROTO_IDP)
+# if defined(HAVE_CONST_IPPROTO_IDP)
+# define IPPROTO_IDP IPPROTO_IDP
+# endif
+#endif
+#if !defined(IPPROTO_HELLO)
+# if defined(HAVE_CONST_IPPROTO_HELLO)
+# define IPPROTO_HELLO IPPROTO_HELLO
+# endif
+#endif
+#if !defined(IPPROTO_ND)
+# if defined(HAVE_CONST_IPPROTO_ND)
+# define IPPROTO_ND IPPROTO_ND
+# endif
+#endif
+#if !defined(IPPROTO_TP)
+# if defined(HAVE_CONST_IPPROTO_TP)
+# define IPPROTO_TP IPPROTO_TP
+# endif
+#endif
+#if !defined(IPPROTO_XTP)
+# if defined(HAVE_CONST_IPPROTO_XTP)
+# define IPPROTO_XTP IPPROTO_XTP
+# endif
+#endif
+#if !defined(IPPROTO_EON)
+# if defined(HAVE_CONST_IPPROTO_EON)
+# define IPPROTO_EON IPPROTO_EON
+# endif
+#endif
+#if !defined(IPPROTO_BIP)
+# if defined(HAVE_CONST_IPPROTO_BIP)
+# define IPPROTO_BIP IPPROTO_BIP
+# endif
+#endif
+#if !defined(IPPROTO_AH)
+# if defined(HAVE_CONST_IPPROTO_AH)
+# define IPPROTO_AH IPPROTO_AH
+# endif
+#endif
+#if !defined(IPPROTO_DSTOPTS)
+# if defined(HAVE_CONST_IPPROTO_DSTOPTS)
+# define IPPROTO_DSTOPTS IPPROTO_DSTOPTS
+# endif
+#endif
+#if !defined(IPPROTO_ESP)
+# if defined(HAVE_CONST_IPPROTO_ESP)
+# define IPPROTO_ESP IPPROTO_ESP
+# endif
+#endif
+#if !defined(IPPROTO_FRAGMENT)
+# if defined(HAVE_CONST_IPPROTO_FRAGMENT)
+# define IPPROTO_FRAGMENT IPPROTO_FRAGMENT
+# endif
+#endif
+#if !defined(IPPROTO_HOPOPTS)
+# if defined(HAVE_CONST_IPPROTO_HOPOPTS)
+# define IPPROTO_HOPOPTS IPPROTO_HOPOPTS
+# endif
+#endif
+#if !defined(IPPROTO_ICMPV6)
+# if defined(HAVE_CONST_IPPROTO_ICMPV6)
+# define IPPROTO_ICMPV6 IPPROTO_ICMPV6
+# endif
+#endif
+#if !defined(IPPROTO_IPV6)
+# if defined(HAVE_CONST_IPPROTO_IPV6)
+# define IPPROTO_IPV6 IPPROTO_IPV6
+# endif
+#endif
+#if !defined(IPPROTO_NONE)
+# if defined(HAVE_CONST_IPPROTO_NONE)
+# define IPPROTO_NONE IPPROTO_NONE
+# endif
+#endif
+#if !defined(IPPROTO_ROUTING)
+# if defined(HAVE_CONST_IPPROTO_ROUTING)
+# define IPPROTO_ROUTING IPPROTO_ROUTING
+# endif
+#endif
+#if !defined(IPPROTO_RAW)
+# if defined(HAVE_CONST_IPPROTO_RAW)
+# define IPPROTO_RAW IPPROTO_RAW
+# else
+# define IPPROTO_RAW 255
+# endif
+#endif
+#if !defined(IPPROTO_MAX)
+# if defined(HAVE_CONST_IPPROTO_MAX)
+# define IPPROTO_MAX IPPROTO_MAX
+# endif
+#endif
+#if !defined(IPPORT_RESERVED)
+# if defined(HAVE_CONST_IPPORT_RESERVED)
+# define IPPORT_RESERVED IPPORT_RESERVED
+# else
+# define IPPORT_RESERVED 1024
+# endif
+#endif
+#if !defined(IPPORT_USERRESERVED)
+# if defined(HAVE_CONST_IPPORT_USERRESERVED)
+# define IPPORT_USERRESERVED IPPORT_USERRESERVED
+# else
+# define IPPORT_USERRESERVED 5000
+# endif
+#endif
+#if !defined(INADDR_ANY)
+# if defined(HAVE_CONST_INADDR_ANY)
+# define INADDR_ANY INADDR_ANY
+# else
+# define INADDR_ANY 0x00000000
+# endif
+#endif
+#if !defined(INADDR_BROADCAST)
+# if defined(HAVE_CONST_INADDR_BROADCAST)
+# define INADDR_BROADCAST INADDR_BROADCAST
+# else
+# define INADDR_BROADCAST 0xffffffff
+# endif
+#endif
+#if !defined(INADDR_LOOPBACK)
+# if defined(HAVE_CONST_INADDR_LOOPBACK)
+# define INADDR_LOOPBACK INADDR_LOOPBACK
+# else
+# define INADDR_LOOPBACK 0x7F000001
+# endif
+#endif
+#if !defined(INADDR_UNSPEC_GROUP)
+# if defined(HAVE_CONST_INADDR_UNSPEC_GROUP)
+# define INADDR_UNSPEC_GROUP INADDR_UNSPEC_GROUP
+# else
+# define INADDR_UNSPEC_GROUP 0xe0000000
+# endif
+#endif
+#if !defined(INADDR_ALLHOSTS_GROUP)
+# if defined(HAVE_CONST_INADDR_ALLHOSTS_GROUP)
+# define INADDR_ALLHOSTS_GROUP INADDR_ALLHOSTS_GROUP
+# else
+# define INADDR_ALLHOSTS_GROUP 0xe0000001
+# endif
+#endif
+#if !defined(INADDR_MAX_LOCAL_GROUP)
+# if defined(HAVE_CONST_INADDR_MAX_LOCAL_GROUP)
+# define INADDR_MAX_LOCAL_GROUP INADDR_MAX_LOCAL_GROUP
+# else
+# define INADDR_MAX_LOCAL_GROUP 0xe00000ff
+# endif
+#endif
+#if !defined(INADDR_NONE)
+# if defined(HAVE_CONST_INADDR_NONE)
+# define INADDR_NONE INADDR_NONE
+# else
+# define INADDR_NONE 0xffffffff
+# endif
+#endif
+#if !defined(IP_OPTIONS)
+# if defined(HAVE_CONST_IP_OPTIONS)
+# define IP_OPTIONS IP_OPTIONS
+# endif
+#endif
+#if !defined(IP_HDRINCL)
+# if defined(HAVE_CONST_IP_HDRINCL)
+# define IP_HDRINCL IP_HDRINCL
+# endif
+#endif
+#if !defined(IP_TOS)
+# if defined(HAVE_CONST_IP_TOS)
+# define IP_TOS IP_TOS
+# endif
+#endif
+#if !defined(IP_TTL)
+# if defined(HAVE_CONST_IP_TTL)
+# define IP_TTL IP_TTL
+# endif
+#endif
+#if !defined(IP_RECVOPTS)
+# if defined(HAVE_CONST_IP_RECVOPTS)
+# define IP_RECVOPTS IP_RECVOPTS
+# endif
+#endif
+#if !defined(IP_RECVRETOPTS)
+# if defined(HAVE_CONST_IP_RECVRETOPTS)
+# define IP_RECVRETOPTS IP_RECVRETOPTS
+# endif
+#endif
+#if !defined(IP_RECVDSTADDR)
+# if defined(HAVE_CONST_IP_RECVDSTADDR)
+# define IP_RECVDSTADDR IP_RECVDSTADDR
+# endif
+#endif
+#if !defined(IP_RETOPTS)
+# if defined(HAVE_CONST_IP_RETOPTS)
+# define IP_RETOPTS IP_RETOPTS
+# endif
+#endif
+#if !defined(IP_MINTTL)
+# if defined(HAVE_CONST_IP_MINTTL)
+# define IP_MINTTL IP_MINTTL
+# endif
+#endif
+#if !defined(IP_DONTFRAG)
+# if defined(HAVE_CONST_IP_DONTFRAG)
+# define IP_DONTFRAG IP_DONTFRAG
+# endif
+#endif
+#if !defined(IP_SENDSRCADDR)
+# if defined(HAVE_CONST_IP_SENDSRCADDR)
+# define IP_SENDSRCADDR IP_SENDSRCADDR
+# endif
+#endif
+#if !defined(IP_ONESBCAST)
+# if defined(HAVE_CONST_IP_ONESBCAST)
+# define IP_ONESBCAST IP_ONESBCAST
+# endif
+#endif
+#if !defined(IP_RECVTTL)
+# if defined(HAVE_CONST_IP_RECVTTL)
+# define IP_RECVTTL IP_RECVTTL
+# endif
+#endif
+#if !defined(IP_RECVIF)
+# if defined(HAVE_CONST_IP_RECVIF)
+# define IP_RECVIF IP_RECVIF
+# endif
+#endif
+#if !defined(IP_RECVSLLA)
+# if defined(HAVE_CONST_IP_RECVSLLA)
+# define IP_RECVSLLA IP_RECVSLLA
+# endif
+#endif
+#if !defined(IP_PORTRANGE)
+# if defined(HAVE_CONST_IP_PORTRANGE)
+# define IP_PORTRANGE IP_PORTRANGE
+# endif
+#endif
+#if !defined(IP_MULTICAST_IF)
+# if defined(HAVE_CONST_IP_MULTICAST_IF)
+# define IP_MULTICAST_IF IP_MULTICAST_IF
+# endif
+#endif
+#if !defined(IP_MULTICAST_TTL)
+# if defined(HAVE_CONST_IP_MULTICAST_TTL)
+# define IP_MULTICAST_TTL IP_MULTICAST_TTL
+# endif
+#endif
+#if !defined(IP_MULTICAST_LOOP)
+# if defined(HAVE_CONST_IP_MULTICAST_LOOP)
+# define IP_MULTICAST_LOOP IP_MULTICAST_LOOP
+# endif
+#endif
+#if !defined(IP_ADD_MEMBERSHIP)
+# if defined(HAVE_CONST_IP_ADD_MEMBERSHIP)
+# define IP_ADD_MEMBERSHIP IP_ADD_MEMBERSHIP
+# endif
+#endif
+#if !defined(IP_DROP_MEMBERSHIP)
+# if defined(HAVE_CONST_IP_DROP_MEMBERSHIP)
+# define IP_DROP_MEMBERSHIP IP_DROP_MEMBERSHIP
+# endif
+#endif
+#if !defined(IP_DEFAULT_MULTICAST_TTL)
+# if defined(HAVE_CONST_IP_DEFAULT_MULTICAST_TTL)
+# define IP_DEFAULT_MULTICAST_TTL IP_DEFAULT_MULTICAST_TTL
+# endif
+#endif
+#if !defined(IP_DEFAULT_MULTICAST_LOOP)
+# if defined(HAVE_CONST_IP_DEFAULT_MULTICAST_LOOP)
+# define IP_DEFAULT_MULTICAST_LOOP IP_DEFAULT_MULTICAST_LOOP
+# endif
+#endif
+#if !defined(IP_MAX_MEMBERSHIPS)
+# if defined(HAVE_CONST_IP_MAX_MEMBERSHIPS)
+# define IP_MAX_MEMBERSHIPS IP_MAX_MEMBERSHIPS
+# endif
+#endif
+#if !defined(IP_ROUTER_ALERT)
+# if defined(HAVE_CONST_IP_ROUTER_ALERT)
+# define IP_ROUTER_ALERT IP_ROUTER_ALERT
+# endif
+#endif
+#if !defined(IP_PKTINFO)
+# if defined(HAVE_CONST_IP_PKTINFO)
+# define IP_PKTINFO IP_PKTINFO
+# endif
+#endif
+#if !defined(IP_PKTOPTIONS)
+# if defined(HAVE_CONST_IP_PKTOPTIONS)
+# define IP_PKTOPTIONS IP_PKTOPTIONS
+# endif
+#endif
+#if !defined(IP_MTU_DISCOVER)
+# if defined(HAVE_CONST_IP_MTU_DISCOVER)
+# define IP_MTU_DISCOVER IP_MTU_DISCOVER
+# endif
+#endif
+#if !defined(IP_RECVERR)
+# if defined(HAVE_CONST_IP_RECVERR)
+# define IP_RECVERR IP_RECVERR
+# endif
+#endif
+#if !defined(IP_RECVTOS)
+# if defined(HAVE_CONST_IP_RECVTOS)
+# define IP_RECVTOS IP_RECVTOS
+# endif
+#endif
+#if !defined(IP_MTU)
+# if defined(HAVE_CONST_IP_MTU)
+# define IP_MTU IP_MTU
+# endif
+#endif
+#if !defined(IP_FREEBIND)
+# if defined(HAVE_CONST_IP_FREEBIND)
+# define IP_FREEBIND IP_FREEBIND
+# endif
+#endif
+#if !defined(IP_IPSEC_POLICY)
+# if defined(HAVE_CONST_IP_IPSEC_POLICY)
+# define IP_IPSEC_POLICY IP_IPSEC_POLICY
+# endif
+#endif
+#if !defined(IP_XFRM_POLICY)
+# if defined(HAVE_CONST_IP_XFRM_POLICY)
+# define IP_XFRM_POLICY IP_XFRM_POLICY
+# endif
+#endif
+#if !defined(IP_PASSSEC)
+# if defined(HAVE_CONST_IP_PASSSEC)
+# define IP_PASSSEC IP_PASSSEC
+# endif
+#endif
+#if !defined(IP_TRANSPARENT)
+# if defined(HAVE_CONST_IP_TRANSPARENT)
+# define IP_TRANSPARENT IP_TRANSPARENT
+# endif
+#endif
+#if !defined(IP_PMTUDISC_DONT)
+# if defined(HAVE_CONST_IP_PMTUDISC_DONT)
+# define IP_PMTUDISC_DONT IP_PMTUDISC_DONT
+# endif
+#endif
+#if !defined(IP_PMTUDISC_WANT)
+# if defined(HAVE_CONST_IP_PMTUDISC_WANT)
+# define IP_PMTUDISC_WANT IP_PMTUDISC_WANT
+# endif
+#endif
+#if !defined(IP_PMTUDISC_DO)
+# if defined(HAVE_CONST_IP_PMTUDISC_DO)
+# define IP_PMTUDISC_DO IP_PMTUDISC_DO
+# endif
+#endif
+#if !defined(IP_UNBLOCK_SOURCE)
+# if defined(HAVE_CONST_IP_UNBLOCK_SOURCE)
+# define IP_UNBLOCK_SOURCE IP_UNBLOCK_SOURCE
+# endif
+#endif
+#if !defined(IP_BLOCK_SOURCE)
+# if defined(HAVE_CONST_IP_BLOCK_SOURCE)
+# define IP_BLOCK_SOURCE IP_BLOCK_SOURCE
+# endif
+#endif
+#if !defined(IP_ADD_SOURCE_MEMBERSHIP)
+# if defined(HAVE_CONST_IP_ADD_SOURCE_MEMBERSHIP)
+# define IP_ADD_SOURCE_MEMBERSHIP IP_ADD_SOURCE_MEMBERSHIP
+# endif
+#endif
+#if !defined(IP_DROP_SOURCE_MEMBERSHIP)
+# if defined(HAVE_CONST_IP_DROP_SOURCE_MEMBERSHIP)
+# define IP_DROP_SOURCE_MEMBERSHIP IP_DROP_SOURCE_MEMBERSHIP
+# endif
+#endif
+#if !defined(IP_MSFILTER)
+# if defined(HAVE_CONST_IP_MSFILTER)
+# define IP_MSFILTER IP_MSFILTER
+# endif
+#endif
+#if !defined(MCAST_JOIN_GROUP)
+# if defined(HAVE_CONST_MCAST_JOIN_GROUP)
+# define MCAST_JOIN_GROUP MCAST_JOIN_GROUP
+# endif
+#endif
+#if !defined(MCAST_BLOCK_SOURCE)
+# if defined(HAVE_CONST_MCAST_BLOCK_SOURCE)
+# define MCAST_BLOCK_SOURCE MCAST_BLOCK_SOURCE
+# endif
+#endif
+#if !defined(MCAST_UNBLOCK_SOURCE)
+# if defined(HAVE_CONST_MCAST_UNBLOCK_SOURCE)
+# define MCAST_UNBLOCK_SOURCE MCAST_UNBLOCK_SOURCE
+# endif
+#endif
+#if !defined(MCAST_LEAVE_GROUP)
+# if defined(HAVE_CONST_MCAST_LEAVE_GROUP)
+# define MCAST_LEAVE_GROUP MCAST_LEAVE_GROUP
+# endif
+#endif
+#if !defined(MCAST_JOIN_SOURCE_GROUP)
+# if defined(HAVE_CONST_MCAST_JOIN_SOURCE_GROUP)
+# define MCAST_JOIN_SOURCE_GROUP MCAST_JOIN_SOURCE_GROUP
+# endif
+#endif
+#if !defined(MCAST_LEAVE_SOURCE_GROUP)
+# if defined(HAVE_CONST_MCAST_LEAVE_SOURCE_GROUP)
+# define MCAST_LEAVE_SOURCE_GROUP MCAST_LEAVE_SOURCE_GROUP
+# endif
+#endif
+#if !defined(MCAST_MSFILTER)
+# if defined(HAVE_CONST_MCAST_MSFILTER)
+# define MCAST_MSFILTER MCAST_MSFILTER
+# endif
+#endif
+#if !defined(MCAST_EXCLUDE)
+# if defined(HAVE_CONST_MCAST_EXCLUDE)
+# define MCAST_EXCLUDE MCAST_EXCLUDE
+# endif
+#endif
+#if !defined(MCAST_INCLUDE)
+# if defined(HAVE_CONST_MCAST_INCLUDE)
+# define MCAST_INCLUDE MCAST_INCLUDE
+# endif
+#endif
+#if !defined(SO_DEBUG)
+# if defined(HAVE_CONST_SO_DEBUG)
+# define SO_DEBUG SO_DEBUG
+# endif
+#endif
+#if !defined(SO_REUSEADDR)
+# if defined(HAVE_CONST_SO_REUSEADDR)
+# define SO_REUSEADDR SO_REUSEADDR
+# endif
+#endif
+#if !defined(SO_REUSEPORT)
+# if defined(HAVE_CONST_SO_REUSEPORT)
+# define SO_REUSEPORT SO_REUSEPORT
+# endif
+#endif
+#if !defined(SO_TYPE)
+# if defined(HAVE_CONST_SO_TYPE)
+# define SO_TYPE SO_TYPE
+# endif
+#endif
+#if !defined(SO_ERROR)
+# if defined(HAVE_CONST_SO_ERROR)
+# define SO_ERROR SO_ERROR
+# endif
+#endif
+#if !defined(SO_DONTROUTE)
+# if defined(HAVE_CONST_SO_DONTROUTE)
+# define SO_DONTROUTE SO_DONTROUTE
+# endif
+#endif
+#if !defined(SO_BROADCAST)
+# if defined(HAVE_CONST_SO_BROADCAST)
+# define SO_BROADCAST SO_BROADCAST
+# endif
+#endif
+#if !defined(SO_SNDBUF)
+# if defined(HAVE_CONST_SO_SNDBUF)
+# define SO_SNDBUF SO_SNDBUF
+# endif
+#endif
+#if !defined(SO_RCVBUF)
+# if defined(HAVE_CONST_SO_RCVBUF)
+# define SO_RCVBUF SO_RCVBUF
+# endif
+#endif
+#if !defined(SO_SNDBUFFORCE)
+# if defined(HAVE_CONST_SO_SNDBUFFORCE)
+# define SO_SNDBUFFORCE SO_SNDBUFFORCE
+# endif
+#endif
+#if !defined(SO_RCVBUFFORCE)
+# if defined(HAVE_CONST_SO_RCVBUFFORCE)
+# define SO_RCVBUFFORCE SO_RCVBUFFORCE
+# endif
+#endif
+#if !defined(SO_KEEPALIVE)
+# if defined(HAVE_CONST_SO_KEEPALIVE)
+# define SO_KEEPALIVE SO_KEEPALIVE
+# endif
+#endif
+#if !defined(SO_OOBINLINE)
+# if defined(HAVE_CONST_SO_OOBINLINE)
+# define SO_OOBINLINE SO_OOBINLINE
+# endif
+#endif
+#if !defined(SO_NO_CHECK)
+# if defined(HAVE_CONST_SO_NO_CHECK)
+# define SO_NO_CHECK SO_NO_CHECK
+# endif
+#endif
+#if !defined(SO_PRIORITY)
+# if defined(HAVE_CONST_SO_PRIORITY)
+# define SO_PRIORITY SO_PRIORITY
+# endif
+#endif
+#if !defined(SO_LINGER)
+# if defined(HAVE_CONST_SO_LINGER)
+# define SO_LINGER SO_LINGER
+# endif
+#endif
+#if !defined(SO_PASSCRED)
+# if defined(HAVE_CONST_SO_PASSCRED)
+# define SO_PASSCRED SO_PASSCRED
+# endif
+#endif
+#if !defined(SO_PEERCRED)
+# if defined(HAVE_CONST_SO_PEERCRED)
+# define SO_PEERCRED SO_PEERCRED
+# endif
+#endif
+#if !defined(SO_RCVLOWAT)
+# if defined(HAVE_CONST_SO_RCVLOWAT)
+# define SO_RCVLOWAT SO_RCVLOWAT
+# endif
+#endif
+#if !defined(SO_SNDLOWAT)
+# if defined(HAVE_CONST_SO_SNDLOWAT)
+# define SO_SNDLOWAT SO_SNDLOWAT
+# endif
+#endif
+#if !defined(SO_RCVTIMEO)
+# if defined(HAVE_CONST_SO_RCVTIMEO)
+# define SO_RCVTIMEO SO_RCVTIMEO
+# endif
+#endif
+#if !defined(SO_SNDTIMEO)
+# if defined(HAVE_CONST_SO_SNDTIMEO)
+# define SO_SNDTIMEO SO_SNDTIMEO
+# endif
+#endif
+#if !defined(SO_ACCEPTCONN)
+# if defined(HAVE_CONST_SO_ACCEPTCONN)
+# define SO_ACCEPTCONN SO_ACCEPTCONN
+# endif
+#endif
+#if !defined(SO_USELOOPBACK)
+# if defined(HAVE_CONST_SO_USELOOPBACK)
+# define SO_USELOOPBACK SO_USELOOPBACK
+# endif
+#endif
+#if !defined(SO_ACCEPTFILTER)
+# if defined(HAVE_CONST_SO_ACCEPTFILTER)
+# define SO_ACCEPTFILTER SO_ACCEPTFILTER
+# endif
+#endif
+#if !defined(SO_DONTTRUNC)
+# if defined(HAVE_CONST_SO_DONTTRUNC)
+# define SO_DONTTRUNC SO_DONTTRUNC
+# endif
+#endif
+#if !defined(SO_WANTMORE)
+# if defined(HAVE_CONST_SO_WANTMORE)
+# define SO_WANTMORE SO_WANTMORE
+# endif
+#endif
+#if !defined(SO_WANTOOBFLAG)
+# if defined(HAVE_CONST_SO_WANTOOBFLAG)
+# define SO_WANTOOBFLAG SO_WANTOOBFLAG
+# endif
+#endif
+#if !defined(SO_NREAD)
+# if defined(HAVE_CONST_SO_NREAD)
+# define SO_NREAD SO_NREAD
+# endif
+#endif
+#if !defined(SO_NKE)
+# if defined(HAVE_CONST_SO_NKE)
+# define SO_NKE SO_NKE
+# endif
+#endif
+#if !defined(SO_NOSIGPIPE)
+# if defined(HAVE_CONST_SO_NOSIGPIPE)
+# define SO_NOSIGPIPE SO_NOSIGPIPE
+# endif
+#endif
+#if !defined(SO_SECURITY_AUTHENTICATION)
+# if defined(HAVE_CONST_SO_SECURITY_AUTHENTICATION)
+# define SO_SECURITY_AUTHENTICATION SO_SECURITY_AUTHENTICATION
+# endif
+#endif
+#if !defined(SO_SECURITY_ENCRYPTION_TRANSPORT)
+# if defined(HAVE_CONST_SO_SECURITY_ENCRYPTION_TRANSPORT)
+# define SO_SECURITY_ENCRYPTION_TRANSPORT SO_SECURITY_ENCRYPTION_TRANSPORT
+# endif
+#endif
+#if !defined(SO_SECURITY_ENCRYPTION_NETWORK)
+# if defined(HAVE_CONST_SO_SECURITY_ENCRYPTION_NETWORK)
+# define SO_SECURITY_ENCRYPTION_NETWORK SO_SECURITY_ENCRYPTION_NETWORK
+# endif
+#endif
+#if !defined(SO_BINDTODEVICE)
+# if defined(HAVE_CONST_SO_BINDTODEVICE)
+# define SO_BINDTODEVICE SO_BINDTODEVICE
+# endif
+#endif
+#if !defined(SO_ATTACH_FILTER)
+# if defined(HAVE_CONST_SO_ATTACH_FILTER)
+# define SO_ATTACH_FILTER SO_ATTACH_FILTER
+# endif
+#endif
+#if !defined(SO_DETACH_FILTER)
+# if defined(HAVE_CONST_SO_DETACH_FILTER)
+# define SO_DETACH_FILTER SO_DETACH_FILTER
+# endif
+#endif
+#if !defined(SO_GET_FILTER)
+# if defined(HAVE_CONST_SO_GET_FILTER)
+# define SO_GET_FILTER SO_GET_FILTER
+# endif
+#endif
+#if !defined(SO_PEERNAME)
+# if defined(HAVE_CONST_SO_PEERNAME)
+# define SO_PEERNAME SO_PEERNAME
+# endif
+#endif
+#if !defined(SO_TIMESTAMP)
+# if defined(HAVE_CONST_SO_TIMESTAMP)
+# define SO_TIMESTAMP SO_TIMESTAMP
+# endif
+#endif
+#if !defined(SO_TIMESTAMPNS)
+# if defined(HAVE_CONST_SO_TIMESTAMPNS)
+# define SO_TIMESTAMPNS SO_TIMESTAMPNS
+# endif
+#endif
+#if !defined(SO_BINTIME)
+# if defined(HAVE_CONST_SO_BINTIME)
+# define SO_BINTIME SO_BINTIME
+# endif
+#endif
+#if !defined(SO_RECVUCRED)
+# if defined(HAVE_CONST_SO_RECVUCRED)
+# define SO_RECVUCRED SO_RECVUCRED
+# endif
+#endif
+#if !defined(SO_MAC_EXEMPT)
+# if defined(HAVE_CONST_SO_MAC_EXEMPT)
+# define SO_MAC_EXEMPT SO_MAC_EXEMPT
+# endif
+#endif
+#if !defined(SO_ALLZONES)
+# if defined(HAVE_CONST_SO_ALLZONES)
+# define SO_ALLZONES SO_ALLZONES
+# endif
+#endif
+#if !defined(SO_PEERSEC)
+# if defined(HAVE_CONST_SO_PEERSEC)
+# define SO_PEERSEC SO_PEERSEC
+# endif
+#endif
+#if !defined(SO_PASSSEC)
+# if defined(HAVE_CONST_SO_PASSSEC)
+# define SO_PASSSEC SO_PASSSEC
+# endif
+#endif
+#if !defined(SO_MARK)
+# if defined(HAVE_CONST_SO_MARK)
+# define SO_MARK SO_MARK
+# endif
+#endif
+#if !defined(SO_TIMESTAMPING)
+# if defined(HAVE_CONST_SO_TIMESTAMPING)
+# define SO_TIMESTAMPING SO_TIMESTAMPING
+# endif
+#endif
+#if !defined(SO_PROTOCOL)
+# if defined(HAVE_CONST_SO_PROTOCOL)
+# define SO_PROTOCOL SO_PROTOCOL
+# endif
+#endif
+#if !defined(SO_DOMAIN)
+# if defined(HAVE_CONST_SO_DOMAIN)
+# define SO_DOMAIN SO_DOMAIN
+# endif
+#endif
+#if !defined(SO_RXQ_OVFL)
+# if defined(HAVE_CONST_SO_RXQ_OVFL)
+# define SO_RXQ_OVFL SO_RXQ_OVFL
+# endif
+#endif
+#if !defined(SO_WIFI_STATUS)
+# if defined(HAVE_CONST_SO_WIFI_STATUS)
+# define SO_WIFI_STATUS SO_WIFI_STATUS
+# endif
+#endif
+#if !defined(SO_PEEK_OFF)
+# if defined(HAVE_CONST_SO_PEEK_OFF)
+# define SO_PEEK_OFF SO_PEEK_OFF
+# endif
+#endif
+#if !defined(SO_NOFCS)
+# if defined(HAVE_CONST_SO_NOFCS)
+# define SO_NOFCS SO_NOFCS
+# endif
+#endif
+#if !defined(SO_LOCK_FILTER)
+# if defined(HAVE_CONST_SO_LOCK_FILTER)
+# define SO_LOCK_FILTER SO_LOCK_FILTER
+# endif
+#endif
+#if !defined(SO_SELECT_ERR_QUEUE)
+# if defined(HAVE_CONST_SO_SELECT_ERR_QUEUE)
+# define SO_SELECT_ERR_QUEUE SO_SELECT_ERR_QUEUE
+# endif
+#endif
+#if !defined(SO_BUSY_POLL)
+# if defined(HAVE_CONST_SO_BUSY_POLL)
+# define SO_BUSY_POLL SO_BUSY_POLL
+# endif
+#endif
+#if !defined(SO_MAX_PACING_RATE)
+# if defined(HAVE_CONST_SO_MAX_PACING_RATE)
+# define SO_MAX_PACING_RATE SO_MAX_PACING_RATE
+# endif
+#endif
+#if !defined(SO_BPF_EXTENSIONS)
+# if defined(HAVE_CONST_SO_BPF_EXTENSIONS)
+# define SO_BPF_EXTENSIONS SO_BPF_EXTENSIONS
+# endif
+#endif
+#if !defined(SOPRI_INTERACTIVE)
+# if defined(HAVE_CONST_SOPRI_INTERACTIVE)
+# define SOPRI_INTERACTIVE SOPRI_INTERACTIVE
+# endif
+#endif
+#if !defined(SOPRI_NORMAL)
+# if defined(HAVE_CONST_SOPRI_NORMAL)
+# define SOPRI_NORMAL SOPRI_NORMAL
+# endif
+#endif
+#if !defined(SOPRI_BACKGROUND)
+# if defined(HAVE_CONST_SOPRI_BACKGROUND)
+# define SOPRI_BACKGROUND SOPRI_BACKGROUND
+# endif
+#endif
+#if !defined(IPX_TYPE)
+# if defined(HAVE_CONST_IPX_TYPE)
+# define IPX_TYPE IPX_TYPE
+# endif
+#endif
+#if !defined(TCP_NODELAY)
+# if defined(HAVE_CONST_TCP_NODELAY)
+# define TCP_NODELAY TCP_NODELAY
+# endif
+#endif
+#if !defined(TCP_MAXSEG)
+# if defined(HAVE_CONST_TCP_MAXSEG)
+# define TCP_MAXSEG TCP_MAXSEG
+# endif
+#endif
+#if !defined(TCP_CORK)
+# if defined(HAVE_CONST_TCP_CORK)
+# define TCP_CORK TCP_CORK
+# endif
+#endif
+#if !defined(TCP_DEFER_ACCEPT)
+# if defined(HAVE_CONST_TCP_DEFER_ACCEPT)
+# define TCP_DEFER_ACCEPT TCP_DEFER_ACCEPT
+# endif
+#endif
+#if !defined(TCP_INFO)
+# if defined(HAVE_CONST_TCP_INFO)
+# define TCP_INFO TCP_INFO
+# endif
+#endif
+#if !defined(TCP_KEEPCNT)
+# if defined(HAVE_CONST_TCP_KEEPCNT)
+# define TCP_KEEPCNT TCP_KEEPCNT
+# endif
+#endif
+#if !defined(TCP_KEEPIDLE)
+# if defined(HAVE_CONST_TCP_KEEPIDLE)
+# define TCP_KEEPIDLE TCP_KEEPIDLE
+# endif
+#endif
+#if !defined(TCP_KEEPINTVL)
+# if defined(HAVE_CONST_TCP_KEEPINTVL)
+# define TCP_KEEPINTVL TCP_KEEPINTVL
+# endif
+#endif
+#if !defined(TCP_LINGER2)
+# if defined(HAVE_CONST_TCP_LINGER2)
+# define TCP_LINGER2 TCP_LINGER2
+# endif
+#endif
+#if !defined(TCP_MD5SIG)
+# if defined(HAVE_CONST_TCP_MD5SIG)
+# define TCP_MD5SIG TCP_MD5SIG
+# endif
+#endif
+#if !defined(TCP_NOOPT)
+# if defined(HAVE_CONST_TCP_NOOPT)
+# define TCP_NOOPT TCP_NOOPT
+# endif
+#endif
+#if !defined(TCP_NOPUSH)
+# if defined(HAVE_CONST_TCP_NOPUSH)
+# define TCP_NOPUSH TCP_NOPUSH
+# endif
+#endif
+#if !defined(TCP_QUICKACK)
+# if defined(HAVE_CONST_TCP_QUICKACK)
+# define TCP_QUICKACK TCP_QUICKACK
+# endif
+#endif
+#if !defined(TCP_SYNCNT)
+# if defined(HAVE_CONST_TCP_SYNCNT)
+# define TCP_SYNCNT TCP_SYNCNT
+# endif
+#endif
+#if !defined(TCP_WINDOW_CLAMP)
+# if defined(HAVE_CONST_TCP_WINDOW_CLAMP)
+# define TCP_WINDOW_CLAMP TCP_WINDOW_CLAMP
+# endif
+#endif
+#if !defined(TCP_FASTOPEN)
+# if defined(HAVE_CONST_TCP_FASTOPEN)
+# define TCP_FASTOPEN TCP_FASTOPEN
+# endif
+#endif
+#if !defined(TCP_CONGESTION)
+# if defined(HAVE_CONST_TCP_CONGESTION)
+# define TCP_CONGESTION TCP_CONGESTION
+# endif
+#endif
+#if !defined(TCP_COOKIE_TRANSACTIONS)
+# if defined(HAVE_CONST_TCP_COOKIE_TRANSACTIONS)
+# define TCP_COOKIE_TRANSACTIONS TCP_COOKIE_TRANSACTIONS
+# endif
+#endif
+#if !defined(TCP_QUEUE_SEQ)
+# if defined(HAVE_CONST_TCP_QUEUE_SEQ)
+# define TCP_QUEUE_SEQ TCP_QUEUE_SEQ
+# endif
+#endif
+#if !defined(TCP_REPAIR)
+# if defined(HAVE_CONST_TCP_REPAIR)
+# define TCP_REPAIR TCP_REPAIR
+# endif
+#endif
+#if !defined(TCP_REPAIR_OPTIONS)
+# if defined(HAVE_CONST_TCP_REPAIR_OPTIONS)
+# define TCP_REPAIR_OPTIONS TCP_REPAIR_OPTIONS
+# endif
+#endif
+#if !defined(TCP_REPAIR_QUEUE)
+# if defined(HAVE_CONST_TCP_REPAIR_QUEUE)
+# define TCP_REPAIR_QUEUE TCP_REPAIR_QUEUE
+# endif
+#endif
+#if !defined(TCP_THIN_DUPACK)
+# if defined(HAVE_CONST_TCP_THIN_DUPACK)
+# define TCP_THIN_DUPACK TCP_THIN_DUPACK
+# endif
+#endif
+#if !defined(TCP_THIN_LINEAR_TIMEOUTS)
+# if defined(HAVE_CONST_TCP_THIN_LINEAR_TIMEOUTS)
+# define TCP_THIN_LINEAR_TIMEOUTS TCP_THIN_LINEAR_TIMEOUTS
+# endif
+#endif
+#if !defined(TCP_TIMESTAMP)
+# if defined(HAVE_CONST_TCP_TIMESTAMP)
+# define TCP_TIMESTAMP TCP_TIMESTAMP
+# endif
+#endif
+#if !defined(TCP_USER_TIMEOUT)
+# if defined(HAVE_CONST_TCP_USER_TIMEOUT)
+# define TCP_USER_TIMEOUT TCP_USER_TIMEOUT
+# endif
+#endif
+#if !defined(UDP_CORK)
+# if defined(HAVE_CONST_UDP_CORK)
+# define UDP_CORK UDP_CORK
+# endif
+#endif
+#if !defined(EAI_ADDRFAMILY)
+# if defined(HAVE_CONST_EAI_ADDRFAMILY)
+# define EAI_ADDRFAMILY EAI_ADDRFAMILY
+# endif
+#endif
+#if !defined(EAI_AGAIN)
+# if defined(HAVE_CONST_EAI_AGAIN)
+# define EAI_AGAIN EAI_AGAIN
+# endif
+#endif
+#if !defined(EAI_BADFLAGS)
+# if defined(HAVE_CONST_EAI_BADFLAGS)
+# define EAI_BADFLAGS EAI_BADFLAGS
+# endif
+#endif
+#if !defined(EAI_FAIL)
+# if defined(HAVE_CONST_EAI_FAIL)
+# define EAI_FAIL EAI_FAIL
+# endif
+#endif
+#if !defined(EAI_FAMILY)
+# if defined(HAVE_CONST_EAI_FAMILY)
+# define EAI_FAMILY EAI_FAMILY
+# endif
+#endif
+#if !defined(EAI_MEMORY)
+# if defined(HAVE_CONST_EAI_MEMORY)
+# define EAI_MEMORY EAI_MEMORY
+# endif
+#endif
+#if !defined(EAI_NODATA)
+# if defined(HAVE_CONST_EAI_NODATA)
+# define EAI_NODATA EAI_NODATA
+# endif
+#endif
+#if !defined(EAI_NONAME)
+# if defined(HAVE_CONST_EAI_NONAME)
+# define EAI_NONAME EAI_NONAME
+# endif
+#endif
+#if !defined(EAI_OVERFLOW)
+# if defined(HAVE_CONST_EAI_OVERFLOW)
+# define EAI_OVERFLOW EAI_OVERFLOW
+# endif
+#endif
+#if !defined(EAI_SERVICE)
+# if defined(HAVE_CONST_EAI_SERVICE)
+# define EAI_SERVICE EAI_SERVICE
+# endif
+#endif
+#if !defined(EAI_SOCKTYPE)
+# if defined(HAVE_CONST_EAI_SOCKTYPE)
+# define EAI_SOCKTYPE EAI_SOCKTYPE
+# endif
+#endif
+#if !defined(EAI_SYSTEM)
+# if defined(HAVE_CONST_EAI_SYSTEM)
+# define EAI_SYSTEM EAI_SYSTEM
+# endif
+#endif
+#if !defined(EAI_BADHINTS)
+# if defined(HAVE_CONST_EAI_BADHINTS)
+# define EAI_BADHINTS EAI_BADHINTS
+# endif
+#endif
+#if !defined(EAI_PROTOCOL)
+# if defined(HAVE_CONST_EAI_PROTOCOL)
+# define EAI_PROTOCOL EAI_PROTOCOL
+# endif
+#endif
+#if !defined(EAI_MAX)
+# if defined(HAVE_CONST_EAI_MAX)
+# define EAI_MAX EAI_MAX
+# endif
+#endif
+#if !defined(AI_PASSIVE)
+# if defined(HAVE_CONST_AI_PASSIVE)
+# define AI_PASSIVE AI_PASSIVE
+# endif
+#endif
+#if !defined(AI_CANONNAME)
+# if defined(HAVE_CONST_AI_CANONNAME)
+# define AI_CANONNAME AI_CANONNAME
+# endif
+#endif
+#if !defined(AI_NUMERICHOST)
+# if defined(HAVE_CONST_AI_NUMERICHOST)
+# define AI_NUMERICHOST AI_NUMERICHOST
+# endif
+#endif
+#if !defined(AI_NUMERICSERV)
+# if defined(HAVE_CONST_AI_NUMERICSERV)
+# define AI_NUMERICSERV AI_NUMERICSERV
+# endif
+#endif
+#if !defined(AI_MASK)
+# if defined(HAVE_CONST_AI_MASK)
+# define AI_MASK AI_MASK
+# endif
+#endif
+#if !defined(AI_ALL)
+# if defined(HAVE_CONST_AI_ALL)
+# define AI_ALL AI_ALL
+# endif
+#endif
+#if !defined(AI_V4MAPPED_CFG)
+# if defined(HAVE_CONST_AI_V4MAPPED_CFG)
+# define AI_V4MAPPED_CFG AI_V4MAPPED_CFG
+# endif
+#endif
+#if !defined(AI_ADDRCONFIG)
+# if defined(HAVE_CONST_AI_ADDRCONFIG)
+# define AI_ADDRCONFIG AI_ADDRCONFIG
+# endif
+#endif
+#if !defined(AI_V4MAPPED)
+# if defined(HAVE_CONST_AI_V4MAPPED)
+# define AI_V4MAPPED AI_V4MAPPED
+# endif
+#endif
+#if !defined(AI_DEFAULT)
+# if defined(HAVE_CONST_AI_DEFAULT)
+# define AI_DEFAULT AI_DEFAULT
+# endif
+#endif
+#if !defined(NI_MAXHOST)
+# if defined(HAVE_CONST_NI_MAXHOST)
+# define NI_MAXHOST NI_MAXHOST
+# endif
+#endif
+#if !defined(NI_MAXSERV)
+# if defined(HAVE_CONST_NI_MAXSERV)
+# define NI_MAXSERV NI_MAXSERV
+# endif
+#endif
+#if !defined(NI_NOFQDN)
+# if defined(HAVE_CONST_NI_NOFQDN)
+# define NI_NOFQDN NI_NOFQDN
+# endif
+#endif
+#if !defined(NI_NUMERICHOST)
+# if defined(HAVE_CONST_NI_NUMERICHOST)
+# define NI_NUMERICHOST NI_NUMERICHOST
+# endif
+#endif
+#if !defined(NI_NAMEREQD)
+# if defined(HAVE_CONST_NI_NAMEREQD)
+# define NI_NAMEREQD NI_NAMEREQD
+# endif
+#endif
+#if !defined(NI_NUMERICSERV)
+# if defined(HAVE_CONST_NI_NUMERICSERV)
+# define NI_NUMERICSERV NI_NUMERICSERV
+# endif
+#endif
+#if !defined(NI_DGRAM)
+# if defined(HAVE_CONST_NI_DGRAM)
+# define NI_DGRAM NI_DGRAM
+# endif
+#endif
+#if !defined(SHUT_RD)
+# if defined(HAVE_CONST_SHUT_RD)
+# define SHUT_RD SHUT_RD
+# else
+# define SHUT_RD 0
+# endif
+#endif
+#if !defined(SHUT_WR)
+# if defined(HAVE_CONST_SHUT_WR)
+# define SHUT_WR SHUT_WR
+# else
+# define SHUT_WR 1
+# endif
+#endif
+#if !defined(SHUT_RDWR)
+# if defined(HAVE_CONST_SHUT_RDWR)
+# define SHUT_RDWR SHUT_RDWR
+# else
+# define SHUT_RDWR 2
+# endif
+#endif
+#if !defined(IPV6_JOIN_GROUP)
+# if defined(HAVE_CONST_IPV6_JOIN_GROUP)
+# define IPV6_JOIN_GROUP IPV6_JOIN_GROUP
+# endif
+#endif
+#if !defined(IPV6_LEAVE_GROUP)
+# if defined(HAVE_CONST_IPV6_LEAVE_GROUP)
+# define IPV6_LEAVE_GROUP IPV6_LEAVE_GROUP
+# endif
+#endif
+#if !defined(IPV6_MULTICAST_HOPS)
+# if defined(HAVE_CONST_IPV6_MULTICAST_HOPS)
+# define IPV6_MULTICAST_HOPS IPV6_MULTICAST_HOPS
+# endif
+#endif
+#if !defined(IPV6_MULTICAST_IF)
+# if defined(HAVE_CONST_IPV6_MULTICAST_IF)
+# define IPV6_MULTICAST_IF IPV6_MULTICAST_IF
+# endif
+#endif
+#if !defined(IPV6_MULTICAST_LOOP)
+# if defined(HAVE_CONST_IPV6_MULTICAST_LOOP)
+# define IPV6_MULTICAST_LOOP IPV6_MULTICAST_LOOP
+# endif
+#endif
+#if !defined(IPV6_UNICAST_HOPS)
+# if defined(HAVE_CONST_IPV6_UNICAST_HOPS)
+# define IPV6_UNICAST_HOPS IPV6_UNICAST_HOPS
+# endif
+#endif
+#if !defined(IPV6_V6ONLY)
+# if defined(HAVE_CONST_IPV6_V6ONLY)
+# define IPV6_V6ONLY IPV6_V6ONLY
+# endif
+#endif
+#if !defined(IPV6_CHECKSUM)
+# if defined(HAVE_CONST_IPV6_CHECKSUM)
+# define IPV6_CHECKSUM IPV6_CHECKSUM
+# endif
+#endif
+#if !defined(IPV6_DONTFRAG)
+# if defined(HAVE_CONST_IPV6_DONTFRAG)
+# define IPV6_DONTFRAG IPV6_DONTFRAG
+# endif
+#endif
+#if !defined(IPV6_DSTOPTS)
+# if defined(HAVE_CONST_IPV6_DSTOPTS)
+# define IPV6_DSTOPTS IPV6_DSTOPTS
+# endif
+#endif
+#if !defined(IPV6_HOPLIMIT)
+# if defined(HAVE_CONST_IPV6_HOPLIMIT)
+# define IPV6_HOPLIMIT IPV6_HOPLIMIT
+# endif
+#endif
+#if !defined(IPV6_HOPOPTS)
+# if defined(HAVE_CONST_IPV6_HOPOPTS)
+# define IPV6_HOPOPTS IPV6_HOPOPTS
+# endif
+#endif
+#if !defined(IPV6_NEXTHOP)
+# if defined(HAVE_CONST_IPV6_NEXTHOP)
+# define IPV6_NEXTHOP IPV6_NEXTHOP
+# endif
+#endif
+#if !defined(IPV6_PATHMTU)
+# if defined(HAVE_CONST_IPV6_PATHMTU)
+# define IPV6_PATHMTU IPV6_PATHMTU
+# endif
+#endif
+#if !defined(IPV6_PKTINFO)
+# if defined(HAVE_CONST_IPV6_PKTINFO)
+# define IPV6_PKTINFO IPV6_PKTINFO
+# endif
+#endif
+#if !defined(IPV6_RECVDSTOPTS)
+# if defined(HAVE_CONST_IPV6_RECVDSTOPTS)
+# define IPV6_RECVDSTOPTS IPV6_RECVDSTOPTS
+# endif
+#endif
+#if !defined(IPV6_RECVHOPLIMIT)
+# if defined(HAVE_CONST_IPV6_RECVHOPLIMIT)
+# define IPV6_RECVHOPLIMIT IPV6_RECVHOPLIMIT
+# endif
+#endif
+#if !defined(IPV6_RECVHOPOPTS)
+# if defined(HAVE_CONST_IPV6_RECVHOPOPTS)
+# define IPV6_RECVHOPOPTS IPV6_RECVHOPOPTS
+# endif
+#endif
+#if !defined(IPV6_RECVPKTINFO)
+# if defined(HAVE_CONST_IPV6_RECVPKTINFO)
+# define IPV6_RECVPKTINFO IPV6_RECVPKTINFO
+# endif
+#endif
+#if !defined(IPV6_RECVRTHDR)
+# if defined(HAVE_CONST_IPV6_RECVRTHDR)
+# define IPV6_RECVRTHDR IPV6_RECVRTHDR
+# endif
+#endif
+#if !defined(IPV6_RECVTCLASS)
+# if defined(HAVE_CONST_IPV6_RECVTCLASS)
+# define IPV6_RECVTCLASS IPV6_RECVTCLASS
+# endif
+#endif
+#if !defined(IPV6_RTHDR)
+# if defined(HAVE_CONST_IPV6_RTHDR)
+# define IPV6_RTHDR IPV6_RTHDR
+# endif
+#endif
+#if !defined(IPV6_RTHDRDSTOPTS)
+# if defined(HAVE_CONST_IPV6_RTHDRDSTOPTS)
+# define IPV6_RTHDRDSTOPTS IPV6_RTHDRDSTOPTS
+# endif
+#endif
+#if !defined(IPV6_RTHDR_TYPE_0)
+# if defined(HAVE_CONST_IPV6_RTHDR_TYPE_0)
+# define IPV6_RTHDR_TYPE_0 IPV6_RTHDR_TYPE_0
+# endif
+#endif
+#if !defined(IPV6_RECVPATHMTU)
+# if defined(HAVE_CONST_IPV6_RECVPATHMTU)
+# define IPV6_RECVPATHMTU IPV6_RECVPATHMTU
+# endif
+#endif
+#if !defined(IPV6_TCLASS)
+# if defined(HAVE_CONST_IPV6_TCLASS)
+# define IPV6_TCLASS IPV6_TCLASS
+# endif
+#endif
+#if !defined(IPV6_USE_MIN_MTU)
+# if defined(HAVE_CONST_IPV6_USE_MIN_MTU)
+# define IPV6_USE_MIN_MTU IPV6_USE_MIN_MTU
+# endif
+#endif
+#if !defined(INET_ADDRSTRLEN)
+# if defined(HAVE_CONST_INET_ADDRSTRLEN)
+# define INET_ADDRSTRLEN INET_ADDRSTRLEN
+# else
+# define INET_ADDRSTRLEN 16
+# endif
+#endif
+#if !defined(INET6_ADDRSTRLEN)
+# if defined(HAVE_CONST_INET6_ADDRSTRLEN)
+# define INET6_ADDRSTRLEN INET6_ADDRSTRLEN
+# else
+# define INET6_ADDRSTRLEN 46
+# endif
+#endif
+#if !defined(IFNAMSIZ)
+# if defined(HAVE_CONST_IFNAMSIZ)
+# define IFNAMSIZ IFNAMSIZ
+# endif
+#endif
+#if !defined(IF_NAMESIZE)
+# if defined(HAVE_CONST_IF_NAMESIZE)
+# define IF_NAMESIZE IF_NAMESIZE
+# endif
+#endif
+#if !defined(SOMAXCONN)
+# if defined(HAVE_CONST_SOMAXCONN)
+# define SOMAXCONN SOMAXCONN
+# else
+# define SOMAXCONN 5
+# endif
+#endif
+#if !defined(SCM_RIGHTS)
+# if defined(HAVE_CONST_SCM_RIGHTS)
+# define SCM_RIGHTS SCM_RIGHTS
+# endif
+#endif
+#if !defined(SCM_TIMESTAMP)
+# if defined(HAVE_CONST_SCM_TIMESTAMP)
+# define SCM_TIMESTAMP SCM_TIMESTAMP
+# endif
+#endif
+#if !defined(SCM_TIMESTAMPNS)
+# if defined(HAVE_CONST_SCM_TIMESTAMPNS)
+# define SCM_TIMESTAMPNS SCM_TIMESTAMPNS
+# endif
+#endif
+#if !defined(SCM_TIMESTAMPING)
+# if defined(HAVE_CONST_SCM_TIMESTAMPING)
+# define SCM_TIMESTAMPING SCM_TIMESTAMPING
+# endif
+#endif
+#if !defined(SCM_BINTIME)
+# if defined(HAVE_CONST_SCM_BINTIME)
+# define SCM_BINTIME SCM_BINTIME
+# endif
+#endif
+#if !defined(SCM_CREDENTIALS)
+# if defined(HAVE_CONST_SCM_CREDENTIALS)
+# define SCM_CREDENTIALS SCM_CREDENTIALS
+# endif
+#endif
+#if !defined(SCM_CREDS)
+# if defined(HAVE_CONST_SCM_CREDS)
+# define SCM_CREDS SCM_CREDS
+# endif
+#endif
+#if !defined(SCM_UCRED)
+# if defined(HAVE_CONST_SCM_UCRED)
+# define SCM_UCRED SCM_UCRED
+# endif
+#endif
+#if !defined(SCM_WIFI_STATUS)
+# if defined(HAVE_CONST_SCM_WIFI_STATUS)
+# define SCM_WIFI_STATUS SCM_WIFI_STATUS
+# endif
+#endif
+#if !defined(LOCAL_PEERCRED)
+# if defined(HAVE_CONST_LOCAL_PEERCRED)
+# define LOCAL_PEERCRED LOCAL_PEERCRED
+# endif
+#endif
+#if !defined(LOCAL_CREDS)
+# if defined(HAVE_CONST_LOCAL_CREDS)
+# define LOCAL_CREDS LOCAL_CREDS
+# endif
+#endif
+#if !defined(LOCAL_CONNWAIT)
+# if defined(HAVE_CONST_LOCAL_CONNWAIT)
+# define LOCAL_CONNWAIT LOCAL_CONNWAIT
+# endif
+#endif
+#if !defined(IFF_802_1Q_VLAN)
+# if defined(HAVE_CONST_IFF_802_1Q_VLAN)
+# define IFF_802_1Q_VLAN IFF_802_1Q_VLAN
+# endif
+#endif
+#if !defined(IFF_ALLMULTI)
+# if defined(HAVE_CONST_IFF_ALLMULTI)
+# define IFF_ALLMULTI IFF_ALLMULTI
+# endif
+#endif
+#if !defined(IFF_ALTPHYS)
+# if defined(HAVE_CONST_IFF_ALTPHYS)
+# define IFF_ALTPHYS IFF_ALTPHYS
+# endif
+#endif
+#if !defined(IFF_AUTOMEDIA)
+# if defined(HAVE_CONST_IFF_AUTOMEDIA)
+# define IFF_AUTOMEDIA IFF_AUTOMEDIA
+# endif
+#endif
+#if !defined(IFF_BONDING)
+# if defined(HAVE_CONST_IFF_BONDING)
+# define IFF_BONDING IFF_BONDING
+# endif
+#endif
+#if !defined(IFF_BRIDGE_PORT)
+# if defined(HAVE_CONST_IFF_BRIDGE_PORT)
+# define IFF_BRIDGE_PORT IFF_BRIDGE_PORT
+# endif
+#endif
+#if !defined(IFF_BROADCAST)
+# if defined(HAVE_CONST_IFF_BROADCAST)
+# define IFF_BROADCAST IFF_BROADCAST
+# endif
+#endif
+#if !defined(IFF_CANTCONFIG)
+# if defined(HAVE_CONST_IFF_CANTCONFIG)
+# define IFF_CANTCONFIG IFF_CANTCONFIG
+# endif
+#endif
+#if !defined(IFF_DEBUG)
+# if defined(HAVE_CONST_IFF_DEBUG)
+# define IFF_DEBUG IFF_DEBUG
+# endif
+#endif
+#if !defined(IFF_DISABLE_NETPOLL)
+# if defined(HAVE_CONST_IFF_DISABLE_NETPOLL)
+# define IFF_DISABLE_NETPOLL IFF_DISABLE_NETPOLL
+# endif
+#endif
+#if !defined(IFF_DONT_BRIDGE)
+# if defined(HAVE_CONST_IFF_DONT_BRIDGE)
+# define IFF_DONT_BRIDGE IFF_DONT_BRIDGE
+# endif
+#endif
+#if !defined(IFF_DORMANT)
+# if defined(HAVE_CONST_IFF_DORMANT)
+# define IFF_DORMANT IFF_DORMANT
+# endif
+#endif
+#if !defined(IFF_DRV_OACTIVE)
+# if defined(HAVE_CONST_IFF_DRV_OACTIVE)
+# define IFF_DRV_OACTIVE IFF_DRV_OACTIVE
+# endif
+#endif
+#if !defined(IFF_DRV_RUNNING)
+# if defined(HAVE_CONST_IFF_DRV_RUNNING)
+# define IFF_DRV_RUNNING IFF_DRV_RUNNING
+# endif
+#endif
+#if !defined(IFF_DYING)
+# if defined(HAVE_CONST_IFF_DYING)
+# define IFF_DYING IFF_DYING
+# endif
+#endif
+#if !defined(IFF_DYNAMIC)
+# if defined(HAVE_CONST_IFF_DYNAMIC)
+# define IFF_DYNAMIC IFF_DYNAMIC
+# endif
+#endif
+#if !defined(IFF_EBRIDGE)
+# if defined(HAVE_CONST_IFF_EBRIDGE)
+# define IFF_EBRIDGE IFF_EBRIDGE
+# endif
+#endif
+#if !defined(IFF_ECHO)
+# if defined(HAVE_CONST_IFF_ECHO)
+# define IFF_ECHO IFF_ECHO
+# endif
+#endif
+#if !defined(IFF_ISATAP)
+# if defined(HAVE_CONST_IFF_ISATAP)
+# define IFF_ISATAP IFF_ISATAP
+# endif
+#endif
+#if !defined(IFF_LINK0)
+# if defined(HAVE_CONST_IFF_LINK0)
+# define IFF_LINK0 IFF_LINK0
+# endif
+#endif
+#if !defined(IFF_LINK1)
+# if defined(HAVE_CONST_IFF_LINK1)
+# define IFF_LINK1 IFF_LINK1
+# endif
+#endif
+#if !defined(IFF_LINK2)
+# if defined(HAVE_CONST_IFF_LINK2)
+# define IFF_LINK2 IFF_LINK2
+# endif
+#endif
+#if !defined(IFF_LIVE_ADDR_CHANGE)
+# if defined(HAVE_CONST_IFF_LIVE_ADDR_CHANGE)
+# define IFF_LIVE_ADDR_CHANGE IFF_LIVE_ADDR_CHANGE
+# endif
+#endif
+#if !defined(IFF_LOOPBACK)
+# if defined(HAVE_CONST_IFF_LOOPBACK)
+# define IFF_LOOPBACK IFF_LOOPBACK
+# endif
+#endif
+#if !defined(IFF_LOWER_UP)
+# if defined(HAVE_CONST_IFF_LOWER_UP)
+# define IFF_LOWER_UP IFF_LOWER_UP
+# endif
+#endif
+#if !defined(IFF_MACVLAN_PORT)
+# if defined(HAVE_CONST_IFF_MACVLAN_PORT)
+# define IFF_MACVLAN_PORT IFF_MACVLAN_PORT
+# endif
+#endif
+#if !defined(IFF_MASTER)
+# if defined(HAVE_CONST_IFF_MASTER)
+# define IFF_MASTER IFF_MASTER
+# endif
+#endif
+#if !defined(IFF_MASTER_8023AD)
+# if defined(HAVE_CONST_IFF_MASTER_8023AD)
+# define IFF_MASTER_8023AD IFF_MASTER_8023AD
+# endif
+#endif
+#if !defined(IFF_MASTER_ALB)
+# if defined(HAVE_CONST_IFF_MASTER_ALB)
+# define IFF_MASTER_ALB IFF_MASTER_ALB
+# endif
+#endif
+#if !defined(IFF_MASTER_ARPMON)
+# if defined(HAVE_CONST_IFF_MASTER_ARPMON)
+# define IFF_MASTER_ARPMON IFF_MASTER_ARPMON
+# endif
+#endif
+#if !defined(IFF_MONITOR)
+# if defined(HAVE_CONST_IFF_MONITOR)
+# define IFF_MONITOR IFF_MONITOR
+# endif
+#endif
+#if !defined(IFF_MULTICAST)
+# if defined(HAVE_CONST_IFF_MULTICAST)
+# define IFF_MULTICAST IFF_MULTICAST
+# endif
+#endif
+#if !defined(IFF_NOARP)
+# if defined(HAVE_CONST_IFF_NOARP)
+# define IFF_NOARP IFF_NOARP
+# endif
+#endif
+#if !defined(IFF_NOTRAILERS)
+# if defined(HAVE_CONST_IFF_NOTRAILERS)
+# define IFF_NOTRAILERS IFF_NOTRAILERS
+# endif
+#endif
+#if !defined(IFF_OACTIVE)
+# if defined(HAVE_CONST_IFF_OACTIVE)
+# define IFF_OACTIVE IFF_OACTIVE
+# endif
+#endif
+#if !defined(IFF_OVS_DATAPATH)
+# if defined(HAVE_CONST_IFF_OVS_DATAPATH)
+# define IFF_OVS_DATAPATH IFF_OVS_DATAPATH
+# endif
+#endif
+#if !defined(IFF_POINTOPOINT)
+# if defined(HAVE_CONST_IFF_POINTOPOINT)
+# define IFF_POINTOPOINT IFF_POINTOPOINT
+# endif
+#endif
+#if !defined(IFF_PORTSEL)
+# if defined(HAVE_CONST_IFF_PORTSEL)
+# define IFF_PORTSEL IFF_PORTSEL
+# endif
+#endif
+#if !defined(IFF_PPROMISC)
+# if defined(HAVE_CONST_IFF_PPROMISC)
+# define IFF_PPROMISC IFF_PPROMISC
+# endif
+#endif
+#if !defined(IFF_PROMISC)
+# if defined(HAVE_CONST_IFF_PROMISC)
+# define IFF_PROMISC IFF_PROMISC
+# endif
+#endif
+#if !defined(IFF_RENAMING)
+# if defined(HAVE_CONST_IFF_RENAMING)
+# define IFF_RENAMING IFF_RENAMING
+# endif
+#endif
+#if !defined(IFF_ROUTE)
+# if defined(HAVE_CONST_IFF_ROUTE)
+# define IFF_ROUTE IFF_ROUTE
+# endif
+#endif
+#if !defined(IFF_RUNNING)
+# if defined(HAVE_CONST_IFF_RUNNING)
+# define IFF_RUNNING IFF_RUNNING
+# endif
+#endif
+#if !defined(IFF_SIMPLEX)
+# if defined(HAVE_CONST_IFF_SIMPLEX)
+# define IFF_SIMPLEX IFF_SIMPLEX
+# endif
+#endif
+#if !defined(IFF_SLAVE)
+# if defined(HAVE_CONST_IFF_SLAVE)
+# define IFF_SLAVE IFF_SLAVE
+# endif
+#endif
+#if !defined(IFF_SLAVE_INACTIVE)
+# if defined(HAVE_CONST_IFF_SLAVE_INACTIVE)
+# define IFF_SLAVE_INACTIVE IFF_SLAVE_INACTIVE
+# endif
+#endif
+#if !defined(IFF_SLAVE_NEEDARP)
+# if defined(HAVE_CONST_IFF_SLAVE_NEEDARP)
+# define IFF_SLAVE_NEEDARP IFF_SLAVE_NEEDARP
+# endif
+#endif
+#if !defined(IFF_SMART)
+# if defined(HAVE_CONST_IFF_SMART)
+# define IFF_SMART IFF_SMART
+# endif
+#endif
+#if !defined(IFF_STATICARP)
+# if defined(HAVE_CONST_IFF_STATICARP)
+# define IFF_STATICARP IFF_STATICARP
+# endif
+#endif
+#if !defined(IFF_SUPP_NOFCS)
+# if defined(HAVE_CONST_IFF_SUPP_NOFCS)
+# define IFF_SUPP_NOFCS IFF_SUPP_NOFCS
+# endif
+#endif
+#if !defined(IFF_TEAM_PORT)
+# if defined(HAVE_CONST_IFF_TEAM_PORT)
+# define IFF_TEAM_PORT IFF_TEAM_PORT
+# endif
+#endif
+#if !defined(IFF_TX_SKB_SHARING)
+# if defined(HAVE_CONST_IFF_TX_SKB_SHARING)
+# define IFF_TX_SKB_SHARING IFF_TX_SKB_SHARING
+# endif
+#endif
+#if !defined(IFF_UNICAST_FLT)
+# if defined(HAVE_CONST_IFF_UNICAST_FLT)
+# define IFF_UNICAST_FLT IFF_UNICAST_FLT
+# endif
+#endif
+#if !defined(IFF_UP)
+# if defined(HAVE_CONST_IFF_UP)
+# define IFF_UP IFF_UP
+# endif
+#endif
+#if !defined(IFF_WAN_HDLC)
+# if defined(HAVE_CONST_IFF_WAN_HDLC)
+# define IFF_WAN_HDLC IFF_WAN_HDLC
+# endif
+#endif
+#if !defined(IFF_XMIT_DST_RELEASE)
+# if defined(HAVE_CONST_IFF_XMIT_DST_RELEASE)
+# define IFF_XMIT_DST_RELEASE IFF_XMIT_DST_RELEASE
+# endif
+#endif
+#if !defined(IFF_VOLATILE)
+# if defined(HAVE_CONST_IFF_VOLATILE)
+# define IFF_VOLATILE IFF_VOLATILE
+# endif
+#endif
+#if !defined(IFF_CANTCHANGE)
+# if defined(HAVE_CONST_IFF_CANTCHANGE)
+# define IFF_CANTCHANGE IFF_CANTCHANGE
+# endif
+#endif
+
+int rsock_family_to_int(const char *str, long len, int *valp);
+
+int rsock_socktype_to_int(const char *str, long len, int *valp);
+
+int rsock_ipproto_to_int(const char *str, long len, int *valp);
+
+int rsock_unknown_level_to_int(const char *str, long len, int *valp);
+
+int rsock_ip_level_to_int(const char *str, long len, int *valp);
+
+int rsock_so_optname_to_int(const char *str, long len, int *valp);
+
+int rsock_ip_optname_to_int(const char *str, long len, int *valp);
+
+#ifdef IPPROTO_IPV6
+int rsock_ipv6_optname_to_int(const char *str, long len, int *valp);
+#endif
+
+int rsock_tcp_optname_to_int(const char *str, long len, int *valp);
+
+int rsock_udp_optname_to_int(const char *str, long len, int *valp);
+
+int rsock_shutdown_how_to_int(const char *str, long len, int *valp);
+
+int rsock_scm_optname_to_int(const char *str, long len, int *valp);
+
+ID rsock_intern_family(int val);
+
+ID rsock_intern_family_noprefix(int val);
+
+ID rsock_intern_protocol_family(int val);
+
+ID rsock_intern_socktype(int val);
+
+ID rsock_intern_ipproto(int val);
+
+ID rsock_intern_iplevel(int val);
+
+ID rsock_intern_so_optname(int val);
+
+ID rsock_intern_ip_optname(int val);
+
+ID rsock_intern_ipv6_optname(int val);
+
+ID rsock_intern_tcp_optname(int val);
+
+ID rsock_intern_udp_optname(int val);
+
+ID rsock_intern_scm_optname(int val);
+
+ID rsock_intern_local_optname(int val);
+
diff --git a/jni/ruby/ext/socket/depend b/jni/ruby/ext/socket/depend
new file mode 100644
index 0000000..30ecfc5
--- /dev/null
+++ b/jni/ruby/ext/socket/depend
@@ -0,0 +1,295 @@
+getnameinfo.o: getnameinfo.c $(arch_hdrdir)/ruby/config.h addrinfo.h sockport.h
+getaddrinfo.o: getaddrinfo.c $(arch_hdrdir)/ruby/config.h addrinfo.h sockport.h
+
+constdefs.h constdefs.c : $(srcdir)/mkconstants.rb
+ @echo "generating constant definitions"
+ @$(RUBY) $(srcdir)/mkconstants.rb -H constdefs.h -o constdefs.c
+
+# AUTOGENERATED DEPENDENCIES START
+ancdata.o: $(RUBY_EXTCONF_H)
+ancdata.o: $(arch_hdrdir)/ruby/config.h
+ancdata.o: $(hdrdir)/ruby/defines.h
+ancdata.o: $(hdrdir)/ruby/encoding.h
+ancdata.o: $(hdrdir)/ruby/intern.h
+ancdata.o: $(hdrdir)/ruby/io.h
+ancdata.o: $(hdrdir)/ruby/missing.h
+ancdata.o: $(hdrdir)/ruby/oniguruma.h
+ancdata.o: $(hdrdir)/ruby/ruby.h
+ancdata.o: $(hdrdir)/ruby/st.h
+ancdata.o: $(hdrdir)/ruby/subst.h
+ancdata.o: $(hdrdir)/ruby/thread.h
+ancdata.o: $(hdrdir)/ruby/util.h
+ancdata.o: $(top_srcdir)/include/ruby.h
+ancdata.o: $(top_srcdir)/internal.h
+ancdata.o: ancdata.c
+ancdata.o: constdefs.h
+ancdata.o: rubysocket.h
+ancdata.o: sockport.h
+basicsocket.o: $(RUBY_EXTCONF_H)
+basicsocket.o: $(arch_hdrdir)/ruby/config.h
+basicsocket.o: $(hdrdir)/ruby/defines.h
+basicsocket.o: $(hdrdir)/ruby/encoding.h
+basicsocket.o: $(hdrdir)/ruby/intern.h
+basicsocket.o: $(hdrdir)/ruby/io.h
+basicsocket.o: $(hdrdir)/ruby/missing.h
+basicsocket.o: $(hdrdir)/ruby/oniguruma.h
+basicsocket.o: $(hdrdir)/ruby/ruby.h
+basicsocket.o: $(hdrdir)/ruby/st.h
+basicsocket.o: $(hdrdir)/ruby/subst.h
+basicsocket.o: $(hdrdir)/ruby/thread.h
+basicsocket.o: $(hdrdir)/ruby/util.h
+basicsocket.o: $(top_srcdir)/include/ruby.h
+basicsocket.o: $(top_srcdir)/internal.h
+basicsocket.o: basicsocket.c
+basicsocket.o: constdefs.h
+basicsocket.o: rubysocket.h
+basicsocket.o: sockport.h
+constants.o: $(RUBY_EXTCONF_H)
+constants.o: $(arch_hdrdir)/ruby/config.h
+constants.o: $(hdrdir)/ruby/defines.h
+constants.o: $(hdrdir)/ruby/encoding.h
+constants.o: $(hdrdir)/ruby/intern.h
+constants.o: $(hdrdir)/ruby/io.h
+constants.o: $(hdrdir)/ruby/missing.h
+constants.o: $(hdrdir)/ruby/oniguruma.h
+constants.o: $(hdrdir)/ruby/ruby.h
+constants.o: $(hdrdir)/ruby/st.h
+constants.o: $(hdrdir)/ruby/subst.h
+constants.o: $(hdrdir)/ruby/thread.h
+constants.o: $(hdrdir)/ruby/util.h
+constants.o: $(top_srcdir)/include/ruby.h
+constants.o: $(top_srcdir)/internal.h
+constants.o: constants.c
+constants.o: constdefs.c
+constants.o: constdefs.h
+constants.o: rubysocket.h
+constants.o: sockport.h
+ifaddr.o: $(RUBY_EXTCONF_H)
+ifaddr.o: $(arch_hdrdir)/ruby/config.h
+ifaddr.o: $(hdrdir)/ruby/defines.h
+ifaddr.o: $(hdrdir)/ruby/encoding.h
+ifaddr.o: $(hdrdir)/ruby/intern.h
+ifaddr.o: $(hdrdir)/ruby/io.h
+ifaddr.o: $(hdrdir)/ruby/missing.h
+ifaddr.o: $(hdrdir)/ruby/oniguruma.h
+ifaddr.o: $(hdrdir)/ruby/ruby.h
+ifaddr.o: $(hdrdir)/ruby/st.h
+ifaddr.o: $(hdrdir)/ruby/subst.h
+ifaddr.o: $(hdrdir)/ruby/thread.h
+ifaddr.o: $(hdrdir)/ruby/util.h
+ifaddr.o: $(top_srcdir)/include/ruby.h
+ifaddr.o: $(top_srcdir)/internal.h
+ifaddr.o: constdefs.h
+ifaddr.o: ifaddr.c
+ifaddr.o: rubysocket.h
+ifaddr.o: sockport.h
+init.o: $(RUBY_EXTCONF_H)
+init.o: $(arch_hdrdir)/ruby/config.h
+init.o: $(hdrdir)/ruby/defines.h
+init.o: $(hdrdir)/ruby/encoding.h
+init.o: $(hdrdir)/ruby/intern.h
+init.o: $(hdrdir)/ruby/io.h
+init.o: $(hdrdir)/ruby/missing.h
+init.o: $(hdrdir)/ruby/oniguruma.h
+init.o: $(hdrdir)/ruby/ruby.h
+init.o: $(hdrdir)/ruby/st.h
+init.o: $(hdrdir)/ruby/subst.h
+init.o: $(hdrdir)/ruby/thread.h
+init.o: $(hdrdir)/ruby/util.h
+init.o: $(top_srcdir)/include/ruby.h
+init.o: $(top_srcdir)/internal.h
+init.o: constdefs.h
+init.o: init.c
+init.o: rubysocket.h
+init.o: sockport.h
+ipsocket.o: $(RUBY_EXTCONF_H)
+ipsocket.o: $(arch_hdrdir)/ruby/config.h
+ipsocket.o: $(hdrdir)/ruby/defines.h
+ipsocket.o: $(hdrdir)/ruby/encoding.h
+ipsocket.o: $(hdrdir)/ruby/intern.h
+ipsocket.o: $(hdrdir)/ruby/io.h
+ipsocket.o: $(hdrdir)/ruby/missing.h
+ipsocket.o: $(hdrdir)/ruby/oniguruma.h
+ipsocket.o: $(hdrdir)/ruby/ruby.h
+ipsocket.o: $(hdrdir)/ruby/st.h
+ipsocket.o: $(hdrdir)/ruby/subst.h
+ipsocket.o: $(hdrdir)/ruby/thread.h
+ipsocket.o: $(hdrdir)/ruby/util.h
+ipsocket.o: $(top_srcdir)/include/ruby.h
+ipsocket.o: $(top_srcdir)/internal.h
+ipsocket.o: constdefs.h
+ipsocket.o: ipsocket.c
+ipsocket.o: rubysocket.h
+ipsocket.o: sockport.h
+option.o: $(RUBY_EXTCONF_H)
+option.o: $(arch_hdrdir)/ruby/config.h
+option.o: $(hdrdir)/ruby/defines.h
+option.o: $(hdrdir)/ruby/encoding.h
+option.o: $(hdrdir)/ruby/intern.h
+option.o: $(hdrdir)/ruby/io.h
+option.o: $(hdrdir)/ruby/missing.h
+option.o: $(hdrdir)/ruby/oniguruma.h
+option.o: $(hdrdir)/ruby/ruby.h
+option.o: $(hdrdir)/ruby/st.h
+option.o: $(hdrdir)/ruby/subst.h
+option.o: $(hdrdir)/ruby/thread.h
+option.o: $(hdrdir)/ruby/util.h
+option.o: $(top_srcdir)/include/ruby.h
+option.o: $(top_srcdir)/internal.h
+option.o: constdefs.h
+option.o: option.c
+option.o: rubysocket.h
+option.o: sockport.h
+raddrinfo.o: $(RUBY_EXTCONF_H)
+raddrinfo.o: $(arch_hdrdir)/ruby/config.h
+raddrinfo.o: $(hdrdir)/ruby/defines.h
+raddrinfo.o: $(hdrdir)/ruby/encoding.h
+raddrinfo.o: $(hdrdir)/ruby/intern.h
+raddrinfo.o: $(hdrdir)/ruby/io.h
+raddrinfo.o: $(hdrdir)/ruby/missing.h
+raddrinfo.o: $(hdrdir)/ruby/oniguruma.h
+raddrinfo.o: $(hdrdir)/ruby/ruby.h
+raddrinfo.o: $(hdrdir)/ruby/st.h
+raddrinfo.o: $(hdrdir)/ruby/subst.h
+raddrinfo.o: $(hdrdir)/ruby/thread.h
+raddrinfo.o: $(hdrdir)/ruby/util.h
+raddrinfo.o: $(top_srcdir)/include/ruby.h
+raddrinfo.o: $(top_srcdir)/internal.h
+raddrinfo.o: constdefs.h
+raddrinfo.o: raddrinfo.c
+raddrinfo.o: rubysocket.h
+raddrinfo.o: sockport.h
+socket.o: $(RUBY_EXTCONF_H)
+socket.o: $(arch_hdrdir)/ruby/config.h
+socket.o: $(hdrdir)/ruby/defines.h
+socket.o: $(hdrdir)/ruby/encoding.h
+socket.o: $(hdrdir)/ruby/intern.h
+socket.o: $(hdrdir)/ruby/io.h
+socket.o: $(hdrdir)/ruby/missing.h
+socket.o: $(hdrdir)/ruby/oniguruma.h
+socket.o: $(hdrdir)/ruby/ruby.h
+socket.o: $(hdrdir)/ruby/st.h
+socket.o: $(hdrdir)/ruby/subst.h
+socket.o: $(hdrdir)/ruby/thread.h
+socket.o: $(hdrdir)/ruby/util.h
+socket.o: $(top_srcdir)/include/ruby.h
+socket.o: $(top_srcdir)/internal.h
+socket.o: constdefs.h
+socket.o: rubysocket.h
+socket.o: socket.c
+socket.o: sockport.h
+sockssocket.o: $(RUBY_EXTCONF_H)
+sockssocket.o: $(arch_hdrdir)/ruby/config.h
+sockssocket.o: $(hdrdir)/ruby/defines.h
+sockssocket.o: $(hdrdir)/ruby/encoding.h
+sockssocket.o: $(hdrdir)/ruby/intern.h
+sockssocket.o: $(hdrdir)/ruby/io.h
+sockssocket.o: $(hdrdir)/ruby/missing.h
+sockssocket.o: $(hdrdir)/ruby/oniguruma.h
+sockssocket.o: $(hdrdir)/ruby/ruby.h
+sockssocket.o: $(hdrdir)/ruby/st.h
+sockssocket.o: $(hdrdir)/ruby/subst.h
+sockssocket.o: $(hdrdir)/ruby/thread.h
+sockssocket.o: $(hdrdir)/ruby/util.h
+sockssocket.o: $(top_srcdir)/include/ruby.h
+sockssocket.o: $(top_srcdir)/internal.h
+sockssocket.o: constdefs.h
+sockssocket.o: rubysocket.h
+sockssocket.o: sockport.h
+sockssocket.o: sockssocket.c
+tcpserver.o: $(RUBY_EXTCONF_H)
+tcpserver.o: $(arch_hdrdir)/ruby/config.h
+tcpserver.o: $(hdrdir)/ruby/defines.h
+tcpserver.o: $(hdrdir)/ruby/encoding.h
+tcpserver.o: $(hdrdir)/ruby/intern.h
+tcpserver.o: $(hdrdir)/ruby/io.h
+tcpserver.o: $(hdrdir)/ruby/missing.h
+tcpserver.o: $(hdrdir)/ruby/oniguruma.h
+tcpserver.o: $(hdrdir)/ruby/ruby.h
+tcpserver.o: $(hdrdir)/ruby/st.h
+tcpserver.o: $(hdrdir)/ruby/subst.h
+tcpserver.o: $(hdrdir)/ruby/thread.h
+tcpserver.o: $(hdrdir)/ruby/util.h
+tcpserver.o: $(top_srcdir)/include/ruby.h
+tcpserver.o: $(top_srcdir)/internal.h
+tcpserver.o: constdefs.h
+tcpserver.o: rubysocket.h
+tcpserver.o: sockport.h
+tcpserver.o: tcpserver.c
+tcpsocket.o: $(RUBY_EXTCONF_H)
+tcpsocket.o: $(arch_hdrdir)/ruby/config.h
+tcpsocket.o: $(hdrdir)/ruby/defines.h
+tcpsocket.o: $(hdrdir)/ruby/encoding.h
+tcpsocket.o: $(hdrdir)/ruby/intern.h
+tcpsocket.o: $(hdrdir)/ruby/io.h
+tcpsocket.o: $(hdrdir)/ruby/missing.h
+tcpsocket.o: $(hdrdir)/ruby/oniguruma.h
+tcpsocket.o: $(hdrdir)/ruby/ruby.h
+tcpsocket.o: $(hdrdir)/ruby/st.h
+tcpsocket.o: $(hdrdir)/ruby/subst.h
+tcpsocket.o: $(hdrdir)/ruby/thread.h
+tcpsocket.o: $(hdrdir)/ruby/util.h
+tcpsocket.o: $(top_srcdir)/include/ruby.h
+tcpsocket.o: $(top_srcdir)/internal.h
+tcpsocket.o: constdefs.h
+tcpsocket.o: rubysocket.h
+tcpsocket.o: sockport.h
+tcpsocket.o: tcpsocket.c
+udpsocket.o: $(RUBY_EXTCONF_H)
+udpsocket.o: $(arch_hdrdir)/ruby/config.h
+udpsocket.o: $(hdrdir)/ruby/defines.h
+udpsocket.o: $(hdrdir)/ruby/encoding.h
+udpsocket.o: $(hdrdir)/ruby/intern.h
+udpsocket.o: $(hdrdir)/ruby/io.h
+udpsocket.o: $(hdrdir)/ruby/missing.h
+udpsocket.o: $(hdrdir)/ruby/oniguruma.h
+udpsocket.o: $(hdrdir)/ruby/ruby.h
+udpsocket.o: $(hdrdir)/ruby/st.h
+udpsocket.o: $(hdrdir)/ruby/subst.h
+udpsocket.o: $(hdrdir)/ruby/thread.h
+udpsocket.o: $(hdrdir)/ruby/util.h
+udpsocket.o: $(top_srcdir)/include/ruby.h
+udpsocket.o: $(top_srcdir)/internal.h
+udpsocket.o: constdefs.h
+udpsocket.o: rubysocket.h
+udpsocket.o: sockport.h
+udpsocket.o: udpsocket.c
+unixserver.o: $(RUBY_EXTCONF_H)
+unixserver.o: $(arch_hdrdir)/ruby/config.h
+unixserver.o: $(hdrdir)/ruby/defines.h
+unixserver.o: $(hdrdir)/ruby/encoding.h
+unixserver.o: $(hdrdir)/ruby/intern.h
+unixserver.o: $(hdrdir)/ruby/io.h
+unixserver.o: $(hdrdir)/ruby/missing.h
+unixserver.o: $(hdrdir)/ruby/oniguruma.h
+unixserver.o: $(hdrdir)/ruby/ruby.h
+unixserver.o: $(hdrdir)/ruby/st.h
+unixserver.o: $(hdrdir)/ruby/subst.h
+unixserver.o: $(hdrdir)/ruby/thread.h
+unixserver.o: $(hdrdir)/ruby/util.h
+unixserver.o: $(top_srcdir)/include/ruby.h
+unixserver.o: $(top_srcdir)/internal.h
+unixserver.o: constdefs.h
+unixserver.o: rubysocket.h
+unixserver.o: sockport.h
+unixserver.o: unixserver.c
+unixsocket.o: $(RUBY_EXTCONF_H)
+unixsocket.o: $(arch_hdrdir)/ruby/config.h
+unixsocket.o: $(hdrdir)/ruby/defines.h
+unixsocket.o: $(hdrdir)/ruby/encoding.h
+unixsocket.o: $(hdrdir)/ruby/intern.h
+unixsocket.o: $(hdrdir)/ruby/io.h
+unixsocket.o: $(hdrdir)/ruby/missing.h
+unixsocket.o: $(hdrdir)/ruby/oniguruma.h
+unixsocket.o: $(hdrdir)/ruby/ruby.h
+unixsocket.o: $(hdrdir)/ruby/st.h
+unixsocket.o: $(hdrdir)/ruby/subst.h
+unixsocket.o: $(hdrdir)/ruby/thread.h
+unixsocket.o: $(hdrdir)/ruby/util.h
+unixsocket.o: $(top_srcdir)/include/ruby.h
+unixsocket.o: $(top_srcdir)/internal.h
+unixsocket.o: constdefs.h
+unixsocket.o: rubysocket.h
+unixsocket.o: sockport.h
+unixsocket.o: unixsocket.c
+# AUTOGENERATED DEPENDENCIES END
diff --git a/jni/ruby/ext/socket/extconf.h b/jni/ruby/ext/socket/extconf.h
new file mode 100644
index 0000000..9386b20
--- /dev/null
+++ b/jni/ruby/ext/socket/extconf.h
@@ -0,0 +1,127 @@
+#ifndef EXTCONF_H
+#define EXTCONF_H
+#define HAVE_SYS_UIO_H 1
+#define HAVE_NETINET_IN_SYSTM_H 1
+#define HAVE_NETINET_TCP_H 1
+#define HAVE_NETINET_UDP_H 1
+#define HAVE_ARPA_INET_H 1
+#define HAVE_NETPACKET_PACKET_H 1
+#define HAVE_NET_ETHERNET_H 1
+#define HAVE_SYS_UN_H 1
+#define HAVE_IFADDRS_H 1
+#define HAVE_SYS_IOCTL_H 1
+#define HAVE_NET_IF_H 1
+#define HAVE_SYS_PARAM_H 1
+#define HAVE_ARPA_NAMESER_H 1
+#define HAVE_RESOLV_H 1
+#define HAVE_TYPE_STRUCT_SOCKADDR_UN 1
+#define HAVE_TYPE_STRUCT_SOCKADDR_STORAGE 1
+#define HAVE_TYPE_STRUCT_ADDRINFO 1
+#define HAVE_TYPE_SOCKLEN_T 1
+#define HAVE_TYPE_STRUCT_IN_PKTINFO 1
+#define HAVE_STRUCT_IN_PKTINFO_IPI_SPEC_DST 1
+#define HAVE_ST_IPI_SPEC_DST 1
+#define HAVE_TYPE_STRUCT_IN6_PKTINFO 1
+#define HAVE_TYPE_STRUCT_IP_MREQ 1
+#define HAVE_TYPE_STRUCT_IP_MREQN 1
+#define HAVE_TYPE_STRUCT_IPV6_MREQ 1
+#define HAVE_STRUCT_MSGHDR_MSG_CONTROL 1
+#define HAVE_ST_MSG_CONTROL 1
+#define HAVE_TYPE_STRUCT_TCP_INFO 1
+#define HAVE_CONST_TCP_ESTABLISHED 1
+#define HAVE_CONST_TCP_SYN_SENT 1
+#define HAVE_CONST_TCP_SYN_RECV 1
+#define HAVE_CONST_TCP_FIN_WAIT1 1
+#define HAVE_CONST_TCP_FIN_WAIT2 1
+#define HAVE_CONST_TCP_TIME_WAIT 1
+#define HAVE_CONST_TCP_CLOSE 1
+#define HAVE_CONST_TCP_CLOSE_WAIT 1
+#define HAVE_CONST_TCP_LAST_ACK 1
+#define HAVE_CONST_TCP_LISTEN 1
+#define HAVE_CONST_TCP_CLOSING 1
+#define HAVE_STRUCT_TCP_INFO_TCPI_STATE 1
+#define HAVE_ST_TCPI_STATE 1
+#define HAVE_STRUCT_TCP_INFO_TCPI_CA_STATE 1
+#define HAVE_ST_TCPI_CA_STATE 1
+#define HAVE_STRUCT_TCP_INFO_TCPI_RETRANSMITS 1
+#define HAVE_ST_TCPI_RETRANSMITS 1
+#define HAVE_STRUCT_TCP_INFO_TCPI_PROBES 1
+#define HAVE_ST_TCPI_PROBES 1
+#define HAVE_STRUCT_TCP_INFO_TCPI_BACKOFF 1
+#define HAVE_ST_TCPI_BACKOFF 1
+#define HAVE_STRUCT_TCP_INFO_TCPI_OPTIONS 1
+#define HAVE_ST_TCPI_OPTIONS 1
+#define HAVE_STRUCT_TCP_INFO_TCPI_RTO 1
+#define HAVE_ST_TCPI_RTO 1
+#define HAVE_STRUCT_TCP_INFO_TCPI_ATO 1
+#define HAVE_ST_TCPI_ATO 1
+#define HAVE_STRUCT_TCP_INFO_TCPI_SND_MSS 1
+#define HAVE_ST_TCPI_SND_MSS 1
+#define HAVE_STRUCT_TCP_INFO_TCPI_RCV_MSS 1
+#define HAVE_ST_TCPI_RCV_MSS 1
+#define HAVE_STRUCT_TCP_INFO_TCPI_UNACKED 1
+#define HAVE_ST_TCPI_UNACKED 1
+#define HAVE_STRUCT_TCP_INFO_TCPI_SACKED 1
+#define HAVE_ST_TCPI_SACKED 1
+#define HAVE_STRUCT_TCP_INFO_TCPI_LOST 1
+#define HAVE_ST_TCPI_LOST 1
+#define HAVE_STRUCT_TCP_INFO_TCPI_RETRANS 1
+#define HAVE_ST_TCPI_RETRANS 1
+#define HAVE_STRUCT_TCP_INFO_TCPI_FACKETS 1
+#define HAVE_ST_TCPI_FACKETS 1
+#define HAVE_STRUCT_TCP_INFO_TCPI_LAST_DATA_SENT 1
+#define HAVE_ST_TCPI_LAST_DATA_SENT 1
+#define HAVE_STRUCT_TCP_INFO_TCPI_LAST_ACK_SENT 1
+#define HAVE_ST_TCPI_LAST_ACK_SENT 1
+#define HAVE_STRUCT_TCP_INFO_TCPI_LAST_DATA_RECV 1
+#define HAVE_ST_TCPI_LAST_DATA_RECV 1
+#define HAVE_STRUCT_TCP_INFO_TCPI_LAST_ACK_RECV 1
+#define HAVE_ST_TCPI_LAST_ACK_RECV 1
+#define HAVE_STRUCT_TCP_INFO_TCPI_PMTU 1
+#define HAVE_ST_TCPI_PMTU 1
+#define HAVE_STRUCT_TCP_INFO_TCPI_RCV_SSTHRESH 1
+#define HAVE_ST_TCPI_RCV_SSTHRESH 1
+#define HAVE_STRUCT_TCP_INFO_TCPI_RTT 1
+#define HAVE_ST_TCPI_RTT 1
+#define HAVE_STRUCT_TCP_INFO_TCPI_RTTVAR 1
+#define HAVE_ST_TCPI_RTTVAR 1
+#define HAVE_STRUCT_TCP_INFO_TCPI_SND_SSTHRESH 1
+#define HAVE_ST_TCPI_SND_SSTHRESH 1
+#define HAVE_STRUCT_TCP_INFO_TCPI_SND_CWND 1
+#define HAVE_ST_TCPI_SND_CWND 1
+#define HAVE_STRUCT_TCP_INFO_TCPI_ADVMSS 1
+#define HAVE_ST_TCPI_ADVMSS 1
+#define HAVE_STRUCT_TCP_INFO_TCPI_REORDERING 1
+#define HAVE_ST_TCPI_REORDERING 1
+#define HAVE_STRUCT_TCP_INFO_TCPI_RCV_RTT 1
+#define HAVE_ST_TCPI_RCV_RTT 1
+#define HAVE_STRUCT_TCP_INFO_TCPI_RCV_SPACE 1
+#define HAVE_ST_TCPI_RCV_SPACE 1
+#define HAVE_STRUCT_TCP_INFO_TCPI_TOTAL_RETRANS 1
+#define HAVE_ST_TCPI_TOTAL_RETRANS 1
+#define HAVE_SOCKET 1
+#define HAVE_SENDMSG 1
+#define HAVE_RECVMSG 1
+#define HAVE_FREEADDRINFO 1
+#define HAVE_GAI_STRERROR 1
+#define GAI_STRERROR_CONST 1
+#define HAVE_ACCEPT4 1
+#define HAVE_INET_NTOP 1
+#define HAVE_INET_PTON 1
+#define HAVE_GETSERVBYPORT 1
+#define HAVE_GETIFADDRS 1
+#define HAVE_IF_INDEXTONAME 1
+#define NEED_IF_INDEXTONAME_DECL 1
+#define HAVE_IF_NAMETOINDEX 1
+#define NEED_IF_NAMETOINDEX_DECL 1
+#define HAVE_GETHOSTBYNAME2 1
+#define HAVE_SOCKETPAIR 1
+#define HAVE_GETHOSTNAME 1
+#define ENABLE_IPV6 1
+#define INET6 1
+#define HAVE_CONST_AF_UNIX 1
+#define HAVE_CONST_SCM_RIGHTS 1
+#define FD_PASSING_WORK_WITH_RECVMSG_MSG_PEEK 1
+#define HAVE_GETNAMEINFO 1
+#define HAVE_GETADDRINFO 1
+#endif
diff --git a/jni/ruby/ext/socket/extconf.rb b/jni/ruby/ext/socket/extconf.rb
new file mode 100644
index 0000000..6d15bba
--- /dev/null
+++ b/jni/ruby/ext/socket/extconf.rb
@@ -0,0 +1,695 @@
+require 'mkmf'
+
+AF_INET6_SOCKET_CREATION_TEST = <<EOF
+#include <sys/types.h>
+#ifndef _WIN32
+#include <sys/socket.h>
+#endif
+int
+main(void)
+{
+ socket(AF_INET6, SOCK_STREAM, 0);
+ return 0;
+}
+EOF
+
+GETADDRINFO_GETNAMEINFO_TEST = <<EOF
+#include <stdlib.h>
+
+#ifndef EXIT_SUCCESS
+#define EXIT_SUCCESS 0
+#endif
+#ifndef EXIT_FAILURE
+#define EXIT_FAILURE 1
+#endif
+
+#ifndef AF_LOCAL
+#define AF_LOCAL AF_UNIX
+#endif
+
+int
+main(void)
+{
+ int passive, gaierr, inet4 = 0, inet6 = 0;
+ struct addrinfo hints, *ai, *aitop;
+ char straddr[INET6_ADDRSTRLEN], strport[16];
+#ifdef _WIN32
+ WSADATA retdata;
+
+ WSAStartup(MAKEWORD(2, 0), &retdata);
+#endif
+
+ for (passive = 0; passive <= 1; passive++) {
+ memset(&hints, 0, sizeof(hints));
+ hints.ai_family = AF_UNSPEC;
+ hints.ai_protocol = IPPROTO_TCP;
+ hints.ai_flags = passive ? AI_PASSIVE : 0;
+ hints.ai_socktype = SOCK_STREAM;
+ if ((gaierr = getaddrinfo(NULL, "54321", &hints, &aitop)) != 0) {
+ (void)gai_strerror(gaierr);
+ goto bad;
+ }
+ for (ai = aitop; ai; ai = ai->ai_next) {
+ if (ai->ai_family == AF_LOCAL) continue;
+ if (ai->ai_addr == NULL)
+ goto bad;
+#if defined(_AIX)
+ if (ai->ai_family == AF_INET6 && passive) {
+ inet6++;
+ continue;
+ }
+ ai->ai_addr->sa_len = ai->ai_addrlen;
+ ai->ai_addr->sa_family = ai->ai_family;
+#endif
+ if (ai->ai_addrlen == 0 ||
+ getnameinfo(ai->ai_addr, ai->ai_addrlen,
+ straddr, sizeof(straddr), strport, sizeof(strport),
+ NI_NUMERICHOST|NI_NUMERICSERV) != 0) {
+ goto bad;
+ }
+ if (strcmp(strport, "54321") != 0) {
+ goto bad;
+ }
+ switch (ai->ai_family) {
+ case AF_INET:
+ if (passive) {
+ if (strcmp(straddr, "0.0.0.0") != 0) {
+ goto bad;
+ }
+ } else {
+ if (strcmp(straddr, "127.0.0.1") != 0) {
+ goto bad;
+ }
+ }
+ inet4++;
+ break;
+ case AF_INET6:
+ if (passive) {
+ if (strcmp(straddr, "::") != 0) {
+ goto bad;
+ }
+ } else {
+ if (strcmp(straddr, "::1") != 0) {
+ goto bad;
+ }
+ }
+ inet6++;
+ break;
+ case AF_UNSPEC:
+ goto bad;
+ break;
+ default:
+ /* another family support? */
+ break;
+ }
+ }
+ }
+
+ if (!(inet4 == 0 || inet4 == 2))
+ goto bad;
+ if (!(inet6 == 0 || inet6 == 2))
+ goto bad;
+
+ if (aitop)
+ freeaddrinfo(aitop);
+ return EXIT_SUCCESS;
+
+ bad:
+ if (aitop)
+ freeaddrinfo(aitop);
+ return EXIT_FAILURE;
+}
+EOF
+
+RECVMSG_WITH_MSG_PEEK_ALLOCATE_FD_TEST = <<'EOF'
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <sys/socket.h>
+#include <sys/un.h>
+#include <unistd.h>
+
+int main(int argc, char *argv[])
+{
+ int ps[2], sv[2];
+ int ret;
+ ssize_t ss;
+ int s_fd, r_fd;
+ struct msghdr s_msg, r_msg;
+ union {
+ struct cmsghdr hdr;
+ char dummy[CMSG_SPACE(sizeof(int))];
+ } s_cmsg, r_cmsg;
+ struct iovec s_iov, r_iov;
+ char s_buf[1], r_buf[1];
+ struct stat s_statbuf, r_statbuf;
+
+ ret = pipe(ps);
+ if (ret == -1) { perror("pipe"); exit(EXIT_FAILURE); }
+
+ s_fd = ps[0];
+
+ ret = socketpair(AF_UNIX, SOCK_DGRAM, 0, sv);
+ if (ret == -1) { perror("socketpair"); exit(EXIT_FAILURE); }
+
+ s_msg.msg_name = NULL;
+ s_msg.msg_namelen = 0;
+ s_msg.msg_iov = &s_iov;
+ s_msg.msg_iovlen = 1;
+ s_msg.msg_control = &s_cmsg;
+ s_msg.msg_controllen = CMSG_SPACE(sizeof(int));;
+ s_msg.msg_flags = 0;
+
+ s_iov.iov_base = &s_buf;
+ s_iov.iov_len = sizeof(s_buf);
+
+ s_buf[0] = 'a';
+
+ s_cmsg.hdr.cmsg_len = CMSG_LEN(sizeof(int));
+ s_cmsg.hdr.cmsg_level = SOL_SOCKET;
+ s_cmsg.hdr.cmsg_type = SCM_RIGHTS;
+ memcpy(CMSG_DATA(&s_cmsg.hdr), (char *)&s_fd, sizeof(int));
+
+ ss = sendmsg(sv[0], &s_msg, 0);
+ if (ss == -1) { perror("sendmsg"); exit(EXIT_FAILURE); }
+
+ r_msg.msg_name = NULL;
+ r_msg.msg_namelen = 0;
+ r_msg.msg_iov = &r_iov;
+ r_msg.msg_iovlen = 1;
+ r_msg.msg_control = &r_cmsg;
+ r_msg.msg_controllen = CMSG_SPACE(sizeof(int));
+ r_msg.msg_flags = 0;
+
+ r_iov.iov_base = &r_buf;
+ r_iov.iov_len = sizeof(r_buf);
+
+ r_buf[0] = '0';
+
+ memset(&r_cmsg, 0xff, CMSG_SPACE(sizeof(int)));
+
+ ss = recvmsg(sv[1], &r_msg, MSG_PEEK);
+ if (ss == -1) { perror("recvmsg"); exit(EXIT_FAILURE); }
+
+ if (ss != 1) {
+ fprintf(stderr, "unexpected return value from recvmsg: %ld\n", (long)ss);
+ exit(EXIT_FAILURE);
+ }
+ if (r_buf[0] != 'a') {
+ fprintf(stderr, "unexpected return data from recvmsg: 0x%02x\n", r_buf[0]);
+ exit(EXIT_FAILURE);
+ }
+
+ if (r_msg.msg_controllen < CMSG_LEN(sizeof(int))) {
+ fprintf(stderr, "unexpected: r_msg.msg_controllen < CMSG_LEN(sizeof(int)) not hold: %ld\n",
+ (long)r_msg.msg_controllen);
+ exit(EXIT_FAILURE);
+ }
+ if (r_cmsg.hdr.cmsg_len < CMSG_LEN(sizeof(int))) {
+ fprintf(stderr, "unexpected: r_cmsg.hdr.cmsg_len < CMSG_LEN(sizeof(int)) not hold: %ld\n",
+ (long)r_cmsg.hdr.cmsg_len);
+ exit(EXIT_FAILURE);
+ }
+ memcpy((char *)&r_fd, CMSG_DATA(&r_cmsg.hdr), sizeof(int));
+
+ if (r_fd < 0) {
+ fprintf(stderr, "negative r_fd: %d\n", r_fd);
+ exit(EXIT_FAILURE);
+ }
+
+ if (r_fd == s_fd) {
+ fprintf(stderr, "r_fd and s_fd is same: %d\n", r_fd);
+ exit(EXIT_FAILURE);
+ }
+
+ ret = fstat(s_fd, &s_statbuf);
+ if (ret == -1) { perror("fstat(s_fd)"); exit(EXIT_FAILURE); }
+
+ ret = fstat(r_fd, &r_statbuf);
+ if (ret == -1) { perror("fstat(r_fd)"); exit(EXIT_FAILURE); }
+
+ if (s_statbuf.st_dev != r_statbuf.st_dev ||
+ s_statbuf.st_ino != r_statbuf.st_ino) {
+ fprintf(stderr, "dev/ino doesn't match: s_fd:%ld/%ld r_fd:%ld/%ld\n",
+ (long)s_statbuf.st_dev, (long)s_statbuf.st_ino,
+ (long)r_statbuf.st_dev, (long)r_statbuf.st_ino);
+ exit(EXIT_FAILURE);
+ }
+
+ return EXIT_SUCCESS;
+}
+EOF
+
+def test_recvmsg_with_msg_peek_creates_fds(headers)
+ case RUBY_PLATFORM
+ when /linux/
+ # Linux 2.6.38 allocate fds by recvmsg with MSG_PEEK.
+ close_fds = true
+ when /bsd|darwin/
+ # FreeBSD 8.2.0, NetBSD 5 and MacOS X Snow Leopard doesn't
+ # allocate fds by recvmsg with MSG_PEEK.
+ # [ruby-dev:44189]
+ # http://bugs.ruby-lang.org/issues/5075
+ close_fds = false
+ when /cygwin/
+ # Cygwin doesn't support fd passing.
+ # http://cygwin.com/ml/cygwin/2003-09/msg01808.html
+ close_fds = false
+ else
+ close_fds = nil
+ end
+ if !CROSS_COMPILING
+ if checking_for("recvmsg() with MSG_PEEK allocate file descriptors") {
+ try_run(cpp_include(headers) + RECVMSG_WITH_MSG_PEEK_ALLOCATE_FD_TEST)
+ }
+ if close_fds == false
+ warn "unexpected fd-passing recvmsg() with MSG_PEEK behavor on #{RUBY_PLATFORM}: fd allocation unexpected."
+ elsif close_fds == nil
+ puts "info: #{RUBY_PLATFORM} recvmsg() with MSG_PEEK allocates fds on fd-passing."
+ end
+ close_fds = true
+ else
+ if close_fds == true
+ warn "unexpected fd-passing recvmsg() with MSG_PEEK behavor on #{RUBY_PLATFORM}: fd allocation expected."
+ elsif close_fds == nil
+ puts "info: #{RUBY_PLATFORM}: recvmsg() with MSG_PEEK doesn't allocates fds on fd-passing."
+ end
+ close_fds = false
+ end
+ end
+ if close_fds == nil
+ abort <<EOS
+Fatal: cannot test fd-passing recvmsg() with MSG_PEEK behavor
+because cross-compilation for #{RUBY_PLATFORM}.
+If recvmsg() with MSG_PEEK allocates fds on fd passing:
+--enable-close-fds-by-recvmsg-with-peek
+If recvmsg() with MSG_PEEK doesn't allocate fds on fd passing:
+--disable-close-fds-by-recvmsg-with-peek
+EOS
+ end
+ close_fds
+end
+
+$INCFLAGS << " -I$(topdir) -I$(top_srcdir)"
+
+if /darwin/ =~ RUBY_PLATFORM
+ # For IPv6 extension header access on OS X 10.7+ [Bug #8517]
+ $CFLAGS << " -D__APPLE_USE_RFC_3542"
+end
+
+headers = []
+unless $mswin or $mingw
+ headers = %w<sys/types.h netdb.h string.h sys/socket.h netinet/in.h>
+end
+
+%w[
+ sys/uio.h
+ xti.h
+ netinet/in_systm.h
+ netinet/tcp.h
+ netinet/tcp_fsm.h
+ netinet/udp.h
+ arpa/inet.h
+ netpacket/packet.h
+ net/ethernet.h
+ sys/un.h
+ ifaddrs.h
+ sys/ioctl.h
+ sys/sockio.h
+ net/if.h
+ sys/param.h
+ sys/ucred.h
+ ucred.h
+ net/if_dl.h
+ arpa/nameser.h
+ resolv.h
+].each {|h|
+ if have_header(h, headers)
+ headers << h
+ end
+}
+
+have_struct_member("struct sockaddr", "sa_len", headers) # 4.4BSD
+have_struct_member("struct sockaddr_in", "sin_len", headers) # 4.4BSD
+have_struct_member("struct sockaddr_in6", "sin6_len", headers) # 4.4BSD
+
+if have_type("struct sockaddr_un", headers) # POSIX
+ have_struct_member("struct sockaddr_un", "sun_len", headers) # 4.4BSD
+end
+
+have_type("struct sockaddr_dl", headers) # AF_LINK address. 4.4BSD since Net2
+
+have_type("struct sockaddr_storage", headers)
+
+have_type("struct addrinfo", headers)
+
+if have_type("socklen_t", headers)
+ if try_static_assert("sizeof(socklen_t) >= sizeof(long)", headers)
+ $defs << "-DRSTRING_SOCKLEN=(socklen_t)RSTRING_LEN"
+ end
+end
+
+have_type("struct in_pktinfo", headers) {|src|
+ src.sub(%r'^/\*top\*/', '\&'"\n#if defined(IPPROTO_IP) && defined(IP_PKTINFO)") <<
+ "#else\n" << "#error\n" << ">>>>>> no in_pktinfo <<<<<<\n" << "#endif\n"
+} and have_struct_member("struct in_pktinfo", "ipi_spec_dst", headers)
+have_type("struct in6_pktinfo", headers) {|src|
+ src.sub(%r'^/\*top\*/', '\&'"\n#if defined(IPPROTO_IPV6) && defined(IPV6_PKTINFO)") <<
+ "#else\n" << "#error\n" << ">>>>>> no in6_pktinfo <<<<<<\n" << "#endif\n"
+}
+
+have_type("struct sockcred", headers)
+have_type("struct cmsgcred", headers)
+
+have_type("struct ip_mreq", headers) # 4.4BSD
+have_type("struct ip_mreqn", headers) # Linux 2.4
+have_type("struct ipv6_mreq", headers) # RFC 3493
+
+have_msg_control = nil
+have_msg_control = have_struct_member('struct msghdr', 'msg_control', headers) unless $mswin or $mingw
+have_struct_member('struct msghdr', 'msg_accrights', headers)
+
+if have_type("struct tcp_info", headers)
+ have_const("TCP_ESTABLISHED", headers)
+ have_const("TCP_SYN_SENT", headers)
+ have_const("TCP_SYN_RECV", headers)
+ have_const("TCP_FIN_WAIT1", headers)
+ have_const("TCP_FIN_WAIT2", headers)
+ have_const("TCP_TIME_WAIT", headers)
+ have_const("TCP_CLOSE", headers)
+ have_const("TCP_CLOSE_WAIT", headers)
+ have_const("TCP_LAST_ACK", headers)
+ have_const("TCP_LISTEN", headers)
+ have_const("TCP_CLOSING", headers)
+ have_struct_member('struct tcp_info', 'tcpi_state', headers)
+ if /solaris/ !~ RUBY_PLATFORM
+ have_struct_member('struct tcp_info', 'tcpi_ca_state', headers)
+ end
+ have_struct_member('struct tcp_info', 'tcpi_retransmits', headers)
+ have_struct_member('struct tcp_info', 'tcpi_probes', headers)
+ have_struct_member('struct tcp_info', 'tcpi_backoff', headers)
+ have_struct_member('struct tcp_info', 'tcpi_options', headers)
+ have_struct_member('struct tcp_info', 'tcpi_snd_wscale', headers)
+ have_struct_member('struct tcp_info', 'tcpi_rcv_wscale', headers)
+ have_struct_member('struct tcp_info', 'tcpi_rto', headers)
+ have_struct_member('struct tcp_info', 'tcpi_ato', headers)
+ have_struct_member('struct tcp_info', 'tcpi_snd_mss', headers)
+ have_struct_member('struct tcp_info', 'tcpi_rcv_mss', headers)
+ have_struct_member('struct tcp_info', 'tcpi_unacked', headers)
+ have_struct_member('struct tcp_info', 'tcpi_sacked', headers)
+ have_struct_member('struct tcp_info', 'tcpi_lost', headers)
+ have_struct_member('struct tcp_info', 'tcpi_retrans', headers)
+ have_struct_member('struct tcp_info', 'tcpi_fackets', headers)
+ have_struct_member('struct tcp_info', 'tcpi_last_data_sent', headers)
+ have_struct_member('struct tcp_info', 'tcpi_last_ack_sent', headers)
+ have_struct_member('struct tcp_info', 'tcpi_last_data_recv', headers)
+ have_struct_member('struct tcp_info', 'tcpi_last_ack_recv', headers)
+ have_struct_member('struct tcp_info', 'tcpi_pmtu', headers)
+ have_struct_member('struct tcp_info', 'tcpi_rcv_ssthresh', headers)
+ have_struct_member('struct tcp_info', 'tcpi_rtt', headers)
+ have_struct_member('struct tcp_info', 'tcpi_rttvar', headers)
+ have_struct_member('struct tcp_info', 'tcpi_snd_ssthresh', headers)
+ have_struct_member('struct tcp_info', 'tcpi_snd_cwnd', headers)
+ have_struct_member('struct tcp_info', 'tcpi_advmss', headers)
+ have_struct_member('struct tcp_info', 'tcpi_reordering', headers)
+ have_struct_member('struct tcp_info', 'tcpi_rcv_rtt', headers)
+ have_struct_member('struct tcp_info', 'tcpi_rcv_space', headers)
+ have_struct_member('struct tcp_info', 'tcpi_total_retrans', headers)
+
+ # FreeBSD extension
+ have_struct_member('struct tcp_info', 'tcpi_snd_wnd', headers)
+ have_struct_member('struct tcp_info', 'tcpi_snd_bwnd', headers)
+ have_struct_member('struct tcp_info', 'tcpi_snd_nxt', headers)
+ have_struct_member('struct tcp_info', 'tcpi_rcv_nxt', headers)
+ have_struct_member('struct tcp_info', 'tcpi_toe_tid', headers)
+ have_struct_member('struct tcp_info', 'tcpi_snd_rexmitpack', headers)
+ have_struct_member('struct tcp_info', 'tcpi_rcv_ooopack', headers)
+ have_struct_member('struct tcp_info', 'tcpi_snd_zerowin', headers)
+end
+
+case RUBY_PLATFORM
+when /mswin(32|64)|mingw/
+ test_func = "WSACleanup"
+ have_library("ws2_32", "WSACleanup", headers)
+when /cygwin/
+ test_func = "socket(0,0,0)"
+when /beos/
+ test_func = "socket(0,0,0)"
+ have_library("net", "socket(0,0,0)", headers)
+when /haiku/
+ test_func = "socket(0,0,0)"
+ have_library("network", "socket(0,0,0)", headers)
+when /i386-os2_emx/
+ test_func = "socket(0,0,0)"
+ have_library("socket", "socket(0,0,0)", headers)
+else
+ test_func = "socket(0,0,0)"
+ have_library("nsl", 't_open("", 0, (struct t_info *)NULL)', headers) # SunOS
+ have_library("socket", "socket(0,0,0)", headers) # SunOS
+end
+
+if have_func(test_func, headers)
+
+ have_func("sendmsg(0, (struct msghdr *)NULL, 0)", headers) # POSIX
+ have_recvmsg = have_func("recvmsg(0, (struct msghdr *)NULL, 0)", headers) # POSIX
+
+ have_func("freehostent((struct hostent *)NULL)", headers) # RFC 2553
+ have_func("freeaddrinfo((struct addrinfo *)NULL)", headers) # RFC 2553
+
+ if /haiku/ !~ RUBY_PLATFORM and
+ have_func("gai_strerror(0)", headers) # POSIX
+ if checking_for("gai_strerror() returns const pointer") {!try_compile(<<EOF)}
+#{cpp_include(headers)}
+#include <stdlib.h>
+void
+conftest_gai_strerror_is_const()
+{
+ *gai_strerror(0) = 0;
+}
+EOF
+ $defs << "-DGAI_STRERROR_CONST"
+ end
+ end
+
+ have_func("accept4", headers)
+
+ have_func('inet_ntop(0, (const void *)0, (char *)0, 0)', headers) or
+ have_func("inet_ntoa(*(struct in_addr *)NULL)", headers)
+ have_func('inet_pton(0, "", (void *)0)', headers) or
+ have_func('inet_aton("", (struct in_addr *)0)', headers)
+ have_func('getservbyport(0, "")', headers)
+ have_func("getifaddrs((struct ifaddrs **)NULL)", headers)
+
+ have_func("getpeereid", headers)
+
+ have_func("getpeerucred(0, (ucred_t **)NULL)", headers) # SunOS
+
+ have_func_decl = proc do |name, headers|
+ if !checking_for("declaration of #{name}()") {!%w[int void].all? {|ret| try_compile(<<EOF)}}
+#{cpp_include(headers)}
+#{ret} #{name}(void);
+EOF
+ $defs << "-DNEED_#{name.tr_cpp}_DECL"
+ end
+ end
+ if have_func('if_indextoname(0, "")', headers)
+ have_func_decl["if_indextoname"]
+ end
+ if have_func('if_nametoindex("")', headers)
+ have_func_decl["if_nametoindex"]
+ end
+
+ have_func("hsterror", headers)
+ have_func('getipnodebyname("", 0, 0, (int *)0)', headers) # RFC 2553
+ have_func('gethostbyname2("", 0)', headers) # RFC 2133
+ have_func("socketpair(0, 0, 0, 0)", headers)
+ unless have_func("gethostname((char *)0, 0)", headers)
+ have_func("uname((struct utsname *)NULL)", headers)
+ end
+
+ ipv6 = false
+ default_ipv6 = /beos|haiku/ !~ RUBY_PLATFORM
+ if enable_config("ipv6", default_ipv6)
+ if checking_for("ipv6") {try_link(AF_INET6_SOCKET_CREATION_TEST)}
+ $defs << "-DENABLE_IPV6" << "-DINET6"
+ ipv6 = true
+ end
+ end
+
+ if ipv6
+ if $mingw
+ $CPPFLAGS << " -D_WIN32_WINNT=0x501" unless $CPPFLAGS.include?("_WIN32_WINNT")
+ end
+ ipv6lib = nil
+ class << (fmt = "unknown")
+ def %(s) s || self end
+ end
+ idirs, ldirs = dir_config("inet6", %w[/usr/inet6 /usr/local/v6].find {|d| File.directory?(d)})
+ checking_for("ipv6 type", fmt) do
+ if have_macro("IPV6_INRIA_VERSION", "netinet/in.h")
+ "inria"
+ elsif have_macro("__KAME__", "netinet/in.h")
+ have_library(ipv6lib = "inet6")
+ "kame"
+ elsif have_macro("_TOSHIBA_INET6", "sys/param.h")
+ have_library(ipv6lib = "inet6") and "toshiba"
+ elsif have_macro("__V6D__", "sys/v6config.h")
+ have_library(ipv6lib = "v6") and "v6d"
+ elsif have_macro("_ZETA_MINAMI_INET6", "sys/param.h")
+ have_library(ipv6lib = "inet6") and "zeta"
+ elsif have_library("inet6")
+ "inet6"
+ end
+ end or not ipv6lib or abort <<EOS
+
+Fatal: no #{ipv6lib} library found. cannot continue.
+You need to fetch lib#{ipv6lib}.a from appropriate
+ipv6 kit and compile beforehand.
+EOS
+ end
+
+ if !have_macro("IPPROTO_IPV6", headers) && have_const("IPPROTO_IPV6", headers)
+ IO.read(File.join(File.dirname(__FILE__), "mkconstants.rb")).sub(/\A.*^__END__$/m, '').split(/\r?\n/).grep(/\AIPPROTO_\w*/){$&}.each {|name|
+ have_const(name, headers) unless $defs.include?("-DHAVE_CONST_#{name.upcase}")
+ }
+ end
+
+ if enable_config("close-fds-by-recvmsg-with-peek") {
+ have_msg_control && have_recvmsg &&
+ have_const('AF_UNIX', headers) && have_const('SCM_RIGHTS', headers) &&
+ test_recvmsg_with_msg_peek_creates_fds(headers)
+ }
+ $defs << "-DFD_PASSING_WORK_WITH_RECVMSG_MSG_PEEK"
+ end
+
+ case enable_config("wide-getaddrinfo")
+ when true
+ getaddr_info_ok = :wide
+ when nil
+ if have_func("getnameinfo", headers) and have_func("getaddrinfo", headers)
+ getaddr_info_ok = :os
+ if !CROSS_COMPILING &&
+ !checking_for("system getaddrinfo working") {
+ try_run(cpp_include(headers) + GETADDRINFO_GETNAMEINFO_TEST)
+ }
+ getaddr_info_ok = :wide
+ end
+ else
+ getaddr_info_ok = :wide
+ end
+ when false
+ if have_func("getnameinfo", headers) and have_func("getaddrinfo", headers)
+ getaddr_info_ok = :os
+ if !CROSS_COMPILING &&
+ !checking_for("system getaddrinfo working") {
+ try_run(cpp_include(headers) + GETADDRINFO_GETNAMEINFO_TEST)
+ }
+ getaddr_info_ok = nil
+ end
+ else
+ getaddr_info_ok = nil
+ end
+ else
+ raise "unexpected enable_config() value"
+ end
+
+ if ipv6 and not getaddr_info_ok
+ abort <<EOS
+
+Fatal: --enable-ipv6 is specified, and your OS seems to support IPv6 feature.
+But your getaddrinfo() and getnameinfo() are appeared to be broken. Sorry,
+you cannot compile IPv6 socket classes with broken these functions.
+You can try --enable-wide-getaddrinfo.
+EOS
+ end
+
+ case with_config("lookup-order-hack", "UNSPEC")
+ when "INET"
+ $defs << "-DLOOKUP_ORDER_HACK_INET"
+ when "INET6"
+ $defs << "-DLOOKUP_ORDER_HACK_INET6"
+ when "UNSPEC"
+ # nothing special
+ else
+ abort <<EOS
+
+Fatal: invalid value for --with-lookup-order-hack (expected INET, INET6 or UNSPEC)
+EOS
+ end
+
+ $objs = [
+ "init.#{$OBJEXT}",
+ "constants.#{$OBJEXT}",
+ "basicsocket.#{$OBJEXT}",
+ "socket.#{$OBJEXT}",
+ "ipsocket.#{$OBJEXT}",
+ "tcpsocket.#{$OBJEXT}",
+ "tcpserver.#{$OBJEXT}",
+ "sockssocket.#{$OBJEXT}",
+ "udpsocket.#{$OBJEXT}",
+ "unixsocket.#{$OBJEXT}",
+ "unixserver.#{$OBJEXT}",
+ "option.#{$OBJEXT}",
+ "ancdata.#{$OBJEXT}",
+ "raddrinfo.#{$OBJEXT}",
+ "ifaddr.#{$OBJEXT}"
+ ]
+
+ if getaddr_info_ok == :wide
+ if !have_type("struct in6_addr", headers) and have_type("struct in_addr6", headers)
+ $defs.pop(2)
+ $defs << "-Din_addr6=in6_addr"
+ end
+ if have_struct_member("struct in6_addr", "s6_addr8", headers)
+ $defs[-1] = "-Ds6_addr=s6_addr8"
+ end
+ if ipv6 == "kame" && have_struct_member("struct in6_addr", "s6_addr32", headers)
+ $defs[-1] = "-DFAITH"
+ end
+ $CPPFLAGS="-I. "+$CPPFLAGS
+ $objs += ["getaddrinfo.#{$OBJEXT}"]
+ $objs += ["getnameinfo.#{$OBJEXT}"]
+ $defs << "-DGETADDRINFO_EMU"
+ end
+
+ # workaround for recent Windows SDK
+ $defs << "-DIPPROTO_IPV6=IPPROTO_IPV6" if $defs.include?("-DHAVE_CONST_IPPROTO_IPV6") && !have_macro("IPPROTO_IPV6")
+
+ $distcleanfiles << "constants.h" << "constdefs.*"
+
+ if enable_config("socks", ENV["SOCKS_SERVER"])
+ if have_library("socks5", "SOCKSinit")
+ $defs << "-DSOCKS5" << "-DSOCKS"
+ elsif have_library("socks", "Rconnect")
+ $defs << "-DSOCKS"
+ end
+ end
+
+ hdr = "netinet6/in6.h"
+ if /darwin/ =~ RUBY_PLATFORM and !try_compile(<<"SRC", nil, :werror=>true)
+#include <netinet/in.h>
+int t(struct in6_addr *addr) {return IN6_IS_ADDR_UNSPECIFIED(addr);}
+SRC
+ print "fixing apple's netinet6/in6.rb ..."; $stdout.flush
+ in6 = File.read("/usr/include/#{hdr}")
+ if in6.gsub!(/\*\(const\s+__uint32_t\s+\*\)\(const\s+void\s+\*\)\(&(\(\w+\))->s6_addr\[(\d+)\]\)/) do
+ i, r = $2.to_i.divmod(4)
+ if r.zero?
+ "#$1->__u6_addr.__u6_addr32[#{i}]"
+ else
+ $&
+ end
+ end
+ FileUtils.mkdir_p(File.dirname(hdr))
+ open(hdr, "w") {|f| f.write(in6)}
+ $distcleanfiles << hdr
+ $distcleandirs << File.dirname(hdr)
+ puts "done"
+ else
+ puts "not needed"
+ end
+ end
+ create_makefile("socket")
+end
diff --git a/jni/ruby/ext/socket/getaddrinfo.c b/jni/ruby/ext/socket/getaddrinfo.c
new file mode 100644
index 0000000..68f610e
--- /dev/null
+++ b/jni/ruby/ext/socket/getaddrinfo.c
@@ -0,0 +1,679 @@
+/*
+ * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the project nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+/*
+ * "#ifdef FAITH" part is local hack for supporting IPv4-v6 translator.
+ *
+ * Issues to be discussed:
+ * - Thread safe-ness must be checked.
+ * - Return values. There are nonstandard return values defined and used
+ * in the source code. This is because RFC2133 is silent about which error
+ * code must be returned for which situation.
+ * - PF_UNSPEC case would be handled in getipnodebyname() with the AI_ALL flag.
+ */
+
+#include "ruby/config.h"
+#ifdef RUBY_EXTCONF_H
+#include RUBY_EXTCONF_H
+#endif
+#include <sys/types.h>
+#ifndef _WIN32
+#include <sys/param.h>
+#if defined(__BEOS__) && !defined(__HAIKU__) && !defined(BONE)
+# include <net/socket.h>
+#else
+# include <sys/socket.h>
+#endif
+#include <netinet/in.h>
+#if defined(HAVE_ARPA_INET_H)
+#include <arpa/inet.h>
+#endif
+#if defined(HAVE_ARPA_NAMESER_H)
+#include <arpa/nameser.h>
+#endif
+#include <netdb.h>
+#if defined(HAVE_RESOLV_H)
+#ifdef _SX
+#include <stdio.h>
+#endif
+#include <resolv.h>
+#endif
+#include <unistd.h>
+#else
+#include <winsock2.h>
+#include <ws2tcpip.h>
+#include <io.h>
+#endif
+#include <string.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <stddef.h>
+#include <ctype.h>
+
+#ifdef SOCKS5
+#include <socks.h>
+#endif
+
+#ifndef HAVE_TYPE_SOCKLEN_T
+typedef int socklen_t;
+#endif
+
+#include "addrinfo.h"
+#include "sockport.h"
+
+#define SUCCESS 0
+#define ANY 0
+#define YES 1
+#define NO 0
+
+#ifdef FAITH
+static int translate = NO;
+static struct in6_addr faith_prefix = IN6ADDR_ANY_INIT;
+#endif
+
+static const char in_addrany[] = { 0, 0, 0, 0 };
+static const char in6_addrany[] = {
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
+};
+static const char in_loopback[] = { 127, 0, 0, 1 };
+static const char in6_loopback[] = {
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1
+};
+
+struct sockinet {
+ u_char si_len;
+ u_char si_family;
+ u_short si_port;
+};
+
+static const struct afd {
+ int a_af;
+ int a_addrlen;
+ int a_socklen;
+ int a_off;
+ const char *a_addrany;
+ const char *a_loopback;
+} afdl [] = {
+#ifdef INET6
+#define N_INET6 0
+ {PF_INET6, sizeof(struct in6_addr),
+ sizeof(struct sockaddr_in6),
+ offsetof(struct sockaddr_in6, sin6_addr),
+ in6_addrany, in6_loopback},
+#define N_INET 1
+#else
+#define N_INET 0
+#endif
+ {PF_INET, sizeof(struct in_addr),
+ sizeof(struct sockaddr_in),
+ offsetof(struct sockaddr_in, sin_addr),
+ in_addrany, in_loopback},
+ {0, 0, 0, 0, NULL, NULL},
+};
+
+#ifdef INET6
+#define PTON_MAX 16
+#else
+#define PTON_MAX 4
+#endif
+
+static int get_name __P((const char *, const struct afd *,
+ struct addrinfo **, char *, struct addrinfo *,
+ int));
+static int get_addr __P((const char *, int, struct addrinfo **,
+ struct addrinfo *, int));
+static int str_isnumber __P((const char *));
+
+static const char *const ai_errlist[] = {
+ "success.",
+ "address family for hostname not supported.", /* EAI_ADDRFAMILY */
+ "temporary failure in name resolution.", /* EAI_AGAIN */
+ "invalid value for ai_flags.", /* EAI_BADFLAGS */
+ "non-recoverable failure in name resolution.", /* EAI_FAIL */
+ "ai_family not supported.", /* EAI_FAMILY */
+ "memory allocation failure.", /* EAI_MEMORY */
+ "no address associated with hostname.", /* EAI_NODATA */
+ "hostname nor servname provided, or not known.",/* EAI_NONAME */
+ "servname not supported for ai_socktype.", /* EAI_SERVICE */
+ "ai_socktype not supported.", /* EAI_SOCKTYPE */
+ "system error returned in errno.", /* EAI_SYSTEM */
+ "invalid value for hints.", /* EAI_BADHINTS */
+ "resolved protocol is unknown.", /* EAI_PROTOCOL */
+ "unknown error.", /* EAI_MAX */
+};
+
+#define GET_CANONNAME(ai, str) \
+if (pai->ai_flags & AI_CANONNAME) {\
+ if (((ai)->ai_canonname = (char *)malloc(strlen(str) + 1)) != NULL) {\
+ strcpy((ai)->ai_canonname, (str));\
+ } else {\
+ error = EAI_MEMORY;\
+ goto free;\
+ }\
+}
+
+#define GET_AI(ai, afd, addr, port) {\
+ char *p;\
+ if (((ai) = (struct addrinfo *)malloc(sizeof(struct addrinfo) +\
+ ((afd)->a_socklen)))\
+ == NULL) {\
+ error = EAI_MEMORY;\
+ goto free;\
+ }\
+ memcpy((ai), pai, sizeof(struct addrinfo));\
+ (ai)->ai_addr = (struct sockaddr *)((ai) + 1);\
+ (ai)->ai_family = (afd)->a_af;\
+ (ai)->ai_addrlen = (afd)->a_socklen;\
+ INIT_SOCKADDR((ai)->ai_addr, (afd)->a_af, (afd)->a_socklen);\
+ ((struct sockinet *)(ai)->ai_addr)->si_port = (port);\
+ p = (char *)((ai)->ai_addr);\
+ memcpy(p + (afd)->a_off, (addr), (afd)->a_addrlen);\
+}
+
+#define ERR(err) { error = (err); goto bad; }
+
+#ifndef HAVE_GAI_STRERROR
+#ifdef GAI_STRERROR_CONST
+const
+#endif
+char *
+gai_strerror(int ecode)
+{
+ if (ecode < 0 || ecode > EAI_MAX)
+ ecode = EAI_MAX;
+ return (char *)ai_errlist[ecode];
+}
+#endif
+
+void
+freeaddrinfo(struct addrinfo *ai)
+{
+ struct addrinfo *next;
+
+ do {
+ next = ai->ai_next;
+ if (ai->ai_canonname)
+ free(ai->ai_canonname);
+ /* no need to free(ai->ai_addr) */
+ free(ai);
+ } while ((ai = next) != NULL);
+}
+
+static int
+str_isnumber(const char *p)
+{
+ char *q = (char *)p;
+ while (*q) {
+ if (! isdigit(*q))
+ return NO;
+ q++;
+ }
+ return YES;
+}
+
+#ifndef HAVE_INET_PTON
+
+static int
+inet_pton(int af, const char *hostname, void *pton)
+{
+ struct in_addr in;
+
+#ifdef HAVE_INET_ATON
+ if (!inet_aton(hostname, &in))
+ return 0;
+#else
+ int d1, d2, d3, d4;
+ char ch;
+
+ if (sscanf(hostname, "%d.%d.%d.%d%c", &d1, &d2, &d3, &d4, &ch) == 4 &&
+ 0 <= d1 && d1 <= 255 && 0 <= d2 && d2 <= 255 &&
+ 0 <= d3 && d3 <= 255 && 0 <= d4 && d4 <= 255) {
+ in.s_addr = htonl(
+ ((long) d1 << 24) | ((long) d2 << 16) |
+ ((long) d3 << 8) | ((long) d4 << 0));
+ }
+ else {
+ return 0;
+ }
+#endif
+ memcpy(pton, &in, sizeof(in));
+ return 1;
+}
+#endif
+
+int
+getaddrinfo(const char *hostname, const char *servname, const struct addrinfo *hints, struct addrinfo **res)
+{
+ struct addrinfo sentinel;
+ struct addrinfo *top = NULL;
+ struct addrinfo *cur;
+ int i, error = 0;
+ char pton[PTON_MAX];
+ struct addrinfo ai;
+ struct addrinfo *pai;
+ u_short port;
+
+#ifdef FAITH
+ static int firsttime = 1;
+
+ if (firsttime) {
+ /* translator hack */
+ {
+ char *q = getenv("GAI");
+ if (q && inet_pton(AF_INET6, q, &faith_prefix) == 1)
+ translate = YES;
+ }
+ firsttime = 0;
+ }
+#endif
+
+ /* initialize file static vars */
+ sentinel.ai_next = NULL;
+ cur = &sentinel;
+ pai = &ai;
+ pai->ai_flags = 0;
+ pai->ai_family = PF_UNSPEC;
+ pai->ai_socktype = ANY;
+ pai->ai_protocol = ANY;
+ pai->ai_addrlen = 0;
+ pai->ai_canonname = NULL;
+ pai->ai_addr = NULL;
+ pai->ai_next = NULL;
+ port = ANY;
+
+ if (hostname == NULL && servname == NULL)
+ return EAI_NONAME;
+ if (hints) {
+ /* error check for hints */
+ if (hints->ai_addrlen || hints->ai_canonname ||
+ hints->ai_addr || hints->ai_next)
+ ERR(EAI_BADHINTS); /* xxx */
+ if (hints->ai_flags & ~AI_MASK)
+ ERR(EAI_BADFLAGS);
+ switch (hints->ai_family) {
+ case PF_UNSPEC:
+ case PF_INET:
+#ifdef INET6
+ case PF_INET6:
+#endif
+ break;
+ default:
+ ERR(EAI_FAMILY);
+ }
+ memcpy(pai, hints, sizeof(*pai));
+ switch (pai->ai_socktype) {
+ case ANY:
+ switch (pai->ai_protocol) {
+ case ANY:
+ break;
+ case IPPROTO_UDP:
+ pai->ai_socktype = SOCK_DGRAM;
+ break;
+ case IPPROTO_TCP:
+ pai->ai_socktype = SOCK_STREAM;
+ break;
+ default:
+#if defined(SOCK_RAW)
+ pai->ai_socktype = SOCK_RAW;
+#endif
+ break;
+ }
+ break;
+#if defined(SOCK_RAW)
+ case SOCK_RAW:
+ break;
+#endif
+ case SOCK_DGRAM:
+ if (pai->ai_protocol != IPPROTO_UDP &&
+ pai->ai_protocol != ANY)
+ ERR(EAI_BADHINTS); /*xxx*/
+ pai->ai_protocol = IPPROTO_UDP;
+ break;
+ case SOCK_STREAM:
+ if (pai->ai_protocol != IPPROTO_TCP &&
+ pai->ai_protocol != ANY)
+ ERR(EAI_BADHINTS); /*xxx*/
+ pai->ai_protocol = IPPROTO_TCP;
+ break;
+ default:
+ ERR(EAI_SOCKTYPE);
+ break;
+ }
+ }
+
+ /*
+ * service port
+ */
+ if (servname) {
+ if (str_isnumber(servname)) {
+ if (pai->ai_socktype == ANY) {
+ /* caller accept *ANY* socktype */
+ pai->ai_socktype = SOCK_DGRAM;
+ pai->ai_protocol = IPPROTO_UDP;
+ }
+ port = htons((unsigned short)atoi(servname));
+ } else if (pai->ai_flags & AI_NUMERICSERV) {
+ ERR(EAI_NONAME);
+ } else {
+ struct servent *sp;
+ const char *proto;
+
+ proto = NULL;
+ switch (pai->ai_socktype) {
+ case ANY:
+ proto = NULL;
+ break;
+ case SOCK_DGRAM:
+ proto = "udp";
+ break;
+ case SOCK_STREAM:
+ proto = "tcp";
+ break;
+ default:
+ fprintf(stderr, "panic!\n");
+ break;
+ }
+ if ((sp = getservbyname((char*)servname, proto)) == NULL)
+ ERR(EAI_SERVICE);
+ port = sp->s_port;
+ if (pai->ai_socktype == ANY)
+ if (strcmp(sp->s_proto, "udp") == 0) {
+ pai->ai_socktype = SOCK_DGRAM;
+ pai->ai_protocol = IPPROTO_UDP;
+ } else if (strcmp(sp->s_proto, "tcp") == 0) {
+ pai->ai_socktype = SOCK_STREAM;
+ pai->ai_protocol = IPPROTO_TCP;
+ } else
+ ERR(EAI_PROTOCOL); /*xxx*/
+ }
+ }
+
+ /*
+ * hostname == NULL.
+ * passive socket -> anyaddr (0.0.0.0 or ::)
+ * non-passive socket -> localhost (127.0.0.1 or ::1)
+ */
+ if (hostname == NULL) {
+ const struct afd *afd;
+ int s;
+
+ for (afd = &afdl[0]; afd->a_af; afd++) {
+ if (!(pai->ai_family == PF_UNSPEC
+ || pai->ai_family == afd->a_af)) {
+ continue;
+ }
+
+ /*
+ * filter out AFs that are not supported by the kernel
+ * XXX errno?
+ */
+ s = socket(afd->a_af, SOCK_DGRAM, 0);
+ if (s < 0)
+ continue;
+#if defined(__BEOS__)
+ closesocket(s);
+#else
+ close(s);
+#endif
+
+ if (pai->ai_flags & AI_PASSIVE) {
+ GET_AI(cur->ai_next, afd, afd->a_addrany, port);
+ /* xxx meaningless?
+ * GET_CANONNAME(cur->ai_next, "anyaddr");
+ */
+ } else {
+ GET_AI(cur->ai_next, afd, afd->a_loopback,
+ port);
+ /* xxx meaningless?
+ * GET_CANONNAME(cur->ai_next, "localhost");
+ */
+ }
+ cur = cur->ai_next;
+ }
+ top = sentinel.ai_next;
+ if (top)
+ goto good;
+ else
+ ERR(EAI_FAMILY);
+ }
+
+ /* hostname as numeric name */
+ for (i = 0; afdl[i].a_af; i++) {
+ if (inet_pton(afdl[i].a_af, hostname, pton)) {
+ u_long v4a;
+#ifdef INET6
+ u_char pfx;
+#endif
+
+ switch (afdl[i].a_af) {
+ case AF_INET:
+ v4a = ((struct in_addr *)pton)->s_addr;
+ if (IN_MULTICAST(v4a) || IN_EXPERIMENTAL(v4a))
+ pai->ai_flags &= ~AI_CANONNAME;
+ v4a >>= IN_CLASSA_NSHIFT;
+ if (v4a == 0 || v4a == IN_LOOPBACKNET)
+ pai->ai_flags &= ~AI_CANONNAME;
+ break;
+#ifdef INET6
+ case AF_INET6:
+ pfx = ((struct in6_addr *)pton)->s6_addr[0];
+ if (pfx == 0 || pfx == 0xfe || pfx == 0xff)
+ pai->ai_flags &= ~AI_CANONNAME;
+ break;
+#endif
+ }
+
+ if (pai->ai_family == afdl[i].a_af ||
+ pai->ai_family == PF_UNSPEC) {
+ if (! (pai->ai_flags & AI_CANONNAME)) {
+ GET_AI(top, &afdl[i], pton, port);
+ goto good;
+ }
+ /*
+ * if AI_CANONNAME and if reverse lookup
+ * fail, return ai anyway to pacify
+ * calling application.
+ *
+ * XXX getaddrinfo() is a name->address
+ * translation function, and it looks strange
+ * that we do addr->name translation here.
+ */
+ get_name(pton, &afdl[i], &top, pton, pai, port);
+ goto good;
+ } else
+ ERR(EAI_FAMILY); /*xxx*/
+ }
+ }
+
+ if (pai->ai_flags & AI_NUMERICHOST)
+ ERR(EAI_NONAME);
+
+ /* hostname as alphabetical name */
+ error = get_addr(hostname, pai->ai_family, &top, pai, port);
+ if (error == 0) {
+ if (top) {
+ good:
+ *res = top;
+ return SUCCESS;
+ } else
+ error = EAI_FAIL;
+ }
+ free:
+ if (top)
+ freeaddrinfo(top);
+ bad:
+ *res = NULL;
+ return error;
+}
+
+static int
+get_name(const char *addr, const struct afd *afd, struct addrinfo **res, char *numaddr, struct addrinfo *pai, int port0)
+{
+ u_short port = port0 & 0xffff;
+ struct hostent *hp;
+ struct addrinfo *cur;
+ int error = 0;
+#ifdef INET6
+ int h_error;
+#endif
+
+#ifdef INET6
+ hp = getipnodebyaddr(addr, afd->a_addrlen, afd->a_af, &h_error);
+#else
+ hp = gethostbyaddr((char*)addr, afd->a_addrlen, AF_INET);
+#endif
+ if (hp && hp->h_name && hp->h_name[0] && hp->h_addr_list[0]) {
+ GET_AI(cur, afd, hp->h_addr_list[0], port);
+ GET_CANONNAME(cur, hp->h_name);
+ } else
+ GET_AI(cur, afd, numaddr, port);
+
+#ifdef INET6
+ if (hp)
+ freehostent(hp);
+#endif
+ *res = cur;
+ return SUCCESS;
+ free:
+ if (cur)
+ freeaddrinfo(cur);
+#ifdef INET6
+ if (hp)
+ freehostent(hp);
+#endif
+ /* bad: */
+ *res = NULL;
+ return error;
+}
+
+static int
+get_addr(const char *hostname, int af, struct addrinfo **res, struct addrinfo *pai, int port0)
+{
+ u_short port = port0 & 0xffff;
+ struct addrinfo sentinel;
+ struct hostent *hp;
+ struct addrinfo *top, *cur;
+ const struct afd *afd;
+ int i, error = 0, h_error;
+ char *ap;
+
+ top = NULL;
+ sentinel.ai_next = NULL;
+ cur = &sentinel;
+#ifdef INET6
+ if (af == AF_UNSPEC) {
+ hp = getipnodebyname(hostname, AF_INET6,
+ AI_ADDRCONFIG|AI_ALL|AI_V4MAPPED, &h_error);
+ } else
+ hp = getipnodebyname(hostname, af, AI_ADDRCONFIG, &h_error);
+#else
+ if (strlen(hostname) >= NI_MAXHOST) ERR(EAI_NODATA);
+ hp = gethostbyname((char*)hostname);
+ h_error = h_errno;
+#endif
+ if (hp == NULL) {
+ switch (h_error) {
+ case HOST_NOT_FOUND:
+ case NO_DATA:
+ error = EAI_NODATA;
+ break;
+ case TRY_AGAIN:
+ error = EAI_AGAIN;
+ break;
+ case NO_RECOVERY:
+ default:
+ error = EAI_FAIL;
+ break;
+ }
+ goto bad;
+ }
+
+ if ((hp->h_name == NULL) || (hp->h_name[0] == 0) ||
+ (hp->h_addr_list[0] == NULL))
+ ERR(EAI_FAIL);
+
+ for (i = 0; (ap = hp->h_addr_list[i]) != NULL; i++) {
+ switch (af) {
+#ifdef INET6
+ case AF_INET6:
+ afd = &afdl[N_INET6];
+ break;
+#endif
+#ifndef INET6
+ default: /* AF_UNSPEC */
+#endif
+ case AF_INET:
+ afd = &afdl[N_INET];
+ break;
+#ifdef INET6
+ default: /* AF_UNSPEC */
+ if (IN6_IS_ADDR_V4MAPPED((struct in6_addr *)ap)) {
+ ap += sizeof(struct in6_addr) -
+ sizeof(struct in_addr);
+ afd = &afdl[N_INET];
+ } else
+ afd = &afdl[N_INET6];
+ break;
+#endif
+ }
+#ifdef FAITH
+ if (translate && afd->a_af == AF_INET) {
+ struct in6_addr *in6;
+
+ GET_AI(cur->ai_next, &afdl[N_INET6], ap, port);
+ in6 = &((struct sockaddr_in6 *)cur->ai_next->ai_addr)->sin6_addr;
+ memcpy(&in6->s6_addr, &faith_prefix,
+ sizeof(struct in6_addr) - sizeof(struct in_addr));
+ memcpy(&in6->s6_addr + sizeof(struct in_addr), ap,
+ sizeof(struct in_addr));
+ } else
+#endif /* FAITH */
+ GET_AI(cur->ai_next, afd, ap, port);
+ if (cur == &sentinel) {
+ top = cur->ai_next;
+ GET_CANONNAME(top, hp->h_name);
+ }
+ cur = cur->ai_next;
+ }
+#ifdef INET6
+ freehostent(hp);
+#endif
+ *res = top;
+ return SUCCESS;
+ free:
+ if (top)
+ freeaddrinfo(top);
+#ifdef INET6
+ if (hp)
+ freehostent(hp);
+#endif
+ bad:
+ *res = NULL;
+ return error;
+}
diff --git a/jni/ruby/ext/socket/getnameinfo.c b/jni/ruby/ext/socket/getnameinfo.c
new file mode 100644
index 0000000..4da9680
--- /dev/null
+++ b/jni/ruby/ext/socket/getnameinfo.c
@@ -0,0 +1,261 @@
+/*
+ * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the project nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+/*
+ * Issues to be discussed:
+ * - Thread safe-ness must be checked
+ * - Return values. There seems to be no standard for return value (RFC2133)
+ * but INRIA implementation returns EAI_xxx defined for getaddrinfo().
+ */
+
+#include "ruby/config.h"
+#ifdef RUBY_EXTCONF_H
+#include RUBY_EXTCONF_H
+#endif
+#include <stdio.h>
+#include <sys/types.h>
+#ifndef _WIN32
+#if defined(__BEOS__) && !defined(__HAIKU__) && !defined(BONE)
+# include <net/socket.h>
+#else
+# include <sys/socket.h>
+#endif
+#include <netinet/in.h>
+#if defined(HAVE_ARPA_INET_H)
+#include <arpa/inet.h>
+#endif
+#if defined(HAVE_ARPA_NAMESER_H)
+#include <arpa/nameser.h>
+#endif
+#include <netdb.h>
+#if defined(HAVE_RESOLV_H)
+#include <resolv.h>
+#endif
+#endif
+#ifdef _WIN32
+#include <winsock2.h>
+#include <ws2tcpip.h>
+#define snprintf _snprintf
+#endif
+
+#include <string.h>
+#include <stddef.h>
+
+#ifdef SOCKS5
+#include <socks.h>
+#endif
+
+#ifndef HAVE_TYPE_SOCKLEN_T
+typedef int socklen_t;
+#endif
+
+#include "addrinfo.h"
+#include "sockport.h"
+
+#define SUCCESS 0
+#define ANY 0
+#define YES 1
+#define NO 0
+
+struct sockinet {
+ u_char si_len;
+ u_char si_family;
+ u_short si_port;
+};
+
+static struct afd {
+ int a_af;
+ int a_addrlen;
+ int a_socklen;
+ int a_off;
+} afdl [] = {
+#ifdef INET6
+#define N_INET6 0
+ {PF_INET6, sizeof(struct in6_addr),
+ sizeof(struct sockaddr_in6),
+ offsetof(struct sockaddr_in6, sin6_addr)},
+#define N_INET 1
+#else
+#define N_INET 0
+#endif
+ {PF_INET, sizeof(struct in_addr),
+ sizeof(struct sockaddr_in),
+ offsetof(struct sockaddr_in, sin_addr)},
+ {0, 0, 0, 0},
+};
+
+#define ENI_NOSOCKET 0
+#define ENI_NOSERVNAME 1
+#define ENI_NOHOSTNAME 2
+#define ENI_MEMORY 3
+#define ENI_SYSTEM 4
+#define ENI_FAMILY 5
+#define ENI_SALEN 6
+
+#ifndef HAVE_INET_NTOP
+static const char *
+inet_ntop(int af, const void *addr, char *numaddr, size_t numaddr_len)
+{
+#ifdef HAVE_INET_NTOA
+ struct in_addr in;
+ memcpy(&in.s_addr, addr, sizeof(in.s_addr));
+ snprintf(numaddr, numaddr_len, "%s", inet_ntoa(in));
+#else
+ unsigned long x = ntohl(*(unsigned long*)addr);
+ snprintf(numaddr, numaddr_len, "%d.%d.%d.%d",
+ (int) (x>>24) & 0xff, (int) (x>>16) & 0xff,
+ (int) (x>> 8) & 0xff, (int) (x>> 0) & 0xff);
+#endif
+ return numaddr;
+}
+#endif
+
+int
+getnameinfo(const struct sockaddr *sa, socklen_t salen, char *host, socklen_t hostlen, char *serv, socklen_t servlen, int flags)
+{
+ struct afd *afd;
+ struct hostent *hp;
+ u_short port;
+ int family, len, i;
+ char *addr, *p;
+ u_long v4a;
+#ifdef INET6
+ u_char pfx;
+#endif
+ int h_error;
+ char numserv[512];
+ char numaddr[512];
+
+ if (sa == NULL)
+ return ENI_NOSOCKET;
+
+ if (!VALIDATE_SOCKLEN(sa, salen)) return ENI_SALEN;
+ len = salen;
+
+ family = sa->sa_family;
+ for (i = 0; afdl[i].a_af; i++)
+ if (afdl[i].a_af == family) {
+ afd = &afdl[i];
+ goto found;
+ }
+ return ENI_FAMILY;
+
+ found:
+ if (len != afd->a_socklen) return ENI_SALEN;
+
+ port = ((struct sockinet *)sa)->si_port; /* network byte order */
+ addr = (char *)sa + afd->a_off;
+
+ if (serv == NULL || servlen == 0) {
+ /* what we should do? */
+ } else if (flags & NI_NUMERICSERV) {
+ snprintf(numserv, sizeof(numserv), "%d", ntohs(port));
+ if (strlen(numserv) + 1 > servlen)
+ return ENI_MEMORY;
+ strcpy(serv, numserv);
+ } else {
+#if defined(HAVE_GETSERVBYPORT)
+ struct servent *sp = getservbyport(port, (flags & NI_DGRAM) ? "udp" : "tcp");
+ if (sp) {
+ if (strlen(sp->s_name) + 1 > servlen)
+ return ENI_MEMORY;
+ strcpy(serv, sp->s_name);
+ } else
+ return ENI_NOSERVNAME;
+#else
+ return ENI_NOSERVNAME;
+#endif
+ }
+
+ switch (sa->sa_family) {
+ case AF_INET:
+ v4a = ntohl(((struct sockaddr_in *)sa)->sin_addr.s_addr);
+ if (IN_MULTICAST(v4a) || IN_EXPERIMENTAL(v4a))
+ flags |= NI_NUMERICHOST;
+ v4a >>= IN_CLASSA_NSHIFT;
+ if (v4a == 0)
+ flags |= NI_NUMERICHOST;
+ break;
+#ifdef INET6
+ case AF_INET6:
+#ifdef HAVE_ADDR8
+ pfx = ((struct sockaddr_in6 *)sa)->sin6_addr.s6_addr8[0];
+#else
+ pfx = ((struct sockaddr_in6 *)sa)->sin6_addr.s6_addr[0];
+#endif
+ if (pfx == 0 || pfx == 0xfe || pfx == 0xff)
+ flags |= NI_NUMERICHOST;
+ break;
+#endif
+ }
+ if (host == NULL || hostlen == 0) {
+ /* what should we do? */
+ } else if (flags & NI_NUMERICHOST) {
+ if (inet_ntop(afd->a_af, addr, numaddr, sizeof(numaddr))
+ == NULL)
+ return ENI_SYSTEM;
+ if (strlen(numaddr) > hostlen)
+ return ENI_MEMORY;
+ strcpy(host, numaddr);
+ } else {
+#ifdef INET6
+ hp = getipnodebyaddr(addr, afd->a_addrlen, afd->a_af, &h_error);
+#else
+ hp = gethostbyaddr(addr, afd->a_addrlen, afd->a_af);
+ h_error = h_errno;
+#endif
+
+ if (hp) {
+ if (flags & NI_NOFQDN) {
+ p = strchr(hp->h_name, '.');
+ if (p) *p = '\0';
+ }
+ if (strlen(hp->h_name) + 1 > hostlen) {
+#ifdef INET6
+ freehostent(hp);
+#endif
+ return ENI_MEMORY;
+ }
+ strcpy(host, hp->h_name);
+#ifdef INET6
+ freehostent(hp);
+#endif
+ } else {
+ if (flags & NI_NAMEREQD)
+ return ENI_NOHOSTNAME;
+ if (inet_ntop(afd->a_af, addr, numaddr, sizeof(numaddr))
+ == NULL)
+ return ENI_NOHOSTNAME;
+ if (strlen(numaddr) > hostlen)
+ return ENI_MEMORY;
+ strcpy(host, numaddr);
+ }
+ }
+ return SUCCESS;
+}
diff --git a/jni/ruby/ext/socket/ifaddr.c b/jni/ruby/ext/socket/ifaddr.c
new file mode 100644
index 0000000..15395d7
--- /dev/null
+++ b/jni/ruby/ext/socket/ifaddr.c
@@ -0,0 +1,459 @@
+#include "rubysocket.h"
+
+#ifdef HAVE_GETIFADDRS
+
+/*
+ * ifa_flags is usually unsigned int.
+ * However it is uint64_t on SunOS 5.11 (OpenIndiana).
+ */
+#ifdef HAVE_LONG_LONG
+typedef unsigned LONG_LONG ifa_flags_t;
+#define PRIxIFAFLAGS PRI_LL_PREFIX"x"
+#define IFAFLAGS2NUM(flags) ULL2NUM(flags)
+#else
+typedef unsigned int ifa_flags_t;
+#define PRIxIFAFLAGS "x"
+#define IFAFLAGS2NUM(flags) UINT2NUM(flags)
+#endif
+
+VALUE rb_cSockIfaddr;
+
+typedef struct rb_ifaddr_tag rb_ifaddr_t;
+typedef struct rb_ifaddr_root_tag rb_ifaddr_root_t;
+
+struct rb_ifaddr_tag {
+ int ord;
+ struct ifaddrs *ifaddr;
+ rb_ifaddr_root_t *root;
+};
+
+struct rb_ifaddr_root_tag {
+ int refcount;
+ int numifaddrs;
+ rb_ifaddr_t ary[1];
+};
+
+static rb_ifaddr_root_t *
+get_root(const rb_ifaddr_t *ifaddr)
+{
+ return (rb_ifaddr_root_t *)((char *)&ifaddr[-ifaddr->ord] -
+ offsetof(rb_ifaddr_root_t, ary));
+}
+
+static void
+ifaddr_mark(void *ptr)
+{
+}
+
+static void
+ifaddr_free(void *ptr)
+{
+ rb_ifaddr_t *ifaddr = ptr;
+ rb_ifaddr_root_t *root = get_root(ifaddr);
+ root->refcount--;
+ if (root->refcount == 0) {
+ freeifaddrs(root->ary[0].ifaddr);
+ xfree(root);
+ }
+}
+
+static size_t
+ifaddr_memsize(const void *ptr)
+{
+ const rb_ifaddr_t *ifaddr;
+ const rb_ifaddr_root_t *root;
+ if (ptr == NULL)
+ return 0;
+ ifaddr = ptr;
+ root = get_root(ifaddr);
+ return sizeof(rb_ifaddr_root_t) + (root->numifaddrs - 1) * sizeof(rb_ifaddr_t);
+}
+
+static const rb_data_type_t ifaddr_type = {
+ "socket/ifaddr",
+ {ifaddr_mark, ifaddr_free, ifaddr_memsize,},
+};
+
+static inline rb_ifaddr_t *
+check_ifaddr(VALUE self)
+{
+ return rb_check_typeddata(self, &ifaddr_type);
+}
+
+static rb_ifaddr_t *
+get_ifaddr(VALUE self)
+{
+ rb_ifaddr_t *rifaddr = check_ifaddr(self);
+
+ if (!rifaddr) {
+ rb_raise(rb_eTypeError, "uninitialized ifaddr");
+ }
+ return rifaddr;
+}
+
+static VALUE
+rsock_getifaddrs(void)
+{
+ int ret;
+ int numifaddrs, i;
+ struct ifaddrs *ifaddrs, *ifa;
+ rb_ifaddr_root_t *root;
+ VALUE result;
+
+ ret = getifaddrs(&ifaddrs);
+ if (ret == -1)
+ rb_sys_fail("getifaddrs");
+
+ if (!ifaddrs) {
+ return rb_ary_new();
+ }
+
+ numifaddrs = 0;
+ for (ifa = ifaddrs; ifa != NULL; ifa = ifa->ifa_next)
+ numifaddrs++;
+
+ root = xmalloc(sizeof(rb_ifaddr_root_t) + (numifaddrs-1) * sizeof(rb_ifaddr_t));
+ root->refcount = root->numifaddrs = numifaddrs;
+
+ ifa = ifaddrs;
+ for (i = 0; i < numifaddrs; i++) {
+ root->ary[i].ord = i;
+ root->ary[i].ifaddr = ifa;
+ root->ary[i].root = root;
+ ifa = ifa->ifa_next;
+ }
+
+ result = rb_ary_new2(numifaddrs);
+ for (i = 0; i < numifaddrs; i++) {
+ rb_ary_push(result, TypedData_Wrap_Struct(rb_cSockIfaddr, &ifaddr_type, &root->ary[i]));
+ }
+
+ return result;
+}
+
+/*
+ * call-seq:
+ * ifaddr.name => string
+ *
+ * Returns the interface name of _ifaddr_.
+ */
+
+static VALUE
+ifaddr_name(VALUE self)
+{
+ rb_ifaddr_t *rifaddr = get_ifaddr(self);
+ struct ifaddrs *ifa = rifaddr->ifaddr;
+ return rb_str_new_cstr(ifa->ifa_name);
+}
+
+#ifdef HAVE_IF_NAMETOINDEX
+/*
+ * call-seq:
+ * ifaddr.ifindex => integer
+ *
+ * Returns the interface index of _ifaddr_.
+ */
+
+static VALUE
+ifaddr_ifindex(VALUE self)
+{
+ rb_ifaddr_t *rifaddr = get_ifaddr(self);
+ struct ifaddrs *ifa = rifaddr->ifaddr;
+ unsigned int ifindex = if_nametoindex(ifa->ifa_name);
+ if (ifindex == 0) {
+ rb_raise(rb_eArgError, "invalid interface name: %s", ifa->ifa_name);
+ }
+ return UINT2NUM(ifindex);
+}
+#else
+#define ifaddr_ifindex rb_f_notimplement
+#endif
+
+/*
+ * call-seq:
+ * ifaddr.flags => integer
+ *
+ * Returns the flags of _ifaddr_.
+ */
+
+static VALUE
+ifaddr_flags(VALUE self)
+{
+ rb_ifaddr_t *rifaddr = get_ifaddr(self);
+ struct ifaddrs *ifa = rifaddr->ifaddr;
+ return IFAFLAGS2NUM(ifa->ifa_flags);
+}
+
+/*
+ * call-seq:
+ * ifaddr.addr => addrinfo
+ *
+ * Returns the address of _ifaddr_.
+ * nil is returned if address is not available in _ifaddr_.
+ */
+
+static VALUE
+ifaddr_addr(VALUE self)
+{
+ rb_ifaddr_t *rifaddr = get_ifaddr(self);
+ struct ifaddrs *ifa = rifaddr->ifaddr;
+ if (ifa->ifa_addr)
+ return rsock_sockaddr_obj(ifa->ifa_addr, rsock_sockaddr_len(ifa->ifa_addr));
+ return Qnil;
+}
+
+/*
+ * call-seq:
+ * ifaddr.netmask => addrinfo
+ *
+ * Returns the netmask address of _ifaddr_.
+ * nil is returned if netmask is not available in _ifaddr_.
+ */
+
+static VALUE
+ifaddr_netmask(VALUE self)
+{
+ rb_ifaddr_t *rifaddr = get_ifaddr(self);
+ struct ifaddrs *ifa = rifaddr->ifaddr;
+ if (ifa->ifa_netmask)
+ return rsock_sockaddr_obj(ifa->ifa_netmask, rsock_sockaddr_len(ifa->ifa_netmask));
+ return Qnil;
+}
+
+/*
+ * call-seq:
+ * ifaddr.broadaddr => addrinfo
+ *
+ * Returns the broadcast address of _ifaddr_.
+ * nil is returned if the flags doesn't have IFF_BROADCAST.
+ */
+
+static VALUE
+ifaddr_broadaddr(VALUE self)
+{
+ rb_ifaddr_t *rifaddr = get_ifaddr(self);
+ struct ifaddrs *ifa = rifaddr->ifaddr;
+ if ((ifa->ifa_flags & IFF_BROADCAST) && ifa->ifa_broadaddr)
+ return rsock_sockaddr_obj(ifa->ifa_broadaddr, rsock_sockaddr_len(ifa->ifa_broadaddr));
+ return Qnil;
+}
+
+/*
+ * call-seq:
+ * ifaddr.dstaddr => addrinfo
+ *
+ * Returns the destination address of _ifaddr_.
+ * nil is returned if the flags doesn't have IFF_POINTOPOINT.
+ */
+
+static VALUE
+ifaddr_dstaddr(VALUE self)
+{
+ rb_ifaddr_t *rifaddr = get_ifaddr(self);
+ struct ifaddrs *ifa = rifaddr->ifaddr;
+ if ((ifa->ifa_flags & IFF_POINTOPOINT) && ifa->ifa_dstaddr)
+ return rsock_sockaddr_obj(ifa->ifa_dstaddr, rsock_sockaddr_len(ifa->ifa_dstaddr));
+ return Qnil;
+}
+
+static void
+ifaddr_inspect_flags(ifa_flags_t flags, VALUE result)
+{
+ const char *sep = " ";
+#define INSPECT_BIT(bit, name) \
+ if (flags & (bit)) { rb_str_catf(result, "%s" name, sep); flags &= ~(ifa_flags_t)(bit); sep = ","; }
+#ifdef IFF_UP
+ INSPECT_BIT(IFF_UP, "UP")
+#endif
+#ifdef IFF_BROADCAST
+ INSPECT_BIT(IFF_BROADCAST, "BROADCAST")
+#endif
+#ifdef IFF_DEBUG
+ INSPECT_BIT(IFF_DEBUG, "DEBUG")
+#endif
+#ifdef IFF_LOOPBACK
+ INSPECT_BIT(IFF_LOOPBACK, "LOOPBACK")
+#endif
+#ifdef IFF_POINTOPOINT
+ INSPECT_BIT(IFF_POINTOPOINT, "POINTOPOINT")
+#endif
+#ifdef IFF_RUNNING
+ INSPECT_BIT(IFF_RUNNING, "RUNNING")
+#endif
+#ifdef IFF_NOARP
+ INSPECT_BIT(IFF_NOARP, "NOARP")
+#endif
+#ifdef IFF_PROMISC
+ INSPECT_BIT(IFF_PROMISC, "PROMISC")
+#endif
+#ifdef IFF_NOTRAILERS
+ INSPECT_BIT(IFF_NOTRAILERS, "NOTRAILERS")
+#endif
+#ifdef IFF_ALLMULTI
+ INSPECT_BIT(IFF_ALLMULTI, "ALLMULTI")
+#endif
+#ifdef IFF_SIMPLEX
+ INSPECT_BIT(IFF_SIMPLEX, "SIMPLEX")
+#endif
+#ifdef IFF_MASTER
+ INSPECT_BIT(IFF_MASTER, "MASTER")
+#endif
+#ifdef IFF_SLAVE
+ INSPECT_BIT(IFF_SLAVE, "SLAVE")
+#endif
+#ifdef IFF_MULTICAST
+ INSPECT_BIT(IFF_MULTICAST, "MULTICAST")
+#endif
+#ifdef IFF_PORTSEL
+ INSPECT_BIT(IFF_PORTSEL, "PORTSEL")
+#endif
+#ifdef IFF_AUTOMEDIA
+ INSPECT_BIT(IFF_AUTOMEDIA, "AUTOMEDIA")
+#endif
+#ifdef IFF_DYNAMIC
+ INSPECT_BIT(IFF_DYNAMIC, "DYNAMIC")
+#endif
+#ifdef IFF_LOWER_UP
+ INSPECT_BIT(IFF_LOWER_UP, "LOWER_UP")
+#endif
+#ifdef IFF_DORMANT
+ INSPECT_BIT(IFF_DORMANT, "DORMANT")
+#endif
+#ifdef IFF_ECHO
+ INSPECT_BIT(IFF_ECHO, "ECHO")
+#endif
+#undef INSPECT_BIT
+ if (flags) {
+ rb_str_catf(result, "%s%#"PRIxIFAFLAGS, sep, flags);
+ }
+}
+
+/*
+ * call-seq:
+ * ifaddr.inspect => string
+ *
+ * Returns a string to show contents of _ifaddr_.
+ */
+
+static VALUE
+ifaddr_inspect(VALUE self)
+{
+ rb_ifaddr_t *rifaddr = get_ifaddr(self);
+ struct ifaddrs *ifa;
+ VALUE result;
+
+ ifa = rifaddr->ifaddr;
+
+ result = rb_str_new_cstr("#<");
+
+ rb_str_append(result, rb_class_name(CLASS_OF(self)));
+ rb_str_cat2(result, " ");
+ rb_str_cat2(result, ifa->ifa_name);
+
+ if (ifa->ifa_flags)
+ ifaddr_inspect_flags(ifa->ifa_flags, result);
+
+ if (ifa->ifa_addr) {
+ rb_str_cat2(result, " ");
+ rsock_inspect_sockaddr(ifa->ifa_addr,
+ rsock_sockaddr_len(ifa->ifa_addr),
+ result);
+ }
+ if (ifa->ifa_netmask) {
+ rb_str_cat2(result, " netmask=");
+ rsock_inspect_sockaddr(ifa->ifa_netmask,
+ rsock_sockaddr_len(ifa->ifa_netmask),
+ result);
+ }
+
+ if ((ifa->ifa_flags & IFF_BROADCAST) && ifa->ifa_broadaddr) {
+ rb_str_cat2(result, " broadcast=");
+ rsock_inspect_sockaddr(ifa->ifa_broadaddr,
+ rsock_sockaddr_len(ifa->ifa_broadaddr),
+ result);
+ }
+
+ if ((ifa->ifa_flags & IFF_POINTOPOINT) && ifa->ifa_dstaddr) {
+ rb_str_cat2(result, " dstaddr=");
+ rsock_inspect_sockaddr(ifa->ifa_dstaddr,
+ rsock_sockaddr_len(ifa->ifa_dstaddr),
+ result);
+ }
+
+ rb_str_cat2(result, ">");
+ return result;
+}
+#endif
+
+#ifdef HAVE_GETIFADDRS
+/*
+ * call-seq:
+ * Socket.getifaddrs => [ifaddr1, ...]
+ *
+ * Returns an array of interface addresses.
+ * An element of the array is an instance of Socket::Ifaddr.
+ *
+ * This method can be used to find multicast-enabled interfaces:
+ *
+ * pp Socket.getifaddrs.reject {|ifaddr|
+ * !ifaddr.addr.ip? || (ifaddr.flags & Socket::IFF_MULTICAST == 0)
+ * }.map {|ifaddr| [ifaddr.name, ifaddr.ifindex, ifaddr.addr] }
+ * #=> [["eth0", 2, #<Addrinfo: 221.186.184.67>],
+ * # ["eth0", 2, #<Addrinfo: fe80::216:3eff:fe95:88bb%eth0>]]
+ *
+ * Example result on GNU/Linux:
+ * pp Socket.getifaddrs
+ * #=> [#<Socket::Ifaddr lo UP,LOOPBACK,RUNNING,0x10000 PACKET[protocol=0 lo hatype=772 HOST hwaddr=00:00:00:00:00:00]>,
+ * # #<Socket::Ifaddr eth0 UP,BROADCAST,RUNNING,MULTICAST,0x10000 PACKET[protocol=0 eth0 hatype=1 HOST hwaddr=00:16:3e:95:88:bb] broadcast=PACKET[protocol=0 eth0 hatype=1 HOST hwaddr=ff:ff:ff:ff:ff:ff]>,
+ * # #<Socket::Ifaddr sit0 NOARP PACKET[protocol=0 sit0 hatype=776 HOST hwaddr=00:00:00:00]>,
+ * # #<Socket::Ifaddr lo UP,LOOPBACK,RUNNING,0x10000 127.0.0.1 netmask=255.0.0.0>,
+ * # #<Socket::Ifaddr eth0 UP,BROADCAST,RUNNING,MULTICAST,0x10000 221.186.184.67 netmask=255.255.255.240 broadcast=221.186.184.79>,
+ * # #<Socket::Ifaddr lo UP,LOOPBACK,RUNNING,0x10000 ::1 netmask=ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff>,
+ * # #<Socket::Ifaddr eth0 UP,BROADCAST,RUNNING,MULTICAST,0x10000 fe80::216:3eff:fe95:88bb%eth0 netmask=ffff:ffff:ffff:ffff::>]
+ *
+ * Example result on FreeBSD:
+ * pp Socket.getifaddrs
+ * #=> [#<Socket::Ifaddr usbus0 UP,0x10000 LINK[usbus0]>,
+ * # #<Socket::Ifaddr re0 UP,BROADCAST,RUNNING,MULTICAST,0x800 LINK[re0 3a:d0:40:9a:fe:e8]>,
+ * # #<Socket::Ifaddr re0 UP,BROADCAST,RUNNING,MULTICAST,0x800 10.250.10.18 netmask=255.255.255.? (7 bytes for 16 bytes sockaddr_in) broadcast=10.250.10.255>,
+ * # #<Socket::Ifaddr re0 UP,BROADCAST,RUNNING,MULTICAST,0x800 fe80:2::38d0:40ff:fe9a:fee8 netmask=ffff:ffff:ffff:ffff::>,
+ * # #<Socket::Ifaddr re0 UP,BROADCAST,RUNNING,MULTICAST,0x800 2001:2e8:408:10::12 netmask=UNSPEC>,
+ * # #<Socket::Ifaddr plip0 POINTOPOINT,MULTICAST,0x800 LINK[plip0]>,
+ * # #<Socket::Ifaddr lo0 UP,LOOPBACK,RUNNING,MULTICAST LINK[lo0]>,
+ * # #<Socket::Ifaddr lo0 UP,LOOPBACK,RUNNING,MULTICAST ::1 netmask=ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff>,
+ * # #<Socket::Ifaddr lo0 UP,LOOPBACK,RUNNING,MULTICAST fe80:4::1 netmask=ffff:ffff:ffff:ffff::>,
+ * # #<Socket::Ifaddr lo0 UP,LOOPBACK,RUNNING,MULTICAST 127.0.0.1 netmask=255.?.?.? (5 bytes for 16 bytes sockaddr_in)>]
+ *
+ */
+
+static VALUE
+socket_s_getifaddrs(VALUE self)
+{
+ return rsock_getifaddrs();
+}
+#else
+#define socket_s_getifaddrs rb_f_notimplement
+#endif
+
+void
+rsock_init_sockifaddr(void)
+{
+#ifdef HAVE_GETIFADDRS
+ /*
+ * Document-class: Socket::Ifaddr
+ *
+ * Socket::Ifaddr represents a result of getifaddrs() function.
+ */
+ rb_cSockIfaddr = rb_define_class_under(rb_cSocket, "Ifaddr", rb_cData);
+ rb_define_method(rb_cSockIfaddr, "inspect", ifaddr_inspect, 0);
+ rb_define_method(rb_cSockIfaddr, "name", ifaddr_name, 0);
+ rb_define_method(rb_cSockIfaddr, "ifindex", ifaddr_ifindex, 0);
+ rb_define_method(rb_cSockIfaddr, "flags", ifaddr_flags, 0);
+ rb_define_method(rb_cSockIfaddr, "addr", ifaddr_addr, 0);
+ rb_define_method(rb_cSockIfaddr, "netmask", ifaddr_netmask, 0);
+ rb_define_method(rb_cSockIfaddr, "broadaddr", ifaddr_broadaddr, 0);
+ rb_define_method(rb_cSockIfaddr, "dstaddr", ifaddr_dstaddr, 0);
+#endif
+
+ rb_define_singleton_method(rb_cSocket, "getifaddrs", socket_s_getifaddrs, 0);
+}
diff --git a/jni/ruby/ext/socket/init.c b/jni/ruby/ext/socket/init.c
new file mode 100644
index 0000000..c3f3396
--- /dev/null
+++ b/jni/ruby/ext/socket/init.c
@@ -0,0 +1,615 @@
+/************************************************
+
+ init.c -
+
+ created at: Thu Mar 31 12:21:29 JST 1994
+
+ Copyright (C) 1993-2007 Yukihiro Matsumoto
+
+************************************************/
+
+#include "rubysocket.h"
+
+VALUE rb_cBasicSocket;
+VALUE rb_cIPSocket;
+VALUE rb_cTCPSocket;
+VALUE rb_cTCPServer;
+VALUE rb_cUDPSocket;
+#ifdef AF_UNIX
+VALUE rb_cUNIXSocket;
+VALUE rb_cUNIXServer;
+#endif
+VALUE rb_cSocket;
+VALUE rb_cAddrinfo;
+
+VALUE rb_eSocket;
+
+#ifdef SOCKS
+VALUE rb_cSOCKSSocket;
+#endif
+
+int rsock_do_not_reverse_lookup = 1;
+
+void
+rsock_raise_socket_error(const char *reason, int error)
+{
+#ifdef EAI_SYSTEM
+ if (error == EAI_SYSTEM) rb_sys_fail(reason);
+#endif
+ rb_raise(rb_eSocket, "%s: %s", reason, gai_strerror(error));
+}
+
+VALUE
+rsock_init_sock(VALUE sock, int fd)
+{
+ rb_io_t *fp;
+#ifndef _WIN32
+ struct stat sbuf;
+
+ if (fstat(fd, &sbuf) < 0)
+ rb_sys_fail("fstat(2)");
+ rb_update_max_fd(fd);
+ if (!S_ISSOCK(sbuf.st_mode))
+ rb_raise(rb_eArgError, "not a socket file descriptor");
+#else
+ rb_update_max_fd(fd);
+ if (!rb_w32_is_socket(fd))
+ rb_raise(rb_eArgError, "not a socket file descriptor");
+#endif
+
+ MakeOpenFile(sock, fp);
+ fp->fd = fd;
+ fp->mode = FMODE_READWRITE|FMODE_DUPLEX;
+ rb_io_ascii8bit_binmode(sock);
+ if (rsock_do_not_reverse_lookup) {
+ fp->mode |= FMODE_NOREVLOOKUP;
+ }
+ rb_io_synchronized(fp);
+
+ return sock;
+}
+
+VALUE
+rsock_sendto_blocking(void *data)
+{
+ struct rsock_send_arg *arg = data;
+ VALUE mesg = arg->mesg;
+ return (VALUE)sendto(arg->fd, RSTRING_PTR(mesg), RSTRING_LEN(mesg),
+ arg->flags, arg->to, arg->tolen);
+}
+
+VALUE
+rsock_send_blocking(void *data)
+{
+ struct rsock_send_arg *arg = data;
+ VALUE mesg = arg->mesg;
+ return (VALUE)send(arg->fd, RSTRING_PTR(mesg), RSTRING_LEN(mesg),
+ arg->flags);
+}
+
+struct recvfrom_arg {
+ int fd, flags;
+ VALUE str;
+ socklen_t alen;
+ union_sockaddr buf;
+};
+
+static VALUE
+recvfrom_blocking(void *data)
+{
+ struct recvfrom_arg *arg = data;
+ socklen_t len0 = arg->alen;
+ ssize_t ret;
+ ret = recvfrom(arg->fd, RSTRING_PTR(arg->str), RSTRING_LEN(arg->str),
+ arg->flags, &arg->buf.addr, &arg->alen);
+ if (ret != -1 && len0 < arg->alen)
+ arg->alen = len0;
+ return (VALUE)ret;
+}
+
+VALUE
+rsock_s_recvfrom(VALUE sock, int argc, VALUE *argv, enum sock_recv_type from)
+{
+ rb_io_t *fptr;
+ VALUE str, klass;
+ struct recvfrom_arg arg;
+ VALUE len, flg;
+ long buflen;
+ long slen;
+
+ rb_scan_args(argc, argv, "11", &len, &flg);
+
+ if (flg == Qnil) arg.flags = 0;
+ else arg.flags = NUM2INT(flg);
+ buflen = NUM2INT(len);
+
+ GetOpenFile(sock, fptr);
+ if (rb_io_read_pending(fptr)) {
+ rb_raise(rb_eIOError, "recv for buffered IO");
+ }
+ arg.fd = fptr->fd;
+ arg.alen = (socklen_t)sizeof(arg.buf);
+
+ arg.str = str = rb_tainted_str_new(0, buflen);
+ klass = RBASIC(str)->klass;
+ rb_obj_hide(str);
+
+ while (rb_io_check_closed(fptr),
+ rsock_maybe_wait_fd(arg.fd),
+ (slen = BLOCKING_REGION_FD(recvfrom_blocking, &arg)) < 0) {
+ if (!rb_io_wait_readable(fptr->fd)) {
+ rb_sys_fail("recvfrom(2)");
+ }
+ if (RBASIC(str)->klass || RSTRING_LEN(str) != buflen) {
+ rb_raise(rb_eRuntimeError, "buffer string modified");
+ }
+ }
+
+ rb_obj_reveal(str, klass);
+ if (slen < RSTRING_LEN(str)) {
+ rb_str_set_len(str, slen);
+ }
+ rb_obj_taint(str);
+ switch (from) {
+ case RECV_RECV:
+ return str;
+ case RECV_IP:
+#if 0
+ if (arg.alen != sizeof(struct sockaddr_in)) {
+ rb_raise(rb_eTypeError, "sockaddr size differs - should not happen");
+ }
+#endif
+ if (arg.alen && arg.alen != sizeof(arg.buf)) /* OSX doesn't return a from result for connection-oriented sockets */
+ return rb_assoc_new(str, rsock_ipaddr(&arg.buf.addr, arg.alen, fptr->mode & FMODE_NOREVLOOKUP));
+ else
+ return rb_assoc_new(str, Qnil);
+
+#ifdef HAVE_SYS_UN_H
+ case RECV_UNIX:
+ return rb_assoc_new(str, rsock_unixaddr(&arg.buf.un, arg.alen));
+#endif
+ case RECV_SOCKET:
+ return rb_assoc_new(str, rsock_io_socket_addrinfo(sock, &arg.buf.addr, arg.alen));
+ default:
+ rb_bug("rsock_s_recvfrom called with bad value");
+ }
+}
+
+VALUE
+rsock_s_recvfrom_nonblock(VALUE sock, int argc, VALUE *argv, enum sock_recv_type from)
+{
+ rb_io_t *fptr;
+ VALUE str;
+ union_sockaddr buf;
+ socklen_t alen = (socklen_t)sizeof buf;
+ VALUE len, flg;
+ long buflen;
+ long slen;
+ int fd, flags;
+ VALUE addr = Qnil;
+ socklen_t len0;
+
+ rb_scan_args(argc, argv, "11", &len, &flg);
+
+ if (flg == Qnil) flags = 0;
+ else flags = NUM2INT(flg);
+ buflen = NUM2INT(len);
+
+#ifdef MSG_DONTWAIT
+ /* MSG_DONTWAIT avoids the race condition between fcntl and recvfrom.
+ It is not portable, though. */
+ flags |= MSG_DONTWAIT;
+#endif
+
+ GetOpenFile(sock, fptr);
+ if (rb_io_read_pending(fptr)) {
+ rb_raise(rb_eIOError, "recvfrom for buffered IO");
+ }
+ fd = fptr->fd;
+
+ str = rb_tainted_str_new(0, buflen);
+
+ rb_io_check_closed(fptr);
+ rb_io_set_nonblock(fptr);
+ len0 = alen;
+ slen = recvfrom(fd, RSTRING_PTR(str), buflen, flags, &buf.addr, &alen);
+ if (slen != -1 && len0 < alen)
+ alen = len0;
+
+ if (slen < 0) {
+ switch (errno) {
+ case EAGAIN:
+#if defined(EWOULDBLOCK) && EWOULDBLOCK != EAGAIN
+ case EWOULDBLOCK:
+#endif
+ rb_readwrite_sys_fail(RB_IO_WAIT_READABLE, "recvfrom(2) would block");
+ }
+ rb_sys_fail("recvfrom(2)");
+ }
+ if (slen < RSTRING_LEN(str)) {
+ rb_str_set_len(str, slen);
+ }
+ rb_obj_taint(str);
+ switch (from) {
+ case RECV_RECV:
+ return str;
+
+ case RECV_IP:
+ if (alen && alen != sizeof(buf)) /* connection-oriented socket may not return a from result */
+ addr = rsock_ipaddr(&buf.addr, alen, fptr->mode & FMODE_NOREVLOOKUP);
+ break;
+
+ case RECV_SOCKET:
+ addr = rsock_io_socket_addrinfo(sock, &buf.addr, alen);
+ break;
+
+ default:
+ rb_bug("rsock_s_recvfrom_nonblock called with bad value");
+ }
+ return rb_assoc_new(str, addr);
+}
+
+/* returns true if SOCK_CLOEXEC is supported */
+int rsock_detect_cloexec(int fd)
+{
+#ifdef SOCK_CLOEXEC
+ int flags = fcntl(fd, F_GETFD);
+
+ if (flags == -1)
+ rb_bug("rsock_detect_cloexec: fcntl(%d, F_GETFD) failed: %s", fd, strerror(errno));
+
+ if (flags & FD_CLOEXEC)
+ return 1;
+#endif
+ return 0;
+}
+
+#ifdef SOCK_CLOEXEC
+static int
+rsock_socket0(int domain, int type, int proto)
+{
+ int ret;
+ static int cloexec_state = -1; /* <0: unknown, 0: ignored, >0: working */
+
+ if (cloexec_state > 0) { /* common path, if SOCK_CLOEXEC is defined */
+ ret = socket(domain, type|SOCK_CLOEXEC, proto);
+ if (ret >= 0) {
+ if (ret <= 2)
+ goto fix_cloexec;
+ goto update_max_fd;
+ }
+ }
+ else if (cloexec_state < 0) { /* usually runs once only for detection */
+ ret = socket(domain, type|SOCK_CLOEXEC, proto);
+ if (ret >= 0) {
+ cloexec_state = rsock_detect_cloexec(ret);
+ if (cloexec_state == 0 || ret <= 2)
+ goto fix_cloexec;
+ goto update_max_fd;
+ }
+ else if (ret == -1 && errno == EINVAL) {
+ /* SOCK_CLOEXEC is available since Linux 2.6.27. Linux 2.6.18 fails with EINVAL */
+ ret = socket(domain, type, proto);
+ if (ret != -1) {
+ cloexec_state = 0;
+ /* fall through to fix_cloexec */
+ }
+ }
+ }
+ else { /* cloexec_state == 0 */
+ ret = socket(domain, type, proto);
+ }
+ if (ret == -1)
+ return -1;
+fix_cloexec:
+ rb_maygvl_fd_fix_cloexec(ret);
+update_max_fd:
+ rb_update_max_fd(ret);
+
+ return ret;
+}
+#else /* !SOCK_CLOEXEC */
+static int
+rsock_socket0(int domain, int type, int proto)
+{
+ int ret = socket(domain, type, proto);
+
+ if (ret == -1)
+ return -1;
+ rb_fd_fix_cloexec(ret);
+
+ return ret;
+}
+#endif /* !SOCK_CLOEXEC */
+
+int
+rsock_socket(int domain, int type, int proto)
+{
+ int fd;
+
+ fd = rsock_socket0(domain, type, proto);
+ if (fd < 0) {
+ if (errno == EMFILE || errno == ENFILE) {
+ rb_gc();
+ fd = rsock_socket0(domain, type, proto);
+ }
+ }
+ if (0 <= fd)
+ rb_update_max_fd(fd);
+ return fd;
+}
+
+/* emulate blocking connect behavior on EINTR or non-blocking socket */
+static int
+wait_connectable(int fd)
+{
+ int sockerr, revents;
+ socklen_t sockerrlen;
+
+ /* only to clear pending error */
+ sockerrlen = (socklen_t)sizeof(sockerr);
+ if (getsockopt(fd, SOL_SOCKET, SO_ERROR, (void *)&sockerr, &sockerrlen) < 0)
+ return -1;
+
+ /*
+ * Stevens book says, successful finish turn on RB_WAITFD_OUT and
+ * failure finish turn on both RB_WAITFD_IN and RB_WAITFD_OUT.
+ * So it's enough to wait only RB_WAITFD_OUT and check the pending error
+ * by getsockopt().
+ *
+ * Note: rb_wait_for_single_fd already retries on EINTR/ERESTART
+ */
+ revents = rb_wait_for_single_fd(fd, RB_WAITFD_IN|RB_WAITFD_OUT, NULL);
+
+ if (revents < 0)
+ return -1;
+
+ sockerrlen = (socklen_t)sizeof(sockerr);
+ if (getsockopt(fd, SOL_SOCKET, SO_ERROR, (void *)&sockerr, &sockerrlen) < 0)
+ return -1;
+
+ switch (sockerr) {
+ case 0:
+ /*
+ * be defensive in case some platforms set SO_ERROR on the original,
+ * interrupted connect()
+ */
+ case EINTR:
+#ifdef ERESTART
+ case ERESTART:
+#endif
+ case EAGAIN:
+#ifdef EINPROGRESS
+ case EINPROGRESS:
+#endif
+#ifdef EALREADY
+ case EALREADY:
+#endif
+#ifdef EISCONN
+ case EISCONN:
+#endif
+ return 0; /* success */
+ default:
+ /* likely (but not limited to): ECONNREFUSED, ETIMEDOUT, EHOSTUNREACH */
+ errno = sockerr;
+ return -1;
+ }
+
+ return 0;
+}
+
+struct connect_arg {
+ int fd;
+ socklen_t len;
+ const struct sockaddr *sockaddr;
+};
+
+static VALUE
+connect_blocking(void *data)
+{
+ struct connect_arg *arg = data;
+ return (VALUE)connect(arg->fd, arg->sockaddr, arg->len);
+}
+
+#if defined(SOCKS) && !defined(SOCKS5)
+static VALUE
+socks_connect_blocking(void *data)
+{
+ struct connect_arg *arg = data;
+ return (VALUE)Rconnect(arg->fd, arg->sockaddr, arg->len);
+}
+#endif
+
+int
+rsock_connect(int fd, const struct sockaddr *sockaddr, int len, int socks)
+{
+ int status;
+ rb_blocking_function_t *func = connect_blocking;
+ struct connect_arg arg;
+
+ arg.fd = fd;
+ arg.sockaddr = sockaddr;
+ arg.len = len;
+#if defined(SOCKS) && !defined(SOCKS5)
+ if (socks) func = socks_connect_blocking;
+#endif
+ status = (int)BLOCKING_REGION_FD(func, &arg);
+
+ if (status < 0) {
+ switch (errno) {
+ case EINTR:
+#ifdef ERESTART
+ case ERESTART:
+#endif
+ case EAGAIN:
+#ifdef EINPROGRESS
+ case EINPROGRESS:
+#endif
+ return wait_connectable(fd);
+ }
+ }
+ return status;
+}
+
+static void
+make_fd_nonblock(int fd)
+{
+ int flags;
+#ifdef F_GETFL
+ flags = fcntl(fd, F_GETFL);
+ if (flags == -1) {
+ rb_sys_fail("fnctl(2)");
+ }
+#else
+ flags = 0;
+#endif
+ flags |= O_NONBLOCK;
+ if (fcntl(fd, F_SETFL, flags) == -1) {
+ rb_sys_fail("fnctl(2)");
+ }
+}
+
+static int
+cloexec_accept(int socket, struct sockaddr *address, socklen_t *address_len)
+{
+ int ret;
+ socklen_t len0 = 0;
+#ifdef HAVE_ACCEPT4
+ static int try_accept4 = 1;
+#endif
+ if (address_len) len0 = *address_len;
+#ifdef HAVE_ACCEPT4
+ if (try_accept4) {
+ int flags = 0;
+#ifdef SOCK_CLOEXEC
+ flags |= SOCK_CLOEXEC;
+#endif
+ ret = accept4(socket, address, address_len, flags);
+ /* accept4 is available since Linux 2.6.28, glibc 2.10. */
+ if (ret != -1) {
+ if (ret <= 2)
+ rb_maygvl_fd_fix_cloexec(ret);
+ if (address_len && len0 < *address_len) *address_len = len0;
+ return ret;
+ }
+ if (errno != ENOSYS) {
+ return -1;
+ }
+ try_accept4 = 0;
+ }
+#endif
+ ret = accept(socket, address, address_len);
+ if (ret == -1) return -1;
+ if (address_len && len0 < *address_len) *address_len = len0;
+ rb_maygvl_fd_fix_cloexec(ret);
+ return ret;
+}
+
+
+VALUE
+rsock_s_accept_nonblock(VALUE klass, rb_io_t *fptr, struct sockaddr *sockaddr, socklen_t *len)
+{
+ int fd2;
+
+ rb_secure(3);
+ rb_io_set_nonblock(fptr);
+ fd2 = cloexec_accept(fptr->fd, (struct sockaddr*)sockaddr, len);
+ if (fd2 < 0) {
+ switch (errno) {
+ case EAGAIN:
+#if defined(EWOULDBLOCK) && EWOULDBLOCK != EAGAIN
+ case EWOULDBLOCK:
+#endif
+ case ECONNABORTED:
+#if defined EPROTO
+ case EPROTO:
+#endif
+ rb_readwrite_sys_fail(RB_IO_WAIT_READABLE, "accept(2) would block");
+ }
+ rb_sys_fail("accept(2)");
+ }
+ rb_update_max_fd(fd2);
+ make_fd_nonblock(fd2);
+ return rsock_init_sock(rb_obj_alloc(klass), fd2);
+}
+
+struct accept_arg {
+ int fd;
+ struct sockaddr *sockaddr;
+ socklen_t *len;
+};
+
+static VALUE
+accept_blocking(void *data)
+{
+ struct accept_arg *arg = data;
+ return (VALUE)cloexec_accept(arg->fd, arg->sockaddr, arg->len);
+}
+
+VALUE
+rsock_s_accept(VALUE klass, int fd, struct sockaddr *sockaddr, socklen_t *len)
+{
+ int fd2;
+ int retry = 0;
+ struct accept_arg arg;
+
+ rb_secure(3);
+ arg.fd = fd;
+ arg.sockaddr = sockaddr;
+ arg.len = len;
+ retry:
+ rsock_maybe_wait_fd(fd);
+ fd2 = (int)BLOCKING_REGION_FD(accept_blocking, &arg);
+ if (fd2 < 0) {
+ switch (errno) {
+ case EMFILE:
+ case ENFILE:
+ if (retry) break;
+ rb_gc();
+ retry = 1;
+ goto retry;
+ default:
+ if (!rb_io_wait_readable(fd)) break;
+ retry = 0;
+ goto retry;
+ }
+ rb_sys_fail("accept(2)");
+ }
+ rb_update_max_fd(fd2);
+ if (!klass) return INT2NUM(fd2);
+ return rsock_init_sock(rb_obj_alloc(klass), fd2);
+}
+
+int
+rsock_getfamily(int sockfd)
+{
+ union_sockaddr ss;
+ socklen_t sslen = (socklen_t)sizeof(ss);
+
+ ss.addr.sa_family = AF_UNSPEC;
+ if (getsockname(sockfd, &ss.addr, &sslen) < 0)
+ return AF_UNSPEC;
+
+ return ss.addr.sa_family;
+}
+
+void
+rsock_init_socket_init(void)
+{
+ /*
+ * SocketError is the error class for socket.
+ */
+ rb_eSocket = rb_define_class("SocketError", rb_eStandardError);
+ rsock_init_ipsocket();
+ rsock_init_tcpsocket();
+ rsock_init_tcpserver();
+ rsock_init_sockssocket();
+ rsock_init_udpsocket();
+ rsock_init_unixsocket();
+ rsock_init_unixserver();
+ rsock_init_sockopt();
+ rsock_init_ancdata();
+ rsock_init_addrinfo();
+ rsock_init_sockifaddr();
+ rsock_init_socket_constants();
+}
diff --git a/jni/ruby/ext/socket/ipsocket.c b/jni/ruby/ext/socket/ipsocket.c
new file mode 100644
index 0000000..16a8373
--- /dev/null
+++ b/jni/ruby/ext/socket/ipsocket.c
@@ -0,0 +1,338 @@
+/************************************************
+
+ ipsocket.c -
+
+ created at: Thu Mar 31 12:21:29 JST 1994
+
+ Copyright (C) 1993-2007 Yukihiro Matsumoto
+
+************************************************/
+
+#include "rubysocket.h"
+
+struct inetsock_arg
+{
+ VALUE sock;
+ struct {
+ VALUE host, serv;
+ struct rb_addrinfo *res;
+ } remote, local;
+ int type;
+ int fd;
+};
+
+static VALUE
+inetsock_cleanup(struct inetsock_arg *arg)
+{
+ if (arg->remote.res) {
+ rb_freeaddrinfo(arg->remote.res);
+ arg->remote.res = 0;
+ }
+ if (arg->local.res) {
+ rb_freeaddrinfo(arg->local.res);
+ arg->local.res = 0;
+ }
+ if (arg->fd >= 0) {
+ close(arg->fd);
+ }
+ return Qnil;
+}
+
+static VALUE
+init_inetsock_internal(struct inetsock_arg *arg)
+{
+ int error = 0;
+ int type = arg->type;
+ struct addrinfo *res, *lres;
+ int fd, status = 0, local = 0;
+ const char *syscall = 0;
+
+ arg->remote.res = rsock_addrinfo(arg->remote.host, arg->remote.serv, SOCK_STREAM,
+ (type == INET_SERVER) ? AI_PASSIVE : 0);
+ /*
+ * Maybe also accept a local address
+ */
+
+ if (type != INET_SERVER && (!NIL_P(arg->local.host) || !NIL_P(arg->local.serv))) {
+ arg->local.res = rsock_addrinfo(arg->local.host, arg->local.serv, SOCK_STREAM, 0);
+ }
+
+ arg->fd = fd = -1;
+ for (res = arg->remote.res->ai; res; res = res->ai_next) {
+#if !defined(INET6) && defined(AF_INET6)
+ if (res->ai_family == AF_INET6)
+ continue;
+#endif
+ lres = NULL;
+ if (arg->local.res) {
+ for (lres = arg->local.res->ai; lres; lres = lres->ai_next) {
+ if (lres->ai_family == res->ai_family)
+ break;
+ }
+ if (!lres) {
+ if (res->ai_next || status < 0)
+ continue;
+ /* Use a different family local address if no choice, this
+ * will cause EAFNOSUPPORT. */
+ lres = arg->local.res->ai;
+ }
+ }
+ status = rsock_socket(res->ai_family,res->ai_socktype,res->ai_protocol);
+ syscall = "socket(2)";
+ fd = status;
+ if (fd < 0) {
+ error = errno;
+ continue;
+ }
+ arg->fd = fd;
+ if (type == INET_SERVER) {
+#if !defined(_WIN32) && !defined(__CYGWIN__)
+ status = 1;
+ setsockopt(fd, SOL_SOCKET, SO_REUSEADDR,
+ (char*)&status, (socklen_t)sizeof(status));
+#endif
+ status = bind(fd, res->ai_addr, res->ai_addrlen);
+ syscall = "bind(2)";
+ }
+ else {
+ if (lres) {
+ status = bind(fd, lres->ai_addr, lres->ai_addrlen);
+ local = status;
+ syscall = "bind(2)";
+ }
+
+ if (status >= 0) {
+ status = rsock_connect(fd, res->ai_addr, res->ai_addrlen,
+ (type == INET_SOCKS));
+ syscall = "connect(2)";
+ }
+ }
+
+ if (status < 0) {
+ error = errno;
+ close(fd);
+ arg->fd = fd = -1;
+ continue;
+ } else
+ break;
+ }
+ if (status < 0) {
+ VALUE host, port;
+
+ if (local < 0) {
+ host = arg->local.host;
+ port = arg->local.serv;
+ } else {
+ host = arg->remote.host;
+ port = arg->remote.serv;
+ }
+
+ rsock_syserr_fail_host_port(error, syscall, host, port);
+ }
+
+ arg->fd = -1;
+
+ if (type == INET_SERVER) {
+ status = listen(fd, SOMAXCONN);
+ if (status < 0) {
+ error = errno;
+ close(fd);
+ rb_syserr_fail(error, "listen(2)");
+ }
+ }
+
+ /* create new instance */
+ return rsock_init_sock(arg->sock, fd);
+}
+
+VALUE
+rsock_init_inetsock(VALUE sock, VALUE remote_host, VALUE remote_serv,
+ VALUE local_host, VALUE local_serv, int type)
+{
+ struct inetsock_arg arg;
+ arg.sock = sock;
+ arg.remote.host = remote_host;
+ arg.remote.serv = remote_serv;
+ arg.remote.res = 0;
+ arg.local.host = local_host;
+ arg.local.serv = local_serv;
+ arg.local.res = 0;
+ arg.type = type;
+ arg.fd = -1;
+ return rb_ensure(init_inetsock_internal, (VALUE)&arg,
+ inetsock_cleanup, (VALUE)&arg);
+}
+
+static ID id_numeric, id_hostname;
+
+int
+rsock_revlookup_flag(VALUE revlookup, int *norevlookup)
+{
+#define return_norevlookup(x) {*norevlookup = (x); return 1;}
+ ID id;
+
+ switch (revlookup) {
+ case Qtrue: return_norevlookup(0);
+ case Qfalse: return_norevlookup(1);
+ case Qnil: break;
+ default:
+ Check_Type(revlookup, T_SYMBOL);
+ id = SYM2ID(revlookup);
+ if (id == id_numeric) return_norevlookup(1);
+ if (id == id_hostname) return_norevlookup(0);
+ rb_raise(rb_eArgError, "invalid reverse_lookup flag: :%s", rb_id2name(id));
+ }
+ return 0;
+#undef return_norevlookup
+}
+
+/*
+ * call-seq:
+ * ipsocket.addr([reverse_lookup]) => [address_family, port, hostname, numeric_address]
+ *
+ * Returns the local address as an array which contains
+ * address_family, port, hostname and numeric_address.
+ *
+ * If +reverse_lookup+ is +true+ or +:hostname+,
+ * hostname is obtained from numeric_address using reverse lookup.
+ * Or if it is +false+, or +:numeric+,
+ * hostname is same as numeric_address.
+ * Or if it is +nil+ or ommitted, obeys to +ipsocket.do_not_reverse_lookup+.
+ * See +Socket.getaddrinfo+ also.
+ *
+ * TCPSocket.open("www.ruby-lang.org", 80) {|sock|
+ * p sock.addr #=> ["AF_INET", 49429, "hal", "192.168.0.128"]
+ * p sock.addr(true) #=> ["AF_INET", 49429, "hal", "192.168.0.128"]
+ * p sock.addr(false) #=> ["AF_INET", 49429, "192.168.0.128", "192.168.0.128"]
+ * p sock.addr(:hostname) #=> ["AF_INET", 49429, "hal", "192.168.0.128"]
+ * p sock.addr(:numeric) #=> ["AF_INET", 49429, "192.168.0.128", "192.168.0.128"]
+ * }
+ *
+ */
+static VALUE
+ip_addr(int argc, VALUE *argv, VALUE sock)
+{
+ rb_io_t *fptr;
+ union_sockaddr addr;
+ socklen_t len = (socklen_t)sizeof addr;
+ int norevlookup;
+
+ GetOpenFile(sock, fptr);
+
+ if (argc < 1 || !rsock_revlookup_flag(argv[0], &norevlookup))
+ norevlookup = fptr->mode & FMODE_NOREVLOOKUP;
+ if (getsockname(fptr->fd, &addr.addr, &len) < 0)
+ rb_sys_fail("getsockname(2)");
+ return rsock_ipaddr(&addr.addr, len, norevlookup);
+}
+
+/*
+ * call-seq:
+ * ipsocket.peeraddr([reverse_lookup]) => [address_family, port, hostname, numeric_address]
+ *
+ * Returns the remote address as an array which contains
+ * address_family, port, hostname and numeric_address.
+ * It is defined for connection oriented socket such as TCPSocket.
+ *
+ * If +reverse_lookup+ is +true+ or +:hostname+,
+ * hostname is obtained from numeric_address using reverse lookup.
+ * Or if it is +false+, or +:numeric+,
+ * hostname is same as numeric_address.
+ * Or if it is +nil+ or ommitted, obeys to +ipsocket.do_not_reverse_lookup+.
+ * See +Socket.getaddrinfo+ also.
+ *
+ * TCPSocket.open("www.ruby-lang.org", 80) {|sock|
+ * p sock.peeraddr #=> ["AF_INET", 80, "carbon.ruby-lang.org", "221.186.184.68"]
+ * p sock.peeraddr(true) #=> ["AF_INET", 80, "carbon.ruby-lang.org", "221.186.184.68"]
+ * p sock.peeraddr(false) #=> ["AF_INET", 80, "221.186.184.68", "221.186.184.68"]
+ * p sock.peeraddr(:hostname) #=> ["AF_INET", 80, "carbon.ruby-lang.org", "221.186.184.68"]
+ * p sock.peeraddr(:numeric) #=> ["AF_INET", 80, "221.186.184.68", "221.186.184.68"]
+ * }
+ *
+ */
+static VALUE
+ip_peeraddr(int argc, VALUE *argv, VALUE sock)
+{
+ rb_io_t *fptr;
+ union_sockaddr addr;
+ socklen_t len = (socklen_t)sizeof addr;
+ int norevlookup;
+
+ GetOpenFile(sock, fptr);
+
+ if (argc < 1 || !rsock_revlookup_flag(argv[0], &norevlookup))
+ norevlookup = fptr->mode & FMODE_NOREVLOOKUP;
+ if (getpeername(fptr->fd, &addr.addr, &len) < 0)
+ rb_sys_fail("getpeername(2)");
+ return rsock_ipaddr(&addr.addr, len, norevlookup);
+}
+
+/*
+ * call-seq:
+ * ipsocket.recvfrom(maxlen) => [mesg, ipaddr]
+ * ipsocket.recvfrom(maxlen, flags) => [mesg, ipaddr]
+ *
+ * Receives a message and return the message as a string and
+ * an address which the message come from.
+ *
+ * _maxlen_ is the maximum number of bytes to receive.
+ *
+ * _flags_ should be a bitwise OR of Socket::MSG_* constants.
+ *
+ * ipaddr is same as IPSocket#{peeraddr,addr}.
+ *
+ * u1 = UDPSocket.new
+ * u1.bind("127.0.0.1", 4913)
+ * u2 = UDPSocket.new
+ * u2.send "uuuu", 0, "127.0.0.1", 4913
+ * p u1.recvfrom(10) #=> ["uuuu", ["AF_INET", 33230, "localhost", "127.0.0.1"]]
+ *
+ */
+static VALUE
+ip_recvfrom(int argc, VALUE *argv, VALUE sock)
+{
+ return rsock_s_recvfrom(sock, argc, argv, RECV_IP);
+}
+
+/*
+ * call-seq:
+ * IPSocket.getaddress(host) => ipaddress
+ *
+ * Lookups the IP address of _host_.
+ *
+ * IPSocket.getaddress("localhost") #=> "127.0.0.1"
+ * IPSocket.getaddress("ip6-localhost") #=> "::1"
+ *
+ */
+static VALUE
+ip_s_getaddress(VALUE obj, VALUE host)
+{
+ union_sockaddr addr;
+ struct rb_addrinfo *res = rsock_addrinfo(host, Qnil, SOCK_STREAM, 0);
+ socklen_t len = res->ai->ai_addrlen;
+
+ /* just take the first one */
+ memcpy(&addr, res->ai->ai_addr, len);
+ rb_freeaddrinfo(res);
+
+ return rsock_make_ipaddr(&addr.addr, len);
+}
+
+void
+rsock_init_ipsocket(void)
+{
+ /*
+ * Document-class: IPSocket < BasicSocket
+ *
+ * IPSocket is the super class of TCPSocket and UDPSocket.
+ */
+ rb_cIPSocket = rb_define_class("IPSocket", rb_cBasicSocket);
+ rb_define_method(rb_cIPSocket, "addr", ip_addr, -1);
+ rb_define_method(rb_cIPSocket, "peeraddr", ip_peeraddr, -1);
+ rb_define_method(rb_cIPSocket, "recvfrom", ip_recvfrom, -1);
+ rb_define_singleton_method(rb_cIPSocket, "getaddress", ip_s_getaddress, 1);
+ rb_undef_method(rb_cIPSocket, "getpeereid");
+
+ id_numeric = rb_intern_const("numeric");
+ id_hostname = rb_intern_const("hostname");
+}
diff --git a/jni/ruby/ext/socket/lib/socket.rb b/jni/ruby/ext/socket/lib/socket.rb
new file mode 100644
index 0000000..2cd7aea
--- /dev/null
+++ b/jni/ruby/ext/socket/lib/socket.rb
@@ -0,0 +1,871 @@
+require 'socket.so'
+
+class Addrinfo
+ # creates an Addrinfo object from the arguments.
+ #
+ # The arguments are interpreted as similar to self.
+ #
+ # Addrinfo.tcp("0.0.0.0", 4649).family_addrinfo("www.ruby-lang.org", 80)
+ # #=> #<Addrinfo: 221.186.184.68:80 TCP (www.ruby-lang.org:80)>
+ #
+ # Addrinfo.unix("/tmp/sock").family_addrinfo("/tmp/sock2")
+ # #=> #<Addrinfo: /tmp/sock2 SOCK_STREAM>
+ #
+ def family_addrinfo(*args)
+ if args.empty?
+ raise ArgumentError, "no address specified"
+ elsif Addrinfo === args.first
+ raise ArgumentError, "too many arguments" if args.length != 1
+ addrinfo = args.first
+ if (self.pfamily != addrinfo.pfamily) ||
+ (self.socktype != addrinfo.socktype)
+ raise ArgumentError, "Addrinfo type mismatch"
+ end
+ addrinfo
+ elsif self.ip?
+ raise ArgumentError, "IP address needs host and port but #{args.length} arguments given" if args.length != 2
+ host, port = args
+ Addrinfo.getaddrinfo(host, port, self.pfamily, self.socktype, self.protocol)[0]
+ elsif self.unix?
+ raise ArgumentError, "UNIX socket needs single path argument but #{args.length} arguments given" if args.length != 1
+ path, = args
+ Addrinfo.unix(path)
+ else
+ raise ArgumentError, "unexpected family"
+ end
+ end
+
+ # creates a new Socket connected to the address of +local_addrinfo+.
+ #
+ # If _local_addrinfo_ is nil, the address of the socket is not bound.
+ #
+ # The _timeout_ specify the seconds for timeout.
+ # Errno::ETIMEDOUT is raised when timeout occur.
+ #
+ # If a block is given the created socket is yielded for each address.
+ #
+ def connect_internal(local_addrinfo, timeout=nil) # :yields: socket
+ sock = Socket.new(self.pfamily, self.socktype, self.protocol)
+ begin
+ sock.ipv6only! if self.ipv6?
+ sock.bind local_addrinfo if local_addrinfo
+ if timeout
+ begin
+ sock.connect_nonblock(self)
+ rescue IO::WaitWritable
+ if !IO.select(nil, [sock], nil, timeout)
+ raise Errno::ETIMEDOUT, 'user specified timeout'
+ end
+ begin
+ sock.connect_nonblock(self) # check connection failure
+ rescue Errno::EISCONN
+ end
+ end
+ else
+ sock.connect(self)
+ end
+ rescue Exception
+ sock.close
+ raise
+ end
+ if block_given?
+ begin
+ yield sock
+ ensure
+ sock.close if !sock.closed?
+ end
+ else
+ sock
+ end
+ end
+ private :connect_internal
+
+ # :call-seq:
+ # addrinfo.connect_from([local_addr_args], [opts]) {|socket| ... }
+ # addrinfo.connect_from([local_addr_args], [opts])
+ #
+ # creates a socket connected to the address of self.
+ #
+ # If one or more arguments given as _local_addr_args_,
+ # it is used as the local address of the socket.
+ # _local_addr_args_ is given for family_addrinfo to obtain actual address.
+ #
+ # If _local_addr_args_ is not given, the local address of the socket is not bound.
+ #
+ # The optional last argument _opts_ is options represented by a hash.
+ # _opts_ may have following options:
+ #
+ # [:timeout] specify the timeout in seconds.
+ #
+ # If a block is given, it is called with the socket and the value of the block is returned.
+ # The socket is returned otherwise.
+ #
+ # Addrinfo.tcp("www.ruby-lang.org", 80).connect_from("0.0.0.0", 4649) {|s|
+ # s.print "GET / HTTP/1.0\r\nHost: www.ruby-lang.org\r\n\r\n"
+ # puts s.read
+ # }
+ #
+ # # Addrinfo object can be taken for the argument.
+ # Addrinfo.tcp("www.ruby-lang.org", 80).connect_from(Addrinfo.tcp("0.0.0.0", 4649)) {|s|
+ # s.print "GET / HTTP/1.0\r\nHost: www.ruby-lang.org\r\n\r\n"
+ # puts s.read
+ # }
+ #
+ def connect_from(*args, &block)
+ opts = Hash === args.last ? args.pop : {}
+ local_addr_args = args
+ connect_internal(family_addrinfo(*local_addr_args), opts[:timeout], &block)
+ end
+
+ # :call-seq:
+ # addrinfo.connect([opts]) {|socket| ... }
+ # addrinfo.connect([opts])
+ #
+ # creates a socket connected to the address of self.
+ #
+ # The optional argument _opts_ is options represented by a hash.
+ # _opts_ may have following options:
+ #
+ # [:timeout] specify the timeout in seconds.
+ #
+ # If a block is given, it is called with the socket and the value of the block is returned.
+ # The socket is returned otherwise.
+ #
+ # Addrinfo.tcp("www.ruby-lang.org", 80).connect {|s|
+ # s.print "GET / HTTP/1.0\r\nHost: www.ruby-lang.org\r\n\r\n"
+ # puts s.read
+ # }
+ #
+ def connect(opts={}, &block)
+ connect_internal(nil, opts[:timeout], &block)
+ end
+
+ # :call-seq:
+ # addrinfo.connect_to([remote_addr_args], [opts]) {|socket| ... }
+ # addrinfo.connect_to([remote_addr_args], [opts])
+ #
+ # creates a socket connected to _remote_addr_args_ and bound to self.
+ #
+ # The optional last argument _opts_ is options represented by a hash.
+ # _opts_ may have following options:
+ #
+ # [:timeout] specify the timeout in seconds.
+ #
+ # If a block is given, it is called with the socket and the value of the block is returned.
+ # The socket is returned otherwise.
+ #
+ # Addrinfo.tcp("0.0.0.0", 4649).connect_to("www.ruby-lang.org", 80) {|s|
+ # s.print "GET / HTTP/1.0\r\nHost: www.ruby-lang.org\r\n\r\n"
+ # puts s.read
+ # }
+ #
+ def connect_to(*args, &block)
+ opts = Hash === args.last ? args.pop : {}
+ remote_addr_args = args
+ remote_addrinfo = family_addrinfo(*remote_addr_args)
+ remote_addrinfo.send(:connect_internal, self, opts[:timeout], &block)
+ end
+
+ # creates a socket bound to self.
+ #
+ # If a block is given, it is called with the socket and the value of the block is returned.
+ # The socket is returned otherwise.
+ #
+ # Addrinfo.udp("0.0.0.0", 9981).bind {|s|
+ # s.local_address.connect {|s| s.send "hello", 0 }
+ # p s.recv(10) #=> "hello"
+ # }
+ #
+ def bind
+ sock = Socket.new(self.pfamily, self.socktype, self.protocol)
+ begin
+ sock.ipv6only! if self.ipv6?
+ sock.setsockopt(:SOCKET, :REUSEADDR, 1)
+ sock.bind(self)
+ rescue Exception
+ sock.close
+ raise
+ end
+ if block_given?
+ begin
+ yield sock
+ ensure
+ sock.close if !sock.closed?
+ end
+ else
+ sock
+ end
+ end
+
+ # creates a listening socket bound to self.
+ def listen(backlog=Socket::SOMAXCONN)
+ sock = Socket.new(self.pfamily, self.socktype, self.protocol)
+ begin
+ sock.ipv6only! if self.ipv6?
+ sock.setsockopt(:SOCKET, :REUSEADDR, 1)
+ sock.bind(self)
+ sock.listen(backlog)
+ rescue Exception
+ sock.close
+ raise
+ end
+ if block_given?
+ begin
+ yield sock
+ ensure
+ sock.close if !sock.closed?
+ end
+ else
+ sock
+ end
+ end
+
+ # iterates over the list of Addrinfo objects obtained by Addrinfo.getaddrinfo.
+ #
+ # Addrinfo.foreach(nil, 80) {|x| p x }
+ # #=> #<Addrinfo: 127.0.0.1:80 TCP (:80)>
+ # # #<Addrinfo: 127.0.0.1:80 UDP (:80)>
+ # # #<Addrinfo: [::1]:80 TCP (:80)>
+ # # #<Addrinfo: [::1]:80 UDP (:80)>
+ #
+ def self.foreach(nodename, service, family=nil, socktype=nil, protocol=nil, flags=nil, &block)
+ Addrinfo.getaddrinfo(nodename, service, family, socktype, protocol, flags).each(&block)
+ end
+end
+
+class BasicSocket < IO
+ # Returns an address of the socket suitable for connect in the local machine.
+ #
+ # This method returns _self_.local_address, except following condition.
+ #
+ # - IPv4 unspecified address (0.0.0.0) is replaced by IPv4 loopback address (127.0.0.1).
+ # - IPv6 unspecified address (::) is replaced by IPv6 loopback address (::1).
+ #
+ # If the local address is not suitable for connect, SocketError is raised.
+ # IPv4 and IPv6 address which port is 0 is not suitable for connect.
+ # Unix domain socket which has no path is not suitable for connect.
+ #
+ # Addrinfo.tcp("0.0.0.0", 0).listen {|serv|
+ # p serv.connect_address #=> #<Addrinfo: 127.0.0.1:53660 TCP>
+ # serv.connect_address.connect {|c|
+ # s, _ = serv.accept
+ # p [c, s] #=> [#<Socket:fd 4>, #<Socket:fd 6>]
+ # }
+ # }
+ #
+ def connect_address
+ addr = local_address
+ afamily = addr.afamily
+ if afamily == Socket::AF_INET
+ raise SocketError, "unbound IPv4 socket" if addr.ip_port == 0
+ if addr.ip_address == "0.0.0.0"
+ addr = Addrinfo.new(["AF_INET", addr.ip_port, nil, "127.0.0.1"], addr.pfamily, addr.socktype, addr.protocol)
+ end
+ elsif defined?(Socket::AF_INET6) && afamily == Socket::AF_INET6
+ raise SocketError, "unbound IPv6 socket" if addr.ip_port == 0
+ if addr.ip_address == "::"
+ addr = Addrinfo.new(["AF_INET6", addr.ip_port, nil, "::1"], addr.pfamily, addr.socktype, addr.protocol)
+ elsif addr.ip_address == "0.0.0.0" # MacOS X 10.4 returns "a.b.c.d" for IPv4-mapped IPv6 address.
+ addr = Addrinfo.new(["AF_INET6", addr.ip_port, nil, "::1"], addr.pfamily, addr.socktype, addr.protocol)
+ elsif addr.ip_address == "::ffff:0.0.0.0" # MacOS X 10.6 returns "::ffff:a.b.c.d" for IPv4-mapped IPv6 address.
+ addr = Addrinfo.new(["AF_INET6", addr.ip_port, nil, "::1"], addr.pfamily, addr.socktype, addr.protocol)
+ end
+ elsif defined?(Socket::AF_UNIX) && afamily == Socket::AF_UNIX
+ raise SocketError, "unbound Unix socket" if addr.unix_path == ""
+ end
+ addr
+ end
+end
+
+class Socket < BasicSocket
+ # enable the socket option IPV6_V6ONLY if IPV6_V6ONLY is available.
+ def ipv6only!
+ if defined? Socket::IPV6_V6ONLY
+ self.setsockopt(:IPV6, :V6ONLY, 1)
+ end
+ end
+
+ # :call-seq:
+ # Socket.tcp(host, port, local_host=nil, local_port=nil, [opts]) {|socket| ... }
+ # Socket.tcp(host, port, local_host=nil, local_port=nil, [opts])
+ #
+ # creates a new socket object connected to host:port using TCP/IP.
+ #
+ # If local_host:local_port is given,
+ # the socket is bound to it.
+ #
+ # The optional last argument _opts_ is options represented by a hash.
+ # _opts_ may have following options:
+ #
+ # [:connect_timeout] specify the timeout in seconds.
+ #
+ # If a block is given, the block is called with the socket.
+ # The value of the block is returned.
+ # The socket is closed when this method returns.
+ #
+ # If no block is given, the socket is returned.
+ #
+ # Socket.tcp("www.ruby-lang.org", 80) {|sock|
+ # sock.print "GET / HTTP/1.0\r\nHost: www.ruby-lang.org\r\n\r\n"
+ # sock.close_write
+ # puts sock.read
+ # }
+ #
+ def self.tcp(host, port, *rest) # :yield: socket
+ opts = Hash === rest.last ? rest.pop : {}
+ raise ArgumentError, "wrong number of arguments (#{rest.length} for 2)" if 2 < rest.length
+ local_host, local_port = rest
+ last_error = nil
+ ret = nil
+
+ connect_timeout = opts[:connect_timeout]
+
+ local_addr_list = nil
+ if local_host != nil || local_port != nil
+ local_addr_list = Addrinfo.getaddrinfo(local_host, local_port, nil, :STREAM, nil)
+ end
+
+ Addrinfo.foreach(host, port, nil, :STREAM) {|ai|
+ if local_addr_list
+ local_addr = local_addr_list.find {|local_ai| local_ai.afamily == ai.afamily }
+ next if !local_addr
+ else
+ local_addr = nil
+ end
+ begin
+ sock = local_addr ?
+ ai.connect_from(local_addr, :timeout => connect_timeout) :
+ ai.connect(:timeout => connect_timeout)
+ rescue SystemCallError
+ last_error = $!
+ next
+ end
+ ret = sock
+ break
+ }
+ if !ret
+ if last_error
+ raise last_error
+ else
+ raise SocketError, "no appropriate local address"
+ end
+ end
+ if block_given?
+ begin
+ yield ret
+ ensure
+ ret.close if !ret.closed?
+ end
+ else
+ ret
+ end
+ end
+
+ # :stopdoc:
+ def self.ip_sockets_port0(ai_list, reuseaddr)
+ sockets = []
+ begin
+ sockets.clear
+ port = nil
+ ai_list.each {|ai|
+ begin
+ s = Socket.new(ai.pfamily, ai.socktype, ai.protocol)
+ rescue SystemCallError
+ next
+ end
+ sockets << s
+ s.ipv6only! if ai.ipv6?
+ if reuseaddr
+ s.setsockopt(:SOCKET, :REUSEADDR, 1)
+ end
+ if !port
+ s.bind(ai)
+ port = s.local_address.ip_port
+ else
+ s.bind(ai.family_addrinfo(ai.ip_address, port))
+ end
+ }
+ rescue Errno::EADDRINUSE
+ sockets.each {|s| s.close }
+ retry
+ rescue Exception
+ sockets.each {|s| s.close }
+ raise
+ end
+ sockets
+ end
+ class << self
+ private :ip_sockets_port0
+ end
+
+ def self.tcp_server_sockets_port0(host)
+ ai_list = Addrinfo.getaddrinfo(host, 0, nil, :STREAM, nil, Socket::AI_PASSIVE)
+ sockets = ip_sockets_port0(ai_list, true)
+ begin
+ sockets.each {|s|
+ s.listen(Socket::SOMAXCONN)
+ }
+ rescue Exception
+ sockets.each {|s| s.close }
+ raise
+ end
+ sockets
+ end
+ class << self
+ private :tcp_server_sockets_port0
+ end
+ # :startdoc:
+
+ # creates TCP/IP server sockets for _host_ and _port_.
+ # _host_ is optional.
+ #
+ # If no block given,
+ # it returns an array of listening sockets.
+ #
+ # If a block is given, the block is called with the sockets.
+ # The value of the block is returned.
+ # The socket is closed when this method returns.
+ #
+ # If _port_ is 0, actual port number is chosen dynamically.
+ # However all sockets in the result has same port number.
+ #
+ # # tcp_server_sockets returns two sockets.
+ # sockets = Socket.tcp_server_sockets(1296)
+ # p sockets #=> [#<Socket:fd 3>, #<Socket:fd 4>]
+ #
+ # # The sockets contains IPv6 and IPv4 sockets.
+ # sockets.each {|s| p s.local_address }
+ # #=> #<Addrinfo: [::]:1296 TCP>
+ # # #<Addrinfo: 0.0.0.0:1296 TCP>
+ #
+ # # IPv6 and IPv4 socket has same port number, 53114, even if it is chosen dynamically.
+ # sockets = Socket.tcp_server_sockets(0)
+ # sockets.each {|s| p s.local_address }
+ # #=> #<Addrinfo: [::]:53114 TCP>
+ # # #<Addrinfo: 0.0.0.0:53114 TCP>
+ #
+ # # The block is called with the sockets.
+ # Socket.tcp_server_sockets(0) {|sockets|
+ # p sockets #=> [#<Socket:fd 3>, #<Socket:fd 4>]
+ # }
+ #
+ def self.tcp_server_sockets(host=nil, port)
+ if port == 0
+ sockets = tcp_server_sockets_port0(host)
+ else
+ last_error = nil
+ sockets = []
+ begin
+ Addrinfo.foreach(host, port, nil, :STREAM, nil, Socket::AI_PASSIVE) {|ai|
+ begin
+ s = ai.listen
+ rescue SystemCallError
+ last_error = $!
+ next
+ end
+ sockets << s
+ }
+ if sockets.empty?
+ raise last_error
+ end
+ rescue Exception
+ sockets.each {|s| s.close }
+ raise
+ end
+ end
+ if block_given?
+ begin
+ yield sockets
+ ensure
+ sockets.each {|s| s.close if !s.closed? }
+ end
+ else
+ sockets
+ end
+ end
+
+ # yield socket and client address for each a connection accepted via given sockets.
+ #
+ # The arguments are a list of sockets.
+ # The individual argument should be a socket or an array of sockets.
+ #
+ # This method yields the block sequentially.
+ # It means that the next connection is not accepted until the block returns.
+ # So concurrent mechanism, thread for example, should be used to service multiple clients at a time.
+ #
+ def self.accept_loop(*sockets) # :yield: socket, client_addrinfo
+ sockets.flatten!(1)
+ if sockets.empty?
+ raise ArgumentError, "no sockets"
+ end
+ loop {
+ readable, _, _ = IO.select(sockets)
+ readable.each {|r|
+ begin
+ sock, addr = r.accept_nonblock
+ rescue IO::WaitReadable
+ next
+ end
+ yield sock, addr
+ }
+ }
+ end
+
+ # creates a TCP/IP server on _port_ and calls the block for each connection accepted.
+ # The block is called with a socket and a client_address as an Addrinfo object.
+ #
+ # If _host_ is specified, it is used with _port_ to determine the server addresses.
+ #
+ # The socket is *not* closed when the block returns.
+ # So application should close it explicitly.
+ #
+ # This method calls the block sequentially.
+ # It means that the next connection is not accepted until the block returns.
+ # So concurrent mechanism, thread for example, should be used to service multiple clients at a time.
+ #
+ # Note that Addrinfo.getaddrinfo is used to determine the server socket addresses.
+ # When Addrinfo.getaddrinfo returns two or more addresses,
+ # IPv4 and IPv6 address for example,
+ # all of them are used.
+ # Socket.tcp_server_loop succeeds if one socket can be used at least.
+ #
+ # # Sequential echo server.
+ # # It services only one client at a time.
+ # Socket.tcp_server_loop(16807) {|sock, client_addrinfo|
+ # begin
+ # IO.copy_stream(sock, sock)
+ # ensure
+ # sock.close
+ # end
+ # }
+ #
+ # # Threaded echo server
+ # # It services multiple clients at a time.
+ # # Note that it may accept connections too much.
+ # Socket.tcp_server_loop(16807) {|sock, client_addrinfo|
+ # Thread.new {
+ # begin
+ # IO.copy_stream(sock, sock)
+ # ensure
+ # sock.close
+ # end
+ # }
+ # }
+ #
+ def self.tcp_server_loop(host=nil, port, &b) # :yield: socket, client_addrinfo
+ tcp_server_sockets(host, port) {|sockets|
+ accept_loop(sockets, &b)
+ }
+ end
+
+ # :call-seq:
+ # Socket.udp_server_sockets([host, ] port)
+ #
+ # Creates UDP/IP sockets for a UDP server.
+ #
+ # If no block given, it returns an array of sockets.
+ #
+ # If a block is given, the block is called with the sockets.
+ # The value of the block is returned.
+ # The sockets are closed when this method returns.
+ #
+ # If _port_ is zero, some port is chosen.
+ # But the chosen port is used for the all sockets.
+ #
+ # # UDP/IP echo server
+ # Socket.udp_server_sockets(0) {|sockets|
+ # p sockets.first.local_address.ip_port #=> 32963
+ # Socket.udp_server_loop_on(sockets) {|msg, msg_src|
+ # msg_src.reply msg
+ # }
+ # }
+ #
+ def self.udp_server_sockets(host=nil, port)
+ last_error = nil
+ sockets = []
+
+ ipv6_recvpktinfo = nil
+ if defined? Socket::AncillaryData
+ if defined? Socket::IPV6_RECVPKTINFO # RFC 3542
+ ipv6_recvpktinfo = Socket::IPV6_RECVPKTINFO
+ elsif defined? Socket::IPV6_PKTINFO # RFC 2292
+ ipv6_recvpktinfo = Socket::IPV6_PKTINFO
+ end
+ end
+
+ local_addrs = Socket.ip_address_list
+
+ ip_list = []
+ Addrinfo.foreach(host, port, nil, :DGRAM, nil, Socket::AI_PASSIVE) {|ai|
+ if ai.ipv4? && ai.ip_address == "0.0.0.0"
+ local_addrs.each {|a|
+ next if !a.ipv4?
+ ip_list << Addrinfo.new(a.to_sockaddr, :INET, :DGRAM, 0);
+ }
+ elsif ai.ipv6? && ai.ip_address == "::" && !ipv6_recvpktinfo
+ local_addrs.each {|a|
+ next if !a.ipv6?
+ ip_list << Addrinfo.new(a.to_sockaddr, :INET6, :DGRAM, 0);
+ }
+ else
+ ip_list << ai
+ end
+ }
+
+ if port == 0
+ sockets = ip_sockets_port0(ip_list, false)
+ else
+ ip_list.each {|ip|
+ ai = Addrinfo.udp(ip.ip_address, port)
+ begin
+ s = ai.bind
+ rescue SystemCallError
+ last_error = $!
+ next
+ end
+ sockets << s
+ }
+ if sockets.empty?
+ raise last_error
+ end
+ end
+
+ sockets.each {|s|
+ ai = s.local_address
+ if ipv6_recvpktinfo && ai.ipv6? && ai.ip_address == "::"
+ s.setsockopt(:IPV6, ipv6_recvpktinfo, 1)
+ end
+ }
+
+ if block_given?
+ begin
+ yield sockets
+ ensure
+ sockets.each {|s| s.close if !s.closed? } if sockets
+ end
+ else
+ sockets
+ end
+ end
+
+ # :call-seq:
+ # Socket.udp_server_recv(sockets) {|msg, msg_src| ... }
+ #
+ # Receive UDP/IP packets from the given _sockets_.
+ # For each packet received, the block is called.
+ #
+ # The block receives _msg_ and _msg_src_.
+ # _msg_ is a string which is the payload of the received packet.
+ # _msg_src_ is a Socket::UDPSource object which is used for reply.
+ #
+ # Socket.udp_server_loop can be implemented using this method as follows.
+ #
+ # udp_server_sockets(host, port) {|sockets|
+ # loop {
+ # readable, _, _ = IO.select(sockets)
+ # udp_server_recv(readable) {|msg, msg_src| ... }
+ # }
+ # }
+ #
+ def self.udp_server_recv(sockets)
+ sockets.each {|r|
+ begin
+ msg, sender_addrinfo, _, *controls = r.recvmsg_nonblock
+ rescue IO::WaitReadable
+ next
+ end
+ ai = r.local_address
+ if ai.ipv6? and pktinfo = controls.find {|c| c.cmsg_is?(:IPV6, :PKTINFO) }
+ ai = Addrinfo.udp(pktinfo.ipv6_pktinfo_addr.ip_address, ai.ip_port)
+ yield msg, UDPSource.new(sender_addrinfo, ai) {|reply_msg|
+ r.sendmsg reply_msg, 0, sender_addrinfo, pktinfo
+ }
+ else
+ yield msg, UDPSource.new(sender_addrinfo, ai) {|reply_msg|
+ r.send reply_msg, 0, sender_addrinfo
+ }
+ end
+ }
+ end
+
+ # :call-seq:
+ # Socket.udp_server_loop_on(sockets) {|msg, msg_src| ... }
+ #
+ # Run UDP/IP server loop on the given sockets.
+ #
+ # The return value of Socket.udp_server_sockets is appropriate for the argument.
+ #
+ # It calls the block for each message received.
+ #
+ def self.udp_server_loop_on(sockets, &b) # :yield: msg, msg_src
+ loop {
+ readable, _, _ = IO.select(sockets)
+ udp_server_recv(readable, &b)
+ }
+ end
+
+ # :call-seq:
+ # Socket.udp_server_loop(port) {|msg, msg_src| ... }
+ # Socket.udp_server_loop(host, port) {|msg, msg_src| ... }
+ #
+ # creates a UDP/IP server on _port_ and calls the block for each message arrived.
+ # The block is called with the message and its source information.
+ #
+ # This method allocates sockets internally using _port_.
+ # If _host_ is specified, it is used conjunction with _port_ to determine the server addresses.
+ #
+ # The _msg_ is a string.
+ #
+ # The _msg_src_ is a Socket::UDPSource object.
+ # It is used for reply.
+ #
+ # # UDP/IP echo server.
+ # Socket.udp_server_loop(9261) {|msg, msg_src|
+ # msg_src.reply msg
+ # }
+ #
+ def self.udp_server_loop(host=nil, port, &b) # :yield: message, message_source
+ udp_server_sockets(host, port) {|sockets|
+ udp_server_loop_on(sockets, &b)
+ }
+ end
+
+ # UDP/IP address information used by Socket.udp_server_loop.
+ class UDPSource
+ # +remote_address+ is an Addrinfo object.
+ #
+ # +local_address+ is an Addrinfo object.
+ #
+ # +reply_proc+ is a Proc used to send reply back to the source.
+ def initialize(remote_address, local_address, &reply_proc)
+ @remote_address = remote_address
+ @local_address = local_address
+ @reply_proc = reply_proc
+ end
+
+ # Address of the source
+ attr_reader :remote_address
+
+ # Local address
+ attr_reader :local_address
+
+ def inspect # :nodoc:
+ "\#<#{self.class}: #{@remote_address.inspect_sockaddr} to #{@local_address.inspect_sockaddr}>"
+ end
+
+ # Sends the String +msg+ to the source
+ def reply(msg)
+ @reply_proc.call msg
+ end
+ end
+
+ # creates a new socket connected to path using UNIX socket socket.
+ #
+ # If a block is given, the block is called with the socket.
+ # The value of the block is returned.
+ # The socket is closed when this method returns.
+ #
+ # If no block is given, the socket is returned.
+ #
+ # # talk to /tmp/sock socket.
+ # Socket.unix("/tmp/sock") {|sock|
+ # t = Thread.new { IO.copy_stream(sock, STDOUT) }
+ # IO.copy_stream(STDIN, sock)
+ # t.join
+ # }
+ #
+ def self.unix(path) # :yield: socket
+ addr = Addrinfo.unix(path)
+ sock = addr.connect
+ if block_given?
+ begin
+ yield sock
+ ensure
+ sock.close if !sock.closed?
+ end
+ else
+ sock
+ end
+ end
+
+ # creates a UNIX server socket on _path_
+ #
+ # If no block given, it returns a listening socket.
+ #
+ # If a block is given, it is called with the socket and the block value is returned.
+ # When the block exits, the socket is closed and the socket file is removed.
+ #
+ # socket = Socket.unix_server_socket("/tmp/s")
+ # p socket #=> #<Socket:fd 3>
+ # p socket.local_address #=> #<Addrinfo: /tmp/s SOCK_STREAM>
+ #
+ # Socket.unix_server_socket("/tmp/sock") {|s|
+ # p s #=> #<Socket:fd 3>
+ # p s.local_address #=> # #<Addrinfo: /tmp/sock SOCK_STREAM>
+ # }
+ #
+ def self.unix_server_socket(path)
+ if !unix_socket_abstract_name?(path)
+ begin
+ st = File.lstat(path)
+ rescue Errno::ENOENT
+ end
+ if st && st.socket? && st.owned?
+ File.unlink path
+ end
+ end
+ s = Addrinfo.unix(path).listen
+ if block_given?
+ begin
+ yield s
+ ensure
+ s.close if !s.closed?
+ if !unix_socket_abstract_name?(path)
+ File.unlink path
+ end
+ end
+ else
+ s
+ end
+ end
+
+ class << self
+ private
+
+ def unix_socket_abstract_name?(path)
+ /linux/ =~ RUBY_PLATFORM && /\A(\0|\z)/ =~ path
+ end
+ end
+
+ # creates a UNIX socket server on _path_.
+ # It calls the block for each socket accepted.
+ #
+ # If _host_ is specified, it is used with _port_ to determine the server ports.
+ #
+ # The socket is *not* closed when the block returns.
+ # So application should close it.
+ #
+ # This method deletes the socket file pointed by _path_ at first if
+ # the file is a socket file and it is owned by the user of the application.
+ # This is safe only if the directory of _path_ is not changed by a malicious user.
+ # So don't use /tmp/malicious-users-directory/socket.
+ # Note that /tmp/socket and /tmp/your-private-directory/socket is safe assuming that /tmp has sticky bit.
+ #
+ # # Sequential echo server.
+ # # It services only one client at a time.
+ # Socket.unix_server_loop("/tmp/sock") {|sock, client_addrinfo|
+ # begin
+ # IO.copy_stream(sock, sock)
+ # ensure
+ # sock.close
+ # end
+ # }
+ #
+ def self.unix_server_loop(path, &b) # :yield: socket, client_addrinfo
+ unix_server_socket(path) {|serv|
+ accept_loop(serv, &b)
+ }
+ end
+
+end
+
diff --git a/jni/ruby/ext/socket/mkconstants.rb b/jni/ruby/ext/socket/mkconstants.rb
new file mode 100644
index 0000000..59fcb17
--- /dev/null
+++ b/jni/ruby/ext/socket/mkconstants.rb
@@ -0,0 +1,804 @@
+require 'optparse'
+require 'erb'
+
+opt = OptionParser.new
+
+opt.def_option('-h', 'help') {
+ puts opt
+ exit 0
+}
+
+opt_o = nil
+opt.def_option('-o FILE', 'specify output file') {|filename|
+ opt_o = filename
+}
+
+opt_H = nil
+opt.def_option('-H FILE', 'specify output header file') {|filename|
+ opt_H = filename
+}
+
+C_ESC = {
+ "\\" => "\\\\",
+ '"' => '\"',
+ "\n" => '\n',
+}
+
+0x00.upto(0x1f) {|ch| C_ESC[[ch].pack("C")] ||= "\\%03o" % ch }
+0x7f.upto(0xff) {|ch| C_ESC[[ch].pack("C")] = "\\%03o" % ch }
+C_ESC_PAT = Regexp.union(*C_ESC.keys)
+
+def c_str(str)
+ '"' + str.gsub(C_ESC_PAT) {|s| C_ESC[s]} + '"'
+end
+
+opt.parse!
+
+
+
+h = {}
+COMMENTS = Hash.new { |h, name| h[name] = name }
+
+DATA.each_line {|s|
+ name, default_value, comment = s.chomp.split(/\s+/, 3)
+ next unless name && name[0] != ?#
+
+ default_value = nil if default_value == 'nil'
+
+ if h.has_key? name
+ warn "#{$.}: warning: duplicate name: #{name}"
+ next
+ end
+ h[name] = default_value
+ COMMENTS[name] = comment
+}
+DEFS = h.to_a
+
+def each_const
+ DEFS.each {|name, default_value|
+ guard = nil
+ if /\A(AF_INET6|PF_INET6|IPV6_.*)\z/ =~ name
+ # IPv6 is not supported although AF_INET6 is defined on mingw
+ guard = "defined(INET6)"
+ end
+ yield guard, name, default_value
+ }
+end
+
+def each_name(pat)
+ DEFS.each {|name, default_value|
+ next if pat !~ name
+ yield name
+ }
+end
+
+ERB.new(<<'EOS', nil, '%').def_method(Object, "gen_const_decls")
+% each_const {|guard, name, default_value|
+#if !defined(<%=name%>)
+# if defined(HAVE_CONST_<%=name.upcase%>)
+# define <%=name%> <%=name%>
+%if default_value
+# else
+# define <%=name%> <%=default_value%>
+%end
+# endif
+#endif
+% }
+EOS
+
+ERB.new(<<'EOS', nil, '%').def_method(Object, "gen_const_defs_in_guard(name, default_value)")
+#if defined(<%=name%>)
+ /* <%= COMMENTS[name] %> */
+ rb_define_const(rb_cSocket, <%=c_str name%>, INTEGER2NUM(<%=name%>));
+ /* <%= COMMENTS[name] %> */
+ rb_define_const(rb_mSockConst, <%=c_str name%>, INTEGER2NUM(<%=name%>));
+#endif
+EOS
+
+ERB.new(<<'EOS', nil, '%').def_method(Object, "gen_const_defs")
+% each_const {|guard, name, default_value|
+% if guard
+#if <%=guard%>
+<%= gen_const_defs_in_guard(name, default_value).chomp %>
+#endif
+% else
+<%= gen_const_defs_in_guard(name, default_value).chomp %>
+% end
+% }
+EOS
+
+def reverse_each_name(pat)
+ DEFS.reverse_each {|name, default_value|
+ next if pat !~ name
+ yield name
+ }
+end
+
+def each_names_with_len(pat, prefix_optional=nil)
+ h = {}
+ DEFS.each {|name, default_value|
+ next if pat !~ name
+ (h[name.length] ||= []) << [name, name]
+ }
+ if prefix_optional
+ if Regexp === prefix_optional
+ prefix_pat = prefix_optional
+ else
+ prefix_pat = /\A#{Regexp.escape prefix_optional}/
+ end
+ DEFS.each {|const, default_value|
+ next if pat !~ const
+ next if prefix_pat !~ const
+ name = $'
+ (h[name.length] ||= []) << [name, const]
+ }
+ end
+ hh = {}
+ h.each {|len, pairs|
+ pairs.each {|name, const|
+ raise "name crash: #{name}" if hh[name]
+ hh[name] = true
+ }
+ }
+ h.keys.sort.each {|len|
+ yield h[len], len
+ }
+end
+
+ERB.new(<<'EOS', nil, '%').def_method(Object, "gen_name_to_int_decl(funcname, pat, prefix_optional, guard=nil)")
+%if guard
+#ifdef <%=guard%>
+int <%=funcname%>(const char *str, long len, int *valp);
+#endif
+%else
+int <%=funcname%>(const char *str, long len, int *valp);
+%end
+EOS
+
+ERB.new(<<'EOS', nil, '%').def_method(Object, "gen_name_to_int_func_in_guard(funcname, pat, prefix_optional, guard=nil)")
+int
+<%=funcname%>(const char *str, long len, int *valp)
+{
+ switch (len) {
+% each_names_with_len(pat, prefix_optional) {|pairs, len|
+ case <%=len%>:
+% pairs.each {|name, const|
+#ifdef <%=const%>
+ if (memcmp(str, <%=c_str name%>, <%=len%>) == 0) { *valp = <%=const%>; return 0; }
+#endif
+% }
+ return -1;
+
+% }
+ default:
+ return -1;
+ }
+}
+EOS
+
+ERB.new(<<'EOS', nil, '%').def_method(Object, "gen_name_to_int_func(funcname, pat, prefix_optional, guard=nil)")
+%if guard
+#ifdef <%=guard%>
+<%=gen_name_to_int_func_in_guard(funcname, pat, prefix_optional, guard)%>
+#endif
+%else
+<%=gen_name_to_int_func_in_guard(funcname, pat, prefix_optional, guard)%>
+%end
+EOS
+
+NAME_TO_INT_DEFS = []
+def def_name_to_int(funcname, pat, prefix_optional, guard=nil)
+ decl = gen_name_to_int_decl(funcname, pat, prefix_optional, guard)
+ func = gen_name_to_int_func(funcname, pat, prefix_optional, guard)
+ NAME_TO_INT_DEFS << [decl, func]
+end
+
+def reverse_each_name_with_prefix_optional(pat, prefix_pat)
+ reverse_each_name(pat) {|n|
+ yield n, n
+ }
+ if prefix_pat
+ reverse_each_name(pat) {|n|
+ next if prefix_pat !~ n
+ yield n, $'
+ }
+ end
+end
+
+ERB.new(<<'EOS', nil, '%').def_method(Object, "gen_int_to_name_hash(hash_var, pat, prefix_pat)")
+ <%=hash_var%> = st_init_numtable();
+% reverse_each_name_with_prefix_optional(pat, prefix_pat) {|n,s|
+#ifdef <%=n%>
+ st_insert(<%=hash_var%>, (st_data_t)<%=n%>, (st_data_t)rb_intern2(<%=c_str s%>, <%=s.length%>));
+#endif
+% }
+EOS
+
+ERB.new(<<'EOS', nil, '%').def_method(Object, "gen_int_to_name_func(func_name, hash_var)")
+ID
+<%=func_name%>(int val)
+{
+ st_data_t name;
+ if (st_lookup(<%=hash_var%>, (st_data_t)val, &name))
+ return (ID)name;
+ return 0;
+}
+EOS
+
+ERB.new(<<'EOS', nil, '%').def_method(Object, "gen_int_to_name_decl(func_name, hash_var)")
+ID <%=func_name%>(int val);
+EOS
+
+INTERN_DEFS = []
+def def_intern(func_name, pat, prefix_optional=nil)
+ prefix_pat = nil
+ if prefix_optional
+ if Regexp === prefix_optional
+ prefix_pat = prefix_optional
+ else
+ prefix_pat = /\A#{Regexp.escape prefix_optional}/
+ end
+ end
+ hash_var = "#{func_name}_hash"
+ vardef = "static st_table *#{hash_var};"
+ gen_hash = gen_int_to_name_hash(hash_var, pat, prefix_pat)
+ decl = gen_int_to_name_decl(func_name, hash_var)
+ func = gen_int_to_name_func(func_name, hash_var)
+ INTERN_DEFS << [vardef, gen_hash, decl, func]
+end
+
+def_name_to_int("rsock_family_to_int", /\A(AF_|PF_)/, "AF_")
+def_name_to_int("rsock_socktype_to_int", /\ASOCK_/, "SOCK_")
+def_name_to_int("rsock_ipproto_to_int", /\AIPPROTO_/, "IPPROTO_")
+def_name_to_int("rsock_unknown_level_to_int", /\ASOL_SOCKET\z/, "SOL_")
+def_name_to_int("rsock_ip_level_to_int", /\A(SOL_SOCKET\z|IPPROTO_)/, /\A(SOL_|IPPROTO_)/)
+def_name_to_int("rsock_so_optname_to_int", /\ASO_/, "SO_")
+def_name_to_int("rsock_ip_optname_to_int", /\AIP_/, "IP_")
+def_name_to_int("rsock_ipv6_optname_to_int", /\AIPV6_/, "IPV6_", "IPPROTO_IPV6")
+def_name_to_int("rsock_tcp_optname_to_int", /\ATCP_/, "TCP_")
+def_name_to_int("rsock_udp_optname_to_int", /\AUDP_/, "UDP_")
+def_name_to_int("rsock_shutdown_how_to_int", /\ASHUT_/, "SHUT_")
+def_name_to_int("rsock_scm_optname_to_int", /\ASCM_/, "SCM_")
+
+def_intern('rsock_intern_family', /\AAF_/)
+def_intern('rsock_intern_family_noprefix', /\AAF_/, "AF_")
+def_intern('rsock_intern_protocol_family', /\APF_/)
+def_intern('rsock_intern_socktype', /\ASOCK_/)
+def_intern('rsock_intern_ipproto', /\AIPPROTO_/)
+def_intern('rsock_intern_iplevel', /\A(SOL_SOCKET\z|IPPROTO_)/, /\A(SOL_|IPPROTO_)/)
+def_intern('rsock_intern_so_optname', /\ASO_/, "SO_")
+def_intern('rsock_intern_ip_optname', /\AIP_/, "IP_")
+def_intern('rsock_intern_ipv6_optname', /\AIPV6_/, "IPV6_")
+def_intern('rsock_intern_tcp_optname', /\ATCP_/, "TCP_")
+def_intern('rsock_intern_udp_optname', /\AUDP_/, "UDP_")
+def_intern('rsock_intern_scm_optname', /\ASCM_/, "SCM_")
+def_intern('rsock_intern_local_optname', /\ALOCAL_/, "LOCAL_")
+
+result = ERB.new(<<'EOS', nil, '%').result(binding)
+/* autogenerated file */
+
+<%= INTERN_DEFS.map {|vardef, gen_hash, decl, func| vardef }.join("\n") %>
+
+#ifdef HAVE_LONG_LONG
+#define INTEGER2NUM(n) \
+ (FIXNUM_MAX < (n) ? ULL2NUM(n) : \
+ FIXNUM_MIN > (LONG_LONG)(n) ? LL2NUM(n) : \
+ LONG2FIX(n))
+#else
+#define INTEGER2NUM(n) \
+ (FIXNUM_MAX < (n) ? ULONG2NUM(n) : \
+ FIXNUM_MIN > (long)(n) ? LONG2NUM(n) : \
+ LONG2FIX(n))
+#endif
+
+static void
+init_constants(void)
+{
+ /*
+ * Document-module: Socket::Constants
+ *
+ * Socket::Constants provides socket-related constants. All possible
+ * socket constants are listed in the documentation but they may not all
+ * be present on your platform.
+ *
+ * If the underlying platform doesn't define a constant the corresponding
+ * Ruby constant is not defined.
+ *
+ */
+ rb_mSockConst = rb_define_module_under(rb_cSocket, "Constants");
+
+<%= gen_const_defs %>
+<%= INTERN_DEFS.map {|vardef, gen_hash, decl, func| gen_hash }.join("\n") %>
+}
+
+<%= NAME_TO_INT_DEFS.map {|decl, func| func }.join("\n") %>
+
+<%= INTERN_DEFS.map {|vardef, gen_hash, decl, func| func }.join("\n") %>
+
+EOS
+
+header_result = ERB.new(<<'EOS', nil, '%').result(binding)
+/* autogenerated file */
+<%= gen_const_decls %>
+<%= NAME_TO_INT_DEFS.map {|decl, func| decl }.join("\n") %>
+<%= INTERN_DEFS.map {|vardef, gen_hash, decl, func| decl }.join("\n") %>
+EOS
+
+if opt_H
+ File.open(opt_H, 'w') {|f|
+ f << header_result
+ }
+else
+ result = header_result + result
+end
+
+if opt_o
+ File.open(opt_o, 'w') {|f|
+ f << result
+ }
+else
+ $stdout << result
+end
+
+__END__
+
+SOCK_STREAM nil A stream socket provides a sequenced, reliable two-way connection for a byte stream
+SOCK_DGRAM nil A datagram socket provides connectionless, unreliable messaging
+SOCK_RAW nil A raw socket provides low-level access for direct access or implementing network protocols
+SOCK_RDM nil A reliable datagram socket provides reliable delivery of messages
+SOCK_SEQPACKET nil A sequential packet socket provides sequenced, reliable two-way connection for datagrams
+SOCK_PACKET nil Device-level packet access
+
+AF_UNSPEC nil Unspecified protocol, any supported address family
+PF_UNSPEC nil Unspecified protocol, any supported address family
+AF_INET nil IPv4 protocol
+PF_INET nil IPv4 protocol
+AF_INET6 nil IPv6 protocol
+PF_INET6 nil IPv6 protocol
+AF_UNIX nil UNIX sockets
+PF_UNIX nil UNIX sockets
+AF_AX25 nil AX.25 protocol
+PF_AX25 nil AX.25 protocol
+AF_IPX nil IPX protocol
+PF_IPX nil IPX protocol
+AF_APPLETALK nil AppleTalk protocol
+PF_APPLETALK nil AppleTalk protocol
+AF_LOCAL nil Host-internal protocols
+PF_LOCAL nil Host-internal protocols
+AF_IMPLINK nil ARPANET IMP protocol
+PF_IMPLINK nil ARPANET IMP protocol
+AF_PUP nil PARC Universal Packet protocol
+PF_PUP nil PARC Universal Packet protocol
+AF_CHAOS nil MIT CHAOS protocols
+PF_CHAOS nil MIT CHAOS protocols
+AF_NS nil XEROX NS protocols
+PF_NS nil XEROX NS protocols
+AF_ISO nil ISO Open Systems Interconnection protocols
+PF_ISO nil ISO Open Systems Interconnection protocols
+AF_OSI nil ISO Open Systems Interconnection protocols
+PF_OSI nil ISO Open Systems Interconnection protocols
+AF_ECMA nil European Computer Manufacturers protocols
+PF_ECMA nil European Computer Manufacturers protocols
+AF_DATAKIT nil Datakit protocol
+PF_DATAKIT nil Datakit protocol
+AF_CCITT nil CCITT (now ITU-T) protocols
+PF_CCITT nil CCITT (now ITU-T) protocols
+AF_SNA nil IBM SNA protocol
+PF_SNA nil IBM SNA protocol
+AF_DEC nil DECnet protocol
+PF_DEC nil DECnet protocol
+AF_DLI nil DEC Direct Data Link Interface protocol
+PF_DLI nil DEC Direct Data Link Interface protocol
+AF_LAT nil Local Area Transport protocol
+PF_LAT nil Local Area Transport protocol
+AF_HYLINK nil NSC Hyperchannel protocol
+PF_HYLINK nil NSC Hyperchannel protocol
+AF_ROUTE nil Internal routing protocol
+PF_ROUTE nil Internal routing protocol
+AF_LINK nil Link layer interface
+PF_LINK nil Link layer interface
+AF_COIP nil Connection-oriented IP
+PF_COIP nil Connection-oriented IP
+AF_CNT nil Computer Network Technology
+PF_CNT nil Computer Network Technology
+AF_SIP nil Simple Internet Protocol
+PF_SIP nil Simple Internet Protocol
+AF_NDRV nil Network driver raw access
+PF_NDRV nil Network driver raw access
+AF_ISDN nil Integrated Services Digital Network
+PF_ISDN nil Integrated Services Digital Network
+AF_NATM nil Native ATM access
+PF_NATM nil Native ATM access
+AF_SYSTEM
+PF_SYSTEM
+AF_NETBIOS nil NetBIOS
+PF_NETBIOS nil NetBIOS
+AF_PPP nil Point-to-Point Protocol
+PF_PPP nil Point-to-Point Protocol
+AF_ATM nil Asynchronous Transfer Mode
+PF_ATM nil Asynchronous Transfer Mode
+AF_NETGRAPH nil Netgraph sockets
+PF_NETGRAPH nil Netgraph sockets
+AF_MAX nil Maximum address family for this platform
+PF_MAX nil Maximum address family for this platform
+AF_PACKET nil Direct link-layer access
+PF_PACKET nil Direct link-layer access
+
+AF_E164 nil CCITT (ITU-T) E.164 recommendation
+PF_XTP nil eXpress Transfer Protocol
+PF_RTIP
+PF_PIP
+PF_KEY
+
+MSG_OOB nil Process out-of-band data
+MSG_PEEK nil Peek at incoming message
+MSG_DONTROUTE nil Send without using the routing tables
+MSG_EOR nil Data completes record
+MSG_TRUNC nil Data discarded before delivery
+MSG_CTRUNC nil Control data lost before delivery
+MSG_WAITALL nil Wait for full request or error
+MSG_DONTWAIT nil This message should be non-blocking
+MSG_EOF nil Data completes connection
+MSG_FLUSH nil Start of a hold sequence. Dumps to so_temp
+MSG_HOLD nil Hold fragment in so_temp
+MSG_SEND nil Send the packet in so_temp
+MSG_HAVEMORE nil Data ready to be read
+MSG_RCVMORE nil Data remains in the current packet
+MSG_COMPAT nil End of record
+MSG_PROXY nil Wait for full request
+MSG_FIN
+MSG_SYN
+MSG_CONFIRM nil Confirm path validity
+MSG_RST
+MSG_ERRQUEUE nil Fetch message from error queue
+MSG_NOSIGNAL nil Do not generate SIGPIPE
+MSG_MORE nil Sender will send more
+MSG_FASTOPEN nil Reduce step of the handshake process
+
+SOL_SOCKET nil Socket-level options
+SOL_IP nil IP socket options
+SOL_IPX nil IPX socket options
+SOL_AX25 nil AX.25 socket options
+SOL_ATALK nil AppleTalk socket options
+SOL_TCP nil TCP socket options
+SOL_UDP nil UDP socket options
+
+IPPROTO_IP 0 Dummy protocol for IP
+IPPROTO_ICMP 1 Control message protocol
+IPPROTO_IGMP nil Group Management Protocol
+IPPROTO_GGP nil Gateway to Gateway Protocol
+IPPROTO_TCP 6 TCP
+IPPROTO_EGP nil Exterior Gateway Protocol
+IPPROTO_PUP nil PARC Universal Packet protocol
+IPPROTO_UDP 17 UDP
+IPPROTO_IDP nil XNS IDP
+IPPROTO_HELLO nil "hello" routing protocol
+IPPROTO_ND nil Sun net disk protocol
+IPPROTO_TP nil ISO transport protocol class 4
+IPPROTO_XTP nil Xpress Transport Protocol
+IPPROTO_EON nil ISO cnlp
+IPPROTO_BIP
+IPPROTO_AH nil IP6 auth header
+IPPROTO_DSTOPTS nil IP6 destination option
+IPPROTO_ESP nil IP6 Encapsulated Security Payload
+IPPROTO_FRAGMENT nil IP6 fragmentation header
+IPPROTO_HOPOPTS nil IP6 hop-by-hop options
+IPPROTO_ICMPV6 nil ICMP6
+IPPROTO_IPV6 nil IP6 header
+IPPROTO_NONE nil IP6 no next header
+IPPROTO_ROUTING nil IP6 routing header
+
+IPPROTO_RAW 255 Raw IP packet
+IPPROTO_MAX nil Maximum IPPROTO constant
+
+# Some port configuration
+IPPORT_RESERVED 1024 Default minimum address for bind or connect
+IPPORT_USERRESERVED 5000 Default maximum address for bind or connect
+
+# Some reserved IP v.4 addresses
+INADDR_ANY 0x00000000 A socket bound to INADDR_ANY receives packets from all interfaces and sends from the default IP address
+INADDR_BROADCAST 0xffffffff The network broadcast address
+INADDR_LOOPBACK 0x7F000001 The loopback address
+INADDR_UNSPEC_GROUP 0xe0000000 The reserved multicast group
+INADDR_ALLHOSTS_GROUP 0xe0000001 Multicast group for all systems on this subset
+INADDR_MAX_LOCAL_GROUP 0xe00000ff The last local network multicast group
+INADDR_NONE 0xffffffff A bitmask for matching no valid IP address
+
+# IP [gs]etsockopt options
+IP_OPTIONS nil IP options to be included in packets
+IP_HDRINCL nil Header is included with data
+IP_TOS nil IP type-of-service
+IP_TTL nil IP time-to-live
+IP_RECVOPTS nil Receive all IP options with datagram
+IP_RECVRETOPTS nil Receive all IP options for response
+IP_RECVDSTADDR nil Receive IP destination address with datagram
+IP_RETOPTS nil IP options to be included in datagrams
+IP_MINTTL nil Minimum TTL allowed for received packets
+IP_DONTFRAG nil Don't fragment packets
+IP_SENDSRCADDR nil Source address for outgoing UDP datagrams
+IP_ONESBCAST nil Force outgoing broadcast datagrams to have the undirected broadcast address
+IP_RECVTTL nil Receive IP TTL with datagrams
+IP_RECVIF nil Receive interface information with datagrams
+IP_RECVSLLA nil Receive link-layer address with datagrams
+IP_PORTRANGE nil Set the port range for sockets with unspecified port numbers
+IP_MULTICAST_IF nil IP multicast interface
+IP_MULTICAST_TTL nil IP multicast TTL
+IP_MULTICAST_LOOP nil IP multicast loopback
+IP_ADD_MEMBERSHIP nil Add a multicast group membership
+IP_DROP_MEMBERSHIP nil Drop a multicast group membership
+IP_DEFAULT_MULTICAST_TTL nil Default multicast TTL
+IP_DEFAULT_MULTICAST_LOOP nil Default multicast loopback
+IP_MAX_MEMBERSHIPS nil Maximum number multicast groups a socket can join
+IP_ROUTER_ALERT nil Notify transit routers to more closely examine the contents of an IP packet
+IP_PKTINFO nil Receive packet information with datagrams
+IP_PKTOPTIONS nil Receive packet options with datagrams
+IP_MTU_DISCOVER nil Path MTU discovery
+IP_RECVERR nil Enable extended reliable error message passing
+IP_RECVTOS nil Receive TOS with incoming packets
+IP_MTU nil The Maximum Transmission Unit of the socket
+IP_FREEBIND nil Allow binding to nonexistent IP addresses
+IP_IPSEC_POLICY nil IPsec security policy
+IP_XFRM_POLICY
+IP_PASSSEC nil Retrieve security context with datagram
+IP_TRANSPARENT nil Transparent proxy
+IP_PMTUDISC_DONT nil Never send DF frames
+IP_PMTUDISC_WANT nil Use per-route hints
+IP_PMTUDISC_DO nil Always send DF frames
+IP_UNBLOCK_SOURCE nil Unblock IPv4 multicast packets with a give source address
+IP_BLOCK_SOURCE nil Block IPv4 multicast packets with a give source address
+IP_ADD_SOURCE_MEMBERSHIP nil Add a multicast group membership
+IP_DROP_SOURCE_MEMBERSHIP nil Drop a multicast group membership
+IP_MSFILTER nil Multicast source filtering
+
+MCAST_JOIN_GROUP nil Join a multicast group
+MCAST_BLOCK_SOURCE nil Block multicast packets from this source
+MCAST_UNBLOCK_SOURCE nil Unblock multicast packets from this source
+MCAST_LEAVE_GROUP nil Leave a multicast group
+MCAST_JOIN_SOURCE_GROUP nil Join a multicast source group
+MCAST_LEAVE_SOURCE_GROUP nil Leave a multicast source group
+MCAST_MSFILTER nil Multicast source filtering
+MCAST_EXCLUDE nil Exclusive multicast source filter
+MCAST_INCLUDE nil Inclusive multicast source filter
+
+SO_DEBUG nil Debug info recording
+SO_REUSEADDR nil Allow local address reuse
+SO_REUSEPORT nil Allow local address and port reuse
+SO_TYPE nil Get the socket type
+SO_ERROR nil Get and clear the error status
+SO_DONTROUTE nil Use interface addresses
+SO_BROADCAST nil Permit sending of broadcast messages
+SO_SNDBUF nil Send buffer size
+SO_RCVBUF nil Receive buffer size
+SO_SNDBUFFORCE nil Send buffer size without wmem_max limit (Linux 2.6.14)
+SO_RCVBUFFORCE nil Receive buffer size without rmem_max limit (Linux 2.6.14)
+SO_KEEPALIVE nil Keep connections alive
+SO_OOBINLINE nil Leave received out-of-band data in-line
+SO_NO_CHECK nil Disable checksums
+SO_PRIORITY nil The protocol-defined priority for all packets on this socket
+SO_LINGER nil Linger on close if data is present
+SO_PASSCRED nil Receive SCM_CREDENTIALS messages
+SO_PEERCRED nil The credentials of the foreign process connected to this socket
+SO_RCVLOWAT nil Receive low-water mark
+SO_SNDLOWAT nil Send low-water mark
+SO_RCVTIMEO nil Receive timeout
+SO_SNDTIMEO nil Send timeout
+SO_ACCEPTCONN nil Socket has had listen() called on it
+SO_USELOOPBACK nil Bypass hardware when possible
+SO_ACCEPTFILTER nil There is an accept filter
+SO_DONTTRUNC nil Retain unread data
+SO_WANTMORE nil Give a hint when more data is ready
+SO_WANTOOBFLAG nil OOB data is wanted in MSG_FLAG on receive
+SO_NREAD nil Get first packet byte count
+SO_NKE nil Install socket-level Network Kernel Extension
+SO_NOSIGPIPE nil Don't SIGPIPE on EPIPE
+SO_SECURITY_AUTHENTICATION
+SO_SECURITY_ENCRYPTION_TRANSPORT
+SO_SECURITY_ENCRYPTION_NETWORK
+SO_BINDTODEVICE nil Only send packets from the given interface
+SO_ATTACH_FILTER nil Attach an accept filter
+SO_DETACH_FILTER nil Detach an accept filter
+SO_GET_FILTER nil Obtain filter set by SO_ATTACH_FILTER (Linux 3.8)
+SO_PEERNAME nil Name of the connecting user
+SO_TIMESTAMP nil Receive timestamp with datagrams (timeval)
+SO_TIMESTAMPNS nil Receive nanosecond timestamp with datagrams (timespec)
+SO_BINTIME nil Receive timestamp with datagrams (bintime)
+SO_RECVUCRED nil Receive user credentials with datagram
+SO_MAC_EXEMPT nil Mandatory Access Control exemption for unlabeled peers
+SO_ALLZONES nil Bypass zone boundaries
+SO_PEERSEC nil Obtain the security credentials (Linux 2.6.2)
+SO_PASSSEC nil Toggle security context passing (Linux 2.6.18)
+SO_MARK nil Set the mark for mark-based routing (Linux 2.6.25)
+SO_TIMESTAMPING nil Time stamping of incoming and outgoing packets (Linux 2.6.30)
+SO_PROTOCOL nil Protocol given for socket() (Linux 2.6.32)
+SO_DOMAIN nil Domain given for socket() (Linux 2.6.32)
+SO_RXQ_OVFL nil Toggle cmsg for number of packets dropped (Linux 2.6.33)
+SO_WIFI_STATUS nil Toggle cmsg for wifi status (Linux 3.3)
+SO_PEEK_OFF nil Set the peek offset (Linux 3.4)
+SO_NOFCS nil Set netns of a socket (Linux 3.4)
+SO_LOCK_FILTER nil Lock the filter attached to a socket (Linux 3.9)
+SO_SELECT_ERR_QUEUE nil Make select() detect socket error queue with errorfds (Linux 3.10)
+SO_BUSY_POLL nil Set the threshold in microseconds for low latency polling (Linux 3.11)
+SO_MAX_PACING_RATE nil Cap the rate computed by transport layer. [bytes per second] (Linux 3.13)
+SO_BPF_EXTENSIONS nil Query supported BPF extensions (Linux 3.14)
+
+SOPRI_INTERACTIVE nil Interactive socket priority
+SOPRI_NORMAL nil Normal socket priority
+SOPRI_BACKGROUND nil Background socket priority
+
+IPX_TYPE
+
+TCP_NODELAY nil Don't delay sending to coalesce packets
+TCP_MAXSEG nil Set maximum segment size
+TCP_CORK nil Don't send partial frames (Linux 2.2, glibc 2.2)
+TCP_DEFER_ACCEPT nil Don't notify a listening socket until data is ready (Linux 2.4, glibc 2.2)
+TCP_INFO nil Retrieve information about this socket (Linux 2.4, glibc 2.2)
+TCP_KEEPCNT nil Maximum number of keepalive probes allowed before dropping a connection (Linux 2.4, glibc 2.2)
+TCP_KEEPIDLE nil Idle time before keepalive probes are sent (Linux 2.4, glibc 2.2)
+TCP_KEEPINTVL nil Time between keepalive probes (Linux 2.4, glibc 2.2)
+TCP_LINGER2 nil Lifetime of orphaned FIN_WAIT2 sockets (Linux 2.4, glibc 2.2)
+TCP_MD5SIG nil Use MD5 digests (RFC2385, Linux 2.6.20, glibc 2.7)
+TCP_NOOPT nil Don't use TCP options
+TCP_NOPUSH nil Don't push the last block of write
+TCP_QUICKACK nil Enable quickack mode (Linux 2.4.4, glibc 2.3)
+TCP_SYNCNT nil Number of SYN retransmits before a connection is dropped (Linux 2.4, glibc 2.2)
+TCP_WINDOW_CLAMP nil Clamp the size of the advertised window (Linux 2.4, glibc 2.2)
+TCP_FASTOPEN nil Reduce step of the handshake process (Linux 3.7, glibc 2.18)
+TCP_CONGESTION nil TCP congestion control algorithm (Linux 2.6.13, glibc 2.6)
+TCP_COOKIE_TRANSACTIONS nil TCP Cookie Transactions (Linux 2.6.33, glibc 2.18)
+TCP_QUEUE_SEQ nil Sequence of a queue for repair mode (Linux 3.5, glibc 2.18)
+TCP_REPAIR nil Repair mode (Linux 3.5, glibc 2.18)
+TCP_REPAIR_OPTIONS nil Options for repair mode (Linux 3.5, glibc 2.18)
+TCP_REPAIR_QUEUE nil Queue for repair mode (Linux 3.5, glibc 2.18)
+TCP_THIN_DUPACK nil Duplicated acknowledgments handling for thin-streams (Linux 2.6.34, glibc 2.18)
+TCP_THIN_LINEAR_TIMEOUTS nil Linear timeouts for thin-streams (Linux 2.6.34, glibc 2.18)
+TCP_TIMESTAMP nil TCP timestamp (Linux 3.9, glibc 2.18)
+TCP_USER_TIMEOUT nil Max timeout before a TCP connection is aborted (Linux 2.6.37, glibc 2.18)
+
+UDP_CORK nil Don't send partial frames (Linux 2.5.44, glibc 2.11)
+
+EAI_ADDRFAMILY nil Address family for hostname not supported
+EAI_AGAIN nil Temporary failure in name resolution
+EAI_BADFLAGS nil Invalid flags
+EAI_FAIL nil Non-recoverable failure in name resolution
+EAI_FAMILY nil Address family not supported
+EAI_MEMORY nil Memory allocation failure
+EAI_NODATA nil No address associated with hostname
+EAI_NONAME nil Hostname nor servname, or not known
+EAI_OVERFLOW nil Argument buffer overflow
+EAI_SERVICE nil Servname not supported for socket type
+EAI_SOCKTYPE nil Socket type not supported
+EAI_SYSTEM nil System error returned in errno
+EAI_BADHINTS nil Invalid value for hints
+EAI_PROTOCOL nil Resolved protocol is unknown
+EAI_MAX nil Maximum error code from getaddrinfo
+
+AI_PASSIVE nil Get address to use with bind()
+AI_CANONNAME nil Fill in the canonical name
+AI_NUMERICHOST nil Prevent host name resolution
+AI_NUMERICSERV nil Prevent service name resolution
+AI_MASK nil Valid flag mask for getaddrinfo (not for application use)
+AI_ALL nil Allow all addresses
+AI_V4MAPPED_CFG nil Accept IPv4 mapped addresses if the kernel supports it
+AI_ADDRCONFIG nil Accept only if any address is assigned
+AI_V4MAPPED nil Accept IPv4-mapped IPv6 addresses
+AI_DEFAULT nil Default flags for getaddrinfo
+
+NI_MAXHOST nil Maximum length of a hostname
+NI_MAXSERV nil Maximum length of a service name
+NI_NOFQDN nil An FQDN is not required for local hosts, return only the local part
+NI_NUMERICHOST nil Return a numeric address
+NI_NAMEREQD nil A name is required
+NI_NUMERICSERV nil Return the service name as a digit string
+NI_DGRAM nil The service specified is a datagram service (looks up UDP ports)
+
+SHUT_RD 0 Shut down the reading side of the socket
+SHUT_WR 1 Shut down the writing side of the socket
+SHUT_RDWR 2 Shut down the both sides of the socket
+
+IPV6_JOIN_GROUP nil Join a group membership
+IPV6_LEAVE_GROUP nil Leave a group membership
+IPV6_MULTICAST_HOPS nil IP6 multicast hops
+IPV6_MULTICAST_IF nil IP6 multicast interface
+IPV6_MULTICAST_LOOP nil IP6 multicast loopback
+IPV6_UNICAST_HOPS nil IP6 unicast hops
+IPV6_V6ONLY nil Only bind IPv6 with a wildcard bind
+IPV6_CHECKSUM nil Checksum offset for raw sockets
+IPV6_DONTFRAG nil Don't fragment packets
+IPV6_DSTOPTS nil Destination option
+IPV6_HOPLIMIT nil Hop limit
+IPV6_HOPOPTS nil Hop-by-hop option
+IPV6_NEXTHOP nil Next hop address
+IPV6_PATHMTU nil Retrieve current path MTU
+IPV6_PKTINFO nil Receive packet information with datagram
+IPV6_RECVDSTOPTS nil Receive all IP6 options for response
+IPV6_RECVHOPLIMIT nil Receive hop limit with datagram
+IPV6_RECVHOPOPTS nil Receive hop-by-hop options
+IPV6_RECVPKTINFO nil Receive destination IP address and incoming interface
+IPV6_RECVRTHDR nil Receive routing header
+IPV6_RECVTCLASS nil Receive traffic class
+IPV6_RTHDR nil Allows removal of sticky routing headers
+IPV6_RTHDRDSTOPTS nil Allows removal of sticky destination options header
+IPV6_RTHDR_TYPE_0 nil Routing header type 0
+IPV6_RECVPATHMTU nil Receive current path MTU with datagram
+IPV6_TCLASS nil Specify the traffic class
+IPV6_USE_MIN_MTU nil Use the minimum MTU size
+
+INET_ADDRSTRLEN 16 Maximum length of an IPv4 address string
+INET6_ADDRSTRLEN 46 Maximum length of an IPv6 address string
+IFNAMSIZ nil Maximum interface name size
+IF_NAMESIZE nil Maximum interface name size
+
+SOMAXCONN 5 Maximum connection requests that may be queued for a socket
+
+SCM_RIGHTS nil Access rights
+SCM_TIMESTAMP nil Timestamp (timeval)
+SCM_TIMESTAMPNS nil Timespec (timespec)
+SCM_TIMESTAMPING nil Timestamp (timespec list) (Linux 2.6.30)
+SCM_BINTIME nil Timestamp (bintime)
+SCM_CREDENTIALS nil The sender's credentials
+SCM_CREDS nil Process credentials
+SCM_UCRED nil User credentials
+SCM_WIFI_STATUS nil Wifi status (Linux 3.3)
+
+LOCAL_PEERCRED nil Retrieve peer credentials
+LOCAL_CREDS nil Pass credentials to receiver
+LOCAL_CONNWAIT nil Connect blocks until accepted
+
+IFF_802_1Q_VLAN nil 802.1Q VLAN device
+IFF_ALLMULTI nil receive all multicast packets
+IFF_ALTPHYS nil use alternate physical connection
+IFF_AUTOMEDIA nil auto media select active
+IFF_BONDING nil bonding master or slave
+IFF_BRIDGE_PORT nil device used as bridge port
+IFF_BROADCAST nil broadcast address valid
+IFF_CANTCONFIG nil unconfigurable using ioctl(2)
+IFF_DEBUG nil turn on debugging
+IFF_DISABLE_NETPOLL nil disable netpoll at run-time
+IFF_DONT_BRIDGE nil disallow bridging this ether dev
+IFF_DORMANT nil driver signals dormant
+IFF_DRV_OACTIVE nil tx hardware queue is full
+IFF_DRV_RUNNING nil resources allocated
+IFF_DYING nil interface is winding down
+IFF_DYNAMIC nil dialup device with changing addresses
+IFF_EBRIDGE nil ethernet bridging device
+IFF_ECHO nil echo sent packets
+IFF_ISATAP nil ISATAP interface (RFC4214)
+IFF_LINK0 nil per link layer defined bit 0
+IFF_LINK1 nil per link layer defined bit 1
+IFF_LINK2 nil per link layer defined bit 2
+IFF_LIVE_ADDR_CHANGE nil hardware address change when it's running
+IFF_LOOPBACK nil loopback net
+IFF_LOWER_UP nil driver signals L1 up
+IFF_MACVLAN_PORT nil device used as macvlan port
+IFF_MASTER nil master of a load balancer
+IFF_MASTER_8023AD nil bonding master, 802.3ad.
+IFF_MASTER_ALB nil bonding master, balance-alb.
+IFF_MASTER_ARPMON nil bonding master, ARP mon in use
+IFF_MONITOR nil user-requested monitor mode
+IFF_MULTICAST nil supports multicast
+IFF_NOARP nil no address resolution protocol
+IFF_NOTRAILERS nil avoid use of trailers
+IFF_OACTIVE nil transmission in progress
+IFF_OVS_DATAPATH nil device used as Open vSwitch datapath port
+IFF_POINTOPOINT nil point-to-point link
+IFF_PORTSEL nil can set media type
+IFF_PPROMISC nil user-requested promisc mode
+IFF_PROMISC nil receive all packets
+IFF_RENAMING nil interface is being renamed
+IFF_ROUTE nil routing entry installed
+IFF_RUNNING nil resources allocated
+IFF_SIMPLEX nil can't hear own transmissions
+IFF_SLAVE nil slave of a load balancer
+IFF_SLAVE_INACTIVE nil bonding slave not the curr. active
+IFF_SLAVE_NEEDARP nil need ARPs for validation
+IFF_SMART nil interface manages own routes
+IFF_STATICARP nil static ARP
+IFF_SUPP_NOFCS nil sending custom FCS
+IFF_TEAM_PORT nil used as team port
+IFF_TX_SKB_SHARING nil sharing skbs on transmit
+IFF_UNICAST_FLT nil unicast filtering
+IFF_UP nil interface is up
+IFF_WAN_HDLC nil WAN HDLC device
+IFF_XMIT_DST_RELEASE nil dev_hard_start_xmit() is allowed to release skb->dst
+IFF_VOLATILE nil volatile flags
+IFF_CANTCHANGE nil flags not changeable
diff --git a/jni/ruby/ext/socket/option.c b/jni/ruby/ext/socket/option.c
new file mode 100644
index 0000000..b00ffb9
--- /dev/null
+++ b/jni/ruby/ext/socket/option.c
@@ -0,0 +1,1473 @@
+#include "rubysocket.h"
+
+VALUE rb_cSockOpt;
+
+#define pack_var(v) rb_str_new((const char *)&(v), sizeof(v))
+
+#define CAT(x,y) x##y
+#define XCAT(x,y) CAT(x,y)
+
+#if defined(__linux__) || \
+ defined(__GNU__) /* GNU/Hurd */ || \
+ defined(__FreeBSD__) || \
+ defined(__DragonFly__) || \
+ defined(__APPLE__) || \
+ defined(_WIN32) || \
+ defined(__CYGWIN__)
+# define TYPE_IP_MULTICAST_LOOP int
+# define TYPE_IP_MULTICAST_TTL int
+#else
+/* The original IP multicast implementation by Steve Deering
+ * NetBSD
+ * OpenBSD
+ * SunOS
+ */
+# define TYPE_IP_MULTICAST_LOOP byte
+# define TYPE_IP_MULTICAST_TTL byte
+# define USE_INSPECT_BYTE 1
+#endif
+
+static VALUE
+sockopt_pack_byte(VALUE value)
+{
+ char i = NUM2CHR(rb_to_int(value));
+ return pack_var(i);
+}
+
+static VALUE
+sockopt_pack_int(VALUE value)
+{
+ int i = NUM2INT(rb_to_int(value));
+ return pack_var(i);
+}
+
+static VALUE
+constant_to_sym(int constant, ID (*intern_const)(int))
+{
+ ID name = intern_const(constant);
+ if (name) {
+ return ID2SYM(name);
+ }
+
+ return INT2NUM(constant);
+}
+
+static VALUE
+optname_to_sym(int level, int optname)
+{
+ switch (level) {
+ case SOL_SOCKET:
+ return constant_to_sym(optname, rsock_intern_so_optname);
+ case IPPROTO_IP:
+ return constant_to_sym(optname, rsock_intern_ip_optname);
+#ifdef IPPROTO_IPV6
+ case IPPROTO_IPV6:
+ return constant_to_sym(optname, rsock_intern_ipv6_optname);
+#endif
+ case IPPROTO_TCP:
+ return constant_to_sym(optname, rsock_intern_tcp_optname);
+ case IPPROTO_UDP:
+ return constant_to_sym(optname, rsock_intern_udp_optname);
+ default:
+ return INT2NUM(optname);
+ }
+}
+
+/*
+ * call-seq:
+ * Socket::Option.new(family, level, optname, data) => sockopt
+ *
+ * Returns a new Socket::Option object.
+ *
+ * sockopt = Socket::Option.new(:INET, :SOCKET, :KEEPALIVE, [1].pack("i"))
+ * p sockopt #=> #<Socket::Option: INET SOCKET KEEPALIVE 1>
+ *
+ */
+static VALUE
+sockopt_initialize(VALUE self, VALUE vfamily, VALUE vlevel, VALUE voptname, VALUE data)
+{
+ int family = rsock_family_arg(vfamily);
+ int level = rsock_level_arg(family, vlevel);
+ int optname = rsock_optname_arg(family, level, voptname);
+ StringValue(data);
+ rb_ivar_set(self, rb_intern("family"), INT2NUM(family));
+ rb_ivar_set(self, rb_intern("level"), INT2NUM(level));
+ rb_ivar_set(self, rb_intern("optname"), INT2NUM(optname));
+ rb_ivar_set(self, rb_intern("data"), data);
+ return self;
+}
+
+VALUE
+rsock_sockopt_new(int family, int level, int optname, VALUE data)
+{
+ NEWOBJ_OF(obj, struct RObject, rb_cSockOpt, T_OBJECT);
+ StringValue(data);
+ sockopt_initialize((VALUE)obj, INT2NUM(family), INT2NUM(level), INT2NUM(optname), data);
+ return (VALUE)obj;
+}
+
+/*
+ * call-seq:
+ * sockopt.family => integer
+ *
+ * returns the socket family as an integer.
+ *
+ * p Socket::Option.new(:INET6, :IPV6, :RECVPKTINFO, [1].pack("i!")).family
+ * #=> 10
+ */
+static VALUE
+sockopt_family_m(VALUE self)
+{
+ return rb_attr_get(self, rb_intern("family"));
+}
+
+static int
+sockopt_level(VALUE self)
+{
+ return NUM2INT(rb_attr_get(self, rb_intern("level")));
+}
+
+/*
+ * call-seq:
+ * sockopt.level => integer
+ *
+ * returns the socket level as an integer.
+ *
+ * p Socket::Option.new(:INET6, :IPV6, :RECVPKTINFO, [1].pack("i!")).level
+ * #=> 41
+ */
+static VALUE
+sockopt_level_m(VALUE self)
+{
+ return INT2NUM(sockopt_level(self));
+}
+
+static int
+sockopt_optname(VALUE self)
+{
+ return NUM2INT(rb_attr_get(self, rb_intern("optname")));
+}
+
+/*
+ * call-seq:
+ * sockopt.optname => integer
+ *
+ * returns the socket option name as an integer.
+ *
+ * p Socket::Option.new(:INET6, :IPV6, :RECVPKTINFO, [1].pack("i!")).optname
+ * #=> 2
+ */
+static VALUE
+sockopt_optname_m(VALUE self)
+{
+ return INT2NUM(sockopt_optname(self));
+}
+
+/*
+ * call-seq:
+ * sockopt.data => string
+ * sockopt.to_s => string
+ *
+ * returns the socket option data as a string.
+ *
+ * p Socket::Option.new(:INET6, :IPV6, :RECVPKTINFO, [1].pack("i!")).data
+ * #=> "\x01\x00\x00\x00"
+ */
+static VALUE
+sockopt_data(VALUE self)
+{
+ VALUE v = rb_attr_get(self, rb_intern("data"));
+ StringValue(v);
+ return v;
+}
+
+/*
+ * call-seq:
+ * Socket::Option.byte(family, level, optname, integer) => sockopt
+ *
+ * Creates a new Socket::Option object which contains a byte as data.
+ *
+ * p Socket::Option.byte(:INET, :SOCKET, :KEEPALIVE, 1)
+ * #=> #<Socket::Option: INET SOCKET KEEPALIVE 1>
+ */
+static VALUE
+sockopt_s_byte(VALUE klass, VALUE vfamily, VALUE vlevel, VALUE voptname, VALUE vint)
+{
+ int family = rsock_family_arg(vfamily);
+ int level = rsock_level_arg(family, vlevel);
+ int optname = rsock_optname_arg(family, level, voptname);
+ return rsock_sockopt_new(family, level, optname, sockopt_pack_byte(vint));
+}
+
+/*
+ * call-seq:
+ * sockopt.byte => integer
+ *
+ * Returns the data in _sockopt_ as an byte.
+ *
+ * sockopt = Socket::Option.byte(:INET, :SOCKET, :KEEPALIVE, 1)
+ * p sockopt.byte => 1
+ */
+static VALUE
+sockopt_byte(VALUE self)
+{
+ unsigned char i;
+ VALUE data = sockopt_data(self);
+ StringValue(data);
+ if (RSTRING_LEN(data) != sizeof(i))
+ rb_raise(rb_eTypeError, "size differ. expected as sizeof(int)=%d but %ld",
+ (int)sizeof(i), (long)RSTRING_LEN(data));
+ return CHR2FIX(*RSTRING_PTR(data));
+}
+
+/*
+ * call-seq:
+ * Socket::Option.int(family, level, optname, integer) => sockopt
+ *
+ * Creates a new Socket::Option object which contains an int as data.
+ *
+ * The size and endian is dependent on the platform.
+ *
+ * p Socket::Option.int(:INET, :SOCKET, :KEEPALIVE, 1)
+ * #=> #<Socket::Option: INET SOCKET KEEPALIVE 1>
+ */
+static VALUE
+sockopt_s_int(VALUE klass, VALUE vfamily, VALUE vlevel, VALUE voptname, VALUE vint)
+{
+ int family = rsock_family_arg(vfamily);
+ int level = rsock_level_arg(family, vlevel);
+ int optname = rsock_optname_arg(family, level, voptname);
+ return rsock_sockopt_new(family, level, optname, sockopt_pack_int(vint));
+}
+
+/*
+ * call-seq:
+ * sockopt.int => integer
+ *
+ * Returns the data in _sockopt_ as an int.
+ *
+ * The size and endian is dependent on the platform.
+ *
+ * sockopt = Socket::Option.int(:INET, :SOCKET, :KEEPALIVE, 1)
+ * p sockopt.int => 1
+ */
+static VALUE
+sockopt_int(VALUE self)
+{
+ int i;
+ VALUE data = sockopt_data(self);
+ StringValue(data);
+ if (RSTRING_LEN(data) != sizeof(int))
+ rb_raise(rb_eTypeError, "size differ. expected as sizeof(int)=%d but %ld",
+ (int)sizeof(int), (long)RSTRING_LEN(data));
+ memcpy((char*)&i, RSTRING_PTR(data), sizeof(int));
+ return INT2NUM(i);
+}
+
+/*
+ * call-seq:
+ * Socket::Option.bool(family, level, optname, bool) => sockopt
+ *
+ * Creates a new Socket::Option object which contains boolean as data.
+ * Actually 0 or 1 as int is used.
+ *
+ * p Socket::Option.bool(:INET, :SOCKET, :KEEPALIVE, true)
+ * #=> #<Socket::Option: INET SOCKET KEEPALIVE 1>
+ *
+ * p Socket::Option.bool(:INET, :SOCKET, :KEEPALIVE, false)
+ * #=> #<Socket::Option: AF_INET SOCKET KEEPALIVE 0>
+ *
+ */
+static VALUE
+sockopt_s_bool(VALUE klass, VALUE vfamily, VALUE vlevel, VALUE voptname, VALUE vbool)
+{
+ int family = rsock_family_arg(vfamily);
+ int level = rsock_level_arg(family, vlevel);
+ int optname = rsock_optname_arg(family, level, voptname);
+ int i = RTEST(vbool) ? 1 : 0;
+ return rsock_sockopt_new(family, level, optname, pack_var(i));
+}
+
+/*
+ * call-seq:
+ * sockopt.bool => true or false
+ *
+ * Returns the data in _sockopt_ as an boolean value.
+ *
+ * sockopt = Socket::Option.int(:INET, :SOCKET, :KEEPALIVE, 1)
+ * p sockopt.bool => true
+ */
+static VALUE
+sockopt_bool(VALUE self)
+{
+ int i;
+ VALUE data = sockopt_data(self);
+ StringValue(data);
+ if (RSTRING_LEN(data) != sizeof(int))
+ rb_raise(rb_eTypeError, "size differ. expected as sizeof(int)=%d but %ld",
+ (int)sizeof(int), (long)RSTRING_LEN(data));
+ memcpy((char*)&i, RSTRING_PTR(data), sizeof(int));
+ return i == 0 ? Qfalse : Qtrue;
+}
+
+/*
+ * call-seq:
+ * Socket::Option.linger(onoff, secs) => sockopt
+ *
+ * Creates a new Socket::Option object for SOL_SOCKET/SO_LINGER.
+ *
+ * _onoff_ should be an integer or a boolean.
+ *
+ * _secs_ should be the number of seconds.
+ *
+ * p Socket::Option.linger(true, 10)
+ * #=> #<Socket::Option: UNSPEC SOCKET LINGER on 10sec>
+ *
+ */
+static VALUE
+sockopt_s_linger(VALUE klass, VALUE vonoff, VALUE vsecs)
+{
+ VALUE tmp;
+ struct linger l;
+ memset(&l, 0, sizeof(l));
+ if (!NIL_P(tmp = rb_check_to_integer(vonoff, "to_int")))
+ l.l_onoff = NUM2INT(tmp);
+ else
+ l.l_onoff = RTEST(vonoff) ? 1 : 0;
+ l.l_linger = NUM2INT(vsecs);
+ return rsock_sockopt_new(AF_UNSPEC, SOL_SOCKET, SO_LINGER, pack_var(l));
+}
+
+/*
+ * call-seq:
+ * sockopt.linger => [bool, seconds]
+ *
+ * Returns the linger data in _sockopt_ as a pair of boolean and integer.
+ *
+ * sockopt = Socket::Option.linger(true, 10)
+ * p sockopt.linger => [true, 10]
+ */
+static VALUE
+sockopt_linger(VALUE self)
+{
+ int level = sockopt_level(self);
+ int optname = sockopt_optname(self);
+ VALUE data = sockopt_data(self);
+ struct linger l;
+ VALUE vonoff, vsecs;
+
+ if (level != SOL_SOCKET || optname != SO_LINGER)
+ rb_raise(rb_eTypeError, "linger socket option expected");
+ if (RSTRING_LEN(data) != sizeof(l))
+ rb_raise(rb_eTypeError, "size differ. expected as sizeof(struct linger)=%d but %ld",
+ (int)sizeof(struct linger), (long)RSTRING_LEN(data));
+ memcpy((char*)&l, RSTRING_PTR(data), sizeof(struct linger));
+ switch (l.l_onoff) {
+ case 0: vonoff = Qfalse; break;
+ case 1: vonoff = Qtrue; break;
+ default: vonoff = INT2NUM(l.l_onoff); break;
+ }
+ vsecs = INT2NUM(l.l_linger);
+ return rb_assoc_new(vonoff, vsecs);
+}
+
+/*
+ * call-seq:
+ * Socket::Option.ipv4_multicast_loop(integer) => sockopt
+ *
+ * Creates a new Socket::Option object for IP_MULTICAST_LOOP.
+ *
+ * The size is dependent on the platform.
+ *
+ * sockopt = Socket::Option.int(:INET, :IPPROTO_IP, :IP_MULTICAST_LOOP, 1)
+ * p sockopt.int => 1
+ *
+ * p Socket::Option.ipv4_multicast_loop(10)
+ * #=> #<Socket::Option: INET IP MULTICAST_LOOP 10>
+ *
+ */
+static VALUE
+sockopt_s_ipv4_multicast_loop(VALUE klass, VALUE value)
+{
+
+#if defined(IPPROTO_IP) && defined(IP_MULTICAST_LOOP)
+ VALUE o = XCAT(sockopt_pack_,TYPE_IP_MULTICAST_LOOP)(value);
+ return rsock_sockopt_new(AF_INET, IPPROTO_IP, IP_MULTICAST_LOOP, o);
+#else
+# error IPPROTO_IP or IP_MULTICAST_LOOP is not implemented
+#endif
+}
+
+/*
+ * call-seq:
+ * sockopt.ipv4_multicast_loop => integer
+ *
+ * Returns the ipv4_multicast_loop data in _sockopt_ as a integer.
+ *
+ * sockopt = Socket::Option.ipv4_multicast_loop(10)
+ * p sockopt.ipv4_multicast_loop => 10
+ */
+static VALUE
+sockopt_ipv4_multicast_loop(VALUE self)
+{
+ int family = NUM2INT(sockopt_family_m(self));
+ int level = sockopt_level(self);
+ int optname = sockopt_optname(self);
+
+#if defined(IPPROTO_IP) && defined(IP_MULTICAST_LOOP)
+ if (family == AF_INET && level == IPPROTO_IP && optname == IP_MULTICAST_LOOP) {
+ return XCAT(sockopt_,TYPE_IP_MULTICAST_LOOP)(self);
+ }
+#endif
+ rb_raise(rb_eTypeError, "ipv4_multicast_loop socket option expected");
+ UNREACHABLE;
+}
+
+#define inspect_ipv4_multicast_loop(a,b,c,d) \
+ XCAT(inspect_,TYPE_IP_MULTICAST_LOOP)(a,b,c,d)
+
+/*
+ * call-seq:
+ * Socket::Option.ipv4_multicast_ttl(integer) => sockopt
+ *
+ * Creates a new Socket::Option object for IP_MULTICAST_TTL.
+ *
+ * The size is dependent on the platform.
+ *
+ * p Socket::Option.ipv4_multicast_ttl(10)
+ * #=> #<Socket::Option: INET IP MULTICAST_TTL 10>
+ *
+ */
+static VALUE
+sockopt_s_ipv4_multicast_ttl(VALUE klass, VALUE value)
+{
+#if defined(IPPROTO_IP) && defined(IP_MULTICAST_TTL)
+ VALUE o = XCAT(sockopt_pack_,TYPE_IP_MULTICAST_TTL)(value);
+ return rsock_sockopt_new(AF_INET, IPPROTO_IP, IP_MULTICAST_TTL, o);
+#else
+# error IPPROTO_IP or IP_MULTICAST_TTL is not implemented
+#endif
+}
+
+/*
+ * call-seq:
+ * sockopt.ipv4_multicast_ttl => integer
+ *
+ * Returns the ipv4_multicast_ttl data in _sockopt_ as a integer.
+ *
+ * sockopt = Socket::Option.ipv4_multicast_ttl(10)
+ * p sockopt.ipv4_multicast_ttl => 10
+ */
+static VALUE
+sockopt_ipv4_multicast_ttl(VALUE self)
+{
+ int family = NUM2INT(sockopt_family_m(self));
+ int level = sockopt_level(self);
+ int optname = sockopt_optname(self);
+
+#if defined(IPPROTO_IP) && defined(IP_MULTICAST_TTL)
+ if (family == AF_INET && level == IPPROTO_IP && optname == IP_MULTICAST_TTL) {
+ return XCAT(sockopt_,TYPE_IP_MULTICAST_TTL)(self);
+ }
+#endif
+ rb_raise(rb_eTypeError, "ipv4_multicast_ttl socket option expected");
+ UNREACHABLE;
+}
+
+#define inspect_ipv4_multicast_ttl(a,b,c,d) \
+ XCAT(inspect_,TYPE_IP_MULTICAST_TTL)(a,b,c,d)
+
+static int
+inspect_int(int level, int optname, VALUE data, VALUE ret)
+{
+ if (RSTRING_LEN(data) == sizeof(int)) {
+ int i;
+ memcpy((char*)&i, RSTRING_PTR(data), sizeof(int));
+ rb_str_catf(ret, " %d", i);
+ return 1;
+ }
+ else {
+ return 0;
+ }
+}
+
+#ifdef USE_INSPECT_BYTE
+static int
+inspect_byte(int level, int optname, VALUE data, VALUE ret)
+{
+ if (RSTRING_LEN(data) == sizeof(unsigned char)) {
+ rb_str_catf(ret, " %d", (unsigned char)*RSTRING_PTR(data));
+ return 1;
+ }
+ else {
+ return 0;
+ }
+}
+#endif
+
+static int
+inspect_errno(int level, int optname, VALUE data, VALUE ret)
+{
+ if (RSTRING_LEN(data) == sizeof(int)) {
+ int i;
+ char *err;
+ memcpy((char*)&i, RSTRING_PTR(data), sizeof(int));
+ err = strerror(i);
+ rb_str_catf(ret, " %s (%d)", err, i);
+ return 1;
+ }
+ else {
+ return 0;
+ }
+}
+
+#if defined(IPV6_MULTICAST_LOOP)
+static int
+inspect_uint(int level, int optname, VALUE data, VALUE ret)
+{
+ if (RSTRING_LEN(data) == sizeof(int)) {
+ unsigned int i;
+ memcpy((char*)&i, RSTRING_PTR(data), sizeof(unsigned int));
+ rb_str_catf(ret, " %u", i);
+ return 1;
+ }
+ else {
+ return 0;
+ }
+}
+#endif
+
+#if defined(SOL_SOCKET) && defined(SO_LINGER) /* POSIX */
+static int
+inspect_linger(int level, int optname, VALUE data, VALUE ret)
+{
+ if (RSTRING_LEN(data) == sizeof(struct linger)) {
+ struct linger s;
+ memcpy((char*)&s, RSTRING_PTR(data), sizeof(s));
+ switch (s.l_onoff) {
+ case 0: rb_str_cat2(ret, " off"); break;
+ case 1: rb_str_cat2(ret, " on"); break;
+ default: rb_str_catf(ret, " on(%d)", s.l_onoff); break;
+ }
+ rb_str_catf(ret, " %dsec", s.l_linger);
+ return 1;
+ }
+ else {
+ return 0;
+ }
+}
+#endif
+
+#if defined(SOL_SOCKET) && defined(SO_TYPE) /* POSIX */
+static int
+inspect_socktype(int level, int optname, VALUE data, VALUE ret)
+{
+ if (RSTRING_LEN(data) == sizeof(int)) {
+ int i;
+ ID id;
+ memcpy((char*)&i, RSTRING_PTR(data), sizeof(int));
+ id = rsock_intern_socktype(i);
+ if (id)
+ rb_str_catf(ret, " %s", rb_id2name(id));
+ else
+ rb_str_catf(ret, " %d", i);
+ return 1;
+ }
+ else {
+ return 0;
+ }
+}
+#endif
+
+static int
+inspect_timeval_as_interval(int level, int optname, VALUE data, VALUE ret)
+{
+ if (RSTRING_LEN(data) == sizeof(struct timeval)) {
+ struct timeval s;
+ memcpy((char*)&s, RSTRING_PTR(data), sizeof(s));
+ rb_str_catf(ret, " %ld.%06ldsec", (long)s.tv_sec, (long)s.tv_usec);
+ return 1;
+ }
+ else {
+ return 0;
+ }
+}
+
+/*
+ * socket option for IPv4 multicast is bit confusing.
+ *
+ * IP Multicast is implemented by Steve Deering at first:
+ * IP Multicast Extensions for 4.3BSD UNIX and related systems
+ * (MULTICAST 1.2 Release)
+ * http://www.kohala.com/start/mcast.api.txt
+ *
+ * There are 2 socket options which takes a u_char (unsigned char).
+ *
+ * IP_MULTICAST_TTL
+ * IP_MULTICAST_LOOP
+ *
+ * However Linux and FreeBSD setsockname accepts int argument
+ * as well as u_char.
+ * Their getsockname returns int.
+ *
+ * There are 3 socket options which takes a struct.
+ *
+ * IP_MULTICAST_IF: struct in_addr
+ * IP_ADD_MEMBERSHIP: struct ip_mreq
+ * IP_DROP_MEMBERSHIP: struct ip_mreq
+ *
+ * But they uses an IP address to specify an interface.
+ * This means the API cannot specify an unnumbered interface.
+ *
+ * Linux 2.4 introduces struct ip_mreqn to fix this problem.
+ * struct ip_mreqn has imr_ifindex field to specify interface index.
+ *
+ * IP_MULTICAST_IF: struct ip_mreqn
+ * IP_ADD_MEMBERSHIP: struct ip_mreqn
+ * IP_DROP_MEMBERSHIP: struct ip_mreqn
+ *
+ * FreeBSD 7 obtained struct ip_mreqn for IP_MULTICAST_IF.
+ * http://www.FreeBSD.org/cgi/cvsweb.cgi/src/sys/netinet/in.h.diff?r1=1.99;r2=1.100
+ *
+ * Another hackish workaround is "RFC 1724 hack".
+ * RFC 1724 section 3.3 suggests unnumbered interfaces
+ * specified by pseudo address 0.0.0.0/8.
+ * NetBSD 4 and FreeBSD 5 documented it.
+ * http://cvsweb.netbsd.org/cgi-bin/cvsweb.cgi/src/share/man/man4/ip.4.diff?r1=1.16&r2=1.17
+ * http://www.FreeBSD.org/cgi/cvsweb.cgi/src/share/man/man4/ip.4.diff?r1=1.37;r2=1.38
+ * FreeBSD 7.0 removed it.
+ * http://www.FreeBSD.org/cgi/cvsweb.cgi/src/share/man/man4/ip.4.diff?r1=1.49;r2=1.50
+ *
+ * RFC 1724 hack is not supported by Socket::Option#inspect because
+ * it is not distinguishable by the size.
+ */
+
+#if !defined HAVE_INET_NTOP && ! defined _WIN32
+static const char *
+inet_ntop(int af, const void *addr, char *numaddr, size_t numaddr_len)
+{
+#ifdef HAVE_INET_NTOA
+ struct in_addr in;
+ memcpy(&in.s_addr, addr, sizeof(in.s_addr));
+ snprintf(numaddr, numaddr_len, "%s", inet_ntoa(in));
+#else
+ unsigned long x = ntohl(*(unsigned long*)addr);
+ snprintf(numaddr, numaddr_len, "%d.%d.%d.%d",
+ (int) (x>>24) & 0xff, (int) (x>>16) & 0xff,
+ (int) (x>> 8) & 0xff, (int) (x>> 0) & 0xff);
+#endif
+ return numaddr;
+}
+#elif defined __MINGW32__
+# define inet_ntop(f,a,n,l) rb_w32_inet_ntop(f,a,n,l)
+#elif defined _MSC_VER && RUBY_MSVCRT_VERSION < 90
+const char *WSAAPI inet_ntop(int, const void *, char *, size_t);
+#endif
+
+/* Although the buffer size needed depends on the prefixes, "%u" may generate "4294967295". */
+static int
+rb_if_indextoname(const char *succ_prefix, const char *fail_prefix, unsigned int ifindex, char *buf, size_t len)
+{
+#if defined(HAVE_IF_INDEXTONAME)
+ char ifbuf[IFNAMSIZ];
+ if (if_indextoname(ifindex, ifbuf) == NULL)
+ return snprintf(buf, len, "%s%u", fail_prefix, ifindex);
+ else
+ return snprintf(buf, len, "%s%s", succ_prefix, ifbuf);
+#else
+# ifndef IFNAMSIZ
+# define IFNAMSIZ (sizeof(unsigned int)*3+1)
+# endif
+ return snprintf(buf, len, "%s%u", fail_prefix, ifindex);
+#endif
+}
+
+#if defined(IPPROTO_IP) && defined(HAVE_TYPE_STRUCT_IP_MREQ) /* 4.4BSD, GNU/Linux */
+static int
+inspect_ipv4_mreq(int level, int optname, VALUE data, VALUE ret)
+{
+ if (RSTRING_LEN(data) == sizeof(struct ip_mreq)) {
+ struct ip_mreq s;
+ char addrbuf[INET_ADDRSTRLEN];
+ memcpy((char*)&s, RSTRING_PTR(data), sizeof(s));
+ if (inet_ntop(AF_INET, &s.imr_multiaddr, addrbuf, (socklen_t)sizeof(addrbuf)) == NULL)
+ rb_str_cat2(ret, " invalid-address");
+ else
+ rb_str_catf(ret, " %s", addrbuf);
+ if (inet_ntop(AF_INET, &s.imr_interface, addrbuf, (socklen_t)sizeof(addrbuf)) == NULL)
+ rb_str_catf(ret, " invalid-address");
+ else
+ rb_str_catf(ret, " %s", addrbuf);
+ return 1;
+ }
+ else {
+ return 0;
+ }
+}
+#endif
+
+#if defined(IPPROTO_IP) && defined(HAVE_TYPE_STRUCT_IP_MREQN) /* GNU/Linux, FreeBSD 7 */
+static int
+inspect_ipv4_mreqn(int level, int optname, VALUE data, VALUE ret)
+{
+ if (RSTRING_LEN(data) == sizeof(struct ip_mreqn)) {
+ struct ip_mreqn s;
+ char addrbuf[INET_ADDRSTRLEN], ifbuf[32+IFNAMSIZ];
+ memcpy((char*)&s, RSTRING_PTR(data), sizeof(s));
+ if (inet_ntop(AF_INET, &s.imr_multiaddr, addrbuf, (socklen_t)sizeof(addrbuf)) == NULL)
+ rb_str_cat2(ret, " invalid-address");
+ else
+ rb_str_catf(ret, " %s", addrbuf);
+ if (inet_ntop(AF_INET, &s.imr_address, addrbuf, (socklen_t)sizeof(addrbuf)) == NULL)
+ rb_str_catf(ret, " invalid-address");
+ else
+ rb_str_catf(ret, " %s", addrbuf);
+ rb_if_indextoname(" ", " ifindex:", s.imr_ifindex, ifbuf, sizeof(ifbuf));
+ rb_str_cat2(ret, ifbuf);
+ return 1;
+ }
+ else {
+ return 0;
+ }
+}
+#endif
+
+#if defined(IPPROTO_IP) && defined(HAVE_TYPE_STRUCT_IP_MREQ) /* 4.4BSD, GNU/Linux */
+static int
+inspect_ipv4_add_drop_membership(int level, int optname, VALUE data, VALUE ret)
+{
+ if (RSTRING_LEN(data) == sizeof(struct ip_mreq))
+ return inspect_ipv4_mreq(level, optname, data, ret);
+# if defined(HAVE_TYPE_STRUCT_IP_MREQN)
+ else if (RSTRING_LEN(data) == sizeof(struct ip_mreqn))
+ return inspect_ipv4_mreqn(level, optname, data, ret);
+# endif
+ else
+ return 0;
+}
+#endif
+
+#if defined(IPPROTO_IP) && defined(IP_MULTICAST_IF) && defined(HAVE_TYPE_STRUCT_IP_MREQN) /* 4.4BSD, GNU/Linux */
+static int
+inspect_ipv4_multicast_if(int level, int optname, VALUE data, VALUE ret)
+{
+ if (RSTRING_LEN(data) == sizeof(struct in_addr)) {
+ struct in_addr s;
+ char addrbuf[INET_ADDRSTRLEN];
+ memcpy((char*)&s, RSTRING_PTR(data), sizeof(s));
+ if (inet_ntop(AF_INET, &s, addrbuf, (socklen_t)sizeof(addrbuf)) == NULL)
+ rb_str_cat2(ret, " invalid-address");
+ else
+ rb_str_catf(ret, " %s", addrbuf);
+ return 1;
+ }
+ else if (RSTRING_LEN(data) == sizeof(struct ip_mreqn)) {
+ return inspect_ipv4_mreqn(level, optname, data, ret);
+ }
+ else {
+ return 0;
+ }
+}
+#endif
+
+#if defined(IPV6_MULTICAST_IF) /* POSIX, RFC 3493 */
+static int
+inspect_ipv6_multicast_if(int level, int optname, VALUE data, VALUE ret)
+{
+ if (RSTRING_LEN(data) == sizeof(int)) {
+ char ifbuf[32+IFNAMSIZ];
+ unsigned int ifindex;
+ memcpy((char*)&ifindex, RSTRING_PTR(data), sizeof(unsigned int));
+ rb_if_indextoname(" ", " ", ifindex, ifbuf, sizeof(ifbuf));
+ rb_str_cat2(ret, ifbuf);
+ return 1;
+ }
+ else {
+ return 0;
+ }
+}
+#endif
+
+#if defined(IPPROTO_IPV6) && defined(HAVE_TYPE_STRUCT_IPV6_MREQ) /* POSIX, RFC 3493 */
+static int
+inspect_ipv6_mreq(int level, int optname, VALUE data, VALUE ret)
+{
+ if (RSTRING_LEN(data) == sizeof(struct ipv6_mreq)) {
+ struct ipv6_mreq s;
+ char addrbuf[INET6_ADDRSTRLEN], ifbuf[32+IFNAMSIZ];
+ memcpy((char*)&s, RSTRING_PTR(data), sizeof(s));
+ if (inet_ntop(AF_INET6, &s.ipv6mr_multiaddr, addrbuf, (socklen_t)sizeof(addrbuf)) == NULL)
+ rb_str_cat2(ret, " invalid-address");
+ else
+ rb_str_catf(ret, " %s", addrbuf);
+ rb_if_indextoname(" ", " interface:", s.ipv6mr_interface, ifbuf, sizeof(ifbuf));
+ rb_str_cat2(ret, ifbuf);
+ return 1;
+ }
+ else {
+ return 0;
+ }
+}
+#endif
+
+#if defined(IPPROTO_TCP) && defined(TCP_INFO) && defined(HAVE_TYPE_STRUCT_TCP_INFO)
+
+#ifdef __FreeBSD__
+# ifndef HAVE_CONST_TCP_ESTABLISHED
+# define TCP_ESTABLISHED TCPS_ESTABLISHED
+# endif
+# ifndef HAVE_CONST_TCP_SYN_SENT
+# define TCP_SYN_SENT TCPS_SYN_SENT
+# endif
+# ifndef HAVE_CONST_TCP_SYN_RECV
+# define TCP_SYN_RECV TCPS_SYN_RECEIVED
+# endif
+# ifndef HAVE_CONST_TCP_FIN_WAIT1
+# define TCP_FIN_WAIT1 TCPS_FIN_WAIT_1
+# endif
+# ifndef HAVE_CONST_TCP_FIN_WAIT2
+# define TCP_FIN_WAIT2 TCPS_FIN_WAIT_2
+# endif
+# ifndef HAVE_CONST_TCP_TIME_WAIT
+# define TCP_TIME_WAIT TCPS_TIME_WAIT
+# endif
+# ifndef HAVE_CONST_TCP_CLOSE
+# define TCP_CLOSE TCPS_CLOSED
+# endif
+# ifndef HAVE_CONST_TCP_CLOSE_WAIT
+# define TCP_CLOSE_WAIT TCPS_CLOSE_WAIT
+# endif
+# ifndef HAVE_CONST_TCP_LAST_ACK
+# define TCP_LAST_ACK TCPS_LAST_ACK
+# endif
+# ifndef HAVE_CONST_TCP_LISTEN
+# define TCP_LISTEN TCPS_LISTEN
+# endif
+# ifndef HAVE_CONST_TCP_CLOSING
+# define TCP_CLOSING TCPS_CLOSING
+# endif
+#endif
+
+#if defined(HAVE_CONST_TCP_ESTABLISHED) && !defined(TCP_ESTABLISHED)
+# define TCP_ESTABLISHED TCP_ESTABLISHED
+#endif
+#if defined(HAVE_CONST_TCP_SYN_SENT) && !defined(TCP_SYN_SENT)
+# define TCP_SYN_SENT TCP_SYN_SENT
+#endif
+#if defined(HAVE_CONST_TCP_SYN_RECV) && !defined(TCP_SYN_RECV)
+# define TCP_SYN_RECV TCP_SYN_RECV
+#endif
+#if defined(HAVE_CONST_TCP_FIN_WAIT1) && !defined(TCP_FIN_WAIT1)
+# define TCP_FIN_WAIT1 TCP_FIN_WAIT1
+#endif
+#if defined(HAVE_CONST_TCP_FIN_WAIT2) && !defined(TCP_FIN_WAIT2)
+# define TCP_FIN_WAIT2 TCP_FIN_WAIT2
+#endif
+#if defined(HAVE_CONST_TCP_TIME_WAIT) && !defined(TCP_TIME_WAIT)
+# define TCP_TIME_WAIT TCP_TIME_WAIT
+#endif
+#if defined(HAVE_CONST_TCP_CLOSE) && !defined(TCP_CLOSE)
+# define TCP_CLOSE TCP_CLOSE
+#endif
+#if defined(HAVE_CONST_TCP_CLOSE_WAIT) && !defined(TCP_CLOSE_WAIT)
+# define TCP_CLOSE_WAIT TCP_CLOSE_WAIT
+#endif
+#if defined(HAVE_CONST_TCP_LAST_ACK) && !defined(TCP_LAST_ACK)
+# define TCP_LAST_ACK TCP_LAST_ACK
+#endif
+#if defined(HAVE_CONST_TCP_LISTEN) && !defined(TCP_LISTEN)
+# define TCP_LISTEN TCP_LISTEN
+#endif
+#if defined(HAVE_CONST_TCP_CLOSING) && !defined(TCP_CLOSING)
+# define TCP_CLOSING TCP_CLOSING
+#endif
+
+static void
+inspect_tcpi_options(VALUE ret, uint8_t options)
+{
+ int sep = '=';
+
+ rb_str_cat2(ret, " options");
+#define INSPECT_TCPI_OPTION(optval, name) \
+ if (options & (optval)) { \
+ options &= ~(uint8_t)(optval); \
+ rb_str_catf(ret, "%c%s", sep, name); \
+ sep = ','; \
+ }
+#ifdef TCPI_OPT_TIMESTAMPS /* GNU/Linux, FreeBSD */
+ INSPECT_TCPI_OPTION(TCPI_OPT_TIMESTAMPS, "TIMESTAMPS");
+#endif
+#ifdef TCPI_OPT_SACK /* GNU/Linux, FreeBSD */
+ INSPECT_TCPI_OPTION(TCPI_OPT_SACK, "SACK");
+#endif
+#ifdef TCPI_OPT_WSCALE /* GNU/Linux, FreeBSD */
+ INSPECT_TCPI_OPTION(TCPI_OPT_WSCALE, "WSCALE");
+#endif
+#ifdef TCPI_OPT_ECN /* GNU/Linux, FreeBSD */
+ INSPECT_TCPI_OPTION(TCPI_OPT_ECN, "ECN");
+#endif
+#ifdef TCPI_OPT_ECN_SEEN /* GNU/Linux */
+ INSPECT_TCPI_OPTION(TCPI_OPT_ECN_SEEN, "ECN_SEEN");
+#endif
+#ifdef TCPI_OPT_SYN_DATA /* GNU/Linux */
+ INSPECT_TCPI_OPTION(TCPI_OPT_SYN_DATA, "SYN_DATA");
+#endif
+#ifdef TCPI_OPT_TOE /* FreeBSD */
+ INSPECT_TCPI_OPTION(TCPI_OPT_TOE, "TOE");
+#endif
+#undef INSPECT_TCPI_OPTION
+
+ if (options || sep == '=') {
+ rb_str_catf(ret, "%c%u", sep, options);
+ }
+}
+
+static void
+inspect_tcpi_usec(VALUE ret, const char *prefix, uint32_t t)
+{
+ rb_str_catf(ret, "%s%u.%06us", prefix, t / 1000000, t % 1000000);
+}
+
+#if defined(__linux__) || defined(__sun)
+static void
+inspect_tcpi_msec(VALUE ret, const char *prefix, uint32_t t)
+{
+ rb_str_catf(ret, "%s%u.%03us", prefix, t / 1000, t % 1000);
+}
+#endif
+
+#ifdef __FreeBSD__
+# define inspect_tcpi_rto(ret, t) inspect_tcpi_usec(ret, " rto=", t)
+# define inspect_tcpi_last_data_recv(ret, t) inspect_tcpi_usec(ret, " last_data_recv=", t)
+# define inspect_tcpi_rtt(ret, t) inspect_tcpi_usec(ret, " rtt=", t)
+# define inspect_tcpi_rttvar(ret, t) inspect_tcpi_usec(ret, " rttvar=", t)
+#else
+# define inspect_tcpi_rto(ret, t) inspect_tcpi_usec(ret, " rto=", t)
+# define inspect_tcpi_ato(ret, t) inspect_tcpi_usec(ret, " ato=", t)
+# define inspect_tcpi_last_data_sent(ret, t) inspect_tcpi_msec(ret, " last_data_sent=", t)
+# define inspect_tcpi_last_data_recv(ret, t) inspect_tcpi_msec(ret, " last_data_recv=", t)
+# define inspect_tcpi_last_ack_sent(ret, t) inspect_tcpi_msec(ret, " last_ack_sent=", t)
+# define inspect_tcpi_last_ack_recv(ret, t) inspect_tcpi_msec(ret, " last_ack_recv=", t)
+# define inspect_tcpi_rtt(ret, t) inspect_tcpi_usec(ret, " rtt=", t)
+# define inspect_tcpi_rttvar(ret, t) inspect_tcpi_usec(ret, " rttvar=", t)
+# define inspect_tcpi_rcv_rtt(ret, t) inspect_tcpi_usec(ret, " rcv_rtt=", t)
+#endif
+
+static int
+inspect_tcp_info(int level, int optname, VALUE data, VALUE ret)
+{
+ size_t actual_size = RSTRING_LEN(data);
+ if (sizeof(struct tcp_info) <= actual_size) {
+ struct tcp_info s;
+ memcpy((char*)&s, RSTRING_PTR(data), sizeof(s));
+#ifdef HAVE_STRUCT_TCP_INFO_TCPI_STATE
+ switch (s.tcpi_state) {
+# ifdef TCP_ESTABLISHED
+ case TCP_ESTABLISHED: rb_str_cat_cstr(ret, " state=ESTABLISHED"); break;
+# endif
+# ifdef TCP_SYN_SENT
+ case TCP_SYN_SENT: rb_str_cat_cstr(ret, " state=SYN_SENT"); break;
+# endif
+# ifdef TCP_SYN_RECV
+ case TCP_SYN_RECV: rb_str_cat_cstr(ret, " state=SYN_RECV"); break;
+# endif
+# ifdef TCP_FIN_WAIT1
+ case TCP_FIN_WAIT1: rb_str_cat_cstr(ret, " state=FIN_WAIT1"); break;
+# endif
+# ifdef TCP_FIN_WAIT2
+ case TCP_FIN_WAIT2: rb_str_cat_cstr(ret, " state=FIN_WAIT2"); break;
+# endif
+# ifdef TCP_TIME_WAIT
+ case TCP_TIME_WAIT: rb_str_cat_cstr(ret, " state=TIME_WAIT"); break;
+# endif
+# ifdef TCP_CLOSE
+ case TCP_CLOSE: rb_str_cat_cstr(ret, " state=CLOSED"); break; /* RFC 793 uses "CLOSED", not "CLOSE" */
+# endif
+# ifdef TCP_CLOSE_WAIT
+ case TCP_CLOSE_WAIT: rb_str_cat_cstr(ret, " state=CLOSE_WAIT"); break;
+# endif
+# ifdef TCP_LAST_ACK
+ case TCP_LAST_ACK: rb_str_cat_cstr(ret, " state=LAST_ACK"); break;
+# endif
+# ifdef TCP_LISTEN
+ case TCP_LISTEN: rb_str_cat_cstr(ret, " state=LISTEN"); break;
+# endif
+# ifdef TCP_CLOSING
+ case TCP_CLOSING: rb_str_cat_cstr(ret, " state=CLOSING"); break;
+# endif
+ default: rb_str_catf(ret, " state=%u", s.tcpi_state); break;
+ }
+#endif
+#ifdef HAVE_STRUCT_TCP_INFO_TCPI_CA_STATE
+ switch (s.tcpi_ca_state) {
+ case TCP_CA_Open: rb_str_cat_cstr(ret, " ca_state=Open"); break;
+ case TCP_CA_Disorder: rb_str_cat_cstr(ret, " ca_state=Disorder"); break;
+ case TCP_CA_CWR: rb_str_cat_cstr(ret, " ca_state=CWR"); break;
+ case TCP_CA_Recovery: rb_str_cat_cstr(ret, " ca_state=Recovery"); break;
+ case TCP_CA_Loss: rb_str_cat_cstr(ret, " ca_state=Loss"); break;
+ default: rb_str_catf(ret, " ca_state=%u", s.tcpi_ca_state); break;
+ }
+#endif
+#ifdef HAVE_STRUCT_TCP_INFO_TCPI_RETRANSMITS
+ rb_str_catf(ret, " retransmits=%u", s.tcpi_retransmits);
+#endif
+#ifdef HAVE_STRUCT_TCP_INFO_TCPI_PROBES
+ rb_str_catf(ret, " probes=%u", s.tcpi_probes);
+#endif
+#ifdef HAVE_STRUCT_TCP_INFO_TCPI_BACKOFF
+ rb_str_catf(ret, " backoff=%u", s.tcpi_backoff);
+#endif
+#ifdef HAVE_STRUCT_TCP_INFO_TCPI_OPTIONS
+ inspect_tcpi_options(ret, s.tcpi_options);
+#endif
+#ifdef HAVE_STRUCT_TCP_INFO_TCPI_SND_WSCALE
+ rb_str_catf(ret, " snd_wscale=%u", s.tcpi_snd_wscale);
+#endif
+#ifdef HAVE_STRUCT_TCP_INFO_TCPI_RCV_WSCALE
+ rb_str_catf(ret, " rcv_wscale=%u", s.tcpi_rcv_wscale);
+#endif
+#ifdef HAVE_STRUCT_TCP_INFO_TCPI_RTO
+ inspect_tcpi_rto(ret, s.tcpi_rto);
+#endif
+#ifdef HAVE_STRUCT_TCP_INFO_TCPI_ATO
+ inspect_tcpi_ato(ret, s.tcpi_ato);
+#endif
+#ifdef HAVE_STRUCT_TCP_INFO_TCPI_SND_MSS
+ rb_str_catf(ret, " snd_mss=%u", s.tcpi_snd_mss);
+#endif
+#ifdef HAVE_STRUCT_TCP_INFO_TCPI_RCV_MSS
+ rb_str_catf(ret, " rcv_mss=%u", s.tcpi_rcv_mss);
+#endif
+#ifdef HAVE_STRUCT_TCP_INFO_TCPI_UNACKED
+ rb_str_catf(ret, " unacked=%u", s.tcpi_unacked);
+#endif
+#ifdef HAVE_STRUCT_TCP_INFO_TCPI_SACKED
+ rb_str_catf(ret, " sacked=%u", s.tcpi_sacked);
+#endif
+#ifdef HAVE_STRUCT_TCP_INFO_TCPI_LOST
+ rb_str_catf(ret, " lost=%u", s.tcpi_lost);
+#endif
+#ifdef HAVE_STRUCT_TCP_INFO_TCPI_RETRANS
+ rb_str_catf(ret, " retrans=%u", s.tcpi_retrans);
+#endif
+#ifdef HAVE_STRUCT_TCP_INFO_TCPI_FACKETS
+ rb_str_catf(ret, " fackets=%u", s.tcpi_fackets);
+#endif
+#ifdef HAVE_STRUCT_TCP_INFO_TCPI_LAST_DATA_SENT
+ inspect_tcpi_last_data_sent(ret, s.tcpi_last_data_sent);
+#endif
+#ifdef HAVE_STRUCT_TCP_INFO_TCPI_LAST_ACK_SENT
+ inspect_tcpi_last_ack_sent(ret, s.tcpi_last_ack_sent);
+#endif
+#ifdef HAVE_STRUCT_TCP_INFO_TCPI_LAST_DATA_RECV
+ inspect_tcpi_last_data_recv(ret, s.tcpi_last_data_recv);
+#endif
+#ifdef HAVE_STRUCT_TCP_INFO_TCPI_LAST_ACK_RECV
+ inspect_tcpi_last_ack_recv(ret, s.tcpi_last_ack_recv);
+#endif
+#ifdef HAVE_STRUCT_TCP_INFO_TCPI_PMTU
+ rb_str_catf(ret, " pmtu=%u", s.tcpi_pmtu);
+#endif
+#ifdef HAVE_STRUCT_TCP_INFO_TCPI_RCV_SSTHRESH
+ rb_str_catf(ret, " rcv_ssthresh=%u", s.tcpi_rcv_ssthresh);
+#endif
+#ifdef HAVE_STRUCT_TCP_INFO_TCPI_RTT
+ inspect_tcpi_rtt(ret, s.tcpi_rtt);
+#endif
+#ifdef HAVE_STRUCT_TCP_INFO_TCPI_RTTVAR
+ inspect_tcpi_rttvar(ret, s.tcpi_rttvar);
+#endif
+#ifdef HAVE_STRUCT_TCP_INFO_TCPI_SND_SSTHRESH
+ rb_str_catf(ret, " snd_ssthresh=%u", s.tcpi_snd_ssthresh);
+#endif
+#ifdef HAVE_STRUCT_TCP_INFO_TCPI_SND_CWND
+ rb_str_catf(ret, " snd_cwnd=%u", s.tcpi_snd_cwnd);
+#endif
+#ifdef HAVE_STRUCT_TCP_INFO_TCPI_ADVMSS
+ rb_str_catf(ret, " advmss=%u", s.tcpi_advmss);
+#endif
+#ifdef HAVE_STRUCT_TCP_INFO_TCPI_REORDERING
+ rb_str_catf(ret, " reordering=%u", s.tcpi_reordering);
+#endif
+#ifdef HAVE_STRUCT_TCP_INFO_TCPI_RCV_RTT
+ inspect_tcpi_rcv_rtt(ret, s.tcpi_rcv_rtt);
+#endif
+#ifdef HAVE_STRUCT_TCP_INFO_TCPI_RCV_SPACE
+ rb_str_catf(ret, " rcv_space=%u", s.tcpi_rcv_space);
+#endif
+#ifdef HAVE_STRUCT_TCP_INFO_TCPI_TOTAL_RETRANS
+ rb_str_catf(ret, " total_retrans=%u", s.tcpi_total_retrans);
+#endif
+#ifdef HAVE_STRUCT_TCP_INFO_TCPI_SND_WND
+ rb_str_catf(ret, " snd_wnd=%u", s.tcpi_snd_wnd); /* FreeBSD */
+#endif
+#ifdef HAVE_STRUCT_TCP_INFO_TCPI_SND_BWND
+ rb_str_catf(ret, " snd_bwnd=%u", s.tcpi_snd_bwnd); /* FreeBSD */
+#endif
+#ifdef HAVE_STRUCT_TCP_INFO_TCPI_SND_NXT
+ rb_str_catf(ret, " snd_nxt=%u", s.tcpi_snd_nxt); /* FreeBSD */
+#endif
+#ifdef HAVE_STRUCT_TCP_INFO_TCPI_RCV_NXT
+ rb_str_catf(ret, " rcv_nxt=%u", s.tcpi_rcv_nxt); /* FreeBSD */
+#endif
+#ifdef HAVE_STRUCT_TCP_INFO_TCPI_TOE_TID
+ rb_str_catf(ret, " toe_tid=%u", s.tcpi_toe_tid); /* FreeBSD */
+#endif
+#ifdef HAVE_STRUCT_TCP_INFO_TCPI_SND_REXMITPACK
+ rb_str_catf(ret, " snd_rexmitpack=%u", s.tcpi_snd_rexmitpack); /* FreeBSD */
+#endif
+#ifdef HAVE_STRUCT_TCP_INFO_TCPI_RCV_OOOPACK
+ rb_str_catf(ret, " rcv_ooopack=%u", s.tcpi_rcv_ooopack); /* FreeBSD */
+#endif
+#ifdef HAVE_STRUCT_TCP_INFO_TCPI_SND_ZEROWIN
+ rb_str_catf(ret, " snd_zerowin=%u", s.tcpi_snd_zerowin); /* FreeBSD */
+#endif
+ if (sizeof(struct tcp_info) < actual_size)
+ rb_str_catf(ret, " (%u bytes too long)", (unsigned)(actual_size - sizeof(struct tcp_info)));
+ return 1;
+ }
+ else {
+ return 0;
+ }
+}
+#endif
+
+#if defined(SOL_SOCKET) && defined(SO_PEERCRED) /* GNU/Linux, OpenBSD */
+#if defined(__OpenBSD__)
+#define RUBY_SOCK_PEERCRED struct sockpeercred
+#else
+#define RUBY_SOCK_PEERCRED struct ucred
+#endif
+static int
+inspect_peercred(int level, int optname, VALUE data, VALUE ret)
+{
+ if (RSTRING_LEN(data) == sizeof(RUBY_SOCK_PEERCRED)) {
+ RUBY_SOCK_PEERCRED cred;
+ memcpy(&cred, RSTRING_PTR(data), sizeof(RUBY_SOCK_PEERCRED));
+ rb_str_catf(ret, " pid=%u euid=%u egid=%u",
+ (unsigned)cred.pid, (unsigned)cred.uid, (unsigned)cred.gid);
+ rb_str_cat2(ret, " (ucred)");
+ return 1;
+ }
+ else {
+ return 0;
+ }
+}
+#endif
+
+#if defined(LOCAL_PEERCRED) /* FreeBSD, MacOS X */
+static int
+inspect_local_peercred(int level, int optname, VALUE data, VALUE ret)
+{
+ if (RSTRING_LEN(data) == sizeof(struct xucred)) {
+ struct xucred cred;
+ memcpy(&cred, RSTRING_PTR(data), sizeof(struct xucred));
+ if (cred.cr_version != XUCRED_VERSION)
+ return 0;
+ rb_str_catf(ret, " version=%u", cred.cr_version);
+ rb_str_catf(ret, " euid=%u", cred.cr_uid);
+ if (cred.cr_ngroups) {
+ int i;
+ const char *sep = " groups=";
+ for (i = 0; i < cred.cr_ngroups; i++) {
+ rb_str_catf(ret, "%s%u", sep, cred.cr_groups[i]);
+ sep = ",";
+ }
+ }
+ rb_str_cat2(ret, " (xucred)");
+ return 1;
+ }
+ else {
+ return 0;
+ }
+}
+#endif
+
+
+/*
+ * call-seq:
+ * sockopt.inspect => string
+ *
+ * Returns a string which shows sockopt in human-readable form.
+ *
+ * p Socket::Option.new(:INET, :SOCKET, :KEEPALIVE, [1].pack("i")).inspect
+ * #=> "#<Socket::Option: INET SOCKET KEEPALIVE 1>"
+ *
+ */
+static VALUE
+sockopt_inspect(VALUE self)
+{
+ int family = NUM2INT(sockopt_family_m(self));
+ int level = NUM2INT(sockopt_level_m(self));
+ int optname = NUM2INT(sockopt_optname_m(self));
+ VALUE data = sockopt_data(self);
+ VALUE v, ret;
+ ID family_id, level_id, optname_id;
+ int inspected;
+
+ StringValue(data);
+
+ ret = rb_sprintf("#<%s:", rb_obj_classname(self));
+
+ family_id = rsock_intern_family_noprefix(family);
+ if (family_id)
+ rb_str_catf(ret, " %s", rb_id2name(family_id));
+ else
+ rb_str_catf(ret, " family:%d", family);
+
+ if (level == SOL_SOCKET) {
+ rb_str_cat2(ret, " SOCKET");
+
+ optname_id = rsock_intern_so_optname(optname);
+ if (optname_id)
+ rb_str_catf(ret, " %s", rb_id2name(optname_id));
+ else
+ rb_str_catf(ret, " optname:%d", optname);
+ }
+#ifdef HAVE_SYS_UN_H
+ else if (family == AF_UNIX) {
+ rb_str_catf(ret, " level:%d", level);
+
+ optname_id = rsock_intern_local_optname(optname);
+ if (optname_id)
+ rb_str_catf(ret, " %s", rb_id2name(optname_id));
+ else
+ rb_str_catf(ret, " optname:%d", optname);
+ }
+#endif
+ else if (IS_IP_FAMILY(family)) {
+ level_id = rsock_intern_iplevel(level);
+ if (level_id)
+ rb_str_catf(ret, " %s", rb_id2name(level_id));
+ else
+ rb_str_catf(ret, " level:%d", level);
+
+ v = optname_to_sym(level, optname);
+ if (SYMBOL_P(v))
+ rb_str_catf(ret, " %s", rb_id2name(SYM2ID(v)));
+ else
+ rb_str_catf(ret, " optname:%d", optname);
+ }
+ else {
+ rb_str_catf(ret, " level:%d", level);
+ rb_str_catf(ret, " optname:%d", optname);
+ }
+
+ inspected = 0;
+
+ if (level == SOL_SOCKET)
+ family = AF_UNSPEC;
+ switch (family) {
+ case AF_UNSPEC:
+ switch (level) {
+ case SOL_SOCKET:
+ switch (optname) {
+# if defined(SO_DEBUG) /* POSIX */
+ case SO_DEBUG: inspected = inspect_int(level, optname, data, ret); break;
+# endif
+# if defined(SO_ERROR) /* POSIX */
+ case SO_ERROR: inspected = inspect_errno(level, optname, data, ret); break;
+# endif
+# if defined(SO_TYPE) /* POSIX */
+ case SO_TYPE: inspected = inspect_socktype(level, optname, data, ret); break;
+# endif
+# if defined(SO_ACCEPTCONN) /* POSIX */
+ case SO_ACCEPTCONN: inspected = inspect_int(level, optname, data, ret); break;
+# endif
+# if defined(SO_BROADCAST) /* POSIX */
+ case SO_BROADCAST: inspected = inspect_int(level, optname, data, ret); break;
+# endif
+# if defined(SO_REUSEADDR) /* POSIX */
+ case SO_REUSEADDR: inspected = inspect_int(level, optname, data, ret); break;
+# endif
+# if defined(SO_KEEPALIVE) /* POSIX */
+ case SO_KEEPALIVE: inspected = inspect_int(level, optname, data, ret); break;
+# endif
+# if defined(SO_OOBINLINE) /* POSIX */
+ case SO_OOBINLINE: inspected = inspect_int(level, optname, data, ret); break;
+# endif
+# if defined(SO_SNDBUF) /* POSIX */
+ case SO_SNDBUF: inspected = inspect_int(level, optname, data, ret); break;
+# endif
+# if defined(SO_RCVBUF) /* POSIX */
+ case SO_RCVBUF: inspected = inspect_int(level, optname, data, ret); break;
+# endif
+# if defined(SO_DONTROUTE) /* POSIX */
+ case SO_DONTROUTE: inspected = inspect_int(level, optname, data, ret); break;
+# endif
+# if defined(SO_RCVLOWAT) /* POSIX */
+ case SO_RCVLOWAT: inspected = inspect_int(level, optname, data, ret); break;
+# endif
+# if defined(SO_SNDLOWAT) /* POSIX */
+ case SO_SNDLOWAT: inspected = inspect_int(level, optname, data, ret); break;
+# endif
+# if defined(SO_LINGER) /* POSIX */
+ case SO_LINGER: inspected = inspect_linger(level, optname, data, ret); break;
+# endif
+# if defined(SO_RCVTIMEO) /* POSIX */
+ case SO_RCVTIMEO: inspected = inspect_timeval_as_interval(level, optname, data, ret); break;
+# endif
+# if defined(SO_SNDTIMEO) /* POSIX */
+ case SO_SNDTIMEO: inspected = inspect_timeval_as_interval(level, optname, data, ret); break;
+# endif
+# if defined(SO_PEERCRED) /* GNU/Linux, OpenBSD */
+ case SO_PEERCRED: inspected = inspect_peercred(level, optname, data, ret); break;
+# endif
+ }
+ break;
+ }
+ break;
+
+ case AF_INET:
+#ifdef INET6
+ case AF_INET6:
+#endif
+ switch (level) {
+# if defined(IPPROTO_IP)
+ case IPPROTO_IP:
+ switch (optname) {
+# if defined(IP_MULTICAST_IF) && defined(HAVE_TYPE_STRUCT_IP_MREQN) /* 4.4BSD, GNU/Linux */
+ case IP_MULTICAST_IF: inspected = inspect_ipv4_multicast_if(level, optname, data, ret); break;
+# endif
+# if defined(IP_ADD_MEMBERSHIP) /* 4.4BSD, GNU/Linux */
+ case IP_ADD_MEMBERSHIP: inspected = inspect_ipv4_add_drop_membership(level, optname, data, ret); break;
+# endif
+# if defined(IP_DROP_MEMBERSHIP) /* 4.4BSD, GNU/Linux */
+ case IP_DROP_MEMBERSHIP: inspected = inspect_ipv4_add_drop_membership(level, optname, data, ret); break;
+# endif
+# if defined(IP_MULTICAST_LOOP) /* 4.4BSD, GNU/Linux */
+ case IP_MULTICAST_LOOP: inspected = inspect_ipv4_multicast_loop(level, optname, data, ret); break;
+# endif
+# if defined(IP_MULTICAST_TTL) /* 4.4BSD, GNU/Linux */
+ case IP_MULTICAST_TTL: inspected = inspect_ipv4_multicast_ttl(level, optname, data, ret); break;
+# endif
+ }
+ break;
+# endif
+
+# if defined(IPPROTO_IPV6)
+ case IPPROTO_IPV6:
+ switch (optname) {
+# if defined(IPV6_MULTICAST_HOPS) /* POSIX */
+ case IPV6_MULTICAST_HOPS: inspected = inspect_int(level, optname, data, ret); break;
+# endif
+# if defined(IPV6_MULTICAST_IF) /* POSIX */
+ case IPV6_MULTICAST_IF: inspected = inspect_ipv6_multicast_if(level, optname, data, ret); break;
+# endif
+# if defined(IPV6_MULTICAST_LOOP) /* POSIX */
+ case IPV6_MULTICAST_LOOP: inspected = inspect_uint(level, optname, data, ret); break;
+# endif
+# if defined(IPV6_JOIN_GROUP) /* POSIX */
+ case IPV6_JOIN_GROUP: inspected = inspect_ipv6_mreq(level, optname, data, ret); break;
+# endif
+# if defined(IPV6_LEAVE_GROUP) /* POSIX */
+ case IPV6_LEAVE_GROUP: inspected = inspect_ipv6_mreq(level, optname, data, ret); break;
+# endif
+# if defined(IPV6_UNICAST_HOPS) /* POSIX */
+ case IPV6_UNICAST_HOPS: inspected = inspect_int(level, optname, data, ret); break;
+# endif
+# if defined(IPV6_V6ONLY) /* POSIX */
+ case IPV6_V6ONLY: inspected = inspect_int(level, optname, data, ret); break;
+# endif
+ }
+ break;
+# endif
+
+# if defined(IPPROTO_TCP)
+ case IPPROTO_TCP:
+ switch (optname) {
+# if defined(TCP_NODELAY) /* POSIX */
+ case TCP_NODELAY: inspected = inspect_int(level, optname, data, ret); break;
+# endif
+# if defined(TCP_INFO) && defined(HAVE_TYPE_STRUCT_TCP_INFO) /* Linux, FreeBSD */
+ case TCP_INFO: inspected = inspect_tcp_info(level, optname, data, ret); break;
+# endif
+ }
+ break;
+# endif
+ }
+ break;
+
+#ifdef HAVE_SYS_UN_H
+ case AF_UNIX:
+ switch (level) {
+ case 0:
+ switch (optname) {
+# if defined(LOCAL_PEERCRED)
+ case LOCAL_PEERCRED: inspected = inspect_local_peercred(level, optname, data, ret); break;
+# endif
+ }
+ break;
+ }
+ break;
+#endif
+ }
+
+ if (!inspected) {
+ rb_str_cat2(ret, " ");
+ rb_str_append(ret, rb_str_dump(data));
+ }
+
+ rb_str_cat2(ret, ">");
+
+ return ret;
+}
+
+/*
+ * call-seq:
+ * sockopt.unpack(template) => array
+ *
+ * Calls String#unpack on sockopt.data.
+ *
+ * sockopt = Socket::Option.new(:INET, :SOCKET, :KEEPALIVE, [1].pack("i"))
+ * p sockopt.unpack("i") #=> [1]
+ * p sockopt.data.unpack("i") #=> [1]
+ */
+static VALUE
+sockopt_unpack(VALUE self, VALUE template)
+{
+ return rb_funcall(sockopt_data(self), rb_intern("unpack"), 1, template);
+}
+
+void
+rsock_init_sockopt(void)
+{
+ /*
+ * Document-class: Socket::Option
+ *
+ * Socket::Option represents a socket option used by
+ * BasicSocket#getsockopt and BasicSocket#setsockopt. A socket option
+ * contains the socket #family, protocol #level, option name #optname and
+ * option value #data.
+ */
+ rb_cSockOpt = rb_define_class_under(rb_cSocket, "Option", rb_cObject);
+ rb_define_method(rb_cSockOpt, "initialize", sockopt_initialize, 4);
+ rb_define_method(rb_cSockOpt, "family", sockopt_family_m, 0);
+ rb_define_method(rb_cSockOpt, "level", sockopt_level_m, 0);
+ rb_define_method(rb_cSockOpt, "optname", sockopt_optname_m, 0);
+ rb_define_method(rb_cSockOpt, "data", sockopt_data, 0);
+ rb_define_method(rb_cSockOpt, "inspect", sockopt_inspect, 0);
+
+ rb_define_singleton_method(rb_cSockOpt, "int", sockopt_s_int, 4);
+ rb_define_method(rb_cSockOpt, "int", sockopt_int, 0);
+
+ rb_define_singleton_method(rb_cSockOpt, "byte", sockopt_s_byte, 4);
+ rb_define_method(rb_cSockOpt, "byte", sockopt_byte, 0);
+
+ rb_define_singleton_method(rb_cSockOpt, "bool", sockopt_s_bool, 4);
+ rb_define_method(rb_cSockOpt, "bool", sockopt_bool, 0);
+
+ rb_define_singleton_method(rb_cSockOpt, "linger", sockopt_s_linger, 2);
+ rb_define_method(rb_cSockOpt, "linger", sockopt_linger, 0);
+
+ rb_define_singleton_method(rb_cSockOpt, "ipv4_multicast_ttl", sockopt_s_ipv4_multicast_ttl, 1);
+ rb_define_method(rb_cSockOpt, "ipv4_multicast_ttl", sockopt_ipv4_multicast_ttl, 0);
+
+ rb_define_singleton_method(rb_cSockOpt, "ipv4_multicast_loop", sockopt_s_ipv4_multicast_loop, 1);
+ rb_define_method(rb_cSockOpt, "ipv4_multicast_loop", sockopt_ipv4_multicast_loop, 0);
+
+ rb_define_method(rb_cSockOpt, "unpack", sockopt_unpack, 1);
+
+ rb_define_method(rb_cSockOpt, "to_s", sockopt_data, 0); /* compatibility for ruby before 1.9.2 */
+}
+
diff --git a/jni/ruby/ext/socket/raddrinfo.c b/jni/ruby/ext/socket/raddrinfo.c
new file mode 100644
index 0000000..caa08fe
--- /dev/null
+++ b/jni/ruby/ext/socket/raddrinfo.c
@@ -0,0 +1,2575 @@
+/************************************************
+
+ raddrinfo.c -
+
+ created at: Thu Mar 31 12:21:29 JST 1994
+
+ Copyright (C) 1993-2007 Yukihiro Matsumoto
+
+************************************************/
+
+#include "rubysocket.h"
+
+#if defined(INET6) && (defined(LOOKUP_ORDER_HACK_INET) || defined(LOOKUP_ORDER_HACK_INET6))
+#define LOOKUP_ORDERS (sizeof(lookup_order_table) / sizeof(lookup_order_table[0]))
+static const int lookup_order_table[] = {
+#if defined(LOOKUP_ORDER_HACK_INET)
+ PF_INET, PF_INET6, PF_UNSPEC,
+#elif defined(LOOKUP_ORDER_HACK_INET6)
+ PF_INET6, PF_INET, PF_UNSPEC,
+#else
+ /* should not happen */
+#endif
+};
+
+static int
+ruby_getaddrinfo(const char *nodename, const char *servname,
+ const struct addrinfo *hints, struct addrinfo **res)
+{
+ struct addrinfo tmp_hints;
+ int i, af, error;
+
+ if (hints->ai_family != PF_UNSPEC) {
+ return getaddrinfo(nodename, servname, hints, res);
+ }
+
+ for (i = 0; i < LOOKUP_ORDERS; i++) {
+ af = lookup_order_table[i];
+ MEMCPY(&tmp_hints, hints, struct addrinfo, 1);
+ tmp_hints.ai_family = af;
+ error = getaddrinfo(nodename, servname, &tmp_hints, res);
+ if (error) {
+ if (tmp_hints.ai_family == PF_UNSPEC) {
+ break;
+ }
+ }
+ else {
+ break;
+ }
+ }
+
+ return error;
+}
+#define getaddrinfo(node,serv,hints,res) ruby_getaddrinfo((node),(serv),(hints),(res))
+#endif
+
+#if defined(_AIX)
+static int
+ruby_getaddrinfo__aix(const char *nodename, const char *servname,
+ const struct addrinfo *hints, struct addrinfo **res)
+{
+ int error = getaddrinfo(nodename, servname, hints, res);
+ struct addrinfo *r;
+ if (error)
+ return error;
+ for (r = *res; r != NULL; r = r->ai_next) {
+ if (r->ai_addr->sa_family == 0)
+ r->ai_addr->sa_family = r->ai_family;
+ if (r->ai_addr->sa_len == 0)
+ r->ai_addr->sa_len = r->ai_addrlen;
+ }
+ return 0;
+}
+#undef getaddrinfo
+#define getaddrinfo(node,serv,hints,res) ruby_getaddrinfo__aix((node),(serv),(hints),(res))
+static int
+ruby_getnameinfo__aix(const struct sockaddr *sa, size_t salen,
+ char *host, size_t hostlen,
+ char *serv, size_t servlen, int flags)
+{
+ struct sockaddr_in6 *sa6;
+ u_int32_t *a6;
+
+ if (sa->sa_family == AF_INET6) {
+ sa6 = (struct sockaddr_in6 *)sa;
+ a6 = sa6->sin6_addr.u6_addr.u6_addr32;
+
+ if (a6[0] == 0 && a6[1] == 0 && a6[2] == 0 && a6[3] == 0) {
+ strncpy(host, "::", hostlen);
+ snprintf(serv, servlen, "%d", sa6->sin6_port);
+ return 0;
+ }
+ }
+ return getnameinfo(sa, salen, host, hostlen, serv, servlen, flags);
+}
+#undef getnameinfo
+#define getnameinfo(sa, salen, host, hostlen, serv, servlen, flags) \
+ ruby_getnameinfo__aix((sa), (salen), (host), (hostlen), (serv), (servlen), (flags))
+#endif
+
+static int str_is_number(const char *);
+
+#if defined(__APPLE__)
+static int
+ruby_getaddrinfo__darwin(const char *nodename, const char *servname,
+ const struct addrinfo *hints, struct addrinfo **res)
+{
+ /* fix [ruby-core:29427] */
+ const char *tmp_servname;
+ struct addrinfo tmp_hints;
+ int error;
+
+ tmp_servname = servname;
+ MEMCPY(&tmp_hints, hints, struct addrinfo, 1);
+ if (nodename && servname) {
+ if (str_is_number(tmp_servname) && atoi(servname) == 0) {
+ tmp_servname = NULL;
+#ifdef AI_NUMERICSERV
+ if (tmp_hints.ai_flags) tmp_hints.ai_flags &= ~AI_NUMERICSERV;
+#endif
+ }
+ }
+
+ error = getaddrinfo(nodename, tmp_servname, &tmp_hints, res);
+ if (error == 0) {
+ /* [ruby-dev:23164] */
+ struct addrinfo *r;
+ r = *res;
+ while (r) {
+ if (! r->ai_socktype) r->ai_socktype = hints->ai_socktype;
+ if (! r->ai_protocol) {
+ if (r->ai_socktype == SOCK_DGRAM) {
+ r->ai_protocol = IPPROTO_UDP;
+ }
+ else if (r->ai_socktype == SOCK_STREAM) {
+ r->ai_protocol = IPPROTO_TCP;
+ }
+ }
+ r = r->ai_next;
+ }
+ }
+
+ return error;
+}
+#undef getaddrinfo
+#define getaddrinfo(node,serv,hints,res) ruby_getaddrinfo__darwin((node),(serv),(hints),(res))
+#endif
+
+#ifndef GETADDRINFO_EMU
+struct getaddrinfo_arg
+{
+ const char *node;
+ const char *service;
+ const struct addrinfo *hints;
+ struct addrinfo **res;
+};
+
+static void *
+nogvl_getaddrinfo(void *arg)
+{
+ int ret;
+ struct getaddrinfo_arg *ptr = arg;
+ ret = getaddrinfo(ptr->node, ptr->service, ptr->hints, ptr->res);
+#ifdef __linux__
+ /* On Linux (mainly Ubuntu 13.04) /etc/nsswitch.conf has mdns4 and
+ * it cause getaddrinfo to return EAI_SYSTEM/ENOENT. [ruby-list:49420]
+ */
+ if (ret == EAI_SYSTEM && errno == ENOENT)
+ ret = EAI_NONAME;
+#endif
+ return (void *)(VALUE)ret;
+}
+#endif
+
+static int
+numeric_getaddrinfo(const char *node, const char *service,
+ const struct addrinfo *hints,
+ struct addrinfo **res)
+{
+#ifdef HAVE_INET_PTON
+# if defined __MINGW64__
+# define inet_pton(f,s,d) rb_w32_inet_pton(f,s,d)
+# endif
+
+ if (node && (!service || strspn(service, "0123456789") == strlen(service))) {
+ static const struct {
+ int socktype;
+ int protocol;
+ } list[] = {
+ { SOCK_STREAM, IPPROTO_TCP },
+ { SOCK_DGRAM, IPPROTO_UDP },
+ { SOCK_RAW, 0 }
+ };
+ struct addrinfo *ai = NULL;
+ int port = service ? (unsigned short)atoi(service): 0;
+ int hint_family = hints ? hints->ai_family : PF_UNSPEC;
+ int hint_socktype = hints ? hints->ai_socktype : 0;
+ int hint_protocol = hints ? hints->ai_protocol : 0;
+ char ipv4addr[4];
+#ifdef AF_INET6
+ char ipv6addr[16];
+ if ((hint_family == PF_UNSPEC || hint_family == PF_INET6) &&
+ strspn(node, "0123456789abcdefABCDEF.:") == strlen(node) &&
+ inet_pton(AF_INET6, node, ipv6addr)) {
+ int i;
+ for (i = numberof(list)-1; 0 <= i; i--) {
+ if ((hint_socktype == 0 || hint_socktype == list[i].socktype) &&
+ (hint_protocol == 0 || list[i].protocol == 0 || hint_protocol == list[i].protocol)) {
+ struct addrinfo *ai0 = xcalloc(1, sizeof(struct addrinfo));
+ struct sockaddr_in6 *sa = xmalloc(sizeof(struct sockaddr_in6));
+ INIT_SOCKADDR_IN6(sa, sizeof(struct sockaddr_in6));
+ memcpy(&sa->sin6_addr, ipv6addr, sizeof(ipv6addr));
+ sa->sin6_port = htons(port);
+ ai0->ai_family = PF_INET6;
+ ai0->ai_socktype = list[i].socktype;
+ ai0->ai_protocol = hint_protocol ? hint_protocol : list[i].protocol;
+ ai0->ai_addrlen = sizeof(struct sockaddr_in6);
+ ai0->ai_addr = (struct sockaddr *)sa;
+ ai0->ai_canonname = NULL;
+ ai0->ai_next = ai;
+ ai = ai0;
+ }
+ }
+ }
+ else
+#endif
+ if ((hint_family == PF_UNSPEC || hint_family == PF_INET) &&
+ strspn(node, "0123456789.") == strlen(node) &&
+ inet_pton(AF_INET, node, ipv4addr)) {
+ int i;
+ for (i = numberof(list)-1; 0 <= i; i--) {
+ if ((hint_socktype == 0 || hint_socktype == list[i].socktype) &&
+ (hint_protocol == 0 || list[i].protocol == 0 || hint_protocol == list[i].protocol)) {
+ struct addrinfo *ai0 = xcalloc(1, sizeof(struct addrinfo));
+ struct sockaddr_in *sa = xmalloc(sizeof(struct sockaddr_in));
+ INIT_SOCKADDR_IN(sa, sizeof(struct sockaddr_in));
+ memcpy(&sa->sin_addr, ipv4addr, sizeof(ipv4addr));
+ sa->sin_port = htons(port);
+ ai0->ai_family = PF_INET;
+ ai0->ai_socktype = list[i].socktype;
+ ai0->ai_protocol = hint_protocol ? hint_protocol : list[i].protocol;
+ ai0->ai_addrlen = sizeof(struct sockaddr_in);
+ ai0->ai_addr = (struct sockaddr *)sa;
+ ai0->ai_canonname = NULL;
+ ai0->ai_next = ai;
+ ai = ai0;
+ }
+ }
+ }
+ if (ai) {
+ *res = ai;
+ return 0;
+ }
+ }
+#endif
+ return EAI_FAIL;
+}
+
+int
+rb_getaddrinfo(const char *node, const char *service,
+ const struct addrinfo *hints,
+ struct rb_addrinfo **res)
+{
+ struct addrinfo *ai;
+ int ret;
+ int allocated_by_malloc = 0;
+
+ ret = numeric_getaddrinfo(node, service, hints, &ai);
+ if (ret == 0)
+ allocated_by_malloc = 1;
+ else {
+#ifdef GETADDRINFO_EMU
+ ret = getaddrinfo(node, service, hints, &ai);
+#else
+ struct getaddrinfo_arg arg;
+ MEMZERO(&arg, struct getaddrinfo_arg, 1);
+ arg.node = node;
+ arg.service = service;
+ arg.hints = hints;
+ arg.res = &ai;
+ ret = (int)(VALUE)rb_thread_call_without_gvl(nogvl_getaddrinfo, &arg, RUBY_UBF_IO, 0);
+#endif
+ }
+
+ if (ret == 0) {
+ *res = (struct rb_addrinfo *)xmalloc(sizeof(struct rb_addrinfo));
+ (*res)->allocated_by_malloc = allocated_by_malloc;
+ (*res)->ai = ai;
+ }
+ return ret;
+}
+
+void
+rb_freeaddrinfo(struct rb_addrinfo *ai)
+{
+ if (!ai->allocated_by_malloc)
+ freeaddrinfo(ai->ai);
+ else {
+ struct addrinfo *ai1, *ai2;
+ ai1 = ai->ai;
+ while (ai1) {
+ ai2 = ai1->ai_next;
+ xfree(ai1->ai_addr);
+ xfree(ai1);
+ ai1 = ai2;
+ }
+ }
+ xfree(ai);
+}
+
+#ifndef GETADDRINFO_EMU
+struct getnameinfo_arg
+{
+ const struct sockaddr *sa;
+ socklen_t salen;
+ int flags;
+ char *host;
+ size_t hostlen;
+ char *serv;
+ size_t servlen;
+};
+
+static void *
+nogvl_getnameinfo(void *arg)
+{
+ struct getnameinfo_arg *ptr = arg;
+ return (void *)(VALUE)getnameinfo(ptr->sa, ptr->salen,
+ ptr->host, (socklen_t)ptr->hostlen,
+ ptr->serv, (socklen_t)ptr->servlen,
+ ptr->flags);
+}
+#endif
+
+int
+rb_getnameinfo(const struct sockaddr *sa, socklen_t salen,
+ char *host, size_t hostlen,
+ char *serv, size_t servlen, int flags)
+{
+#ifdef GETADDRINFO_EMU
+ return getnameinfo(sa, salen, host, hostlen, serv, servlen, flags);
+#else
+ struct getnameinfo_arg arg;
+ int ret;
+ arg.sa = sa;
+ arg.salen = salen;
+ arg.host = host;
+ arg.hostlen = hostlen;
+ arg.serv = serv;
+ arg.servlen = servlen;
+ arg.flags = flags;
+ ret = (int)(VALUE)rb_thread_call_without_gvl(nogvl_getnameinfo, &arg, RUBY_UBF_IO, 0);
+ return ret;
+#endif
+}
+
+static void
+make_ipaddr0(struct sockaddr *addr, socklen_t addrlen, char *buf, size_t buflen)
+{
+ int error;
+
+ error = rb_getnameinfo(addr, addrlen, buf, buflen, NULL, 0, NI_NUMERICHOST);
+ if (error) {
+ rsock_raise_socket_error("getnameinfo", error);
+ }
+}
+
+VALUE
+rsock_make_ipaddr(struct sockaddr *addr, socklen_t addrlen)
+{
+ char hbuf[1024];
+
+ make_ipaddr0(addr, addrlen, hbuf, sizeof(hbuf));
+ return rb_str_new2(hbuf);
+}
+
+static void
+make_inetaddr(unsigned int host, char *buf, size_t buflen)
+{
+ struct sockaddr_in sin;
+
+ INIT_SOCKADDR_IN(&sin, sizeof(sin));
+ sin.sin_addr.s_addr = host;
+ make_ipaddr0((struct sockaddr*)&sin, sizeof(sin), buf, buflen);
+}
+
+static int
+str_is_number(const char *p)
+{
+ char *ep;
+
+ if (!p || *p == '\0')
+ return 0;
+ ep = NULL;
+ (void)STRTOUL(p, &ep, 10);
+ if (ep && *ep == '\0')
+ return 1;
+ else
+ return 0;
+}
+
+static char*
+host_str(VALUE host, char *hbuf, size_t hbuflen, int *flags_ptr)
+{
+ if (NIL_P(host)) {
+ return NULL;
+ }
+ else if (rb_obj_is_kind_of(host, rb_cInteger)) {
+ unsigned int i = NUM2UINT(host);
+
+ make_inetaddr(htonl(i), hbuf, hbuflen);
+ if (flags_ptr) *flags_ptr |= AI_NUMERICHOST;
+ return hbuf;
+ }
+ else {
+ char *name;
+
+ SafeStringValue(host);
+ name = RSTRING_PTR(host);
+ if (!name || *name == 0 || (name[0] == '<' && strcmp(name, "<any>") == 0)) {
+ make_inetaddr(INADDR_ANY, hbuf, hbuflen);
+ if (flags_ptr) *flags_ptr |= AI_NUMERICHOST;
+ }
+ else if (name[0] == '<' && strcmp(name, "<broadcast>") == 0) {
+ make_inetaddr(INADDR_BROADCAST, hbuf, hbuflen);
+ if (flags_ptr) *flags_ptr |= AI_NUMERICHOST;
+ }
+ else if (strlen(name) >= hbuflen) {
+ rb_raise(rb_eArgError, "hostname too long (%"PRIuSIZE")",
+ strlen(name));
+ }
+ else {
+ strcpy(hbuf, name);
+ }
+ return hbuf;
+ }
+}
+
+static char*
+port_str(VALUE port, char *pbuf, size_t pbuflen, int *flags_ptr)
+{
+ if (NIL_P(port)) {
+ return 0;
+ }
+ else if (FIXNUM_P(port)) {
+ snprintf(pbuf, pbuflen, "%ld", FIX2LONG(port));
+#ifdef AI_NUMERICSERV
+ if (flags_ptr) *flags_ptr |= AI_NUMERICSERV;
+#endif
+ return pbuf;
+ }
+ else {
+ char *serv;
+
+ SafeStringValue(port);
+ serv = RSTRING_PTR(port);
+ if (strlen(serv) >= pbuflen) {
+ rb_raise(rb_eArgError, "service name too long (%"PRIuSIZE")",
+ strlen(serv));
+ }
+ strcpy(pbuf, serv);
+ return pbuf;
+ }
+}
+
+struct rb_addrinfo*
+rsock_getaddrinfo(VALUE host, VALUE port, struct addrinfo *hints, int socktype_hack)
+{
+ struct rb_addrinfo* res = NULL;
+ char *hostp, *portp;
+ int error;
+ char hbuf[NI_MAXHOST], pbuf[NI_MAXSERV];
+ int additional_flags = 0;
+
+ hostp = host_str(host, hbuf, sizeof(hbuf), &additional_flags);
+ portp = port_str(port, pbuf, sizeof(pbuf), &additional_flags);
+
+ if (socktype_hack && hints->ai_socktype == 0 && str_is_number(portp)) {
+ hints->ai_socktype = SOCK_DGRAM;
+ }
+ hints->ai_flags |= additional_flags;
+
+ error = rb_getaddrinfo(hostp, portp, hints, &res);
+ if (error) {
+ if (hostp && hostp[strlen(hostp)-1] == '\n') {
+ rb_raise(rb_eSocket, "newline at the end of hostname");
+ }
+ rsock_raise_socket_error("getaddrinfo", error);
+ }
+
+ return res;
+}
+
+struct rb_addrinfo*
+rsock_addrinfo(VALUE host, VALUE port, int socktype, int flags)
+{
+ struct addrinfo hints;
+
+ MEMZERO(&hints, struct addrinfo, 1);
+ hints.ai_family = AF_UNSPEC;
+ hints.ai_socktype = socktype;
+ hints.ai_flags = flags;
+ return rsock_getaddrinfo(host, port, &hints, 1);
+}
+
+VALUE
+rsock_ipaddr(struct sockaddr *sockaddr, socklen_t sockaddrlen, int norevlookup)
+{
+ VALUE family, port, addr1, addr2;
+ VALUE ary;
+ int error;
+ char hbuf[1024], pbuf[1024];
+ ID id;
+
+ id = rsock_intern_family(sockaddr->sa_family);
+ if (id) {
+ family = rb_str_dup(rb_id2str(id));
+ }
+ else {
+ sprintf(pbuf, "unknown:%d", sockaddr->sa_family);
+ family = rb_str_new2(pbuf);
+ }
+
+ addr1 = Qnil;
+ if (!norevlookup) {
+ error = rb_getnameinfo(sockaddr, sockaddrlen, hbuf, sizeof(hbuf),
+ NULL, 0, 0);
+ if (! error) {
+ addr1 = rb_str_new2(hbuf);
+ }
+ }
+ error = rb_getnameinfo(sockaddr, sockaddrlen, hbuf, sizeof(hbuf),
+ pbuf, sizeof(pbuf), NI_NUMERICHOST | NI_NUMERICSERV);
+ if (error) {
+ rsock_raise_socket_error("getnameinfo", error);
+ }
+ addr2 = rb_str_new2(hbuf);
+ if (addr1 == Qnil) {
+ addr1 = addr2;
+ }
+ port = INT2FIX(atoi(pbuf));
+ ary = rb_ary_new3(4, family, port, addr1, addr2);
+
+ return ary;
+}
+
+#ifdef HAVE_SYS_UN_H
+VALUE
+rsock_unixpath_str(struct sockaddr_un *sockaddr, socklen_t len)
+{
+ char *s, *e;
+ s = sockaddr->sun_path;
+ e = (char *)sockaddr + len;
+ while (s < e && *(e-1) == '\0')
+ e--;
+ if (s <= e)
+ return rb_str_new(s, e-s);
+ else
+ return rb_str_new2("");
+}
+
+VALUE
+rsock_unixaddr(struct sockaddr_un *sockaddr, socklen_t len)
+{
+ return rb_assoc_new(rb_str_new2("AF_UNIX"),
+ rsock_unixpath_str(sockaddr, len));
+}
+
+socklen_t
+rsock_unix_sockaddr_len(VALUE path)
+{
+#ifdef __linux__
+ if (RSTRING_LEN(path) == 0) {
+ /* autobind; see unix(7) for details. */
+ return (socklen_t) sizeof(sa_family_t);
+ }
+ else if (RSTRING_PTR(path)[0] == '\0') {
+ /* abstract namespace; see unix(7) for details. */
+ if (SOCKLEN_MAX - offsetof(struct sockaddr_un, sun_path) < (size_t)RSTRING_LEN(path))
+ rb_raise(rb_eArgError, "Linux abstract socket too long");
+ return (socklen_t) offsetof(struct sockaddr_un, sun_path) +
+ RSTRING_SOCKLEN(path);
+ }
+ else {
+#endif
+ return (socklen_t) sizeof(struct sockaddr_un);
+#ifdef __linux__
+ }
+#endif
+}
+#endif
+
+struct hostent_arg {
+ VALUE host;
+ struct rb_addrinfo* addr;
+ VALUE (*ipaddr)(struct sockaddr*, socklen_t);
+};
+
+static VALUE
+make_hostent_internal(struct hostent_arg *arg)
+{
+ VALUE host = arg->host;
+ struct addrinfo* addr = arg->addr->ai;
+ VALUE (*ipaddr)(struct sockaddr*, socklen_t) = arg->ipaddr;
+
+ struct addrinfo *ai;
+ struct hostent *h;
+ VALUE ary, names;
+ char **pch;
+ const char* hostp;
+ char hbuf[NI_MAXHOST];
+
+ ary = rb_ary_new();
+ if (addr->ai_canonname) {
+ hostp = addr->ai_canonname;
+ }
+ else {
+ hostp = host_str(host, hbuf, sizeof(hbuf), NULL);
+ }
+ rb_ary_push(ary, rb_str_new2(hostp));
+
+ if (addr->ai_canonname && strlen(addr->ai_canonname) < NI_MAXHOST &&
+ (h = gethostbyname(addr->ai_canonname))) {
+ names = rb_ary_new();
+ if (h->h_aliases != NULL) {
+ for (pch = h->h_aliases; *pch; pch++) {
+ rb_ary_push(names, rb_str_new2(*pch));
+ }
+ }
+ }
+ else {
+ names = rb_ary_new2(0);
+ }
+ rb_ary_push(ary, names);
+ rb_ary_push(ary, INT2NUM(addr->ai_family));
+ for (ai = addr; ai; ai = ai->ai_next) {
+ rb_ary_push(ary, (*ipaddr)(ai->ai_addr, ai->ai_addrlen));
+ }
+
+ return ary;
+}
+
+VALUE
+rsock_freeaddrinfo(VALUE arg)
+{
+ struct rb_addrinfo *addr = (struct rb_addrinfo *)arg;
+ rb_freeaddrinfo(addr);
+ return Qnil;
+}
+
+VALUE
+rsock_make_hostent(VALUE host, struct rb_addrinfo *addr, VALUE (*ipaddr)(struct sockaddr *, socklen_t))
+{
+ struct hostent_arg arg;
+
+ arg.host = host;
+ arg.addr = addr;
+ arg.ipaddr = ipaddr;
+ return rb_ensure(make_hostent_internal, (VALUE)&arg,
+ rsock_freeaddrinfo, (VALUE)addr);
+}
+
+typedef struct {
+ VALUE inspectname;
+ VALUE canonname;
+ int pfamily;
+ int socktype;
+ int protocol;
+ socklen_t sockaddr_len;
+ union_sockaddr addr;
+} rb_addrinfo_t;
+
+static void
+addrinfo_mark(void *ptr)
+{
+ rb_addrinfo_t *rai = ptr;
+ if (rai) {
+ rb_gc_mark(rai->inspectname);
+ rb_gc_mark(rai->canonname);
+ }
+}
+
+#define addrinfo_free RUBY_TYPED_DEFAULT_FREE
+
+static size_t
+addrinfo_memsize(const void *ptr)
+{
+ return ptr ? sizeof(rb_addrinfo_t) : 0;
+}
+
+static const rb_data_type_t addrinfo_type = {
+ "socket/addrinfo",
+ {addrinfo_mark, addrinfo_free, addrinfo_memsize,},
+};
+
+static VALUE
+addrinfo_s_allocate(VALUE klass)
+{
+ return TypedData_Wrap_Struct(klass, &addrinfo_type, 0);
+}
+
+#define IS_ADDRINFO(obj) rb_typeddata_is_kind_of((obj), &addrinfo_type)
+static inline rb_addrinfo_t *
+check_addrinfo(VALUE self)
+{
+ return rb_check_typeddata(self, &addrinfo_type);
+}
+
+static rb_addrinfo_t *
+get_addrinfo(VALUE self)
+{
+ rb_addrinfo_t *rai = check_addrinfo(self);
+
+ if (!rai) {
+ rb_raise(rb_eTypeError, "uninitialized socket address");
+ }
+ return rai;
+}
+
+
+static rb_addrinfo_t *
+alloc_addrinfo(void)
+{
+ rb_addrinfo_t *rai = ZALLOC(rb_addrinfo_t);
+ rai->inspectname = Qnil;
+ rai->canonname = Qnil;
+ return rai;
+}
+
+static void
+init_addrinfo(rb_addrinfo_t *rai, struct sockaddr *sa, socklen_t len,
+ int pfamily, int socktype, int protocol,
+ VALUE canonname, VALUE inspectname)
+{
+ if ((socklen_t)sizeof(rai->addr) < len)
+ rb_raise(rb_eArgError, "sockaddr string too big");
+ memcpy((void *)&rai->addr, (void *)sa, len);
+ rai->sockaddr_len = len;
+
+ rai->pfamily = pfamily;
+ rai->socktype = socktype;
+ rai->protocol = protocol;
+ rai->canonname = canonname;
+ rai->inspectname = inspectname;
+}
+
+VALUE
+rsock_addrinfo_new(struct sockaddr *addr, socklen_t len,
+ int family, int socktype, int protocol,
+ VALUE canonname, VALUE inspectname)
+{
+ VALUE a;
+ rb_addrinfo_t *rai;
+
+ a = addrinfo_s_allocate(rb_cAddrinfo);
+ DATA_PTR(a) = rai = alloc_addrinfo();
+ init_addrinfo(rai, addr, len, family, socktype, protocol, canonname, inspectname);
+ return a;
+}
+
+static struct rb_addrinfo *
+call_getaddrinfo(VALUE node, VALUE service,
+ VALUE family, VALUE socktype, VALUE protocol, VALUE flags,
+ int socktype_hack)
+{
+ struct addrinfo hints;
+ struct rb_addrinfo *res;
+
+ MEMZERO(&hints, struct addrinfo, 1);
+ hints.ai_family = NIL_P(family) ? PF_UNSPEC : rsock_family_arg(family);
+
+ if (!NIL_P(socktype)) {
+ hints.ai_socktype = rsock_socktype_arg(socktype);
+ }
+ if (!NIL_P(protocol)) {
+ hints.ai_protocol = NUM2INT(protocol);
+ }
+ if (!NIL_P(flags)) {
+ hints.ai_flags = NUM2INT(flags);
+ }
+ res = rsock_getaddrinfo(node, service, &hints, socktype_hack);
+
+ if (res == NULL)
+ rb_raise(rb_eSocket, "host not found");
+ return res;
+}
+
+static VALUE make_inspectname(VALUE node, VALUE service, struct addrinfo *res);
+
+static void
+init_addrinfo_getaddrinfo(rb_addrinfo_t *rai, VALUE node, VALUE service,
+ VALUE family, VALUE socktype, VALUE protocol, VALUE flags,
+ VALUE inspectnode, VALUE inspectservice)
+{
+ struct rb_addrinfo *res = call_getaddrinfo(node, service, family, socktype, protocol, flags, 1);
+ VALUE canonname;
+ VALUE inspectname = rb_str_equal(node, inspectnode) ? Qnil : make_inspectname(inspectnode, inspectservice, res->ai);
+
+ canonname = Qnil;
+ if (res->ai->ai_canonname) {
+ canonname = rb_tainted_str_new_cstr(res->ai->ai_canonname);
+ OBJ_FREEZE(canonname);
+ }
+
+ init_addrinfo(rai, res->ai->ai_addr, res->ai->ai_addrlen,
+ NUM2INT(family), NUM2INT(socktype), NUM2INT(protocol),
+ canonname, inspectname);
+
+ rb_freeaddrinfo(res);
+}
+
+static VALUE
+make_inspectname(VALUE node, VALUE service, struct addrinfo *res)
+{
+ VALUE inspectname = Qnil;
+
+ if (res) {
+ /* drop redundant information which also shown in address:port part. */
+ char hbuf[NI_MAXHOST], pbuf[NI_MAXSERV];
+ int ret;
+ ret = rb_getnameinfo(res->ai_addr, res->ai_addrlen, hbuf,
+ sizeof(hbuf), pbuf, sizeof(pbuf),
+ NI_NUMERICHOST|NI_NUMERICSERV);
+ if (ret == 0) {
+ if (RB_TYPE_P(node, T_STRING) && strcmp(hbuf, RSTRING_PTR(node)) == 0)
+ node = Qnil;
+ if (RB_TYPE_P(service, T_STRING) && strcmp(pbuf, RSTRING_PTR(service)) == 0)
+ service = Qnil;
+ else if (RB_TYPE_P(service, T_FIXNUM) && atoi(pbuf) == FIX2INT(service))
+ service = Qnil;
+ }
+ }
+
+ if (RB_TYPE_P(node, T_STRING)) {
+ inspectname = rb_str_dup(node);
+ }
+ if (RB_TYPE_P(service, T_STRING)) {
+ if (NIL_P(inspectname))
+ inspectname = rb_sprintf(":%s", StringValueCStr(service));
+ else
+ rb_str_catf(inspectname, ":%s", StringValueCStr(service));
+ }
+ else if (RB_TYPE_P(service, T_FIXNUM) && FIX2INT(service) != 0)
+ {
+ if (NIL_P(inspectname))
+ inspectname = rb_sprintf(":%d", FIX2INT(service));
+ else
+ rb_str_catf(inspectname, ":%d", FIX2INT(service));
+ }
+ if (!NIL_P(inspectname)) {
+ OBJ_INFECT(inspectname, node);
+ OBJ_INFECT(inspectname, service);
+ OBJ_FREEZE(inspectname);
+ }
+ return inspectname;
+}
+
+static VALUE
+addrinfo_firstonly_new(VALUE node, VALUE service, VALUE family, VALUE socktype, VALUE protocol, VALUE flags)
+{
+ VALUE ret;
+ VALUE canonname;
+ VALUE inspectname;
+
+ struct rb_addrinfo *res = call_getaddrinfo(node, service, family, socktype, protocol, flags, 0);
+
+ inspectname = make_inspectname(node, service, res->ai);
+
+ canonname = Qnil;
+ if (res->ai->ai_canonname) {
+ canonname = rb_tainted_str_new_cstr(res->ai->ai_canonname);
+ OBJ_FREEZE(canonname);
+ }
+
+ ret = rsock_addrinfo_new(res->ai->ai_addr, res->ai->ai_addrlen,
+ res->ai->ai_family, res->ai->ai_socktype,
+ res->ai->ai_protocol,
+ canonname, inspectname);
+
+ rb_freeaddrinfo(res);
+ return ret;
+}
+
+static VALUE
+addrinfo_list_new(VALUE node, VALUE service, VALUE family, VALUE socktype, VALUE protocol, VALUE flags)
+{
+ VALUE ret;
+ struct addrinfo *r;
+ VALUE inspectname;
+
+ struct rb_addrinfo *res = call_getaddrinfo(node, service, family, socktype, protocol, flags, 0);
+
+ inspectname = make_inspectname(node, service, res->ai);
+
+ ret = rb_ary_new();
+ for (r = res->ai; r; r = r->ai_next) {
+ VALUE addr;
+ VALUE canonname = Qnil;
+
+ if (r->ai_canonname) {
+ canonname = rb_tainted_str_new_cstr(r->ai_canonname);
+ OBJ_FREEZE(canonname);
+ }
+
+ addr = rsock_addrinfo_new(r->ai_addr, r->ai_addrlen,
+ r->ai_family, r->ai_socktype, r->ai_protocol,
+ canonname, inspectname);
+
+ rb_ary_push(ret, addr);
+ }
+
+ rb_freeaddrinfo(res);
+ return ret;
+}
+
+
+#ifdef HAVE_SYS_UN_H
+static void
+init_unix_addrinfo(rb_addrinfo_t *rai, VALUE path, int socktype)
+{
+ struct sockaddr_un un;
+ socklen_t len;
+
+ StringValue(path);
+
+ if (sizeof(un.sun_path) < (size_t)RSTRING_LEN(path))
+ rb_raise(rb_eArgError,
+ "too long unix socket path (%"PRIuSIZE" bytes given but %"PRIuSIZE" bytes max)",
+ (size_t)RSTRING_LEN(path), sizeof(un.sun_path));
+
+ INIT_SOCKADDR_UN(&un, sizeof(struct sockaddr_un));
+ memcpy((void*)&un.sun_path, RSTRING_PTR(path), RSTRING_LEN(path));
+
+ len = rsock_unix_sockaddr_len(path);
+ init_addrinfo(rai, (struct sockaddr *)&un, len,
+ PF_UNIX, socktype, 0, Qnil, Qnil);
+}
+#endif
+
+/*
+ * call-seq:
+ * Addrinfo.new(sockaddr) => addrinfo
+ * Addrinfo.new(sockaddr, family) => addrinfo
+ * Addrinfo.new(sockaddr, family, socktype) => addrinfo
+ * Addrinfo.new(sockaddr, family, socktype, protocol) => addrinfo
+ *
+ * returns a new instance of Addrinfo.
+ * The instance contains sockaddr, family, socktype, protocol.
+ * sockaddr means struct sockaddr which can be used for connect(2), etc.
+ * family, socktype and protocol are integers which is used for arguments of socket(2).
+ *
+ * sockaddr is specified as an array or a string.
+ * The array should be compatible to the value of IPSocket#addr or UNIXSocket#addr.
+ * The string should be struct sockaddr as generated by
+ * Socket.sockaddr_in or Socket.unpack_sockaddr_un.
+ *
+ * sockaddr examples:
+ * - ["AF_INET", 46102, "localhost.localdomain", "127.0.0.1"]
+ * - ["AF_INET6", 42304, "ip6-localhost", "::1"]
+ * - ["AF_UNIX", "/tmp/sock"]
+ * - Socket.sockaddr_in("smtp", "2001:DB8::1")
+ * - Socket.sockaddr_in(80, "172.18.22.42")
+ * - Socket.sockaddr_in(80, "www.ruby-lang.org")
+ * - Socket.sockaddr_un("/tmp/sock")
+ *
+ * In an AF_INET/AF_INET6 sockaddr array, the 4th element,
+ * numeric IP address, is used to construct socket address in the Addrinfo instance.
+ * If the 3rd element, textual host name, is non-nil, it is also recorded but used only for Addrinfo#inspect.
+ *
+ * family is specified as an integer to specify the protocol family such as Socket::PF_INET.
+ * It can be a symbol or a string which is the constant name
+ * with or without PF_ prefix such as :INET, :INET6, :UNIX, "PF_INET", etc.
+ * If omitted, PF_UNSPEC is assumed.
+ *
+ * socktype is specified as an integer to specify the socket type such as Socket::SOCK_STREAM.
+ * It can be a symbol or a string which is the constant name
+ * with or without SOCK_ prefix such as :STREAM, :DGRAM, :RAW, "SOCK_STREAM", etc.
+ * If omitted, 0 is assumed.
+ *
+ * protocol is specified as an integer to specify the protocol such as Socket::IPPROTO_TCP.
+ * It must be an integer, unlike family and socktype.
+ * If omitted, 0 is assumed.
+ * Note that 0 is reasonable value for most protocols, except raw socket.
+ *
+ */
+static VALUE
+addrinfo_initialize(int argc, VALUE *argv, VALUE self)
+{
+ rb_addrinfo_t *rai;
+ VALUE sockaddr_arg, sockaddr_ary, pfamily, socktype, protocol;
+ int i_pfamily, i_socktype, i_protocol;
+ struct sockaddr *sockaddr_ptr;
+ socklen_t sockaddr_len;
+ VALUE canonname = Qnil, inspectname = Qnil;
+
+ if (check_addrinfo(self))
+ rb_raise(rb_eTypeError, "already initialized socket address");
+ DATA_PTR(self) = rai = alloc_addrinfo();
+
+ rb_scan_args(argc, argv, "13", &sockaddr_arg, &pfamily, &socktype, &protocol);
+
+ i_pfamily = NIL_P(pfamily) ? PF_UNSPEC : rsock_family_arg(pfamily);
+ i_socktype = NIL_P(socktype) ? 0 : rsock_socktype_arg(socktype);
+ i_protocol = NIL_P(protocol) ? 0 : NUM2INT(protocol);
+
+ sockaddr_ary = rb_check_array_type(sockaddr_arg);
+ if (!NIL_P(sockaddr_ary)) {
+ VALUE afamily = rb_ary_entry(sockaddr_ary, 0);
+ int af;
+ StringValue(afamily);
+ if (rsock_family_to_int(RSTRING_PTR(afamily), RSTRING_LEN(afamily), &af) == -1)
+ rb_raise(rb_eSocket, "unknown address family: %s", StringValueCStr(afamily));
+ switch (af) {
+ case AF_INET: /* ["AF_INET", 46102, "localhost.localdomain", "127.0.0.1"] */
+#ifdef INET6
+ case AF_INET6: /* ["AF_INET6", 42304, "ip6-localhost", "::1"] */
+#endif
+ {
+ VALUE service = rb_ary_entry(sockaddr_ary, 1);
+ VALUE nodename = rb_ary_entry(sockaddr_ary, 2);
+ VALUE numericnode = rb_ary_entry(sockaddr_ary, 3);
+ int flags;
+
+ service = INT2NUM(NUM2INT(service));
+ if (!NIL_P(nodename))
+ StringValue(nodename);
+ StringValue(numericnode);
+ flags = AI_NUMERICHOST;
+#ifdef AI_NUMERICSERV
+ flags |= AI_NUMERICSERV;
+#endif
+
+ init_addrinfo_getaddrinfo(rai, numericnode, service,
+ INT2NUM(i_pfamily ? i_pfamily : af), INT2NUM(i_socktype), INT2NUM(i_protocol),
+ INT2NUM(flags),
+ nodename, service);
+ break;
+ }
+
+#ifdef HAVE_SYS_UN_H
+ case AF_UNIX: /* ["AF_UNIX", "/tmp/sock"] */
+ {
+ VALUE path = rb_ary_entry(sockaddr_ary, 1);
+ StringValue(path);
+ init_unix_addrinfo(rai, path, SOCK_STREAM);
+ break;
+ }
+#endif
+
+ default:
+ rb_raise(rb_eSocket, "unexpected address family");
+ }
+ }
+ else {
+ StringValue(sockaddr_arg);
+ sockaddr_ptr = (struct sockaddr *)RSTRING_PTR(sockaddr_arg);
+ sockaddr_len = RSTRING_SOCKLEN(sockaddr_arg);
+ init_addrinfo(rai, sockaddr_ptr, sockaddr_len,
+ i_pfamily, i_socktype, i_protocol,
+ canonname, inspectname);
+ }
+
+ return self;
+}
+
+static int
+get_afamily(struct sockaddr *addr, socklen_t len)
+{
+ if ((socklen_t)((char*)&addr->sa_family + sizeof(addr->sa_family) - (char*)addr) <= len)
+ return addr->sa_family;
+ else
+ return AF_UNSPEC;
+}
+
+static int
+ai_get_afamily(rb_addrinfo_t *rai)
+{
+ return get_afamily(&rai->addr.addr, rai->sockaddr_len);
+}
+
+static VALUE
+inspect_sockaddr(VALUE addrinfo, VALUE ret)
+{
+ rb_addrinfo_t *rai = get_addrinfo(addrinfo);
+ union_sockaddr *sockaddr = &rai->addr;
+ socklen_t socklen = rai->sockaddr_len;
+ return rsock_inspect_sockaddr((struct sockaddr *)sockaddr, socklen, ret);
+}
+
+VALUE
+rsock_inspect_sockaddr(struct sockaddr *sockaddr_arg, socklen_t socklen, VALUE ret)
+{
+ union_sockaddr *sockaddr = (union_sockaddr *)sockaddr_arg;
+ if (socklen == 0) {
+ rb_str_cat2(ret, "empty-sockaddr");
+ }
+ else if ((long)socklen < ((char*)&sockaddr->addr.sa_family + sizeof(sockaddr->addr.sa_family)) - (char*)sockaddr)
+ rb_str_cat2(ret, "too-short-sockaddr");
+ else {
+ switch (sockaddr->addr.sa_family) {
+ case AF_UNSPEC:
+ {
+ rb_str_cat2(ret, "UNSPEC");
+ break;
+ }
+
+ case AF_INET:
+ {
+ struct sockaddr_in *addr;
+ int port;
+ addr = &sockaddr->in;
+ if ((socklen_t)(((char*)&addr->sin_addr)-(char*)addr+0+1) <= socklen)
+ rb_str_catf(ret, "%d", ((unsigned char*)&addr->sin_addr)[0]);
+ else
+ rb_str_cat2(ret, "?");
+ if ((socklen_t)(((char*)&addr->sin_addr)-(char*)addr+1+1) <= socklen)
+ rb_str_catf(ret, ".%d", ((unsigned char*)&addr->sin_addr)[1]);
+ else
+ rb_str_cat2(ret, ".?");
+ if ((socklen_t)(((char*)&addr->sin_addr)-(char*)addr+2+1) <= socklen)
+ rb_str_catf(ret, ".%d", ((unsigned char*)&addr->sin_addr)[2]);
+ else
+ rb_str_cat2(ret, ".?");
+ if ((socklen_t)(((char*)&addr->sin_addr)-(char*)addr+3+1) <= socklen)
+ rb_str_catf(ret, ".%d", ((unsigned char*)&addr->sin_addr)[3]);
+ else
+ rb_str_cat2(ret, ".?");
+
+ if ((socklen_t)(((char*)&addr->sin_port)-(char*)addr+(int)sizeof(addr->sin_port)) < socklen) {
+ port = ntohs(addr->sin_port);
+ if (port)
+ rb_str_catf(ret, ":%d", port);
+ }
+ else {
+ rb_str_cat2(ret, ":?");
+ }
+ if ((socklen_t)sizeof(struct sockaddr_in) != socklen)
+ rb_str_catf(ret, " (%d bytes for %d bytes sockaddr_in)",
+ (int)socklen,
+ (int)sizeof(struct sockaddr_in));
+ break;
+ }
+
+#ifdef AF_INET6
+ case AF_INET6:
+ {
+ struct sockaddr_in6 *addr;
+ char hbuf[1024];
+ int port;
+ int error;
+ if (socklen < (socklen_t)sizeof(struct sockaddr_in6)) {
+ rb_str_catf(ret, "too-short-AF_INET6-sockaddr %d bytes", (int)socklen);
+ }
+ else {
+ addr = &sockaddr->in6;
+ /* use getnameinfo for scope_id.
+ * RFC 4007: IPv6 Scoped Address Architecture
+ * draft-ietf-ipv6-scope-api-00.txt: Scoped Address Extensions to the IPv6 Basic Socket API
+ */
+ error = getnameinfo(&sockaddr->addr, socklen,
+ hbuf, (socklen_t)sizeof(hbuf), NULL, 0,
+ NI_NUMERICHOST|NI_NUMERICSERV);
+ if (error) {
+ rsock_raise_socket_error("getnameinfo", error);
+ }
+ if (addr->sin6_port == 0) {
+ rb_str_cat2(ret, hbuf);
+ }
+ else {
+ port = ntohs(addr->sin6_port);
+ rb_str_catf(ret, "[%s]:%d", hbuf, port);
+ }
+ if ((socklen_t)sizeof(struct sockaddr_in6) < socklen)
+ rb_str_catf(ret, "(sockaddr %d bytes too long)", (int)(socklen - sizeof(struct sockaddr_in6)));
+ }
+ break;
+ }
+#endif
+
+#ifdef HAVE_SYS_UN_H
+ case AF_UNIX:
+ {
+ struct sockaddr_un *addr = &sockaddr->un;
+ char *p, *s, *e;
+ s = addr->sun_path;
+ e = (char*)addr + socklen;
+ while (s < e && *(e-1) == '\0')
+ e--;
+ if (e < s)
+ rb_str_cat2(ret, "too-short-AF_UNIX-sockaddr");
+ else if (s == e)
+ rb_str_cat2(ret, "empty-path-AF_UNIX-sockaddr");
+ else {
+ int printable_only = 1;
+ p = s;
+ while (p < e) {
+ printable_only = printable_only && ISPRINT(*p) && !ISSPACE(*p);
+ p++;
+ }
+ if (printable_only) { /* only printable, no space */
+ if (s[0] != '/') /* relative path */
+ rb_str_cat2(ret, "UNIX ");
+ rb_str_cat(ret, s, p - s);
+ }
+ else {
+ rb_str_cat2(ret, "UNIX");
+ while (s < e)
+ rb_str_catf(ret, ":%02x", (unsigned char)*s++);
+ }
+ }
+ break;
+ }
+#endif
+
+#if defined(AF_PACKET) && defined(__linux__)
+ /* GNU/Linux */
+ case AF_PACKET:
+ {
+ struct sockaddr_ll *addr;
+ const char *sep = "[";
+#define CATSEP do { rb_str_cat2(ret, sep); sep = " "; } while (0);
+
+ addr = (struct sockaddr_ll *)sockaddr;
+
+ rb_str_cat2(ret, "PACKET");
+
+ if (offsetof(struct sockaddr_ll, sll_protocol) + sizeof(addr->sll_protocol) <= (size_t)socklen) {
+ CATSEP;
+ rb_str_catf(ret, "protocol=%d", ntohs(addr->sll_protocol));
+ }
+ if (offsetof(struct sockaddr_ll, sll_ifindex) + sizeof(addr->sll_ifindex) <= (size_t)socklen) {
+ char buf[IFNAMSIZ];
+ CATSEP;
+ if (if_indextoname(addr->sll_ifindex, buf) == NULL)
+ rb_str_catf(ret, "ifindex=%d", addr->sll_ifindex);
+ else
+ rb_str_catf(ret, "%s", buf);
+ }
+ if (offsetof(struct sockaddr_ll, sll_hatype) + sizeof(addr->sll_hatype) <= (size_t)socklen) {
+ CATSEP;
+ rb_str_catf(ret, "hatype=%d", addr->sll_hatype);
+ }
+ if (offsetof(struct sockaddr_ll, sll_pkttype) + sizeof(addr->sll_pkttype) <= (size_t)socklen) {
+ CATSEP;
+ if (addr->sll_pkttype == PACKET_HOST)
+ rb_str_cat2(ret, "HOST");
+ else if (addr->sll_pkttype == PACKET_BROADCAST)
+ rb_str_cat2(ret, "BROADCAST");
+ else if (addr->sll_pkttype == PACKET_MULTICAST)
+ rb_str_cat2(ret, "MULTICAST");
+ else if (addr->sll_pkttype == PACKET_OTHERHOST)
+ rb_str_cat2(ret, "OTHERHOST");
+ else if (addr->sll_pkttype == PACKET_OUTGOING)
+ rb_str_cat2(ret, "OUTGOING");
+ else
+ rb_str_catf(ret, "pkttype=%d", addr->sll_pkttype);
+ }
+ if (socklen != (socklen_t)(offsetof(struct sockaddr_ll, sll_addr) + addr->sll_halen)) {
+ CATSEP;
+ if (offsetof(struct sockaddr_ll, sll_halen) + sizeof(addr->sll_halen) <= (size_t)socklen) {
+ rb_str_catf(ret, "halen=%d", addr->sll_halen);
+ }
+ }
+ if (offsetof(struct sockaddr_ll, sll_addr) < (size_t)socklen) {
+ socklen_t len, i;
+ CATSEP;
+ rb_str_cat2(ret, "hwaddr");
+ len = addr->sll_halen;
+ if ((size_t)socklen < offsetof(struct sockaddr_ll, sll_addr) + len)
+ len = socklen - offsetof(struct sockaddr_ll, sll_addr);
+ for (i = 0; i < len; i++) {
+ rb_str_cat2(ret, i == 0 ? "=" : ":");
+ rb_str_catf(ret, "%02x", addr->sll_addr[i]);
+ }
+ }
+
+ if (socklen < (socklen_t)(offsetof(struct sockaddr_ll, sll_halen) + sizeof(addr->sll_halen)) ||
+ (socklen_t)(offsetof(struct sockaddr_ll, sll_addr) + addr->sll_halen) != socklen) {
+ CATSEP;
+ rb_str_catf(ret, "(%d bytes for %d bytes sockaddr_ll)",
+ (int)socklen, (int)sizeof(struct sockaddr_ll));
+ }
+
+ rb_str_cat2(ret, "]");
+#undef CATSEP
+
+ break;
+ }
+#endif
+
+#if defined(AF_LINK) && defined(HAVE_TYPE_STRUCT_SOCKADDR_DL)
+ /* AF_LINK is defined in 4.4BSD derivations since Net2.
+ link_ntoa is also defined at Net2.
+ However Debian GNU/kFreeBSD defines AF_LINK but
+ don't have link_ntoa. */
+ case AF_LINK:
+ {
+ /*
+ * Simple implementation using link_ntoa():
+ * This doesn't work on Debian GNU/kFreeBSD 6.0.7 (squeeze).
+ * Also, the format is bit different.
+ *
+ * rb_str_catf(ret, "LINK %s", link_ntoa(&sockaddr->dl));
+ * break;
+ */
+ struct sockaddr_dl *addr = &sockaddr->dl;
+ char *np = NULL, *ap = NULL, *endp;
+ int nlen = 0, alen = 0;
+ int i, off;
+ const char *sep = "[";
+#define CATSEP do { rb_str_cat2(ret, sep); sep = " "; } while (0);
+
+ rb_str_cat2(ret, "LINK");
+
+ endp = ((char *)addr) + socklen;
+
+ if (offsetof(struct sockaddr_dl, sdl_data) < socklen) {
+ np = addr->sdl_data;
+ nlen = addr->sdl_nlen;
+ if (endp - np < nlen)
+ nlen = (int)(endp - np);
+ }
+ off = addr->sdl_nlen;
+
+ if (offsetof(struct sockaddr_dl, sdl_data) + off < socklen) {
+ ap = addr->sdl_data + off;
+ alen = addr->sdl_alen;
+ if (endp - ap < alen)
+ alen = (int)(endp - ap);
+ }
+
+ CATSEP;
+ if (np)
+ rb_str_catf(ret, "%.*s", nlen, np);
+ else
+ rb_str_cat2(ret, "?");
+
+ if (ap && 0 < alen) {
+ CATSEP;
+ for (i = 0; i < alen; i++)
+ rb_str_catf(ret, "%s%02x", i == 0 ? "" : ":", (unsigned char)ap[i]);
+ }
+
+ if (socklen < (socklen_t)(offsetof(struct sockaddr_dl, sdl_nlen) + sizeof(addr->sdl_nlen)) ||
+ socklen < (socklen_t)(offsetof(struct sockaddr_dl, sdl_alen) + sizeof(addr->sdl_alen)) ||
+ socklen < (socklen_t)(offsetof(struct sockaddr_dl, sdl_slen) + sizeof(addr->sdl_slen)) ||
+ /* longer length is possible behavior because struct sockaddr_dl has "minimum work area, can be larger" as the last field.
+ * cf. Net2:/usr/src/sys/net/if_dl.h. */
+ socklen < (socklen_t)(offsetof(struct sockaddr_dl, sdl_data) + addr->sdl_nlen + addr->sdl_alen + addr->sdl_slen)) {
+ CATSEP;
+ rb_str_catf(ret, "(%d bytes for %d bytes sockaddr_dl)",
+ (int)socklen, (int)sizeof(struct sockaddr_dl));
+ }
+
+ rb_str_cat2(ret, "]");
+#undef CATSEP
+ break;
+ }
+#endif
+
+ default:
+ {
+ ID id = rsock_intern_family(sockaddr->addr.sa_family);
+ if (id == 0)
+ rb_str_catf(ret, "unknown address family %d", sockaddr->addr.sa_family);
+ else
+ rb_str_catf(ret, "%s address format unknown", rb_id2name(id));
+ break;
+ }
+ }
+ }
+
+ return ret;
+}
+
+/*
+ * call-seq:
+ * addrinfo.inspect => string
+ *
+ * returns a string which shows addrinfo in human-readable form.
+ *
+ * Addrinfo.tcp("localhost", 80).inspect #=> "#<Addrinfo: 127.0.0.1:80 TCP (localhost)>"
+ * Addrinfo.unix("/tmp/sock").inspect #=> "#<Addrinfo: /tmp/sock SOCK_STREAM>"
+ *
+ */
+static VALUE
+addrinfo_inspect(VALUE self)
+{
+ rb_addrinfo_t *rai = get_addrinfo(self);
+ int internet_p;
+ VALUE ret;
+
+ ret = rb_sprintf("#<%s: ", rb_obj_classname(self));
+
+ inspect_sockaddr(self, ret);
+
+ if (rai->pfamily && ai_get_afamily(rai) != rai->pfamily) {
+ ID id = rsock_intern_protocol_family(rai->pfamily);
+ if (id)
+ rb_str_catf(ret, " %s", rb_id2name(id));
+ else
+ rb_str_catf(ret, " PF_\?\?\?(%d)", rai->pfamily);
+ }
+
+ internet_p = rai->pfamily == PF_INET;
+#ifdef INET6
+ internet_p = internet_p || rai->pfamily == PF_INET6;
+#endif
+ if (internet_p && rai->socktype == SOCK_STREAM &&
+ (rai->protocol == 0 || rai->protocol == IPPROTO_TCP)) {
+ rb_str_cat2(ret, " TCP");
+ }
+ else if (internet_p && rai->socktype == SOCK_DGRAM &&
+ (rai->protocol == 0 || rai->protocol == IPPROTO_UDP)) {
+ rb_str_cat2(ret, " UDP");
+ }
+ else {
+ if (rai->socktype) {
+ ID id = rsock_intern_socktype(rai->socktype);
+ if (id)
+ rb_str_catf(ret, " %s", rb_id2name(id));
+ else
+ rb_str_catf(ret, " SOCK_\?\?\?(%d)", rai->socktype);
+ }
+
+ if (rai->protocol) {
+ if (internet_p) {
+ ID id = rsock_intern_ipproto(rai->protocol);
+ if (id)
+ rb_str_catf(ret, " %s", rb_id2name(id));
+ else
+ goto unknown_protocol;
+ }
+ else {
+ unknown_protocol:
+ rb_str_catf(ret, " UNKNOWN_PROTOCOL(%d)", rai->protocol);
+ }
+ }
+ }
+
+ if (!NIL_P(rai->canonname)) {
+ VALUE name = rai->canonname;
+ rb_str_catf(ret, " %s", StringValueCStr(name));
+ }
+
+ if (!NIL_P(rai->inspectname)) {
+ VALUE name = rai->inspectname;
+ rb_str_catf(ret, " (%s)", StringValueCStr(name));
+ }
+
+ rb_str_buf_cat2(ret, ">");
+ return ret;
+}
+
+/*
+ * call-seq:
+ * addrinfo.inspect_sockaddr => string
+ *
+ * returns a string which shows the sockaddr in _addrinfo_ with human-readable form.
+ *
+ * Addrinfo.tcp("localhost", 80).inspect_sockaddr #=> "127.0.0.1:80"
+ * Addrinfo.tcp("ip6-localhost", 80).inspect_sockaddr #=> "[::1]:80"
+ * Addrinfo.unix("/tmp/sock").inspect_sockaddr #=> "/tmp/sock"
+ *
+ */
+VALUE
+rsock_addrinfo_inspect_sockaddr(VALUE self)
+{
+ return inspect_sockaddr(self, rb_str_new("", 0));
+}
+
+/* :nodoc: */
+static VALUE
+addrinfo_mdump(VALUE self)
+{
+ rb_addrinfo_t *rai = get_addrinfo(self);
+ VALUE sockaddr, afamily, pfamily, socktype, protocol, canonname, inspectname;
+ int afamily_int = ai_get_afamily(rai);
+ ID id;
+
+ id = rsock_intern_protocol_family(rai->pfamily);
+ if (id == 0)
+ rb_raise(rb_eSocket, "unknown protocol family: %d", rai->pfamily);
+ pfamily = rb_id2str(id);
+
+ if (rai->socktype == 0)
+ socktype = INT2FIX(0);
+ else {
+ id = rsock_intern_socktype(rai->socktype);
+ if (id == 0)
+ rb_raise(rb_eSocket, "unknown socktype: %d", rai->socktype);
+ socktype = rb_id2str(id);
+ }
+
+ if (rai->protocol == 0)
+ protocol = INT2FIX(0);
+ else if (IS_IP_FAMILY(afamily_int)) {
+ id = rsock_intern_ipproto(rai->protocol);
+ if (id == 0)
+ rb_raise(rb_eSocket, "unknown IP protocol: %d", rai->protocol);
+ protocol = rb_id2str(id);
+ }
+ else {
+ rb_raise(rb_eSocket, "unknown protocol: %d", rai->protocol);
+ }
+
+ canonname = rai->canonname;
+
+ inspectname = rai->inspectname;
+
+ id = rsock_intern_family(afamily_int);
+ if (id == 0)
+ rb_raise(rb_eSocket, "unknown address family: %d", afamily_int);
+ afamily = rb_id2str(id);
+
+ switch(afamily_int) {
+#ifdef HAVE_SYS_UN_H
+ case AF_UNIX:
+ {
+ struct sockaddr_un *su = &rai->addr.un;
+ char *s, *e;
+ s = su->sun_path;
+ e = (char*)su + rai->sockaddr_len;
+ while (s < e && *(e-1) == '\0')
+ e--;
+ sockaddr = rb_str_new(s, e-s);
+ break;
+ }
+#endif
+
+ default:
+ {
+ char hbuf[NI_MAXHOST], pbuf[NI_MAXSERV];
+ int error;
+ error = getnameinfo(&rai->addr.addr, rai->sockaddr_len,
+ hbuf, (socklen_t)sizeof(hbuf), pbuf, (socklen_t)sizeof(pbuf),
+ NI_NUMERICHOST|NI_NUMERICSERV);
+ if (error) {
+ rsock_raise_socket_error("getnameinfo", error);
+ }
+ sockaddr = rb_assoc_new(rb_str_new_cstr(hbuf), rb_str_new_cstr(pbuf));
+ break;
+ }
+ }
+
+ return rb_ary_new3(7, afamily, sockaddr, pfamily, socktype, protocol, canonname, inspectname);
+}
+
+/* :nodoc: */
+static VALUE
+addrinfo_mload(VALUE self, VALUE ary)
+{
+ VALUE v;
+ VALUE canonname, inspectname;
+ int afamily, pfamily, socktype, protocol;
+ union_sockaddr ss;
+ socklen_t len;
+ rb_addrinfo_t *rai;
+
+ if (check_addrinfo(self))
+ rb_raise(rb_eTypeError, "already initialized socket address");
+
+ ary = rb_convert_type(ary, T_ARRAY, "Array", "to_ary");
+
+ v = rb_ary_entry(ary, 0);
+ StringValue(v);
+ if (rsock_family_to_int(RSTRING_PTR(v), RSTRING_LEN(v), &afamily) == -1)
+ rb_raise(rb_eTypeError, "unexpected address family");
+
+ v = rb_ary_entry(ary, 2);
+ StringValue(v);
+ if (rsock_family_to_int(RSTRING_PTR(v), RSTRING_LEN(v), &pfamily) == -1)
+ rb_raise(rb_eTypeError, "unexpected protocol family");
+
+ v = rb_ary_entry(ary, 3);
+ if (v == INT2FIX(0))
+ socktype = 0;
+ else {
+ StringValue(v);
+ if (rsock_socktype_to_int(RSTRING_PTR(v), RSTRING_LEN(v), &socktype) == -1)
+ rb_raise(rb_eTypeError, "unexpected socktype");
+ }
+
+ v = rb_ary_entry(ary, 4);
+ if (v == INT2FIX(0))
+ protocol = 0;
+ else {
+ StringValue(v);
+ if (IS_IP_FAMILY(afamily)) {
+ if (rsock_ipproto_to_int(RSTRING_PTR(v), RSTRING_LEN(v), &protocol) == -1)
+ rb_raise(rb_eTypeError, "unexpected protocol");
+ }
+ else {
+ rb_raise(rb_eTypeError, "unexpected protocol");
+ }
+ }
+
+ v = rb_ary_entry(ary, 5);
+ if (NIL_P(v))
+ canonname = Qnil;
+ else {
+ StringValue(v);
+ canonname = v;
+ }
+
+ v = rb_ary_entry(ary, 6);
+ if (NIL_P(v))
+ inspectname = Qnil;
+ else {
+ StringValue(v);
+ inspectname = v;
+ }
+
+ v = rb_ary_entry(ary, 1);
+ switch(afamily) {
+#ifdef HAVE_SYS_UN_H
+ case AF_UNIX:
+ {
+ struct sockaddr_un uaddr;
+ INIT_SOCKADDR_UN(&uaddr, sizeof(struct sockaddr_un));
+
+ StringValue(v);
+ if (sizeof(uaddr.sun_path) < (size_t)RSTRING_LEN(v))
+ rb_raise(rb_eSocket,
+ "too long AF_UNIX path (%"PRIuSIZE" bytes given but %"PRIuSIZE" bytes max)",
+ (size_t)RSTRING_LEN(v), sizeof(uaddr.sun_path));
+ memcpy(uaddr.sun_path, RSTRING_PTR(v), RSTRING_LEN(v));
+ len = (socklen_t)sizeof(uaddr);
+ memcpy(&ss, &uaddr, len);
+ break;
+ }
+#endif
+
+ default:
+ {
+ VALUE pair = rb_convert_type(v, T_ARRAY, "Array", "to_ary");
+ struct rb_addrinfo *res;
+ int flags = AI_NUMERICHOST;
+#ifdef AI_NUMERICSERV
+ flags |= AI_NUMERICSERV;
+#endif
+ res = call_getaddrinfo(rb_ary_entry(pair, 0), rb_ary_entry(pair, 1),
+ INT2NUM(pfamily), INT2NUM(socktype), INT2NUM(protocol),
+ INT2NUM(flags), 1);
+
+ len = res->ai->ai_addrlen;
+ memcpy(&ss, res->ai->ai_addr, res->ai->ai_addrlen);
+ rb_freeaddrinfo(res);
+ break;
+ }
+ }
+
+ DATA_PTR(self) = rai = alloc_addrinfo();
+ init_addrinfo(rai, &ss.addr, len,
+ pfamily, socktype, protocol,
+ canonname, inspectname);
+ return self;
+}
+
+/*
+ * call-seq:
+ * addrinfo.afamily => integer
+ *
+ * returns the address family as an integer.
+ *
+ * Addrinfo.tcp("localhost", 80).afamily == Socket::AF_INET #=> true
+ *
+ */
+static VALUE
+addrinfo_afamily(VALUE self)
+{
+ rb_addrinfo_t *rai = get_addrinfo(self);
+ return INT2NUM(ai_get_afamily(rai));
+}
+
+/*
+ * call-seq:
+ * addrinfo.pfamily => integer
+ *
+ * returns the protocol family as an integer.
+ *
+ * Addrinfo.tcp("localhost", 80).pfamily == Socket::PF_INET #=> true
+ *
+ */
+static VALUE
+addrinfo_pfamily(VALUE self)
+{
+ rb_addrinfo_t *rai = get_addrinfo(self);
+ return INT2NUM(rai->pfamily);
+}
+
+/*
+ * call-seq:
+ * addrinfo.socktype => integer
+ *
+ * returns the socket type as an integer.
+ *
+ * Addrinfo.tcp("localhost", 80).socktype == Socket::SOCK_STREAM #=> true
+ *
+ */
+static VALUE
+addrinfo_socktype(VALUE self)
+{
+ rb_addrinfo_t *rai = get_addrinfo(self);
+ return INT2NUM(rai->socktype);
+}
+
+/*
+ * call-seq:
+ * addrinfo.protocol => integer
+ *
+ * returns the socket type as an integer.
+ *
+ * Addrinfo.tcp("localhost", 80).protocol == Socket::IPPROTO_TCP #=> true
+ *
+ */
+static VALUE
+addrinfo_protocol(VALUE self)
+{
+ rb_addrinfo_t *rai = get_addrinfo(self);
+ return INT2NUM(rai->protocol);
+}
+
+/*
+ * call-seq:
+ * addrinfo.to_sockaddr => string
+ * addrinfo.to_s => string
+ *
+ * returns the socket address as packed struct sockaddr string.
+ *
+ * Addrinfo.tcp("localhost", 80).to_sockaddr
+ * #=> "\x02\x00\x00P\x7F\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00\x00"
+ *
+ */
+static VALUE
+addrinfo_to_sockaddr(VALUE self)
+{
+ rb_addrinfo_t *rai = get_addrinfo(self);
+ VALUE ret;
+ ret = rb_str_new((char*)&rai->addr, rai->sockaddr_len);
+ OBJ_INFECT(ret, self);
+ return ret;
+}
+
+/*
+ * call-seq:
+ * addrinfo.canonname => string or nil
+ *
+ * returns the canonical name as an string.
+ *
+ * nil is returned if no canonical name.
+ *
+ * The canonical name is set by Addrinfo.getaddrinfo when AI_CANONNAME is specified.
+ *
+ * list = Addrinfo.getaddrinfo("www.ruby-lang.org", 80, :INET, :STREAM, nil, Socket::AI_CANONNAME)
+ * p list[0] #=> #<Addrinfo: 221.186.184.68:80 TCP carbon.ruby-lang.org (www.ruby-lang.org)>
+ * p list[0].canonname #=> "carbon.ruby-lang.org"
+ *
+ */
+static VALUE
+addrinfo_canonname(VALUE self)
+{
+ rb_addrinfo_t *rai = get_addrinfo(self);
+ return rai->canonname;
+}
+
+/*
+ * call-seq:
+ * addrinfo.ip? => true or false
+ *
+ * returns true if addrinfo is internet (IPv4/IPv6) address.
+ * returns false otherwise.
+ *
+ * Addrinfo.tcp("127.0.0.1", 80).ip? #=> true
+ * Addrinfo.tcp("::1", 80).ip? #=> true
+ * Addrinfo.unix("/tmp/sock").ip? #=> false
+ *
+ */
+static VALUE
+addrinfo_ip_p(VALUE self)
+{
+ rb_addrinfo_t *rai = get_addrinfo(self);
+ int family = ai_get_afamily(rai);
+ return IS_IP_FAMILY(family) ? Qtrue : Qfalse;
+}
+
+/*
+ * call-seq:
+ * addrinfo.ipv4? => true or false
+ *
+ * returns true if addrinfo is IPv4 address.
+ * returns false otherwise.
+ *
+ * Addrinfo.tcp("127.0.0.1", 80).ipv4? #=> true
+ * Addrinfo.tcp("::1", 80).ipv4? #=> false
+ * Addrinfo.unix("/tmp/sock").ipv4? #=> false
+ *
+ */
+static VALUE
+addrinfo_ipv4_p(VALUE self)
+{
+ rb_addrinfo_t *rai = get_addrinfo(self);
+ return ai_get_afamily(rai) == AF_INET ? Qtrue : Qfalse;
+}
+
+/*
+ * call-seq:
+ * addrinfo.ipv6? => true or false
+ *
+ * returns true if addrinfo is IPv6 address.
+ * returns false otherwise.
+ *
+ * Addrinfo.tcp("127.0.0.1", 80).ipv6? #=> false
+ * Addrinfo.tcp("::1", 80).ipv6? #=> true
+ * Addrinfo.unix("/tmp/sock").ipv6? #=> false
+ *
+ */
+static VALUE
+addrinfo_ipv6_p(VALUE self)
+{
+#ifdef AF_INET6
+ rb_addrinfo_t *rai = get_addrinfo(self);
+ return ai_get_afamily(rai) == AF_INET6 ? Qtrue : Qfalse;
+#else
+ return Qfalse;
+#endif
+}
+
+/*
+ * call-seq:
+ * addrinfo.unix? => true or false
+ *
+ * returns true if addrinfo is UNIX address.
+ * returns false otherwise.
+ *
+ * Addrinfo.tcp("127.0.0.1", 80).unix? #=> false
+ * Addrinfo.tcp("::1", 80).unix? #=> false
+ * Addrinfo.unix("/tmp/sock").unix? #=> true
+ *
+ */
+static VALUE
+addrinfo_unix_p(VALUE self)
+{
+ rb_addrinfo_t *rai = get_addrinfo(self);
+#ifdef AF_UNIX
+ return ai_get_afamily(rai) == AF_UNIX ? Qtrue : Qfalse;
+#else
+ return Qfalse;
+#endif
+}
+
+/*
+ * call-seq:
+ * addrinfo.getnameinfo => [nodename, service]
+ * addrinfo.getnameinfo(flags) => [nodename, service]
+ *
+ * returns nodename and service as a pair of strings.
+ * This converts struct sockaddr in addrinfo to textual representation.
+ *
+ * flags should be bitwise OR of Socket::NI_??? constants.
+ *
+ * Addrinfo.tcp("127.0.0.1", 80).getnameinfo #=> ["localhost", "www"]
+ *
+ * Addrinfo.tcp("127.0.0.1", 80).getnameinfo(Socket::NI_NUMERICSERV)
+ * #=> ["localhost", "80"]
+ */
+static VALUE
+addrinfo_getnameinfo(int argc, VALUE *argv, VALUE self)
+{
+ rb_addrinfo_t *rai = get_addrinfo(self);
+ VALUE vflags;
+ char hbuf[1024], pbuf[1024];
+ int flags, error;
+
+ rb_scan_args(argc, argv, "01", &vflags);
+
+ flags = NIL_P(vflags) ? 0 : NUM2INT(vflags);
+
+ if (rai->socktype == SOCK_DGRAM)
+ flags |= NI_DGRAM;
+
+ error = getnameinfo(&rai->addr.addr, rai->sockaddr_len,
+ hbuf, (socklen_t)sizeof(hbuf), pbuf, (socklen_t)sizeof(pbuf),
+ flags);
+ if (error) {
+ rsock_raise_socket_error("getnameinfo", error);
+ }
+
+ return rb_assoc_new(rb_str_new2(hbuf), rb_str_new2(pbuf));
+}
+
+/*
+ * call-seq:
+ * addrinfo.ip_unpack => [addr, port]
+ *
+ * Returns the IP address and port number as 2-element array.
+ *
+ * Addrinfo.tcp("127.0.0.1", 80).ip_unpack #=> ["127.0.0.1", 80]
+ * Addrinfo.tcp("::1", 80).ip_unpack #=> ["::1", 80]
+ */
+static VALUE
+addrinfo_ip_unpack(VALUE self)
+{
+ rb_addrinfo_t *rai = get_addrinfo(self);
+ int family = ai_get_afamily(rai);
+ VALUE vflags;
+ VALUE ret, portstr;
+
+ if (!IS_IP_FAMILY(family))
+ rb_raise(rb_eSocket, "need IPv4 or IPv6 address");
+
+ vflags = INT2NUM(NI_NUMERICHOST|NI_NUMERICSERV);
+ ret = addrinfo_getnameinfo(1, &vflags, self);
+ portstr = rb_ary_entry(ret, 1);
+ rb_ary_store(ret, 1, INT2NUM(atoi(StringValueCStr(portstr))));
+ return ret;
+}
+
+/*
+ * call-seq:
+ * addrinfo.ip_address => string
+ *
+ * Returns the IP address as a string.
+ *
+ * Addrinfo.tcp("127.0.0.1", 80).ip_address #=> "127.0.0.1"
+ * Addrinfo.tcp("::1", 80).ip_address #=> "::1"
+ */
+static VALUE
+addrinfo_ip_address(VALUE self)
+{
+ rb_addrinfo_t *rai = get_addrinfo(self);
+ int family = ai_get_afamily(rai);
+ VALUE vflags;
+ VALUE ret;
+
+ if (!IS_IP_FAMILY(family))
+ rb_raise(rb_eSocket, "need IPv4 or IPv6 address");
+
+ vflags = INT2NUM(NI_NUMERICHOST|NI_NUMERICSERV);
+ ret = addrinfo_getnameinfo(1, &vflags, self);
+ return rb_ary_entry(ret, 0);
+}
+
+/*
+ * call-seq:
+ * addrinfo.ip_port => port
+ *
+ * Returns the port number as an integer.
+ *
+ * Addrinfo.tcp("127.0.0.1", 80).ip_port #=> 80
+ * Addrinfo.tcp("::1", 80).ip_port #=> 80
+ */
+static VALUE
+addrinfo_ip_port(VALUE self)
+{
+ rb_addrinfo_t *rai = get_addrinfo(self);
+ int family = ai_get_afamily(rai);
+ int port;
+
+ if (!IS_IP_FAMILY(family)) {
+ bad_family:
+#ifdef AF_INET6
+ rb_raise(rb_eSocket, "need IPv4 or IPv6 address");
+#else
+ rb_raise(rb_eSocket, "need IPv4 address");
+#endif
+ }
+
+ switch (family) {
+ case AF_INET:
+ if (rai->sockaddr_len != sizeof(struct sockaddr_in))
+ rb_raise(rb_eSocket, "unexpected sockaddr size for IPv4");
+ port = ntohs(rai->addr.in.sin_port);
+ break;
+
+#ifdef AF_INET6
+ case AF_INET6:
+ if (rai->sockaddr_len != sizeof(struct sockaddr_in6))
+ rb_raise(rb_eSocket, "unexpected sockaddr size for IPv6");
+ port = ntohs(rai->addr.in6.sin6_port);
+ break;
+#endif
+
+ default:
+ goto bad_family;
+ }
+
+ return INT2NUM(port);
+}
+
+static int
+extract_in_addr(VALUE self, uint32_t *addrp)
+{
+ rb_addrinfo_t *rai = get_addrinfo(self);
+ int family = ai_get_afamily(rai);
+ if (family != AF_INET) return 0;
+ *addrp = ntohl(rai->addr.in.sin_addr.s_addr);
+ return 1;
+}
+
+/*
+ * Returns true for IPv4 private address (10.0.0.0/8, 172.16.0.0/12, 192.168.0.0/16).
+ * It returns false otherwise.
+ */
+static VALUE
+addrinfo_ipv4_private_p(VALUE self)
+{
+ uint32_t a;
+ if (!extract_in_addr(self, &a)) return Qfalse;
+ if ((a & 0xff000000) == 0x0a000000 || /* 10.0.0.0/8 */
+ (a & 0xfff00000) == 0xac100000 || /* 172.16.0.0/12 */
+ (a & 0xffff0000) == 0xc0a80000) /* 192.168.0.0/16 */
+ return Qtrue;
+ return Qfalse;
+}
+
+/*
+ * Returns true for IPv4 loopback address (127.0.0.0/8).
+ * It returns false otherwise.
+ */
+static VALUE
+addrinfo_ipv4_loopback_p(VALUE self)
+{
+ uint32_t a;
+ if (!extract_in_addr(self, &a)) return Qfalse;
+ if ((a & 0xff000000) == 0x7f000000) /* 127.0.0.0/8 */
+ return Qtrue;
+ return Qfalse;
+}
+
+/*
+ * Returns true for IPv4 multicast address (224.0.0.0/4).
+ * It returns false otherwise.
+ */
+static VALUE
+addrinfo_ipv4_multicast_p(VALUE self)
+{
+ uint32_t a;
+ if (!extract_in_addr(self, &a)) return Qfalse;
+ if ((a & 0xf0000000) == 0xe0000000) /* 224.0.0.0/4 */
+ return Qtrue;
+ return Qfalse;
+}
+
+#ifdef INET6
+
+static struct in6_addr *
+extract_in6_addr(VALUE self)
+{
+ rb_addrinfo_t *rai = get_addrinfo(self);
+ int family = ai_get_afamily(rai);
+ if (family != AF_INET6) return NULL;
+ return &rai->addr.in6.sin6_addr;
+}
+
+/*
+ * Returns true for IPv6 unspecified address (::).
+ * It returns false otherwise.
+ */
+static VALUE
+addrinfo_ipv6_unspecified_p(VALUE self)
+{
+ struct in6_addr *addr = extract_in6_addr(self);
+ if (addr && IN6_IS_ADDR_UNSPECIFIED(addr)) return Qtrue;
+ return Qfalse;
+}
+
+/*
+ * Returns true for IPv6 loopback address (::1).
+ * It returns false otherwise.
+ */
+static VALUE
+addrinfo_ipv6_loopback_p(VALUE self)
+{
+ struct in6_addr *addr = extract_in6_addr(self);
+ if (addr && IN6_IS_ADDR_LOOPBACK(addr)) return Qtrue;
+ return Qfalse;
+}
+
+/*
+ * Returns true for IPv6 multicast address (ff00::/8).
+ * It returns false otherwise.
+ */
+static VALUE
+addrinfo_ipv6_multicast_p(VALUE self)
+{
+ struct in6_addr *addr = extract_in6_addr(self);
+ if (addr && IN6_IS_ADDR_MULTICAST(addr)) return Qtrue;
+ return Qfalse;
+}
+
+/*
+ * Returns true for IPv6 link local address (ff80::/10).
+ * It returns false otherwise.
+ */
+static VALUE
+addrinfo_ipv6_linklocal_p(VALUE self)
+{
+ struct in6_addr *addr = extract_in6_addr(self);
+ if (addr && IN6_IS_ADDR_LINKLOCAL(addr)) return Qtrue;
+ return Qfalse;
+}
+
+/*
+ * Returns true for IPv6 site local address (ffc0::/10).
+ * It returns false otherwise.
+ */
+static VALUE
+addrinfo_ipv6_sitelocal_p(VALUE self)
+{
+ struct in6_addr *addr = extract_in6_addr(self);
+ if (addr && IN6_IS_ADDR_SITELOCAL(addr)) return Qtrue;
+ return Qfalse;
+}
+
+/*
+ * Returns true for IPv6 unique local address (fc00::/7, RFC4193).
+ * It returns false otherwise.
+ */
+static VALUE
+addrinfo_ipv6_unique_local_p(VALUE self)
+{
+ struct in6_addr *addr = extract_in6_addr(self);
+ if (addr && IN6_IS_ADDR_UNIQUE_LOCAL(addr)) return Qtrue;
+ return Qfalse;
+}
+
+/*
+ * Returns true for IPv4-mapped IPv6 address (::ffff:0:0/80).
+ * It returns false otherwise.
+ */
+static VALUE
+addrinfo_ipv6_v4mapped_p(VALUE self)
+{
+ struct in6_addr *addr = extract_in6_addr(self);
+ if (addr && IN6_IS_ADDR_V4MAPPED(addr)) return Qtrue;
+ return Qfalse;
+}
+
+/*
+ * Returns true for IPv4-compatible IPv6 address (::/80).
+ * It returns false otherwise.
+ */
+static VALUE
+addrinfo_ipv6_v4compat_p(VALUE self)
+{
+ struct in6_addr *addr = extract_in6_addr(self);
+ if (addr && IN6_IS_ADDR_V4COMPAT(addr)) return Qtrue;
+ return Qfalse;
+}
+
+/*
+ * Returns true for IPv6 multicast node-local scope address.
+ * It returns false otherwise.
+ */
+static VALUE
+addrinfo_ipv6_mc_nodelocal_p(VALUE self)
+{
+ struct in6_addr *addr = extract_in6_addr(self);
+ if (addr && IN6_IS_ADDR_MC_NODELOCAL(addr)) return Qtrue;
+ return Qfalse;
+}
+
+/*
+ * Returns true for IPv6 multicast link-local scope address.
+ * It returns false otherwise.
+ */
+static VALUE
+addrinfo_ipv6_mc_linklocal_p(VALUE self)
+{
+ struct in6_addr *addr = extract_in6_addr(self);
+ if (addr && IN6_IS_ADDR_MC_LINKLOCAL(addr)) return Qtrue;
+ return Qfalse;
+}
+
+/*
+ * Returns true for IPv6 multicast site-local scope address.
+ * It returns false otherwise.
+ */
+static VALUE
+addrinfo_ipv6_mc_sitelocal_p(VALUE self)
+{
+ struct in6_addr *addr = extract_in6_addr(self);
+ if (addr && IN6_IS_ADDR_MC_SITELOCAL(addr)) return Qtrue;
+ return Qfalse;
+}
+
+/*
+ * Returns true for IPv6 multicast organization-local scope address.
+ * It returns false otherwise.
+ */
+static VALUE
+addrinfo_ipv6_mc_orglocal_p(VALUE self)
+{
+ struct in6_addr *addr = extract_in6_addr(self);
+ if (addr && IN6_IS_ADDR_MC_ORGLOCAL(addr)) return Qtrue;
+ return Qfalse;
+}
+
+/*
+ * Returns true for IPv6 multicast global scope address.
+ * It returns false otherwise.
+ */
+static VALUE
+addrinfo_ipv6_mc_global_p(VALUE self)
+{
+ struct in6_addr *addr = extract_in6_addr(self);
+ if (addr && IN6_IS_ADDR_MC_GLOBAL(addr)) return Qtrue;
+ return Qfalse;
+}
+
+/*
+ * Returns IPv4 address of IPv4 mapped/compatible IPv6 address.
+ * It returns nil if +self+ is not IPv4 mapped/compatible IPv6 address.
+ *
+ * Addrinfo.ip("::192.0.2.3").ipv6_to_ipv4 #=> #<Addrinfo: 192.0.2.3>
+ * Addrinfo.ip("::ffff:192.0.2.3").ipv6_to_ipv4 #=> #<Addrinfo: 192.0.2.3>
+ * Addrinfo.ip("::1").ipv6_to_ipv4 #=> nil
+ * Addrinfo.ip("192.0.2.3").ipv6_to_ipv4 #=> nil
+ * Addrinfo.unix("/tmp/sock").ipv6_to_ipv4 #=> nil
+ */
+static VALUE
+addrinfo_ipv6_to_ipv4(VALUE self)
+{
+ rb_addrinfo_t *rai = get_addrinfo(self);
+ struct in6_addr *addr;
+ int family = ai_get_afamily(rai);
+ if (family != AF_INET6) return Qnil;
+ addr = &rai->addr.in6.sin6_addr;
+ if (IN6_IS_ADDR_V4MAPPED(addr) || IN6_IS_ADDR_V4COMPAT(addr)) {
+ struct sockaddr_in sin4;
+ INIT_SOCKADDR_IN(&sin4, sizeof(sin4));
+ memcpy(&sin4.sin_addr, (char*)addr + sizeof(*addr) - sizeof(sin4.sin_addr), sizeof(sin4.sin_addr));
+ return rsock_addrinfo_new((struct sockaddr *)&sin4, (socklen_t)sizeof(sin4),
+ PF_INET, rai->socktype, rai->protocol,
+ rai->canonname, rai->inspectname);
+ }
+ else {
+ return Qnil;
+ }
+}
+
+#endif
+
+#ifdef HAVE_SYS_UN_H
+/*
+ * call-seq:
+ * addrinfo.unix_path => path
+ *
+ * Returns the socket path as a string.
+ *
+ * Addrinfo.unix("/tmp/sock").unix_path #=> "/tmp/sock"
+ */
+static VALUE
+addrinfo_unix_path(VALUE self)
+{
+ rb_addrinfo_t *rai = get_addrinfo(self);
+ int family = ai_get_afamily(rai);
+ struct sockaddr_un *addr;
+ char *s, *e;
+
+ if (family != AF_UNIX)
+ rb_raise(rb_eSocket, "need AF_UNIX address");
+
+ addr = &rai->addr.un;
+
+ s = addr->sun_path;
+ e = (char*)addr + rai->sockaddr_len;
+ if (e < s)
+ rb_raise(rb_eSocket, "too short AF_UNIX address: %"PRIuSIZE" bytes given for minimum %"PRIuSIZE" bytes.",
+ (size_t)rai->sockaddr_len, (size_t)(s - (char *)addr));
+ if (addr->sun_path + sizeof(addr->sun_path) < e)
+ rb_raise(rb_eSocket,
+ "too long AF_UNIX path (%"PRIuSIZE" bytes given but %"PRIuSIZE" bytes max)",
+ (size_t)(e - addr->sun_path), sizeof(addr->sun_path));
+ while (s < e && *(e-1) == '\0')
+ e--;
+ return rb_str_new(s, e-s);
+}
+#endif
+
+/*
+ * call-seq:
+ * Addrinfo.getaddrinfo(nodename, service, family, socktype, protocol, flags) => [addrinfo, ...]
+ * Addrinfo.getaddrinfo(nodename, service, family, socktype, protocol) => [addrinfo, ...]
+ * Addrinfo.getaddrinfo(nodename, service, family, socktype) => [addrinfo, ...]
+ * Addrinfo.getaddrinfo(nodename, service, family) => [addrinfo, ...]
+ * Addrinfo.getaddrinfo(nodename, service) => [addrinfo, ...]
+ *
+ * returns a list of addrinfo objects as an array.
+ *
+ * This method converts nodename (hostname) and service (port) to addrinfo.
+ * Since the conversion is not unique, the result is a list of addrinfo objects.
+ *
+ * nodename or service can be nil if no conversion intended.
+ *
+ * family, socktype and protocol are hint for preferred protocol.
+ * If the result will be used for a socket with SOCK_STREAM,
+ * SOCK_STREAM should be specified as socktype.
+ * If so, Addrinfo.getaddrinfo returns addrinfo list appropriate for SOCK_STREAM.
+ * If they are omitted or nil is given, the result is not restricted.
+ *
+ * Similarly, PF_INET6 as family restricts for IPv6.
+ *
+ * flags should be bitwise OR of Socket::AI_??? constants such as follows.
+ * Note that the exact list of the constants depends on OS.
+ *
+ * AI_PASSIVE Get address to use with bind()
+ * AI_CANONNAME Fill in the canonical name
+ * AI_NUMERICHOST Prevent host name resolution
+ * AI_NUMERICSERV Prevent service name resolution
+ * AI_V4MAPPED Accept IPv4-mapped IPv6 addresses
+ * AI_ALL Allow all addresses
+ * AI_ADDRCONFIG Accept only if any address is assigned
+ *
+ * Note that socktype should be specified whenever application knows the usage of the address.
+ * Some platform causes an error when socktype is omitted and servname is specified as an integer
+ * because some port numbers, 512 for example, are ambiguous without socktype.
+ *
+ * Addrinfo.getaddrinfo("www.kame.net", 80, nil, :STREAM)
+ * #=> [#<Addrinfo: 203.178.141.194:80 TCP (www.kame.net)>,
+ * # #<Addrinfo: [2001:200:dff:fff1:216:3eff:feb1:44d7]:80 TCP (www.kame.net)>]
+ *
+ */
+static VALUE
+addrinfo_s_getaddrinfo(int argc, VALUE *argv, VALUE self)
+{
+ VALUE node, service, family, socktype, protocol, flags;
+
+ rb_scan_args(argc, argv, "24", &node, &service, &family, &socktype, &protocol, &flags);
+ return addrinfo_list_new(node, service, family, socktype, protocol, flags);
+}
+
+/*
+ * call-seq:
+ * Addrinfo.ip(host) => addrinfo
+ *
+ * returns an addrinfo object for IP address.
+ *
+ * The port, socktype, protocol of the result is filled by zero.
+ * So, it is not appropriate to create a socket.
+ *
+ * Addrinfo.ip("localhost") #=> #<Addrinfo: 127.0.0.1 (localhost)>
+ */
+static VALUE
+addrinfo_s_ip(VALUE self, VALUE host)
+{
+ VALUE ret;
+ rb_addrinfo_t *rai;
+ ret = addrinfo_firstonly_new(host, Qnil,
+ INT2NUM(PF_UNSPEC), INT2FIX(0), INT2FIX(0), INT2FIX(0));
+ rai = get_addrinfo(ret);
+ rai->socktype = 0;
+ rai->protocol = 0;
+ return ret;
+}
+
+/*
+ * call-seq:
+ * Addrinfo.tcp(host, port) => addrinfo
+ *
+ * returns an addrinfo object for TCP address.
+ *
+ * Addrinfo.tcp("localhost", "smtp") #=> #<Addrinfo: 127.0.0.1:25 TCP (localhost:smtp)>
+ */
+static VALUE
+addrinfo_s_tcp(VALUE self, VALUE host, VALUE port)
+{
+ return addrinfo_firstonly_new(host, port,
+ INT2NUM(PF_UNSPEC), INT2NUM(SOCK_STREAM), INT2NUM(IPPROTO_TCP), INT2FIX(0));
+}
+
+/*
+ * call-seq:
+ * Addrinfo.udp(host, port) => addrinfo
+ *
+ * returns an addrinfo object for UDP address.
+ *
+ * Addrinfo.udp("localhost", "daytime") #=> #<Addrinfo: 127.0.0.1:13 UDP (localhost:daytime)>
+ */
+static VALUE
+addrinfo_s_udp(VALUE self, VALUE host, VALUE port)
+{
+ return addrinfo_firstonly_new(host, port,
+ INT2NUM(PF_UNSPEC), INT2NUM(SOCK_DGRAM), INT2NUM(IPPROTO_UDP), INT2FIX(0));
+}
+
+#ifdef HAVE_SYS_UN_H
+
+/*
+ * call-seq:
+ * Addrinfo.unix(path [, socktype]) => addrinfo
+ *
+ * returns an addrinfo object for UNIX socket address.
+ *
+ * _socktype_ specifies the socket type.
+ * If it is omitted, :STREAM is used.
+ *
+ * Addrinfo.unix("/tmp/sock") #=> #<Addrinfo: /tmp/sock SOCK_STREAM>
+ * Addrinfo.unix("/tmp/sock", :DGRAM) #=> #<Addrinfo: /tmp/sock SOCK_DGRAM>
+ */
+static VALUE
+addrinfo_s_unix(int argc, VALUE *argv, VALUE self)
+{
+ VALUE path, vsocktype, addr;
+ int socktype;
+ rb_addrinfo_t *rai;
+
+ rb_scan_args(argc, argv, "11", &path, &vsocktype);
+
+ if (NIL_P(vsocktype))
+ socktype = SOCK_STREAM;
+ else
+ socktype = rsock_socktype_arg(vsocktype);
+
+ addr = addrinfo_s_allocate(rb_cAddrinfo);
+ DATA_PTR(addr) = rai = alloc_addrinfo();
+ init_unix_addrinfo(rai, path, socktype);
+ OBJ_INFECT(addr, path);
+ return addr;
+}
+
+#endif
+
+VALUE
+rsock_sockaddr_string_value(volatile VALUE *v)
+{
+ VALUE val = *v;
+ if (IS_ADDRINFO(val)) {
+ *v = addrinfo_to_sockaddr(val);
+ }
+ StringValue(*v);
+ return *v;
+}
+
+VALUE
+rsock_sockaddr_string_value_with_addrinfo(volatile VALUE *v, VALUE *rai_ret)
+{
+ VALUE val = *v;
+ *rai_ret = Qnil;
+ if (IS_ADDRINFO(val)) {
+ *v = addrinfo_to_sockaddr(val);
+ *rai_ret = val;
+ }
+ StringValue(*v);
+ return *v;
+}
+
+char *
+rsock_sockaddr_string_value_ptr(volatile VALUE *v)
+{
+ rsock_sockaddr_string_value(v);
+ return RSTRING_PTR(*v);
+}
+
+VALUE
+rb_check_sockaddr_string_type(VALUE val)
+{
+ if (IS_ADDRINFO(val))
+ return addrinfo_to_sockaddr(val);
+ return rb_check_string_type(val);
+}
+
+VALUE
+rsock_fd_socket_addrinfo(int fd, struct sockaddr *addr, socklen_t len)
+{
+ int family;
+ int socktype;
+ int ret;
+ socklen_t optlen = (socklen_t)sizeof(socktype);
+
+ /* assumes protocol family and address family are identical */
+ family = get_afamily(addr, len);
+
+ ret = getsockopt(fd, SOL_SOCKET, SO_TYPE, (void*)&socktype, &optlen);
+ if (ret == -1) {
+ rb_sys_fail("getsockopt(SO_TYPE)");
+ }
+
+ return rsock_addrinfo_new(addr, len, family, socktype, 0, Qnil, Qnil);
+}
+
+VALUE
+rsock_io_socket_addrinfo(VALUE io, struct sockaddr *addr, socklen_t len)
+{
+ rb_io_t *fptr;
+
+ switch (TYPE(io)) {
+ case T_FIXNUM:
+ return rsock_fd_socket_addrinfo(FIX2INT(io), addr, len);
+
+ case T_BIGNUM:
+ return rsock_fd_socket_addrinfo(NUM2INT(io), addr, len);
+
+ case T_FILE:
+ GetOpenFile(io, fptr);
+ return rsock_fd_socket_addrinfo(fptr->fd, addr, len);
+
+ default:
+ rb_raise(rb_eTypeError, "neither IO nor file descriptor");
+ }
+
+ UNREACHABLE;
+}
+
+/*
+ * Addrinfo class
+ */
+void
+rsock_init_addrinfo(void)
+{
+ /*
+ * The Addrinfo class maps <tt>struct addrinfo</tt> to ruby. This
+ * structure identifies an Internet host and a service.
+ */
+ rb_cAddrinfo = rb_define_class("Addrinfo", rb_cData);
+ rb_define_alloc_func(rb_cAddrinfo, addrinfo_s_allocate);
+ rb_define_method(rb_cAddrinfo, "initialize", addrinfo_initialize, -1);
+ rb_define_method(rb_cAddrinfo, "inspect", addrinfo_inspect, 0);
+ rb_define_method(rb_cAddrinfo, "inspect_sockaddr", rsock_addrinfo_inspect_sockaddr, 0);
+ rb_define_singleton_method(rb_cAddrinfo, "getaddrinfo", addrinfo_s_getaddrinfo, -1);
+ rb_define_singleton_method(rb_cAddrinfo, "ip", addrinfo_s_ip, 1);
+ rb_define_singleton_method(rb_cAddrinfo, "tcp", addrinfo_s_tcp, 2);
+ rb_define_singleton_method(rb_cAddrinfo, "udp", addrinfo_s_udp, 2);
+#ifdef HAVE_SYS_UN_H
+ rb_define_singleton_method(rb_cAddrinfo, "unix", addrinfo_s_unix, -1);
+#endif
+
+ rb_define_method(rb_cAddrinfo, "afamily", addrinfo_afamily, 0);
+ rb_define_method(rb_cAddrinfo, "pfamily", addrinfo_pfamily, 0);
+ rb_define_method(rb_cAddrinfo, "socktype", addrinfo_socktype, 0);
+ rb_define_method(rb_cAddrinfo, "protocol", addrinfo_protocol, 0);
+ rb_define_method(rb_cAddrinfo, "canonname", addrinfo_canonname, 0);
+
+ rb_define_method(rb_cAddrinfo, "ipv4?", addrinfo_ipv4_p, 0);
+ rb_define_method(rb_cAddrinfo, "ipv6?", addrinfo_ipv6_p, 0);
+ rb_define_method(rb_cAddrinfo, "unix?", addrinfo_unix_p, 0);
+
+ rb_define_method(rb_cAddrinfo, "ip?", addrinfo_ip_p, 0);
+ rb_define_method(rb_cAddrinfo, "ip_unpack", addrinfo_ip_unpack, 0);
+ rb_define_method(rb_cAddrinfo, "ip_address", addrinfo_ip_address, 0);
+ rb_define_method(rb_cAddrinfo, "ip_port", addrinfo_ip_port, 0);
+
+ rb_define_method(rb_cAddrinfo, "ipv4_private?", addrinfo_ipv4_private_p, 0);
+ rb_define_method(rb_cAddrinfo, "ipv4_loopback?", addrinfo_ipv4_loopback_p, 0);
+ rb_define_method(rb_cAddrinfo, "ipv4_multicast?", addrinfo_ipv4_multicast_p, 0);
+
+#ifdef INET6
+ rb_define_method(rb_cAddrinfo, "ipv6_unspecified?", addrinfo_ipv6_unspecified_p, 0);
+ rb_define_method(rb_cAddrinfo, "ipv6_loopback?", addrinfo_ipv6_loopback_p, 0);
+ rb_define_method(rb_cAddrinfo, "ipv6_multicast?", addrinfo_ipv6_multicast_p, 0);
+ rb_define_method(rb_cAddrinfo, "ipv6_linklocal?", addrinfo_ipv6_linklocal_p, 0);
+ rb_define_method(rb_cAddrinfo, "ipv6_sitelocal?", addrinfo_ipv6_sitelocal_p, 0);
+ rb_define_method(rb_cAddrinfo, "ipv6_unique_local?", addrinfo_ipv6_unique_local_p, 0);
+ rb_define_method(rb_cAddrinfo, "ipv6_v4mapped?", addrinfo_ipv6_v4mapped_p, 0);
+ rb_define_method(rb_cAddrinfo, "ipv6_v4compat?", addrinfo_ipv6_v4compat_p, 0);
+ rb_define_method(rb_cAddrinfo, "ipv6_mc_nodelocal?", addrinfo_ipv6_mc_nodelocal_p, 0);
+ rb_define_method(rb_cAddrinfo, "ipv6_mc_linklocal?", addrinfo_ipv6_mc_linklocal_p, 0);
+ rb_define_method(rb_cAddrinfo, "ipv6_mc_sitelocal?", addrinfo_ipv6_mc_sitelocal_p, 0);
+ rb_define_method(rb_cAddrinfo, "ipv6_mc_orglocal?", addrinfo_ipv6_mc_orglocal_p, 0);
+ rb_define_method(rb_cAddrinfo, "ipv6_mc_global?", addrinfo_ipv6_mc_global_p, 0);
+
+ rb_define_method(rb_cAddrinfo, "ipv6_to_ipv4", addrinfo_ipv6_to_ipv4, 0);
+#endif
+
+#ifdef HAVE_SYS_UN_H
+ rb_define_method(rb_cAddrinfo, "unix_path", addrinfo_unix_path, 0);
+#endif
+
+ rb_define_method(rb_cAddrinfo, "to_sockaddr", addrinfo_to_sockaddr, 0);
+ rb_define_method(rb_cAddrinfo, "to_s", addrinfo_to_sockaddr, 0); /* compatibility for ruby before 1.9.2 */
+
+ rb_define_method(rb_cAddrinfo, "getnameinfo", addrinfo_getnameinfo, -1);
+
+ rb_define_method(rb_cAddrinfo, "marshal_dump", addrinfo_mdump, 0);
+ rb_define_method(rb_cAddrinfo, "marshal_load", addrinfo_mload, 1);
+}
diff --git a/jni/ruby/ext/socket/rubysocket.h b/jni/ruby/ext/socket/rubysocket.h
new file mode 100644
index 0000000..8beffd2
--- /dev/null
+++ b/jni/ruby/ext/socket/rubysocket.h
@@ -0,0 +1,415 @@
+#ifndef RUBY_SOCKET_H
+#define RUBY_SOCKET_H 1
+
+#include "ruby/ruby.h"
+#include "ruby/io.h"
+#include "ruby/thread.h"
+#include "ruby/util.h"
+#include "internal.h"
+#include <stdio.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+
+#ifdef HAVE_UNISTD_H
+# include <unistd.h>
+#endif
+
+#ifdef HAVE_SYS_UIO_H
+# include <sys/uio.h>
+#endif
+
+#ifdef HAVE_XTI_H
+# include <xti.h>
+#endif
+
+#ifdef _WIN32
+# if defined(_MSC_VER)
+# undef HAVE_TYPE_STRUCT_SOCKADDR_DL
+# endif
+#else
+# if defined(__BEOS__) && !defined(__HAIKU__) && !defined(BONE)
+# include <net/socket.h>
+# else
+# include <sys/socket.h>
+# endif
+# include <netinet/in.h>
+# ifdef HAVE_NETINET_IN_SYSTM_H
+# include <netinet/in_systm.h>
+# endif
+# ifdef HAVE_NETINET_TCP_H
+# include <netinet/tcp.h>
+# endif
+# ifdef HAVE_NETINET_TCP_FSM_H
+# include <netinet/tcp_fsm.h>
+# endif
+# ifdef HAVE_NETINET_UDP_H
+# include <netinet/udp.h>
+# endif
+# ifdef HAVE_ARPA_INET_H
+# include <arpa/inet.h>
+# endif
+# include <netdb.h>
+#endif
+
+#ifdef HAVE_NETPACKET_PACKET_H
+# include <netpacket/packet.h>
+#endif
+#ifdef HAVE_NET_ETHERNET_H
+# include <net/ethernet.h>
+#endif
+
+#include <errno.h>
+
+#ifdef HAVE_SYS_UN_H
+# include <sys/un.h>
+#endif
+
+#if defined(HAVE_FCNTL)
+# ifdef HAVE_SYS_SELECT_H
+# include <sys/select.h>
+# endif
+# ifdef HAVE_SYS_TYPES_H
+# include <sys/types.h>
+# endif
+# ifdef HAVE_SYS_TIME_H
+# include <sys/time.h>
+# endif
+# ifdef HAVE_FCNTL_H
+# include <fcntl.h>
+# endif
+#endif
+
+#ifdef HAVE_IFADDRS_H
+# include <ifaddrs.h>
+#endif
+#ifdef HAVE_SYS_IOCTL_H
+# include <sys/ioctl.h>
+#endif
+#ifdef HAVE_SYS_SOCKIO_H
+# include <sys/sockio.h>
+#endif
+#ifdef HAVE_NET_IF_H
+# include <net/if.h>
+#endif
+
+#ifdef HAVE_SYS_PARAM_H
+# include <sys/param.h>
+#endif
+#ifdef HAVE_SYS_UCRED_H
+# include <sys/ucred.h>
+#endif
+#ifdef HAVE_UCRED_H
+# include <ucred.h>
+#endif
+#ifdef HAVE_NET_IF_DL_H
+# include <net/if_dl.h>
+#endif
+
+#ifndef HAVE_TYPE_SOCKLEN_T
+typedef int socklen_t;
+#endif
+
+#ifdef NEED_IF_INDEXTONAME_DECL
+char *if_indextoname(unsigned int, char *);
+#endif
+#ifdef NEED_IF_NAMETOINDEX_DECL
+unsigned int if_nametoindex(const char *);
+#endif
+
+#define SOCKLEN_MAX \
+ (0 < (socklen_t)-1 ? \
+ ~(socklen_t)0 : \
+ (((((socklen_t)1) << (sizeof(socklen_t) * CHAR_BIT - 2)) - 1) * 2 + 1))
+
+#ifndef RSTRING_SOCKLEN
+# define RSTRING_SOCKLEN (socklen_t)RSTRING_LENINT
+#endif
+
+#ifndef EWOULDBLOCK
+# define EWOULDBLOCK EAGAIN
+#endif
+
+/*
+ * workaround for NetBSD, OpenBSD and etc.
+ * The problem is since 4.4BSD-Lite.
+ * FreeBSD fix the problem at FreeBSD 2.2.0.
+ * NetBSD fix the problem at NetBSD 3.0 by kern/29624.
+ * OpenBSD fix the problem at OpenBSD 3.8.
+ */
+#define pseudo_AF_FTIP pseudo_AF_RTIP
+
+#ifndef HAVE_GETADDRINFO
+# include "addrinfo.h"
+#endif
+
+#include "sockport.h"
+
+#ifndef NI_MAXHOST
+# define NI_MAXHOST 1025
+#endif
+#ifndef NI_MAXSERV
+# define NI_MAXSERV 32
+#endif
+
+#ifdef AF_INET6
+# define IS_IP_FAMILY(af) ((af) == AF_INET || (af) == AF_INET6)
+#else
+# define IS_IP_FAMILY(af) ((af) == AF_INET)
+#endif
+
+#ifndef IN6_IS_ADDR_UNIQUE_LOCAL
+# define IN6_IS_ADDR_UNIQUE_LOCAL(a) (((a)->s6_addr[0] == 0xfc) || ((a)->s6_addr[0] == 0xfd))
+#endif
+
+#ifndef HAVE_TYPE_STRUCT_SOCKADDR_STORAGE
+/*
+ * RFC 2553: protocol-independent placeholder for socket addresses
+ */
+# define _SS_MAXSIZE 128
+# define _SS_ALIGNSIZE (sizeof(double))
+# define _SS_PAD1SIZE (_SS_ALIGNSIZE - sizeof(unsigned char) * 2)
+# define _SS_PAD2SIZE (_SS_MAXSIZE - sizeof(unsigned char) * 2 - \
+ _SS_PAD1SIZE - _SS_ALIGNSIZE)
+
+struct sockaddr_storage {
+# ifdef HAVE_STRUCT_SOCKADDR_SA_LEN
+ unsigned char ss_len; /* address length */
+ unsigned char ss_family; /* address family */
+# else
+ unsigned short ss_family;
+# endif
+ char __ss_pad1[_SS_PAD1SIZE];
+ double __ss_align; /* force desired structure storage alignment */
+ char __ss_pad2[_SS_PAD2SIZE];
+};
+#endif
+
+typedef union {
+ struct sockaddr addr;
+ struct sockaddr_in in;
+#ifdef AF_INET6
+ struct sockaddr_in6 in6;
+#endif
+#ifdef HAVE_TYPE_STRUCT_SOCKADDR_UN
+ struct sockaddr_un un;
+#endif
+#ifdef HAVE_TYPE_STRUCT_SOCKADDR_DL
+ struct sockaddr_dl dl; /* AF_LINK */
+#endif
+ struct sockaddr_storage storage;
+ char place_holder[2048]; /* sockaddr_storage is not enough for Unix domain sockets on SunOS and Darwin. */
+} union_sockaddr;
+
+#ifdef __APPLE__
+/*
+ * CMSG_ macros are broken on 64bit darwin, because __DARWIN_ALIGN
+ * aligns up to __darwin_size_t which is 64bit, but CMSG_DATA is
+ * 32bit-aligned.
+ */
+# undef __DARWIN_ALIGNBYTES
+# define __DARWIN_ALIGNBYTES (sizeof(unsigned int) - 1)
+#endif
+
+#if defined(_AIX)
+# ifndef CMSG_SPACE
+# define CMSG_SPACE(len) (_CMSG_ALIGN(sizeof(struct cmsghdr)) + _CMSG_ALIGN(len))
+# endif
+# ifndef CMSG_LEN
+# define CMSG_LEN(len) (_CMSG_ALIGN(sizeof(struct cmsghdr)) + (len))
+# endif
+#endif
+
+#ifdef __BEOS__
+# undef close
+# define close closesocket
+#endif
+
+#define INET_CLIENT 0
+#define INET_SERVER 1
+#define INET_SOCKS 2
+
+extern int rsock_do_not_reverse_lookup;
+extern int rsock_cmsg_cloexec_state;
+#define FMODE_NOREVLOOKUP 0x100
+
+extern VALUE rb_cBasicSocket;
+extern VALUE rb_cIPSocket;
+extern VALUE rb_cTCPSocket;
+extern VALUE rb_cTCPServer;
+extern VALUE rb_cUDPSocket;
+#ifdef HAVE_SYS_UN_H
+extern VALUE rb_cUNIXSocket;
+extern VALUE rb_cUNIXServer;
+#endif
+extern VALUE rb_cSocket;
+extern VALUE rb_cAddrinfo;
+extern VALUE rb_cSockOpt;
+
+extern VALUE rb_eSocket;
+
+#ifdef SOCKS
+extern VALUE rb_cSOCKSSocket;
+# ifdef SOCKS5
+# include <socks.h>
+# else
+void SOCKSinit();
+int Rconnect();
+# endif
+#endif
+
+#include "constdefs.h"
+
+#define BLOCKING_REGION_FD(func, arg) (long)rb_thread_io_blocking_region((func), (arg), (arg)->fd)
+
+#define SockAddrStringValue(v) rsock_sockaddr_string_value(&(v))
+#define SockAddrStringValuePtr(v) rsock_sockaddr_string_value_ptr(&(v))
+#define SockAddrStringValueWithAddrinfo(v, rai_ret) rsock_sockaddr_string_value_with_addrinfo(&(v), &(rai_ret))
+VALUE rsock_sockaddr_string_value(volatile VALUE *);
+char *rsock_sockaddr_string_value_ptr(volatile VALUE *);
+VALUE rsock_sockaddr_string_value_with_addrinfo(volatile VALUE *v, VALUE *ai_ret);
+
+VALUE rb_check_sockaddr_string_type(VALUE);
+
+NORETURN(void rsock_raise_socket_error(const char *, int));
+
+int rsock_family_arg(VALUE domain);
+int rsock_socktype_arg(VALUE type);
+int rsock_level_arg(int family, VALUE level);
+int rsock_optname_arg(int family, int level, VALUE optname);
+int rsock_cmsg_type_arg(int family, int level, VALUE type);
+int rsock_shutdown_how_arg(VALUE how);
+
+int rsock_getfamily(int sockfd);
+
+struct rb_addrinfo {
+ struct addrinfo *ai;
+ int allocated_by_malloc;
+};
+int rb_getaddrinfo(const char *node, const char *service, const struct addrinfo *hints, struct rb_addrinfo **res);
+void rb_freeaddrinfo(struct rb_addrinfo *ai);
+VALUE rsock_freeaddrinfo(VALUE arg);
+int rb_getnameinfo(const struct sockaddr *sa, socklen_t salen, char *host, size_t hostlen, char *serv, size_t servlen, int flags);
+struct rb_addrinfo *rsock_addrinfo(VALUE host, VALUE port, int socktype, int flags);
+struct rb_addrinfo *rsock_getaddrinfo(VALUE host, VALUE port, struct addrinfo *hints, int socktype_hack);
+VALUE rsock_fd_socket_addrinfo(int fd, struct sockaddr *addr, socklen_t len);
+VALUE rsock_io_socket_addrinfo(VALUE io, struct sockaddr *addr, socklen_t len);
+
+VALUE rsock_addrinfo_new(struct sockaddr *addr, socklen_t len, int family, int socktype, int protocol, VALUE canonname, VALUE inspectname);
+VALUE rsock_addrinfo_inspect_sockaddr(VALUE rai);
+
+VALUE rsock_make_ipaddr(struct sockaddr *addr, socklen_t addrlen);
+VALUE rsock_ipaddr(struct sockaddr *sockaddr, socklen_t sockaddrlen, int norevlookup);
+VALUE rsock_make_hostent(VALUE host, struct rb_addrinfo *addr, VALUE (*ipaddr)(struct sockaddr *, socklen_t));
+VALUE rsock_inspect_sockaddr(struct sockaddr *addr, socklen_t socklen, VALUE ret);
+socklen_t rsock_sockaddr_len(struct sockaddr *addr);
+VALUE rsock_sockaddr_obj(struct sockaddr *addr, socklen_t len);
+
+int rsock_revlookup_flag(VALUE revlookup, int *norevlookup);
+
+#ifdef HAVE_SYS_UN_H
+VALUE rsock_unixpath_str(struct sockaddr_un *sockaddr, socklen_t len);
+VALUE rsock_unixaddr(struct sockaddr_un *sockaddr, socklen_t len);
+socklen_t rsock_unix_sockaddr_len(VALUE path);
+#endif
+
+int rsock_socket(int domain, int type, int proto);
+int rsock_detect_cloexec(int fd);
+VALUE rsock_init_sock(VALUE sock, int fd);
+VALUE rsock_sock_s_socketpair(int argc, VALUE *argv, VALUE klass);
+VALUE rsock_init_inetsock(VALUE sock, VALUE remote_host, VALUE remote_serv, VALUE local_host, VALUE local_serv, int type);
+VALUE rsock_init_unixsock(VALUE sock, VALUE path, int server);
+
+struct rsock_send_arg {
+ int fd, flags;
+ VALUE mesg;
+ struct sockaddr *to;
+ socklen_t tolen;
+};
+
+VALUE rsock_sendto_blocking(void *data);
+VALUE rsock_send_blocking(void *data);
+VALUE rsock_bsock_send(int argc, VALUE *argv, VALUE sock);
+
+enum sock_recv_type {
+ RECV_RECV, /* BasicSocket#recv(no from) */
+ RECV_IP, /* IPSocket#recvfrom */
+ RECV_UNIX, /* UNIXSocket#recvfrom */
+ RECV_SOCKET /* Socket#recvfrom */
+};
+
+VALUE rsock_s_recvfrom_nonblock(VALUE sock, int argc, VALUE *argv, enum sock_recv_type from);
+VALUE rsock_s_recvfrom(VALUE sock, int argc, VALUE *argv, enum sock_recv_type from);
+
+int rsock_connect(int fd, const struct sockaddr *sockaddr, int len, int socks);
+
+VALUE rsock_s_accept(VALUE klass, int fd, struct sockaddr *sockaddr, socklen_t *len);
+VALUE rsock_s_accept_nonblock(VALUE klass, rb_io_t *fptr, struct sockaddr *sockaddr, socklen_t *len);
+VALUE rsock_sock_listen(VALUE sock, VALUE log);
+
+VALUE rsock_sockopt_new(int family, int level, int optname, VALUE data);
+
+#if defined(HAVE_SENDMSG)
+VALUE rsock_bsock_sendmsg(int argc, VALUE *argv, VALUE sock);
+VALUE rsock_bsock_sendmsg_nonblock(int argc, VALUE *argv, VALUE sock);
+#else
+#define rsock_bsock_sendmsg rb_f_notimplement
+#define rsock_bsock_sendmsg_nonblock rb_f_notimplement
+#endif
+
+#if defined(HAVE_RECVMSG)
+VALUE rsock_bsock_recvmsg(int argc, VALUE *argv, VALUE sock);
+VALUE rsock_bsock_recvmsg_nonblock(int argc, VALUE *argv, VALUE sock);
+ssize_t rsock_recvmsg(int socket, struct msghdr *message, int flags);
+#else
+#define rsock_bsock_recvmsg rb_f_notimplement
+#define rsock_bsock_recvmsg_nonblock rb_f_notimplement
+#endif
+
+#ifdef HAVE_STRUCT_MSGHDR_MSG_CONTROL
+void rsock_discard_cmsg_resource(struct msghdr *mh, int msg_peek_p);
+#endif
+
+void rsock_init_basicsocket(void);
+void rsock_init_ipsocket(void);
+void rsock_init_tcpsocket(void);
+void rsock_init_tcpserver(void);
+void rsock_init_sockssocket(void);
+void rsock_init_udpsocket(void);
+void rsock_init_unixsocket(void);
+void rsock_init_unixserver(void);
+void rsock_init_socket_constants(void);
+void rsock_init_ancdata(void);
+void rsock_init_addrinfo(void);
+void rsock_init_sockopt(void);
+void rsock_init_sockifaddr(void);
+void rsock_init_socket_init(void);
+
+NORETURN(void rsock_syserr_fail_host_port(int err, const char *, VALUE, VALUE));
+NORETURN(void rsock_syserr_fail_path(int err, const char *, VALUE));
+NORETURN(void rsock_syserr_fail_sockaddr(int err, const char *mesg, struct sockaddr *addr, socklen_t len));
+NORETURN(void rsock_syserr_fail_raddrinfo(int err, const char *mesg, VALUE rai));
+NORETURN(void rsock_syserr_fail_raddrinfo_or_sockaddr(int err, const char *mesg, VALUE addr, VALUE rai));
+
+NORETURN(void rsock_sys_fail_host_port(const char *, VALUE, VALUE));
+NORETURN(void rsock_sys_fail_path(const char *, VALUE));
+NORETURN(void rsock_sys_fail_sockaddr(const char *, struct sockaddr *addr, socklen_t len));
+NORETURN(void rsock_sys_fail_raddrinfo(const char *, VALUE rai));
+NORETURN(void rsock_sys_fail_raddrinfo_or_sockaddr(const char *, VALUE addr, VALUE rai));
+
+/*
+ * It is safe on Linux to attempt using a socket without waiting on it in
+ * all cases. For some syscalls (e.g. accept/accept4), blocking on the
+ * syscall instead of relying on select/poll allows the kernel to use
+ * "wake-one" behavior and avoid the thundering herd problem.
+ * This is likely safe on all other *nix-like systems, so this whitelist
+ * can be expanded by interested parties.
+ */
+#if defined(__linux__)
+static inline int rsock_maybe_fd_writable(int fd) { return 1; }
+static inline void rsock_maybe_wait_fd(int fd) { }
+#else /* some systems (mswin/mingw) need these. ref: r36946 */
+# define rsock_maybe_fd_writable(fd) rb_thread_fd_writable((fd))
+# define rsock_maybe_wait_fd(fd) rb_thread_wait_fd((fd))
+#endif
+
+#endif
diff --git a/jni/ruby/ext/socket/socket.c b/jni/ruby/ext/socket/socket.c
new file mode 100644
index 0000000..81028c5
--- /dev/null
+++ b/jni/ruby/ext/socket/socket.c
@@ -0,0 +1,2182 @@
+/************************************************
+
+ socket.c -
+
+ created at: Thu Mar 31 12:21:29 JST 1994
+
+ Copyright (C) 1993-2007 Yukihiro Matsumoto
+
+************************************************/
+
+#include "rubysocket.h"
+
+static VALUE sock_s_unpack_sockaddr_in(VALUE, VALUE);
+
+void
+rsock_sys_fail_host_port(const char *mesg, VALUE host, VALUE port)
+{
+ rsock_syserr_fail_host_port(errno, mesg, host, port);
+}
+
+void
+rsock_syserr_fail_host_port(int err, const char *mesg, VALUE host, VALUE port)
+{
+ VALUE message;
+
+ message = rb_sprintf("%s for %+"PRIsVALUE" port % "PRIsVALUE"",
+ mesg, host, port);
+
+ rb_syserr_fail_str(err, message);
+}
+
+void
+rsock_sys_fail_path(const char *mesg, VALUE path)
+{
+ rsock_syserr_fail_path(errno, mesg, path);
+}
+
+void
+rsock_syserr_fail_path(int err, const char *mesg, VALUE path)
+{
+ VALUE message;
+
+ if (RB_TYPE_P(path, T_STRING)) {
+ message = rb_sprintf("%s for % "PRIsVALUE"", mesg, path);
+ rb_syserr_fail_str(err, message);
+ }
+ else {
+ rb_syserr_fail(err, mesg);
+ }
+}
+
+void
+rsock_sys_fail_sockaddr(const char *mesg, struct sockaddr *addr, socklen_t len)
+{
+ rsock_syserr_fail_sockaddr(errno, mesg, addr, len);
+}
+
+void
+rsock_syserr_fail_sockaddr(int err, const char *mesg, struct sockaddr *addr, socklen_t len)
+{
+ VALUE rai;
+
+ rai = rsock_addrinfo_new(addr, len, PF_UNSPEC, 0, 0, Qnil, Qnil);
+
+ rsock_syserr_fail_raddrinfo(err, mesg, rai);
+}
+
+void
+rsock_sys_fail_raddrinfo(const char *mesg, VALUE rai)
+{
+ rsock_syserr_fail_raddrinfo(errno, mesg, rai);
+}
+
+void
+rsock_syserr_fail_raddrinfo(int err, const char *mesg, VALUE rai)
+{
+ VALUE str, message;
+
+ str = rsock_addrinfo_inspect_sockaddr(rai);
+ message = rb_sprintf("%s for %"PRIsVALUE"", mesg, str);
+
+ rb_syserr_fail_str(err, message);
+}
+
+void
+rsock_sys_fail_raddrinfo_or_sockaddr(const char *mesg, VALUE addr, VALUE rai)
+{
+ rsock_syserr_fail_raddrinfo_or_sockaddr(errno, mesg, addr, rai);
+}
+
+void
+rsock_syserr_fail_raddrinfo_or_sockaddr(int err, const char *mesg, VALUE addr, VALUE rai)
+{
+ if (NIL_P(rai)) {
+ StringValue(addr);
+
+ rsock_syserr_fail_sockaddr(err, mesg,
+ (struct sockaddr *)RSTRING_PTR(addr),
+ (socklen_t)RSTRING_LEN(addr)); /* overflow should be checked already */
+ }
+ else
+ rsock_syserr_fail_raddrinfo(err, mesg, rai);
+}
+
+static void
+setup_domain_and_type(VALUE domain, int *dv, VALUE type, int *tv)
+{
+ *dv = rsock_family_arg(domain);
+ *tv = rsock_socktype_arg(type);
+}
+
+/*
+ * call-seq:
+ * Socket.new(domain, socktype [, protocol]) => socket
+ *
+ * Creates a new socket object.
+ *
+ * _domain_ should be a communications domain such as: :INET, :INET6, :UNIX, etc.
+ *
+ * _socktype_ should be a socket type such as: :STREAM, :DGRAM, :RAW, etc.
+ *
+ * _protocol_ is optional and should be a protocol defined in the domain.
+ * If protocol is not given, 0 is used internally.
+ *
+ * Socket.new(:INET, :STREAM) # TCP socket
+ * Socket.new(:INET, :DGRAM) # UDP socket
+ * Socket.new(:UNIX, :STREAM) # UNIX stream socket
+ * Socket.new(:UNIX, :DGRAM) # UNIX datagram socket
+ */
+static VALUE
+sock_initialize(int argc, VALUE *argv, VALUE sock)
+{
+ VALUE domain, type, protocol;
+ int fd;
+ int d, t;
+
+ rb_scan_args(argc, argv, "21", &domain, &type, &protocol);
+ if (NIL_P(protocol))
+ protocol = INT2FIX(0);
+
+ rb_secure(3);
+ setup_domain_and_type(domain, &d, type, &t);
+ fd = rsock_socket(d, t, NUM2INT(protocol));
+ if (fd < 0) rb_sys_fail("socket(2)");
+
+ return rsock_init_sock(sock, fd);
+}
+
+#if defined HAVE_SOCKETPAIR
+static VALUE
+io_call_close(VALUE io)
+{
+ return rb_funcall(io, rb_intern("close"), 0, 0);
+}
+
+static VALUE
+io_close(VALUE io)
+{
+ return rb_rescue(io_call_close, io, 0, 0);
+}
+
+static VALUE
+pair_yield(VALUE pair)
+{
+ return rb_ensure(rb_yield, pair, io_close, rb_ary_entry(pair, 1));
+}
+#endif
+
+#if defined HAVE_SOCKETPAIR
+
+#ifdef SOCK_CLOEXEC
+static int
+rsock_socketpair0(int domain, int type, int protocol, int sv[2])
+{
+ int ret;
+ static int cloexec_state = -1; /* <0: unknown, 0: ignored, >0: working */
+
+ if (cloexec_state > 0) { /* common path, if SOCK_CLOEXEC is defined */
+ ret = socketpair(domain, type|SOCK_CLOEXEC, protocol, sv);
+ if (ret == 0 && (sv[0] <= 2 || sv[1] <= 2)) {
+ goto fix_cloexec; /* highly unlikely */
+ }
+ goto update_max_fd;
+ }
+ else if (cloexec_state < 0) { /* usually runs once only for detection */
+ ret = socketpair(domain, type|SOCK_CLOEXEC, protocol, sv);
+ if (ret == 0) {
+ cloexec_state = rsock_detect_cloexec(sv[0]);
+ if ((cloexec_state == 0) || (sv[0] <= 2 || sv[1] <= 2))
+ goto fix_cloexec;
+ goto update_max_fd;
+ }
+ else if (ret == -1 && errno == EINVAL) {
+ /* SOCK_CLOEXEC is available since Linux 2.6.27. Linux 2.6.18 fails with EINVAL */
+ ret = socketpair(domain, type, protocol, sv);
+ if (ret != -1) {
+ /* The reason of EINVAL may be other than SOCK_CLOEXEC.
+ * So disable SOCK_CLOEXEC only if socketpair() succeeds without SOCK_CLOEXEC.
+ * Ex. Socket.pair(:UNIX, 0xff) fails with EINVAL.
+ */
+ cloexec_state = 0;
+ }
+ }
+ }
+ else { /* cloexec_state == 0 */
+ ret = socketpair(domain, type, protocol, sv);
+ }
+ if (ret == -1) {
+ return -1;
+ }
+
+fix_cloexec:
+ rb_maygvl_fd_fix_cloexec(sv[0]);
+ rb_maygvl_fd_fix_cloexec(sv[1]);
+
+update_max_fd:
+ rb_update_max_fd(sv[0]);
+ rb_update_max_fd(sv[1]);
+
+ return ret;
+}
+#else /* !SOCK_CLOEXEC */
+static int
+rsock_socketpair0(int domain, int type, int protocol, int sv[2])
+{
+ int ret = socketpair(domain, type, protocol, sv);
+
+ if (ret == -1)
+ return -1;
+
+ rb_fd_fix_cloexec(sv[0]);
+ rb_fd_fix_cloexec(sv[1]);
+ return ret;
+}
+#endif /* !SOCK_CLOEXEC */
+
+static int
+rsock_socketpair(int domain, int type, int protocol, int sv[2])
+{
+ int ret;
+
+ ret = rsock_socketpair0(domain, type, protocol, sv);
+ if (ret < 0 && (errno == EMFILE || errno == ENFILE)) {
+ rb_gc();
+ ret = rsock_socketpair0(domain, type, protocol, sv);
+ }
+
+ return ret;
+}
+
+/*
+ * call-seq:
+ * Socket.pair(domain, type, protocol) => [socket1, socket2]
+ * Socket.socketpair(domain, type, protocol) => [socket1, socket2]
+ *
+ * Creates a pair of sockets connected each other.
+ *
+ * _domain_ should be a communications domain such as: :INET, :INET6, :UNIX, etc.
+ *
+ * _socktype_ should be a socket type such as: :STREAM, :DGRAM, :RAW, etc.
+ *
+ * _protocol_ should be a protocol defined in the domain,
+ * defaults to 0 for the domain.
+ *
+ * s1, s2 = Socket.pair(:UNIX, :STREAM, 0)
+ * s1.send "a", 0
+ * s1.send "b", 0
+ * s1.close
+ * p s2.recv(10) #=> "ab"
+ * p s2.recv(10) #=> ""
+ * p s2.recv(10) #=> ""
+ *
+ * s1, s2 = Socket.pair(:UNIX, :DGRAM, 0)
+ * s1.send "a", 0
+ * s1.send "b", 0
+ * p s2.recv(10) #=> "a"
+ * p s2.recv(10) #=> "b"
+ *
+ */
+VALUE
+rsock_sock_s_socketpair(int argc, VALUE *argv, VALUE klass)
+{
+ VALUE domain, type, protocol;
+ int d, t, p, sp[2];
+ int ret;
+ VALUE s1, s2, r;
+
+ rb_scan_args(argc, argv, "21", &domain, &type, &protocol);
+ if (NIL_P(protocol))
+ protocol = INT2FIX(0);
+
+ setup_domain_and_type(domain, &d, type, &t);
+ p = NUM2INT(protocol);
+ ret = rsock_socketpair(d, t, p, sp);
+ if (ret < 0) {
+ rb_sys_fail("socketpair(2)");
+ }
+
+ s1 = rsock_init_sock(rb_obj_alloc(klass), sp[0]);
+ s2 = rsock_init_sock(rb_obj_alloc(klass), sp[1]);
+ r = rb_assoc_new(s1, s2);
+ if (rb_block_given_p()) {
+ return rb_ensure(pair_yield, r, io_close, s1);
+ }
+ return r;
+}
+#else
+#define rsock_sock_s_socketpair rb_f_notimplement
+#endif
+
+/*
+ * call-seq:
+ * socket.connect(remote_sockaddr) => 0
+ *
+ * Requests a connection to be made on the given +remote_sockaddr+. Returns 0 if
+ * successful, otherwise an exception is raised.
+ *
+ * === Parameter
+ * * +remote_sockaddr+ - the +struct+ sockaddr contained in a string or Addrinfo object
+ *
+ * === Example:
+ * # Pull down Google's web page
+ * require 'socket'
+ * include Socket::Constants
+ * socket = Socket.new( AF_INET, SOCK_STREAM, 0 )
+ * sockaddr = Socket.pack_sockaddr_in( 80, 'www.google.com' )
+ * socket.connect( sockaddr )
+ * socket.write( "GET / HTTP/1.0\r\n\r\n" )
+ * results = socket.read
+ *
+ * === Unix-based Exceptions
+ * On unix-based systems the following system exceptions may be raised if
+ * the call to _connect_ fails:
+ * * Errno::EACCES - search permission is denied for a component of the prefix
+ * path or write access to the +socket+ is denied
+ * * Errno::EADDRINUSE - the _sockaddr_ is already in use
+ * * Errno::EADDRNOTAVAIL - the specified _sockaddr_ is not available from the
+ * local machine
+ * * Errno::EAFNOSUPPORT - the specified _sockaddr_ is not a valid address for
+ * the address family of the specified +socket+
+ * * Errno::EALREADY - a connection is already in progress for the specified
+ * socket
+ * * Errno::EBADF - the +socket+ is not a valid file descriptor
+ * * Errno::ECONNREFUSED - the target _sockaddr_ was not listening for connections
+ * refused the connection request
+ * * Errno::ECONNRESET - the remote host reset the connection request
+ * * Errno::EFAULT - the _sockaddr_ cannot be accessed
+ * * Errno::EHOSTUNREACH - the destination host cannot be reached (probably
+ * because the host is down or a remote router cannot reach it)
+ * * Errno::EINPROGRESS - the O_NONBLOCK is set for the +socket+ and the
+ * connection cannot be immediately established; the connection will be
+ * established asynchronously
+ * * Errno::EINTR - the attempt to establish the connection was interrupted by
+ * delivery of a signal that was caught; the connection will be established
+ * asynchronously
+ * * Errno::EISCONN - the specified +socket+ is already connected
+ * * Errno::EINVAL - the address length used for the _sockaddr_ is not a valid
+ * length for the address family or there is an invalid family in _sockaddr_
+ * * Errno::ENAMETOOLONG - the pathname resolved had a length which exceeded
+ * PATH_MAX
+ * * Errno::ENETDOWN - the local interface used to reach the destination is down
+ * * Errno::ENETUNREACH - no route to the network is present
+ * * Errno::ENOBUFS - no buffer space is available
+ * * Errno::ENOSR - there were insufficient STREAMS resources available to
+ * complete the operation
+ * * Errno::ENOTSOCK - the +socket+ argument does not refer to a socket
+ * * Errno::EOPNOTSUPP - the calling +socket+ is listening and cannot be connected
+ * * Errno::EPROTOTYPE - the _sockaddr_ has a different type than the socket
+ * bound to the specified peer address
+ * * Errno::ETIMEDOUT - the attempt to connect time out before a connection
+ * was made.
+ *
+ * On unix-based systems if the address family of the calling +socket+ is
+ * AF_UNIX the follow exceptions may be raised if the call to _connect_
+ * fails:
+ * * Errno::EIO - an i/o error occurred while reading from or writing to the
+ * file system
+ * * Errno::ELOOP - too many symbolic links were encountered in translating
+ * the pathname in _sockaddr_
+ * * Errno::ENAMETOOLLONG - a component of a pathname exceeded NAME_MAX
+ * characters, or an entire pathname exceeded PATH_MAX characters
+ * * Errno::ENOENT - a component of the pathname does not name an existing file
+ * or the pathname is an empty string
+ * * Errno::ENOTDIR - a component of the path prefix of the pathname in _sockaddr_
+ * is not a directory
+ *
+ * === Windows Exceptions
+ * On Windows systems the following system exceptions may be raised if
+ * the call to _connect_ fails:
+ * * Errno::ENETDOWN - the network is down
+ * * Errno::EADDRINUSE - the socket's local address is already in use
+ * * Errno::EINTR - the socket was cancelled
+ * * Errno::EINPROGRESS - a blocking socket is in progress or the service provider
+ * is still processing a callback function. Or a nonblocking connect call is
+ * in progress on the +socket+.
+ * * Errno::EALREADY - see Errno::EINVAL
+ * * Errno::EADDRNOTAVAIL - the remote address is not a valid address, such as
+ * ADDR_ANY TODO check ADDRANY TO INADDR_ANY
+ * * Errno::EAFNOSUPPORT - addresses in the specified family cannot be used with
+ * with this +socket+
+ * * Errno::ECONNREFUSED - the target _sockaddr_ was not listening for connections
+ * refused the connection request
+ * * Errno::EFAULT - the socket's internal address or address length parameter
+ * is too small or is not a valid part of the user space address
+ * * Errno::EINVAL - the +socket+ is a listening socket
+ * * Errno::EISCONN - the +socket+ is already connected
+ * * Errno::ENETUNREACH - the network cannot be reached from this host at this time
+ * * Errno::EHOSTUNREACH - no route to the network is present
+ * * Errno::ENOBUFS - no buffer space is available
+ * * Errno::ENOTSOCK - the +socket+ argument does not refer to a socket
+ * * Errno::ETIMEDOUT - the attempt to connect time out before a connection
+ * was made.
+ * * Errno::EWOULDBLOCK - the socket is marked as nonblocking and the
+ * connection cannot be completed immediately
+ * * Errno::EACCES - the attempt to connect the datagram socket to the
+ * broadcast address failed
+ *
+ * === See
+ * * connect manual pages on unix-based systems
+ * * connect function in Microsoft's Winsock functions reference
+ */
+static VALUE
+sock_connect(VALUE sock, VALUE addr)
+{
+ VALUE rai;
+ rb_io_t *fptr;
+ int fd, n;
+
+ SockAddrStringValueWithAddrinfo(addr, rai);
+ addr = rb_str_new4(addr);
+ GetOpenFile(sock, fptr);
+ fd = fptr->fd;
+ n = rsock_connect(fd, (struct sockaddr*)RSTRING_PTR(addr), RSTRING_SOCKLEN(addr), 0);
+ if (n < 0) {
+ rsock_sys_fail_raddrinfo_or_sockaddr("connect(2)", addr, rai);
+ }
+
+ return INT2FIX(n);
+}
+
+/*
+ * call-seq:
+ * socket.connect_nonblock(remote_sockaddr) => 0
+ *
+ * Requests a connection to be made on the given +remote_sockaddr+ after
+ * O_NONBLOCK is set for the underlying file descriptor.
+ * Returns 0 if successful, otherwise an exception is raised.
+ *
+ * === Parameter
+ * * +remote_sockaddr+ - the +struct+ sockaddr contained in a string or Addrinfo object
+ *
+ * === Example:
+ * # Pull down Google's web page
+ * require 'socket'
+ * include Socket::Constants
+ * socket = Socket.new(AF_INET, SOCK_STREAM, 0)
+ * sockaddr = Socket.sockaddr_in(80, 'www.google.com')
+ * begin # emulate blocking connect
+ * socket.connect_nonblock(sockaddr)
+ * rescue IO::WaitWritable
+ * IO.select(nil, [socket]) # wait 3-way handshake completion
+ * begin
+ * socket.connect_nonblock(sockaddr) # check connection failure
+ * rescue Errno::EISCONN
+ * end
+ * end
+ * socket.write("GET / HTTP/1.0\r\n\r\n")
+ * results = socket.read
+ *
+ * Refer to Socket#connect for the exceptions that may be thrown if the call
+ * to _connect_nonblock_ fails.
+ *
+ * Socket#connect_nonblock may raise any error corresponding to connect(2) failure,
+ * including Errno::EINPROGRESS.
+ *
+ * If the exception is Errno::EINPROGRESS,
+ * it is extended by IO::WaitWritable.
+ * So IO::WaitWritable can be used to rescue the exceptions for retrying connect_nonblock.
+ *
+ * === See
+ * * Socket#connect
+ */
+static VALUE
+sock_connect_nonblock(VALUE sock, VALUE addr)
+{
+ VALUE rai;
+ rb_io_t *fptr;
+ int n;
+
+ SockAddrStringValueWithAddrinfo(addr, rai);
+ addr = rb_str_new4(addr);
+ GetOpenFile(sock, fptr);
+ rb_io_set_nonblock(fptr);
+ n = connect(fptr->fd, (struct sockaddr*)RSTRING_PTR(addr), RSTRING_SOCKLEN(addr));
+ if (n < 0) {
+ if (errno == EINPROGRESS)
+ rb_readwrite_sys_fail(RB_IO_WAIT_WRITABLE, "connect(2) would block");
+ rsock_sys_fail_raddrinfo_or_sockaddr("connect(2)", addr, rai);
+ }
+
+ return INT2FIX(n);
+}
+
+/*
+ * call-seq:
+ * socket.bind(local_sockaddr) => 0
+ *
+ * Binds to the given local address.
+ *
+ * === Parameter
+ * * +local_sockaddr+ - the +struct+ sockaddr contained in a string or an Addrinfo object
+ *
+ * === Example
+ * require 'socket'
+ *
+ * # use Addrinfo
+ * socket = Socket.new(:INET, :STREAM, 0)
+ * socket.bind(Addrinfo.tcp("127.0.0.1", 2222))
+ * p socket.local_address #=> #<Addrinfo: 127.0.0.1:2222 TCP>
+ *
+ * # use struct sockaddr
+ * include Socket::Constants
+ * socket = Socket.new( AF_INET, SOCK_STREAM, 0 )
+ * sockaddr = Socket.pack_sockaddr_in( 2200, 'localhost' )
+ * socket.bind( sockaddr )
+ *
+ * === Unix-based Exceptions
+ * On unix-based based systems the following system exceptions may be raised if
+ * the call to _bind_ fails:
+ * * Errno::EACCES - the specified _sockaddr_ is protected and the current
+ * user does not have permission to bind to it
+ * * Errno::EADDRINUSE - the specified _sockaddr_ is already in use
+ * * Errno::EADDRNOTAVAIL - the specified _sockaddr_ is not available from the
+ * local machine
+ * * Errno::EAFNOSUPPORT - the specified _sockaddr_ is not a valid address for
+ * the family of the calling +socket+
+ * * Errno::EBADF - the _sockaddr_ specified is not a valid file descriptor
+ * * Errno::EFAULT - the _sockaddr_ argument cannot be accessed
+ * * Errno::EINVAL - the +socket+ is already bound to an address, and the
+ * protocol does not support binding to the new _sockaddr_ or the +socket+
+ * has been shut down.
+ * * Errno::EINVAL - the address length is not a valid length for the address
+ * family
+ * * Errno::ENAMETOOLONG - the pathname resolved had a length which exceeded
+ * PATH_MAX
+ * * Errno::ENOBUFS - no buffer space is available
+ * * Errno::ENOSR - there were insufficient STREAMS resources available to
+ * complete the operation
+ * * Errno::ENOTSOCK - the +socket+ does not refer to a socket
+ * * Errno::EOPNOTSUPP - the socket type of the +socket+ does not support
+ * binding to an address
+ *
+ * On unix-based based systems if the address family of the calling +socket+ is
+ * Socket::AF_UNIX the follow exceptions may be raised if the call to _bind_
+ * fails:
+ * * Errno::EACCES - search permission is denied for a component of the prefix
+ * path or write access to the +socket+ is denied
+ * * Errno::EDESTADDRREQ - the _sockaddr_ argument is a null pointer
+ * * Errno::EISDIR - same as Errno::EDESTADDRREQ
+ * * Errno::EIO - an i/o error occurred
+ * * Errno::ELOOP - too many symbolic links were encountered in translating
+ * the pathname in _sockaddr_
+ * * Errno::ENAMETOOLLONG - a component of a pathname exceeded NAME_MAX
+ * characters, or an entire pathname exceeded PATH_MAX characters
+ * * Errno::ENOENT - a component of the pathname does not name an existing file
+ * or the pathname is an empty string
+ * * Errno::ENOTDIR - a component of the path prefix of the pathname in _sockaddr_
+ * is not a directory
+ * * Errno::EROFS - the name would reside on a read only filesystem
+ *
+ * === Windows Exceptions
+ * On Windows systems the following system exceptions may be raised if
+ * the call to _bind_ fails:
+ * * Errno::ENETDOWN-- the network is down
+ * * Errno::EACCES - the attempt to connect the datagram socket to the
+ * broadcast address failed
+ * * Errno::EADDRINUSE - the socket's local address is already in use
+ * * Errno::EADDRNOTAVAIL - the specified address is not a valid address for this
+ * computer
+ * * Errno::EFAULT - the socket's internal address or address length parameter
+ * is too small or is not a valid part of the user space addressed
+ * * Errno::EINVAL - the +socket+ is already bound to an address
+ * * Errno::ENOBUFS - no buffer space is available
+ * * Errno::ENOTSOCK - the +socket+ argument does not refer to a socket
+ *
+ * === See
+ * * bind manual pages on unix-based systems
+ * * bind function in Microsoft's Winsock functions reference
+ */
+static VALUE
+sock_bind(VALUE sock, VALUE addr)
+{
+ VALUE rai;
+ rb_io_t *fptr;
+
+ SockAddrStringValueWithAddrinfo(addr, rai);
+ GetOpenFile(sock, fptr);
+ if (bind(fptr->fd, (struct sockaddr*)RSTRING_PTR(addr), RSTRING_SOCKLEN(addr)) < 0)
+ rsock_sys_fail_raddrinfo_or_sockaddr("bind(2)", addr, rai);
+
+ return INT2FIX(0);
+}
+
+/*
+ * call-seq:
+ * socket.listen( int ) => 0
+ *
+ * Listens for connections, using the specified +int+ as the backlog. A call
+ * to _listen_ only applies if the +socket+ is of type SOCK_STREAM or
+ * SOCK_SEQPACKET.
+ *
+ * === Parameter
+ * * +backlog+ - the maximum length of the queue for pending connections.
+ *
+ * === Example 1
+ * require 'socket'
+ * include Socket::Constants
+ * socket = Socket.new( AF_INET, SOCK_STREAM, 0 )
+ * sockaddr = Socket.pack_sockaddr_in( 2200, 'localhost' )
+ * socket.bind( sockaddr )
+ * socket.listen( 5 )
+ *
+ * === Example 2 (listening on an arbitrary port, unix-based systems only):
+ * require 'socket'
+ * include Socket::Constants
+ * socket = Socket.new( AF_INET, SOCK_STREAM, 0 )
+ * socket.listen( 1 )
+ *
+ * === Unix-based Exceptions
+ * On unix based systems the above will work because a new +sockaddr+ struct
+ * is created on the address ADDR_ANY, for an arbitrary port number as handed
+ * off by the kernel. It will not work on Windows, because Windows requires that
+ * the +socket+ is bound by calling _bind_ before it can _listen_.
+ *
+ * If the _backlog_ amount exceeds the implementation-dependent maximum
+ * queue length, the implementation's maximum queue length will be used.
+ *
+ * On unix-based based systems the following system exceptions may be raised if the
+ * call to _listen_ fails:
+ * * Errno::EBADF - the _socket_ argument is not a valid file descriptor
+ * * Errno::EDESTADDRREQ - the _socket_ is not bound to a local address, and
+ * the protocol does not support listening on an unbound socket
+ * * Errno::EINVAL - the _socket_ is already connected
+ * * Errno::ENOTSOCK - the _socket_ argument does not refer to a socket
+ * * Errno::EOPNOTSUPP - the _socket_ protocol does not support listen
+ * * Errno::EACCES - the calling process does not have appropriate privileges
+ * * Errno::EINVAL - the _socket_ has been shut down
+ * * Errno::ENOBUFS - insufficient resources are available in the system to
+ * complete the call
+ *
+ * === Windows Exceptions
+ * On Windows systems the following system exceptions may be raised if
+ * the call to _listen_ fails:
+ * * Errno::ENETDOWN - the network is down
+ * * Errno::EADDRINUSE - the socket's local address is already in use. This
+ * usually occurs during the execution of _bind_ but could be delayed
+ * if the call to _bind_ was to a partially wildcard address (involving
+ * ADDR_ANY) and if a specific address needs to be committed at the
+ * time of the call to _listen_
+ * * Errno::EINPROGRESS - a Windows Sockets 1.1 call is in progress or the
+ * service provider is still processing a callback function
+ * * Errno::EINVAL - the +socket+ has not been bound with a call to _bind_.
+ * * Errno::EISCONN - the +socket+ is already connected
+ * * Errno::EMFILE - no more socket descriptors are available
+ * * Errno::ENOBUFS - no buffer space is available
+ * * Errno::ENOTSOC - +socket+ is not a socket
+ * * Errno::EOPNOTSUPP - the referenced +socket+ is not a type that supports
+ * the _listen_ method
+ *
+ * === See
+ * * listen manual pages on unix-based systems
+ * * listen function in Microsoft's Winsock functions reference
+ */
+VALUE
+rsock_sock_listen(VALUE sock, VALUE log)
+{
+ rb_io_t *fptr;
+ int backlog;
+
+ backlog = NUM2INT(log);
+ GetOpenFile(sock, fptr);
+ if (listen(fptr->fd, backlog) < 0)
+ rb_sys_fail("listen(2)");
+
+ return INT2FIX(0);
+}
+
+/*
+ * call-seq:
+ * socket.recvfrom(maxlen) => [mesg, sender_addrinfo]
+ * socket.recvfrom(maxlen, flags) => [mesg, sender_addrinfo]
+ *
+ * Receives up to _maxlen_ bytes from +socket+. _flags_ is zero or more
+ * of the +MSG_+ options. The first element of the results, _mesg_, is the data
+ * received. The second element, _sender_addrinfo_, contains protocol-specific
+ * address information of the sender.
+ *
+ * === Parameters
+ * * +maxlen+ - the maximum number of bytes to receive from the socket
+ * * +flags+ - zero or more of the +MSG_+ options
+ *
+ * === Example
+ * # In one file, start this first
+ * require 'socket'
+ * include Socket::Constants
+ * socket = Socket.new( AF_INET, SOCK_STREAM, 0 )
+ * sockaddr = Socket.pack_sockaddr_in( 2200, 'localhost' )
+ * socket.bind( sockaddr )
+ * socket.listen( 5 )
+ * client, client_addrinfo = socket.accept
+ * data = client.recvfrom( 20 )[0].chomp
+ * puts "I only received 20 bytes '#{data}'"
+ * sleep 1
+ * socket.close
+ *
+ * # In another file, start this second
+ * require 'socket'
+ * include Socket::Constants
+ * socket = Socket.new( AF_INET, SOCK_STREAM, 0 )
+ * sockaddr = Socket.pack_sockaddr_in( 2200, 'localhost' )
+ * socket.connect( sockaddr )
+ * socket.puts "Watch this get cut short!"
+ * socket.close
+ *
+ * === Unix-based Exceptions
+ * On unix-based based systems the following system exceptions may be raised if the
+ * call to _recvfrom_ fails:
+ * * Errno::EAGAIN - the +socket+ file descriptor is marked as O_NONBLOCK and no
+ * data is waiting to be received; or MSG_OOB is set and no out-of-band data
+ * is available and either the +socket+ file descriptor is marked as
+ * O_NONBLOCK or the +socket+ does not support blocking to wait for
+ * out-of-band-data
+ * * Errno::EWOULDBLOCK - see Errno::EAGAIN
+ * * Errno::EBADF - the +socket+ is not a valid file descriptor
+ * * Errno::ECONNRESET - a connection was forcibly closed by a peer
+ * * Errno::EFAULT - the socket's internal buffer, address or address length
+ * cannot be accessed or written
+ * * Errno::EINTR - a signal interrupted _recvfrom_ before any data was available
+ * * Errno::EINVAL - the MSG_OOB flag is set and no out-of-band data is available
+ * * Errno::EIO - an i/o error occurred while reading from or writing to the
+ * filesystem
+ * * Errno::ENOBUFS - insufficient resources were available in the system to
+ * perform the operation
+ * * Errno::ENOMEM - insufficient memory was available to fulfill the request
+ * * Errno::ENOSR - there were insufficient STREAMS resources available to
+ * complete the operation
+ * * Errno::ENOTCONN - a receive is attempted on a connection-mode socket that
+ * is not connected
+ * * Errno::ENOTSOCK - the +socket+ does not refer to a socket
+ * * Errno::EOPNOTSUPP - the specified flags are not supported for this socket type
+ * * Errno::ETIMEDOUT - the connection timed out during connection establishment
+ * or due to a transmission timeout on an active connection
+ *
+ * === Windows Exceptions
+ * On Windows systems the following system exceptions may be raised if
+ * the call to _recvfrom_ fails:
+ * * Errno::ENETDOWN - the network is down
+ * * Errno::EFAULT - the internal buffer and from parameters on +socket+ are not
+ * part of the user address space, or the internal fromlen parameter is
+ * too small to accommodate the peer address
+ * * Errno::EINTR - the (blocking) call was cancelled by an internal call to
+ * the WinSock function WSACancelBlockingCall
+ * * Errno::EINPROGRESS - a blocking Windows Sockets 1.1 call is in progress or
+ * the service provider is still processing a callback function
+ * * Errno::EINVAL - +socket+ has not been bound with a call to _bind_, or an
+ * unknown flag was specified, or MSG_OOB was specified for a socket with
+ * SO_OOBINLINE enabled, or (for byte stream-style sockets only) the internal
+ * len parameter on +socket+ was zero or negative
+ * * Errno::EISCONN - +socket+ is already connected. The call to _recvfrom_ is
+ * not permitted with a connected socket on a socket that is connection
+ * oriented or connectionless.
+ * * Errno::ENETRESET - the connection has been broken due to the keep-alive
+ * activity detecting a failure while the operation was in progress.
+ * * Errno::EOPNOTSUPP - MSG_OOB was specified, but +socket+ is not stream-style
+ * such as type SOCK_STREAM. OOB data is not supported in the communication
+ * domain associated with +socket+, or +socket+ is unidirectional and
+ * supports only send operations
+ * * Errno::ESHUTDOWN - +socket+ has been shutdown. It is not possible to
+ * call _recvfrom_ on a socket after _shutdown_ has been invoked.
+ * * Errno::EWOULDBLOCK - +socket+ is marked as nonblocking and a call to
+ * _recvfrom_ would block.
+ * * Errno::EMSGSIZE - the message was too large to fit into the specified buffer
+ * and was truncated.
+ * * Errno::ETIMEDOUT - the connection has been dropped, because of a network
+ * failure or because the system on the other end went down without
+ * notice
+ * * Errno::ECONNRESET - the virtual circuit was reset by the remote side
+ * executing a hard or abortive close. The application should close the
+ * socket; it is no longer usable. On a UDP-datagram socket this error
+ * indicates a previous send operation resulted in an ICMP Port Unreachable
+ * message.
+ */
+static VALUE
+sock_recvfrom(int argc, VALUE *argv, VALUE sock)
+{
+ return rsock_s_recvfrom(sock, argc, argv, RECV_SOCKET);
+}
+
+/*
+ * call-seq:
+ * socket.recvfrom_nonblock(maxlen) => [mesg, sender_addrinfo]
+ * socket.recvfrom_nonblock(maxlen, flags) => [mesg, sender_addrinfo]
+ *
+ * Receives up to _maxlen_ bytes from +socket+ using recvfrom(2) after
+ * O_NONBLOCK is set for the underlying file descriptor.
+ * _flags_ is zero or more of the +MSG_+ options.
+ * The first element of the results, _mesg_, is the data received.
+ * The second element, _sender_addrinfo_, contains protocol-specific address
+ * information of the sender.
+ *
+ * When recvfrom(2) returns 0, Socket#recvfrom_nonblock returns
+ * an empty string as data.
+ * The meaning depends on the socket: EOF on TCP, empty packet on UDP, etc.
+ *
+ * === Parameters
+ * * +maxlen+ - the maximum number of bytes to receive from the socket
+ * * +flags+ - zero or more of the +MSG_+ options
+ *
+ * === Example
+ * # In one file, start this first
+ * require 'socket'
+ * include Socket::Constants
+ * socket = Socket.new(AF_INET, SOCK_STREAM, 0)
+ * sockaddr = Socket.sockaddr_in(2200, 'localhost')
+ * socket.bind(sockaddr)
+ * socket.listen(5)
+ * client, client_addrinfo = socket.accept
+ * begin # emulate blocking recvfrom
+ * pair = client.recvfrom_nonblock(20)
+ * rescue IO::WaitReadable
+ * IO.select([client])
+ * retry
+ * end
+ * data = pair[0].chomp
+ * puts "I only received 20 bytes '#{data}'"
+ * sleep 1
+ * socket.close
+ *
+ * # In another file, start this second
+ * require 'socket'
+ * include Socket::Constants
+ * socket = Socket.new(AF_INET, SOCK_STREAM, 0)
+ * sockaddr = Socket.sockaddr_in(2200, 'localhost')
+ * socket.connect(sockaddr)
+ * socket.puts "Watch this get cut short!"
+ * socket.close
+ *
+ * Refer to Socket#recvfrom for the exceptions that may be thrown if the call
+ * to _recvfrom_nonblock_ fails.
+ *
+ * Socket#recvfrom_nonblock may raise any error corresponding to recvfrom(2) failure,
+ * including Errno::EWOULDBLOCK.
+ *
+ * If the exception is Errno::EWOULDBLOCK or Errno::AGAIN,
+ * it is extended by IO::WaitReadable.
+ * So IO::WaitReadable can be used to rescue the exceptions for retrying recvfrom_nonblock.
+ *
+ * === See
+ * * Socket#recvfrom
+ */
+static VALUE
+sock_recvfrom_nonblock(int argc, VALUE *argv, VALUE sock)
+{
+ return rsock_s_recvfrom_nonblock(sock, argc, argv, RECV_SOCKET);
+}
+
+/*
+ * call-seq:
+ * socket.accept => [client_socket, client_addrinfo]
+ *
+ * Accepts a next connection.
+ * Returns a new Socket object and Addrinfo object.
+ *
+ * serv = Socket.new(:INET, :STREAM, 0)
+ * serv.listen(5)
+ * c = Socket.new(:INET, :STREAM, 0)
+ * c.connect(serv.connect_address)
+ * p serv.accept #=> [#<Socket:fd 6>, #<Addrinfo: 127.0.0.1:48555 TCP>]
+ *
+ */
+static VALUE
+sock_accept(VALUE sock)
+{
+ rb_io_t *fptr;
+ VALUE sock2;
+ union_sockaddr buf;
+ socklen_t len = (socklen_t)sizeof buf;
+
+ GetOpenFile(sock, fptr);
+ sock2 = rsock_s_accept(rb_cSocket,fptr->fd,&buf.addr,&len);
+
+ return rb_assoc_new(sock2, rsock_io_socket_addrinfo(sock2, &buf.addr, len));
+}
+
+/*
+ * call-seq:
+ * socket.accept_nonblock => [client_socket, client_addrinfo]
+ *
+ * Accepts an incoming connection using accept(2) after
+ * O_NONBLOCK is set for the underlying file descriptor.
+ * It returns an array containing the accepted socket
+ * for the incoming connection, _client_socket_,
+ * and an Addrinfo, _client_addrinfo_.
+ *
+ * === Example
+ * # In one script, start this first
+ * require 'socket'
+ * include Socket::Constants
+ * socket = Socket.new(AF_INET, SOCK_STREAM, 0)
+ * sockaddr = Socket.sockaddr_in(2200, 'localhost')
+ * socket.bind(sockaddr)
+ * socket.listen(5)
+ * begin # emulate blocking accept
+ * client_socket, client_addrinfo = socket.accept_nonblock
+ * rescue IO::WaitReadable, Errno::EINTR
+ * IO.select([socket])
+ * retry
+ * end
+ * puts "The client said, '#{client_socket.readline.chomp}'"
+ * client_socket.puts "Hello from script one!"
+ * socket.close
+ *
+ * # In another script, start this second
+ * require 'socket'
+ * include Socket::Constants
+ * socket = Socket.new(AF_INET, SOCK_STREAM, 0)
+ * sockaddr = Socket.sockaddr_in(2200, 'localhost')
+ * socket.connect(sockaddr)
+ * socket.puts "Hello from script 2."
+ * puts "The server said, '#{socket.readline.chomp}'"
+ * socket.close
+ *
+ * Refer to Socket#accept for the exceptions that may be thrown if the call
+ * to _accept_nonblock_ fails.
+ *
+ * Socket#accept_nonblock may raise any error corresponding to accept(2) failure,
+ * including Errno::EWOULDBLOCK.
+ *
+ * If the exception is Errno::EWOULDBLOCK, Errno::AGAIN, Errno::ECONNABORTED or Errno::EPROTO,
+ * it is extended by IO::WaitReadable.
+ * So IO::WaitReadable can be used to rescue the exceptions for retrying accept_nonblock.
+ *
+ * === See
+ * * Socket#accept
+ */
+static VALUE
+sock_accept_nonblock(VALUE sock)
+{
+ rb_io_t *fptr;
+ VALUE sock2;
+ union_sockaddr buf;
+ socklen_t len = (socklen_t)sizeof buf;
+
+ GetOpenFile(sock, fptr);
+ sock2 = rsock_s_accept_nonblock(rb_cSocket, fptr, &buf.addr, &len);
+ return rb_assoc_new(sock2, rsock_io_socket_addrinfo(sock2, &buf.addr, len));
+}
+
+/*
+ * call-seq:
+ * socket.sysaccept => [client_socket_fd, client_addrinfo]
+ *
+ * Accepts an incoming connection returning an array containing the (integer)
+ * file descriptor for the incoming connection, _client_socket_fd_,
+ * and an Addrinfo, _client_addrinfo_.
+ *
+ * === Example
+ * # In one script, start this first
+ * require 'socket'
+ * include Socket::Constants
+ * socket = Socket.new( AF_INET, SOCK_STREAM, 0 )
+ * sockaddr = Socket.pack_sockaddr_in( 2200, 'localhost' )
+ * socket.bind( sockaddr )
+ * socket.listen( 5 )
+ * client_fd, client_addrinfo = socket.sysaccept
+ * client_socket = Socket.for_fd( client_fd )
+ * puts "The client said, '#{client_socket.readline.chomp}'"
+ * client_socket.puts "Hello from script one!"
+ * socket.close
+ *
+ * # In another script, start this second
+ * require 'socket'
+ * include Socket::Constants
+ * socket = Socket.new( AF_INET, SOCK_STREAM, 0 )
+ * sockaddr = Socket.pack_sockaddr_in( 2200, 'localhost' )
+ * socket.connect( sockaddr )
+ * socket.puts "Hello from script 2."
+ * puts "The server said, '#{socket.readline.chomp}'"
+ * socket.close
+ *
+ * Refer to Socket#accept for the exceptions that may be thrown if the call
+ * to _sysaccept_ fails.
+ *
+ * === See
+ * * Socket#accept
+ */
+static VALUE
+sock_sysaccept(VALUE sock)
+{
+ rb_io_t *fptr;
+ VALUE sock2;
+ union_sockaddr buf;
+ socklen_t len = (socklen_t)sizeof buf;
+
+ GetOpenFile(sock, fptr);
+ sock2 = rsock_s_accept(0,fptr->fd,&buf.addr,&len);
+
+ return rb_assoc_new(sock2, rsock_io_socket_addrinfo(sock2, &buf.addr, len));
+}
+
+#ifdef HAVE_GETHOSTNAME
+/*
+ * call-seq:
+ * Socket.gethostname => hostname
+ *
+ * Returns the hostname.
+ *
+ * p Socket.gethostname #=> "hal"
+ *
+ * Note that it is not guaranteed to be able to convert to IP address using gethostbyname, getaddrinfo, etc.
+ * If you need local IP address, use Socket.ip_address_list.
+ */
+static VALUE
+sock_gethostname(VALUE obj)
+{
+#if defined(NI_MAXHOST)
+# define RUBY_MAX_HOST_NAME_LEN NI_MAXHOST
+#elif defined(HOST_NAME_MAX)
+# define RUBY_MAX_HOST_NAME_LEN HOST_NAME_MAX
+#else
+# define RUBY_MAX_HOST_NAME_LEN 1024
+#endif
+
+ char buf[RUBY_MAX_HOST_NAME_LEN+1];
+
+ rb_secure(3);
+ if (gethostname(buf, (int)sizeof buf - 1) < 0)
+ rb_sys_fail("gethostname(3)");
+
+ buf[sizeof buf - 1] = '\0';
+ return rb_str_new2(buf);
+}
+#else
+#ifdef HAVE_UNAME
+
+#include <sys/utsname.h>
+
+static VALUE
+sock_gethostname(VALUE obj)
+{
+ struct utsname un;
+
+ rb_secure(3);
+ uname(&un);
+ return rb_str_new2(un.nodename);
+}
+#else
+#define sock_gethostname rb_f_notimplement
+#endif
+#endif
+
+static VALUE
+make_addrinfo(struct rb_addrinfo *res0, int norevlookup)
+{
+ VALUE base, ary;
+ struct addrinfo *res;
+
+ if (res0 == NULL) {
+ rb_raise(rb_eSocket, "host not found");
+ }
+ base = rb_ary_new();
+ for (res = res0->ai; res; res = res->ai_next) {
+ ary = rsock_ipaddr(res->ai_addr, res->ai_addrlen, norevlookup);
+ if (res->ai_canonname) {
+ RARRAY_PTR(ary)[2] = rb_str_new2(res->ai_canonname);
+ }
+ rb_ary_push(ary, INT2FIX(res->ai_family));
+ rb_ary_push(ary, INT2FIX(res->ai_socktype));
+ rb_ary_push(ary, INT2FIX(res->ai_protocol));
+ rb_ary_push(base, ary);
+ }
+ return base;
+}
+
+static VALUE
+sock_sockaddr(struct sockaddr *addr, socklen_t len)
+{
+ char *ptr;
+
+ switch (addr->sa_family) {
+ case AF_INET:
+ ptr = (char*)&((struct sockaddr_in*)addr)->sin_addr.s_addr;
+ len = (socklen_t)sizeof(((struct sockaddr_in*)addr)->sin_addr.s_addr);
+ break;
+#ifdef AF_INET6
+ case AF_INET6:
+ ptr = (char*)&((struct sockaddr_in6*)addr)->sin6_addr.s6_addr;
+ len = (socklen_t)sizeof(((struct sockaddr_in6*)addr)->sin6_addr.s6_addr);
+ break;
+#endif
+ default:
+ rb_raise(rb_eSocket, "unknown socket family:%d", addr->sa_family);
+ break;
+ }
+ return rb_str_new(ptr, len);
+}
+
+/*
+ * call-seq:
+ * Socket.gethostbyname(hostname) => [official_hostname, alias_hostnames, address_family, *address_list]
+ *
+ * Obtains the host information for _hostname_.
+ *
+ * p Socket.gethostbyname("hal") #=> ["localhost", ["hal"], 2, "\x7F\x00\x00\x01"]
+ *
+ */
+static VALUE
+sock_s_gethostbyname(VALUE obj, VALUE host)
+{
+ rb_secure(3);
+ return rsock_make_hostent(host, rsock_addrinfo(host, Qnil, SOCK_STREAM, AI_CANONNAME), sock_sockaddr);
+}
+
+/*
+ * call-seq:
+ * Socket.gethostbyaddr(address_string [, address_family]) => hostent
+ *
+ * Obtains the host information for _address_.
+ *
+ * p Socket.gethostbyaddr([221,186,184,68].pack("CCCC"))
+ * #=> ["carbon.ruby-lang.org", [], 2, "\xDD\xBA\xB8D"]
+ */
+static VALUE
+sock_s_gethostbyaddr(int argc, VALUE *argv)
+{
+ VALUE addr, family;
+ struct hostent *h;
+ char **pch;
+ VALUE ary, names;
+ int t = AF_INET;
+
+ rb_scan_args(argc, argv, "11", &addr, &family);
+ StringValue(addr);
+ if (!NIL_P(family)) {
+ t = rsock_family_arg(family);
+ }
+#ifdef AF_INET6
+ else if (RSTRING_LEN(addr) == 16) {
+ t = AF_INET6;
+ }
+#endif
+ h = gethostbyaddr(RSTRING_PTR(addr), RSTRING_SOCKLEN(addr), t);
+ if (h == NULL) {
+#ifdef HAVE_HSTRERROR
+ extern int h_errno;
+ rb_raise(rb_eSocket, "%s", (char*)hstrerror(h_errno));
+#else
+ rb_raise(rb_eSocket, "host not found");
+#endif
+ }
+ ary = rb_ary_new();
+ rb_ary_push(ary, rb_str_new2(h->h_name));
+ names = rb_ary_new();
+ rb_ary_push(ary, names);
+ if (h->h_aliases != NULL) {
+ for (pch = h->h_aliases; *pch; pch++) {
+ rb_ary_push(names, rb_str_new2(*pch));
+ }
+ }
+ rb_ary_push(ary, INT2NUM(h->h_addrtype));
+#ifdef h_addr
+ for (pch = h->h_addr_list; *pch; pch++) {
+ rb_ary_push(ary, rb_str_new(*pch, h->h_length));
+ }
+#else
+ rb_ary_push(ary, rb_str_new(h->h_addr, h->h_length));
+#endif
+
+ return ary;
+}
+
+/*
+ * call-seq:
+ * Socket.getservbyname(service_name) => port_number
+ * Socket.getservbyname(service_name, protocol_name) => port_number
+ *
+ * Obtains the port number for _service_name_.
+ *
+ * If _protocol_name_ is not given, "tcp" is assumed.
+ *
+ * Socket.getservbyname("smtp") #=> 25
+ * Socket.getservbyname("shell") #=> 514
+ * Socket.getservbyname("syslog", "udp") #=> 514
+ */
+static VALUE
+sock_s_getservbyname(int argc, VALUE *argv)
+{
+ VALUE service, proto;
+ struct servent *sp;
+ long port;
+ const char *servicename, *protoname = "tcp";
+
+ rb_scan_args(argc, argv, "11", &service, &proto);
+ StringValue(service);
+ if (!NIL_P(proto)) StringValue(proto);
+ servicename = StringValueCStr(service);
+ if (!NIL_P(proto)) protoname = StringValueCStr(proto);
+ sp = getservbyname(servicename, protoname);
+ if (sp) {
+ port = ntohs(sp->s_port);
+ }
+ else {
+ char *end;
+
+ port = STRTOUL(servicename, &end, 0);
+ if (*end != '\0') {
+ rb_raise(rb_eSocket, "no such service %s/%s", servicename, protoname);
+ }
+ }
+ return INT2FIX(port);
+}
+
+/*
+ * call-seq:
+ * Socket.getservbyport(port [, protocol_name]) => service
+ *
+ * Obtains the port number for _port_.
+ *
+ * If _protocol_name_ is not given, "tcp" is assumed.
+ *
+ * Socket.getservbyport(80) #=> "www"
+ * Socket.getservbyport(514, "tcp") #=> "shell"
+ * Socket.getservbyport(514, "udp") #=> "syslog"
+ *
+ */
+static VALUE
+sock_s_getservbyport(int argc, VALUE *argv)
+{
+ VALUE port, proto;
+ struct servent *sp;
+ long portnum;
+ const char *protoname = "tcp";
+
+ rb_scan_args(argc, argv, "11", &port, &proto);
+ portnum = NUM2LONG(port);
+ if (portnum != (uint16_t)portnum) {
+ const char *s = portnum > 0 ? "big" : "small";
+ rb_raise(rb_eRangeError, "integer %ld too %s to convert into `int16_t'", portnum, s);
+ }
+ if (!NIL_P(proto)) protoname = StringValueCStr(proto);
+
+ sp = getservbyport((int)htons((uint16_t)portnum), protoname);
+ if (!sp) {
+ rb_raise(rb_eSocket, "no such service for port %d/%s", (int)portnum, protoname);
+ }
+ return rb_tainted_str_new2(sp->s_name);
+}
+
+/*
+ * call-seq:
+ * Socket.getaddrinfo(nodename, servname[, family[, socktype[, protocol[, flags[, reverse_lookup]]]]]) => array
+ *
+ * Obtains address information for _nodename_:_servname_.
+ *
+ * _family_ should be an address family such as: :INET, :INET6, :UNIX, etc.
+ *
+ * _socktype_ should be a socket type such as: :STREAM, :DGRAM, :RAW, etc.
+ *
+ * _protocol_ should be a protocol defined in the family,
+ * and defaults to 0 for the family.
+ *
+ * _flags_ should be bitwise OR of Socket::AI_* constants.
+ *
+ * Socket.getaddrinfo("www.ruby-lang.org", "http", nil, :STREAM)
+ * #=> [["AF_INET", 80, "carbon.ruby-lang.org", "221.186.184.68", 2, 1, 6]] # PF_INET/SOCK_STREAM/IPPROTO_TCP
+ *
+ * Socket.getaddrinfo("localhost", nil)
+ * #=> [["AF_INET", 0, "localhost", "127.0.0.1", 2, 1, 6], # PF_INET/SOCK_STREAM/IPPROTO_TCP
+ * # ["AF_INET", 0, "localhost", "127.0.0.1", 2, 2, 17], # PF_INET/SOCK_DGRAM/IPPROTO_UDP
+ * # ["AF_INET", 0, "localhost", "127.0.0.1", 2, 3, 0]] # PF_INET/SOCK_RAW/IPPROTO_IP
+ *
+ * _reverse_lookup_ directs the form of the third element, and has to
+ * be one of below. If _reverse_lookup_ is omitted, the default value is +nil+.
+ *
+ * +true+, +:hostname+: hostname is obtained from numeric address using reverse lookup, which may take a time.
+ * +false+, +:numeric+: hostname is same as numeric address.
+ * +nil+: obey to the current +do_not_reverse_lookup+ flag.
+ *
+ * If Addrinfo object is preferred, use Addrinfo.getaddrinfo.
+ */
+static VALUE
+sock_s_getaddrinfo(int argc, VALUE *argv)
+{
+ VALUE host, port, family, socktype, protocol, flags, ret, revlookup;
+ struct addrinfo hints;
+ struct rb_addrinfo *res;
+ int norevlookup;
+
+ rb_scan_args(argc, argv, "25", &host, &port, &family, &socktype, &protocol, &flags, &revlookup);
+
+ MEMZERO(&hints, struct addrinfo, 1);
+ hints.ai_family = NIL_P(family) ? PF_UNSPEC : rsock_family_arg(family);
+
+ if (!NIL_P(socktype)) {
+ hints.ai_socktype = rsock_socktype_arg(socktype);
+ }
+ if (!NIL_P(protocol)) {
+ hints.ai_protocol = NUM2INT(protocol);
+ }
+ if (!NIL_P(flags)) {
+ hints.ai_flags = NUM2INT(flags);
+ }
+ if (NIL_P(revlookup) || !rsock_revlookup_flag(revlookup, &norevlookup)) {
+ norevlookup = rsock_do_not_reverse_lookup;
+ }
+ res = rsock_getaddrinfo(host, port, &hints, 0);
+
+ ret = make_addrinfo(res, norevlookup);
+ rb_freeaddrinfo(res);
+ return ret;
+}
+
+/*
+ * call-seq:
+ * Socket.getnameinfo(sockaddr [, flags]) => [hostname, servicename]
+ *
+ * Obtains name information for _sockaddr_.
+ *
+ * _sockaddr_ should be one of follows.
+ * - packed sockaddr string such as Socket.sockaddr_in(80, "127.0.0.1")
+ * - 3-elements array such as ["AF_INET", 80, "127.0.0.1"]
+ * - 4-elements array such as ["AF_INET", 80, ignored, "127.0.0.1"]
+ *
+ * _flags_ should be bitwise OR of Socket::NI_* constants.
+ *
+ * Note:
+ * The last form is compatible with IPSocket#addr and IPSocket#peeraddr.
+ *
+ * Socket.getnameinfo(Socket.sockaddr_in(80, "127.0.0.1")) #=> ["localhost", "www"]
+ * Socket.getnameinfo(["AF_INET", 80, "127.0.0.1"]) #=> ["localhost", "www"]
+ * Socket.getnameinfo(["AF_INET", 80, "localhost", "127.0.0.1"]) #=> ["localhost", "www"]
+ *
+ * If Addrinfo object is preferred, use Addrinfo#getnameinfo.
+ */
+static VALUE
+sock_s_getnameinfo(int argc, VALUE *argv)
+{
+ VALUE sa, af = Qnil, host = Qnil, port = Qnil, flags, tmp;
+ char *hptr, *pptr;
+ char hbuf[1024], pbuf[1024];
+ int fl;
+ struct rb_addrinfo *res = NULL;
+ struct addrinfo hints, *r;
+ int error, saved_errno;
+ union_sockaddr ss;
+ struct sockaddr *sap;
+ socklen_t salen;
+
+ sa = flags = Qnil;
+ rb_scan_args(argc, argv, "11", &sa, &flags);
+
+ fl = 0;
+ if (!NIL_P(flags)) {
+ fl = NUM2INT(flags);
+ }
+ tmp = rb_check_sockaddr_string_type(sa);
+ if (!NIL_P(tmp)) {
+ sa = tmp;
+ if (sizeof(ss) < (size_t)RSTRING_LEN(sa)) {
+ rb_raise(rb_eTypeError, "sockaddr length too big");
+ }
+ memcpy(&ss, RSTRING_PTR(sa), RSTRING_LEN(sa));
+ if (!VALIDATE_SOCKLEN(&ss.addr, RSTRING_LEN(sa))) {
+ rb_raise(rb_eTypeError, "sockaddr size differs - should not happen");
+ }
+ sap = &ss.addr;
+ salen = RSTRING_SOCKLEN(sa);
+ goto call_nameinfo;
+ }
+ tmp = rb_check_array_type(sa);
+ if (!NIL_P(tmp)) {
+ sa = tmp;
+ MEMZERO(&hints, struct addrinfo, 1);
+ if (RARRAY_LEN(sa) == 3) {
+ af = RARRAY_PTR(sa)[0];
+ port = RARRAY_PTR(sa)[1];
+ host = RARRAY_PTR(sa)[2];
+ }
+ else if (RARRAY_LEN(sa) >= 4) {
+ af = RARRAY_PTR(sa)[0];
+ port = RARRAY_PTR(sa)[1];
+ host = RARRAY_PTR(sa)[3];
+ if (NIL_P(host)) {
+ host = RARRAY_PTR(sa)[2];
+ }
+ else {
+ /*
+ * 4th element holds numeric form, don't resolve.
+ * see rsock_ipaddr().
+ */
+#ifdef AI_NUMERICHOST /* AIX 4.3.3 doesn't have AI_NUMERICHOST. */
+ hints.ai_flags |= AI_NUMERICHOST;
+#endif
+ }
+ }
+ else {
+ rb_raise(rb_eArgError, "array size should be 3 or 4, %ld given",
+ RARRAY_LEN(sa));
+ }
+ /* host */
+ if (NIL_P(host)) {
+ hptr = NULL;
+ }
+ else {
+ strncpy(hbuf, StringValuePtr(host), sizeof(hbuf));
+ hbuf[sizeof(hbuf) - 1] = '\0';
+ hptr = hbuf;
+ }
+ /* port */
+ if (NIL_P(port)) {
+ strcpy(pbuf, "0");
+ pptr = NULL;
+ }
+ else if (FIXNUM_P(port)) {
+ snprintf(pbuf, sizeof(pbuf), "%ld", NUM2LONG(port));
+ pptr = pbuf;
+ }
+ else {
+ strncpy(pbuf, StringValuePtr(port), sizeof(pbuf));
+ pbuf[sizeof(pbuf) - 1] = '\0';
+ pptr = pbuf;
+ }
+ hints.ai_socktype = (fl & NI_DGRAM) ? SOCK_DGRAM : SOCK_STREAM;
+ /* af */
+ hints.ai_family = NIL_P(af) ? PF_UNSPEC : rsock_family_arg(af);
+ error = rb_getaddrinfo(hptr, pptr, &hints, &res);
+ if (error) goto error_exit_addr;
+ sap = res->ai->ai_addr;
+ salen = res->ai->ai_addrlen;
+ }
+ else {
+ rb_raise(rb_eTypeError, "expecting String or Array");
+ }
+
+ call_nameinfo:
+ error = rb_getnameinfo(sap, salen, hbuf, sizeof(hbuf),
+ pbuf, sizeof(pbuf), fl);
+ if (error) goto error_exit_name;
+ if (res) {
+ for (r = res->ai->ai_next; r; r = r->ai_next) {
+ char hbuf2[1024], pbuf2[1024];
+
+ sap = r->ai_addr;
+ salen = r->ai_addrlen;
+ error = rb_getnameinfo(sap, salen, hbuf2, sizeof(hbuf2),
+ pbuf2, sizeof(pbuf2), fl);
+ if (error) goto error_exit_name;
+ if (strcmp(hbuf, hbuf2) != 0|| strcmp(pbuf, pbuf2) != 0) {
+ rb_freeaddrinfo(res);
+ rb_raise(rb_eSocket, "sockaddr resolved to multiple nodename");
+ }
+ }
+ rb_freeaddrinfo(res);
+ }
+ return rb_assoc_new(rb_str_new2(hbuf), rb_str_new2(pbuf));
+
+ error_exit_addr:
+ saved_errno = errno;
+ if (res) rb_freeaddrinfo(res);
+ errno = saved_errno;
+ rsock_raise_socket_error("getaddrinfo", error);
+
+ error_exit_name:
+ saved_errno = errno;
+ if (res) rb_freeaddrinfo(res);
+ errno = saved_errno;
+ rsock_raise_socket_error("getnameinfo", error);
+
+ UNREACHABLE;
+}
+
+/*
+ * call-seq:
+ * Socket.sockaddr_in(port, host) => sockaddr
+ * Socket.pack_sockaddr_in(port, host) => sockaddr
+ *
+ * Packs _port_ and _host_ as an AF_INET/AF_INET6 sockaddr string.
+ *
+ * Socket.sockaddr_in(80, "127.0.0.1")
+ * #=> "\x02\x00\x00P\x7F\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00\x00"
+ *
+ * Socket.sockaddr_in(80, "::1")
+ * #=> "\n\x00\x00P\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\x00\x00\x00\x00"
+ *
+ */
+static VALUE
+sock_s_pack_sockaddr_in(VALUE self, VALUE port, VALUE host)
+{
+ struct rb_addrinfo *res = rsock_addrinfo(host, port, 0, 0);
+ VALUE addr = rb_str_new((char*)res->ai->ai_addr, res->ai->ai_addrlen);
+
+ rb_freeaddrinfo(res);
+ OBJ_INFECT(addr, port);
+ OBJ_INFECT(addr, host);
+
+ return addr;
+}
+
+/*
+ * call-seq:
+ * Socket.unpack_sockaddr_in(sockaddr) => [port, ip_address]
+ *
+ * Unpacks _sockaddr_ into port and ip_address.
+ *
+ * _sockaddr_ should be a string or an addrinfo for AF_INET/AF_INET6.
+ *
+ * sockaddr = Socket.sockaddr_in(80, "127.0.0.1")
+ * p sockaddr #=> "\x02\x00\x00P\x7F\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00\x00"
+ * p Socket.unpack_sockaddr_in(sockaddr) #=> [80, "127.0.0.1"]
+ *
+ */
+static VALUE
+sock_s_unpack_sockaddr_in(VALUE self, VALUE addr)
+{
+ struct sockaddr_in * sockaddr;
+ VALUE host;
+
+ sockaddr = (struct sockaddr_in*)SockAddrStringValuePtr(addr);
+ if (RSTRING_LEN(addr) <
+ (char*)&((struct sockaddr *)sockaddr)->sa_family +
+ sizeof(((struct sockaddr *)sockaddr)->sa_family) -
+ (char*)sockaddr)
+ rb_raise(rb_eArgError, "too short sockaddr");
+ if (((struct sockaddr *)sockaddr)->sa_family != AF_INET
+#ifdef INET6
+ && ((struct sockaddr *)sockaddr)->sa_family != AF_INET6
+#endif
+ ) {
+#ifdef INET6
+ rb_raise(rb_eArgError, "not an AF_INET/AF_INET6 sockaddr");
+#else
+ rb_raise(rb_eArgError, "not an AF_INET sockaddr");
+#endif
+ }
+ host = rsock_make_ipaddr((struct sockaddr*)sockaddr, RSTRING_SOCKLEN(addr));
+ OBJ_INFECT(host, addr);
+ return rb_assoc_new(INT2NUM(ntohs(sockaddr->sin_port)), host);
+}
+
+#ifdef HAVE_SYS_UN_H
+
+/*
+ * call-seq:
+ * Socket.sockaddr_un(path) => sockaddr
+ * Socket.pack_sockaddr_un(path) => sockaddr
+ *
+ * Packs _path_ as an AF_UNIX sockaddr string.
+ *
+ * Socket.sockaddr_un("/tmp/sock") #=> "\x01\x00/tmp/sock\x00\x00..."
+ *
+ */
+static VALUE
+sock_s_pack_sockaddr_un(VALUE self, VALUE path)
+{
+ struct sockaddr_un sockaddr;
+ VALUE addr;
+
+ StringValue(path);
+ INIT_SOCKADDR_UN(&sockaddr, sizeof(struct sockaddr_un));
+ if (sizeof(sockaddr.sun_path) < (size_t)RSTRING_LEN(path)) {
+ rb_raise(rb_eArgError, "too long unix socket path (%"PRIuSIZE" bytes given but %"PRIuSIZE" bytes max)",
+ (size_t)RSTRING_LEN(path), sizeof(sockaddr.sun_path));
+ }
+ memcpy(sockaddr.sun_path, RSTRING_PTR(path), RSTRING_LEN(path));
+ addr = rb_str_new((char*)&sockaddr, rsock_unix_sockaddr_len(path));
+ OBJ_INFECT(addr, path);
+
+ return addr;
+}
+
+/*
+ * call-seq:
+ * Socket.unpack_sockaddr_un(sockaddr) => path
+ *
+ * Unpacks _sockaddr_ into path.
+ *
+ * _sockaddr_ should be a string or an addrinfo for AF_UNIX.
+ *
+ * sockaddr = Socket.sockaddr_un("/tmp/sock")
+ * p Socket.unpack_sockaddr_un(sockaddr) #=> "/tmp/sock"
+ *
+ */
+static VALUE
+sock_s_unpack_sockaddr_un(VALUE self, VALUE addr)
+{
+ struct sockaddr_un * sockaddr;
+ VALUE path;
+
+ sockaddr = (struct sockaddr_un*)SockAddrStringValuePtr(addr);
+ if (RSTRING_LEN(addr) <
+ (char*)&((struct sockaddr *)sockaddr)->sa_family +
+ sizeof(((struct sockaddr *)sockaddr)->sa_family) -
+ (char*)sockaddr)
+ rb_raise(rb_eArgError, "too short sockaddr");
+ if (((struct sockaddr *)sockaddr)->sa_family != AF_UNIX) {
+ rb_raise(rb_eArgError, "not an AF_UNIX sockaddr");
+ }
+ if (sizeof(struct sockaddr_un) < (size_t)RSTRING_LEN(addr)) {
+ rb_raise(rb_eTypeError, "too long sockaddr_un - %ld longer than %d",
+ RSTRING_LEN(addr), (int)sizeof(struct sockaddr_un));
+ }
+ path = rsock_unixpath_str(sockaddr, RSTRING_SOCKLEN(addr));
+ OBJ_INFECT(path, addr);
+ return path;
+}
+#endif
+
+#if defined(HAVE_GETIFADDRS) || defined(SIOCGLIFCONF) || defined(SIOCGIFCONF) || defined(_WIN32)
+
+static socklen_t
+sockaddr_len(struct sockaddr *addr)
+{
+ if (addr == NULL)
+ return 0;
+
+#ifdef HAVE_STRUCT_SOCKADDR_SA_LEN
+ if (addr->sa_len != 0)
+ return addr->sa_len;
+#endif
+
+ switch (addr->sa_family) {
+ case AF_INET:
+ return (socklen_t)sizeof(struct sockaddr_in);
+
+#ifdef AF_INET6
+ case AF_INET6:
+ return (socklen_t)sizeof(struct sockaddr_in6);
+#endif
+
+#ifdef HAVE_SYS_UN_H
+ case AF_UNIX:
+ return (socklen_t)sizeof(struct sockaddr_un);
+#endif
+
+#ifdef AF_PACKET
+ case AF_PACKET:
+ return (socklen_t)(offsetof(struct sockaddr_ll, sll_addr) + ((struct sockaddr_ll *)addr)->sll_halen);
+#endif
+
+ default:
+ return (socklen_t)(offsetof(struct sockaddr, sa_family) + sizeof(addr->sa_family));
+ }
+}
+
+socklen_t
+rsock_sockaddr_len(struct sockaddr *addr)
+{
+ return sockaddr_len(addr);
+}
+
+static VALUE
+sockaddr_obj(struct sockaddr *addr, socklen_t len)
+{
+#if defined(AF_INET6) && defined(__KAME__)
+ struct sockaddr_in6 addr6;
+#endif
+
+ if (addr == NULL)
+ return Qnil;
+
+ len = sockaddr_len(addr);
+
+#if defined(__KAME__) && defined(AF_INET6)
+ if (addr->sa_family == AF_INET6) {
+ /* KAME uses the 2nd 16bit word of link local IPv6 address as interface index internally */
+ /* http://orange.kame.net/dev/cvsweb.cgi/kame/IMPLEMENTATION */
+ /* convert fe80:1::1 to fe80::1%1 */
+ len = (socklen_t)sizeof(struct sockaddr_in6);
+ memcpy(&addr6, addr, len);
+ addr = (struct sockaddr *)&addr6;
+ if (IN6_IS_ADDR_LINKLOCAL(&addr6.sin6_addr) &&
+ addr6.sin6_scope_id == 0 &&
+ (addr6.sin6_addr.s6_addr[2] || addr6.sin6_addr.s6_addr[3])) {
+ addr6.sin6_scope_id = (addr6.sin6_addr.s6_addr[2] << 8) | addr6.sin6_addr.s6_addr[3];
+ addr6.sin6_addr.s6_addr[2] = 0;
+ addr6.sin6_addr.s6_addr[3] = 0;
+ }
+ }
+#endif
+
+ return rsock_addrinfo_new(addr, len, addr->sa_family, 0, 0, Qnil, Qnil);
+}
+
+VALUE
+rsock_sockaddr_obj(struct sockaddr *addr, socklen_t len)
+{
+ return sockaddr_obj(addr, len);
+}
+
+#endif
+
+#if defined(HAVE_GETIFADDRS) || (defined(SIOCGLIFCONF) && defined(SIOCGLIFNUM) && !defined(__hpux)) || defined(SIOCGIFCONF) || defined(_WIN32)
+/*
+ * call-seq:
+ * Socket.ip_address_list => array
+ *
+ * Returns local IP addresses as an array.
+ *
+ * The array contains Addrinfo objects.
+ *
+ * pp Socket.ip_address_list
+ * #=> [#<Addrinfo: 127.0.0.1>,
+ * #<Addrinfo: 192.168.0.128>,
+ * #<Addrinfo: ::1>,
+ * ...]
+ *
+ */
+static VALUE
+socket_s_ip_address_list(VALUE self)
+{
+#if defined(HAVE_GETIFADDRS)
+ struct ifaddrs *ifp = NULL;
+ struct ifaddrs *p;
+ int ret;
+ VALUE list;
+
+ ret = getifaddrs(&ifp);
+ if (ret == -1) {
+ rb_sys_fail("getifaddrs");
+ }
+
+ list = rb_ary_new();
+ for (p = ifp; p; p = p->ifa_next) {
+ if (p->ifa_addr != NULL && IS_IP_FAMILY(p->ifa_addr->sa_family)) {
+ struct sockaddr *addr = p->ifa_addr;
+#if defined(AF_INET6) && defined(__sun)
+ /*
+ * OpenIndiana SunOS 5.11 getifaddrs() returns IPv6 link local
+ * address with sin6_scope_id == 0.
+ * So fill it from the interface name (ifa_name).
+ */
+ struct sockaddr_in6 addr6;
+ if (addr->sa_family == AF_INET6) {
+ socklen_t len = (socklen_t)sizeof(struct sockaddr_in6);
+ memcpy(&addr6, addr, len);
+ addr = (struct sockaddr *)&addr6;
+ if (IN6_IS_ADDR_LINKLOCAL(&addr6.sin6_addr) &&
+ addr6.sin6_scope_id == 0) {
+ unsigned int ifindex = if_nametoindex(p->ifa_name);
+ if (ifindex != 0) {
+ addr6.sin6_scope_id = ifindex;
+ }
+ }
+ }
+#endif
+ rb_ary_push(list, sockaddr_obj(addr, sockaddr_len(addr)));
+ }
+ }
+
+ freeifaddrs(ifp);
+
+ return list;
+#elif defined(SIOCGLIFCONF) && defined(SIOCGLIFNUM) && !defined(__hpux)
+ /* Solaris if_tcp(7P) */
+ /* HP-UX has SIOCGLIFCONF too. But it uses different struct */
+ int fd = -1;
+ int ret;
+ struct lifnum ln;
+ struct lifconf lc;
+ char *reason = NULL;
+ int save_errno;
+ int i;
+ VALUE list = Qnil;
+
+ lc.lifc_buf = NULL;
+
+ fd = socket(AF_INET, SOCK_DGRAM, 0);
+ if (fd == -1)
+ rb_sys_fail("socket(2)");
+
+ memset(&ln, 0, sizeof(ln));
+ ln.lifn_family = AF_UNSPEC;
+
+ ret = ioctl(fd, SIOCGLIFNUM, &ln);
+ if (ret == -1) {
+ reason = "SIOCGLIFNUM";
+ goto finish;
+ }
+
+ memset(&lc, 0, sizeof(lc));
+ lc.lifc_family = AF_UNSPEC;
+ lc.lifc_flags = 0;
+ lc.lifc_len = sizeof(struct lifreq) * ln.lifn_count;
+ lc.lifc_req = xmalloc(lc.lifc_len);
+
+ ret = ioctl(fd, SIOCGLIFCONF, &lc);
+ if (ret == -1) {
+ reason = "SIOCGLIFCONF";
+ goto finish;
+ }
+
+ list = rb_ary_new();
+ for (i = 0; i < ln.lifn_count; i++) {
+ struct lifreq *req = &lc.lifc_req[i];
+ if (IS_IP_FAMILY(req->lifr_addr.ss_family)) {
+ if (req->lifr_addr.ss_family == AF_INET6 &&
+ IN6_IS_ADDR_LINKLOCAL(&((struct sockaddr_in6 *)(&req->lifr_addr))->sin6_addr) &&
+ ((struct sockaddr_in6 *)(&req->lifr_addr))->sin6_scope_id == 0) {
+ struct lifreq req2;
+ memcpy(req2.lifr_name, req->lifr_name, LIFNAMSIZ);
+ ret = ioctl(fd, SIOCGLIFINDEX, &req2);
+ if (ret == -1) {
+ reason = "SIOCGLIFINDEX";
+ goto finish;
+ }
+ ((struct sockaddr_in6 *)(&req->lifr_addr))->sin6_scope_id = req2.lifr_index;
+ }
+ rb_ary_push(list, sockaddr_obj((struct sockaddr *)&req->lifr_addr, req->lifr_addrlen));
+ }
+ }
+
+ finish:
+ save_errno = errno;
+ if (lc.lifc_buf != NULL)
+ xfree(lc.lifc_req);
+ if (fd != -1)
+ close(fd);
+ errno = save_errno;
+
+ if (reason)
+ rb_sys_fail(reason);
+ return list;
+
+#elif defined(SIOCGIFCONF)
+ int fd = -1;
+ int ret;
+#define EXTRA_SPACE ((int)(sizeof(struct ifconf) + sizeof(union_sockaddr)))
+ char initbuf[4096+EXTRA_SPACE];
+ char *buf = initbuf;
+ int bufsize;
+ struct ifconf conf;
+ struct ifreq *req;
+ VALUE list = Qnil;
+ const char *reason = NULL;
+ int save_errno;
+
+ fd = socket(AF_INET, SOCK_DGRAM, 0);
+ if (fd == -1)
+ rb_sys_fail("socket(2)");
+
+ bufsize = sizeof(initbuf);
+ buf = initbuf;
+
+ retry:
+ conf.ifc_len = bufsize;
+ conf.ifc_req = (struct ifreq *)buf;
+
+ /* fprintf(stderr, "bufsize: %d\n", bufsize); */
+
+ ret = ioctl(fd, SIOCGIFCONF, &conf);
+ if (ret == -1) {
+ reason = "SIOCGIFCONF";
+ goto finish;
+ }
+
+ /* fprintf(stderr, "conf.ifc_len: %d\n", conf.ifc_len); */
+
+ if (bufsize - EXTRA_SPACE < conf.ifc_len) {
+ if (bufsize < conf.ifc_len) {
+ /* NetBSD returns required size for all interfaces. */
+ bufsize = conf.ifc_len + EXTRA_SPACE;
+ }
+ else {
+ bufsize = bufsize << 1;
+ }
+ if (buf == initbuf)
+ buf = NULL;
+ buf = xrealloc(buf, bufsize);
+ goto retry;
+ }
+
+ close(fd);
+ fd = -1;
+
+ list = rb_ary_new();
+ req = conf.ifc_req;
+ while ((char*)req < (char*)conf.ifc_req + conf.ifc_len) {
+ struct sockaddr *addr = &req->ifr_addr;
+ if (IS_IP_FAMILY(addr->sa_family)) {
+ rb_ary_push(list, sockaddr_obj(addr, sockaddr_len(addr)));
+ }
+#ifdef HAVE_STRUCT_SOCKADDR_SA_LEN
+# ifndef _SIZEOF_ADDR_IFREQ
+# define _SIZEOF_ADDR_IFREQ(r) \
+ (sizeof(struct ifreq) + \
+ (sizeof(struct sockaddr) < (r).ifr_addr.sa_len ? \
+ (r).ifr_addr.sa_len - sizeof(struct sockaddr) : \
+ 0))
+# endif
+ req = (struct ifreq *)((char*)req + _SIZEOF_ADDR_IFREQ(*req));
+#else
+ req = (struct ifreq *)((char*)req + sizeof(struct ifreq));
+#endif
+ }
+
+ finish:
+
+ save_errno = errno;
+ if (buf != initbuf)
+ xfree(buf);
+ if (fd != -1)
+ close(fd);
+ errno = save_errno;
+
+ if (reason)
+ rb_sys_fail(reason);
+ return list;
+
+#undef EXTRA_SPACE
+#elif defined(_WIN32)
+ typedef struct ip_adapter_unicast_address_st {
+ unsigned LONG_LONG dummy0;
+ struct ip_adapter_unicast_address_st *Next;
+ struct {
+ struct sockaddr *lpSockaddr;
+ int iSockaddrLength;
+ } Address;
+ int dummy1;
+ int dummy2;
+ int dummy3;
+ long dummy4;
+ long dummy5;
+ long dummy6;
+ } ip_adapter_unicast_address_t;
+ typedef struct ip_adapter_anycast_address_st {
+ unsigned LONG_LONG dummy0;
+ struct ip_adapter_anycast_address_st *Next;
+ struct {
+ struct sockaddr *lpSockaddr;
+ int iSockaddrLength;
+ } Address;
+ } ip_adapter_anycast_address_t;
+ typedef struct ip_adapter_addresses_st {
+ unsigned LONG_LONG dummy0;
+ struct ip_adapter_addresses_st *Next;
+ void *dummy1;
+ ip_adapter_unicast_address_t *FirstUnicastAddress;
+ ip_adapter_anycast_address_t *FirstAnycastAddress;
+ void *dummy2;
+ void *dummy3;
+ void *dummy4;
+ void *dummy5;
+ void *dummy6;
+ BYTE dummy7[8];
+ DWORD dummy8;
+ DWORD dummy9;
+ DWORD dummy10;
+ DWORD IfType;
+ int OperStatus;
+ DWORD dummy12;
+ DWORD dummy13[16];
+ void *dummy14;
+ } ip_adapter_addresses_t;
+ typedef ULONG (WINAPI *GetAdaptersAddresses_t)(ULONG, ULONG, PVOID, ip_adapter_addresses_t *, PULONG);
+ HMODULE h;
+ GetAdaptersAddresses_t pGetAdaptersAddresses;
+ ULONG len;
+ DWORD ret;
+ ip_adapter_addresses_t *adapters;
+ VALUE list;
+
+ h = LoadLibrary("iphlpapi.dll");
+ if (!h)
+ rb_notimplement();
+ pGetAdaptersAddresses = (GetAdaptersAddresses_t)GetProcAddress(h, "GetAdaptersAddresses");
+ if (!pGetAdaptersAddresses) {
+ FreeLibrary(h);
+ rb_notimplement();
+ }
+
+ ret = pGetAdaptersAddresses(AF_UNSPEC, 0, NULL, NULL, &len);
+ if (ret != ERROR_SUCCESS && ret != ERROR_BUFFER_OVERFLOW) {
+ errno = rb_w32_map_errno(ret);
+ FreeLibrary(h);
+ rb_sys_fail("GetAdaptersAddresses");
+ }
+ adapters = (ip_adapter_addresses_t *)ALLOCA_N(BYTE, len);
+ ret = pGetAdaptersAddresses(AF_UNSPEC, 0, NULL, adapters, &len);
+ if (ret != ERROR_SUCCESS) {
+ errno = rb_w32_map_errno(ret);
+ FreeLibrary(h);
+ rb_sys_fail("GetAdaptersAddresses");
+ }
+
+ list = rb_ary_new();
+ for (; adapters; adapters = adapters->Next) {
+ ip_adapter_unicast_address_t *uni;
+ ip_adapter_anycast_address_t *any;
+ if (adapters->OperStatus != 1) /* 1 means IfOperStatusUp */
+ continue;
+ for (uni = adapters->FirstUnicastAddress; uni; uni = uni->Next) {
+#ifndef INET6
+ if (uni->Address.lpSockaddr->sa_family == AF_INET)
+#else
+ if (IS_IP_FAMILY(uni->Address.lpSockaddr->sa_family))
+#endif
+ rb_ary_push(list, sockaddr_obj(uni->Address.lpSockaddr, uni->Address.iSockaddrLength));
+ }
+ for (any = adapters->FirstAnycastAddress; any; any = any->Next) {
+#ifndef INET6
+ if (any->Address.lpSockaddr->sa_family == AF_INET)
+#else
+ if (IS_IP_FAMILY(any->Address.lpSockaddr->sa_family))
+#endif
+ rb_ary_push(list, sockaddr_obj(any->Address.lpSockaddr, any->Address.iSockaddrLength));
+ }
+ }
+
+ FreeLibrary(h);
+ return list;
+#endif
+}
+#else
+#define socket_s_ip_address_list rb_f_notimplement
+#endif
+
+void
+Init_socket(void)
+{
+ rsock_init_basicsocket();
+
+ /*
+ * Document-class: Socket < BasicSocket
+ *
+ * Class +Socket+ provides access to the underlying operating system
+ * socket implementations. It can be used to provide more operating system
+ * specific functionality than the protocol-specific socket classes.
+ *
+ * The constants defined under Socket::Constants are also defined under
+ * Socket. For example, Socket::AF_INET is usable as well as
+ * Socket::Constants::AF_INET. See Socket::Constants for the list of
+ * constants.
+ *
+ * === What's a socket?
+ *
+ * Sockets are endpoints of a bidirectional communication channel.
+ * Sockets can communicate within a process, between processes on the same
+ * machine or between different machines. There are many types of socket:
+ * TCPSocket, UDPSocket or UNIXSocket for example.
+ *
+ * Sockets have their own vocabulary:
+ *
+ * *domain:*
+ * The family of protocols:
+ * * Socket::PF_INET
+ * * Socket::PF_INET6
+ * * Socket::PF_UNIX
+ * * etc.
+ *
+ * *type:*
+ * The type of communications between the two endpoints, typically
+ * * Socket::SOCK_STREAM
+ * * Socket::SOCK_DGRAM.
+ *
+ * *protocol:*
+ * Typically _zero_.
+ * This may be used to identify a variant of a protocol.
+ *
+ * *hostname:*
+ * The identifier of a network interface:
+ * * a string (hostname, IPv4 or IPv6 address or +broadcast+
+ * which specifies a broadcast address)
+ * * a zero-length string which specifies INADDR_ANY
+ * * an integer (interpreted as binary address in host byte order).
+ *
+ * === Quick start
+ *
+ * Many of the classes, such as TCPSocket, UDPSocket or UNIXSocket,
+ * ease the use of sockets comparatively to the equivalent C programming interface.
+ *
+ * Let's create an internet socket using the IPv4 protocol in a C-like manner:
+ *
+ * s = Socket.new Socket::AF_INET, Socket::SOCK_STREAM
+ * s.connect Socket.pack_sockaddr_in(80, 'example.com')
+ *
+ * You could also use the TCPSocket class:
+ *
+ * s = TCPSocket.new 'example.com', 80
+ *
+ * A simple server might look like this:
+ *
+ * require 'socket'
+ *
+ * server = TCPServer.new 2000 # Server bound to port 2000
+ *
+ * loop do
+ * client = server.accept # Wait for a client to connect
+ * client.puts "Hello !"
+ * client.puts "Time is #{Time.now}"
+ * client.close
+ * end
+ *
+ * A simple client may look like this:
+ *
+ * require 'socket'
+ *
+ * s = TCPSocket.new 'localhost', 2000
+ *
+ * while line = s.gets # Read lines from socket
+ * puts line # and print them
+ * end
+ *
+ * s.close # close socket when done
+ *
+ * === Exception Handling
+ *
+ * Ruby's Socket implementation raises exceptions based on the error
+ * generated by the system dependent implementation. This is why the
+ * methods are documented in a way that isolate Unix-based system
+ * exceptions from Windows based exceptions. If more information on a
+ * particular exception is needed, please refer to the Unix manual pages or
+ * the Windows WinSock reference.
+ *
+ * === Convenience methods
+ *
+ * Although the general way to create socket is Socket.new,
+ * there are several methods of socket creation for most cases.
+ *
+ * TCP client socket::
+ * Socket.tcp, TCPSocket.open
+ * TCP server socket::
+ * Socket.tcp_server_loop, TCPServer.open
+ * UNIX client socket::
+ * Socket.unix, UNIXSocket.open
+ * UNIX server socket::
+ * Socket.unix_server_loop, UNIXServer.open
+ *
+ * === Documentation by
+ *
+ * * Zach Dennis
+ * * Sam Roberts
+ * * <em>Programming Ruby</em> from The Pragmatic Bookshelf.
+ *
+ * Much material in this documentation is taken with permission from
+ * <em>Programming Ruby</em> from The Pragmatic Bookshelf.
+ */
+ rb_cSocket = rb_define_class("Socket", rb_cBasicSocket);
+
+ rsock_init_socket_init();
+
+ rb_define_method(rb_cSocket, "initialize", sock_initialize, -1);
+ rb_define_method(rb_cSocket, "connect", sock_connect, 1);
+ rb_define_method(rb_cSocket, "connect_nonblock", sock_connect_nonblock, 1);
+ rb_define_method(rb_cSocket, "bind", sock_bind, 1);
+ rb_define_method(rb_cSocket, "listen", rsock_sock_listen, 1);
+ rb_define_method(rb_cSocket, "accept", sock_accept, 0);
+ rb_define_method(rb_cSocket, "accept_nonblock", sock_accept_nonblock, 0);
+ rb_define_method(rb_cSocket, "sysaccept", sock_sysaccept, 0);
+
+ rb_define_method(rb_cSocket, "recvfrom", sock_recvfrom, -1);
+ rb_define_method(rb_cSocket, "recvfrom_nonblock", sock_recvfrom_nonblock, -1);
+
+ rb_define_singleton_method(rb_cSocket, "socketpair", rsock_sock_s_socketpair, -1);
+ rb_define_singleton_method(rb_cSocket, "pair", rsock_sock_s_socketpair, -1);
+ rb_define_singleton_method(rb_cSocket, "gethostname", sock_gethostname, 0);
+ rb_define_singleton_method(rb_cSocket, "gethostbyname", sock_s_gethostbyname, 1);
+ rb_define_singleton_method(rb_cSocket, "gethostbyaddr", sock_s_gethostbyaddr, -1);
+ rb_define_singleton_method(rb_cSocket, "getservbyname", sock_s_getservbyname, -1);
+ rb_define_singleton_method(rb_cSocket, "getservbyport", sock_s_getservbyport, -1);
+ rb_define_singleton_method(rb_cSocket, "getaddrinfo", sock_s_getaddrinfo, -1);
+ rb_define_singleton_method(rb_cSocket, "getnameinfo", sock_s_getnameinfo, -1);
+ rb_define_singleton_method(rb_cSocket, "sockaddr_in", sock_s_pack_sockaddr_in, 2);
+ rb_define_singleton_method(rb_cSocket, "pack_sockaddr_in", sock_s_pack_sockaddr_in, 2);
+ rb_define_singleton_method(rb_cSocket, "unpack_sockaddr_in", sock_s_unpack_sockaddr_in, 1);
+#ifdef HAVE_SYS_UN_H
+ rb_define_singleton_method(rb_cSocket, "sockaddr_un", sock_s_pack_sockaddr_un, 1);
+ rb_define_singleton_method(rb_cSocket, "pack_sockaddr_un", sock_s_pack_sockaddr_un, 1);
+ rb_define_singleton_method(rb_cSocket, "unpack_sockaddr_un", sock_s_unpack_sockaddr_un, 1);
+#endif
+
+ rb_define_singleton_method(rb_cSocket, "ip_address_list", socket_s_ip_address_list, 0);
+}
diff --git a/jni/ruby/ext/socket/sockport.h b/jni/ruby/ext/socket/sockport.h
new file mode 100644
index 0000000..7689e5e
--- /dev/null
+++ b/jni/ruby/ext/socket/sockport.h
@@ -0,0 +1,116 @@
+/************************************************
+
+ sockport.h -
+
+ $Author: akr $
+ created at: Fri Apr 30 23:19:34 JST 1999
+
+************************************************/
+
+#ifndef SOCKPORT_H
+#define SOCKPORT_H
+
+#ifdef HAVE_STRUCT_SOCKADDR_SA_LEN
+# define VALIDATE_SOCKLEN(addr, len) ((addr)->sa_len == (len))
+#else
+# define VALIDATE_SOCKLEN(addr, len) ((void)(addr), (void)(len), 1)
+#endif
+
+#ifdef HAVE_STRUCT_SOCKADDR_SA_LEN
+# define SET_SA_LEN(sa, len) (void)((sa)->sa_len = (len))
+#else
+# define SET_SA_LEN(sa, len) (void)(len)
+#endif
+
+/* for strict-aliasing rule */
+#ifdef HAVE_STRUCT_SOCKADDR_IN_SIN_LEN
+# define SET_SIN_LEN(sa, len) (void)((sa)->sin_len = (len))
+#else
+# define SET_SIN_LEN(sa, len) SET_SA_LEN((struct sockaddr *)(sa), (len))
+#endif
+
+#ifdef HAVE_STRUCT_SOCKADDR_IN6_SIN6_LEN
+# define SET_SIN6_LEN(sa, len) (void)((sa)->sin6_len = (len))
+#else
+# define SET_SIN6_LEN(sa, len) SET_SA_LEN((struct sockaddr *)(sa), (len))
+#endif
+
+#define INIT_SOCKADDR(addr, family, len) \
+ do { \
+ struct sockaddr *init_sockaddr_ptr = (addr); \
+ socklen_t init_sockaddr_len = (len); \
+ memset(init_sockaddr_ptr, 0, init_sockaddr_len); \
+ init_sockaddr_ptr->sa_family = (family); \
+ SET_SA_LEN(init_sockaddr_ptr, init_sockaddr_len); \
+ } while (0)
+
+#define INIT_SOCKADDR_IN(addr, len) \
+ do { \
+ struct sockaddr_in *init_sockaddr_ptr = (addr); \
+ socklen_t init_sockaddr_len = (len); \
+ memset(init_sockaddr_ptr, 0, init_sockaddr_len); \
+ init_sockaddr_ptr->sin_family = AF_INET; \
+ SET_SIN_LEN(init_sockaddr_ptr, init_sockaddr_len); \
+ } while (0)
+
+#define INIT_SOCKADDR_IN6(addr, len) \
+ do { \
+ struct sockaddr_in6 *init_sockaddr_ptr = (addr); \
+ socklen_t init_sockaddr_len = (len); \
+ memset(init_sockaddr_ptr, 0, init_sockaddr_len); \
+ init_sockaddr_ptr->sin6_family = AF_INET6; \
+ SET_SIN6_LEN(init_sockaddr_ptr, init_sockaddr_len); \
+ } while (0)
+
+
+/* for strict-aliasing rule */
+#ifdef HAVE_TYPE_STRUCT_SOCKADDR_UN
+# ifdef HAVE_STRUCT_SOCKADDR_IN_SUN_LEN
+# define SET_SUN_LEN(sa, len) (void)((sa)->sun_len = (len))
+# else
+# define SET_SUN_LEN(sa, len) SET_SA_LEN((struct sockaddr *)(sa), (len))
+# endif
+# define INIT_SOCKADDR_UN(addr, len) \
+ do { \
+ struct sockaddr_un *init_sockaddr_ptr = (addr); \
+ socklen_t init_sockaddr_len = (len); \
+ memset(init_sockaddr_ptr, 0, init_sockaddr_len); \
+ init_sockaddr_ptr->sun_family = AF_UNIX; \
+ SET_SUN_LEN(init_sockaddr_ptr, init_sockaddr_len); \
+ } while (0)
+#endif
+
+#ifndef IN_MULTICAST
+# define IN_CLASSD(i) (((long)(i) & 0xf0000000) == 0xe0000000)
+# define IN_MULTICAST(i) IN_CLASSD(i)
+#endif
+
+#ifndef IN_EXPERIMENTAL
+# define IN_EXPERIMENTAL(i) ((((long)(i)) & 0xe0000000) == 0xe0000000)
+#endif
+
+#ifndef IN_CLASSA_NSHIFT
+# define IN_CLASSA_NSHIFT 24
+#endif
+
+#ifndef IN_LOOPBACKNET
+# define IN_LOOPBACKNET 127
+#endif
+
+#ifndef AF_UNSPEC
+# define AF_UNSPEC 0
+#endif
+
+#ifndef PF_UNSPEC
+# define PF_UNSPEC AF_UNSPEC
+#endif
+
+#ifndef PF_INET
+# define PF_INET AF_INET
+#endif
+
+#if defined(HOST_NOT_FOUND) && !defined(h_errno) && !defined(__CYGWIN__)
+extern int h_errno;
+#endif
+
+#endif
diff --git a/jni/ruby/ext/socket/sockssocket.c b/jni/ruby/ext/socket/sockssocket.c
new file mode 100644
index 0000000..81f77a6
--- /dev/null
+++ b/jni/ruby/ext/socket/sockssocket.c
@@ -0,0 +1,68 @@
+/************************************************
+
+ sockssocket.c -
+
+ created at: Thu Mar 31 12:21:29 JST 1994
+
+ Copyright (C) 1993-2007 Yukihiro Matsumoto
+
+************************************************/
+
+#include "rubysocket.h"
+
+#ifdef SOCKS
+/*
+ * call-seq:
+ * SOCKSSocket.new(host, serv) => socket
+ *
+ * Opens a SOCKS connection to +host+ via the SOCKS server +serv+.
+ *
+ */
+static VALUE
+socks_init(VALUE sock, VALUE host, VALUE serv)
+{
+ static int init = 0;
+
+ if (init == 0) {
+ SOCKSinit("ruby");
+ init = 1;
+ }
+
+ return rsock_init_inetsock(sock, host, serv, Qnil, Qnil, INET_SOCKS);
+}
+
+#ifdef SOCKS5
+/*
+ * Closes the SOCKS connection.
+ *
+ */
+static VALUE
+socks_s_close(VALUE sock)
+{
+ rb_io_t *fptr;
+
+ GetOpenFile(sock, fptr);
+ shutdown(fptr->fd, 2);
+ return rb_io_close(sock);
+}
+#endif
+#endif
+
+void
+rsock_init_sockssocket(void)
+{
+#ifdef SOCKS
+ /*
+ * Document-class: SOCKSSocket < TCPSocket
+ *
+ * SOCKS is an Internet protocol that routes packets between a client and
+ * a server through a proxy server. SOCKS5, if supported, additionally
+ * provides authentication so only authorized users may access a server.
+ */
+ rb_cSOCKSSocket = rb_define_class("SOCKSSocket", rb_cTCPSocket);
+ rb_define_method(rb_cSOCKSSocket, "initialize", socks_init, 2);
+#ifdef SOCKS5
+ rb_define_method(rb_cSOCKSSocket, "close", socks_s_close, 0);
+#endif
+#endif
+}
diff --git a/jni/ruby/ext/socket/tcpserver.c b/jni/ruby/ext/socket/tcpserver.c
new file mode 100644
index 0000000..2245a06
--- /dev/null
+++ b/jni/ruby/ext/socket/tcpserver.c
@@ -0,0 +1,178 @@
+/************************************************
+
+ tcpserver.c -
+
+ created at: Thu Mar 31 12:21:29 JST 1994
+
+ Copyright (C) 1993-2007 Yukihiro Matsumoto
+
+************************************************/
+
+#include "rubysocket.h"
+
+/*
+ * call-seq:
+ * TCPServer.new([hostname,] port) => tcpserver
+ *
+ * Creates a new server socket bound to _port_.
+ *
+ * If _hostname_ is given, the socket is bound to it.
+ *
+ * serv = TCPServer.new("127.0.0.1", 28561)
+ * s = serv.accept
+ * s.puts Time.now
+ * s.close
+ *
+ * Internally, TCPServer.new calls getaddrinfo() function to
+ * obtain addresses.
+ * If getaddrinfo() returns multiple addresses,
+ * TCPServer.new tries to create a server socket for each address
+ * and returns first one that is successful.
+ *
+ */
+static VALUE
+tcp_svr_init(int argc, VALUE *argv, VALUE sock)
+{
+ VALUE hostname, port;
+
+ rb_scan_args(argc, argv, "011", &hostname, &port);
+ return rsock_init_inetsock(sock, hostname, port, Qnil, Qnil, INET_SERVER);
+}
+
+/*
+ * call-seq:
+ * tcpserver.accept => tcpsocket
+ *
+ * Accepts an incoming connection. It returns a new TCPSocket object.
+ *
+ * TCPServer.open("127.0.0.1", 14641) {|serv|
+ * s = serv.accept
+ * s.puts Time.now
+ * s.close
+ * }
+ *
+ */
+static VALUE
+tcp_accept(VALUE sock)
+{
+ rb_io_t *fptr;
+ union_sockaddr from;
+ socklen_t fromlen;
+
+ GetOpenFile(sock, fptr);
+ fromlen = (socklen_t)sizeof(from);
+ return rsock_s_accept(rb_cTCPSocket, fptr->fd, &from.addr, &fromlen);
+}
+
+/*
+ * call-seq:
+ * tcpserver.accept_nonblock => tcpsocket
+ *
+ * Accepts an incoming connection using accept(2) after
+ * O_NONBLOCK is set for the underlying file descriptor.
+ * It returns an accepted TCPSocket for the incoming connection.
+ *
+ * === Example
+ * require 'socket'
+ * serv = TCPServer.new(2202)
+ * begin # emulate blocking accept
+ * sock = serv.accept_nonblock
+ * rescue IO::WaitReadable, Errno::EINTR
+ * IO.select([serv])
+ * retry
+ * end
+ * # sock is an accepted socket.
+ *
+ * Refer to Socket#accept for the exceptions that may be thrown if the call
+ * to TCPServer#accept_nonblock fails.
+ *
+ * TCPServer#accept_nonblock may raise any error corresponding to accept(2) failure,
+ * including Errno::EWOULDBLOCK.
+ *
+ * If the exception is Errno::EWOULDBLOCK, Errno::AGAIN, Errno::ECONNABORTED, Errno::EPROTO,
+ * it is extended by IO::WaitReadable.
+ * So IO::WaitReadable can be used to rescue the exceptions for retrying accept_nonblock.
+ *
+ * === See
+ * * TCPServer#accept
+ * * Socket#accept
+ */
+static VALUE
+tcp_accept_nonblock(VALUE sock)
+{
+ rb_io_t *fptr;
+ union_sockaddr from;
+ socklen_t fromlen;
+
+ GetOpenFile(sock, fptr);
+ fromlen = (socklen_t)sizeof(from);
+ return rsock_s_accept_nonblock(rb_cTCPSocket, fptr, &from.addr, &fromlen);
+}
+
+/*
+ * call-seq:
+ * tcpserver.sysaccept => file_descriptor
+ *
+ * Returns a file descriptor of a accepted connection.
+ *
+ * TCPServer.open("127.0.0.1", 28561) {|serv|
+ * fd = serv.sysaccept
+ * s = IO.for_fd(fd)
+ * s.puts Time.now
+ * s.close
+ * }
+ *
+ */
+static VALUE
+tcp_sysaccept(VALUE sock)
+{
+ rb_io_t *fptr;
+ union_sockaddr from;
+ socklen_t fromlen;
+
+ GetOpenFile(sock, fptr);
+ fromlen = (socklen_t)sizeof(from);
+ return rsock_s_accept(0, fptr->fd, &from.addr, &fromlen);
+}
+
+void
+rsock_init_tcpserver(void)
+{
+ /*
+ * Document-class: TCPServer < TCPSocket
+ *
+ * TCPServer represents a TCP/IP server socket.
+ *
+ * A simple TCP server may look like:
+ *
+ * require 'socket'
+ *
+ * server = TCPServer.new 2000 # Server bind to port 2000
+ * loop do
+ * client = server.accept # Wait for a client to connect
+ * client.puts "Hello !"
+ * client.puts "Time is #{Time.now}"
+ * client.close
+ * end
+ *
+ * A more usable server (serving multiple clients):
+ *
+ * require 'socket'
+ *
+ * server = TCPServer.new 2000
+ * loop do
+ * Thread.start(server.accept) do |client|
+ * client.puts "Hello !"
+ * client.puts "Time is #{Time.now}"
+ * client.close
+ * end
+ * end
+ *
+ */
+ rb_cTCPServer = rb_define_class("TCPServer", rb_cTCPSocket);
+ rb_define_method(rb_cTCPServer, "accept", tcp_accept, 0);
+ rb_define_method(rb_cTCPServer, "accept_nonblock", tcp_accept_nonblock, 0);
+ rb_define_method(rb_cTCPServer, "sysaccept", tcp_sysaccept, 0);
+ rb_define_method(rb_cTCPServer, "initialize", tcp_svr_init, -1);
+ rb_define_method(rb_cTCPServer, "listen", rsock_sock_listen, 1); /* in socket.c */
+}
diff --git a/jni/ruby/ext/socket/tcpsocket.c b/jni/ruby/ext/socket/tcpsocket.c
new file mode 100644
index 0000000..6217e42
--- /dev/null
+++ b/jni/ruby/ext/socket/tcpsocket.c
@@ -0,0 +1,82 @@
+/************************************************
+
+ tcpsocket.c -
+
+ created at: Thu Mar 31 12:21:29 JST 1994
+
+ Copyright (C) 1993-2007 Yukihiro Matsumoto
+
+************************************************/
+
+#include "rubysocket.h"
+
+/*
+ * call-seq:
+ * TCPSocket.new(remote_host, remote_port, local_host=nil, local_port=nil)
+ *
+ * Opens a TCP connection to +remote_host+ on +remote_port+. If +local_host+
+ * and +local_port+ are specified, then those parameters are used on the local
+ * end to establish the connection.
+ */
+static VALUE
+tcp_init(int argc, VALUE *argv, VALUE sock)
+{
+ VALUE remote_host, remote_serv;
+ VALUE local_host, local_serv;
+
+ rb_scan_args(argc, argv, "22", &remote_host, &remote_serv,
+ &local_host, &local_serv);
+
+ return rsock_init_inetsock(sock, remote_host, remote_serv,
+ local_host, local_serv, INET_CLIENT);
+}
+
+static VALUE
+tcp_sockaddr(struct sockaddr *addr, socklen_t len)
+{
+ return rsock_make_ipaddr(addr, len);
+}
+
+/*
+ * call-seq:
+ * TCPSocket.gethostbyname(hostname) => [official_hostname, alias_hostnames, address_family, *address_list]
+ *
+ * Lookups host information by _hostname_.
+ *
+ * TCPSocket.gethostbyname("localhost")
+ * #=> ["localhost", ["hal"], 2, "127.0.0.1"]
+ *
+ */
+static VALUE
+tcp_s_gethostbyname(VALUE obj, VALUE host)
+{
+ rb_secure(3);
+ return rsock_make_hostent(host, rsock_addrinfo(host, Qnil, SOCK_STREAM, AI_CANONNAME),
+ tcp_sockaddr);
+}
+
+void
+rsock_init_tcpsocket(void)
+{
+ /*
+ * Document-class: TCPSocket < IPSocket
+ *
+ * TCPSocket represents a TCP/IP client socket.
+ *
+ * A simple client may look like:
+ *
+ * require 'socket'
+ *
+ * s = TCPSocket.new 'localhost', 2000
+ *
+ * while line = s.gets # Read lines from socket
+ * puts line # and print them
+ * end
+ *
+ * s.close # close socket when done
+ *
+ */
+ rb_cTCPSocket = rb_define_class("TCPSocket", rb_cIPSocket);
+ rb_define_singleton_method(rb_cTCPSocket, "gethostbyname", tcp_s_gethostbyname, 1);
+ rb_define_method(rb_cTCPSocket, "initialize", tcp_init, -1);
+}
diff --git a/jni/ruby/ext/socket/udpsocket.c b/jni/ruby/ext/socket/udpsocket.c
new file mode 100644
index 0000000..eb605ca
--- /dev/null
+++ b/jni/ruby/ext/socket/udpsocket.c
@@ -0,0 +1,266 @@
+/************************************************
+
+ udpsocket.c -
+
+ created at: Thu Mar 31 12:21:29 JST 1994
+
+ Copyright (C) 1993-2007 Yukihiro Matsumoto
+
+************************************************/
+
+#include "rubysocket.h"
+
+/*
+ * call-seq:
+ * UDPSocket.new([address_family]) => socket
+ *
+ * Creates a new UDPSocket object.
+ *
+ * _address_family_ should be an integer, a string or a symbol:
+ * Socket::AF_INET, "AF_INET", :INET, etc.
+ *
+ * UDPSocket.new #=> #<UDPSocket:fd 3>
+ * UDPSocket.new(Socket::AF_INET6) #=> #<UDPSocket:fd 4>
+ *
+ */
+static VALUE
+udp_init(int argc, VALUE *argv, VALUE sock)
+{
+ VALUE arg;
+ int family = AF_INET;
+ int fd;
+
+ rb_secure(3);
+ if (rb_scan_args(argc, argv, "01", &arg) == 1) {
+ family = rsock_family_arg(arg);
+ }
+ fd = rsock_socket(family, SOCK_DGRAM, 0);
+ if (fd < 0) {
+ rb_sys_fail("socket(2) - udp");
+ }
+
+ return rsock_init_sock(sock, fd);
+}
+
+struct udp_arg
+{
+ struct rb_addrinfo *res;
+ int fd;
+};
+
+static VALUE
+udp_connect_internal(struct udp_arg *arg)
+{
+ int fd = arg->fd;
+ struct addrinfo *res;
+
+ for (res = arg->res->ai; res; res = res->ai_next) {
+ if (rsock_connect(fd, res->ai_addr, res->ai_addrlen, 0) >= 0) {
+ return Qtrue;
+ }
+ }
+ return Qfalse;
+}
+
+/*
+ * call-seq:
+ * udpsocket.connect(host, port) => 0
+ *
+ * Connects _udpsocket_ to _host_:_port_.
+ *
+ * This makes possible to send without destination address.
+ *
+ * u1 = UDPSocket.new
+ * u1.bind("127.0.0.1", 4913)
+ * u2 = UDPSocket.new
+ * u2.connect("127.0.0.1", 4913)
+ * u2.send "uuuu", 0
+ * p u1.recvfrom(10) #=> ["uuuu", ["AF_INET", 33230, "localhost", "127.0.0.1"]]
+ *
+ */
+static VALUE
+udp_connect(VALUE sock, VALUE host, VALUE port)
+{
+ rb_io_t *fptr;
+ struct udp_arg arg;
+ VALUE ret;
+
+ rb_secure(3);
+ arg.res = rsock_addrinfo(host, port, SOCK_DGRAM, 0);
+ GetOpenFile(sock, fptr);
+ arg.fd = fptr->fd;
+ ret = rb_ensure(udp_connect_internal, (VALUE)&arg,
+ rsock_freeaddrinfo, (VALUE)arg.res);
+ if (!ret) rsock_sys_fail_host_port("connect(2)", host, port);
+ return INT2FIX(0);
+}
+
+/*
+ * call-seq:
+ * udpsocket.bind(host, port) #=> 0
+ *
+ * Binds _udpsocket_ to _host_:_port_.
+ *
+ * u1 = UDPSocket.new
+ * u1.bind("127.0.0.1", 4913)
+ * u1.send "message-to-self", 0, "127.0.0.1", 4913
+ * p u1.recvfrom(10) #=> ["message-to", ["AF_INET", 4913, "localhost", "127.0.0.1"]]
+ *
+ */
+static VALUE
+udp_bind(VALUE sock, VALUE host, VALUE port)
+{
+ rb_io_t *fptr;
+ struct rb_addrinfo *res0;
+ struct addrinfo *res;
+
+ rb_secure(3);
+ res0 = rsock_addrinfo(host, port, SOCK_DGRAM, 0);
+ GetOpenFile(sock, fptr);
+ for (res = res0->ai; res; res = res->ai_next) {
+ if (bind(fptr->fd, res->ai_addr, res->ai_addrlen) < 0) {
+ continue;
+ }
+ rb_freeaddrinfo(res0);
+ return INT2FIX(0);
+ }
+ rb_freeaddrinfo(res0);
+
+ rsock_sys_fail_host_port("bind(2)", host, port);
+
+ return INT2FIX(0);
+}
+
+/*
+ * call-seq:
+ * udpsocket.send(mesg, flags, host, port) => numbytes_sent
+ * udpsocket.send(mesg, flags, sockaddr_to) => numbytes_sent
+ * udpsocket.send(mesg, flags) => numbytes_sent
+ *
+ * Sends _mesg_ via _udpsocket_.
+ *
+ * _flags_ should be a bitwise OR of Socket::MSG_* constants.
+ *
+ * u1 = UDPSocket.new
+ * u1.bind("127.0.0.1", 4913)
+ *
+ * u2 = UDPSocket.new
+ * u2.send "hi", 0, "127.0.0.1", 4913
+ *
+ * mesg, addr = u1.recvfrom(10)
+ * u1.send mesg, 0, addr[3], addr[1]
+ *
+ * p u2.recv(100) #=> "hi"
+ *
+ */
+static VALUE
+udp_send(int argc, VALUE *argv, VALUE sock)
+{
+ VALUE flags, host, port;
+ rb_io_t *fptr;
+ int n;
+ struct rb_addrinfo *res0;
+ struct addrinfo *res;
+ struct rsock_send_arg arg;
+
+ if (argc == 2 || argc == 3) {
+ return rsock_bsock_send(argc, argv, sock);
+ }
+ rb_scan_args(argc, argv, "4", &arg.mesg, &flags, &host, &port);
+
+ StringValue(arg.mesg);
+ res0 = rsock_addrinfo(host, port, SOCK_DGRAM, 0);
+ GetOpenFile(sock, fptr);
+ arg.fd = fptr->fd;
+ arg.flags = NUM2INT(flags);
+ for (res = res0->ai; res; res = res->ai_next) {
+ retry:
+ arg.to = res->ai_addr;
+ arg.tolen = res->ai_addrlen;
+ rsock_maybe_fd_writable(arg.fd);
+ n = (int)BLOCKING_REGION_FD(rsock_sendto_blocking, &arg);
+ if (n >= 0) {
+ rb_freeaddrinfo(res0);
+ return INT2FIX(n);
+ }
+ if (rb_io_wait_writable(fptr->fd)) {
+ goto retry;
+ }
+ }
+ rb_freeaddrinfo(res0);
+ rsock_sys_fail_host_port("sendto(2)", host, port);
+ return INT2FIX(n);
+}
+
+/*
+ * call-seq:
+ * udpsocket.recvfrom_nonblock(maxlen) => [mesg, sender_inet_addr]
+ * udpsocket.recvfrom_nonblock(maxlen, flags) => [mesg, sender_inet_addr]
+ *
+ * Receives up to _maxlen_ bytes from +udpsocket+ using recvfrom(2) after
+ * O_NONBLOCK is set for the underlying file descriptor.
+ * If _maxlen_ is omitted, its default value is 65536.
+ * _flags_ is zero or more of the +MSG_+ options.
+ * The first element of the results, _mesg_, is the data received.
+ * The second element, _sender_inet_addr_, is an array to represent the sender address.
+ *
+ * When recvfrom(2) returns 0,
+ * Socket#recvfrom_nonblock returns an empty string as data.
+ * It means an empty packet.
+ *
+ * === Parameters
+ * * +maxlen+ - the number of bytes to receive from the socket
+ * * +flags+ - zero or more of the +MSG_+ options
+ *
+ * === Example
+ * require 'socket'
+ * s1 = UDPSocket.new
+ * s1.bind("127.0.0.1", 0)
+ * s2 = UDPSocket.new
+ * s2.bind("127.0.0.1", 0)
+ * s2.connect(*s1.addr.values_at(3,1))
+ * s1.connect(*s2.addr.values_at(3,1))
+ * s1.send "aaa", 0
+ * begin # emulate blocking recvfrom
+ * p s2.recvfrom_nonblock(10) #=> ["aaa", ["AF_INET", 33302, "localhost.localdomain", "127.0.0.1"]]
+ * rescue IO::WaitReadable
+ * IO.select([s2])
+ * retry
+ * end
+ *
+ * Refer to Socket#recvfrom for the exceptions that may be thrown if the call
+ * to _recvfrom_nonblock_ fails.
+ *
+ * UDPSocket#recvfrom_nonblock may raise any error corresponding to recvfrom(2) failure,
+ * including Errno::EWOULDBLOCK.
+ *
+ * If the exception is Errno::EWOULDBLOCK or Errno::AGAIN,
+ * it is extended by IO::WaitReadable.
+ * So IO::WaitReadable can be used to rescue the exceptions for retrying recvfrom_nonblock.
+ *
+ * === See
+ * * Socket#recvfrom
+ */
+static VALUE
+udp_recvfrom_nonblock(int argc, VALUE *argv, VALUE sock)
+{
+ return rsock_s_recvfrom_nonblock(sock, argc, argv, RECV_IP);
+}
+
+void
+rsock_init_udpsocket(void)
+{
+ /*
+ * Document-class: UDPSocket < IPSocket
+ *
+ * UDPSocket represents a UDP/IP socket.
+ *
+ */
+ rb_cUDPSocket = rb_define_class("UDPSocket", rb_cIPSocket);
+ rb_define_method(rb_cUDPSocket, "initialize", udp_init, -1);
+ rb_define_method(rb_cUDPSocket, "connect", udp_connect, 2);
+ rb_define_method(rb_cUDPSocket, "bind", udp_bind, 2);
+ rb_define_method(rb_cUDPSocket, "send", udp_send, -1);
+ rb_define_method(rb_cUDPSocket, "recvfrom_nonblock", udp_recvfrom_nonblock, -1);
+}
+
diff --git a/jni/ruby/ext/socket/unixserver.c b/jni/ruby/ext/socket/unixserver.c
new file mode 100644
index 0000000..df98497
--- /dev/null
+++ b/jni/ruby/ext/socket/unixserver.c
@@ -0,0 +1,155 @@
+/************************************************
+
+ unixserver.c -
+
+ created at: Thu Mar 31 12:21:29 JST 1994
+
+ Copyright (C) 1993-2007 Yukihiro Matsumoto
+
+************************************************/
+
+#include "rubysocket.h"
+
+#ifdef HAVE_SYS_UN_H
+/*
+ * call-seq:
+ * UNIXServer.new(path) => unixserver
+ *
+ * Creates a new UNIX server socket bound to _path_.
+ *
+ * serv = UNIXServer.new("/tmp/sock")
+ * s = serv.accept
+ * p s.read
+ */
+static VALUE
+unix_svr_init(VALUE sock, VALUE path)
+{
+ return rsock_init_unixsock(sock, path, 1);
+}
+
+/*
+ * call-seq:
+ * unixserver.accept => unixsocket
+ *
+ * Accepts an incoming connection.
+ * It returns a new UNIXSocket object.
+ *
+ * UNIXServer.open("/tmp/sock") {|serv|
+ * UNIXSocket.open("/tmp/sock") {|c|
+ * s = serv.accept
+ * s.puts "hi"
+ * s.close
+ * p c.read #=> "hi\n"
+ * }
+ * }
+ *
+ */
+static VALUE
+unix_accept(VALUE sock)
+{
+ rb_io_t *fptr;
+ struct sockaddr_un from;
+ socklen_t fromlen;
+
+ GetOpenFile(sock, fptr);
+ fromlen = (socklen_t)sizeof(struct sockaddr_un);
+ return rsock_s_accept(rb_cUNIXSocket, fptr->fd,
+ (struct sockaddr*)&from, &fromlen);
+}
+
+/*
+ * call-seq:
+ * unixserver.accept_nonblock => unixsocket
+ *
+ * Accepts an incoming connection using accept(2) after
+ * O_NONBLOCK is set for the underlying file descriptor.
+ * It returns an accepted UNIXSocket for the incoming connection.
+ *
+ * === Example
+ * require 'socket'
+ * serv = UNIXServer.new("/tmp/sock")
+ * begin # emulate blocking accept
+ * sock = serv.accept_nonblock
+ * rescue IO::WaitReadable, Errno::EINTR
+ * IO.select([serv])
+ * retry
+ * end
+ * # sock is an accepted socket.
+ *
+ * Refer to Socket#accept for the exceptions that may be thrown if the call
+ * to UNIXServer#accept_nonblock fails.
+ *
+ * UNIXServer#accept_nonblock may raise any error corresponding to accept(2) failure,
+ * including Errno::EWOULDBLOCK.
+ *
+ * If the exception is Errno::EWOULDBLOCK, Errno::AGAIN, Errno::ECONNABORTED or Errno::EPROTO,
+ * it is extended by IO::WaitReadable.
+ * So IO::WaitReadable can be used to rescue the exceptions for retrying accept_nonblock.
+ *
+ * === See
+ * * UNIXServer#accept
+ * * Socket#accept
+ */
+static VALUE
+unix_accept_nonblock(VALUE sock)
+{
+ rb_io_t *fptr;
+ struct sockaddr_un from;
+ socklen_t fromlen;
+
+ GetOpenFile(sock, fptr);
+ fromlen = (socklen_t)sizeof(from);
+ return rsock_s_accept_nonblock(rb_cUNIXSocket, fptr,
+ (struct sockaddr *)&from, &fromlen);
+}
+
+/*
+ * call-seq:
+ * unixserver.sysaccept => file_descriptor
+ *
+ * Accepts a new connection.
+ * It returns the new file descriptor which is an integer.
+ *
+ * UNIXServer.open("/tmp/sock") {|serv|
+ * UNIXSocket.open("/tmp/sock") {|c|
+ * fd = serv.sysaccept
+ * s = IO.new(fd)
+ * s.puts "hi"
+ * s.close
+ * p c.read #=> "hi\n"
+ * }
+ * }
+ *
+ */
+static VALUE
+unix_sysaccept(VALUE sock)
+{
+ rb_io_t *fptr;
+ struct sockaddr_un from;
+ socklen_t fromlen;
+
+ GetOpenFile(sock, fptr);
+ fromlen = (socklen_t)sizeof(struct sockaddr_un);
+ return rsock_s_accept(0, fptr->fd, (struct sockaddr*)&from, &fromlen);
+}
+
+#endif
+
+void
+rsock_init_unixserver(void)
+{
+#ifdef HAVE_SYS_UN_H
+ /*
+ * Document-class: UNIXServer < UNIXSocket
+ *
+ * UNIXServer represents a UNIX domain stream server socket.
+ *
+ */
+ rb_cUNIXServer = rb_define_class("UNIXServer", rb_cUNIXSocket);
+ rb_define_method(rb_cUNIXServer, "initialize", unix_svr_init, 1);
+ rb_define_method(rb_cUNIXServer, "accept", unix_accept, 0);
+ rb_define_method(rb_cUNIXServer, "accept_nonblock", unix_accept_nonblock, 0);
+ rb_define_method(rb_cUNIXServer, "sysaccept", unix_sysaccept, 0);
+ rb_define_method(rb_cUNIXServer, "listen", rsock_sock_listen, 1); /* in socket.c */
+#endif
+}
diff --git a/jni/ruby/ext/socket/unixsocket.c b/jni/ruby/ext/socket/unixsocket.c
new file mode 100644
index 0000000..9a4c2cf
--- /dev/null
+++ b/jni/ruby/ext/socket/unixsocket.c
@@ -0,0 +1,534 @@
+/************************************************
+
+ unixsocket.c -
+
+ created at: Thu Mar 31 12:21:29 JST 1994
+
+ Copyright (C) 1993-2007 Yukihiro Matsumoto
+
+************************************************/
+
+#include "rubysocket.h"
+
+#ifdef HAVE_SYS_UN_H
+struct unixsock_arg {
+ struct sockaddr_un *sockaddr;
+ socklen_t sockaddrlen;
+ int fd;
+};
+
+static VALUE
+unixsock_connect_internal(VALUE a)
+{
+ struct unixsock_arg *arg = (struct unixsock_arg *)a;
+ return (VALUE)rsock_connect(arg->fd, (struct sockaddr*)arg->sockaddr,
+ arg->sockaddrlen, 0);
+}
+
+VALUE
+rsock_init_unixsock(VALUE sock, VALUE path, int server)
+{
+ struct sockaddr_un sockaddr;
+ socklen_t sockaddrlen;
+ int fd, status;
+ rb_io_t *fptr;
+
+ SafeStringValue(path);
+
+ INIT_SOCKADDR_UN(&sockaddr, sizeof(struct sockaddr_un));
+ if (sizeof(sockaddr.sun_path) < (size_t)RSTRING_LEN(path)) {
+ rb_raise(rb_eArgError, "too long unix socket path (%ldbytes given but %dbytes max)",
+ RSTRING_LEN(path), (int)sizeof(sockaddr.sun_path));
+ }
+ memcpy(sockaddr.sun_path, RSTRING_PTR(path), RSTRING_LEN(path));
+ sockaddrlen = rsock_unix_sockaddr_len(path);
+
+ fd = rsock_socket(AF_UNIX, SOCK_STREAM, 0);
+ if (fd < 0) {
+ rsock_sys_fail_path("socket(2)", path);
+ }
+
+ if (server) {
+ status = bind(fd, (struct sockaddr*)&sockaddr, sockaddrlen);
+ }
+ else {
+ int prot;
+ struct unixsock_arg arg;
+ arg.sockaddr = &sockaddr;
+ arg.sockaddrlen = sockaddrlen;
+ arg.fd = fd;
+ status = (int)rb_protect(unixsock_connect_internal, (VALUE)&arg, &prot);
+ if (prot) {
+ close(fd);
+ rb_jump_tag(prot);
+ }
+ }
+
+ if (status < 0) {
+ close(fd);
+ rsock_sys_fail_path("connect(2)", path);
+ }
+
+ if (server) {
+ if (listen(fd, SOMAXCONN) < 0) {
+ close(fd);
+ rsock_sys_fail_path("listen(2)", path);
+ }
+ }
+
+ rsock_init_sock(sock, fd);
+ if (server) {
+ GetOpenFile(sock, fptr);
+ fptr->pathv = rb_str_new_frozen(path);
+ }
+
+ return sock;
+}
+
+/*
+ * call-seq:
+ * UNIXSocket.new(path) => unixsocket
+ *
+ * Creates a new UNIX client socket connected to _path_.
+ *
+ * s = UNIXSocket.new("/tmp/sock")
+ * s.send "hello", 0
+ *
+ */
+static VALUE
+unix_init(VALUE sock, VALUE path)
+{
+ return rsock_init_unixsock(sock, path, 0);
+}
+
+/*
+ * call-seq:
+ * unixsocket.path => path
+ *
+ * Returns the path of the local address of unixsocket.
+ *
+ * s = UNIXServer.new("/tmp/sock")
+ * p s.path #=> "/tmp/sock"
+ *
+ */
+static VALUE
+unix_path(VALUE sock)
+{
+ rb_io_t *fptr;
+
+ GetOpenFile(sock, fptr);
+ if (NIL_P(fptr->pathv)) {
+ struct sockaddr_un addr;
+ socklen_t len = (socklen_t)sizeof(addr);
+ socklen_t len0 = len;
+ if (getsockname(fptr->fd, (struct sockaddr*)&addr, &len) < 0)
+ rsock_sys_fail_path("getsockname(2)", fptr->pathv);
+ if (len0 < len) len = len0;
+ fptr->pathv = rb_obj_freeze(rsock_unixpath_str(&addr, len));
+ }
+ return rb_str_dup(fptr->pathv);
+}
+
+/*
+ * call-seq:
+ * unixsocket.recvfrom(maxlen [, flags]) => [mesg, unixaddress]
+ *
+ * Receives a message via _unixsocket_.
+ *
+ * _maxlen_ is the maximum number of bytes to receive.
+ *
+ * _flags_ should be a bitwise OR of Socket::MSG_* constants.
+ *
+ * s1 = Socket.new(:UNIX, :DGRAM, 0)
+ * s1_ai = Addrinfo.unix("/tmp/sock1")
+ * s1.bind(s1_ai)
+ *
+ * s2 = Socket.new(:UNIX, :DGRAM, 0)
+ * s2_ai = Addrinfo.unix("/tmp/sock2")
+ * s2.bind(s2_ai)
+ * s3 = UNIXSocket.for_fd(s2.fileno)
+ *
+ * s1.send "a", 0, s2_ai
+ * p s3.recvfrom(10) #=> ["a", ["AF_UNIX", "/tmp/sock1"]]
+ *
+ */
+static VALUE
+unix_recvfrom(int argc, VALUE *argv, VALUE sock)
+{
+ return rsock_s_recvfrom(sock, argc, argv, RECV_UNIX);
+}
+
+#if defined(HAVE_STRUCT_MSGHDR_MSG_CONTROL) && defined(SCM_RIGHTS)
+#define FD_PASSING_BY_MSG_CONTROL 1
+#else
+#define FD_PASSING_BY_MSG_CONTROL 0
+#endif
+
+#if defined(HAVE_STRUCT_MSGHDR_MSG_ACCRIGHTS)
+#define FD_PASSING_BY_MSG_ACCRIGHTS 1
+#else
+#define FD_PASSING_BY_MSG_ACCRIGHTS 0
+#endif
+
+struct iomsg_arg {
+ int fd;
+ struct msghdr msg;
+};
+
+#if defined(HAVE_SENDMSG) && (FD_PASSING_BY_MSG_CONTROL || FD_PASSING_BY_MSG_ACCRIGHTS)
+static VALUE
+sendmsg_blocking(void *data)
+{
+ struct iomsg_arg *arg = data;
+ return sendmsg(arg->fd, &arg->msg, 0);
+}
+
+/*
+ * call-seq:
+ * unixsocket.send_io(io) => nil
+ *
+ * Sends _io_ as file descriptor passing.
+ *
+ * s1, s2 = UNIXSocket.pair
+ *
+ * s1.send_io STDOUT
+ * stdout = s2.recv_io
+ *
+ * p STDOUT.fileno #=> 1
+ * p stdout.fileno #=> 6
+ *
+ * stdout.puts "hello" # outputs "hello\n" to standard output.
+ */
+static VALUE
+unix_send_io(VALUE sock, VALUE val)
+{
+ int fd;
+ rb_io_t *fptr;
+ struct iomsg_arg arg;
+ struct iovec vec[1];
+ char buf[1];
+
+#if FD_PASSING_BY_MSG_CONTROL
+ union {
+ struct cmsghdr hdr;
+ char pad[sizeof(struct cmsghdr)+8+sizeof(int)+8];
+ } cmsg;
+#endif
+
+ if (rb_obj_is_kind_of(val, rb_cIO)) {
+ rb_io_t *valfptr;
+ GetOpenFile(val, valfptr);
+ fd = valfptr->fd;
+ }
+ else if (FIXNUM_P(val)) {
+ fd = FIX2INT(val);
+ }
+ else {
+ rb_raise(rb_eTypeError, "neither IO nor file descriptor");
+ }
+
+ GetOpenFile(sock, fptr);
+
+ arg.msg.msg_name = NULL;
+ arg.msg.msg_namelen = 0;
+
+ /* Linux and Solaris doesn't work if msg_iov is NULL. */
+ buf[0] = '\0';
+ vec[0].iov_base = buf;
+ vec[0].iov_len = 1;
+ arg.msg.msg_iov = vec;
+ arg.msg.msg_iovlen = 1;
+
+#if FD_PASSING_BY_MSG_CONTROL
+ arg.msg.msg_control = (caddr_t)&cmsg;
+ arg.msg.msg_controllen = (socklen_t)CMSG_LEN(sizeof(int));
+ arg.msg.msg_flags = 0;
+ MEMZERO((char*)&cmsg, char, sizeof(cmsg));
+ cmsg.hdr.cmsg_len = (socklen_t)CMSG_LEN(sizeof(int));
+ cmsg.hdr.cmsg_level = SOL_SOCKET;
+ cmsg.hdr.cmsg_type = SCM_RIGHTS;
+ memcpy(CMSG_DATA(&cmsg.hdr), &fd, sizeof(int));
+#else
+ arg.msg.msg_accrights = (caddr_t)&fd;
+ arg.msg.msg_accrightslen = sizeof(fd);
+#endif
+
+ arg.fd = fptr->fd;
+ while ((int)BLOCKING_REGION_FD(sendmsg_blocking, &arg) == -1) {
+ if (!rb_io_wait_writable(arg.fd))
+ rsock_sys_fail_path("sendmsg(2)", fptr->pathv);
+ }
+
+ return Qnil;
+}
+#else
+#define unix_send_io rb_f_notimplement
+#endif
+
+#if defined(HAVE_RECVMSG) && (FD_PASSING_BY_MSG_CONTROL || FD_PASSING_BY_MSG_ACCRIGHTS)
+static VALUE
+recvmsg_blocking(void *data)
+{
+ struct iomsg_arg *arg = data;
+ int flags = 0;
+ return rsock_recvmsg(arg->fd, &arg->msg, flags);
+}
+
+/*
+ * call-seq:
+ * unixsocket.recv_io([klass [, mode]]) => io
+ *
+ * Example
+ *
+ * UNIXServer.open("/tmp/sock") {|serv|
+ * UNIXSocket.open("/tmp/sock") {|c|
+ * s = serv.accept
+ *
+ * c.send_io STDOUT
+ * stdout = s.recv_io
+ *
+ * p STDOUT.fileno #=> 1
+ * p stdout.fileno #=> 7
+ *
+ * stdout.puts "hello" # outputs "hello\n" to standard output.
+ * }
+ * }
+ *
+ */
+static VALUE
+unix_recv_io(int argc, VALUE *argv, VALUE sock)
+{
+ VALUE klass, mode;
+ rb_io_t *fptr;
+ struct iomsg_arg arg;
+ struct iovec vec[2];
+ char buf[1];
+
+ int fd;
+#if FD_PASSING_BY_MSG_CONTROL
+ union {
+ struct cmsghdr hdr;
+ char pad[sizeof(struct cmsghdr)+8+sizeof(int)+8];
+ } cmsg;
+#endif
+
+ rb_scan_args(argc, argv, "02", &klass, &mode);
+ if (argc == 0)
+ klass = rb_cIO;
+ if (argc <= 1)
+ mode = Qnil;
+
+ GetOpenFile(sock, fptr);
+
+ arg.msg.msg_name = NULL;
+ arg.msg.msg_namelen = 0;
+
+ vec[0].iov_base = buf;
+ vec[0].iov_len = sizeof(buf);
+ arg.msg.msg_iov = vec;
+ arg.msg.msg_iovlen = 1;
+
+#if FD_PASSING_BY_MSG_CONTROL
+ arg.msg.msg_control = (caddr_t)&cmsg;
+ arg.msg.msg_controllen = (socklen_t)CMSG_SPACE(sizeof(int));
+ arg.msg.msg_flags = 0;
+ cmsg.hdr.cmsg_len = (socklen_t)CMSG_LEN(sizeof(int));
+ cmsg.hdr.cmsg_level = SOL_SOCKET;
+ cmsg.hdr.cmsg_type = SCM_RIGHTS;
+ fd = -1;
+ memcpy(CMSG_DATA(&cmsg.hdr), &fd, sizeof(int));
+#else
+ arg.msg.msg_accrights = (caddr_t)&fd;
+ arg.msg.msg_accrightslen = sizeof(fd);
+ fd = -1;
+#endif
+
+ arg.fd = fptr->fd;
+ while ((int)BLOCKING_REGION_FD(recvmsg_blocking, &arg) == -1) {
+ if (!rb_io_wait_readable(arg.fd))
+ rsock_sys_fail_path("recvmsg(2)", fptr->pathv);
+ }
+
+#if FD_PASSING_BY_MSG_CONTROL
+ if (arg.msg.msg_controllen < (socklen_t)sizeof(struct cmsghdr)) {
+ rb_raise(rb_eSocket,
+ "file descriptor was not passed (msg_controllen=%d smaller than sizeof(struct cmsghdr)=%d)",
+ (int)arg.msg.msg_controllen, (int)sizeof(struct cmsghdr));
+ }
+ if (cmsg.hdr.cmsg_level != SOL_SOCKET) {
+ rb_raise(rb_eSocket,
+ "file descriptor was not passed (cmsg_level=%d, %d expected)",
+ cmsg.hdr.cmsg_level, SOL_SOCKET);
+ }
+ if (cmsg.hdr.cmsg_type != SCM_RIGHTS) {
+ rb_raise(rb_eSocket,
+ "file descriptor was not passed (cmsg_type=%d, %d expected)",
+ cmsg.hdr.cmsg_type, SCM_RIGHTS);
+ }
+ if (arg.msg.msg_controllen < (socklen_t)CMSG_LEN(sizeof(int))) {
+ rb_raise(rb_eSocket,
+ "file descriptor was not passed (msg_controllen=%d smaller than CMSG_LEN(sizeof(int))=%d)",
+ (int)arg.msg.msg_controllen, (int)CMSG_LEN(sizeof(int)));
+ }
+ if ((socklen_t)CMSG_SPACE(sizeof(int)) < arg.msg.msg_controllen) {
+ rb_raise(rb_eSocket,
+ "file descriptor was not passed (msg_controllen=%d bigger than CMSG_SPACE(sizeof(int))=%d)",
+ (int)arg.msg.msg_controllen, (int)CMSG_SPACE(sizeof(int)));
+ }
+ if (cmsg.hdr.cmsg_len != CMSG_LEN(sizeof(int))) {
+ rsock_discard_cmsg_resource(&arg.msg, 0);
+ rb_raise(rb_eSocket,
+ "file descriptor was not passed (cmsg_len=%d, %d expected)",
+ (int)cmsg.hdr.cmsg_len, (int)CMSG_LEN(sizeof(int)));
+ }
+#else
+ if (arg.msg.msg_accrightslen != sizeof(fd)) {
+ rb_raise(rb_eSocket,
+ "file descriptor was not passed (accrightslen=%d, %d expected)",
+ arg.msg.msg_accrightslen, (int)sizeof(fd));
+ }
+#endif
+
+#if FD_PASSING_BY_MSG_CONTROL
+ memcpy(&fd, CMSG_DATA(&cmsg.hdr), sizeof(int));
+#endif
+
+ rb_update_max_fd(fd);
+
+ if (rsock_cmsg_cloexec_state < 0)
+ rsock_cmsg_cloexec_state = rsock_detect_cloexec(fd);
+ if (rsock_cmsg_cloexec_state == 0 || fd <= 2)
+ rb_maygvl_fd_fix_cloexec(fd);
+
+ if (klass == Qnil)
+ return INT2FIX(fd);
+ else {
+ ID for_fd;
+ int ff_argc;
+ VALUE ff_argv[2];
+ CONST_ID(for_fd, "for_fd");
+ ff_argc = mode == Qnil ? 1 : 2;
+ ff_argv[0] = INT2FIX(fd);
+ ff_argv[1] = mode;
+ return rb_funcall2(klass, for_fd, ff_argc, ff_argv);
+ }
+}
+#else
+#define unix_recv_io rb_f_notimplement
+#endif
+
+/*
+ * call-seq:
+ * unixsocket.addr => [address_family, unix_path]
+ *
+ * Returns the local address as an array which contains
+ * address_family and unix_path.
+ *
+ * Example
+ * serv = UNIXServer.new("/tmp/sock")
+ * p serv.addr #=> ["AF_UNIX", "/tmp/sock"]
+ */
+static VALUE
+unix_addr(VALUE sock)
+{
+ rb_io_t *fptr;
+ struct sockaddr_un addr;
+ socklen_t len = (socklen_t)sizeof addr;
+ socklen_t len0 = len;
+
+ GetOpenFile(sock, fptr);
+
+ if (getsockname(fptr->fd, (struct sockaddr*)&addr, &len) < 0)
+ rsock_sys_fail_path("getsockname(2)", fptr->pathv);
+ if (len0 < len) len = len0;
+ return rsock_unixaddr(&addr, len);
+}
+
+/*
+ * call-seq:
+ * unixsocket.peeraddr => [address_family, unix_path]
+ *
+ * Returns the remote address as an array which contains
+ * address_family and unix_path.
+ *
+ * Example
+ * serv = UNIXServer.new("/tmp/sock")
+ * c = UNIXSocket.new("/tmp/sock")
+ * p c.peeraddr #=> ["AF_UNIX", "/tmp/sock"]
+ */
+static VALUE
+unix_peeraddr(VALUE sock)
+{
+ rb_io_t *fptr;
+ struct sockaddr_un addr;
+ socklen_t len = (socklen_t)sizeof addr;
+ socklen_t len0 = len;
+
+ GetOpenFile(sock, fptr);
+
+ if (getpeername(fptr->fd, (struct sockaddr*)&addr, &len) < 0)
+ rsock_sys_fail_path("getpeername(2)", fptr->pathv);
+ if (len0 < len) len = len0;
+ return rsock_unixaddr(&addr, len);
+}
+
+/*
+ * call-seq:
+ * UNIXSocket.pair([type [, protocol]]) => [unixsocket1, unixsocket2]
+ * UNIXSocket.socketpair([type [, protocol]]) => [unixsocket1, unixsocket2]
+ *
+ * Creates a pair of sockets connected to each other.
+ *
+ * _socktype_ should be a socket type such as: :STREAM, :DGRAM, :RAW, etc.
+ *
+ * _protocol_ should be a protocol defined in the domain.
+ * 0 is default protocol for the domain.
+ *
+ * s1, s2 = UNIXSocket.pair
+ * s1.send "a", 0
+ * s1.send "b", 0
+ * p s2.recv(10) #=> "ab"
+ *
+ */
+static VALUE
+unix_s_socketpair(int argc, VALUE *argv, VALUE klass)
+{
+ VALUE domain, type, protocol;
+ VALUE args[3];
+
+ domain = INT2FIX(PF_UNIX);
+ rb_scan_args(argc, argv, "02", &type, &protocol);
+ if (argc == 0)
+ type = INT2FIX(SOCK_STREAM);
+ if (argc <= 1)
+ protocol = INT2FIX(0);
+
+ args[0] = domain;
+ args[1] = type;
+ args[2] = protocol;
+
+ return rsock_sock_s_socketpair(3, args, klass);
+}
+#endif
+
+void
+rsock_init_unixsocket(void)
+{
+#ifdef HAVE_SYS_UN_H
+ /*
+ * Document-class: UNIXSocket < BasicSocket
+ *
+ * UNIXSocket represents a UNIX domain stream client socket.
+ */
+ rb_cUNIXSocket = rb_define_class("UNIXSocket", rb_cBasicSocket);
+ rb_define_method(rb_cUNIXSocket, "initialize", unix_init, 1);
+ rb_define_method(rb_cUNIXSocket, "path", unix_path, 0);
+ rb_define_method(rb_cUNIXSocket, "addr", unix_addr, 0);
+ rb_define_method(rb_cUNIXSocket, "peeraddr", unix_peeraddr, 0);
+ rb_define_method(rb_cUNIXSocket, "recvfrom", unix_recvfrom, -1);
+ rb_define_method(rb_cUNIXSocket, "send_io", unix_send_io, 1);
+ rb_define_method(rb_cUNIXSocket, "recv_io", unix_recv_io, -1);
+ rb_define_singleton_method(rb_cUNIXSocket, "socketpair", unix_s_socketpair, -1);
+ rb_define_singleton_method(rb_cUNIXSocket, "pair", unix_s_socketpair, -1);
+#endif
+}
diff --git a/jni/ruby/ext/stringio/Makefile b/jni/ruby/ext/stringio/Makefile
new file mode 100644
index 0000000..474d920
--- /dev/null
+++ b/jni/ruby/ext/stringio/Makefile
@@ -0,0 +1,273 @@
+
+SHELL = /bin/sh
+
+# V=0 quiet, V=1 verbose. other values don't work.
+V = 0
+Q1 = $(V:1=)
+Q = $(Q1:0=@)
+ECHO1 = $(V:1=@:)
+ECHO = $(ECHO1:0=@echo)
+NULLCMD = :
+
+#### Start of system configuration section. ####
+top_srcdir = $(topdir)/.
+srcdir = $(top_srcdir)/ext/stringio
+topdir = ../..
+hdrdir = $(top_srcdir)/include
+arch_hdrdir = $(extout)/include/$(arch)
+PATH_SEPARATOR = :
+VPATH = $(srcdir):$(arch_hdrdir)/ruby:$(hdrdir)/ruby
+RUBYLIB =
+RUBYOPT = -
+prefix = $(DESTDIR)/usr/local
+rubysitearchprefix = $(rubylibprefix)/$(sitearch)
+rubyarchprefix = $(rubylibprefix)/$(arch)
+rubylibprefix = $(libdir)/$(RUBY_BASE_NAME)
+exec_prefix = $(prefix)
+vendorarchhdrdir = $(vendorhdrdir)/$(sitearch)
+sitearchhdrdir = $(sitehdrdir)/$(sitearch)
+rubyarchhdrdir = $(rubyhdrdir)/$(arch)
+vendorhdrdir = $(rubyhdrdir)/vendor_ruby
+sitehdrdir = $(rubyhdrdir)/site_ruby
+rubyhdrdir = $(includedir)/$(RUBY_VERSION_NAME)
+vendorarchdir = $(vendorlibdir)/$(sitearch)
+vendorlibdir = $(vendordir)/$(ruby_version)
+vendordir = $(rubylibprefix)/vendor_ruby
+sitearchdir = $(sitelibdir)/$(sitearch)
+sitelibdir = $(sitedir)/$(ruby_version)
+sitedir = $(rubylibprefix)/site_ruby
+rubyarchdir = $(rubylibdir)/$(arch)
+rubylibdir = $(rubylibprefix)/$(ruby_version)
+sitearchincludedir = $(includedir)/$(sitearch)
+archincludedir = $(includedir)/$(arch)
+sitearchlibdir = $(libdir)/$(sitearch)
+archlibdir = $(libdir)/$(arch)
+ridir = $(datarootdir)/$(RI_BASE_NAME)
+mandir = $(datarootdir)/man
+localedir = $(datarootdir)/locale
+libdir = $(exec_prefix)/lib
+psdir = $(docdir)
+pdfdir = $(docdir)
+dvidir = $(docdir)
+htmldir = $(docdir)
+infodir = $(datarootdir)/info
+docdir = $(datarootdir)/doc/$(PACKAGE)
+oldincludedir = $(DESTDIR)/usr/include
+includedir = $(prefix)/include
+localstatedir = $(prefix)/var
+sharedstatedir = $(prefix)/com
+sysconfdir = $(prefix)/etc
+datadir = $(datarootdir)
+datarootdir = $(prefix)/share
+libexecdir = $(exec_prefix)/libexec
+sbindir = $(exec_prefix)/sbin
+bindir = $(exec_prefix)/bin
+archdir = $(rubyarchdir)
+
+
+CC = gcc
+CXX = g++
+LIBRUBY = $(LIBRUBY_SO)
+LIBRUBY_A = lib$(RUBY_SO_NAME)-static.a
+LIBRUBYARG_SHARED = -Wl,-R$(libdir) -L$(libdir) -l$(RUBY_SO_NAME)
+LIBRUBYARG_STATIC = -Wl,-R$(libdir) -L$(libdir) -l$(RUBY_SO_NAME)-static
+empty =
+OUTFLAG = -o $(empty)
+COUTFLAG = -o $(empty)
+
+RUBY_EXTCONF_H = extconf.h
+cflags = $(optflags) $(debugflags) $(warnflags)
+optflags = -O3 -fno-fast-math
+debugflags = -ggdb3
+warnflags = -Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wunused-variable -Wpointer-arith -Wwrite-strings -Wdeclaration-after-statement -Wimplicit-function-declaration -Wdeprecated-declarations -Wno-packed-bitfield-compat
+CCDLFLAGS = -fPIC
+CFLAGS = $(CCDLFLAGS) $(cflags) -fPIC $(ARCH_FLAG)
+INCFLAGS = -I. -I$(arch_hdrdir) -I$(hdrdir) -I$(srcdir)
+DEFS =
+CPPFLAGS = -DRUBY_EXTCONF_H=\"$(RUBY_EXTCONF_H)\" $(DEFS) $(cppflags)
+CXXFLAGS = $(CCDLFLAGS) $(cxxflags) $(ARCH_FLAG)
+ldflags = -L. -fstack-protector -rdynamic -Wl,-export-dynamic
+dldflags =
+ARCH_FLAG =
+DLDFLAGS = $(ldflags) $(dldflags) $(ARCH_FLAG)
+LDSHARED = $(CC) -shared
+LDSHAREDXX = $(CXX) -shared
+AR = ar
+EXEEXT =
+
+RUBY_INSTALL_NAME = $(RUBY_BASE_NAME)
+RUBY_SO_NAME = ruby
+RUBYW_INSTALL_NAME =
+RUBY_VERSION_NAME = $(RUBY_BASE_NAME)-$(ruby_version)
+RUBYW_BASE_NAME = rubyw
+RUBY_BASE_NAME = ruby
+
+arch = x86_64-linux
+sitearch = $(arch)
+ruby_version = 2.2.0
+ruby = $(topdir)/miniruby -I'$(topdir)' -I'$(top_srcdir)/lib' -I'$(extout)/$(arch)' -I'$(extout)/common'
+RUBY = $(ruby)
+ruby_headers = $(hdrdir)/ruby.h $(hdrdir)/ruby/ruby.h $(hdrdir)/ruby/defines.h $(hdrdir)/ruby/missing.h $(hdrdir)/ruby/intern.h $(hdrdir)/ruby/st.h $(hdrdir)/ruby/subst.h $(arch_hdrdir)/ruby/config.h $(RUBY_EXTCONF_H)
+
+RM = rm -f
+RM_RF = $(RUBY) -run -e rm -- -rf
+RMDIRS = rmdir --ignore-fail-on-non-empty -p
+MAKEDIRS = /bin/mkdir -p
+INSTALL = /usr/bin/install -c
+INSTALL_PROG = $(INSTALL) -m 0755
+INSTALL_DATA = $(INSTALL) -m 644
+COPY = cp
+TOUCH = exit >
+
+#### End of system configuration section. ####
+
+preload =
+
+libpath = . $(topdir)
+LIBPATH = -L. -L$(topdir)
+DEFFILE =
+
+CLEANFILES = mkmf.log
+DISTCLEANFILES =
+DISTCLEANDIRS =
+
+extout = $(topdir)/.ext
+extout_prefix = $(extout)$(target_prefix)/
+target_prefix =
+LOCAL_LIBS =
+LIBS = $(LIBRUBYARG_SHARED) -lpthread -lgmp -ldl -lcrypt -lm -lc
+ORIG_SRCS = stringio.c
+SRCS = $(ORIG_SRCS)
+OBJS = stringio.o
+HDRS = $(srcdir)/extconf.h
+TARGET = stringio
+TARGET_NAME = stringio
+TARGET_ENTRY = Init_$(TARGET_NAME)
+DLLIB = $(TARGET).so
+EXTSTATIC =
+STATIC_LIB = $(TARGET).a
+
+TIMESTAMP_DIR = $(extout)/.timestamp
+BINDIR = $(extout)/bin
+RUBYCOMMONDIR = $(extout)/common
+RUBYLIBDIR = $(RUBYCOMMONDIR)$(target_prefix)
+RUBYARCHDIR = $(extout)/$(arch)$(target_prefix)
+HDRDIR = $(extout)/include/ruby$(target_prefix)
+ARCHHDRDIR = $(extout)/include/$(arch)/ruby$(target_prefix)
+
+TARGET_SO = $(RUBYARCHDIR)/$(DLLIB)
+CLEANLIBS = $(RUBYARCHDIR)/$(TARGET).so
+CLEANOBJS = *.o *.bak
+
+all: install
+static: all
+.PHONY: all install static install-so install-rb
+.PHONY: clean clean-so clean-static clean-rb
+
+clean-static::
+clean-rb-default::
+clean-rb::
+clean-so::
+clean: clean-so clean-static clean-rb-default clean-rb
+ -$(Q)$(RM) $(CLEANLIBS) $(CLEANOBJS) $(CLEANFILES) .*.time
+
+distclean-rb-default::
+distclean-rb::
+distclean-so::
+distclean-static::
+distclean: clean distclean-so distclean-static distclean-rb-default distclean-rb
+ -$(Q)$(RM) Makefile $(RUBY_EXTCONF_H) conftest.* mkmf.log
+ -$(Q)$(RM) core ruby$(EXEEXT) *~ $(DISTCLEANFILES)
+ -$(Q)$(RMDIRS) $(DISTCLEANDIRS) 2> /dev/null || true
+
+realclean: distclean
+install: install-so install-rb
+
+install-so: $(RUBYARCHDIR)/$(DLLIB)
+clean-so::
+ -$(Q)$(RM) $(RUBYARCHDIR)/$(DLLIB)
+ -$(Q)$(RMDIRS) $(RUBYARCHDIR) 2> /dev/null || true
+clean-static::
+ -$(Q)$(RM) $(STATIC_LIB)
+install-rb: pre-install-rb install-rb-default
+install-rb-default: pre-install-rb-default
+pre-install-rb: Makefile
+pre-install-rb-default: Makefile
+pre-install-rb-default:
+ @$(NULLCMD)
+$(TIMESTAMP_DIR)/.RUBYARCHDIR.time:
+ $(Q) $(MAKEDIRS) $(@D) $(RUBYARCHDIR)
+ $(Q) $(TOUCH) $@
+
+site-install: site-install-so site-install-rb
+site-install-so: install-so
+site-install-rb: install-rb
+
+.SUFFIXES: .c .m .cc .mm .cxx .cpp .o .S
+
+.cc.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<
+
+.cc.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -S $<
+
+.mm.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<
+
+.mm.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -S $<
+
+.cxx.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<
+
+.cxx.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -S $<
+
+.cpp.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<
+
+.cpp.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -S $<
+
+.c.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -c $<
+
+.c.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -S $<
+
+.m.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -c $<
+
+.m.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -S $<
+
+$(RUBYARCHDIR)/$(DLLIB): $(OBJS) Makefile $(TIMESTAMP_DIR)/.RUBYARCHDIR.time
+ $(ECHO) linking shared-object $(DLLIB)
+ -$(Q)$(RM) $(@)
+ $(Q) $(LDSHARED) -o $@ $(OBJS) $(LIBPATH) $(DLDFLAGS) $(LOCAL_LIBS) $(LIBS)
+
+$(STATIC_LIB): $(OBJS)
+ -$(Q)$(RM) $(@)
+ $(ECHO) linking static-library $(@)
+ $(Q) $(AR) cru $@ $(OBJS)
+ -$(Q)ranlib $(@) 2> /dev/null || true
+
+###
+$(OBJS): $(RUBY_EXTCONF_H)
+
+stringio.o: stringio.c $(HDRS) $(ruby_headers) \
+ $(hdrdir)/ruby/io.h \
+ $(hdrdir)/ruby/encoding.h \
+ $(hdrdir)/ruby/oniguruma.h
diff --git a/jni/ruby/ext/stringio/README b/jni/ruby/ext/stringio/README
new file mode 100644
index 0000000..fa3730d
--- /dev/null
+++ b/jni/ruby/ext/stringio/README
@@ -0,0 +1,18 @@
+-*- rd -*-
+$Author: nobu $
+
+=begin
+
+= StringIO
+Pseudo (({IO})) class from/to (({String})).
+
+This library is based on MoonWolf version written in Ruby. Thanks a lot.
+
+= Differences to (({IO}))
+
+* not implemented: (({fcntl})), (({reopen})).
+* (({fileno})) returns nil.
+* (({pos=})) returns new position, not 0.
+* (({ungetc})) does nothing at start of the string.
+
+=end
diff --git a/jni/ruby/ext/stringio/depend b/jni/ruby/ext/stringio/depend
new file mode 100644
index 0000000..db356dd
--- /dev/null
+++ b/jni/ruby/ext/stringio/depend
@@ -0,0 +1,4 @@
+stringio.o: stringio.c $(HDRS) $(ruby_headers) \
+ $(hdrdir)/ruby/io.h \
+ $(hdrdir)/ruby/encoding.h \
+ $(hdrdir)/ruby/oniguruma.h
diff --git a/jni/ruby/ext/stringio/extconf.h b/jni/ruby/ext/stringio/extconf.h
new file mode 100644
index 0000000..cda0cc8
--- /dev/null
+++ b/jni/ruby/ext/stringio/extconf.h
@@ -0,0 +1,3 @@
+#ifndef EXTCONF_H
+#define EXTCONF_H
+#endif
diff --git a/jni/ruby/ext/stringio/extconf.rb b/jni/ruby/ext/stringio/extconf.rb
new file mode 100644
index 0000000..8fc84b3
--- /dev/null
+++ b/jni/ruby/ext/stringio/extconf.rb
@@ -0,0 +1,2 @@
+require 'mkmf'
+create_makefile('stringio')
diff --git a/jni/ruby/ext/stringio/stringio.c b/jni/ruby/ext/stringio/stringio.c
new file mode 100644
index 0000000..e54f11a
--- /dev/null
+++ b/jni/ruby/ext/stringio/stringio.c
@@ -0,0 +1,1621 @@
+/**********************************************************************
+
+ stringio.c -
+
+ $Author: nobu $
+ $RoughId: stringio.c,v 1.13 2002/03/14 03:24:18 nobu Exp $
+ created at: Tue Feb 19 04:10:38 JST 2002
+
+ All the files in this distribution are covered under the Ruby's
+ license (see the file COPYING).
+
+**********************************************************************/
+
+#include "ruby.h"
+#include "ruby/io.h"
+#include "ruby/encoding.h"
+#if defined(HAVE_FCNTL_H) || defined(_WIN32)
+#include <fcntl.h>
+#elif defined(HAVE_SYS_FCNTL_H)
+#include <sys/fcntl.h>
+#endif
+
+struct StringIO {
+ VALUE string;
+ long pos;
+ long lineno;
+ int flags;
+ int count;
+};
+
+static void strio_init(int, VALUE *, struct StringIO *, VALUE);
+
+#define IS_STRIO(obj) (rb_typeddata_is_kind_of((obj), &strio_data_type))
+#define error_inval(msg) (errno = EINVAL, rb_sys_fail(msg))
+
+static struct StringIO *
+strio_alloc(void)
+{
+ struct StringIO *ptr = ALLOC(struct StringIO);
+ ptr->string = Qnil;
+ ptr->pos = 0;
+ ptr->lineno = 0;
+ ptr->flags = 0;
+ ptr->count = 1;
+ return ptr;
+}
+
+static void
+strio_mark(void *p)
+{
+ struct StringIO *ptr = p;
+ if (ptr) {
+ rb_gc_mark(ptr->string);
+ }
+}
+
+static void
+strio_free(void *p)
+{
+ struct StringIO *ptr = p;
+ if (--ptr->count <= 0) {
+ xfree(ptr);
+ }
+}
+
+static size_t
+strio_memsize(const void *p)
+{
+ const struct StringIO *ptr = p;
+ if (!ptr) return 0;
+ return sizeof(struct StringIO);
+}
+
+static const rb_data_type_t strio_data_type = {
+ "strio",
+ {
+ strio_mark,
+ strio_free,
+ strio_memsize,
+ },
+ 0, 0, RUBY_TYPED_FREE_IMMEDIATELY
+};
+
+#define check_strio(self) ((struct StringIO*)rb_check_typeddata((self), &strio_data_type))
+
+static struct StringIO*
+get_strio(VALUE self)
+{
+ struct StringIO *ptr = check_strio(rb_io_taint_check(self));
+
+ if (!ptr) {
+ rb_raise(rb_eIOError, "uninitialized stream");
+ }
+ return ptr;
+}
+
+static VALUE
+strio_substr(struct StringIO *ptr, long pos, long len)
+{
+ VALUE str = ptr->string;
+ rb_encoding *enc = rb_enc_get(str);
+ long rlen = RSTRING_LEN(str) - pos;
+
+ if (len > rlen) len = rlen;
+ if (len < 0) len = 0;
+ if (len == 0) return rb_str_new(0,0);
+ return rb_enc_str_new(RSTRING_PTR(str)+pos, len, enc);
+}
+
+#define StringIO(obj) get_strio(obj)
+
+#define STRIO_READABLE FL_USER4
+#define STRIO_WRITABLE FL_USER5
+#define STRIO_READWRITE (STRIO_READABLE|STRIO_WRITABLE)
+typedef char strio_flags_check[(STRIO_READABLE/FMODE_READABLE == STRIO_WRITABLE/FMODE_WRITABLE) * 2 - 1];
+#define STRIO_MODE_SET_P(strio, mode) \
+ ((RBASIC(strio)->flags & STRIO_##mode) && \
+ ((struct StringIO*)DATA_PTR(strio))->flags & FMODE_##mode)
+#define CLOSED(strio) (!STRIO_MODE_SET_P(strio, READWRITE))
+#define READABLE(strio) STRIO_MODE_SET_P(strio, READABLE)
+#define WRITABLE(strio) STRIO_MODE_SET_P(strio, WRITABLE)
+
+static VALUE sym_exception;
+
+static struct StringIO*
+readable(VALUE strio)
+{
+ struct StringIO *ptr = StringIO(strio);
+ if (!READABLE(strio)) {
+ rb_raise(rb_eIOError, "not opened for reading");
+ }
+ return ptr;
+}
+
+static struct StringIO*
+writable(VALUE strio)
+{
+ struct StringIO *ptr = StringIO(strio);
+ if (!WRITABLE(strio)) {
+ rb_raise(rb_eIOError, "not opened for writing");
+ }
+ if (!OBJ_TAINTED(ptr->string)) {
+ }
+ return ptr;
+}
+
+static void
+check_modifiable(struct StringIO *ptr)
+{
+ if (OBJ_FROZEN(ptr->string)) {
+ rb_raise(rb_eIOError, "not modifiable string");
+ }
+}
+
+static VALUE
+strio_s_allocate(VALUE klass)
+{
+ return TypedData_Wrap_Struct(klass, &strio_data_type, 0);
+}
+
+/*
+ * call-seq: StringIO.new(string=""[, mode])
+ *
+ * Creates new StringIO instance from with _string_ and _mode_.
+ */
+static VALUE
+strio_initialize(int argc, VALUE *argv, VALUE self)
+{
+ struct StringIO *ptr = check_strio(self);
+
+ if (!ptr) {
+ DATA_PTR(self) = ptr = strio_alloc();
+ }
+ rb_call_super(0, 0);
+ strio_init(argc, argv, ptr, self);
+ return self;
+}
+
+static void
+strio_init(int argc, VALUE *argv, struct StringIO *ptr, VALUE self)
+{
+ VALUE string, mode;
+ int trunc = 0;
+
+ switch (rb_scan_args(argc, argv, "02", &string, &mode)) {
+ case 2:
+ if (FIXNUM_P(mode)) {
+ int flags = FIX2INT(mode);
+ ptr->flags = rb_io_oflags_fmode(flags);
+ trunc = flags & O_TRUNC;
+ }
+ else {
+ const char *m = StringValueCStr(mode);
+ ptr->flags = rb_io_modestr_fmode(m);
+ trunc = *m == 'w';
+ }
+ StringValue(string);
+ if ((ptr->flags & FMODE_WRITABLE) && OBJ_FROZEN(string)) {
+ errno = EACCES;
+ rb_sys_fail(0);
+ }
+ if (trunc) {
+ rb_str_resize(string, 0);
+ }
+ break;
+ case 1:
+ StringValue(string);
+ ptr->flags = OBJ_FROZEN(string) ? FMODE_READABLE : FMODE_READWRITE;
+ break;
+ case 0:
+ string = rb_enc_str_new("", 0, rb_default_external_encoding());
+ ptr->flags = FMODE_READWRITE;
+ break;
+ }
+ ptr->string = string;
+ ptr->pos = 0;
+ ptr->lineno = 0;
+ RBASIC(self)->flags |= (ptr->flags & FMODE_READWRITE) * (STRIO_READABLE / FMODE_READABLE);
+}
+
+static VALUE
+strio_finalize(VALUE self)
+{
+ struct StringIO *ptr = StringIO(self);
+ ptr->string = Qnil;
+ ptr->flags &= ~FMODE_READWRITE;
+ return self;
+}
+
+/*
+ * call-seq: StringIO.open(string=""[, mode]) {|strio| ...}
+ *
+ * Equivalent to StringIO.new except that when it is called with a block, it
+ * yields with the new instance and closes it, and returns the result which
+ * returned from the block.
+ */
+static VALUE
+strio_s_open(int argc, VALUE *argv, VALUE klass)
+{
+ VALUE obj = rb_class_new_instance(argc, argv, klass);
+ if (!rb_block_given_p()) return obj;
+ return rb_ensure(rb_yield, obj, strio_finalize, obj);
+}
+
+/*
+ * Returns +false+. Just for compatibility to IO.
+ */
+static VALUE
+strio_false(VALUE self)
+{
+ StringIO(self);
+ return Qfalse;
+}
+
+/*
+ * Returns +nil+. Just for compatibility to IO.
+ */
+static VALUE
+strio_nil(VALUE self)
+{
+ StringIO(self);
+ return Qnil;
+}
+
+/*
+ * Returns *strio* itself. Just for compatibility to IO.
+ */
+static VALUE
+strio_self(VALUE self)
+{
+ StringIO(self);
+ return self;
+}
+
+/*
+ * Returns 0. Just for compatibility to IO.
+ */
+static VALUE
+strio_0(VALUE self)
+{
+ StringIO(self);
+ return INT2FIX(0);
+}
+
+/*
+ * Returns the argument unchanged. Just for compatibility to IO.
+ */
+static VALUE
+strio_first(VALUE self, VALUE arg)
+{
+ StringIO(self);
+ return arg;
+}
+
+/*
+ * Raises NotImplementedError.
+ */
+static VALUE
+strio_unimpl(int argc, VALUE *argv, VALUE self)
+{
+ StringIO(self);
+ rb_notimplement();
+
+ UNREACHABLE;
+}
+
+/*
+ * call-seq: strio.string -> string
+ *
+ * Returns underlying String object, the subject of IO.
+ */
+static VALUE
+strio_get_string(VALUE self)
+{
+ return StringIO(self)->string;
+}
+
+/*
+ * call-seq:
+ * strio.string = string -> string
+ *
+ * Changes underlying String object, the subject of IO.
+ */
+static VALUE
+strio_set_string(VALUE self, VALUE string)
+{
+ struct StringIO *ptr = StringIO(self);
+
+ rb_io_taint_check(self);
+ ptr->flags &= ~FMODE_READWRITE;
+ StringValue(string);
+ ptr->flags = OBJ_FROZEN(string) ? FMODE_READABLE : FMODE_READWRITE;
+ ptr->pos = 0;
+ ptr->lineno = 0;
+ return ptr->string = string;
+}
+
+/*
+ * call-seq:
+ * strio.close -> nil
+ *
+ * Closes strio. The *strio* is unavailable for any further data
+ * operations; an +IOError+ is raised if such an attempt is made.
+ */
+static VALUE
+strio_close(VALUE self)
+{
+ StringIO(self);
+ if (CLOSED(self)) {
+ rb_raise(rb_eIOError, "closed stream");
+ }
+ RBASIC(self)->flags &= ~STRIO_READWRITE;
+ return Qnil;
+}
+
+/*
+ * call-seq:
+ * strio.close_read -> nil
+ *
+ * Closes the read end of a StringIO. Will raise an +IOError+ if the
+ * *strio* is not readable.
+ */
+static VALUE
+strio_close_read(VALUE self)
+{
+ StringIO(self);
+ if (!READABLE(self)) {
+ rb_raise(rb_eIOError, "closing non-duplex IO for reading");
+ }
+ RBASIC(self)->flags &= ~STRIO_READABLE;
+ return Qnil;
+}
+
+/*
+ * call-seq:
+ * strio.close_write -> nil
+ *
+ * Closes the write end of a StringIO. Will raise an +IOError+ if the
+ * *strio* is not writeable.
+ */
+static VALUE
+strio_close_write(VALUE self)
+{
+ StringIO(self);
+ if (!WRITABLE(self)) {
+ rb_raise(rb_eIOError, "closing non-duplex IO for writing");
+ }
+ RBASIC(self)->flags &= ~STRIO_WRITABLE;
+ return Qnil;
+}
+
+/*
+ * call-seq:
+ * strio.closed? -> true or false
+ *
+ * Returns +true+ if *strio* is completely closed, +false+ otherwise.
+ */
+static VALUE
+strio_closed(VALUE self)
+{
+ StringIO(self);
+ if (!CLOSED(self)) return Qfalse;
+ return Qtrue;
+}
+
+/*
+ * call-seq:
+ * strio.closed_read? -> true or false
+ *
+ * Returns +true+ if *strio* is not readable, +false+ otherwise.
+ */
+static VALUE
+strio_closed_read(VALUE self)
+{
+ StringIO(self);
+ if (READABLE(self)) return Qfalse;
+ return Qtrue;
+}
+
+/*
+ * call-seq:
+ * strio.closed_write? -> true or false
+ *
+ * Returns +true+ if *strio* is not writable, +false+ otherwise.
+ */
+static VALUE
+strio_closed_write(VALUE self)
+{
+ StringIO(self);
+ if (WRITABLE(self)) return Qfalse;
+ return Qtrue;
+}
+
+/*
+ * call-seq:
+ * strio.eof -> true or false
+ * strio.eof? -> true or false
+ *
+ * Returns true if *strio* is at end of file. The stringio must be
+ * opened for reading or an +IOError+ will be raised.
+ */
+static VALUE
+strio_eof(VALUE self)
+{
+ struct StringIO *ptr = readable(self);
+ if (ptr->pos < RSTRING_LEN(ptr->string)) return Qfalse;
+ return Qtrue;
+}
+
+/* :nodoc: */
+static VALUE
+strio_copy(VALUE copy, VALUE orig)
+{
+ struct StringIO *ptr;
+
+ orig = rb_convert_type(orig, T_DATA, "StringIO", "to_strio");
+ if (copy == orig) return copy;
+ ptr = StringIO(orig);
+ if (check_strio(copy)) {
+ strio_free(DATA_PTR(copy));
+ }
+ DATA_PTR(copy) = ptr;
+ OBJ_INFECT(copy, orig);
+ RBASIC(copy)->flags &= ~STRIO_READWRITE;
+ RBASIC(copy)->flags |= RBASIC(orig)->flags & STRIO_READWRITE;
+ ++ptr->count;
+ return copy;
+}
+
+/*
+ * call-seq:
+ * strio.lineno -> integer
+ *
+ * Returns the current line number in *strio*. The stringio must be
+ * opened for reading. +lineno+ counts the number of times +gets+ is
+ * called, rather than the number of newlines encountered. The two
+ * values will differ if +gets+ is called with a separator other than
+ * newline. See also the <code>$.</code> variable.
+ */
+static VALUE
+strio_get_lineno(VALUE self)
+{
+ return LONG2NUM(StringIO(self)->lineno);
+}
+
+/*
+ * call-seq:
+ * strio.lineno = integer -> integer
+ *
+ * Manually sets the current line number to the given value.
+ * <code>$.</code> is updated only on the next read.
+ */
+static VALUE
+strio_set_lineno(VALUE self, VALUE lineno)
+{
+ StringIO(self)->lineno = NUM2LONG(lineno);
+ return lineno;
+}
+
+#define strio_binmode strio_self
+
+#define strio_fcntl strio_unimpl
+
+#define strio_flush strio_self
+
+#define strio_fsync strio_0
+
+/*
+ * call-seq:
+ * strio.reopen(other_StrIO) -> strio
+ * strio.reopen(string, mode) -> strio
+ *
+ * Reinitializes *strio* with the given <i>other_StrIO</i> or _string_
+ * and _mode_ (see StringIO#new).
+ */
+static VALUE
+strio_reopen(int argc, VALUE *argv, VALUE self)
+{
+ rb_io_taint_check(self);
+ if (argc == 1 && !RB_TYPE_P(*argv, T_STRING)) {
+ return strio_copy(self, *argv);
+ }
+ strio_init(argc, argv, StringIO(self), self);
+ return self;
+}
+
+/*
+ * call-seq:
+ * strio.pos -> integer
+ * strio.tell -> integer
+ *
+ * Returns the current offset (in bytes) of *strio*.
+ */
+static VALUE
+strio_get_pos(VALUE self)
+{
+ return LONG2NUM(StringIO(self)->pos);
+}
+
+/*
+ * call-seq:
+ * strio.pos = integer -> integer
+ *
+ * Seeks to the given position (in bytes) in *strio*.
+ */
+static VALUE
+strio_set_pos(VALUE self, VALUE pos)
+{
+ struct StringIO *ptr = StringIO(self);
+ long p = NUM2LONG(pos);
+ if (p < 0) {
+ error_inval(0);
+ }
+ ptr->pos = p;
+ return pos;
+}
+
+/*
+ * call-seq:
+ * strio.rewind -> 0
+ *
+ * Positions *strio* to the beginning of input, resetting
+ * +lineno+ to zero.
+ */
+static VALUE
+strio_rewind(VALUE self)
+{
+ struct StringIO *ptr = StringIO(self);
+ ptr->pos = 0;
+ ptr->lineno = 0;
+ return INT2FIX(0);
+}
+
+/*
+ * call-seq:
+ * strio.seek(amount, whence=SEEK_SET) -> 0
+ *
+ * Seeks to a given offset _amount_ in the stream according to
+ * the value of _whence_ (see IO#seek).
+ */
+static VALUE
+strio_seek(int argc, VALUE *argv, VALUE self)
+{
+ VALUE whence;
+ struct StringIO *ptr = StringIO(self);
+ long offset;
+
+ rb_scan_args(argc, argv, "11", NULL, &whence);
+ offset = NUM2LONG(argv[0]);
+ if (CLOSED(self)) {
+ rb_raise(rb_eIOError, "closed stream");
+ }
+ switch (NIL_P(whence) ? 0 : NUM2LONG(whence)) {
+ case 0:
+ break;
+ case 1:
+ offset += ptr->pos;
+ break;
+ case 2:
+ offset += RSTRING_LEN(ptr->string);
+ break;
+ default:
+ error_inval("invalid whence");
+ }
+ if (offset < 0) {
+ error_inval(0);
+ }
+ ptr->pos = offset;
+ return INT2FIX(0);
+}
+
+/*
+ * call-seq:
+ * strio.sync -> true
+ *
+ * Returns +true+ always.
+ */
+static VALUE
+strio_get_sync(VALUE self)
+{
+ StringIO(self);
+ return Qtrue;
+}
+
+#define strio_set_sync strio_first
+
+#define strio_tell strio_get_pos
+
+/*
+ * call-seq:
+ * strio.each_byte {|byte| block } -> strio
+ * strio.each_byte -> anEnumerator
+ *
+ * See IO#each_byte.
+ */
+static VALUE
+strio_each_byte(VALUE self)
+{
+ struct StringIO *ptr = readable(self);
+
+ RETURN_ENUMERATOR(self, 0, 0);
+
+ while (ptr->pos < RSTRING_LEN(ptr->string)) {
+ char c = RSTRING_PTR(ptr->string)[ptr->pos++];
+ rb_yield(CHR2FIX(c));
+ }
+ return self;
+}
+
+/*
+ * This is a deprecated alias for #each_byte.
+ */
+static VALUE
+strio_bytes(VALUE self)
+{
+ rb_warn("StringIO#bytes is deprecated; use #each_byte instead");
+ if (!rb_block_given_p())
+ return rb_enumeratorize(self, ID2SYM(rb_intern("each_byte")), 0, 0);
+ return strio_each_byte(self);
+}
+
+/*
+ * call-seq:
+ * strio.getc -> string or nil
+ *
+ * See IO#getc.
+ */
+static VALUE
+strio_getc(VALUE self)
+{
+ struct StringIO *ptr = readable(self);
+ rb_encoding *enc = rb_enc_get(ptr->string);
+ int len;
+ char *p;
+
+ if (ptr->pos >= RSTRING_LEN(ptr->string)) {
+ return Qnil;
+ }
+ p = RSTRING_PTR(ptr->string)+ptr->pos;
+ len = rb_enc_mbclen(p, RSTRING_END(ptr->string), enc);
+ ptr->pos += len;
+ return rb_enc_str_new(p, len, rb_enc_get(ptr->string));
+}
+
+/*
+ * call-seq:
+ * strio.getbyte -> fixnum or nil
+ *
+ * See IO#getbyte.
+ */
+static VALUE
+strio_getbyte(VALUE self)
+{
+ struct StringIO *ptr = readable(self);
+ int c;
+ if (ptr->pos >= RSTRING_LEN(ptr->string)) {
+ return Qnil;
+ }
+ c = RSTRING_PTR(ptr->string)[ptr->pos++];
+ return CHR2FIX(c);
+}
+
+static void
+strio_extend(struct StringIO *ptr, long pos, long len)
+{
+ long olen;
+
+ check_modifiable(ptr);
+ olen = RSTRING_LEN(ptr->string);
+ if (pos + len > olen) {
+ rb_str_resize(ptr->string, pos + len);
+ if (pos > olen)
+ MEMZERO(RSTRING_PTR(ptr->string) + olen, char, pos - olen);
+ }
+ else {
+ rb_str_modify(ptr->string);
+ }
+}
+
+/*
+ * call-seq:
+ * strio.ungetc(string) -> nil
+ *
+ * Pushes back one character (passed as a parameter) onto *strio*
+ * such that a subsequent buffered read will return it. There is no
+ * limitation for multiple pushbacks including pushing back behind the
+ * beginning of the buffer string.
+ */
+static VALUE
+strio_ungetc(VALUE self, VALUE c)
+{
+ struct StringIO *ptr = readable(self);
+ long lpos, clen;
+ char *p, *pend;
+ rb_encoding *enc, *enc2;
+
+ if (NIL_P(c)) return Qnil;
+ check_modifiable(ptr);
+ if (FIXNUM_P(c)) {
+ int cc = FIX2INT(c);
+ char buf[16];
+
+ enc = rb_enc_get(ptr->string);
+ rb_enc_mbcput(cc, buf, enc);
+ c = rb_enc_str_new(buf, rb_enc_codelen(cc, enc), enc);
+ }
+ else {
+ SafeStringValue(c);
+ enc = rb_enc_get(ptr->string);
+ enc2 = rb_enc_get(c);
+ if (enc != enc2 && enc != rb_ascii8bit_encoding()) {
+ c = rb_str_conv_enc(c, enc2, enc);
+ }
+ }
+ if (RSTRING_LEN(ptr->string) < ptr->pos) {
+ long len = RSTRING_LEN(ptr->string);
+ rb_str_resize(ptr->string, ptr->pos - 1);
+ memset(RSTRING_PTR(ptr->string) + len, 0, ptr->pos - len - 1);
+ rb_str_concat(ptr->string, c);
+ ptr->pos--;
+ }
+ else {
+ /* get logical position */
+ lpos = 0; p = RSTRING_PTR(ptr->string); pend = p + ptr->pos;
+ for (;;) {
+ clen = rb_enc_mbclen(p, pend, enc);
+ if (p+clen >= pend) break;
+ p += clen;
+ lpos++;
+ }
+ clen = p - RSTRING_PTR(ptr->string);
+ rb_str_update(ptr->string, lpos, ptr->pos ? 1 : 0, c);
+ ptr->pos = clen;
+ }
+
+ return Qnil;
+}
+
+/*
+ * call-seq:
+ * strio.ungetbyte(fixnum) -> nil
+ *
+ * See IO#ungetbyte
+ */
+static VALUE
+strio_ungetbyte(VALUE self, VALUE c)
+{
+ struct StringIO *ptr = readable(self);
+ char buf[1], *cp = buf;
+ long pos = ptr->pos, cl = 1;
+ VALUE str = ptr->string;
+
+ if (NIL_P(c)) return Qnil;
+ if (FIXNUM_P(c)) {
+ buf[0] = (char)FIX2INT(c);
+ }
+ else {
+ SafeStringValue(c);
+ cp = RSTRING_PTR(c);
+ cl = RSTRING_LEN(c);
+ if (cl == 0) return Qnil;
+ }
+ check_modifiable(ptr);
+ rb_str_modify(str);
+ if (cl > pos) {
+ char *s;
+ long rest = RSTRING_LEN(str) - pos;
+ rb_str_resize(str, rest + cl);
+ s = RSTRING_PTR(str);
+ memmove(s + cl, s + pos, rest);
+ pos = 0;
+ }
+ else {
+ pos -= cl;
+ }
+ memcpy(RSTRING_PTR(str) + pos, cp, cl);
+ ptr->pos = pos;
+ RB_GC_GUARD(c);
+ return Qnil;
+}
+
+/*
+ * call-seq:
+ * strio.readchar -> string
+ *
+ * See IO#readchar.
+ */
+static VALUE
+strio_readchar(VALUE self)
+{
+ VALUE c = rb_funcall2(self, rb_intern("getc"), 0, 0);
+ if (NIL_P(c)) rb_eof_error();
+ return c;
+}
+
+/*
+ * call-seq:
+ * strio.readbyte -> fixnum
+ *
+ * See IO#readbyte.
+ */
+static VALUE
+strio_readbyte(VALUE self)
+{
+ VALUE c = rb_funcall2(self, rb_intern("getbyte"), 0, 0);
+ if (NIL_P(c)) rb_eof_error();
+ return c;
+}
+
+/*
+ * call-seq:
+ * strio.each_char {|char| block } -> strio
+ * strio.each_char -> anEnumerator
+ *
+ * See IO#each_char.
+ */
+static VALUE
+strio_each_char(VALUE self)
+{
+ VALUE c;
+
+ RETURN_ENUMERATOR(self, 0, 0);
+
+ while (!NIL_P(c = strio_getc(self))) {
+ rb_yield(c);
+ }
+ return self;
+}
+
+/*
+ * This is a deprecated alias for <code>each_char</code>.
+ */
+static VALUE
+strio_chars(VALUE self)
+{
+ rb_warn("StringIO#chars is deprecated; use #each_char instead");
+ if (!rb_block_given_p())
+ return rb_enumeratorize(self, ID2SYM(rb_intern("each_char")), 0, 0);
+ return strio_each_char(self);
+}
+
+/*
+ * call-seq:
+ * strio.each_codepoint {|c| block } -> strio
+ * strio.each_codepoint -> anEnumerator
+ *
+ * See IO#each_codepoint.
+ */
+static VALUE
+strio_each_codepoint(VALUE self)
+{
+ struct StringIO *ptr;
+ rb_encoding *enc;
+ unsigned int c;
+ int n;
+
+ RETURN_ENUMERATOR(self, 0, 0);
+
+ ptr = readable(self);
+ enc = rb_enc_get(ptr->string);
+ for (;;) {
+ if (ptr->pos >= RSTRING_LEN(ptr->string)) {
+ return self;
+ }
+
+ c = rb_enc_codepoint_len(RSTRING_PTR(ptr->string)+ptr->pos,
+ RSTRING_END(ptr->string), &n, enc);
+ rb_yield(UINT2NUM(c));
+ ptr->pos += n;
+ }
+ return self;
+}
+
+/*
+ * This is a deprecated alias for <code>each_codepoint</code>.
+ */
+static VALUE
+strio_codepoints(VALUE self)
+{
+ rb_warn("StringIO#codepoints is deprecated; use #each_codepoint instead");
+ if (!rb_block_given_p())
+ return rb_enumeratorize(self, ID2SYM(rb_intern("each_codepoint")), 0, 0);
+ return strio_each_codepoint(self);
+}
+
+/* Boyer-Moore search: copied from regex.c */
+static void
+bm_init_skip(long *skip, const char *pat, long m)
+{
+ int c;
+
+ for (c = 0; c < (1 << CHAR_BIT); c++) {
+ skip[c] = m;
+ }
+ while (--m) {
+ skip[(unsigned char)*pat++] = m;
+ }
+}
+
+static long
+bm_search(const char *little, long llen, const char *big, long blen, const long *skip)
+{
+ long i, j, k;
+
+ i = llen - 1;
+ while (i < blen) {
+ k = i;
+ j = llen - 1;
+ while (j >= 0 && big[k] == little[j]) {
+ k--;
+ j--;
+ }
+ if (j < 0) return k + 1;
+ i += skip[(unsigned char)big[i]];
+ }
+ return -1;
+}
+
+static VALUE
+strio_getline(int argc, VALUE *argv, struct StringIO *ptr)
+{
+ const char *s, *e, *p;
+ long n, limit = 0;
+ VALUE str, lim;
+
+ rb_scan_args(argc, argv, "02", &str, &lim);
+ switch (argc) {
+ case 0:
+ str = rb_rs;
+ break;
+
+ case 1:
+ if (!NIL_P(str) && !RB_TYPE_P(str, T_STRING)) {
+ VALUE tmp = rb_check_string_type(str);
+ if (NIL_P(tmp)) {
+ limit = NUM2LONG(str);
+ if (limit == 0) return rb_str_new(0,0);
+ str = rb_rs;
+ }
+ else {
+ str = tmp;
+ }
+ }
+ break;
+
+ case 2:
+ if (!NIL_P(str)) StringValue(str);
+ if (!NIL_P(lim)) limit = NUM2LONG(lim);
+ break;
+ }
+
+ if (ptr->pos >= (n = RSTRING_LEN(ptr->string))) {
+ return Qnil;
+ }
+ s = RSTRING_PTR(ptr->string);
+ e = s + RSTRING_LEN(ptr->string);
+ s += ptr->pos;
+ if (limit > 0 && s + limit < e) {
+ e = rb_enc_right_char_head(s, s + limit, e, rb_enc_get(ptr->string));
+ }
+ if (NIL_P(str)) {
+ str = strio_substr(ptr, ptr->pos, e - s);
+ }
+ else if ((n = RSTRING_LEN(str)) == 0) {
+ p = s;
+ while (*p == '\n') {
+ if (++p == e) {
+ return Qnil;
+ }
+ }
+ s = p;
+ while ((p = memchr(p, '\n', e - p)) && (p != e)) {
+ if (*++p == '\n') {
+ e = p + 1;
+ break;
+ }
+ }
+ str = strio_substr(ptr, s - RSTRING_PTR(ptr->string), e - s);
+ }
+ else if (n == 1) {
+ if ((p = memchr(s, RSTRING_PTR(str)[0], e - s)) != 0) {
+ e = p + 1;
+ }
+ str = strio_substr(ptr, ptr->pos, e - s);
+ }
+ else {
+ if (n < e - s) {
+ if (e - s < 1024) {
+ for (p = s; p + n <= e; ++p) {
+ if (MEMCMP(p, RSTRING_PTR(str), char, n) == 0) {
+ e = p + n;
+ break;
+ }
+ }
+ }
+ else {
+ long skip[1 << CHAR_BIT], pos;
+ p = RSTRING_PTR(str);
+ bm_init_skip(skip, p, n);
+ if ((pos = bm_search(p, n, s, e - s, skip)) >= 0) {
+ e = s + pos + n;
+ }
+ }
+ }
+ str = strio_substr(ptr, ptr->pos, e - s);
+ }
+ ptr->pos = e - RSTRING_PTR(ptr->string);
+ ptr->lineno++;
+ return str;
+}
+
+/*
+ * call-seq:
+ * strio.gets(sep=$/) -> string or nil
+ * strio.gets(limit) -> string or nil
+ * strio.gets(sep, limit) -> string or nil
+ *
+ * See IO#gets.
+ */
+static VALUE
+strio_gets(int argc, VALUE *argv, VALUE self)
+{
+ VALUE str = strio_getline(argc, argv, readable(self));
+
+ rb_lastline_set(str);
+ return str;
+}
+
+/*
+ * call-seq:
+ * strio.readline(sep=$/) -> string
+ * strio.readline(limit) -> string or nil
+ * strio.readline(sep, limit) -> string or nil
+ *
+ * See IO#readline.
+ */
+static VALUE
+strio_readline(int argc, VALUE *argv, VALUE self)
+{
+ VALUE line = rb_funcall2(self, rb_intern("gets"), argc, argv);
+ if (NIL_P(line)) rb_eof_error();
+ return line;
+}
+
+/*
+ * call-seq:
+ * strio.each(sep=$/) {|line| block } -> strio
+ * strio.each(limit) {|line| block } -> strio
+ * strio.each(sep, limit) {|line| block } -> strio
+ * strio.each(...) -> anEnumerator
+ *
+ * strio.each_line(sep=$/) {|line| block } -> strio
+ * strio.each_line(limit) {|line| block } -> strio
+ * strio.each_line(sep,limit) {|line| block } -> strio
+ * strio.each_line(...) -> anEnumerator
+ *
+ * See IO#each.
+ */
+static VALUE
+strio_each(int argc, VALUE *argv, VALUE self)
+{
+ VALUE line;
+
+ StringIO(self);
+ RETURN_ENUMERATOR(self, argc, argv);
+
+ if (argc > 0 && !NIL_P(argv[argc-1]) && NIL_P(rb_check_string_type(argv[argc-1])) &&
+ NUM2LONG(argv[argc-1]) == 0) {
+ rb_raise(rb_eArgError, "invalid limit: 0 for each_line");
+ }
+
+ while (!NIL_P(line = strio_getline(argc, argv, readable(self)))) {
+ rb_yield(line);
+ }
+ return self;
+}
+
+/*
+ * This is a deprecated alias for <code>each_line</code>.
+ */
+static VALUE
+strio_lines(int argc, VALUE *argv, VALUE self)
+{
+ rb_warn("StringIO#lines is deprecated; use #each_line instead");
+ if (!rb_block_given_p())
+ return rb_enumeratorize(self, ID2SYM(rb_intern("each_line")), argc, argv);
+ return strio_each(argc, argv, self);
+}
+
+/*
+ * call-seq:
+ * strio.readlines(sep=$/) -> array
+ * strio.readlines(limit) -> array
+ * strio.readlines(sep,limit) -> array
+ *
+ * See IO#readlines.
+ */
+static VALUE
+strio_readlines(int argc, VALUE *argv, VALUE self)
+{
+ VALUE ary, line;
+
+ StringIO(self);
+ ary = rb_ary_new();
+ if (argc > 0 && !NIL_P(argv[argc-1]) && NIL_P(rb_check_string_type(argv[argc-1])) &&
+ NUM2LONG(argv[argc-1]) == 0) {
+ rb_raise(rb_eArgError, "invalid limit: 0 for readlines");
+ }
+
+ while (!NIL_P(line = strio_getline(argc, argv, readable(self)))) {
+ rb_ary_push(ary, line);
+ }
+ return ary;
+}
+
+/*
+ * call-seq:
+ * strio.write(string) -> integer
+ * strio.syswrite(string) -> integer
+ *
+ * Appends the given string to the underlying buffer string of *strio*.
+ * The stream must be opened for writing. If the argument is not a
+ * string, it will be converted to a string using <code>to_s</code>.
+ * Returns the number of bytes written. See IO#write.
+ */
+static VALUE
+strio_write(VALUE self, VALUE str)
+{
+ struct StringIO *ptr = writable(self);
+ long len, olen;
+ rb_encoding *enc, *enc2;
+ rb_encoding *const ascii8bit = rb_ascii8bit_encoding();
+
+ if (!RB_TYPE_P(str, T_STRING))
+ str = rb_obj_as_string(str);
+ enc = rb_enc_get(ptr->string);
+ enc2 = rb_enc_get(str);
+ if (enc != enc2 && enc != ascii8bit) {
+ str = rb_str_conv_enc(str, enc2, enc);
+ }
+ len = RSTRING_LEN(str);
+ if (len == 0) return INT2FIX(0);
+ check_modifiable(ptr);
+ olen = RSTRING_LEN(ptr->string);
+ if (ptr->flags & FMODE_APPEND) {
+ ptr->pos = olen;
+ }
+ if (ptr->pos == olen) {
+ if (enc == ascii8bit || enc2 == ascii8bit) {
+ rb_enc_str_buf_cat(ptr->string, RSTRING_PTR(str), len, enc);
+ OBJ_INFECT(ptr->string, str);
+ }
+ else {
+ rb_str_buf_append(ptr->string, str);
+ }
+ }
+ else {
+ strio_extend(ptr, ptr->pos, len);
+ memmove(RSTRING_PTR(ptr->string)+ptr->pos, RSTRING_PTR(str), len);
+ OBJ_INFECT(ptr->string, str);
+ }
+ OBJ_INFECT(ptr->string, self);
+ RB_GC_GUARD(str);
+ ptr->pos += len;
+ return LONG2NUM(len);
+}
+
+/*
+ * call-seq:
+ * strio << obj -> strio
+ *
+ * See IO#<<.
+ */
+#define strio_addstr rb_io_addstr
+
+/*
+ * call-seq:
+ * strio.print() -> nil
+ * strio.print(obj, ...) -> nil
+ *
+ * See IO#print.
+ */
+#define strio_print rb_io_print
+
+/*
+ * call-seq:
+ * strio.printf(format_string [, obj, ...] ) -> nil
+ *
+ * See IO#printf.
+ */
+#define strio_printf rb_io_printf
+
+/*
+ * call-seq:
+ * strio.putc(obj) -> obj
+ *
+ * See IO#putc.
+ */
+static VALUE
+strio_putc(VALUE self, VALUE ch)
+{
+ struct StringIO *ptr = writable(self);
+ VALUE str;
+
+ check_modifiable(ptr);
+ if (RB_TYPE_P(ch, T_STRING)) {
+ str = rb_str_substr(ch, 0, 1);
+ }
+ else {
+ char c = NUM2CHR(ch);
+ str = rb_str_new(&c, 1);
+ }
+ strio_write(self, str);
+ return ch;
+}
+
+/*
+ * call-seq:
+ * strio.puts(obj, ...) -> nil
+ *
+ * See IO#puts.
+ */
+#define strio_puts rb_io_puts
+
+/*
+ * call-seq:
+ * strio.read([length [, outbuf]]) -> string, outbuf, or nil
+ *
+ * See IO#read.
+ */
+static VALUE
+strio_read(int argc, VALUE *argv, VALUE self)
+{
+ struct StringIO *ptr = readable(self);
+ VALUE str = Qnil;
+ long len;
+ int binary = 0;
+
+ switch (argc) {
+ case 2:
+ str = argv[1];
+ if (!NIL_P(str)) {
+ StringValue(str);
+ rb_str_modify(str);
+ }
+ case 1:
+ if (!NIL_P(argv[0])) {
+ len = NUM2LONG(argv[0]);
+ if (len < 0) {
+ rb_raise(rb_eArgError, "negative length %ld given", len);
+ }
+ if (len > 0 && ptr->pos >= RSTRING_LEN(ptr->string)) {
+ if (!NIL_P(str)) rb_str_resize(str, 0);
+ return Qnil;
+ }
+ binary = 1;
+ break;
+ }
+ /* fall through */
+ case 0:
+ len = RSTRING_LEN(ptr->string);
+ if (len <= ptr->pos) {
+ if (NIL_P(str)) {
+ str = rb_str_new(0, 0);
+ }
+ else {
+ rb_str_resize(str, 0);
+ }
+ return str;
+ }
+ else {
+ len -= ptr->pos;
+ }
+ break;
+ default:
+ rb_raise(rb_eArgError, "wrong number of arguments (%d for 0)", argc);
+ }
+ if (NIL_P(str)) {
+ str = strio_substr(ptr, ptr->pos, len);
+ if (binary) rb_enc_associate(str, rb_ascii8bit_encoding());
+ }
+ else {
+ long rest = RSTRING_LEN(ptr->string) - ptr->pos;
+ if (len > rest) len = rest;
+ rb_str_resize(str, len);
+ MEMCPY(RSTRING_PTR(str), RSTRING_PTR(ptr->string) + ptr->pos, char, len);
+ if (binary)
+ rb_enc_associate(str, rb_ascii8bit_encoding());
+ else
+ rb_enc_copy(str, ptr->string);
+ }
+ ptr->pos += RSTRING_LEN(str);
+ return str;
+}
+
+/*
+ * call-seq:
+ * strio.sysread(integer[, outbuf]) -> string
+ * strio.readpartial(integer[, outbuf]) -> string
+ *
+ * Similar to #read, but raises +EOFError+ at end of string instead of
+ * returning +nil+, as well as IO#sysread does.
+ */
+static VALUE
+strio_sysread(int argc, VALUE *argv, VALUE self)
+{
+ VALUE val = rb_funcall2(self, rb_intern("read"), argc, argv);
+ if (NIL_P(val)) {
+ rb_eof_error();
+ }
+ return val;
+}
+
+/*
+ * call-seq:
+ * strio.read_nonblock(integer[, outbuf [, opts]]) -> string
+ *
+ * Similar to #read, but raises +EOFError+ at end of string unless the
+ * +exception: false+ option is passed in.
+ */
+static VALUE
+strio_read_nonblock(int argc, VALUE *argv, VALUE self)
+{
+ VALUE opts = Qnil, val;
+ int no_exception = 0;
+
+ rb_scan_args(argc, argv, "11:", NULL, NULL, &opts);
+
+ if (!NIL_P(opts)) {
+ argc--;
+
+ if (Qfalse == rb_hash_aref(opts, sym_exception))
+ no_exception = 1;
+ }
+
+ val = strio_read(argc, argv, self);
+ if (NIL_P(val)) {
+ if (no_exception)
+ return Qnil;
+ else
+ rb_eof_error();
+ }
+
+ return val;
+}
+
+#define strio_syswrite rb_io_write
+
+static VALUE
+strio_syswrite_nonblock(int argc, VALUE *argv, VALUE self)
+{
+ VALUE str;
+
+ rb_scan_args(argc, argv, "10:", &str, NULL);
+ return strio_syswrite(self, str);
+}
+
+#define strio_isatty strio_false
+
+#define strio_pid strio_nil
+
+#define strio_fileno strio_nil
+
+/*
+ * call-seq:
+ * strio.length -> integer
+ * strio.size -> integer
+ *
+ * Returns the size of the buffer string.
+ */
+static VALUE
+strio_size(VALUE self)
+{
+ VALUE string = StringIO(self)->string;
+ if (NIL_P(string)) {
+ rb_raise(rb_eIOError, "not opened");
+ }
+ return ULONG2NUM(RSTRING_LEN(string));
+}
+
+/*
+ * call-seq:
+ * strio.truncate(integer) -> 0
+ *
+ * Truncates the buffer string to at most _integer_ bytes. The *strio*
+ * must be opened for writing.
+ */
+static VALUE
+strio_truncate(VALUE self, VALUE len)
+{
+ VALUE string = writable(self)->string;
+ long l = NUM2LONG(len);
+ long plen = RSTRING_LEN(string);
+ if (l < 0) {
+ error_inval("negative length");
+ }
+ rb_str_resize(string, l);
+ if (plen < l) {
+ MEMZERO(RSTRING_PTR(string) + plen, char, l - plen);
+ }
+ return len;
+}
+
+/*
+ * call-seq:
+ * strio.external_encoding => encoding
+ *
+ * Returns the Encoding object that represents the encoding of the file.
+ * If strio is write mode and no encoding is specified, returns <code>nil</code>.
+ */
+
+static VALUE
+strio_external_encoding(VALUE self)
+{
+ return rb_enc_from_encoding(rb_enc_get(StringIO(self)->string));
+}
+
+/*
+ * call-seq:
+ * strio.internal_encoding => encoding
+ *
+ * Returns the Encoding of the internal string if conversion is
+ * specified. Otherwise returns nil.
+ */
+
+static VALUE
+strio_internal_encoding(VALUE self)
+{
+ return Qnil;
+}
+
+/*
+ * call-seq:
+ * strio.set_encoding(ext_enc, [int_enc[, opt]]) => strio
+ *
+ * Specify the encoding of the StringIO as <i>ext_enc</i>.
+ * Use the default external encoding if <i>ext_enc</i> is nil.
+ * 2nd argument <i>int_enc</i> and optional hash <i>opt</i> argument
+ * are ignored; they are for API compatibility to IO.
+ */
+
+static VALUE
+strio_set_encoding(int argc, VALUE *argv, VALUE self)
+{
+ rb_encoding* enc;
+ VALUE str = StringIO(self)->string;
+ VALUE ext_enc, int_enc, opt;
+
+ argc = rb_scan_args(argc, argv, "11:", &ext_enc, &int_enc, &opt);
+
+ if (NIL_P(ext_enc)) {
+ enc = rb_default_external_encoding();
+ }
+ else {
+ enc = rb_to_encoding(ext_enc);
+ }
+ rb_enc_associate(str, enc);
+ return self;
+}
+
+/*
+ * Pseudo I/O on String object.
+ *
+ * Commonly used to simulate `$stdio` or `$stderr`
+ *
+ * === Examples
+ *
+ * require 'stringio'
+ *
+ * io = StringIO.new
+ * io.puts "Hello World"
+ * io.string #=> "Hello World"
+ */
+void
+Init_stringio(void)
+{
+ VALUE StringIO = rb_define_class("StringIO", rb_cData);
+
+ rb_include_module(StringIO, rb_mEnumerable);
+ rb_define_alloc_func(StringIO, strio_s_allocate);
+ rb_define_singleton_method(StringIO, "open", strio_s_open, -1);
+ rb_define_method(StringIO, "initialize", strio_initialize, -1);
+ rb_define_method(StringIO, "initialize_copy", strio_copy, 1);
+ rb_define_method(StringIO, "reopen", strio_reopen, -1);
+
+ rb_define_method(StringIO, "string", strio_get_string, 0);
+ rb_define_method(StringIO, "string=", strio_set_string, 1);
+ rb_define_method(StringIO, "lineno", strio_get_lineno, 0);
+ rb_define_method(StringIO, "lineno=", strio_set_lineno, 1);
+
+
+ /* call-seq: strio.binmode -> true */
+ rb_define_method(StringIO, "binmode", strio_binmode, 0);
+ rb_define_method(StringIO, "close", strio_close, 0);
+ rb_define_method(StringIO, "close_read", strio_close_read, 0);
+ rb_define_method(StringIO, "close_write", strio_close_write, 0);
+ rb_define_method(StringIO, "closed?", strio_closed, 0);
+ rb_define_method(StringIO, "closed_read?", strio_closed_read, 0);
+ rb_define_method(StringIO, "closed_write?", strio_closed_write, 0);
+ rb_define_method(StringIO, "eof", strio_eof, 0);
+ rb_define_method(StringIO, "eof?", strio_eof, 0);
+ /* call-seq: strio.fcntl */
+ rb_define_method(StringIO, "fcntl", strio_fcntl, -1);
+ /* call-seq: strio.flush -> strio */
+ rb_define_method(StringIO, "flush", strio_flush, 0);
+ /* call-seq: strio.fsync -> 0 */
+ rb_define_method(StringIO, "fsync", strio_fsync, 0);
+ rb_define_method(StringIO, "pos", strio_get_pos, 0);
+ rb_define_method(StringIO, "pos=", strio_set_pos, 1);
+ rb_define_method(StringIO, "rewind", strio_rewind, 0);
+ rb_define_method(StringIO, "seek", strio_seek, -1);
+ rb_define_method(StringIO, "sync", strio_get_sync, 0);
+ /* call-seq: strio.sync = boolean -> boolean */
+ rb_define_method(StringIO, "sync=", strio_set_sync, 1);
+ rb_define_method(StringIO, "tell", strio_tell, 0);
+
+ rb_define_method(StringIO, "each", strio_each, -1);
+ rb_define_method(StringIO, "each_line", strio_each, -1);
+ rb_define_method(StringIO, "lines", strio_lines, -1);
+ rb_define_method(StringIO, "each_byte", strio_each_byte, 0);
+ rb_define_method(StringIO, "bytes", strio_bytes, 0);
+ rb_define_method(StringIO, "each_char", strio_each_char, 0);
+ rb_define_method(StringIO, "chars", strio_chars, 0);
+ rb_define_method(StringIO, "each_codepoint", strio_each_codepoint, 0);
+ rb_define_method(StringIO, "codepoints", strio_codepoints, 0);
+ rb_define_method(StringIO, "getc", strio_getc, 0);
+ rb_define_method(StringIO, "ungetc", strio_ungetc, 1);
+ rb_define_method(StringIO, "ungetbyte", strio_ungetbyte, 1);
+ rb_define_method(StringIO, "getbyte", strio_getbyte, 0);
+ rb_define_method(StringIO, "gets", strio_gets, -1);
+ rb_define_method(StringIO, "readlines", strio_readlines, -1);
+ rb_define_method(StringIO, "read", strio_read, -1);
+
+ rb_define_method(StringIO, "write", strio_write, 1);
+ rb_define_method(StringIO, "putc", strio_putc, 1);
+
+ /*
+ * call-seq:
+ * strio.isatty -> nil
+ * strio.tty? -> nil
+ *
+ */
+ rb_define_method(StringIO, "isatty", strio_isatty, 0);
+ rb_define_method(StringIO, "tty?", strio_isatty, 0);
+
+ /* call-seq: strio.pid -> nil */
+ rb_define_method(StringIO, "pid", strio_pid, 0);
+
+ /* call-seq: strio.fileno -> nil */
+ rb_define_method(StringIO, "fileno", strio_fileno, 0);
+ rb_define_method(StringIO, "size", strio_size, 0);
+ rb_define_method(StringIO, "length", strio_size, 0);
+ rb_define_method(StringIO, "truncate", strio_truncate, 1);
+
+ rb_define_method(StringIO, "external_encoding", strio_external_encoding, 0);
+ rb_define_method(StringIO, "internal_encoding", strio_internal_encoding, 0);
+ rb_define_method(StringIO, "set_encoding", strio_set_encoding, -1);
+
+ {
+ VALUE mReadable = rb_define_module_under(rb_cIO, "generic_readable");
+ rb_define_method(mReadable, "readchar", strio_readchar, 0);
+ rb_define_method(mReadable, "readbyte", strio_readbyte, 0);
+ rb_define_method(mReadable, "readline", strio_readline, -1);
+ rb_define_method(mReadable, "sysread", strio_sysread, -1);
+ rb_define_method(mReadable, "readpartial", strio_sysread, -1);
+ rb_define_method(mReadable, "read_nonblock", strio_read_nonblock, -1);
+ rb_include_module(StringIO, mReadable);
+ }
+ {
+ VALUE mWritable = rb_define_module_under(rb_cIO, "generic_writable");
+ rb_define_method(mWritable, "<<", strio_addstr, 1);
+ rb_define_method(mWritable, "print", strio_print, -1);
+ rb_define_method(mWritable, "printf", strio_printf, -1);
+ rb_define_method(mWritable, "puts", strio_puts, -1);
+ rb_define_method(mWritable, "syswrite", strio_syswrite, 1);
+ rb_define_method(mWritable, "write_nonblock", strio_syswrite_nonblock, -1);
+ rb_include_module(StringIO, mWritable);
+ }
+
+ sym_exception = ID2SYM(rb_intern("exception"));
+}
diff --git a/jni/ruby/ext/strscan/Makefile b/jni/ruby/ext/strscan/Makefile
new file mode 100644
index 0000000..6f45703
--- /dev/null
+++ b/jni/ruby/ext/strscan/Makefile
@@ -0,0 +1,286 @@
+
+SHELL = /bin/sh
+
+# V=0 quiet, V=1 verbose. other values don't work.
+V = 0
+Q1 = $(V:1=)
+Q = $(Q1:0=@)
+ECHO1 = $(V:1=@:)
+ECHO = $(ECHO1:0=@echo)
+NULLCMD = :
+
+#### Start of system configuration section. ####
+top_srcdir = $(topdir)/.
+srcdir = $(top_srcdir)/ext/strscan
+topdir = ../..
+hdrdir = $(top_srcdir)/include
+arch_hdrdir = $(extout)/include/$(arch)
+PATH_SEPARATOR = :
+VPATH = $(srcdir):$(arch_hdrdir)/ruby:$(hdrdir)/ruby
+RUBYLIB =
+RUBYOPT = -
+prefix = $(DESTDIR)/usr/local
+rubysitearchprefix = $(rubylibprefix)/$(sitearch)
+rubyarchprefix = $(rubylibprefix)/$(arch)
+rubylibprefix = $(libdir)/$(RUBY_BASE_NAME)
+exec_prefix = $(prefix)
+vendorarchhdrdir = $(vendorhdrdir)/$(sitearch)
+sitearchhdrdir = $(sitehdrdir)/$(sitearch)
+rubyarchhdrdir = $(rubyhdrdir)/$(arch)
+vendorhdrdir = $(rubyhdrdir)/vendor_ruby
+sitehdrdir = $(rubyhdrdir)/site_ruby
+rubyhdrdir = $(includedir)/$(RUBY_VERSION_NAME)
+vendorarchdir = $(vendorlibdir)/$(sitearch)
+vendorlibdir = $(vendordir)/$(ruby_version)
+vendordir = $(rubylibprefix)/vendor_ruby
+sitearchdir = $(sitelibdir)/$(sitearch)
+sitelibdir = $(sitedir)/$(ruby_version)
+sitedir = $(rubylibprefix)/site_ruby
+rubyarchdir = $(rubylibdir)/$(arch)
+rubylibdir = $(rubylibprefix)/$(ruby_version)
+sitearchincludedir = $(includedir)/$(sitearch)
+archincludedir = $(includedir)/$(arch)
+sitearchlibdir = $(libdir)/$(sitearch)
+archlibdir = $(libdir)/$(arch)
+ridir = $(datarootdir)/$(RI_BASE_NAME)
+mandir = $(datarootdir)/man
+localedir = $(datarootdir)/locale
+libdir = $(exec_prefix)/lib
+psdir = $(docdir)
+pdfdir = $(docdir)
+dvidir = $(docdir)
+htmldir = $(docdir)
+infodir = $(datarootdir)/info
+docdir = $(datarootdir)/doc/$(PACKAGE)
+oldincludedir = $(DESTDIR)/usr/include
+includedir = $(prefix)/include
+localstatedir = $(prefix)/var
+sharedstatedir = $(prefix)/com
+sysconfdir = $(prefix)/etc
+datadir = $(datarootdir)
+datarootdir = $(prefix)/share
+libexecdir = $(exec_prefix)/libexec
+sbindir = $(exec_prefix)/sbin
+bindir = $(exec_prefix)/bin
+archdir = $(rubyarchdir)
+
+
+CC = gcc
+CXX = g++
+LIBRUBY = $(LIBRUBY_SO)
+LIBRUBY_A = lib$(RUBY_SO_NAME)-static.a
+LIBRUBYARG_SHARED = -Wl,-R$(libdir) -L$(libdir) -l$(RUBY_SO_NAME)
+LIBRUBYARG_STATIC = -Wl,-R$(libdir) -L$(libdir) -l$(RUBY_SO_NAME)-static
+empty =
+OUTFLAG = -o $(empty)
+COUTFLAG = -o $(empty)
+
+RUBY_EXTCONF_H = extconf.h
+cflags = $(optflags) $(debugflags) $(warnflags)
+optflags = -O3 -fno-fast-math
+debugflags = -ggdb3
+warnflags = -Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wunused-variable -Wpointer-arith -Wwrite-strings -Wdeclaration-after-statement -Wimplicit-function-declaration -Wdeprecated-declarations -Wno-packed-bitfield-compat
+CCDLFLAGS = -fPIC
+CFLAGS = $(CCDLFLAGS) $(cflags) -fPIC $(ARCH_FLAG)
+INCFLAGS = -I. -I$(arch_hdrdir) -I$(hdrdir) -I$(srcdir) -I$(top_srcdir)
+DEFS =
+CPPFLAGS = -DRUBY_EXTCONF_H=\"$(RUBY_EXTCONF_H)\" $(DEFS) $(cppflags)
+CXXFLAGS = $(CCDLFLAGS) $(cxxflags) $(ARCH_FLAG)
+ldflags = -L. -fstack-protector -rdynamic -Wl,-export-dynamic
+dldflags =
+ARCH_FLAG =
+DLDFLAGS = $(ldflags) $(dldflags) $(ARCH_FLAG)
+LDSHARED = $(CC) -shared
+LDSHAREDXX = $(CXX) -shared
+AR = ar
+EXEEXT =
+
+RUBY_INSTALL_NAME = $(RUBY_BASE_NAME)
+RUBY_SO_NAME = ruby
+RUBYW_INSTALL_NAME =
+RUBY_VERSION_NAME = $(RUBY_BASE_NAME)-$(ruby_version)
+RUBYW_BASE_NAME = rubyw
+RUBY_BASE_NAME = ruby
+
+arch = x86_64-linux
+sitearch = $(arch)
+ruby_version = 2.2.0
+ruby = $(topdir)/miniruby -I'$(topdir)' -I'$(top_srcdir)/lib' -I'$(extout)/$(arch)' -I'$(extout)/common'
+RUBY = $(ruby)
+ruby_headers = $(hdrdir)/ruby.h $(hdrdir)/ruby/ruby.h $(hdrdir)/ruby/defines.h $(hdrdir)/ruby/missing.h $(hdrdir)/ruby/intern.h $(hdrdir)/ruby/st.h $(hdrdir)/ruby/subst.h $(arch_hdrdir)/ruby/config.h $(RUBY_EXTCONF_H)
+
+RM = rm -f
+RM_RF = $(RUBY) -run -e rm -- -rf
+RMDIRS = rmdir --ignore-fail-on-non-empty -p
+MAKEDIRS = /bin/mkdir -p
+INSTALL = /usr/bin/install -c
+INSTALL_PROG = $(INSTALL) -m 0755
+INSTALL_DATA = $(INSTALL) -m 644
+COPY = cp
+TOUCH = exit >
+
+#### End of system configuration section. ####
+
+preload =
+
+libpath = . $(topdir)
+LIBPATH = -L. -L$(topdir)
+DEFFILE =
+
+CLEANFILES = mkmf.log
+DISTCLEANFILES =
+DISTCLEANDIRS =
+
+extout = $(topdir)/.ext
+extout_prefix = $(extout)$(target_prefix)/
+target_prefix =
+LOCAL_LIBS =
+LIBS = $(LIBRUBYARG_SHARED) -lpthread -lgmp -ldl -lcrypt -lm -lc
+ORIG_SRCS = strscan.c
+SRCS = $(ORIG_SRCS)
+OBJS = strscan.o
+HDRS = $(srcdir)/extconf.h
+TARGET = strscan
+TARGET_NAME = strscan
+TARGET_ENTRY = Init_$(TARGET_NAME)
+DLLIB = $(TARGET).so
+EXTSTATIC =
+STATIC_LIB = $(TARGET).a
+
+TIMESTAMP_DIR = $(extout)/.timestamp
+BINDIR = $(extout)/bin
+RUBYCOMMONDIR = $(extout)/common
+RUBYLIBDIR = $(RUBYCOMMONDIR)$(target_prefix)
+RUBYARCHDIR = $(extout)/$(arch)$(target_prefix)
+HDRDIR = $(extout)/include/ruby$(target_prefix)
+ARCHHDRDIR = $(extout)/include/$(arch)/ruby$(target_prefix)
+
+TARGET_SO = $(RUBYARCHDIR)/$(DLLIB)
+CLEANLIBS = $(RUBYARCHDIR)/$(TARGET).so
+CLEANOBJS = *.o *.bak
+
+all: install
+static: all
+.PHONY: all install static install-so install-rb
+.PHONY: clean clean-so clean-static clean-rb
+
+clean-static::
+clean-rb-default::
+clean-rb::
+clean-so::
+clean: clean-so clean-static clean-rb-default clean-rb
+ -$(Q)$(RM) $(CLEANLIBS) $(CLEANOBJS) $(CLEANFILES) .*.time
+
+distclean-rb-default::
+distclean-rb::
+distclean-so::
+distclean-static::
+distclean: clean distclean-so distclean-static distclean-rb-default distclean-rb
+ -$(Q)$(RM) Makefile $(RUBY_EXTCONF_H) conftest.* mkmf.log
+ -$(Q)$(RM) core ruby$(EXEEXT) *~ $(DISTCLEANFILES)
+ -$(Q)$(RMDIRS) $(DISTCLEANDIRS) 2> /dev/null || true
+
+realclean: distclean
+install: install-so install-rb
+
+install-so: $(RUBYARCHDIR)/$(DLLIB)
+clean-so::
+ -$(Q)$(RM) $(RUBYARCHDIR)/$(DLLIB)
+ -$(Q)$(RMDIRS) $(RUBYARCHDIR) 2> /dev/null || true
+clean-static::
+ -$(Q)$(RM) $(STATIC_LIB)
+install-rb: pre-install-rb install-rb-default
+install-rb-default: pre-install-rb-default
+pre-install-rb: Makefile
+pre-install-rb-default: Makefile
+pre-install-rb-default:
+ @$(NULLCMD)
+$(TIMESTAMP_DIR)/.RUBYARCHDIR.time:
+ $(Q) $(MAKEDIRS) $(@D) $(RUBYARCHDIR)
+ $(Q) $(TOUCH) $@
+
+site-install: site-install-so site-install-rb
+site-install-so: install-so
+site-install-rb: install-rb
+
+.SUFFIXES: .c .m .cc .mm .cxx .cpp .o .S
+
+.cc.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<
+
+.cc.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -S $<
+
+.mm.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<
+
+.mm.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -S $<
+
+.cxx.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<
+
+.cxx.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -S $<
+
+.cpp.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<
+
+.cpp.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -S $<
+
+.c.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -c $<
+
+.c.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -S $<
+
+.m.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -c $<
+
+.m.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -S $<
+
+$(RUBYARCHDIR)/$(DLLIB): $(OBJS) Makefile $(TIMESTAMP_DIR)/.RUBYARCHDIR.time
+ $(ECHO) linking shared-object $(DLLIB)
+ -$(Q)$(RM) $(@)
+ $(Q) $(LDSHARED) -o $@ $(OBJS) $(LIBPATH) $(DLDFLAGS) $(LOCAL_LIBS) $(LIBS)
+
+$(STATIC_LIB): $(OBJS)
+ -$(Q)$(RM) $(@)
+ $(ECHO) linking static-library $(@)
+ $(Q) $(AR) cru $@ $(OBJS)
+ -$(Q)ranlib $(@) 2> /dev/null || true
+
+###
+$(OBJS): $(RUBY_EXTCONF_H)
+
+# AUTOGENERATED DEPENDENCIES START
+strscan.o: $(RUBY_EXTCONF_H)
+strscan.o: $(arch_hdrdir)/ruby/config.h
+strscan.o: $(hdrdir)/ruby/defines.h
+strscan.o: $(hdrdir)/ruby/encoding.h
+strscan.o: $(hdrdir)/ruby/intern.h
+strscan.o: $(hdrdir)/ruby/missing.h
+strscan.o: $(hdrdir)/ruby/oniguruma.h
+strscan.o: $(hdrdir)/ruby/re.h
+strscan.o: $(hdrdir)/ruby/regex.h
+strscan.o: $(hdrdir)/ruby/ruby.h
+strscan.o: $(hdrdir)/ruby/st.h
+strscan.o: $(hdrdir)/ruby/subst.h
+strscan.o: $(top_srcdir)/regenc.h
+strscan.o: $(top_srcdir)/regint.h
+strscan.o: strscan.c
+# AUTOGENERATED DEPENDENCIES END
diff --git a/jni/ruby/ext/strscan/depend b/jni/ruby/ext/strscan/depend
new file mode 100644
index 0000000..324c5da
--- /dev/null
+++ b/jni/ruby/ext/strscan/depend
@@ -0,0 +1,17 @@
+# AUTOGENERATED DEPENDENCIES START
+strscan.o: $(RUBY_EXTCONF_H)
+strscan.o: $(arch_hdrdir)/ruby/config.h
+strscan.o: $(hdrdir)/ruby/defines.h
+strscan.o: $(hdrdir)/ruby/encoding.h
+strscan.o: $(hdrdir)/ruby/intern.h
+strscan.o: $(hdrdir)/ruby/missing.h
+strscan.o: $(hdrdir)/ruby/oniguruma.h
+strscan.o: $(hdrdir)/ruby/re.h
+strscan.o: $(hdrdir)/ruby/regex.h
+strscan.o: $(hdrdir)/ruby/ruby.h
+strscan.o: $(hdrdir)/ruby/st.h
+strscan.o: $(hdrdir)/ruby/subst.h
+strscan.o: $(top_srcdir)/regenc.h
+strscan.o: $(top_srcdir)/regint.h
+strscan.o: strscan.c
+# AUTOGENERATED DEPENDENCIES END
diff --git a/jni/ruby/ext/strscan/extconf.h b/jni/ruby/ext/strscan/extconf.h
new file mode 100644
index 0000000..cda0cc8
--- /dev/null
+++ b/jni/ruby/ext/strscan/extconf.h
@@ -0,0 +1,3 @@
+#ifndef EXTCONF_H
+#define EXTCONF_H
+#endif
diff --git a/jni/ruby/ext/strscan/extconf.rb b/jni/ruby/ext/strscan/extconf.rb
new file mode 100644
index 0000000..3e5a295
--- /dev/null
+++ b/jni/ruby/ext/strscan/extconf.rb
@@ -0,0 +1,3 @@
+require 'mkmf'
+$INCFLAGS << " -I$(top_srcdir)"
+create_makefile 'strscan'
diff --git a/jni/ruby/ext/strscan/strscan.c b/jni/ruby/ext/strscan/strscan.c
new file mode 100644
index 0000000..5f70b4b
--- /dev/null
+++ b/jni/ruby/ext/strscan/strscan.c
@@ -0,0 +1,1402 @@
+/*
+ $Id: strscan.c 48672 2014-12-01 21:30:58Z nobu $
+
+ Copyright (c) 1999-2006 Minero Aoki
+
+ This program is free software.
+ You can distribute/modify this program under the terms of
+ the Ruby License. For details, see the file COPYING.
+*/
+
+#include "ruby/ruby.h"
+#include "ruby/re.h"
+#include "ruby/encoding.h"
+#include "regint.h"
+
+#define STRSCAN_VERSION "0.7.0"
+
+/* =======================================================================
+ Data Type Definitions
+ ======================================================================= */
+
+static VALUE StringScanner;
+static VALUE ScanError;
+static ID id_byteslice;
+
+struct strscanner
+{
+ /* multi-purpose flags */
+ unsigned long flags;
+#define FLAG_MATCHED (1 << 0)
+
+ /* the string to scan */
+ VALUE str;
+
+ /* scan pointers */
+ long prev; /* legal only when MATCHED_P(s) */
+ long curr; /* always legal */
+
+ /* the regexp register; legal only when MATCHED_P(s) */
+ struct re_registers regs;
+
+ /* regexp used for last scan */
+ VALUE regex;
+};
+
+#define MATCHED_P(s) ((s)->flags & FLAG_MATCHED)
+#define MATCHED(s) (s)->flags |= FLAG_MATCHED
+#define CLEAR_MATCH_STATUS(s) (s)->flags &= ~FLAG_MATCHED
+
+#define S_PBEG(s) (RSTRING_PTR((s)->str))
+#define S_LEN(s) (RSTRING_LEN((s)->str))
+#define S_PEND(s) (S_PBEG(s) + S_LEN(s))
+#define CURPTR(s) (S_PBEG(s) + (s)->curr)
+#define S_RESTLEN(s) (S_LEN(s) - (s)->curr)
+
+#define EOS_P(s) ((s)->curr >= RSTRING_LEN(p->str))
+
+#define GET_SCANNER(obj,var) do {\
+ (var) = check_strscan(obj);\
+ if (NIL_P((var)->str)) rb_raise(rb_eArgError, "uninitialized StringScanner object");\
+} while (0)
+
+/* =======================================================================
+ Function Prototypes
+ ======================================================================= */
+
+static VALUE infect _((VALUE str, struct strscanner *p));
+static VALUE extract_range _((struct strscanner *p, long beg_i, long end_i));
+static VALUE extract_beg_len _((struct strscanner *p, long beg_i, long len));
+
+static struct strscanner *check_strscan _((VALUE obj));
+static void strscan_mark _((void *p));
+static void strscan_free _((void *p));
+static size_t strscan_memsize _((const void *p));
+static VALUE strscan_s_allocate _((VALUE klass));
+static VALUE strscan_initialize _((int argc, VALUE *argv, VALUE self));
+static VALUE strscan_init_copy _((VALUE vself, VALUE vorig));
+
+static VALUE strscan_s_mustc _((VALUE self));
+static VALUE strscan_terminate _((VALUE self));
+static VALUE strscan_clear _((VALUE self));
+static VALUE strscan_get_string _((VALUE self));
+static VALUE strscan_set_string _((VALUE self, VALUE str));
+static VALUE strscan_concat _((VALUE self, VALUE str));
+static VALUE strscan_get_pos _((VALUE self));
+static VALUE strscan_set_pos _((VALUE self, VALUE pos));
+static VALUE strscan_do_scan _((VALUE self, VALUE regex,
+ int succptr, int getstr, int headonly));
+static VALUE strscan_scan _((VALUE self, VALUE re));
+static VALUE strscan_match_p _((VALUE self, VALUE re));
+static VALUE strscan_skip _((VALUE self, VALUE re));
+static VALUE strscan_check _((VALUE self, VALUE re));
+static VALUE strscan_scan_full _((VALUE self, VALUE re,
+ VALUE succp, VALUE getp));
+static VALUE strscan_scan_until _((VALUE self, VALUE re));
+static VALUE strscan_skip_until _((VALUE self, VALUE re));
+static VALUE strscan_check_until _((VALUE self, VALUE re));
+static VALUE strscan_search_full _((VALUE self, VALUE re,
+ VALUE succp, VALUE getp));
+static void adjust_registers_to_matched _((struct strscanner *p));
+static VALUE strscan_getch _((VALUE self));
+static VALUE strscan_get_byte _((VALUE self));
+static VALUE strscan_getbyte _((VALUE self));
+static VALUE strscan_peek _((VALUE self, VALUE len));
+static VALUE strscan_peep _((VALUE self, VALUE len));
+static VALUE strscan_unscan _((VALUE self));
+static VALUE strscan_bol_p _((VALUE self));
+static VALUE strscan_eos_p _((VALUE self));
+static VALUE strscan_empty_p _((VALUE self));
+static VALUE strscan_rest_p _((VALUE self));
+static VALUE strscan_matched_p _((VALUE self));
+static VALUE strscan_matched _((VALUE self));
+static VALUE strscan_matched_size _((VALUE self));
+static VALUE strscan_aref _((VALUE self, VALUE idx));
+static VALUE strscan_pre_match _((VALUE self));
+static VALUE strscan_post_match _((VALUE self));
+static VALUE strscan_rest _((VALUE self));
+static VALUE strscan_rest_size _((VALUE self));
+
+static VALUE strscan_inspect _((VALUE self));
+static VALUE inspect1 _((struct strscanner *p));
+static VALUE inspect2 _((struct strscanner *p));
+
+/* =======================================================================
+ Utils
+ ======================================================================= */
+
+static VALUE
+infect(VALUE str, struct strscanner *p)
+{
+ OBJ_INFECT(str, p->str);
+ return str;
+}
+
+static VALUE
+str_new(struct strscanner *p, const char *ptr, long len)
+{
+ VALUE str = rb_str_new(ptr, len);
+ rb_enc_copy(str, p->str);
+ return str;
+}
+
+static VALUE
+extract_range(struct strscanner *p, long beg_i, long end_i)
+{
+ if (beg_i > S_LEN(p)) return Qnil;
+ if (end_i > S_LEN(p))
+ end_i = S_LEN(p);
+ return infect(str_new(p, S_PBEG(p) + beg_i, end_i - beg_i), p);
+}
+
+static VALUE
+extract_beg_len(struct strscanner *p, long beg_i, long len)
+{
+ if (beg_i > S_LEN(p)) return Qnil;
+ if (beg_i + len > S_LEN(p))
+ len = S_LEN(p) - beg_i;
+ return infect(str_new(p, S_PBEG(p) + beg_i, len), p);
+}
+
+/* =======================================================================
+ Constructor
+ ======================================================================= */
+
+static void
+strscan_mark(void *ptr)
+{
+ struct strscanner *p = ptr;
+ rb_gc_mark(p->str);
+}
+
+static void
+strscan_free(void *ptr)
+{
+ struct strscanner *p = ptr;
+ onig_region_free(&(p->regs), 0);
+ ruby_xfree(p);
+}
+
+static size_t
+strscan_memsize(const void *ptr)
+{
+ const struct strscanner *p = ptr;
+ size_t size = 0;
+ if (p) {
+ size = sizeof(*p) - sizeof(p->regs) + onig_region_memsize(&p->regs);
+ }
+ return size;
+}
+
+static const rb_data_type_t strscanner_type = {
+ "StringScanner",
+ {strscan_mark, strscan_free, strscan_memsize},
+ 0, 0, RUBY_TYPED_FREE_IMMEDIATELY
+};
+
+static VALUE
+strscan_s_allocate(VALUE klass)
+{
+ struct strscanner *p;
+
+ p = ZALLOC(struct strscanner);
+ CLEAR_MATCH_STATUS(p);
+ onig_region_init(&(p->regs));
+ p->str = Qnil;
+ return TypedData_Wrap_Struct(klass, &strscanner_type, p);
+}
+
+/*
+ * call-seq: StringScanner.new(string, dup = false)
+ *
+ * Creates a new StringScanner object to scan over the given +string+.
+ * +dup+ argument is obsolete and not used now.
+ */
+static VALUE
+strscan_initialize(int argc, VALUE *argv, VALUE self)
+{
+ struct strscanner *p;
+ VALUE str, need_dup;
+
+ p = check_strscan(self);
+ rb_scan_args(argc, argv, "11", &str, &need_dup);
+ StringValue(str);
+ p->str = str;
+
+ return self;
+}
+
+static struct strscanner *
+check_strscan(VALUE obj)
+{
+ return rb_check_typeddata(obj, &strscanner_type);
+}
+
+/*
+ * call-seq:
+ * dup
+ * clone
+ *
+ * Duplicates a StringScanner object.
+ */
+static VALUE
+strscan_init_copy(VALUE vself, VALUE vorig)
+{
+ struct strscanner *self, *orig;
+
+ self = check_strscan(vself);
+ orig = check_strscan(vorig);
+ if (self != orig) {
+ self->flags = orig->flags;
+ self->str = orig->str;
+ self->prev = orig->prev;
+ self->curr = orig->curr;
+ if (rb_reg_region_copy(&self->regs, &orig->regs))
+ rb_memerror();
+ RB_GC_GUARD(vorig);
+ }
+
+ return vself;
+}
+
+/* =======================================================================
+ Instance Methods
+ ======================================================================= */
+
+/*
+ * call-seq: StringScanner.must_C_version
+ *
+ * This method is defined for backward compatibility.
+ */
+static VALUE
+strscan_s_mustc(VALUE self)
+{
+ return self;
+}
+
+/*
+ * Reset the scan pointer (index 0) and clear matching data.
+ */
+static VALUE
+strscan_reset(VALUE self)
+{
+ struct strscanner *p;
+
+ GET_SCANNER(self, p);
+ p->curr = 0;
+ CLEAR_MATCH_STATUS(p);
+ return self;
+}
+
+/*
+ * call-seq:
+ * terminate
+ * clear
+ *
+ * Set the scan pointer to the end of the string and clear matching data.
+ */
+static VALUE
+strscan_terminate(VALUE self)
+{
+ struct strscanner *p;
+
+ GET_SCANNER(self, p);
+ p->curr = S_LEN(p);
+ CLEAR_MATCH_STATUS(p);
+ return self;
+}
+
+/*
+ * Equivalent to #terminate.
+ * This method is obsolete; use #terminate instead.
+ */
+static VALUE
+strscan_clear(VALUE self)
+{
+ rb_warning("StringScanner#clear is obsolete; use #terminate instead");
+ return strscan_terminate(self);
+}
+
+/*
+ * Returns the string being scanned.
+ */
+static VALUE
+strscan_get_string(VALUE self)
+{
+ struct strscanner *p;
+
+ GET_SCANNER(self, p);
+ return p->str;
+}
+
+/*
+ * call-seq: string=(str)
+ *
+ * Changes the string being scanned to +str+ and resets the scanner.
+ * Returns +str+.
+ */
+static VALUE
+strscan_set_string(VALUE self, VALUE str)
+{
+ struct strscanner *p = check_strscan(self);
+
+ StringValue(str);
+ p->str = str;
+ p->curr = 0;
+ CLEAR_MATCH_STATUS(p);
+ return str;
+}
+
+/*
+ * call-seq:
+ * concat(str)
+ * <<(str)
+ *
+ * Appends +str+ to the string being scanned.
+ * This method does not affect scan pointer.
+ *
+ * s = StringScanner.new("Fri Dec 12 1975 14:39")
+ * s.scan(/Fri /)
+ * s << " +1000 GMT"
+ * s.string # -> "Fri Dec 12 1975 14:39 +1000 GMT"
+ * s.scan(/Dec/) # -> "Dec"
+ */
+static VALUE
+strscan_concat(VALUE self, VALUE str)
+{
+ struct strscanner *p;
+
+ GET_SCANNER(self, p);
+ StringValue(str);
+ rb_str_append(p->str, str);
+ return self;
+}
+
+/*
+ * Returns the byte position of the scan pointer. In the 'reset' position, this
+ * value is zero. In the 'terminated' position (i.e. the string is exhausted),
+ * this value is the bytesize of the string.
+ *
+ * In short, it's a 0-based index into bytes of the string.
+ *
+ * s = StringScanner.new('test string')
+ * s.pos # -> 0
+ * s.scan_until /str/ # -> "test str"
+ * s.pos # -> 8
+ * s.terminate # -> #<StringScanner fin>
+ * s.pos # -> 11
+ */
+static VALUE
+strscan_get_pos(VALUE self)
+{
+ struct strscanner *p;
+
+ GET_SCANNER(self, p);
+ return INT2FIX(p->curr);
+}
+
+/*
+ * Returns the character position of the scan pointer. In the 'reset' position, this
+ * value is zero. In the 'terminated' position (i.e. the string is exhausted),
+ * this value is the size of the string.
+ *
+ * In short, it's a 0-based index into the string.
+ *
+ * s = StringScanner.new("abcädeföghi")
+ * s.charpos # -> 0
+ * s.scan_until(/ä/) # -> "abcä"
+ * s.pos # -> 5
+ * s.charpos # -> 4
+ */
+static VALUE
+strscan_get_charpos(VALUE self)
+{
+ struct strscanner *p;
+ VALUE substr;
+
+ GET_SCANNER(self, p);
+
+ substr = rb_funcall(p->str, id_byteslice, 2, INT2FIX(0), INT2NUM(p->curr));
+
+ return rb_str_length(substr);
+}
+
+/*
+ * call-seq: pos=(n)
+ *
+ * Set the byte position of the scan pointer.
+ *
+ * s = StringScanner.new('test string')
+ * s.pos = 7 # -> 7
+ * s.rest # -> "ring"
+ */
+static VALUE
+strscan_set_pos(VALUE self, VALUE v)
+{
+ struct strscanner *p;
+ long i;
+
+ GET_SCANNER(self, p);
+ i = NUM2INT(v);
+ if (i < 0) i += S_LEN(p);
+ if (i < 0) rb_raise(rb_eRangeError, "index out of range");
+ if (i > S_LEN(p)) rb_raise(rb_eRangeError, "index out of range");
+ p->curr = i;
+ return INT2NUM(i);
+}
+
+static VALUE
+strscan_do_scan(VALUE self, VALUE regex, int succptr, int getstr, int headonly)
+{
+ regex_t *rb_reg_prepare_re(VALUE re, VALUE str);
+ struct strscanner *p;
+ regex_t *re;
+ long ret;
+ int tmpreg;
+
+ Check_Type(regex, T_REGEXP);
+ GET_SCANNER(self, p);
+
+ CLEAR_MATCH_STATUS(p);
+ if (S_RESTLEN(p) < 0) {
+ return Qnil;
+ }
+
+ p->regex = regex;
+ re = rb_reg_prepare_re(regex, p->str);
+ tmpreg = re != RREGEXP(regex)->ptr;
+ if (!tmpreg) RREGEXP(regex)->usecnt++;
+
+ if (headonly) {
+ ret = onig_match(re, (UChar* )CURPTR(p),
+ (UChar* )(CURPTR(p) + S_RESTLEN(p)),
+ (UChar* )CURPTR(p), &(p->regs), ONIG_OPTION_NONE);
+ }
+ else {
+ ret = onig_search(re,
+ (UChar* )CURPTR(p), (UChar* )(CURPTR(p) + S_RESTLEN(p)),
+ (UChar* )CURPTR(p), (UChar* )(CURPTR(p) + S_RESTLEN(p)),
+ &(p->regs), ONIG_OPTION_NONE);
+ }
+ if (!tmpreg) RREGEXP(regex)->usecnt--;
+ if (tmpreg) {
+ if (RREGEXP(regex)->usecnt) {
+ onig_free(re);
+ }
+ else {
+ onig_free(RREGEXP(regex)->ptr);
+ RREGEXP(regex)->ptr = re;
+ }
+ }
+
+ if (ret == -2) rb_raise(ScanError, "regexp buffer overflow");
+ if (ret < 0) {
+ /* not matched */
+ return Qnil;
+ }
+
+ MATCHED(p);
+ p->prev = p->curr;
+ if (succptr) {
+ p->curr += p->regs.end[0];
+ }
+ if (getstr) {
+ return extract_beg_len(p, p->prev, p->regs.end[0]);
+ }
+ else {
+ return INT2FIX(p->regs.end[0]);
+ }
+}
+
+/*
+ * call-seq: scan(pattern) => String
+ *
+ * Tries to match with +pattern+ at the current position. If there's a match,
+ * the scanner advances the "scan pointer" and returns the matched string.
+ * Otherwise, the scanner returns +nil+.
+ *
+ * s = StringScanner.new('test string')
+ * p s.scan(/\w+/) # -> "test"
+ * p s.scan(/\w+/) # -> nil
+ * p s.scan(/\s+/) # -> " "
+ * p s.scan(/\w+/) # -> "string"
+ * p s.scan(/./) # -> nil
+ *
+ */
+static VALUE
+strscan_scan(VALUE self, VALUE re)
+{
+ return strscan_do_scan(self, re, 1, 1, 1);
+}
+
+/*
+ * call-seq: match?(pattern)
+ *
+ * Tests whether the given +pattern+ is matched from the current scan pointer.
+ * Returns the length of the match, or +nil+. The scan pointer is not advanced.
+ *
+ * s = StringScanner.new('test string')
+ * p s.match?(/\w+/) # -> 4
+ * p s.match?(/\w+/) # -> 4
+ * p s.match?(/\s+/) # -> nil
+ */
+static VALUE
+strscan_match_p(VALUE self, VALUE re)
+{
+ return strscan_do_scan(self, re, 0, 0, 1);
+}
+
+/*
+ * call-seq: skip(pattern)
+ *
+ * Attempts to skip over the given +pattern+ beginning with the scan pointer.
+ * If it matches, the scan pointer is advanced to the end of the match, and the
+ * length of the match is returned. Otherwise, +nil+ is returned.
+ *
+ * It's similar to #scan, but without returning the matched string.
+ *
+ * s = StringScanner.new('test string')
+ * p s.skip(/\w+/) # -> 4
+ * p s.skip(/\w+/) # -> nil
+ * p s.skip(/\s+/) # -> 1
+ * p s.skip(/\w+/) # -> 6
+ * p s.skip(/./) # -> nil
+ *
+ */
+static VALUE
+strscan_skip(VALUE self, VALUE re)
+{
+ return strscan_do_scan(self, re, 1, 0, 1);
+}
+
+/*
+ * call-seq: check(pattern)
+ *
+ * This returns the value that #scan would return, without advancing the scan
+ * pointer. The match register is affected, though.
+ *
+ * s = StringScanner.new("Fri Dec 12 1975 14:39")
+ * s.check /Fri/ # -> "Fri"
+ * s.pos # -> 0
+ * s.matched # -> "Fri"
+ * s.check /12/ # -> nil
+ * s.matched # -> nil
+ *
+ * Mnemonic: it "checks" to see whether a #scan will return a value.
+ */
+static VALUE
+strscan_check(VALUE self, VALUE re)
+{
+ return strscan_do_scan(self, re, 0, 1, 1);
+}
+
+/*
+ * call-seq: scan_full(pattern, advance_pointer_p, return_string_p)
+ *
+ * Tests whether the given +pattern+ is matched from the current scan pointer.
+ * Advances the scan pointer if +advance_pointer_p+ is true.
+ * Returns the matched string if +return_string_p+ is true.
+ * The match register is affected.
+ *
+ * "full" means "#scan with full parameters".
+ */
+static VALUE
+strscan_scan_full(VALUE self, VALUE re, VALUE s, VALUE f)
+{
+ return strscan_do_scan(self, re, RTEST(s), RTEST(f), 1);
+}
+
+/*
+ * call-seq: scan_until(pattern)
+ *
+ * Scans the string _until_ the +pattern+ is matched. Returns the substring up
+ * to and including the end of the match, advancing the scan pointer to that
+ * location. If there is no match, +nil+ is returned.
+ *
+ * s = StringScanner.new("Fri Dec 12 1975 14:39")
+ * s.scan_until(/1/) # -> "Fri Dec 1"
+ * s.pre_match # -> "Fri Dec "
+ * s.scan_until(/XYZ/) # -> nil
+ */
+static VALUE
+strscan_scan_until(VALUE self, VALUE re)
+{
+ return strscan_do_scan(self, re, 1, 1, 0);
+}
+
+/*
+ * call-seq: exist?(pattern)
+ *
+ * Looks _ahead_ to see if the +pattern+ exists _anywhere_ in the string,
+ * without advancing the scan pointer. This predicates whether a #scan_until
+ * will return a value.
+ *
+ * s = StringScanner.new('test string')
+ * s.exist? /s/ # -> 3
+ * s.scan /test/ # -> "test"
+ * s.exist? /s/ # -> 2
+ * s.exist? /e/ # -> nil
+ */
+static VALUE
+strscan_exist_p(VALUE self, VALUE re)
+{
+ return strscan_do_scan(self, re, 0, 0, 0);
+}
+
+/*
+ * call-seq: skip_until(pattern)
+ *
+ * Advances the scan pointer until +pattern+ is matched and consumed. Returns
+ * the number of bytes advanced, or +nil+ if no match was found.
+ *
+ * Look ahead to match +pattern+, and advance the scan pointer to the _end_
+ * of the match. Return the number of characters advanced, or +nil+ if the
+ * match was unsuccessful.
+ *
+ * It's similar to #scan_until, but without returning the intervening string.
+ *
+ * s = StringScanner.new("Fri Dec 12 1975 14:39")
+ * s.skip_until /12/ # -> 10
+ * s #
+ */
+static VALUE
+strscan_skip_until(VALUE self, VALUE re)
+{
+ return strscan_do_scan(self, re, 1, 0, 0);
+}
+
+/*
+ * call-seq: check_until(pattern)
+ *
+ * This returns the value that #scan_until would return, without advancing the
+ * scan pointer. The match register is affected, though.
+ *
+ * s = StringScanner.new("Fri Dec 12 1975 14:39")
+ * s.check_until /12/ # -> "Fri Dec 12"
+ * s.pos # -> 0
+ * s.matched # -> 12
+ *
+ * Mnemonic: it "checks" to see whether a #scan_until will return a value.
+ */
+static VALUE
+strscan_check_until(VALUE self, VALUE re)
+{
+ return strscan_do_scan(self, re, 0, 1, 0);
+}
+
+/*
+ * call-seq: search_full(pattern, advance_pointer_p, return_string_p)
+ *
+ * Scans the string _until_ the +pattern+ is matched.
+ * Advances the scan pointer if +advance_pointer_p+, otherwise not.
+ * Returns the matched string if +return_string_p+ is true, otherwise
+ * returns the number of bytes advanced.
+ * This method does affect the match register.
+ */
+static VALUE
+strscan_search_full(VALUE self, VALUE re, VALUE s, VALUE f)
+{
+ return strscan_do_scan(self, re, RTEST(s), RTEST(f), 0);
+}
+
+static void
+adjust_registers_to_matched(struct strscanner *p)
+{
+ onig_region_clear(&(p->regs));
+ onig_region_set(&(p->regs), 0, 0, (int)(p->curr - p->prev));
+}
+
+/*
+ * Scans one character and returns it.
+ * This method is multibyte character sensitive.
+ *
+ * s = StringScanner.new("ab")
+ * s.getch # => "a"
+ * s.getch # => "b"
+ * s.getch # => nil
+ *
+ * $KCODE = 'EUC'
+ * s = StringScanner.new("\244\242")
+ * s.getch # => "\244\242" # Japanese hira-kana "A" in EUC-JP
+ * s.getch # => nil
+ */
+static VALUE
+strscan_getch(VALUE self)
+{
+ struct strscanner *p;
+ long len;
+
+ GET_SCANNER(self, p);
+ CLEAR_MATCH_STATUS(p);
+ if (EOS_P(p))
+ return Qnil;
+
+ len = rb_enc_mbclen(CURPTR(p), S_PEND(p), rb_enc_get(p->str));
+ if (p->curr + len > S_LEN(p)) {
+ len = S_LEN(p) - p->curr;
+ }
+ p->prev = p->curr;
+ p->curr += len;
+ MATCHED(p);
+ adjust_registers_to_matched(p);
+ return extract_range(p, p->prev + p->regs.beg[0],
+ p->prev + p->regs.end[0]);
+}
+
+/*
+ * Scans one byte and returns it.
+ * This method is not multibyte character sensitive.
+ * See also: #getch.
+ *
+ * s = StringScanner.new('ab')
+ * s.get_byte # => "a"
+ * s.get_byte # => "b"
+ * s.get_byte # => nil
+ *
+ * $KCODE = 'EUC'
+ * s = StringScanner.new("\244\242")
+ * s.get_byte # => "\244"
+ * s.get_byte # => "\242"
+ * s.get_byte # => nil
+ */
+static VALUE
+strscan_get_byte(VALUE self)
+{
+ struct strscanner *p;
+
+ GET_SCANNER(self, p);
+ CLEAR_MATCH_STATUS(p);
+ if (EOS_P(p))
+ return Qnil;
+
+ p->prev = p->curr;
+ p->curr++;
+ MATCHED(p);
+ adjust_registers_to_matched(p);
+ return extract_range(p, p->prev + p->regs.beg[0],
+ p->prev + p->regs.end[0]);
+}
+
+/*
+ * Equivalent to #get_byte.
+ * This method is obsolete; use #get_byte instead.
+ */
+static VALUE
+strscan_getbyte(VALUE self)
+{
+ rb_warning("StringScanner#getbyte is obsolete; use #get_byte instead");
+ return strscan_get_byte(self);
+}
+
+/*
+ * call-seq: peek(len)
+ *
+ * Extracts a string corresponding to <tt>string[pos,len]</tt>, without
+ * advancing the scan pointer.
+ *
+ * s = StringScanner.new('test string')
+ * s.peek(7) # => "test st"
+ * s.peek(7) # => "test st"
+ *
+ */
+static VALUE
+strscan_peek(VALUE self, VALUE vlen)
+{
+ struct strscanner *p;
+ long len;
+
+ GET_SCANNER(self, p);
+
+ len = NUM2LONG(vlen);
+ if (EOS_P(p))
+ return infect(str_new(p, "", 0), p);
+
+ if (p->curr + len > S_LEN(p))
+ len = S_LEN(p) - p->curr;
+ return extract_beg_len(p, p->curr, len);
+}
+
+/*
+ * Equivalent to #peek.
+ * This method is obsolete; use #peek instead.
+ */
+static VALUE
+strscan_peep(VALUE self, VALUE vlen)
+{
+ rb_warning("StringScanner#peep is obsolete; use #peek instead");
+ return strscan_peek(self, vlen);
+}
+
+/*
+ * Set the scan pointer to the previous position. Only one previous position is
+ * remembered, and it changes with each scanning operation.
+ *
+ * s = StringScanner.new('test string')
+ * s.scan(/\w+/) # => "test"
+ * s.unscan
+ * s.scan(/../) # => "te"
+ * s.scan(/\d/) # => nil
+ * s.unscan # ScanError: unscan failed: previous match record not exist
+ */
+static VALUE
+strscan_unscan(VALUE self)
+{
+ struct strscanner *p;
+
+ GET_SCANNER(self, p);
+ if (! MATCHED_P(p))
+ rb_raise(ScanError, "unscan failed: previous match record not exist");
+ p->curr = p->prev;
+ CLEAR_MATCH_STATUS(p);
+ return self;
+}
+
+/*
+ * Returns +true+ iff the scan pointer is at the beginning of the line.
+ *
+ * s = StringScanner.new("test\ntest\n")
+ * s.bol? # => true
+ * s.scan(/te/)
+ * s.bol? # => false
+ * s.scan(/st\n/)
+ * s.bol? # => true
+ * s.terminate
+ * s.bol? # => true
+ */
+static VALUE
+strscan_bol_p(VALUE self)
+{
+ struct strscanner *p;
+
+ GET_SCANNER(self, p);
+ if (CURPTR(p) > S_PEND(p)) return Qnil;
+ if (p->curr == 0) return Qtrue;
+ return (*(CURPTR(p) - 1) == '\n') ? Qtrue : Qfalse;
+}
+
+/*
+ * Returns +true+ if the scan pointer is at the end of the string.
+ *
+ * s = StringScanner.new('test string')
+ * p s.eos? # => false
+ * s.scan(/test/)
+ * p s.eos? # => false
+ * s.terminate
+ * p s.eos? # => true
+ */
+static VALUE
+strscan_eos_p(VALUE self)
+{
+ struct strscanner *p;
+
+ GET_SCANNER(self, p);
+ return EOS_P(p) ? Qtrue : Qfalse;
+}
+
+/*
+ * Equivalent to #eos?.
+ * This method is obsolete, use #eos? instead.
+ */
+static VALUE
+strscan_empty_p(VALUE self)
+{
+ rb_warning("StringScanner#empty? is obsolete; use #eos? instead");
+ return strscan_eos_p(self);
+}
+
+/*
+ * Returns true iff there is more data in the string. See #eos?.
+ * This method is obsolete; use #eos? instead.
+ *
+ * s = StringScanner.new('test string')
+ * s.eos? # These two
+ * s.rest? # are opposites.
+ */
+static VALUE
+strscan_rest_p(VALUE self)
+{
+ struct strscanner *p;
+
+ GET_SCANNER(self, p);
+ return EOS_P(p) ? Qfalse : Qtrue;
+}
+
+/*
+ * Returns +true+ iff the last match was successful.
+ *
+ * s = StringScanner.new('test string')
+ * s.match?(/\w+/) # => 4
+ * s.matched? # => true
+ * s.match?(/\d+/) # => nil
+ * s.matched? # => false
+ */
+static VALUE
+strscan_matched_p(VALUE self)
+{
+ struct strscanner *p;
+
+ GET_SCANNER(self, p);
+ return MATCHED_P(p) ? Qtrue : Qfalse;
+}
+
+/*
+ * Returns the last matched string.
+ *
+ * s = StringScanner.new('test string')
+ * s.match?(/\w+/) # -> 4
+ * s.matched # -> "test"
+ */
+static VALUE
+strscan_matched(VALUE self)
+{
+ struct strscanner *p;
+
+ GET_SCANNER(self, p);
+ if (! MATCHED_P(p)) return Qnil;
+ return extract_range(p, p->prev + p->regs.beg[0],
+ p->prev + p->regs.end[0]);
+}
+
+/*
+ * Returns the size of the most recent match (see #matched), or +nil+ if there
+ * was no recent match.
+ *
+ * s = StringScanner.new('test string')
+ * s.check /\w+/ # -> "test"
+ * s.matched_size # -> 4
+ * s.check /\d+/ # -> nil
+ * s.matched_size # -> nil
+ */
+static VALUE
+strscan_matched_size(VALUE self)
+{
+ struct strscanner *p;
+
+ GET_SCANNER(self, p);
+ if (! MATCHED_P(p)) return Qnil;
+ return INT2NUM(p->regs.end[0] - p->regs.beg[0]);
+}
+
+static int
+name_to_backref_number(struct re_registers *regs, VALUE regexp, const char* name, const char* name_end, rb_encoding *enc)
+{
+ int num;
+
+ num = onig_name_to_backref_number(RREGEXP(regexp)->ptr,
+ (const unsigned char* )name, (const unsigned char* )name_end, regs);
+ if (num >= 1) {
+ return num;
+ }
+ else {
+ rb_enc_raise(enc, rb_eIndexError, "undefined group name reference: %.*s",
+ rb_long2int(name_end - name), name);
+ }
+
+ UNREACHABLE;
+}
+
+/*
+ * call-seq: [](n)
+ *
+ * Return the n-th subgroup in the most recent match.
+ *
+ * s = StringScanner.new("Fri Dec 12 1975 14:39")
+ * s.scan(/(\w+) (\w+) (\d+) /) # -> "Fri Dec 12 "
+ * s[0] # -> "Fri Dec 12 "
+ * s[1] # -> "Fri"
+ * s[2] # -> "Dec"
+ * s[3] # -> "12"
+ * s.post_match # -> "1975 14:39"
+ * s.pre_match # -> ""
+ *
+ * s.reset
+ * s.scan(/(?<wday>\w+) (?<month>\w+) (?<day>\d+) /) # -> "Fri Dec 12 "
+ * s[0] # -> "Fri Dec 12 "
+ * s[1] # -> "Fri"
+ * s[2] # -> "Dec"
+ * s[3] # -> "12"
+ * s[:wday] # -> "Fri"
+ * s[:month] # -> "Dec"
+ * s[:day] # -> "12"
+ * s.post_match # -> "1975 14:39"
+ * s.pre_match # -> ""
+ */
+static VALUE
+strscan_aref(VALUE self, VALUE idx)
+{
+ const char *name;
+ struct strscanner *p;
+ long i;
+
+ GET_SCANNER(self, p);
+ if (! MATCHED_P(p)) return Qnil;
+
+ switch (TYPE(idx)) {
+ case T_SYMBOL:
+ idx = rb_sym2str(idx);
+ /* fall through */
+ case T_STRING:
+ RSTRING_GETMEM(idx, name, i);
+ i = name_to_backref_number(&(p->regs), p->regex, name, name + i, rb_enc_get(idx));
+ break;
+ default:
+ i = NUM2LONG(idx);
+ }
+
+ if (i < 0)
+ i += p->regs.num_regs;
+ if (i < 0) return Qnil;
+ if (i >= p->regs.num_regs) return Qnil;
+ if (p->regs.beg[i] == -1) return Qnil;
+
+ return extract_range(p, p->prev + p->regs.beg[i],
+ p->prev + p->regs.end[i]);
+}
+
+/*
+ * Return the <i><b>pre</b>-match</i> (in the regular expression sense) of the last scan.
+ *
+ * s = StringScanner.new('test string')
+ * s.scan(/\w+/) # -> "test"
+ * s.scan(/\s+/) # -> " "
+ * s.pre_match # -> "test"
+ * s.post_match # -> "string"
+ */
+static VALUE
+strscan_pre_match(VALUE self)
+{
+ struct strscanner *p;
+
+ GET_SCANNER(self, p);
+ if (! MATCHED_P(p)) return Qnil;
+ return extract_range(p, 0, p->prev + p->regs.beg[0]);
+}
+
+/*
+ * Return the <i><b>post</b>-match</i> (in the regular expression sense) of the last scan.
+ *
+ * s = StringScanner.new('test string')
+ * s.scan(/\w+/) # -> "test"
+ * s.scan(/\s+/) # -> " "
+ * s.pre_match # -> "test"
+ * s.post_match # -> "string"
+ */
+static VALUE
+strscan_post_match(VALUE self)
+{
+ struct strscanner *p;
+
+ GET_SCANNER(self, p);
+ if (! MATCHED_P(p)) return Qnil;
+ return extract_range(p, p->prev + p->regs.end[0], S_LEN(p));
+}
+
+/*
+ * Returns the "rest" of the string (i.e. everything after the scan pointer).
+ * If there is no more data (eos? = true), it returns <tt>""</tt>.
+ */
+static VALUE
+strscan_rest(VALUE self)
+{
+ struct strscanner *p;
+
+ GET_SCANNER(self, p);
+ if (EOS_P(p)) {
+ return infect(str_new(p, "", 0), p);
+ }
+ return extract_range(p, p->curr, S_LEN(p));
+}
+
+/*
+ * <tt>s.rest_size</tt> is equivalent to <tt>s.rest.size</tt>.
+ */
+static VALUE
+strscan_rest_size(VALUE self)
+{
+ struct strscanner *p;
+ long i;
+
+ GET_SCANNER(self, p);
+ if (EOS_P(p)) {
+ return INT2FIX(0);
+ }
+ i = S_LEN(p) - p->curr;
+ return INT2FIX(i);
+}
+
+/*
+ * <tt>s.restsize</tt> is equivalent to <tt>s.rest_size</tt>.
+ * This method is obsolete; use #rest_size instead.
+ */
+static VALUE
+strscan_restsize(VALUE self)
+{
+ rb_warning("StringScanner#restsize is obsolete; use #rest_size instead");
+ return strscan_rest_size(self);
+}
+
+#define INSPECT_LENGTH 5
+
+/*
+ * Returns a string that represents the StringScanner object, showing:
+ * - the current position
+ * - the size of the string
+ * - the characters surrounding the scan pointer
+ *
+ * s = StringScanner.new("Fri Dec 12 1975 14:39")
+ * s.inspect # -> '#<StringScanner 0/21 @ "Fri D...">'
+ * s.scan_until /12/ # -> "Fri Dec 12"
+ * s.inspect # -> '#<StringScanner 10/21 "...ec 12" @ " 1975...">'
+ */
+static VALUE
+strscan_inspect(VALUE self)
+{
+ struct strscanner *p;
+ VALUE a, b;
+
+ p = check_strscan(self);
+ if (NIL_P(p->str)) {
+ a = rb_sprintf("#<%"PRIsVALUE" (uninitialized)>", rb_obj_class(self));
+ return infect(a, p);
+ }
+ if (EOS_P(p)) {
+ a = rb_sprintf("#<%"PRIsVALUE" fin>", rb_obj_class(self));
+ return infect(a, p);
+ }
+ if (p->curr == 0) {
+ b = inspect2(p);
+ a = rb_sprintf("#<%"PRIsVALUE" %ld/%ld @ %"PRIsVALUE">",
+ rb_obj_class(self),
+ p->curr, S_LEN(p),
+ b);
+ return infect(a, p);
+ }
+ a = inspect1(p);
+ b = inspect2(p);
+ a = rb_sprintf("#<%"PRIsVALUE" %ld/%ld %"PRIsVALUE" @ %"PRIsVALUE">",
+ rb_obj_class(self),
+ p->curr, S_LEN(p),
+ a, b);
+ return infect(a, p);
+}
+
+static VALUE
+inspect1(struct strscanner *p)
+{
+ VALUE str;
+ long len;
+
+ if (p->curr == 0) return rb_str_new2("");
+ if (p->curr > INSPECT_LENGTH) {
+ str = rb_str_new_cstr("...");
+ len = INSPECT_LENGTH;
+ }
+ else {
+ str = rb_str_new(0, 0);
+ len = p->curr;
+ }
+ rb_str_cat(str, CURPTR(p) - len, len);
+ return rb_str_dump(str);
+}
+
+static VALUE
+inspect2(struct strscanner *p)
+{
+ VALUE str;
+ long len;
+
+ if (EOS_P(p)) return rb_str_new2("");
+ len = S_LEN(p) - p->curr;
+ if (len > INSPECT_LENGTH) {
+ str = rb_str_new(CURPTR(p), INSPECT_LENGTH);
+ rb_str_cat2(str, "...");
+ }
+ else {
+ str = rb_str_new(CURPTR(p), len);
+ }
+ return rb_str_dump(str);
+}
+
+/* =======================================================================
+ Ruby Interface
+ ======================================================================= */
+
+/*
+ * Document-class: StringScanner
+ *
+ * StringScanner provides for lexical scanning operations on a String. Here is
+ * an example of its usage:
+ *
+ * s = StringScanner.new('This is an example string')
+ * s.eos? # -> false
+ *
+ * p s.scan(/\w+/) # -> "This"
+ * p s.scan(/\w+/) # -> nil
+ * p s.scan(/\s+/) # -> " "
+ * p s.scan(/\s+/) # -> nil
+ * p s.scan(/\w+/) # -> "is"
+ * s.eos? # -> false
+ *
+ * p s.scan(/\s+/) # -> " "
+ * p s.scan(/\w+/) # -> "an"
+ * p s.scan(/\s+/) # -> " "
+ * p s.scan(/\w+/) # -> "example"
+ * p s.scan(/\s+/) # -> " "
+ * p s.scan(/\w+/) # -> "string"
+ * s.eos? # -> true
+ *
+ * p s.scan(/\s+/) # -> nil
+ * p s.scan(/\w+/) # -> nil
+ *
+ * Scanning a string means remembering the position of a <i>scan pointer</i>,
+ * which is just an index. The point of scanning is to move forward a bit at
+ * a time, so matches are sought after the scan pointer; usually immediately
+ * after it.
+ *
+ * Given the string "test string", here are the pertinent scan pointer
+ * positions:
+ *
+ * t e s t s t r i n g
+ * 0 1 2 ... 1
+ * 0
+ *
+ * When you #scan for a pattern (a regular expression), the match must occur
+ * at the character after the scan pointer. If you use #scan_until, then the
+ * match can occur anywhere after the scan pointer. In both cases, the scan
+ * pointer moves <i>just beyond</i> the last character of the match, ready to
+ * scan again from the next character onwards. This is demonstrated by the
+ * example above.
+ *
+ * == Method Categories
+ *
+ * There are other methods besides the plain scanners. You can look ahead in
+ * the string without actually scanning. You can access the most recent match.
+ * You can modify the string being scanned, reset or terminate the scanner,
+ * find out or change the position of the scan pointer, skip ahead, and so on.
+ *
+ * === Advancing the Scan Pointer
+ *
+ * - #getch
+ * - #get_byte
+ * - #scan
+ * - #scan_until
+ * - #skip
+ * - #skip_until
+ *
+ * === Looking Ahead
+ *
+ * - #check
+ * - #check_until
+ * - #exist?
+ * - #match?
+ * - #peek
+ *
+ * === Finding Where we Are
+ *
+ * - #beginning_of_line? (#bol?)
+ * - #eos?
+ * - #rest?
+ * - #rest_size
+ * - #pos
+ *
+ * === Setting Where we Are
+ *
+ * - #reset
+ * - #terminate
+ * - #pos=
+ *
+ * === Match Data
+ *
+ * - #matched
+ * - #matched?
+ * - #matched_size
+ * - []
+ * - #pre_match
+ * - #post_match
+ *
+ * === Miscellaneous
+ *
+ * - <<
+ * - #concat
+ * - #string
+ * - #string=
+ * - #unscan
+ *
+ * There are aliases to several of the methods.
+ */
+void
+Init_strscan(void)
+{
+ ID id_scanerr = rb_intern("ScanError");
+ VALUE tmp;
+
+ id_byteslice = rb_intern("byteslice");
+
+ StringScanner = rb_define_class("StringScanner", rb_cObject);
+ ScanError = rb_define_class_under(StringScanner, "Error", rb_eStandardError);
+ if (!rb_const_defined(rb_cObject, id_scanerr)) {
+ rb_const_set(rb_cObject, id_scanerr, ScanError);
+ }
+ tmp = rb_str_new2(STRSCAN_VERSION);
+ rb_obj_freeze(tmp);
+ rb_const_set(StringScanner, rb_intern("Version"), tmp);
+ tmp = rb_str_new2("$Id: strscan.c 48672 2014-12-01 21:30:58Z nobu $");
+ rb_obj_freeze(tmp);
+ rb_const_set(StringScanner, rb_intern("Id"), tmp);
+
+ rb_define_alloc_func(StringScanner, strscan_s_allocate);
+ rb_define_private_method(StringScanner, "initialize", strscan_initialize, -1);
+ rb_define_private_method(StringScanner, "initialize_copy", strscan_init_copy, 1);
+ rb_define_singleton_method(StringScanner, "must_C_version", strscan_s_mustc, 0);
+ rb_define_method(StringScanner, "reset", strscan_reset, 0);
+ rb_define_method(StringScanner, "terminate", strscan_terminate, 0);
+ rb_define_method(StringScanner, "clear", strscan_clear, 0);
+ rb_define_method(StringScanner, "string", strscan_get_string, 0);
+ rb_define_method(StringScanner, "string=", strscan_set_string, 1);
+ rb_define_method(StringScanner, "concat", strscan_concat, 1);
+ rb_define_method(StringScanner, "<<", strscan_concat, 1);
+ rb_define_method(StringScanner, "pos", strscan_get_pos, 0);
+ rb_define_method(StringScanner, "pos=", strscan_set_pos, 1);
+ rb_define_method(StringScanner, "charpos", strscan_get_charpos, 0);
+ rb_define_method(StringScanner, "pointer", strscan_get_pos, 0);
+ rb_define_method(StringScanner, "pointer=", strscan_set_pos, 1);
+
+ rb_define_method(StringScanner, "scan", strscan_scan, 1);
+ rb_define_method(StringScanner, "skip", strscan_skip, 1);
+ rb_define_method(StringScanner, "match?", strscan_match_p, 1);
+ rb_define_method(StringScanner, "check", strscan_check, 1);
+ rb_define_method(StringScanner, "scan_full", strscan_scan_full, 3);
+
+ rb_define_method(StringScanner, "scan_until", strscan_scan_until, 1);
+ rb_define_method(StringScanner, "skip_until", strscan_skip_until, 1);
+ rb_define_method(StringScanner, "exist?", strscan_exist_p, 1);
+ rb_define_method(StringScanner, "check_until", strscan_check_until, 1);
+ rb_define_method(StringScanner, "search_full", strscan_search_full, 3);
+
+ rb_define_method(StringScanner, "getch", strscan_getch, 0);
+ rb_define_method(StringScanner, "get_byte", strscan_get_byte, 0);
+ rb_define_method(StringScanner, "getbyte", strscan_getbyte, 0);
+ rb_define_method(StringScanner, "peek", strscan_peek, 1);
+ rb_define_method(StringScanner, "peep", strscan_peep, 1);
+
+ rb_define_method(StringScanner, "unscan", strscan_unscan, 0);
+
+ rb_define_method(StringScanner, "beginning_of_line?", strscan_bol_p, 0);
+ rb_alias(StringScanner, rb_intern("bol?"), rb_intern("beginning_of_line?"));
+ rb_define_method(StringScanner, "eos?", strscan_eos_p, 0);
+ rb_define_method(StringScanner, "empty?", strscan_empty_p, 0);
+ rb_define_method(StringScanner, "rest?", strscan_rest_p, 0);
+
+ rb_define_method(StringScanner, "matched?", strscan_matched_p, 0);
+ rb_define_method(StringScanner, "matched", strscan_matched, 0);
+ rb_define_method(StringScanner, "matched_size", strscan_matched_size, 0);
+ rb_define_method(StringScanner, "[]", strscan_aref, 1);
+ rb_define_method(StringScanner, "pre_match", strscan_pre_match, 0);
+ rb_define_method(StringScanner, "post_match", strscan_post_match, 0);
+
+ rb_define_method(StringScanner, "rest", strscan_rest, 0);
+ rb_define_method(StringScanner, "rest_size", strscan_rest_size, 0);
+ rb_define_method(StringScanner, "restsize", strscan_restsize, 0);
+
+ rb_define_method(StringScanner, "inspect", strscan_inspect, 0);
+}
diff --git a/jni/ruby/ext/syslog/Makefile b/jni/ruby/ext/syslog/Makefile
new file mode 100644
index 0000000..6e37fb7
--- /dev/null
+++ b/jni/ruby/ext/syslog/Makefile
@@ -0,0 +1,292 @@
+
+SHELL = /bin/sh
+
+# V=0 quiet, V=1 verbose. other values don't work.
+V = 0
+Q1 = $(V:1=)
+Q = $(Q1:0=@)
+ECHO1 = $(V:1=@:)
+ECHO = $(ECHO1:0=@echo)
+NULLCMD = :
+
+#### Start of system configuration section. ####
+top_srcdir = $(topdir)/.
+srcdir = $(top_srcdir)/ext/syslog
+topdir = ../..
+hdrdir = $(top_srcdir)/include
+arch_hdrdir = $(extout)/include/$(arch)
+PATH_SEPARATOR = :
+VPATH = $(srcdir):$(arch_hdrdir)/ruby:$(hdrdir)/ruby
+RUBYLIB =
+RUBYOPT = -
+prefix = $(DESTDIR)/usr/local
+rubysitearchprefix = $(rubylibprefix)/$(sitearch)
+rubyarchprefix = $(rubylibprefix)/$(arch)
+rubylibprefix = $(libdir)/$(RUBY_BASE_NAME)
+exec_prefix = $(prefix)
+vendorarchhdrdir = $(vendorhdrdir)/$(sitearch)
+sitearchhdrdir = $(sitehdrdir)/$(sitearch)
+rubyarchhdrdir = $(rubyhdrdir)/$(arch)
+vendorhdrdir = $(rubyhdrdir)/vendor_ruby
+sitehdrdir = $(rubyhdrdir)/site_ruby
+rubyhdrdir = $(includedir)/$(RUBY_VERSION_NAME)
+vendorarchdir = $(vendorlibdir)/$(sitearch)
+vendorlibdir = $(vendordir)/$(ruby_version)
+vendordir = $(rubylibprefix)/vendor_ruby
+sitearchdir = $(sitelibdir)/$(sitearch)
+sitelibdir = $(sitedir)/$(ruby_version)
+sitedir = $(rubylibprefix)/site_ruby
+rubyarchdir = $(rubylibdir)/$(arch)
+rubylibdir = $(rubylibprefix)/$(ruby_version)
+sitearchincludedir = $(includedir)/$(sitearch)
+archincludedir = $(includedir)/$(arch)
+sitearchlibdir = $(libdir)/$(sitearch)
+archlibdir = $(libdir)/$(arch)
+ridir = $(datarootdir)/$(RI_BASE_NAME)
+mandir = $(datarootdir)/man
+localedir = $(datarootdir)/locale
+libdir = $(exec_prefix)/lib
+psdir = $(docdir)
+pdfdir = $(docdir)
+dvidir = $(docdir)
+htmldir = $(docdir)
+infodir = $(datarootdir)/info
+docdir = $(datarootdir)/doc/$(PACKAGE)
+oldincludedir = $(DESTDIR)/usr/include
+includedir = $(prefix)/include
+localstatedir = $(prefix)/var
+sharedstatedir = $(prefix)/com
+sysconfdir = $(prefix)/etc
+datadir = $(datarootdir)
+datarootdir = $(prefix)/share
+libexecdir = $(exec_prefix)/libexec
+sbindir = $(exec_prefix)/sbin
+bindir = $(exec_prefix)/bin
+archdir = $(rubyarchdir)
+
+
+CC = gcc
+CXX = g++
+LIBRUBY = $(LIBRUBY_SO)
+LIBRUBY_A = lib$(RUBY_SO_NAME)-static.a
+LIBRUBYARG_SHARED = -Wl,-R$(libdir) -L$(libdir) -l$(RUBY_SO_NAME)
+LIBRUBYARG_STATIC = -Wl,-R$(libdir) -L$(libdir) -l$(RUBY_SO_NAME)-static
+empty =
+OUTFLAG = -o $(empty)
+COUTFLAG = -o $(empty)
+
+RUBY_EXTCONF_H = extconf.h
+cflags = $(optflags) $(debugflags) $(warnflags)
+optflags = -O3 -fno-fast-math
+debugflags = -ggdb3
+warnflags = -Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wunused-variable -Wpointer-arith -Wwrite-strings -Wdeclaration-after-statement -Wimplicit-function-declaration -Wdeprecated-declarations -Wno-packed-bitfield-compat
+CCDLFLAGS = -fPIC
+CFLAGS = $(CCDLFLAGS) $(cflags) -fPIC $(ARCH_FLAG)
+INCFLAGS = -I. -I$(arch_hdrdir) -I$(hdrdir) -I$(srcdir)
+DEFS =
+CPPFLAGS = -DRUBY_EXTCONF_H=\"$(RUBY_EXTCONF_H)\" $(DEFS) $(cppflags)
+CXXFLAGS = $(CCDLFLAGS) $(cxxflags) $(ARCH_FLAG)
+ldflags = -L. -fstack-protector -rdynamic -Wl,-export-dynamic
+dldflags =
+ARCH_FLAG =
+DLDFLAGS = $(ldflags) $(dldflags) $(ARCH_FLAG)
+LDSHARED = $(CC) -shared
+LDSHAREDXX = $(CXX) -shared
+AR = ar
+EXEEXT =
+
+RUBY_INSTALL_NAME = $(RUBY_BASE_NAME)
+RUBY_SO_NAME = ruby
+RUBYW_INSTALL_NAME =
+RUBY_VERSION_NAME = $(RUBY_BASE_NAME)-$(ruby_version)
+RUBYW_BASE_NAME = rubyw
+RUBY_BASE_NAME = ruby
+
+arch = x86_64-linux
+sitearch = $(arch)
+ruby_version = 2.2.0
+ruby = $(topdir)/miniruby -I'$(topdir)' -I'$(top_srcdir)/lib' -I'$(extout)/$(arch)' -I'$(extout)/common'
+RUBY = $(ruby)
+ruby_headers = $(hdrdir)/ruby.h $(hdrdir)/ruby/ruby.h $(hdrdir)/ruby/defines.h $(hdrdir)/ruby/missing.h $(hdrdir)/ruby/intern.h $(hdrdir)/ruby/st.h $(hdrdir)/ruby/subst.h $(arch_hdrdir)/ruby/config.h $(RUBY_EXTCONF_H)
+
+RM = rm -f
+RM_RF = $(RUBY) -run -e rm -- -rf
+RMDIRS = rmdir --ignore-fail-on-non-empty -p
+MAKEDIRS = /bin/mkdir -p
+INSTALL = /usr/bin/install -c
+INSTALL_PROG = $(INSTALL) -m 0755
+INSTALL_DATA = $(INSTALL) -m 644
+COPY = cp
+TOUCH = exit >
+
+#### End of system configuration section. ####
+
+preload =
+
+libpath = . $(topdir)
+LIBPATH = -L. -L$(topdir)
+DEFFILE =
+
+CLEANFILES = mkmf.log
+DISTCLEANFILES =
+DISTCLEANDIRS =
+
+extout = $(topdir)/.ext
+extout_prefix = $(extout)$(target_prefix)/
+target_prefix =
+LOCAL_LIBS =
+LIBS = $(LIBRUBYARG_SHARED) -lpthread -lgmp -ldl -lcrypt -lm -lc
+ORIG_SRCS = syslog.c
+SRCS = $(ORIG_SRCS)
+OBJS = syslog.o
+HDRS = $(srcdir)/extconf.h
+TARGET = syslog
+TARGET_NAME = syslog
+TARGET_ENTRY = Init_$(TARGET_NAME)
+DLLIB = $(TARGET).so
+EXTSTATIC =
+STATIC_LIB = $(TARGET).a
+
+TIMESTAMP_DIR = $(extout)/.timestamp
+BINDIR = $(extout)/bin
+RUBYCOMMONDIR = $(extout)/common
+RUBYLIBDIR = $(RUBYCOMMONDIR)$(target_prefix)
+RUBYARCHDIR = $(extout)/$(arch)$(target_prefix)
+HDRDIR = $(extout)/include/ruby$(target_prefix)
+ARCHHDRDIR = $(extout)/include/$(arch)/ruby$(target_prefix)
+
+TARGET_SO = $(RUBYARCHDIR)/$(DLLIB)
+CLEANLIBS = $(RUBYARCHDIR)/$(TARGET).so
+CLEANOBJS = *.o *.bak
+
+all: install
+static: all
+.PHONY: all install static install-so install-rb
+.PHONY: clean clean-so clean-static clean-rb
+
+clean-static::
+clean-rb-default::
+clean-rb::
+clean-so::
+clean: clean-so clean-static clean-rb-default clean-rb
+ -$(Q)$(RM) $(CLEANLIBS) $(CLEANOBJS) $(CLEANFILES) .*.time
+
+distclean-rb-default::
+distclean-rb::
+distclean-so::
+distclean-static::
+distclean: clean distclean-so distclean-static distclean-rb-default distclean-rb
+ -$(Q)$(RM) Makefile $(RUBY_EXTCONF_H) conftest.* mkmf.log
+ -$(Q)$(RM) core ruby$(EXEEXT) *~ $(DISTCLEANFILES)
+ -$(Q)$(RMDIRS) $(DISTCLEANDIRS) 2> /dev/null || true
+
+realclean: distclean
+install: install-so install-rb
+
+install-so: $(RUBYARCHDIR)/$(DLLIB)
+clean-so::
+ -$(Q)$(RM) $(RUBYARCHDIR)/$(DLLIB)
+ -$(Q)$(RMDIRS) $(RUBYARCHDIR) 2> /dev/null || true
+clean-static::
+ -$(Q)$(RM) $(STATIC_LIB)
+install-rb: pre-install-rb install-rb-default
+install-rb-default: pre-install-rb-default
+pre-install-rb: Makefile
+pre-install-rb-default: Makefile
+pre-install-rb-default: $(TIMESTAMP_DIR)/.RUBYLIBDIR.-.syslog.time
+install-rb-default: $(RUBYLIBDIR)/syslog/logger.rb
+$(RUBYLIBDIR)/syslog/logger.rb: $(srcdir)/lib/syslog/logger.rb $(TIMESTAMP_DIR)/.RUBYLIBDIR.-.syslog.time
+ $(Q) $(COPY) $(srcdir)/lib/syslog/logger.rb $(@D)
+clean-rb-default::
+ -$(Q)$(RM) $(RUBYLIBDIR)/syslog/logger.rb
+pre-install-rb-default:
+ $(ECHO) installing default syslog libraries
+clean-rb-default::
+ -$(Q)$(RMDIRS) $(RUBYLIBDIR)/syslog 2> /dev/null || true
+$(TIMESTAMP_DIR)/.RUBYARCHDIR.time:
+ $(Q) $(MAKEDIRS) $(@D) $(RUBYARCHDIR)
+ $(Q) $(TOUCH) $@
+$(TIMESTAMP_DIR)/.RUBYLIBDIR.-.syslog.time:
+ $(Q) $(MAKEDIRS) $(@D) $(RUBYLIBDIR)/syslog
+ $(Q) $(TOUCH) $@
+
+site-install: site-install-so site-install-rb
+site-install-so: install-so
+site-install-rb: install-rb
+
+.SUFFIXES: .c .m .cc .mm .cxx .cpp .o .S
+
+.cc.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<
+
+.cc.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -S $<
+
+.mm.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<
+
+.mm.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -S $<
+
+.cxx.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<
+
+.cxx.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -S $<
+
+.cpp.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<
+
+.cpp.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -S $<
+
+.c.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -c $<
+
+.c.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -S $<
+
+.m.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -c $<
+
+.m.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -S $<
+
+$(RUBYARCHDIR)/$(DLLIB): $(OBJS) Makefile $(TIMESTAMP_DIR)/.RUBYARCHDIR.time
+ $(ECHO) linking shared-object $(DLLIB)
+ -$(Q)$(RM) $(@)
+ $(Q) $(LDSHARED) -o $@ $(OBJS) $(LIBPATH) $(DLDFLAGS) $(LOCAL_LIBS) $(LIBS)
+
+$(STATIC_LIB): $(OBJS)
+ -$(Q)$(RM) $(@)
+ $(ECHO) linking static-library $(@)
+ $(Q) $(AR) cru $@ $(OBJS)
+ -$(Q)ranlib $(@) 2> /dev/null || true
+
+###
+$(OBJS): $(RUBY_EXTCONF_H)
+
+# AUTOGENERATED DEPENDENCIES START
+syslog.o: $(RUBY_EXTCONF_H)
+syslog.o: $(arch_hdrdir)/ruby/config.h
+syslog.o: $(hdrdir)/ruby/defines.h
+syslog.o: $(hdrdir)/ruby/intern.h
+syslog.o: $(hdrdir)/ruby/missing.h
+syslog.o: $(hdrdir)/ruby/ruby.h
+syslog.o: $(hdrdir)/ruby/st.h
+syslog.o: $(hdrdir)/ruby/subst.h
+syslog.o: $(hdrdir)/ruby/util.h
+syslog.o: syslog.c
+# AUTOGENERATED DEPENDENCIES END
diff --git a/jni/ruby/ext/syslog/depend b/jni/ruby/ext/syslog/depend
new file mode 100644
index 0000000..d818fd8
--- /dev/null
+++ b/jni/ruby/ext/syslog/depend
@@ -0,0 +1,12 @@
+# AUTOGENERATED DEPENDENCIES START
+syslog.o: $(RUBY_EXTCONF_H)
+syslog.o: $(arch_hdrdir)/ruby/config.h
+syslog.o: $(hdrdir)/ruby/defines.h
+syslog.o: $(hdrdir)/ruby/intern.h
+syslog.o: $(hdrdir)/ruby/missing.h
+syslog.o: $(hdrdir)/ruby/ruby.h
+syslog.o: $(hdrdir)/ruby/st.h
+syslog.o: $(hdrdir)/ruby/subst.h
+syslog.o: $(hdrdir)/ruby/util.h
+syslog.o: syslog.c
+# AUTOGENERATED DEPENDENCIES END
diff --git a/jni/ruby/ext/syslog/extconf.h b/jni/ruby/ext/syslog/extconf.h
new file mode 100644
index 0000000..1a962c0
--- /dev/null
+++ b/jni/ruby/ext/syslog/extconf.h
@@ -0,0 +1,6 @@
+#ifndef EXTCONF_H
+#define EXTCONF_H
+#define HAVE_SYSLOG_H 1
+#define HAVE_OPENLOG 1
+#define HAVE_SETLOGMASK 1
+#endif
diff --git a/jni/ruby/ext/syslog/extconf.rb b/jni/ruby/ext/syslog/extconf.rb
new file mode 100644
index 0000000..d1f68af
--- /dev/null
+++ b/jni/ruby/ext/syslog/extconf.rb
@@ -0,0 +1,10 @@
+# $RoughId: extconf.rb,v 1.3 2001/11/24 17:49:26 knu Exp $
+# $Id: extconf.rb 25189 2009-10-02 12:04:37Z akr $
+
+require 'mkmf'
+
+have_header("syslog.h") &&
+ have_func("openlog") &&
+ have_func("setlogmask") &&
+ create_makefile("syslog")
+
diff --git a/jni/ruby/ext/syslog/lib/syslog/logger.rb b/jni/ruby/ext/syslog/lib/syslog/logger.rb
new file mode 100644
index 0000000..7040e19
--- /dev/null
+++ b/jni/ruby/ext/syslog/lib/syslog/logger.rb
@@ -0,0 +1,208 @@
+require 'syslog'
+require 'logger'
+
+##
+# Syslog::Logger is a Logger work-alike that logs via syslog instead of to a
+# file. You can use Syslog::Logger to aggregate logs between multiple
+# machines.
+#
+# By default, Syslog::Logger uses the program name 'ruby', but this can be
+# changed via the first argument to Syslog::Logger.new.
+#
+# NOTE! You can only set the Syslog::Logger program name when you initialize
+# Syslog::Logger for the first time. This is a limitation of the way
+# Syslog::Logger uses syslog (and in some ways, a limitation of the way
+# syslog(3) works). Attempts to change Syslog::Logger's program name after
+# the first initialization will be ignored.
+#
+# === Example
+#
+# The following will log to syslogd on your local machine:
+#
+# require 'syslog/logger'
+#
+# log = Syslog::Logger.new 'my_program'
+# log.info 'this line will be logged via syslog(3)'
+#
+# Also the facility may be set to specify the facility level which will be used:
+#
+# log.info 'this line will be logged using Syslog default facility level'
+#
+# log_local1 = Syslog::Logger.new 'my_program', Syslog::LOG_LOCAL1
+# log_local1.info 'this line will be logged using local1 facility level'
+#
+#
+# You may need to perform some syslog.conf setup first. For a BSD machine add
+# the following lines to /etc/syslog.conf:
+#
+# !my_program
+# *.* /var/log/my_program.log
+#
+# Then touch /var/log/my_program.log and signal syslogd with a HUP
+# (killall -HUP syslogd, on FreeBSD).
+#
+# If you wish to have logs automatically roll over and archive, see the
+# newsyslog.conf(5) and newsyslog(8) man pages.
+
+class Syslog::Logger
+ # Default formatter for log messages.
+ class Formatter
+ def call severity, time, progname, msg
+ clean msg
+ end
+
+ private
+
+ ##
+ # Clean up messages so they're nice and pretty.
+
+ def clean message
+ message = message.to_s.strip
+ message.gsub!(/\e\[[0-9;]*m/, '') # remove useless ansi color codes
+ return message
+ end
+ end
+
+ ##
+ # The version of Syslog::Logger you are using.
+
+ VERSION = '2.1.0'
+
+ ##
+ # Maps Logger warning types to syslog(3) warning types.
+ #
+ # Messages from Ruby applications are not considered as critical as messages
+ # from other system daemons using syslog(3), so most messages are reduced by
+ # one level. For example, a fatal message for Ruby's Logger is considered
+ # an error for syslog(3).
+
+ LEVEL_MAP = {
+ ::Logger::UNKNOWN => Syslog::LOG_ALERT,
+ ::Logger::FATAL => Syslog::LOG_ERR,
+ ::Logger::ERROR => Syslog::LOG_WARNING,
+ ::Logger::WARN => Syslog::LOG_NOTICE,
+ ::Logger::INFO => Syslog::LOG_INFO,
+ ::Logger::DEBUG => Syslog::LOG_DEBUG,
+ }
+
+ ##
+ # Returns the internal Syslog object that is initialized when the
+ # first instance is created.
+
+ def self.syslog
+ @@syslog
+ end
+
+ ##
+ # Specifies the internal Syslog object to be used.
+
+ def self.syslog= syslog
+ @@syslog = syslog
+ end
+
+ ##
+ # Builds a methods for level +meth+.
+
+ def self.make_methods meth
+ level = ::Logger.const_get(meth.upcase)
+ eval <<-EOM, nil, __FILE__, __LINE__ + 1
+ def #{meth}(message = nil, &block)
+ add(#{level}, message, &block)
+ end
+
+ def #{meth}?
+ @level <= #{level}
+ end
+ EOM
+ end
+
+ ##
+ # :method: unknown
+ #
+ # Logs a +message+ at the unknown (syslog alert) log level, or logs the
+ # message returned from the block.
+
+ ##
+ # :method: fatal
+ #
+ # Logs a +message+ at the fatal (syslog err) log level, or logs the message
+ # returned from the block.
+
+ ##
+ # :method: error
+ #
+ # Logs a +message+ at the error (syslog warning) log level, or logs the
+ # message returned from the block.
+
+ ##
+ # :method: warn
+ #
+ # Logs a +message+ at the warn (syslog notice) log level, or logs the
+ # message returned from the block.
+
+ ##
+ # :method: info
+ #
+ # Logs a +message+ at the info (syslog info) log level, or logs the message
+ # returned from the block.
+
+ ##
+ # :method: debug
+ #
+ # Logs a +message+ at the debug (syslog debug) log level, or logs the
+ # message returned from the block.
+
+ Logger::Severity::constants.each do |severity|
+ make_methods severity.downcase
+ end
+
+ ##
+ # Log level for Logger compatibility.
+
+ attr_accessor :level
+
+ # Logging formatter, as a +Proc+ that will take four arguments and
+ # return the formatted message. The arguments are:
+ #
+ # +severity+:: The Severity of the log message.
+ # +time+:: A Time instance representing when the message was logged.
+ # +progname+:: The #progname configured, or passed to the logger method.
+ # +msg+:: The _Object_ the user passed to the log message; not necessarily a
+ # String.
+ #
+ # The block should return an Object that can be written to the logging
+ # device via +write+. The default formatter is used when no formatter is
+ # set.
+ attr_accessor :formatter
+
+ ##
+ # The facility argument is used to specify what type of program is logging the message.
+
+ attr_accessor :facility
+
+ ##
+ # Fills in variables for Logger compatibility. If this is the first
+ # instance of Syslog::Logger, +program_name+ may be set to change the logged
+ # program name. The +facility+ may be set to specify the facility level which will be used.
+ #
+ # Due to the way syslog works, only one program name may be chosen.
+
+ def initialize program_name = 'ruby', facility = nil
+ @level = ::Logger::DEBUG
+ @formatter = Formatter.new
+
+ @@syslog ||= Syslog.open(program_name)
+
+ @facility = (facility || @@syslog.facility)
+ end
+
+ ##
+ # Almost duplicates Logger#add. +progname+ is ignored.
+
+ def add severity, message = nil, progname = nil, &block
+ severity ||= ::Logger::UNKNOWN
+ @level <= severity and
+ @@syslog.log( (LEVEL_MAP[severity] | @facility), '%s', formatter.call(severity, Time.now, progname, (message || block.call)) )
+ true
+ end
+end
diff --git a/jni/ruby/ext/syslog/syslog.c b/jni/ruby/ext/syslog/syslog.c
new file mode 100644
index 0000000..4e4e281
--- /dev/null
+++ b/jni/ruby/ext/syslog/syslog.c
@@ -0,0 +1,592 @@
+/*
+ * UNIX Syslog extension for Ruby
+ * Amos Gouaux, University of Texas at Dallas
+ * <amos+ruby@utdallas.edu>
+ * Documented by mathew <meta@pobox.com>
+ *
+ * $RoughId: syslog.c,v 1.21 2002/02/25 12:21:17 knu Exp $
+ * $Id: syslog.c 47792 2014-10-04 23:09:32Z nobu $
+ */
+
+#include "ruby/ruby.h"
+#include "ruby/util.h"
+#include <syslog.h>
+
+/* Syslog class */
+static VALUE mSyslog;
+/*
+ * Module holding all Syslog constants. See Syslog::log and
+ * Syslog::open for constant descriptions.
+ */
+static VALUE mSyslogConstants;
+/* Module holding Syslog option constants */
+static VALUE mSyslogOption;
+/* Module holding Syslog facility constants */
+static VALUE mSyslogFacility;
+/* Module holding Syslog level constants */
+static VALUE mSyslogLevel;
+/* Module holding Syslog utility macros */
+static VALUE mSyslogMacros;
+
+static const char *syslog_ident = NULL;
+static int syslog_options = -1, syslog_facility = -1, syslog_mask = -1;
+static int syslog_opened = 0;
+
+/* Package helper routines */
+static void syslog_write(int pri, int argc, VALUE *argv)
+{
+ VALUE str;
+
+ if (argc < 1) {
+ rb_raise(rb_eArgError, "no log message supplied");
+ }
+
+ if (!syslog_opened) {
+ rb_raise(rb_eRuntimeError, "must open syslog before write");
+ }
+
+ str = rb_f_sprintf(argc, argv);
+
+ syslog(pri, "%s", RSTRING_PTR(str));
+}
+
+/* Closes the syslog facility.
+ * Raises a runtime exception if it is not open.
+ */
+static VALUE mSyslog_close(VALUE self)
+{
+ if (!syslog_opened) {
+ rb_raise(rb_eRuntimeError, "syslog not opened");
+ }
+
+ closelog();
+
+ xfree((void *)syslog_ident);
+ syslog_ident = NULL;
+ syslog_options = syslog_facility = syslog_mask = -1;
+ syslog_opened = 0;
+
+ return Qnil;
+}
+
+/* call-seq:
+ * open(ident, options, facility) => syslog
+ *
+ * :yields: syslog
+ *
+ * Open the syslog facility.
+ * Raises a runtime exception if it is already open.
+ *
+ * Can be called with or without a code block. If called with a block, the
+ * Syslog object created is passed to the block.
+ *
+ * If the syslog is already open, raises a RuntimeError.
+ *
+ * +ident+ is a String which identifies the calling program.
+ *
+ * +options+ is the logical OR of any of the following:
+ *
+ * LOG_CONS:: If there is an error while sending to the system logger,
+ * write directly to the console instead.
+ *
+ * LOG_NDELAY:: Open the connection now, rather than waiting for the first
+ * message to be written.
+ *
+ * LOG_NOWAIT:: Don't wait for any child processes created while logging
+ * messages. (Has no effect on Linux.)
+ *
+ * LOG_ODELAY:: Opposite of LOG_NDELAY; wait until a message is sent before
+ * opening the connection. (This is the default.)
+ *
+ * LOG_PERROR:: Print the message to stderr as well as sending it to syslog.
+ * (Not in POSIX.1-2001.)
+ *
+ * LOG_PID:: Include the current process ID with each message.
+ *
+ * +facility+ describes the type of program opening the syslog, and is
+ * the logical OR of any of the following which are defined for the host OS:
+ *
+ * LOG_AUTH:: Security or authorization. Deprecated, use LOG_AUTHPRIV
+ * instead.
+ *
+ * LOG_AUTHPRIV:: Security or authorization messages which should be kept
+ * private.
+ *
+ * LOG_CONSOLE:: System console message.
+ *
+ * LOG_CRON:: System task scheduler (cron or at).
+ *
+ * LOG_DAEMON:: A system daemon which has no facility value of its own.
+ *
+ * LOG_FTP:: An FTP server.
+ *
+ * LOG_KERN:: A kernel message (not sendable by user processes, so not of
+ * much use to Ruby, but listed here for completeness).
+ *
+ * LOG_LPR:: Line printer subsystem.
+ *
+ * LOG_MAIL:: Mail delivery or transport subsystem.
+ *
+ * LOG_NEWS:: Usenet news system.
+ *
+ * LOG_NTP:: Network Time Protocol server.
+ *
+ * LOG_SECURITY:: General security message.
+ *
+ * LOG_SYSLOG:: Messages generated internally by syslog.
+ *
+ * LOG_USER:: Generic user-level message.
+ *
+ * LOG_UUCP:: UUCP subsystem.
+ *
+ * LOG_LOCAL0 to LOG_LOCAL7:: Locally-defined facilities.
+ *
+ * Example:
+ *
+ * Syslog.open("webrick", Syslog::LOG_PID,
+ * Syslog::LOG_DAEMON | Syslog::LOG_LOCAL3)
+ *
+ */
+static VALUE mSyslog_open(int argc, VALUE *argv, VALUE self)
+{
+ VALUE ident, opt, fac;
+
+ if (syslog_opened) {
+ rb_raise(rb_eRuntimeError, "syslog already open");
+ }
+
+ rb_scan_args(argc, argv, "03", &ident, &opt, &fac);
+
+ if (NIL_P(ident)) {
+ ident = rb_gv_get("$0");
+ }
+ SafeStringValue(ident);
+ syslog_ident = strdup(RSTRING_PTR(ident));
+
+ if (NIL_P(opt)) {
+ syslog_options = LOG_PID | LOG_CONS;
+ } else {
+ syslog_options = NUM2INT(opt);
+ }
+
+ if (NIL_P(fac)) {
+ syslog_facility = LOG_USER;
+ } else {
+ syslog_facility = NUM2INT(fac);
+ }
+
+ openlog(syslog_ident, syslog_options, syslog_facility);
+
+ syslog_opened = 1;
+
+ setlogmask(syslog_mask = setlogmask(0));
+
+ /* be like File.new.open {...} */
+ if (rb_block_given_p()) {
+ rb_ensure(rb_yield, self, mSyslog_close, self);
+ }
+
+ return self;
+}
+
+/* call-seq:
+ * reopen(ident, options, facility) => syslog
+ *
+ * :yields: syslog
+ *
+ * Closes and then reopens the syslog.
+ *
+ * Arguments are the same as for open().
+ */
+static VALUE mSyslog_reopen(int argc, VALUE *argv, VALUE self)
+{
+ mSyslog_close(self);
+
+ return mSyslog_open(argc, argv, self);
+}
+
+/* call-seq:
+ * opened?
+ *
+ * Returns true if the syslog is open.
+ */
+static VALUE mSyslog_isopen(VALUE self)
+{
+ return syslog_opened ? Qtrue : Qfalse;
+}
+
+/* Returns the identity string used in the last call to open()
+ */
+static VALUE mSyslog_ident(VALUE self)
+{
+ return syslog_opened ? rb_str_new2(syslog_ident) : Qnil;
+}
+
+/* Returns the options bitmask used in the last call to open()
+ */
+static VALUE mSyslog_options(VALUE self)
+{
+ return syslog_opened ? INT2NUM(syslog_options) : Qnil;
+}
+
+/* Returns the facility number used in the last call to open()
+ */
+static VALUE mSyslog_facility(VALUE self)
+{
+ return syslog_opened ? INT2NUM(syslog_facility) : Qnil;
+}
+
+/* Returns the log priority mask in effect. The mask is not reset by opening
+ * or closing syslog.
+ */
+static VALUE mSyslog_get_mask(VALUE self)
+{
+ return syslog_opened ? INT2NUM(syslog_mask) : Qnil;
+}
+
+/* call-seq:
+ * mask=(priority_mask)
+ *
+ * Sets the log priority mask. A method LOG_UPTO is defined to make it easier
+ * to set mask values. Example:
+ *
+ * Syslog.mask = Syslog::LOG_UPTO(Syslog::LOG_ERR)
+ *
+ * Alternatively, specific priorities can be selected and added together using
+ * binary OR. Example:
+ *
+ * Syslog.mask = Syslog::LOG_MASK(Syslog::LOG_ERR) | Syslog::LOG_MASK(Syslog::LOG_CRIT)
+ *
+ * The priority mask persists through calls to open() and close().
+ */
+static VALUE mSyslog_set_mask(VALUE self, VALUE mask)
+{
+ if (!syslog_opened) {
+ rb_raise(rb_eRuntimeError, "must open syslog before setting log mask");
+ }
+
+ setlogmask(syslog_mask = NUM2INT(mask));
+
+ return mask;
+}
+
+/* call-seq:
+ * log(priority, format_string, *format_args)
+ *
+ * Log a message with the specified priority. Example:
+ *
+ * Syslog.log(Syslog::LOG_CRIT, "Out of disk space")
+ * Syslog.log(Syslog::LOG_CRIT, "User %s logged in", ENV['USER'])
+ *
+ * The priority levels, in descending order, are:
+ *
+ * LOG_EMERG:: System is unusable
+ * LOG_ALERT:: Action needs to be taken immediately
+ * LOG_CRIT:: A critical condition has occurred
+ * LOG_ERR:: An error occurred
+ * LOG_WARNING:: Warning of a possible problem
+ * LOG_NOTICE:: A normal but significant condition occurred
+ * LOG_INFO:: Informational message
+ * LOG_DEBUG:: Debugging information
+ *
+ * Each priority level also has a shortcut method that logs with it's named priority.
+ * As an example, the two following statements would produce the same result:
+ *
+ * Syslog.log(Syslog::LOG_ALERT, "Out of memory")
+ * Syslog.alert("Out of memory")
+ *
+ * Format strings are as for printf/sprintf, except that in addition %m is
+ * replaced with the error message string that would be returned by
+ * strerror(errno).
+ *
+ */
+static VALUE mSyslog_log(int argc, VALUE *argv, VALUE self)
+{
+ VALUE pri;
+
+ if (argc < 2) {
+ rb_raise(rb_eArgError, "wrong number of arguments (%d for 2+)", argc);
+ }
+
+ argc--;
+ pri = *argv++;
+
+ if (!FIXNUM_P(pri)) {
+ rb_raise(rb_eTypeError, "type mismatch: %"PRIsVALUE" given", rb_obj_class(pri));
+ }
+
+ syslog_write(FIX2INT(pri), argc, argv);
+
+ return self;
+}
+
+/* Returns an inspect() string summarizing the object state.
+ */
+static VALUE mSyslog_inspect(VALUE self)
+{
+ Check_Type(self, T_MODULE);
+
+ if (!syslog_opened)
+ return rb_sprintf("<#%"PRIsVALUE": opened=false>", self);
+
+ return rb_sprintf("<#%"PRIsVALUE": opened=true, ident=\"%s\", options=%d, facility=%d, mask=%d>",
+ self,
+ syslog_ident,
+ syslog_options,
+ syslog_facility,
+ syslog_mask);
+}
+
+/* Returns self, for backward compatibility.
+ */
+static VALUE mSyslog_instance(VALUE self)
+{
+ return self;
+}
+
+#define define_syslog_shortcut_method(pri, name) \
+static VALUE mSyslog_##name(int argc, VALUE *argv, VALUE self) \
+{ \
+ syslog_write((pri), argc, argv); \
+\
+ return self; \
+}
+
+#ifdef LOG_EMERG
+define_syslog_shortcut_method(LOG_EMERG, emerg)
+#endif
+#ifdef LOG_ALERT
+define_syslog_shortcut_method(LOG_ALERT, alert)
+#endif
+#ifdef LOG_CRIT
+define_syslog_shortcut_method(LOG_CRIT, crit)
+#endif
+#ifdef LOG_ERR
+define_syslog_shortcut_method(LOG_ERR, err)
+#endif
+#ifdef LOG_WARNING
+define_syslog_shortcut_method(LOG_WARNING, warning)
+#endif
+#ifdef LOG_NOTICE
+define_syslog_shortcut_method(LOG_NOTICE, notice)
+#endif
+#ifdef LOG_INFO
+define_syslog_shortcut_method(LOG_INFO, info)
+#endif
+#ifdef LOG_DEBUG
+define_syslog_shortcut_method(LOG_DEBUG, debug)
+#endif
+
+/* call-seq:
+ * LOG_MASK(priority_level) => priority_mask
+ *
+ * Generates a mask bit for a priority level. See #mask=
+ */
+static VALUE mSyslogMacros_LOG_MASK(VALUE mod, VALUE pri)
+{
+ return INT2FIX(LOG_MASK(NUM2INT(pri)));
+}
+
+/* call-seq:
+ * LOG_UPTO(priority_level) => priority_mask
+ *
+ * Generates a mask value for priority levels at or below the level specified.
+ * See #mask=
+ */
+static VALUE mSyslogMacros_LOG_UPTO(VALUE mod, VALUE pri)
+{
+ return INT2FIX(LOG_UPTO(NUM2INT(pri)));
+}
+
+static VALUE mSyslogMacros_included(VALUE mod, VALUE target)
+{
+ rb_extend_object(target, mSyslogMacros);
+ return mod;
+}
+
+/* The syslog package provides a Ruby interface to the POSIX system logging
+ * facility.
+ *
+ * Syslog messages are typically passed to a central logging daemon.
+ * The daemon may filter them; route them into different files (usually
+ * found under /var/log); place them in SQL databases; forward
+ * them to centralized logging servers via TCP or UDP; or even alert the
+ * system administrator via email, pager or text message.
+ *
+ * Unlike application-level logging via Logger or Log4r, syslog is designed
+ * to allow secure tamper-proof logging.
+ *
+ * The syslog protocol is standardized in RFC 5424.
+ */
+void Init_syslog(void)
+{
+ mSyslog = rb_define_module("Syslog");
+
+ mSyslogConstants = rb_define_module_under(mSyslog, "Constants");
+
+ mSyslogOption = rb_define_module_under(mSyslog, "Option");
+ mSyslogFacility = rb_define_module_under(mSyslog, "Facility");
+ mSyslogLevel = rb_define_module_under(mSyslog, "Level");
+ mSyslogMacros = rb_define_module_under(mSyslog, "Macros");
+
+ rb_define_module_function(mSyslog, "open", mSyslog_open, -1);
+ rb_define_module_function(mSyslog, "reopen", mSyslog_reopen, -1);
+ rb_define_module_function(mSyslog, "open!", mSyslog_reopen, -1);
+ rb_define_module_function(mSyslog, "opened?", mSyslog_isopen, 0);
+
+ rb_define_module_function(mSyslog, "ident", mSyslog_ident, 0);
+ rb_define_module_function(mSyslog, "options", mSyslog_options, 0);
+ rb_define_module_function(mSyslog, "facility", mSyslog_facility, 0);
+
+ rb_define_module_function(mSyslog, "log", mSyslog_log, -1);
+ rb_define_module_function(mSyslog, "close", mSyslog_close, 0);
+ rb_define_module_function(mSyslog, "mask", mSyslog_get_mask, 0);
+ rb_define_module_function(mSyslog, "mask=", mSyslog_set_mask, 1);
+
+ rb_define_singleton_method(mSyslog, "inspect", mSyslog_inspect, 0);
+ rb_define_module_function(mSyslog, "instance", mSyslog_instance, 0);
+
+ /* Syslog options */
+
+#define rb_define_syslog_option(c) \
+ rb_define_const(mSyslogOption, #c, INT2NUM(c))
+
+#ifdef LOG_PID
+ rb_define_syslog_option(LOG_PID);
+#endif
+#ifdef LOG_CONS
+ rb_define_syslog_option(LOG_CONS);
+#endif
+#ifdef LOG_ODELAY
+ rb_define_syslog_option(LOG_ODELAY); /* deprecated */
+#endif
+#ifdef LOG_NDELAY
+ rb_define_syslog_option(LOG_NDELAY);
+#endif
+#ifdef LOG_NOWAIT
+ rb_define_syslog_option(LOG_NOWAIT); /* deprecated */
+#endif
+#ifdef LOG_PERROR
+ rb_define_syslog_option(LOG_PERROR);
+#endif
+
+ /* Syslog facilities */
+
+#define rb_define_syslog_facility(c) \
+ rb_define_const(mSyslogFacility, #c, INT2NUM(c))
+
+#ifdef LOG_AUTH
+ rb_define_syslog_facility(LOG_AUTH);
+#endif
+#ifdef LOG_AUTHPRIV
+ rb_define_syslog_facility(LOG_AUTHPRIV);
+#endif
+#ifdef LOG_CONSOLE
+ rb_define_syslog_facility(LOG_CONSOLE);
+#endif
+#ifdef LOG_CRON
+ rb_define_syslog_facility(LOG_CRON);
+#endif
+#ifdef LOG_DAEMON
+ rb_define_syslog_facility(LOG_DAEMON);
+#endif
+#ifdef LOG_FTP
+ rb_define_syslog_facility(LOG_FTP);
+#endif
+#ifdef LOG_KERN
+ rb_define_syslog_facility(LOG_KERN);
+#endif
+#ifdef LOG_LPR
+ rb_define_syslog_facility(LOG_LPR);
+#endif
+#ifdef LOG_MAIL
+ rb_define_syslog_facility(LOG_MAIL);
+#endif
+#ifdef LOG_NEWS
+ rb_define_syslog_facility(LOG_NEWS);
+#endif
+#ifdef LOG_NTP
+ rb_define_syslog_facility(LOG_NTP);
+#endif
+#ifdef LOG_SECURITY
+ rb_define_syslog_facility(LOG_SECURITY);
+#endif
+#ifdef LOG_SYSLOG
+ rb_define_syslog_facility(LOG_SYSLOG);
+#endif
+#ifdef LOG_USER
+ rb_define_syslog_facility(LOG_USER);
+#endif
+#ifdef LOG_UUCP
+ rb_define_syslog_facility(LOG_UUCP);
+#endif
+#ifdef LOG_LOCAL0
+ rb_define_syslog_facility(LOG_LOCAL0);
+#endif
+#ifdef LOG_LOCAL1
+ rb_define_syslog_facility(LOG_LOCAL1);
+#endif
+#ifdef LOG_LOCAL2
+ rb_define_syslog_facility(LOG_LOCAL2);
+#endif
+#ifdef LOG_LOCAL3
+ rb_define_syslog_facility(LOG_LOCAL3);
+#endif
+#ifdef LOG_LOCAL4
+ rb_define_syslog_facility(LOG_LOCAL4);
+#endif
+#ifdef LOG_LOCAL5
+ rb_define_syslog_facility(LOG_LOCAL5);
+#endif
+#ifdef LOG_LOCAL6
+ rb_define_syslog_facility(LOG_LOCAL6);
+#endif
+#ifdef LOG_LOCAL7
+ rb_define_syslog_facility(LOG_LOCAL7);
+#endif
+
+ /* Syslog levels and the shortcut methods */
+
+#define rb_define_syslog_level(c, m) \
+ rb_define_const(mSyslogLevel, #c, INT2NUM(c)); \
+ rb_define_module_function(mSyslog, #m, mSyslog_##m, -1)
+
+#ifdef LOG_EMERG
+ rb_define_syslog_level(LOG_EMERG, emerg);
+#endif
+#ifdef LOG_ALERT
+ rb_define_syslog_level(LOG_ALERT, alert);
+#endif
+#ifdef LOG_CRIT
+ rb_define_syslog_level(LOG_CRIT, crit);
+#endif
+#ifdef LOG_ERR
+ rb_define_syslog_level(LOG_ERR, err);
+#endif
+#ifdef LOG_WARNING
+ rb_define_syslog_level(LOG_WARNING, warning);
+#endif
+#ifdef LOG_NOTICE
+ rb_define_syslog_level(LOG_NOTICE, notice);
+#endif
+#ifdef LOG_INFO
+ rb_define_syslog_level(LOG_INFO, info);
+#endif
+#ifdef LOG_DEBUG
+ rb_define_syslog_level(LOG_DEBUG, debug);
+#endif
+
+ /* Syslog macros */
+
+ rb_define_method(mSyslogMacros, "LOG_MASK", mSyslogMacros_LOG_MASK, 1);
+ rb_define_method(mSyslogMacros, "LOG_UPTO", mSyslogMacros_LOG_UPTO, 1);
+ rb_define_singleton_method(mSyslogMacros, "included", mSyslogMacros_included, 1);
+
+ rb_include_module(mSyslogConstants, mSyslogOption);
+ rb_include_module(mSyslogConstants, mSyslogFacility);
+ rb_include_module(mSyslogConstants, mSyslogLevel);
+ rb_funcall(mSyslogConstants, rb_intern("include"), 1, mSyslogMacros);
+
+ rb_define_singleton_method(mSyslogConstants, "included", mSyslogMacros_included, 1);
+ rb_funcall(mSyslog, rb_intern("include"), 1, mSyslogConstants);
+}
diff --git a/jni/ruby/ext/syslog/syslog.txt b/jni/ruby/ext/syslog/syslog.txt
new file mode 100644
index 0000000..4286f29
--- /dev/null
+++ b/jni/ruby/ext/syslog/syslog.txt
@@ -0,0 +1,124 @@
+.\" syslog.txt - -*- Indented-Text -*-
+$RoughId: syslog.txt,v 1.18 2002/02/25 08:20:14 knu Exp $
+$Id: syslog.txt 31689 2011-05-22 09:26:02Z nobu $
+
+UNIX Syslog extension for Ruby
+Amos Gouaux, University of Texas at Dallas
+<amos+ruby@utdallas.edu>
+&
+Akinori MUSHA
+<knu@iDaemons.org>
+
+Contact:
+ - Akinori MUSHA <knu@iDaemons.org> (current maintainer)
+
+** Syslog(Module)
+
+Included Modules: Syslog::Constants
+
+require 'syslog'
+
+A Simple wrapper for the UNIX syslog system calls that might be handy
+if you're writing a server in Ruby. For the details of the syslog(8)
+architecture and constants, see the syslog(3) manual page of your
+platform.
+
+Module Methods:
+
+ open(ident = $0, logopt = Syslog::LOG_PID | Syslog::LOG_CONS,
+ facility = Syslog::LOG_USER) [{ |syslog| ... }]
+
+ Opens syslog with the given options and returns the module
+ itself. If a block is given, calls it with an argument of
+ itself. If syslog is already opened, raises RuntimeError.
+
+ Example:
+ Syslog.open('ftpd', Syslog::LOG_PID | Syslog::LOG_NDELAY,
+ Syslog::LOG_FTP)
+
+ open!(ident = $0, logopt = Syslog::LOG_PID | Syslog::LOG_CONS,
+ facility = Syslog::LOG_USER)
+ reopen(ident = $0, logopt = Syslog::LOG_PID | Syslog::LOG_CONS,
+ facility = Syslog::LOG_USER)
+
+ Same as open, but does a close first.
+
+ opened?
+
+ Returns true if syslog opened, otherwise false.
+
+ ident
+ options
+ facility
+
+ Returns the parameters given in the last open, respectively.
+ Every call of Syslog::open resets these values.
+
+ log(pri, message, ...)
+
+ Writes message to syslog.
+
+ Example:
+ Syslog.log(Syslog::LOG_CRIT, "the sky is falling in %d seconds!", 10)
+
+ crit(message, ...)
+ emerg(message, ...)
+ alert(message, ...)
+ err(message, ...)
+ warning(message, ...)
+ notice(message, ...)
+ info(message, ...)
+ debug(message, ...)
+
+ These are shortcut methods of Syslog::log(). The lineup may
+ vary depending on what priorities are defined on your system.
+
+ Example:
+ Syslog.crit("the sky is falling in %d seconds!", 5)
+
+ mask
+ mask=(mask)
+
+ Returns or sets the log priority mask. The value of the mask
+ is persistent and will not be reset by Syslog::open or
+ Syslog::close.
+
+ Example:
+ Syslog.mask = Syslog::LOG_UPTO(Syslog::LOG_ERR)
+
+ close
+
+ Closes syslog.
+
+ inspect
+
+ Returns the "inspect" string of the Syslog module.
+
+ instance
+
+ Returns the module itself. (Just for backward compatibility)
+
+ LOG_MASK(pri)
+
+ Creates a mask for one priority.
+
+ LOG_UPTO(pri)
+
+ Creates a mask for all priorities up to pri.
+
+** Syslog::Constants(Module)
+
+require 'syslog'
+include Syslog::Constants
+
+This module includes the LOG_* constants available on the system.
+
+Module Methods:
+
+ LOG_MASK(pri)
+
+ Creates a mask for one priority.
+
+ LOG_UPTO(pri)
+
+ Creates a mask for all priorities up to pri.
diff --git a/jni/ruby/ext/thread/Makefile b/jni/ruby/ext/thread/Makefile
new file mode 100644
index 0000000..735f513
--- /dev/null
+++ b/jni/ruby/ext/thread/Makefile
@@ -0,0 +1,267 @@
+
+SHELL = /bin/sh
+
+# V=0 quiet, V=1 verbose. other values don't work.
+V = 0
+Q1 = $(V:1=)
+Q = $(Q1:0=@)
+ECHO1 = $(V:1=@:)
+ECHO = $(ECHO1:0=@echo)
+NULLCMD = :
+
+#### Start of system configuration section. ####
+top_srcdir = $(topdir)/.
+srcdir = $(top_srcdir)/ext/thread
+topdir = ../..
+hdrdir = $(top_srcdir)/include
+arch_hdrdir = $(extout)/include/$(arch)
+PATH_SEPARATOR = :
+VPATH = $(srcdir):$(arch_hdrdir)/ruby:$(hdrdir)/ruby
+RUBYLIB =
+RUBYOPT = -
+prefix = $(DESTDIR)/usr/local
+rubysitearchprefix = $(rubylibprefix)/$(sitearch)
+rubyarchprefix = $(rubylibprefix)/$(arch)
+rubylibprefix = $(libdir)/$(RUBY_BASE_NAME)
+exec_prefix = $(prefix)
+vendorarchhdrdir = $(vendorhdrdir)/$(sitearch)
+sitearchhdrdir = $(sitehdrdir)/$(sitearch)
+rubyarchhdrdir = $(rubyhdrdir)/$(arch)
+vendorhdrdir = $(rubyhdrdir)/vendor_ruby
+sitehdrdir = $(rubyhdrdir)/site_ruby
+rubyhdrdir = $(includedir)/$(RUBY_VERSION_NAME)
+vendorarchdir = $(vendorlibdir)/$(sitearch)
+vendorlibdir = $(vendordir)/$(ruby_version)
+vendordir = $(rubylibprefix)/vendor_ruby
+sitearchdir = $(sitelibdir)/$(sitearch)
+sitelibdir = $(sitedir)/$(ruby_version)
+sitedir = $(rubylibprefix)/site_ruby
+rubyarchdir = $(rubylibdir)/$(arch)
+rubylibdir = $(rubylibprefix)/$(ruby_version)
+sitearchincludedir = $(includedir)/$(sitearch)
+archincludedir = $(includedir)/$(arch)
+sitearchlibdir = $(libdir)/$(sitearch)
+archlibdir = $(libdir)/$(arch)
+ridir = $(datarootdir)/$(RI_BASE_NAME)
+mandir = $(datarootdir)/man
+localedir = $(datarootdir)/locale
+libdir = $(exec_prefix)/lib
+psdir = $(docdir)
+pdfdir = $(docdir)
+dvidir = $(docdir)
+htmldir = $(docdir)
+infodir = $(datarootdir)/info
+docdir = $(datarootdir)/doc/$(PACKAGE)
+oldincludedir = $(DESTDIR)/usr/include
+includedir = $(prefix)/include
+localstatedir = $(prefix)/var
+sharedstatedir = $(prefix)/com
+sysconfdir = $(prefix)/etc
+datadir = $(datarootdir)
+datarootdir = $(prefix)/share
+libexecdir = $(exec_prefix)/libexec
+sbindir = $(exec_prefix)/sbin
+bindir = $(exec_prefix)/bin
+archdir = $(rubyarchdir)
+
+
+CC = gcc
+CXX = g++
+LIBRUBY = $(LIBRUBY_SO)
+LIBRUBY_A = lib$(RUBY_SO_NAME)-static.a
+LIBRUBYARG_SHARED = -Wl,-R$(libdir) -L$(libdir) -l$(RUBY_SO_NAME)
+LIBRUBYARG_STATIC = -Wl,-R$(libdir) -L$(libdir) -l$(RUBY_SO_NAME)-static
+empty =
+OUTFLAG = -o $(empty)
+COUTFLAG = -o $(empty)
+
+RUBY_EXTCONF_H = extconf.h
+cflags = $(optflags) $(debugflags) $(warnflags)
+optflags = -O3 -fno-fast-math
+debugflags = -ggdb3
+warnflags = -Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wunused-variable -Wpointer-arith -Wwrite-strings -Wdeclaration-after-statement -Wimplicit-function-declaration -Wdeprecated-declarations -Wno-packed-bitfield-compat
+CCDLFLAGS = -fPIC
+CFLAGS = $(CCDLFLAGS) $(cflags) -fPIC $(ARCH_FLAG)
+INCFLAGS = -I. -I$(arch_hdrdir) -I$(hdrdir) -I$(srcdir)
+DEFS =
+CPPFLAGS = -DRUBY_EXTCONF_H=\"$(RUBY_EXTCONF_H)\" $(DEFS) $(cppflags)
+CXXFLAGS = $(CCDLFLAGS) $(cxxflags) $(ARCH_FLAG)
+ldflags = -L. -fstack-protector -rdynamic -Wl,-export-dynamic
+dldflags =
+ARCH_FLAG =
+DLDFLAGS = $(ldflags) $(dldflags) $(ARCH_FLAG)
+LDSHARED = $(CC) -shared
+LDSHAREDXX = $(CXX) -shared
+AR = ar
+EXEEXT =
+
+RUBY_INSTALL_NAME = $(RUBY_BASE_NAME)
+RUBY_SO_NAME = ruby
+RUBYW_INSTALL_NAME =
+RUBY_VERSION_NAME = $(RUBY_BASE_NAME)-$(ruby_version)
+RUBYW_BASE_NAME = rubyw
+RUBY_BASE_NAME = ruby
+
+arch = x86_64-linux
+sitearch = $(arch)
+ruby_version = 2.2.0
+ruby = $(topdir)/miniruby -I'$(topdir)' -I'$(top_srcdir)/lib' -I'$(extout)/$(arch)' -I'$(extout)/common'
+RUBY = $(ruby)
+ruby_headers = $(hdrdir)/ruby.h $(hdrdir)/ruby/ruby.h $(hdrdir)/ruby/defines.h $(hdrdir)/ruby/missing.h $(hdrdir)/ruby/intern.h $(hdrdir)/ruby/st.h $(hdrdir)/ruby/subst.h $(arch_hdrdir)/ruby/config.h $(RUBY_EXTCONF_H)
+
+RM = rm -f
+RM_RF = $(RUBY) -run -e rm -- -rf
+RMDIRS = rmdir --ignore-fail-on-non-empty -p
+MAKEDIRS = /bin/mkdir -p
+INSTALL = /usr/bin/install -c
+INSTALL_PROG = $(INSTALL) -m 0755
+INSTALL_DATA = $(INSTALL) -m 644
+COPY = cp
+TOUCH = exit >
+
+#### End of system configuration section. ####
+
+preload =
+
+libpath = . $(topdir)
+LIBPATH = -L. -L$(topdir)
+DEFFILE =
+
+CLEANFILES = mkmf.log
+DISTCLEANFILES =
+DISTCLEANDIRS =
+
+extout = $(topdir)/.ext
+extout_prefix = $(extout)$(target_prefix)/
+target_prefix =
+LOCAL_LIBS =
+LIBS = $(LIBRUBYARG_SHARED) -lpthread -lgmp -ldl -lcrypt -lm -lc
+ORIG_SRCS = thread.c
+SRCS = $(ORIG_SRCS)
+OBJS = thread.o
+HDRS = $(srcdir)/extconf.h
+TARGET = thread
+TARGET_NAME = thread
+TARGET_ENTRY = Init_$(TARGET_NAME)
+DLLIB = $(TARGET).so
+EXTSTATIC =
+STATIC_LIB = $(TARGET).a
+
+TIMESTAMP_DIR = $(extout)/.timestamp
+BINDIR = $(extout)/bin
+RUBYCOMMONDIR = $(extout)/common
+RUBYLIBDIR = $(RUBYCOMMONDIR)$(target_prefix)
+RUBYARCHDIR = $(extout)/$(arch)$(target_prefix)
+HDRDIR = $(extout)/include/ruby$(target_prefix)
+ARCHHDRDIR = $(extout)/include/$(arch)/ruby$(target_prefix)
+
+TARGET_SO = $(RUBYARCHDIR)/$(DLLIB)
+CLEANLIBS = $(RUBYARCHDIR)/$(TARGET).so
+CLEANOBJS = *.o *.bak
+
+all: install
+static: all
+.PHONY: all install static install-so install-rb
+.PHONY: clean clean-so clean-static clean-rb
+
+clean-static::
+clean-rb-default::
+clean-rb::
+clean-so::
+clean: clean-so clean-static clean-rb-default clean-rb
+ -$(Q)$(RM) $(CLEANLIBS) $(CLEANOBJS) $(CLEANFILES) .*.time
+
+distclean-rb-default::
+distclean-rb::
+distclean-so::
+distclean-static::
+distclean: clean distclean-so distclean-static distclean-rb-default distclean-rb
+ -$(Q)$(RM) Makefile $(RUBY_EXTCONF_H) conftest.* mkmf.log
+ -$(Q)$(RM) core ruby$(EXEEXT) *~ $(DISTCLEANFILES)
+ -$(Q)$(RMDIRS) $(DISTCLEANDIRS) 2> /dev/null || true
+
+realclean: distclean
+install: install-so install-rb
+
+install-so: $(RUBYARCHDIR)/$(DLLIB)
+clean-so::
+ -$(Q)$(RM) $(RUBYARCHDIR)/$(DLLIB)
+ -$(Q)$(RMDIRS) $(RUBYARCHDIR) 2> /dev/null || true
+clean-static::
+ -$(Q)$(RM) $(STATIC_LIB)
+install-rb: pre-install-rb install-rb-default
+install-rb-default: pre-install-rb-default
+pre-install-rb: Makefile
+pre-install-rb-default: Makefile
+pre-install-rb-default:
+ @$(NULLCMD)
+$(TIMESTAMP_DIR)/.RUBYARCHDIR.time:
+ $(Q) $(MAKEDIRS) $(@D) $(RUBYARCHDIR)
+ $(Q) $(TOUCH) $@
+
+site-install: site-install-so site-install-rb
+site-install-so: install-so
+site-install-rb: install-rb
+
+.SUFFIXES: .c .m .cc .mm .cxx .cpp .o .S
+
+.cc.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<
+
+.cc.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -S $<
+
+.mm.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<
+
+.mm.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -S $<
+
+.cxx.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<
+
+.cxx.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -S $<
+
+.cpp.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<
+
+.cpp.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -S $<
+
+.c.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -c $<
+
+.c.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -S $<
+
+.m.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -c $<
+
+.m.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -S $<
+
+$(RUBYARCHDIR)/$(DLLIB): $(OBJS) Makefile $(TIMESTAMP_DIR)/.RUBYARCHDIR.time
+ $(ECHO) linking shared-object $(DLLIB)
+ -$(Q)$(RM) $(@)
+ $(Q) $(LDSHARED) -o $@ $(OBJS) $(LIBPATH) $(DLDFLAGS) $(LOCAL_LIBS) $(LIBS)
+
+$(STATIC_LIB): $(OBJS)
+ -$(Q)$(RM) $(@)
+ $(ECHO) linking static-library $(@)
+ $(Q) $(AR) cru $@ $(OBJS)
+ -$(Q)ranlib $(@) 2> /dev/null || true
+
+$(OBJS): $(HDRS) $(ruby_headers)
diff --git a/jni/ruby/ext/thread/extconf.h b/jni/ruby/ext/thread/extconf.h
new file mode 100644
index 0000000..cda0cc8
--- /dev/null
+++ b/jni/ruby/ext/thread/extconf.h
@@ -0,0 +1,3 @@
+#ifndef EXTCONF_H
+#define EXTCONF_H
+#endif
diff --git a/jni/ruby/ext/thread/extconf.rb b/jni/ruby/ext/thread/extconf.rb
new file mode 100644
index 0000000..f2f0890
--- /dev/null
+++ b/jni/ruby/ext/thread/extconf.rb
@@ -0,0 +1,3 @@
+require 'mkmf'
+
+create_makefile('thread')
diff --git a/jni/ruby/ext/thread/thread.c b/jni/ruby/ext/thread/thread.c
new file mode 100644
index 0000000..b8656a1
--- /dev/null
+++ b/jni/ruby/ext/thread/thread.c
@@ -0,0 +1,656 @@
+#include <ruby.h>
+
+enum {
+ CONDVAR_WAITERS = 0
+};
+
+enum {
+ QUEUE_QUE = 0,
+ QUEUE_WAITERS = 1,
+ SZQUEUE_WAITERS = 2,
+ SZQUEUE_MAX = 3
+};
+
+#define GET_CONDVAR_WAITERS(cv) get_array((cv), CONDVAR_WAITERS)
+
+#define GET_QUEUE_QUE(q) get_array((q), QUEUE_QUE)
+#define GET_QUEUE_WAITERS(q) get_array((q), QUEUE_WAITERS)
+#define GET_SZQUEUE_WAITERS(q) get_array((q), SZQUEUE_WAITERS)
+#define GET_SZQUEUE_MAX(q) RSTRUCT_GET((q), SZQUEUE_MAX)
+#define GET_SZQUEUE_ULONGMAX(q) NUM2ULONG(GET_SZQUEUE_MAX(q))
+
+static VALUE
+get_array(VALUE obj, int idx)
+{
+ VALUE ary = RSTRUCT_GET(obj, idx);
+ if (!RB_TYPE_P(ary, T_ARRAY)) {
+ rb_raise(rb_eTypeError, "%+"PRIsVALUE" not initialized", obj);
+ }
+ return ary;
+}
+
+static VALUE
+ary_buf_new(void)
+{
+ return rb_ary_tmp_new(1);
+}
+
+static void
+wakeup_first_thread(VALUE list)
+{
+ VALUE thread;
+
+ while (!NIL_P(thread = rb_ary_shift(list))) {
+ if (RTEST(rb_thread_wakeup_alive(thread))) break;
+ }
+}
+
+static void
+wakeup_all_threads(VALUE list)
+{
+ VALUE thread;
+ long i;
+
+ for (i=0; i<RARRAY_LEN(list); i++) {
+ thread = RARRAY_AREF(list, i);
+ rb_thread_wakeup_alive(thread);
+ }
+ rb_ary_clear(list);
+}
+
+/*
+ * Document-class: ConditionVariable
+ *
+ * ConditionVariable objects augment class Mutex. Using condition variables,
+ * it is possible to suspend while in the middle of a critical section until a
+ * resource becomes available.
+ *
+ * Example:
+ *
+ * require 'thread'
+ *
+ * mutex = Mutex.new
+ * resource = ConditionVariable.new
+ *
+ * a = Thread.new {
+ * mutex.synchronize {
+ * # Thread 'a' now needs the resource
+ * resource.wait(mutex)
+ * # 'a' can now have the resource
+ * }
+ * }
+ *
+ * b = Thread.new {
+ * mutex.synchronize {
+ * # Thread 'b' has finished using the resource
+ * resource.signal
+ * }
+ * }
+ */
+
+/*
+ * Document-method: ConditionVariable::new
+ *
+ * Creates a new condition variable instance.
+ */
+
+static VALUE
+rb_condvar_initialize(VALUE self)
+{
+ RSTRUCT_SET(self, CONDVAR_WAITERS, ary_buf_new());
+ return self;
+}
+
+struct sleep_call {
+ VALUE mutex;
+ VALUE timeout;
+};
+
+static ID id_sleep;
+
+static VALUE
+do_sleep(VALUE args)
+{
+ struct sleep_call *p = (struct sleep_call *)args;
+ return rb_funcall2(p->mutex, id_sleep, 1, &p->timeout);
+}
+
+static VALUE
+delete_current_thread(VALUE ary)
+{
+ return rb_ary_delete(ary, rb_thread_current());
+}
+
+/*
+ * Document-method: ConditionVariable#wait
+ * call-seq: wait(mutex, timeout=nil)
+ *
+ * Releases the lock held in +mutex+ and waits; reacquires the lock on wakeup.
+ *
+ * If +timeout+ is given, this method returns after +timeout+ seconds passed,
+ * even if no other thread doesn't signal.
+ */
+
+static VALUE
+rb_condvar_wait(int argc, VALUE *argv, VALUE self)
+{
+ VALUE waiters = GET_CONDVAR_WAITERS(self);
+ VALUE mutex, timeout;
+ struct sleep_call args;
+
+ rb_scan_args(argc, argv, "11", &mutex, &timeout);
+
+ args.mutex = mutex;
+ args.timeout = timeout;
+ rb_ary_push(waiters, rb_thread_current());
+ rb_ensure(do_sleep, (VALUE)&args, delete_current_thread, waiters);
+
+ return self;
+}
+
+/*
+ * Document-method: ConditionVariable#signal
+ *
+ * Wakes up the first thread in line waiting for this lock.
+ */
+
+static VALUE
+rb_condvar_signal(VALUE self)
+{
+ wakeup_first_thread(GET_CONDVAR_WAITERS(self));
+ return self;
+}
+
+/*
+ * Document-method: ConditionVariable#broadcast
+ *
+ * Wakes up all threads waiting for this lock.
+ */
+
+static VALUE
+rb_condvar_broadcast(VALUE self)
+{
+ wakeup_all_threads(GET_CONDVAR_WAITERS(self));
+ return self;
+}
+
+/*
+ * Document-class: Queue
+ *
+ * This class provides a way to synchronize communication between threads.
+ *
+ * Example:
+ *
+ * require 'thread'
+ * queue = Queue.new
+ *
+ * producer = Thread.new do
+ * 5.times do |i|
+ * sleep rand(i) # simulate expense
+ * queue << i
+ * puts "#{i} produced"
+ * end
+ * end
+ *
+ * consumer = Thread.new do
+ * 5.times do |i|
+ * value = queue.pop
+ * sleep rand(i/2) # simulate expense
+ * puts "consumed #{value}"
+ * end
+ * end
+ *
+ */
+
+/*
+ * Document-method: Queue::new
+ *
+ * Creates a new queue instance.
+ */
+
+static VALUE
+rb_queue_initialize(VALUE self)
+{
+ RSTRUCT_SET(self, QUEUE_QUE, ary_buf_new());
+ RSTRUCT_SET(self, QUEUE_WAITERS, ary_buf_new());
+ return self;
+}
+
+static VALUE
+queue_do_push(VALUE self, VALUE obj)
+{
+ rb_ary_push(GET_QUEUE_QUE(self), obj);
+ wakeup_first_thread(GET_QUEUE_WAITERS(self));
+ return self;
+}
+
+/*
+ * Document-method: Queue#push
+ * call-seq:
+ * push(object)
+ * enq(object)
+ * <<(object)
+ *
+ * Pushes the given +object+ to the queue.
+ */
+
+static VALUE
+rb_queue_push(VALUE self, VALUE obj)
+{
+ return queue_do_push(self, obj);
+}
+
+static unsigned long
+queue_length(VALUE self)
+{
+ VALUE que = GET_QUEUE_QUE(self);
+ return RARRAY_LEN(que);
+}
+
+static unsigned long
+queue_num_waiting(VALUE self)
+{
+ VALUE waiters = GET_QUEUE_WAITERS(self);
+ return RARRAY_LEN(waiters);
+}
+
+struct waiting_delete {
+ VALUE waiting;
+ VALUE th;
+};
+
+static VALUE
+queue_delete_from_waiting(struct waiting_delete *p)
+{
+ rb_ary_delete(p->waiting, p->th);
+ return Qnil;
+}
+
+static VALUE
+queue_sleep(VALUE arg)
+{
+ rb_thread_sleep_deadly();
+ return Qnil;
+}
+
+static VALUE
+queue_do_pop(VALUE self, int should_block)
+{
+ struct waiting_delete args;
+ args.waiting = GET_QUEUE_WAITERS(self);
+ args.th = rb_thread_current();
+
+ while (queue_length(self) == 0) {
+ if (!should_block) {
+ rb_raise(rb_eThreadError, "queue empty");
+ }
+ rb_ary_push(args.waiting, args.th);
+ rb_ensure(queue_sleep, (VALUE)0, queue_delete_from_waiting, (VALUE)&args);
+ }
+
+ return rb_ary_shift(GET_QUEUE_QUE(self));
+}
+
+static int
+queue_pop_should_block(int argc, const VALUE *argv)
+{
+ int should_block = 1;
+ rb_check_arity(argc, 0, 1);
+ if (argc > 0) {
+ should_block = !RTEST(argv[0]);
+ }
+ return should_block;
+}
+
+/*
+ * Document-method: Queue#pop
+ * call-seq:
+ * pop(non_block=false)
+ * deq(non_block=false)
+ * shift(non_block=false)
+ *
+ * Retrieves data from the queue.
+ *
+ * If the queue is empty, the calling thread is suspended until data is pushed
+ * onto the queue. If +non_block+ is true, the thread isn't suspended, and an
+ * exception is raised.
+ */
+
+static VALUE
+rb_queue_pop(int argc, VALUE *argv, VALUE self)
+{
+ int should_block = queue_pop_should_block(argc, argv);
+ return queue_do_pop(self, should_block);
+}
+
+/*
+ * Document-method: Queue#empty?
+ * call-seq: empty?
+ *
+ * Returns +true+ if the queue is empty.
+ */
+
+static VALUE
+rb_queue_empty_p(VALUE self)
+{
+ return queue_length(self) == 0 ? Qtrue : Qfalse;
+}
+
+/*
+ * Document-method: Queue#clear
+ *
+ * Removes all objects from the queue.
+ */
+
+static VALUE
+rb_queue_clear(VALUE self)
+{
+ rb_ary_clear(GET_QUEUE_QUE(self));
+ return self;
+}
+
+/*
+ * Document-method: Queue#length
+ * call-seq:
+ * length
+ * size
+ *
+ * Returns the length of the queue.
+ */
+
+static VALUE
+rb_queue_length(VALUE self)
+{
+ unsigned long len = queue_length(self);
+ return ULONG2NUM(len);
+}
+
+/*
+ * Document-method: Queue#num_waiting
+ *
+ * Returns the number of threads waiting on the queue.
+ */
+
+static VALUE
+rb_queue_num_waiting(VALUE self)
+{
+ unsigned long len = queue_num_waiting(self);
+ return ULONG2NUM(len);
+}
+
+/*
+ * Document-class: SizedQueue
+ *
+ * This class represents queues of specified size capacity. The push operation
+ * may be blocked if the capacity is full.
+ *
+ * See Queue for an example of how a SizedQueue works.
+ */
+
+/*
+ * Document-method: SizedQueue::new
+ * call-seq: new(max)
+ *
+ * Creates a fixed-length queue with a maximum size of +max+.
+ */
+
+static VALUE
+rb_szqueue_initialize(VALUE self, VALUE vmax)
+{
+ long max;
+
+ max = NUM2LONG(vmax);
+ if (max <= 0) {
+ rb_raise(rb_eArgError, "queue size must be positive");
+ }
+
+ RSTRUCT_SET(self, QUEUE_QUE, ary_buf_new());
+ RSTRUCT_SET(self, QUEUE_WAITERS, ary_buf_new());
+ RSTRUCT_SET(self, SZQUEUE_WAITERS, ary_buf_new());
+ RSTRUCT_SET(self, SZQUEUE_MAX, vmax);
+
+ return self;
+}
+
+/*
+ * Document-method: SizedQueue#max
+ *
+ * Returns the maximum size of the queue.
+ */
+
+static VALUE
+rb_szqueue_max_get(VALUE self)
+{
+ return GET_SZQUEUE_MAX(self);
+}
+
+/*
+ * Document-method: SizedQueue#max=
+ * call-seq: max=(number)
+ *
+ * Sets the maximum size of the queue to the given +number+.
+ */
+
+static VALUE
+rb_szqueue_max_set(VALUE self, VALUE vmax)
+{
+ long max = NUM2LONG(vmax), diff = 0;
+ VALUE t;
+
+ if (max <= 0) {
+ rb_raise(rb_eArgError, "queue size must be positive");
+ }
+ if ((unsigned long)max > GET_SZQUEUE_ULONGMAX(self)) {
+ diff = max - GET_SZQUEUE_ULONGMAX(self);
+ }
+ RSTRUCT_SET(self, SZQUEUE_MAX, vmax);
+ while (diff-- > 0 && !NIL_P(t = rb_ary_shift(GET_SZQUEUE_WAITERS(self)))) {
+ rb_thread_wakeup_alive(t);
+ }
+ return vmax;
+}
+
+static int
+szqueue_push_should_block(int argc, const VALUE *argv)
+{
+ int should_block = 1;
+ rb_check_arity(argc, 1, 2);
+ if (argc > 1) {
+ should_block = !RTEST(argv[1]);
+ }
+ return should_block;
+}
+
+/*
+ * Document-method: SizedQueue#push
+ * call-seq:
+ * push(object, non_block=false)
+ * enq(object, non_block=false)
+ * <<(object)
+ *
+ * Pushes +object+ to the queue.
+ *
+ * If there is no space left in the queue, waits until space becomes
+ * available, unless +non_block+ is true. If +non_block+ is true, the
+ * thread isn't suspended, and an exception is raised.
+ */
+
+static VALUE
+rb_szqueue_push(int argc, VALUE *argv, VALUE self)
+{
+ struct waiting_delete args;
+ int should_block = szqueue_push_should_block(argc, argv);
+ args.waiting = GET_SZQUEUE_WAITERS(self);
+ args.th = rb_thread_current();
+
+ while (queue_length(self) >= GET_SZQUEUE_ULONGMAX(self)) {
+ if (!should_block) {
+ rb_raise(rb_eThreadError, "queue full");
+ }
+ rb_ary_push(args.waiting, args.th);
+ rb_ensure((VALUE (*)())rb_thread_sleep_deadly, (VALUE)0, queue_delete_from_waiting, (VALUE)&args);
+ }
+ return queue_do_push(self, argv[0]);
+}
+
+static VALUE
+szqueue_do_pop(VALUE self, int should_block)
+{
+ VALUE retval = queue_do_pop(self, should_block);
+
+ if (queue_length(self) < GET_SZQUEUE_ULONGMAX(self)) {
+ wakeup_first_thread(GET_SZQUEUE_WAITERS(self));
+ }
+
+ return retval;
+}
+
+/*
+ * Document-method: SizedQueue#pop
+ * call-seq:
+ * pop(non_block=false)
+ * deq(non_block=false)
+ * shift(non_block=false)
+ *
+ * Retrieves data from the queue.
+ *
+ * If the queue is empty, the calling thread is suspended until data is pushed
+ * onto the queue. If +non_block+ is true, the thread isn't suspended, and an
+ * exception is raised.
+ */
+
+static VALUE
+rb_szqueue_pop(int argc, VALUE *argv, VALUE self)
+{
+ int should_block = queue_pop_should_block(argc, argv);
+ return szqueue_do_pop(self, should_block);
+}
+
+/*
+ * Document-method: Queue#clear
+ *
+ * Removes all objects from the queue.
+ */
+
+static VALUE
+rb_szqueue_clear(VALUE self)
+{
+ rb_ary_clear(GET_QUEUE_QUE(self));
+ wakeup_all_threads(GET_SZQUEUE_WAITERS(self));
+ return self;
+}
+
+/*
+ * Document-method: SizedQueue#num_waiting
+ *
+ * Returns the number of threads waiting on the queue.
+ */
+
+static VALUE
+rb_szqueue_num_waiting(VALUE self)
+{
+ long len = queue_num_waiting(self);
+ VALUE waiters = GET_SZQUEUE_WAITERS(self);
+ len += RARRAY_LEN(waiters);
+ return ULONG2NUM(len);
+}
+
+#ifndef UNDER_THREAD
+#define UNDER_THREAD 1
+#endif
+
+/* :nodoc: */
+static VALUE
+undumpable(VALUE obj)
+{
+ rb_raise(rb_eTypeError, "can't dump %"PRIsVALUE, rb_obj_class(obj));
+ UNREACHABLE;
+}
+
+void
+Init_thread(void)
+{
+#if UNDER_THREAD
+#define ALIAS_GLOBAL_CONST(name) do { \
+ ID id = rb_intern_const(#name); \
+ if (!rb_const_defined_at(rb_cObject, id)) { \
+ rb_const_set(rb_cObject, id, rb_c##name); \
+ } \
+ } while (0)
+#define OUTER rb_cThread
+#else
+#define ALIAS_GLOBAL_CONST(name) do { /* nothing */ } while (0)
+#define OUTER 0
+#endif
+
+ VALUE rb_cConditionVariable = rb_struct_define_without_accessor_under(
+ OUTER,
+ "ConditionVariable", rb_cObject, rb_struct_alloc_noinit,
+ "waiters", NULL);
+ VALUE rb_cQueue = rb_struct_define_without_accessor_under(
+ OUTER,
+ "Queue", rb_cObject, rb_struct_alloc_noinit,
+ "que", "waiters", NULL);
+ VALUE rb_cSizedQueue = rb_struct_define_without_accessor_under(
+ OUTER,
+ "SizedQueue", rb_cQueue, rb_struct_alloc_noinit,
+ "que", "waiters", "queue_waiters", "size", NULL);
+
+#if 0
+ rb_cConditionVariable = rb_define_class("ConditionVariable", rb_cObject); /* teach rdoc ConditionVariable */
+ rb_cQueue = rb_define_class("Queue", rb_cObject); /* teach rdoc Queue */
+ rb_cSizedQueue = rb_define_class("SizedQueue", rb_cObject); /* teach rdoc SizedQueue */
+#endif
+
+ id_sleep = rb_intern("sleep");
+
+ rb_define_method(rb_cConditionVariable, "initialize", rb_condvar_initialize, 0);
+ rb_undef_method(rb_cConditionVariable, "initialize_copy");
+ rb_define_method(rb_cConditionVariable, "marshal_dump", undumpable, 0);
+ rb_define_method(rb_cConditionVariable, "wait", rb_condvar_wait, -1);
+ rb_define_method(rb_cConditionVariable, "signal", rb_condvar_signal, 0);
+ rb_define_method(rb_cConditionVariable, "broadcast", rb_condvar_broadcast, 0);
+
+ rb_define_method(rb_cQueue, "initialize", rb_queue_initialize, 0);
+ rb_undef_method(rb_cQueue, "initialize_copy");
+ rb_define_method(rb_cQueue, "marshal_dump", undumpable, 0);
+ rb_define_method(rb_cQueue, "push", rb_queue_push, 1);
+ rb_define_method(rb_cQueue, "pop", rb_queue_pop, -1);
+ rb_define_method(rb_cQueue, "empty?", rb_queue_empty_p, 0);
+ rb_define_method(rb_cQueue, "clear", rb_queue_clear, 0);
+ rb_define_method(rb_cQueue, "length", rb_queue_length, 0);
+ rb_define_method(rb_cQueue, "num_waiting", rb_queue_num_waiting, 0);
+
+ /* Alias for #push. */
+ rb_define_alias(rb_cQueue, "enq", "push");
+ /* Alias for #push. */
+ rb_define_alias(rb_cQueue, "<<", "push");
+ /* Alias for #pop. */
+ rb_define_alias(rb_cQueue, "deq", "pop");
+ /* Alias for #pop. */
+ rb_define_alias(rb_cQueue, "shift", "pop");
+ /* Alias for #length. */
+ rb_define_alias(rb_cQueue, "size", "length");
+
+ rb_define_method(rb_cSizedQueue, "initialize", rb_szqueue_initialize, 1);
+ rb_define_method(rb_cSizedQueue, "max", rb_szqueue_max_get, 0);
+ rb_define_method(rb_cSizedQueue, "max=", rb_szqueue_max_set, 1);
+ rb_define_method(rb_cSizedQueue, "push", rb_szqueue_push, -1);
+ rb_define_method(rb_cSizedQueue, "pop", rb_szqueue_pop, -1);
+ rb_define_method(rb_cSizedQueue, "clear", rb_szqueue_clear, 0);
+ rb_define_method(rb_cSizedQueue, "num_waiting", rb_szqueue_num_waiting, 0);
+
+ /* Alias for #push. */
+ rb_define_alias(rb_cSizedQueue, "enq", "push");
+ /* Alias for #push. */
+ rb_define_alias(rb_cSizedQueue, "<<", "push");
+ /* Alias for #pop. */
+ rb_define_alias(rb_cSizedQueue, "deq", "pop");
+ /* Alias for #pop. */
+ rb_define_alias(rb_cSizedQueue, "shift", "pop");
+
+ rb_provide("thread.rb");
+ ALIAS_GLOBAL_CONST(ConditionVariable);
+ ALIAS_GLOBAL_CONST(Queue);
+ ALIAS_GLOBAL_CONST(SizedQueue);
+}
diff --git a/jni/ruby/ext/tk/ChangeLog.tkextlib b/jni/ruby/ext/tk/ChangeLog.tkextlib
new file mode 100644
index 0000000..52a0b7e
--- /dev/null
+++ b/jni/ruby/ext/tk/ChangeLog.tkextlib
@@ -0,0 +1,949 @@
+2009-07-12 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
+
+ * ext/tk/lib/tkextlib/*: update release.
+ Tcllib 1.8/Tklib 0.4.1 ==> Tcllib 1.11.1/Tklib 0.5
+ BWidgets 1.7 ==> BWidgets 1.8
+ TkTable 2.9 ==> TkTable 2.10
+ TkTreeCtrl 2005-12-02 ==> TkTreeCtrl 2.2.9
+ Tile 0.8.0/8.5.1 ==> Tile 0.8.3/8.6b1
+ IncrTcl 2005-02-14 ==> IncrTcl 2008-12-15
+ TclX 2005-02-07 ==> TclX 2008-12-15
+ Trofs 0.4.3 ==> Trofs 0.4.4
+
+--------------< ... some bug fixes ... >------------------
+
+Tue Nov 25 03:37:42 2008 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
+
+ * ext/tk/lib/tkextlib/blt/tabset.rb,
+ ext/tk/lib/tkextlib/blt/tabnotebook.rb:
+ fix many bugs. Now, those work properly.
+
+Sat Nov 22 10:31:25 2008 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
+
+ * ext/tk/lib/tkextlib/blt.rb, ext/tk/lib/tkextlib/blt/vector.rb:
+ fix NameError bug.
+
+2008-05-12 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
+
+ * ext/tk/lib/tkextlib/tkDND/shape.rb: wrong package name.
+
+--------------< ... some changes ... >------------------
+
+2007-05-26 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
+
+ * ext/tk/lib/tkextlib/tcllib/tablelist.rb: fix typo.
+
+ * ext/tk/lib/tkextlib/tile/dialog.rb: forget to give an argument.
+
+ * ext/tk/lib/tkextlib/version.rb: update RELEASE_DATE.
+
+2007-01-26 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
+
+ * ext/tk/lib/tkextlib/iwidgets/checkbox.rb: wrong number of arguments
+ [ruby-Bugs-7776].
+
+ * ext/tk/lib/tkextlib/iwidgets/radiobox.rb: ditto.
+
+ * ext/tk/lib/tkextlib/blt/tile/checkbutton.rb: change primary name
+ of class [ruby-dev:30080].
+
+ * ext/tk/lib/tkextlib/blt/tile/radiobutton.rb: ditto.
+
+2006-11-07 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
+
+ * lib/tkextlib/tile/treeview.rb : minor bug fix.
+
+ * lib/tkextlib/blt/table.rb: fix bugs which forbade use of
+ '::blt::table' command. Now, probably, it'll works properly.
+
+2006-11-06 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
+
+ * lib/tkextlib/version.rb: keep release date of tkextlib on
+ "Tk::Tkextlib_RELEASE_DATE".
+
+ * lib/tkextlib/tile/treeview.rb : support Tile 0.7.8.
+ Now, you can handle tree items as objects.
+
+2006-10-04 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
+
+ * lib/tkextlib/tile.rb, lib/tkextlib/tile/* : support Tile 0.7.6.
+
+2006-10-03 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
+
+ * lib/tkextlib/SUPPORT_STATUS: [ruby-talk:211939] check links
+ of extensions.
+
+ * lib/tkextlib/blt/container.rb: define instance methods properly.
+
+ * lib/tkextlib/tile/tcombobox.rb: bug fix [ruby-talk:213003].
+
+ * lib/tkextlib/tile/tnotebook.rb: ditto.
+
+ * lib/tkextlib/tile/treeview.rb: ditto.
+
+ * lib/tkextlib/tile/sizegrip.rb: [new] add 'ttk::sizegrip' widget.
+
+2006-08-31 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
+
+ * lib/tkextlib/blt.rb: double dashes (--) option doesn't work
+ properly on some versions of BLT (wrong description on the
+ manual of `blt::bgexec'?).
+
+2005-12-11 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
+
+ * lib/tkextlib/SUPPORT_STATUS: update to support libraries in
+ ActiveTcl8.4.12.0.
+
+ * lib/tkextlib/tile/tnotebook.rb: add Tk::Tile::TNotebook#insert.
+
+ * sample/tkextlib/tile/demo.rb: improve the look of a part of the demo.
+
+2005-11-25 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
+
+ * sample/tkextlib/tile/demo.rb: bug fix
+
+ * sample/tkextlib/tile/themes/*: add some themes (blue,
+ keramik, and plastik; require Tile-0.5 or later).
+
+2005-11-22 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
+
+ * lib/tkextlib/tile.rb: bug fix (Tk::Tile::USE_TTK_NAMESPACE
+ is not defined).
+
+2005-11-19 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
+
+ * sample/tkextlib/treectrl/demo.rb: remove dependency on Ruby's
+ version (1.8 or 1.9).
+
+2005-10-23 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
+
+ * lib/tkextlib/*: update to support ActiveTcl8.4.11.2
+
+ * lib/tkextlib/trofs/*: support Trofs 0.4.3
+
+ * lib/tkextlib/tile/*: support Tile 0.7.2
+
+ * lib/tkextlib/vu/*: support vu 2.3.0
+
+ * lib/tkextlib/tcllib/*: support Tcllib 1.8 (Tklib 0.3 part only)
+
+ * lib/tkextlib/*: improve conversion of option values
+
+2005-10-04 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
+
+ * lib/tkextlib/tktable/tktable.rb: border_* instance methods
+ don't call 'border' subcommands.
+
+2005-08-10 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
+
+ * lib/tkextlib/blt/component.rb: didn't check
+ __item_ruby2val_optkeys().
+
+2005-08-09 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
+
+ * lib/tkextlib/blt/barchart.rb: support to treat tkvariable-type
+ configure options.
+
+ * lib/tkextlib/blt/component.rb: ditto.
+
+ * lib/tkextlib/blt/dragdrop.rb: ditto.
+
+ * lib/tkextlib/blt/treeview.rb: ditto.
+
+ * lib/tkextlib/bwidget/button.rb: ditto.
+
+ * lib/tkextlib/bwidget/entry.rb: ditto.
+
+ * lib/tkextlib/bwidget/label.rb: ditto.
+
+ * lib/tkextlib/bwidget/labelentry.rb: ditto.
+
+ * lib/tkextlib/bwidget/labelframe.rb: ditto.
+
+ * lib/tkextlib/bwidget/mainframe.rb: ditto.
+
+ * lib/tkextlib/bwidget/passwddlg.rb: ditto.
+
+ * lib/tkextlib/bwidget/spinbox.rb: ditto.
+
+ * lib/tkextlib/bwidget/tree.rb: ditto.
+
+ * lib/tkextlib/iwidgets/calendar.rb: ditto.
+
+ * lib/tkextlib/iwidgets/entryfield.rb: ditto.
+
+ * lib/tkextlib/iwidgets/hierarchy.rb: ditto.
+
+ * lib/tkextlib/iwidgets/labeledframe.rb: ditto.
+
+ * lib/tkextlib/iwidgets/labeledwidget.rb: ditto.
+
+ * lib/tkextlib/iwidgets/menubar.rb: ditto.
+
+ * lib/tkextlib/iwidgets/scrolledlistbox.rb: ditto.
+
+ * lib/tkextlib/iwidgets/spinner.rb: ditto.
+
+ * lib/tkextlib/iwidgets/toolbar.rb: ditto.
+
+ * lib/tkextlib/tkimg/pixmap.rb: ditto.
+
+ * lib/tkextlib/tktable/tktable.rb: ditto.
+
+2005-08-06 ocean <ocean@ruby-lang.org>
+
+ * sample/tkextlib/tile/demo.rb: use Tk::Tile::Scale#variable.
+
+2005-08-04 ocean <ocean@ruby-lang.org>
+
+ * sample/tkextlib/tile/demo.rb: followed previous changes.
+
+2005-08-04 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
+
+ * lib/tkextlib/tile/t*.rb: aliased class names starting with 'T'
+ to non 'T' ones. (ie. Tk::Tile::TButton -> Tk::Tile::Button)
+ [ruby-dev:26724]
+
+ * lib/tkextlib/tile.rb: ditto. (autoload support)
+
+2005-08-04 ocean <ocean@ruby-lang.org>
+
+ * sample/tkextlib/tile/demo.rb: fixed: Tk::Tile::TProgressbar is
+ supported on tile 0.6 or later, not tile 0.5.
+
+ * sample/tkextlib/tile/demo.rb: updated scales demo to use
+ Tk::Tile::TProgressbar for tile 0.6 or later.
+
+ * sample/tkextlib/tile/demo.rb: set some TkVariable default values.
+
+2005-08-03 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
+
+ * lib/tkextlib/tile/treeview.rb: Tk::Tile::Treeview#headingconfigure
+ is now working and more. [ruby-dev:26716]
+
+ * sample/tkextlib/tile/demo.rb: use Tk::Tile::Treeview#headingconfigure instead of direct Tk.tk_call.
+
+2005-08-02 ocean <ocean@ruby-lang.org>
+
+ * lib/tkextlib/tile/tprogressbar.rb: Tk::Tile::TProgressbar#start
+ takes optional argument `interval'.
+
+ * sample/tkextlib/tile/demo.rb: emulate Tk::Tile::TProgressbar
+ with Tk::Tile::TProgress in tile 0.4. (repeating buttons demo)
+
+2005-08-02 ocean <ocean@ruby-lang.org>
+
+ * sample/tkextlib/tile/demo.rb: added repeating buttons demo.
+
+ * sample/tkextlib/tile/repeater.tcl: ditto. (new file)
+
+2005-08-01 ocean <ocean@ruby-lang.org>
+
+ * lib/tkextlib/tile.rb: fixed autoload for Treeview.
+
+ * lib/tkextlib/tile/treeview.rb: replaced `ary2tk_list(items)' with
+ `*items'.
+
+ * sample/tkextlib/tile/demo.rb: added treeview demo. (tile 0.5 or
+ later is required) [ruby-dev:26668]
+
+2005-08-01 ocean <ocean@ruby-lang.org>
+
+ * sample/tkextlib/tile/demo.rb: added combobox demo.
+
+2005-07-27 ocean <ocean@ruby-lang.org>
+
+ * sample/tkextlib/tile/demo.rb: fixed typo.
+
+2005-06-16 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
+
+ * lib/tkextlib/SUPPOPRT_STATUS: add RELEASE_DATE information.
+
+ * lib/tkextlib/tile/style.rb: add "style element options <elem>"
+ command support.
+
+2005-06-08 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
+
+ * lib/tkextlib/ICONS/icons.rb: fail to create instances of
+ Tk::ICONS [ruby-dev:26305].
+
+2005-06-07 ocean <ocean@ruby-lang.org>
+
+ * sample/tkextlib/tile/themes/kroc.{rb,tcl}: also support tile 0.4.
+
+2005-06-07 ocean <ocean@ruby-lang.org>
+
+ * sample/tkextlib/tile/themes/kroc.{rb,tcl}: support tile 0.5 or later.
+ ("pixmap" element constructor replaced by "image")
+
+2005-06-05 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
+
+ * sample/tkextlib/tile/demo.rb: fix TypeError & create Console
+
+2005-05-30 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
+
+ * lib/tkextlib/blt.rb: add PACKAGE_NAME information of Tcl/Tk
+ Extension.
+
+ * lib/tkextlib/bwidget.rb: ditto.
+
+ * lib/tkextlib/iwidgets.rb: ditto.
+
+ * lib/tkextlib/tile.rb: ditto.
+
+ * lib/tkextlib/tkimg.rb: ditto.
+
+ * lib/tkextlib/vu.rb: ditto.
+
+ * lib/tkextlib/ICONS/icons.rb: ditto.
+
+ * lib/tkextlib/itcl/incr_tcl.rb: ditto.
+
+ * lib/tkextlib/itk/incr_tk.rb: ditto.
+
+ * lib/tkextlib/tcllib/autoscroll.rb: ditto.
+
+ * lib/tkextlib/tcllib/ctext.rb: ditto.
+
+ * lib/tkextlib/tcllib/cursor.rb: ditto.
+
+ * lib/tkextlib/tcllib/datefield.rb: ditto.
+
+ * lib/tkextlib/tcllib/ico.rb: ditto.
+
+ * lib/tkextlib/tcllib/ip_entry.rb: ditto.
+
+ * lib/tkextlib/tcllib/plotchart.rb: ditto.
+
+ * lib/tkextlib/tcllib/style.rb: ditto.
+
+ * lib/tkextlib/tcllib/tkpiechart.rb: ditto.
+
+ * lib/tkextlib/tclx/tclx.rb: ditto.
+
+ * lib/tkextlib/tkDND/shape.rb: ditto.
+
+ * lib/tkextlib/tkDND/tkdnd.rb: ditto.
+
+ * lib/tkextlib/tkHTML/htmlwidget.rb: ditto.
+
+ * lib/tkextlib/tkimg/bmp.rb: ditto.
+
+ * lib/tkextlib/tkimg/gif.rb: ditto.
+
+ * lib/tkextlib/tkimg/ico.rb: ditto.
+
+ * lib/tkextlib/tkimg/jpeg.rb: ditto.
+
+ * lib/tkextlib/tkimg/pcx.rb: ditto.
+
+ * lib/tkextlib/tkimg/pixmap.rb: ditto.
+
+ * lib/tkextlib/tkimg/png.rb: ditto.
+
+ * lib/tkextlib/tkimg/ppm.rb: ditto.
+
+ * lib/tkextlib/tkimg/ps.rb: ditto.
+
+ * lib/tkextlib/tkimg/sgi.rb: ditto.
+
+ * lib/tkextlib/tkimg/sun.rb: ditto.
+
+ * lib/tkextlib/tkimg/tga.rb: ditto.
+
+ * lib/tkextlib/tkimg/tiff.rb: ditto.
+
+ * lib/tkextlib/tkimg/window.rb: ditto.
+
+ * lib/tkextlib/tkimg/xbm.rb: ditto.
+
+ * lib/tkextlib/tkimg/xpm.rb: ditto.
+
+ * lib/tkextlib/tktable/tktable.rb: ditto.
+
+ * lib/tkextlib/tktrans/tktrans.rb: ditto.
+
+ * lib/tkextlib/treectrl/tktreectrl.rb: ditto.
+
+ * lib/tkextlib/winico/winico.rb: ditto.
+
+2005-05-25 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
+
+ * lib/tkextlib/iwidgets/scrolledlistbox.rb: follow the change
+ of tk.rb. modify to attend encoding.
+
+ * lib/tkextlib/iwidgets/scrolledtext.rb: ditto.
+
+ * lib/tkextlib/iwidgets/scrolledcanvas.rb: bug fix on
+ TkCanvas#delete when given non-TkcItem arguments.
+
+2005-05-10 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
+
+ * lib/tkextlib/blt/winop.rb: fix typo
+
+2005-05-08 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
+
+ * lib/tkextlib/vu/pie.rb: fix typo
+
+2005-04-10 ocean <ocean@ruby-lang.org>
+
+ * sample/tkextlib/treectrl/mailwasher.rb: fixed typo. [ruby-dev:26008]
+
+2005-04-09 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
+
+ * sample/tkextlib/tile/demo.rb: new demo of Tile extension.
+
+ * sample/tkextlib/tile/iconlib.tcl: part of the demo.
+
+ * sample/tkextlib/tile/toolbutton.tcl: ditto.
+
+ * sample/tkextlib/tile/readme.txt: document of the demo.
+
+ * sample/tkextlib/tile/Orig_LICENSE.txt: ditto.
+
+ * sample/tkextlib/tile/themes/kroc.tcl: sample theme written with Tcl.
+
+ * sample/tkextlib/tile/themes/pkgIndex.tcl: pkgIndex of kroc.tcl.
+
+ * sample/tkextlib/tile/themes/kroc.rb: Kroc theme written with Ruby.
+
+ * sample/tkextlib/tile/themes/kroc/button-h.gif: images for Kroc theme.
+
+ * sample/tkextlib/tile/themes/kroc/button-n.gif: ditto.
+
+ * sample/tkextlib/tile/themes/kroc/button-p.gif: ditto.
+
+ * sample/tkextlib/tile/themes/kroc/check-hc.gif: ditto.
+
+ * sample/tkextlib/tile/themes/kroc/check-hu.gif: ditto.
+
+ * sample/tkextlib/tile/themes/kroc/check-nc.gif: ditto.
+
+ * sample/tkextlib/tile/themes/kroc/check-nu.gif: ditto.
+
+ * sample/tkextlib/tile/themes/kroc/radio-hc.gif: ditto.
+
+ * sample/tkextlib/tile/themes/kroc/radio-hu.gif: ditto.
+
+ * sample/tkextlib/tile/themes/kroc/radio-nc.gif: ditto.
+
+ * sample/tkextlib/tile/themes/kroc/radio-nu.gif: ditto.
+
+ * lib/tkextlib/tile.rb: bug fix (tested on the new demo).
+
+ * lib/tkextlib/tile/style.rb: ditto.
+
+ * lib/tkextlib/tile/tbutton.rb: ditto.
+
+ * lib/tkextlib/tile/tcheckbutton.rb: ditto.
+
+ * lib/tkextlib/tile/tcombobox.rb: ditto.
+
+ * lib/tkextlib/tile/tentry.rb: ditto.
+
+ * lib/tkextlib/tile/tframe.rb: ditto.
+
+ * lib/tkextlib/tile/tlabel.rb: ditto.
+
+ * lib/tkextlib/tile/tlabelframe.rb: ditto.
+
+ * lib/tkextlib/tile/tmenubutton.rb: ditto.
+
+ * lib/tkextlib/tile/tnotebook.rb: ditto.
+
+ * lib/tkextlib/tile/tprogressbar.rb: ditto.
+
+ * lib/tkextlib/tile/tradiobutton.rb: ditto.
+
+ * lib/tkextlib/tile/treeview.rb: ditto.
+
+ * lib/tkextlib/tile/tscrollbar.rb: ditto.
+
+ * lib/tkextlib/tile/tseparator.rb: ditto.
+
+ * lib/tkextlib/tile/tsquare.rb: ditto.
+
+ * lib/tkextlib/tile/tpaned.rb: new library
+
+ * lib/tkextlib/tile/tscale.rb: ditto.
+
+ * lib/tkextlib/SUPPORT_STATUS: update support status of Tile extension.
+
+ * lib/tkextlib/tcllib/ctext.rb: use TkCommandNames on create_self().
+
+ * lib/tkextlib/tcllib/datefield.rb: ditto.
+
+ * lib/tkextlib/tcllib/ip_entry.rb: ditto.
+
+ * lib/tkextlib/tkHTML/htmlwidget.rb: ditto.
+
+ * lib/tkextlib/treectrl/tktreectrl.rb: ditto.
+
+2005-04-09 ocean <ocean@ruby-lang.org>
+
+ * sample/tkextlib/treectrl/explorer.rb: File.executable? returns true
+ even if it's plain text file. (this function only checks access right)
+
+2005-04-09 ocean <ocean@ruby-lang.org>
+
+ * sample/tkextlib/treectrl/{help,www-options}.rb: fixed typo.
+ (click or resize column header)
+
+2005-04-09 ocean <ocean@ruby-lang.org>
+
+ * sample/tkextlib/treectrl/imovie.rb: fixed typo. (click on clip title)
+
+2005-04-08 ocean <ocean@ruby-lang.org>
+
+ * sample/tkextlib/treectrl/random.rb: fixed typo. (drop node outside of
+ widget, or reenter widget while dragging)
+
+2005-04-08 ocean <ocean@ruby-lang.org>
+
+ * sample/tkextlib/treectrl/outlook-newgrounp.rb: image had disappered when
+ node was selected.
+
+2005-04-08 ocean <ocean@ruby-lang.org>
+
+ * sample/tkextlib/treectrl/{random,outlook-newgroup}.rb:
+ tk::treectrl uses 'afterId' not 'afterID'.
+
+ * sample/tkextlib/treectrl/{random,outlook-newgroup}.rb:
+ item_firstchild can return empty string. (drop node to leaf node)
+
+ * sample/tkextlib/treectrl/random.rb: Enumerable#find didn't work properly
+ because tried to compare String with Integer. (drag node and leave widget)
+
+ * sample/tkextlib/treectrl/random.rb: and some fixes.
+
+2005-04-08 ocean <ocean@ruby-lang.org>
+
+ * lib/tkextlib/treectrl/tktreectrl.rb (selection_clear): fixed typo.
+
+ * sample/tkextlib/treectrl/random.rb: node deselection now works.
+
+ * sample/tkextlib/treectrl/demo.rb: fixed typo. (popup menu on column header)
+
+2005-04-08 ocean <ocean@ruby-lang.org>
+
+ * sample/tkextlib/treectrl/help.rb: fixed typo. (wrong color)
+
+2005-04-08 ocean <ocean@ruby-lang.org>
+
+ * sample/tkextlib/treectrl/random.rb: fixed typo. (wrong itemheight)
+
+ * sample/tkextlib/treectrl/outlook-newgroup.rb: ditto.
+
+ * sample/tkextlib/treectrl/explorer.rb: ditto.
+
+ * sample/tkextlib/treectrl/help.rb: ditto.
+
+2005-04-07 ocean <ocean@ruby-lang.org>
+
+ * sample/tkextlib/treectrl/*.rb: some speed up... cache the result of
+ version checking.
+
+2005-04-07 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
+
+ * lib/tkextlib/treectrl/tktreectrl.rb: performance tuning by calling
+ tk_send_without_enc. [ruby-dev:25997]
+
+2005-04-04 ocean <ocean@ruby-lang.org>
+
+ * lib/tkextlib/tktable/tktable.rb: added Tk::TkTable#selection_present.
+
+2005-04-02 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
+
+ * lib/tkextlib/treectrl/tktreectrl.rb: support TreeCtrl's cvs head.
+
+2005-04-02 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
+
+ * lib/tkextlib/blt/component.rb: add TreeCtrl#legend_window_create().
+
+ * sample/tkextlib/blt/graph6.rb: use legend_window_create().
+
+ * lib/tkextlib/blt/tree.rb: forget to call tagid().
+
+ * lib/tkextlib/blt/treeview.rb: ditto.
+
+2005-04-01 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
+
+ * sample/tkextlib/treectrl/demo.rb: bridge the gap of
+ Hash#index or Hash#key between ruby 1.8 and 1.9
+
+2005-04-01 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
+
+ * lib/tkextlib/blt/component.rb: bug fix on treatment of
+ component objects.
+
+ * sample/tkextlib/blt/graph6.rb: a new sample script.
+
+2005-03-31 ocean <ocean@ruby-lang.org>
+
+ * sample/tkextlib/treectrl/demo.rb: should use Hash#index.
+
+ * sample/tkextlib/treectrl/demo.rb: TkImage was not
+ cached properly.
+
+ * sample/tkextlib/treectrl/random.rb: fixed typo.
+
+2005-03-31 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
+
+ * sample/tkextlib/iwidgets/sample/hierarchy.rb: show basename
+ only [ruby-dev:25970]
+
+ * sample/tkextlib/treectrl/demo.rb: add check for existence of
+ 'backgroundimage' option.
+
+ * sample/tkextlib/treectrl/bitmaps.rb: ditto.
+
+ * sample/tkextlib/treectrl/outlook-newgroup.rb: lack of '%I'
+ event callback argument.
+
+2005-03-31 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
+
+ * sample/tkextlib/iwidgets/sample/hierarchy.rb: fail to treat
+ Japanese (i18n?) filenames.
+
+2005-03-30 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
+
+ * sample/tkextlib/bwidget/tree.rb: use 'return' in the Proc object.
+
+ * sample/tkextlib/tkHTML/hv.rb: ditto.
+
+ * sample/tkextlib/tkHTML/ss.rb: ditto.
+
+ * sample/tkextlib/tktable/basic.rb: ditto.
+
+ * sample/tkextlib/tktable/command.rb: ditto.
+
+ * sample/tkextlib/tktable/debug.rb: ditto.
+
+ * sample/tkextlib/tktable/maxsize.rb: ditto.
+
+ * sample/tkextlib/treectrl/demo.rb: ditto.
+
+2005-03-29 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
+
+ * lib/tkextlib/blt/component.rb: cannot create elements except
+ default type of element.
+
+ * lib/tkextlib/blt/barchart.rb: ditto.
+
+ * lib/tkextlib/blt/graph.rb: ditto.
+
+ * lib/tkextlib/blt/stripchart.rb: ditto.
+
+ * lib/tkextlib/blt/component.rb: axis command option gets
+ proper object type of arguments.
+
+ * sample/tkextlib/blt/calendar.rb: new sample.
+
+ * sample/tkextlib/blt/pareto.rb: ditto.
+
+2005-03-28 ocean <ocean@ruby-lang.org>
+
+ * lib/tkextlib/iwidgets/notebook.rb: fixed typo.
+
+2005-03-26 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
+
+ * lib/tkextlib/blt.rb: add commands for zooming.
+
+ * lib/tkextlib/blt/bitmap.rb (new_with_name): add for using
+ given name.
+
+ * lib/tkextlib/blt/busy.rb: bug fix on Tk::BLT::Busy::Shild class.
+
+ * lib/tkextlib/blt/component.rb: typo fix.
+
+ * lib/tkextlib/blt/component.rb: fix lack of *_create methods
+
+ * lib/tkextlib/blt/component.rb: proper call on xaxis_* and so on.
+
+ * lib/tkextlib/blt/htext.rb: add TkVariable object to access
+ special Tcl variables.
+
+ * lib/tkextlib/treectrl/tktreectrl.rb: typo fix.
+
+ * lib/tkextlib/treectrl/tktreectrl.rb: proper treatment
+ of 'font' option of element_configure.
+
+ * lib/tkextlib/treectrl/tktreectrl.rb: bug fix on item_sort.
+
+ * lib/tkextlib/treectrl/tktreectrl.rb: add methods to
+ call TreeCtrl commands for bindings.
+
+ * sample/tkextlib/blt/*: add some sample scripts.
+
+ * sample/tkextlib/treectrl/*: add some sample scripts.
+
+2005-03-18 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
+
+ * lib/tkextlib/treectrl/tktreectrl.rb: bug fix and define some
+ classes for components of Tk::TreeCtrl
+
+2005-03-17 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
+
+ * lib/tkextlib/treectrl/tktreectrl.rb: call wrong method in
+ Tk::TreeCtrl#*_configinfo and current_*_configinfo method
+
+2005-03-16 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
+
+ * lib/tkextlib/SUPPORT_STATUS: change the status of TkImg
+
+ * lib/tkextlib/treectrl/tktreectrl.rb: bug fix and support
+ TkTreeCtrl-1.1
+
+ * lib/tkextlib/SUPPORT_STATUS: change the supported version of
+ TkTreeCtrl
+
+2005-03-15 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
+
+ * sample/tkextlib/tkimg: add sample
+
+2005-03-06 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
+
+ * lib/tkextlib/SUPPORT_STATUS: add version info of each extension
+
+2005-03-05 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
+
+ * lib/tkextlib/tile.rb: lack of "autoload TProgressbar"
+
+2005-03-05 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
+
+ * lib/tkextlib/tile.rb: support tile-0.6
+
+ * lib/tkextlib/tile/tbutton.rb: ditto
+
+ * lib/tkextlib/tile/tcheckbutton.rb: ditto
+
+ * lib/tkextlib/tile/tlabel.rb: ditto
+
+ * lib/tkextlib/tile/tmenubutton.rb: ditto
+
+ * lib/tkextlib/tile/tnotebook.rb: ditto
+
+ * lib/tkextlib/tile/tradiobutton.rb: ditto
+
+ * lib/tkextlib/tile/tcombobox.rb: [new] ditto
+
+ * lib/tkextlib/tile/tentry.rb: [new] ditto
+
+ * lib/tkextlib/tile/tframe.rb: [new] ditto
+
+ * lib/tkextlib/tile/tlabelframe.rb: [new] ditto
+
+ * lib/tkextlib/tile/tprogressbar.rb: [new] ditto
+
+ * lib/tkextlib/tile/treeview.rb: [new] ditto
+
+ * lib/tkextlib/tile/tscrollbar.rb: [new] ditto
+
+ * lib/tkextlib/tile/tseparator.rb: [new] ditto
+
+ * lib/tkextlib/tile/tsquare.rb: [new] ditto
+
+2005-02-20 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
+
+ * lib/tkextlib/tclx/tclx.rb: warning TclX's 'signal' command.
+
+2005-01-25 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
+
+ * lib/tkextlib/blt/component.rb: bug fix. cannot accept
+ a callback ID string for a command argument. [ruby-dev:25479]
+
+ * lib/tkextlib/blt/tabset.rb: ditto
+
+ * lib/tkextlib/blt/treeview.rb: ditto
+
+ * lib/tkextlib/bwidget/labelentry.rb: ditto
+
+ * lib/tkextlib/bwidget/listbox.rb: ditto
+
+ * lib/tkextlib/bwidget/notebook.rb: ditto
+
+ * lib/tkextlib/bwidget/spinbox.rb: ditto
+
+ * lib/tkextlib/bwidget/tree.rb: ditto
+
+ * lib/tkextlib/itk/incr_tk.rb: ditto
+
+ * lib/tkextlib/iwidgets/scrolledcanvas.rb: ditto
+
+ * lib/tkextlib/tkDND/tkdnd.rb: ditto
+
+ * lib/tkextlib/treectrl/tktreectrl.rb: ditto
+
+ * sample/tkextlib/tkHTML/ss.rb: local variable scope bug fix
+ [ruby-dev:25479]
+
+ * sample/tkextlib/vu/vu_demo.rb: rename from vu.rb; avoid the bug on
+ Windows version of Tcl/Tk. The trouble based on the bug occurs when
+ the script name (without extension) is a same name as a Tcl/Tk's
+ library file name (without extension) required in the script.
+
+2004-12-24 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
+
+ * lib/tkextlib/blt: add BLT extension support
+
+2004-12-16 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
+
+ * lib/tkextlib/bwidget/labelentry.rb: use TkCore.callback_obj?()
+
+ * lib/tkextlib/bwidget/listbox.rb: ditto
+
+ * lib/tkextlib/bwidget/notebook.rb: ditto
+
+ * lib/tkextlib/bwidget/spinbox.rb: ditto
+
+ * lib/tkextlib/itk/incr_tk.rb: ditto
+
+ * lib/tkextlib/iwidgets/scrolledcanvas.rb: ditto
+
+ * lib/tkextlib/tkDND/tkdnd.rb: ditto
+
+ * lib/tkextlib/treectrl/tktreectrl.rb: ditto
+
+ * lib/tkextlib/winico/winico.rb: ditto
+
+2004-12-10 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
+
+ * lib/tkextlib/tile/style.rb: 'theme_use' method bug fix
+
+2004-12-08 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
+
+ * lib/tkextlib/bwidget/notebook.rb: raise method cannot return
+ the raised page.
+
+ * lib/tkextlib/bwidget/labelentry.rb: bind methods accept
+ subst_args + block
+
+ * lib/tkextlib/bwidget/listbox.rb: ditto
+
+ * lib/tkextlib/bwidget/notebook.rb: ditto
+
+ * lib/tkextlib/bwidget/spinbox.rb: ditto
+
+ * lib/tkextlib/bwidget/tree.rb: ditto
+
+ * lib/tkextlib/itk/incr_tk.rb: ditto
+
+ * lib/tkextlib/iwidgets/scrolledcanvas.rb: ditto
+
+ * lib/tkextlib/tkDND/tkdnd.rb: ditto
+
+ * lib/tkextlib/treectrl/tktreectrl.rb: ditto
+
+2004-11-26 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
+
+ * lib/tkextlib/bwidget/notebook.rb: uses epath
+
+ * lib/tkextlib/bwidget/widget.rb: ditto
+
+ * lib/tkextlib/tktable/tktable.rb: ditto
+
+ * lib/tkextlib/tcllib/cursor.rb: ditto, and bug fix
+
+2004-11-10 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
+
+ * lib/tkextlib/tile/style.rb: bug fix
+
+2004-11-07 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
+
+ * lib/tkextlib/iwidgets/scrolledcanvas.rb: bind-event methods
+ accept multi substitution arguments.
+
+ * lib/tkextlib/tktable/tktable.rb: ditto.
+
+ * lib/tkextlib/treectrl/tktreectrl.rb: ditto
+
+2004-11-03 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
+
+ * lib/tkextlib/SUPPORT_STATUS: BLT moves to 'plan to support'
+ from 'not determined'
+
+ * lib/tkextlib/itk/incr_tk.rb: __cget_cmd and __config_cmd are
+ private methods
+
+ * lib/tkextlib/tcllib/autoscroll.rb: extend TkCore
+
+ * lib/tkextlib/tcllib/cursor.rb: ditto.
+
+ * lib/tkextlib/tcllib/plotchart.rb: ditto.
+
+ * lib/tkextlib/tcllib/style.rb: ditto.
+
+ * lib/tkextlib/tile/style.rb: ditto.
+
+ * lib/tkextlib/tkDND/shape.rb: ditto.
+
+2004-10-24 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
+
+ * lib/tkextlib/bwidget/tree.rb: bug fix on Windows
+
+2004-10-16 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
+
+ * lib/tkextlib/tcllib/ico.rb: new library (Tk::Tcllib:ICO)
+
+ * lib/tkextlib/tcllib.rb: add Tk::Tcllib::ICO (based on tcllib 1.7)
+
+2004-10-06 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
+
+ * lib/tkextlib/bwidget.rb (BWidget.grab): bug fix
+
+ * lib/tkextlib/tcllib.rb: typo fix
+
+2004-07-28 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
+
+ * lib/tkextlib/add winico support
+
+2004-07-23 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
+
+ * lib/tkextlib/add TclX support (partially; infox command and
+ XPG/3 MsgCat only)
+
+2004-07-15 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
+
+ * bug fix
+
+ * support TkTable extension
+
+2004-07-12 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
+
+ * bug fix
+
+ * support Iwidgets extension
+
+2004-07-10 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
+
+ * bug fix
+
+ * add more part of [incr Widget] support (about 65%? are complete)
+
+ * use Tk::ValidateConfigure.__def_validcmd() method
+ (new function to define validatecommand methods easier)
+
+ * tcllib.rb : avoid the loading trouble that almost all part of
+ the extension is not available when some libraries are invalid.
+
+2004-07-09 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
+
+ * add some part of [incr Widget] support (about 50%? are complete)
+
+2004-07-07 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
+
+ * add [incr Tck], [incr Tk] support
+
+2004-07-06 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
+
+ * support BWidget extension
+
+ * add BWidget extension demo
+
+ * add ICONS extension demo
+
+ * many bug fix
+
+2004-07-01 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
+
+ * 1st release of tkextlib ( to support Tcl/Tk extensions )
diff --git a/jni/ruby/ext/tk/MANUAL_tcltklib.eng b/jni/ruby/ext/tk/MANUAL_tcltklib.eng
new file mode 100644
index 0000000..957e8ec
--- /dev/null
+++ b/jni/ruby/ext/tk/MANUAL_tcltklib.eng
@@ -0,0 +1,473 @@
+(tof)
+ 2005/07/05 Hidetoshi NAGAI
+
+This document discribes about the 'tcltklib' library. Although there
+is the 'tcltk' library (tcltk.rb) under this directory, no description
+in this document (because it is not maintained recently).
+
+==============================================================
+module TclTklib
+ : Defines methods to do operations which are independed on
+ : Tcl/Tk interpreters
+
+ module TclTkLib::EventFlag
+ : Defines flags to define target events on 'do_one_event' methods.
+ : When to give, please use bit-operator (e.g. WINDOW | DONT_WAIT).
+
+ [constants]
+ NONE
+ : Is 0. It means "there is no target". But on the real
+ : operation, it is same to ALL.
+
+ WINDOW
+ : 'window' event is processed.
+
+ FILE
+ : 'file' event is processed.
+
+ TIMER
+ : 'timer' event is processed.
+
+ IDLE
+ : 'idle' operation (e.g. 're-draw'; the operations when the
+ : other kinds of events doesn't occur) is processed.
+
+ ALL
+ : All kinds of events are processed.
+ : Same to 'WINDOW | FILE | TIMER | IDLE'.
+
+ DONT_WAIT
+ : Without this flag, 'do_one_event' waits the occurrence of
+ : a target event. With this flag, doesn't wait and returns
+ : false if there is no target event for processing.
+
+ module TclTkLib::VarAccessFlag
+ : Defines flags to give '_get_variable' and so on. When to give,
+ : please use bit-operator (e.g. GLOBAL_ONLY | LEAVE_ERR_MSG ).
+
+ [constants]
+ NONE
+ : Is 0. It means "set no flag".
+
+ GLOBAL_ONLY
+ : (site Tcl/Tk's man page)
+ : Under normal circumstances the procedures look up
+ : variables as follows: If a procedure call is active
+ : in interp, a variable is looked up at the current
+ : level of procedure call. Otherwise, a variable is
+ : looked up first in the current namespace, then in
+ : the global namespace. However, if this bit is set
+ : in flags then the variable is looked up only in the
+ : global namespace even if there is a procedure call
+ : active. If both GLOBAL_ONLY and NAMESPACE_ONLY are
+ : given, GLOBAL_ONLY is ignored.
+ :
+ : *** ATTENTION ***
+ : Tcl7.6 doesn't have namespaces. So NAMESPACE_ONLY
+ : is defined as 0, and then GLOBAL_ONLY is available
+ : even if flag is (GLOBAL_ONLY | NAMESPACE_ONLY).
+
+ NAMESPACE_ONLY
+ : (site Tcl/Tk's man page)
+ : Under normal circumstances the procedures look up
+ : variables as follows: If a procedure call is active
+ : in interp, a variable is looked up at the current
+ : level of procedure call. Otherwise, a variable is
+ : looked up first in the current namespace, then in
+ : the global namespace. However, if this bit is set
+ : in flags then the variable is looked up only in the
+ : current namespace even if there is a procedure call
+ : active.
+ :
+ : *** ATTENTION ***
+ : Tcl7.6 doesn't have namespaces. So NAMESPACE_ONLY
+ : is defined as 0.
+
+ LEAVE_ERR_MSG
+ : (site Tcl/Tk's man page)
+ : If an error is returned and this bit is set in flags,
+ : then an error message will be left in the interpreter's
+ : result, where it can be retrieved with Tcl_GetObjResult
+ : or Tcl_GetStringResult. If this flag bit isn't set then
+ : no error message is left and the interpreter's result
+ : will not be modified.
+
+ APPEND_VALUE
+ : (site Tcl/Tk's man page)
+ : If this bit is set then newValue is appended to the
+ : current value, instead of replacing it. If the variable
+ : is currently undefined, then this bit is ignored.
+
+ LIST_ELEMENT
+ : (site Tcl/Tk's man page)
+ : If this bit is set, then newValue is converted to a
+ : valid Tcl list element before setting (or appending
+ : to) the variable. A separator space is appended before
+ : the new list element unless the list element is going
+ : to be the first element in a list or sublist (i.e. the
+ : variable's current value is empty, or contains the
+ : single character ``{'', or ends in `` }'').
+
+ PARSE_VARNAME
+ : (site Tcl/Tk's man page)
+ : If this bit is set when calling _set_variable and so
+ : on, var_name argument may contain both an array and an
+ : element name: if the name contains an open parenthesis
+ : and ends with a close parenthesis, then the value
+ : between the parentheses is treated as an element name
+ : (which can have any string value) and the characters
+ : before the first open parenthesis are treated as the
+ : name of an array variable. If the flag PARSE_VARNAME
+ : is given, index_name argument should be 'nil' since the
+ : array and element names are taken from var_name.
+ :
+ : *** ATTENTION ***
+ : Tcl7.6 doesn't have this flag. So PARSE_VARNAME is
+ : defined as 0.
+
+ module TclTkLib::RELEASE_TYPE
+ : Defines release type number of Tcl/Tk
+
+ ALPHA
+ : ALPHA release
+
+ BETA
+ : BETA release
+
+ FINAL
+ : FINAL release
+
+ [module methods]
+ get_version()
+ : return an array of major, minor, release-type number,
+ : and patchlevel of current Tcl/Tk library.
+
+ mainloop(check_root = true)
+ : Starts the eventloop. If 'check_root' is true, this method
+ : doesn't return when a root widget exists.
+ : If 'check_root' is false, doesn't return by the other
+ : reasons than exceptions.
+
+ mainloop_thread?
+ : Returns whether the current thread executes the eventloop.
+ : If true, the eventloop is working on the current thread.
+ : If no eventloop is working, this method returns nil.
+ : And if the other thread executes the eventloop, returns false.
+ :
+ : *** ATTENTION ***
+ : When this methods returns false, it is dangerous to call a Tk
+ : interpreter directly.
+
+ mainloop_watchdog(check_root = true)
+ : On the normal eventloop, some kinds of callback operations
+ : cause deadlock. To avoid some of such deadlocks, this
+ : method starts an eventloop and a watchdog-thread.
+
+ do_one_event(flag = TclTkLib::EventFlag::ALL |
+ TclTkLib::EventFlag::DONT_WAIT)
+ : Do one event for processing. When processed an event,
+ : returns true.
+ : If NOT set DONT_WAIT flag, this method waits occurrence of
+ : a target event.
+ : If set DONT_WAIT flag and no event for processing, returns
+ : false immediately.
+ : If $SAFE >= 4, or $SAFE >= 1 and the flag is tainted,
+ : force to set DONT_WAIT flag.
+
+ set_eventloop_tick(timer_tick)
+ : Define the interval of thread-switching with an integer
+ : value of mili-seconds.
+ : Default timer_tick is 0. It means that thread-switching
+ : is based on the count of processed events.
+ : ( see 'set_eventloop_weight' method )
+ : However, if the eventloop thread is the only thread,
+ : timer_tick cannot be set to 0. If 0, then is set to 100 ms
+ : automatically (see NO_THREAD_INTERRUPT_TIME on tcltklib.c).
+ : On $SAFE >= 4, cannot call this method.
+
+ get_eventloop_tick
+ : Get current value of 'timer_tick'
+
+ set_no_event_wait(no_event_wait)
+ : Define sleeping time of the eventloop when two or more
+ : thread are running and there is no event for processing.
+ : Default value is 20 (ms).
+ : If the eventloop thread is the only thread, this value is
+ : invalid.
+ : On $SAFE >= 4, cannot call this method.
+
+ get_no_event_wait
+ : Get current value of 'no_event_wait'.
+
+ set_eventloop_weight(loop_max, no_event_tick)
+ : Define the weight parameters for the eventloop thread.
+ : That is invalid when the eventloop is the only thread.
+ : 'loop_max' is the max events for thread-switching.
+ : 'no_event_tick' is the increment value of the event count
+ : when no event for processing (And then, the eventloop thread
+ : sleeps 'no_event_wait' mili-seconds).
+ : 'loop_max == 800' and 'no_event_tick == 10' are default.
+ : On $SAFE >= 4, cannot call this method.
+
+ get_eventloop_weight
+ : Get current values of 'loop_max' and 'no_event_tick'.
+
+ mainloop_abort_on_exception=(bool)
+ : Define whether the eventloop stops on exception or not.
+ : If true (default value), stops on exception.
+ : If false, show a waring message but ignore the exception.
+ : If nil, no warning message and ignore the exception.
+ : This parameter is sometimes useful when multiple Tk
+ : interpreters are working. Because the only one eventloop
+ : admins all Tk interpreters, sometimes exception on a
+ : interpreter kills the eventloop thread. Even if such
+ : situation, when abort_on_exception == false or nil,
+ : the eventloop ignores the exception and continue to working.
+ : On $SAFE >= 4, cannot call this method.
+
+ mainloop_abort_on_exception
+ : Get current status of that.
+
+ num_of_mainwindows
+ : Returns the number of main-windows (root-widget).
+ : Because there is only one main-window for one Tk interpreter,
+ : the value is same to the number of interpreters which has
+ : available Tk functions.
+
+ _merge_tklist(str, str, ... )
+ : Get a Tcl's list string from arguments with a Tcl/Tk's
+ : library function. Each arguemnt is converted to a valid
+ : Tcl list element.
+
+ _conv_listelement(str)
+ : Convert the argument to a valid Tcl list element with
+ : Tcl/Tk's library function.
+
+ _toUTF8(str, encoding=nil)
+ _fromUTF8(str, encoding=nil)
+ : Call the function (which is internal function of Tcl/Tk) to
+ : convert to/from a UTF8 string.
+
+ _subst_UTF_backslash(str)
+ _subst_Tcl_backslash(str)
+ : Substitute backslash sequence with Tcl's rule (include \uhhhh;
+ : give a sixteen-bit hexadecimal value for Unicode character).
+ : _subst_Tcl_backslash method parses all backslash sequence.
+ : _subst_UTF_backslash method parses \uhhhh only.
+
+ encoding_system
+ encoding_system=(encoding)
+ : Get and set Tcl's system encoding.
+
+ encoding
+ encoding=(encoding)
+ : alias of encoding_system / encoding_system=
+ : ( probably, Ruby/Tk's tk.rb will override them )
+
+
+class TclTkIp
+ [class methods]
+ new(ip_name=nil, options='')
+ : Generate an instance of TclTkIp class.
+ : If 'ip_name' argument is given as a string, it is the name
+ : of the Tk interpreter which is shown by 'winfo interps'
+ : command.
+ : 'options' argument accepts a string which is the command
+ : line options of wish; such as '-geometry' or '-use'.
+ : The information is used to generate the root widget of the
+ : interpreter.
+ : ( e.g. TclTkIp.new('FOO', '-geometry 500x200 -use 0x2200009') )
+ : If is given nil or false for the 'option' argument, generates
+ : the Tcl interpreter without Tk library. Then the interpreter
+ : doesn't need GUI environment. Therefore, even if a window
+ : system doesn't exist or cannot be used, Ruby can control the
+ : Tcl interpreter and the extension libraries loaded on the
+ : interpreter.
+
+ [instance methods]
+ create_slave(name, safe=false)
+ : Create a slave interpreter.
+ : The parent of the interpreter is the receiver of this method.
+ : The name of the slave interpreter is given by 'name' argument.
+ : The 'safe' argument decides whether the slave interpreter is
+ : created as a safe interpreter or not. If true, create a safe
+ : interpreter. Default is false. However, if the parent
+ : interpreter is a safe interpreter, the created interpreter is
+ : a safe interpreter (ignore 'safe' argument value).
+ : If $SAFE >= 4, can create a safe interpreter only.
+
+ make_safe
+ : Make the interpreter to the safe interpreter, and returns
+ : self. If fail, raise RuntimeError.
+
+ safe?
+ : Check whether the interpreter is the safe interpreter.
+ : If is the safe interpreter, returns true.
+
+ allow_ruby_exit?
+ : Return the mode whether 'exit' function of ruby or 'exit'
+ : command of Tcl/Tk can quit the ruby process or not on the
+ : interpreter. If false, such a command quit the interpreter
+ : only.
+ : The default value for a master interpreter is true, and
+ : for a slave interpreter is false.
+
+ allow_ruby_exit=(mode)
+ : Change the mode of 'allow_ruby_exit?'.
+ : If $SAFE >= 4 or the interpreter is a "safe" interpreter,
+ : this is not permitted (raise an exception).
+
+ delete
+ : Delete the interpreter.
+ : The deleted interpreter doesn't accept command and then
+ : raise an exception.
+
+ deleted?
+ : Check whether the interpreter is already deleted.
+ : If deleted, returns true.
+
+ has_mainwindow?
+ : Check whether the interpreter has a MainWindow (root widget).
+ : If has, returns true. If doesn't, returns false.
+ : If IP is already deleted, returns nil.
+
+ restart
+ : Restart Tk part of the interpreter.
+ : Use this when you need Tk functions after destroying the
+ : root widget.
+ : On $SAFE >= 4, cannot call this method.
+
+ _eval(str)
+ _invoke(*args)
+ : Estimates the arguments as a command on the Tk interpreter.
+ : The argument of _eval is a script of Tcl/Tk.
+ : Each argument of _invoke is a token of one command line of
+ : Tcl/Tk.
+ : Because the operation of _invoke doesn't through the
+ : command line parser of Tk interpreter, the cost of
+ : estimation is smaller than _eval. However, auto_load
+ : mechanism of the Tk interpreter doesn't work on _invoke.
+ : So _invoke can call only the command which already
+ : registered on the interpreter by 'load' command and so on.
+ : On _eval command, auto_load mechanism words. So if succeed
+ : to _eval and register the command once, after that, the
+ : command can be called by _invoke.
+
+ _cancel_eval(str)
+ _cancel_eval_unwind(str)
+ : (Tcl/Tk8.6 or later)
+ : Call Tcl_CancelEval() function, and cancel evaluation.
+
+ _toUTF8(str, encoding=nil)
+ _fromUTF8(str, encoding=nil)
+ : Call the function (which is internal function of Tcl/Tk) to
+ : convert to/from a UTF8 string.
+
+ _thread_vwait(var_name)
+ _thread_tkwait(mode, target)
+ : 'vwait' or 'tkwait' with thread support.
+ : The difference from normal 'vwait' or 'tkwait' command is
+ : doing independent wait from the vwait stack when they are
+ : called on the other thread than the eventloop thread.
+ : In the case of Tcl/Tk's vwait / tkwait, if 2nd vwait /
+ : tkwait is called on waiting for 1st vwait / tkwait,
+ : returns the order of [2nd]->[1st] regardless of the order
+ : of when the wait condition was fulfilled.
+ : If _thread_vwait / _thread_tkwait is called on the
+ : eventloop thread, there is no difference from vwait /
+ : tkwait. But if called on the other thread than the
+ : eventloop, stops the thread. And when the wait condition
+ : is fulfilled, the thread restarts. The meaning of
+ : "independent from the vwait stack" is that the timing of
+ : restarting is independent from the waiting status of the
+ : other threads. That is, even if the eventloop thread is
+ : waiting by vwait and is not fulfilled the condition,
+ : _thread_vwait completes the waiting when its waiting
+ : condition is fulfilled and the thread which stopped by
+ : _thread_vwait can continue the operation.
+
+ _return_value
+ : Get the last result value on the interpreter.
+
+ _get_variable(var_name, flag)
+ _get_variable2(var_name, index_name, flag)
+ : Get the current value of a variable. If specified a
+ : index_name (see also the PARSE_VARNAME flag), get the
+ : value of the index_name element.
+
+ _set_variable(var_name, value, flag)
+ _set_variable2(var_name, index_name, value, flag)
+ : Create or modify a variable. If specified a index_name
+ : (see also the PARSE_VARNAME flag), create or modify the
+ : index_name element.
+
+ _unset_variable(var_name)
+ _unset_variable2(var_name, index_name)
+ : Remove a variable. If specified a index_name (see also
+ : the PARSE_VARNAME flag), remove the index_name element.
+
+ _get_global_var(var_name)
+ _get_global_var2(var_name, index_name)
+ _set_global_var(var_name, value)
+ _set_global_var2(var_name, index_name, value)
+ _unset_global_var(var_name)
+ _unset_global_var2(var_name, index_name)
+ : Call the associated method with the flag argument
+ : (GLOBAL_ONLY | LEAVE_ERR_MSG).
+
+ _split_tklist(str)
+ : Split the argument with Tcl/Tk's library function and
+ : get an array as a list of Tcl list elements.
+
+ _merge_tklist(str, str, ... )
+ : Get a Tcl's list string from arguments with a Tcl/Tk's
+ : library function. Each arguemnt is converted to a valid
+ : Tcl list element.
+
+ _conv_listelement(str)
+ : Convert the argument to a valid Tcl list element with
+ : Tcl/Tk's library function.
+
+ mainloop
+ mainloop_watchdog
+ : If on the slave interpreter, never start an eventloop and
+ : returns nil.
+ : With the exception that, same to the TclTkLib module method
+ : with the same name.
+
+ do_one_event
+ : With the exception that the argument is forced to set
+ : DONT_WAIT flag on the slave interpreter, same to
+ : TclTkLib#do_one_event.
+
+ set_eventloop_tick
+ get_eventloop_tick
+ set_no_event_wait
+ get_no_event_wait
+ set_eventloop_weight
+ get_eventloop_weight
+ mainloop_abort_on_exception
+ mainloop_abort_on_exception=
+ : With the exception that it is ignored to set value on the
+ : slave interpreter, same to the TclTkLib module method with
+ : the same name.
+
+ encoding_table
+ : For Ruby m17n. Return encoding relation table between Ruby's
+ : Encoding object and Tcl's encoding name.
+
+class TkCallbackBreak < StandardError
+class TkCallbackContinue < StandardError
+ : They are exception classes to break or continue the Tk callback
+ : operation.
+ : If raise TkCallbackBreak on the callback procedure, Ruby returns
+ : 'break' code to Tk interpreter (Then the Tk interpreter will
+ : break the operation for the current event).
+ : If raise TkCallbackContinue, returns 'continue' code (Then the Tk
+ : interpreter will break the operation for the current bindtag and
+ : starts the operation for the next bindtag for the current event).
+ : However, current tcltklib supports Ruby's 'break' and 'next' to
+ : get the same effect. That is, those classes are obsolete. Those
+ : exist for backward compatibility.
+
+(eof)
diff --git a/jni/ruby/ext/tk/MANUAL_tcltklib.ja b/jni/ruby/ext/tk/MANUAL_tcltklib.ja
new file mode 100644
index 0000000..1de1736
--- /dev/null
+++ b/jni/ruby/ext/tk/MANUAL_tcltklib.ja
@@ -0,0 +1,584 @@
+(tof)
+ 2005/07/05 Hidetoshi NAGAI
+
+本ドキュメントã«ã¯å¤ã„ tcltk ライブラリ,tcltklib ライブラリã®èª¬æ˜Ž
+ãŒå«ã¾ã‚Œã¦ã„ã¾ã™ãŒï¼Œãã®è¨˜è¿°å†…容ã¯å¤ã„ã‚‚ã®ã¨ãªã£ã¦ã„ã¾ã™ï¼Ž
+
+tcltk ライブラリ(tcltk.rb)ã¯ç¾åœ¨ã§ã¯ãƒ¡ãƒ³ãƒ†ãƒŠãƒ³ã‚¹ãŒäº‹å®Ÿä¸Šè¡Œã‚ã‚Œã¦
+ã„ãªã„ãŸã‚,å¤ã„ドキュメントã®èª¬æ˜ŽãŒãã®ã¾ã¾æœ‰åŠ¹ã§ã™ï¼Žãã‚Œã«å¯¾ã—,
+tcltklib ライブラリã«ã¤ã„ã¦ã¯ï¼Œç¾åœ¨ã® Ruby/Tk(tk.rb 以下ã®ãƒ©ã‚¤ãƒ–ラ
+リ群)を稼åƒã•ã›ã‚‹ãŸã‚ã®ä¸­å¿ƒã¨ã—ã¦ãƒ¡ãƒ³ãƒ†ãƒŠãƒ³ã‚¹ã•ã‚Œã¦ã„ã‚‹ãŸã‚,少々
+é•ã„ãŒç”Ÿã˜ã¦ã„ã¾ã™ï¼Ž
+
+ãã“ã§ï¼Œã¾ãšå¤ã„説明文書を示ã—ãŸå¾Œï¼Œç¾åœ¨ã® tcltklib ライブラリã«ã¤
+ã„ã¦ã®èª¬æ˜Žã‚’加ãˆã¾ã™ï¼Ž
+
+以下ãŒãƒ©ã‚¤ãƒ–ラリã®å¤ã„説明文書ã§ã™ï¼Ž
+==============================================================
+ MANUAL.euc
+ Sep. 19, 1997 Y. Shigehiro
+
+以下, 「tcl/tkã€ã¨ã„ã†è¡¨è¨˜ã¯, tclsh ã‚„ wish を実ç¾ã—ã¦ã„ã‚‹, 一般ã§ã„ã†
+ã¨ã“ã‚ã® tcl/tk を指ã—ã¾ã™. 「tcltk ライブラリã€, 「tcltklib ライブラ
+リã€ã¨ã„ã†è¡¨è¨˜ã¯, 本パッケージã«å«ã¾ã‚Œã‚‹ ruby 用ã®ãƒ©ã‚¤ãƒ–ラリを指ã—ã¾ã™.
+
+<< tcltk ライブラリ >>
+
+tcl/tk ã® C ライブラリを利用ã™ã‚‹ãŸã‚ã®é«˜(中?)水準インターフェースをæ
+ä¾›ã—ã¾ã™.
+
+ã“ã®ãƒ©ã‚¤ãƒ–ラリ㯠ruby ã‹ã‚‰ tcl/tk ライブラリを利用ã™ã‚‹ãŸã‚ã®ã‚‚ã®ã§, 内
+部㧠tcltklib ライブラリを利用ã—ã¦ã„ã¾ã™.
+
+[説明]
+
+tcl/tk インタプリタã§ã¯, ウィジェットã«ä½•ã‹æŒ‡ç¤ºã‚’é€ã‚‹ã«ã¯, ウィジェッ
+トåã«ç¶šã„ã¦ãƒ‘ラメータを書ãã¾ã™. ã—ãŸãŒã£ã¦, ウィジェットãŒã‚ªãƒ–ジェク
+トã§ã‚ã‚Š, ãã‚Œã«å¯¾ã—ã¦ãƒ¡ã‚½ãƒƒãƒ‰ã‚’é€ã£ã¦ã„ã‚‹, ã¨ã¿ãªã™ã“ã¨ãŒã§ãã¾ã™. ã•
+ã¦, tcl/tk インタプリタã§ã¯, 組ã¿è¾¼ã¿ã‚³ãƒžãƒ³ãƒ‰ã‚‚, å‰è¿°ã®ã‚¦ã‚£ã‚¸ã‚§ãƒƒãƒˆã¨
+åŒã˜ã‚ˆã†ãªæ›¸å¼ã®å‘½ä»¤ã§å®Ÿè¡Œã•ã‚Œã¾ã™. ã™ãªã‚ã¡, コマンドもオブジェクトã§
+ã‚ã‚‹ã¨è€ƒãˆã‚‹ã“ã¨ãŒã§ãã¾ã™.
+
+ã“ã®ã‚ˆã†ãªè€ƒãˆã«åŸºã¥ã, tcltk ライブラリã§ã¯, tcl/tk ã®ã‚³ãƒžãƒ³ãƒ‰ã‚„ウィ
+ジェットã«å¯¾å¿œã™ã‚‹ã‚ªãƒ–ジェクトを生æˆã—ã¾ã™. オブジェクトã«å¯¾ã™ã‚‹ãƒ¡ã‚½ãƒƒ
+ド呼ã³å‡ºã—ã¯, e() メソッドã«ã‚ˆã‚Šå®Ÿè¡Œã•ã‚Œã¾ã™. 例ãˆã°, tcl/tk ã® info
+コマンドã«å¯¾å¿œã™ã‚‹ ruby ã®ã‚ªãƒ–ジェクト㌠info ã¨ã„ã†åå‰ã§ã‚ã‚‹ã¨ã™ã‚‹ã¨,
+tcl/tk ã®
+ info commands
+ã¨ã„ã†å‘½ä»¤ã¯ tcltk ライブラリã§ã¯
+ info.e("commands")
+ã¨è¨˜è¿°ã•ã‚Œã¾ã™. ã¾ãŸ, 「.ã€ã¨ã„ã†ã‚¦ã‚£ã‚¸ã‚§ãƒƒãƒˆ (wish 実行時ã«è‡ªå‹•çš„ã«ç”Ÿ
+æˆã•ã‚Œã‚‹ãƒ«ãƒ¼ãƒˆã‚¦ã‚£ã‚¸ã‚§ãƒƒãƒˆ) ã«å¯¾å¿œã™ã‚‹ ruby ã®ã‚ªãƒ–ジェクト㌠root ã¨ã„
+ã†åå‰ã§ã‚ã‚‹ã¨ã™ã‚‹ã¨,
+ . configure -height 300 -width 300
+ã¨ã„ㆠtcl/tk ã®å‘½ä»¤ã¯
+ root.e("configure -height 300 -width 300")
+ã¨è¨˜è¿°ã•ã‚Œã¾ã™. ã“ã®ã‚ˆã†ãªè¨˜è¿°ã¯, 見ãŸã‚ã«ã¯ç¾Žã—ãã‚ã‚Šã¾ã›ã‚“ãŒ, ãã—ã¦,
+スクリプトを読む人ã«ã¯è¦‹ã¥ã‚‰ã„ã‹ã‚‚知れã¾ã›ã‚“ãŒ, 実際ã«ã‚¹ã‚¯ãƒªãƒ—トを書ã„
+ã¦ã¿ã‚‹ã¨äºˆæƒ³å¤–ã«æ‰‹è»½ã§ã™.
+
+[使用法]
+
+1. ライブラリを読ã¿è¾¼ã‚€.
+ require "tcltk"
+
+2. tcl/tk インタプリタを生æˆã™ã‚‹.
+ ip = TclTkInterpreter.new()
+
+3. tcl/tk ã®ã‚³ãƒžãƒ³ãƒ‰ã«å¯¾å¿œã™ã‚‹ã‚ªãƒ–ジェクトを変数ã«ä»£å…¥ã—ã¦ãŠã.
+ # コマンドã«å¯¾å¿œã™ã‚‹ã‚ªãƒ–ジェクトãŒå…¥ã£ãŸ Hash ã‚’å–り出ã™.
+ c = ip.commands()
+ # 使ã„ãŸã„コマンドã«å¯¾å¿œã™ã‚‹ã‚ªãƒ–ジェクトを個別ã®å¤‰æ•°ã«ä»£å…¥ã™ã‚‹.
+ bind, button, info, wm = c.indexes("bind", "button", "info", "wm")
+
+4. å¿…è¦ãªå‡¦ç†ã‚’è¡Œã†.
+ 詳ã—ãã¯, サンプルをå‚ç…§ã®ã“ã¨.
+
+5. 準備ãŒã§ããŸã‚‰, イベントループã«å…¥ã‚‹.
+ TclTk.mainloop()
+
+(( 以下, モジュール, クラス等ã®èª¬æ˜Žã‚’書ã予定.))
+
+
+
+<< tcltklib ライブラリ >>
+
+tcl/tk ã® C ライブラリを利用ã™ã‚‹ãŸã‚ã®ä½Žæ°´æº–インターフェースをæä¾›ã—ã¾
+ã™.
+
+コンパイル/実行ã«ã¯, tcl/tk ã® C ライブラリãŒå¿…è¦ã§ã™.
+
+[説明]
+
+ã“ã®ãƒ©ã‚¤ãƒ–ラリを用ã„ã‚‹ã¨, ruby ã‹ã‚‰ tcl/tk ã® C ライブラリを利用ã§ãã¾
+ã™. 具体的ã«ã¯, ruby インタプリタã‹ã‚‰ tcl/tk インタプリタを呼ã³å‡ºã™ã“
+ã¨ãŒã§ãã¾ã™. ã•ã‚‰ã«, ãã®(ruby インタプリタã‹ã‚‰å‘¼ã³å‡ºã—ãŸ) tcl/tk イ
+ンタプリタã‹ã‚‰, 逆㫠ruby インタプリタを呼ã³å‡ºã™ã“ã¨ã‚‚ã§ãã¾ã™.
+
+[使用法]
+
+require "tcltklib" ã™ã‚‹ã¨, 以下ã®ãƒ¢ã‚¸ãƒ¥ãƒ¼ãƒ«, クラスãŒåˆ©ç”¨å¯èƒ½ã§ã™.
+
+モジュール TclTkLib
+ tcl/tk ライブラリを呼ã³å‡ºã™ãƒ¡ã‚½ãƒƒãƒ‰ã‚’集ã‚ãŸãƒ¢ã‚¸ãƒ¥ãƒ¼ãƒ«ã§ã™. ãŸã ã—,
+ tcl/tk インタプリタ関係ã®ãƒ¡ã‚½ãƒƒãƒ‰ã¯ã‚¯ãƒ©ã‚¹ TclTkIp ã«ã‚ã‚Šã¾ã™.
+
+ モジュールメソッド mainloop()
+ Tk_MainLoop を実行ã—ã¾ã™. å…¨ã¦ã® tk ã®ã‚¦ã‚¤ãƒ³ãƒ‰ã‚¦ãŒç„¡ããªã‚‹ã¨çµ‚了
+ ã—ã¾ã™(例ãˆã°, tcl/tk ã§æ›¸ãã¨ã“ã‚ã® "destroy ." ã‚’ã—ãŸå ´åˆç­‰).
+ 引数: ç„¡ã—
+ 戻り値: nil
+
+クラス TclTkIp
+ インスタンス㌠tcl/tk ã®ã‚¤ãƒ³ã‚¿ãƒ—リタã«å¯¾å¿œã—ã¾ã™. tcl/tk ã®ãƒ©ã‚¤ãƒ–
+ ラリã®ä»•æ§˜é€šã‚Š, インスタンスを複数個生æˆã—ã¦ã‚‚æ­£ã—ã動作ã—ã¾ã™(ã
+ ã‚“ãªã“ã¨ã‚’ã™ã‚‹å¿…è¦ã¯ã‚ã¾ã‚Šç„¡ã„ã¯ãšã§ã™ãŒ). インタプリタ㯠wish ã®
+ tcl/tk コマンドを実行ã§ãã¾ã™. ã•ã‚‰ã«, 以下ã®ã‚³ãƒžãƒ³ãƒ‰ã‚’実行ã§ãã¾
+ ã™.
+ コマンド ruby
+ 引数を ruby ã§å®Ÿè¡Œã—ã¾ã™(ruby_eval_string を実行ã—ã¾ã™). 引数
+ 㯠1 ã¤ã§ãªã‘ã‚Œã°ãªã‚Šã¾ã›ã‚“. 戻り値㯠ruby ã®å®Ÿè¡Œçµæžœã§ã™.
+ ruby ã®å®Ÿè¡Œçµæžœã¯ nil ã‹ String ã§ãªã‘ã‚Œã°ãªã‚Šã¾ã›ã‚“.
+
+ クラスメソッド new()
+ TclTkIp クラスã®ã‚¤ãƒ³ã‚¹ã‚¿ãƒ³ã‚¹ã‚’生æˆã—ã¾ã™
+ 引数: ç„¡ã—
+ 戻り値 (TclTkIp): 生æˆã•ã‚ŒãŸã‚¤ãƒ³ã‚¹ã‚¿ãƒ³ã‚¹
+
+ メソッド _eval(script)
+ インタプリタ㧠script を評価ã—ã¾ã™(Tcl_Eval を実行ã—ã¾ã™). å‰è¿°
+ ã®ã‚ˆã†ã«, ruby コマンドã«ã‚ˆã‚Š script 内ã‹ã‚‰ ruby スクリプトを実
+ è¡Œã§ãã¾ã™.
+ 引数: script (String) - インタプリタã§è©•ä¾¡ã™ã‚‹ã‚¹ã‚¯ãƒªãƒ—ト文字列
+ 戻り値 (String): 評価çµæžœ ((Tcl_Interp *)->result)
+
+ メソッド _return_value()
+ ç›´å‰ã® Tcl_Eval ã®æˆ»ã‚Šå€¤ã‚’è¿”ã—ã¾ã™. 0(TCL_OK) ã§æ­£å¸¸çµ‚了ã§ã™.
+ 引数: ç„¡ã—
+ 戻り値 (Fixnum): ç›´å‰ã® Tcl_Eval() ãŒè¿”ã—ãŸå€¤.
+
+==============================================================
+
+以下ãŒæœ¬ãƒ‰ã‚­ãƒ¥ãƒ¡ãƒ³ãƒˆä½œæˆæ™‚点ã§ã® tcltklib ライブラリã®èª¬æ˜Žã§ã™ï¼Ž
+==============================================================
+モジュール TclTkLib
+ : 個々㮠Tcl/Tk インタープリタã«ä¾å­˜ã—ãªã„å‡¦ç† ( == イベントルー
+ : プã«é–¢ã™ã‚‹å‡¦ç† ) を呼ã³å‡ºã™ãƒ¡ã‚½ãƒƒãƒ‰ã‚’定義ã—ãŸãƒ¢ã‚¸ãƒ¥ãƒ¼ãƒ«ï¼Ž
+
+ モジュール TclTkLib::EventFlag
+ : do_one_event を呼ã³å‡ºã™éš›ã®å‡¦ç†å¯¾è±¡ã‚¤ãƒ™ãƒ³ãƒˆã‚’指定ã™ã‚‹ãŸã‚ã®
+ : フラグ ( WINDOW|DONT_WAIT ã¨ã„ã†ã‚ˆã†ã«ãƒ“ット演算å­ã§é€£çµã—ã¦
+ : 指定 ) を定数ã¨ã—ã¦å®šç¾©ã—ãŸãƒ¢ã‚¸ãƒ¥ãƒ¼ãƒ«ï¼Žä»¥ä¸‹ã®å®šæ•°ãŒå«ã¾ã‚Œã‚‹ï¼Ž
+
+ 定数 NONE
+ : 値㯠0 ã§ï¼Œå€¤ã¨ã—ã¦ã¯ã„ã‹ãªã‚‹ç¨®é¡žã®ã‚¤ãƒ™ãƒ³ãƒˆã‚‚指定ã—ã¦ã„ãªã„
+ : ã“ã¨ã«ãªã‚‹ãŒï¼Œå®Ÿéš›ã®å‡¦ç†ä¸Šã¯ ALL ã¨åŒã˜ã¨ã—ã¦æ‰±ã‚れる.
+
+ 定数 WINDOW
+ : window イベントを処ç†å¯¾è±¡ã¨ã™ã‚‹
+
+ 定数 FILE
+ : file イベントを処ç†å¯¾è±¡ã¨ã™ã‚‹
+
+ 定数 TIMER
+ : timer イベントを処ç†å¯¾è±¡ã¨ã™ã‚‹
+
+ 定数 IDLE
+ : ã‚¢ã‚¤ãƒ‰ãƒ«ãƒ«ãƒ¼ãƒ—å‡¦ç† ( å†æç”»ãªã©ï¼Œä»–ã®ç¨®é¡žã®ã‚¤ãƒ™ãƒ³ãƒˆãŒç™ºç”Ÿ
+ : ã—ã¦ã„ãªã„ã¨ãã«è¡Œã‚ã‚Œã‚‹å‡¦ç† ) を処ç†å¯¾è±¡ã¨ã™ã‚‹
+
+ 定数 ALL
+ : ã™ã¹ã¦ã®ç¨®é¡žã®ã‚¤ãƒ™ãƒ³ãƒˆã‚’処ç†å¯¾è±¡ã¨ã™ã‚‹
+ : WINDOW|FILE|TIMER|IDLE ã¨åŒã˜
+
+ 定数 DONT_WAIT
+ : 処ç†å¯¾è±¡ã‚¤ãƒ™ãƒ³ãƒˆãŒå­˜åœ¨ã—ãªã„å ´åˆã«ï¼Œã‚¤ãƒ™ãƒ³ãƒˆç™ºç”Ÿã‚’å¾…ãŸãš
+ : ã« do_one_event を終了 ( false を返㙠) ã™ã‚‹
+
+ モジュール TclTkLib::VarAccessFlag
+ : _get_variable ãªã©ã§ã®ãƒ•ãƒ©ã‚°ã‚’指定ã™ã‚‹ãŸã‚ã®ã‚‚ã®ï¼Žãƒ•ãƒ©ã‚°ã«
+ : ã¯ä»¥ä¸‹ã®å®šæ•°ã‚’ OR ã§é€£çµã—ã¦ä¸Žãˆã‚‹ï¼Ž
+
+ 定数 NONE
+ : 値㯠0 ã§ï¼Œä½•ã‚‚フラグを指定ã—ã¦ã„ãªã„ã®ã«ç­‰ã—ã„.
+
+ 定数 GLOBAL_ONLY
+ : 通常,変数ã®æ¤œç´¢ã¯ã¾ãšæ‰‹ç¶šã呼ã³å‡ºã—ã‚’è¡Œã£ãŸãƒ¬ãƒ™ãƒ«ã§æ¤œ
+ : ç´¢ã—,次ã«ç¾åœ¨ã®åå‰ç©ºé–“ã§æ¤œç´¢ï¼Œæœ€å¾Œã«ã‚°ãƒ­ãƒ¼ãƒãƒ«ç©ºé–“ã§
+ : 検索を行ã†ï¼Žã—ã‹ã—,ã“ã®ãƒ•ãƒ©ã‚°ãŒæŒ‡å®šã•ã‚ŒãŸå ´åˆã«ã¯ï¼Œã‚°
+ : ローãƒãƒ«ç©ºé–“ã§ã®ã¿æ¤œç´¢ã™ã‚‹ï¼Ž
+ : ã‚‚ã— GLOBAL_ONLY 㨠NAMESPACE_ONLY ã¨ãŒä¸¡æ–¹æŒ‡å®šã•ã‚ŒãŸå ´
+ : åˆã«ã¯ï¼ŒGLOBAL_ONLY ã®æŒ‡å®šã¯ç„¡è¦–ã•ã‚Œã‚‹ï¼Ž
+
+ 定数 NAMESPACE_ONLY
+ : ã“ã®ãƒ•ãƒ©ã‚°ãŒæŒ‡å®šã•ã‚ŒãŸå ´åˆã«ã¯ï¼Œç¾åœ¨ã®åå‰ç©ºé–“ã§ã®ã¿å¤‰
+ : æ•°ã®æ¤œç´¢ã‚’è¡Œã†ï¼ŽGLOBAL_ONLY ã®èª¬æ˜Žã‚‚å‚ç…§ã™ã‚‹ã“ã¨ï¼Ž
+
+ 定数 LEAVE_ERR_MSG
+ : 変数アクセスã«ãŠã„ã¦ã‚¨ãƒ©ãƒ¼ãŒç™ºç”Ÿã—ãŸå ´åˆï¼Œã“ã®ãƒ•ãƒ©ã‚°ãŒ
+ : 指定ã•ã‚Œã¦ã„ã‚Œã°ï¼Œå®Ÿè¡Œçµæžœã¨ã—㦠Tcl インタープリタã«ã‚¨
+ : ラーメッセージãŒæ®‹ã•ã‚Œã‚‹ï¼Žã“ã®ãƒ•ãƒ©ã‚°ãŒæŒ‡å®šã•ã‚Œã¦ã„ãªã‘
+ : ã‚Œã°ï¼Œã‚¨ãƒ©ãƒ¼ãƒ¡ãƒƒã‚»ãƒ¼ã‚¸ã¯ä¸€åˆ‡æ®‹ã•ã‚Œãªã„.
+
+ 定数 APPEND_VALUE
+ : ã“ã®ãƒ•ãƒ©ã‚°ãŒæŒ‡å®šã•ã‚Œã¦ã„ãŸå ´åˆï¼Œå¤‰æ•°ã®å€¤ã‚’ç½®ãæ›ãˆã®ã§
+ : ã¯ãªã,ç¾åœ¨ã®å€¤ã«ä»£å…¥å€¤ãŒè¿½åŠ  (append; 文字列連çµ) ã•
+ : れる.変数ãŒæœªå®šç¾©ã‚ã£ãŸå ´åˆï¼Œã“ã®ãƒ•ãƒ©ã‚°ã¯ç„¡è¦–ã•ã‚Œã‚‹ï¼Ž
+
+ 定数 LIST_ELEMENT
+ : ã“ã®ãƒ•ãƒ©ã‚°ãŒæŒ‡å®šã•ã‚Œã¦ã„ãŸå ´åˆï¼Œä»£å…¥å€¤ã¯ã¾ãš Tcl ã®ãƒªã‚¹
+ : トè¦ç´ ã¨ã—ã¦é©åˆ‡ã¨ãªã‚‹ã‚ˆã†ã«å¤‰æ›ã•ã‚Œã‚‹ï¼Žä»£å…¥å€¤ãŒãƒªã‚¹ãƒˆ
+ : (ã¾ãŸã¯ã‚µãƒ–リスト) ã®æœ€åˆã®è¦ç´ ã¨ãªã‚‹ã®ã§ãªã„é™ã‚Šï¼Œä»£å…¥
+ : 値ã®ç›´å‰ã«ã¯ç©ºç™½æ–‡å­—ãŒè¿½åŠ ã•ã‚Œã‚‹ï¼Ž
+
+ 定数 PARSE_VARNAME
+ : _set_variable ãªã©ã®å‘¼ã³å‡ºã—ã«ãŠã„ã¦ã“ã®ãƒ•ãƒ©ã‚°ãŒæŒ‡å®šã•
+ : ã‚Œã¦ã„ãŸå ´åˆï¼Œvar_name 引数ãŒé€£æƒ³é…列åã¨è¦ç´ åã¨ã‚’両方
+ : å«ã‚€å¯èƒ½æ€§ãŒã‚ã‚‹ (é–‹ã括弧をå«ã¿ï¼Œé–‰ã˜æ‹¬å¼§ã§çµ‚ã‚ã‚‹) ã“
+ : ã¨ã‚’示ã™ï¼Žãã®å ´åˆï¼Œæ‹¬å¼§ã®é–“ãŒè¦ç´ å指定,最åˆã®é–‹ã括
+ : 弧ã¾ã§ãŒé€£æƒ³é…列åã¨ã—ã¦æ‰±ã‚れる._set_variable2 ãªã©ã§
+ : ã“ã®ãƒ•ãƒ©ã‚°ã‚’指定ã™ã‚‹å ´åˆï¼Œé€£æƒ³é…列åã¨è¦ç´ å㯠var_name
+ : ã‹ã‚‰æŠ½å‡ºã•ã‚Œã‚‹ã¯ãšã§ã‚ã‚‹ã‹ã‚‰ï¼Œindex_name 引数㯠nil ã¨
+ : ã›ã­ã°ãªã‚‰ãªã„.
+
+ モジュール TclTkLib::RELEASE_TYPE
+ : Tcl/Tk ã®ãƒªãƒªãƒ¼ã‚¹ã‚¿ã‚¤ãƒ—番å·ã®å®šç¾©
+
+ 定数 ALPHA
+ : ALPHA リリース
+
+ 定数 BETA
+ : BETA リリース
+
+ 定数 FINAL
+ : FINAL リリース
+
+ モジュールメソッド
+ get_version()
+ : Tcl/Tk ã® major, minor, release-type 番å·, patchlevel ã‚’
+ : é…列ã«ã—ã¦è¿”ã™ï¼Ž
+
+ mainloop(check_root = true)
+ : イベントループを起動ã™ã‚‹ï¼Žcheck_root ㌠true ã§ã‚ã‚Œã°ï¼Œ
+ : root widget ãŒå­˜åœ¨ã™ã‚‹é™ã‚Šï¼Œã“ã®ãƒ¡ã‚½ãƒƒãƒ‰ã¯çµ‚了ã—ãªã„.
+ : check_root ㌠false ã®å ´åˆã¯ï¼Œroot widget ãŒæ¶ˆæ»…ã—ã¦ã‚‚
+ : ã“ã®ãƒ¡ã‚½ãƒƒãƒ‰ã¯çµ‚了ã—ãªã„ ( root widget ãŒæ¶ˆæ»…ã—ã¦ã‚‚,
+ : WINDOW 以外ã®ã‚¤ãƒ™ãƒ³ãƒˆã¯ç™ºç”Ÿã—ã†ã‚‹ãŸã‚ ).終了ã«ã¯ï¼Œå¤–部
+ : ã‹ã‚‰ã®åƒã掛㑠( スレッドを活用ã™ã‚‹ãªã© ) ãŒå¿…è¦ï¼Ž
+
+ mainloop_thread?
+ : カレントスレッドãŒã‚¤ãƒ™ãƒ³ãƒˆãƒ«ãƒ¼ãƒ—を実行ã—ã¦ã„るスレッド
+ : ã‹ã©ã†ã‹ã‚’è¿”ã™ï¼Ž
+ : イベントループを実行ã—ã¦ã„るスレッドã§ã‚れ㰠true を,
+ : ã©ã®ã‚¹ãƒ¬ãƒƒãƒ‰ã§ã‚‚イベントループãŒå®Ÿè¡Œã•ã‚Œã¦ã„ãªã„å ´åˆã¯
+ : nil を,他ã®ã‚¹ãƒ¬ãƒƒãƒ‰ã§ã‚¤ãƒ™ãƒ³ãƒˆãƒ«ãƒ¼ãƒ—ãŒå®Ÿè¡Œã•ã‚Œã¦ã„ã‚‹å ´
+ : åˆã¯ false ã‚’è¿”ã™ï¼Ž
+ : false ã®éš›ã« Tk インタープリタを直接呼ã¶ã®ã¯å±é™ºã§ã‚る.
+
+ mainloop_watchdog(check_root = true)
+ : 通常ã®ã‚¤ãƒ™ãƒ³ãƒˆãƒ«ãƒ¼ãƒ—ã§ã¯ï¼Œã‚¤ãƒ™ãƒ³ãƒˆå‡¦ç†ã®å†…容ã«ã‚ˆã£ã¦ã¯
+ : デッドロックを引ãèµ·ã“ã™å¯èƒ½æ€§ãŒã‚ã‚‹ (例ãˆã°ã‚¤ãƒ™ãƒ³ãƒˆã«
+ : 対ã™ã‚‹ã‚³ãƒ¼ãƒ«ãƒãƒƒã‚¯å‡¦ç†ä¸­ã§ widget æ“作をã—,ãã®çµ‚了を
+ : å¾…ã¤ãªã©).ã“ã®ãƒ¡ã‚½ãƒƒãƒ‰ã¯ï¼Œãã†ã—ãŸãƒ‡ãƒƒãƒ‰ãƒ­ãƒƒã‚¯ã‚’回é¿ã™
+ : ã‚‹ãŸã‚ã®ç›£è¦–スレッド付ãã§ã‚¤ãƒ™ãƒ³ãƒˆãƒ«ãƒ¼ãƒ—ã‚’èµ·å‹•ã™ã‚‹
+ : ( 監視スレッドを生æˆã—ãŸå¾Œã«ã‚¤ãƒ™ãƒ³ãƒˆãƒ«ãƒ¼ãƒ—を実行ã™ã‚‹ ).
+ : 引数ã®æ„味㯠mainloop ã¨åŒã˜ã§ã‚る.
+
+ do_one_event(flag = TclTkLib::EventFlag::ALL |
+ TclTkLib::EventFlag::DONT_WAIT)
+ : 処ç†å¾…ã¡ã®ã‚¤ãƒ™ãƒ³ãƒˆ 1 個を実行ã™ã‚‹ï¼Ž
+ : イベントを処ç†ã—ãŸå ´åˆã¯ true ã‚’è¿”ã™ï¼Ž
+ : フラグ㧠DONT_WAIT を指定ã—ã¦ã„ãªã„å ´åˆï¼Œãƒ•ãƒ©ã‚°ã§å‡¦ç†å¯¾
+ : 象ã¨ãªã£ã¦ã„る種類ã®ã‚¤ãƒ™ãƒ³ãƒˆãŒç™ºç”Ÿã™ã‚‹ã¾ã§å¾…ã¡ç¶šã‘る.
+ : DONT_WAIT を指定ã—ã¦ã„ãŸå ´åˆï¼Œå‡¦ç†å¯¾è±¡ã‚¤ãƒ™ãƒ³ãƒˆãŒãªãã¦ã‚‚
+ : ã™ãã«çµ‚了㗠false ã‚’è¿”ã™ï¼Ž
+ : $SAFE >= 4 ã‹ï¼Œ$SAFE >= 1 ã‹ã¤ flag ãŒæ±šæŸ“ã•ã‚Œã¦ã„ã‚‹ãªã‚‰ã°
+ : flag ã«ã¯ DONT_WAIT ãŒå¼·åˆ¶çš„ã«ä»˜ã‘られる.
+
+ set_eventloop_tick(timer_tick)
+ : イベントループã¨åŒæ™‚ã«åˆ¥ã‚¹ãƒ¬ãƒƒãƒ‰ãŒç¨¼åƒã—ã¦ã„ã‚‹å ´åˆã«ï¼Œæ™‚
+ : é–“ã«åŸºã¥ã„ãŸå¼·åˆ¶çš„ãªã‚¹ãƒ¬ãƒƒãƒ‰ã‚¹ã‚¤ãƒƒãƒãƒ³ã‚°ã‚’ã©ã®ç¨‹åº¦ã®é »åº¦
+ : ( 時間間隔 ) ã§ç™ºç”Ÿã•ã›ã‚‹ã‹ã‚’ミリ秒å˜ä½ã®æ•´æ•°å€¤ã§æŒ‡å®šã™ã‚‹ï¼Ž
+ : 0 を指定ã™ã‚‹ã¨ï¼Œã“ã®å¼·åˆ¶çš„ãªã‚¹ã‚¤ãƒƒãƒãƒ³ã‚°ã¯è¡Œã‚ã‚Œãªã„.
+ : 標準ã§ã¯ 0 ã«è¨­å®šã•ã‚Œã¦ãŠã‚Šï¼Œã‚¤ãƒ™ãƒ³ãƒˆå‡¦ç†æ•°ã«åŸºã¥ãスイッ
+ : ãƒãƒ³ã‚°ã ã‘ãŒè¡Œã‚れる ( see set_eventloop_weight ).
+ : ãŸã ã—,稼åƒã—ã¦ã„るスレッドãŒã‚¤ãƒ™ãƒ³ãƒˆãƒ«ãƒ¼ãƒ—ã ã‘ã®å ´åˆï¼Œ
+ : timer_tick ã‚’ 0 ã«è¨­å®šã™ã‚‹ã“ã¨ã¯ã§ããªã„.もã—設定ã•ã‚Œã¦
+ : ã„ãŸã‚‰ï¼Œ100 ms ( see NO_THREAD_INTERRUPT_TIME ) ã«è‡ªå‹•è¨­
+ : 定ã•ã‚Œã‚‹ï¼Ž
+ : 詳細ãªèª¬æ˜Žã¯ç•¥ã™ãŒï¼Œã“れ㯠CPU パワーを節約ã—ã¤ã¤å®‰å…¨ã§
+ : 安定ã—ãŸå‹•ä½œã‚’実ç¾ã™ã‚‹ãŸã‚ã«å®Ÿè£…ã—ãŸä»•æ§˜ã§ã‚る.
+ : $SAFE >= 4 ã§ã¯å®Ÿè¡ŒãŒç¦æ­¢ã•ã‚Œã‚‹ï¼Ž
+
+ get_eventloop_tick
+ : timer_tick ã®ç¾åœ¨å€¤ã‚’è¿”ã™ï¼Ž
+
+ set_no_event_wait(no_event_wait)
+ : 複数ã®ã‚¹ãƒ¬ãƒƒãƒ‰ãŒç¨¼åƒã—ã¦ã„ã‚‹å ´åˆã§ï¼Œå‡¦ç†å¾…ã¡ã‚¤ãƒ™ãƒ³ãƒˆãŒå…¨
+ : ã存在ã—ãªã‹ã£ãŸéš›ã« sleep 状態ã«å…¥ã‚‹æ™‚間長を指定ã™ã‚‹ï¼Ž
+ : 稼åƒã‚¹ãƒ¬ãƒƒãƒ‰ãŒã‚¤ãƒ™ãƒ³ãƒˆãƒ«ãƒ¼ãƒ—ã ã‘ã®å ´åˆã«ã¯æ„味をãªã•ãªã„.
+ : デフォルトã®å€¤ã¯ 20 (ms)
+ : $SAFE >= 4 ã§ã¯å®Ÿè¡ŒãŒç¦æ­¢ã•ã‚Œã‚‹ï¼Ž
+
+ get_no_event_wait
+ : no_event_wait ã®ç¾åœ¨å€¤ã‚’è¿”ã™ï¼Ž
+
+ set_eventloop_weight(loop_max, no_event_tick)
+ : 複数ã®ã‚¹ãƒ¬ãƒƒãƒ‰ãŒç¨¼åƒã—ã¦ã„る際㫠Ruby/Tk ã®ã‚¤ãƒ™ãƒ³ãƒˆãƒ«ãƒ¼
+ : プã«å‰²ã‚Šå½“ã¦ã‚‹æ¯”é‡ã‚’定ã‚ã‚‹ãŸã‚ã®ãƒ‘ラメータを設定ã™ã‚‹ï¼Ž
+ : 稼åƒã‚¹ãƒ¬ãƒƒãƒ‰ãŒã‚¤ãƒ™ãƒ³ãƒˆãƒ«ãƒ¼ãƒ—ã ã‘ã®å ´åˆã«ã¯æ„味をãªã•ãªã„.
+ : 一度ã®ã‚¹ãƒ¬ãƒƒãƒ‰åˆ‡ã‚Šæ›¿ãˆã®é–“ã«å‡¦ç†ã™ã‚‹ã‚¤ãƒ™ãƒ³ãƒˆã®æœ€å¤§æ•°ã¨ï¼Œ
+ : 処ç†å¾…ã¡ã®ã‚¤ãƒ™ãƒ³ãƒˆãŒå­˜åœ¨ã—ãªã„éš›ã®åŠ ç®—æ•°ã¨ã‚’設定ã™ã‚‹ï¼Ž
+ : 処ç†å¾…ã¡ã‚¤ãƒ™ãƒ³ãƒˆãŒå­˜åœ¨ã—ãªã„å ´åˆã¯ no_event_wait ( see
+ : set_no_event_wait ) ã ã‘ã®é–“ sleep 状態ã«å…¥ã‚‹ï¼Ž
+ : デフォルトã§ã¯ãã‚Œãžã‚Œ 800 回㨠10 回,ã¤ã¾ã‚Šï¼Œ800 個ã®ã‚¤
+ : ベント (アイドルイベントをå«ã‚€) を処ç†ã™ã‚‹ã¨ã‹ï¼Œã‚¤ãƒ™ãƒ³ãƒˆ
+ : ãŒå…¨ã発生ã—ãªã„ã¾ã¾ã« 80 回ã®å‡¦ç†å¾…ã¡ã‚¤ãƒ™ãƒ³ãƒˆæ¤œæŸ»ãŒå®Œäº†
+ : ã™ã‚‹ã¨ã‹ã§ã‚«ã‚¦ãƒ³ãƒˆãŒ 800 以上ã«ãªã‚‹ã¨ã‚¹ãƒ¬ãƒƒãƒ‰ã‚¹ã‚¤ãƒƒãƒãƒ³ã‚°
+ : ãŒç™ºç”Ÿã™ã‚‹ã“ã¨ã«ãªã‚‹ï¼Ž
+ : $SAFE >= 4 ã§ã¯å®Ÿè¡ŒãŒç¦æ­¢ã•ã‚Œã‚‹ï¼Ž
+
+ get_eventloop_weight
+ : ç¾åœ¨ã® loop_max 㨠no_event_tick ã¨ã®å€¤ã‚’è¿”ã™ï¼Ž
+ : ( see set_eventloop_wait )
+
+ mainloop_abort_on_exception=(bool)
+ : Tk インタープリタ上ã§ä¾‹å¤–を発生ã—ãŸéš›ã«ï¼Œã‚¤ãƒ™ãƒ³ãƒˆãƒ«ãƒ¼ãƒ—ã‚’
+ : エラーåœæ­¢ã•ã›ã‚‹ã‹ã©ã†ã‹ã‚’指定ã™ã‚‹ï¼Žtrue を指定ã—ãŸå ´åˆã¯
+ : エラーåœæ­¢ã™ã‚‹ãŒï¼Œfalse ã®å ´åˆã¯ä¾‹å¤–を無視ã—ã¦ã‚¤ãƒ™ãƒ³ãƒˆãƒ«ãƒ¼
+ : プを継続ã™ã‚‹ï¼Žã•ã‚‰ã« nil ã®å ´åˆã¯è­¦å‘Šãƒ¢ãƒ¼ãƒ‰ã§ãªã„é™ã‚Šã¯ã‚¨
+ : ラーメッセージã®å‡ºåŠ›ã™ã‚‰çœç•¥ã—ã¦ï¼Œä¾‹å¤–を無視ã™ã‚‹ï¼Ž
+ : デフォルトã§ã¯ true ã«è¨­å®šã•ã‚Œã¦ã„る.
+ : 1個ã®ã‚¤ãƒ³ã‚¿ãƒ¼ãƒ—リタã ã‘を使ã£ã¦ã„ã‚‹å ´åˆã«ã¯ã‚¨ãƒ©ãƒ¼æ™‚ã«ãã®
+ : ã¾ã¾åœæ­¢ã—ã¦ã‚‚通常ã¯å•é¡Œãªã„ãŒï¼Œè¤‡æ•°ã®ã‚¤ãƒ³ã‚¿ãƒ¼ãƒ—リタãŒåŒæ™‚
+ : ã«å‹•ä½œã—ã¦ã„ã‚‹å ´åˆã«ã¯ï¼Œãれらを管ç†ã™ã‚‹ã‚¤ãƒ™ãƒ³ãƒˆãƒ«ãƒ¼ãƒ—ã¯ï¼‘
+ : 個ã ã‘ã§ã‚ã‚‹ãŸã‚,ã„ãšã‚Œã‹ã®ã‚¤ãƒ³ã‚¿ãƒ¼ãƒ—リタã®ã‚¨ãƒ©ãƒ¼ãŒåŽŸå› ã§ï¼Œ
+ : ä»–ã®ã‚¤ãƒ³ã‚¿ãƒ¼ãƒ—リタã®å‡¦ç†ç¶™ç¶šãŒä¸å¯èƒ½ã«ãªã‚‹ã“ã¨ãŒã‚る.ãã®
+ : よã†ãªå ´åˆã§ã‚‚エラーを無視ã—ã¦ã‚¤ãƒ™ãƒ³ãƒˆãƒ«ãƒ¼ãƒ—ãŒç¨¼åƒã‚’続ã‘ã‚‹
+ : ã“ã¨ã§ï¼Œä»–ã®ã‚¤ãƒ³ã‚¿ãƒ¼ãƒ—リタãŒæ­£å¸¸ã«å‹•ä½œã—続ã‘ã‚‹ã“ã¨ãŒã§ãる.
+ : $SAFE >= 4 ã§ã¯å®Ÿè¡ŒãŒç¦æ­¢ã•ã‚Œã‚‹ï¼Ž
+
+ mainloop_abort_on_exception
+ : Tk インタープリタ上ã§ä¾‹å¤–を発生ã—ãŸéš›ã«ï¼Œã‚¤ãƒ™ãƒ³ãƒˆãƒ«ãƒ¼ãƒ—をエ
+ : ラーåœæ­¢ã•ã›ã‚‹ã‹ã©ã†ã‹ã®è¨­å®šçŠ¶æ…‹ã‚’ true/false ã§å¾—る.
+
+ num_of_mainwindows
+ : ç¾åœ¨ã®ãƒ¡ã‚¤ãƒ³ã‚¦ã‚£ãƒ³ãƒ‰ã‚¦ (ルートウィジェット) ã®æ•°ã‚’è¿”ã™ï¼Ž
+ : メインウィンドウã¯ä¸€ã¤ã®ã‚¤ãƒ³ã‚¿ãƒ¼ãƒ—リタã«ä»˜ã最大一ã¤ã§ã‚ã‚‹
+ : ã®ã§ï¼Œã“ã®å€¤ã¯ç¾åœ¨ Tk ã®æ©Ÿèƒ½ãŒæœ‰åŠ¹ã§ã‚るインタープリタã®ç·
+ : æ•°ã«ç­‰ã—ã„.
+
+ _merge_tklist(str, str, ... )
+ : Tcl/Tk ã®ãƒ©ã‚¤ãƒ–ラリ関数を使ã£ã¦ï¼Œå¼•æ•°ã®æ–‡å­—列ãŒãã‚Œãžã‚Œ
+ : æ­£ã—ã一ã¤ã®ãƒªã‚¹ãƒˆè¦ç´ ã¨ãªã‚‹ã‚ˆã†ã«é€£çµã—ãŸæ–‡å­—列を返ã™ï¼Ž
+
+ _conv_listelement(str)
+ : Tcl/Tk ã®ãƒ©ã‚¤ãƒ–ラリ関数を使ã£ã¦ï¼Œå¼•æ•°ã®æ–‡å­—列㌠Tcl ã®
+ : 一ã¤ã®ãƒªã‚¹ãƒˆè¦ç´ ã¨ã—ã¦é©åˆ‡ãªè¡¨ç¾ã«ãªã‚‹ã‚ˆã†ã«å¤‰æ›ã—ãŸæ–‡
+ : 字列を返ã™ï¼Ž
+
+ _toUTF8(str, encoding=nil)
+ _fromUTF8(str, encoding=nil)
+ : Tcl/Tk ãŒå†…蔵ã—ã¦ã„ã‚‹ UTF8 変æ›å‡¦ç†ã‚’呼ã³å‡ºã™ï¼Ž
+
+ _subst_UTF_backslash(str)
+ _subst_Tcl_backslash(str)
+ : Tcl ã®ãƒ«ãƒ¼ãƒ«ã§ãƒãƒƒã‚¯ã‚¹ãƒ©ãƒƒã‚·ãƒ¥è¨˜æ³• ( \uhhhh ã«ã‚ˆã‚‹
+ : Unicode 文字表ç¾ã‚’å«ã‚€ ) を解æžã™ã‚‹ï¼Ž
+ : _subst_Tcl_backslash ã¯ã™ã¹ã¦ã®ãƒãƒƒã‚¯ã‚¹ãƒ©ãƒƒã‚·ãƒ¥è¨˜æ³•ã‚’
+ : ç½®ãæ›ãˆã‚‹ã®ã«å¯¾ã—,_subst_UTF_backslash 㯠\uhhhh
+ : ã«ã‚ˆã‚‹ Unicode 文字表ç¾ã ã‘ã‚’ç½®ãæ›ãˆã‚‹ï¼Ž
+
+ encoding_system
+ encoding_system=(encoding)
+ : Tcl ã® system encoding ã®ç²å¾—ãŠã‚ˆã³è¨­å®š
+
+ encoding
+ encoding=(encoding)
+ : encoding_system / encoding_system= ã® alias
+ : ( Ruby/Tk ã® tk.rb ã§ã¯ç½®ãæ›ãˆã‚‰ã‚Œã‚‹äºˆå®šã®ã‚‚ã®ï¼Ž)
+
+
+クラス TclTkIp
+ クラスメソッド
+ new(ip_name=nil, options='')
+ : TclTkIp クラスã®ã‚¤ãƒ³ã‚¹ã‚¿ãƒ³ã‚¹ã‚’生æˆã™ã‚‹ï¼Ž
+ : ip_name ã«æ–‡å­—列を与ãˆãŸå ´åˆã¯ï¼Œãれ㌠winfo interps ãªã©ã§
+ : 表示ã•ã‚Œã‚‹åå‰ã«ãªã‚‹ï¼Ž
+ : options ã«ã¯ï¼Œ-geometry ã‚„ -use ãªã©ï¼Œwish ã®ã‚³ãƒžãƒ³ãƒ‰ãƒ©ã‚¤ãƒ³
+ : 引数ã¨ã—ã¦ä¸Žãˆã‚‹ã‚ªãƒ—ションã¨åŒæ§˜ã®æƒ…報を文字列ã¨ã—ã¦ä¸Žãˆã‚‹ï¼Ž
+ : 与ãˆã‚‰ã‚ŒãŸæƒ…å ±ã¯ï¼Œroot widget 生æˆã®éš›ã«ç”¨ã„られる.
+ : ( e.g. TclTkIp.new('FOO', '-geometry 500x200 -use 0x2200009') )
+ : ã‚‚ã— options ã«æ•¢ãˆã¦ nil ã¾ãŸã¯ false を与ãˆãŸå ´åˆï¼ŒTk ライ
+ : ブラリãŒå°Žå…¥ã•ã‚Œã¦ã„ãªã„ (ã¤ã¾ã‚Šã¯ Tcl ã®ã¿ã®) インタープリ
+ : タを生æˆã™ã‚‹ï¼Žã“ã®å ´åˆã¯ GUI 環境ã¯å¿…è¦ãªã„ãŸã‚,ウインドウ
+ : システムãŒå­˜åœ¨ã—ãªã„,ã¾ãŸã¯ä½¿ç”¨ã§ããªã„環境ã§ã‚‚ Tcl インター
+ : プリタを生æˆã—,Tcl ã‚„ãã®æ‹¡å¼µãƒ©ã‚¤ãƒ–ラリを活用ã™ã‚‹ã“ã¨ãŒã§ãる.
+
+ インスタンスメソッド
+ create_slave(name, safe=false)
+ : レシーãƒã‚’親ã¨ã™ã‚‹ name ã¨ã„ã†åå‰ã®ã‚¹ãƒ¬ãƒ¼ãƒ–インタープリタを
+ : 生æˆã™ã‚‹ï¼Ž
+ : safe ã«ã¯ç”Ÿæˆã™ã‚‹ã‚¤ãƒ³ã‚¿ãƒ¼ãƒ—リタを safe インタープリタã¨ã™ã‚‹
+ : ã‹ã‚’指定ã™ã‚‹ï¼Žãƒ‡ãƒ•ã‚©ãƒ«ãƒˆã¯ false ã¨ã„ã†ã“ã¨ã«ãªã£ã¦ã„ã‚‹ãŒï¼Œ
+ : ãŸã¨ãˆæ˜Žç¢ºã« false を指定ã—ã¦ã„ãŸã¨ã—ã¦ã‚‚,親ã¨ãªã‚‹ã‚¤ãƒ³ã‚¿ãƒ¼
+ : プリタ㌠safe インタープリタã§ã‚ã‚Œã°ï¼Œãã®è¨­å®šã‚’引ã継ã„ã§
+ : safe インタープリタã¨ã—ã¦ç”Ÿæˆã•ã‚Œã‚‹ï¼Ž
+ : $SAFE >= 4 ã§ã¯ï¼Œsafe インタープリタ以外ã®ç”ŸæˆãŒç¦æ­¢ã•ã‚Œã‚‹ï¼Ž
+
+ make_safe
+ : Tcl/Tk インタープリタを safe インタープリタã«å¤‰æ›´ã™ã‚‹ï¼Ž
+ : 戻り値ã¯ãƒ¬ã‚·ãƒ¼ãƒã§ã‚るインタープリタ自身ã§ã‚る.
+ : 失敗ã—ãŸå ´åˆã¯ RuntimeError ã®ä¾‹å¤–を発生ã™ã‚‹ï¼Ž
+
+ safe?
+ : Tcl/Tk インタープリタ㌠safe インタープリタã§ã‚ã‚‹ã‹ã‚’調ã¹ã‚‹ï¼Ž
+ : safe インタープリタã§ã‚れ㰠true ã‚’è¿”ã™ï¼Ž
+
+ allow_ruby_exit?
+ : 対象ã¨ãªã‚‹ã‚¤ãƒ³ã‚¿ãƒ¼ãƒ—リタ上ã®è©•ä¾¡ã§ï¼Œruby ã® exit 関数ã¾ãŸã¯
+ : Tcl/Tk 上㮠exit コマンドã«ã‚ˆã£ã¦ ruby 自体を終了ã•ã›ã‚‹ã“ã¨
+ : を許ã™ã‹ã©ã†ã‹ã‚’è¿”ã™ï¼Ž
+ : 許ã•ãªã„å ´åˆã¯å¯¾è±¡ã®ã‚¤ãƒ³ã‚¿ãƒ¼ãƒ—リタã ã‘ãŒçµ‚了ã™ã‚‹ï¼Ž
+ : マスターインタープリタã®ãƒ‡ãƒ•ã‚©ãƒ«ãƒˆå€¤ã¯ true,スレーブインター
+ : プリタã®ãƒ‡ãƒ•ã‚©ãƒ«ãƒˆå€¤ã¯ false ã§ã‚る.
+
+ allow_ruby_exit=(mode)
+ : 対象ã¨ãªã‚‹ã‚¤ãƒ³ã‚¿ãƒ¼ãƒ—リタ㮠allow_ruby_exit? ã®çŠ¶æ…‹ã‚’変更ã™ã‚‹ï¼Ž
+ : $SAFE >= 4 ã¾ãŸã¯ã‚¤ãƒ³ã‚¿ãƒ¼ãƒ—リタ㌠safe インタープリタã®å ´åˆã¯
+ : 変更ãŒè¨±ã•ã‚Œãªã„ (例外を発生).
+
+ delete
+ : Tcl/Tk インタープリタを delete ã™ã‚‹ï¼Ž
+ : delete ã•ã‚ŒãŸã‚¤ãƒ³ã‚¿ãƒ¼ãƒ—リタã¯ï¼Œä»¥å¾Œä¸€åˆ‡ã®æ“作ãŒã§ããªããªã‚Šï¼Œ
+ : コマンドをé€ã£ã¦ã‚‚例外を発生ã™ã‚‹ã‚ˆã†ã«ãªã‚‹ï¼Ž
+
+ deleted?
+ : Tcl/Tk インタープリタãŒã™ã§ã« delete ã•ã‚Œã¦ã„ã‚‹ã‹ã‚’調ã¹ã‚‹ï¼Ž
+ : delete 済ã¿ã§ã‚³ãƒžãƒ³ãƒ‰ã‚’å—ã‘付ã‘ãªã„状態ã«ãªã£ã¦ã„ã‚‹ãªã‚‰ã°
+ : true ã‚’è¿”ã™ï¼Ž
+
+ has_mainwindow?
+ : Tcl/Tk インタープリタã«ãƒ¡ã‚¤ãƒ³ã‚¦ã‚£ãƒ³ãƒ‰ã‚¦ (root widget) ãŒ
+ : 存在ã™ã‚Œã° true を,存在ã—ãªã‘れ㰠false ã‚’è¿”ã™ï¼Ž
+ : インタープリタãŒæ—¢ã« delete 済ã¿ã§ã‚れ㰠nil ã‚’è¿”ã™ï¼Ž
+
+ restart
+ : Tcl/Tk インタープリタ㮠Tk 部分ã®åˆæœŸåŒ–,å†èµ·å‹•ã‚’è¡Œã†ï¼Ž
+ : 一旦 root widget を破壊ã—ãŸå¾Œã«å†åº¦ Tk ã®æ©Ÿèƒ½ãŒå¿…è¦ã¨
+ : ãªã£ãŸå ´åˆã«ç”¨ã„る.
+ : $SAFE >= 4 ã§ã¯å®Ÿè¡ŒãŒç¦æ­¢ã•ã‚Œã‚‹ï¼Ž
+
+ _eval(str)
+ _invoke(*args)
+ : Tcl/Tk インタープリタ上ã§è©•ä¾¡ã‚’è¡Œã†ï¼Ž
+ : _eval ã¯è©•ä¾¡ã‚¹ã‚¯ãƒªãƒ—トãŒä¸€ã¤ã®æ–‡å­—列ã§ã‚ã‚‹ã“ã¨ã«å¯¾ã—,
+ : _invoke ã¯è©•ä¾¡ã‚¹ã‚¯ãƒªãƒ—ト㮠token ã”ã¨ã«ä¸€ã¤ã®å¼•æ•°ã¨ãª
+ : るよã†ã«ä¸Žãˆã‚‹ï¼Ž
+ : _invoke ã®æ–¹ã¯ Tcl/Tk インタープリタã®å­—å¥è§£æžå™¨ã‚’用ã„
+ : ãªã„ãŸã‚,評価ã®è² è·ãŒã‚ˆã‚Šå°‘ãªãã¦ã™ã‚€ï¼ŽãŸã ã—,ãã®ä»£
+ : ã‚ã‚Šã« auto_load ã®ã‚ˆã†ãªæ©Ÿæ§‹ã¯åƒã‹ãšï¼Œload ç­‰ã«ã‚ˆã£ã¦
+ : Tcl/Tk インタープリタ上ã«æ—¢ã«ç™»éŒ²æ¸ˆã¿ã®ã‚³ãƒžãƒ³ãƒ‰ã—ã‹å‘¼
+ : ã³å‡ºã™ã“ã¨ãŒã§ããªã„.
+ : _eval ã§ã¯ auto_load 機構ãŒåƒããŸã‚,一度 _eval を実行
+ : ã—ã¦ç™»éŒ²ã«æˆåŠŸã—ã•ãˆã™ã‚Œã°ï¼Œä»¥é™ã¯ _invoke ã§ã‚‚利用ã§
+ : ãるよã†ã«ãªã‚‹ï¼Ž
+
+ _cancel_eval(str)
+ _cancel_eval_unwind(str)
+ : (Tcl/Tk8.6 or later)
+ : Tcl_CancelEval() 関数を呼ã³å‡ºã—,eval ã®å®Ÿè¡Œã‚’打ã¡åˆ‡ã‚‹ï¼Ž
+
+ _toUTF8(str, encoding=nil)
+ _fromUTF8(str, encoding=nil)
+ : Tcl/Tk ãŒå†…蔵ã—ã¦ã„ã‚‹ UTF8 変æ›å‡¦ç†ã‚’呼ã³å‡ºã™ï¼Ž
+
+ _thread_vwait(var_name)
+ _thread_tkwait(mode, target)
+ : スレッド対応㮠vwait ã‚ã‚‹ã„㯠tkwait 相当ã®ãƒ¡ã‚½ãƒƒãƒ‰ï¼Ž
+ : 通常㮠vwait ã‚ã‚‹ã„㯠tkwait コマンドã¨ç•°ãªã‚‹ã®ã¯ï¼Œã‚¤ãƒ™ãƒ³
+ : トループã¨ã¯ç•°ãªã‚‹ã‚¹ãƒ¬ãƒƒãƒ‰ã‹ã‚‰å‘¼ã³å‡ºã—ãŸå ´åˆã« vwait ç­‰ã®
+ : スタックã¨ã¯ç‹¬ç«‹ã«æ¡ä»¶ã®æˆç«‹å¾…ã¡ãŒãªã•ã‚Œã‚‹ã“ã¨ã§ã‚る.
+ : 通常㮠vwait / tkwait ã§ã¯ï¼Œvwait / tkwait (1) ã®å¾…ã¡ã®é€”
+ : 中ã§ã•ã‚‰ã« vwait / tkwait (2) ãŒå‘¼ã°ã‚ŒãŸå ´åˆï¼Œå¾…ã¡ã®å¯¾è±¡
+ : ã¨ãªã£ã¦ã„ã‚‹æ¡ä»¶ã®æˆç«‹é †åºãŒã©ã†ã‚れ,(2)->(1) ã®é †ã§å¾…ã¡
+ : を終了ã—ã¦æˆ»ã£ã¦ãる.
+ : _thread_vwait / _thread_tkwait ã¯ï¼Œã‚¤ãƒ™ãƒ³ãƒˆãƒ«ãƒ¼ãƒ—ã®ã‚¹ãƒ¬ãƒƒ
+ : ドã§å‘¼ã°ã‚ŒãŸå ´åˆã¯é€šå¸¸ã® vwait / tkwait ã¨åŒæ§˜ã«å‹•ä½œã™ã‚‹
+ : ãŒï¼Œã‚¤ãƒ™ãƒ³ãƒˆãƒ«ãƒ¼ãƒ—以外ã®ã‚¹ãƒ¬ãƒƒãƒ‰ã§å‘¼ã°ã‚ŒãŸå ´åˆã«ã¯ãã®ã‚¹
+ : レッドをåœæ­¢ã•ã›ã¦å¾…ã¡ã«å…¥ã‚Šï¼Œæ¡ä»¶ãŒæˆç«‹ã—ãŸæ™‚ã«ã‚¹ãƒ¬ãƒƒãƒ‰
+ : ã®å®Ÿè¡Œã‚’å†é–‹ã™ã‚‹ï¼Žã€Œvwait ç­‰ã®å¾…ã¡ã‚¹ã‚¿ãƒƒã‚¯ã¨ã¯ç‹¬ç«‹ã€ã¨ã„
+ : ã†æ„味ã¯ï¼Œã“ã®å†é–‹ã®ã‚¿ã‚¤ãƒŸãƒ³ã‚°ãŒä»–ã®ã‚¹ãƒ¬ãƒƒãƒ‰ã§ã®å¾…ã¡çŠ¶æ³
+ : ã¨ã¯ç„¡é–¢ä¿‚ã¨ã„ã†ã“ã¨ã§ã‚る.ã¤ã¾ã‚Šï¼Œã‚¤ãƒ™ãƒ³ãƒˆãƒ«ãƒ¼ãƒ—ç­‰ã®ä»–
+ : ã®ã‚¹ãƒ¬ãƒƒãƒ‰ã§ vwait ç­‰ã§å¾…ã¡ã®çŠ¶æ…‹ã«ã‚ã£ãŸã¨ã—ã¦ã‚‚ãã®å®Œäº†
+ : ã‚’å¾…ã¤ã“ã¨ãªã,自らã®å¾…ã¡æ¡ä»¶ãŒæˆç«‹æ¬¡ç¬¬ï¼Œå‡¦ç†ã‚’継続ã™ã‚‹
+ : ã“ã¨ã«ãªã‚‹ï¼Ž
+
+ _return_value
+ : ç›´å‰ã® Tcl/Tk 上ã§ã®è©•ä¾¡ã®å®Ÿè¡Œçµæžœã¨ã—ã¦ã®æˆ»ã‚Šå€¤ã‚’è¿”ã™ï¼Ž
+
+ _get_variable(var_name, flag)
+ _get_variable2(var_name, index_name, flag)
+ : Tcl/Tk 上㮠var ã¨ã„ã†å¤‰æ•°åã®å¤‰æ•°ã®å€¤ã‚’è¿”ã™ï¼Ž
+ : ã‚‚ã— index_name ãŒæŒ‡å®š (PARSE_VARNAME フラグã®èª¬æ˜Žã‚‚å‚ç…§)
+ : ã•ã‚ŒãŸå ´åˆã¯é€£æƒ³é…列 var_name ã® index_name ã®è¦ç´ ã‚’è¿”ã™ï¼Ž
+ : flag ã«ã¯å¤‰æ•°ã‚’検索ã™ã‚‹éš›ã®æ¡ä»¶ã‚’指定ã™ã‚‹ï¼Žflag ã«ä¸Žãˆã‚‹
+ : 値ã¯ãƒ¢ã‚¸ãƒ¥ãƒ¼ãƒ« TclTkLib::VarAccessFlag ã‚’å‚ç…§ã™ã‚‹ã“ã¨ï¼Ž
+
+ _set_variable(var_name, value, flag)
+ _set_variable2(var_name, index_name, value, flag)
+ : Tcl/Tk 上㮠var ã¨ã„ã†å¤‰æ•°åã®å¤‰æ•°ã«å€¤ã‚’設定ã™ã‚‹ï¼Ž
+ : ã‚‚ã— index_name ãŒæŒ‡å®š (PARSE_VARNAME フラグã®èª¬æ˜Žã‚‚å‚ç…§)
+ : ã•ã‚ŒãŸå ´åˆã¯é€£æƒ³é…列 var_name ã® index_name ã®è¦ç´ ã‚’設定
+ : ã™ã‚‹ï¼Ž
+ : flag ã«ã¯å¤‰æ•°ã‚’検索ã™ã‚‹éš›ã®æ¡ä»¶ã‚’指定ã™ã‚‹ï¼Žflag ã«ä¸Žãˆã‚‹
+ : 値ã¯ãƒ¢ã‚¸ãƒ¥ãƒ¼ãƒ« TclTkLib::VarAccessFlag ã‚’å‚ç…§ã™ã‚‹ã“ã¨ï¼Ž
+
+ _unset_variable(var_name)
+ _unset_variable2(var_name, index_name)
+ : Tcl/Tk 上㮠var_name ã¨ã„ã†å¤‰æ•°åã®å¤‰æ•°ã‚’消去ã™ã‚‹ï¼Ž
+ : ã‚‚ã— index_name ãŒæŒ‡å®š (PARSE_VARNAME フラグã®èª¬æ˜Žã‚‚å‚ç…§)
+ : ã•ã‚ŒãŸå ´åˆã¯é€£æƒ³é…列 var_name ã‹ã‚‰ index_name ã®è¦ç´ ã ã‘
+ : を消去ã™ã‚‹ï¼Ž
+
+ _get_global_var(var_name)
+ _get_global_var2(var_name, index_name)
+ _set_global_var(var_name, value)
+ _set_global_var2(var_name, index_name, value)
+ _unset_global_var(var_name)
+ _unset_global_var2(var_name, index_name)
+ : ãã‚Œãžã‚Œï¼Œå¯¾å¿œã™ã‚‹å¤‰æ•°ã‚¢ã‚¯ã‚»ã‚¹ãƒ¡ã‚½ãƒƒãƒ‰ã® flag ã«å¯¾ã—ã¦
+ : (GLOBAL_ONLY | LEAVE_ERR_MSG) を与ãˆãŸã‚‚ã®ï¼Ž
+
+ _split_tklist(str)
+ : Tcl/Tk ã®ãƒ©ã‚¤ãƒ–ラリ関数を使ã£ã¦ï¼Œæ–‡å­—列 str をリストã«
+ : 分割ã™ã‚‹ (文字列ã®é…列ã¨ã—ã¦è¿”ã™).
+
+ _merge_tklist(str, str, ... )
+ : Tcl/Tk ã®ãƒ©ã‚¤ãƒ–ラリ関数を使ã£ã¦ï¼Œå¼•æ•°ã®æ–‡å­—列ãŒãã‚Œãžã‚Œ
+ : æ­£ã—ã一ã¤ã®ãƒªã‚¹ãƒˆè¦ç´ ã¨ãªã‚‹ã‚ˆã†ã«é€£çµã—ãŸæ–‡å­—列を返ã™ï¼Ž
+
+ _conv_listelement(str)
+ : Tcl/Tk ã®ãƒ©ã‚¤ãƒ–ラリ関数を使ã£ã¦ï¼Œå¼•æ•°ã®æ–‡å­—列㌠Tcl ã®
+ : 一ã¤ã®ãƒªã‚¹ãƒˆè¦ç´ ã¨ã—ã¦é©åˆ‡ãªè¡¨ç¾ã«ãªã‚‹ã‚ˆã†ã«å¤‰æ›ã—ãŸæ–‡
+ : 字列を返ã™ï¼Ž
+
+ mainloop
+ mainloop_watchdog
+ : スレーブ IP ã®å ´åˆã«ã¯ã‚¤ãƒ™ãƒ³ãƒˆãƒ«ãƒ¼ãƒ—ã‚’èµ·å‹•ã›ãšã« nil ã‚’è¿”ã™ï¼Ž
+ : ãれ以外ã®ç‚¹ã§ã¯å¼•æ•°ã‚’å«ã‚㦠TclTkLib ã®åŒåメソッドã«åŒã˜ï¼Ž
+
+ do_one_event
+ : スレーブ IP ã®å ´åˆã«ã¯å¼•æ•°ã®ã‚¤ãƒ™ãƒ³ãƒˆãƒ•ãƒ©ã‚°ã« DONT_WAIT ãŒ
+ : 強制的ã«è¿½åŠ ã•ã‚Œã‚‹ (イベント待ã¡ã§ã‚¹ãƒªãƒ¼ãƒ—ã™ã‚‹ã“ã¨ã¯ç¦æ­¢).
+ : ãれ以外ã®ç‚¹ã§ã¯å¼•æ•°ã‚’å«ã‚㦠TclTkLib ã®åŒåメソッドã«åŒã˜ï¼Ž
+
+ set_eventloop_tick
+ get_eventloop_tick
+ set_no_event_wait
+ get_no_event_wait
+ set_eventloop_weight
+ get_eventloop_weight
+ mainloop_abort_on_exception
+ mainloop_abort_on_exception=
+ : スレーブ IP ã®å ´åˆã«ã¯å€¤ã®è¨­å®šãŒè¨±ã•ã‚Œãªã„ (無視ã•ã‚Œã‚‹).
+ : ãれ以外ã®ç‚¹ã§ã¯å¼•æ•°ã‚’å«ã‚㦠TclTkLib ã®åŒåメソッドã«åŒã˜ï¼Ž
+
+ encoding_table
+ : Ruby m17n 用㫠Ruby 㨠Tk ã¨ã®é–“ã® encoding 対応表を返ã™ï¼Ž
+
+クラス TkCallbackBreak < StandardError
+クラス TkCallbackContinue < StandardError
+ : ã“れらã¯ã‚¤ãƒ™ãƒ³ãƒˆã‚³ãƒ¼ãƒ«ãƒãƒƒã‚¯ã«ãŠã„ã¦ï¼Œã‚³ãƒ¼ãƒ«ãƒãƒƒã‚¯å‡¦ç†ã‚’é©åˆ‡ã«ä¸­
+ : æ–­ã—ãŸã‚Šï¼Œæ¬¡ã®ãƒã‚¤ãƒ³ãƒ‰ã‚¿ã‚°ã®ãƒã‚¤ãƒ³ãƒ‡ã‚£ãƒ³ã‚°å‡¦ç†ã«é€²ã‚ãŸã‚Šã™ã‚‹ã“ã¨
+ : ã‚’å¯èƒ½ã«ã™ã‚‹ãŸã‚ã®ä¾‹å¤–クラスã§ã‚る.
+ : コールãƒãƒƒã‚¯ã§ break ã‚„ continue を実ç¾ã™ã‚‹ãŸã‚ã«ã¯ï¼Œã‚³ãƒ¼ãƒ«ãƒãƒƒã‚¯
+ : ã§ã‚ã‚‹ Ruby 手続ã㌠Tcl/Tk インタープリタå´ã«é©åˆ‡ãªãƒªã‚¿ãƒ¼ãƒ³ã‚³ãƒ¼
+ : ドを返ã™å¿…è¦ãŒã‚る.Ruby ã®æ‰‹ç¶šããŒæ™®é€šã«å€¤ã‚’è¿”ã™ã®ã§ã¯ï¼Œãã‚ŒãŒæ™®
+ : 通ã®æˆ»ã‚Šå€¤ã§ã‚ã‚‹ã®ã‹å¦ã‹ã‚’区別ãŒã§ããªã„ãŸã‚,例外発生を利用ã—ãŸ
+ : 実装を行ã£ã¦ã„る.
+ : ãŸã ã—ç¾åœ¨ã§ã¯ï¼Œã‚³ãƒ¼ãƒ«ãƒãƒƒã‚¯æ‰‹ç¶šãã‚’ Ruby ã® break, next ã§çµ‚了ã™
+ : ã‚‹ã“ã¨ã§åŒç­‰ã®çµæžœã‚’å¾—ã‚‹ã“ã¨ãŒã§ãるよã†ã«ãªã£ã¦ã„る.ãれゆãˆï¼Œ
+ : ã“れらã¯å¿…è¦ãªã„ã‚‚ã®ã§ã¯ã‚ã‚‹ãŒï¼Œäº’æ›æ€§ã®ãŸã‚ã«æ®‹ã—ã¦ã‚る.
+
+(eof)
diff --git a/jni/ruby/ext/tk/Makefile b/jni/ruby/ext/tk/Makefile
new file mode 100644
index 0000000..8a43b96
--- /dev/null
+++ b/jni/ruby/ext/tk/Makefile
@@ -0,0 +1,150 @@
+# ***DUMMY MAKEFILE***
+
+SHELL = /bin/sh
+
+# V=0 quiet, V=1 verbose. other values don't work.
+V = 0
+Q1 = $(V:1=)
+Q = $(Q1:0=@)
+ECHO1 = $(V:1=@:)
+ECHO = $(ECHO1:0=@echo)
+NULLCMD = :
+
+#### Start of system configuration section. ####
+top_srcdir = $(topdir)/.
+srcdir = $(top_srcdir)/ext/tk
+topdir = ../..
+hdrdir = $(top_srcdir)/include
+arch_hdrdir = $(extout)/include/$(arch)
+PATH_SEPARATOR = :
+VPATH = $(srcdir):$(arch_hdrdir)/ruby:$(hdrdir)/ruby
+RUBYLIB =
+RUBYOPT = -
+prefix = $(DESTDIR)/usr/local
+rubysitearchprefix = $(rubylibprefix)/$(sitearch)
+rubyarchprefix = $(rubylibprefix)/$(arch)
+rubylibprefix = $(libdir)/$(RUBY_BASE_NAME)
+exec_prefix = $(prefix)
+vendorarchhdrdir = $(vendorhdrdir)/$(sitearch)
+sitearchhdrdir = $(sitehdrdir)/$(sitearch)
+rubyarchhdrdir = $(rubyhdrdir)/$(arch)
+vendorhdrdir = $(rubyhdrdir)/vendor_ruby
+sitehdrdir = $(rubyhdrdir)/site_ruby
+rubyhdrdir = $(includedir)/$(RUBY_VERSION_NAME)
+vendorarchdir = $(vendorlibdir)/$(sitearch)
+vendorlibdir = $(vendordir)/$(ruby_version)
+vendordir = $(rubylibprefix)/vendor_ruby
+sitearchdir = $(sitelibdir)/$(sitearch)
+sitelibdir = $(sitedir)/$(ruby_version)
+sitedir = $(rubylibprefix)/site_ruby
+rubyarchdir = $(rubylibdir)/$(arch)
+rubylibdir = $(rubylibprefix)/$(ruby_version)
+sitearchincludedir = $(includedir)/$(sitearch)
+archincludedir = $(includedir)/$(arch)
+sitearchlibdir = $(libdir)/$(sitearch)
+archlibdir = $(libdir)/$(arch)
+ridir = $(datarootdir)/$(RI_BASE_NAME)
+mandir = $(datarootdir)/man
+localedir = $(datarootdir)/locale
+libdir = $(exec_prefix)/lib
+psdir = $(docdir)
+pdfdir = $(docdir)
+dvidir = $(docdir)
+htmldir = $(docdir)
+infodir = $(datarootdir)/info
+docdir = $(datarootdir)/doc/$(PACKAGE)
+oldincludedir = $(DESTDIR)/usr/include
+includedir = $(prefix)/include
+localstatedir = $(prefix)/var
+sharedstatedir = $(prefix)/com
+sysconfdir = $(prefix)/etc
+datadir = $(datarootdir)
+datarootdir = $(prefix)/share
+libexecdir = $(exec_prefix)/libexec
+sbindir = $(exec_prefix)/sbin
+bindir = $(exec_prefix)/bin
+archdir = $(rubyarchdir)
+
+
+CC = gcc
+CXX = g++
+LIBRUBY = $(LIBRUBY_SO)
+LIBRUBY_A = lib$(RUBY_SO_NAME)-static.a
+LIBRUBYARG_SHARED = -Wl,-R$(libdir) -L$(libdir) -l$(RUBY_SO_NAME)
+LIBRUBYARG_STATIC = -Wl,-R$(libdir) -L$(libdir) -l$(RUBY_SO_NAME)-static
+empty =
+OUTFLAG = -o $(empty)
+COUTFLAG = -o $(empty)
+
+RUBY_EXTCONF_H =
+cflags = $(optflags) $(debugflags) $(warnflags)
+optflags = -O3 -fno-fast-math
+debugflags = -ggdb3
+warnflags = -Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wunused-variable -Wpointer-arith -Wwrite-strings -Wdeclaration-after-statement -Wimplicit-function-declaration -Wdeprecated-declarations -Wno-packed-bitfield-compat
+CCDLFLAGS = -fPIC
+CFLAGS = $(CCDLFLAGS) $(cflags) -fPIC $(ARCH_FLAG)
+INCFLAGS = -I. -I$(arch_hdrdir) -I$(hdrdir) -I$(srcdir) -I/usr/local/include -I/usr/local/include
+DEFS =
+CPPFLAGS = -DHAVE_RUBY_NATIVE_THREAD_P -DHAVE_RB_ERRINFO -DHAVE_RB_SAFE_LEVEL -DHAVE_RB_HASH_LOOKUP -DHAVE_RB_PROC_NEW -DHAVE_RB_OBJ_UNTRUST -DHAVE_RB_OBJ_TAINT -DHAVE_RB_SET_SAFE_LEVEL_FORCE -DHAVE_RB_SOURCEFILE -DHAVE_RB_THREAD_CHECK_TRAP_PENDING $(DEFS) $(cppflags)
+CXXFLAGS = $(CCDLFLAGS) $(cxxflags) $(ARCH_FLAG)
+ldflags = -L. -fstack-protector -rdynamic -Wl,-export-dynamic
+dldflags =
+ARCH_FLAG =
+DLDFLAGS = $(ldflags) $(dldflags) $(ARCH_FLAG)
+LDSHARED = $(CC) -shared
+LDSHAREDXX = $(CXX) -shared
+AR = ar
+EXEEXT =
+
+RUBY_INSTALL_NAME = $(RUBY_BASE_NAME)
+RUBY_SO_NAME = ruby
+RUBYW_INSTALL_NAME =
+RUBY_VERSION_NAME = $(RUBY_BASE_NAME)-$(ruby_version)
+RUBYW_BASE_NAME = rubyw
+RUBY_BASE_NAME = ruby
+
+arch = x86_64-linux
+sitearch = $(arch)
+ruby_version = 2.2.0
+ruby = $(topdir)/miniruby -I'$(topdir)' -I'$(top_srcdir)/lib' -I'$(extout)/$(arch)' -I'$(extout)/common'
+RUBY = $(ruby)
+ruby_headers = $(hdrdir)/ruby.h $(hdrdir)/ruby/ruby.h $(hdrdir)/ruby/defines.h $(hdrdir)/ruby/missing.h $(hdrdir)/ruby/intern.h $(hdrdir)/ruby/st.h $(hdrdir)/ruby/subst.h $(arch_hdrdir)/ruby/config.h
+
+RM = rm -f
+RM_RF = $(RUBY) -run -e rm -- -rf
+RMDIRS = rmdir --ignore-fail-on-non-empty -p
+MAKEDIRS = /bin/mkdir -p
+INSTALL = /usr/bin/install -c
+INSTALL_PROG = $(INSTALL) -m 0755
+INSTALL_DATA = $(INSTALL) -m 644
+COPY = cp
+TOUCH = exit >
+
+#### End of system configuration section. ####
+
+preload =
+CLEANFILES = mkmf.log config_list
+DISTCLEANFILES =
+
+all install static install-so install-rb: Makefile
+.PHONY: all install static install-so install-rb
+.PHONY: clean clean-so clean-static clean-rb
+
+
+clean-static::
+clean-rb-default::
+clean-rb::
+clean-so::
+clean: clean-so clean-static clean-rb-default clean-rb
+ -$(Q)$(RM) $(CLEANLIBS) $(CLEANOBJS) $(CLEANFILES) .*.time
+
+distclean-rb-default::
+distclean-rb::
+distclean-so::
+distclean-static::
+distclean: clean distclean-so distclean-static distclean-rb-default distclean-rb
+ -$(Q)$(RM) Makefile $(RUBY_EXTCONF_H) conftest.* mkmf.log
+ -$(Q)$(RM) core ruby$(EXEEXT) *~ $(DISTCLEANFILES)
+ -$(Q)$(RMDIRS) $(DISTCLEANDIRS) 2> /dev/null || true
+
+realclean: distclean
diff --git a/jni/ruby/ext/tk/README.1st b/jni/ruby/ext/tk/README.1st
new file mode 100644
index 0000000..4ffef34
--- /dev/null
+++ b/jni/ruby/ext/tk/README.1st
@@ -0,0 +1,19 @@
+If you want to use Ruby/Tk (tk.rb and so on), you must have tcltklib.so
+which is working correctly. When you have some troubles on compiling,
+please read README.tcltklib and README.ActiveTcl.
+Even if there is a tcltklib.so on your Ruby library directory, it will not
+work without Tcl/Tk libraries (e.g. libtcl8.4.so) on your environment.
+You must also check that your Tcl/Tk is installed properly.
+
+--------------------------------------------
+ ( the following is written in UTF-8 )
+
+Ruby/Tk (tk.rb ãªã©) を使ã„ãŸã„å ´åˆã«ã¯ï¼Œtcltklib.so ãŒæ­£ã—ãå‹•ã„ã¦ã„ãª
+ã‘ã‚Œã°ãªã‚Šã¾ã›ã‚“.コンパイル時ã«ä½•ã‹å•é¡ŒãŒç”Ÿã˜ãŸå ´åˆã¯ï¼ŒREADME.tcltklib
+ã‚„ README.ActiveTcl を見ã¦ãã ã•ã„.
+ãŸã¨ãˆ Ruby ã®ãƒ©ã‚¤ãƒ–ラリディレクトリ㫠tcltklib.so ãŒå­˜åœ¨ã—ã¦ã„ãŸã¨ã—ã¦
+も,実行環境㫠Tcl/Tk ライブラリ (libtcl8.4.so ãªã©) ãŒãªã‘ã‚Œã°æ©Ÿèƒ½ã—ã¾
+ã›ã‚“.Tcl/Tk ãŒæ­£ã—ãインストールã•ã‚Œã¦ã„ã‚‹ã‹ã‚‚ãƒã‚§ãƒƒã‚¯ã—ã¦ãã ã•ã„.
+
+==========================================================
+ Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
diff --git a/jni/ruby/ext/tk/README.ActiveTcl b/jni/ruby/ext/tk/README.ActiveTcl
new file mode 100644
index 0000000..990f612
--- /dev/null
+++ b/jni/ruby/ext/tk/README.ActiveTcl
@@ -0,0 +1,62 @@
+ActiveTcl is ActiveState's quality-assured distribution of Tcl.
+
+# see <http://www.activestate.com/Products/ActiveTcl/>
+# <http://www.tcl.tk/>
+
+First of all, please try to configure without any options.
+"extconf.rb" searches ActiveTcl as default action.
+If you have ActiveTcl and standard (or your own) Tcl/Tk on your
+environment and don't want to use ActiveTcl on your Ruby/Tk, please
+use --without-ActiveTcl option.
+
+When "extconf.rb" fails to find your ActiveTcl libraries, please try
+the followings.
+
+If you want to use ActiveTcl binary package as the Tcl/Tk libraries,
+please use the following configure options.
+
+ --with-ActiveTcl=<ActiveTcl_root>
+ ( When without argument; no <ActiveTcl_root>; only '--with-ActiveTcl',
+ it same to '--with-ActiveTcl=/opt/ActiveTcl*/lib' )
+
+ --with-tcl-dir=<ActiveTcl_root>
+ --with-tk-dir=<ActiveTcl_root>
+
+And use the followings if you need.
+
+ --with-tcllib=<libname>
+ --with-tklib=<libname>
+ --enable-tcltk-stubs
+
+For example, when you install ActiveTcl-8.4.x to '/usr/local/ActiveTcl',
+
+ configure --with-tcl-dir=/usr/local/ActiveTcl/ \
+ --with-tk-dir=/usr/local/ActiveTcl/ \
+ --with-tcllib=tclstub8.4 \
+ --with-tklib=tkstub8.4 \
+ --enable-tcltk-stubs
+
+It depends on your environment that you have to add the directory of
+ActiveTcl's libraries to your library path when execute Ruby/Tk.
+One of the way is to add entries to TCLLIBPATH environment variable,
+and one of the others add to LD_LIBRARY_PATH environment variable
+
+Probably, using TCLLIBPATH is better. The value is appended at the
+head of Tcl's 'auto_path' variable. You can see the value of the
+variable by using 'Tk::AUTO_PATH.value' or 'Tk::AUTO_PATH.list'.
+
+For example, on Linux, one of the ways is to use LD_LIBRARY_PATH
+environment variable.
+-------------------------------------------------------------------------
+ [bash]$ LD_LIBRARY_PATH=/usr/local/ActiveTcl/lib:$LD_LIBRARY_PATH \
+ ruby your-Ruby/Tk-script
+
+ [bash]$ LD_LIBRARY_PATH=/usr/local/ActiveTcl/lib:$LD_LIBRARY_PATH irb
+-------------------------------------------------------------------------
+Based on it, the Tcl interpreter changes auto_path variable's value.
+
+Then, you'll be able to use Tcl/Tk extension libraries included in the
+ActiveTcl package (e.g. call TkPackage.require('BWidget'), and then,
+use functions/widgets of BWidget extension).
+
+ Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
diff --git a/jni/ruby/ext/tk/README.fork b/jni/ruby/ext/tk/README.fork
new file mode 100644
index 0000000..c58d758
--- /dev/null
+++ b/jni/ruby/ext/tk/README.fork
@@ -0,0 +1,34 @@
+Ruby/Tk does NOT support forking the process on which Tk interpreter
+is running (unless NEVER control Tk interpreter under the forked child
+process). In the library 'tk.rb', a Tk interpreter is initialized.
+Therefore, if you want running Tk under a child process, please call
+"require 'tk'" in the child process.
+
+# If do fork and exec(<new Ruby/Tk>) on the child process, you can
+# control Ruby/Tk interpreter on the child process by 'send' command
+# of Tcl/Tk. About this, please see Tk.appsend and Tk.rb_appsend, or
+# 'remote-tk.rb' and the sample 'sample/remote-ip_sample.rb'.
+
+For example, the following sample1 will NOT work, and sample2 will
+work properly.
+
+---<sample1: NOT work>---------------------------------------
+require 'tk' ## init Tk interpreter under parent process
+
+exit! if fork ## exit parent process
+
+## child process
+TkButton.new(:text=>'QUIT', :command=>proc{exit}).pack
+Tk.mainloop
+-------------------------------------------------------------
+
+---<sample2: will work>--------------------------------------
+exit! if fork ## exit main process
+
+## child process
+require 'tk' ## init Tk interpreter under child process
+TkButton.new(:text=>'QUIT', :command=>proc{exit}).pack
+Tk.mainloop
+-------------------------------------------------------------
+
+ 2004/05/22 Hidetoshi NAGAI
diff --git a/jni/ruby/ext/tk/README.macosx-aqua b/jni/ruby/ext/tk/README.macosx-aqua
new file mode 100644
index 0000000..1563072
--- /dev/null
+++ b/jni/ruby/ext/tk/README.macosx-aqua
@@ -0,0 +1,67 @@
+
+ *** for MacOS X Aqua (Tcl/Tk Aqua) users ***
+
+First of all, please read README.tcltklib to use Tcl/Tk Aqua Framework.
+
+With Tcl/Tk Aqua libraries, current tcltklib somtimes freezes when
+using Aqua specific dialogs (e.g. Tk.messageBox).
+This is a known bug of Ruby-1.8.4 release.
+
+When you meet the trouble on your GUI, you'll be able to avoid the trouble
+by Tcl/Tk's traditional dialogs.
+If you want to do that, please call some of the following bits of script
+after "reqruie 'tk'".
+
+=================================================================
+# use a traditional dialog for Tk.chooseColor()
+Tk.ip_eval(<<'EOS')
+ proc ::tk_chooseColor {args} {
+ return [eval tk::dialog::color:: $args]
+ }
+EOS
+
+# use a traditional dialog for Tk.getOpenFile() and Tk.getMultipleOpenFile()
+Tk.ip_eval(<<'EOS')
+ proc ::tk_getOpenFile {args} {
+ if {$::tk_strictMotif} {
+ return [eval tk::MotifFDialog open $args]
+ } else {
+ return [eval ::tk::dialog::file:: open $args]
+ }
+ }
+EOS
+
+# use a traditional dialog for Tk.getSaveFile() and Tk.getMultipleSaveFile()
+Tk.ip_eval(<<'EOS')
+ proc ::tk_getSaveFile {args} {
+ if {$::tk_strictMotif} {
+ return [eval tk::MotifFDialog save $args]
+ } else {
+ return [eval ::tk::dialog::file:: save $args]
+ }
+ }
+EOS
+
+# use a traditional dialog for Tk.messageBox()
+Tk.ip_eval(<<'EOS')
+ proc ::tk_messageBox {args} {
+ return [eval tk::MessageBox $args]
+ }
+EOS
+
+# use a traditional dialog for Tk.chooseDirectory()
+Tk.ip_eval(<<'EOS')
+ proc ::tk_chooseDirectory {args} {
+ return [eval ::tk::dialog::file::chooseDir:: $args]
+ }
+EOS
+=================================================================
+
+Each of them replaces the platform specific dialog command to the
+traditional one.
+
+If you use some MultiTkIp objects, probably, you'll have to call the
+bits of script for each MultiTkIp object.
+
+--
+Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
diff --git a/jni/ruby/ext/tk/README.tcltklib b/jni/ruby/ext/tk/README.tcltklib
new file mode 100644
index 0000000..da343a4
--- /dev/null
+++ b/jni/ruby/ext/tk/README.tcltklib
@@ -0,0 +1,152 @@
+To compile 'tcltklib', you must have Tcl/Tk libraries on your environment.
+Although 'extconf.rb' script searches Tcl/Tk libraries and header files
+(as default, searches tclConfig.sh/tkConfig.sh and use the defintions on
+those; ActiveTcl has high priority on searching unless --without-ActiveTcl),
+sometimes fails to find them. And then, 'tcltklib' cannot be compiled. If
+Tcl/Tk libraries or header files are installed but are not found, you can
+give the information by arguments of the 'configure' script. Please give
+some or all of the following options.
+
+ --with-tk-old-extconf use old "extconf.rb" (default: false).
+ If current extconf.rb doesn't work properly
+ (or your install process is based on old
+ documant about Ruby/Tk install), please try
+ this option.
+
+ --with-ActiveTcl / --without-ActiveTcl
+ --with-ActiveTcl=<dir> search ActiveTcl libraries (default: true).
+ When true, try to find installed ActiveTcl.
+ When <dir> is given, use it as the ActiveTcl's
+ top directory (use <dir>/lib, and so on).
+ Old "extconf.rb" doesn't support this option.
+
+ --with-tk-shlib-search-path=<paths>
+ teach the paths for loading shared-libraries
+ to linker.
+ <paths> is a path list with the same format
+ as PATH environment variable.
+ This option may be experimental.
+ Old "extconf.rb" doesn't support this option.
+
+ --with-tcltkversion=<version>
+ --with-tcltkversion=<tclversion>,<tkversion>
+ force version of Tcl/Tk library
+ (e.g. libtcl8.4g.so & libtk8.4g.so ==> --with-tcltkversion=8.4g
+ libtcl8.4.so & libtk8.4g.so ==> --with-tcltkversion=8.4,8.4g)
+
+ --enable-tcl-h-ver-check/--disable-tcl-h-ver-check
+ --enable-tk-h-ver-check/--disable-tk-h-ver-check
+ enable or disable for checking MAJOR_VERSION and
+ MINOR_VERSION on tcl.h/tk.h whether match with
+ Tcl/Tk libraries' version or not.
+
+ --with-tcl-build-dir=<dir>
+ --with-tk-build-dir=<dir> If you want to compile with libraries on Tcl/Tk
+ build dir (still NOT installed), you must use
+ these options.
+ (e.g. --with-tcl-build-dir=./build/tcl8.5.9/unix)
+ When use these options, --with-tclConfig-dir and
+ --with-tkConfig-dir options are ignored (however,
+ --with-tclConfig-file and --with-tkConfig-file
+ options are still available).
+
+ --with-tclConfig-file=<file>/--without-tclConfig-file
+ --with-tkConfig-file=<file>/--without-tkConfig-file
+ file path of tclConfig.sh/tkConfig.sh, or don't
+ refer those.
+ If you want use non-standard filenames of config
+ files (e.g. tclConfig-static.sh), you must use
+ these options.
+
+ --with-tclConfig-dir=<dir>
+ --with-tkConfig-dir=<dir> the directory contains 'tclConfig.sh' and
+ 'tkConfig.sh'.
+ Current "extconf.rb" uses the information
+ on tclConfig.sh/tkConfig.rb, if possible.
+ Old "extconf.rb" doesn't support this option.
+
+ --with-tcllib=<libname> (e.g. libtcl8.4.so ==> --with-tcllib=tcl8.4)
+ --with-tklib=<libname> (e.g. libtk8.4.so ==> --with-tklib=tk8.4)
+
+ --enable-tcltk-stubs (if you force to enable stubs)
+ On old "extconf.rb", default is false.
+ On current "extconf.rb", default is true when
+ tclConfig.sh/tkConfig.sh have TCL_STUB_LIB_SPEC
+ /TK_STUB_LIB_SPEC, else default is false.
+
+ --with-tcl-dir=<path>
+ equal to "--with-tcl-include=<path>/include --with-tcl-lib=<path>/lib"
+
+ --with-tk-dir=<path>
+ equal to "--with-tk-include=<path>/include --with-tk-lib=<path>/lib"
+
+ --with-tcl-include=<dir> the directory contains 'tcl.h'
+ --with-tk-include=<dir> the directory contains 'tk.h'
+
+ --with-tcl-lib=<dir> the directory contains 'libtcl<version>.so'
+ --with-tk-lib=<dir> the directory contains 'libtk<version>.so'
+
+ --enable-mac-tcltk-framework (MacOS X) use Tcl/Tk framework
+ (Obsolete. Please use '--enable-tcltk-framework'.)
+
+ --enable-tcltk-framework use Tcl/Tk framework
+
+ --with-tcltk-framework=<dir> the directory contains Tcl/Tk framework;
+ "<dir>/Tcl.framework" and "<dir>/Tk.framework".
+ When this option is given, it is assumed that
+ --enable-tcltk-framework option is given also.
+
+ --with-tcl-framework-dir=<dir>
+ Tcl framework directory (e.g. "/Library/Frameworks/Tcl.framework")
+
+ --with-tk-framework-dir=<dir>
+ Tk framework directory (e.g. "/Library/Frameworks/Tk.framework")
+
+ --with-tcl-framework-header=<dir>
+ Tcl framework headers directory
+ (e.g. "/Library/Frameworks/Tcl.framework/Headers")
+
+ --with-tk-framework-header=<dir>
+ Tk framework headers directory
+ (e.g. "/Library/Frameworks/Tk.framework/Headers")
+
+
+ --with-X11 / --without-X11 use / not use the X Window System
+
+ --with-X11-dir=<path>
+ equal to "--with-X11-include=<path>/include --with-X11-lib=<path>/lib"
+
+ --with-X11-include=<dir> the directory contais X11 header files
+ --with-X11-lib=<dir> the directory contais X11 libraries
+
+
+If you forgot to give the options when do 'configure' on toplevel
+directory of Ruby sources, please try something like as the followings.
+
+ $ cd ext/tcltklib
+ $ rm Makefile
+ $ CONFIGURE_ARGS='--with-tcl-include=/usr/local/include/tcl8.4/ --with-tcllib=tcl8.4 --with-tklib=tk8.4' ruby extconf.rb
+
+
+ *** ATTENTION ***
+When your Tcl/Tk libraries are compiled with "pthread support",
+Ruby/Tk may cause "Hang-up" or "Segmentation Fault" frequently.
+If you have such a trouble, please try to use the '--enable-pthread'
+option of the 'configure' command and re-compile Ruby sources.
+It may help you to avoid this trouble. The following configure
+options may be useful.
+
+ --enable-tcl-thread/--disable-tcl-thread
+ --with-tclConfig-file=<path of 'tclConfig.sh'>
+ --with-tkConfig-file=<path of 'tkConfig.sh'>
+
+It is not need that 'tclConfig.sh' is a normal Tcl/Tk's tclConfig.sh.
+But the file is expected to include the line "TCL_THREADS=0" or "...=1".
+When no "TCL_THREADS=?" line, if Tcl version is 7.x or 8.0 which is
+given by "TCL_MAJOR_VERSION=?" line and "TCL_MINOR_VERSION=?" line,
+then --disable-tcl-thread is expected. Else, ignore the 'tclConfig.sh'.
+If --enable-tcl-thread or --disable-tcl-thread option is given, then
+--with-tclConfig-file option is ignored.
+
+==========================================================
+ Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
diff --git a/jni/ruby/ext/tk/config_list.in b/jni/ruby/ext/tk/config_list.in
new file mode 100644
index 0000000..143a7b5
--- /dev/null
+++ b/jni/ruby/ext/tk/config_list.in
@@ -0,0 +1,41 @@
+##############################################
+# configure options for Ruby/Tk
+# release date: 2011-06-05
+##############################################
+with tk-old-extconf
+with ActiveTcl
+with tk-shlib-search-path
+enable tcltk-stubs
+with tcltkversion
+enable tcl-h-ver-check
+enable tk-h-ver-check
+with tcl-build-dir
+with tk-build-dir
+with tcl-config
+with tk-config
+with tclConfig-dir
+with tkConfig-dir
+with tclConfig-file
+with tkConfig-file
+with tcllib
+with tklib
+with tcl-dir
+with tk-dir
+with tcl-include
+with tk-include
+with tcl-lib
+with tk-lib
+enable mac-tcltk-framework
+enable tcltk-framework
+with tcltk-framework
+with tcl-framework-dir
+with tk-framework-dir
+with tcl-framework-header
+with tk-framework-header
+with X11
+with X11-dir
+with X11-include
+with X11-lib
+enable pthread
+enable tcl-thread
+enable space-on-tk-libpath
diff --git a/jni/ruby/ext/tk/depend b/jni/ruby/ext/tk/depend
new file mode 100644
index 0000000..f7ba322
--- /dev/null
+++ b/jni/ruby/ext/tk/depend
@@ -0,0 +1,2 @@
+tcltklib.o: tcltklib.c $(hdrdir)/ruby.h $(topdir)/config.h $(hdrdir)/defines.h stubs.h
+stubs.o: stubs.c $(hdrdir)/ruby.h $(topdir)/config.h $(hdrdir)/defines.h stubs.h
diff --git a/jni/ruby/ext/tk/extconf.rb b/jni/ruby/ext/tk/extconf.rb
new file mode 100644
index 0000000..c6a2dd5
--- /dev/null
+++ b/jni/ruby/ext/tk/extconf.rb
@@ -0,0 +1,2094 @@
+##############################################################
+# extconf.rb for tcltklib
+# release date: 2010-07-30
+##############################################################
+require 'mkmf'
+
+TkLib_Config = {}
+TkLib_Config['search_versions'] =
+ # %w[8.9 8.8 8.7 8.6 8.5 8.4 8.3 8.2 8.1 8.0 7.6 4.2]
+ # %w[8.7 8.6 8.5 8.4 8.3 8.2 8.1 8.0]
+ # %w[8.7 8.6 8.5 8.4 8.0] # to shorten search steps
+ %w[8.6 8.5 8.4]
+
+TkLib_Config['unsupported_versions'] =
+ %w[8.8 8.7]
+
+TkLib_Config['major_nums'] = '87'
+
+
+##############################################################
+
+TkLib_Config['enable-shared'] = enable_config("shared")
+
+
+##############################################################
+# use old extconf.rb ?
+##############################################################
+if with_config('tk-old-extconf')
+ require File.join(File.dirname(__FILE__), 'old-extconf.rb')
+ exit
+end
+
+
+##############################################################
+# check configs
+##############################################################
+($cleanfiles ||= "") << 'config_list'
+config_list_file = 'config_list'
+config_list_file_source = File.join(File.dirname(__FILE__),'config_list.in')
+if !File.exist?(config_list_file) ||
+ File.ctime(config_list_file_source) > File.ctime(config_list_file)
+ old_config_list_file = config_list_file_source
+else
+ old_config_list_file = config_list_file
+end
+
+current_configs = {'with'=>{}, 'enable'=>{}}
+
+# setup keys by config_list.in
+IO.foreach(config_list_file_source){|line|
+ line.chomp!
+ line.lstrip!
+ next if line.empty? || line =~ /^\#/ #
+ mode, key, value = line.split(/\s+/, 3)
+ value ||= ""
+ current_configs[mode][key] = value rescue nil
+}
+
+# define current value of keys
+IO.foreach(old_config_list_file){|line|
+ line.chomp!
+ line.lstrip!
+ next if line.empty? || line =~ /^\#/ #
+ mode, key, value = line.split(/\s+/, 3)
+ value ||= ""
+ if current_configs[mode] && current_configs[mode].has_key?(key)
+ current_configs[mode][key] = value
+ end
+}
+
+update_flag = false
+current_configs['with'].each_key{|key|
+ if (value = with_config(key).to_s) != current_configs['with'][key]
+ update_flag = true
+ current_configs['with'][key] = value
+ end
+}
+current_configs['enable'].each_key{|key|
+ if (value = enable_config(key).to_s) != current_configs['enable'][key]
+ update_flag = true
+ current_configs['enable'][key] = value
+ end
+}
+
+# update current_configs
+if update_flag || !File.exist?(config_list_file)
+ open(config_list_file, 'w'){|fobj|
+ fobj.print("# values of current configure options (generated by extconf.rb)\n");
+ ['with', 'enable'].each{|mode|
+ current_configs[mode].each_key{|key|
+ fobj.print("#{mode} #{key} #{current_configs[mode][key]}\n")
+ }
+ }
+ }
+end
+
+if update_flag
+ puts "Configure options for Ruby/Tk may be updated."
+ puts "So, delete files which depend on old configs."
+ File.delete(*Dir.glob("*.#{CONFIG['DLEXT']}", File::FNM_CASEFOLD))
+ File.delete(*Dir.glob("*.#{$OBJEXT}", File::FNM_CASEFOLD))
+ File.delete('Makefile') rescue nil
+
+else
+ makefile = 'Makefile'
+ if File.exist?(makefile) &&
+ File.ctime(config_list_file) > File.ctime(makefile)
+ # no need to update Makefile
+ exit
+ end
+end
+
+
+##############################################################
+# fuctions
+##############################################################
+def is_win32?
+ /mswin|mingw|cygwin|bccwin/ =~ RUBY_PLATFORM
+end
+
+def is_macosx?
+ /darwin/ =~ RUBY_PLATFORM
+end
+
+def maybe_64bit?
+ /64|universal|s390x/ =~ RUBY_PLATFORM
+end
+
+def check_tcltk_version(version)
+ return [nil, nil] unless version.kind_of? String
+
+ tclver, tkver = version.split(',')
+ tclver = tclver.strip
+ return [tclver, tkver.strip] if tkver
+
+ dot = major = minor_dot = minor = plvl_dot = plvl = ext = nil
+ if tclver =~ /^(\d)(\.?)(\d)(\.?)(\d*)(.*)$/
+ major = $1; minor_dot = $2; minor = $3; plvl_dot = $4; plvl = $5; ext = $6
+ dot = ! minor_dot.empty?
+ if plvl_dot.empty? && ! plvl.empty?
+ minor << plvl
+ end
+ elsif tclver =~ /^(\d)(\.?)(\d?)(.*)$/
+ major = $1; minor_dot = $2; minor = $3; ext = $4
+ dot = ! minor_dot.empty?
+ else # unknown -> believe user
+ return [tclver, tkver]
+ end
+
+ # check Tcl7.6 / Tk4.2 ?
+ if major == "7" # Tcl7.6 ( not support Tclversion < 7.6 )
+ # Tk4.2
+ tkver = "4" + ((dot)? ".": "") + ((minor.empty)? "": "2") + ext
+ elsif major == "4" # Tk4.2 ( not support Tkversion < 4.2 )
+ # Tcl7.6
+ tkver = tclver
+ tclver = "7" + ((dot)? ".": "") + ((minor.empty)? "": "6") + ext
+ end
+
+ tkver = tclver unless tkver
+
+ [tclver, tkver]
+end
+
+def get_shlib_versions(major = 8, minor_max = 9, minor_min = 0, ext = "")
+ if tclcfg = TkLib_Config["tclConfig_info"]
+ major = tclcfg['TCL_MAJOR_VERSION'].to_i
+ minor_min = tclcfg['TCL_MINOR_VERSION'].to_i
+
+ elsif TkLib_Config["tcltkversion"]
+ tclver, tkver = TkLib_Config["tcltkversion"]
+ if tclver =~ /8\.?(\d)(.*)/
+ minor_min = $1.to_i
+ ext = $2
+ else
+ # unsupported version
+ return [""]
+ end
+ end
+
+ # if disable-stubs, version is fixed.
+ minor_max = minor_min unless TkLib_Config["tcltk-stubs"]
+
+ vers = []
+ minor_max.downto(minor_min){|minor|
+ vers << "#{major}.#{minor}#{ext}" unless ext.empty?
+ vers << "#{major}.#{minor}"
+ }
+
+ vers << ""
+end
+
+def get_shlib_path_head
+ path_head = []
+ path_dirs = []
+
+ if TkLib_Config["ActiveTcl"].kind_of?(String) # glob path
+ # path_head << TkLib_Config["ActiveTcl"]
+ path_head.concat Dir.glob(TkLib_Config["ActiveTcl"], File::FNM_CASEFOLD).sort.reverse
+ # path_dirs.concat Dir.glob(File.join(TkLib_Config["ActiveTcl"], 'lib'), File::FNM_CASEFOLD).sort.reverse
+ end
+
+ if CROSS_COMPILING
+ elsif is_win32?
+ if TkLib_Config["ActiveTcl"]
+ path_head.concat ["c:/ActiveTcl", "c:/Program Files/ActiveTcl",
+ "c:/Program Files (x86)/ActiveTcl"]
+ end
+ path_head.concat [
+ "c:/Tcl", "c:/Program Files/Tcl", "c:/Program Files (x86)/Tcl",
+ "/Tcl", "/Program Files/Tcl", "/Program Files (x86)/Tcl"
+ ]
+ path_head.uniq!
+ #path_head.each{|dir| path_dirs << dir.dup if File.directory? dir}
+ path_head.each{|dir| path_dirs << File.expand_path(dir) if File.directory? dir}
+
+ # for MinGW
+ ["/usr/local/lib64", "/usr/lib64", "/usr/local/lib", "/usr/lib"].each{|dir|
+ #path_dirs << dir if File.directory? dir
+ path_dirs << File.expand_path(dir) if File.directory? dir
+ }
+ path_dirs |= ENV['LIBRARY_PATH'].split(';').find_all{|dir| File.directory? dir}.map{|dir| File.expand_path(dir)} if ENV['LIBRARY_PATH']
+ path_dirs |= ENV['PATH'].split(';').find_all{|dir| File.directory? dir}.map{|dir| File.expand_path(dir)} if ENV['PATH']
+
+ else
+ [
+ '/opt', '/pkg', '/share',
+ '/usr/local/opt', '/usr/local/pkg', '/usr/local/share', '/usr/local',
+ '/usr/opt', '/usr/pkg', '/usr/share', '/usr/contrib', '/usr'
+ ].each{|dir|
+ next unless File.directory?(dir)
+
+ path_dirs << "#{dir}/lib64" if maybe_64bit?
+ path_dirs << "#{dir}/lib"
+ path_dirs << "#{dir}" unless Dir.glob("#{dir}/lib*.*", File::FNM_CASEFOLD).empty?
+
+ dirnames = []
+ if TkLib_Config["ActiveTcl"]
+ dirnames.concat ["ActiveTcl"]
+ end
+ dirnames.concat ["TclTk","Tcl_Tk","Tcl-Tk"]
+
+ dirnames.each{|name|
+ path_dirs << "#{dir}/#{name}" if File.directory?("#{dir}/#{name}")
+ path_head << "#{dir}/#{name}" unless Dir.glob("#{dir}/#{name}[-89_]*", File::FNM_CASEFOLD).empty?
+ }
+ }
+ end
+
+ unless TkLib_Config["space-on-tk-libpath"]
+ path_head.delete_if{|path| path =~ / /}
+ path_dirs.delete_if{|path| path =~ / /}
+ end
+
+ [path_head, path_dirs]
+end
+
+def find_macosx_framework
+ use_framework = is_macosx? && TkLib_Config["ActiveTcl"]
+
+ use_framework ||= (tcl_hdr = with_config("tcl-framework-header"))
+ use_framework ||= (tk_hdr = with_config("tk-framework-header"))
+ tcl_hdr = nil unless tcl_hdr.kind_of? String
+ tk_hdr = nil unless tk_hdr.kind_of? String
+ TkLib_Config["tcl-framework-header"] = tcl_hdr
+ TkLib_Config["tk-framework-header"] = tk_hdr
+
+ use_framework ||= (tcl_dir = with_config("tcl-framework-dir"))
+ tcl_dir = nil unless tcl_dir.kind_of? String
+ if !tcl_dir && tcl_hdr
+ # e.g. /Library/Frameworks/Tcl.framework/Headers
+ # ==> /Library/Frameworks/Tcl.framework
+ tcl_dir = File.dirname(tcl_hdr.strip.chomp('/'))
+ end
+ TkLib_Config["tcl-framework-dir"] = tcl_dir
+
+ use_framework ||= (tk_dir = with_config("tk-framework-dir"))
+ tk_dir = nil unless tk_dir.kind_of? String
+ if !tk_dir && tk_hdr
+ # e.g. /Library/Frameworks/Tk.framework/Headers
+ # ==> /Library/Frameworks/Tk.framework
+ tk_dir = File.dirname(tk_hdr.strip.chomp('/'))
+ end
+ TkLib_Config["tk-framework-dir"] = tk_dir
+
+ if tcl_dir && !tk_dir
+ tk_dir = File.join(File.dirname(tcl_dir), 'Tk.framework')
+ TkLib_Config["tk-framework-dir"] = tk_dir
+ elsif !tcl_dir && tk_dir
+ tcl_dir = File.join(File.dirname(tk_dir), 'Tcl.framework')
+ TkLib_Config["tcl-framework-dir"] = tcl_dir
+ end
+ if tcl_dir && tk_dir
+ TkLib_Config["tcltk-framework"] = File.dirname(tcl_dir) unless TkLib_Config["tcltk-framework"]
+ return [tcl_dir, tk_dir]
+ end
+
+ # framework is disabled?
+ if with_config("tcltk-framework") == false ||
+ enable_config("tcltk-framework") == false
+ return false
+ end
+
+ use_framework ||= (framework_dir = with_config("tcltk-framework"))
+ if framework_dir.kind_of? String
+ TkLib_Config["tcltk-framework"] = framework_dir.strip.chomp('/')
+ return [File.join(TkLib_Config["tcltk-framework"], 'Tcl.framework'),
+ File.join(TkLib_Config["tcltk-framework"], 'Tk.framework')]
+ end
+
+ unless enable_config("tcltk-framework", use_framework) ||
+ enable_config("mac-tcltk-framework", use_framework)
+ TkLib_Config["tcltk-framework"] = false
+ return false
+ end
+
+ paths = [
+ #"~/Library/Frameworks",
+ "/Library/Frameworks",
+ "/Network/Library/Frameworks", "/System/Library/Frameworks"
+ ]
+ paths.reverse! unless TkLib_Config["ActiveTcl"] # system has higher priority
+
+ paths.map{|dir| dir.strip.chomp('/')}.each{|dir|
+ next unless File.exist?(File.join(dir, "Tcl.framework", "Headers"))
+ next unless File.directory?(tcldir = File.join(dir, "Tcl.framework"))
+ next unless File.exist?(File.join(dir, "Tk.framework", "Headers"))
+ next unless File.directory?(tkdir = File.join(dir, "Tk.framework"))
+ TkLib_Config["tcltk-framework"] = dir
+ return [tcldir, tkdir]
+ }
+
+ nil
+end
+
+def collect_tcltk_defs(tcl_defs_str, tk_defs_str)
+ conflicts = [
+ 'PACKAGE_NAME', 'PACKAGE_TARNAME', 'PACKAGE_VERSION',
+ 'PACKAGE_STRING', 'PACKAGE_BUGREPORT'
+ ]
+
+ begin
+ # Ruby 1.9.x or later
+ arch_config_h = RbConfig.expand($arch_hdrdir + "/ruby/config.h")
+ if File.exist?(arch_config_h)
+ keys = []
+ IO.foreach(arch_config_h){|line|
+ if line =~ /^#define +([^ ]+)/
+ keys << $1
+ end
+ }
+ conflicts = keys
+ end
+ rescue
+ # ignore, use default
+ end
+
+ if tcl_defs_str
+ tcl_defs = tcl_defs_str.split(/ ?-D/).map{|s|
+ s =~ /^([^=]+)(.*)$/
+ [$1, $2]
+ }
+ else
+ tcl_defs = []
+ end
+
+ if tk_defs_str
+ tk_defs = tk_defs_str.split(/ ?-D/).map{|s|
+ s =~ /^([^=]+)(.*)$/
+ [$1, $2]
+ }
+ else
+ tk_defs = []
+ end
+
+ defs = tcl_defs | tk_defs
+
+ defs.delete_if{|name,value|
+ conflicts.include?(name) ||
+ ( (vtcl = tcl_defs.assoc(name)) && (vtk = tk_defs.assoc(name)) &&
+ vtcl != vtk )
+ }
+
+ defs.map{|ary| s = ary.join(''); (s.strip.empty?)? "": "-D" << s}
+end
+
+def parse_tclConfig(file)
+ # check tclConfig.sh/tkConfig.sh
+ tbl = Hash.new{|h,k| h[k] = ""}
+ return tbl unless file
+ IO.foreach(file){|line|
+ line.strip!
+ next if line !~ /^([^\#=][^=]*)=(['"]|)(.*)\2$/
+ key, val = $1, $3
+ tbl[key] = val.gsub(/\$\{([^}]+)\}/){|s|
+ subst = $1
+ (tbl[subst])? tbl[subst]: s
+ } rescue nil
+ }
+ tbl
+end
+
+def get_libpath(lib_flag, lib_spec)
+ # get libpath from {TCL,Tk}_LIB_FLAG and {TCL,Tk}_LIB_SPEC
+ lib_spec.gsub(/(#{lib_flag}|-L)/, "").strip
+end
+
+def get_tclConfig_dirs
+ config_dir = []
+
+ if CROSS_COMPILING
+ elsif is_win32?
+ if TkLib_Config["ActiveTcl"]
+ dirs = []
+ if TkLib_Config["ActiveTcl"].kind_of?(String)
+ dirs << File.join(TkLib_Config["ActiveTcl"], 'lib')
+ end
+ dirs.concat [
+ "c:/ActiveTcl*/lib", "c:/Tcl*/lib",
+ "c:/Program Files*/ActiveTcl*/lib", "c:/Program Files*/Tcl*/lib",
+ "/ActiveTcl*/lib", "/Tcl*/lib",
+ "/Program Files*/ActiveTcl*/lib", "/Program Files*/Tcl*/lib"
+ ]
+ else
+ dirs = [
+ "c:/Tcl*/lib", "c:/Program Files*/Tcl*/lib",
+ "/Tcl*/lib", "/Program Files*/Tcl*/lib"
+ ]
+ end
+ dirs = dirs.collect{|d| Dir.glob(d, File::FNM_CASEFOLD)}.flatten.uniq
+
+ dirs |= ENV['LIBRARY_PATH'].split(';') if ENV['LIBRARY_PATH']
+ dirs |= ENV['PATH'].split(';') if ENV['PATH']
+
+ exeext = RbConfig::CONFIG['EXEEXT']
+ ENV['PATH'].split(File::PATH_SEPARATOR).each{|dir|
+ dir.tr!(File::ALT_SEPARATOR, File::SEPARATOR) if File::ALT_SEPARATOR
+ next if Dir.glob(File.join(dir, "{tclsh,wish}*#{exeext}"), File::FNM_CASEFOLD).empty?
+ dirs << File.expand_path(File.join(dir, '..', 'lib'))
+ dirs << dir
+ # dirs << File.expand_path(File.join(dir, '..'))
+ }
+
+ unless TkLib_Config["space-on-tk-libpath"]
+ dirs.delete_if{|path| path =~ / /}
+ end
+
+ config_dir.concat(dirs.zip(dirs))
+
+ else
+ if framework = find_macosx_framework()
+ config_dir.unshift(framework)
+ end
+
+ if activeTcl = TkLib_Config['ActiveTcl']
+ # check latest version at first
+ if is_macosx?
+ base = File.expand_path(activeTcl)
+ config_dir << [
+ File.join(base, 'Tcl.framework'), File.join(base, 'Tk.framework')
+ ]
+
+ config_dir << [
+ File.join(base, 'Tcl.framework', 'Versions', 'Current'),
+ File.join(base, 'Tk.framework', 'Versions', 'Current')
+ ]
+
+ Dir.glob(File.join(base, 'Tcl.framework',
+ 'Versions', '*')).sort.reverse.each{|dir|
+ next if dir =~ /Current/
+ config_dir << [dir, dir.gsub(/Tcl/, 'Tk')]
+ }
+ else
+ config_dir.concat(Dir.glob(File.join(activeTcl, 'lib'), File::FNM_CASEFOLD).sort.reverse)
+ end
+ end
+
+ config_dir << RbConfig::CONFIG['libdir']
+
+ ((maybe_64bit?)? ['lib64', 'lib']: ['lib']).each{|dir|
+ config_dir.concat [
+ File.join(RbConfig::CONFIG['exec_prefix'], dir),
+ File.join(RbConfig::CONFIG['prefix'], dir),
+ "/usr/local/opt/#{dir}", "/usr/local/pkg/#{dir}",
+ "/usr/local/share/#{dir}", "/usr/local/#{dir}",
+ "/usr/opt/#{dir}", "/usr/pkg/#{dir}", "/usr/share/#{dir}",
+ "/usr/contrib/#{dir}", "/usr/#{dir}"
+ ]
+ }
+
+ config_dir.concat [
+ '/opt', '/pkg', '/share',
+ '/usr/local/opt', '/usr/local/pkg', '/usr/local/share', '/usr/local',
+ '/usr/opt', '/usr/pkg', '/usr/share', '/usr/contrib', '/usr'
+ ].map{|dir|
+ Dir.glob(dir + "/{tcltk,tcl,tk}[#{TkLib_Config['major_nums']}*/lib",
+ File::FNM_CASEFOLD)
+ Dir.glob(dir + "/{tcltk,tcl,tk}[#{TkLib_Config['major_nums']}*",
+ File::FNM_CASEFOLD)
+ Dir.glob(dir + '/{tcltk,tcl,tk}/lib', File::FNM_CASEFOLD)
+ Dir.glob(dir + '/{tcltk,tcl,tk}', File::FNM_CASEFOLD)
+ }.flatten!
+
+ exeext = RbConfig::CONFIG['EXEEXT']
+ ENV['PATH'].split(File::PATH_SEPARATOR).each{|dir|
+ dir.tr!(File::ALT_SEPARATOR, File::SEPARATOR) if File::ALT_SEPARATOR
+ next if Dir.glob(File.join(dir, "{tclsh,wish}*#{exeext}"), File::FNM_CASEFOLD).empty?
+ config_dir << File.expand_path(File.join(dir, '..', 'lib'))
+ }
+
+ # for MacOS X
+ paths = [
+ #"~/Library/Tcl",
+ "/Library/Tcl", "/Network/Library/Tcl", "/System/Library/Tcl"
+ ]
+ paths.reverse! unless TkLib_Config["ActiveTcl"]
+
+ paths.each{|path|
+ config_dir << path
+ config_dir.concat(Dir.glob(File.join(path, '{tcl,tk}*'), File::FNM_CASEFOLD).sort.reverse.find_all{|d| File.directory?(d)})
+ }
+
+ paths = [
+ #"~/Library/Frameworks",
+ "/Library/Frameworks",
+ "/Network/Library/Frameworks", "/System/Library/Frameworks"
+ ]
+ paths.reverse! unless TkLib_Config["ActiveTcl"]
+
+ paths.each{|frmwk|
+ base = File.expand_path(frmwk)
+ config_dir << [
+ File.join(base, 'Tcl.framework'), File.join(base, 'Tk.framework')
+ ]
+
+ config_dir << [
+ File.join(base, 'Tcl.framework', 'Versions', 'Current'),
+ File.join(base, 'Tk.framework', 'Versions', 'Current')
+ ]
+
+ Dir.glob(File.join(base, 'Tcl.framework',
+ 'Versions', '*')).sort.reverse.each{|dir|
+ next if dir =~ /Current/
+ config_dir << [dir, dir.gsub(/Tcl/, 'Tk')]
+ }
+ }
+ end
+
+ config_dir
+end
+
+def get_ext_list()
+ exts = [CONFIG['DLEXT']]
+ exts.concat %w(dll) if is_win32?
+ exts.concat %w(bundle dylib) if is_macosx?
+
+ if TkLib_Config["tcltk-stubs"] || TkLib_Config['enable-shared'] == false
+ exts.unshift "lib" if is_win32?
+ exts.unshift "a"
+ exts.unshift CONFIG['LIBEXT']
+ end
+
+ if is_win32?
+ exts.map!{|ext| [ext.downcase, ext.upcase]}.flatten!
+ end
+
+ exts
+end
+
+def libcheck_for_tclConfig(tcldir, tkdir, tclconf, tkconf)
+ tcllib_ok = tklib_ok = false
+
+ if TkLib_Config["tcltk-stubs"]
+ stub = "stub"
+ tclfunc = "Tcl_InitStubs"
+ tkfunc = "Tk_InitStubs"
+ else
+ stub = ""
+ tclfunc = "Tcl_FindExecutable"
+ tkfunc = "Tk_Init"
+ end
+
+ incflags = ($INCFLAGS ||= "").dup
+ libpath = ($LIBPATH ||= []).dup
+ libs_param = ($libs ||= "").dup
+ tcllibs = nil
+ mkmf_param = nil
+
+ tclver, tkver = TkLib_Config["tcltkversion"]
+ exts = "(" + get_ext_list.join('|') + ")"
+
+ if tclver
+ tcl_glob = "*tcl#{stub}#{tclver}.*"
+ tcl_regexp = /^.*(tcl#{stub}#{tclver}.*)\.(#{exts}).*$/
+ elsif tclconf
+ tcl_glob = "*tcl#{stub}#{tclconf['TCL_MAJOR_VERSION']}{.,}#{tclconf['TCL_MINOR_VERSION']}*.*"
+ tcl_regexp = /^.*(tcl#{stub}#{tclconf['TCL_MAJOR_VERSION']}(?:\.|)#{tclconf['TCL_MINOR_VERSION']}.*)\.(#{exts}).*$/
+ end
+ if tkver
+ tk_glob = "*tk#{stub}#{tkver}.*"
+ tk_regexp = /^.*(tk#{stub}#{tkver}.*)\.(#{exts}).*$/
+ elsif tkconf
+ tk_glob = "*tk#{stub}#{tkconf['TK_MAJOR_VERSION']}{.,}#{tkconf['TK_MINOR_VERSION']}*.*"
+ tk_regexp = /^.*(tk#{stub}#{tkconf['TK_MAJOR_VERSION']}(?:\.|)#{tkconf['TK_MINOR_VERSION']}.*)\.#{exts}.*$/
+ end
+
+ tcllib_ok ||= !tclconf || Dir.glob(File.join(tcldir, tcl_glob), File::FNM_CASEFOLD).find{|file|
+ if file =~ tcl_regexp
+ libname = $1
+ ext = $2.downcase
+ begin
+ $INCFLAGS = incflags.dup << " " << tclconf["TCL_INCLUDE_SPEC"]
+ #puts "check #{file} #{$1} #{tclfunc} #{tcldir}"
+ #find_library($1, tclfunc, tcldir)
+ if (tclconf && tclconf["TCL_SHARED_BUILD"] == "0") ||
+ (ext != CONFIG['DLEXT'] && ext == CONFIG['LIBEXT']) || ext == "a"
+ # static link
+ tcllibs = $libs + " -DSTATIC_BUILD " + file.quote
+
+ # FIX ME: avoid pathname trouble (fail to find) on MinGW.
+ # e.g. TCL_INCLUDE_SPEC describes "-I/usr/local/include",
+ # but compiler can find "-IC:/msys/1.0/local/include" only.
+ $INCFLAGS << " -I" << File.join(File.dirname(File.dirname(file)),"include") if is_win32?
+ else
+ tcllibs = append_library($libs, libname)
+ tcllibs = "#{libpathflag([tcldir])} #{tcllibs}"
+
+ # FIX ME: avoid pathname trouble (fail to find) on MinGW.
+ $INCFLAGS << " -I" << File.join(File.dirname(tcldir),"include") if is_win32?
+ end
+
+ $LIBPATH = libpath | [tcldir]
+ try_func(tclfunc, tcllibs, ["tcl.h"]) ||
+ ( try_func(tclfunc, tcllibs << " " << tclconf['TCL_LIBS'], ["tcl.h"]) if tclconf['TCL_LIBS'] )
+
+ ensure
+ mkmf_param = {
+ 'PATH' => file,
+ 'LIBNAME' => libname,
+ 'libs' => tcllibs.dup,
+ 'INCFLAGS' => $INCFLAGS.dup,
+ 'LIBPATH' => $LIBPATH.dup,
+ }
+ $LIBPATH = libpath.dup
+ $libs = libs_param.dup
+ end
+ end
+ }
+ tclconf['MKMF_PARAMS'] = mkmf_param if tclconf && tcllib_ok
+
+ tklib_ok ||= !tkconf || Dir.glob(File.join(tkdir, tk_glob), File::FNM_CASEFOLD).find{|file|
+ if file =~ tk_regexp
+ libname = $1
+ ext = $2.downcase
+ begin
+ #puts "check #{file} #{$1} #{tkfunc} #{tkdir}"
+ # find_library($1, tkfunc, tkdir)
+ if (tkconf && tkconf["TCL_SHARED_BUILD"] == "0") ||
+ (ext != CONFIG['DLEXT'] && ext == CONFIG['LIBEXT']) || ext == "a"
+ # static link
+ tklibs = " -DSTATIC_BUILD " + file.quote
+
+ # FIX ME: avoid pathname trouble (fail to find) on MinGW.
+ $INCFLAGS << " -I" << File.join(File.dirname(File.dirname(file)),"include") if is_win32?
+ else
+ tklibs = append_library("", libname)
+ #tklibs = append_library("", $1)
+ tklibs = "#{libpathflag([tkdir])} #{tklibs}"
+
+ # FIX ME: avoid pathname trouble (fail to find) on MinGW.
+ $INCFLAGS << " -I" << File.join(File.dirname(tcldir),"include") if is_win32?
+ end
+
+ tklibs << " " << tcllibs if tcllibs
+ tmp_tklibs = tklibs.dup
+ $LIBPATH = libpath | [tkdir]
+ try_func(tkfunc, tklibs, ["tcl.h", "tk.h"]) ||
+ ( try_func(tkfunc, tklibs << " " << tkconf['TK_LIBS'], ["tcl.h", "tk.h"]) if tkconf['TK_LIBS'] ) ||
+ ( try_func(tkfunc, (tklibs = tmp_tklibs.dup) << " " << tkconf['TK_XLIBSW'], ["tcl.h", "tk.h"]) if tkconf['TK_XLIBSW'] ) ||
+ ( try_func(tkfunc, tklibs << " " << tkconf['TK_LIBS'], ["tcl.h", "tk.h"]) if tkconf['TK_LIBS'] )
+
+ ensure
+ mkmf_param = {
+ 'PATH' => file,
+ 'LIBNAME' => libname,
+ 'libs' => tklibs.dup,
+ 'INCFLAGS' => $INCFLAGS.dup,
+ 'LIBPATH' => $LIBPATH.dup,
+ }
+ $LIBPATH = libpath.dup
+ $libs = libs_param.dup
+ end
+ end
+ }
+
+ $INCFLAGS = incflags.dup
+ tkconf['MKMF_PARAMS'] = mkmf_param if tkconf && tklib_ok
+
+ [tcllib_ok, tklib_ok]
+end
+
+def search_tclConfig(*paths) # libdir list or [tcl-libdir|file, tk-libdir|file]
+ TkLib_Config["tclConfig_paths"] = []
+
+ paths.compact!
+ if paths.empty?
+ config_dir = get_tclConfig_dirs
+ elsif paths.length == 1 && !paths[0][0] && !paths[0][1]
+ config_dir = get_tclConfig_dirs.map{|dir|
+ if dir.kind_of? Array
+ [ (paths[0][0] == false)? nil: dir[0],
+ (paths[0][1] == false)? nil: dir[1] ]
+ else
+ [ (paths[0][0] == false)? nil: dir,
+ (paths[0][1] == false)? nil: dir ]
+ end
+ }
+ else
+ # fixed tclConfig
+ config_dir = []
+ paths.each{|path|
+ if path.kind_of?(Array)
+ config_dir << path
+ else
+ dirs = Dir.glob(path, File::FNM_CASEFOLD)
+ config_dir.concat(dirs.zip(dirs))
+ end
+ }
+ end
+
+ tclver, tkver = TkLib_Config['tcltkversion']
+ if tclver && tclver =~ /^\D*(\d)\.?(\d)?/ # ignore PATCH_LEVEL
+ tclver_major = $1
+ tclver_minor = $2
+ else
+ tclver_major = nil
+ tclver_minor = nil
+ end
+ if tkver && tkver =~ /^\D*(\d)\.?(\d)?/ # ignore PATCH_LEVEL
+ tkver_major = $1
+ tkver_minor = $2
+ else
+ tkver_major = nil
+ tkver_minor = nil
+ end
+
+ conf = nil
+ progress_flag = false
+
+ config_dir.uniq!
+ config_dir.map{|dir|
+ if dir.kind_of? Array
+ [ (dir[0])? dir[0].strip.chomp('/'): nil,
+ (dir[1])? dir[1].strip.chomp('/'): nil ]
+ else
+ dir.strip.chomp('/')
+ end
+ }.each{|dir|
+ print("."); progress_flag = true # progress
+ # print("check #{dir} ==>");
+ if dir.kind_of? Array
+ tcldir, tkdir = dir
+ else
+ tcldir = tkdir = dir
+ end
+
+ tails = ['Config-shared.sh', 'config-shared.sh', 'Config.sh', 'config.sh']
+
+ if tcldir
+ if File.file?(tcldir)
+ tclcfg_files = [tcldir] * tails.length
+ else
+ tclcfg_files = tails.map{|f| File.join(tcldir, 'tcl' << f)}
+ end
+ else
+ tclcfg_files = [nil] * tails.length
+ end
+
+ if tkdir
+ if File.file?(tkdir)
+ tkcfg_files = [tkdir] * tails.length
+ else
+ tkcfg_files = tails.map{|f| File.join(tkdir, 'tk' << f)}
+ end
+ else
+ tkcfg_files = [nil] * tails.length
+ end
+
+ tclcfg_files.zip(tkcfg_files).map{|tclpath, tkpath|
+ [ (tclpath && File.exist?(tclpath))? File.expand_path(tclpath): tclpath,
+ (tkpath && File.exist?(tkpath))? File.expand_path(tkpath): tkpath ]
+ }.uniq.each{|tclpath, tkpath|
+ next if tclpath && !File.exist?(tclpath)
+ next if tkpath && !File.exist?(tkpath)
+
+ # parse tclConfig.sh/tkConfig.sh
+ tclconf = (tclpath)? parse_tclConfig(tclpath): nil
+ if tclconf
+ if tclver && ((tclver_major && tclver_major != tclconf['TCL_MAJOR_VERSION']) || (tclver_minor && tclver_minor != tclconf['TCL_MINOR_VERSION']))
+ print("\n") if progress_flag
+ puts "Ignore \"#{tclpath}\" (unmatch with configured version)."
+ progress_flag = false
+ next
+ end
+ if TkLib_Config['unsupported_versions'].find{|ver| ver == "#{tclconf['TCL_MAJOR_VERSION']}.#{tclconf['TCL_MINOR_VERSION']}"}
+ print("\n") if progress_flag
+ puts "Ignore \"#{tclpath}\" (unsupported version of Tcl/Tk)."
+ progress_flag = false
+ next
+ end
+ end
+
+ tkconf = (tkpath)? parse_tclConfig(tkpath): nil
+ if tkconf
+ if tkver && ((tkver_major && tkver_major != tkconf['TK_MAJOR_VERSION']) || (tkver_minor && tkver_minor != tkconf['TK_MINOR_VERSION']))
+ print("\n") if progress_flag
+ puts "Ignore \"#{tkpath}\" (unmatch with configured version)."
+ progress_flag = false
+ next
+ end
+ if TkLib_Config['unsupported_versions'].find{|ver| ver == "#{tkconf['TK_MAJOR_VERSION']}.#{tkconf['TK_MINOR_VERSION']}"}
+ print("\n") if progress_flag
+ puts "Ignore \"#{tkpath}\" (unsupported version of Tcl/Tk)."
+ progress_flag = false
+ next
+ end
+ end
+
+ # nativethread check
+ if !TkLib_Config["ruby_with_thread"]
+ if tclconf
+ if tclconf['TCL_THREADS'] == '1'
+ puts "\nWARNING: found #{tclpath.inspect}, but it WITH nativethread-support under ruby WITHOUT nativethread-support. So, ignore it."
+ TkLib_Config["tcl-NG-path"] << File.dirname(tclpath)
+ next
+ end
+ else
+ puts "\nWARNING: When not refer tclConfig.sh, cannot check native-thread support on Tcl/Tk libraries. Ruby, which is used now, does NOT support native-thread. So, if Tcl/Tk libraries support native-thread, it will NOT work properly."
+ end
+ end
+
+ # find tclConfig.sh & tkConfig.sh
+ conf = [tclconf, tkconf] unless conf
+
+ # check Tcl library
+ if is_macosx? && TkLib_Config["tcltk-framework"]
+ # if use framework, not check (believe it is installed properly)
+ tcllib_ok = tklib_ok = true
+ else
+ tcllib_ok, tklib_ok =
+ libcheck_for_tclConfig((tclpath)? File.dirname(tclpath): nil,
+ (tkpath)? File.dirname(tkpath): nil,
+ tclconf, tkconf)
+ end
+
+ unless tcllib_ok && tklib_ok
+ unless tcllib_ok
+ puts "\nWARNING: found #{tclpath.inspect}, but cannot find valid Tcl library for the tclConfig.sh. So, ignore it."
+ TkLib_Config["tcl-NG-path"] << File.dirname(tclpath)
+ end
+ unless tklib_ok
+ puts "\nWARNING: found #{tkpath.inspect}, but cannot find valid Tk library for the tkConfig.sh. So, ignore it."
+ TkLib_Config["tk-NG-path"] << File.dirname(tkpath)
+ end
+ next
+ end
+
+ #return [tclpath, tkpath]
+ # print(" #{[tclpath, tkpath].inspect}");
+ TkLib_Config["tclConfig_paths"] << [tclpath, tkpath]
+ }
+
+ # print("\n");
+ }
+
+ if is_macosx? && TkLib_Config["tcltk-stubs"]
+ CONFIG['LDSHARED'] << " -Xlinker -bind_at_load"
+ if config_string('LDSHAREDXX')
+ config_string('LDSHAREDXX') << " -Xlinker -bind_at_load"
+ end
+ end
+
+ if TkLib_Config["tclConfig_paths"].empty?
+ [nil, nil]
+ else
+ # find tclConfig.sh and tkConfig.sh
+ TkLib_Config["tclConfig_info"], TkLib_Config["tkConfig_info"] = conf
+ TkLib_Config["tclConfig_paths"][0]
+ end
+end
+
+def get_tclConfig(tclConfig_file, tkConfig_file, tclConfig_dir, tkConfig_dir)
+ use_tclConfig = tclConfig_file != false && tclConfig_dir != false
+ use_tkConfig = tkConfig_file != false && tkConfig_dir != false
+
+ unless use_tclConfig || use_tkConfig
+ puts("Don't use [tclConfig.sh, tkConfig.sh]")
+ return [nil, nil]
+ end
+
+ tclConfig_file = nil unless tclConfig_file.kind_of? String
+ tkConfig_file = nil unless tkConfig_file.kind_of? String
+ tclConfig_dir = nil unless tclConfig_dir.kind_of? String
+ tkConfig_dir = nil unless tkConfig_dir.kind_of? String
+
+ if use_tclConfig && !tclConfig_dir
+ if tclConfig_file
+ tclConfig_dir = File.dirname(tclConfig_file)
+ elsif tkConfig_dir
+ tclConfig_dir = tkConfig_dir
+ end
+ end
+ if use_tkConfig && !tkConfig_dir
+ if tkConfig_file
+ tkConfig_dir = File.dirname(tkConfig_file)
+ elsif tclConfig_dir
+ tkConfig_dir = tclConfig_dir
+ end
+ end
+ tkConfig_dir ||= tclConfig_dir
+
+ if use_tclConfig
+ TkLib_Config["tclConfig-file"] = tclConfig_file
+ TkLib_Config["tclConfig-dir"] = tclConfig_dir
+ else
+ tclConfig_file = false
+ tclConfig_dir = false
+ end
+ if use_tkConfig
+ TkLib_Config["tkConfig-file"] = tkConfig_file
+ TkLib_Config["tkConfig-dir"] = tkConfig_dir
+ else
+ tkConfig_file = false
+ tkConfig_dir = false
+ end
+
+ print ("Don't use tclConfig.sh (specified by configure option).\n") unless use_tclConfig
+ print ("Don't use tkConfig.sh (specified by configure option).\n") unless use_tkConfig
+ print("Search ")
+ print("tclConfig.sh", (tclConfig_dir)? " (in #{tclConfig_dir})": "") if use_tclConfig
+ print((use_tclConfig)? " and ": "", "tkConfig.sh", (tkConfig_dir)? " (in #{tkConfig_dir})": "") if use_tkConfig
+ print(".")
+
+ if tclConfig_dir || tkConfig_dir || !use_tclConfig || !use_tkConfig
+ tclConfig, tkConfig =
+ search_tclConfig([ ((tclConfig_file)? tclConfig_file: tclConfig_dir),
+ ((tkConfig_file)? tkConfig_file: tkConfig_dir) ])
+ else
+ tclConfig, tkConfig = search_tclConfig()
+ end
+ print("\n")
+ # TclConfig_Info = TkLib_Config["tclConfig_info"]
+ # TkConfig_Info = TkLib_Config["tkConfig_info"]
+
+ if tclConfig || tkConfig
+ dirs = TkLib_Config["tclConfig_paths"].map{|tclpath, tkpath|
+ [ (tclpath)? File.dirname(tclpath): nil,
+ (tkpath)? File.dirname(tkpath): nil ]
+ }
+ dirs |= dirs
+ puts("Valid [tclConfig.sh, tkConfig.sh] are found in #{dirs.inspect}")
+ puts("Use [tclConfig.sh, tkConfig.sh] == #{[tclConfig, tkConfig].inspect}")
+ $LIBPATH ||= []
+ $LIBPATH |= [File.dirname(tclConfig)] if tclConfig
+ $LIBPATH |= [File.dirname(tkConfig)] if tkConfig
+ #TkLib_Config["tclConfig_paths"].each{|tclcfg, tkcfg|
+ # $LIBPATH |= [File.dirname(tclcfg)] | [File.dirname(tkcfg)]
+ #}
+ else
+ puts("Fail to find [tclConfig.sh, tkConfig.sh]")
+ end
+
+ [tclConfig, tkConfig]
+end
+
+def check_tcl_NG_path(path_list)
+ path_list.find_all{|path| not TkLib_Config["tcl-NG-path"].include?(path) }
+end
+
+def check_tk_NG_path(path_list)
+ path_list.find_all{|path| not TkLib_Config["tk-NG-path"].include?(path) }
+end
+
+def check_NG_path(path_list)
+ path_list.find_all{|path|
+ not (TkLib_Config["tcl-NG-path"].include?(path) &&
+ TkLib_Config["tk-NG-path"].include?(path))
+ }
+end
+
+def check_shlib_search_path(paths)
+ if !paths || paths.empty?
+ path_list = []
+
+ #if TkLib_Config["ActiveTcl"]
+ # path_list.concat Dir.glob(TkLib_Config["ActiveTcl"], File::FNM_CASEFOLD).sort.reverse
+ #end
+ if TkLib_Config["ActiveTcl"].kind_of?(String) # glob path
+ path_list.concat Dir.glob(TkLib_Config["ActiveTcl"], File::FNM_CASEFOLD).sort.reverse
+ end
+
+ vers = get_shlib_versions
+ path_head, path_dirs = get_shlib_path_head
+
+ path_list.concat vers.map{|ver|
+ path_head.map{|head|
+ if ver.empty?
+ head + "/lib"
+ else
+ dirs = []
+
+ if Dir.glob(head, File::FNM_CASEFOLD).find{|dir| dir == head}
+ dirs << head + "/lib"
+ end
+
+ if !Dir.glob(head + "-*", File::FNM_CASEFOLD).empty?
+ dirs << head + "-#{ver}/lib" if !Dir.glob(head + "-[89].*", File::FNM_CASEFOLD).empty?
+ dirs << head + "-#{ver.delete('.')}/lib" if !Dir.glob(head + "-[89][0-9]*", File::FNM_CASEFOLD).empty?
+ end
+
+ if !Dir.glob(head + "[_-]*", File::FNM_CASEFOLD).empty?
+ dirs << head + "_#{ver}/lib" if !Dir.glob(head + "_[89].*", File::FNM_CASEFOLD).empty?
+ dirs << head + "-#{ver}/lib" if !Dir.glob(head + "-[89].*", File::FNM_CASEFOLD).empty?
+ dirs << head + "_#{ver.delete('.')}/lib" if !Dir.glob(head + "_[89][0-9]*", File::FNM_CASEFOLD).empty?
+ dirs << head + "-#{ver.delete('.')}/lib" if !Dir.glob(head + "-[89][0-9]*", File::FNM_CASEFOLD).empty?
+ end
+
+ dirs
+ end
+ }
+ }.flatten!
+
+ path_list.concat path_dirs
+
+ else
+ # paths is a string with PATH environment style
+ path_list = paths.split((is_win32?)? ';': ':')
+ end
+
+ path_list = check_NG_path(path_list)
+ path_list.map!{|path| path.strip}
+
+ if !CROSS_COMPILING and (is_win32? || is_macosx?)
+ # exist-dir only
+ path_list.delete_if{|path| Dir.glob(File.join(path, "*.{a,so,dll,lib}")).empty?}
+ end
+
+ # keep paths for searching dynamic libs
+ #$LIBPATH |= path_list
+ path_list.uniq
+end
+
+def search_vers_on_path(vers, path, *heads)
+ exts = get_ext_list.join(',')
+ files = Dir.glob(File.join(path, "*{#{heads.join(',')}}*.{#{exts}}"), File::FNM_CASEFOLD)
+ vers.find_all{|ver| files.find{|f| f =~ /(#{ver}|#{ver.delete('.')})/} }
+end
+
+def find_tcl(tcllib, stubs, version, *opt_paths)
+ if TclConfig_Info['MKMF_PARAMS']
+ # already checked existence of tcl library based on tclConfig.sh
+ ($INCFLAGS ||= "") << " " << TclConfig_Info['MKMF_PARAMS']['INCFLAGS']
+ $LIBPATH ||= []; $LIBPATH |= TclConfig_Info['MKMF_PARAMS']['LIBPATH']
+ ($libs ||= "") << " " << TclConfig_Info['MKMF_PARAMS']['libs']
+ return [true, nil, nil, nil]
+ end
+ # else, no available tclConfig.sh on the system
+
+ print "Search Tcl library"
+
+ if stubs
+ func = "Tcl_InitStubs"
+ lib = "tclstub"
+ else
+ func = "Tcl_FindExecutable"
+ lib = "tcl"
+ end
+
+ if version && ! version.empty?
+ versions = [version]
+ else
+ versions = TkLib_Config['search_versions']
+ end
+
+ default_paths = []
+
+ default_paths.concat [
+ RbConfig::CONFIG['libdir'],
+ File.join(RbConfig::CONFIG['exec_prefix'], 'lib'),
+ File.join(RbConfig::CONFIG['prefix'], 'lib'),
+ "/usr/local/lib", "/usr/pkg/lib", "/usr/contrib/lib", "/usr/lib"
+ ].find_all{|dir| File.directory?(dir)} unless CROSS_COMPILING
+
+ if TkLib_Config["ActiveTcl"].kind_of?(String) # glob path
+ default_paths.concat Dir.glob(TkLib_Config["ActiveTcl"]).sort.reverse.map{|d| d << "/lib"}
+ end
+
+ if !CROSS_COMPILING and is_win32?
+ default_paths.concat [
+ "c:/Tcl/lib","c:/Program Files/Tcl/lib","c:/Program Files (x86)/Tcl/lib",
+ "/Tcl/lib","/Program Files/Tcl/lib","/Program Files (x86)/Tcl/lib"
+ ].find_all{|dir| File.directory?(dir)}.map{|dir| File.expand_path(dir)}
+
+ # for MinGW
+ ["/usr/local/lib64", "/usr/lib64", "/usr/local/lib", "/usr/lib"].each{|dir|
+ default_paths << File.expand_path(dir) if File.directory? dir
+ }
+
+ default_paths |= ENV['LIBRARY_PATH'].split(';').find_all{|dir| File.directory? dir}.map{|dir| File.expand_path(dir)} if ENV['LIBRARY_PATH']
+ default_paths |= ENV['PATH'].split(';').find_all{|dir| File.directory? dir}.map{|dir| File.expand_path(dir)} if ENV['PATH']
+ end
+
+ default_paths |= TkLib_Config["checked_shlib_dirs"]
+
+ unless TkLib_Config["space-on-tk-libpath"]
+ default_paths.delete_if{|path| path =~ / /}
+ end
+
+ if (paths = opt_paths.compact).empty?
+ paths = check_tcl_NG_path(default_paths)
+ end
+
+ incflags = ($INCFLAGS ||= "").dup
+ libpath = ($LIBPATH ||= []).dup
+ libs_param = ($libs ||= "").dup
+ tcllibs = nil
+
+ exts = "(" + get_ext_list.join('|') + ")"
+
+ paths.map{|path|
+ lib_w_sufx = lib
+ begin
+ $LIBPATH |= [path]
+ inc = [File.join(File.dirname(path),"include"), File.dirname(path)]
+ inc.each{|f| $INCFLAGS << " -I" << f }
+
+ if tcllib
+ print(".")
+ if have_library(tcllib, func, ["tcl.h"])
+ return [true, path, tcllib, nil, *inc]
+ end
+ else
+ sufx_list = ['', 't', 'g', 's', 'x']
+ search_vers_on_path(versions, path, lib, 'tcl').find{|ver|
+ dir_enum = Dir.foreach(path)
+ no_dot_ver = ver.delete('.')
+ libnames = ["#{lib}#{ver}", "#{lib}#{no_dot_ver}"]
+ libnames << "tcl#{ver}" << "tcl#{no_dot_ver}" if lib != "tcl"
+ libnames.find{|libname|
+ sufx_list.find{|sufx|
+ print(".")
+ dir_enum.map{|fname|
+ if fname =~ /^.*(#{libname}.*#{sufx})\.(#{exts}).*$/
+ [fname, $1, $2]
+ end
+ }.compact.find{|fname, lib_w_sufx, ext|
+ ext.downcase!
+ if (ext != CONFIG['DLEXT'] && ext == CONFIG['LIBEXT']) ||
+ ext == "a"
+ # static link
+ tcllibs = libs_param + " -DSTATIC_BUILD " + fname.quote
+ else
+ tcllibs = append_library($libs, lib_w_sufx)
+ tcllibs = "#{libpathflag([path])} #{tcllibs}"
+ end
+ if try_func(func, tcllibs, ["tcl.h"])
+ return [true, path, nil, tcllibs, *inc]
+ end
+ }
+ }
+ }
+ }
+ if (!version && (print(".");try_func(func, libs_param, ["tcl.h"])))
+ return [true, path, lib_w_sufx, nil, *inc]
+ end
+ end
+ ensure
+ $LIBPATH = libpath.dup
+ $libs = libs_param.dup
+ $INCFLAGS = incflags.dup
+ end
+ }
+
+ print("\n") # progress
+ [false, nil, nil, nil]
+end
+
+def parse_TK_LIBS(tklibs)
+ sfx = "lib|shlib|dll|so"
+ re = /(("|')[^"']+\.(#{sfx})\2|[^"' ]+\.(#{sfx})|-l("|')[^"']+\5|-l[^" ]+)/#'
+
+ tklibs.scan(re).map{|lib,|
+ if lib =~ /^("|')([^"]+)\.(#{sfx})\1/
+ "\"-l#{$2}\""
+ elsif lib =~ /([^" ]+)\.(#{sfx})/
+ "-l#{$1}"
+ else
+ lib
+ end
+ }.join(' ')
+end
+
+def find_tk(tklib, stubs, version, *opt_paths)
+ if TkConfig_Info['MKMF_PARAMS']
+ # already checked existence of tcl library based on tkConfig.sh
+ ($INCFLAGS ||= "") << " " << TkConfig_Info['MKMF_PARAMS']['INCFLAGS']
+ $LIBPATH ||= []; $LIBPATH |= TkConfig_Info['MKMF_PARAMS']['LIBPATH']
+ ($libs ||= "") << " " << TkConfig_Info['MKMF_PARAMS']['libs']
+ return [true, nil, nil, nil]
+ end
+ # else, no available tkConfig.sh on the system
+
+ print "Search Tk library"
+
+ if stubs
+ func = "Tk_InitStubs"
+ lib = "tkstub"
+ else
+ func = "Tk_Init"
+ lib = "tk"
+ end
+
+ if version && ! version.empty?
+ versions = [version]
+ else
+ versions = TkLib_Config['search_versions']
+ end
+
+ default_paths = []
+
+ default_paths.concat [
+ RbConfig::CONFIG['libdir'],
+ File.join(RbConfig::CONFIG['exec_prefix'], 'lib'),
+ File.join(RbConfig::CONFIG['prefix'], 'lib'),
+ "/usr/local/lib", "/usr/pkg/lib", "/usr/contrib/lib", "/usr/lib"
+ ].find_all{|dir| File.directory?(dir)} unless CROSS_COMPILING
+
+ if !CROSS_COMPILING and is_win32?
+ default_paths.concat [
+ "c:/Tcl/lib","c:/Program Files/Tcl/lib","c:/Program Files (x86)/Tcl/lib",
+ "/Tcl/lib","/Program Files/Tcl/lib","/Program Files (x86)/Tcl/lib"
+ ].find_all{|dir| File.directory?(dir)}
+
+ # for MinGW
+ ["/usr/local/lib64", "/usr/lib64", "/usr/local/lib", "/usr/lib"].each{|dir|
+ default_paths << File.expand_path(dir) if File.directory? dir
+ }
+
+ default_paths |= ENV['LIBRARY_PATH'].split(';').find_all{|dir| File.directory? dir}.map{|dir| File.expand_path(dir)} if ENV['LIBRARY_PATH']
+ default_paths |= ENV['PATH'].split(';').find_all{|dir| File.directory? dir}.map{|dir| File.expand_path(dir)} if ENV['PATH']
+ end
+
+ default_paths |= TkLib_Config["checked_shlib_dirs"]
+
+ unless TkLib_Config["space-on-tk-libpath"]
+ default_paths.delete_if{|path| path =~ / /}
+ end
+
+ if (paths = opt_paths.compact).empty?
+ paths = check_tk_NG_path(default_paths)
+ end
+
+ incflags = ($INCFLAGS ||= "").dup
+ libpath = ($LIBPATH ||= []).dup
+ libs_param = ($libs ||= "").dup
+ tcllibs = nil
+
+ exts = "(" + get_ext_list.join('|') + ")"
+
+ paths.map{|path|
+ lib_w_sufx = lib
+ begin
+ $LIBPATH |= [path]
+ inc = [File.join(File.dirname(path),"include"), File.dirname(path)]
+ inc.each{|f| $INCFLAGS << " -I" << f }
+
+ if tklib
+ print(".")
+ if have_library(tklib, func, ["tcl.h", "tk.h"])
+ return [true, path, tklib, nil, *inc]
+ end
+ else
+ sufx_list = ['', 't', 'g', 's', 'x']
+ search_vers_on_path(versions, path, lib, 'tk').find{|ver|
+ dir_enum = Dir.foreach(path)
+ no_dot_ver = ver.delete('.')
+ libnames = ["#{lib}#{ver}", "#{lib}#{no_dot_ver}"]
+ libnames << "tk#{ver}" << "tk#{no_dot_ver}" if lib != "tk"
+ libnames.find{|libname|
+ sufx_list.find{|sufx|
+ print(".")
+ dir_enum.map{|fname|
+ if fname =~ /^.*(#{libname}.*#{sufx})\.(#{exts}).*$/
+ [fname, $1, $2]
+ end
+ }.compact.find{|fname, lib_w_sufx, ext|
+ if (ext != CONFIG['DLEXT'] && ext == CONFIG['LIBEXT']) ||
+ ext == "a"
+ # static link
+ tklibs = libs_param + " -DSTATIC_BUILD " + fname.quote
+ else
+ tklibs = append_library($libs, lib_w_sufx)
+ tklibs = "#{libpathflag([path])} #{tklibs}"
+ end
+ if try_func(func, tklibs, ["tcl.h", "tk.h"])
+ return [true, path, nil, tklibs, *inc]
+ end
+ }
+ }
+ }
+ }
+ if (!version && (print(".");try_func(func, libs_param, ["tcl.h", "tk.h"])))
+ return [true, path, lib_w_sufx, nil, *inc]
+ end
+ end
+ ensure
+ $LIBPATH = libpath
+ $libs = libs_param
+ $INCFLAGS = incflags.dup
+ end
+ }
+
+ print("\n") # progress
+ [false, nil, nil, nil]
+end
+
+def find_tcltk_library(tcllib, tklib, stubs, tclversion, tkversion,
+ tcl_opt_paths, tk_opt_paths)
+ st,path,lib,libs,*inc = find_tcl(tcllib, stubs, tclversion, *tcl_opt_paths)
+ if !st && TkLib_Config['enable-shared'] == nil
+ TkLib_Config['enable-shared'] = false
+ st,path,lib,libs,*inc = find_tcl(tcllib, stubs, tclversion, *tcl_opt_paths)
+ end
+ unless st
+ puts("Warning:: cannot find Tcl library. tcltklib will not be compiled (tcltklib is disabled on your Ruby. That is, Ruby/Tk will not work). Please check configure options.")
+ return false
+ else
+ ($LIBPATH ||= []; $LIBPATH |= [path]) if path
+ $libs = append_library($libs, lib) if lib
+ ($libs ||= "") << " " << libs if libs
+ $INCFLAGS ||= ""
+ inc.each{|f| $INCFLAGS << " -I" << f}
+ end
+
+ st,path,lib,libs,*inc = find_tk(tklib, stubs, tkversion, *tk_opt_paths)
+ if !st && TkLib_Config['enable-shared'] == nil
+ TkLib_Config['enable-shared'] = false
+ st,path,lib,libs,*inc = find_tk(tklib, stubs, tkversion, *tk_opt_paths)
+ end
+ unless st
+ puts("Warning:: cannot find Tk library. tcltklib will not be compiled (tcltklib is disabled on your Ruby. That is, Ruby/Tk will not work). Please check configure options.")
+ return false
+ else
+ ($LIBPATH ||= []; $LIBPATH |= [path]) if path
+ $libs = append_library($libs, lib) if lib && !lib.empty?
+ ($libs ||= "") << " " << libs if libs
+ $INCFLAGS ||= ""
+ inc.each{|f| $INCFLAGS << " -I" << f}
+ end
+
+ true
+end
+
+def find_tcltk_header(tclver, tkver)
+ base_dir = []
+
+ base_dir.concat [
+ File.join(RbConfig::CONFIG['prefix'], 'include'),
+ "/usr/local/include", "/usr/pkg/include", "/usr/contrib/include",
+ "/usr/include"
+ ].find_all{|dir| File.directory?(dir)}.map{|dir| File.expand_path(dir)}
+
+ if !CROSS_COMPILING && is_win32?
+ base_dir.concat [
+ "c:/Tcl/include","c:/Program Files/Tcl/include",
+ "c:/Program Files (x86)/Tcl/include",
+ "/Tcl/include","/Program Files/Tcl/include",
+ "/Program Files (x86)/Tcl/include"
+ ].find_all{|dir| File.directory?(dir)}.map{|dir| File.expand_path(dir)}
+
+ if ENV['CPATH']
+ base_dir |= ENV['CPATH'].split(';').find_all{|dir| File.directory?(dir)}.map{|dir| File.expand_path(dir)}
+ end
+ end
+
+ base_dir |= TkLib_Config["checked_shlib_dirs"]
+
+ unless TkLib_Config["space-on-tk-libpath"]
+ base_dir.delete_if{|path| path =~ / /}
+ end
+
+ # tcl.h
+ if TclConfig_Info['MKMF_PARAMS']
+ # already checked existence of tcl headers based on tclConfig.sh
+ have_tcl_h = true
+ else
+ print "\nSearch tcl.h"
+ if enable_config("tcl-h-ver-check", true) &&
+ tclver && tclver =~ /^\D*(\d)\.?(\d)/
+ major = $1; minor = $2
+ else
+ major = minor = nil
+ end
+ print(".") # progress
+ if major && minor
+ # version check on tcl.h
+ version_check = proc {|code|
+ code << ("#if TCL_MAJOR_VERSION != #{major} || TCL_MINOR_VERSION != #{minor}\n" \
+ "#error VERSION does not match\n" \
+ "#endif")
+ }
+ else
+ version_check = nil
+ end
+ have_tcl_h = have_header('tcl.h', &version_check)
+ unless have_tcl_h
+ if tclver && ! tclver.empty?
+ versions = [tclver]
+ else
+ versions = TkLib_Config['search_versions']
+ end
+ paths = base_dir.dup
+ (versions + [""]).each{|ver|
+ paths.concat(base_dir.map{|dir|
+ [
+ dir + '/tcl' + ver,
+ dir + '/tcl' + ver + '/include',
+ dir + '/tcl' + ver.delete('.'),
+ dir + '/tcl' + ver.delete('.') + '/include'
+ ]
+ }.flatten)
+ }
+ paths = paths.map{|dir|
+ (File.directory?(dir))? File.expand_path(dir): nil
+ }.compact.uniq
+
+ if major || minor
+ version_check = proc {|code|
+ code << "#if TCL_MAJOR_VERSION != #{major}\n#error MAJOR_VERSION does not match\n#endif\n" if major
+ code << "#if TCL_MINOR_VERSION != #{minor}\n#error MINOR_VERSION does not match\n#endif\n" if minor
+ code
+ }
+ else
+ version_check = nil
+ end
+ have_tcl_h = paths.find{|path|
+ print(".") # progress
+ inc_opt = " -I#{path.quote}"
+ if try_header("tcl", inc_opt, &version_check)
+ ($INCFLAGS ||= "") << inc_opt
+ true
+ else
+ false
+ end
+ }
+ end
+ end
+
+ # tk.h
+ if TkConfig_Info['MKMF_PARAMS']
+ # already checked existence of tk headers based on tkConfig.sh
+ have_tk_h = true
+ else
+ print "\nSearch tk.h"
+ if enable_config("tk-h-ver-check", true) &&
+ tkver && tkver =~ /^\D*(\d)\.?(\d)/
+ major = $1; minor = $2
+ else
+ major = minor = nil
+ end
+ print(".") # progress
+ if major && minor
+ # version check on tk.h
+ version_check = proc {|code|
+ code << ("#if TK_MAJOR_VERSION != #{major} || TK_MINOR_VERSION != #{minor}\n" \
+ "#error VERSION does not match\n" \
+ "#endif")
+ }
+ else
+ version_check = nil
+ end
+ have_tk_h = have_header('tk.h')
+ unless have_tk_h
+ if tkver && ! tkver.empty?
+ versions = [tkver]
+ else
+ versions = TkLib_Config['search_versions']
+ end
+ paths = base_dir.dup
+ (versions + [""]).each{|ver|
+ paths.concat(base_dir.map{|dir|
+ [
+ dir + '/tk' + ver,
+ dir + '/tk' + ver + '/include',
+ dir + '/tk' + ver.delete('.'),
+ dir + '/tk' + ver.delete('.') + '/include'
+ ]
+ }.flatten)
+ }
+ paths = paths.map{|dir|
+ (File.directory?(dir))? File.expand_path(dir): nil
+ }.compact.uniq
+
+ if major || minor
+ version_check = proc {|code|
+ code << "#if TK_MAJOR_VERSION != #{major}\n#error MAJOR_VERSION does not match\n#endif\n" if major
+ code << "#if TK_MINOR_VERSION != #{minor}\n#error MINOR_VERSION does not match\n#endif\n" if minor
+ code
+ }
+ else
+ version_check = nil
+ end
+ have_tk_h = paths.find{|path|
+ print(".") # progress
+ inc_opt = " -I#{path.quote}"
+ if try_header(%w'tcl.h tk.h', inc_opt, &version_check)
+ ($INCFLAGS ||= "") << inc_opt
+ true
+ else
+ false
+ end
+ }
+ end
+ end
+
+ puts "Can't find \"tcl.h\"." unless have_tcl_h
+ puts "Can't find \"tk.h\"." unless have_tk_h
+ have_tcl_h && have_tk_h
+end
+
+def setup_for_macosx_framework(tclver, tkver)
+ # use framework, but no tclConfig.sh
+ unless $LIBS && $LIBS.include?('-framework')
+ ($LIBS ||= "") << ' -framework Tk -framework Tcl'
+ end
+
+ if TkLib_Config["tcl-framework-header"]
+ TclConfig_Info['TCL_INCLUDE_SPEC'][0,0] =
+ " -I#{TkLib_Config["tcl-framework-header"].quote} "
+ else
+ tcl_base = File.join(TkLib_Config["tcltk-framework"], 'Tcl.framework')
+ if tclver
+ TclConfig_Info['TCL_INCLUDE_SPEC'] <<
+ " -I#{File.join(tcl_base, 'Versions', tclver, 'Headers').quote} "
+ end
+
+ TclConfig_Info['TCL_INCLUDE_SPEC'] << File.join(tcl_base, 'Headers')
+
+ unless tclver
+ dir = Dir.glob(File.join(tcl_base, 'Versions', '*', 'Headers'),
+ File::FNM_CASEFOLD).sort.reverse[0]
+ TclConfig_Info['TCL_INCLUDE_SPEC'] << "-I#{dir.quote} " if dir
+ end
+ end
+
+ if TkLib_Config["tk-framework-header"]
+ TkConfig_Info['TK_INCLUDE_SPEC'][0,0] =
+ " -I#{TkLib_Config["tk-framework-header"].quote} "
+ else
+ tk_base = File.join(TkLib_Config["tcltk-framework"], 'Tk.framework')
+ if tkver
+ TkConfig_Info['TK_INCLUDE_SPEC'] <<
+ " -I#{File.join(tk_base, 'Versions', tkver, 'Headers').quote} "
+ end
+
+ TkConfig_Info['TK_INCLUDE_SPEC'] << File.join(tk_base, 'Headers')
+
+ unless tkver
+ dir = Dir.glob(File.join(tk_base, 'Versions', '*', 'Headers'),
+ File::FNM_CASEFOLD).sort.reverse[0]
+ TkConfig_Info['TK_INCLUDE_SPEC'] << "-I#{dir.quote} " if dir
+ end
+ end
+end
+
+def find_X11(*opt_paths)
+ defaults =
+ [ "/usr/X11*/lib", "/usr/lib/X11*", "/usr/local/X11*", "/usr/openwin/lib" ]
+ paths = []
+ opt_paths.compact.each{|path| paths.concat(Dir.glob(path.strip.chomp('/'), File::FNM_CASEFOLD))}
+ defaults.compact.each{|path| paths.concat(Dir.glob(path.strip.chomp('/'), File::FNM_CASEFOLD))}
+ st = find_library("X11", "XOpenDisplay", *paths)
+ unless st
+ puts("Warning:: cannot find X11 library. tcltklib will not be compiled (tcltklib is disabled on your Ruby. That is, Ruby/Tk will not work). Please check configure options. If your Tcl/Tk don't require X11, please try --without-X11.")
+ end
+ st
+end
+
+def search_X_libraries
+ use_tkConfig = false
+ if TkConfig_Info['config_file_path']
+ # use definitions on tkConfig.sh
+ if (TkConfig_Info['TK_XINCLUDES'] &&
+ !TkConfig_Info['TK_XINCLUDES'].strip.empty?) ||
+ (TkConfig_Info['TK_XLIBSW'] && !TkConfig_Info['TK_XLIBSW'].strip.empty?)
+ use_tkConfig = true
+ #use_X = true && with_config("X11", ! is_win32?)
+ use_X = with_config("X11", true)
+ else
+ #use_X = false || with_config("X11", false)
+ use_X = with_config("X11", false)
+ end
+ else
+ # depend on configure options
+ use_X = with_config("X11", !(is_win32? || TkLib_Config["tcltk-framework"]))
+ end
+
+ if TkConfig_Info['TK_XINCLUDES'] &&
+ !TkConfig_Info['TK_XINCLUDES'].strip.empty?
+ ($INCFLAGS ||= "") << " " << TkConfig_Info['TK_XINCLUDES'].strip
+ end
+
+ if use_X
+ puts("Use X11 libraries (or use TK_XINCLUDES/TK_XLIBSW information on tkConfig.sh).")
+ x11_idir, x11_ldir = dir_config("X11")
+ x11_ldir2 = with_config("X11-lib")
+ unless find_X11(x11_ldir2, x11_ldir)
+ puts("Can't find X11 libraries. ")
+ if use_tkConfig &&
+ TkConfig_Info['TK_XLIBSW'] && !TkConfig_Info['TK_XLIBSW'].strip.empty?
+ puts("But, try to use TK_XLIBSW information (believe tkCOnfig.sh).")
+ ($libs ||= "") << " " << TkConfig_Info['TK_XLIBSW'] << " "
+ else
+ puts("So, can't make tcltklib.so which is required by Ruby/Tk.")
+ exit
+ end
+ end
+ end
+
+ use_X
+end
+
+def pthread_check()
+ tcl_major_ver = nil
+ tcl_minor_ver = nil
+
+ # Is tcl-thread given by user ?
+ case enable_config("tcl-thread")
+ when true
+ tcl_enable_thread = true
+ when false
+ tcl_enable_thread = false
+ else
+ tcl_enable_thread = nil
+ end
+
+ if TclConfig_Info['config_file_path']
+ if tcl_enable_thread == true
+ puts("Warning: definiton of tclConfig.sh is ignored, because --enable-tcl-thread option is given.")
+ elsif tcl_enable_thread == false
+ puts("Warning: definition of tclConfig.sh is ignored, because --disable-tcl-thread option is given.")
+ else
+ # tcl-thread is unknown and tclConfig.sh is given
+ if TclConfig_Info['TCL_THREADS']
+ tcl_enable_thread = (TclConfig_Info['TCL_THREADS'] == "1")
+ else
+ tcl_major_ver = TclConfig_Info['TCL_MAJOR_VERSION'].to_i
+ tcl_minor_ver = TclConfig_Info['TCL_MINOR_VERSION'].to_i
+ if tcl_major_ver < 8 || (tcl_major_ver == 8 && tcl_minor_ver == 0)
+ tcl_enable_thread = false
+ end
+ end
+
+ if tcl_enable_thread == nil
+ # cannot find definition
+ if tcl_major_ver
+ puts("Warning: '#{TclConfig_Info['config_file_path']}' doesn't include TCL_THREADS definition.")
+ else
+ puts("Warning: '#{TclConfig_Info['config_file_path']}' may not be a tclConfig file.")
+ end
+ #tclConfig = false
+ end
+ end
+ end
+
+ if tcl_enable_thread == nil && !TclConfig_Info['config_file_path']
+ # tcl-thread is unknown and tclConfig is unavailable
+ begin
+ try_run("int main() { exit(0); }")
+ rescue Exception
+ # cannot try_run. Is CROSS-COMPILE environment?
+ puts(%Q'\
+*****************************************************************************
+**
+** NATIVETHREAD SUPPORT CHECK WARNING:
+**
+** We cannot check the consistency of nativethread support between
+** Ruby and the Tcl/Tk library in your environment (are you perhaps
+** cross-compiling?). If nativethread support for these 2 packages
+** is inconsistent you may find you get errors when running Ruby/Tk
+** (e.g. hangs or segmentation faults). We strongly recommend
+** you to check the consistency manually.
+**
+*****************************************************************************
+')
+ return true
+ end
+ end
+
+ if tcl_enable_thread == nil
+ # tcl-thread is unknown
+ if try_run(<<EOF)
+#include <tcl.h>
+int main() {
+ Tcl_Interp *ip;
+ ip = Tcl_CreateInterp();
+ exit((Tcl_Eval(ip, "set tcl_platform(threaded)") == TCL_OK)? 0: 1);
+}
+EOF
+ tcl_enable_thread = true
+ elsif try_run(<<EOF)
+#include <tcl.h>
+static Tcl_ThreadDataKey dataKey;
+int main() { exit((Tcl_GetThreadData(&dataKey, 1) == dataKey)? 1: 0); }
+EOF
+ tcl_enable_thread = true
+ else
+ tcl_enable_thread = false
+ end
+ end
+
+ # check pthread mode
+ if (TkLib_Config["ruby_with_thread"])
+ $CPPFLAGS ||= ""
+
+ # ruby -> enable
+ unless tcl_enable_thread
+ # ruby -> enable && tcl -> disable
+ puts(%Q'\
+*****************************************************************************
+**
+** NATIVETHREAD SUPPORT MODE WARNING:
+**
+** Ruby is compiled with --enable-pthread, but your Tcl/Tk library
+** seems to be compiled without nativethread support. Although you can
+** create the tcltklib library, this combination may cause errors (e.g.
+** hangs or segmentation faults). If you have no reason to keep the
+** current nativethread support status, we recommend you reconfigure and
+** recompile the libraries so that both or neither support nativethreads.
+**
+** If you want change the status of nativethread support, please recompile
+** Ruby without "--enable-pthread" configure option (If you use Ruby 1.9.x
+** or later, you cannot remove this option, because it requires native-
+** thread support.) or recompile Tcl/Tk with "--enable-threads" configure
+** option (if your Tcl/Tk is later than or equal to Tcl/Tk 8.1).
+**
+*****************************************************************************
+')
+ end
+
+ # ruby -> enable && tcl -> enable/disable
+ if tcl_enable_thread
+ $CPPFLAGS += ' -DWITH_TCL_ENABLE_THREAD=1'
+ else
+ $CPPFLAGS += ' -DWITH_TCL_ENABLE_THREAD=0'
+ end
+
+ return true
+
+ else
+ # ruby -> disable
+ if tcl_enable_thread
+ # ruby -> disable && tcl -> enable
+ puts(%Q'\
+*****************************************************************************
+**
+** NATIVETHREAD SUPPORT MODE ERROR:
+**
+** Ruby is not compiled with --enable-pthread, but your Tcl/Tk
+** library seems to be compiled with nativethread support. This
+** combination may cause frequent hang or segmentation fault
+** errors when Ruby/Tk is working. We recommend that you NEVER
+** create the library with such a combination of nativethread support.
+**
+** Please recompile Ruby with the "--enable-pthread" configure option
+** or recompile Tcl/Tk with the "--disable-threads" configure option.
+**
+*****************************************************************************
+')
+ $CPPFLAGS += ' -DWITH_TCL_ENABLE_THREAD=1'
+ return false
+ else
+ # ruby -> disable && tcl -> disable
+ $CPPFLAGS += ' -DWITH_TCL_ENABLE_THREAD=0'
+ return true
+ end
+ end
+end
+
+##############################################################
+# main
+##############################################################
+# check header file
+print("check functions.")
+
+%w"ruby_native_thread_p rb_errinfo rb_safe_level rb_hash_lookup
+ rb_proc_new rb_obj_untrust rb_obj_taint rb_set_safe_level_force
+ rb_sourcefile rb_thread_alive_p rb_thread_check_trap_pending".each do |func|
+ have_func(func, "ruby.h")
+ print(".") # progress
+end
+print("\n") # progress
+
+print("check struct members.")
+have_struct_member("struct RArray", "ptr", "ruby.h")
+print(".") # progress
+have_struct_member("struct RArray", "len", "ruby.h")
+print("\n") # progress
+
+# check libraries
+unless is_win32?
+ print("check libraries.")
+ have_library("nsl", "t_open")
+ print(".") # progress
+ have_library("socket", "socket")
+ print(".") # progress
+ have_library("dl", "dlopen")
+ print(".") # progress
+ have_library("m", "log", "math.h")
+ print("\n") # progress
+end
+$CPPFLAGS ||= ""
+$CPPFLAGS += ' -D_WIN32' if /cygwin/ =~ RUBY_PLATFORM
+
+# Does ruby have nativethread ?
+TkLib_Config["ruby_with_thread"] =
+ macro_defined?('HAVE_NATIVETHREAD', '#include "ruby.h"')
+
+
+#---------------------------------------------------
+TclConfig_Info = {}
+TkConfig_Info = {}
+
+# use Tcl/Tk build dir? (has highest priority)
+TkLib_Config["tcl-build-dir"] = with_config("tcl-build-dir")
+TkLib_Config["tk-build-dir"] = with_config("tk-build-dir")
+if TkLib_Config["tcl-build-dir"]
+ puts("use Tcl build (pre-install) dir \"#{TkLib_Config["tcl-build-dir"]}\"")
+ TkLib_Config["tcl-build-dir"] = File.expand_path(TkLib_Config["tcl-build-dir"])
+ base = File.dirname(TkLib_Config["tcl-build-dir"])
+ ($INCFLAGS ||= "") << " -I#{File.join(base, "generic").quote} -I#{TkLib_Config["tcl-build-dir"].quote}"
+ $LIBPATH ||= []; $LIBPATH |= [TkLib_Config["tcl-build-dir"]]
+end
+if TkLib_Config["tk-build-dir"]
+ puts("use Tk build (pre-install) dir \"#{TkLib_Config["tk-build-dir"]}\"")
+ TkLib_Config["tk-build-dir"] = File.expand_path(TkLib_Config["tk-build-dir"])
+ base = File.dirname(TkLib_Config["tk-build-dir"])
+ ($INCFLAGS ||= "") << " -I#{File.join(base, "generic").quote} -I#{TkLib_Config["tk-build-dir"].quote}"
+ $LIBPATH ||= []; $LIBPATH |= [TkLib_Config["tk-build-dir"]]
+end
+
+# check requirement of Tcl/tk version
+tcltk_version = with_config("tcltkversion")
+TkLib_Config["tcltkversion"] = check_tcltk_version(tcltk_version)
+
+if TkLib_Config["tcl-build-dir"]
+ if (cfgfile = with_config("tclConfig-file", Dir.glob(File.join(TkLib_Config["tcl-build-dir"], "tclConfig*.sh"), File::FNM_CASEFOLD)[0]))
+ TclConfig_Info['config_file_path'] = cfgfile
+ TkLib_Config["tclConfig_info"] = cfginfo = parse_tclConfig(cfgfile)
+ if tclver = TkLib_Config["tcltkversion"][0]
+ TkLib_Config["tcltkversion"][0].sub!(/\d(\.?)\d/, "#{cfginfo['TCL_MAJOR_VERSION']}\\1#{cfginfo['TCL_MINOR_VERSION']}")
+ else
+ TkLib_Config["tcltkversion"][0] = "#{cfginfo['TCL_MAJOR_VERSION']}.#{cfginfo['TCL_MINOR_VERSION']}"
+ end
+ end
+end
+if TkLib_Config["tk-build-dir"]
+ if (cfgfile = with_config("tkConfig-file", Dir.glob(File.join(TkLib_Config["tk-build-dir"], "tkConfig*.sh"), File::FNM_CASEFOLD)[0]))
+ TkConfig_Info['config_file_path'] = cfgfile
+ TkLib_Config["tkConfig_info"] = cfginfo = parse_tclConfig(cfgfile)
+ if TkLib_Config["tcltkversion"][1]
+ TkLib_Config["tcltkversion"][1].sub!(/\d(\.?)\d/, "#{cfginfo['TK_MAJOR_VERSION']}\\1#{cfginfo['TK_MINOR_VERSION']}")
+ else
+ TkLib_Config["tcltkversion"][1] = "#{cfginfo['TK_MAJOR_VERSION']}.#{cfginfo['TK_MINOR_VERSION']}"
+ end
+ end
+end
+
+tclver, tkver = TkLib_Config["tcltkversion"]
+puts("Specified Tcl/Tk version is #{[tclver, tkver].inspect}") if tclver||tkver
+
+# use ActiveTcl ?
+#if activeTcl = with_config("ActiveTcl")
+#if activeTcl = with_config("ActiveTcl", true)
+if activeTcl = with_config("ActiveTcl", !(TkLib_Config["tcl-build-dir"] && TkLib_Config["tk-build-dir"]))
+ puts("Use ActiveTcl libraries (if available).")
+ unless activeTcl.kind_of? String
+ # set default ActiveTcl path
+ if CROSS_COMPILING
+ elsif is_win32?
+ activeTcl = 'c:/Tcl*'
+ elsif is_macosx?
+ activeTcl = '/Library/Frameworks'
+ else
+ activeTcl = '/opt/ActiveTcl*'
+ end
+ end
+end
+TkLib_Config["ActiveTcl"] = activeTcl
+
+# allow space chars on a libpath
+TkLib_Config["space-on-tk-libpath"] =
+ enable_config("space-on-tk-libpath", ! is_win32?)
+
+# enable Tcl/Tk stubs?
+=begin
+if TclConfig_Info['TCL_STUB_LIB_SPEC'] && TkConfig_Info['TK_STUB_LIB_SPEC'] &&
+ !TclConfig_Info['TCL_STUB_LIB_SPEC'].strip.empty? &&
+ !TkConfig_Info['TK_STUB_LIB_SPEC'].strip.empty?
+ stubs = true
+ unless (st = enable_config("tcltk-stubs")).nil?
+ stubs &&= st
+ end
+ unless (st = with_config("tcltk-stubs")).nil?
+ stubs &&= st
+ end
+else
+ stubs = enable_config("tcltk-stubs") || with_config("tcltk-stubs")
+end
+=end
+stubs = enable_config("tcltk-stubs") || with_config("tcltk-stubs")
+if (TkLib_Config["tcltk-stubs"] = stubs)
+ puts("Compile with Tcl/Tk stubs.")
+ $CPPFLAGS ||= ""; $CPPFLAGS += ' -DUSE_TCL_STUBS -DUSE_TK_STUBS'
+end
+
+# directory configuration of Tcl/Tk libraries
+if TkLib_Config["tcl-build-dir"]
+ tcl_idir = File.join(File.dirname(TkLib_Config["tcl-build-dir"]),"generic")
+ tcl_ldir = TkLib_Config["tcl-build-dir"]
+else
+ tcl_idir, tcl_ldir = dir_config("tcl")
+end
+if TkLib_Config["tk-build-dir"]
+ tk_idir = File.join(File.dirname(TkLib_Config["tk-build-dir"]),"generic")
+ tk_ldir = TkLib_Config["tk-build-dir"]
+else
+ tk_idir, tk_ldir = dir_config("tk")
+end
+
+tcl_idir = tk_idir unless tcl_idir
+tcl_ldir = tk_ldir unless tcl_ldir
+tk_idir = tcl_idir unless tk_idir
+tk_ldir = tcl_ldir unless tk_ldir
+
+TclConfig_Info['TCL_INCLUDE_SPEC'] ||= ""
+TkConfig_Info['TK_INCLUDE_SPEC'] ||= ""
+TclConfig_Info['TCL_INCLUDE_SPEC'][0,0] = "-I#{tcl_idir.quote} " if tcl_idir
+TkConfig_Info['TK_INCLUDE_SPEC'][0,0] = "-I#{tk_idir.quote} " if tk_idir
+
+# get tclConfig.sh/tkConfig.sh
+TkLib_Config["tcl-NG-path"] = []
+TkLib_Config["tk-NG-path"] = []
+tclcfg, tkcfg =
+ get_tclConfig(
+ TclConfig_Info['config_file_path'] || with_config("tclConfig-file", true),
+ TkConfig_Info['config_file_path'] || with_config("tkConfig-file", true),
+ (TclConfig_Info['config_file_path'])?
+ File.dirname(TclConfig_Info['config_file_path']) :
+ with_config("tclConfig-dir", tcl_ldir || true),
+ (TkConfig_Info['config_file_path'])?
+ File.dirname(TkConfig_Info['config_file_path']) :
+ with_config("tkConfig-dir", tk_ldir || true)
+ )
+TclConfig_Info.merge!(TkLib_Config["tclConfig_info"]) if TkLib_Config["tclConfig_info"]
+TkConfig_Info.merge!(TkLib_Config["tkConfig_info"]) if TkLib_Config["tkConfig_info"]
+TclConfig_Info['config_file_path'] ||= tclcfg
+TkConfig_Info['config_file_path'] ||= tkcfg
+
+tk_cfg_dir = File.dirname(TkConfig_Info['config_file_path']) rescue nil
+tcl_cfg_dir = File.dirname(TclConfig_Info['config_file_path']) rescue nil
+
+tk_ldir_list = [tk_ldir, tk_cfg_dir].uniq
+tcl_ldir_list = [tcl_ldir, tcl_cfg_dir].uniq
+
+if TkConfig_Info['config_file_path']
+ if TkLib_Config["tk-build-dir"]
+ spec_dir = get_libpath(TkConfig_Info['TK_LIB_FLAG'], TkConfig_Info['TK_BUILD_LIB_SPEC'])
+ else
+ spec_dir = get_libpath(TkConfig_Info['TK_LIB_FLAG'], TkConfig_Info['TK_LIB_SPEC'])
+ end
+ tk_ldir_list << spec_dir if File.directory?(spec_dir)
+end
+if TclConfig_Info['config_file_path']
+ if TkLib_Config["tcl-build-dir"]
+ spec_dir = get_libpath(TclConfig_Info['TCL_LIB_FLAG'], TclConfig_Info['TCL_BUILD_LIB_SPEC'])
+ else
+ spec_dir = get_libpath(TclConfig_Info['TCL_LIB_FLAG'], TclConfig_Info['TCL_LIB_SPEC'])
+ end
+ tcl_ldir_list << spec_dir if File.directory?(spec_dir)
+end
+
+# check tk_shlib_search_path
+TkLib_Config["checked_shlib_dirs"] =
+ check_shlib_search_path(with_config('tk-shlib-search-path'))
+
+# set TCL_DEFS and TK_DEFS
+$CPPFLAGS ||= ""
+# $CPPFLAGS += " #{TclConfig_Info['TCL_DEFS']}"
+# $CPPFLAGS += " #{TkConfig_Info['TK_DEFS']}"
+$defs += collect_tcltk_defs(TclConfig_Info['TCL_DEFS'], TkConfig_Info['TK_DEFS'])
+
+# MacOS X Frameworks?
+if TkLib_Config["tcltk-framework"]
+ puts("Use MacOS X Frameworks.")
+ ($LDFLAGS ||= "") << " " << libpathflag([TkLib_Config["tcl-build-dir"]]) if TkLib_Config["tcl-build-dir"]
+
+ libs = ''
+ if tcl_cfg_dir
+ TclConfig_Info['TCL_LIBS'] ||= ""
+ ($INCFLAGS ||= "") << ' ' << TclConfig_Info['TCL_INCLUDE_SPEC']
+ libs << ' ' << TclConfig_Info['TCL_LIBS']
+ if stubs
+ if TkLib_Config["tcl-build-dir"] &&
+ TclConfig_Info['TCL_BUILD_STUB_LIB_SPEC'] &&
+ !TclConfig_Info['TCL_BUILD_STUB_LIB_SPEC'].strip.empty?
+ libs << ' ' << TclConfig_Info['TCL_BUILD_STUB_LIB_SPEC']
+ else
+ libs << ' ' << TclConfig_Info['TCL_STUB_LIB_SPEC']
+ end
+ else
+ if TkLib_Config["tcl-build-dir"] &&
+ TclConfig_Info['TCL_BUILD_LIB_SPEC'] &&
+ !TclConfig_Info['TCL_BUILD_LIB_SPEC'].strip.empty?
+ libs << ' ' << TclConfig_Info['TCL_BUILD_LIB_SPEC']
+ else
+ libs << ' ' << TclConfig_Info['TCL_LIB_SPEC']
+ end
+ end
+ end
+
+ libs << " " << libpathflag([TkLib_Config["tk-build-dir"]]) if TkLib_Config["tk-build-dir"]
+
+ if tk_cfg_dir
+ TkConfig_Info['TK_LIBS'] ||= ""
+ ($INCFLAGS ||= "") << ' ' << TkConfig_Info['TK_INCLUDE_SPEC']
+ libs << ' ' << TkConfig_Info['TK_LIBS']
+ if stubs
+ if TkLib_Config["tk-build-dir"] &&
+ TclConfig_Info['TK_BUILD_STUB_LIB_SPEC'] &&
+ !TclConfig_Info['TK_BUILD_STUB_LIB_SPEC'].strip.empty?
+ libs << ' ' << TkConfig_Info['TK_BUILD_STUB_LIB_SPEC']
+ else
+ libs << ' ' << TkConfig_Info['TK_STUB_LIB_SPEC']
+ end
+ else
+ if TkLib_Config["tk-build-dir"] &&
+ TclConfig_Info['TK_BUILD_LIB_SPEC'] &&
+ !TclConfig_Info['TK_BUILD_LIB_SPEC'].strip.empty?
+ libs << ' ' << TkConfig_Info['TK_BUILD_LIB_SPEC']
+ else
+ libs << ' ' << TkConfig_Info['TK_LIB_SPEC']
+ end
+ end
+ end
+ $LDFLAGS << ' ' << libs
+ setup_for_macosx_framework(tclver, tkver) if tcl_cfg_dir && tk_cfg_dir
+end
+
+# name of Tcl/Tk libraries
+tklib = with_config("tklib")
+tcllib = with_config("tcllib")
+
+# search X libraries
+use_X = search_X_libraries
+
+
+#---------------------------------------------------
+if (TkLib_Config["tcltk-framework"] ||
+ ( find_tcltk_header(tclver, tkver) &&
+ find_tcltk_library(tcllib, tklib, stubs, tclver, tkver,
+ tcl_ldir_list, tk_ldir_list) ) ) &&
+ (stubs || pthread_check())
+ # create Makefile
+
+ # for SUPPORT_STATUS
+ $INSTALLFILES ||= []
+ $INSTALLFILES << ["lib/tkextlib/SUPPORT_STATUS", "$(RUBYLIBDIR)", "lib"]
+
+ # create
+ $defs << %[-DRUBY_VERSION=\\"#{RUBY_VERSION}\\"]
+ $defs << %[-DRUBY_RELEASE_DATE=\\"#{RUBY_RELEASE_DATE}\\"]
+
+ # remove harmful definitions.
+ $defs.delete_if{|x|/^-Du?intptr_t=/ =~ x}
+
+ create_makefile("tcltklib")
+
+ puts "\nFind Tcl/Tk libraries. Make tcltklib.so which is required by Ruby/Tk."
+else
+ puts "\nCan't find proper Tcl/Tk libraries. So, can't make tcltklib.so which is required by Ruby/Tk."
+ puts "If you have Tcl/Tk libraries on your environment, you may be able to use them with configure options (see ext/tk/README.tcltklib)."
+ puts "At present, Tcl/Tk8.6 is not supported. Although you can try to use Tcl/Tk8.6 with configure options, it will not work correctly. I recommend you to use Tcl/Tk8.5 or 8.4."
+end
diff --git a/jni/ruby/ext/tk/lib/README b/jni/ruby/ext/tk/lib/README
new file mode 100644
index 0000000..c076755
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/README
@@ -0,0 +1,30 @@
+README this file
+multi-tk.rb multiple Tk interpreter (included safe-Tk) support
+remotei-tk.rb control remote Tk interpreter on the other process support
+tk.rb Tk interface
+
+tk/ library files construct Ruby/Tk
+
+tkextlib/ non-standard Tcl/Tk extension support libraries
+
+*********************************************************************
+*** The followings exists for backward compatibility only.
+*** The only thing which they work is that requires current
+*** library files ( tk/*.rb ).
+*********************************************************************
+tkafter.rb handles Tcl after
+tkbgerror.rb Tk error module
+tkcanvas.rb Tk canvas interface
+tkclass.rb provides generic names for Tk classes
+tkconsole.rb console command support
+tkdialog.rb Tk dialog class
+tkentry.rb Tk entry class
+tkfont.rb Tk font support
+tkmacpkg.rb Mac resource support
+tkmenubar.rb TK menubar utility
+tkmngfocus.rb focus manager
+tkpalette.rb pallete support
+tkscrollbox.rb scroll box, also example of compound widget
+tktext.rb text classes
+tkvirtevent.rb virtual event support
+tkwinpkg.rb Win DDE and registry support
diff --git a/jni/ruby/ext/tk/lib/multi-tk.rb b/jni/ruby/ext/tk/lib/multi-tk.rb
new file mode 100644
index 0000000..bb6e69a
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/multi-tk.rb
@@ -0,0 +1,3754 @@
+#
+# multi-tk.rb - supports multi Tk interpreters
+# by Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
+
+require 'tcltklib'
+require 'tkutil'
+require 'thread'
+
+if defined? Tk
+ fail RuntimeError,"'multi-tk' library must be required before requiring 'tk'"
+end
+
+################################################
+# ignore exception on the mainloop?
+
+TclTkLib.mainloop_abort_on_exception = true
+# TclTkLib.mainloop_abort_on_exception = false
+# TclTkLib.mainloop_abort_on_exception = nil
+
+
+################################################
+# add ThreadGroup check to TclTkIp.new
+class << TclTkIp
+ alias __new__ new
+ private :__new__
+
+ def new(*args)
+ if Thread.current.group != ThreadGroup::Default
+ raise SecurityError, 'only ThreadGroup::Default can call TclTkIp.new'
+ end
+ obj = __new__(*args)
+ obj.instance_eval{
+ @force_default_encoding ||= TkUtil.untrust([false])
+ @encoding ||= TkUtil.untrust([nil])
+ def @encoding.to_s; self.join(nil); end
+ }
+ obj
+ end
+end
+
+
+################################################
+# exceptiopn to treat the return value from IP
+class MultiTkIp_OK < Exception
+ def self.send(thread, ret=nil)
+ thread.raise self.new(ret)
+ end
+
+ def initialize(ret=nil)
+ super('succeed')
+ @return_value = ret
+ end
+
+ attr_reader :return_value
+ alias value return_value
+end
+MultiTkIp_OK.freeze
+
+
+################################################
+# methods for construction
+class MultiTkIp
+ class Command_Queue < Queue
+ def initialize(interp)
+ @interp = interp
+ super()
+ end
+
+ def push(value)
+ if !@interp || @interp.deleted?
+ fail RuntimeError, "Tk interpreter is already deleted"
+ end
+ super(value)
+ end
+ alias << push
+ alias enq push
+
+ def close
+ @interp = nil
+ end
+ end
+ Command_Queue.freeze
+
+ BASE_DIR = File.dirname(__FILE__)
+
+ WITH_RUBY_VM = Object.const_defined?(:RubyVM) && ::RubyVM.class == Class
+ WITH_ENCODING = defined?(::Encoding.default_external)
+ #WITH_ENCODING = Object.const_defined?(:Encoding) && ::Encoding.class == Class
+
+ (@@SLAVE_IP_ID = ['slave'.freeze, TkUtil.untrust('0')]).instance_eval{
+ @mutex = Mutex.new
+ def mutex; @mutex; end
+ freeze
+ }
+
+ @@IP_TABLE = TkUtil.untrust({}) unless defined?(@@IP_TABLE)
+
+ @@INIT_IP_ENV = TkUtil.untrust([]) unless defined?(@@INIT_IP_ENV) # table of Procs
+ @@ADD_TK_PROCS = TkUtil.untrust([]) unless defined?(@@ADD_TK_PROCS) # table of [name, args, body]
+
+ @@TK_TABLE_LIST = TkUtil.untrust([]) unless defined?(@@TK_TABLE_LIST)
+
+ unless defined?(@@TK_CMD_TBL)
+ @@TK_CMD_TBL = TkUtil.untrust(Object.new)
+
+ # @@TK_CMD_TBL.instance_variable_set('@tbl', {}.taint)
+ tbl_obj = TkUtil.untrust(Hash.new{|hash,key|
+ fail IndexError, "unknown command ID '#{key}'"
+ })
+ @@TK_CMD_TBL.instance_variable_set('@tbl', tbl_obj)
+
+ class << @@TK_CMD_TBL
+ allow = [
+ '__send__', '__id__', 'freeze', 'inspect', 'kind_of?', 'object_id',
+ '[]', '[]=', 'delete', 'each', 'has_key?'
+ ]
+ instance_methods.each{|m| undef_method(m) unless allow.index(m.to_s)}
+
+ def kind_of?(klass)
+ @tbl.kind_of?(klass)
+ end
+
+ def inspect
+ if Thread.current.group == ThreadGroup::Default
+ @tbl.inspect
+ else
+ ip = MultiTkIp.__getip
+ @tbl.reject{|idx, ent| ent.respond_to?(:ip) && ent.ip != ip}.inspect
+ end
+ end
+
+ def [](idx)
+ return unless (ent = @tbl[idx])
+ if Thread.current.group == ThreadGroup::Default
+ ent
+ elsif ent.respond_to?(:ip)
+ (ent.ip == MultiTkIp.__getip)? ent: nil
+ else
+ ent
+ end
+ end
+
+ def []=(idx,val)
+ if self.has_key?(idx) && Thread.current.group != ThreadGroup::Default
+ fail SecurityError,"cannot change the entried command"
+ end
+ @tbl[idx] = val
+ end
+
+ def delete(idx, &blk)
+ # if gets an entry, is permitted to delete
+ if self[idx]
+ @tbl.delete(idx)
+ elsif blk
+ blk.call(idx)
+ else
+ nil
+ end
+ end
+
+ def each(&blk)
+ if Thread.current.group == ThreadGroup::Default
+ @tbl.each(&blk)
+ else
+ ip = MultiTkIp.__getip
+ @tbl.each{|idx, ent|
+ blk.call(idx, ent) unless ent.respond_to?(:ip) && ent.ip != ip
+ }
+ end
+ self
+ end
+
+ def has_key?(k)
+ @tbl.has_key?(k)
+ end
+ alias include? has_key?
+ alias key? has_key?
+ alias member? has_key?
+ end
+
+ @@TK_CMD_TBL.freeze
+ end
+
+ ######################################
+
+ @@CB_ENTRY_CLASS = Class.new(TkCallbackEntry){
+ def initialize(ip, cmd)
+ @ip = ip
+ @safe = safe = $SAFE
+ # @cmd = cmd
+ cmd = MultiTkIp._proc_on_safelevel(&cmd)
+ @cmd = proc{|*args| cmd.call(safe, *args)}
+ self.freeze
+ end
+ attr_reader :ip, :cmd
+ def inspect
+ cmd.inspect
+ end
+ def call(*args)
+ unless @ip.deleted?
+ current = Thread.current
+ backup_ip = current[:callback_ip]
+ current[:callback_ip] = @ip
+ begin
+ ret = @ip.cb_eval(@cmd, *args)
+ fail ret if ret.kind_of?(Exception)
+ ret
+ rescue TkCallbackBreak, TkCallbackContinue => e
+ fail e
+ rescue SecurityError => e
+ # in 'exit', 'exit!', and 'abort' : security error --> delete IP
+ if e.backtrace[0] =~ /^(.+?):(\d+):in `(exit|exit!|abort)'/
+ @ip.delete
+ elsif @ip.safe?
+ if @ip.respond_to?(:cb_error)
+ @ip.cb_error(e)
+ else
+ nil # ignore
+ end
+ else
+ fail e
+ end
+ rescue Exception => e
+ fail e if e.message =~ /^TkCallback/
+
+ if @ip.safe?
+ if @ip.respond_to?(:cb_error)
+ @ip.cb_error(e)
+ else
+ nil # ignore
+ end
+ else
+ fail e
+ end
+ ensure
+ current[:callback_ip] = backup_ip
+ end
+ end
+ end
+ }.freeze
+
+ ######################################
+
+ def _keys2opts(src_keys)
+ return nil if src_keys == nil
+ keys = {}; src_keys.each{|k, v| keys[k.to_s] = v}
+ #keys.collect{|k,v| "-#{k} #{v}"}.join(' ')
+ keys.collect{|k,v| "-#{k} #{TclTkLib._conv_listelement(TkComm::_get_eval_string(v))}"}.join(' ')
+ end
+ private :_keys2opts
+
+ def _check_and_return(thread, exception, wait=0)
+ unless thread
+ unless exception.kind_of?(MultiTkIp_OK)
+ msg = "#{exception.class}: #{exception.message}"
+
+ if @interp.deleted?
+ warn("Warning (#{self}): " + msg)
+ return nil
+ end
+
+ if safe?
+ warn("Warning (#{self}): " + msg) if $DEBUG
+ return nil
+ end
+
+ begin
+ @interp._eval_without_enc(@interp._merge_tklist('bgerror', msg))
+ rescue Exception => e
+ warn("Warning (#{self}): " + msg)
+ end
+ end
+ return nil
+ end
+
+ if wait == 0
+ # no wait
+ Thread.pass
+ if thread.stop?
+ thread.raise exception
+ end
+ return thread
+ end
+
+ # wait to stop the caller thread
+ wait.times{
+ if thread.stop?
+ # ready to send exception
+ thread.raise exception
+ return thread
+ end
+
+ # wait
+ Thread.pass
+ }
+
+ # unexpected error
+ thread.raise RuntimeError, "the thread may not wait for the return value"
+ return thread
+ end
+
+ ######################################
+
+ def set_cb_error(cmd = Proc.new)
+ @cb_error_proc[0] = cmd
+ end
+
+ def cb_error(e)
+ if @cb_error_proc[0].respond_to?(:call)
+ @cb_error_proc[0].call(e)
+ end
+ end
+
+ ######################################
+
+ def set_safe_level(safe)
+ if safe > @safe_level[0]
+ @safe_level[0] = safe
+ @cmd_queue.enq([@system, 'set_safe_level', safe])
+ end
+ @safe_level[0]
+ end
+ def safe_level=(safe)
+ set_safe_level(safe)
+ end
+ def self.set_safe_level(safe)
+ __getip.set_safe_level(safe)
+ end
+ def self.safe_level=(safe)
+ self.set_safe_level(safe)
+ end
+ def safe_level
+ @safe_level[0]
+ end
+ def self.safe_level
+ __getip.safe_level
+ end
+
+ def wait_on_mainloop?
+ @wait_on_mainloop[0]
+ end
+ def wait_on_mainloop=(bool)
+ @wait_on_mainloop[0] = bool
+ end
+
+ def running_mainloop?
+ @wait_on_mainloop[1] > 0
+ end
+
+ def _destroy_slaves_of_slaveIP(ip)
+ unless ip.deleted?
+ # ip._split_tklist(ip._invoke('interp', 'slaves')).each{|name|
+ ip._split_tklist(ip._invoke_without_enc('interp', 'slaves')).each{|name|
+ name = _fromUTF8(name)
+ begin
+ # ip._eval_without_enc("#{name} eval {foreach i [after info] {after cancel $i}}")
+ after_ids = ip._eval_without_enc("#{name} eval {after info}")
+ ip._eval_without_enc("#{name} eval {foreach i {#{after_ids}} {after cancel $i}}")
+ rescue Exception
+ end
+ begin
+ # ip._invoke('interp', 'eval', name, 'destroy', '.')
+ ip._invoke(name, 'eval', 'destroy', '.')
+ rescue Exception
+ end
+
+ # safe_base?
+ if ip._eval_without_enc("catch {::safe::interpConfigure #{name}}") == '0'
+ begin
+ ip._eval_without_enc("::safe::interpDelete #{name}")
+ rescue Exception
+ end
+ end
+=begin
+ if ip._invoke('interp', 'exists', name) == '1'
+ begin
+ ip._invoke(name, 'eval', 'exit')
+ rescue Exception
+ end
+ end
+=end
+ unless ip.deleted?
+ if ip._invoke('interp', 'exists', name) == '1'
+ begin
+ ip._invoke('interp', 'delete', name)
+ rescue Exception
+ end
+ end
+ end
+ }
+ end
+ end
+
+ def _receiver_eval_proc_core(safe_level, thread, cmd, *args)
+ begin
+ #ret = proc{$SAFE = safe_level; cmd.call(*args)}.call
+ #ret = cmd.call(safe_level, *args)
+ normal_ret = false
+ ret = catch(:IRB_EXIT) do # IRB hack
+ retval = cmd.call(safe_level, *args)
+ normal_ret = true
+ retval
+ end
+ unless normal_ret
+ # catch IRB_EXIT
+ exit(ret)
+ end
+ ret
+ rescue SystemExit => e
+ # delete IP
+ unless @interp.deleted?
+ @slave_ip_tbl.each{|name, subip|
+ _destroy_slaves_of_slaveIP(subip)
+ begin
+ # subip._eval_without_enc("foreach i [after info] {after cancel $i}")
+ after_ids = subip._eval_without_enc("after info")
+ subip._eval_without_enc("foreach i {#{after_ids}} {after cancel $i}")
+ rescue Exception
+ end
+=begin
+ begin
+ subip._invoke('destroy', '.') unless subip.deleted?
+ rescue Exception
+ end
+=end
+ # safe_base?
+ if @interp._eval_without_enc("catch {::safe::interpConfigure #{name}}") == '0'
+ begin
+ @interp._eval_without_enc("::safe::interpDelete #{name}")
+ rescue Exception
+ else
+ next if subip.deleted?
+ end
+ end
+ if subip.respond_to?(:safe_base?) && subip.safe_base? &&
+ !subip.deleted?
+ # do 'exit' to call the delete_hook procedure
+ begin
+ subip._eval_without_enc('exit')
+ rescue Exception
+ end
+ else
+ begin
+ subip.delete unless subip.deleted?
+ rescue Exception
+ end
+ end
+ }
+
+ begin
+ # @interp._eval_without_enc("foreach i [after info] {after cancel $i}")
+ after_ids = @interp._eval_without_enc("after info")
+ @interp._eval_without_enc("foreach i {#{after_ids}} {after cancel $i}")
+ rescue Exception
+ end
+ begin
+ @interp._invoke('destroy', '.') unless @interp.deleted?
+ rescue Exception
+ end
+ if @safe_base && !@interp.deleted?
+ # do 'exit' to call the delete_hook procedure
+ @interp._eval_without_enc('exit')
+ else
+ @interp.delete unless @interp.deleted?
+ end
+ end
+
+ if e.backtrace[0] =~ /^(.+?):(\d+):in `(exit|exit!|abort)'/
+ _check_and_return(thread, MultiTkIp_OK.new($3 == 'exit'))
+ else
+ _check_and_return(thread, MultiTkIp_OK.new(nil))
+ end
+
+ # if master? && !safe? && allow_ruby_exit?
+ if !@interp.deleted? && master? && !safe? && allow_ruby_exit?
+=begin
+ ObjectSpace.each_object(TclTkIp){|obj|
+ obj.delete unless obj.deleted?
+ }
+=end
+ #exit(e.status)
+ fail e
+ end
+ # break
+
+ rescue SecurityError => e
+ # in 'exit', 'exit!', and 'abort' : security error --> delete IP
+ if e.backtrace[0] =~ /^(.+?):(\d+):in `(exit|exit!|abort)'/
+ ret = ($3 == 'exit')
+ unless @interp.deleted?
+ @slave_ip_tbl.each{|name, subip|
+ _destroy_slaves_of_slaveIP(subip)
+ begin
+ # subip._eval_without_enc("foreach i [after info] {after cancel $i}")
+ after_ids = subip._eval_without_enc("after info")
+ subip._eval_without_enc("foreach i {#{after_ids}} {after cancel $i}")
+ rescue Exception
+ end
+=begin
+ begin
+ subip._invoke('destroy', '.') unless subip.deleted?
+ rescue Exception
+ end
+=end
+ # safe_base?
+ if @interp._eval_without_enc("catch {::safe::interpConfigure #{name}}") == '0'
+ begin
+ @interp._eval_without_enc("::safe::interpDelete #{name}")
+ rescue Exception
+ else
+ next if subip.deleted?
+ end
+ end
+ if subip.respond_to?(:safe_base?) && subip.safe_base? &&
+ !subip.deleted?
+ # do 'exit' to call the delete_hook procedure
+ begin
+ subip._eval_without_enc('exit')
+ rescue Exception
+ end
+ else
+ begin
+ subip.delete unless subip.deleted?
+ rescue Exception
+ end
+ end
+ }
+
+ begin
+ # @interp._eval_without_enc("foreach i [after info] {after cancel $i}")
+ after_ids = @interp._eval_without_enc("after info")
+ @interp._eval_without_enc("foreach i {#{after_ids}} {after cancel $i}")
+ rescue Exception
+ end
+=begin
+ begin
+ @interp._invoke('destroy', '.') unless @interp.deleted?
+ rescue Exception
+ end
+=end
+ if @safe_base && !@interp.deleted?
+ # do 'exit' to call the delete_hook procedure
+ @interp._eval_without_enc('exit')
+ else
+ @interp.delete unless @interp.deleted?
+ end
+ end
+ _check_and_return(thread, MultiTkIp_OK.new(ret))
+ # break
+
+ else
+ # raise security error
+ _check_and_return(thread, e)
+ end
+
+ rescue Exception => e
+ # raise exception
+ begin
+ bt = _toUTF8(e.backtrace.join("\n"))
+ if MultiTkIp::WITH_ENCODING
+ bt.force_encoding('utf-8')
+ else
+ bt.instance_variable_set(:@encoding, 'utf-8')
+ end
+ rescue Exception
+ bt = e.backtrace.join("\n")
+ end
+ begin
+ @interp._set_global_var('errorInfo', bt)
+ rescue Exception
+ end
+ _check_and_return(thread, e)
+
+ else
+ # no exception
+ _check_and_return(thread, MultiTkIp_OK.new(ret))
+ end
+ end
+
+ def _receiver_eval_proc(last_thread, safe_level, thread, cmd, *args)
+ if thread
+ Thread.new{
+ last_thread.join if last_thread
+ unless @interp.deleted?
+ _receiver_eval_proc_core(safe_level, thread, cmd, *args)
+ end
+ }
+ else
+ Thread.new{
+ unless @interp.deleted?
+ _receiver_eval_proc_core(safe_level, thread, cmd, *args)
+ end
+ }
+ last_thread
+ end
+ end
+
+ private :_receiver_eval_proc, :_receiver_eval_proc_core
+
+ def _receiver_mainloop(check_root)
+ if @evloop_thread[0] && @evloop_thread[0].alive?
+ @evloop_thread[0]
+ else
+ @evloop_thread[0] = Thread.new{
+ while !@interp.deleted?
+ #if check_root
+ # inf = @interp._invoke_without_enc('info', 'command', '.')
+ # break if !inf.kind_of?(String) || inf != '.'
+ #end
+ break if check_root && !@interp.has_mainwindow?
+ sleep 0.5
+ end
+ }
+ @evloop_thread[0]
+ end
+ end
+
+ def _create_receiver_and_watchdog(lvl = $SAFE)
+ lvl = $SAFE if lvl < $SAFE
+
+ # command-procedures receiver
+ receiver = Thread.new(lvl){|safe_level|
+ last_thread = {}
+
+ loop do
+ break if @interp.deleted?
+ thread, cmd, *args = @cmd_queue.deq
+ if thread == @system
+ # control command
+ case cmd
+ when 'set_safe_level'
+ begin
+ safe_level = args[0] if safe_level < args[0]
+ rescue Exception
+ end
+ when 'call_mainloop'
+ thread = args.shift
+ _check_and_return(thread,
+ MultiTkIp_OK.new(_receiver_mainloop(*args)))
+ else
+ # ignore
+ end
+
+ else
+ # procedure
+ last_thread[thread] = _receiver_eval_proc(last_thread[thread],
+ safe_level, thread,
+ cmd, *args)
+ end
+ end
+ }
+
+ # watchdog of receiver
+ watchdog = Thread.new{
+ begin
+ loop do
+ sleep 1
+ if @interp.deleted?
+ receiver.kill
+ @cmd_queue.close
+ end
+ break unless receiver.alive?
+ end
+ rescue Exception
+ # ignore all kind of Exception
+ end
+
+ # receiver is dead
+ retry_count = 3
+ loop do
+ Thread.pass
+ begin
+ thread, cmd, *args = @cmd_queue.deq(true) # non-block
+ rescue ThreadError
+ # queue is empty
+ retry_count -= 1
+ break if retry_count <= 0
+ sleep 0.5
+ retry
+ end
+ next unless thread
+ if thread.alive?
+ if @interp.deleted?
+ thread.raise RuntimeError, 'the interpreter is already deleted'
+ else
+ thread.raise RuntimeError,
+ 'the interpreter no longer receives command procedures'
+ end
+ end
+ end
+ }
+
+ # return threads
+ [receiver, watchdog]
+ end
+ private :_check_and_return, :_create_receiver_and_watchdog
+
+ ######################################
+
+ unless self.const_defined? :RUN_EVENTLOOP_ON_MAIN_THREAD
+ ### Ruby 1.9 !!!!!!!!!!!!!!!!!!!!!!!!!!
+ RUN_EVENTLOOP_ON_MAIN_THREAD = false
+ end
+
+ if self.const_defined? :DEFAULT_MASTER_NAME
+ name = DEFAULT_MASTER_NAME.to_s
+ else
+ name = nil
+ end
+ if self.const_defined?(:DEFAULT_MASTER_OPTS) &&
+ DEFAULT_MASTER_OPTS.kind_of?(Hash)
+ keys = DEFAULT_MASTER_OPTS
+ else
+ keys = {}
+ end
+
+ @@DEFAULT_MASTER = self.allocate
+ @@DEFAULT_MASTER.instance_eval{
+ @tk_windows = TkUtil.untrust({})
+
+ @tk_table_list = TkUtil.untrust([])
+
+ @slave_ip_tbl = TkUtil.untrust({})
+
+ @slave_ip_top = TkUtil.untrust({})
+
+ @evloop_thread = TkUtil.untrust([])
+
+ unless keys.kind_of? Hash
+ fail ArgumentError, "expecting a Hash object for the 2nd argument"
+ end
+
+ if !WITH_RUBY_VM || RUN_EVENTLOOP_ON_MAIN_THREAD ### check Ruby 1.9 !!!!!!!
+ @interp = TclTkIp.new(name, _keys2opts(keys))
+ else ### Ruby 1.9 !!!!!!!!!!!
+ @interp_thread = Thread.new{
+ current = Thread.current
+ begin
+ current[:interp] = interp = TclTkIp.new(name, _keys2opts(keys))
+ rescue e
+ current[:interp] = e
+ raise e
+ end
+ #sleep
+ current[:mutex] = mutex = Mutex.new
+ current[:root_check] = cond_var = ConditionVariable.new
+
+ status = [nil]
+ def status.value
+ self[0]
+ end
+ def status.value=(val)
+ self[0] = val
+ end
+ current[:status] = status
+
+ begin
+ begin
+ #TclTkLib.mainloop_abort_on_exception = false
+ #Thread.current[:status].value = TclTkLib.mainloop(true)
+ interp.mainloop_abort_on_exception = true
+ current[:status].value = interp.mainloop(true)
+ rescue SystemExit=>e
+ current[:status].value = e
+ rescue Exception=>e
+ current[:status].value = e
+ retry if interp.has_mainwindow?
+ ensure
+ mutex.synchronize{ cond_var.broadcast }
+ end
+
+ #Thread.current[:status].value = TclTkLib.mainloop(false)
+ current[:status].value = interp.mainloop(false)
+
+ ensure
+ # interp must be deleted before the thread for interp is dead.
+ # If not, raise Tcl_Panic on Tcl_AsyncDelete because async handler
+ # deleted by the wrong thread.
+ interp.delete
+ end
+ }
+ until @interp_thread[:interp]
+ Thread.pass
+ end
+ # INTERP_THREAD.run
+ raise @interp_thread[:interp] if @interp_thread[:interp].kind_of? Exception
+ @interp = @interp_thread[:interp]
+
+ # delete the interpreter and kill the eventloop thread at exit
+ interp = @interp
+ interp_thread = @interp_thread
+ END{
+ if interp_thread.alive?
+ interp.delete
+ interp_thread.kill
+ end
+ }
+
+ def self.mainloop(check_root = true)
+ begin
+ TclTkLib.set_eventloop_window_mode(true)
+ @interp_thread.value
+ ensure
+ TclTkLib.set_eventloop_window_mode(false)
+ end
+ end
+ end
+
+ @interp.instance_eval{
+ @force_default_encoding ||= TkUtil.untrust([false])
+ @encoding ||= TkUtil.untrust([nil])
+ def @encoding.to_s; self.join(nil); end
+ }
+
+ @ip_name = nil
+
+ @callback_status = TkUtil.untrust([])
+
+ @system = Object.new
+
+ @wait_on_mainloop = TkUtil.untrust([true, 0])
+
+ @threadgroup = Thread.current.group
+
+ @safe_base = false
+
+ @safe_level = [$SAFE]
+
+ @cmd_queue = MultiTkIp::Command_Queue.new(@interp)
+
+ @cmd_receiver, @receiver_watchdog = _create_receiver_and_watchdog(@safe_level[0])
+
+ @threadgroup.add @cmd_receiver
+ @threadgroup.add @receiver_watchdog
+
+ # NOT enclose @threadgroup for @@DEFAULT_MASTER
+
+ @@IP_TABLE[ThreadGroup::Default] = self
+ @@IP_TABLE[@threadgroup] = self
+
+ #################################
+
+ @pseudo_toplevel = [false, nil]
+
+ def self.__pseudo_toplevel
+ Thread.current.group == ThreadGroup::Default &&
+ MultiTkIp.__getip == @@DEFAULT_MASTER &&
+ self.__pseudo_toplevel_evaluable? && @pseudo_toplevel[1]
+ end
+
+ def self.__pseudo_toplevel=(m)
+ unless (Thread.current.group == ThreadGroup::Default &&
+ MultiTkIp.__getip == @@DEFAULT_MASTER)
+ fail SecurityError, "no permission to manipulate"
+ end
+
+ # if m.kind_of?(Module) && m.respond_to?(:pseudo_toplevel_evaluable?)
+ if m.respond_to?(:pseudo_toplevel_evaluable?)
+ @pseudo_toplevel[0] = true
+ @pseudo_toplevel[1] = m
+ else
+ fail ArgumentError, 'fail to set pseudo-toplevel'
+ end
+ self
+ end
+
+ def self.__pseudo_toplevel_evaluable?
+ begin
+ @pseudo_toplevel[0] && @pseudo_toplevel[1].pseudo_toplevel_evaluable?
+ rescue Exception
+ false
+ end
+ end
+
+ def self.__pseudo_toplevel_evaluable=(mode)
+ unless (Thread.current.group == ThreadGroup::Default &&
+ MultiTkIp.__getip == @@DEFAULT_MASTER)
+ fail SecurityError, "no permission to manipulate"
+ end
+
+ @pseudo_toplevel[0] = (mode)? true: false
+ end
+
+ #################################
+
+ @assign_request = Class.new(Exception){
+ def self.new(target, ret)
+ obj = super()
+ obj.target = target
+ obj.ret = ret
+ obj
+ end
+ attr_accessor :target, :ret
+ }
+
+ @assign_thread = Thread.new{
+ loop do
+ begin
+ Thread.stop
+ rescue @assign_request=>req
+ begin
+ req.ret[0] = req.target.instance_eval{
+ @cmd_receiver, @receiver_watchdog =
+ _create_receiver_and_watchdog(@safe_level[0])
+ @threadgroup.add @cmd_receiver
+ @threadgroup.add @receiver_watchdog
+ @threadgroup.enclose
+ true
+ }
+ rescue Exception=>e
+ begin
+ req.ret[0] = e
+ rescue Exception
+ # ignore
+ end
+ end
+ rescue Exception
+ # ignore
+ end
+ end
+ }
+
+ def self.assign_receiver_and_watchdog(target)
+ ret = [nil]
+ @assign_thread.raise(@assign_request.new(target, ret))
+ while ret[0] == nil
+ unless @assign_thread.alive?
+ raise RuntimeError, 'lost the thread to assign a receiver and a watchdog thread'
+ end
+ end
+ if ret[0].kind_of?(Exception)
+ raise ret[0]
+ else
+ ret[0]
+ end
+ end
+
+ #################################
+
+ @init_ip_env_queue = Queue.new
+ Thread.new{
+ current = Thread.current
+ loop {
+ mtx, cond, ret, table, script = @init_ip_env_queue.deq
+ begin
+ ret[0] = table.each{|tg, ip| ip._init_ip_env(script) }
+ rescue Exception => e
+ ret[0] = e
+ ensure
+ mtx.synchronize{ cond.signal }
+ end
+ mtx = cond = ret = table = script = nil # clear variables for GC
+ }
+ }
+
+ def self.__init_ip_env__(table, script)
+ ret = []
+ mtx = (Thread.current[:MultiTk_ip_Mutex] ||= Mutex.new)
+ cond = (Thread.current[:MultiTk_ip_CondVar] ||= ConditionVariable.new)
+ mtx.synchronize{
+ @init_ip_env_queue.enq([mtx, cond, ret, table, script])
+ cond.wait(mtx)
+ }
+ if ret[0].kind_of?(Exception)
+ raise ret[0]
+ else
+ ret[0]
+ end
+ end
+
+ #################################
+
+ class << self
+ undef :instance_eval
+ end
+ }
+
+ @@DEFAULT_MASTER.freeze # defend against modification
+
+ ######################################
+
+ def self.inherited(subclass)
+ # trust if on ThreadGroup::Default or @@DEFAULT_MASTER's ThreadGroup
+ if @@IP_TABLE[Thread.current.group] == @@DEFAULT_MASTER
+ begin
+ class << subclass
+ self.methods.each{|m|
+ name = m.to_s
+ begin
+ unless name == '__id__' || name == '__send__' || name == 'freeze'
+ undef_method(m)
+ end
+ rescue Exception
+ # ignore all exceptions
+ end
+ }
+ end
+ ensure
+ subclass.freeze
+ fail SecurityError,
+ "cannot create subclass of MultiTkIp on a untrusted ThreadGroup"
+ end
+ end
+ end
+
+ ######################################
+
+ @@SAFE_OPT_LIST = [
+ 'accessPath'.freeze,
+ 'statics'.freeze,
+ 'nested'.freeze,
+ 'deleteHook'.freeze
+ ].freeze
+
+ def _parse_slaveopts(keys)
+ name = nil
+ safe = false
+ safe_opts = {}
+ tk_opts = {}
+
+ keys.each{|k,v|
+ k_str = k.to_s
+ if k_str == 'name'
+ name = v
+ elsif k_str == 'safe'
+ safe = v
+ elsif @@SAFE_OPT_LIST.member?(k_str)
+ safe_opts[k_str] = v
+ else
+ tk_opts[k_str] = v
+ end
+ }
+
+ if keys['without_tk'] || keys[:without_tk]
+ [name, safe, safe_opts, nil]
+ else
+ [name, safe, safe_opts, tk_opts]
+ end
+ end
+ private :_parse_slaveopts
+
+ def _create_slave_ip_name
+ @@SLAVE_IP_ID.mutex.synchronize{
+ name = @@SLAVE_IP_ID.join('')
+ @@SLAVE_IP_ID[1].succ!
+ name.freeze
+ }
+ end
+ private :_create_slave_ip_name
+
+ ######################################
+
+ def __check_safetk_optkeys(optkeys)
+ # based on 'safetk.tcl'
+ new_keys = {}
+ optkeys.each{|k,v| new_keys[k.to_s] = v}
+
+ # check 'display'
+ if !new_keys.key?('display')
+ begin
+ #new_keys['display'] = @interp._invoke('winfo screen .')
+ new_keys['display'] = @interp._invoke('winfo', 'screen', '.')
+ rescue
+ if ENV[DISPLAY]
+ new_keys['display'] = ENV[DISPLAY]
+ elsif !new_keys.key?('use')
+ warn "Warning: no screen info or ENV[DISPLAY], so use ':0.0'"
+ new_keys['display'] = ':0.0'
+ end
+ end
+ end
+
+ # check 'use'
+ if new_keys.key?('use')
+ # given 'use'
+ case new_keys['use']
+ when TkWindow
+ new_keys['use'] = TkWinfo.id(new_keys['use'])
+ #assoc_display = @interp._eval('winfo screen .')
+ assoc_display = @interp._invoke('winfo', 'screen', '.')
+ when /^\..*/
+ new_keys['use'] = @interp._invoke('winfo', 'id', new_keys['use'])
+ assoc_display = @interp._invoke('winfo', 'screen', new_keys['use'])
+ else
+ begin
+ pathname = @interp._invoke('winfo', 'pathname', new_keys['use'])
+ assoc_display = @interp._invoke('winfo', 'screen', pathname)
+ rescue
+ assoc_display = new_keys['display']
+ end
+ end
+
+ # match display?
+ if assoc_display != new_keys['display']
+ if optkeys.key?(:display) || optkeys.key?('display')
+ fail RuntimeError,
+ "conflicting 'display'=>#{new_keys['display']} " +
+ "and display '#{assoc_display}' on 'use'=>#{new_keys['use']}"
+ else
+ new_keys['display'] = assoc_display
+ end
+ end
+ end
+
+ # return
+ new_keys
+ end
+ private :__check_safetk_optkeys
+
+ def __create_safetk_frame(slave_ip, slave_name, app_name, keys)
+ # display option is used by ::safe::loadTk
+ loadTk_keys = {}
+ loadTk_keys['display'] = keys['display']
+ dup_keys = keys.dup
+
+ # keys for toplevel : allow followings
+ toplevel_keys = {}
+ ['height', 'width', 'background', 'menu'].each{|k|
+ toplevel_keys[k] = dup_keys.delete(k) if dup_keys.key?(k)
+ }
+ toplevel_keys['classname'] = 'SafeTk'
+ toplevel_keys['screen'] = dup_keys.delete('display')
+
+ # other keys used by pack option of container frame
+
+ # create toplevel widget
+ begin
+ top = TkToplevel.new(toplevel_keys)
+ rescue NameError => e
+ fail e unless @interp.safe?
+ fail SecurityError, "unable create toplevel on the safe interpreter"
+ end
+ msg = "Untrusted Ruby/Tk applet (#{slave_name})"
+ if app_name.kind_of?(String)
+ top.title "#{app_name} (#{slave_name})"
+ else
+ top.title msg
+ end
+
+ # procedure to delete slave interpreter
+ slave_delete_proc = proc{
+ unless slave_ip.deleted?
+ #if slave_ip._invoke('info', 'command', '.') != ""
+ # slave_ip._invoke('destroy', '.')
+ #end
+ #slave_ip.delete
+ slave_ip._eval_without_enc('exit')
+ end
+ begin
+ top.destroy if top.winfo_exist?
+ rescue
+ # ignore
+ end
+ }
+ tag = TkBindTag.new.bind('Destroy', slave_delete_proc)
+
+ top.bindtags = top.bindtags.unshift(tag)
+
+ # create control frame
+ TkFrame.new(top, :bg=>'red', :borderwidth=>3, :relief=>'ridge') {|fc|
+ fc.bindtags = fc.bindtags.unshift(tag)
+
+ TkFrame.new(fc, :bd=>0){|f|
+ TkButton.new(f,
+ :text=>'Delete', :bd=>1, :padx=>2, :pady=>0,
+ :highlightthickness=>0, :command=>slave_delete_proc
+ ).pack(:side=>:right, :fill=>:both)
+ f.pack(:side=>:right, :fill=>:both, :expand=>true)
+ }
+
+ TkLabel.new(fc, :text=>msg, :padx=>2, :pady=>0,
+ :anchor=>:w).pack(:side=>:left, :fill=>:both, :expand=>true)
+
+ fc.pack(:side=>:bottom, :fill=>:x)
+ }
+
+ # container frame for slave interpreter
+ dup_keys['fill'] = :both unless dup_keys.key?('fill')
+ dup_keys['expand'] = true unless dup_keys.key?('expand')
+ c = TkFrame.new(top, :container=>true).pack(dup_keys)
+ c.bind('Destroy', proc{top.destroy})
+
+ # return keys
+ loadTk_keys['use'] = TkWinfo.id(c)
+ [loadTk_keys, top.path]
+ end
+ private :__create_safetk_frame
+
+ def __create_safe_slave_obj(safe_opts, app_name, tk_opts)
+ raise SecurityError, "no permission to manipulate" unless self.manipulable?
+
+ # safe interpreter
+ ip_name = _create_slave_ip_name
+ slave_ip = @interp.create_slave(ip_name, true)
+ slave_ip.instance_eval{
+ @force_default_encoding ||= TkUtil.untrust([false])
+ @encoding ||= TkUtil.untrust([nil])
+ def @encoding.to_s; self.join(nil); end
+ }
+ @slave_ip_tbl[ip_name] = slave_ip
+ def slave_ip.safe_base?
+ true
+ end
+
+ @interp._eval("::safe::interpInit #{ip_name}")
+
+ slave_ip._invoke('set', 'argv0', app_name) if app_name.kind_of?(String)
+
+ if tk_opts
+ tk_opts = __check_safetk_optkeys(tk_opts)
+ if tk_opts.key?('use')
+ @slave_ip_top[ip_name] = ''
+ else
+ tk_opts, top_path = __create_safetk_frame(slave_ip, ip_name, app_name,
+ tk_opts)
+ @slave_ip_top[ip_name] = top_path
+ end
+ @interp._eval("::safe::loadTk #{ip_name} #{_keys2opts(tk_opts)}")
+ @interp._invoke('__replace_slave_tk_commands__', ip_name)
+ else
+ @slave_ip_top[ip_name] = nil
+ end
+
+ if safe_opts.key?('deleteHook') || safe_opts.key?(:deleteHook)
+ @interp._eval("::safe::interpConfigure #{ip_name} " +
+ _keys2opts(safe_opts))
+ else
+ @interp._eval("::safe::interpConfigure #{ip_name} " +
+ _keys2opts(safe_opts) + '-deleteHook {' +
+ TkComm._get_eval_string(proc{|slave|
+ self._default_delete_hook(slave)
+ }) + '}')
+ end
+
+ [slave_ip, ip_name]
+ end
+
+ def __create_trusted_slave_obj(name, keys)
+ raise SecurityError, "no permission to manipulate" unless self.manipulable?
+
+ ip_name = _create_slave_ip_name
+ slave_ip = @interp.create_slave(ip_name, false)
+ slave_ip.instance_eval{
+ @force_default_encoding ||= TkUtil.untrust([false])
+ @encoding ||= TkUtil.untrust([nil])
+ def @encoding.to_s; self.join(nil); end
+ }
+ slave_ip._invoke('set', 'argv0', name) if name.kind_of?(String)
+ slave_ip._invoke('set', 'argv', _keys2opts(keys))
+ @interp._invoke('load', '', 'Tk', ip_name)
+ @interp._invoke('__replace_slave_tk_commands__', ip_name)
+ @slave_ip_tbl[ip_name] = slave_ip
+ [slave_ip, ip_name]
+ end
+
+ ######################################
+
+ def _create_slave_object(keys={})
+ raise SecurityError, "no permission to manipulate" unless self.manipulable?
+
+ ip = MultiTkIp.new_slave(self, keys={})
+ @slave_ip_tbl[ip.name] = ip
+ end
+
+ ######################################
+
+ def initialize(master, safeip=true, keys={})
+ if $SAFE >= 4
+ fail SecurityError, "cannot create a new interpreter at level #{$SAFE}"
+ end
+
+ if safeip == nil && $SAFE >= 2
+ fail SecurityError, "cannot create a master-ip at level #{$SAFE}"
+ end
+
+ if master.deleted? && safeip == nil
+ fail RuntimeError, "cannot create a slave of a deleted interpreter"
+ end
+
+ if !master.deleted? && !master.master? && master.safe?
+ fail SecurityError, "safe-slave-ip cannot create a new interpreter"
+ end
+
+ if safeip == nil && !master.master?
+ fail SecurityError, "slave-ip cannot create a master-ip"
+ end
+
+ unless keys.kind_of? Hash
+ fail ArgumentError, "expecting a Hash object for the 2nd argument"
+ end
+
+ @tk_windows = {}
+ @tk_table_list = []
+ @slave_ip_tbl = {}
+ @slave_ip_top = {}
+ @cb_error_proc = []
+ @evloop_thread = []
+
+ TkUtil.untrust(@tk_windows) unless @tk_windows.tainted?
+ TkUtil.untrust(@tk_table_list) unless @tk_table_list.tainted?
+ TkUtil.untrust(@slave_ip_tbl) unless @slave_ip_tbl.tainted?
+ TkUtil.untrust(@slave_ip_top) unless @slave_ip_top.tainted?
+ TkUtil.untrust(@cb_error_proc) unless @cb_error_proc.tainted?
+ TkUtil.untrust(@evloop_thread) unless @evloop_thread.tainted?
+
+ @callback_status = []
+
+ name, safe, safe_opts, tk_opts = _parse_slaveopts(keys)
+
+ safe = 4 if safe && !safe.kind_of?(Fixnum)
+
+ @safe_base = false
+
+ if safeip == nil
+ # create master-ip
+ unless WITH_RUBY_VM
+ @interp = TclTkIp.new(name, _keys2opts(tk_opts))
+ @interp.instance_eval{
+ @force_default_encoding ||= TkUtil.untrust([false])
+ @encoding ||= TkUtil.untrust([nil])
+ def @encoding.to_s; self.join(nil); end
+ }
+
+ else ### Ruby 1.9 !!!!!!!!!!!
+=begin
+ @interp_thread = Thread.new{
+ Thread.current[:interp] = interp = TclTkIp.new(name, _keys2opts(tk_opts))
+ interp.instance_eval{
+ @force_default_encoding ||= TkUtil.untrust([false])
+ @encoding ||= TkUtil.untrust([nil])
+ def @encoding.to_s; self.join(nil); end
+ }
+
+ #sleep
+ TclTkLib.mainloop(true)
+ }
+ until @interp_thread[:interp]
+ Thread.pass
+ end
+ # INTERP_THREAD.run
+ @interp = @interp_thread[:interp]
+=end
+ @interp_thread = Thread.new{
+ current = Thread.current
+ begin
+ current[:interp] = interp = TclTkIp.new(name, _keys2opts(tk_opts))
+ rescue e
+ current[:interp] = e
+ raise e
+ end
+ #sleep
+ #TclTkLib.mainloop(true)
+ current[:mutex] = mutex = Mutex.new
+ current[:root_check] = cond_ver = ConditionVariable.new
+
+ status = [nil]
+ def status.value
+ self[0]
+ end
+ def status.value=(val)
+ self[0] = val
+ end
+ current[:status] = status
+
+ begin
+ begin
+ current[:status].value = interp.mainloop(true)
+ rescue SystemExit=>e
+ current[:status].value = e
+ rescue Exception=>e
+ current[:status].value = e
+ retry if interp.has_mainwindow?
+ ensure
+ mutex.synchronize{ cond_var.broadcast }
+ end
+ current[:status].value = interp.mainloop(false)
+ ensure
+ interp.delete
+ end
+ }
+ until @interp_thread[:interp]
+ Thread.pass
+ end
+ # INTERP_THREAD.run
+ @interp = @interp_thread[:interp]
+
+ @evloop_thread[0] = @interp_thread
+
+ def self.mainloop(check_root = true)
+ begin
+ TclTkLib.set_eventloop_window_mode(true)
+ @interp_thread.value
+ ensure
+ TclTkLib.set_eventloop_window_mode(false)
+ end
+ end
+ end
+
+ @interp.instance_eval{
+ @force_default_encoding ||= TkUtil.untrust([false])
+ @encoding ||= TkUtil.untrust([nil])
+ def @encoding.to_s; self.join(nil); end
+ }
+
+ @ip_name = nil
+
+ if safe
+ safe = $SAFE if safe < $SAFE
+ @safe_level = [safe]
+ else
+ @safe_level = [$SAFE]
+ end
+
+ else
+ # create slave-ip
+ if safeip || master.safe?
+ @safe_base = true
+ @interp, @ip_name = master.__create_safe_slave_obj(safe_opts,
+ name, tk_opts)
+ # @interp_thread = nil if RUBY_VERSION < '1.9.0' ### !!!!!!!!!!!
+ @interp_thread = nil unless WITH_RUBY_VM ### Ruby 1.9 !!!!!!!!!!!
+ if safe
+ safe = master.safe_level if safe < master.safe_level
+ @safe_level = [safe]
+ else
+ @safe_level = [4]
+ end
+ else
+ @interp, @ip_name = master.__create_trusted_slave_obj(name, tk_opts)
+ # @interp_thread = nil if RUBY_VERSION < '1.9.0' ### !!!!!!!!!!!
+ @interp_thread = nil unless WITH_RUBY_VM ### Ruby 1.9 !!!!!!!!!!!
+ if safe
+ safe = master.safe_level if safe < master.safe_level
+ @safe_level = [safe]
+ else
+ @safe_level = [master.safe_level]
+ end
+ end
+ @set_alias_proc = proc{|name|
+ master._invoke('interp', 'alias', @ip_name, name, '', name)
+ }.freeze
+ end
+
+ @system = Object.new
+
+ @wait_on_mainloop = TkUtil.untrust([true, 0])
+ # @wait_on_mainloop = TkUtil.untrust([false, 0])
+
+ @threadgroup = ThreadGroup.new
+
+ @pseudo_toplevel = [false, nil]
+
+ @cmd_queue = MultiTkIp::Command_Queue.new(@interp)
+
+=begin
+ @cmd_receiver, @receiver_watchdog = _create_receiver_and_watchdog(@safe_level[0])
+
+ @threadgroup.add @cmd_receiver
+ @threadgroup.add @receiver_watchdog
+
+ @threadgroup.enclose
+=end
+ @@DEFAULT_MASTER.assign_receiver_and_watchdog(self)
+
+ @@IP_TABLE[@threadgroup] = self
+ @@TK_TABLE_LIST.size.times{
+ @tk_table_list << TkUtil.untrust({})
+ }
+ _init_ip_internal(@@INIT_IP_ENV, @@ADD_TK_PROCS)
+
+ class << self
+ undef :instance_eval
+ end
+
+ # dummy call for initialization
+ self.eval_proc{ Tk.tk_call('set', 'tcl_patchLevel') }
+
+ self.freeze # defend against modification
+ end
+
+ ######################################
+
+ def _default_delete_hook(slave)
+ raise SecurityError, "no permission to manipulate" unless self.manipulable?
+ @slave_ip_tbl.delete(slave)
+ top = @slave_ip_top.delete(slave)
+ if top.kind_of?(String)
+ # call default hook of safetk.tcl (ignore exceptions)
+ if top == ''
+ begin
+ @interp._eval("::safe::disallowTk #{slave}")
+ rescue
+ warn("Waring: fail to call '::safe::disallowTk'") if $DEBUG
+ end
+ else # toplevel path
+ begin
+ @interp._eval("::safe::tkDelete {} #{top} #{slave}")
+ rescue
+ warn("Waring: fail to call '::safe::tkDelete'") if $DEBUG
+ begin
+ @interp._eval("destroy #{top}")
+ rescue
+ warn("Waring: fail to destroy toplevel") if $DEBUG
+ end
+ end
+ end
+ end
+ end
+
+end
+
+
+# get target IP
+class MultiTkIp
+ @@CALLBACK_SUBTHREAD = Class.new(Thread){
+ def self.new(interp, &blk)
+ super(interp){|ip| Thread.current[:callback_ip] = ip; blk.call}
+ end
+
+ @table = TkUtil.untrust(Hash.new{|h,k| h[k] = TkUtil.untrust([])})
+ def self.table
+ @table
+ end
+ }
+
+ def self._ip_id_
+ __getip._ip_id_
+ end
+ def _ip_id_
+ # for RemoteTkIp
+ ''
+ end
+
+ def self.__getip
+ current = Thread.current
+ if current.kind_of?(@@CALLBACK_SUBTHREAD)
+ return current[:callback_ip]
+ end
+ if TclTkLib.mainloop_thread? != false && current[:callback_ip]
+ return current[:callback_ip]
+ end
+ if current.group == ThreadGroup::Default
+ @@DEFAULT_MASTER
+ else
+ ip = @@IP_TABLE[current.group]
+ unless ip
+ fail SecurityError,
+ "cannot call Tk methods on #{Thread.current.inspect}"
+ end
+ ip
+ end
+ end
+end
+
+
+# aliases of constructor
+class << MultiTkIp
+ alias __new new
+ private :__new
+
+ def new_master(safe=nil, keys={}, &blk)
+ if MultiTkIp::WITH_RUBY_VM
+ #### TODO !!!!!!
+ fail RuntimeError,
+ 'sorry, still not support multiple master-interpreters on RubyVM'
+ end
+
+ if safe.kind_of?(Hash)
+ keys = safe
+ elsif safe.kind_of?(Integer)
+ raise ArgumentError, "unexpected argument(s)" unless keys.kind_of?(Hash)
+ if !keys.key?(:safe) && !keys.key?('safe')
+ keys[:safe] = safe
+ end
+ elsif safe == nil
+ # do nothing
+ else
+ raise ArgumentError, "unexpected argument(s)"
+ end
+
+ ip = __new(__getip, nil, keys)
+ #ip.eval_proc(proc{$SAFE=ip.safe_level; Proc.new}.call) if block_given?
+ if block_given?
+ #Thread.new{ip.eval_proc(proc{$SAFE=ip.safe_level; Proc.new}.call)}
+ #Thread.new{ip.eval_proc(proc{$SAFE=ip.safe_level; yield}.call)}
+ ip._proc_on_safelevel(&blk).call(ip.safe_level)
+ end
+ ip
+ end
+
+ alias new new_master
+
+ def new_slave(safe=nil, keys={}, &blk)
+ if safe.kind_of?(Hash)
+ keys = safe
+ elsif safe.kind_of?(Integer)
+ raise ArgumentError, "unexpected argument(s)" unless keys.kind_of?(Hash)
+ if !keys.key?(:safe) && !keys.key?('safe')
+ keys[:safe] = safe
+ end
+ elsif safe == nil
+ # do nothing
+ else
+ raise ArgumentError, "unexpected argument(s)"
+ end
+
+ ip = __new(__getip, false, keys)
+ # ip.eval_proc(proc{$SAFE=ip.safe_level; Proc.new}.call) if block_given?
+ if block_given?
+ #Thread.new{ip.eval_proc(proc{$SAFE=ip.safe_level; Proc.new}.call)}
+ #Thread.new{ip.eval_proc(proc{$SAFE=ip.safe_level; yield}.call)}
+ ip._proc_on_safelevel(&blk).call(ip.safe_level)
+ end
+ ip
+ end
+ alias new_trusted_slave new_slave
+
+ def new_safe_slave(safe=4, keys={}, &blk)
+ if safe.kind_of?(Hash)
+ keys = safe
+ elsif safe.kind_of?(Integer)
+ raise ArgumentError, "unexpected argument(s)" unless keys.kind_of?(Hash)
+ if !keys.key?(:safe) && !keys.key?('safe')
+ keys[:safe] = safe
+ end
+ else
+ raise ArgumentError, "unexpected argument(s)"
+ end
+
+ ip = __new(__getip, true, keys)
+ # ip.eval_proc(proc{$SAFE=ip.safe_level; Proc.new}.call) if block_given?
+ if block_given?
+ #Thread.new{ip.eval_proc(proc{$SAFE=ip.safe_level; Proc.new}.call)}
+ #Thread.new{ip.eval_proc(proc{$SAFE=ip.safe_level; yield}.call)}
+ ip._proc_on_safelevel(&blk).call(ip.safe_level)
+ end
+ ip
+ end
+ alias new_safeTk new_safe_slave
+end
+
+
+# get info
+class MultiTkIp
+ def inspect
+ s = self.to_s.chop!
+ if self.manipulable?
+ if master?
+ if @interp.deleted?
+ s << ':deleted-master'
+ else
+ s << ':master'
+ end
+ else
+ if @interp.deleted?
+ s << ':deleted-slave'
+ elsif @interp.safe?
+ s << ':safe-slave'
+ else
+ s << ':trusted-slave'
+ end
+ end
+ end
+ s << '>'
+ end
+
+ def master?
+ if @ip_name
+ false
+ else
+ true
+ end
+ end
+ def self.master?
+ __getip.master?
+ end
+
+ def slave?
+ not master?
+ end
+ def self.slave?
+ not self.master?
+ end
+
+ def alive?
+ raise SecurityError, "no permission to manipulate" unless self.manipulable?
+ begin
+ return false unless @cmd_receiver.alive?
+ return false if @interp.deleted?
+ return false if @interp._invoke('interp', 'exists', '') == '0'
+ rescue Exception
+ return false
+ end
+ true
+ end
+ def self.alive?
+ __getip.alive?
+ end
+
+ def path
+ @ip_name || ''
+ end
+ def self.path
+ __getip.path
+ end
+ def ip_name
+ @ip_name || ''
+ end
+ def self.ip_name
+ __getip.ip_name
+ end
+ def to_eval
+ @ip_name || ''
+ end
+ def self.to_eval
+ __getip.to_eval
+ end
+
+ def slaves(all = false)
+ raise SecurityError, "no permission to manipulate" unless self.manipulable?
+ @interp._invoke('interp','slaves').split.map!{|name|
+ if @slave_ip_tbl.key?(name)
+ @slave_ip_tbl[name]
+ elsif all
+ name
+ else
+ nil
+ end
+ }.compact!
+ end
+ def self.slaves(all = false)
+ __getip.slaves(all)
+ end
+
+ def manipulable?
+ return true if (Thread.current.group == ThreadGroup::Default)
+ ip = MultiTkIp.__getip
+ (ip == self) || ip._is_master_of?(@interp)
+ end
+ def self.manipulable?
+ true
+ end
+
+ def _is_master_of?(tcltkip_obj)
+ tcltkip_obj.slave_of?(@interp)
+ end
+ protected :_is_master_of?
+end
+
+
+# instance methods to treat tables
+class MultiTkIp
+ def _tk_cmd_tbl
+ tbl = {}
+ MultiTkIp.tk_cmd_tbl.each{|id, ent| tbl[id] = ent if ent.ip == self }
+ tbl
+ end
+
+ def _tk_windows
+ @tk_windows
+ end
+
+ def _tk_table_list
+ @tk_table_list
+ end
+
+ def _add_new_tables
+ (@@TK_TABLE_LIST.size - @tk_table_list.size).times{
+ @tk_table_list << TkUtil.untrust({})
+ }
+ end
+
+ def _init_ip_env(script)
+ self.eval_proc{script.call(self)}
+ end
+
+ def _add_tk_procs(name, args, body)
+ return if slave?
+ @interp._invoke('proc', name, args, body) if args && body
+ @interp._invoke('interp', 'slaves').split.each{|slave|
+ @interp._invoke('interp', 'alias', slave, name, '', name)
+ }
+ end
+
+ def _remove_tk_procs(*names)
+ return if slave?
+ names.each{|name|
+ name = name.to_s
+
+ return if @interp.deleted?
+ @interp._invoke('rename', name, '')
+
+ return if @interp.deleted?
+ @interp._invoke('interp', 'slaves').split.each{|slave|
+ return if @interp.deleted?
+ @interp._invoke('interp', 'alias', slave, name, '') rescue nil
+ }
+ }
+ end
+
+ def _init_ip_internal(init_ip_env, add_tk_procs)
+ #init_ip_env.each{|script| self.eval_proc{script.call(self)}}
+ init_ip_env.each{|script| self._init_ip_env(script)}
+ add_tk_procs.each{|name, args, body|
+ if master?
+ @interp._invoke('proc', name, args, body) if args && body
+ else
+ @set_alias_proc.call(name)
+ end
+ }
+ end
+end
+
+
+# class methods to treat tables
+class MultiTkIp
+ def self.tk_cmd_tbl
+ @@TK_CMD_TBL
+ end
+ def self.tk_windows
+ __getip._tk_windows
+ end
+ def self.tk_object_table(id)
+ __getip._tk_table_list[id]
+ end
+ def self.create_table
+ if __getip.slave?
+ begin
+ raise SecurityError, "slave-IP has no permission creating a new table"
+ rescue SecurityError => e
+ #p e.backtrace
+ # Is called on a Ruby/Tk library?
+ caller_info = e.backtrace[1]
+ if caller_info =~ %r{^#{MultiTkIp::BASE_DIR}/(tk|tkextlib)/[^:]+\.rb:}
+ # Probably, caller is a Ruby/Tk library --> allow creating
+ else
+ raise e
+ end
+ end
+ end
+
+ id = @@TK_TABLE_LIST.size
+ obj = Object.new
+ @@TK_TABLE_LIST << obj
+ obj.instance_variable_set(:@id, id)
+ obj.instance_variable_set(:@mutex, Mutex.new)
+ obj.instance_eval{
+ def self.mutex
+ @mutex
+ end
+ def self.method_missing(m, *args)
+ MultiTkIp.tk_object_table(@id).__send__(m, *args)
+ end
+ }
+ obj.freeze
+ @@IP_TABLE.each{|tg, ip| ip._add_new_tables }
+ return obj
+ end
+
+ def self.init_ip_env(script = Proc.new)
+ @@INIT_IP_ENV << script
+ if __getip.slave?
+ begin
+ raise SecurityError, "slave-IP has no permission initializing IP env"
+ rescue SecurityError => e
+ #p e.backtrace
+ # Is called on a Ruby/Tk library?
+ caller_info = e.backtrace[1]
+ if caller_info =~ %r{^#{MultiTkIp::BASE_DIR}/(tk|tkextlib)/[^:]+\.rb:}
+ # Probably, caller is a Ruby/Tk library --> allow creating
+ else
+ raise e
+ end
+ end
+ end
+
+ # @@IP_TABLE.each{|tg, ip|
+ # ip._init_ip_env(script)
+ # }
+ @@DEFAULT_MASTER.__init_ip_env__(@@IP_TABLE, script)
+ end
+
+ def self.add_tk_procs(name, args=nil, body=nil)
+ if name.kind_of?(Array) # => an array of [name, args, body]
+ name.each{|param| self.add_tk_procs(*param)}
+ else
+ name = name.to_s
+ @@ADD_TK_PROCS << [name, args, body]
+ @@IP_TABLE.each{|tg, ip|
+ ip._add_tk_procs(name, args, body)
+ }
+ end
+ end
+
+ def self.remove_tk_procs(*names)
+ names.each{|name|
+ name = name.to_s
+ @@ADD_TK_PROCS.delete_if{|elem|
+ elem.kind_of?(Array) && elem[0].to_s == name
+ }
+ }
+ @@IP_TABLE.each{|tg, ip|
+ ip._remove_tk_procs(*names)
+ }
+ end
+
+ def self.init_ip_internal
+ __getip._init_ip_internal(@@INIT_IP_ENV, @@ADD_TK_PROCS)
+ end
+end
+
+# for callback operation
+class MultiTkIp
+ def self.cb_entry_class
+ @@CB_ENTRY_CLASS
+ end
+ def self.get_cb_entry(cmd)
+ @@CB_ENTRY_CLASS.new(__getip, cmd).freeze
+ end
+
+=begin
+ def cb_eval(cmd, *args)
+ #self.eval_callback{ TkComm._get_eval_string(TkUtil.eval_cmd(cmd, *args)) }
+ #ret = self.eval_callback{ TkComm._get_eval_string(TkUtil.eval_cmd(cmd, *args)) }
+ ret = self.eval_callback(*args){|safe, *params|
+ $SAFE=safe if $SAFE < safe
+ TkComm._get_eval_string(TkUtil.eval_cmd(cmd, *params))
+ }
+ if ret.kind_of?(Exception)
+ raise ret
+ end
+ ret
+ end
+=end
+ def cb_eval(cmd, *args)
+ self.eval_callback(*args,
+ &_proc_on_safelevel{|*params|
+ TkComm._get_eval_string(TkUtil.eval_cmd(cmd, *params))
+ })
+ end
+=begin
+ def cb_eval(cmd, *args)
+ self.eval_callback(*args){|safe, *params|
+ $SAFE=safe if $SAFE < safe
+ # TkUtil.eval_cmd(cmd, *params)
+ TkComm._get_eval_string(TkUtil.eval_cmd(cmd, *params))
+ }
+ end
+=end
+=begin
+ def cb_eval(cmd, *args)
+ @callback_status[0] ||= TkVariable.new
+ @callback_status[1] ||= TkVariable.new
+ st, val = @callback_status
+ th = Thread.new{
+ self.eval_callback(*args){|safe, *params|
+ #p [status, val, safe, *params]
+ $SAFE=safe if $SAFE < safe
+ begin
+ TkComm._get_eval_string(TkUtil.eval_cmd(cmd, *params))
+ rescue TkCallbackContinue
+ st.value = 4
+ rescue TkCallbackBreak
+ st.value = 3
+ rescue TkCallbackReturn
+ st.value = 2
+ rescue Exception => e
+ val.value = e.message
+ st.value = 1
+ else
+ st.value = 0
+ end
+ }
+ }
+ begin
+ st.wait
+ status = st.numeric
+ retval = val.value
+ rescue => e
+ fail e
+ end
+
+ if status == 1
+ fail RuntimeError, retval
+ elsif status == 2
+ fail TkCallbackReturn, "Tk callback returns 'return' status"
+ elsif status == 3
+ fail TkCallbackBreak, "Tk callback returns 'break' status"
+ elsif status == 4
+ fail TkCallbackContinue, "Tk callback returns 'continue' status"
+ else
+ ''
+ end
+ end
+=end
+
+end
+
+# pseudo-toplevel operation support
+class MultiTkIp
+ # instance method
+ def __pseudo_toplevel
+ ip = MultiTkIp.__getip
+ (ip == @@DEFAULT_MASTER || ip == self) &&
+ self.__pseudo_toplevel_evaluable? && @pseudo_toplevel[1]
+ end
+
+ def __pseudo_toplevel=(m)
+ unless (Thread.current.group == ThreadGroup::Default &&
+ MultiTkIp.__getip == @@DEFAULT_MASTER)
+ fail SecurityError, "no permission to manipulate"
+ end
+
+ # if m.kind_of?(Module) && m.respond_to?(:pseudo_toplevel_evaluable?)
+ if m.respond_to?(:pseudo_toplevel_evaluable?)
+ @pseudo_toplevel[0] = true
+ @pseudo_toplevel[1] = m
+ else
+ fail ArgumentError, 'fail to set pseudo-toplevel'
+ end
+ self
+ end
+
+ def __pseudo_toplevel_evaluable?
+ begin
+ @pseudo_toplevel[0] && @pseudo_toplevel[1].pseudo_toplevel_evaluable?
+ rescue Exception
+ false
+ end
+ end
+
+ def __pseudo_toplevel_evaluable=(mode)
+ unless (Thread.current.group == ThreadGroup::Default &&
+ MultiTkIp.__getip == @@DEFAULT_MASTER)
+ fail SecurityError, "no permission to manipulate"
+ end
+
+ @pseudo_toplevel[0] = (mode)? true: false
+ end
+end
+
+
+################################################
+# use pseudo-toplevel feature of MultiTkIp ?
+if (!defined?(Use_PseudoToplevel_Feature_of_MultiTkIp) ||
+ Use_PseudoToplevel_Feature_of_MultiTkIp)
+ module MultiTkIp_PseudoToplevel_Evaluable
+ #def pseudo_toplevel_eval(body = Proc.new)
+ # Thread.current[:TOPLEVEL] = self
+ # begin
+ # body.call
+ # ensure
+ # Thread.current[:TOPLEVEL] = nil
+ # end
+ #end
+
+ def pseudo_toplevel_evaluable?
+ @pseudo_toplevel_evaluable
+ end
+
+ def pseudo_toplevel_evaluable=(mode)
+ @pseudo_toplevel_evaluable = (mode)? true: false
+ end
+
+ def self.extended(mod)
+ mod.__send__(:extend_object, mod)
+ mod.instance_variable_set('@pseudo_toplevel_evaluable', true)
+ end
+ end
+
+ class Object
+ alias __method_missing_alias_for_MultiTkIp__ method_missing
+ private :__method_missing_alias_for_MultiTkIp__
+
+ def method_missing(id, *args)
+ begin
+ has_top = (top = MultiTkIp.__getip.__pseudo_toplevel) &&
+ top.respond_to?(:pseudo_toplevel_evaluable?) &&
+ top.pseudo_toplevel_evaluable? &&
+ top.respond_to?(id)
+ rescue Exception => e
+ has_top = false
+ end
+
+ if has_top
+ top.__send__(id, *args)
+ else
+ __method_missing_alias_for_MultiTkIp__(id, *args)
+ end
+ end
+ end
+else
+ # dummy
+ module MultiTkIp_PseudoToplevel_Evaluable
+ def pseudo_toplevel_evaluable?
+ false
+ end
+ end
+end
+
+
+################################################
+# evaluate a procedure on the proper interpreter
+class MultiTkIp
+ # instance & class method
+ def _proc_on_safelevel(cmd=nil) # require a block for eval
+ if cmd
+ if cmd.kind_of?(Method)
+ _proc_on_safelevel{|*args| cmd.call(*args)}
+ else
+ _proc_on_safelevel(&cmd)
+ end
+ else
+ #Proc.new{|safe, *args| $SAFE=safe if $SAFE < safe; yield(*args)}
+ Proc.new{|safe, *args|
+ # avoid security error on Exception objects
+ untrust_proc = proc{|err|
+ begin
+ err.untrust if err.respond_to?(:untrust)
+ rescue SecurityError
+ end
+ err
+ }
+ $SAFE=safe if $SAFE < safe;
+ begin
+ yield(*args)
+ rescue Exception => e
+ fail untrust_proc.call(e)
+ end
+ }
+ end
+ end
+ def MultiTkIp._proc_on_safelevel(cmd=nil, &blk)
+ MultiTkIp.__getip._proc_on_safelevel(cmd, &blk)
+ end
+
+ def _proc_on_current_safelevel(cmd=nil, &blk) # require a block for eval
+ safe = $SAFE
+ cmd = _proc_on_safelevel(cmd, &blk)
+ Proc.new{|*args| cmd.call(safe, *args)}
+ end
+ def MultiTkIp._proc_on_current_safelevel(cmd=nil, &blk)
+ MultiTkIp.__getip._proc_on_current_safelevel(cmd, &blk)
+ end
+
+ ######################################
+ # instance method
+ def eval_proc_core(req_val, cmd, *args)
+ # check
+ raise SecurityError, "no permission to manipulate" unless self.manipulable?
+ unless cmd.kind_of?(Proc) || cmd.kind_of?(Method)
+ raise RuntimeError, "A Proc/Method object is expected for the 'cmd' argument"
+ end
+
+ # on IP thread
+ if @cmd_receiver == Thread.current ||
+ (!req_val && TclTkLib.mainloop_thread? != false) # callback
+ begin
+ ret = cmd.call(safe_level, *args)
+ rescue SystemExit => e
+ # exit IP
+ warn("Warning: "+ e.inspect + " on " + self.inspect) if $DEBUG
+ begin
+ self._eval_without_enc('exit')
+ rescue Exception => e
+ end
+ self.delete
+ ret = nil
+ rescue Exception => e
+ if $DEBUG
+ warn("Warning: " + e.class.inspect +
+ ((e.message.length > 0)? ' "' + e.message + '"': '') +
+ " on " + self.inspect)
+ end
+=begin
+ begin
+ bt = _toUTF8(e.backtrace.join("\n"))
+ bt.instance_variable_set(:@encoding, 'utf-8')
+ rescue Exception
+ bt = e.backtrace.join("\n")
+ end
+ begin
+ @interp._set_global_var('errorInfo', bt)
+ rescue Exception
+ end
+=end
+ ret = e
+ end
+ return ret
+ end
+
+ # send cmd to the proc-queue
+ unless req_val
+ begin
+ @cmd_queue.enq([nil, cmd, *args])
+ rescue Exception => e
+ # ignore
+ if $DEBUG
+ warn("Warning: " + e.class.inspect +
+ ((e.message.length > 0)? ' "' + e.message + '"': '') +
+ " on " + self.inspect)
+ end
+ return e
+ end
+ return nil
+ end
+
+ # send and get return value by exception
+ begin
+ @cmd_queue.enq([Thread.current, cmd, *args])
+ Thread.stop
+ rescue MultiTkIp_OK => ret
+ # return value
+ return ret.value
+ rescue SystemExit => e
+ # exit IP
+ warn("Warning: " + e.inspect + " on " + self.inspect) if $DEBUG
+ begin
+ self._eval_without_enc('exit')
+ rescue Exception
+ end
+ if !self.deleted? && !safe? && allow_ruby_exit?
+ self.delete
+ fail e
+ else
+ self.delete
+ end
+ rescue Exception => e
+ if $DEBUG
+ warn("Warning: " + e.class.inspect +
+ ((e.message.length > 0)? ' "' + e.message + '"': '') +
+ " on " + self.inspect)
+ end
+ return e
+ end
+ return nil
+ end
+ private :eval_proc_core
+
+if false && WITH_RUBY_VM ### Ruby 1.9
+ # Not stable, so disable this feature
+ def eval_callback(*args)
+ if block_given?
+ cmd = Proc.new
+ else
+ cmd = args.shift
+ end
+ begin
+ if @@CALLBACK_SUBTHREAD.table[self].index(Thread.current)
+ last_th = nil
+ else
+ last_th = @@CALLBACK_SUBTHREAD.table[self][-1]
+ end
+ @@CALLBACK_SUBTHREAD.new(self){
+ @@CALLBACK_SUBTHREAD.table[self] << Thread.current
+ begin
+ last_th.join if last_th
+ eval_proc_core(false, cmd, *args)
+ rescue Exception=>e
+ e
+ ensure
+ @@CALLBACK_SUBTHREAD.table[self].delete(Thread.current)
+ end
+ }
+ end
+ end
+else ### Ruby 1.8
+ def eval_callback(*args)
+ if block_given?
+ cmd = Proc.new
+ else
+ cmd = args.shift
+ end
+ begin
+ eval_proc_core(false, cmd, *args)
+ rescue Exception=>e
+ e
+ ensure
+ end
+ end
+end
+
+ def eval_proc(*args, &blk)
+ if block_given?
+ cmd = _proc_on_safelevel(&blk)
+ else
+ unless (cmd = args.shift)
+ fail ArgumentError, "A Proc or Method object is expected for 1st argument"
+ end
+ cmd = _proc_on_safelevel(&cmd)
+ end
+ if TclTkLib.mainloop_thread? == true
+ # call from eventloop
+ current = Thread.current
+ backup_ip = current[:callback_ip]
+ current[:callback_ip] = self
+ begin
+ eval_proc_core(false, cmd, *args)
+ ensure
+ current[:callback_ip] = backup_ip
+ end
+ else
+ eval_proc_core(true,
+ proc{|safe, *params|
+ Thread.new{cmd.call(safe, *params)}.value
+ },
+ *args)
+ end
+ end
+=begin
+ def eval_proc(*args)
+ # The scope of the eval-block of 'eval_proc' method is different from
+ # the external. If you want to pass local values to the eval-block,
+ # use arguments of eval_proc method. They are passed to block-arguments.
+ if block_given?
+ cmd = Proc.new
+ else
+ unless (cmd = args.shift)
+ fail ArgumentError, "A Proc or Method object is expected for 1st argument"
+ end
+ end
+ if TclTkLib.mainloop_thread? == true
+ # call from eventloop
+ current = Thread.current
+ backup_ip = current[:callback_ip]
+ current[:callback_ip] = self
+ begin
+ eval_proc_core(false,
+ proc{|safe, *params|
+ $SAFE=safe if $SAFE < safe
+ cmd.call(*params)
+ }, *args)
+ ensure
+ current[:callback_ip] = backup_ip
+ end
+ else
+ eval_proc_core(true,
+ proc{|safe, *params|
+ $SAFE=safe if $SAFE < safe
+ Thread.new(*params, &cmd).value
+ },
+ *args)
+ end
+ end
+=end
+ alias call eval_proc
+
+ def bg_eval_proc(*args)
+ if block_given?
+ cmd = Proc.new
+ else
+ unless (cmd = args.shift)
+ fail ArgumentError, "A Proc or Method object is expected for 1st argument"
+ end
+ end
+ Thread.new{
+ eval_proc(cmd, *args)
+=begin
+ eval_proc_core(false,
+ proc{|safe, *params|
+ $SAFE=safe if $SAFE < safe
+ Thread.new(*params, &cmd).value
+ },
+ safe_level, *args)
+=end
+ }
+ end
+ alias background_eval_proc bg_eval_proc
+ alias thread_eval_proc bg_eval_proc
+ alias bg_call bg_eval_proc
+ alias background_call bg_eval_proc
+
+ def eval_string(cmd, *eval_args)
+ # cmd string ==> proc
+ unless cmd.kind_of?(String)
+ raise RuntimeError, "A String object is expected for the 'cmd' argument"
+ end
+
+ eval_proc_core(true,
+ proc{|safe|
+ Kernel.eval("$SAFE=#{safe} if $SAFE < #{safe};" << cmd,
+ *eval_args)
+ })
+ end
+ alias eval_str eval_string
+
+ def bg_eval_string(cmd, *eval_args)
+ # cmd string ==> proc
+ unless cmd.kind_of?(String)
+ raise RuntimeError, "A String object is expected for the 'cmd' argument"
+ end
+ Thread.new{
+ eval_proc_core(true,
+ proc{|safe|
+ Kernel.eval("$SAFE=#{safe} if $SAFE < #{safe};" << cmd,
+ *eval_args)
+ })
+ }
+ end
+ alias background_eval_string bg_eval_string
+ alias bg_eval_str bg_eval_string
+ alias background_eval_str bg_eval_string
+
+ def eval(*args, &blk)
+ if block_given?
+ eval_proc(*args, &blk)
+ elsif args[0]
+ if args[0].respond_to?(:call)
+ eval_proc(*args)
+ else
+ eval_string(*args)
+ end
+ else
+ fail ArgumentError, "no argument to eval"
+ end
+ end
+
+ def bg_eval(*args, &blk)
+ if block_given?
+ bg_eval_proc(*args, &blk)
+ elsif args[0]
+ if args[0].respond_to?(:call)
+ bg_eval_proc(*args)
+ else
+ bg_eval_string(*args)
+ end
+ else
+ fail ArgumentError, "no argument to eval"
+ end
+ end
+ alias background_eval bg_eval
+end
+
+class << MultiTkIp
+ # class method
+ def eval_proc(*args, &blk)
+ # class ==> interp object
+ __getip.eval_proc(*args, &blk)
+ end
+ alias call eval_proc
+
+ def bg_eval_proc(*args, &blk)
+ # class ==> interp object
+ __getip.bg_eval_proc(*args, &blk)
+ end
+ alias background_eval_proc bg_eval_proc
+ alias thread_eval_proc bg_eval_proc
+ alias bg_call bg_eval_proc
+ alias background_call bg_eval_proc
+
+ def eval_string(cmd, *eval_args)
+ # class ==> interp object
+ __getip.eval_string(cmd, *eval_args)
+ end
+ alias eval_str eval_string
+
+ def bg_eval_string(cmd, *eval_args)
+ # class ==> interp object
+ __getip.bg_eval_string(cmd, *eval_args)
+ end
+ alias background_eval_string bg_eval_string
+ alias bg_eval_str bg_eval_string
+ alias background_eval_str bg_eval_string
+
+ def eval(*args, &blk)
+ # class ==> interp object
+ __getip.eval(*args, &blk)
+ end
+ def bg_eval(*args, &blk)
+ # class ==> interp object
+ __getip.bg_eval(*args, &blk)
+ end
+ alias background_eval bg_eval
+end
+
+
+# event loop
+# all master/slave IPs are controled by only one event-loop
+class MultiTkIp
+ def self.default_master?
+ __getip == @@DEFAULT_MASTER
+ end
+end
+class << MultiTkIp
+ def mainloop(check_root = true)
+ __getip.mainloop(check_root)
+ end
+ def mainloop_watchdog(check_root = true)
+ __getip.mainloop_watchdog(check_root)
+ end
+ def do_one_event(flag = TclTkLib::EventFlag::ALL)
+ __getip.do_one_event(flag)
+ end
+ def mainloop_abort_on_exception
+ # __getip.mainloop_abort_on_exception
+ TclTkLib.mainloop_abort_on_exception
+ end
+ def mainloop_abort_on_exception=(mode)
+ # __getip.mainloop_abort_on_exception=(mode)
+ TclTkLib.mainloop_abort_on_exception=(mode)
+ end
+ def set_eventloop_tick(tick)
+ __getip.set_eventloop_tick(tick)
+ end
+ def get_eventloop_tick
+ __getip.get_eventloop_tick
+ end
+ def set_no_event_wait(tick)
+ __getip.set_no_event_wait(tick)
+ end
+ def get_no_event_wait
+ __getip.get_no_event_wait
+ end
+ def set_eventloop_weight(loop_max, no_event_tick)
+ __getip.set_eventloop_weight(loop_max, no_event_tick)
+ end
+ def get_eventloop_weight
+ __getip.get_eventloop_weight
+ end
+end
+
+# class methods to delegate to TclTkIp
+class << MultiTkIp
+ def method_missing(id, *args)
+ __getip.__send__(id, *args)
+ end
+
+ def make_safe
+ __getip.make_safe
+ end
+
+ def safe?
+ __getip.safe?
+ end
+
+ def safe_base?
+ begin
+ __getip.safe_base?
+ rescue
+ false
+ end
+ end
+
+ def allow_ruby_exit?
+ __getip.allow_ruby_exit?
+ end
+
+ def allow_ruby_exit= (mode)
+ __getip.allow_ruby_exit = mode
+ end
+
+ def delete
+ __getip.delete
+ end
+
+ def deleted?
+ __getip.deleted?
+ end
+
+ def has_mainwindow?
+ __getip.has_mainwindow?
+ end
+
+ def invalid_namespace?
+ __getip.invalid_namespace?
+ end
+
+ def abort(msg = nil)
+ __getip.abort(msg)
+ end
+
+ def exit(st = true)
+ __getip.exit(st)
+ end
+
+ def exit!(st = false)
+ __getip.exit!(st)
+ end
+
+ def restart(app_name = nil, keys = {})
+ init_ip_internal
+
+ __getip._invoke('set', 'argv0', app_name) if app_name
+ if keys.kind_of?(Hash)
+ __getip._invoke('set', 'argv', _keys2opts(keys))
+ end
+
+ __getip.restart
+ end
+
+ def _eval(str)
+ __getip._eval(str)
+ end
+
+ def _invoke(*args)
+ __getip._invoke(*args)
+ end
+
+ def _eval_without_enc(str)
+ __getip._eval_without_enc(str)
+ end
+
+ def _invoke_without_enc(*args)
+ __getip._invoke_without_enc(*args)
+ end
+
+ def _eval_with_enc(str)
+ __getip._eval_with_enc(str)
+ end
+
+ def _invoke_with_enc(*args)
+ __getip._invoke_with_enc(*args)
+ end
+
+ def _toUTF8(str, encoding=nil)
+ __getip._toUTF8(str, encoding)
+ end
+
+ def _fromUTF8(str, encoding=nil)
+ __getip._fromUTF8(str, encoding)
+ end
+
+ def _thread_vwait(var)
+ __getip._thread_vwait(var)
+ end
+
+ def _thread_tkwait(mode, target)
+ __getip._thread_tkwait(mode, target)
+ end
+
+ def _return_value
+ __getip._return_value
+ end
+
+ def _get_variable(var, flag)
+ __getip._get_variable(var, flag)
+ end
+ def _get_variable2(var, idx, flag)
+ __getip._get_variable2(var, idx, flag)
+ end
+ def _set_variable(var, value, flag)
+ __getip._set_variable(var, value, flag)
+ end
+ def _set_variable2(var, idx, value, flag)
+ __getip._set_variable2(var, idx, value, flag)
+ end
+ def _unset_variable(var, flag)
+ __getip._unset_variable(var, flag)
+ end
+ def _unset_variable2(var, idx, flag)
+ __getip._unset_variable2(var, idx, flag)
+ end
+
+ def _get_global_var(var)
+ __getip._get_global_var(var)
+ end
+ def _get_global_var2(var, idx)
+ __getip._get_global_var2(var, idx)
+ end
+ def _set_global_var(var, value)
+ __getip._set_global_var(var, value)
+ end
+ def _set_global_var2(var, idx, value)
+ __getip._set_global_var2(var, idx, value)
+ end
+ def _unset_global_var(var)
+ __getip._unset_global_var(var)
+ end
+ def _unset_global_var2(var, idx)
+ __getip._unset_global_var2(var, idx)
+ end
+
+ def _make_menu_embeddable(menu_path)
+ __getip._make_menu_embeddable(menu_path)
+ end
+
+ def _split_tklist(str)
+ __getip._split_tklist(str)
+ end
+ def _merge_tklist(*args)
+ __getip._merge_tklist(*args)
+ end
+ def _conv_listelement(arg)
+ __getip._conv_listelement(arg)
+ end
+
+ def _create_console
+ __getip._create_console
+ end
+end
+
+
+# wrap methods on TclTkLib : not permit calling TclTkLib module methods
+class << TclTkLib
+ def mainloop(check_root = true)
+ MultiTkIp.mainloop(check_root)
+ end
+ def mainloop_watchdog(check_root = true)
+ MultiTkIp.mainloop_watchdog(check_root)
+ end
+ def do_one_event(flag = TclTkLib::EventFlag::ALL)
+ MultiTkIp.do_one_event(flag)
+ end
+ #def mainloop_abort_on_exception
+ # MultiTkIp.mainloop_abort_on_exception
+ #end
+ #def mainloop_abort_on_exception=(mode)
+ # MultiTkIp.mainloop_abort_on_exception=(mode)
+ #end
+ def set_eventloop_tick(tick)
+ MultiTkIp.set_eventloop_tick(tick)
+ end
+ def get_eventloop_tick
+ MultiTkIp.get_eventloop_tick
+ end
+ def set_no_event_wait(tick)
+ MultiTkIp.set_no_event_wait(tick)
+ end
+ def get_no_event_wait
+ MultiTkIp.get_no_event_wait
+ end
+ def set_eventloop_weight(loop_max, no_event_tick)
+ MultiTkIp.set_eventloop_weight(loop_max, no_event_tick)
+ end
+ def get_eventloop_weight
+ MultiTkIp.get_eventloop_weight
+ end
+ def restart(*args)
+ MultiTkIp.restart(*args)
+ end
+
+ def _merge_tklist(*args)
+ MultiTkIp._merge_tklist(*args)
+ end
+ def _conv_listelement(arg)
+ MultiTkIp._conv_listelement(arg)
+ end
+end
+
+
+# depend on TclTkIp
+class MultiTkIp
+# def mainloop(check_root = true, restart_on_dead = true)
+ def mainloop(check_root = true, restart_on_dead = false)
+ raise SecurityError, "no permission to manipulate" unless self.manipulable?
+
+ if WITH_RUBY_VM ### Ruby 1.9 !!!!!!!!!!!
+ return @interp_thread.value if @interp_thread
+ end
+
+ #return self if self.slave?
+ #return self if self != @@DEFAULT_MASTER
+ if self != @@DEFAULT_MASTER
+ if @wait_on_mainloop[0]
+ begin
+ @wait_on_mainloop[1] += 1
+ if $SAFE >= 4
+ _receiver_mainloop(check_root).join
+ else
+ @cmd_queue.enq([@system, 'call_mainloop',
+ Thread.current, check_root])
+ Thread.stop
+ end
+ rescue MultiTkIp_OK => ret
+ # return value
+ if ret.value.kind_of?(Thread)
+ return ret.value.value
+ else
+ return ret.value
+ end
+ rescue SystemExit => e
+ # exit IP
+ warn("Warning: " + e.inspect + " on " + self.inspect) if $DEBUG
+ begin
+ self._eval_without_enc('exit')
+ rescue Exception
+ end
+ self.delete
+ rescue StandardError => e
+ if $DEBUG
+ warn("Warning: " + e.class.inspect +
+ ((e.message.length > 0)? ' "' + e.message + '"': '') +
+ " on " + self.inspect)
+ end
+ return e
+ rescue Exception => e
+ return e
+ ensure
+ @wait_on_mainloop[1] -= 1
+ end
+ end
+ return
+ end
+
+ unless restart_on_dead
+ @wait_on_mainloop[1] += 1
+=begin
+ begin
+ @interp.mainloop(check_root)
+ rescue StandardError => e
+ if $DEBUG
+ warn("Warning: " + e.class.inspect +
+ ((e.message.length > 0)? ' "' + e.message + '"': '') +
+ " on " + self.inspect)
+ end
+ end
+=end
+ begin
+ @interp.mainloop(check_root)
+ ensure
+ @wait_on_mainloop[1] -= 1
+ end
+ else
+ loop do
+ break unless self.alive?
+ if check_root
+ begin
+ break if TclTkLib.num_of_mainwindows == 0
+ rescue StandardError
+ break
+ end
+ end
+ break if @interp.deleted?
+ begin
+ @wait_on_mainloop[1] += 1
+ @interp.mainloop(check_root)
+ rescue StandardError => e
+ if TclTkLib.mainloop_abort_on_exception != nil
+ #STDERR.print("Warning: Tk mainloop receives ", $!.class.inspect,
+ # " exception (ignore) : ", $!.message, "\n");
+ if $DEBUG
+ warn("Warning: Tk mainloop receives " << e.class.inspect <<
+ " exception (ignore) : " << e.message);
+ end
+ end
+ #raise e
+ rescue Exception => e
+=begin
+ if TclTkLib.mainloop_abort_on_exception != nil
+ #STDERR.print("Warning: Tk mainloop receives ", $!.class.inspect,
+ # " exception (ignore) : ", $!.message, "\n");
+ if $DEBUG
+ warn("Warning: Tk mainloop receives " << e.class.inspect <<
+ " exception (ignore) : " << e.message);
+ end
+ end
+=end
+ raise e
+ ensure
+ @wait_on_mainloop[1] -= 1
+ Thread.pass # avoid eventloop conflict
+ end
+ end
+ end
+ self
+ end
+
+ def make_safe
+ raise SecurityError, "no permission to manipulate" unless self.manipulable?
+ @interp.make_safe
+ end
+
+ def safe?
+ raise SecurityError, "no permission to manipulate" unless self.manipulable?
+ @interp.safe?
+ end
+
+ def safe_base?
+ raise SecurityError, "no permission to manipulate" unless self.manipulable?
+ @safe_base
+ end
+
+ def allow_ruby_exit?
+ raise SecurityError, "no permission to manipulate" unless self.manipulable?
+ @interp.allow_ruby_exit?
+ end
+
+ def allow_ruby_exit= (mode)
+ raise SecurityError, "no permission to manipulate" unless self.manipulable?
+ @interp.allow_ruby_exit = mode
+ end
+
+ def delete
+ raise SecurityError, "no permission to manipulate" unless self.manipulable?
+ @slave_ip_tbl.each{|name, subip|
+ _destroy_slaves_of_slaveIP(subip)
+=begin
+ begin
+ subip._invoke('destroy', '.') unless subip.deleted?
+ rescue Exception
+ end
+=end
+ begin
+ # subip._eval_without_enc("foreach i [after info] {after cancel $i}")
+ unless subip.deleted?
+ after_ids = subip._eval_without_enc("after info")
+ subip._eval_without_enc("foreach i {#{after_ids}} {after cancel $i}")
+ end
+ rescue Exception
+ end
+
+ # safe_base?
+ if @interp._eval_without_enc("catch {::safe::interpConfigure #{name}}") == '0'
+ begin
+ @interp._eval_without_enc("::safe::interpDelete #{name}")
+ rescue Exception
+ else
+ next if subip.deleted?
+ end
+ end
+ if subip.respond_to?(:safe_base?) && subip.safe_base? &&
+ !subip.deleted?
+ # do 'exit' to call the delete_hook procedure
+ begin
+ subip._eval_without_enc('exit')
+ rescue Exception
+ end
+ else
+ begin
+ subip.delete unless subip.deleted?
+ rescue Exception
+ end
+ end
+ }
+
+ begin
+ # @interp._eval_without_enc("foreach i [after info] {after cancel $i}")
+ after_ids = @interp._eval_without_enc("after info")
+ @interp._eval_without_enc("foreach i {#{after_ids}} {after cancel $i}")
+ rescue Exception
+ end
+
+ begin
+ @interp._invoke('destroy', '.') unless @interp.deleted?
+ rescue Exception
+ end
+
+ if @safe_base && !@interp.deleted?
+ # do 'exit' to call the delete_hook procedure
+ @interp._eval_without_enc('exit')
+ end
+ @interp.delete
+ self
+ end
+
+ def deleted?
+ raise SecurityError, "no permission to manipulate" unless self.manipulable?
+ @interp.deleted?
+ end
+
+ def has_mainwindow?
+ raise SecurityError, "no permission to manipulate" unless self.manipulable?
+ @interp.has_mainwindow?
+ end
+
+ def invalid_namespace?
+ raise SecurityError, "no permission to manipulate" unless self.manipulable?
+ @interp.invalid_namespace?
+ end
+
+ def abort(msg = nil)
+ raise SecurityError, "no permission to manipulate" unless self.manipulable?
+ if master? && !safe? && allow_ruby_exit?
+ if msg
+ Kernel.abort(msg)
+ else
+ Kernel.abort
+ end
+ else
+ # ignore msg
+ delete
+ 1
+ end
+ end
+
+ def exit(st = true)
+ raise SecurityError, "no permission to manipulate" unless self.manipulable?
+ if master? && !safe? && allow_ruby_exit?
+ Kernel.exit(st)
+ else
+ delete
+ st
+ end
+ end
+
+ def exit!(st = false)
+ raise SecurityError, "no permission to manipulate" unless self.manipulable?
+ if master? && !safe? && allow_ruby_exit?
+ Kernel.exit!(st)
+ else
+ delete
+ st
+ end
+ end
+
+ def restart(app_name = nil, keys = {})
+ raise SecurityError, "no permission to manipulate" unless self.manipulable?
+
+ _init_ip_internal(@@INIT_IP_ENV, @@ADD_TK_PROCS)
+
+ @interp._invoke('set', 'argv0', app_name) if app_name
+ if keys.kind_of?(Hash)
+ @interp._invoke('set', 'argv', _keys2opts(keys))
+ end
+
+ @interp.restart
+ end
+
+ def __eval(str)
+ raise SecurityError, "no permission to manipulate" unless self.manipulable?
+ @interp.__eval(str)
+ end
+
+ def __invoke(*args)
+ raise SecurityError, "no permission to manipulate" unless self.manipulable?
+ @interp.__invoke(*args)
+ end
+
+ def _eval(str)
+ raise SecurityError, "no permission to manipulate" unless self.manipulable?
+ @interp._eval(str)
+ end
+
+ def _invoke(*args)
+ raise SecurityError, "no permission to manipulate" unless self.manipulable?
+ @interp._invoke(*args)
+ end
+
+ def _eval_without_enc(str)
+ raise SecurityError, "no permission to manipulate" unless self.manipulable?
+ @interp._eval_without_enc(str)
+ end
+
+ def _invoke_without_enc(*args)
+ raise SecurityError, "no permission to manipulate" unless self.manipulable?
+ @interp._invoke_without_enc(*args)
+ end
+
+ def _eval_with_enc(str)
+ raise SecurityError, "no permission to manipulate" unless self.manipulable?
+ @interp._eval_with_enc(str)
+ end
+
+ def _invoke_with_enc(*args)
+ raise SecurityError, "no permission to manipulate" unless self.manipulable?
+ @interp._invoke_with_enc(*args)
+ end
+
+ def _toUTF8(str, encoding=nil)
+ raise SecurityError, "no permission to manipulate" unless self.manipulable?
+ @interp._toUTF8(str, encoding)
+ end
+
+ def _fromUTF8(str, encoding=nil)
+ raise SecurityError, "no permission to manipulate" unless self.manipulable?
+ @interp._fromUTF8(str, encoding)
+ end
+
+ def _thread_vwait(var)
+ raise SecurityError, "no permission to manipulate" unless self.manipulable?
+ @interp._thread_vwait(var)
+ end
+
+ def _thread_tkwait(mode, target)
+ raise SecurityError, "no permission to manipulate" unless self.manipulable?
+ @interp._thread_tkwait(mode, target)
+ end
+
+ def _return_value
+ raise SecurityError, "no permission to manipulate" unless self.manipulable?
+ @interp._return_value
+ end
+
+ def _get_variable(var, flag)
+ raise SecurityError, "no permission to manipulate" unless self.manipulable?
+ @interp._get_variable(var, flag)
+ end
+ def _get_variable2(var, idx, flag)
+ raise SecurityError, "no permission to manipulate" unless self.manipulable?
+ @interp._get_variable2(var, idx, flag)
+ end
+ def _set_variable(var, value, flag)
+ raise SecurityError, "no permission to manipulate" unless self.manipulable?
+ @interp._set_variable(var, value, flag)
+ end
+ def _set_variable2(var, idx, value, flag)
+ raise SecurityError, "no permission to manipulate" unless self.manipulable?
+ @interp._set_variable2(var, idx, value, flag)
+ end
+ def _unset_variable(var, flag)
+ raise SecurityError, "no permission to manipulate" unless self.manipulable?
+ @interp._unset_variable(var, flag)
+ end
+ def _unset_variable2(var, idx, flag)
+ raise SecurityError, "no permission to manipulate" unless self.manipulable?
+ @interp._unset_variable2(var, idx, flag)
+ end
+
+ def _get_global_var(var)
+ raise SecurityError, "no permission to manipulate" unless self.manipulable?
+ @interp._get_global_var(var)
+ end
+ def _get_global_var2(var, idx)
+ raise SecurityError, "no permission to manipulate" unless self.manipulable?
+ @interp._get_global_var2(var, idx)
+ end
+ def _set_global_var(var, value)
+ raise SecurityError, "no permission to manipulate" unless self.manipulable?
+ @interp._set_global_var(var, value)
+ end
+ def _set_global_var2(var, idx, value)
+ raise SecurityError, "no permission to manipulate" unless self.manipulable?
+ @interp._set_global_var2(var, idx, value)
+ end
+ def _unset_global_var(var)
+ raise SecurityError, "no permission to manipulate" unless self.manipulable?
+ @interp._unset_global_var(var)
+ end
+ def _unset_global_var2(var, idx)
+ raise SecurityError, "no permission to manipulate" unless self.manipulable?
+ @interp._unset_global_var2(var, idx)
+ end
+
+ def _make_menu_embeddable(menu_path)
+ raise SecurityError, "no permission to manipulate" unless self.manipulable?
+ @interp._make_menu_embeddable(menu_path)
+ end
+
+ def _split_tklist(str)
+ raise SecurityError, "no permission to manipulate" unless self.manipulable?
+ @interp._split_tklist(str)
+ end
+ def _merge_tklist(*args)
+ raise SecurityError, "no permission to manipulate" unless self.manipulable?
+ @interp._merge_tklist(*args)
+ end
+ def _conv_listelement(arg)
+ raise SecurityError, "no permission to manipulate" unless self.manipulable?
+ @interp._conv_listelement(arg)
+ end
+end
+
+
+# interp command support
+class MultiTkIp
+ def _lst2ary(str)
+ return [] if str == ""
+ idx = str.index('{')
+ while idx and idx > 0 and str[idx-1] == ?\\
+ idx = str.index('{', idx+1)
+ end
+ return str.split unless idx
+
+ list = str[0,idx].split
+ str = str[idx+1..-1]
+ i = -1
+ brace = 1
+ str.each_byte {|c|
+ c = c.chr
+ i += 1
+ brace += 1 if c == '{'
+ brace -= 1 if c == '}'
+ break if brace == 0
+ }
+ if i == 0
+ list.push ''
+ elsif str[0, i] == ' '
+ list.push ' '
+ else
+ list.push str[0..i-1]
+ end
+ #list += _lst2ary(str[i+1..-1])
+ list.concat(_lst2ary(str[i+1..-1]))
+ list
+ end
+ private :_lst2ary
+
+ def _slavearg(slave)
+ if slave.kind_of?(MultiTkIp)
+ slave.path
+ elsif slave.kind_of?(String)
+ slave
+ else
+ slave.to_s
+ end
+ end
+ private :_slavearg
+
+ def alias_info(slave, cmd_name)
+ raise SecurityError, "no permission to manipulate" unless self.manipulable?
+ _lst2ary(@interp._invoke('interp', 'alias', _slavearg(slave), cmd_name))
+ end
+ def self.alias_info(slave, cmd_name)
+ __getip.alias_info(slave, cmd_name)
+ end
+
+ def alias_delete(slave, cmd_name)
+ raise SecurityError, "no permission to manipulate" unless self.manipulable?
+ @interp._invoke('interp', 'alias', _slavearg(slave), cmd_name, '')
+ self
+ end
+ def self.alias_delete(slave, cmd_name)
+ __getip.alias_delete(slave, cmd_name)
+ self
+ end
+
+ def def_alias(slave, new_cmd, org_cmd, *args)
+ raise SecurityError, "no permission to manipulate" unless self.manipulable?
+ ret = @interp._invoke('interp', 'alias', _slavearg(slave), new_cmd,
+ '', org_cmd, *args)
+ (ret == new_cmd)? self: nil
+ end
+ def self.def_alias(slave, new_cmd, org_cmd, *args)
+ ret = __getip.def_alias(slave, new_cmd, org_cmd, *args)
+ (ret == new_cmd)? self: nil
+ end
+
+ def aliases(slave = '')
+ raise SecurityError, "no permission to manipulate" unless self.manipulable?
+ _lst2ary(@interp._invoke('interp', 'aliases', _slavearg(slave)))
+ end
+ def self.aliases(slave = '')
+ __getip.aliases(slave)
+ end
+
+ def delete_slaves(*args)
+ raise SecurityError, "no permission to manipulate" unless self.manipulable?
+ slaves = args.collect{|s| _slavearg(s)}
+ @interp._invoke('interp', 'delete', *slaves) if slaves.size > 0
+ self
+ end
+ def self.delete_slaves(*args)
+ __getip.delete_slaves(*args)
+ self
+ end
+
+ def exist?(slave = '')
+ raise SecurityError, "no permission to manipulate" unless self.manipulable?
+ ret = @interp._invoke('interp', 'exists', _slavearg(slave))
+ (ret == '1')? true: false
+ end
+ def self.exist?(slave = '')
+ __getip.exist?(slave)
+ end
+
+ def delete_cmd(slave, cmd)
+ raise SecurityError, "no permission to manipulate" unless self.manipulable?
+ slave_invoke = @interp._invoke('list', 'rename', cmd, '')
+ @interp._invoke('interp', 'eval', _slavearg(slave), slave_invoke)
+ self
+ end
+ def self.delete_cmd(slave, cmd)
+ __getip.delete_cmd(slave, cmd)
+ self
+ end
+
+ def expose_cmd(slave, cmd, aliasname = nil)
+ raise SecurityError, "no permission to manipulate" unless self.manipulable?
+ if aliasname
+ @interp._invoke('interp', 'expose', _slavearg(slave), cmd, aliasname)
+ else
+ @interp._invoke('interp', 'expose', _slavearg(slave), cmd)
+ end
+ self
+ end
+ def self.expose_cmd(slave, cmd, aliasname = nil)
+ __getip.expose_cmd(slave, cmd, aliasname)
+ self
+ end
+
+ def hide_cmd(slave, cmd, aliasname = nil)
+ raise SecurityError, "no permission to manipulate" unless self.manipulable?
+ if aliasname
+ @interp._invoke('interp', 'hide', _slavearg(slave), cmd, aliasname)
+ else
+ @interp._invoke('interp', 'hide', _slavearg(slave), cmd)
+ end
+ self
+ end
+ def self.hide_cmd(slave, cmd, aliasname = nil)
+ __getip.hide_cmd(slave, cmd, aliasname)
+ self
+ end
+
+ def hidden_cmds(slave = '')
+ raise SecurityError, "no permission to manipulate" unless self.manipulable?
+ _lst2ary(@interp._invoke('interp', 'hidden', _slavearg(slave)))
+ end
+ def self.hidden_cmds(slave = '')
+ __getip.hidden_cmds(slave)
+ end
+
+ def invoke_hidden(slave, cmd, *args)
+ raise SecurityError, "no permission to manipulate" unless self.manipulable?
+ if args[-1].kind_of?(Hash)
+ keys = _symbolkey2str(args.pop)
+ else
+ keys = []
+ end
+ keys << _slavearg(slave)
+ if Tk::TCL_MAJOR_VERSION > 8 ||
+ (Tk::TCL_MAJOR_VERSION == 8 && Tk::TCL_MINOR_VERSION >= 5)
+ keys << '--'
+ end
+ keys << cmd
+ keys.concat(args)
+ @interp._invoke('interp', 'invokehidden', *keys)
+ end
+ def self.invoke_hidden(slave, cmd, *args)
+ __getip.invoke_hidden(slave, cmd, *args)
+ end
+
+ def invoke_hidden_on_global(slave, cmd, *args)
+ raise SecurityError, "no permission to manipulate" unless self.manipulable?
+ if args[-1].kind_of?(Hash)
+ keys = _symbolkey2str(args.pop)
+ else
+ keys = []
+ end
+ keys << _slavearg(slave)
+ keys << '-global'
+ if Tk::TCL_MAJOR_VERSION > 8 ||
+ (Tk::TCL_MAJOR_VERSION == 8 && Tk::TCL_MINOR_VERSION >= 5)
+ keys << '--'
+ end
+ keys << cmd
+ keys.concat(args)
+ @interp._invoke('interp', 'invokehidden', *keys)
+ end
+ def self.invoke_hidden_on_global(slave, cmd, *args)
+ __getip.invoke_hidden_on_global(slave, cmd, *args)
+ end
+
+ def invoke_hidden_on_namespace(slave, ns, cmd, *args)
+ # for Tcl8.5 or later
+ raise SecurityError, "no permission to manipulate" unless self.manipulable?
+ if args[-1].kind_of?(Hash)
+ keys = _symbolkey2str(args.pop)
+ else
+ keys = []
+ end
+ keys << _slavearg(slave)
+ keys << '-namespace' << TkComm._get_eval_string(ns)
+ keys << '--' << cmd
+ keys.concat(args)
+ @interp._invoke('interp', 'invokehidden', *keys)
+ end
+ def self.invoke_hidden_on_namespace(slave, ns, cmd, *args)
+ __getip.invoke_hidden_on_namespace(slave, ns, cmd, *args)
+ end
+
+ def mark_trusted(slave = '')
+ raise SecurityError, "no permission to manipulate" unless self.manipulable?
+ @interp._invoke('interp', 'marktrusted', _slavearg(slave))
+ self
+ end
+ def self.mark_trusted(slave = '')
+ __getip.mark_trusted(slave)
+ self
+ end
+
+ def set_bgerror_handler(cmd = Proc.new, slave = nil, &b)
+ raise SecurityError, "no permission to manipulate" unless self.manipulable?
+
+ unless TkComm._callback_entry?(cmd)
+ if !slave && b
+ slave = cmd
+ cmd = Proc.new(&b)
+ end
+ end
+ slave = '' unless slave
+
+ @interp._invoke('interp', 'bgerror', _slavearg(slave), cmd)
+ end
+ def self.bgerror(cmd = Proc.new, slave = nil, &b)
+ __getip.bgerror(cmd, slave, &b)
+ end
+
+ def get_bgerror_handler(slave = '')
+ raise SecurityError, "no permission to manipulate" unless self.manipulable?
+ procedure(@interp._invoke('interp', 'bgerror', _slavearg(slave)))
+ end
+ def self.bgerror(slave = '')
+ __getip.bgerror(slave)
+ end
+
+ def set_limit(limit_type, slave = '', opts = {})
+ raise SecurityError, "no permission to manipulate" unless self.manipulable?
+ @interp._invoke('interp', 'limit', _slavearg(slave), limit_type, opts)
+ end
+ def self.set_limit(limit_type, slave = '', opts = {})
+ __getip.set_limit(limit_type, slave, opts)
+ end
+
+ def get_limit(limit_type, slave = '', slot = nil)
+ raise SecurityError, "no permission to manipulate" unless self.manipulable?
+
+ if slot
+ num_or_str(@interp._invoke('interp', 'limit', _slavearg(slave),
+ limit_type, slot))
+ else
+ l = @interp._split_tklist(@interp._invoke_without_enc('interp', 'limit',
+ _slavearg(slave),
+ limit_type))
+ l.map!{|s| _fromUTF8(s)}
+ r = {}
+ until l.empty?
+ key = l.shift[1..-1]
+ val = l.shift
+ val = num_or_str(val) if val
+ r[key] = val
+ end
+ r
+ end
+ end
+ def self.get_limit(limit_type, slave = '', slot = nil)
+ __getip.get_limit(limit_type, slave, slot)
+ end
+
+ def recursion_limit(slave = '', limit = None)
+ raise SecurityError, "no permission to manipulate" unless self.manipulable?
+ number(@interp._invoke('interp', 'recursionlimit',
+ _slavearg(slave), limit))
+ end
+ def self.recursion_limit(slave = '', limit = None)
+ __getip.recursion_limit(slave)
+ end
+
+ def alias_target(aliascmd, slave = '')
+ raise SecurityError, "no permission to manipulate" unless self.manipulable?
+ @interp._invoke('interp', 'target', _slavearg(slave), aliascmd)
+ end
+ def self.alias_target(aliascmd, slave = '')
+ __getip.alias_target(aliascmd, slave)
+ end
+
+ def share_stdin(dist, src = '')
+ raise SecurityError, "no permission to manipulate" unless self.manipulable?
+ @interp._invoke('interp', 'share', src, 'stdin', dist)
+ self
+ end
+ def self.share_stdin(dist, src = '')
+ __getip.share_stdin(dist, src)
+ self
+ end
+
+ def share_stdout(dist, src = '')
+ raise SecurityError, "no permission to manipulate" unless self.manipulable?
+ @interp._invoke('interp', 'share', src, 'stdout', dist)
+ self
+ end
+ def self.share_stdout(dist, src = '')
+ __getip.share_stdout(dist, src)
+ self
+ end
+
+ def share_stderr(dist, src = '')
+ raise SecurityError, "no permission to manipulate" unless self.manipulable?
+ @interp._invoke('interp', 'share', src, 'stderr', dist)
+ self
+ end
+ def self.share_stderr(dist, src = '')
+ __getip.share_stderr(dist, src)
+ self
+ end
+
+ def transfer_stdin(dist, src = '')
+ raise SecurityError, "no permission to manipulate" unless self.manipulable?
+ @interp._invoke('interp', 'transfer', src, 'stdin', dist)
+ self
+ end
+ def self.transfer_stdin(dist, src = '')
+ __getip.transfer_stdin(dist, src)
+ self
+ end
+
+ def transfer_stdout(dist, src = '')
+ raise SecurityError, "no permission to manipulate" unless self.manipulable?
+ @interp._invoke('interp', 'transfer', src, 'stdout', dist)
+ self
+ end
+ def self.transfer_stdout(dist, src = '')
+ __getip.transfer_stdout(dist, src)
+ self
+ end
+
+ def transfer_stderr(dist, src = '')
+ raise SecurityError, "no permission to manipulate" unless self.manipulable?
+ @interp._invoke('interp', 'transfer', src, 'stderr', dist)
+ self
+ end
+ def self.transfer_stderr(dist, src = '')
+ __getip.transfer_stderr(dist, src)
+ self
+ end
+
+ def share_stdio(dist, src = '')
+ raise SecurityError, "no permission to manipulate" unless self.manipulable?
+ @interp._invoke('interp', 'share', src, 'stdin', dist)
+ @interp._invoke('interp', 'share', src, 'stdout', dist)
+ @interp._invoke('interp', 'share', src, 'stderr', dist)
+ self
+ end
+ def self.share_stdio(dist, src = '')
+ __getip.share_stdio(dist, src)
+ self
+ end
+
+ def transfer_stdio(dist, src = '')
+ raise SecurityError, "no permission to manipulate" unless self.manipulable?
+ @interp._invoke('interp', 'transfer', src, 'stdin', dist)
+ @interp._invoke('interp', 'transfer', src, 'stdout', dist)
+ @interp._invoke('interp', 'transfer', src, 'stderr', dist)
+ self
+ end
+ def self.transfer_stdio(dist, src = '')
+ __getip.transfer_stdio(dist, src)
+ self
+ end
+end
+
+
+# Safe Base :: manipulating safe interpreter
+class MultiTkIp
+ def safeip_configure(slot, value=None)
+ # use for '-noStatics' option ==> {statics=>false}
+ # for '-nestedLoadOk' option ==> {nested=>true}
+ if slot.kind_of?(Hash)
+ ip = MultiTkIp.__getip
+ ip._eval('::safe::interpConfigure ' + @ip_name + ' ' + _keys2opts(slot))
+ else
+ ip._eval('::safe::interpConfigure ' + @ip_name + ' ' +
+ "-#{slot} #{_get_eval_string(value)}")
+ end
+ self
+ end
+
+ def safeip_configinfo(slot = nil)
+ ip = MultiTkIp.__getip
+ ret = {}
+ if slot
+ conf = _lst2ary(ip._eval("::safe::interpConfigure " +
+ @ip_name + " -#{slot}"))
+ if conf[0] == '-deleteHook'
+=begin
+ if conf[1] =~ /^rb_out\S* (c(_\d+_)?\d+)/
+ ret[conf[0][1..-1]] = MultiTkIp._tk_cmd_tbl[$1]
+=end
+ if conf[1] =~ /rb_out\S*(?:\s+(::\S*|[{](::.*)[}]|["](::.*)["]))? (c(_\d+_)?(\d+))/
+ ret[conf[0][1..-1]] = MultiTkIp._tk_cmd_tbl[$4]
+ else
+ ret[conf[0][1..-1]] = conf[1]
+ end
+ else
+ ret[conf[0][1..-1]] = conf[1]
+ end
+ else
+ Hash[*_lst2ary(ip._eval("::safe::interpConfigure " +
+ @ip_name))].each{|k, v|
+ if k == '-deleteHook'
+=begin
+ if v =~ /^rb_out\S* (c(_\d+_)?\d+)/
+ ret[k[1..-1]] = MultiTkIp._tk_cmd_tbl[$1]
+=end
+ if v =~ /rb_out\S*(?:\s+(::\S*|[{](::.*)[}]|["](::.*)["]))? (c(_\d+_)?(\d+))/
+ ret[k[1..-1]] = MultiTkIp._tk_cmd_tbl[$4]
+ else
+ ret[k[1..-1]] = v
+ end
+ else
+ ret[k[1..-1]] = v
+ end
+ }
+ end
+ ret
+ end
+
+ def safeip_delete
+ ip = MultiTkIp.__getip
+ ip._eval("::safe::interpDelete " + @ip_name)
+ end
+
+ def safeip_add_to_access_path(dir)
+ ip = MultiTkIp.__getip
+ ip._eval("::safe::interpAddToAccessPath #{@ip_name} #{dir}")
+ end
+
+ def safeip_find_in_access_path(dir)
+ ip = MultiTkIp.__getip
+ ip._eval("::safe::interpFindInAccessPath #{@ip_name} #{dir}")
+ end
+
+ def safeip_set_log_cmd(cmd = Proc.new)
+ ip = MultiTkIp.__getip
+ ip._eval("::safe::setLogCmd #{@ip_name} #{_get_eval_string(cmd)}")
+ end
+end
+
+
+# encoding convert
+class << MultiTkIp
+ def encoding_table
+ __getip.encoding_table
+ end
+
+ def force_default_encoding=(mode)
+ __getip.force_default_encoding=(mode)
+ end
+
+ def force_default_encoding?
+ __getip.force_default_encoding?
+ end
+
+ def default_encoding=(enc)
+ __getip.default_encoding=(enc)
+ end
+
+ def encoding=(enc)
+ __getip.encoding=(enc)
+ end
+
+ def encoding_name
+ __getip.encoding_name
+ end
+
+ def encoding_obj
+ __getip.encoding_obj
+ end
+ alias encoding encoding_name
+ alias default_encoding encoding_name
+
+ def encoding_convertfrom(str, enc=None)
+ __getip.encoding_convertfrom(str, enc)
+ end
+ alias encoding_convert_from encoding_convertfrom
+
+ def encoding_convertto(str, enc=None)
+ __getip.encoding_convertto(str, enc)
+ end
+ alias encoding_convert_to encoding_convertto
+end
+class MultiTkIp
+ def encoding_table
+ @interp.encoding_table
+ end
+
+ def force_default_encoding=(mode)
+ raise SecurityError, "no permission to manipulate" unless self.manipulable?
+ @interp.force_default_encoding = mode
+ end
+ def force_default_encoding?
+ raise SecurityError, "no permission to manipulate" unless self.manipulable?
+ @interp.force_default_encoding?
+ end
+
+ def default_encoding=(enc)
+ raise SecurityError, "no permission to manipulate" unless self.manipulable?
+ @interp.default_encoding = enc
+ end
+
+ def encoding=(enc)
+ raise SecurityError, "no permission to manipulate" unless self.manipulable?
+ @interp.encoding = enc
+ end
+ def encoding_name
+ raise SecurityError, "no permission to manipulate" unless self.manipulable?
+ @interp.encoding_name
+ end
+ def encoding_obj
+ raise SecurityError, "no permission to manipulate" unless self.manipulable?
+ @interp.encoding_obj
+ end
+ alias encoding encoding_name
+ alias default_encoding encoding_name
+
+ def encoding_convertfrom(str, enc=None)
+ raise SecurityError, "no permission to manipulate" unless self.manipulable?
+ @interp.encoding_convertfrom(str, enc)
+ end
+ alias encoding_convert_from encoding_convertfrom
+
+ def encoding_convertto(str, enc=None)
+ raise SecurityError, "no permission to manipulate" unless self.manipulable?
+ @interp.encoding_convertto(str, enc)
+ end
+ alias encoding_convert_to encoding_convertto
+end
+
+
+# remove methods for security
+=begin
+class MultiTkIp
+ INTERP_THREAD = @@DEFAULT_MASTER.instance_variable_get('@interp_thread')
+ INTERP_MUTEX = INTERP_THREAD[:mutex]
+ INTERP_ROOT_CHECK = INTERP_THREAD[:root_check]
+
+ # undef_method :instance_eval
+ undef_method :instance_variable_get
+ undef_method :instance_variable_set
+end
+
+module TkCore
+ if MultiTkIp::WITH_RUBY_VM &&
+ ! MultiTkIp::RUN_EVENTLOOP_ON_MAIN_THREAD ### check Ruby 1.9 !!!!!!!
+ INTERP_THREAD = MultiTkIp::INTERP_THREAD
+ INTERP_MUTEX = MultiTkIp::INTERP_MUTEX
+ INTERP_ROOT_CHECK = MultiTkIp::INTERP_ROOT_CHECK
+ end
+end
+class MultiTkIp
+ remove_const(:INTERP_THREAD)
+ remove_const(:INTERP_MUTEX)
+ remove_const(:INTERP_ROOT_CHECK)
+end
+=end
+if MultiTkIp::WITH_RUBY_VM &&
+ ! MultiTkIp::RUN_EVENTLOOP_ON_MAIN_THREAD ### check Ruby 1.9 !!!!!!!
+ class MultiTkIp
+ INTERP_THREAD = @@DEFAULT_MASTER.instance_variable_get('@interp_thread')
+ INTERP_THREAD_STATUS = INTERP_THREAD[:status]
+ INTERP_MUTEX = INTERP_THREAD[:mutex]
+ INTERP_ROOT_CHECK = INTERP_THREAD[:root_check]
+ end
+ module TkCore
+ INTERP_THREAD = MultiTkIp::INTERP_THREAD
+ INTERP_THREAD_STATUS = MultiTkIp::INTERP_THREAD_STATUS
+ INTERP_MUTEX = MultiTkIp::INTERP_MUTEX
+ INTERP_ROOT_CHECK = MultiTkIp::INTERP_ROOT_CHECK
+ end
+ class MultiTkIp
+ remove_const(:INTERP_THREAD)
+ remove_const(:INTERP_THREAD_STATUS)
+ remove_const(:INTERP_MUTEX)
+ remove_const(:INTERP_ROOT_CHECK)
+ end
+end
+
+class MultiTkIp
+ # undef_method :instance_eval
+ undef_method :instance_variable_get
+ undef_method :instance_variable_set
+end
+# end of MultiTkIp definition
+
+# defend against modification
+#MultiTkIp.freeze
+#TclTkLib.freeze
+
+########################################
+# start Tk which depends on MultiTkIp
+module TkCore
+ INTERP = MultiTkIp
+end
+require 'tk'
diff --git a/jni/ruby/ext/tk/lib/remote-tk.rb b/jni/ruby/ext/tk/lib/remote-tk.rb
new file mode 100644
index 0000000..443d660
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/remote-tk.rb
@@ -0,0 +1,530 @@
+#
+# remote-tk.rb - supports to control remote Tk interpreters
+# by Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
+
+if defined? MultiTkIp
+ fail RuntimeError, "'remote-tk' library must be required before requiring 'multi-tk'"
+end
+
+class MultiTkIp; end
+class RemoteTkIp < MultiTkIp; end
+
+class MultiTkIp
+ @@IP_TABLE = TkUtil.untrust({}) unless defined?(@@IP_TABLE)
+ @@TK_TABLE_LIST = TkUtil.untrust([]) unless defined?(@@TK_TABLE_LIST)
+ def self._IP_TABLE; @@IP_TABLE; end
+ def self._TK_TABLE_LIST; @@TK_TABLE_LIST; end
+
+ @flag = true
+ def self._DEFAULT_MASTER
+ # work only once
+ if @flag
+ @flag = nil
+ @@DEFAULT_MASTER
+ else
+ nil
+ end
+ end
+end
+class RemoteTkIp
+ @@IP_TABLE = MultiTkIp._IP_TABLE unless defined?(@@IP_TABLE)
+ @@TK_TABLE_LIST = MultiTkIp._TK_TABLE_LIST unless defined?(@@TK_TABLE_LIST)
+end
+class << MultiTkIp
+ undef _IP_TABLE
+ undef _TK_TABLE_LIST
+end
+
+require 'multi-tk'
+
+class RemoteTkIp
+ if defined?(@@DEFAULT_MASTER)
+ MultiTkIp._DEFAULT_MASTER
+ else
+ @@DEFAULT_MASTER = MultiTkIp._DEFAULT_MASTER
+ end
+end
+
+
+###############################
+
+class << RemoteTkIp
+ undef new_master, new_slave, new_safe_slave
+ undef new_trusted_slave, new_safeTk
+
+ def new(*args, &b)
+ ip = __new(*args)
+ ip.eval_proc(&b) if b
+ ip
+ end
+end
+
+class RemoteTkIp
+ def initialize(remote_ip, displayof=nil, timeout=5)
+ if $SAFE >= 4
+ fail SecurityError, "cannot access another interpreter at level #{$SAFE}"
+ end
+
+ @interp = MultiTkIp.__getip
+ if @interp.safe?
+ fail SecurityError, "safe-IP cannot create RemoteTkIp"
+ end
+
+
+ @interp.allow_ruby_exit = false
+ @appname = @interp._invoke('tk', 'appname')
+ @remote = remote_ip.to_s.dup.freeze
+ if displayof.kind_of?(TkWindow)
+ @displayof = displayof.path.dup.freeze
+ else
+ @displayof = nil
+ end
+ if self.deleted?
+ fail RuntimeError, "no Tk application named \"#{@remote}\""
+ end
+
+ @tk_windows = {}
+ @tk_table_list = []
+ @slave_ip_tbl = {}
+ @slave_ip_top = {}
+
+ @force_default_encoding ||= TkUtil.untrust([false])
+ @encoding ||= TkUtil.untrust([nil])
+ def @encoding.to_s; self.join(nil); end
+
+ TkUtil.untrust(@tk_windows) unless @tk_windows.tainted?
+ TkUtil.untrust(@tk_table_list) unless @tk_table_list.tainted?
+ TkUtil.untrust(@slave_ip_tbl) unless @slave_ip_tbl.tainted?
+ TkUtil.untrust(@slave_ip_top) unless @slave_ip_top.tainted?
+
+ @system = Object.new
+
+ @threadgroup = ThreadGroup.new
+
+ @safe_level = [$SAFE]
+
+ @wait_on_mainloop = [true, 0]
+
+ @cmd_queue = Queue.new
+
+=begin
+ @cmd_receiver, @receiver_watchdog = _create_receiver_and_watchdog()
+
+ @threadgroup.add @cmd_receiver
+ @threadgroup.add @receiver_watchdog
+
+ @threadgroup.enclose
+=end
+ @@DEFAULT_MASTER.assign_receiver_and_watchdog(self)
+
+ @@IP_TABLE[@threadgroup] = self
+ @@TK_TABLE_LIST.size.times{
+ (tbl = {}).tainted? || TkUtil.untrust(tbl)
+ @tk_table_list << tbl
+ }
+
+ @ret_val = TkVariable.new
+ if timeout > 0 && ! _available_check(timeout)
+ fail RuntimeError, "cannot create connection"
+ end
+ @ip_id = _create_connection
+
+ class << self
+ undef :instance_eval
+ end
+
+ self.freeze # defend against modification
+ end
+
+ def manipulable?
+ return true if (Thread.current.group == ThreadGroup::Default)
+ MultiTkIp.__getip == @interp && ! @interp.safe?
+ end
+ def self.manipulable?
+ true
+ end
+
+ def _is_master_of?(tcltkip_obj)
+ tcltkip_obj == @interp
+ end
+ protected :_is_master_of?
+
+ def _ip_id_
+ @ip_id
+ end
+
+ def _available_check(timeout = 5)
+ raise SecurityError, "no permission to manipulate" unless self.manipulable?
+
+ return nil if timeout < 1
+ @ret_val.value = ''
+ @interp._invoke('send', '-async', @remote,
+ 'send', '-async', Tk.appname,
+ "set #{@ret_val.id} ready")
+ Tk.update
+ if @ret_val != 'ready'
+ (1..(timeout*5)).each{
+ sleep 0.2
+ Tk.update
+ break if @ret_val == 'ready'
+ }
+ end
+ @ret_val.value == 'ready'
+ end
+ private :_available_check
+
+ def _create_connection
+ raise SecurityError, "no permission to manipulate" unless self.manipulable?
+
+ ip_id = '_' + @interp._invoke('send', @remote, <<-'EOS') + '_'
+ if {[catch {set _rubytk_control_ip_id_} ret] != 0} {
+ set _rubytk_control_ip_id_ 0
+ } else {
+ set _rubytk_control_ip_id_ [expr $ret + 1]
+ }
+ return $_rubytk_control_ip_id_
+ EOS
+
+ @interp._invoke('send', @remote, <<-EOS)
+ proc rb_out#{ip_id} args {
+ send #{@appname} rb_out \$args
+ }
+ EOS
+
+ ip_id
+ end
+ private :_create_connection
+
+ def _appsend(enc_mode, async, *cmds)
+ raise SecurityError, "no permission to manipulate" unless self.manipulable?
+
+ p ['_appsend', [@remote, @displayof], enc_mode, async, cmds] if $DEBUG
+ if $SAFE >= 4
+ fail SecurityError, "cannot send commands at level 4"
+ elsif $SAFE >= 1 && cmds.find{|obj| obj.tainted?}
+ fail SecurityError, "cannot send tainted commands at level #{$SAFE}"
+ end
+
+ cmds = @interp._merge_tklist(*TkUtil::_conv_args([], enc_mode, *cmds))
+ if @displayof
+ if async
+ @interp.__invoke('send', '-async', '-displayof', @displayof,
+ '--', @remote, *cmds)
+ else
+ @interp.__invoke('send', '-displayof', @displayof,
+ '--', @remote, *cmds)
+ end
+ else
+ if async
+ @interp.__invoke('send', '-async', '--', @remote, *cmds)
+ else
+ @interp.__invoke('send', '--', @remote, *cmds)
+ end
+ end
+ end
+ private :_appsend
+
+ def ready?(timeout=5)
+ if timeout < 0
+ fail ArgumentError, "timeout must be positive number"
+ end
+ _available_check(timeout)
+ end
+
+ def is_rubytk?
+ return false if _appsend(false, false, 'info', 'command', 'ruby') == ""
+ [ _appsend(false, false, 'ruby', 'RUBY_VERSION'),
+ _appsend(false, false, 'set', 'tk_patchLevel') ]
+ end
+
+ def appsend(async, *args)
+ raise SecurityError, "no permission to manipulate" unless self.manipulable?
+
+ if async != true && async != false && async != nil
+ args.unshift(async)
+ async = false
+ end
+ if @displayof
+ Tk.appsend_displayof(@remote, @displayof, async, *args)
+ else
+ Tk.appsend(@remote, async, *args)
+ end
+ end
+
+ def rb_appsend(async, *args)
+ raise SecurityError, "no permission to manipulate" unless self.manipulable?
+
+ if async != true && async != false && async != nil
+ args.unshift(async)
+ async = false
+ end
+ if @displayof
+ Tk.rb_appsend_displayof(@remote, @displayof, async, *args)
+ else
+ Tk.rb_appsend(@remote, async, *args)
+ end
+ end
+
+ def create_slave(name, safe=false)
+ if safe
+ safe_opt = ''
+ else
+ safe_opt = '-safe'
+ end
+ _appsend(false, false, "interp create #{safe_opt} -- #{name}")
+ end
+
+ def make_safe
+ fail RuntimeError, 'cannot change safe mode of the remote interpreter'
+ end
+
+ def safe?
+ _appsend(false, false, 'interp issafe')
+ end
+
+ def safe_base?
+ false
+ end
+
+ def allow_ruby_exit?
+ false
+ end
+
+ def allow_ruby_exit= (mode)
+ fail RuntimeError, 'cannot change mode of the remote interpreter'
+ end
+
+ def delete
+ _appsend(false, true, 'exit')
+ end
+
+ def deleted?
+ raise SecurityError, "no permission to manipulate" unless self.manipulable?
+
+ if @displayof
+ lst = @interp._invoke_without_enc('winfo', 'interps',
+ '-displayof', @displayof)
+ else
+ lst = @interp._invoke_without_enc('winfo', 'interps')
+ end
+ # unless @interp._split_tklist(lst).index(@remote)
+ unless @interp._split_tklist(lst).index(_toUTF8(@remote))
+ true
+ else
+ false
+ end
+ end
+
+ def has_mainwindow?
+ raise SecurityError, "no permission to manipulate" unless self.manipulable?
+
+ begin
+ inf = @interp._invoke_without_enc('info', 'command', '.')
+ rescue Exception
+ return nil
+ end
+ if !inf.kind_of?(String) || inf != '.'
+ false
+ else
+ true
+ end
+ end
+
+ def invalid_namespace?
+ false
+ end
+
+ def restart
+ fail RuntimeError, 'cannot restart the remote interpreter'
+ end
+
+ def __eval(str)
+ _appsend(false, false, str)
+ end
+ def _eval(str)
+ _appsend(nil, false, str)
+ end
+ def _eval_without_enc(str)
+ _appsend(false, false, str)
+ end
+ def _eval_with_enc(str)
+ _appsend(true, false, str)
+ end
+
+ def _invoke(*args)
+ _appsend(nil, false, *args)
+ end
+
+ def __invoke(*args)
+ _appsend(false, false, *args)
+ end
+ def _invoke(*args)
+ _appsend(nil, false, *args)
+ end
+ def _invoke_without_enc(*args)
+ _appsend(false, false, *args)
+ end
+ def _invoke_with_enc(*args)
+ _appsend(true, false, *args)
+ end
+
+ def _toUTF8(str, encoding=nil)
+ raise SecurityError, "no permission to manipulate" unless self.manipulable?
+ @interp._toUTF8(str, encoding)
+ end
+
+ def _fromUTF8(str, encoding=nil)
+ raise SecurityError, "no permission to manipulate" unless self.manipulable?
+ @interp._fromUTF8(str, encoding)
+ end
+
+ def _thread_vwait(var_name)
+ _appsend(false, 'thread_vwait', varname)
+ end
+
+ def _thread_tkwait(mode, target)
+ _appsend(false, 'thread_tkwait', mode, target)
+ end
+
+ def _return_value
+ raise SecurityError, "no permission to manipulate" unless self.manipulable?
+ @interp._return_value
+ end
+
+ def _get_variable(var_name, flag)
+ # ignore flag
+ _appsend(false, 'set', TkComm::_get_eval_string(var_name))
+ end
+ def _get_variable2(var_name, index_name, flag)
+ # ignore flag
+ _appsend(false, 'set', "#{TkComm::_get_eval_string(var_name)}(#{TkComm::_get_eval_string(index_name)})")
+ end
+
+ def _set_variable(var_name, value, flag)
+ # ignore flag
+ _appsend(false, 'set', TkComm::_get_eval_string(var_name), TkComm::_get_eval_string(value))
+ end
+ def _set_variable2(var_name, index_name, value, flag)
+ # ignore flag
+ _appsend(false, 'set', "#{TkComm::_get_eval_string(var_name)}(#{TkComm::_get_eval_string(index_name)})", TkComm::_get_eval_string(value))
+ end
+
+ def _unset_variable(var_name, flag)
+ # ignore flag
+ _appsend(false, 'unset', TkComm::_get_eval_string(var_name))
+ end
+ def _unset_variable2(var_name, index_name, flag)
+ # ignore flag
+ _appsend(false, 'unset', "#{var_name}(#{index_name})")
+ end
+
+ def _get_global_var(var_name)
+ _appsend(false, 'set', TkComm::_get_eval_string(var_name))
+ end
+ def _get_global_var2(var_name, index_name)
+ _appsend(false, 'set', "#{TkComm::_get_eval_string(var_name)}(#{TkComm::_get_eval_string(index_name)})")
+ end
+
+ def _set_global_var(var_name, value)
+ _appsend(false, 'set', TkComm::_get_eval_string(var_name), TkComm::_get_eval_string(value))
+ end
+ def _set_global_var2(var_name, index_name, value)
+ _appsend(false, 'set', "#{TkComm::_get_eval_string(var_name)}(#{TkComm::_get_eval_string(index_name)})", TkComm::_get_eval_string(value))
+ end
+
+ def _unset_global_var(var_name)
+ _appsend(false, 'unset', TkComm::_get_eval_string(var_name))
+ end
+ def _unset_global_var2(var_name, index_name)
+ _appsend(false, 'unset', "#{var_name}(#{index_name})")
+ end
+
+ def _split_tklist(str)
+ raise SecurityError, "no permission to manipulate" unless self.manipulable?
+ @interp._split_tklist(str)
+ end
+
+ def _merge_tklist(*args)
+ raise SecurityError, "no permission to manipulate" unless self.manipulable?
+ @interp._merge_tklist(*args)
+ end
+
+ def _conv_listelement(str)
+ raise SecurityError, "no permission to manipulate" unless self.manipulable?
+ @interp._conv_listelement(str)
+ end
+
+ def _create_console
+ fail RuntimeError, 'not support "_create_console" on the remote interpreter'
+ end
+
+ def mainloop
+ fail RuntimeError, 'not support "mainloop" on the remote interpreter'
+ end
+ def mainloop_watchdog
+ fail RuntimeError, 'not support "mainloop_watchdog" on the remote interpreter'
+ end
+ def do_one_event(flag = nil)
+ fail RuntimeError, 'not support "do_one_event" on the remote interpreter'
+ end
+ def mainloop_abort_on_exception
+ fail RuntimeError, 'not support "mainloop_abort_on_exception" on the remote interpreter'
+ end
+ def mainloop_abort_on_exception=(mode)
+ fail RuntimeError, 'not support "mainloop_abort_on_exception=" on the remote interpreter'
+ end
+ def set_eventloop_tick(*args)
+ fail RuntimeError, 'not support "set_eventloop_tick" on the remote interpreter'
+ end
+ def get_eventloop_tick
+ fail RuntimeError, 'not support "get_eventloop_tick" on the remote interpreter'
+ end
+ def set_no_event_wait(*args)
+ fail RuntimeError, 'not support "set_no_event_wait" on the remote interpreter'
+ end
+ def get_no_event_wait
+ fail RuntimeError, 'not support "get_no_event_wait" on the remote interpreter'
+ end
+ def set_eventloop_weight(*args)
+ fail RuntimeError, 'not support "set_eventloop_weight" on the remote interpreter'
+ end
+ def get_eventloop_weight
+ fail RuntimeError, 'not support "get_eventloop_weight" on the remote interpreter'
+ end
+end
+
+class << RemoteTkIp
+ def mainloop(*args)
+ fail RuntimeError, 'not support "mainloop" on the remote interpreter'
+ end
+ def mainloop_watchdog(*args)
+ fail RuntimeError, 'not support "mainloop_watchdog" on the remote interpreter'
+ end
+ def do_one_event(flag = nil)
+ fail RuntimeError, 'not support "do_one_event" on the remote interpreter'
+ end
+ def mainloop_abort_on_exception
+ fail RuntimeError, 'not support "mainloop_abort_on_exception" on the remote interpreter'
+ end
+ def mainloop_abort_on_exception=(mode)
+ fail RuntimeError, 'not support "mainloop_abort_on_exception=" on the remote interpreter'
+ end
+ def set_eventloop_tick(*args)
+ fail RuntimeError, 'not support "set_eventloop_tick" on the remote interpreter'
+ end
+ def get_eventloop_tick
+ fail RuntimeError, 'not support "get_eventloop_tick" on the remote interpreter'
+ end
+ def set_no_event_wait(*args)
+ fail RuntimeError, 'not support "set_no_event_wait" on the remote interpreter'
+ end
+ def get_no_event_wait
+ fail RuntimeError, 'not support "get_no_event_wait" on the remote interpreter'
+ end
+ def set_eventloop_weight(*args)
+ fail RuntimeError, 'not support "set_eventloop_weight" on the remote interpreter'
+ end
+ def get_eventloop_weight
+ fail RuntimeError, 'not support "get_eventloop_weight" on the remote interpreter'
+ end
+end
diff --git a/jni/ruby/ext/tk/lib/tcltk.rb b/jni/ruby/ext/tk/lib/tcltk.rb
new file mode 100644
index 0000000..f8fbdfb
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tcltk.rb
@@ -0,0 +1,367 @@
+# tof
+
+#### tcltk library, more direct manipulation of tcl/tk
+#### Sep. 5, 1997 Y. Shigehiro
+
+require "tcltklib"
+
+################
+
+# module TclTk: collection of tcl/tk utilities (supplies namespace.)
+module TclTk
+
+ # initialize Hash to hold unique symbols and such
+ @namecnt = {}
+
+ # initialize Hash to hold callbacks
+ @callback = {}
+end
+
+# TclTk.mainloop(): call TclTkLib.mainloop()
+def TclTk.mainloop()
+ print("mainloop: start\n") if $DEBUG
+ TclTkLib.mainloop()
+ print("mainloop: end\n") if $DEBUG
+end
+
+# TclTk.deletecallbackkey(ca): remove callback from TclTk module
+# this does not remove callbacks from tcl/tk interpreter
+# without calling this method, TclTkInterpreter will not be GCed
+# ca: callback(TclTkCallback)
+def TclTk.deletecallbackkey(ca)
+ print("deletecallbackkey: ", ca.to_s(), "\n") if $DEBUG
+ @callback.delete(ca.to_s)
+end
+
+# TclTk.dcb(ca, wid, W): call TclTk.deletecallbackkey() for each callbacks
+# in an array.
+# this is for callback for top-level <Destroy>
+# ca: array of callbacks(TclTkCallback)
+# wid: top-level widget(TclTkWidget)
+# w: information about window given by %W(String)
+def TclTk.dcb(ca, wid, w)
+ if wid.to_s() == w
+ ca.each{|i|
+ TclTk.deletecallbackkey(i)
+ }
+ end
+end
+
+# TclTk._addcallback(ca): register callback
+# ca: callback(TclTkCallback)
+def TclTk._addcallback(ca)
+ print("_addcallback: ", ca.to_s(), "\n") if $DEBUG
+ @callback[ca.to_s()] = ca
+end
+
+# TclTk._callcallback(key, arg): invoke registered callback
+# key: key to select callback (to_s value of the TclTkCallback)
+# arg: parameter from tcl/tk interpreter
+def TclTk._callcallback(key, arg)
+ print("_callcallback: ", @callback[key].inspect, "\n") if $DEBUG
+ @callback[key]._call(arg)
+ # throw out callback value
+ # should return String to satisfy rb_eval_string()
+ return ""
+end
+
+# TclTk._newname(prefix): generate unique name(String)
+# prefix: prefix of the unique name
+def TclTk._newname(prefix)
+ # generated name counter is stored in @namecnt
+ if !@namecnt.key?(prefix)
+ # first appearing prefix, initialize
+ @namecnt[prefix] = 1
+ else
+ # already appeared prefix, generate next name
+ @namecnt[prefix] += 1
+ end
+ return "#{prefix}#{@namecnt[prefix]}"
+end
+
+################
+
+# class TclTkInterpreter: tcl/tk interpreter
+class TclTkInterpreter
+
+ # initialize():
+ def initialize()
+ # generate interpreter object
+ @ip = TclTkIp.new()
+
+ # add ruby_fmt command to tcl interpreter
+ # ruby_fmt command format arguments by `format' and call `ruby' command
+ # (notice ruby command receives only one argument)
+ if $DEBUG
+ @ip._eval("proc ruby_fmt {fmt args} { puts \"ruby_fmt: $fmt $args\" ; set cmd [list ruby [format $fmt $args]] ; uplevel $cmd }")
+ else
+ @ip._eval("proc ruby_fmt {fmt args} { set cmd [list ruby [format $fmt $args]] ; uplevel $cmd }")
+ end
+
+ # @ip._get_eval_string(*args): generate string to evaluate in tcl interpreter
+ # *args: script which is going to be evaluated under tcl/tk
+ def @ip._get_eval_string(*args)
+ argstr = ""
+ args.each{|arg|
+ argstr += " " if argstr != ""
+ # call to_eval if it is defined
+ if (arg.respond_to?(:to_eval))
+ argstr += arg.to_eval()
+ else
+ # call to_s unless defined
+ argstr += arg.to_s()
+ end
+ }
+ return argstr
+ end
+
+ # @ip._eval_args(*args): evaluate string under tcl/tk interpreter
+ # returns result string.
+ # *args: script which is going to be evaluated under tcl/tk
+ def @ip._eval_args(*args)
+ # calculate the string to eval in the interpreter
+ argstr = _get_eval_string(*args)
+
+ # evaluate under the interpreter
+ print("_eval: \"", argstr, "\"") if $DEBUG
+ res = _eval(argstr)
+ if $DEBUG
+ print(" -> \"", res, "\"\n")
+ elsif _return_value() != 0
+ print(res, "\n")
+ end
+ fail(%Q/can't eval "#{argstr}"/) if _return_value() != 0 #'
+ return res
+ end
+
+ # generate tcl/tk command object and register in the hash
+ @commands = {}
+ # for all commands registered in tcl/tk interpreter:
+ @ip._eval("info command").split(/ /).each{|comname|
+ if comname =~ /^[.]/
+ # if command is a widget (path), generate TclTkWidget,
+ # and register it in the hash
+ @commands[comname] = TclTkWidget.new(@ip, comname)
+ else
+ # otherwise, generate TclTkCommand
+ @commands[comname] = TclTkCommand.new(@ip, comname)
+ end
+ }
+ end
+
+ # commands(): returns hash of the tcl/tk commands
+ def commands()
+ return @commands
+ end
+
+ # rootwidget(): returns root widget(TclTkWidget)
+ def rootwidget()
+ return @commands["."]
+ end
+
+ # _tcltkip(): returns @ip(TclTkIp)
+ def _tcltkip()
+ return @ip
+ end
+
+ # method_missing(id, *args): execute undefined method as tcl/tk command
+ # id: method symbol
+ # *args: method arguments
+ def method_missing(id, *args)
+ # if command named by id registered, then execute it
+ if @commands.key?(id.id2name)
+ return @commands[id.id2name].e(*args)
+ else
+ # otherwise, exception
+ super
+ end
+ end
+end
+
+# class TclTkObject: base class of the tcl/tk objects
+class TclTkObject
+
+ # initialize(ip, exp):
+ # ip: interpreter(TclTkIp)
+ # exp: tcl/tk representation
+ def initialize(ip, exp)
+ fail("type is not TclTkIp") if !ip.kind_of?(TclTkIp)
+ @ip = ip
+ @exp = exp
+ end
+
+ # to_s(): returns tcl/tk representation
+ def to_s()
+ return @exp
+ end
+end
+
+# class TclTkCommand: tcl/tk commands
+# you should not call TclTkCommand.new()
+# commands are created by TclTkInterpreter:initialize()
+class TclTkCommand < TclTkObject
+
+ # e(*args): execute command. returns String (e is for exec or eval)
+ # *args: command arguments
+ def e(*args)
+ return @ip._eval_args(to_s(), *args)
+ end
+end
+
+# class TclTkLibCommand: tcl/tk commands in the library
+class TclTkLibCommand < TclTkCommand
+
+ # initialize(ip, name):
+ # ip: interpreter(TclTkInterpreter)
+ # name: command name (String)
+ def initialize(ip, name)
+ super(ip._tcltkip, name)
+ end
+end
+
+# class TclTkVariable: tcl/tk variable
+class TclTkVariable < TclTkObject
+
+ # initialize(interp, dat):
+ # interp: interpreter(TclTkInterpreter)
+ # dat: the value to set(String)
+ # if nil, not initialize variable
+ def initialize(interp, dat)
+ # auto-generate tcl/tk representation (variable name)
+ exp = TclTk._newname("v_")
+ # initialize TclTkObject
+ super(interp._tcltkip(), exp)
+ # safe this for `set' command
+ @set = interp.commands()["set"]
+ # set value
+ set(dat) if dat
+ end
+
+ # although you can set/read variables by using set in tcl/tk,
+ # we provide the method for accessing variables
+
+ # set(data): set tcl/tk variable using `set'
+ # data: new value
+ def set(data)
+ @set.e(to_s(), data.to_s())
+ end
+
+ # get(): read tcl/tk variable(String) using `set'
+ def get()
+ return @set.e(to_s())
+ end
+end
+
+# class TclTkWidget: tcl/tk widget
+class TclTkWidget < TclTkCommand
+
+ # initialize(*args):
+ # *args: parameters
+ def initialize(*args)
+ if args[0].kind_of?(TclTkIp)
+ # in case the 1st argument is TclTkIp:
+
+ # Wrap tcl/tk widget by TclTkWidget
+ # (used in TclTkInterpreter#initialize())
+
+ # need two arguments
+ fail("invalid # of parameter") if args.size != 2
+
+ # ip: interpreter(TclTkIp)
+ # exp: tcl/tk representation
+ ip, exp = args
+
+ # initialize TclTkObject
+ super(ip, exp)
+ elsif args[0].kind_of?(TclTkInterpreter)
+ # in case 1st parameter is TclTkInterpreter:
+
+ # generate new widget from parent widget
+
+ # interp: interpreter(TclTkInterpreter)
+ # parent: parent widget
+ # command: widget generating tk command(label ç­‰)
+ # *args: argument to the command
+ interp, parent, command, *args = args
+
+ # generate widget name
+ exp = parent.to_s()
+ exp += "." if exp !~ /[.]$/
+ exp += TclTk._newname("w_")
+ # initialize TclTkObject
+ super(interp._tcltkip(), exp)
+ # generate widget
+ res = @ip._eval_args(command, exp, *args)
+# fail("can't create Widget") if res != exp
+ # for tk_optionMenu, it is legal res != exp
+ else
+ fail("first parameter is not TclTkInterpreter")
+ end
+ end
+end
+
+# class TclTkCallback: tcl/tk callbacks
+class TclTkCallback < TclTkObject
+
+ # initialize(interp, pr, arg):
+ # interp: interpreter(TclTkInterpreter)
+ # pr: callback procedure(Proc)
+ # arg: string to pass as block parameters of pr
+ # bind command of tcl/tk uses % replacement for parameters
+ # pr can receive replaced data using block parameter
+ # its format is specified by arg string
+ # You should not specify arg for the command like
+ # scrollbar with -command option, which receives parameters
+ # without specifying any replacement
+ def initialize(interp, pr, arg = nil)
+ # auto-generate tcl/tk representation (variable name)
+ exp = TclTk._newname("c_")
+ # initialize TclTkObject
+ super(interp._tcltkip(), exp)
+ # save parameters
+ @pr = pr
+ @arg = arg
+ # register in the module
+ TclTk._addcallback(self)
+ end
+
+ # to_eval(): returns string representation for @ip._eval_args
+ def to_eval()
+ if @arg
+ # bind replaces %s before calling ruby_fmt, so %%s is used
+ s = %Q/{ruby_fmt {TclTk._callcallback("#{to_s()}", "%%s")} #{@arg}}/
+ else
+ s = %Q/{ruby_fmt {TclTk._callcallback("#{to_s()}", "%s")}}/
+ end
+
+ return s
+ end
+
+ # _call(arg): invoke callback
+ # arg: callback parameter
+ def _call(arg)
+ @pr.call(arg)
+ end
+end
+
+# class TclTkImage: tcl/tk images
+class TclTkImage < TclTkCommand
+
+ # initialize(interp, t, *args):
+ # generating image is done by TclTkImage.new()
+ # destroying is done by image delete (inconsistent, sigh)
+ # interp: interpreter(TclTkInterpreter)
+ # t: image type (photo, bitmap, etc.)
+ # *args: command argument
+ def initialize(interp, t, *args)
+ # auto-generate tcl/tk representation
+ exp = TclTk._newname("i_")
+ # initialize TclTkObject
+ super(interp._tcltkip(), exp)
+ # generate image
+ res = @ip._eval_args("image create", t, exp, *args)
+ fail("can't create Image") if res != exp
+ end
+end
+
+# eof
diff --git a/jni/ruby/ext/tk/lib/tk.rb b/jni/ruby/ext/tk/lib/tk.rb
new file mode 100644
index 0000000..45f86a9
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tk.rb
@@ -0,0 +1,5775 @@
+#
+# tk.rb - Tk interface module using tcltklib
+# by Yukihiro Matsumoto <matz@netlab.jp>
+
+# use Shigehiro's tcltklib
+require 'tcltklib'
+require 'tkutil'
+
+# autoload
+require 'tk/autoload'
+
+# for Mutex
+require 'thread'
+
+class TclTkIp
+ # backup original (without encoding) _eval and _invoke
+ alias _eval_without_enc _eval
+ alias __eval__ _eval
+ alias _invoke_without_enc _invoke
+ alias __invoke__ _invoke
+
+ def _ip_id_
+ # for RemoteTkIp
+ ''
+ end
+
+ alias __initialize__ initialize
+ private :__initialize__
+
+ def initialize(*args)
+ __initialize__(*args)
+
+ @force_default_encoding ||= TkUtil.untrust([false])
+ @encoding ||= TkUtil.untrust([nil])
+ def @encoding.to_s; self.join(nil); end
+ end
+end
+
+# define TkComm module (step 1: basic functions)
+module TkComm
+ include TkUtil
+ extend TkUtil
+
+ WidgetClassNames = TkUtil.untrust({})
+ TkExtlibAutoloadModule = TkUtil.untrust([])
+
+ # None = Object.new ### --> definition is moved to TkUtil module
+ # def None.to_s
+ # 'None'
+ # end
+ # None.freeze
+
+ #Tk_CMDTBL = {}
+ #Tk_WINDOWS = {}
+ Tk_IDs = [
+ TkUtil.untrust("00000"), # [0]-cmdid
+ TkUtil.untrust("00000") # [1]-winid
+ ]
+ Tk_IDs.instance_eval{
+ @mutex = Mutex.new
+ def mutex; @mutex; end
+ freeze
+ }
+
+ # for backward compatibility
+ Tk_CMDTBL = Object.new
+ def Tk_CMDTBL.method_missing(id, *args)
+ TkCore::INTERP.tk_cmd_tbl.__send__(id, *args)
+ end
+ Tk_CMDTBL.freeze
+ Tk_WINDOWS = Object.new
+ def Tk_WINDOWS.method_missing(id, *args)
+ TkCore::INTERP.tk_windows.__send__(id, *args)
+ end
+ Tk_WINDOWS.freeze
+
+ self.instance_eval{
+ @cmdtbl = TkUtil.untrust([])
+ }
+
+ unless const_defined?(:GET_CONFIGINFO_AS_ARRAY)
+ # GET_CONFIGINFO_AS_ARRAY = false => returns a Hash { opt =>val, ... }
+ # true => returns an Array [[opt,val], ... ]
+ # val is a list which includes resource info.
+ GET_CONFIGINFO_AS_ARRAY = true
+ end
+ unless const_defined?(:GET_CONFIGINFOwoRES_AS_ARRAY)
+ # for configinfo without resource info; list of [opt, value] pair
+ # false => returns a Hash { opt=>val, ... }
+ # true => returns an Array [[opt,val], ... ]
+ GET_CONFIGINFOwoRES_AS_ARRAY = true
+ end
+ # *** ATTENTION ***
+ # 'current_configinfo' method always returns a Hash under all cases of above.
+
+ def error_at
+ frames = caller()
+ frames.delete_if do |c|
+ c =~ %r!/tk(|core|thcore|canvas|text|entry|scrollbox)\.rb:\d+!
+ end
+ frames
+ end
+ private :error_at
+
+ def _genobj_for_tkwidget(path)
+ return TkRoot.new if path == '.'
+
+ begin
+ #tk_class = TkCore::INTERP._invoke('winfo', 'class', path)
+ tk_class = Tk.ip_invoke_without_enc('winfo', 'class', path)
+ rescue
+ return path
+ end
+
+ if ruby_class = WidgetClassNames[tk_class]
+ ruby_class_name = ruby_class.name
+ # gen_class_name = ruby_class_name + 'GeneratedOnTk'
+ gen_class_name = ruby_class_name
+ classname_def = ''
+ else # ruby_class == nil
+ if Tk.const_defined?(tk_class)
+ Tk.const_get(tk_class) # auto_load
+ ruby_class = WidgetClassNames[tk_class]
+ end
+
+ unless ruby_class
+ mods = TkExtlibAutoloadModule.find_all{|m| m.const_defined?(tk_class)}
+ mods.each{|mod|
+ begin
+ mod.const_get(tk_class) # auto_load
+ break if (ruby_class = WidgetClassNames[tk_class])
+ rescue LoadError
+ # ignore load error
+ end
+ }
+ end
+
+ unless ruby_class
+ std_class = 'Tk' << tk_class
+ if Object.const_defined?(std_class)
+ Object.const_get(std_class) # auto_load
+ ruby_class = WidgetClassNames[tk_class]
+ end
+ end
+
+ unless ruby_class
+ if Tk.const_defined?('TOPLEVEL_ALIASES') &&
+ Tk::TOPLEVEL_ALIASES.const_defined?(std_class)
+ Tk::TOPLEVEL_ALIASES.const_get(std_class) # auto_load
+ ruby_class = WidgetClassNames[tk_class]
+ end
+ end
+
+ if ruby_class
+ # found
+ ruby_class_name = ruby_class.name
+ gen_class_name = ruby_class_name
+ classname_def = ''
+ else
+ # unknown
+ ruby_class_name = 'TkWindow'
+ gen_class_name = 'TkWidget_' + tk_class
+ classname_def = "WidgetClassName = '#{tk_class}'.freeze"
+ end
+ end
+
+###################################
+=begin
+ if ruby_class = WidgetClassNames[tk_class]
+ ruby_class_name = ruby_class.name
+ # gen_class_name = ruby_class_name + 'GeneratedOnTk'
+ gen_class_name = ruby_class_name
+ classname_def = ''
+ else
+ mod = TkExtlibAutoloadModule.find{|m| m.const_defined?(tk_class)}
+ if mod
+ ruby_class_name = mod.name + '::' + tk_class
+ gen_class_name = ruby_class_name
+ classname_def = ''
+ elsif Object.const_defined?('Tk' + tk_class)
+ ruby_class_name = 'Tk' + tk_class
+ # gen_class_name = ruby_class_name + 'GeneratedOnTk'
+ gen_class_name = ruby_class_name
+ classname_def = ''
+ else
+ ruby_class_name = 'TkWindow'
+ # gen_class_name = ruby_class_name + tk_class + 'GeneratedOnTk'
+ gen_class_name = 'TkWidget_' + tk_class
+ classname_def = "WidgetClassName = '#{tk_class}'.freeze"
+ end
+ end
+=end
+
+=begin
+ unless Object.const_defined? gen_class_name
+ Object.class_eval "class #{gen_class_name}<#{ruby_class_name}
+ #{classname_def}
+ end"
+ end
+ Object.class_eval "#{gen_class_name}.new('widgetname'=>'#{path}',
+ 'without_creating'=>true)"
+=end
+ base = Object
+ gen_class_name.split('::').each{|klass|
+ next if klass == ''
+ if base.const_defined?(klass)
+ base = base.class_eval klass
+ else
+ base = base.class_eval "class #{klass}<#{ruby_class_name}
+ #{classname_def}
+ end
+ #{klass}"
+ end
+ }
+ base.class_eval "#{gen_class_name}.new('widgetname'=>'#{path}',
+ 'without_creating'=>true)"
+ end
+ private :_genobj_for_tkwidget
+ module_function :_genobj_for_tkwidget
+
+ def _at(x,y=nil)
+ if y
+ "@#{Integer(x)},#{Integer(y)}"
+ else
+ "@#{Integer(x)}"
+ end
+ end
+ module_function :_at
+
+ def tk_tcl2ruby(val, enc_mode = false, listobj = true)
+=begin
+ if val =~ /^rb_out\S* (c(_\d+_)?\d+)/
+ #return Tk_CMDTBL[$1]
+ return TkCore::INTERP.tk_cmd_tbl[$1]
+ #cmd_obj = TkCore::INTERP.tk_cmd_tbl[$1]
+ #if cmd_obj.kind_of?(Proc) || cmd_obj.kind_of?(Method)
+ # cmd_obj
+ #else
+ # cmd_obj.cmd
+ #end
+ end
+=end
+ if val =~ /rb_out\S*(?:\s+(::\S*|[{](::.*)[}]|["](::.*)["]))? (c(_\d+_)?(\d+))/
+ return TkCore::INTERP.tk_cmd_tbl[$4]
+ end
+ #if val.include? ?\s
+ # return val.split.collect{|v| tk_tcl2ruby(v)}
+ #end
+ case val
+ when /\A@font\S+\z/
+ TkFont.get_obj(val)
+ when /\A-?\d+\z/
+ val.to_i
+ when /\A\.\S*\z/
+ #Tk_WINDOWS[val] ? Tk_WINDOWS[val] : _genobj_for_tkwidget(val)
+ TkCore::INTERP.tk_windows[val]?
+ TkCore::INTERP.tk_windows[val] : _genobj_for_tkwidget(val)
+ when /\Ai(_\d+_)?\d+\z/
+ TkImage::Tk_IMGTBL.mutex.synchronize{
+ TkImage::Tk_IMGTBL[val]? TkImage::Tk_IMGTBL[val] : val
+ }
+ when /\A-?\d+\.?\d*(e[-+]?\d+)?\z/
+ val.to_f
+ when /\\ /
+ val.gsub(/\\ /, ' ')
+ when /[^\\] /
+ if listobj
+ #tk_split_escstr(val).collect{|elt|
+ # tk_tcl2ruby(elt, enc_mode, listobj)
+ #}
+ val = _toUTF8(val) unless enc_mode
+ tk_split_escstr(val, false, false).collect{|elt|
+ tk_tcl2ruby(elt, true, listobj)
+ }
+ elsif enc_mode
+ _fromUTF8(val)
+ else
+ val
+ end
+ else
+ if enc_mode
+ _fromUTF8(val)
+ else
+ val
+ end
+ end
+ end
+
+ private :tk_tcl2ruby
+ module_function :tk_tcl2ruby
+ #private_class_method :tk_tcl2ruby
+
+unless const_defined?(:USE_TCLs_LIST_FUNCTIONS)
+ USE_TCLs_LIST_FUNCTIONS = true
+end
+
+if USE_TCLs_LIST_FUNCTIONS
+ ###########################################################################
+ # use Tcl function version of split_list
+ ###########################################################################
+
+ def tk_split_escstr(str, src_enc=true, dst_enc=true)
+ str = _toUTF8(str) if src_enc
+ if dst_enc
+ TkCore::INTERP._split_tklist(str).map!{|s| _fromUTF8(s)}
+ else
+ TkCore::INTERP._split_tklist(str)
+ end
+ end
+
+ def tk_split_sublist(str, depth=-1, src_enc=true, dst_enc=true)
+ # return [] if str == ""
+ # list = TkCore::INTERP._split_tklist(str)
+ str = _toUTF8(str) if src_enc
+
+ if depth == 0
+ return "" if str == ""
+ list = [str]
+ else
+ return [] if str == ""
+ list = TkCore::INTERP._split_tklist(str)
+ end
+ if list.size == 1
+ # tk_tcl2ruby(list[0], nil, false)
+ tk_tcl2ruby(list[0], dst_enc, false)
+ else
+ list.collect{|token| tk_split_sublist(token, depth - 1, false, dst_enc)}
+ end
+ end
+
+ def tk_split_list(str, depth=0, src_enc=true, dst_enc=true)
+ return [] if str == ""
+ str = _toUTF8(str) if src_enc
+ TkCore::INTERP._split_tklist(str).map!{|token|
+ tk_split_sublist(token, depth - 1, false, dst_enc)
+ }
+ end
+
+ def tk_split_simplelist(str, src_enc=true, dst_enc=true)
+ #lst = TkCore::INTERP._split_tklist(str)
+ #if (lst.size == 1 && lst =~ /^\{.*\}$/)
+ # TkCore::INTERP._split_tklist(str[1..-2])
+ #else
+ # lst
+ #end
+
+ str = _toUTF8(str) if src_enc
+ if dst_enc
+ TkCore::INTERP._split_tklist(str).map!{|s| _fromUTF8(s)}
+ else
+ TkCore::INTERP._split_tklist(str)
+ end
+ end
+
+ def array2tk_list(ary, enc=nil)
+ return "" if ary.size == 0
+
+ sys_enc = TkCore::INTERP.encoding
+ sys_enc = TclTkLib.encoding_system unless sys_enc
+
+ dst_enc = (enc == nil)? sys_enc: enc
+
+ dst = ary.collect{|e|
+ if e.kind_of? Array
+ s = array2tk_list(e, enc)
+ elsif e.kind_of? Hash
+ tmp_ary = []
+ #e.each{|k,v| tmp_ary << k << v }
+ e.each{|k,v| tmp_ary << "-#{_get_eval_string(k)}" << v }
+ s = array2tk_list(tmp_ary, enc)
+ else
+ s = _get_eval_string(e, enc)
+ end
+
+ if dst_enc != true && dst_enc != false
+ if (s_enc = s.instance_variable_get(:@encoding))
+ s_enc = s_enc.to_s
+ elsif TkCore::WITH_ENCODING
+ s_enc = s.encoding.name
+ else
+ s_enc = sys_enc
+ end
+ dst_enc = true if s_enc != dst_enc
+ end
+
+ s
+ }
+
+ if sys_enc && dst_enc
+ dst.map!{|s| _toUTF8(s)}
+ ret = TkCore::INTERP._merge_tklist(*dst)
+ if TkCore::WITH_ENCODING
+ if dst_enc.kind_of?(String)
+ ret = _fromUTF8(ret, dst_enc)
+ ret.force_encoding(dst_enc)
+ else
+ ret.force_encoding('utf-8')
+ end
+ else # without encoding
+ if dst_enc.kind_of?(String)
+ ret = _fromUTF8(ret, dst_enc)
+ ret.instance_variable_set(:@encoding, dst_enc)
+ else
+ ret.instance_variable_set(:@encoding, 'utf-8')
+ end
+ end
+ ret
+ else
+ TkCore::INTERP._merge_tklist(*dst)
+ end
+ end
+
+else
+ ###########################################################################
+ # use Ruby script version of split_list (traditional methods)
+ ###########################################################################
+
+ def tk_split_escstr(str, src_enc=true, dst_enc=true)
+ return [] if str == ""
+ list = []
+ token = nil
+ escape = false
+ brace = 0
+ str.split('').each {|c|
+ brace += 1 if c == '{' && !escape
+ brace -= 1 if c == '}' && !escape
+ if brace == 0 && c == ' ' && !escape
+ list << token.gsub(/^\{(.*)\}$/, '\1') if token
+ token = nil
+ else
+ token = (token || "") << c
+ end
+ escape = (c == '\\' && !escape)
+ }
+ list << token.gsub(/^\{(.*)\}$/, '\1') if token
+ list
+ end
+
+ def tk_split_sublist(str, depth=-1, src_enc=true, dst_enc=true)
+ #return [] if str == ""
+ #return [tk_split_sublist(str[1..-2])] if str =~ /^\{.*\}$/
+ #list = tk_split_escstr(str)
+ if depth == 0
+ return "" if str == ""
+ str = str[1..-2] if str =~ /^\{.*\}$/
+ list = [str]
+ else
+ return [] if str == []
+ return [tk_split_sublist(str[1..-2], depth - 1)] if str =~ /^\{.*\}$/
+ list = tk_split_escstr(str)
+ end
+ if list.size == 1
+ tk_tcl2ruby(list[0], nil, false)
+ else
+ list.collect{|token| tk_split_sublist(token, depth - 1)}
+ end
+ end
+
+ def tk_split_list(str, depth=0, src_enc=true, dst_enc=true)
+ return [] if str == ""
+ tk_split_escstr(str).collect{|token|
+ tk_split_sublist(token, depth - 1)
+ }
+ end
+
+ def tk_split_simplelist(str, src_enc=true, dst_enc=true)
+ return [] if str == ""
+ list = []
+ token = nil
+ escape = false
+ brace = 0
+ str.split('').each {|c|
+ if c == '\\' && !escape
+ escape = true
+ token = (token || "") << c if brace > 0
+ next
+ end
+ brace += 1 if c == '{' && !escape
+ brace -= 1 if c == '}' && !escape
+ if brace == 0 && c == ' ' && !escape
+ list << token.gsub(/^\{(.*)\}$/, '\1') if token
+ token = nil
+ else
+ token = (token || "") << c
+ end
+ escape = false
+ }
+ list << token.gsub(/^\{(.*)\}$/, '\1') if token
+ list
+ end
+
+ def array2tk_list(ary, enc=nil)
+ ary.collect{|e|
+ if e.kind_of? Array
+ "{#{array2tk_list(e, enc)}}"
+ elsif e.kind_of? Hash
+ # "{#{e.to_a.collect{|ee| array2tk_list(ee)}.join(' ')}}"
+ e.each{|k,v| tmp_ary << "-#{_get_eval_string(k)}" << v }
+ array2tk_list(tmp_ary, enc)
+ else
+ s = _get_eval_string(e, enc)
+ (s.index(/\s/) || s.size == 0)? "{#{s}}": s
+ end
+ }.join(" ")
+ end
+end
+
+ private :tk_split_escstr, :tk_split_sublist
+ private :tk_split_list, :tk_split_simplelist
+ private :array2tk_list
+
+ module_function :tk_split_escstr, :tk_split_sublist
+ module_function :tk_split_list, :tk_split_simplelist
+ module_function :array2tk_list
+
+ private_class_method :tk_split_escstr, :tk_split_sublist
+ private_class_method :tk_split_list, :tk_split_simplelist
+# private_class_method :array2tk_list
+
+=begin
+ ### --> definition is moved to TkUtil module
+ def _symbolkey2str(keys)
+ h = {}
+ keys.each{|key,value| h[key.to_s] = value}
+ h
+ end
+ private :_symbolkey2str
+ module_function :_symbolkey2str
+=end
+
+=begin
+ ### --> definition is moved to TkUtil module
+ # def hash_kv(keys, enc_mode = nil, conf = [], flat = false)
+ def hash_kv(keys, enc_mode = nil, conf = nil)
+ # Hash {key=>val, key=>val, ... } or Array [ [key, val], [key, val], ... ]
+ # ==> Array ['-key', val, '-key', val, ... ]
+ dst = []
+ if keys and keys != None
+ keys.each{|k, v|
+ #dst.push("-#{k}")
+ dst.push('-' + k.to_s)
+ if v != None
+ # v = _get_eval_string(v, enc_mode) if (enc_mode || flat)
+ v = _get_eval_string(v, enc_mode) if enc_mode
+ dst.push(v)
+ end
+ }
+ end
+ if conf
+ conf + dst
+ else
+ dst
+ end
+ end
+ private :hash_kv
+ module_function :hash_kv
+=end
+
+=begin
+ ### --> definition is moved to TkUtil module
+ def bool(val)
+ case val
+ when "1", 1, 'yes', 'true'
+ true
+ else
+ false
+ end
+ end
+
+ def number(val)
+ case val
+ when /^-?\d+$/
+ val.to_i
+ when /^-?\d+\.?\d*(e[-+]?\d+)?$/
+ val.to_f
+ else
+ fail(ArgumentError, "invalid value for Number:'#{val}'")
+ end
+ end
+ def string(val)
+ if val == "{}"
+ ''
+ elsif val[0] == ?{ && val[-1] == ?}
+ val[1..-2]
+ else
+ val
+ end
+ end
+ def num_or_str(val)
+ begin
+ number(val)
+ rescue ArgumentError
+ string(val)
+ end
+ end
+=end
+
+ def list(val, depth=0, enc=true)
+ tk_split_list(val, depth, enc, enc)
+ end
+ def simplelist(val, src_enc=true, dst_enc=true)
+ tk_split_simplelist(val, src_enc, dst_enc)
+ end
+ def window(val)
+ if val =~ /^\./
+ #Tk_WINDOWS[val]? Tk_WINDOWS[val] : _genobj_for_tkwidget(val)
+ TkCore::INTERP.tk_windows[val]?
+ TkCore::INTERP.tk_windows[val] : _genobj_for_tkwidget(val)
+ else
+ nil
+ end
+ end
+ def image_obj(val)
+ if val =~ /^i(_\d+_)?\d+$/
+ TkImage::Tk_IMGTBL.mutex.synchronize{
+ TkImage::Tk_IMGTBL[val]? TkImage::Tk_IMGTBL[val] : val
+ }
+ else
+ val
+ end
+ end
+ def procedure(val)
+=begin
+ if val =~ /^rb_out\S* (c(_\d+_)?\d+)/
+ #Tk_CMDTBL[$1]
+ #TkCore::INTERP.tk_cmd_tbl[$1]
+ TkCore::INTERP.tk_cmd_tbl[$1].cmd
+=end
+ if val =~ /rb_out\S*(?:\s+(::\S*|[{](::.*)[}]|["](::.*)["]))? (c(_\d+_)?(\d+))/
+ return TkCore::INTERP.tk_cmd_tbl[$4].cmd
+ else
+ #nil
+ val
+ end
+ end
+ private :bool, :number, :num_or_str, :num_or_nil, :string
+ private :list, :simplelist, :window, :image_obj, :procedure
+ module_function :bool, :number, :num_or_str, :num_or_nil, :string
+ module_function :list, :simplelist, :window, :image_obj, :procedure
+
+ if (RUBY_VERSION.split('.').map{|n| n.to_i} <=> [1,8,7]) < 0
+ def slice_ary(ary, size)
+ sliced = []
+ wk_ary = ary.dup
+ until wk_ary.size.zero?
+ sub_ary = []
+ size.times{ sub_ary << wk_ary.shift }
+ yield(sub_ary) if block_given?
+ sliced << sub_ary
+ end
+ (block_given?)? ary: sliced
+ end
+ else
+ def slice_ary(ary, size, &b)
+ if b
+ ary.each_slice(size, &b)
+ else
+ ary.each_slice(size).to_a
+ end
+ end
+ end
+ private :slice_ary
+ module_function :slice_ary
+
+ def subst(str, *opts)
+ # opts := :nobackslashes | :nocommands | novariables
+ tk_call('subst',
+ *(opts.collect{|opt|
+ opt = opt.to_s
+ (opt[0] == ?-)? opt: '-' << opt
+ } << str))
+ end
+
+ def _toUTF8(str, encoding = nil)
+ TkCore::INTERP._toUTF8(str, encoding)
+ end
+ def _fromUTF8(str, encoding = nil)
+ TkCore::INTERP._fromUTF8(str, encoding)
+ end
+ private :_toUTF8, :_fromUTF8
+ module_function :_toUTF8, :_fromUTF8
+
+ def _callback_entry_class?(cls)
+ cls <= Proc || cls <= Method || cls <= TkCallbackEntry
+ end
+ private :_callback_entry_class?
+ module_function :_callback_entry_class?
+
+ def _callback_entry?(obj)
+ obj.kind_of?(Proc) || obj.kind_of?(Method) || obj.kind_of?(TkCallbackEntry)
+ end
+ private :_callback_entry?
+ module_function :_callback_entry?
+
+=begin
+ ### --> definition is moved to TkUtil module
+ def _get_eval_string(str, enc_mode = nil)
+ return nil if str == None
+ if str.kind_of?(TkObject)
+ str = str.path
+ elsif str.kind_of?(String)
+ str = _toUTF8(str) if enc_mode
+ elsif str.kind_of?(Symbol)
+ str = str.id2name
+ str = _toUTF8(str) if enc_mode
+ elsif str.kind_of?(Hash)
+ str = hash_kv(str, enc_mode).join(" ")
+ elsif str.kind_of?(Array)
+ str = array2tk_list(str)
+ str = _toUTF8(str) if enc_mode
+ elsif str.kind_of?(Proc)
+ str = install_cmd(str)
+ elsif str == nil
+ str = ""
+ elsif str == false
+ str = "0"
+ elsif str == true
+ str = "1"
+ elsif (str.respond_to?(:to_eval))
+ str = str.to_eval()
+ str = _toUTF8(str) if enc_mode
+ else
+ str = str.to_s() || ''
+ unless str.kind_of? String
+ fail RuntimeError, "fail to convert the object to a string"
+ end
+ str = _toUTF8(str) if enc_mode
+ end
+ return str
+ end
+=end
+=begin
+ def _get_eval_string(obj, enc_mode = nil)
+ case obj
+ when Numeric
+ obj.to_s
+ when String
+ (enc_mode)? _toUTF8(obj): obj
+ when Symbol
+ (enc_mode)? _toUTF8(obj.id2name): obj.id2name
+ when TkObject
+ obj.path
+ when Hash
+ hash_kv(obj, enc_mode).join(' ')
+ when Array
+ (enc_mode)? _toUTF8(array2tk_list(obj)): array2tk_list(obj)
+ when Proc, Method, TkCallbackEntry
+ install_cmd(obj)
+ when false
+ '0'
+ when true
+ '1'
+ when nil
+ ''
+ when None
+ nil
+ else
+ if (obj.respond_to?(:to_eval))
+ (enc_mode)? _toUTF8(obj.to_eval): obj.to_eval
+ else
+ begin
+ obj = obj.to_s || ''
+ rescue
+ fail RuntimeError, "fail to convert object '#{obj}' to string"
+ end
+ (enc_mode)? _toUTF8(obj): obj
+ end
+ end
+ end
+ private :_get_eval_string
+ module_function :_get_eval_string
+=end
+
+=begin
+ ### --> definition is moved to TkUtil module
+ def _get_eval_enc_str(obj)
+ return obj if obj == None
+ _get_eval_string(obj, true)
+ end
+ private :_get_eval_enc_str
+ module_function :_get_eval_enc_str
+=end
+
+=begin
+ ### --> obsolete
+ def ruby2tcl(v, enc_mode = nil)
+ if v.kind_of?(Hash)
+ v = hash_kv(v)
+ v.flatten!
+ v.collect{|e|ruby2tcl(e, enc_mode)}
+ else
+ _get_eval_string(v, enc_mode)
+ end
+ end
+ private :ruby2tcl
+=end
+
+=begin
+ ### --> definition is moved to TkUtil module
+ def _conv_args(args, enc_mode, *src_args)
+ conv_args = []
+ src_args.each{|arg|
+ conv_args << _get_eval_string(arg, enc_mode) unless arg == None
+ # if arg.kind_of?(Hash)
+ # arg.each{|k, v|
+ # args << '-' + k.to_s
+ # args << _get_eval_string(v, enc_mode)
+ # }
+ # elsif arg != None
+ # args << _get_eval_string(arg, enc_mode)
+ # end
+ }
+ args + conv_args
+ end
+ private :_conv_args
+=end
+
+ def _curr_cmd_id
+ #id = format("c%.4d", Tk_IDs[0])
+ id = "c" + TkCore::INTERP._ip_id_ + TkComm::Tk_IDs[0]
+ end
+ def _next_cmd_id
+ TkComm::Tk_IDs.mutex.synchronize{
+ id = _curr_cmd_id
+ #Tk_IDs[0] += 1
+ TkComm::Tk_IDs[0].succ!
+ id
+ }
+ end
+ private :_curr_cmd_id, :_next_cmd_id
+ module_function :_curr_cmd_id, :_next_cmd_id
+
+ def TkComm.install_cmd(cmd, local_cmdtbl=nil)
+ return '' if cmd == ''
+ begin
+ ns = TkCore::INTERP._invoke_without_enc('namespace', 'current')
+ ns = nil if ns == '::' # for backward compatibility
+ rescue
+ # probably, Tcl7.6
+ ns = nil
+ end
+ id = _next_cmd_id
+ #Tk_CMDTBL[id] = cmd
+ if cmd.kind_of?(TkCallbackEntry)
+ TkCore::INTERP.tk_cmd_tbl[id] = cmd
+ else
+ TkCore::INTERP.tk_cmd_tbl[id] = TkCore::INTERP.get_cb_entry(cmd)
+ end
+ @cmdtbl = [] unless defined? @cmdtbl
+ TkUtil.untrust(@cmdtbl) unless @cmdtbl.tainted?
+ @cmdtbl.push id
+
+ if local_cmdtbl && local_cmdtbl.kind_of?(Array)
+ begin
+ local_cmdtbl << id
+ rescue Exception
+ # ignore
+ end
+ end
+
+ #return Kernel.format("rb_out %s", id);
+ if ns
+ 'rb_out' << TkCore::INTERP._ip_id_ << ' ' << ns << ' ' << id
+ else
+ 'rb_out' << TkCore::INTERP._ip_id_ << ' ' << id
+ end
+ end
+ def TkComm.uninstall_cmd(id, local_cmdtbl=nil)
+ #id = $1 if /rb_out\S* (c(_\d+_)?\d+)/ =~ id
+ id = $4 if id =~ /rb_out\S*(?:\s+(::\S*|[{](::.*)[}]|["](::.*)["]))? (c(_\d+_)?(\d+))/
+
+ if local_cmdtbl && local_cmdtbl.kind_of?(Array)
+ begin
+ local_cmdtbl.delete(id)
+ rescue Exception
+ # ignore
+ end
+ end
+ @cmdtbl.delete(id)
+
+ #Tk_CMDTBL.delete(id)
+ TkCore::INTERP.tk_cmd_tbl.delete(id)
+ end
+ # private :install_cmd, :uninstall_cmd
+ # module_function :install_cmd, :uninstall_cmd
+ def install_cmd(cmd)
+ TkComm.install_cmd(cmd, @cmdtbl)
+ end
+ def uninstall_cmd(id)
+ TkComm.uninstall_cmd(id, @cmdtbl)
+ end
+
+=begin
+ def install_win(ppath,name=nil)
+ if !name or name == ''
+ #name = format("w%.4d", Tk_IDs[1])
+ #Tk_IDs[1] += 1
+ name = "w" + Tk_IDs[1]
+ Tk_IDs[1].succ!
+ end
+ if name[0] == ?.
+ @path = name.dup
+ elsif !ppath or ppath == "."
+ @path = Kernel.format(".%s", name);
+ else
+ @path = Kernel.format("%s.%s", ppath, name)
+ end
+ #Tk_WINDOWS[@path] = self
+ TkCore::INTERP.tk_windows[@path] = self
+ end
+=end
+ def install_win(ppath,name=nil)
+ if name
+ if name == ''
+ raise ArgumentError, "invalid wiget-name '#{name}'"
+ end
+ if name[0] == ?.
+ @path = '' + name
+ @path.freeze
+ return TkCore::INTERP.tk_windows[@path] = self
+ end
+ else
+ Tk_IDs.mutex.synchronize{
+ name = "w" + TkCore::INTERP._ip_id_ + Tk_IDs[1]
+ Tk_IDs[1].succ!
+ }
+ end
+ if !ppath or ppath == '.'
+ @path = '.' + name
+ else
+ @path = ppath + '.' + name
+ end
+ @path.freeze
+ TkCore::INTERP.tk_windows[@path] = self
+ end
+
+ def uninstall_win()
+ #Tk_WINDOWS.delete(@path)
+ TkCore::INTERP.tk_windows.delete(@path)
+ end
+ private :install_win, :uninstall_win
+
+ def _epath(win)
+ if win.kind_of?(TkObject)
+ win.epath
+ elsif win.respond_to?(:epath)
+ win.epath
+ else
+ win
+ end
+ end
+ private :_epath
+end
+
+# define TkComm module (step 2: event binding)
+module TkComm
+ include TkEvent
+ extend TkEvent
+
+ def tk_event_sequence(context)
+ if context.kind_of? TkVirtualEvent
+ context = context.path
+ end
+ if context.kind_of? Array
+ context = context.collect{|ev|
+ if ev.kind_of? TkVirtualEvent
+ ev.path
+ else
+ ev
+ end
+ }.join("><")
+ end
+ if /,/ =~ context
+ context = context.split(/\s*,\s*/).join("><")
+ else
+ context
+ end
+ end
+
+ def _bind_core(mode, what, context, cmd, *args)
+ id = install_bind(cmd, *args) if cmd
+ begin
+ tk_call_without_enc(*(what + ["<#{tk_event_sequence(context)}>",
+ mode + id]))
+ rescue
+ uninstall_cmd(id) if cmd
+ fail
+ end
+ end
+
+ def _bind(what, context, cmd, *args)
+ _bind_core('', what, context, cmd, *args)
+ end
+
+ def _bind_append(what, context, cmd, *args)
+ _bind_core('+', what, context, cmd, *args)
+ end
+
+ def _bind_remove(what, context)
+ tk_call_without_enc(*(what + ["<#{tk_event_sequence(context)}>", '']))
+ end
+
+ def _bindinfo(what, context=nil)
+ if context
+ if TkCore::WITH_RUBY_VM ### Ruby 1.9 !!!!
+ enum_obj = tk_call_without_enc(*what+["<#{tk_event_sequence(context)}>"]).each_line
+ else
+ enum_obj = tk_call_without_enc(*what+["<#{tk_event_sequence(context)}>"])
+ end
+ enum_obj.collect {|cmdline|
+=begin
+ if cmdline =~ /^rb_out\S* (c(?:_\d+_)?\d+)\s+(.*)$/
+ #[Tk_CMDTBL[$1], $2]
+ [TkCore::INTERP.tk_cmd_tbl[$1], $2]
+=end
+ if cmdline =~ /rb_out\S*(?:\s+(::\S*|[{](::.*)[}]|["](::.*)["]))? (c(_\d+_)?(\d+))/
+ [TkCore::INTERP.tk_cmd_tbl[$4], $5]
+ else
+ cmdline
+ end
+ }
+ else
+ tk_split_simplelist(tk_call_without_enc(*what)).collect!{|seq|
+ l = seq.scan(/<*[^<>]+>*/).collect!{|subseq|
+ case (subseq)
+ when /^<<[^<>]+>>$/
+ TkVirtualEvent.getobj(subseq[1..-2])
+ when /^<[^<>]+>$/
+ subseq[1..-2]
+ else
+ subseq.split('')
+ end
+ }.flatten
+ (l.size == 1) ? l[0] : l
+ }
+ end
+ end
+
+ def _bind_core_for_event_class(klass, mode, what, context, cmd, *args)
+ id = install_bind_for_event_class(klass, cmd, *args) if cmd
+ begin
+ tk_call_without_enc(*(what + ["<#{tk_event_sequence(context)}>",
+ mode + id]))
+ rescue
+ uninstall_cmd(id) if cmd
+ fail
+ end
+ end
+
+ def _bind_for_event_class(klass, what, context, cmd, *args)
+ _bind_core_for_event_class(klass, '', what, context, cmd, *args)
+ end
+
+ def _bind_append_for_event_class(klass, what, context, cmd, *args)
+ _bind_core_for_event_class(klass, '+', what, context, cmd, *args)
+ end
+
+ def _bind_remove_for_event_class(klass, what, context)
+ _bind_remove(what, context)
+ end
+
+ def _bindinfo_for_event_class(klass, what, context=nil)
+ _bindinfo(what, context)
+ end
+
+ private :tk_event_sequence
+ private :_bind_core, :_bind, :_bind_append, :_bind_remove, :_bindinfo
+ private :_bind_core_for_event_class, :_bind_for_event_class,
+ :_bind_append_for_event_class, :_bind_remove_for_event_class,
+ :_bindinfo_for_event_class
+
+ #def bind(tagOrClass, context, cmd=Proc.new, *args)
+ # _bind(["bind", tagOrClass], context, cmd, *args)
+ # tagOrClass
+ #end
+ def bind(tagOrClass, context, *args)
+ # if args[0].kind_of?(Proc) || args[0].kind_of?(Method)
+ if TkComm._callback_entry?(args[0]) || !block_given?
+ cmd = args.shift
+ else
+ cmd = Proc.new
+ end
+ _bind(["bind", tagOrClass], context, cmd, *args)
+ tagOrClass
+ end
+
+ #def bind_append(tagOrClass, context, cmd=Proc.new, *args)
+ # _bind_append(["bind", tagOrClass], context, cmd, *args)
+ # tagOrClass
+ #end
+ def bind_append(tagOrClass, context, *args)
+ # if args[0].kind_of?(Proc) || args[0].kind_of?(Method)
+ if TkComm._callback_entry?(args[0]) || !block_given?
+ cmd = args.shift
+ else
+ cmd = Proc.new
+ end
+ _bind_append(["bind", tagOrClass], context, cmd, *args)
+ tagOrClass
+ end
+
+ def bind_remove(tagOrClass, context)
+ _bind_remove(['bind', tagOrClass], context)
+ tagOrClass
+ end
+
+ def bindinfo(tagOrClass, context=nil)
+ _bindinfo(['bind', tagOrClass], context)
+ end
+
+ #def bind_all(context, cmd=Proc.new, *args)
+ # _bind(['bind', 'all'], context, cmd, *args)
+ # TkBindTag::ALL
+ #end
+ def bind_all(context, *args)
+ # if args[0].kind_of?(Proc) || args[0].kind_of?(Method)
+ if TkComm._callback_entry?(args[0]) || !block_given?
+ cmd = args.shift
+ else
+ cmd = Proc.new
+ end
+ _bind(['bind', 'all'], context, cmd, *args)
+ TkBindTag::ALL
+ end
+
+ #def bind_append_all(context, cmd=Proc.new, *args)
+ # _bind_append(['bind', 'all'], context, cmd, *args)
+ # TkBindTag::ALL
+ #end
+ def bind_append_all(context, *args)
+ # if args[0].kind_of?(Proc) || args[0].kind_of?(Method)
+ if TkComm._callback_entry?(args[0]) || !block_given?
+ cmd = args.shift
+ else
+ cmd = Proc.new
+ end
+ _bind_append(['bind', 'all'], context, cmd, *args)
+ TkBindTag::ALL
+ end
+
+ def bind_remove_all(context)
+ _bind_remove(['bind', 'all'], context)
+ TkBindTag::ALL
+ end
+
+ def bindinfo_all(context=nil)
+ _bindinfo(['bind', 'all'], context)
+ end
+end
+
+
+module TkCore
+ include TkComm
+ extend TkComm
+
+ WITH_RUBY_VM = Object.const_defined?(:RubyVM) && ::RubyVM.class == Class
+ WITH_ENCODING = defined?(::Encoding.default_external) && true
+ #WITH_ENCODING = Object.const_defined?(:Encoding) && ::Encoding.class == Class
+
+ unless self.const_defined? :INTERP
+ if self.const_defined? :IP_NAME
+ name = IP_NAME.to_s
+ else
+ #name = nil
+ name = $0
+ end
+ if self.const_defined? :IP_OPTS
+ if IP_OPTS.kind_of?(Hash)
+ opts = hash_kv(IP_OPTS).join(' ')
+ else
+ opts = IP_OPTS.to_s
+ end
+ else
+ opts = ''
+ end
+
+ # RUN_EVENTLOOP_ON_MAIN_THREAD = true
+
+ unless self.const_defined? :RUN_EVENTLOOP_ON_MAIN_THREAD
+ if WITH_RUBY_VM ### check Ruby 1.9 !!!!!!!
+ # *** NEED TO FIX ***
+ case RUBY_PLATFORM
+ when /cygwin/
+ RUN_EVENTLOOP_ON_MAIN_THREAD = true
+ when /darwin/ # MacOS X
+=begin
+ ip = TclTkIp.new(name, opts)
+ if ip._invoke_without_enc('tk', 'windowingsystem') == 'aqua' &&
+ (TclTkLib.get_version<=>[8,4,TclTkLib::RELEASE_TYPE::FINAL,6]) > 0
+=end
+ if TclTkLib::WINDOWING_SYSTEM == 'aqua' &&
+ (TclTkLib.get_version<=>[8,4,TclTkLib::RELEASE_TYPE::FINAL,6]) > 0
+ # *** KNOWN BUG ***
+ # Main event loop thread of TkAqua (> Tk8.4.9) must be the main
+ # application thread. So, ruby1.9 users must call Tk.mainloop on
+ # the main application thread.
+ #
+ # *** ADD (2009/05/10) ***
+ # In some cases (I don't know the description of conditions),
+ # TkAqua 8.4.7 has a same kind of hang-up trouble.
+ # So, if 8.4.7 or later, set RUN_EVENTLOOP_ON_MAIN_THREAD to true.
+ # When you want to control this mode, please call the following
+ # (set true/false as you want) before "require 'tk'".
+ # ----------------------------------------------------------
+ # module TkCore; RUN_EVENTLOOP_ON_MAIN_THREAD = true; end
+ # ----------------------------------------------------------
+ #
+ # *** ADD (2010/07/05) ***
+ # The value of TclTkLib::WINDOWING_SYSTEM is defined at compiling.
+ # If it is inconsistent with linked DLL, please call the following
+ # before "require 'tk'".
+ # ----------------------------------------------------------
+ # require 'tcltklib'
+ # module TclTkLib
+ # remove_const :WINDOWING_SYSTEM
+ # WINDOWING_SYSTEM = 'x11' # or 'aqua'
+ # end
+ # ----------------------------------------------------------
+ #
+ RUN_EVENTLOOP_ON_MAIN_THREAD = true
+ else
+ RUN_EVENTLOOP_ON_MAIN_THREAD = false
+=begin
+ ip.delete
+ ip = nil
+=end
+ end
+ else
+ RUN_EVENTLOOP_ON_MAIN_THREAD = false
+ end
+
+ else # Ruby 1.8.x
+ RUN_EVENTLOOP_ON_MAIN_THREAD = false
+ end
+ end
+
+ if !WITH_RUBY_VM || RUN_EVENTLOOP_ON_MAIN_THREAD ### check Ruby 1.9 !!!!!!!
+ INTERP = TclTkIp.new(name, opts) unless self.const_defined? :INTERP
+ else
+ INTERP_MUTEX = Mutex.new
+ INTERP_ROOT_CHECK = ConditionVariable.new
+ INTERP_THREAD = Thread.new{
+ begin
+ #Thread.current[:interp] = interp = TclTkIp.new(name, opts)
+ interp = TclTkIp.new(name, opts)
+ rescue => e
+ Thread.current[:interp] = e
+ raise e
+ end
+
+ interp.mainloop_abort_on_exception = true
+ Thread.current.instance_variable_set("@interp", interp)
+
+ status = [nil]
+ def status.value
+ self[0]
+ end
+ def status.value=(val)
+ self[0] = val
+ end
+
+ Thread.current[:status] = status
+ #sleep
+
+ # like as 1.8, withdraw a root widget before calling Tk.mainloop
+ interp._eval <<EOS
+wm withdraw .
+rename wm __wm_orig__
+proc wm {subcmd win args} {
+ set val [eval [list __wm_orig__ $subcmd $win] $args]
+ if {[string equal $subcmd withdraw] && [string equal $win .]} {
+ rename wm {}
+ rename __wm_orig__ wm
+ }
+ return $val
+}
+proc __startup_rbtk_mainloop__ {args} {
+ rename __startup_rbtk_mainloop__ {}
+ if {[info command __wm_orig__] == "__wm_orig__"} {
+ rename wm {}
+ rename __wm_orig__ wm
+ if [string equal [wm state .] withdrawn] {
+ wm deiconify .
+ }
+ }
+}
+set __initial_state_of_rubytk__ 1
+trace add variable __initial_state_of_rubytk__ unset __startup_rbtk_mainloop__
+
+# complete initializing
+ruby {TkCore::INTERP_THREAD[:interp] = TkCore::INTERP_THREAD.instance_variable_get('@interp')}
+EOS
+
+ begin
+ begin
+ #TclTkLib.mainloop_abort_on_exception = false
+ #interp.mainloop_abort_on_exception = true
+ #Thread.current[:interp] = interp
+ #Thread.current[:status].value = TclTkLib.mainloop(true)
+ Thread.current[:status].value = interp.mainloop(true)
+ rescue SystemExit=>e
+ Thread.current[:status].value = e
+ rescue Exception=>e
+ Thread.current[:status].value = e
+ p e if $DEBUG
+ retry if interp.has_mainwindow?
+ ensure
+ INTERP_MUTEX.synchronize{ INTERP_ROOT_CHECK.broadcast }
+ end
+
+ unless interp.deleted?
+ begin
+ #Thread.current[:status].value = TclTkLib.mainloop(false)
+ Thread.current[:status].value = interp.mainloop(false)
+ rescue Exception=>e
+ puts "ignore exception on interp: #{e.inspect}\n" if $DEBUG
+ end
+ end
+
+ ensure
+ # interp must be deleted before the thread for interp is dead.
+ # If not, raise Tcl_Panic on Tcl_AsyncDelete because async handler
+ # deleted by the wrong thread.
+ interp.delete
+ end
+ }
+
+ # check a Tcl/Tk interpreter is initialized
+ until INTERP_THREAD[:interp]
+ # Thread.pass
+ INTERP_THREAD.run
+ end
+
+ # INTERP_THREAD.run
+ raise INTERP_THREAD[:interp] if INTERP_THREAD[:interp].kind_of? Exception
+
+ # check an eventloop is running
+ while INTERP_THREAD.alive? && TclTkLib.mainloop_thread?.nil?
+ INTERP_THREAD.run
+ end
+
+ INTERP = INTERP_THREAD[:interp]
+ INTERP_THREAD_STATUS = INTERP_THREAD[:status]
+
+ # delete the interpreter and kill the eventloop thread at exit
+ END{
+ if INTERP_THREAD.alive?
+ INTERP.delete
+ INTERP_THREAD.kill
+ end
+ }
+
+ # (for safety's sake) force the eventloop to run
+ INTERP_THREAD.run
+ end
+
+ def INTERP.__getip
+ self
+ end
+ def INTERP.default_master?
+ true
+ end
+
+ INTERP.instance_eval{
+ # @tk_cmd_tbl = TkUtil.untrust({})
+ @tk_cmd_tbl =
+ TkUtil.untrust(Hash.new{|hash, key|
+ fail IndexError, "unknown command ID '#{key}'"
+ })
+ def @tk_cmd_tbl.[]=(idx,val)
+ if self.has_key?(idx) && Thread.current.group != ThreadGroup::Default
+ fail SecurityError,"cannot change the entried command"
+ end
+ super(idx,val)
+ end
+
+ @tk_windows = TkUtil.untrust({})
+
+ @tk_table_list = TkUtil.untrust([])
+
+ @init_ip_env = TkUtil.untrust([]) # table of Procs
+ @add_tk_procs = TkUtil.untrust([]) # table of [name, args, body]
+
+ @force_default_encoding ||= TkUtil.untrust([false])
+ @encoding ||= TkUtil.untrust([nil])
+ def @encoding.to_s; self.join(nil); end
+
+ @cb_entry_class = Class.new(TkCallbackEntry){
+ class << self
+ def inspect
+ sprintf("#<Class(TkCallbackEntry):%0x>", self.__id__)
+ end
+ alias to_s inspect
+ end
+
+ def initialize(ip, cmd)
+ @ip = ip
+ @cmd = cmd
+ end
+ attr_reader :ip, :cmd
+ def call(*args)
+ @ip.cb_eval(@cmd, *args)
+ end
+ def inspect
+ sprintf("#<cb_entry:%0x>", self.__id__)
+ end
+ alias to_s inspect
+ }.freeze
+ }
+
+ def INTERP.cb_entry_class
+ @cb_entry_class
+ end
+ def INTERP.tk_cmd_tbl
+ @tk_cmd_tbl
+ end
+ def INTERP.tk_windows
+ @tk_windows
+ end
+
+ class Tk_OBJECT_TABLE
+ def initialize(id)
+ @id = id
+ @mutex = Mutex.new
+ end
+ def mutex
+ @mutex
+ end
+ def method_missing(m, *args, &b)
+ TkCore::INTERP.tk_object_table(@id).__send__(m, *args, &b)
+ end
+ end
+
+ def INTERP.tk_object_table(id)
+ @tk_table_list[id]
+ end
+ def INTERP.create_table
+ id = @tk_table_list.size
+ (tbl = {}).tainted? || TkUtil.untrust(tbl)
+ @tk_table_list << tbl
+# obj = Object.new
+# obj.instance_eval <<-EOD
+# def self.method_missing(m, *args)
+# TkCore::INTERP.tk_object_table(#{id}).send(m, *args)
+# end
+# EOD
+# return obj
+ Tk_OBJECT_TABLE.new(id)
+ end
+
+ def INTERP.get_cb_entry(cmd)
+ @cb_entry_class.new(__getip, cmd).freeze
+ end
+ def INTERP.cb_eval(cmd, *args)
+ TkUtil._get_eval_string(TkUtil.eval_cmd(cmd, *args))
+ end
+
+ def INTERP.init_ip_env(script = Proc.new)
+ @init_ip_env << script
+ script.call(self)
+ end
+ def INTERP.add_tk_procs(name, args = nil, body = nil)
+ if name.kind_of?(Array)
+ name.each{|param| self.add_tk_procs(*param)}
+ else
+ name = name.to_s
+ @add_tk_procs << [name, args, body]
+ self._invoke('proc', name, args, body) if args && body
+ end
+ end
+ def INTERP.remove_tk_procs(*names)
+ names.each{|name|
+ name = name.to_s
+ @add_tk_procs.delete_if{|elem|
+ elem.kind_of?(Array) && elem[0].to_s == name
+ }
+ #self._invoke('rename', name, '')
+ self.__invoke__('rename', name, '')
+ }
+ end
+ def INTERP.init_ip_internal
+ ip = self
+ @init_ip_env.each{|script| script.call(ip)}
+ @add_tk_procs.each{|name,args,body| ip._invoke('proc',name,args,body)}
+ end
+ end
+
+ unless self.const_defined? :RUN_EVENTLOOP_ON_MAIN_THREAD
+ ### Ruby 1.9 !!!!!!!!!!!!!!!!!!!!!!!!!!
+ RUN_EVENTLOOP_ON_MAIN_THREAD = false
+ end
+
+ WIDGET_DESTROY_HOOK = '<WIDGET_DESTROY_HOOK>'
+ INTERP._invoke_without_enc('event', 'add',
+ "<#{WIDGET_DESTROY_HOOK}>", '<Destroy>')
+ INTERP._invoke_without_enc('bind', 'all', "<#{WIDGET_DESTROY_HOOK}>",
+ install_cmd(proc{|path|
+ unless TkCore::INTERP.deleted?
+ begin
+ if (widget=TkCore::INTERP.tk_windows[path])
+ if widget.respond_to?(:__destroy_hook__)
+ widget.__destroy_hook__
+ end
+ end
+ rescue Exception=>e
+ p e if $DEBUG
+ end
+ end
+ }) << ' %W')
+
+ INTERP.add_tk_procs(TclTkLib::FINALIZE_PROC_NAME, '',
+ "catch { bind all <#{WIDGET_DESTROY_HOOK}> {} }")
+
+ INTERP.add_tk_procs('rb_out', 'ns args', <<-'EOL')
+ if [regexp {^::} $ns] {
+ set cmd {namespace eval $ns {ruby_cmd TkCore callback} $args}
+ } else {
+ set cmd {eval {ruby_cmd TkCore callback} $ns $args}
+ }
+ if {[set st [catch $cmd ret]] != 0} {
+ #return -code $st $ret
+ set idx [string first "\n\n" $ret]
+ if {$idx > 0} {
+ return -code $st \
+ -errorinfo [string range $ret [expr $idx + 2] \
+ [string length $ret]] \
+ [string range $ret 0 [expr $idx - 1]]
+ } else {
+ return -code $st $ret
+ }
+ } else {
+ return $ret
+ }
+ EOL
+=begin
+ INTERP.add_tk_procs('rb_out', 'args', <<-'EOL')
+ if {[set st [catch {eval {ruby_cmd TkCore callback} $args} ret]] != 0} {
+ #return -code $st $ret
+ set idx [string first "\n\n" $ret]
+ if {$idx > 0} {
+ return -code $st \
+ -errorinfo [string range $ret [expr $idx + 2] \
+ [string length $ret]] \
+ [string range $ret 0 [expr $idx - 1]]
+ } else {
+ return -code $st $ret
+ }
+ } else {
+ return $ret
+ }
+ EOL
+=end
+=begin
+ INTERP.add_tk_procs('rb_out', 'args', <<-'EOL')
+ #regsub -all {\\} $args {\\\\} args
+ #regsub -all {!} $args {\\!} args
+ #regsub -all "{" $args "\\{" args
+ regsub -all {(\\|!|\{|\})} $args {\\\1} args
+ if {[set st [catch {ruby [format "TkCore.callback %%Q!%s!" $args]} ret]] != 0} {
+ #return -code $st $ret
+ set idx [string first "\n\n" $ret]
+ if {$idx > 0} {
+ return -code $st \
+ -errorinfo [string range $ret [expr $idx + 2] \
+ [string length $ret]] \
+ [string range $ret 0 [expr $idx - 1]]
+ } else {
+ return -code $st $ret
+ }
+ } else {
+ return $ret
+ }
+ EOL
+=end
+
+ if !WITH_RUBY_VM || RUN_EVENTLOOP_ON_MAIN_THREAD ### check Ruby 1.9 !!!!!!!
+ at_exit{ INTERP.remove_tk_procs(TclTkLib::FINALIZE_PROC_NAME) }
+ else
+ at_exit{
+ Tk.root.destroy
+ INTERP.remove_tk_procs(TclTkLib::FINALIZE_PROC_NAME)
+ INTERP_THREAD.kill.join
+ }
+ end
+
+ EventFlag = TclTkLib::EventFlag
+
+ def callback_break
+ fail TkCallbackBreak, "Tk callback returns 'break' status"
+ end
+
+ def callback_continue
+ fail TkCallbackContinue, "Tk callback returns 'continue' status"
+ end
+
+ def callback_return
+ fail TkCallbackReturn, "Tk callback returns 'return' status"
+ end
+
+ def TkCore.callback(*arg)
+ begin
+ if TkCore::INTERP.tk_cmd_tbl.kind_of?(Hash)
+ #TkCore::INTERP.tk_cmd_tbl[arg.shift].call(*arg)
+ normal_ret = false
+ ret = catch(:IRB_EXIT) do # IRB hack
+ retval = TkCore::INTERP.tk_cmd_tbl[arg.shift].call(*arg)
+ normal_ret = true
+ retval
+ end
+ unless normal_ret
+ # catch IRB_EXIT
+ exit(ret)
+ end
+ ret
+ end
+ rescue SystemExit=>e
+ exit(e.status)
+ rescue Interrupt=>e
+ fail(e)
+ rescue Exception => e
+ begin
+ msg = _toUTF8(e.class.inspect) + ': ' +
+ _toUTF8(e.message) + "\n" +
+ "\n---< backtrace of Ruby side >-----\n" +
+ _toUTF8(e.backtrace.join("\n")) +
+ "\n---< backtrace of Tk side >-------"
+ if TkCore::WITH_ENCODING
+ msg.force_encoding('utf-8')
+ else
+ msg.instance_variable_set(:@encoding, 'utf-8')
+ end
+ rescue Exception
+ msg = e.class.inspect + ': ' + e.message + "\n" +
+ "\n---< backtrace of Ruby side >-----\n" +
+ e.backtrace.join("\n") +
+ "\n---< backtrace of Tk side >-------"
+ end
+ # TkCore::INTERP._set_global_var('errorInfo', msg)
+ # fail(e)
+ fail(e, msg)
+ end
+ end
+=begin
+ def TkCore.callback(arg_str)
+ # arg = tk_split_list(arg_str)
+ arg = tk_split_simplelist(arg_str)
+ #_get_eval_string(TkUtil.eval_cmd(Tk_CMDTBL[arg.shift], *arg))
+ #_get_eval_string(TkUtil.eval_cmd(TkCore::INTERP.tk_cmd_tbl[arg.shift],
+ # *arg))
+ # TkCore::INTERP.tk_cmd_tbl[arg.shift].call(*arg)
+ begin
+ TkCore::INTERP.tk_cmd_tbl[arg.shift].call(*arg)
+ rescue Exception => e
+ raise(e, e.class.inspect + ': ' + e.message + "\n" +
+ "\n---< backtrace of Ruby side >-----\n" +
+ e.backtrace.join("\n") +
+ "\n---< backtrace of Tk side >-------")
+ end
+#=begin
+# cb_obj = TkCore::INTERP.tk_cmd_tbl[arg.shift]
+# unless $DEBUG
+# cb_obj.call(*arg)
+# else
+# begin
+# raise 'check backtrace'
+# rescue
+# # ignore backtrace before 'callback'
+# pos = -($!.backtrace.size)
+# end
+# begin
+# cb_obj.call(*arg)
+# rescue
+# trace = $!.backtrace
+# raise $!, "\n#{trace[0]}: #{$!.message} (#{$!.class})\n" +
+# "\tfrom #{trace[1..pos].join("\n\tfrom ")}"
+# end
+# end
+#=end
+ end
+=end
+
+ def load_cmd_on_ip(tk_cmd)
+ bool(tk_call('auto_load', tk_cmd))
+ end
+
+ def after(ms, cmd=Proc.new)
+ cmdid = install_cmd(proc{ret = cmd.call;uninstall_cmd(cmdid); ret})
+ after_id = tk_call_without_enc("after",ms,cmdid)
+ after_id.instance_variable_set('@cmdid', cmdid)
+ after_id
+ end
+=begin
+ def after(ms, cmd=Proc.new)
+ crit_bup = Thread.critical
+ Thread.critical = true
+
+ myid = _curr_cmd_id
+ cmdid = install_cmd(proc{ret = cmd.call;uninstall_cmd(myid); ret})
+
+ Thread.critical = crit_bup
+
+ tk_call_without_enc("after",ms,cmdid) # return id
+# return
+# if false #defined? Thread
+# Thread.start do
+# ms = Float(ms)/1000
+# ms = 10 if ms == 0
+# sleep ms/1000
+# cmd.call
+# end
+# else
+# cmdid = install_cmd(cmd)
+# tk_call("after",ms,cmdid)
+# end
+ end
+=end
+
+ def after_idle(cmd=Proc.new)
+ cmdid = install_cmd(proc{ret = cmd.call;uninstall_cmd(cmdid); ret})
+ after_id = tk_call_without_enc('after','idle',cmdid)
+ after_id.instance_variable_set('@cmdid', cmdid)
+ after_id
+ end
+=begin
+ def after_idle(cmd=Proc.new)
+ crit_bup = Thread.critical
+ Thread.critical = true
+
+ myid = _curr_cmd_id
+ cmdid = install_cmd(proc{ret = cmd.call;uninstall_cmd(myid); ret})
+
+ Thread.critical = crit_bup
+
+ tk_call_without_enc('after','idle',cmdid)
+ end
+=end
+
+ def after_cancel(afterId)
+ tk_call_without_enc('after','cancel',afterId)
+ if (cmdid = afterId.instance_variable_get('@cmdid'))
+ afterId.instance_variable_set('@cmdid', nil)
+ uninstall_cmd(cmdid)
+ end
+ afterId
+ end
+
+ def windowingsystem
+ tk_call_without_enc('tk', 'windowingsystem')
+ end
+
+ def scaling(scale=nil)
+ if scale
+ tk_call_without_enc('tk', 'scaling', scale)
+ else
+ Float(number(tk_call_without_enc('tk', 'scaling')))
+ end
+ end
+ def scaling_displayof(win, scale=nil)
+ if scale
+ tk_call_without_enc('tk', 'scaling', '-displayof', win, scale)
+ else
+ Float(number(tk_call_without_enc('tk', '-displayof', win, 'scaling')))
+ end
+ end
+
+ def inactive
+ Integer(tk_call_without_enc('tk', 'inactive'))
+ end
+ def inactive_displayof(win)
+ Integer(tk_call_without_enc('tk', 'inactive', '-displayof', win))
+ end
+ def reset_inactive
+ tk_call_without_enc('tk', 'inactive', 'reset')
+ end
+ def reset_inactive_displayof(win)
+ tk_call_without_enc('tk', 'inactive', '-displayof', win, 'reset')
+ end
+
+ def appname(name=None)
+ tk_call('tk', 'appname', name)
+ end
+
+ def appsend_deny
+ tk_call('rename', 'send', '')
+ end
+
+ def appsend(interp, async, *args)
+ if $SAFE >= 4
+ fail SecurityError, "cannot send Tk commands at level 4"
+ elsif $SAFE >= 1 && args.find{|obj| obj.tainted?}
+ fail SecurityError, "cannot send tainted Tk commands at level #{$SAFE}"
+ end
+ if async != true && async != false && async != nil
+ args.unshift(async)
+ async = false
+ end
+ if async
+ tk_call('send', '-async', '--', interp, *args)
+ else
+ tk_call('send', '--', interp, *args)
+ end
+ end
+
+ def rb_appsend(interp, async, *args)
+ if $SAFE >= 4
+ fail SecurityError, "cannot send Ruby commands at level 4"
+ elsif $SAFE >= 1 && args.find{|obj| obj.tainted?}
+ fail SecurityError, "cannot send tainted Ruby commands at level #{$SAFE}"
+ end
+ if async != true && async != false && async != nil
+ args.unshift(async)
+ async = false
+ end
+ #args = args.collect!{|c| _get_eval_string(c).gsub(/[\[\]$"]/, '\\\\\&')}
+ args = args.collect!{|c| _get_eval_string(c).gsub(/[\[\]$"\\]/, '\\\\\&')}
+ # args.push(').to_s"')
+ # appsend(interp, async, 'ruby "(', *args)
+ args.push('}.call)"')
+ appsend(interp, async, 'ruby "TkComm._get_eval_string(proc{', *args)
+ end
+
+ def appsend_displayof(interp, win, async, *args)
+ if $SAFE >= 4
+ fail SecurityError, "cannot send Tk commands at level 4"
+ elsif $SAFE >= 1 && args.find{|obj| obj.tainted?}
+ fail SecurityError, "cannot send tainted Tk commands at level #{$SAFE}"
+ end
+ win = '.' if win == nil
+ if async != true && async != false && async != nil
+ args.unshift(async)
+ async = false
+ end
+ if async
+ tk_call('send', '-async', '-displayof', win, '--', interp, *args)
+ else
+ tk_call('send', '-displayor', win, '--', interp, *args)
+ end
+ end
+
+ def rb_appsend_displayof(interp, win, async, *args)
+ if $SAFE >= 4
+ fail SecurityError, "cannot send Ruby commands at level 4"
+ elsif $SAFE >= 1 && args.find{|obj| obj.tainted?}
+ fail SecurityError, "cannot send tainted Ruby commands at level #{$SAFE}"
+ end
+ win = '.' if win == nil
+ if async != true && async != false && async != nil
+ args.unshift(async)
+ async = false
+ end
+ #args = args.collect!{|c| _get_eval_string(c).gsub(/[\[\]$"]/, '\\\\\&')}
+ args = args.collect!{|c| _get_eval_string(c).gsub(/[\[\]$"\\]/, '\\\\\&')}
+ # args.push(').to_s"')
+ # appsend_displayof(interp, win, async, 'ruby "(', *args)
+ args.push('}.call)"')
+ appsend(interp, win, async, 'ruby "TkComm._get_eval_string(proc{', *args)
+ end
+
+ def info(*args)
+ tk_call('info', *args)
+ end
+
+ def mainloop(check_root = true)
+ if !TkCore::WITH_RUBY_VM
+ TclTkLib.mainloop(check_root)
+
+ elsif TkCore::RUN_EVENTLOOP_ON_MAIN_THREAD
+ # if TclTkLib::WINDOWING_SYSTEM == 'aqua' &&
+ #if TkCore::INTERP._invoke_without_enc('tk','windowingsystem')=='aqua' &&
+ # Thread.current != Thread.main &&
+ # (TclTkLib.get_version <=> [8,4,TclTkLib::RELEASE_TYPE::FINAL,9]) > 0
+ # raise RuntimeError,
+ # "eventloop on TkAqua ( > Tk8.4.9 ) works on the main thread only"
+ #end
+ if Thread.current != Thread.main
+ raise RuntimeError, "Tk.mainloop is allowed on the main thread only"
+ end
+ TclTkLib.mainloop(check_root)
+
+ else ### Ruby 1.9 !!!!!
+ unless TkCore::INTERP.default_master?
+ # [MultiTkIp] slave interp ?
+ return TkCore::INTERP._thread_tkwait('window', '.') if check_root
+ end
+
+ # like as 1.8, withdraw a root widget before calling Tk.mainloop
+ TkCore::INTERP._eval_without_enc('catch {unset __initial_state_of_rubytk__}')
+ INTERP_THREAD.run
+
+ begin
+ TclTkLib.set_eventloop_window_mode(true)
+
+ # force run the eventloop
+ TkCore::INTERP._eval_without_enc('update')
+ TkCore::INTERP._eval_without_enc('catch {set __initial_state_of_rubytk__}')
+ INTERP_THREAD.run
+ if check_root
+ INTERP_MUTEX.synchronize{
+ INTERP_ROOT_CHECK.wait(INTERP_MUTEX)
+ status = INTERP_THREAD_STATUS.value
+ if status && TkCore::INTERP.default_master?
+ INTERP_THREAD_STATUS.value = nil if $SAFE < 4
+ raise status if status.kind_of?(Exception)
+ end
+ }
+ else
+ # INTERP_THREAD.value
+ begin
+ INTERP_THREAD.value
+ rescue Exception => e
+ raise e
+ end
+ end
+ rescue Exception => e
+ raise e
+ ensure
+ TclTkLib.set_eventloop_window_mode(false)
+ end
+ end
+ end
+
+ def mainloop_thread?
+ # true : current thread is mainloop
+ # nil : there is no mainloop
+ # false : mainloop is running on the other thread
+ # ( At then, it is dangerous to call Tk interpreter directly. )
+ if !TkCore::WITH_RUBY_VM || TkCore::RUN_EVENTLOOP_ON_MAIN_THREAD
+ ### Ruby 1.9 !!!!!!!!!!!
+ TclTkLib.mainloop_thread?
+ else
+ Thread.current == INTERP_THREAD
+ end
+ end
+
+ def mainloop_exist?
+ TclTkLib.mainloop_thread? != nil
+ end
+
+ def is_mainloop?
+ TclTkLib.mainloop_thread? == true
+ end
+
+ def mainloop_watchdog(check_root = true)
+ # watchdog restarts mainloop when mainloop is dead
+ TclTkLib.mainloop_watchdog(check_root)
+ end
+
+ def do_one_event(flag = TclTkLib::EventFlag::ALL)
+ TclTkLib.do_one_event(flag)
+ end
+
+ def set_eventloop_tick(timer_tick)
+ TclTkLib.set_eventloop_tick(timer_tick)
+ end
+
+ def get_eventloop_tick()
+ TclTkLib.get_eventloop_tick
+ end
+
+ def set_no_event_wait(wait)
+ TclTkLib.set_no_even_wait(wait)
+ end
+
+ def get_no_event_wait()
+ TclTkLib.get_no_eventloop_wait
+ end
+
+ def set_eventloop_weight(loop_max, no_event_tick)
+ TclTkLib.set_eventloop_weight(loop_max, no_event_tick)
+ end
+
+ def get_eventloop_weight()
+ TclTkLib.get_eventloop_weight
+ end
+
+ def restart(app_name = nil, keys = {})
+ TkCore::INTERP.init_ip_internal
+
+ tk_call('set', 'argv0', app_name) if app_name
+ if keys.kind_of?(Hash)
+ # tk_call('set', 'argc', keys.size * 2)
+ tk_call('set', 'argv', hash_kv(keys).join(' '))
+ end
+
+ INTERP.restart
+ nil
+ end
+
+ def event_generate(win, context, keys=nil)
+ #win = win.path if win.kind_of?(TkObject)
+ if context.kind_of?(TkEvent::Event)
+ context.generate(win, ((keys)? keys: {}))
+ elsif keys
+ tk_call_without_enc('event', 'generate', win,
+ "<#{tk_event_sequence(context)}>",
+ *hash_kv(keys, true))
+ else
+ tk_call_without_enc('event', 'generate', win,
+ "<#{tk_event_sequence(context)}>")
+ end
+ nil
+ end
+
+ def messageBox(keys)
+ tk_call('tk_messageBox', *hash_kv(keys))
+ end
+
+ def getOpenFile(keys = nil)
+ tk_call('tk_getOpenFile', *hash_kv(keys))
+ end
+ def getMultipleOpenFile(keys = nil)
+ simplelist(tk_call('tk_getOpenFile', '-multiple', '1', *hash_kv(keys)))
+ end
+
+ def getSaveFile(keys = nil)
+ tk_call('tk_getSaveFile', *hash_kv(keys))
+ end
+ def getMultipleSaveFile(keys = nil)
+ simplelist(tk_call('tk_getSaveFile', '-multiple', '1', *hash_kv(keys)))
+ end
+
+ def chooseColor(keys = nil)
+ tk_call('tk_chooseColor', *hash_kv(keys))
+ end
+
+ def chooseDirectory(keys = nil)
+ tk_call('tk_chooseDirectory', *hash_kv(keys))
+ end
+
+ def _ip_eval_core(enc_mode, cmd_string)
+ case enc_mode
+ when nil
+ res = INTERP._eval(cmd_string)
+ when false
+ res = INTERP._eval_without_enc(cmd_string)
+ when true
+ res = INTERP._eval_with_enc(cmd_string)
+ end
+ if INTERP._return_value() != 0
+ fail RuntimeError, res, error_at
+ end
+ return res
+ end
+ private :_ip_eval_core
+
+ def ip_eval(cmd_string)
+ _ip_eval_core(nil, cmd_string)
+ end
+
+ def ip_eval_without_enc(cmd_string)
+ _ip_eval_core(false, cmd_string)
+ end
+
+ def ip_eval_with_enc(cmd_string)
+ _ip_eval_core(true, cmd_string)
+ end
+
+ def _ip_invoke_core(enc_mode, *args)
+ case enc_mode
+ when false
+ res = INTERP._invoke_without_enc(*args)
+ when nil
+ res = INTERP._invoke(*args)
+ when true
+ res = INTERP._invoke_with_enc(*args)
+ end
+ if INTERP._return_value() != 0
+ fail RuntimeError, res, error_at
+ end
+ return res
+ end
+ private :_ip_invoke_core
+
+ def ip_invoke(*args)
+ _ip_invoke_core(nil, *args)
+ end
+
+ def ip_invoke_without_enc(*args)
+ _ip_invoke_core(false, *args)
+ end
+
+ def ip_invoke_with_enc(*args)
+ _ip_invoke_core(true, *args)
+ end
+
+ def _tk_call_core(enc_mode, *args)
+ ### puts args.inspect if $DEBUG
+ #args.collect! {|x|ruby2tcl(x, enc_mode)}
+ #args.compact!
+ #args.flatten!
+ args = _conv_args([], enc_mode, *args)
+ puts 'invoke args => ' + args.inspect if $DEBUG
+ ### print "=> ", args.join(" ").inspect, "\n" if $DEBUG
+ begin
+ # res = TkUtil.untrust(INTERP._invoke(*args))
+ # res = INTERP._invoke(enc_mode, *args)
+ res = _ip_invoke_core(enc_mode, *args)
+ # >>>>> _invoke returns a TAINTED string <<<<<
+ rescue NameError => err
+ # err = $!
+ begin
+ args.unshift "unknown"
+ #res = TkUtil.untrust(INTERP._invoke(*args))
+ #res = INTERP._invoke(enc_mode, *args)
+ res = _ip_invoke_core(enc_mode, *args)
+ # >>>>> _invoke returns a TAINTED string <<<<<
+ rescue StandardError => err2
+ fail err2 unless /^invalid command/ =~ err2.message
+ fail err
+ end
+ end
+ if INTERP._return_value() != 0
+ fail RuntimeError, res, error_at
+ end
+ ### print "==> ", res.inspect, "\n" if $DEBUG
+ return res
+ end
+ private :_tk_call_core
+
+ def tk_call(*args)
+ _tk_call_core(nil, *args)
+ end
+
+ def tk_call_without_enc(*args)
+ _tk_call_core(false, *args)
+ end
+
+ def tk_call_with_enc(*args)
+ _tk_call_core(true, *args)
+ end
+
+ def _tk_call_to_list_core(depth, arg_enc, val_enc, *args)
+ args = _conv_args([], arg_enc, *args)
+ val = _tk_call_core(false, *args)
+ if !depth.kind_of?(Integer) || depth == 0
+ tk_split_simplelist(val, false, val_enc)
+ else
+ tk_split_list(val, depth, false, val_enc)
+ end
+ end
+ #private :_tk_call_to_list_core
+
+ def tk_call_to_list(*args)
+ _tk_call_to_list_core(-1, nil, true, *args)
+ end
+
+ def tk_call_to_list_without_enc(*args)
+ _tk_call_to_list_core(-1, false, false, *args)
+ end
+
+ def tk_call_to_list_with_enc(*args)
+ _tk_call_to_list_core(-1, true, true, *args)
+ end
+
+ def tk_call_to_simplelist(*args)
+ _tk_call_to_list_core(0, nil, true, *args)
+ end
+
+ def tk_call_to_simplelist_without_enc(*args)
+ _tk_call_to_list_core(0, false, false, *args)
+ end
+
+ def tk_call_to_simplelist_with_enc(*args)
+ _tk_call_to_list_core(0, true, true, *args)
+ end
+end
+
+
+module Tk
+ include TkCore
+ extend Tk
+
+ TCL_VERSION = INTERP._invoke_without_enc("info", "tclversion").freeze
+ TCL_PATCHLEVEL = INTERP._invoke_without_enc("info", "patchlevel").freeze
+
+ major, minor = TCL_VERSION.split('.')
+ TCL_MAJOR_VERSION = major.to_i
+ TCL_MINOR_VERSION = minor.to_i
+
+ TK_VERSION = INTERP._invoke_without_enc("set", "tk_version").freeze
+ TK_PATCHLEVEL = INTERP._invoke_without_enc("set", "tk_patchLevel").freeze
+
+ major, minor = TK_VERSION.split('.')
+ TK_MAJOR_VERSION = major.to_i
+ TK_MINOR_VERSION = minor.to_i
+
+ JAPANIZED_TK = (INTERP._invoke_without_enc("info", "commands",
+ "kanji") != "").freeze
+
+ def Tk.const_missing(sym)
+ case(sym)
+ when :TCL_LIBRARY
+ INTERP._invoke_without_enc('global', 'tcl_library')
+ INTERP._invoke("set", "tcl_library").freeze
+
+ when :TK_LIBRARY
+ INTERP._invoke_without_enc('global', 'tk_library')
+ INTERP._invoke("set", "tk_library").freeze
+
+ when :LIBRARY
+ INTERP._invoke("info", "library").freeze
+
+ #when :PKG_PATH, :PACKAGE_PATH, :TCL_PACKAGE_PATH
+ # INTERP._invoke_without_enc('global', 'tcl_pkgPath')
+ # tk_split_simplelist(INTERP._invoke('set', 'tcl_pkgPath'))
+
+ #when :LIB_PATH, :LIBRARY_PATH, :TCL_LIBRARY_PATH
+ # INTERP._invoke_without_enc('global', 'tcl_libPath')
+ # tk_split_simplelist(INTERP._invoke('set', 'tcl_libPath'))
+
+ when :PLATFORM, :TCL_PLATFORM
+ if $SAFE >= 4
+ fail SecurityError, "can't get #{sym} when $SAFE >= 4"
+ end
+ INTERP._invoke_without_enc('global', 'tcl_platform')
+ Hash[*tk_split_simplelist(INTERP._invoke_without_enc('array', 'get',
+ 'tcl_platform'))]
+
+ when :ENV
+ INTERP._invoke_without_enc('global', 'env')
+ Hash[*tk_split_simplelist(INTERP._invoke('array', 'get', 'env'))]
+
+ #when :AUTO_PATH #<===
+ # tk_split_simplelist(INTERP._invoke('set', 'auto_path'))
+
+ #when :AUTO_OLDPATH
+ # tk_split_simplelist(INTERP._invoke('set', 'auto_oldpath'))
+
+ when :AUTO_INDEX
+ INTERP._invoke_without_enc('global', 'auto_index')
+ Hash[*tk_split_simplelist(INTERP._invoke('array', 'get', 'auto_index'))]
+
+ when :PRIV, :PRIVATE, :TK_PRIV
+ priv = {}
+ if INTERP._invoke_without_enc('info', 'vars', 'tk::Priv') != ""
+ var_nam = 'tk::Priv'
+ else
+ var_nam = 'tkPriv'
+ end
+ INTERP._invoke_without_enc('global', var_nam)
+ Hash[*tk_split_simplelist(INTERP._invoke('array', 'get',
+ var_nam))].each{|k,v|
+ k.freeze
+ case v
+ when /^-?\d+$/
+ priv[k] = v.to_i
+ when /^-?\d+\.?\d*(e[-+]?\d+)?$/
+ priv[k] = v.to_f
+ else
+ priv[k] = v.freeze
+ end
+ }
+ priv
+
+ else
+ raise NameError, 'uninitialized constant Tk::' + sym.id2name
+ end
+ end
+
+ def Tk.errorInfo
+ INTERP._invoke_without_enc('global', 'errorInfo')
+ INTERP._invoke_without_enc('set', 'errorInfo')
+ end
+
+ def Tk.errorCode
+ INTERP._invoke_without_enc('global', 'errorCode')
+ code = tk_split_simplelist(INTERP._invoke_without_enc('set', 'errorCode'))
+ case code[0]
+ when 'CHILDKILLED', 'CHILDSTATUS', 'CHILDSUSP'
+ begin
+ pid = Integer(code[1])
+ code[1] = pid
+ rescue
+ end
+ end
+ code
+ end
+
+ def Tk.has_mainwindow?
+ INTERP.has_mainwindow?
+ end
+
+ def root
+ Tk::Root.new
+ end
+
+ def Tk.load_tclscript(file, enc=nil)
+ if enc
+ # TCL_VERSION >= 8.5
+ tk_call('source', '-encoding', enc, file)
+ else
+ tk_call('source', file)
+ end
+ end
+
+ def Tk.load_tcllibrary(file, pkg_name=None, interp=None)
+ tk_call('load', file, pkg_name, interp)
+ end
+
+ def Tk.unload_tcllibrary(*args)
+ if args[-1].kind_of?(Hash)
+ keys = _symbolkey2str(args.pop)
+ nocomp = (keys['nocomplain'])? '-nocomplain': None
+ keeplib = (keys['keeplibrary'])? '-keeplibrary': None
+ tk_call('unload', nocomp, keeplib, '--', *args)
+ else
+ tk_call('unload', *args)
+ end
+ end
+
+ def Tk.pkgconfig_list(mod)
+ # Tk8.5 feature
+ if mod.kind_of?(Module)
+ if mod.respond_to?(:package_name)
+ pkgname = mod.package_name
+ elsif mod.const_defined?(:PACKAGE_NAME)
+ pkgname = mod::PACKAGE_NAME
+ else
+ fail NotImplementedError, 'may not be a module for a Tcl extension'
+ end
+ else
+ pkgname = mod.to_s
+ end
+
+ pkgname = '::' << pkgname unless pkgname =~ /^::/
+
+ tk_split_list(tk_call(pkgname + '::pkgconfig', 'list'))
+ end
+
+ def Tk.pkgconfig_get(mod, key)
+ # Tk8.5 feature
+ if mod.kind_of?(Module)
+ if mod.respond_to?(:package_name)
+ pkgname = mod.package_name
+ else
+ fail NotImplementedError, 'may not be a module for a Tcl extension'
+ end
+ else
+ pkgname = mod.to_s
+ end
+
+ pkgname = '::' << pkgname unless pkgname =~ /^::/
+
+ tk_call(pkgname + '::pkgconfig', 'get', key)
+ end
+
+ def Tk.tcl_pkgconfig_list
+ # Tk8.5 feature
+ Tk.pkgconfig_list('::tcl')
+ end
+
+ def Tk.tcl_pkgconfig_get(key)
+ # Tk8.5 feature
+ Tk.pkgconfig_get('::tcl', key)
+ end
+
+ def Tk.tk_pkgconfig_list
+ # Tk8.5 feature
+ Tk.pkgconfig_list('::tk')
+ end
+
+ def Tk.tk_pkgconfig_get(key)
+ # Tk8.5 feature
+ Tk.pkgconfig_get('::tk', key)
+ end
+
+ def Tk.bell(nice = false)
+ if nice
+ tk_call_without_enc('bell', '-nice')
+ else
+ tk_call_without_enc('bell')
+ end
+ nil
+ end
+
+ def Tk.bell_on_display(win, nice = false)
+ if nice
+ tk_call_without_enc('bell', '-displayof', win, '-nice')
+ else
+ tk_call_without_enc('bell', '-displayof', win)
+ end
+ nil
+ end
+
+ def Tk.destroy(*wins)
+ #tk_call_without_enc('destroy', *wins)
+ tk_call_without_enc('destroy', *(wins.collect{|win|
+ if win.kind_of?(TkWindow)
+ win.epath
+ else
+ win
+ end
+ }))
+ end
+
+ def Tk.exit
+ TkCore::INTERP.has_mainwindow? && tk_call_without_enc('destroy', '.')
+ end
+
+ ################################################
+
+ def Tk.sleep(ms = nil, id = nil)
+ if id
+ var = (id.kind_of?(TkVariable))? id: TkVarAccess.new(id.to_s)
+ else
+ var = TkVariable.new
+ end
+
+ var.value = tk_call_without_enc('after', ms, proc{ var.value = 0 }) if ms
+ var.thread_wait
+ ms
+ end
+
+ def Tk.wakeup(id)
+ ((id.kind_of?(TkVariable))? id: TkVarAccess.new(id.to_s)).value = 0
+ nil
+ end
+
+ ################################################
+
+ def Tk.pack(*args)
+ TkPack.configure(*args)
+ end
+ def Tk.pack_forget(*args)
+ TkPack.forget(*args)
+ end
+ def Tk.unpack(*args)
+ TkPack.forget(*args)
+ end
+
+ def Tk.grid(*args)
+ TkGrid.configure(*args)
+ end
+ def Tk.grid_forget(*args)
+ TkGrid.forget(*args)
+ end
+ def Tk.ungrid(*args)
+ TkGrid.forget(*args)
+ end
+
+ def Tk.place(*args)
+ TkPlace.configure(*args)
+ end
+ def Tk.place_forget(*args)
+ TkPlace.forget(*args)
+ end
+ def Tk.unplace(*args)
+ TkPlace.forget(*args)
+ end
+
+ def Tk.update(idle=nil)
+ if idle
+ tk_call_without_enc('update', 'idletasks')
+ else
+ tk_call_without_enc('update')
+ end
+ end
+ def Tk.update_idletasks
+ update(true)
+ end
+ def update(idle=nil)
+ # only for backward compatibility (This never be recommended to use)
+ Tk.update(idle)
+ self
+ end
+
+ # NOTE::
+ # If no eventloop-thread is running, "thread_update" method is same
+ # to "update" method. Else, "thread_update" method waits to complete
+ # idletask operation on the eventloop-thread.
+ def Tk.thread_update(idle=nil)
+ if idle
+ tk_call_without_enc('thread_update', 'idletasks')
+ else
+ tk_call_without_enc('thread_update')
+ end
+ end
+ def Tk.thread_update_idletasks
+ thread_update(true)
+ end
+
+ def Tk.lower_window(win, below=None)
+ tk_call('lower', _epath(win), _epath(below))
+ nil
+ end
+ def Tk.raise_window(win, above=None)
+ tk_call('raise', _epath(win), _epath(above))
+ nil
+ end
+
+ def Tk.current_grabs(win = nil)
+ if win
+ window(tk_call_without_enc('grab', 'current', win))
+ else
+ tk_split_list(tk_call_without_enc('grab', 'current'))
+ end
+ end
+
+ def Tk.focus(display=nil)
+ if display == nil
+ window(tk_call_without_enc('focus'))
+ else
+ window(tk_call_without_enc('focus', '-displayof', display))
+ end
+ end
+
+ def Tk.focus_to(win, force=false)
+ if force
+ tk_call_without_enc('focus', '-force', win)
+ else
+ tk_call_without_enc('focus', win)
+ end
+ end
+
+ def Tk.focus_lastfor(win)
+ window(tk_call_without_enc('focus', '-lastfor', win))
+ end
+
+ def Tk.focus_next(win)
+ TkManageFocus.next(win)
+ end
+
+ def Tk.focus_prev(win)
+ TkManageFocus.prev(win)
+ end
+
+ def Tk.strictMotif(mode=None)
+ bool(tk_call_without_enc('set', 'tk_strictMotif', mode))
+ end
+
+ def Tk.show_kinsoku(mode='both')
+ begin
+ if /^8\.*/ === TK_VERSION && JAPANIZED_TK
+ tk_split_simplelist(tk_call('kinsoku', 'show', mode))
+ end
+ rescue
+ end
+ end
+ def Tk.add_kinsoku(chars, mode='both')
+ begin
+ if /^8\.*/ === TK_VERSION && JAPANIZED_TK
+ tk_split_simplelist(tk_call('kinsoku', 'add', mode,
+ *(chars.split(''))))
+ else
+ []
+ end
+ rescue
+ []
+ end
+ end
+ def Tk.delete_kinsoku(chars, mode='both')
+ begin
+ if /^8\.*/ === TK_VERSION && JAPANIZED_TK
+ tk_split_simplelist(tk_call('kinsoku', 'delete', mode,
+ *(chars.split(''))))
+ end
+ rescue
+ end
+ end
+
+ def Tk.toUTF8(str, encoding = nil)
+ _toUTF8(str, encoding)
+ end
+
+ def Tk.fromUTF8(str, encoding = nil)
+ _fromUTF8(str, encoding)
+ end
+end
+
+###########################################
+# string with Tcl's encoding
+###########################################
+module Tk
+ def Tk.subst_utf_backslash(str)
+ Tk::EncodedString.subst_utf_backslash(str)
+ end
+ def Tk.subst_tk_backslash(str)
+ Tk::EncodedString.subst_tk_backslash(str)
+ end
+ def Tk.utf_to_backslash_sequence(str)
+ Tk::EncodedString.utf_to_backslash_sequence(str)
+ end
+ def Tk.utf_to_backslash(str)
+ Tk::EncodedString.utf_to_backslash_sequence(str)
+ end
+ def Tk.to_backslash_sequence(str)
+ Tk::EncodedString.to_backslash_sequence(str)
+ end
+end
+
+
+###########################################
+# convert kanji string to/from utf-8
+###########################################
+if (/^(8\.[1-9]|9\.|[1-9][0-9])/ =~ Tk::TCL_VERSION && !Tk::JAPANIZED_TK)
+ module Tk
+ module Encoding
+ extend Encoding
+
+ TkCommandNames = ['encoding'.freeze].freeze
+
+ #############################################
+
+ if TkCore::WITH_ENCODING ### Ruby 1.9
+ RubyEncoding = ::Encoding
+
+ # for saving GC cost
+ #ENCNAMES_CMD = ['encoding'.freeze, 'names'.freeze]
+ BINARY_NAME = 'binary'.freeze
+ UTF8_NAME = 'utf-8'.freeze
+ DEFAULT_EXTERNAL_NAME = RubyEncoding.default_external.name.freeze
+ DEFAULT_INTERNAL_NAME = RubyEncoding.default_internal.name.freeze rescue nil
+
+ BINARY = RubyEncoding.find(BINARY_NAME)
+ UNKNOWN = RubyEncoding.find('ASCII-8BIT')
+
+ ### start of creating ENCODING_TABLE
+ ENCODING_TABLE = TkCore::INTERP.encoding_table
+=begin
+ ENCODING_TABLE = {
+ 'binary' => BINARY,
+ # 'UNKNOWN-8BIT' => UNKNOWN,
+ }
+
+ list = TkCore::INTERP._invoke_without_enc(ENCNAMES_CMD[0],
+ ENCNAMES_CMD[1])
+ TkCore::INTERP._split_tklist(list).each{|name|
+ begin
+ enc = RubyEncoding.find(name)
+ rescue ArgumentError
+ case name
+ when 'identity'
+ enc = BINARY
+ when 'shiftjis'
+ enc = RubyEncoding.find('Shift_JIS')
+ when 'unicode'
+ enc = RubyEncoding.find('UTF-8')
+ #if Tk.tk_call('set', 'tcl_platform(byteOrder)') =='littleEndian'
+ # enc = RubyEncoding.find('UTF-16LE')
+ #else
+ # enc = RubyEncoding.find('UTF-16BE')
+ #end
+ when 'symbol'
+ # single byte data
+ enc = RubyEncoding.find('ASCII-8BIT') ### ???
+ else
+ # unsupported on Ruby, but supported on Tk
+ enc = TkCore::INTERP.create_dummy_encoding_for_tk(name)
+ end
+ end
+ ENCODING_TABLE[name.freeze] = enc
+ }
+=end
+=begin
+ def ENCODING_TABLE.get_name(enc)
+ orig_enc = enc
+
+ # unles enc, use system default
+ # 1st: Ruby/Tk default encoding
+ # 2nd: Tcl/Tk default encoding
+ # 3rd: Ruby's default_external
+ enc ||= TkCore::INTERP.encoding
+ enc ||= TclTkLib.encoding_system
+ enc ||= DEFAULT_EXTERNAL_NAME
+
+ if enc.kind_of?(RubyEncoding)
+ # Ruby's Encoding object
+ if (name = self.key(enc))
+ return name
+ end
+
+ # Is it new ?
+ list = TkCore::INTERP._invoke_without_enc(ENCNAMES_CMD[0],
+ ENCNAMES_CMD[1])
+ TkComm.simplelist(list).each{|name|
+ if ((enc == RubyEncoding.find(name)) rescue false)
+ # new relation!! update table
+ self[name.freeze] = enc
+ return name
+ end
+ }
+ else
+ # String or Symbol ?
+ if self[name = enc.to_s]
+ return name
+ end
+
+ # Is it new ?
+ if (enc_obj = (RubyEncoding.find(name) rescue false))
+ list = TkCore::INTERP._invoke_without_enc(ENCNAMES_CMD[0],
+ ENCNAMES_CMD[1])
+ if TkComm.simplelist(list).index(name)
+ # Tk's encoding name ?
+ self[name.freeze] = enc_obj # new relation!! update table
+ return name
+ else
+ # Ruby's encoding name ?
+ if (name = self.key(enc_obj))
+ return name
+ end
+ end
+ end
+ end
+
+ fail ArgumentError, "unsupported Tk encoding '#{orig_enc}'"
+ end
+
+ def ENCODING_TABLE.get_obj(enc)
+ # returns the encoding object.
+ # If 'enc' is the encoding name on Tk only, it returns nil.
+ ((obj = self[self.get_name(enc)]).kind_of?(RubyEncoding))? obj: nil
+ end
+=end
+ ### end of creating ENCODING_TABLE
+
+ end
+
+ #############################################
+
+ if TkCore::WITH_ENCODING
+ ################################
+ ### Ruby 1.9
+ ################################
+ def force_default_encoding(mode)
+ TkCore::INTERP.force_default_encoding = mode
+ end
+
+ def force_default_encoding?
+ TkCore::INTERP.force_default_encoding?
+ end
+
+ def default_encoding=(enc)
+ TkCore::INTERP.default_encoding = Tk::Encoding::ENCODING_TABLE.get_name(enc)
+ end
+
+ def encoding=(enc)
+ TkCore::INTERP.encoding = Tk::Encoding::ENCODING_TABLE.get_name(enc)
+ end
+
+ def encoding_name
+ Tk::Encoding::ENCODING_TABLE.get_name(TkCore::INTERP.encoding)
+ end
+ def encoding_obj
+ Tk::Encoding::ENCODING_TABLE.get_obj(TkCore::INTERP.encoding)
+ end
+ alias encoding encoding_name
+ alias default_encoding encoding_name
+
+ def tk_encoding_names
+ #TkComm.simplelist(TkCore::INTERP._invoke_without_enc(Tk::Encoding::ENCNAMES_CMD[0], Tk::Encoding::ENCNAMES_CMD[1]))
+ TkComm.simplelist(TkCore::INTERP._invoke_without_enc('encoding', 'names'))
+ end
+ def encoding_names
+ self.tk_encoding_names.find_all{|name|
+ Tk::Encoding::ENCODING_TABLE.get_name(name) rescue false
+ }
+ end
+ def encoding_objs
+ self.tk_encoding_names.map!{|name|
+ Tk::Encoding::ENCODING_TABLE.get_obj(name) rescue nil
+ }.compact
+ end
+
+ def encoding_system=(enc)
+ TclTkLib.encoding_system = Tk::Encoding::ENCODING_TABLE.get_name(enc)
+ end
+
+ def encoding_system_name
+ Tk::Encoding::ENCODING_TABLE.get_name(TclTkLib.encoding_system)
+ end
+ def encoding_system_obj
+ Tk::Encoding::ENCODING_TABLE.get_obj(TclTkLib.encoding_system)
+ end
+ alias encoding_system encoding_system_name
+
+ ################################
+ else
+ ################################
+ ### Ruby 1.8-
+ ################################
+ def force_default_encoding=(mode)
+ true
+ end
+
+ def force_default_encoding?
+ true
+ end
+
+ def default_encoding=(enc)
+ TkCore::INTERP.default_encoding = enc
+ end
+
+ def encoding=(enc)
+ TkCore::INTERP.encoding = enc
+ end
+
+ def encoding_obj
+ TkCore::INTERP.encoding
+ end
+ def encoding_name
+ TkCore::INTERP.encoding
+ end
+ alias encoding encoding_name
+ alias default_encoding encoding_name
+
+ def tk_encoding_names
+ TkComm.simplelist(Tk.tk_call('encoding', 'names'))
+ end
+ def encoding_objs
+ self.tk_encoding_names
+ end
+ def encoding_names
+ self.tk_encoding_names
+ end
+
+ def encoding_system=(enc)
+ TclTkLib.encoding_system = enc
+ end
+
+ def encoding_system_name
+ TclTkLib.encoding_system
+ end
+ def encoding_system_obj
+ TclTkLib.encoding_system
+ end
+ alias encoding_system encoding_system_name
+
+ ################################
+ end
+
+ def encoding_convertfrom(str, enc=nil)
+ enc = encoding_system_name unless enc
+ str = str.dup
+ if TkCore::WITH_ENCODING
+ if str.kind_of?(Tk::EncodedString)
+ str.__instance_variable_set('@encoding', nil)
+ else
+ str.instance_variable_set('@encoding', nil)
+ end
+ str.force_encoding('binary')
+ else
+ str.instance_variable_set('@encoding', 'binary')
+ end
+ ret = TkCore::INTERP._invoke_without_enc('encoding', 'convertfrom',
+ enc, str)
+ if TkCore::WITH_ENCODING
+ ret.force_encoding('utf-8')
+ else
+ Tk::UTF8_String.new(ret)
+ end
+ ret
+ end
+ alias encoding_convert_from encoding_convertfrom
+
+ def encoding_convertto(str, enc=nil)
+ # str must be a UTF-8 string
+ enc = encoding_system_name unless enc
+ ret = TkCore::INTERP._invoke_without_enc('encoding', 'convertto',
+ enc, str)
+ #ret.instance_variable_set('@encoding', 'binary')
+ if TkCore::WITH_ENCODING
+ #ret.force_encoding(Tk::Encoding::ENCODING_TABLE.get_obj('binary'))
+ ret.force_encoding(Tk::Encoding::ENCODING_TABLE.get_obj(enc))
+ end
+ ret
+ end
+ alias encoding_convert_to encoding_convertto
+
+ def encoding_dirs
+ # Tcl8.5 feature
+ TkComm.simplelist(Tk.tk_call_without_enc('encoding', 'dirs'))
+ end
+
+ def encoding_dirs=(dir_list) # an array or a Tcl's list string
+ # Tcl8.5 feature
+ Tk.tk_call_without_enc('encoding', 'dirs', dir_list)
+ end
+ end
+
+ extend Encoding
+ end
+
+ class TclTkIp
+ def force_default_encoding=(mode)
+ @force_default_encoding[0] = (mode)? true: false
+ end
+
+ def force_default_encoding?
+ @force_default_encoding[0] ||= false
+ end
+
+ def default_encoding=(name)
+ name = name.name if Tk::WITH_ENCODING && name.kind_of?(::Encoding)
+ @encoding[0] = name.to_s.dup
+ end
+
+ # from tkencoding.rb by ttate@jaist.ac.jp
+ #attr_accessor :encoding
+ def encoding=(name)
+ self.force_default_encoding = true # for comaptibility
+ self.default_encoding = name
+ end
+
+ def encoding_name
+ (@encoding[0])? @encoding[0].dup: nil
+ end
+ alias encoding encoding_name
+ alias default_encoding encoding_name
+
+ def encoding_obj
+ if Tk::WITH_ENCODING
+ Tk::Encoding.tcl2rb_encoding(@encoding[0])
+ else
+ (@encoding[0])? @encoding[0].dup: nil
+ end
+ end
+
+ alias __toUTF8 _toUTF8
+ alias __fromUTF8 _fromUTF8
+
+ if Object.const_defined?(:Encoding) && ::Encoding.class == Class
+ # with Encoding (Ruby 1.9+)
+ #
+ # use functions on Tcl as default.
+ # but when unsupported encoding on Tcl, use methods on Ruby.
+ #
+ def _toUTF8(str, enc = nil)
+ if enc
+ # use given encoding
+ begin
+ enc_name = Tk::Encoding::ENCODING_TABLE.get_name(enc)
+ rescue
+ # unknown encoding for Tk -> try to convert encoding on Ruby
+ str = str.dup.force_encoding(enc)
+ str.encode!(Tk::Encoding::UTF8_NAME) # modify self !!
+ return str # if no error, probably succeed converting
+ end
+ end
+
+ enc_name ||= str.instance_variable_get(:@encoding)
+
+ enc_name ||=
+ Tk::Encoding::ENCODING_TABLE.get_name(str.encoding) rescue nil
+
+ if enc_name
+ # str has its encoding information
+ encstr = __toUTF8(str, enc_name)
+ encstr.force_encoding(Tk::Encoding::UTF8_NAME)
+ return encstr
+ else
+ # str.encoding isn't supported by Tk -> try to convert on Ruby
+ begin
+ return str.encode(Tk::Encoding::UTF8_NAME) # new string
+ rescue
+ # error -> ignore, try to use default encoding of Ruby/Tk
+ end
+ end
+
+ #enc_name ||=
+ # Tk::Encoding::ENCODING_TABLE.get_name(Tk.encoding) rescue nil
+ enc_name ||= Tk::Encoding::ENCODING_TABLE.get_name(nil)
+
+ # is 'binary' encoding?
+ if enc_name == Tk::Encoding::BINARY_NAME
+ return str.dup.force_encoding(Tk::Encoding::BINARY_NAME)
+ end
+
+ # force default encoding?
+ if ! str.kind_of?(Tk::EncodedString) && self.force_default_encoding?
+ enc_name = Tk::Encoding::ENCODING_TABLE.get_name(Tk.default_encoding)
+ end
+
+ encstr = __toUTF8(str, enc_name)
+ encstr.force_encoding(Tk::Encoding::UTF8_NAME)
+ encstr
+ end
+ def _fromUTF8(str, enc = nil)
+ # str must be UTF-8 or binary.
+ enc_name = str.instance_variable_get(:@encoding)
+ enc_name ||=
+ Tk::Encoding::ENCODING_TABLE.get_name(str.encoding) rescue nil
+
+ # is 'binary' encoding?
+ if enc_name == Tk::Encoding::BINARY_NAME
+ return str.dup.force_encoding(Tk::Encoding::BINARY_NAME)
+ end
+
+ # get target encoding name (if enc == nil, use default encoding)
+ begin
+ enc_name = Tk::Encoding::ENCODING_TABLE.get_name(enc)
+ rescue
+ # then, enc != nil
+ # unknown encoding for Tk -> try to convert encoding on Ruby
+ str = str.dup.force_encoding(Tk::Encoding::UTF8_NAME)
+ str.encode!(enc) # modify self !!
+ return str # if no error, probably succeed converting
+ end
+
+ encstr = __fromUTF8(str, enc_name)
+ encstr.force_encoding(Tk::Encoding::ENCODING_TABLE.get_obj(enc_name))
+ encstr
+ end
+ ###
+ else
+ # without Encoding (Ruby 1.8)
+ def _toUTF8(str, encoding = nil)
+ __toUTF8(str, encoding)
+ end
+ def _fromUTF8(str, encoding = nil)
+ __fromUTF8(str, encoding)
+ end
+ ###
+ end
+
+ alias __eval _eval
+ alias __invoke _invoke
+
+ def _eval(cmd)
+ _fromUTF8(__eval(_toUTF8(cmd)))
+ end
+
+ def _invoke(*cmds)
+ _fromUTF8(__invoke(*(cmds.collect{|cmd| _toUTF8(cmd)})))
+ end
+
+ alias _eval_with_enc _eval
+ alias _invoke_with_enc _invoke
+
+=begin
+ #### --> definition is moved to TclTkIp module
+
+ def _toUTF8(str, encoding = nil)
+ # decide encoding
+ if encoding
+ encoding = encoding.to_s
+ elsif str.kind_of?(Tk::EncodedString) && str.encoding != nil
+ encoding = str.encoding.to_s
+ elsif str.instance_variable_get(:@encoding)
+ encoding = str.instance_variable_get(:@encoding).to_s
+ elsif defined?(@encoding) && @encoding != nil
+ encoding = @encoding.to_s
+ else
+ encoding = __invoke('encoding', 'system')
+ end
+
+ # convert
+ case encoding
+ when 'utf-8', 'binary'
+ str
+ else
+ __toUTF8(str, encoding)
+ end
+ end
+
+ def _fromUTF8(str, encoding = nil)
+ unless encoding
+ if defined?(@encoding) && @encoding != nil
+ encoding = @encoding.to_s
+ else
+ encoding = __invoke('encoding', 'system')
+ end
+ end
+
+ if str.kind_of?(Tk::EncodedString)
+ if str.encoding == 'binary'
+ str
+ else
+ __fromUTF8(str, encoding)
+ end
+ elsif str.instance_variable_get(:@encoding).to_s == 'binary'
+ str
+ else
+ __fromUTF8(str, encoding)
+ end
+ end
+=end
+
+=begin
+ def _eval(cmd)
+ if defined?(@encoding) && @encoding != 'utf-8'
+ ret = if cmd.kind_of?(Tk::EncodedString)
+ case cmd.encoding
+ when 'utf-8', 'binary'
+ __eval(cmd)
+ else
+ __eval(_toUTF8(cmd, cmd.encoding))
+ end
+ elsif cmd.instance_variable_get(:@encoding) == 'binary'
+ __eval(cmd)
+ else
+ __eval(_toUTF8(cmd, @encoding))
+ end
+ if ret.kind_of?(String) && ret.instance_variable_get(:@encoding) == 'binary'
+ ret
+ else
+ _fromUTF8(ret, @encoding)
+ end
+ else
+ __eval(cmd)
+ end
+ end
+
+ def _invoke(*cmds)
+ if defined?(@encoding) && @encoding != 'utf-8'
+ cmds = cmds.collect{|cmd|
+ if cmd.kind_of?(Tk::EncodedString)
+ case cmd.encoding
+ when 'utf-8', 'binary'
+ cmd
+ else
+ _toUTF8(cmd, cmd.encoding)
+ end
+ elsif cmd.instance_variable_get(:@encoding) == 'binary'
+ cmd
+ else
+ _toUTF8(cmd, @encoding)
+ end
+ }
+ ret = __invoke(*cmds)
+ if ret.kind_of?(String) && ret.instance_variable_get(:@encoding) == 'binary'
+ ret
+ else
+ _fromUTF8(ret, @encoding)
+ end
+ else
+ __invoke(*cmds)
+ end
+ end
+=end
+ end
+
+ module TclTkLib
+ class << self
+ def force_default_encoding=(mode)
+ TkCore::INTERP.force_default_encoding = mode
+ end
+
+ def force_default_encoding?
+ TkCore::INTERP.force_default_encoding?
+ end
+
+ def default_encoding=(name)
+ TkCore::INTERP.default_encoding = name
+ end
+
+ alias _encoding encoding
+ alias _encoding= encoding=
+ def encoding=(name)
+ name = name.name if name.kind_of?(::Encoding) if Tk::WITH_ENCODING
+ TkCore::INTERP.encoding = name
+ end
+
+ def encoding_name
+ TkCore::INTERP.encoding
+ end
+ alias encoding encoding_name
+ alias default_encoding encoding_name
+
+ def encoding_obj
+ if Tk::WITH_ENCODING
+ Tk::Encoding.tcl2rb_encoding(TkCore::INTERP.encoding)
+ else
+ TkCore::INTERP.encoding
+ end
+ end
+ end
+ end
+
+ # estimate encoding
+ unless TkCore::WITH_ENCODING
+ case $KCODE
+ when /^e/i # EUC
+ Tk.encoding = 'euc-jp'
+ Tk.encoding_system = 'euc-jp'
+ when /^s/i # SJIS
+ begin
+ if Tk.encoding_system == 'cp932'
+ Tk.encoding = 'cp932'
+ else
+ Tk.encoding = 'shiftjis'
+ Tk.encoding_system = 'shiftjis'
+ end
+ rescue StandardError, NameError
+ Tk.encoding = 'shiftjis'
+ Tk.encoding_system = 'shiftjis'
+ end
+ when /^u/i # UTF8
+ Tk.encoding = 'utf-8'
+ Tk.encoding_system = 'utf-8'
+ else # NONE
+ if defined? DEFAULT_TK_ENCODING
+ Tk.encoding_system = DEFAULT_TK_ENCODING
+ end
+ begin
+ Tk.encoding = Tk.encoding_system
+ rescue StandardError, NameError
+ Tk.encoding = 'utf-8'
+ Tk.encoding_system = 'utf-8'
+ end
+ end
+
+ else ### Ruby 1.9 !!!!!!!!!!!!
+ # loc_enc_obj = (::Encoding.find(::Encoding.locale_charmap) rescue Tk::Encoding::UNKNOWN)
+ loc_enc_obj = ::Encoding.find("locale")
+ ext_enc_obj = ::Encoding.default_external
+ int_enc_obj = ::Encoding.default_internal || ext_enc_obj
+ tksys_enc_name = Tk::Encoding::ENCODING_TABLE.get_name(Tk.encoding_system)
+ # p [Tk.encoding, Tk.encoding_system, loc_enc_obj, ext_enc_obj]
+
+=begin
+ if ext_enc_obj == Tk::Encoding::UNKNOWN
+ if defined? DEFAULT_TK_ENCODING
+ if DEFAULT_TK_ENCODING.kind_of?(::Encoding)
+ tk_enc_name = DEFAULT_TK_ENCODING.name
+ tksys_enc_name = DEFAULT_TK_ENCODING.name
+ else
+ tk_enc_name = DEFAULT_TK_ENCODING
+ tksys_enc_name = DEFAULT_TK_ENCODING
+ end
+ else
+ tk_enc_name = loc_enc_obj.name
+ tksys_enc_name = loc_enc_obj.name
+ end
+ else
+ tk_enc_name = ext_enc_obj.name
+ tksys_enc_name = ext_enc_obj.name
+ end
+
+ # Tk.encoding = tk_enc_name
+ Tk.default_encoding = tk_enc_name
+ Tk.encoding_system = tksys_enc_name
+=end
+
+ if ext_enc_obj == Tk::Encoding::UNKNOWN
+ if loc_enc_obj == Tk::Encoding::UNKNOWN
+ # use Tk.encoding_system
+ else
+ # use locale_charmap
+ begin
+ loc_enc_name = Tk::Encoding::ENCODING_TABLE.get_name(loc_enc_obj)
+ if loc_enc_name && loc_enc_name != tksys_enc_name
+ # use locale_charmap
+ Tk.encoding_system = loc_enc_name
+ else
+ # use Tk.encoding_system
+ end
+ rescue ArgumentError
+ # unsupported encoding on Tk -> use Tk.encoding_system
+ end
+ end
+ else
+ begin
+ ext_enc_name = Tk::Encoding::ENCODING_TABLE.get_name(ext_enc_obj)
+ if ext_enc_name && ext_enc_name != tksys_enc_name
+ # use default_external
+ Tk.encoding_system = ext_enc_name
+ else
+ # use Tk.encoding_system
+ end
+ rescue ArgumentError
+ # unsupported encoding on Tk -> use Tk.encoding_system
+ end
+ end
+
+ # setup Tk.encoding
+ enc_name = nil
+
+ begin
+ default_def = DEFAULT_TK_ENCODING
+ if ::Encoding.find(default_def.to_s) != Tk::Encoding::UNKNOWN
+ enc_name = Tk::Encoding::ENCODING_TABLE.get_name(default_def)
+ end
+ rescue NameError
+ # ignore
+ enc_name = nil
+ rescue ArgumentError
+ enc_name = nil
+ fail ArgumentError,
+ "DEFAULT_TK_ENCODING has an unknown encoding #{default_def}"
+ end
+
+ unless enc_name
+ #if ext_enc_obj == Tk::Encoding::UNKNOWN
+ if int_enc_obj == Tk::Encoding::UNKNOWN
+ if loc_enc_obj == Tk::Encoding::UNKNOWN
+ # use Tk.encoding_system
+ enc_name = tksys_enc_name
+ else
+ # use locale_charmap
+ begin
+ loc_enc_name = Tk::Encoding::ENCODING_TABLE.get_name(loc_enc_obj)
+ if loc_enc_name
+ # use locale_charmap
+ enc_name = loc_enc_name
+ else
+ # use Tk.encoding_system
+ enc_name = tksys_enc_name
+ end
+ rescue ArgumentError
+ # unsupported encoding on Tk -> use Tk.encoding_system
+ enc_name = tksys_enc_name
+ end
+ end
+ else
+ begin
+ #ext_enc_name = Tk::Encoding::ENCODING_TABLE.get_name(ext_enc_obj)
+ #if ext_enc_name && ext_enc_name != tksys_enc_name
+ int_enc_name = Tk::Encoding::ENCODING_TABLE.get_name(int_enc_obj)
+ if int_enc_name
+ # use default_internal
+ enc_name = int_enc_name
+ else
+ # use Tk.encoding_system
+ enc_name = tksys_enc_name
+ end
+ rescue ArgumentError
+ # unsupported encoding on Tk -> use Tk.encoding_system
+ enc_name = tksys_enc_name
+ end
+ end
+ end
+
+ Tk.default_encoding = (enc_name)? enc_name: tksys_enc_name
+ end
+
+else
+ # dummy methods
+ module Tk
+ module Encoding
+ extend Encoding
+
+ def force_default_encoding=(mode)
+ nil
+ end
+
+ def force_default_encoding?
+ nil
+ end
+
+ def default_encoding=(enc)
+ nil
+ end
+ def default_encoding
+ nil
+ end
+
+ def encoding=(name)
+ nil
+ end
+ def encoding
+ nil
+ end
+ def encoding_names
+ nil
+ end
+ def encoding_system
+ nil
+ end
+ def encoding_system=(enc)
+ nil
+ end
+
+ def encoding_convertfrom(str, enc=None)
+ str
+ end
+ alias encoding_convert_from encoding_convertfrom
+
+ def encoding_convertto(str, enc=None)
+ str
+ end
+ alias encoding_convert_to encoding_convertto
+ def encoding_dirs
+ nil
+ end
+ def encoding_dirs=(dir_array)
+ nil
+ end
+ end
+
+ extend Encoding
+ end
+
+ class TclTkIp
+ attr_accessor :encoding
+
+ alias __eval _eval
+ alias __invoke _invoke
+
+ alias _eval_with_enc _eval
+ alias _invoke_with_enc _invoke
+ end
+end
+
+
+module TkBindCore
+ #def bind(context, cmd=Proc.new, *args)
+ # Tk.bind(self, context, cmd, *args)
+ #end
+ def bind(context, *args)
+ # if args[0].kind_of?(Proc) || args[0].kind_of?(Method)
+ if TkComm._callback_entry?(args[0]) || !block_given?
+ cmd = args.shift
+ else
+ cmd = Proc.new
+ end
+ Tk.bind(self, context, cmd, *args)
+ end
+
+ #def bind_append(context, cmd=Proc.new, *args)
+ # Tk.bind_append(self, context, cmd, *args)
+ #end
+ def bind_append(context, *args)
+ # if args[0].kind_of?(Proc) || args[0].kind_of?(Method)
+ if TkComm._callback_entry?(args[0]) || !block_given?
+ cmd = args.shift
+ else
+ cmd = Proc.new
+ end
+ Tk.bind_append(self, context, cmd, *args)
+ end
+
+ def bind_remove(context)
+ Tk.bind_remove(self, context)
+ end
+
+ def bindinfo(context=nil)
+ Tk.bindinfo(self, context)
+ end
+end
+
+
+module TkTreatFont
+ def __font_optkeys
+ ['font']
+ end
+ private :__font_optkeys
+
+ def __pathname
+ self.path
+ end
+ private :__pathname
+
+ ################################
+
+ def font_configinfo(key = nil)
+ optkeys = __font_optkeys
+ if key && !optkeys.find{|opt| opt.to_s == key.to_s}
+ fail ArgumentError, "unknown font option name `#{key}'"
+ end
+
+ win, tag = __pathname.split(':')
+
+ if key
+ pathname = [win, tag, key].join(';')
+ TkFont.used_on(pathname) ||
+ TkFont.init_widget_font(pathname, *__confinfo_cmd)
+ elsif optkeys.size == 1
+ pathname = [win, tag, optkeys[0]].join(';')
+ TkFont.used_on(pathname) ||
+ TkFont.init_widget_font(pathname, *__confinfo_cmd)
+ else
+ fonts = {}
+ optkeys.each{|k|
+ k = k.to_s
+ pathname = [win, tag, k].join(';')
+ fonts[k] =
+ TkFont.used_on(pathname) ||
+ TkFont.init_widget_font(pathname, *__confinfo_cmd)
+ }
+ fonts
+ end
+ end
+ alias fontobj font_configinfo
+
+ def font_configure(slot)
+ pathname = __pathname
+
+ slot = _symbolkey2str(slot)
+
+ __font_optkeys.each{|optkey|
+ optkey = optkey.to_s
+ l_optkey = 'latin' << optkey
+ a_optkey = 'ascii' << optkey
+ k_optkey = 'kanji' << optkey
+
+ if slot.key?(optkey)
+ fnt = slot.delete(optkey)
+ if fnt.kind_of?(TkFont)
+ slot.delete(l_optkey)
+ slot.delete(a_optkey)
+ slot.delete(k_optkey)
+
+ fnt.call_font_configure([pathname, optkey], *(__config_cmd << {}))
+ next
+ else
+ if fnt
+ if (slot.key?(l_optkey) ||
+ slot.key?(a_optkey) ||
+ slot.key?(k_optkey))
+ fnt = TkFont.new(fnt)
+
+ lfnt = slot.delete(l_optkey)
+ lfnt = slot.delete(a_optkey) if slot.key?(a_optkey)
+ kfnt = slot.delete(k_optkey)
+
+ fnt.latin_replace(lfnt) if lfnt
+ fnt.kanji_replace(kfnt) if kfnt
+
+ fnt.call_font_configure([pathname, optkey],
+ *(__config_cmd << {}))
+ next
+ else
+ fnt = hash_kv(fnt) if fnt.kind_of?(Hash)
+ unless TkConfigMethod.__IGNORE_UNKNOWN_CONFIGURE_OPTION__
+ tk_call(*(__config_cmd << "-#{optkey}" << fnt))
+ else
+ begin
+ tk_call(*(__config_cmd << "-#{optkey}" << fnt))
+ rescue
+ # ignore
+ end
+ end
+ end
+ end
+ next
+ end
+ end
+
+ lfnt = slot.delete(l_optkey)
+ lfnt = slot.delete(a_optkey) if slot.key?(a_optkey)
+ kfnt = slot.delete(k_optkey)
+
+ if lfnt && kfnt
+ TkFont.new(lfnt, kfnt).call_font_configure([pathname, optkey],
+ *(__config_cmd << {}))
+ elsif lfnt
+ latinfont_configure([lfnt, optkey])
+ elsif kfnt
+ kanjifont_configure([kfnt, optkey])
+ end
+ }
+
+ # configure other (without font) options
+ tk_call(*(__config_cmd.concat(hash_kv(slot)))) if slot != {}
+ self
+ end
+
+ def latinfont_configure(ltn, keys=nil)
+ if ltn.kind_of?(Array)
+ key = ltn[1]
+ ltn = ltn[0]
+ else
+ key = nil
+ end
+
+ optkeys = __font_optkeys
+ if key && !optkeys.find{|opt| opt.to_s == key.to_s}
+ fail ArgumentError, "unknown font option name `#{key}'"
+ end
+
+ win, tag = __pathname.split(':')
+
+ optkeys = [key] if key
+
+ optkeys.each{|optkey|
+ optkey = optkey.to_s
+
+ pathname = [win, tag, optkey].join(';')
+
+ if (fobj = TkFont.used_on(pathname))
+ fobj = TkFont.new(fobj) # create a new TkFont object
+ elsif Tk::JAPANIZED_TK
+ fobj = fontobj # create a new TkFont object
+ else
+ ltn = hash_kv(ltn) if ltn.kind_of?(Hash)
+ unless TkConfigMethod.__IGNORE_UNKNOWN_CONFIGURE_OPTION__
+ tk_call(*(__config_cmd << "-#{optkey}" << ltn))
+ else
+ begin
+ tk_call(*(__config_cmd << "-#{optkey}" << ltn))
+ rescue => e
+ # ignore
+ end
+ end
+ next
+ end
+
+ if fobj.kind_of?(TkFont)
+ if ltn.kind_of?(TkFont)
+ conf = {}
+ ltn.latin_configinfo.each{|k,val| conf[k] = val}
+ if keys
+ fobj.latin_configure(conf.update(keys))
+ else
+ fobj.latin_configure(conf)
+ end
+ else
+ fobj.latin_replace(ltn)
+ end
+ end
+
+ fobj.call_font_configure([pathname, optkey], *(__config_cmd << {}))
+ }
+ self
+ end
+ alias asciifont_configure latinfont_configure
+
+ def kanjifont_configure(knj, keys=nil)
+ if knj.kind_of?(Array)
+ key = knj[1]
+ knj = knj[0]
+ else
+ key = nil
+ end
+
+ optkeys = __font_optkeys
+ if key && !optkeys.find{|opt| opt.to_s == key.to_s}
+ fail ArgumentError, "unknown font option name `#{key}'"
+ end
+
+ win, tag = __pathname.split(':')
+
+ optkeys = [key] if key
+
+ optkeys.each{|optkey|
+ optkey = optkey.to_s
+
+ pathname = [win, tag, optkey].join(';')
+
+ if (fobj = TkFont.used_on(pathname))
+ fobj = TkFont.new(fobj) # create a new TkFont object
+ elsif Tk::JAPANIZED_TK
+ fobj = fontobj # create a new TkFont object
+ else
+ knj = hash_kv(knj) if knj.kind_of?(Hash)
+ unless TkConfigMethod.__IGNORE_UNKNOWN_CONFIGURE_OPTION__
+ tk_call(*(__config_cmd << "-#{optkey}" << knj))
+ else
+ begin
+ tk_call(*(__config_cmd << "-#{optkey}" << knj))
+ rescue => e
+ # ignore
+ end
+ end
+ next
+ end
+
+ if fobj.kind_of?(TkFont)
+ if knj.kind_of?(TkFont)
+ conf = {}
+ knj.kanji_configinfo.each{|k,val| conf[k] = val}
+ if keys
+ fobj.kanji_configure(conf.update(keys))
+ else
+ fobj.kanji_configure(conf)
+ end
+ else
+ fobj.kanji_replace(knj)
+ end
+ end
+
+ fobj.call_font_configure([pathname, optkey], *(__config_cmd << {}))
+ }
+ self
+ end
+
+ def font_copy(win, wintag=nil, winkey=nil, targetkey=nil)
+ if wintag
+ if winkey
+ fnt = win.tagfontobj(wintag, winkey).dup
+ else
+ fnt = win.tagfontobj(wintag).dup
+ end
+ else
+ if winkey
+ fnt = win.fontobj(winkey).dup
+ else
+ fnt = win.fontobj.dup
+ end
+ end
+
+ if targetkey
+ fnt.call_font_configure([__pathname, targetkey], *(__config_cmd << {}))
+ else
+ fnt.call_font_configure(__pathname, *(__config_cmd << {}))
+ end
+ self
+ end
+
+ def latinfont_copy(win, wintag=nil, winkey=nil, targetkey=nil)
+ if targetkey
+ fontobj(targetkey).dup.call_font_configure([__pathname, targetkey],
+ *(__config_cmd << {}))
+ else
+ fontobj.dup.call_font_configure(__pathname, *(__config_cmd << {}))
+ end
+
+ if wintag
+ if winkey
+ fontobj.latin_replace(win.tagfontobj(wintag, winkey).latin_font_id)
+ else
+ fontobj.latin_replace(win.tagfontobj(wintag).latin_font_id)
+ end
+ else
+ if winkey
+ fontobj.latin_replace(win.fontobj(winkey).latin_font_id)
+ else
+ fontobj.latin_replace(win.fontobj.latin_font_id)
+ end
+ end
+ self
+ end
+ alias asciifont_copy latinfont_copy
+
+ def kanjifont_copy(win, wintag=nil, winkey=nil, targetkey=nil)
+ if targetkey
+ fontobj(targetkey).dup.call_font_configure([__pathname, targetkey],
+ *(__config_cmd << {}))
+ else
+ fontobj.dup.call_font_configure(__pathname, *(__config_cmd << {}))
+ end
+
+ if wintag
+ if winkey
+ fontobj.kanji_replace(win.tagfontobj(wintag, winkey).kanji_font_id)
+ else
+ fontobj.kanji_replace(win.tagfontobj(wintag).kanji_font_id)
+ end
+ else
+ if winkey
+ fontobj.kanji_replace(win.fontobj(winkey).kanji_font_id)
+ else
+ fontobj.kanji_replace(win.fontobj.kanji_font_id)
+ end
+ end
+ self
+ end
+end
+
+
+module TkConfigMethod
+ include TkUtil
+ include TkTreatFont
+
+ def TkConfigMethod.__IGNORE_UNKNOWN_CONFIGURE_OPTION__
+ @mode || false
+ end
+ def TkConfigMethod.__set_IGNORE_UNKNOWN_CONFIGURE_OPTION__!(mode)
+ fail SecurityError, "can't change the mode" if $SAFE>=4
+ @mode = (mode)? true: false
+ end
+
+ def __cget_cmd
+ [self.path, 'cget']
+ end
+ private :__cget_cmd
+
+ def __config_cmd
+ [self.path, 'configure']
+ end
+ private :__config_cmd
+
+ def __confinfo_cmd
+ __config_cmd
+ end
+ private :__confinfo_cmd
+
+ def __configinfo_struct
+ {:key=>0, :alias=>1, :db_name=>1, :db_class=>2,
+ :default_value=>3, :current_value=>4}
+ end
+ private :__configinfo_struct
+
+ def __optkey_aliases
+ {}
+ end
+ private :__optkey_aliases
+
+ def __numval_optkeys
+ []
+ end
+ private :__numval_optkeys
+
+ def __numstrval_optkeys
+ []
+ end
+ private :__numstrval_optkeys
+
+ def __boolval_optkeys
+ ['exportselection', 'jump', 'setgrid', 'takefocus']
+ end
+ private :__boolval_optkeys
+
+ def __strval_optkeys
+ [
+ 'text', 'label', 'show', 'data', 'file',
+ 'activebackground', 'activeforeground', 'background',
+ 'disabledforeground', 'disabledbackground', 'foreground',
+ 'highlightbackground', 'highlightcolor', 'insertbackground',
+ 'selectbackground', 'selectforeground', 'troughcolor'
+ ]
+ end
+ private :__strval_optkeys
+
+ def __listval_optkeys
+ []
+ end
+ private :__listval_optkeys
+
+ def __numlistval_optkeys
+ []
+ end
+ private :__numlistval_optkeys
+
+ def __tkvariable_optkeys
+ ['variable', 'textvariable']
+ end
+ private :__tkvariable_optkeys
+
+ def __val2ruby_optkeys # { key=>proc, ... }
+ # The method is used to convert a opt-value to a ruby's object.
+ # When get the value of the option "key", "proc.call(value)" is called.
+ {}
+ end
+ private :__val2ruby_optkeys
+
+ def __ruby2val_optkeys # { key=>proc, ... }
+ # The method is used to convert a ruby's object to a opt-value.
+ # When set the value of the option "key", "proc.call(value)" is called.
+ # That is, "-#{key} #{proc.call(value)}".
+ {}
+ end
+ private :__ruby2val_optkeys
+
+ def __methodcall_optkeys # { key=>method, ... }
+ # The method is used to both of get and set.
+ # Usually, the 'key' will not be a widget option.
+ {}
+ end
+ private :__methodcall_optkeys
+
+ def __keyonly_optkeys # { def_key=>undef_key or nil, ... }
+ {}
+ end
+ private :__keyonly_optkeys
+
+ def __conv_keyonly_opts(keys)
+ return keys unless keys.kind_of?(Hash)
+ keyonly = __keyonly_optkeys
+ keys2 = {}
+ keys.each{|k, v|
+ optkey = keyonly.find{|kk,vv| kk.to_s == k.to_s}
+ if optkey
+ defkey, undefkey = optkey
+ if v
+ keys2[defkey.to_s] = None
+ elsif undefkey
+ keys2[undefkey.to_s] = None
+ else
+ # remove key
+ end
+ else
+ keys2[k.to_s] = v
+ end
+ }
+ keys2
+ end
+ private :__conv_keyonly_opts
+
+ def config_hash_kv(keys, enc_mode = nil, conf = nil)
+ hash_kv(__conv_keyonly_opts(keys), enc_mode, conf)
+ end
+
+ ################################
+
+ def [](id)
+ cget(id)
+ end
+
+ def []=(id, val)
+ configure(id, val)
+ val
+ end
+
+ def cget_tkstring(option)
+ opt = option.to_s
+ fail ArgumentError, "Invalid option `#{option.inspect}'" if opt.length == 0
+ tk_call_without_enc(*(__cget_cmd << "-#{opt}"))
+ end
+
+ def __cget_core(slot)
+ orig_slot = slot
+ slot = slot.to_s
+
+ if slot.length == 0
+ fail ArgumentError, "Invalid option `#{orig_slot.inspect}'"
+ end
+
+ alias_name, real_name = __optkey_aliases.find{|k, v| k.to_s == slot}
+ if real_name
+ slot = real_name.to_s
+ end
+
+ if ( method = _symbolkey2str(__val2ruby_optkeys())[slot] )
+ optval = tk_call_without_enc(*(__cget_cmd << "-#{slot}"))
+ begin
+ return method.call(optval)
+ rescue => e
+ warn("Warning:: #{e.message} (when #{method}.call(#{optval.inspect})") if $DEBUG
+ return optval
+ end
+ end
+
+ if ( method = _symbolkey2str(__methodcall_optkeys)[slot] )
+ return self.__send__(method)
+ end
+
+ case slot
+ when /^(#{__numval_optkeys.join('|')})$/
+ begin
+ number(tk_call_without_enc(*(__cget_cmd << "-#{slot}")))
+ rescue
+ nil
+ end
+
+ when /^(#{__numstrval_optkeys.join('|')})$/
+ num_or_str(tk_call_without_enc(*(__cget_cmd << "-#{slot}")))
+
+ when /^(#{__boolval_optkeys.join('|')})$/
+ begin
+ bool(tk_call_without_enc(*(__cget_cmd << "-#{slot}")))
+ rescue
+ nil
+ end
+
+ when /^(#{__listval_optkeys.join('|')})$/
+ simplelist(tk_call_without_enc(*(__cget_cmd << "-#{slot}")))
+
+ when /^(#{__numlistval_optkeys.join('|')})$/
+ conf = tk_call_without_enc(*(__cget_cmd << "-#{slot}"))
+ if conf =~ /^[0-9+-]/
+ list(conf)
+ else
+ conf
+ end
+
+ when /^(#{__strval_optkeys.join('|')})$/
+ _fromUTF8(tk_call_without_enc(*(__cget_cmd << "-#{slot}")))
+
+ when /^(|latin|ascii|kanji)(#{__font_optkeys.join('|')})$/
+ fontcode = $1
+ fontkey = $2
+ fnt = tk_tcl2ruby(tk_call_without_enc(*(__cget_cmd << "-#{fontkey}")), true)
+ unless fnt.kind_of?(TkFont)
+ fnt = fontobj(fontkey)
+ end
+ if fontcode == 'kanji' && JAPANIZED_TK && TK_VERSION =~ /^4\.*/
+ # obsolete; just for compatibility
+ fnt.kanji_font
+ else
+ fnt
+ end
+
+ when /^(#{__tkvariable_optkeys.join('|')})$/
+ v = tk_call_without_enc(*(__cget_cmd << "-#{slot}"))
+ (v.empty?)? nil: TkVarAccess.new(v)
+
+ else
+ tk_tcl2ruby(tk_call_without_enc(*(__cget_cmd << "-#{slot}")), true)
+ end
+ end
+ private :__cget_core
+
+ def cget(slot)
+ unless TkConfigMethod.__IGNORE_UNKNOWN_CONFIGURE_OPTION__
+ __cget_core(slot)
+ else
+ begin
+ __cget_core(slot)
+ rescue => e
+ if current_configinfo.has_key?(slot.to_s)
+ # error on known option
+ fail e
+ else
+ # unknown option
+ nil
+ end
+ end
+ end
+ end
+ def cget_strict(slot)
+ # never use TkConfigMethod.__IGNORE_UNKNOWN_CONFIGURE_OPTION__
+ __cget_core(slot)
+ end
+
+ def __configure_core(slot, value=None)
+ if slot.kind_of? Hash
+ slot = _symbolkey2str(slot)
+
+ __optkey_aliases.each{|alias_name, real_name|
+ alias_name = alias_name.to_s
+ if slot.has_key?(alias_name)
+ slot[real_name.to_s] = slot.delete(alias_name)
+ end
+ }
+
+ __methodcall_optkeys.each{|key, method|
+ value = slot.delete(key.to_s)
+ self.__send__(method, value) if value
+ }
+
+ __ruby2val_optkeys.each{|key, method|
+ key = key.to_s
+ slot[key] = method.call(slot[key]) if slot.has_key?(key)
+ }
+
+ __keyonly_optkeys.each{|defkey, undefkey|
+ conf = slot.find{|kk, vv| kk == defkey.to_s}
+ if conf
+ k, v = conf
+ if v
+ slot[k] = None
+ else
+ slot[undefkey.to_s] = None if undefkey
+ slot.delete(k)
+ end
+ end
+ }
+
+ if (slot.find{|k, v| k =~ /^(|latin|ascii|kanji)(#{__font_optkeys.join('|')})$/})
+ font_configure(slot)
+ elsif slot.size > 0
+ tk_call(*(__config_cmd.concat(hash_kv(slot))))
+ end
+
+ else
+ orig_slot = slot
+ slot = slot.to_s
+ if slot.length == 0
+ fail ArgumentError, "Invalid option `#{orig_slot.inspect}'"
+ end
+
+ alias_name, real_name = __optkey_aliases.find{|k, v| k.to_s == slot}
+ if real_name
+ slot = real_name.to_s
+ end
+
+ if ( conf = __keyonly_optkeys.find{|k, v| k.to_s == slot} )
+ defkey, undefkey = conf
+ if value
+ tk_call(*(__config_cmd << "-#{defkey}"))
+ elsif undefkey
+ tk_call(*(__config_cmd << "-#{undefkey}"))
+ end
+ elsif ( method = _symbolkey2str(__ruby2val_optkeys)[slot] )
+ tk_call(*(__config_cmd << "-#{slot}" << method.call(value)))
+ elsif ( method = _symbolkey2str(__methodcall_optkeys)[slot] )
+ self.__send__(method, value)
+ elsif (slot =~ /^(|latin|ascii|kanji)(#{__font_optkeys.join('|')})$/)
+ if value == None
+ fontobj($2)
+ else
+ font_configure({slot=>value})
+ end
+ else
+ tk_call(*(__config_cmd << "-#{slot}" << value))
+ end
+ end
+ self
+ end
+ private :__configure_core
+
+ def __check_available_configure_options(keys)
+ availables = self.current_configinfo.keys
+
+ # add non-standard keys
+ availables |= __font_optkeys.map{|k|
+ [k.to_s, "latin#{k}", "ascii#{k}", "kanji#{k}"]
+ }.flatten
+ availables |= __methodcall_optkeys.keys.map{|k| k.to_s}
+ availables |= __keyonly_optkeys.keys.map{|k| k.to_s}
+
+ keys = _symbolkey2str(keys)
+ keys.delete_if{|k, v| !(availables.include?(k))}
+ end
+
+ def configure(slot, value=None)
+ unless TkConfigMethod.__IGNORE_UNKNOWN_CONFIGURE_OPTION__
+ __configure_core(slot, value)
+ else
+ if slot.kind_of?(Hash)
+ begin
+ __configure_core(slot)
+ rescue
+ slot = __check_available_configure_options(slot)
+ __configure_core(slot) unless slot.empty?
+ end
+ else
+ begin
+ __configure_core(slot, value)
+ rescue => e
+ if current_configinfo.has_key?(slot.to_s)
+ # error on known option
+ fail e
+ else
+ # unknown option
+ nil
+ end
+ end
+ end
+ end
+ self
+ end
+
+ def configure_cmd(slot, value)
+ configure(slot, install_cmd(value))
+ end
+
+ def __configinfo_core(slot = nil)
+ if TkComm::GET_CONFIGINFO_AS_ARRAY
+ if (slot &&
+ slot.to_s =~ /^(|latin|ascii|kanji)(#{__font_optkeys.join('|')})$/)
+ fontkey = $2
+ # conf = tk_split_simplelist(_fromUTF8(tk_call_without_enc(*(__confinfo_cmd << "-#{fontkey}"))))
+ conf = tk_split_simplelist(tk_call_without_enc(*(__confinfo_cmd << "-#{fontkey}")), false, true)
+ conf[__configinfo_struct[:key]] =
+ conf[__configinfo_struct[:key]][1..-1]
+ if ( ! __configinfo_struct[:alias] \
+ || conf.size > __configinfo_struct[:alias] + 1 )
+ fnt = conf[__configinfo_struct[:default_value]]
+ if TkFont.is_system_font?(fnt)
+ conf[__configinfo_struct[:default_value]] = TkNamedFont.new(fnt)
+ end
+ conf[__configinfo_struct[:current_value]] = fontobj(fontkey)
+ elsif ( __configinfo_struct[:alias] \
+ && conf.size == __configinfo_struct[:alias] + 1 \
+ && conf[__configinfo_struct[:alias]][0] == ?- )
+ conf[__configinfo_struct[:alias]] =
+ conf[__configinfo_struct[:alias]][1..-1]
+ end
+ conf
+ else
+ if slot
+ slot = slot.to_s
+
+ alias_name, real_name = __optkey_aliases.find{|k, v| k.to_s == slot}
+ if real_name
+ slot = real_name.to_s
+ end
+
+ case slot
+ when /^(#{__val2ruby_optkeys().keys.join('|')})$/
+ method = _symbolkey2str(__val2ruby_optkeys())[slot]
+ conf = tk_split_simplelist(tk_call_without_enc(*(__confinfo_cmd() << "-#{slot}")), false, true)
+ if ( __configinfo_struct[:default_value] \
+ && conf[__configinfo_struct[:default_value]] )
+ optval = conf[__configinfo_struct[:default_value]]
+ begin
+ val = method.call(optval)
+ rescue => e
+ warn("Warning:: #{e.message} (when #{method}.call(#{optval.inspect})") if $DEBUG
+ val = optval
+ end
+ conf[__configinfo_struct[:default_value]] = val
+ end
+ if ( conf[__configinfo_struct[:current_value]] )
+ optval = conf[__configinfo_struct[:current_value]]
+ begin
+ val = method.call(optval)
+ rescue => e
+ warn("Warning:: #{e.message} (when #{method}.call(#{optval.inspect})") if $DEBUG
+ val = optval
+ end
+ conf[__configinfo_struct[:current_value]] = val
+ end
+
+ when /^(#{__methodcall_optkeys.keys.join('|')})$/
+ method = _symbolkey2str(__methodcall_optkeys)[slot]
+ return [slot, '', '', '', self.__send__(method)]
+
+ when /^(#{__numval_optkeys.join('|')})$/
+ # conf = tk_split_simplelist(_fromUTF8(tk_call_without_enc(*(__confinfo_cmd << "-#{slot}"))))
+ conf = tk_split_simplelist(tk_call_without_enc(*(__confinfo_cmd << "-#{slot}")), false, true)
+
+ if ( __configinfo_struct[:default_value] \
+ && conf[__configinfo_struct[:default_value]])
+ begin
+ conf[__configinfo_struct[:default_value]] =
+ number(conf[__configinfo_struct[:default_value]])
+ rescue
+ conf[__configinfo_struct[:default_value]] = nil
+ end
+ end
+ if ( conf[__configinfo_struct[:current_value]] )
+ begin
+ conf[__configinfo_struct[:current_value]] =
+ number(conf[__configinfo_struct[:current_value]])
+ rescue
+ conf[__configinfo_struct[:current_value]] = nil
+ end
+ end
+
+ when /^(#{__numstrval_optkeys.join('|')})$/
+ # conf = tk_split_simplelist(_fromUTF8(tk_call_without_enc(*(__confinfo_cmd << "-#{slot}"))))
+ conf = tk_split_simplelist(tk_call_without_enc(*(__confinfo_cmd << "-#{slot}")), false, true)
+
+ if ( __configinfo_struct[:default_value] \
+ && conf[__configinfo_struct[:default_value]])
+ conf[__configinfo_struct[:default_value]] =
+ num_or_str(conf[__configinfo_struct[:default_value]])
+ end
+ if ( conf[__configinfo_struct[:current_value]] )
+ conf[__configinfo_struct[:current_value]] =
+ num_or_str(conf[__configinfo_struct[:current_value]])
+ end
+
+ when /^(#{__boolval_optkeys.join('|')})$/
+ # conf = tk_split_simplelist(_fromUTF8(tk_call_without_enc(*(__confinfo_cmd << "-#{slot}"))))
+ conf = tk_split_simplelist(tk_call_without_enc(*(__confinfo_cmd << "-#{slot}")), false, true)
+
+ if ( __configinfo_struct[:default_value] \
+ && conf[__configinfo_struct[:default_value]])
+ begin
+ conf[__configinfo_struct[:default_value]] =
+ bool(conf[__configinfo_struct[:default_value]])
+ rescue
+ conf[__configinfo_struct[:default_value]] = nil
+ end
+ end
+ if ( conf[__configinfo_struct[:current_value]] )
+ begin
+ conf[__configinfo_struct[:current_value]] =
+ bool(conf[__configinfo_struct[:current_value]])
+ rescue
+ conf[__configinfo_struct[:current_value]] = nil
+ end
+ end
+
+ when /^(#{__listval_optkeys.join('|')})$/
+ # conf = tk_split_simplelist(_fromUTF8(tk_call_without_enc(*(__confinfo_cmd << "-#{slot}"))))
+ conf = tk_split_simplelist(tk_call_without_enc(*(__confinfo_cmd << "-#{slot}")), false, true)
+
+ if ( __configinfo_struct[:default_value] \
+ && conf[__configinfo_struct[:default_value]])
+ conf[__configinfo_struct[:default_value]] =
+ simplelist(conf[__configinfo_struct[:default_value]])
+ end
+ if ( conf[__configinfo_struct[:current_value]] )
+ conf[__configinfo_struct[:current_value]] =
+ simplelist(conf[__configinfo_struct[:current_value]])
+ end
+
+ when /^(#{__numlistval_optkeys.join('|')})$/
+ # conf = tk_split_simplelist(_fromUTF8(tk_call_without_enc(*(__confinfo_cmd << "-#{slot}"))))
+ conf = tk_split_simplelist(tk_call_without_enc(*(__confinfo_cmd << "-#{slot}")), false, true)
+
+ if ( __configinfo_struct[:default_value] \
+ && conf[__configinfo_struct[:default_value]] \
+ && conf[__configinfo_struct[:default_value]] =~ /^[0-9]/ )
+ conf[__configinfo_struct[:default_value]] =
+ list(conf[__configinfo_struct[:default_value]])
+ end
+ if ( conf[__configinfo_struct[:current_value]] \
+ && conf[__configinfo_struct[:current_value]] =~ /^[0-9]/ )
+ conf[__configinfo_struct[:current_value]] =
+ list(conf[__configinfo_struct[:current_value]])
+ end
+
+ when /^(#{__strval_optkeys.join('|')})$/
+ # conf = tk_split_simplelist(_fromUTF8(tk_call_without_enc(*(__confinfo_cmd << "-#{slot}"))))
+ conf = tk_split_simplelist(tk_call_without_enc(*(__confinfo_cmd << "-#{slot}")), false, true)
+
+ when /^(#{__tkvariable_optkeys.join('|')})$/
+ conf = tk_split_simplelist(tk_call_without_enc(*(__confinfo_cmd << "-#{slot}")), false, true)
+
+ if ( __configinfo_struct[:default_value] \
+ && conf[__configinfo_struct[:default_value]])
+ v = conf[__configinfo_struct[:default_value]]
+ if v.empty?
+ conf[__configinfo_struct[:default_value]] = nil
+ else
+ conf[__configinfo_struct[:default_value]] = TkVarAccess.new(v)
+ end
+ end
+ if ( conf[__configinfo_struct[:current_value]] )
+ v = conf[__configinfo_struct[:current_value]]
+ if v.empty?
+ conf[__configinfo_struct[:current_value]] = nil
+ else
+ conf[__configinfo_struct[:current_value]] = TkVarAccess.new(v)
+ end
+ end
+
+ else
+ # conf = tk_split_list(_fromUTF8(tk_call_without_enc(*(__confinfo_cmd << "-#{slot}"))))
+ # conf = tk_split_list(tk_call_without_enc(*(__confinfo_cmd << "-#{slot}")), 0, false, true)
+ conf = tk_split_list(tk_call_without_enc(*(__confinfo_cmd << "-#{slot}")), 1, false, true)
+ end
+ conf[__configinfo_struct[:key]] =
+ conf[__configinfo_struct[:key]][1..-1]
+
+ if ( __configinfo_struct[:alias] \
+ && conf.size == __configinfo_struct[:alias] + 1 \
+ && conf[__configinfo_struct[:alias]][0] == ?- )
+ conf[__configinfo_struct[:alias]] =
+ conf[__configinfo_struct[:alias]][1..-1]
+ end
+
+ conf
+
+ else
+ # ret = tk_split_simplelist(_fromUTF8(tk_call_without_enc(*__confinfo_cmd))).collect{|conflist|
+ # conf = tk_split_simplelist(conflist)
+ ret = tk_split_simplelist(tk_call_without_enc(*__confinfo_cmd), false, false).collect{|conflist|
+ conf = tk_split_simplelist(conflist, false, true)
+ conf[__configinfo_struct[:key]] =
+ conf[__configinfo_struct[:key]][1..-1]
+
+ optkey = conf[__configinfo_struct[:key]]
+ case optkey
+ when /^(#{__val2ruby_optkeys().keys.join('|')})$/
+ method = _symbolkey2str(__val2ruby_optkeys())[optkey]
+ if ( __configinfo_struct[:default_value] \
+ && conf[__configinfo_struct[:default_value]] )
+ optval = conf[__configinfo_struct[:default_value]]
+ begin
+ val = method.call(optval)
+ rescue => e
+ warn("Warning:: #{e.message} (when #{method}.call(#{optval.inspect})") if $DEBUG
+ val = optval
+ end
+ conf[__configinfo_struct[:default_value]] = val
+ end
+ if ( conf[__configinfo_struct[:current_value]] )
+ optval = conf[__configinfo_struct[:current_value]]
+ begin
+ val = method.call(optval)
+ rescue => e
+ warn("Warning:: #{e.message} (when #{method}.call(#{optval.inspect})") if $DEBUG
+ val = optval
+ end
+ conf[__configinfo_struct[:current_value]] = val
+ end
+
+ when /^(#{__strval_optkeys.join('|')})$/
+ # do nothing
+
+ when /^(#{__numval_optkeys.join('|')})$/
+ if ( __configinfo_struct[:default_value] \
+ && conf[__configinfo_struct[:default_value]] )
+ begin
+ conf[__configinfo_struct[:default_value]] =
+ number(conf[__configinfo_struct[:default_value]])
+ rescue
+ conf[__configinfo_struct[:default_value]] = nil
+ end
+ end
+ if ( conf[__configinfo_struct[:current_value]] )
+ begin
+ conf[__configinfo_struct[:current_value]] =
+ number(conf[__configinfo_struct[:current_value]])
+ rescue
+ conf[__configinfo_struct[:current_value]] = nil
+ end
+ end
+
+ when /^(#{__numstrval_optkeys.join('|')})$/
+ if ( __configinfo_struct[:default_value] \
+ && conf[__configinfo_struct[:default_value]] )
+ conf[__configinfo_struct[:default_value]] =
+ num_or_str(conf[__configinfo_struct[:default_value]])
+ end
+ if ( conf[__configinfo_struct[:current_value]] )
+ conf[__configinfo_struct[:current_value]] =
+ num_or_str(conf[__configinfo_struct[:current_value]])
+ end
+
+ when /^(#{__boolval_optkeys.join('|')})$/
+ if ( __configinfo_struct[:default_value] \
+ && conf[__configinfo_struct[:default_value]] )
+ begin
+ conf[__configinfo_struct[:default_value]] =
+ bool(conf[__configinfo_struct[:default_value]])
+ rescue
+ conf[__configinfo_struct[:default_value]] = nil
+ end
+ end
+ if ( conf[__configinfo_struct[:current_value]] )
+ begin
+ conf[__configinfo_struct[:current_value]] =
+ bool(conf[__configinfo_struct[:current_value]])
+ rescue
+ conf[__configinfo_struct[:current_value]] = nil
+ end
+ end
+
+ when /^(#{__listval_optkeys.join('|')})$/
+ if ( __configinfo_struct[:default_value] \
+ && conf[__configinfo_struct[:default_value]] )
+ conf[__configinfo_struct[:default_value]] =
+ simplelist(conf[__configinfo_struct[:default_value]])
+ end
+ if ( conf[__configinfo_struct[:current_value]] )
+ conf[__configinfo_struct[:current_value]] =
+ simplelist(conf[__configinfo_struct[:current_value]])
+ end
+
+ when /^(#{__numlistval_optkeys.join('|')})$/
+ if ( __configinfo_struct[:default_value] \
+ && conf[__configinfo_struct[:default_value]] \
+ && conf[__configinfo_struct[:default_value]] =~ /^[0-9]/ )
+ conf[__configinfo_struct[:default_value]] =
+ list(conf[__configinfo_struct[:default_value]])
+ end
+ if ( conf[__configinfo_struct[:current_value]] \
+ && conf[__configinfo_struct[:current_value]] =~ /^[0-9]/ )
+ conf[__configinfo_struct[:current_value]] =
+ list(conf[__configinfo_struct[:current_value]])
+ end
+
+ when /^(#{__tkvariable_optkeys.join('|')})$/
+ if ( __configinfo_struct[:default_value] \
+ && conf[__configinfo_struct[:default_value]] )
+ v = conf[__configinfo_struct[:default_value]]
+ if v.empty?
+ conf[__configinfo_struct[:default_value]] = nil
+ else
+ conf[__configinfo_struct[:default_value]] = TkVarAccess.new(v)
+ end
+ end
+ if ( conf[__configinfo_struct[:current_value]] )
+ v = conf[__configinfo_struct[:current_value]]
+ if v.empty?
+ conf[__configinfo_struct[:current_value]] = nil
+ else
+ conf[__configinfo_struct[:current_value]] = TkVarAccess.new(v)
+ end
+ end
+
+ else
+ if ( __configinfo_struct[:default_value] \
+ && conf[__configinfo_struct[:default_value]] )
+ if conf[__configinfo_struct[:default_value]].index('{')
+ conf[__configinfo_struct[:default_value]] =
+ tk_split_list(conf[__configinfo_struct[:default_value]])
+ else
+ conf[__configinfo_struct[:default_value]] =
+ tk_tcl2ruby(conf[__configinfo_struct[:default_value]])
+ end
+ end
+ if conf[__configinfo_struct[:current_value]]
+ if conf[__configinfo_struct[:current_value]].index('{')
+ conf[__configinfo_struct[:current_value]] =
+ tk_split_list(conf[__configinfo_struct[:current_value]])
+ else
+ conf[__configinfo_struct[:current_value]] =
+ tk_tcl2ruby(conf[__configinfo_struct[:current_value]])
+ end
+ end
+ end
+
+ if ( __configinfo_struct[:alias] \
+ && conf.size == __configinfo_struct[:alias] + 1 \
+ && conf[__configinfo_struct[:alias]][0] == ?- )
+ conf[__configinfo_struct[:alias]] =
+ conf[__configinfo_struct[:alias]][1..-1]
+ end
+
+ conf
+ }
+
+ __font_optkeys.each{|optkey|
+ optkey = optkey.to_s
+ fontconf = ret.assoc(optkey)
+ if fontconf && fontconf.size > 2
+ ret.delete_if{|inf| inf[0] =~ /^(|latin|ascii|kanji)#{optkey}$/}
+ fnt = fontconf[__configinfo_struct[:default_value]]
+ if TkFont.is_system_font?(fnt)
+ fontconf[__configinfo_struct[:default_value]] \
+ = TkNamedFont.new(fnt)
+ end
+ fontconf[__configinfo_struct[:current_value]] = fontobj(optkey)
+ ret.push(fontconf)
+ end
+ }
+
+ __methodcall_optkeys.each{|optkey, m|
+ ret << [optkey.to_s, '', '', '', self.__send__(m)]
+ }
+
+ ret
+ end
+ end
+
+ else # ! TkComm::GET_CONFIGINFO_AS_ARRAY
+ if (slot &&
+ slot.to_s =~ /^(|latin|ascii|kanji)(#{__font_optkeys.join('|')})$/)
+ fontkey = $2
+ # conf = tk_split_simplelist(_fromUTF8(tk_call_without_enc(*(__confinfo_cmd << "-#{fontkey}"))))
+ conf = tk_split_simplelist(tk_call_without_enc(*(__confinfo_cmd << "-#{fontkey}")), false, true)
+ conf[__configinfo_struct[:key]] =
+ conf[__configinfo_struct[:key]][1..-1]
+
+ if ( ! __configinfo_struct[:alias] \
+ || conf.size > __configinfo_struct[:alias] + 1 )
+ fnt = conf[__configinfo_struct[:default_value]]
+ if TkFont.is_system_font?(fnt)
+ conf[__configinfo_struct[:default_value]] = TkNamedFont.new(fnt)
+ end
+ conf[__configinfo_struct[:current_value]] = fontobj(fontkey)
+ { conf.shift => conf }
+ elsif ( __configinfo_struct[:alias] \
+ && conf.size == __configinfo_struct[:alias] + 1 )
+ if conf[__configinfo_struct[:alias]][0] == ?-
+ conf[__configinfo_struct[:alias]] =
+ conf[__configinfo_struct[:alias]][1..-1]
+ end
+ { conf[0] => conf[1] }
+ else
+ { conf.shift => conf }
+ end
+ else
+ if slot
+ slot = slot.to_s
+
+ alias_name, real_name = __optkey_aliases.find{|k,var| k.to_s == slot}
+ if real_name
+ slot = real_name.to_s
+ end
+
+ case slot
+ when /^(#{__val2ruby_optkeys().keys.join('|')})$/
+ method = _symbolkey2str(__val2ruby_optkeys())[slot]
+ conf = tk_split_simplelist(tk_call_without_enc(*(__confinfo_cmd << "-#{slot}")), false, true)
+ if ( __configinfo_struct[:default_value] \
+ && conf[__configinfo_struct[:default_value]] )
+ optval = conf[__configinfo_struct[:default_value]]
+ begin
+ val = method.call(optval)
+ rescue => e
+ warn("Warning:: #{e.message} (when #{method}.call(#{optval.inspect})") if $DEBUG
+ val = optval
+ end
+ conf[__configinfo_struct[:default_value]] = val
+ end
+ if ( conf[__configinfo_struct[:current_value]] )
+ optval = conf[__configinfo_struct[:current_value]]
+ begin
+ val = method.call(optval)
+ rescue => e
+ warn("Warning:: #{e.message} (when #{method}.call(#{optval.inspect})") if $DEBUG
+ val = optval
+ end
+ conf[__configinfo_struct[:current_value]] = val
+ end
+
+ when /^(#{__methodcall_optkeys.keys.join('|')})$/
+ method = _symbolkey2str(__methodcall_optkeys)[slot]
+ return {slot => ['', '', '', self.__send__(method)]}
+
+ when /^(#{__numval_optkeys.join('|')})$/
+ # conf = tk_split_simplelist(_fromUTF8(tk_call_without_enc(*(__confinfo_cmd << "-#{slot}"))))
+ conf = tk_split_simplelist(tk_call_without_enc(*(__confinfo_cmd << "-#{slot}")), false, true)
+
+ if ( __configinfo_struct[:default_value] \
+ && conf[__configinfo_struct[:default_value]] )
+ begin
+ conf[__configinfo_struct[:default_value]] =
+ number(conf[__configinfo_struct[:default_value]])
+ rescue
+ conf[__configinfo_struct[:default_value]] = nil
+ end
+ end
+ if ( conf[__configinfo_struct[:current_value]] )
+ begin
+ conf[__configinfo_struct[:current_value]] =
+ number(conf[__configinfo_struct[:current_value]])
+ rescue
+ conf[__configinfo_struct[:current_value]] = nil
+ end
+ end
+
+ when /^(#{__numstrval_optkeys.join('|')})$/
+ # conf = tk_split_simplelist(_fromUTF8(tk_call_without_enc(*(__confinfo_cmd << "-#{slot}"))))
+ conf = tk_split_simplelist(tk_call_without_enc(*(__confinfo_cmd << "-#{slot}")), false, true)
+
+ if ( __configinfo_struct[:default_value] \
+ && conf[__configinfo_struct[:default_value]] )
+ conf[__configinfo_struct[:default_value]] =
+ num_or_str(conf[__configinfo_struct[:default_value]])
+ end
+ if ( conf[__configinfo_struct[:current_value]] )
+ conf[__configinfo_struct[:current_value]] =
+ num_or_str(conf[__configinfo_struct[:current_value]])
+ end
+
+ when /^(#{__boolval_optkeys.join('|')})$/
+ # conf = tk_split_simplelist(_fromUTF8(tk_call_without_enc(*(__confinfo_cmd << "-#{slot}"))))
+ conf = tk_split_simplelist(tk_call_without_enc(*(__confinfo_cmd << "-#{slot}")), false, true)
+
+ if ( __configinfo_struct[:default_value] \
+ && conf[__configinfo_struct[:default_value]] )
+ begin
+ conf[__configinfo_struct[:default_value]] =
+ bool(conf[__configinfo_struct[:default_value]])
+ rescue
+ conf[__configinfo_struct[:default_value]] = nil
+ end
+ end
+ if ( conf[__configinfo_struct[:current_value]] )
+ begin
+ conf[__configinfo_struct[:current_value]] =
+ bool(conf[__configinfo_struct[:current_value]])
+ rescue
+ conf[__configinfo_struct[:current_value]] = nil
+ end
+ end
+
+ when /^(#{__listval_optkeys.join('|')})$/
+ # conf = tk_split_simplelist(_fromUTF8(tk_call_without_enc(*(__confinfo_cmd << "-#{slot}"))))
+ conf = tk_split_simplelist(tk_call_without_enc(*(__confinfo_cmd << "-#{slot}")), false, true)
+
+ if ( __configinfo_struct[:default_value] \
+ && conf[__configinfo_struct[:default_value]] )
+ conf[__configinfo_struct[:default_value]] =
+ simplelist(conf[__configinfo_struct[:default_value]])
+ end
+ if ( conf[__configinfo_struct[:current_value]] )
+ conf[__configinfo_struct[:current_value]] =
+ simplelist(conf[__configinfo_struct[:current_value]])
+ end
+
+ when /^(#{__numlistval_optkeys.join('|')})$/
+ # conf = tk_split_simplelist(_fromUTF8(tk_call_without_enc(*(__confinfo_cmd << "-#{slot}"))))
+ conf = tk_split_simplelist(tk_call_without_enc(*(__confinfo_cmd << "-#{slot}")), false, true)
+
+ if ( __configinfo_struct[:default_value] \
+ && conf[__configinfo_struct[:default_value]] \
+ && conf[__configinfo_struct[:default_value]] =~ /^[0-9]/ )
+ conf[__configinfo_struct[:default_value]] =
+ list(conf[__configinfo_struct[:default_value]])
+ end
+ if ( conf[__configinfo_struct[:current_value]] \
+ && conf[__configinfo_struct[:current_value]] =~ /^[0-9]/ )
+ conf[__configinfo_struct[:current_value]] =
+ list(conf[__configinfo_struct[:current_value]])
+ end
+
+ when /^(#{__tkvariable_optkeys.join('|')})$/
+ conf = tk_split_simplelist(tk_call_without_enc(*(__confinfo_cmd << "-#{slot}")), false, true)
+
+ if ( __configinfo_struct[:default_value] \
+ && conf[__configinfo_struct[:default_value]] )
+ v = conf[__configinfo_struct[:default_value]]
+ if v.empty?
+ conf[__configinfo_struct[:default_value]] = nil
+ else
+ conf[__configinfo_struct[:default_value]] = TkVarAccess.new(v)
+ end
+ end
+ if ( conf[__configinfo_struct[:current_value]] )
+ v = conf[__configinfo_struct[:current_value]]
+ if v.empty?
+ conf[__configinfo_struct[:current_value]] = nil
+ else
+ conf[__configinfo_struct[:current_value]] = TkVarAccess.new(v)
+ end
+ end
+
+ when /^(#{__strval_optkeys.join('|')})$/
+ # conf = tk_split_simplelist(_fromUTF8(tk_call_without_enc(*(__confinfo_cmd << "-#{slot}"))))
+ conf = tk_split_simplelist(tk_call_without_enc(*(__confinfo_cmd << "-#{slot}")), false, true)
+ else
+ # conf = tk_split_list(_fromUTF8(tk_call_without_enc(*(__confinfo_cmd << "-#{slot}"))))
+ conf = tk_split_list(tk_call_without_enc(*(__confinfo_cmd << "-#{slot}")), 0, false, true)
+ end
+ conf[__configinfo_struct[:key]] =
+ conf[__configinfo_struct[:key]][1..-1]
+
+ if ( __configinfo_struct[:alias] \
+ && conf.size == __configinfo_struct[:alias] + 1 )
+ if conf[__configinfo_struct[:alias]][0] == ?-
+ conf[__configinfo_struct[:alias]] =
+ conf[__configinfo_struct[:alias]][1..-1]
+ end
+ { conf[0] => conf[1] }
+ else
+ { conf.shift => conf }
+ end
+
+ else
+ ret = {}
+ # tk_split_simplelist(_fromUTF8(tk_call_without_enc(*__confinfo_cmd))).each{|conflist|
+ # conf = tk_split_simplelist(conflist)
+ tk_split_simplelist(tk_call_without_enc(*__confinfo_cmd), false, false).each{|conflist|
+ conf = tk_split_simplelist(conflist, false, true)
+ conf[__configinfo_struct[:key]] =
+ conf[__configinfo_struct[:key]][1..-1]
+
+ optkey = conf[__configinfo_struct[:key]]
+ case optkey
+ when /^(#{__val2ruby_optkeys().keys.join('|')})$/
+ method = _symbolkey2str(__val2ruby_optkeys())[optkey]
+ if ( __configinfo_struct[:default_value] \
+ && conf[__configinfo_struct[:default_value]] )
+ optval = conf[__configinfo_struct[:default_value]]
+ begin
+ val = method.call(optval)
+ rescue => e
+ warn("Warning:: #{e.message} (when #{method}.call(#{optval.inspect})") if $DEBUG
+ val = optval
+ end
+ conf[__configinfo_struct[:default_value]] = val
+ end
+ if ( conf[__configinfo_struct[:current_value]] )
+ optval = conf[__configinfo_struct[:current_value]]
+ begin
+ val = method.call(optval)
+ rescue => e
+ warn("Warning:: #{e.message} (when #{method}.call(#{optval.inspect})") if $DEBUG
+ val = optval
+ end
+ conf[__configinfo_struct[:current_value]] = val
+ end
+
+ when /^(#{__strval_optkeys.join('|')})$/
+ # do nothing
+
+ when /^(#{__numval_optkeys.join('|')})$/
+ if ( __configinfo_struct[:default_value] \
+ && conf[__configinfo_struct[:default_value]] )
+ begin
+ conf[__configinfo_struct[:default_value]] =
+ number(conf[__configinfo_struct[:default_value]])
+ rescue
+ conf[__configinfo_struct[:default_value]] = nil
+ end
+ end
+ if ( conf[__configinfo_struct[:current_value]] )
+ begin
+ conf[__configinfo_struct[:current_value]] =
+ number(conf[__configinfo_struct[:current_value]])
+ rescue
+ conf[__configinfo_struct[:current_value]] = nil
+ end
+ end
+
+ when /^(#{__numstrval_optkeys.join('|')})$/
+ if ( __configinfo_struct[:default_value] \
+ && conf[__configinfo_struct[:default_value]] )
+ conf[__configinfo_struct[:default_value]] =
+ num_or_str(conf[__configinfo_struct[:default_value]])
+ end
+ if ( conf[__configinfo_struct[:current_value]] )
+ conf[__configinfo_struct[:current_value]] =
+ num_or_str(conf[__configinfo_struct[:current_value]])
+ end
+
+ when /^(#{__boolval_optkeys.join('|')})$/
+ if ( __configinfo_struct[:default_value] \
+ && conf[__configinfo_struct[:default_value]] )
+ begin
+ conf[__configinfo_struct[:default_value]] =
+ bool(conf[__configinfo_struct[:default_value]])
+ rescue
+ conf[__configinfo_struct[:default_value]] = nil
+ end
+ end
+ if ( conf[__configinfo_struct[:current_value]] )
+ begin
+ conf[__configinfo_struct[:current_value]] =
+ bool(conf[__configinfo_struct[:current_value]])
+ rescue
+ conf[__configinfo_struct[:current_value]] = nil
+ end
+ end
+
+ when /^(#{__listval_optkeys.join('|')})$/
+ if ( __configinfo_struct[:default_value] \
+ && conf[__configinfo_struct[:default_value]] )
+ conf[__configinfo_struct[:default_value]] =
+ simplelist(conf[__configinfo_struct[:default_value]])
+ end
+ if ( conf[__configinfo_struct[:current_value]] )
+ conf[__configinfo_struct[:current_value]] =
+ simplelist(conf[__configinfo_struct[:current_value]])
+ end
+
+ when /^(#{__numlistval_optkeys.join('|')})$/
+ if ( __configinfo_struct[:default_value] \
+ && conf[__configinfo_struct[:default_value]] \
+ && conf[__configinfo_struct[:default_value]] =~ /^[0-9]/ )
+ conf[__configinfo_struct[:default_value]] =
+ list(conf[__configinfo_struct[:default_value]])
+ end
+ if ( conf[__configinfo_struct[:current_value]] \
+ && conf[__configinfo_struct[:current_value]] =~ /^[0-9]/ )
+ conf[__configinfo_struct[:current_value]] =
+ list(conf[__configinfo_struct[:current_value]])
+ end
+
+ when /^(#{__tkvariable_optkeys.join('|')})$/
+ if ( __configinfo_struct[:default_value] \
+ && conf[__configinfo_struct[:default_value]] )
+ v = conf[__configinfo_struct[:default_value]]
+ if v.empty?
+ conf[__configinfo_struct[:default_value]] = nil
+ else
+ conf[__configinfo_struct[:default_value]] = TkVarAccess.new
+ end
+ end
+ if ( conf[__configinfo_struct[:current_value]] )
+ v = conf[__configinfo_struct[:current_value]]
+ if v.empty?
+ conf[__configinfo_struct[:current_value]] = nil
+ else
+ conf[__configinfo_struct[:current_value]] = TkVarAccess.new
+ end
+ end
+
+ else
+ if ( __configinfo_struct[:default_value] \
+ && conf[__configinfo_struct[:default_value]] )
+ if conf[__configinfo_struct[:default_value]].index('{')
+ conf[__configinfo_struct[:default_value]] =
+ tk_split_list(conf[__configinfo_struct[:default_value]])
+ else
+ conf[__configinfo_struct[:default_value]] =
+ tk_tcl2ruby(conf[__configinfo_struct[:default_value]])
+ end
+ end
+ if conf[__configinfo_struct[:current_value]]
+ if conf[__configinfo_struct[:current_value]].index('{')
+ conf[__configinfo_struct[:current_value]] =
+ tk_split_list(conf[__configinfo_struct[:current_value]])
+ else
+ conf[__configinfo_struct[:current_value]] =
+ tk_tcl2ruby(conf[__configinfo_struct[:current_value]])
+ end
+ end
+ end
+
+ if ( __configinfo_struct[:alias] \
+ && conf.size == __configinfo_struct[:alias] + 1 )
+ if conf[__configinfo_struct[:alias]][0] == ?-
+ conf[__configinfo_struct[:alias]] =
+ conf[__configinfo_struct[:alias]][1..-1]
+ end
+ ret[conf[0]] = conf[1]
+ else
+ ret[conf.shift] = conf
+ end
+ }
+
+ __font_optkeys.each{|optkey|
+ optkey = optkey.to_s
+ fontconf = ret[optkey]
+ if fontconf.kind_of?(Array)
+ ret.delete(optkey)
+ ret.delete('latin' << optkey)
+ ret.delete('ascii' << optkey)
+ ret.delete('kanji' << optkey)
+ fnt = fontconf[__configinfo_struct[:default_value]]
+ if TkFont.is_system_font?(fnt)
+ fontconf[__configinfo_struct[:default_value]] \
+ = TkNamedFont.new(fnt)
+ end
+ fontconf[__configinfo_struct[:current_value]] = fontobj(optkey)
+ ret[optkey] = fontconf
+ end
+ }
+
+ __methodcall_optkeys.each{|optkey, m|
+ ret[optkey.to_s] = ['', '', '', self.__send__(m)]
+ }
+
+ ret
+ end
+ end
+ end
+ end
+ private :__configinfo_core
+
+ def configinfo(slot = nil)
+ if slot && TkConfigMethod.__IGNORE_UNKNOWN_CONFIGURE_OPTION__
+ begin
+ __configinfo_core(slot)
+ rescue
+ Array.new(__configinfo_struct.values.max).unshift(slot.to_s)
+ end
+ else
+ __configinfo_core(slot)
+ end
+ end
+
+ def current_configinfo(slot = nil)
+ if TkComm::GET_CONFIGINFO_AS_ARRAY
+ if slot
+ org_slot = slot
+ begin
+ conf = configinfo(slot)
+ if ( ! __configinfo_struct[:alias] \
+ || conf.size > __configinfo_struct[:alias] + 1 )
+ return {conf[0] => conf[-1]}
+ end
+ slot = conf[__configinfo_struct[:alias]]
+ end while(org_slot != slot)
+ fail RuntimeError,
+ "there is a configure alias loop about '#{org_slot}'"
+ else
+ ret = {}
+ configinfo().each{|cnf|
+ if ( ! __configinfo_struct[:alias] \
+ || cnf.size > __configinfo_struct[:alias] + 1 )
+ ret[cnf[0]] = cnf[-1]
+ end
+ }
+ ret
+ end
+ else # ! TkComm::GET_CONFIGINFO_AS_ARRAY
+ ret = {}
+ configinfo(slot).each{|key, cnf|
+ ret[key] = cnf[-1] if cnf.kind_of?(Array)
+ }
+ ret
+ end
+ end
+end
+
+class TkObject<TkKernel
+ extend TkCore
+ include Tk
+ include TkConfigMethod
+ include TkBindCore
+
+### --> definition is moved to TkUtil module
+# def path
+# @path
+# end
+
+ def epath
+ @path
+ end
+
+ def to_eval
+ @path
+ end
+
+ def tk_send(cmd, *rest)
+ tk_call(path, cmd, *rest)
+ end
+ def tk_send_without_enc(cmd, *rest)
+ tk_call_without_enc(path, cmd, *rest)
+ end
+ def tk_send_with_enc(cmd, *rest)
+ tk_call_with_enc(path, cmd, *rest)
+ end
+ # private :tk_send, :tk_send_without_enc, :tk_send_with_enc
+
+ def tk_send_to_list(cmd, *rest)
+ tk_call_to_list(path, cmd, *rest)
+ end
+ def tk_send_to_list_without_enc(cmd, *rest)
+ tk_call_to_list_without_enc(path, cmd, *rest)
+ end
+ def tk_send_to_list_with_enc(cmd, *rest)
+ tk_call_to_list_with_enc(path, cmd, *rest)
+ end
+ def tk_send_to_simplelist(cmd, *rest)
+ tk_call_to_simplelist(path, cmd, *rest)
+ end
+ def tk_send_to_simplelist_without_enc(cmd, *rest)
+ tk_call_to_simplelist_without_enc(path, cmd, *rest)
+ end
+ def tk_send_to_simplelist_with_enc(cmd, *rest)
+ tk_call_to_simplelist_with_enc(path, cmd, *rest)
+ end
+
+ def method_missing(id, *args)
+ name = id.id2name
+ case args.length
+ when 1
+ if name[-1] == ?=
+ configure name[0..-2], args[0]
+ args[0]
+ else
+ configure name, args[0]
+ self
+ end
+ when 0
+ begin
+ cget(name)
+ rescue
+ if self.kind_of?(TkWindow) && name != "to_ary" && name != "to_str"
+ fail NameError,
+ "unknown option '#{id}' for #{self.inspect} (deleted widget?)"
+ else
+ super(id, *args)
+ end
+# fail NameError,
+# "undefined local variable or method `#{name}' for #{self.to_s}",
+# error_at
+ end
+ else
+ super(id, *args)
+# fail NameError, "undefined method `#{name}' for #{self.to_s}", error_at
+ end
+ end
+
+=begin
+ def [](id)
+ cget(id)
+ end
+
+ def []=(id, val)
+ configure(id, val)
+ val
+ end
+=end
+
+ def event_generate(context, keys=nil)
+ if context.kind_of?(TkEvent::Event)
+ context.generate(self, ((keys)? keys: {}))
+ elsif keys
+ #tk_call('event', 'generate', path,
+ # "<#{tk_event_sequence(context)}>", *hash_kv(keys))
+ tk_call_without_enc('event', 'generate', path,
+ "<#{tk_event_sequence(context)}>",
+ *hash_kv(keys, true))
+ else
+ #tk_call('event', 'generate', path, "<#{tk_event_sequence(context)}>")
+ tk_call_without_enc('event', 'generate', path,
+ "<#{tk_event_sequence(context)}>")
+ end
+ end
+
+ def tk_trace_variable(v)
+ #unless v.kind_of?(TkVariable)
+ # fail(ArgumentError, "type error (#{v.class}); must be TkVariable object")
+ #end
+ v
+ end
+ private :tk_trace_variable
+
+ def destroy
+ #tk_call 'trace', 'vdelete', @tk_vn, 'w', @var_id if @var_id
+ end
+end
+
+
+class TkWindow<TkObject
+ include TkWinfo
+ extend TkBindCore
+ include Tk::Wm_for_General
+ include Tk::Busy
+
+ @@WIDGET_INSPECT_FULL = false
+ def TkWindow._widget_inspect_full_?
+ @@WIDGET_INSPECT_FULL
+ end
+ def TkWindow._widget_inspect_full_=(mode)
+ @@WIDGET_INSPECT_FULL = (mode && true) || false
+ end
+
+ TkCommandNames = [].freeze
+ ## ==> If TkCommandNames[0] is a string (not a null string),
+ ## assume the string is a Tcl/Tk's create command of the widget class.
+ WidgetClassName = ''.freeze
+ # WidgetClassNames[WidgetClassName] = self
+ ## ==> If self is a widget class, entry to the WidgetClassNames table.
+ def self.to_eval
+ self::WidgetClassName
+ end
+
+ def initialize(parent=nil, keys=nil)
+ if parent.kind_of? Hash
+ keys = _symbolkey2str(parent)
+ parent = keys.delete('parent')
+ widgetname = keys.delete('widgetname')
+ install_win(if parent then parent.path end, widgetname)
+ without_creating = keys.delete('without_creating')
+ # if without_creating && !widgetname
+ # fail ArgumentError,
+ # "if set 'without_creating' to true, need to define 'widgetname'"
+ # end
+ elsif keys
+ keys = _symbolkey2str(keys)
+ widgetname = keys.delete('widgetname')
+ install_win(if parent then parent.path end, widgetname)
+ without_creating = keys.delete('without_creating')
+ # if without_creating && !widgetname
+ # fail ArgumentError,
+ # "if set 'without_creating' to true, need to define 'widgetname'"
+ # end
+ else
+ install_win(if parent then parent.path end)
+ end
+ if self.method(:create_self).arity == 0
+ p 'create_self has no arg' if $DEBUG
+ create_self unless without_creating
+ if keys
+ # tk_call @path, 'configure', *hash_kv(keys)
+ configure(keys)
+ end
+ else
+ p 'create_self has args' if $DEBUG
+ fontkeys = {}
+ methodkeys = {}
+ if keys
+ #['font', 'kanjifont', 'latinfont', 'asciifont'].each{|key|
+ # fontkeys[key] = keys.delete(key) if keys.key?(key)
+ #}
+ __font_optkeys.each{|key|
+ fkey = key.to_s
+ fontkeys[fkey] = keys.delete(fkey) if keys.key?(fkey)
+
+ fkey = "kanji#{key}"
+ fontkeys[fkey] = keys.delete(fkey) if keys.key?(fkey)
+
+ fkey = "latin#{key}"
+ fontkeys[fkey] = keys.delete(fkey) if keys.key?(fkey)
+
+ fkey = "ascii#{key}"
+ fontkeys[fkey] = keys.delete(fkey) if keys.key?(fkey)
+ }
+
+ __optkey_aliases.each{|alias_name, real_name|
+ alias_name = alias_name.to_s
+ if keys.has_key?(alias_name)
+ keys[real_name.to_s] = keys.delete(alias_name)
+ end
+ }
+
+ __methodcall_optkeys.each{|key|
+ key = key.to_s
+ methodkeys[key] = keys.delete(key) if keys.key?(key)
+ }
+
+ __ruby2val_optkeys.each{|key, method|
+ key = key.to_s
+ keys[key] = method.call(keys[key]) if keys.has_key?(key)
+ }
+ end
+ if without_creating && keys
+ #configure(keys)
+ configure(__conv_keyonly_opts(keys))
+ else
+ #create_self(keys)
+ create_self(__conv_keyonly_opts(keys))
+ end
+ font_configure(fontkeys) unless fontkeys.empty?
+ configure(methodkeys) unless methodkeys.empty?
+ end
+ end
+
+ def create_self(keys)
+ # may need to override
+ begin
+ cmd = self.class::TkCommandNames[0]
+ fail unless (cmd.kind_of?(String) && cmd.length > 0)
+ rescue
+ fail RuntimeError, "class #{self.class} may be an abstract class"
+ end
+
+ if keys and keys != None
+ unless TkConfigMethod.__IGNORE_UNKNOWN_CONFIGURE_OPTION__
+ tk_call_without_enc(cmd, @path, *hash_kv(keys, true))
+ else
+ begin
+ tk_call_without_enc(cmd, @path, *hash_kv(keys, true))
+ rescue => e
+ tk_call_without_enc(cmd, @path)
+ keys = __check_available_configure_options(keys)
+ unless keys.empty?
+ begin
+ # try to configure
+ configure(keys)
+ rescue
+ # fail => includes options adaptable when creattion only?
+ begin
+ tk_call_without_enc('destroy', @path)
+ rescue
+ # cannot rescue options error
+ fail e
+ else
+ # re-create widget
+ tk_call_without_enc(cmd, @path, *hash_kv(keys, true))
+ end
+ end
+ end
+ end
+ end
+ else
+ tk_call_without_enc(cmd, @path)
+ end
+ end
+ private :create_self
+
+ def inspect
+ if @@WIDGET_INSPECT_FULL
+ super
+ else
+ str = super
+ str[0..(str.index(' '))] << '@path=' << @path.inspect << '>'
+ end
+ end
+
+ def exist?
+ TkWinfo.exist?(self)
+ end
+
+ alias subcommand tk_send
+
+ def bind_class
+ @db_class || self.class()
+ end
+
+ def database_classname
+ TkWinfo.classname(self)
+ end
+ def database_class
+ name = database_classname()
+ if WidgetClassNames[name]
+ WidgetClassNames[name]
+ else
+ TkDatabaseClass.new(name)
+ end
+ end
+ def self.database_classname
+ self::WidgetClassName
+ end
+ def self.database_class
+ WidgetClassNames[self::WidgetClassName]
+ end
+
+ def pack(keys = nil)
+ #tk_call_without_enc('pack', epath, *hash_kv(keys, true))
+ if keys
+ TkPack.configure(self, keys)
+ else
+ TkPack.configure(self)
+ end
+ self
+ end
+
+ def pack_in(target, keys = nil)
+ if keys
+ keys = keys.dup
+ keys['in'] = target
+ else
+ keys = {'in'=>target}
+ end
+ #tk_call 'pack', epath, *hash_kv(keys)
+ TkPack.configure(self, keys)
+ self
+ end
+
+ def pack_forget
+ #tk_call_without_enc('pack', 'forget', epath)
+ TkPack.forget(self)
+ self
+ end
+ alias unpack pack_forget
+
+ def pack_config(slot, value=None)
+ #if slot.kind_of? Hash
+ # tk_call 'pack', 'configure', epath, *hash_kv(slot)
+ #else
+ # tk_call 'pack', 'configure', epath, "-#{slot}", value
+ #end
+ if slot.kind_of? Hash
+ TkPack.configure(self, slot)
+ else
+ TkPack.configure(self, slot=>value)
+ end
+ end
+ alias pack_configure pack_config
+
+ def pack_info()
+ #ilist = list(tk_call('pack', 'info', epath))
+ #info = {}
+ #while key = ilist.shift
+ # info[key[1..-1]] = ilist.shift
+ #end
+ #return info
+ TkPack.info(self)
+ end
+
+ def pack_propagate(mode=None)
+ #if mode == None
+ # bool(tk_call('pack', 'propagate', epath))
+ #else
+ # tk_call('pack', 'propagate', epath, mode)
+ # self
+ #end
+ if mode == None
+ TkPack.propagate(self)
+ else
+ TkPack.propagate(self, mode)
+ self
+ end
+ end
+
+ def pack_slaves()
+ #list(tk_call('pack', 'slaves', epath))
+ TkPack.slaves(self)
+ end
+
+ def grid(keys = nil)
+ #tk_call 'grid', epath, *hash_kv(keys)
+ if keys
+ TkGrid.configure(self, keys)
+ else
+ TkGrid.configure(self)
+ end
+ self
+ end
+
+ def grid_in(target, keys = nil)
+ if keys
+ keys = keys.dup
+ keys['in'] = target
+ else
+ keys = {'in'=>target}
+ end
+ #tk_call 'grid', epath, *hash_kv(keys)
+ TkGrid.configure(self, keys)
+ self
+ end
+
+ def grid_anchor(anchor=None)
+ if anchor == None
+ TkGrid.anchor(self)
+ else
+ TkGrid.anchor(self, anchor)
+ self
+ end
+ end
+
+ def grid_forget
+ #tk_call('grid', 'forget', epath)
+ TkGrid.forget(self)
+ self
+ end
+ alias ungrid grid_forget
+
+ def grid_bbox(*args)
+ #list(tk_call('grid', 'bbox', epath, *args))
+ TkGrid.bbox(self, *args)
+ end
+
+ def grid_config(slot, value=None)
+ #if slot.kind_of? Hash
+ # tk_call 'grid', 'configure', epath, *hash_kv(slot)
+ #else
+ # tk_call 'grid', 'configure', epath, "-#{slot}", value
+ #end
+ if slot.kind_of? Hash
+ TkGrid.configure(self, slot)
+ else
+ TkGrid.configure(self, slot=>value)
+ end
+ end
+ alias grid_configure grid_config
+
+ def grid_columnconfig(index, keys)
+ #tk_call('grid', 'columnconfigure', epath, index, *hash_kv(keys))
+ TkGrid.columnconfigure(self, index, keys)
+ end
+ alias grid_columnconfigure grid_columnconfig
+
+ def grid_rowconfig(index, keys)
+ #tk_call('grid', 'rowconfigure', epath, index, *hash_kv(keys))
+ TkGrid.rowconfigure(self, index, keys)
+ end
+ alias grid_rowconfigure grid_rowconfig
+
+ def grid_columnconfiginfo(index, slot=nil)
+ #if slot
+ # tk_call('grid', 'columnconfigure', epath, index, "-#{slot}").to_i
+ #else
+ # ilist = list(tk_call('grid', 'columnconfigure', epath, index))
+ # info = {}
+ # while key = ilist.shift
+ # info[key[1..-1]] = ilist.shift
+ # end
+ # info
+ #end
+ TkGrid.columnconfiginfo(self, index, slot)
+ end
+
+ def grid_rowconfiginfo(index, slot=nil)
+ #if slot
+ # tk_call('grid', 'rowconfigure', epath, index, "-#{slot}").to_i
+ #else
+ # ilist = list(tk_call('grid', 'rowconfigure', epath, index))
+ # info = {}
+ # while key = ilist.shift
+ # info[key[1..-1]] = ilist.shift
+ # end
+ # info
+ #end
+ TkGrid.rowconfiginfo(self, index, slot)
+ end
+
+ def grid_column(index, keys=nil)
+ if keys.kind_of?(Hash)
+ grid_columnconfigure(index, keys)
+ else
+ grid_columnconfiginfo(index, keys)
+ end
+ end
+
+ def grid_row(index, keys=nil)
+ if keys.kind_of?(Hash)
+ grid_rowconfigure(index, keys)
+ else
+ grid_rowconfiginfo(index, keys)
+ end
+ end
+
+ def grid_info()
+ #list(tk_call('grid', 'info', epath))
+ TkGrid.info(self)
+ end
+
+ def grid_location(x, y)
+ #list(tk_call('grid', 'location', epath, x, y))
+ TkGrid.location(self, x, y)
+ end
+
+ def grid_propagate(mode=None)
+ #if mode == None
+ # bool(tk_call('grid', 'propagate', epath))
+ #else
+ # tk_call('grid', 'propagate', epath, mode)
+ # self
+ #end
+ if mode == None
+ TkGrid.propagate(self)
+ else
+ TkGrid.propagate(self, mode)
+ self
+ end
+ end
+
+ def grid_remove()
+ #tk_call 'grid', 'remove', epath
+ TkGrid.remove(self)
+ self
+ end
+
+ def grid_size()
+ #list(tk_call('grid', 'size', epath))
+ TkGrid.size(self)
+ end
+
+ def grid_slaves(keys = nil)
+ #list(tk_call('grid', 'slaves', epath, *hash_kv(args)))
+ TkGrid.slaves(self, keys)
+ end
+
+ def place(keys)
+ #tk_call 'place', epath, *hash_kv(keys)
+ TkPlace.configure(self, keys)
+ self
+ end
+
+ def place_in(target, keys = nil)
+ if keys
+ keys = keys.dup
+ keys['in'] = target
+ else
+ keys = {'in'=>target}
+ end
+ #tk_call 'place', epath, *hash_kv(keys)
+ TkPlace.configure(self, keys)
+ self
+ end
+
+ def place_forget
+ #tk_call 'place', 'forget', epath
+ TkPlace.forget(self)
+ self
+ end
+ alias unplace place_forget
+
+ def place_config(slot, value=None)
+ #if slot.kind_of? Hash
+ # tk_call 'place', 'configure', epath, *hash_kv(slot)
+ #else
+ # tk_call 'place', 'configure', epath, "-#{slot}", value
+ #end
+ TkPlace.configure(self, slot, value)
+ end
+ alias place_configure place_config
+
+ def place_configinfo(slot = nil)
+ # for >= Tk8.4a2 ?
+ #if slot
+ # conf = tk_split_list(tk_call('place', 'configure', epath, "-#{slot}") )
+ # conf[0] = conf[0][1..-1]
+ # conf
+ #else
+ # tk_split_simplelist(tk_call('place',
+ # 'configure', epath)).collect{|conflist|
+ # conf = tk_split_simplelist(conflist)
+ # conf[0] = conf[0][1..-1]
+ # conf
+ # }
+ #end
+ TkPlace.configinfo(self, slot)
+ end
+
+ def place_info()
+ #ilist = list(tk_call('place', 'info', epath))
+ #info = {}
+ #while key = ilist.shift
+ # info[key[1..-1]] = ilist.shift
+ #end
+ #return info
+ TkPlace.info(self)
+ end
+
+ def place_slaves()
+ #list(tk_call('place', 'slaves', epath))
+ TkPlace.slaves(self)
+ end
+
+ def set_focus(force=false)
+ if force
+ tk_call_without_enc('focus', '-force', path)
+ else
+ tk_call_without_enc('focus', path)
+ end
+ self
+ end
+ alias focus set_focus
+
+ def grab(opt = nil)
+ unless opt
+ tk_call_without_enc('grab', 'set', path)
+ return self
+ end
+
+ case opt
+ when 'set', :set
+ tk_call_without_enc('grab', 'set', path)
+ return self
+ when 'global', :global
+ #return(tk_call('grab', 'set', '-global', path))
+ tk_call_without_enc('grab', 'set', '-global', path)
+ return self
+ when 'release', :release
+ #return tk_call('grab', 'release', path)
+ tk_call_without_enc('grab', 'release', path)
+ return self
+ when 'current', :current
+ return window(tk_call_without_enc('grab', 'current', path))
+ when 'status', :status
+ return tk_call_without_enc('grab', 'status', path)
+ else
+ return tk_call_without_enc('grab', opt, path)
+ end
+ end
+
+ def grab_current
+ grab('current')
+ end
+ alias current_grab grab_current
+ def grab_release
+ grab('release')
+ end
+ alias release_grab grab_release
+ def grab_set
+ grab('set')
+ end
+ alias set_grab grab_set
+ def grab_set_global
+ grab('global')
+ end
+ alias set_global_grab grab_set_global
+ def grab_status
+ grab('status')
+ end
+
+ def lower(below=None)
+ # below = below.epath if below.kind_of?(TkObject)
+ below = _epath(below)
+ tk_call 'lower', epath, below
+ self
+ end
+ alias lower_window lower
+ def raise(above=None)
+ #above = above.epath if above.kind_of?(TkObject)
+ above = _epath(above)
+ tk_call 'raise', epath, above
+ self
+ end
+ alias raise_window raise
+
+ def command(cmd=nil, &b)
+ if cmd
+ configure_cmd('command', cmd)
+ elsif b
+ configure_cmd('command', Proc.new(&b))
+ else
+ cget('command')
+ end
+ end
+
+ def colormodel(model=None)
+ tk_call('tk', 'colormodel', path, model)
+ self
+ end
+
+ def caret(keys=nil)
+ TkXIM.caret(path, keys)
+ end
+
+ def destroy
+ super
+ children = []
+ rexp = /^#{self.path}\.[^.]+$/
+ TkCore::INTERP.tk_windows.each{|path, obj|
+ children << [path, obj] if path =~ rexp
+ }
+ if defined?(@cmdtbl)
+ for id in @cmdtbl
+ uninstall_cmd id
+ end
+ end
+
+ children.each{|path, obj|
+ obj.instance_eval{
+ if defined?(@cmdtbl)
+ for id in @cmdtbl
+ uninstall_cmd id
+ end
+ end
+ }
+ TkCore::INTERP.tk_windows.delete(path)
+ }
+
+ begin
+ tk_call_without_enc('destroy', epath)
+ rescue
+ end
+ uninstall_win
+ end
+
+ def wait_visibility(on_thread = true)
+ if $SAFE >= 4
+ fail SecurityError, "can't wait visibility at $SAFE >= 4"
+ end
+ on_thread &= (Thread.list.size != 1)
+ if on_thread
+ INTERP._thread_tkwait('visibility', path)
+ else
+ INTERP._invoke('tkwait', 'visibility', path)
+ end
+ end
+ def eventloop_wait_visibility
+ wait_visibility(false)
+ end
+ def thread_wait_visibility
+ wait_visibility(true)
+ end
+ alias wait wait_visibility
+ alias tkwait wait_visibility
+ alias eventloop_wait eventloop_wait_visibility
+ alias eventloop_tkwait eventloop_wait_visibility
+ alias eventloop_tkwait_visibility eventloop_wait_visibility
+ alias thread_wait thread_wait_visibility
+ alias thread_tkwait thread_wait_visibility
+ alias thread_tkwait_visibility thread_wait_visibility
+
+ def wait_destroy(on_thread = true)
+ if $SAFE >= 4
+ fail SecurityError, "can't wait destroy at $SAFE >= 4"
+ end
+ on_thread &= (Thread.list.size != 1)
+ if on_thread
+ INTERP._thread_tkwait('window', epath)
+ else
+ INTERP._invoke('tkwait', 'window', epath)
+ end
+ end
+ alias wait_window wait_destroy
+ def eventloop_wait_destroy
+ wait_destroy(false)
+ end
+ alias eventloop_wait_window eventloop_wait_destroy
+ def thread_wait_destroy
+ wait_destroy(true)
+ end
+ alias thread_wait_window thread_wait_destroy
+
+ alias tkwait_destroy wait_destroy
+ alias tkwait_window wait_destroy
+
+ alias eventloop_tkwait_destroy eventloop_wait_destroy
+ alias eventloop_tkwait_window eventloop_wait_destroy
+
+ alias thread_tkwait_destroy thread_wait_destroy
+ alias thread_tkwait_window thread_wait_destroy
+
+ def bindtags(taglist=nil)
+ if taglist
+ fail ArgumentError, "taglist must be Array" unless taglist.kind_of? Array
+ tk_call('bindtags', path, taglist)
+ taglist
+ else
+ list(tk_call('bindtags', path)).collect{|tag|
+ if tag.kind_of?(String)
+ if cls = WidgetClassNames[tag]
+ cls
+ elsif btag = TkBindTag.id2obj(tag)
+ btag
+ else
+ tag
+ end
+ else
+ tag
+ end
+ }
+ end
+ end
+
+ def bindtags=(taglist)
+ bindtags(taglist)
+ taglist
+ end
+
+ def bindtags_shift
+ taglist = bindtags
+ tag = taglist.shift
+ bindtags(taglist)
+ tag
+ end
+
+ def bindtags_unshift(tag)
+ bindtags(bindtags().unshift(tag))
+ end
+end
+TkWidget = TkWindow
+
+# freeze core modules
+#TclTkLib.freeze
+#TclTkIp.freeze
+#TkUtil.freeze
+#TkKernel.freeze
+#TkComm.freeze
+#TkComm::Event.freeze
+#TkCore.freeze
+#Tk.freeze
+
+module Tk
+ RELEASE_DATE = '2014-10-19'.freeze
+
+ autoload :AUTO_PATH, 'tk/variable'
+ autoload :TCL_PACKAGE_PATH, 'tk/variable'
+ autoload :PACKAGE_PATH, 'tk/variable'
+ autoload :TCL_LIBRARY_PATH, 'tk/variable'
+ autoload :LIBRARY_PATH, 'tk/variable'
+ autoload :TCL_PRECISION, 'tk/variable'
+end
+
+# call setup script for Tk extension libraries (base configuration)
+begin
+ require 'tkextlib/version.rb'
+ require 'tkextlib/setup.rb'
+rescue LoadError
+ # ignore
+end
diff --git a/jni/ruby/ext/tk/lib/tk/after.rb b/jni/ruby/ext/tk/lib/tk/after.rb
new file mode 100644
index 0000000..fac9de4
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tk/after.rb
@@ -0,0 +1,6 @@
+#
+# tk/after.rb : methods for Tcl/Tk after command
+#
+# $Id: after.rb 25189 2009-10-02 12:04:37Z akr $
+#
+require 'tk/timer'
diff --git a/jni/ruby/ext/tk/lib/tk/autoload.rb b/jni/ruby/ext/tk/lib/tk/autoload.rb
new file mode 100644
index 0000000..451922c
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tk/autoload.rb
@@ -0,0 +1,762 @@
+#
+# autoload
+#
+############################################
+# geometry manager
+module Tk
+ autoload :Grid, 'tk/grid'
+ def Grid(*args); TkGrid.configure(*args); end
+
+ autoload :Pack, 'tk/pack'
+ def Pack(*args); TkPack.configure(*args); end
+
+ autoload :Place, 'tk/place'
+ def Place(*args); TkPlace.configure(*args); end
+end
+
+autoload :TkGrid, 'tk/grid'
+def TkGrid(*args); TkGrid.configure(*args); end
+
+autoload :TkPack, 'tk/pack'
+def TkPack(*args); TkPack.configure(*args); end
+
+autoload :TkPlace, 'tk/place'
+def TkPlace(*args); TkPlace.configure(*args); end
+
+
+############################################
+# classes on Tk module
+module Tk
+ autoload :Busy, 'tk/busy'
+
+ autoload :Button, 'tk/button'
+
+ autoload :Canvas, 'tk/canvas'
+
+ autoload :CheckButton, 'tk/checkbutton'
+ autoload :Checkbutton, 'tk/checkbutton'
+
+ autoload :Entry, 'tk/entry'
+
+ autoload :Frame, 'tk/frame'
+
+ autoload :Label, 'tk/label'
+
+ autoload :LabelFrame, 'tk/labelframe'
+ autoload :Labelframe, 'tk/labelframe'
+
+ autoload :Listbox, 'tk/listbox'
+
+ autoload :Menu, 'tk/menu'
+ autoload :MenuClone, 'tk/menu'
+ autoload :CloneMenu, 'tk/menu'
+ autoload :SystemMenu, 'tk/menu'
+ autoload :SysMenu_Help, 'tk/menu'
+ autoload :SysMenu_System, 'tk/menu'
+ autoload :SysMenu_Apple, 'tk/menu'
+ autoload :Menubutton, 'tk/menu'
+ autoload :MenuButton, 'tk/menu'
+ autoload :OptionMenubutton, 'tk/menu'
+ autoload :OptionMenBbutton, 'tk/menu'
+
+ autoload :Message, 'tk/message'
+
+ autoload :PanedWindow, 'tk/panedwindow'
+ autoload :Panedwindow, 'tk/panedwindow'
+
+ autoload :RadioButton, 'tk/radiobutton'
+ autoload :Radiobutton, 'tk/radiobutton'
+
+ autoload :Root, 'tk/root'
+
+ autoload :Scale, 'tk/scale'
+
+ autoload :Scrollbar, 'tk/scrollbar'
+ autoload :XScrollbar, 'tk/scrollbar'
+ autoload :YScrollbar, 'tk/scrollbar'
+
+ autoload :Spinbox, 'tk/spinbox'
+
+ autoload :Text, 'tk/text'
+
+ autoload :Toplevel, 'tk/toplevel'
+end
+
+
+############################################
+# sub-module of Tk
+module Tk
+ autoload :Clock, 'tk/clock'
+
+ autoload :OptionObj, 'tk/optionobj'
+
+ autoload :X_Scrollable, 'tk/scrollable'
+ autoload :Y_Scrollable, 'tk/scrollable'
+ autoload :Scrollable, 'tk/scrollable'
+
+ autoload :Fontchooser, 'tk/fontchooser'
+
+ autoload :Wm, 'tk/wm'
+ autoload :Wm_for_General, 'tk/wm'
+
+ autoload :MacResource, 'tk/macpkg'
+
+ autoload :WinDDE, 'tk/winpkg'
+ autoload :WinRegistry, 'tk/winpkg'
+
+ autoload :ValidateConfigure, 'tk/validation'
+ autoload :ItemValidateConfigure, 'tk/validation'
+
+ autoload :EncodedString, 'tk/encodedstr'
+ def Tk.EncodedString(str, enc = nil); Tk::EncodedString.new(str, enc); end
+
+ autoload :BinaryString, 'tk/encodedstr'
+ def Tk.BinaryString(str); Tk::BinaryString.new(str); end
+
+ autoload :UTF8_String, 'tk/encodedstr'
+ def Tk.UTF8_String(str); Tk::UTF8_String.new(str); end
+
+end
+
+
+############################################
+# toplevel classes/modules (fixed)
+autoload :TkBgError, 'tk/bgerror'
+
+autoload :TkBindTag, 'tk/bindtag'
+autoload :TkBindTagAll, 'tk/bindtag'
+autoload :TkDatabaseClass, 'tk/bindtag'
+
+autoload :TkConsole, 'tk/console'
+
+autoload :TkcItem, 'tk/canvas'
+autoload :TkcArc, 'tk/canvas'
+autoload :TkcBitmap, 'tk/canvas'
+autoload :TkcImage, 'tk/canvas'
+autoload :TkcLine, 'tk/canvas'
+autoload :TkcOval, 'tk/canvas'
+autoload :TkcPolygon, 'tk/canvas'
+autoload :TkcRectangle, 'tk/canvas'
+autoload :TkcText, 'tk/canvas'
+autoload :TkcWindow, 'tk/canvas'
+
+autoload :TkcTagAccess, 'tk/canvastag'
+autoload :TkcTag, 'tk/canvastag'
+autoload :TkcTagString, 'tk/canvastag'
+autoload :TkcNamedTag, 'tk/canvastag'
+autoload :TkcTagAll, 'tk/canvastag'
+autoload :TkcTagCurrent, 'tk/canvastag'
+autoload :TkcTagGroup, 'tk/canvastag'
+
+autoload :TkClipboard, 'tk/clipboard'
+
+autoload :TkComposite, 'tk/composite'
+
+autoload :TkConsole, 'tk/console'
+
+autoload :TkDialog, 'tk/dialog'
+autoload :TkDialog2, 'tk/dialog'
+autoload :TkDialogObj, 'tk/dialog'
+autoload :TkWarning, 'tk/dialog'
+autoload :TkWarning2, 'tk/dialog'
+autoload :TkWarningObj, 'tk/dialog'
+
+autoload :TkEvent, 'tk/event'
+
+autoload :TkFont, 'tk/font'
+autoload :TkNamedFont, 'tk/font'
+
+autoload :TkImage, 'tk/image'
+autoload :TkBitmapImage, 'tk/image'
+autoload :TkPhotoImage, 'tk/image'
+
+autoload :TkItemConfigMethod, 'tk/itemconfig'
+
+autoload :TkTreatItemFont, 'tk/itemfont'
+
+autoload :TkKinput, 'tk/kinput'
+
+autoload :TkSystemMenu, 'tk/menu'
+
+autoload :TkMenubar, 'tk/menubar'
+
+autoload :TkMenuSpec, 'tk/menuspec'
+
+autoload :TkManageFocus, 'tk/mngfocus'
+
+autoload :TkMsgCatalog, 'tk/msgcat'
+autoload :TkMsgCat, 'tk/msgcat'
+
+autoload :TkNamespace, 'tk/namespace'
+
+autoload :TkOptionDB, 'tk/optiondb'
+autoload :TkOption, 'tk/optiondb'
+autoload :TkResourceDB, 'tk/optiondb'
+
+autoload :TkPackage, 'tk/package'
+
+autoload :TkPalette, 'tk/palette'
+
+autoload :TkRoot, 'tk/root'
+
+autoload :TkScrollbox, 'tk/scrollbox'
+
+autoload :TkSelection, 'tk/selection'
+
+autoload :TkTreatTagFont, 'tk/tagfont'
+
+autoload :TkTextImage, 'tk/textimage'
+autoload :TktImage, 'tk/textimage'
+
+autoload :TkTextMark, 'tk/textmark'
+autoload :TkTextNamedMark, 'tk/textmark'
+autoload :TkTextMarkInsert, 'tk/textmark'
+autoload :TkTextMarkCurrent, 'tk/textmark'
+autoload :TkTextMarkAnchor, 'tk/textmark'
+autoload :TktMark, 'tk/textmark'
+autoload :TktNamedMark, 'tk/textmark'
+autoload :TktMarkInsert, 'tk/textmark'
+autoload :TktMarkCurrent, 'tk/textmark'
+autoload :TktMarkAnchor, 'tk/textmark'
+
+autoload :TkTextTag, 'tk/texttag'
+autoload :TkTextNamedTag, 'tk/texttag'
+autoload :TkTextTagSel, 'tk/texttag'
+autoload :TktTag, 'tk/texttag'
+autoload :TktNamedTag, 'tk/texttag'
+autoload :TktTagSel, 'tk/texttag'
+
+autoload :TkTextWindow, 'tk/textwindow'
+autoload :TktWindow, 'tk/textwindow'
+
+autoload :TkAfter, 'tk/timer'
+autoload :TkTimer, 'tk/timer'
+autoload :TkRTTimer, 'tk/timer'
+
+autoload :TkTextWin, 'tk/txtwin_abst'
+
+autoload :TkValidation, 'tk/validation'
+autoload :TkValidateCommand, 'tk/validation'
+
+autoload :TkVariable, 'tk/variable'
+autoload :TkVarAccess, 'tk/variable'
+
+autoload :TkVirtualEvent, 'tk/virtevent'
+autoload :TkNamedVirtualEvent,'tk/virtevent'
+
+autoload :TkWinfo, 'tk/winfo'
+
+autoload :TkXIM, 'tk/xim'
+
+
+############################################
+# toplevel classes/modules (switchable)
+module Tk
+ @TOPLEVEL_ALIAS_TABLE = {}
+ @TOPLEVEL_ALIAS_TABLE[:Tk] = {
+ :TkButton => 'tk/button',
+
+ :TkCanvas => 'tk/canvas',
+
+ :TkCheckButton => 'tk/checkbutton',
+ :TkCheckbutton => 'tk/checkbutton',
+
+ # :TkDialog => 'tk/dialog',
+ # :TkDialog2 => 'tk/dialog',
+ # :TkDialogObj => 'tk/dialog',
+ # :TkWarning => 'tk/dialog',
+ # :TkWarning2 => 'tk/dialog',
+ # :TkWarningObj => 'tk/dialog',
+
+ :TkEntry => 'tk/entry',
+
+ :TkFrame => 'tk/frame',
+
+ :TkLabel => 'tk/label',
+
+ :TkLabelFrame => 'tk/labelframe',
+ :TkLabelframe => 'tk/labelframe',
+
+ :TkListbox => 'tk/listbox',
+
+ :TkMacResource => 'tk/macpkg',
+
+ :TkMenu => 'tk/menu',
+ :TkMenuClone => 'tk/menu',
+ :TkCloneMenu => 'tk/menu',
+ # :TkSystemMenu => 'tk/menu',
+ :TkSysMenu_Help => 'tk/menu',
+ :TkSysMenu_System => 'tk/menu',
+ :TkSysMenu_Apple => 'tk/menu',
+ :TkMenubutton => 'tk/menu',
+ :TkMenuButton => 'tk/menu',
+ :TkOptionMenubutton => 'tk/menu',
+ :TkOptionMenuButton => 'tk/menu',
+
+ :TkMessage => 'tk/message',
+
+ :TkPanedWindow => 'tk/panedwindow',
+ :TkPanedwindow => 'tk/panedwindow',
+
+ :TkRadioButton => 'tk/radiobutton',
+ :TkRadiobutton => 'tk/radiobutton',
+
+ # :TkRoot => 'tk/root',
+
+ :TkScale => 'tk/scale',
+
+ :TkScrollbar => 'tk/scrollbar',
+ :TkXScrollbar => 'tk/scrollbar',
+ :TkYScrollbar => 'tk/scrollbar',
+
+ :TkSpinbox => 'tk/spinbox',
+
+ :TkText => 'tk/text',
+
+ :TkToplevel => 'tk/toplevel',
+
+ :TkWinDDE => 'tk/winpkg',
+ :TkWinRegistry => 'tk/winpkg',
+ }
+
+ @TOPLEVEL_ALIAS_OWNER = {}
+
+ @TOPLEVEL_ALIAS_SETUP_PROC = {}
+
+ @AUTOLOAD_FILE_SYM_TABLE = Hash.new{|h,k| h[k]={}} # TABLE[file][sym] -> obj
+
+ @current_default_widget_set = nil
+
+ module TOPLEVEL_ALIASES; end
+end
+
+class Object
+ include Tk::TOPLEVEL_ALIASES
+end
+
+############################################
+# methods to control default widget set
+############################################
+
+class << Tk
+ def default_widget_set
+ @current_default_widget_set
+ end
+
+ def default_widget_set=(target)
+ target = target.to_sym
+ return target if target == @current_default_widget_set
+
+ if (cmd = @TOPLEVEL_ALIAS_SETUP_PROC[target])
+ cmd.call(target)
+ end
+
+ _replace_toplevel_aliases(target)
+ end
+
+ def widget_set_symbols
+ @TOPLEVEL_ALIAS_TABLE.keys
+ end
+
+ def toplevel_aliases_on_widget_set(widget_set)
+ if (tbl = @TOPLEVEL_ALIAS_TABLE[widget_set.to_sym])
+ tbl.collect{|k, v| (v.nil?)? nil: k}.compact
+ else
+ fail ArgumentError, "unknown widget_set #{widget_set.to_sym.inspect}"
+ end
+ end
+
+ def __toplevel_alias_setup_proc__(*target_list, &cmd)
+ target_list.each{|target| @TOPLEVEL_ALIAS_SETUP_PROC[target.to_sym] = cmd}
+ end
+
+ def topobj_defined?(sym) #=> alias_filename or object or false
+ Object.autoload?(sym) ||
+ (Object.const_defined?(sym) && Object.const_get(sym))
+ end
+ def topalias_defined?(sym) #=> alias_filename or object or false
+ Tk::TOPLEVEL_ALIASES.autoload?(sym) ||
+ (Tk::TOPLEVEL_ALIASES.const_defined?(sym) &&
+ Tk::TOPLEVEL_ALIASES.const_get(sym))
+ end
+ def define_topobj(sym, obj)
+ if obj.kind_of? String
+ # obj is an autoload path
+ Object.autoload(sym, obj)
+ unless Object.autoload?(sym)
+ # file is autoloaded?
+ if @AUTOLOAD_FILE_SYM_TABLE.has_key?(obj) &&
+ (loaded_obj = @AUTOLOAD_FILE_SYM_TABLE[obj][sym])
+ Object.const_set(sym, loaded_obj)
+ else
+ fail ArgumentError, "cannot define autoload file (already loaded?)"
+ end
+ end
+ else
+ # object
+ Object.const_set(sym, obj)
+ end
+ end
+ def define_topalias(sym, obj)
+ if obj.kind_of? String
+ # obj is an autoload path
+ Tk::TOPLEVEL_ALIASES.autoload(sym, obj)
+ unless Tk::TOPLEVEL_ALIASES.autoload?(sym)
+ # file is autoloaded?
+ if @AUTOLOAD_FILE_SYM_TABLE.has_key?(obj) &&
+ (loaded_obj = @AUTOLOAD_FILE_SYM_TABLE[obj][sym])
+ Tk::TOPLEVEL_ALIASES.const_set(sym, loaded_obj)
+ else
+ fail ArgumentError, "cannot define autoload file (already loaded?)"
+ end
+ end
+ else
+ # object
+ Tk::TOPLEVEL_ALIASES.const_set(sym, obj)
+ end
+ end
+ def replace_topobj(sym, obj) #=> old_obj (alias_filename or object) or nil
+ if old_obj = topobj_defined?(sym)
+ Object.class_eval{remove_const sym} rescue nil # ignore err
+ end
+ define_topobj(sym, obj)
+ old_obj
+ end
+ def replace_topalias(sym, obj) #=> old_obj (alias_filename or object) or nil
+ if old_obj = topalias_defined?(sym)
+ Tk::TOPLEVEL_ALIASES.module_eval{remove_const sym} rescue nil #ignore err
+ end
+ define_topalias(sym, obj)
+ old_obj
+ end
+ private :topobj_defined?, :topalias_defined?
+ private :define_topobj, :define_topalias
+ private :replace_topobj, :replace_topalias
+
+ def __regist_toplevel_aliases__(target, obj, *symbols)
+ # initial regist
+ @TOPLEVEL_ALIAS_TABLE[target = target.to_sym] ||= {}
+ symbols.each{|sym|
+ @TOPLEVEL_ALIAS_TABLE[target][sym = sym.to_sym] = obj
+ if !topalias_defined?(sym) || target == @current_default_widget_set
+ @TOPLEVEL_ALIAS_OWNER[sym] = target
+ replace_topalias(sym, obj)
+ replace_topobj(sym, obj) unless obj.kind_of?(String) # NOT autoload
+ end
+ }
+ end
+
+ def regist_sym_for_loaded_file(auto, obj, sym)
+ @AUTOLOAD_FILE_SYM_TABLE[auto][sym] = obj
+
+ reg = /^#{Regexp.quote(auto)}(\.rb|\.so|)$/
+ @TOPLEVEL_ALIAS_TABLE.each_key{|set|
+ if @TOPLEVEL_ALIAS_TABLE[set][sym] =~ reg
+ @TOPLEVEL_ALIAS_TABLE[set][sym] = obj
+ if @TOPLEVEL_ALIAS_OWNER[sym].nil? || @TOPLEVEL_ALIAS_OWNER[sym] == set
+ replace_topalias(sym, obj)
+ replace_topobj(sym, obj) if set == @current_default_widget_set
+ end
+ end
+ }
+ if (f = Object.autoload?(sym)) && f =~ reg
+ replace_topobj(sym, obj)
+ end
+ if (f = Tk::TOPLEVEL_ALIASES.autoload?(sym)) && f =~ reg
+ replace_topalias(sym, obj)
+ end
+ end
+ private :regist_sym_for_loaded_file
+
+ def set_topalias(target, obj, sym)
+ # obj is a kind of String : define autoload path
+ # Class : use the class object
+ if target == @current_default_widget_set
+ case @TOPLEVEL_ALIAS_OWNER[sym]
+ when false
+ # Object::sym is out of control. --> not change
+ # Make ALIAS::sym under control, because target widget set is current.
+ # Keep OWNER[sym]
+ @TOPLEVEL_ALIAS_TABLE[target][sym] = obj
+ replace_topalias(sym, obj)
+
+ when target
+ if current_obj = topobj_defined?(sym)
+ if current_obj == obj
+ # Make current_obj under control.
+ # Keep Object::sym.
+ # Keep OWNER[sym].
+ @TOPLEVEL_ALIAS_TABLE[target][sym] = obj
+ replace_topalias(sym, obj)
+
+ else # current_obj != obj
+ if current_obj == topalias_defined?(sym)
+ # Change controlled object
+ # Keep OWNER[sym].
+ @TOPLEVEL_ALIAS_TABLE[target][sym] = obj
+ replace_topalias(sym, obj)
+ replace_topobj(sym, obj)
+
+ else # current_obj != topalias_defined?(sym)
+ # Maybe current_obj is defined by user. --> OWNER[sym] = faise
+ # Keep Object::sym.
+ @TOPLEVEL_ALIAS_OWNER[sym] = false
+ @TOPLEVEL_ALIAS_TABLE[target][sym] = obj
+ replace_topalias(sym, obj)
+ end
+ end
+
+ else # NOT topobj_defined?(sym)
+ # New definition for sym at target.
+ # Keep OWNER[sym].
+ @TOPLEVEL_ALIAS_TABLE[target][sym] = obj
+ replace_topalias(sym, obj)
+ define_topobj(sym, obj)
+ end
+
+ when nil
+ # New definition for sym at target.
+ @TOPLEVEL_ALIAS_OWNER[sym] = target
+ @TOPLEVEL_ALIAS_TABLE[target][sym] = obj
+ replace_topalias(sym, obj)
+
+ else # others
+ # Maybe planning to make sym under control.
+ @TOPLEVEL_ALIAS_OWNER[sym] = target
+ @TOPLEVEL_ALIAS_TABLE[target][sym] = obj
+ replace_topalias(sym, obj)
+ replace_topobj(sym, obj)
+ end
+
+ else # target != @current_default_widget_set
+ case @TOPLEVEL_ALIAS_OWNER[sym]
+ when false
+ # Object::sym is out of control. --> not change
+ if topalias_defined?(sym)
+ # ALIAS[sym] may be defined by other widget set.
+ # Keep Object::sym (even if it is not defined)
+ # Keep ALIAS[sym].
+ # Keep OWNER[sym].
+ @TOPLEVEL_ALIAS_TABLE[target][sym] = obj
+
+ else # NOT topalias_defined?(sym)
+ # Nobody controls ALIAS[sym].
+ # At leaset, current widget set doesn't control ALIAS[sym].
+ # Keep Object::sym (even if it is not defined)
+ # Keep OWNER[sym].
+ @TOPLEVEL_ALIAS_TABLE[target][sym] = obj
+ define_topalias(sym, obj)
+ end
+
+ when target
+ # Maybe change controlled object, because Object::sym is under control.
+ # Keep OWNER[sym].
+ @TOPLEVEL_ALIAS_TABLE[target][sym] = obj
+ replace_topalias(sym, obj)
+ replace_topobj(sym, obj)
+
+ when nil
+ # New definition for sym
+ @TOPLEVEL_ALIAS_OWNER[sym] = target
+ @TOPLEVEL_ALIAS_TABLE[target][sym] = obj
+ replace_topalias(sym, obj)
+ replace_topobj(sym, obj)
+
+ else # others
+ # An other widget set controls sym.
+ # Keep Object::sym (even if it is not defined)
+ # Keep ALIAS[sym].
+ # Keep OWNER[sym].
+ @TOPLEVEL_ALIAS_TABLE[target][sym] = obj
+
+ end
+ end
+
+ sym
+ end
+ private :set_topalias
+
+ def __set_toplevel_aliases__(target, obj, *symbols)
+ # obj is a kind of String : define autoload path
+ # Class : use the class object
+ target = target.to_sym
+ symbols.each{|sym| set_topalias(target, obj, sym.to_sym)}
+ end
+
+ def __set_loaded_toplevel_aliases__(autopath, target, obj, *symbols)
+ # autopath is an autoload file
+ # Currently, this method doesn't support that autoload loads
+ # different toplevels between <basename>.rb and <basename>.so extension.
+ shortpath = (autopath =~ /^(.*)(.rb|.so)$/)? $1: autopath
+ target = target.to_sym
+ symbols.map!{|sym| sym.to_sym}
+
+ symbols.each{|sym| regist_sym_for_loaded_file(shortpath, obj, sym) }
+ symbols.each{|sym| set_topalias(target, obj, sym)}
+ end
+
+ def backup_current_topdef(sym)
+ return if (current = @current_default_widget_set).nil?
+
+ case @TOPLEVEL_ALIAS_OWNER[sym]
+ when false
+ # Object::sym is out of control.
+ if (cur_alias = topalias_defined?(sym)) && ! cur_alias.kind_of?(String)
+ @TOPLEVEL_ALIAS_TABLE[current][sym] = cur_alias
+ end
+
+ when current
+ if cur_obj = topobj_defined?(sym)
+ if ! cur_obj.kind_of?(String) && (cur_alias = topalias_defined?(sym))
+ if cur_alias.kind_of?(String)
+ # Mayby, user replaced Object::sym.
+ # Make Object::sym out of control.
+ @TOPLEVEL_ALIAS_OWNER[sym] = false
+ elsif cur_obj == cur_alias
+ # Possibley, defined normally. Backup it
+ @TOPLEVEL_ALIAS_TABLE[current][sym] = cur_alias
+ else
+ # Mayby, user replaced Object::sym.
+ # Make Object::sym out of control.
+ @TOPLEVEL_ALIAS_OWNER[sym] = false
+ end
+ end
+ else
+ # Mayby, user replaced Object::sym.
+ # Make Object::sym out of control.
+ @TOPLEVEL_ALIAS_OWNER[sym] = false
+ end
+
+ when nil
+ # Object::sym is out of control.
+ if (cur_alias = topalias_defined?(sym)) && ! cur_alias.kind_of?(String)
+ # Possibley, defined normally. Backup it.
+ @TOPLEVEL_ALIAS_TABLE[current][sym] = cur_alias
+ end
+ else
+ # No authority to control Object::sym and ALIASES::sym.
+ # Do nothing.
+ end
+ end
+ private :backup_current_topdef
+
+ def _replace_toplevel_aliases(target)
+ # backup
+ @TOPLEVEL_ALIAS_TABLE[target].each_key{|sym|
+ backup_current_topdef(sym)
+ }
+
+ # replace
+ @TOPLEVEL_ALIAS_TABLE[target].each_key{|sym|
+ next if (obj = @TOPLEVEL_ALIAS_TABLE[target][sym]).nil?
+ if @TOPLEVEL_ALIAS_OWNER[sym] == false
+ # Object::sym is out of control. --> not change
+ # Keep OWNER[sym].
+ replace_topalias(sym, obj)
+ else
+ # New definition
+ @TOPLEVEL_ALIAS_OWNER[sym] = target
+ replace_topalias(sym, obj)
+ replace_topobj(sym, obj)
+ end
+ }
+
+ # change default_widget_set
+ @current_default_widget_set = target
+ end
+ private :_replace_toplevel_aliases
+
+ def __import_toplevel_aliases__(target, *symbols)
+ current = @current_default_widget_set
+ symbols.each{|sym|
+ sym = sym.to_sym
+ if (obj = @TOPLEVEL_ALIAS_TABLE[target][sym]).nil?
+ # remove
+ @TOPLEVEL_ALIAS_TABLE[current].delete(sym)
+ @TOPLEVEL_ALIAS_OWNER.delete(sym)
+ Tk::TOPLEVEL_ALIASES.module_eval{remove_const sym} if topalias_defined?(sym)
+ Object.class_eval{remove_const sym} if topobj_defined?(sym)
+
+ elsif obj == false
+ # remove, but OWNER[sym] <- false and not treat Object::sym
+ @TOPLEVEL_ALIAS_TABLE[current].delete(sym)
+ @TOPLEVEL_ALIAS_OWNER[sym] = false
+ Tk::TOPLEVEL_ALIASES.module_eval{remove_const sym} if topalias_defined?(sym)
+
+ elsif @TOPLEVEL_ALIAS_OWNER[sym] == false
+ # Object::sym is out of control. --> not change
+ # Keep OWNER[sym].
+ @TOPLEVEL_ALIAS_TABLE[current][sym] = obj
+ replace_topalias(sym, obj)
+
+ else
+ # new definition under control
+ @TOPLEVEL_ALIAS_OWNER[sym] = current
+ @TOPLEVEL_ALIAS_TABLE[current][sym] = obj
+ replace_topalias(sym, obj)
+ replace_topobj(sym, obj)
+ end
+ }
+ end
+
+ def __remove_toplevel_aliases__(*symbols)
+ # remove toplevel aliases of current widget set
+ current = @current_default_widget_set
+ symbols.each{|sym|
+ sym = sym.to_sym
+ @TOPLEVEL_ALIAS_TABLE[current].delete(sym)
+ @TOPLEVEL_ALIAS_OWNER.delete(sym)
+ Tk::TOPLEVEL_ALIASES.module_eval{remove_const sym} if topalias_defined?(sym)
+ Object.class_eval{remove_const sym} if topobj_defined?(sym)
+ }
+ end
+
+ def __reset_toplevel_owner__(*symbols)
+ symbols.each{|sym| @TOPLEVEL_ALIAS_OWNER.delete(sym.to_sym)}
+ end
+
+ def __disable_toplevel_control__(*symbols)
+ symbols.each{|sym| @TOPLEVEL_ALIAS_OWNER[sym.to_sym] = false}
+ end
+
+ def __create_widget_set__(new_set, src_set={})
+ new_set = new_set.to_sym
+ if @TOPLEVEL_ALIAS_TABLE[new_set]
+ fail RuntimeError, "A widget-set #{new_set.inspect} is already exist."
+ end
+ if src_set.kind_of?(Symbol)
+ # new_set is an alias name of existed widget set.
+ @TOPLEVEL_ALIAS_TABLE[new_set] = @TOPLEVEL_ALIAS_TABLE[src_set]
+ else
+ @TOPLEVEL_ALIAS_TABLE[new_set] = {}
+ src_set.each{|sym, obj| set_topalias(new_set, obj, sym.to_sym) }
+ end
+ end
+end
+
+
+############################################
+# setup default widget set => :Tk
+Tk.default_widget_set = :Tk
+
+
+############################################
+# depend on the version of Tcl/Tk
+# major, minor, type, patchlevel = TclTkLib.get_version
+
+############################################
+# Ttk (Tile) support
+=begin
+if major > 8 ||
+ (major == 8 && minor > 5) ||
+ (major == 8 && minor == 5 && type >= TclTkLib::RELEASE_TYPE::BETA)
+ # Tcl/Tk 8.5 beta or later
+ Object.autoload :Ttk, 'tkextlib/tile'
+ Tk.autoload :Tile, 'tkextlib/tile'
+
+ require 'tk/ttk_selector'
+end
+=end
+Object.autoload :Ttk, 'tkextlib/tile'
+Tk.autoload :Tile, 'tkextlib/tile'
+require 'tk/ttk_selector'
diff --git a/jni/ruby/ext/tk/lib/tk/bgerror.rb b/jni/ruby/ext/tk/lib/tk/bgerror.rb
new file mode 100644
index 0000000..c82a8e0
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tk/bgerror.rb
@@ -0,0 +1,29 @@
+#
+# tkbgerror -- bgerror ( tkerror ) module
+# 1998/07/16 by Hidetoshi Nagai <nagai@ai.kyutech.ac.jp>
+#
+require 'tk'
+
+module TkBgError
+ extend Tk
+
+ TkCommandNames = ['bgerror'.freeze].freeze
+
+ def bgerror(message)
+ tk_call('bgerror', message)
+ end
+ alias tkerror bgerror
+ alias show bgerror
+ module_function :bgerror, :tkerror, :show
+
+ def set_handler(hdlr = Proc.new) #==> handler :: proc{|msg| ...body... }
+ tk_call('proc', 'bgerror', 'msg', install_cmd(hdlr) + ' $msg')
+ end
+ def set_default
+ begin
+ tk_call('rename', 'bgerror', '')
+ rescue RuntimeError
+ end
+ end
+ module_function :set_handler, :set_default
+end
diff --git a/jni/ruby/ext/tk/lib/tk/bindtag.rb b/jni/ruby/ext/tk/lib/tk/bindtag.rb
new file mode 100644
index 0000000..23b4e0b
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tk/bindtag.rb
@@ -0,0 +1,138 @@
+#
+# tk/bind.rb : control event binding
+#
+require 'tk'
+
+class TkBindTag
+ include TkBindCore
+
+ #BTagID_TBL = {}
+ BTagID_TBL = TkCore::INTERP.create_table
+
+ (Tk_BINDTAG_ID = ["btag".freeze, TkUtil.untrust("00000")]).instance_eval{
+ @mutex = Mutex.new
+ def mutex; @mutex; end
+ freeze
+ }
+
+ TkCore::INTERP.init_ip_env{
+ BTagID_TBL.mutex.synchronize{ BTagID_TBL.clear }
+ }
+
+ def TkBindTag.id2obj(id)
+ BTagID_TBL.mutex.synchronize{
+ (BTagID_TBL[id])? BTagID_TBL[id]: id
+ }
+ end
+
+=begin
+ def TkBindTag.new_by_name(name, *args, &b)
+ BTagID_TBL.mutex.synchronize{
+ return BTagID_TBL[name] if BTagID_TBL[name]
+ }
+
+ self.new.instance_eval{
+ BTagID_TBL.mutex.synchronize{
+ BTagID_TBL.delete @id
+ @id = name
+ BTagID_TBL[@id] = self
+ }
+ bind(*args, &b) if args != []
+ self
+ }
+ end
+=end
+ def TkBindTag.new_by_name(name, *args, &b)
+ obj = nil
+ BTagID_TBL.mutex.synchronize{
+ if BTagID_TBL[name]
+ obj = BTagID_TBL[name]
+ else
+ (obj = BTagID_TBL[name] = self.allocate).instance_eval{
+ @id = name
+ }
+ end
+ }
+ bind(*args, &b) if obj && args != []
+ obj
+ end
+
+ def initialize(*args, &b)
+ Tk_BINDTAG_ID.mutex.synchronize{
+ # @id = Tk_BINDTAG_ID.join('')
+ @id = Tk_BINDTAG_ID.join(TkCore::INTERP._ip_id_)
+ Tk_BINDTAG_ID[1].succ!
+ }
+ BTagID_TBL.mutex.synchronize{
+ BTagID_TBL[@id] = self
+ }
+ bind(*args, &b) if args != []
+ end
+
+ ALL = self.new_by_name('all')
+
+ def name
+ @id
+ end
+
+ def to_eval
+ @id
+ end
+
+ def inspect
+ #Kernel.format "#<TkBindTag: %s>", @id
+ '#<TkBindTag: ' + @id + '>'
+ end
+end
+
+
+class TkBindTagAll<TkBindTag
+ def TkBindTagAll.new(*args, &b)
+ $stderr.puts "Warning: TkBindTagALL is obsolete. Use TkBindTag::ALL\n"
+
+ TkBindTag::ALL.bind(*args, &b) if args != []
+ TkBindTag::ALL
+ end
+end
+
+
+class TkDatabaseClass<TkBindTag
+=begin
+ def self.new(name, *args, &b)
+ BTagID_TBL.mutex.synchronize{
+ return BTagID_TBL[name] if BTagID_TBL[name]
+ }
+ super(name, *args, &b)
+ end
+
+ def initialize(name, *args, &b)
+ @id = name
+ BTagID_TBL.mutex.synchronize{
+ BTagID_TBL[@id] = self
+ }
+ bind(*args, &b) if args != []
+ end
+=end
+ def self.new(name, *args, &b)
+ BTagID_TBL.mutex.synchronize{
+ if BTagID_TBL[name]
+ BTagID_TBL[name]
+ else
+ BTagID_TBL[name] = self.allocate.instance_eval{
+ initialize(name, *args, &b)
+ self
+ }
+ end
+ }
+ end
+
+ def initialize(name, *args, &b)
+ @id = name
+ bind(*args, &b) if args != []
+ end
+
+ def inspect
+ #Kernel.format "#<TkDatabaseClass: %s>", @id
+ '#<TkDatabaseClass: ' + @id + '>'
+ end
+end
diff --git a/jni/ruby/ext/tk/lib/tk/busy.rb b/jni/ruby/ext/tk/lib/tk/busy.rb
new file mode 100644
index 0000000..7f4f89f
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tk/busy.rb
@@ -0,0 +1,118 @@
+#
+# tk/busy.rb: support 'tk busy' command (Tcl/Tk8.6 or later)
+#
+require 'tk'
+
+module Tk::Busy
+ include TkCore
+ extend TkCore
+ extend TkItemConfigMethod
+end
+
+class << Tk::Busy
+ def __item_cget_cmd(win)
+ # maybe need to override
+ ['tk', 'busy', 'cget', win.path]
+ end
+ private :__item_cget_cmd
+
+ def __item_config_cmd(win)
+ # maybe need to override
+ ['tk', 'busy', 'configure', win.path]
+ end
+ private :__item_config_cmd
+
+ def __item_confinfo_cmd(win)
+ # maybe need to override
+ __item_config_cmd(win)
+ end
+ private :__item_confinfo_cmd
+
+ alias cget_tkstring itemcget_tkstring
+ alias cget itemcget
+ alias cget_strict itemcget_strict
+ alias configure itemconfigure
+ alias configinfo itemconfiginfo
+ alias current_configinfo current_itemconfiginfo
+
+ private :itemcget_tkstring, :itemcget, :itemcget_strict
+ private :itemconfigure, :itemconfiginfo, :current_itemconfiginfo
+
+ def method_missing(id, *args)
+ name = id.id2name
+ case args.length
+ when 1
+ if name[-1] == ?=
+ configure name[0..-2], args[0]
+ args[0]
+ else
+ configure name, args[0]
+ self
+ end
+ when 0
+ begin
+ cget(name)
+ rescue
+ super(id, *args)
+ end
+ else
+ super(id, *args)
+ end
+ end
+
+ def hold(win, keys={})
+ tk_call_without_enc('tk', 'busy', 'hold', win, *hash_kv(keys))
+ win
+ end
+
+ def forget(*wins)
+ tk_call_without_enc('tk', 'busy', 'forget', *wins)
+ self
+ end
+
+ def current(pat=None)
+ list(tk_call('tk', 'busy', 'current', pat))
+ end
+
+ def status(win)
+ bool(tk_call_without_enc('tk', 'busy', 'status', win))
+ end
+end
+
+module Tk::Busy
+ def busy_configinfo(option=nil)
+ Tk::Busy.configinfo(self, option)
+ end
+
+ def busy_current_configinfo(option=nil)
+ Tk::Busy.current_configinfo(self, option)
+ end
+
+ def busy_configure(option, value=None)
+ Tk::Busy.configure(self, option, value)
+ self
+ end
+
+ def busy_cget(option)
+ Tk::Busy.configure(self, option)
+ end
+
+ def busy(keys={})
+ Tk::Busy.hold(self, keys)
+ self
+ end
+ alias busy_hold busy
+
+ def busy_forget
+ Tk::Busy.forget(self)
+ self
+ end
+
+ def busy_current?
+ ! Tk::Busy.current(self.path).empty?
+ end
+
+ def busy_status
+ Tk::Busy.status(self)
+ end
+end
diff --git a/jni/ruby/ext/tk/lib/tk/button.rb b/jni/ruby/ext/tk/lib/tk/button.rb
new file mode 100644
index 0000000..65233c9
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tk/button.rb
@@ -0,0 +1,31 @@
+#
+# tk/button.rb : treat button widget
+#
+require 'tk'
+require 'tk/label'
+
+class Tk::Button<Tk::Label
+ TkCommandNames = ['button'.freeze].freeze
+ WidgetClassName = 'Button'.freeze
+ WidgetClassNames[WidgetClassName] ||= self
+ #def create_self(keys)
+ # if keys and keys != None
+ # tk_call_without_enc('button', @path, *hash_kv(keys, true))
+ # else
+ # tk_call_without_enc('button', @path)
+ # end
+ #end
+ #private :create_self
+
+ def invoke
+ _fromUTF8(tk_send_without_enc('invoke'))
+ end
+ def flash
+ tk_send_without_enc('flash')
+ self
+ end
+end
+
+#TkButton = Tk::Button unless Object.const_defined? :TkButton
+#Tk.__set_toplevel_aliases__(:Tk, Tk::Button, :TkButton)
+Tk.__set_loaded_toplevel_aliases__('tk/button.rb', :Tk, Tk::Button, :TkButton)
diff --git a/jni/ruby/ext/tk/lib/tk/canvas.rb b/jni/ruby/ext/tk/lib/tk/canvas.rb
new file mode 100644
index 0000000..f3e9a7c
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tk/canvas.rb
@@ -0,0 +1,846 @@
+#
+# tk/canvas.rb - Tk canvas classes
+# by Yukihiro Matsumoto <matz@caelum.co.jp>
+#
+require 'tk'
+require 'tk/canvastag'
+require 'tk/itemconfig'
+require 'tk/scrollable'
+
+module TkCanvasItemConfig
+ include TkItemConfigMethod
+
+ def __item_strval_optkeys(id)
+ # maybe need to override
+ super(id) + [
+ 'fill', 'activefill', 'disabledfill',
+ 'outline', 'activeoutline', 'disabledoutline'
+ ]
+ end
+ private :__item_strval_optkeys
+
+ def __item_methodcall_optkeys(id)
+ {'coords'=>'coords'}
+ end
+ private :__item_methodcall_optkeys
+
+ def __item_val2ruby_optkeys(id) # { key=>proc, ... }
+ super(id).update('window'=>proc{|i, v| window(v)},
+ 'tags'=>proc{|i, v|
+ simplelist(v).collect{|tag| TkcTag.id2obj(self, tag)}
+ })
+ end
+ private :__item_val2ruby_optkeys
+
+ def __item_pathname(tagOrId)
+ if tagOrId.kind_of?(TkcItem) || tagOrId.kind_of?(TkcTag)
+ self.path + ';' + tagOrId.id.to_s
+ else
+ self.path + ';' + tagOrId.to_s
+ end
+ end
+ private :__item_pathname
+end
+
+class Tk::Canvas<TkWindow
+ include TkCanvasItemConfig
+ include Tk::Scrollable
+
+ TkCommandNames = ['canvas'.freeze].freeze
+ WidgetClassName = 'Canvas'.freeze
+ WidgetClassNames[WidgetClassName] ||= self
+
+ def __destroy_hook__
+ TkcItem::CItemID_TBL.delete(@path)
+ end
+
+ #def create_self(keys)
+ # if keys and keys != None
+ # tk_call_without_enc('canvas', @path, *hash_kv(keys, true))
+ # else
+ # tk_call_without_enc('canvas', @path)
+ # end
+ #end
+ #private :create_self
+
+ def __numval_optkeys
+ super() + ['closeenough']
+ end
+ private :__numval_optkeys
+
+ def __boolval_optkeys
+ super() + ['confine']
+ end
+ private :__boolval_optkeys
+
+ def tagid(tag)
+ if tag.kind_of?(TkcItem) || tag.kind_of?(TkcTag)
+ tag.id
+ else
+ tag # maybe an Array of configure parameters
+ end
+ end
+ private :tagid
+
+
+ # create a canvas item without creating a TkcItem object
+ def create(type, *args)
+ if type.kind_of?(Class) && type < TkcItem
+ # do nothing
+ elsif TkcItem.type2class(type.to_s)
+ type = TkcItem.type2class(type.to_s)
+ else
+ fail ArgumentError, "type must a subclass of TkcItem class, or a string in CItemTypeToClass"
+ end
+ type.create(self, *args)
+ end
+
+ def addtag(tag, mode, *args)
+ mode = mode.to_s
+ if args[0] && mode =~ /^(above|below|with(tag)?)$/
+ args[0] = tagid(args[0])
+ end
+ tk_send_without_enc('addtag', tagid(tag), mode, *args)
+ self
+ end
+ def addtag_above(tagOrId, target)
+ addtag(tagOrId, 'above', tagid(target))
+ end
+ def addtag_all(tagOrId)
+ addtag(tagOrId, 'all')
+ end
+ def addtag_below(tagOrId, target)
+ addtag(tagOrId, 'below', tagid(target))
+ end
+ def addtag_closest(tagOrId, x, y, halo=None, start=None)
+ addtag(tagOrId, 'closest', x, y, halo, start)
+ end
+ def addtag_enclosed(tagOrId, x1, y1, x2, y2)
+ addtag(tagOrId, 'enclosed', x1, y1, x2, y2)
+ end
+ def addtag_overlapping(tagOrId, x1, y1, x2, y2)
+ addtag(tagOrId, 'overlapping', x1, y1, x2, y2)
+ end
+ def addtag_withtag(tagOrId, tag)
+ addtag(tagOrId, 'withtag', tagid(tag))
+ end
+
+ def bbox(tagOrId, *tags)
+ list(tk_send_without_enc('bbox', tagid(tagOrId),
+ *tags.collect{|t| tagid(t)}))
+ end
+
+ #def itembind(tag, context, cmd=Proc.new, *args)
+ # _bind([path, "bind", tagid(tag)], context, cmd, *args)
+ # self
+ #end
+ def itembind(tag, context, *args)
+ # if args[0].kind_of?(Proc) || args[0].kind_of?(Method)
+ if TkComm._callback_entry?(args[0]) || !block_given?
+ cmd = args.shift
+ else
+ cmd = Proc.new
+ end
+ _bind([path, "bind", tagid(tag)], context, cmd, *args)
+ self
+ end
+
+ #def itembind_append(tag, context, cmd=Proc.new, *args)
+ # _bind_append([path, "bind", tagid(tag)], context, cmd, *args)
+ # self
+ #end
+ def itembind_append(tag, context, *args)
+ # if args[0].kind_of?(Proc) || args[0].kind_of?(Method)
+ if TkComm._callback_entry?(args[0]) || !block_given?
+ cmd = args.shift
+ else
+ cmd = Proc.new
+ end
+ _bind_append([path, "bind", tagid(tag)], context, cmd, *args)
+ self
+ end
+
+ def itembind_remove(tag, context)
+ _bind_remove([path, "bind", tagid(tag)], context)
+ self
+ end
+
+ def itembindinfo(tag, context=nil)
+ _bindinfo([path, "bind", tagid(tag)], context)
+ end
+
+ def canvasx(screen_x, *args)
+ #tk_tcl2ruby(tk_send_without_enc('canvasx', screen_x, *args))
+ number(tk_send_without_enc('canvasx', screen_x, *args))
+ end
+ def canvasy(screen_y, *args)
+ #tk_tcl2ruby(tk_send_without_enc('canvasy', screen_y, *args))
+ number(tk_send_without_enc('canvasy', screen_y, *args))
+ end
+ alias canvas_x canvasx
+ alias canvas_y canvasy
+
+ def coords(tag, *args)
+ if args.empty?
+ tk_split_list(tk_send_without_enc('coords', tagid(tag)))
+ else
+ tk_send_without_enc('coords', tagid(tag), *(args.flatten))
+ self
+ end
+ end
+
+ def dchars(tag, first, last=None)
+ tk_send_without_enc('dchars', tagid(tag),
+ _get_eval_enc_str(first), _get_eval_enc_str(last))
+ self
+ end
+
+ def delete(*args)
+ tbl = nil
+ TkcItem::CItemID_TBL.mutex.synchronize{
+ tbl = TkcItem::CItemID_TBL[self.path]
+ }
+ if tbl
+ args.each{|tag|
+ find('withtag', tag).each{|item|
+ if item.kind_of?(TkcItem)
+ TkcItem::CItemID_TBL.mutex.synchronize{
+ tbl.delete(item.id)
+ }
+ end
+ }
+ }
+ end
+ tk_send_without_enc('delete', *args.collect{|t| tagid(t)})
+ self
+ end
+ alias remove delete
+
+ def dtag(tag, tag_to_del=None)
+ tk_send_without_enc('dtag', tagid(tag), tagid(tag_to_del))
+ self
+ end
+ alias deltag dtag
+
+ def find(mode, *args)
+ list(tk_send_without_enc('find', mode, *args)).collect!{|id|
+ TkcItem.id2obj(self, id)
+ }
+ end
+ def find_above(target)
+ find('above', tagid(target))
+ end
+ def find_all
+ find('all')
+ end
+ def find_below(target)
+ find('below', tagid(target))
+ end
+ def find_closest(x, y, halo=None, start=None)
+ find('closest', x, y, halo, start)
+ end
+ def find_enclosed(x1, y1, x2, y2)
+ find('enclosed', x1, y1, x2, y2)
+ end
+ def find_overlapping(x1, y1, x2, y2)
+ find('overlapping', x1, y1, x2, y2)
+ end
+ def find_withtag(tag)
+ find('withtag', tag)
+ end
+
+ def itemfocus(tagOrId=nil)
+ if tagOrId
+ tk_send_without_enc('focus', tagid(tagOrId))
+ self
+ else
+ ret = tk_send_without_enc('focus')
+ if ret == ""
+ nil
+ else
+ TkcItem.id2obj(self, ret)
+ end
+ end
+ end
+
+ def gettags(tagOrId)
+ list(tk_send_without_enc('gettags', tagid(tagOrId))).collect{|tag|
+ TkcTag.id2obj(self, tag)
+ }
+ end
+
+ def icursor(tagOrId, index)
+ tk_send_without_enc('icursor', tagid(tagOrId), index)
+ self
+ end
+
+ def imove(tagOrId, idx, x, y)
+ tk_send_without_enc('imove', tagid(tagOrId), idx, x, y)
+ self
+ end
+ alias i_move imove
+
+ def index(tagOrId, idx)
+ number(tk_send_without_enc('index', tagid(tagOrId), idx))
+ end
+
+ def insert(tagOrId, index, string)
+ tk_send_without_enc('insert', tagid(tagOrId), index,
+ _get_eval_enc_str(string))
+ self
+ end
+
+=begin
+ def itemcget(tagOrId, option)
+ case option.to_s
+ when 'dash', 'activedash', 'disableddash'
+ conf = tk_send_without_enc('itemcget', tagid(tagOrId), "-#{option}")
+ if conf =~ /^[0-9]/
+ list(conf)
+ else
+ conf
+ end
+ when 'text', 'label', 'show', 'data', 'file', 'maskdata', 'maskfile'
+ _fromUTF8(tk_send_without_enc('itemcget', tagid(tagOrId), "-#{option}"))
+ when 'font', 'kanjifont'
+ #fnt = tk_tcl2ruby(tk_send('itemcget', tagid(tagOrId), "-#{option}"))
+ fnt = tk_tcl2ruby(_fromUTF8(tk_send_with_enc('itemcget', tagid(tagOrId), '-font')))
+ unless fnt.kind_of?(TkFont)
+ fnt = tagfontobj(tagid(tagOrId), fnt)
+ end
+ if option.to_s == 'kanjifont' && JAPANIZED_TK && TK_VERSION =~ /^4\.*/
+ # obsolete; just for compatibility
+ fnt.kanji_font
+ else
+ fnt
+ end
+ else
+ tk_tcl2ruby(_fromUTF8(tk_send_without_enc('itemcget', tagid(tagOrId),
+ "-#{option}")))
+ end
+ end
+
+ def itemconfigure(tagOrId, key, value=None)
+ if key.kind_of? Hash
+ key = _symbolkey2str(key)
+ coords = key.delete('coords')
+ self.coords(tagOrId, coords) if coords
+
+ if ( key['font'] || key['kanjifont'] \
+ || key['latinfont'] || key['asciifont'] )
+ tagfont_configure(tagid(tagOrId), key.dup)
+ else
+ _fromUTF8(tk_send_without_enc('itemconfigure', tagid(tagOrId),
+ *hash_kv(key, true)))
+ end
+
+ else
+ if ( key == 'coords' || key == :coords )
+ self.coords(tagOrId, value)
+ elsif ( key == 'font' || key == :font ||
+ key == 'kanjifont' || key == :kanjifont ||
+ key == 'latinfont' || key == :latinfont ||
+ key == 'asciifont' || key == :asciifont )
+ if value == None
+ tagfontobj(tagid(tagOrId))
+ else
+ tagfont_configure(tagid(tagOrId), {key=>value})
+ end
+ else
+ _fromUTF8(tk_send_without_enc('itemconfigure', tagid(tagOrId),
+ "-#{key}", _get_eval_enc_str(value)))
+ end
+ end
+ self
+ end
+# def itemconfigure(tagOrId, key, value=None)
+# if key.kind_of? Hash
+# tk_send 'itemconfigure', tagid(tagOrId), *hash_kv(key)
+# else
+# tk_send 'itemconfigure', tagid(tagOrId), "-#{key}", value
+# end
+# end
+# def itemconfigure(tagOrId, keys)
+# tk_send 'itemconfigure', tagid(tagOrId), *hash_kv(keys)
+# end
+
+ def itemconfiginfo(tagOrId, key=nil)
+ if TkComm::GET_CONFIGINFO_AS_ARRAY
+ if key
+ case key.to_s
+ when 'coords'
+ return ['coords', '', '', '', self.coords(tagOrId)]
+ when 'dash', 'activedash', 'disableddash'
+ conf = tk_split_simplelist(tk_send_without_enc('itemconfigure', tagid(tagOrId), "-#{key}"))
+ if conf[3] && conf[3] =~ /^[0-9]/
+ conf[3] = list(conf[3])
+ end
+ if conf[4] && conf[4] =~ /^[0-9]/
+ conf[4] = list(conf[4])
+ end
+ when 'text', 'label', 'show', 'data', 'file', 'maskdata', 'maskfile'
+ conf = tk_split_simplelist(_fromUTF8(tk_send_without_enc('itemconfigure', tagid(tagOrId), "-#{key}")))
+ when 'font', 'kanjifont'
+ conf = tk_split_simplelist(_fromUTF8(tk_send_without_enc('itemconfigure', tagid(tagOrId),"-#{key}")))
+ conf[4] = tagfont_configinfo(tagid(tagOrId), conf[4])
+ else
+ conf = tk_split_list(_fromUTF8(tk_send_without_enc('itemconfigure', tagid(tagOrId), "-#{key}")))
+ end
+ conf[0] = conf[0][1..-1]
+ conf
+ else
+ ret = tk_split_simplelist(_fromUTF8(tk_send_without_enc('itemconfigure', tagid(tagOrId)))).collect{|conflist|
+ conf = tk_split_simplelist(conflist)
+ conf[0] = conf[0][1..-1]
+ case conf[0]
+ when 'text', 'label', 'show', 'data', 'file', 'maskdata', 'maskfile'
+ when 'dash', 'activedash', 'disableddash'
+ if conf[3] && conf[3] =~ /^[0-9]/
+ conf[3] = list(conf[3])
+ end
+ if conf[4] && conf[4] =~ /^[0-9]/
+ conf[4] = list(conf[4])
+ end
+ else
+ if conf[3]
+ if conf[3].index('{')
+ conf[3] = tk_split_list(conf[3])
+ else
+ conf[3] = tk_tcl2ruby(conf[3])
+ end
+ end
+ if conf[4]
+ if conf[4].index('{')
+ conf[4] = tk_split_list(conf[4])
+ else
+ conf[4] = tk_tcl2ruby(conf[4])
+ end
+ end
+ end
+ conf[1] = conf[1][1..-1] if conf.size == 2 # alias info
+ conf
+ }
+
+ fontconf = ret.assoc('font')
+ if fontconf
+ ret.delete_if{|item| item[0] == 'font' || item[0] == 'kanjifont'}
+ fontconf[4] = tagfont_configinfo(tagid(tagOrId), fontconf[4])
+ ret.push(fontconf)
+ end
+
+ ret << ['coords', '', '', '', self.coords(tagOrId)]
+ end
+ else # ! TkComm::GET_CONFIGINFO_AS_ARRAY
+ if key
+ case key.to_s
+ when 'coords'
+ {'coords' => ['', '', '', self.coords(tagOrId)]}
+ when 'dash', 'activedash', 'disableddash'
+ conf = tk_split_simplelist(tk_send_without_enc('itemconfigure',
+ tagid(tagOrId),
+ "-#{key}"))
+ if conf[3] && conf[3] =~ /^[0-9]/
+ conf[3] = list(conf[3])
+ end
+ if conf[4] && conf[4] =~ /^[0-9]/
+ conf[4] = list(conf[4])
+ end
+ when 'text', 'label', 'show', 'data', 'file', 'maskdata', 'maskfile'
+ conf = tk_split_simplelist(_fromUTF8(tk_send_without_enc('itemconfigure', tagid(tagOrId), "-#{key}")))
+ when 'font', 'kanjifont'
+ conf = tk_split_simplelist(_fromUTF8(tk_send_without_enc('itemconfigure', tagid(tagOrId),"-#{key}")))
+ conf[4] = tagfont_configinfo(tagid(tagOrId), conf[4])
+ else
+ conf = tk_split_list(_fromUTF8(tk_send_without_enc('itemconfigure', tagid(tagOrId), "-#{key}")))
+ end
+ key = conf.shift[1..-1]
+ { key => conf }
+ else
+ ret = {}
+ tk_split_simplelist(_fromUTF8(tk_send_without_enc('itemconfigure', tagid(tagOrId)))).each{|conflist|
+ conf = tk_split_simplelist(conflist)
+ key = conf.shift[1..-1]
+ case key
+ when 'text', 'label', 'show', 'data', 'file', 'maskdata', 'maskfile'
+ when 'dash', 'activedash', 'disableddash'
+ if conf[2] && conf[2] =~ /^[0-9]/
+ conf[2] = list(conf[2])
+ end
+ if conf[3] && conf[3] =~ /^[0-9]/
+ conf[3] = list(conf[3])
+ end
+ else
+ if conf[2]
+ if conf[2].index('{')
+ conf[2] = tk_split_list(conf[2])
+ else
+ conf[2] = tk_tcl2ruby(conf[2])
+ end
+ end
+ if conf[3]
+ if conf[3].index('{')
+ conf[3] = tk_split_list(conf[3])
+ else
+ conf[3] = tk_tcl2ruby(conf[3])
+ end
+ end
+ end
+ if conf.size == 1
+ ret[key] = conf[0][1..-1] # alias info
+ else
+ ret[key] = conf
+ end
+ }
+
+ fontconf = ret['font']
+ if fontconf
+ ret.delete('font')
+ ret.delete('kanjifont')
+ fontconf[3] = tagfont_configinfo(tagid(tagOrId), fontconf[3])
+ ret['font'] = fontconf
+ end
+
+ ret['coords'] = ['', '', '', self.coords(tagOrId)]
+
+ ret
+ end
+ end
+ end
+
+ def current_itemconfiginfo(tagOrId, key=nil)
+ if TkComm::GET_CONFIGINFO_AS_ARRAY
+ if key
+ conf = itemconfiginfo(tagOrId, key)
+ {conf[0] => conf[4]}
+ else
+ ret = {}
+ itemconfiginfo(tagOrId).each{|conf|
+ ret[conf[0]] = conf[4] if conf.size > 2
+ }
+ ret
+ end
+ else # ! TkComm::GET_CONFIGINFO_AS_ARRAY
+ ret = {}
+ itemconfiginfo(tagOrId, key).each{|k, conf|
+ ret[k] = conf[-1] if conf.kind_of?(Array)
+ }
+ ret
+ end
+ end
+=end
+
+ def lower(tag, below=nil)
+ if below
+ tk_send_without_enc('lower', tagid(tag), tagid(below))
+ else
+ tk_send_without_enc('lower', tagid(tag))
+ end
+ self
+ end
+
+ def move(tag, dx, dy)
+ tk_send_without_enc('move', tagid(tag), dx, dy)
+ self
+ end
+
+ def moveto(tag, x, y)
+ # Tcl/Tk 8.6 or later
+ tk_send_without_enc('moveto', tagid(tag), x, y)
+ self
+ end
+ alias move_to moveto
+
+ def postscript(keys)
+ tk_send("postscript", *hash_kv(keys))
+ end
+
+ def raise(tag, above=nil)
+ if above
+ tk_send_without_enc('raise', tagid(tag), tagid(above))
+ else
+ tk_send_without_enc('raise', tagid(tag))
+ end
+ self
+ end
+
+ def rchars(tag, first, last, str_or_coords)
+ # Tcl/Tk 8.6 or later
+ str_or_coords = str_or_coords.flatten if str_or_coords.kinad_of? Array
+ tk_send_without_enc('rchars', tagid(tag), first, last, str_or_coords)
+ self
+ end
+ alias replace_chars rchars
+ alias replace_coords rchars
+
+ def scale(tag, x, y, xs, ys)
+ tk_send_without_enc('scale', tagid(tag), x, y, xs, ys)
+ self
+ end
+
+ def scan_mark(x, y)
+ tk_send_without_enc('scan', 'mark', x, y)
+ self
+ end
+ def scan_dragto(x, y, gain=None)
+ tk_send_without_enc('scan', 'dragto', x, y, gain)
+ self
+ end
+
+ def select(mode, *args)
+ r = tk_send_without_enc('select', mode, *args)
+ (mode == 'item')? TkcItem.id2obj(self, r): self
+ end
+ def select_adjust(tagOrId, index)
+ select('adjust', tagid(tagOrId), index)
+ end
+ def select_clear
+ select('clear')
+ end
+ def select_from(tagOrId, index)
+ select('from', tagid(tagOrId), index)
+ end
+ def select_item
+ select('item')
+ end
+ def select_to(tagOrId, index)
+ select('to', tagid(tagOrId), index)
+ end
+
+ def itemtype(tag)
+ TkcItem.type2class(tk_send('type', tagid(tag)))
+ end
+
+ def create_itemobj_from_id(idnum)
+ id = TkcItem.id2obj(self, idnum.to_i)
+ return id if id.kind_of?(TkcItem)
+
+ typename = tk_send('type', id)
+ unless type = TkcItem.type2class(typename)
+ (itemclass = typename.dup)[0,1] = typename[0,1].upcase
+ type = TkcItem.const_set(itemclass, Class.new(TkcItem))
+ type.const_set("CItemTypeName", typename.freeze)
+ TkcItem::CItemTypeToClass[typename] = type
+ end
+
+ canvas = self
+ (obj = type.allocate).instance_eval{
+ @parent = @c = canvas
+ @path = canvas.path
+ @id = id
+ TkcItem::CItemID_TBL.mutex.synchronize{
+ TkcItem::CItemID_TBL[@path] = {} unless TkcItem::CItemID_TBL[@path]
+ TkcItem::CItemID_TBL[@path][@id] = self
+ }
+ }
+ end
+end
+
+#TkCanvas = Tk::Canvas unless Object.const_defined? :TkCanvas
+#Tk.__set_toplevel_aliases__(:Tk, Tk::Canvas, :TkCanvas)
+Tk.__set_loaded_toplevel_aliases__('tk/canvas.rb', :Tk, Tk::Canvas, :TkCanvas)
+
+
+class TkcItem<TkObject
+ extend Tk
+ include TkcTagAccess
+ extend TkItemFontOptkeys
+ extend TkItemConfigOptkeys
+
+ CItemTypeName = nil
+ CItemTypeToClass = {}
+
+ CItemID_TBL = TkCore::INTERP.create_table
+
+ TkCore::INTERP.init_ip_env{
+ CItemID_TBL.mutex.synchronize{ CItemID_TBL.clear }
+ }
+
+ def TkcItem.type2class(type)
+ CItemTypeToClass[type]
+ end
+
+ def TkcItem.id2obj(canvas, id)
+ cpath = canvas.path
+ CItemID_TBL.mutex.synchronize{
+ if CItemID_TBL[cpath]
+ CItemID_TBL[cpath][id]? CItemID_TBL[cpath][id]: id
+ else
+ id
+ end
+ }
+ end
+
+ ########################################
+ def self._parse_create_args(args)
+ fontkeys = {}
+ methodkeys = {}
+ if args[-1].kind_of? Hash
+ keys = _symbolkey2str(args.pop)
+ if args.size == 0
+ args = keys.delete('coords')
+ unless args.kind_of?(Array)
+ fail "coords parameter must be given by an Array"
+ end
+ end
+
+ #['font', 'kanjifont', 'latinfont', 'asciifont'].each{|key|
+ # fontkeys[key] = keys.delete(key) if keys.key?(key)
+ #}
+ __item_font_optkeys(nil).each{|key|
+ fkey = key.to_s
+ fontkeys[fkey] = keys.delete(fkey) if keys.key?(fkey)
+
+ fkey = "kanji#{key}"
+ fontkeys[fkey] = keys.delete(fkey) if keys.key?(fkey)
+
+ fkey = "latin#{key}"
+ fontkeys[fkey] = keys.delete(fkey) if keys.key?(fkey)
+
+ fkey = "ascii#{key}"
+ fontkeys[fkey] = keys.delete(fkey) if keys.key?(fkey)
+ }
+
+ __item_optkey_aliases(nil).each{|alias_name, real_name|
+ alias_name = alias_name.to_s
+ if keys.has_key?(alias_name)
+ keys[real_name.to_s] = keys.delete(alias_name)
+ end
+ }
+
+ __item_methodcall_optkeys(nil).each{|key|
+ key = key.to_s
+ methodkeys[key] = keys.delete(key) if keys.key?(key)
+ }
+
+ __item_ruby2val_optkeys(nil).each{|key, method|
+ key = key.to_s
+ keys[key] = method.call(keys[key]) if keys.has_key?(key)
+ }
+
+ #args = args.flatten.concat(hash_kv(keys))
+ args = args.flatten.concat(itemconfig_hash_kv(nil, keys))
+ else
+ args = args.flatten
+ end
+
+ [args, fontkeys, methodkeys]
+ end
+ private_class_method :_parse_create_args
+
+ def self.create(canvas, *args)
+ unless self::CItemTypeName
+ fail RuntimeError, "#{self} is an abstract class"
+ end
+ args, fontkeys, methodkeys = _parse_create_args(args)
+ idnum = tk_call_without_enc(canvas.path, 'create',
+ self::CItemTypeName, *args)
+ canvas.itemconfigure(idnum, fontkeys) unless fontkeys.empty?
+ canvas.itemconfigure(idnum, methodkeys) unless methodkeys.empty?
+ idnum.to_i # 'canvas item id' is an integer number
+ end
+ ########################################
+
+ def initialize(parent, *args)
+ #unless parent.kind_of?(Tk::Canvas)
+ # fail ArgumentError, "expect Tk::Canvas for 1st argument"
+ #end
+ @parent = @c = parent
+ @path = parent.path
+
+ @id = create_self(*args) # an integer number as 'canvas item id'
+ CItemID_TBL.mutex.synchronize{
+ CItemID_TBL[@path] = {} unless CItemID_TBL[@path]
+ CItemID_TBL[@path][@id] = self
+ }
+ end
+ def create_self(*args)
+ self.class.create(@c, *args) # return an integer number as 'canvas item id'
+ end
+ private :create_self
+
+ def id
+ @id
+ end
+
+ def exist?
+ if @c.find_withtag(@id)
+ true
+ else
+ false
+ end
+ end
+
+ def delete
+ @c.delete @id
+ CItemID_TBL.mutex.synchronize{
+ CItemID_TBL[@path].delete(@id) if CItemID_TBL[@path]
+ }
+ self
+ end
+ alias remove delete
+ alias destroy delete
+end
+
+class TkcArc<TkcItem
+ CItemTypeName = 'arc'.freeze
+ CItemTypeToClass[CItemTypeName] = self
+end
+
+class TkcBitmap<TkcItem
+ CItemTypeName = 'bitmap'.freeze
+ CItemTypeToClass[CItemTypeName] = self
+end
+
+class TkcImage<TkcItem
+ CItemTypeName = 'image'.freeze
+ CItemTypeToClass[CItemTypeName] = self
+end
+
+class TkcLine<TkcItem
+ CItemTypeName = 'line'.freeze
+ CItemTypeToClass[CItemTypeName] = self
+end
+
+class TkcOval<TkcItem
+ CItemTypeName = 'oval'.freeze
+ CItemTypeToClass[CItemTypeName] = self
+end
+
+class TkcPolygon<TkcItem
+ CItemTypeName = 'polygon'.freeze
+ CItemTypeToClass[CItemTypeName] = self
+end
+
+class TkcRectangle<TkcItem
+ CItemTypeName = 'rectangle'.freeze
+ CItemTypeToClass[CItemTypeName] = self
+end
+
+class TkcText<TkcItem
+ CItemTypeName = 'text'.freeze
+ CItemTypeToClass[CItemTypeName] = self
+ def self.create(canvas, *args)
+ if args[-1].kind_of?(Hash)
+ keys = _symbolkey2str(args.pop)
+ txt = keys['text']
+ keys['text'] = _get_eval_enc_str(txt) if txt
+ args.push(keys)
+ end
+ super(canvas, *args)
+ end
+end
+
+class TkcWindow<TkcItem
+ CItemTypeName = 'window'.freeze
+ CItemTypeToClass[CItemTypeName] = self
+ def self.create(canvas, *args)
+ if args[-1].kind_of?(Hash)
+ keys = _symbolkey2str(args.pop)
+ win = keys['window']
+ # keys['window'] = win.epath if win.kind_of?(TkWindow)
+ keys['window'] = _epath(win) if win
+ args.push(keys)
+ end
+ super(canvas, *args)
+ end
+end
diff --git a/jni/ruby/ext/tk/lib/tk/canvastag.rb b/jni/ruby/ext/tk/lib/tk/canvastag.rb
new file mode 100644
index 0000000..495d92a
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tk/canvastag.rb
@@ -0,0 +1,459 @@
+#
+# tk/canvastag.rb - methods for treating canvas tags
+#
+require 'tk'
+require 'tk/tagfont'
+
+module TkcTagAccess
+ include TkComm
+ include TkTreatTagFont
+end
+
+require 'tk/canvas'
+
+module TkcTagAccess
+ def addtag(tag)
+ @c.addtag(tag, 'withtag', @id)
+ self
+ end
+
+ def bbox
+ @c.bbox(@id)
+ end
+
+ #def bind(seq, cmd=Proc.new, *args)
+ # @c.itembind(@id, seq, cmd, *args)
+ # self
+ #end
+ def bind(seq, *args)
+ # if args[0].kind_of?(Proc) || args[0].kind_of?(Method)
+ if TkComm._callback_entry?(args[0]) || !block_given?
+ cmd = args.shift
+ else
+ cmd = Proc.new
+ end
+ @c.itembind(@id, seq, cmd, *args)
+ self
+ end
+
+ #def bind_append(seq, cmd=Proc.new, *args)
+ # @c.itembind_append(@id, seq, cmd, *args)
+ # self
+ #end
+ def bind_append(seq, *args)
+ # if args[0].kind_of?(Proc) || args[0].kind_of?(Method)
+ if TkComm._callback_entry?(args[0]) || !block_given?
+ cmd = args.shift
+ else
+ cmd = Proc.new
+ end
+ @c.itembind_append(@id, seq, cmd, *args)
+ self
+ end
+
+ def bind_remove(seq)
+ @c.itembind_remove(@id, seq)
+ self
+ end
+
+ def bindinfo(seq=nil)
+ @c.itembindinfo(@id, seq)
+ end
+
+ def cget_tkstring(option)
+ @c.itemcget_tkstring(@id, option)
+ end
+ def cget(option)
+ @c.itemcget(@id, option)
+ end
+ def cget_strict(option)
+ @c.itemcget_strict(@id, option)
+ end
+
+ def configure(key, value=None)
+ @c.itemconfigure(@id, key, value)
+ self
+ end
+# def configure(keys)
+# @c.itemconfigure @id, keys
+# end
+
+ def configinfo(key=nil)
+ @c.itemconfiginfo(@id, key)
+ end
+
+ def current_configinfo(key=nil)
+ @c.current_itemconfiginfo(@id, key)
+ end
+
+ def coords(*args)
+ @c.coords(@id, *args)
+ end
+
+ def dchars(first, last=None)
+ @c.dchars(@id, first, last)
+ self
+ end
+
+ def dtag(tag_to_del=None)
+ @c.dtag(@id, tag_to_del)
+ self
+ end
+ alias deltag dtag
+
+ def find
+ @c.find('withtag', @id)
+ end
+ alias list find
+
+ def focus
+ @c.itemfocus(@id)
+ end
+
+ def gettags
+ @c.gettags(@id)
+ end
+
+ def icursor(index)
+ @c.icursor(@id, index)
+ self
+ end
+
+ def imove(idx, x, y)
+ # Tcl/Tk 8.6 or later
+ @c.imove(@id, idx, x, y)
+ self
+ end
+ alias i_move imove
+
+ def index(idx)
+ @c.index(@id, idx)
+ end
+
+ def insert(beforethis, string)
+ @c.insert(@id, beforethis, string)
+ self
+ end
+
+ def lower(belowthis=None)
+ @c.lower(@id, belowthis)
+ self
+ end
+
+ def move(xamount, yamount)
+ @c.move(@id, xamount, yamount)
+ self
+ end
+
+ def moveto(x, y)
+ # Tcl/Tk 8.6 or later
+ @c.moveto(@id, x, y)
+ self
+ end
+ alias move_to moveto
+
+ def raise(abovethis=None)
+ @c.raise(@id, abovethis)
+ self
+ end
+
+ def scale(xorigin, yorigin, xscale, yscale)
+ @c.scale(@id, xorigin, yorigin, xscale, yscale)
+ self
+ end
+
+ def rchars(first, last, str_or_coords)
+ # Tcl/Tk 8.6 or later
+ @c.rchars(@id, first, last, str_or_coords)
+ self
+ end
+ alias replace_chars rchars
+ alias replace_coords rchars
+
+ def select_adjust(index)
+ @c.select('adjust', @id, index)
+ self
+ end
+ def select_from(index)
+ @c.select('from', @id, index)
+ self
+ end
+ def select_to(index)
+ @c.select('to', @id, index)
+ self
+ end
+
+ def itemtype
+ @c.itemtype(@id)
+ end
+
+ # Following operators support logical expressions of canvas tags
+ # (for Tk8.3+).
+ # If tag1.path is 't1' and tag2.path is 't2', then
+ # ltag = tag1 & tag2; ltag.path => "(t1)&&(t2)"
+ # ltag = tag1 | tag2; ltag.path => "(t1)||(t2)"
+ # ltag = tag1 ^ tag2; ltag.path => "(t1)^(t2)"
+ # ltag = - tag1; ltag.path => "!(t1)"
+ def & (tag)
+ if tag.kind_of? TkObject
+ TkcTagString.new(@c, '(' + @id + ')&&(' + tag.path + ')')
+ else
+ TkcTagString.new(@c, '(' + @id + ')&&(' + tag.to_s + ')')
+ end
+ end
+
+ def | (tag)
+ if tag.kind_of? TkObject
+ TkcTagString.new(@c, '(' + @id + ')||(' + tag.path + ')')
+ else
+ TkcTagString.new(@c, '(' + @id + ')||(' + tag.to_s + ')')
+ end
+ end
+
+ def ^ (tag)
+ if tag.kind_of? TkObject
+ TkcTagString.new(@c, '(' + @id + ')^(' + tag.path + ')')
+ else
+ TkcTagString.new(@c, '(' + @id + ')^(' + tag.to_s + ')')
+ end
+ end
+
+ def -@
+ TkcTagString.new(@c, '!(' + @id + ')')
+ end
+end
+
+class TkcTag<TkObject
+ include TkcTagAccess
+
+ CTagID_TBL = TkCore::INTERP.create_table
+
+ (Tk_CanvasTag_ID = ['ctag'.freeze, TkUtil.untrust('00000')]).instance_eval{
+ @mutex = Mutex.new
+ def mutex; @mutex; end
+ freeze
+ }
+
+ TkCore::INTERP.init_ip_env{
+ CTagID_TBL.mutex.synchronize{ CTagID_TBL.clear }
+ }
+
+ def TkcTag.id2obj(canvas, id)
+ cpath = canvas.path
+ CTagID_TBL.mutex.synchronize{
+ if CTagID_TBL[cpath]
+ CTagID_TBL[cpath][id]? CTagID_TBL[cpath][id]: id
+ else
+ id
+ end
+ }
+ end
+
+ def initialize(parent, mode=nil, *args)
+ #unless parent.kind_of?(TkCanvas)
+ # fail ArgumentError, "expect TkCanvas for 1st argument"
+ #end
+ @c = parent
+ @cpath = parent.path
+ Tk_CanvasTag_ID.mutex.synchronize{
+ # @path = @id = Tk_CanvasTag_ID.join('')
+ @path = @id = Tk_CanvasTag_ID.join(TkCore::INTERP._ip_id_)
+ Tk_CanvasTag_ID[1].succ!
+ }
+ CTagID_TBL.mutex.synchronize{
+ CTagID_TBL[@cpath] = {} unless CTagID_TBL[@cpath]
+ CTagID_TBL[@cpath][@id] = self
+ }
+ if mode
+ tk_call_without_enc(@c.path, "addtag", @id, mode, *args)
+ end
+ end
+ def id
+ @id
+ end
+
+ def exist?
+ if @c.find_withtag(@id)
+ true
+ else
+ false
+ end
+ end
+
+ def delete
+ @c.delete @id
+ CTagID_TBL.mutex.synchronize{
+ CTagID_TBL[@cpath].delete(@id) if CTagID_TBL[@cpath]
+ }
+ self
+ end
+ alias remove delete
+ alias destroy delete
+
+ def set_to_above(target)
+ @c.addtag_above(@id, target)
+ self
+ end
+ alias above set_to_above
+
+ def set_to_all
+ @c.addtag_all(@id)
+ self
+ end
+ alias all set_to_all
+
+ def set_to_below(target)
+ @c.addtag_below(@id, target)
+ self
+ end
+ alias below set_to_below
+
+ def set_to_closest(x, y, halo=None, start=None)
+ @c.addtag_closest(@id, x, y, halo, start)
+ self
+ end
+ alias closest set_to_closest
+
+ def set_to_enclosed(x1, y1, x2, y2)
+ @c.addtag_enclosed(@id, x1, y1, x2, y2)
+ self
+ end
+ alias enclosed set_to_enclosed
+
+ def set_to_overlapping(x1, y1, x2, y2)
+ @c.addtag_overlapping(@id, x1, y1, x2, y2)
+ self
+ end
+ alias overlapping set_to_overlapping
+
+ def set_to_withtag(target)
+ @c.addtag_withtag(@id, target)
+ self
+ end
+ alias withtag set_to_withtag
+end
+
+class TkcTagString<TkcTag
+ def self.new(parent, name, mode=nil, *args)
+ obj = nil
+ CTagID_TBL.mutex.synchronize{
+ if CTagID_TBL[parent.path] && CTagID_TBL[parent.path][name]
+ obj = CTagID_TBL[parent.path][name]
+ else
+ # super(parent, name, *args)
+ (obj = self.allocate).instance_eval{
+ @c = parent
+ @cpath = parent.path
+ @path = @id = name
+ CTagID_TBL[@cpath] = {} unless CTagID_TBL[@cpath]
+ CTagID_TBL[@cpath][@id] = self
+ }
+ end
+ }
+ if obj && mode
+ tk_call_without_enc(@c.path, "addtag", @id, mode, *args)
+ end
+ obj
+ end
+
+ def initialize(parent, name, mode=nil, *args)
+ # dummy:: not called by 'new' method
+
+ #unless parent.kind_of?(TkCanvas)
+ # fail ArgumentError, "expect TkCanvas for 1st argument"
+ #end
+ @c = parent
+ @cpath = parent.path
+ @path = @id = name
+
+ if mode
+ tk_call_without_enc(@c.path, "addtag", @id, mode, *args)
+ end
+ end
+end
+TkcNamedTag = TkcTagString
+
+class TkcTagAll<TkcTagString
+ def self.new(parent)
+ super(parent, 'all')
+ end
+=begin
+ def initialize(parent)
+ #unless parent.kind_of?(TkCanvas)
+ # fail ArgumentError, "expect TkCanvas for 1st argument"
+ #end
+ @c = parent
+ @cpath = parent.path
+ @path = @id = 'all'
+ CTagID_TBL.mutex.synchronize{
+ CTagID_TBL[@cpath] = {} unless CTagID_TBL[@cpath]
+ CTagID_TBL[@cpath][@id] = self
+ }
+ end
+=end
+end
+
+class TkcTagCurrent<TkcTagString
+ def self.new(parent)
+ super(parent, 'current')
+ end
+=begin
+ def initialize(parent)
+ #unless parent.kind_of?(TkCanvas)
+ # fail ArgumentError, "expect TkCanvas for 1st argument"
+ #end
+ @c = parent
+ @cpath = parent.path
+ @path = @id = 'current'
+ CTagID_TBL.mutex.synchronize{
+ CTagID_TBL[@cpath] = {} unless CTagID_TBL[@cpath]
+ CTagID_TBL[@cpath][@id] = self
+ }
+ end
+=end
+end
+
+class TkcGroup<TkcTag
+ (Tk_cGroup_ID = ['tkcg'.freeze, TkUtil.untrust('00000')]).instance_eval{
+ @mutex = Mutex.new
+ def mutex; @mutex; end
+ freeze
+ }
+
+ #def create_self(parent, *args)
+ def initialize(parent, *args)
+ #unless parent.kind_of?(TkCanvas)
+ # fail ArgumentError, "expect TkCanvas for 1st argument"
+ #end
+ @c = parent
+ @cpath = parent.path
+ Tk_cGroup_ID.mutex.synchronize{
+ # @path = @id = Tk_cGroup_ID.join('')
+ @path = @id = Tk_cGroup_ID.join(TkCore::INTERP._ip_id_)
+ Tk_cGroup_ID[1].succ!
+ }
+ CTagID_TBL.mutex.synchronize{
+ CTagID_TBL[@cpath] = {} unless CTagID_TBL[@cpath]
+ CTagID_TBL[@cpath][@id] = self
+ }
+ include(*args) if args != []
+ end
+ #private :create_self
+
+ def include(*tags)
+ for i in tags
+ #i.addtag(@id)
+ @c.addtag_withtag(@id, i)
+ end
+ self
+ end
+ alias add include
+
+ def exclude(*tags)
+ for i in tags
+ #i.dtag(@id)
+ @c.dtag(i, @id)
+ end
+ self
+ end
+end
diff --git a/jni/ruby/ext/tk/lib/tk/checkbutton.rb b/jni/ruby/ext/tk/lib/tk/checkbutton.rb
new file mode 100644
index 0000000..b744954
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tk/checkbutton.rb
@@ -0,0 +1,32 @@
+#
+# tk/checkbutton.rb : treat checkbutton widget
+#
+require 'tk'
+require 'tk/radiobutton'
+
+class Tk::CheckButton<Tk::RadioButton
+ TkCommandNames = ['checkbutton'.freeze].freeze
+ WidgetClassName = 'Checkbutton'.freeze
+ WidgetClassNames[WidgetClassName] ||= self
+ #def create_self(keys)
+ # if keys and keys != None
+ # tk_call_without_enc('checkbutton', @path, *hash_kv(keys, true))
+ # else
+ # tk_call_without_enc('checkbutton', @path)
+ # end
+ #end
+ #private :create_self
+
+ def toggle
+ tk_send_without_enc('toggle')
+ self
+ end
+end
+
+Tk::Checkbutton = Tk::CheckButton
+#TkCheckButton = Tk::CheckButton unless Object.const_defined? :TkCheckButton
+#TkCheckbutton = Tk::Checkbutton unless Object.const_defined? :TkCheckbutton
+#Tk.__set_toplevel_aliases__(:Tk, Tk::CheckButton,
+# :TkCheckButton, :TkCheckbutton)
+Tk.__set_loaded_toplevel_aliases__('tk/checkbutton.rb', :Tk, Tk::CheckButton,
+ :TkCheckButton, :TkCheckbutton)
diff --git a/jni/ruby/ext/tk/lib/tk/clipboard.rb b/jni/ruby/ext/tk/lib/tk/clipboard.rb
new file mode 100644
index 0000000..d4205a5
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tk/clipboard.rb
@@ -0,0 +1,75 @@
+#
+# tk/clipboard.rb : methods to treat clipboard
+#
+require 'tk'
+
+module TkClipboard
+ include Tk
+ extend Tk
+
+ TkCommandNames = ['clipboard'.freeze].freeze
+
+ def self.clear(win=nil)
+ if win
+ tk_call_without_enc('clipboard', 'clear', '-displayof', win)
+ else
+ tk_call_without_enc('clipboard', 'clear')
+ end
+ end
+ def self.clear_on_display(win)
+ tk_call_without_enc('clipboard', 'clear', '-displayof', win)
+ end
+
+ def self.get(type=nil)
+ if type
+ tk_call_without_enc('clipboard', 'get', '-type', type)
+ else
+ tk_call_without_enc('clipboard', 'get')
+ end
+ end
+ def self.get_on_display(win, type=nil)
+ if type
+ tk_call_without_enc('clipboard', 'get', '-displayof', win, '-type', type)
+ else
+ tk_call_without_enc('clipboard', 'get', '-displayof', win)
+ end
+ end
+
+ def self.set(data, keys=nil)
+ clear
+ append(data, keys)
+ end
+ def self.set_on_display(win, data, keys=nil)
+ clear(win)
+ append_on_display(win, data, keys)
+ end
+
+ def self.append(data, keys=nil)
+ args = ['clipboard', 'append']
+ args.concat(hash_kv(keys))
+ args.concat(['--', data])
+ tk_call(*args)
+ end
+ def self.append_on_display(win, data, keys=nil)
+ args = ['clipboard', 'append', '-displayof', win]
+ args.concat(hash_kv(keys))
+ args.concat(['--', data])
+ tk_call(*args)
+ end
+
+ def clear
+ TkClipboard.clear_on_display(self)
+ self
+ end
+ def get(type=nil)
+ TkClipboard.get_on_display(self, type)
+ end
+ def set(data, keys=nil)
+ TkClipboard.set_on_display(self, data, keys)
+ self
+ end
+ def append(data, keys=nil)
+ TkClipboard.append_on_display(self, data, keys)
+ self
+ end
+end
diff --git a/jni/ruby/ext/tk/lib/tk/clock.rb b/jni/ruby/ext/tk/lib/tk/clock.rb
new file mode 100644
index 0000000..4e9438f
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tk/clock.rb
@@ -0,0 +1,71 @@
+#
+# tk/clock.rb : methods for clock command
+#
+require 'tk'
+
+module Tk
+ module Clock
+ include Tk
+ extend TkCore
+
+ def self.add(clk, *args)
+ tk_call_without_enc('clock','add', clk, *args).to_i
+ end
+
+ def self.clicks(ms=nil)
+ ms = ms.to_s if ms.kind_of?(Symbol)
+ case ms
+ when nil, ''
+ tk_call_without_enc('clock','clicks').to_i
+ when /^mic/
+ tk_call_without_enc('clock','clicks','-microseconds').to_i
+ when /^mil/
+ tk_call_without_enc('clock','clicks','-milliseconds').to_i
+ else
+ tk_call_without_enc('clock','clicks','-milliseconds').to_i
+ end
+ end
+
+ def self.format(clk, form=nil)
+ if form
+ tk_call('clock','format',clk,'-format',form)
+ else
+ tk_call('clock','format',clk)
+ end
+ end
+
+ def self.formatGMT(clk, form=nil)
+ if form
+ tk_call('clock','format',clk,'-format',form,'-gmt','1')
+ else
+ tk_call('clock','format',clk,'-gmt','1')
+ end
+ end
+
+ def self.scan(str, base=nil)
+ if base
+ tk_call('clock','scan',str,'-base',base).to_i
+ else
+ tk_call('clock','scan',str).to_i
+ end
+ end
+
+ def self.scanGMT(str, base=nil)
+ if base
+ tk_call('clock','scan',str,'-base',base,'-gmt','1').to_i
+ else
+ tk_call('clock','scan',str,'-gmt','1').to_i
+ end
+ end
+
+ def self.seconds
+ tk_call_without_enc('clock','seconds').to_i
+ end
+ def self.milliseconds
+ tk_call_without_enc('clock','milliseconds').to_i
+ end
+ def self.microseconds
+ tk_call_without_enc('clock','microseconds').to_i
+ end
+ end
+end
diff --git a/jni/ruby/ext/tk/lib/tk/composite.rb b/jni/ruby/ext/tk/lib/tk/composite.rb
new file mode 100644
index 0000000..e267c7a
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tk/composite.rb
@@ -0,0 +1,484 @@
+#
+# tk/composite.rb :
+#
+require 'tk'
+
+module TkComposite
+ include Tk
+ extend Tk
+
+=begin
+ def initialize(parent=nil, *args)
+ @delegates = {}
+ @option_methods = {}
+ @option_setting = {}
+
+ if parent.kind_of? Hash
+ keys = _symbolkey2str(parent)
+ parent = keys.delete('parent')
+ @frame = TkFrame.new(parent)
+ @path = @epath = @frame.path
+ initialize_composite(keys)
+ else
+ @frame = TkFrame.new(parent)
+ @path = @epath = @frame.path
+ initialize_composite(*args)
+ end
+ end
+=end
+
+ def _choice_classname_of_baseframe
+ base_class_name = nil
+
+ klass = WidgetClassNames[self.class::WidgetClassName]
+
+ if klass
+ # WidgetClassName is a known class
+ #if klass <= TkFrame || klass < TkComposite
+ if klass <= TkFrame || klass < Tk::Frame || klass < TkComposite
+ # klass is valid for the base frame
+ if self.class <= klass
+ # use my classname
+ base_class_name = self.class.name
+ if base_class_name == ''
+ # anonymous class -> use ancestor's name
+ base_class_name = klass.name
+ end
+ else
+ # not subclass -> use WidgetClassName
+ base_class_name = klass.name
+ end
+
+ else
+ # klass is invalid for the base frame
+ #if self.class < TkFrame || self.class.superclass < TkComposite
+ if self.class < TkFrame || self.class.superclass < Tk::Frame || self.class.superclass < TkComposite
+ # my class name is valid for the base frame -> use my classname
+ base_class_name = self.class.name
+ if base_class_name == ''
+ # anonymous class -> use TkFrame
+ base_class_name = nil
+ end
+ else
+ # no idea for the base frame -> use TkFrame
+ base_class_name = nil
+ end
+ end
+
+ elsif self.class::WidgetClassName && ! self.class::WidgetClassName.empty?
+ # unknown WidgetClassName is defined -> use it for the base frame
+ base_class_name = self.class::WidgetClassName
+
+ else
+ # no valid WidgetClassName
+ #if self.class < TkFrame || self.class.superclass < TkComposite
+ if self.class < TkFrame || self.class.superclass < Tk::Frame || self.class.superclass < TkComposite
+ # my class name is valid for the base frame -> use my classname
+ base_class_name = self.class.name
+ if base_class_name == ''
+ # anonymous class -> use TkFrame
+ base_class_name = nil
+ end
+ else
+ # no idea for the base frame -> use TkFrame
+ base_class_name = nil
+ end
+ end
+
+ base_class_name
+ end
+ private :_choice_classname_of_baseframe
+
+ # def initialize(parent=nil, *args)
+ def initialize(*args)
+ @delegates = {}
+ @option_methods = {}
+ @option_setting = {}
+
+ if args[-1].kind_of?(Hash)
+ keys = _symbolkey2str(args.pop)
+ else
+ keys = {}
+ end
+ parent = args.shift
+ parent = keys.delete('parent') if keys.has_key?('parent')
+
+ if keys.key?('classname')
+ keys['class'] = keys.delete('classname')
+ end
+ if (base_class_name = (keys.delete('class')).to_s).empty?
+ base_class_name = _choice_classname_of_baseframe
+ end
+
+ if base_class_name
+ # @frame = Tk::Frame.new(parent, :class=>base_class_name)
+ # --> use current TkFrame class
+ @frame = TkFrame.new(parent, :class=>base_class_name)
+ else
+ # @frame = Tk::Frame.new(parent)
+ # --> use current TkFrame class
+ @frame = TkFrame.new(parent)
+ end
+ @path = @epath = @frame.path
+
+ args.push(keys) unless keys.empty?
+ initialize_composite(*args)
+ end
+
+ def database_classname
+ @frame.database_classname
+ end
+
+ def database_class
+ @frame.database_class
+ end
+
+ def epath
+ @epath
+ end
+
+ def initialize_composite(*args) end
+ private :initialize_composite
+
+ def inspect
+ str = super
+ str.chop << ' @epath=' << @epath.inspect << '>'
+ end
+
+ def _get_opt_method_list(arg)
+ m_set, m_cget, m_info = arg
+ m_set = m_set.to_s
+ m_cget = m_set if !m_cget && self.method(m_set).arity == -1
+ m_cget = m_cget.to_s if m_cget
+ m_info = m_info.to_s if m_info
+ [m_set, m_cget, m_info]
+ end
+ private :_get_opt_method_list
+
+ def option_methods(*opts)
+ if opts.size == 1 && opts[0].kind_of?(Hash)
+ # {name => [m_set, m_cget, m_info], name => method} style
+ opts[0].each{|name, arg|
+ m_set, m_cget, m_info = _get_opt_method_list(arg)
+ @option_methods[name.to_s] = {
+ :set => m_set, :cget => m_cget, :info => m_info
+ }
+ }
+ else
+ # [m_set, m_cget, m_info] or method style
+ opts.each{|arg|
+ m_set, m_cget, m_info = _get_opt_method_list(arg)
+ @option_methods[m_set] = {
+ :set => m_set, :cget => m_cget, :info => m_info
+ }
+ }
+ end
+ end
+
+ def delegate_alias(alias_opt, option, *wins)
+ if wins.length == 0
+ fail ArgumentError, "target widgets are not given"
+ end
+ if alias_opt != option && (alias_opt == 'DEFAULT' || option == 'DEFAULT')
+ fail ArgumentError, "cannot alias 'DEFAULT' option"
+ end
+ alias_opt = alias_opt.to_s
+ option = option.to_s
+ if @delegates[alias_opt].kind_of?(Array)
+ if (elem = @delegates[alias_opt].assoc(option))
+ wins.each{|w| elem[1].push(w)}
+ else
+ @delegates[alias_opt] << [option, wins]
+ end
+ else
+ @delegates[alias_opt] = [ [option, wins] ]
+ end
+ end
+
+ def delegate(option, *wins)
+ delegate_alias(option, option, *wins)
+ end
+
+ def __cget_delegates(slot)
+ slot = slot.to_s
+
+ if @option_methods.include?(slot)
+ if @option_methods[slot][:cget]
+ return self.__send__(@option_methods[slot][:cget])
+ else
+ if @option_setting[slot]
+ return @option_setting[slot]
+ else
+ return ''
+ end
+ end
+ end
+
+ tbl = @delegates[slot]
+ tbl = @delegates['DEFAULT'] unless tbl
+
+ begin
+ if tbl
+ opt, wins = tbl[-1]
+ opt = slot if opt == 'DEFAULT'
+ if wins && wins[-1]
+ # return wins[-1].cget(opt)
+ return wins[-1].cget_strict(opt)
+ end
+ end
+ rescue
+ end
+
+ return None
+ end
+ private :__cget_delegates
+
+ def cget_tkstring(slot)
+ if (ret = __cget_delegates(slot)) == None
+ super(slot)
+ else
+ _get_eval_string(ret)
+ end
+ end
+
+ def cget(slot)
+ if (ret = __cget_delegates(slot)) == None
+ super(slot)
+ else
+ ret
+ end
+ end
+
+ def cget_strict(slot)
+ if (ret = __cget_delegates(slot)) == None
+ super(slot)
+ else
+ ret
+ end
+ end
+
+=begin
+ def cget(slot)
+ slot = slot.to_s
+
+ if @option_methods.include?(slot)
+ if @option_methods[slot][:cget]
+ return self.__send__(@option_methods[slot][:cget])
+ else
+ if @option_setting[slot]
+ return @option_setting[slot]
+ else
+ return ''
+ end
+ end
+ end
+
+ tbl = @delegates[slot]
+ tbl = @delegates['DEFAULT'] unless tbl
+
+ begin
+ if tbl
+ opt, wins = tbl[-1]
+ opt = slot if opt == 'DEFAULT'
+ if wins && wins[-1]
+ return wins[-1].cget(opt)
+ end
+ end
+ rescue
+ end
+
+ super(slot)
+ end
+=end
+
+ def configure(slot, value=None)
+ if slot.kind_of? Hash
+ slot.each{|slot,value| configure slot, value}
+ return self
+ end
+
+ slot = slot.to_s
+
+ if @option_methods.include?(slot)
+ unless @option_methods[slot][:cget]
+ if value.kind_of?(Symbol)
+ @option_setting[slot] = value.to_s
+ else
+ @option_setting[slot] = value
+ end
+ end
+ return self.__send__(@option_methods[slot][:set], value)
+ end
+
+ tbl = @delegates[slot]
+ tbl = @delegates['DEFAULT'] unless tbl
+
+ begin
+ if tbl
+ last = nil
+ tbl.each{|opt, wins|
+ opt = slot if opt == 'DEFAULT'
+ wins.each{|w| last = w.configure(opt, value)}
+ }
+ return last
+ end
+ rescue
+ end
+
+ super(slot, value)
+ end
+
+ def configinfo(slot = nil)
+ if TkComm::GET_CONFIGINFO_AS_ARRAY
+ if slot
+ slot = slot.to_s
+ if @option_methods.include?(slot)
+ if @option_methods[slot][:info]
+ return self.__send__(@option_methods[slot][:info])
+ else
+ return [slot, '', '', '', self.cget(slot)]
+ end
+ end
+
+ tbl = @delegates[slot]
+ tbl = @delegates['DEFAULT'] unless tbl
+
+ begin
+ if tbl
+ if tbl.length == 1
+ opt, wins = tbl[0]
+ if slot == opt || opt == 'DEFAULT'
+ return wins[-1].configinfo(slot)
+ else
+ info = wins[-1].configinfo(opt)
+ info[0] = slot
+ return info
+ end
+ else
+ opt, wins = tbl[-1]
+ return [slot, '', '', '', wins[-1].cget(opt)]
+ end
+ end
+ rescue
+ end
+
+ super(slot)
+
+ else # slot == nil
+ info_list = super(slot)
+
+ tbl = @delegates['DEFAULT']
+ if tbl
+ wins = tbl[0][1]
+ if wins && wins[-1]
+ wins[-1].configinfo.each{|info|
+ slot = info[0]
+ info_list.delete_if{|i| i[0] == slot} << info
+ }
+ end
+ end
+
+ @delegates.each{|slot, tbl|
+ next if slot == 'DEFAULT'
+ if tbl.length == 1
+ opt, wins = tbl[0]
+ next unless wins && wins[-1]
+ if slot == opt
+ info_list.delete_if{|i| i[0] == slot} <<
+ wins[-1].configinfo(slot)
+ else
+ info = wins[-1].configinfo(opt)
+ info[0] = slot
+ info_list.delete_if{|i| i[0] == slot} << info
+ end
+ else
+ opt, wins = tbl[-1]
+ info_list.delete_if{|i| i[0] == slot} <<
+ [slot, '', '', '', wins[-1].cget(opt)]
+ end
+ }
+
+ @option_methods.each{|slot, m|
+ if m[:info]
+ info = self.__send__(m[:info])
+ else
+ info = [slot, '', '', '', self.cget(slot)]
+ end
+ info_list.delete_if{|i| i[0] == slot} << info
+ }
+
+ info_list
+ end
+
+ else # ! TkComm::GET_CONFIGINFO_AS_ARRAY
+ if slot
+ slot = slot.to_s
+ if @option_methods.include?(slot)
+ if @option_methods[slot][:info]
+ return self.__send__(@option_methods[slot][:info])
+ else
+ return {slot => ['', '', '', self.cget(slot)]}
+ end
+ end
+
+ tbl = @delegates[slot]
+ tbl = @delegates['DEFAULT'] unless tbl
+
+ begin
+ if tbl
+ if tbl.length == 1
+ opt, wins = tbl[0]
+ if slot == opt || opt == 'DEFAULT'
+ return wins[-1].configinfo(slot)
+ else
+ return {slot => wins[-1].configinfo(opt)[opt]}
+ end
+ else
+ opt, wins = tbl[-1]
+ return {slot => ['', '', '', wins[-1].cget(opt)]}
+ end
+ end
+ rescue
+ end
+
+ super(slot)
+
+ else # slot == nil
+ info_list = super(slot)
+
+ tbl = @delegates['DEFAULT']
+ if tbl
+ wins = tbl[0][1]
+ info_list.update(wins[-1].configinfo) if wins && wins[-1]
+ end
+
+ @delegates.each{|slot, tbl|
+ next if slot == 'DEFAULT'
+ if tbl.length == 1
+ opt, wins = tbl[0]
+ next unless wins && wins[-1]
+ if slot == opt
+ info_list.update(wins[-1].configinfo(slot))
+ else
+ info_list.update({slot => wins[-1].configinfo(opt)[opt]})
+ end
+ else
+ opt, wins = tbl[-1]
+ info_list.update({slot => ['', '', '', wins[-1].cget(opt)]})
+ end
+ }
+
+ @option_methods.each{|slot, m|
+ if m[:info]
+ info = self.__send__(m[:info])
+ else
+ info = {slot => ['', '', '', self.cget(slot)]}
+ end
+ info_list.update(info)
+ }
+
+ info_list
+ end
+ end
+ end
+end
diff --git a/jni/ruby/ext/tk/lib/tk/console.rb b/jni/ruby/ext/tk/lib/tk/console.rb
new file mode 100644
index 0000000..64e2575
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tk/console.rb
@@ -0,0 +1,52 @@
+#
+# tk/console.rb : control the console on system without a real console
+#
+require 'tk'
+
+module TkConsole
+ include Tk
+ extend Tk
+
+ TkCommandNames = ['console'.freeze, 'consoleinterp'.freeze].freeze
+
+ def self.create
+ TkCore::INTERP._create_console
+ end
+ self.create # initialize console
+
+ def self.title(str=None)
+ tk_call 'console', str
+ end
+ def self.hide
+ tk_call_without_enc('console', 'hide')
+ end
+ def self.show
+ tk_call_without_enc('console', 'show')
+ end
+ def self.eval(tcl_script)
+ #
+ # supports a Tcl script only
+ # I have no idea to support a Ruby script seamlessly.
+ #
+ _fromUTF8(tk_call_without_enc('console', 'eval',
+ _get_eval_enc_str(tcl_script)))
+ end
+ def self.maininterp_eval(tcl_script)
+ #
+ # supports a Tcl script only
+ # I have no idea to support a Ruby script seamlessly.
+ #
+ _fromUTF8(tk_call_without_enc('consoleinterp', 'eval',
+ _get_eval_enc_str(tcl_script)))
+
+ end
+ def self.maininterp_record(tcl_script)
+ #
+ # supports a Tcl script only
+ # I have no idea to support a Ruby script seamlessly.
+ #
+ _fromUTF8(tk_call_without_enc('consoleinterp', 'record',
+ _get_eval_enc_str(tcl_script)))
+
+ end
+end
diff --git a/jni/ruby/ext/tk/lib/tk/dialog.rb b/jni/ruby/ext/tk/lib/tk/dialog.rb
new file mode 100644
index 0000000..7ef7820
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tk/dialog.rb
@@ -0,0 +1,326 @@
+#
+# tk/dialog.rb : create dialog boxes
+#
+require 'tk'
+require 'tk/variable.rb'
+
+class TkDialogObj < TkWindow
+ extend Tk
+
+ TkCommandNames = ['tk_dialog'.freeze].freeze
+
+ def self.show(*args)
+ dlog = self.new(*args)
+ dlog.show
+ dlog
+ end
+
+ def _set_button_config(configs)
+ set_config = proc{|c,i|
+ if $VERBOSE && (c.has_key?('command') || c.has_key?(:command))
+ STDERR.print("Warning: cannot give a command option " +
+ "to the dialog button#{i}. It was removed.\n")
+ end
+ c.delete('command'); c.delete(:command)
+ # @config << Kernel.format("%s.button%s configure %s; ",
+ # @path, i, hash_kv(c).join(' '))
+ # @config << @path+'.button'+i.to_s+' configure '+hash_kv(c).join(' ')+'; '
+ @config << @path+'.button'+i.to_s+' configure '+
+ array2tk_list(hash_kv(c))+'; '
+ }
+ case configs
+ when Proc
+ @buttons.each_index{|i|
+ if (c = configs.call(i)).kind_of?(Hash)
+ set_config.call(c,i)
+ end
+ }
+
+ when Array
+ @buttons.each_index{|i|
+ if (c = configs[i]).kind_of?(Hash)
+ set_config.call(c,i)
+ end
+ }
+
+ when Hash
+ @buttons.each_with_index{|s,i|
+ if (c = configs[s]).kind_of?(Hash)
+ set_config.call(c,i)
+ end
+ }
+ end
+ # @config = 'after idle {' + @config + '};' if @config != ""
+ @config = array2tk_list(['after', 'idle', @config]) << ';' if @config != ""
+ end
+ private :_set_button_config
+
+ # initialize tk_dialog
+ def create_self(keys)
+ # @var = TkVariable.new
+ @val = nil
+
+ @title = title
+
+ @message = message
+ @message_config = message_config
+ @msgframe_config = msgframe_config
+
+ @bitmap = bitmap
+ @bitmap_config = message_config
+
+ @default_button = default_button
+
+ @buttons = buttons
+ @button_configs = proc{|num| button_configs(num)}
+ @btnframe_config = btnframe_config
+
+ #@config = "puts [winfo children .w0000];"
+ @config = ""
+
+ @command = prev_command
+
+ if keys.kind_of?(Hash)
+ @title = keys['title'] if keys.key? 'title'
+ @message = keys['message'] if keys.key? 'message'
+ @bitmap = keys['bitmap'] if keys.key? 'bitmap'
+ # @bitmap = '{}' if @bitmap == nil || @bitmap == ""
+ @bitmap = '' unless @bitmap
+ @default_button = keys['default'] if keys.key? 'default'
+ @buttons = keys['buttons'] if keys.key? 'buttons'
+
+ @command = keys['prev_command'] if keys.key? 'prev_command'
+
+ @message_config = keys['message_config'] if keys.key? 'message_config'
+ @msgframe_config = keys['msgframe_config'] if keys.key? 'msgframe_config'
+ @bitmap_config = keys['bitmap_config'] if keys.key? 'bitmap_config'
+ @button_configs = keys['button_configs'] if keys.key? 'button_configs'
+ @btnframe_config = keys['btnframe_config'] if keys.key? 'btnframe_config'
+ end
+
+ #if @title.include? ?\s
+ # @title = '{' + @title + '}'
+ #end
+
+ if @buttons.kind_of?(Array)
+ _set_button_config(@buttons.collect{|cfg|
+ (cfg.kind_of? Array)? cfg[1]: nil})
+ @buttons = @buttons.collect{|cfg| (cfg.kind_of? Array)? cfg[0]: cfg}
+ end
+ if @buttons.kind_of?(Hash)
+ _set_button_config(@buttons)
+ @buttons = @buttons.keys
+ end
+ @buttons = tk_split_simplelist(@buttons) if @buttons.kind_of?(String)
+ @buttons = [] unless @buttons
+=begin
+ @buttons = @buttons.collect{|s|
+ if s.kind_of?(Array)
+ s = s.join(' ')
+ end
+ if s.include? ?\s
+ '{' + s + '}'
+ else
+ s
+ end
+ }
+=end
+
+ if @message_config.kind_of?(Hash)
+ # @config << Kernel.format("%s.msg configure %s;",
+ # @path, hash_kv(@message_config).join(' '))
+ # @config << @path+'.msg configure '+hash_kv(@message_config).join(' ')+';'
+ @config << @path+'.msg configure '+
+ array2tk_list(hash_kv(@message_config))+';'
+ end
+
+ if @msgframe_config.kind_of?(Hash)
+ # @config << Kernel.format("%s.top configure %s;",
+ # @path, hash_kv(@msgframe_config).join(' '))
+ # @config << @path+'.top configure '+hash_kv(@msgframe_config).join(' ')+';'
+ @config << @path+'.top configure '+
+ array2tk_list(hash_kv(@msgframe_config))+';'
+ end
+
+ if @btnframe_config.kind_of?(Hash)
+ # @config << Kernel.format("%s.bot configure %s;",
+ # @path, hash_kv(@btnframe_config).join(' '))
+ # @config << @path+'.bot configure '+hash_kv(@btnframe_config).join(' ')+';'
+ @config << @path+'.bot configure '+
+ array2tk_list(hash_kv(@btnframe_config))+';'
+ end
+
+ if @bitmap_config.kind_of?(Hash)
+ # @config << Kernel.format("%s.bitmap configure %s;",
+ # @path, hash_kv(@bitmap_config).join(' '))
+ # @config << @path+'.bitmap configure '+hash_kv(@bitmap_config).join(' ')+';'
+ @config << @path+'.bitmap configure '+
+ array2tk_list(hash_kv(@bitmap_config))+';'
+ end
+
+ _set_button_config(@button_configs) if @button_configs
+ end
+ private :create_self
+
+ def show
+ # if @command.kind_of?(Proc)
+ if TkComm._callback_entry?(@command)
+ @command.call(self)
+ end
+
+ if @default_button.kind_of?(String)
+ default_button = @buttons.index(@default_button)
+ else
+ default_button = @default_button
+ end
+ # default_button = '{}' if default_button == nil
+ default_button = '' if default_button == nil
+ #Tk.ip_eval('eval {global '+@var.id+';'+@config+
+ # 'set '+@var.id+' [tk_dialog '+
+ # @path+" "+@title+" {#{@message}} "+@bitmap+" "+
+ # String(default_button)+" "+@buttons.join(' ')+']}')
+ Tk.ip_eval(@config)
+ # @val = Tk.ip_eval('tk_dialog ' + @path + ' ' + @title +
+ # ' {' + @message + '} ' + @bitmap + ' ' +
+ # String(default_button) + ' ' + @buttons.join(' ')).to_i
+ # @val = Tk.ip_eval(self.class::TkCommandNames[0] + ' ' + @path + ' ' +
+ # @title + ' {' + @message + '} ' + @bitmap + ' ' +
+ # String(default_button) + ' ' + @buttons.join(' ')).to_i
+ @val = Tk.ip_eval(array2tk_list([
+ self.class::TkCommandNames[0],
+ @path, @title, @message, @bitmap,
+ String(default_button)
+ ].concat(@buttons))).to_i
+ end
+
+ def value
+ # @var.value.to_i
+ @val
+ end
+
+ def name
+ (@val)? @buttons[@val]: nil
+ end
+
+ ############################################################
+ # #
+ # following methods should be overridden for each dialog #
+ # #
+ ############################################################
+ private
+
+ def title
+ # returns a title string of the dialog window
+ return "DIALOG"
+ end
+ def message
+ # returns a message text to display on the dialog
+ return "MESSAGE"
+ end
+ def message_config
+ # returns a Hash {option=>value, ...} for the message text
+ return nil
+ end
+ def msgframe_config
+ # returns a Hash {option=>value, ...} for the message text frame
+ return nil
+ end
+ def bitmap
+ # returns a bitmap name or a bitmap file path
+ # (@ + path ; e.g. '@/usr/share/bitmap/sample.xbm')
+ return "info"
+ end
+ def bitmap_config
+ # returns nil or a Hash {option=>value, ...} for the bitmap
+ return nil
+ end
+ def default_button
+ # returns a default button's number or name
+ # if nil or null string, set no-default
+ return 0
+ end
+ def buttons
+ #return "BUTTON1 BUTTON2"
+ return ["BUTTON1", "BUTTON2"]
+ end
+ def button_configs(num)
+ # returns nil / Proc / Array or Hash (see _set_button_config)
+ return nil
+ end
+ def btnframe_config
+ # returns nil or a Hash {option=>value, ...} for the button frame
+ return nil
+ end
+ def prev_command
+ # returns nil or a Proc
+ return nil
+ end
+end
+TkDialog2 = TkDialogObj
+
+#
+# TkDialog : with showing at initialize
+#
+class TkDialog < TkDialogObj
+ def self.show(*args)
+ self.new(*args)
+ end
+
+ def initialize(*args)
+ super(*args)
+ show
+ end
+end
+
+
+#
+# dialog for warning
+#
+class TkWarningObj < TkDialogObj
+ def initialize(parent = nil, mes = nil)
+ if !mes
+ if parent.kind_of?(TkWindow)
+ mes = ""
+ else
+ mes = parent.to_s
+ parent = nil
+ end
+ end
+ super(parent, :message=>mes)
+ end
+
+ def show(mes = nil)
+ mes_bup = @message
+ @message = mes if mes
+ ret = super()
+ @message = mes_bup
+ ret
+ end
+
+ #######
+ private
+
+ def title
+ return "WARNING";
+ end
+ def bitmap
+ return "warning";
+ end
+ def default_button
+ return 0;
+ end
+ def buttons
+ return "OK";
+ end
+end
+TkWarning2 = TkWarningObj
+
+class TkWarning < TkWarningObj
+ def self.show(*args)
+ self.new(*args)
+ end
+ def initialize(*args)
+ super(*args)
+ show
+ end
+end
diff --git a/jni/ruby/ext/tk/lib/tk/encodedstr.rb b/jni/ruby/ext/tk/lib/tk/encodedstr.rb
new file mode 100644
index 0000000..59fbb19
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tk/encodedstr.rb
@@ -0,0 +1,187 @@
+#
+# tk/encodedstr.rb : Tk::EncodedString class
+#
+require 'tk'
+
+###########################################
+# string with Tcl's encoding
+###########################################
+module Tk
+ class EncodedString < String
+ Encoding = nil
+
+ def self.subst_utf_backslash(str)
+ # str.gsub(/\\u([0-9A-Fa-f]{1,4})/){[$1.hex].pack('U')}
+ TclTkLib._subst_UTF_backslash(str)
+ end
+ def self.utf_backslash(str)
+ self.subst_utf_backslash(str)
+ end
+
+ def self.subst_tk_backslash(str)
+ TclTkLib._subst_Tcl_backslash(str)
+ end
+
+ def self.utf_to_backslash_sequence(str)
+ str.unpack('U*').collect{|c|
+ if c <= 0xFF # ascii character
+ c.chr
+ else
+ format('\u%X', c)
+ end
+ }.join('')
+ end
+ def self.utf_to_backslash(str)
+ self.utf_to_backslash_sequence(str)
+ end
+
+ def self.to_backslash_sequence(str)
+ str.unpack('U*').collect{|c|
+ if c <= 0x1F # control character
+ case c
+ when 0x07; '\a'
+ when 0x08; '\b'
+ when 0x09; '\t'
+ when 0x0a; '\n'
+ when 0x0b; '\v'
+ when 0x0c; '\f'
+ when 0x0d; '\r'
+ else
+ format('\x%02X', c)
+ end
+ elsif c <= 0xFF # ascii character
+ c.chr
+ else
+ format('\u%X', c)
+ end
+ }.join('')
+ end
+
+ def self.new_with_utf_backslash(str, enc = nil)
+ self.new('', enc).replace(self.subst_utf_backslash(str))
+ end
+
+ def self.new_without_utf_backslash(str, enc = nil)
+ self.new('', enc).replace(str)
+ end
+
+ def initialize(str, enc = nil)
+ super(str)
+ # @encoding = ( enc ||
+ # ((self.class::Encoding)?
+ # self.class::Encoding : Tk.encoding_system) )
+ enc ||= (self.class::Encoding)?
+ self.class::Encoding :
+ ((Tk.encoding)? Tk.encoding : Tk.encoding_system)
+ if TkCore::WITH_ENCODING
+ unless encobj = Tk::Encoding::ENCODING_TABLE.get_obj(enc)
+ fail ArgumentError, "unsupported Tk encoding '#{enc}'"
+ end
+ self.force_encoding(encobj)
+ else
+ @encoding = enc
+ end
+ end
+
+ if TkCore::WITH_ENCODING
+ alias encoding_obj encoding
+ alias __encoding encoding
+ def encoding
+ Tk::Encoding::ENCODING_TABLE.get_name(super())
+ end
+ else
+ def encoding
+ @encoding
+ end
+ alias encoding_obj encoding
+ end
+
+ if TkCore::WITH_ENCODING
+ # wrapper methods for compatibility
+ alias __instance_variable_get instance_variable_get
+ alias __instance_variable_set instance_variable_set
+ alias __instance_eval instance_eval
+ alias __instance_variables instance_variables
+
+ def instance_variable_get(key)
+ if (key.to_s == '@encoding')
+ self.encoding
+ else
+ super(key)
+ end
+ end
+
+ def instance_variable_set(key, value)
+ if (key.to_s == '@encoding')
+ if value
+ self.force_encoding(value)
+ else
+ self.force_encoding(Tk::Encoding::UNKNOWN)
+ end
+ value
+ else
+ super(key, value)
+ end
+ end
+
+ def instance_eval(*args, &b)
+ old_enc = @encoding = self.encoding
+
+ ret = super(*args, &b)
+
+ if @encoding
+ if @encoding != old_enc
+ # modified by user
+ self.force_encoding(@encoding)
+ end
+ remove_instance_variable(:@encoding)
+ else
+ begin
+ remove_instance_variable(:@encoding)
+ # user sets to nil -> use current default
+ self.force_encoding(Tk.encoding)
+ rescue NameError
+ # removed by user -> ignore, because user don't use @encoding
+ end
+ end
+ ret
+ end
+ end
+
+ def instance_variables
+ ret = super()
+ ret << :@encoding # fake !!
+ ret
+ end
+ end
+ # def Tk.EncodedString(str, enc = nil)
+ # Tk::EncodedString.new(str, enc)
+ # end
+
+ ##################################
+
+ class BinaryString < EncodedString
+ Encoding = 'binary'.freeze
+ end
+ # def Tk.BinaryString(str)
+ # Tk::BinaryString.new(str)
+ # end
+
+ ##################################
+
+ class UTF8_String < EncodedString
+ Encoding = 'utf-8'.freeze
+ def self.new(str)
+ super(self.subst_utf_backslash(str))
+ end
+
+ def to_backslash_sequence
+ Tk::EncodedString.utf_to_backslash_sequence(self)
+ end
+ alias to_backslash to_backslash_sequence
+ end
+ # def Tk.UTF8_String(str)
+ # Tk::UTF8_String.new(str)
+ # end
+
+end
diff --git a/jni/ruby/ext/tk/lib/tk/entry.rb b/jni/ruby/ext/tk/lib/tk/entry.rb
new file mode 100644
index 0000000..d4aa03f
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tk/entry.rb
@@ -0,0 +1,120 @@
+#
+# tk/entry.rb - Tk entry classes
+# by Yukihiro Matsumoto <matz@caelum.co.jp>
+
+require 'tk'
+require 'tk/label'
+require 'tk/scrollable'
+require 'tk/validation'
+
+class Tk::Entry<Tk::Label
+ include X_Scrollable
+ include TkValidation
+
+ TkCommandNames = ['entry'.freeze].freeze
+ WidgetClassName = 'Entry'.freeze
+ WidgetClassNames[WidgetClassName] ||= self
+
+ #def create_self(keys)
+ # super(__conv_vcmd_on_hash_kv(keys))
+ #end
+ #private :create_self
+
+ def __strval_optkeys
+ super() + ['show', 'disabledbackground', 'readonlybackground']
+ end
+ private :__strval_optkeys
+
+ def bbox(index)
+ list(tk_send_without_enc('bbox', index))
+ end
+ def cursor
+ number(tk_send_without_enc('index', 'insert'))
+ end
+ alias icursor cursor
+ def cursor=(index)
+ tk_send_without_enc('icursor', index)
+ #self
+ index
+ end
+ alias icursor= cursor=
+ def index(idx)
+ number(tk_send_without_enc('index', idx))
+ end
+ def insert(pos,text)
+ tk_send_without_enc('insert', pos, _get_eval_enc_str(text))
+ self
+ end
+ def delete(first, last=None)
+ tk_send_without_enc('delete', first, last)
+ self
+ end
+ def mark(pos)
+ tk_send_without_enc('scan', 'mark', pos)
+ self
+ end
+ def dragto(pos)
+ tk_send_without_enc('scan', 'dragto', pos)
+ self
+ end
+ def selection_adjust(index)
+ tk_send_without_enc('selection', 'adjust', index)
+ self
+ end
+ def selection_clear
+ tk_send_without_enc('selection', 'clear')
+ self
+ end
+ def selection_from(index)
+ tk_send_without_enc('selection', 'from', index)
+ self
+ end
+ def selection_present()
+ bool(tk_send_without_enc('selection', 'present'))
+ end
+ def selection_range(s, e)
+ tk_send_without_enc('selection', 'range', s, e)
+ self
+ end
+ def selection_to(index)
+ tk_send_without_enc('selection', 'to', index)
+ self
+ end
+
+ def invoke_validate
+ bool(tk_send_without_enc('validate'))
+ end
+ def validate(mode = nil)
+ if mode
+ configure 'validate', mode
+ else
+ invoke_validate
+ end
+ end
+
+ def value
+ _fromUTF8(tk_send_without_enc('get'))
+ end
+ def value= (val)
+ tk_send_without_enc('delete', 0, 'end')
+ tk_send_without_enc('insert', 0, _get_eval_enc_str(val))
+ val
+ end
+ alias get value
+ alias set value=
+
+ def [](*args)
+ self.value[*args]
+ end
+ def []=(*args)
+ val = args.pop
+ str = self.value
+ str[*args] = val
+ self.value = str
+ val
+ end
+end
+
+#TkEntry = Tk::Entry unless Object.const_defined? :TkEntry
+#Tk.__set_toplevel_aliases__(:Tk, Tk::Entry, :TkEntry)
+Tk.__set_loaded_toplevel_aliases__('tk/entry.rb', :Tk, Tk::Entry, :TkEntry)
diff --git a/jni/ruby/ext/tk/lib/tk/event.rb b/jni/ruby/ext/tk/lib/tk/event.rb
new file mode 100644
index 0000000..bf4e122
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tk/event.rb
@@ -0,0 +1,562 @@
+#
+# tk/event.rb - module for event
+#
+
+module TkEvent
+end
+
+########################
+
+require 'tkutil'
+require 'tk' unless Object.const_defined? :TkComm
+
+########################
+
+module TkEvent
+ class Event < TkUtil::CallbackSubst
+ module Grp
+ KEY = 0x1
+ BUTTON = 0x2
+ MOTION = 0x4
+ CROSSING = 0x8
+ FOCUS = 0x10
+ EXPOSE = 0x20
+ VISIBILITY = 0x40
+ CREATE = 0x80
+ DESTROY = 0x100
+ UNMAP = 0x200
+ MAP = 0x400
+ REPARENT = 0x800
+ CONFIG = 0x1000
+ GRAVITY = 0x2000
+ CIRC = 0x4000
+ PROP = 0x8000
+ COLORMAP = 0x10000
+ VIRTUAL = 0x20000
+ ACTIVATE = 0x40000
+ MAPREQ = 0x80000
+ CONFIGREQ = 0x100000
+ RESIZEREQ = 0x200000
+ CIRCREQ = 0x400000
+
+ MWHEEL = KEY
+
+ STRING_DATA = 0x80000000 # special flag for 'data' field
+
+ ALL = 0xFFFFFFFF
+
+ KEY_BUTTON_MOTION_VIRTUAL = (KEY|MWHEEL|BUTTON|MOTION|VIRTUAL)
+ KEY_BUTTON_MOTION_CROSSING = (KEY|MWHEEL|BUTTON|MOTION|CROSSING|VIRTUAL)
+ end
+
+ type_data = [
+ #-----+-------------------+------------------+-----------------------#
+ # ID | const | group_flag | context_name #
+ #-----+-------------------+------------------+-----------------------#
+ [ 2, :KeyPress, Grp::KEY, 'KeyPress', 'Key' ],
+ [ 3, :KeyRelease, Grp::KEY, 'KeyRelease' ],
+ [ 4, :ButtonPress, Grp::BUTTON, 'ButtonPress', 'Button' ],
+ [ 5, :ButtonRelease, Grp::BUTTON, 'ButtonRelease' ],
+ [ 6, :MotionNotify, Grp::MOTION, 'Motion' ],
+ [ 7, :EnterNotify, Grp::CROSSING, 'Enter' ],
+ [ 8, :LeaveNotify, Grp::CROSSING, 'Leave' ],
+ [ 9, :FocusIn, Grp::FOCUS, 'FocusIn' ],
+ [ 10, :FocusOut, Grp::FOCUS, 'FocusOut' ],
+ [ 11, :KeymapNotify, 0, ],
+ [ 12, :Expose, Grp::EXPOSE, 'Expose' ],
+ [ 13, :GraphicsExpose, Grp::EXPOSE, ],
+ [ 14, :NoExpose, 0, ],
+ [ 15, :VisibilityNotify, Grp::VISIBILITY, 'Visibility' ],
+ [ 16, :CreateNotify, Grp::CREATE, 'Create' ],
+ [ 17, :DestroyNotify, Grp::DESTROY, 'Destroy' ],
+ [ 18, :UnmapNotify, Grp::UNMAP, 'Unmap' ],
+ [ 19, :MapNotify, Grp::MAP, 'Map' ],
+ [ 20, :MapRequest, Grp::MAPREQ, 'MapRequest' ],
+ [ 21, :ReparentNotify, Grp::REPARENT, 'Reparent' ],
+ [ 22, :ConfigureNotify, Grp::CONFIG, 'Configure' ],
+ [ 23, :ConfigureRequest, Grp::CONFIGREQ, 'ConfigureRequest' ],
+ [ 24, :GravityNotify, Grp::GRAVITY, 'Gravity' ],
+ [ 25, :ResizeRequest, Grp::RESIZEREQ, 'ResizeRequest' ],
+ [ 26, :CirculateNotify, Grp::CIRC, 'Circulate' ],
+ [ 27, :CirculateRequest, 0, 'CirculateRequest' ],
+ [ 28, :PropertyNotify, Grp::PROP, 'Property' ],
+ [ 29, :SelectionClear, 0, ],
+ [ 30, :SelectionRequest, 0, ],
+ [ 31, :SelectionNotify, 0, ],
+ [ 32, :ColormapNotify, Grp::COLORMAP, 'Colormap' ],
+ [ 33, :ClientMessage, 0, ],
+ [ 34, :MappingNotify, 0, ],
+ [ 35, :VirtualEvent, Grp::VIRTUAL, ],
+ [ 36, :ActivateNotify, Grp::ACTIVATE, 'Activate' ],
+ [ 37, :DeactivateNotify, Grp::ACTIVATE, 'Deactivate' ],
+ [ 38, :MouseWheelEvent, Grp::MWHEEL, 'MouseWheel' ],
+ [ 39, :TK_LASTEVENT, 0, ]
+ ]
+
+ module TypeNum
+ end
+
+ TYPE_NAME_TBL = Hash.new
+ TYPE_ID_TBL = Hash.new
+ TYPE_GROUP_TBL = Hash.new
+
+ type_data.each{|id, c_name, g_flag, *t_names|
+ TypeNum.const_set(c_name, id)
+ t_names.each{|t_name| t_name.freeze; TYPE_NAME_TBL[t_name] = id }
+ TYPE_ID_TBL[id] = t_names
+ TYPE_GROUP_TBL[id] = g_flag
+ }
+
+ TYPE_NAME_TBL.freeze
+ TYPE_ID_TBL.freeze
+
+ def self.type_id(name)
+ TYPE_NAME_TBL[name.to_s]
+ end
+
+ def self.type_name(id)
+ TYPE_ID_TBL[id] && TYPE_ID_TBL[id][0]
+ end
+
+ def self.group_flag(id)
+ TYPE_GROUP_TBL[id] || 0
+ end
+
+ #############################################
+
+ module StateMask
+ ShiftMask = (1<<0)
+ LockMask = (1<<1)
+ ControlMask = (1<<2)
+ Mod1Mask = (1<<3)
+ Mod2Mask = (1<<4)
+ Mod3Mask = (1<<5)
+ Mod4Mask = (1<<6)
+ Mod5Mask = (1<<7)
+ Button1Mask = (1<<8)
+ Button2Mask = (1<<9)
+ Button3Mask = (1<<10)
+ Button4Mask = (1<<11)
+ Button5Mask = (1<<12)
+
+ AnyModifier = (1<<15)
+
+ META_MASK = (AnyModifier<<1)
+ ALT_MASK = (AnyModifier<<2)
+ EXTENDED_MASK = (AnyModifier<<3)
+
+ CommandMask = Mod1Mask
+ OptionMask = Mod2Mask
+ end
+
+ #############################################
+
+ FIELD_FLAG = {
+ # key => flag
+ 'above' => Grp::CONFIG,
+ 'borderwidth' => (Grp::CREATE|Grp::CONFIG),
+ 'button' => Grp::BUTTON,
+ 'count' => Grp::EXPOSE,
+ 'data' => (Grp::VIRTUAL|Grp::STRING_DATA),
+ 'delta' => Grp::MWHEEL,
+ 'detail' => (Grp::FOCUS|Grp::CROSSING),
+ 'focus' => Grp::CROSSING,
+ 'height' => (Grp::EXPOSE|Grp::CONFIG),
+ 'keycode' => Grp::KEY,
+ 'keysym' => Grp::KEY,
+ 'mode' => (Grp::CROSSING|Grp::FOCUS),
+ 'override' => (Grp::CREATE|Grp::MAP|Grp::REPARENT|Grp::CONFIG),
+ 'place' => Grp::CIRC,
+ 'root' => (Grp::KEY_BUTTON_MOTION_VIRTUAL|Grp::CROSSING),
+ 'rootx' => (Grp::KEY_BUTTON_MOTION_VIRTUAL|Grp::CROSSING),
+ 'rooty' => (Grp::KEY_BUTTON_MOTION_VIRTUAL|Grp::CROSSING),
+ 'sendevent' => Grp::ALL,
+ 'serial' => Grp::ALL,
+ 'state' => (Grp::KEY_BUTTON_MOTION_VIRTUAL|
+ Grp::CROSSING|Grp::VISIBILITY),
+ 'subwindow' => (Grp::KEY_BUTTON_MOTION_VIRTUAL|Grp::CROSSING),
+ 'time' => (Grp::KEY_BUTTON_MOTION_VIRTUAL|Grp::CROSSING|
+ Grp::PROP),
+ 'warp' => Grp::KEY_BUTTON_MOTION_VIRTUAL,
+ 'width' => (Grp::EXPOSE|Grp::CREATE|Grp::CONFIG),
+ 'window' => (Grp::CREATE|Grp::UNMAP|Grp::MAP|Grp::REPARENT|
+ Grp::CONFIG|Grp::GRAVITY|Grp::CIRC),
+ 'when' => Grp::ALL,
+ 'x' => (Grp::KEY_BUTTON_MOTION_VIRTUAL|Grp::CROSSING|
+ Grp::EXPOSE|Grp::CREATE|Grp::CONFIG|Grp::GRAVITY|
+ Grp::REPARENT),
+ 'y' => (Grp::KEY_BUTTON_MOTION_VIRTUAL|Grp::CROSSING|
+ Grp::EXPOSE|Grp::CREATE|Grp::CONFIG|Grp::GRAVITY|
+ Grp::REPARENT),
+ }
+
+ FIELD_OPERATION = {
+ 'root' => proc{|val|
+ begin
+ Tk.tk_call_without_enc('winfo', 'pathname', val)
+ val
+ rescue
+ nil
+ end
+ },
+
+ 'subwindow' => proc{|val|
+ begin
+ Tk.tk_call_without_enc('winfo', 'pathname', val)
+ val
+ rescue
+ nil
+ end
+ },
+
+ 'window' => proc{|val| nil}
+ }
+
+ #-------------------------------------------
+
+ def valid_fields(group_flag=nil)
+ group_flag = self.class.group_flag(self.type) unless group_flag
+
+ fields = {}
+ FIELD_FLAG.each{|key, flag|
+ next if (flag & group_flag) == 0
+ begin
+ val = self.__send__(key)
+ rescue
+ next
+ end
+ # next if !val || val == '??'
+ next if !val || (val == '??' && (flag & Grp::STRING_DATA))
+ fields[key] = val
+ }
+
+ fields
+ end
+
+ def valid_for_generate(group_flag=nil)
+ fields = valid_fields(group_flag)
+
+ FIELD_OPERATION.each{|key, cmd|
+ next unless fields.has_key?(key)
+ val = FIELD_OPERATION[key].call(fields[key])
+ if val
+ fields[key] = val
+ else
+ fields.delete(key)
+ end
+ }
+
+ fields
+ end
+
+ def generate(win, modkeys={})
+ klass = self.class
+
+ if modkeys.has_key?(:type) || modkeys.has_key?('type')
+ modkeys = TkComm._symbolkey2str(modkeys)
+ type_id = modkeys.delete('type')
+ else
+ type_id = self.type
+ end
+
+ type_name = klass.type_name(type_id)
+ unless type_name
+ fail RuntimeError, "type_id #{type_id} is invalid"
+ end
+
+ group_flag = klass.group_flag(type_id)
+
+ opts = valid_for_generate(group_flag)
+
+ modkeys.each{|key, val|
+ if val
+ opts[key.to_s] = val
+ else
+ opts.delete(key.to_s)
+ end
+ }
+
+ if group_flag != Grp::KEY
+ Tk.event_generate(win, type_name, opts)
+ else
+ # If type is KEY event, focus should be set to target widget.
+ # If not set, original widget will get the same event.
+ # That will make infinite loop.
+ w = Tk.tk_call_without_enc('focus')
+ begin
+ Tk.tk_call_without_enc('focus', win)
+ Tk.event_generate(win, type_name, opts)
+ ensure
+ Tk.tk_call_without_enc('focus', w)
+ end
+ end
+ end
+
+ #############################################
+
+ # [ <'%' subst-key char>, <proc type char>, <instance var (accessor) name>]
+ KEY_TBL = [
+ [ ?#, ?n, :serial ],
+ [ ?a, ?s, :above ],
+ [ ?b, ?n, :num ],
+ [ ?c, ?n, :count ],
+ [ ?d, ?s, :detail ],
+ # ?e
+ [ ?f, ?b, :focus ],
+ # ?g
+ [ ?h, ?n, :height ],
+ [ ?i, ?s, :win_hex ],
+ # ?j
+ [ ?k, ?n, :keycode ],
+ # ?l
+ [ ?m, ?s, :mode ],
+ # ?n
+ [ ?o, ?b, :override ],
+ [ ?p, ?s, :place ],
+ # ?q
+ # ?r
+ [ ?s, ?x, :state ],
+ [ ?t, ?n, :time ],
+ # ?u
+ [ ?v, ?n, :value_mask ],
+ [ ?w, ?n, :width ],
+ [ ?x, ?n, :x ],
+ [ ?y, ?n, :y ],
+ # ?z
+ [ ?A, ?s, :char ],
+ [ ?B, ?n, :borderwidth ],
+ # ?C
+ [ ?D, ?n, :wheel_delta ],
+ [ ?E, ?b, :send_event ],
+ # ?F
+ # ?G
+ # ?H
+ # ?I
+ # ?J
+ [ ?K, ?s, :keysym ],
+ # ?L
+ # ?M
+ [ ?N, ?n, :keysym_num ],
+ # ?O
+ [ ?P, ?s, :property ],
+ # ?Q
+ [ ?R, ?s, :rootwin_id ],
+ [ ?S, ?s, :subwindow ],
+ [ ?T, ?n, :type ],
+ # ?U
+ # ?V
+ [ ?W, ?w, :widget ],
+ [ ?X, ?n, :x_root ],
+ [ ?Y, ?n, :y_root ],
+ # ?Z
+ nil
+ ]
+
+ # [ <'%' subst-key str>, <proc type char>, <instance var (accessor) name>]
+ # the subst-key string will be converted to a bytecode (128+idx).
+ LONGKEY_TBL = [
+ # for example, for %CTT and %CST subst-key on tkdnd-2.0
+ # ['CTT', ?l, :drop_target_type],
+ # ['CST', ?l, :drop_source_type],
+ ]
+
+ # [ <proc type char>, <proc/method to convert tcl-str to ruby-obj>]
+ PROC_TBL = [
+ [ ?n, TkComm.method(:num_or_str) ],
+ [ ?s, TkComm.method(:string) ],
+ [ ?b, TkComm.method(:bool) ],
+ [ ?w, TkComm.method(:window) ],
+
+ [ ?x, proc{|val|
+ begin
+ TkComm::number(val)
+ rescue ArgumentError
+ val
+ end
+ }
+ ],
+
+ nil
+ ]
+
+=begin
+ # for Ruby m17n :: ?x --> String --> char-code ( getbyte(0) )
+ KEY_TBL.map!{|inf|
+ if inf.kind_of?(Array)
+ inf[0] = inf[0].getbyte(0) if inf[0].kind_of?(String)
+ inf[1] = inf[1].getbyte(0) if inf[1].kind_of?(String)
+ end
+ inf
+ }
+
+ PROC_TBL.map!{|inf|
+ if inf.kind_of?(Array)
+ inf[0] = inf[0].getbyte(0) if inf[0].kind_of?(String)
+ end
+ inf
+ }
+=end
+
+ # setup tables to be used by scan_args, _get_subst_key, _get_all_subst_keys
+ #
+ # _get_subst_key() and _get_all_subst_keys() generates key-string
+ # which describe how to convert callback arguments to ruby objects.
+ # When binding parameters are given, use _get_subst_key().
+ # But when no parameters are given, use _get_all_subst_keys() to
+ # create a Event class object as a callback parameter.
+ #
+ # scan_args() is used when doing callback. It convert arguments
+ # ( which are Tcl strings ) to ruby objects based on the key string
+ # that is generated by _get_subst_key() or _get_all_subst_keys().
+ #
+ _setup_subst_table(KEY_TBL, PROC_TBL)
+ # _setup_subst_table(KEY_TBL, LONGKEY_TBL, PROC_TBL) # if use longname-keys
+
+ #
+ # NOTE: The order of parameters which passed to callback procedure is
+ # <extra_arg>, <extra_arg>, ... , <subst_arg>, <subst_arg>, ...
+ #
+
+ # If you need support extra arguments given by Tcl/Tk,
+ # please override _get_extra_args_tbl
+ #
+ #def self._get_extra_args_tbl
+ # # return an array of convert procs
+ # []
+ #end
+
+=begin
+ alias button num
+ alias delta wheel_delta
+ alias root rootwin_id
+ alias rootx x_root
+ alias root_x x_root
+ alias rooty y_root
+ alias root_y y_root
+ alias sendevent send_event
+=end
+ ALIAS_TBL = {
+ :button => :num,
+ :data => :detail,
+ :delta => :wheel_delta,
+ :root => :rootwin_id,
+ :rootx => :x_root,
+ :root_x => :x_root,
+ :rooty => :y_root,
+ :root_y => :y_root,
+ :sendevent => :send_event,
+ :window => :widget
+ }
+
+ _define_attribute_aliases(ALIAS_TBL)
+
+ end
+
+ ###############################################
+
+ def install_bind_for_event_class(klass, cmd, *args)
+ extra_args_tbl = klass._get_extra_args_tbl
+
+ if args.compact.size > 0
+ args.map!{|arg| klass._sym2subst(arg)}
+ args = args.join(' ')
+ keys = klass._get_subst_key(args)
+
+ if cmd.kind_of?(String)
+ id = cmd
+ elsif cmd.kind_of?(TkCallbackEntry)
+ id = install_cmd(cmd)
+ else
+ id = install_cmd(proc{|*arg|
+ ex_args = []
+ extra_args_tbl.reverse_each{|conv| ex_args << conv.call(arg.pop)}
+ begin
+ TkUtil.eval_cmd(cmd, *(ex_args.concat(klass.scan_args(keys, arg))))
+ rescue Exception=>e
+ if TkCore::INTERP.kind_of?(TclTkIp)
+ fail e
+ else
+ # MultiTkIp
+ fail Exception, "#{e.class}: #{e.message.dup}"
+ end
+ end
+ })
+ end
+ elsif cmd.respond_to?(:arity) && cmd.arity == 0 # args.size == 0
+ args = ''
+ if cmd.kind_of?(String)
+ id = cmd
+ elsif cmd.kind_of?(TkCallbackEntry)
+ id = install_cmd(cmd)
+ else
+ id = install_cmd(proc{
+ begin
+ TkUtil.eval_cmd(cmd)
+ rescue Exception=>e
+ if TkCore::INTERP.kind_of?(TclTkIp)
+ fail e
+ else
+ # MultiTkIp
+ fail Exception, "#{e.class}: #{e.message.dup}"
+ end
+ end
+ })
+ end
+ else
+ keys, args = klass._get_all_subst_keys
+
+ if cmd.kind_of?(String)
+ id = cmd
+ elsif cmd.kind_of?(TkCallbackEntry)
+ id = install_cmd(cmd)
+ else
+ id = install_cmd(proc{|*arg|
+ ex_args = []
+ extra_args_tbl.reverse_each{|conv| ex_args << conv.call(arg.pop)}
+ begin
+ TkUtil.eval_cmd(cmd, *(ex_args << klass.new(*klass.scan_args(keys, arg))))
+ rescue Exception=>e
+ if TkCore::INTERP.kind_of?(TclTkIp)
+ fail e
+ else
+ # MultiTkIp
+ fail Exception, "#{e.class}: #{e.message.dup}"
+ end
+ end
+ })
+ end
+ end
+
+ if TkCore::INTERP.kind_of?(TclTkIp)
+ id + ' ' + args
+ else
+ # MultiTkIp
+ "if {[set st [catch {#{id} #{args}} ret]] != 0} {
+ if {$st == 4} {
+ return -code continue $ret
+ } elseif {$st == 3} {
+ return -code break $ret
+ } elseif {$st == 2} {
+ return -code return $ret
+ } elseif {[regexp {^Exception: (TkCallbackContinue: .*)$} \
+ $ret m msg]} {
+ return -code continue $msg
+ } elseif {[regexp {^Exception: (TkCallbackBreak: .*)$} $ret m msg]} {
+ return -code break $msg
+ } elseif {[regexp {^Exception: (TkCallbackReturn: .*)$} $ret m msg]} {
+ return -code return $msg
+ } elseif {[regexp {^Exception: (\\S+: .*)$} $ret m msg]} {
+ return -code return $msg
+ } else {
+ return -code error $ret
+ }
+ } else {
+ set ret
+ }"
+ end
+ end
+
+ def install_bind(cmd, *args)
+ install_bind_for_event_class(TkEvent::Event, cmd, *args)
+ end
+end
diff --git a/jni/ruby/ext/tk/lib/tk/font.rb b/jni/ruby/ext/tk/lib/tk/font.rb
new file mode 100644
index 0000000..03db850
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tk/font.rb
@@ -0,0 +1,2351 @@
+#
+# tk/font.rb - the class to treat fonts on Ruby/Tk
+#
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+require 'tk'
+
+class TkFont
+ include Tk
+ extend TkCore
+
+ TkCommandNames = ['font'.freeze].freeze
+
+ (Tk_FontID = ["@font".freeze, TkUtil.untrust("00000")]).instance_eval{
+ @mutex = Mutex.new
+ def mutex; @mutex; end
+ freeze
+ }
+
+ Tk_FontNameTBL = TkCore::INTERP.create_table
+ Tk_FontUseTBL = TkCore::INTERP.create_table
+
+ TkCore::INTERP.init_ip_env{
+ Tk_FontNameTBL.mutex.synchronize{ Tk_FontNameTBL.clear }
+ Tk_FontUseTBL.mutex.synchronize{ Tk_FontUseTBL.clear }
+ }
+
+ # option_type : default => string
+ OptionType = Hash.new(?s)
+ OptionType['size'] = ?n
+ OptionType['pointadjust'] = ?n
+ OptionType['underline'] = ?b
+ OptionType['overstrike'] = ?b
+
+ # metric_type : default => num_or_str
+ MetricType = Hash.new(?n)
+ MetricType['fixed'] = ?b
+
+ # system font names
+ SYSTEM_FONT_NAMES = []
+ def SYSTEM_FONT_NAMES.add(font_names)
+ (@mutex ||= Mutex.new).synchronize{
+ self.replace(self | font_names.map{|name| name.to_s})
+ }
+ end
+ def SYSTEM_FONT_NAMES.include?(name)
+ (@mutex ||= Mutex.new).synchronize{
+ super(name.to_s)
+ }
+ end
+
+ # set default font
+ case Tk::TK_VERSION
+ when /^4\..*/
+ DEFAULT_LATIN_FONT_NAME = 'a14'.freeze
+ DEFAULT_KANJI_FONT_NAME = 'k14'.freeze
+
+ when /^8\.[0-4]/
+ if JAPANIZED_TK
+ begin
+ fontnames = tk_call('font', 'names')
+ case fontnames
+ when /defaultgui/
+ # Tcl/Tk-JP for Windows
+ ltn = 'defaultgui'
+ knj = 'defaultgui'
+ when /Mincho:Helvetica-Bold-12/
+ # Tcl/Tk-JP for UNIX/X
+ ltn, knj = tk_split_simplelist(tk_call('font', 'configure',
+ 'Mincho:Helvetica-Bold-12',
+ '-compound'))
+ else
+ # unknown Tcl/Tk-JP
+ #platform = tk_call('set', 'tcl_platform(platform)')
+ platform = Tk::PLATFORM['platform']
+ case platform
+ when 'unix'
+ ltn = {'family'=>'Helvetica'.freeze,
+ 'size'=>-12, 'weight'=>'bold'.freeze}
+ #knj = 'k14'
+ #knj = '-misc-fixed-medium-r-normal--14-*-*-*-c-*-jisx0208.1983-0'
+ knj = '-*-fixed-bold-r-normal--12-*-*-*-c-*-jisx0208.1983-0'
+ when 'windows'
+ ltn = {'family'=>'MS Sans Serif'.freeze, 'size'=>8}
+ knj = 'mincho'
+ when 'macintosh'
+ ltn = 'system'
+ knj = 'mincho'
+ else # unknown
+ ltn = 'Helvetica'
+ knj = 'mincho'
+ end
+ end
+ rescue
+ ltn = 'Helvetica'
+ knj = 'mincho'
+ end
+
+ else # not JAPANIZED_TK
+ begin
+ #platform = tk_call('set', 'tcl_platform(platform)')
+ platform = Tk::PLATFORM['platform']
+ case platform
+ when 'unix'
+ ltn = {'family'=>'Helvetica'.freeze,
+ 'size'=>-12, 'weight'=>'bold'.freeze}
+ when 'windows'
+ ltn = {'family'=>'MS Sans Serif'.freeze, 'size'=>8}
+ when 'macintosh'
+ ltn = 'system'
+ else # unknown
+ ltn = 'Helvetica'
+ end
+ rescue
+ ltn = 'Helvetica'
+ end
+
+ knj = ltn.dup
+ end
+
+ DEFAULT_LATIN_FONT_NAME = ltn.freeze
+ DEFAULT_KANJI_FONT_NAME = knj.freeze
+
+ when /^8\.[5-9]/, /^9\..*/
+ if tk_call('font', 'names') =~ /\bTkDefaultFont\b/
+ DEFAULT_LATIN_FONT_NAME = 'TkDefaultFont'.freeze
+ DEFAULT_KANJI_FONT_NAME = 'TkDefaultFont'.freeze
+ else
+ DEFAULT_LATIN_FONT_NAME = 'Helvetica'.freeze
+ DEFAULT_KANJI_FONT_NAME = 'mincho'.freeze
+ end
+
+ else # unknown version
+ DEFAULT_LATIN_FONT_NAME = 'Helvetica'.freeze
+ DEFAULT_KANJI_FONT_NAME = 'mincho'.freeze
+
+ end
+
+ if $DEBUG
+ print "default latin font = "; p DEFAULT_LATIN_FONT_NAME
+ print "default kanji font = "; p DEFAULT_KANJI_FONT_NAME
+ end
+
+
+ ###################################
+ class DescendantFont
+ def initialize(compound, type)
+ unless compound.kind_of?(TkFont)
+ fail ArgumentError, "a TkFont object is expected for the 1st argument"
+ end
+
+ @compound = compound
+ case type
+ when 'kanji', 'latin', 'ascii'
+ @type = type
+ when :kanji, :latin, :ascii
+ @type = type.to_s
+ else
+ fail ArgumentError, "unknown type '#{type}'"
+ end
+ end
+
+ def dup
+ fail RuntimeError, "cannot dupulicate a descendant font"
+ end
+ def clone
+ fail RuntimeError, "cannot clone a descendant font"
+ end
+
+ def to_eval
+ @compound.__send__(@type + '_font_id')
+ end
+ def font
+ @compound.__send__(@type + '_font_id')
+ end
+ alias font_id font
+ alias name font
+ alias to_s font
+
+ def [](slot)
+ @compound.__send__(@type + '_configinfo', slot)
+ end
+ def []=(slot, value)
+ @compound.__send__(@type + '_configure', slot, value)
+ value
+ end
+
+ def method_missing(id, *args)
+ @compound.__send__(@type + '_' + id.id2name, *args)
+ end
+ end
+
+
+ ###################################
+ # class methods
+ ###################################
+ def TkFont.is_system_font?(fnt)
+ # true --> system font which is available on the current system
+ # false --> not system font (or unknown system font)
+ # nil --> system font name, but not available on the current system
+ fnt = fnt.to_s
+ SYSTEM_FONT_NAMES.include?(fnt) && self.names.index(fnt) && true
+ end
+
+ def TkFont.actual(fnt, option=nil)
+ fnt = '{}' if fnt == ''
+ if fnt.kind_of?(TkFont)
+ fnt.actual(option)
+ else
+ actual_core(fnt, nil, option)
+ end
+ end
+ def TkFont.actual_hash(fnt, option=nil)
+ Hash[TkFont.actual(fnt, option)]
+ end
+
+ def TkFont.actual_displayof(fnt, win, option=nil)
+ fnt = '{}' if fnt == ''
+ if fnt.kind_of?(TkFont)
+ fnt.actual_displayof(win, option)
+ else
+ win = '.' unless win
+ actual_core(fnt, win, option)
+ end
+ end
+ def TkFont.actual_hash_displayof(fnt, option=nil)
+ Hash[TkFont.actual_displayof(fnt, option)]
+ end
+
+ def TkFont.configure(fnt, slot, value=None)
+ if fnt.kind_of?(TkFont)
+ fnt.configure(fnt, slot, value)
+ else
+ configure_core(fnt, slot, value)
+ end
+ fnt
+ end
+
+ def TkFont.configinfo(fnt, slot=nil)
+ if fnt.kind_of?(TkFont)
+ fnt.configinfo(fnt, slot)
+ else
+ configinfo_core(fnt, slot)
+ end
+ end
+
+ def TkFont.current_configinfo(fnt, slot=nil)
+ if fnt.kind_of?(TkFont)
+ fnt.current_configinfo(fnt, slot)
+ else
+ current_configinfo_core(fnt, slot)
+ end
+ end
+
+ def TkFont.measure(fnt, text)
+ fnt = '{}' if fnt == ''
+ if fnt.kind_of?(TkFont)
+ fnt.measure(text)
+ else
+ measure_core(fnt, nil, text)
+ end
+ end
+
+ def TkFont.measure_displayof(fnt, win, text)
+ fnt = '{}' if fnt == ''
+ if fnt.kind_of?(TkFont)
+ fnt.measure_displayof(win, text)
+ else
+ win = '.' unless win
+ measure_core(fnt, win, text)
+ end
+ end
+
+ def TkFont.metrics(fnt, option=nil)
+ fnt = '{}' if fnt == ''
+ if fnt.kind_of?(TkFont)
+ fnt.metrics(option)
+ else
+ metrics_core(fnt, nil, option)
+ end
+ end
+ def TkFont.metrics_hash(fnt, option=nil)
+ if option
+ val = TkFont.metrics(fnt, option)
+ case TkFont::MetricsType[option.to_s]
+ when ?n
+ val = TkComm::num_or_str(val)
+ when ?b
+ val = TkComm::bool(val)
+ else
+ # do nothing
+ end
+ return val
+ end
+
+ h = Hash[TkFont.metrics(fnt)]
+ h.keys.each{|k|
+ case TkFont::MetricsType[k.to_s]
+ when ?n
+ h[k] = TkComm::num_or_str(h[k])
+ when ?b
+ h[k] = TkComm::bool(h[k])
+ else
+ # do nothing
+ end
+ }
+ h
+ end
+
+ def TkFont.metrics_displayof(fnt, win, option=nil)
+ fnt = '{}' if fnt == ''
+ if fnt.kind_of?(TkFont)
+ font.metrics_displayof(win, option=nil)
+ else
+ win = '.' unless win
+ metrics_core(fnt, win, option)
+ end
+ end
+ def TkFont.metrics_hash_displayof(fnt, win, option=nil)
+ if option
+ val = TkFont.metrics_displayof(fnt, win, option)
+ case TkFont::MetricsType[option.to_s]
+ when ?n
+ val = TkComm::num_or_str(val)
+ when ?b
+ val = TkComm::bool(val)
+ else
+ # do nothing
+ end
+ return val
+ end
+
+ h = Hash[TkFont.metrics_displayof(fnt, win, option)]
+ h.keys.each{|k|
+ case TkFont::MetricsType[k.to_s]
+ when ?n
+ h[k] = TkComm::num_or_str(h[k])
+ when ?b
+ h[k] = TkComm::bool(h[k])
+ else
+ # do nothing
+ end
+ }
+ h
+ end
+
+ def TkFont.families(win=nil)
+ case (Tk::TK_VERSION)
+ when /^4\..*/
+ ['fixed']
+
+ when /^8\..*/
+ if win
+ tk_split_simplelist(tk_call('font', 'families', '-displayof', win))
+ else
+ tk_split_simplelist(tk_call('font', 'families'))
+ end
+ end
+ end
+
+ def TkFont.names
+ case (Tk::TK_VERSION)
+ when /^4\..*/
+ r = ['fixed']
+ r += ['a14', 'k14'] if JAPANIZED_TK
+ Tk_FontNameTBL.mutex.synchronize{
+ Tk_FontNameTBL.each_value{|obj| r.push(obj)}
+ }
+ #r | []
+ r.uniq
+
+ when /^8\..*/
+ tk_split_simplelist(tk_call('font', 'names'))
+
+ end
+ end
+
+ def TkFont.create_copy(font)
+ fail 'source-font must be a TkFont object' unless font.kind_of? TkFont
+ if TkComm::GET_CONFIGINFOwoRES_AS_ARRAY
+ keys = {}
+ font.configinfo.each{|key,value| keys[key] = value }
+ TkFont.new(font.latin_font_id, font.kanji_font_id, keys)
+ else # ! TkComm::GET_CONFIGINFOwoRES_AS_ARRAY
+ TkFont.new(font.latin_font_id, font.kanji_font_id, font.configinfo)
+ end
+ end
+
+ def TkFont.get_obj(name)
+ name = name.to_s
+ if name =~ /^(@font[0-9]+)(|c|l|k)$/
+ Tk_FontNameTBL.mutex.synchronize{
+ Tk_FontNameTBL[$1]
+ }
+ else
+ Tk_FontNameTBL.mutex.synchronize{
+ Tk_FontNameTBL[name]
+ }
+ end
+ end
+
+ def TkFont.init_widget_font(pathname, *args)
+ win, tag, key = pathname.split(';')
+ key = 'font' if key == nil || key == ''
+ path = [win, tag, key].join(';')
+
+ case (Tk::TK_VERSION)
+ when /^4\..*/
+ regexp = /^-(|kanji)#{key} /
+
+ conf_list = tk_split_simplelist(tk_call(*args)).
+ find_all{|prop| prop =~ regexp}.
+ collect{|prop| tk_split_simplelist(prop)}
+
+ if conf_list.size == 0
+ raise RuntimeError, "the widget may not support 'font' option"
+ end
+
+ args << {}
+
+ ltn_key = "-#{key}"
+ knj_key = "-kanji#{key}"
+
+ ltn_info = conf_list.find{|conf| conf[0] == ltn_key}
+ ltn = ltn_info[-1]
+ ltn = nil if ltn == [] || ltn == ""
+
+ knj_info = conf_list.find{|conf| conf[0] == knj_key}
+ knj = knj_info[-1]
+ knj = nil if knj == [] || knj == ""
+
+ TkFont.new(ltn, knj).call_font_configure([path, key], *args)
+
+ when /^8\.[0-4]/
+ regexp = /^-#{key} /
+
+ conf_list = tk_split_simplelist(tk_call(*args)).
+ find_all{|prop| prop =~ regexp}.
+ collect{|prop| tk_split_simplelist(prop)}
+
+ if conf_list.size == 0
+ raise RuntimeError, "the widget may not support 'font' option"
+ end
+
+ args << {}
+
+ optkey = "-#{key}"
+
+ info = conf_list.find{|conf| conf[0] == optkey}
+ fnt = info[-1]
+ fnt = nil if fnt == [] || fnt == ""
+
+ unless fnt
+ # create dummy
+ # TkFont.new(nil, nil).call_font_configure([path, key], *args)
+ dummy_fnt = TkFont.allocate
+ dummy_fnt.instance_eval{ init_dummy_fontobj() }
+ dummy_fnt
+ else
+ begin
+ compound = tk_split_simplelist(
+ Hash[*tk_split_simplelist(tk_call('font', 'configure',
+ fnt))].collect{|k,v|
+ [k[1..-1], v]
+ }.assoc('compound')[1])
+ rescue
+ compound = []
+ end
+ if compound == []
+ if TkFont.is_system_font?(fnt)
+ TkNamedFont.new(fnt).call_font_configure([path, key], *args)
+ else
+ TkFont.new(fnt).call_font_configure([path, key], *args)
+ end
+ else
+ TkFont.new(compound[0],
+ compound[1]).call_font_configure([path, key], *args)
+ end
+ end
+
+ when /^8\.[5-9]/, /^9\..*/
+ regexp = /^-#{key} /
+
+ conf_list = tk_split_simplelist(tk_call(*args)).
+ find_all{|prop| prop =~ regexp}.
+ collect{|prop| tk_split_simplelist(prop)}
+
+ if conf_list.size == 0
+ raise RuntimeError, "the widget may not support 'font' option"
+ end
+
+ args << {}
+
+ optkey = "-#{key}"
+
+ info = conf_list.find{|conf| conf[0] == optkey}
+ fnt = info[-1]
+ fnt = nil if fnt == [] || fnt == ""
+
+ unless fnt
+ # create dummy
+ # TkFont.new(nil, nil).call_font_configure([path, key], *args)
+ dummy_fnt = TkFont.allocate
+ dummy_fnt.instance_eval{ init_dummy_fontobj() }
+ dummy_fnt
+ else
+ if TkFont.is_system_font?(fnt)
+ TkNamedFont.new(fnt).call_font_configure([path, key], *args)
+ else
+ TkFont.new(fnt).call_font_configure([path, key], *args)
+ end
+ end
+ end
+ end
+
+ def TkFont.used_on(path=nil)
+ Tk_FontUseTBL.mutex.synchronize{
+ if path
+ Tk_FontUseTBL[path]
+ else
+ # Tk_FontUseTBL.values | []
+ Tk_FontUseTBL.values.uniq
+ end
+ }
+ end
+
+ def TkFont.failsafe(font)
+ begin
+ if /^8\..*/ === Tk::TK_VERSION && JAPANIZED_TK
+ tk_call('font', 'failsafe', font)
+ end
+ rescue
+ end
+ end
+
+ ###################################
+ # instance methods
+ ###################################
+ private
+ ###################################
+ def init_dummy_fontobj
+ Tk_FontID.mutex.synchronize{
+ @id = Tk_FontID.join(TkCore::INTERP._ip_id_)
+ Tk_FontID[1].succ!
+ }
+ Tk_FontNameTBL.mutex.synchronize{
+ Tk_FontNameTBL[@id] = self
+ }
+
+ # @latin_desscendant = nil
+ # @kanji_desscendant = nil
+ @descendant = [nil, nil] # [latin, kanji]
+
+ case (Tk::TK_VERSION)
+ when /^4\..*/
+ @latinfont = ""
+ @kanjifont = ""
+ if JAPANIZED_TK
+ @compoundfont = [[@latinfont], [@kanjifont]]
+ @fontslot = {'font'=>@latinfont, 'kanjifont'=>@kanjifont}
+ else
+ @compoundfont = @latinfont
+ @fontslot = {'font'=>@latinfont}
+ end
+ else
+ @latinfont = @id + 'l'
+ @kanjifont = @id + 'k'
+ @compoundfont = @id + 'c'
+
+ if JAPANIZED_TK
+ tk_call('font', 'create', @latinfont, '-charset', 'iso8859')
+ tk_call('font', 'create', @kanjifont, '-charset', 'jisx0208.1983')
+ tk_call('font', 'create', @compoundfont,
+ '-compound', [@latinfont, @kanjifont])
+ else
+ tk_call('font', 'create', @latinfont)
+ tk_call('font', 'create', @kanjifont)
+ tk_call('font', 'create', @compoundfont)
+ end
+
+ @fontslot = {'font'=>@compoundfont}
+ end
+
+ self
+ end
+
+ def initialize(ltn=nil, knj=nil, keys=nil)
+ ltn = '{}' if ltn == ''
+ knj = '{}' if knj == ''
+
+ Tk_FontID.mutex.synchronize{
+ # @id = Tk_FontID.join('')
+ @id = Tk_FontID.join(TkCore::INTERP._ip_id_)
+ Tk_FontID[1].succ!
+ }
+ Tk_FontNameTBL.mutex.synchronize{
+ Tk_FontNameTBL[@id] = self
+ }
+
+ # @latin_desscendant = nil
+ # @kanji_desscendant = nil
+ @descendant = [nil, nil] # [latin, kanji]
+
+ # @latinfont = @id + 'l'
+ # @kanjifont = @id + 'k'
+ # @compoundfont = @id + 'c'
+ # @fontslot = {}
+
+ if knj.kind_of?(Hash) && !keys
+ keys = knj
+ knj = nil
+ end
+
+ # compound font check
+ if Tk::TK_VERSION == '8.0' && JAPANIZED_TK
+ begin
+ compound = tk_split_simplelist(tk_call('font', 'configure',
+ ltn, '-compound'))
+ if knj == nil
+ if compound != []
+ ltn, knj = compound
+ end
+ else
+ if compound != []
+ ltn = compound[0]
+ end
+ compound = tk_split_simplelist(tk_call('font', 'configure',
+ knj, '-compound'))
+ if compound != []
+ knj = compound[1]
+ end
+ end
+ rescue
+ end
+ end
+
+ if ltn
+ if JAPANIZED_TK && !knj
+ if Tk::TK_VERSION =~ /^4..*/
+ knj = DEFAULT_KANJI_FONT_NAME
+ else
+ knj = ltn
+ end
+ end
+ else
+ ltn = DEFAULT_LATIN_FONT_NAME
+ knj = DEFAULT_KANJI_FONT_NAME if JAPANIZED_TK && !knj
+ end
+
+ create_compoundfont(ltn, knj, keys)
+ end
+
+ def initialize_copy(font)
+ unless font.kind_of?(TkFont)
+ fail TypeError, '"initialize_copy should take same class object'
+ end
+ if TkComm::GET_CONFIGINFOwoRES_AS_ARRAY
+ keys = {}
+ font.configinfo.each{|key,value| keys[key] = value }
+ initialize(font.latin_font_id, font.kanji_font_id, keys)
+ else # ! TkComm::GET_CONFIGINFOwoRES_AS_ARRAY
+ initialize(font.latin_font_id, font.kanji_font_id, font.configinfo)
+ end
+ end
+
+ def _get_font_info_from_hash(font)
+ font = _symbolkey2str(font)
+ foundry = (info = font['foundry'] .to_s)? info: '*'
+ family = (info = font['family'] .to_s)? info: '*'
+ weight = (info = font['weight'] .to_s)? info: '*'
+ slant = (info = font['slant'] .to_s)? info: '*'
+ swidth = (info = font['swidth'] .to_s)? info: '*'
+ adstyle = (info = font['adstyle'] .to_s)? info: '*'
+ pixels = (info = font['pixels'] .to_s)? info: '*'
+ points = (info = font['points'] .to_s)? info: '*'
+ resx = (info = font['resx'] .to_s)? info: '*'
+ resy = (info = font['resy'] .to_s)? info: '*'
+ space = (info = font['space'] .to_s)? info: '*'
+ avgWidth = (info = font['avgWidth'].to_s)? info: '*'
+ charset = (info = font['charset'] .to_s)? info: '*'
+ encoding = (info = font['encoding'].to_s)? info: '*'
+
+ [foundry, family, weight, slant, swidth, adstyle,
+ pixels, points, resx, resy, space, avgWidth, charset, encoding]
+ end
+
+ def create_latinfont_tk4x(font)
+ if font.kind_of? Hash
+ @latinfont = '-' + _get_font_info_from_hash(font).join('-') + '-'
+
+ elsif font.kind_of? Array
+ finfo = {}
+ finfo['family'] = font[0].to_s
+ if font[1]
+ fsize = font[1].to_s
+ if fsize != '0' && fsize =~ /^(|\+|-)([0-9]+)$/
+ if $1 == '-'
+ finfo['pixels'] = $2
+ else
+ finfo['points'] = $2
+ end
+ else
+ finfo['points'] = '13'
+ end
+ end
+ font[2..-1].each{|style|
+ case (style)
+ when 'normal'
+ finfo['weight'] = style
+ when 'bold'
+ finfo['weight'] = style
+ when 'roman'
+ finfo['slant'] = 'r'
+ when 'italic'
+ finfo['slant'] = 'i'
+ end
+ }
+
+ @latinfont = '-' + _get_font_info_from_hash(finfo).join('-') + '-'
+
+ elsif font.kind_of? TkFont
+ @latinfont = font.latin_font
+
+ else
+ if font
+ @latinfont = font
+ else
+ @latinfont = DEFAULT_LATIN_FONT_NAME
+ end
+
+ end
+ end
+
+ def create_kanjifont_tk4x(font)
+ unless JAPANIZED_TK
+ @kanjifont = ""
+ return
+ end
+
+ if font.kind_of? Hash
+ @kanjifont = '-' + _get_font_info_from_hash(font).join('-') + '-'
+
+ elsif font.kind_of? Array
+ finfo = {}
+ finfo['family'] = font[0].to_s
+ if font[1]
+ fsize = font[1].to_s
+ if fsize != '0' && fsize =~ /^(|\+|-)([0-9]+)$/
+ if $1 == '-'
+ finfo['pixels'] = $2
+ else
+ finfo['points'] = $2
+ end
+ else
+ finfo['points'] = '13'
+ end
+ end
+ font[2..-1].each{|style|
+ case (style)
+ when 'normal'
+ finfo['weight'] = style
+ when 'bold'
+ finfo['weight'] = style
+ when 'roman'
+ finfo['slant'] = 'r'
+ when 'italic'
+ finfo['slant'] = 'i'
+ end
+ }
+
+ @kanjifont = '-' + _get_font_info_from_hash(finfo).join('-') + '-'
+ elsif font.kind_of? TkFont
+ @kanjifont = font.kanji_font_id
+ else
+ if font
+ @kanjifont = font
+ else
+ @kanjifont = DEFAULT_KANJI_FONT_NAME
+ end
+ end
+ end
+
+ def create_compoundfont_tk4x(ltn, knj, keys)
+ create_latinfont(ltn)
+ create_kanjifont(knj)
+
+ if JAPANIZED_TK
+ @compoundfont = [[@latinfont], [@kanjifont]]
+ @fontslot = {'font'=>@latinfont, 'kanjifont'=>@kanjifont}
+ # @fontslot.clear
+ # @fontslot['font'] = @latinfont
+ # @fontslot['kanjifont'] = @kanjifont
+ else
+ @compoundfont = @latinfont
+ @fontslot = {'font'=>@latinfont}
+ # @fontslot.clear
+ # @fontslot['font'] = @latinfont
+ end
+ end
+
+ def create_latinfont_tk8x(font)
+ @latinfont = @id + 'l'
+
+ if JAPANIZED_TK
+ if font.kind_of? Hash
+ if font[:charset] || font['charset']
+ tk_call('font', 'create', @latinfont, *hash_kv(font))
+ else
+ tk_call('font', 'create', @latinfont,
+ '-charset', 'iso8859', *hash_kv(font))
+ end
+ elsif font.kind_of? Array
+ tk_call('font', 'create', @latinfont, '-copy', array2tk_list(font))
+ tk_call('font', 'configure', @latinfont, '-charset', 'iso8859')
+ elsif font.kind_of? TkFont
+ tk_call('font', 'create', @latinfont, '-copy', font.latin_font)
+ elsif font
+ tk_call('font', 'create', @latinfont, '-copy', font,
+ '-charset', 'iso8859')
+ else
+ tk_call('font', 'create', @latinfont, '-charset', 'iso8859')
+ end
+ else
+ if font.kind_of? Hash
+ tk_call('font', 'create', @latinfont, *hash_kv(font))
+ else
+ keys = {}
+ if font.kind_of? Array
+ actual_core(array2tk_list(font)).each{|key,val| keys[key] = val}
+ elsif font.kind_of? TkFont
+ actual_core(font.latin_font).each{|key,val| keys[key] = val}
+ elsif font
+ actual_core(font).each{|key,val| keys[key] = val}
+ end
+ tk_call('font', 'create', @latinfont, *hash_kv(keys))
+ end
+
+ if font && @compoundfont
+ keys = {}
+ actual_core(@latinfont).each{|key,val| keys[key] = val}
+ tk_call('font', 'configure', @compoundfont, *hash_kv(keys))
+ end
+ end
+ end
+
+ def create_kanjifont_tk8x(font)
+ @kanjifont = @id + 'k'
+
+ if JAPANIZED_TK
+ if font.kind_of? Hash
+ if font[:charset] || font['charset']
+ tk_call('font', 'create', @kanjifont, *hash_kv(font))
+ else
+ tk_call('font', 'create', @kanjifont,
+ '-charset', 'jisx0208.1983', *hash_kv(font))
+ end
+ elsif font.kind_of? Array
+ tk_call('font', 'create', @kanjifont, '-copy', array2tk_list(font))
+ tk_call('font', 'configure', @kanjifont, '-charset', 'jisx0208.1983')
+ elsif font.kind_of? TkFont
+ tk_call('font', 'create', @kanjifont, '-copy', font.kanji_font_id)
+ elsif font
+ tk_call('font', 'create', @kanjifont, '-copy', font,
+ '-charset', 'jisx0208.1983')
+ else
+ tk_call('font', 'create', @kanjifont, '-charset', 'jisx0208.1983')
+ end
+ # end of JAPANIZED_TK
+
+ else
+ if font.kind_of? Hash
+ tk_call('font', 'create', @kanjifont, *hash_kv(font))
+ else
+ keys = {}
+ if font.kind_of? Array
+ actual_core(array2tk_list(font)).each{|key,val| keys[key] = val}
+ elsif font.kind_of? TkFont
+ actual_core(font.kanji_font_id).each{|key,val| keys[key] = val}
+ elsif font
+ actual_core(font).each{|key,val| keys[key] = val}
+ end
+ tk_call('font', 'create', @kanjifont, *hash_kv(keys))
+ end
+
+ if font && @compoundfont
+ keys = {}
+ actual_core(@kanjifont).each{|key,val| keys[key] = val}
+ tk_call('font', 'configure', @compoundfont, *hash_kv(keys))
+ end
+ end
+ end
+
+ def create_compoundfont_tk8x(ltn, knj, keys)
+ if knj
+ create_latinfont(ltn)
+ create_kanjifont(knj)
+ else
+ cfnt = ltn
+ create_kanjifont(cfnt)
+ create_latinfont(cfnt)
+ end
+
+ @compoundfont = @id + 'c'
+
+ if JAPANIZED_TK
+ unless keys
+ keys = {}
+ else
+ keys = keys.dup
+ end
+ if (tk_call('font', 'configure', @latinfont, '-underline') == '1' &&
+ tk_call('font', 'configure', @kanjifont, '-underline') == '1' &&
+ !keys.key?('underline'))
+ keys['underline'] = true
+ end
+ if (tk_call('font', 'configure', @latinfont, '-overstrike') == '1' &&
+ tk_call('font', 'configure', @kanjifont, '-overstrike') == '1' &&
+ !keys.key?('overstrike'))
+ keys['overstrike'] = true
+ end
+
+ @fontslot = {'font'=>@compoundfont}
+ # @fontslot['font'] = @compoundfont
+ begin
+ tk_call('font', 'create', @compoundfont,
+ '-compound', [@latinfont, @kanjifont], *hash_kv(keys))
+ rescue RuntimeError => e
+ if ltn == knj
+ if e.message =~ /kanji font .* specified/
+ tk_call('font', 'delete', @latinfont)
+ create_latinfont(DEFAULT_LATIN_FONT_NAME)
+ opts = []
+ Hash[*(tk_split_simplelist(tk_call('font', 'configure',
+ @kanjifont)))].each{|k,v|
+ case k
+ when '-size', '-weight', '-slant', '-underline', '-overstrike'
+ opts << k << v
+ end
+ }
+ tk_call('font', 'configure', @latinfont, *opts)
+ tk_call('font', 'create', @compoundfont,
+ '-compound', [@latinfont, @kanjifont], *hash_kv(keys))
+
+ elsif e.message =~ /ascii font .* specified/
+ tk_call('font', 'delete', @kanjifont)
+ create_kanjifont(DEFAULT_KANJI_FONT_NAME)
+ opts = []
+ Hash[*(tk_split_simplelist(tk_call('font', 'configure',
+ @latinfont)))].each{|k,v|
+ case k
+ when '-size', '-weight', '-slant', '-underline', '-overstrike'
+ opts << k << v
+ end
+ }
+ tk_call('font', 'configure', @kanjifont, *opts)
+ tk_call('font', 'create', @compoundfont,
+ '-compound', [@latinfont, @kanjifont], *hash_kv(keys))
+
+ else
+ raise e
+ end
+ else
+ raise e
+ end
+ end
+ else
+ tk_call('font', 'create', @compoundfont)
+
+ latinkeys = {}
+ begin
+ actual_core(@latinfont).each{|key,val| latinkeys[key] = val}
+ rescue
+ latinkeys = {}
+ end
+ if latinkeys != {}
+ tk_call('font', 'configure', @compoundfont, *hash_kv(latinkeys))
+ end
+
+ if knj
+ compoundkeys = nil
+ kanjikeys = {}
+ begin
+ actual_core(@kanjifont).each{|key,val| kanjikeys[key] = val}
+ rescue
+ kanjikeys = {}
+ end
+ if kanjikeys != {}
+ tk_call('font', 'configure', @compoundfont, *hash_kv(kanjikeys))
+ end
+ end
+
+ if cfnt
+ if cfnt.kind_of?(Hash)
+ compoundkeys = cfnt.dup
+ else
+ compoundkeys = {}
+ actual_core(cfnt).each{|key,val| compoundkeys[key] = val}
+ end
+ compoundkeys.update(_symbolkey2str(keys))
+ keys = compoundkeys
+ end
+
+ @fontslot = {'font'=>@compoundfont}
+ # @fontslot['font'] = @compoundfont
+ tk_call('font', 'configure', @compoundfont, *hash_kv(keys))
+ end
+ end
+
+ ###################################
+ public
+ ###################################
+ def inspect
+ sprintf("#<%s:%0x:%s>", self.class.inspect, self.__id__, @compoundfont)
+ end
+
+ def method_missing(id, *args)
+ name = id.id2name
+ case args.length
+ when 1
+ if name[-1] == ?=
+ configure name[0..-2], args[0]
+ args[0]
+ else
+ configure name, args[0]
+ self
+ end
+ when 0
+ begin
+ configinfo name
+ rescue
+ super(id, *args)
+# fail NameError, "undefined local variable or method `#{name}' for #{self.to_s}", error_at
+ end
+ else
+ super(id, *args)
+# fail NameError, "undefined method `#{name}' for #{self.to_s}", error_at
+ end
+ end
+
+ def call_font_configure(path, *args)
+ if path.kind_of?(Array)
+ # [path, optkey]
+ win, tag = path[0].split(';')
+ optkey = path[1].to_s
+ else
+ win, tag, optkey = path.split(';')
+ end
+
+ fontslot = _symbolkey2str(@fontslot)
+ if optkey && optkey != ""
+ ltn = fontslot.delete('font')
+ knj = fontslot.delete('kanjifont')
+ fontslot[optkey] = ltn if ltn
+ fontslot["kanji#{optkey}"] = knj if knj
+ end
+
+ keys = _symbolkey2str(args.pop).update(fontslot)
+ args.concat(hash_kv(keys))
+ begin
+ tk_call(*args)
+ rescue => e
+ unless TkConfigMethod.__IGNORE_UNKNOWN_CONFIGURE_OPTION__
+ fail e
+ end
+ end
+ Tk_FontUseTBL.mutex.synchronize{
+ Tk_FontUseTBL[[win, tag, optkey].join(';')] = self
+ }
+ self
+ end
+
+ def used
+ ret = []
+ table = nil
+ Tk_FontUseTBL.mutex.synchronize{
+ table = Tk_FontUseTBL.clone # to avoid deadlock
+ }
+ table.each{|key,value|
+ next unless self == value
+ if key.include?(';')
+ win, tag, optkey = key.split(';')
+ winobj = tk_tcl2ruby(win)
+ #if winobj.kind_of? TkText
+ if winobj.kind_of?(TkText) || winobj.kind_of?(Tk::Text)
+ if optkey
+ ret.push([winobj, winobj.tagid2obj(tag), optkey])
+ else
+ ret.push([winobj, winobj.tagid2obj(tag)])
+ end
+ #elsif winobj.kind_of? TkCanvas
+ elsif winobj.kind_of?(TkCanvas) || winobj.kind_of?(Tk::Canvas)
+ if (tagobj = TkcTag.id2obj(winobj, tag)).kind_of? TkcTag
+ if optkey
+ ret.push([winobj, tagobj, optkey])
+ else
+ ret.push([winobj, tagobj])
+ end
+ elsif (tagobj = TkcItem.id2obj(winobj, tag)).kind_of? TkcItem
+ if optkey
+ ret.push([winobj, tagobj, optkey])
+ else
+ ret.push([winobj, tagobj])
+ end
+ else
+ if optkey
+ ret.push([winobj, tag, optkey])
+ else
+ ret.push([winobj, tag])
+ end
+ end
+ #elsif winobj.kind_of? TkMenu
+ elsif winobj.kind_of?(TkMenu) || winobj.kind_of?(Tk::Menu)
+ if optkey
+ ret.push([winobj, tag, optkey])
+ else
+ ret.push([winobj, tag])
+ end
+ else
+ if optkey
+ ret.push([win, tag, optkey])
+ else
+ ret.push([win, tag])
+ end
+ end
+ else
+ ret.push(tk_tcl2ruby(key))
+ end
+ }
+ ret
+ end
+
+ def id
+ @id
+ end
+
+ def to_eval
+ font
+ end
+
+ def font
+ @compoundfont
+ end
+ alias font_id font
+ alias name font
+ alias to_s font
+
+ def latin_font_id
+ @latinfont
+ end
+
+ def latin_font
+ # @latinfont
+ if @descendant[0] # [0] -> latin
+ @descendant[0]
+ else
+ @descendant[0] = DescendantFont.new(self, 'latin')
+ end
+=begin
+ if @latin_descendant
+ @latin_descendant
+ else
+ @latin_descendant = DescendantFont.new(self, 'latin')
+ end
+=end
+ end
+ alias latinfont latin_font
+
+ def kanji_font_id
+ @kanjifont
+ end
+
+ def kanji_font
+ # @kanjifont
+ if @descendant[1] # [1] -> kanji
+ @descendant[1]
+ else
+ @descendant[1] = DescendantFont.new(self, 'kanji')
+ end
+=begin
+ if @kanji_descendant
+ @kanji_descendant
+ else
+ @kanji_descendant = DescendantFont.new(self, 'kanji')
+ end
+=end
+ end
+ alias kanjifont kanji_font
+
+ def actual(option=nil)
+ actual_core(@compoundfont, nil, option)
+ end
+ def actual_hash(option=nil)
+ Hash[actual(option)]
+ end
+
+ def actual_displayof(win, option=nil)
+ win = '.' unless win
+ actual_core(@compoundfont, win, option)
+ end
+ def actual_hash_displayof(win, option=nil)
+ Hash[actual_displayof(win, option)]
+ end
+
+ def latin_actual(option=nil)
+ if @latinfont == nil
+ actual_core(@compoundfont, nil, option) # use @compoundfont
+ else
+ actual_core(@latinfont, nil, option)
+ end
+ end
+ def latin_actual_hash(option=nil)
+ Hash[latin_actual(option)]
+ end
+
+ def latin_actual_displayof(win, option=nil)
+ win = '.' unless win
+ if @latinfont == nil
+ actual_core(@compoundfont, win, option) # use @compoundfont
+ else
+ actual_core(@latinfont, win, option)
+ end
+ end
+ def latin_actual_hash_displayof(win, option=nil)
+ Hash[latin_actual_displayof(win, option)]
+ end
+
+ def kanji_actual(option=nil)
+ #if JAPANIZED_TK
+ if @kanjifont == nil
+ actual_core(@compoundfont, nil, option) # use @compoundfont
+ elsif @kanjifont != ""
+ actual_core(@kanjifont, nil, option)
+ else
+ actual_core_tk4x(nil, nil, option)
+ end
+ end
+ def kanji_actual_hash(option=nil)
+ Hash[kanji_actual(option)]
+ end
+
+ def kanji_actual_displayof(win, option=nil)
+ #if JAPANIZED_TK
+ if @kanjifont == nil
+ actual_core(@compoundfont, nil, option) # use @compoundfont
+ elsif @kanjifont != ""
+ win = '.' unless win
+ actual_core(@kanjifont, win, option)
+ else
+ actual_core_tk4x(nil, win, option)
+ end
+ end
+ def kanji_actual_hash_displayof(win, option=nil)
+ Hash[kanji_actual_displayof(win, option)]
+ end
+
+ def [](slot)
+ configinfo slot
+ end
+
+ def []=(slot, val)
+ configure slot, val
+ val
+ end
+
+ def configure(slot, value=None)
+ configure_core(@compoundfont, slot, value)
+ self
+ end
+
+ def configinfo(slot=nil)
+ configinfo_core(@compoundfont, slot)
+ end
+
+ def current_configinfo(slot=nil)
+ current_configinfo_core(@compoundfont, slot)
+ end
+
+ def delete
+ delete_core
+ end
+
+ def latin_configure(slot, value=None)
+ if JAPANIZED_TK
+ configure_core(@latinfont, slot, value)
+ else
+ configure(slot, value)
+ end
+ self
+ end
+
+ def latin_configinfo(slot=nil)
+ if JAPANIZED_TK
+ configinfo_core(@latinfont, slot)
+ else
+ configinfo(slot)
+ end
+ end
+ def latin_current_configinfo(slot=nil)
+ Hash[latin_configinfo(slot)]
+ end
+
+ def kanji_configure(slot, value=None)
+ #if JAPANIZED_TK
+ if @kanjifont == nil
+ configure_core(@compoundfont, slot, value) # use @compoundfont
+ elsif @kanjifont != ""
+ configure_core(@kanjifont, slot, value)
+ configure('size'=>configinfo('size')) # to reflect new configuration
+ else
+ #""
+ configure(slot, value)
+ end
+ self
+ end
+
+ def kanji_configinfo(slot=nil)
+ #if JAPANIZED_TK
+ if @kanjifont == nil
+ configure_core(@compoundfont, slot) # use @compoundfont
+ elsif @kanjifont != ""
+ configinfo_core(@kanjifont, slot)
+ else
+ #[]
+ configinfo(slot)
+ end
+ end
+ def kanji_current_configinfo(slot=nil)
+ Hash[kanji_configinfo(slot)]
+ end
+
+ def replace(ltn, knj=None)
+ knj = ltn if knj == None
+ latin_replace(ltn)
+ kanji_replace(knj)
+ self
+ end
+
+ def latin_replace(ltn)
+ if @latinfont
+ latin_replace_core(ltn)
+ reset_pointadjust
+ else
+ # not compound font -> copy properties of ltn
+ latinkeys = {}
+ begin
+ actual_core(ltn).each{|key,val| latinkeys[key] = val}
+ rescue
+ latinkeys = {}
+ end
+ begin
+ tk_call('font', 'configure', @compoundfont, *hash_kv(latinkeys))
+ rescue
+ # not exist? (deleted?) -> create font
+ tk_call('font', 'create', @compoundfont, *hash_kv(latinkeys))
+ end
+ end
+
+ self
+ end
+
+ def kanji_replace(knj)
+ return self unless @kanjifont # ignore
+ kanji_replace_core(knj)
+ reset_pointadjust
+ self
+ end
+
+ def measure(text)
+ measure_core(@compoundfont, nil, text)
+ end
+
+ def measure_displayof(win, text)
+ win = '.' unless win
+ measure_core(@compoundfont, win, text)
+ end
+
+ def metrics(option=nil)
+ metrics_core(@compoundfont, nil, option)
+ end
+ def metrics_hash(option=nil)
+ if option
+ val = metrics(option)
+ case TkFont::MetricsType[option.to_s]
+ when ?n
+ val = TkComm::num_or_str(val)
+ when ?b
+ val = TkComm::bool(val)
+ else
+ # do nothing
+ end
+ return val
+ end
+
+ h = Hash[metrics(option)]
+ h.keys.each{|k|
+ case TkFont::MetricsType[k.to_s]
+ when ?n
+ h[k] = TkComm::num_or_str(h[k])
+ when ?b
+ h[k] = TkComm::bool(h[k])
+ else
+ # do nothing
+ end
+ }
+ h
+ end
+
+ def metrics_displayof(win, option=nil)
+ win = '.' unless win
+ metrics_core(@compoundfont, win, option)
+ end
+ def metrics_hash_displayof(win, option=nil)
+ if option
+ val = metrics_displayof(win, option)
+ case TkFont::MetricsType[option.to_s]
+ when ?n
+ val = TkComm::num_or_str(val)
+ when ?b
+ val = TkComm::bool(val)
+ else
+ # do nothing
+ end
+ return val
+ end
+
+ h = Hash[metrics_displayof(win, option)]
+ h.keys.each{|k|
+ case TkFont::MetricsType[k.to_s]
+ when ?n
+ h[k] = TkComm::num_or_str(h[k])
+ when ?b
+ h[k] = TkComm::bool(h[k])
+ else
+ # do nothing
+ end
+ }
+ h
+ end
+
+ def latin_metrics(option=nil)
+ if @latinfont == nil
+ metrics_core(@compoundfont, nil, option) # use @compoundfont
+ else
+ metrics_core(@latinfont, nil, option)
+ end
+ end
+ def latin_metrics_hash(option=nil)
+ if option
+ val = latin_metrics(option)
+ case TkFont::MetricsType[option.to_s]
+ when ?n
+ val = TkComm::num_or_str(val)
+ when ?b
+ val = TkComm::bool(val)
+ else
+ # do nothing
+ end
+ return val
+ end
+
+ h = Hash[latin_metrics(option)]
+ h.keys.each{|k|
+ case TkFont::MetricsType[k.to_s]
+ when ?n
+ h[k] = TkComm::num_or_str(h[k])
+ when ?b
+ h[k] = TkComm::bool(h[k])
+ else
+ # do nothing
+ end
+ }
+ h
+ end
+
+ def latin_metrics_displayof(win, option=nil)
+ win = '.' unless win
+ if @latinfont == nil
+ metrics_core(@compoundfont, win, option) # use @compoundfont
+ else
+ metrics_core(@latinfont, win, option)
+ end
+ end
+ def latin_metrics_hash_displayof(win, option=nil)
+ if option
+ val = latin_metrics_displayof(win, option)
+ case TkFont::MetricsType[option.to_s]
+ when ?n
+ val = TkComm::num_or_str(val)
+ when ?b
+ val = TkComm::bool(val)
+ else
+ # do nothing
+ end
+ return val
+ end
+
+ h = Hash[latin_metrics_displayof(win, option)]
+ h.keys.each{|k|
+ case TkFont::MetricsType[k.to_s]
+ when ?n
+ h[k] = TkComm::num_or_str(h[k])
+ when ?b
+ h[k] = TkComm::bool(h[k])
+ else
+ # do nothing
+ end
+ }
+ h
+ end
+
+ def kanji_metrics(option=nil)
+ if @latinfont == nil
+ metrics_core(@compoundfont, nil, option) # use @compoundfont
+ elsif JAPANIZED_TK
+ metrics_core(@kanjifont, nil, option)
+ else
+ metrics_core_tk4x(nil, nil, option)
+ end
+ end
+ def kanji_metrics_hash(option=nil)
+ if option
+ val = kanji_metrics(option)
+ case TkFont::MetricsType[option.to_s]
+ when ?n
+ val = TkComm::num_or_str(val)
+ when ?b
+ val = TkComm::bool(val)
+ else
+ # do nothing
+ end
+ return val
+ end
+
+ h = Hash[kanji_metrics(option)]
+ h.keys.each{|k|
+ case TkFont::MetricsType[k.to_s]
+ when ?n
+ h[k] = TkComm::num_or_str(h[k])
+ when ?b
+ h[k] = TkComm::bool(h[k])
+ else
+ # do nothing
+ end
+ }
+ h
+ end
+
+ def kanji_metrics_displayof(win, option=nil)
+ win = '.' unless win
+ if @latinfont == nil
+ metrics_core(@compoundfont, win, option) # use @compoundfont
+ elsif JAPANIZED_TK
+ metrics_core(@kanjifont, win, option)
+ else
+ metrics_core_tk4x(nil, win, option)
+ end
+ end
+ def kanji_metrics_hash_displayof(win, option=nil)
+ if option
+ val = kanji_metrics_displayof(win, option)
+ case TkFont::MetricsType[option.to_s]
+ when ?n
+ val = TkComm::num_or_str(val)
+ when ?b
+ val = TkComm::bool(val)
+ else
+ # do nothing
+ end
+ return val
+ end
+
+ h = Hash[kanji_metrics_displayof(win, option)]
+ h.keys.each{|k|
+ case TkFont::MetricsType[k.to_s]
+ when ?n
+ h[k] = TkComm::num_or_str(h[k])
+ when ?b
+ h[k] = TkComm::bool(h[k])
+ else
+ # do nothing
+ end
+ }
+ h
+ end
+
+ def reset_pointadjust
+ begin
+ if /^8\..*/ === Tk::TK_VERSION && JAPANIZED_TK
+ configure('pointadjust' => latin_actual.assoc('size')[1].to_f /
+ kanji_actual.assoc('size')[1].to_f )
+ end
+ rescue
+ end
+ self
+ end
+
+ ###################################
+ # private alias
+ ###################################
+ case (Tk::TK_VERSION)
+ when /^4\..*/
+ alias create_latinfont create_latinfont_tk4x
+ alias create_kanjifont create_kanjifont_tk4x
+ alias create_compoundfont create_compoundfont_tk4x
+
+ when /^8\.[0-5]/
+ alias create_latinfont create_latinfont_tk8x
+ alias create_kanjifont create_kanjifont_tk8x
+ alias create_compoundfont create_compoundfont_tk8x
+
+ else
+ alias create_latinfont create_latinfont_tk8x
+ alias create_kanjifont create_kanjifont_tk8x
+ alias create_compoundfont create_compoundfont_tk8x
+
+ end
+
+ ###################################
+ # public alias
+ ###################################
+ alias ascii_font latin_font
+ alias asciifont latinfont
+ alias create_asciifont create_latinfont
+ alias ascii_actual latin_actual
+ alias ascii_actual_displayof latin_actual_displayof
+ alias ascii_configure latin_configure
+ alias ascii_configinfo latin_configinfo
+ alias ascii_replace latin_replace
+ alias ascii_metrics latin_metrics
+
+ ###################################
+=begin
+ def dup
+ TkFont.new(self)
+ end
+ def clone
+ TkFont.new(self)
+ end
+=end
+end
+
+module TkFont::CoreMethods
+ include Tk
+ extend TkCore
+
+ private
+
+ def actual_core_tk4x(font, win=nil, option=nil)
+ # dummy
+ if option == 'pointadjust' || option == :pointadjust
+ 1.0
+ elsif option
+ case TkFont::OptionType[option.to_s]
+ when ?n
+ 0
+ when ?b
+ false
+ else
+ ''
+ end
+ else
+ [['family',''], ['size',0], ['weight',''], ['slant',''],
+ ['underline',false], ['overstrike',false], ['charset',''],
+ ['pointadjust',0]]
+ end
+ end
+
+ def actual_core_tk8x(font, win=nil, option=nil)
+ font = '{}' if font == ''
+
+ if option == 'compound' || option == :compound
+ ""
+ elsif option
+ if win
+ val = tk_call('font', 'actual', font,
+ "-displayof", win, "-#{option}")
+ else
+ val = tk_call('font', 'actual', font, "-#{option}")
+ end
+ case TkFont::OptionType[option.to_s]
+ when ?n
+ num_or_str(val)
+ when ?b
+ bool(val)
+ else
+ val
+ end
+ else
+ l = tk_split_simplelist(if win
+ tk_call('font', 'actual', font,
+ "-displayof", win)
+ else
+ tk_call('font', 'actual', font)
+ end)
+ r = []
+ while key=l.shift
+ if key == '-compound'
+ l.shift
+ else
+ key = key[1..-1]
+ val = l.shift
+ case TkFont::OptionType[key]
+ when ?n
+ r.push [key, num_or_str(val)]
+ when ?b
+ r.push [key, bool(val)]
+ else
+ r.push [key, val]
+ end
+ end
+ end
+ r
+ end
+ end
+
+ def configure_core_tk4x(font, slot, value=None)
+ #""
+ self
+ end
+
+ def configinfo_core_tk4x(font, option=nil)
+ # dummy
+ if TkComm::GET_CONFIGINFOwoRES_AS_ARRAY
+ if option == 'pointadjust' || option == :pointadjust
+ 1.0
+ elsif option
+ case TkFont::OptionType[option.to_s]
+ when ?n
+ 0
+ when ?b
+ false
+ else
+ ''
+ end
+ else
+ [['family',''], ['size',0], ['weight',''], ['slant',''],
+ ['underline',false], ['overstrike',false], ['charset',''],
+ ['pointadjust',1.0]]
+ end
+ else # ! TkComm::GET_CONFIGINFOwoRES_AS_ARRAY
+ current_configinfo_core_tk4x(font, option)
+ end
+ end
+
+ def current_configinfo_core_tk4x(font, option=nil)
+ if option
+ case TkFont::OptionType[option.to_s]
+ when ?n
+ 0
+ when ?b
+ false
+ else
+ ''
+ end
+ else
+ {'family'=>'', 'size'=>0, 'weight'=>'', 'slant'=>'',
+ 'underline'=>false, 'overstrike'=>false,
+ 'charset'=>false, 'pointadjust'=>1.0}
+ end
+ end
+
+ def configure_core_tk8x(font, slot, value=None)
+ if JAPANIZED_TK
+ begin
+ padjust = tk_call('font', 'configure', font, '-pointadjust')
+ rescue
+ padjust = nil
+ end
+ else
+ padjust = nil
+ end
+ if slot.kind_of? Hash
+ if JAPANIZED_TK && (slot.key?('family') || slot.key?(:family))
+ slot = _symbolkey2str(slot)
+ configure_core_tk8x(font, 'family', slot.delete('family'))
+ end
+
+ if ((slot.key?('size') || slot.key?(:size)) &&
+ padjust && !slot.key?('pointadjust') && !slot.key?(:pointadjust))
+ tk_call('font', 'configure', font,
+ '-pointadjust', padjust, *hash_kv(slot))
+ else
+ tk_call('font', 'configure', font, *hash_kv(slot))
+ end
+ elsif (slot == 'size' || slot == :size) && padjust != nil
+ tk_call('font', 'configure', font,
+ "-#{slot}", value, '-pointadjust', padjust)
+ elsif JAPANIZED_TK && (slot == 'family' || slot == :family)
+ # coumpund font?
+ begin
+ compound = tk_split_simplelist(tk_call('font', 'configure',
+ font, '-compound'))
+ rescue
+ tk_call('font', 'configure', font, '-family', value)
+ return self
+ end
+ if compound == []
+ tk_call('font', 'configure', font, '-family', value)
+ return self
+ end
+ ltn, knj = compound
+
+ lfnt = tk_call('font', 'create', '-copy', ltn)
+ begin
+ tk_call('font', 'configure', lfnt, '-family', value)
+ latin_replace_core_tk8x(lfnt)
+ rescue RuntimeError => e
+ fail e if $DEBUG
+ ensure
+ tk_call('font', 'delete', lfnt) if lfnt != ''
+ end
+
+ kfnt = tk_call('font', 'create', '-copy', knj)
+ begin
+ tk_call('font', 'configure', kfnt, '-family', value)
+ kanji_replace_core_tk8x(lfnt)
+ rescue RuntimeError => e
+ fail e if $DEBUG
+ ensure
+ tk_call('font', 'delete', kfnt) if kfnt != ''
+ end
+
+ else
+ tk_call('font', 'configure', font, "-#{slot}", value)
+ end
+ self
+ end
+
+ def configinfo_core_tk8x(font, option=nil)
+ if TkComm::GET_CONFIGINFOwoRES_AS_ARRAY
+ if option == 'compound' || option == :compound
+ ""
+ elsif option
+ val = tk_call('font', 'configure', font, "-#{option}")
+ case TkFont::OptionType[option.to_s]
+ when ?n
+ num_or_str(val)
+ when ?b
+ bool(val)
+ else
+ val
+ end
+ else
+ l = tk_split_simplelist(tk_call('font', 'configure', font))
+ r = []
+ while key=l.shift
+ if key == '-compound'
+ l.shift
+ else
+ key = key[1..-1]
+ val = l.shift
+ case TkFont::OptionType[key]
+ when ?n
+ r.push [key, num_or_str(val)]
+ when ?b
+ r.push [key, bool(val)]
+ else
+ r.push [key, val]
+ end
+ end
+ end
+ r
+ end
+ else # ! TkComm::GET_CONFIGINFOwoRES_AS_ARRAY
+ current_configinfo_core_tk8x(font, option)
+ end
+ end
+
+ def current_configinfo_core_tk8x(font, option=nil)
+ if option == 'compound'
+ ""
+ elsif option
+ val = tk_call('font', 'configure', font, "-#{option}")
+ case TkFont::OptionType[option.to_s]
+ when ?n
+ num_or_str(val)
+ when ?b
+ bool(val)
+ else
+ val
+ end
+ else
+ l = tk_split_simplelist(tk_call('font', 'configure', font))
+ h = {}
+ while key=l.shift
+ if key == '-compound'
+ l.shift
+ else
+ key = key[1..-1]
+ val = l.shift
+ case TkFont::OptionType[key]
+ when ?n
+ h[key] = num_or_str(val)
+ when ?b
+ h[key] = bool(val)
+ else
+ h[key] = val
+ end
+ end
+ end
+ h
+ end
+ end
+
+ def delete_core_tk4x
+ TkFont::Tk_FontNameTBL.mutex.synchronize{
+ TkFont::Tk_FontNameTBL.delete(@id)
+ }
+ TkFont::Tk_FontUseTBL.mutex.synchronize{
+ TkFont::Tk_FontUseTBL.delete_if{|key,value| value == self}
+ }
+ end
+
+ def delete_core_tk8x
+ begin
+ tk_call('font', 'delete', @latinfont) if @latinfont
+ rescue
+ end
+ begin
+ tk_call('font', 'delete', @kanjifont) if @kanjifont
+ rescue
+ end
+ begin
+ tk_call('font', 'delete', @compoundfont) if @compoundfont
+ rescue
+ end
+ TkFont::Tk_FontNameTBL.mutex.synchronize{
+ TkFont::Tk_FontNameTBL.delete(@id)
+ }
+ TkFont::Tk_FontUseTBL.mutex.synchronize{
+ TkFont::Tk_FontUseTBL.delete_if{|key,value| value == self}
+ }
+ end
+
+ def latin_replace_core_tk4x(ltn)
+ create_latinfont_tk4x(ltn)
+ @compoundfont[0] = [@latinfont] if JAPANIZED_TK
+ @fontslot['font'] = @latinfont
+ table = nil
+ TkFont::Tk_FontUseTBL.mutex.synchronize{
+ table = TkFont::Tk_FontUseTBL.clone
+ }
+ table.each{|w, fobj|
+ if self == fobj
+ begin
+ if w.include?(';')
+ win, tag, optkey = w.split(';')
+ optkey = 'font' if optkey == nil || optkey == ''
+ winobj = tk_tcl2ruby(win)
+# winobj.tagfont_configure(tag, {'font'=>@latinfont})
+ #if winobj.kind_of? TkText
+ if winobj.kind_of?(TkText) || winobj.kind_of?(Tk::Text)
+ tk_call(win, 'tag', 'configure', tag, "-#{optkey}", @latinfont)
+ #elsif winobj.kind_of? TkCanvas
+ elsif winobj.kind_of?(TkCanvas) || winobj.kind_of?(Tk::Canvas)
+ tk_call(win, 'itemconfigure', tag, "-#{optkey}", @latinfont)
+ #elsif winobj.kind_of? TkMenu
+ elsif winobj.kind_of?(TkMenu) || winobj.kind_of?(Tk::Menu)
+ tk_call(win, 'entryconfigure', tag, "-#{optkey}", @latinfont)
+ else
+ raise RuntimeError, "unknown widget type"
+ end
+ else
+# tk_tcl2ruby(w).font_configure('font'=>@latinfont)
+ tk_call(w, 'configure', '-font', @latinfont)
+ end
+ rescue
+ TkFont::Tk_FontUseTBL.mutex.synchronize{
+ TkFont::Tk_FontUseTBL.delete(w)
+ }
+ end
+ end
+ }
+ self
+ end
+
+ def kanji_replace_core_tk4x(knj)
+ return self unless JAPANIZED_TK
+
+ create_kanjifont_tk4x(knj)
+ @compoundfont[1] = [@kanjifont]
+ @fontslot['kanjifont'] = @kanjifont
+ table = nil
+ TkFont::Tk_FontUseTBL.mutex.synchronize{
+ table = TkFont::Tk_FontUseTBL.clone
+ }
+ table.dup.each{|w, fobj|
+ if self == fobj
+ begin
+ if w.include?(';')
+ win, tag, optkey = w.split(';')
+ optkey = 'kanjifont' unless optkey
+ winobj = tk_tcl2ruby(win)
+# winobj.tagfont_configure(tag, {'kanjifont'=>@kanjifont})
+ #if winobj.kind_of? TkText
+ if winobj.kind_of?(TkText) || winobj.kind_of?(Tk::Text)
+ tk_call(win, 'tag', 'configure', tag, "-#{optkey}", @kanjifont)
+ #elsif winobj.kind_of? TkCanvas
+ elsif winobj.kind_of?(TkCanvas) || winobj.kind_of?(Tk::Canvas)
+ tk_call(win, 'itemconfigure', tag, "-#{optkey}", @kanjifont)
+ #elsif winobj.kind_of? TkMenu
+ elsif winobj.kind_of?(TkMenu) || winobj.kind_of?(Tk::Menu)
+ tk_call(win, 'entryconfigure', tag, "-#{optkey}", @latinfont)
+ else
+ raise RuntimeError, "unknown widget type"
+ end
+ else
+# tk_tcl2ruby(w).font_configure('kanjifont'=>@kanjifont)
+ tk_call(w, 'configure', '-kanjifont', @kanjifont)
+ end
+ rescue
+ Tk_FontUseTBL.mutex.synchronize{
+ TkFont::Tk_FontUseTBL.delete(w)
+ }
+ end
+ end
+ }
+ self
+ end
+
+ def latin_replace_core_tk8x(ltn)
+ ltn = '{}' if ltn == ''
+
+ if JAPANIZED_TK
+ begin
+ tk_call('font', 'delete', '@font_tmp')
+ rescue
+ end
+ begin
+ fnt_bup = tk_call('font', 'create', '@font_tmp', '-copy', @latinfont)
+ rescue
+ #fnt_bup = ''
+ fnt_bup = TkFont::DEFAULT_LATIN_FONT_NAME
+ end
+ end
+
+ begin
+ tk_call('font', 'delete', @latinfont)
+ rescue
+ end
+ create_latinfont(ltn)
+
+ if JAPANIZED_TK
+ keys = self.configinfo
+ tk_call('font', 'delete', @compoundfont)
+ begin
+ tk_call('font', 'create', @compoundfont,
+ '-compound', [@latinfont, @kanjifont], *hash_kv(keys))
+=begin
+ latinkeys = {}
+ begin
+ actual_core(@latinfont).each{|key,val| latinkeys[key] = val}
+ rescue
+ latinkeys = {}
+ end
+ if latinkeys != {}
+ tk_call('font', 'configure', @compoundfont, *hash_kv(latinkeys))
+ end
+=end
+ rescue RuntimeError => e
+ tk_call('font', 'delete', @latinfont)
+ if fnt_bup && fnt_bup != ''
+ tk_call('font', 'create', @latinfont, '-copy', fnt_bup)
+ tk_call('font', 'create', @compoundfont,
+ '-compound', [@latinfont, @kanjifont], *hash_kv(keys))
+ tk_call('font', 'delete', fnt_bup)
+ else
+ fail e
+ end
+ end
+
+ else
+ latinkeys = {}
+ begin
+ actual_core(@latinfont).each{|key,val| latinkeys[key] = val}
+ rescue
+ latinkeys = {}
+ end
+ begin
+ tk_call('font', 'configure', @compoundfont, *hash_kv(latinkeys))
+ rescue
+ # not exist? (deleted?) -> create font
+ tk_call('font', 'create', @compoundfont, *hash_kv(latinkeys))
+ end
+ end
+ self
+ end
+
+ def kanji_replace_core_tk8x(knj)
+ knj = '{}' if knj == ''
+
+ if JAPANIZED_TK
+ begin
+ tk_call('font', 'delete', '@font_tmp')
+ rescue
+ end
+ begin
+ fnt_bup = tk_call('font', 'create', '@font_tmp', '-copy', @kanjifont)
+ rescue
+ #fnt_bup = ''
+ fnt_bup = TkFont::DEFAULT_KANJI_FONT_NAME
+ end
+ end
+
+ begin
+ tk_call('font', 'delete', @kanjifont)
+ rescue
+ end
+ create_kanjifont(knj)
+
+ if JAPANIZED_TK
+ keys = self.configinfo
+ tk_call('font', 'delete', @compoundfont)
+ begin
+ tk_call('font', 'create', @compoundfont,
+ '-compound', [@latinfont, @kanjifont], *hash_kv(keys))
+ rescue RuntimeError => e
+ tk_call('font', 'delete', @kanjifont)
+ if fnt_bup && fnt_bup != ''
+ tk_call('font', 'create', @kanjifont, '-copy', fnt_bup)
+ tk_call('font', 'create', @compoundfont,
+ '-compound', [@latinfont, @kanjifont], *hash_kv(keys))
+ tk_call('font', 'delete', fnt_bup)
+ else
+ fail e
+ end
+ end
+ end
+ self
+ end
+
+ def measure_core_tk4x(font, win, text)
+ 0
+ end
+
+ def measure_core_tk8x(font, win, text)
+ font = '{}' if font == ''
+
+ if win
+ number(tk_call('font', 'measure', font,
+ '-displayof', win, text))
+ else
+ number(tk_call('font', 'measure', font, text))
+ end
+ end
+
+ def metrics_core_tk4x(font, win, option=nil)
+ # dummy
+ if option
+ ""
+ else
+ [['ascent',[]], ['descent',[]], ['linespace',[]], ['fixed',[]]]
+ end
+ end
+
+ def metrics_core_tk8x(font, win, option=nil)
+ font = '{}' if font == ''
+
+ if option
+ if win
+ number(tk_call('font', 'metrics', font,
+ "-displayof", win, "-#{option}"))
+ else
+ number(tk_call('font', 'metrics', font, "-#{option}"))
+ end
+ else
+ l = tk_split_list(if win
+ tk_call('font','metrics',font,"-displayof",win)
+ else
+ tk_call('font','metrics',font)
+ end)
+ r = []
+ while key=l.shift
+ r.push [key[1..-1], l.shift.to_i]
+=begin
+ if key == '-fixed' # boolean value
+ r.push [key[1..-1], bool(l.shift)]
+ else
+ r.push [key[1..-1], l.shift.to_i]
+ end
+=end
+ end
+ r
+ end
+ end
+
+ ###################################
+ # private alias
+ ###################################
+ case (Tk::TK_VERSION)
+ when /^4\..*/
+ alias actual_core actual_core_tk4x
+ alias configure_core configure_core_tk4x
+ alias configinfo_core configinfo_core_tk4x
+ alias current_configinfo_core current_configinfo_core_tk4x
+ alias delete_core delete_core_tk4x
+ alias latin_replace_core latin_replace_core_tk4x
+ alias kanji_replace_core kanji_replace_core_tk4x
+ alias measure_core measure_core_tk4x
+ alias metrics_core metrics_core_tk4x
+
+ when /^8\.[0-9]/
+ alias actual_core actual_core_tk8x
+ alias configure_core configure_core_tk8x
+ alias configinfo_core configinfo_core_tk8x
+ alias current_configinfo_core current_configinfo_core_tk8x
+ alias delete_core delete_core_tk8x
+ alias latin_replace_core latin_replace_core_tk8x
+ alias kanji_replace_core kanji_replace_core_tk8x
+ alias measure_core measure_core_tk8x
+ alias metrics_core metrics_core_tk8x
+
+ else
+ alias actual_core actual_core_tk8x
+ alias configure_core configure_core_tk8x
+ alias configinfo_core configinfo_core_tk8x
+ alias current_configinfo_core current_configinfo_core_tk8x
+ alias delete_core delete_core_tk8x
+ alias latin_replace_core latin_replace_core_tk8x
+ alias kanji_replace_core kanji_replace_core_tk8x
+ alias measure_core measure_core_tk8x
+ alias metrics_core metrics_core_tk8x
+
+ end
+end
+
+class TkFont
+ include TkFont::CoreMethods
+ extend TkFont::CoreMethods
+end
+
+class TkNamedFont < TkFont
+ # for built-in named fonts
+ def TkNamedFont.find(name)
+ name = name.to_s
+ unless (obj = Tk_FontNameTBL[name])
+ obj = self.new(name) if TkFont.is_system_font?(name)
+ end
+ obj
+ end
+
+ def TkNamedFont.new(name, keys=nil)
+ name = name.to_s
+ obj = nil
+ Tk_FontNameTBL.mutex.synchronize{
+ unless (obj = Tk_FontNameTBL[name])
+ (obj = self.allocate).instance_eval{
+ @id = @compoundfont = name.to_s
+ @latinfont = nil
+ @kanjifont = nil
+ @descendant = [self, self] # [latin, kanji] : dummy
+ Tk_FontNameTBL[@id] = self
+ }
+ end
+ }
+ obj.instance_eval{ initialize(name, keys) }
+ obj
+ end
+
+ ###########################
+ private
+ ###########################
+ def initialize(name, keys=nil)
+ @id = @compoundfont = name.to_s
+
+ # if not exist named font, create it.
+ begin
+ if keys
+ tk_call('font', 'configure', @compoundfont, keys)
+ else
+ tk_call('font', 'configure', @compoundfont)
+ end
+ rescue
+ # the named font doesn't exist -> create
+ if keys
+ tk_call('font', 'create', @compoundfont, keys)
+ else
+ tk_call('font', 'create', @compoundfont)
+ end
+ end
+ end
+
+ def create_latinfont(fnt)
+ # ignore
+ end
+ def create_kanjifont(fnt)
+ # ignore
+ end
+ def create_compoundfont(ltn, knj, keys)
+ # ignore
+ end
+
+ ###########################
+ public
+ ###########################
+ def latin_font_id
+ @compoundfont
+ end
+ def kanji_font_id
+ @compoundfont
+ end
+end
+
+#######################################
+# define system font names
+#######################################
+if Tk::TCL_MAJOR_VERSION > 8 ||
+ (Tk::TCL_MAJOR_VERSION == 8 && Tk::TCL_MINOR_VERSION >= 5)
+ # add standard fonts of Tcl/Tk 8.5+
+ TkFont::SYSTEM_FONT_NAMES.add [
+ 'TkDefaultFont', 'TkTextFont', 'TkFixedFont', 'TkMenuFont',
+ 'TkHeadingFont', 'TkCaptionFont', 'TkSmallCaptionFont',
+ 'TkIconFont', 'TkTooltipFont'
+ ]
+end
+
+# platform-specific fonts
+# -- windows
+TkFont::SYSTEM_FONT_NAMES.add [
+ 'ansifixed', 'ansi', 'device', 'oemfixed', 'systemfixed', 'system'
+]
+
+# -- macintosh, macosx
+TkFont::SYSTEM_FONT_NAMES.add ['system', 'application']
+
+if Tk::TCL_MAJOR_VERSION > 8 ||
+ (Tk::TCL_MAJOR_VERSION == 8 && Tk::TCL_MINOR_VERSION >= 5)
+ TkFont::SYSTEM_FONT_NAMES.add ['menu']
+end
+
+# -- macosx (Aqua theme)
+if Tk::TCL_MAJOR_VERSION > 8 ||
+ (Tk::TCL_MAJOR_VERSION == 8 && Tk::TCL_MINOR_VERSION >= 5)
+ TkFont::SYSTEM_FONT_NAMES.add [
+ 'systemSystemFont', 'systemEmphasizedSystemFont',
+ 'systemSmallSystemFont', 'systemSmallEmphasizedSystemFont',
+ 'systemApplicationFont', 'systemLabelFont', 'systemViewsFont',
+ 'systemMenuTitleFont', 'systemMenuItemFont', 'systemMenuItemMarkFont',
+ 'systemMenuItemCmdKeyFont', 'systemWindowTitleFont',
+ 'systemPushButtonFont', 'systemUtilityWindowTitleFont',
+ 'systemAlertHeaderFont', 'systemToolbarFont', 'systemMiniSystemFont',
+ 'systemDetailSystemFont', 'systemDetailEmphasizedSystemFont'
+ ]
+end
+
+#######################################
+# autoload
+#######################################
+class TkFont
+ autoload :Chooser, 'tk/fontchooser'
+end
diff --git a/jni/ruby/ext/tk/lib/tk/fontchooser.rb b/jni/ruby/ext/tk/lib/tk/fontchooser.rb
new file mode 100644
index 0000000..22d70f9
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tk/fontchooser.rb
@@ -0,0 +1,180 @@
+#
+# tk/fontchooser.rb -- "tk fontchooser" support (Tcl/Tk8.6 or later)
+#
+require 'tk'
+require 'tk/font'
+
+module TkFont::Chooser
+ extend TkCore
+end
+
+module Tk
+ Fontchooser = TkFont::Chooser
+end
+
+class << TkFont::Chooser
+ def method_missing(id, *args)
+ name = id.id2name
+ case args.length
+ when 1
+ if name[-1] == ?=
+ configure name[0..-2], args[0]
+ args[0]
+ else
+ configure name, args[0]
+ self
+ end
+ when 0
+ begin
+ cget(name)
+ rescue
+ super(id, *args)
+ end
+ else
+ super(id, *args)
+ end
+ end
+
+ def __configinfo_value(key, val)
+ case key
+ when 'parent'
+ window(val)
+ when 'title'
+ val
+ when 'font'
+ if (lst = tk_split_simplelist(val)).size == 1
+ lst[0]
+ else
+ lst.map{|elem| num_or_str(elem)}
+ end
+ when 'command'
+ tk_tcl2ruby(val)
+ when 'visible'
+ bool(val)
+ else # unkown
+ val
+ end
+ end
+ private :__configinfo_value
+
+ def configinfo(option=nil)
+ if !option && TkComm::GET_CONFIGINFOwoRES_AS_ARRAY
+ lst = tk_split_simplelist(tk_call('tk', 'fontchooser', 'configure'))
+ ret = []
+ TkComm.slice_ary(lst, 2){|k, v|
+ k = k[1..-1]
+ ret << [k, __configinfo_value(k, v)]
+ }
+ ret
+ else
+ current_configinfo(option)
+ end
+ end
+
+ def current_configinfo(option=nil)
+ if option
+ opt = option.to_s
+ fail ArgumentError, "Invalid option `#{option.inspect}'" if opt.empty?
+ __configinfo_value(option.to_s, tk_call('tk','fontchooser',
+ 'configure',"-#{opt}"))
+ else
+ lst = tk_split_simplelist(tk_call('tk', 'fontchooser', 'configure'))
+ ret = {}
+ TkComm.slice_ary(lst, 2){|k, v|
+ k = k[1..-1]
+ ret[k] = __configinfo_value(k, v)
+ }
+ ret
+ end
+ end
+
+ def configure(option, value=None)
+ if option.kind_of? Hash
+ tk_call('tk', 'fontchooser', 'configure',
+ *hash_kv(_symbolkey2str(option)))
+ else
+ opt = option.to_s
+ fail ArgumentError, "Invalid option `#{option.inspect}'" if opt.empty?
+ tk_call('tk', 'fontchooser', 'configure', "-#{opt}", value)
+ end
+ self
+ end
+
+ def configure_cmd(slot, value)
+ configure(slot, install_cmd(value))
+ end
+
+ def command(cmd=nil, &b)
+ if cmd
+ configure_cmd('command', cmd)
+ elsif b
+ configure_cmd('command', Proc.new(&b))
+ else
+ cget('command')
+ end
+ end
+
+ def cget(slot)
+ configinfo slot
+ end
+
+ def [](slot)
+ cget slot
+ end
+
+ def []=(slot, val)
+ configure slot, val
+ val
+ end
+
+ def show
+ tk_call('tk', 'fontchooser', 'show')
+ self
+ end
+
+ def hide
+ tk_call('tk', 'fontchooser', 'hide')
+ self
+ end
+
+ def toggle
+ cget(:visible) ? hide: show
+ self
+ end
+
+ def set_for(target, title="Font")
+ if target.kind_of? TkFont
+ configs = {
+ :font=>target.actual_hash,
+ :command=>proc{|fnt, *args|
+ target.configure(TkFont.actual_hash(fnt))
+ }
+ }
+ elsif target.kind_of? Hash
+ # key=>value list or OptionObj
+ fnt = target[:font] rescue ''
+ fnt = fnt.actual_hash if fnt.kind_of?(TkFont)
+ configs = {
+ :font => fnt,
+ :command=>proc{|fnt, *args|
+ target[:font] = TkFont.actual_hash(fnt)
+ }
+ }
+ else
+ configs = {
+ :font=>target.cget_tkstring(:font),
+ :command=>proc{|fnt, *args|
+ target.font = TkFont.actual_hash_displayof(fnt, target)
+ }
+ }
+ end
+
+ configs[:title] = title if title
+ configure(configs)
+ target
+ end
+
+ def unset
+ configure(:command, nil)
+ end
+end
diff --git a/jni/ruby/ext/tk/lib/tk/frame.rb b/jni/ruby/ext/tk/lib/tk/frame.rb
new file mode 100644
index 0000000..5118939
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tk/frame.rb
@@ -0,0 +1,132 @@
+#
+# tk/frame.rb : treat frame widget
+#
+require 'tk'
+
+class Tk::Frame<TkWindow
+ TkCommandNames = ['frame'.freeze].freeze
+ WidgetClassName = 'Frame'.freeze
+ WidgetClassNames[WidgetClassName] ||= self
+
+################# old version
+# def initialize(parent=nil, keys=nil)
+# if keys.kind_of? Hash
+# keys = keys.dup
+# @classname = keys.delete('classname') if keys.key?('classname')
+# @colormap = keys.delete('colormap') if keys.key?('colormap')
+# @container = keys.delete('container') if keys.key?('container')
+# @visual = keys.delete('visual') if keys.key?('visual')
+# end
+# super(parent, keys)
+# end
+#
+# def create_self
+# s = []
+# s << "-class" << @classname if @classname
+# s << "-colormap" << @colormap if @colormap
+# s << "-container" << @container if @container
+# s << "-visual" << @visual if @visual
+# tk_call 'frame', @path, *s
+# end
+#################
+
+ def __boolval_optkeys
+ super() << 'container'
+ end
+ private :__boolval_optkeys
+
+ def initialize(parent=nil, keys=nil)
+ my_class_name = nil
+ if self.class < WidgetClassNames[self.class::WidgetClassName]
+ my_class_name = self.class.name
+ my_class_name = nil if my_class_name == ''
+ end
+ if parent.kind_of? Hash
+ keys = _symbolkey2str(parent)
+ else
+ if keys
+ keys = _symbolkey2str(keys)
+ keys['parent'] = parent
+ else
+ keys = {'parent'=>parent}
+ end
+ end
+ if keys.key?('classname')
+ keys['class'] = keys.delete('classname')
+ end
+ @classname = keys['class']
+ @colormap = keys['colormap']
+ @container = keys['container']
+ @visual = keys['visual']
+ if !@classname && my_class_name
+ keys['class'] = @classname = my_class_name
+ end
+ if @classname.kind_of? TkBindTag
+ @db_class = @classname
+ @classname = @classname.id
+ elsif @classname
+ @db_class = TkDatabaseClass.new(@classname)
+ else
+ @db_class = self.class
+ @classname = @db_class::WidgetClassName
+ end
+ super(keys)
+ end
+
+ #def create_self(keys)
+ # if keys and keys != None
+ # tk_call_without_enc('frame', @path, *hash_kv(keys))
+ # else
+ # tk_call_without_enc( 'frame', @path)
+ # end
+ #end
+ #private :create_self
+
+ def database_classname
+ @classname
+ end
+
+ def self.database_class
+ if self == WidgetClassNames[WidgetClassName] || self.name == ''
+ self
+ else
+ TkDatabaseClass.new(self.name)
+ end
+ end
+ def self.database_classname
+ self.database_class.name
+ end
+
+ def self.bind(*args, &b)
+ if self == WidgetClassNames[WidgetClassName] || self.name == ''
+ super(*args, &b)
+ else
+ TkDatabaseClass.new(self.name).bind(*args, &b)
+ end
+ end
+ def self.bind_append(*args, &b)
+ if self == WidgetClassNames[WidgetClassName] || self.name == ''
+ super(*args, &b)
+ else
+ TkDatabaseClass.new(self.name).bind_append(*args, &b)
+ end
+ end
+ def self.bind_remove(*args)
+ if self == WidgetClassNames[WidgetClassName] || self.name == ''
+ super(*args)
+ else
+ TkDatabaseClass.new(self.name).bind_remove(*args)
+ end
+ end
+ def self.bindinfo(*args)
+ if self == WidgetClassNames[WidgetClassName] || self.name == ''
+ super(*args)
+ else
+ TkDatabaseClass.new(self.name).bindinfo(*args)
+ end
+ end
+end
+
+#TkFrame = Tk::Frame unless Object.const_defined? :TkFrame
+#Tk.__set_toplevel_aliases__(:Tk, Tk::Frame, :TkFrame)
+Tk.__set_loaded_toplevel_aliases__('tk/frame.rb', :Tk, Tk::Frame, :TkFrame)
diff --git a/jni/ruby/ext/tk/lib/tk/grid.rb b/jni/ruby/ext/tk/lib/tk/grid.rb
new file mode 100644
index 0000000..e1e07c4
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tk/grid.rb
@@ -0,0 +1,279 @@
+#
+# tk/grid.rb : control grid geometry manager
+#
+require 'tk'
+
+module TkGrid
+ include Tk
+ extend Tk
+
+ TkCommandNames = ['grid'.freeze].freeze
+
+ def anchor(master, anchor=None)
+ # master = master.epath if master.kind_of?(TkObject)
+ master = _epath(master)
+ tk_call_without_enc('grid', 'anchor', master, anchor)
+ end
+
+ def bbox(master, *args)
+ # master = master.epath if master.kind_of?(TkObject)
+ master = _epath(master)
+ args.unshift(master)
+ list(tk_call_without_enc('grid', 'bbox', *args))
+ end
+
+=begin
+ def configure(win, *args)
+ if args[-1].kind_of?(Hash)
+ opts = args.pop
+ else
+ opts = {}
+ end
+ params = []
+ params.push(_epath(win))
+ args.each{|win|
+ case win
+ when '-', 'x', '^' # RELATIVE PLACEMENT
+ params.push(win)
+ else
+ params.push(_epath(win))
+ end
+ }
+ opts.each{|k, v|
+ params.push("-#{k}")
+ params.push((v.kind_of?(TkObject))? v.epath: v)
+ }
+ if Tk::TCL_MAJOR_VERSION < 8 ||
+ (Tk::TCL_MAJOR_VERSION == 8 && Tk::TCL_MINOR_VERSION <= 3)
+ if params[0] == '-' || params[0] == 'x' || params[0] == '^'
+ tk_call_without_enc('grid', *params)
+ else
+ tk_call_without_enc('grid', 'configure', *params)
+ end
+ else
+ tk_call_without_enc('grid', 'configure', *params)
+ end
+ end
+=end
+ def configure(*args)
+ if args[-1].kind_of?(Hash)
+ opts = args.pop
+ else
+ opts = {}
+ end
+ fail ArgumentError, 'no widget is given' if args.empty?
+ params = []
+ args.flatten(1).each{|win|
+ case win
+ when '-', ?- # RELATIVE PLACEMENT (increase columnspan)
+ params.push('-')
+ when /^-+$/ # RELATIVE PLACEMENT (increase columnspan)
+ params.concat(win.to_s.split(//))
+ when '^', ?^ # RELATIVE PLACEMENT (increase rowspan)
+ params.push('^')
+ when /^\^+$/ # RELATIVE PLACEMENT (increase rowspan)
+ params.concat(win.to_s.split(//))
+ when 'x', :x, ?x, nil, '' # RELATIVE PLACEMENT (empty column)
+ params.push('x')
+ when /^x+$/ # RELATIVE PLACEMENT (empty column)
+ params.concat(win.to_s.split(//))
+ else
+ params.push(_epath(win))
+ end
+ }
+ opts.each{|k, v|
+ params.push("-#{k}")
+ params.push(_epath(v)) # have to use 'epath' (hash_kv() is unavailable)
+ }
+ if Tk::TCL_MAJOR_VERSION < 8 ||
+ (Tk::TCL_MAJOR_VERSION == 8 && Tk::TCL_MINOR_VERSION <= 3)
+ if params[0] == '-' || params[0] == 'x' || params[0] == '^'
+ tk_call_without_enc('grid', *params)
+ else
+ tk_call_without_enc('grid', 'configure', *params)
+ end
+ else
+ tk_call_without_enc('grid', 'configure', *params)
+ end
+ end
+ alias grid configure
+
+ def columnconfigure(master, index, args)
+ # master = master.epath if master.kind_of?(TkObject)
+ master = _epath(master)
+ tk_call_without_enc("grid", 'columnconfigure',
+ master, index, *hash_kv(args))
+ end
+
+ def rowconfigure(master, index, args)
+ # master = master.epath if master.kind_of?(TkObject)
+ master = _epath(master)
+ tk_call_without_enc("grid", 'rowconfigure', master, index, *hash_kv(args))
+ end
+
+ def columnconfiginfo(master, index, slot=nil)
+ # master = master.epath if master.kind_of?(TkObject)
+ master = _epath(master)
+ if slot
+ case slot
+ when 'uniform', :uniform
+ tk_call_without_enc('grid', 'columnconfigure',
+ master, index, "-#{slot}")
+ else
+ num_or_str(tk_call_without_enc('grid', 'columnconfigure',
+ master, index, "-#{slot}"))
+ end
+ else
+ #ilist = list(tk_call_without_enc('grid','columnconfigure',master,index))
+ ilist = simplelist(tk_call_without_enc('grid', 'columnconfigure',
+ master, index))
+ info = {}
+ while key = ilist.shift
+ case key
+ when 'uniform'
+ info[key[1..-1]] = ilist.shift
+ else
+ info[key[1..-1]] = tk_tcl2ruby(ilist.shift)
+ end
+ end
+ info
+ end
+ end
+
+ def rowconfiginfo(master, index, slot=nil)
+ # master = master.epath if master.kind_of?(TkObject)
+ master = _epath(master)
+ if slot
+ case slot
+ when 'uniform', :uniform
+ tk_call_without_enc('grid', 'rowconfigure',
+ master, index, "-#{slot}")
+ else
+ num_or_str(tk_call_without_enc('grid', 'rowconfigure',
+ master, index, "-#{slot}"))
+ end
+ else
+ #ilist = list(tk_call_without_enc('grid', 'rowconfigure', master, index))
+ ilist = simplelist(tk_call_without_enc('grid', 'rowconfigure',
+ master, index))
+ info = {}
+ while key = ilist.shift
+ case key
+ when 'uniform'
+ info[key[1..-1]] = ilist.shift
+ else
+ info[key[1..-1]] = tk_tcl2ruby(ilist.shift)
+ end
+ end
+ info
+ end
+ end
+
+ def column(master, index, keys=nil)
+ if keys.kind_of?(Hash)
+ columnconfigure(master, index, keys)
+ else
+ columnconfiginfo(master, index, keys)
+ end
+ end
+
+ def row(master, index, keys=nil)
+ if keys.kind_of?(Hash)
+ rowconfigure(master, index, keys)
+ else
+ rowconfiginfo(master, index, keys)
+ end
+ end
+
+ def add(widget, *args)
+ configure(widget, *args)
+ end
+
+ def forget(*args)
+ return '' if args.size == 0
+ wins = args.collect{|win|
+ # (win.kind_of?(TkObject))? win.epath: win
+ _epath(win)
+ }
+ tk_call_without_enc('grid', 'forget', *wins)
+ end
+
+ def info(slave)
+ # slave = slave.epath if slave.kind_of?(TkObject)
+ slave = _epath(slave)
+ #ilist = list(tk_call_without_enc('grid', 'info', slave))
+ ilist = simplelist(tk_call_without_enc('grid', 'info', slave))
+ info = {}
+ while key = ilist.shift
+ #info[key[1..-1]] = ilist.shift
+ info[key[1..-1]] = tk_tcl2ruby(ilist.shift)
+ end
+ return info
+ end
+
+ def location(master, x, y)
+ # master = master.epath if master.kind_of?(TkObject)
+ master = _epath(master)
+ list(tk_call_without_enc('grid', 'location', master, x, y))
+ end
+
+ def propagate(master, mode=None)
+ # master = master.epath if master.kind_of?(TkObject)
+ master = _epath(master)
+ if mode == None
+ bool(tk_call_without_enc('grid', 'propagate', master))
+ else
+ tk_call_without_enc('grid', 'propagate', master, mode)
+ end
+ end
+
+ def remove(*args)
+ return '' if args.size == 0
+ wins = args.collect{|win|
+ # (win.kind_of?(TkObject))? win.epath: win
+ _epath(win)
+ }
+ tk_call_without_enc('grid', 'remove', *wins)
+ end
+
+ def size(master)
+ # master = master.epath if master.kind_of?(TkObject)
+ master = _epath(master)
+ list(tk_call_without_enc('grid', 'size', master))
+ end
+
+ def slaves(master, keys=nil)
+ # master = master.epath if master.kind_of?(TkObject)
+ master = _epath(master)
+ list(tk_call_without_enc('grid', 'slaves', master, *hash_kv(args)))
+ end
+
+ module_function :anchor, :bbox, :add, :forget, :propagate, :info
+ module_function :remove, :size, :slaves, :location
+ module_function :grid, :configure, :columnconfigure, :rowconfigure
+ module_function :column, :row, :columnconfiginfo, :rowconfiginfo
+end
+=begin
+def TkGrid(win, *args)
+ if args[-1].kind_of?(Hash)
+ opts = args.pop
+ else
+ opts = {}
+ end
+ params = []
+ params.push((win.kind_of?(TkObject))? win.epath: win)
+ args.each{|win|
+ case win
+ when '-', 'x', '^' # RELATIVE PLACEMENT
+ params.push(win)
+ else
+ params.push((win.kind_of?(TkObject))? win.epath: win)
+ end
+ }
+ opts.each{|k, v|
+ params.push("-#{k}")
+ params.push((v.kind_of?(TkObject))? v.epath: v)
+ }
+ tk_call_without_enc("grid", *params)
+end
+=end
diff --git a/jni/ruby/ext/tk/lib/tk/image.rb b/jni/ruby/ext/tk/lib/tk/image.rb
new file mode 100644
index 0000000..9723839
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tk/image.rb
@@ -0,0 +1,395 @@
+#
+# tk/image.rb : treat Tk image objects
+#
+
+require 'tk'
+
+class TkImage<TkObject
+ include Tk
+
+ TkCommandNames = ['image'.freeze].freeze
+
+ Tk_IMGTBL = TkCore::INTERP.create_table
+
+ (Tk_Image_ID = ['i'.freeze, TkUtil.untrust('00000')]).instance_eval{
+ @mutex = Mutex.new
+ def mutex; @mutex; end
+ freeze
+ }
+
+ TkCore::INTERP.init_ip_env{
+ Tk_IMGTBL.mutex.synchronize{ Tk_IMGTBL.clear }
+ }
+
+ def self.new(keys=nil)
+ if keys.kind_of?(Hash)
+ name = nil
+ if keys.key?(:imagename)
+ name = keys[:imagename]
+ elsif keys.key?('imagename')
+ name = keys['imagename']
+ end
+ if name
+ if name.kind_of?(TkImage)
+ obj = name
+ else
+ name = _get_eval_string(name)
+ obj = nil
+ Tk_IMGTBL.mutex.synchronize{
+ obj = Tk_IMGTBL[name]
+ }
+ end
+ if obj
+ if !(keys[:without_creating] || keys['without_creating'])
+ keys = _symbolkey2str(keys)
+ keys.delete('imagename')
+ keys.delete('without_creating')
+ obj.instance_eval{
+ tk_call_without_enc('image', 'create',
+ @type, @path, *hash_kv(keys, true))
+ }
+ end
+ return obj
+ end
+ end
+ end
+ (obj = self.allocate).instance_eval{
+ Tk_IMGTBL.mutex.synchronize{
+ initialize(keys)
+ Tk_IMGTBL[@path] = self
+ }
+ }
+ obj
+ end
+
+ def initialize(keys=nil)
+ @path = nil
+ without_creating = false
+ if keys.kind_of?(Hash)
+ keys = _symbolkey2str(keys)
+ @path = keys.delete('imagename')
+ without_creating = keys.delete('without_creating')
+ end
+ unless @path
+ Tk_Image_ID.mutex.synchronize{
+ @path = Tk_Image_ID.join(TkCore::INTERP._ip_id_)
+ Tk_Image_ID[1].succ!
+ }
+ end
+ unless without_creating
+ tk_call_without_enc('image', 'create',
+ @type, @path, *hash_kv(keys, true))
+ end
+ end
+
+ def delete
+ Tk_IMGTBL.mutex.synchronize{
+ Tk_IMGTBL.delete(@id) if @id
+ }
+ tk_call_without_enc('image', 'delete', @path)
+ self
+ end
+ def height
+ number(tk_call_without_enc('image', 'height', @path))
+ end
+ def inuse
+ bool(tk_call_without_enc('image', 'inuse', @path))
+ end
+ def itemtype
+ tk_call_without_enc('image', 'type', @path)
+ end
+ def width
+ number(tk_call_without_enc('image', 'width', @path))
+ end
+
+ def TkImage.names
+ Tk_IMGTBL.mutex.synchronize{
+ Tk.tk_call_without_enc('image', 'names').split.collect!{|id|
+ (Tk_IMGTBL[id])? Tk_IMGTBL[id] : id
+ }
+ }
+ end
+
+ def TkImage.types
+ Tk.tk_call_without_enc('image', 'types').split
+ end
+end
+
+class TkBitmapImage<TkImage
+ def __strval_optkeys
+ super() + ['maskdata', 'maskfile']
+ end
+ private :__strval_optkeys
+
+ def initialize(*args)
+ @type = 'bitmap'
+ super(*args)
+ end
+end
+
+# A photo is an image whose pixels can display any color or be transparent.
+# At present, only GIF and PPM/PGM formats are supported, but an interface
+# exists to allow additional image file formats to be added easily.
+#
+# This class documentation is a copy from the original Tcl/Tk at
+# http://www.tcl.tk/man/tcl8.5/TkCmd/photo.htm with some rewritten parts.
+class TkPhotoImage<TkImage
+ NullArgOptionKeys = [ "shrink", "grayscale" ]
+
+ def _photo_hash_kv(keys)
+ keys = _symbolkey2str(keys)
+ NullArgOptionKeys.collect{|opt|
+ if keys[opt]
+ keys[opt] = None
+ else
+ keys.delete(opt)
+ end
+ }
+ keys.collect{|k,v|
+ ['-' << k, v]
+ }.flatten
+ end
+ private :_photo_hash_kv
+
+ # Create a new image with the given options.
+ # == Examples of use :
+ # === Create an empty image of 300x200 pixels
+ #
+ # image = TkPhotoImage.new(:height => 200, :width => 300)
+ #
+ # === Create an image from a file
+ #
+ # image = TkPhotoImage.new(:file: => 'my_image.gif')
+ #
+ # == Options
+ # Photos support the following options:
+ # * :data
+ # Specifies the contents of the image as a string.
+ # * :format
+ # Specifies the name of the file format for the data.
+ # * :file
+ # Gives the name of a file that is to be read to supply data for the image.
+ # * :gamma
+ # Specifies that the colors allocated for displaying this image in a window
+ # should be corrected for a non-linear display with the specified gamma
+ # exponent value.
+ # * height
+ # Specifies the height of the image, in pixels. This option is useful
+ # primarily in situations where the user wishes to build up the contents of
+ # the image piece by piece. A value of zero (the default) allows the image
+ # to expand or shrink vertically to fit the data stored in it.
+ # * palette
+ # Specifies the resolution of the color cube to be allocated for displaying
+ # this image.
+ # * width
+ # Specifies the width of the image, in pixels. This option is useful
+ # primarily in situations where the user wishes to build up the contents of
+ # the image piece by piece. A value of zero (the default) allows the image
+ # to expand or shrink horizontally to fit the data stored in it.
+ def initialize(*args)
+ @type = 'photo'
+ super(*args)
+ end
+
+ # Blank the image; that is, set the entire image to have no data, so it will
+ # be displayed as transparent, and the background of whatever window it is
+ # displayed in will show through.
+ def blank
+ tk_send_without_enc('blank')
+ self
+ end
+
+ def cget_strict(option)
+ case option.to_s
+ when 'data', 'file'
+ tk_send 'cget', '-' << option.to_s
+ else
+ tk_tcl2ruby(tk_send('cget', '-' << option.to_s))
+ end
+ end
+
+ # Returns the current value of the configuration option given by option.
+ # Example, display name of the file from which <tt>image</tt> was created:
+ # puts image.cget :file
+ def cget(option)
+ unless TkConfigMethod.__IGNORE_UNKNOWN_CONFIGURE_OPTION__
+ cget_strict(option)
+ else
+ begin
+ cget_strict(option)
+ rescue => e
+ if current_configinfo.has_key?(option.to_s)
+ # error on known option
+ fail e
+ else
+ # unknown option
+ nil
+ end
+ end
+ end
+ end
+
+ # Copies a region from the image called source to the image called
+ # destination, possibly with pixel zooming and/or subsampling. If no options
+ # are specified, this method copies the whole of source into destination,
+ # starting at coordinates (0,0) in destination. The following options may be
+ # specified:
+ #
+ # * :from [x1, y1, x2, y2]
+ # Specifies a rectangular sub-region of the source image to be copied.
+ # (x1,y1) and (x2,y2) specify diagonally opposite corners of the rectangle.
+ # If x2 and y2 are not specified, the default value is the bottom-right
+ # corner of the source image. The pixels copied will include the left and
+ # top edges of the specified rectangle but not the bottom or right edges.
+ # If the :from option is not given, the default is the whole source image.
+ # * :to [x1, y1, x2, y2]
+ # Specifies a rectangular sub-region of the destination image to be
+ # affected. (x1,y1) and (x2,y2) specify diagonally opposite corners of the
+ # rectangle. If x2 and y2 are not specified, the default value is (x1,y1)
+ # plus the size of the source region (after subsampling and zooming, if
+ # specified). If x2 and y2 are specified, the source region will be
+ # replicated if necessary to fill the destination region in a tiled fashion.
+ # * :shrink
+ # Specifies that the size of the destination image should be reduced, if
+ # necessary, so that the region being copied into is at the bottom-right
+ # corner of the image. This option will not affect the width or height of
+ # the image if the user has specified a non-zero value for the :width or
+ # :height configuration option, respectively.
+ # * :zoom [x, y]
+ # Specifies that the source region should be magnified by a factor of x
+ # in the X direction and y in the Y direction. If y is not given, the
+ # default value is the same as x. With this option, each pixel in the
+ # source image will be expanded into a block of x x y pixels in the
+ # destination image, all the same color. x and y must be greater than 0.
+ # * :subsample [x, y]
+ # Specifies that the source image should be reduced in size by using only
+ # every xth pixel in the X direction and yth pixel in the Y direction.
+ # Negative values will cause the image to be flipped about the Y or X axes,
+ # respectively. If y is not given, the default value is the same as x.
+ # * :compositingrule rule
+ # Specifies how transparent pixels in the source image are combined with
+ # the destination image. When a compositing rule of <tt>overlay</tt> is set,
+ # the old contents of the destination image are visible, as if the source
+ # image were printed on a piece of transparent film and placed over the
+ # top of the destination. When a compositing rule of <tt>set</tt> is set,
+ # the old contents of the destination image are discarded and the source
+ # image is used as-is. The default compositing rule is <tt>overlay</tt>.
+ def copy(src, *opts)
+ if opts.size == 0
+ tk_send('copy', src)
+ elsif opts.size == 1 && opts[0].kind_of?(Hash)
+ tk_send('copy', src, *_photo_hash_kv(opts[0]))
+ else
+ # for backward compatibility
+ args = opts.collect{|term|
+ if term.kind_of?(String) && term.include?(?\s)
+ term.split
+ else
+ term
+ end
+ }.flatten
+ tk_send('copy', src, *args)
+ end
+ self
+ end
+
+ # Returns image data in the form of a string. The following options may be
+ # specified:
+ # * :background color
+ # If the color is specified, the data will not contain any transparency
+ # information. In all transparent pixels the color will be replaced by the
+ # specified color.
+ # * :format format-name
+ # Specifies the name of the image file format handler to be used.
+ # Specifically, this subcommand searches for the first handler whose name
+ # matches an initial substring of format-name and which has the capability
+ # to read this image data. If this option is not given, this subcommand
+ # uses the first handler that has the capability to read the image data.
+ # * :from [x1, y1, x2, y2]
+ # Specifies a rectangular region of imageName to be returned. If only x1
+ # and y1 are specified, the region extends from (x1,y1) to the bottom-right
+ # corner of imageName. If all four coordinates are given, they specify
+ # diagonally opposite corners of the rectangular region, including x1,y1
+ # and excluding x2,y2. The default, if this option is not given, is the
+ # whole image.
+ # * :grayscale
+ # If this options is specified, the data will not contain color information.
+ # All pixel data will be transformed into grayscale.
+ def data(keys={})
+ tk_split_list(tk_send('data', *_photo_hash_kv(keys)))
+ end
+
+ # Returns the color of the pixel at coordinates (x,y) in the image as a list
+ # of three integers between 0 and 255, representing the red, green and blue
+ # components respectively.
+ def get(x, y)
+ tk_send('get', x, y).split.collect{|n| n.to_i}
+ end
+
+ def put(data, *opts)
+ if opts.empty?
+ tk_send('put', data)
+ elsif opts.size == 1 && opts[0].kind_of?(Hash)
+ tk_send('put', data, *_photo_hash_kv(opts[0]))
+ else
+ # for backward compatibility
+ tk_send('put', data, '-to', *opts)
+ end
+ self
+ end
+
+ def read(file, *opts)
+ if opts.size == 0
+ tk_send('read', file)
+ elsif opts.size == 1 && opts[0].kind_of?(Hash)
+ tk_send('read', file, *_photo_hash_kv(opts[0]))
+ else
+ # for backward compatibility
+ args = opts.collect{|term|
+ if term.kind_of?(String) && term.include?(?\s)
+ term.split
+ else
+ term
+ end
+ }.flatten
+ tk_send('read', file, *args)
+ end
+ self
+ end
+
+ def redither
+ tk_send 'redither'
+ self
+ end
+
+ # Returns a boolean indicating if the pixel at (x,y) is transparent.
+ def get_transparency(x, y)
+ bool(tk_send('transparency', 'get', x, y))
+ end
+
+ # Makes the pixel at (x,y) transparent if <tt>state</tt> is true, and makes
+ # that pixel opaque otherwise.
+ def set_transparency(x, y, state)
+ tk_send('transparency', 'set', x, y, state)
+ self
+ end
+
+ def write(file, *opts)
+ if opts.size == 0
+ tk_send('write', file)
+ elsif opts.size == 1 && opts[0].kind_of?(Hash)
+ tk_send('write', file, *_photo_hash_kv(opts[0]))
+ else
+ # for backward compatibility
+ args = opts.collect{|term|
+ if term.kind_of?(String) && term.include?(?\s)
+ term.split
+ else
+ term
+ end
+ }.flatten
+ tk_send('write', file, *args)
+ end
+ self
+ end
+end
diff --git a/jni/ruby/ext/tk/lib/tk/itemconfig.rb b/jni/ruby/ext/tk/lib/tk/itemconfig.rb
new file mode 100644
index 0000000..1439604
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tk/itemconfig.rb
@@ -0,0 +1,1222 @@
+#
+# tk/itemconfig.rb : control item/tag configuration of widget
+#
+require 'tk'
+require 'tkutil'
+require 'tk/itemfont.rb'
+
+module TkItemConfigOptkeys
+ include TkUtil
+
+ def __item_optkey_aliases(id)
+ {}
+ end
+ private :__item_optkey_aliases
+
+ def __item_numval_optkeys(id)
+ []
+ end
+ private :__item_numval_optkeys
+
+ def __item_numstrval_optkeys(id)
+ []
+ end
+ private :__item_numstrval_optkeys
+
+ def __item_boolval_optkeys(id)
+ ['exportselection', 'jump', 'setgrid', 'takefocus']
+ end
+ private :__item_boolval_optkeys
+
+ def __item_strval_optkeys(id)
+ # maybe need to override
+ [
+ 'text', 'label', 'show', 'data', 'file', 'maskdata', 'maskfile',
+ 'activebackground', 'activeforeground', 'background',
+ 'disabledforeground', 'disabledbackground', 'foreground',
+ 'highlightbackground', 'highlightcolor', 'insertbackground',
+ 'selectbackground', 'selectforeground', 'troughcolor'
+ ]
+ end
+ private :__item_strval_optkeys
+
+ def __item_listval_optkeys(id)
+ []
+ end
+ private :__item_listval_optkeys
+
+ def __item_numlistval_optkeys(id)
+ # maybe need to override
+ ['dash', 'activedash', 'disableddash']
+ end
+ private :__item_numlistval_optkeys
+
+ def __item_tkvariable_optkeys(id)
+ ['variable', 'textvariable']
+ end
+ private :__item_tkvariable_optkeys
+
+ def __item_val2ruby_optkeys(id) # { key=>method, ... }
+ # The method is used to convert a opt-value to a ruby's object.
+ # When get the value of the option "key", "method.call(id, val)" is called.
+ {}
+ end
+ private :__item_val2ruby_optkeys
+
+ def __item_ruby2val_optkeys(id) # { key=>method, ... }
+ # The method is used to convert a ruby's object to a opt-value.
+ # When set the value of the option "key", "method.call(id, val)" is called.
+ # That is, "-#{key} #{method.call(id, value)}".
+ {}
+ end
+ private :__item_ruby2val_optkeys
+
+ def __item_methodcall_optkeys(id) # { key=>method, ... }
+ # Use the method for both of get and set.
+ # Usually, the 'key' will not be a widget option.
+ #
+ # maybe need to override
+ # {'coords'=>'coords'}
+ {}
+ end
+ private :__item_methodcall_optkeys
+
+ ################################################
+
+ def __item_keyonly_optkeys(id) # { def_key=>(undef_key|nil), ... }
+ # maybe need to override
+ {}
+ end
+ private :__item_keyonly_optkeys
+
+
+ def __conv_item_keyonly_opts(id, keys)
+ return keys unless keys.kind_of?(Hash)
+ keyonly = __item_keyonly_optkeys(id)
+ keys2 = {}
+ keys.each{|k, v|
+ optkey = keyonly.find{|kk,vv| kk.to_s == k.to_s}
+ if optkey
+ defkey, undefkey = optkey
+ if v
+ keys2[defkey.to_s] = None
+ else
+ keys2[undefkey.to_s] = None
+ end
+ else
+ keys2[k.to_s] = v
+ end
+ }
+ keys2
+ end
+
+ def itemconfig_hash_kv(id, keys, enc_mode = nil, conf = nil)
+ hash_kv(__conv_item_keyonly_opts(id, keys), enc_mode, conf)
+ end
+end
+
+module TkItemConfigMethod
+ include TkUtil
+ include TkTreatItemFont
+ include TkItemConfigOptkeys
+
+ def TkItemConfigMethod.__IGNORE_UNKNOWN_CONFIGURE_OPTION__
+ @mode || false
+ end
+ def TkItemConfigMethod.__set_IGNORE_UNKNOWN_CONFIGURE_OPTION__!(mode)
+ fail SecurityError, "can't change the mode" if $SAFE>=4
+ @mode = (mode)? true: false
+ end
+
+ def __item_cget_cmd(id)
+ # maybe need to override
+ [self.path, 'itemcget', id]
+ end
+ private :__item_cget_cmd
+
+ def __item_config_cmd(id)
+ # maybe need to override
+ [self.path, 'itemconfigure', id]
+ end
+ private :__item_config_cmd
+
+ def __item_confinfo_cmd(id)
+ # maybe need to override
+ __item_config_cmd(id)
+ end
+ private :__item_confinfo_cmd
+
+ def __item_configinfo_struct(id)
+ # maybe need to override
+ {:key=>0, :alias=>1, :db_name=>1, :db_class=>2,
+ :default_value=>3, :current_value=>4}
+ end
+ private :__item_configinfo_struct
+
+ ################################################
+
+ def tagid(tagOrId)
+ # maybe need to override
+ tagOrId
+ end
+
+ ################################################
+
+
+ def itemcget_tkstring(tagOrId, option)
+ opt = option.to_s
+ fail ArgumentError, "Invalid option `#{option.inspect}'" if opt.length == 0
+ tk_call_without_enc(*(__item_cget_cmd(tagid(tagOrId)) << "-#{opt}"))
+ end
+
+ def __itemcget_core(tagOrId, option)
+ orig_opt = option
+ option = option.to_s
+
+ if option.length == 0
+ fail ArgumentError, "Invalid option `#{orig_opt.inspect}'"
+ end
+
+ alias_name, real_name = __item_optkey_aliases(tagid(tagOrId)).find{|k, v| k.to_s == option}
+ if real_name
+ option = real_name.to_s
+ end
+
+ if ( method = _symbolkey2str(__item_val2ruby_optkeys(tagid(tagOrId)))[option] )
+ optval = tk_call_without_enc(*(__item_cget_cmd(tagid(tagOrId)) << "-#{option}"))
+ begin
+ return method.call(tagOrId, optval)
+ rescue => e
+ warn("Warning:: #{e.message} (when #{method}.call(#{tagOrId.inspect}, #{optval.inspect})") if $DEBUG
+ return optval
+ end
+ end
+
+ if ( method = _symbolkey2str(__item_methodcall_optkeys(tagid(tagOrId)))[option] )
+ return self.__send__(method, tagOrId)
+ end
+
+ case option
+ when /^(#{__item_numval_optkeys(tagid(tagOrId)).join('|')})$/
+ begin
+ number(tk_call_without_enc(*(__item_cget_cmd(tagid(tagOrId)) << "-#{option}")))
+ rescue
+ nil
+ end
+
+ when /^(#{__item_numstrval_optkeys(tagid(tagOrId)).join('|')})$/
+ num_or_str(tk_call_without_enc(*(__item_cget_cmd(tagid(tagOrId)) << "-#{option}")))
+
+ when /^(#{__item_boolval_optkeys(tagid(tagOrId)).join('|')})$/
+ begin
+ bool(tk_call_without_enc(*(__item_cget_cmd(tagid(tagOrId)) << "-#{option}")))
+ rescue
+ nil
+ end
+
+ when /^(#{__item_listval_optkeys(tagid(tagOrId)).join('|')})$/
+ simplelist(tk_call_without_enc(*(__item_cget_cmd(tagid(tagOrId)) << "-#{option}")))
+
+ when /^(#{__item_numlistval_optkeys(tagid(tagOrId)).join('|')})$/
+ conf = tk_call_without_enc(*(__item_cget_cmd(tagid(tagOrId)) << "-#{option}"))
+ if conf =~ /^[0-9]/
+ list(conf)
+ else
+ conf
+ end
+
+ when /^(#{__item_tkvariable_optkeys(tagid(tagOrId)).join('|')})$/
+ v = tk_call_without_enc(*(__item_cget_cmd(tagid(tagOrId)) << "-#{option}"))
+ (v.empty?)? nil: TkVarAccess.new(v)
+
+ when /^(#{__item_strval_optkeys(tagid(tagOrId)).join('|')})$/
+ _fromUTF8(tk_call_without_enc(*(__item_cget_cmd(tagid(tagOrId)) << "-#{option}")))
+
+ when /^(|latin|ascii|kanji)(#{__item_font_optkeys(tagid(tagOrId)).join('|')})$/
+ fontcode = $1
+ fontkey = $2
+ fnt = tk_tcl2ruby(tk_call_without_enc(*(__item_cget_cmd(tagid(tagOrId)) << "-#{fontkey}")), true)
+ unless fnt.kind_of?(TkFont)
+ fnt = tagfontobj(tagid(tagOrId), fontkey)
+ end
+ if fontcode == 'kanji' && JAPANIZED_TK && TK_VERSION =~ /^4\.*/
+ # obsolete; just for compatibility
+ fnt.kanji_font
+ else
+ fnt
+ end
+ else
+ tk_tcl2ruby(tk_call_without_enc(*(__item_cget_cmd(tagid(tagOrId)) << "-#{option}")), true)
+ end
+ end
+ private :__itemcget_core
+
+ def itemcget(tagOrId, option)
+ unless TkItemConfigMethod.__IGNORE_UNKNOWN_CONFIGURE_OPTION__
+ __itemcget_core(tagOrId, option)
+ else
+ begin
+ __itemcget_core(tagOrId, option)
+ rescue => e
+ begin
+ if __current_itemconfiginfo(tagOrId).has_key?(option.to_s)
+ # not tag error & option is known -> error on known option
+ fail e
+ else
+ # not tag error & option is unknown
+ nil
+ end
+ rescue
+ fail e # tag error
+ end
+ end
+ end
+ end
+ def itemcget_strict(tagOrId, option)
+ # never use TkItemConfigMethod.__IGNORE_UNKNOWN_CONFIGURE_OPTION__
+ __itemcget_core(tagOrId, option)
+ end
+
+ def __itemconfigure_core(tagOrId, slot, value=None)
+ if slot.kind_of? Hash
+ slot = _symbolkey2str(slot)
+
+ __item_optkey_aliases(tagid(tagOrId)).each{|alias_name, real_name|
+ alias_name = alias_name.to_s
+ if slot.has_key?(alias_name)
+ slot[real_name.to_s] = slot.delete(alias_name)
+ end
+ }
+
+ __item_methodcall_optkeys(tagid(tagOrId)).each{|key, method|
+ value = slot.delete(key.to_s)
+ self.__send__(method, tagOrId, value) if value
+ }
+
+ __item_ruby2val_optkeys(tagid(tagOrId)).each{|key, method|
+ key = key.to_s
+ slot[key] = method.call(tagOrId, slot[key]) if slot.has_key?(key)
+ }
+
+ __item_keyonly_optkeys(tagid(tagOrId)).each{|defkey, undefkey|
+ conf = slot.find{|kk, vv| kk == defkey.to_s}
+ if conf
+ k, v = conf
+ if v
+ slot[k] = None
+ else
+ slot[undefkey.to_s] = None if undefkey
+ slot.delete(k)
+ end
+ end
+ }
+
+ if (slot.find{|k, v| k =~ /^(|latin|ascii|kanji)(#{__item_font_optkeys(tagid(tagOrId)).join('|')})$/})
+ tagfont_configure(tagid(tagOrId), slot)
+ elsif slot.size > 0
+ tk_call(*(__item_config_cmd(tagid(tagOrId)).concat(hash_kv(slot))))
+ end
+
+ else
+ orig_slot = slot
+ slot = slot.to_s
+ if slot.length == 0
+ fail ArgumentError, "Invalid option `#{orig_slot.inspect}'"
+ end
+
+ alias_name, real_name = __item_optkey_aliases(tagid(tagOrId)).find{|k, v| k.to_s == slot}
+ if real_name
+ slot = real_name.to_s
+ end
+
+ if ( conf = __item_keyonly_optkeys(tagid(tagOrId)).find{|k, v| k.to_s == slot } )
+ defkey, undefkey = conf
+ if value
+ tk_call(*(__item_config_cmd(tagid(tagOrId)) << "-#{defkey}"))
+ elsif undefkey
+ tk_call(*(__item_config_cmd(tagid(tagOrId)) << "-#{undefkey}"))
+ end
+ elsif ( method = _symbolkey2str(__item_ruby2val_optkeys(tagid(tagOrId)))[slot] )
+ tk_call(*(__item_config_cmd(tagid(tagOrId)) << "-#{slot}" << method.call(tagOrId, value)))
+ elsif ( method = _symbolkey2str(__item_methodcall_optkeys(tagid(tagOrId)))[slot] )
+ self.__send__(method, tagOrId, value)
+ elsif (slot =~ /^(|latin|ascii|kanji)(#{__item_font_optkeys(tagid(tagOrId)).join('|')})$/)
+ if value == None
+ tagfontobj(tagid(tagOrId), $2)
+ else
+ tagfont_configure(tagid(tagOrId), {slot=>value})
+ end
+ else
+ tk_call(*(__item_config_cmd(tagid(tagOrId)) << "-#{slot}" << value))
+ end
+ end
+ self
+ end
+ private :__itemconfigure_core
+
+ def __check_available_itemconfigure_options(tagOrId, keys)
+ id = tagid(tagOrId)
+
+ availables = self.__current_itemconfiginfo(id).keys
+
+ # add non-standard keys
+ availables |= __font_optkeys.map{|k|
+ [k.to_s, "latin#{k}", "ascii#{k}", "kanji#{k}"]
+ }.flatten
+ availables |= __item_methodcall_optkeys(id).keys.map{|k| k.to_s}
+ availables |= __item_keyonly_optkeys(id).keys.map{|k| k.to_s}
+
+ keys = _symbolkey2str(keys)
+
+ keys.delete_if{|k, v| !(availables.include?(k))}
+ end
+
+ def itemconfigure(tagOrId, slot, value=None)
+ unless TkItemConfigMethod.__IGNORE_UNKNOWN_CONFIGURE_OPTION__
+ __itemconfigure_core(tagOrId, slot, value)
+ else
+ if slot.kind_of?(Hash)
+ begin
+ __itemconfigure_core(tagOrId, slot)
+ rescue
+ slot = __check_available_itemconfigure_options(tagOrId, slot)
+ __itemconfigure_core(tagOrId, slot) unless slot.empty?
+ end
+ else
+ begin
+ __itemconfigure_core(tagOrId, slot, value)
+ rescue => e
+ begin
+ if __current_itemconfiginfo(tagOrId).has_key?(slot.to_s)
+ # not tag error & option is known -> error on known option
+ fail e
+ else
+ # not tag error & option is unknown
+ nil
+ end
+ rescue
+ fail e # tag error
+ end
+ end
+ end
+ end
+ self
+ end
+
+ def __itemconfiginfo_core(tagOrId, slot = nil)
+ if TkComm::GET_CONFIGINFO_AS_ARRAY
+ if (slot && slot.to_s =~ /^(|latin|ascii|kanji)(#{__item_font_optkeys(tagid(tagOrId)).join('|')})$/)
+ fontkey = $2
+ # conf = tk_split_simplelist(_fromUTF8(tk_call_without_enc(*(__item_confinfo_cmd(tagid(tagOrId)) << "-#{fontkey}"))))
+ conf = tk_split_simplelist(tk_call_without_enc(*(__item_confinfo_cmd(tagid(tagOrId)) << "-#{fontkey}")), false, true)
+ conf[__item_configinfo_struct(tagid(tagOrId))[:key]] =
+ conf[__item_configinfo_struct(tagid(tagOrId))[:key]][1..-1]
+ if ( ! __item_configinfo_struct(tagid(tagOrId))[:alias] \
+ || conf.size > __item_configinfo_struct(tagid(tagOrId))[:alias] + 1 )
+ fnt = conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]]
+ if TkFont.is_system_font?(fnt)
+ conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] = TkNamedFont.new(fnt)
+ end
+ conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] = tagfontobj(tagid(tagOrId), fontkey)
+ elsif ( __item_configinfo_struct(tagid(tagOrId))[:alias] \
+ && conf.size == __item_configinfo_struct(tagid(tagOrId))[:alias] + 1 \
+ && conf[__item_configinfo_struct(tagid(tagOrId))[:alias]][0] == ?- )
+ conf[__item_configinfo_struct(tagid(tagOrId))[:alias]] =
+ conf[__item_configinfo_struct(tagid(tagOrId))[:alias]][1..-1]
+ end
+ conf
+ else
+ if slot
+ slot = slot.to_s
+
+ alias_name, real_name = __item_optkey_aliases(tagid(tagOrId)).find{|k, v| k.to_s == slot}
+ if real_name
+ slot = real_name.to_s
+ end
+
+ case slot
+ when /^(#{__item_val2ruby_optkeys(tagid(tagOrId)).keys.join('|')})$/
+ method = _symbolkey2str(__item_val2ruby_optkeys(tagid(tagOrId)))[slot]
+ conf = tk_split_simplelist(tk_call_without_enc(*(__item_confinfo_cmd(tagid(tagOrId)) << "-#{slot}")), false, true)
+ if ( __item_configinfo_struct(tagid(tagOrId))[:default_value] \
+ && conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] )
+ optval = conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]]
+ begin
+ val = method.call(tagOrId, optval)
+ rescue => e
+ warn("Warning:: #{e.message} (when #{method}.call(#{tagOrId.inspect}, #{optval.inspect})") if $DEBUG
+ val = optval
+ end
+ conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] = val
+ end
+ if ( conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] )
+ optval = conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]]
+ begin
+ val = method.call(tagOrId, optval)
+ rescue => e
+ warn("Warning:: #{e.message} (when #{method}lcall(#{tagOrId.inspect}, #{optval.inspect})") if $DEBUG
+ val = optval
+ end
+ conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] = val
+ end
+
+ when /^(#{__item_methodcall_optkeys(tagid(tagOrId)).keys.join('|')})$/
+ method = _symbolkey2str(__item_methodcall_optkeys(tagid(tagOrId)))[slot]
+ return [slot, '', '', '', self.__send__(method, tagOrId)]
+
+ when /^(#{__item_numval_optkeys(tagid(tagOrId)).join('|')})$/
+ # conf = tk_split_simplelist(_fromUTF8(tk_call_without_enc(*(__item_confinfo_cmd(tagid(tagOrId)) << "-#{slot}"))))
+ conf = tk_split_simplelist(tk_call_without_enc(*(__item_confinfo_cmd(tagid(tagOrId)) << "-#{slot}")), false, true)
+
+ if ( __item_configinfo_struct(tagid(tagOrId))[:default_value] \
+ && conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] )
+ begin
+ conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] =
+ number(conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]])
+ rescue
+ conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] = nil
+ end
+ end
+ if ( conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] )
+ begin
+ conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] =
+ number(conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]])
+ rescue
+ conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] = nil
+ end
+ end
+
+ when /^(#{__item_numstrval_optkeys(tagid(tagOrId)).join('|')})$/
+ # conf = tk_split_simplelist(_fromUTF8(tk_call_without_enc(*(__item_confinfo_cmd(tagid(tagOrId)) << "-#{slot}"))))
+ conf = tk_split_simplelist(tk_call_without_enc(*(__item_confinfo_cmd(tagid(tagOrId)) << "-#{slot}")), false, true)
+
+ if ( __item_configinfo_struct(tagid(tagOrId))[:default_value] \
+ && conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] )
+ conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] =
+ num_or_str(conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]])
+ end
+ if ( conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] )
+ conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] =
+ num_or_str(conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]])
+ end
+
+ when /^(#{__item_boolval_optkeys(tagid(tagOrId)).join('|')})$/
+ # conf = tk_split_simplelist(_fromUTF8(tk_call_without_enc(*(__item_confinfo_cmd(tagid(tagOrId)) << "-#{slot}"))))
+ conf = tk_split_simplelist(tk_call_without_enc(*(__item_confinfo_cmd(tagid(tagOrId)) << "-#{slot}")), false, true)
+
+ if ( __item_configinfo_struct(tagid(tagOrId))[:default_value] \
+ && conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] )
+ begin
+ conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] =
+ bool(conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]])
+ rescue
+ conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] = nil
+ end
+ end
+ if ( conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] )
+ begin
+ conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] =
+ bool(conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]])
+ rescue
+ conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] = nil
+ end
+ end
+
+ when /^(#{__item_listval_optkeys(tagid(tagOrId)).join('|')})$/
+ # conf = tk_split_simplelist(_fromUTF8(tk_call_without_enc(*(__item_confinfo_cmd(tagid(tagOrId)) << "-#{slot}"))))
+ conf = tk_split_simplelist(tk_call_without_enc(*(__item_confinfo_cmd(tagid(tagOrId)) << "-#{slot}")), false, true)
+
+ if ( __item_configinfo_struct(tagid(tagOrId))[:default_value] \
+ && conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] )
+ conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] =
+ simplelist(conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]])
+ end
+ if ( conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] )
+ conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] =
+ simplelist(conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]])
+ end
+
+ when /^(#{__item_numlistval_optkeys(tagid(tagOrId)).join('|')})$/
+ # conf = tk_split_simplelist(_fromUTF8(tk_call_without_enc(*(__item_confinfo_cmd(tagid(tagOrId)) << "-#{slot}"))))
+ conf = tk_split_simplelist(tk_call_without_enc(*(__item_confinfo_cmd(tagid(tagOrId)) << "-#{slot}")), false, true)
+
+ if ( __item_configinfo_struct(tagid(tagOrId))[:default_value] \
+ && conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] \
+ && conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] =~ /^[0-9]/ )
+ conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] =
+ list(conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]])
+ end
+ if ( conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] \
+ && conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] =~ /^[0-9]/ )
+ conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] =
+ list(conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]])
+ end
+
+ when /^(#{__item_strval_optkeys(tagid(tagOrId)).join('|')})$/
+ # conf = tk_split_simplelist(_fromUTF8(tk_call_without_enc(*(__item_confinfo_cmd(tagid(tagOrId)) << "-#{slot}"))))
+ conf = tk_split_simplelist(tk_call_without_enc(*(__item_confinfo_cmd(tagid(tagOrId)) << "-#{slot}")), false, true)
+
+ when /^(#{__item_tkvariable_optkeys(tagid(tagOrId)).join('|')})$/
+ conf = tk_split_simplelist(tk_call_without_enc(*(__item_confinfo_cmd(tagid(tagOrId)) << "-#{slot}")), false, true)
+
+ if ( __item_configinfo_struct(tagid(tagOrId))[:default_value] \
+ && conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] )
+ v = conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]]
+ if v.empty?
+ conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] = nil
+ else
+ conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] = TkVarAccess.new(v)
+ end
+ end
+ if ( conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] )
+ v = conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]]
+ if v.empty?
+ conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] = nil
+ else
+ conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] = TkVarAccess.new(v)
+ end
+ end
+
+ else
+ # conf = tk_split_list(_fromUTF8(tk_call_without_enc(*(__item_confinfo_cmd(tagid(tagOrId)) << "-#{slot}"))))
+ conf = tk_split_list(tk_call_without_enc(*(__item_confinfo_cmd(tagid(tagOrId)) << "-#{slot}")), 0, false, true)
+ end
+ conf[__item_configinfo_struct(tagid(tagOrId))[:key]] =
+ conf[__item_configinfo_struct(tagid(tagOrId))[:key]][1..-1]
+
+ if ( __item_configinfo_struct(tagid(tagOrId))[:alias] \
+ && conf.size == __item_configinfo_struct(tagid(tagOrId))[:alias] + 1 \
+ && conf[__item_configinfo_struct(tagid(tagOrId))[:alias]][0] == ?- )
+ conf[__item_configinfo_struct(tagid(tagOrId))[:alias]] =
+ conf[__item_configinfo_struct(tagid(tagOrId))[:alias]][1..-1]
+ end
+
+ conf
+
+ else
+ # ret = tk_split_simplelist(_fromUTF8(tk_call_without_enc(*(__item_confinfo_cmd(tagid(tagOrId)))))).collect{|conflist|
+ # conf = tk_split_simplelist(conflist)
+ ret = tk_split_simplelist(tk_call_without_enc(*(__item_confinfo_cmd(tagid(tagOrId)))), false, false).collect{|conflist|
+ conf = tk_split_simplelist(conflist, false, true)
+ conf[__item_configinfo_struct(tagid(tagOrId))[:key]] =
+ conf[__item_configinfo_struct(tagid(tagOrId))[:key]][1..-1]
+
+ optkey = conf[__item_configinfo_struct(tagid(tagOrId))[:key]]
+ case optkey
+ when /^(#{__item_val2ruby_optkeys(tagid(tagOrId)).keys.join('|')})$/
+ method = _symbolkey2str(__item_val2ruby_optkeys(tagid(tagOrId)))[optkey]
+ if ( __item_configinfo_struct(tagid(tagOrId))[:default_value] \
+ && conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] )
+ optval = conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]]
+ begin
+ val = method(tagOrId, optval)
+ rescue => e
+ warn("Warning:: #{e.message} (when #{method}.call(#{tagOrId.inspect}, #{optval.inspect})") if $DEBUG
+ val = optval
+ end
+ conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] = val
+ end
+ if ( conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] )
+ optval = conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]]
+ begin
+ val = method.call(tagOrId, optval)
+ rescue => e
+ warn("Warning:: #{e.message} (when #{method}.call(#{tagOrId.inspect}, #{optval.inspect})") if $DEBUG
+ val = optval
+ end
+ conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] = val
+ end
+
+ when /^(#{__item_strval_optkeys(tagid(tagOrId)).join('|')})$/
+ # do nothing
+
+ when /^(#{__item_numval_optkeys(tagid(tagOrId)).join('|')})$/
+ if ( __item_configinfo_struct(tagid(tagOrId))[:default_value] \
+ && conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] )
+ begin
+ conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] =
+ number(conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]])
+ rescue
+ conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] = nil
+ end
+ end
+ if ( conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] )
+ begin
+ conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] =
+ number(conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]])
+ rescue
+ conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] = nil
+ end
+ end
+
+ when /^(#{__item_numstrval_optkeys(tagid(tagOrId)).join('|')})$/
+ if ( __item_configinfo_struct(tagid(tagOrId))[:default_value] \
+ && conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] )
+ conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] =
+ num_or_str(conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]])
+ end
+ if ( conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] )
+ conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] =
+ num_or_str(conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]])
+ end
+
+ when /^(#{__item_boolval_optkeys(tagid(tagOrId)).join('|')})$/
+ if ( __item_configinfo_struct(tagid(tagOrId))[:default_value] \
+ && conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] )
+ begin
+ conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] =
+ bool(conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]])
+ rescue
+ conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] = nil
+ end
+ end
+ if ( conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] )
+ begin
+ conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] =
+ bool(conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]])
+ rescue
+ conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] = nil
+ end
+ end
+
+ when /^(#{__item_listval_optkeys(tagid(tagOrId)).join('|')})$/
+ if ( __item_configinfo_struct(tagid(tagOrId))[:default_value] \
+ && conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] )
+ conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] =
+ simplelist(conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]])
+ end
+ if ( conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] )
+ conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] =
+ simplelist(conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]])
+ end
+
+ when /^(#{__item_numlistval_optkeys(tagid(tagOrId)).join('|')})$/
+ if ( __item_configinfo_struct(tagid(tagOrId))[:default_value] \
+ && conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] \
+ && conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] =~ /^[0-9]/ )
+ conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] =
+ list(conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]])
+ end
+ if ( conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] \
+ && conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] =~ /^[0-9]/ )
+ conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] =
+ list(conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]])
+ end
+
+ when /^(#{__item_tkvariable_optkeys(tagid(tagOrId)).join('|')})$/
+ if ( __item_configinfo_struct(tagid(tagOrId))[:default_value] \
+ && conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] )
+ v = conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]]
+ if v.empty?
+ conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] = nil
+ else
+ conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] = TkVarAccess.new(v)
+ end
+ end
+ if ( conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] )
+ v = conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]]
+ if v.empty?
+ conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] = nil
+ else
+ conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] = TkVarAccess.new(v)
+ end
+ end
+
+ else
+ if ( __item_configinfo_struct(tagid(tagOrId))[:default_value] \
+ && conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] )
+ if conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]].index('{')
+ conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] =
+ tk_split_list(conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]])
+ else
+ conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] =
+ tk_tcl2ruby(conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]])
+ end
+ end
+ if conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]]
+ if conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]].index('{')
+ conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] =
+ tk_split_list(conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]])
+ else
+ conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] =
+ tk_tcl2ruby(conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]])
+ end
+ end
+ end
+
+ if ( __item_configinfo_struct(tagid(tagOrId))[:alias] \
+ && conf.size == __item_configinfo_struct(tagid(tagOrId))[:alias] + 1 \
+ && conf[__item_configinfo_struct(tagid(tagOrId))[:alias]][0] == ?- )
+ conf[__item_configinfo_struct(tagid(tagOrId))[:alias]] =
+ conf[__item_configinfo_struct(tagid(tagOrId))[:alias]][1..-1]
+ end
+
+ conf
+ }
+
+ __item_font_optkeys(tagid(tagOrId)).each{|optkey|
+ optkey = optkey.to_s
+ fontconf = ret.assoc(optkey)
+ if fontconf && fontconf.size > 2
+ ret.delete_if{|inf| inf[0] =~ /^(|latin|ascii|kanji)#{optkey}$/}
+ fnt = fontconf[__item_configinfo_struct(tagid(tagOrId))[:default_value]]
+ if TkFont.is_system_font?(fnt)
+ fontconf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] = TkNamedFont.new(fnt)
+ end
+ fontconf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] = tagfontobj(tagid(tagOrId), optkey)
+ ret.push(fontconf)
+ end
+ }
+
+ __item_methodcall_optkeys(tagid(tagOrId)).each{|optkey, method|
+ ret << [optkey.to_s, '', '', '', self.__send__(method, tagOrId)]
+ }
+
+ ret
+ end
+ end
+
+ else # ! TkComm::GET_CONFIGINFO_AS_ARRAY
+ if (slot && slot.to_s =~ /^(|latin|ascii|kanji)(#{__item_font_optkeys(tagid(tagOrId)).join('|')})$/)
+ fontkey = $2
+ # conf = tk_split_simplelist(_fromUTF8(tk_call_without_enc(*(__item_confinfo_cmd(tagid(tagOrId)) << "-#{fontkey}"))))
+ conf = tk_split_simplelist(tk_call_without_enc(*(__item_confinfo_cmd(tagid(tagOrId)) << "-#{fontkey}")), false, true)
+ conf[__item_configinfo_struct(tagid(tagOrId))[:key]] =
+ conf[__item_configinfo_struct(tagid(tagOrId))[:key]][1..-1]
+
+ if ( ! __item_configinfo_struct(tagid(tagOrId))[:alias] \
+ || conf.size > __item_configinfo_struct(tagid(tagOrId))[:alias] + 1 )
+ fnt = conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]]
+ if TkFont.is_system_font?(fnt)
+ conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] = TkNamedFont.new(fnt)
+ end
+ conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] = tagfontobj(tagid(tagOrId), fontkey)
+ { conf.shift => conf }
+ elsif ( __item_configinfo_struct(tagid(tagOrId))[:alias] \
+ && conf.size == __item_configinfo_struct(tagid(tagOrId))[:alias] + 1 )
+ if conf[__item_configinfo_struct(tagid(tagOrId))[:alias]][0] == ?-
+ conf[__item_configinfo_struct(tagid(tagOrId))[:alias]] =
+ conf[__item_configinfo_struct(tagid(tagOrId))[:alias]][1..-1]
+ end
+ { conf[0] => conf[1] }
+ else
+ { conf.shift => conf }
+ end
+ else
+ if slot
+ slot = slot.to_s
+
+ alias_name, real_name = __item_optkey_aliases(tagid(tagOrId)).find{|k, v| k.to_s == slot}
+ if real_name
+ slot = real_name.to_s
+ end
+
+ case slot
+ when /^(#{__item_val2ruby_optkeys(tagid(tagOrId)).keys.join('|')})$/
+ method = _symbolkey2str(__item_val2ruby_optkeys(tagid(tagOrId)))[slot]
+ conf = tk_split_simplelist(tk_call_without_enc(*(__item_confinfo_cmd(tagid(tagOrId)) << "-#{slot}")), false, true)
+ if ( __item_configinfo_struct(tagid(tagOrId))[:default_value] \
+ && conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] )
+ optval = conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]]
+ begin
+ val = method.call(tagOrId, optval)
+ rescue => e
+ warn("Warning:: #{e.message} (when #{method}.call(#{tagOrId.inspect}, #{optval.inspect})") if $DEBUG
+ val = optval
+ end
+ conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] = val
+ end
+ if ( conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] )
+ optval = conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]]
+ begin
+ val = method.call(tagOrId, optval)
+ rescue => e
+ warn("Warning:: #{e.message} (when #{method}.call(#{tagOrId.inspect}, #{optval.inspect})") if $DEBUG
+ val = optval
+ end
+ conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] = val
+ end
+
+ when /^(#{__item_methodcall_optkeys(tagid(tagOrId)).keys.join('|')})$/
+ method = _symbolkey2str(__item_methodcall_optkeys(tagid(tagOrId)))[slot]
+ return {slot => ['', '', '', self.__send__(method, tagOrId)]}
+
+ when /^(#{__item_numval_optkeys(tagid(tagOrId)).join('|')})$/
+ # conf = tk_split_simplelist(_fromUTF8(tk_call_without_enc(*(__item_confinfo_cmd(tagid(tagOrId)) << "-#{slot}"))))
+ conf = tk_split_simplelist(tk_call_without_enc(*(__item_confinfo_cmd(tagid(tagOrId)) << "-#{slot}")), false, true)
+
+ if ( __item_configinfo_struct(tagid(tagOrId))[:default_value] \
+ && conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] )
+ begin
+ conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] =
+ number(conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]])
+ rescue
+ conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] = nil
+ end
+ end
+ if ( conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] )
+ begin
+ conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] =
+ number(conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]])
+ rescue
+ conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] = nil
+ end
+ end
+
+ when /^(#{__item_numstrval_optkeys(tagid(tagOrId)).join('|')})$/
+ # conf = tk_split_simplelist(_fromUTF8(tk_call_without_enc(*(__item_confinfo_cmd(tagid(tagOrId)) << "-#{slot}"))))
+ conf = tk_split_simplelist(tk_call_without_enc(*(__item_confinfo_cmd(tagid(tagOrId)) << "-#{slot}")), false, true)
+
+ if ( __item_configinfo_struct(tagid(tagOrId))[:default_value] \
+ && conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] )
+ conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] =
+ num_or_stre(conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]])
+ end
+ if ( conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] )
+ conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] =
+ num_or_str(conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]])
+ end
+
+ when /^(#{__item_boolval_optkeys(tagid(tagOrId)).join('|')})$/
+ # conf = tk_split_simplelist(_fromUTF8(tk_call_without_enc(*(__item_confinfo_cmd(tagid(tagOrId)) << "-#{slot}"))))
+ conf = tk_split_simplelist(tk_call_without_enc(*(__item_confinfo_cmd(tagid(tagOrId)) << "-#{slot}")), false, true)
+
+ if ( __item_configinfo_struct(tagid(tagOrId))[:default_value] \
+ && conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] )
+ begin
+ conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] =
+ bool(conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]])
+ rescue
+ conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] = nil
+ end
+ end
+ if ( conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] )
+ begin
+ conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] =
+ bool(conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]])
+ rescue
+ conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] = nil
+ end
+ end
+
+ when /^(#{__item_listval_optkeys(tagid(tagOrId)).join('|')})$/
+ # conf = tk_split_simplelist(_fromUTF8(tk_call_without_enc(*(__item_confinfo_cmd(tagid(tagOrId)) << "-#{slot}"))))
+ conf = tk_split_simplelist(tk_call_without_enc(*(__item_confinfo_cmd(tagid(tagOrId)) << "-#{slot}")), false, true)
+
+ if ( __item_configinfo_struct(tagid(tagOrId))[:default_value] \
+ && conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] )
+ conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] =
+ simplelist(conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]])
+ end
+ if ( conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] )
+ conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] =
+ simplelist(conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]])
+ end
+
+ when /^(#{__item_numlistval_optkeys(tagid(tagOrId)).join('|')})$/
+ # conf = tk_split_simplelist(_fromUTF8(tk_call_without_enc(*(__item_confinfo_cmd(tagid(tagOrId)) << "-#{slot}"))))
+ conf = tk_split_simplelist(tk_call_without_enc(*(__item_confinfo_cmd(tagid(tagOrId)) << "-#{slot}")), false, true)
+
+ if ( __item_configinfo_struct(tagid(tagOrId))[:default_value] \
+ && conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] \
+ && conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] =~ /^[0-9]/ )
+ conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] =
+ list(conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]])
+ end
+ if ( conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] \
+ && conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] =~ /^[0-9]/ )
+ conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] =
+ list(conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]])
+ end
+
+ when /^(#{__item_strval_optkeys(tagid(tagOrId)).join('|')})$/
+ # conf = tk_split_simplelist(_fromUTF8(tk_call_without_enc(*(__item_confinfo_cmd(tagid(tagOrId)) << "-#{slot}"))))
+ conf = tk_split_simplelist(tk_call_without_enc(*(__item_confinfo_cmd(tagid(tagOrId)) << "-#{slot}")), false, true)
+
+ when /^(#{__item_tkvariable_optkeys(tagid(tagOrId)).join('|')})$/
+ conf = tk_split_simplelist(tk_call_without_enc(*(__item_confinfo_cmd(tagid(tagOrId)) << "-#{slot}")), false, true)
+
+ if ( __item_configinfo_struct(tagid(tagOrId))[:default_value] \
+ && conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] )
+ v = conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]]
+ if v.empty?
+ conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] = nil
+ else
+ conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] = TkVarAccess.new(v)
+ end
+ end
+ if ( conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] )
+ v = conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]]
+ if v.empty?
+ conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] = nil
+ else
+ conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] = TkVarAccess.new(v)
+ end
+ end
+
+ else
+ # conf = tk_split_list(_fromUTF8(tk_call_without_enc(*(__item_confinfo_cmd(tagid(tagOrId)) << "-#{slot}"))))
+ conf = tk_split_list(tk_call_without_enc(*(__item_confinfo_cmd(tagid(tagOrId)) << "-#{slot}")), 0, false, true)
+ end
+ conf[__item_configinfo_struct(tagid(tagOrId))[:key]] =
+ conf[__item_configinfo_struct(tagid(tagOrId))[:key]][1..-1]
+
+ if ( __item_configinfo_struct(tagid(tagOrId))[:alias] \
+ && conf.size == __item_configinfo_struct(tagid(tagOrId))[:alias] + 1 )
+ if conf[__item_configinfo_struct(tagid(tagOrId))[:alias]][0] == ?-
+ conf[__item_configinfo_struct(tagid(tagOrId))[:alias]] =
+ conf[__item_configinfo_struct(tagid(tagOrId))[:alias]][1..-1]
+ end
+ { conf[0] => conf[1] }
+ else
+ { conf.shift => conf }
+ end
+
+ else
+ ret = {}
+ # tk_split_simplelist(_fromUTF8(tk_call_without_enc(*(__item_confinfo_cmd(tagid(tagOrId)))))).each{|conflist|
+ # conf = tk_split_simplelist(conflist)
+ tk_split_simplelist(tk_call_without_enc(*(__item_confinfo_cmd(tagid(tagOrId)))), false, false).each{|conflist|
+ conf = tk_split_simplelist(conflist, false, true)
+ conf[__item_configinfo_struct(tagid(tagOrId))[:key]] =
+ conf[__item_configinfo_struct(tagid(tagOrId))[:key]][1..-1]
+
+ optkey = conf[__item_configinfo_struct(tagid(tagOrId))[:key]]
+ case optkey
+ when /^(#{__item_val2ruby_optkeys(tagid(tagOrId)).keys.join('|')})$/
+ method = _symbolkey2str(__item_val2ruby_optkeys(tagid(tagOrId)))[optkey]
+ if ( __item_configinfo_struct(tagid(tagOrId))[:default_value] \
+ && conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] )
+ optval = conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]]
+ begin
+ val = method.call(tagOrId, optval)
+ rescue => e
+ warn("Warning:: #{e.message} (when #{method}.call(#{tagOrId.inspect}, #{optval.inspect})") if $DEBUG
+ val = optval
+ end
+ conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] = val
+ end
+ if ( conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] )
+ optval = conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]]
+ begin
+ val = method.call(tagOrId, optval)
+ rescue => e
+ warn("Warning:: #{e.message} (when #{method}.call(#{tagOrId.inspect}, #{optval.inspect})") if $DEBUG
+ val = optval
+ end
+ conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] = val
+ end
+
+ when /^(#{__item_strval_optkeys(tagid(tagOrId)).join('|')})$/
+ # do nothing
+
+ when /^(#{__item_numval_optkeys(tagid(tagOrId)).join('|')})$/
+ if ( __item_configinfo_struct(tagid(tagOrId))[:default_value] \
+ && conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] )
+ begin
+ conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] =
+ number(conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]])
+ rescue
+ conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] = nil
+ end
+ end
+ if ( conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] )
+ begin
+ conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] =
+ number(conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]])
+ rescue
+ conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] = nil
+ end
+ end
+
+ when /^(#{__item_numstrval_optkeys(tagid(tagOrId)).join('|')})$/
+ if ( __item_configinfo_struct(tagid(tagOrId))[:default_value] \
+ && conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] )
+ conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] =
+ num_or_str(conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]])
+ end
+ if ( conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] )
+ conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] =
+ num_or_str(conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]])
+ end
+
+ when /^(#{__item_boolval_optkeys(tagid(tagOrId)).join('|')})$/
+ if ( __item_configinfo_struct(tagid(tagOrId))[:default_value] \
+ && conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] )
+ begin
+ conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] =
+ bool(conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]])
+ rescue
+ conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] = nil
+ end
+ end
+ if ( conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] )
+ begin
+ conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] =
+ bool(conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]])
+ rescue
+ conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] = nil
+ end
+ end
+
+ when /^(#{__item_listval_optkeys(tagid(tagOrId)).join('|')})$/
+ if ( __item_configinfo_struct(tagid(tagOrId))[:default_value] \
+ && conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] )
+ conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] =
+ simplelist(conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]])
+ end
+ if ( conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] )
+ conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] =
+ simplelist(conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]])
+ end
+
+ when /^(#{__item_numlistval_optkeys(tagid(tagOrId)).join('|')})$/
+ if ( __item_configinfo_struct(tagid(tagOrId))[:default_value] \
+ && conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] \
+ && conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] =~ /^[0-9]/ )
+ conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] =
+ list(conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]])
+ end
+ if ( conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] \
+ && conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] =~ /^[0-9]/ )
+ conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] =
+ list(conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]])
+ end
+
+ when /^(#{__item_tkvariable_optkeys(tagid(tagOrId)).join('|')})$/
+ if ( __item_configinfo_struct(tagid(tagOrId))[:default_value] \
+ && conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] )
+ v = conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]]
+ if v.empty?
+ conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] = nil
+ else
+ conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] = TkVarAccess.new(v)
+ end
+ end
+ if ( conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] )
+ v = conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]]
+ if v.empty?
+ conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] = nil
+ else
+ conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] = TkVarAccess.new(v)
+ end
+ end
+
+ else
+ if ( __item_configinfo_struct(tagid(tagOrId))[:default_value] \
+ && conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] )
+ if conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]].index('{')
+ conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] =
+ tk_split_list(conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]])
+ else
+ conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] =
+ tk_tcl2ruby(conf[__item_configinfo_struct(tagid(tagOrId))[:default_value]])
+ end
+ end
+ if conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]]
+ if conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]].index('{')
+ conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] =
+ tk_split_list(conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]])
+ else
+ conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] =
+ tk_tcl2ruby(conf[__item_configinfo_struct(tagid(tagOrId))[:current_value]])
+ end
+ end
+ end
+
+ if ( __item_configinfo_struct(tagid(tagOrId))[:alias] \
+ && conf.size == __item_configinfo_struct(tagid(tagOrId))[:alias] + 1 )
+ if conf[__item_configinfo_struct(tagid(tagOrId))[:alias]][0] == ?-
+ conf[__item_configinfo_struct(tagid(tagOrId))[:alias]] =
+ conf[__item_configinfo_struct(tagid(tagOrId))[:alias]][1..-1]
+ end
+ ret[conf[0]] = conf[1]
+ else
+ ret[conf.shift] = conf
+ end
+ }
+
+ __item_font_optkeys(tagid(tagOrId)).each{|optkey|
+ optkey = optkey.to_s
+ fontconf = ret[optkey]
+ if fontconf.kind_of?(Array)
+ ret.delete(optkey)
+ ret.delete('latin' << optkey)
+ ret.delete('ascii' << optkey)
+ ret.delete('kanji' << optkey)
+ fnt = fontconf[__item_configinfo_struct(tagid(tagOrId))[:default_value]]
+ if TkFont.is_system_font?(fnt)
+ fontconf[__item_configinfo_struct(tagid(tagOrId))[:default_value]] = TkNamedFont.new(fnt)
+ end
+ fontconf[__item_configinfo_struct(tagid(tagOrId))[:current_value]] = tagfontobj(tagid(tagOrId), optkey)
+ ret[optkey] = fontconf
+ end
+ }
+
+ __item_methodcall_optkeys(tagid(tagOrId)).each{|optkey, method|
+ ret[optkey.to_s] = ['', '', '', self.__send__(method, tagOrId)]
+ }
+
+ ret
+ end
+ end
+ end
+ end
+ private :__itemconfiginfo_core
+
+ def itemconfiginfo(tagOrId, slot = nil)
+ if slot && TkItemConfigMethod.__IGNORE_UNKNOWN_CONFIGURE_OPTION__
+ begin
+ __itemconfiginfo_core(tagOrId, slot)
+ rescue => e
+ begin
+ __itemconfiginfo_core(tagOrId)
+ # not tag error -> option is unknown
+ Array.new(__item_configinfo_struct.values.max).unshift(slot.to_s)
+ rescue
+ fail e # tag error
+ end
+ end
+ else
+ __itemconfiginfo_core(tagOrId, slot)
+ end
+ end
+
+ def __current_itemconfiginfo(tagOrId, slot = nil)
+ if TkComm::GET_CONFIGINFO_AS_ARRAY
+ if slot
+ org_slot = slot
+ begin
+ conf = __itemconfiginfo_core(tagOrId, slot)
+ if ( ! __item_configinfo_struct(tagid(tagOrId))[:alias] \
+ || conf.size > __item_configinfo_struct(tagid(tagOrId))[:alias] + 1 )
+ return {conf[0] => conf[-1]}
+ end
+ slot = conf[__item_configinfo_struct(tagid(tagOrId))[:alias]]
+ end while(org_slot != slot)
+ fail RuntimeError,
+ "there is a configure alias loop about '#{org_slot}'"
+ else
+ ret = {}
+ __itemconfiginfo_core(tagOrId).each{|conf|
+ if ( ! __item_configinfo_struct(tagid(tagOrId))[:alias] \
+ || conf.size > __item_configinfo_struct(tagid(tagOrId))[:alias] + 1 )
+ ret[conf[0]] = conf[-1]
+ end
+ }
+
+ ret
+ end
+ else # ! TkComm::GET_CONFIGINFO_AS_ARRAY
+ ret = {}
+ __itemconfiginfo_core(tagOrId, slot).each{|key, conf|
+ ret[key] = conf[-1] if conf.kind_of?(Array)
+ }
+ ret
+ end
+ end
+
+ def current_itemconfiginfo(tagOrId, slot = nil)
+ __current_itemconfiginfo(tagOrId, slot)
+ end
+end
diff --git a/jni/ruby/ext/tk/lib/tk/itemfont.rb b/jni/ruby/ext/tk/lib/tk/itemfont.rb
new file mode 100644
index 0000000..b5da4fa
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tk/itemfont.rb
@@ -0,0 +1,327 @@
+#
+# tk/itemfont.rb : control font of widget items
+#
+require 'tk'
+
+module TkItemFontOptkeys
+ def __item_font_optkeys(id)
+ # maybe need to override
+ ['font']
+ end
+ private :__item_font_optkeys
+end
+
+module TkTreatItemFont
+ include TkItemFontOptkeys
+
+ def __item_pathname(id)
+ # maybe need to override
+ [self.path, id].join(';')
+ end
+ private :__item_pathname
+
+ ################################################
+
+ def tagfont_configinfo(tagOrId, key = nil)
+ optkeys = __item_font_optkeys(tagid(tagOrId))
+ if key && !optkeys.find{|opt| opt.to_s == key.to_s}
+ fail ArgumentError, "unknown font option name `#{key}'"
+ end
+
+ win, tag = __item_pathname(tagid(tagOrId)).split(';')
+
+ if key
+ pathname = [win, tag, key].join(';')
+ TkFont.used_on(pathname) ||
+ TkFont.init_widget_font(pathname,
+ *(__item_confinfo_cmd(tagid(tagOrId))))
+ elsif optkeys.size == 1
+ pathname = [win, tag, optkeys[0]].join(';')
+ TkFont.used_on(pathname) ||
+ TkFont.init_widget_font(pathname,
+ *(__item_confinfo_cmd(tagid(tagOrId))))
+ else
+ fonts = {}
+ optkeys.each{|key|
+ key = key.to_s
+ pathname = [win, tag, key].join(';')
+ fonts[key] =
+ TkFont.used_on(pathname) ||
+ TkFont.init_widget_font(pathname,
+ *(__item_confinfo_cmd(tagid(tagOrId))))
+ }
+ fonts
+ end
+ end
+ alias tagfontobj tagfont_configinfo
+
+ def tagfont_configure(tagOrId, slot)
+ pathname = __item_pathname(tagid(tagOrId))
+
+ slot = _symbolkey2str(slot)
+
+ __item_font_optkeys(tagid(tagOrId)).each{|optkey|
+ optkey = optkey.to_s
+ l_optkey = 'latin' << optkey
+ a_optkey = 'ascii' << optkey
+ k_optkey = 'kanji' << optkey
+
+ if slot.key?(optkey)
+ fnt = slot.delete(optkey)
+ if fnt.kind_of?(TkFont)
+ slot.delete(l_optkey)
+ slot.delete(a_optkey)
+ slot.delete(k_optkey)
+
+ fnt.call_font_configure([pathname, optkey],
+ *(__item_config_cmd(tagid(tagOrId)) << {}))
+ next
+ else
+ if fnt
+ if (slot.key?(l_optkey) ||
+ slot.key?(a_optkey) ||
+ slot.key?(k_optkey))
+ fnt = TkFont.new(fnt)
+
+ lfnt = slot.delete(l_optkey)
+ lfnt = slot.delete(a_optkey) if slot.key?(a_optkey)
+ kfnt = slot.delete(k_optkey)
+
+ fnt.latin_replace(lfnt) if lfnt
+ fnt.kanji_replace(kfnt) if kfnt
+
+ fnt.call_font_configure([pathname, optkey],
+ *(__item_config_cmd(tagid(tagOrId)) << {}))
+ next
+ else
+ fnt = hash_kv(fnt) if fnt.kind_of?(Hash)
+ unless TkItemConfigMethod.__IGNORE_UNKNOWN_CONFIGURE_OPTION__
+ tk_call(*(__item_config_cmd(tagid(tagOrId)) << "-#{optkey}" << fnt))
+ else
+ begin
+ tk_call(*(__item_config_cmd(tagid(tagOrId)) << "-#{optkey}" << fnt))
+ rescue => e
+ # ignore
+ end
+ end
+ end
+ end
+ next
+ end
+ end
+
+ lfnt = slot.delete(l_optkey)
+ lfnt = slot.delete(a_optkey) if slot.key?(a_optkey)
+ kfnt = slot.delete(k_optkey)
+
+ if lfnt && kfnt
+ TkFont.new(lfnt, kfnt).call_font_configure([pathname, optkey],
+ *(__item_config_cmd(tagid(tagOrId)) << {}))
+ elsif lfnt
+ latintagfont_configure([lfnt, optkey])
+ elsif kfnt
+ kanjitagfont_configure([kfnt, optkey])
+ end
+ }
+
+ # configure other (without font) options
+ tk_call(*(__item_config_cmd(tagid(tagOrId)).concat(hash_kv(slot)))) if slot != {}
+ self
+ end
+
+ def latintagfont_configure(tagOrId, ltn, keys=nil)
+ if ltn.kind_of?(Array)
+ key = ltn[1]
+ ltn = ltn[0]
+ else
+ key = nil
+ end
+
+ optkeys = __item_font_optkeys(tagid(tagOrId))
+ if key && !optkeys.find{|opt| opt.to_s == key.to_s}
+ fail ArgumentError, "unknown font option name `#{key}'"
+ end
+
+ win, tag = __item_pathname(tagid(tagOrId)).split(';')
+
+ optkeys = [key] if key
+
+ optkeys.each{|optkey|
+ optkey = optkey.to_s
+
+ pathname = [win, tag, optkey].join(';')
+
+ if (fobj = TkFont.used_on(pathname))
+ fobj = TkFont.new(fobj) # create a new TkFont object
+ elsif Tk::JAPANIZED_TK
+ fobj = fontobj # create a new TkFont object
+ else
+ ltn = hash_kv(ltn) if ltn.kind_of?(Hash)
+ unless TkItemConfigMethod.__IGNORE_UNKNOWN_CONFIGURE_OPTION__
+ tk_call(*(__item_config_cmd(tagid(tagOrId)) << "-#{optkey}" << ltn))
+ else
+ begin
+ tk_call(*(__item_config_cmd(tagid(tagOrId)) << "-#{optkey}" << ltn))
+ rescue => e
+ # ignore
+ end
+ end
+ next
+ end
+
+ if fobj.kind_of?(TkFont)
+ if ltn.kind_of?(TkFont)
+ conf = {}
+ ltn.latin_configinfo.each{|key,val| conf[key] = val}
+ if keys
+ fobj.latin_configure(conf.update(keys))
+ else
+ fobj.latin_configure(conf)
+ end
+ else
+ fobj.latin_replace(ltn)
+ end
+ end
+
+ fobj.call_font_configure([pathname, optkey], *(__item_config_cmd(tagid(tagOrId)) << {}))
+ }
+ self
+ end
+ alias asciitagfont_configure latintagfont_configure
+
+ def kanjitagfont_configure(tagOrId, knj, keys=nil)
+ if knj.kind_of?(Array)
+ key = knj[1]
+ knj = knj[0]
+ else
+ key = nil
+ end
+
+ optkeys = __item_font_optkeys(tagid(tagOrId))
+ if key && !optkeys.find{|opt| opt.to_s == key.to_s}
+ fail ArgumentError, "unknown font option name `#{key}'"
+ end
+
+ win, tag = __item_pathname(tagid(tagOrId)).split(';')
+
+ optkeys = [key] if key
+
+ optkeys.each{|optkey|
+ optkey = optkey.to_s
+
+ pathname = [win, tag, optkey].join(';')
+
+ if (fobj = TkFont.used_on(pathname))
+ fobj = TkFont.new(fobj) # create a new TkFont object
+ elsif Tk::JAPANIZED_TK
+ fobj = fontobj # create a new TkFont object
+ else
+ knj = hash_kv(knj) if knj.kind_of?(Hash)
+ unless TkItemConfigMethod.__IGNORE_UNKNOWN_CONFIGURE_OPTION__
+ tk_call(*(__item_config_cmd(tagid(tagOrId)) << "-#{optkey}" << knj))
+ else
+ begin
+ tk_call(*(__item_config_cmd(tagid(tagOrId)) << "-#{optkey}" << knj))
+ rescue => e
+ # ignore
+ end
+ end
+ next
+ end
+
+ if fobj.kind_of?(TkFont)
+ if knj.kind_of?(TkFont)
+ conf = {}
+ knj.kanji_configinfo.each{|key,val| conf[key] = val}
+ if keys
+ fobj.kanji_configure(conf.update(keys))
+ else
+ fobj.kanji_configure(conf)
+ end
+ else
+ fobj.kanji_replace(knj)
+ end
+ end
+
+ fobj.call_font_configure([pathname, optkey], *(__item_config_cmd(tagid(tagOrId)) << {}))
+ }
+ self
+ end
+
+ def tagfont_copy(tagOrId, win, wintag=nil, winkey=nil, targetkey=nil)
+ if wintag
+ if winkey
+ fnt = win.tagfontobj(wintag, winkey).dup
+ else
+ fnt = win.tagfontobj(wintag).dup
+ end
+ else
+ if winkey
+ fnt = win.fontobj(winkey).dup
+ else
+ fnt = win.fontobj.dup
+ end
+ end
+
+ if targetkey
+ fnt.call_font_configure([__item_pathname(tagid(tagOrId)), targetkey],
+ *(__item_config_cmd(tagid(tagOrId)) << {}))
+ else
+ fnt.call_font_configure(__item_pathname(tagid(tagOrId)),
+ *(__item_config_cmd(tagid(tagOrId)) << {}))
+ end
+ self
+ end
+
+
+ def latintagfont_copy(tagOrId, win, wintag=nil, winkey=nil, targetkey=nil)
+ if targetkey
+ fontobj(targetkey).dup.call_font_configure([__item_pathname(tagid(tagOrId)), targetkey],
+ *(__item_config_cmd(tagid(tagOrId)) << {}))
+ else
+ fontobj.dup.call_font_configure(__item_pathname(tagid(tagOrId)),
+ *(__item_config_cmd(tagid(tagOrId)) << {}))
+ end
+
+ if wintag
+ if winkey
+ fontobj.latin_replace(win.tagfontobj(wintag, winkey).latin_font_id)
+ else
+ fontobj.latin_replace(win.tagfontobj(wintag).latin_font_id)
+ end
+ else
+ if winkey
+ fontobj.latin_replace(win.fontobj(winkey).latin_font_id)
+ else
+ fontobj.latin_replace(win.fontobj.latin_font_id)
+ end
+ end
+ self
+ end
+ alias asciitagfont_copy latintagfont_copy
+
+ def kanjifont_copy(tagOrId, win, wintag=nil, winkey=nil, targetkey=nil)
+ if targetkey
+ fontobj(targetkey).dup.call_font_configure([__item_pathname(tagid(tagOrId)), targetkey],
+ *(__item_config_cmd(tagid(tagOrId)) << {}))
+ else
+ fontobj.dup.call_font_configure(__item_pathname(tagid(tagOrId)),
+ *(__item_config_cmd(tagid(tagOrId)) << {}))
+ end
+
+ if wintag
+ if winkey
+ fontobj.kanji_replace(win.tagfontobj(wintag, winkey).kanji_font_id)
+ else
+ fontobj.kanji_replace(win.tagfontobj(wintag).kanji_font_id)
+ end
+ else
+ if winkey
+ fontobj.kanji_replace(win.fontobj(winkey).kanji_font_id)
+ else
+ fontobj.kanji_replace(win.fontobj.kanji_font_id)
+ end
+ end
+ self
+ end
+end
diff --git a/jni/ruby/ext/tk/lib/tk/kinput.rb b/jni/ruby/ext/tk/lib/tk/kinput.rb
new file mode 100644
index 0000000..b63f756
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tk/kinput.rb
@@ -0,0 +1,71 @@
+#
+# tk/kinput.rb : control kinput
+#
+require 'tk'
+
+module TkKinput
+ include Tk
+ extend Tk
+
+ TkCommandNames = [
+ 'kinput_start'.freeze,
+ 'kinput_send_spot'.freeze,
+ 'kanjiInput'.freeze
+ ].freeze
+
+ def TkKinput.start(win, style=None)
+ tk_call('kinput_start', win, style)
+ end
+ def kinput_start(style=None)
+ TkKinput.start(self, style)
+ end
+
+ def TkKinput.send_spot(win)
+ tk_call('kinput_send_spot', win)
+ end
+ def kinput_send_spot
+ TkKinput.send_spot(self)
+ end
+
+ def TkKinput.input_start(win, keys=nil)
+ tk_call('kanjiInput', 'start', win, *hash_kv(keys))
+ end
+ def kanji_input_start(keys=nil)
+ TkKinput.input_start(self, keys)
+ end
+
+ def TkKinput.attribute_config(win, slot, value=None)
+ if slot.kind_of? Hash
+ tk_call('kanjiInput', 'attribute', win, *hash_kv(slot))
+ else
+ tk_call('kanjiInput', 'attribute', win, "-#{slot}", value)
+ end
+ end
+ def kinput_attribute_config(slot, value=None)
+ TkKinput.attribute_config(self, slot, value)
+ end
+
+ def TkKinput.attribute_info(win, slot=nil)
+ if slot
+ conf = tk_split_list(tk_call('kanjiInput', 'attribute',
+ win, "-#{slot}"))
+ conf[0] = conf[0][1..-1]
+ conf
+ else
+ tk_split_list(tk_call('kanjiInput', 'attribute', win)).collect{|conf|
+ conf[0] = conf[0][1..-1]
+ conf
+ }
+ end
+ end
+ def kinput_attribute_info(slot=nil)
+ TkKinput.attribute_info(self, slot)
+ end
+
+ def TkKinput.input_end(win)
+ tk_call('kanjiInput', 'end', win)
+ end
+ def kanji_input_end
+ TkKinput.input_end(self)
+ end
+end
diff --git a/jni/ruby/ext/tk/lib/tk/label.rb b/jni/ruby/ext/tk/lib/tk/label.rb
new file mode 100644
index 0000000..05e430e
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tk/label.rb
@@ -0,0 +1,22 @@
+#
+# tk/label.rb : treat label widget
+#
+require 'tk'
+
+class Tk::Label<TkWindow
+ TkCommandNames = ['label'.freeze].freeze
+ WidgetClassName = 'Label'.freeze
+ WidgetClassNames[WidgetClassName] ||= self
+ #def create_self(keys)
+ # if keys and keys != None
+ # tk_call_without_enc('label', @path, *hash_kv(keys, true))
+ # else
+ # tk_call_without_enc('label', @path)
+ # end
+ #end
+ #private :create_self
+end
+
+#TkLabel = Tk::Label unless Object.const_defined? :TkLabel
+#Tk.__set_toplevel_aliases__(:Tk, Tk::Label, :TkLabel)
+Tk.__set_loaded_toplevel_aliases__('tk/label.rb', :Tk, Tk::Label, :TkLabel)
diff --git a/jni/ruby/ext/tk/lib/tk/labelframe.rb b/jni/ruby/ext/tk/lib/tk/labelframe.rb
new file mode 100644
index 0000000..6f679e5
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tk/labelframe.rb
@@ -0,0 +1,31 @@
+#
+# tk/labelframe.rb : treat labelframe widget
+#
+require 'tk'
+require 'tk/frame'
+
+class Tk::LabelFrame<Tk::Frame
+ TkCommandNames = ['labelframe'.freeze].freeze
+ WidgetClassName = 'Labelframe'.freeze
+ WidgetClassNames[WidgetClassName] ||= self
+ #def create_self(keys)
+ # if keys and keys != None
+ # tk_call_without_enc('labelframe', @path, *hash_kv(keys, true))
+ # else
+ # tk_call_without_enc('labelframe', @path)
+ # end
+ #end
+ #private :create_self
+
+ def __val2ruby_optkeys # { key=>proc, ... }
+ super().update('labelwidget'=>proc{|v| window(v)})
+ end
+ private :__val2ruby_optkeys
+end
+
+Tk::Labelframe = Tk::LabelFrame
+#TkLabelFrame = Tk::LabelFrame unless Object.const_defined? :TkLabelFrame
+#TkLabelframe = Tk::Labelframe unless Object.const_defined? :TkLabelframe
+#Tk.__set_toplevel_aliases__(:Tk, Tk::LabelFrame, :TkLabelFrame, :TkLabelframe)
+Tk.__set_loaded_toplevel_aliases__('tk/labelframe.rb', :Tk, Tk::LabelFrame,
+ :TkLabelFrame, :TkLabelframe)
diff --git a/jni/ruby/ext/tk/lib/tk/listbox.rb b/jni/ruby/ext/tk/lib/tk/listbox.rb
new file mode 100644
index 0000000..6742b21
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tk/listbox.rb
@@ -0,0 +1,284 @@
+#
+# tk/listbox.rb : treat listbox widget
+#
+require 'tk'
+require 'tk/itemconfig'
+require 'tk/scrollable'
+require 'tk/txtwin_abst'
+
+module TkListItemConfig
+ include TkItemConfigMethod
+
+ def __item_listval_optkeys(id)
+ []
+ end
+ private :__item_listval_optkeys
+end
+
+class Tk::Listbox<TkTextWin
+ include TkListItemConfig
+ include Scrollable
+
+ TkCommandNames = ['listbox'.freeze].freeze
+ WidgetClassName = 'Listbox'.freeze
+ WidgetClassNames[WidgetClassName] ||= self
+
+ #def create_self(keys)
+ # if keys and keys != None
+ # tk_call_without_enc('listbox', @path, *hash_kv(keys, true))
+ # else
+ # tk_call_without_enc('listbox', @path)
+ # end
+ #end
+ #private :create_self
+
+ def __tkvariable_optkeys
+ super() << 'listvariable'
+ end
+ private :__tkvariable_optkeys
+
+ def tagid(id)
+ #id.to_s
+ _get_eval_string(id)
+ end
+
+ def activate(y)
+ tk_send_without_enc('activate', y)
+ self
+ end
+ def curselection
+ list(tk_send_without_enc('curselection'))
+ end
+ def get(first, last=nil)
+ if last
+ # tk_split_simplelist(_fromUTF8(tk_send_without_enc('get', first, last)))
+ tk_split_simplelist(tk_send_without_enc('get', first, last), false, true)
+ else
+ _fromUTF8(tk_send_without_enc('get', first))
+ end
+ end
+ def nearest(y)
+ tk_send_without_enc('nearest', y).to_i
+ end
+ def size
+ tk_send_without_enc('size').to_i
+ end
+ def selection_anchor(index)
+ tk_send_without_enc('selection', 'anchor', index)
+ self
+ end
+ def selection_clear(first, last=None)
+ tk_send_without_enc('selection', 'clear', first, last)
+ self
+ end
+ def selection_includes(index)
+ bool(tk_send_without_enc('selection', 'includes', index))
+ end
+ def selection_set(first, last=None)
+ tk_send_without_enc('selection', 'set', first, last)
+ self
+ end
+
+ def index(idx)
+ tk_send_without_enc('index', idx).to_i
+ end
+
+ def value
+ get('0', 'end')
+ end
+
+ def value= (vals)
+ unless vals.kind_of?(Array)
+ fail ArgumentError, 'an Array is expected'
+ end
+ tk_send_without_enc('delete', '0', 'end')
+ tk_send_without_enc('insert', '0',
+ *(vals.collect{|v| _get_eval_enc_str(v)}))
+ vals
+ end
+
+ def clear
+ tk_send_without_enc('delete', '0', 'end')
+ self
+ end
+ alias erase clear
+
+=begin
+ def itemcget(index, key)
+ case key.to_s
+ when 'text', 'label', 'show'
+ _fromUTF8(tk_send_without_enc('itemcget', index, "-#{key}"))
+ when 'font', 'kanjifont'
+ #fnt = tk_tcl2ruby(tk_send('itemcget', index, "-#{key}"))
+ fnt = tk_tcl2ruby(_fromUTF8(tk_send_without_enc('itemcget', index,
+ '-font')))
+ unless fnt.kind_of?(TkFont)
+ fnt = tagfontobj(index, fnt)
+ end
+ if key.to_s == 'kanjifont' && JAPANIZED_TK && TK_VERSION =~ /^4\.*/
+ # obsolete; just for compatibility
+ fnt.kanji_font
+ else
+ fnt
+ end
+ else
+ tk_tcl2ruby(_fromUTF8(tk_send_without_enc('itemcget', index, "-#{key}")))
+ end
+ end
+ def itemconfigure(index, key, val=None)
+ if key.kind_of? Hash
+ if (key['font'] || key[:font] ||
+ key['kanjifont'] || key[:kanjifont] ||
+ key['latinfont'] || key[:latinfont] ||
+ key['asciifont'] || key[:asciifont] )
+ tagfont_configure(index, _symbolkey2str(key))
+ else
+ tk_send_without_enc('itemconfigure', index, *hash_kv(key, true))
+ end
+
+ else
+ if (key == 'font' || key == :font ||
+ key == 'kanjifont' || key == :kanjifont ||
+ key == 'latinfont' || key == :latinfont ||
+ key == 'asciifont' || key == :asciifont )
+ if val == None
+ tagfontobj(index)
+ else
+ tagfont_configure(index, {key=>val})
+ end
+ else
+ tk_call('itemconfigure', index, "-#{key}", val)
+ end
+ end
+ self
+ end
+
+ def itemconfiginfo(index, key=nil)
+ if TkComm::GET_CONFIGINFO_AS_ARRAY
+ if key
+ case key.to_s
+ when 'text', 'label', 'show'
+ conf = tk_split_simplelist(_fromUTF8(tk_send_without_enc('itemconfigure',index,"-#{key}")))
+ when 'font', 'kanjifont'
+ conf = tk_split_simplelist(_fromUTF8(tk_send_without_enc('itemconfigure',index,"-#{key}")))
+ conf[4] = tagfont_configinfo(index, conf[4])
+ else
+ conf = tk_split_list(_fromUTF8(tk_send_without_enc('itemconfigure',index,"-#{key}")))
+ end
+ conf[0] = conf[0][1..-1]
+ conf
+ else
+ ret = tk_split_simplelist(_fromUTF8(tk_send_without_enc('itemconfigure', index))).collect{|conflist|
+ conf = tk_split_simplelist(conflist)
+ conf[0] = conf[0][1..-1]
+ case conf[0]
+ when 'text', 'label', 'show'
+ else
+ if conf[3]
+ if conf[3].index('{')
+ conf[3] = tk_split_list(conf[3])
+ else
+ conf[3] = tk_tcl2ruby(conf[3])
+ end
+ end
+ if conf[4]
+ if conf[4].index('{')
+ conf[4] = tk_split_list(conf[4])
+ else
+ conf[4] = tk_tcl2ruby(conf[4])
+ end
+ end
+ end
+ conf[1] = conf[1][1..-1] if conf.size == 2 # alias info
+ conf
+ }
+ fontconf = ret.assoc('font')
+ if fontconf
+ ret.delete_if{|item| item[0] == 'font' || item[0] == 'kanjifont'}
+ fontconf[4] = tagfont_configinfo(index, fontconf[4])
+ ret.push(fontconf)
+ else
+ ret
+ end
+ end
+ else # ! TkComm::GET_CONFIGINFO_AS_ARRAY
+ if key
+ case key.to_s
+ when 'text', 'label', 'show'
+ conf = tk_split_simplelist(_fromUTF8(tk_send_without_enc('itemconfigure',index,"-#{key}")))
+ when 'font', 'kanjifont'
+ conf = tk_split_simplelist(_fromUTF8(tk_send_without_enc('itemconfigure',index,"-#{key}")))
+ conf[4] = tagfont_configinfo(index, conf[4])
+ else
+ conf = tk_split_list(_fromUTF8(tk_send_without_enc('itemconfigure',index,"-#{key}")))
+ end
+ key = conf.shift[1..-1]
+ { key => conf }
+ else
+ ret = {}
+ tk_split_simplelist(_fromUTF8(tk_send_without_enc('itemconfigure', index))).each{|conflist|
+ conf = tk_split_simplelist(conflist)
+ key = conf.shift[1..-1]
+ case key
+ when 'text', 'label', 'show'
+ else
+ if conf[2]
+ if conf[2].index('{')
+ conf[2] = tk_split_list(conf[2])
+ else
+ conf[2] = tk_tcl2ruby(conf[2])
+ end
+ end
+ if conf[3]
+ if conf[3].index('{')
+ conf[3] = tk_split_list(conf[3])
+ else
+ conf[3] = tk_tcl2ruby(conf[3])
+ end
+ end
+ end
+ if conf.size == 1
+ ret[key] = conf[0][1..-1] # alias info
+ else
+ ret[key] = conf
+ end
+ }
+ fontconf = ret['font']
+ if fontconf
+ ret.delete('font')
+ ret.delete('kanjifont')
+ fontconf[3] = tagfont_configinfo(index, fontconf[3])
+ ret['font'] = fontconf
+ end
+ ret
+ end
+ end
+ end
+
+ def current_itemconfiginfo(index, key=nil)
+ if TkComm::GET_CONFIGINFO_AS_ARRAY
+ if key
+ conf = itemconfiginfo(index, key)
+ {conf[0] => conf[4]}
+ else
+ ret = {}
+ itemconfiginfo(index).each{|conf|
+ ret[conf[0]] = conf[4] if conf.size > 2
+ }
+ ret
+ end
+ else # ! TkComm::GET_CONFIGINFO_AS_ARRAY
+ ret = {}
+ itemconfiginfo(index, key).each{|k, conf|
+ ret[k] = conf[-1] if conf.kind_of?(Array)
+ }
+ ret
+ end
+ end
+=end
+end
+
+#TkListbox = Tk::Listbox unless Object.const_defined? :TkListbox
+#Tk.__set_toplevel_aliases__(:Tk, Tk::Listbox, :TkListbox)
+Tk.__set_loaded_toplevel_aliases__('tk/listbox.rb', :Tk, Tk::Listbox,
+ :TkListbox)
diff --git a/jni/ruby/ext/tk/lib/tk/macpkg.rb b/jni/ruby/ext/tk/lib/tk/macpkg.rb
new file mode 100644
index 0000000..3ca7953
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tk/macpkg.rb
@@ -0,0 +1,80 @@
+#
+# tk/macpkg.rb : methods for Tcl/Tk packages for Macintosh
+# 2000/11/22 by Hidetoshi Nagai <nagai@ai.kyutech.ac.jp>
+#
+# ATTENTION !!
+# This is NOT TESTED. Because I have no test-environment.
+#
+#
+require 'tk'
+
+module Tk
+ def Tk.load_tclscript_rsrc(resource_name, file=None)
+ # Mac only
+ tk_call('source', '-rsrc', resource_name, file)
+ end
+
+ def Tk.load_tclscript_rsrcid(resource_id, file=None)
+ # Mac only
+ tk_call('source', '-rsrcid', resource_id, file)
+ end
+end
+
+module Tk::MacResource
+end
+#TkMacResource = Tk::MacResource
+#Tk.__set_toplevel_aliases__(:Tk, Tk::MacResource, :TkMacResource)
+Tk.__set_loaded_toplevel_aliases__('tk/macpkg.rb', :Tk, Tk::MacResource,
+ :TkMacResource)
+
+module Tk::MacResource
+ extend Tk
+ extend Tk::MacResource
+
+ TkCommandNames = ['resource'.freeze].freeze
+
+ PACKAGE_NAME = 'resource'.freeze
+ def self.package_name
+ PACKAGE_NAME
+ end
+
+ tk_call_without_enc('package', 'require', 'resource')
+
+ def close(rsrcRef)
+ tk_call('resource', 'close', rsrcRef)
+ end
+
+ def delete(rsrcType, opts=nil)
+ tk_call('resource', 'delete', *(hash_kv(opts) << rsrcType))
+ end
+
+ def files(rsrcRef=nil)
+ if rsrcRef
+ tk_call('resource', 'files', rsrcRef)
+ else
+ tk_split_simplelist(tk_call('resource', 'files'))
+ end
+ end
+
+ def list(rsrcType, rsrcRef=nil)
+ tk_split_simplelist(tk_call('resource', 'list', rsrcType, rsrcRef))
+ end
+
+ def open(fname, access=nil)
+ tk_call('resource', 'open', fname, access)
+ end
+
+ def read(rsrcType, rsrcID, rsrcRef=nil)
+ tk_call('resource', 'read', rsrcType, rsrcID, rsrcRef)
+ end
+
+ def types(rsrcRef=nil)
+ tk_split_simplelist(tk_call('resource', 'types', rsrcRef))
+ end
+
+ def write(rsrcType, data, opts=nil)
+ tk_call('resource', 'write', *(hash_kv(opts) << rsrcType << data))
+ end
+
+ module_function :close, :delete, :files, :list, :open, :read, :types, :write
+end
diff --git a/jni/ruby/ext/tk/lib/tk/menu.rb b/jni/ruby/ext/tk/lib/tk/menu.rb
new file mode 100644
index 0000000..bcd2500
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tk/menu.rb
@@ -0,0 +1,718 @@
+#
+# tk/menu.rb : treat menu and menubutton
+#
+require 'tk'
+require 'tk/itemconfig'
+require 'tk/menuspec'
+
+module TkMenuEntryConfig
+ include TkItemConfigMethod
+
+ def __item_cget_cmd(id)
+ [self.path, 'entrycget', id]
+ end
+ private :__item_cget_cmd
+
+ def __item_config_cmd(id)
+ [self.path, 'entryconfigure', id]
+ end
+ private :__item_config_cmd
+
+ def __item_strval_optkeys(id)
+ super(id) << 'selectcolor'
+ end
+ private :__item_strval_optkeys
+
+ def __item_listval_optkeys(id)
+ []
+ end
+ private :__item_listval_optkeys
+
+ def __item_val2ruby_optkeys(id) # { key=>proc, ... }
+ super(id).update('menu'=>proc{|i, v| window(v)})
+ end
+ private :__item_val2ruby_optkeys
+
+ alias entrycget_tkstring itemcget_tkstring
+ alias entrycget itemcget
+ alias entrycget_strict itemcget_strict
+ alias entryconfigure itemconfigure
+ alias entryconfiginfo itemconfiginfo
+ alias current_entryconfiginfo current_itemconfiginfo
+
+ private :itemcget_tkstring, :itemcget, :itemcget_strict
+ private :itemconfigure, :itemconfiginfo, :current_itemconfiginfo
+end
+
+class Tk::Menu<TkWindow
+ include Wm
+ include TkMenuEntryConfig
+ extend TkMenuSpec
+
+ TkCommandNames = ['menu'.freeze].freeze
+ WidgetClassName = 'Menu'.freeze
+ WidgetClassNames[WidgetClassName] ||= self
+
+ #def create_self(keys)
+ # if keys and keys != None
+ # tk_call_without_enc('menu', @path, *hash_kv(keys, true))
+ # else
+ # tk_call_without_enc('menu', @path)
+ # end
+ #end
+ #private :create_self
+
+ def __strval_optkeys
+ super() << 'selectcolor' << 'title'
+ end
+ private :__strval_optkeys
+
+ def __boolval_optkeys
+ super() << 'tearoff'
+ end
+ private :__boolval_optkeys
+
+ def self.new_menuspec(menu_spec, parent = nil, tearoff = false, keys = nil)
+ if parent.kind_of?(Hash)
+ keys = _symbolkey2str(parent)
+ parent = keys.delete('parent')
+ tearoff = keys.delete('tearoff')
+ elsif tearoff.kind_of?(Hash)
+ keys = _symbolkey2str(tearoff)
+ tearoff = keys.delete('tearoff')
+ elsif keys
+ keys = _symbolkey2str(keys)
+ else
+ keys = {}
+ end
+
+ widgetname = keys.delete('widgetname')
+ _create_menu(parent, menu_spec, widgetname, tearoff, keys)
+ end
+
+ def tagid(id)
+ #id.to_s
+ _get_eval_string(id)
+ end
+
+ def activate(index)
+ tk_send_without_enc('activate', _get_eval_enc_str(index))
+ self
+ end
+ def add(type, keys=nil)
+ tk_send_without_enc('add', type, *hash_kv(keys, true))
+ self
+ end
+ def add_cascade(keys=nil)
+ add('cascade', keys)
+ end
+ def add_checkbutton(keys=nil)
+ add('checkbutton', keys)
+ end
+ def add_command(keys=nil)
+ add('command', keys)
+ end
+ def add_radiobutton(keys=nil)
+ add('radiobutton', keys)
+ end
+ def add_separator(keys=nil)
+ add('separator', keys)
+ end
+
+ def clone_menu(*args)
+ if args[0].kind_of?(TkWindow)
+ parent = args.shift
+ else
+ parent = self
+ end
+
+ if args[0].kind_of?(String) || args[0].kind_of?(Symbol) # menu type
+ type = args.shift
+ else
+ type = None # 'normal'
+ end
+
+ if args[0].kind_of?(Hash)
+ keys = _symbolkey2str(args.shift)
+ else
+ keys = {}
+ end
+
+ parent = keys.delete('parent') if keys.has_key?('parent')
+ type = keys.delete('type') if keys.has_key?('type')
+
+ if keys.empty?
+ Tk::MenuClone.new(self, parent, type)
+ else
+ Tk::MenuClone.new(self, parent, type, keys)
+ end
+ end
+
+ def index(idx)
+ ret = tk_send_without_enc('index', _get_eval_enc_str(idx))
+ (ret == 'none')? nil: number(ret)
+ end
+ def invoke(index)
+ _fromUTF8(tk_send_without_enc('invoke', _get_eval_enc_str(index)))
+ end
+ def insert(index, type, keys=nil)
+ tk_send_without_enc('insert', _get_eval_enc_str(index),
+ type, *hash_kv(keys, true))
+ self
+ end
+ def delete(first, last=nil)
+ if last
+ tk_send_without_enc('delete', _get_eval_enc_str(first),
+ _get_eval_enc_str(last))
+ else
+ tk_send_without_enc('delete', _get_eval_enc_str(first))
+ end
+ self
+ end
+ def popup(x, y, index=nil)
+ if index
+ tk_call_without_enc('tk_popup', path, x, y,
+ _get_eval_enc_str(index))
+ else
+ tk_call_without_enc('tk_popup', path, x, y)
+ end
+ self
+ end
+ def post(x, y)
+ _fromUTF8(tk_send_without_enc('post', x, y))
+ end
+ def postcascade(index)
+ tk_send_without_enc('postcascade', _get_eval_enc_str(index))
+ self
+ end
+ def postcommand(cmd=Proc.new)
+ configure_cmd 'postcommand', cmd
+ self
+ end
+ def set_focus
+ tk_call_without_enc('tk_menuSetFocus', path)
+ self
+ end
+ def tearoffcommand(cmd=Proc.new)
+ configure_cmd 'tearoffcommand', cmd
+ self
+ end
+ def menutype(index)
+ tk_send_without_enc('type', _get_eval_enc_str(index))
+ end
+ def unpost
+ tk_send_without_enc('unpost')
+ self
+ end
+ def xposition(index)
+ number(tk_send_without_enc('xposition', _get_eval_enc_str(index)))
+ end
+ def yposition(index)
+ number(tk_send_without_enc('yposition', _get_eval_enc_str(index)))
+ end
+
+=begin
+ def entrycget(index, key)
+ case key.to_s
+ when 'text', 'label', 'show'
+ _fromUTF8(tk_send_without_enc('entrycget',
+ _get_eval_enc_str(index), "-#{key}"))
+ when 'font', 'kanjifont'
+ #fnt = tk_tcl2ruby(tk_send('entrycget', index, "-#{key}"))
+ fnt = tk_tcl2ruby(_fromUTF8(tk_send_without_enc('entrycget', _get_eval_enc_str(index), '-font')))
+ unless fnt.kind_of?(TkFont)
+ fnt = tagfontobj(index, fnt)
+ end
+ if key.to_s == 'kanjifont' && JAPANIZED_TK && TK_VERSION =~ /^4\.*/
+ # obsolete; just for compatibility
+ fnt.kanji_font
+ else
+ fnt
+ end
+ else
+ tk_tcl2ruby(_fromUTF8(tk_send_without_enc('entrycget', _get_eval_enc_str(index), "-#{key}")))
+ end
+ end
+ def entryconfigure(index, key, val=None)
+ if key.kind_of? Hash
+ if (key['font'] || key[:font] ||
+ key['kanjifont'] || key[:kanjifont] ||
+ key['latinfont'] || key[:latinfont] ||
+ key['asciifont'] || key[:asciifont])
+ tagfont_configure(index, _symbolkey2str(key))
+ else
+ tk_send_without_enc('entryconfigure', _get_eval_enc_str(index),
+ *hash_kv(key, true))
+ end
+
+ else
+ if (key == 'font' || key == :font ||
+ key == 'kanjifont' || key == :kanjifont ||
+ key == 'latinfont' || key == :latinfont ||
+ key == 'asciifont' || key == :asciifont )
+ if val == None
+ tagfontobj(index)
+ else
+ tagfont_configure(index, {key=>val})
+ end
+ else
+ tk_call('entryconfigure', index, "-#{key}", val)
+ end
+ end
+ self
+ end
+
+ def entryconfiginfo(index, key=nil)
+ if TkComm::GET_CONFIGINFO_AS_ARRAY
+ if key
+ case key.to_s
+ when 'text', 'label', 'show'
+ conf = tk_split_simplelist(_fromUTF8(tk_send_without_enc('entryconfigure',_get_eval_enc_str(index),"-#{key}")))
+ when 'font', 'kanjifont'
+ conf = tk_split_simplelist(_fromUTF8(tk_send_without_enc('entryconfigure',_get_eval_enc_str(index),"-#{key}")))
+ conf[4] = tagfont_configinfo(index, conf[4])
+ else
+ conf = tk_split_list(_fromUTF8(tk_send_without_enc('entryconfigure',_get_eval_enc_str(index),"-#{key}")))
+ end
+ conf[0] = conf[0][1..-1]
+ conf
+ else
+ ret = tk_split_simplelist(_fromUTF8(tk_send_without_enc('entryconfigure', _get_eval_enc_str(index)))).collect{|conflist|
+ conf = tk_split_simplelist(conflist)
+ conf[0] = conf[0][1..-1]
+ case conf[0]
+ when 'text', 'label', 'show'
+ else
+ if conf[3]
+ if conf[3].index('{')
+ conf[3] = tk_split_list(conf[3])
+ else
+ conf[3] = tk_tcl2ruby(conf[3])
+ end
+ end
+ if conf[4]
+ if conf[4].index('{')
+ conf[4] = tk_split_list(conf[4])
+ else
+ conf[4] = tk_tcl2ruby(conf[4])
+ end
+ end
+ end
+ conf[1] = conf[1][1..-1] if conf.size == 2 # alias info
+ conf
+ }
+ if fontconf
+ ret.delete_if{|item| item[0] == 'font' || item[0] == 'kanjifont'}
+ fontconf[4] = tagfont_configinfo(index, fontconf[4])
+ ret.push(fontconf)
+ else
+ ret
+ end
+ end
+ else # ! TkComm::GET_CONFIGINFO_AS_ARRAY
+ if key
+ case key.to_s
+ when 'text', 'label', 'show'
+ conf = tk_split_simplelist(_fromUTF8(tk_send_without_enc('entryconfigure',_get_eval_enc_str(index),"-#{key}")))
+ when 'font', 'kanjifont'
+ conf = tk_split_simplelist(_fromUTF8(tk_send_without_enc('entryconfigure',_get_eval_enc_str(index),"-#{key}")))
+ conf[4] = tagfont_configinfo(index, conf[4])
+ else
+ conf = tk_split_list(_fromUTF8(tk_send_without_enc('entryconfigure',_get_eval_enc_str(index),"-#{key}")))
+ end
+ key = conf.shift[1..-1]
+ { key => conf }
+ else
+ ret = {}
+ tk_split_simplelist(_fromUTF8(tk_send_without_enc('entryconfigure', _get_eval_enc_str(index)))).each{|conflist|
+ conf = tk_split_simplelist(conflist)
+ key = conf.shift[1..-1]
+ case key
+ when 'text', 'label', 'show'
+ else
+ if conf[2]
+ if conf[2].index('{')
+ conf[2] = tk_split_list(conf[2])
+ else
+ conf[2] = tk_tcl2ruby(conf[2])
+ end
+ end
+ if conf[3]
+ if conf[3].index('{')
+ conf[3] = tk_split_list(conf[3])
+ else
+ conf[3] = tk_tcl2ruby(conf[3])
+ end
+ end
+ end
+ if conf.size == 1
+ ret[key] = conf[0][1..-1] # alias info
+ else
+ ret[key] = conf
+ end
+ }
+ fontconf = ret['font']
+ if fontconf
+ ret.delete('font')
+ ret.delete('kanjifont')
+ fontconf[3] = tagfont_configinfo(index, fontconf[3])
+ ret['font'] = fontconf
+ end
+ ret
+ end
+ end
+ end
+
+ def current_entryconfiginfo(index, key=nil)
+ if TkComm::GET_CONFIGINFO_AS_ARRAY
+ if key
+ conf = entryconfiginfo(index, key)
+ {conf[0] => conf[4]}
+ else
+ ret = {}
+ entryconfiginfo(index).each{|conf|
+ ret[conf[0]] = conf[4] if conf.size > 2
+ }
+ ret
+ end
+ else # ! TkComm::GET_CONFIGINFO_AS_ARRAY
+ ret = {}
+ entryconfiginfo(index, key).each{|k, conf|
+ ret[k] = conf[-1] if conf.kind_of?(Array)
+ }
+ ret
+ end
+ end
+=end
+end
+
+#TkMenu = Tk::Menu unless Object.const_defined? :TkMenu
+#Tk.__set_toplevel_aliases__(:Tk, Tk::Menu, :TkMenu)
+Tk.__set_loaded_toplevel_aliases__('tk/menu.rb', :Tk, Tk::Menu, :TkMenu)
+
+
+module Tk::Menu::TkInternalFunction; end
+class << Tk::Menu::TkInternalFunction
+ # These methods calls internal functions of Tcl/Tk.
+ # So, They may not work on your Tcl/Tk.
+ def next_menu(menu, dir='next')
+ dir = dir.to_s
+ case dir
+ when 'next', 'forward', 'down'
+ dir = 'right'
+ when 'previous', 'backward', 'up'
+ dir = 'left'
+ end
+
+ Tk.tk_call('::tk::MenuNextMenu', menu, dir)
+ end
+
+ def next_entry(menu, delta)
+ # delta is increment value of entry index.
+ # For example, +1 denotes 'next entry' and -1 denotes 'previous entry'.
+ Tk.tk_call('::tk::MenuNextEntry', menu, delta)
+ end
+end
+
+class Tk::MenuClone<Tk::Menu
+=begin
+ def initialize(parent, type=None)
+ widgetname = nil
+ if parent.kind_of? Hash
+ keys = _symbolkey2str(parent)
+ parent = keys.delete('parent')
+ widgetname = keys.delete('widgetname')
+ type = keys.delete('type'); type = None unless type
+ end
+ #unless parent.kind_of?(TkMenu)
+ # fail ArgumentError, "parent must be TkMenu"
+ #end
+ @parent = parent
+ install_win(@parent.path, widgetname)
+ tk_call_without_enc(@parent.path, 'clone', @path, type)
+ end
+=end
+ def initialize(src_menu, *args)
+ widgetname = nil
+
+ if args[0].kind_of?(TkWindow) # parent window
+ parent = args.shift
+ else
+ parent = src_menu
+ end
+
+ if args[0].kind_of?(String) || args[0].kind_of?(Symbol) # menu type
+ type = args.shift
+ else
+ type = None # 'normal'
+ end
+
+ if args[0].kind_of?(Hash)
+ keys = _symbolkey2str(args.shift)
+ parent = keys.delete('parent') if keys.has_key?('parent')
+ widgetname = keys.delete('widgetname')
+ type = keys.delete('type') if keys.has_key?('type')
+ else
+ keys = nil
+ end
+
+ @src_menu = src_menu
+ @parent = parent
+ @type = type
+ install_win(@parent.path, widgetname)
+ tk_call_without_enc(@src_menu.path, 'clone', @path, @type)
+ configure(keys) if keys && !keys.empty?
+ end
+
+ def source_menu
+ @src_menu
+ end
+end
+Tk::CloneMenu = Tk::MenuClone
+#TkMenuClone = Tk::MenuClone unless Object.const_defined? :TkMenuClone
+#TkCloneMenu = Tk::CloneMenu unless Object.const_defined? :TkCloneMenu
+#Tk.__set_toplevel_aliases__(:Tk, Tk::MenuClone, :TkMenuClone, :TkCloneMenu)
+Tk.__set_loaded_toplevel_aliases__('tk/menu.rb', :Tk, Tk::MenuClone,
+ :TkMenuClone, :TkCloneMenu)
+
+module Tk::SystemMenu
+ def initialize(parent, keys=nil)
+ if parent.kind_of? Hash
+ keys = _symbolkey2str(parent)
+ parent = keys.delete('parent')
+ end
+ #unless parent.kind_of? TkMenu
+ # fail ArgumentError, "parent must be a TkMenu object"
+ #end
+ # @path = Kernel.format("%s.%s", parent.path, self.class::SYSMENU_NAME)
+ @path = parent.path + '.' + self.class::SYSMENU_NAME
+ #TkComm::Tk_WINDOWS[@path] = self
+ TkCore::INTERP.tk_windows[@path] = self
+ if self.method(:create_self).arity == 0
+ p 'create_self has no arg' if $DEBUG
+ create_self
+ configure(keys) if keys
+ else
+ p 'create_self has an arg' if $DEBUG
+ create_self(keys)
+ end
+ end
+end
+TkSystemMenu = Tk::SystemMenu
+
+
+class Tk::SysMenu_Help<Tk::Menu
+ # for all platform
+ include Tk::SystemMenu
+ SYSMENU_NAME = 'help'
+end
+#TkSysMenu_Help = Tk::SysMenu_Help unless Object.const_defined? :TkSysMenu_Help
+#Tk.__set_toplevel_aliases__(:Tk, Tk::SysMenu_Help, :TkSysMenu_Help)
+Tk.__set_loaded_toplevel_aliases__('tk/menu.rb', :Tk, Tk::SysMenu_Help,
+ :TkSysMenu_Help)
+
+
+class Tk::SysMenu_System<Tk::Menu
+ # for Windows
+ include Tk::SystemMenu
+ SYSMENU_NAME = 'system'
+end
+#TkSysMenu_System = Tk::SysMenu_System unless Object.const_defined? :TkSysMenu_System
+#Tk.__set_toplevel_aliases__(:Tk, Tk::SysMenu_System, :TkSysMenu_System)
+Tk.__set_loaded_toplevel_aliases__('tk/menu.rb', :Tk, Tk::SysMenu_System,
+ :TkSysMenu_System)
+
+
+class Tk::SysMenu_Apple<Tk::Menu
+ # for Machintosh
+ include Tk::SystemMenu
+ SYSMENU_NAME = 'apple'
+end
+#TkSysMenu_Apple = Tk::SysMenu_Apple unless Object.const_defined? :TkSysMenu_Apple
+#Tk.__set_toplevel_aliases__(:Tk, Tk::SysMenu_Apple, :TkSysMenu_Apple)
+Tk.__set_loaded_toplevel_aliases__('tk/menu.rb', :Tk, Tk::SysMenu_Apple,
+ :TkSysMenu_Apple)
+
+
+class Tk::Menubutton<Tk::Label
+ TkCommandNames = ['menubutton'.freeze].freeze
+ WidgetClassName = 'Menubutton'.freeze
+ WidgetClassNames[WidgetClassName] ||= self
+ def create_self(keys)
+ if keys and keys != None
+ unless TkConfigMethod.__IGNORE_UNKNOWN_CONFIGURE_OPTION__
+ # tk_call_without_enc('menubutton', @path, *hash_kv(keys, true))
+ tk_call_without_enc(self.class::TkCommandNames[0], @path,
+ *hash_kv(keys, true))
+ else
+ begin
+ tk_call_without_enc(self.class::TkCommandNames[0], @path,
+ *hash_kv(keys, true))
+ rescue
+ tk_call_without_enc(self.class::TkCommandNames[0], @path)
+ keys = __check_available_configure_options(keys)
+ unless keys.empty?
+ tk_call_without_enc('destroy', @path) rescue nil
+ tk_call_without_enc(self.class::TkCommandNames[0], @path,
+ *hash_kv(keys, true))
+ end
+ end
+ end
+ else
+ # tk_call_without_enc('menubutton', @path)
+ tk_call_without_enc(self.class::TkCommandNames[0], @path)
+ end
+ end
+ private :create_self
+
+ def __boolval_optkeys
+ super() << 'indicatoron'
+ end
+ private :__boolval_optkeys
+
+end
+Tk::MenuButton = Tk::Menubutton
+#TkMenubutton = Tk::Menubutton unless Object.const_defined? :TkMenubutton
+#TkMenuButton = Tk::MenuButton unless Object.const_defined? :TkMenuButton
+#Tk.__set_toplevel_aliases__(:Tk, Tk::Menubutton, :TkMenubutton, :TkMenuButton)
+Tk.__set_loaded_toplevel_aliases__('tk/menu.rb', :Tk, Tk::Menubutton,
+ :TkMenubutton, :TkMenuButton)
+
+
+class Tk::OptionMenubutton<Tk::Menubutton
+ TkCommandNames = ['tk_optionMenu'.freeze].freeze
+
+ class OptionMenu<TkMenu
+ def initialize(path) #==> return value of tk_optionMenu
+ @path = path
+ #TkComm::Tk_WINDOWS[@path] = self
+ TkCore::INTERP.tk_windows[@path] = self
+ end
+ end
+
+ def initialize(*args)
+ # args :: [parent,] [var,] [value[, ...],] [keys]
+ # parent --> TkWindow or nil
+ # var --> TkVariable or nil
+ # keys --> Hash
+ # keys[:parent] or keys['parent'] --> parent
+ # keys[:variable] or keys['variable'] --> var
+ # keys[:values] or keys['values'] --> value, ...
+ # other Hash keys are menubutton options
+ keys = {}
+ keys = args.pop if args[-1].kind_of?(Hash)
+ keys = _symbolkey2str(keys)
+
+ parent = nil
+ if !args.empty? && (args[0].kind_of?(TkWindow) || args[0] == nil)
+ keys.delete('parent') # ignore
+ parent = args.shift
+ else
+ parent = keys.delete('parent')
+ end
+
+ @variable = nil
+ if !args.empty? && (args[0].kind_of?(TkVariable) || args[0] == nil)
+ keys.delete('variable') # ignore
+ @variable = args.shift
+ else
+ @variable = keys.delete('variable')
+ end
+ @variable = TkVariable.new unless @variable
+
+ (args = keys.delete('values') || []) if args.empty?
+ if args.empty?
+ args << @variable.value
+ else
+ @variable.value = args[0]
+ end
+
+ install_win(if parent then parent.path end)
+ @menu = OptionMenu.new(tk_call('tk_optionMenu',
+ @path, @variable.id, *args))
+
+ configure(keys) if keys
+ end
+
+ def value
+ @variable.value
+ end
+
+ def value=(val)
+ @variable.value = val
+ end
+
+ def activate(index)
+ @menu.activate(index)
+ self
+ end
+ def add(value)
+ @menu.add('radiobutton', 'variable'=>@variable,
+ 'label'=>value, 'value'=>value)
+ self
+ end
+ def index(index)
+ @menu.index(index)
+ end
+ def invoke(index)
+ @menu.invoke(index)
+ end
+ def insert(index, value)
+ @menu.insert(index, 'radiobutton', 'variable'=>@variable,
+ 'label'=>value, 'value'=>value)
+ self
+ end
+ def delete(index, last=None)
+ @menu.delete(index, last)
+ self
+ end
+ def xposition(index)
+ @menu.xposition(index)
+ end
+ def yposition(index)
+ @menu.yposition(index)
+ end
+ def menu
+ @menu
+ end
+ def menucget(key)
+ @menu.cget(key)
+ end
+ def menucget_strict(key)
+ @menu.cget_strict(key)
+ end
+ def menuconfigure(key, val=None)
+ @menu.configure(key, val)
+ self
+ end
+ def menuconfiginfo(key=nil)
+ @menu.configinfo(key)
+ end
+ def current_menuconfiginfo(key=nil)
+ @menu.current_configinfo(key)
+ end
+ def entrycget(index, key)
+ @menu.entrycget(index, key)
+ end
+ def entrycget_strict(index, key)
+ @menu.entrycget_strict(index, key)
+ end
+ def entryconfigure(index, key, val=None)
+ @menu.entryconfigure(index, key, val)
+ self
+ end
+ def entryconfiginfo(index, key=nil)
+ @menu.entryconfiginfo(index, key)
+ end
+ def current_entryconfiginfo(index, key=nil)
+ @menu.current_entryconfiginfo(index, key)
+ end
+end
+
+Tk::OptionMenuButton = Tk::OptionMenubutton
+#TkOptionMenubutton = Tk::OptionMenubutton unless Object.const_defined? :TkOptionMenubutton
+#TkOptionMenuButton = Tk::OptionMenuButton unless Object.const_defined? :TkOptionMenuButton
+#Tk.__set_toplevel_aliases__(:Tk, Tk::OptionMenubutton,
+# :TkOptionMenubutton, :TkOptionMenuButton)
+Tk.__set_loaded_toplevel_aliases__('tk/menu.rb', :Tk, Tk::OptionMenubutton,
+ :TkOptionMenubutton, :TkOptionMenuButton)
diff --git a/jni/ruby/ext/tk/lib/tk/menubar.rb b/jni/ruby/ext/tk/lib/tk/menubar.rb
new file mode 100644
index 0000000..9d5571c
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tk/menubar.rb
@@ -0,0 +1,137 @@
+#
+# tk/menubar.rb
+#
+# Original version:
+# Copyright (C) 1998 maeda shugo. All rights reserved.
+# This file can be distributed under the terms of the Ruby.
+
+# Usage:
+#
+# menu_spec = [
+# [['File', 0],
+# ['Open', proc{puts('Open clicked')}, 0],
+# '---',
+# ['Quit', proc{exit}, 0]],
+# [['Edit', 0],
+# ['Cut', proc{puts('Cut clicked')}, 2],
+# ['Copy', proc{puts('Copy clicked')}, 0],
+# ['Paste', proc{puts('Paste clicked')}, 0]]
+# ]
+# menubar = TkMenubar.new(nil, menu_spec,
+# 'tearoff'=>false,
+# 'foreground'=>'grey40',
+# 'activeforeground'=>'red',
+# 'font'=>'-adobe-helvetica-bold-r-*--12-*-iso8859-1')
+# menubar.pack('side'=>'top', 'fill'=>'x')
+#
+#
+# OR
+#
+#
+# menubar = TkMenubar.new
+# menubar.add_menu([['File', 0],
+# ['Open', proc{puts('Open clicked')}, 0],
+# '---',
+# ['Quit', proc{exit}, 0]])
+# menubar.add_menu([['Edit', 0],
+# ['Cut', proc{puts('Cut clicked')}, 2],
+# ['Copy', proc{puts('Copy clicked')}, 0],
+# ['Paste', proc{puts('Paste clicked')}, 0]])
+# menubar.configure('tearoff', false)
+# menubar.configure('foreground', 'grey40')
+# menubar.configure('activeforeground', 'red')
+# menubar.configure('font', '-adobe-helvetica-bold-r-*--12-*-iso8859-1')
+# menubar.pack('side'=>'top', 'fill'=>'x')
+#
+#
+# OR
+#
+# radio_var = TkVariable.new('y')
+# menu_spec = [
+# [['File', 0],
+# {:label=>'Open', :command=>proc{puts('Open clicked')}, :underline=>0},
+# '---',
+# ['Check_A', TkVariable.new(true), 6],
+# {:type=>'checkbutton', :label=>'Check_B',
+# :variable=>TkVariable.new, :underline=>6},
+# '---',
+# ['Radio_X', [radio_var, 'x'], 6],
+# ['Radio_Y', [radio_var, 'y'], 6],
+# ['Radio_Z', [radio_var, 'z'], 6],
+# '---',
+# ['cascade', [
+# ['sss', proc{p 'sss'}, 0],
+# ['ttt', proc{p 'ttt'}, 0],
+# ['uuu', proc{p 'uuu'}, 0],
+# ['vvv', proc{p 'vvv'}, 0],
+# ], 0],
+# '---',
+# ['Quit', proc{exit}, 0]],
+# [['Edit', 0],
+# ['Cut', proc{puts('Cut clicked')}, 2],
+# ['Copy', proc{puts('Copy clicked')}, 0],
+# ['Paste', proc{puts('Paste clicked')}, 0]]
+# ]
+# menubar = TkMenubar.new(nil, menu_spec,
+# 'tearoff'=>false,
+# 'foreground'=>'grey40',
+# 'activeforeground'=>'red',
+# 'font'=>'Helvetia 12 bold')
+# menubar.pack('side'=>'top', 'fill'=>'x')
+
+# See tk/menuspce.rb about the format of the menu_spec
+
+# To use add_menu, configuration must be done by calling configure after
+# adding all menus by add_menu, not by the constructor arguments.
+
+require 'tk'
+require 'tk/frame'
+require 'tk/composite'
+require 'tk/menuspec'
+
+class TkMenubar<Tk::Frame
+ include TkComposite
+ include TkMenuSpec
+
+ def initialize(parent = nil, spec = nil, options = {})
+ if parent.kind_of? Hash
+ options = parent
+ parent = nil
+ spec = (options.has_key?('spec'))? options.delete('spec'): nil
+ end
+
+ _symbolkey2str(options)
+ menuspec_opt = {}
+ TkMenuSpec::MENUSPEC_OPTKEYS.each{|key|
+ menuspec_opt[key] = options.delete(key) if options.has_key?(key)
+ }
+
+ super(parent, options)
+
+ @menus = []
+
+ spec.each{|info| add_menu(info, menuspec_opt)} if spec
+
+ options.each{|key, value| configure(key, value)} if options
+ end
+
+ def add_menu(menu_info, menuspec_opt={})
+ mbtn, menu = _create_menubutton(@frame, menu_info, menuspec_opt)
+
+ submenus = _get_cascade_menus(menu).flatten
+
+ @menus.push([mbtn, menu])
+ delegate('tearoff', menu, *submenus)
+ delegate('foreground', mbtn, menu, *submenus)
+ delegate('background', mbtn, menu, *submenus)
+ delegate('disabledforeground', mbtn, menu, *submenus)
+ delegate('activeforeground', mbtn, menu, *submenus)
+ delegate('activebackground', mbtn, menu, *submenus)
+ delegate('font', mbtn, menu, *submenus)
+ delegate('kanjifont', mbtn, menu, *submenus)
+ end
+
+ def [](index)
+ return @menus[index]
+ end
+end
diff --git a/jni/ruby/ext/tk/lib/tk/menuspec.rb b/jni/ruby/ext/tk/lib/tk/menuspec.rb
new file mode 100644
index 0000000..cb3597e
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tk/menuspec.rb
@@ -0,0 +1,456 @@
+#
+# tk/menuspec.rb
+# Hidethoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+# based on tkmenubar.rb :
+# Copyright (C) 1998 maeda shugo. All rights reserved.
+# This file can be distributed under the terms of the Ruby.
+#
+# The format of the menu_spec is:
+# [ menubutton_info, menubutton_info, ... ]
+#
+# The format of the menubutton_info is:
+# [ menubutton_info, entry_info, entry_info, ... ]
+#
+# And each format of *_info is:
+# [
+# [text, underline, configs], # menu button/entry (*1)
+# [label, command, underline, accelerator, configs], # command entry
+# [label, TkVar_obj, underline, accelerator, configs], # checkbutton entry
+# [label, [TkVar_obj, value],
+# underline, accelerator, configs], # radiobutton entry
+# [label, [[...menu_info...], [...menu_info...], ...],
+# underline, accelerator, configs], # cascade entry (*2)
+# '---', # separator
+# ...
+# ]
+#
+# A menu_info is an array of menu entries:
+# [ entry_info, entry_info, ... ]
+#
+#
+# underline, accelerator, and configs are optional pearameters.
+# Hashes are OK instead of Arrays. Then the entry type ('command',
+# 'checkbutton', 'radiobutton' or 'cascade') is given by 'type' key
+# (e.g. :type=>'cascade'). When type is 'cascade', an array of menu_info
+# is acceptable for 'menu' key (then, create sub-menu).
+#
+# If the value of underline is true instead of an integer,
+# check whether the text/label string contains a '&' character.
+# When includes, the first '&' is removed and its following character is
+# converted the corresponding 'underline' option (first '&' is removed).
+# Else if the value of underline is a String or a Regexp,
+# use the result of label.index(underline) as the index of underline
+# (don't remove matched substring).
+#
+# NOTE: (*1)
+# If you want to make special menus (*.help for UNIX, *.system for Win,
+# and *.apple for Mac), append 'menu_name'=>name (name is 'help' for UNIX,
+# 'system' for Win, and 'apple' for Mac) option to the configs hash of
+# menu button/entry information.
+#
+# NOTE: (*2)
+# If you want to configure a cascade menu, add :menu_config=>{...configs..}
+# to the configs of the cascade entry.
+
+module TkMenuSpec
+ extend TkMenuSpec
+
+ MENUSPEC_OPTKEYS = [ 'layout_proc' ]
+
+ def _create_menu(parent, menu_info, menu_name = nil,
+ tearoff = false, default_opts = nil)
+ if tearoff.kind_of?(Hash)
+ default_opts = tearoff
+ tearoff = false
+ end
+
+ if menu_name.kind_of?(Hash)
+ default_opts = menu_name
+ menu_name = nil
+ tearoff = false
+ end
+
+ if default_opts.kind_of?(Hash)
+ orig_opts = _symbolkey2str(default_opts)
+ else
+ orig_opts = {}
+ end
+
+ tearoff = orig_opts.delete('tearoff') if orig_opts.key?('tearoff')
+ tearoff = false unless tearoff # nil --> false
+
+ if menu_name
+ #menu = Tk::Menu.new(parent, :widgetname=>menu_name, :tearoff=>tearoff)
+ # --> use current TkMenu class
+ menu = TkMenu.new(parent, :widgetname=>menu_name, :tearoff=>tearoff)
+ else
+ #menu = Tk::Menu.new(parent, :tearoff=>tearoff)
+ # --> use current TkMenu class
+ menu = TkMenu.new(parent, :tearoff=>tearoff)
+ end
+
+ for item_info in menu_info
+ if item_info.kind_of?(Hash)
+ options = orig_opts.dup
+ options.update(_symbolkey2str(item_info))
+ item_type = (options.delete('type') || 'command').to_s
+ menu_name = options.delete('menu_name')
+ menu_opts = orig_opts.dup
+ menu_opts.update(_symbolkey2str(options.delete('menu_config') || {}))
+ if item_type == 'cascade' && options['menu'].kind_of?(Array)
+ # create cascade menu
+ submenu = _create_menu(menu, options['menu'], menu_name,
+ tearoff, menu_opts)
+ options['menu'] = submenu
+ end
+ case options['underline']
+ when String, Regexp
+ if options['label'] &&
+ (idx = options['label'].index(options['underline']))
+ options['underline'] = idx
+ else
+ options['underline'] = -1
+ end
+ when true
+ if options['label'] && (idx = options['label'].index('&'))
+ options['label'] = options['label'].dup
+ options['label'][idx] = ''
+ options['underline'] = idx
+ else
+ options['underline'] = -1
+ end
+ end
+ menu.add(item_type, options)
+
+ elsif item_info.kind_of?(Array)
+ options = orig_opts.dup
+
+ options['label'] = item_info[0] if item_info[0]
+
+ case item_info[1]
+ when TkVariable
+ # checkbutton
+ item_type = 'checkbutton'
+ options['variable'] = item_info[1]
+ options['onvalue'] = true
+ options['offvalue'] = false
+
+ when Array
+ # radiobutton or cascade
+ if item_info[1][0].kind_of?(TkVariable)
+ # radiobutton
+ item_type = 'radiobutton'
+ options['variable'] = item_info[1][0]
+ options['value'] = item_info[1][1] if item_info[1][1]
+
+ else
+ # cascade
+ item_type = 'cascade'
+ menu_opts = orig_opts.dup
+ if item_info[4] && item_info[4].kind_of?(Hash)
+ opts = _symbolkey2str(item_info[4])
+ menu_name = opts.delete('menu_name')
+ menu_config = opts.delete('menu_config') || {}
+ menu_opts.update(_symbolkey2str(menu_config))
+ end
+ submenu = _create_menu(menu, item_info[1], menu_name,
+ tearoff, menu_opts)
+ options['menu'] = submenu
+ end
+
+ else
+ # command
+ item_type = 'command'
+ options['command'] = item_info[1] if item_info[1]
+ end
+
+ options['underline'] = item_info[2] if item_info[2]
+ options['accelerator'] = item_info[3] if item_info[3]
+ if item_info[4] && item_info[4].kind_of?(Hash)
+ opts = _symbolkey2str(item_info[4])
+ if item_type == 'cascade'
+ opts.delete('menu_name')
+ opts.delete('menu_config')
+ end
+ options.update(opts)
+ end
+
+ case options['underline']
+ when String, Regexp
+ if options['label'] &&
+ (idx = options['label'].index(options['underline']))
+ options['underline'] = idx
+ else
+ options['underline'] = -1
+ end
+ when true
+ if options['label'] && (idx = options['label'].index('&'))
+ options['label'] = options['label'].dup
+ options['label'][idx] = ''
+ options['underline'] = idx
+ else
+ options['underline'] = -1
+ end
+ end
+
+ menu.add(item_type, options)
+
+ elsif /^-+$/ =~ item_info
+ menu.add('separator')
+
+ else
+ menu.add('command', 'label' => item_info)
+ end
+ end
+
+ menu
+ end
+ private :_create_menu
+
+ def _use_menubar?(parent)
+ use_menubar = false
+ if parent.kind_of?(Tk::Root) || parent.kind_of?(Tk::Toplevel)
+ true
+ elsif parent.current_configinfo.has_key?('menu')
+ true
+ else
+ false
+ end
+ end
+ private :_use_menubar?
+
+ def _create_menu_for_menubar(parent)
+ #unless (mbar = parent.menu).kind_of?(TkMenu)
+ # --> use current TkMenu class
+ mbar = parent.menu
+ unless mbar.kind_of?(Tk::Menu) || mbar.kind_of?(TkMenu)
+ #mbar = Tk::Menu.new(parent, :tearoff=>false)
+ mbar = TkMenu.new(parent, :tearoff=>false)
+ parent.menu(mbar)
+ end
+ mbar
+ end
+ private :_create_menu_for_menubar
+
+ def _create_menubutton(parent, menu_info, tearoff=false, default_opts = {})
+ btn_info = menu_info[0]
+
+ if tearoff.kind_of?(Hash)
+ default_opts = tearoff
+ tearoff = false
+ end
+
+ if default_opts.kind_of?(Hash)
+ default_opts = _symbolkey2str(default_opts)
+
+ if default_opts.has_key?('layout_proc')
+ layout_proc = default_opts.delete('layout_proc')
+ end
+
+ _vertical_mbar_bind_proc = proc{|m, dir|
+ Tk::Menu::TkInternalFunction.next_menu(m, dir) rescue nil
+ # ignore error when the internal function doesn't exist
+ }
+
+ case layout_proc
+ when :vertical, 'vertical', :vertical_left, 'vertical_left'
+ layout_proc = proc{|_parent, _mbtn|
+ _mbtn.direction :right
+ _mbtn.pack(:side=>:top, :fill=>:x)
+
+ menu = _mbtn.menu
+ menu.bind('Tab', _vertical_mbar_bind_proc, :widget, 'forward')
+ menu.bind('Alt-Tab', _vertical_mbar_bind_proc, :widget, 'backward')
+ }
+ when :vertical_right, 'vertical_right'
+ layout_proc = proc{|_parent, _mbtn|
+ _mbtn.direction :left
+ _mbtn.pack(:side=>:top, :fill=>:x)
+
+ menu = _mbtn.menu
+ menu.bind('Tab', _vertical_mbar_bind_proc, :widget, 'forward')
+ menu.bind('Alt-Tab', _vertical_mbar_bind_proc, :widget, 'backward')
+ }
+ when :horizontal, 'horizontal'
+ layout_proc = proc{|_parent, _mbtn| _mbtn.pack(:side=>:left)}
+ else
+ # do nothing
+ end
+ end
+
+ keys = (default_opts)? default_opts.dup: {}
+
+ tearoff = keys.delete('tearoff') if keys.key?('tearoff')
+ tearoff = false unless tearoff # nil --> false
+
+ if _use_menubar?(parent) && ! layout_proc
+ # menubar by menu entries
+ mbar = _create_menu_for_menubar(parent)
+
+ menu_name = nil
+
+ if btn_info.kind_of?(Hash)
+ keys.update(_symbolkey2str(btn_info))
+ menu_name = keys.delete('menu_name')
+ keys['label'] = keys.delete('text') || ''
+
+ case keys['underline']
+ when String, Regexp
+ if idx = keys['label'].index(keys['underline'])
+ keys['underline'] = idx
+ else
+ keys['underline'] = -1
+ end
+ when true
+ if idx = keys['label'].index('&')
+ keys['label'] = keys['label'].dup
+ keys['label'][idx] = ''
+ keys['underline'] = idx
+ else
+ keys['underline'] = -1
+ end
+ end
+
+ elsif btn_info.kind_of?(Array)
+ keys['label'] = btn_info[0] if btn_info[0]
+
+ case btn_info[1]
+ when Integer
+ keys['underline'] = btn_info[1]
+ when String, Regexp
+ if idx = keys['label'].index(btn_info[1])
+ keys['underline'] = idx
+ else
+ keys['underline'] = -1
+ end
+ when true
+ if idx = keys['label'].index('&')
+ keys['label'] = keys['label'].dup
+ keys['label'][idx] = ''
+ keys['underline'] = idx
+ else
+ keys['underline'] = -1
+ end
+ end
+
+ if btn_info[2]&&btn_info[2].kind_of?(Hash)
+ keys.update(_symbolkey2str(btn_info[2]))
+ menu_name = keys.delete('menu_name')
+ end
+
+ else
+ keys = {:label=>btn_info}
+ end
+
+ menu = _create_menu(mbar, menu_info[1..-1], menu_name,
+ tearoff, default_opts)
+ menu.tearoff(tearoff)
+
+ keys['menu'] = menu
+ mbar.add('cascade', keys)
+
+ [mbar, menu]
+
+ else
+ # menubar by menubuttons
+ #mbtn = Tk::Menubutton.new(parent)
+ # --> use current TkMenubutton class
+ mbtn = TkMenubutton.new(parent)
+
+ menu_name = nil
+
+ if btn_info.kind_of?(Hash)
+ keys.update(_symbolkey2str(btn_info))
+ menu_name = keys.delete('menu_name')
+ keys['text'] = keys.delete('label') || ''
+ case keys['underline']
+ when String, Regexp
+ if idx = keys['text'].index(keys['underline'])
+ keys['underline'] = idx
+ else
+ keys['underline'] = -1
+ end
+ when true
+ if idx = keys['text'].index('&')
+ keys['text'] = keys['text'].dup
+ keys['text'][idx] = ''
+ keys['underline'] = idx
+ else
+ keys['underline'] = -1
+ end
+ end
+ mbtn.configure(keys)
+
+ elsif btn_info.kind_of?(Array)
+ case btn_info[1]
+ when String, Regexp
+ if btn_info[0] && (idx = btn_info[0].index(btn_info[1]))
+ btn_info[1] = idx
+ else
+ btn_info[1] = -1
+ end
+ when true
+ if btn_info[0] && (idx = btn_info[0].index('&'))
+ btn_info[0] = btn_info[0].dup
+ btn_info[0][idx] = ''
+ btn_info[1] = idx
+ else
+ btn_info[1] = -1
+ end
+ end
+ mbtn.configure('text', btn_info[0]) if btn_info[0]
+ mbtn.configure('underline', btn_info[1]) if btn_info[1]
+ # mbtn.configure('accelerator', btn_info[2]) if btn_info[2]
+ if btn_info[2]&&btn_info[2].kind_of?(Hash)
+ keys.update(_symbolkey2str(btn_info[2]))
+ menu_name = keys.delete('menu_name')
+ mbtn.configure(keys)
+ end
+
+ else
+ mbtn.configure('text', btn_info)
+ end
+
+ menu = _create_menu(mbtn, menu_info[1..-1], menu_name,
+ tearoff, default_opts)
+ mbtn.menu(menu)
+
+ if layout_proc.kind_of?(Proc) || layout_proc.kind_of?(Method)
+ # e.g. make a vertical menubar
+ # :layout_proc => proc{|parent, btn| btn.pack(:side=>:top, :fill=>:x)}
+ layout_proc.call(parent, mbtn)
+ else
+ mbtn.pack('side' => 'left')
+ end
+
+ [mbtn, menu]
+ end
+ end
+ private :_create_menubutton
+
+ def _create_menubar(parent, menu_spec, tearoff = false, opts = nil)
+ if tearoff.kind_of?(Hash)
+ opts = tearoff
+ tearoff = false
+ end
+ tearoff = false unless tearoff # nil --> false
+ menu_spec.each{|menu_info|
+ _create_menubutton(parent, menu_info, tearoff, opts)
+ }
+ parent
+ end
+ private :_create_menubar
+
+ def _get_cascade_menus(menu)
+ menus = []
+ (0..(menu.index('last'))).each{|idx|
+ if menu.menutype(idx) == 'cascade'
+ submenu = menu.entrycget(idx, 'menu')
+ menus << [submenu, _get_cascade_menus(submenu)]
+ end
+ }
+ menus
+ end
+ private :_get_cascade_menus
+end
diff --git a/jni/ruby/ext/tk/lib/tk/message.rb b/jni/ruby/ext/tk/lib/tk/message.rb
new file mode 100644
index 0000000..5f73b30
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tk/message.rb
@@ -0,0 +1,24 @@
+#
+# tk/message.rb : treat message widget
+#
+require 'tk'
+require 'tk/label'
+
+class Tk::Message<Tk::Label
+ TkCommandNames = ['message'.freeze].freeze
+ WidgetClassName = 'Message'.freeze
+ WidgetClassNames[WidgetClassName] ||= self
+ #def create_self(keys)
+ # if keys and keys != None
+ # tk_call_without_enc('message', @path, *hash_kv(keys, true))
+ # else
+ # tk_call_without_enc('message', @path)
+ # end
+ #end
+ private :create_self
+end
+
+#TkMessage = Tk::Message unless Object.const_defined? :TkMessage
+#Tk.__set_toplevel_aliases__(:Tk, Tk::Message, :TkMessage)
+Tk.__set_loaded_toplevel_aliases__('tk/message.rb', :Tk, Tk::Message,
+ :TkMessage)
diff --git a/jni/ruby/ext/tk/lib/tk/mngfocus.rb b/jni/ruby/ext/tk/lib/tk/mngfocus.rb
new file mode 100644
index 0000000..a05fb94
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tk/mngfocus.rb
@@ -0,0 +1,33 @@
+#
+# tk/mngfocus.rb : methods for Tcl/Tk standard library 'focus.tcl'
+# by Hidetoshi Nagai <nagai@ai.kyutech.ac.jp>
+#
+require 'tk'
+
+module TkManageFocus
+ extend Tk
+
+ TkCommandNames = [
+ 'tk_focusFollowMouse'.freeze,
+ 'tk_focusNext'.freeze,
+ 'tk_focusPrev'.freeze
+ ].freeze
+
+ def TkManageFocus.followsMouse
+ tk_call_without_enc('tk_focusFollowsMouse')
+ end
+
+ def TkManageFocus.next(win)
+ tk_tcl2ruby(tk_call('tk_focusNext', win))
+ end
+ def focusNext
+ TkManageFocus.next(self)
+ end
+
+ def TkManageFocus.prev(win)
+ tk_tcl2ruby(tk_call('tk_focusPrev', win))
+ end
+ def focusPrev
+ TkManageFocus.prev(self)
+ end
+end
diff --git a/jni/ruby/ext/tk/lib/tk/msgcat.rb b/jni/ruby/ext/tk/lib/tk/msgcat.rb
new file mode 100644
index 0000000..f2d0653
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tk/msgcat.rb
@@ -0,0 +1,299 @@
+#
+# tk/msgcat.rb : methods for Tcl message catalog
+# by Hidetoshi Nagai <nagai@ai.kyutech.ac.jp>
+#
+require 'tk'
+
+#class TkMsgCatalog
+class TkMsgCatalog < TkObject
+ include TkCore
+ extend Tk
+ #extend TkMsgCatalog
+
+ TkCommandNames = [
+ '::msgcat::mc'.freeze,
+ '::msgcat::mcmax'.freeze,
+ '::msgcat::mclocale'.freeze,
+ '::msgcat::mcpreferences'.freeze,
+ '::msgcat::mcload'.freeze,
+ '::msgcat::mcset'.freeze,
+ '::msgcat::mcmset'.freeze,
+ '::msgcat::mcunknown'.freeze
+ ].freeze
+
+ tk_call_without_enc('package', 'require', 'Tcl', '8.2')
+
+ PACKAGE_NAME = 'msgcat'.freeze
+ def self.package_name
+ PACKAGE_NAME
+ end
+
+ if self.const_defined? :FORCE_VERSION
+ tk_call_without_enc('package', 'require', 'msgcat', FORCE_VERSION)
+ else
+ tk_call_without_enc('package', 'require', 'msgcat')
+ end
+
+ MSGCAT_EXT = '.msg'
+
+ UNKNOWN_CBTBL = TkUtil.untrust(Hash.new{|hash,key| hash[key] = {}})
+
+ TkCore::INTERP.add_tk_procs('::msgcat::mcunknown', 'args', <<-'EOL')
+ if {[set st [catch {eval {ruby_cmd TkMsgCatalog callback} [namespace current] $args} ret]] != 0} {
+ #return -code $st $ret
+ set idx [string first "\n\n" $ret]
+ if {$idx > 0} {
+ return -code $st \
+ -errorinfo [string range $ret [expr $idx + 2] \
+ [string length $ret]] \
+ [string range $ret 0 [expr $idx - 1]]
+ } else {
+ return -code $st $ret
+ }
+ } else {
+ return $ret
+ }
+ EOL
+
+ def self.callback(namespace, locale, src_str, *args)
+ src_str = sprintf(src_str, *args) unless args.empty?
+ cmd_tbl = TkMsgCatalog::UNKNOWN_CBTBL[TkCore::INTERP.__getip]
+ cmd = cmd_tbl[namespace]
+ cmd = cmd_tbl['::'] unless cmd # use global scope as interp default
+ return src_str unless cmd # no cmd -> return src-str (default action)
+ begin
+ cmd.call(locale, src_str)
+ rescue SystemExit
+ exit(0)
+ rescue Interrupt
+ exit!(1)
+ rescue Exception => e
+ begin
+ msg = _toUTF8(e.class.inspect) + ': ' +
+ _toUTF8(e.message) + "\n" +
+ "\n---< backtrace of Ruby side >-----\n" +
+ _toUTF8(e.backtrace.join("\n")) +
+ "\n---< backtrace of Tk side >-------"
+ if TkCore::WITH_ENCODING
+ msg.force_encoding('utf-8')
+ else
+ msg.instance_variable_set(:@encoding, 'utf-8')
+ end
+ rescue Exception
+ msg = e.class.inspect + ': ' + e.message + "\n" +
+ "\n---< backtrace of Ruby side >-----\n" +
+ e.backtrace.join("\n") +
+ "\n---< backtrace of Tk side >-------"
+ end
+ fail(e, msg)
+ end
+ end
+
+ def initialize(namespace = nil)
+ if namespace.kind_of?(TkNamespace)
+ @namespace = namespace
+ elsif namespace == nil
+ @namespace = TkNamespace.new('::') # global namespace
+ else
+ @namespace = TkNamespace.new(namespace)
+ end
+ @path = @namespace.path
+
+ @msgcat_ext = '.msg'
+ end
+ attr_accessor :msgcat_ext
+
+ def method_missing(id, *args)
+ # locale(src, trans) ==> set_translation(locale, src, trans)
+ loc = id.id2name
+ case args.length
+ when 0 # set locale
+ self.locale=(loc)
+
+ when 1 # src only, or trans_list
+ if args[0].kind_of?(Array)
+ # trans_list
+ #list = args[0].collect{|src, trans|
+ # [ Tk::UTF8_String.new(src), Tk::UTF8_String.new(trans) ]
+ #}
+ self.set_translation_list(loc, args[0])
+ else
+ # src
+ #self.set_translation(loc, Tk::UTF8_String.new(args[0]))
+ self.set_translation(loc, args[0])
+ end
+
+ when 2 # src and trans, or, trans_list and enc
+ if args[0].kind_of?(Array)
+ # trans_list
+ self.set_translation_list(loc, *args)
+ else
+ #self.set_translation(loc, args[0], Tk::UTF8_String.new(args[1]))
+ self.set_translation(loc, *args)
+ end
+
+ when 3 # src and trans and enc
+ self.set_translation(loc, *args)
+
+ else
+ super(id, *args)
+# fail NameError, "undefined method `#{name}' for #{self.to_s}", error_at
+
+ end
+ end
+
+ # *args ::= form, arg, arg, ...
+ def self.translate(*args)
+ dst = args.collect{|src|
+ tk_call_without_enc('::msgcat::mc', _get_eval_string(src, true))
+ }
+ Tk.UTF8_String(sprintf(*dst))
+ end
+ class << self
+ alias mc translate
+ alias [] translate
+ end
+ def translate(*args)
+ dst = args.collect{|src|
+ @namespace.eval{tk_call_without_enc('::msgcat::mc',
+ _get_eval_string(src, true))}
+ }
+ Tk.UTF8_String(sprintf(*dst))
+ end
+ alias mc translate
+ alias [] translate
+
+ def self.maxlen(*src_strings)
+ tk_call('::msgcat::mcmax', *src_strings).to_i
+ end
+ def maxlen(*src_strings)
+ @namespace.eval{tk_call('::msgcat::mcmax', *src_strings).to_i}
+ end
+
+ def self.locale
+ tk_call('::msgcat::mclocale')
+ end
+ def locale
+ @namespace.eval{tk_call('::msgcat::mclocale')}
+ end
+
+ def self.locale=(locale)
+ tk_call('::msgcat::mclocale', locale)
+ end
+ def locale=(locale)
+ @namespace.eval{tk_call('::msgcat::mclocale', locale)}
+ end
+
+ def self.preferences
+ tk_split_simplelist(tk_call('::msgcat::mcpreferences'))
+ end
+ def preferences
+ tk_split_simplelist(@namespace.eval{tk_call('::msgcat::mcpreferences')})
+ end
+
+ def self.load_tk(dir)
+ number(tk_call('::msgcat::mcload', dir))
+ end
+
+ def self.load_rb(dir)
+ count = 0
+ preferences().each{|loc|
+ file = File.join(dir, loc + self::MSGCAT_EXT)
+ if File.readable?(file)
+ count += 1
+ if TkCore::WITH_ENCODING
+ eval(IO.read(file, :encoding=>"ASCII-8BIT"))
+ else
+ eval(IO.read(file))
+ end
+ end
+ }
+ count
+ end
+
+ def load_tk(dir)
+ number(@namespace.eval{tk_call('::msgcat::mcload', dir)})
+ end
+
+ def load_rb(dir)
+ count = 0
+ preferences().each{|loc|
+ file = File.join(dir, loc + @msgcat_ext)
+ if File.readable?(file)
+ count += 1
+ if TkCore::WITH_ENCODING
+ @namespace.eval(IO.read(file, :encoding=>"ASCII-8BIT"))
+ else
+ @namespace.eval(IO.read(file))
+ end
+ end
+ }
+ count
+ end
+
+ def self.load(dir)
+ self.load_rb(dir)
+ end
+ alias load load_rb
+
+ def self.set_translation(locale, src_str, trans_str=None, enc='utf-8')
+ if trans_str && trans_str != None
+ trans_str = Tk.UTF8_String(_toUTF8(trans_str, enc))
+ Tk.UTF8_String(ip_eval_without_enc("::msgcat::mcset {#{locale}} {#{_get_eval_string(src_str, true)}} {#{trans_str}}"))
+ else
+ Tk.UTF8_String(ip_eval_without_enc("::msgcat::mcset {#{locale}} {#{_get_eval_string(src_str, true)}}"))
+ end
+ end
+ def set_translation(locale, src_str, trans_str=None, enc='utf-8')
+ if trans_str && trans_str != None
+ trans_str = Tk.UTF8_String(_toUTF8(trans_str, enc))
+ Tk.UTF8_String(@namespace.eval{
+ ip_eval_without_enc("::msgcat::mcset {#{locale}} {#{_get_eval_string(src_str, true)}} {#{trans_str}}")
+ })
+ else
+ Tk.UTF8_String(@namespace.eval{
+ ip_eval_without_enc("::msgcat::mcset {#{locale}} {#{_get_eval_string(src_str, true)}}")
+ })
+ end
+ end
+
+ def self.set_translation_list(locale, trans_list, enc='utf-8')
+ # trans_list ::= [ [src, trans], [src, trans], ... ]
+ list = []
+ trans_list.each{|src, trans|
+ if trans && trans != None
+ list << _get_eval_string(src, true)
+ list << Tk.UTF8_String(_toUTF8(trans, enc))
+ else
+ list << _get_eval_string(src, true) << ''
+ end
+ }
+ #number(tk_call_without_enc('::msgcat::mcmset', locale, list))
+ number(ip_eval_without_enc("::msgcat::mcmset {#{locale}} {#{_get_eval_string(list)}}"))
+ end
+ def set_translation_list(locale, trans_list, enc='utf-8')
+ # trans_list ::= [ [src, trans], [src, trans], ... ]
+ list = []
+ trans_list.each{|src, trans|
+ if trans && trans != None
+ list << _get_eval_string(src, true)
+ list << Tk.UTF8_String(_toUTF8(trans, enc))
+ else
+ list << _get_eval_string(src, true) << ''
+ end
+ }
+ number(@namespace.eval{
+ #tk_call_without_enc('::msgcat::mcmset', locale, list)
+ ip_eval_without_enc("::msgcat::mcmset {#{locale}} {#{_get_eval_string(list)}}")
+ })
+ end
+
+ def self.def_unknown_proc(cmd=Proc.new)
+ TkMsgCatalog::UNKNOWN_CBTBL[TkCore::INTERP.__getip]['::'] = cmd
+ end
+ def def_unknown_proc(cmd=Proc.new)
+ TkMsgCatalog::UNKNOWN_CBTBL[TkCore::INTERP.__getip][@namespace.path] = cmd
+ end
+end
+
+TkMsgCat = TkMsgCatalog
diff --git a/jni/ruby/ext/tk/lib/tk/namespace.rb b/jni/ruby/ext/tk/lib/tk/namespace.rb
new file mode 100644
index 0000000..0119ba5
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tk/namespace.rb
@@ -0,0 +1,546 @@
+#
+# tk/namespace.rb : methods to manipulate Tcl/Tk namespace
+# by Hidetoshi Nagai <nagai@ai.kyutech.ac.jp>
+#
+require 'tk'
+
+class TkNamespace < TkObject
+ extend Tk
+
+ TkCommandNames = [
+ 'namespace'.freeze,
+ ].freeze
+
+ Tk_Namespace_ID_TBL = TkCore::INTERP.create_table
+
+ (Tk_Namespace_ID = ["ns".freeze, TkUtil.untrust("00000")]).instance_eval{
+ @mutex = Mutex.new
+ def mutex; @mutex; end
+ freeze
+ }
+
+ Tk_NsCode_RetObjID_TBL = TkCore::INTERP.create_table
+
+ TkCore::INTERP.init_ip_env{
+ Tk_Namespace_ID_TBL.mutex.synchronize{ Tk_Namespace_ID_TBL.clear }
+ Tk_NsCode_RetObjID_TBL.mutex.synchronize{ Tk_NsCode_RetObjID_TBL.clear }
+ }
+
+ def TkNamespace.id2obj(id)
+ Tk_Namespace_ID_TBL.mutex.synchronize{
+ Tk_Namespace_ID_TBL[id]? Tk_Namespace_ID_TBL[id]: id
+ }
+ end
+
+ #####################################
+
+ class Ensemble < TkObject
+ def __cget_cmd
+ ['namespace', 'ensemble', 'configure', self.path]
+ end
+ private :__cget_cmd
+
+ def __config_cmd
+ ['namespace', 'ensemble', 'configure', self.path]
+ end
+ private :__config_cmd
+
+ def __configinfo_struct
+ {:key=>0, :alias=>nil, :db_name=>nil, :db_class=>nil,
+ :default_value=>nil, :current_value=>2}
+ end
+ private :__configinfo_struct
+
+ def __boolval_optkeys
+ ['prefixes']
+ end
+ private :__boolval_optkeys
+
+ def __listval_optkeys
+ ['map', 'subcommands', 'unknown']
+ end
+ private :__listval_optkeys
+
+ def self.exist?(ensemble)
+ bool(tk_call('namespace', 'ensemble', 'exists', ensemble))
+ end
+
+ def initialize(keys = {})
+ @ensemble = @path = tk_call('namespace', 'ensemble', 'create', keys)
+ end
+
+ def cget(slot)
+ if slot == :namespace || slot == 'namespace'
+ ns = super(slot)
+ Tk_Namespace_ID_TBL.mutex.synchronize{
+ if TkNamespace::Tk_Namespace_ID_TBL.key?(ns)
+ TkNamespace::Tk_Namespace_ID_TBL[ns]
+ else
+ ns
+ end
+ }
+ else
+ super(slot)
+ end
+ end
+ def cget_strict(slot)
+ if slot == :namespace || slot == 'namespace'
+ ns = super(slot)
+ Tk_Namespace_ID_TBL.mutex.synchronize{
+ if TkNamespace::Tk_Namespace_ID_TBL.key?(ns)
+ TkNamespace::Tk_Namespace_ID_TBL[ns]
+ else
+ ns
+ end
+ }
+ else
+ super(slot)
+ end
+ end
+
+ def configinfo(slot = nil)
+ if slot
+ if slot == :namespace || slot == 'namespace'
+ val = super(slot)
+ Tk_Namespace_ID_TBL.mutex.synchronize{
+ if TkNamespace::Tk_Namespace_ID_TBL.key?(val)
+ val = TkNamespace::Tk_Namespace_ID_TBL[val]
+ end
+ }
+ else
+ val = super(slot)
+ end
+
+ if TkComm::GET_CONFIGINFO_AS_ARRAY
+ [slot.to_s, val]
+ else # ! TkComm::GET_CONFIGINFO_AS_ARRAY
+ {slot.to_s => val}
+ end
+
+ else
+ info = super()
+
+ if TkComm::GET_CONFIGINFO_AS_ARRAY
+ Tk_Namespace_ID_TBL.mutex.synchronize{
+ info.map!{|inf|
+ if inf[0] == 'namespace' &&
+ TkNamespace::Tk_Namespace_ID_TBL.key?(inf[-1])
+ [inf[0], TkNamespace::Tk_Namespace_ID_TBL[inf[-1]]]
+ else
+ inf
+ end
+ }
+ }
+ else # ! TkComm::GET_CONFIGINFO_AS_ARRAY
+ val = info['namespace']
+ Tk_Namespace_ID_TBL.mutex.synchronize{
+ if TkNamespace::Tk_Namespace_ID_TBL.key?(val)
+ info['namespace'] = TkNamespace::Tk_Namespace_ID_TBL[val]
+ end
+ }
+ end
+
+ info
+ end
+ end
+
+ def exists?
+ bool(tk_call('namespace', 'ensemble', 'exists', @path))
+ end
+ end
+
+ #####################################
+
+ class ScopeArgs < Array
+ include Tk
+
+ # alias __tk_call tk_call
+ # alias __tk_call_without_enc tk_call_without_enc
+ # alias __tk_call_with_enc tk_call_with_enc
+ def tk_call(*args)
+ #super('namespace', 'eval', @namespace, *args)
+ args = args.collect{|arg| (s = _get_eval_string(arg, true))? s: ''}
+ super('namespace', 'eval', @namespace,
+ TkCore::INTERP._merge_tklist(*args))
+ end
+ def tk_call_without_enc(*args)
+ #super('namespace', 'eval', @namespace, *args)
+ args = args.collect{|arg| (s = _get_eval_string(arg, true))? s: ''}
+ super('namespace', 'eval', @namespace,
+ TkCore::INTERP._merge_tklist(*args))
+ end
+ def tk_call_with_enc(*args)
+ #super('namespace', 'eval', @namespace, *args)
+ args = args.collect{|arg| (s = _get_eval_string(arg, true))? s: ''}
+ super('namespace', 'eval', @namespace,
+ TkCore::INTERP._merge_tklist(*args))
+ end
+
+ def initialize(namespace, *args)
+ @namespace = namespace
+ super(args.size)
+ self.replace(args)
+ end
+ end
+
+ #####################################
+
+ class NsCode < TkObject
+ def initialize(scope, use_obj_id = false)
+ @scope = scope + ' '
+ @use_obj_id = use_obj_id
+ end
+ def path
+ @scope
+ end
+ def to_eval
+ @scope
+ end
+ def call(*args)
+ ret = TkCore::INTERP._eval_without_enc(@scope + array2tk_list(args))
+ if @use_obj_id
+ ret = TkNamespace::Tk_NsCode_RetObjID_TBL.delete(ret.to_i)
+ end
+ ret
+ end
+ end
+
+ #####################################
+
+ def install_cmd(cmd)
+ lst = tk_split_simplelist(super(cmd), false, false)
+ if lst[1] =~ /^::/
+ lst[1] = @fullname
+ else
+ lst.insert(1, @fullname)
+ end
+ TkCore::INTERP._merge_tklist(*lst)
+ end
+
+ alias __tk_call tk_call
+ alias __tk_call_without_enc tk_call_without_enc
+ alias __tk_call_with_enc tk_call_with_enc
+ def tk_call(*args)
+ #super('namespace', 'eval', @fullname, *args)
+ args = args.collect{|arg| (s = _get_eval_string(arg, true))? s: ''}
+ super('namespace', 'eval', @fullname,
+ TkCore::INTERP._merge_tklist(*args))
+ end
+ def tk_call_without_enc(*args)
+ #super('namespace', 'eval', @fullname, *args)
+ args = args.collect{|arg| (s = _get_eval_string(arg, true))? s: ''}
+ super('namespace', 'eval', @fullname,
+ TkCore::INTERP._merge_tklist(*args))
+ end
+ def tk_call_with_enc(*args)
+ #super('namespace', 'eval', @fullname, *args)
+ args = args.collect{|arg| (s = _get_eval_string(arg, true))? s: ''}
+ super('namespace', 'eval', @fullname,
+ TkCore::INTERP._merge_tklist(*args))
+ end
+ alias ns_tk_call tk_call
+ alias ns_tk_call_without_enc tk_call_without_enc
+ alias ns_tk_call_with_enc tk_call_with_enc
+
+ def initialize(name = nil, parent = nil)
+ unless name
+ Tk_Namespace_ID.mutex.synchronize{
+ # name = Tk_Namespace_ID.join('')
+ name = Tk_Namespace_ID.join(TkCore::INTERP._ip_id_)
+ Tk_Namespace_ID[1].succ!
+ }
+ end
+ name = __tk_call('namespace', 'current') if name == ''
+ if parent
+ if parent =~ /^::/
+ if name =~ /^::/
+ @fullname = parent + name
+ else
+ @fullname = parent +'::'+ name
+ end
+ else
+ ancestor = __tk_call('namespace', 'current')
+ ancestor = '' if ancestor == '::'
+ if name =~ /^::/
+ @fullname = ancestor + '::' + parent + name
+ else
+ @fullname = ancestor + '::'+ parent +'::'+ name
+ end
+ end
+ else # parent == nil
+ ancestor = __tk_call('namespace', 'current')
+ ancestor = '' if ancestor == '::'
+ if name =~ /^::/
+ @fullname = name
+ else
+ @fullname = ancestor + '::' + name
+ end
+ end
+ @path = @fullname
+ @parent = __tk_call('namespace', 'qualifiers', @fullname)
+ @name = __tk_call('namespace', 'tail', @fullname)
+
+ # create namespace
+ __tk_call('namespace', 'eval', @fullname, '')
+
+ Tk_Namespace_ID_TBL.mutex.synchronize{
+ Tk_Namespace_ID_TBL[@fullname] = self
+ }
+ end
+
+ def self.children(*args)
+ # args ::= [<namespace>] [<pattern>]
+ # <pattern> must be glob-style pattern
+ tk_split_simplelist(tk_call('namespace', 'children', *args)).collect{|ns|
+ # ns is fullname
+ Tk_Namespace_ID_TBL.mutex.synchronize{
+ if Tk_Namespace_ID_TBL.key?(ns)
+ Tk_Namespace_ID_TBL[ns]
+ else
+ ns
+ end
+ }
+ }
+ end
+ def children(pattern=None)
+ TkNamespace.children(@fullname, pattern)
+ end
+
+ def self.code(script = Proc.new)
+ TkNamespace.new('').code(script)
+ end
+=begin
+ def code(script = Proc.new)
+ if script.kind_of?(String)
+ cmd = proc{|*args| ScopeArgs.new(@fullname,*args).instance_eval(script)}
+ elsif script.kind_of?(Proc)
+ cmd = proc{|*args| ScopeArgs.new(@fullname,*args).instance_eval(&script)}
+ else
+ fail ArgumentError, "String or Proc is expected"
+ end
+ TkNamespace::NsCode.new(tk_call_without_enc('namespace', 'code',
+ _get_eval_string(cmd, false)))
+ end
+=end
+ def code(script = Proc.new)
+ if script.kind_of?(String)
+ cmd = proc{|*args|
+ ret = ScopeArgs.new(@fullname,*args).instance_eval(script)
+ id = ret.object_id
+ TkNamespace::Tk_NsCode_RetObjID_TBL[id] = ret
+ id
+ }
+ elsif script.kind_of?(Proc)
+ cmd = proc{|*args|
+ if TkCore::WITH_RUBY_VM ### Ruby 1.9 !!!!
+ obj = ScopeArgs.new(@fullname,*args)
+ ret = obj.instance_exec(obj, &script)
+ else
+ ret = ScopeArgs.new(@fullname,*args).instance_eval(&script)
+ end
+ id = ret.object_id
+ TkNamespace::Tk_NsCode_RetObjID_TBL[id] = ret
+ id
+ }
+ else
+ fail ArgumentError, "String or Proc is expected"
+ end
+ TkNamespace::NsCode.new(tk_call_without_enc('namespace', 'code',
+ _get_eval_string(cmd, false)),
+ true)
+ end
+
+ def self.current_path
+ tk_call('namespace', 'current')
+ end
+ def current_path
+ @fullname
+ end
+
+ def self.current
+ ns = self.current_path
+ Tk_Namespace_ID_TBL.mutex.synchronize{
+ if Tk_Namespace_ID_TBL.key?(ns)
+ Tk_Namespace_ID_TBL[ns]
+ else
+ ns
+ end
+ }
+ end
+ def current_namespace
+ # ns_tk_call('namespace', 'current')
+ # @fullname
+ self
+ end
+ alias current current_namespace
+
+ def self.delete(*ns_list)
+ tk_call('namespace', 'delete', *ns_list)
+ ns_list.each{|ns|
+ Tk_Namespace_ID_TBL.mutex.synchronize{
+ if ns.kind_of?(TkNamespace)
+ Tk_Namespace_ID_TBL.delete(ns.path)
+ else
+ Tk_Namespace_ID_TBL.delete(ns.to_s)
+ end
+ }
+ }
+ end
+ def delete
+ TkNamespece.delete(@fullname)
+ end
+
+ def self.ensemble_create(*keys)
+ tk_call('namespace', 'ensemble', 'create', *hash_kv(keys))
+ end
+ def self.ensemble_configure(cmd, slot, value=None)
+ if slot.kind_of?(Hash)
+ tk_call('namespace', 'ensemble', 'configure', cmd, *hash_kv(slot))
+ else
+ tk_call('namespace', 'ensemble', 'configure', cmd, '-'+slot.to_s, value)
+ end
+ end
+ def self.ensemble_configinfo(cmd, slot = nil)
+ if slot
+ tk_call('namespace', 'ensemble', 'configure', cmd, '-' + slot.to_s)
+ else
+ inf = {}
+ Hash(*tk_split_simplelist(tk_call('namespace', 'ensemble', 'configure', cmd))).each{|k, v| inf[k[1..-1]] = v}
+ inf
+ end
+ end
+ def self.ensemble_exist?(cmd)
+ bool(tk_call('namespace', 'ensemble', 'exists', cmd))
+ end
+
+ def self.eval(namespace, cmd = Proc.new, *args)
+ #tk_call('namespace', 'eval', namespace, cmd, *args)
+ TkNamespace.new(namespace).eval(cmd, *args)
+ end
+=begin
+ def eval(cmd = Proc.new, *args)
+ #TkNamespace.eval(@fullname, cmd, *args)
+ #ns_tk_call(cmd, *args)
+ code_obj = code(cmd)
+ ret = code_obj.call(*args)
+ # uninstall_cmd(TkCore::INTERP._split_tklist(code_obj.path)[-1])
+ uninstall_cmd(_fromUTF8(TkCore::INTERP._split_tklist(_toUTF8(code_obj.path))[-1]))
+ tk_tcl2ruby(ret)
+ end
+=end
+ def eval(cmd = Proc.new, *args)
+ code_obj = code(cmd)
+ ret = code_obj.call(*args)
+ uninstall_cmd(_fromUTF8(TkCore::INTERP._split_tklist(_toUTF8(code_obj.path))[-1]))
+ ret
+ end
+
+ def self.exist?(ns)
+ bool(tk_call('namespace', 'exists', ns))
+ end
+ def exist?
+ TkNamespece.exist?(@fullname)
+ end
+
+ def self.export(*patterns)
+ tk_call('namespace', 'export', *patterns)
+ end
+ def self.export_with_clear(*patterns)
+ tk_call('namespace', 'export', '-clear', *patterns)
+ end
+ def export
+ TkNamespace.export(@fullname)
+ end
+ def export_with_clear
+ TkNamespace.export_with_clear(@fullname)
+ end
+
+ def self.forget(*patterns)
+ tk_call('namespace', 'forget', *patterns)
+ end
+ def forget
+ TkNamespace.forget(@fullname)
+ end
+
+ def self.import(*patterns)
+ tk_call('namespace', 'import', *patterns)
+ end
+ def self.force_import(*patterns)
+ tk_call('namespace', 'import', '-force', *patterns)
+ end
+ def import
+ TkNamespace.import(@fullname)
+ end
+ def force_import
+ TkNamespace.force_import(@fullname)
+ end
+
+ def self.inscope(namespace, script, *args)
+ tk_call('namespace', 'inscope', namespace, script, *args)
+ end
+ def inscope(script, *args)
+ TkNamespace.inscope(@fullname, script, *args)
+ end
+
+ def self.origin(cmd)
+ tk_call('namespace', 'origin', cmd)
+ end
+
+ def self.parent(namespace=None)
+ ns = tk_call('namespace', 'parent', namespace)
+ Tk_Namespace_ID_TBL.mutex.synchronize{
+ if Tk_Namespace_ID_TBL.key?(ns)
+ Tk_Namespace_ID_TBL[ns]
+ else
+ ns
+ end
+ }
+ end
+ def parent
+ tk_call('namespace', 'parent', @fullname)
+ end
+
+ def self.get_path
+ tk_call('namespace', 'path')
+ end
+ def self.set_path(*namespace_list)
+ tk_call('namespace', 'path', array2tk_list(namespace_list))
+ end
+ def set_path
+ tk_call('namespace', 'path', @fullname)
+ end
+
+ def self.qualifiers(str)
+ tk_call('namespace', 'qualifiers', str)
+ end
+
+ def self.tail(str)
+ tk_call('namespace', 'tail', str)
+ end
+
+ def self.upvar(namespace, *var_pairs)
+ tk_call('namespace', 'upvar', namespace, *(var_pairs.flatten))
+ end
+ def upvar(*var_pairs)
+ TkNamespace.inscope(@fullname, *(var_pairs.flatten))
+ end
+
+ def self.get_unknown_handler
+ tk_tcl2ruby(tk_call('namespace', 'unknown'))
+ end
+ def self.set_unknown_handler(cmd = Proc.new)
+ tk_call('namespace', 'unknown', cmd)
+ end
+
+ def self.which(name)
+ tk_call('namespace', 'which', name)
+ end
+ def self.which_command(name)
+ tk_call('namespace', 'which', '-command', name)
+ end
+ def self.which_variable(name)
+ tk_call('namespace', 'which', '-variable', name)
+ end
+end
+
+TkNamespace::Global = TkNamespace.new('::')
diff --git a/jni/ruby/ext/tk/lib/tk/optiondb.rb b/jni/ruby/ext/tk/lib/tk/optiondb.rb
new file mode 100644
index 0000000..0f3be30
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tk/optiondb.rb
@@ -0,0 +1,377 @@
+#
+# tk/optiondb.rb : treat option database
+#
+require 'tk'
+
+module TkOptionDB
+ include Tk
+ extend Tk
+
+ TkCommandNames = ['option'.freeze].freeze
+ (CmdClassID = ['CMD_CLASS'.freeze, TkUtil.untrust('00000')]).instance_eval{
+ @mutex = Mutex.new
+ def mutex; @mutex; end
+ freeze
+ }
+
+ module Priority
+ WidgetDefault = 20
+ StartupFile = 40
+ UserDefault = 60
+ Interactive = 80
+ end
+
+ def add(pat, value, pri=None)
+ # if $SAFE >= 4
+ # fail SecurityError, "can't call 'TkOptionDB.add' at $SAFE >= 4"
+ # end
+ tk_call('option', 'add', pat, value, pri)
+ end
+ def clear
+ # if $SAFE >= 4
+ # fail SecurityError, "can't call 'TkOptionDB.crear' at $SAFE >= 4"
+ # end
+ tk_call_without_enc('option', 'clear')
+ end
+ def get(win, name, klass)
+ tk_call('option', 'get', win ,name, klass)
+ end
+ def readfile(file, pri=None)
+ tk_call('option', 'readfile', file, pri)
+ end
+ alias read_file readfile
+ module_function :add, :clear, :get, :readfile, :read_file
+
+ def read_entries(file, f_enc=nil)
+ if TkCore::INTERP.safe?
+ fail SecurityError,
+ "can't call 'TkOptionDB.read_entries' on a safe interpreter"
+ end
+
+ i_enc = ((Tk.encoding)? Tk.encoding : Tk.encoding_system)
+
+ unless f_enc
+ f_enc = i_enc
+ end
+
+ ent = []
+ cline = ''
+ open(file, 'r') {|f|
+ while line = f.gets
+ #cline += line.chomp!
+ cline.concat(line.chomp!)
+ case cline
+ when /\\$/ # continue
+ cline.chop!
+ next
+ when /^\s*(!|#)/ # coment
+ cline = ''
+ next
+ when /^([^:]+):(.*)$/
+ pat = $1.strip
+ val = $2.lstrip
+ p "ResourceDB: #{[pat, val].inspect}" if $DEBUG
+ pat = TkCore::INTERP._toUTF8(pat, f_enc)
+ pat = TkCore::INTERP._fromUTF8(pat, i_enc)
+ val = TkCore::INTERP._toUTF8(val, f_enc)
+ val = TkCore::INTERP._fromUTF8(val, i_enc)
+ ent << [pat, val]
+ cline = ''
+ else # unknown --> ignore
+ cline = ''
+ next
+ end
+ end
+ }
+ ent
+ end
+ module_function :read_entries
+
+ def read_with_encoding(file, f_enc=nil, pri=None)
+ # try to read the file as an OptionDB file
+ read_entries(file, f_enc).each{|pat, val|
+ add(pat, val, pri)
+ }
+
+=begin
+ i_enc = Tk.encoding()
+
+ unless f_enc
+ f_enc = i_enc
+ end
+
+ cline = ''
+ open(file, 'r') {|f|
+ while line = f.gets
+ cline += line.chomp!
+ case cline
+ when /\\$/ # continue
+ cline.chop!
+ next
+ when /^\s*!/ # coment
+ cline = ''
+ next
+ when /^([^:]+):\s(.*)$/
+ pat = $1
+ val = $2
+ p "ResourceDB: #{[pat, val].inspect}" if $DEBUG
+ pat = TkCore::INTERP._toUTF8(pat, f_enc)
+ pat = TkCore::INTERP._fromUTF8(pat, i_enc)
+ val = TkCore::INTERP._toUTF8(val, f_enc)
+ val = TkCore::INTERP._fromUTF8(val, i_enc)
+ add(pat, val, pri)
+ cline = ''
+ else # unknown --> ignore
+ cline = ''
+ next
+ end
+ end
+ }
+=end
+ end
+ module_function :read_with_encoding
+
+ # support procs on the resource database
+ @@resource_proc_class = Class.new
+
+ @@resource_proc_class.const_set(:CARRIER, '.'.freeze)
+
+ @@resource_proc_class.instance_variable_set('@method_tbl',
+ TkCore::INTERP.create_table)
+ @@resource_proc_class.instance_variable_set('@add_method', false)
+ @@resource_proc_class.instance_variable_set('@safe_mode', 4)
+
+ class << @@resource_proc_class
+ private :new
+
+=begin
+ CARRIER = '.'.freeze
+ METHOD_TBL = TkCore::INTERP.create_table
+ ADD_METHOD = false
+ SAFE_MODE = 4
+=end
+
+=begin
+ def __closed_block_check__(str)
+ depth = 0
+ str.scan(/[{}]/){|x|
+ if x == "{"
+ depth += 1
+ elsif x == "}"
+ depth -= 1
+ end
+ if depth <= 0 && !($' =~ /\A\s*\Z/)
+ fail RuntimeError, "bad string for procedure : #{str.inspect}"
+ end
+ }
+ str
+ end
+ private :__closed_block_check__
+=end
+
+ def __check_proc_string__(str)
+ # If you want to check the proc_string, do it in this method.
+ # Please define this in the block given to 'new_proc_class' method.
+ str
+ end
+
+ def method_missing(id, *args)
+ #res_proc, proc_str = self::METHOD_TBL[id]
+ res_proc, proc_str = @method_tbl[id]
+
+ proc_source = TkOptionDB.get(self::CARRIER, id.id2name, '').strip
+ res_proc = nil if proc_str != proc_source # resource is changed
+
+ # unless res_proc.kind_of?(Proc)
+ unless TkComm._callback_entry?(res_proc)
+ #if id == :new || !(self::METHOD_TBL.has_key?(id) || self::ADD_METHOD)
+ if id == :new || !(@method_tbl.has_key?(id) || @add_method)
+ raise NoMethodError,
+ "not support resource-proc '#{id.id2name}' for #{self.name}"
+ end
+ proc_str = proc_source
+ proc_str = '{' + proc_str + '}' unless /\A\{.*\}\Z/ =~ proc_str
+ #proc_str = __closed_block_check__(proc_str)
+ proc_str = __check_proc_string__(proc_str)
+ res_proc = proc{
+ begin
+ #eval("$SAFE = #{self::SAFE_MODE};\nProc.new" + proc_str)
+ eval("$SAFE = #{@safe_mode};\nProc.new" + proc_str)
+ rescue SyntaxError=>err
+ raise SyntaxError,
+ TkCore::INTERP._toUTF8(err.message.gsub(/\(eval\):\d:/,
+ "(#{id.id2name}):"))
+ end
+ }.call
+ #self::METHOD_TBL[id] = [res_proc, proc_source]
+ @method_tbl[id] = [res_proc, proc_source]
+ end
+ res_proc.call(*args)
+ end
+
+ private :__check_proc_string__, :method_missing
+ end
+ @@resource_proc_class.freeze
+
+=begin
+ def __create_new_class(klass, func, safe = 4, add = false, parent = nil)
+ klass = klass.to_s if klass.kind_of? Symbol
+ unless (?A..?Z) === klass[0]
+ fail ArgumentError, "bad string '#{klass}' for class name"
+ end
+ unless func.kind_of? Array
+ fail ArgumentError, "method-list must be Array"
+ end
+ func_str = func.join(' ')
+ if parent == nil
+ install_win(parent)
+ elsif parent <= @@resource_proc_class
+ install_win(parent::CARRIER)
+ else
+ fail ArgumentError, "parent must be Resource-Proc class"
+ end
+ carrier = Tk.tk_call_without_enc('frame', @path, '-class', klass)
+
+ body = <<-"EOD"
+ class #{klass} < TkOptionDB.module_eval('@@resource_proc_class')
+ CARRIER = '#{carrier}'.freeze
+ METHOD_TBL = TkCore::INTERP.create_table
+ ADD_METHOD = #{add}
+ SAFE_MODE = #{safe}
+ %w(#{func_str}).each{|f| METHOD_TBL[f.intern] = nil }
+ end
+ EOD
+
+ if parent.kind_of?(Class) && parent <= @@resource_proc_class
+ parent.class_eval(body)
+ eval(parent.name + '::' + klass)
+ else
+ eval(body)
+ eval('TkOptionDB::' + klass)
+ end
+ end
+=end
+ def __create_new_class(klass, func, safe = 4, add = false, parent = nil)
+ if klass.kind_of?(TkWindow)
+ carrier = klass.path
+ CmdClassID.mutex.synchronize{
+ klass = CmdClassID.join(TkCore::INTERP._ip_id_)
+ CmdClassID[1].succ!
+ }
+ parent = nil # ignore parent
+ else
+ klass = klass.to_s if klass.kind_of?(Symbol)
+ unless (?A..?Z) === klass[0]
+ fail ArgumentError, "bad string '#{klass}' for class name"
+ end
+ if parent == nil
+ install_win(nil)
+ elsif parent.kind_of?(TkWindow)
+ install_win(parent.path)
+ elsif parent <= @@resource_proc_class
+ install_win(parent::CARRIER)
+ else
+ fail ArgumentError, "parent must be Resource-Proc class"
+ end
+ carrier = Tk.tk_call_without_enc('frame', @path, '-class', klass)
+ end
+
+ unless func.kind_of?(Array)
+ fail ArgumentError, "method-list must be Array"
+ end
+ func_str = func.join(' ')
+
+ if parent.kind_of?(Class) && parent <= @@resource_proc_class
+ cmd_klass = Class.new(parent)
+ else
+ cmd_klass = Class.new(TkOptionDB.module_eval('@@resource_proc_class'))
+ end
+ cmd_klass.const_set(:CARRIER, carrier.dup.freeze)
+
+ cmd_klass.instance_variable_set('@method_tbl', TkCore::INTERP.create_table)
+ cmd_klass.instance_variable_set('@add_method', add)
+ cmd_klass.instance_variable_set('@safe_mode', safe)
+ func.each{|f|
+ cmd_klass.instance_variable_get('@method_tbl')[f.to_s.intern] = nil
+ }
+=begin
+ cmd_klass.const_set(:METHOD_TBL, TkCore::INTERP.create_table)
+ cmd_klass.const_set(:ADD_METHOD, add)
+ cmd_klass.const_set(:SAFE_MODE, safe)
+ func.each{|f| cmd_klass::METHOD_TBL[f.to_s.intern] = nil }
+=end
+
+ cmd_klass
+ end
+ module_function :__create_new_class
+ private_class_method :__create_new_class
+
+ def __remove_methods_of_proc_class(klass)
+ # for security, make these methods invalid
+ class << klass
+ def __null_method(*args); nil; end
+ [ :class_eval, :name, :superclass, :clone, :dup, :autoload, :autoload?,
+ :ancestors, :const_defined?, :const_get, :const_set, :const_missing,
+ :class_variables, :constants, :included_modules, :instance_methods,
+ :method_defined?, :module_eval, :private_instance_methods,
+ :protected_instance_methods, :public_instance_methods,
+ :singleton_methods, :remove_const, :remove_method, :undef_method,
+ :to_s, :inspect, :display, :method, :methods, :respond_to?,
+ :instance_variable_get, :instance_variable_set, :instance_method,
+ :instance_eval, :instance_exec, :instance_variables, :kind_of?, :is_a?,
+ :private_methods, :protected_methods, :public_methods ].each{|m|
+ alias_method(m, :__null_method)
+ }
+ end
+ end
+ module_function :__remove_methods_of_proc_class
+ private_class_method :__remove_methods_of_proc_class
+
+ RAND_BASE_CNT = [0]
+ RAND_BASE_HEAD = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
+ RAND_BASE_CHAR = RAND_BASE_HEAD + 'abcdefghijklmnopqrstuvwxyz0123456789_'
+ def __get_random_basename
+ name = '%s%03d' % [RAND_BASE_HEAD[rand(RAND_BASE_HEAD.size),1],
+ RAND_BASE_CNT[0]]
+ len = RAND_BASE_CHAR.size
+ (6+rand(10)).times{
+ name << RAND_BASE_CHAR[rand(len),1]
+ }
+ RAND_BASE_CNT[0] = RAND_BASE_CNT[0] + 1
+ name
+ end
+ module_function :__get_random_basename
+ private_class_method :__get_random_basename
+
+ # define new proc class :
+ # If you want to modify the new class or create a new subclass,
+ # you must do such operation in the block parameter.
+ # Because the created class is flozen after evaluating the block.
+ def new_proc_class(klass, func, safe = 4, add = false, parent = nil, &b)
+ new_klass = __create_new_class(klass, func, safe, add, parent)
+ new_klass.class_eval(&b) if block_given?
+ __remove_methods_of_proc_class(new_klass)
+ new_klass.freeze
+ new_klass
+ end
+ module_function :new_proc_class
+
+ def eval_under_random_base(parent = nil, &b)
+ new_klass = __create_new_class(__get_random_basename(),
+ [], 4, false, parent)
+ ret = new_klass.class_eval(&b) if block_given?
+ __remove_methods_of_proc_class(new_klass)
+ new_klass.freeze
+ ret
+ end
+ module_function :eval_under_random_base
+
+ def new_proc_class_random(klass, func, safe = 4, add = false, &b)
+ eval_under_random_base(){
+ TkOptionDB.new_proc_class(klass, func, safe, add, self, &b)
+ }
+ end
+ module_function :new_proc_class_random
+end
+TkOption = TkOptionDB
+TkResourceDB = TkOptionDB
diff --git a/jni/ruby/ext/tk/lib/tk/optionobj.rb b/jni/ruby/ext/tk/lib/tk/optionobj.rb
new file mode 100644
index 0000000..29b06da
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tk/optionobj.rb
@@ -0,0 +1,212 @@
+#
+# tk/optionobj.rb : control options for a group of widgets
+#
+# NOTE: If you want to use key-only option (no value),
+# use Tk::None for the value of the key-only option.
+#
+# e.g. hash_kv({'aaa'=>1, 'bbb'=>Tk::None, 'ccc'=>3})
+# => ["-aaa", 1, "-bbb", "-ccc", 3]
+#
+require 'tk'
+
+module Tk
+ class OptionObj < Hash
+ include TkUtil
+
+ def initialize(hash = nil)
+ super()
+ @observ = []
+ update_without_notify(_symbolkey2str(hash)) if hash
+ end
+
+ def observ_info
+ @observ.dup
+ end
+
+ def observs
+ @observ.collect{|win|
+ if win.kind_of?(Array)
+ win[0]
+ else
+ win
+ end
+ }
+ end
+
+ def _remove_win(win)
+ if win.kind_of?(Array)
+ widget, method = win
+ @observ.delete_if{|x|
+ if x.kind_of?(Array)
+ x[0] == widget
+ else
+ x == widget
+ end
+ }
+ else
+ @observ.delete_if{|x|
+ if x.kind_of?(Array)
+ x[0] == win
+ else
+ x == win
+ end
+ }
+ end
+ end
+ private :_remove_win
+
+ def assign(*wins)
+ # win :=
+ # widget #==> call widget.configure(hash)
+ # [widget] #==> call widget.configure(hash)
+ # [widget, nil, {src=>target, ... }]
+ # #==> call widget.configure(hash)
+ # with converting hash-key
+ # [widget, method] #==> call widget.method(hash)
+ # [widget, method, {src=>target, ... }]
+ # #==> call widget.method(hash)
+ # with converting hash-key
+ # [widget [receiver, method, arg, ... ]]
+ # #==> call receiver.method(arg, ... , hash)
+ # [widget [receiver, method, arg, ... ], {src=>target, ... }]
+ # #==> call receiver.method(arg, ... , hash)
+ # with onverting hash-key
+ #
+ # src := option_name_on_optobj
+ #
+ # target :=
+ # nil #==> not use the src
+ # option_name_on_target_widget
+ # [ option_name_on_target_widget, ... ]
+ # #==> set all of them
+ #
+ wins.each{|win|
+ _remove_win(win)
+ @observ << win
+ notify(win)
+ }
+ self
+ end
+
+ def unassign(*wins)
+ wins.each{|win|
+ _remove_win(win)
+ }
+ self
+ end
+
+ def notify(target = nil)
+ if target
+ targets = [target]
+ elsif @observ.empty?
+ return self
+ else
+ targets = @observ.dup
+ end
+
+ return self if empty?
+
+ org_hash = _symbolkey2str(self)
+
+ targets.each{|win|
+ widget = receiver = win
+ hash = org_hash
+ begin
+ if win.kind_of?(Array)
+ widget, method, conv_tbl = win
+ receiver = widget
+
+ if conv_tbl
+ hash = {}
+ org_hash.each{|key, val|
+ key = conv_tbl[key] if conv_tbl.key?(key)
+ next unless key
+ if key.kind_of?(Array)
+ key.each{|k| hash[k] = val}
+ else
+ hash[key] = val
+ end
+ }
+ end
+
+ if method.kind_of?(Array)
+ receiver, method, *args = method
+ receiver.__send__(method, *(args << hash))
+ elsif method
+ widget.__send__(method, hash)
+ else
+ widget.configure(hash)
+ end
+
+ else
+ widget.configure(self)
+ end
+ rescue => e
+ if ( ( widget.kind_of?(TkObject) \
+ && widget.respond_to?('exist?') \
+ && ! receiver.exist? ) \
+ || ( receiver.kind_of?(TkObject) \
+ && receiver.respond_to?('exist?') \
+ && ! receiver.exist? ) )
+ @observ.delete(win)
+ else
+ fail e
+ end
+ end
+ }
+
+ self
+ end
+ alias apply notify
+
+ def +(hash)
+ unless hash.kind_of?(Hash)
+ fail ArgumentError, "expect a Hash"
+ end
+ new_obj = self.dup
+ new_obj.update_without_notify(_symbolkey2str(hash))
+ new_obj
+ end
+
+ alias update_without_notify update
+
+ def update(hash)
+ update_without_notify(_symbolkey2str(hash))
+ notify
+ end
+
+ def configure(key, value=nil)
+ if key.kind_of?(Hash)
+ update(key)
+ else
+ store(key,value)
+ end
+ end
+
+ def [](key)
+ super(key.to_s)
+ end
+ alias cget []
+
+ def store(key, val)
+ key = key.to_s
+ super(key, val)
+ notify
+ end
+ def []=(key, val)
+ store(key,val)
+ end
+
+ def replace(hash)
+ super(_symbolkey2str(hash))
+ notify
+ end
+
+ def default(opt)
+ fail RuntimeError, "unknown option `#{opt}'"
+ end
+ private :default
+
+ undef :default=
+ end
+end
diff --git a/jni/ruby/ext/tk/lib/tk/pack.rb b/jni/ruby/ext/tk/lib/tk/pack.rb
new file mode 100644
index 0000000..220a38e
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tk/pack.rb
@@ -0,0 +1,107 @@
+#
+# tk/pack.rb : control pack geometry manager
+#
+require 'tk'
+
+module TkPack
+ include Tk
+ extend Tk
+
+ TkCommandNames = ['pack'.freeze].freeze
+
+=begin
+ def configure(win, *args)
+ if args[-1].kind_of?(Hash)
+ opts = args.pop
+ else
+ opts = {}
+ end
+ params = []
+ # params.push((win.kind_of?(TkObject))? win.epath: win)
+ params.push(_epath(win))
+ args.each{|win|
+ # params.push((win.kind_of?(TkObject))? win.epath: win)
+ params.push(_epath(win))
+ }
+ opts.each{|k, v|
+ params.push("-#{k}")
+ # params.push((v.kind_of?(TkObject))? v.epath: v)
+ params.push(_epath(v))
+ }
+ tk_call_without_enc("pack", 'configure', *params)
+ end
+=end
+ def configure(*args)
+ if args[-1].kind_of?(Hash)
+ opts = args.pop
+ else
+ opts = {}
+ end
+ fail ArgumentError, 'no widget is given' if args.empty?
+ params = []
+ args.flatten(1).each{|win| params.push(_epath(win))}
+ opts.each{|k, v|
+ params.push("-#{k}")
+ params.push(_epath(v)) # have to use 'epath' (hash_kv() is unavailable)
+ }
+ tk_call_without_enc("pack", 'configure', *params)
+ end
+ alias pack configure
+
+ def forget(*args)
+ return '' if args.size == 0
+ wins = args.collect{|win|
+ # (win.kind_of?(TkObject))? win.epath: win
+ _epath(win)
+ }
+ tk_call_without_enc('pack', 'forget', *wins)
+ end
+
+ def info(slave)
+ # slave = slave.epath if slave.kind_of?(TkObject)
+ slave = _epath(slave)
+ ilist = list(tk_call_without_enc('pack', 'info', slave))
+ info = {}
+ while key = ilist.shift
+ info[key[1..-1]] = ilist.shift
+ end
+ return info
+ end
+
+ def propagate(master, mode=None)
+ # master = master.epath if master.kind_of?(TkObject)
+ master = _epath(master)
+ if mode == None
+ bool(tk_call_without_enc('pack', 'propagate', master))
+ else
+ tk_call_without_enc('pack', 'propagate', master, mode)
+ end
+ end
+
+ def slaves(master)
+ # master = master.epath if master.kind_of?(TkObject)
+ master = _epath(master)
+ list(tk_call_without_enc('pack', 'slaves', master))
+ end
+
+ module_function :pack, :configure, :forget, :info, :propagate, :slaves
+end
+=begin
+def TkPack(win, *args)
+ if args[-1].kind_of?(Hash)
+ opts = args.pop
+ else
+ opts = {}
+ end
+ params = []
+ params.push((win.kind_of?(TkObject))? win.epath: win)
+ args.each{|win|
+ params.push((win.kind_of?(TkObject))? win.epath: win)
+ }
+ opts.each{|k, v|
+ params.push("-#{k}")
+ params.push((v.kind_of?(TkObject))? v.epath: v)
+ }
+ tk_call_without_enc("pack", *params)
+end
+=end
diff --git a/jni/ruby/ext/tk/lib/tk/package.rb b/jni/ruby/ext/tk/lib/tk/package.rb
new file mode 100644
index 0000000..0c32973
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tk/package.rb
@@ -0,0 +1,143 @@
+#
+# tk/package.rb : package command
+#
+require 'tk'
+
+module TkPackage
+ include TkCore
+ extend TkPackage
+
+ TkCommandNames = ['package'.freeze].freeze
+
+ def add_path(path)
+ Tk::AUTO_PATH.value = Tk::AUTO_PATH.to_a << path
+ end
+
+ def forget(package)
+ tk_call('package', 'forget', package)
+ nil
+ end
+
+ def if_needed(pkg, ver, *arg, &b)
+ size = arg.size
+
+ if size==0 && !b
+ # proc info
+ procedure(tk_call('package', 'ifneeded', pkg, ver))
+
+ elsif size==0 && b
+ # set proc
+ cmd = proc(&b)
+ tk_call('package', 'ifneeded', pkg, ver, cmd)
+ cmd
+
+ elsif size==1 && !b
+ # set proc
+ cmd = arg[0]
+ if cmd
+ tk_call('package', 'ifneeded', pkg, ver, cmd)
+ cmd
+ else
+ # remove proc
+ tk_call('package', 'ifneeded', pkg, ver, '')
+ nil
+ end
+
+ else
+ fail ArgumentError, 'too many arguments'
+ end
+ end
+
+ def names
+ tk_split_simplelist(tk_call('package', 'names'))
+ end
+
+ def provide(package, version=nil)
+ if version
+ tk_call('package', 'provide', package, version)
+ end
+ if (ret = tk_call('package', 'provide', package)) == ''
+ nil
+ else
+ ret
+ end
+ end
+
+ def present(package, version=None)
+ begin
+ tk_call('package', 'present', package, version)
+ rescue => e
+ fail e.class, 'TkPackage ' << e.message
+ end
+ end
+
+ def present_exact(package, version)
+ begin
+ tk_call('package', 'present', '-exact', package, version)
+ rescue => e
+ fail e.class, 'TkPackage ' << e.message
+ end
+ end
+
+ def require(package, version=None)
+ begin
+ tk_call('package', 'require', package, version)
+ rescue => e
+ fail e.class, 'TkPackage ' << e.message
+ end
+ end
+
+ def require_exact(package, version)
+ begin
+ tk_call('package', 'require', '-exact', package, version)
+ rescue => e
+ fail e.class, 'TkPackage ' << e.message
+ end
+ end
+
+ def unknown_proc(*arg, &b)
+ size = arg.size
+
+ if size==0 && !b
+ # proc info
+ procedure(tk_call('package', 'unknown'))
+
+ elsif size==0 && b
+ # set proc
+ cmd = proc(&b)
+ tk_call('package', 'unknown', cmd)
+ cmd
+
+ elsif size==1 && !b
+ # set proc
+ cmd = arg[0]
+ if cmd
+ tk_call('package', 'unknown', cmd)
+ cmd
+ else
+ # remove proc
+ tk_call('package', 'unknown', '')
+ nil
+ end
+
+ else
+ fail ArgumentError, 'too many arguments'
+ end
+ end
+
+ def versions(package)
+ tk_split_simplelist(tk_call('package', 'versions', package))
+ end
+
+ def vcompare(version1, version2)
+ number(tk_call('package', 'vcompare', version1, version2))
+ end
+
+ def vsatisfies(version1, version2)
+ bool(tk_call('package', 'vsatisfies', version1, version2))
+ end
+
+ def prefer(setting = None)
+ tk_call('package', 'prefer', setting)
+ end
+end
diff --git a/jni/ruby/ext/tk/lib/tk/palette.rb b/jni/ruby/ext/tk/lib/tk/palette.rb
new file mode 100644
index 0000000..9462bb0
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tk/palette.rb
@@ -0,0 +1,55 @@
+#
+# tk/palette.rb : methods for Tcl/Tk standard library 'palette.tcl'
+# 1998/06/21 by Hidetoshi Nagai <nagai@ai.kyutech.ac.jp>
+#
+require 'tk'
+
+module TkPalette
+ include Tk
+ extend Tk
+
+ TkCommandNames = [
+ 'tk_setPalette'.freeze,
+ 'tk_bisque'.freeze,
+ 'tkDarken'.freeze
+ ].freeze
+
+ def TkPalette.set(*args)
+ args = args[0].to_a.flatten if args[0].kind_of? Hash
+ tk_call('tk_setPalette', *args)
+ end
+ def TkPalette.setPalette(*args)
+ TkPalette.set(*args)
+ end
+
+ def TkPalette.bisque
+ tk_call('tk_bisque')
+ end
+
+ def TkPalette.darken(color, percent)
+ tk_call('tkDarken', color, percent)
+ end
+
+ def TkPalette.recolorTree(win, colors)
+ if not colors.kind_of?(Hash)
+ fail "2nd arg need to be Hash"
+ end
+
+ tk_call('global', "tkPalette")
+ colors.each{|key, value|
+ begin
+ if win.cget(key) == tk_call('set', "tkPalette(#{key})")
+ win[key] = colors[key]
+ end
+ rescue
+ # ignore
+ end
+ }
+
+ TkWinfo.children(win).each{|w| TkPalette.recolorTree(w, colors)}
+ end
+
+ def recolorTree(colors)
+ TkPalette.recolorTree(self, colors)
+ end
+end
diff --git a/jni/ruby/ext/tk/lib/tk/panedwindow.rb b/jni/ruby/ext/tk/lib/tk/panedwindow.rb
new file mode 100644
index 0000000..0440780
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tk/panedwindow.rb
@@ -0,0 +1,260 @@
+#
+# tk/panedwindow.rb : treat panedwindow
+#
+require 'tk'
+
+class Tk::PanedWindow<TkWindow
+ TkCommandNames = ['panedwindow'.freeze].freeze
+ WidgetClassName = 'Panedwindow'.freeze
+ WidgetClassNames[WidgetClassName] ||= self
+ #def create_self(keys)
+ # if keys and keys != None
+ # tk_call_without_enc('panedwindow', @path, *hash_kv(keys, true))
+ # else
+ # tk_call_without_enc('panedwindow', @path)
+ # end
+ #end
+ #private :create_self
+
+ def add(*args)
+ keys = args.pop
+ fail ArgumentError, "no window in arguments" unless keys
+ if keys && keys.kind_of?(Hash)
+ fail ArgumentError, "no window in arguments" if args == []
+ # args = args.collect{|w| (w.kind_of?(TkObject))? w.epath: w }
+ args = args.collect{|w| _epath(w) }
+ #args.push(hash_kv(keys))
+ args.concat(hash_kv(keys))
+ else
+ args.push(keys) if keys
+ # args = args.collect{|w| (w.kind_of?(TkObject))? w.epath: w }
+ args = args.collect{|w| _epath(w) }
+ end
+ tk_send_without_enc('add', *args)
+ self
+ end
+
+ def forget(win, *wins)
+ wins.unshift(win)
+ # tk_send_without_enc('forget', *((w.kind_of?(TkObject))? w.epath: w))
+ tk_send_without_enc('forget', *(wins.collect{|w| _epath(w)}))
+ self
+ end
+ alias del forget
+ alias delete forget
+ alias remove forget
+
+ def identify(x, y)
+ list(tk_send_without_enc('identify', x, y))
+ end
+
+ def proxy_coord
+ list(tk_send_without_enc('proxy', 'coord'))
+ end
+ def proxy_forget
+ tk_send_without_enc('proxy', 'forget')
+ self
+ end
+ def proxy_place(x, y)
+ tk_send_without_enc('proxy', 'place', x, y)
+ self
+ end
+
+ def sash_coord(index)
+ list(tk_send('sash', 'coord', index))
+ end
+ def sash_dragto(index, x, y)
+ tk_send('sash', 'dragto', index, x, y)
+ self
+ end
+ def sash_mark(index, x, y)
+ tk_send('sash', 'mark', index, x, y)
+ self
+ end
+ def sash_place(index, x, y)
+ tk_send('sash', 'place', index, x, y)
+ self
+ end
+
+ def panecget_strict(win, key)
+ # win = win.epath if win.kind_of?(TkObject)
+ win = _epath(win)
+ tk_tcl2ruby(tk_send_without_enc('panecget', win, "-#{key}"))
+ end
+ def panecget(win, key)
+ unless TkItemConfigMethod.__IGNORE_UNKNOWN_CONFIGURE_OPTION__
+ panecget_strict(win, key)
+ else
+ begin
+ panecget_strict(win, key)
+ rescue => e
+ begin
+ if current_paneconfiginfo(win).has_key?(option.to_s)
+ # not tag error & option is known -> error on known option
+ fail e
+ else
+ # not tag error & option is unknown
+ nil
+ end
+ rescue
+ fail e # tag error
+ end
+ end
+ end
+ end
+
+ def paneconfigure(win, key, value=nil)
+ # win = win.epath if win.kind_of?(TkObject)
+ win = _epath(win)
+ if key.kind_of? Hash
+ params = []
+ key.each{|k, v|
+ params.push("-#{k}")
+ # params.push((v.kind_of?(TkObject))? v.epath: v)
+ params.push(_epath(v))
+ }
+ tk_send_without_enc('paneconfigure', win, *params)
+ else
+ # value = value.epath if value.kind_of?(TkObject)
+ value = _epath(value)
+ tk_send_without_enc('paneconfigure', win, "-#{key}", value)
+ end
+ self
+ end
+ alias pane_config paneconfigure
+
+ def paneconfiginfo(win, key=nil)
+ if TkComm::GET_CONFIGINFO_AS_ARRAY
+ # win = win.epath if win.kind_of?(TkObject)
+ win = _epath(win)
+ if key
+ #conf = tk_split_list(tk_send_without_enc('paneconfigure',
+ # win, "-#{key}"))
+ conf = tk_split_list(tk_send_without_enc('paneconfigure',
+ win, "-#{key}"),
+ false, true)
+ conf[0] = conf[0][1..-1]
+ if conf[0] == 'hide'
+ conf[3] = bool(conf[3]) unless conf[3].empty?
+ conf[4] = bool(conf[4]) unless conf[4].empty?
+ end
+ conf
+ else
+ #tk_split_simplelist(tk_send_without_enc('paneconfigure',
+ # win)).collect{|conflist|
+ # conf = tk_split_simplelist(conflist)
+ tk_split_simplelist(tk_send_without_enc('paneconfigure', win),
+ false, false).collect{|conflist|
+ conf = tk_split_simplelist(conflist, false, true)
+ conf[0] = conf[0][1..-1]
+ if conf[3]
+ if conf[0] == 'hide'
+ conf[3] = bool(conf[3]) unless conf[3].empty?
+ elsif conf[3].index('{')
+ conf[3] = tk_split_list(conf[3])
+ else
+ conf[3] = tk_tcl2ruby(conf[3])
+ end
+ end
+ if conf[4]
+ if conf[0] == 'hide'
+ conf[4] = bool(conf[4]) unless conf[4].empty?
+ elsif conf[4].index('{')
+ conf[4] = tk_split_list(conf[4])
+ else
+ conf[4] = tk_tcl2ruby(conf[4])
+ end
+ end
+ conf[1] = conf[1][1..-1] if conf.size == 2 # alias info
+ conf
+ }
+ end
+ else # ! TkComm::GET_CONFIGINFO_AS_ARRAY
+ # win = win.epath if win.kind_of?(TkObject)
+ win = _epath(win)
+ if key
+ #conf = tk_split_list(tk_send_without_enc('paneconfigure',
+ # win, "-#{key}"))
+ conf = tk_split_list(tk_send_without_enc('paneconfigure',
+ win, "-#{key}"),
+ false, true)
+ key = conf.shift[1..-1]
+ if key == 'hide'
+ conf[2] = bool(conf[2]) unless conf[2].empty?
+ conf[3] = bool(conf[3]) unless conf[3].empty?
+ end
+ { key => conf }
+ else
+ ret = {}
+ #tk_split_simplelist(tk_send_without_enc('paneconfigure',
+ # win)).each{|conflist|
+ # conf = tk_split_simplelist(conflist)
+ tk_split_simplelist(tk_send_without_enc('paneconfigure', win),
+ false, false).each{|conflist|
+ conf = tk_split_simplelist(conflist, false, true)
+ key = conf.shift[1..-1]
+ if key
+ if key == 'hide'
+ conf[2] = bool(conf[2]) unless conf[2].empty?
+ elsif conf[2].index('{')
+ conf[2] = tk_split_list(conf[2])
+ else
+ conf[2] = tk_tcl2ruby(conf[2])
+ end
+ end
+ if conf[3]
+ if key == 'hide'
+ conf[3] = bool(conf[3]) unless conf[3].empty?
+ elsif conf[3].index('{')
+ conf[3] = tk_split_list(conf[3])
+ else
+ conf[3] = tk_tcl2ruby(conf[3])
+ end
+ end
+ if conf.size == 1
+ ret[key] = conf[0][1..-1] # alias info
+ else
+ ret[key] = conf
+ end
+ }
+ ret
+ end
+ end
+ end
+ alias pane_configinfo paneconfiginfo
+
+ def current_paneconfiginfo(win, key=nil)
+ if TkComm::GET_CONFIGINFO_AS_ARRAY
+ if key
+ conf = paneconfiginfo(win, key)
+ {conf[0] => conf[4]}
+ else
+ ret = {}
+ paneconfiginfo(win).each{|conf|
+ ret[conf[0]] = conf[4] if conf.size > 2
+ }
+ ret
+ end
+ else # ! TkComm::GET_CONFIGINFO_AS_ARRAY
+ ret = {}
+ paneconfiginfo(win, key).each{|k, conf|
+ ret[k] = conf[-1] if conf.kind_of?(Array)
+ }
+ ret
+ end
+ end
+
+ alias current_pane_configinfo current_paneconfiginfo
+
+ def panes
+ list(tk_send_without_enc('panes'))
+ end
+end
+
+Tk::Panedwindow = Tk::PanedWindow
+#TkPanedWindow = Tk::PanedWindow unless Object.const_defined? :TkPanedWindow
+#TkPanedwindow = Tk::Panedwindow unless Object.const_defined? :TkPanedwindow
+#Tk.__set_toplevel_aliases__(:Tk, Tk::PanedWindow,
+# :TkPanedWindow, :TkPanedwindow)
+Tk.__set_loaded_toplevel_aliases__('tk/panedwindow.rb', :Tk, Tk::PanedWindow,
+ :TkPanedWindow, :TkPanedwindow)
diff --git a/jni/ruby/ext/tk/lib/tk/place.rb b/jni/ruby/ext/tk/lib/tk/place.rb
new file mode 100644
index 0000000..109d866
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tk/place.rb
@@ -0,0 +1,128 @@
+#
+# tk/place.rb : control place geometry manager
+#
+require 'tk'
+
+module TkPlace
+ include Tk
+ extend Tk
+
+ TkCommandNames = ['place'.freeze].freeze
+
+ def configure(win, slot, value=None)
+ # for >= Tk8.4a2 ?
+ # win = win.epath if win.kind_of?(TkObject)
+ win = _epath(win)
+ if slot.kind_of? Hash
+ params = []
+ slot.each{|k, v|
+ params.push("-#{k}")
+ # params.push((v.kind_of?(TkObject))? v.epath: v)
+ params.push(_epath(v))
+ }
+ tk_call_without_enc('place', 'configure', win, *params)
+ else
+ # value = value.epath if value.kind_of?(TkObject)
+ value = _epath(value)
+ tk_call_without_enc('place', 'configure', win, "-#{slot}", value)
+ end
+ end
+ alias place configure
+
+ def configinfo(win, slot = nil)
+ # for >= Tk8.4a2 ?
+ if TkComm::GET_CONFIGINFOwoRES_AS_ARRAY
+ # win = win.epath if win.kind_of?(TkObject)
+ win = _epath(win)
+ if slot
+ #conf = tk_split_list(tk_call_without_enc('place', 'configure',
+ # win, "-#{slot}") )
+ conf = tk_split_simplelist(tk_call_without_enc('place', 'configure',
+ win, "-#{slot}") )
+ conf[0] = conf[0][1..-1]
+ conf[1] = tk_tcl2ruby(conf[1])
+ conf[2] = tk_tcl2ruby(conf[1])
+ conf[3] = tk_tcl2ruby(conf[1])
+ conf[4] = tk_tcl2ruby(conf[1])
+ conf
+ else
+ tk_split_simplelist(tk_call_without_enc('place', 'configure',
+ win)).collect{|conflist|
+ #conf = list(conflist)
+ conf = simplelist(conflist).collect!{|inf| tk_tcl2ruby(inf)}
+ conf[0] = conf[0][1..-1]
+ conf
+ }
+ end
+ else # ! TkComm::GET_CONFIGINFOwoRES_AS_ARRAY
+ current_configinfo(win, slot)
+ end
+ end
+
+ def current_configinfo(win, slot = nil)
+ # win = win.epath if win.kind_of?(TkObject)
+ win = _epath(win)
+ if slot
+ #conf = tk_split_list(tk_call_without_enc('place', 'configure',
+ # win, "-#{slot}") )
+ conf = tk_split_simplelist(tk_call_without_enc('place', 'configure',
+ win, "-#{slot}") )
+ # { conf[0][1..-1] => conf[1] }
+ { conf[0][1..-1] => tk_tcl2ruby(conf[4]) }
+ else
+ ret = {}
+ #tk_split_list(tk_call_without_enc('place','configure',win)).each{|conf|
+ tk_split_simplelist(tk_call_without_enc('place', 'configure',
+ win)).each{|conf_list|
+ #ret[conf[0][1..-1]] = conf[1]
+ conf = simplelist(conf_list)
+ ret[conf[0][1..-1]] = tk_tcl2ruby(conf[4])
+ }
+ ret
+ end
+ end
+
+ def forget(win)
+ # win = win.epath if win.kind_of?(TkObject)
+ win = _epath(win)
+ tk_call_without_enc('place', 'forget', win)
+ end
+
+ def info(win)
+ # win = win.epath if win.kind_of?(TkObject)
+ win = _epath(win)
+ #ilist = list(tk_call_without_enc('place', 'info', win))
+ ilist = simplelist(tk_call_without_enc('place', 'info', win))
+ info = {}
+ while key = ilist.shift
+ #info[key[1..-1]] = ilist.shift
+ info[key[1..-1]] = tk_tcl2ruby(ilist.shift)
+ end
+ return info
+ end
+
+ def slaves(master)
+ # master = master.epath if master.kind_of?(TkObject)
+ master = _epath(master)
+ list(tk_call('place', 'slaves', master))
+ end
+
+ module_function :place, :configure, :configinfo, :current_configinfo
+ module_function :forget, :info, :slaves
+end
+=begin
+def TkPlace(win, slot, value=None)
+ win = win.epath if win.kind_of?(TkObject)
+ if slot.kind_of? Hash
+ params = []
+ slot.each{|k, v|
+ params.push("-#{k}")
+ params.push((v.kind_of?(TkObject))? v.epath: v)
+ }
+ tk_call_without_enc('place', win, *params)
+ else
+ value = value.epath if value.kind_of?(TkObject)
+ tk_call_without_enc('place', win, "-#{slot}", value)
+ end
+end
+=end
diff --git a/jni/ruby/ext/tk/lib/tk/radiobutton.rb b/jni/ruby/ext/tk/lib/tk/radiobutton.rb
new file mode 100644
index 0000000..627df6d
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tk/radiobutton.rb
@@ -0,0 +1,73 @@
+#
+# tk/radiobutton.rb : treat radiobutton widget
+#
+require 'tk'
+require 'tk/button'
+
+class Tk::RadioButton<Tk::Button
+ TkCommandNames = ['radiobutton'.freeze].freeze
+ WidgetClassName = 'Radiobutton'.freeze
+ WidgetClassNames[WidgetClassName] ||= self
+ #def create_self(keys)
+ # if keys and keys != None
+ # tk_call_without_enc('radiobutton', @path, *hash_kv(keys, true))
+ # else
+ # tk_call_without_enc('radiobutton', @path)
+ # end
+ #end
+ #private :create_self
+
+ def __boolval_optkeys
+ super() << 'indicatoron'
+ end
+ private :__boolval_optkeys
+
+ def __strval_optkeys
+ super() << 'selectcolor'
+ end
+ private :__strval_optkeys
+
+ def __ruby2val_optkeys # { key=>proc, ... }
+ {
+ 'variable'=>proc{|v| tk_trace_variable(v)} # for backward compatibility
+ }
+ end
+ private :__ruby2val_optkeys
+
+
+ def deselect
+ tk_send_without_enc('deselect')
+ self
+ end
+ def select
+ tk_send_without_enc('select')
+ self
+ end
+
+ def get_value
+ var = tk_send_without_enc('cget', '-variable')
+ if TkVariable::USE_TCLs_SET_VARIABLE_FUNCTIONS
+ _fromUTF8(INTERP._get_global_var(var))
+ else
+ INTERP._eval(Kernel.format('global %s; set %s', var, var))
+ end
+ end
+
+ def set_value(val)
+ var = tk_send_without_enc('cget', '-variable')
+ if TkVariable::USE_TCLs_SET_VARIABLE_FUNCTIONS
+ _fromUTF8(INTERP._set_global_var(var, _get_eval_string(val, true)))
+ else
+ s = '"' + _get_eval_string(val).gsub(/[\[\]$"\\]/, '\\\\\&') + '"'
+ INTERP._eval(Kernel.format('global %s; set %s %s', var, var, s))
+ end
+ end
+end
+
+Tk::Radiobutton = Tk::RadioButton
+#TkRadioButton = Tk::RadioButton unless Object.const_defined? :TkRadioButton
+#TkRadiobutton = Tk::Radiobutton unless Object.const_defined? :TkRadiobutton
+#Tk.__set_toplevel_aliases__(:Tk, Tk::RadioButton,
+# :TkRadioButton, :TkRadiobutton)
+Tk.__set_loaded_toplevel_aliases__('tk/radiobutton.rb', :Tk, Tk::RadioButton,
+ :TkRadioButton, :TkRadiobutton)
diff --git a/jni/ruby/ext/tk/lib/tk/root.rb b/jni/ruby/ext/tk/lib/tk/root.rb
new file mode 100644
index 0000000..b4f0bd1
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tk/root.rb
@@ -0,0 +1,95 @@
+#
+# tk/root.rb : treat root widget
+#
+require 'tk'
+require 'tk/wm'
+require 'tk/menuspec'
+
+class Tk::Root<TkWindow
+ include Wm
+ include TkMenuSpec
+
+ def __methodcall_optkeys # { key=>method, ... }
+ TOPLEVEL_METHODCALL_OPTKEYS
+ end
+ private :__methodcall_optkeys
+
+ def Root.new(keys=nil, &b)
+ unless TkCore::INTERP.tk_windows['.']
+ TkCore::INTERP.tk_windows['.'] =
+ super(:without_creating=>true, :widgetname=>'.'){}
+ end
+ root = TkCore::INTERP.tk_windows['.']
+
+ keys = _symbolkey2str(keys)
+
+ # wm commands
+ root.instance_eval{
+ __methodcall_optkeys.each{|key, method|
+ value = keys.delete(key.to_s)
+ self.__send__(method, value) if value
+ }
+ }
+
+ if keys # wm commands ( for backward comaptibility )
+ keys.each{|k,v|
+ if v.kind_of? Array
+ root.__send__(k,*v)
+ else
+ root.__send__(k,v)
+ end
+ }
+ end
+
+ if block_given?
+ if TkCore::WITH_RUBY_VM ### Ruby 1.9 !!!!
+ root.instance_exec(root, &b)
+ else
+ root.instance_eval(&b)
+ end
+ end
+ root
+ end
+
+ WidgetClassName = 'Tk'.freeze
+ WidgetClassNames[WidgetClassName] ||= self
+
+ def self.to_eval
+ # self::WidgetClassName
+ '.'
+ end
+
+ def create_self
+ @path = '.'
+ end
+ private :create_self
+
+ def path
+ "."
+ end
+
+ def add_menu(menu_info, tearoff=false, opts=nil)
+ # See tk/menuspec.rb for menu_info.
+ # opts is a hash of default configs for all of cascade menus.
+ # Configs of menu_info can override it.
+ if tearoff.kind_of?(Hash)
+ opts = tearoff
+ tearoff = false
+ end
+ _create_menubutton(self, menu_info, tearoff, opts)
+ end
+
+ def add_menubar(menu_spec, tearoff=false, opts=nil)
+ # See tk/menuspec.rb for menu_spec.
+ # opts is a hash of default configs for all of cascade menus.
+ # Configs of menu_spec can override it.
+ menu_spec.each{|info| add_menu(info, tearoff, opts)}
+ self.menu
+ end
+
+ def Root.destroy
+ TkCore::INTERP._invoke('destroy', '.')
+ end
+end
+
+TkRoot = Tk::Root unless Object.const_defined? :TkRoot
diff --git a/jni/ruby/ext/tk/lib/tk/scale.rb b/jni/ruby/ext/tk/lib/tk/scale.rb
new file mode 100644
index 0000000..0bdcead
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tk/scale.rb
@@ -0,0 +1,112 @@
+#
+# tk/scale.rb : treat scale widget
+#
+require 'tk'
+
+class Tk::Scale<TkWindow
+ TkCommandNames = ['scale'.freeze].freeze
+ WidgetClassName = 'Scale'.freeze
+ WidgetClassNames[WidgetClassName] ||= self
+
+ def create_self(keys)
+ if keys and keys != None
+ if keys.key?('command') && ! keys['command'].kind_of?(String)
+ cmd = keys.delete('command')
+ keys['command'] = proc{|val| cmd.call(val.to_f)}
+ end
+ unless TkConfigMethod.__IGNORE_UNKNOWN_CONFIGURE_OPTION__
+ #tk_call_without_enc('scale', @path, *hash_kv(keys, true))
+ tk_call_without_enc(self.class::TkCommandNames[0], @path,
+ *hash_kv(keys, true))
+ else
+ begin
+ tk_call_without_enc(self.class::TkCommandNames[0], @path,
+ *hash_kv(keys, true))
+ rescue
+ tk_call_without_enc(self.class::TkCommandNames[0], @path)
+ keys = __check_available_configure_options(keys)
+ unless keys.empty?
+ begin
+ tk_call_without_enc('destroy', @path)
+ rescue
+ # cannot destroy
+ configure(keys)
+ else
+ # re-create widget
+ tk_call_without_enc(self.class::TkCommandNames[0], @path,
+ *hash_kv(keys, true))
+ end
+ end
+ end
+ end
+ else
+ #tk_call_without_enc('scale', @path)
+ tk_call_without_enc(self.class::TkCommandNames[0], @path)
+ end
+ end
+ private :create_self
+
+ def __strval_optkeys
+ super() << 'label'
+ end
+ private :__strval_optkeys
+
+ def _wrap_command_arg(cmd)
+ proc{|val|
+ if val.kind_of?(String)
+ cmd.call(number(val))
+ else
+ cmd.call(val)
+ end
+ }
+ end
+ private :_wrap_command_arg
+
+ def configure_cmd(slot, value)
+ configure(slot=>value)
+ end
+
+ def configure(slot, value=None)
+ if (slot == 'command' || slot == :command)
+ configure('command'=>value)
+ elsif slot.kind_of?(Hash) &&
+ (slot.key?('command') || slot.key?(:command))
+ slot = _symbolkey2str(slot)
+ slot['command'] = _wrap_command_arg(slot.delete('command'))
+ end
+ super(slot, value)
+ end
+
+ def command(cmd=Proc.new)
+ configure('command'=>cmd)
+ end
+
+ def get(x=None, y=None)
+ number(tk_send_without_enc('get', x, y))
+ end
+
+ def coords(val=None)
+ tk_split_list(tk_send_without_enc('coords', val))
+ end
+
+ def identify(x, y)
+ tk_send_without_enc('identify', x, y)
+ end
+
+ def set(val)
+ tk_send_without_enc('set', val)
+ end
+
+ def value
+ get
+ end
+
+ def value= (val)
+ set(val)
+ val
+ end
+end
+
+#TkScale = Tk::Scale unless Object.const_defined? :TkScale
+#Tk.__set_toplevel_aliases__(:Tk, Tk::Scale, :TkScale)
+Tk.__set_loaded_toplevel_aliases__('tk/scale.rb', :Tk, Tk::Scale, :TkScale)
diff --git a/jni/ruby/ext/tk/lib/tk/scrollable.rb b/jni/ruby/ext/tk/lib/tk/scrollable.rb
new file mode 100644
index 0000000..96959b7
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tk/scrollable.rb
@@ -0,0 +1,82 @@
+#
+# tk/scrollable.rb : module for scrollable widget
+#
+require 'tk'
+
+module Tk
+ module XScrollable
+ def xscrollcommand(cmd=Proc.new)
+ configure_cmd 'xscrollcommand', cmd
+ # Tk.update # avoid scrollbar trouble
+ self
+ end
+
+ def xview(*index)
+ if index.size == 0
+ list(tk_send_without_enc('xview'))
+ else
+ tk_send_without_enc('xview', *index)
+ self
+ end
+ end
+ def xview_moveto(*index)
+ xview('moveto', *index)
+ end
+ def xview_scroll(*index)
+ xview('scroll', *index)
+ end
+
+ def xscrollbar(bar=nil)
+ if bar
+ @xscrollbar = bar
+ @xscrollbar.orient 'horizontal'
+ self.xscrollcommand {|*arg| @xscrollbar.set(*arg)}
+ @xscrollbar.command {|*arg| self.xview(*arg)}
+ Tk.update # avoid scrollbar trouble
+ end
+ @xscrollbar
+ end
+ end
+
+ module YScrollable
+ def yscrollcommand(cmd=Proc.new)
+ configure_cmd 'yscrollcommand', cmd
+ # Tk.update # avoid scrollbar trouble
+ self
+ end
+
+ def yview(*index)
+ if index.size == 0
+ list(tk_send_without_enc('yview'))
+ else
+ tk_send_without_enc('yview', *index)
+ self
+ end
+ end
+ def yview_moveto(*index)
+ yview('moveto', *index)
+ end
+ def yview_scroll(*index)
+ yview('scroll', *index)
+ end
+
+ def yscrollbar(bar=nil)
+ if bar
+ @yscrollbar = bar
+ @yscrollbar.orient 'vertical'
+ self.yscrollcommand {|*arg| @yscrollbar.set(*arg)}
+ @yscrollbar.command {|*arg| self.yview(*arg)}
+ Tk.update # avoid scrollbar trouble
+ end
+ @yscrollbar
+ end
+ end
+
+ X_Scrollable = XScrollable
+ Y_Scrollable = YScrollable
+
+ module Scrollable
+ include XScrollable
+ include YScrollable
+ end
+end
diff --git a/jni/ruby/ext/tk/lib/tk/scrollbar.rb b/jni/ruby/ext/tk/lib/tk/scrollbar.rb
new file mode 100644
index 0000000..c0ac201
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tk/scrollbar.rb
@@ -0,0 +1,183 @@
+#
+# tk/scrollbar.rb : treat scrollbar widget
+#
+require 'tk'
+
+class Tk::Scrollbar<TkWindow
+ TkCommandNames = ['scrollbar'.freeze].freeze
+ WidgetClassName = 'Scrollbar'.freeze
+ WidgetClassNames[WidgetClassName] ||= self
+
+ def create_self(keys)
+ @assigned = []
+ @scroll_proc = proc{|*args|
+ if self.orient == 'horizontal'
+ @assigned.each{|w| w.xview(*args)}
+ else # 'vertical'
+ @assigned.each{|w| w.yview(*args)}
+ end
+ }
+
+ if keys and keys != None
+ unless TkConfigMethod.__IGNORE_UNKNOWN_CONFIGURE_OPTION__
+ #tk_call_without_enc('scrollbar', @path, *hash_kv(keys, true))
+ tk_call_without_enc(self.class::TkCommandNames[0], @path,
+ *hash_kv(keys, true))
+ else
+ begin
+ tk_call_without_enc(self.class::TkCommandNames[0], @path,
+ *hash_kv(keys, true))
+ rescue
+ tk_call_without_enc(self.class::TkCommandNames[0], @path)
+ keys = __check_available_configure_options(keys)
+ unless keys.empty?
+ begin
+ tk_call_without_enc('destroy', @path)
+ rescue
+ # cannot destroy
+ configure(keys)
+ else
+ # re-create widget
+ tk_call_without_enc(self.class::TkCommandNames[0], @path,
+ *hash_kv(keys, true))
+ end
+ end
+ end
+ end
+ else
+ #tk_call_without_enc('scrollbar', @path)
+ tk_call_without_enc(self.class::TkCommandNames[0], @path)
+ end
+ end
+ private :create_self
+
+ def propagate_set(src_win, first, last)
+ self.set(first, last)
+ if self.orient == 'horizontal'
+ @assigned.each{|w| w.xview('moveto', first) if w != src_win}
+ else # 'vertical'
+ @assigned.each{|w| w.yview('moveto', first) if w != src_win}
+ end
+ end
+
+ def assign(*wins)
+ begin
+ self.command(@scroll_proc) if self.cget('command').cmd != @scroll_proc
+ rescue Exception
+ self.command(@scroll_proc)
+ end
+ orient = self.orient
+ wins.each{|w|
+ @assigned << w unless @assigned.index(w)
+ if orient == 'horizontal'
+ w.xscrollcommand proc{|first, last| self.propagate_set(w, first, last)}
+ else # 'vertical'
+ w.yscrollcommand proc{|first, last| self.propagate_set(w, first, last)}
+ end
+ }
+ Tk.update # avoid scrollbar trouble
+ self
+ end
+
+ def assigned_list
+ begin
+ return @assigned.dup if self.cget('command').cmd == @scroll_proc
+ rescue Exception
+ end
+ fail RuntimeError, "not depend on the assigned_list"
+ end
+
+ def configure(*args)
+ ret = super(*args)
+ # Tk.update # avoid scrollbar trouble
+ ret
+ end
+
+ #def delta(deltax=None, deltay=None)
+ def delta(deltax, deltay)
+ number(tk_send_without_enc('delta', deltax, deltay))
+ end
+
+ #def fraction(x=None, y=None)
+ def fraction(x, y)
+ number(tk_send_without_enc('fraction', x, y))
+ end
+
+ def identify(x, y)
+ tk_send_without_enc('identify', x, y)
+ end
+
+ def get
+ #ary1 = tk_send('get').split
+ #ary2 = []
+ #for i in ary1
+ # ary2.push number(i)
+ #end
+ #ary2
+ list(tk_send_without_enc('get'))
+ end
+
+ def set(first, last)
+ tk_send_without_enc('set', first, last)
+ self
+ end
+
+ def activate(element=None)
+ tk_send_without_enc('activate', element)
+ end
+
+ def moveto(fraction)
+ tk_send_without_enc('moveto', fraction)
+ self
+ end
+
+ def scroll(*args)
+ tk_send_without_enc('scroll', *args)
+ self
+ end
+
+ def scroll_units(num)
+ scroll(num, 'units')
+ self
+ end
+
+ def scroll_pages(num)
+ scroll(num, 'pages')
+ self
+ end
+end
+
+#TkScrollbar = Tk::Scrollbar unless Object.const_defined? :TkScrollbar
+#Tk.__set_toplevel_aliases__(:Tk, Tk::Scrollbar, :TkScrollbar)
+Tk.__set_loaded_toplevel_aliases__('tk/scrollbar.rb', :Tk, Tk::Scrollbar,
+ :TkScrollbar)
+
+
+class Tk::XScrollbar<Tk::Scrollbar
+ def create_self(keys)
+ keys = {} unless keys
+ keys['orient'] = 'horizontal'
+ super(keys)
+ end
+ private :create_self
+end
+
+#TkXScrollbar = Tk::XScrollbar unless Object.const_defined? :TkXScrollbar
+#Tk.__set_toplevel_aliases__(:Tk, Tk::XScrollbar, :TkXScrollbar)
+Tk.__set_loaded_toplevel_aliases__('tk/scrollbar.rb', :Tk, Tk::XScrollbar,
+ :TkXScrollbar)
+
+
+class Tk::YScrollbar<Tk::Scrollbar
+ def create_self(keys)
+ keys = {} unless keys
+ keys['orient'] = 'vertical'
+ super(keys)
+ end
+ private :create_self
+end
+
+#TkYScrollbar = Tk::YScrollbar unless Object.const_defined? :TkYScrollbar
+#Tk.__set_toplevel_aliases__(:Tk, Tk::YScrollbar, :TkYScrollbar)
+Tk.__set_loaded_toplevel_aliases__('tk/scrollbar.rb', :Tk, Tk::YScrollbar,
+ :TkYScrollbar)
diff --git a/jni/ruby/ext/tk/lib/tk/scrollbox.rb b/jni/ruby/ext/tk/lib/tk/scrollbox.rb
new file mode 100644
index 0000000..d20742a
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tk/scrollbox.rb
@@ -0,0 +1,39 @@
+#
+# tk/scrollbox.rb - Tk Listbox with Scrollbar
+# as an example of Composite Widget
+# by Yukihiro Matsumoto <matz@netlab.co.jp>
+#
+require 'tk'
+require 'tk/listbox'
+
+class TkScrollbox<Tk::Listbox
+ include TkComposite
+ def initialize_composite(keys=nil)
+ #list = Tk::Listbox.new(@frame)
+ # -> use current TkListbox class
+ list = TkListbox.new(@frame)
+ #scroll = Tk::Scrollbar.new(@frame)
+ # -> use current TkScrollbar class
+ scroll = TkScrollbar.new(@frame)
+ @path = list.path
+
+=begin
+ list.configure 'yscroll', scroll.path+" set"
+ list.pack 'side'=>'left','fill'=>'both','expand'=>'yes'
+ scroll.configure 'command', list.path+" yview"
+ scroll.pack 'side'=>'right','fill'=>'y'
+=end
+ list.yscrollbar(scroll)
+ list.pack('side'=>'left','fill'=>'both','expand'=>'yes')
+ scroll.pack('side'=>'right','fill'=>'y')
+
+ delegate('DEFAULT', list)
+ delegate('foreground', list)
+ delegate('background', list, scroll)
+ delegate('borderwidth', @frame)
+ delegate('relief', @frame)
+
+ configure keys if keys
+ end
+ private :initialize_composite
+end
diff --git a/jni/ruby/ext/tk/lib/tk/selection.rb b/jni/ruby/ext/tk/lib/tk/selection.rb
new file mode 100644
index 0000000..ba0a6f4
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tk/selection.rb
@@ -0,0 +1,86 @@
+#
+# tk/selection.rb : control selection
+#
+require 'tk'
+
+module TkSelection
+ include Tk
+ extend Tk
+
+ TkCommandNames = ['selection'.freeze].freeze
+
+ def self.clear(sel=nil)
+ if sel
+ tk_call_without_enc('selection', 'clear', '-selection', sel)
+ else
+ tk_call_without_enc('selection', 'clear')
+ end
+ end
+ def self.clear_on_display(win, sel=nil)
+ if sel
+ tk_call_without_enc('selection', 'clear',
+ '-displayof', win, '-selection', sel)
+ else
+ tk_call_without_enc('selection', 'clear', '-displayof', win)
+ end
+ end
+ def clear(sel=nil)
+ TkSelection.clear_on_display(self, sel)
+ self
+ end
+
+ def self.get(keys=nil)
+ #tk_call('selection', 'get', *hash_kv(keys))
+ _fromUTF8(tk_call_without_enc('selection', 'get', *hash_kv(keys)))
+ end
+ def self.get_on_display(win, keys=nil)
+ #tk_call('selection', 'get', '-displayof', win, *hash_kv(keys))
+ _fromUTF8(tk_call_without_enc('selection', 'get', '-displayof',
+ win, *hash_kv(keys)))
+ end
+ def get(keys=nil)
+ TkSelection.get_on_display(self, sel)
+ end
+
+ def self.handle(win, func=Proc.new, keys=nil, &b)
+ if func.kind_of?(Hash) && keys == nil
+ keys = func
+ func = Proc.new(&b)
+ end
+ args = ['selection', 'handle']
+ args.concat(hash_kv(keys))
+ args.concat([win, func])
+ tk_call_without_enc(*args)
+ end
+ def handle(func=Proc.new, keys=nil, &b)
+ TkSelection.handle(self, func, keys, &b)
+ end
+
+ def self.get_owner(sel=nil)
+ if sel
+ window(tk_call_without_enc('selection', 'own', '-selection', sel))
+ else
+ window(tk_call_without_enc('selection', 'own'))
+ end
+ end
+ def self.get_owner_on_display(win, sel=nil)
+ if sel
+ window(tk_call_without_enc('selection', 'own',
+ '-displayof', win, '-selection', sel))
+ else
+ window(tk_call_without_enc('selection', 'own', '-displayof', win))
+ end
+ end
+ def get_owner(sel=nil)
+ TkSelection.get_owner_on_display(self, sel)
+ self
+ end
+
+ def self.set_owner(win, keys=nil)
+ tk_call_without_enc('selection', 'own', *(hash_kv(keys) << win))
+ end
+ def set_owner(keys=nil)
+ TkSelection.set_owner(self, keys)
+ self
+ end
+end
diff --git a/jni/ruby/ext/tk/lib/tk/spinbox.rb b/jni/ruby/ext/tk/lib/tk/spinbox.rb
new file mode 100644
index 0000000..f2917d6
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tk/spinbox.rb
@@ -0,0 +1,144 @@
+#
+# tk/spinbox.rb - Tk spinbox classes
+# by Yukihiro Matsumoto <matz@caelum.co.jp>
+#
+require 'tk'
+require 'tk/entry'
+
+class Tk::Spinbox<Tk::Entry
+ TkCommandNames = ['spinbox'.freeze].freeze
+ WidgetClassName = 'Spinbox'.freeze
+ WidgetClassNames[WidgetClassName] ||= self
+
+ class SpinCommand < TkValidateCommand
+ class ValidateArgs < TkUtil::CallbackSubst
+ KEY_TBL = [
+ [ ?d, ?s, :direction ],
+ [ ?s, ?e, :current ],
+ [ ?W, ?w, :widget ],
+ nil
+ ]
+
+ PROC_TBL = [
+ [ ?s, TkComm.method(:string) ],
+ [ ?w, TkComm.method(:window) ],
+
+ [ ?e, proc{|val|
+ #enc = Tk.encoding
+ enc = ((Tk.encoding)? Tk.encoding : Tk.encoding_system)
+ if enc
+ Tk.fromUTF8(TkComm::string(val), enc)
+ else
+ TkComm::string(val)
+ end
+ }
+ ],
+
+ nil
+ ]
+
+=begin
+ # for Ruby m17n :: ?x --> String --> char-code ( getbyte(0) )
+ KEY_TBL.map!{|inf|
+ if inf.kind_of?(Array)
+ inf[0] = inf[0].getbyte(0) if inf[0].kind_of?(String)
+ inf[1] = inf[1].getbyte(0) if inf[1].kind_of?(String)
+ end
+ inf
+ }
+
+ PROC_TBL.map!{|inf|
+ if inf.kind_of?(Array)
+ inf[0] = inf[0].getbyte(0) if inf[0].kind_of?(String)
+ end
+ inf
+ }
+=end
+
+ _setup_subst_table(KEY_TBL, PROC_TBL);
+
+ def self.ret_val(val)
+ (val)? '1': '0'
+ end
+ end
+
+ def self._config_keys
+ ['command']
+ end
+ end
+
+ def __validation_class_list
+ super() << SpinCommand
+ end
+
+ Tk::ValidateConfigure.__def_validcmd(binding, SpinCommand)
+
+ #def create_self(keys)
+ # tk_call_without_enc('spinbox', @path)
+ # if keys and keys != None
+ # configure(keys)
+ # end
+ #end
+ #private :create_self
+
+ def __boolval_optkeys
+ super() << 'wrap'
+ end
+ private :__boolval_optkeys
+
+ def __strval_optkeys
+ super() << 'buttonbackground' << 'format'
+ end
+ private :__strval_optkeys
+
+ def __listval_optkeys
+ super() << 'values'
+ end
+ private :__listval_optkeys
+
+ def identify(x, y)
+ tk_send_without_enc('identify', x, y)
+ end
+
+ def invoke(elem)
+ tk_send_without_enc('invoke', elem)
+ self
+ end
+
+ def spinup
+ begin
+ tk_send_without_enc('invoke', 'buttonup')
+ rescue RuntimeError => e
+ # old version of element?
+ begin
+ tk_send_without_enc('invoke', 'spinup')
+ rescue
+ fail e
+ end
+ end
+ self
+ end
+
+ def spindown
+ begin
+ tk_send_without_enc('invoke', 'buttondown')
+ rescue RuntimeError => e
+ # old version of element?
+ begin
+ tk_send_without_enc('invoke', 'spinup')
+ rescue
+ fail e
+ end
+ end
+ self
+ end
+
+ def set(str)
+ _fromUTF8(tk_send_without_enc('set', _get_eval_enc_str(str)))
+ end
+end
+
+#TkSpinbox = Tk::Spinbox unless Object.const_defined? :TkSpinbox
+#Tk.__set_toplevel_aliases__(:Tk, Tk::Spinbox, :TkSpinbox)
+Tk.__set_loaded_toplevel_aliases__('tk/spinbox.rb', :Tk, Tk::Spinbox,
+ :TkSpinbox)
diff --git a/jni/ruby/ext/tk/lib/tk/tagfont.rb b/jni/ruby/ext/tk/lib/tk/tagfont.rb
new file mode 100644
index 0000000..a180739
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tk/tagfont.rb
@@ -0,0 +1,43 @@
+#
+# tk/tagfont.rb : control font of tags
+#
+require 'tk'
+
+module TkTreatTagFont
+ def font_configinfo
+ @parent.tagfont_configinfo(@id)
+ end
+# alias font font_configinfo
+
+ def font_configure(slot)
+ @parent.tagfont_configure(@id, slot)
+ self
+ end
+
+ def latinfont_configure(ltn, keys=nil)
+ @parent.latintagfont_configure(@id, ltn, keys)
+ self
+ end
+ alias asciifont_configure latinfont_configure
+
+ def kanjifont_configure(knj, keys=nil)
+ @parent.kanjitagfont_configure(@id, ltn, keys)
+ self
+ end
+
+ def font_copy(win, wintag=nil)
+ @parent.tagfont_copy(@id, win, wintag)
+ self
+ end
+
+ def latinfont_copy(win, wintag=nil)
+ @parent.latintagfont_copy(@id, win, wintag)
+ self
+ end
+ alias asciifont_copy latinfont_copy
+
+ def kanjifont_copy(win, wintag=nil)
+ @parent.kanjitagfont_copy(@id, win, wintag)
+ self
+ end
+end
diff --git a/jni/ruby/ext/tk/lib/tk/text.rb b/jni/ruby/ext/tk/lib/tk/text.rb
new file mode 100644
index 0000000..c18b384
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tk/text.rb
@@ -0,0 +1,1604 @@
+#
+# tk/text.rb - Tk text classes
+# by Yukihiro Matsumoto <matz@caelum.co.jp>
+require 'tk'
+require 'tk/itemfont'
+require 'tk/itemconfig'
+require 'tk/scrollable'
+require 'tk/txtwin_abst'
+
+module TkTextTagConfig
+ include TkTreatItemFont
+ include TkItemConfigMethod
+
+ def __item_cget_cmd(id) # id := [ type, tagOrId ]
+ [self.path, id[0], 'cget', id[1]]
+ end
+ private :__item_cget_cmd
+
+ def __item_config_cmd(id) # id := [ type, tagOrId ]
+ [self.path, id[0], 'configure', id[1]]
+ end
+ private :__item_config_cmd
+
+ def __item_pathname(id)
+ if id.kind_of?(Array)
+ id = tagid(id[1])
+ end
+ [self.path, id].join(';')
+ end
+ private :__item_pathname
+
+ def tag_cget_tkstring(tagOrId, option)
+ itemcget_tkstring(['tag', tagOrId], option)
+ end
+ def tag_cget(tagOrId, option)
+ itemcget(['tag', tagOrId], option)
+ end
+ def tag_cget_strict(tagOrId, option)
+ itemcget_strict(['tag', tagOrId], option)
+ end
+ def tag_configure(tagOrId, slot, value=None)
+ itemconfigure(['tag', tagOrId], slot, value)
+ end
+ def tag_configinfo(tagOrId, slot=nil)
+ itemconfiginfo(['tag', tagOrId], slot)
+ end
+ def current_tag_configinfo(tagOrId, slot=nil)
+ current_itemconfiginfo(['tag', tagOrId], slot)
+ end
+
+ def window_cget_tkstring(tagOrId, option)
+ itemcget_tkstring(['window', tagOrId], option)
+ end
+ def window_cget(tagOrId, option)
+ itemcget(['window', tagOrId], option)
+ end
+ def window_cget_strict(tagOrId, option)
+ itemcget_strict(['window', tagOrId], option)
+ end
+ def window_configure(tagOrId, slot, value=None)
+ itemconfigure(['window', tagOrId], slot, value)
+ end
+ def window_configinfo(tagOrId, slot=nil)
+ itemconfiginfo(['window', tagOrId], slot)
+ end
+ def current_window_configinfo(tagOrId, slot=nil)
+ current_itemconfiginfo(['window', tagOrId], slot)
+ end
+
+ private :itemcget_tkstring, :itemcget, :itemcget_strict
+ private :itemconfigure, :itemconfiginfo, :current_itemconfiginfo
+end
+
+class Tk::Text<TkTextWin
+ ItemConfCMD = ['tag'.freeze, 'configure'.freeze].freeze
+ #include TkTreatTextTagFont
+ include TkTextTagConfig
+ include Scrollable
+
+ #######################################
+
+ module IndexModMethods
+ def +(mod)
+ return chars(mod) if mod.kind_of?(Numeric)
+
+ mod = mod.to_s
+ if mod =~ /^\s*[+-]?\d/
+ Tk::Text::IndexString.new(String.new(id) << ' + ' << mod)
+ else
+ Tk::Text::IndexString.new(String.new(id) << ' ' << mod)
+ end
+ end
+
+ def -(mod)
+ return chars(-mod) if mod.kind_of?(Numeric)
+
+ mod = mod.to_s
+ if mod =~ /^\s*[+-]?\d/
+ Tk::Text::IndexString.new(String.new(id) << ' - ' << mod)
+ elsif mod =~ /^\s*[-]\s+(\d.*)$/
+ Tk::Text::IndexString.new(String.new(id) << ' - -' << $1)
+ else
+ Tk::Text::IndexString.new(String.new(id) << ' ' << mod)
+ end
+ end
+
+ def chars(mod)
+ fail ArgumentError, 'expect Integer' unless mod.kind_of?(Integer)
+ if mod < 0
+ Tk::Text::IndexString.new(String.new(id) << ' ' << mod.to_s << ' chars')
+ else
+ Tk::Text::IndexString.new(String.new(id) << ' + ' << mod.to_s << ' chars')
+ end
+ end
+ alias char chars
+
+ def display_chars(mod)
+ # Tk8.5 feature
+ fail ArgumentError, 'expect Integer' unless mod.kind_of?(Integer)
+ if mod < 0
+ Tk::Text::IndexString.new(String.new(id) << ' ' << mod.to_s << ' display chars')
+ else
+ Tk::Text::IndexString.new(String.new(id) << ' + ' << mod.to_s << ' display chars')
+ end
+ end
+ alias display_char display_chars
+
+ def any_chars(mod)
+ # Tk8.5 feature
+ fail ArgumentError, 'expect Integer' unless mod.kind_of?(Integer)
+ if mod < 0
+ Tk::Text::IndexString.new(String.new(id) << ' ' << mod.to_s << ' any chars')
+ else
+ Tk::Text::IndexString.new(String.new(id) << ' + ' << mod.to_s << ' any chars')
+ end
+ end
+ alias any_char any_chars
+
+ def indices(mod)
+ # Tk8.5 feature
+ fail ArgumentError, 'expect Integer' unless mod.kind_of?(Integer)
+ if mod < 0
+ Tk::Text::IndexString.new(String.new(id) << ' ' << mod.to_s << ' indices')
+ else
+ Tk::Text::IndexString.new(String.new(id) << ' + ' << mod.to_s << ' indices')
+ end
+ end
+
+ def display_indices(mod)
+ # Tk8.5 feature
+ fail ArgumentError, 'expect Integer' unless mod.kind_of?(Integer)
+ if mod < 0
+ Tk::Text::IndexString.new(String.new(id) << ' ' << mod.to_s << ' display indices')
+ else
+ Tk::Text::IndexString.new(String.new(id) << ' + ' << mod.to_s << ' display indices')
+ end
+ end
+
+ def any_indices(mod)
+ # Tk8.5 feature
+ fail ArgumentError, 'expect Integer' unless mod.kind_of?(Integer)
+ if mod < 0
+ Tk::Text::IndexString.new(String.new(id) << ' ' << mod.to_s << ' any indices')
+ else
+ Tk::Text::IndexString.new(String.new(id) << ' + ' << mod.to_s << ' any indices')
+ end
+ end
+
+ def lines(mod)
+ fail ArgumentError, 'expect Integer' unless mod.kind_of?(Integer)
+ if mod < 0
+ Tk::Text::IndexString.new(String.new(id) << ' ' << mod.to_s << ' lines')
+ else
+ Tk::Text::IndexString.new(String.new(id) << ' + ' << mod.to_s << ' lines')
+ end
+ end
+ alias line lines
+
+ def display_lines(mod)
+ # Tk8.5 feature
+ fail ArgumentError, 'expect Integer' unless mod.kind_of?(Integer)
+ if mod < 0
+ Tk::Text::IndexString.new(String.new(id) << ' ' << mod.to_s << ' display_lines')
+ else
+ Tk::Text::IndexString.new(String.new(id) << ' + ' << mod.to_s << ' display lines')
+ end
+ end
+ alias display_line display_lines
+
+ def any_lines(mod)
+ # Tk8.5 feature
+ fail ArgumentError, 'expect Integer' unless mod.kind_of?(Integer)
+ if mod < 0
+ Tk::Text::IndexString.new(String.new(id) << ' ' << mod.to_s << ' any_lines')
+ else
+ Tk::Text::IndexString.new(String.new(id) << ' + ' << mod.to_s << ' any lines')
+ end
+ end
+ alias any_line any_lines
+
+ def linestart
+ Tk::Text::IndexString.new(String.new(id) << ' linestart')
+ end
+ def lineend
+ Tk::Text::IndexString.new(String.new(id) << ' lineend')
+ end
+
+ def display_linestart
+ # Tk8.5 feature
+ Tk::Text::IndexString.new(String.new(id) << ' display linestart')
+ end
+ def display_lineend
+ # Tk8.5 feature
+ Tk::Text::IndexString.new(String.new(id) << ' display lineend')
+ end
+
+ def wordstart
+ Tk::Text::IndexString.new(String.new(id) << ' wordstart')
+ end
+ def wordend
+ Tk::Text::IndexString.new(String.new(id) << ' wordend')
+ end
+
+ def display_wordstart
+ # Tk8.5 feature
+ Tk::Text::IndexString.new(String.new(id) << ' display wordstart')
+ end
+ def display_wordend
+ # Tk8.5 feature
+ Tk::Text::IndexString.new(String.new(id) << ' display wordend')
+ end
+ end
+
+ class IndexString < String
+ include IndexModMethods
+
+ def self.at(x,y)
+ self.new("@#{x},#{y}")
+ end
+
+ def self.new(str)
+ if str.kind_of?(String)
+ super(str)
+ elsif str.kind_of?(Symbol)
+ super(str.to_s)
+ else
+ str
+ end
+ end
+
+ def id
+ self
+ end
+ end
+
+ #######################################
+
+ TkCommandNames = ['text'.freeze].freeze
+ WidgetClassName = 'Text'.freeze
+ WidgetClassNames[WidgetClassName] ||= self
+
+ def self.new(*args, &block)
+ obj = super(*args){}
+ obj.init_instance_variable
+ if TkCore::WITH_RUBY_VM ### Ruby 1.9 !!!!
+ obj.instance_exec(obj, &block) if defined? yield
+ else
+ obj.instance_eval(&block) if defined? yield
+ end
+ obj
+ end
+
+ def init_instance_variable
+ @cmdtbl = []
+ @tags = {}
+ end
+
+ def __destroy_hook__
+ TkTextTag::TTagID_TBL.mutex.synchronize{
+ TkTextTag::TTagID_TBL.delete(@path)
+ }
+ TkTextTag::TMarkID_TBL.mutex.synchronize{
+ TkTextMark::TMarkID_TBL.delete(@path)
+ }
+ end
+
+ def create_self(keys)
+ #if keys and keys != None
+ # #tk_call_without_enc('text', @path, *hash_kv(keys, true))
+ # tk_call_without_enc(self.class::TkCommandNames[0], @path,
+ # *hash_kv(keys, true))
+ #else
+ # #tk_call_without_enc('text', @path)
+ # tk_call_without_enc(self.class::TkCommandNames[0], @path)
+ #end
+ super(keys)
+ init_instance_variable
+ end
+ private :create_self
+
+ def __strval_optkeys
+ super() << 'inactiveseletcionbackground'
+ end
+ private :__strval_optkeys
+
+ def self.at(x, y)
+ Tk::Text::IndexString.at(x, y)
+ end
+
+ def at(x, y)
+ Tk::Text::IndexString.at(x, y)
+ end
+
+ def index(idx)
+ Tk::Text::IndexString.new(tk_send_without_enc('index',
+ _get_eval_enc_str(idx)))
+ end
+
+ def get_displaychars(*index)
+ # Tk8.5 feature
+ get('-displaychars', *index)
+ end
+
+ def value
+ _fromUTF8(tk_send_without_enc('get', "1.0", "end - 1 char"))
+ end
+
+ def value= (val)
+ tk_send_without_enc('delete', "1.0", 'end')
+ tk_send_without_enc('insert', "1.0", _get_eval_enc_str(val))
+ val
+ end
+
+ def clear
+ tk_send_without_enc('delete', "1.0", 'end')
+ self
+ end
+ alias erase clear
+
+ def _addcmd(cmd)
+ @cmdtbl.push cmd
+ end
+
+ def _addtag(name, obj)
+ @tags[name] = obj
+ end
+
+ def tagid(tag)
+ if tag.kind_of?(TkTextTag) \
+ || tag.kind_of?(TkTextMark) \
+ || tag.kind_of?(TkTextImage) \
+ || tag.kind_of?(TkTextWindow)
+ tag.id
+ else
+ tag # maybe an Array of configure parameters
+ end
+ end
+ private :tagid
+
+ def tagid2obj(tagid)
+ if @tags[tagid]
+ @tags[tagid]
+ else
+ tagid
+ end
+ end
+
+ def tag_names(index=None)
+ #tk_split_simplelist(_fromUTF8(tk_send_without_enc('tag', 'names', _get_eval_enc_str(index)))).collect{|elt|
+ tk_split_simplelist(tk_send_without_enc('tag', 'names', _get_eval_enc_str(index)), false, true).collect{|elt|
+ tagid2obj(elt)
+ }
+ end
+
+ def mark_names
+ #tk_split_simplelist(_fromUTF8(tk_send_without_enc('mark', 'names'))).collect{|elt|
+ tk_split_simplelist(tk_send_without_enc('mark', 'names'), false, true).collect{|elt|
+ tagid2obj(elt)
+ }
+ end
+
+ def mark_gravity(mark, direction=nil)
+ if direction
+ tk_send_without_enc('mark', 'gravity',
+ _get_eval_enc_str(mark), direction)
+ self
+ else
+ tk_send_without_enc('mark', 'gravity', _get_eval_enc_str(mark))
+ end
+ end
+
+ def mark_set(mark, index)
+ tk_send_without_enc('mark', 'set', _get_eval_enc_str(mark),
+ _get_eval_enc_str(index))
+ self
+ end
+ alias set_mark mark_set
+
+ def mark_unset(*marks)
+ tk_send_without_enc('mark', 'unset',
+ *(marks.collect{|mark| _get_eval_enc_str(mark)}))
+ self
+ end
+ alias unset_mark mark_unset
+
+ def mark_next(index)
+ tagid2obj(_fromUTF8(tk_send_without_enc('mark', 'next',
+ _get_eval_enc_str(index))))
+ end
+ alias next_mark mark_next
+
+ def mark_previous(index)
+ tagid2obj(_fromUTF8(tk_send_without_enc('mark', 'previous',
+ _get_eval_enc_str(index))))
+ end
+ alias previous_mark mark_previous
+
+ def image_cget_strict(index, slot)
+ case slot.to_s
+ when 'text', 'label', 'show', 'data', 'file'
+ _fromUTF8(tk_send_without_enc('image', 'cget',
+ _get_eval_enc_str(index), "-#{slot}"))
+ else
+ tk_tcl2ruby(_fromUTF8(tk_send_without_enc('image', 'cget',
+ _get_eval_enc_str(index),
+ "-#{slot}")))
+ end
+ end
+
+ def image_cget(index, slot)
+ unless TkItemConfigMethod.__IGNORE_UNKNOWN_CONFIGURE_OPTION__
+ image_cget_strict(index, slot)
+ else
+ begin
+ image_cget_strict(index, slot)
+ rescue => e
+ begin
+ if current_image_configinfo(index).has_key?(slot.to_s)
+ # not tag error & option is known -> error on known option
+ fail e
+ else
+ # not tag error & option is unknown
+ nil
+ end
+ rescue
+ fail e # tag error
+ end
+ end
+ end
+ end
+
+ def image_configure(index, slot, value=None)
+ if slot.kind_of?(Hash)
+ _fromUTF8(tk_send_without_enc('image', 'configure',
+ _get_eval_enc_str(index),
+ *hash_kv(slot, true)))
+ else
+ _fromUTF8(tk_send_without_enc('image', 'configure',
+ _get_eval_enc_str(index),
+ "-#{slot}",
+ _get_eval_enc_str(value)))
+ end
+ self
+ end
+
+ def image_configinfo(index, slot = nil)
+ if TkComm::GET_CONFIGINFO_AS_ARRAY
+ if slot
+ case slot.to_s
+ when 'text', 'label', 'show', 'data', 'file'
+ #conf = tk_split_simplelist(_fromUTF8(tk_send_without_enc('image', 'configure', _get_eval_enc_str(index), "-#{slot}")))
+ conf = tk_split_simplelist(tk_send_without_enc('image', 'configure', _get_eval_enc_str(index), "-#{slot}"), false, true)
+ else
+ #conf = tk_split_list(_fromUTF8(tk_send_without_enc('image', 'configure', _get_eval_enc_str(index), "-#{slot}")))
+ conf = tk_split_list(tk_send_without_enc('image', 'configure', _get_eval_enc_str(index), "-#{slot}"), 0, false, true)
+ end
+ conf[0] = conf[0][1..-1]
+ conf
+ else
+ # tk_split_simplelist(_fromUTF8(tk_send_without_enc('image', 'configure', _get_eval_enc_str(index)))).collect{|conflist|
+ # conf = tk_split_simplelist(conflist)
+ tk_split_simplelist(tk_send_without_enc('image', 'configure', _get_eval_enc_str(index)), false, false).collect{|conflist|
+ conf = tk_split_simplelist(conflist, false, true)
+ conf[0] = conf[0][1..-1]
+ case conf[0]
+ when 'text', 'label', 'show', 'data', 'file'
+ else
+ if conf[3]
+ if conf[3].index('{')
+ conf[3] = tk_split_list(conf[3])
+ else
+ conf[3] = tk_tcl2ruby(conf[3])
+ end
+ end
+ if conf[4]
+ if conf[4].index('{')
+ conf[4] = tk_split_list(conf[4])
+ else
+ conf[4] = tk_tcl2ruby(conf[4])
+ end
+ end
+ end
+ conf[1] = conf[1][1..-1] if conf.size == 2 # alias info
+ conf
+ }
+ end
+ else # ! TkComm::GET_CONFIGINFO_AS_ARRAY
+ if slot
+ case slot.to_s
+ when 'text', 'label', 'show', 'data', 'file'
+ #conf = tk_split_simplelist(_fromUTF8(tk_send_without_enc('image', 'configure', _get_eval_enc_str(index), "-#{slot}")))
+ conf = tk_split_simplelist(tk_send_without_enc('image', 'configure', _get_eval_enc_str(index), "-#{slot}"), false, true)
+ else
+ #conf = tk_split_list(_fromUTF8(tk_send_without_enc('image', 'configure', _get_eval_enc_str(index), "-#{slot}")))
+ conf = tk_split_list(tk_send_without_enc('image', 'configure', _get_eval_enc_str(index), "-#{slot}"), 0, false, true)
+ end
+ key = conf.shift[1..-1]
+ { key => conf }
+ else
+ ret = {}
+ #tk_split_simplelist(_fromUTF8(tk_send_without_enc('image', 'configure', _get_eval_enc_str(index)))).each{|conflist|
+ # conf = tk_split_simplelist(conflist)
+ tk_split_simplelist(tk_send_without_enc('image', 'configure', _get_eval_enc_str(index)), false, false).each{|conflist|
+ conf = tk_split_simplelist(conflist, false, true)
+ key = conf.shift[1..-1]
+ case key
+ when 'text', 'label', 'show', 'data', 'file'
+ else
+ if conf[2]
+ if conf[2].index('{')
+ conf[2] = tk_split_list(conf[2])
+ else
+ conf[2] = tk_tcl2ruby(conf[2])
+ end
+ end
+ if conf[3]
+ if conf[3].index('{')
+ conf[3] = tk_split_list(conf[3])
+ else
+ conf[3] = tk_tcl2ruby(conf[3])
+ end
+ end
+ end
+ if conf.size == 1
+ ret[key] = conf[0][1..-1] # alias info
+ else
+ ret[key] = conf
+ end
+ }
+ ret
+ end
+ end
+ end
+
+ def current_image_configinfo(index, slot = nil)
+ if TkComm::GET_CONFIGINFO_AS_ARRAY
+ if slot
+ conf = image_configinfo(index, slot)
+ {conf[0] => conf[4]}
+ else
+ ret = {}
+ image_configinfo(index).each{|conf|
+ ret[conf[0]] = conf[4] if conf.size > 2
+ }
+ ret
+ end
+ else # ! TkComm::GET_CONFIGINFO_AS_ARRAY
+ ret = {}
+ image_configinfo(index, slot).each{|k, conf|
+ ret[k] = conf[-1] if conf.kind_of?(Array)
+ }
+ ret
+ end
+ end
+
+ def image_names
+ #tk_split_simplelist(_fromUTF8(tk_send_without_enc('image', 'names'))).collect{|elt|
+ tk_split_simplelist(tk_send_without_enc('image', 'names'), false, true).collect{|elt|
+ tagid2obj(elt)
+ }
+ end
+
+ def set_insert(index)
+ tk_send_without_enc('mark','set','insert', _get_eval_enc_str(index))
+ self
+ end
+
+ def set_current(index)
+ tk_send_without_enc('mark','set','current', _get_eval_enc_str(index))
+ self
+ end
+
+ def insert(index, chars, *tags)
+ if tags[0].kind_of?(Array)
+ # multiple chars-taglist argument :: str, [tag,...], str, [tag,...], ...
+ args = [chars]
+ while tags.size > 0
+ args << tags.shift.collect{|x|_get_eval_string(x)}.join(' ') # taglist
+ args << tags.shift if tags.size > 0 # chars
+ end
+ super(index, *args)
+ else
+ # single chars-taglist argument :: str, tag, tag, ...
+ if tags.size == 0
+ super(index, chars)
+ else
+ super(index, chars, tags.collect{|x|_get_eval_string(x)}.join(' '))
+ end
+ end
+ end
+
+ def destroy
+ @tags = {} unless @tags
+ @tags.each_value do |t|
+ t.destroy
+ end
+ super()
+ end
+
+ def backspace
+ self.delete 'insert'
+ end
+
+ def bbox(index)
+ list(tk_send_without_enc('bbox', _get_eval_enc_str(index)))
+ end
+
+ def compare(idx1, op, idx2)
+ bool(tk_send_without_enc('compare', _get_eval_enc_str(idx1),
+ op, _get_eval_enc_str(idx2)))
+ end
+
+ def count(idx1, idx2, *opts)
+ # opts are Tk8.5 feature
+ cnt = 0
+ args = opts.collect{|opt|
+ str = opt.to_s
+ cnt += 1 if str != 'update'
+ '-' + str
+ }
+ args << _get_eval_enc_str(idx1) << _get_eval_enc_str(idx2)
+ if cnt <= 1
+ number(tk_send_without_enc('count', *opts))
+ else
+ list(tk_send_without_enc('count', *opts))
+ end
+ end
+
+ def count_info(idx1, idx2, update=true)
+ # Tk8.5 feature
+ opts = [
+ :chars, :displaychars, :displayindices, :displaylines,
+ :indices, :lines, :xpixels, :ypixels
+ ]
+ if update
+ lst = count(idx1, idx2, :update, *opts)
+ else
+ lst = count(idx1, idx2, *opts)
+ end
+ info = {}
+ opts.each_with_index{|key, idx| info[key] = lst[idx]}
+ info
+ end
+
+ def peer_names()
+ # Tk8.5 feature
+ list(tk_send_without_enc('peer', 'names'))
+ end
+
+ def replace(idx1, idx2, *opts)
+ tk_send('replace', idx1, idx2, *opts)
+ self
+ end
+
+ def debug
+ bool(tk_send_without_enc('debug'))
+ end
+ def debug=(boolean)
+ tk_send_without_enc('debug', boolean)
+ #self
+ boolean
+ end
+
+ def dlineinfo(index)
+ list(tk_send_without_enc('dlineinfo', _get_eval_enc_str(index)))
+ end
+
+ def modified?
+ bool(tk_send_without_enc('edit', 'modified'))
+ end
+ def modified(mode)
+ tk_send_without_enc('edit', 'modified', mode)
+ self
+ end
+ def modified=(mode)
+ modified(mode)
+ mode
+ end
+
+ def edit_redo
+ tk_send_without_enc('edit', 'redo')
+ self
+ end
+ def edit_reset
+ tk_send_without_enc('edit', 'reset')
+ self
+ end
+ def edit_separator
+ tk_send_without_enc('edit', 'separator')
+ self
+ end
+ def edit_undo
+ tk_send_without_enc('edit', 'undo')
+ self
+ end
+
+ def xview_pickplace(index)
+ tk_send_without_enc('xview', '-pickplace', _get_eval_enc_str(index))
+ self
+ end
+
+ def yview_pickplace(index)
+ tk_send_without_enc('yview', '-pickplace', _get_eval_enc_str(index))
+ self
+ end
+
+ def text_copy
+ # Tk8.4 feature
+ tk_call_without_enc('tk_textCopy', @path)
+ self
+ end
+
+ def text_cut
+ # Tk8.4 feature
+ tk_call_without_enc('tk_textCut', @path)
+ self
+ end
+
+ def text_paste
+ # Tk8.4 feature
+ tk_call_without_enc('tk_textPaste', @path)
+ self
+ end
+
+ def tag_add(tag, index1, index2=None)
+ tk_send_without_enc('tag', 'add', _get_eval_enc_str(tag),
+ _get_eval_enc_str(index1),
+ _get_eval_enc_str(index2))
+ self
+ end
+ alias addtag tag_add
+ alias add_tag tag_add
+
+ def tag_delete(*tags)
+ tk_send_without_enc('tag', 'delete',
+ *(tags.collect{|tag| _get_eval_enc_str(tag)}))
+ TkTextTag::TTagID_TBL.mutex.synchronize{
+ if TkTextTag::TTagID_TBL[@path]
+ tags.each{|tag|
+ if tag.kind_of?(TkTextTag)
+ TkTextTag::TTagID_TBL[@path].delete(tag.id)
+ else
+ TkTextTag::TTagID_TBL[@path].delete(tag)
+ end
+ }
+ end
+ }
+ self
+ end
+ alias deltag tag_delete
+ alias delete_tag tag_delete
+
+ #def tag_bind(tag, seq, cmd=Proc.new, *args)
+ # _bind([@path, 'tag', 'bind', tag], seq, cmd, *args)
+ # self
+ #end
+ def tag_bind(tag, seq, *args)
+ # if args[0].kind_of?(Proc) || args[0].kind_of?(Method)
+ if TkComm._callback_entry?(args[0]) || !block_given?
+ cmd = args.shift
+ else
+ cmd = Proc.new
+ end
+ _bind([@path, 'tag', 'bind', tag], seq, cmd, *args)
+ self
+ end
+
+ #def tag_bind_append(tag, seq, cmd=Proc.new, *args)
+ # _bind_append([@path, 'tag', 'bind', tag], seq, cmd, *args)
+ # self
+ #end
+ def tag_bind_append(tag, seq, *args)
+ # if args[0].kind_of?(Proc) || args[0].kind_of?(Method)
+ if TkComm._callback_entry?(args[0]) || !block_given?
+ cmd = args.shift
+ else
+ cmd = Proc.new
+ end
+ _bind_append([@path, 'tag', 'bind', tag], seq, cmd, *args)
+ self
+ end
+
+ def tag_bind_remove(tag, seq)
+ _bind_remove([@path, 'tag', 'bind', tag], seq)
+ self
+ end
+
+ def tag_bindinfo(tag, context=nil)
+ _bindinfo([@path, 'tag', 'bind', tag], context)
+ end
+
+=begin
+ def tag_cget(tag, key)
+ case key.to_s
+ when 'text', 'label', 'show', 'data', 'file'
+ tk_call_without_enc(@path, 'tag', 'cget',
+ _get_eval_enc_str(tag), "-#{key}")
+ when 'font', 'kanjifont'
+ #fnt = tk_tcl2ruby(tk_send('tag', 'cget', tag, "-#{key}"))
+ fnt = tk_tcl2ruby(_fromUTF8(tk_send_without_enc('tag','cget',_get_eval_enc_str(tag),'-font')))
+ unless fnt.kind_of?(TkFont)
+ fnt = tagfontobj(tag, fnt)
+ end
+ if key.to_s == 'kanjifont' && JAPANIZED_TK && TK_VERSION =~ /^4\.*/
+ # obsolete; just for compatibility
+ fnt.kanji_font
+ else
+ fnt
+ end
+ else
+ tk_tcl2ruby(_fromUTF8(tk_call_without_enc(@path,'tag','cget',_get_eval_enc_str(tag),"-#{key}")))
+ end
+ end
+
+ def tag_configure(tag, key, val=None)
+ if key.kind_of?(Hash)
+ key = _symbolkey2str(key)
+ if ( key['font'] || key['kanjifont'] \
+ || key['latinfont'] || key['asciifont'] )
+ tagfont_configure(tag, key)
+ else
+ tk_send_without_enc('tag', 'configure', _get_eval_enc_str(tag),
+ *hash_kv(key, true))
+ end
+
+ else
+ if key == 'font' || key == :font ||
+ key == 'kanjifont' || key == :kanjifont ||
+ key == 'latinfont' || key == :latinfont ||
+ key == 'asciifont' || key == :asciifont
+ if val == None
+ tagfontobj(tag)
+ else
+ tagfont_configure(tag, {key=>val})
+ end
+ else
+ tk_send_without_enc('tag', 'configure', _get_eval_enc_str(tag),
+ "-#{key}", _get_eval_enc_str(val))
+ end
+ end
+ self
+ end
+
+ def tag_configinfo(tag, key=nil)
+ if TkComm::GET_CONFIGINFO_AS_ARRAY
+ if key
+ case key.to_s
+ when 'text', 'label', 'show', 'data', 'file'
+ conf = tk_split_simplelist(_fromUTF8(tk_send_without_enc('tag','configure',_get_eval_enc_str(tag),"-#{key}")))
+ when 'font', 'kanjifont'
+ conf = tk_split_simplelist(_fromUTF8(tk_send_without_enc('tag','configure',_get_eval_enc_str(tag),"-#{key}")))
+ conf[4] = tagfont_configinfo(tag, conf[4])
+ else
+ conf = tk_split_list(_fromUTF8(tk_send_without_enc('tag','configure',_get_eval_enc_str(tag),"-#{key}")))
+ end
+ conf[0] = conf[0][1..-1]
+ conf
+ else
+ ret = tk_split_simplelist(_fromUTF8(tk_send('tag','configure',_get_eval_enc_str(tag)))).collect{|conflist|
+ conf = tk_split_simplelist(conflist)
+ conf[0] = conf[0][1..-1]
+ case conf[0]
+ when 'text', 'label', 'show', 'data', 'file'
+ else
+ if conf[3]
+ if conf[3].index('{')
+ conf[3] = tk_split_list(conf[3])
+ else
+ conf[3] = tk_tcl2ruby(conf[3])
+ end
+ end
+ if conf[4]
+ if conf[4].index('{')
+ conf[4] = tk_split_list(conf[4])
+ else
+ conf[4] = tk_tcl2ruby(conf[4])
+ end
+ end
+ end
+ conf[1] = conf[1][1..-1] if conf.size == 2 # alias info
+ conf
+ }
+ fontconf = ret.assoc('font')
+ if fontconf
+ ret.delete_if{|item| item[0] == 'font' || item[0] == 'kanjifont'}
+ fontconf[4] = tagfont_configinfo(tag, fontconf[4])
+ ret.push(fontconf)
+ else
+ ret
+ end
+ end
+ else # ! TkComm::GET_CONFIGINFO_AS_ARRAY
+ if key
+ case key.to_s
+ when 'text', 'label', 'show', 'data', 'file'
+ conf = tk_split_simplelist(_fromUTF8(tk_send_without_enc('tag','configure',_get_eval_enc_str(tag),"-#{key}")))
+ when 'font', 'kanjifont'
+ conf = tk_split_simplelist(_fromUTF8(tk_send_without_enc('tag','configure',_get_eval_enc_str(tag),"-#{key}")))
+ conf[4] = tagfont_configinfo(tag, conf[4])
+ else
+ conf = tk_split_list(_fromUTF8(tk_send_without_enc('tag','configure',_get_eval_enc_str(tag),"-#{key}")))
+ end
+ key = conf.shift[1..-1]
+ { key => conf }
+ else
+ ret = {}
+ tk_split_simplelist(_fromUTF8(tk_send('tag','configure',_get_eval_enc_str(tag)))).each{|conflist|
+ conf = tk_split_simplelist(conflist)
+ key = conf.shift[1..-1]
+ case key
+ when 'text', 'label', 'show', 'data', 'file'
+ else
+ if conf[2]
+ if conf[2].index('{')
+ conf[2] = tk_split_list(conf[2])
+ else
+ conf[2] = tk_tcl2ruby(conf[2])
+ end
+ end
+ if conf[3]
+ if conf[3].index('{')
+ conf[3] = tk_split_list(conf[3])
+ else
+ conf[3] = tk_tcl2ruby(conf[3])
+ end
+ end
+ end
+ if conf.size == 1
+ ret[key] = conf[0][1..-1] # alias info
+ else
+ ret[key] = conf
+ end
+ }
+ fontconf = ret['font']
+ if fontconf
+ ret.delete('font')
+ ret.delete('kanjifont')
+ fontconf[3] = tagfont_configinfo(tag, fontconf[3])
+ ret['font'] = fontconf
+ end
+ ret
+ end
+ end
+ end
+
+ def current_tag_configinfo(tag, key=nil)
+ if TkComm::GET_CONFIGINFO_AS_ARRAY
+ if key
+ conf = tag_configinfo(tag, key)
+ {conf[0] => conf[4]}
+ else
+ ret = {}
+ tag_configinfo(tag).each{|conf|
+ ret[conf[0]] = conf[4] if conf.size > 2
+ }
+ ret
+ end
+ else # ! TkComm::GET_CONFIGINFO_AS_ARRAY
+ ret = {}
+ tag_configinfo(tag, key).each{|k, conf|
+ ret[k] = conf[-1] if conf.kind_of?(Array)
+ }
+ ret
+ end
+ end
+=end
+
+ def tag_raise(tag, above=None)
+ tk_send_without_enc('tag', 'raise', _get_eval_enc_str(tag),
+ _get_eval_enc_str(above))
+ self
+ end
+
+ def tag_lower(tag, below=None)
+ tk_send_without_enc('tag', 'lower', _get_eval_enc_str(tag),
+ _get_eval_enc_str(below))
+ self
+ end
+
+ def tag_remove(tag, *indices)
+ tk_send_without_enc('tag', 'remove', _get_eval_enc_str(tag),
+ *(indices.collect{|idx| _get_eval_enc_str(idx)}))
+ self
+ end
+
+ def tag_ranges(tag)
+ #l = tk_split_simplelist(tk_send_without_enc('tag', 'ranges',
+ # _get_eval_enc_str(tag)))
+ l = tk_split_simplelist(tk_send_without_enc('tag', 'ranges',
+ _get_eval_enc_str(tag)),
+ false, true)
+ r = []
+ while key=l.shift
+ r.push [Tk::Text::IndexString.new(key), Tk::Text::IndexString.new(l.shift)]
+ end
+ r
+ end
+
+ def tag_nextrange(tag, first, last=None)
+ simplelist(tk_send_without_enc('tag', 'nextrange',
+ _get_eval_enc_str(tag),
+ _get_eval_enc_str(first),
+ _get_eval_enc_str(last))).collect{|idx|
+ Tk::Text::IndexString.new(idx)
+ }
+ end
+
+ def tag_prevrange(tag, first, last=None)
+ simplelist(tk_send_without_enc('tag', 'prevrange',
+ _get_eval_enc_str(tag),
+ _get_eval_enc_str(first),
+ _get_eval_enc_str(last))).collect{|idx|
+ Tk::Text::IndexString.new(idx)
+ }
+ end
+
+=begin
+ def window_cget(index, slot)
+ case slot.to_s
+ when 'text', 'label', 'show', 'data', 'file'
+ _fromUTF8(tk_send_without_enc('window', 'cget',
+ _get_eval_enc_str(index), "-#{slot}"))
+ when 'font', 'kanjifont'
+ #fnt = tk_tcl2ruby(tk_send('window', 'cget', index, "-#{slot}"))
+ fnt = tk_tcl2ruby(_fromUTF8(tk_send_without_enc('window', 'cget', _get_eval_enc_str(index), '-font')))
+ unless fnt.kind_of?(TkFont)
+ fnt = tagfontobj(index, fnt)
+ end
+ if slot.to_s == 'kanjifont' && JAPANIZED_TK && TK_VERSION =~ /^4\.*/
+ # obsolete; just for compatibility
+ fnt.kanji_font
+ else
+ fnt
+ end
+ else
+ tk_tcl2ruby(_fromUTF8(tk_send_without_enc('window', 'cget', _get_eval_enc_str(index), "-#{slot}")))
+ end
+ end
+
+ def window_configure(index, slot, value=None)
+ if index.kind_of?(TkTextWindow)
+ index.configure(slot, value)
+ else
+ if slot.kind_of?(Hash)
+ slot = _symbolkey2str(slot)
+ win = slot['window']
+ # slot['window'] = win.epath if win.kind_of?(TkWindow)
+ slot['window'] = _epath(win) if win
+ if slot['create']
+ p_create = slot['create']
+ if p_create.kind_of?(Proc)
+#=begin
+ slot['create'] = install_cmd(proc{
+ id = p_create.call
+ if id.kind_of?(TkWindow)
+ id.epath
+ else
+ id
+ end
+ })
+#=end
+ slot['create'] = install_cmd(proc{_epath(p_create.call)})
+ end
+ end
+ tk_send_without_enc('window', 'configure',
+ _get_eval_enc_str(index),
+ *hash_kv(slot, true))
+ else
+ if slot == 'window' || slot == :window
+ # id = value
+ # value = id.epath if id.kind_of?(TkWindow)
+ value = _epath(value)
+ end
+ if slot == 'create' || slot == :create
+ p_create = value
+ if p_create.kind_of?(Proc)
+#=begin
+ value = install_cmd(proc{
+ id = p_create.call
+ if id.kind_of?(TkWindow)
+ id.epath
+ else
+ id
+ end
+ })
+#=end
+ value = install_cmd(proc{_epath(p_create.call)})
+ end
+ end
+ tk_send_without_enc('window', 'configure',
+ _get_eval_enc_str(index),
+ "-#{slot}", _get_eval_enc_str(value))
+ end
+ end
+ self
+ end
+
+ def window_configinfo(win, slot = nil)
+ if TkComm::GET_CONFIGINFO_AS_ARRAY
+ if slot
+ case slot.to_s
+ when 'text', 'label', 'show', 'data', 'file'
+ conf = tk_split_simplelist(_fromUTF8(tk_send('window', 'configure', _get_eval_enc_str(win), "-#{slot}")))
+ else
+ conf = tk_split_list(_fromUTF8(tk_send('window', 'configure', _get_eval_enc_str(win), "-#{slot}")))
+ end
+ conf[0] = conf[0][1..-1]
+ conf
+ else
+ tk_split_simplelist(_fromUTF8(tk_send('window', 'configure', _get_eval_enc_str(win)))).collect{|conflist|
+ conf = tk_split_simplelist(conflist)
+ conf[0] = conf[0][1..-1]
+ case conf[0]
+ when 'text', 'label', 'show', 'data', 'file'
+ else
+ if conf[3]
+ if conf[3].index('{')
+ conf[3] = tk_split_list(conf[3])
+ else
+ conf[3] = tk_tcl2ruby(conf[3])
+ end
+ end
+ if conf[4]
+ if conf[4].index('{')
+ conf[4] = tk_split_list(conf[4])
+ else
+ conf[4] = tk_tcl2ruby(conf[4])
+ end
+ end
+ end
+ conf[1] = conf[1][1..-1] if conf.size == 2 # alias info
+ conf
+ }
+ end
+ else # ! TkComm::GET_CONFIGINFO_AS_ARRAY
+ if slot
+ case slot.to_s
+ when 'text', 'label', 'show', 'data', 'file'
+ conf = tk_split_simplelist(_fromUTF8(tk_send('window', 'configure', _get_eval_enc_str(win), "-#{slot}")))
+ else
+ conf = tk_split_list(_fromUTF8(tk_send('window', 'configure', _get_eval_enc_str(win), "-#{slot}")))
+ end
+ key = conf.shift[1..-1]
+ { key => conf }
+ else
+ ret = {}
+ tk_split_simplelist(_fromUTF8(tk_send('window', 'configure', _get_eval_enc_str(win)))).each{|conflist|
+ conf = tk_split_simplelist(conflist)
+ key = conf.shift[1..-1]
+ case key
+ when 'text', 'label', 'show', 'data', 'file'
+ else
+ if conf[2]
+ if conf[2].index('{')
+ conf[2] = tk_split_list(conf[2])
+ else
+ conf[2] = tk_tcl2ruby(conf[2])
+ end
+ end
+ if conf[3]
+ if conf[3].index('{')
+ conf[3] = tk_split_list(conf[3])
+ else
+ conf[3] = tk_tcl2ruby(conf[3])
+ end
+ end
+ end
+ if conf.size == 1
+ ret[key] = conf[0][1..-1] # alias info
+ else
+ ret[key] = conf
+ end
+ }
+ ret
+ end
+ end
+ end
+
+ def current_window_configinfo(win, slot = nil)
+ if TkComm::GET_CONFIGINFO_AS_ARRAY
+ if slot
+ conf = window_configinfo(win, slot)
+ {conf[0] => conf[4]}
+ else
+ ret = {}
+ window_configinfo(win).each{|conf|
+ ret[conf[0]] = conf[4] if conf.size > 2
+ }
+ ret
+ end
+ else # ! TkComm::GET_CONFIGINFO_AS_ARRAY
+ ret = {}
+ window_configinfo(win, slot).each{|k, conf|
+ ret[k] = conf[-1] if conf.kind_of?(Array)
+ }
+ ret
+ end
+ end
+=end
+
+ def window_names
+ # tk_split_simplelist(_fromUTF8(tk_send_without_enc('window', 'names'))).collect{|elt|
+ tk_split_simplelist(tk_send_without_enc('window', 'names'), false, true).collect{|elt|
+ tagid2obj(elt)
+ }
+ end
+
+ def _ktext_length(txt)
+ if TkCore::WITH_ENCODING ### Ruby 1.9 !!!!!!!!!!!!!
+ return txt.length
+ end
+ ###########################
+
+ if $KCODE !~ /n/i
+ return txt.gsub(/[^\Wa-zA-Z_\d]/, ' ').length
+ end
+
+ # $KCODE == 'NONE'
+ if JAPANIZED_TK
+ tk_call_without_enc('kstring', 'length',
+ _get_eval_enc_str(txt)).to_i
+ else
+ begin
+ tk_call_without_enc('encoding', 'convertto', 'ascii',
+ _get_eval_enc_str(txt)).length
+ rescue StandardError, NameError
+ # sorry, I have no plan
+ txt.length
+ end
+ end
+ end
+ private :_ktext_length
+
+ def tksearch(*args)
+ # call 'search' subcommand of text widget
+ # args ::= [<array_of_opts>] <pattern> <start_index> [<stop_index>]
+ # If <pattern> is regexp, then it must be a regular expression of Tcl
+ nocase = false
+ if args[0].kind_of?(Array)
+ opts = args.shift.collect{|opt|
+ s_opt = opt.to_s
+ nocase = true if s_opt == 'nocase'
+ '-' + s_opt
+ }
+ else
+ opts = []
+ end
+
+ if args[0].kind_of?(Regexp)
+ regexp = args.shift
+ if !nocase && (regexp.options & Regexp::IGNORECASE) != 0
+ opts << '-nocase'
+ end
+ args.unshift(regexp.source)
+ end
+
+ opts << '--'
+
+ ret = tk_send('search', *(opts + args))
+ if ret == ""
+ nil
+ else
+ Tk::Text::IndexString.new(ret)
+ end
+ end
+
+ def tksearch_with_count(*args)
+ # call 'search' subcommand of text widget
+ # args ::= [<array_of_opts>] <var> <pattern> <start_index> [<stop_index>]
+ # If <pattern> is regexp, then it must be a regular expression of Tcl
+ nocase = false
+ if args[0].kind_of?(Array)
+ opts = args.shift.collect{|opt|
+ s_opt = opt.to_s
+ nocase = true if s_opt == 'nocase'
+ '-' + s_opt
+ }
+ else
+ opts = []
+ end
+
+ opts << '-count' << args.shift
+
+ if args[0].kind_of?(Regexp)
+ regexp = args.shift
+ if !nocase && (regexp.options & Regexp::IGNORECASE) != 0
+ opts << '-nocase'
+ end
+ args.unshift(regexp.source)
+ end
+
+ opts << '--'
+
+ ret = tk_send('search', *(opts + args))
+ if ret == ""
+ nil
+ else
+ Tk::Text::IndexString.new(ret)
+ end
+ end
+
+ def search_with_length(pat,start,stop=None)
+ pat = pat.chr if pat.kind_of?(Integer)
+ if stop != None
+ return ["", 0] if compare(start,'>=',stop)
+ txt = get(start,stop)
+ if (pos = txt.index(pat))
+ match = $&
+ #pos = txt[0..(pos-1)].split('').length if pos > 0
+ pos = _ktext_length(txt[0..(pos-1)]) if pos > 0
+ if pat.kind_of?(String)
+ #return [index(start + " + #{pos} chars"), pat.split('').length]
+ return [index(start + " + #{pos} chars"),
+ _ktext_length(pat), pat.dup]
+ else
+ #return [index(start + " + #{pos} chars"), $&.split('').length]
+ return [index(start + " + #{pos} chars"),
+ _ktext_length(match), match]
+ end
+ else
+ return ["", 0]
+ end
+ else
+ txt = get(start,'end - 1 char')
+ if (pos = txt.index(pat))
+ match = $&
+ #pos = txt[0..(pos-1)].split('').length if pos > 0
+ pos = _ktext_length(txt[0..(pos-1)]) if pos > 0
+ if pat.kind_of?(String)
+ #return [index(start + " + #{pos} chars"), pat.split('').length]
+ return [index(start + " + #{pos} chars"),
+ _ktext_length(pat), pat.dup]
+ else
+ #return [index(start + " + #{pos} chars"), $&.split('').length]
+ return [index(start + " + #{pos} chars"),
+ _ktext_length(match), match]
+ end
+ else
+ txt = get('1.0','end - 1 char')
+ if (pos = txt.index(pat))
+ match = $&
+ #pos = txt[0..(pos-1)].split('').length if pos > 0
+ pos = _ktext_length(txt[0..(pos-1)]) if pos > 0
+ if pat.kind_of?(String)
+ #return [index("1.0 + #{pos} chars"), pat.split('').length]
+ return [index("1.0 + #{pos} chars"),
+ _ktext_length(pat), pat.dup]
+ else
+ #return [index("1.0 + #{pos} chars"), $&.split('').length]
+ return [index("1.0 + #{pos} chars"), _ktext_length(match), match]
+ end
+ else
+ return ["", 0]
+ end
+ end
+ end
+ end
+
+ def search(pat,start,stop=None)
+ search_with_length(pat,start,stop)[0]
+ end
+
+ def rsearch_with_length(pat,start,stop=None)
+ pat = pat.chr if pat.kind_of?(Integer)
+ if stop != None
+ return ["", 0] if compare(start,'<=',stop)
+ txt = get(stop,start)
+ if (pos = txt.rindex(pat))
+ match = $&
+ #pos = txt[0..(pos-1)].split('').length if pos > 0
+ pos = _ktext_length(txt[0..(pos-1)]) if pos > 0
+ if pat.kind_of?(String)
+ #return [index(stop + " + #{pos} chars"), pat.split('').length]
+ return [index(stop + " + #{pos} chars"), _ktext_length(pat), pat.dup]
+ else
+ #return [index(stop + " + #{pos} chars"), $&.split('').length]
+ return [index(stop + " + #{pos} chars"), _ktext_length(match), match]
+ end
+ else
+ return ["", 0]
+ end
+ else
+ txt = get('1.0',start)
+ if (pos = txt.rindex(pat))
+ match = $&
+ #pos = txt[0..(pos-1)].split('').length if pos > 0
+ pos = _ktext_length(txt[0..(pos-1)]) if pos > 0
+ if pat.kind_of?(String)
+ #return [index("1.0 + #{pos} chars"), pat.split('').length]
+ return [index("1.0 + #{pos} chars"), _ktext_length(pat), pat.dup]
+ else
+ #return [index("1.0 + #{pos} chars"), $&.split('').length]
+ return [index("1.0 + #{pos} chars"), _ktext_length(match), match]
+ end
+ else
+ txt = get('1.0','end - 1 char')
+ if (pos = txt.rindex(pat))
+ match = $&
+ #pos = txt[0..(pos-1)].split('').length if pos > 0
+ pos = _ktext_length(txt[0..(pos-1)]) if pos > 0
+ if pat.kind_of?(String)
+ #return [index("1.0 + #{pos} chars"), pat.split('').length]
+ return [index("1.0 + #{pos} chars"), _ktext_length(pat), pat.dup]
+ else
+ #return [index("1.0 + #{pos} chars"), $&.split('').length]
+ return [index("1.0 + #{pos} chars"), _ktext_length(match), match]
+ end
+ else
+ return ["", 0]
+ end
+ end
+ end
+ end
+
+ def rsearch(pat,start,stop=None)
+ rsearch_with_length(pat,start,stop)[0]
+ end
+
+ def dump(type_info, *index, &block)
+ if type_info.kind_of?(Symbol)
+ type_info = [ type_info.to_s ]
+ elsif type_info.kind_of?(String)
+ type_info = [ type_info ]
+ end
+ args = type_info.collect{|inf| '-' + inf}
+ args << '-command' << block if block
+ str = tk_send('dump', *(args + index))
+ result = []
+ sel = nil
+ i = 0
+ while i < str.size
+ # retrieve key
+ idx = str.index(/ /, i)
+ result.push str[i..(idx-1)]
+ i = idx + 1
+
+ # retrieve value
+ case result[-1]
+ when 'text'
+ if str[i] == ?{
+ # text formed as {...}
+ val, i = _retrieve_braced_text(str, i)
+ result.push val
+ else
+ # text which may contain backslahes
+ val, i = _retrieve_backslashed_text(str, i)
+ result.push val
+ end
+ else
+ idx = str.index(/ /, i)
+ val = str[i..(idx-1)]
+ case result[-1]
+ when 'mark'
+ case val
+ when 'insert'
+ result.push TkTextMarkInsert.new(self)
+ when 'current'
+ result.push TkTextMarkCurrent.new(self)
+ when 'anchor'
+ result.push TkTextMarkAnchor.new(self)
+ else
+ result.push tk_tcl2ruby(val)
+ end
+ when 'tagon'
+ if val == 'sel'
+ if sel
+ result.push sel
+ else
+ result.push TkTextTagSel.new(self)
+ end
+ else
+ result.push tk_tcl2ruby(val)
+ end
+ when 'tagoff'
+ result.push tk_tcl2ruby(val)
+ when 'window'
+ result.push tk_tcl2ruby(val)
+ when 'image'
+ result.push tk_tcl2ruby(val)
+ end
+ i = idx + 1
+ end
+
+ # retrieve index
+ idx = str.index(/ /, i)
+ if idx
+ result.push(Tk::Text::IndexString.new(str[i..(idx-1)]))
+ i = idx + 1
+ else
+ result.push(Tk::Text::IndexString.new(str[i..-1]))
+ break
+ end
+ end
+
+ kvis = []
+ until result.empty?
+ kvis.push [result.shift, result.shift, result.shift]
+ end
+ kvis # result is [[key1, value1, index1], [key2, value2, index2], ...]
+ end
+
+ def _retrieve_braced_text(str, i)
+ cnt = 0
+ idx = i
+ while idx < str.size
+ case str[idx]
+ when ?{
+ cnt += 1
+ when ?}
+ cnt -= 1
+ if cnt == 0
+ break
+ end
+ end
+ idx += 1
+ end
+ return str[i+1..idx-1], idx + 2
+ end
+ private :_retrieve_braced_text
+
+ def _retrieve_backslashed_text(str, i)
+ j = i
+ idx = nil
+ loop {
+ idx = str.index(/ /, j)
+ if str[idx-1] == ?\\
+ j += 1
+ else
+ break
+ end
+ }
+ val = str[i..(idx-1)]
+ val.gsub!(/\\( |\{|\})/, '\1')
+ return val, idx + 1
+ end
+ private :_retrieve_backslashed_text
+
+ def dump_all(*index, &block)
+ dump(['all'], *index, &block)
+ end
+ def dump_mark(*index, &block)
+ dump(['mark'], *index, &block)
+ end
+ def dump_tag(*index, &block)
+ dump(['tag'], *index, &block)
+ end
+ def dump_text(*index, &block)
+ dump(['text'], *index, &block)
+ end
+ def dump_window(*index, &block)
+ dump(['window'], *index, &block)
+ end
+ def dump_image(*index, &block)
+ dump(['image'], *index, &block)
+ end
+end
+
+#TkText = Tk::Text unless Object.const_defined? :TkText
+#Tk.__set_toplevel_aliases__(:Tk, Tk::Text, :TkText)
+Tk.__set_loaded_toplevel_aliases__('tk/text.rb', :Tk, Tk::Text, :TkText)
+
+
+#######################################
+
+class Tk::Text::Peer < Tk::Text
+ # Tk8.5 feature
+ def initialize(text, parent=nil, keys={})
+ unless text.kind_of?(Tk::Text)
+ fail ArgumentError, "Tk::Text is expected for 1st argument"
+ end
+ @src_text = text
+ super(parent, keys)
+ end
+
+ def create_self(keys)
+ if keys and keys != None
+ tk_call_without_enc(@src_text.path, 'peer', 'create',
+ @path, *hash_kv(keys, true))
+ else
+ tk_call_without_enc(@src_text.path, 'peer', 'create', @path)
+ end
+ end
+ private :create_self
+end
diff --git a/jni/ruby/ext/tk/lib/tk/textimage.rb b/jni/ruby/ext/tk/lib/tk/textimage.rb
new file mode 100644
index 0000000..99027a0
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tk/textimage.rb
@@ -0,0 +1,88 @@
+#
+# tk/textimage.rb - treat Tk text image object
+#
+require 'tk'
+require 'tk/text'
+
+class TkTextImage<TkObject
+ include Tk::Text::IndexModMethods
+
+ def initialize(parent, index, keys)
+ #unless parent.kind_of?(Tk::Text)
+ # fail ArgumentError, "expect Tk::Text for 1st argument"
+ #end
+ @t = parent
+ if index == 'end' || index == :end
+ @path = TkTextMark.new(@t, tk_call(@t.path, 'index', 'end - 1 chars'))
+ elsif index.kind_of? TkTextMark
+ if tk_call_without_enc(@t.path,'index',index.path) == tk_call_without_enc(@t.path,'index','end')
+ @path = TkTextMark.new(@t, tk_call_without_enc(@t.path, 'index',
+ 'end - 1 chars'))
+ else
+ @path = TkTextMark.new(@t, tk_call_without_enc(@t.path, 'index',
+ index.path))
+ end
+ else
+ @path = TkTextMark.new(@t, tk_call_without_enc(@t.path, 'index',
+ _get_eval_enc_str(index)))
+ end
+ @path.gravity = 'left'
+ @index = @path.path
+ @id = tk_call_without_enc(@t.path, 'image', 'create', @index,
+ *hash_kv(keys, true)).freeze
+ @path.gravity = 'right'
+ end
+
+ def id
+ Tk::Text::IndexString.new(@id)
+ end
+ def mark
+ @path
+ end
+
+ def [](slot)
+ cget(slot)
+ end
+ def []=(slot, value)
+ configure(slot, value)
+ value
+ end
+
+ def cget(slot)
+ @t.image_cget(@index, slot)
+ end
+
+ def cget_strict(slot)
+ @t.image_cget_strict(@index, slot)
+ end
+
+ def configure(slot, value=None)
+ @t.image_configure(@index, slot, value)
+ self
+ end
+# def configure(slot, value)
+# tk_call @t.path, 'image', 'configure', @index, "-#{slot}", value
+# end
+
+ def configinfo(slot = nil)
+ @t.image_configinfo(@index, slot)
+ end
+
+ def current_configinfo(slot = nil)
+ @t.current_image_configinfo(@index, slot)
+ end
+
+ def image
+ img = tk_call_without_enc(@t.path, 'image', 'cget', @index, '-image')
+ TkImage::Tk_IMGTBL[img]? TkImage::Tk_IMGTBL[img] : img
+ end
+
+ def image=(value)
+ tk_call_without_enc(@t.path, 'image', 'configure', @index, '-image',
+ _get_eval_enc_str(value))
+ #self
+ value
+ end
+end
+
+TktImage = TkTextImage
diff --git a/jni/ruby/ext/tk/lib/tk/textmark.rb b/jni/ruby/ext/tk/lib/tk/textmark.rb
new file mode 100644
index 0000000..d1888c5
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tk/textmark.rb
@@ -0,0 +1,204 @@
+#
+# tk/textmark.rb - methods for treating text marks
+#
+require 'tk'
+require 'tk/text'
+
+class TkTextMark<TkObject
+ include Tk::Text::IndexModMethods
+
+ TMarkID_TBL = TkCore::INTERP.create_table
+
+ (Tk_TextMark_ID = ['mark'.freeze, TkUtil.untrust('00000')]).instance_eval{
+ @mutex = Mutex.new
+ def mutex; @mutex; end
+ freeze
+ }
+
+ TkCore::INTERP.init_ip_env{
+ TMarkID_TBL.mutex.synchronize{ TMarkID_TBL.clear }
+ }
+
+ def TkTextMark.id2obj(text, id)
+ tpath = text.path
+ TMarkID_TBL.mutex.synchronize{
+ if TMarkID_TBL[tpath]
+ TMarkID_TBL[tpath][id]? TMarkID_TBL[tpath][id]: id
+ else
+ id
+ end
+ }
+ end
+
+ def initialize(parent, index)
+ #unless parent.kind_of?(Tk::Text)
+ # fail ArgumentError, "expect Tk::Text for 1st argument"
+ #end
+ @parent = @t = parent
+ @tpath = parent.path
+ Tk_TextMark_ID.mutex.synchronize{
+ # @path = @id = Tk_TextMark_ID.join('')
+ @path = @id = Tk_TextMark_ID.join(TkCore::INTERP._ip_id_).freeze
+ Tk_TextMark_ID[1].succ!
+ }
+ TMarkID_TBL.mutex.synchronize{
+ TMarkID_TBL[@id] = self
+ TMarkID_TBL[@tpath] = {} unless TMarkID_TBL[@tpath]
+ TMarkID_TBL[@tpath][@id] = self
+ }
+ tk_call_without_enc(@t.path, 'mark', 'set', @id,
+ _get_eval_enc_str(index))
+ @t._addtag id, self
+ end
+
+ def id
+ Tk::Text::IndexString.new(@id)
+ end
+
+ def exist?
+ #if ( tk_split_simplelist(_fromUTF8(tk_call_without_enc(@t.path, 'mark', 'names'))).find{|id| id == @id } )
+ if ( tk_split_simplelist(tk_call_without_enc(@t.path, 'mark', 'names'), false, true).find{|id| id == @id } )
+ true
+ else
+ false
+ end
+ end
+
+=begin
+ # move to Tk::Text::IndexModMethods module
+ def +(mod)
+ return chars(mod) if mod.kind_of?(Numeric)
+
+ mod = mod.to_s
+ if mod =~ /^\s*[+-]?\d/
+ Tk::Text::IndexString.new(@id + ' + ' + mod)
+ else
+ Tk::Text::IndexString.new(@id + ' ' + mod)
+ end
+ end
+
+ def -(mod)
+ return chars(-mod) if mod.kind_of?(Numeric)
+
+ mod = mod.to_s
+ if mod =~ /^\s*[+-]?\d/
+ Tk::Text::IndexString.new(@id + ' - ' + mod)
+ elsif mod =~ /^\s*[-]\s+(\d.*)$/
+ Tk::Text::IndexString.new(@id + ' - -' + $1)
+ else
+ Tk::Text::IndexString.new(@id + ' ' + mod)
+ end
+ end
+=end
+
+ def pos
+ @t.index(@id)
+ end
+
+ def pos=(where)
+ set(where)
+ end
+
+ def set(where)
+ tk_call_without_enc(@t.path, 'mark', 'set', @id,
+ _get_eval_enc_str(where))
+ self
+ end
+
+ def unset
+ tk_call_without_enc(@t.path, 'mark', 'unset', @id)
+ self
+ end
+ alias destroy unset
+
+ def gravity
+ tk_call_without_enc(@t.path, 'mark', 'gravity', @id)
+ end
+
+ def gravity=(direction)
+ tk_call_without_enc(@t.path, 'mark', 'gravity', @id, direction)
+ #self
+ direction
+ end
+
+ def next(index = nil)
+ if index
+ @t.tagid2obj(_fromUTF8(tk_call_without_enc(@t.path, 'mark', 'next', _get_eval_enc_str(index))))
+ else
+ @t.tagid2obj(_fromUTF8(tk_call_without_enc(@t.path, 'mark', 'next', @id)))
+ end
+ end
+
+ def previous(index = nil)
+ if index
+ @t.tagid2obj(_fromUTF8(tk_call_without_enc(@t.path, 'mark', 'previous', _get_eval_enc_str(index))))
+ else
+ @t.tagid2obj(_fromUTF8(tk_call_without_enc(@t.path, 'mark', 'previous', @id)))
+ end
+ end
+end
+TktMark = TkTextMark
+
+class TkTextNamedMark<TkTextMark
+ def self.new(parent, name, index=nil)
+ TMarkID_TBL.mutex.synchronize{
+ if TMarkID_TBL[parent.path] && TMarkID_TBL[parent.path][name]
+ obj = TMarkID_TBL[parent.path][name]
+ else
+ # super(parent, name, *args)
+ (obj = self.allocate).instance_eval{
+ @parent = @t = parent
+ @tpath = parent.path
+ @path = @id = name
+ TMarkID_TBL[@id] = self
+ TMarkID_TBL[@tpath] = {} unless TMarkID_TBL[@tpath]
+ TMarkID_TBL[@tpath][@id] = self unless TMarkID_TBL[@tpath][@id]
+ @t._addtag @id, self
+ }
+ obj
+ end
+
+ if obj && index
+ tk_call_without_enc(parent.path, 'mark', 'set', name,
+ _get_eval_enc_str(index))
+ end
+ obj
+ }
+ end
+
+ def initialize(parent, name, index=nil)
+ # dummy:: not called by 'new' method
+
+ #unless parent.kind_of?(Tk::Text)
+ # fail ArgumentError, "expect Tk::Text for 1st argument"
+ #end
+ @parent = @t = parent
+ @tpath = parent.path
+ @path = @id = name
+ tk_call_without_enc(@t.path, 'mark', 'set', @id,
+ _get_eval_enc_str(index)) if index
+ @t._addtag @id, self
+ end
+end
+TktNamedMark = TkTextNamedMark
+
+class TkTextMarkInsert<TkTextNamedMark
+ def self.new(parent,*args)
+ super(parent, 'insert', *args)
+ end
+end
+TktMarkInsert = TkTextMarkInsert
+
+class TkTextMarkCurrent<TkTextNamedMark
+ def self.new(parent,*args)
+ super(parent, 'current', *args)
+ end
+end
+TktMarkCurrent = TkTextMarkCurrent
+
+class TkTextMarkAnchor<TkTextNamedMark
+ def self.new(parent,*args)
+ super(parent, 'anchor', *args)
+ end
+end
+TktMarkAnchor = TkTextMarkAnchor
diff --git a/jni/ruby/ext/tk/lib/tk/texttag.rb b/jni/ruby/ext/tk/lib/tk/texttag.rb
new file mode 100644
index 0000000..9669201
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tk/texttag.rb
@@ -0,0 +1,321 @@
+#
+# tk/texttag.rb - methods for treating text tags
+#
+require 'tk'
+require 'tk/text'
+require 'tk/tagfont'
+
+class TkTextTag<TkObject
+ include TkTreatTagFont
+ include Tk::Text::IndexModMethods
+
+ TTagID_TBL = TkCore::INTERP.create_table
+
+ (Tk_TextTag_ID = ['tag'.freeze, TkUtil.untrust('00000')]).instance_eval{
+ @mutex = Mutex.new
+ def mutex; @mutex; end
+ freeze
+ }
+
+ TkCore::INTERP.init_ip_env{
+ TTagID_TBL.mutex.synchronize{ TTagID_TBL.clear }
+ }
+
+ def TkTextTag.id2obj(text, id)
+ tpath = text.path
+ TTagID_TBL.mutex.synchronize{
+ if TTagID_TBL[tpath]
+ TTagID_TBL[tpath][id]? TTagID_TBL[tpath][id]: id
+ else
+ id
+ end
+ }
+ end
+
+ def initialize(parent, *args)
+ #unless parent.kind_of?(TkText)
+ # fail ArgumentError, "expect TkText for 1st argument"
+ #end
+ @parent = @t = parent
+ @tpath = parent.path
+ Tk_TextTag_ID.mutex.synchronize{
+ # @path = @id = Tk_TextTag_ID.join('')
+ @path = @id = Tk_TextTag_ID.join(TkCore::INTERP._ip_id_).freeze
+ Tk_TextTag_ID[1].succ!
+ }
+ TTagID_TBL.mutex.synchronize{
+ TTagID_TBL[@id] = self
+ TTagID_TBL[@tpath] = {} unless TTagID_TBL[@tpath]
+ TTagID_TBL[@tpath][@id] = self
+ }
+ #tk_call @t.path, "tag", "configure", @id, *hash_kv(keys)
+ if args != []
+ keys = args.pop
+ if keys.kind_of?(Hash)
+ add(*args) if args != []
+ configure(keys)
+ else
+ args.push keys
+ add(*args)
+ end
+ end
+ @t._addtag id, self
+ end
+
+ def id
+ Tk::Text::IndexString.new(@id)
+ end
+
+ def exist?
+ #if ( tk_split_simplelist(_fromUTF8(tk_call_without_enc(@t.path, 'tag', 'names'))).find{|id| id == @id } )
+ if ( tk_split_simplelist(tk_call_without_enc(@t.path, 'tag', 'names'), false, true).find{|id| id == @id } )
+ true
+ else
+ false
+ end
+ end
+
+ def first
+ Tk::Text::IndexString.new(@id + '.first')
+ end
+
+ def last
+ Tk::Text::IndexString.new(@id + '.last')
+ end
+
+ def add(*indices)
+ tk_call_without_enc(@t.path, 'tag', 'add', @id,
+ *(indices.collect{|idx| _get_eval_enc_str(idx)}))
+ self
+ end
+
+ def remove(*indices)
+ tk_call_without_enc(@t.path, 'tag', 'remove', @id,
+ *(indices.collect{|idx| _get_eval_enc_str(idx)}))
+ self
+ end
+
+ def ranges
+ l = tk_split_simplelist(tk_call_without_enc(@t.path, 'tag', 'ranges', @id))
+ r = []
+ while key=l.shift
+ r.push [Tk::Text::IndexString.new(key), Tk::Text::IndexString.new(l.shift)]
+ end
+ r
+ end
+
+ def nextrange(first, last=None)
+ simplelist(tk_call_without_enc(@t.path, 'tag', 'nextrange', @id,
+ _get_eval_enc_str(first),
+ _get_eval_enc_str(last))).collect{|idx|
+ Tk::Text::IndexString.new(idx)
+ }
+ end
+
+ def prevrange(first, last=None)
+ simplelist(tk_call_without_enc(@t.path, 'tag', 'prevrange', @id,
+ _get_eval_enc_str(first),
+ _get_eval_enc_str(last))).collect{|idx|
+ Tk::Text::IndexString.new(idx)
+ }
+ end
+
+ def [](key)
+ cget key
+ end
+
+ def []=(key,val)
+ configure key, val
+ val
+ end
+
+ def cget_tkstring(key)
+ @t.tag_cget_tkstring @id, key
+ end
+ def cget(key)
+ @t.tag_cget @id, key
+ end
+ def cget_strict(key)
+ @t.tag_cget_strict @id, key
+ end
+=begin
+ def cget(key)
+ case key.to_s
+ when 'text', 'label', 'show', 'data', 'file'
+ _fromUTF8(tk_call_without_enc(@t.path, 'tag', 'cget', @id, "-#{key}"))
+ when 'font', 'kanjifont'
+ #fnt = tk_tcl2ruby(tk_call(@t.path, 'tag', 'cget', @id, "-#{key}"))
+ fnt = tk_tcl2ruby(_fromUTF8(tk_call_without_enc(@t.path, 'tag', 'cget',
+ @id, '-font')))
+ unless fnt.kind_of?(TkFont)
+ fnt = tagfontobj(@id, fnt)
+ end
+ if key.to_s == 'kanjifont' && JAPANIZED_TK && TK_VERSION =~ /^4\.*/
+ # obsolete; just for compatibility
+ fnt.kanji_font
+ else
+ fnt
+ end
+ else
+ tk_tcl2ruby(_fromUTF8(tk_call_without_enc(@t.path, 'tag', 'cget',
+ @id, "-#{key}")))
+ end
+ end
+=end
+
+ def configure(key, val=None)
+ @t.tag_configure @id, key, val
+ end
+# def configure(key, val=None)
+# if key.kind_of?(Hash)
+# tk_call @t.path, 'tag', 'configure', @id, *hash_kv(key)
+# else
+# tk_call @t.path, 'tag', 'configure', @id, "-#{key}", val
+# end
+# end
+# def configure(key, value)
+# if value == FALSE
+# value = "0"
+# elsif value.kind_of?(Proc)
+# value = install_cmd(value)
+# end
+# tk_call @t.path, 'tag', 'configure', @id, "-#{key}", value
+# end
+
+ def configinfo(key=nil)
+ @t.tag_configinfo @id, key
+ end
+
+ def current_configinfo(key=nil)
+ @t.current_tag_configinfo @id, key
+ end
+
+ #def bind(seq, cmd=Proc.new, *args)
+ # _bind([@t.path, 'tag', 'bind', @id], seq, cmd, *args)
+ # self
+ #end
+ def bind(seq, *args)
+ # if args[0].kind_of?(Proc) || args[0].kind_of?(Method)
+ if TkComm._callback_entry?(args[0]) || !block_given?
+ cmd = args.shift
+ else
+ cmd = Proc.new
+ end
+ _bind([@t.path, 'tag', 'bind', @id], seq, cmd, *args)
+ self
+ end
+
+ #def bind_append(seq, cmd=Proc.new, *args)
+ # _bind_append([@t.path, 'tag', 'bind', @id], seq, cmd, *args)
+ # self
+ #end
+ def bind_append(seq, *args)
+ # if args[0].kind_of?(Proc) || args[0].kind_of?(Method)
+ if TkComm._callback_entry?(args[0]) || !block_given?
+ cmd = args.shift
+ else
+ cmd = Proc.new
+ end
+ _bind_append([@t.path, 'tag', 'bind', @id], seq, cmd, *args)
+ self
+ end
+
+ def bind_remove(seq)
+ _bind_remove([@t.path, 'tag', 'bind', @id], seq)
+ self
+ end
+
+ def bindinfo(context=nil)
+ _bindinfo([@t.path, 'tag', 'bind', @id], context)
+ end
+
+ def raise(above=None)
+ tk_call_without_enc(@t.path, 'tag', 'raise', @id,
+ _get_eval_enc_str(above))
+ self
+ end
+
+ def lower(below=None)
+ tk_call_without_enc(@t.path, 'tag', 'lower', @id,
+ _get_eval_enc_str(below))
+ self
+ end
+
+ def destroy
+ tk_call_without_enc(@t.path, 'tag', 'delete', @id)
+ TTagID_TBL.mutex.synchronize{
+ TTagID_TBL[@tpath].delete(@id) if TTagID_TBL[@tpath]
+ }
+ self
+ end
+end
+TktTag = TkTextTag
+
+class TkTextNamedTag<TkTextTag
+ def self.new(parent, name, *args)
+ tagobj = nil
+ TTagID_TBL.mutex.synchronize{
+ if TTagID_TBL[parent.path] && TTagID_TBL[parent.path][name]
+ tagobj = TTagID_TBL[parent.path][name]
+ else
+ # super(parent, name, *args)
+ (tagobj = self.allocate).instance_eval{
+ @parent = @t = parent
+ @tpath = parent.path
+ @path = @id = name
+ TTagID_TBL[@id] = self
+ TTagID_TBL[@tpath] = {} unless TTagID_TBL[@tpath]
+ TTagID_TBL[@tpath][@id] = self unless TTagID_TBL[@tpath][@id]
+ @t._addtag @id, self
+ }
+ end
+ }
+
+ if args != []
+ keys = args.pop
+ if keys.kind_of?(Hash)
+ tagobj.add(*args) if args != []
+ tagobj.configure(keys)
+ else
+ args.push keys
+ tagobj.add(*args)
+ end
+ end
+
+ tagobj
+ end
+
+ def initialize(parent, name, *args)
+ # dummy:: not called by 'new' method
+
+ #unless parent.kind_of?(Tk::Text)
+ # fail ArgumentError, "expect Tk::Text for 1st argument"
+ #end
+ @parent = @t = parent
+ @tpath = parent.path
+ @path = @id = name
+
+ #if mode
+ # tk_call @t.path, "addtag", @id, *args
+ #end
+ if args != []
+ keys = args.pop
+ if keys.kind_of?(Hash)
+ add(*args) if args != []
+ configure(keys)
+ else
+ args.push keys
+ add(*args)
+ end
+ end
+ @t._addtag @id, self
+ end
+end
+TktNamedTag = TkTextNamedTag
+
+class TkTextTagSel<TkTextNamedTag
+ def self.new(parent, *args)
+ super(parent, 'sel', *args)
+ end
+end
+TktTagSel = TkTextTagSel
diff --git a/jni/ruby/ext/tk/lib/tk/textwindow.rb b/jni/ruby/ext/tk/lib/tk/textwindow.rb
new file mode 100644
index 0000000..49327b2
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tk/textwindow.rb
@@ -0,0 +1,154 @@
+#
+# tk/textwindow.rb - treat Tk text window object
+#
+require 'tk'
+require 'tk/text'
+
+class TkTextWindow<TkObject
+ include Tk::Text::IndexModMethods
+
+ def initialize(parent, index, keys = {})
+ #unless parent.kind_of?(Tk::Text)
+ # fail ArgumentError, "expect Tk::Text for 1st argument"
+ #end
+ @t = parent
+ if index == 'end' || index == :end
+ @path = TkTextMark.new(@t, tk_call_without_enc(@t.path, 'index',
+ 'end - 1 chars'))
+ elsif index.kind_of?(TkTextMark)
+ if tk_call_without_enc(@t.path,'index',index.path) == tk_call_without_enc(@t.path,'index','end')
+ @path = TkTextMark.new(@t, tk_call_without_enc(@t.path, 'index',
+ 'end - 1 chars'))
+ else
+ @path = TkTextMark.new(@t, tk_call_without_enc(@t.path, 'index',
+ index.path))
+ end
+ else
+ @path = TkTextMark.new(@t, tk_call_without_enc(@t.path, 'index', _get_eval_enc_str(index)))
+ end
+ @path.gravity = 'left'
+ @index = @path.path
+ keys = _symbolkey2str(keys)
+ @id = keys['window']
+ # keys['window'] = @id.epath if @id.kind_of?(TkWindow)
+ keys['window'] = _epath(@id) if @id
+ if keys['create']
+ @p_create = keys['create']
+ # if @p_create.kind_of?(Proc)
+ if TkComm._callback_entry?(@p_create)
+=begin
+ keys['create'] = install_cmd(proc{
+ @id = @p_create.call
+ if @id.kind_of?(TkWindow)
+ @id.epath
+ else
+ @id
+ end
+ })
+=end
+ keys['create'] = install_cmd(proc{@id = @p_create.call; _epath(@id)})
+ end
+ end
+ tk_call_without_enc(@t.path, 'window', 'create', @index,
+ *hash_kv(keys, true))
+ @path.gravity = 'right'
+ end
+
+ def id
+ Tk::Text::IndexString.new(_epath(@id))
+ end
+ def mark
+ @path
+ end
+
+ def [](slot)
+ cget(slot)
+ end
+ def []=(slot, value)
+ configure(slot, value)
+ value
+ end
+
+ def cget(slot)
+ @t.window_cget(@index, slot)
+ end
+ def cget_strict(slot)
+ @t.window_cget_strict(@index, slot)
+ end
+
+ def configure(slot, value=None)
+ if slot.kind_of?(Hash)
+ slot = _symbolkey2str(slot)
+ if slot['window']
+ @id = slot['window']
+ # slot['window'] = @id.epath if @id.kind_of?(TkWindow)
+ slot['window'] = _epath(@id) if @id
+ end
+ if slot['create']
+ self.create=slot.delete('create')
+ end
+ if slot.size > 0
+ tk_call_without_enc(@t.path, 'window', 'configure', @index,
+ *hash_kv(slot, true))
+ end
+ else
+ if slot == 'window' || slot == :window
+ @id = value
+ # value = @id.epath if @id.kind_of?(TkWindow)
+ value = _epath(@id) if @id
+ end
+ if slot == 'create' || slot == :create
+ self.create=value
+ else
+ tk_call_without_enc(@t.path, 'window', 'configure', @index,
+ "-#{slot}", _get_eval_enc_str(value))
+ end
+ end
+ self
+ end
+
+ def configinfo(slot = nil)
+ @t.window_configinfo(@index, slot)
+ end
+
+ def current_configinfo(slot = nil)
+ @t.current_window_configinfo(@index, slot)
+ end
+
+ def window
+ @id
+ end
+
+ def window=(value)
+ @id = value
+ # value = @id.epath if @id.kind_of?(TkWindow)
+ value = _epath(@id) if @id
+ tk_call_without_enc(@t.path, 'window', 'configure', @index,
+ '-window', _get_eval_enc_str(value))
+ value
+ end
+
+ def create
+ @p_create
+ end
+
+ def create=(value)
+ @p_create = value
+ # if @p_create.kind_of?(Proc)
+ if TkComm._callback_entry?(@p_create)
+ value = install_cmd(proc{
+ @id = @p_create.call
+ if @id.kind_of?(TkWindow)
+ @id.epath
+ else
+ @id
+ end
+ })
+ end
+ tk_call_without_enc(@t.path, 'window', 'configure', @index,
+ '-create', _get_eval_enc_str(value))
+ value
+ end
+end
+
+TktWindow = TkTextWindow
diff --git a/jni/ruby/ext/tk/lib/tk/timer.rb b/jni/ruby/ext/tk/lib/tk/timer.rb
new file mode 100644
index 0000000..fb2e088
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tk/timer.rb
@@ -0,0 +1,669 @@
+#
+# tk/timer.rb : methods for Tcl/Tk after command
+#
+# $Id: timer.rb 25189 2009-10-02 12:04:37Z akr $
+#
+require 'tk'
+
+class TkTimer
+ include TkCore
+ extend TkCore
+
+ TkCommandNames = ['after'.freeze].freeze
+
+ (Tk_CBID = ['a'.freeze, TkUtil.untrust('00000')]).instance_eval{
+ @mutex = Mutex.new
+ def mutex; @mutex; end
+ freeze
+ }
+
+ Tk_CBTBL = TkUtil.untrust({})
+
+ TkCore::INTERP.add_tk_procs('rb_after', 'id', <<-'EOL')
+ if {[set st [catch {eval {ruby_cmd TkTimer callback} $id} ret]] != 0} {
+ return -code $st $ret
+ } {
+ return $ret
+ }
+ EOL
+
+ DEFAULT_IGNORE_EXCEPTIONS = [ NameError, RuntimeError ].freeze
+
+ ###############################
+ # class methods
+ ###############################
+ def self.start(*args, &b)
+ self.new(*args, &b).start
+ end
+
+ def self.callback(obj_id)
+ ex_obj = Tk_CBTBL[obj_id]
+ return "" if ex_obj == nil; # canceled
+ ex_obj.cb_call
+ end
+
+ def self.info(obj = nil)
+ if obj
+ if obj.kind_of?(TkTimer)
+ if obj.after_id
+ inf = tk_split_list(tk_call_without_enc('after','info',obj.after_id))
+ [Tk_CBTBL[inf[0][1]], inf[1]]
+ else
+ nil
+ end
+ else
+ fail ArgumentError, "TkTimer object is expected"
+ end
+ else
+ tk_call_without_enc('after', 'info').split(' ').collect!{|id|
+ ret = Tk_CBTBL.find{|key,val| val.after_id == id}
+ (ret == nil)? id: ret[1]
+ }
+ end
+ end
+
+
+ ###############################
+ # instance methods
+ ###############################
+ def do_callback
+ @in_callback = true
+ @after_id = nil
+ begin
+ @return_value = @current_proc.call(self)
+ rescue SystemExit
+ exit(0)
+ rescue Interrupt
+ exit!(1)
+ rescue Exception => e
+ if @cancel_on_exception &&
+ @cancel_on_exception.find{|exc| e.kind_of?(exc)}
+ cancel
+ @return_value = e
+ @in_callback = false
+ return e
+ else
+ fail e
+ end
+ end
+ if @set_next
+ set_next_callback(@current_args)
+ else
+ @set_next = true
+ end
+ @in_callback = false
+ @return_value
+ end
+
+ def set_callback(sleep, args=nil)
+ if TkCore::INTERP.deleted?
+ self.cancel
+ return self
+ end
+ @after_script = "rb_after #{@id}"
+ @current_args = args
+ @current_script = [sleep, @after_script]
+ @after_id = tk_call_without_enc('after', sleep, @after_script)
+ self
+ end
+
+ def set_next_callback(args)
+ if @running == false || @proc_max == 0 || @do_loop == 0
+ Tk_CBTBL.delete(@id) ;# for GC
+ @running = false
+ # @wait_var.value = 0
+ __at_end__
+ return
+ end
+ if @current_pos >= @proc_max
+ if @do_loop < 0 || (@do_loop -= 1) > 0
+ @current_pos = 0
+ else
+ Tk_CBTBL.delete(@id) ;# for GC
+ @running = false
+ # @wait_var.value = 0
+ __at_end__
+ return
+ end
+ end
+
+ @current_args = args
+
+ # if @sleep_time.kind_of?(Proc)
+ if TkComm._callback_entry?(@sleep_time)
+ sleep = @sleep_time.call(self)
+ else
+ sleep = @sleep_time
+ end
+ @current_sleep = sleep
+
+ cmd, *cmd_args = @loop_proc[@current_pos]
+ @current_pos += 1
+ @current_proc = cmd
+
+ set_callback(sleep, cmd_args)
+ end
+
+ def initialize(*args, &b)
+ Tk_CBID.mutex.synchronize{
+ # @id = Tk_CBID.join('')
+ @id = Tk_CBID.join(TkCore::INTERP._ip_id_)
+ Tk_CBID[1].succ!
+ }
+
+ @wait_var = TkVariable.new(0)
+
+ @at_end_proc = nil
+
+ @cb_cmd = TkCore::INTERP.get_cb_entry(self.method(:do_callback))
+
+ @set_next = true
+
+ @init_sleep = 0
+ @init_proc = nil
+ @init_args = []
+
+ @current_script = []
+ @current_proc = nil
+ @current_args = nil
+ @return_value = nil
+
+ @sleep_time = 0
+ @current_sleep = 0
+ @loop_exec = 0
+ @do_loop = 0
+ @loop_proc = []
+ @proc_max = 0
+ @current_pos = 0
+
+ @after_id = nil
+ @after_script = nil
+
+ @cancel_on_exception = DEFAULT_IGNORE_EXCEPTIONS
+ # Unless @cancel_on_exception, Ruby/Tk shows an error dialog box when
+ # an excepsion is raised on TkTimer callback procedure.
+ # If @cancel_on_exception is an array of exception classes and the raised
+ # exception is included in the array, Ruby/Tk cancels executing TkTimer
+ # callback procedures silently (TkTimer#cancel is called and no dialog is
+ # shown).
+
+ if b
+ case args.size
+ when 0
+ add_procs(b)
+ when 1
+ args << -1 << b
+ else
+ args << b
+ end
+ end
+
+ set_procs(*args) if args != []
+
+ @running = false
+ @in_callback = false
+ end
+
+ attr :after_id
+ attr :after_script
+ attr :current_proc
+ attr :current_args
+ attr :current_sleep
+ alias :current_interval :current_sleep
+ attr :return_value
+
+ attr_accessor :loop_exec
+
+ def __at_end__
+ @at_end_proc.call(self) if @at_end_proc
+ @wait_var.value = 0 # for wait
+ end
+ private :__at_end__
+
+ def cb_call
+ @cb_cmd.call
+ end
+
+ def get_procs
+ [@init_sleep, @init_proc, @init_args, @sleep_time, @loop_exec, @loop_proc]
+ end
+
+ def current_status
+ [@running, @current_sleep, @current_proc, @current_args,
+ @do_loop, @cancel_on_exception]
+ end
+
+ def cancel_on_exception?
+ @cancel_on_exception
+ end
+
+ def cancel_on_exception=(mode)
+ if mode.kind_of?(Array)
+ @cancel_on_exception = mode
+ elsif mode
+ @cancel_on_exception = DEFAULT_IGNORE_EXCEPTIONS
+ else
+ @cancel_on_exception = false
+ end
+ #self
+ end
+
+ def running?
+ @running
+ end
+
+ def loop_rest
+ @do_loop
+ end
+
+ def loop_rest=(rest)
+ @do_loop = rest
+ #self
+ end
+
+ def set_interval(interval)
+ #if interval != 'idle' && interval != :idle \
+ # && !interval.kind_of?(Integer) && !interval.kind_of?(Proc)
+ if interval != 'idle' && interval != :idle \
+ && !interval.kind_of?(Integer) && !TkComm._callback_entry?(interval)
+ fail ArgumentError, "expect Integer or Proc"
+ end
+ @sleep_time = interval
+ end
+
+ def set_procs(interval, loop_exec, *procs)
+ #if interval != 'idle' && interval != :idle \
+ # && !interval.kind_of?(Integer) && !interval.kind_of?(Proc)
+ if interval != 'idle' && interval != :idle \
+ && !interval.kind_of?(Integer) && !TkComm._callback_entry?(interval)
+ fail ArgumentError, "expect Integer or Proc for 1st argument"
+ end
+ @sleep_time = interval
+
+ @loop_proc = []
+ procs.each{|e|
+ # if e.kind_of?(Proc)
+ if TkComm._callback_entry?(e)
+ @loop_proc.push([e])
+ else
+ @loop_proc.push(e)
+ end
+ }
+ @proc_max = @loop_proc.size
+ @current_pos = 0
+
+ if loop_exec.kind_of?(Integer) && loop_exec < 0
+ @loop_exec = -1
+ elsif loop_exec == true
+ @loop_exec = -1
+ elsif loop_exec == nil || loop_exec == false || loop_exec == 0
+ @loop_exec = 0
+ else
+ if not loop_exec.kind_of?(Integer)
+ fail ArgumentError, "expect Integer for 2nd argument"
+ end
+ @loop_exec = loop_exec
+ end
+ @do_loop = @loop_exec
+
+ self
+ end
+
+ def add_procs(*procs)
+ procs.each{|e|
+ # if e.kind_of?(Proc)
+ if TkComm._callback_entry?(e)
+ @loop_proc.push([e])
+ else
+ @loop_proc.push(e)
+ end
+ }
+ @proc_max = @loop_proc.size
+
+ self
+ end
+
+ def delete_procs(*procs)
+ procs.each{|e|
+ # if e.kind_of?(Proc)
+ if TkComm._callback_entry?(e)
+ @loop_proc.delete([e])
+ else
+ @loop_proc.delete(e)
+ end
+ }
+ @proc_max = @loop_proc.size
+
+ cancel if @proc_max == 0
+
+ self
+ end
+
+ def delete_at(n)
+ @loop_proc.delete_at(n)
+ @proc_max = @loop_proc.size
+ cancel if @proc_max == 0
+ self
+ end
+
+ def set_start_proc(sleep=nil, init_proc=nil, *init_args, &b)
+ # set parameters for 'restart'
+ sleep = @init_sleep unless sleep
+
+ if sleep != 'idle' && sleep != :idle && !sleep.kind_of?(Integer)
+ fail ArgumentError, "expect Integer or 'idle' for 1st argument"
+ end
+
+ @init_sleep = sleep
+ @init_proc = init_proc
+ @init_args = init_args
+
+ @init_proc = b if !@init_proc && b
+ @init_proc = proc{|*args| } if @init_sleep > 0 && !@init_proc
+
+ self
+ end
+
+ def start(*init_args, &b)
+ return nil if @running
+
+ Tk_CBTBL[@id] = self
+ @do_loop = @loop_exec
+ @current_pos = 0
+ @return_value = nil
+ @after_id = nil
+
+ @init_sleep = 0
+ @init_proc = nil
+ @init_args = nil
+
+ argc = init_args.size
+ if argc > 0
+ sleep = init_args.shift
+ if sleep != 'idle' && sleep != :idle && !sleep.kind_of?(Integer)
+ fail ArgumentError, "expect Integer or 'idle' for 1st argument"
+ end
+ @init_sleep = sleep
+ end
+ @init_proc = init_args.shift if argc > 1
+ @init_args = init_args if argc > 2
+
+ @init_proc = b if !@init_proc && b
+ @init_proc = proc{|*args| } if @init_sleep > 0 && !@init_proc
+
+ @current_sleep = @init_sleep
+ @running = true
+ if @init_proc
+ # if not @init_proc.kind_of?(Proc)
+ if !TkComm._callback_entry?(@init_proc)
+ fail ArgumentError, "Argument '#{@init_proc}' need to be Proc"
+ end
+ @current_proc = @init_proc
+ set_callback(@init_sleep, @init_args)
+ @set_next = false if @in_callback
+ else
+ set_next_callback(@init_args)
+ end
+
+ self
+ end
+
+ def reset(*reset_args)
+ restart() if @running
+
+ if @init_proc
+ @return_value = @init_proc.call(self)
+ else
+ @return_value = nil
+ end
+
+ @current_pos = 0
+ @current_args = @init_args
+ @current_script = []
+
+ @set_next = false if @in_callback
+
+ self
+ end
+
+ def restart(*restart_args, &b)
+ cancel if @running
+ if restart_args.empty? && !b
+ start(@init_sleep, @init_proc, *@init_args)
+ else
+ start(*restart_args, &b)
+ end
+ end
+
+ def cancel
+ @running = false
+ # @wait_var.value = 0
+ __at_end__
+ tk_call 'after', 'cancel', @after_id if @after_id
+ @after_id = nil
+
+ Tk_CBTBL.delete(@id) ;# for GC
+ self
+ end
+ alias stop cancel
+
+ def continue(wait=nil)
+ fail RuntimeError, "is already running" if @running
+ return restart() if @current_script.empty?
+ sleep, cmd = @current_script
+ fail RuntimeError, "no procedure to continue" unless cmd
+ if wait
+ unless wait.kind_of?(Integer)
+ fail ArgumentError, "expect Integer for 1st argument"
+ end
+ sleep = wait
+ end
+ Tk_CBTBL[@id] = self
+ @running = true
+ @after_id = tk_call_without_enc('after', sleep, cmd)
+ self
+ end
+
+ def skip
+ fail RuntimeError, "is not running now" unless @running
+ cancel
+ Tk_CBTBL[@id] = self
+ @running = true
+ set_next_callback(@current_args)
+ self
+ end
+
+ def info
+ if @after_id
+ inf = tk_split_list(tk_call_without_enc('after', 'info', @after_id))
+ [Tk_CBTBL[inf[0][1]], inf[1]]
+ else
+ nil
+ end
+ end
+
+ def at_end(*arg, &b)
+ if arg.empty?
+ if b
+ @at_end_proc = b
+ else
+ # no proc
+ return @at_end_proc
+ end
+ else
+ fail ArgumentError, "wrong number of arguments" if arg.length != 1 || b
+ @at_end_proc = arg[0]
+ end
+ self
+ end
+
+ def wait(on_thread = true, check_root = false)
+ if $SAFE >= 4
+ fail SecurityError, "can't wait timer at $SAFE >= 4"
+ end
+
+ unless @running
+ if @return_value.kind_of?(Exception)
+ fail @return_value
+ else
+ return @return_value
+ end
+ end
+
+ @wait_var.wait(on_thread, check_root)
+ if @return_value.kind_of?(Exception)
+ fail @return_value
+ else
+ @return_value
+ end
+ end
+ def eventloop_wait(check_root = false)
+ wait(false, check_root)
+ end
+ def thread_wait(check_root = false)
+ wait(true, check_root)
+ end
+ def tkwait(on_thread = true)
+ wait(on_thread, true)
+ end
+ def eventloop_tkwait
+ wait(false, true)
+ end
+ def thread_tkwait
+ wait(true, true)
+ end
+end
+
+TkAfter = TkTimer
+
+
+class TkRTTimer < TkTimer
+ DEFAULT_OFFSET_LIST_SIZE = 5
+
+ def initialize(*args, &b)
+ super(*args, &b)
+
+ @offset_list = Array.new(DEFAULT_OFFSET_LIST_SIZE){ [0, 0] }
+ @offset_s = 0
+ @offset_u = 0
+ @est_time = nil
+ end
+
+ def start(*args, &b)
+ return nil if @running
+ @est_time = nil
+ @cb_start_time = Time.now
+ super(*args, &b)
+ end
+
+ def cancel
+ super()
+ @est_time = nil
+ @cb_start_time = Time.now
+ self
+ end
+ alias stop cancel
+
+ def continue(wait=nil)
+ fail RuntimeError, "is already running" if @running
+ @cb_start_time = Time.now
+ super(wait)
+ end
+
+ def set_interval(interval)
+ super(interval)
+ @est_time = nil
+ end
+
+ def _offset_ave
+ size = 0
+ d_sec = 0; d_usec = 0
+ @offset_list.each_with_index{|offset, idx|
+ # weight = 1
+ weight = idx + 1
+ size += weight
+ d_sec += offset[0] * weight
+ d_usec += offset[1] * weight
+ }
+ offset_s, mod = d_sec.divmod(size)
+ offset_u = ((mod * 1000000 + d_usec) / size.to_f).round
+ [offset_s, offset_u]
+ end
+ private :_offset_ave
+
+ def set_next_callback(args)
+ if @running == false || @proc_max == 0 || @do_loop == 0
+ Tk_CBTBL.delete(@id) ;# for GC
+ @running = false
+ # @wait_var.value = 0
+ __at_end__
+ return
+ end
+ if @current_pos >= @proc_max
+ if @do_loop < 0 || (@do_loop -= 1) > 0
+ @current_pos = 0
+ else
+ Tk_CBTBL.delete(@id) ;# for GC
+ @running = false
+ # @wait_var.value = 0
+ __at_end__
+ return
+ end
+ end
+
+ @current_args = args
+
+ cmd, *cmd_args = @loop_proc[@current_pos]
+ @current_pos += 1
+ @current_proc = cmd
+
+ @offset_s, @offset_u = _offset_ave
+
+ if TkComm._callback_entry?(@sleep_time)
+ sleep = @sleep_time.call(self)
+ else
+ sleep = @sleep_time
+ end
+
+ if @est_time
+ @est_time = Time.at(@est_time.to_i, @est_time.usec + sleep*1000)
+ else
+ @est_time = Time.at(@cb_start_time.to_i,
+ @cb_start_time.usec + sleep*1000)
+ end
+
+ now = Time.now
+ real_sleep = ((@est_time.to_i - now.to_i + @offset_s)*1000.0 +
+ (@est_time.usec - now.usec + @offset_u)/1000.0).round
+ if real_sleep <= 0
+ real_sleep = 0
+ @offset_s = now.to_i
+ @offset_u = now.usec
+ end
+ @current_sleep = real_sleep
+
+ set_callback(real_sleep, cmd_args)
+ end
+
+ def cb_call
+ if @est_time
+ @offset_list.shift
+
+ @cb_start_time = Time.now
+
+ if @current_sleep == 0
+ @offset_list.push([
+ @offset_s - @cb_start_time.to_i,
+ @offset_u - @cb_start_time.usec
+ ])
+ else
+ @offset_list.push([
+ @offset_s + (@est_time.to_i - @cb_start_time.to_i),
+ @offset_u + (@est_time.usec - @cb_start_time.usec)
+ ])
+ end
+ end
+
+ @cb_cmd.call
+ end
+end
diff --git a/jni/ruby/ext/tk/lib/tk/tk_mac.rb b/jni/ruby/ext/tk/lib/tk/tk_mac.rb
new file mode 100644
index 0000000..77bb234
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tk/tk_mac.rb
@@ -0,0 +1,158 @@
+#
+# tk/tk_mac.rb : Access Mac-Specific functionality on OS X from Tk
+# (supported by Tk8.6 or later)
+#
+# ATTENTION !!
+# This is NOT TESTED. Because I have no test-environment.
+#
+require 'tk'
+
+module Tk
+ module Mac
+ end
+end
+
+module Tk::Mac
+ extend TkCore
+
+ # event handler callbacks
+ def self.def_ShowPreferences(cmd=Proc.new)
+ ip_eval("proc ::tk::mac::ShowPreferences {} { #{install_cmd(cmd)} }")
+ nil
+ end
+
+ def self.def_OpenApplication(cmd=Proc.new)
+ ip_eval("proc ::tk::mac::OpenApplication {} { #{install_cmd(cmd)} }")
+ nil
+ end
+
+ def self.def_ReopenApplication(cmd=Proc.new)
+ ip_eval("proc ::tk::mac::ReopenApplication {} { #{install_cmd(cmd)} }")
+ nil
+ end
+
+ def self.def_OpenDocument(cmd=Proc.new)
+ ip_eval("proc ::tk::mac::OpenDocument {args} { eval #{install_cmd(cmd)} $args }")
+ nil
+ end
+
+ def self.def_PrintDocument(cmd=Proc.new)
+ ip_eval("proc ::tk::mac::PrintDocument {args} { eval #{install_cmd(cmd)} $args }")
+ nil
+ end
+
+ def self.def_Quit(cmd=Proc.new)
+ ip_eval("proc ::tk::mac::Quit {} { #{install_cmd(cmd)} }")
+ nil
+ end
+
+ def self.def_OnHide(cmd=Proc.new)
+ ip_eval("proc ::tk::mac::OnHide {} { #{install_cmd(cmd)} }")
+ nil
+ end
+
+ def self.def_OnShow(cmd=Proc.new)
+ ip_eval("proc ::tk::mac::OnShow {} { #{install_cmd(cmd)} }")
+ nil
+ end
+
+ def self.def_ShowHelp(cmd=Proc.new)
+ ip_eval("proc ::tk::mac::ShowHelp {} { #{install_cmd(cmd)} }")
+ nil
+ end
+
+
+ # additional dialogs
+ def self.standardAboutPanel
+ tk_call('::tk::mac::standardAboutPanel')
+ nil
+ end
+
+
+ # system configuration
+ def self.useCompatibilityMetrics(mode)
+ tk_call('::tk::mac::useCompatibilityMetrics', mode)
+ nil
+ end
+
+ def self.CGAntialiasLimit(limit)
+ tk_call('::tk::mac::CGAntialiasLimit', limit)
+ nil
+ end
+
+ def self.antialiasedtext(num)
+ tk_call('::tk::mac::antialiasedtext', num)
+ nil
+ end
+
+ def self.useThemedToplevel(mode)
+ tk_call('::tk::mac::useThemedToplevel', mode)
+ nil
+ end
+
+end
+
+class Tk::Mac::IconBitmap < TkImage
+ TkCommandNames = ['::tk::mac::iconBitmap'].freeze
+
+ def self.new(width, height, keys)
+ if keys.kind_of?(Hash)
+ name = nil
+ if keys.key?(:imagename)
+ name = keys[:imagename]
+ elsif keys.key?('imagename')
+ name = keys['imagename']
+ end
+ if name
+ if name.kind_of?(TkImage)
+ obj = name
+ else
+ name = _get_eval_string(name)
+ obj = nil
+ Tk_IMGTBL.mutex.synchronize{
+ obj = Tk_IMGTBL[name]
+ }
+ end
+ if obj
+ if !(keys[:without_creating] || keys['without_creating'])
+ keys = _symbolkey2str(keys)
+ keys.delete('imagename')
+ keys.delete('without_creating')
+ obj.instance_eval{
+ tk_call_without_enc('::tk::mac::iconBitmap',
+ @path, width, height, *hash_kv(keys, true))
+ }
+ end
+ return obj
+ end
+ end
+ end
+ (obj = self.allocate).instance_eval{
+ Tk_IMGTBL.mutex.synchronize{
+ initialize(width, height, keys)
+ Tk_IMGTBL[@path] = self
+ }
+ }
+ obj
+ end
+
+ def initialize(width, height, keys)
+ @path = nil
+ without_creating = false
+ if keys.kind_of?(Hash)
+ keys = _symbolkey2str(keys)
+ @path = keys.delete('imagename')
+ without_creating = keys.delete('without_creating')
+ end
+ unless @path
+ Tk_Image_ID.mutex.synchronize{
+ @path = Tk_Image_ID.join(TkCore::INTERP._ip_id_)
+ Tk_Image_ID[1].succ!
+ }
+ end
+ unless without_creating
+ tk_call_without_enc('::tk::mac::iconBitmap',
+ @path, width, height, *hash_kv(keys, true))
+ end
+ end
+end
diff --git a/jni/ruby/ext/tk/lib/tk/toplevel.rb b/jni/ruby/ext/tk/lib/tk/toplevel.rb
new file mode 100644
index 0000000..30ef009
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tk/toplevel.rb
@@ -0,0 +1,264 @@
+#
+# tk/toplevel.rb : treat toplevel widget
+#
+require 'tk'
+require 'tk/wm'
+require 'tk/menuspec'
+
+class Tk::Toplevel<TkWindow
+ include Wm
+ include TkMenuSpec
+
+ TkCommandNames = ['toplevel'.freeze].freeze
+ WidgetClassName = 'Toplevel'.freeze
+ WidgetClassNames[WidgetClassName] ||= self
+
+################# old version
+# def initialize(parent=nil, screen=nil, classname=nil, keys=nil)
+# if screen.kind_of? Hash
+# keys = screen.dup
+# else
+# @screen = screen
+# end
+# @classname = classname
+# if keys.kind_of? Hash
+# keys = keys.dup
+# @classname = keys.delete('classname') if keys.key?('classname')
+# @colormap = keys.delete('colormap') if keys.key?('colormap')
+# @container = keys.delete('container') if keys.key?('container')
+# @screen = keys.delete('screen') if keys.key?('screen')
+# @use = keys.delete('use') if keys.key?('use')
+# @visual = keys.delete('visual') if keys.key?('visual')
+# end
+# super(parent, keys)
+# end
+#
+# def create_self
+# s = []
+# s << "-class" << @classname if @classname
+# s << "-colormap" << @colormap if @colormap
+# s << "-container" << @container if @container
+# s << "-screen" << @screen if @screen
+# s << "-use" << @use if @use
+# s << "-visual" << @visual if @visual
+# tk_call 'toplevel', @path, *s
+# end
+#################
+
+ def __boolval_optkeys
+ super() << 'container'
+ end
+ private :__boolval_optkeys
+
+ def __strval_optkeys
+ super() << 'screen'
+ end
+ private :__strval_optkeys
+
+ def __val2ruby_optkeys # { key=>proc, ... }
+ super().update('menu'=>proc{|v| window(v)})
+ end
+ private :__val2ruby_optkeys
+
+ def __methodcall_optkeys # { key=>method, ... }
+ TOPLEVEL_METHODCALL_OPTKEYS
+ end
+ private :__methodcall_optkeys
+
+ def _wm_command_option_chk(keys)
+ keys = {} unless keys
+ new_keys = {}
+ wm_cmds = {}
+
+ conf_methods = _symbolkey2str(__methodcall_optkeys())
+
+ keys.each{|k,v| # k is a String
+ if conf_methods.key?(k)
+ wm_cmds[conf_methods[k]] = v
+ elsif Wm.method_defined?(k)
+ case k
+ when 'screen','class','colormap','container','use','visual'
+ new_keys[k] = v
+ else
+ case self.method(k).arity
+ when -1,1
+ wm_cmds[k] = v
+ else
+ new_keys[k] = v
+ end
+ end
+ else
+ new_keys[k] = v
+ end
+ }
+ [new_keys, wm_cmds]
+ end
+ private :_wm_command_option_chk
+
+ def initialize(parent=nil, screen=nil, classname=nil, keys=nil)
+ my_class_name = nil
+ if self.class < WidgetClassNames[WidgetClassName]
+ my_class_name = self.class.name
+ my_class_name = nil if my_class_name == ''
+ end
+ if parent.kind_of? Hash
+ keys = _symbolkey2str(parent)
+ if keys.key?('classname')
+ keys['class'] = keys.delete('classname')
+ end
+ @classname = keys['class']
+ @colormap = keys['colormap']
+ @container = keys['container']
+ @screen = keys['screen']
+ @use = keys['use']
+ @visual = keys['visual']
+ if !@classname && my_class_name
+ keys['class'] = @classname = my_class_name
+ end
+ if @classname.kind_of? TkBindTag
+ @db_class = @classname
+ keys['class'] = @classname = @classname.id
+ elsif @classname
+ @db_class = TkDatabaseClass.new(@classname)
+ keys['class'] = @classname
+ else
+ @db_class = self.class
+ @classname = @db_class::WidgetClassName
+ end
+ keys, cmds = _wm_command_option_chk(keys)
+ super(keys)
+ cmds.each{|k,v|
+ if v.kind_of? Array
+ self.__send__(k,*v)
+ else
+ self.__send__(k,v)
+ end
+ }
+ return
+ end
+
+ if screen.kind_of? Hash
+ keys = screen
+ else
+ @screen = screen
+ if classname.kind_of? Hash
+ keys = classname
+ else
+ @classname = classname
+ end
+ end
+ if keys.kind_of? Hash
+ keys = _symbolkey2str(keys)
+ if keys.key?('classname')
+ keys['class'] = keys.delete('classname')
+ end
+ @classname = keys['class'] unless @classname
+ @colormap = keys['colormap']
+ @container = keys['container']
+ @screen = keys['screen'] unless @screen
+ @use = keys['use']
+ @visual = keys['visual']
+ else
+ keys = {}
+ end
+ if !@classname && my_class_name
+ keys['class'] = @classname = my_class_name
+ end
+ if @classname.kind_of? TkBindTag
+ @db_class = @classname
+ keys['class'] = @classname = @classname.id
+ elsif @classname
+ @db_class = TkDatabaseClass.new(@classname)
+ keys['class'] = @classname
+ else
+ @db_class = self.class
+ @classname = @db_class::WidgetClassName
+ end
+ keys, cmds = _wm_command_option_chk(keys)
+ super(parent, keys)
+ cmds.each{|k,v|
+ if v.kind_of? Array
+ self.send(k,*v)
+ else
+ self.send(k,v)
+ end
+ }
+ end
+
+ #def create_self(keys)
+ # if keys and keys != None
+ # tk_call_without_enc('toplevel', @path, *hash_kv(keys, true))
+ # else
+ # tk_call_without_enc('toplevel', @path)
+ # end
+ #end
+ #private :create_self
+
+ def specific_class
+ @classname
+ end
+
+ def add_menu(menu_info, tearoff=false, opts=nil)
+ # See tk/menuspec.rb for menu_info.
+ # opts is a hash of default configs for all of cascade menus.
+ # Configs of menu_info can override it.
+ if tearoff.kind_of?(Hash)
+ opts = tearoff
+ tearoff = false
+ end
+ _create_menubutton(self, menu_info, tearoff, opts)
+ end
+
+ def add_menubar(menu_spec, tearoff=false, opts=nil)
+ # See tk/menuspec.rb for menu_spec.
+ # opts is a hash of default configs for all of cascade menus.
+ # Configs of menu_spec can override it.
+ menu_spec.each{|info| add_menu(info, tearoff, opts)}
+ self.menu
+ end
+
+ def self.database_class
+ if self == WidgetClassNames[WidgetClassName] || self.name == ''
+ self
+ else
+ TkDatabaseClass.new(self.name)
+ end
+ end
+ def self.database_classname
+ self.database_class.name
+ end
+
+ def self.bind(*args, &b)
+ if self == WidgetClassNames[WidgetClassName] || self.name == ''
+ super(*args, &b)
+ else
+ TkDatabaseClass.new(self.name).bind(*args, &b)
+ end
+ end
+ def self.bind_append(*args, &b)
+ if self == WidgetClassNames[WidgetClassName] || self.name == ''
+ super(*args, &b)
+ else
+ TkDatabaseClass.new(self.name).bind_append(*args, &b)
+ end
+ end
+ def self.bind_remove(*args)
+ if self == WidgetClassNames[WidgetClassName] || self.name == ''
+ super(*args)
+ else
+ TkDatabaseClass.new(self.name).bind_remove(*args)
+ end
+ end
+ def self.bindinfo(*args)
+ if self == WidgetClassNames[WidgetClassName] || self.name == ''
+ super(*args)
+ else
+ TkDatabaseClass.new(self.name).bindinfo(*args)
+ end
+ end
+end
+
+#TkToplevel = Tk::Toplevel unless Object.const_defined? :TkToplevel
+#Tk.__set_toplevel_aliases__(:Tk, Tk::Toplevel, :TkToplevel)
+Tk.__set_loaded_toplevel_aliases__('tk/toplevel.rb', :Tk, Tk::Toplevel,
+ :TkToplevel)
diff --git a/jni/ruby/ext/tk/lib/tk/ttk_selector.rb b/jni/ruby/ext/tk/lib/tk/ttk_selector.rb
new file mode 100644
index 0000000..cc9e992
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tk/ttk_selector.rb
@@ -0,0 +1,98 @@
+#
+# ttk_selector
+#
+######################################
+# toplevel classes/modules
+module Tk
+ @TOPLEVEL_ALIAS_TABLE[:Ttk] = {
+ :TkButton => 'tkextlib/tile/tbutton',
+
+ :TkCheckbutton => 'tkextlib/tile/tcheckbutton',
+ :TkCheckButton => 'tkextlib/tile/tcheckbutton',
+
+ # :TkDialog => 'tkextlib/tile/dialog',
+
+ :TkEntry => 'tkextlib/tile/tentry',
+
+ :TkCombobox => 'tkextlib/tile/tcombobox',
+
+ :TkFrame => 'tkextlib/tile/tframe',
+
+ :TkLabel => 'tkextlib/tile/tlabel',
+
+ :TkLabelframe => 'tkextlib/tile/tlabelframe',
+ :TkLabelFrame => 'tkextlib/tile/tlabelframe',
+
+ :TkMenubutton => 'tkextlib/tile/tmenubutton',
+ :TkMenuButton => 'tkextlib/tile/tmenubutton',
+
+ :TkNotebook => 'tkextlib/tile/tnotebook',
+
+ # :TkPaned => 'tkextlib/tile/tpaned',
+ :TkPanedwindow => 'tkextlib/tile/tpaned',
+ :TkPanedWindow => 'tkextlib/tile/tpaned',
+
+ :TkProgressbar => 'tkextlib/tile/tprogressbar',
+
+ :TkRadiobutton => 'tkextlib/tile/tradiobutton',
+ :TkRadioButton => 'tkextlib/tile/tradiobutton',
+
+ :TkScale => 'tkextlib/tile/tscale',
+ # :TkProgress => 'tkextlib/tile/tscale',
+
+ :TkScrollbar => 'tkextlib/tile/tscrollbar',
+ :TkXScrollbar => 'tkextlib/tile/tscrollbar',
+ :TkYScrollbar => 'tkextlib/tile/tscrollbar',
+
+ :TkSeparator => 'tkextlib/tile/tseparator',
+
+ :TkSizeGrip => 'tkextlib/tile/sizegrip',
+ :TkSizegrip => 'tkextlib/tile/sizegrip',
+
+ # :TkSquare => 'tkextlib/tile/tsquare',
+
+ :TkTreeview => 'tkextlib/tile/treeview',
+ }
+
+ # @TOPLEVEL_ALIAS_TABLE[:Tile] = @TOPLEVEL_ALIAS_TABLE[:Ttk]
+ Tk.__create_widget_set__(:Tile, :Ttk)
+
+ ############################################
+ # depend on the version of Tcl/Tk
+ major, minor, type, patchlevel = TclTkLib.get_version
+
+ # ttk::spinbox is supported on Tcl/Tk8.6b1 or later
+ if ([major,minor,type,patchlevel] <=>
+ [8,6,TclTkLib::RELEASE_TYPE::BETA,1]) >= 0
+ @TOPLEVEL_ALIAS_TABLE[:Ttk].update(
+ :TkSpinbox => 'tkextlib/tile/tspinbox'
+ )
+ end
+
+ ################################################
+ # register some Ttk widgets as default
+ # (Ttk is a standard library on Tcl/Tk8.5+)
+ @TOPLEVEL_ALIAS_TABLE[:Ttk].each{|sym, file|
+ #unless Tk::TOPLEVEL_ALIASES.autoload?(sym) || Tk::TOPLEVEL_ALIASES.const_defined?(sym)
+ # @TOPLEVEL_ALIAS_OWNER[sym] = :Ttk
+ # Tk::TOPLEVEL_ALIASES.autoload(sym, file)
+ #end
+ Tk.__regist_toplevel_aliases__(:Ttk, file, sym)
+ }
+
+ ################################################
+
+ # @TOPLEVEL_ALIAS_SETUP_PROC[:Tile] =
+ # @TOPLEVEL_ALIAS_SETUP_PROC[:Ttk] = proc{|mod|
+ # unless Tk.autoload?(:Tile) || Tk.const_defined?(:Tile)
+ # Object.autoload :Ttk, 'tkextlib/tile'
+ # Tk.autoload :Tile, 'tkextlib/tile'
+ # end
+ # }
+ Tk.__toplevel_alias_setup_proc__(:Ttk, :Tile){|mod|
+ unless Tk.autoload?(:Tile) || Tk.const_defined?(:Tile)
+ Object.autoload :Ttk, 'tkextlib/tile'
+ Tk.autoload :Tile, 'tkextlib/tile'
+ end
+ }
+end
diff --git a/jni/ruby/ext/tk/lib/tk/txtwin_abst.rb b/jni/ruby/ext/tk/lib/tk/txtwin_abst.rb
new file mode 100644
index 0000000..540f806
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tk/txtwin_abst.rb
@@ -0,0 +1,39 @@
+#
+# tk/txtwin_abst.rb : TkTextWin abstruct class
+#
+require 'tk'
+
+class TkTextWin<TkWindow
+ TkCommandNames = [].freeze
+ #def create_self
+ # fail RuntimeError, "TkTextWin is an abstract class"
+ #end
+ #private :create_self
+
+ def bbox(index)
+ list(tk_send_without_enc('bbox', index))
+ end
+ def delete(first, last=None)
+ tk_send_without_enc('delete', first, last)
+ self
+ end
+ def get(*index)
+ _fromUTF8(tk_send_without_enc('get', *index))
+ end
+ def insert(index, *args)
+ tk_send('insert', index, *args)
+ self
+ end
+ def scan_mark(x, y)
+ tk_send_without_enc('scan', 'mark', x, y)
+ self
+ end
+ def scan_dragto(x, y)
+ tk_send_without_enc('scan', 'dragto', x, y)
+ self
+ end
+ def see(index)
+ tk_send_without_enc('see', index)
+ self
+ end
+end
diff --git a/jni/ruby/ext/tk/lib/tk/validation.rb b/jni/ruby/ext/tk/lib/tk/validation.rb
new file mode 100644
index 0000000..0ebd5c5
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tk/validation.rb
@@ -0,0 +1,397 @@
+#
+# tk/validation.rb - validation support module for entry, spinbox, and so on
+#
+require 'tk'
+
+module Tk
+ module ValidateConfigure
+ def self.__def_validcmd(scope, klass, keys=nil)
+ keys = klass._config_keys unless keys
+ keys.each{|key|
+ eval("def #{key}(*args, &b)
+ __validcmd_call(#{klass.name}, '#{key}', *args, &b)
+ end", scope)
+ }
+ end
+
+ def __validcmd_call(klass, key, *args, &b)
+ return cget(key) if args.empty? && !b
+
+ cmd = (b)? proc(&b) : args.shift
+
+ if cmd.kind_of?(klass)
+ configure(key, cmd)
+ elsif !args.empty?
+ configure(key, [cmd, args])
+ else
+ configure(key, cmd)
+ end
+ end
+
+ def __validation_class_list
+ # maybe need to override
+ []
+ end
+
+ def __get_validate_key2class
+ k2c = {}
+ __validation_class_list.each{|klass|
+ klass._config_keys.each{|key|
+ k2c[key.to_s] = klass
+ }
+ }
+ k2c
+ end
+
+ def __conv_vcmd_on_hash_kv(keys)
+ key2class = __get_validate_key2class
+
+ keys = _symbolkey2str(keys)
+ key2class.each{|key, klass|
+ if keys[key].kind_of?(Array)
+ cmd, *args = keys[key]
+ #keys[key] = klass.new(cmd, args.join(' '))
+ keys[key] = klass.new(cmd, *args)
+ # elsif keys[key].kind_of?(Proc) || keys[key].kind_of?(Method)
+ elsif TkComm._callback_entry?(keys[key])
+ keys[key] = klass.new(keys[key])
+ end
+ }
+ keys
+ end
+
+ def create_self(keys)
+ super(__conv_vcmd_on_hash_kv(keys))
+ end
+ private :create_self
+
+ def configure(slot, value=TkComm::None)
+ if slot.kind_of?(Hash)
+ super(__conv_vcmd_on_hash_kv(slot))
+ else
+ super(__conv_vcmd_on_hash_kv(slot=>value))
+ end
+ self
+ end
+=begin
+ def configure(slot, value=TkComm::None)
+ key2class = __get_validate_key2class
+
+ if slot.kind_of?(Hash)
+ slot = _symbolkey2str(slot)
+ key2class.each{|key, klass|
+ if slot[key].kind_of?(Array)
+ cmd, *args = slot[key]
+ slot[key] = klass.new(cmd, args.join(' '))
+ elsif slot[key].kind_of?(Proc) || slot[key].kind_of?(Method)
+ slot[key] = klass.new(slot[key])
+ end
+ }
+ super(slot)
+
+ else
+ slot = slot.to_s
+ if (klass = key2class[slot])
+ if value.kind_of?(Array)
+ cmd, *args = value
+ value = klass.new(cmd, args.join(' '))
+ elsif value.kind_of?(Proc) || value.kind_of?(Method)
+ value = klass.new(value)
+ end
+ end
+ super(slot, value)
+ end
+
+ self
+ end
+=end
+ end
+
+ module ItemValidateConfigure
+ def self.__def_validcmd(scope, klass, keys=nil)
+ keys = klass._config_keys unless keys
+ keys.each{|key|
+ eval("def item_#{key}(id, *args, &b)
+ __item_validcmd_call(#{klass.name}, '#{key}', id, *args, &b)
+ end", scope)
+ }
+ end
+
+ def __item_validcmd_call(tagOrId, klass, key, *args, &b)
+ return itemcget(tagid(tagOrId), key) if args.empty? && !b
+
+ cmd = (b)? proc(&b) : args.shift
+
+ if cmd.kind_of?(klass)
+ itemconfigure(tagid(tagOrId), key, cmd)
+ elsif !args.empty?
+ itemconfigure(tagid(tagOrId), key, [cmd, args])
+ else
+ itemconfigure(tagid(tagOrId), key, cmd)
+ end
+ end
+
+ def __item_validation_class_list(id)
+ # maybe need to override
+ []
+ end
+
+ def __get_item_validate_key2class(id)
+ k2c = {}
+ __item_validation_class_list(id).each{|klass|
+ klass._config_keys.each{|key|
+ k2c[key.to_s] = klass
+ }
+ }
+ end
+
+ def __conv_item_vcmd_on_hash_kv(keys)
+ key2class = __get_item_validate_key2class(tagid(tagOrId))
+
+ keys = _symbolkey2str(keys)
+ key2class.each{|key, klass|
+ if keys[key].kind_of?(Array)
+ cmd, *args = keys[key]
+ #keys[key] = klass.new(cmd, args.join(' '))
+ keys[key] = klass.new(cmd, *args)
+ # elsif keys[key].kind_of?(Proc) || keys[key].kind_of?(Method)
+ elsif TkComm._callback_entry?(keys[key])
+ keys[key] = klass.new(keys[key])
+ end
+ }
+ keys
+ end
+
+ def itemconfigure(tagOrId, slot, value=TkComm::None)
+ if slot.kind_of?(Hash)
+ super(__conv_item_vcmd_on_hash_kv(slot))
+ else
+ super(__conv_item_vcmd_on_hash_kv(slot=>value))
+ end
+ self
+ end
+=begin
+ def itemconfigure(tagOrId, slot, value=TkComm::None)
+ key2class = __get_item_validate_key2class(tagid(tagOrId))
+
+ if slot.kind_of?(Hash)
+ slot = _symbolkey2str(slot)
+ key2class.each{|key, klass|
+ if slot[key].kind_of?(Array)
+ cmd, *args = slot[key]
+ slot[key] = klass.new(cmd, args.join(' '))
+ elsif slot[key].kind_of?(Proc) || slot[key].kind_of?(Method)
+ slot[key] = klass.new(slot[key])
+ end
+ }
+ super(slot)
+
+ else
+ slot = slot.to_s
+ if (klass = key2class[slot])
+ if value.kind_of?(Array)
+ cmd, *args = value
+ value = klass.new(cmd, args.join(' '))
+ elsif value.kind_of?(Proc) || value.kind_of?(Method)
+ value = klass.new(value)
+ end
+ end
+ super(slot, value)
+ end
+
+ self
+ end
+=end
+ end
+end
+
+class TkValidateCommand
+ include TkComm
+ extend TkComm
+
+ class ValidateArgs < TkUtil::CallbackSubst
+ KEY_TBL = [
+ [ ?d, ?n, :action ],
+ [ ?i, ?x, :index ],
+ [ ?s, ?e, :current ],
+ [ ?v, ?s, :type ],
+ [ ?P, ?e, :value ],
+ [ ?S, ?e, :string ],
+ [ ?V, ?s, :triggered ],
+ [ ?W, ?w, :widget ],
+ nil
+ ]
+
+ PROC_TBL = [
+ [ ?n, TkComm.method(:number) ],
+ [ ?s, TkComm.method(:string) ],
+ [ ?w, TkComm.method(:window) ],
+
+ [ ?e, proc{|val|
+ #enc = Tk.encoding
+ enc = ((Tk.encoding)? Tk.encoding : Tk.encoding_system)
+ if enc
+ Tk.fromUTF8(TkComm::string(val), enc)
+ else
+ TkComm::string(val)
+ end
+ }
+ ],
+
+ [ ?x, proc{|val|
+ idx = TkComm::number(val)
+ if idx < 0
+ nil
+ else
+ idx
+ end
+ }
+ ],
+
+ nil
+ ]
+
+=begin
+ # for Ruby m17n :: ?x --> String --> char-code ( getbyte(0) )
+ KEY_TBL.map!{|inf|
+ if inf.kind_of?(Array)
+ inf[0] = inf[0].getbyte(0) if inf[0].kind_of?(String)
+ inf[1] = inf[1].getbyte(0) if inf[1].kind_of?(String)
+ end
+ inf
+ }
+
+ PROC_TBL.map!{|inf|
+ if inf.kind_of?(Array)
+ inf[0] = inf[0].getbyte(0) if inf[0].kind_of?(String)
+ end
+ inf
+ }
+=end
+
+ _setup_subst_table(KEY_TBL, PROC_TBL);
+
+ #
+ # NOTE: The order of parameters which passed to callback procedure is
+ # <extra_arg>, <extra_arg>, ... , <subst_arg>, <subst_arg>, ...
+ #
+
+ #def self._get_extra_args_tbl
+ # # return an array of convert procs
+ # []
+ #end
+
+ def self.ret_val(val)
+ (val)? '1': '0'
+ end
+ end
+
+ ###############################################
+
+ def self._config_keys
+ # array of config-option key (string or symbol)
+ ['vcmd', 'validatecommand', 'invcmd', 'invalidcommand']
+ end
+
+ def _initialize_for_cb_class(klass, cmd = Proc.new, *args)
+ extra_args_tbl = klass._get_extra_args_tbl
+
+ if args.compact.size > 0
+ args.map!{|arg| klass._sym2subst(arg)}
+ args = args.join(' ')
+ keys = klass._get_subst_key(args)
+ if cmd.kind_of?(String)
+ id = cmd
+ elsif cmd.kind_of?(TkCallbackEntry)
+ @id = install_cmd(cmd)
+ else
+ @id = install_cmd(proc{|*arg|
+ ex_args = []
+ extra_args_tbl.reverse_each{|conv| ex_args << conv.call(arg.pop)}
+ klass.ret_val(cmd.call(
+ *(ex_args.concat(klass.scan_args(keys, arg)))
+ ))
+ }) + ' ' + args
+ end
+ else
+ keys, args = klass._get_all_subst_keys
+ if cmd.kind_of?(String)
+ id = cmd
+ elsif cmd.kind_of?(TkCallbackEntry)
+ @id = install_cmd(cmd)
+ else
+ @id = install_cmd(proc{|*arg|
+ ex_args = []
+ extra_args_tbl.reverse_each{|conv| ex_args << conv.call(arg.pop)}
+ klass.ret_val(cmd.call(
+ *(ex_args << klass.new(*klass.scan_args(keys, arg)))
+ ))
+ }) + ' ' + args
+ end
+ end
+ end
+
+ def initialize(cmd = Proc.new, *args)
+ _initialize_for_cb_class(self.class::ValidateArgs, cmd, *args)
+ end
+
+ def to_eval
+ @id
+ end
+end
+
+module TkValidation
+ include Tk::ValidateConfigure
+
+ class ValidateCmd < TkValidateCommand
+ module Action
+ Insert = 1
+ Delete = 0
+ Others = -1
+ Focus = -1
+ Forced = -1
+ Textvariable = -1
+ TextVariable = -1
+ end
+ end
+
+ #####################################
+
+ def __validation_class_list
+ super() << ValidateCmd
+ end
+
+ Tk::ValidateConfigure.__def_validcmd(binding, ValidateCmd)
+
+=begin
+ def validatecommand(cmd = Proc.new, args = nil)
+ if cmd.kind_of?(ValidateCmd)
+ configure('validatecommand', cmd)
+ elsif args
+ configure('validatecommand', [cmd, args])
+ else
+ configure('validatecommand', cmd)
+ end
+ end
+=end
+# def validatecommand(*args, &b)
+# __validcmd_call(ValidateCmd, 'validatecommand', *args, &b)
+# end
+# alias vcmd validatecommand
+
+=begin
+ def invalidcommand(cmd = Proc.new, args = nil)
+ if cmd.kind_of?(ValidateCmd)
+ configure('invalidcommand', cmd)
+ elsif args
+ configure('invalidcommand', [cmd, args])
+ else
+ configure('invalidcommand', cmd)
+ end
+ end
+=end
+# def invalidcommand(*args, &b)
+# __validcmd_call(ValidateCmd, 'invalidcommand', *args, &b)
+# end
+# alias invcmd invalidcommand
+end
diff --git a/jni/ruby/ext/tk/lib/tk/variable.rb b/jni/ruby/ext/tk/lib/tk/variable.rb
new file mode 100644
index 0000000..0487b03
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tk/variable.rb
@@ -0,0 +1,1799 @@
+#
+# tk/variable.rb : treat Tk variable object
+#
+require 'tk'
+
+class TkVariable
+ include Tk
+ extend TkCore
+
+ include Comparable
+
+ #TkCommandNames = ['tkwait'.freeze].freeze
+ TkCommandNames = ['vwait'.freeze].freeze
+
+ #TkVar_CB_TBL = {}
+ #TkVar_ID_TBL = {}
+ TkVar_CB_TBL = TkCore::INTERP.create_table
+ TkVar_ID_TBL = TkCore::INTERP.create_table
+ (Tk_VARIABLE_ID = ["v".freeze, TkUtil.untrust("00000")]).instance_eval{
+ @mutex = Mutex.new
+ def mutex; @mutex; end
+ freeze
+ }
+ TkCore::INTERP.init_ip_env{
+ TkVar_CB_TBL.mutex.synchronize{ TkVar_CB_TBL.clear }
+ TkVar_ID_TBL.mutex.synchronize{ TkVar_ID_TBL.clear }
+ }
+
+ major, minor, type, patchlevel = TclTkLib.get_version
+ USE_OLD_TRACE_OPTION_STYLE = (major < 8) || (major == 8 && minor < 4)
+
+ #TkCore::INTERP.add_tk_procs('rb_var', 'args',
+ # "ruby [format \"TkVariable.callback %%Q!%s!\" $args]")
+ TkCore::INTERP.add_tk_procs('rb_var', 'args', <<-'EOL')
+ if {[set st [catch {eval {ruby_cmd TkVariable callback} $args} ret]] != 0} {
+ set idx [string first "\n\n" $ret]
+ if {$idx > 0} {
+ global errorInfo
+ set tcl_backtrace $errorInfo
+ set errorInfo [string range $ret [expr $idx + 2] \
+ [string length $ret]]
+ append errorInfo "\n" $tcl_backtrace
+ bgerror [string range $ret 0 [expr $idx - 1]]
+ } else {
+ bgerror $ret
+ }
+ return ""
+ #return -code $st $ret
+ } else {
+ return $ret
+ }
+ EOL
+
+ #def TkVariable.callback(args)
+ def TkVariable.callback(id, name1, name2, op)
+ #name1,name2,op = tk_split_list(args)
+ #name1,name2,op = tk_split_simplelist(args)
+ if cb_obj = TkVar_CB_TBL[id]
+ #_get_eval_string(TkVar_CB_TBL[name1].trace_callback(name2,op))
+ begin
+ _get_eval_string(cb_obj.trace_callback(name2, op))
+ rescue SystemExit
+ exit(0)
+ rescue Interrupt
+ exit!(1)
+ rescue Exception => e
+ begin
+ msg = _toUTF8(e.class.inspect) + ': ' +
+ _toUTF8(e.message) + "\n" +
+ "\n---< backtrace of Ruby side >-----\n" +
+ _toUTF8(e.backtrace.join("\n")) +
+ "\n---< backtrace of Tk side >-------"
+ if TkCore::WITH_ENCODING
+ msg.force_encoding('utf-8')
+ else
+ msg.instance_variable_set(:@encoding, 'utf-8')
+ end
+ rescue Exception
+ msg = e.class.inspect + ': ' + e.message + "\n" +
+ "\n---< backtrace of Ruby side >-----\n" +
+ e.backtrace.join("\n") +
+ "\n---< backtrace of Tk side >-------"
+ end
+ fail(e, msg)
+ end
+=begin
+ begin
+ raise 'check backtrace'
+ rescue
+ # ignore backtrace before 'callback'
+ pos = -($!.backtrace.size)
+ end
+ begin
+ _get_eval_string(TkVar_CB_TBL[name1].trace_callback(name2,op))
+ rescue
+ trace = $!.backtrace
+ raise $!, "\n#{trace[0]}: #{$!.message} (#{$!.class})\n" +
+ "\tfrom #{trace[1..pos].join("\n\tfrom ")}"
+ end
+=end
+ else
+ ''
+ end
+ end
+
+ def self.new_hash(val = {})
+ if val.kind_of?(Hash)
+ self.new(val)
+ else
+ fail ArgumentError, 'Hash is expected'
+ end
+ end
+
+ #
+ # default_value is available only when the variable is an assoc array.
+ #
+ def default_value(val=nil, &b)
+ if b
+ @def_default = :proc
+ @default_val = proc(&b)
+ else
+ @def_default = :val
+ @default_val = val
+ end
+ self
+ end
+ def set_default_value(val)
+ @def_default = :val
+ @default_val = val
+ self
+ end
+ alias default_value= set_default_value
+ def default_proc(cmd = Proc.new)
+ @def_default = :proc
+ @default_val = cmd
+ self
+ end
+
+ def undef_default
+ @default_val = nil
+ @def_default = false
+ self
+ end
+
+ def default_value_type
+ @type
+ end
+ def default_element_value_type(idxs)
+ if idxs.kind_of?(Array)
+ index = idxs.collect{|idx| _get_eval_string(idx, true)}.join(',')
+ else
+ index = _get_eval_string(idxs, true)
+ end
+ @element_type[index]
+ end
+
+ def _set_default_value_type_core(type, idxs)
+ if type.kind_of?(Class)
+ if type == NilClass
+ type = nil
+ elsif type == Numeric
+ type = :numeric
+ elsif type == TrueClass || type == FalseClass
+ type = :bool
+ elsif type == String
+ type = :string
+ elsif type == Symbol
+ type = :symbol
+ elsif type == Array
+ type = :list
+ elsif type <= TkVariable
+ type = :variable
+ elsif type <= TkWindow
+ type = :window
+ elsif TkComm._callback_entry_class?(type)
+ type = :procedure
+ else
+ type = nil
+ end
+ else
+ case(type)
+ when nil
+ type = nil
+ when :numeric, 'numeric'
+ type = :numeric
+ when true, false, :bool, 'bool'
+ type = :bool
+ when :string, 'string'
+ type = :string
+ when :symbol, 'symbol'
+ type = :symbol
+ when :list, 'list'
+ type = :list
+ when :numlist, 'numlist'
+ type = :numlist
+ when :variable, 'variable'
+ type = :variable
+ when :window, 'window'
+ type = :window
+ when :procedure, 'procedure'
+ type = :procedure
+ else
+ return _set_default_value_type_core(type.class, idxs)
+ end
+ end
+ if idxs
+ if idxs.kind_of?(Array)
+ index = idxs.collect{|idx| _get_eval_string(idx, true)}.join(',')
+ else
+ index = _get_eval_string(idxs, true)
+ end
+ @element_type[index] = type
+ else
+ @type = type
+ end
+ type
+ end
+ private :_set_default_value_type_core
+
+ def set_default_value_type(type)
+ _set_default_value_type_core(type, nil)
+ self
+ end
+ alias default_value_type= set_default_value_type
+
+ def set_default_element_value_type(idxs, type)
+ _set_default_value_type_core(type, idxs)
+ self
+ end
+
+ def _to_default_type(val, idxs = nil)
+ if idxs
+ if idxs.kind_of?(Array)
+ index = idxs.collect{|idx| _get_eval_string(idx, true)}.join(',')
+ else
+ index = _get_eval_string(idxs, true)
+ end
+ type = @element_type[index]
+ else
+ type = @type
+ end
+ return val unless type
+ if val.kind_of?(Hash)
+ val.keys.each{|k| val[k] = _to_default_type(val[k], idxs) }
+ val
+ else
+ begin
+ case(type)
+ when :numeric
+ number(val)
+ when :bool
+ TkComm.bool(val)
+ when :string
+ val
+ when :symbol
+ val.intern
+ when :list
+ tk_split_simplelist(val)
+ when :numlist
+ tk_split_simplelist(val).collect!{|v| number(v)}
+ when :variable
+ TkVarAccess.new(val)
+ when :window
+ TkComm.window(val)
+ when :procedure
+ TkComm.procedure(val)
+ else
+ val
+ end
+ rescue
+ val
+ end
+ end
+ end
+ private :_to_default_type
+
+ def _to_default_element_type(idxs, val)
+ _to_default_type(val, idxs)
+ end
+ private :_to_default_element_type
+
+ def initialize(val="", type=nil)
+ # @id = Tk_VARIABLE_ID.join('')
+ begin
+ Tk_VARIABLE_ID.mutex.synchronize{
+ @id = Tk_VARIABLE_ID.join(TkCore::INTERP._ip_id_)
+ Tk_VARIABLE_ID[1].succ!
+ }
+ end until INTERP._invoke_without_enc('info', 'globals', @id).empty?
+
+ TkVar_ID_TBL.mutex.synchronize{
+ TkVar_ID_TBL[@id] = self
+ }
+
+ @var = @id
+ @elem = nil
+
+ @def_default = false
+ @default_val = nil
+
+ @trace_var = nil
+ @trace_elem = nil
+ @trace_opts = nil
+
+ @type = nil
+ var = self
+ @element_type = Hash.new{|k,v| var.default_value_type }
+
+ self.default_value_type = type
+
+ # teach Tk-ip that @id is global var
+ INTERP._invoke_without_enc('global', @id)
+ #INTERP._invoke('global', @id)
+
+ # create and init
+ if val.kind_of?(Hash)
+ # assoc-array variable
+ self[''] = 0
+ self.clear
+ end
+ self.value = val
+
+=begin
+ if val == []
+ # INTERP._eval(format('global %s; set %s(0) 0; unset %s(0)',
+ # @id, @id, @id))
+ elsif val.kind_of?(Array)
+ a = []
+ # val.each_with_index{|e,i| a.push(i); a.push(array2tk_list(e))}
+ # s = '"' + a.join(" ").gsub(/[\[\]$"]/, '\\\\\&') + '"'
+ val.each_with_index{|e,i| a.push(i); a.push(e)}
+ #s = '"' + array2tk_list(a).gsub(/[\[\]$"]/, '\\\\\&') + '"'
+ s = '"' + array2tk_list(a).gsub(/[\[\]$"\\]/, '\\\\\&') + '"'
+ INTERP._eval(format('global %s; array set %s %s', @id, @id, s))
+ elsif val.kind_of?(Hash)
+ #s = '"' + val.to_a.collect{|e| array2tk_list(e)}.join(" ")\
+ # .gsub(/[\[\]$"]/, '\\\\\&') + '"'
+ s = '"' + val.to_a.collect{|e| array2tk_list(e)}.join(" ")\
+ .gsub(/[\[\]$"\\]/, '\\\\\&') + '"'
+ INTERP._eval(format('global %s; array set %s %s', @id, @id, s))
+ else
+ #s = '"' + _get_eval_string(val).gsub(/[\[\]$"]/, '\\\\\&') + '"'
+ s = '"' + _get_eval_string(val).gsub(/[\[\]$"\\]/, '\\\\\&') + '"'
+ INTERP._eval(format('global %s; set %s %s', @id, @id, s))
+ end
+=end
+=begin
+ if val.kind_of?(Hash)
+ #s = '"' + val.to_a.collect{|e| array2tk_list(e)}.join(" ")\
+ # .gsub(/[\[\]$"]/, '\\\\\&') + '"'
+ s = '"' + val.to_a.collect{|e| array2tk_list(e)}.join(" ")\
+ .gsub(/[\[\]$"\\]/, '\\\\\&') + '"'
+ INTERP._eval(Kernel.format('global %s; array set %s %s', @id, @id, s))
+ else
+ #s = '"' + _get_eval_string(val).gsub(/[\[\]$"]/, '\\\\\&') + '"'
+ s = '"' + _get_eval_string(val).gsub(/[\[\]$"\\]/, '\\\\\&') + '"'
+ INTERP._eval(Kernel.format('global %s; set %s %s', @id, @id, s))
+ end
+=end
+ end
+
+ def wait(on_thread = false, check_root = false)
+ if $SAFE >= 4
+ fail SecurityError, "can't wait variable at $SAFE >= 4"
+ end
+ on_thread &= (Thread.list.size != 1)
+ if on_thread
+ if check_root
+ INTERP._thread_tkwait('variable', @id)
+ else
+ INTERP._thread_vwait(@id)
+ end
+ else
+ if check_root
+ INTERP._invoke_without_enc('tkwait', 'variable', @id)
+ else
+ INTERP._invoke_without_enc('vwait', @id)
+ end
+ end
+ end
+ def eventloop_wait(check_root = false)
+ wait(false, check_root)
+ end
+ def thread_wait(check_root = false)
+ wait(true, check_root)
+ end
+ def tkwait(on_thread = true)
+ wait(on_thread, true)
+ end
+ def eventloop_tkwait
+ wait(false, true)
+ end
+ def thread_tkwait
+ wait(true, true)
+ end
+
+ def id
+ @id
+ end
+
+ def ref(*idxs)
+ # "#{@id}(#{idxs.collect{|idx| _get_eval_string(idx)}.join(',')})"
+ TkVarAccess.new("#{@id}(#{idxs.collect{|idx| _get_eval_string(idx)}.join(',')})")
+ end
+
+ def is_hash?
+ #ITNERP._eval("global #{@id}; array exist #{@id}") == '1'
+ INTERP._invoke_without_enc('global', @id)
+ # INTERP._invoke_without_enc('array', 'exist', @id) == '1'
+ TkComm.bool(INTERP._invoke_without_enc('array', 'exist', @id))
+ end
+
+ def is_scalar?
+ ! is_hash?
+ end
+
+ def exist?(*elems)
+ INTERP._invoke_without_enc('global', @id)
+ if elems.empty?
+ TkComm.bool(tk_call('info', 'exist', @id))
+ else
+ # array
+ index = elems.collect{|idx| _get_eval_string(idx, true)}.join(',')
+ TkComm.bool(tk_call('info', 'exist', "#{@id}")) &&
+ TkComm.bool(tk_call('info', 'exist', "#{@id}(#{index})"))
+ end
+ end
+
+ def keys
+ if (is_scalar?)
+ fail RuntimeError, 'cannot get keys from a scalar variable'
+ end
+ #tk_split_simplelist(INTERP._eval("global #{@id}; array get #{@id}"))
+ INTERP._invoke_without_enc('global', @id)
+ #tk_split_simplelist(INTERP._fromUTF8(INTERP._invoke_without_enc('array', 'names', @id)))
+ tk_split_simplelist(INTERP._invoke_without_enc('array', 'names', @id),
+ false, true)
+ end
+
+ def size
+ INTERP._invoke_without_enc('global', @id)
+ TkComm.number(INTERP._invoke_without_enc('array', 'size', @id))
+ end
+
+ def clear
+ if (is_scalar?)
+ fail RuntimeError, 'cannot clear a scalar variable'
+ end
+ keys.each{|k| unset(k)}
+ self
+ end
+
+ def update(hash)
+ if (is_scalar?)
+ fail RuntimeError, 'cannot update a scalar variable'
+ end
+ hash.each{|k,v| self[k] = v}
+ self
+ end
+
+unless const_defined?(:USE_TCLs_SET_VARIABLE_FUNCTIONS)
+ USE_TCLs_SET_VARIABLE_FUNCTIONS = true
+end
+
+if USE_TCLs_SET_VARIABLE_FUNCTIONS
+ ###########################################################################
+ # use Tcl function version of set tkvariable
+ ###########################################################################
+
+ def _value
+ #if INTERP._eval("global #{@id}; array exist #{@id}") == '1'
+ INTERP._invoke_without_enc('global', @id)
+ # if INTERP._invoke('array', 'exist', @id) == '1'
+ if TkComm.bool(INTERP._invoke('array', 'exist', @id))
+ #Hash[*tk_split_simplelist(INTERP._eval("global #{@id}; array get #{@id}"))]
+ Hash[*tk_split_simplelist(INTERP._invoke('array', 'get', @id))]
+ else
+ _fromUTF8(INTERP._get_global_var(@id))
+ end
+ end
+
+ def value=(val)
+ val = val._value if !@type && @type != :variable && val.kind_of?(TkVariable)
+ if val.kind_of?(Hash)
+ self.clear
+ val.each{|k, v|
+ #INTERP._set_global_var2(@id, _toUTF8(_get_eval_string(k)),
+ # _toUTF8(_get_eval_string(v)))
+ INTERP._set_global_var2(@id, _get_eval_string(k, true),
+ _get_eval_string(v, true))
+ }
+ self.value
+# elsif val.kind_of?(Array)
+=begin
+ INTERP._set_global_var(@id, '')
+ val.each{|v|
+ #INTERP._set_variable(@id, _toUTF8(_get_eval_string(v)),
+ INTERP._set_variable(@id, _get_eval_string(v, true),
+ TclTkLib::VarAccessFlag::GLOBAL_ONLY |
+ TclTkLib::VarAccessFlag::LEAVE_ERR_MSG |
+ TclTkLib::VarAccessFlag::APPEND_VALUE |
+ TclTkLib::VarAccessFlag::LIST_ELEMENT)
+ }
+ self.value
+=end
+# _fromUTF8(INTERP._set_global_var(@id, array2tk_list(val, true)))
+ else
+ #_fromUTF8(INTERP._set_global_var(@id, _toUTF8(_get_eval_string(val))))
+ _fromUTF8(INTERP._set_global_var(@id, _get_eval_string(val, true)))
+ end
+ end
+
+ def _element_value(*idxs)
+ index = idxs.collect{|idx| _get_eval_string(idx, true)}.join(',')
+ begin
+ _fromUTF8(INTERP._get_global_var2(@id, index))
+ rescue => e
+ case @def_default
+ when :proc
+ @default_val.call(self, *idxs)
+ when :val
+ @default_val
+ else
+ fail e
+ end
+ end
+ #_fromUTF8(INTERP._get_global_var2(@id, index))
+ #_fromUTF8(INTERP._get_global_var2(@id, _toUTF8(_get_eval_string(index))))
+ #_fromUTF8(INTERP._get_global_var2(@id, _get_eval_string(index, true)))
+ end
+
+ def []=(*args)
+ val = args.pop
+ type = default_element_value_type(args)
+ val = val._value if !type && type != :variable && val.kind_of?(TkVariable)
+ index = args.collect{|idx| _get_eval_string(idx, true)}.join(',')
+ _fromUTF8(INTERP._set_global_var2(@id, index, _get_eval_string(val, true)))
+ #_fromUTF8(INTERP._set_global_var2(@id, _toUTF8(_get_eval_string(index)),
+ # _toUTF8(_get_eval_string(val))))
+ #_fromUTF8(INTERP._set_global_var2(@id, _get_eval_string(index, true),
+ # _get_eval_string(val, true)))
+ end
+
+ def unset(*elems)
+ if elems.empty?
+ INTERP._unset_global_var(@id)
+ else
+ index = elems.collect{|idx| _get_eval_string(idx, true)}.join(',')
+ INTERP._unset_global_var2(@id, index)
+ end
+ end
+ alias remove unset
+
+else
+ ###########################################################################
+ # use Ruby script version of set tkvariable (traditional methods)
+ ###########################################################################
+
+ def _value
+ begin
+ INTERP._eval(Kernel.format('global %s; set %s', @id, @id))
+ #INTERP._eval(Kernel.format('set %s', @id))
+ #INTERP._invoke_without_enc('set', @id)
+ rescue
+ if INTERP._eval(Kernel.format('global %s; array exists %s',
+ @id, @id)) != "1"
+ #if INTERP._eval(Kernel.format('array exists %s', @id)) != "1"
+ #if INTERP._invoke_without_enc('array', 'exists', @id) != "1"
+ fail
+ else
+ Hash[*tk_split_simplelist(INTERP._eval(Kernel.format('global %s; array get %s', @id, @id)))]
+ #Hash[*tk_split_simplelist(_fromUTF8(INTERP._invoke_without_enc('array', 'get', @id)))]
+ end
+ end
+ end
+
+ def value=(val)
+ val = val._value if !@type && @type != :variable && val.kind_of?(TkVariable)
+ begin
+ #s = '"' + _get_eval_string(val).gsub(/[\[\]$"]/, '\\\\\&') + '"'
+ s = '"' + _get_eval_string(val).gsub(/[\[\]$"\\]/, '\\\\\&') + '"'
+ INTERP._eval(Kernel.format('global %s; set %s %s', @id, @id, s))
+ #INTERP._eval(Kernel.format('set %s %s', @id, s))
+ #_fromUTF8(INTERP._invoke_without_enc('set', @id, _toUTF8(s)))
+ rescue
+ if INTERP._eval(Kernel.format('global %s; array exists %s',
+ @id, @id)) != "1"
+ #if INTERP._eval(Kernel.format('array exists %s', @id)) != "1"
+ #if INTERP._invoke_without_enc('array', 'exists', @id) != "1"
+ fail
+ else
+ if val == []
+ INTERP._eval(Kernel.format('global %s; unset %s; set %s(0) 0; unset %s(0)', @id, @id, @id, @id))
+ #INTERP._eval(Kernel.format('unset %s; set %s(0) 0; unset %s(0)',
+ # @id, @id, @id))
+ #INTERP._invoke_without_enc('unset', @id)
+ #INTERP._invoke_without_enc('set', @id+'(0)', 0)
+ #INTERP._invoke_without_enc('unset', @id+'(0)')
+ elsif val.kind_of?(Array)
+ a = []
+ val.each_with_index{|e,i| a.push(i); a.push(array2tk_list(e, true))}
+ #s = '"' + a.join(" ").gsub(/[\[\]$"]/, '\\\\\&') + '"'
+ s = '"' + a.join(" ").gsub(/[\[\]$"\\]/, '\\\\\&') + '"'
+ INTERP._eval(Kernel.format('global %s; unset %s; array set %s %s',
+ @id, @id, @id, s))
+ #INTERP._eval(Kernel.format('unset %s; array set %s %s',
+ # @id, @id, s))
+ #INTERP._invoke_without_enc('unset', @id)
+ #_fromUTF8(INTERP._invoke_without_enc('array','set', @id, _toUTF8(s)))
+ elsif val.kind_of?(Hash)
+ #s = '"' + val.to_a.collect{|e| array2tk_list(e)}.join(" ")\
+ # .gsub(/[\[\]$"]/, '\\\\\&') + '"'
+ s = '"' + val.to_a.collect{|e| array2tk_list(e, true)}.join(" ")\
+ .gsub(/[\[\]$\\"]/, '\\\\\&') + '"'
+ INTERP._eval(Kernel.format('global %s; unset %s; array set %s %s',
+ @id, @id, @id, s))
+ #INTERP._eval(Kernel.format('unset %s; array set %s %s',
+ # @id, @id, s))
+ #INTERP._invoke_without_enc('unset', @id)
+ #_fromUTF8(INTERP._invoke_without_enc('array','set', @id, _toUTF8(s)))
+ else
+ fail
+ end
+ end
+ end
+ end
+
+ def _element_value(*idxs)
+ index = idxs.collect{|idx| _get_eval_string(idx)}.join(',')
+ begin
+ INTERP._eval(Kernel.format('global %s; set %s(%s)', @id, @id, index))
+ rescue => e
+ case @def_default
+ when :proc
+ @default_val.call(self, *idxs)
+ when :val
+ @default_val
+ else
+ fail e
+ end
+ end
+ #INTERP._eval(Kernel.format('global %s; set %s(%s)', @id, @id, index))
+ #INTERP._eval(Kernel.format('global %s; set %s(%s)',
+ # @id, @id, _get_eval_string(index)))
+ #INTERP._eval(Kernel.format('set %s(%s)', @id, _get_eval_string(index)))
+ #INTERP._eval('set ' + @id + '(' + _get_eval_string(index) + ')')
+ end
+
+ def []=(*args)
+ val = args.pop
+ type = default_element_value_type(args)
+ val = val._value if !type && type != :variable && val.kind_of?(TkVariable)
+ index = args.collect{|idx| _get_eval_string(idx)}.join(',')
+ INTERP._eval(Kernel.format('global %s; set %s(%s) %s', @id, @id,
+ index, _get_eval_string(val)))
+ #INTERP._eval(Kernel.format('global %s; set %s(%s) %s', @id, @id,
+ # _get_eval_string(index), _get_eval_string(val)))
+ #INTERP._eval(Kernel.format('set %s(%s) %s', @id,
+ # _get_eval_string(index), _get_eval_string(val)))
+ #INTERP._eval('set ' + @id + '(' + _get_eval_string(index) + ') ' +
+ # _get_eval_string(val))
+ end
+
+ def unset(*elems)
+ if elems.empty?
+ INTERP._eval(Kernel.format('global %s; unset %s', @id, @id))
+ #INTERP._eval(Kernel.format('unset %s', @id))
+ #INTERP._eval('unset ' + @id)
+ else
+ index = elems.collect{|idx| _get_eval_string(idx, true)}.join(',')
+ INTERP._eval(Kernel.format('global %s; unset %s(%s)', @id, @id, index))
+ #INTERP._eval(Kernel.format('global %s; unset %s(%s)',
+ # @id, @id, _get_eval_string(elem)))
+ #INTERP._eval(Kernel.format('unset %s(%s)', @id, tk_tcl2ruby(elem)))
+ #INTERP._eval('unset ' + @id + '(' + _get_eval_string(elem) + ')')
+ end
+ end
+ alias remove unset
+
+end
+
+ protected :_value, :_element_value
+
+ def value
+ _to_default_type(_value)
+ end
+
+ def [](*idxs)
+ _to_default_element_type(idxs, _element_value(*idxs))
+ end
+
+ def set_value(val)
+ self.value = val
+ self
+ end
+
+ def to_hash
+ hash = {}
+ self.keys.each{|k|
+ hash[k] = self[k]
+ }
+ hash
+ end
+
+ def set_element_value(idxs, val)
+ if idxs.kind_of?(Array)
+ self[*idxs]=val
+ else
+ self[idxs]=val
+ end
+ self
+ end
+
+ def set_value_type(val)
+ self.default_value_type = val.class
+ self.value = val
+ self
+ end
+
+ alias value_type= set_value_type
+
+ def set_element_value_type(idxs, val)
+ self.set_default_element_value_type(idxs, val.class)
+ if idxs.kind_of?(Array)
+ self[*idxs]=val
+ else
+ self[idxs]=val
+ end
+ self
+ end
+
+ def numeric
+ number(_value)
+ end
+ def numeric_element(*idxs)
+ number(_element_value(*idxs))
+ end
+ def set_numeric(val)
+ case val
+ when Numeric
+ self.value=(val)
+ when TkVariable
+ self.value=(val.numeric)
+ else
+ raise ArgumentError, "Numeric is expected"
+ end
+ self
+ end
+ alias numeric= set_numeric
+ def set_numeric_element(idxs, val)
+ case val
+ when Numeric
+ val
+ when TkVariable
+ val = val.numeric
+ else
+ raise ArgumentError, "Numeric is expected"
+ end
+ if idxs.kind_of?(Array)
+ self[*idxs]=val
+ else
+ self[idxs]=val
+ end
+ self
+ end
+ def set_numeric_type(val)
+ @type = :numeric
+ self.numeric=(val)
+ self
+ end
+ alias numeric_type= set_numeric_type
+ def set_numeric_element_type(idxs, val)
+ self.set_default_element_value_type(idxs, :numeric)
+ self.set_numeric_element(idxs, val)
+ end
+
+ def bool
+ TkComm.bool(_value)
+=begin
+ # see Tcl_GetBoolean man-page
+ case _value.downcase
+ when '0', 'false', 'no', 'off'
+ false
+ else
+ true
+ end
+=end
+ end
+ def bool_element(*idxs)
+ TkComm.bool(_element_value(*idxs))
+ end
+ def set_bool(val)
+ if ! val
+ self.value = '0'
+ else
+ case val.to_s.downcase
+ when 'false', '0', 'no', 'off'
+ self.value = '0'
+ else
+ self.value = '1'
+ end
+ end
+ self
+ end
+ alias bool= set_bool
+ def set_bool_element(idxs, val)
+ if ! val
+ val = '0'
+ else
+ case val.to_s.downcase
+ when 'false', '0', 'no', 'off'
+ val = '0'
+ else
+ val = '1'
+ end
+ end
+ if idxs.kind_of?(Array)
+ self[*idxs]=val
+ else
+ self[idxs]=val
+ end
+ self
+ end
+ def set_bool_type(val)
+ @type = :bool
+ self.bool=(val)
+ self
+ end
+ alias bool_type= set_bool_type
+ def set_bool_element_type(idxs, val)
+ self.set_default_element_value_type(idxs, :bool)
+ self.set_bool_element(idxs, val)
+ end
+
+ def variable
+ # keeps a Tcl's variable name
+ TkVarAccess.new(self._value)
+ end
+ def variable_element(*idxs)
+ TkVarAccess.new(_element_value(*idxs))
+ end
+ def set_variable(var)
+ var = var.id if var.kind_of?(TkVariable)
+ self.value = var
+ self
+ end
+ alias variable= set_variable
+ def set_variable_element(idxs, var)
+ var = var.id if var.kind_of?(TkVariable)
+ if idxs.kind_of?(Array)
+ self[*idxs]=var
+ else
+ self[idxs]=var
+ end
+ self
+ end
+ def set_variable_type(var)
+ @type = :variable
+ var = var.id if var.kind_of?(TkVariable)
+ self.value = var
+ self
+ end
+ alias variable_type= set_variable_type
+ def set_variable_element_type(idxs, var)
+ self.set_default_element_value_type(idxs, :variable)
+ self.set_variable_element(idxs, var)
+ end
+
+ def window
+ TkComm.window(self._value)
+ end
+ def window_element(*idxs)
+ TkComm.window(_element_value(*idxs))
+ end
+ def set_window(win)
+ win = win._value if win.kind_of?(TkVariable)
+ self.value = win
+ self
+ end
+ alias window= set_window
+ def set_window_element(idxs, win)
+ win = win._value if win.kind_of?(TkVariable)
+ if idxs.kind_of?(Array)
+ self[*idxs]=win
+ else
+ self[idxs]=win
+ end
+ self
+ end
+ def set_window_type(win)
+ @type = :window
+ self.window=(win)
+ self
+ end
+ alias window_type= set_window_type
+ def set_window_element_type(idxs, win)
+ self.set_default_element_value_type(idxs, :window)
+ self.set_window_element(idxs, win)
+ end
+
+ def procedure
+ TkComm.procedure(self._value)
+ end
+ def procedure_element(*idxs)
+ TkComm.procedure(_element_value(*idxs))
+ end
+ def set_procedure(cmd)
+ self.value = cmd
+ self
+ end
+ alias procedure= set_procedure
+ def set_procedure_element(idxs, cmd)
+ cmd = cmd._value if cmd.kind_of?(TkVariable)
+ if idxs.kind_of?(Array)
+ self[*idxs]=cmd
+ else
+ self[idxs]=cmd
+ end
+ self
+ end
+ def set_procedure_type(cmd)
+ @type = :procedure
+ self.procedure=(cmd)
+ self
+ end
+ alias procedure_type= set_procedure_type
+ def set_procedure_element_type(idxs, cmd)
+ self.set_default_element_value_type(idxs, :procedure)
+ self.set_proceure_element(idxs, cmd)
+ end
+
+ def to_proc
+ cmd = self.procedure
+ if cmd.respond_to?(:call)
+ cmd
+ else
+ # cmd is a String
+ cmd.to_sym.to_proc
+ end
+ end
+
+ def to_i
+ number(_value).to_i
+ end
+ alias to_int to_i
+ def element_to_i(*idxs)
+ number(_element_value(*idxs)).to_i
+ end
+
+ def to_f
+ number(_value).to_f
+ end
+ def element_to_f(*idxs)
+ number(_element_value(*idxs)).to_f
+ end
+
+ def to_s
+ #string(value).to_s
+ _value
+ end
+ alias string to_s
+ alias to_str to_s
+ def element_to_s(*idxs)
+ _element_value(*idxs)
+ end
+ def string_element(*idxs)
+ _element_value(*idxs)
+ end
+ def set_string(val)
+ val = val._value if val.kind_of?(TkVariable)
+ self.value=val
+ self
+ end
+ alias string= set_string
+ def set_string_element(idxs, val)
+ val = val._value if val.kind_of?(TkVariable)
+ if idxs.kind_of?(Array)
+ self[*idxs]=val
+ else
+ self[idxs]=val
+ end
+ self
+ end
+ def set_string_type(val)
+ @type = :string
+ self.string=(val)
+ self
+ end
+ alias string_type= set_string_type
+ def set_string_element_type(idxs, val)
+ self.set_default_element_value_type(idxs, :string)
+ self.set_string_element(idxs, val)
+ end
+
+ def to_sym
+ _value.intern
+ end
+ alias symbol to_sym
+ def element_to_sym(*idxs)
+ _element_value(*idxs).intern
+ end
+ alias symbol_element element_to_sym
+ def set_symbol(val)
+ val = val._value if val.kind_of?(TkVariable)
+ self.value=val
+ self
+ end
+ alias symbol= set_symbol
+ def set_symbol_element(idxs, val)
+ val = val._value if val.kind_of?(TkVariable)
+ if idxs.kind_of?(Array)
+ self[*idxs]=val
+ else
+ self[idxs]=val
+ end
+ self
+ end
+ def set_symbol_type(val)
+ @type = :symbol
+ self.value=(val)
+ self
+ end
+ alias symbol_type= set_symbol_type
+ def set_symbol_element_type(idxs, val)
+ self.set_default_element_value_type(idxs, :symbol)
+ self.set_symbol_element(idxs, val)
+ end
+
+ def list
+ #tk_split_list(value)
+ tk_split_simplelist(_value)
+ end
+ alias to_a list
+ alias to_ary list
+ def list_element(*idxs)
+ tk_split_simplelist(_element_value(*idxs))
+ end
+ alias element_to_a list_element
+
+ def numlist
+ list.collect!{|val| number(val)}
+ end
+ def numlist_element(*idxs)
+ list_element(*idxs).collect!{|val| number(val)}
+ end
+
+ def set_list(val)
+ case val
+ when Array
+ self.value=(val)
+ when TkVariable
+ self.value=(val.list)
+ else
+ raise ArgumentError, "Array is expected"
+ end
+ self
+ end
+ alias list= set_list
+
+ alias set_numlist set_list
+ alias numlist= set_numlist
+
+ def set_list_element(idxs, val)
+ case val
+ when Array
+ val
+ when TkVariable
+ val = val.list
+ else
+ raise ArgumentError, "Array is expected"
+ end
+ if idxs.kind_of?(Array)
+ self[*idxs]=val
+ else
+ self[idxs]=val
+ end
+ self
+ end
+ alias set_numlist_element set_list_element
+
+ def set_list_type(val)
+ @type = :list
+ self.list=(val)
+ self
+ end
+ alias list_type= set_list_type
+ def set_list_element_type(idxs, val)
+ self.set_default_element_value_type(idxs, :list)
+ self.set_list_element(idxs, val)
+ end
+ def set_numlist_type(val)
+ @type = :numlist
+ self.numlist=(val)
+ self
+ end
+ alias numlist_type= set_numlist_type
+ def set_numlist_element_type(idxs, val)
+ self.set_default_element_value_type(idxs, :numlist)
+ self.set_numlist_element(idxs, val)
+ end
+
+ def lappend(*elems)
+ tk_call('lappend', @id, *elems)
+ self
+ end
+ def element_lappend(idxs, *elems)
+ if idxs.kind_of?(Array)
+ idxs = idxs.collect{|idx| _get_eval_string(idx, true)}.join(',')
+ end
+ tk_call('lappend', "#{@id}(#{idxs})", *elems)
+ self
+ end
+
+ def lindex(idx)
+ tk_call('lindex', self._value, idx)
+ end
+ alias lget lindex
+ def element_lindex(elem_idxs, idx)
+ if elem_idxs.kind_of?(Array)
+ val = _element_value(*elem_idxs)
+ else
+ val = _element_value(elem_idxs)
+ end
+ tk_call('lindex', val, idx)
+ end
+ alias element_lget element_lindex
+
+ def lget_i(idx)
+ number(lget(idx)).to_i
+ end
+ def element_lget_i(elem_idxs, idx)
+ number(element_lget(elem_idxs, idx)).to_i
+ end
+
+ def lget_f(idx)
+ number(lget(idx)).to_f
+ end
+ def element_lget_f(elem_idxs, idx)
+ number(element_lget(elem_idxs, idx)).to_f
+ end
+
+ def lset(idx, val)
+ tk_call('lset', @id, idx, val)
+ self
+ end
+ def element_lset(elem_idxs, idx, val)
+ if elem_idxs.kind_of?(Array)
+ idxs = elem_idxs.collect{|i| _get_eval_string(i, true)}.join(',')
+ end
+ tk_call('lset', "#{@id}(#{idxs})", idx, val)
+ self
+ end
+
+ def inspect
+ #Kernel.format "#<TkVariable: %s>", @id
+ '#<TkVariable: ' + @id + '>'
+ end
+
+ def coerce(other)
+ case other
+ when TkVariable
+ [other._value, self._value]
+ when String
+ [other, self.to_s]
+ when Symbol
+ [other, self.to_sym]
+ when Numeric
+ [other, self.numeric]
+ when Array
+ [other, self.to_a]
+ else
+ [other, self._value]
+ end
+ end
+
+ def +@
+ self.numeric
+ end
+ def -@
+ -(self.numeric)
+ end
+
+ def &(other)
+ if other.kind_of?(Array)
+ self.to_a & other.to_a
+ else
+ self.to_i & other.to_i
+ end
+ end
+ def |(other)
+ if other.kind_of?(Array)
+ self.to_a | other.to_a
+ else
+ self.to_i | other.to_i
+ end
+ end
+ def +(other)
+ case other
+ when Array
+ self.to_a + other
+ when String
+ self._value + other
+ else
+ begin
+ number(self._value) + other
+ rescue
+ self._value + other.to_s
+ end
+ end
+ end
+ def -(other)
+ if other.kind_of?(Array)
+ self.to_a - other
+ else
+ number(self._value) - other
+ end
+ end
+ def *(other)
+ num_or_str(self._value) * other
+ #begin
+ # number(self._value) * other
+ #rescue
+ # self._value * other
+ #end
+ end
+ def /(other)
+ number(self._value) / other
+ end
+ def %(other)
+ num_or_str(self._value) % other
+ #begin
+ # number(self._value) % other
+ #rescue
+ # self._value % other
+ #end
+ end
+ def **(other)
+ number(self._value) ** other
+ end
+ def =~(other)
+ self._value =~ other
+ end
+
+ def ==(other)
+ case other
+ when TkVariable
+ #self.equal?(other)
+ self._value == other._value
+ when String
+ self.to_s == other
+ when Symbol
+ self.to_sym == other
+ when Integer
+ self.to_i == other
+ when Float
+ self.to_f == other
+ when Array
+ self.to_a == other
+ when Hash
+ # false if self is not an assoc array
+ self._value == other
+ else
+ # false
+ self._value == _get_eval_string(other)
+ end
+ end
+
+ def ===(other)
+ if other.kind_of?(TkVariable)
+ self.id == other.id
+ else
+ super
+ end
+ end
+
+ def zero?
+ numeric.zero?
+ end
+ def nonzero?
+ !(numeric.zero?)
+ end
+
+ def <=>(other)
+ if other.kind_of?(TkVariable)
+ begin
+ val = other.numeric
+ other = val
+ rescue
+ other = other._value
+ end
+ elsif other.kind_of?(Numeric)
+ begin
+ return self.numeric <=> other
+ rescue
+ return self._value <=> other.to_s
+ end
+ elsif other.kind_of?(Array)
+ return self.list <=> other
+ else
+ return self._value <=> other
+ end
+ end
+
+ def to_eval
+ @id
+ end
+
+ def trace_callback(elem, op)
+ if @trace_var.kind_of? Array
+ @trace_var.each{|m,e| e.call(self,elem,op) if m.index(op)}
+ end
+ if elem.kind_of?(String) && elem != ''
+ if @trace_elem.kind_of?(Hash) && @trace_elem[elem].kind_of?(Array)
+ @trace_elem[elem].each{|m,e| e.call(self,elem,op) if m.index(op)}
+ end
+ end
+ end
+
+ def _check_trace_opt(opts)
+ if opts.kind_of?(Array)
+ opt_str = opts.map{|s| s.to_s}.join(' ')
+ else
+ opt_str = opts.to_s
+ end
+
+ fail ArgumentError, 'null trace option' if opt_str.empty?
+
+ if opt_str =~ /[^arwu\s]/
+ # new format (Tcl/Tk8.4+?)
+ if opts.kind_of?(Array)
+ opt_ary = opts.map{|opt| opt.to_s.strip}
+ else
+ opt_ary = opt_str.split(/\s+|\|/)
+ opt_ary.delete('')
+ end
+ if USE_OLD_TRACE_OPTION_STYLE
+ opt_ary.uniq.map{|opt|
+ case opt
+ when 'array'
+ 'a'
+ when 'read'
+ 'r'
+ when 'write'
+ 'w'
+ when 'unset'
+ 'u'
+ else
+ fail ArgumentError, "unsupported trace option '#{opt}' on Tcl/Tk#{Tk::TCL_PATCHLEVEL}"
+ end
+ }.join
+ else
+ opt_ary
+ end
+ else
+ # old format
+ opt_ary = opt_str.delete('^arwu').split(//).uniq
+ if USE_OLD_TRACE_OPTION_STYLE
+ opt_ary.join
+ else
+ opt_ary.map{|c|
+ case c
+ when 'a'
+ 'array'
+ when 'r'
+ 'read'
+ when 'w'
+ 'write'
+ when 'u'
+ 'unset'
+ end
+ }
+ end
+ end
+ end
+ private :_check_trace_opt
+
+ def trace(opts, cmd = Proc.new)
+ opts = _check_trace_opt(opts)
+ (@trace_var ||= []).unshift([opts,cmd])
+
+ if @trace_opts == nil
+ TkVar_CB_TBL[@id] = self
+ @trace_opts = opts.dup
+ if USE_OLD_TRACE_OPTION_STYLE
+ Tk.tk_call_without_enc('trace', 'variable',
+ @id, @trace_opts, 'rb_var ' << @id)
+ else
+ Tk.tk_call_without_enc('trace', 'add', 'variable',
+ @id, @trace_opts, 'rb_var ' << @id)
+ end
+ else
+ newopts = @trace_opts.dup
+ if USE_OLD_TRACE_OPTION_STYLE
+ opts.each_byte{|c| newopts.concat(c.chr) unless newopts.index(c.chr)}
+ if newopts != @trace_opts
+ Tk.tk_call_without_enc('trace', 'vdelete',
+ @id, @trace_opts, 'rb_var ' << @id)
+ @trace_opts.replace(newopts)
+ Tk.tk_call_without_enc('trace', 'variable',
+ @id, @trace_opts, 'rb_var ' << @id)
+ end
+ else
+ newopts |= opts
+ unless (newopts - @trace_opts).empty?
+ Tk.tk_call_without_enc('trace', 'remove', 'variable',
+ @id, @trace_opts, 'rb_var ' << @id)
+ @trace_opts.replace(newopts)
+ Tk.tk_call_without_enc('trace', 'add', 'variable',
+ @id, @trace_opts, 'rb_var ' << @id)
+ end
+ end
+ end
+
+ self
+ end
+
+ def trace_element(elem, opts, cmd = Proc.new)
+ if @elem
+ fail(RuntimeError,
+ "invalid for a TkVariable which denotes an element of Tcl's array")
+ end
+
+ opts = _check_trace_opt(opts)
+
+ ((@trace_elem ||= {})[elem] ||= []).unshift([opts,cmd])
+
+ if @trace_opts == nil
+ TkVar_CB_TBL[@id] = self
+ @trace_opts = opts.dup
+ if USE_OLD_TRACE_OPTION_STYLE
+ Tk.tk_call_without_enc('trace', 'add', 'variable',
+ @id, @trace_opts, 'rb_var ' << @id)
+ else
+ Tk.tk_call_without_enc('trace', 'variable',
+ @id, @trace_opts, 'rb_var ' << @id)
+ end
+ else
+ newopts = @trace_opts.dup
+ if USE_OLD_TRACE_OPTION_STYLE
+ opts.each_byte{|c| newopts.concat(c.chr) unless newopts.index(c.chr)}
+ if newopts != @trace_opts
+ Tk.tk_call_without_enc('trace', 'vdelete',
+ @id, @trace_opts, 'rb_var ' << @id)
+ @trace_opts.replace(newopts)
+ Tk.tk_call_without_enc('trace', 'variable',
+ @id, @trace_opts, 'rb_var ' << @id)
+ end
+ else
+ newopts |= opts
+ unless (newopts - @trace_opts).empty?
+ Tk.tk_call_without_enc('trace', 'remove', 'variable',
+ @id, @trace_opts, 'rb_var ' << @id)
+ @trace_opts.replace(newopts)
+ Tk.tk_call_without_enc('trace', 'add', 'variable',
+ @id, @trace_opts, 'rb_var ' << @id)
+ end
+ end
+ end
+
+ self
+ end
+
+ def trace_info
+ return [] unless @trace_var
+ @trace_var.dup
+ end
+ alias trace_vinfo trace_info
+
+ def trace_info_for_element(elem)
+ if @elem
+ fail(RuntimeError,
+ "invalid for a TkVariable which denotes an element of Tcl's array")
+ end
+ return [] unless @trace_elem
+ return [] unless @trace_elem[elem]
+ @trace_elem[elem].dup
+ end
+ alias trace_vinfo_for_element trace_info_for_element
+
+ def trace_remove(opts,cmd)
+ return self unless @trace_var.kind_of? Array
+
+ opts = _check_trace_opt(opts)
+
+ idx = -1
+ if USE_OLD_TRACE_OPTION_STYLE
+ newopts = ''
+ @trace_var.each_with_index{|e, i|
+ if idx < 0 && e[1] == cmd
+ diff = false
+ ['a', 'r', 'w', 'u'].each{|c|
+ break if (diff = e[0].index(c) ^ opts.index(c))
+ }
+ unless diff
+ #find
+ idx = i
+ next
+ end
+ end
+ e[0].each_byte{|c| newopts.concat(c.chr) unless newopts.index(c.chr)}
+ }
+ else
+ newopts = []
+ @trace_var.each_with_index{|e, i|
+ if idx < 0 && e[1] == cmd &&
+ e[0].size == opts.size && (e[0] - opts).empty?
+ # find
+ idx = i
+ next
+ end
+ newopts |= e[0]
+ }
+ end
+
+ if idx >= 0
+ @trace_var.delete_at(idx)
+ else
+ return self
+ end
+
+ (@trace_elem ||= {}).each{|elem|
+ @trace_elem[elem].each{|e|
+ if USE_OLD_TRACE_OPTION_STYLE
+ e[0].each_byte{|c| newopts.concat(c.chr) unless newopts.index(c.chr)}
+ else
+ newopts |= e[0]
+ end
+ }
+ }
+
+ if USE_OLD_TRACE_OPTION_STYLE
+ diff = false
+ @trace_opts.each_byte{|c| break if (diff = ! newopts.index(c))}
+ if diff
+ Tk.tk_call_without_enc('trace', 'vdelete',
+ @id, @trace_opts, 'rb_var ' << @id)
+ @trace_opts.replace(newopts)
+ unless @trace_opts.empty?
+ Tk.tk_call_without_enc('trace', 'variable',
+ @id, @trace_opts, 'rb_var ' << @id)
+ end
+ end
+ else
+ unless (@trace_opts - newopts).empty?
+ Tk.tk_call_without_enc('trace', 'remove', 'variable',
+ @id, @trace_opts, 'rb_var ' << @id)
+ @trace_opts.replace(newopts)
+ unless @trace_opts.empty?
+ Tk.tk_call_without_enc('trace', 'add', 'variable',
+ @id, @trace_opts, 'rb_var ' << @id)
+ end
+ end
+ end
+
+ self
+ end
+ alias trace_delete trace_remove
+ alias trace_vdelete trace_remove
+
+ def trace_remove_for_element(elem,opts,cmd)
+ if @elem
+ fail(RuntimeError,
+ "invalid for a TkVariable which denotes an element of Tcl's array")
+ end
+ return self unless @trace_elem.kind_of? Hash
+ return self unless @trace_elem[elem].kind_of? Array
+
+ opts = _check_trace_opt(opts)
+
+ idx = -1
+ if USE_OLD_TRACE_OPTION_STYLE
+ @trace_elem[elem].each_with_index{|e, i|
+ if idx < 0 && e[1] == cmd
+ diff = false
+ ['a', 'r', 'w', 'u'].each{|c|
+ break if (diff = e[0].index(c) ^ opts.index(c))
+ }
+ unless diff
+ #find
+ idx = i
+ next
+ end
+ end
+ }
+ else
+ @trace_elem[elem].each_with_index{|e, i|
+ if idx < 0 && e[1] == cmd &&
+ e[0].size == opts.size && (e[0] - opts).empty?
+ # find
+ idx = i
+ next
+ end
+ }
+ end
+
+ if idx >= 0
+ @trace_elem[elem].delete_at(idx)
+ else
+ return self
+ end
+
+ if USE_OLD_TRACE_OPTION_STYLE
+ newopts = ''
+ @trace_var.each{|e|
+ e[0].each_byte{|c| newopts.concat(c.chr) unless newopts.index(c.chr)}
+ }
+ @trace_elem.each{|elem|
+ @trace_elem[elem].each{|e|
+ e[0].each_byte{|c| newopts.concat(c.chr) unless newopts.index(c.chr)}
+ }
+ }
+ else
+ newopts = []
+ @trace_var.each{|e|
+ newopts |= e[0]
+ }
+ @trace_elem.each{|elem|
+ @trace_elem[elem].each{|e|
+ e[0].each_byte{|c| newopts.concat(c.chr) unless newopts.index(c.chr)}
+ }
+ }
+ end
+
+ if USE_OLD_TRACE_OPTION_STYLE
+ diff = false
+ @trace_opts.each_byte{|c| break if (diff = ! newopts.index(c))}
+ if diff
+ Tk.tk_call_without_enc('trace', 'vdelete',
+ @id, @trace_opts, 'rb_var ' << @id)
+ @trace_opts.replace(newopts)
+ unless @trace_opts.empty?
+ Tk.tk_call_without_enc('trace', 'variable',
+ @id, @trace_opts, 'rb_var ' << @id)
+ end
+ end
+ else
+ unless (@trace_opts - newopts).empty?
+ Tk.tk_call_without_enc('trace', 'remove', 'variable',
+ @id, @trace_opts, 'rb_var ' << @id)
+ @trace_opts.replace(newopts)
+ unless @trace_opts.empty?
+ Tk.tk_call_without_enc('trace', 'add', 'variable',
+ @id, @trace_opts, 'rb_var ' << @id)
+ end
+ end
+ end
+
+ self
+ end
+ alias trace_delete_for_element trace_remove_for_element
+ alias trace_vdelete_for_element trace_remove_for_element
+end
+
+class TkVarAccess<TkVariable
+ def self.new(name, *args)
+ if name.kind_of?(TkVariable)
+ name.value = args[0] unless args.empty?
+ return name
+ end
+
+ name = name.to_s
+ v = nil
+ TkVar_ID_TBL.mutex.synchronize{
+ if v = TkVar_ID_TBL[name]
+ v.value = args[0] unless args.empty?
+ return v
+ else
+ (v = self.allocate).instance_eval{
+ @id = name
+ TkVar_ID_TBL[@id] = self
+ @var = @id
+ }
+ end
+ }
+
+ v.instance_eval{ initialize(name, *args) }
+ v
+ end
+
+ def self.new_hash(name, *args)
+ if name.kind_of?(TkVariable)
+ unless name.is_hash?
+ fail ArgumentError, "already exist as a scalar variable"
+ end
+ name.value = args[0] unless args.empty?
+ return name
+ end
+
+ name = name.to_s
+ v = nil
+ TkVar_ID_TBL.mutex.synchronize{
+ if v = TkVar_ID_TBL[name]
+ unless v.is_hash?
+ fail ArgumentError, "already exist as a scalar variable"
+ end
+ v.value = args[0] unless args.empty?
+ return v
+ else
+ (v = self.allocate).instance_eval{
+ @id = name
+ TkVar_ID_TBL[@id] = self
+ @var = @id
+ }
+ end
+ }
+
+ INTERP._invoke_without_enc('global', name)
+ if args.empty? && INTERP._invoke_without_enc('array', 'exist', name) == '0'
+ v.instance_eval{ initialize(name, {}) } # force creating
+ else
+ v.instance_eval{ initialize(name, *args) }
+ end
+ v
+ end
+
+ def initialize(varname, val=nil)
+ # @id = varname
+ # TkVar_ID_TBL[@id] = self
+
+ # @var = @id
+ @elem = nil
+
+ @def_default = false
+ @default_val = nil
+
+ @trace_var = nil
+ @trace_elem = nil
+ @trace_opts = nil
+
+ @type = nil
+ var = self
+ @element_type = Hash.new{|k,v| var.default_value_type }
+
+ # is an element?
+ if @id =~ /^([^(]+)\((.+)\)$/
+ # is an element --> var == $1, elem == $2
+ @var = $1
+ @elem = $2
+ end
+
+ # teach Tk-ip that @id is global var
+ INTERP._invoke_without_enc('global', @var)
+=begin
+ begin
+ INTERP._invoke_without_enc('global', @id)
+ rescue => e
+ if @id =~ /^(.+)\([^()]+\)$/
+ # is an element --> varname == $1
+ INTERP._invoke_without_enc('global', $1)
+ else
+ fail e
+ end
+ end
+=end
+
+ if val
+ if val.kind_of?(Hash)
+ # assoc-array variable
+ self[''] = 0
+ self.clear
+ end
+ #s = '"' + _get_eval_string(val).gsub(/[\[\]$"]/, '\\\\\&') + '"' #"
+ #s = '"' + _get_eval_string(val).gsub(/[\[\]$"\\]/, '\\\\\&') + '"' #"
+ #INTERP._eval(Kernel.format('global %s; set %s %s', @id, @id, s))
+ #INTERP._set_global_var(@id, _toUTF8(_get_eval_string(val)))
+ self.value = val
+ end
+ end
+end
+
+module Tk
+ begin
+ INTERP._invoke_without_enc('global', 'auto_path')
+ auto_path = INTERP._invoke('set', 'auto_path')
+ rescue => e
+ begin
+ INTERP._invoke_without_enc('global', 'env')
+ auto_path = INTERP._invoke('set', 'env(TCLLIBPATH)')
+ rescue => e
+ auto_path = Tk::LIBRARY
+ end
+ end
+
+ AUTO_PATH = TkVarAccess.new('auto_path', auto_path)
+
+=begin
+ AUTO_OLDPATH = tk_split_simplelist(INTERP._invoke('set', 'auto_oldpath'))
+ AUTO_OLDPATH.each{|s| s.freeze}
+ AUTO_OLDPATH.freeze
+=end
+
+ TCL_PACKAGE_PATH = TkVarAccess.new('tcl_pkgPath')
+ PACKAGE_PATH = TCL_PACKAGE_PATH
+
+ TCL_LIBRARY_PATH = TkVarAccess.new('tcl_libPath')
+ LIBRARY_PATH = TCL_LIBRARY_PATH
+
+ TCL_PRECISION = TkVarAccess.new('tcl_precision')
+end
diff --git a/jni/ruby/ext/tk/lib/tk/virtevent.rb b/jni/ruby/ext/tk/lib/tk/virtevent.rb
new file mode 100644
index 0000000..c11e969
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tk/virtevent.rb
@@ -0,0 +1,139 @@
+#
+# tk/virtevent.rb : treats virtual events
+# 1998/07/16 by Hidetoshi Nagai <nagai@ai.kyutech.ac.jp>
+#
+require 'tk'
+
+class TkVirtualEvent<TkObject
+ extend Tk
+
+ TkCommandNames = ['event'.freeze].freeze
+
+ (TkVirtualEventID = ["VirtEvent".freeze, TkUtil.untrust("00000")]).instance_eval{
+ @mutex = Mutex.new
+ def mutex; @mutex; end
+ freeze
+ }
+
+ TkVirtualEventTBL = TkCore::INTERP.create_table
+
+ TkCore::INTERP.init_ip_env{
+ TkVirtualEventTBL.mutex.synchronize{ TkVirtualEventTBL.clear }
+ }
+
+ class PreDefVirtEvent<self
+ def self.new(event, *sequences)
+ if event =~ /^<(<.*>)>$/
+ event = $1
+ elsif event !~ /^<.*>$/
+ event = '<' + event + '>'
+ end
+ TkVirtualEvent::TkVirtualEventTBL.mutex.synchronize{
+ if TkVirtualEvent::TkVirtualEventTBL.has_key?(event)
+ TkVirtualEvent::TkVirtualEventTBL[event]
+ else
+ # super(event, *sequences)
+ (obj = self.allocate).instance_eval{
+ initialize(event, *sequences)
+ TkVirtualEvent::TkVirtualEventTBL[@id] = self
+ }
+ end
+ }
+ end
+
+ def initialize(event, *sequences)
+ @path = @id = event
+ _add_sequences(sequences)
+ end
+ end
+
+ def TkVirtualEvent.getobj(event)
+ obj = nil
+ TkVirtualEventTBL.mutex.synchronize{
+ obj = TkVirtualEventTBL[event]
+ }
+ if obj
+ obj
+ else
+ if tk_call_without_enc('event', 'info').index("<#{event}>")
+ PreDefVirtEvent.new(event)
+ else
+ fail ArgumentError, "undefined virtual event '<#{event}>'"
+ end
+ end
+ end
+
+ def TkVirtualEvent.info
+ tk_call_without_enc('event', 'info').split(/\s+/).collect!{|seq|
+ TkVirtualEvent.getobj(seq[1..-2])
+ }
+ end
+
+ def initialize(*sequences)
+ TkVirtualEventID.mutex.synchronize{
+ # @path = @id = '<' + TkVirtualEventID.join('') + '>'
+ @path = @id = '<' + TkVirtualEventID.join(TkCore::INTERP._ip_id_) + '>'
+ TkVirtualEventID[1].succ!
+ }
+ _add_sequences(sequences)
+ end
+
+ def _add_sequences(seq_ary)
+ unless seq_ary.empty?
+ tk_call_without_enc('event', 'add', "<#{@id}>",
+ *(seq_ary.collect{|seq|
+ "<#{tk_event_sequence(seq)}>"
+ }) )
+ end
+ self
+ end
+ private :_add_sequences
+
+ def add(*sequences)
+ if sequences != []
+ _add_sequences(sequences)
+ TkVirtualEventTBL.mutex.synchronize{
+ TkVirtualEventTBL[@id] = self
+ }
+ end
+ self
+ end
+
+ def delete(*sequences)
+ if sequences.empty?
+ tk_call_without_enc('event', 'delete', "<#{@id}>")
+ TkVirtualEventTBL.mutex.synchronize{
+ TkVirtualEventTBL.delete(@id)
+ }
+ else
+ tk_call_without_enc('event', 'delete', "<#{@id}>",
+ *(sequences.collect{|seq|
+ "<#{tk_event_sequence(seq)}>"
+ }) )
+ if tk_call_without_enc('event','info',"<#{@id}>").empty?
+ TkVirtualEventTBL.mutex.synchronize{
+ TkVirtualEventTBL.delete(@id)
+ }
+ end
+ end
+ self
+ end
+
+ def info
+ tk_call_without_enc('event','info',"<#{@id}>").split(/\s+/).collect!{|seq|
+ lst = seq.scan(/<*[^<>]+>*/).collect!{|subseq|
+ case (subseq)
+ when /^<<[^<>]+>>$/
+ TkVirtualEvent.getobj(subseq[1..-2])
+ when /^<[^<>]+>$/
+ subseq[1..-2]
+ else
+ subseq.split('')
+ end
+ }.flatten
+ (lst.size == 1) ? lst[0] : lst
+ }
+ end
+end
+
+TkNamedVirtualEvent = TkVirtualEvent::PreDefVirtEvent
diff --git a/jni/ruby/ext/tk/lib/tk/winfo.rb b/jni/ruby/ext/tk/lib/tk/winfo.rb
new file mode 100644
index 0000000..b10cfe6
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tk/winfo.rb
@@ -0,0 +1,392 @@
+#
+# tk/winfo.rb : methods for winfo command
+#
+module TkWinfo
+end
+
+require 'tk'
+
+module TkWinfo
+ include Tk
+ extend Tk
+
+ TkCommandNames = ['winfo'.freeze].freeze
+
+ def TkWinfo.atom(name, win=nil)
+ if win
+ number(tk_call_without_enc('winfo', 'atom', '-displayof', win,
+ _get_eval_enc_str(name)))
+ else
+ number(tk_call_without_enc('winfo', 'atom', _get_eval_enc_str(name)))
+ end
+ end
+ def winfo_atom(name)
+ TkWinfo.atom(name, self)
+ end
+
+ def TkWinfo.atomname(id, win=nil)
+ if win
+ _fromUTF8(tk_call_without_enc('winfo', 'atomname',
+ '-displayof', win, id))
+ else
+ _fromUTF8(tk_call_without_enc('winfo', 'atomname', id))
+ end
+ end
+ def winfo_atomname(id)
+ TkWinfo.atomname(id, self)
+ end
+
+ def TkWinfo.cells(win)
+ number(tk_call_without_enc('winfo', 'cells', win))
+ end
+ def winfo_cells
+ TkWinfo.cells self
+ end
+
+ def TkWinfo.children(win)
+ list(tk_call_without_enc('winfo', 'children', win))
+ end
+ def winfo_children
+ TkWinfo.children self
+ end
+
+ def TkWinfo.classname(win)
+ tk_call_without_enc('winfo', 'class', win)
+ end
+ def winfo_classname
+ TkWinfo.classname self
+ end
+ alias winfo_class winfo_classname
+
+ def TkWinfo.colormapfull(win)
+ bool(tk_call_without_enc('winfo', 'colormapfull', win))
+ end
+ def winfo_colormapfull
+ TkWinfo.colormapfull self
+ end
+
+ def TkWinfo.containing(rootX, rootY, win=nil)
+ if win
+ window(tk_call_without_enc('winfo', 'containing',
+ '-displayof', win, rootX, rootY))
+ else
+ window(tk_call_without_enc('winfo', 'containing', rootX, rootY))
+ end
+ end
+ def winfo_containing(x, y)
+ TkWinfo.containing(x, y, self)
+ end
+
+ def TkWinfo.depth(win)
+ number(tk_call_without_enc('winfo', 'depth', win))
+ end
+ def winfo_depth
+ TkWinfo.depth self
+ end
+
+ def TkWinfo.exist?(win)
+ bool(tk_call_without_enc('winfo', 'exists', win))
+ end
+ def winfo_exist?
+ TkWinfo.exist? self
+ end
+
+ def TkWinfo.fpixels(win, dist)
+ number(tk_call_without_enc('winfo', 'fpixels', win, dist))
+ end
+ def winfo_fpixels(dist)
+ TkWinfo.fpixels self, dist
+ end
+
+ def TkWinfo.geometry(win)
+ tk_call_without_enc('winfo', 'geometry', win)
+ end
+ def winfo_geometry
+ TkWinfo.geometry self
+ end
+
+ def TkWinfo.height(win)
+ number(tk_call_without_enc('winfo', 'height', win))
+ end
+ def winfo_height
+ TkWinfo.height self
+ end
+
+ def TkWinfo.id(win)
+ tk_call_without_enc('winfo', 'id', win)
+ end
+ def winfo_id
+ TkWinfo.id self
+ end
+
+ def TkWinfo.interps(win=nil)
+ if win
+ #tk_split_simplelist(tk_call_without_enc('winfo', 'interps',
+ # '-displayof', win))
+ tk_split_simplelist(tk_call_without_enc('winfo', 'interps',
+ '-displayof', win),
+ false, true)
+ else
+ #tk_split_simplelist(tk_call_without_enc('winfo', 'interps'))
+ tk_split_simplelist(tk_call_without_enc('winfo', 'interps'),
+ false, true)
+ end
+ end
+ def winfo_interps
+ TkWinfo.interps self
+ end
+
+ def TkWinfo.mapped?(win)
+ bool(tk_call_without_enc('winfo', 'ismapped', win))
+ end
+ def winfo_mapped?
+ TkWinfo.mapped? self
+ end
+
+ def TkWinfo.manager(win)
+ tk_call_without_enc('winfo', 'manager', win)
+ end
+ def winfo_manager
+ TkWinfo.manager self
+ end
+
+ def TkWinfo.appname(win)
+ tk_call('winfo', 'name', win)
+ end
+ def winfo_appname
+ TkWinfo.appname self
+ end
+
+ def TkWinfo.parent(win)
+ window(tk_call_without_enc('winfo', 'parent', win))
+ end
+ def winfo_parent
+ TkWinfo.parent self
+ end
+
+ def TkWinfo.widget(id, win=nil)
+ if win
+ window(tk_call_without_enc('winfo', 'pathname', '-displayof', win, id))
+ else
+ window(tk_call_without_enc('winfo', 'pathname', id))
+ end
+ end
+ def winfo_widget(id)
+ TkWinfo.widget id, self
+ end
+
+ def TkWinfo.pixels(win, dist)
+ number(tk_call_without_enc('winfo', 'pixels', win, dist))
+ end
+ def winfo_pixels(dist)
+ TkWinfo.pixels self, dist
+ end
+
+ def TkWinfo.reqheight(win)
+ number(tk_call_without_enc('winfo', 'reqheight', win))
+ end
+ def winfo_reqheight
+ TkWinfo.reqheight self
+ end
+
+ def TkWinfo.reqwidth(win)
+ number(tk_call_without_enc('winfo', 'reqwidth', win))
+ end
+ def winfo_reqwidth
+ TkWinfo.reqwidth self
+ end
+
+ def TkWinfo.rgb(win, color)
+ list(tk_call_without_enc('winfo', 'rgb', win, color))
+ end
+ def winfo_rgb(color)
+ TkWinfo.rgb self, color
+ end
+
+ def TkWinfo.rootx(win)
+ number(tk_call_without_enc('winfo', 'rootx', win))
+ end
+ def winfo_rootx
+ TkWinfo.rootx self
+ end
+
+ def TkWinfo.rooty(win)
+ number(tk_call_without_enc('winfo', 'rooty', win))
+ end
+ def winfo_rooty
+ TkWinfo.rooty self
+ end
+
+ def TkWinfo.screen(win)
+ tk_call('winfo', 'screen', win)
+ end
+ def winfo_screen
+ TkWinfo.screen self
+ end
+
+ def TkWinfo.screencells(win)
+ number(tk_call_without_enc('winfo', 'screencells', win))
+ end
+ def winfo_screencells
+ TkWinfo.screencells self
+ end
+
+ def TkWinfo.screendepth(win)
+ number(tk_call_without_enc('winfo', 'screendepth', win))
+ end
+ def winfo_screendepth
+ TkWinfo.screendepth self
+ end
+
+ def TkWinfo.screenheight (win)
+ number(tk_call_without_enc('winfo', 'screenheight', win))
+ end
+ def winfo_screenheight
+ TkWinfo.screenheight self
+ end
+
+ def TkWinfo.screenmmheight(win)
+ number(tk_call_without_enc('winfo', 'screenmmheight', win))
+ end
+ def winfo_screenmmheight
+ TkWinfo.screenmmheight self
+ end
+
+ def TkWinfo.screenmmwidth(win)
+ number(tk_call_without_enc('winfo', 'screenmmwidth', win))
+ end
+ def winfo_screenmmwidth
+ TkWinfo.screenmmwidth self
+ end
+
+ def TkWinfo.screenvisual(win)
+ tk_call_without_enc('winfo', 'screenvisual', win)
+ end
+ def winfo_screenvisual
+ TkWinfo.screenvisual self
+ end
+
+ def TkWinfo.screenwidth(win)
+ number(tk_call_without_enc('winfo', 'screenwidth', win))
+ end
+ def winfo_screenwidth
+ TkWinfo.screenwidth self
+ end
+
+ def TkWinfo.server(win)
+ tk_call('winfo', 'server', win)
+ end
+ def winfo_server
+ TkWinfo.server self
+ end
+
+ def TkWinfo.toplevel(win)
+ window(tk_call_without_enc('winfo', 'toplevel', win))
+ end
+ def winfo_toplevel
+ TkWinfo.toplevel self
+ end
+
+ def TkWinfo.visual(win)
+ tk_call_without_enc('winfo', 'visual', win)
+ end
+ def winfo_visual
+ TkWinfo.visual self
+ end
+
+ def TkWinfo.visualid(win)
+ tk_call_without_enc('winfo', 'visualid', win)
+ end
+ def winfo_visualid
+ TkWinfo.visualid self
+ end
+
+ def TkWinfo.visualsavailable(win, includeids=false)
+ if includeids
+ list(tk_call_without_enc('winfo', 'visualsavailable',
+ win, "includeids"))
+ else
+ list(tk_call_without_enc('winfo', 'visualsavailable', win))
+ end
+ end
+ def winfo_visualsavailable(includeids=false)
+ TkWinfo.visualsavailable self, includeids
+ end
+
+ def TkWinfo.vrootheight(win)
+ number(tk_call_without_enc('winfo', 'vrootheight', win))
+ end
+ def winfo_vrootheight
+ TkWinfo.vrootheight self
+ end
+
+ def TkWinfo.vrootwidth(win)
+ number(tk_call_without_enc('winfo', 'vrootwidth', win))
+ end
+ def winfo_vrootwidth
+ TkWinfo.vrootwidth self
+ end
+
+ def TkWinfo.vrootx(win)
+ number(tk_call_without_enc('winfo', 'vrootx', win))
+ end
+ def winfo_vrootx
+ TkWinfo.vrootx self
+ end
+
+ def TkWinfo.vrooty(win)
+ number(tk_call_without_enc('winfo', 'vrooty', win))
+ end
+ def winfo_vrooty
+ TkWinfo.vrooty self
+ end
+
+ def TkWinfo.width(win)
+ number(tk_call_without_enc('winfo', 'width', win))
+ end
+ def winfo_width
+ TkWinfo.width self
+ end
+
+ def TkWinfo.x(win)
+ number(tk_call_without_enc('winfo', 'x', win))
+ end
+ def winfo_x
+ TkWinfo.x self
+ end
+
+ def TkWinfo.y(win)
+ number(tk_call_without_enc('winfo', 'y', win))
+ end
+ def winfo_y
+ TkWinfo.y self
+ end
+
+ def TkWinfo.viewable(win)
+ bool(tk_call_without_enc('winfo', 'viewable', win))
+ end
+ def winfo_viewable
+ TkWinfo.viewable self
+ end
+
+ def TkWinfo.pointerx(win)
+ number(tk_call_without_enc('winfo', 'pointerx', win))
+ end
+ def winfo_pointerx
+ TkWinfo.pointerx self
+ end
+
+ def TkWinfo.pointery(win)
+ number(tk_call_without_enc('winfo', 'pointery', win))
+ end
+ def winfo_pointery
+ TkWinfo.pointery self
+ end
+
+ def TkWinfo.pointerxy(win)
+ list(tk_call_without_enc('winfo', 'pointerxy', win))
+ end
+ def winfo_pointerxy
+ TkWinfo.pointerxy self
+ end
+end
diff --git a/jni/ruby/ext/tk/lib/tk/winpkg.rb b/jni/ruby/ext/tk/lib/tk/winpkg.rb
new file mode 100644
index 0000000..80e0439
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tk/winpkg.rb
@@ -0,0 +1,156 @@
+#
+# tk/winpkg.rb : methods for Tcl/Tk packages for Microsoft Windows
+# 2000/11/22 by Hidetoshi Nagai <nagai@ai.kyutech.ac.jp>
+#
+# ATTENTION !!
+# This is NOT TESTED. Because I have no test-environment.
+#
+require 'tk'
+
+module Tk::WinDDE
+end
+#TkWinDDE = Tk::WinDDE
+#Tk.__set_toplevel_aliases__(:Tk, Tk::WinDDE, :TkWinDDE)
+Tk.__set_loaded_toplevel_aliases__('tk/winpkg.rb', :Tk, Tk::WinDDE, :TkWinDDE)
+
+module Tk::WinDDE
+ extend Tk
+ extend Tk::WinDDE
+
+ TkCommandNames = ['dde'.freeze].freeze
+
+ PACKAGE_NAME = 'dde'.freeze
+ def self.package_name
+ PACKAGE_NAME
+ end
+
+ if self.const_defined? :FORCE_VERSION
+ tk_call_without_enc('package', 'require', 'dde', FORCE_VERSION)
+ else
+ tk_call_without_enc('package', 'require', 'dde')
+ end
+
+ #def servername(topic=None)
+ # tk_call('dde', 'servername', topic)
+ #end
+ def servername(*args)
+ if args.size == 0
+ tk_call('dde', 'servername')
+ else
+ if args[-1].kind_of?(Hash) # dde 1.2 +
+ keys = _symbolkey2str(args.pop)
+ force = (keys.delete('force'))? '-force': None
+ exact = (keys.delete('exact'))? '-exact': None
+ if keys.size == 0
+ tk_call('dde', 'servername', force, exact)
+ elsif args.size == 0
+ tk_call('dde', 'servername', force, exact, *hash_kv(keys))
+ else
+ tk_call('dde', 'servername', force, exact,
+ *((hash_kv(keys) << '--') + args))
+ end
+ else
+ tk_call('dde', 'servername', *args)
+ end
+ end
+ end
+
+ def execute(service, topic, data)
+ tk_call('dde', 'execute', service, topic, data)
+ end
+
+ def async_execute(service, topic, data)
+ tk_call('dde', '-async', 'execute', service, topic, data)
+ end
+
+ def poke(service, topic, item, data)
+ tk_call('dde', 'poke', service, topic, item, data)
+ end
+
+ def request(service, topic, item)
+ tk_call('dde', 'request', service, topic, item)
+ end
+
+ def binary_request(service, topic, item)
+ tk_call('dde', 'request', '-binary', service, topic, item)
+ end
+
+ def services(service, topic)
+ tk_call('dde', 'services', service, topic)
+ end
+
+ def eval(topic, cmd, *args)
+ tk_call('dde', 'eval', topic, cmd, *args)
+ end
+
+ def async_eval(topic, cmd, *args)
+ tk_call('dde', 'eval', -async, topic, cmd, *args)
+ end
+
+ module_function :servername, :execute, :async_execute,
+ :poke, :request, :services, :eval
+end
+
+module Tk::WinRegistry
+end
+#TkWinRegistry = Tk::WinRegistry
+#Tk.__set_toplevel_aliases__(:Tk, Tk::WinRegistry, :TkWinRegistry)
+Tk.__set_loaded_toplevel_aliases__('tk/winpkg.rb', :Tk, Tk::WinRegistry,
+ :TkWinRegistry)
+
+module Tk::WinRegistry
+ extend Tk
+ extend Tk::WinRegistry
+
+ TkCommandNames = ['registry'.freeze].freeze
+
+ if self.const_defined? :FORCE_VERSION
+ tk_call('package', 'require', 'registry', FORCE_VERSION)
+ else
+ tk_call('package', 'require', 'registry')
+ end
+
+ def broadcast(keynam, timeout=nil)
+ if timeout
+ tk_call('registry', 'broadcast', keynam, '-timeout', timeout)
+ else
+ tk_call('registry', 'broadcast', keynam)
+ end
+ end
+
+ def delete(keynam, valnam=None)
+ tk_call('registry', 'delete', keynam, valnam)
+ end
+
+ def get(keynam, valnam)
+ tk_call('registry', 'get', keynam, valnam)
+ end
+
+ def keys(keynam, pattern=nil)
+ lst = tk_split_simplelist(tk_call('registry', 'keys', keynam))
+ if pattern
+ lst.find_all{|key| key =~ pattern}
+ else
+ lst
+ end
+ end
+
+ def set(keynam, valnam=None, data=None, dattype=None)
+ tk_call('registry', 'set', keynam, valnam, data, dattype)
+ end
+
+ def type(keynam, valnam)
+ tk_call('registry', 'type', keynam, valnam)
+ end
+
+ def values(keynam, pattern=nil)
+ lst = tk_split_simplelist(tk_call('registry', 'values', keynam))
+ if pattern
+ lst.find_all{|val| val =~ pattern}
+ else
+ lst
+ end
+ end
+
+ module_function :delete, :get, :keys, :set, :type, :values
+end
diff --git a/jni/ruby/ext/tk/lib/tk/wm.rb b/jni/ruby/ext/tk/lib/tk/wm.rb
new file mode 100644
index 0000000..fcd5a2c
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tk/wm.rb
@@ -0,0 +1,552 @@
+#
+# tk/wm.rb : methods for wm command
+#
+require 'tk'
+
+module Tk
+ module Wm
+ #include TkComm
+ extend TkCore
+
+ TkCommandNames = ['wm'.freeze].freeze
+
+ TOPLEVEL_METHODCALL_OPTKEYS = {}
+
+ def Wm.aspect(win, *args)
+ if args.length == 0
+ list(tk_call_without_enc('wm', 'aspect', win.epath))
+ else
+ args = args[0] if args.length == 1 && args[0].kind_of?(Array)
+ tk_call('wm', 'aspect', win.epath, *args)
+ win
+ end
+ end
+ def aspect(*args)
+ Wm.aspect(self, *args)
+ end
+ alias wm_aspect aspect
+ TOPLEVEL_METHODCALL_OPTKEYS['aspect'] = 'aspect'
+
+ def Wm.attributes(win, slot=nil,value=TkComm::None)
+ if slot == nil
+ lst = tk_split_list(tk_call('wm', 'attributes', win.epath))
+ info = {}
+ while key = lst.shift
+ info[key[1..-1]] = lst.shift
+ end
+ info
+ elsif slot.kind_of? Hash
+ tk_call('wm', 'attributes', win.epath, *hash_kv(slot))
+ win
+ elsif value == TkComm::None
+ tk_call('wm', 'attributes', win.epath, "-#{slot}")
+ else
+ tk_call('wm', 'attributes', win.epath, "-#{slot}", value)
+ win
+ end
+ end
+ def attributes(slot=nil,value=TkComm::None)
+ Wm.attributes(self, slot, value)
+ end
+ alias wm_attributes attributes
+ TOPLEVEL_METHODCALL_OPTKEYS['attributes'] = 'attributes'
+
+ def Wm.client(win, name=TkComm::None)
+ if name == TkComm::None
+ tk_call('wm', 'client', win.epath)
+ else
+ name = '' if name == nil
+ tk_call('wm', 'client', win.epath, name)
+ win
+ end
+ end
+ def client(name=TkComm::None)
+ Wm.client(self, name)
+ end
+ alias wm_client client
+ TOPLEVEL_METHODCALL_OPTKEYS['client'] = 'client'
+
+ def Wm.colormapwindows(win, *args)
+ if args.size == 0
+ list(tk_call_without_enc('wm', 'colormapwindows', win.epath))
+ else
+ args = args[0] if args.length == 1 && args[0].kind_of?(Array)
+ tk_call_without_enc('wm', 'colormapwindows', win.epath, *args)
+ win
+ end
+ end
+ def colormapwindows(*args)
+ Wm.colormapwindows(self, *args)
+ end
+ alias wm_colormapwindows colormapwindows
+ TOPLEVEL_METHODCALL_OPTKEYS['colormapwindows'] = 'colormapwindows'
+
+ def Wm.command(win, value=nil)
+ if value
+ tk_call('wm', 'command', win.epath, value)
+ win
+ else
+ #procedure(tk_call('wm', 'command', win.epath))
+ tk_call('wm', 'command', win.epath)
+ end
+ end
+ def wm_command(value=nil)
+ Wm.command(self, value)
+ end
+ TOPLEVEL_METHODCALL_OPTKEYS['wm_command'] = 'wm_command'
+
+ def Wm.deiconify(win, ex = true)
+ if ex
+ tk_call_without_enc('wm', 'deiconify', win.epath)
+ else
+ Wm.iconify(win)
+ end
+ win
+ end
+ def deiconify(ex = true)
+ Wm.deiconify(self, ex)
+ end
+ alias wm_deiconify deiconify
+
+ def Wm.focusmodel(win, mode = nil)
+ if mode
+ tk_call_without_enc('wm', 'focusmodel', win.epath, mode)
+ win
+ else
+ tk_call_without_enc('wm', 'focusmodel', win.epath)
+ end
+ end
+ def focusmodel(mode = nil)
+ Wm.focusmodel(self, mode)
+ end
+ alias wm_focusmodel focusmodel
+ TOPLEVEL_METHODCALL_OPTKEYS['focusmodel'] = 'focusmodel'
+
+ def Wm.forget(win)
+ # Tcl/Tk 8.5+
+ # work with dockable frames
+ tk_call_without_enc('wm', 'forget', win.epath)
+ win
+ end
+ def wm_forget
+ Wm.forget(self)
+ end
+
+ def Wm.frame(win)
+ tk_call_without_enc('wm', 'frame', win.epath)
+ end
+ def frame
+ Wm.frame(self)
+ end
+ alias wm_frame frame
+
+ def Wm.geometry(win, geom=nil)
+ if geom
+ tk_call_without_enc('wm', 'geometry', win.epath, geom)
+ win
+ else
+ tk_call_without_enc('wm', 'geometry', win.epath)
+ end
+ end
+ def geometry(geom=nil)
+ Wm.geometry(self, geom)
+ end
+ alias wm_geometry geometry
+ TOPLEVEL_METHODCALL_OPTKEYS['geometry'] = 'geometry'
+
+ def Wm.grid(win, *args)
+ if args.size == 0
+ list(tk_call_without_enc('wm', 'grid', win.epath))
+ else
+ args = args[0] if args.length == 1 && args[0].kind_of?(Array)
+ tk_call_without_enc('wm', 'grid', win.epath, *args)
+ win
+ end
+ end
+ def wm_grid(*args)
+ Wm.grid(self, *args)
+ end
+ TOPLEVEL_METHODCALL_OPTKEYS['wm_grid'] = 'wm_grid'
+
+ def Wm.group(win, leader = nil)
+ if leader
+ tk_call('wm', 'group', win.epath, leader)
+ win
+ else
+ window(tk_call('wm', 'group', win.epath))
+ end
+ end
+ def group(leader = nil)
+ Wm.group(self, leader)
+ end
+ alias wm_group group
+ TOPLEVEL_METHODCALL_OPTKEYS['group'] = 'group'
+
+ def Wm.iconbitmap(win, bmp=nil)
+ if bmp
+ tk_call_without_enc('wm', 'iconbitmap', win.epath, bmp)
+ win
+ else
+ image_obj(tk_call_without_enc('wm', 'iconbitmap', win.epath))
+ end
+ end
+ def iconbitmap(bmp=nil)
+ Wm.iconbitmap(self, bmp)
+ end
+ alias wm_iconbitmap iconbitmap
+ TOPLEVEL_METHODCALL_OPTKEYS['iconbitmap'] = 'iconbitmap'
+
+ def Wm.iconphoto(win, *imgs)
+ if imgs.empty?
+ win.instance_eval{
+ @wm_iconphoto = nil unless defined? @wm_iconphoto
+ return @wm_iconphoto
+ }
+ end
+
+ imgs = imgs[0] if imgs.length == 1 && imgs[0].kind_of?(Array)
+ tk_call_without_enc('wm', 'iconphoto', win.epath, *imgs)
+ win.instance_eval{ @wm_iconphoto = imgs }
+ win
+ end
+ def iconphoto(*imgs)
+ Wm.iconphoto(self, *imgs)
+ end
+ alias wm_iconphoto iconphoto
+ TOPLEVEL_METHODCALL_OPTKEYS['iconphoto'] = 'iconphoto'
+
+ def Wm.iconphoto_default(win, *imgs)
+ imgs = imgs[0] if imgs.length == 1 && imgs[0].kind_of?(Array)
+ tk_call_without_enc('wm', 'iconphoto', win.epath, '-default', *imgs)
+ win
+ end
+ def iconphoto_default(*imgs)
+ Wm.iconphoto_default(self, *imgs)
+ end
+ alias wm_iconphoto_default iconphoto_default
+
+ def Wm.iconify(win, ex = true)
+ if ex
+ tk_call_without_enc('wm', 'iconify', win.epath)
+ else
+ Wm.deiconify(win)
+ end
+ win
+ end
+ def iconify(ex = true)
+ Wm.iconify(self, ex)
+ end
+ alias wm_iconify iconify
+
+ def Wm.iconmask(win, bmp=nil)
+ if bmp
+ tk_call_without_enc('wm', 'iconmask', win.epath, bmp)
+ win
+ else
+ image_obj(tk_call_without_enc('wm', 'iconmask', win.epath))
+ end
+ end
+ def iconmask(bmp=nil)
+ Wm.iconmask(self, bmp)
+ end
+ alias wm_iconmask iconmask
+ TOPLEVEL_METHODCALL_OPTKEYS['iconmask'] = 'iconmask'
+
+ def Wm.iconname(win, name=nil)
+ if name
+ tk_call('wm', 'iconname', win.epath, name)
+ win
+ else
+ tk_call('wm', 'iconname', win.epath)
+ end
+ end
+ def iconname(name=nil)
+ Wm.iconname(self, name)
+ end
+ alias wm_iconname iconname
+ TOPLEVEL_METHODCALL_OPTKEYS['iconname'] = 'iconname'
+
+ def Wm.iconposition(win, *args)
+ if args.size == 0
+ list(tk_call_without_enc('wm', 'iconposition', win.epath))
+ else
+ args = args[0] if args.length == 1 && args[0].kind_of?(Array)
+ tk_call_without_enc('wm', 'iconposition', win.epath, *args)
+ win
+ end
+ end
+ def iconposition(*args)
+ Wm.iconposition(self, *args)
+ end
+ alias wm_iconposition iconposition
+ TOPLEVEL_METHODCALL_OPTKEYS['iconposition'] = 'iconposition'
+
+ def Wm.iconwindow(win, iconwin = nil)
+ if iconwin
+ tk_call_without_enc('wm', 'iconwindow', win.epath, iconwin)
+ win
+ else
+ w = tk_call_without_enc('wm', 'iconwindow', win.epath)
+ (w == '')? nil: window(w)
+ end
+ end
+ def iconwindow(iconwin = nil)
+ Wm.iconwindow(self, iconwin)
+ end
+ alias wm_iconwindow iconwindow
+ TOPLEVEL_METHODCALL_OPTKEYS['iconwindow'] = 'iconwindow'
+
+ def Wm.manage(win)
+ # Tcl/Tk 8.5+ feature
+ tk_call_without_enc('wm', 'manage', win.epath)
+ win
+ end
+ def wm_manage
+ Wm.manage(self)
+ end
+=begin
+ def Wm.manage(win, use_id = nil)
+ # Tcl/Tk 8.5+ feature
+ # --------------------------------------------------------------
+ # In the future release, I want to support to embed the 'win'
+ # into the container which has window-id 'use-id'.
+ # It may give users frexibility on controlling their GUI.
+ # However, it may be difficult for current Tcl/Tk (Tcl/Tk8.5.1),
+ # because it seems to require to modify Tcl/Tk's source code.
+ # --------------------------------------------------------------
+ if use_id
+ tk_call_without_enc('wm', 'manage', win.epath, '-use', use_id)
+ else
+ tk_call_without_enc('wm', 'manage', win.epath)
+ end
+ win
+ end
+=end
+
+ def Wm.maxsize(win, *args)
+ if args.size == 0
+ list(tk_call_without_enc('wm', 'maxsize', win.epath))
+ else
+ args = args[0] if args.length == 1 && args[0].kind_of?(Array)
+ tk_call_without_enc('wm', 'maxsize', win.epath, *args)
+ win
+ end
+ end
+ def maxsize(*args)
+ Wm.maxsize(self, *args)
+ end
+ alias wm_maxsize maxsize
+ TOPLEVEL_METHODCALL_OPTKEYS['maxsize'] = 'maxsize'
+
+ def Wm.minsize(win, *args)
+ if args.size == 0
+ list(tk_call_without_enc('wm', 'minsize', win.epath))
+ else
+ args = args[0] if args.length == 1 && args[0].kind_of?(Array)
+ tk_call_without_enc('wm', 'minsize', win.path, *args)
+ win
+ end
+ end
+ def minsize(*args)
+ Wm.minsize(self, *args)
+ end
+ alias wm_minsize minsize
+ TOPLEVEL_METHODCALL_OPTKEYS['minsize'] = 'minsize'
+
+ def Wm.overrideredirect(win, mode=TkComm::None)
+ if mode == TkComm::None
+ bool(tk_call_without_enc('wm', 'overrideredirect', win.epath))
+ else
+ tk_call_without_enc('wm', 'overrideredirect', win.epath, mode)
+ win
+ end
+ end
+ def overrideredirect(mode=TkComm::None)
+ Wm.overrideredirect(self, mode)
+ end
+ alias wm_overrideredirect overrideredirect
+ TOPLEVEL_METHODCALL_OPTKEYS['overrideredirect'] = 'overrideredirect'
+
+ def Wm.positionfrom(win, who=TkComm::None)
+ if who == TkComm::None
+ r = tk_call_without_enc('wm', 'positionfrom', win.epath)
+ (r == "")? nil: r
+ else
+ tk_call_without_enc('wm', 'positionfrom', win.epath, who)
+ win
+ end
+ end
+ def positionfrom(who=TkComm::None)
+ Wm.positionfrom(self, who)
+ end
+ alias wm_positionfrom positionfrom
+ TOPLEVEL_METHODCALL_OPTKEYS['positionfrom'] = 'positionfrom'
+
+ def Wm.protocol(win, name=nil, cmd=nil, &b)
+ if cmd
+ tk_call_without_enc('wm', 'protocol', win.epath, name, cmd)
+ win
+ elsif b
+ tk_call_without_enc('wm', 'protocol', win.epath, name, proc(&b))
+ win
+ elsif name
+ result = tk_call_without_enc('wm', 'protocol', win.epath, name)
+ (result == "")? nil : tk_tcl2ruby(result)
+ else
+ tk_split_simplelist(tk_call_without_enc('wm', 'protocol', win.epath))
+ end
+ end
+ def protocol(name=nil, cmd=nil, &b)
+ Wm.protocol(self, name, cmd, &b)
+ end
+ alias wm_protocol protocol
+
+ def Wm.protocols(win, kv=nil)
+ unless kv
+ ret = {}
+ Wm.protocol(win).each{|name|
+ ret[name] = Wm.protocol(win, name)
+ }
+ return ret
+ end
+
+ unless kv.kind_of?(Hash)
+ fail ArgumentError, 'expect a hash of protocol=>command'
+ end
+ kv.each{|k, v| Wm.protocol(win, k, v)}
+ win
+ end
+ def protocols(kv=nil)
+ Wm.protocols(self, kv)
+ end
+ alias wm_protocols protocols
+ TOPLEVEL_METHODCALL_OPTKEYS['protocols'] = 'protocols'
+
+ def Wm.resizable(win, *args)
+ if args.length == 0
+ list(tk_call_without_enc('wm', 'resizable', win.epath)).map!{|e| bool(e)}
+ else
+ args = args[0] if args.length == 1 && args[0].kind_of?(Array)
+ tk_call_without_enc('wm', 'resizable', win.epath, *args)
+ win
+ end
+ end
+ def resizable(*args)
+ Wm.resizable(self, *args)
+ end
+ alias wm_resizable resizable
+ TOPLEVEL_METHODCALL_OPTKEYS['resizable'] = 'resizable'
+
+ def Wm.sizefrom(win, who=TkComm::None)
+ if who == TkComm::None
+ r = tk_call_without_enc('wm', 'sizefrom', win.epath)
+ (r == "")? nil: r
+ else
+ tk_call_without_enc('wm', 'sizefrom', win.epath, who)
+ win
+ end
+ end
+ def sizefrom(who=TkComm::None)
+ Wm.sizefrom(self, who)
+ end
+ alias wm_sizefrom sizefrom
+ TOPLEVEL_METHODCALL_OPTKEYS['sizefrom'] = 'sizefrom'
+
+ def Wm.stackorder(win)
+ list(tk_call('wm', 'stackorder', win.epath))
+ end
+ def stackorder
+ Wm.stackorder(self)
+ end
+ alias wm_stackorder stackorder
+
+ def Wm.stackorder_isabove(win, target)
+ bool(tk_call('wm', 'stackorder', win.epath, 'isabove', target))
+ end
+ def Wm.stackorder_is_above(win, target)
+ Wm.stackorder_isabove(win, target)
+ end
+ def stackorder_isabove(target)
+ Wm.stackorder_isabove(self, target)
+ end
+ alias stackorder_is_above stackorder_isabove
+ alias wm_stackorder_isabove stackorder_isabove
+ alias wm_stackorder_is_above stackorder_isabove
+
+ def Wm.stackorder_isbelow(win, target)
+ bool(tk_call('wm', 'stackorder', win.epath, 'isbelow', target))
+ end
+ def Wm.stackorder_is_below(win, target)
+ Wm.stackorder_isbelow(win, target)
+ end
+ def stackorder_isbelow(target)
+ Wm.stackorder_isbelow(self, target)
+ end
+ alias stackorder_is_below stackorder_isbelow
+ alias wm_stackorder_isbelow stackorder_isbelow
+ alias wm_stackorder_is_below stackorder_isbelow
+
+ def Wm.state(win, st=nil)
+ if st
+ tk_call_without_enc('wm', 'state', win.epath, st)
+ win
+ else
+ tk_call_without_enc('wm', 'state', win.epath)
+ end
+ end
+ def state(st=nil)
+ Wm.state(self, st)
+ end
+ alias wm_state state
+ TOPLEVEL_METHODCALL_OPTKEYS['state'] = 'state'
+
+ def Wm.title(win, str=nil)
+ if str
+ tk_call('wm', 'title', win.epath, str)
+ win
+ else
+ tk_call('wm', 'title', win.epath)
+ end
+ end
+ def title(str=nil)
+ Wm.title(self, str)
+ end
+ alias wm_title title
+ TOPLEVEL_METHODCALL_OPTKEYS['title'] = 'title'
+
+ def Wm.transient(win, master=nil)
+ if master
+ tk_call_without_enc('wm', 'transient', win.epath, master)
+ win
+ else
+ window(tk_call_without_enc('wm', 'transient', win.epath))
+ end
+ end
+ def transient(master=nil)
+ Wm.transient(self, master)
+ end
+ alias wm_transient transient
+ TOPLEVEL_METHODCALL_OPTKEYS['transient'] = 'transient'
+
+ def Wm.withdraw(win, ex = true)
+ if ex
+ tk_call_without_enc('wm', 'withdraw', win.epath)
+ else
+ Wm.deiconify(win)
+ end
+ win
+ end
+ def withdraw(ex = true)
+ Wm.withdraw(self, ex)
+ end
+ alias wm_withdraw withdraw
+ end
+
+ module Wm_for_General
+ Wm.instance_methods.each{|m|
+ if (m = m.to_s) =~ /^wm_(.*)$/
+ eval "def #{m}(*args, &b); Tk::Wm.#{$1}(self, *args, &b); end"
+ end
+ }
+ end
+end
diff --git a/jni/ruby/ext/tk/lib/tk/xim.rb b/jni/ruby/ext/tk/lib/tk/xim.rb
new file mode 100644
index 0000000..c0126c5
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tk/xim.rb
@@ -0,0 +1,122 @@
+#
+# tk/xim.rb : control imput_method
+#
+require 'tk'
+
+module TkXIM
+ include Tk
+ extend Tk
+
+ TkCommandNames = ['imconfigure'.freeze].freeze
+
+ def TkXIM.useinputmethods(value = None, win = nil)
+ if value == None
+ if win
+ bool(tk_call_without_enc('tk', 'useinputmethods',
+ '-displayof', win))
+ else
+ bool(tk_call_without_enc('tk', 'useinputmethods'))
+ end
+ else
+ if win
+ bool(tk_call_without_enc('tk', 'useinputmethods',
+ '-displayof', win, value))
+ else
+ bool(tk_call_without_enc('tk', 'useinputmethods', value))
+ end
+ end
+ end
+
+ def TkXIM.useinputmethods_displayof(win, value = None)
+ TkXIM.useinputmethods(value, win)
+ end
+
+ def TkXIM.caret(win, keys=nil)
+ if keys
+ tk_call_without_enc('tk', 'caret', win, *hash_kv(keys))
+ self
+ else
+ lst = tk_split_list(tk_call_without_enc('tk', 'caret', win))
+ info = {}
+ while key = lst.shift
+ info[key[1..-1]] = lst.shift
+ end
+ info
+ end
+ end
+
+ def TkXIM.configure(win, slot, value=None)
+ begin
+ if /^8\.*/ === Tk::TK_VERSION && JAPANIZED_TK
+ if slot.kind_of? Hash
+ tk_call('imconfigure', win, *hash_kv(slot))
+ else
+ tk_call('imconfigure', win, "-#{slot}", value)
+ end
+ end
+ rescue
+ end
+ end
+
+ def TkXIM.configinfo(win, slot=nil)
+ if TkComm::GET_CONFIGINFOwoRES_AS_ARRAY
+ begin
+ if /^8\.*/ === Tk::TK_VERSION && JAPANIZED_TK
+ if slot
+ conf = tk_split_list(tk_call('imconfigure', win, "-#{slot}"))
+ conf[0] = conf[0][1..-1]
+ conf
+ else
+ tk_split_list(tk_call('imconfigure', win)).collect{|conf|
+ conf[0] = conf[0][1..-1]
+ conf
+ }
+ end
+ else
+ []
+ end
+ rescue
+ []
+ end
+ else # ! TkComm::GET_CONFIGINFOwoRES_AS_ARRAY
+ TkXIM.current_configinfo(win, slot)
+ end
+ end
+
+ def TkXIM.current_configinfo(win, slot=nil)
+ begin
+ if /^8\.*/ === Tk::TK_VERSION && JAPANIZED_TK
+ if slot
+ conf = tk_split_list(tk_call('imconfigure', win, "-#{slot}"))
+ { conf[0][1..-1] => conf[1] }
+ else
+ ret = {}
+ tk_split_list(tk_call('imconfigure', win)).each{|conf|
+ ret[conf[0][1..-1]] = conf[1]
+ }
+ ret
+ end
+ else
+ {}
+ end
+ rescue
+ {}
+ end
+ end
+
+ def useinputmethods(value=None)
+ TkXIM.useinputmethods(value, self)
+ end
+
+ def caret(keys=nil)
+ TkXIM.caret(self, keys=nil)
+ end
+
+ def imconfigure(slot, value=None)
+ TkXIM.configure(self, slot, value)
+ end
+
+ def imconfiginfo(slot=nil)
+ TkXIM.configinfo(self, slot)
+ end
+end
diff --git a/jni/ruby/ext/tk/lib/tkafter.rb b/jni/ruby/ext/tk/lib/tkafter.rb
new file mode 100644
index 0000000..f659458
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkafter.rb
@@ -0,0 +1,4 @@
+#
+# tkafter.rb - load tk/after.rb
+#
+require 'tk/timer'
diff --git a/jni/ruby/ext/tk/lib/tkbgerror.rb b/jni/ruby/ext/tk/lib/tkbgerror.rb
new file mode 100644
index 0000000..deba7a5
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkbgerror.rb
@@ -0,0 +1,4 @@
+#
+# tkbgerror.rb - load tk/bgerror.rb
+#
+require 'tk/bgerror'
diff --git a/jni/ruby/ext/tk/lib/tkcanvas.rb b/jni/ruby/ext/tk/lib/tkcanvas.rb
new file mode 100644
index 0000000..9524614
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkcanvas.rb
@@ -0,0 +1,4 @@
+#
+# tkcanvas.rb - load tk/canvas.rb
+#
+require 'tk/canvas'
diff --git a/jni/ruby/ext/tk/lib/tkclass.rb b/jni/ruby/ext/tk/lib/tkclass.rb
new file mode 100644
index 0000000..9918ce6
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkclass.rb
@@ -0,0 +1,47 @@
+#
+# tkclass.rb - Tk classes
+# Date: 2000/11/27 09:23:36
+# by Yukihiro Matsumoto <matz@caelum.co.jp>
+#
+# $Id: tkclass.rb 25189 2009-10-02 12:04:37Z akr $
+
+require "tk"
+
+TopLevel = TkToplevel
+Frame = TkFrame
+Label = TkLabel
+Button = TkButton
+Radiobutton = TkRadioButton
+Checkbutton = TkCheckButton
+Message = TkMessage
+Entry = TkEntry
+Spinbox = TkSpinbox
+Text = TkText
+Scale = TkScale
+Scrollbar = TkScrollbar
+Listbox = TkListbox
+Menu = TkMenu
+Menubutton = TkMenubutton
+Canvas = TkCanvas
+Arc = TkcArc
+Bitmap = TkcBitmap
+Line = TkcLine
+Oval = TkcOval
+Polygon = TkcPolygon
+Rectangle = TkcRectangle
+TextItem = TkcText
+WindowItem = TkcWindow
+BitmapImage = TkBitmapImage
+PhotoImage = TkPhotoImage
+Selection = TkSelection
+Winfo = TkWinfo
+Pack = TkPack
+Grid = TkGrid
+Place = TkPlace
+Variable = TkVariable
+Font = TkFont
+VirtualEvent = TkVirtualEvent
+
+def Mainloop
+ Tk.mainloop
+end
diff --git a/jni/ruby/ext/tk/lib/tkconsole.rb b/jni/ruby/ext/tk/lib/tkconsole.rb
new file mode 100644
index 0000000..9960ddb
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkconsole.rb
@@ -0,0 +1,4 @@
+#
+# tkconsole.rb - load tk/console.rb
+#
+require 'tk/console'
diff --git a/jni/ruby/ext/tk/lib/tkdialog.rb b/jni/ruby/ext/tk/lib/tkdialog.rb
new file mode 100644
index 0000000..bec5e5d
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkdialog.rb
@@ -0,0 +1,4 @@
+#
+# tkdialog.rb - load tk/dialog.rb
+#
+require 'tk/dialog'
diff --git a/jni/ruby/ext/tk/lib/tkentry.rb b/jni/ruby/ext/tk/lib/tkentry.rb
new file mode 100644
index 0000000..2dcfcab
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkentry.rb
@@ -0,0 +1,4 @@
+#
+# tkentry.rb - load tk/entry.rb
+#
+require 'tk/entry'
diff --git a/jni/ruby/ext/tk/lib/tkextlib/ICONS.rb b/jni/ruby/ext/tk/lib/tkextlib/ICONS.rb
new file mode 100644
index 0000000..18d84c0
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/ICONS.rb
@@ -0,0 +1,13 @@
+#
+# ICONS support
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+
+# call setup script for general 'tkextlib' libraries
+require 'tkextlib/setup.rb'
+
+# call setup script
+require 'tkextlib/ICONS/setup.rb'
+
+# load library
+require 'tkextlib/ICONS/icons'
diff --git a/jni/ruby/ext/tk/lib/tkextlib/ICONS/icons.rb b/jni/ruby/ext/tk/lib/tkextlib/ICONS/icons.rb
new file mode 100644
index 0000000..bd3180a
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/ICONS/icons.rb
@@ -0,0 +1,129 @@
+#
+# tkextlib/ICONS/icons.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+
+require 'tk'
+
+# call setup script for general 'tkextlib' libraries
+require 'tkextlib/setup.rb'
+
+# call setup script
+require 'tkextlib/ICONS/setup.rb'
+
+# TkPackage.require('icons', '1.0')
+TkPackage.require('icons')
+
+module Tk
+ class ICONS < TkImage
+ extend Tk
+
+ PACKAGE_NAME = 'icons'.freeze
+ def self.package_name
+ PACKAGE_NAME
+ end
+
+ def self.package_version
+ begin
+ TkPackage.require('icons')
+ rescue
+ ''
+ end
+ end
+
+ def self.create(*args) # icon, icon, ..., ?option=>value, ...?
+ if args[-1].kind_of?(Hash)
+ keys = args.pop
+ icons = simplelist(tk_call('::icons::icons', 'create',
+ *(hash_kv(keys) << (args.flatten))))
+ else
+ icons = simplelist(tk_call('::icons::icons', 'create',
+ args.flatten))
+ end
+
+ icons.collect{|icon| self.new(icon, :without_creating=>true)}
+ end
+
+ def self.delete(*icons) # icon, icon, ...
+ icons = icons.flatten
+ return if icons.empty?
+ icons.map!{|icon|
+ if icon.kind_of?(Tk::ICONS)
+ Tk_IMGTBL.delete(icon.path)
+ icon.name
+ elsif icon.to_s =~ /^::icon::(.*)/
+ name = $1
+ Tk_IMGTBL.delete(icon)
+ name
+ else
+ Tk_IMGTBL.delete("::icon::#{icon}")
+ icon
+ end
+ }
+ tk_call('::icons::icons', 'delete', icons)
+ end
+
+ def self.query(*args) # icon, icon, ..., ?option=>value, ...?
+ if args[-1].kind_of?(Hash)
+ keys = args.pop
+ simplelist(tk_call('::icons::icons', 'query',
+ *(hash_kv(keys) << (args.flatten))))
+ else
+ simplelist(tk_call('::icons::icons', 'query', args.flatten))
+ end . map{|inf| list(inf) }
+ end
+
+ ##########################################
+
+ class << self
+ alias _new new
+
+ def new(name, keys=nil)
+ if obj = Tk_IMGTBL["::icon::#{name}"]
+ if keys
+ keys = _symbolkey2str(keys)
+ unless keys.delete('without_creating')
+ tk_call('::icons::icons', 'create', *(hash_kv(keys) << obj.name))
+ end
+ end
+ else
+ obj = _new(name, keys)
+ end
+ obj
+ end
+ end
+
+ ##########################################
+
+ def initialize(name, keys=nil)
+ if name.kind_of?(String) && name =~ /^::icon::(.+)$/
+ @name = $1
+ @path = name
+ else
+ @name = name.to_s
+ @path = "::icon::#{@name}"
+ end
+ keys = _symbolkey2str(keys)
+ unless keys.delete('without_creating')
+ tk_call('::icons::icons', 'create', *(hash_kv(keys) << @name))
+ end
+ Tk_IMGTBL[@path] = self
+ end
+
+ def name
+ @name
+ end
+
+ def delete
+ Tk_IMGTBL.delete(@path)
+ tk_call('::icons::icons', 'delete', @name)
+ self
+ end
+
+ def query(keys={})
+ list(simplelist(tk_call('::icons::icons', 'query',
+ *(hash_kv(keys) << @name))
+ )[0])
+ end
+ end
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/ICONS/setup.rb b/jni/ruby/ext/tk/lib/tkextlib/ICONS/setup.rb
new file mode 100644
index 0000000..ee406c6
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/ICONS/setup.rb
@@ -0,0 +1,8 @@
+#
+# setup.rb -- setup script before calling TkPackage.require()
+#
+# If you need some setup operations (for example, add a library path
+# to the library search path) before using Tcl/Tk library packages
+# wrapped by Ruby scripts in this directory, please write the setup
+# operations in this file.
+#
diff --git a/jni/ruby/ext/tk/lib/tkextlib/SUPPORT_STATUS b/jni/ruby/ext/tk/lib/tkextlib/SUPPORT_STATUS
new file mode 100644
index 0000000..de51c51
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/SUPPORT_STATUS
@@ -0,0 +1,193 @@
+
+ [ current support status of Tcl/Tk extensions ]
+
+ *** RELEASE_DATE of the libraries => see 'tkextlib/version.rb' ***
+
+The following list shows *CURRENT* status when this file was modified
+at last. If you want to add other Tcl/Tk extensions to the planed list
+(or change its status position), please request them at the ruby-talk,
+ruby-list, or ruby-dev ML. Although we cannot promise to support your
+requests, we'll try to do.
+
+If you want to check that wrapper libraries are ready to use on your
+environment, please execute 'pkg_checker.rb' with no arguments. The
+script may give you some hints about that.
+
+
+ ***** IMPORTANT NOTE **********************************************
+
+ 'support' means that Ruby/Tk's wrapper libraries are released.
+ 'not support' does *NOT* mean that the extension doesn't work
+ on Ruby/Tk.
+
+ The version number of each extension means the latest version
+ which is checked its feature. That is, it does NOT means only
+ version of working. Library files maybe include some features
+ which is included in the former version but removed from the
+ latest, and maybe able to support the later version then the
+ shown version.
+
+ Even if the status of the extension is 'not support', you can
+ control the functions/widgets of the extension without wrapper
+ libraries by Tk.tk_call(), Tk.ip_eval(), and so on.
+
+ If you cannot use installed Tcl/Tk extension, please check the
+ followings.
+
+ (1) On your Tcl/Tk, does the extension work?
+
+ (2) Do DLL libraries of the extension exist on DLL load-path?
+ (See also "<ruby archive>/ext/tcltklib/README.ActiveTcl")
+
+ (3) Is the Tcl library directory of the extension included in
+ library search-path of the Tcl interpreter linked Ruby/Tk?
+
+ The check results may request you to do some setup operations
+ before using the extension. If so, then please write the step
+ of setup operations into the "setup.rb" file in the directory
+ of the wrapper libraries for the extension (It is the wrapper
+ libraries have the standard structure of the libraries in this
+ directory). The "setup" file is required before requiring the
+ Tcl library package (TkPackage.require(<libname>)).
+
+ *******************************************************************
+
+
+===< support with some examples (may be beta quality) >=======================
+
+Tcllib 1.11.1
+Tklib 0.5 http://sourceforge.net/projects/tcllib ==> tcllib
+ ( partial support; primary support target is Tklib)
+
+IWidgets 4.0.2 http://sourceforge.net/projects/incrtcl ==> iwidgets
+
+BWidget 1.8 [ CVS/Hd(2009-07-02) ]
+ http://sourceforge.net/projects/tcllib ==> bwidget
+
+TkTable 2.10 http://sourceforge.net/projects/tktable ==> tktable
+ * see also <http://www.korus.hu/~fery/ruby/tktable.rb>
+ written by Ferenc Engard (ferenc@engard.hu)
+
+Vu widgets 2.3.0 http://sourceforge.net/projects/tktable ==> vu
+
+TkHTML 2.0 http://www.hwaci.com/sw/tkhtml/ ==> tkHTML
+
+ICONS 1.0 http://www.satisoft.com/tcltk/icons/ ==> ICONS
+
+TkImg 1.3 http://sourceforge.net/projects/tkimg ==> tkimg
+
+
+BLT 2.4z http://sourceforge.net/projects/blt ==> blt
+
+TkTreeCtrl 2.2.9
+ http://tktreectrl.sourceforge.net/ ==> treectrl
+
+Tile 0.8.3/8.6b1
+ http://sourceforge.net/projects/tktable ==> tile
+
+
+
+===< support (may be alpha or beta quality) >=================================
+
+IncrTcl CVS/Hd(2008-12-15)
+ http://sourceforge.net/projects/incrtcl ==> itcl, itk
+
+TclX CVS/Hd(2008-12-15)
+ http://sourceforge.net/projects/tclx
+ ==> tclx (partial support; infox command and
+ XPG/3 message catalogs only)
+
+Trofs 0.4.4 http://math.nist.gov/~DPorter/tcltk/trofs/
+
+
+
+===< possibly available (not tested; alpha quality) >=========================
+
+winico 0.6
+ http://sourceforge.net/projects/tktable
+ ==> winico (win32 only)
+
+TkTrans latest(2004-10-11)
+ http://www2.cmp.uea.ac.uk/~fuzz/tktrans/default.html
+ ==> tktrans (win32 only)
+
+TkDND 1.0a2 http://sourceforge.net/projects/tkdnd ==> tkDND
+
+
+
+===< plan to support (alpha quality libraries may be included) >==============
+
+GraphViz *** http://www.graphviz.org/
+
+Tkgeomap *** http://tkgeomap.sourceforge.net/index.html
+
+
+
+===< not determined to supprt or not >========================================
+
+Tix *** http://tixlibrary.sourceforge.net/
+
+TkZinc *** http://www.tkzinc.org/
+
+Wbc *** http://home.t-online.de/home/csaba.nemethi/
+
+Mentry *** http://home.t-online.de/home/csaba.nemethi/
+
+Tablelist *** http://home.t-online.de/home/csaba.nemethi/
+
+ANIGIF *** http://cardtable.sourceforge.net/tcltk/
+
+IMG_ROTATE *** http://cardtable.sourceforge.net/tcltk/
+
+TclVfs *** http://sourceforge.net/projects/tclvfs/
+
+vfwtcl *** http://sourceforge.net/projects/avicaptcl
+ * Win32 only
+
+multicast *** http://sourceforge.net/projects/avicaptcl
+ * Win32 only
+
+XBit *** http://www.geocities.com/~chengye/
+ * current implementation is for Windows only
+
+QuickTimeTcl *** http://hem.fyristorg.com/matben/qt/
+ * works under Mac OS (8,9,X) or Windows
+
+
+
+===< may not support (already exist, out of Ruby/Tk scope, and so on) >=======
+
+TkCon *** http://sourceforge.net/projects/tkcon
+
+Expect *** http://sourceforge.net/projects/expect
+
+TclXML *** http://sourceforge.net/projects/tclxml
+
+TclXSLT *** http://sourceforge.net/projects/tclxml
+
+TclDOM *** http://sourceforge.net/projects/tclxml
+
+TclSOAP *** http://sourceforge.net/projects/tclsoap
+
+Snack *** http://www.speech.kth.se/~kare/snack2.2.tar.gz
+ * use Snack for Ruby
+ (see http://rbsnack.sourceforge.net/)
+
+Tcom *** http://www.vex.net/~cthuang/tcom/
+
+tDOM *** http://www.tdom.org
+
+Mk4tcl *** http://www.equi4.com/metakit/tcl.html
+
+Memchan *** http://sourceforge.net/projects/memchan
+
+XOTcl *** http://www.xotcl.org/
+
+
+===< tool (may not supprt) >==================================================
+
+tbcload/tclcompiler
+ *** http://www.tcl.tk/software/tclpro/
+
+
+(End of List)
diff --git a/jni/ruby/ext/tk/lib/tkextlib/blt.rb b/jni/ruby/ext/tk/lib/tkextlib/blt.rb
new file mode 100644
index 0000000..8b132e4
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/blt.rb
@@ -0,0 +1,189 @@
+#
+# BLT support
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+
+require 'tk'
+require 'tk/variable'
+
+# call setup script for general 'tkextlib' libraries
+require 'tkextlib/setup.rb'
+
+# call setup script
+require 'tkextlib/blt/setup.rb'
+
+# load all image format handlers
+#TkPackage.require('BLT', '2.4')
+TkPackage.require('BLT')
+
+module Tk
+ module BLT
+ TkComm::TkExtlibAutoloadModule.unshift(self)
+ # Require autoload-symbols which is a same name as widget classname.
+ # Those are used at TkComm._genobj_for_tkwidget method.
+
+ extend TkCore
+
+ VERSION = tk_call('set', 'blt_version')
+ PATCH_LEVEL = tk_call('set', 'blt_patchLevel')
+
+ begin
+ lib = TkCore::INTERP._invoke('set', 'blt_library')
+ rescue
+ lib = ''
+ end
+ LIBRARY = TkVarAccess.new('blt_library', lib)
+
+ begin
+ lib = TkCore::INTERP._invoke('set', 'blt_libPath')
+ rescue
+ lib = ''
+ end
+ LIB_PATH = TkVarAccess.new('blt_libPath', lib)
+
+ PACKAGE_NAME = 'BLT'.freeze
+ def self.package_name
+ PACKAGE_NAME
+ end
+
+ def self.package_version
+ begin
+ TkPackage.require('BLT')
+ rescue
+ ''
+ end
+ end
+
+ ####################################################
+
+ def self.beep(percent = 50)
+ tk_call('::blt::beep', percent)
+ end
+
+ def self.bgexec(*args)
+ if args[0].kind_of?(TkVariable)
+ var = args.shift
+ else
+ var = TkVariable.new
+ end
+ params = [var]
+
+ params.concat(hash_kv(args.shift, true)) if args[0].kind_of?(Hash)
+
+ params << '--' if args[0] =~ /^\s*-[^-]/
+ params.concat(args)
+
+ tk_call('::blt::bgexec', *params)
+ var
+ end
+
+ def self.detach_bgexec(*args)
+ if args[0].kind_of?(TkVariable)
+ var = args.shift
+ else
+ var = TkVariable.new
+ end
+ params = [var]
+
+ params.concat(hash_kv(args.shift, true)) if args[0].kind_of?(Hash)
+
+ params << '--' if args[0] =~ /^\s*-[^-]/
+ params.concat(args)
+ params << '&'
+
+ [var, tk_split_list(tk_call('::blt::bgexec', *params))]
+ end
+
+ def self.bltdebug(lvl = nil)
+ if lvl
+ tk_call('::blt::bltdebug', lvl)
+ else
+ number(tk_call('::blt::bltdebug'))
+ end
+ end
+
+ def self.crc32_file(name)
+ tk_call_without_enc('::blt::crc32', name)
+ end
+ def self.crc32_data(dat)
+ tk_call_without_enc('::blt::crc32', '-data', dat)
+ end
+
+ ####################################################
+
+ def self.active_legend(graph)
+ tk_call_without_enc('Blt_ActiveLegend', graph)
+ end
+ def self.crosshairs(graph)
+ tk_call_without_enc('Blt_Crosshairs', graph)
+ end
+ def self.zoom_stack(graph)
+ tk_call_without_enc('Blt_ZoomStack', graph)
+ end
+ def self.print_key(graph)
+ tk_call_without_enc('Blt_PrintKey', graph)
+ end
+ def self.closest_point(graph)
+ tk_call_without_enc('Blt_ClosestPoint', graph)
+ end
+
+ module GraphCommand
+ def active_legend
+ tk_call_without_enc('Blt_ActiveLegend', @path)
+ self
+ end
+ def crosshairs
+ tk_call_without_enc('Blt_Crosshairs', @path)
+ self
+ end
+ def zoom_stack
+ tk_call_without_enc('Blt_ZoomStack', @path)
+ self
+ end
+ def print_key
+ tk_call_without_enc('Blt_PrintKey', @path)
+ self
+ end
+ def closest_point
+ tk_call_without_enc('Blt_ClosestPoint', @path)
+ self
+ end
+ end
+
+ ####################################################
+
+ autoload :PlotComponent,'tkextlib/blt/component.rb'
+
+ autoload :Barchart, 'tkextlib/blt/barchart.rb'
+ autoload :Bitmap, 'tkextlib/blt/bitmap.rb'
+ autoload :Busy, 'tkextlib/blt/busy.rb'
+ autoload :Container, 'tkextlib/blt/container.rb'
+ autoload :CutBuffer, 'tkextlib/blt/cutbuffer.rb'
+ autoload :DragDrop, 'tkextlib/blt/dragdrop.rb'
+ autoload :EPS, 'tkextlib/blt/eps.rb'
+ autoload :Htext, 'tkextlib/blt/htext.rb'
+ autoload :Graph, 'tkextlib/blt/graph.rb'
+ autoload :Spline, 'tkextlib/blt/spline.rb'
+ autoload :Stripchart, 'tkextlib/blt/stripchart.rb'
+ autoload :Table, 'tkextlib/blt/table.rb'
+ autoload :Tabnotebook, 'tkextlib/blt/tabnotebook.rb'
+ autoload :Tabset, 'tkextlib/blt/tabset.rb'
+ autoload :Ted, 'tkextlib/blt/ted.rb'
+ autoload :Tile, 'tkextlib/blt/tile.rb'
+ autoload :Tree, 'tkextlib/blt/tree.rb'
+ autoload :TreeView, 'tkextlib/blt/treeview.rb'
+ autoload :Hiertable, 'tkextlib/blt/treeview.rb'
+ # Hierbox is obsolete
+ autoload :Vector, 'tkextlib/blt/vector.rb'
+ autoload :VectorAccess, 'tkextlib/blt/vector.rb'
+ autoload :Watch, 'tkextlib/blt/watch.rb'
+ autoload :Winop, 'tkextlib/blt/winop.rb'
+ autoload :WinOp, 'tkextlib/blt/winop.rb'
+
+ # Unix only
+ autoload :DnD, 'tkextlib/blt/unix_dnd.rb'
+
+ # Windows only
+ autoload :Printer, 'tkextlib/blt/win_printer.rb'
+ end
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/blt/barchart.rb b/jni/ruby/ext/tk/lib/tkextlib/blt/barchart.rb
new file mode 100644
index 0000000..a86b91c
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/blt/barchart.rb
@@ -0,0 +1,79 @@
+#
+# tkextlib/blt/barchart.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+
+require 'tk'
+require 'tkextlib/blt.rb'
+require 'tkextlib/blt/component.rb'
+
+module Tk::BLT
+ class Barchart < TkWindow
+ TkCommandNames = ['::blt::barchart'.freeze].freeze
+ WidgetClassName = 'Barchart'.freeze
+ WidgetClassNames[WidgetClassName] ||= self
+
+ include PlotComponent
+ include GraphCommand
+
+ def __boolval_optkeys
+ ['bufferelements', 'buffergraph', 'invertxy']
+ end
+ private :__boolval_optkeys
+
+ def __strval_optkeys
+ ['text', 'label', 'title', 'file',
+ 'background', 'plotbackground']
+ end
+ private :__strval_optkeys
+
+ def __tkvariable_optkeys
+ super() << 'colormap' << 'fontmap'
+ end
+ private :__tkvariable_optkeys
+
+=begin
+ BarElement_ID = ['blt_barchart_bar'.freeze, TkUtil.untrust('00000')].freeze
+
+ def bar(elem=nil, keys={})
+ if elem.kind_of?(Hash)
+ keys = elem
+ elem = nil
+ end
+ unless elem
+ elem = BarElement_ID.join(TkCore::INTERP._ip_id_).freeze
+ BarElement_ID[1].succ!
+ end
+ tk_send('bar', elem, keys)
+ Element.new(self, elem, :without_creating=>true)
+ end
+=end
+
+ def extents(item)
+ num_or_str(tk_send_without_enc('extents', item))
+ end
+
+ def invtransform(x, y)
+ list(tk_send_without_enc('invtransform', x, y))
+ end
+
+ def inside(x, y)
+ bool(tk_send_without_enc('inside', x, y))
+ end
+
+ def metafile(file=None)
+ # Windows only
+ tk_send('metafile', file)
+ self
+ end
+
+ def snap(output, keys={})
+ tk_send_without_enc('snap', *(hash_kv(keys, false) + output))
+ self
+ end
+
+ def transform(x, y)
+ list(tk_send_without_enc('transform', x, y))
+ end
+ end
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/blt/bitmap.rb b/jni/ruby/ext/tk/lib/tkextlib/blt/bitmap.rb
new file mode 100644
index 0000000..3254b63
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/blt/bitmap.rb
@@ -0,0 +1,112 @@
+#
+# tkextlib/blt/bitmap.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+
+require 'tk'
+require 'tkextlib/blt.rb'
+
+module Tk::BLT
+ class Bitmap < TkObject
+ extend TkCore
+
+ TkCommandNames = ['::blt::bitmap'.freeze].freeze
+
+ BITMAP_ID_TBL = TkCore::INTERP.create_table
+
+ (BITMAP_ID = ['blt_bitmap_id'.freeze, TkUtil.untrust('00000')]).instance_eval{
+ @mutex = Mutex.new
+ def mutex; @mutex; end
+ freeze
+ }
+
+ TkCore::INTERP.init_ip_env{
+ BITMAP_ID_TBL.mutex.synchronize{ BITMAP_ID_TBL.clear }
+ }
+
+ def self.data(name)
+ dat = tk_simple_list(tk_call('::blt::bitmap', 'data', name))
+ [ tk_split_list(dat[0]), tk_simple_list(dat[1]) ]
+ end
+
+ def self.exist?(name)
+ bool(tk_call('::blt::bitmap', 'exists', name))
+ end
+
+ def self.height(name)
+ number(tk_call('::blt::bitmap', 'height', name))
+ end
+
+ def self.width(name)
+ number(tk_call('::blt::bitmap', 'width', name))
+ end
+
+ def self.source(name)
+ tk_simple_list(tk_call('::blt::bitmap', 'source', name))
+ end
+
+ #################################
+
+ class << self
+ alias _new new
+
+ def new(data, keys={})
+ _new(:data, nil, data, keys)
+ end
+ alias define new
+
+ def new_with_name(name, data, keys={})
+ _new(:data, name, data, keys)
+ end
+ alias define_with_name new_with_name
+
+ def compose(text, keys={})
+ _new(:text, nil, text, keys)
+ end
+
+ def compose_with_name(name, text, keys={})
+ _new(:text, name, text, keys)
+ end
+ end
+
+ def initialize(type, name, data, keys = {})
+ if name
+ @id = name
+ else
+ BITMAP_ID.mutex.synchronize{
+ @id = BITMAP_ID.join(TkCore::INTERP._ip_id_)
+ BITMAP_ID[1].succ!
+ }
+ BITMAP_ID_TBL.mutex.synchronize{
+ BITMAP_ID_TBL[@id] = self
+ }
+ end
+
+ @path = @id
+
+ unless bool(tk_call('::blt::bitmap', 'exists', @id))
+ if type == :text
+ tk_call('::blt::bitmap', 'compose', @id, data, *hash_kv(keys))
+ else # :data
+ tk_call('::blt::bitmap', 'define', @id, data, *hash_kv(keys))
+ end
+ end
+ end
+
+ def exist?
+ bool(tk_call('::blt::bitmap', 'exists', @id))
+ end
+
+ def height
+ number(tk_call('::blt::bitmap', 'height', @id))
+ end
+
+ def width
+ number(tk_call('::blt::bitmap', 'width', @id))
+ end
+
+ def source
+ tk_simple_list(tk_call('::blt::bitmap', 'source', @id))
+ end
+ end
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/blt/busy.rb b/jni/ruby/ext/tk/lib/tkextlib/blt/busy.rb
new file mode 100644
index 0000000..b5287fb
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/blt/busy.rb
@@ -0,0 +1,83 @@
+#
+# tkextlib/blt/busy.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+
+require 'tk'
+require 'tk/itemconfig.rb'
+require 'tkextlib/blt.rb'
+
+module Tk::BLT
+ module Busy
+ extend TkCore
+ extend TkItemConfigMethod
+
+ TkCommandNames = ['::blt::busy'.freeze].freeze
+
+ ###########################
+
+ class Shield < TkWindow
+ def self.shield_path(win)
+ win = window(win) unless win.kind_of?(TkWindow)
+ if win.kind_of?(Tk::Toplevel)
+ win.path + '._Busy'
+ else
+ win.path + '_Busy'
+ end
+ end
+
+ def initialize(win)
+ @path = self.class.shield_path(win)
+ end
+ end
+
+ def self.shield_path(win)
+ Tk::BLT::Busy::Shield.shield_path(win)
+ end
+ end
+end
+
+class << Tk::BLT::Busy
+ def __item_config_cmd(win)
+ ['::blt::busy', 'configure', win]
+ end
+ private :__item_config_cmd
+
+ undef itemcget
+ undef itemcget_tkstring
+ alias configure itemconfigure
+ alias configinfo itemconfiginfo
+ alias current_configinfo current_itemconfiginfo
+ private :itemconfigure, :itemconfiginfo, :current_itemconfiginfo
+
+ ##################################
+
+ def hold(win, keys={})
+ tk_call('::blt::busy', 'hold', win, *hash_kv(keys))
+ end
+
+ def release(*wins)
+ tk_call('::blt::busy', 'release', *wins)
+ end
+
+ def forget(*wins)
+ tk_call('::blt::busy', 'forget', *wins)
+ end
+
+ def is_busy(pat=None)
+ tk_split_list(tk_call('::blt::busy', 'isbusy', pat))
+ end
+
+ def names(pat=None)
+ tk_split_list(tk_call('::blt::busy', 'names', pat))
+ end
+ alias windows names
+
+ def check(win)
+ bool(tk_call('::blt::busy', 'check', win))
+ end
+
+ def status(win)
+ bool(tk_call('::blt::busy', 'status', win))
+ end
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/blt/component.rb b/jni/ruby/ext/tk/lib/tkextlib/blt/component.rb
new file mode 100644
index 0000000..c7ea213
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/blt/component.rb
@@ -0,0 +1,2218 @@
+#
+# tkextlib/blt/component.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+
+require 'tk'
+require 'tkextlib/blt.rb'
+
+module Tk::BLT
+ module PlotComponent
+ include TkItemConfigMethod
+
+ module OptKeys
+ def __item_font_optkeys(id)
+ ['font', 'tickfont', 'titlefont']
+ end
+ private :__item_font_optkeys
+
+ def __item_numstrval_optkeys(id)
+ ['xoffset', 'yoffset']
+ end
+ private :__item_numstrval_optkeys
+
+ def __item_boolval_optkeys(id)
+ ['hide', 'under', 'descending', 'logscale', 'loose', 'showticks',
+ 'titlealternate', 'scalesymbols', 'minor', 'raised',
+ 'center', 'decoration', 'landscape', 'maxpect']
+ end
+ private :__item_boolval_optkeys
+
+ def __item_strval_optkeys(id)
+ ['text', 'label', 'limits', 'title',
+ 'show', 'file', 'maskdata', 'maskfile',
+ 'color', 'titlecolor', 'fill', 'outline', 'offdash']
+ end
+ private :__item_strval_optkeys
+
+ def __item_listval_optkeys(id)
+ ['bindtags']
+ end
+ private :__item_listval_optkeys
+
+ def __item_numlistval_optkeys(id)
+ ['dashes', 'majorticks', 'minorticks']
+ end
+ private :__item_numlistval_optkeys
+
+ def __item_tkvariable_optkeys(id)
+ ['variable', 'textvariable', 'colormap', 'fontmap']
+ end
+ private :__item_tkvariable_optkeys
+ end
+
+ include OptKeys
+
+ def __item_cget_cmd(id)
+ if id.kind_of?(Array)
+ # id := [ type, name ]
+ [self.path, id[0], 'cget', id[1]]
+ else
+ [self.path, id, 'cget']
+ end
+ end
+ private :__item_cget_cmd
+
+ def __item_config_cmd(id)
+ if id.kind_of?(Array)
+ # id := [ type, name, ... ]
+ type, *names = id
+ [self.path, type, 'configure'].concat(names)
+ else
+ [self.path, id, 'configure']
+ end
+ end
+ private :__item_config_cmd
+
+ def __item_pathname(id)
+ if id.kind_of?(Array)
+ id = tagid(id[1])
+ end
+ [self.path, id].join(';')
+ end
+ private :__item_pathname
+
+ def axis_cget_tkstring(id, option)
+ ret = itemcget_tkstring(['axis', tagid(id)], option)
+ end
+ def axis_cget(id, option)
+ ret = itemcget(['axis', tagid(id)], option)
+ end
+ def axis_cget_strict(id, option)
+ ret = itemcget_strict(['axis', tagid(id)], option)
+ end
+ def axis_configure(*args)
+ slot = args.pop
+ if slot.kind_of?(Hash)
+ value = None
+ slot = _symbolkey2str(slot)
+ if cmd = slot.delete('command')
+ slot['command'] = proc{|w, tick|
+ cmd.call(TkComm.window(w), TkComm.num_or_str(tick))
+ }
+ end
+ else
+ value = slot
+ slot = args.pop
+ if slot == :command || slot == 'command'
+ cmd = value
+ value = proc{|w, tick|
+ cmd.call(TkComm.window(w), TkComm.num_or_str(tick))
+ }
+ end
+ end
+ id_list = args.flatten.collect!{|id| tagid(id)}.unshift('axis')
+ itemconfigure(id_list, slot, value)
+ end
+ def axis_configinfo(id, slot=nil)
+ itemconfiginfo(['axis', tagid(id)], slot)
+ end
+ def current_axis_configinfo(id, slot=nil)
+ current_itemconfiginfo(['axis', tagid(id)], slot)
+ end
+
+ def crosshairs_cget_tkstring(option)
+ itemcget_tkstring('crosshairs', option)
+ end
+ def crosshairs_cget(option)
+ itemcget('crosshairs', option)
+ end
+ def crosshairs_cget_strict(option)
+ itemcget_strict('crosshairs', option)
+ end
+ def crosshairs_configure(slot, value=None)
+ itemconfigure('crosshairs', slot, value)
+ end
+ def crosshairs_configinfo(slot=nil)
+ itemconfiginfo('crosshairs', slot)
+ end
+ def current_crosshairs_configinfo(slot=nil)
+ current_itemconfiginfo('crosshairs', slot)
+ end
+
+ def element_cget_tkstring(id, option)
+ itemcget_tkstring(['element', tagid(id)], option)
+ end
+ def element_cget(id, option)
+ itemcget(['element', tagid(id)], option)
+ end
+ def element_cget_strict(id, option)
+ itemcget_strict(['element', tagid(id)], option)
+ end
+ def element_configure(*args)
+ slot = args.pop
+ if slot.kind_of?(Hash)
+ value = None
+ else
+ value = slot
+ slot = args.pop
+ end
+ id_list = args.flatten.collect!{|id| tagid(id)}.unshift('element')
+ itemconfigure(id_list, slot, value)
+ end
+ def element_configinfo(id, slot=nil)
+ itemconfiginfo(['element', tagid(id)], slot)
+ end
+ def current_element_configinfo(id, slot=nil)
+ current_itemconfiginfo(['element', tagid(id)], slot)
+ end
+
+ def bar_cget_tkstring(id, option)
+ itemcget_tkstring(['bar', tagid(id)], option)
+ end
+ def bar_cget(id, option)
+ itemcget(['bar', tagid(id)], option)
+ end
+ def bar_cget_strict(id, option)
+ itemcget_strict(['bar', tagid(id)], option)
+ end
+ def bar_configure(*args)
+ slot = args.pop
+ if slot.kind_of?(Hash)
+ value = None
+ else
+ value = slot
+ slot = args.pop
+ end
+ id_list = args.flatten.collect!{|id| tagid(id)}.unshift('bar')
+ itemconfigure(id_list, slot, value)
+ end
+ def bar_configinfo(id, slot=nil)
+ itemconfiginfo(['bar', tagid(id)], slot)
+ end
+ def current_bar_configinfo(id, slot=nil)
+ current_itemconfiginfo(['bar', tagid(id)], slot)
+ end
+
+ def line_cget_tkstring(id, option)
+ itemcget_tkstring(['line', tagid(id)], option)
+ end
+ def line_cget(id, option)
+ itemcget(['line', tagid(id)], option)
+ end
+ def line_cget_strict(id, option)
+ itemcget_strict(['line', tagid(id)], option)
+ end
+ def line_configure(*args)
+ slot = args.pop
+ if slot.kind_of?(Hash)
+ value = None
+ else
+ value = slot
+ slot = args.pop
+ end
+ id_list = args.flatten.collect!{|id| tagid(id)}.unshift('line')
+ itemconfigure(id_list, slot, value)
+ end
+ def line_configinfo(id, slot=nil)
+ itemconfiginfo(['line', tagid(id)], slot)
+ end
+ def current_line_configinfo(id, slot=nil)
+ current_itemconfiginfo(['line', tagid(id)], slot)
+ end
+
+ def gridline_cget_tkstring(option)
+ itemcget_tkstring('grid', option)
+ end
+ def gridline_cget(option)
+ itemcget('grid', option)
+ end
+ def gridline_cget_strict(option)
+ itemcget_strict('grid', option)
+ end
+ def gridline_configure(slot, value=None)
+ itemconfigure('grid', slot, value)
+ end
+ def gridline_configinfo(slot=nil)
+ itemconfiginfo('grid', slot)
+ end
+ def current_gridline_configinfo(slot=nil)
+ current_itemconfiginfo('grid', slot)
+ end
+
+ def legend_cget_tkstring(option)
+ itemcget_tkstring('legend', option)
+ end
+ def legend_cget(option)
+ itemcget('legend', option)
+ end
+ def legend_cget_strict(option)
+ itemcget_strict('legend', option)
+ end
+ def legend_configure(slot, value=None)
+ itemconfigure('legend', slot, value)
+ end
+ def legend_configinfo(slot=nil)
+ itemconfiginfo('legend', slot)
+ end
+ def current_legend_configinfo(slot=nil)
+ current_itemconfiginfo('legend', slot)
+ end
+
+ def pen_cget_tkstring(id, option)
+ itemcget_tkstring(['pen', tagid(id)], option)
+ end
+ def pen_cget(id, option)
+ itemcget(['pen', tagid(id)], option)
+ end
+ def pen_cget_strict(id, option)
+ itemcget_strict(['pen', tagid(id)], option)
+ end
+ def pen_configure(*args)
+ slot = args.pop
+ if slot.kind_of?(Hash)
+ value = None
+ else
+ value = slot
+ slot = args.pop
+ end
+ id_list = args.flatten.collect!{|id| tagid(id)}.unshift('pen')
+ itemconfigure(id_list, slot, value)
+ end
+ def pen_configinfo(id, slot=nil)
+ itemconfiginfo(['pen', tagid(id)], slot)
+ end
+ def current_pen_configinfo(id, slot=nil)
+ current_itemconfiginfo(['pen', tagid(id)], slot)
+ end
+
+ def postscript_cget_tkstring(option)
+ itemcget_tkstring('postscript', option)
+ end
+ def postscript_cget(option)
+ itemcget('postscript', option)
+ end
+ def postscript_cget_strict(option)
+ itemcget_strict('postscript', option)
+ end
+ def postscript_configure(slot, value=None)
+ itemconfigure('postscript', slot, value)
+ end
+ def postscript_configinfo(slot=nil)
+ itemconfiginfo('postscript', slot)
+ end
+ def current_postscript_configinfo(slot=nil)
+ current_itemconfiginfo('postscript', slot)
+ end
+
+ def marker_cget_tkstring(id, option)
+ itemcget_tkstring(['marker', tagid(id)], option)
+ end
+ def marker_cget(id, option)
+ itemcget(['marker', tagid(id)], option)
+ end
+ def marker_cget_strict(id, option)
+ itemcget_strict(['marker', tagid(id)], option)
+ end
+ def marker_configure(*args)
+ slot = args.pop
+ if slot.kind_of?(Hash)
+ value = None
+ else
+ value = slot
+ slot = args.pop
+ end
+ id_list = args.flatten.collect!{|id| tagid(id)}.unshift('marker')
+ itemconfigure(id_list, slot, value)
+ end
+ def marker_configinfo(id, slot=nil)
+ itemconfiginfo(['marker', tagid(id)], slot)
+ end
+ def current_marker_configinfo(id, slot=nil)
+ current_itemconfiginfo(['marker', tagid(id)], slot)
+ end
+
+ alias __itemcget_tkstring itemcget_tkstring
+ alias __itemcget itemcget
+ alias __itemcget_strict itemcget_strict
+ alias __itemconfiginfo itemconfiginfo
+ alias __current_itemconfiginfo current_itemconfiginfo
+ private :__itemcget_tkstring, :__itemcget, :__itemconfiginfo, :__current_itemconfiginfo
+
+ def itemcget_tkstring(tagOrId, option)
+ __itemcget_tkstring(tagid(tagOrId), option)
+ end
+ def itemcget_strict(tagOrId, option)
+ ret = __itemcget(tagid(tagOrId), option)
+ if option == 'bindtags' || option == :bindtags
+ ret.collect{|tag| TkBindTag.id2obj(tag)}
+ else
+ ret
+ end
+ end
+ def itemcget(tagOrId, option)
+ unless TkItemConfigMethod.__IGNORE_UNKNOWN_CONFIGURE_OPTION__
+ itemcget_strict(tagOrId, option)
+ else
+ begin
+ itemcget_strict(tagOrId, option)
+ rescue => e
+ begin
+ if current_itemconfiginfo(tagOrId).has_key?(option.to_s)
+ # error on known option
+ fail e
+ else
+ # unknown option
+ nil
+ end
+ rescue
+ fail e # tag error
+ end
+ end
+ end
+ end
+ def itemconfiginfo(tagOrId, slot = nil)
+ ret = __itemconfiginfo(tagid(tagOrId), slot)
+
+ if TkComm::GET_CONFIGINFO_AS_ARRAY
+ if slot
+ if slot == 'bindtags' || slot == :bindtags
+ ret[-2] = ret[-2].collect{|tag| TkBindTag.id2obj(tag)}
+ ret[-1] = ret[-1].collect{|tag| TkBindTag.id2obj(tag)}
+ end
+ else
+ if (inf = ret.assoc('bindtags'))
+ inf[-2] = inf[-2].collect{|tag| TkBindTag.id2obj(tag)}
+ inf[-1] = inf[-1].collect{|tag| TkBindTag.id2obj(tag)}
+ end
+ end
+
+ else # ! TkComm::GET_CONFIGINFO_AS_ARRAY
+ if (inf = ret['bindtags'])
+ inf[-2] = inf[-2].collect{|tag| TkBindTag.id2obj(tag)}
+ inf[-1] = inf[-1].collect{|tag| TkBindTag.id2obj(tag)}
+ ret['bindtags'] = inf
+ end
+ end
+
+ ret
+ end
+ def current_itemconfiginfo(tagOrId, slot = nil)
+ ret = __current_itemconfiginfo(tagid(tagOrId), slot)
+
+ if (val = ret['bindtags'])
+ ret['bindtags'] = val.collect{|tag| TkBindTag.id2obj(tag)}
+ end
+
+ ret
+ end
+
+ private :itemcget_tkstring, :itemcget, :itemcget_strict
+ private :itemconfigure, :itemconfiginfo, :current_itemconfiginfo
+
+ #################
+
+ class Axis < TkObject
+ (OBJ_ID = ['blt_chart_axis'.freeze, TkUtil.untrust('00000')]).instance_eval{
+ @mutex = Mutex.new
+ def mutex; @mutex; end
+ freeze
+ }
+
+ AxisID_TBL = TkCore::INTERP.create_table
+
+ TkCore::INTERP.init_ip_env{
+ AxisID_TBL.mutex.synchronize{ AxisID_TBL.clear }
+ }
+
+ def self.id2obj(chart, id)
+ cpath = chart.path
+ AxisID_TBL.mutex.synchronize{
+ return id unless AxisID_TBL[cpath]
+ AxisID_TBL[cpath][id]? AxisID_TBL[cpath][id]: id
+ }
+ end
+
+ def self.new(chart, axis=nil, keys={})
+ if axis.kind_of?(Hash)
+ keys = axis
+ axis = nil
+ end
+ if keys
+ keys = _symbolkey2str(keys)
+ not_create = keys.delete('without_creating')
+ else
+ not_create = false
+ end
+
+ obj = nil
+ AxisID_TBL.mutex.synchronize{
+ chart_path = chart.path
+ AxisID_TBL[chart_path] ||= {}
+ if axis && AxisID_TBL[chart_path][axis]
+ obj = AxisID_TBL[chart_path][axis]
+ else
+ (obj = self.allocate).instance_eval{
+ if axis
+ @axis = @id = axis.to_s
+ else
+ OBJ_ID.mutex.synchronize{
+ @axis = @id = OBJ_ID.join(TkCore::INTERP._ip_id_).freeze
+ OBJ_ID[1].succ!
+ }
+ end
+ @path = @id
+ @parent = @chart = chart
+ @cpath = @chart.path
+ Axis::AxisID_TBL[@cpath][@axis] = self
+ unless not_create
+ tk_call(@chart, 'axis', 'create', @axis, keys)
+ return obj
+ end
+ }
+ end
+ }
+
+ obj.configure(keys) if obj && ! keys.empty?
+ obj
+ end
+
+ def initialize(chart, axis=nil, keys={})
+ # dummy:: not called by 'new' method
+
+ if axis.kind_of?(Hash)
+ keys = axis
+ axis = nil
+ end
+ if axis
+ @axis = @id = axis.to_s
+ else
+ OBJ_ID.mutex.synchronize{
+ @axis = @id = OBJ_ID.join(TkCore::INTERP._ip_id_).freeze
+ OBJ_ID[1].succ!
+ }
+ end
+ @path = @id
+ @parent = @chart = chart
+ @cpath = @chart.path
+ # Axis::AxisID_TBL[@cpath][@axis] = self
+ keys = _symbolkey2str(keys)
+ unless keys.delete('without_creating')
+ # @chart.axis_create(@axis, keys)
+ tk_call(@chart, 'axis', 'create', @axis, keys)
+ end
+ end
+
+ def id
+ @id
+ end
+
+ def to_eval
+ @id
+ end
+
+ def cget_tkstring(option)
+ @chart.axis_cget_tkstring(@id, option)
+ end
+ def cget(option)
+ @chart.axis_cget(@id, option)
+ end
+ def cget_strict(option)
+ @chart.axis_cget_strict(@id, option)
+ end
+ def configure(key, value=None)
+ @chart.axis_configure(@id, key, value)
+ self
+ end
+ def configinfo(key=nil)
+ @chart.axis_configinfo(@id, key)
+ end
+ def current_configinfo(key=nil)
+ @chart.current_axis_configinfo(@id, key)
+ end
+
+ def command(cmd=nil, &b)
+ if cmd
+ configure('command', cmd)
+ elsif b
+ configure('command', Proc.new(&b))
+ else
+ cget('command')
+ end
+ end
+
+ def delete
+ @chart.axis_delete(@id)
+ self
+ end
+
+ def invtransform(val)
+ @chart.axis_invtransform(@id, val)
+ end
+
+ def limits
+ @chart.axis_limits(@id)
+ end
+
+ def name
+ @axis
+ end
+
+ def transform(val)
+ @chart.axis_transform(@id, val)
+ end
+
+ def view
+ @chart.axis_view(@id)
+ self
+ end
+
+ def use(name=None) # if @id == xaxis | x2axis | yaxis | y2axis
+ @chart.axis_use(@id, name)
+ end
+
+ def use_as(axis) # axis := xaxis | x2axis | yaxis | y2axis
+ @chart.axis_use(axis, @id)
+ end
+ end
+
+ #################
+
+ class Crosshairs < TkObject
+ CrosshairsID_TBL = TkCore::INTERP.create_table
+
+ TkCore::INTERP.init_ip_env{
+ CrosshairsID_TBL.mutex.synchronize{ CrosshairsID_TBL.clear }
+ }
+
+ def self.new(chart, keys={})
+ obj = nil
+ CrosshairsID_TBL.mutex.synchronize{
+ unless (obj = CrosshairsID_TBL[chart.path])
+ (obj = self.allocate).instance_eval{
+ @parent = @chart = chart
+ @cpath = @chart.path
+ @path = @id = 'crosshairs'
+ Crosshairs::CrosshairsID_TBL[@cpath] = self
+ }
+ end
+ }
+ chart.crosshair_configure(keys) if obj && ! keys.empty?
+ obj
+ end
+
+ def initialize(chart, keys={})
+ # dummy:: not called by 'new' method
+
+ @parent = @chart = chart
+ @cpath = @chart.path
+ # Crosshairs::CrosshairsID_TBL[@cpath] = self
+ @chart.crosshair_configure(keys) unless keys.empty?
+ @path = @id = 'crosshairs'
+ end
+
+ def id
+ @id
+ end
+
+ def to_eval
+ @id
+ end
+
+ def cget_tkstring(option)
+ @chart.crosshair_cget_tkstring(option)
+ end
+ def cget(option)
+ @chart.crosshair_cget(option)
+ end
+ def cget_strict(option)
+ @chart.crosshair_cget_strict(option)
+ end
+ def configure(key, value=None)
+ @chart.crosshair_configure(key, value)
+ self
+ end
+ def configinfo(key=nil)
+ @chart.crosshair_configinfo(key)
+ end
+ def current_configinfo(key=nil)
+ @chart.current_crosshair_configinfo(key)
+ end
+
+ def off
+ @chart.crosshair_off
+ self
+ end
+ def on
+ @chart.crosshair_on
+ self
+ end
+ def toggle
+ @chart.crosshair_toggle
+ self
+ end
+ end
+
+ #################
+
+ class Element < TkObject
+ extend Tk
+ extend TkItemFontOptkeys
+ extend TkItemConfigOptkeys
+
+ extend Tk::BLT::PlotComponent::OptKeys
+
+ ElementTypeName = 'element'
+ ElementTypeToClass = { ElementTypeName=>self }
+
+ ElementID_TBL = TkCore::INTERP.create_table
+
+ TkCore::INTERP.init_ip_env{
+ ElementID_TBL.mutex.synchronize{ ElementID_TBL.clear }
+ }
+
+ (OBJ_ID = ['blt_chart_element'.freeze, TkUtil.untrust('00000')]).instance_eval{
+ @mutex = Mutex.new
+ def mutex; @mutex; end
+ freeze
+ }
+
+ def Element.type2class(type)
+ ElementTypeToClass[type]
+ end
+
+ def Element.id2obj(chart, id)
+ cpath = chart.path
+ ElementID_TBL.mutex.synchronize{
+ return id unless ElementID_TBL[cpath]
+ ElementID_TBL[cpath][id]? ElementID_TBL[cpath][id]: id
+ }
+ end
+
+ def self.new(chart, element=nil, keys={})
+ if element.kind_of?(Hash)
+ keys = element
+ element = nil
+ end
+ if keys
+ keys = _symbolkey2str(keys)
+ not_create = keys.delete('without_creating')
+ else
+ not_create = false
+ end
+
+ obj = nil
+ ElementID_TBL.mutex.synchronize{
+ chart_path = chart.path
+ ElementID_TBL[chart_path] ||= {}
+ if element && ElementID_TBL[chart_path][element]
+ obj = ElementID_TBL[chart_path][element]
+ else
+ (obj = self.allocate).instance_eval{
+ if element
+ @element = @id = element.to_s
+ else
+ OBJ_ID.mutex.synchronize{
+ @element = @id = OBJ_ID.join(TkCore::INTERP._ip_id_).freeze
+ OBJ_ID[1].succ!
+ }
+ end
+ @path = @id
+ @parent = @chart = chart
+ @cpath = @chart.path
+ @typename = self.class::ElementTypeName
+ Element::ElementID_TBL[@cpath][@element] = self
+ unless not_create
+ tk_call(@chart, @typename, 'create', @element, keys)
+ return obj
+ end
+ }
+ end
+ }
+
+ obj.configure(keys) if obj && ! keys.empty?
+ obj
+ end
+
+ def initialize(chart, element=nil, keys={})
+ # dummy:: not called by 'new' method
+
+ if element.kind_of?(Hash)
+ keys = element
+ element = nil
+ end
+ if element
+ @element = @id = element.to_s
+ else
+ OBJ_ID.mutex.synchronize{
+ @element = @id = OBJ_ID.join(TkCore::INTERP._ip_id_).freeze
+ OBJ_ID[1].succ!
+ }
+ end
+ @path = @id
+ @parent = @chart = chart
+ @cpath = @chart.path
+ @typename = self.class::ElementTypeName
+ # Element::ElementID_TBL[@cpath][@element] = self
+ keys = _symbolkey2str(keys)
+ unless keys.delete('without_creating')
+ # @chart.element_create(@element, keys)
+ tk_call(@chart, @typename, 'create', @element, keys)
+ end
+ end
+
+ def id
+ @id
+ end
+
+ def to_eval
+ @id
+ end
+
+ def cget_tkstring(option)
+ # @chart.element_cget(@id, option)
+ @chart.__send__(@typename + '_cget_tkstring', @id, option)
+ end
+ def cget(option)
+ # @chart.element_cget(@id, option)
+ @chart.__send__(@typename + '_cget', @id, option)
+ end
+ def cget_strict(option)
+ @chart.__send__(@typename + '_cget_strict', @id, option)
+ end
+ def configure(key, value=None)
+ # @chart.element_configure(@id, key, value)
+ @chart.__send__(@typename + '_configure', @id, key, value)
+ self
+ end
+ def configinfo(key=nil)
+ # @chart.element_configinfo(@id, key)
+ @chart.__send__(@typename + '_configinfo', @id, key)
+ end
+ def current_configinfo(key=nil)
+ # @chart.current_element_configinfo(@id, key)
+ @chart.__send__('current_' << @typename << '_configinfo', @id, key)
+ end
+
+ def activate(*args)
+ @chart.element_activate(@id, *args)
+ end
+
+ def closest(x, y, var, keys={})
+ # @chart.element_closest(x, y, var, @id, keys)
+ @chart.__send__(@typename + '_closest', x, y, var, @id, keys)
+ end
+
+ def deactivate
+ @chart.element_deactivate(@id)
+ self
+ end
+
+ def delete
+ @chart.element_delete(@id)
+ self
+ end
+
+ def exist?
+ @chart.element_exist?(@id)
+ end
+
+ def name
+ @element
+ end
+
+ def type
+ @chart.element_type(@id)
+ end
+ end
+
+ class Bar < Element
+ ElementTypeName = 'bar'.freeze
+ ElementTypeToClass[ElementTypeName] = self
+ end
+ class Line < Element
+ ElementTypeName = 'line'.freeze
+ ElementTypeToClass[ElementTypeName] = self
+ end
+
+ #################
+
+ class GridLine < TkObject
+ GridLineID_TBL = TkCore::INTERP.create_table
+ TkCore::INTERP.init_ip_env{
+ GridLineID_TBL.mutex.synchronize{ GridLineID_TBL.clear }
+ }
+
+ def self.new(chart, keys={})
+ obj = nil
+ GridLineID_TBL.mutex.synchronize{
+ unless (obj = GridLineID_TBL[chart.path])
+ (obj = self.allocate).instance_eval{
+ @parent = @chart = chart
+ @cpath = @chart.path
+ @path = @id = 'grid'
+ GridLine::GridLineID_TBL[@cpath] = self
+ }
+ end
+ }
+ chart.gridline_configure(keys) if obj && ! keys.empty?
+ obj
+ end
+
+ def initialize(chart, keys={})
+ # dummy:: not called by 'new' method
+
+ @parent = @chart = chart
+ @cpath = @chart.path
+ # GridLine::GridLineID_TBL[@cpath] = self
+ @chart.gridline_configure(keys) unless keys.empty?
+ @path = @id = 'grid'
+ end
+
+ def id
+ @id
+ end
+
+ def to_eval
+ @id
+ end
+
+ def cget_tkstring(option)
+ @chart.gridline_cget_tkstring(option)
+ end
+ def cget(option)
+ @chart.gridline_cget(option)
+ end
+ def cget_strict(option)
+ @chart.gridline_cget_strict(option)
+ end
+ def configure(key, value=None)
+ @chart.gridline_configure(key, value)
+ self
+ end
+ def configinfo(key=nil)
+ @chart.gridline_configinfo(key)
+ end
+ def current_configinfo(key=nil)
+ @chart.current_gridline_configinfo(key)
+ end
+
+ def off
+ @chart.gridline_off
+ self
+ end
+ def on
+ @chart.gridline_on
+ self
+ end
+ def toggle
+ @chart.gridline_toggle
+ self
+ end
+ end
+
+ #################
+
+ class Legend < TkObject
+ LegendID_TBL = TkCore::INTERP.create_table
+
+ TkCore::INTERP.init_ip_env{
+ LegendID_TBL.mutex.synchronize{ LegendID_TBL.clear }
+ }
+
+ def self.new(chart, keys={})
+ obj = nil
+ LegenedID_TBL.mutex.synchronize{
+ unless (obj = LegenedID_TBL[chart.path])
+ (obj = self.allocate).instance_eval{
+ @parent = @chart = chart
+ @cpath = @chart.path
+ @path = @id = 'crosshairs'
+ Legend::LegenedID_TBL[@cpath] = self
+ }
+ end
+ }
+ chart.legend_configure(keys) if obj && ! keys.empty?
+ obj
+ end
+
+ def initialize(chart, keys={})
+ # dummy:: not called by 'new' method
+
+ @parent = @chart = chart
+ @cpath = @chart.path
+ # Legend::LegendID_TBL[@cpath] = self
+ @chart.legend_configure(keys) unless keys.empty?
+ @path = @id = 'legend'
+ end
+
+ def id
+ @id
+ end
+
+ def to_eval
+ @id
+ end
+
+ def cget_tkstring(option)
+ @chart.legend_cget_tkstring(option)
+ end
+ def cget(option)
+ @chart.legend_cget(option)
+ end
+ def cget_strict(option)
+ @chart.legend_cget_strict(option)
+ end
+ def configure(key, value=None)
+ @chart.legend_configure(key, value)
+ self
+ end
+ def configinfo(key=nil)
+ @chart.legend_configinfo(key)
+ end
+ def current_configinfo(key=nil)
+ @chart.current_legend_configinfo(key)
+ end
+
+ def activate(*args)
+ @chart.legend_activate(*args)
+ end
+
+ def deactivate(*args)
+ @chart.legend_deactivate(*args)
+ end
+
+ def get(pos, y=nil)
+ @chart.legend_get(pos, y)
+ end
+ end
+
+ #################
+
+ class Pen < TkObject
+ (OBJ_ID = ['blt_chart_pen'.freeze, TkUtil.untrust('00000')]).instance_eval{
+ @mutex = Mutex.new
+ def mutex; @mutex; end
+ freeze
+ }
+
+ PenID_TBL = TkCore::INTERP.create_table
+
+ TkCore::INTERP.init_ip_env{
+ PenID_TBL.mutex.synchronize{ PenID_TBL.clear }
+ }
+
+ def self.id2obj(chart, id)
+ cpath = chart.path
+ PenID_TBL.mutex.synchronize{
+ return id unless PenID_TBL[cpath]
+ PenID_TBL[cpath][id]? PenID_TBL[cpath][id]: id
+ }
+ end
+
+ def self.new(chart, pen=nil, keys={})
+ if pen.kind_of?(Hash)
+ keys = pen
+ pen = nil
+ end
+ if keys
+ keys = _symbolkey2str(keys)
+ not_create = keys.delete('without_creating')
+ else
+ not_create = false
+ end
+
+ obj = nil
+ PenID_TBL.mutex.synchronize{
+ chart_path = chart.path
+ PenID_TBL[chart_path] ||= {}
+ if pen && PenID_TBL[chart_path][pen]
+ obj = PenID_TBL[chart_path][pen]
+ else
+ (obj = self.allocate).instance_eval{
+ if pen
+ @pen = @id = pen.to_s
+ else
+ OBJ_ID.mutex.synchronize{
+ @pen = @id = OBJ_ID.join(TkCore::INTERP._ip_id_).freeze
+ OBJ_ID[1].succ!
+ }
+ end
+ @path = @id
+ @parent = @chart = chart
+ @cpath = @chart.path
+ Pen::PenID_TBL[@cpath][@pen] = self
+ unless not_create
+ tk_call(@chart, 'pen', 'create', @pen, keys)
+ return obj
+ end
+ }
+ end
+ }
+
+ obj.configure(keys) if obj && ! keys.empty?
+ obj
+ end
+
+ def initialize(chart, pen=nil, keys={})
+ if pen.kind_of?(Hash)
+ keys = pen
+ pen = nil
+ end
+ if pen
+ @pen = @id = pen.to_s
+ else
+ OBJ_ID.mutex.synchronize{
+ @pen = @id = OBJ_ID.join(TkCore::INTERP._ip_id_).freeze
+ OBJ_ID[1].succ!
+ }
+ end
+ @path = @id
+ @parent = @chart = chart
+ @cpath = @chart.path
+ Pen::PenID_TBL[@cpath][@pen] = self
+ keys = _symbolkey2str(keys)
+ unless keys.delete('without_creating')
+ # @chart.pen_create(@pen, keys)
+ tk_call(@chart, 'pen', 'create', @pen, keys)
+ end
+ end
+
+ def id
+ @id
+ end
+
+ def to_eval
+ @id
+ end
+
+ def cget_tkstring(option)
+ @chart.pen_cget_tkstring(@id, option)
+ end
+ def cget(option)
+ @chart.pen_cget(@id, option)
+ end
+ def cget_strict(option)
+ @chart.pen_cget_strict(@id, option)
+ end
+ def configure(key, value=None)
+ @chart.pen_configure(@id, key, value)
+ self
+ end
+ def configinfo(key=nil)
+ @chart.pen_configinfo(@id, key)
+ end
+ def current_configinfo(key=nil)
+ @chart.current_pen_configinfo(@id, key)
+ end
+
+ def delete
+ @chart.pen_delete(@id)
+ self
+ end
+
+ def name
+ @pen
+ end
+ end
+
+ #################
+
+ class Postscript < TkObject
+ PostscriptID_TBL = TkCore::INTERP.create_table
+
+ TkCore::INTERP.init_ip_env{
+ PostscriptID_TBL.mutex.synchronize{ PostscriptID_TBL.clear }
+ }
+
+ def self.new(chart, keys={})
+ obj = nil
+ PostscriptID_TBL.mutex.synchronize{
+ unless (obj = PostscriptID_TBL[chart.path])
+ (obj = self.allocate).instance_eval{
+ @parent = @chart = chart
+ @cpath = @chart.path
+ @path = @id = 'postscript'
+ Postscript::PostscriptID_TBL[@cpath] = self
+ }
+ end
+ }
+ chart.postscript_configure(keys) if obj && ! keys.empty?
+ obj
+ end
+
+ def initialize(chart, keys={})
+ # dummy:: not called by 'new' method
+
+ @parent = @chart = chart
+ @cpath = @chart.path
+ # Postscript::PostscriptID_TBL[@cpath] = self
+ @chart.postscript_configure(keys) unless keys.empty?
+ @path = @id = 'postscript'
+ end
+
+ def id
+ @id
+ end
+
+ def to_eval
+ @id
+ end
+
+ def cget_tkstring(option)
+ @chart.postscript_cget_tkstring(option)
+ end
+ def cget(option)
+ @chart.postscript_cget(option)
+ end
+ def cget_strict(option)
+ @chart.postscript_cget_strict(option)
+ end
+ def configure(key, value=None)
+ @chart.postscript_configure(key, value)
+ self
+ end
+ def configinfo(key=nil)
+ @chart.postscript_configinfo(key)
+ end
+ def current_configinfo(key=nil)
+ @chart.current_postscript_configinfo(key)
+ end
+
+ def output(file=nil, keys={})
+ if file.kind_of?(Hash)
+ keys = file
+ file = nil
+ end
+
+ ret = @chart.postscript_output(file, keys)
+
+ if file
+ self
+ else
+ ret
+ end
+ end
+ end
+
+ #################
+ class Marker < TkObject
+ extend Tk
+ extend TkItemFontOptkeys
+ extend TkItemConfigOptkeys
+
+ extend Tk::BLT::PlotComponent::OptKeys
+
+ MarkerTypeName = nil
+ MarkerTypeToClass = {}
+ MarkerID_TBL = TkCore::INTERP.create_table
+
+ TkCore::INTERP.init_ip_env{
+ MarkerID_TBL.mutex.synchronize{ MarkerID_TBL.clear }
+ }
+
+ def Marker.type2class(type)
+ MarkerTypeToClass[type]
+ end
+
+ def Marker.id2obj(chart, id)
+ cpath = chart.path
+ MarkerID_TBL.mutex.synchronize{
+ if MarkerID_TBL[cpath]
+ MarkerID_TBL[cpath][id]? MarkerID_TBL[cpath][id]: id
+ else
+ id
+ end
+ }
+ end
+
+ def self._parse_create_args(keys)
+ fontkeys = {}
+ methodkeys = {}
+ if keys.kind_of? Hash
+ keys = _symbolkey2str(keys)
+
+ __item_font_optkeys(nil).each{|key|
+ fkey = key.to_s
+ fontkeys[fkey] = keys.delete(fkey) if keys.key?(fkey)
+
+ fkey = "kanji#{key}"
+ fontkeys[fkey] = keys.delete(fkey) if keys.key?(fkey)
+
+ fkey = "latin#{key}"
+ fontkeys[fkey] = keys.delete(fkey) if keys.key?(fkey)
+
+ fkey = "ascii#{key}"
+ fontkeys[fkey] = keys.delete(fkey) if keys.key?(fkey)
+ }
+
+ __item_optkey_aliases(nil).each{|alias_name, real_name|
+ alias_name = alias_name.to_s
+ if keys.has_key?(alias_name)
+ keys[real_name.to_s] = keys.delete(alias_name)
+ end
+ }
+
+ __item_methodcall_optkeys(nil).each{|key|
+ key = key.to_s
+ methodkeys[key] = keys.delete(key) if keys.key?(key)
+ }
+
+ __item_ruby2val_optkeys(nil).each{|key, method|
+ key = key.to_s
+ keys[key] = method.call(keys[key]) if keys.has_key?(key)
+ }
+
+ args = itemconfig_hash_kv(nil, keys)
+ else
+ args = []
+ end
+
+ [args, fontkeys, methodkeys]
+ end
+ private_class_method :_parse_create_args
+
+ def self.create(chart, keys={})
+ unless self::MarkerTypeName
+ fail RuntimeError, "#{self} is an abstract class"
+ end
+ args, fontkeys, methodkeys = _parse_create_args(keys)
+ idnum = tk_call_without_enc(chart.path, 'marker', 'create',
+ self::MarkerTypeName, *args)
+ chart.marker_configure(idnum, fontkeys) unless fontkeys.empty?
+ chart.marker_configure(idnum, methodkeys) unless methodkeys.empty?
+ idnum.to_i # 'item id' is an integer number
+ end
+
+ def self.create_type(chart, type, keys={})
+ args, fontkeys, methodkeys = _parse_create_args(keys)
+ idnum = tk_call_without_enc(chart.path, 'marker', 'create',
+ type, *args)
+ chart.marker_configure(idnum, fontkeys) unless fontkeys.empty?
+ chart.marker_configure(idnum, methodkeys) unless methodkeys.empty?
+ id = idnum.to_i # 'item id' is an integer number
+ obj = self.allocate
+ obj.instance_eval{
+ @parent = @chart = chart
+ @cpath = chart.path
+ @id = id
+ Tk::BLT::PlotComponent::Marker::MarkerID_TBL.mutex.synchronize{
+ Tk::BLT::PlotComponent::Marker::MarkerID_TBL[@cpath] ||= {}
+ Tk::BLT::PlotComponent::Marker::MarkerID_TBL[@cpath][@id] = self
+ }
+ }
+ obj
+ end
+
+ def initialize(parent, *args)
+ @parent = @chart = parent
+ @cpath = parent.path
+
+ @path = @id = create_self(*args) # an integer number as 'item id'
+ Tk::BLT::PlotComponent::Marker::MarkerID_TBL.mutex.synchronize{
+ Tk::BLT::PlotComponent::Marker::MarkerID_TBL[@cpath] ||= {}
+ Tk::BLT::PlotComponent::Marker::MarkerID_TBL[@cpath][@id] = self
+ }
+ end
+ def create_self(*args)
+ self.class.create(@chart, *args) # return an integer as 'item id'
+ end
+ private :create_self
+
+ def id
+ @id
+ end
+
+ def to_eval
+ @id
+ end
+
+ def cget_tkstring(option)
+ @chart.marker_cget_tkstring(@id, option)
+ end
+ def cget(option)
+ @chart.marker_cget(@id, option)
+ end
+ def cget_strict(option)
+ @chart.marker_cget_strict(@id, option)
+ end
+ def configure(key, value=None)
+ @chart.marker_configure(@id, key, value)
+ self
+ end
+ def configinfo(key=nil)
+ @chart.marker_configinfo(@id, key)
+ end
+ def current_configinfo(key=nil)
+ @chart.current_marker_configinfo(@id, key)
+ end
+
+ def after(target=None)
+ @chart.marker_after(@id, target)
+ end
+
+ def before(target=None)
+ @chart.marker_before(@id, target)
+ end
+
+ def delete
+ @chart.marker_delete(@id)
+ end
+
+ def exist?
+ @chart.marker_exist(@id)
+ end
+
+ def type
+ @chart.marker_type(@id)
+ end
+ end
+
+ class TextMarker < Marker
+ MarkerTypeName = 'text'.freeze
+ MarkerTypeToClass[MarkerTypeName] = self
+ end
+ class LineMarker < Marker
+ MarkerTypeName = 'line'.freeze
+ MarkerTypeToClass[MarkerTypeName] = self
+ end
+ class BitmapMarker < Marker
+ MarkerTypeName = 'bitmap'.freeze
+ MarkerTypeToClass[MarkerTypeName] = self
+ end
+ class ImageMarker < Marker
+ MarkerTypeName = 'image'.freeze
+ MarkerTypeToClass[MarkerTypeName] = self
+ end
+ class PolygonMarker < Marker
+ MarkerTypeName = 'polygon'.freeze
+ MarkerTypeToClass[MarkerTypeName] = self
+ end
+ class WindowMarker < Marker
+ MarkerTypeName = 'window'.freeze
+ MarkerTypeToClass[MarkerTypeName] = self
+ end
+
+ #################
+
+ def __destroy_hook__
+ Axis::AxisID_TBL.delete(@path)
+ Crosshairs::CrosshairsID_TBL.delete(@path)
+ Element::ElementID_TBL.delete(@path)
+ GridLine::GridLineID_TBL.delete(@path)
+ Legend::LegendID_TBL.delete(@path)
+ Pen::PenID_TBL.delete(@path)
+ Postscript::PostscriptID_TBL.delete(@path)
+ Marker::MarkerID_TBL.delete(@path)
+ super()
+ end
+
+ #################
+
+ def tagid(tag)
+ if tag.kind_of?(Axis) ||
+ tag.kind_of?(Crosshairs) ||
+ tag.kind_of?(Element) ||
+ tag.kind_of?(GridLine) ||
+ tag.kind_of?(Legend) ||
+ tag.kind_of?(Pen) ||
+ tag.kind_of?(Postscript) ||
+ tag.kind_of?(Marker)
+ tag.id
+ else
+ tag # maybe an Array of configure parameters
+ end
+ end
+
+ def _component_bind(target, tag, context, *args)
+ if TkComm._callback_entry?(args[0]) || !block_given?
+ cmd = args.shift
+ else
+ cmd = Proc.new
+ end
+ _bind([path, target, 'bind', tagid(tag)], context, cmd, *args)
+ self
+ end
+ def _component_bind_append(target, tag, context, *args)
+ if TkComm._callback_entry?(args[0]) || !block_given?
+ cmd = args.shift
+ else
+ cmd = Proc.new
+ end
+ _bind_append([path, target, 'bind', tagid(tag)], context, cmd, *args)
+ self
+ end
+ def _component_bind_remove(target, tag, context)
+ _bind_remove([path, target, 'bind', tagid(tag)], context)
+ self
+ end
+ def _component_bindinfo(target, tag, context=nil)
+ _bindinfo([path, target, 'bind', tagid(tag)], context)
+ end
+ private :_component_bind, :_component_bind_append
+ private :_component_bind_remove, :_component_bindinfo
+
+ def axis_bind(tag, context, *args)
+ _component_bind('axis', tag, context, *args)
+ end
+ def axis_bind_append(tag, context, *args)
+ _component_bind_append('axis', tag, context, *args)
+ end
+ def axis_bind_remove(tag, context)
+ _component_bind_remove('axis', tag, context)
+ end
+ def axis_bindinfo(tag, context=nil)
+ _component_bindinfo('axis', tag, context)
+ end
+
+ def element_bind(tag, context, *args)
+ _component_bind('element', tag, context, *args)
+ end
+ def element_bind_append(tag, context, *args)
+ _component_bind_append('element', tag, context, *args)
+ end
+ def element_bind_remove(tag, context)
+ _component_bind_remove('element', tag, context)
+ end
+ def element_bindinfo(tag, context=nil)
+ _component_bindinfo('element', tag, context)
+ end
+
+ def bar_bind(tag, context, *args)
+ _component_bind('bar', tag, context, *args)
+ end
+ def bar_bind_append(tag, context, *args)
+ _component_bind_append('bar', tag, context, *args)
+ end
+ def bar_bind_remove(tag, context)
+ _component_bind_remove('bar', tag, context)
+ end
+ def bar_bindinfo(tag, context=nil)
+ _component_bindinfo('bar', tag, context)
+ end
+
+ def line_bind(tag, context, *args)
+ _component_bind('line', tag, context, *args)
+ end
+ def line_bind_append(tag, context, *args)
+ _component_bind_append('line', tag, context, *args)
+ end
+ def line_bind_remove(tag, context)
+ _component_bind_remove('line', tag, context)
+ end
+ def line_bindinfo(tag, context=nil)
+ _component_bindinfo('line', tag, context)
+ end
+
+ def legend_bind(tag, context, *args)
+ _component_bind('legend', tag, context, *args)
+ end
+ def legend_bind_append(tag, context, *args)
+ _component_bind_append('legend', tag, context, *args)
+ end
+ def legend_bind_remove(tag, context)
+ _component_bind_remove('legend', tag, context)
+ end
+ def legend_bindinfo(tag, context=nil)
+ _component_bindinfo('legend', tag, context)
+ end
+
+ def marker_bind(tag, context, *args)
+ _component_bind('marker', tag, context, *args)
+ end
+ def marker_bind_append(tag, context, *args)
+ _component_bind_append('marker', tag, context, *args)
+ end
+ def marker_bind_remove(tag, context)
+ _component_bind_remove('marker', tag, context)
+ end
+ def marker_bindinfo(tag, context=nil)
+ _component_bindinfo('marker', tag, context)
+ end
+
+ ###################
+
+ def axis_create(id=nil, keys={})
+ # tk_send('axis', 'create', tagid(id), keys)
+ Tk::BLT::PlotComponent::Axis.new(self, tagid(id), keys)
+ end
+ def axis_delete(*ids)
+ tk_send('axis', 'delete', *(ids.collect{|id| tagid(id)}))
+ self
+ end
+ def axis_invtransform(id, val)
+ list(tk_send('axis', 'invtransform', tagid(id), val))
+ end
+ def axis_limits(id)
+ list(tk_send('axis', 'limits', tagid(id)))
+ end
+ def axis_names(*pats)
+ simplelist(tk_send('axis', 'names',
+ *(pats.collect{|pat| tagid(pat)}))).collect{|axis|
+ Tk::BLT::PlotComponent::Axis.id2obj(self, axis)
+ }
+ end
+ def axis_transform(id, val)
+ list(tk_send('axis', 'transform', tagid(id), val))
+ end
+ def axis_view(id)
+ tk_send('axis', 'view', tagid(id))
+ self
+ end
+ def axis_use(id, target=nil)
+ if target
+ Tk::BLT::PlotComponent::Axis.id2obj(self,
+ tk_send('axis', 'use',
+ tagid(id), tagid(target)))
+ else
+ Tk::BLT::PlotComponent::Axis.id2obj(self,
+ tk_send('axis', 'use', tagid(id)))
+ end
+ end
+
+ ###################
+
+ def crosshairs_off
+ tk_send_without_enc('crosshairs', 'off')
+ self
+ end
+ def crosshairs_on
+ tk_send_without_enc('crosshairs', 'on')
+ self
+ end
+ def crosshairs_toggle
+ tk_send_without_enc('crosshairs', 'toggle')
+ self
+ end
+
+ ###################
+
+ def element_create(id=nil, keys={})
+ # tk_send('element', 'create', tagid(id), keys)
+ Tk::BLT::PlotComponent::Element.new(self, tagid(id), keys)
+ end
+ def element_activate(*args)
+ if args.empty?
+ list(tk_send('element', 'activate')).collect{|elem|
+ Tk::BLT::PlotComponent::Element.id2obj(self, elem)
+ }
+ else
+ # id, *indices
+ id = args.shift
+ tk_send('element', 'activate', tagid(id), *args)
+ end
+ end
+ def element_closest(x, y, var, *args)
+ if args[-1].kind_of?(Hash)
+ keys = args.pop
+ bool(tk_send('element', 'closest', x, y, var,
+ *(hash_kv(keys).concat(args.collect{|id| tagid(id)}))))
+ else
+ bool(tk_send('element', 'closest', x, y, var,
+ *(args.collect{|id| tagid(id)})))
+ end
+ end
+ def element_deactivate(*ids)
+ tk_send('element', 'deactivate', *(ids.collect{|id| tagid(id)}))
+ self
+ end
+ def element_delete(*ids)
+ tk_send('element', 'delete', *(ids.collect{|id| tagid(id)}))
+ self
+ end
+ def element_exist?(id)
+ bool(tk_send('element', 'exists', tagid(id)))
+ end
+ def element_names(*pats)
+ simplelist(tk_send('element', 'names',
+ *(pats.collect{|pat| tagid(pat)}))).collect{|elem|
+ Tk::BLT::PlotComponent::Element.id2obj(self, elem)
+ }
+ end
+ def element_show(*names)
+ if names.empty?
+ simplelist(tk_send('element', 'show'))
+ else
+ tk_send('element', 'show', *(names.collect{|n| tagid(n)}))
+ self
+ end
+ end
+ def element_type(id)
+ tk_send('element', 'type', tagid(id))
+ end
+
+ ###################
+
+ def bar_create(id=nil, keys={})
+ # tk_send('bar', 'create', tagid(id), keys)
+ Tk::BLT::PlotComponent::Bar.new(self, tagid(id), keys)
+ end
+ alias bar bar_create
+ def bar_activate(*args)
+ if args.empty?
+ list(tk_send('bar', 'activate')).collect{|elem|
+ Tk::BLT::PlotComponent::Element.id2obj(self, elem)
+ }
+ else
+ # id, *indices
+ id = args.shift
+ tk_send('bar', 'activate', tagid(id), *args)
+ end
+ end
+ def bar_closest(x, y, var, *args)
+ if args[-1].kind_of?(Hash)
+ keys = args.pop
+ bool(tk_send('bar', 'closest', x, y, var,
+ *(hash_kv(keys).concat(args.collect{|id| tagid(id)}))))
+ else
+ bool(tk_send('bar', 'closest', x, y, var,
+ *(args.collect{|id| tagid(id)})))
+ end
+ end
+ def bar_deactivate(*ids)
+ tk_send('bar', 'deactivate', *(ids.collect{|id| tagid(id)}))
+ self
+ end
+ def bar_delete(*ids)
+ tk_send('bar', 'delete', *(ids.collect{|id| tagid(id)}))
+ self
+ end
+ def bar_exist?(id)
+ bool(tk_send('bar', 'exists', tagid(id)))
+ end
+ def bar_names(*pats)
+ simplelist(tk_send('bar', 'names',
+ *(pats.collect{|pat| tagid(pat)}))).collect{|elem|
+ Tk::BLT::PlotComponent::Element.id2obj(self, elem)
+ }
+ end
+ def bar_show(*names)
+ if names.empty?
+ simplelist(tk_send('bar', 'show'))
+ else
+ tk_send('bar', 'show', *(names.collect{|n| tagid(n)}))
+ self
+ end
+ end
+ def bar_type(id)
+ tk_send('bar', 'type', tagid(id))
+ end
+
+ ###################
+
+ def line_create(id=nil, keys={})
+ # tk_send('line', 'create', tagid(id), keys)
+ Tk::BLT::PlotComponent::Line.new(self, tagid(id), keys)
+ end
+ alias bar line_create
+ def line_activate(*args)
+ if args.empty?
+ list(tk_send('line', 'activate')).collect{|elem|
+ Tk::BLT::PlotComponent::Element.id2obj(self, elem)
+ }
+ else
+ # id, *indices
+ id = args.shift
+ tk_send('line', 'activate', tagid(id), *args)
+ end
+ end
+ def line_closest(x, y, var, *args)
+ if args[-1].kind_of?(Hash)
+ keys = args.pop
+ bool(tk_send('line', 'closest', x, y, var,
+ *(hash_kv(keys).concat(args.collect{|id| tagid(id)}))))
+ else
+ bool(tk_send('line', 'closest', x, y, var,
+ *(args.collect{|id| tagid(id)})))
+ end
+ end
+ def line_deactivate(*ids)
+ tk_send('line', 'deactivate', *(ids.collect{|id| tagid(id)}))
+ self
+ end
+ def line_delete(*ids)
+ tk_send('line', 'delete', *(ids.collect{|id| tagid(id)}))
+ self
+ end
+ def line_exist?(id)
+ bool(tk_send('line', 'exists', tagid(id)))
+ end
+ def line_names(*pats)
+ simplelist(tk_send('line', 'names',
+ *(pats.collect{|pat| tagid(pat)}))).collect{|elem|
+ Tk::BLT::PlotComponent::Element.id2obj(self, elem)
+ }
+ end
+ def line_show(*names)
+ if names.empty?
+ simplelist(tk_send('line', 'show'))
+ else
+ tk_send('line', 'show', *(names.collect{|n| tagid(n)}))
+ self
+ end
+ end
+ def line_type(id)
+ tk_send('line', 'type', tagid(id))
+ end
+
+ ###################
+
+ def gridline_off
+ tk_send_without_enc('grid', 'off')
+ self
+ end
+ def gridline_on
+ tk_send_without_enc('grid', 'on')
+ self
+ end
+ def gridline_toggle
+ tk_send_without_enc('grid', 'toggle')
+ self
+ end
+
+ ###################
+
+ def legend_window_create(parent=nil, keys=nil)
+ if parent.kind_of?(Hash)
+ keys = _symbolkey2str(parent)
+ parent = keys.delete('parent')
+ widgetname = keys.delete('widgetname')
+ keys.delete('without_creating')
+ elsif keys
+ keys = _symbolkey2str(keys)
+ widgetname = keys.delete('widgetname')
+ keys.delete('without_creating')
+ end
+
+ legend = self.class.new(parent, :without_creating=>true,
+ :widgetname=>widgetname)
+ class << legend
+ def __destroy_hook__
+ TkCore::INTERP.tk_windows.delete(@path)
+ end
+ end
+
+ if keys
+ self.legend_configure(keys.update('position'=>legend))
+ else
+ self.legend_configure('position'=>legend)
+ end
+ legend
+ end
+
+ def legend_activate(*pats)
+ list(tk_send('legend', 'activate',
+ *(pats.collect{|pat| tagid(pat)}))).collect{|elem|
+ Tk::BLT::PlotComponent::Element.id2obj(self, elem)
+ }
+ end
+ def legend_deactivate(*pats)
+ list(tk_send('legend', 'deactivate',
+ *(pats.collect{|pat| tagid(pat)}))).collect{|elem|
+ Tk::BLT::PlotComponent::Element.id2obj(self, elem)
+ }
+ end
+ def legend_get(pos, y=nil)
+ if y
+ Tk::BLT::PlotComponent::Element.id2obj(self,
+ tk_send('legend', 'get',
+ _at(pos, y)))
+ else
+ Tk::BLT::PlotComponent::Element.id2obj(self,
+ tk_send('legend', 'get', pos))
+ end
+ end
+
+ ###################
+
+ def pen_create(id=nil, keys={})
+ # tk_send('pen', 'create', tagid(id), keys)
+ Tk::BLT::PlotComponent::Pen.new(self, tagid(id), keys)
+ end
+ def pen_delete(*ids)
+ tk_send('pen', 'delete', *(ids.collect{|id| tagid(id)}))
+ self
+ end
+ def pen_names(*pats)
+ simplelist(tk_send('pen', 'names',
+ *(pats.collect{|pat| tagid(pat)}))).collect{|pen|
+ Tk::BLT::PlotComponent::Pen.id2obj(self, pen)
+ }
+ end
+
+ ###################
+
+ def postscript_output(file=nil, keys={})
+ if file.kind_of?(Hash)
+ keys = file
+ file = nil
+ end
+
+ if file
+ tk_send('postscript', 'output', file, keys)
+ self
+ else
+ tk_send('postscript', 'output', keys)
+ end
+ end
+
+ ###################
+
+ def marker_create(type, keys={})
+ case type
+ when :text, 'text'
+ Tk::BLT::PlotComponent::TextMarker.new(self, keys)
+ when :line, 'line'
+ Tk::BLT::PlotComponent::LineMarker.new(self, keys)
+ when :bitmap, 'bitmap'
+ Tk::BLT::PlotComponent::BitmapMarker.new(self, keys)
+ when :image, 'image'
+ Tk::BLT::PlotComponent::ImageMarker.new(self, keys)
+ when :polygon, 'polygon'
+ Tk::BLT::PlotComponent::PolygonMarker.new(self, keys)
+ when :window, 'window'
+ Tk::BLT::PlotComponent::WindowMarker.new(self, keys)
+ else
+ if type.kind_of?(Tk::BLT::PlotComponent::Marker)
+ type.new(self, keys)
+ else
+ Tk::BLT::PlotComponent::Marker.create_type(self, type, keys)
+ end
+ end
+ end
+ def marker_after(id, target=nil)
+ if target
+ tk_send_without_enc('marker', 'after', tagid(id), tagid(target))
+ else
+ tk_send_without_enc('marker', 'after', tagid(id))
+ end
+ self
+ end
+ def marker_before(id, target=None)
+ if target
+ tk_send_without_enc('marker', 'before', tagid(id), tagid(target))
+ else
+ tk_send_without_enc('marker', 'before', tagid(id))
+ end
+ self
+ end
+ def marker_delete(*ids)
+ tk_send('marker', 'delete', *(ids.collect{|id| tagid(id)}))
+ self
+ end
+ def marker_exist?(id)
+ bool(tk_send('marker', 'exists', tagid(id)))
+ end
+ def marker_names(*pats)
+ simplelist(tk_send('marker', 'names',
+ *(pats.collect{|pat| tagid(pat)}))).collect{|id|
+ Tk::BLT::PlotComponent::Marker.id2obj(self, id)
+ }
+ end
+ def marker_type(id)
+ tk_send('marker', 'type', tagid(id))
+ end
+
+ ###################
+
+ def xaxis_cget_tkstring(option)
+ itemcget_tkstring('xaxis', option)
+ end
+ def xaxis_cget(option)
+ itemcget('xaxis', option)
+ end
+ def xaxis_cget_strict(option)
+ itemcget_strict('xaxis', option)
+ end
+ def xaxis_configure(slot, value=None)
+ if slot.kind_of?(Hash)
+ slot = _symbolkey2str(slot)
+ if cmd = slot.delete('command')
+ slot['command'] = proc{|w, tick|
+ cmd.call(TkComm.window(w), TkComm.num_or_str(tick))
+ }
+ end
+ elsif slot == :command || slot == 'command'
+ cmd = value
+ value = proc{|w, tick|
+ cmd.call(TkComm.window(w), TkComm.num_or_str(tick))
+ }
+ end
+ itemconfigure('xaxis', slot, value)
+ end
+ def xaxis_configinfo(slot=nil)
+ itemconfiginfo('xaxis', slot)
+ end
+ def current_xaxis_configinfo(slot=nil)
+ current_itemconfiginfo('xaxis', slot)
+ end
+ def xaxis_bind(context, *args)
+ if TkComm._callback_entry?(args[0]) || !block_given?
+ cmd = args.shift
+ else
+ cmd = Proc.new
+ end
+ _bind([path, 'xaxis', 'bind'], context, cmd, *args)
+ self
+ end
+ def xaxis_bind_append(context, *args)
+ if TkComm._callback_entry?(args[0]) || !block_given?
+ cmd = args.shift
+ else
+ cmd = Proc.new
+ end
+ _bind_append([path, 'xaxis', 'bind'], context, cmd, *args)
+ self
+ end
+ def xaxis_bind_remove(context)
+ _bind_remove([path, 'xaxis', 'bind'], context)
+ self
+ end
+ def xaxis_bindinfo(context=nil)
+ _bindinfo([path, 'xaxis', 'bind'], context)
+ end
+ def xaxis_invtransform(val)
+ list(tk_send('xaxis', 'invtransform', val))
+ end
+ def xaxis_limits
+ list(tk_send('xaxis', 'limits'))
+ end
+ def xaxis_transform(val)
+ list(tk_send('xaxis', 'transform', val))
+ end
+ def xaxis_use(target=nil)
+ if target
+ Tk::BLT::PlotComponent::Axis.id2obj(self,
+ tk_send('xaxis', 'use',
+ tagid(target)))
+ else
+ Tk::BLT::PlotComponent::Axis.id2obj(self, tk_send('xaxis', 'use'))
+ end
+ end
+
+ def x2axis_cget_tkstring(option)
+ itemcget_tkstring('x2axis', option)
+ end
+ def x2axis_cget(option)
+ itemcget('x2axis', option)
+ end
+ def x2axis_cget_strict(option)
+ itemcget_strict('x2axis', option)
+ end
+ def x2axis_configure(slot, value=None)
+ if slot.kind_of?(Hash)
+ slot = _symbolkey2str(slot)
+ if cmd = slot.delete('command')
+ slot['command'] = proc{|w, tick|
+ cmd.call(TkComm.window(w), TkComm.num_or_str(tick))
+ }
+ end
+ elsif slot == :command || slot == 'command'
+ cmd = value
+ value = proc{|w, tick|
+ cmd.call(TkComm.window(w), TkComm.num_or_str(tick))
+ }
+ end
+ itemconfigure('x2axis', slot, value)
+ end
+ def x2axis_configinfo(slot=nil)
+ itemconfiginfo('x2axis', slot)
+ end
+ def current_x2axis_configinfo(slot=nil)
+ current_itemconfiginfo('x2axis', slot)
+ end
+ def x2axis_bind(context, *args)
+ if TkComm._callback_entry?(args[0]) || !block_given?
+ cmd = args.shift
+ else
+ cmd = Proc.new
+ end
+ _bind([path, 'x2axis', 'bind'], context, cmd, *args)
+ self
+ end
+ def x2axis_bind_append(context, *args)
+ if TkComm._callback_entry?(args[0]) || !block_given?
+ cmd = args.shift
+ else
+ cmd = Proc.new
+ end
+ _bind_append([path, 'x2axis', 'bind'], context, cmd, *args)
+ self
+ end
+ def x2axis_bind_remove(context)
+ _bind_remove([path, 'x2axis', 'bind'], context)
+ self
+ end
+ def x2axis_bindinfo(context=nil)
+ _bindinfo([path, 'x2axis', 'bind'], context)
+ end
+ def x2axis_invtransform(val)
+ list(tk_send('x2axis', 'invtransform', val))
+ end
+ def x2axis_limits
+ list(tk_send('x2axis', 'limits'))
+ end
+ def x2axis_transform(val)
+ list(tk_send('x2axis', 'transform', val))
+ end
+ def x2axis_use(target=nil)
+ if target
+ Tk::BLT::PlotComponent::Axis.id2obj(self,
+ tk_send('x2axis', 'use',
+ tagid(target)))
+ else
+ Tk::BLT::PlotComponent::Axis.id2obj(self, tk_send('x2axis', 'use'))
+ end
+ end
+
+ def yaxis_cget_tkstring(option)
+ itemcget_tkstring('yaxis', option)
+ end
+ def yaxis_cget(option)
+ itemcget('yaxis', option)
+ end
+ def yaxis_cget_strict(option)
+ itemcget_strict('yaxis', option)
+ end
+ def yaxis_configure(slot, value=None)
+ if slot.kind_of?(Hash)
+ slot = _symbolkey2str(slot)
+ if cmd = slot.delete('command')
+ slot['command'] = proc{|w, tick|
+ cmd.call(TkComm.window(w), TkComm.num_or_str(tick))
+ }
+ end
+ elsif slot == :command || slot == 'command'
+ cmd = value
+ value = proc{|w, tick|
+ cmd.call(TkComm.window(w), TkComm.num_or_str(tick))
+ }
+ end
+ itemconfigure('yaxis', slot, value)
+ end
+ def yaxis_configinfo(slot=nil)
+ itemconfiginfo('yaxis', slot)
+ end
+ def current_yaxis_configinfo(slot=nil)
+ current_itemconfiginfo('yaxis', slot)
+ end
+ def yaxis_bind(context, *args)
+ if TkComm._callback_entry?(args[0]) || !block_given?
+ cmd = args.shift
+ else
+ cmd = Proc.new
+ end
+ _bind([path, 'yaxis', 'bind'], context, cmd, *args)
+ self
+ end
+ def yaxis_bind_append(context, *args)
+ if TkComm._callback_entry?(args[0]) || !block_given?
+ cmd = args.shift
+ else
+ cmd = Proc.new
+ end
+ _bind_append([path, 'yaxis', 'bind'], context, cmd, *args)
+ self
+ end
+ def yaxis_bind_remove(context)
+ _bind_remove([path, 'yaxis', 'bind'], context)
+ self
+ end
+ def yaxis_bindinfo(context=nil)
+ _bindinfo([path, 'yaxis', 'bind'], context)
+ end
+ def yaxis_invtransform(val)
+ list(tk_send('yaxis', 'invtransform', val))
+ end
+ def yaxis_limits
+ list(tk_send('yaxis', 'limits'))
+ end
+ def yaxis_transform(val)
+ list(tk_send('yaxis', 'transform', val))
+ end
+ def yaxis_use(target=nil)
+ if target
+ Tk::BLT::PlotComponent::Axis.id2obj(self,
+ tk_send('yaxis', 'use',
+ tagid(target)))
+ else
+ Tk::BLT::PlotComponent::Axis.id2obj(self, tk_send('yaxis', 'use'))
+ end
+ end
+
+ def y2axis_cget_tkstring(option)
+ itemcget_tkstring('y2axis', option)
+ end
+ def y2axis_cget(option)
+ itemcget('y2axis', option)
+ end
+ def y2axis_cget_strict(option)
+ itemcget_strict('y2axis', option)
+ end
+ def y2axis_configure(slot, value=None)
+ if slot.kind_of?(Hash)
+ slot = _symbolkey2str(slot)
+ if cmd = slot.delete('command')
+ slot['command'] = proc{|w, tick|
+ cmd.call(TkComm.window(w), TkComm.num_or_str(tick))
+ }
+ end
+ elsif slot == :command || slot == 'command'
+ cmd = value
+ value = proc{|w, tick|
+ cmd.call(TkComm.window(w), TkComm.num_or_str(tick))
+ }
+ end
+ itemconfigure('y2axis', slot, value)
+ end
+ def y2axis_configinfo(slot=nil)
+ axis_configinfo('y2axis', slot)
+ end
+ def current_y2axis_configinfo(slot=nil)
+ current_itemconfiginfo('y2axis', slot)
+ end
+ def y2axis_bind(context, *args)
+ if TkComm._callback_entry?(args[0]) || !block_given?
+ cmd = args.shift
+ else
+ cmd = Proc.new
+ end
+ _bind([path, 'y2axis', 'bind'], context, cmd, *args)
+ self
+ end
+ def y2axis_bind_append(context, *args)
+ if TkComm._callback_entry?(args[0]) || !block_given?
+ cmd = args.shift
+ else
+ cmd = Proc.new
+ end
+ _bind_append([path, 'y2axis', 'bind'], context, cmd, *args)
+ self
+ end
+ def y2axis_bind_remove(context)
+ _bind_remove([path, 'y2axis', 'bind'], context)
+ self
+ end
+ def y2axis_bindinfo(context=nil)
+ _bindinfo([path, 'y2axis', 'bind'], context)
+ end
+ def y2axis_invtransform(val)
+ list(tk_send('y2axis', 'invtransform', val))
+ end
+ def y2axis_limits
+ list(tk_send('y2axis', 'limits'))
+ end
+ def y2axis_transform(val)
+ list(tk_send('y2axis', 'transform', val))
+ end
+ def y2axis_use(target=nil)
+ if target
+ Tk::BLT::PlotComponent::Axis.id2obj(self,
+ tk_send('y2axis', 'use',
+ tagid(target)))
+ else
+ Tk::BLT::PlotComponent::Axis.id2obj(self, tk_send('y2axis', 'use'))
+ end
+ end
+ end
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/blt/container.rb b/jni/ruby/ext/tk/lib/tkextlib/blt/container.rb
new file mode 100644
index 0000000..be05828
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/blt/container.rb
@@ -0,0 +1,28 @@
+#
+# tkextlib/blt/container.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+
+require 'tk'
+require 'tkextlib/blt.rb'
+
+module Tk::BLT
+ class Container < TkWindow
+ TkCommandNames = ['::blt::container'.freeze].freeze
+ WidgetClassName = 'Container'.freeze
+ WidgetClassNames[WidgetClassName] ||= self
+
+ def __strval_optkeys
+ super() << 'name'
+ end
+ private :__strval_optkeys
+
+ def find_command(pat)
+ Hash[*simplelist(tk_send_without_enc('find', '-command', pat))]
+ end
+
+ def find_name(pat)
+ Hash[*simplelist(tk_send_without_enc('find', '-name', pat))]
+ end
+ end
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/blt/cutbuffer.rb b/jni/ruby/ext/tk/lib/tkextlib/blt/cutbuffer.rb
new file mode 100644
index 0000000..1cc39df
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/blt/cutbuffer.rb
@@ -0,0 +1,23 @@
+#
+# tkextlib/blt/cutbuffer.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+
+require 'tk'
+require 'tkextlib/blt.rb'
+
+module Tk::BLT
+ module CutBuffer
+ TkCommandNames = ['::blt::cutbuffer'.freeze].freeze
+
+ def self.get(num = 0)
+ Tk.tk_call('::blt::cutbuffer', 'get', num)
+ end
+ def self.rotate(count = 1)
+ Tk.tk_call('::blt::cutbuffer', 'rotate', count)
+ end
+ def self.set(val, num = 0)
+ Tk.tk_call('::blt::cutbuffer', 'set', val, num)
+ end
+ end
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/blt/dragdrop.rb b/jni/ruby/ext/tk/lib/tkextlib/blt/dragdrop.rb
new file mode 100644
index 0000000..aa5c565
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/blt/dragdrop.rb
@@ -0,0 +1,269 @@
+#
+# tkextlib/blt/dragdrop.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+
+require 'tk'
+require 'tk/itemconfig'
+require 'tkextlib/blt.rb'
+
+module Tk::BLT
+ module DragDrop
+ extend TkCore
+
+ TkCommandNames = ['::blt::drag&drop'.freeze].freeze
+
+ class Token < TkWindow
+ WidgetClassName = 'DragDropToken'.freeze
+ WidgetClassNames[WidgetClassName] ||= self
+
+ def initialize(arg)
+ if arg.kind_of?(Hash) # arg is a hash includes the widgetpath of token
+ arg = _symbolkey2str(arg)
+ install_win(nil, arg['widgetname'])
+ else # arg is a drag&drop source
+ tk_call('::blt::drag&drop', 'source', arg)
+ install_win(nil, tk_call('::blt::drag&drop', 'token', arg))
+ end
+ end
+ end
+
+ ###################################
+
+ extend TkItemConfigMethod
+ extend Tk::ValidateConfigure
+
+ class << self
+ def __item_config_cmd(id) # id := ['source'|'target', win]
+ ['::blt::drag&drop', id[0], id[1]]
+ end
+ private :__item_config_cmd
+
+ def __item_boolval_optkeys(id)
+ super(id) << 'selftarget'
+ end
+ private :__item_boolval_optkeys
+
+ def __item_listval_optkeys(id)
+ super(id) << 'send'
+ end
+ private :__item_listval_optkeys
+
+ def __item_strval_optkeys(id)
+ super(id) << 'rejectbg' << 'rejectfg' << 'tokenbg'
+ end
+ private :__item_strval_optkeys
+
+ undef itemcget
+ undef itemcget_tkstring
+ private :itemconfigure, :itemconfiginfo, :current_itemconfiginfo
+
+ def source_configure(win, slot, value=None)
+ itemconfigure(['source', win], slot, value)
+ end
+ def source_configinfo(win, slot=nil)
+ itemconfiginfo(['source', win], slot)
+ end
+ def current_source_configinfo(win, slot=nil)
+ current_itemconfiginfo(['source', win], slot)
+ end
+ end
+
+ class PackageCommand < TkValidateCommand
+ class ValidateArgs < TkUtil::CallbackSubst
+ KEY_TBL = [
+ [ ?t, ?w, :token ],
+ [ ?W, ?w, :widget ],
+ nil
+ ]
+
+ PROC_TBL = [
+ [ ?w, TkComm.method(:window) ],
+ nil
+ ]
+
+=begin
+ # for Ruby m17n :: ?x --> String --> char-code ( getbyte(0) )
+ KEY_TBL.map!{|inf|
+ if inf.kind_of?(Array)
+ inf[0] = inf[0].getbyte(0) if inf[0].kind_of?(String)
+ inf[1] = inf[1].getbyte(0) if inf[1].kind_of?(String)
+ end
+ inf
+ }
+
+ PROC_TBL.map!{|inf|
+ if inf.kind_of?(Array)
+ inf[0] = inf[0].getbyte(0) if inf[0].kind_of?(String)
+ end
+ inf
+ }
+=end
+
+ _setup_subst_table(KEY_TBL, PROC_TBL)
+
+ def self.ret_val(val)
+ val
+ end
+ end
+
+ def self._config_keys
+ ['packagecmd']
+ end
+ end
+
+ class SiteCommand < TkValidateCommand
+ class ValidateArgs < TkUtil::CallbackSubst
+ KEY_TBL = [
+ [ ?s, ?b, :compatible ],
+ [ ?t, ?w, :token ],
+ nil
+ ]
+
+ PROC_TBL = [
+ [ ?b, TkComm.method(:bool) ],
+ [ ?w, TkComm.method(:window) ],
+ nil
+ ]
+
+=begin
+ # for Ruby m17n :: ?x --> String --> char-code ( getbyte(0) )
+ KEY_TBL.map!{|inf|
+ if inf.kind_of?(Array)
+ inf[0] = inf[0].getbyte(0) if inf[0].kind_of?(String)
+ inf[1] = inf[1].getbyte(0) if inf[1].kind_of?(String)
+ end
+ inf
+ }
+
+ PROC_TBL.map!{|inf|
+ if inf.kind_of?(Array)
+ inf[0] = inf[0].getbyte(0) if inf[0].kind_of?(String)
+ end
+ inf
+ }
+=end
+
+ _setup_subst_table(KEY_TBL, PROC_TBL)
+
+ def self.ret_val(val)
+ val
+ end
+ end
+
+ def self._config_keys
+ ['sitecmd']
+ end
+ end
+
+ def self.__validation_class_list
+ super() << PackageCommand << SiteCommand
+ end
+
+ class << self
+ Tk::ValidateConfigure.__def_validcmd(binding, PackageCommand)
+ Tk::ValidateConfigure.__def_validcmd(binding, SiteCommand)
+ end
+
+ ###################################
+
+ class DnD_Handle < TkUtil::CallbackSubst
+ KEY_TBL = [
+ [ ?i, ?s, :ip_name ],
+ [ ?v, ?v, :value ],
+ [ ?W, ?w, :widget ],
+ nil
+ ]
+
+ PROC_TBL = [
+ [ ?i, TkComm.method(:string) ],
+ [ ?v, TkComm.method(:tk_tcl2ruby) ],
+ [ ?w, TkComm.method(:window) ],
+ nil
+ ]
+
+=begin
+ # for Ruby m17n :: ?x --> String --> char-code ( getbyte(0) )
+ KEY_TBL.map!{|inf|
+ if inf.kind_of?(Array)
+ inf[0] = inf[0].getbyte(0) if inf[0].kind_of?(String)
+ inf[1] = inf[1].getbyte(0) if inf[1].kind_of?(String)
+ end
+ inf
+ }
+
+ PROC_TBL.map!{|inf|
+ if inf.kind_of?(Array)
+ inf[0] = inf[0].getbyte(0) if inf[0].kind_of?(String)
+ end
+ inf
+ }
+=end
+
+ _setup_subst_table(KEY_TBL, PROC_TBL)
+ end
+
+ def self.source_handler(win, datatype, cmd=Proc.new, *args)
+ _bind_for_event_class(DnD_Handle,
+ ['::blt::drag&drop', 'source', win, 'handler'],
+ cmd, *args)
+ end
+
+ def self.target_handler(win, datatype, cmd=Proc.new, *args)
+ _bind_for_event_class(DnD_Handle,
+ ['::blt::drag&drop', 'target', win, 'handler'],
+ cmd, *args)
+ end
+
+ ###################################
+
+ def self.init_source(win)
+ tk_call('::blt::drag&drop', 'source', win)
+ end
+
+ def self.source()
+ list(tk_call('::blt::drag&drop', 'source'))
+ end
+
+ def self.source_handler_list(win)
+ simplelist(tk_call('::blt::drag&drop', 'source', win, 'handler'))
+ end
+ def self.source_handler_info(win, type)
+ tk_tcl2ruby(tk_call('::blt::drag&drop', 'source', win, 'handler', type))
+ end
+
+ def self.target
+ list(tk_call('::blt::drag&drop', 'target'))
+ end
+ def self.target_handler_list(win)
+ simplelist(tk_call('::blt::drag&drop', 'target', win, 'handler'))
+ end
+
+ def self.handle_target(win, type, val=None)
+ tk_call('::blt::drag&drop', 'target', win, 'handle', type, val)
+ end
+
+ def self.token(win)
+ window(tk_call('::blt::drag&drop', 'token', win))
+ end
+
+ def self.drag(win, x, y)
+ tk_call('::blt::drag&drop', 'drag', win, x, y)
+ end
+ def self.drop(win, x, y)
+ tk_call('::blt::drag&drop', 'drop', win, x, y)
+ end
+
+ def self.errors(cmd=Proc.new)
+ tk_call('::blt::drag&drop', 'errors', cmd)
+ end
+
+ def self.active
+ bool(tk_call('::blt::drag&drop', 'active'))
+ end
+
+ def self.location(x=None, y=None)
+ list(tk_call('::blt::drag&drop', 'location', x, y))
+ end
+ end
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/blt/eps.rb b/jni/ruby/ext/tk/lib/tkextlib/blt/eps.rb
new file mode 100644
index 0000000..0dba87a
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/blt/eps.rb
@@ -0,0 +1,32 @@
+#
+# tkextlib/blt/eps.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+
+require 'tk'
+require 'tk/canvas'
+require 'tkextlib/blt.rb'
+
+module Tk::BLT
+ class EPS < TkcItem
+ CItemTypeName = 'eps'.freeze
+ CItemTypeToClass[CItemTypeName] = self
+ end
+end
+
+class Tk::Canvas
+ alias __BLT_EPS_item_strval_optkeys __item_strval_optkeys
+ def __item_strval_optkeys(id)
+ __BLT_EPS_item_strval_optkeys(id) + [
+ 'shadowcolor', 'title', 'titlecolor'
+ ]
+ end
+ private :__item_strval_optkeys
+
+ alias __BLT_EPS_item_boolval_optkeys __item_boolval_optkeys
+ def __item_boolval_optkeys(id)
+ __BLT_EPS_item_boolval_optkeys(id) + ['showimage']
+ end
+ private :__item_boolval_optkeys
+end
+
diff --git a/jni/ruby/ext/tk/lib/tkextlib/blt/graph.rb b/jni/ruby/ext/tk/lib/tkextlib/blt/graph.rb
new file mode 100644
index 0000000..6bd4424
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/blt/graph.rb
@@ -0,0 +1,67 @@
+#
+# tkextlib/blt/graph.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+
+require 'tk'
+require 'tkextlib/blt.rb'
+require 'tkextlib/blt/component.rb'
+
+module Tk::BLT
+ class Graph < TkWindow
+ TkCommandNames = ['::blt::graph'.freeze].freeze
+ WidgetClassName = 'Graph'.freeze
+ WidgetClassNames[WidgetClassName] ||= self
+
+ include PlotComponent
+ include GraphCommand
+
+ def __boolval_optkeys
+ ['bufferelements', 'invertxy']
+ end
+ private :__boolval_optkeys
+
+ def __strval_optkeys
+ ['text', 'label', 'title', 'file', 'plotbackground']
+ end
+ private :__strval_optkeys
+
+=begin
+ BarElement_ID = ['blt_graph_bar'.freeze, TkUtil.untrust('00000')].freeze
+
+ def bar(elem=nil, keys={})
+ if elem.kind_of?(Hash)
+ keys = elem
+ elem = nil
+ end
+ unless elem
+ elem = BarElement_ID.join(TkCore::INTERP._ip_id_).freeze
+ BarElement_ID[1].succ!
+ end
+ tk_send('bar', elem, keys)
+ Element.new(self, elem, :without_creating=>true)
+ end
+=end
+
+ def extents(item)
+ num_or_str(tk_send_without_enc('extents', item))
+ end
+
+ def invtransform(x, y)
+ list(tk_send_without_enc('invtransform', x, y))
+ end
+
+ def inside(x, y)
+ bool(tk_send_without_enc('inside', x, y))
+ end
+
+ def snap(output, keys={})
+ tk_send_without_enc('snap', *(hash_kv(keys, false) + output))
+ self
+ end
+
+ def transform(x, y)
+ list(tk_send_without_enc('transform', x, y))
+ end
+ end
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/blt/htext.rb b/jni/ruby/ext/tk/lib/tkextlib/blt/htext.rb
new file mode 100644
index 0000000..878bd99
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/blt/htext.rb
@@ -0,0 +1,112 @@
+#
+# tkextlib/blt/htext.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+
+require 'tk'
+require 'tk/itemconfig.rb'
+require 'tkextlib/blt.rb'
+
+module Tk::BLT
+ class Htext<TkWindow
+ Htext_Var = TkVarAccess.new_hash('htext')
+ Htext_Widget = TkVarAccess.new('htext(widget)', :window)
+ Htext_File = TkVarAccess.new('htext(file)')
+ Htext_Line = TkVarAccess.new('htext(line)')
+
+ include TkItemConfigMethod
+ include Scrollable
+
+ TkCommandNames = ['::blt::htext'.freeze].freeze
+ WidgetClassName = 'Htext'.freeze
+ WidgetClassNames[WidgetClassName] ||= self
+
+ alias window_cget_tkstring itemcget_tkstring
+ alias window_cget itemcget
+ alias window_cget_strict itemcget_strict
+ alias window_configure itemconfigure
+ alias window_configuinfo itemconfiginfo
+ alias current_window_configuinfo current_itemconfiginfo
+
+ def __strval_optkeys
+ super() << 'filename'
+ end
+ private :__strval_optkeys
+
+ def append(win, keys={})
+ tk_send('append', _epath(win), keys)
+ self
+ end
+
+ def goto_line(idx)
+ tk_send_without_enc('gotoline', idx)
+ self
+ end
+ def current_line
+ number(tk_send_without_enc('gotoline'))
+ end
+
+ def index(str)
+ number(tk_send('index', str))
+ end
+
+ def line_pos(str)
+ tk_send('linepos', str)
+ end
+
+ def range(from=None, to=None)
+ tk_send_without_enc('range', from, to)
+ end
+
+ def scan_mark(pos)
+ tk_send_without_enc('scan', 'mark', pos)
+ self
+ end
+
+ def scan_dragto(pos)
+ tk_send_without_enc('scan', 'dragto', pos)
+ self
+ end
+
+ def search(pat, from=None, to=None)
+ num = number(tk_send('search', pat, from, to))
+ (num < 0)? nil: num
+ end
+
+ def selection_adjust(index)
+ tk_send_without_enc('selection', 'adjust', index)
+ self
+ end
+ def selection_clear()
+ tk_send_without_enc('selection', 'clear')
+ self
+ end
+ def selection_from(index)
+ tk_send_without_enc('selection', 'from', index)
+ self
+ end
+ def selection_line(index)
+ tk_send_without_enc('selection', 'line', index)
+ self
+ end
+ def selection_present()
+ bool(tk_send_without_enc('selection', 'present'))
+ end
+ def selection_range(first, last)
+ tk_send_without_enc('selection', 'range', first, last)
+ self
+ end
+ def selection_to(index)
+ tk_send_without_enc('selection', 'to', index)
+ self
+ end
+ def selection_word(index)
+ tk_send_without_enc('selection', 'word', index)
+ self
+ end
+
+ def windows(pat=None)
+ list(tk_send('windows', pat))
+ end
+ end
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/blt/setup.rb b/jni/ruby/ext/tk/lib/tkextlib/blt/setup.rb
new file mode 100644
index 0000000..ee406c6
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/blt/setup.rb
@@ -0,0 +1,8 @@
+#
+# setup.rb -- setup script before calling TkPackage.require()
+#
+# If you need some setup operations (for example, add a library path
+# to the library search path) before using Tcl/Tk library packages
+# wrapped by Ruby scripts in this directory, please write the setup
+# operations in this file.
+#
diff --git a/jni/ruby/ext/tk/lib/tkextlib/blt/spline.rb b/jni/ruby/ext/tk/lib/tkextlib/blt/spline.rb
new file mode 100644
index 0000000..9f75a0b
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/blt/spline.rb
@@ -0,0 +1,23 @@
+#
+# tkextlib/blt/spline.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+
+require 'tk'
+require 'tkextlib/blt.rb'
+
+module Tk::BLT
+ module Spline
+ extend TkCore
+
+ TkCommandNames = ['::blt::spline'.freeze].freeze
+
+ def self.natural(x, y, sx, sy)
+ tk_call('::blt::spline', 'natural', x, y, sx, sy)
+ end
+
+ def self.quadratic(x, y, sx, sy)
+ tk_call('::blt::spline', 'quadratic', x, y, sx, sy)
+ end
+ end
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/blt/stripchart.rb b/jni/ruby/ext/tk/lib/tkextlib/blt/stripchart.rb
new file mode 100644
index 0000000..74093f1
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/blt/stripchart.rb
@@ -0,0 +1,74 @@
+#
+# tkextlib/blt/stripchart.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+
+require 'tk'
+require 'tkextlib/blt.rb'
+require 'tkextlib/blt/component.rb'
+
+module Tk::BLT
+ class Stripchart < TkWindow
+ TkCommandNames = ['::blt::stripchart'.freeze].freeze
+ WidgetClassName = 'Stripchart'.freeze
+ WidgetClassNames[WidgetClassName] ||= self
+
+ include PlotComponent
+ include GraphCommand
+
+ def __boolval_optkeys
+ ['bufferelements', 'buffergraph', 'invertxy']
+ end
+ private :__boolval_optkeys
+
+ def __strval_optkeys
+ ['text', 'label', 'title', 'file',
+ 'background', 'plotbackground']
+ end
+ private :__strval_optkeys
+
+=begin
+ BarElement_ID = ['blt_stripchart_bar'.freeze, TkUtil.untrust('00000')].freeze
+
+ def bar(elem=nil, keys={})
+ if elem.kind_of?(Hash)
+ keys = elem
+ elem = nil
+ end
+ unless elem
+ elem = BarElement_ID.join(TkCore::INTERP._ip_id_).freeze
+ BarElement_ID[1].succ!
+ end
+ tk_send('bar', elem, keys)
+ Element.new(self, elem, :without_creating=>true)
+ end
+=end
+
+ def extents(item)
+ num_or_str(tk_send_without_enc('extents', item))
+ end
+
+ def invtransform(x, y)
+ list(tk_send_without_enc('invtransform', x, y))
+ end
+
+ def inside(x, y)
+ bool(tk_send_without_enc('inside', x, y))
+ end
+
+ def metafile(file=None)
+ # Windows only
+ tk_send('metafile', file)
+ self
+ end
+
+ def snap(output, keys={})
+ tk_send_without_enc('snap', *(hash_kv(keys, false) + output))
+ self
+ end
+
+ def transform(x, y)
+ list(tk_send_without_enc('transform', x, y))
+ end
+ end
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/blt/table.rb b/jni/ruby/ext/tk/lib/tkextlib/blt/table.rb
new file mode 100644
index 0000000..205e29e
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/blt/table.rb
@@ -0,0 +1,412 @@
+#
+# tkextlib/blt/table.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+
+require 'tk'
+require 'tk/itemconfig.rb'
+require 'tkextlib/blt.rb'
+
+module Tk::BLT
+ module Table
+ include Tk
+ extend Tk
+ extend TkItemConfigMethod
+
+ TkCommandNames = ['::blt::table'.freeze].freeze
+
+ module TableContainer
+ def blt_table_add(*args)
+ Tk::BLT::Table.add(self, *args)
+ self
+ end
+
+ def blt_table_arrange()
+ Tk::BLT::Table.arrange(self)
+ self
+ end
+
+ def blt_table_cget_tkstring(*args)
+ Tk::BLT::Table.cget_tkstring(self, *args)
+ end
+ def blt_table_cget(*args)
+ Tk::BLT::Table.cget(self, *args)
+ end
+ def blt_table_cget_strict(*args)
+ Tk::BLT::Table.cget_strict(self, *args)
+ end
+
+ def blt_table_configure(*args)
+ Tk::BLT::Table.configure(self, *args)
+ self
+ end
+
+ def blt_table_configinfo(*args)
+ Tk::BLT::Table.configinfo(self, *args)
+ end
+
+ def blt_table_current_configinfo(*args)
+ Tk::BLT::Table.current_configinfo(self, *args)
+ end
+
+ def blt_table_locate(x, y)
+ Tk::BLT::Table.locate(self, x, y)
+ end
+
+ def blt_table_delete(*args)
+ Tk::BLT::Table.delete(self, *args)
+ self
+ end
+
+ def blt_table_extents(item)
+ Tk::BLT::Table.extents(self, item)
+ end
+
+ def blt_table_insert(*args)
+ Tk::BLT::Table.insert(self, *args)
+ self
+ end
+
+ def blt_table_insert_before(*args)
+ Tk::BLT::Table.insert_before(self, *args)
+ self
+ end
+
+ def blt_table_insert_after(*args)
+ Tk::BLT::Table.insert_after(self, *args)
+ self
+ end
+
+ def blt_table_join(first, last)
+ Tk::BLT::Table.join(self, first, last)
+ self
+ end
+
+ def blt_table_save()
+ Tk::BLT::Table.save(self)
+ end
+
+ def blt_table_search(*args)
+ Tk::BLT::Table.search(self, *args)
+ end
+
+ def blt_table_split(*args)
+ Tk::BLT::Table.split(self, *args)
+ self
+ end
+
+ def blt_table_itemcget_tkstring(*args)
+ Tk::BLT::Table.itemcget_tkstring(self, *args)
+ end
+ def blt_table_itemcget(*args)
+ Tk::BLT::Table.itemcget(self, *args)
+ end
+ def blt_table_itemcget_strict(*args)
+ Tk::BLT::Table.itemcget_strict(self, *args)
+ end
+
+ def blt_table_itemconfigure(*args)
+ Tk::BLT::Table.itemconfigure(self, *args)
+ self
+ end
+
+ def blt_table_itemconfiginfo(*args)
+ Tk::BLT::Table.itemconfiginfo(self, *args)
+ end
+
+ def blt_table_current_itemconfiginfo(*args)
+ Tk::BLT::Table.current_itemconfiginfo(self, *args)
+ end
+
+ def blt_table_iteminfo(item)
+ Tk::BLT::Table.iteminfo(self, item)
+ end
+ end
+ end
+end
+
+
+############################################
+class << Tk::BLT::Table
+ def __item_cget_cmd(id) # id := [ container, item ]
+ win = (id[0].kind_of?(TkWindow))? id[0].path: id[0].to_s
+ ['::blt::table', 'cget', win, id[1]]
+ end
+ private :__item_cget_cmd
+
+ def __item_config_cmd(id) # id := [ container, item, ... ]
+ container, *items = id
+ win = (container.kind_of?(TkWindow))? container.path: container.to_s
+ ['::blt::table', 'configure', win, *items]
+ end
+ private :__item_config_cmd
+
+ def __item_pathname(id)
+ win = (id[0].kind_of?(TkWindow))? id[0].path: id[0].to_s
+ win + ';'
+ end
+ private :__item_pathname
+
+ alias __itemcget_tkstring itemcget_tkstring
+ alias __itemcget itemcget
+ alias __itemcget_strict itemcget_strict
+ alias __itemconfigure itemconfigure
+ alias __itemconfiginfo itemconfiginfo
+ alias __current_itemconfiginfo current_itemconfiginfo
+
+ private :__itemcget_tkstring, :__itemcget, :__itemcget_strict
+ private :__itemconfigure, :__itemconfiginfo, :__current_itemconfiginfo
+
+ def __boolval_optkeys
+ super() << 'propagate'
+ end
+ private :__boolval_optkeys
+
+ def tagid(tag)
+ if tag.kind_of?(Array)
+ case tag[0]
+ when Integer
+ # [row, col]
+ tag.join(',')
+ when :c, :C, 'c', 'C', :r, :R, 'r', 'R'
+ # c0 or r1 or C*, and so on
+ tag.collect{|elem| elem.to_s}.join('')
+ else
+ tag
+ end
+ elsif tag.kind_of?(TkWindow)
+ _epath(tag)
+ else
+ tag
+ end
+ end
+
+ def tagid2obj(tagid)
+ tagid
+ end
+
+ ############################################
+
+ def cget_tkstring(container, option)
+ __itemcget_tkstring([container], option)
+ end
+ def cget(container, option)
+ __itemcget([container], option)
+ end
+ def cget_strict(container, option)
+ __itemcget_strict([container], option)
+ end
+
+ def configure(container, *args)
+ __itemconfigure([container], *args)
+ end
+
+ def configinfo(container, *args)
+ __itemconfiginfo([container], *args)
+ end
+
+ def current_configinfo(container, *args)
+ __current_itemconfiginfo([container], *args)
+ end
+
+ def itemcget_tkstring(container, item, option)
+ __itemcget_tkstring([container, tagid(item)], option)
+ end
+ def itemcget(container, item, option)
+ __itemcget([container, tagid(item)], option)
+ end
+ def itemcget_strict(container, item, option)
+ __itemcget_strict([container, tagid(item)], option)
+ end
+
+ def itemconfigure(container, *args)
+ if args[-1].kind_of?(Hash)
+ # container, item, item, ... , hash_optkeys
+ keys = args.pop
+ fail ArgumentError, 'no item is given' if args.empty?
+ id = [container]
+ args.each{|item| id << tagid(item)}
+ __itemconfigure(id, keys)
+ else
+ # container, item, item, ... , option, value
+ val = args.pop
+ opt = args.pop
+ fail ArgumentError, 'no item is given' if args.empty?
+ id = [container]
+ args.each{|item| id << tagid(item)}
+ __itemconfigure(id, opt, val)
+ end
+ container
+ end
+
+ def itemconfiginfo(container, *args)
+ slot = args[-1]
+ if slot.kind_of?(String) || slot.kind_of?(Symbol)
+ slot = slot.to_s
+ if slot[0] == ?. || slot =~ /^\d+,\d+$/ || slot =~ /^(c|C|r|R)(\*|\d+)/
+ # widget || row,col || Ci or Ri
+ slot = nil
+ else
+ # option
+ slot = args.pop
+ end
+ else
+ slot = nil
+ end
+
+ fail ArgumentError, 'no item is given' if args.empty?
+
+ id = [container]
+ args.each{|item| id << tagid(item)}
+ __itemconfiginfo(id, slot)
+ end
+
+ def current_itemconfiginfo(container, *args)
+ slot = args[-1]
+ if slot.kind_of?(String) || slot.kind_of?(Symbol)
+ slot = slot.to_s
+ if slot[0] == ?. || slot =~ /^\d+,\d+$/ || slot =~ /^(c|C|r|R)(\*|\d+)/
+ # widget || row,col || Ci or Ri
+ slot = nil
+ else
+ # option
+ slot = args.pop
+ end
+ else
+ slot = nil
+ end
+
+ fail ArgumentError, 'no item is given' if args.empty?
+
+ id = [container]
+ args.each{|item| id << tagid(item)}
+ __current_itemconfiginfo(id, slot)
+ end
+
+ def info(container)
+ ret = {}
+ inf = list(tk_call('::blt::table', 'info', container))
+ until inf.empty?
+ opt = inf.slice!(0..1)
+ ret[opt[1..-1]] = opt[1]
+ end
+ ret
+ end
+
+ def iteminfo(container, item)
+ inf = list(tk_call('::blt::table', 'info', container, tagid(item)).chomp)
+
+ ret = []
+ until inf.empty? || (inf[0].kind_of?(String) && inf[0] =~ /^-/)
+ ret << inf.shift
+ end
+
+ if inf.length > 1
+ keys = {}
+ while inf.length > 1
+ opt = inf.slice!(0..1)
+ keys[opt[0][1..-1]] = opt[1]
+ end
+ ret << keys
+ end
+
+ ret
+ end
+
+ ############################################
+
+ def create_container(container)
+ tk_call('::blt::table', container)
+ begin
+ class << container
+ include Tk::BLT::Table::TableContainer
+ end
+ rescue
+ warn('fail to include TableContainer methods (frozen object?)')
+ end
+ container
+ end
+
+ def add(container, *args)
+ if args.empty?
+ tk_call('::blt::table', container)
+ else
+ args = args.collect{|arg|
+ if arg.kind_of?(TkWindow)
+ _epath(arg)
+ elsif arg.kind_of?(Array) # index
+ arg.join(',')
+ else
+ arg
+ end
+ }
+ tk_call('::blt::table', container, *args)
+ end
+ container
+ end
+
+ def arrange(container)
+ tk_call('::blt::table', 'arrange', container)
+ container
+ end
+
+ def delete(container, *args)
+ tk_call('::blt::table', 'delete', container, *args)
+ end
+
+ def extents(container, item)
+ ret = []
+ inf = list(tk_call('::blt::table', 'extents', container, item))
+ ret << inf.slice!(0..4) until inf.empty?
+ ret
+ end
+
+ def forget(*wins)
+ wins = wins.collect{|win| _epath(win)}
+ tk_call('::blt::table', 'forget', *wins)
+ end
+
+ def insert(container, *args)
+ tk_call('::blt::table', 'insert', container, *args)
+ end
+
+ def insert_before(container, *args)
+ tk_call('::blt::table', 'insert', container, '-before', *args)
+ end
+
+ def insert_after(container, *args)
+ tk_call('::blt::table', 'insert', container, '-after', *args)
+ end
+
+ def join(container, first, last)
+ tk_call('::blt::table', 'join', container, first, last)
+ end
+
+ def locate(container, x, y)
+ tk_call('::blt::table', 'locate', container, x, y)
+ end
+
+ def containers(arg={})
+ list(tk_call('::blt::table', 'containers', *hash_kv(arg)))
+ end
+
+ def containers_pattern(pat)
+ list(tk_call('::blt::table', 'containers', '-pattern', pat))
+ end
+
+ def containers_slave(win)
+ list(tk_call('::blt::table', 'containers', '-slave', win))
+ end
+
+ def save(container)
+ tk_call('::blt::table', 'save', container)
+ end
+
+ def search(container, keys={})
+ list(tk_call('::blt::table', 'containers', *hash_kv(keys)))
+ end
+
+ def split(container, *args)
+ tk_call('::blt::table', 'split', container, *args)
+ end
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/blt/tabnotebook.rb b/jni/ruby/ext/tk/lib/tkextlib/blt/tabnotebook.rb
new file mode 100644
index 0000000..82936c6
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/blt/tabnotebook.rb
@@ -0,0 +1,110 @@
+#
+# tkextlib/blt/tabnotebook.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+
+require 'tk'
+require 'tkextlib/blt.rb'
+require 'tkextlib/blt/tabset.rb'
+
+module Tk::BLT
+ class Tabnotebook < Tabset
+ TkCommandNames = ['::blt::tabnotebook'.freeze].freeze
+ WidgetClassName = 'Tabnotebook'.freeze
+ WidgetClassNames[WidgetClassName] ||= self
+
+ class Tab < Tk::BLT::Tabset::Tab
+ def self.new(parent, pos=nil, name=nil, keys={})
+ if pos.kind_of?(Hash)
+ keys = pos
+ name = nil
+ pos = nil
+ end
+ if name.kind_of?(Hash)
+ keys = name
+ name = nil
+ end
+ obj = nil
+ TabID_TBL.mutex.synchronize{
+ if name && TabID_TBL[parent.path] && TabID_TBL[parent.path][name]
+ obj = TabID_TBL[parent.path][name]
+ if pos
+ if pos.to_s == 'end'
+ obj.move_after('end')
+ else
+ obj.move_before(pos)
+ end
+ end
+ obj.configure if keys && ! keys.empty?
+ else
+ (obj = self.allocate).instance_eval{
+ initialize(parent, pos, name, keys)
+ TabID_TBL[@tpath] = {} unless TabID_TBL[@tpath]
+ TabID_TBL[@tpath][@id] = self
+ }
+ end
+ }
+ obj
+ end
+
+ def initialize(parent, pos, name, keys)
+ @t = parent
+ @tpath = parent.path
+ if name
+ @path = @id = name
+ unless (list(tk_call(@tpath, 'tab', 'names', @id)).empty?)
+ if pos
+ idx = tk_call(@tpath, 'index', @id)
+ if pos.to_s == 'end'
+ tk_call(@tpath, 'move', idx, 'after', 'end')
+ else
+ tk_call(@tpath, 'move', idx, 'before', pos)
+ end
+ end
+ tk_call(@tpath, 'tab', 'configure', @id, keys)
+ else
+ fail ArgumentError, "can't find tab \"#{@id}\" in #{@t}"
+ end
+ else
+ pos = 'end' unless pos
+ @path = @id = tk_call(@tpath, 'insert', pos, keys)
+ end
+ end
+ end
+
+ #######################################
+
+ def get_tab(index)
+ if (idx = tk_send_without_enc('id', tagindex(index))).empty?
+ nil
+ else
+ Tk::BLT::Tabset::Tab.id2obj(self, idx)
+ end
+ end
+ alias get_id get_tab
+
+ def get_tabobj(index)
+ if (idx = tk_send_without_enc('id', tagindex(index))).empty?
+ nil
+ else
+ Tk::BLT::Tabnotebook::Tab.new(self, nil, idx)
+ end
+ end
+
+ alias index_name index
+
+ def insert(pos=nil, keys={})
+ if pos.kind_of?(Hash)
+ keys = pos
+ pos = nil
+ end
+ pos = 'end' if pos.nil?
+ Tk::BLT::Tabnotebook::Tab.new(self, nil,
+ tk_send('insert', tagindex(pos), keys))
+
+ end
+ undef :insert_tabs
+
+ undef :tab_pageheight, :tab_pagewidth
+ end
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/blt/tabset.rb b/jni/ruby/ext/tk/lib/tkextlib/blt/tabset.rb
new file mode 100644
index 0000000..c4716c7
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/blt/tabset.rb
@@ -0,0 +1,504 @@
+#
+# tkextlib/blt/tabset.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+
+require 'tk'
+require 'tkextlib/blt.rb'
+
+module Tk::BLT
+ class Tabset < TkWindow
+ class Tab < TkObject
+ include TkTreatItemFont
+
+ TabID_TBL = TkCore::INTERP.create_table
+
+ (TabsetTab_ID = ['blt_tabset_tab'.freeze, TkUtil.untrust('00000')]).instance_eval{
+ @mutex = Mutex.new
+ def mutex; @mutex; end
+ freeze
+ }
+
+ TkCore::INTERP.init_ip_env{
+ TabID_TBL.mutex.synchronize{ TabID_TBL.clear }
+ }
+
+ def self.id2obj(tabset, id)
+ tpath = tabset.path
+ TabID_TBL.mutex.synchronize{
+ if TabID_TBL[tpath]
+ TabID_TBL[tpath][id]? TabID_TBL[tpath][id]: id
+ else
+ id
+ end
+ }
+ end
+
+ def self.new(parent, pos=nil, name=nil, keys={})
+ if pos.kind_of?(Hash)
+ keys = pos
+ name = nil
+ pos = nil
+ end
+ if name.kind_of?(Hash)
+ keys = name
+ name = nil
+ end
+ obj = nil
+ TabID_TBL.mutex.synchronize{
+ if name && TabID_TBL[parent.path] && TabID_TBL[parent.path][name]
+ obj = TabID_TBL[parent.path][name]
+ if pos
+ if pos.to_s == 'end'
+ obj.move_after('end')
+ else
+ obj.move_before(pos)
+ end
+ end
+ obj.configure if keys && ! keys.empty?
+ else
+ (obj = self.allocate).instance_eval{
+ initialize(parent, pos, name, keys)
+ TabID_TBL[@tpath] = {} unless TabID_TBL[@tpath]
+ TabID_TBL[@tpath][@id] = self
+ }
+ end
+ }
+ obj
+ end
+
+ def initialize(parent, pos, name, keys)
+ @t = parent
+ @tpath = parent.path
+ if name
+ @path = @id = name
+ unless (list(tk_call(@tpath, 'tab', 'names', @id)).empty?)
+ if pos
+ idx = tk_call(@tpath, 'index', '-name', @id)
+ if pos.to_s == 'end'
+ tk_call(@tpath, 'move', idx, 'after', 'end')
+ else
+ tk_call(@tpath, 'move', idx, 'before', pos)
+ end
+ end
+ tk_call(@tpath, 'tab', 'configure', @id, keys)
+ else
+ pos = 'end' unless pos
+ tk_call(@tpath, 'insert', pos, @id, keys)
+ end
+ else
+ pos = 'end' unless pos
+ TabsetTab_ID.mutex.synchronize{
+ @path = @id = TabsetTab_ID.join(TkCore::INTERP._ip_id_)
+ TabsetTab_ID[1].succ!
+ }
+ tk_call(@tpath, 'insert', pos, @id, keys)
+ end
+ end
+
+ #def bind(context, cmd=Proc.new, *args)
+ # @t.tab_bind(@id, context, cmd, *args)
+ # self
+ #end
+ def bind(context, *args)
+ # if args[0].kind_of?(Proc) || args[0].kind_of?(Method)
+ if TkComm._callback_entry?(args[0]) || !block_given?
+ cmd = args.shift
+ else
+ cmd = Proc.new
+ end
+ @t.tab_bind(@id, context, cmd, *args)
+ self
+ end
+ #def bind_append(context, cmd=Proc.new, *args)
+ # @t.tab_bind_append(@id, context, cmd, *args)
+ # self
+ #end
+ def bind_append(context, *args)
+ # if args[0].kind_of?(Proc) || args[0].kind_of?(Method)
+ if TkComm._callback_entry?(args[0]) || !block_given?
+ cmd = args.shift
+ else
+ cmd = Proc.new
+ end
+ @t.tab_bind_append(@id, context, cmd, *args)
+ self
+ end
+ def bind_remove(context)
+ @t.tab_bind_remove(@id, context)
+ self
+ end
+ def bindinfo(context=nil)
+ @t.tab_bindinfo(@id, context)
+ end
+
+ def cget_tkstring(*args)
+ @t.tab_cget_tkstring(@id, *args)
+ end
+ def cget(*args)
+ @t.tab_cget(@id, *args)
+ end
+ def cget_strict(*args)
+ @t.tab_cget_strict(@id, *args)
+ end
+ def configure(*args)
+ @t.tab_configure(@id, *args)
+ end
+ def configinfo(*args)
+ @t.tab_configinfo(@id, *args)
+ end
+ def current_configinfo(*args)
+ @t.current_tab_configinfo(@id, *args)
+ end
+
+ def delete()
+ @t.delete(@id)
+ TabID_TBL.mutex.synchronize{
+ TabID_TBL[@tpath].delete(@id)
+ }
+ self
+ end
+
+ def get_name()
+ @id.dup
+ end
+
+ def focus()
+ @t.focus(self.index)
+ end
+
+ def index()
+ @t.index_name(@id)
+ end
+
+ def invoke()
+ @t.invoke(self.index)
+ end
+
+ def move_before(idx)
+ @t.move_before(self.index, idx)
+ end
+ def move_after(idx)
+ @t.move_after(self.index, idx)
+ end
+
+ def perforation_highlight(mode)
+ @t.perforation_highlight(self.index, mode)
+ end
+ def perforation_invoke()
+ @t.perforation_invoke(self.index)
+ end
+
+ def see()
+ @t.see(self.index)
+ end
+
+ def tearoff(name=None)
+ @t.tab_tearoff(self.index, *args)
+ end
+ end
+
+ ########################################
+
+ class NamedTab < Tab
+ def self.new(parent, name)
+ super(parent, nil, name, {})
+ end
+ end
+
+ ########################################
+
+ include X_Scrollable
+ include TkItemConfigMethod
+
+ TkCommandNames = ['::blt::tabset'.freeze].freeze
+ WidgetClassName = 'Tabset'.freeze
+ WidgetClassNames[WidgetClassName] ||= self
+
+ def __destroy_hook__
+ Tk::BLT::Tabset::Tab::TabID_TBL.mutex.synchronize{
+ Tk::BLT::Tabset::Tab::TabID_TBL.delete(@path)
+ }
+ end
+
+ ########################################
+
+ def __boolval_optkeys
+ super() << 'samewidth' << 'tearoff'
+ end
+ private :__strval_optkeys
+
+ def __strval_optkeys
+ super() << 'tabbackground' << 'tabforeground'
+ end
+ private :__strval_optkeys
+
+ def __item_cget_cmd(id)
+ [self.path, 'tab', 'cget', id]
+ end
+ private :__item_cget_cmd
+
+ def __item_config_cmd(id)
+ [self.path, 'tab', 'configure', id]
+ end
+ private :__item_config_cmd
+
+ def __item_pathname(tagOrId)
+ if tagOrId.kind_of?(Tk::BLT::Tabset::Tab)
+ self.path + ';' + tagOrId.id.to_s
+ else
+ self.path + ';' + tagOrId.to_s
+ end
+ end
+ private :__item_pathname
+
+ alias tab_cget_tkstring itemcget_tkstring
+ alias tab_cget itemcget
+ alias tab_cget_strict itemcget_strict
+ alias tab_configure itemconfigure
+ alias tab_configinfo itemconfiginfo
+ alias current_tab_configinfo current_itemconfiginfo
+
+ def __item_strval_optkeys(id)
+ super(id) << 'shadow'
+ end
+ private :__item_strval_optkeys
+
+ def tagid(tab)
+ if tab.kind_of?(Tk::BLT::Tabset::Tab)
+ tab.id
+ else
+ tab
+ end
+ end
+
+ def tagindex(tab)
+ if tab.kind_of?(Tk::BLT::Tabset::Tab)
+ tab.index
+ else
+ tab
+ end
+ end
+
+ ########################################
+
+ def activate(index)
+ tk_send('activate', tagindex(index))
+ self
+ end
+ alias highlight activate
+
+ #def tabbind(tag, context, cmd=Proc.new, *args)
+ # _bind([path, "bind", tagid(tag)], context, cmd, *args)
+ # self
+ #end
+ def tabbind(tag, context, *args)
+ # if args[0].kind_of?(Proc) || args[0].kind_of?(Method)
+ if TkComm._callback_entry?(args[0]) || !block_given?
+ cmd = args.shift
+ else
+ cmd = Proc.new
+ end
+ _bind([path, "bind", tagid(tag)], context, cmd, *args)
+ self
+ end
+ #def tabbind_append(tag, context, cmd=Proc.new, *args)
+ # _bind_append([path, "bind", tagid(tag)], context, cmd, *args)
+ # self
+ #end
+ def tabbind_append(tag, context, *args)
+ # if args[0].kind_of?(Proc) || args[0].kind_of?(Method)
+ if TkComm._callback_entry?(args[0]) || !block_given?
+ cmd = args.shift
+ else
+ cmd = Proc.new
+ end
+ _bind_append([path, "bind", tagid(tag)], context, cmd, *args)
+ self
+ end
+ def tabbind_remove(tag, context)
+ _bind_remove([path, "bind", tagid(tag)], context)
+ self
+ end
+ def tabbindinfo(tag, context=nil)
+ _bindinfo([path, "bind", tagid(tag)], context)
+ end
+
+ def delete(first, last=None)
+ tk_send('delete', tagindex(first), tagindex(last))
+ if first.kind_of?(Tk::BLT::Tabset::Tab)
+ TabID_TBL.mutex.synchronize{
+ TabID_TBL[@path].delete(first.id)
+ }
+ end
+ # middle tabs of the range are unknown
+ if last.kind_of?(Tk::BLT::Tabset::Tab)
+ TabID_TBL.mutex.synchronize{
+ TabID_TBL[@path].delete(last.id)
+ }
+ end
+ self
+ end
+
+ def focus(index)
+ tk_send('focus', tagindex(index))
+ self
+ end
+
+ def get_tab(index)
+ if (idx = tk_send_without_enc('get', tagindex(index))).empty?
+ nil
+ else
+ Tk::BLT::Tabset::Tab.id2obj(self, idx)
+ end
+ end
+ def get_tabobj(index)
+ if (idx = tk_send_without_enc('get', tagindex(index))).empty?
+ nil
+ else
+ Tk::BLT::Tabset::Tab.new(self, nil, name, {})
+ end
+ end
+
+ def index(str)
+ num_or_str(tk_send('index', str))
+ end
+ def index_name(tab)
+ num_or_str(tk_send('index', '-name', tagid(tab)))
+ end
+
+ def insert(pos, tab, keys={})
+ pos = 'end' if pos.nil?
+ Tk::BLT::Tabset::Tab.new(self, tagindex(pos), tagid(tab), keys)
+ end
+ def insert_tabs(pos, *tabs)
+ pos = 'end' if pos.nil?
+ if tabs[-1].kind_of?(Hash)
+ keys = tabs.pop
+ else
+ keys = {}
+ end
+ fail ArgumentError, 'no tabs is given' if tabs.empty?
+ tabs.map!{|tab| tagid(tab)}
+ tk_send('insert', tagindex(pos), *(tabs + [keys]))
+ tabs.collect{|tab| Tk::BLT::Tabset::Tab.new(self, nil, tagid(tab))}
+ end
+
+ def invoke(index)
+ tk_send('invoke', tagindex(index))
+ end
+
+ def move_before(index, base_idx)
+ tk_send('move', tagindex(index), 'before', tagindex(base_idx))
+ self
+ end
+ def move_after(index, base_idx)
+ tk_send('move', tagindex(index), 'after', tagindex(base_idx))
+ self
+ end
+
+ def nearest(x, y)
+ Tk::BLT::Tabset::Tab.id2obj(self, num_or_str(tk_send_without_enc('nearest', x, y)))
+ end
+
+ def perforation_activate(mode)
+ tk_send('perforation', 'activate', mode)
+ self
+ end
+ def perforation_highlight(index, *args)
+ if args.empty?
+ # index --> mode
+ tk_send('perforation', 'highlight', index)
+ elsif args.size == 1
+ # args[0] --> mode
+ tk_send('perforation', 'highlight', tagindex(index), args[0])
+ else # Error: call to get Tcl's error message
+ tk_send('perforation', 'highlight', tagindex(index), *args)
+ end
+ self
+ end
+ def perforation_invoke(index=nil)
+ if index
+ tk_send('perforation', 'invoke', tagindex(index))
+ else
+ tk_send('perforation', 'invoke')
+ end
+ end
+
+ def scan_mark(x, y)
+ tk_send_without_enc('scan', 'mark', x, y)
+ self
+ end
+ def scan_dragto(x, y)
+ tk_send_without_enc('scan', 'dragto', x, y)
+ self
+ end
+
+ def see(index)
+ tk_send('see', tagindex(index))
+ self
+ end
+
+ def size()
+ number(tk_send_without_enc('size'))
+ end
+
+ def select(index)
+ tk_send('select', tagindex(index))
+ self
+ end
+
+ def tab_dockall
+ tk_send('tab', 'dockall')
+ self
+ end
+
+ def tab_names(pat=None)
+ simplelist(tk_send('tab', 'names', pat)).collect{|name|
+ Tk::BLT::Tabset::Tab.id2obj(self, name)
+ }
+ end
+
+ def tab_objs(pat=None)
+ simplelist(tk_send('tab', 'names', pat)).collect{|name|
+ Tk::BLT::Tabset::Tab.new(self, nil, name, {})
+ }
+ end
+
+ def tab_ids(pat=None)
+ simplelist(tk_send('tab', 'names', pat))
+ end
+
+ def tab_pageheight
+ number(tk_send('tab', 'pageheight'))
+ end
+
+ def tab_pagewidth
+ number(tk_send('tab', 'pagewidth'))
+ end
+
+ def tab_tearoff(index, parent=None)
+ window(tk_send('tab', 'tearoff', tagindex(index), parent))
+ end
+
+ def xscrollcommand(cmd=Proc.new)
+ configure_cmd 'scrollcommand', cmd
+ self
+ end
+ alias scrollcommand xscrollcommand
+
+ def xview(*index)
+ if index.empty?
+ list(tk_send_without_enc('view'))
+ else
+ tk_send_without_enc('view', *index)
+ self
+ end
+ end
+ alias view xview
+ alias view_moveto xview_moveto
+ alias view_scroll xview_scroll
+
+ alias scrollbar xscrollbar
+ end
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/blt/ted.rb b/jni/ruby/ext/tk/lib/tkextlib/blt/ted.rb
new file mode 100644
index 0000000..53ab9ac
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/blt/ted.rb
@@ -0,0 +1,68 @@
+#
+# tkextlib/blt/ted.rb
+#
+# *** This is alpha version, because there is no document on BLT. ***
+#
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+
+require 'tk'
+require 'tkextlib/blt.rb'
+
+module Tk::BLT
+ module Ted
+ extend TkCore
+
+ TkCommandNames = ['::blt::ted'.freeze].freeze
+
+ ##############################
+
+ extend TkItemConfigMethod
+
+ class << self
+ def __item_cget_cmd(id)
+ ['::blt::ted', 'cget', id]
+ end
+ private :__item_cget_cmd
+
+ def __item_config_cmd(id)
+ ['::blt::ted', 'configure', id]
+ end
+ private :__item_config_cmd
+
+ private :itemcget_tkstring, :itemcget, :itemcget_strict
+ private :itemconfigure, :itemconfiginfo, :current_itemconfiginfo
+
+ def cget_tkstring(master, option)
+ itemcget_tkstring(master, option)
+ end
+ def cget(master, option)
+ itemcget(master, option)
+ end
+ def cget_strict(master, option)
+ itemcget_strict(master, option)
+ end
+ def configure(master, slot, value=None)
+ itemconfigure(master, slot, value)
+ end
+ def configinfo(master, slot=nil)
+ itemconfiginfo(master, slot)
+ end
+ def current_configinfo(master, slot=nil)
+ current_itemconfiginfo(master, slot)
+ end
+ end
+
+ ##############################
+
+ def self.edit(master, *args)
+ tk_call('::blt::ted', 'edit', master, *args)
+ end
+ def self.rep(master, *args)
+ tk_call('::blt::ted', 'rep', master, *args)
+ end
+ def self.select(master, *args)
+ tk_call('::blt::ted', 'select', master, *args)
+ end
+ end
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/blt/tile.rb b/jni/ruby/ext/tk/lib/tkextlib/blt/tile.rb
new file mode 100644
index 0000000..c67cafd
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/blt/tile.rb
@@ -0,0 +1,25 @@
+#
+# tkextlib/blt/tile.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+
+require 'tk'
+require 'tkextlib/blt.rb'
+
+module Tk::BLT
+ module Tile
+ TkComm::TkExtlibAutoloadModule.unshift(self)
+ # Require autoload-symbols which is a same name as widget classname.
+ # Those are used at TkComm._genobj_for_tkwidget method.
+
+ autoload :Button, 'tkextlib/blt/tile/button.rb'
+ autoload :CheckButton, 'tkextlib/blt/tile/checkbutton.rb'
+ autoload :Checkbutton, 'tkextlib/blt/tile/checkbutton.rb'
+ autoload :Radiobutton, 'tkextlib/blt/tile/radiobutton.rb'
+ autoload :RadioButton, 'tkextlib/blt/tile/radiobutton.rb'
+ autoload :Frame, 'tkextlib/blt/tile/frame.rb'
+ autoload :Label, 'tkextlib/blt/tile/label.rb'
+ autoload :Scrollbar, 'tkextlib/blt/tile/scrollbar.rb'
+ autoload :Toplevel, 'tkextlib/blt/tile/toplevel.rb'
+ end
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/blt/tile/button.rb b/jni/ruby/ext/tk/lib/tkextlib/blt/tile/button.rb
new file mode 100644
index 0000000..2e0863c
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/blt/tile/button.rb
@@ -0,0 +1,16 @@
+#
+# tkextlib/blt/tile/button.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+
+require 'tk'
+require 'tk/button'
+require 'tkextlib/blt/tile.rb'
+
+module Tk::BLT
+ module Tile
+ class Button < Tk::Button
+ TkCommandNames = ['::blt::tile::button'.freeze].freeze
+ end
+ end
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/blt/tile/checkbutton.rb b/jni/ruby/ext/tk/lib/tkextlib/blt/tile/checkbutton.rb
new file mode 100644
index 0000000..da230b5
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/blt/tile/checkbutton.rb
@@ -0,0 +1,17 @@
+#
+# tkextlib/blt/tile/checkbutton.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+
+require 'tk'
+require 'tk/checkbutton'
+require 'tkextlib/blt/tile.rb'
+
+module Tk::BLT
+ module Tile
+ class CheckButton < Tk::CheckButton
+ TkCommandNames = ['::blt::tile::checkbutton'.freeze].freeze
+ end
+ Checkbutton = CheckButton
+ end
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/blt/tile/frame.rb b/jni/ruby/ext/tk/lib/tkextlib/blt/tile/frame.rb
new file mode 100644
index 0000000..5434af4
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/blt/tile/frame.rb
@@ -0,0 +1,16 @@
+#
+# tkextlib/blt/tile/frame.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+
+require 'tk'
+require 'tk/frame'
+require 'tkextlib/blt/tile.rb'
+
+module Tk::BLT
+ module Tile
+ class Frame < Tk::Frame
+ TkCommandNames = ['::blt::tile::frame'.freeze].freeze
+ end
+ end
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/blt/tile/label.rb b/jni/ruby/ext/tk/lib/tkextlib/blt/tile/label.rb
new file mode 100644
index 0000000..f370c14
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/blt/tile/label.rb
@@ -0,0 +1,16 @@
+#
+# tkextlib/blt/tile/label.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+
+require 'tk'
+require 'tk/label'
+require 'tkextlib/blt/tile.rb'
+
+module Tk::BLT
+ module Tile
+ class Label < Tk::Label
+ TkCommandNames = ['::blt::tile::label'.freeze].freeze
+ end
+ end
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/blt/tile/radiobutton.rb b/jni/ruby/ext/tk/lib/tkextlib/blt/tile/radiobutton.rb
new file mode 100644
index 0000000..814f9a5
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/blt/tile/radiobutton.rb
@@ -0,0 +1,17 @@
+#
+# tkextlib/blt/tile/radiobutton.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+
+require 'tk'
+require 'tk/radiobutton'
+require 'tkextlib/blt/tile.rb'
+
+module Tk::BLT
+ module Tile
+ class RadioButton < Tk::RadioButton
+ TkCommandNames = ['::blt::tile::radiobutton'.freeze].freeze
+ end
+ Radiobutton = RadioButton
+ end
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/blt/tile/scrollbar.rb b/jni/ruby/ext/tk/lib/tkextlib/blt/tile/scrollbar.rb
new file mode 100644
index 0000000..2ae871d
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/blt/tile/scrollbar.rb
@@ -0,0 +1,16 @@
+#
+# tkextlib/blt/tile/scrollbar.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+
+require 'tk'
+require 'tk/scrollbar'
+require 'tkextlib/blt/tile.rb'
+
+module Tk::BLT
+ module Tile
+ class Scrollbar < Tk::Scrollbar
+ TkCommandNames = ['::blt::tile::scrollbar'.freeze].freeze
+ end
+ end
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/blt/tile/toplevel.rb b/jni/ruby/ext/tk/lib/tkextlib/blt/tile/toplevel.rb
new file mode 100644
index 0000000..76d5f86
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/blt/tile/toplevel.rb
@@ -0,0 +1,16 @@
+#
+# tkextlib/blt/tile/toplevel.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+
+require 'tk'
+require 'tk/toplevel'
+require 'tkextlib/blt/tile.rb'
+
+module Tk::BLT
+ module Tile
+ class Toplevel < Tk::Toplevel
+ TkCommandNames = ['::blt::tile::toplevel'.freeze].freeze
+ end
+ end
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/blt/tree.rb b/jni/ruby/ext/tk/lib/tkextlib/blt/tree.rb
new file mode 100644
index 0000000..1a3563e
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/blt/tree.rb
@@ -0,0 +1,1058 @@
+#
+# tkextlib/blt/tree.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+
+require 'tk'
+require 'tkextlib/blt.rb'
+
+module Tk::BLT
+ class Tree < TkObject
+ TkCommandNames = ['::blt::tree'.freeze].freeze
+
+ ###################################
+
+ class Node < TkObject
+ TreeNodeID_TBL = TkCore::INTERP.create_table
+
+ TkCore::INTERP.init_ip_env{
+ TreeNodeID_TBL.mutex.synchronize{ TreeNodeID_TBL.clear }
+ }
+
+ def self.id2obj(tree, id)
+ tpath = tree.path
+ TreeNodeID_TBL.mutex.synchronize{
+ if TreeNodeID_TBL[tpath]
+ if TreeNodeID_TBL[tpath][id]
+ TreeNodeID_TBL[tpath][id]
+ else
+ begin
+ # self.new(tree, nil, 'node'=>Integer(id))
+ id = Integer(id)
+ if bool(tk_call(@tpath, 'exists', id))
+ (obj = self.allocate).instance_eval{
+ @parent = @tree = tree
+ @tpath = tpath
+ @path = @id = id
+ TreeNodeID_TBL[@tpath] = {} unless TreeNodeID_TBL[@tpath]
+ TreeNodeID_TBL[@tpath][@id] = self
+ }
+ obj
+ else
+ id
+ end
+ rescue
+ id
+ end
+ end
+ else
+ id
+ end
+ }
+ end
+
+ def self.new(tree, parent, keys={})
+ keys = _symbolkey2str(keys)
+ tpath = tree.path
+
+ TreeNodeID_TBL.mutex.synchronize{
+ TreeNodeID_TBL[tpath] ||= {}
+ if (id = keys['node']) && (obj = TreeNodeID_TBL[tpath][id])
+ keys.delete('node')
+ tk_call(tree.path, 'move', id, parent, keys) if parent
+ return obj
+ end
+
+ (obj = self.allocate).instance_eval{
+ initialize(tree, parent, keys)
+ TreeNodeID_TBL[tpath][@id] = self
+ }
+ obj
+ }
+ end
+
+ def initialize(tree, parent, keys={})
+ @parent = @tree = tree
+ @tpath = @parent.path
+
+ if (id = keys['node']) && bool(tk_call(@tpath, 'exists', id))
+ @path = @id = id
+ keys.delete('node')
+ tk_call(@tpath, 'move', @id, parent, keys) if parent
+ else
+ parent = tk_call(@tpath, 'root') unless parent
+ @path = @id = tk_call(@tpath, 'insert', parent, keys)
+ end
+ end
+
+ def id
+ @id
+ end
+
+ def apply(keys={})
+ @tree.apply(@id, keys)
+ self
+ end
+
+ def children()
+ @tree.children(@id)
+ end
+
+ def copy(parent, keys={})
+ @tree.copy(@id, parent, keys)
+ end
+ def copy_to(dest_tree, parent, keys={})
+ @tree.copy_to(@id, dest_tree, parent, keys)
+ end
+
+ def degree()
+ @tree.degree(@id)
+ end
+
+ def delete()
+ @tree.delete(@id)
+ self
+ end
+
+ def depth()
+ @tree.depth(@id)
+ end
+
+ def dump()
+ @tree.dump(@id)
+ end
+
+ def dump_to_file(file)
+ @tree.dump_to_file(@id, file)
+ self
+ end
+
+ def exist?(keys={})
+ @tree.exist?(@id, keys)
+ end
+
+ def find(keys={})
+ @tree.find(@id, keys)
+ end
+
+ def find_child(label)
+ @tree.find_child(@id, label)
+ end
+
+ def first_child()
+ @tree.first_child(@id)
+ end
+
+ def get()
+ @tree.get(@id)
+ end
+ def get_value(key, default_val=None)
+ @tree.get_value(@id, key, default_val)
+ end
+
+ def index()
+ @tree.index(@id)
+ end
+
+ def leaf?()
+ @tree.leaf?(@id)
+ end
+ def link?()
+ @tree.link?(@id)
+ end
+ def root?()
+ @tree.root?(@id)
+ end
+
+ def keys()
+ @tree.keys(@id)
+ end
+
+ def label(text = nil)
+ @tree.label(@id, nil)
+ end
+ def label=(text)
+ @tree.label(@id, text)
+ end
+
+ def last_child()
+ @tree.last_child(@id)
+ end
+
+ def move(dest, keys={})
+ @tree.keys(@id, dest, keys)
+ self
+ end
+
+ def next()
+ @tree.next(@id)
+ end
+
+ def next_sibling()
+ @tree.next_sibling(@id)
+ end
+
+ def parent()
+ @tree.parent(@id)
+ end
+
+ def fullpath()
+ @tree.fullpath(@id)
+ end
+
+ def position()
+ @tree.position(@id)
+ end
+
+ def previous()
+ @tree.previous(@id)
+ end
+
+ def prev_sibling()
+ @tree.prev_sibling(@id)
+ end
+
+ def restore(str, keys={})
+ @tree.restore(@id, str, keys)
+ self
+ end
+ def restore_overwrite(str, keys={})
+ @tree.restore_overwrite(@id, str, keys)
+ self
+ end
+
+ def restore_from_file(file, keys={})
+ @tree.restore_from_file(@id, file, keys)
+ self
+ end
+ def restore_overwrite_from_file(file, keys={})
+ @tree.restore_overwrite_from_file(@id, file, keys)
+ self
+ end
+
+ def root()
+ @tree.root(@id)
+ self
+ end
+
+ def set(data)
+ @tree.set(@id, data)
+ self
+ end
+
+ def size()
+ @tree.size(@id)
+ end
+
+ def sort(keys={})
+ @tree.sort(@id, keys)
+ self
+ end
+
+ def type(key)
+ @tree.type(@id, key)
+ end
+
+ def unset(*keys)
+ @tree.unset(@id, *keys)
+ self
+ end
+
+ def values(key=None)
+ @tree.values(@id, key)
+ end
+ end
+
+ ###################################
+
+ class Tag < TkObject
+ TreeTagID_TBL = TkCore::INTERP.create_table
+
+ TkCore::INTERP.init_ip_env{
+ TreeTagID_TBL.mutex.synchronize{ TreeTagID_TBL.clear }
+ }
+
+ (TreeTag_ID = ['blt_tree_tag'.freeze, TkUtil.untrust('00000')]).instance_eval{
+ @mutex = Mutex.new
+ def mutex; @mutex; end
+ freeze
+ }
+
+ def self.id2obj(tree, id)
+ tpath = tree.path
+ TreeTagID_TBL.mutex.synchronize{
+ if TreeTagID_TBL[tpath]
+ if TreeTagID_TBL[tpath][id]
+ TreeTagID_TBL[tpath][id]
+ else
+ begin
+ # self.new(tree, id)
+ (obj = self.allocate).instance_eval{
+ @parent = @tree = tree
+ @tpath = @parent.path
+ @path = @id = id.dup.freeze if id
+ TreeTagID_TBL[@tpath] = {} unless TreeTagID_TBL[@tpath]
+ TreeTagID_TBL[@tpath][@id] = self
+ }
+ obj
+ rescue
+ id
+ end
+ end
+ else
+ id
+ end
+ }
+ end
+
+ def initialize(tree, tag_str = nil)
+ @parent = @tree = tree
+ @tpath = @parent.path
+
+ if tag_str
+ @path = @id = tag_str.dup.freeze
+ else
+ TreeTag_ID.mutex.synchronize{
+ @path = @id = TreeTag_ID.join(TkCore::INTERP._ip_id_)
+ TreeTag_ID[1].succ!
+ }
+ end
+ TreeTagID_TBL.mutex.synchronize{
+ TreeTagID_TBL[@tpath] = {} unless TreeTagID_TBL[@tpath]
+ TreeTagID_TBL[@tpath][@id] = self
+ }
+ end
+
+ def id
+ @id
+ end
+
+ def add(*nodes)
+ tk_call(@tpath, 'tag', 'add', @id, *nodes)
+ self
+ end
+
+ def delete(*nodes)
+ tk_call(@tpath, 'tag', 'delete', @id, *nodes)
+ self
+ end
+
+ def forget()
+ tk_call(@tpath, 'tag', 'forget', @id)
+ TreeTagID_TBL.mutex.synchronize{
+ TreeTagID_TBL[@tpath].delete(@id)
+ }
+ self
+ end
+
+ def nodes()
+ simplelist(tk_call(@tpath, 'tag', 'nodes', @id)).collect{|node|
+ Tk::BLT::Tree::Node.id2obj(@path, node)
+ }
+ end
+
+ def set(node)
+ tk_call(@tpath, 'tag', 'set', node, @id)
+ self
+ end
+
+ def unset(node)
+ tk_call(@tpath, 'tag', 'unset', node, @id)
+ self
+ end
+ end
+
+ ###################################
+
+ class Notify < TkObject
+ NotifyID_TBL = TkCore::INTERP.create_table
+
+ TkCore::INTERP.init_ip_env{
+ NotifyID_TBL.mutex.synchronize{ NotifyID_TBL.clear }
+ }
+
+ def self.id2obj(tree, id)
+ tpath = tree.path
+ NotifyID_TBL.mutex.synchronize{
+ if NotifyID_TBL[tpath]
+ if NotifyID_TBL[tpath][id]
+ NotifyID_TBL[tpath][id]
+ else
+ (obj = self.allocate).instance_eval{
+ @parent = @tree = tree
+ @tpath = @parent.path
+ @path = @id = id
+ NotifyID_TBL[@tpath] ||= {}
+ NotifyID_TBL[@tpath][@id] = self
+ }
+ obj
+ end
+ else
+ return id
+ end
+ }
+ end
+
+ def self.new(tree, *args, &b)
+ NotifyID_TBL.mutex.synchronize{
+ if tree.kind_of?(Array)
+ # not create
+ tpath = tree[0].path
+ NotifyID_TBL[tpath] ||= {}
+ unless (obj = NotifyID_TBL[tpath][tree[1]])
+ (NotifyID_TBL[tpath][tree[1]] =
+ obj = self.allocate).instance_eval{
+ @parent = @tree = tree[0]
+ @tpath = @parent.path
+ @path = @id = tree[1]
+ }
+ end
+ return obj
+ end
+
+ (obj = self.allocate).instance_eval{
+ initialize(tree, *args, &b)
+ NotifyID_TBL[@tpath] ||= {}
+ NotifyID_TBL[@tpath][@id] = self
+ }
+ return obj
+ }
+ end
+
+ def initialize(tree, *args, &b)
+ @parent = @tree = tree
+ @tpath = @parent.path
+
+ # if args[0].kind_of?(Proc) || args[0].kind_of?(Method)
+ if TkComm._callback_entry?(args[0])
+ cmd = args.shift
+ # elsif args[-1].kind_of?(Proc) || args[-1].kind_of?(Method)
+ elsif TkComm._callback_entry?(args[-1])
+ cmd = args.pop
+ elsif b
+ cmd = Proc.new(&b)
+ else
+ fail ArgumentError, "lack of 'command' argument"
+ end
+
+ args = args.collect{|arg| '-' << arg.to_s}
+
+ args << proc{|id, type|
+ cmd.call(Tk::BLT::Tree::Node.id2obj(@tree, id),
+ ((type[0] == ?-)? type[1..-1]: type))
+ }
+
+ @path = @id = tk_call(@tpath, 'notify', 'create', *args)
+ end
+
+ def id
+ @id
+ end
+
+ def delete()
+ tk_call(@tpath, 'notify', 'delete', @id)
+ NotifyID_TBL.mutex.synchronize{
+ NotifyID_TBL[@tpath].delete(@id)
+ }
+ self
+ end
+
+ def info()
+ lst = simplelist(tk_call(@tpath, 'notify', 'info', id))
+ lst[0] = Tk::BLT::Tree::Notify.id2obj(@tree, lst[0])
+ lst[1] = simplelist(lst[1]).collect{|flag| flag[1..-1]}
+ lst[2] = tk_tcl2ruby(lst[2])
+ lst
+ end
+ end
+
+ ###################################
+
+ class Trace < TkObject
+ TraceID_TBL = TkCore::INTERP.create_table
+
+ TkCore::INTERP.init_ip_env{
+ TraceID_TBL.mutex.synchronize{ TraceID_TBL.clear }
+ }
+
+ def self.id2obj(tree, id)
+ tpath = tree.path
+ TraceID_TBL.mutex.synchronize{
+ if TraceID_TBL[tpath]
+ if TraceID_TBL[tpath][id]
+ TraceID_TBL[tpath][id]
+ else
+ begin
+ # self.new([tree, id])
+ (obj = self.allocate).instance_eval{
+ @parent = @tree = tree
+ @tpath = @parent.path
+ @path = @id = node # == traceID
+ TraceID_TBL[@tpath] ||= {}
+ TraceID_TBL[@tpath][@id] = self
+ }
+ obj
+ rescue
+ id
+ end
+ end
+ else
+ id
+ end
+ }
+ end
+
+ def self.new(tree, *args, &b)
+ TraceID_TBL.mutex.synchronize{
+ if tree.kind_of?(Array)
+ # not create
+ tpath = tree[0].path
+ TraceID_TBL[tpath] ||= {}
+ unless (obj = TraceID_TBL[tpath][tree[1]])
+ (TraceID_TBL[tpath][tree[1]] =
+ obj = self.allocate).instance_eval{
+ @parent = @tree = tree
+ @tpath = @parent.path
+ @path = @id = tree[1] # == traceID
+ }
+ end
+ return obj
+ end
+
+ # super(true, tree, *args, &b)
+ (obj = self.allocate).instance_eval{
+ initialize(tree, *args, &b)
+ TraceID_TBL[@tpath] ||= {}
+ TraceID_TBL[@tpath][@id] = self
+ }
+ return obj
+ }
+ end
+
+ def initialize(tree, node, key, opts, cmd=nil, &b)
+ @parent = @tree = tree
+ @tpath = @parent.path
+
+ if !cmd
+ if b
+ cmd = Proc.new(&b)
+ else
+ fail ArgumentError, "lack of 'command' argument"
+ end
+ end
+
+ @path = @id = tk_call(@tpath, 'trace', 'create', node, key, opts,
+ proc{|t, id, k, ops|
+ tobj = Tk::BLT::Tree.id2obj(t)
+ if tobj.kind_of?(Tk::BLT::Tree)
+ nobj = Tk::BLT::Tree::Node.id2obj(tobj, id)
+ else
+ nobj = id
+ end
+ cmd.call(tobj, nobj, k, ops)
+ })
+ end
+
+ def id
+ @id
+ end
+
+ def delete()
+ tk_call(@tpath, 'trace', 'delete', @id)
+ TraceID_TBL.mutex.synchronize{
+ TraceID_TBL[tpath].delete(@id)
+ }
+ self
+ end
+
+ def info()
+ lst = simplelist(tk_call(@tpath, 'trace', 'info', id))
+ lst[0] = Tk::BLT::Tree::Trace.id2obj(@tree, lst[0])
+ lst[2] = simplelist(lst[2])
+ lst[3] = tk_tcl2ruby(lst[3])
+ lst
+ end
+ end
+
+ ###################################
+
+ TreeID_TBL = TkCore::INTERP.create_table
+
+ (Tree_ID = ['blt_tree'.freeze, TkUtil.untrust('00000')]).instance_eval{
+ @mutex = Mutex.new
+ def mutex; @mutex; end
+ freeze
+ }
+
+ def __keyonly_optkeys
+ {
+ # apply / find command
+ 'invert'=>nil, 'leafonly'=>nil, 'nocase'=>nil,
+
+ # apply / find / sort command
+ 'path'=>nil,
+
+ # copy / restore / restorefile command
+ 'overwrite'=>nil,
+
+ # copy command
+ 'recurse'=>nil, 'tags'=>nil,
+
+ # sort command
+ 'ascii'=>nil, 'decreasing'=>nil, 'disctionary'=>nil,
+ 'integer'=>nil, 'real'=>nil, 'recurse'=>nil, 'reorder'=>nil,
+ }
+ end
+
+ def self.id2obj(id)
+ TreeID_TBL.mutex.synchronize{
+ TreeID_TBL[id]? TreeID_TBL[id]: id
+ }
+ end
+
+ def self.names(pat = None)
+ simplelist(tk_call('::blt::tree', 'names', pat)).collect{|name|
+ id2obj(name)
+ }
+ end
+
+ def self.destroy(*names)
+ tk_call('::blt::tree', 'destroy',
+ *(names.collect{|n| (n.kind_of?(Tk::BLT::Tree))? n.id: n }) )
+ end
+
+ def self.new(name = nil)
+ TreeID_TBL.mutex.synchronize{
+ if name && TreeID_TBL[name]
+ TreeID_TBL[name]
+ else
+ (obj = self.allocate).instance_eval{
+ initialize(name)
+ TreeID_TBL[@id] = self
+ }
+ obj
+ end
+ }
+ end
+
+ def initialzie(name = nil)
+ if name
+ @path = @id = name
+ else
+ Tree_ID.mutex.synchronize{
+ @path = @id = Tree_ID.join(TkCore::INTERP._ip_id_)
+ Tree_ID[1].succ!
+ }
+ end
+
+ tk_call('::blt::tree', 'create', @id)
+ end
+
+ def __destroy_hook__
+ Tk::BLT::Tree::Node::TreeNodeID_TBL.mutex.synchronize{
+ Tk::BLT::Tree::Node::TreeNodeID_TBL.delete(@path)
+ }
+ Tk::BLT::Tree::Tag::TreeTagID_TBL.mutex.synchronize{
+ Tk::BLT::Tree::Tag::TreeTagID_TBL.delete(@path)
+ }
+ Tk::BLT::Tree::Notify::NotifyID_TBL.mutex.synchronize{
+ Tk::BLT::Tree::Notify::NotifyID_TBL.delete(@path)
+ }
+ Tk::BLT::Tree::Trace::TraceID_TBL.mutex.synchronize{
+ Tk::BLT::Tree::Trace::TraceID_TBL.delete(@path)
+ }
+ end
+
+ def tagid(tag)
+ if tag.kind_of?(Tk::BLT::Tree::Node) ||
+ tag.kind_of?(Tk::BLT::Tree::Tag) ||
+ tag.kind_of?(Tk::BLT::Tree::Notify) ||
+ tag.kind_of?(Tk::BLT::Tree::Trace)
+ tag.id
+ else
+ tag # maybe an Array of configure parameters
+ end
+ end
+
+ def destroy()
+ tk_call('::blt::tree', 'destroy', @id)
+ self
+ end
+
+ def ancestor(node1, node2)
+ Tk::BLT::Tree::Node.id2obj(self, tk_call('::blt::tree', 'ancestor',
+ tagid(node1), tagid(node2)))
+ end
+
+ def apply(node, keys={})
+ tk_call('::blt::tree', 'apply', tagid(node), __conv_keyonly_opts(keys))
+ self
+ end
+
+ def attach(tree_obj)
+ tk_call('::blt::tree', 'attach', tree_obj)
+ self
+ end
+
+ def children(node)
+ simplelist(tk_call('::blt::tree', 'children', tagid(node))).collect{|n|
+ Tk::BLT::Tree::Node.id2obj(self, n)
+ }
+ end
+
+ def copy(src, parent, keys={})
+ id = tk_call('::blt::tree', 'copy', tagid(src), tagid(parent),
+ __conv_keyonly_opts(keys))
+ Tk::BLT::Tree::Node.new(self, nil, 'node'=>id)
+ end
+ def copy_to(src, dest_tree, parent, keys={})
+ return copy(src, parent, keys={}) unless dest_tree
+
+ id = tk_call('::blt::tree', 'copy', tagid(src), dest_tree,
+ tagid(parent), __conv_keyonly_opts(keys))
+ Tk::BLT::Tree::Node.new(dest_tree, nil, 'node'=>id)
+ end
+
+ def degree(node)
+ number(tk_call('::blt::tree', 'degree', tagid(node)))
+ end
+
+ def delete(*nodes)
+ tk_call('::blt::tree', 'delete', *(nodes.collect{|node| tagid(node)}))
+ Tk::BLT::Tree::Node::TreeNodeID_TBL.mutex.synchronize{
+ nodes.each{|node|
+ if node.kind_of?(Tk::BLT::Tree::Node)
+ Tk::BLT::Tree::Node::TreeNodeID_TBL[@path].delete(node.id)
+ else
+ Tk::BLT::Tree::Node::TreeNodeID_TBL[@path].delete(node.to_s)
+ end
+ }
+ }
+ self
+ end
+
+ def depth(node)
+ number(tk_call('::blt::tree', 'depth', tagid(node)))
+ end
+
+ def dump(node)
+ simplelist(tk_call('::blt::tree', 'dump', tagid(node))).collect{|n|
+ simplelist(n)
+ }
+ end
+
+ def dump_to_file(node, file)
+ tk_call('::blt::tree', 'dumpfile', tagid(node), file)
+ self
+ end
+
+ def exist?(node, key=None)
+ bool(tk_call('::blt::tree', 'exists', tagid(node), key))
+ end
+
+ def find(node, keys={})
+ simplelist(tk_call('::blt::tree', 'find', tagid(node),
+ __conv_keyonly_opts(keys))).collect{|n|
+ Tk::BLT::Tree::Node.id2obj(self, n)
+ }
+ end
+
+ def find_child(node, label)
+ ret = tk_call('::blt::tree', 'findchild', tagid(node), label)
+ (ret == '-1')? nil: Tk::BLT::Tree::Node.id2obj(self, ret)
+ end
+
+ def first_child(node)
+ ret = tk_call('::blt::tree', 'firstchild', tagid(node))
+ (ret == '-1')? nil: Tk::BLT::Tree::Node.id2obj(self, ret)
+ end
+
+ def get(node)
+ Hash[*simplelist(tk_call('::blt::tree', 'get', tagid(node)))]
+ end
+ def get_value(node, key, default_val=None)
+ tk_call('::blt::tree', 'get', tagid(node), key, default_val)
+ end
+
+ def index(node)
+ Tk::BLT::Tree::Node.id2obj(self,
+ tk_call('::blt::tree', 'index', tagid(node)))
+ end
+
+ def insert(parent, keys={})
+ id = tk_call('::blt::tree', 'insert', tagid(parent), keys)
+ Tk::BLT::Tree::Node.new(self, nil, 'node'=>id)
+ end
+
+ def ancestor?(node1, node2)
+ bool(tk_call('::blt::tree', 'is', 'ancestor',
+ tagid(node1), tagid(node2)))
+ end
+ def before?(node1, node2)
+ bool(tk_call('::blt::tree', 'is', 'before',
+ tagid(node1), tagid(node2)))
+ end
+ def leaf?(node)
+ bool(tk_call('::blt::tree', 'is', 'leaf', tagid(node)))
+ end
+ def link?(node)
+ bool(tk_call('::blt::tree', 'is', 'link', tagid(node)))
+ end
+ def root?(node)
+ bool(tk_call('::blt::tree', 'is', 'root', tagid(node)))
+ end
+
+ def keys(node, *nodes)
+ if nodes.empty?
+ simplelist(tk_call('blt::tree', 'keys', tagid(node)))
+ else
+ simplelist(tk_call('blt::tree', 'keys', tagid(node),
+ *(nodes.collect{|n| tagid(n)}))).collect{|lst|
+ simplelist(lst)
+ }
+ end
+ end
+
+ def label(node, text=nil)
+ if text
+ tk_call('::blt::tree', 'label', tagid(node), text)
+ text
+ else
+ tk_call('::blt::tree', 'label', tagid(node))
+ end
+ end
+
+ def last_child(node)
+ ret = tk_call('::blt::tree', 'lastchild', tagid(node))
+ (ret == '-1')? nil: Tk::BLT::Tree::Node.id2obj(self, ret)
+ end
+
+ def link(parent, node, keys={})
+ ret = tk_call('::blt::tree', 'link', tagid(parent), tagid(node),
+ __conv_keyonly_opts(keys))
+ (ret == '-1')? nil: Tk::BLT::Tree::Node.id2obj(self, ret)
+ end
+
+ def move(node, dest, keys={})
+ tk_call('::blt::tree', 'move', tagid(node), tagid(dest), keys)
+ self
+ end
+
+ def next(node)
+ ret = tk_call('::blt::tree', 'next', tagid(node))
+ (ret == '-1')? nil: Tk::BLT::Tree::Node.id2obj(self, ret)
+ end
+
+ def next_sibling(node)
+ ret = tk_call('::blt::tree', 'nextsibling', tagid(node))
+ (ret == '-1')? nil: Tk::BLT::Tree::Node.id2obj(self, ret)
+ end
+
+ def notify_create(*args, &b)
+ Tk::BLT::Tree::Notify.new(self, *args, &b)
+ end
+
+ def notify_delete(id)
+ if id.kind_of?(Tk::BLT::Tree::Notify)
+ id.delete
+ else
+ tk_call(@path, 'notify', 'delete', id)
+ Tk::BLT::Tree::Notify::NotifyID_TBL.mutex.synchronize{
+ Tk::BLT::Tree::Notify::NotifyID_TBL[@path].delete(id.to_s)
+ }
+ end
+ self
+ end
+
+ def notify_info(id)
+ lst = simplelist(tk_call(@path, 'notify', 'info', tagid(id)))
+ lst[0] = Tk::BLT::Tree::Notify.id2obj(self, lst[0])
+ lst[1] = simplelist(lst[1]).collect{|flag| flag[1..-1]}
+ lst[2] = tk_tcl2ruby(lst[2])
+ lst
+ end
+
+ def notify_names()
+ tk_call(@path, 'notify', 'names').collect{|id|
+ Tk::BLT::Tree::Notify.id2obj(self, id)
+ }
+ end
+
+ def parent(node)
+ ret = tk_call('::blt::tree', 'parent', tagid(node))
+ (ret == '-1')? nil: Tk::BLT::Tree::Node.id2obj(self, ret)
+ end
+
+ def fullpath(node)
+ tk_call('::blt::tree', 'path', tagid(node))
+ end
+
+ def position(node)
+ number(tk_call('::blt::tree', 'position', tagid(node)))
+ end
+
+ def previous(node)
+ ret = tk_call('::blt::tree', 'previous', tagid(node))
+ (ret == '-1')? nil: Tk::BLT::Tree::Node.id2obj(self, ret)
+ end
+
+ def prev_sibling(node)
+ ret = tk_call('::blt::tree', 'prevsibling', tagid(node))
+ (ret == '-1')? nil: Tk::BLT::Tree::Node.id2obj(self, ret)
+ end
+
+ def restore(node, str, keys={})
+ tk_call('::blt::tree', 'restore', tagid(node), str,
+ __conv_keyonly_opts(keys))
+ self
+ end
+ def restore_overwrite(node, str, keys={})
+ keys = __conv_keyonly_opts(keys)
+ keys.delete('overwrite')
+ keys.delete(:overwrite)
+ tk_call('::blt::tree', 'restore', tagid(node), str, '-overwrite', keys)
+ self
+ end
+
+ def restore_from_file(node, file, keys={})
+ tk_call('::blt::tree', 'restorefile', tagid(node), file,
+ __conv_keyonly_opts(keys))
+ self
+ end
+ def restore_overwrite_from_file(node, file, keys={})
+ keys = __conv_keyonly_opts(keys)
+ keys.delete('overwrite')
+ keys.delete(:overwrite)
+ tk_call('::blt::tree', 'restorefile', tagid(node), file,
+ '-overwrite', keys)
+ self
+ end
+
+ def root(node=None)
+ Tk::BLT::Tree::Node.id2obj(self, tk_call('::blt::tree', 'root',
+ tagid(node)))
+ end
+
+ def set(node, data)
+ unless data.kind_of?(Hash)
+ fail ArgumentError, 'Hash is expected for data'
+ end
+ args = []
+ data.each{|k, v| args << k << v}
+ tk_call('::blt::tree', 'set', tagid(node), *args)
+ self
+ end
+
+ def size(node)
+ number(tk_call('::blt::tree', 'size', tagid(node)))
+ end
+
+ def sort(node, keys={})
+ tk_call('::blt::tree', 'sort', tagid(node), __conv_keyonly_opts(keys))
+ self
+ end
+
+ def tag_add(tag, *nodes)
+ tk_call(@path, 'tag', 'add', tagid(tag), *(nodes.collect{|n| tagid(n)}))
+ self
+ end
+
+ def tag_delete(tag, *nodes)
+ tk_call(@path, 'tag', 'delete', tagid(tag),
+ *(nodes.collect{|n| tagid(n)}))
+ self
+ end
+
+ def tag_forget(tag)
+ tag = tag.id if tag.kind_of?(Tk::BLT::Tree::Tag)
+ tk_call(@path, 'tag', 'forget', tag)
+ TreeTagID_TBL.mutex.synchronize{
+ TreeTagID_TBL[@path].delete(tag)
+ }
+ self
+ end
+
+ def tag_get(node, *patterns)
+ simplelist(tk_call(@tpath, 'tag', 'get', tagid(node),
+ *(patterns.collect{|pat| tagid(pat)}))).collect{|str|
+ Tk::BLT::Tree::Tag.id2obj(self, str)
+ }
+ end
+
+ def tag_names(node = None)
+ simplelist(tk_call(@tpath, 'tag', 'names', tagid(node))).collect{|str|
+ Tk::BLT::Tree::Tag.id2obj(self, str)
+ }
+ end
+
+ def tag_nodes(tag)
+ simplelist(tk_call(@tpath, 'tag', 'nodes', tagid(tag))).collect{|node|
+ Tk::BLT::Tree::Node.id2obj(self, node)
+ }
+ end
+
+ def tag_set(node, *tags)
+ tk_call(@path, 'tag', 'set', tagid(node), *(tags.collect{|t| tagid(t)}))
+ self
+ end
+
+ def tag_unset(node, *tags)
+ tk_call(@path, 'tag', 'unset', tagid(node),
+ *(tags.collect{|t| tagid(t)}))
+ self
+ end
+
+ def trace_create(*args, &b)
+ Tk::BLT::Tree::Trace.new(self, *args, &b)
+ end
+
+=begin
+ def trace_delete(*args)
+ args.each{|id|
+ if id.kind_of?(Tk::BLT::Tree::Trace)
+ id.delete
+ else
+ tk_call(@path, 'trace', 'delete', id)
+ Tk::BLT::Tree::Trace::TraceID_TBL[@path].delete(id.to_s)
+ end
+ self
+ }
+ end
+=end
+ def trace_delete(*args)
+ args = args.collect{|id| tagid(id)}
+ tk_call(@path, 'trace', 'delete', *args)
+ Tk::BLT::Tree::Trace::TraceID_TBL.mutex.synchronize{
+ args.each{|id| Tk::BLT::Tree::Trace::TraceID_TBL[@path].delete(id.to_s)}
+ }
+ self
+ end
+
+ def trace_info(id)
+ lst = simplelist(tk_call(@path, 'trace', 'info', tagid(id)))
+ lst[0] = Tk::BLT::Tree::Trace.id2obj(self, lst[0])
+ lst[2] = simplelist(lst[2])
+ lst[3] = tk_tcl2ruby(lst[3])
+ lst
+ end
+
+ def trace_names()
+ tk_call(@path, 'trace', 'names').collect{|id|
+ Tk::BLT::Tree::Trace.id2obj(self, id)
+ }
+ end
+
+ def type(node, key)
+ tk_call('::blt::tree', 'type', tagid(node), key)
+ end
+
+ def unset(node, *keys)
+ tk_call('::blt::tree', 'unset', tagid(node), *keys)
+ self
+ end
+
+ def values(node, key=None)
+ simplelist(tk_call('::blt::tree', 'values', tagid(node), key))
+ end
+ end
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/blt/treeview.rb b/jni/ruby/ext/tk/lib/tkextlib/blt/treeview.rb
new file mode 100644
index 0000000..38d9041
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/blt/treeview.rb
@@ -0,0 +1,1287 @@
+#
+# tkextlib/blt/treeview.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+
+require 'tk'
+require 'tkextlib/blt.rb'
+require 'tk/validation.rb'
+
+module Tk::BLT
+ class Treeview < TkWindow
+ module ConfigMethod
+ end
+
+ module TagOrID_Methods
+ end
+
+ class Node < TkObject
+ end
+
+ class Tag < TkObject
+ end
+ end
+
+ class Hiertable < Treeview
+ end
+end
+
+######################################
+
+module Tk::BLT::Treeview::ConfigMethod
+ include TkItemConfigMethod
+
+ def __item_boolval_optkeys(id)
+ case id
+ when Array
+ # id := [ 'column', name ]
+ ['edit', 'hide']
+ when 'sort'
+ ['decreasing']
+ else
+ []
+ end
+ end
+ private :__item_boolval_optkeys
+
+ def __item_strval_optkeys(id)
+ case id
+ when Array
+ # id := [ 'column', name ]
+ super() << 'titleforeground' << 'titleshadow'
+ when 'sort'
+ ['decreasing']
+ else
+ []
+ end
+ end
+ private :__item_strval_optkeys
+
+ def __item_listval_optkeys(id)
+ case id
+ when 'entry'
+ ['bindtags']
+ else
+ []
+ end
+ end
+ private :__item_listval_optkeys
+
+ def __item_cget_cmd(id)
+ if id.kind_of?(Array)
+ # id := [ type, name ]
+ [self.path, id[0], 'cget', id[1]]
+ else
+ [self.path, id, 'cget']
+ end
+ end
+ private :__item_cget_cmd
+
+ def __item_config_cmd(id)
+ if id.kind_of?(Array)
+ # id := [ type, name ]
+ [self.path, id[0], 'configure', id[1]]
+ else
+ [self.path, id, 'configure']
+ end
+ end
+ private :__item_config_cmd
+
+ def __item_pathname(id)
+ if id.kind_of?(Array)
+ id = tagid(id[1])
+ end
+ [self.path, id].join(';')
+ end
+ private :__item_pathname
+
+ def column_cget_tkstring(name, option)
+ itemcget_tkstring(['column', name], option)
+ end
+ def column_cget(name, option)
+ itemcget(['column', name], option)
+ end
+ def column_cget_strict(name, option)
+ itemcget_strict(['column', name], option)
+ end
+ def column_configure(name, slot, value=None)
+ itemconfigure(['column', name], slot, value)
+ end
+ def column_configinfo(name, slot=nil)
+ itemconfiginfo(['column', name], slot)
+ end
+ def current_column_configinfo(name, slot=nil)
+ current_itemconfiginfo(['column', name], slot)
+ end
+
+ def button_cget_tkstring(option)
+ itemcget_tkstring('button', option)
+ end
+ def button_cget(option)
+ itemcget('button', option)
+ end
+ def button_cget_strict(option)
+ itemcget_strict('button', option)
+ end
+ def button_configure(slot, value=None)
+ itemconfigure('button', slot, value)
+ end
+ def button_configinfo(slot=nil)
+ itemconfiginfo('button', slot)
+ end
+ def current_button_configinfo(slot=nil)
+ current_itemconfiginfo('button', slot)
+ end
+
+ def entry_cget_tkstring(option)
+ itemcget_tkstring('entry', option)
+ end
+ def entry_cget(option)
+ ret = itemcget('entry', option)
+ if option == 'bindtags' || option == :bindtags
+ ret.collect{|tag| TkBindTag.id2obj(tag)}
+ else
+ ret
+ end
+ end
+ def entry_cget_strict(option)
+ ret = itemcget_strict('entry', option)
+ if option == 'bindtags' || option == :bindtags
+ ret.collect{|tag| TkBindTag.id2obj(tag)}
+ else
+ ret
+ end
+ end
+ def entry_configure(slot, value=None)
+ itemconfigure('entry', slot, value)
+ end
+ def entry_configinfo(slot=nil)
+ ret = itemconfiginfo('entry', slot)
+
+ if TkComm::GET_CONFIGINFO_AS_ARRAY
+ if slot
+ if slot == 'bindtags' || slot == :bindtags
+ ret[-2] = ret[-2].collect{|tag| TkBindTag.id2obj(tag)}
+ ret[-1] = ret[-1].collect{|tag| TkBindTag.id2obj(tag)}
+ end
+ else
+ inf = ret.assoc('bindtags')
+ inf[-2] = inf[-2].collect{|tag| TkBindTag.id2obj(tag)}
+ inf[-1] = inf[-1].collect{|tag| TkBindTag.id2obj(tag)}
+ end
+
+ else # ! TkComm::GET_CONFIGINFO_AS_ARRAY
+ if (inf = ret['bindtags'])
+ inf[-2] = inf[-2].collect{|tag| TkBindTag.id2obj(tag)}
+ inf[-1] = inf[-1].collect{|tag| TkBindTag.id2obj(tag)}
+ ret['bindtags'] = inf
+ end
+ end
+
+ ret
+ end
+ def current_entry_configinfo(slot=nil)
+ ret = current_itemconfiginfo('entry', slot)
+
+ if (val = ret['bindtags'])
+ ret['bindtags'] = val.collect{|tag| TkBindTag.id2obj(tag)}
+ end
+
+ ret
+ end
+
+ def sort_cget_tkstring(option)
+ itemcget_tkstring('sort', option)
+ end
+ def sort_cget(option)
+ itemcget('sort', option)
+ end
+ def sort_cget_strict(option)
+ itemcget_strict('sort', option)
+ end
+ def sort_configure(slot, value=None)
+ itemconfigure('sort', slot, value)
+ end
+ def sort_configinfo(slot=nil)
+ itemconfiginfo('sort', slot)
+ end
+ def current_sort_configinfo(slot=nil)
+ current_itemconfiginfo('sort', slot)
+ end
+
+ def text_cget_tkstring(option)
+ itemcget_tkstring('text', option)
+ end
+ def text_cget(option)
+ itemcget('text', option)
+ end
+ def text_cget_strict(option)
+ itemcget_strict('text', option)
+ end
+ def text_configure(slot, value=None)
+ itemconfigure('text', slot, value)
+ end
+ def text_configinfo(slot=nil)
+ itemconfiginfo('text', slot)
+ end
+ def current_text_configinfo(slot=nil)
+ current_itemconfiginfo('text', slot)
+ end
+
+ private :itemcget_tkstring, :itemcget, :itemcget_strict
+ private :itemconfigure, :itemconfiginfo, :current_itemconfiginfo
+end
+
+class Tk::BLT::Treeview
+ TkCommandNames = ['::blt::treeview'.freeze].freeze
+ WidgetClassName = 'TreeView'.freeze
+ WidgetClassNames[WidgetClassName] ||= self
+
+ include Scrollable
+ include ValidateConfigure
+ include ItemValidateConfigure
+ include Tk::BLT::Treeview::ConfigMethod
+
+ ########################
+
+ def __boolval_optkeys
+ ['autocreate', 'allowduplicates', 'exportselection', 'flat', 'hideroot',
+ 'newtags', 'showtitles', 'sortselection']
+ end
+ private :__boolval_optkeys
+
+ def __strval_optkeys
+ super() + ['focusforeground', 'linecolor', 'separator', 'trim']
+ end
+ private :__strval_optkeys
+
+ ########################
+
+ class OpenCloseCommand < TkValidateCommand
+ class ValidateArgs < TkUtil::CallbackSubst
+ KEY_TBL = [
+ [ ?W, ?w, :widget ],
+ [ ?p, ?s, :name ],
+ [ ?P, ?s, :fullpath ],
+ [ ?#, ?x, :node_id ],
+ nil
+ ]
+
+ PROC_TBL = [
+ [ ?x, TkComm.method(:num_or_str) ],
+ [ ?s, TkComm.method(:string) ],
+ [ ?w, TkComm.method(:window) ],
+ nil
+ ]
+
+=begin
+ # for Ruby m17n :: ?x --> String --> char-code ( getbyte(0) )
+ KEY_TBL.map!{|inf|
+ if inf.kind_of?(Array)
+ inf[0] = inf[0].getbyte(0) if inf[0].kind_of?(String)
+ inf[1] = inf[1].getbyte(0) if inf[1].kind_of?(String)
+ end
+ inf
+ }
+
+ PROC_TBL.map!{|inf|
+ if inf.kind_of?(Array)
+ inf[0] = inf[0].getbyte(0) if inf[0].kind_of?(String)
+ end
+ inf
+ }
+=end
+
+ _setup_subst_table(KEY_TBL, PROC_TBL);
+
+ def self.ret_val(val)
+ val
+ end
+ end
+
+ def self._config_keys
+ ['opencommand', 'closecomand']
+ end
+ end
+
+ def __validation_class_list
+ super() << OpenCloseCommand
+ end
+
+ Tk::ValidateConfigure.__def_validcmd(binding, OpenCloseCommand)
+
+ ########################
+
+ def __item_validation_class_list(id)
+ case id
+ when 'entry'
+ super(id) << OpenCloseCommand
+ else
+ super(id)
+ end
+ end
+
+ Tk::ItemValidateConfigure.__def_validcmd(binding, OpenCloseCommand)
+
+ ########################
+
+ def __destroy_hook__
+ Tk::BLT::Treeview::Node::TreeNodeID_TBL.mutex.synchronize{
+ Tk::BLT::Treeview::Node::TreeNodeID_TBL.delete(@path)
+ }
+ Tk::BLT::Treeview::Tag::TreeTagID_TBL.mutex.synchronize{
+ Tk::BLT::Treeview::Tag::TreeTagID_TBL.delete(@path)
+ }
+ end
+
+ def tagid(tag)
+ if tag.kind_of?(Tk::BLT::Treeview::Node) \
+ || tag.kind_of?(Tk::BLT::Treeview::Tag)
+ tag.id
+ else
+ tag # maybe an Array of configure parameters
+ end
+ end
+ private :tagid
+
+ def tagid2obj(tagid)
+ if tagid.kind_of?(Integer)
+ Tk::BLT::Treeview::Node.id2obj(self, tagid.to_s)
+ elsif tagid.kind_of?(String)
+ if tagid =~ /^\d+$/
+ Tk::BLT::Treeview::Node.id2obj(self, tagid)
+ else
+ Tk::BLT::Treeview::Tag.id2obj(self, tagid)
+ end
+ else
+ tagid
+ end
+ end
+
+ def bbox(*tags)
+ list(tk_send('bbox', *(tags.collect{|tag| tagid(tag)})))
+ end
+
+ def screen_bbox(*tags)
+ list(tk_send('bbox', '-screen', *(tags.collect{|tag| tagid(tag)})))
+ end
+
+ def tag_bind(tag, seq, *args)
+ if TkComm._callback_entry?(args[0]) || !block_given?
+ cmd = args.shift
+ else
+ cmd = Proc.new
+ end
+ _bind([@path, 'bind', tagid(tag)], seq, cmd, *args)
+ self
+ end
+ def tag_bind_append(tag, seq, *args)
+ if TkComm._callback_entry?(args[0]) || !block_given?
+ cmd = args.shift
+ else
+ cmd = Proc.new
+ end
+ _bind_append([@path, 'bind', tagid(tag)], seq, cmd, *args)
+ self
+ end
+ def tag_bind_remove(tag, seq)
+ _bind_remove([@path, 'bind', tagid(tag)], seq)
+ self
+ end
+ def tag_bindinfo(tag, seq=nil)
+ _bindinfo([@path, 'bind', tagid(tag)], seq)
+ end
+
+ def button_activate(tag)
+ tk_send('button', 'activate', tagid(tag))
+ self
+ end
+
+ def button_bind(tag, seq, *args)
+ if TkComm._callback_entry?(args[0]) || !block_given?
+ cmd = args.shift
+ else
+ cmd = Proc.new
+ end
+ _bind([@path, 'button', 'bind', tagid(tag)], seq, cmd, *args)
+ self
+ end
+ def button_bind_append(tag, seq, *args)
+ if TkComm._callback_entry?(args[0]) || !block_given?
+ cmd = args.shift
+ else
+ cmd = Proc.new
+ end
+ _bind_append([@path, 'button', 'bind', tagid(tag)], seq, cmd, *args)
+ self
+ end
+ def button_bind_remove(tag, seq)
+ _bind_remove([@path, 'button', 'bind', tagid(tag)], seq)
+ self
+ end
+ def button_bindinfo(tag, seq=nil)
+ _bindinfo([@path, 'button', 'bind', tagid(tag)], seq)
+ end
+
+ def close(*tags)
+ tk_send('close', *(tags.collect{|tag| tagid(tag)}))
+ self
+ end
+ def close_recurse(*tags)
+ tk_send('close', '-recurse', *(tags.collect{|tag| tagid(tag)}))
+ self
+ end
+
+ def column_activate(column=None)
+ if column == None
+ tk_send('column', 'activate')
+ else
+ tk_send('column', 'activate', column)
+ self
+ end
+ end
+
+ def column_delete(*fields)
+ tk_send('column', 'delete', *fields)
+ self
+ end
+ def column_insert(pos, field, *opts)
+ tk_send('column', 'insert', pos, field, *opts)
+ self
+ end
+ def column_invoke(field)
+ tk_send('column', 'invoke', field)
+ self
+ end
+ def column_move(name, dest)
+ tk_send('column', 'move', name, dest)
+ self
+ end
+ def column_names()
+ simplelist(tk_send('column', 'names'))
+ end
+ def column_nearest(x, y=None)
+ tk_send('column', 'nearest', x, y)
+ end
+
+ def curselection
+ simplelist(tk_send('curselection')).collect{|id| tagid2obj(id)}
+ end
+
+ def delete(*tags)
+ tk_send('delete', *(tags.collect{|tag| tagid(tag)}))
+ self
+ end
+
+ def entry_activate(tag)
+ tk_send('entry', 'activate', tagid(tag))
+ self
+ end
+ def entry_children(tag, first=None, last=None)
+ simplelist(tk_send('entry', 'children', tagid(tag),
+ first, last)).collect{|id| tagid2obj(id)}
+ end
+ def entry_delete(tag, first=None, last=None)
+ tk_send('entry', 'delete', tagid(tag), first, last)
+ end
+ def entry_before?(tag1, tag2)
+ bool(tk_send('entry', 'isbefore', tagid(tag1), tagid(tag2)))
+ end
+ def entry_hidden?(tag)
+ bool(tk_send('entry', 'ishidden', tagid(tag)))
+ end
+ def entry_open?(tag)
+ bool(tk_send('entry', 'isopen', tagid(tag)))
+ end
+
+ def entry_size(tag)
+ number(tk_send('entry', 'size', tagid(tag)))
+ end
+ def entry_size_recurse(tag)
+ number(tk_send('entry', 'size', '-recurse', tagid(tag)))
+ end
+
+ def _search_flags(keys)
+ keys = _symbolkey2str(keys)
+ keys['exact'] = None if keys.delete('exact')
+ keys['glob'] = None if keys.delete('glob')
+ keys['regexp'] = None if keys.delete('regexp')
+ keys['nonmatching'] = None if keys.delete('nonmatching')
+ end
+ private :_search_flags
+
+ ################################
+
+ class FindExecFlagValue < TkValidateCommand
+ class ValidateArgs < TkUtil::CallbackSubst
+ KEY_TBL = [
+ [ ?W, ?w, :widget ],
+ [ ?p, ?s, :name ],
+ [ ?P, ?s, :fullpath ],
+ [ ?#, ?x, :node_id ],
+ nil
+ ]
+
+ PROC_TBL = [
+ [ ?x, TkComm.method(:num_or_str) ],
+ [ ?s, TkComm.method(:string) ],
+ [ ?w, TkComm.method(:window) ],
+ nil
+ ]
+
+=begin
+ # for Ruby m17n :: ?x --> String --> char-code ( getbyte(0) )
+ KEY_TBL.map!{|inf|
+ if inf.kind_of?(Array)
+ inf[0] = inf[0].getbyte(0) if inf[0].kind_of?(String)
+ inf[1] = inf[1].getbyte(0) if inf[1].kind_of?(String)
+ end
+ inf
+ }
+
+ PROC_TBL.map!{|inf|
+ if inf.kind_of?(Array)
+ inf[0] = inf[0].getbyte(0) if inf[0].kind_of?(String)
+ end
+ inf
+ }
+=end
+
+ _setup_subst_table(KEY_TBL, PROC_TBL);
+
+ def self.ret_val(val)
+ val
+ end
+ end
+
+ def self._config_keys
+ []
+ end
+ end
+
+ def _find_exec_flag_value(val)
+ if val.kind_of?(Array)
+ cmd, *args = val
+ #FindExecFlagValue.new(cmd, args.join(' '))
+ FindExecFlagValue.new(cmd, *args)
+ elsif TkComm._callback_entry?(val)
+ FindExecFlagValue.new(val)
+ else
+ val
+ end
+ end
+
+ ################################
+
+ def find(first, last, keys={})
+ keys = _search_flags(keys)
+ keys['exec'] = _find_exec_flag_value(keys['exec']) if keys.key?('exec')
+ args = hash_kv(keys) << '--' << tagid(first) << tagid(last)
+ simplelist(tk_send('find', *args)).collect{|id| tagid2obj(id)}
+ end
+
+ def tag_focus(tag)
+ tk_send('focus', tagid(tag))
+ self
+ end
+ def get(*tags)
+ simplelist(tk_send('get', *(tags.collect{|tag| tagid(tag)})))
+ end
+ def get_full(*tags)
+ simplelist(tk_send('get', '-full', *(tags.collect{|tag| tagid(tag)})))
+ end
+
+ def hide(*tags)
+ if tags[-1].kind_of?(Hash)
+ keys = tags.pop
+ else
+ keys = {}
+ end
+ keys = _search_flags(keys)
+ args = hash_kv(keys) << '--'
+ args.concat(tags.collect{|t| tagid(t)})
+ tk_send('hide', *args)
+ self
+ end
+
+ def index(str)
+ tagid2obj(tk_send('index', str))
+ end
+ def index_at(tag, str)
+ tagid2obj(tk_send('index', '-at', tagid(tag), str))
+ end
+ def index_at_path(tag, str)
+ tagid2obj(tk_send('index', '-at', tagid(tag), '-path', str))
+ end
+
+ def insert(pos, parent=nil, keys={})
+ Tk::BLT::Treeview::Node.new(pos, parent, keys)
+ end
+ def insert_at(tag, pos, parent=nil, keys={})
+ if parent.kind_of?(Hash)
+ keys = parent
+ parent = nil
+ end
+
+ keys = _symbolkey2str(keys)
+ keys['at'] = tagid(tag)
+
+ Tk::BLT::Treeview::Node.new(pos, parent, keys)
+ end
+
+ def move_before(tag, dest)
+ tk_send('move', tagid(tag), 'before', tagid(dest))
+ self
+ end
+ def move_after(tag, dest)
+ tk_send('move', tagid(tag), 'after', tagid(dest))
+ self
+ end
+ def move_into(tag, dest)
+ tk_send('move', tagid(tag), 'into', tagid(dest))
+ self
+ end
+
+ def nearest(x, y, var=None)
+ tagid2obj(tk_send('nearest', x, y, var))
+ end
+
+ def open(*tags)
+ tk_send('open', *(tags.collect{|tag| tagid(tag)}))
+ self
+ end
+ def open_recurse(*tags)
+ tk_send('open', '-recurse', *(tags.collect{|tag| tagid(tag)}))
+ self
+ end
+
+ def range(first, last)
+ simplelist(tk_send('range', tagid(first), tagid(last))).collect{|id|
+ tagid2obj(id)
+ }
+ end
+ def range_open(first, last)
+ simplelist(tk_send('range', '-open',
+ tagid(first), tagid(last))).collect{|id|
+ tagid2obj(id)
+ }
+ end
+
+ def scan_mark(x, y)
+ tk_send_without_enc('scan', 'mark', x, y)
+ self
+ end
+ def scan_dragto(x, y)
+ tk_send_without_enc('scan', 'dragto', x, y)
+ self
+ end
+
+ def see(tag)
+ tk_send_without_enc('see', tagid(tag))
+ self
+ end
+ def see_anchor(anchor, tag)
+ tk_send_without_enc('see', '-anchor', anchor, tagid(tag))
+ self
+ end
+
+ def selection_anchor(tag)
+ tk_send_without_enc('selection', 'anchor', tagid(tag))
+ self
+ end
+ def selection_cancel()
+ tk_send_without_enc('selection', 'cancel')
+ self
+ end
+ def selection_clear(first, last=None)
+ tk_send_without_enc('selection', 'clear', tagid(first), tagid(last))
+ self
+ end
+ def selection_clear_all()
+ tk_send_without_enc('selection', 'clearall')
+ self
+ end
+ def selection_mark(tag)
+ tk_send_without_enc('selection', 'mark', tagid(tag))
+ self
+ end
+ def selection_include?(tag)
+ bool(tk_send('selection', 'include', tagid(tag)))
+ end
+ def selection_present?()
+ bool(tk_send('selection', 'present'))
+ end
+ def selection_set(first, last=None)
+ tk_send_without_enc('selection', 'set', tagid(first), tagid(last))
+ self
+ end
+ def selection_toggle(first, last=None)
+ tk_send_without_enc('selection', 'toggle', tagid(first), tagid(last))
+ self
+ end
+
+ def show(*tags)
+ if tags[-1].kind_of?(Hash)
+ keys = tags.pop
+ else
+ keys = {}
+ end
+ keys = _search_flags(keys)
+ args = hash_kv(keys) << '--'
+ args.concat(tags.collect{|t| tagid(t)})
+ tk_send('show', *args)
+ self
+ end
+
+ def sort_auto(mode)
+ tk_send('sort', 'auto', mode)
+ self
+ end
+ def sort_auto=(mode)
+ tk_send('sort', 'auto', mode)
+ mode
+ end
+ def sort_auto?
+ bool(tk_send('sort', 'auto'))
+ end
+ def sort_once(*tags)
+ tk_send('sort', 'once', *(tags.collect{|tag| tagid(tag)}))
+ self
+ end
+ def sort_once_recurse(*tags)
+ tk_send('sort', 'once', '-recurse', *(tags.collect{|tag| tagid(tag)}))
+ self
+ end
+
+ def tag_add(tag, *ids)
+ tk_send('tag', 'add', tagid(tag), *ids)
+ self
+ end
+ def tag_delete(tag, *ids)
+ tk_send('tag', 'delete', tagid(tag), *ids)
+ self
+ end
+ def tag_forget(tag)
+ tk_send('tag', 'forget', tagid(tag))
+ self
+ end
+ def tag_names(id=nil)
+ id = (id)? tagid(id): None
+
+ simplelist(tk_send('tag', 'nodes', id)).collect{|tag|
+ Tk::BLT::Treeview::Tag.id2obj(self, tag)
+ }
+ end
+ def tag_nodes(tag)
+ simplelist(tk_send('tag', 'nodes', tagid(tag))).collect{|id|
+ Tk::BLT::Treeview::Node.id2obj(self, id)
+ }
+ end
+
+ def text_apply
+ tk_send('text', 'apply')
+ self
+ end
+ def text_cancel
+ tk_send('text', 'cancel')
+ self
+ end
+
+ def text_delete(first, last)
+ tk_send('text', 'delete', first, last)
+ self
+ end
+ def text_get(x, y)
+ tk_send('text', 'get', x, y)
+ end
+ def text_get_root(x, y)
+ tk_send('text', 'get', '-root', x, y)
+ end
+ def text_icursor(idx)
+ tk_send('text', 'icursor', idx)
+ self
+ end
+ def text_index(idx)
+ num_or_str(tk_send('text', 'index', idx))
+ end
+ def text_insert(idx, str)
+ tk_send('text', 'insert', idx, str)
+ self
+ end
+
+ def text_selection_adjust(idx)
+ tk_send('text', 'selection', 'adjust', idx)
+ self
+ end
+ def text_selection_clear
+ tk_send('text', 'selection', 'clear')
+ self
+ end
+ def text_selection_from(idx)
+ tk_send('text', 'selection', 'from', idx)
+ self
+ end
+ def text_selection_present
+ num_or_str(tk_send('text', 'selection', 'present'))
+ end
+ def text_selection_range(start, last)
+ tk_send('text', 'selection', 'range', start, last)
+ self
+ end
+ def text_selection_to(idx)
+ tk_send('text', 'selection', 'to', idx)
+ self
+ end
+
+ def toggle(tag)
+ tk_send('toggle', tagid(tag))
+ self
+ end
+end
+
+######################################
+
+module Tk::BLT::Treeview::TagOrID_Methods
+ def bbox
+ @tree.bbox(self)
+ end
+ def screen_bbox
+ @tree.screen_bbox(self)
+ end
+
+ def bind(seq, *args)
+ @tree.tag_bind(self, seq, *args)
+ self
+ end
+ def bind_append(seq, *args)
+ @tree.tag_bind_append(self, seq, *args)
+ self
+ end
+ def bind_remove(seq)
+ @tree.tag_bind_remove(self, seq)
+ self
+ end
+ def bindinfo(seq=nil)
+ @tree.tag_bindinfo(self, seq)
+ end
+
+ def button_activate
+ @tree.button_activate(self)
+ self
+ end
+
+ def button_bind(seq, *args)
+ @tree.button_bind(self, seq, *args)
+ self
+ end
+ def button_bind_append(seq, *args)
+ @tree.button_bind_append(self, seq, *args)
+ self
+ end
+ def button_bind_remove(seq)
+ @tree.button_bind_remove(self, seq)
+ self
+ end
+ def button_bindinfo(seq=nil)
+ @tree.button_bindinfo(self, seq)
+ end
+
+ def close
+ @tree.close(self)
+ self
+ end
+ def close_recurse
+ @tree.close_recurse(self)
+ self
+ end
+
+ def delete
+ @tree.delete(self)
+ self
+ end
+
+ def entry_activate
+ @tree.entry_activate(self)
+ self
+ end
+ def entry_children(first=None, last=None)
+ @tree.entry_children(self, first, last)
+ end
+ def entry_delete(first=None, last=None)
+ @tree.entry_delete(self, first, last)
+ end
+ def entry_before?(tag)
+ @tree.entry_before?(self, tag)
+ end
+ def entry_hidden?
+ @tree.entry_before?(self)
+ end
+ def entry_open?
+ @tree.entry_open?(self)
+ end
+
+ def entry_size
+ @tree.entry_size(self)
+ end
+ def entry_size_recurse
+ @tree.entry_size_recurse(self)
+ end
+
+ def focus
+ @tree.tag_focus(self)
+ self
+ end
+
+ def get
+ @tree.get(self)
+ end
+ def get_full
+ @tree.get_full(self)
+ end
+
+ def hide
+ @tree.hide(self)
+ self
+ end
+
+ def index(str)
+ @tree.index_at(self, str)
+ end
+ def index_path(str)
+ @tree.index_at_path(self, str)
+ end
+
+ def insert(pos, parent=nil, keys={})
+ @tree.insert_at(self, pos, parent, keys)
+ end
+
+ def move_before(dest)
+ @tree.move_before(self, dest)
+ self
+ end
+ def move_after(dest)
+ @tree.move_after(self, dest)
+ self
+ end
+ def move_into(dest)
+ @tree.move_into(self, dest)
+ self
+ end
+
+ def open
+ @tree.open(self)
+ self
+ end
+ def open_recurse
+ @tree.open_recurse(self)
+ self
+ end
+
+ def range_to(tag)
+ @tree.range(self, tag)
+ end
+ def range_open_to(tag)
+ @tree.range(self, tag)
+ end
+
+ def see
+ @tree.see(self)
+ self
+ end
+ def see_anchor(anchor)
+ @tree.see_anchor(anchor, self)
+ self
+ end
+
+ def selection_anchor
+ @tree.selection_anchor(self)
+ self
+ end
+ def selection_clear
+ @tree.selection_clear(self)
+ self
+ end
+ def selection_mark
+ @tree.selection_mark(self)
+ self
+ end
+ def selection_include?
+ @tree.selection_include?(self)
+ end
+ def selection_set
+ @tree.selection_set(self)
+ self
+ end
+ def selection_toggle
+ @tree.selection_toggle(self)
+ self
+ end
+
+ def show
+ @tree.show(self)
+ self
+ end
+
+ def sort_once
+ @tree.sort_once(self)
+ self
+ end
+ def sort_once_recurse
+ @tree.sort_once_recurse(self)
+ self
+ end
+
+ def toggle
+ @tree.toggle(self)
+ self
+ end
+end
+
+######################################
+
+class Tk::BLT::Treeview::Node < TkObject
+ include Tk::BLT::Treeview::TagOrID_Methods
+
+ TreeNodeID_TBL = TkCore::INTERP.create_table
+
+ (TreeNode_ID = ['blt_treeview_node'.freeze, TkUtil.untrust('00000')]).instance_eval{
+ @mutex = Mutex.new
+ def mutex; @mutex; end
+ freeze
+ }
+
+ TkCore::INTERP.init_ip_env{
+ TreeNodeID_TBL.mutex.synchronize{ TreeNodeID_TBL.clear }
+ }
+
+ def self.id2obj(tree, id)
+ tpath = tree.path
+ TreeNodeID_TBL.mutex.synchronize{
+ if TreeNodeID_TBL[tpath]
+ if TreeNodeID_TBL[tpath][id]
+ TreeNodeID_TBL[tpath][id]
+ else
+ begin
+ # self.new(tree, nil, nil, 'node'=>Integer(id))
+ unless (tk_call(@tpath, 'get', id)).empty?
+ id = Integer(id)
+ (obj = self.allocate).instance_eval{
+ @parent = @tree = tree
+ @tpath = @parent.path
+ @path = @id = id
+ TreeNodeID_TBL[@tpath] ||= {}
+ TreeNodeID_TBL[@tpath][@id] = self
+ }
+ obj
+ else
+ id
+ end
+ rescue
+ id
+ end
+ end
+ else
+ id
+ end
+ }
+ end
+
+ def self.new(tree, pos, parent=nil, keys={})
+ if parent.kind_of?(Hash)
+ keys = parent
+ parent = nil
+ end
+
+ keys = _symbolkey2str(keys)
+ tpath = tree.path
+
+ TreeNodeID_TBL.mutex.synchronize{
+ TreeNodeID_TBL[tpath] ||= {}
+ if (id = keys['node']) && (obj = TreeNodeID_TBL[tpath][id])
+ keys.delete('node')
+ tk_call(tree.path, 'move', id, pos, parent) if parent
+ return obj
+ end
+
+ #super(tree, pos, parent, keys)
+ (obj = self.allocate).instance_eval{
+ initialize(tree, pos, parent, keys)
+ TreeNodeID_TBL[tpath][@id] = self
+ }
+ obj
+ }
+ end
+
+ def initialize(tree, pos, parent, keys)
+ @parent = @tree = tree
+ @tpath = @parent.path
+
+ if (id = keys['node'])
+ # if tk_call(@tpath, 'get', id).empty?
+ # fail RuntimeError, "not exist the node '#{id}'"
+ # end
+ @path = @id = id
+ tk_call(@tpath, 'move', @id, pos, tagid(parent)) if parent
+ configure(keys) if keys && ! keys.empty?
+ else
+ name = nil
+ TreeNode_ID.mutex.synchronize{
+ name = TreeNode_ID.join(TkCore::INTERP._ip_id_).freeze
+ TreeNode_ID[1].succ!
+ }
+
+ at = keys.delete['at']
+
+ if parent
+ if parent.kind_of?(Tk::BLT::Treeview::Node) ||
+ parent.kind_of?(Tk::BLT::Treeview::Tag)
+ path = [get_full(parent.id)[0], name]
+ at = nil # ignore 'at' option
+ else
+ path = [parent.to_s, name]
+ end
+ else
+ path = name
+ end
+
+ if at
+ @id = tk_call(@tpath, 'insert', '-at', tagid(at), pos, path, keys)
+ else
+ @id = tk_call(@tpath, 'insert', pos, path, keys)
+ end
+ @path = @id
+ end
+ end
+
+ def id
+ @id
+ end
+end
+
+######################################
+
+class Tk::BLT::Treeview::Tag < TkObject
+ include Tk::BLT::Treeview::TagOrID_Methods
+
+ TreeTagID_TBL = TkCore::INTERP.create_table
+
+ (TreeTag_ID = ['blt_treeview_tag'.freeze, TkUtil.untrust('00000')]).instance_eval{
+ @mutex = Mutex.new
+ def mutex; @mutex; end
+ freeze
+ }
+
+ TkCore::INTERP.init_ip_env{
+ TreeTagID_TBL.mutex.synchronize{ TreeTagID_TBL.clear }
+ }
+
+ def self.id2obj(tree, name)
+ tpath = tree.path
+ TreeTagID_TBL.mutex.synchronize{
+ if TreeTagID_TBL[tpath]
+ if TreeTagID_TBL[tpath][name]
+ TreeTagID_TBL[tpath][name]
+ else
+ #self.new(tree, name)
+ (obj = self.allocate).instance_eval{
+ @parent = @tree = tree
+ @tpath = @parent.path
+ @path = @id = name
+ TreeTagID_TBL[@tpath] = {} unless TreeTagID_TBL[@tpath]
+ TreeTagID_TBL[@tpath][@id] = self
+ }
+ obj
+ end
+ else
+ id
+ end
+ }
+ end
+
+ def self.new_by_name(tree, name, *ids)
+ TreeTagID_TBL.mutex.synchronize{
+ unless (obj = TreeTagID_TBL[tree.path][name])
+ (obj = self.allocate).instance_eval{
+ initialize(tree, name, ids)
+ TreeTagID_TBL[@tpath] = {} unless TreeTagID_TBL[@tpath]
+ TreeTagID_TBL[@tpath][@id] = self
+ }
+ end
+ obj
+ }
+ end
+
+ def self.new(tree, *ids)
+ TreeTagID_TBL.mutex.synchronize{
+ (obj = self.allocate).instance_eval{
+ if tree.kind_of?(Array)
+ initialize(tree[0], tree[1], ids)
+ else
+ initialize(tree, nil, ids)
+ end
+ TreeTagID_TBL[@tpath] = {} unless TreeTagID_TBL[@tpath]
+ TreeTagID_TBL[@tpath][@id] = self
+ }
+ obj
+ }
+ end
+
+ def initialize(tree, name, ids)
+ @parent = @tree = tree
+ @tpath = @parent.path
+
+ if name
+ @path = @id = name
+ else
+ TreeTag_ID.mutex.synchronize{
+ @path = @id = TreeTag_ID.join(TkCore::INTERP._ip_id_).freeze
+ TreeTag_ID[1].succ!
+ }
+ end
+
+ unless ids.empty?
+ tk_call(@tpath, 'tag', 'add', @id, *(ids.collect{|id| tagid(id)}))
+ end
+ end
+
+ def tagid(tag)
+ if tag.kind_of?(Tk::BLT::Treeview::Node) \
+ || tag.kind_of?(Tk::BLT::Treeview::Tag)
+ tag.id
+ else
+ tag
+ end
+ end
+ private :tagid
+
+ def id
+ @id
+ end
+
+ def add(*ids)
+ tk_call(@tpath, 'tag', 'add', @id, *(ids{|id| tagid(id)}))
+ self
+ end
+
+ def remove(*ids)
+ tk_call(@tpath, 'tag', 'delete', @id, *(ids{|id| tagid(id)}))
+ self
+ end
+
+ def forget
+ tk_call(@tpath, 'tag', 'forget', @id)
+ self
+ end
+
+ def nodes
+ simplelist(tk_call(@tpath, 'tag', 'nodes', @id)).collect{|id|
+ Tk::BLT::Treeview::Node.id2obj(@tree, id)
+ }
+ end
+end
+
+class Tk::BLT::Hiertable
+ TkCommandNames = ['::blt::hiertable'.freeze].freeze
+ WidgetClassName = 'Hiertable'.freeze
+ WidgetClassNames[WidgetClassName] ||= self
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/blt/unix_dnd.rb b/jni/ruby/ext/tk/lib/tkextlib/blt/unix_dnd.rb
new file mode 100644
index 0000000..8996f7c
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/blt/unix_dnd.rb
@@ -0,0 +1,141 @@
+#
+# tkextlib/blt/unix_dnd.rb
+#
+# *** This is alpha version, because there is no document on BLT. ***
+#
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+
+require 'tk'
+require 'tkextlib/blt.rb'
+
+module Tk::BLT
+ module DnD
+ extend TkCore
+
+ TkCommandNames = ['::blt::dnd'.freeze].freeze
+
+ ##############################
+
+ extend TkItemConfigMethod
+
+ class << self
+ def __item_cget_cmd(id)
+ ['::blt::dnd', *id]
+ end
+ private :__item_cget_cmd
+
+ def __item_config_cmd(id)
+ ['::blt::dnd', *id]
+ end
+ private :__item_config_cmd
+
+ private :itemcget_tkstring, :itemcget, :itemcget_strict
+ private :itemconfigure, :itemconfiginfo, :current_itemconfiginfo
+
+ def cget_tkstring(win, option)
+ itemcget_tkstring(['cget', win], option)
+ end
+ def cget(win, option)
+ itemcget(['cget', win], option)
+ end
+ def cget_strict(win, option)
+ itemcget_strict(['cget', win], option)
+ end
+ def configure(win, slot, value=None)
+ itemconfigure(['configure', win], slot, value)
+ end
+ def configinfo(win, slot=nil)
+ itemconfiginfo(['configure', win], slot)
+ end
+ def current_configinfo(win, slot=nil)
+ current_itemconfiginfo(['configure', win], slot)
+ end
+
+ def token_cget_tkstring(win, option)
+ itemcget_tkstring(['token', 'cget', win], option)
+ end
+ def token_cget(win, option)
+ itemcget(['token', 'cget', win], option)
+ end
+ def token_cget_strict(win, option)
+ itemcget_strict(['token', 'cget', win], option)
+ end
+ def token_configure(win, slot, value=None)
+ itemconfigure(['token', 'configure', win], slot, value)
+ end
+ def token_configinfo(win, slot=nil)
+ itemconfiginfo(['token', 'configure', win], slot)
+ end
+ def current_token_configinfo(win, slot=nil)
+ current_itemconfiginfo(['token', 'configure', win], slot)
+ end
+
+ def token_windowconfigure(win, slot, value=None)
+ itemconfigure(['token', 'window', win], slot, value)
+ end
+ def token_windowconfiginfo(win, slot=nil)
+ itemconfiginfo(['token', 'window', win], slot)
+ end
+ def current_token_windowconfiginfo(win, slot=nil)
+ current_itemconfiginfo(['token', 'window', win], slot)
+ end
+ end
+
+ ##############################
+
+ def self.cancel(win)
+ tk_call('::blt::dnd', 'cancel', *wins)
+ end
+ def self.delete(*wins)
+ tk_call('::blt::dnd', 'delete', *wins)
+ end
+ def self.delete_source(*wins)
+ tk_call('::blt::dnd', 'delete', '-source', *wins)
+ end
+ def self.delete_target(*wins)
+ tk_call('::blt::dnd', 'delete', '-target', *wins)
+ end
+ def self.drag(win, x, y, token=None)
+ tk_call('::blt::dnd', 'drag', win, x, y, token)
+ end
+ def self.drop(win, x, y, token=None)
+ tk_call('::blt::dnd', 'drop', win, x, y, token)
+ end
+ def self.get_data(win, fmt=nil, cmd=nil)
+ if fmt
+ tk_call('::blt::dnd', 'getdata', win, fmt, cmd)
+ else
+ list(tk_call('::blt::dnd', 'getdata', win))
+ end
+ end
+ def self.names(pat=None)
+ list(tk_call('::blt::dnd', 'names', pat))
+ end
+ def self.source_names(pat=None)
+ list(tk_call('::blt::dnd', 'names', '-source', pat))
+ end
+ def self.target_names(pat=None)
+ list(tk_call('::blt::dnd', 'names', '-target', pat))
+ end
+ def self.pull(win, fmt)
+ tk_call('::blt::dnd', 'pull', win, fmt)
+ end
+ def self.register(win, keys={})
+ tk_call('::blt::dnd', 'register', win, keys)
+ end
+ def self.select(win, x, y, timestamp)
+ tk_call('::blt::dnd', 'select', win, x, y, timestamp)
+ end
+ def self.set_data(win, fmt=nil, cmd=nil)
+ if fmt
+ tk_call('::blt::dnd', 'setdata', win, fmt, cmd)
+ else
+ list(tk_call('::blt::dnd', 'setdata', win))
+ end
+ end
+ def self.token(*args)
+ tk_call('::blt::dnd', 'token', *args)
+ end
+ end
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/blt/vector.rb b/jni/ruby/ext/tk/lib/tkextlib/blt/vector.rb
new file mode 100644
index 0000000..742e901
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/blt/vector.rb
@@ -0,0 +1,256 @@
+#
+# tkextlib/blt/vector.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+
+require 'tk'
+require 'tkextlib/blt.rb'
+
+module Tk::BLT
+ class Vector < TkVariable
+ TkCommandNames = ['::blt::vector'.freeze].freeze
+
+ def self.create(*args)
+ tk_call('::blt::vector', 'create', *args)
+ end
+
+ def self.destroy(*args)
+ tk_call('::blt::vector', 'destroy', *args)
+ end
+
+ def self.expr(expression)
+ tk_call('::blt::vector', 'expr', expression)
+ end
+
+ def self.names(pat=None)
+ list = simplelist(tk_call('::blt::vector', 'names', pat))
+ TkVar_ID_TBL.mutex.synchronize{
+ list.collect{|name|
+ if TkVar_ID_TBL[name]
+ TkVar_ID_TBL[name]
+ elsif name[0..1] == '::' && TkVar_ID_TBL[name[2..-1]]
+ TkVar_ID_TBL[name[2..-1]]
+ else
+ name
+ end
+ }
+ }
+ end
+
+ ####################################
+
+ def initialize(size=nil, keys={})
+ if size.kind_of?(Hash)
+ keys = size
+ size = nil
+ end
+ if size.kind_of?(Array)
+ # [first, last]
+ size = size.join(':')
+ end
+ if size
+ @id = TkCore::INTERP._invoke('::blt::vector', 'create',
+ "#auto(#{size})", *hash_kv(keys))
+ else
+ @id = TkCore::INTERP._invoke('::blt::vector', 'create',
+ "#auto", *hash_kv(keys))
+ end
+
+ TkVar_ID_TBL.mutex.synchronize{
+ TkVar_ID_TBL[@id] = self
+ }
+
+ @def_default = false
+ @default_val = nil
+
+ @trace_var = nil
+ @trace_elem = nil
+ @trace_opts = nil
+
+ # teach Tk-ip that @id is global var
+ TkCore::INTERP._invoke_without_enc('global', @id)
+ end
+
+ def destroy
+ tk_call('::blt::vector', 'destroy', @id)
+ end
+
+ def inspect
+ '#<Tk::BLT::Vector: ' + @id + '>'
+ end
+
+ def to_s
+ @id
+ end
+
+ def *(item)
+ list(tk_call(@id, '*', item))
+ end
+
+ def +(item)
+ list(tk_call(@id, '+', item))
+ end
+
+ def -(item)
+ list(tk_call(@id, '-', item))
+ end
+
+ def /(item)
+ list(tk_call(@id, '/', item))
+ end
+
+ def append(*vectors)
+ tk_call(@id, 'append', *vectors)
+ end
+
+ def binread(channel, len=None, keys={})
+ if len.kind_of?(Hash)
+ keys = len
+ len = None
+ end
+ keys = _symbolkey2str(keys)
+ keys['swap'] = None if keys.delete('swap')
+ tk_call(@id, 'binread', channel, len, keys)
+ end
+
+ def clear()
+ tk_call(@id, 'clear')
+ self
+ end
+
+ def delete(*indices)
+ tk_call(@id, 'delete', *indices)
+ self
+ end
+
+ def dup_vector(vec)
+ tk_call(@id, 'dup', vec)
+ self
+ end
+
+ def expr(expression)
+ tk_call(@id, 'expr', expression)
+ self
+ end
+
+ def index(idx, val=None)
+ number(tk_call(@id, 'index', idx, val))
+ end
+
+ def [](idx)
+ index(idx)
+ end
+
+ def []=(idx, val)
+ index(idx, val)
+ end
+
+ def length()
+ number(tk_call(@id, 'length'))
+ end
+
+ def length=(size)
+ number(tk_call(@id, 'length', size))
+ end
+
+ def merge(*vectors)
+ tk_call(@id, 'merge', *vectors)
+ self
+ end
+
+ def normalize(vec=None)
+ tk_call(@id, 'normalize', vec)
+ self
+ end
+
+ def notify(keyword)
+ tk_call(@id, 'notify', keyword)
+ self
+ end
+
+ def offset()
+ number(tk_call(@id, 'offset'))
+ end
+
+ def offset=(val)
+ number(tk_call(@id, 'offset', val))
+ end
+
+ def random()
+ tk_call(@id, 'random')
+ end
+
+ def populate(vector, density=None)
+ tk_call(@id, 'populate', vector, density)
+ self
+ end
+
+ def range(first, last=None)
+ list(tk_call(@id, 'range', first, last))
+ end
+
+ def search(val1, val2=None)
+ list(tk_call(@id, 'search', val1, val2))
+ end
+
+ def set(item)
+ tk_call(@id, 'set', item)
+ self
+ end
+
+ def seq(start, finish=None, step=None)
+ tk_call(@id, 'seq', start, finish, step)
+ self
+ end
+
+ def sort(*vectors)
+ tk_call(@id, 'sort', *vectors)
+ self
+ end
+
+ def sort_reverse(*vectors)
+ tk_call(@id, 'sort', '-reverse', *vectors)
+ self
+ end
+
+ def split(*vectors)
+ tk_call(@id, 'split', *vectors)
+ self
+ end
+
+ def variable(var)
+ tk_call(@id, 'variable', var)
+ self
+ end
+ end
+
+ class VectorAccess < Vector
+ def self.new(name)
+ TkVar_ID_TBL.mutex.synchronize{
+ if TkVar_ID_TBL[name]
+ TkVar_ID_TBL[name]
+ else
+ (obj = self.allocate).instance_eval{
+ initialize(name)
+ TkVar_ID_TBL[@id] = self
+ }
+ obj
+ end
+ }
+ end
+
+ def initialize(vec_name)
+ @id = vec_name
+
+ @def_default = false
+ @default_val = nil
+
+ @trace_var = nil
+ @trace_elem = nil
+ @trace_opts = nil
+
+ # teach Tk-ip that @id is global var
+ TkCore::INTERP._invoke_without_enc('global', @id)
+ end
+ end
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/blt/watch.rb b/jni/ruby/ext/tk/lib/tkextlib/blt/watch.rb
new file mode 100644
index 0000000..292623f
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/blt/watch.rb
@@ -0,0 +1,175 @@
+#
+# tkextlib/blt/watch.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+
+require 'tk'
+require 'tkextlib/blt.rb'
+
+module Tk::BLT
+ class Watch < TkObject
+ extend TkCore
+
+ TkCommandNames = ['::blt::watch'.freeze].freeze
+
+ WATCH_ID_TBL = TkCore::INTERP.create_table
+
+ (BLT_WATCH_ID = ['blt_watch_id'.freeze, TkUtil.untrust('00000')]).instance_eval{
+ @mutex = Mutex.new
+ def mutex; @mutex; end
+ freeze
+ }
+
+ TkCore::INTERP.init_ip_env{
+ WATCH_ID_TBL.mutex.synchronize{ WATCH_ID_TBL.clear }
+ }
+
+ def self.names(state = None)
+ lst = tk_split_list(tk_call('::blt::watch', 'names', state))
+ WATCH_ID_TBL.mutex.synchronize{
+ lst.collect{|name|
+ WATCH_ID_TBL[name] || name
+ }
+ }
+ end
+
+ def __numval_optkeys
+ ['maxlevel']
+ end
+ private :__numval_optkeys
+
+ def __boolval_optkeys
+ ['active']
+ end
+ private :__boolval_optkeys
+
+ def __config_cmd
+ ['::blt::watch', 'configure', self.path]
+ end
+ private :__config_cmd
+
+ def initialize(name = nil, keys = {})
+ if name.kind_of?(Hash)
+ keys = name
+ name = nil
+ end
+
+ if name
+ @id = name.to_s
+ else
+ BLT_WATCH_ID.mutex.synchronize{
+ @id = BLT_WATCH_ID.join(TkCore::INTERP._ip_id_)
+ BLT_WATCH_ID[1].succ!
+ }
+ end
+
+ @path = @id
+
+ WATCH_ID_TBL.mutex.synchronize{
+ WATCH_ID_TBL[@id] = self
+ }
+ tk_call('::blt::watch', 'create', @id, *hash_kv(keys))
+ end
+
+ def activate
+ tk_call('::blt::watch', 'activate', @id)
+ self
+ end
+ def deactivate
+ tk_call('::blt::watch', 'deactivate', @id)
+ self
+ end
+ def delete
+ tk_call('::blt::watch', 'delete', @id)
+ self
+ end
+ def info
+ ret = []
+ lst = tk_split_simplelist(tk_call('::blt::watch', 'info', @id))
+ until lst.empty?
+ k, v, *lst = lst
+ k = k[1..-1]
+ case k
+ when /^(#{__strval_optkeys.join('|')})$/
+ # do nothing
+
+ when /^(#{__numval_optkeys.join('|')})$/
+ begin
+ v = number(v)
+ rescue
+ v = nil
+ end
+
+ when /^(#{__numstrval_optkeys.join('|')})$/
+ v = num_or_str(v)
+
+ when /^(#{__boolval_optkeys.join('|')})$/
+ begin
+ v = bool(v)
+ rescue
+ v = nil
+ end
+
+ when /^(#{__listval_optkeys.join('|')})$/
+ v = simplelist(v)
+
+ when /^(#{__numlistval_optkeys.join('|')})$/
+ v = list(v)
+
+ else
+ if v.index('{')
+ v = tk_split_list(v)
+ else
+ v = tk_tcl2ruby(v)
+ end
+ end
+
+ ret << [k, v]
+ end
+
+ ret
+ end
+ def configinfo(slot = nil)
+ if slot
+ slot = slot.to_s
+ v = cget(slot)
+ if TkComm::GET_CONFIGINFO_AS_ARRAY
+ [slot, v]
+ else
+ {slot=>v}
+ end
+ else
+ if TkComm::GET_CONFIGINFO_AS_ARRAY
+ info
+ else
+ Hash[*(info.flatten)]
+ end
+ end
+ end
+ def cget_strict(key)
+ key = key.to_s
+ begin
+ info.assoc(key)[1]
+ rescue
+ fail ArgumentError, "unknown option '#{key}'"
+ end
+ end
+ def cget(key)
+ unless TkConfigMethod.__IGNORE_UNKNOWN_CONFIGURE_OPTION__
+ cget_strict(key)
+ else
+ begin
+ cget_strict(key)
+ rescue => e
+ if current_configinfo.has_key?(key.to_s)
+ # error on known option
+ fail e
+ else
+ # unknown option
+ nil
+ end
+ end
+ end
+ end
+ end
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/blt/win_printer.rb b/jni/ruby/ext/tk/lib/tkextlib/blt/win_printer.rb
new file mode 100644
index 0000000..7ac6a0d
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/blt/win_printer.rb
@@ -0,0 +1,61 @@
+#
+# tkextlib/blt/win_printer.rb
+#
+# *** Windows only ***
+#
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+
+require 'tk'
+require 'tkextlib/blt.rb'
+
+module Tk::BLT
+ class Printer < TkObject
+ extend TkCore
+
+ TkCommandNames = ['::blt::printer'.freeze].freeze
+
+ def self.enum(attribute)
+ simplelist(tk_call('::blt::printer', 'enum', attribute))
+ end
+
+ def self.names(pat=None)
+ simplelist(tk_call('::blt::printer', 'names', pat))
+ end
+
+ def self.open(printer)
+ self.new(printer)
+ end
+
+ #################################
+
+ def initialize(printer)
+ @printer_id = tk_call('::blt::printer', 'open', printer)
+ end
+
+ def close
+ tk_call('::blt::print', 'close', @printer_id)
+ self
+ end
+ def get_attrs(var)
+ tk_call('::blt::print', 'getattrs', @printer_id, var)
+ var
+ end
+ def set_attrs(var)
+ tk_call('::blt::print', 'setattrs', @printer_id, var)
+ self
+ end
+ def snap(win)
+ tk_call('::blt::print', 'snap', @printer_id, win)
+ self
+ end
+ def write(str)
+ tk_call('::blt::print', 'write', @printer_id, str)
+ self
+ end
+ def write_with_title(title, str)
+ tk_call('::blt::print', 'write', @printer_id, title, str)
+ self
+ end
+ end
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/blt/winop.rb b/jni/ruby/ext/tk/lib/tkextlib/blt/winop.rb
new file mode 100644
index 0000000..03bdb60
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/blt/winop.rb
@@ -0,0 +1,107 @@
+#
+# tkextlib/blt/winop.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+
+require 'tk'
+require 'tkextlib/blt.rb'
+
+module Tk::BLT
+ module Winop
+ extend TkCore
+
+ TkCommandNames = ['::blt::winop'.freeze].freeze
+ end
+ WinOp = Winop
+end
+
+class << Tk::BLT::Winop
+ def changes(win)
+ tk_call('::blt::winop', 'changes', win)
+ end
+
+ def colormap(win)
+ Hash[*list(tk_call('::blt::winop', 'colormap', win))]
+ end
+
+ def convolve(src, dest, filter)
+ tk_call('::blt::winop', 'convolve', src, dest, filter)
+ end
+
+ def image_convolve(src, dest, filter)
+ tk_call('::blt::winop', 'image', 'convolve', src, dest, filter)
+ end
+ def image_gradient(photo, left, right, type)
+ tk_call('::blt::winop', 'image', 'gradient', photo, left, right, type)
+ end
+ def image_read_jpeg(file, photo)
+ tk_call('::blt::winop', 'image', 'readjpeg', file, photo)
+ end
+ def image_resample(src, dest, horiz_filter=None, vert_filter=None)
+ tk_call('::blt::winop', 'image', 'resample',
+ src, dest, horiz_filter, vert_filter)
+ end
+ def image_rotate(src, dest, angle)
+ tk_call('::blt::winop', 'image', 'rotate', src, dest, angle)
+ end
+ def image_snap(win, photo, width=None, height=None)
+ tk_call('::blt::winop', 'image', 'snap', win, photo, width, height)
+ end
+ def image_subsample(src, dest, x, y, width, height,
+ horiz_filter=None, vert_filter=None)
+ tk_call('::blt::winop', 'image', 'subsample',
+ src, dest, x, y, width, height, horiz_filter, vert_filter)
+ end
+
+ def quantize(src, dest, colors)
+ tk_call('::blt::winop', 'quantize', src, dest, colors)
+ end
+
+ def query()
+ tk_call('::blt::winop', 'query')
+ end
+
+ def read_jpeg(file, photo)
+ tk_call('::blt::winop', 'readjpeg', file, photo)
+ end
+
+ def resample(src, dest, horiz_filter=None, vert_filter=None)
+ tk_call('::blt::winop', 'resample',
+ src, dest, horiz_filter, vert_filter)
+ end
+
+ def subsample(src, dest, x, y, width, height,
+ horiz_filter=None, vert_filter=None)
+ tk_call('::blt::winop', 'subsample',
+ src, dest, x, y, width, height, horiz_filter, vert_filter)
+ end
+
+ def raise(*wins)
+ tk_call('::blt::winop', 'raise', *wins)
+ end
+
+ def lower(*wins)
+ tk_call('::blt::winop', 'lower', *wins)
+ end
+
+ def map(*wins)
+ tk_call('::blt::winop', 'map', *wins)
+ end
+
+ def unmap(*wins)
+ tk_call('::blt::winop', 'unmap', *wins)
+ end
+
+ def move(win, x, y)
+ tk_call('::blt::winop', 'move', win, x, y)
+ end
+
+ def snap(win, photo)
+ tk_call('::blt::winop', 'snap', win, photo)
+ end
+
+ def warpto(win = None)
+ tk_call('::blt::winop', 'warpto', win)
+ end
+ alias warp_to warpto
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/bwidget.rb b/jni/ruby/ext/tk/lib/tkextlib/bwidget.rb
new file mode 100644
index 0000000..7a1eff5
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/bwidget.rb
@@ -0,0 +1,153 @@
+#
+# BWidget extension support
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+
+require 'tk'
+
+# call setup script for general 'tkextlib' libraries
+require 'tkextlib/setup.rb'
+
+# call setup script
+require 'tkextlib/bwidget/setup.rb'
+
+# load all image format handlers
+#TkPackage.require('BWidget', '1.7')
+TkPackage.require('BWidget')
+
+module Tk
+ module BWidget
+ TkComm::TkExtlibAutoloadModule.unshift(self)
+ # Require autoload-symbols which is a same name as widget classname.
+ # Those are used at TkComm._genobj_for_tkwidget method.
+
+ extend TkCore
+
+ LIBRARY = tk_call('set', '::BWIDGET::LIBRARY')
+
+ PACKAGE_NAME = 'BWidget'.freeze
+ def self.package_name
+ PACKAGE_NAME
+ end
+
+ def self.package_version
+ begin
+ TkPackage.require('BWidget')
+ rescue
+ ''
+ end
+ end
+
+ def self.XLFDfont(cmd, *args)
+ if args[-1].kind_of?(Hash)
+ keys = args.pop
+ args.concat(hash_kv(keys))
+ end
+ tk_call('BWidget::XLFDfont', cmd, *args)
+ end
+
+ def self.assert(exp, msg=None)
+ tk_call('BWidget::assert', exp, msg)
+ end
+
+ def self.badOptionString(type, value, list)
+ tk_call('BWidget::badOptionString', type, value, list)
+ end
+
+ def self.bindMouseWheel(widget)
+ tk_call('BWidget::bindMouseWheel', widget)
+ end
+
+ def self.classes(klass)
+ list(tk_call('BWidget::classes', klass))
+ end
+
+ def self.clonename(menu)
+ tk_call('BWidget::clonename', menu)
+ end
+
+ def self.focus(opt, path)
+ tk_call('BWidget::focus', opt, path)
+ end
+
+ def self.get3dcolor(path, bgcolor)
+ tk_call('BWidget::get3dcolor', path, bgcolor)
+ end
+
+ def self.getname(name)
+ tk_call('BWidget::getname', name)
+ end
+
+ def self.grab(opt, path)
+ tk_call('BWidget::grab', opt, path)
+ end
+
+ def self.inuse(klass)
+ bool(tk_call('BWidget::inuse', klass))
+ end
+
+ def self.library(klass, *klasses)
+ tk_call('BWidget::library', klass, *klasses)
+ end
+
+ def self.lreorder(list, neworder)
+ tk_call('BWidget::lreorder', list, neworder)
+ end
+
+ def self.parsetext(text)
+ tk_call('BWidget::parsetext', text)
+ end
+
+ def self.place(path, w, h, *args)
+ if args[-1].kind_of?(Hash)
+ keys = args.pop
+ args.concat(hash_kv(keys))
+ end
+ tk_call('BWidget::place', path, w, h, *(args.flatten))
+ end
+
+ def self.write(file, mode=None)
+ tk_call('BWidget::write', file, mode)
+ end
+
+ def self.wrongNumArgsString(str)
+ tk_call('BWidget::wrongNumArgsString', str)
+ end
+
+ ####################################################
+
+ autoload :ArrowButton, 'tkextlib/bwidget/arrowbutton'
+ autoload :Bitmap, 'tkextlib/bwidget/bitmap'
+ autoload :Button, 'tkextlib/bwidget/button'
+ autoload :ButtonBox, 'tkextlib/bwidget/buttonbox'
+ autoload :ComboBox, 'tkextlib/bwidget/combobox'
+ autoload :Dialog, 'tkextlib/bwidget/dialog'
+ autoload :DragSite, 'tkextlib/bwidget/dragsite'
+ autoload :DropSite, 'tkextlib/bwidget/dropsite'
+ autoload :DynamicHelp, 'tkextlib/bwidget/dynamichelp'
+ autoload :Entry, 'tkextlib/bwidget/entry'
+ autoload :Label, 'tkextlib/bwidget/label'
+ autoload :LabelEntry, 'tkextlib/bwidget/labelentry'
+ autoload :LabelFrame, 'tkextlib/bwidget/labelframe'
+ autoload :ListBox, 'tkextlib/bwidget/listbox'
+ autoload :MainFrame, 'tkextlib/bwidget/mainframe'
+ autoload :MessageDlg, 'tkextlib/bwidget/messagedlg'
+ autoload :NoteBook, 'tkextlib/bwidget/notebook'
+ autoload :PagesManager, 'tkextlib/bwidget/pagesmanager'
+ autoload :PanedWindow, 'tkextlib/bwidget/panedwindow'
+ autoload :PasswdDlg, 'tkextlib/bwidget/passwddlg'
+ autoload :ProgressBar, 'tkextlib/bwidget/progressbar'
+ autoload :ProgressDlg, 'tkextlib/bwidget/progressdlg'
+ autoload :ScrollableFrame, 'tkextlib/bwidget/scrollableframe'
+ autoload :ScrolledWindow, 'tkextlib/bwidget/scrolledwindow'
+ autoload :ScrollView, 'tkextlib/bwidget/scrollview'
+ autoload :SelectColor, 'tkextlib/bwidget/selectcolor'
+ autoload :SelectFont, 'tkextlib/bwidget/selectfont'
+ autoload :Separator, 'tkextlib/bwidget/separator'
+ autoload :SpinBox, 'tkextlib/bwidget/spinbox'
+ autoload :TitleFrame, 'tkextlib/bwidget/titleframe'
+ autoload :Tree, 'tkextlib/bwidget/tree'
+ autoload :Widget, 'tkextlib/bwidget/widget'
+
+ end
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/bwidget/arrowbutton.rb b/jni/ruby/ext/tk/lib/tkextlib/bwidget/arrowbutton.rb
new file mode 100644
index 0000000..13fe9e5
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/bwidget/arrowbutton.rb
@@ -0,0 +1,21 @@
+#
+# tkextlib/bwidget/arrowbutton.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+
+require 'tk'
+require 'tkextlib/bwidget.rb'
+require 'tkextlib/bwidget/button'
+
+module Tk
+ module BWidget
+ class ArrowButton < Tk::BWidget::Button
+ end
+ end
+end
+
+class Tk::BWidget::ArrowButton
+ TkCommandNames = ['ArrowButton'.freeze].freeze
+ WidgetClassName = 'ArrowButton'.freeze
+ WidgetClassNames[WidgetClassName] ||= self
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/bwidget/bitmap.rb b/jni/ruby/ext/tk/lib/tkextlib/bwidget/bitmap.rb
new file mode 100644
index 0000000..6cfde20
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/bwidget/bitmap.rb
@@ -0,0 +1,21 @@
+#
+# tkextlib/bwidget/bitmap.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+require 'tk'
+require 'tk/image'
+require 'tkextlib/bwidget.rb'
+
+module Tk
+ module BWidget
+ class Bitmap < TkPhotoImage
+ end
+ end
+end
+
+class Tk::BWidget::Bitmap
+ def initialize(name)
+ @path = tk_call_without_enc('Bitmap::get', name)
+ Tk_IMGTBL[@path] = self
+ end
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/bwidget/button.rb b/jni/ruby/ext/tk/lib/tkextlib/bwidget/button.rb
new file mode 100644
index 0000000..e139fb6
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/bwidget/button.rb
@@ -0,0 +1,31 @@
+#
+# tkextlib/bwidget/button.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+
+require 'tk'
+require 'tk/button'
+require 'tkextlib/bwidget.rb'
+
+module Tk
+ module BWidget
+ class Button < Tk::Button
+ end
+ end
+end
+
+class Tk::BWidget::Button
+ TkCommandNames = ['Button'.freeze].freeze
+ WidgetClassName = 'Button'.freeze
+ WidgetClassNames[WidgetClassName] ||= self
+
+ def __strval_optkeys
+ super() << 'helptext'
+ end
+ private :__strval_optkeys
+
+ def __tkvariable_optkeys
+ super() << 'helpvar'
+ end
+ private :__tkvariable_optkeys
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/bwidget/buttonbox.rb b/jni/ruby/ext/tk/lib/tkextlib/bwidget/buttonbox.rb
new file mode 100644
index 0000000..a6de33c
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/bwidget/buttonbox.rb
@@ -0,0 +1,90 @@
+#
+# tkextlib/bwidget/buttonbox.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+
+require 'tk'
+require 'tkextlib/bwidget.rb'
+require 'tkextlib/bwidget/button'
+
+module Tk
+ module BWidget
+ class ButtonBox < TkWindow
+ end
+ end
+end
+
+class Tk::BWidget::ButtonBox
+ TkCommandNames = ['ButtonBox'.freeze].freeze
+ WidgetClassName = 'ButtonBox'.freeze
+ WidgetClassNames[WidgetClassName] ||= self
+
+ include TkItemConfigMethod
+
+ def __boolval_optkeys
+ super() << 'homogeneous'
+ end
+ private :__boolval_optkeys
+
+ def tagid(tagOrId)
+ if tagOrId.kind_of?(Tk::BWidget::Button)
+ name = tagOrId[:name]
+ return index(name) unless name.empty?
+ end
+ if tagOrId.kind_of?(Tk::Button)
+ return index(tagOrId[:text])
+ end
+ # index(tagOrId.to_s)
+ index(_get_eval_string(tagOrId))
+ end
+
+ def add(keys={}, &b)
+ win = window(tk_send('add', *hash_kv(keys)))
+ if b
+ if TkCore::WITH_RUBY_VM ### Ruby 1.9 !!!!
+ win.instance_exec(self, &b)
+ else
+ win.instance_eval(&b)
+ end
+ end
+ win
+ end
+
+ def delete(idx)
+ tk_send('delete', tagid(idx))
+ self
+ end
+
+ def index(idx)
+ if idx.kind_of?(Tk::BWidget::Button)
+ name = idx[:name]
+ idx = name unless name.empty?
+ end
+ if idx.kind_of?(Tk::Button)
+ idx = idx[:text]
+ end
+ number(tk_send('index', idx.to_s))
+ end
+
+ def insert(idx, keys={}, &b)
+ win = window(tk_send('insert', tagid(idx), *hash_kv(keys)))
+ if b
+ if TkCore::WITH_RUBY_VM ### Ruby 1.9 !!!!
+ win.instance_exec(self, &b)
+ else
+ win.instance_eval(&b)
+ end
+ end
+ win
+ end
+
+ def invoke(idx)
+ tk_send('invoke', tagid(idx))
+ self
+ end
+
+ def set_focus(idx)
+ tk_send('setfocus', tagid(idx))
+ self
+ end
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/bwidget/combobox.rb b/jni/ruby/ext/tk/lib/tkextlib/bwidget/combobox.rb
new file mode 100644
index 0000000..16143df
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/bwidget/combobox.rb
@@ -0,0 +1,62 @@
+#
+# tkextlib/bwidget/combobox.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+
+require 'tk'
+require 'tk/entry'
+require 'tkextlib/bwidget.rb'
+require 'tkextlib/bwidget/listbox'
+require 'tkextlib/bwidget/spinbox'
+
+module Tk
+ module BWidget
+ class ComboBox < Tk::BWidget::SpinBox
+ end
+ end
+end
+
+class Tk::BWidget::ComboBox
+ include Scrollable
+
+ TkCommandNames = ['ComboBox'.freeze].freeze
+ WidgetClassName = 'ComboBox'.freeze
+ WidgetClassNames[WidgetClassName] ||= self
+
+ def __boolval_optkeys
+ super() << 'autocomplete' << 'autopost'
+ end
+ private :__boolval_optkeys
+
+ def get_listbox(&b)
+ win = window(tk_send_without_enc('getlistbox'))
+ if b
+ if TkCore::WITH_RUBY_VM ### Ruby 1.9 !!!!
+ win.instance_exec(self, &b)
+ else
+ win.instance_eval(&b)
+ end
+ end
+ win
+ end
+
+ def clear_value
+ tk_send_without_enc('clearvalue')
+ self
+ end
+ alias clearvalue clear_value
+
+ def icursor(idx)
+ tk_send_without_enc('icursor', idx)
+ end
+
+ def post
+ tk_send_without_enc('post')
+ self
+ end
+
+ def unpost
+ tk_send_without_enc('unpost')
+ self
+ end
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/bwidget/dialog.rb b/jni/ruby/ext/tk/lib/tkextlib/bwidget/dialog.rb
new file mode 100644
index 0000000..3b0656f
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/bwidget/dialog.rb
@@ -0,0 +1,194 @@
+#
+# tkextlib/bwidget/dialog.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+
+require 'tk'
+require 'tk/frame'
+require 'tkextlib/bwidget.rb'
+require 'tkextlib/bwidget/buttonbox'
+
+module Tk
+ module BWidget
+ class Dialog < TkWindow
+ end
+ end
+end
+
+class Tk::BWidget::Dialog
+ TkCommandNames = ['Dialog'.freeze].freeze
+ WidgetClassName = 'Dialog'.freeze
+ WidgetClassNames[WidgetClassName] ||= self
+
+ include TkItemConfigMethod
+
+ def __numstrval_optkeys
+ super() << 'buttonwidth'
+ end
+ private :__numstrval_optkeys
+
+ def __strval_optkeys
+ super() << 'title' << 'geometry'
+ end
+ private :__strval_optkeys
+
+ def __boolval_optkeys
+ super() << 'transient' << 'homogeneous'
+ end
+ private :__boolval_optkeys
+
+ def initialize(parent=nil, keys=nil)
+ @relative = ''
+ if parent.kind_of?(Hash)
+ keys = _symbolkey2str(parent)
+ @relative = keys['parent'] if keys.key?('parent')
+ @relative = keys.delete('relative') if keys.key?('relative')
+ super(keys)
+ elsif keys
+ keys = _symbolkey2str(keys)
+ @relative = keys.delete('parent') if keys.key?('parent')
+ @relative = keys.delete('relative') if keys.key?('relative')
+ super(parent, keys)
+ else
+ super(parent)
+ end
+ end
+
+ def create_self(keys)
+ cmd = self.class::TkCommandNames[0]
+ if keys and keys != None
+ tk_call_without_enc(cmd, @path, '-parent', @relative,
+ *hash_kv(keys, true))
+ else
+ tk_call_without_enc(cmd, @path, '-parent', @relative)
+ end
+ end
+
+ def cget_tkstring(slot)
+ if slot.to_s == 'relative'
+ super('parent')
+ else
+ super(slot)
+ end
+ end
+ def cget_strict(slot)
+ if slot.to_s == 'relative'
+ super('parent')
+ else
+ super(slot)
+ end
+ end
+ def cget(slot)
+ if slot.to_s == 'relative'
+ super('parent')
+ else
+ super(slot)
+ end
+ end
+
+ def configure(slot, value=None)
+ if slot.kind_of?(Hash)
+ slot = _symbolkey2str(slot)
+ slot['parent'] = slot.delete('relative') if slot.key?('relative')
+ super(slot)
+ else
+ if slot.to_s == 'relative'
+ super('parent', value)
+ else
+ super(slot, value)
+ end
+ end
+ end
+
+ def configinfo(slot=nil)
+ if slot
+ if slot.to_s == 'relative'
+ super('parent')
+ else
+ super(slot)
+ end
+ else
+ ret = super()
+ if TkComm::GET_CONFIGINFO_AS_ARRAY
+ ret << ['relative', 'parent']
+ else
+ ret['relative'] = 'parent'
+ end
+ end
+ end
+
+ def tagid(tagOrId)
+ if tagOrId.kind_of?(Tk::BWidget::Button)
+ name = tagOrId[:name]
+ return index(name) unless name.empty?
+ end
+ if tagOrId.kind_of?(Tk::Button)
+ return index(tagOrId[:text])
+ end
+ # index(tagOrId.to_s)
+ index(_get_eval_string(tagOrId))
+ end
+
+ def add(keys={}, &b)
+ win = window(tk_send('add', *hash_kv(keys)))
+ if b
+ if TkCore::WITH_RUBY_VM ### Ruby 1.9 !!!!
+ win.instance_exec(self, &b)
+ else
+ win.instance_eval(&b)
+ end
+ end
+ win
+ end
+
+ def get_frame(&b)
+ win = window(tk_send('getframe'))
+ if b
+ if TkCore::WITH_RUBY_VM ### Ruby 1.9 !!!!
+ win.instance_exec(self, &b)
+ else
+ win.instance_eval(&b)
+ end
+ end
+ win
+ end
+
+ def get_buttonbox(&b)
+ win = window(@path + '.bbox')
+ if b
+ if TkCore::WITH_RUBY_VM ### Ruby 1.9 !!!!
+ win.instance_exec(self, &b)
+ else
+ win.instance_eval(&b)
+ end
+ end
+ win
+ end
+
+ def draw(focus_win=None)
+ tk_send('draw', focus_win)
+ end
+
+ def enddialog(ret)
+ tk_send('enddialog', ret)
+ end
+
+ def index(idx)
+ get_buttonbox.index(idx)
+ end
+
+ def invoke(idx)
+ tk_send('invoke', tagid(idx))
+ self
+ end
+
+ def set_focus(idx)
+ tk_send('setfocus', tagid(idx))
+ self
+ end
+
+ def withdraw
+ tk_send('withdraw')
+ self
+ end
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/bwidget/dragsite.rb b/jni/ruby/ext/tk/lib/tkextlib/bwidget/dragsite.rb
new file mode 100644
index 0000000..4d4de17
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/bwidget/dragsite.rb
@@ -0,0 +1,31 @@
+#
+# tkextlib/bwidget/dragsite.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+
+require 'tk'
+require 'tkextlib/bwidget.rb'
+
+module Tk
+ module BWidget
+ module DragSite
+ end
+ end
+end
+
+module Tk::BWidget::DragSite
+ include Tk
+ extend Tk
+
+ def self.include(klass, type, event)
+ tk_call('DragSite::include', klass, type, event)
+ end
+
+ def self.register(path, keys={})
+ tk_call('DragSite::register', path, *hash_kv(keys))
+ end
+
+ def self.set_drag(path, subpath, initcmd, endcmd, force=None)
+ tk_call('DragSite::setdrag', path, subpath, initcmd, endcmd, force)
+ end
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/bwidget/dropsite.rb b/jni/ruby/ext/tk/lib/tkextlib/bwidget/dropsite.rb
new file mode 100644
index 0000000..e5e98fb
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/bwidget/dropsite.rb
@@ -0,0 +1,39 @@
+#
+# tkextlib/bwidget/dropsite.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+
+require 'tk'
+require 'tkextlib/bwidget.rb'
+
+module Tk
+ module BWidget
+ module DropSite
+ end
+ end
+end
+
+module Tk::BWidget::DropSite
+ include Tk
+ extend Tk
+
+ def self.include(klass, type)
+ tk_call('DropSite::include', klass, type)
+ end
+
+ def self.register(path, keys={})
+ tk_call('DropSite::register', path, *hash_kv(keys))
+ end
+
+ def self.set_cursor(cursor)
+ tk_call('DropSite::setcursor', cursor)
+ end
+
+ def self.set_drop(path, subpath, dropover, drop, force=None)
+ tk_call('DropSite::setdrop', path, subpath, dropover, drop, force)
+ end
+
+ def self.set_operation(op)
+ tk_call('DropSite::setoperation', op)
+ end
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/bwidget/dynamichelp.rb b/jni/ruby/ext/tk/lib/tkextlib/bwidget/dynamichelp.rb
new file mode 100644
index 0000000..846e580
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/bwidget/dynamichelp.rb
@@ -0,0 +1,63 @@
+#
+# tkextlib/bwidget/dynamichelp.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+
+require 'tk'
+require 'tkextlib/bwidget.rb'
+
+module Tk
+ module BWidget
+ module DynamicHelp
+ end
+ end
+end
+
+module Tk::BWidget::DynamicHelp
+ include Tk
+ extend Tk
+
+ def self.__pathname
+ 'DynamicHelp::configure'
+ end
+
+ def __strval_optkeys
+ super() << 'topbackground'
+ end
+ private :__strval_optkeys
+
+ def self.__cget_cmd
+ ['DynamicHelp::configure']
+ end
+
+ def self.__config_cmd
+ ['DynamicHelp::configure']
+ end
+
+ def self.cget_strict(slot)
+ slot = slot.to_s
+ info = {}
+ self.current_configinfo.each{|k,v| info[k.to_s] = v if k.to_s == slot}
+ fail RuntimeError, "unknown option \"-#{slot}\"" if info.empty?
+ info.values[0]
+ end
+ def self.cget(slot)
+ self.current_configinfo(slot).values[0]
+ end
+
+ def self.add(widget, keys={})
+ tk_call('DynamicHelp::add', widget, *hash_kv(keys))
+ end
+
+ def self.delete(widget)
+ tk_call('DynamicHelp::delete', widget)
+ end
+
+ def self.include(klass, type)
+ tk_call('DynamicHelp::include', klass, type)
+ end
+
+ def self.sethelp(path, subpath, force=None)
+ tk_call('DynamicHelp::sethelp', path, subpath, force)
+ end
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/bwidget/entry.rb b/jni/ruby/ext/tk/lib/tkextlib/bwidget/entry.rb
new file mode 100644
index 0000000..8dc4496
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/bwidget/entry.rb
@@ -0,0 +1,43 @@
+#
+# tkextlib/bwidget/entry.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+
+require 'tk'
+require 'tk/entry'
+require 'tkextlib/bwidget.rb'
+
+module Tk
+ module BWidget
+ class Entry < Tk::Entry
+ end
+ end
+end
+
+class Tk::BWidget::Entry
+ include Scrollable
+
+ TkCommandNames = ['Entry'.freeze].freeze
+ WidgetClassName = 'Entry'.freeze
+ WidgetClassNames[WidgetClassName] ||= self
+
+ def __strval_optkeys
+ super() << 'helptext' << 'insertbackground'
+ end
+ private :__strval_optkeys
+
+ def __boolval_optkeys
+ super() << 'dragenabled' << 'dropenabled' << 'editable'
+ end
+ private :__boolval_optkeys
+
+ def __tkvariable_optkeys
+ super() << 'helpvar'
+ end
+ private :__tkvariable_optkeys
+
+ def invoke
+ tk_send_without_enc('invoke')
+ self
+ end
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/bwidget/label.rb b/jni/ruby/ext/tk/lib/tkextlib/bwidget/label.rb
new file mode 100644
index 0000000..e8d9352
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/bwidget/label.rb
@@ -0,0 +1,41 @@
+#
+# tkextlib/bwidget/label.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+
+require 'tk'
+require 'tk/label'
+require 'tkextlib/bwidget.rb'
+
+module Tk
+ module BWidget
+ class Label < Tk::Label
+ end
+ end
+end
+
+class Tk::BWidget::Label
+ TkCommandNames = ['Label'.freeze].freeze
+ WidgetClassName = 'Label'.freeze
+ WidgetClassNames[WidgetClassName] ||= self
+
+ def __strval_optkeys
+ super() << 'helptext'
+ end
+ private :__strval_optkeys
+
+ def __boolval_optkeys
+ super() << 'dragenabled' << 'dropenabled'
+ end
+ private :__boolval_optkeys
+
+ def __tkvariable_optkeys
+ super() << 'helpvar'
+ end
+ private :__tkvariable_optkeys
+
+ def set_focus
+ tk_send_without_enc('setfocus')
+ self
+ end
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/bwidget/labelentry.rb b/jni/ruby/ext/tk/lib/tkextlib/bwidget/labelentry.rb
new file mode 100644
index 0000000..16e7b46
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/bwidget/labelentry.rb
@@ -0,0 +1,80 @@
+#
+# tkextlib/bwidget/labelentry.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+
+require 'tk'
+require 'tk/entry'
+require 'tkextlib/bwidget.rb'
+require 'tkextlib/bwidget/labelframe'
+require 'tkextlib/bwidget/entry'
+
+module Tk
+ module BWidget
+ class LabelEntry < Tk::Entry
+ end
+ end
+end
+
+class Tk::BWidget::LabelEntry
+ include Scrollable
+
+ TkCommandNames = ['LabelEntry'.freeze].freeze
+ WidgetClassName = 'LabelEntry'.freeze
+ WidgetClassNames[WidgetClassName] ||= self
+
+ def __strval_optkeys
+ super() << 'helptext' << 'insertbackground' << 'entryfg' << 'entrybg'
+ end
+ private :__strval_optkeys
+
+ def __tkvariable_optkeys
+ super() << 'helpvar'
+ end
+ private :__tkvariable_optkeys
+
+ def __font_optkeys
+ super() << 'labelfont'
+ end
+ private :__font_optkeys
+
+ #def entrybind(*args)
+ # _bind([path, 'bind'], *args)
+ # self
+ #end
+ def entrybind(context, *args)
+ # if args[0].kind_of?(Proc) || args[0].kind_of?(Method)
+ if TkComm._callback_entry?(args[0]) || !block_given?
+ cmd = args.shift
+ else
+ cmd = Proc.new
+ end
+ _bind([path, 'bind'], context, cmd, *args)
+ self
+ end
+
+ #def entrybind_append(*args)
+ # _bind_append([path, 'bind'], *args)
+ # self
+ #end
+ def entrybind_append(context, *args)
+ #if args[0].kind_of?(Proc) || args[0].kind_of?(Method)
+ if TkComm._callback_entry?(args[0]) || !block_given?
+ cmd = args.shift
+ else
+ cmd = Proc.new
+ end
+ _bind_append([path, 'bind'], context, cmd, *args)
+ self
+ end
+
+ def entrybind_remove(*args)
+ _bind_remove([path, 'bind'], *args)
+ self
+ end
+
+ def entrybindinfo(*args)
+ _bindinfo([path, 'bind'], *args)
+ self
+ end
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/bwidget/labelframe.rb b/jni/ruby/ext/tk/lib/tkextlib/bwidget/labelframe.rb
new file mode 100644
index 0000000..0710f21
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/bwidget/labelframe.rb
@@ -0,0 +1,52 @@
+#
+# tkextlib/bwidget/labelframe.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+
+require 'tk'
+require 'tk/frame'
+require 'tkextlib/bwidget.rb'
+require 'tkextlib/bwidget/label'
+
+module Tk
+ module BWidget
+ class LabelFrame < TkWindow
+ end
+ end
+end
+
+class Tk::BWidget::LabelFrame
+ TkCommandNames = ['LabelFrame'.freeze].freeze
+ WidgetClassName = 'LabelFrame'.freeze
+ WidgetClassNames[WidgetClassName] ||= self
+
+ def __strval_optkeys
+ super() << 'helptext'
+ end
+ private :__strval_optkeys
+
+ def __boolval_optkeys
+ super() << 'dragenabled' << 'dropenabled'
+ end
+ private :__boolval_optkeys
+
+ def __tkvariable_optkeys
+ super() << 'helpvar'
+ end
+ private :__tkvariable_optkeys
+
+ def self.align(*args)
+ tk_call('LabelFrame::align', *args)
+ end
+ def get_frame(&b)
+ win = window(tk_send_without_enc('getframe'))
+ if b
+ if TkCore::WITH_RUBY_VM ### Ruby 1.9 !!!!
+ win.instance_exec(self, &b)
+ else
+ win.instance_eval(&b)
+ end
+ end
+ win
+ end
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/bwidget/listbox.rb b/jni/ruby/ext/tk/lib/tkextlib/bwidget/listbox.rb
new file mode 100644
index 0000000..930491c
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/bwidget/listbox.rb
@@ -0,0 +1,361 @@
+#
+# tkextlib/bwidget/listbox.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+
+require 'tk'
+require 'tk/canvas'
+require 'tkextlib/bwidget.rb'
+
+module Tk
+ module BWidget
+ class ListBox < TkWindow
+ # is NOT a subclass of a listbox widget class.
+ # because it constructed on a canvas widget.
+
+ class Item < TkObject
+ end
+ end
+ end
+end
+
+class Tk::BWidget::ListBox
+ include TkItemConfigMethod
+ include Scrollable
+
+ TkCommandNames = ['ListBox'.freeze].freeze
+ WidgetClassName = 'ListBox'.freeze
+ WidgetClassNames[WidgetClassName] ||= self
+
+ class Event_for_Items < TkEvent::Event
+ def self._get_extra_args_tbl
+ [
+ TkComm.method(:string) # item idenfier
+ ]
+ end
+ end
+
+ def __boolval_optkeys
+ super() << 'autofocus' << 'dragenabled' << 'dropenabled' << 'selectfill'
+ end
+ private :__boolval_optkeys
+
+ def tagid(tag)
+ if tag.kind_of?(Tk::BWidget::ListBox::Item)
+ tag.id
+ else
+ # tag
+ _get_eval_string(tag)
+ end
+ end
+
+ #def imagebind(*args)
+ # _bind_for_event_class(Event_for_Items, [path, 'bindImage'], *args)
+ # self
+ #end
+ def imagebind(context, *args)
+ #if args[0].kind_of?(Proc) || args[0].kind_of?(Method)
+ if TkComm._callback_entry?(args[0]) || !block_given?
+ cmd = args.shift
+ else
+ cmd = Proc.new
+ end
+ _bind_for_event_class(Event_for_Items, [path, 'bindImage'],
+ context, cmd, *args)
+ self
+ end
+
+ #def imagebind_append(*args)
+ # _bind_append_for_event_class(Event_for_Items, [path, 'bindImage'], *args)
+ # self
+ #end
+ def imagebind_append(context, *args)
+ #if args[0].kind_of?(Proc) || args[0].kind_of?(Method)
+ if TkComm._callback_entry?(args[0]) || !block_given?
+ cmd = args.shift
+ else
+ cmd = Proc.new
+ end
+ _bind_append_for_event_class(Event_for_Items, [path, 'bindImage'],
+ context, cmd, *args)
+ self
+ end
+
+ def imagebind_remove(*args)
+ _bind_remove_for_event_class(Event_for_Items, [path, 'bindImage'], *args)
+ self
+ end
+
+ def imagebindinfo(*args)
+ _bindinfo_for_event_class(Event_for_Items, [path, 'bindImage'], *args)
+ end
+
+ #def textbind(*args)
+ # _bind_for_event_class(Event_for_Items, [path, 'bindText'], *args)
+ # self
+ #end
+ def textbind(context, *args)
+ #if args[0].kind_of?(Proc) || args[0].kind_of?(Method)
+ if TkComm._callback_entry?(args[0]) || !block_given?
+ cmd = args.shift
+ else
+ cmd = Proc.new
+ end
+ _bind_for_event_class(Event_for_Items, [path, 'bindText'],
+ context, cmd, *args)
+ self
+ end
+
+ #def textbind_append(*args)
+ # _bind_append_for_event_class(Event_for_Items, [path, 'bindText'], *args)
+ # self
+ #end
+ def textbind_append(context, *args)
+ #if args[0].kind_of?(Proc) || args[0].kind_of?(Method)
+ if TkComm._callback_entry?(args[0]) || !block_given?
+ cmd = args.shift
+ else
+ cmd = Proc.new
+ end
+ _bind_append_for_event_class(Event_for_Items, [path, 'bindText'],
+ context, cmd, *args)
+ self
+ end
+
+ def textbind_remove(*args)
+ _bind_remove_for_event_class(Event_for_Items, [path, 'bindText'], *args)
+ self
+ end
+
+ def textbindinfo(*args)
+ _bindinfo_for_event_class(Event_for_Items, [path, 'bindText'], *args)
+ end
+
+ def delete(*args)
+ tk_send('delete', *args)
+ self
+ end
+
+ def edit(item, text, *args)
+ tk_send('edit', tagid(item), text, *args)
+ self
+ end
+
+ def exist?(item)
+ bool(tk_send('exists', tagid(item)))
+ end
+
+ def index(item)
+ num_or_str(tk_send('index', tagid(item)))
+ end
+
+ def insert(idx, item, keys={})
+ tk_send('insert', idx, tagid(item), *hash_kv(keys))
+ self
+ end
+
+ def get_item(idx)
+ tk_send('items', idx)
+ end
+
+ def items(first=None, last=None)
+ list(tk_send('items', first, last))
+ end
+
+ def move(item, idx)
+ tk_send('move', tagid(item), idx)
+ self
+ end
+
+ def reorder(neworder)
+ tk_send('reorder', neworder)
+ self
+ end
+
+ def see(item)
+ tk_send('see', tagid(item))
+ self
+ end
+
+ def selection_clear
+ tk_send_without_enc('selection', 'clear')
+ self
+ end
+
+ def selection_set(*args)
+ tk_send_without_enc('selection', 'set',
+ *(args.collect{|item| tagid(item)}))
+ self
+ end
+
+ def selection_add(*args)
+ tk_send_without_enc('selection', 'add',
+ *(args.collect{|item| tagid(item)}))
+ self
+ end
+
+ def selection_remove(*args)
+ tk_send_without_enc('selection', 'remove',
+ *(args.collect{|item| tagid(item)}))
+ self
+ end
+
+ def selection_get(*args)
+ simplelist(tk_send_without_enc('selection', 'get')).collect{|item|
+ Tk::BWidget::ListBox::Item.id2obj(self, item)
+ }
+ end
+end
+
+class Tk::BWidget::ListBox::Item
+ include TkTreatTagFont
+
+ ListItem_TBL = TkCore::INTERP.create_table
+
+ (ListItem_ID = ['bw:item'.freeze, TkUtil.untrust('00000')]).instance_eval{
+ @mutex = Mutex.new
+ def mutex; @mutex; end
+ freeze
+ }
+
+ TkCore::INTERP.init_ip_env{
+ ListItem_TBL.mutex.synchronize{ ListItem_TBL.clear }
+ }
+
+ def self.id2obj(lbox, id)
+ lpath = lbox.path
+ ListItem_TBL.mutex.synchronize{
+ if ListItem_TBL[lpath]
+ ListItem_TBL[lpath][id]? ListItem_TBL[lpath][id]: id
+ else
+ id
+ end
+ }
+ end
+
+ def initialize(lbox, *args)
+ if lbox.kind_of?(Tk::BWidget::ListBox)
+ @listbox = lbox
+ else
+ fail RuntimeError,
+ "expect Tk::BWidget::ListBox or Tk::BWidget::ListBox::Item for 1st argument"
+ end
+
+ if args[-1].kind_of?(Hash)
+ keys = _symbolkey2str(args.pop)
+ else
+ keys = {}
+ end
+
+ index = keys.delete('index')
+ unless args.empty?
+ index = args.shift
+ end
+ index = 'end' unless index
+
+ unless args.empty?
+ fail RuntimeError, 'too much arguments'
+ end
+
+ @lpath = @listbox.path
+
+ if keys.key?('itemname')
+ @path = @id = keys.delete('itemname')
+ else
+ ListItem_ID.mutex.synchronize{
+ @path = @id = ListItem_ID.join(TkCore::INTERP._ip_id_)
+ ListItem_ID[1].succ!
+ }
+ end
+
+ ListItem_TBL.mutex.synchronize{
+ ListItem_TBL[@id] = self
+ ListItem_TBL[@lpath] = {} unless ListItem_TBL[@lpath]
+ ListItem_TBL[@lpath][@id] = self
+ }
+
+ @listbox.insert(index, @id, keys)
+ end
+
+ def listbox
+ @listbox
+ end
+
+ def id
+ @id
+ end
+
+ def [](key)
+ cget(key)
+ end
+
+ def []=(key, val)
+ configure(key, val)
+ val
+ end
+
+ def cget_tkstring(key)
+ @listbox.itemcget_tkstring(@id, key)
+ end
+ def cget(key)
+ @listbox.itemcget(@id, key)
+ end
+ def cget_strict(key)
+ @listbox.itemcget_strict(@id, key)
+ end
+
+ def configure(key, val=None)
+ @listbox.itemconfigure(@id, key, val)
+ end
+
+ def configinfo(key=nil)
+ @listbox.itemconfiginfo(@id, key)
+ end
+
+ def current_configinfo(key=nil)
+ @listbox.current_itemconfiginfo(@id, key)
+ end
+
+ def delete
+ @listbox.delete(@id)
+ self
+ end
+
+ def edit(*args)
+ @listbox.edit(@id, *args)
+ self
+ end
+
+ def exist?
+ @listbox.exist?(@id)
+ end
+
+ def index
+ @listbox.index(@id)
+ end
+
+ def move(index)
+ @listbox.move(@id, index)
+ end
+
+ def see
+ @listbox.see(@id)
+ end
+
+ def selection_add
+ @listbox.selection_add(@id)
+ end
+
+ def selection_remove
+ @listbox.selection_remove(@id)
+ end
+
+ def selection_set
+ @listbox.selection_set(@id)
+ end
+
+ def selection_toggle
+ @listbox.selection_toggle(@id)
+ end
+end
+
diff --git a/jni/ruby/ext/tk/lib/tkextlib/bwidget/mainframe.rb b/jni/ruby/ext/tk/lib/tkextlib/bwidget/mainframe.rb
new file mode 100644
index 0000000..92253bd
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/bwidget/mainframe.rb
@@ -0,0 +1,132 @@
+#
+# tkextlib/bwidget/mainframe.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+
+require 'tk'
+require 'tk/frame'
+require 'tkextlib/bwidget.rb'
+require 'tkextlib/bwidget/progressbar'
+
+module Tk
+ module BWidget
+ class MainFrame < TkWindow
+ end
+ end
+end
+
+class Tk::BWidget::MainFrame
+ TkCommandNames = ['MainFrame'.freeze].freeze
+ WidgetClassName = 'MainFrame'.freeze
+ WidgetClassNames[WidgetClassName] ||= self
+
+ def __strval_optkeys
+ super() << 'progressfg'
+ end
+ private :__strval_optkeys
+
+ def __tkvariable_optkeys
+ super() << 'progressvar'
+ end
+ private :__tkvariable_optkeys
+
+ def __val2ruby_optkeys # { key=>proc, ... }
+ # The method is used to convert a opt-value to a ruby's object.
+ # When get the value of the option "key", "proc.call(value)" is called.
+ {
+ 'menu'=>proc{|v| simplelist(v).collect!{|elem| simplelist(v)}}
+ }
+ end
+ private :__val2ruby_optkeys
+
+ def add_indicator(keys={}, &b)
+ win = window(tk_send('addindicator', *hash_kv(keys)))
+ if b
+ if TkCore::WITH_RUBY_VM ### Ruby 1.9 !!!!
+ win.instance_exec(self, &b)
+ else
+ win.instance_eval(&b)
+ end
+ end
+ win
+ end
+
+ def add_toolbar(&b)
+ win = window(tk_send('addtoolbar'))
+ if b
+ if TkCore::WITH_RUBY_VM ### Ruby 1.9 !!!!
+ win.instance_exec(self, &b)
+ else
+ win.instance_eval(&b)
+ end
+ end
+ win
+ end
+
+ def get_frame(&b)
+ win = window(tk_send('getframe'))
+ if b
+ if TkCore::WITH_RUBY_VM ### Ruby 1.9 !!!!
+ win.instance_exec(self, &b)
+ else
+ win.instance_eval(&b)
+ end
+ end
+ win
+ end
+
+ def get_indicator(idx, &b)
+ win = window(tk_send('getindicator', idx))
+ if b
+ if TkCore::WITH_RUBY_VM ### Ruby 1.9 !!!!
+ win.instance_exec(self, &b)
+ else
+ win.instance_eval(&b)
+ end
+ end
+ win
+ end
+
+ def get_menu(menu_id, &b)
+ win = window(tk_send('getmenu', menu_id))
+ if b
+ if TkCore::WITH_RUBY_VM ### Ruby 1.9 !!!!
+ win.instance_exec(self, &b)
+ else
+ win.instance_eval(&b)
+ end
+ end
+ win
+ end
+
+ def get_toolbar(idx, &b)
+ win = window(tk_send('gettoolbar', idx))
+ if b
+ if TkCore::WITH_RUBY_VM ### Ruby 1.9 !!!!
+ win.instance_exec(self, &b)
+ else
+ win.instance_eval(&b)
+ end
+ end
+ win
+ end
+
+ def get_menustate(tag)
+ tk_send('getmenustate', tag) # return state name string
+ end
+
+ def set_menustate(tag, state)
+ tk_send('setmenustate', tag, state)
+ self
+ end
+
+ def show_statusbar(name)
+ tk_send('showstatusbar', name)
+ self
+ end
+
+ def show_toolbar(idx, mode)
+ tk_send('showtoolbar', idx, mode)
+ self
+ end
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/bwidget/messagedlg.rb b/jni/ruby/ext/tk/lib/tkextlib/bwidget/messagedlg.rb
new file mode 100644
index 0000000..7b62614
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/bwidget/messagedlg.rb
@@ -0,0 +1,192 @@
+#
+# tkextlib/bwidget/messagedlg.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+
+require 'tk'
+require 'tkextlib/bwidget.rb'
+require 'tkextlib/bwidget/dialog.rb'
+
+module Tk
+ module BWidget
+ class MessageDlg < TkWindow
+ end
+ end
+end
+
+class Tk::BWidget::MessageDlg
+ TkCommandNames = ['MessageDlg'.freeze].freeze
+ WidgetClassName = 'MessageDlg'.freeze
+ WidgetClassNames[WidgetClassName] ||= self
+
+ def initialize(parent=nil, keys=nil)
+ @relative = ''
+ if parent.kind_of?(Hash)
+ keys = _symbolkey2str(parent)
+ @relative = keys['parent'] if keys.key?('parent')
+ @relative = keys.delete('relative') if keys.key?('relative')
+ super(keys)
+ elsif keys
+ keys = _symbolkey2str(keys)
+ @relative = keys.delete('parent') if keys.key?('parent')
+ @relative = keys.delete('relative') if keys.key?('relative')
+ super(parent, keys)
+ else
+ super(parent)
+ end
+ end
+
+ def create_self(keys)
+ # NOT create widget.
+ # Because the widget no longer exist when returning from creation.
+ @keys = _symbolkey2str(keys).update('parent'=>@relative)
+ @info = nil
+ end
+ private :create_self
+
+ def __strval_optkeys
+ super() << 'message' << 'title'
+ end
+ private :__strval_optkeys
+
+ def __listval_optkeys
+ super() << 'buttons'
+ end
+ private :__listval_optkeys
+
+ def cget(slot)
+ slot = slot.to_s
+ if slot == 'relative'
+ slot = 'parent'
+ end
+ if winfo_exist?
+ val = super(slot)
+ @keys[slot] = val
+ end
+ @keys[slot]
+ end
+ def cget_strict(slot)
+ slot = slot.to_s
+ if slot == 'relative'
+ slot = 'parent'
+ end
+ if winfo_exist?
+ val = super(slot)
+ @keys[slot] = val
+ end
+ @keys[slot]
+ end
+
+ def configure(slot, value=None)
+ if winfo_exist?
+ super(slot, value)
+ end
+ if slot.kind_of?(Hash)
+ slot = _symbolkey2str(slot)
+ slot['parent'] = slot.delete('relative') if slot.key?('relative')
+ @keys.update(slot)
+
+ if @info
+ # update @info
+ slot.each{|k, v|
+ if TkComm::GET_CONFIGINFO_AS_ARRAY
+ if (inf = @info.assoc(k))
+ inf[-1] = v
+ else
+ @info << [k, '', '', '', v]
+ end
+ else
+ if (inf = @info[k])
+ inf[-1] = v
+ else
+ @info[k] = ['', '', '', v]
+ end
+ end
+ }
+ end
+
+ else # ! Hash
+ slot = slot.to_s
+ slot = 'parent' if slot == 'relative'
+ @keys[slot] = value
+
+ if @info
+ # update @info
+ if TkComm::GET_CONFIGINFO_AS_ARRAY
+ if (inf = @info.assoc(slot))
+ inf[-1] = value
+ else
+ @info << [slot, '', '', '', value]
+ end
+ else
+ if (inf = @info[slot])
+ inf[-1] = value
+ else
+ @info[slot] = ['', '', '', value]
+ end
+ end
+ end
+ end
+
+ self
+ end
+
+ def configinfo(slot=nil)
+ if winfo_exist?
+ @info = super()
+ if TkComm::GET_CONFIGINFO_AS_ARRAY
+ @info << ['relative', 'parent']
+ else
+ @info['relative'] = 'parent'
+ end
+ end
+
+ if TkComm::GET_CONFIGINFO_AS_ARRAY
+ if @info
+ if winfo_exist?
+ # update @keys
+ @info.each{|inf| @keys[inf[0]] = inf[-1] if inf.size > 2 }
+ end
+ else
+ @info = []
+ @keys.each{|k, v|
+ @info << [k, '', '', '', v]
+ }
+ @info << ['relative', 'parent']
+ end
+
+ if slot
+ @info.asoc(slot.to_s).dup
+ else
+ @info.dup
+ end
+
+ else # ! TkComm::GET_CONFIGINFO_AS_ARRAY
+ if @info
+ if winfo_exist?
+ # update @keys
+ @info.each{|k, inf| @keys[k] = inf[-1] if inf.size > 2 }
+ end
+ else
+ @info = {}
+ @keys.each{|k, v|
+ @info[k] = ['', '', '', v]
+ }
+ @info['relative'] = 'parent'
+ end
+
+ if slot
+ @info[slot.to_s].dup
+ else
+ @info.dup
+ end
+ end
+ end
+
+ def create
+ # return the index of the pressed button, or nil if it is destroyed
+ ret = num_or_str(tk_call(self.class::TkCommandNames[0],
+ @path, *hash_kv(@keys)))
+ (ret < 0)? nil: ret
+ end
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/bwidget/notebook.rb b/jni/ruby/ext/tk/lib/tkextlib/bwidget/notebook.rb
new file mode 100644
index 0000000..ed28bcd
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/bwidget/notebook.rb
@@ -0,0 +1,166 @@
+#
+# tkextlib/bwidget/notebook.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+
+require 'tk'
+require 'tk/frame'
+require 'tkextlib/bwidget.rb'
+
+module Tk
+ module BWidget
+ class NoteBook < TkWindow
+ end
+ end
+end
+
+class Tk::BWidget::NoteBook
+ include TkItemConfigMethod
+
+ TkCommandNames = ['NoteBook'.freeze].freeze
+ WidgetClassName = 'NoteBook'.freeze
+ WidgetClassNames[WidgetClassName] ||= self
+
+ class Event_for_Tabs < TkEvent::Event
+ def self._get_extra_args_tbl
+ [
+ TkComm.method(:string) # page idenfier
+ ]
+ end
+ end
+
+ def __boolval_optkeys
+ super() << 'homogeneous'
+ end
+ private :__boolval_optkeys
+
+ def tagid(id)
+ if id.kind_of?(TkWindow)
+ #id.path
+ id.epath
+ elsif id.kind_of?(TkObject)
+ id.to_eval
+ else
+ # id.to_s
+ _get_eval_string(id)
+ end
+ end
+
+ #def tabbind(*args)
+ # _bind_for_event_class(Event_for_Tabs, [path, 'bindtabs'], *args)
+ # self
+ #end
+ def tabbind(context, *args)
+ #if args[0].kind_of?(Proc) || args[0].kind_of?(Method)
+ if TkComm._callback_entry?(args[0]) || !block_given?
+ cmd = args.shift
+ else
+ cmd = Proc.new
+ end
+ _bind_for_event_class(Event_for_Tabs, [path, 'bindtabs'],
+ context, cmd, *args)
+ self
+ end
+
+ #def tabbind_append(*args)
+ # _bind_append_for_event_class(Event_for_Tabs, [path, 'bindtabs'], *args)
+ # self
+ #end
+ def tabbind_append(context, *args)
+ #if args[0].kind_of?(Proc) || args[0].kind_of?(Method)
+ if TkComm._callback_entry?(args[0]) || !block_given?
+ cmd = args.shift
+ else
+ cmd = Proc.new
+ end
+ _bind_append_for_event_class(Event_for_Tabs, [path, 'bindtabs'],
+ context, cmd, *args)
+ self
+ end
+
+ def tabbind_remove(*args)
+ _bind_remove_for_event_class(Event_for_Tabs, [path, 'bindtabs'], *args)
+ self
+ end
+
+ def tabbindinfo(*args)
+ _bindinfo_for_event_class(Event_for_Tabs, [path, 'bindtabs'], *args)
+ end
+
+ def add(page, &b)
+ win = window(tk_send('add', tagid(page)))
+ if b
+ if TkCore::WITH_RUBY_VM ### Ruby 1.9 !!!!
+ win.instance_exec(self, &b)
+ else
+ win.instance_eval(&b)
+ end
+ end
+ win
+ end
+
+ def compute_size
+ tk_send('compute_size')
+ self
+ end
+
+ def delete(page, destroyframe=None)
+ tk_send('delete', tagid(page), destroyframe)
+ self
+ end
+
+ def get_frame(page, &b)
+ win = window(tk_send('getframe', tagid(page)))
+ if b
+ if TkCore::WITH_RUBY_VM ### Ruby 1.9 !!!!
+ win.instance_exec(self, &b)
+ else
+ win.instance_eval(&b)
+ end
+ end
+ win
+ end
+
+ def index(page)
+ num_or_str(tk_send('index', tagid(page)))
+ end
+
+ def insert(index, page, keys={}, &b)
+ win = window(tk_send('insert', index, tagid(page), *hash_kv(keys)))
+ if b
+ if TkCore::WITH_RUBY_VM ### Ruby 1.9 !!!!
+ win.instance_exec(self, &b)
+ else
+ win.instance_eval(&b)
+ end
+ end
+ win
+ end
+
+ def move(page, index)
+ tk_send('move', tagid(page), index)
+ self
+ end
+
+ def get_page(page)
+ tk_send('pages', page)
+ end
+
+ def pages(first=None, last=None)
+ list(tk_send('pages', first, last))
+ end
+
+ def raise(page=nil)
+ if page
+ tk_send('raise', page)
+ self
+ else
+ tk_send('raise')
+ end
+ end
+
+ def see(page)
+ tk_send('see', page)
+ self
+ end
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/bwidget/pagesmanager.rb b/jni/ruby/ext/tk/lib/tkextlib/bwidget/pagesmanager.rb
new file mode 100644
index 0000000..31bbf1f
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/bwidget/pagesmanager.rb
@@ -0,0 +1,73 @@
+#
+# tkextlib/bwidget/pagesmanager.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+
+require 'tk'
+require 'tk/frame'
+require 'tkextlib/bwidget.rb'
+
+module Tk
+ module BWidget
+ class PagesManager < TkWindow
+ end
+ end
+end
+
+class Tk::BWidget::PagesManager
+ TkCommandNames = ['PagesManager'.freeze].freeze
+ WidgetClassName = 'PagesManager'.freeze
+ WidgetClassNames[WidgetClassName] ||= self
+
+ def tagid(id)
+ # id.to_s
+ _get_eval_string(id)
+ end
+
+ def add(page, &b)
+ win = window(tk_send('add', tagid(page)))
+ if b
+ if TkCore::WITH_RUBY_VM ### Ruby 1.9 !!!!
+ win.instance_exec(self, &b)
+ else
+ win.instance_eval(&b)
+ end
+ end
+ win
+ end
+
+ def compute_size
+ tk_send('compute_size')
+ self
+ end
+
+ def delete(page)
+ tk_send('delete', tagid(page))
+ self
+ end
+
+ def get_frame(page, &b)
+ win = window(tk_send('getframe', tagid(page)))
+ if b
+ if TkCore::WITH_RUBY_VM ### Ruby 1.9 !!!!
+ win.instance_exec(self, &b)
+ else
+ win.instance_eval(&b)
+ end
+ end
+ win
+ end
+
+ def get_page(page)
+ tk_send('pages', page)
+ end
+
+ def pages(first=None, last=None)
+ list(tk_send('pages', first, last))
+ end
+
+ def raise(page=None)
+ tk_send('raise', page)
+ self
+ end
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/bwidget/panedwindow.rb b/jni/ruby/ext/tk/lib/tkextlib/bwidget/panedwindow.rb
new file mode 100644
index 0000000..54cf06c
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/bwidget/panedwindow.rb
@@ -0,0 +1,42 @@
+#
+# tkextlib/bwidget/panedwindow.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+
+require 'tk'
+require 'tk/frame'
+require 'tkextlib/bwidget.rb'
+
+module Tk
+ module BWidget
+ class PanedWindow < TkWindow
+ end
+ end
+end
+
+class Tk::BWidget::PanedWindow
+ TkCommandNames = ['PanedWindow'.freeze].freeze
+ WidgetClassName = 'PanedWindow'.freeze
+ WidgetClassNames[WidgetClassName] ||= self
+
+ def __strval_optkeys
+ super() << 'activator'
+ end
+ private :__strval_optkeys
+
+ def add(keys={})
+ window(tk_send('add', *hash_kv(keys)))
+ end
+
+ def get_frame(idx, &b)
+ win = window(tk_send_without_enc('getframe', idx))
+ if b
+ if TkCore::WITH_RUBY_VM ### Ruby 1.9 !!!!
+ win.instance_exec(self, &b)
+ else
+ win.instance_eval(&b)
+ end
+ end
+ win
+ end
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/bwidget/panelframe.rb b/jni/ruby/ext/tk/lib/tkextlib/bwidget/panelframe.rb
new file mode 100644
index 0000000..1cbf914
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/bwidget/panelframe.rb
@@ -0,0 +1,67 @@
+#
+# tkextlib/bwidget/panelframe.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+
+require 'tk'
+require 'tk/frame'
+require 'tkextlib/bwidget.rb'
+
+module Tk
+ module BWidget
+ class PanelFrame < TkWindow
+ end
+ end
+end
+
+class Tk::BWidget::PanelFrame
+ TkCommandNames = ['PanelFrame'.freeze].freeze
+ WidgetClassName = 'PanelFrame'.freeze
+ WidgetClassNames[WidgetClassName] ||= self
+
+ def __strval_optkeys
+ super() + ['panelforeground', 'panelbackground']
+ end
+ private :__strval_optkeys
+
+ def add(win, keys={})
+ tk_send('add', win, keys)
+ self
+ end
+
+ def delete(*wins)
+ tk_send('delete', *wins)
+ self
+ end
+
+ def get_frame(&b)
+ win = window(tk_send_without_enc('getframe'))
+ if b
+ if TkCore::WITH_RUBY_VM ### Ruby 1.9 !!!!
+ win.instance_exec(self, &b)
+ else
+ win.instance_eval(&b)
+ end
+ end
+ win
+ end
+
+ def items
+ simplelist(tk_send('items')).map{|w| window(w)}
+ end
+
+ def remove(*wins)
+ tk_send('remove', *wins)
+ self
+ end
+
+ def remove_with_destroy(*wins)
+ tk_send('remove', '-destroy', *wins)
+ self
+ end
+
+ def delete(*wins) # same to 'remove_with_destroy'
+ tk_send('delete', *wins)
+ self
+ end
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/bwidget/passwddlg.rb b/jni/ruby/ext/tk/lib/tkextlib/bwidget/passwddlg.rb
new file mode 100644
index 0000000..ea50c87
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/bwidget/passwddlg.rb
@@ -0,0 +1,44 @@
+#
+# tkextlib/bwidget/passwddlg.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+
+require 'tk'
+require 'tkextlib/bwidget.rb'
+require 'tkextlib/bwidget/messagedlg'
+
+module Tk
+ module BWidget
+ class PasswdDlg < Tk::BWidget::MessageDlg
+ end
+ end
+end
+
+class Tk::BWidget::PasswdDlg
+ TkCommandNames = ['PasswdDlg'.freeze].freeze
+ WidgetClassName = 'PasswdDlg'.freeze
+ WidgetClassNames[WidgetClassName] ||= self
+
+ def __strval_optkeys
+ super() << 'loginhelptext' << 'loginlabel' << 'logintext' <<
+ 'passwdlabel' << 'passwdtext'
+ end
+ private :__strval_optkeys
+
+ def __boolval_optkeys
+ super() << 'passwdeditable' << 'homogeneous'
+ end
+ private :__boolval_optkeys
+
+ def __tkvariable_optkeys
+ super() << 'loginhelpvar' << 'logintextvariable' <<
+ 'passwdhelpvar' << 'passwdtextvariable'
+ end
+ private :__tkvariable_optkeys
+
+ def create
+ login, passwd = simplelist(tk_call(self.class::TkCommandNames[0],
+ @path, *hash_kv(@keys)))
+ [login, passwd]
+ end
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/bwidget/progressbar.rb b/jni/ruby/ext/tk/lib/tkextlib/bwidget/progressbar.rb
new file mode 100644
index 0000000..18eb673
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/bwidget/progressbar.rb
@@ -0,0 +1,20 @@
+#
+# tkextlib/bwidget/progressbar.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+
+require 'tk'
+require 'tkextlib/bwidget.rb'
+
+module Tk
+ module BWidget
+ class ProgressBar < TkWindow
+ end
+ end
+end
+
+class Tk::BWidget::ProgressBar
+ TkCommandNames = ['ProgressBar'.freeze].freeze
+ WidgetClassName = 'ProgressBar'.freeze
+ WidgetClassNames[WidgetClassName] ||= self
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/bwidget/progressdlg.rb b/jni/ruby/ext/tk/lib/tkextlib/bwidget/progressdlg.rb
new file mode 100644
index 0000000..0c0c454
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/bwidget/progressdlg.rb
@@ -0,0 +1,58 @@
+#
+# tkextlib/bwidget/progressdlg.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+
+require 'tk'
+require 'tk/variable'
+require 'tkextlib/bwidget.rb'
+require 'tkextlib/bwidget/progressbar'
+require 'tkextlib/bwidget/messagedlg'
+
+module Tk
+ module BWidget
+ class ProgressDlg < Tk::BWidget::MessageDlg
+ end
+ end
+end
+
+class Tk::BWidget::ProgressDlg
+ TkCommandNames = ['ProgressDlg'.freeze].freeze
+ WidgetClassName = 'ProgressDlg'.freeze
+ WidgetClassNames[WidgetClassName] ||= self
+
+ def create_self(keys)
+ # NOT create widget for reusing the object
+ super(keys)
+ @keys['textvariable'] = TkVariable.new unless @keys.key?('textvariable')
+ @keys['variable'] = TkVariable.new unless @keys.key?('variable')
+ end
+
+ def textvariable
+ @keys['textvariable']
+ end
+
+ def text
+ @keys['textvariable'].value
+ end
+
+ def text= (txt)
+ @keys['textvariable'].value = txt
+ end
+
+ def variable
+ @keys['variable']
+ end
+
+ def value
+ @keys['variable'].value
+ end
+
+ def value= (val)
+ @keys['variable'].value = val
+ end
+
+ def create
+ window(tk_call(self.class::TkCommandNames[0], @path, *hash_kv(@keys)))
+ end
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/bwidget/scrollableframe.rb b/jni/ruby/ext/tk/lib/tkextlib/bwidget/scrollableframe.rb
new file mode 100644
index 0000000..5bd00d6
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/bwidget/scrollableframe.rb
@@ -0,0 +1,40 @@
+#
+# tkextlib/bwidget/scrollableframe.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+
+require 'tk'
+require 'tk/frame'
+require 'tkextlib/bwidget.rb'
+
+module Tk
+ module BWidget
+ class ScrollableFrame < TkWindow
+ end
+ end
+end
+
+class Tk::BWidget::ScrollableFrame
+ include Scrollable
+
+ TkCommandNames = ['ScrollableFrame'.freeze].freeze
+ WidgetClassName = 'ScrollableFrame'.freeze
+ WidgetClassNames[WidgetClassName] ||= self
+
+ def get_frame(&b)
+ win = window(tk_send_without_enc('getframe'))
+ if b
+ if TkCore::WITH_RUBY_VM ### Ruby 1.9 !!!!
+ win.instance_exec(self, &b)
+ else
+ win.instance_eval(&b)
+ end
+ end
+ win
+ end
+
+ def see(win, vert=None, horiz=None)
+ tk_send_without_enc('see', win, vert, horiz)
+ self
+ end
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/bwidget/scrolledwindow.rb b/jni/ruby/ext/tk/lib/tkextlib/bwidget/scrolledwindow.rb
new file mode 100644
index 0000000..ea5a18c
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/bwidget/scrolledwindow.rb
@@ -0,0 +1,48 @@
+#
+# tkextlib/bwidget/scrolledwindow.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+
+require 'tk'
+require 'tk/frame'
+require 'tkextlib/bwidget.rb'
+
+module Tk
+ module BWidget
+ class ScrolledWindow < TkWindow
+ end
+ end
+end
+
+class Tk::BWidget::ScrolledWindow
+ TkCommandNames = ['ScrolledWindow'.freeze].freeze
+ WidgetClassName = 'ScrolledWindow'.freeze
+ WidgetClassNames[WidgetClassName] ||= self
+
+ def __strval_optkeys
+ super() << 'sides'
+ end
+ private :__strval_optkeys
+
+ def __boolval_optkeys
+ super() << 'managed'
+ end
+ private :__boolval_optkeys
+
+ def get_frame(&b)
+ win = window(tk_send_without_enc('getframe'))
+ if b
+ if TkCore::WITH_RUBY_VM ### Ruby 1.9 !!!!
+ win.instance_exec(self, &b)
+ else
+ win.instance_eval(&b)
+ end
+ end
+ win
+ end
+
+ def set_widget(win)
+ tk_send_without_enc('setwidget', win)
+ self
+ end
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/bwidget/scrollview.rb b/jni/ruby/ext/tk/lib/tkextlib/bwidget/scrollview.rb
new file mode 100644
index 0000000..ab27bc9
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/bwidget/scrollview.rb
@@ -0,0 +1,25 @@
+#
+# tkextlib/bwidget/scrollview.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+
+require 'tk'
+require 'tkextlib/bwidget.rb'
+
+module Tk
+ module BWidget
+ class ScrollView < TkWindow
+ end
+ end
+end
+
+class Tk::BWidget::ScrollView
+ TkCommandNames = ['ScrollView'.freeze].freeze
+ WidgetClassName = 'ScrollView'.freeze
+ WidgetClassNames[WidgetClassName] ||= self
+
+ def __strval_optkeys
+ super() << 'fill'
+ end
+ private :__strval_optkeys
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/bwidget/selectcolor.rb b/jni/ruby/ext/tk/lib/tkextlib/bwidget/selectcolor.rb
new file mode 100644
index 0000000..456175e
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/bwidget/selectcolor.rb
@@ -0,0 +1,73 @@
+#
+# tkextlib/bwidget/selectcolor.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+
+require 'tk'
+require 'tkextlib/bwidget.rb'
+require 'tkextlib/bwidget/messagedlg'
+
+module Tk
+ module BWidget
+ class SelectColor < Tk::BWidget::MessageDlg
+ class Dialog < Tk::BWidget::SelectColor
+ end
+ class Menubutton < Tk::Menubutton
+ end
+ MenuButton = Menubutton
+ end
+ end
+end
+
+class Tk::BWidget::SelectColor
+ extend Tk
+
+ TkCommandNames = ['SelectColor'.freeze].freeze
+ WidgetClassName = 'SelectColor'.freeze
+ WidgetClassNames[WidgetClassName] ||= self
+
+ def dialog(keys={})
+ newkeys = @keys.dup
+ newkeys.update(_symbolkey2str(keys))
+ tk_call('SelectColor::dialog', @path, *hash_kv(newkeys))
+ end
+
+ def menu(*args)
+ if args[-1].kind_of?(Hash)
+ keys = args.pop
+ else
+ keys = {}
+ end
+ place = args.flatten
+ newkeys = @keys.dup
+ newkeys.update(_symbolkey2str(keys))
+ tk_call('SelectColor::menu', @path, place, *hash_kv(newkeys))
+ end
+
+ def self.set_color(idx, color)
+ tk_call('SelectColor::setcolor', idx, color)
+ end
+end
+
+class Tk::BWidget::SelectColor::Dialog
+ def create_self(keys)
+ super(keys)
+ @keys['type'] = 'dialog'
+ end
+
+ def create
+ @keys['type'] = 'dialog' # 'dialog' type returns color
+ tk_call(Tk::BWidget::SelectColor::TkCommandNames[0],
+ @path, *hash_kv(@keys))
+ end
+end
+
+class Tk::BWidget::SelectColor::Menubutton
+ def create_self(keys)
+ keys = {} unless keys
+ keys = _symbolkey2str(keys)
+ keys['type'] = 'menubutton' # 'toolbar' type returns widget path
+ window(tk_call(Tk::BWidget::SelectColor::TkCommandNames[0],
+ @path, *hash_kv(keys)))
+ end
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/bwidget/selectfont.rb b/jni/ruby/ext/tk/lib/tkextlib/bwidget/selectfont.rb
new file mode 100644
index 0000000..23419cb
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/bwidget/selectfont.rb
@@ -0,0 +1,91 @@
+#
+# tkextlib/bwidget/selectfont.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+
+require 'tk'
+require 'tkextlib/bwidget.rb'
+require 'tkextlib/bwidget/messagedlg'
+
+module Tk
+ module BWidget
+ class SelectFont < Tk::BWidget::MessageDlg
+ class Dialog < Tk::BWidget::SelectFont
+ end
+ class Toolbar < TkWindow
+ end
+ end
+ end
+end
+
+class Tk::BWidget::SelectFont
+ extend Tk
+
+ TkCommandNames = ['SelectFont'.freeze].freeze
+ WidgetClassName = 'SelectFont'.freeze
+ WidgetClassNames[WidgetClassName] ||= self
+
+ def __strval_optkeys
+ super() << 'sampletext' << 'title'
+ end
+ private :__strval_optkeys
+
+ def __boolval_optkeys
+ super() << 'nosizes'
+ end
+ private :__boolval_optkeys
+
+ def __font_optkeys
+ [] # without fontobj operation
+ end
+ private :__font_optkeys
+
+ def create
+ tk_call(self.class::TkCommandNames[0], @path, *hash_kv(@keys))
+ end
+
+ def self.load_font
+ tk_call('SelectFont::loadfont')
+ end
+end
+
+class Tk::BWidget::SelectFont::Dialog
+ def __font_optkeys
+ [] # without fontobj operation
+ end
+
+ def create_self(keys)
+ super(keys)
+ @keys['type'] = 'dialog'
+ end
+
+ def configure(slot, value=None)
+ if slot.kind_of?(Hash)
+ slot.delete['type']
+ slot.delete[:type]
+ return self if slot.empty?
+ else
+ return self if slot == 'type' || slot == :type
+ end
+ super(slot, value)
+ end
+
+ def create
+ @keys['type'] = 'dialog' # 'dialog' type returns font name
+ tk_call(Tk::BWidget::SelectFont::TkCommandNames[0], @path, *hash_kv(@keys))
+ end
+end
+
+class Tk::BWidget::SelectFont::Toolbar
+ def __font_optkeys
+ [] # without fontobj operation
+ end
+
+ def create_self(keys)
+ keys = {} unless keys
+ keys = _symbolkey2str(keys)
+ keys['type'] = 'toolbar' # 'toolbar' type returns widget path
+ window(tk_call(Tk::BWidget::SelectFont::TkCommandNames[0],
+ @path, *hash_kv(keys)))
+ end
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/bwidget/separator.rb b/jni/ruby/ext/tk/lib/tkextlib/bwidget/separator.rb
new file mode 100644
index 0000000..6d92321
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/bwidget/separator.rb
@@ -0,0 +1,20 @@
+#
+# tkextlib/bwidget/separator.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+
+require 'tk'
+require 'tkextlib/bwidget.rb'
+
+module Tk
+ module BWidget
+ class Separator < TkWindow
+ end
+ end
+end
+
+class Tk::BWidget::Separator
+ TkCommandNames = ['Separator'.freeze].freeze
+ WidgetClassName = 'Separator'.freeze
+ WidgetClassNames[WidgetClassName] ||= self
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/bwidget/setup.rb b/jni/ruby/ext/tk/lib/tkextlib/bwidget/setup.rb
new file mode 100644
index 0000000..ee406c6
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/bwidget/setup.rb
@@ -0,0 +1,8 @@
+#
+# setup.rb -- setup script before calling TkPackage.require()
+#
+# If you need some setup operations (for example, add a library path
+# to the library search path) before using Tcl/Tk library packages
+# wrapped by Ruby scripts in this directory, please write the setup
+# operations in this file.
+#
diff --git a/jni/ruby/ext/tk/lib/tkextlib/bwidget/spinbox.rb b/jni/ruby/ext/tk/lib/tkextlib/bwidget/spinbox.rb
new file mode 100644
index 0000000..0a45b04
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/bwidget/spinbox.rb
@@ -0,0 +1,98 @@
+#
+# tkextlib/bwidget/entry.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+
+require 'tk'
+require 'tkextlib/bwidget.rb'
+require 'tkextlib/bwidget/arrowbutton'
+require 'tkextlib/bwidget/entry'
+
+module Tk
+ module BWidget
+ class SpinBox < Tk::Entry
+ end
+ end
+end
+
+class Tk::BWidget::SpinBox
+ include Scrollable
+
+ TkCommandNames = ['SpinBox'.freeze].freeze
+ WidgetClassName = 'SpinBox'.freeze
+ WidgetClassNames[WidgetClassName] ||= self
+
+ def __strval_optkeys
+ super() << 'helptext' << 'insertbackground' << 'entryfg' << 'entrybg'
+ end
+ private :__strval_optkeys
+
+ def __boolval_optkeys
+ super() << 'dragenabled' << 'dropenabled' << 'editable'
+ end
+ private :__boolval_optkeys
+
+ def __listval_optkeys
+ super() << 'values'
+ end
+ private :__listval_optkeys
+
+ def __tkvariable_optkeys
+ super() << 'helpvar'
+ end
+ private :__tkvariable_optkeys
+
+ #def entrybind(*args)
+ # _bind([path, 'bind'], *args)
+ # self
+ #end
+ def entrybind(context, *args)
+ #if args[0].kind_of?(Proc) || args[0].kind_of?(Method)
+ if TkComm._callback_entry?(args[0]) || !block_given?
+ cmd = args.shift
+ else
+ cmd = Proc.new
+ end
+ _bind([path, 'bind'], context, cmd, *args)
+ self
+ end
+
+ #def entrybind_append(*args)
+ # _bind_append([path, 'bind'], *args)
+ # self
+ #end
+ def entrybind_append(context, *args)
+ #if args[0].kind_of?(Proc) || args[0].kind_of?(Method)
+ if TkComm._callback_entry?(args[0]) || !block_given?
+ cmd = args.shift
+ else
+ cmd = Proc.new
+ end
+ _bind_append([path, 'bind'], context, cmd, *args)
+ self
+ end
+
+ def entrybind_remove(*args)
+ _bind_remove([path, 'bind'], *args)
+ self
+ end
+
+ def entrybindinfo(*args)
+ _bindinfo([path, 'bind'], *args)
+ self
+ end
+
+ def get_index_of_value
+ number(tk_send_without_enc('getvalue'))
+ end
+ alias get_value get_index_of_value
+ alias get_value_index get_index_of_value
+
+ def set_value_by_index(idx)
+ idx = "@#{idx}" if idx.kind_of?(Integer)
+ tk_send_without_enc('setvalue', idx)
+ self
+ end
+ alias set_value set_value_by_index
+ alias set_index_value set_value_by_index
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/bwidget/statusbar.rb b/jni/ruby/ext/tk/lib/tkextlib/bwidget/statusbar.rb
new file mode 100644
index 0000000..5c5dd43
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/bwidget/statusbar.rb
@@ -0,0 +1,62 @@
+#
+# tkextlib/bwidget/statusbar.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+
+require 'tk'
+require 'tk/frame'
+require 'tkextlib/bwidget.rb'
+
+module Tk
+ module BWidget
+ class StatusBar < TkWindow
+ end
+ end
+end
+
+class Tk::BWidget::StatusBar
+ TkCommandNames = ['StatusBar'.freeze].freeze
+ WidgetClassName = 'StatusBar'.freeze
+ WidgetClassNames[WidgetClassName] ||= self
+
+ def __boolval_optkeys
+ super() << 'showresize' << 'showseparator' << 'showresizesep'
+ end
+ private :__boolval_optkeys
+
+ def add(win, keys={})
+ tk_send('add', win, keys)
+ self
+ end
+
+ def remove(*wins)
+ tk_send('remove', *wins)
+ self
+ end
+
+ def remove_with_destroy(*wins)
+ tk_send('remove', '-destroy', *wins)
+ self
+ end
+
+ def delete(*wins) # same to 'remove_with_destroy'
+ tk_send('delete', *wins)
+ self
+ end
+
+ def get_frame(&b)
+ win = window(tk_send_without_enc('getframe'))
+ if b
+ if TkCore::WITH_RUBY_VM ### Ruby 1.9 !!!!
+ win.instance_exec(self, &b)
+ else
+ win.instance_eval(&b)
+ end
+ end
+ win
+ end
+
+ def items
+ simplelist(tk_send('items')).map{|w| window(w)}
+ end
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/bwidget/titleframe.rb b/jni/ruby/ext/tk/lib/tkextlib/bwidget/titleframe.rb
new file mode 100644
index 0000000..7187911
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/bwidget/titleframe.rb
@@ -0,0 +1,33 @@
+#
+# tkextlib/bwidget/titleframe.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+
+require 'tk'
+require 'tk/frame'
+require 'tkextlib/bwidget.rb'
+
+module Tk
+ module BWidget
+ class TitleFrame < TkWindow
+ end
+ end
+end
+
+class Tk::BWidget::TitleFrame
+ TkCommandNames = ['TitleFrame'.freeze].freeze
+ WidgetClassName = 'TitleFrame'.freeze
+ WidgetClassNames[WidgetClassName] ||= self
+
+ def get_frame(&b)
+ win = window(tk_send_without_enc('getframe'))
+ if b
+ if TkCore::WITH_RUBY_VM ### Ruby 1.9 !!!!
+ win.instance_exec(self, &b)
+ else
+ win.instance_eval(&b)
+ end
+ end
+ win
+ end
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/bwidget/tree.rb b/jni/ruby/ext/tk/lib/tkextlib/bwidget/tree.rb
new file mode 100644
index 0000000..089c482
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/bwidget/tree.rb
@@ -0,0 +1,500 @@
+#
+# tkextlib/bwidget/tree.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+
+require 'tk'
+require 'tk/canvas'
+require 'tkextlib/bwidget.rb'
+
+module Tk
+ module BWidget
+ class Tree < TkWindow
+ class Node < TkObject
+ end
+ end
+ end
+end
+
+class Tk::BWidget::Tree
+ include TkItemConfigMethod
+ include Scrollable
+
+ TkCommandNames = ['Tree'.freeze].freeze
+ WidgetClassName = 'Tree'.freeze
+ WidgetClassNames[WidgetClassName] ||= self
+
+ class Event_for_Items < TkEvent::Event
+ def self._get_extra_args_tbl
+ [
+ TkComm.method(:string) # item idenfier
+ ]
+ end
+ end
+
+ def __strval_optkeys
+ super() << 'crossfill' << 'linesfill'
+ end
+ private :__strval_optkeys
+
+ def __boolval_optkeys
+ super() << 'dragenabled' << 'dropenabled' <<
+ 'redraw' << 'selectfill' << 'showlines'
+ end
+ private :__boolval_optkeys
+
+ def __tkvariable_optkeys
+ super() << 'helpvar'
+ end
+ private :__tkvariable_optkeys
+
+ def tagid(tag)
+ if tag.kind_of?(Tk::BWidget::Tree::Node)
+ tag.id
+ else
+ # tag
+ _get_eval_string(tag)
+ end
+ end
+
+ def areabind(context, *args)
+ if TkComm._callback_entry?(args[0]) || !block_given?
+ cmd = args.shift
+ else
+ cmd = Proc.new
+ end
+ _bind_for_event_class(Event_for_Items, [path, 'bindArea'],
+ context, cmd, *args)
+ self
+ end
+
+ def areabind_append(context, *args)
+ if TkComm._callback_entry?(args[0]) || !block_given?
+ cmd = args.shift
+ else
+ cmd = Proc.new
+ end
+ _bind_append_for_event_class(Event_for_Items, [path, 'bindArea'],
+ context, cmd, *args)
+ self
+ end
+
+ def areabind_remove(*args)
+ _bind_remove_for_event_class(Event_for_Items, [path, 'bindArea'], *args)
+ self
+ end
+
+ def areabindinfo(*args)
+ _bindinfo_for_event_class(Event_for_Items, [path, 'bindArea'], *args)
+ end
+
+ #def imagebind(*args)
+ # _bind_for_event_class(Event_for_Items, [path, 'bindImage'], *args)
+ # self
+ #end
+ def imagebind(context, *args)
+ #if args[0].kind_of?(Proc) || args[0].kind_of?(Method)
+ if TkComm._callback_entry?(args[0]) || !block_given?
+ cmd = args.shift
+ else
+ cmd = Proc.new
+ end
+ _bind_for_event_class(Event_for_Items, [path, 'bindImage'],
+ context, cmd, *args)
+ self
+ end
+
+ #def imagebind_append(*args)
+ # _bind_append_for_event_class(Event_for_Items, [path, 'bindImage'], *args)
+ # self
+ #end
+ def imagebind_append(context, *args)
+ #if args[0].kind_of?(Proc) || args[0].kind_of?(Method)
+ if TkComm._callback_entry?(args[0]) || !block_given?
+ cmd = args.shift
+ else
+ cmd = Proc.new
+ end
+ _bind_append_for_event_class(Event_for_Items, [path, 'bindImage'],
+ context, cmd, *args)
+ self
+ end
+
+ def imagebind_remove(*args)
+ _bind_remove_for_event_class(Event_for_Items, [path, 'bindImage'], *args)
+ self
+ end
+
+ def imagebindinfo(*args)
+ _bindinfo_for_event_class(Event_for_Items, [path, 'bindImage'], *args)
+ end
+
+ #def textbind(*args)
+ # _bind_for_event_class(Event_for_Items, [path, 'bindText'], *args)
+ # self
+ #end
+ def textbind(context, *args)
+ #if args[0].kind_of?(Proc) || args[0].kind_of?(Method)
+ if TkComm._callback_entry?(args[0]) || !block_given?
+ cmd = args.shift
+ else
+ cmd = Proc.new
+ end
+ _bind_for_event_class(Event_for_Items, [path, 'bindText'],
+ context, cmd, *args)
+ self
+ end
+
+ #def textbind_append(*args)
+ # _bind_append_for_event_class(Event_for_Items, [path, 'bindText'], *args)
+ # self
+ #end
+ def textbind_append(context, *args)
+ #if args[0].kind_of?(Proc) || args[0].kind_of?(Method)
+ if TkComm._callback_entry?(args[0]) || !block_given?
+ cmd = args.shift
+ else
+ cmd = Proc.new
+ end
+ _bind_append_for_event_class(Event_for_Items, [path, 'bindText'],
+ context, cmd, *args)
+ self
+ end
+
+ def textbind_remove(*args)
+ _bind_remove_for_event_class(Event_for_Items, [path, 'bindText'], *args)
+ self
+ end
+
+ def textbindinfo(*args)
+ _bindinfo_for_event_class(Event_for_Items, [path, 'bindText'], *args)
+ end
+
+ def close_tree(node, recurse=None)
+ tk_send('closetree', tagid(node), recurse)
+ self
+ end
+
+ def delete(*args)
+ tk_send('delete', *(args.collect{|node| tagid(node)}))
+ self
+ end
+
+ def edit(node, text, *args)
+ tk_send('edit', tagid(node), text, *args)
+ self
+ end
+
+ def exist?(node)
+ bool(tk_send('exists', tagid(node)))
+ end
+
+ def find(findinfo, confine=None)
+ Tk::BWidget::Tree::Node.id2obj(self, tk_send(findinfo, confine))
+ end
+ def find_position(x, y, confine=None)
+ self.find(_at(x,y), confine)
+ end
+ def find_line(linenum)
+ self.find(linenum)
+ end
+
+ def index(node)
+ num_or_str(tk_send('index', tagid(node)))
+ end
+
+ def insert(idx, parent, node, keys={})
+ tk_send('insert', idx, tagid(parent), tagid(node), *hash_kv(keys))
+ self
+ end
+
+ def line(node)
+ number(tk_send('line', tagid(node)))
+ end
+
+ def move(parent, node, idx)
+ tk_send('move', tagid(parent), tagid(node), idx)
+ self
+ end
+
+ def get_node(node, idx)
+ Tk::BWidget::Tree::Node.id2obj(self, tk_send('nodes', tagid(node), idx))
+ end
+
+ def nodes(node, first=None, last=None)
+ simplelist(tk_send('nodes', tagid(node), first, last)).collect{|node|
+ Tk::BWidget::Tree::Node.id2obj(self, node)
+ }
+ end
+
+ def open?(node)
+ bool(self.itemcget(tagid(node), 'open'))
+ end
+
+ def open_tree(node, recurse=None)
+ tk_send('opentree', tagid(node), recurse)
+ self
+ end
+
+ def parent(node)
+ Tk::BWidget::Tree::Node.id2obj(self, tk_send('parent', tagid(node)))
+ end
+
+ def reorder(node, neworder)
+ tk_send('reorder', tagid(node), neworder)
+ self
+ end
+
+ def see(node)
+ tk_send('see', tagid(node))
+ self
+ end
+
+ def selection_add(*args)
+ tk_send_without_enc('selection', 'add',
+ *(args.collect{|node| tagid(node)}))
+ self
+ end
+
+ def selection_clear
+ tk_send_without_enc('selection', 'clear')
+ self
+ end
+
+ def selection_get
+ list(tk_send_without_enc('selection', 'get'))
+ end
+
+ def selection_include?(*args)
+ bool(tk_send_without_enc('selection', 'get',
+ *(args.collect{|node| tagid(node)})))
+ end
+
+ def selection_range(*args)
+ tk_send_without_enc('selection', 'range',
+ *(args.collect{|node| tagid(node)}))
+ self
+ end
+
+ def selection_remove(*args)
+ tk_send_without_enc('selection', 'remove',
+ *(args.collect{|node| tagid(node)}))
+ self
+ end
+
+ def selection_set(*args)
+ tk_send_without_enc('selection', 'set',
+ *(args.collect{|node| tagid(node)}))
+ self
+ end
+
+ def selection_toggle(*args)
+ tk_send_without_enc('selection', 'toggle',
+ *(args.collect{|node| tagid(node)}))
+ self
+ end
+
+ def toggle(node)
+ tk_send_without_enc('toggle', tagid(node))
+ self
+ end
+
+ def visible(node)
+ bool(tk_send_without_enc('visible', tagid(node)))
+ end
+end
+
+class Tk::BWidget::Tree::Node
+ include TkTreatTagFont
+
+ TreeNode_TBL = TkCore::INTERP.create_table
+
+ (TreeNode_ID = ['bw:node'.freeze, TkUtil.untrust('00000')]).instance_eval{
+ @mutex = Mutex.new
+ def mutex; @mutex; end
+ freeze
+ }
+
+ TkCore::INTERP.init_ip_env{
+ TreeNode_TBL.mutex.synchronize{ TreeNode_TBL.clear }
+ }
+
+ def self.id2obj(tree, id)
+ tpath = tree.path
+ TreeNode_TBL.mutex.synchronize{
+ if TreeNode_TBL[tpath]
+ TreeNode_TBL[tpath][id]? TreeNode_TBL[tpath][id]: id
+ else
+ id
+ end
+ }
+ end
+
+ def initialize(tree, *args)
+ if tree.kind_of?(Tk::BWidget::Tree)
+ @tree = tree
+ parent = args.shift
+ if parent.kind_of?(Tk::BWidget::Tree::Node)
+ if parent.tree.path != @tree.path
+ fail RuntimeError, 'tree of parent node is not match'
+ end
+ end
+ elsif tree.kind_of?(Tk::BWidget::Tree::Node)
+ @tree = tree.tree
+ parent = tree.parent
+ else
+ fail RuntimeError,
+ "expect Tk::BWidget::Tree or Tk::BWidget::Tree::Node for 1st argument"
+ end
+
+ if args[-1].kind_of?(Hash)
+ keys = _symbolkey2str(args.pop)
+ else
+ keys = {}
+ end
+
+ index = keys.delete('index')
+ unless args.empty?
+ index = args.shift
+ end
+ index = 'end' unless index
+
+ unless args.empty?
+ fail RuntimeError, 'too much arguments'
+ end
+
+ @tpath = @tree.path
+
+ if keys.key?('nodename')
+ @path = @id = keys.delete('nodename')
+ else
+ TreeNode_ID.mutex.synchronize{
+ @path = @id = TreeNode_ID.join(TkCore::INTERP._ip_id_)
+ TreeNode_ID[1].succ!
+ }
+ end
+
+ TreeNode_TBL.mutex.synchronize{
+ TreeNode_TBL[@id] = self
+ TreeNode_TBL[@tpath] = {} unless TreeNode_TBL[@tpath]
+ TreeNode_TBL[@tpath][@id] = self
+ }
+
+ @tree.insert(index, parent, @id, keys)
+ end
+
+ def tree
+ @tree
+ end
+
+ def id
+ @id
+ end
+
+ def [](key)
+ cget(key)
+ end
+
+ def []=(key, val)
+ configure(key, val)
+ val
+ end
+
+ def cget_tkstring(key)
+ @tree.itemcget_tkstring(@id, key)
+ end
+ def cget(key)
+ @tree.itemcget(@id, key)
+ end
+ def cget_strict(key)
+ @tree.itemcget_strict(@id, key)
+ end
+
+ def configure(key, val=None)
+ @tree.itemconfigure(@id, key, val)
+ end
+
+ def configinfo(key=nil)
+ @tree.itemconfiginfo(@id, key)
+ end
+
+ def current_configinfo(key=nil)
+ @tree.current_itemconfiginfo(@id, key)
+ end
+
+ def close_tree(recurse=None)
+ @tree.close_tree(@id, recurse)
+ self
+ end
+
+ def delete
+ @tree.delete(@id)
+ self
+ end
+
+ def edit(*args)
+ @tree.edit(@id, *args)
+ self
+ end
+
+ def exist?
+ @tree.exist?(@id)
+ end
+
+ def index
+ @tree.index(@id)
+ end
+
+ def move(index, parent=nil)
+ if parent
+ @tree.move(parent, @id, index)
+ else
+ @tree.move(self.parent, @id, index)
+ end
+ end
+
+ def open_tree(recurse=None)
+ @tree.open_tree(@id, recurse)
+ self
+ end
+
+ def open?
+ bool(@tree.itemcget(@id, 'open'))
+ end
+
+ def parent
+ @tree.parent(@id)
+ end
+
+ def reorder(neworder)
+ @tree.reorder(@id, neworder)
+ end
+
+ def see
+ @tree.see(@id)
+ end
+
+ def selection_add
+ @tree.selection_add(@id)
+ end
+
+ def selection_remove
+ @tree.selection_remove(@id)
+ end
+
+ def selection_set
+ @tree.selection_set(@id)
+ end
+
+ def selection_toggle
+ @tree.selection_toggle(@id)
+ end
+
+ def toggle
+ @tree.toggle(@id)
+ end
+
+ def visible
+ @tree.visible(@id)
+ end
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/bwidget/widget.rb b/jni/ruby/ext/tk/lib/tkextlib/bwidget/widget.rb
new file mode 100644
index 0000000..a93364b
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/bwidget/widget.rb
@@ -0,0 +1,129 @@
+#
+# tkextlib/bwidget/widget.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+
+require 'tk'
+require 'tkextlib/bwidget.rb'
+
+module Tk
+ module BWidget
+ module Widget
+ end
+ end
+end
+
+module Tk::BWidget::Widget
+ include Tk
+ extend Tk
+
+ def self.__pathname
+ 'Widget::configure'
+ end
+
+ def self.__cget_cmd
+ ['Widget::cget']
+ end
+
+ def self.__config_cmd
+ ['Widget::configure']
+ end
+
+ def self.cget_strict(slot)
+ slot = slot.to_s
+ info = {}
+ self.current_configinfo.each{|k,v| info[k.to_s] = v if k.to_s == slot}
+ fail RuntimeError, "unknown option \"-#{slot}\"" if info.empty?
+ info.values[0]
+ end
+ def self.cget(slot)
+ self.current_configinfo(slot).values[0]
+ end
+
+ def self.add_map(klass, subclass, subpath, opts)
+ tk_call('Widget::addmap', klass, subclass, subpath, opts)
+ end
+
+ def self.bwinclude(klass, subclass, subpath, *args)
+ tk_call('Widget::bwinclude', klass, subclass, subpath, *args)
+ end
+
+ def self.create(klass, path, rename=None, &b)
+ win = window(tk_call('Widget::create', klass, path, rename))
+ if b
+ if TkCore::WITH_RUBY_VM ### Ruby 1.9 !!!!
+ win.instance_exec(self, &b)
+ else
+ win.instance_eval(&b)
+ end
+ end
+ win
+ end
+
+ def self.declare(klass, optlist)
+ tk_call('Widget::declare', klass, optlist)
+ end
+
+ def self.define(klass, filename, *args)
+ tk_call('Widget::define', klass, filename, *args)
+ end
+
+ def self.destroy(win)
+ tk_call('Widget::destroy', _epath(win))
+ end
+
+ def self.focus_next(win)
+ tk_call('Widget::focusNext', win)
+ end
+
+ def self.focus_ok(win)
+ tk_call('Widget::focusOk', win)
+ end
+
+ def self.focus_prev(win)
+ tk_call('Widget::focusPrev', win)
+ end
+
+ def self.generate_doc(dir, widgetlist)
+ tk_call('Widget::generate-doc', dir, widgetlist)
+ end
+
+ def self.generate_widget_doc(klass, iscmd, file)
+ tk_call('Widget::generate-widget-doc', klass, iscmd, file)
+ end
+
+ def self.get_option(win, option)
+ tk_call('Widget::getoption', win, option)
+ end
+
+ def self.get_variable(win, varname, my_varname=None)
+ tk_call('Widget::getVariable', win, varname, my_varname)
+ end
+
+ def self.has_changed(win, option, pvalue)
+ tk_call('Widget::hasChanged', win, option, pvalue)
+ end
+
+ def self.init(klass, win, options)
+ tk_call('Widget::init', klass, win, options)
+ end
+
+ def self.set_option(win, option, value)
+ tk_call('Widget::setoption', win, option, value)
+ end
+
+ def self.sub_cget_strict(win, subwidget)
+ tk_call('Widget::subcget', win, subwidget)
+ end
+ def self.sub_cget(win, subwidget)
+ self.sub_cget_strict(win, subwidget)
+ end
+
+ def self.sync_options(klass, subclass, subpath, options)
+ tk_call('Widget::syncoptions', klass, subclass, subpath, options)
+ end
+
+ def self.tkinclude(klass, tkwidget, subpath, *args)
+ tk_call('Widget::tkinclude', klass, tkwidget, subpath, *args)
+ end
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/itcl.rb b/jni/ruby/ext/tk/lib/tkextlib/itcl.rb
new file mode 100644
index 0000000..1d6ecf0
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/itcl.rb
@@ -0,0 +1,13 @@
+#
+# [incr Tcl] support
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+
+# call setup script for general 'tkextlib' libraries
+require 'tkextlib/setup.rb'
+
+# call setup script
+require 'tkextlib/itcl/setup.rb'
+
+# load library
+require 'tkextlib/itcl/incr_tcl.rb'
diff --git a/jni/ruby/ext/tk/lib/tkextlib/itcl/incr_tcl.rb b/jni/ruby/ext/tk/lib/tkextlib/itcl/incr_tcl.rb
new file mode 100644
index 0000000..8f6bb33
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/itcl/incr_tcl.rb
@@ -0,0 +1,178 @@
+#
+# tkextlib/itk/incr_tcl.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+
+require 'tk'
+
+# call setup script
+require 'tkextlib/itcl.rb'
+
+# TkPackage.require('Itcl', '3.2')
+TkPackage.require('Itcl')
+
+module Tk
+ module Itcl
+ include Tk
+ extend Tk
+
+ LIBRARY = TkVarAccess.new('::itcl::library')
+ PURIST = TkVarAccess.new('::itcl::purist')
+
+ VERSION = TkCore::INTERP._invoke("set", "::itcl::version").freeze
+ PATCHLEVEL = TkCore::INTERP._invoke("set", "::itcl::patchLevel").freeze
+
+ PACKAGE_NAME = 'Itcl'.freeze
+ def self.package_name
+ PACKAGE_NAME
+ end
+
+ def self.package_version
+ begin
+ TkPackage.require('Itcl')
+ rescue
+ ''
+ end
+ end
+
+ ##############################################
+
+ class ItclObject < TkObject
+ ITCL_CLASSNAME = ''.freeze
+
+ (ITCL_OBJ_ID = ['itclobj'.freeze, TkUtil.untrust('00000')]).instance_eval{
+ @mutex = Mutex.new
+ def mutex; @mutex; end
+ freeze
+ }
+ ITCL_OBJ_TBL = TkUtil.untrust({})
+
+ def initialize(*args)
+ if (@klass = self.class::ITCL_CLASSNAME).empty?
+ fail RuntimeError, 'unknown itcl class (abstract class?)'
+ end
+ Tk::Itcl::ItclObject::ITCL_OBJ_ID.mutex.synchronize{
+ @id = Tk::Itcl::ItclObject::TCL_OBJ_ID.join(TkCore::INTERP._ip_id_)
+ Tk::Itcl::ItclObject::ITCL_OBJ_ID[1].succ!
+ }
+ @path = @id
+ end
+
+ def self.call_proc(name, *args)
+ tk_call("#{ITCL_CLASSNAME}::#{cmd}", *args)
+ end
+
+ def call_method(name, *args)
+ tk_call(@path, name, *args)
+ end
+
+ def isa(klass)
+ bool(tk_call(@path, 'isa', klass))
+ end
+ alias itcl_kind_of? isa
+
+ def info_class
+ tk_call(@path, 'info', 'class')
+ end
+
+ def info_inherit
+ simplelist(tk_call(@path, 'info', 'inherit'))
+ end
+
+ def info_heritage
+ list(tk_call(@path, 'info', 'heritage'))
+ end
+
+ def info_function(*args)
+ if args[-1].kind_of?(Array)
+ params = args.pop
+ params.each{|param|
+ param = param.to_s
+ args << ( (param[0] == ?-)? param: "-#{param}" )
+ }
+ end
+ list(tk_call(@path, 'info', 'function', *args))
+ end
+
+ def info_variable(*args)
+ if args[-1].kind_of?(Array)
+ params = args.pop
+ params.each{|param|
+ param = param.to_s
+ args << ( (param[0] == ?-)? param: "-#{param}" )
+ }
+ end
+ list(tk_call(@path, 'info', 'variable', *args))
+ end
+ end
+
+ ##############################################
+
+ def self.body(klass, func, args, body)
+ tk_call('::itcl::body', "#{klass}::#{func}", args, body)
+ end
+
+ def self.code(cmd, *args)
+ tk_call('::itcl::code', cmd, *args)
+ end
+
+ def self.code_in_namespace(namespace, cmd, *args)
+ tk_call('::itcl::code', '-namespace', namespace, cmd, *args)
+ end
+
+ def self.configbody(klass, var, body)
+ tk_call('::itcl::configbody', "#{klass}::#{var}", body)
+ end
+
+ def self.create_itcl_class(name, body)
+ TkCore::INTERP._invoke('::itcl::class', name, body)
+ klass = Class.new(Tk::Itcl::ItclObject)
+ klass.const_set('ITCL_CLASSNAME', name.dup.freeze)
+ klass
+ end
+
+ def self.delete_itcl_class(*names)
+ tk_call('::itcl::delete', 'class', *names)
+ end
+
+ def self.delete_itcl_object(*names)
+ tk_call('::itcl::delete', 'object', *names)
+ end
+
+ def self.delete_namespace(*names)
+ tk_call('::itcl::delete', 'namespace', *names)
+ end
+
+ def self.ensemble(name, *args)
+ tk_call('::itcl::ensemble', name, *args)
+ end
+
+ def self.find_classes(pat=None)
+ simplelist(tk_call('::itcl::find', 'classes', pat))
+ end
+
+ def self.find_objects(*args)
+ simplelist(tk_call('::itcl::find', 'objects', *args))
+ end
+
+ def self.is_itcl_class(target)
+ bool(tk_call('::itcl::is', 'class', target))
+ end
+
+ def self.is_itcl_object(target)
+ bool(tk_call('::itcl::is', 'object', target))
+ end
+
+ def self.create_local_obj(klass, name, *args)
+ tk_call('::itcl::local', klass, name, *args)
+ end
+
+ def self.is_itcl_instance(klass, target)
+ bool(tk_call('::itcl::is', 'object', '-class', klass, target))
+ end
+
+ def self.scope(var)
+ tk_call('::itcl::scope', var)
+ end
+ end
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/itcl/setup.rb b/jni/ruby/ext/tk/lib/tkextlib/itcl/setup.rb
new file mode 100644
index 0000000..70b38e4
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/itcl/setup.rb
@@ -0,0 +1,13 @@
+#
+# setup.rb -- setup script before calling TkPackage.require()
+#
+# If you need some setup operations (for example, add a library path
+# to the library search path) before using Tcl/Tk library packages
+# wrapped by Ruby scripts in this directory, please write the setup
+# operations in this file.
+#
+
+
+# set [incr Tcl] library directory
+
+# ENV['ITCL_LIBRARY'] = '/usr/local/ActiveTcl/lib/itcl3.2/'
diff --git a/jni/ruby/ext/tk/lib/tkextlib/itk.rb b/jni/ruby/ext/tk/lib/tkextlib/itk.rb
new file mode 100644
index 0000000..7492bd3
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/itk.rb
@@ -0,0 +1,13 @@
+#
+# [incr Tk] support
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+
+# call setup script for general 'tkextlib' libraries
+require 'tkextlib/setup.rb'
+
+# call setup script
+require 'tkextlib/itk/setup.rb'
+
+# load library
+require 'tkextlib/itk/incr_tk.rb'
diff --git a/jni/ruby/ext/tk/lib/tkextlib/itk/incr_tk.rb b/jni/ruby/ext/tk/lib/tkextlib/itk/incr_tk.rb
new file mode 100644
index 0000000..989585e
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/itk/incr_tk.rb
@@ -0,0 +1,446 @@
+#
+# tkextlib/itk/incr_tk.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+
+require 'tk'
+require 'tk/menuspec'
+require 'tkextlib/itcl.rb'
+
+# call setup script
+require 'tkextlib/itk.rb'
+
+#TkPackage.require('Itk', '3.2')
+TkPackage.require('Itk')
+
+module Tk
+ module Itk
+ include Tk
+ extend Tk
+
+ LIBRARY = TkVarAccess.new('::itk::library')
+
+ PACKAGE_NAME = 'Itk'.freeze
+ def self.package_name
+ PACKAGE_NAME
+ end
+
+ def self.package_version
+ begin
+ TkPackage.require('Itk')
+ rescue
+ ''
+ end
+ end
+
+ def self.usual(arg, *args)
+ tk_call('::itk::usual', arg, *args)
+ end
+
+ def self.usual_names
+ list(tk_call('::itk::usual'))
+ end
+
+ ############################
+
+ class Archetype < TkWindow
+ TkCommandNames = [].freeze
+ # WidgetClassName = 'Archetype'.freeze
+ # WidgetClassNames[WidgetClassName] = self
+
+ def self.to_eval
+ '::itk::' << self::WidgetClassName
+ end
+
+ def __destroy_hook__
+ Tk::Itk::Component::ComponentID_TBL.delete(self.path)
+ end
+
+ #### [incr Tk] public methods
+ def component
+ simplelist(tk_send('component'))
+ end
+
+ def component_path(name)
+ window(tk_send('component', name))
+ end
+ alias component_widget component_path
+
+ def component_invoke(name, cmd, *args)
+ window(tk_send('component', name, cmd, *args))
+ end
+
+ def component_obj(*names)
+ names = component if names.empty?
+ names.collect{|name| Tk::Itk::Component.new(self.path, name) }
+ end
+
+ #### [incr Tk] protected methods
+=begin
+ def itk_component_add(visibility, name, create_cmds, option_cmds=None)
+ args = []
+ visibility.each{|v| v = v.to_s; args << ( (v[0] == ?-)? v: "-#{v}" )}
+ args << '--' << name << create_cmd << option_cmds
+ tk_call('itk_component', 'add', *args)
+ end
+
+ def itk_component_delete(*names)
+ tk_call('itk_component', 'delete', *names)
+ end
+
+ def itk_initialize(keys={})
+ tk_call('itk_initialize', keys)
+ end
+
+ def itk_option_add(*args)
+ tk_call('itk_option', 'add', *args)
+ end
+
+ def itk_option_define(name, resource, klass, init, config=None)
+ tk_call('itk_option', 'define', name, resource, klass, init, config)
+ end
+
+ def itk_option_remove(*args)
+ tk_call('itk_option', 'remove', *args)
+ end
+=end
+ end
+
+ ############################
+
+ class Toplevel < Archetype
+ TkCommandNames = ['::itk::Toplevel'].freeze
+ WidgetClassName = 'Toplevel'.freeze
+ WidgetClassNames[WidgetClassName] ||= self
+
+ include Wm
+ include TkMenuSpec
+
+ def __strval_optkeys
+ super() << 'title'
+ end
+ private :__strval_optkeys
+ end
+
+ ############################
+
+ class Widget < Archetype
+ TkCommandNames = ['::itk::Widget'].freeze
+ WidgetClassName = 'Widget'.freeze
+ WidgetClassNames[WidgetClassName] ||= self
+ end
+
+
+ ############################
+
+ class Component < TkObject
+ def __cget_cmd
+ [self.master, 'component', self.name, 'cget']
+ end
+ private :__cget_cmd
+
+ def __config_cmd
+ [self.master, 'component', self.name, 'configure']
+ end
+ private :__config_cmd
+
+ ComponentID_TBL = TkCore::INTERP.create_table
+
+ (Itk_Component_ID = ['itk:component'.freeze, TkUtil.untrust('00000')]).instance_eval{
+ @mutex = Mutex.new
+ def mutex; @mutex; end
+ freeze
+ }
+
+ TkCore::INTERP.init_ip_env{
+ ComponentID_TBL.mutex.synchronize{ ComponentID_TBL.clear }
+ }
+
+ def self.id2obj(master, id)
+ if master.kind_of?(TkObject)
+ master = master.path
+ else
+ master = master.to_s
+ end
+ ComponentID_TBL.mutex.synchronize{
+ if ComponentID_TBL.key?(master)
+ (ComponentID_TBL[master].key?(id))? ComponentID_TBL[master][id]: id
+ else
+ id
+ end
+ }
+ end
+
+ def self.new(master, component=nil)
+ if master.kind_of?(TkObject)
+ master = master.path
+ else
+ master = master.to_s
+ end
+
+ if component.kind_of?(Tk::Itk::Component)
+ component = component.name
+ elsif component
+ component = component.to_s
+ else
+ Itk_Component_ID.mutex.synchronize{
+ component = Itk_Component_ID.join(TkCore::INTERP._ip_id_)
+ Itk_Component_ID[1].succ!
+ }
+ end
+
+ ComponentID_TBL.mutex.synchronize{
+ if ComponentID_TBL.key?(master)
+ if ComponentID_TBL[master].key?(component)
+ return ComponentID_TBL[master][component]
+ end
+ else
+ ComponentID_TBL[master] = {}
+ end
+ }
+
+ super(master, component)
+ end
+
+ def initialize(master, component)
+ @master = master
+ @component = component
+
+ ComponentID_TBL.mutex.synchronize{
+ ComponentID_TBL[@master][@component] = self
+ }
+
+ begin
+ @widget = window(tk_call(@master, 'component', @component))
+ @path = @widget.path
+ rescue
+ @widget = nil
+ @path = nil
+ end
+ end
+
+ def path
+ unless @path
+ begin
+ @widget = window(tk_call(@master, 'component', @component))
+ @path = @widget.path
+ rescue
+ fail RuntimeError, 'component is not assigned to a widget'
+ end
+ end
+ @path
+ end
+
+ def epath
+ path()
+ end
+
+ def to_eval
+ path()
+ end
+
+ def master
+ @master
+ end
+
+ def name
+ @component
+ end
+
+ def widget
+ unless @widget
+ begin
+ @widget = window(tk_call(@master, 'component', @component))
+ @path = @widget.path
+ rescue
+ fail RuntimeError, 'component is not assigned to a widget'
+ end
+ end
+ @widget
+ end
+
+ def widget_class
+ unless @widget
+ begin
+ @widget = window(tk_call(@master, 'component', @component))
+ @path = @widget.path
+ @widget.classname
+ rescue
+ nil
+ end
+ end
+ end
+
+ def method_missing(id, *args)
+ name = id.id2name
+
+ # try 1 : component command
+ begin
+ return tk_call(@master, 'component', @component, name, *args)
+ rescue
+ end
+
+ # try 2 : component configure
+ len = args.length
+ begin
+ case len
+ when 1
+ if name[-1] == ?=
+ return configure(name[0..-2], args[0])
+ else
+ return configure(name, args[0])
+ end
+ when 0
+ return cget(name)
+ end
+ rescue
+ end
+
+ # try 3 : widget method or widget configure
+ begin
+ unless @widget
+ @widget = window(tk_call(@master, 'component', @component))
+ @path = @widget.path
+ end
+ @widget.__send__(id, *args)
+ rescue
+ end
+
+ # unknown method
+ super(id, *args)
+ # fail RuntimeError, "unknown method '#{name}' for #{self.inspect}"
+ end
+
+ def tk_send(cmd, *rest)
+ begin
+ tk_call(@master, 'component', @component, cmd, *rest)
+ rescue
+ unless @path
+ begin
+ @widget = window(tk_call(@master, 'component', @component))
+ @path = @widget.path
+ rescue
+ fail RuntimeError, 'component is not assigned to a widget'
+ end
+ end
+ tk_call(@path, cmd, *rest)
+ end
+ end
+
+ def tk_send_without_enc(cmd, *rest)
+ begin
+ tk_call_without_enc(@master, 'component', @component, cmd, *rest)
+ rescue
+ unless @path
+ begin
+ @widget = window(tk_call(@master, 'component', @component))
+ @path = @widget.path
+ rescue
+ fail RuntimeError, 'component is not assigned to a widget'
+ end
+ end
+ tk_call_without_enc(@path, cmd, *rest)
+ end
+ end
+
+ def tk_send_with_enc(cmd, *rest)
+ begin
+ tk_call_with_enc(@master, 'component', @component, cmd, *rest)
+ rescue
+ unless @path
+ begin
+ @widget = window(tk_call(@master, 'component', @component))
+ @path = @widget.path
+ rescue
+ fail RuntimeError, 'component is not assigned to a widget'
+ end
+ end
+ tk_call_with_enc(@path, cmd, *rest)
+ end
+ end
+
+ #def bind(*args)
+ # unless @widget
+ # begin
+ # @widget = window(tk_call(@master, 'component', @component))
+ # @path = @widget.path
+ # rescue
+ # fail RuntimeError, 'component is not assigned to a widget'
+ # end
+ # end
+ # @widget.bind(*args)
+ #end
+ def bind(context, *args)
+ unless @widget
+ begin
+ @widget = window(tk_call(@master, 'component', @component))
+ @path = @widget.path
+ rescue
+ fail RuntimeError, 'component is not assigned to a widget'
+ end
+ end
+ # if args[0].kind_of?(Proc) || args[0].kind_of?(Method)
+ if TkComm._callback_entry?(args[0]) || !block_given?
+ cmd = args.shift
+ else
+ cmd = Proc.new
+ end
+ @widget.bind(context, cmd, *args)
+ end
+
+ #def bind_append(*args)
+ # unless @widget
+ # begin
+ # @widget = window(tk_call(@master, 'component', @component))
+ # @path = @widget.path
+ # rescue
+ # fail RuntimeError, 'component is not assigned to a widget'
+ # end
+ # end
+ # @widget.bind_append(*args)
+ #end
+ def bind_append(context, *args)
+ unless @widget
+ begin
+ @widget = window(tk_call(@master, 'component', @component))
+ @path = @widget.path
+ rescue
+ fail RuntimeError, 'component is not assigned to a widget'
+ end
+ end
+ # if args[0].kind_of?(Proc) || args[0].kind_of?(Method)
+ if TkComm._callback_entry?(args[0]) || !block_given?
+ cmd = args.shift
+ else
+ cmd = Proc.new
+ end
+ @widget.bind_append(context, cmd, *args)
+ end
+
+ def bind_remove(*args)
+ unless @widget
+ begin
+ @widget = window(tk_call(@master, 'component', @component))
+ @path = @widget.path
+ rescue
+ fail RuntimeError, 'component is not assigned to a widget'
+ end
+ end
+ @widget.bind_remove(*args)
+ end
+
+ def bindinfo(*args)
+ unless @widget
+ begin
+ @widget = window(tk_call(@master, 'component', @component))
+ @path = @widget.path
+ rescue
+ fail RuntimeError, 'component is not assigned to a widget'
+ end
+ end
+ @widget.bindinfo(*args)
+ end
+
+ end
+ end
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/itk/setup.rb b/jni/ruby/ext/tk/lib/tkextlib/itk/setup.rb
new file mode 100644
index 0000000..544926e
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/itk/setup.rb
@@ -0,0 +1,13 @@
+#
+# setup.rb -- setup script before calling TkPackage.require()
+#
+# If you need some setup operations (for example, add a library path
+# to the library search path) before using Tcl/Tk library packages
+# wrapped by Ruby scripts in this directory, please write the setup
+# operations in this file.
+#
+
+
+# set [incr Tk] library directory
+
+# ENV['ITK_LIBRARY'] = '/usr/local/ActiveTcl/lib/itk3.2/'
diff --git a/jni/ruby/ext/tk/lib/tkextlib/iwidgets.rb b/jni/ruby/ext/tk/lib/tkextlib/iwidgets.rb
new file mode 100644
index 0000000..ebd4cf7
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/iwidgets.rb
@@ -0,0 +1,94 @@
+#
+# [incr Widgets] support
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+
+require 'tk'
+require 'tkextlib/itcl'
+require 'tkextlib/itk'
+
+# call setup script for general 'tkextlib' libraries
+#require 'tkextlib/setup.rb'
+
+# call setup script
+#require 'tkextlib/iwidgets/setup.rb'
+
+# load all image format handlers
+#TkPackage.require('Iwidgets', '4.0')
+TkPackage.require('Iwidgets')
+
+module Tk
+ module Iwidgets
+ TkComm::TkExtlibAutoloadModule.unshift(self)
+
+ extend TkCore
+
+ PACKAGE_NAME = 'Iwidgets'.freeze
+ def self.package_name
+ PACKAGE_NAME
+ end
+
+ def self.package_version
+ begin
+ TkPackage.require('Iwidgets')
+ rescue
+ ''
+ end
+ end
+
+ ####################################################
+
+ autoload :Buttonbox, 'tkextlib/iwidgets/buttonbox'
+ autoload :Calendar, 'tkextlib/iwidgets/calendar'
+ autoload :Canvasprintbox, 'tkextlib/iwidgets/canvasprintbox'
+ autoload :Canvasprintdialog, 'tkextlib/iwidgets/canvasprintdialog'
+ autoload :Checkbox, 'tkextlib/iwidgets/checkbox'
+ autoload :Combobox, 'tkextlib/iwidgets/combobox'
+ autoload :Dateentry, 'tkextlib/iwidgets/dateentry'
+ autoload :Datefield, 'tkextlib/iwidgets/datefield'
+ autoload :Dialog, 'tkextlib/iwidgets/dialog'
+ autoload :Dialogshell, 'tkextlib/iwidgets/dialogshell'
+ autoload :Disjointlistbox, 'tkextlib/iwidgets/disjointlistbox'
+ autoload :Entryfield, 'tkextlib/iwidgets/entryfield'
+ autoload :Extbutton, 'tkextlib/iwidgets/extbutton'
+ autoload :Extfileselectionbox, 'tkextlib/iwidgets/extfileselectionbox'
+ autoload :Extfileselectiondialog,'tkextlib/iwidgets/extfileselectiondialog'
+ autoload :Feedback, 'tkextlib/iwidgets/feedback'
+ autoload :Fileselectionbox, 'tkextlib/iwidgets/fileselectionbox'
+ autoload :Fileselectiondialog, 'tkextlib/iwidgets/fileselectiondialog'
+ autoload :Finddialog, 'tkextlib/iwidgets/finddialog'
+ autoload :Hierarchy, 'tkextlib/iwidgets/hierarchy'
+ autoload :Hyperhelp, 'tkextlib/iwidgets/hyperhelp'
+ autoload :Labeledframe, 'tkextlib/iwidgets/labeledframe'
+ autoload :Labeledwidget, 'tkextlib/iwidgets/labeledwidget'
+ autoload :Mainwindow, 'tkextlib/iwidgets/mainwindow'
+ autoload :Menubar, 'tkextlib/iwidgets/menubar'
+ autoload :Messagebox, 'tkextlib/iwidgets/messagebox'
+ autoload :Messagedialog, 'tkextlib/iwidgets/messagedialog'
+ autoload :Notebook, 'tkextlib/iwidgets/notebook'
+ autoload :Optionmenu, 'tkextlib/iwidgets/optionmenu'
+ autoload :Panedwindow, 'tkextlib/iwidgets/panedwindow'
+ autoload :Pushbutton, 'tkextlib/iwidgets/pushbutton'
+ autoload :Promptdialog, 'tkextlib/iwidgets/promptdialog'
+ autoload :Radiobox, 'tkextlib/iwidgets/radiobox'
+ autoload :Scrolledcanvas, 'tkextlib/iwidgets/scrolledcanvas'
+ autoload :Scrolledframe, 'tkextlib/iwidgets/scrolledframe'
+ autoload :Scrolledhtml, 'tkextlib/iwidgets/scrolledhtml'
+ autoload :Scrolledlistbox, 'tkextlib/iwidgets/scrolledlistbox'
+ autoload :Scrolledtext, 'tkextlib/iwidgets/scrolledtext'
+ autoload :Scrolledwidget, 'tkextlib/iwidgets/scrolledwidget'
+ autoload :Selectionbox, 'tkextlib/iwidgets/selectionbox'
+ autoload :Selectiondialog, 'tkextlib/iwidgets/selectiondialog'
+ autoload :Shell, 'tkextlib/iwidgets/shell'
+ autoload :Spindate, 'tkextlib/iwidgets/spindate'
+ autoload :Spinint, 'tkextlib/iwidgets/spinint'
+ autoload :Spinner, 'tkextlib/iwidgets/spinner'
+ autoload :Spintime, 'tkextlib/iwidgets/spintime'
+ autoload :Tabnotebook, 'tkextlib/iwidgets/tabnotebook'
+ autoload :Tabset, 'tkextlib/iwidgets/tabset'
+ autoload :Timeentry, 'tkextlib/iwidgets/timeentry'
+ autoload :Timefield, 'tkextlib/iwidgets/timefield'
+ autoload :Toolbar, 'tkextlib/iwidgets/toolbar'
+ autoload :Watch, 'tkextlib/iwidgets/watch'
+ end
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/iwidgets/buttonbox.rb b/jni/ruby/ext/tk/lib/tkextlib/iwidgets/buttonbox.rb
new file mode 100644
index 0000000..91e06d1
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/iwidgets/buttonbox.rb
@@ -0,0 +1,121 @@
+#
+# tkextlib/iwidgets/buttonbox.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+
+require 'tk'
+require 'tkextlib/iwidgets.rb'
+
+module Tk
+ module Iwidgets
+ class Buttonbox < Tk::Itk::Widget
+ end
+ end
+end
+
+class Tk::Iwidgets::Buttonbox
+ TkCommandNames = ['::iwidgets::buttonbox'.freeze].freeze
+ WidgetClassName = 'Buttonbox'.freeze
+ WidgetClassNames[WidgetClassName] ||= self
+
+ ####################################
+
+ include TkItemConfigMethod
+
+ def __item_cget_cmd(id)
+ [self.path, 'buttoncget', id]
+ end
+ private :__item_cget_cmd
+
+ def __item_config_cmd(id)
+ [self.path, 'buttonconfigure', id]
+ end
+ private :__item_config_cmd
+
+ def __item_boolval_optkeys(id)
+ super(id) << 'defaultring'
+ end
+ private :__item_boolval_optkeys
+
+ def tagid(tagOrId)
+ if tagOrId.kind_of?(Tk::Itk::Component)
+ tagOrId.name
+ else
+ #_get_eval_string(tagOrId)
+ tagOrId
+ end
+ end
+
+ alias buttoncget_tkstring itemcget_tkstring
+ alias buttoncget itemcget
+ alias buttoncget_strict itemcget_strict
+ alias buttonconfigure itemconfigure
+ alias buttonconfiginfo itemconfiginfo
+ alias current_buttonconfiginfo current_itemconfiginfo
+
+ private :itemcget_tkstring, :itemcget, :itemcget_strict
+ private :itemconfigure, :itemconfiginfo, :current_itemconfiginfo
+
+ ####################################
+
+ def add(tag=nil, keys={})
+ if tag.kind_of?(Hash)
+ keys = tag
+ tag = nil
+ end
+ if tag
+ tag = Tk::Itk::Component.new(self, tagid(tag))
+ else
+ tag = Tk::Itk::Component.new(self)
+ end
+ tk_call(@path, 'add', tagid(tag), *hash_kv(keys))
+ tag
+ end
+
+ def default(idx)
+ tk_call(@path, 'default', index(idx))
+ self
+ end
+
+ def delete(idx)
+ tk_call(@path, 'delete', index(idx))
+ self
+ end
+
+ def hide(idx)
+ tk_call(@path, 'hide', index(idx))
+ self
+ end
+
+ def index(idx)
+ number(tk_call(@path, 'index', tagid(idx)))
+ end
+
+ def insert(idx, tag=nil, keys={})
+ if tag.kind_of?(Hash)
+ keys = tag
+ tag = nil
+ end
+ if tag
+ tag = Tk::Itk::Component.new(self, tagid(tag))
+ else
+ tag = Tk::Itk::Component.new(self)
+ end
+ tk_call(@path, 'insert', index(idx), tagid(tag), *hash_kv(keys))
+ tag
+ end
+
+ def invoke(idx=nil)
+ if idx
+ tk_call(@path, 'invoke', index(idx))
+ else
+ tk_call(@path, 'invoke')
+ end
+ self
+ end
+
+ def show(idx)
+ tk_call(@path, 'show', index(idx))
+ self
+ end
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/iwidgets/calendar.rb b/jni/ruby/ext/tk/lib/tkextlib/iwidgets/calendar.rb
new file mode 100644
index 0000000..a5478c7
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/iwidgets/calendar.rb
@@ -0,0 +1,125 @@
+#
+# tkextlib/iwidgets/calendar.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+
+require 'tk'
+require 'tkextlib/iwidgets.rb'
+
+module Tk
+ module Iwidgets
+ class Calendar < Tk::Itk::Widget
+ end
+ end
+end
+
+class Tk::Iwidgets::Calendar
+ TkCommandNames = ['::iwidgets::calendar'.freeze].freeze
+ WidgetClassName = 'Calendar'.freeze
+ WidgetClassNames[WidgetClassName] ||= self
+
+ def __strval_optkeys
+ super() + [
+ 'buttonforeground', 'outline', 'selectcolor',
+ 'weekdaybackground', 'weekendbackground'
+ ]
+ end
+ private :__strval_optkeys
+
+ def __listval_optkeys
+ super() << 'days'
+ end
+ private :__listval_optkeys
+
+ def __font_optkeys
+ super() + ['currentdatefont', 'datefont', 'dayfont', 'titlefont']
+ end
+ private :__font_optkeys
+
+ ####################################
+
+ include Tk::ValidateConfigure
+
+ class CalendarCommand < TkValidateCommand
+ #class CalCmdArgs < TkUtil::CallbackSubst
+ class ValidateArgs < TkUtil::CallbackSubst
+ KEY_TBL = [ [?d, ?s, :date], nil ]
+ PROC_TBL = [ [?s, TkComm.method(:string) ], nil ]
+
+=begin
+ # for Ruby m17n :: ?x --> String --> char-code ( getbyte(0) )
+ KEY_TBL.map!{|inf|
+ if inf.kind_of?(Array)
+ inf[0] = inf[0].getbyte(0) if inf[0].kind_of?(String)
+ inf[1] = inf[1].getbyte(0) if inf[1].kind_of?(String)
+ end
+ inf
+ }
+
+ PROC_TBL.map!{|inf|
+ if inf.kind_of?(Array)
+ inf[0] = inf[0].getbyte(0) if inf[0].kind_of?(String)
+ end
+ inf
+ }
+=end
+
+ _setup_subst_table(KEY_TBL, PROC_TBL);
+
+ def self.ret_val(val)
+ val
+ end
+ end
+
+ def self._config_keys
+ # array of config-option key (string or symbol)
+ ['command']
+ end
+
+ #def initialize(cmd = Proc.new, *args)
+ # _initialize_for_cb_class(CalCmdArgs, cmd, *args)
+ #end
+ end
+
+ def __validation_class_list
+ super() << CalendarCommand
+ end
+
+ Tk::ValidateConfigure.__def_validcmd(binding, CalendarCommand)
+=begin
+ def command(cmd = Proc.new, args = nil)
+ if cmd.kind_of?(CalendarCommand)
+ configure('command', cmd)
+ elsif args
+ configure('command', [cmd, args])
+ else
+ configure('command', cmd)
+ end
+ end
+=end
+
+ ####################################
+
+ def get_string
+ tk_call(@path, 'get', '-string')
+ end
+ alias get get_string
+
+ def get_clicks
+ number(tk_call(@path, 'get', '-clicks'))
+ end
+
+ def select(date)
+ tk_call(@path, 'select', date)
+ self
+ end
+
+ def show(date)
+ tk_call(@path, 'show', date)
+ self
+ end
+ def show_now
+ tk_call(@path, 'show', 'now')
+ self
+ end
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/iwidgets/canvasprintbox.rb b/jni/ruby/ext/tk/lib/tkextlib/iwidgets/canvasprintbox.rb
new file mode 100644
index 0000000..398eec3
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/iwidgets/canvasprintbox.rb
@@ -0,0 +1,53 @@
+#
+# tkextlib/iwidgets/canvasprintbox.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+
+require 'tk'
+require 'tkextlib/iwidgets.rb'
+
+module Tk
+ module Iwidgets
+ class Canvasprintbox < Tk::Itk::Widget
+ end
+ end
+end
+
+class Tk::Iwidgets::Canvasprintbox
+ TkCommandNames = ['::iwidgets::canvasprintbox'.freeze].freeze
+ WidgetClassName = 'Canvasprintbox'.freeze
+ WidgetClassNames[WidgetClassName] ||= self
+
+ def __strval_optkeys
+ super() << 'filename'
+ end
+ private :__strval_optkeys
+
+ def __boolval_optkeys
+ super() << 'stretch'
+ end
+ private :__boolval_optkeys
+
+ def get_output
+ tk_call(@path, 'getoutput')
+ end
+
+ def print
+ bool(tk_call(@path, 'print'))
+ end
+
+ def refresh
+ tk_call(@path, 'refresh')
+ self
+ end
+
+ def set_canvas(win)
+ tk_call(@path, 'setcanvas', win)
+ self
+ end
+
+ def stop
+ tk_call(@path, 'stop')
+ self
+ end
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/iwidgets/canvasprintdialog.rb b/jni/ruby/ext/tk/lib/tkextlib/iwidgets/canvasprintdialog.rb
new file mode 100644
index 0000000..e64d815
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/iwidgets/canvasprintdialog.rb
@@ -0,0 +1,38 @@
+#
+# tkextlib/iwidgets/canvasprintdialog.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+
+require 'tk'
+require 'tkextlib/iwidgets.rb'
+
+module Tk
+ module Iwidgets
+ class Canvasprintdialog < Tk::Iwidgets::Dialog
+ end
+ end
+end
+
+class Tk::Iwidgets::Canvasprintdialog
+ TkCommandNames = ['::iwidgets::canvasprintdialog'.freeze].freeze
+ WidgetClassName = 'Canvasprintdialog'.freeze
+ WidgetClassNames[WidgetClassName] ||= self
+
+ def get_output
+ tk_call(@path, 'getoutput')
+ end
+
+ def print
+ bool(tk_call(@path, 'print'))
+ end
+
+ def refresh
+ tk_call(@path, 'refresh')
+ self
+ end
+
+ def set_canvas(win)
+ tk_call(@path, 'setcanvas', win)
+ self
+ end
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/iwidgets/checkbox.rb b/jni/ruby/ext/tk/lib/tkextlib/iwidgets/checkbox.rb
new file mode 100644
index 0000000..a7476c8
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/iwidgets/checkbox.rb
@@ -0,0 +1,130 @@
+#
+# tkextlib/iwidgets/checkbox.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+
+require 'tk'
+require 'tkextlib/iwidgets.rb'
+
+module Tk
+ module Iwidgets
+ class Checkbox < Tk::Iwidgets::Labeledframe
+ end
+ end
+end
+
+class Tk::Iwidgets::Checkbox
+ TkCommandNames = ['::iwidgets::checkbox'.freeze].freeze
+ WidgetClassName = 'Checkbox'.freeze
+ WidgetClassNames[WidgetClassName] ||= self
+
+ ####################################
+
+ include TkItemConfigMethod
+
+ def __item_cget_cmd(id)
+ [self.path, 'buttoncget', id]
+ end
+ private :__item_cget_cmd
+
+ def __item_config_cmd(id)
+ [self.path, 'buttonconfigure', id]
+ end
+ private :__item_config_cmd
+
+ def __item_boolval_optkeys(id)
+ super(id) << 'defaultring'
+ end
+ private :__item_boolval_optkeys
+
+ def tagid(tagOrId)
+ if tagOrId.kind_of?(Tk::Itk::Component)
+ tagOrId.name
+ else
+ #_get_eval_string(tagOrId)
+ tagOrId
+ end
+ end
+
+ alias buttoncget_tkstring itemcget_tkstring
+ alias buttoncget itemcget
+ alias buttoncget_strict itemcget_strict
+ alias buttonconfigure itemconfigure
+ alias buttonconfiginfo itemconfiginfo
+ alias current_buttonconfiginfo current_itemconfiginfo
+
+ private :itemcget_tkstring, :itemcget, :itemcget_strict
+ private :itemconfigure, :itemconfiginfo, :current_itemconfiginfo
+
+ ####################################
+
+ def add(tag=nil, keys={})
+ if tag.kind_of?(Hash)
+ keys = tag
+ tag = nil
+ end
+ if tag
+ tag = Tk::Itk::Component.new(self, tagid(tag))
+ else
+ tag = Tk::Itk::Component.new(self)
+ end
+ tk_call(@path, 'add', tagid(tag), *hash_kv(keys))
+ tag
+ end
+
+ def delete(idx)
+ tk_call(@path, 'delete', index(idx))
+ self
+ end
+
+ def deselect(idx)
+ tk_call(@path, 'deselect', index(idx))
+ self
+ end
+
+ def flash(idx)
+ tk_call(@path, 'flash', index(idx))
+ self
+ end
+
+ def get_tags
+ simplelist(tk_call_without_enc(@path, 'get'))
+ end
+
+ def get_objs
+ simplelist(tk_call_without_enc(@path, 'get')).collect{|id|
+ Tk::Itk::Component.id2obj(self, id)
+ }
+ end
+
+ def get(idx=nil)
+ if idx
+ bool(tk_call_without_enc(@path, 'get', index(idx)))
+ else
+ get_tags
+ end
+ end
+
+ def index(idx)
+ number(tk_call(@path, 'index', tagid(idx)))
+ end
+
+ def insert(idx, tag=nil, keys={})
+ if tag.kind_of?(Hash)
+ keys = tag
+ tag = nil
+ end
+ if tag
+ tag = Tk::Itk::Component.new(self, tagid(tag))
+ else
+ tag = Tk::Itk::Component.new(self)
+ end
+ tk_call(@path, 'insert', index(idx), tagid(tag), *hash_kv(keys))
+ tag
+ end
+
+ def select(idx)
+ tk_call(@path, 'select', index(idx))
+ self
+ end
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/iwidgets/combobox.rb b/jni/ruby/ext/tk/lib/tkextlib/iwidgets/combobox.rb
new file mode 100644
index 0000000..82dcf25
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/iwidgets/combobox.rb
@@ -0,0 +1,104 @@
+#
+# tkextlib/iwidgets/combobox.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+
+require 'tk'
+require 'tkextlib/iwidgets.rb'
+
+module Tk
+ module Iwidgets
+ class Combobox < Tk::Iwidgets::Entryfield
+ end
+ end
+end
+
+class Tk::Iwidgets::Combobox
+ TkCommandNames = ['::iwidgets::combobox'.freeze].freeze
+ WidgetClassName = 'Combobox'.freeze
+ WidgetClassNames[WidgetClassName] ||= self
+
+ def __boolval_optkeys
+ super() << 'completion' << 'dropdown' << 'editable' << 'unique'
+ end
+ private :__boolval_optkeys
+
+ def clear(component=None)
+ tk_call(@path, 'clear', component)
+ self
+ end
+
+ def delete_list(first, last=None)
+ tk_call(@path, 'delete', 'list', first, last)
+ self
+ end
+
+ def delete_entry(first, last=None)
+ tk_call(@path, 'delete', 'entry', first, last)
+ self
+ end
+
+ def get_list_contents(index)
+ tk_call(@path, 'get', index)
+ end
+
+ def insert_list(idx, *elems)
+ tk_call(@path, 'insert', 'list', idx, *elems)
+ self
+ end
+
+ def insert_entry(idx, *elems)
+ tk_call(@path, 'insert', 'entry', idx, *elems)
+ self
+ end
+
+ # listbox methods
+ def size
+ tk_send_without_enc('size').to_i
+ end
+ def see(index)
+ tk_send_without_enc('see', index)
+ self
+ end
+ def selection_anchor(index)
+ tk_send_without_enc('selection', 'anchor', index)
+ self
+ end
+ def selection_clear(first, last=None)
+ tk_send_without_enc('selection', 'clear', first, last)
+ self
+ end
+ def selection_includes(index)
+ bool(tk_send_without_enc('selection', 'includes', index))
+ end
+ def selection_set(first, last=None)
+ tk_send_without_enc('selection', 'set', first, last)
+ self
+ end
+
+ # scrolledlistbox methods
+ def get_curselection
+ tk_call(@path, 'getcurselection')
+ end
+ def justify(dir)
+ tk_call(@path, 'justify', dir)
+ self
+ end
+ def sort(*params, &b)
+ # see 'lsort' man page about params
+ if b
+ tk_call(@path, 'sort', '-command', proc(&b), *params)
+ else
+ tk_call(@path, 'sort', *params)
+ end
+ self
+ end
+ def sort_ascending
+ tk_call(@path, 'sort', 'ascending')
+ self
+ end
+ def sort_descending
+ tk_call(@path, 'sort', 'descending')
+ self
+ end
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/iwidgets/dateentry.rb b/jni/ruby/ext/tk/lib/tkextlib/iwidgets/dateentry.rb
new file mode 100644
index 0000000..98a0051
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/iwidgets/dateentry.rb
@@ -0,0 +1,20 @@
+#
+# tkextlib/iwidgets/dateentry.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+
+require 'tk'
+require 'tkextlib/iwidgets.rb'
+
+module Tk
+ module Iwidgets
+ class Dateentry < Tk::Iwidgets::Datefield
+ end
+ end
+end
+
+class Tk::Iwidgets::Dateentry
+ TkCommandNames = ['::iwidgets::dateentry'.freeze].freeze
+ WidgetClassName = 'Dateentry'.freeze
+ WidgetClassNames[WidgetClassName] ||= self
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/iwidgets/datefield.rb b/jni/ruby/ext/tk/lib/tkextlib/iwidgets/datefield.rb
new file mode 100644
index 0000000..50d5405
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/iwidgets/datefield.rb
@@ -0,0 +1,58 @@
+#
+# tkextlib/iwidgets/datefield.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+
+require 'tk'
+require 'tkextlib/iwidgets.rb'
+
+module Tk
+ module Iwidgets
+ class Datefield < Tk::Iwidgets::Labeledwidget
+ end
+ end
+end
+
+class Tk::Iwidgets::Datefield
+ TkCommandNames = ['::iwidgets::datefield'.freeze].freeze
+ WidgetClassName = 'Datefield'.freeze
+ WidgetClassNames[WidgetClassName] ||= self
+
+ def __boolval_optkeys
+ super() << 'gmt'
+ end
+ private :__boolval_optkeys
+
+ def __strval_optkeys
+ super() << 'textbackground'
+ end
+ private :__strval_optkeys
+
+ def __font_optkeys
+ super() << 'textfont'
+ end
+ private :__font_optkeys
+
+ def get_string
+ tk_call(@path, 'get', '-string')
+ end
+ alias get get_string
+
+ def get_clicks
+ number(tk_call(@path, 'get', '-clicks'))
+ end
+
+ def valid?
+ bool(tk_call(@path, 'isvalid'))
+ end
+ alias isvalid? valid?
+
+ def show(date=None)
+ tk_call(@path, 'show', date)
+ self
+ end
+ def show_now
+ tk_call(@path, 'show', 'now')
+ self
+ end
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/iwidgets/dialog.rb b/jni/ruby/ext/tk/lib/tkextlib/iwidgets/dialog.rb
new file mode 100644
index 0000000..2d554ca
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/iwidgets/dialog.rb
@@ -0,0 +1,20 @@
+#
+# tkextlib/iwidgets/dialog.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+
+require 'tk'
+require 'tkextlib/iwidgets.rb'
+
+module Tk
+ module Iwidgets
+ class Dialog < Tk::Iwidgets::Dialogshell
+ end
+ end
+end
+
+class Tk::Iwidgets::Dialog
+ TkCommandNames = ['::iwidgets::dialog'.freeze].freeze
+ WidgetClassName = 'Dialog'.freeze
+ WidgetClassNames[WidgetClassName] ||= self
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/iwidgets/dialogshell.rb b/jni/ruby/ext/tk/lib/tkextlib/iwidgets/dialogshell.rb
new file mode 100644
index 0000000..e880594
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/iwidgets/dialogshell.rb
@@ -0,0 +1,121 @@
+#
+# tkextlib/iwidgets/dialogshell.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+
+require 'tk'
+require 'tkextlib/iwidgets.rb'
+
+module Tk
+ module Iwidgets
+ class Dialogshell < Tk::Iwidgets::Shell
+ end
+ end
+end
+
+class Tk::Iwidgets::Dialogshell
+ TkCommandNames = ['::iwidgets::dialogshell'.freeze].freeze
+ WidgetClassName = 'Dialogshell'.freeze
+ WidgetClassNames[WidgetClassName] ||= self
+
+ ####################################
+
+ include TkItemConfigMethod
+
+ def __item_cget_cmd(id)
+ [self.path, 'buttoncget', id]
+ end
+ private :__item_cget_cmd
+
+ def __item_config_cmd(id)
+ [self.path, 'buttonconfigure', id]
+ end
+ private :__item_config_cmd
+
+ def __item_boolval_optkeys(id)
+ super(id) << 'defaultring'
+ end
+ private :__item_boolval_optkeys
+
+ def tagid(tagOrId)
+ if tagOrId.kind_of?(Tk::Itk::Component)
+ tagOrId.name
+ else
+ #_get_eval_string(tagOrId)
+ tagOrId
+ end
+ end
+
+ alias buttoncget_tkstring itemcget_tkstring
+ alias buttoncget itemcget
+ alias buttoncget_strict itemcget_strict
+ alias buttonconfigure itemconfigure
+ alias buttonconfiginfo itemconfiginfo
+ alias current_buttonconfiginfo current_itemconfiginfo
+
+ private :itemcget_tkstring, :itemcget, :itemcget_strict
+ private :itemconfigure, :itemconfiginfo, :current_itemconfiginfo
+
+ ####################################
+
+ def add(tag=nil, keys={})
+ if tag.kind_of?(Hash)
+ keys = tag
+ tag = nil
+ end
+ if tag
+ tag = Tk::Itk::Component.new(self, tagid(tag))
+ else
+ tag = Tk::Itk::Component.new(self)
+ end
+ tk_call(@path, 'add', tagid(tag), *hash_kv(keys))
+ tag
+ end
+
+ def default(idx)
+ tk_call(@path, 'default', index(idx))
+ self
+ end
+
+ def delete(idx)
+ tk_call(@path, 'delete', index(idx))
+ self
+ end
+
+ def hide(idx)
+ tk_call(@path, 'hide', index(idx))
+ self
+ end
+
+ def index(idx)
+ number(tk_call(@path, 'index', tagid(idx)))
+ end
+
+ def insert(idx, tag=nil, keys={})
+ if tag.kind_of?(Hash)
+ keys = tag
+ tag = nil
+ end
+ if tag
+ tag = Tk::Itk::Component.new(self, tagid(tag))
+ else
+ tag = Tk::Itk::Component.new(self)
+ end
+ tk_call(@path, 'insert', index(idx), tagid(tag), *hash_kv(keys))
+ tag
+ end
+
+ def invoke(idx=nil)
+ if idx
+ tk_call(@path, 'invoke', index(idx))
+ else
+ tk_call(@path, 'invoke')
+ end
+ self
+ end
+
+ def show(idx)
+ tk_call(@path, 'show', index(idx))
+ self
+ end
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/iwidgets/disjointlistbox.rb b/jni/ruby/ext/tk/lib/tkextlib/iwidgets/disjointlistbox.rb
new file mode 100644
index 0000000..07ab025
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/iwidgets/disjointlistbox.rb
@@ -0,0 +1,50 @@
+#
+# tkextlib/iwidgets/disjointlistbox.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+
+require 'tk'
+require 'tkextlib/iwidgets.rb'
+
+module Tk
+ module Iwidgets
+ class Disjointlistbox < Tk::Itk::Widget
+ end
+ end
+end
+
+class Tk::Iwidgets::Disjointlistbox
+ TkCommandNames = ['::iwidgets::disjointlistbox'.freeze].freeze
+ WidgetClassName = 'Disjointlistbox'.freeze
+ WidgetClassNames[WidgetClassName] ||= self
+
+ def __strval_optkeys
+ super() << 'lhslabeltext' << 'rhslabeltext' << 'lhsbuttonlabel' << 'rhsbuttonlabel'
+ end
+ private :__strval_optkeys
+
+ def set_lhs(*items)
+ tk_call(@path, 'setlhs', items)
+ self
+ end
+ def set_rhs(*items)
+ tk_call(@path, 'setrhs', items)
+ self
+ end
+
+ def get_lhs
+ simplelist(tk_call(@path, 'getlhs'))
+ end
+ def get_rhs
+ simplelist(tk_call(@path, 'getrhs'))
+ end
+
+ def insert_lhs(*items)
+ tk_call(@path, 'insertlhs', items)
+ self
+ end
+ def insert_rhs(*items)
+ tk_call(@path, 'insertrhs', items)
+ self
+ end
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/iwidgets/entryfield.rb b/jni/ruby/ext/tk/lib/tkextlib/iwidgets/entryfield.rb
new file mode 100644
index 0000000..3e7149a
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/iwidgets/entryfield.rb
@@ -0,0 +1,185 @@
+#
+# tkextlib/iwidgets/entryfield.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+
+require 'tk'
+require 'tkextlib/iwidgets.rb'
+
+module Tk
+ module Iwidgets
+ class Entryfield < Tk::Iwidgets::Labeledwidget
+ end
+ end
+end
+
+class Tk::Iwidgets::Entryfield
+ TkCommandNames = ['::iwidgets::entryfield'.freeze].freeze
+ WidgetClassName = 'Entryfield'.freeze
+ WidgetClassNames[WidgetClassName] ||= self
+
+ def __font_optkeys
+ super() << 'textfont'
+ end
+ private :__font_optkeys
+
+ ####################################
+
+ include Tk::ValidateConfigure
+
+ class EntryfieldValidate < TkValidateCommand
+ #class CalCmdArgs < TkUtil::CallbackSubst
+ class ValidateArgs < TkUtil::CallbackSubst
+ KEY_TBL = [
+ [ ?c, ?s, :char ],
+ [ ?P, ?s, :post ],
+ [ ?S, ?s, :current ],
+ [ ?W, ?w, :widget ],
+ nil
+ ]
+ PROC_TBL = [
+ [ ?s, TkComm.method(:string) ],
+ [ ?w, TkComm.method(:window) ],
+ nil
+ ]
+
+=begin
+ # for Ruby m17n :: ?x --> String --> char-code ( getbyte(0) )
+ KEY_TBL.map!{|inf|
+ if inf.kind_of?(Array)
+ inf[0] = inf[0].getbyte(0) if inf[0].kind_of?(String)
+ inf[1] = inf[1].getbyte(0) if inf[1].kind_of?(String)
+ end
+ inf
+ }
+
+ PROC_TBL.map!{|inf|
+ if inf.kind_of?(Array)
+ inf[0] = inf[0].getbyte(0) if inf[0].kind_of?(String)
+ end
+ inf
+ }
+=end
+
+ _setup_subst_table(KEY_TBL, PROC_TBL);
+ end
+
+ def self._config_keys
+ ['validate', 'invalid']
+ end
+ end
+
+ def __validation_class_list
+ super() << EntryfieldValidate
+ end
+
+ Tk::ValidateConfigure.__def_validcmd(binding, EntryfieldValidate)
+=begin
+ def validate(cmd = Proc.new, args = nil)
+ if cmd.kind_of?(ValidateCmd)
+ configure('validate', cmd)
+ elsif args
+ configure('validate', [cmd, args])
+ else
+ configure('validate', cmd)
+ end
+ end
+
+ def invalid(cmd = Proc.new, args = nil)
+ if cmd.kind_of?(ValidateCmd)
+ configure('invalid', cmd)
+ elsif args
+ configure('invalid', [cmd, args])
+ else
+ configure('invalid', cmd)
+ end
+ end
+=end
+
+ ####################################
+
+ def clear
+ tk_call(@path, 'clear')
+ self
+ end
+
+ def delete(first, last=None)
+ tk_send_without_enc('delete', first, last)
+ self
+ end
+
+ def value
+ _fromUTF8(tk_send_without_enc('get'))
+ end
+ def value= (val)
+ tk_send_without_enc('delete', 0, 'end')
+ tk_send_without_enc('insert', 0, _get_eval_enc_str(val))
+ val
+ end
+ alias get value
+ alias set value=
+
+ def cursor=(index)
+ tk_send_without_enc('icursor', index)
+ #self
+ index
+ end
+ alias icursor cursor=
+
+ def index(index)
+ number(tk_send_without_enc('index', index))
+ end
+
+ def insert(pos,text)
+ tk_send_without_enc('insert', pos, _get_eval_enc_str(text))
+ self
+ end
+
+ def mark(pos)
+ tk_send_without_enc('scan', 'mark', pos)
+ self
+ end
+ def dragto(pos)
+ tk_send_without_enc('scan', 'dragto', pos)
+ self
+ end
+ def selection_adjust(index)
+ tk_send_without_enc('selection', 'adjust', index)
+ self
+ end
+ def selection_clear
+ tk_send_without_enc('selection', 'clear')
+ self
+ end
+ def selection_from(index)
+ tk_send_without_enc('selection', 'from', index)
+ self
+ end
+ def selection_present()
+ bool(tk_send_without_enc('selection', 'present'))
+ end
+ def selection_range(s, e)
+ tk_send_without_enc('selection', 'range', s, e)
+ self
+ end
+ def selection_to(index)
+ tk_send_without_enc('selection', 'to', index)
+ self
+ end
+
+ # based on tk/scrollable.rb
+ def xview(*index)
+ if index.size == 0
+ list(tk_send_without_enc('xview'))
+ else
+ tk_send_without_enc('xview', *index)
+ self
+ end
+ end
+ def xview_moveto(*index)
+ xview('moveto', *index)
+ end
+ def xview_scroll(*index)
+ xview('scroll', *index)
+ end
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/iwidgets/extbutton.rb b/jni/ruby/ext/tk/lib/tkextlib/iwidgets/extbutton.rb
new file mode 100644
index 0000000..e744fba
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/iwidgets/extbutton.rb
@@ -0,0 +1,40 @@
+#
+# tkextlib/iwidgets/extbutton.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+
+require 'tk'
+require 'tkextlib/iwidgets.rb'
+
+module Tk
+ module Iwidgets
+ class Extbutton < Tk::Itk::Widget
+ end
+ end
+end
+
+class Tk::Iwidgets::Extbutton
+ TkCommandNames = ['::iwidgets::extbutton'.freeze].freeze
+ WidgetClassName = 'Extbutton'.freeze
+ WidgetClassNames[WidgetClassName] ||= self
+
+ def __strval_optkeys
+ super() << 'bitmapforeground' << 'ringbackground'
+ end
+ private :__strval_optkeys
+
+ def __boolval_optkeys
+ super() << 'defaultring'
+ end
+ private :__boolval_optkeys
+
+ def invoke
+ tk_call(@path, 'invoke')
+ self
+ end
+
+ def flash
+ tk_call(@path, 'flash')
+ self
+ end
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/iwidgets/extfileselectionbox.rb b/jni/ruby/ext/tk/lib/tkextlib/iwidgets/extfileselectionbox.rb
new file mode 100644
index 0000000..2ff15bb
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/iwidgets/extfileselectionbox.rb
@@ -0,0 +1,46 @@
+#
+# tkextlib/iwidgets/extfileselectionbox.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+
+require 'tk'
+require 'tkextlib/iwidgets.rb'
+
+module Tk
+ module Iwidgets
+ class Extfileselectionbox < Tk::Itk::Widget
+ end
+ end
+end
+
+class Tk::Iwidgets::Extfileselectionbox
+ TkCommandNames = ['::iwidgets::extfileselectionbox'.freeze].freeze
+ WidgetClassName = 'Extfileselectionbox'.freeze
+ WidgetClassNames[WidgetClassName] ||= self
+
+ def __strval_optkeys
+ super() + [
+ 'dirslabel', 'fileslabel', 'filterlabel', 'mask', 'nomatchstring',
+ 'selectionlabel'
+ ]
+ end
+ private :__strval_optkeys
+
+ def __boolval_optkeys
+ super() + ['dirson', 'fileson', 'filteron', 'selectionon']
+ end
+ private :__boolval_optkeys
+
+ def child_site
+ window(tk_call(@path, 'childsite'))
+ end
+
+ def filter
+ tk_call(@path, 'filter')
+ self
+ end
+
+ def get
+ tk_call(@path, 'get')
+ end
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/iwidgets/extfileselectiondialog.rb b/jni/ruby/ext/tk/lib/tkextlib/iwidgets/extfileselectiondialog.rb
new file mode 100644
index 0000000..509fdcf
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/iwidgets/extfileselectiondialog.rb
@@ -0,0 +1,33 @@
+#
+# tkextlib/iwidgets/extfileselectiondialog.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+
+require 'tk'
+require 'tkextlib/iwidgets.rb'
+
+module Tk
+ module Iwidgets
+ class Extfileselectiondialog < Tk::Iwidgets::Dialog
+ end
+ end
+end
+
+class Tk::Iwidgets::Extfileselectiondialog
+ TkCommandNames = ['::iwidgets::extfileselectiondialog'.freeze].freeze
+ WidgetClassName = 'Extfileselectiondialog'.freeze
+ WidgetClassNames[WidgetClassName] ||= self
+
+ def child_site
+ window(tk_call(@path, 'childsite'))
+ end
+
+ def filter
+ tk_call(@path, 'filter')
+ self
+ end
+
+ def get
+ tk_call(@path, 'get')
+ end
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/iwidgets/feedback.rb b/jni/ruby/ext/tk/lib/tkextlib/iwidgets/feedback.rb
new file mode 100644
index 0000000..29d04c8
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/iwidgets/feedback.rb
@@ -0,0 +1,35 @@
+#
+# tkextlib/iwidgets/feedback.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+
+require 'tk'
+require 'tkextlib/iwidgets.rb'
+
+module Tk
+ module Iwidgets
+ class Feedback < Tk::Iwidgets::Labeledwidget
+ end
+ end
+end
+
+class Tk::Iwidgets::Feedback
+ TkCommandNames = ['::iwidgets::feedback'.freeze].freeze
+ WidgetClassName = 'Feedback'.freeze
+ WidgetClassNames[WidgetClassName] ||= self
+
+ def __strval_optkeys
+ super() << 'barcolor'
+ end
+ private :__strval_optkeys
+
+ def reset
+ tk_call(@path, 'reset')
+ self
+ end
+
+ def step(inc=1)
+ tk_call(@path, 'step', inc)
+ self
+ end
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/iwidgets/fileselectionbox.rb b/jni/ruby/ext/tk/lib/tkextlib/iwidgets/fileselectionbox.rb
new file mode 100644
index 0000000..a425b53
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/iwidgets/fileselectionbox.rb
@@ -0,0 +1,46 @@
+#
+# tkextlib/iwidgets/fileselectionbox.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+
+require 'tk'
+require 'tkextlib/iwidgets.rb'
+
+module Tk
+ module Iwidgets
+ class Fileselectionbox < Tk::Itk::Widget
+ end
+ end
+end
+
+class Tk::Iwidgets::Fileselectionbox
+ TkCommandNames = ['::iwidgets::fileselectionbox'.freeze].freeze
+ WidgetClassName = 'Fileselectionbox'.freeze
+ WidgetClassNames[WidgetClassName] ||= self
+
+ def __strval_optkeys
+ super() + [
+ 'directory', 'dirslabel', 'fileslabel', 'filterlabel', 'mask',
+ 'nomatchstring', 'selectionlabel'
+ ]
+ end
+ private :__strval_optkeys
+
+ def __boolval_optkeys
+ super() + ['dirson', 'fileson', 'filteron', 'selectionon']
+ end
+ private :__boolval_optkeys
+
+ def child_site
+ window(tk_call(@path, 'childsite'))
+ end
+
+ def filter
+ tk_call(@path, 'filter')
+ self
+ end
+
+ def get
+ tk_call(@path, 'get')
+ end
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/iwidgets/fileselectiondialog.rb b/jni/ruby/ext/tk/lib/tkextlib/iwidgets/fileselectiondialog.rb
new file mode 100644
index 0000000..ebcdaf8
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/iwidgets/fileselectiondialog.rb
@@ -0,0 +1,33 @@
+#
+# tkextlib/iwidgets/fileselectiondialog.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+
+require 'tk'
+require 'tkextlib/iwidgets.rb'
+
+module Tk
+ module Iwidgets
+ class Fileselectiondialog < Tk::Iwidgets::Dialog
+ end
+ end
+end
+
+class Tk::Iwidgets::Fileselectiondialog
+ TkCommandNames = ['::iwidgets::fileselectiondialog'.freeze].freeze
+ WidgetClassName = 'Fileselectiondialog'.freeze
+ WidgetClassNames[WidgetClassName] ||= self
+
+ def child_site
+ window(tk_call(@path, 'childsite'))
+ end
+
+ def filter
+ tk_call(@path, 'filter')
+ self
+ end
+
+ def get
+ tk_call(@path, 'get')
+ end
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/iwidgets/finddialog.rb b/jni/ruby/ext/tk/lib/tkextlib/iwidgets/finddialog.rb
new file mode 100644
index 0000000..3d522e0
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/iwidgets/finddialog.rb
@@ -0,0 +1,42 @@
+#
+# tkextlib/iwidgets/finddialog.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+
+require 'tk'
+require 'tkextlib/iwidgets.rb'
+
+module Tk
+ module Iwidgets
+ class Finddialog < Tk::Iwidgets::Dialogshell
+ end
+ end
+end
+
+class Tk::Iwidgets::Finddialog
+ TkCommandNames = ['::iwidgets::finddialog'.freeze].freeze
+ WidgetClassName = 'Finddialog'.freeze
+ WidgetClassNames[WidgetClassName] ||= self
+
+ def __strval_optkeys
+ super() + [
+ 'patternbackground', 'patternforeground',
+ 'searchbackground', 'searchforeground'
+ ]
+ end
+ private :__strval_optkeys
+
+ def __val2ruby_optkeys # { key=>proc, ... }
+ super().update('textwidget'=>proc{|v| window(v)})
+ end
+ private :__val2ruby_optkeys
+
+ def clear
+ tk_call(@path, 'clear')
+ self
+ end
+
+ def find
+ tk_call(@path, 'find')
+ end
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/iwidgets/hierarchy.rb b/jni/ruby/ext/tk/lib/tkextlib/iwidgets/hierarchy.rb
new file mode 100644
index 0000000..cb9301d
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/iwidgets/hierarchy.rb
@@ -0,0 +1,365 @@
+#
+# tkextlib/iwidgets/hierarchy.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+
+require 'tk'
+require 'tk/text'
+require 'tkextlib/iwidgets.rb'
+
+module Tk
+ module Iwidgets
+ class Hierarchy < Tk::Iwidgets::Scrolledwidget
+ end
+ end
+end
+
+class Tk::Iwidgets::Hierarchy
+ ItemConfCMD = ['tag'.freeze, 'configure'.freeze].freeze
+ include TkTextTagConfig
+
+ TkCommandNames = ['::iwidgets::hierarchy'.freeze].freeze
+ WidgetClassName = 'Hierarchy'.freeze
+ WidgetClassNames[WidgetClassName] ||= self
+
+ ####################################
+
+ include Tk::ValidateConfigure
+
+ class QueryCommand < TkValidateCommand
+ class ValidateArgs < TkUtil::CallbackSubst
+ KEY_TBL = [ [?n, ?s, :node], nil ]
+ PROC_TBL = [ [?s, TkComm.method(:string) ], nil ]
+
+=begin
+ # for Ruby m17n :: ?x --> String --> char-code ( getbyte(0) )
+ KEY_TBL.map!{|inf|
+ if inf.kind_of?(Array)
+ inf[0] = inf[0].getbyte(0) if inf[0].kind_of?(String)
+ inf[1] = inf[1].getbyte(0) if inf[1].kind_of?(String)
+ end
+ inf
+ }
+
+ PROC_TBL.map!{|inf|
+ if inf.kind_of?(Array)
+ inf[0] = inf[0].getbyte(0) if inf[0].kind_of?(String)
+ end
+ inf
+ }
+=end
+
+ _setup_subst_table(KEY_TBL, PROC_TBL);
+
+ def self.ret_val(val)
+ val
+ end
+ end
+
+ def self._config_keys
+ # array of config-option key (string or symbol)
+ ['querycommand']
+ end
+ end
+
+ class IndicatorCommand < TkValidateCommand
+ class ValidateArgs < TkUtil::CallbackSubst
+ KEY_TBL = [
+ [ ?n, ?s, :node ],
+ [ ?s, ?b, :status ],
+ nil
+ ]
+
+ PROC_TBL = [
+ [ ?s, TkComm.method(:string) ],
+ [ ?b, TkComm.method(:bool) ],
+ nil
+ ]
+
+=begin
+ # for Ruby m17n :: ?x --> String --> char-code ( getbyte(0) )
+ KEY_TBL.map!{|inf|
+ if inf.kind_of?(Array)
+ inf[0] = inf[0].getbyte(0) if inf[0].kind_of?(String)
+ inf[1] = inf[1].getbyte(0) if inf[1].kind_of?(String)
+ end
+ inf
+ }
+
+ PROC_TBL.map!{|inf|
+ if inf.kind_of?(Array)
+ inf[0] = inf[0].getbyte(0) if inf[0].kind_of?(String)
+ end
+ inf
+ }
+=end
+
+ _setup_subst_table(KEY_TBL, PROC_TBL);
+
+ def self.ret_val(val)
+ val
+ end
+ end
+
+ def self._config_keys
+ # array of config-option key (string or symbol)
+ ['iconcommand', 'icondblcommand', 'imagedblcommand']
+ end
+ end
+
+ class IconCommand < TkValidateCommand
+ class ValidateArgs < TkUtil::CallbackSubst
+ KEY_TBL = [
+ [ ?n, ?s, :node ],
+ [ ?i, ?s, :icon ],
+ nil
+ ]
+ PROC_TBL = [ [ ?s, TkComm.method(:string) ], nil ]
+
+=begin
+ # for Ruby m17n :: ?x --> String --> char-code ( getbyte(0) )
+ KEY_TBL.map!{|inf|
+ if inf.kind_of?(Array)
+ inf[0] = inf[0].getbyte(0) if inf[0].kind_of?(String)
+ inf[1] = inf[1].getbyte(0) if inf[1].kind_of?(String)
+ end
+ inf
+ }
+
+ PROC_TBL.map!{|inf|
+ if inf.kind_of?(Array)
+ inf[0] = inf[0].getbyte(0) if inf[0].kind_of?(String)
+ end
+ inf
+ }
+=end
+
+ _setup_subst_table(KEY_TBL, PROC_TBL);
+
+ def self.ret_val(val)
+ val
+ end
+ end
+
+ def self._config_keys
+ # array of config-option key (string or symbol)
+ ['dblclickcommand', 'imagecommand', 'selectcommand']
+ end
+ end
+
+ def __validation_class_list
+ super() << QueryCommand << IndicatorCommand << IconCommand
+ end
+
+ Tk::ValidateConfigure.__def_validcmd(binding, QueryCommand)
+ Tk::ValidateConfigure.__def_validcmd(binding, IndicatorCommand)
+ Tk::ValidateConfigure.__def_validcmd(binding, IconCommand)
+
+ ####################################
+
+ def __boolval_optkeys
+ super() << 'alwaysquery' << 'expanded' << 'filter'
+ end
+ private :__boolval_optkeys
+
+ def __strval_optkeys
+ super() << 'markbackground' << 'markforeground' << 'textbackground'
+ end
+ private :__strval_optkeys
+
+ def __font_optkeys
+ super() << 'textfont'
+ end
+ private :__font_optkeys
+
+ def clear
+ tk_call(@path, 'clear')
+ self
+ end
+
+ def collapse(node)
+ tk_call(@path, 'collapse')
+ self
+ end
+
+ def current
+ tk_call(@path, 'current')
+ end
+
+ def draw(mode=None)
+ case mode
+ when None
+ # do nothing
+ when 'now', :now
+ mode = '-now'
+ when 'eventually', :eventually
+ mode = '-eventually'
+ when String, Symbol
+ mode = mode.to_s
+ mode = '-' << mode if mode[0] != ?-
+ end
+ tk_call(@path, 'draw', mode)
+ end
+
+ def expand(node)
+ tk_call(@path, 'expand', node)
+ self
+ end
+
+ def expanded?(node)
+ bool(tk_call(@path, 'expanded', node))
+ end
+
+ def exp_state
+ list(tk_call(@path, 'expState'))
+ end
+ alias expand_state exp_state
+ alias expanded_list exp_state
+
+ def mark_clear
+ tk_call(@path, 'mark', 'clear')
+ self
+ end
+ def mark_add(*nodes)
+ tk_call(@path, 'mark', 'add', *nodes)
+ self
+ end
+ def mark_remove(*nodes)
+ tk_call(@path, 'mark', 'remove', *nodes)
+ self
+ end
+ def mark_get
+ list(tk_call(@path, 'mark', 'get'))
+ end
+
+ def refresh(node)
+ tk_call(@path, 'refresh', node)
+ self
+ end
+
+ def prune(node)
+ tk_call(@path, 'prune', node)
+ self
+ end
+
+ def selection_clear
+ tk_call(@path, 'selection', 'clear')
+ self
+ end
+ def selection_add(*nodes)
+ tk_call(@path, 'selection', 'add', *nodes)
+ self
+ end
+ def selection_remove(*nodes)
+ tk_call(@path, 'selection', 'remove', *nodes)
+ self
+ end
+ def selection_get
+ list(tk_call(@path, 'selection', 'get'))
+ end
+
+ def toggle(node)
+ tk_call(@path, 'toggle', node)
+ self
+ end
+
+ # based on Tk::Text widget
+
+ def bbox(index)
+ list(tk_send_without_enc('bbox', _get_eval_enc_str(index)))
+ end
+
+ def compare(idx1, op, idx2)
+ bool(tk_send_without_enc('compare', _get_eval_enc_str(idx1),
+ op, _get_eval_enc_str(idx2)))
+ end
+
+ def debug
+ bool(tk_send_without_enc('debug'))
+ end
+ def debug=(boolean)
+ tk_send_without_enc('debug', boolean)
+ #self
+ boolean
+ end
+
+ def delete(first, last=None)
+ tk_send_without_enc('delete', first, last)
+ self
+ end
+
+ def dlineinfo(index)
+ list(tk_send_without_enc('dlineinfo', _get_eval_enc_str(index)))
+ end
+
+ def get(*index)
+ _fromUTF8(tk_send_without_enc('get', *index))
+ end
+
+ def index(index)
+ tk_send_without_enc('index', _get_eval_enc_str(index))
+ end
+
+ def insert(index, chars, *tags)
+ if tags[0].kind_of? Array
+ # multiple chars-taglist argument :: str, [tag,...], str, [tag,...], ...
+ args = [chars]
+ while tags.size > 0
+ args << tags.shift.collect{|x|_get_eval_string(x)}.join(' ') # taglist
+ args << tags.shift if tags.size > 0 # chars
+ end
+ super(index, *args)
+ else
+ # single chars-taglist argument :: str, tag, tag, ...
+ if tags.size == 0
+ super(index, chars)
+ else
+ super(index, chars, tags.collect{|x|_get_eval_string(x)}.join(' '))
+ end
+ end
+ end
+
+ def scan_mark(x, y)
+ tk_send_without_enc('scan', 'mark', x, y)
+ self
+ end
+ def scan_dragto(x, y)
+ tk_send_without_enc('scan', 'dragto', x, y)
+ self
+ end
+ def see(index)
+ tk_send_without_enc('see', index)
+ self
+ end
+
+ # based on tk/scrollable.rb
+ def xview(*index)
+ if index.size == 0
+ list(tk_send_without_enc('xview'))
+ else
+ tk_send_without_enc('xview', *index)
+ self
+ end
+ end
+ def xview_moveto(*index)
+ xview('moveto', *index)
+ end
+ def xview_scroll(*index)
+ xview('scroll', *index)
+ end
+
+ def yview(*index)
+ if index.size == 0
+ list(tk_send_without_enc('yview'))
+ else
+ tk_send_without_enc('yview', *index)
+ self
+ end
+ end
+ def yview_moveto(*index)
+ yview('moveto', *index)
+ end
+ def yview_scroll(*index)
+ yview('scroll', *index)
+ end
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/iwidgets/hyperhelp.rb b/jni/ruby/ext/tk/lib/tkextlib/iwidgets/hyperhelp.rb
new file mode 100644
index 0000000..d4ea1aa
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/iwidgets/hyperhelp.rb
@@ -0,0 +1,50 @@
+#
+# tkextlib/iwidgets/hyperhelp.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+
+require 'tk'
+require 'tkextlib/iwidgets.rb'
+
+module Tk
+ module Iwidgets
+ class Hyperhelp < Tk::Iwidgets::Shell
+ end
+ end
+end
+
+class Tk::Iwidgets::Hyperhelp
+ TkCommandNames = ['::iwidgets::hyperhelp'.freeze].freeze
+ WidgetClassName = 'Hyperhelp'.freeze
+ WidgetClassNames[WidgetClassName] ||= self
+
+ def __strval_optkeys
+ super() << 'helpdir'
+ end
+ private :__strval_optkeys
+
+ def __listval_optkeys
+ super() << 'topics'
+ end
+ private :__listval_optkeys
+
+ def show_topic(topic)
+ tk_call(@path, 'showtopic', topic)
+ self
+ end
+
+ def follow_link(href)
+ tk_call(@path, 'followlink', href)
+ self
+ end
+
+ def forward
+ tk_call(@path, 'forward')
+ self
+ end
+
+ def back
+ tk_call(@path, 'back')
+ self
+ end
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/iwidgets/labeledframe.rb b/jni/ruby/ext/tk/lib/tkextlib/iwidgets/labeledframe.rb
new file mode 100644
index 0000000..6595398
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/iwidgets/labeledframe.rb
@@ -0,0 +1,39 @@
+#
+# tkextlib/iwidgets/labeledframe.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+
+require 'tk'
+require 'tkextlib/iwidgets.rb'
+
+module Tk
+ module Iwidgets
+ class Labeledframe < Tk::Itk::Archetype
+ end
+ end
+end
+
+class Tk::Iwidgets::Labeledframe
+ TkCommandNames = ['::iwidgets::labeledframe'.freeze].freeze
+ WidgetClassName = 'Labeledframe'.freeze
+ WidgetClassNames[WidgetClassName] ||= self
+
+ def __strval_optkeys
+ super() << 'labeltext'
+ end
+ private :__strval_optkeys
+
+ def __tkvariable_optkeys
+ super() << 'labelvariable'
+ end
+ private :__tkvariable_optkeys
+
+ def __font_optkeys
+ super() << 'labelfont'
+ end
+ private :__font_optkeys
+
+ def child_site
+ window(tk_call(@path, 'childsite'))
+ end
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/iwidgets/labeledwidget.rb b/jni/ruby/ext/tk/lib/tkextlib/iwidgets/labeledwidget.rb
new file mode 100644
index 0000000..d36d428
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/iwidgets/labeledwidget.rb
@@ -0,0 +1,45 @@
+#
+# tkextlib/iwidgets/labeledwidget.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+
+require 'tk'
+require 'tkextlib/iwidgets.rb'
+
+module Tk
+ module Iwidgets
+ class Labeledwidget < Tk::Itk::Widget
+ end
+ end
+end
+
+class Tk::Iwidgets::Labeledwidget
+ extend TkCore
+
+ TkCommandNames = ['::iwidgets::labeledwidget'.freeze].freeze
+ WidgetClassName = 'Labeledwidget'.freeze
+ WidgetClassNames[WidgetClassName] ||= self
+
+ def __strval_optkeys
+ super() << 'labeltext'
+ end
+ private :__strval_optkeys
+
+ def __tkvariable_optkeys
+ super() << 'labelvariable'
+ end
+ private :__tkvariable_optkeys
+
+ def __font_optkeys
+ super() << 'labelfont'
+ end
+ private :__font_optkeys
+
+ def self.alignlabels(*wins)
+ tk_call('::iwidgets::Labeledwidget::alignlabels', *wins)
+ end
+
+ def child_site
+ window(tk_call(@path, 'childsite'))
+ end
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/iwidgets/mainwindow.rb b/jni/ruby/ext/tk/lib/tkextlib/iwidgets/mainwindow.rb
new file mode 100644
index 0000000..ebf4802
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/iwidgets/mainwindow.rb
@@ -0,0 +1,67 @@
+#
+# tkextlib/iwidgets/mainwindow.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+
+require 'tk'
+require 'tkextlib/iwidgets.rb'
+
+module Tk
+ module Iwidgets
+ class Mainwindow < Tk::Iwidgets::Shell
+ end
+ end
+end
+
+class Tk::Iwidgets::Mainwindow
+ TkCommandNames = ['::iwidgets::mainwindow'.freeze].freeze
+ WidgetClassName = 'Mainwindow'.freeze
+ WidgetClassNames[WidgetClassName] ||= self
+
+ def __boolval_optkeys
+ super() << 'helpline' << 'statusline'
+ end
+ private :__boolval_optkeys
+
+ def __strval_optkeys
+ super() << 'menubarbackground' << 'menubarforeground' << 'toolbarforeground'
+ end
+ private :__strval_optkeys
+
+ def __font_optkeys
+ super() << 'menubarfont' << 'toolbarfont'
+ end
+ private :__font_optkeys
+
+ def child_site
+ window(tk_call(@path, 'childsite'))
+ end
+
+ def menubar(*args)
+ unless args.empty?
+ tk_call(@path, 'menubar', *args)
+ end
+ window(tk_call(@path, 'menubar'))
+ end
+
+ def mousebar(*args)
+ unless args.empty?
+ tk_call(@path, 'mousebar', *args)
+ end
+ window(tk_call(@path, 'mousebar'))
+ end
+
+ def msgd(*args)
+ unless args.empty?
+ tk_call(@path, 'msgd', *args)
+ end
+ window(tk_call(@path, 'msgd'))
+ end
+
+ def toolbar(*args)
+ unless args.empty?
+ tk_call(@path, 'toolbar', *args)
+ end
+ window(tk_call(@path, 'toolbar'))
+ end
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/iwidgets/menubar.rb b/jni/ruby/ext/tk/lib/tkextlib/iwidgets/menubar.rb
new file mode 100644
index 0000000..f9a17d0
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/iwidgets/menubar.rb
@@ -0,0 +1,212 @@
+#
+# tkextlib/iwidgets/menubar.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+
+require 'tk'
+require 'tkextlib/iwidgets.rb'
+
+module Tk
+ module Iwidgets
+ class Menubar < Tk::Itk::Widget
+ end
+ end
+end
+
+class Tk::Iwidgets::Menubar
+ TkCommandNames = ['::iwidgets::menubar'.freeze].freeze
+ WidgetClassName = 'Menubar'.freeze
+ WidgetClassNames[WidgetClassName] ||= self
+
+ def __strval_optkeys
+ super() << 'menubuttons'
+ end
+ private :__strval_optkeys
+
+ def __tkvariable_optkeys
+ super() << 'helpvariable'
+ end
+ private :__tkvariable_optkeys
+
+ ####################################
+
+ include TkItemConfigMethod
+
+ def __item_cget_cmd(id)
+ [self.path, 'menucget', id]
+ end
+ private :__item_cget_cmd
+
+ def __item_config_cmd(id)
+ [self.path, 'menuconfigure', id]
+ end
+ private :__item_config_cmd
+
+ def __item_strval_optkeys(id)
+ super(id) << 'selectcolor'
+ end
+ private :__item_strval_optkeys
+
+ def __item_tkvariable_optkeys(id)
+ super(id) << 'helpstr'
+ end
+ private :__item_tkvariable_optkeys
+
+ def tagid(tagOrId)
+ if tagOrId.kind_of?(Tk::Itk::Component)
+ tagOrId.name
+ else
+ #_get_eval_string(tagOrId)
+ tagOrId
+ end
+ end
+
+ alias menucget_tkstring itemcget_tkstring
+ alias menucget itemcget
+ alias menucget_strict itemcget_strict
+ alias menuconfigure itemconfigure
+ alias menuconfiginfo itemconfiginfo
+ alias current_menuconfiginfo current_itemconfiginfo
+
+ private :itemcget_tkstring, :itemcget, :itemcget_strict
+ private :itemconfigure, :itemconfiginfo, :current_itemconfiginfo
+
+ ####################################
+
+ def __methodcall_optkeys
+ {'menubuttons'=>'menubuttons'}
+ end
+
+ def menubuttons(val = nil)
+ unless val
+ return tk_call(@path, 'cget', '-menubuttons')
+ end
+
+ tk_call(@path, 'configure', '-menubuttons', _parse_menu_spec(val))
+ self
+ end
+
+ def _parse_menu_spec(menu_spec)
+ ret = ''
+ menu_spec.each{|spec|
+ next unless spec
+
+ if spec.kind_of?(Hash)
+ args = [spec]
+ type = 'options'
+ else
+ type, *args = spec
+ end
+
+ type = type.to_s
+ case type
+ when 'options'
+ keys = args[0]
+ ary = [type]
+ ary.concat(hash_kv(keys))
+ ret << array2tk_list(ary) << "\n"
+
+ when 'menubutton', 'cascade'
+ name, keys = args
+ if keys
+ ary = [type, name]
+ keys = _symbolkey2str(keys)
+ keys['menu'] = _parse_menu_spec(keys['menu']) if keys.key?('menu')
+ ary.concat(hash_kv(keys))
+ ret << array2tk_list(ary) << "\n"
+ else
+ ret << array2tk_list([type, name]) << "\n"
+ end
+
+ else
+ name, keys = args
+ if keys
+ ary = [type, name]
+ ary.concat(hash_kv(keys))
+ ret << array2tk_list(ary) << "\n"
+ else
+ ret << array2tk_list([type, name]) << "\n"
+ end
+ end
+ }
+ ret
+ end
+
+ ####################################
+
+ def add(type, tag=nil, keys={})
+ if tag.kind_of?(Hash)
+ keys = tag
+ tag = nil
+ end
+ if tag
+ tag = Tk::Itk::Component.new(self, tagid(tag))
+ else
+ tag = Tk::Itk::Component.new(self)
+ end
+ keys = _symbolkey2str(keys)
+ keys['menu'] = _parse_menu_spec(keys['menu']) if keys.key?('menu')
+ tk_call(@path, 'add', type, tagid(tag), *hash_kv(keys))
+ tag
+ end
+
+ def delete(path1, path2=nil)
+ if path2
+ else
+ tk_call(@path, 'delete', index(idx))
+ end
+ self
+ end
+
+ def index(idx)
+ number(tk_call(@path, 'index', tagid(idx)))
+ end
+
+ def insert(idx, type, tag=nil, keys={})
+ if tag.kind_of?(Hash)
+ keys = tag
+ tag = nil
+ end
+ if tag
+ tag = Tk::Itk::Component.new(self, tagid(tag))
+ else
+ tag = Tk::Itk::Component.new(self)
+ end
+ keys = _symbolkey2str(keys)
+ keys['menu'] = _parse_menu_spec(keys['menu']) if keys.key?('menu')
+ tk_call(@path, 'insert', index(idx), type, tagid(tag), *hash_kv(keys))
+ tag
+ end
+
+ def invoke(idx)
+ tk_call(@path, 'invoke', index(idx))
+ self
+ end
+
+ def menupath(pat)
+ if (win = tk_call(@path, 'path', pat)) == '-1'
+ return nil
+ end
+ window(win)
+ end
+ def menupath_glob(pat)
+ if (win = tk_call(@path, 'path', '-glob', pat)) == '-1'
+ return nil
+ end
+ window(win)
+ end
+ def menupath_tclregexp(pat)
+ if (win = tk_call(@path, 'path', '-regexp', pat)) == '-1'
+ return nil
+ end
+ window(win)
+ end
+
+ def type(path)
+ tk_call(@path, 'type', path)
+ end
+
+ def yposition(path)
+ number(tk_call(@path, 'yposition', path))
+ end
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/iwidgets/messagebox.rb b/jni/ruby/ext/tk/lib/tkextlib/iwidgets/messagebox.rb
new file mode 100644
index 0000000..6adb53d
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/iwidgets/messagebox.rb
@@ -0,0 +1,93 @@
+#
+# tkextlib/iwidgets/messagebox.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+
+require 'tk'
+require 'tkextlib/iwidgets.rb'
+
+module Tk
+ module Iwidgets
+ class Messagebox < Tk::Iwidgets::Scrolledwidget
+ end
+ end
+end
+
+class Tk::Iwidgets::Messagebox
+ TkCommandNames = ['::iwidgets::messagebox'.freeze].freeze
+ WidgetClassName = 'Messagebox'.freeze
+ WidgetClassNames[WidgetClassName] ||= self
+
+ ####################################
+
+ include TkItemConfigMethod
+
+ def __item_cget_cmd(id)
+ [self.path, 'type', 'cget', id]
+ end
+ private :__item_cget_cmd
+
+ def __item_config_cmd(id)
+ [self.path, 'type', 'configure', id]
+ end
+ private :__item_config_cmd
+
+ def tagid(tagOrId)
+ if tagOrId.kind_of?(Tk::Itk::Component)
+ tagOrId.name
+ else
+ #_get_eval_string(tagOrId)
+ tagOrId
+ end
+ end
+
+ def __item_boolval_optkeys(id)
+ super(id) << 'bell' << 'show'
+ end
+ private :__item_boolval_optkeys
+
+ alias typecget_tkstring itemcget_tkstring
+ alias typecget itemcget
+ alias typecget_strict itemcget_strict
+ alias typeconfigure itemconfigure
+ alias typeconfiginfo itemconfiginfo
+ alias current_typeconfiginfo current_itemconfiginfo
+
+ private :itemcget_tkstring, :itemcget, :itemcget_strict
+ private :itemconfigure, :itemconfiginfo, :current_itemconfiginfo
+
+ ####################################
+
+ def __strval_optkeys
+ super() << 'filename' << 'savedir'
+ end
+ private :__strval_optkeys
+
+ def type_add(tag=nil, keys={})
+ if tag.kind_of?(Hash)
+ keys = tag
+ tag = nil
+ end
+ unless tag
+ tag = Tk::Itk::Component.new(self)
+ end
+ tk_call(@path, 'type', 'add', tagid(tag), *hash_kv(keys))
+ tag
+ end
+
+ def clear
+ tk_call(@path, 'clear')
+ self
+ end
+
+ def export(file)
+ tk_call(@path, 'export', file)
+ self
+ end
+
+ def issue(string, type=None, *args)
+ tk_call(@path, 'issue', string, tagid(type), *args)
+ self
+ end
+
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/iwidgets/messagedialog.rb b/jni/ruby/ext/tk/lib/tkextlib/iwidgets/messagedialog.rb
new file mode 100644
index 0000000..9aa5900
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/iwidgets/messagedialog.rb
@@ -0,0 +1,20 @@
+#
+# tkextlib/iwidgets/messagedialog.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+
+require 'tk'
+require 'tkextlib/iwidgets.rb'
+
+module Tk
+ module Iwidgets
+ class Messagedialog < Tk::Iwidgets::Dialog
+ end
+ end
+end
+
+class Tk::Iwidgets::Messagedialog
+ TkCommandNames = ['::iwidgets::messagedialog'.freeze].freeze
+ WidgetClassName = 'Messagedialog'.freeze
+ WidgetClassNames[WidgetClassName] ||= self
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/iwidgets/notebook.rb b/jni/ruby/ext/tk/lib/tkextlib/iwidgets/notebook.rb
new file mode 100644
index 0000000..7ed4126
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/iwidgets/notebook.rb
@@ -0,0 +1,175 @@
+#
+# tkextlib/iwidgets/notebook.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+
+require 'tk'
+require 'tkextlib/iwidgets.rb'
+
+module Tk
+ module Iwidgets
+ class Notebook < Tk::Itk::Widget
+ end
+ end
+end
+
+class Tk::Iwidgets::Notebook
+ TkCommandNames = ['::iwidgets::notebook'.freeze].freeze
+ WidgetClassName = 'Notebook'.freeze
+ WidgetClassNames[WidgetClassName] ||= self
+
+ ####################################
+
+ include TkItemConfigMethod
+
+ def __item_cget_cmd(id)
+ [self.path, 'pagecget', id]
+ end
+ private :__item_cget_cmd
+
+ def __item_config_cmd(id)
+ [self.path, 'pageconfigure', id]
+ end
+ private :__item_config_cmd
+
+ def tagid(tagOrId)
+ if tagOrId.kind_of?(Tk::Itk::Component)
+ tagOrId.name
+ else
+ #_get_eval_string(tagOrId)
+ tagOrId
+ end
+ end
+
+ alias pagecget_tkstring itemcget_tkstring
+ alias pagecget itemcget
+ alias pagecget_strict itemcget_strict
+ alias pageconfigure itemconfigure
+ alias pageconfiginfo itemconfiginfo
+ alias current_pageconfiginfo current_itemconfiginfo
+
+ private :itemcget_tkstring, :itemcget, :itemcget_strict
+ private :itemconfigure, :itemconfiginfo, :current_itemconfiginfo
+
+ ####################################
+
+ def __boolval_optkeys
+ super() << 'auto'
+ end
+ private :__boolval_optkeys
+
+ def add(keys={})
+ window(tk_call(@path, 'add', *hash_kv(keys)))
+ end
+
+ def child_site_list
+ list(tk_call(@path, 'childsite'))
+ end
+
+ def child_site(idx)
+ if (new_idx = self.index(idx)) < 0
+ new_idx = tagid(idx)
+ end
+ window(tk_call(@path, 'childsite', new_idx))
+ end
+
+ def delete(idx1, idx2=nil)
+ if (new_idx1 = self.index(idx1)) < 0
+ new_idx1 = tagid(idx1)
+ end
+ if idx2
+ if (new_idx2 = self.index(idx2)) < 0
+ new_idx2 = tagid(idx2)
+ end
+ tk_call(@path, 'delete', new_idx1, new_idx2)
+ else
+ tk_call(@path, 'delete', new_idx1)
+ end
+ self
+ end
+
+ def index(idx)
+ number(tk_call(@path, 'index', tagid(idx)))
+ end
+
+ def insert(idx, keys={})
+ if (new_idx = self.index(idx)) < 0
+ new_idx = tagid(idx)
+ end
+ window(tk_call(@path, 'insert', new_idx, *hash_kv(keys)))
+ end
+
+ def next
+ tk_call(@path, 'next')
+ self
+ end
+
+ def prev
+ tk_call(@path, 'prev')
+ self
+ end
+
+ def select(idx)
+ if (new_idx = self.index(idx)) < 0
+ new_idx = tagid(idx)
+ end
+ tk_call(@path, 'select', new_idx)
+ self
+ end
+
+ def scrollcommand(cmd=Proc.new)
+ configure_cmd 'scrollcommand', cmd
+ self
+ end
+ alias xscrollcommand scrollcommand
+ alias yscrollcommand scrollcommand
+
+ def xscrollbar(bar=nil)
+ if bar
+ @scrollbar = bar
+ @scrollbar.orient 'horizontal'
+ self.scrollcommand {|*arg| @scrollbar.set(*arg)}
+ @scrollbar.command {|*arg| self.xview(*arg)}
+ Tk.update # avoid scrollbar trouble
+ end
+ @scrollbar
+ end
+ def yscrollbar(bar=nil)
+ if bar
+ @scrollbar = bar
+ @scrollbar.orient 'vertical'
+ self.scrollcommand {|*arg| @scrollbar.set(*arg)}
+ @scrollbar.command {|*arg| self.yview(*arg)}
+ Tk.update # avoid scrollbar trouble
+ end
+ @scrollbar
+ end
+ alias scrollbar yscrollbar
+
+ def view(*idxs)
+ if idxs.size == 0
+ idx = num_or_str(tk_send_without_enc('view'))
+ if idx.kind_of?(Fixnum) && idx < 0
+ nil
+ else
+ idx
+ end
+ else
+ tk_send_without_enc('view', *idxs)
+ self
+ end
+ end
+ alias xview view
+ alias yview view
+
+ def view_moveto(*idxs)
+ view('moveto', *idxs)
+ end
+ alias xview_moveto view_moveto
+ alias yview_moveto view_moveto
+ def view_scroll(index, what='pages')
+ view('scroll', index, what)
+ end
+ alias xview_scroll view_scroll
+ alias yview_scroll view_scroll
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/iwidgets/optionmenu.rb b/jni/ruby/ext/tk/lib/tkextlib/iwidgets/optionmenu.rb
new file mode 100644
index 0000000..57a3cc7
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/iwidgets/optionmenu.rb
@@ -0,0 +1,92 @@
+#
+# tkextlib/iwidgets/optionmenu.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+
+require 'tk'
+require 'tkextlib/iwidgets.rb'
+
+module Tk
+ module Iwidgets
+ class Optionmenu < Tk::Iwidgets::Labeledwidget
+ end
+ end
+end
+
+class Tk::Iwidgets::Optionmenu
+ TkCommandNames = ['::iwidgets::optionmenu'.freeze].freeze
+ WidgetClassName = 'Optionmenu'.freeze
+ WidgetClassNames[WidgetClassName] ||= self
+
+ def __boolval_optkeys
+ super() << 'cyclicon'
+ end
+ private :__boolval_optkeys
+
+ def delete(first, last=nil)
+ if last
+ tk_call(@path, 'delete', first, last)
+ else
+ tk_call(@path, 'delete', first)
+ end
+ self
+ end
+
+ def disable(idx)
+ tk_call(@path, 'disable', idx)
+ self
+ end
+
+ def enable(idx)
+ tk_call(@path, 'enable', idx)
+ self
+ end
+
+ def get(first=nil, last=nil)
+ if last
+ simplelist(tk_call(@path, 'get', first, last))
+ elsif first
+ tk_call(@path, 'get', first)
+ else
+ tk_call(@path, 'get')
+ end
+ end
+ def get_range(first, last)
+ get(first, last)
+ end
+ def get_selected
+ get()
+ end
+
+ def index(idx)
+ number(tk_call(@path, 'index', idx))
+ end
+
+ def insert(idx, *args)
+ tk_call(@path, 'insert', idx, *args)
+ self
+ end
+
+ def select(idx)
+ tk_call(@path, 'select', idx)
+ self
+ end
+
+ def sort(*params, &b)
+ # see 'lsort' man page about params
+ if b
+ tk_call(@path, 'sort', '-command', proc(&b), *params)
+ else
+ tk_call(@path, 'sort', *params)
+ end
+ self
+ end
+ def sort_ascending
+ tk_call(@path, 'sort', 'ascending')
+ self
+ end
+ def sort_descending
+ tk_call(@path, 'sort', 'descending')
+ self
+ end
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/iwidgets/panedwindow.rb b/jni/ruby/ext/tk/lib/tkextlib/iwidgets/panedwindow.rb
new file mode 100644
index 0000000..65463cc
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/iwidgets/panedwindow.rb
@@ -0,0 +1,134 @@
+#
+# tkextlib/iwidgets/panedwindow.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+
+require 'tk'
+require 'tkextlib/iwidgets.rb'
+
+module Tk
+ module Iwidgets
+ class Panedwindow < Tk::Itk::Widget
+ end
+ end
+end
+
+class Tk::Iwidgets::Panedwindow
+ TkCommandNames = ['::iwidgets::panedwindow'.freeze].freeze
+ WidgetClassName = 'Panedwindow'.freeze
+ WidgetClassNames[WidgetClassName] ||= self
+
+ ####################################
+
+ include TkItemConfigMethod
+
+ def __item_cget_cmd(id)
+ [self.path, 'panecget', id]
+ end
+ private :__item_cget_cmd
+
+ def __item_config_cmd(id)
+ [self.path, 'paneconfigure', id]
+ end
+ private :__item_config_cmd
+
+ def tagid(tagOrId)
+ if tagOrId.kind_of?(Tk::Itk::Component)
+ tagOrId.name
+ else
+ #_get_eval_string(tagOrId)
+ tagOrId
+ end
+ end
+
+ alias panecget_tkstring itemcget_tkstring
+ alias panecget itemcget
+ alias panecget_strict itemcget_strict
+ alias paneconfigure itemconfigure
+ alias paneconfiginfo itemconfiginfo
+ alias current_paneconfiginfo current_itemconfiginfo
+
+ private :itemcget_tkstring, :itemcget, :itemcget_strict
+ private :itemconfigure, :itemconfiginfo, :current_itemconfiginfo
+
+ ####################################
+
+ def __boolval_optkeys
+ super() << 'showhandle'
+ end
+ private :__boolval_optkeys
+
+ def add(tag=nil, keys={})
+ if tag.kind_of?(Hash)
+ keys = tag
+ tag = nil
+ end
+ if tag
+ tag = Tk::Itk::Component.new(self, tagid(tag))
+ else
+ tag = Tk::Itk::Component.new(self)
+ end
+ window(tk_call(@path, 'add', tagid(tag), *hash_kv(keys)))
+ tag
+ end
+
+ def child_site_list
+ list(tk_call(@path, 'childsite'))
+ end
+
+ def child_site(idx)
+ window(tk_call(@path, 'childsite', index(idx)))
+ end
+
+ def delete(idx)
+ tk_call(@path, 'delete', index(idx))
+ self
+ end
+
+ def fraction(*percentages)
+ tk_call(@path, 'fraction', *percentages)
+ self
+ end
+
+ def hide(idx)
+ tk_call(@path, 'hide', index(idx))
+ self
+ end
+
+ def index(idx)
+ number(tk_call(@path, 'index', tagid(idx)))
+ end
+
+ def insert(idx, tag=nil, keys={})
+ if tag.kind_of?(Hash)
+ keys = tag
+ tag = nil
+ end
+ if tag
+ tag = Tk::Itk::Component.new(self, tagid(tag))
+ else
+ tag = Tk::Itk::Component.new(self)
+ end
+ window(tk_call(@path, 'insert', index(idx), tagid(tag), *hash_kv(keys)))
+ tag
+ end
+
+ def invoke(idx=nil)
+ if idx
+ tk_call(@path, 'invoke', index(idx))
+ else
+ tk_call(@path, 'invoke')
+ end
+ self
+ end
+
+ def reset
+ tk_call(@path, 'reset')
+ self
+ end
+
+ def show(idx)
+ tk_call(@path, 'show', index(idx))
+ self
+ end
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/iwidgets/promptdialog.rb b/jni/ruby/ext/tk/lib/tkextlib/iwidgets/promptdialog.rb
new file mode 100644
index 0000000..7c7ff7a
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/iwidgets/promptdialog.rb
@@ -0,0 +1,131 @@
+#
+# tkextlib/iwidgets/promptdialog.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+
+require 'tk'
+require 'tkextlib/iwidgets.rb'
+
+module Tk
+ module Iwidgets
+ class Promptdialog < Tk::Iwidgets::Dialog
+ end
+ end
+end
+
+class Tk::Iwidgets::Promptdialog
+ TkCommandNames = ['::iwidgets::promptdialog'.freeze].freeze
+ WidgetClassName = 'Promptdialog'.freeze
+ WidgetClassNames[WidgetClassName] ||= self
+
+ # index method is not available, because it shows index of the entry field
+ def default(name)
+ tk_call(@path, 'default', tagid(name))
+ self
+ end
+
+ def hide(name)
+ tk_call(@path, 'hide', tagid(name))
+ self
+ end
+
+ def invoke(name=nil)
+ if name
+ tk_call(@path, 'invoke', tagid(name))
+ else
+ tk_call(@path, 'invoke')
+ end
+ self
+ end
+
+ def show(name)
+ tk_call(@path, 'show', tagid(name))
+ self
+ end
+
+
+ # based on Tk::Iwidgets::Entryfield
+ def clear
+ tk_call(@path, 'clear')
+ self
+ end
+
+ def delete(first, last=None)
+ tk_send_without_enc('delete', first, last)
+ self
+ end
+
+ def value
+ _fromUTF8(tk_send_without_enc('get'))
+ end
+ def value= (val)
+ tk_send_without_enc('delete', 0, 'end')
+ tk_send_without_enc('insert', 0, _get_eval_enc_str(val))
+ val
+ end
+ alias get value
+ alias set value=
+
+ def cursor=(index)
+ tk_send_without_enc('icursor', index)
+ #self
+ index
+ end
+ alias icursor cursor=
+
+ def index(idx)
+ number(tk_send_without_enc('index', idx))
+ end
+
+ def insert(pos,text)
+ tk_send_without_enc('insert', pos, _get_eval_enc_str(text))
+ self
+ end
+
+ def mark(pos)
+ tk_send_without_enc('scan', 'mark', pos)
+ self
+ end
+ def dragto(pos)
+ tk_send_without_enc('scan', 'dragto', pos)
+ self
+ end
+ def selection_adjust(index)
+ tk_send_without_enc('selection', 'adjust', index)
+ self
+ end
+ def selection_clear
+ tk_send_without_enc('selection', 'clear')
+ self
+ end
+ def selection_from(index)
+ tk_send_without_enc('selection', 'from', index)
+ self
+ end
+ def selection_present()
+ bool(tk_send_without_enc('selection', 'present'))
+ end
+ def selection_range(s, e)
+ tk_send_without_enc('selection', 'range', s, e)
+ self
+ end
+ def selection_to(index)
+ tk_send_without_enc('selection', 'to', index)
+ self
+ end
+
+ def xview(*index)
+ if index.size == 0
+ list(tk_send_without_enc('xview'))
+ else
+ tk_send_without_enc('xview', *index)
+ self
+ end
+ end
+ def xview_moveto(*index)
+ xview('moveto', *index)
+ end
+ def xview_scroll(*index)
+ xview('scroll', *index)
+ end
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/iwidgets/pushbutton.rb b/jni/ruby/ext/tk/lib/tkextlib/iwidgets/pushbutton.rb
new file mode 100644
index 0000000..ae56788
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/iwidgets/pushbutton.rb
@@ -0,0 +1,35 @@
+#
+# tkextlib/iwidgets/pushbutton.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+
+require 'tk'
+require 'tkextlib/iwidgets.rb'
+
+module Tk
+ module Iwidgets
+ class Pushbutton < Tk::Itk::Widget
+ end
+ end
+end
+
+class Tk::Iwidgets::Pushbutton
+ TkCommandNames = ['::iwidgets::pushbutton'.freeze].freeze
+ WidgetClassName = 'Pushbutton'.freeze
+ WidgetClassNames[WidgetClassName] ||= self
+
+ def __boolval_optkeys
+ super() << 'defaultring'
+ end
+ private :__boolval_optkeys
+
+ def invoke
+ tk_call_without_enc(@path, 'invoke')
+ self
+ end
+
+ def flash
+ tk_call_without_enc(@path, 'flash')
+ self
+ end
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/iwidgets/radiobox.rb b/jni/ruby/ext/tk/lib/tkextlib/iwidgets/radiobox.rb
new file mode 100644
index 0000000..2118177
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/iwidgets/radiobox.rb
@@ -0,0 +1,121 @@
+#
+# tkextlib/iwidgets/radiobox.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+
+require 'tk'
+require 'tkextlib/iwidgets.rb'
+
+module Tk
+ module Iwidgets
+ class Radiobox < Tk::Iwidgets::Labeledframe
+ end
+ end
+end
+
+class Tk::Iwidgets::Radiobox
+ TkCommandNames = ['::iwidgets::radiobox'.freeze].freeze
+ WidgetClassName = 'Radiobox'.freeze
+ WidgetClassNames[WidgetClassName] ||= self
+
+ ####################################
+
+ include TkItemConfigMethod
+
+ def __item_cget_cmd(id)
+ [self.path, 'buttoncget', id]
+ end
+ private :__item_cget_cmd
+
+ def __item_config_cmd(id)
+ [self.path, 'buttonconfigure', id]
+ end
+ private :__item_config_cmd
+
+ def __item_boolval_optkeys(id)
+ super(id) << 'defaultring'
+ end
+ private :__item_boolval_optkeys
+
+ def tagid(tagOrId)
+ if tagOrId.kind_of?(Tk::Itk::Component)
+ tagOrId.name
+ else
+ #_get_eval_string(tagOrId)
+ tagOrId
+ end
+ end
+
+ alias buttoncget_tkstring itemcget_tkstring
+ alias buttoncget itemcget
+ alias buttoncget_strict itemcget_strict
+ alias buttonconfigure itemconfigure
+ alias buttonconfiginfo itemconfiginfo
+ alias current_buttonconfiginfo current_itemconfiginfo
+
+ private :itemcget_tkstring, :itemcget, :itemcget_strict
+ private :itemconfigure, :itemconfiginfo, :current_itemconfiginfo
+
+ ####################################
+
+ def add(tag=nil, keys={})
+ if tag.kind_of?(Hash)
+ keys = tag
+ tag = nil
+ end
+ if tag
+ tag = Tk::Itk::Component.new(self, tagid(tag))
+ else
+ tag = Tk::Itk::Component.new(self)
+ end
+ tk_call(@path, 'add', tagid(tag), *hash_kv(keys))
+ tag
+ end
+
+ def delete(idx)
+ tk_call(@path, 'delete', index(idx))
+ self
+ end
+
+ def deselect(idx)
+ tk_call(@path, 'deselect', index(idx))
+ self
+ end
+
+ def flash(idx)
+ tk_call(@path, 'flash', index(idx))
+ self
+ end
+
+ def get_tag
+ ((tag = tk_call_without_enc(@path, 'get')).empty?)? nil: tag
+ end
+ alias get get_tag
+
+ def get_obj
+ (tag = get_tag)? Tk::Itk::Component.id2obj(self, tag): nil
+ end
+
+ def index(idx)
+ number(tk_call(@path, 'index', tagid(idx)))
+ end
+
+ def insert(idx, tag=nil, keys={})
+ if tag.kind_of?(Hash)
+ keys = tag
+ tag = nil
+ end
+ if tag
+ tag = Tk::Itk::Component.new(self, tagid(tag))
+ else
+ tag = Tk::Itk::Component.new(self)
+ end
+ tk_call(@path, 'insert', index(idx), tagid(tag), *hash_kv(keys))
+ tag
+ end
+
+ def select(idx)
+ tk_call(@path, 'select', index(idx))
+ self
+ end
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/iwidgets/scopedobject.rb b/jni/ruby/ext/tk/lib/tkextlib/iwidgets/scopedobject.rb
new file mode 100644
index 0000000..056cd85
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/iwidgets/scopedobject.rb
@@ -0,0 +1,24 @@
+#
+# tkextlib/iwidgets/buttonbox.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+
+require 'tk'
+require 'tkextlib/iwidgets.rb'
+
+module Tk
+ module Iwidgets
+ class Scopedobject < TkObject
+ end
+ end
+end
+
+class Tk::Iwidgets::Scopedobject
+ TkCommandNames = ['::iwidgets::scopedobject'.freeze].freeze
+ WidgetClassName = 'Scopedobject'.freeze
+ WidgetClassNames[WidgetClassName] ||= self
+
+ def initialize(obj_name, keys={})
+ @path = tk_call(self.class::TkCommandNames[0], obj_name, *hash_kv(keys))
+ end
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/iwidgets/scrolledcanvas.rb b/jni/ruby/ext/tk/lib/tkextlib/iwidgets/scrolledcanvas.rb
new file mode 100644
index 0000000..4dea2f2
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/iwidgets/scrolledcanvas.rb
@@ -0,0 +1,353 @@
+#
+# tkextlib/iwidgets/scrolledcanvas.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+
+require 'tk'
+require 'tk/canvas'
+require 'tkextlib/iwidgets.rb'
+
+module Tk
+ module Iwidgets
+ class Scrolledcanvas < Tk::Iwidgets::Scrolledwidget
+ end
+ end
+end
+
+class Tk::Iwidgets::Scrolledcanvas
+ TkCommandNames = ['::iwidgets::scrolledcanvas'.freeze].freeze
+ WidgetClassName = 'Scrolledcanvas'.freeze
+ WidgetClassNames[WidgetClassName] ||= self
+
+ ################################
+
+ def __boolval_optkeys
+ super() << 'autoresize'
+ end
+ private :__boolval_optkeys
+
+ def __strval_optkeys
+ super() << 'textbackground'
+ end
+ private :__strval_optkeys
+
+ def initialize(*args)
+ super(*args)
+ @canvas = component_widget('canvas')
+ end
+
+ def method_missing(id, *args)
+ if @canvas.respond_to?(id)
+ @canvas.__send__(id, *args)
+ else
+ super(id, *args)
+ end
+ end
+
+ ################################
+
+ def child_site
+ window(tk_call(@path, 'childsite'))
+ end
+
+ def justify(dir)
+ tk_call(@path, 'justify', dir)
+ self
+ end
+
+ ##########################
+ include TkCanvasItemConfig
+
+ def tagid(tag)
+ if tag.kind_of?(TkcItem) || tag.kind_of?(TkcTag)
+ tag.id
+ elsif tag.kind_of?(Tk::Itk::Component)
+ tag.name
+ else
+ tag # maybe an Array of configure parameters
+ end
+ end
+ private :tagid
+
+ # create a canvas item without creating a TkcItem object
+ def create(type, *args)
+ type.create(self, *args)
+ end
+
+ #######################
+
+ def addtag(tag, mode, *args)
+ tk_send_without_enc('addtag', tagid(tag), mode, *args)
+ self
+ end
+ def addtag_above(tagOrId, target)
+ addtag(tagOrId, 'above', tagid(target))
+ end
+ def addtag_all(tagOrId)
+ addtag(tagOrId, 'all')
+ end
+ def addtag_below(tagOrId, target)
+ addtag(tagOrId, 'below', tagid(target))
+ end
+ def addtag_closest(tagOrId, x, y, halo=None, start=None)
+ addtag(tagOrId, 'closest', x, y, halo, start)
+ end
+ def addtag_enclosed(tagOrId, x1, y1, x2, y2)
+ addtag(tagOrId, 'enclosed', x1, y1, x2, y2)
+ end
+ def addtag_overlapping(tagOrId, x1, y1, x2, y2)
+ addtag(tagOrId, 'overlapping', x1, y1, x2, y2)
+ end
+ def addtag_withtag(tagOrId, tag)
+ addtag(tagOrId, 'withtag', tagid(tag))
+ end
+
+ def bbox(tagOrId, *tags)
+ list(tk_send_without_enc('bbox', tagid(tagOrId),
+ *tags.collect{|t| tagid(t)}))
+ end
+
+ #def itembind(tag, context, cmd=Proc.new, *args)
+ # _bind([path, "bind", tagid(tag)], context, cmd, *args)
+ # self
+ #end
+ def itembind(tag, context, *args)
+ # if args[0].kind_of?(Proc) || args[0].kind_of?(Method)
+ if TkComm._callback_entry?(args[0]) || !block_given?
+ cmd = args.shift
+ else
+ cmd = Proc.new
+ end
+ _bind([path, "bind", tagid(tag)], context, cmd, *args)
+ self
+ end
+
+ #def itembind_append(tag, context, cmd=Proc.new, *args)
+ # _bind_append([path, "bind", tagid(tag)], context, cmd, *args)
+ # self
+ #end
+ def itembind_append(tag, context, *args)
+ # if args[0].kind_of?(Proc) || args[0].kind_of?(Method)
+ if TkComm._callback_entry?(args[0]) || !block_given?
+ cmd = args.shift
+ else
+ cmd = Proc.new
+ end
+ _bind_append([path, "bind", tagid(tag)], context, cmd, *args)
+ self
+ end
+
+ def itembind_remove(tag, context)
+ _bind_remove([path, "bind", tagid(tag)], context)
+ self
+ end
+
+ def itembindinfo(tag, context=nil)
+ _bindinfo([path, "bind", tagid(tag)], context)
+ end
+
+ def canvasx(screen_x, *args)
+ #tk_tcl2ruby(tk_send_without_enc('canvasx', screen_x, *args))
+ number(tk_send_without_enc('canvasx', screen_x, *args))
+ end
+ def canvasy(screen_y, *args)
+ #tk_tcl2ruby(tk_send_without_enc('canvasy', screen_y, *args))
+ number(tk_send_without_enc('canvasy', screen_y, *args))
+ end
+
+ def coords(tag, *args)
+ if args == []
+ tk_split_list(tk_send_without_enc('coords', tagid(tag)))
+ else
+ tk_send_without_enc('coords', tagid(tag), *(args.flatten))
+ self
+ end
+ end
+
+ def dchars(tag, first, last=None)
+ tk_send_without_enc('dchars', tagid(tag),
+ _get_eval_enc_str(first), _get_eval_enc_str(last))
+ self
+ end
+
+ def delete(*args)
+ tbl = nil
+ TkcItem::CItemID_TBL.mutex.synchronize{
+ tbl = TkcItem::CItemID_TBL[self.path]
+ }
+ if tbl
+ find('withtag', *args).each{|item|
+ if item.kind_of?(TkcItem)
+ TkcItem::CItemID_TBL.mutex.synchronize{
+ tbl.delete(item.id)
+ }
+ end
+ }
+ end
+ tk_send_without_enc('delete', *args.collect{|t| tagid(t)})
+ self
+ end
+ alias remove delete
+
+ def dtag(tag, tag_to_del=None)
+ tk_send_without_enc('dtag', tagid(tag), tag_to_del)
+ self
+ end
+
+ def find(mode, *args)
+ list(tk_send_without_enc('find', mode, *args)).collect!{|id|
+ TkcItem.id2obj(self, id)
+ }
+ end
+ def find_above(target)
+ find('above', tagid(target))
+ end
+ def find_all
+ find('all')
+ end
+ def find_below(target)
+ find('below', tagid(target))
+ end
+ def find_closest(x, y, halo=None, start=None)
+ find('closest', x, y, halo, start)
+ end
+ def find_enclosed(x1, y1, x2, y2)
+ find('enclosed', x1, y1, x2, y2)
+ end
+ def find_overlapping(x1, y1, x2, y2)
+ find('overlapping', x1, y1, x2, y2)
+ end
+ def find_withtag(tag)
+ find('withtag', tag)
+ end
+
+ def itemfocus(tagOrId=nil)
+ if tagOrId
+ tk_send_without_enc('focus', tagid(tagOrId))
+ self
+ else
+ ret = tk_send_without_enc('focus')
+ if ret == ""
+ nil
+ else
+ TkcItem.id2obj(self, ret)
+ end
+ end
+ end
+
+ def gettags(tagOrId)
+ list(tk_send_without_enc('gettags', tagid(tagOrId))).collect{|tag|
+ TkcTag.id2obj(self, tag)
+ }
+ end
+
+ def icursor(tagOrId, index)
+ tk_send_without_enc('icursor', tagid(tagOrId), index)
+ self
+ end
+
+ def index(tagOrId, idx)
+ number(tk_send_without_enc('index', tagid(tagOrId), idx))
+ end
+
+ def insert(tagOrId, index, string)
+ tk_send_without_enc('insert', tagid(tagOrId), index,
+ _get_eval_enc_str(string))
+ self
+ end
+
+ def lower(tag, below=nil)
+ if below
+ tk_send_without_enc('lower', tagid(tag), tagid(below))
+ else
+ tk_send_without_enc('lower', tagid(tag))
+ end
+ self
+ end
+
+ def move(tag, x, y)
+ tk_send_without_enc('move', tagid(tag), x, y)
+ self
+ end
+
+ def postscript(keys)
+ tk_send("postscript", *hash_kv(keys))
+ end
+
+ def raise(tag, above=nil)
+ if above
+ tk_send_without_enc('raise', tagid(tag), tagid(above))
+ else
+ tk_send_without_enc('raise', tagid(tag))
+ end
+ self
+ end
+
+ def scale(tag, x, y, xs, ys)
+ tk_send_without_enc('scale', tagid(tag), x, y, xs, ys)
+ self
+ end
+
+ def scan_mark(x, y)
+ tk_send_without_enc('scan', 'mark', x, y)
+ self
+ end
+ def scan_dragto(x, y)
+ tk_send_without_enc('scan', 'dragto', x, y)
+ self
+ end
+
+ def select(mode, *args)
+ r = tk_send_without_enc('select', mode, *args)
+ (mode == 'item')? TkcItem.id2obj(self, r): self
+ end
+ def select_adjust(tagOrId, index)
+ select('adjust', tagid(tagOrId), index)
+ end
+ def select_clear
+ select('clear')
+ end
+ def select_from(tagOrId, index)
+ select('from', tagid(tagOrId), index)
+ end
+ def select_item
+ select('item')
+ end
+ def select_to(tagOrId, index)
+ select('to', tagid(tagOrId), index)
+ end
+
+ def itemtype(tag)
+ TkcItem.type2class(tk_send('type', tagid(tag)))
+ end
+
+ def xview(*index)
+ if index.size == 0
+ list(tk_send_without_enc('xview'))
+ else
+ tk_send_without_enc('xview', *index)
+ self
+ end
+ end
+ def xview_moveto(*index)
+ xview('moveto', *index)
+ end
+ def xview_scroll(*index)
+ xview('scroll', *index)
+ end
+
+ def yview(*index)
+ if index.size == 0
+ list(tk_send_without_enc('yview'))
+ else
+ tk_send_without_enc('yview', *index)
+ self
+ end
+ end
+ def yview_moveto(*index)
+ yview('moveto', *index)
+ end
+ def yview_scroll(*index)
+ yview('scroll', *index)
+ end
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/iwidgets/scrolledframe.rb b/jni/ruby/ext/tk/lib/tkextlib/iwidgets/scrolledframe.rb
new file mode 100644
index 0000000..7b7b95d
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/iwidgets/scrolledframe.rb
@@ -0,0 +1,59 @@
+#
+# tkextlib/iwidgets/scrolledframe.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+
+require 'tk'
+require 'tkextlib/iwidgets.rb'
+
+module Tk
+ module Iwidgets
+ class Scrolledframe < Tk::Iwidgets::Scrolledwidget
+ end
+ end
+end
+
+class Tk::Iwidgets::Scrolledframe
+ TkCommandNames = ['::iwidgets::scrolledframe'.freeze].freeze
+ WidgetClassName = 'Scrolledframe'.freeze
+ WidgetClassNames[WidgetClassName] ||= self
+
+ def child_site
+ window(tk_call(@path, 'childsite'))
+ end
+
+ def justify(dir)
+ tk_call(@path, 'justify', dir)
+ self
+ end
+
+ def xview(*index)
+ if index.size == 0
+ list(tk_send_without_enc('xview'))
+ else
+ tk_send_without_enc('xview', *index)
+ self
+ end
+ end
+ def xview_moveto(*index)
+ xview('moveto', *index)
+ end
+ def xview_scroll(*index)
+ xview('scroll', *index)
+ end
+
+ def yview(*index)
+ if index.size == 0
+ list(tk_send_without_enc('yview'))
+ else
+ tk_send_without_enc('yview', *index)
+ self
+ end
+ end
+ def yview_moveto(*index)
+ yview('moveto', *index)
+ end
+ def yview_scroll(*index)
+ yview('scroll', *index)
+ end
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/iwidgets/scrolledhtml.rb b/jni/ruby/ext/tk/lib/tkextlib/iwidgets/scrolledhtml.rb
new file mode 100644
index 0000000..dc2966b
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/iwidgets/scrolledhtml.rb
@@ -0,0 +1,58 @@
+#
+# tkextlib/iwidgets/scrolledhtml.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+
+require 'tk'
+require 'tkextlib/iwidgets.rb'
+
+module Tk
+ module Iwidgets
+ class Scrolledhtml < Tk::Iwidgets::Scrolledtext
+ end
+ end
+end
+
+class Tk::Iwidgets::Scrolledhtml
+ TkCommandNames = ['::iwidgets::scrolledhtml'.freeze].freeze
+ WidgetClassName = 'Scrolledhtml'.freeze
+ WidgetClassNames[WidgetClassName] ||= self
+
+ def __boolval_optkeys
+ super() << 'update'
+ end
+ private :__boolval_optkeys
+
+ def __strval_optkeys
+ super() << 'fontname' << 'link' << 'alink' << 'textbackground'
+ end
+ private :__strval_optkeys
+
+ def __font_optkeys
+ super() << 'fixedfont'
+ end
+ private :__font_optkeys
+
+ def import(href)
+ tk_call(@path, 'import', href)
+ self
+ end
+
+ def import_link(href)
+ tk_call(@path, 'import', '-link', href)
+ self
+ end
+
+ def pwd
+ tk_call(@path, 'pwd')
+ end
+
+ def render(htmltext, workdir=None)
+ tk_call(@path, 'render', htmltext, workdir)
+ self
+ end
+
+ def title
+ tk_call(@path, 'title')
+ end
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/iwidgets/scrolledlistbox.rb b/jni/ruby/ext/tk/lib/tkextlib/iwidgets/scrolledlistbox.rb
new file mode 100644
index 0000000..20a4cd1
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/iwidgets/scrolledlistbox.rb
@@ -0,0 +1,207 @@
+#
+# tkextlib/iwidgets/scrolledlistbox.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+
+require 'tk'
+require 'tk/listbox'
+require 'tkextlib/iwidgets.rb'
+
+module Tk
+ module Iwidgets
+ class Scrolledlistbox < Tk::Iwidgets::Scrolledwidget
+ end
+ end
+end
+
+class Tk::Iwidgets::Scrolledlistbox
+ TkCommandNames = ['::iwidgets::scrolledlistbox'.freeze].freeze
+ WidgetClassName = 'Scrolledlistbox'.freeze
+ WidgetClassNames[WidgetClassName] ||= self
+
+ def __strval_optkeys
+ super() << 'textbackground'
+ end
+ private :__strval_optkeys
+
+ def __tkvariable_optkeys
+ super() << 'listvariable'
+ end
+ private :__tkvariable_optkeys
+
+ def __font_optkeys
+ super() << 'textfont'
+ end
+ private :__font_optkeys
+
+ ################################
+
+ def initialize(*args)
+ super(*args)
+ @listbox = component_widget('listbox')
+ end
+
+ def method_missing(id, *args)
+ if @listbox.respond_to?(id)
+ @listbox.__send__(id, *args)
+ else
+ super(id, *args)
+ end
+ end
+
+ ################################
+
+ def clear
+ tk_call(@path, 'clear')
+ self
+ end
+
+ def get_curselection
+ tk_call(@path, 'getcurselection')
+ end
+
+ def justify(dir)
+ tk_call(@path, 'justify', dir)
+ self
+ end
+
+ def selected_item_count
+ number(tk_call(@path, 'selecteditemcount'))
+ end
+
+ def sort(*params, &b)
+ # see 'lsort' man page about params
+ if b
+ tk_call(@path, 'sort', '-command', proc(&b), *params)
+ else
+ tk_call(@path, 'sort', *params)
+ end
+ self
+ end
+ def sort_ascending
+ tk_call(@path, 'sort', 'ascending')
+ self
+ end
+ def sort_descending
+ tk_call(@path, 'sort', 'descending')
+ self
+ end
+
+ #####################################
+
+ def bbox(index)
+ list(tk_send_without_enc('bbox', index))
+ end
+ def delete(first, last=None)
+ tk_send_without_enc('delete', first, last)
+ self
+ end
+ def get(*index)
+ _fromUTF8(tk_send_without_enc('get', *index))
+ end
+ def insert(index, *args)
+ tk_send('insert', index, *args)
+ self
+ end
+ def scan_mark(x, y)
+ tk_send_without_enc('scan', 'mark', x, y)
+ self
+ end
+ def scan_dragto(x, y)
+ tk_send_without_enc('scan', 'dragto', x, y)
+ self
+ end
+ def see(index)
+ tk_send_without_enc('see', index)
+ self
+ end
+
+ #####################################
+
+ include TkListItemConfig
+
+ def tagid(tag)
+ if tag.kind_of?(Tk::Itk::Component)
+ tag.name
+ else
+ super(tag)
+ end
+ end
+ private :tagid
+
+ #####################################
+
+ def activate(y)
+ tk_send_without_enc('activate', y)
+ self
+ end
+ def curselection
+ list(tk_send_without_enc('curselection'))
+ end
+ def get(first, last=nil)
+ if last
+ # tk_split_simplelist(_fromUTF8(tk_send_without_enc('get', first, last)))
+ tk_split_simplelist(tk_send_without_enc('get', first, last),
+ false, true)
+ else
+ _fromUTF8(tk_send_without_enc('get', first))
+ end
+ end
+ def nearest(y)
+ tk_send_without_enc('nearest', y).to_i
+ end
+ def size
+ tk_send_without_enc('size').to_i
+ end
+ def selection_anchor(index)
+ tk_send_without_enc('selection', 'anchor', index)
+ self
+ end
+ def selection_clear(first, last=None)
+ tk_send_without_enc('selection', 'clear', first, last)
+ self
+ end
+ def selection_includes(index)
+ bool(tk_send_without_enc('selection', 'includes', index))
+ end
+ def selection_set(first, last=None)
+ tk_send_without_enc('selection', 'set', first, last)
+ self
+ end
+
+ def index(idx)
+ tk_send_without_enc('index', idx).to_i
+ end
+
+ #####################################
+
+ def xview(*index)
+ if index.size == 0
+ list(tk_send_without_enc('xview'))
+ else
+ tk_send_without_enc('xview', *index)
+ self
+ end
+ end
+ def xview_moveto(*index)
+ xview('moveto', *index)
+ end
+ def xview_scroll(*index)
+ xview('scroll', *index)
+ end
+
+ def yview(*index)
+ if index.size == 0
+ list(tk_send_without_enc('yview'))
+ else
+ tk_send_without_enc('yview', *index)
+ self
+ end
+ end
+ def yview_moveto(*index)
+ yview('moveto', *index)
+ end
+ def yview_scroll(*index)
+ yview('scroll', *index)
+ end
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/iwidgets/scrolledtext.rb b/jni/ruby/ext/tk/lib/tkextlib/iwidgets/scrolledtext.rb
new file mode 100644
index 0000000..69b7d31
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/iwidgets/scrolledtext.rb
@@ -0,0 +1,568 @@
+#
+# tkextlib/iwidgets/scrolledtext.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+
+require 'tk'
+require 'tk/text'
+require 'tkextlib/iwidgets.rb'
+
+module Tk
+ module Iwidgets
+ class Scrolledtext < Tk::Iwidgets::Scrolledwidget
+ end
+ end
+end
+
+class Tk::Iwidgets::Scrolledtext
+ TkCommandNames = ['::iwidgets::scrolledtext'.freeze].freeze
+ WidgetClassName = 'Scrolledtext'.freeze
+ WidgetClassNames[WidgetClassName] ||= self
+
+ def __strval_optkeys
+ super() << 'textbackground'
+ end
+ private :__strval_optkeys
+
+ def __font_optkeys
+ super() << 'textfont'
+ end
+ private :__font_optkeys
+
+ ################################
+
+ def initialize(*args)
+ super(*args)
+ @text = component_widget('text')
+ end
+
+ def method_missing(id, *args)
+ if @text.respond_to?(id)
+ @text.__send__(id, *args)
+ else
+ super(id, *args)
+ end
+ end
+
+ ################################
+
+ def child_site
+ window(tk_call(@path, 'childsite'))
+ end
+
+ def clear
+ tk_call(@path, 'clear')
+ self
+ end
+
+ def import(file, idx=nil)
+ if idx
+ tk_call(@path, 'import', file, index(idx))
+ else
+ tk_call(@path, 'import', file)
+ end
+ self
+ end
+
+ def export(file)
+ tk_call(@path, 'export', file)
+ self
+ end
+
+ #####################################
+
+ include TkTextTagConfig
+
+ def tagid(tag)
+ if tag.kind_of?(Tk::Itk::Component)
+ tag.name
+ else
+ super(tag)
+ end
+ end
+ private :tagid
+
+ def bbox(index)
+ list(tk_send('bbox', index))
+ end
+ def compare(idx1, op, idx2)
+ bool(tk_send_without_enc('compare', _get_eval_enc_str(idx1),
+ op, _get_eval_enc_str(idx2)))
+ end
+
+ def debug
+ bool(tk_send_without_enc('debug'))
+ end
+ def debug=(boolean)
+ tk_send_without_enc('debug', boolean)
+ #self
+ boolean
+ end
+
+ def delete(first, last=None)
+ tk_send_without_enc('delete', first, last)
+ self
+ end
+
+ def dlineinfo(index)
+ list(tk_send_without_enc('dlineinfo', _get_eval_enc_str(index)))
+ end
+
+ def get(*index)
+ _fromUTF8(tk_send_without_enc('get', *index))
+ end
+ def get_displaychars(*index)
+ # Tk8.5 feature
+ get('-displaychars', *index)
+ end
+
+ def image_cget_tkstring(index, slot)
+ _fromUTF8(tk_send_without_enc('image', 'cget',
+ _get_eval_enc_str(index), "-#{slot.to_s}"))
+ end
+ def image_cget_strict(index, slot)
+ case slot.to_s
+ when 'text', 'label', 'show', 'data', 'file'
+ _fromUTF8(tk_send_without_enc('image', 'cget',
+ _get_eval_enc_str(index), "-#{slot}"))
+ else
+ tk_tcl2ruby(_fromUTF8(tk_send_without_enc('image', 'cget',
+ _get_eval_enc_str(index),
+ "-#{slot}")))
+ end
+ end
+ def image_cget(index, slot)
+ unless TkItemConfigMethod.__IGNORE_UNKNOWN_CONFIGURE_OPTION__
+ image_cget_strict(index, slot)
+ else
+ begin
+ image_cget_strict(index, slot)
+ rescue => e
+ begin
+ if current_image_configinfo.has_key?(slot.to_s)
+ # error on known option
+ fail e
+ else
+ # unknown option
+ nil
+ end
+ rescue
+ fail e # tag error
+ end
+ end
+ end
+ end
+
+ def image_configure(index, slot, value=None)
+ if slot.kind_of? Hash
+ _fromUTF8(tk_send_without_enc('image', 'configure',
+ _get_eval_enc_str(index),
+ *hash_kv(slot, true)))
+ else
+ _fromUTF8(tk_send_without_enc('image', 'configure',
+ _get_eval_enc_str(index),
+ "-#{slot}",
+ _get_eval_enc_str(value)))
+ end
+ self
+ end
+
+ def image_configinfo(index, slot = nil)
+ if TkComm::GET_CONFIGINFO_AS_ARRAY
+ if slot
+ case slot.to_s
+ when 'text', 'label', 'show', 'data', 'file'
+ #conf = tk_split_simplelist(_fromUTF8(tk_send_without_enc('image', 'configure', _get_eval_enc_str(index), "-#{slot}")))
+ conf = tk_split_simplelist(tk_send_without_enc('image', 'configure', _get_eval_enc_str(index), "-#{slot}"), false, true)
+ else
+ #conf = tk_split_list(_fromUTF8(tk_send_without_enc('image', 'configure', _get_eval_enc_str(index), "-#{slot}")))
+ conf = tk_split_list(tk_send_without_enc('image', 'configure', _get_eval_enc_str(index), "-#{slot}"), 0, false, true)
+ end
+ conf[0] = conf[0][1..-1]
+ conf
+ else
+ #tk_split_simplelist(_fromUTF8(tk_send_without_enc('image', 'configure', _get_eval_enc_str(index)))).collect{|conflist|
+ # conf = tk_split_simplelist(conflist)
+ tk_split_simplelist(tk_send_without_enc('image', 'configure', _get_eval_enc_str(index)), false, false).collect{|conflist|
+ conf = tk_split_simplelist(conflist, false, true)
+ conf[0] = conf[0][1..-1]
+ case conf[0]
+ when 'text', 'label', 'show', 'data', 'file'
+ else
+ if conf[3]
+ if conf[3].index('{')
+ conf[3] = tk_split_list(conf[3])
+ else
+ conf[3] = tk_tcl2ruby(conf[3])
+ end
+ end
+ if conf[4]
+ if conf[4].index('{')
+ conf[4] = tk_split_list(conf[4])
+ else
+ conf[4] = tk_tcl2ruby(conf[4])
+ end
+ end
+ end
+ conf[1] = conf[1][1..-1] if conf.size == 2 # alias info
+ conf
+ }
+ end
+ else # ! TkComm::GET_CONFIGINFO_AS_ARRAY
+ if slot
+ case slot.to_s
+ when 'text', 'label', 'show', 'data', 'file'
+ #conf = tk_split_simplelist(_fromUTF8(tk_send_without_enc('image', 'configure', _get_eval_enc_str(index), "-#{slot}")))
+ conf = tk_split_simplelist(tk_send_without_enc('image', 'configure', _get_eval_enc_str(index), "-#{slot}"), false, true)
+ else
+ #conf = tk_split_list(_fromUTF8(tk_send_without_enc('image', 'configure', _get_eval_enc_str(index), "-#{slot}")))
+ conf = tk_split_list(tk_send_without_enc('image', 'configure', _get_eval_enc_str(index), "-#{slot}"), 0, false, true)
+ end
+ key = conf.shift[1..-1]
+ { key => conf }
+ else
+ ret = {}
+ #tk_split_simplelist(_fromUTF8(tk_send_without_enc('image', 'configure', _get_eval_enc_str(index)))).each{|conflist|
+ # conf = tk_split_simplelist(conflist)
+ tk_split_simplelist(tk_send_without_enc('image', 'configure', _get_eval_enc_str(index)), false, false).each{|conflist|
+ conf = tk_split_simplelist(conflist, false, true)
+ key = conf.shift[1..-1]
+ case key
+ when 'text', 'label', 'show', 'data', 'file'
+ else
+ if conf[2]
+ if conf[2].index('{')
+ conf[2] = tk_split_list(conf[2])
+ else
+ conf[2] = tk_tcl2ruby(conf[2])
+ end
+ end
+ if conf[3]
+ if conf[3].index('{')
+ conf[3] = tk_split_list(conf[3])
+ else
+ conf[3] = tk_tcl2ruby(conf[3])
+ end
+ end
+ end
+ if conf.size == 1
+ ret[key] = conf[0][1..-1] # alias info
+ else
+ ret[key] = conf
+ end
+ }
+ ret
+ end
+ end
+ end
+
+ def current_image_configinfo(index, slot = nil)
+ if TkComm::GET_CONFIGINFO_AS_ARRAY
+ if slot
+ conf = image_configinfo(index, slot)
+ {conf[0] => conf[4]}
+ else
+ ret = {}
+ image_configinfo(index).each{|conf|
+ ret[conf[0]] = conf[4] if conf.size > 2
+ }
+ ret
+ end
+ else # ! TkComm::GET_CONFIGINFO_AS_ARRAY
+ ret = {}
+ image_configinfo(index, slot).each{|k, conf|
+ ret[k] = conf[-1] if conf.kind_of?(Array)
+ }
+ ret
+ end
+ end
+
+ def image_names
+ #tk_split_simplelist(_fromUTF8(tk_send_without_enc('image', 'names'))).collect{|elt|
+ tk_split_simplelist(tk_send_without_enc('image', 'names'), false, true).collect{|elt|
+ tagid2obj(elt)
+ }
+ end
+
+ def index(idx)
+ tk_send_without_enc('index', _get_eval_enc_str(idx))
+ end
+
+ def insert(index, *args)
+ tk_send('insert', index, *args)
+ self
+ end
+
+ def mark_names
+ #tk_split_simplelist(_fromUTF8(tk_send_without_enc('mark', 'names'))).collect{|elt|
+ tk_split_simplelist(tk_send_without_enc('mark', 'names'), false, true).collect{|elt|
+ tagid2obj(elt)
+ }
+ end
+
+ def mark_gravity(mark, direction=nil)
+ if direction
+ tk_send_without_enc('mark', 'gravity',
+ _get_eval_enc_str(mark), direction)
+ self
+ else
+ tk_send_without_enc('mark', 'gravity', _get_eval_enc_str(mark))
+ end
+ end
+
+ def mark_set(mark, index)
+ tk_send_without_enc('mark', 'set', _get_eval_enc_str(mark),
+ _get_eval_enc_str(index))
+ self
+ end
+ alias set_mark mark_set
+
+ def mark_unset(*marks)
+ tk_send_without_enc('mark', 'unset',
+ *(marks.collect{|mark| _get_eval_enc_str(mark)}))
+ self
+ end
+ alias unset_mark mark_unset
+
+ def mark_next(index)
+ tagid2obj(_fromUTF8(tk_send_without_enc('mark', 'next',
+ _get_eval_enc_str(index))))
+ end
+ alias next_mark mark_next
+
+ def mark_previous(index)
+ tagid2obj(_fromUTF8(tk_send_without_enc('mark', 'previous',
+ _get_eval_enc_str(index))))
+ end
+ alias previous_mark mark_previous
+
+ def scan_mark(x, y)
+ tk_send_without_enc('scan', 'mark', x, y)
+ self
+ end
+ def scan_dragto(x, y)
+ tk_send_without_enc('scan', 'dragto', x, y)
+ self
+ end
+
+
+ def _ktext_length(txt)
+ if TkCore::WITH_ENCODING ### Ruby 1.9 !!!!!!!!!!!!!
+ return txt.length
+ end
+ ###########################
+
+ if $KCODE !~ /n/i
+ return txt.gsub(/[^\Wa-zA-Z_\d]/, ' ').length
+ end
+
+ # $KCODE == 'NONE'
+ if JAPANIZED_TK
+ tk_call_without_enc('kstring', 'length',
+ _get_eval_enc_str(txt)).to_i
+ else
+ begin
+ tk_call_without_enc('encoding', 'convertto', 'ascii',
+ _get_eval_enc_str(txt)).length
+ rescue StandardError, NameError
+ # sorry, I have no plan
+ txt.length
+ end
+ end
+ end
+ private :_ktext_length
+
+ def tksearch(*args)
+ # call 'search' subcommand of text widget
+ # args ::= [<array_of_opts>] <pattern> <start_index> [<stop_index>]
+ # If <pattern> is regexp, then it must be a regular expression of Tcl
+ if args[0].kind_of?(Array)
+ opts = args.shift.collect{|opt| '-' + opt.to_s }
+ else
+ opts = []
+ end
+
+ opts << '--'
+
+ ret = tk_send('search', *(opts + args))
+ if ret == ""
+ nil
+ else
+ ret
+ end
+ end
+
+ def tksearch_with_count(*args)
+ # call 'search' subcommand of text widget
+ # args ::= [<array_of_opts>] <var> <pattern> <start_index> [<stop_index>]
+ # If <pattern> is regexp, then it must be a regular expression of Tcl
+ if args[0].kind_of?(Array)
+ opts = args.shift.collect{|opt| '-' + opt.to_s }
+ else
+ opts = []
+ end
+
+ opts << '-count' << args.shift << '--'
+
+ ret = tk_send('search', *(opts + args))
+ if ret == ""
+ nil
+ else
+ ret
+ end
+ end
+
+ def search_with_length(pat,start,stop=None)
+ pat = pat.chr if pat.kind_of? Integer
+ if stop != None
+ return ["", 0] if compare(start,'>=',stop)
+ txt = get(start,stop)
+ if (pos = txt.index(pat))
+ match = $&
+ #pos = txt[0..(pos-1)].split('').length if pos > 0
+ pos = _ktext_length(txt[0..(pos-1)]) if pos > 0
+ if pat.kind_of? String
+ #return [index(start + " + #{pos} chars"), pat.split('').length]
+ return [index(start + " + #{pos} chars"),
+ _ktext_length(pat), pat.dup]
+ else
+ #return [index(start + " + #{pos} chars"), $&.split('').length]
+ return [index(start + " + #{pos} chars"),
+ _ktext_length(match), match]
+ end
+ else
+ return ["", 0]
+ end
+ else
+ txt = get(start,'end - 1 char')
+ if (pos = txt.index(pat))
+ match = $&
+ #pos = txt[0..(pos-1)].split('').length if pos > 0
+ pos = _ktext_length(txt[0..(pos-1)]) if pos > 0
+ if pat.kind_of? String
+ #return [index(start + " + #{pos} chars"), pat.split('').length]
+ return [index(start + " + #{pos} chars"),
+ _ktext_length(pat), pat.dup]
+ else
+ #return [index(start + " + #{pos} chars"), $&.split('').length]
+ return [index(start + " + #{pos} chars"),
+ _ktext_length(match), match]
+ end
+ else
+ txt = get('1.0','end - 1 char')
+ if (pos = txt.index(pat))
+ match = $&
+ #pos = txt[0..(pos-1)].split('').length if pos > 0
+ pos = _ktext_length(txt[0..(pos-1)]) if pos > 0
+ if pat.kind_of? String
+ #return [index("1.0 + #{pos} chars"), pat.split('').length]
+ return [index("1.0 + #{pos} chars"),
+ _ktext_length(pat), pat.dup]
+ else
+ #return [index("1.0 + #{pos} chars"), $&.split('').length]
+ return [index("1.0 + #{pos} chars"), _ktext_length(match), match]
+ end
+ else
+ return ["", 0]
+ end
+ end
+ end
+ end
+
+ def search(pat,start,stop=None)
+ search_with_length(pat,start,stop)[0]
+ end
+
+ def rsearch_with_length(pat,start,stop=None)
+ pat = pat.chr if pat.kind_of? Integer
+ if stop != None
+ return ["", 0] if compare(start,'<=',stop)
+ txt = get(stop,start)
+ if (pos = txt.rindex(pat))
+ match = $&
+ #pos = txt[0..(pos-1)].split('').length if pos > 0
+ pos = _ktext_length(txt[0..(pos-1)]) if pos > 0
+ if pat.kind_of? String
+ #return [index(stop + " + #{pos} chars"), pat.split('').length]
+ return [index(stop + " + #{pos} chars"), _ktext_length(pat), pat.dup]
+ else
+ #return [index(stop + " + #{pos} chars"), $&.split('').length]
+ return [index(stop + " + #{pos} chars"), _ktext_length(match), match]
+ end
+ else
+ return ["", 0]
+ end
+ else
+ txt = get('1.0',start)
+ if (pos = txt.rindex(pat))
+ match = $&
+ #pos = txt[0..(pos-1)].split('').length if pos > 0
+ pos = _ktext_length(txt[0..(pos-1)]) if pos > 0
+ if pat.kind_of? String
+ #return [index("1.0 + #{pos} chars"), pat.split('').length]
+ return [index("1.0 + #{pos} chars"), _ktext_length(pat), pat.dup]
+ else
+ #return [index("1.0 + #{pos} chars"), $&.split('').length]
+ return [index("1.0 + #{pos} chars"), _ktext_length(match), match]
+ end
+ else
+ txt = get('1.0','end - 1 char')
+ if (pos = txt.rindex(pat))
+ match = $&
+ #pos = txt[0..(pos-1)].split('').length if pos > 0
+ pos = _ktext_length(txt[0..(pos-1)]) if pos > 0
+ if pat.kind_of? String
+ #return [index("1.0 + #{pos} chars"), pat.split('').length]
+ return [index("1.0 + #{pos} chars"), _ktext_length(pat), pat.dup]
+ else
+ #return [index("1.0 + #{pos} chars"), $&.split('').length]
+ return [index("1.0 + #{pos} chars"), _ktext_length(match), match]
+ end
+ else
+ return ["", 0]
+ end
+ end
+ end
+ end
+
+ def rsearch(pat,start,stop=None)
+ rsearch_with_length(pat,start,stop)[0]
+ end
+
+ def see(index)
+ tk_send_without_enc('see', index)
+ self
+ end
+
+ ###############################
+
+ def xview(*index)
+ if index.size == 0
+ list(tk_send_without_enc('xview'))
+ else
+ tk_send_without_enc('xview', *index)
+ self
+ end
+ end
+ def xview_moveto(*index)
+ xview('moveto', *index)
+ end
+ def xview_scroll(*index)
+ xview('scroll', *index)
+ end
+
+ def yview(*index)
+ if index.size == 0
+ list(tk_send_without_enc('yview'))
+ else
+ tk_send_without_enc('yview', *index)
+ self
+ end
+ end
+ def yview_moveto(*index)
+ yview('moveto', *index)
+ end
+ def yview_scroll(*index)
+ yview('scroll', *index)
+ end
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/iwidgets/scrolledwidget.rb b/jni/ruby/ext/tk/lib/tkextlib/iwidgets/scrolledwidget.rb
new file mode 100644
index 0000000..5ecd2d7
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/iwidgets/scrolledwidget.rb
@@ -0,0 +1,20 @@
+#
+# tkextlib/iwidgets/scrolledwidget.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+
+require 'tk'
+require 'tkextlib/iwidgets.rb'
+
+module Tk
+ module Iwidgets
+ class Scrolledwidget < Tk::Iwidgets::Labeledwidget
+ end
+ end
+end
+
+class Tk::Iwidgets::Scrolledwidget
+ TkCommandNames = ['::iwidgets::scrolledwidget'.freeze].freeze
+ WidgetClassName = 'Scrolledwidget'.freeze
+ WidgetClassNames[WidgetClassName] ||= self
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/iwidgets/selectionbox.rb b/jni/ruby/ext/tk/lib/tkextlib/iwidgets/selectionbox.rb
new file mode 100644
index 0000000..eb8fe3a
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/iwidgets/selectionbox.rb
@@ -0,0 +1,102 @@
+#
+# tkextlib/iwidgets/selectionbox.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+
+require 'tk'
+require 'tkextlib/iwidgets.rb'
+
+module Tk
+ module Iwidgets
+ class Selectionbox < Tk::Itk::Widget
+ end
+ end
+end
+
+class Tk::Iwidgets::Selectionbox
+ TkCommandNames = ['::iwidgets::selectionbox'.freeze].freeze
+ WidgetClassName = 'Selectionbox'.freeze
+ WidgetClassNames[WidgetClassName] ||= self
+
+ def __boolval_optkeys
+ super() << 'itemson' << 'selectionon'
+ end
+ private :__boolval_optkeys
+
+ def __strval_optkeys
+ super() << 'itemslabel' << 'selectionlabel'
+ end
+ private :__strval_optkeys
+
+ def child_site
+ window(tk_call(@path, 'childsite'))
+ end
+
+ def clear_items
+ tk_call(@path, 'clear', 'items')
+ self
+ end
+
+ def clear_selection
+ tk_call(@path, 'clear', 'selection')
+ self
+ end
+
+ def get
+ tk_call(@path, 'get')
+ end
+
+ def insert_items(idx, *args)
+ tk_call(@path, 'insert', 'items', idx, *args)
+ end
+
+ def insert_selection(pos, text)
+ tk_call(@path, 'insert', 'selection', pos, text)
+ end
+
+ def select_item
+ tk_call(@path, 'selectitem')
+ self
+ end
+
+ # based on Tk::Listbox ( and TkTextWin )
+ def curselection
+ list(tk_send_without_enc('curselection'))
+ end
+ def delete(first, last=None)
+ tk_send_without_enc('delete', first, last)
+ self
+ end
+ def index(idx)
+ tk_send_without_enc('index', idx).to_i
+ end
+ def nearest(y)
+ tk_send_without_enc('nearest', y).to_i
+ end
+ def scan_mark(x, y)
+ tk_send_without_enc('scan', 'mark', x, y)
+ self
+ end
+ def scan_dragto(x, y)
+ tk_send_without_enc('scan', 'dragto', x, y)
+ self
+ end
+ def selection_anchor(index)
+ tk_send_without_enc('selection', 'anchor', index)
+ self
+ end
+ def selection_clear(first, last=None)
+ tk_send_without_enc('selection', 'clear', first, last)
+ self
+ end
+ def selection_includes(index)
+ bool(tk_send_without_enc('selection', 'includes', index))
+ end
+ def selection_set(first, last=None)
+ tk_send_without_enc('selection', 'set', first, last)
+ self
+ end
+ def size
+ tk_send_without_enc('size').to_i
+ end
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/iwidgets/selectiondialog.rb b/jni/ruby/ext/tk/lib/tkextlib/iwidgets/selectiondialog.rb
new file mode 100644
index 0000000..45aecf3
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/iwidgets/selectiondialog.rb
@@ -0,0 +1,92 @@
+#
+# tkextlib/iwidgets/selectiondialog.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+
+require 'tk'
+require 'tkextlib/iwidgets.rb'
+
+module Tk
+ module Iwidgets
+ class Selectiondialog < Tk::Iwidgets::Dialog
+ end
+ end
+end
+
+class Tk::Iwidgets::Selectiondialog
+ TkCommandNames = ['::iwidgets::selectiondialog'.freeze].freeze
+ WidgetClassName = 'Selectiondialog'.freeze
+ WidgetClassNames[WidgetClassName] ||= self
+
+ def child_site
+ window(tk_call(@path, 'childsite'))
+ end
+
+ def clear_items
+ tk_call(@path, 'clear', 'items')
+ self
+ end
+
+ def clear_selection
+ tk_call(@path, 'clear', 'selection')
+ self
+ end
+
+ def get
+ tk_call(@path, 'get')
+ end
+
+ def insert_items(idx, *args)
+ tk_call(@path, 'insert', 'items', idx, *args)
+ end
+
+ def insert_selection(pos, text)
+ tk_call(@path, 'insert', 'selection', pos, text)
+ end
+
+ def select_item
+ tk_call(@path, 'selectitem')
+ self
+ end
+
+ # based on Tk::Listbox ( and TkTextWin )
+ def curselection
+ list(tk_send_without_enc('curselection'))
+ end
+ def delete(first, last=None)
+ tk_send_without_enc('delete', first, last)
+ self
+ end
+ def index(idx)
+ tk_send_without_enc('index', idx).to_i
+ end
+ def nearest(y)
+ tk_send_without_enc('nearest', y).to_i
+ end
+ def scan_mark(x, y)
+ tk_send_without_enc('scan', 'mark', x, y)
+ self
+ end
+ def scan_dragto(x, y)
+ tk_send_without_enc('scan', 'dragto', x, y)
+ self
+ end
+ def selection_anchor(index)
+ tk_send_without_enc('selection', 'anchor', index)
+ self
+ end
+ def selection_clear(first, last=None)
+ tk_send_without_enc('selection', 'clear', first, last)
+ self
+ end
+ def selection_includes(index)
+ bool(tk_send_without_enc('selection', 'includes', index))
+ end
+ def selection_set(first, last=None)
+ tk_send_without_enc('selection', 'set', first, last)
+ self
+ end
+ def size
+ tk_send_without_enc('size').to_i
+ end
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/iwidgets/setup.rb b/jni/ruby/ext/tk/lib/tkextlib/iwidgets/setup.rb
new file mode 100644
index 0000000..ee406c6
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/iwidgets/setup.rb
@@ -0,0 +1,8 @@
+#
+# setup.rb -- setup script before calling TkPackage.require()
+#
+# If you need some setup operations (for example, add a library path
+# to the library search path) before using Tcl/Tk library packages
+# wrapped by Ruby scripts in this directory, please write the setup
+# operations in this file.
+#
diff --git a/jni/ruby/ext/tk/lib/tkextlib/iwidgets/shell.rb b/jni/ruby/ext/tk/lib/tkextlib/iwidgets/shell.rb
new file mode 100644
index 0000000..c560e3a
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/iwidgets/shell.rb
@@ -0,0 +1,38 @@
+#
+# tkextlib/iwidgets/shell.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+
+require 'tk'
+require 'tkextlib/iwidgets.rb'
+
+module Tk
+ module Iwidgets
+ class Shell < Tk::Itk::Toplevel
+ end
+ end
+end
+
+class Tk::Iwidgets::Shell
+ TkCommandNames = ['::iwidgets::shell'.freeze].freeze
+ WidgetClassName = 'Shell'.freeze
+ WidgetClassNames[WidgetClassName] ||= self
+
+ def activate
+ tk_call(@path, 'activate') # may return val of deactibate method
+ end
+
+ def center(win=None)
+ tk_call(@path, 'center', win)
+ self
+ end
+
+ def child_site
+ window(tk_call(@path, 'childsite'))
+ end
+
+ def deactivate(val=None)
+ tk_call(@path, 'deactivate', val)
+ self
+ end
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/iwidgets/spindate.rb b/jni/ruby/ext/tk/lib/tkextlib/iwidgets/spindate.rb
new file mode 100644
index 0000000..b3de9ed
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/iwidgets/spindate.rb
@@ -0,0 +1,48 @@
+#
+# tkextlib/iwidgets/spindate.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+
+require 'tk'
+require 'tkextlib/iwidgets.rb'
+
+module Tk
+ module Iwidgets
+ class Spindate < Tk::Itk::Widget
+ end
+ end
+end
+
+class Tk::Iwidgets::Spindate
+ TkCommandNames = ['::iwidgets::spindate'.freeze].freeze
+ WidgetClassName = 'Spindate'.freeze
+ WidgetClassNames[WidgetClassName] ||= self
+
+ def __boolval_optkeys
+ super() << 'dayon' << 'monthon' << 'yearon'
+ end
+ private :__boolval_optkeys
+
+ def __strval_optkeys
+ super() << 'daylabel' << 'monthformat' << 'monthlabel' << 'yearlabel'
+ end
+ private :__strval_optkeys
+
+ def get_string
+ tk_call(@path, 'get', '-string')
+ end
+ alias get get_string
+
+ def get_clicks
+ number(tk_call(@path, 'get', '-clicks'))
+ end
+
+ def show(date=None)
+ tk_call(@path, 'show', date)
+ self
+ end
+ def show_now
+ tk_call(@path, 'show', 'now')
+ self
+ end
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/iwidgets/spinint.rb b/jni/ruby/ext/tk/lib/tkextlib/iwidgets/spinint.rb
new file mode 100644
index 0000000..bede3bb
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/iwidgets/spinint.rb
@@ -0,0 +1,30 @@
+#
+# tkextlib/iwidgets/spinint.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+
+require 'tk'
+require 'tkextlib/iwidgets.rb'
+
+module Tk
+ module Iwidgets
+ class Spinint < Tk::Iwidgets::Spinner
+ end
+ end
+end
+
+class Tk::Iwidgets::Spinint
+ TkCommandNames = ['::iwidgets::spinint'.freeze].freeze
+ WidgetClassName = 'Spinint'.freeze
+ WidgetClassNames[WidgetClassName] ||= self
+
+ def __boolval_optkeys
+ super() << 'wrap'
+ end
+ private :__boolval_optkeys
+
+ def __numlistval_optkeys
+ super() << 'range'
+ end
+ private :__numlistval_optkeys
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/iwidgets/spinner.rb b/jni/ruby/ext/tk/lib/tkextlib/iwidgets/spinner.rb
new file mode 100644
index 0000000..d960996
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/iwidgets/spinner.rb
@@ -0,0 +1,169 @@
+#
+# tkextlib/iwidgets/spinner.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+
+require 'tk'
+require 'tkextlib/iwidgets.rb'
+
+module Tk
+ module Iwidgets
+ class Spinner < Tk::Iwidgets::Labeledwidget
+ end
+ end
+end
+
+class Tk::Iwidgets::Spinner
+ TkCommandNames = ['::iwidgets::spinner'.freeze].freeze
+ WidgetClassName = 'Spinner'.freeze
+ WidgetClassNames[WidgetClassName] ||= self
+
+ ####################################
+
+ include Tk::ValidateConfigure
+
+ class EntryfieldValidate < TkValidateCommand
+ #class CalCmdArgs < TkUtil::CallbackSubst
+ class ValidateArgs < TkUtil::CallbackSubst
+ KEY_TBL = [
+ [ ?c, ?s, :char ],
+ [ ?P, ?s, :post ],
+ [ ?S, ?s, :current ],
+ [ ?W, ?w, :widget ],
+ nil
+ ]
+ PROC_TBL = [
+ [ ?s, TkComm.method(:string) ],
+ [ ?w, TkComm.method(:window) ],
+ nil
+ ]
+
+=begin
+ # for Ruby m17n :: ?x --> String --> char-code ( getbyte(0) )
+ KEY_TBL.map!{|inf|
+ if inf.kind_of?(Array)
+ inf[0] = inf[0].getbyte(0) if inf[0].kind_of?(String)
+ inf[1] = inf[1].getbyte(0) if inf[1].kind_of?(String)
+ end
+ inf
+ }
+
+ PROC_TBL.map!{|inf|
+ if inf.kind_of?(Array)
+ inf[0] = inf[0].getbyte(0) if inf[0].kind_of?(String)
+ end
+ inf
+ }
+=end
+
+ _setup_subst_table(KEY_TBL, PROC_TBL);
+ end
+
+ def self._config_keys
+ ['validate', 'invalid']
+ end
+ end
+
+ def __validation_class_list
+ super() << EntryfieldValidate
+ end
+
+ Tk::ValidateConfigure.__def_validcmd(binding, EntryfieldValidate)
+
+ ####################################
+
+ def up
+ tk_call_without_enc(@path, 'up')
+ self
+ end
+
+ def down
+ tk_call_without_enc(@path, 'down')
+ self
+ end
+
+ def clear
+ tk_call_without_enc(@path, 'clear')
+ self
+ end
+
+ def delete(first, last=None)
+ tk_send_without_enc('delete', first, last)
+ self
+ end
+
+ def value
+ _fromUTF8(tk_send_without_enc('get'))
+ end
+ def value= (val)
+ tk_send_without_enc('delete', 0, 'end')
+ tk_send_without_enc('insert', 0, _get_eval_enc_str(val))
+ val
+ end
+ alias get value
+ alias set value=
+
+ def cursor=(index)
+ tk_send_without_enc('icursor', index)
+ #self
+ index
+ end
+ alias icursor cursor=
+
+ def index(idx)
+ number(tk_send_without_enc('index', idx))
+ end
+
+ def insert(pos,text)
+ tk_send_without_enc('insert', pos, _get_eval_enc_str(text))
+ self
+ end
+
+ def mark(pos)
+ tk_send_without_enc('scan', 'mark', pos)
+ self
+ end
+ def dragto(pos)
+ tk_send_without_enc('scan', 'dragto', pos)
+ self
+ end
+ def selection_adjust(index)
+ tk_send_without_enc('selection', 'adjust', index)
+ self
+ end
+ def selection_clear
+ tk_send_without_enc('selection', 'clear')
+ self
+ end
+ def selection_from(index)
+ tk_send_without_enc('selection', 'from', index)
+ self
+ end
+ def selection_present()
+ bool(tk_send_without_enc('selection', 'present'))
+ end
+ def selection_range(s, e)
+ tk_send_without_enc('selection', 'range', s, e)
+ self
+ end
+ def selection_to(index)
+ tk_send_without_enc('selection', 'to', index)
+ self
+ end
+
+ # based on tk/scrollable.rb
+ def xview(*index)
+ if index.size == 0
+ list(tk_send_without_enc('xview'))
+ else
+ tk_send_without_enc('xview', *index)
+ self
+ end
+ end
+ def xview_moveto(*index)
+ xview('moveto', *index)
+ end
+ def xview_scroll(*index)
+ xview('scroll', *index)
+ end
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/iwidgets/spintime.rb b/jni/ruby/ext/tk/lib/tkextlib/iwidgets/spintime.rb
new file mode 100644
index 0000000..20f8197
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/iwidgets/spintime.rb
@@ -0,0 +1,48 @@
+#
+# tkextlib/iwidgets/spintime.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+
+require 'tk'
+require 'tkextlib/iwidgets.rb'
+
+module Tk
+ module Iwidgets
+ class Spintime < Tk::Itk::Widget
+ end
+ end
+end
+
+class Tk::Iwidgets::Spintime
+ TkCommandNames = ['::iwidgets::spintime'.freeze].freeze
+ WidgetClassName = 'Spintime'.freeze
+ WidgetClassNames[WidgetClassName] ||= self
+
+ def __boolval_optkeys
+ super() << 'houron' << 'militaryon' << 'minutelabel' << 'secondlabel'
+ end
+ private :__boolval_optkeys
+
+ def __strval_optkeys
+ super() << 'hourlabel' << 'minuteon' << 'secondon'
+ end
+ private :__strval_optkeys
+
+ def get_string
+ tk_call(@path, 'get', '-string')
+ end
+ alias get get_string
+
+ def get_clicks
+ number(tk_call(@path, 'get', '-clicks'))
+ end
+
+ def show(date=None)
+ tk_call(@path, 'show', date)
+ self
+ end
+ def show_now
+ tk_call(@path, 'show', 'now')
+ self
+ end
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/iwidgets/tabnotebook.rb b/jni/ruby/ext/tk/lib/tkextlib/iwidgets/tabnotebook.rb
new file mode 100644
index 0000000..f56efa9
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/iwidgets/tabnotebook.rb
@@ -0,0 +1,181 @@
+#
+# tkextlib/iwidgets/tabnotebook.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+
+require 'tk'
+require 'tkextlib/iwidgets.rb'
+
+module Tk
+ module Iwidgets
+ class Tabnotebook < Tk::Itk::Widget
+ end
+ end
+end
+
+class Tk::Iwidgets::Tabnotebook
+ TkCommandNames = ['::iwidgets::tabnotebook'.freeze].freeze
+ WidgetClassName = 'Tabnotebook'.freeze
+ WidgetClassNames[WidgetClassName] ||= self
+
+ ####################################
+
+ include TkItemConfigMethod
+
+ def __item_cget_cmd(id)
+ [self.path, 'pagecget', id]
+ end
+ private :__item_cget_cmd
+
+ def __item_config_cmd(id)
+ [self.path, 'pageconfigure', id]
+ end
+ private :__item_config_cmd
+
+ def __item_strval_optkeys(id)
+ super(id) << 'tabbackground' << 'tabforeground'
+ end
+ private :__item_strval_optkeys
+
+ def tagid(tagOrId)
+ if tagOrId.kind_of?(Tk::Itk::Component)
+ tagOrId.name
+ else
+ #_get_eval_string(tagOrId)
+ tagOrId
+ end
+ end
+
+ alias pagecget_tkstring itemcget_tkstring
+ alias pagecget itemcget
+ alias pagecget_strict itemcget_strict
+ alias pageconfigure itemconfigure
+ alias pageconfiginfo itemconfiginfo
+ alias current_pageconfiginfo current_itemconfiginfo
+
+ private :itemcget_tkstring, :itemcget, :itemcget_strict
+ private :itemconfigure, :itemconfiginfo, :current_itemconfiginfo
+
+ ####################################
+
+ def __boolval_optkeys
+ super() << 'auto' << 'equaltabs' << 'raiseselect' << 'tabborders'
+ end
+ private :__boolval_optkeys
+
+ def __strval_optkeys
+ super() << 'backdrop' << 'tabbackground' << 'tabforeground'
+ end
+ private :__strval_optkeys
+
+ def initialize(*args)
+ super(*args)
+ @tabset = self.component_widget('tabset')
+ end
+
+ def add(keys={})
+ window(tk_call(@path, 'add', *hash_kv(keys)))
+ end
+
+ def child_site_list
+ list(tk_call(@path, 'childsite'))
+ end
+
+ def child_site(idx)
+ window(tk_call(@path, 'childsite', index(idx)))
+ end
+
+ def delete(idx1, idx2=nil)
+ if idx2
+ tk_call(@path, 'delete', index(idx1), index(idx2))
+ else
+ tk_call(@path, 'delete', index(idx1))
+ end
+ self
+ end
+
+ def index(idx)
+ #number(tk_call(@path, 'index', tagid(idx)))
+ @tabset.index(tagid(idx))
+ end
+
+ def insert(idx, keys={})
+ window(tk_call(@path, 'insert', index(idx), *hash_kv(keys)))
+ end
+
+ def next
+ tk_call(@path, 'next')
+ self
+ end
+
+ def prev
+ tk_call(@path, 'prev')
+ self
+ end
+
+ def select(idx)
+ tk_call(@path, 'select', index(idx))
+ self
+ end
+
+ def show_tab(idx)
+ @tabset.show_tab(idx)
+ self
+ end
+
+ def scrollcommand(cmd=Proc.new)
+ configure_cmd 'scrollcommand', cmd
+ self
+ end
+ alias xscrollcommand scrollcommand
+ alias yscrollcommand scrollcommand
+
+ def xscrollbar(bar=nil)
+ if bar
+ @scrollbar = bar
+ @scrollbar.orient 'horizontal'
+ self.scrollcommand {|*arg| @scrollbar.set(*arg)}
+ @scrollbar.command {|*arg| self.xview(*arg)}
+ Tk.update # avoid scrollbar trouble
+ end
+ @scrollbar
+ end
+ def yscrollbar(bar=nil)
+ if bar
+ @scrollbar = bar
+ @scrollbar.orient 'vertical'
+ self.scrollcommand {|*arg| @scrollbar.set(*arg)}
+ @scrollbar.command {|*arg| self.yview(*arg)}
+ Tk.update # avoid scrollbar trouble
+ end
+ @scrollbar
+ end
+ alias scrollbar yscrollbar
+
+ def view(*index)
+ if index.size == 0
+ idx = num_or_str(tk_send_without_enc('view'))
+ if idx.kind_of?(Fixnum) && idx < 0
+ nil
+ else
+ idx
+ end
+ else
+ tk_send_without_enc('view', *index)
+ self
+ end
+ end
+ alias xview view
+ alias yview view
+
+ def view_moveto(*index)
+ view('moveto', *index)
+ end
+ alias xview_moveto view_moveto
+ alias yview_moveto view_moveto
+ def view_scroll(index, what='pages')
+ view('scroll', index, what)
+ end
+ alias xview_scroll view_scroll
+ alias yview_scroll view_scroll
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/iwidgets/tabset.rb b/jni/ruby/ext/tk/lib/tkextlib/iwidgets/tabset.rb
new file mode 100644
index 0000000..501ead4
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/iwidgets/tabset.rb
@@ -0,0 +1,145 @@
+#
+# tkextlib/iwidgets/tabset.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+
+require 'tk'
+require 'tkextlib/iwidgets.rb'
+
+module Tk
+ module Iwidgets
+ class Tabset < Tk::Itk::Widget
+ end
+ end
+end
+
+class Tk::Iwidgets::Tabset
+ TkCommandNames = ['::iwidgets::tabset'.freeze].freeze
+ WidgetClassName = 'Tabset'.freeze
+ WidgetClassNames[WidgetClassName] ||= self
+
+ ####################################
+
+ include TkItemConfigMethod
+
+ def __item_cget_cmd(id)
+ [self.path, 'tabcget', id]
+ end
+ private :__item_cget_cmd
+
+ def __item_config_cmd(id)
+ [self.path, 'tabconfigure', id]
+ end
+ private :__item_config_cmd
+
+ def tagid(tagOrId)
+ if tagOrId.kind_of?(Tk::Itk::Component)
+ tagOrId.name
+ else
+ #_get_eval_string(tagOrId)
+ tagOrId
+ end
+ end
+
+ alias tabcget_tkstring itemcget_tkstring
+ alias tabcget itemcget
+ alias tabcget_strict itemcget_strict
+ alias tabconfigure itemconfigure
+ alias tabconfiginfo itemconfiginfo
+ alias current_tabconfiginfo current_itemconfiginfo
+
+ private :itemcget_tkstring, :itemcget, :itemcget_strict
+ private :itemconfigure, :itemconfiginfo, :current_itemconfiginfo
+
+ ####################################
+
+ def __boolval_optkeys
+ super() << 'equaltabs' << 'raiseselect' << 'tabborders'
+ end
+ private :__boolval_optkeys
+
+ def __strval_optkeys
+ super() << 'backdrop'
+ end
+ private :__strval_optkeys
+
+ def add(keys={})
+ window(tk_call(@path, 'add', *hash_kv(keys)))
+ end
+
+ def delete(idx1, idx2=nil)
+ if idx2
+ tk_call(@path, 'delete', index(idx1), index(idx2))
+ else
+ tk_call(@path, 'delete', index(idx1))
+ end
+ self
+ end
+
+ def index(idx)
+ number(tk_call(@path, 'index', tagid(idx)))
+ end
+
+ def insert(idx, keys={})
+ window(tk_call(@path, 'insert', index(idx), *hash_kv(keys)))
+ end
+
+ def next
+ tk_call(@path, 'next')
+ self
+ end
+
+ def prev
+ tk_call(@path, 'prev')
+ self
+ end
+
+ def select(idx)
+ tk_call(@path, 'select', index(idx))
+ self
+ end
+
+ def show_tab(idx)
+ if index(idx) == 0
+ self.start = 0
+ return
+ end
+
+ reutrn unless @canvas ||= self.winfo_children[0]
+
+ delta = 1 if (delta = cget(:gap)) == 'overlap' ||
+ (delta = self.winfo_pixels(delta) + 1) <= 0
+
+ case cget(:tabpos)
+ when 's', 'n'
+ if (head = tabcget(idx, :left)) < 0
+ self.start -= head
+ return
+ end
+ tabs_size = @canvas.winfo_width
+ tab_start, tab_end = @canvas .
+ find_overlapping(head, 0, head + delta, @canvas.winfo_height) .
+ find_all{|id| @canvas.itemtype(id) == TkcPolygon} .
+ map!{|id| bbox = @canvas.bbox(id); [bbox[0], bbox[2]]} . max
+
+ when 'e', 'w'
+ if (head = tabcget(idx, :top)) < 0
+ self.start -= head
+ return
+ end
+ tabs_size = @canvas.winfo_height
+ tab_start, tab_end = @canvas .
+ find_overlapping(0, head, @canvas.winfo_width, head + delta) .
+ find_all{|id| @canvas.itemtype(id) == TkcPolygon} .
+ map!{|id| bbox = @canvas.bbox(id); [bbox[1], bbox[3]]} . max
+ end
+
+ if (size = tab_end - tab_start + 1) > tabs_size
+ self.start -= tab_start
+ elsif head + size > tabs_size
+ self.start -= head + size - tabs_size
+ end
+
+ self
+ end
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/iwidgets/timeentry.rb b/jni/ruby/ext/tk/lib/tkextlib/iwidgets/timeentry.rb
new file mode 100644
index 0000000..b0afb3a
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/iwidgets/timeentry.rb
@@ -0,0 +1,25 @@
+#
+# tkextlib/iwidgets/timeentry.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+
+require 'tk'
+require 'tkextlib/iwidgets.rb'
+
+module Tk
+ module Iwidgets
+ class Timeentry < Tk::Iwidgets::Timefield
+ end
+ end
+end
+
+class Tk::Iwidgets::Timeentry
+ TkCommandNames = ['::iwidgets::timeentry'.freeze].freeze
+ WidgetClassName = 'Timeentry'.freeze
+ WidgetClassNames[WidgetClassName] ||= self
+
+ def __strval_optkeys
+ super() << 'closetext'
+ end
+ private :__strval_optkeys
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/iwidgets/timefield.rb b/jni/ruby/ext/tk/lib/tkextlib/iwidgets/timefield.rb
new file mode 100644
index 0000000..c34281d
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/iwidgets/timefield.rb
@@ -0,0 +1,58 @@
+#
+# tkextlib/iwidgets/timefield.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+
+require 'tk'
+require 'tkextlib/iwidgets.rb'
+
+module Tk
+ module Iwidgets
+ class Timefield < Tk::Iwidgets::Labeledwidget
+ end
+ end
+end
+
+class Tk::Iwidgets::Timefield
+ TkCommandNames = ['::iwidgets::timefield'.freeze].freeze
+ WidgetClassName = 'Timefield'.freeze
+ WidgetClassNames[WidgetClassName] ||= self
+
+ def __boolval_optkeys
+ super() << 'gmt'
+ end
+ private :__boolval_optkeys
+
+ def __strval_optkeys
+ super() << 'textbackground'
+ end
+ private :__strval_optkeys
+
+ def __font_optkeys
+ super() << 'textfont'
+ end
+ private :__font_optkeys
+
+ def get_string
+ tk_call(@path, 'get', '-string')
+ end
+ alias get get_string
+
+ def get_clicks
+ number(tk_call(@path, 'get', '-clicks'))
+ end
+
+ def valid?
+ bool(tk_call(@path, 'isvalid'))
+ end
+ alias isvalid? valid?
+
+ def show(time=None)
+ tk_call(@path, 'show', time)
+ self
+ end
+ def show_now
+ tk_call(@path, 'show', 'now')
+ self
+ end
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/iwidgets/toolbar.rb b/jni/ruby/ext/tk/lib/tkextlib/iwidgets/toolbar.rb
new file mode 100644
index 0000000..5b474c3
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/iwidgets/toolbar.rb
@@ -0,0 +1,112 @@
+#
+# tkextlib/iwidgets/toolbar.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+
+require 'tk'
+require 'tkextlib/iwidgets.rb'
+
+module Tk
+ module Iwidgets
+ class Toolbar < Tk::Itk::Widget
+ end
+ end
+end
+
+class Tk::Iwidgets::Toolbar
+ TkCommandNames = ['::iwidgets::toolbar'.freeze].freeze
+ WidgetClassName = 'Toolbar'.freeze
+ WidgetClassNames[WidgetClassName] ||= self
+
+ def __tkvariable_optkeys
+ super() << 'helpvariable'
+ end
+ private :__tkvariable_optkeys
+
+ ####################################
+
+ include TkItemConfigMethod
+
+ def __item_cget_cmd(id)
+ [self.path, 'itemcget', self.index(id)]
+ end
+ private :__item_cget_cmd
+
+ def __item_config_cmd(id)
+ [self.path, 'itemconfigure', self.index(id)]
+ end
+ private :__item_config_cmd
+
+ def __item_strval_optkeys(id)
+ super(id) << 'helpstr' << 'balloonstr'
+ end
+ private :__item_strval_optkeys
+
+ def tagid(tagOrId)
+ if tagOrId.kind_of?(Tk::Itk::Component)
+ tagOrId.name
+ else
+ #_get_eval_string(tagOrId)
+ tagOrId
+ end
+ end
+
+ ####################################
+
+ def __strval_optkeys
+ super() << 'balloonbackground' << 'balloonforeground'
+ end
+ private :__strval_optkeys
+
+ def __tkvariable_optkeys
+ super() << 'helpvariable'
+ end
+ private :__tkvariable_optkeys
+
+ def __font_optkeys
+ super() << 'balloonfont'
+ end
+ private :__font_optkeys
+
+ def add(type, tag=nil, keys={})
+ if tag.kind_of?(Hash)
+ keys = tag
+ tag = nil
+ end
+ if tag
+ tag = Tk::Itk::Component.new(self, tagid(tag))
+ else
+ tag = Tk::Itk::Component.new(self)
+ end
+ window(tk_call(@path, 'add', type, tagid(tag), *hash_kv(keys)))
+ tag
+ end
+
+ def delete(idx1, idx2=nil)
+ if idx2
+ tk_call(@path, 'delete', index(idx1), index(idx2))
+ else
+ tk_call(@path, 'delete', index(idx1))
+ end
+ self
+ end
+
+ def index(idx)
+ number(tk_call(@path, 'index', tagid(idx)))
+ end
+
+ def insert(idx, type, tag=nil, keys={})
+ if tag.kind_of?(Hash)
+ keys = tag
+ tag = nil
+ end
+ if tag
+ tag = Tk::Itk::Component.new(self, tagid(tag))
+ else
+ tag = Tk::Itk::Component.new(self)
+ end
+ window(tk_call(@path, 'insert', index(idx), type,
+ tagid(tag), *hash_kv(keys)))
+ tag
+ end
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/iwidgets/watch.rb b/jni/ruby/ext/tk/lib/tkextlib/iwidgets/watch.rb
new file mode 100644
index 0000000..f10ec54
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/iwidgets/watch.rb
@@ -0,0 +1,56 @@
+#
+# tkextlib/iwidgets/watch.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+
+require 'tk'
+require 'tkextlib/iwidgets.rb'
+
+module Tk
+ module Iwidgets
+ class Watch < Tk::Itk::Widget
+ end
+ end
+end
+
+class Tk::Iwidgets::Watch
+ TkCommandNames = ['::iwidgets::watch'.freeze].freeze
+ WidgetClassName = 'Watch'.freeze
+ WidgetClassNames[WidgetClassName] ||= self
+
+ def __boolval_optkeys
+ super() << 'showampm'
+ end
+ private :__boolval_optkeys
+
+ def __strval_optkeys
+ super() << 'clockcolor' << 'hourcolor' << 'minutecolor' <<
+ 'pivotcolor' << 'secondcolor' << 'tickcolor'
+ end
+ private :__strval_optkeys
+
+ def get_string
+ tk_call(@path, 'get', '-string')
+ end
+ alias get get_string
+
+ def get_clicks
+ number(tk_call(@path, 'get', '-clicks'))
+ end
+
+ def show(time=None)
+ tk_call(@path, 'show', time)
+ self
+ end
+ def show_now
+ tk_call(@path, 'show', 'now')
+ self
+ end
+
+ def watch(*args)
+ unless args.empty?
+ tk_call(@path, 'watch', *args)
+ end
+ component_path('canvas')
+ end
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/pkg_checker.rb b/jni/ruby/ext/tk/lib/tkextlib/pkg_checker.rb
new file mode 100755
index 0000000..e2fd97b
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/pkg_checker.rb
@@ -0,0 +1,184 @@
+#!/usr/bin/env ruby
+#
+# Ruby/Tk extension library checker
+#
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+require 'tk'
+
+TkRoot.new.withdraw # hide root window
+
+name = File.basename(__FILE__)
+
+add_path = false
+verbose = false
+
+def help_msg
+ print "Usage: #{$0} [-l] [-v] [-h] [--] [dir]\n"
+ print "\tIf dir is omitted, check the directory that this command exists.\n"
+ print "\tAvailable options are \n"
+ print "\t -l : Add dir to $LOAD_PATH\n"
+ print "\t (If dir == '<parent>/tkextlib', add <parent> also.)\n"
+ print "\t -v : Verbose mode (show reason of fail)\n"
+ print "\t -h : Show this message\n"
+ print "\t -- : End of options\n"
+end
+
+while(ARGV[0] && ARGV[0][0] == ?-)
+ case ARGV[0]
+ when '--'
+ ARGV.shift
+ break;
+ when '-l'
+ ARGV.shift
+ add_path = true
+ when '-v'
+ ARGV.shift
+ verbose = true
+ when '-h'
+ help_msg
+ exit(0)
+ else
+ print "Argument Error!! : unknown option '#{ARGV[0]}'\n"
+ help_msg
+ exit(1)
+ end
+end
+
+if ARGV[0]
+ dir = File.expand_path(ARGV[0])
+else
+ dir = File.dirname(File.expand_path(__FILE__))
+end
+
+if add_path
+ $LOAD_PATH.unshift(dir)
+ if File.basename(dir) == 'tkextlib'
+ $LOAD_PATH.unshift(File.dirname(dir))
+ end
+end
+
+print "\nRuby/Tk extension library checker\n"
+print "( Note:: This check is very simple one. Shown status may be wrong. )\n"
+print "\n check directory :: #{dir}"
+print "\n $LOAD_PATH :: #{$LOAD_PATH.inspect}\n"
+
+def get_pkg_list(file)
+ pkg_list = []
+
+ File.foreach(file){|l|
+ if l =~ /^(?:[^#]+\s|\s*)(?:|;\s*)TkPackage\s*\.\s*require\s*\(?\s*(["'])((\w|:)+)\1/
+ pkg = [$2, :package]
+ pkg_list << pkg unless pkg_list.member?(pkg)
+ end
+ if l =~ /^(?:[^#]+\s|\s*)(?:|;\s*)Tk\s*\.\s*load_tcllibrary\s*\(?\s*(["'])((\w|:)+)\1/
+ pkg = [$2, :library]
+ pkg_list << pkg unless pkg_list.member?(pkg)
+ end
+ if l =~ /^(?:[^#]+\s|\s*)(?:|;\s*)Tk\s*\.\s*load_tclscript\s*\(?\s*(["'])((\w|:)+)\1/
+ pkg = [$2, :script]
+ pkg_list << pkg unless pkg_list.member?(pkg)
+ end
+ if l =~ /^(?:[^#]+\s|\s*)(?:|;\s*)require\s*\(?\s*(["'])((\w|\/|:)+)\1/
+ pkg = [$2, :require_ruby_lib]
+ pkg_list << pkg unless pkg_list.member?(pkg)
+ end
+ }
+
+ pkg_list
+end
+
+def check_pkg(file, verbose=false)
+ pkg_list = get_pkg_list(file)
+
+ error_list = []
+ success_list = {}
+
+ pkg_list.each{|name, type|
+ next if success_list[name]
+
+ begin
+ case type
+ when :package
+ ver = TkPackage.require(name)
+ success_list[name] = ver
+ error_list.delete_if{|n, t| n == name}
+
+ when :library
+ Tk.load_tcllibrary(name)
+ success_list[name] = :library
+ error_list.delete_if{|n, t| n == name}
+
+ when :script
+ Tk.load_tclscript(name)
+ success_list[name] = :script
+ error_list.delete_if{|n, t| n == name}
+
+ when :require_ruby_lib
+ require name
+
+ end
+ rescue => e
+ if verbose
+ error_list << [name, type, e.message]
+ else
+ error_list << [name, type]
+ end
+ end
+ }
+
+ success_list.dup.each{|name, ver|
+ unless ver.kind_of?(String)
+ begin
+ ver = TkPackage.require(name)
+ sccess_list[name] = ver
+ rescue
+ end
+ end
+ }
+
+ [success_list, error_list]
+end
+
+def subdir_check(dir, verbose=false)
+ Dir.foreach(dir){|f|
+ next if f == '.' || f == '..'
+ if File.directory?(f)
+ subdir_check(File.join(dir, f))
+ elsif File.extname(f) == '.rb'
+ path = File.join(dir, f)
+ suc, err = check_pkg(path, verbose)
+ if err.empty?
+ print 'Ready : ', path, ' : require->', suc.inspect, "\n"
+ else
+ print '*LACK : ', path, ' : require->', suc.inspect,
+ ' FAIL->', err.inspect, "\n"
+ end
+ end
+ }
+end
+
+Dir.chdir(dir)
+
+(Dir['*.rb'] - ['setup.rb', name]).each{|f|
+ subdir = File.basename(f, '.*')
+=begin
+ begin
+ # read 'setup.rb' as if the library has standard structure
+ require File.join(subdir, 'setup.rb')
+ rescue LoadError
+ # ignore error
+ end
+=end
+ print "\n"
+
+ suc, err = check_pkg(f, verbose)
+ if err.empty?
+ print 'Ready : ', f, ' : require->', suc.inspect, "\n"
+ else
+ print '*LACK : ', f, ' : require->', suc.inspect,
+ ' FAIL->', err.inspect, "\n"
+ end
+
+ subdir_check(subdir, verbose) if File.directory?(subdir)
+}
diff --git a/jni/ruby/ext/tk/lib/tkextlib/setup.rb b/jni/ruby/ext/tk/lib/tkextlib/setup.rb
new file mode 100644
index 0000000..79facc5
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/setup.rb
@@ -0,0 +1,8 @@
+#
+# setup.rb -- setup script before using Tk extension libraries
+#
+# If you need some setup operations for Tk extensions (for example,
+# modify the dynamic library path) required, please write the setup
+# operations in this file. This file is required at the last of
+# "require 'tk'".
+#
diff --git a/jni/ruby/ext/tk/lib/tkextlib/tcllib.rb b/jni/ruby/ext/tk/lib/tkextlib/tcllib.rb
new file mode 100644
index 0000000..2831989
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/tcllib.rb
@@ -0,0 +1,105 @@
+#
+# tcllib extension support
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+
+require 'tk'
+
+# call setup script for general 'tkextlib' libraries
+require 'tkextlib/setup.rb'
+
+# call setup script
+require 'tkextlib/tcllib/setup.rb'
+
+err = ''
+
+# package:: autoscroll
+target = 'tkextlib/tcllib/autoscroll'
+begin
+ require target
+rescue => e
+ err << "\n ['" << target << "'] " << e.class.name << ' : ' << e.message
+end
+
+# package:: cursor
+target = 'tkextlib/tcllib/cursor'
+begin
+ require target
+rescue => e
+ err << "\n ['" << target << "'] " << e.class.name << ' : ' << e.message
+end
+
+# package:: style
+target = 'tkextlib/tcllib/style'
+begin
+ require target
+rescue => e
+ err << "\n ['" << target << "'] " << e.class.name << ' : ' << e.message
+end
+
+# autoload
+module Tk
+ module Tcllib
+ TkComm::TkExtlibAutoloadModule.unshift(self)
+
+ # package:: autoscroll
+ autoload :Autoscroll, 'tkextlib/tcllib/autoscroll'
+
+ # package:: ctext
+ autoload :CText, 'tkextlib/tcllib/ctext'
+
+ # package:: cursor
+ autoload :Cursor, 'tkextlib/tcllib/cursor'
+
+ # package:: datefield
+ autoload :Datefield, 'tkextlib/tcllib/datefield'
+ autoload :DateField, 'tkextlib/tcllib/datefield'
+
+ # package:: getstring
+ autoload :GetString_Dialog, 'tkextlib/tcllib/getstring'
+
+ # package:: history
+ autoload :History, 'tkextlib/tcllib/history'
+
+ # package:: ico
+ autoload :ICO, 'tkextlib/tcllib/ico'
+
+ # package:: ipentry
+ autoload :IP_Entry, 'tkextlib/tcllib/ip_entry'
+ autoload :IPEntry, 'tkextlib/tcllib/ip_entry'
+
+ # package:: khim
+ autoload :KHIM, 'tkextlib/tcllib/khim'
+
+ # package:: ntext
+ autoload :Ntext, 'tkextlib/tcllib/ntext'
+
+ # package:: Plotchart
+ autoload :Plotchart, 'tkextlib/tcllib/plotchart'
+
+ # package:: style
+ autoload :Style, 'tkextlib/tcllib/style'
+
+ # package:: swaplist
+ autoload :Swaplist_Dialog, 'tkextlib/tcllib/swaplist'
+
+ # package:: tablelist
+ autoload :Tablelist, 'tkextlib/tcllib/tablelist'
+ autoload :TableList, 'tkextlib/tcllib/tablelist'
+ autoload :Tablelist_Tile, 'tkextlib/tcllib/tablelist_tile'
+ autoload :TableList_Tile, 'tkextlib/tcllib/tablelist_tile'
+
+ # package:: tkpiechart
+ autoload :Tkpiechart, 'tkextlib/tcllib/tkpiechart'
+
+ # package:: tooltip
+ autoload :Tooltip, 'tkextlib/tcllib/tooltip'
+
+ # package:: widget
+ autoload :Widget, 'tkextlib/tcllib/widget'
+ end
+end
+
+if $VERBOSE && !err.empty?
+ warn("Warning: some sub-packages are failed to require : " + err)
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/tcllib/README b/jni/ruby/ext/tk/lib/tkextlib/tcllib/README
new file mode 100644
index 0000000..441918a
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/tcllib/README
@@ -0,0 +1,135 @@
+
+ [ tcllib extension support files ]
+
+Tcllib includes many utilities. But currently, supports TKLib part
+only (see the following 'tcllib contents').
+
+If you request to support others, please send your message to one of
+ruby-talk/ruby-list/ruby-dev/ruby-ext mailing lists.
+
+-----<from "What is tcllib?">----------------------------
+Tcllib is a collection of utility modules for Tcl. These modules provide
+a wide variety of functionality, from implementations of standard data
+structures to implementations of common networking protocols. The intent
+is to collect commonly used function into a single library, which users
+can rely on to be available and stable.
+---------------------------------------------------------
+
+-----< tcllib contents (based on tcllib-1.6.1) >---------
+Programming tools
+ * cmdline - Procedures to process command lines and options.
+ * comm - A remote communications facility for Tcl (7.6, 8.0, and later)
+ * control - Procedures for control flow structures.
+ * fileutil - Procedures implementing some file utilities
+ * log - Procedures to log messages of libraries and applications.
+ * logger - System to control logging of events.
+ * multiplexer - One-to-many communication with sockets.
+ * snit - Snit's Not Incr Tcl
+ * snitfaq - Snit Frequently Asked Questions
+ * stooop - Object oriented extension.
+ * stoop - Simple Tcl Only Object Oriented Programming
+ * switched - stooop switched class
+ * profiler - Tcl source code profiler
+
+Mathematics
+ * math::statistics - Basic statistical functions and procedures
+ * math::calculus - Integration and ordinary differential equations
+ * math::optimize - Optimisation routines
+ * math::fuzzy - Fuzzy comparison of floating-point numbers
+ * counter - Procedures for counters and histograms
+ * combinatorics - Combinatorial functions in the Tcl Math Library
+
+Data structures
+ * struct::list - Procedures for manipulating lists
+ * struct::set - Procedures for manipulating sets
+ * struct::stack - Create and manipulate stack objects
+ * struct::queue - Create and manipulate queue objects
+ * struct::prioqueue - Create and manipulate prioqueue objects
+ * struct::skiplist - Create and manipulate skiplists
+ * struct::tree - Create and manipulate tree objects
+ * struct::graph - Create and manipulate directed graph objects
+ * struct::record - Define and create records (similar to 'C' structures)
+ * struct::matrix - Create and manipulate matrix objects
+ * struct::pool - Create and manipulate pool objects (of discrete items)
+ * report - Create and manipulate report objects
+
+Text processing
+ * expander - Procedures to process templates and expand text.
+ * base64 - Procedures to encode and decode base64
+ * yencode - encode/decoding a binary file
+ * uuencode - encode/decoding a binary file
+ * csv - Procedures to handle CSV data.
+ * inifile - Parsing of Windows INI files
+ * htmlparse - Procedures to parse HTML strings
+ * mime - Manipulation of MIME body parts
+ * Tcl MIME - generates and parses MIME body parts
+ * textutil - Procedures to manipulate texts and strings.
+ * exif - Tcl EXIF extracts and parses EXIF fields from digital images
+ * EXIF - extract and parse EXIF fields from digital images
+
+Hashes, checksums, and encryption
+ * cksum - calculate a cksum(1) compatible checksum
+ * crc16 - Perform a 16bit Cyclic Redundancy Check
+ * crc32 - Perform a 32bit Cyclic Redundancy Check
+ * des - Perform DES encryption of Tcl data
+ * md4 - MD4 Message-Digest Algorithm
+ * md5 - MD5 Message-Digest Algorithm
+ * ripemd160 - RIPEMD-160 Message-Digest Algorithm
+ * ripemd128 - RIPEMD-128 Message-Digest Algorithm
+ * md5crypt - MD5-based password encryption
+ * sha1 - Perform sha1 hashing
+ * sum - calculate a sum(1) compatible checksum
+ * soundex - Soundex
+
+Documentation tools
+ * mpexpand - Markup processor
+ * doctools - Create and manipulate doctools converter object
+ * doctoc_fmt - Specification of simple tcl markup for table of contents
+ * doctools_api - Interface specification for formatter code
+ * doctools_fmt - Specification of simple tcl markup for manpages
+ * docidx - Create and manipulate docidx converter objects
+ * docidx_api - Interface specification for index formatting code
+ * docidx_fmt - Specification of simple tcl markup for an index
+ * doctoc - Create and manipulate doctoc converter objects
+ * doctoc_api - Interface specification for toc formatting code
+ * doctools::changelog - Handle text in Emacs ChangeLog format
+ * doctools::cvs - Handle text in 'cvs log' format
+
+Networking
+ * uri - URI utilities
+ * dns - Tcl Domain Name Service Client
+ * ntp_time - Tcl Time Service Client
+ * nntp - Tcl client for the NNTP protocol
+ * pop3 - Tcl client for POP3 email protocol
+ * pop3d - Tcl POP3 server implementation
+ * pop3d::udb - Simple user database for pop3d
+ * pop3d::dbox - Simple mailbox database for pop3d
+ * ftp - Client-side tcl implementation of the ftp protocol
+ * ftp - Client-side tcl implementation of the ftp protocol
+ * ftpd - Tcl FTP server implementation
+ * smtp - Client-side tcl implementation of the smtp protocol
+ * smtpd - Tcl SMTP server implementation
+ * irc - Create IRC connection and interface.
+
+CGI programming
+ * ncgi - Procedures to manipulate CGI values.
+ * html - Procedures to generate HTML structures
+ * javascript - Procedures to generate HTML and Java Script structures.
+
+Grammars and finite automata
+ * grammar::fa - Create and manipulate finite automatons
+ * grammar::fa::op - Operations on finite automatons
+ * grammar::dacceptor - Create and use deterministic acceptors
+ * grammar::dexec - Execute deterministic finite automatons
+
+TKLib
+ * Plotchart - Simple plotting and charting package
+ * autoscroll - Provides for a scrollbar to automatically mapped and
+ unmapped as needed
+ * ctext - An extended text widget with customizable Syntax highlighting
+ * cursor - Procedures to handle CURSOR data
+ * datefield - Tk datefield widget
+ * style - Changes default Tk look&feel
+ * ipentry - An IP address entry widget
+ * tkpiechart - Creates and dynamically updates 2D or 3D pie charts
+---------------------------------------------------------
diff --git a/jni/ruby/ext/tk/lib/tkextlib/tcllib/autoscroll.rb b/jni/ruby/ext/tk/lib/tkextlib/tcllib/autoscroll.rb
new file mode 100644
index 0000000..2def59b
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/tcllib/autoscroll.rb
@@ -0,0 +1,158 @@
+#
+# tkextlib/tcllib/autoscroll.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+# * Part of tcllib extension
+# * Provides for a scrollbar to automatically mapped and unmapped as needed
+#
+# (The following is the original description of the library.)
+#
+# This package allows scrollbars to be mapped and unmapped as needed
+# depending on the size and content of the scrollbars scrolled widget.
+# The scrollbar must be managed by either pack or grid, other geometry
+# managers are not supported.
+#
+# When managed by pack, any geometry changes made in the scrollbars parent
+# between the time a scrollbar is unmapped, and when it is mapped will be
+# lost. It is an error to destroy any of the scrollbars siblings while the
+# scrollbar is unmapped. When managed by grid, if anything becomes gridded
+# in the same row and column the scrollbar occupied it will be replaced by
+# the scrollbar when remapped.
+#
+# This package may be used on any scrollbar-like widget as long as it
+# supports the set subcommand in the same style as scrollbar. If the set
+# subcommand is not used then this package will have no effect.
+#
+
+require 'tk'
+require 'tk/scrollbar'
+require 'tkextlib/tcllib.rb'
+
+module Tk
+ module Tcllib
+ module Autoscroll
+ PACKAGE_NAME = 'autoscroll'.freeze
+ def self.package_name
+ PACKAGE_NAME
+ end
+
+ def self.package_version
+ begin
+ TkPackage.require('autoscroll')
+ rescue
+ ''
+ end
+ end
+
+ def self.not_available
+ fail RuntimeError, "'tkextlib/tcllib/autoscroll' extension is not available on your current environment."
+ end
+
+ def self.autoscroll(win)
+ Tk::Tcllib::Autoscroll.not_available
+ end
+
+ def self.unautoscroll(win)
+ Tk::Tcllib::Autoscroll.not_available
+ end
+ end
+ end
+end
+
+module Tk
+ module Scrollable
+ def autoscroll(mode = nil)
+ case mode
+ when :x, 'x'
+ if @xscrollbar
+ Tk::Tcllib::Autoscroll.autoscroll(@xscrollbar)
+ end
+ when :y, 'y'
+ if @yscrollbar
+ Tk::Tcllib::Autoscroll.autoscroll(@yscrollbar)
+ end
+ when nil, :both, 'both'
+ if @xscrollbar
+ Tk::Tcllib::Autoscroll.autoscroll(@xscrollbar)
+ end
+ if @yscrollbar
+ Tk::Tcllib::Autoscroll.autoscroll(@yscrollbar)
+ end
+ else
+ fail ArgumentError, "'x', 'y' or 'both' (String or Symbol) is expected"
+ end
+ self
+ end
+ def unautoscroll(mode = nil)
+ case mode
+ when :x, 'x'
+ if @xscrollbar
+ Tk::Tcllib::Autoscroll.unautoscroll(@xscrollbar)
+ end
+ when :y, 'y'
+ if @yscrollbar
+ Tk::Tcllib::Autoscroll.unautoscroll(@yscrollbar)
+ end
+ when nil, :both, 'both'
+ if @xscrollbar
+ Tk::Tcllib::Autoscroll.unautoscroll(@xscrollbar)
+ end
+ if @yscrollbar
+ Tk::Tcllib::Autoscroll.unautoscroll(@yscrollbar)
+ end
+ else
+ fail ArgumentError, "'x', 'y' or 'both' (String or Symbol) is expected"
+ end
+ self
+ end
+ end
+end
+
+class Tk::Scrollbar
+ def autoscroll
+ # Arranges for the already existing scrollbar to be mapped
+ # and unmapped as needed.
+ #tk_call_without_enc('::autoscroll::autoscroll', @path)
+ Tk::Tcllib::Autoscroll.autoscroll(self)
+ self
+ end
+ def unautoscroll
+ # Returns the scrollbar to its original static state.
+ #tk_call_without_enc('::autoscroll::unautoscroll', @path)
+ Tk::Tcllib::Autoscroll.unautoscroll(self)
+ self
+ end
+end
+
+# TkPackage.require('autoscroll', '1.0')
+# TkPackage.require('autoscroll', '1.1')
+TkPackage.require('autoscroll')
+
+module Tk
+ module Tcllib
+ class << Autoscroll
+ undef not_available
+ end
+
+ module Autoscroll
+ extend TkCore
+ def self.autoscroll(win)
+ tk_call_without_enc('::autoscroll::autoscroll', win.path)
+ end
+
+ def self.unautoscroll(win)
+ tk_call_without_enc('::autoscroll::unautoscroll', win.path)
+ end
+
+ def self.wrap
+ # v1.1
+ tk_call_without_enc('::autoscroll::wrap')
+ end
+
+ def self.unwrap
+ # v1.1
+ tk_call_without_enc('::autoscroll::unwrap')
+ end
+ end
+ end
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/tcllib/calendar.rb b/jni/ruby/ext/tk/lib/tkextlib/tcllib/calendar.rb
new file mode 100644
index 0000000..b6843df
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/tcllib/calendar.rb
@@ -0,0 +1,55 @@
+#
+# tkextlib/tcllib/calendar.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+# * Part of tcllib extension
+# * calendar widget
+#
+
+require 'tk'
+require 'tkextlib/tcllib.rb'
+
+# TkPackage.require('widget::calendar', '0.9')
+TkPackage.require('widget::calendar')
+
+module Tk::Tcllib
+ module Widget
+ class Calendar < TkCanvas
+ PACKAGE_NAME = 'widget::calendar'.freeze
+ def self.package_name
+ PACKAGE_NAME
+ end
+
+ def self.package_version
+ begin
+ TkPackage.require('widget::calendar')
+ rescue
+ ''
+ end
+ end
+ end
+ end
+end
+
+class Tk::Tcllib::Widget::Calendar
+ TkCommandNames = ['::widget::calendar'.freeze].freeze
+
+ def __boolval_optkeys
+ super() << 'showpast'
+ end
+ private :__boolval_optkeys
+
+ def create_self(keys)
+ if keys and keys != None
+ tk_call_without_enc(self.class::TkCommandNames[0], @path,
+ *hash_kv(keys, true))
+ else
+ tk_call_without_enc(self.class::TkCommandNames[0], @path)
+ end
+ end
+ private :create_self
+
+ def get(what = 'all')
+ tk_send('get', what)
+ end
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/tcllib/canvas_sqmap.rb b/jni/ruby/ext/tk/lib/tkextlib/tcllib/canvas_sqmap.rb
new file mode 100644
index 0000000..ba87cd3
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/tcllib/canvas_sqmap.rb
@@ -0,0 +1,36 @@
+#
+# tkextlib/tcllib/canvas.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+# * Part of tcllib extension
+# *
+#
+
+require 'tk'
+require 'tkextlib/tcllib.rb'
+
+# TkPackage.require('widget::canvas_sqmap', '0.2')
+TkPackage.require('widget::canvas_sqmap')
+
+module Tk::Tcllib
+ module Widget
+ class Canvas_Sqmap < Canvas
+ TkCommandNames = ['::widget::canvas_sqmap'.freeze].freeze
+
+ def image_set(cell, img)
+ tk_send('image', 'set', cell, img)
+ self
+ end
+
+ def image_unset(cell)
+ tk_send('image', 'unset', cell)
+ self
+ end
+
+ def flush
+ tk_send('flush')
+ self
+ end
+ end
+ end
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/tcllib/canvas_zoom.rb b/jni/ruby/ext/tk/lib/tkextlib/tcllib/canvas_zoom.rb
new file mode 100644
index 0000000..f4ffb48
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/tcllib/canvas_zoom.rb
@@ -0,0 +1,21 @@
+#
+# tkextlib/tcllib/canvas.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+# * Part of tcllib extension
+# *
+#
+
+require 'tk'
+require 'tkextlib/tcllib.rb'
+
+# TkPackage.require('widget::canvas_zoom', '0.1')
+TkPackage.require('widget::canvas_zoom')
+
+module Tk::Tcllib
+ module Widget
+ class Canvas_Zoom < Canvas
+ TkCommandNames = ['::widget::canvas_zoom'.freeze].freeze
+ end
+ end
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/tcllib/chatwidget.rb b/jni/ruby/ext/tk/lib/tkextlib/tcllib/chatwidget.rb
new file mode 100644
index 0000000..ddb0340
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/tcllib/chatwidget.rb
@@ -0,0 +1,151 @@
+#
+# tkextlib/tcllib/chatwidget.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+# * Part of tcllib extension
+# * chatwidget - Provides a multi-paned view suitable for display of
+# chat room or irc channel information
+#
+
+require 'tk'
+require 'tkextlib/tcllib.rb'
+
+# TkPackage.require('chatwidget', '1.1.0')
+TkPackage.require('chatwidget')
+
+module Tk::Tcllib
+ class ChatWidget < TkText
+ PACKAGE_NAME = 'chatwidget'.freeze
+ def self.package_name
+ PACKAGE_NAME
+ end
+
+ def self.package_version
+ begin
+ TkPackage.require('chatwidget')
+ rescue
+ ''
+ end
+ end
+ end
+end
+
+class Tk::Tcllib::ChatWidget
+ TkCommandNames = ['::chatwidget::chatwidget'.freeze].freeze
+
+ def show_topic
+ tk_send_without_enc('topic', 'show')
+ self
+ end
+
+ def hide_topic
+ tk_send_without_enc('topic', 'hide')
+ self
+ end
+
+ def set_topic(topic)
+ tk_send('topic', 'set', topic)
+ end
+
+ def list_name
+ tk_split_simplelist(tk_send('name', 'list'))
+ end
+
+ def list_name_full
+ tk_split_simplelist(tk_send('name', 'list')).map{|lst|
+ nick, *opts = tk_split_simplelist(lst)
+ h_opt = {}
+ opts.slice(2){|k, v| h_opt[k[1..-1]] = tk_tcl2ruby(v)}
+ [nick, h_opt]
+ }
+ end
+
+ def add_name(nick, opts={})
+ tk_send('name', 'add', nick, *(hash_kv(opts)))
+ end
+
+ def delete_name(nick)
+ tk_send('name', 'delete', nick)
+ end
+
+ def get_name(nick)
+ lst = tk_send('name', 'get', nick)
+ return nil if lst.empty?
+ nick, *opts = tk_split_simplelist(lst)
+ h_opt = {}
+ opts.slice(2){|k, v| h_opt[k[1..-1]] = tk_tcl2ruby(v)}
+ [nick, h_opt]
+ end
+
+ def message(msg, opts={})
+ tk_send('message', msg, *(hash_kv(opts)))
+ self
+ end
+
+ def _parse_hook_list(lst)
+ tk_split_simplelist(lst).map{|hook|
+ cmd, prior = tk_split_simplelist(hook)
+ [procedure(cmd), number(prior)]
+ }
+ end
+ private :_parse_hook_list
+
+ def hook_add(type, *args, &blk) # args -> [prior, cmd], [prior], [cmd]
+ #type -> 'message', 'post', 'names_group', 'names_nick', 'chatstate', 'url'
+
+ if prior = args.shift
+ if !prior.kind_of?(Numeric)
+ cmd = prior
+ if (prior = args.shift) && !prior.kind_of?(Numeric) # error
+ args.unshift(prior)
+ end
+ args.unshift(cmd)
+ end
+ prior ||= 50 # default priority
+ end
+
+ cmd = args.shift || blk
+
+ fail ArgumentError, "invalid arguments" unless args.empty?
+ fail ArgumentError, "no callback is given" unless cmd
+
+ _parse_hook_list(tk_send('hook', 'add', type, cmd, prior))
+ end
+
+ def hook_remove(type, cmd)
+ #type -> 'message', 'post', 'names_group', 'names_nick', 'chatstate', 'url'
+ _parse_hook_list(tk_send('hook', 'remove', type, cmd))
+ end
+
+ def hook_run(type, *cmd_args)
+ #type -> 'message', 'post', 'names_group', 'names_nick', 'chatstate', 'url'
+ tk_send('hook', 'run', type, *cmd_args)
+ end
+
+ def hook_list(type)
+ #type -> 'message', 'post', 'names_group', 'names_nick', 'chatstate', 'url'
+ _parse_hook_list(tk_send('hook', 'list', type))
+ end
+
+ def show_names
+ tk_send('names', 'show')
+ self
+ end
+
+ def hide_names
+ tk_send('names', 'hide')
+ self
+ end
+
+ def names_widget
+ window(tk_send('names'))
+ end
+
+ def entry_widget
+ window(tk_send('entry'))
+ end
+
+ def chat_widget
+ window(tk_send('chat'))
+ end
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/tcllib/crosshair.rb b/jni/ruby/ext/tk/lib/tkextlib/tcllib/crosshair.rb
new file mode 100644
index 0000000..49b5361
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/tcllib/crosshair.rb
@@ -0,0 +1,117 @@
+#
+# tkextlib/tcllib/crosshair.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+# * Part of tcllib extension
+# * Crosshairs for Tk canvas
+#
+
+require 'tk'
+require 'tkextlib/tcllib.rb'
+
+# TkPackage.require('crosshair', '1.0.2')
+TkPackage.require('crosshair')
+
+module Tk::Tcllib
+ module Crosshair
+ PACKAGE_NAME = 'crosshair'.freeze
+ def self.package_name
+ PACKAGE_NAME
+ end
+
+ def self.package_version
+ begin
+ TkPackage.require('crosshair')
+ rescue
+ ''
+ end
+ end
+ end
+end
+
+module Tk::Tcllib::Crosshair
+ include TkCore
+ TkCommandNames = ['::crosshair::crosshair'.freeze].freeze
+
+ def self.crosshair(w, keys={})
+ Tk.tk_call('::crosshair::crosshair', w, *hash_kv(keys))
+ w
+ end
+ def self.on(w, keys={})
+ self.crosshair(w, keys)
+ end
+
+ def self.off(w)
+ Tk.tk_call('::crosshair::off', w)
+ w
+ end
+
+ def self.track_on(w, &b)
+ Tk.tk_call('::crosshair::track_on', w, b)
+ w
+ end
+
+ def self.track_off(w)
+ Tk.tk_call('::crosshair::track_off', w)
+ w
+ end
+end
+
+class << Tk::Tcllib::Crosshair
+ include TkComm
+ include TkCanvasItemConfig
+
+ def __item_methodcall_optkeys(id)
+ {}
+ end
+ private :__item_methodcall_optkeys
+
+ def __item_config_cmd(id)
+ # maybe need to override
+ ['::crosshair::configure', id]
+ end
+ private :__item_config_cmd
+
+ private :itemcget_tkstring, :itemcget, :itemcget_strict
+ private :itemconfigure, :itemconfiginfo, :current_itemconfiginfo
+
+ def confugure(w, slot, value=None)
+ itemconfigure(w, slot, value)
+ end
+ def confuginfo(w, slot = nil)
+ itemconfiginfo(w, slot)
+ end
+ def current_configinfo(w, slot = nil)
+ current_itemconfiginfo(w, slot)
+ end
+ def cget(w, slot)
+ current_itemconfiginfo(w, slot).values[0]
+ end
+end
+
+module Tk::Tcllib::Crosshair
+ def crosshair_on(keys={})
+ Tk::Tcllib::Crosshair.on(self, keys)
+ end
+ def crosshair_off
+ Tk::Tcllib::Crosshair.off(self)
+ end
+ def crosshair_track_on(&b)
+ Tk::Tcllib::Crosshair.track_on(self, &b)
+ end
+ def crosshair_track_off
+ Tk::Tcllib::Crosshair.track_off(self)
+ end
+ def crosshair_configure(*args)
+ Tk::Tcllib::Crosshair.configure(self, *args)
+ end
+ def crosshair_configinfo(slot = nil)
+ Tk::Tcllib::Crosshair.configinfo(self, slot)
+ end
+ def crosshair_current_configinfo(slot = nil)
+ Tk::Tcllib::Crosshair.current_configinfo(self, slot)
+ end
+ def crosshair_cget(slot)
+ Tk::Tcllib::Crosshair.cget(self, slot)
+ end
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/tcllib/ctext.rb b/jni/ruby/ext/tk/lib/tkextlib/tcllib/ctext.rb
new file mode 100644
index 0000000..308847c
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/tcllib/ctext.rb
@@ -0,0 +1,160 @@
+#
+# tkextlib/tcllib/ctext.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+# * Part of tcllib extension
+# * Overloads the text widget and provides new commands
+#
+
+require 'tk'
+require 'tk/text'
+require 'tkextlib/tcllib.rb'
+
+# TkPackage.require('ctext', '3.1')
+TkPackage.require('ctext')
+
+module Tk
+ module Tcllib
+ class CText < Tk::Text
+ PACKAGE_NAME = 'ctext'.freeze
+ def self.package_name
+ PACKAGE_NAME
+ end
+
+ def self.package_version
+ begin
+ TkPackage.require('ctext')
+ rescue
+ ''
+ end
+ end
+ end
+ end
+end
+
+class Tk::Tcllib::CText
+ TkCommandNames = ['ctext'.freeze].freeze
+ WidgetClassName = 'Ctext'.freeze
+ WidgetClassNames[WidgetClassName] ||= self
+
+ def create_self(keys)
+ if keys and keys != None
+ tk_call_without_enc(self.class::TkCommandNames[0], @path,
+ *hash_kv(keys, true))
+ else
+ tk_call_without_enc(self.class::TkCommandNames[0], @path)
+ end
+ end
+ private :create_self
+
+ def __strval_optkeys
+ super() << 'linemapfg' << 'linemapbg' <<
+ 'linemap_select_fg' << 'linemap_select_bg'
+ end
+ private :__strval_optkeys
+
+ def __boolval_optkeys
+ super() << 'highlight' << 'linemap_markable'
+ end
+ private :__boolval_optkeys
+
+ def append(*args)
+ tk_send('append', *args)
+ end
+
+ def copy
+ tk_send('copy')
+ end
+
+ def cut
+ tk_send('cut')
+ end
+
+ def fast_delete(*args)
+ tk_send('fastdelete', *args)
+ end
+
+ def fast_insert(*args)
+ tk_send('fastinsert', *args)
+ end
+
+ def highlight(*args)
+ tk_send('highlight', *args)
+ end
+
+ def paste
+ tk_send('paste')
+ end
+
+ def edit(*args)
+ tk_send('edit', *args)
+ end
+
+ def add_highlight_class(klass, col, *keywords)
+ tk_call('ctext::addHighlightClass', @path, klass, col, keywords.flatten)
+ self
+ end
+
+ def add_highlight_class_for_special_chars(klass, col, *chrs)
+ tk_call('ctext::addHighlightClassForSpecialChars',
+ @path, klass, col, chrs.join(''))
+ self
+ end
+
+ def add_highlight_class_for_regexp(klass, col, tcl_regexp)
+ tk_call('ctext::addHighlightClassForRegexp',
+ @path, klass, col, tcl_regexp)
+ self
+ end
+
+ def add_highlight_class_with_only_char_start(klass, col, chr)
+ tk_call('ctext::addHighlightClassWithOnlyCharStart',
+ @path, klass, col, chr)
+ self
+ end
+
+ def clear_highlight_classes
+ tk_call('ctext::clearHighlightClasses', @path)
+ self
+ end
+
+ def get_highlight_classes
+ tk_split_simplelist(tk_call('ctext::getHighlightClasses', @path))
+ end
+
+ def delete_highlight_class(klass)
+ tk_call('ctext::deleteHighlightClass', @path, klass)
+ self
+ end
+
+ def enable_C_comments
+ tk_call('ctext::enableComments', @path)
+ self
+ end
+
+ def disable_C_comments
+ tk_call('ctext::disableComments', @path)
+ self
+ end
+
+ def find_next_char(idx, chr)
+ tk_call('ctext::findNextChar', @path, idx, chr)
+ end
+
+ def find_next_space(idx)
+ tk_call('ctext::findNextSpace', @path, idx)
+ end
+
+ def find_previous_space(idx)
+ tk_call('ctext::findPreviousSpace', @path, idx)
+ end
+
+ def set_update_proc(cmd=Proc.new)
+ tk_call('proc', 'ctext::update', '', cmd)
+ self
+ end
+
+ def modified?(mode)
+ bool(tk_call('ctext::modified', @path, mode))
+ end
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/tcllib/cursor.rb b/jni/ruby/ext/tk/lib/tkextlib/tcllib/cursor.rb
new file mode 100644
index 0000000..5c47f97
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/tcllib/cursor.rb
@@ -0,0 +1,97 @@
+#
+# tkextlib/tcllib/cursor.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+# * Part of tcllib extension
+# * Procedures to handle CURSOR data
+#
+
+require 'tk'
+require 'tkextlib/tcllib.rb'
+
+module Tk
+ module Tcllib
+ module Cursor
+ PACKAGE_NAME = 'cursor'.freeze
+ def self.package_name
+ PACKAGE_NAME
+ end
+
+ def self.package_version
+ begin
+ TkPackage.require('cursor')
+ rescue
+ ''
+ end
+ end
+
+ def self.not_available
+ fail RuntimeError, "'tkextlib/tcllib/cursor' extension is not available on your current environment."
+ end
+
+ def self.cursor_display(win=None)
+ Tk::Tcllib::Cursor.not_available
+ end
+
+ def self.cursor_propagate(win, cursor)
+ Tk::Tcllib::Cursor.not_available
+ end
+
+ def self.cursor_restore(win, cursor = None)
+ Tk::Tcllib::Cursor.not_available
+ end
+ end
+ end
+
+ def self.cursor_display(parent=None)
+ # Pops up a dialog with a listbox containing all the cursor names.
+ # Selecting a cursor name will display it in that dialog.
+ # This is simply for viewing any available cursors on the platform .
+ #tk_call_without_enc('::cursor::display', parent)
+ Tk::Tcllib::Cursor.cursor_display(parent)
+ end
+end
+
+class TkWindow
+ def cursor_propagate(cursor)
+ # Sets the cursor for self and all its descendants to cursor.
+ #tk_call_without_enc('::cursor::propagate', @path, cursor)
+ Tk::Tcllib::Cursor.cursor_propagate(self, cursor)
+ end
+ def cursor_restore(cursor = None)
+ # Restore the original or previously set cursor for self and all its
+ # descendants. If cursor is specified, that will be used if on any
+ # widget that did not have a preset cursor (set by a previous call
+ # to TkWindow#cursor_propagate).
+ #tk_call_without_enc('::cursor::restore', @path, cursor)
+ Tk::Tcllib::Cursor.cursor_restore(self, cursor)
+ end
+end
+
+# TkPackage.require('cursor', '0.1')
+TkPackage.require('cursor')
+
+module Tk
+ module Tcllib
+ class << Cursor
+ undef not_available
+ end
+
+ module Cursor
+ extend TkCore
+ def self.cursor_display(win=None)
+ tk_call_without_enc('::cursor::display', _epath(win))
+ end
+
+ def self.cursor_propagate(win, cursor)
+ #tk_call_without_enc('::cursor::propagate', win.path, cursor)
+ tk_call_without_enc('::cursor::propagate', _epath(win), cursor)
+ end
+
+ def self.cursor_restore(win, cursor = None)
+ #tk_call_without_enc('::cursor::restore', win.path, cursor)
+ tk_call_without_enc('::cursor::restore', _epath(win), cursor)
+ end
+ end
+ end
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/tcllib/dateentry.rb b/jni/ruby/ext/tk/lib/tkextlib/tcllib/dateentry.rb
new file mode 100644
index 0000000..77038d9
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/tcllib/dateentry.rb
@@ -0,0 +1,62 @@
+#
+# tkextlib/tcllib/dateentry.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+# * Part of tcllib extension
+# * dateentry widget
+#
+
+require 'tk'
+require 'tkextlib/tcllib.rb'
+
+# TkPackage.require('widget::dateentry', '0.91')
+TkPackage.require('widget::dateentry')
+
+module Tk::Tcllib
+ module Widget
+ class Dateentry < Tk::Tile::TEntry
+ PACKAGE_NAME = 'widget::dateentry'.freeze
+ def self.package_name
+ PACKAGE_NAME
+ end
+
+ def self.package_version
+ begin
+ TkPackage.require('widget::dateentry')
+ rescue
+ ''
+ end
+ end
+ end
+ DateEntry = Dateentry
+ end
+end
+
+class Tk::Tcllib::Widget::Dateentry
+ TkCommandNames = ['::widget::dateentry'.freeze].freeze
+
+ def __strval_optkeys
+ super() << ['dateformat']
+ end
+ private :__strval_optkeys
+
+ def create_self(keys)
+ if keys and keys != None
+ tk_call_without_enc(self.class::TkCommandNames[0], @path,
+ *hash_kv(keys, true))
+ else
+ tk_call_without_enc(self.class::TkCommandNames[0], @path)
+ end
+ end
+ private :create_self
+
+ def post
+ tk_send('post')
+ self
+ end
+
+ def unpost
+ tk_send('unpost')
+ self
+ end
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/tcllib/datefield.rb b/jni/ruby/ext/tk/lib/tkextlib/tcllib/datefield.rb
new file mode 100644
index 0000000..4c2eae7
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/tcllib/datefield.rb
@@ -0,0 +1,57 @@
+#
+# tkextlib/tcllib/datefield.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+# * Part of tcllib extension
+# * Tk datefield widget
+#
+# (The following is the original description of the library.)
+#
+# The datefield package provides the datefield widget which is an enhanced
+# text entry widget for the purpose of date entry. Only valid dates of the
+# form MM/DD/YYYY can be entered.
+#
+# The datefield widget is, in fact, just an entry widget with specialized
+# bindings. This means all the command and options for an entry widget apply
+# equally here.
+
+require 'tk'
+require 'tk/entry'
+require 'tkextlib/tcllib.rb'
+
+# TkPackage.require('datefield', '0.1')
+TkPackage.require('datefield')
+
+module Tk
+ module Tcllib
+ class Datefield < Tk::Entry
+ PACKAGE_NAME = 'datefield'.freeze
+ def self.package_name
+ PACKAGE_NAME
+ end
+
+ def self.package_version
+ begin
+ TkPackage.require('datefield')
+ rescue
+ ''
+ end
+ end
+ end
+ DateField = Datefield
+ end
+end
+
+class Tk::Tcllib::Datefield
+ TkCommandNames = ['::datefield::datefield'.freeze].freeze
+
+ def create_self(keys)
+ if keys and keys != None
+ tk_call_without_enc(self.class::TkCommandNames[0], @path,
+ *hash_kv(keys, true))
+ else
+ tk_call_without_enc(self.class::TkCommandNames[0], @path)
+ end
+ end
+ private :create_self
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/tcllib/diagrams.rb b/jni/ruby/ext/tk/lib/tkextlib/tcllib/diagrams.rb
new file mode 100644
index 0000000..d24ba9d
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/tcllib/diagrams.rb
@@ -0,0 +1,224 @@
+#
+# tkextlib/tcllib/diagrams.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+# * Part of tcllib extension
+# * Draw diagrams
+#
+
+require 'tk'
+require 'tkextlib/tcllib.rb'
+
+# TkPackage.require('Diagrams', '0.3')
+TkPackage.require('Diagrams')
+
+module Tk::Tcllib
+ module Diagrams
+ PACKAGE_NAME = 'Diagrams'.freeze
+ def self.package_name
+ PACKAGE_NAME
+ end
+
+ def self.package_version
+ begin
+ TkPackage.require('Diagrams')
+ rescue
+ ''
+ end
+ end
+ end
+end
+
+class << Tk::Tcllib::Diagrams
+ include TkCore
+
+ def drawin(canvas)
+ tk_call('::Diagrams::drawin', canvas)
+ canvas
+ end
+ alias draw_in drawin
+
+ def saveps(filename)
+ tk_call('::Diagrams::saveps', filename)
+ filename
+ end
+ alias save_ps saveps
+
+ def direction(dir)
+ tk_call('::Diagrams::direction', dir)
+ dir
+ end
+
+ def currentpos(pos)
+ list(tk_call('::Diagrams::currentpos', pos))
+ end
+ alias current_pos currentpos
+ alias currentpos= currentpos
+ alias current_pos= currentpos
+
+ def getpos(anchor, obj)
+ list(tk_call('::Diagrams::getpos', anchor, obj))
+ end
+ alias get_pos getpos
+
+ def position(x, y)
+ list(tk_call('::Diagrams::position', x, y))
+ end
+
+ def box(text, width=nil, height=nil)
+ if width || height
+ width = '' unless width
+ height = '' unless height
+ list(tk_call('::Diagrams::box', text, width, height))
+ else
+ list(tk_call('::Diagrams::box', text))
+ end
+ end
+
+ def plaintext(text, width=nil, height=nil)
+ if width || height
+ width = '' unless width
+ height = '' unless height
+ list(tk_call('::Diagrams::plaintext', text, width, height))
+ else
+ list(tk_call('::Diagrams::plaintext', text))
+ end
+ end
+
+ def circle(text, radius=nil)
+ if radius
+ list(tk_call('::Diagrams::circle', text, radius))
+ else
+ list(tk_call('::Diagrams::circle', text))
+ end
+ end
+
+ def slanted(text, width=nil, height=nil, angle=nil)
+ if width || height || angle
+ width = '' unless width
+ height = '' unless height
+ if angle
+ list(tk_call('::Diagrams::slanted', text, width, height, angle))
+ else
+ list(tk_call('::Diagrams::slanted', text, width, height))
+ end
+ else
+ list(tk_call('::Diagrams::slanted', text))
+ end
+ end
+
+ def diamond(text, width=nil, height=nil)
+ if width || height
+ width = '' unless width
+ height = '' unless height
+ list(tk_call('::Diagrams::diamond', text, width, height))
+ else
+ list(tk_call('::Diagrams::diamond', text))
+ end
+ end
+
+ def drum(text, width=nil, height=nil)
+ if width || height
+ width = '' unless width
+ height = '' unless height
+ list(tk_call('::Diagrams::drum', text, width, height))
+ else
+ list(tk_call('::Diagrams::drum', text))
+ end
+ end
+
+ def arrow(text=nil, length=nil, head=nil)
+ if length || head
+ text = '' unless text
+ length = '' unless length
+ list(tk_call('::Diagrams::arrow', text, length, head))
+ else
+ if text
+ list(tk_call('::Diagrams::arrow', text))
+ else
+ list(tk_call('::Diagrams::arrow'))
+ end
+ end
+ end
+
+ def line(*args)
+ ary = []
+ args.each{|arg|
+ if arg.kind_of?(Array) && arg.length == 2 # [length, angle]
+ ary.concat arg
+ else # ["POSITION", x, y] or length or angle
+ ary << arg
+ end
+ }
+ list(tk_call('::Diagrams::line', *ary))
+ end
+
+ def bracket(dir, dist, from_pos, to_pos)
+ list(tk_call('::Diagrams::bracket', dir, dist, from_pos, to_pos))
+ end
+
+ def attach(anchor=None)
+ tk_call('::Diagrams::attach', anchor)
+ end
+
+ def color(name=None)
+ tk_call('::Diagrams::color', name)
+ end
+
+ def fillcolor(name=None)
+ tk_call('::Diagrams::fillcolor', name)
+ end
+
+ def textcolor(name=None)
+ tk_call('::Diagrams::textcolor', name)
+ end
+
+ def usegap(mode=None)
+ bool(tk_call('::Diagrams::usegap', mode))
+ end
+ alias use_gap usegap
+
+ def xgap(val=None)
+ number(tk_call('::Diagrams::xgap', val))
+ end
+
+ def ygap(val=None)
+ number(tk_call('::Diagrams::ygap', val))
+ end
+
+ def textfont(fnt=None)
+ tk_call('::Diagrams::textfont', fnt)
+ end
+
+ def linewidth(pixels=None)
+ number(tk_call('::Diagrams::linewidth', pixels))
+ end
+
+ def linestyle(style=None)
+ tk_call('::Diagrams::linestyle', style)
+ end
+
+ def pushstate
+ tk_call('::Diagrams::pushstate')
+ end
+ alias push_state pushstate
+
+ def popstate
+ tk_call('::Diagrams::popstate')
+ end
+ alias pop_state popstate
+
+ def computepos
+ list(tk_call('::Diagrams::computepos'))
+ end
+ alias compute_pos computepos
+
+ def boxcoords(x1, y1, x2, y2)
+ list(tk_call('::Diagrams::boxcoords', x1, y1, x2, y2))
+ end
+
+ def moveobject(obj)
+ list(tk_call('::Diagrams::moveobject', obj))
+ end
+ alias move_object moveobject
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/tcllib/dialog.rb b/jni/ruby/ext/tk/lib/tkextlib/tcllib/dialog.rb
new file mode 100644
index 0000000..86a0ef2
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/tcllib/dialog.rb
@@ -0,0 +1,84 @@
+#
+# tkextlib/tcllib/dialog.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+# * Part of tcllib extension
+# * Generic dialog widget (themed)
+#
+
+require 'tk'
+require 'tkextlib/tcllib.rb'
+
+# TkPackage.require('widget::dialog', '1.2')
+TkPackage.require('widget::dialog')
+
+module Tk::Tcllib
+ module Widget
+ class Dialog < TkWindow
+ PACKAGE_NAME = 'widget::dialog'.freeze
+ def self.package_name
+ PACKAGE_NAME
+ end
+
+ def self.package_version
+ begin
+ TkPackage.require('widget::dialog')
+ rescue
+ ''
+ end
+ end
+ end
+ end
+end
+
+class Tk::Tcllib::Widget::Dialog
+ TkCommandNames = ['::widget::dialog'.freeze].freeze
+
+ def __boolval_optkeys
+ ['separator', 'synchronous', 'transient']
+ end
+ private :__boolval_optkeys
+
+ def create_self(keys)
+ if keys and keys != None
+ tk_call_without_enc(self.class::TkCommandNames[0], @path,
+ *hash_kv(keys, true))
+ else
+ tk_call_without_enc(self.class::TkCommandNames[0], @path)
+ end
+ end
+ private :create_self
+
+ def add(what, *args)
+ window(tk_send('add', *args))
+ end
+
+ def get_frame
+ window(tk_send('getframe'))
+ end
+
+ def set_widget(widget)
+ tk_send('setwidget', widget)
+ self
+ end
+
+ def display
+ tk_send('display')
+ self
+ end
+ alias show display
+
+ def cancel
+ tk_send('cancel')
+ self
+ end
+
+ def close(reason = None)
+ tk_send('close', reason)
+ end
+
+ def withdraw
+ tk_send('withdraw')
+ self
+ end
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/tcllib/getstring.rb b/jni/ruby/ext/tk/lib/tkextlib/tcllib/getstring.rb
new file mode 100644
index 0000000..48711d3
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/tcllib/getstring.rb
@@ -0,0 +1,134 @@
+#
+# tkextlib/tcllib/getstring.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+# * Part of tcllib extension
+# * A dialog which consists of an Entry, OK, and Cancel buttons.
+#
+
+require 'tk'
+require 'tk/entry'
+require 'tkextlib/tcllib.rb'
+
+# TkPackage.require('getstring', '0.1')
+TkPackage.require('getstring')
+
+module Tk::Tcllib
+ class GetString_Dialog < TkWindow
+ PACKAGE_NAME = 'getstring'.freeze
+ def self.package_name
+ PACKAGE_NAME
+ end
+
+ def self.package_version
+ begin
+ TkPackage.require('getstring')
+ rescue
+ ''
+ end
+ end
+ end
+end
+
+
+class Tk::Tcllib::GetString_Dialog
+ TkCommandNames = ['::getstring::tk_getString'.freeze].freeze
+ WidgetClassName = 'TkSDialog'.freeze
+ WidgetClassNames[WidgetClassName] ||= self
+
+ def self.show(*args)
+ dialog = self.new(*args)
+ dialog.show
+ [dialog.status, dialog.value]
+ end
+ def self.display(*args)
+ self.show(*args)
+ end
+
+ def initialize(*args) # args = (parent=nil, text='', keys=nil)
+ keys = args.pop
+ if keys.kind_of?(Hash)
+ text = args.pop
+ @keys = _symbolkey2str(keys)
+ args.push(keys)
+ else
+ text = keys
+ @keys = {}
+ end
+ if text
+ @text = text.dup
+ else
+ @text = ''
+ end
+
+ @variable = TkVariable.new
+ @status = nil
+
+ super(*args)
+ end
+
+ def create_self(keys)
+ # dummy
+ end
+ private :create_self
+
+ def show
+ @variable.value = ''
+ @status = bool(tk_call(self.class::TkCommandNames[0],
+ @path, @variable, @text, *hash_kv(@keys)))
+ end
+ alias display show
+
+ def status
+ @status
+ end
+
+ def value
+ @variable.value
+ end
+
+ def cget_strict(slot)
+ slot = slot.to_s
+ if slot == 'text'
+ @text
+ else
+ @keys[slot]
+ end
+ end
+ def cget(slot)
+ cget_strict(slot)
+ end
+
+ def configure(slot, value=None)
+ if slot.kind_of?(Hash)
+ slot.each{|k, v| configure(k, v)}
+ else
+ slot = slot.to_s
+ value = _symbolkey2str(value) if value.kind_of?(Hash)
+ if value && value != None
+ if slot == 'text'
+ @text = value.to_s
+ else
+ @keys[slot] = value
+ end
+ else
+ if slot == 'text'
+ @text = ''
+ else
+ @keys.delete(slot)
+ end
+ end
+ end
+ self
+ end
+
+ def configinfo(slot = nil)
+ if slot
+ slot = slot.to_s
+ [ slot, nil, nil, nil, ( (slot == 'text')? @text: @keys[slot] ) ]
+ else
+ @keys.collect{|k, v| [ k, nil, nil, nil, v ] } \
+ << [ 'text', nil, nil, nil, @text ]
+ end
+ end
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/tcllib/history.rb b/jni/ruby/ext/tk/lib/tkextlib/tcllib/history.rb
new file mode 100644
index 0000000..a01a4eb
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/tcllib/history.rb
@@ -0,0 +1,73 @@
+#
+# tkextlib/tcllib/history.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+# * Part of tcllib extension
+# * Provides a history for Entry widgets
+#
+
+require 'tk'
+require 'tk/entry'
+require 'tkextlib/tcllib.rb'
+
+# TkPackage.require('history', '0.1')
+TkPackage.require('history')
+
+module Tk::Tcllib
+ module History
+ PACKAGE_NAME = 'history'.freeze
+ def self.package_name
+ PACKAGE_NAME
+ end
+
+ def self.package_version
+ begin
+ TkPackage.require('history')
+ rescue
+ ''
+ end
+ end
+ end
+end
+
+module Tk::Tcllib::History
+ extend TkCore
+
+ def self.init(entry, length=None)
+ tk_call_without_enc('::history::init', entry.path, length)
+ entry.extend(self) # add methods to treat history to the entry widget
+ end
+
+ def self.remove(entry)
+ tk_call_without_enc('::history::remove', entry.path)
+ entry
+ end
+
+ def history_remove
+ tk_call_without_enc('::history::remove', @path)
+ self
+ end
+
+ def history_add(text)
+ tk_call('::history::add', @path, text)
+ self
+ end
+
+ def history_get
+ simplelist(tk_call_without_enc('::history::get', @path))
+ end
+
+ def history_clear
+ tk_call_without_enc('::history::clear', @path)
+ self
+ end
+
+ def history_configure(opt, value)
+ tk_call('::history::configure', @path, opt, value)
+ self
+ end
+
+ def history_configinfo(opt)
+ tk_call('::history::configure', @path, opt)
+ end
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/tcllib/ico.rb b/jni/ruby/ext/tk/lib/tkextlib/tcllib/ico.rb
new file mode 100644
index 0000000..36a32c6
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/tcllib/ico.rb
@@ -0,0 +1,146 @@
+#
+# tkextlib/tcllib/ico.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+# * Part of tcllib extension
+# * Reading and writing windows icons
+#
+
+require 'tk'
+require 'tk/image'
+#require 'tkextlib/tcllib.rb'
+
+# TkPackage.require('ico', '0.3')
+TkPackage.require('ico')
+
+module Tk
+ module Tcllib
+ class ICO < TkImage
+ PACKAGE_NAME = 'ico'.freeze
+ def self.package_name
+ PACKAGE_NAME
+ end
+
+ def self.package_version
+ begin
+ TkPackage.require('ico')
+ rescue
+ ''
+ end
+ end
+ end
+ end
+end
+
+class Tk::Tcllib::ICO
+ def self.list(file, keys=nil)
+ tk_split_list(tk_call_without_enc('::ico::getIconList', file,
+ *hash_kv(keys, true)))
+ end
+
+ def self.icons(file, keys=nil)
+ tk_split_simplelist(tk_call_without_enc('::ico::icons', file,
+ *hash_kv(keys, true))).map{|elem|
+ num_or_str(elem)
+ }
+ end
+
+ def self.get_members(file, name, keys=nil)
+ tk_split_simplelist(tk_call_without_enc('::ico::getMembers', file, name,
+ *hash_kv(keys, true))).map{|elem|
+ name, width, height, bpp = tk_split_simplelist(elem)
+ [name, number(width), number(height), number(bpp)]
+ }
+ end
+
+ def self.get(file, index, keys=nil)
+ tk_call_without_enc('::ico::getIcon', file, index, *hash_kv(keys, true))
+ end
+ def self.get_icon(*args)
+ get(*args)
+ end
+
+ def self.get_by_name(file, name, keys=nil)
+ tk_call_without_enc('::ico::getIconByName', file, name,
+ *hash_kv(keys, true))
+ end
+ def self.get_icon_by_name(*args)
+ get_by_name(*args)
+ end
+
+ def self.get_fileicon(file, keys=nil)
+ tk_call_without_enc('::ico::getFileIcon', file, *hash_kv(keys, true))
+ end
+
+ def self.get_image(file, index, keys={})
+ keys = _symbolkey2str(keys)
+ keys.delete('format')
+ self.new(file, index, keys)
+ end
+
+ def self.get_data(file, index, keys={})
+ keys['format'] = 'data'
+ tk_split_list(tk_call_without_enc('::ico::getIcon', file, index,
+ *hash_kv(keys, true)))
+ end
+
+ def self.write(file, index, depth, data, keys=nil)
+ tk_call_without_enc('::ico::writeIcon', file, index, depth, data,
+ *hash_kv(keys, true))
+ end
+
+ def self.copy(from_file, from_index, to_file, to_index, keys=nil)
+ tk_call_without_enc('::ico::copyIcon',
+ from_file, from_index, to_file, to_index,
+ *hash_kv(keys, true))
+ end
+
+ def self.exe_to_ico(exe_file, ico_file, keys=nil)
+ tk_call_without_enc('::ico::copyIcon', exe_file, ico_file,
+ *hash_kv(keys, true))
+ end
+
+ def self.clear_cache(file=None)
+ tk_call_without_enc('::ico::clearCache', file)
+ end
+
+ def self.transparent_color(image, color)
+ if image.kind_of?(Array)
+ tk_split_list(tk_call_without_enc('::ico::transparentColor',
+ image, color))
+ else
+ tk_call_without_enc('::ico::transparentColor', image, color)
+ end
+ end
+
+ def self.show(file, keys=nil)
+ tk_call_without_enc('::ico::Show', file, *hash_kv(keys, true))
+ end
+
+ ###########################
+
+ def initialize(file, index, keys=nil)
+ keys = _symbolkey2str(keys)
+ if keys.key?('name')
+ @path = keys['name'].to_s
+ else
+ Tk_Image_ID.mutex.synchronize{
+ @path = Tk_Image_ID.join(TkCore::INTERP._ip_id_)
+ Tk_Image_ID[1].succ!
+ }
+ end
+ tk_call_without_enc('::ico::getIcon', file, index, '-name', @path,
+ '-format', 'image', *hash_kv(keys, true))
+ Tk_IMGTBL[@path] = self
+ end
+
+ def write(file, index, depth, keys=nil)
+ Tk::Tcllib::ICO.write(file, index, depth, @path, keys=nil)
+ self
+ end
+
+ def transparent_color(color)
+ tk_call_without_enc('::ico::transparentColor', @path, color)
+ self
+ end
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/tcllib/ip_entry.rb b/jni/ruby/ext/tk/lib/tkextlib/tcllib/ip_entry.rb
new file mode 100644
index 0000000..4878cc3
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/tcllib/ip_entry.rb
@@ -0,0 +1,75 @@
+#
+# tkextlib/tcllib/ip_entry.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+# * Part of tcllib extension
+# * An IP address entry widget
+#
+# (The following is the original description of the library.)
+#
+# This package provides a widget for the entering of a IP address.
+# It guarantees a valid address at all times.
+
+require 'tk'
+require 'tkextlib/tcllib.rb'
+
+# TkPackage.require('ipentry', '0.1')
+TkPackage.require('ipentry')
+
+module Tk
+ module Tcllib
+ class IP_Entry < Tk::Entry
+ PACKAGE_NAME = 'ipentry'.freeze
+ def self.package_name
+ PACKAGE_NAME
+ end
+
+ def self.package_version
+ begin
+ TkPackage.require('ipentry')
+ rescue
+ ''
+ end
+ end
+ end
+ IPEntry = IP_Entry
+
+ class IP_Entry6 < IP_Entry
+ end
+ IPEntry6 = IP_Entry6
+ IP6_Entry = IP_Entry6
+ end
+end
+
+class Tk::Tcllib::IP_Entry
+ TkCommandNames = ['::ipentry::ipentry'.freeze].freeze
+ WidgetClassName = 'IPEntry'.freeze
+ WidgetClassNames[WidgetClassName] ||= self
+
+ def create_self(keys)
+ if keys and keys != None
+ tk_call_without_enc(self.class::TkCommandNames[0], @path,
+ *hash_kv(keys, true))
+ else
+ tk_call_without_enc(self.class::TkCommandNames[0], @path)
+ end
+ end
+ private :create_self
+
+ def __strval_optkeys
+ super() << 'fg' << 'bg' << 'insertbackground'
+ end
+ private :__strval_optkeys
+
+ def complete?
+ bool(tk_send_without_enc('complete'))
+ end
+
+ def insert(*ip)
+ tk_send_without_enc('insert', array2tk_list(ip.flatten))
+ end
+end
+
+class Tk::Tcllib::IP_Entry6 < Tk::Tcllib::IP_Entry
+ TkCommandNames = ['::ipentry::ipentry6'.freeze].freeze
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/tcllib/khim.rb b/jni/ruby/ext/tk/lib/tkextlib/tcllib/khim.rb
new file mode 100644
index 0000000..5dc2130
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/tcllib/khim.rb
@@ -0,0 +1,68 @@
+#
+# tkextlib/tcllib/khim.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+# * Part of tcllib extension
+# * Kevin's Hacky Input Method
+#
+
+require 'tk'
+require 'tkextlib/tcllib.rb'
+
+# TkPackage.require('khim', '1.0')
+TkPackage.require('khim')
+
+module Tk::Tcllib
+ class KHIM < TkToplevel
+ PACKAGE_NAME = 'khim'.freeze
+ def self.package_name
+ PACKAGE_NAME
+ end
+
+ def self.package_version
+ begin
+ TkPackage.require('khim')
+ rescue
+ ''
+ end
+ end
+ end
+end
+
+class Tk::Tcllib::KHIM
+ TkCommandNames = ['::khim::getOptions'.freeze].freeze
+
+ def self.get_options(parent='')
+ path = parent + '.tcllib_widget_khim_dialog'
+ self.new(:widgetname => path)
+ end
+
+ def self.get_config #=> cmd_string
+ Tk.tk_call_without_enc('::khim::getConfig')
+ end
+
+ def self.set_config(*args)
+ if args.length == 1
+ # cmd_string generated by
+ #Tk.ip_eval_without_enc(cmd_string)
+ Tk.ip_eval(cmd_string)
+ else
+ # args for setConfig command
+ #Tk.tk_call_without_enc('::khim::setConfig', *args)
+ Tk.tk_call('::khim::setConfig', *args)
+ end
+ end
+
+ def self.showHelp
+ Tk::Tcllib::KHIM::Help.new
+ end
+
+ def create_self(keys=None)
+ @db_class = @classname = nil
+ super(None) # ignore keys
+ end
+end
+
+class Tk::Tcllib::KHIM::Help < TkToplevel
+ TkCommandNames = ['::khim::showHelp'.freeze].freeze
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/tcllib/menuentry.rb b/jni/ruby/ext/tk/lib/tkextlib/tcllib/menuentry.rb
new file mode 100644
index 0000000..f1eb2f2
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/tcllib/menuentry.rb
@@ -0,0 +1,47 @@
+#
+# tkextlib/tcllib/menuentry.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+# * Part of tcllib extension
+# * menuentry widget
+#
+
+require 'tk'
+require 'tkextlib/tcllib.rb'
+
+# TkPackage.require('widget::menuentry', '1.0')
+TkPackage.require('widget::menuentry')
+
+module Tk::Tcllib
+ module Widget
+ class Menuentry < Tk::Tile::TEntry
+ PACKAGE_NAME = 'widget::menuentry'.freeze
+ def self.package_name
+ PACKAGE_NAME
+ end
+
+ def self.package_version
+ begin
+ TkPackage.require('widget::menuentry')
+ rescue
+ ''
+ end
+ end
+ end
+ MenuEntry = Menuentry
+ end
+end
+
+class Tk::Tcllib::Widget::Menuentry
+ TkCommandNames = ['::widget::menuentry'.freeze].freeze
+
+ def create_self(keys)
+ if keys and keys != None
+ tk_call_without_enc(self.class::TkCommandNames[0], @path,
+ *hash_kv(keys, true))
+ else
+ tk_call_without_enc(self.class::TkCommandNames[0], @path)
+ end
+ end
+ private :create_self
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/tcllib/ntext.rb b/jni/ruby/ext/tk/lib/tkextlib/tcllib/ntext.rb
new file mode 100644
index 0000000..7888ed4
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/tcllib/ntext.rb
@@ -0,0 +1,146 @@
+#
+# tkextlib/tcllib/ntext.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+# * Part of tcllib extension
+# * Ntext bindtag
+#
+
+require 'tk'
+require 'tkextlib/tcllib.rb'
+
+# TkPackage.require('ntext', '0.81')
+TkPackage.require('ntext')
+
+module Tk::Tcllib
+ Ntext = TkBindTag.new_by_name('Ntext')
+end
+
+# variables
+Tk::Tcllib::Ntext.instance_eval{
+ # boolean
+ @classicAnchor = TkVarAccess.new('::ntext::classicAnchor')
+ @classicExtras = TkVarAccess.new('::ntext::classicExtras')
+ @classicMouseSelect = TkVarAccess.new('::ntext::classicMouseSelect')
+ @classicWordBreak = TkVarAccess.new('::ntext::classicWordBreak')
+ @classicWrap = TkVarAccess.new('::ntext::classicWrap')
+ @overwrite = TkVarAccess.new('::ntext::overwrite')
+
+ # regexp
+ @newWrapRegexp = TkVarAccess.new('::ntext::newWrapRegexp')
+
+ # variables (advanced use)
+ @tcl_match_wordBreakAfter = TkVarAccess.new('::ntext::tcl_match_wordBreakAfter')
+ @tcl_match_wordBreakBefore = TkVarAccess.new('::ntext::tcl_match_wordBreakBefore')
+ @tcl_match_endOfWord = TkVarAccess.new('::ntext::tcl_match_endOfWord')
+ @tcl_match_startOfNextWord = TkVarAccess.new('::ntext::tcl_match_startOfNextWord')
+ @tcl_match_startOfPreviousWord = TkVarAccess.new('::ntext::tcl_match_startOfPreviousWord')
+}
+
+class << Tk::Tcllib::Ntext
+ def wrapIndent(txt, *args)
+ TK.tk_call('::next::wrapIndent', txt, *args)
+ end
+
+ def initializeMatchPatterns
+ TK.tk_call('::next::initializeMatchPatterns')
+ self
+ end
+
+ def createMatchPatterns(*args)
+ TK.tk_call('::next::createMatchPatterns', *args)
+ self
+ end
+
+ # functions (advanced use)
+ #ntext::new_wordBreakAfter
+ #ntext::new_wordBreakBefore
+ #ntext::new_endOfWord
+ #ntext::new_startOfNextWord
+ #ntext::new_startOfPreviousWord
+
+ # accessor
+ def classicAnchor
+ @classicAnchor.bool
+ end
+ def classicAnchor=(mode)
+ @classicAnchor.bool = mode
+ end
+
+ def classicExtras
+ @classicExtras.bool
+ end
+ def classicExtras=(mode)
+ @classicExtras.bool = mode
+ end
+
+ def classicMouseSelect
+ @classicMouseSelect.bool
+ end
+ def classicMouseSelect=(mode)
+ @classicMouseSelect.bool = mode
+ end
+
+ def classicWordBreak
+ @classicWordBreak.bool
+ end
+ def classicWordBreak=(mode)
+ @classicWordBreak.bool = mode
+ end
+
+ def classicWrap
+ @classicWrap.bool
+ end
+ def classicWrap=(mode)
+ @classicWrap.bool = mode
+ end
+
+ def overwrite
+ @overwrite.bool
+ end
+ def overwrite=(mode)
+ @classic.bool = mode
+ end
+
+ def newWrapRegexp
+ @newWrapRegexp.value
+ end
+ def newWrapRegexp=(val)
+ @newWrapRegexp.value = val
+ end
+
+ def tcl_match_wordBreakAfter
+ @tcl_match_wordBreakAfter.value
+ end
+ def tcl_match_wordBreakAfter=(val)
+ @tcl_match_wordBreakAfter.value = val
+ end
+
+ def tcl_match_wordBreakBefore
+ @tcl_match_wordBreakBefore.value
+ end
+ def tcl_match_wordBreakBefore=(val)
+ @tcl_match_wordBreakBefore.value = val
+ end
+
+ def tcl_match_endOfWord
+ @tcl_match_endOfWord.value
+ end
+ def tcl_match_endOfWord=(val)
+ @tcl_match_endOfWord.value = val
+ end
+
+ def tcl_match_startOfNextWord
+ @tcl_match_startOfNextWord.value
+ end
+ def tcl_match_startOfNextWord=(val)
+ @tcl_match_startOfNextWord.value = val
+ end
+
+ def tcl_match_startOfPreviousWord
+ @tcl_match_startOfPreviousWord.value
+ end
+ def tcl_match_startOfPreviousWord=(val)
+ @tcl_match_startOfPreviousWord.value = val
+ end
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/tcllib/panelframe.rb b/jni/ruby/ext/tk/lib/tkextlib/tcllib/panelframe.rb
new file mode 100644
index 0000000..020c51c
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/tcllib/panelframe.rb
@@ -0,0 +1,78 @@
+#
+# tkextlib/tcllib/panelframe.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+# * Part of tcllib extension
+# * Create PanelFrame widgets.
+#
+
+require 'tk'
+require 'tkextlib/tcllib.rb'
+
+# TkPackage.require('widget::panelframe', '1.0')
+TkPackage.require('widget::panelframe')
+
+module Tk::Tcllib
+ module Widget
+ class PanelFrame < TkWindow
+ PACKAGE_NAME = 'widget::panelframe'.freeze
+ def self.package_name
+ PACKAGE_NAME
+ end
+
+ def self.package_version
+ begin
+ TkPackage.require('widget::panelframe')
+ rescue
+ ''
+ end
+ end
+ end
+ Panelframe = PanelFrame
+ end
+end
+
+class Tk::Tcllib::Widget::PanelFrame
+ TkCommandNames = ['::widget::panelframe'.freeze].freeze
+
+ def create_self(keys)
+ if keys and keys != None
+ tk_call_without_enc(self.class::TkCommandNames[0], @path,
+ *hash_kv(keys, true))
+ else
+ tk_call_without_enc(self.class::TkCommandNames[0], @path)
+ end
+ end
+ private :create_self
+
+ def add(what, *args)
+ window(tk_send('add', *args))
+ end
+
+ #def get_frame
+ # window(tk_send('getframe'))
+ #end
+
+ def set_widget(widget)
+ tk_send('setwidget', widget)
+ self
+ end
+
+ def remove(*wins)
+ tk_send('remove', *wins)
+ self
+ end
+ def remove_destroy(*wins)
+ tk_send('remove', '-destroy', *wins)
+ self
+ end
+
+ def delete(*wins)
+ tk_send('delete', *wins)
+ self
+ end
+
+ def items
+ simplelist(tk_send('items')).collect!{|w| window(w)}
+ end
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/tcllib/plotchart.rb b/jni/ruby/ext/tk/lib/tkextlib/tcllib/plotchart.rb
new file mode 100644
index 0000000..a1ebe86
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/tcllib/plotchart.rb
@@ -0,0 +1,1404 @@
+#
+# tkextlib/tcllib/plotchart.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+# * Part of tcllib extension
+# * Simple plotting and charting package
+#
+# (The following is the original description of the library.)
+#
+# Plotchart is a Tcl-only package that focuses on the easy creation of
+# xy-plots, barcharts and other common types of graphical presentations.
+# The emphasis is on ease of use, rather than flexibility. The procedures
+# that create a plot use the entire canvas window, making the layout of the
+# plot completely automatic.
+#
+# This results in the creation of an xy-plot in, say, ten lines of code:
+# --------------------------------------------------------------------
+# package require Plotchart
+#
+# canvas .c -background white -width 400 -height 200
+# pack .c -fill both
+#
+# #
+# # Create the plot with its x- and y-axes
+# #
+# set s [::Plotchart::createXYPlot .c {0.0 100.0 10.0} {0.0 100.0 20.0}]
+#
+# foreach {x y} {0.0 32.0 10.0 50.0 25.0 60.0 78.0 11.0 } {
+# $s plot series1 $x $y
+# }
+#
+# $s title "Data series"
+# --------------------------------------------------------------------
+#
+# A drawback of the package might be that it does not do any data management.
+# So if the canvas that holds the plot is to be resized, the whole plot must
+# be redrawn. The advantage, though, is that it offers a number of plot and
+# chart types:
+#
+# * XY-plots like the one shown above with any number of data series.
+# * Stripcharts, a kind of XY-plots where the horizontal axis is adjusted
+# automatically. The result is a kind of sliding window on the data
+# series.
+# * Polar plots, where the coordinates are polar instead of cartesian.
+# * Isometric plots, where the scale of the coordinates in the two
+# directions is always the same, i.e. a circle in world coordinates
+# appears as a circle on the screen.
+# You can zoom in and out, as well as pan with these plots (Note: this
+# works best if no axes are drawn, the zooming and panning routines do
+# not distinguish the axes), using the mouse buttons with the control
+# key and the arrow keys with the control key.
+# * Piecharts, with automatic scaling to indicate the proportions.
+# * Barcharts, with either vertical or horizontal bars, stacked bars or
+# bars side by side.
+# * Timecharts, where bars indicate a time period and milestones or other
+# important moments in time are represented by triangles.
+# * 3D plots (both for displaying surfaces and 3D bars)
+#
+
+require 'tk'
+require 'tkextlib/tcllib.rb'
+
+# TkPackage.require('Plotchart', '0.9')
+# TkPackage.require('Plotchart', '1.1')
+# TkPackage.require('Plotchart', '1.6.3')
+TkPackage.require('Plotchart')
+
+module Tk
+ module Tcllib
+ module Plotchart
+ PACKAGE_NAME = 'Plotchart'.freeze
+ def self.package_name
+ PACKAGE_NAME
+ end
+
+ def self.package_version
+ begin
+ TkPackage.require('Plotchart')
+ rescue
+ ''
+ end
+ end
+ end
+ end
+end
+
+module Tk::Tcllib::Plotchart
+ extend TkCore
+ ############################
+ def self.view_port(w, *args) # args := pxmin, pymin, pxmax, pymax
+ tk_call_without_enc('::Plotchart::viewPort', w.path, *(args.flatten))
+ end
+
+ def self.world_coordinates(w, *args) # args := xmin, ymin, xmax, ymax
+ tk_call_without_enc('::Plotchart::worldCoordinates',
+ w.path, *(args.flatten))
+ end
+
+ def self.world_3D_coordinates(w, *args)
+ # args := xmin, ymin, zmin, xmax, ymax, zmax
+ tk_call_without_enc('::Plotchart::world3DCoordinates',
+ w.path, *(args.flatten))
+ end
+
+ def self.coords_to_pixel(w, x, y)
+ list(tk_call_without_enc('::Plotchart::coordsToPixel', w.path, x, y))
+ end
+
+ def self.coords_3D_to_pixel(w, x, y, z)
+ list(tk_call_without_enc('::Plotchart::coords3DToPixel', w.path, x, y, z))
+ end
+
+ def self.plotconfig(*args)
+ case args.length
+ when 0, 1, 2
+ # 0: (no args) --> list of chat types
+ # 1: charttype --> list of components
+ # 2: charttype, component --> list of properties
+ simplelist(tk_call('::Plotchart::plotconfig', *args))
+ when 3
+ # 3: charttype, component, property --> current value
+ tk_call('::Plotchart::plotconfig', *args)
+ else
+ # 4: charttype, component, property, value : set new value
+ # 5+: Error on Tcl/Tk
+ tk_call('::Plotchart::plotconfig', *args)
+ nil
+ end
+ end
+
+ def self.plotpack(w, dir, *plots)
+ tk_call_without_enc('::Plotchart::plotpack', w.path, dir, *plots)
+ w
+ end
+
+ def self.polar_coordinates(w, radmax)
+ tk_call_without_enc('::Plotchart::polarCoordinates', w.path, radmax)
+ end
+
+ def self.polar_to_pixel(w, rad, phi)
+ list(tk_call_without_enc('::Plotchart::polarToPixel', w.path, rad, phi))
+ end
+
+ def self.pixel_to_coords(w, x, y)
+ list(tk_call_without_enc('::Plotchart::pixelToCoords', w.path, x, y))
+ end
+
+ def self.determine_scale(*args) # (xmin, xmax, inverted=false)
+ tk_call_without_enc('::Plotchart::determineScale', *args)
+ end
+
+ def self.set_zoom_pan(w)
+ tk_call_without_enc('::Plotchart::setZoomPan', w.path)
+ end
+
+ ############################
+ module ChartMethod
+ include TkCore
+
+ def title(str)
+ tk_call_without_enc(@chart, 'title', _get_eval_enc_str(str))
+ self
+ end
+
+ def save_plot(filename)
+ tk_call_without_enc(@chart, 'saveplot', filename)
+ self
+ end
+
+ def xtext(str)
+ tk_call_without_enc(@chart, 'xtext', _get_eval_enc_str(str))
+ self
+ end
+
+ def ytext(str)
+ tk_call_without_enc(@chart, 'ytext', _get_eval_enc_str(str))
+ self
+ end
+
+ def xconfig(key, value=None)
+ if key.kind_of?(Hash)
+ tk_call_without_enc(@chart, 'xconfig', *hash_kv(key, true))
+ else
+ tk_call(@chart, 'xconfig', "-#{key}",value)
+ end
+ self
+ end
+
+ def yconfig(key, value=None)
+ if key.kind_of?(Hash)
+ tk_call_without_enc(@chart, 'yconfig', *hash_kv(key, true))
+ else
+ tk_call(@chart, 'yconfig', "-#{key}", value)
+ end
+ self
+ end
+
+ def background(part, color_or_image, dir)
+ tk_call_without_enc(@chart, 'background',
+ part, color_or_image, dir)
+ self
+ end
+
+ def xticklines(color=None)
+ tk_call(@chart, 'xticklines', color)
+ self
+ end
+
+ def yticklines(color=None)
+ tk_call(@chart, 'yticklines', color)
+ self
+ end
+
+ def legendconfig(key, value=None)
+ if key.kind_of?(Hash)
+ tk_call_without_enc(@chart, 'legendconfig', *hash_kv(key, true))
+ else
+ tk_call(@chart, 'legendconfig', "-#{key}", value)
+ end
+ self
+ end
+
+ def legend(series, text)
+ tk_call_without_enc(@chart, 'legend',
+ _get_eval_enc_str(series), _get_eval_enc_str(text))
+ self
+ end
+
+ def balloon(*args) # args => (x, y, text, dir) or ([x, y], text, dir)
+ if args[0].kind_of?(Array)
+ # args => ([x, y], text, dir)
+ x, y = args.shift
+ else
+ # args => (x, y, text, dir)
+ x = args.shift
+ y = args.shift
+ end
+
+ text, dir = args
+
+ tk_call_without_enc(@chart, 'balloon', x, y,
+ _get_eval_enc_str(text), dir)
+ self
+ end
+
+ def balloonconfig(key, value=None)
+ if key.kind_of?(Hash)
+ tk_call_without_enc(@chart, 'balloonconfig', *hash_kv(key, true))
+ else
+ tk_call(@chart, 'balloonconfig', "-#{key}", value)
+ end
+ end
+
+ def plaintext(*args) # args => (x, y, text, dir) or ([x, y], text, dir)
+ if args[0].kind_of?(Array)
+ # args => ([x, y], text, dir)
+ x, y = args.shift
+ else
+ # args => (x, y, text, dir)
+ x = args.shift
+ y = args.shift
+ end
+
+ text, dir = args
+
+ tk_call_without_enc(@chart, 'plaintext', x, y,
+ _get_eval_enc_str(text), dir)
+ self
+ end
+
+ ############################
+
+ def view_port(*args) # args := pxmin, pymin, pxmax, pymax
+ tk_call_without_enc('::Plotchart::viewPort', @path, *(args.flatten))
+ self
+ end
+
+ def world_coordinates(*args) # args := xmin, ymin, xmax, ymax
+ tk_call_without_enc('::Plotchart::worldCoordinates',
+ @path, *(args.flatten))
+ self
+ end
+
+ def world_3D_coordinates(*args)
+ # args := xmin, ymin, zmin, xmax, ymax, zmax
+ tk_call_without_enc('::Plotchart::world3DCoordinates',
+ @path, *(args.flatten))
+ self
+ end
+
+ def coords_to_pixel(x, y)
+ list(tk_call_without_enc('::Plotchart::coordsToPixel', @path, x, y))
+ end
+
+ def coords_3D_to_pixel(x, y, z)
+ list(tk_call_without_enc('::Plotchart::coords3DToPixel', @path, x, y, z))
+ end
+
+ def plotpack(dir, *plots)
+ tk_call_without_enc('::Plotchart::plotpack', @path, dir, *plots)
+ self
+ end
+
+ def polar_coordinates(radmax)
+ tk_call_without_enc('::Plotchart::polarCoordinates', @path, radmax)
+ self
+ end
+
+ def polar_to_pixel(rad, phi)
+ list(tk_call_without_enc('::Plotchart::polarToPixel', @path, rad, phi))
+ end
+
+ def pixel_to_coords(x, y)
+ list(tk_call_without_enc('::Plotchart::pixelToCoords', @path, x, y))
+ end
+
+ def determine_scale(xmax, ymax)
+ tk_call_without_enc('::Plotchart::determineScale', @path, xmax, ymax)
+ self
+ end
+
+ def set_zoom_pan()
+ tk_call_without_enc('::Plotchart::setZoomPan', @path)
+ self
+ end
+ end
+
+ ############################
+ class XYPlot < Tk::Canvas
+ include ChartMethod
+
+ TkCommandNames = [
+ 'canvas'.freeze,
+ '::Plotchart::createXYPlot'.freeze
+ ].freeze
+
+ def initialize(*args) # args := ([parent,] xaxis, yaxis [, keys])
+ # xaxis := Array of [minimum, maximum, stepsize]
+ # yaxis := Array of [minimum, maximum, stepsize]
+ if args[0].kind_of?(Array)
+ @xaxis = args.shift
+ @yaxis = args.shift
+
+ super(*args) # create canvas widget
+ else
+ parent = args.shift
+
+ @xaxis = args.shift
+ @yaxis = args.shift
+
+ if parent.kind_of?(Tk::Canvas)
+ @path = parent.path
+ else
+ super(parent, *args) # create canvas widget
+ end
+ end
+
+ @chart = _create_chart
+ end
+
+ def _create_chart
+ p self.class::TkCommandNames[1] if $DEBUG
+ tk_call_without_enc(self.class::TkCommandNames[1], @path,
+ array2tk_list(@xaxis), array2tk_list(@yaxis))
+ end
+ private :_create_chart
+
+ def __destroy_hook__
+ Tk::Tcllib::Plotchart::PlotSeries::SeriesID_TBL.mutex.synchronize{
+ Tk::Tcllib::Plotchart::PlotSeries::SeriesID_TBL.delete(@path)
+ }
+ end
+
+ def plot(series, x, y)
+ tk_call_without_enc(@chart, 'plot', _get_eval_enc_str(series), x, y)
+ self
+ end
+
+ def contourlines(xcrd, ycrd, vals, clss=None)
+ xcrd = array2tk_list(xcrd) if xcrd.kind_of?(Array)
+ ycrd = array2tk_list(ycrd) if ycrd.kind_of?(Array)
+ vals = array2tk_list(vals) if vals.kind_of?(Array)
+ clss = array2tk_list(clss) if clss.kind_of?(Array)
+
+ tk_call(@chart, 'contourlines', xcrd, ycrd, vals, clss)
+ self
+ end
+
+ def contourfill(xcrd, ycrd, vals, clss=None)
+ xcrd = array2tk_list(xcrd) if xcrd.kind_of?(Array)
+ ycrd = array2tk_list(ycrd) if ycrd.kind_of?(Array)
+ vals = array2tk_list(vals) if vals.kind_of?(Array)
+ clss = array2tk_list(clss) if clss.kind_of?(Array)
+
+ tk_call(@chart, 'contourfill', xcrd, ycrd, vals, clss)
+ self
+ end
+
+ def contourbox(xcrd, ycrd, vals, clss=None)
+ xcrd = array2tk_list(xcrd) if xcrd.kind_of?(Array)
+ ycrd = array2tk_list(ycrd) if ycrd.kind_of?(Array)
+ vals = array2tk_list(vals) if vals.kind_of?(Array)
+ clss = array2tk_list(clss) if clss.kind_of?(Array)
+
+ tk_call(@chart, 'contourbox', xcrd, ycrd, vals, clss)
+ self
+ end
+
+ def color_map(colors)
+ colors = array2tk_list(colors) if colors.kind_of?(Array)
+
+ tk_call_without_enc(@chart, 'colorMap', colors)
+ self
+ end
+
+ def grid_cells(xcrd, ycrd)
+ xcrd = array2tk_list(xcrd) if xcrd.kind_of?(Array)
+ ycrd = array2tk_list(ycrd) if ycrd.kind_of?(Array)
+
+ tk_call_without_enc(@chart, 'grid', xcrd, ycrd)
+ self
+ end
+
+ def dataconfig(series, key, value=None)
+ if key.kind_of?(Hash)
+ tk_call_without_enc(@chart, 'dataconfig', series, *hash_kv(key, true))
+ else
+ tk_call(@chart, 'dataconfig', series, "-#{key}", value)
+ end
+ end
+
+ def rescale(xscale, yscale) # xscale|yscale => [newmin, newmax, newstep]
+ tk_call_without_enc(@chart, 'rescale', xscale, yscale)
+ self
+ end
+
+ def trend(series, xcrd, ycrd)
+ tk_call_without_enc(@chart, 'trend',
+ _get_eval_enc_str(series), xcrd, ycrd)
+ self
+ end
+
+ def rchart(series, xcrd, ycrd)
+ tk_call_without_enc(@chart, 'rchart',
+ _get_eval_enc_str(series), xcrd, ycrd)
+ self
+ end
+
+ def interval(series, xcrd, ymin, ymax, ycenter=None)
+ tk_call(@chart, 'interval', series, xcrd, ymin, ymax, ycenter)
+ self
+ end
+
+ def box_and_whiskers(series, xcrd, ycrd)
+ tk_call_without_enc(@chart, 'box-and-whiskers',
+ _get_eval_enc_str(series), xcrd, ycrd)
+ self
+ end
+ alias box_whiskers box_and_whiskers
+
+ def vectorconfig(series, key, value=None)
+ if key.kind_of?(Hash)
+ tk_call_without_enc(@chart, 'vectorconfig',
+ _get_eval_enc_str(series), *hash_kv(key, true))
+ else
+ tk_call(@chart, 'vectorconfig', series, "-#{key}", value)
+ end
+ self
+ end
+
+ def vector(series, xcrd, ycrd, ucmp, vcmp)
+ tk_call_without_enc(@chart, 'vector', _get_eval_enc_str(series),
+ xcrd, ycrd, ucmp, vcmp)
+ self
+ end
+
+ def dotconfig(series, key, value=None)
+ if key.kind_of?(Hash)
+ tk_call_without_enc(@chart, 'dotconfig',
+ _get_eval_enc_str(series), *hash_kv(key, true))
+ else
+ tk_call(@chart, 'dotconfig', series, "-#{key}", value)
+ end
+ self
+ end
+
+ def dot(series, xcrd, ycrd, value)
+ tk_call_without_enc(@chart, 'dot', _get_eval_enc_str(series),
+ xcrd, ycrd, value)
+ self
+ end
+ end
+
+ ############################
+ class Stripchart < XYPlot
+ TkCommandNames = [
+ 'canvas'.freeze,
+ '::Plotchart::createStripchart'.freeze
+ ].freeze
+ end
+
+ ############################
+ class TXPlot < XYPlot
+ TkCommandNames = [
+ 'canvas'.freeze,
+ '::Plotchart::createTXPlot'.freeze
+ ].freeze
+ end
+
+ ############################
+ class XLogYPlot < XYPlot
+ TkCommandNames = [
+ 'canvas'.freeze,
+ '::Plotchart::createXLogYPlot'.freeze
+ ].freeze
+ end
+
+ ############################
+ class Histogram < XYPlot
+ TkCommandNames = [
+ 'canvas'.freeze,
+ '::Plotchart::createHistogram'.freeze
+ ].freeze
+ end
+
+ ############################
+ class PolarPlot < Tk::Canvas
+ include ChartMethod
+
+ TkCommandNames = [
+ 'canvas'.freeze,
+ '::Plotchart::createPolarplot'.freeze
+ ].freeze
+
+ def initialize(*args) # args := ([parent,] radius_data [, keys])
+ # radius_data := Array of [maximum_radius, stepsize]
+ if args[0].kind_of?(Array)
+ @radius_data = args.shift
+
+ super(*args) # create canvas widget
+ else
+ parent = args.shift
+
+ @radius_data = args.shift
+
+ if parent.kind_of?(Tk::Canvas)
+ @path = parent.path
+ else
+ super(parent, *args) # create canvas widget
+ end
+ end
+
+ @chart = _create_chart
+ end
+
+ def _create_chart
+ p self.class::TkCommandNames[1] if $DEBUG
+ tk_call_without_enc(self.class::TkCommandNames[1], @path,
+ array2tk_list(@radius_data))
+ end
+ private :_create_chart
+
+ def __destroy_hook__
+ Tk::Tcllib::Plotchart::PlotSeries::SeriesID_TBL.mutex.synchronize{
+ Tk::Tcllib::Plotchart::PlotSeries::SeriesID_TBL.delete(@path)
+ }
+ end
+
+ def plot(series, radius, angle)
+ tk_call_without_enc(@chart, 'plot', _get_eval_enc_str(series),
+ radius, angle)
+ self
+ end
+
+ def dataconfig(series, key, value=None)
+ if key.kind_of?(Hash)
+ tk_call_without_enc(@chart, 'dataconfig', _get_eval_enc_str(series),
+ *hash_kv(key, true))
+ else
+ tk_call(@chart, 'dataconfig', series, "-#{key}", value)
+ end
+ end
+ end
+ Polarplot = PolarPlot
+
+ ############################
+ class IsometricPlot < Tk::Canvas
+ include ChartMethod
+
+ TkCommandNames = [
+ 'canvas'.freeze,
+ '::Plotchart::createIsometricPlot'.freeze
+ ].freeze
+
+ def initialize(*args) # args := ([parent,] xaxis, yaxis, [, step] [, keys])
+ # xaxis := Array of [minimum, maximum]
+ # yaxis := Array of [minimum, maximum]
+ # step := Float of stepsize | "noaxes" | :noaxes
+ if args[0].kind_of?(Array)
+ @xaxis = args.shift
+ @yaxis = args.shift
+
+ if args[0].kind_of?(Hash)
+ @stepsize = :noaxes
+ else
+ @stepsize = args.shift
+ end
+
+ super(*args) # create canvas widget
+ else
+ parent = args.shift
+
+ @xaxis = args.shift
+ @yaxis = args.shift
+
+ if args[0].kind_of?(Hash)
+ @stepsize = :noaxes
+ else
+ @stepsize = args.shift
+ end
+
+ if parent.kind_of?(Tk::Canvas)
+ @path = parent.path
+ else
+ super(parent, *args) # create canvas widget
+ end
+ end
+
+ @chart = _create_chart
+ end
+
+ def _create_chart
+ p self.class::TkCommandNames[1] if $DEBUG
+ tk_call_without_enc(self.class::TkCommandNames[1], @path,
+ array2tk_list(@xaxis), array2tk_list(@yaxis),
+ @stepsize)
+ end
+ private :_create_chart
+
+ def plot(type, *args)
+ self.__send__("plot_#{type.to_s.tr('-', '_')}", *args)
+ end
+
+ def plot_rectangle(*args) # args := x1, y1, x2, y2, color
+ tk_call_without_enc(@chart, 'plot', 'rectangle', *(args.flatten))
+ self
+ end
+
+ def plot_filled_rectangle(*args) # args := x1, y1, x2, y2, color
+ tk_call_without_enc(@chart, 'plot', 'filled-rectangle', *(args.flatten))
+ self
+ end
+
+ def plot_circle(*args) # args := xc, yc, radius, color
+ tk_call_without_enc(@chart, 'plot', 'circle', *(args.flatten))
+ self
+ end
+
+ def plot_filled_circle(*args) # args := xc, yc, radius, color
+ tk_call_without_enc(@chart, 'plot', 'filled-circle', *(args.flatten))
+ self
+ end
+ end
+ Isometricplot = IsometricPlot
+
+ ############################
+ class Plot3D < Tk::Canvas
+ include ChartMethod
+
+ TkCommandNames = [
+ 'canvas'.freeze,
+ '::Plotchart::create3DPlot'.freeze
+ ].freeze
+
+ def initialize(*args) # args := ([parent,] xaxis, yaxis, zaxis [, keys])
+ # xaxis := Array of [minimum, maximum, stepsize]
+ # yaxis := Array of [minimum, maximum, stepsize]
+ # zaxis := Array of [minimum, maximum, stepsize]
+ if args[0].kind_of?(Array)
+ @xaxis = args.shift
+ @yaxis = args.shift
+ @zaxis = args.shift
+
+ super(*args) # create canvas widget
+ else
+ parent = args.shift
+
+ @xaxis = args.shift
+ @yaxis = args.shift
+ @zaxis = args.shift
+
+ if parent.kind_of?(Tk::Canvas)
+ @path = parent.path
+ else
+ super(parent, *args) # create canvas widget
+ end
+ end
+
+ @chart = _create_chart
+ end
+
+ def _create_chart
+ p self.class::TkCommandNames[1] if $DEBUG
+ tk_call_without_enc(self.class::TkCommandNames[1], @path,
+ array2tk_list(@xaxis),
+ array2tk_list(@yaxis),
+ array2tk_list(@zaxis))
+ end
+ private :_create_chart
+
+ def plot_function(cmd=Proc.new)
+ Tk.ip_eval("proc #{@path}_#{@chart} {x y} {#{install_cmd(cmd)} $x $y}")
+ tk_call_without_enc(@chart, 'plotfunc', "#{@path}_#{@chart}")
+ self
+ end
+
+ def plot_funcont(conts, cmd=Proc.new)
+ conts = array2tk_list(conts) if conts.kind_of?(Array)
+ Tk.ip_eval("proc #{@path}_#{@chart} {x y} {#{install_cmd(cmd)} $x $y}")
+ tk_call_without_enc(@chart, 'plotfuncont', "#{@path}_#{@chart}", conts)
+ self
+ end
+
+ def grid_size(nxcells, nycells)
+ tk_call_without_enc(@chart, 'gridsize', nxcells, nycells)
+ self
+ end
+
+ def plot_line(dat, color)
+ # dat has to be provided as a 2 level array.
+ # 1st level contains rows, drawn in y-direction,
+ # and each row is an array whose elements are drawn in x-direction,
+ # for the columns.
+ tk_call_without_enc(@chart, 'plotline', dat, color)
+ self
+ end
+
+ def plot_data(dat)
+ # dat has to be provided as a 2 level array.
+ # 1st level contains rows, drawn in y-direction,
+ # and each row is an array whose elements are drawn in x-direction,
+ # for the columns.
+ tk_call_without_enc(@chart, 'plotdata', dat)
+ self
+ end
+
+ def zconfig(key, value=None)
+ if key.kind_of?(Hash)
+ tk_call_without_enc(@chart, 'zconfig', *hash_kv(key, true))
+ else
+ tk_call(@chart, 'zconfig', "-#{key}", value)
+ end
+ self
+ end
+
+ def colour(fill, border)
+ # configure the colours to use for polygon borders and inner area
+ tk_call_without_enc(@chart, 'colour', fill, border)
+ self
+ end
+ alias colours colour
+ alias colors colour
+ alias color colour
+ end
+
+ ############################
+ class Barchart3D < Tk::Canvas
+ include ChartMethod
+
+ TkCommandNames = [
+ 'canvas'.freeze,
+ '::Plotchart::create3DBarchart'.freeze
+ ].freeze
+
+ def initialize(*args) # args := ([parent,] yaxis, nobars [, keys])
+ # yaxis := Array of [minimum, maximum, stepsize]
+ # nobars := number of bars
+ if args[0].kind_of?(Array)
+ @yaxis = args.shift
+ @nobars = args.shift
+
+ super(*args) # create canvas widget
+ else
+ parent = args.shift
+
+ @yaxis = args.shift
+ @nobars = args.shift
+
+ if parent.kind_of?(Tk::Canvas)
+ @path = parent.path
+ else
+ super(parent, *args) # create canvas widget
+ end
+ end
+
+ @chart = _create_chart
+ end
+
+ def _create_chart
+ p self.class::TkCommandNames[1] if $DEBUG
+ tk_call_without_enc(self.class::TkCommandNames[1], @path,
+ array2tk_list(@yaxis), @nobars)
+ end
+ private :_create_chart
+
+ def plot(label, yvalue, color)
+ tk_call_without_enc(@chart, 'plot', _get_eval_enc_str(label),
+ _get_eval_enc_str(yvalue), color)
+ self
+ end
+
+ def config(key, value=None)
+ if key.kind_of?(Hash)
+ tk_call_without_enc(@chart, 'config', *hash_kv(key, true))
+ else
+ tk_call(@chart, 'config', "-#{key}", value)
+ end
+ self
+ end
+ end
+
+ ############################
+ class RibbonChart3D < Tk::Canvas
+ include ChartMethod
+
+ TkCommandNames = [
+ 'canvas'.freeze,
+ '::Plotchart::create3DRibbonChart'.freeze
+ ].freeze
+
+ def initialize(*args) # args := ([parent,] names, yaxis, zaxis [, keys])
+ # names := Array of the series
+ # yaxis := Array of [minimum, maximum, stepsize]
+ # zaxis := Array of [minimum, maximum, stepsize]
+ if args[0].kind_of?(Array)
+ @names = args.shift
+ @yaxis = args.shift
+ @zaxis = args.shift
+
+ super(*args) # create canvas widget
+ else
+ parent = args.shift
+
+ @names = args.shift
+ @yaxis = args.shift
+ @zaxis = args.shift
+
+ if parent.kind_of?(Tk::Canvas)
+ @path = parent.path
+ else
+ super(parent, *args) # create canvas widget
+ end
+ end
+
+ @chart = _create_chart
+ end
+
+ def _create_chart
+ p self.class::TkCommandNames[1] if $DEBUG
+ tk_call_without_enc(self.class::TkCommandNames[1], @path,
+ array2tk_list(@names),
+ array2tk_list(@yaxis),
+ array2tk_list(@zaxis))
+ end
+ private :_create_chart
+
+ def line(*args) # xypairs, color
+ color = args.pop # last argument is a color
+ xypairs = TkComm.slice_ary(args.flatten, 2) # regenerate xypairs
+ tk_call_without_enc(@chart, 'line', xypairs, color)
+ self
+ end
+
+ def area(*args) # xypairs, color
+ color = args.pop # last argument is a color
+ xypairs = TkComm.slice_ary(args.flatten, 2) # regenerate xypairs
+ tk_call_without_enc(@chart, 'area', xypairs, color)
+ self
+ end
+
+ def zconfig(key, value=None)
+ if key.kind_of?(Hash)
+ tk_call_without_enc(@chart, 'zconfig', *hash_kv(key, true))
+ else
+ tk_call(@chart, 'zconfig',"-#{key}", value)
+ end
+ self
+ end
+ end
+
+
+ ############################
+ class Piechart < Tk::Canvas
+ include ChartMethod
+
+ TkCommandNames = [
+ 'canvas'.freeze,
+ '::Plotchart::createPiechart'.freeze
+ ].freeze
+
+ def initialize(*args) # args := ([parent] [, keys])
+ if args[0].kind_of?(Tk::Canvas)
+ parent = args.shift
+ @path = parent.path
+ else
+ super(*args) # create canvas widget
+ end
+ @chart = _create_chart
+ end
+
+ def _create_chart
+ p self.class::TkCommandNames[1] if $DEBUG
+ tk_call_without_enc(self.class::TkCommandNames[1], @path)
+ end
+ private :_create_chart
+
+ def plot(*dat) # argument is a list of [label, value]
+ tk_call(@chart, 'plot', dat.flatten)
+ self
+ end
+
+ def colours(*list)
+ tk_call_without_enc(@chart, 'colours', *list)
+ self
+ end
+ alias colors colours
+ end
+
+
+ ############################
+ class Radialchart < Tk::Canvas
+ include ChartMethod
+
+ TkCommandNames = [
+ 'canvas'.freeze,
+ '::Plotchart::createRadialchart'.freeze
+ ].freeze
+
+ def initialize(*args) # args := ([parent,] names, scale, style [, keys])
+ # radius_data := Array of [maximum_radius, stepsize]
+ if args[0].kind_of?(Array)
+ @names = args.shift
+ @scale = args.shift
+ @style = args.shift
+
+ super(*args) # create canvas widget
+ else
+ parent = args.shift
+
+ @names = args.shift
+ @scale = args.shift
+ @style = args.shift
+
+ if parent.kind_of?(Tk::Canvas)
+ @path = parent.path
+ else
+ super(parent, *args) # create canvas widget
+ end
+ end
+
+ @chart = _create_chart
+ end
+
+ def _create_chart
+ p self.class::TkCommandNames[1] if $DEBUG
+ tk_call_without_enc(self.class::TkCommandNames[1], @path,
+ array2tk_list(@names), @scale, @style)
+ end
+ private :_create_chart
+
+ def __destroy_hook__
+ Tk::Tcllib::Plotchart::PlotSeries::SeriesID_TBL.mutex.synchronize{
+ Tk::Tcllib::Plotchart::PlotSeries::SeriesID_TBL.delete(@path)
+ }
+ end
+
+ def plot(data, color, thickness)
+ tk_call_without_enc(@chart, 'plot', _get_eval_enc_str(data),
+ color, thickness)
+ self
+ end
+
+ def colours(*list)
+ tk_call_without_enc(@chart, 'colours', *list)
+ self
+ end
+ alias colors colours
+ end
+
+ ############################
+ class Barchart < Tk::Canvas
+ include ChartMethod
+
+ TkCommandNames = [
+ 'canvas'.freeze,
+ '::Plotchart::createBarchart'.freeze
+ ].freeze
+
+ def initialize(*args)
+ # args := ([parent,] xlabels, ylabels [, series] [, keys])
+ # xlabels, ylabels := labels | axis ( depend on normal or horizontal )
+ # labels := Array of [label, label, ...]
+ # (It determines the number of bars that will be plotted per series.)
+ # axis := Array of [minimum, maximum, stepsize]
+ # series := Integer number of data series | 'stacked' | :stacked
+ if args[0].kind_of?(Array)
+ @xlabels = args.shift
+ @ylabels = args.shift
+
+ if args[0].kind_of?(Hash)
+ @series_size = :stacked
+ else
+ @series_size = args.shift
+ end
+
+ super(*args) # create canvas widget
+ else
+ parent = args.shift
+
+ @xlabels = args.shift
+ @ylabels = args.shift
+
+ if args[0].kind_of?(Hash)
+ @series_size = :stacked
+ else
+ @series_size = args.shift
+ end
+
+ if parent.kind_of?(Tk::Canvas)
+ @path = parent.path
+ else
+ super(parent, *args) # create canvas widget
+ end
+ end
+
+ @chart = _create_chart
+ end
+
+ def _create_chart
+ p self.class::TkCommandNames[1] if $DEBUG
+ tk_call_without_enc(self.class::TkCommandNames[1], @path,
+ array2tk_list(@xlabels), array2tk_list(@ylabels),
+ @series_size)
+ end
+ private :_create_chart
+
+ def __destroy_hook__
+ Tk::Tcllib::Plotchart::PlotSeries::SeriesID_TBL.mutex.synchronize{
+ Tk::Tcllib::Plotchart::PlotSeries::SeriesID_TBL.delete(@path)
+ }
+ end
+
+ def plot(series, dat, col=None)
+ tk_call(@chart, 'plot', series, dat, col)
+ self
+ end
+
+ def colours(*cols)
+ # set the colours to be used
+ tk_call(@chart, 'colours', *cols)
+ self
+ end
+ alias colour colours
+ alias colors colours
+ alias color colours
+ end
+
+ ############################
+ class HorizontalBarchart < Barchart
+ TkCommandNames = [
+ 'canvas'.freeze,
+ '::Plotchart::createHorizontalBarchart'.freeze
+ ].freeze
+ end
+
+ ############################
+ class Boxplot < Tk::Canvas
+ include ChartMethod
+
+ TkCommandNames = [
+ 'canvas'.freeze,
+ '::Plotchart::createBoxplot'.freeze
+ ].freeze
+
+ def initialize(*args) # args := ([parent,] xaxis, ylabels [, keys])
+ # xaxis := Array of [minimum, maximum, stepsize]
+ # yaxis := List of labels for the y-axis
+ if args[0].kind_of?(Array)
+ @xaxis = args.shift
+ @ylabels = args.shift
+
+ super(*args) # create canvas widget
+ else
+ parent = args.shift
+
+ @xaxis = args.shift
+ @ylabels = args.shift
+
+ if parent.kind_of?(Tk::Canvas)
+ @path = parent.path
+ else
+ super(parent, *args) # create canvas widget
+ end
+ end
+
+ @chart = _create_chart
+ end
+
+ def _create_chart
+ p self.class::TkCommandNames[1] if $DEBUG
+ tk_call_without_enc(self.class::TkCommandNames[1], @path,
+ array2tk_list(@xaxis), array2tk_list(@ylabels))
+ end
+ private :_create_chart
+
+ def __destroy_hook__
+ Tk::Tcllib::Plotchart::PlotSeries::SeriesID_TBL.mutex.synchronize{
+ Tk::Tcllib::Plotchart::PlotSeries::SeriesID_TBL.delete(@path)
+ }
+ end
+
+ def plot(label, *values)
+ tk_call(@chart, 'plot', label, values.flatten)
+ self
+ end
+ end
+
+ ############################
+ class RightAxis < Tk::Canvas
+ include ChartMethod
+
+ TkCommandNames = [
+ 'canvas'.freeze,
+ '::Plotchart::createRightAxis'.freeze
+ ].freeze
+
+ def initialize(*args) # args := ([parent,] yaxis [, keys])
+ # yaxis := Array of [minimum, maximum, stepsize]
+ if args[0].kind_of?(Array)
+ @yaxis = args.shift
+
+ super(*args) # create canvas widget
+ else
+ parent = args.shift
+
+ @yaxis = args.shift
+
+ if parent.kind_of?(Tk::Canvas)
+ @path = parent.path
+ else
+ super(parent, *args) # create canvas widget
+ end
+ end
+
+ @chart = _create_chart
+ end
+
+ def _create_chart
+ p self.class::TkCommandNames[1] if $DEBUG
+ tk_call_without_enc(self.class::TkCommandNames[1], @path,
+ array2tk_list(@yaxis))
+ end
+ private :_create_chart
+
+ def __destroy_hook__
+ Tk::Tcllib::Plotchart::PlotSeries::SeriesID_TBL.mutex.synchronize{
+ Tk::Tcllib::Plotchart::PlotSeries::SeriesID_TBL.delete(@path)
+ }
+ end
+ end
+
+ ############################
+ class Timechart < Tk::Canvas
+ include ChartMethod
+
+ TkCommandNames = [
+ 'canvas'.freeze,
+ '::Plotchart::createTimechart'.freeze
+ ].freeze
+
+ def initialize(*args)
+ # args := ([parent,] time_begin, time_end, items [, keys])
+ # time_begin := String of time format (e.g. "1 january 2004")
+ # time_end := String of time format (e.g. "1 january 2004")
+ # items := Expected/maximum number of items
+ # ( This determines the vertical spacing. )
+ if args[0].kind_of?(String)
+ @time_begin = args.shift
+ @time_end = args.shift
+ @items = args.shift
+
+ super(*args) # create canvas widget
+ else
+ parent = args.shift
+
+ @time_begin = args.shift
+ @time_end = args.shift
+ @items = args.shift
+
+ if parent.kind_of?(Tk::Canvas)
+ @path = parent.path
+ else
+ super(parent, *args) # create canvas widget
+ end
+ end
+
+ @chart = _create_chart
+ end
+
+ def _create_chart
+ p self.class::TkCommandNames[1] if $DEBUG
+ tk_call_without_enc(self.class::TkCommandNames[1], @path,
+ @time_begin, @time_end, @items)
+ end
+ private :_create_chart
+
+ def period(txt, time_begin, time_end, col=None)
+ tk_call(@chart, 'period', txt, time_begin, time_end, col)
+ self
+ end
+
+ def milestone(txt, time, col=None)
+ tk_call(@chart, 'milestone', txt, time, col)
+ self
+ end
+
+ def vertline(txt, time)
+ tk_call(@chart, 'vertline', txt, time)
+ self
+ end
+
+ def hscroll=(scr)
+ tk_call_without_enc(@chart, 'hscroll', scr)
+ scr
+ end
+ def hscroll(scr)
+ tk_call_without_enc(@chart, 'hscroll', scr)
+ self
+ end
+
+ def vscroll=(scr)
+ tk_call_without_enc(@chart, 'vscroll', scr)
+ scr
+ end
+ def vscroll(scr)
+ tk_call_without_enc(@chart, 'vscroll', scr)
+ self
+ end
+ end
+
+ ############################
+ class Ganttchart < Tk::Canvas
+ include ChartMethod
+
+ TkCommandNames = [
+ 'canvas'.freeze,
+ '::Plotchart::createGanttchart'.freeze
+ ].freeze
+
+ def initialize(*args)
+ # args := ([parent,] time_begin, time_end, items [, text_width] [, keys])
+ # time_begin := String of time format (e.g. "1 january 2004")
+ # time_end := String of time format (e.g. "1 january 2004")
+ # args := Expected/maximum number of items
+ # ( This determines the vertical spacing. ),
+ # Expected/maximum width of items,
+ # Option Hash ( { key=>value, ... } )
+ if args[0].kind_of?(String)
+ @time_begin = args.shift
+ @time_end = args.shift
+ @args = args
+
+ super(*args) # create canvas widget
+ else
+ parent = args.shift
+
+ @time_begin = args.shift
+ @time_end = args.shift
+ @args = args
+
+ if parent.kind_of?(Tk::Canvas)
+ @path = parent.path
+ else
+ super(parent, *args) # create canvas widget
+ end
+ end
+
+ @chart = _create_chart
+ end
+
+ def _create_chart
+ p self.class::TkCommandNames[1] if $DEBUG
+ tk_call(self.class::TkCommandNames[1], @path,
+ @time_begin, @time_end, *args)
+ end
+ private :_create_chart
+
+ def task(txt, time_begin, time_end, completed=0.0)
+ list(tk_call(@chart, 'task', txt, time_begin, time_end,
+ completed)).collect!{|id|
+ TkcItem.id2obj(self, id)
+ }
+ end
+
+ def milestone(txt, time, col=None)
+ tk_call(@chart, 'milestone', txt, time, col)
+ self
+ end
+
+ def vertline(txt, time)
+ tk_call(@chart, 'vertline', txt, time)
+ self
+ end
+
+ def connect(from_task, to_task)
+ from_task = array2tk_list(from_task) if from_task.kind_of?(Array)
+ to_task = array2tk_list(to_task) if to_task.kind_of?(Array)
+
+ tk_call(@chart, 'connect', from_task, to_task)
+ self
+ end
+
+ def summary(txt, tasks)
+ tasks = array2tk_list(tasks) if tasks.kind_of?(Array)
+ tk_call(@chart, 'summary', tasks)
+ self
+ end
+
+ def color_of_part(keyword, newcolor)
+ tk_call(@chart, 'color', keyword, newcolor)
+ self
+ end
+
+ def font_of_part(keyword, newfont)
+ tk_call(@chart, 'font', keyword, newfont)
+ self
+ end
+
+ def hscroll=(scr)
+ tk_call_without_enc(@chart, 'hscroll', scr)
+ scr
+ end
+ def hscroll(scr)
+ tk_call_without_enc(@chart, 'hscroll', scr)
+ self
+ end
+
+ def vscroll=(scr)
+ tk_call_without_enc(@chart, 'vscroll', scr)
+ scr
+ end
+ def vscroll(scr)
+ tk_call_without_enc(@chart, 'vscroll', scr)
+ self
+ end
+ end
+
+ ############################
+ class PlotSeries < TkObject
+ SeriesID_TBL = TkCore::INTERP.create_table
+
+ (Series_ID = ['series'.freeze, TkUtil.untrust('00000')]).instance_eval{
+ @mutex = Mutex.new
+ def mutex; @mutex; end
+ freeze
+ }
+ TkCore::INTERP.init_ip_env{
+ SeriesID_TBL.mutex.synchronize{ SeriesID_TBL.clear }
+ }
+
+ def self.id2obj(chart, id)
+ path = chart.path
+ SeriesID_TBL.mutex.synchronize{
+ if SeriesID_TBL[path]
+ SeriesID_TBL[path][id]? SeriesID_TBL[path][id]: id
+ else
+ id
+ end
+ }
+ end
+
+ def initialize(chart, keys=nil)
+ @parent = @chart_obj = chart
+ @ppath = @chart_obj.path
+ Series_ID.mutex.synchronize{
+ @path = @series = @id = Series_ID.join(TkCore::INTERP._ip_id_)
+ Series_ID[1].succ!
+ }
+ SeriesID_TBL.mutex.synchronize{
+ SeriesID_TBL[@ppath] ||= {}
+ SeriesID_TBL[@ppath][@id] = self
+ }
+ dataconfig(keys) if keys.kind_of?(Hash)
+ end
+
+ def plot(*args)
+ @chart_obj.plot(@series, *args)
+ end
+
+ def dataconfig(key, value=None)
+ @chart_obj.dataconfig(@series, key, value)
+ end
+ end
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/tcllib/ruler.rb b/jni/ruby/ext/tk/lib/tkextlib/tcllib/ruler.rb
new file mode 100644
index 0000000..d22dafa
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/tcllib/ruler.rb
@@ -0,0 +1,65 @@
+#
+# tkextlib/tcllib/ruler.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+# * Part of tcllib extension
+# * ruler widget
+#
+
+require 'tk'
+require 'tkextlib/tcllib.rb'
+
+# TkPackage.require('widget::ruler', '1.0')
+TkPackage.require('widget::ruler')
+
+module Tk::Tcllib
+ module Widget
+ class Ruler < TkWindow
+ PACKAGE_NAME = 'widget::ruler'.freeze
+ def self.package_name
+ PACKAGE_NAME
+ end
+
+ def self.package_version
+ begin
+ TkPackage.require('widget::ruler')
+ rescue
+ ''
+ end
+ end
+ end
+ end
+end
+
+class Tk::Tcllib::Widget::Ruler
+ TkCommandNames = ['::widget::ruler'.freeze].freeze
+
+ def __boolval_optkeys
+ ['showvalues', 'outline', 'grid']
+ end
+ private :__boolval_optkeys
+
+ def __numlistval_optkeys
+ ['interval', 'sizes']
+ end
+ private :__numlistval_optkeys
+
+ def create_self(keys)
+ if keys and keys != None
+ tk_call_without_enc(self.class::TkCommandNames[0], @path,
+ *hash_kv(keys, true))
+ else
+ tk_call_without_enc(self.class::TkCommandNames[0], @path)
+ end
+ end
+ private :create_self
+
+ def redraw
+ tk_send('redraw')
+ self
+ end
+
+ def shade(org, dest, frac)
+ tk_send('shade', org, dest, frac)
+ end
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/tcllib/screenruler.rb b/jni/ruby/ext/tk/lib/tkextlib/tcllib/screenruler.rb
new file mode 100644
index 0000000..75fa36b
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/tcllib/screenruler.rb
@@ -0,0 +1,68 @@
+#
+# tkextlib/tcllib/screenruler.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+# * Part of tcllib extension
+# * screenruler dialog
+#
+
+require 'tk'
+require 'tkextlib/tcllib.rb'
+
+# TkPackage.require('widget::screenruler', '1.1')
+TkPackage.require('widget::screenruler')
+
+module Tk::Tcllib
+ module Widget
+ class ScreenRuler < TkWindow
+ PACKAGE_NAME = 'widget::ruler'.freeze
+ def self.package_name
+ PACKAGE_NAME
+ end
+
+ def self.package_version
+ begin
+ TkPackage.require('widget::screenruler')
+ rescue
+ ''
+ end
+ end
+ end
+ Screenruler = ScreenRuler
+ end
+end
+
+class Tk::Tcllib::Widget::ScreenRuler
+ TkCommandNames = ['::widget::screenruler'.freeze].freeze
+
+ def __boolval_optkeys
+ ['topmost', 'reflect']
+ end
+ private :__boolval_optkeys
+
+ def __numlistval_optkeys
+ ['alpha']
+ end
+ private :__numlistval_optkeys
+
+ def create_self(keys)
+ if keys and keys != None
+ tk_call_without_enc(self.class::TkCommandNames[0], @path,
+ *hash_kv(keys, true))
+ else
+ tk_call_without_enc(self.class::TkCommandNames[0], @path)
+ end
+ end
+ private :create_self
+
+ def display
+ tk_send('display')
+ self
+ end
+ alias show display
+
+ def hide
+ tk_send('hide')
+ self
+ end
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/tcllib/scrolledwindow.rb b/jni/ruby/ext/tk/lib/tkextlib/tcllib/scrolledwindow.rb
new file mode 100644
index 0000000..c9488b4
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/tcllib/scrolledwindow.rb
@@ -0,0 +1,57 @@
+#
+# tkextlib/tcllib/scrolledwindow.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+# * Part of tcllib extension
+# * scrolledwindow widget
+#
+
+require 'tk'
+require 'tkextlib/tcllib.rb'
+
+# TkPackage.require('widget::scrolledwindow', '1.2')
+TkPackage.require('widget::scrolledwindow')
+
+module Tk::Tcllib
+ module Widget
+ class Scrolledwindow < Tk::Tile::TFrame
+ PACKAGE_NAME = 'widget::scrolledwindow'.freeze
+ def self.package_name
+ PACKAGE_NAME
+ end
+
+ def self.package_version
+ begin
+ TkPackage.require('widget::scrolledwindow')
+ rescue
+ ''
+ end
+ end
+ end
+ ScrolledWindow = Scrolledwindow
+ end
+end
+
+class Tk::Tcllib::Widget::ScrolledWindow
+ TkCommandNames = ['::widget::scrolledwindow'.freeze].freeze
+
+ def create_self(keys)
+ if keys and keys != None
+ tk_call_without_enc(self.class::TkCommandNames[0], @path,
+ *hash_kv(keys, true))
+ else
+ tk_call_without_enc(self.class::TkCommandNames[0], @path)
+ end
+ end
+ private :create_self
+
+ def getframe
+ window(tk_send_without_enc('getframe'))
+ end
+ alias get_frame getframe
+
+ def setwidget(w)
+ window(tk_send_without_enc('setwidget', w))
+ end
+ alias set_widget setwidget
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/tcllib/scrollwin.rb b/jni/ruby/ext/tk/lib/tkextlib/tcllib/scrollwin.rb
new file mode 100644
index 0000000..c9f6062
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/tcllib/scrollwin.rb
@@ -0,0 +1,61 @@
+#
+# tkextlib/tcllib/scrollwin.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+# * Part of tcllib extension
+# * Scrolled widget
+#
+
+require 'tk'
+require 'tkextlib/tcllib.rb'
+
+# TkPackage.require('widget::scrolledwindow', '1.0')
+TkPackage.require('widget::scrolledwindow')
+
+module Tk::Tcllib
+ module Widget
+ class ScrolledWindow < TkWindow
+ PACKAGE_NAME = 'widget::scrolledwindow'.freeze
+ def self.package_name
+ PACKAGE_NAME
+ end
+
+ def self.package_version
+ begin
+ TkPackage.require('widget::scrolledwindow')
+ rescue
+ ''
+ end
+ end
+ end
+ Scrolledwindow = ScrolledWindow
+ end
+end
+
+class Tk::Tcllib::Widget::ScrolledWindow
+ TkCommandNames = ['::widget::scrolledwindow'.freeze].freeze
+
+ def __numlistval_optkeys
+ ['ipad']
+ end
+ private :__numlistval_optkeys
+
+ def create_self(keys)
+ if keys and keys != None
+ tk_call_without_enc(self.class::TkCommandNames[0], @path,
+ *hash_kv(keys, true))
+ else
+ tk_call_without_enc(self.class::TkCommandNames[0], @path)
+ end
+ end
+ private :create_self
+
+ def get_frame
+ window(tk_send('getframe'))
+ end
+
+ def set_widget(widget)
+ tk_send('setwidget', widget)
+ self
+ end
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/tcllib/setup.rb b/jni/ruby/ext/tk/lib/tkextlib/tcllib/setup.rb
new file mode 100644
index 0000000..ee406c6
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/tcllib/setup.rb
@@ -0,0 +1,8 @@
+#
+# setup.rb -- setup script before calling TkPackage.require()
+#
+# If you need some setup operations (for example, add a library path
+# to the library search path) before using Tcl/Tk library packages
+# wrapped by Ruby scripts in this directory, please write the setup
+# operations in this file.
+#
diff --git a/jni/ruby/ext/tk/lib/tkextlib/tcllib/statusbar.rb b/jni/ruby/ext/tk/lib/tkextlib/tcllib/statusbar.rb
new file mode 100644
index 0000000..46a4b9d
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/tcllib/statusbar.rb
@@ -0,0 +1,79 @@
+#
+# tkextlib/tcllib/statusbar.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+# * Part of tcllib extension
+# * statusbar widget
+#
+
+require 'tk'
+require 'tkextlib/tcllib.rb'
+
+# TkPackage.require('widget::statusbar', '1.2')
+TkPackage.require('widget::statusbar')
+
+module Tk::Tcllib
+ module Widget
+ class Statusbar < Tk::Tile::TFrame
+ PACKAGE_NAME = 'widget::statusbar'.freeze
+ def self.package_name
+ PACKAGE_NAME
+ end
+
+ def self.package_version
+ begin
+ TkPackage.require('widget::statusbar')
+ rescue
+ ''
+ end
+ end
+ end
+ end
+end
+
+class Tk::Tcllib::Widget::Statusbar
+ TkCommandNames = ['::widget::statusbar'.freeze].freeze
+
+ def __boolval_optkeys
+ super() << 'separator' << 'resize' << 'resizeseparator'
+ end
+ private :__boolval_optkeys
+
+ def create_self(keys)
+ if keys and keys != None
+ tk_call_without_enc(self.class::TkCommandNames[0], @path,
+ *hash_kv(keys, true))
+ else
+ tk_call_without_enc(self.class::TkCommandNames[0], @path)
+ end
+ end
+ private :create_self
+
+ def getframe
+ window(tk_send_without_enc('getframe'))
+ end
+ alias get_frame getframe
+
+ def add(w, keys={})
+ window(tk_send_without_enc('setwidget', *(hash_kv(keys))))
+ end
+
+ def remove(*wins)
+ tk_send_without_enc('remove', *wins)
+ self
+ end
+
+ def remove_with_destroy(*wins)
+ tk_send_without_enc('remove', '-destroy', *wins)
+ self
+ end
+
+ def delete(*wins)
+ tk_send_without_enc('delete', *wins)
+ self
+ end
+
+ def items(pat=None)
+ tk_split_list(tk_send('items', pat))
+ end
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/tcllib/style.rb b/jni/ruby/ext/tk/lib/tkextlib/tcllib/style.rb
new file mode 100644
index 0000000..dac6916
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/tcllib/style.rb
@@ -0,0 +1,61 @@
+#
+# tkextlib/tcllib/style.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+# * Part of tcllib extension
+# * select and use some 'style' of option (resource) DB
+#
+
+require 'tk'
+require 'tkextlib/tcllib.rb'
+
+module Tk::Tcllib
+ module Style
+ PACKAGE_NAME = 'style'.freeze
+ def self.package_name
+ PACKAGE_NAME
+ end
+
+ def self.package_version
+ begin
+ TkPackage.require('style')
+ rescue
+ ''
+ end
+ end
+
+ def self.not_available
+ fail RuntimeError, "'tkextlib/tcllib/style' extension is not available on your current environment."
+ end
+
+ def self.names
+ Tk::Tcllib::Style.not_available
+ end
+
+ def self.use(style)
+ Tk::Tcllib::Style.not_available
+ end
+ end
+end
+
+# TkPackage.require('style', '0.1')
+# TkPackage.require('style', '0.3')
+TkPackage.require('style')
+
+module Tk::Tcllib
+ class << Style
+ undef not_available
+ end
+
+ module Style
+ extend TkCore
+
+ def self.names
+ tk_split_simplelist(tk_call('style::names'))
+ end
+
+ def self.use(style)
+ tk_call('style::use', style)
+ end
+ end
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/tcllib/superframe.rb b/jni/ruby/ext/tk/lib/tkextlib/tcllib/superframe.rb
new file mode 100644
index 0000000..adc9c4a
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/tcllib/superframe.rb
@@ -0,0 +1,51 @@
+#
+# tkextlib/tcllib/superframe.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+# * Part of tcllib extension
+# * Superframe widget - enhanced labelframe widget
+#
+
+require 'tk'
+require 'tkextlib/tcllib.rb'
+
+# TkPackage.require('widget::superframe', '1.0')
+TkPackage.require('widget::superframe')
+
+module Tk::Tcllib
+ module Widget
+ class SuperFrame < TkWindow
+ PACKAGE_NAME = 'widget::superframe'.freeze
+ def self.package_name
+ PACKAGE_NAME
+ end
+
+ def self.package_version
+ begin
+ TkPackage.require('widget::superframe')
+ rescue
+ ''
+ end
+ end
+ end
+ Superframe = SuperlFrame
+ end
+end
+
+class Tk::Tcllib::Widget::SuperFrame
+ TkCommandNames = ['::widget::superframe'.freeze].freeze
+
+ def create_self(keys)
+ if keys and keys != None
+ tk_call_without_enc(self.class::TkCommandNames[0], @path,
+ *hash_kv(keys, true))
+ else
+ tk_call_without_enc(self.class::TkCommandNames[0], @path)
+ end
+ end
+ private :create_self
+
+ def labelwidget
+ window(tk_send('labelwidget'))
+ end
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/tcllib/swaplist.rb b/jni/ruby/ext/tk/lib/tkextlib/tcllib/swaplist.rb
new file mode 100644
index 0000000..7698640
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/tcllib/swaplist.rb
@@ -0,0 +1,150 @@
+#
+# tkextlib/tcllib/swaplist.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+# * Part of tcllib extension
+# * A dialog which allows a user to move options between two lists
+#
+
+require 'tk'
+require 'tkextlib/tcllib.rb'
+
+# TkPackage.require('swaplist', '0.1')
+TkPackage.require('swaplist')
+
+module Tk::Tcllib
+ class Swaplist_Dialog < TkWindow
+ PACKAGE_NAME = 'swaplist'.freeze
+ def self.package_name
+ PACKAGE_NAME
+ end
+
+ def self.package_version
+ begin
+ TkPackage.require('swaplist')
+ rescue
+ ''
+ end
+ end
+ end
+end
+
+
+class Tk::Tcllib::Swaplist_Dialog
+ TkCommandNames = ['::swaplist::swaplist'.freeze].freeze
+ WidgetClassName = 'Swaplist'.freeze
+ WidgetClassNames[WidgetClassName] ||= self
+
+ def self.show(*args)
+ dialog = self.new(*args)
+ dialog.show
+ [dialog.status, dialog.value]
+ end
+ def self.display(*args)
+ self.show(*args)
+ end
+
+ def initialize(*args)
+ # args = (parent=nil, complete_list=[], selected_list=[], keys=nil)
+ keys = args.pop
+ if keys.kind_of?(Hash)
+ @selected_list = args.pop
+ @complete_list = args.pop
+ @keys = _symbolkey2str(keys)
+ args.push(keys)
+ else
+ @selected_list = keys
+ @complete_list = args.pop
+ @keys = {}
+ end
+
+ @selected_list = [] unless @selected_list
+ @complete_list = [] unless @complete_list
+
+ @variable = TkVariable.new
+ @status = nil
+
+ super(*args)
+ end
+
+ def create_self(keys)
+ # dummy
+ end
+ private :create_self
+
+ def show
+ @variable.value = ''
+ @status = bool(tk_call(self.class::TkCommandNames[0],
+ @path, @variable,
+ @complete_list, @selected_list,
+ *hash_kv(@keys)))
+ end
+ alias display show
+
+ def status
+ @status
+ end
+
+ def value
+ @variable.list
+ end
+ alias selected value
+
+ def cget_strict(slot)
+ slot = slot.to_s
+ if slot == 'complete_list'
+ @complete_list
+ elsif slot == 'selected_list'
+ @selected_list
+ else
+ @keys[slot]
+ end
+ end
+ def cget(slot)
+ cget_strict(slot)
+ end
+
+ def configure(slot, value=None)
+ if slot.kind_of?(Hash)
+ slot.each{|k, v| configure(k, v)}
+ else
+ slot = slot.to_s
+ value = _symbolkey2str(value) if value.kind_of?(Hash)
+ if value && value != None
+ if slot == 'complete_list'
+ @complete_list = value
+ elsif slot == 'selected_list'
+ @selected_list = value
+ else
+ @keys[slot] = value
+ end
+ else
+ if slot == 'complete_list'
+ @complete_list = []
+ elsif slot == 'selected_list'
+ @selected_list = []
+ else
+ @keys.delete(slot)
+ end
+ end
+ end
+ self
+ end
+
+ def configinfo(slot = nil)
+ if slot
+ slot = slot.to_s
+ if slot == 'complete_list'
+ [ slot, nil, nil, nil, @complete_list ]
+ elsif slot == 'selected_list'
+ [ slot, nil, nil, nil, @selected_list ]
+ else
+ [ slot, nil, nil, nil, @keys[slot] ]
+ end
+ else
+ @keys.collect{|k, v| [ k, nil, nil, nil, v ] } \
+ << [ 'complete_list', nil, nil, nil, @complete_list ] \
+ << [ 'selected_list', nil, nil, nil, @selected_list ]
+ end
+ end
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/tcllib/tablelist.rb b/jni/ruby/ext/tk/lib/tkextlib/tcllib/tablelist.rb
new file mode 100644
index 0000000..bf5ab66
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/tcllib/tablelist.rb
@@ -0,0 +1,28 @@
+#
+# tkextlib/tcllib/tablelist.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+# * Part of tcllib extension
+# * A multi-column listbox
+
+require 'tk'
+require 'tkextlib/tcllib.rb'
+
+# check Tile extension :: If already loaded, use tablelist_tile.
+unless defined? Tk::Tcllib::Tablelist_usingTile
+ Tk::Tcllib::Tablelist_usingTile =
+ TkPackage.provide('tile') || TkPackage.provide('Ttk')
+end
+
+if Tk::Tcllib::Tablelist_usingTile
+ # with Tile
+ require 'tkextlib/tcllib/tablelist_tile'
+
+else
+ # without Tile
+
+ # TkPackage.require('tablelist', '4.2')
+ TkPackage.require('tablelist')
+
+ require 'tkextlib/tcllib/tablelist_core'
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/tcllib/tablelist_core.rb b/jni/ruby/ext/tk/lib/tkextlib/tcllib/tablelist_core.rb
new file mode 100644
index 0000000..2a5c415
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/tcllib/tablelist_core.rb
@@ -0,0 +1,1072 @@
+#
+# tkextlib/tcllib/tablelist_core.rb
+#
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+# * Part of tcllib extension
+# * This file is required by 'tkextlib/tcllib/tablelist.rb' or
+# 'tkextlib/tcllib/tablelist_tile.rb'.
+#
+
+module Tk
+ module Tcllib
+ class Tablelist < TkWindow
+ if Tk::Tcllib::Tablelist_usingTile
+ PACKAGE_NAME = 'Tablelist_tile'.freeze
+ else
+ PACKAGE_NAME = 'Tablelist'.freeze
+ end
+ def self.package_name
+ PACKAGE_NAME
+ end
+
+ def self.package_version
+ begin
+ TkPackage.require(self.package_name)
+ rescue
+ ''
+ end
+ end
+
+ def self.use_Tile?
+ (Tk::Tcllib::Tablelist_usingTile)? true: false
+ end
+ end
+ TableList = Tablelist
+ end
+end
+
+module Tk::Tcllib::TablelistItemConfig
+ include TkItemConfigMethod
+
+ def _to_idx(idx)
+ if idx.kind_of?(Array)
+ idx.collect{|elem| _get_eval_string(elem)}.join(',')
+ else
+ idx
+ end
+ end
+ def _from_idx(idx)
+ return idx unless idx.kind_of?(String)
+
+ if idx[0] == ?@ # '@x,y'
+ idx
+ elsif idx =~ /([^,]+),([^,]+)/
+ row = $1, column = $2
+ [num_or_str(row), num_or_str(column)]
+ else
+ num_or_str(idx)
+ end
+ end
+ private :_to_idx, :_from_idx
+
+ def __item_cget_cmd(mixed_id)
+ [self.path, mixed_id[0] + 'cget', _to_idx(mixed_id[1])]
+ end
+ def __item_config_cmd(mixed_id)
+ [self.path, mixed_id[0] + 'configure', _to_idx(mixed_id[1])]
+ end
+
+ def cell_cget_tkstring(tagOrId, option)
+ itemcget_tkstring(['cell', tagOrId], option)
+ end
+ def cell_cget(tagOrId, option)
+ itemcget(['cell', tagOrId], option)
+ end
+ def cell_cget_strict(tagOrId, option)
+ itemcget_strict(['cell', tagOrId], option)
+ end
+ def cell_configure(tagOrId, slot, value=None)
+ itemconfigure(['cell', tagOrId], slot, value)
+ end
+ def cell_configinfo(tagOrId, slot=nil)
+ itemconfiginfo(['cell', tagOrId], slot)
+ end
+ def current_cell_configinfo(tagOrId, slot=nil)
+ current_itemconfiginfo(['cell', tagOrId], slot)
+ end
+ alias cellcget_tkstring cell_cget_tkstring
+ alias cellcget cell_cget
+ alias cellcget_strict cell_cget_strict
+ alias cellconfigure cell_configure
+ alias cellconfiginfo cell_configinfo
+ alias current_cellconfiginfo current_cell_configinfo
+
+ def column_cget_tkstring(tagOrId, option)
+ itemcget_tkstring(['column', tagOrId], option)
+ end
+ def column_cget(tagOrId, option)
+ itemcget(['column', tagOrId], option)
+ end
+ def column_cget_strict(tagOrId, option)
+ itemcget_strict(['column', tagOrId], option)
+ end
+ def column_configure(tagOrId, slot, value=None)
+ itemconfigure(['column', tagOrId], slot, value)
+ end
+ def column_configinfo(tagOrId, slot=nil)
+ itemconfiginfo(['column', tagOrId], slot)
+ end
+ def current_column_configinfo(tagOrId, slot=nil)
+ current_itemconfiginfo(['column', tagOrId], slot)
+ end
+ alias columncget_tkstring column_cget_tkstring
+ alias columncget column_cget
+ alias columncget_strict column_cget_strict
+ alias columnconfigure column_configure
+ alias columnconfiginfo column_configinfo
+ alias current_columnconfiginfo current_column_configinfo
+
+ def row_cget_tkstring(tagOrId, option)
+ itemcget_tkstring(['row', tagOrId], option)
+ end
+ def row_cget(tagOrId, option)
+ itemcget(['row', tagOrId], option)
+ end
+ def row_cget_strict(tagOrId, option)
+ itemcget_strict(['row', tagOrId], option)
+ end
+ def row_configure(tagOrId, slot, value=None)
+ itemconfigure(['row', tagOrId], slot, value)
+ end
+ def row_configinfo(tagOrId, slot=nil)
+ itemconfiginfo(['row', tagOrId], slot)
+ end
+ def current_row_configinfo(tagOrId, slot=nil)
+ current_itemconfiginfo(['row', tagOrId], slot)
+ end
+ alias rowcget_tkstring row_cget_tkstring
+ alias rowcget row_cget
+ alias rowcget_strict row_cget_strict
+ alias rowconfigure row_configure
+ alias rowconfiginfo row_configinfo
+ alias current_rowconfiginfo current_row_configinfo
+
+ private :itemcget_tkstring, :itemcget, :itemcget_strict
+ private :itemconfigure, :itemconfiginfo, :current_itemconfiginfo
+end
+
+class Tk::Tcllib::Tablelist
+ include Tk::Tcllib::TablelistItemConfig
+ include Scrollable
+
+ TkCommandNames = ['::tablelist::tablelist'.freeze].freeze
+ WidgetClassName = 'Tablelist'.freeze
+ WidgetClassNames[WidgetClassName] ||= self
+
+ def create_self(keys)
+ if keys and keys != None
+ tk_call_without_enc(self.class::TkCommandNames[0], @path,
+ *hash_kv(keys, true))
+ else
+ tk_call_without_enc(self.class::TkCommandNames[0], @path)
+ end
+ end
+ private :create_self
+
+ ##########################
+
+ def __numval_optkeys
+ super() + ['titlecolumns']
+ end
+ private :__numval_optkeys
+
+ def __strval_optkeys
+ super() + ['snipstring']
+ end
+ private :__strval_optkeys
+
+ def __boolval_optkeys
+ super() - ['takefocus'] + [
+ 'forceeditendcommand', 'movablecolumns', 'movablerows',
+ 'protecttitlecolumns', 'resizablecolumns', 'setfocus',
+ 'showarrow', 'showlabels', 'showseparators'
+ ]
+ end
+ private :__boolval_optkeys
+
+ def __listval_optkeys
+ super() + ['columns', 'columntitles']
+ end
+ private :__listval_optkeys
+
+ def __tkvariable_optkeys
+ super() + ['listvariable']
+ end
+ private :__tkvariable_optkeys
+
+ def __val2ruby_optkeys # { key=>proc, ... }
+ # The method is used to convert a opt-value to a ruby's object.
+ # When get the value of the option "key", "proc.call(value)" is called.
+ super().update('stretch'=>proc{|v|
+ (v == 'all')? v: simplelist(v)
+ },
+ 'takefocus'=>proc{|v|
+ case v
+ when '1'
+ true
+ when '0'
+ false
+ when ''
+ nil
+ else # cmd
+ tk_tcl2ruby(cmd)
+ end
+ })
+ end
+ private :__val2ruby_optkeys
+
+ def __ruby2val_optkeys # { key=>proc, ... }
+ # The method is used to convert a ruby's object to a opt-value.
+ # When set the value of the option "key", "proc.call(value)" is called.
+ # That is, "-#{key} #{proc.call(value)}".
+ super().update('stretch'=>proc{|v|
+ (v.kind_of?(Array))? v.collect{|e| _to_idx(e)}: v
+ },
+ 'takefocus'=>proc{|v|
+ case v
+ when true
+ '1'
+ when false
+ '0'
+ when nil
+ ''
+ else
+ _get_eval_string(v)
+ end
+ })
+ end
+ private :__ruby2val_optkeys
+
+ def __font_optkeys
+ super() + ['labelfont']
+ end
+ private :__font_optkeys
+
+ ##########################
+
+ def __item_strval_optkeys(id)
+ if id[0] == 'cell'
+ super(id) + ['title']
+ else
+ super(id) - ['text'] + ['title', 'name']
+ end
+ end
+ private :__item_strval_optkeys
+
+ def __item_boolval_optkeys(id)
+ super(id) + [
+ 'changesnipside', 'editable', 'hide', 'resizable', 'selectable',
+ 'showarrow', 'showlinenumbers', 'stretchable', 'stretchwindow', 'wrap'
+ ]
+ end
+ private :__item_boolval_optkeys
+
+ def __item_listval_optkeys(id)
+ if id[0] == 'cell'
+ super(id)
+ else
+ super(id) + ['text']
+ end
+ end
+ private :__item_listval_optkeys
+
+ def __item_font_optkeys(id)
+ # maybe need to override
+ super(id) + ['labelfont']
+ end
+ private :__item_font_optkeys
+
+ ##########################
+
+ def activate(index)
+ tk_send('activate', _to_idx(index))
+ self
+ end
+
+ def activate_cell(index)
+ tk_send('activatecell', _to_idx(index))
+ self
+ end
+ alias activatecell activate_cell
+
+ def get_attrib(name=nil)
+ if name && name != None
+ tk_send('attrib', name)
+ else
+ ret = []
+ lst = simplelist(tk_send('attrib'))
+ until lst.empty?
+ ret << ( [lst.shift] << lst.shift )
+ end
+ ret
+ end
+ end
+ def set_attrib(*args)
+ tk_send('attrib', *(args.flatten))
+ self
+ end
+
+ def bbox(index)
+ list(tk_send('bbox', _to_idx(index)))
+ end
+
+ def bodypath
+ window(tk_send('bodypath'))
+ end
+
+ def bodytag
+ TkBindTag.new_by_name(tk_send('bodytag'))
+ end
+
+ def cancel_editing
+ tk_send('cancelediting')
+ self
+ end
+ alias cancelediting cancel_editing
+
+ def get_cellattrib(name=nil)
+ if name && name != None
+ tk_send('cellattrib', name)
+ else
+ ret = []
+ lst = simplelist(tk_send('cellattrib'))
+ until lst.empty?
+ ret << ( [lst.shift] << lst.shift )
+ end
+ ret
+ end
+ end
+ def set_cellattrib(*args)
+ tk_send('cellattrib', *(args.flatten))
+ self
+ end
+
+ def cellindex(idx)
+ _from_idx(tk_send('cellindex', _to_idx(idx)))
+ end
+
+ def cellselection_anchor(idx)
+ tk_send('cellselection', 'anchor', _to_idx(idx))
+ self
+ end
+
+ def cellselection_clear(first, last=nil)
+ if first.kind_of?(Array)
+ tk_send('cellselection', 'clear', first.collect{|idx| _to_idx(idx)})
+ else
+ first = _to_idx(first)
+ last = (last)? _to_idx(last): first
+ tk_send('cellselection', 'clear', first, last)
+ end
+ self
+ end
+
+ def cellselection_includes(idx)
+ bool(tk_send('cellselection', 'includes', _to_idx(idx)))
+ end
+
+ def cellselection_set(first, last=nil)
+ if first.kind_of?(Array)
+ tk_send('cellselection', 'set', first.collect{|idx| _to_idx(idx)})
+ else
+ first = _to_idx(first)
+ last = (last)? _to_idx(last): first
+ tk_send('cellselection', 'set', first, last)
+ end
+ self
+ end
+
+ def get_columnattrib(name=nil)
+ if name && name != None
+ tk_send('columnattrib', name)
+ else
+ ret = []
+ lst = simplelist(tk_send('columnattrib'))
+ until lst.empty?
+ ret << ( [lst.shift] << lst.shift )
+ end
+ ret
+ end
+ end
+ def set_columnattrib(*args)
+ tk_send('columnattrib', *(args.flatten))
+ self
+ end
+
+ def columncount
+ number(tk_send('columncount'))
+ end
+
+ def columnindex(idx)
+ number(tk_send('columnindex', _to_idx(idx)))
+ end
+
+ def columnwidth(idx, opt=nil)
+ if opt
+ number(tk_send('columnwidth', _to_idx(idx), "-#{opt}"))
+ else
+ number(tk_send('columnwidth', _to_idx(idx)))
+ end
+ end
+ def requested_columnwidth(idx)
+ columnwidth(idx, 'requested')
+ end
+ def stretched_columnwidth(idx)
+ columnwidth(idx, 'stretched')
+ end
+ def total_columnwidth(idx)
+ columnwidth(idx, 'total')
+ end
+
+ def configcelllist(lst) # lst ==> [idx, opt, val, idx, opt, val, ...]
+ ary = []
+ lst.slice(3){|idx, opt, val|
+ ary << _to_idx(idx) << "-#{opt}" << val
+ }
+ tk_send('configcelllist', ary)
+ self
+ end
+ alias config_celllist configcelllist
+
+ def configcells(*args) # args ==> idx, opt, val, idx, opt, val, ...
+ ary = []
+ args.slice(3){|idx, opt, val|
+ ary << _to_idx(idx) << "-#{opt}" << val
+ }
+ tk_send('configcells', *ary)
+ self
+ end
+ alias config_cells configcells
+
+ def configcolumnlist(lst) # lst ==> [idx, opt, val, idx, opt, val, ...]
+ ary = []
+ lst.slice(3){|idx, opt, val|
+ ary << _to_idx(idx) << "-#{opt}" << val
+ }
+ tk_send('configcolumnlist', ary)
+ self
+ end
+ alias config_columnlist configcolumnlist
+
+ def configcolumns(*args) # args ==> idx, opt, val, idx, opt, val, ...
+ ary = []
+ args.slice(3){|idx, opt, val|
+ ary << _to_idx(idx) << "-#{opt}" << val
+ }
+ tk_send('configcolumns', *ary)
+ self
+ end
+ alias config_columns configcolumns
+
+ def configrowlist(lst) # lst ==> [idx, opt, val, idx, opt, val, ...]
+ ary = []
+ lst.slice(3){|idx, opt, val|
+ ary << _to_idx(idx) << "-#{opt}" << val
+ }
+ tk_send('configrowlist', ary)
+ self
+ end
+ alias config_rowlist configrowlist
+
+ def configrows(*args) # args ==> idx, opt, val, idx, opt, val, ...
+ ary = []
+ args.slice(3){|idx, opt, val|
+ ary << _to_idx(idx) << "-#{opt}" << val
+ }
+ tk_send('configrows', *ary)
+ self
+ end
+ alias config_rows configrows
+
+ def containing(y)
+ idx = num_or_str(tk_send('containing', y))
+ (idx.kind_of?(Fixnum) && idx < 0)? nil: idx
+ end
+
+ def containing_cell(x, y)
+ idx = _from_idx(tk_send('containingcell', x, y))
+ if idx.kind_of?(Array)
+ [
+ ((idx[0].kind_of?(Fixnum) && idx[0] < 0)? nil: idx[0]),
+ ((idx[1].kind_of?(Fixnum) && idx[1] < 0)? nil: idx[1])
+ ]
+ else
+ idx
+ end
+ end
+ alias containingcell containing_cell
+
+ def containing_column(x)
+ idx = num_or_str(tk_send('containingcolumn', x))
+ (idx.kind_of?(Fixnum) && idx < 0)? nil: idx
+ end
+ alias containingcolumn containing_column
+
+ def curcellselection
+ simplelist(tk_send('curcellselection')).collect!{|idx| _from_idx(idx)}
+ end
+
+ def curselection
+ list(tk_send('curselection'))
+ end
+
+ def delete_items(first, last=nil)
+ if first.kind_of?(Array)
+ tk_send('delete', first.collect{|idx| _to_idx(idx)})
+ else
+ first = _to_idx(first)
+ last = (last)? _to_idx(last): first
+ tk_send('delete', first, last)
+ end
+ self
+ end
+ alias delete delete_items
+ alias deleteitems delete_items
+
+ def delete_columns(first, last=nil)
+ if first.kind_of?(Array)
+ tk_send('deletecolumns', first.collect{|idx| _to_idx(idx)})
+ else
+ first = _to_idx(first)
+ last = (last)? _to_idx(last): first
+ tk_send('deletecolumns', first, last)
+ end
+ self
+ end
+ alias deletecolumns delete_columns
+
+ def edit_cell(idx)
+ tk_send('editcell', _to_idx(idx))
+ self
+ end
+ alias editcell edit_cell
+
+ def editwintag
+ TkBindTag.new_by_name(tk_send('editwintag'))
+ end
+
+ def editwinpath
+ window(tk_send('editwinpath'))
+ end
+
+ def entrypath
+ window(tk_send('entrypath'))
+ end
+
+ def fill_column(idx, txt)
+ tk_send('fillcolumn', _to_idx(idx), txt)
+ self
+ end
+ alias fillcolumn fill_column
+
+ def finish_editing
+ tk_send('finishediting')
+ self
+ end
+ alias finishediting finish_editing
+
+ def formatinfo
+ key, row, col = simplelist(tk_send('formatinfo'))
+ [key, number(row), number(col)]
+ end
+
+ def get(first, last=nil)
+ if first.kind_of?(Array)
+ simplelist(tk_send('get', first.collect{|idx| _to_idx(idx)})).collect!{|elem| simplelist(elem) }
+ else
+ first = _to_idx(first)
+ last = (last)? _to_idx(last): first
+ simplelist(tk_send('get', first, last))
+ end
+ end
+
+ def get_cells(first, last=nil)
+ if first.kind_of?(Array)
+ simplelist(tk_send('getcells', first.collect{|idx| _to_idx(idx)})).collect!{|elem| simplelist(elem) }
+ else
+ first = _to_idx(first)
+ last = (last)? _to_idx(last): first
+ simplelist(tk_send('getcells', first, last))
+ end
+ end
+ alias getcells get_cells
+
+ def get_columns(first, last=nil)
+ if first.kind_of?(Array)
+ simplelist(tk_send('getcolumns', first.collect{|idx| _to_idx(idx)})).collect!{|elem| simplelist(elem) }
+ else
+ first = _to_idx(first)
+ last = (last)? _to_idx(last): first
+ simplelist(tk_send('getcolumns', first, last))
+ end
+ end
+ alias getcolumns get_columns
+
+ def get_keys(first, last=nil)
+ if first.kind_of?(Array)
+ simplelist(tk_send('getkeys', first.collect{|idx| _to_idx(idx)})).collect!{|elem| simplelist(elem) }
+ else
+ first = _to_idx(first)
+ last = (last)? _to_idx(last): first
+ simplelist(tk_send('getkeys', first, last))
+ end
+ end
+ alias getkeys get_keys
+
+ def has_attrib?(name)
+ bool(tk_send('hasattrib', name))
+ end
+
+ def has_cellattrib?(idx, name)
+ bool(tk_send('hascellattrib', _to_idx(idx), name))
+ end
+
+ def has_columnattrib?(idx, name)
+ bool(tk_send('hascolumnattrib', _to_idx(idx), name))
+ end
+
+ def has_rowattrib?(idx, name)
+ bool(tk_send('hasrowattrib', _to_idx(idx), name))
+ end
+
+ def imagelabelpath(idx)
+ window(tk_send('imagelabelpath', _to_idx(idx)))
+ end
+
+ def index(idx)
+ number(tk_send('index', _to_idx(idx)))
+ end
+
+ def insert(idx, *items)
+ tk_send('insert', _to_idx(idx), *items)
+ self
+ end
+
+ def insert_columnlist(idx, columnlist)
+ tk_send('insertcolumnlist', _to_idx(idx), columnlist)
+ self
+ end
+ alias insertcolumnlist insert_columnlist
+
+ def insert_columns(idx, *args)
+ tk_send('insertcolums', _to_idx(idx), *args)
+ self
+ end
+ alias insertcolumns insert_columns
+
+ def insert_list(idx, list)
+ tk_send('insertlist', _to_idx(idx), list)
+ self
+ end
+ alias insertlist insert_list
+
+ def is_elem_snipped?(cellidx, tkvar)
+ bool(tk_send('iselemsnipped', _to_idx(cellidx), tkvar))
+ end
+ alias elem_snipped? is_elem_snipped?
+
+ def is_title_snipped?(colidx, tkvar)
+ bool(tk_send('istitlesnipped', _to_idx(colidx), tkvar))
+ end
+ alias title_snipped? is_title_snipped?
+
+ def itemlistvar
+ TkVarAccess.new(tk_send('itemlistvar'))
+ end
+
+ def labelpath(idx)
+ window(tk_send('labelpath', _to_idx(idx)))
+ end
+
+ def labels
+ simplelist(tk_send('labels'))
+ end
+
+ def labeltag
+ TkBindTag.new_by_name(tk_send('labeltag'))
+ end
+
+ def move(src, target)
+ tk_send('move', _to_idx(src), _to_idx(target))
+ self
+ end
+
+ def move_column(src, target)
+ tk_send('movecolumn', _to_idx(src), _to_idx(target))
+ self
+ end
+ alias movecolumn move_column
+
+ def nearest(y)
+ _from_idx(tk_send('nearest', y))
+ end
+
+ def nearest_cell(x, y)
+ _from_idx(tk_send('nearestcell', x, y))
+ end
+ alias nearestcell nearest_cell
+
+ def nearest_column(x)
+ _from_idx(tk_send('nearestcolumn', x))
+ end
+ alias nearestcolumn nearest_column
+
+ def reject_input
+ tk_send('rejectinput')
+ self
+ end
+ alias rejectinput reject_input
+
+ def reset_sortinfo
+ tk_send('resetsortinfo')
+ self
+ end
+ alias resetsortinfo reset_sortinfo
+
+ def get_rowattrib(name=nil)
+ if name && name != None
+ tk_send('rowattrib', name)
+ else
+ ret = []
+ lst = simplelist(tk_send('rowattrib'))
+ until lst.empty?
+ ret << ( [lst.shift] << lst.shift )
+ end
+ ret
+ end
+ end
+ def set_rowattrib(*args)
+ tk_send('rowattrib', *(args.flatten))
+ self
+ end
+
+ def scan_mark(x, y)
+ tk_send('scan', 'mark', x, y)
+ self
+ end
+
+ def scan_dragto(x, y)
+ tk_send('scan', 'dragto', x, y)
+ self
+ end
+
+ def see(idx)
+ tk_send('see', _to_idx(idx))
+ self
+ end
+
+ def see_cell(idx)
+ tk_send('seecell', _to_idx(idx))
+ self
+ end
+ alias seecell see_cell
+
+ def see_column(idx)
+ tk_send('seecolumn', _to_idx(idx))
+ self
+ end
+ alias seecolumn see_column
+
+ def selection_anchor(idx)
+ tk_send('selection', 'anchor', _to_idx(idx))
+ self
+ end
+
+ def selection_clear(first, last=nil)
+ if first.kind_of?(Array)
+ tk_send('selection', 'clear', first.collect{|idx| _to_idx(idx)})
+ else
+ first = _to_idx(first)
+ last = (last)? _to_idx(last): first
+ tk_send('selection', 'clear', first, last)
+ end
+ self
+ end
+
+ def selection_includes(idx)
+ bool(tk_send('selection', 'includes', _to_idx(idx)))
+ end
+
+ def selection_set(first, last=nil)
+ if first.kind_of?(Array)
+ tk_send('selection', 'set', first.collect{|idx| _to_idx(idx)})
+ else
+ first = _to_idx(first)
+ last = (last)? _to_idx(last): first
+ tk_send('selection', 'set', first, last)
+ end
+ self
+ end
+
+ def separatorpath(idx=nil)
+ if idx
+ window(tk_send('separatorpath', _to_idx(idx)))
+ else
+ window(tk_send('separatorpath'))
+ end
+ end
+
+ def separators
+ simplelist(tk_send('separators')).collect!{|w| window(w)}
+ end
+
+ def size
+ number(tk_send('size'))
+ end
+
+ def sort(order=nil)
+ if order
+ order = order.to_s
+ order = '-' << order if order[0] != ?-
+ if order.length < 2
+ order = nil
+ end
+ end
+ if order
+ tk_send('sort', order)
+ else
+ tk_send('sort')
+ end
+ self
+ end
+ def sort_increasing
+ tk_send('sort', '-increasing')
+ self
+ end
+ def sort_decreasing
+ tk_send('sort', '-decreasing')
+ self
+ end
+
+
+ # default of 'labelcommand' option
+ DEFAULT_labelcommand_value =
+ DEFAULT_sortByColumn_cmd = '::tablelist::sortByColumn'
+
+ # default of 'labelcommand2' option
+ DEFAULT_labelcommand2_value =
+ DEFAULT_addToSortColumns_cmd = '::tablelist::addToSortColumns'
+
+ def sortByColumn_with_event_generate(idx)
+ tk_call('::tablelist::sortByColumn', @path, _to_idx(idx))
+ end
+
+ def addToSortColumns_with_event_generate(idx)
+ tk_call('::tablelist::addToSortColumns', @path, _to_idx(idx))
+ end
+
+ def sort_by_column(idx, order=nil)
+ if order
+ order = order.to_s
+ order = '-' << order if order[0] != ?-
+ if order.length < 2
+ order = nil
+ end
+ end
+ if order
+ tk_send('sortbycolumn', _to_idx(idx), order)
+ else
+ tk_send('sortbycolumn', _to_idx(idx))
+ end
+ self
+ end
+ def sort_by_column_increasing(idx)
+ tk_send('sortbycolumn', _to_idx(idx), '-increasing')
+ self
+ end
+ def sort_by_column_decreasing(idx)
+ tk_send('sortbycolumn', _to_idx(idx), '-decreasing')
+ self
+ end
+
+ def sort_by_columnlist(idxlist, orderlist=None)
+ # orderlist :: list of 'increasing' or 'decreasing'
+ tk_send('sortbycolumnlist', idxlist.map{|idx| _to_idx(idx)}, orderlist)
+ self
+ end
+
+ def sortcolumn
+ idx = num_or_str(tk_send('sortcolum'))
+ (idx.kind_of?(Fixnum) && idx < 0)? nil: idx
+ end
+
+ def sortcolumnlist
+ simplelist(tk_send('sortcolumlist')).map{|col| num_or_str(col)}
+ end
+
+ def sortorder
+ tk_send('sortorder')
+ end
+
+ def sortorderlist
+ simplelist(tk_send('sortorderlist'))
+ end
+
+ def toggle_columnhide(first, last=nil)
+ if first.kind_of?(Array)
+ tk_send('togglecolumnhide', first.collect{|idx| _to_idx(idx)})
+ else
+ first = _to_idx(first)
+ last = (last)? _to_idx(last): first
+ tk_send('togglecolumnhide', first, last)
+ end
+ end
+
+ def toggle_rowhide(first, last=nil)
+ if first.kind_of?(Array)
+ tk_send('togglerowhide', first.collect{|idx| _to_idx(idx)})
+ else
+ first = _to_idx(first)
+ last = (last)? _to_idx(last): first
+ tk_send('togglerowhide', first, last)
+ end
+ end
+
+ def toggle_visibility(first, last=nil)
+ if first.kind_of?(Array)
+ tk_send('togglevisibility', first.collect{|idx| _to_idx(idx)})
+ else
+ first = _to_idx(first)
+ last = (last)? _to_idx(last): first
+ tk_send('togglevisibility', first, last)
+ end
+ self
+ end
+ alias togglevisibility toggle_visibility
+
+ def unset_attrib(name)
+ tk_send('unsetattrib', name)
+ self
+ end
+
+ def unset_cellattrib(idx, name)
+ tk_send('unsetcellattrib', _to_idx(idx), name)
+ self
+ end
+
+ def unset_columnattrib(idx, name)
+ tk_send('unsetcolumnattrib', _to_idx(idx), name)
+ self
+ end
+
+ def unset_rowattrib(idx, name)
+ tk_send('unsetrowattrib', _to_idx(idx), name)
+ self
+ end
+
+ def windowpath(idx)
+ window(tk_send('windowpath', _to_idx(idx)))
+ end
+end
+
+class << Tk::Tcllib::Tablelist
+ ############################################################
+ # helper commands
+ def getTablelistPath(descendant)
+ window(Tk.tk_call('::tablelist::getTablelistPath', descendant))
+ end
+
+ def getTablelistColumn(descendant)
+ num_or_str(Tk.tk_call('::tablelist::getTablelistColumn', headerlabel))
+ end
+
+
+ def convEventFields(descendant, x, y)
+ window(Tk.tk_call('::tablelist::convEventFields', descendant, x, y))
+ end
+
+
+ ############################################################
+ # with the BWidget package
+ def addBWidgetEntry(name=None)
+ Tk.tk_call('::tablelist::addBWidgetEntry', name)
+ end
+
+ def addBWidgetSpinBox(name=None)
+ Tk.tk_call('::tablelist::addBWidgetSpinBox', name)
+ end
+
+ def addBWidgetComboBox(name=None)
+ Tk.tk_call('::tablelist::addBWidgetComboBox', name)
+ end
+
+
+ ############################################################
+ # with the Iwidgets ([incr Widgets]) package
+ def addIncrEntryfield(name=None)
+ Tk.tk_call('::tablelist::addIncrEntry', name)
+ end
+
+ def addIncrDateTimeWidget(type, seconds=false, name=None)
+ # type := 'datefield'|'dateentry'|timefield'|'timeentry'
+ if seconds && seconds != None
+ seconds = '-seconds'
+ else
+ seconds = None
+ end
+ Tk.tk_call('::tablelist::addDateTimeWidget', type, seconds, name)
+ end
+
+ def addIncrSpinner(name=None)
+ Tk.tk_call('::tablelist::addIncrSpinner', name)
+ end
+
+ def addIncrSpinint(name=None)
+ Tk.tk_call('::tablelist::addIncrSpinint', name)
+ end
+
+ def addIncrCombobox(name=None)
+ Tk.tk_call('::tablelist::addIncrCombobox', name)
+ end
+
+
+ ############################################################
+ # with Bryan Oakley's combobox package
+ def addOakleyCombobox(name=None)
+ Tk.tk_call('::tablelist::addOakleyCombobox', name)
+ end
+
+ ############################################################
+ # with the multi-entry package Mentry is a library extension
+ def addDateMentry(format, separator, gmt=false, name=None)
+ if gmt && gmt != None
+ gmt = '-gmt'
+ else
+ gmt = None
+ end
+ Tk.tk_call('::tablelist::addDateMentry', format, separator, gmt, name)
+ end
+
+ def addTimeMentry(format, separator, gmt=false, name=None)
+ if gmt && gmt != None
+ gmt = '-gmt'
+ else
+ gmt = None
+ end
+ Tk.tk_call('::tablelist::addTimeMentry', format, separator, gmt, name)
+ end
+
+ def addDateTimeMentry(format, date_sep, time_sep, gmt=false, name=None)
+ if gmt && gmt != None
+ gmt = '-gmt'
+ else
+ gmt = None
+ end
+ Tk.tk_call('::tablelist::addDateTimeMentry',
+ format, date_sep, time_sep, gmt, name)
+ end
+
+ def addFixedPointMentry(count1, count2, comma=false, name=None)
+ if comma && comma != None
+ comma = '-comma'
+ else
+ comma = None
+ end
+ Tk.tk_call('::tablelist::addFixedPoingMentry', count1, count2, comma, name)
+ end
+
+ def addIPAddrMentry(name=None)
+ Tk.tk_call('::tablelist::addIPAddrMentry', name)
+ end
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/tcllib/tablelist_tile.rb b/jni/ruby/ext/tk/lib/tkextlib/tcllib/tablelist_tile.rb
new file mode 100644
index 0000000..0a14584
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/tcllib/tablelist_tile.rb
@@ -0,0 +1,43 @@
+#
+# tkextlib/tcllib/tablelist_tlie.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+# * Part of tcllib extension
+# * A multi-column listbox
+
+require 'tk'
+require 'tkextlib/tcllib.rb'
+
+# TkPackage.require('tablelist_tile', '4.2')
+TkPackage.require('tablelist_tile')
+
+unless defined? Tk::Tcllib::Tablelist_usingTile
+ Tk::Tcllib::Tablelist_usingTile = true
+end
+
+requrie 'tkextlib/tcllib/tablelist_core'
+
+module Tk
+ module Tcllib
+ class Tablelist
+ # commands related to tile Themems
+ def self.set_theme(theme)
+ Tk.tk_call('::tablelist::setTheme', theme)
+ end
+
+ def self.get_current_theme
+ Tk.tk_call('::tablelist::getCurrentTheme')
+ end
+
+ def self.get_theme_list
+ TkComm.simplelist(Tk.tk_call('::tablelist::getThemes'))
+ end
+ def self.set_theme_defaults
+ Tk.tk_call('::tablelist::setThemeDefaults')
+ end
+ end
+
+ Tablelist_Tile = Tablelist
+ TableList_Tile = Tablelist
+ end
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/tcllib/tkpiechart.rb b/jni/ruby/ext/tk/lib/tkextlib/tcllib/tkpiechart.rb
new file mode 100644
index 0000000..2f6e4b4
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/tcllib/tkpiechart.rb
@@ -0,0 +1,314 @@
+#
+# tkextlib/tcllib/tkpiechart.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+# * Part of tcllib extension
+# * Create 2D or 3D pies with labels in Tcl canvases
+#
+
+require 'tk'
+require 'tk/canvas'
+require 'tkextlib/tcllib.rb'
+
+# TkPackage.require('tkpiechart', '6.6')
+TkPackage.require('tkpiechart')
+
+module Tk
+ module Tcllib
+ module Tkpiechart
+ end
+ end
+end
+
+module Tk::Tcllib::Tkpiechart
+ PACKAGE_NAME = 'tkpiechart'.freeze
+ def self.package_name
+ PACKAGE_NAME
+ end
+
+ def self.package_version
+ begin
+ TkPackage.require('tkpiechart')
+ rescue
+ ''
+ end
+ end
+
+ module ConfigMethod
+ include TkConfigMethod
+
+ def __pathname
+ self.path + ';' + self.tag
+ end
+ private :__pathname
+
+ def __cget_cmd
+ ['::switched::cget', self.tag]
+ end
+
+ def __config_cmd
+ ['::switched::configure', self.tag]
+ end
+ private :__config_cmd
+
+ def __configinfo_struct
+ {:key=>0, :alias=>nil, :db_name=>nil, :db_class=>nil,
+ :default_value=>1, :current_value=>2}
+ end
+ private :__configinfo_struct
+
+ def __boolval_optkeys
+ super() << 'select' << 'autoupdate' << 'selectable'
+ end
+ private :__boolval_optkeys
+
+ def __strval_optkeys
+ super() << 'bordercolor' << 'textbackground' <<
+ 'widestvaluetext' << 'title'
+ end
+ private :__strval_optkeys
+
+ def __listval_optkeys
+ super() << 'colors'
+ end
+ private :__listval_optkeys
+ end
+
+ ####################################
+ class PieChartObj < TkcItem
+ include ConfigMethod
+
+ def __font_optkeys
+ ['titlefont']
+ end
+ private :__font_optkeys
+ end
+
+ ####################################
+ class Pie < TkcItem
+ include ConfigMethod
+
+ def create_self(x, y, width, height, keys=None)
+ if keys and keys != None
+ @tag_key = tk_call_without_enc('::stooop::new', 'pie',
+ @c, x, y, *hash_kv(keys, true))
+ else
+ @tag_key = tk_call_without_enc('::stooop::new', 'pie', @c, x, y)
+ end
+
+ @slice_tbl = {}
+
+ id = "pie(#{@tag_key})"
+
+ @tag = @tag_pie = TkcNamedTag(@c, id)
+ @tag_slices = TkcNamedTag(@c, "pieSlices(#{@tag_key})")
+
+ id
+ end
+ private :create_self
+
+ def tag_key
+ @tag_key
+ end
+ def tag
+ @tag
+ end
+ def canvas
+ @c
+ end
+ def _entry_slice(slice)
+ @slice_tbl[slice.to_eval] = slice
+ end
+ def _delete_slice(slice)
+ @slice_tbl.delete(slice.to_eval)
+ end
+
+ def delete
+ tk_call_without_enc('::stooop::delete', @tag_key)
+ CItemID_TBL.mutex.synchronize{
+ CItemID_TBL[@path].delete(@id) if CItemID_TBL[@path]
+ }
+ self
+ end
+
+ def new_slice(text=None)
+ Slice.new(self, text)
+ end
+
+ def delete_slice(slice)
+ unless slice.kind_of?(Slice)
+ unless (slice = @slice_tbl[slice])
+ return tk_call_without_enc('pie::deleteSlice', @tag_key, slice)
+ end
+ end
+ unless slice.kind_of?(Slice) && slice.pie == self
+ fail ArgumentError, "argument is not a slice of self"
+ end
+ slice.delete
+ end
+
+ def selected_slices
+ tk_split_simplelist(tk_call_without_enc('pie::selectedSlices',
+ @tag_key)).collect{|slice|
+ @slice_tbl[slice] || Slice.new(:no_create, self, slice)
+ }
+ end
+ end
+
+ ####################################
+ class Slice < TkcItem
+ include ConfigMethod
+
+ def __config_cmd
+ ['::switched::configure', self.tag]
+ end
+ private :__config_cmd
+
+ #------------------------
+
+ def initialize(pie, *args)
+ unless pie.kind_of?(Pie) && pie != :no_create
+ fail ArgumentError, "expects TkPiechart::Pie for 1st argument"
+ end
+
+ if pie == :no_create
+ @pie, @tag_key = args
+ else
+ text = args[0] || None
+ @pie = pie
+ @tag_key = tk_call_without_enc('pie::newSlice', @pie.tag_key, text)
+ end
+ @parent = @c = @pie.canvas
+ @path = @parent.path
+
+ @pie._entry_slice(self)
+
+ @id = "slices(#{@tag_key})"
+ @tag = TkcNamedTag.new(@pie.canvas, @id)
+
+ CItemID_TBL.mutex.synchronize{
+ CItemID_TBL[@path] = {} unless CItemID_TBL[@path]
+ CItemID_TBL[@path][@id] = self
+ }
+ end
+
+ def tag_key
+ @tag_key
+ end
+ def tag
+ @tag
+ end
+ def pie
+ @pie
+ end
+
+ def delete
+ tk_call_without_enc('pie::deleteSlice', @pie.tag_key, @tag_key)
+ CItemID_TBL.mutex.synchronize{
+ CItemID_TBL[@path].delete(@id) if CItemID_TBL[@path]
+ }
+ @pie._delete_slice(self)
+ self
+ end
+
+ def size(share, disp=None)
+ tk_call_without_enc('pie::sizeSlice',
+ @pie.tag_key, @tag_key, share, disp)
+ self
+ end
+
+ def label(text)
+ tk_call_without_enc('pie::labelSlice', @pie.tag_key, @tag_key, text)
+ self
+ end
+ end
+
+ ####################################
+ class BoxLabeler < TkcItem
+ include ConfigMethod
+
+ def __config_cmd
+ ['::switched::configure', self.tag]
+ end
+ private :__config_cmd
+
+ #------------------------
+
+ def create_self(keys=None)
+ if keys and keys != None
+ @tag_key = tk_call_without_enc('::stooop::new', 'pieBoxLabeler',
+ *hash_kv(keys, true))
+ else
+ @tag_key = tk_call_without_enc('::stooop::new', 'pieBoxLabeler')
+ end
+
+ id = "pieBoxLabeler(#{@tag_key})"
+ @tag = TkcNamedTag(@c, id)
+
+ id
+ end
+ private :create_self
+ end
+
+ ####################################
+ class PeripheralLabeler < TkcItem
+ include ConfigMethod
+
+ def __font_optkeys
+ ['font', 'smallfont']
+ end
+ private :__font_optkeys
+
+ def __config_cmd
+ ['::switched::configure', self.tag]
+ end
+ private :__config_cmd
+
+ #------------------------
+
+ def create_self(keys=None)
+ if keys and keys != None
+ @tag_key = tk_call_without_enc('::stooop::new',
+ 'piePeripheralLabeler',
+ *hash_kv(keys, true))
+ else
+ @tag_key = tk_call_without_enc('::stooop::new', 'piePeripheralLabeler')
+ end
+
+ id = "piePeripheralLabeler(#{@tag_key})"
+ @tag = TkcNamedTag(@c, id)
+
+ id
+ end
+ private :create_self
+ end
+
+ ####################################
+ class Label < TkcItem
+ include ConfigMethod
+
+ def __config_cmd
+ ['::switched::configure', self.tag]
+ end
+ private :__config_cmd
+
+ #------------------------
+
+ def create_self(x, y, keys=None)
+ if keys and keys != None
+ @tag_key = tk_call_without_enc('::stooop::new', 'canvasLabel',
+ @c, x, y, width, height,
+ *hash_kv(keys, true))
+ else
+ @tag_key = tk_call_without_enc('::stooop::new', 'canvasLabel',
+ @c, x, y, width, height)
+ end
+
+ id = "canvasLabel(#{@tag_key})"
+ @tag = TkcNamedTag(@c, id)
+
+ id
+ end
+ private :create_self
+ end
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/tcllib/toolbar.rb b/jni/ruby/ext/tk/lib/tkextlib/tcllib/toolbar.rb
new file mode 100644
index 0000000..6eae4eb
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/tcllib/toolbar.rb
@@ -0,0 +1,175 @@
+#
+# tkextlib/tcllib/toolbar.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+# * Part of tcllib extension
+# * toolbar widget
+#
+
+require 'tk'
+require 'tkextlib/tcllib.rb'
+
+# TkPackage.require('widget::toolbar', '1.2')
+TkPackage.require('widget::toolbar')
+
+module Tk::Tcllib
+ module Widget
+ class Toolbar < TkWindow
+ PACKAGE_NAME = 'widget::toolbar'.freeze
+ def self.package_name
+ PACKAGE_NAME
+ end
+
+ def self.package_version
+ begin
+ TkPackage.require('widget::toolbar')
+ rescue
+ ''
+ end
+ end
+ end
+
+ module ToolbarItemConfig
+ include TkItemConfigMethod
+ end
+ end
+end
+
+
+class Tk::Tcllib::Widget::ToolbarItem < TkObject
+ include TkTreatTagFont
+
+ ToolbarItemID_TBL = TkCore::INTERP.create_table
+
+ TkCore::INTERP.init_ip_env{
+ TTagID_TBL.mutex.synchronize{ TTagID_TBL.clear }
+ }
+
+ def ToolbarItem.id2obj(tbar, id)
+ tpath = tbar.path
+ ToolbarItemID_TBL.mutex.synchronize{
+ if ToolbarItemID_TBL[tpath]
+ ToolbarItemID_TBL[tpath][id]? ToolbarItemID_TBL[tpath][id]: id
+ else
+ id
+ end
+ }
+ end
+
+ def initaialize(parent, *args)
+ @parent = @t = parent
+ @tpath = parent.path
+
+ @path = @id = @t.tk_send('add', *args)
+ # A same id is rejected by the Tcl function.
+
+ ToolbarItemID_TBL.mutex.synchronize{
+ ToolbarItemID_TBL[@id] = self
+ ToolbarItemID_TBL[@tpath] = {} unless ToolbarItemID_TBL[@tpath]
+ ToolbarItemID_TBL[@tpath][@id] = self
+ }
+ end
+
+ def [](key)
+ cget key
+ end
+
+ def []=(key,val)
+ configure key, val
+ val
+ end
+
+ def cget_tkstring(option)
+ @t.itemcget_tkstring(@id, option)
+ end
+ def cget(option)
+ @t.itemcget(@id, option)
+ end
+ def cget_strict(option)
+ @t.itemcget_strict(@id, option)
+ end
+
+ def configure(key, value=None)
+ @t.itemconfigure(@id, key, value)
+ self
+ end
+
+ def configinfo(key=nil)
+ @t.itemconfiginfo(@id, key)
+ end
+
+ def current_configinfo(key=nil)
+ @t.current_itemconfiginfo(@id, key)
+ end
+
+ def delete
+ @t.delete(@id)
+ end
+
+ def itemid
+ @t.itemid(@id)
+ end
+
+ def remove
+ @t.remove(@id)
+ end
+ def remove_with_destroy
+ @t.remove_with_destroy(@id)
+ end
+end
+
+class Tk::Tcllib::Widget::Toolbar
+ include Tk::Tcllib::Widget::ToolbarItemConfig
+
+ TkCommandNames = ['::widget::toolbar'.freeze].freeze
+
+ def __destroy_hook__
+ Tk::Tcllib::Widget::ToolbarItem::ToolbarItemID_TBL.mutex.synchronize{
+ Tk::Tcllib::Widget::ToolbarItem::ToolbarItemID_TBL.delete(@path)
+ }
+ end
+
+ def create_self(keys)
+ if keys and keys != None
+ tk_call_without_enc(self.class::TkCommandNames[0], @path,
+ *hash_kv(keys, true))
+ else
+ tk_call_without_enc(self.class::TkCommandNames[0], @path)
+ end
+ end
+ private :create_self
+
+ def getframe
+ window(tk_send('getframe'))
+ end
+ alias get_frame getframe
+
+ def add(*args)
+ Tk::Tcllib::Widget::Toolbar.new(self, *args)
+ end
+
+ def itemid(item)
+ window(tk_send('itemid'))
+ end
+
+ def items(pattern)
+ tk_split_simplelist(tk_send('items', pattern)).map{|id|
+ Tk::Tcllib::Widget::ToolbarItem.id2obj(self, id)
+ }
+ end
+
+ def remove(*items)
+ tk_send('remove', *items)
+ self
+ end
+
+ def remove_with_destroy(*items)
+ tk_send('remove', '-destroy', *items)
+ self
+ end
+
+ def delete(*items)
+ tk_send('delete', *items)
+ self
+ end
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/tcllib/tooltip.rb b/jni/ruby/ext/tk/lib/tkextlib/tcllib/tooltip.rb
new file mode 100644
index 0000000..070e63a
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/tcllib/tooltip.rb
@@ -0,0 +1,104 @@
+#
+# tkextlib/tcllib/tooltip.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+# * Part of tcllib extension
+# * Provides tooltips, a small text message that is displayed when the
+# mouse hovers over a widget.
+#
+
+require 'tk'
+require 'tkextlib/tcllib.rb'
+
+# TkPackage.require('tooltip', '1.1')
+TkPackage.require('tooltip')
+
+module Tk::Tcllib
+ module Tooltip
+ PACKAGE_NAME = 'tooltip'.freeze
+ def self.package_name
+ PACKAGE_NAME
+ end
+
+ def self.package_version
+ begin
+ TkPackage.require('tooltip')
+ rescue
+ ''
+ end
+ end
+ end
+end
+
+module Tk::Tcllib::Tooltip
+ extend TkCore
+
+ WidgetClassName = 'Tooltip'.freeze
+ WidgetClassNames[WidgetClassName] ||= self
+
+ def self.database_classname
+ self::WidgetClassName
+ end
+ def self.database_class
+ WidgetClassNames[self::WidgetClassName]
+ end
+
+ def self.clear(glob_path_pat = None)
+ self.clear_glob(glob_path_pat)
+ end
+
+ def self.clear_glob(glob_path_pat)
+ tk_call_without_enc('::tooltip::tooltip', 'clear', glob_path_pat)
+ end
+
+ def self.clear_widgets(*args)
+ self.clear_glob("{#{args.collect{|w| _get_eval_string(w)}.join(',')}}")
+ end
+
+ def self.clear_children(*args)
+ self.clear_glob("{#{args.collect{|w| s = _get_eval_string(w); "#{s},#{s}.*"}.join(',')}}")
+ end
+
+ def self.delay(millisecs=None)
+ number(tk_call_without_enc('::tooltip::tooltip', 'delay', millisecs))
+ end
+ def self.delay=(millisecs)
+ self.delay(millisecs)
+ end
+
+ def self.fade?
+ bool(tk_call_without_enc('::tooltip::tooltip', 'fade'))
+ end
+ def self.fade(mode)
+ tk_call_without_enc('::tooltip::tooltip', 'fade', mode)
+ end
+
+ def self.disable
+ tk_call_without_enc('::tooltip::tooltip', 'disable')
+ false
+ end
+ def self.off
+ self.disable
+ end
+
+ def self.enable
+ tk_call_without_enc('::tooltip::tooltip', 'enable')
+ true
+ end
+ def self.on
+ self.enable
+ end
+
+ def self.register(widget, msg, keys=nil)
+ if keys.kind_of?(Hash)
+ args = hash_kv(keys) << msg
+ else
+ args = msg
+ end
+ tk_call('::tooltip::tooltip', widget.path, *args)
+ end
+
+ def self.erase(widget)
+ tk_call_without_enc('::tooltip::tooltip', widget.path, '')
+ end
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/tcllib/validator.rb b/jni/ruby/ext/tk/lib/tkextlib/tcllib/validator.rb
new file mode 100644
index 0000000..3a71960
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/tcllib/validator.rb
@@ -0,0 +1,65 @@
+#
+# tkextlib/tcllib/validator.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+# * Part of tcllib extension
+# * Provides a unified validation API
+#
+
+require 'tk'
+require 'tkextlib/tcllib.rb'
+
+# TkPackage.require('widget::validator', '0.1')
+TkPackage.require('widget::validator')
+
+module Tk::Tcllib
+ module Validator
+ PACKAGE_NAME = 'widget::validator'.freeze
+ def self.package_name
+ PACKAGE_NAME
+ end
+
+ def self.package_version
+ begin
+ TkPackage.require('widget::validator')
+ rescue
+ ''
+ end
+ end
+ end
+end
+
+module Tk::Tcllib::Validator
+ extend TkCore
+
+ def self.attach(widget, color, cmd=Proc.new)
+ tk_call_without_enc('::widget::validator', 'attach', widget, color, cmd)
+ nil
+ end
+
+ def self.detach(widget)
+ tk_call_without_enc('::widget::validator', 'detach', widget)
+ nil
+ end
+
+ def self.validate(widget)
+ tk_call_without_enc('::widget::validator', 'validate', widget)
+ nil
+ end
+
+ def attach_validator(color, cmd=Proc.new)
+ tk_call_without_enc('::widget::validator', 'attach', @path, color, cmd)
+ self
+ end
+
+ def detach_validator(color, cmd=Proc.new)
+ tk_call_without_enc('::widget::validator', 'detach', @path)
+ self
+ end
+
+ def invoke_validator(color, cmd=Proc.new)
+ tk_call_without_enc('::widget::validator', 'validate', @path)
+ self
+ end
+ alias validate_validator invoke_validator
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/tcllib/widget.rb b/jni/ruby/ext/tk/lib/tkextlib/tcllib/widget.rb
new file mode 100644
index 0000000..57fdf7a
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/tcllib/widget.rb
@@ -0,0 +1,82 @@
+#
+# tkextlib/tcllib/widget.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+# * Part of tcllib extension
+# * megawidget package that uses snit as the object system (snidgets)
+#
+
+require 'tk'
+require 'tkextlib/tcllib.rb'
+
+# TkPackage.require('widget', '3.0')
+TkPackage.require('widget')
+
+module Tk::Tcllib
+ module Widget
+ PACKAGE_NAME = 'widget'.freeze
+ def self.package_name
+ PACKAGE_NAME
+ end
+
+ def self.package_version
+ begin
+ TkPackage.require('widget')
+ rescue
+ ''
+ end
+ end
+
+ #--- followings may be private functions of tklib
+ def self.isa(compare_as, *args)
+ begin
+ return Tk.tk_call('::widget::isa', compare_as, *args)
+ rescue => e
+ if TkComm.bool(Tk.tk_call('info','command','::widget::isa')) ||
+ ! TkComm.bool(Tk.tk_call('info','command','::widget::validate'))
+ fail e
+ end
+ end
+ Tk.tk_call('::widget::validate', compare_as, *args)
+ end
+ def self.validate(compare_as, *args)
+ begin
+ return Tk.tk_call('::widget::validate', compare_as, *args)
+ rescue => e
+ if TkComm.bool(Tk.tk_call('info','command','::widget::validate')) ||
+ ! TkComm.bool(Tk.tk_call('info','command','::widget::isa'))
+ fail e
+ end
+ end
+ Tk.tk_call('::widget::isa', compare_as, *args)
+ end
+ end
+end
+
+module Tk::Tcllib::Widget
+ TkComm::TkExtlibAutoloadModule.unshift(self)
+
+ autoload :Calendar, 'tkextlib/tcllib/calendar'
+
+ autoload :Canvas_Sqmap, 'tkextlib/tcllib/canvas_sqmap'
+ autoload :Canvas_Zoom, 'tkextlib/tcllib/canvas_zoom'
+
+ autoload :Dialog, 'tkextlib/tcllib/dialog'
+
+ autoload :Panelframe, 'tkextlib/tcllib/panelframe'
+ autoload :PanelFrame, 'tkextlib/tcllib/panelframe'
+
+ autoload :Ruler, 'tkextlib/tcllib/ruler'
+
+ autoload :Screenruler, 'tkextlib/tcllib/screenruler'
+ autoload :ScreenRuler, 'tkextlib/tcllib/screenruler'
+
+ autoload :Scrolledwindow, 'tkextlib/tcllib/scrollwin'
+ autoload :ScrolledWindow, 'tkextlib/tcllib/scrollwin'
+
+ autoload :Superframe, 'tkextlib/tcllib/superframe'
+ autoload :SuperFrame, 'tkextlib/tcllib/superframe'
+
+ autoload :Toolbar, 'tkextlib/tcllib/toolbar'
+ autoload :ToolbarItem, 'tkextlib/tcllib/toolbar'
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/tclx.rb b/jni/ruby/ext/tk/lib/tkextlib/tclx.rb
new file mode 100644
index 0000000..3a4ff27
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/tclx.rb
@@ -0,0 +1,13 @@
+#
+# TclX support
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+
+# call setup script for general 'tkextlib' libraries
+require 'tkextlib/setup.rb'
+
+# call setup script
+require 'tkextlib/tclx/setup.rb'
+
+# load library
+require 'tkextlib/tclx/tclx'
diff --git a/jni/ruby/ext/tk/lib/tkextlib/tclx/setup.rb b/jni/ruby/ext/tk/lib/tkextlib/tclx/setup.rb
new file mode 100644
index 0000000..ee406c6
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/tclx/setup.rb
@@ -0,0 +1,8 @@
+#
+# setup.rb -- setup script before calling TkPackage.require()
+#
+# If you need some setup operations (for example, add a library path
+# to the library search path) before using Tcl/Tk library packages
+# wrapped by Ruby scripts in this directory, please write the setup
+# operations in this file.
+#
diff --git a/jni/ruby/ext/tk/lib/tkextlib/tclx/tclx.rb b/jni/ruby/ext/tk/lib/tkextlib/tclx/tclx.rb
new file mode 100644
index 0000000..5a908fc
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/tclx/tclx.rb
@@ -0,0 +1,74 @@
+#
+# tclx/tclx.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+require 'tk'
+
+# call setup script for general 'tkextlib' libraries
+require 'tkextlib/setup.rb'
+
+# call setup script
+require 'tkextlib/tclx/setup.rb'
+
+# TkPackage.require('Tclx', '8.0')
+TkPackage.require('Tclx')
+
+module Tk
+ module TclX
+ PACKAGE_NAME = 'Tclx'.freeze
+ def self.package_name
+ PACKAGE_NAME
+ end
+
+ def self.package_version
+ begin
+ TkPackage.require('Tclx')
+ rescue
+ ''
+ end
+ end
+
+ def self.infox(*args)
+ Tk.tk_call('infox', *args)
+ end
+
+ def self.signal(*args)
+ warn("Warning: Don't recommend to use TclX's 'signal' command. Please use Ruby's 'Signal.trap' method")
+ Tk.tk_call('signal', *args)
+ end
+
+ def self.signal_restart(*args)
+ warn("Warning: Don't recommend to use TclX's 'signal' command. Please use Ruby's 'Signal.trap' method")
+ Tk.tk_call('signal', '-restart', *args)
+ end
+
+ ##############################
+
+ class XPG3_MsgCat
+ class << self
+ alias open new
+ end
+
+ def initialize(catname, fail_mode=false)
+ if fail_mode
+ @msgcat_id = Tk.tk_call('catopen', '-fail', catname)
+ else
+ @msgcat_id = Tk.tk_call('catopen', '-nofail', catname)
+ end
+ end
+
+ def close(fail_mode=false)
+ if fail_mode
+ Tk.tk_call('catclose', '-fail', @msgcat_id)
+ else
+ Tk.tk_call('catclose', '-nofail', @msgcat_id)
+ end
+ self
+ end
+
+ def get(setnum, msgnum, defaultstr)
+ Tk.tk_call('catgets', @msgcat_id, setnum, msgnum, defaultstr)
+ end
+ end
+ end
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/tile.rb b/jni/ruby/ext/tk/lib/tkextlib/tile.rb
new file mode 100644
index 0000000..6c11e21
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/tile.rb
@@ -0,0 +1,449 @@
+#
+# Tile theme engin (tile widget set) support
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+
+require 'tk'
+require 'tk/ttk_selector'
+
+# call setup script for general 'tkextlib' libraries
+require 'tkextlib/setup.rb'
+
+# library directory
+require 'tkextlib/tile/setup.rb'
+
+# load package
+# TkPackage.require('tile', '0.4')
+# TkPackage.require('tile', '0.6')
+# TkPackage.require('tile', '0.7')
+if Tk::TK_MAJOR_VERSION > 8 ||
+ (Tk::TK_MAJOR_VERSION == 8 && Tk::TK_MINOR_VERSION >= 5)
+ begin
+ TkPackage.require('tile') # for compatibility (version check of 'tile')
+ rescue RuntimeError
+ # ignore, even if cannot find package 'tile'
+ end
+ pkgname = 'Ttk'
+else
+ pkgname = 'tile'
+end
+
+begin
+ verstr = TkPackage.require(pkgname)
+rescue RuntimeError
+ # define dummy methods
+ module Tk
+ module Tile
+ CANNOT_FIND_PACKAGE = true
+ def self.const_missing(sym)
+ TkPackage.require(PACKAGE_NAME)
+ end
+ def self.method_missing(*args)
+ TkPackage.require(PACKAGE_NAME)
+ end
+ end
+ end
+ Tk.__cannot_find_tk_package_for_widget_set__(:Ttk, pkgname)
+ if pkgname == 'Ttk'
+ verstr = Tk::TK_PATCHLEVEL # dummy
+ else
+ verstr = '0.7' # dummy
+ end
+end
+
+ver = verstr.split('.')
+if ver[0].to_i == 0
+ # Tile extension package
+ if ver[1].to_i <= 4
+ # version 0.4 or former
+ module Tk
+ module Tile
+ USE_TILE_NAMESPACE = true
+ USE_TTK_NAMESPACE = false
+ TILE_SPEC_VERSION_ID = 0
+ end
+ end
+ elsif ver[1].to_i <= 6
+ # version 0.5 -- version 0.6
+ module Tk
+ module Tile
+ USE_TILE_NAMESPACE = true
+ USE_TTK_NAMESPACE = true
+ TILE_SPEC_VERSION_ID = 5
+ end
+ end
+ elsif ver[1].to_i <= 7
+ module Tk
+ module Tile
+ USE_TILE_NAMESPACE = false
+ USE_TTK_NAMESPACE = true
+ TILE_SPEC_VERSION_ID = 7
+ end
+ end
+ else
+ # version 0.8 or later
+ module Tk
+ module Tile
+ USE_TILE_NAMESPACE = false
+ USE_TTK_NAMESPACE = true
+ TILE_SPEC_VERSION_ID = 8
+ end
+ end
+ end
+
+ module Tk::Tile
+ PACKAGE_NAME = 'tile'.freeze
+ end
+else
+ # Ttk package merged Tcl/Tk core (Tcl/Tk 8.5+)
+ module Tk
+ module Tile
+ USE_TILE_NAMESPACE = false
+ USE_TTK_NAMESPACE = true
+ TILE_SPEC_VERSION_ID = 8
+
+ PACKAGE_NAME = 'Ttk'.freeze
+ end
+ end
+end
+
+# autoload
+module Tk
+ module Tile
+ TkComm::TkExtlibAutoloadModule.unshift(self)
+
+ def self.package_name
+ PACKAGE_NAME
+ end
+
+ def self.package_version
+ begin
+ TkPackage.require(PACKAGE_NAME)
+ rescue
+ ''
+ end
+ end
+
+ def self.__Import_Tile_Widgets__!
+ warn 'Warning: "Tk::Tile::__Import_Tile_Widgets__!" is obsolete.' <<
+ ' To control default widget set, use "Tk.default_widget_set = :Ttk"'
+ Tk.tk_call('namespace', 'import', '-force', 'ttk::*')
+ end
+
+ def self.__define_LoadImages_proc_for_compatibility__!
+ # Ttk 8.5 (Tile 0.8) lost 'LoadImages' utility procedure.
+ # So, some old scripts doen't work, because those scripts use the
+ # procedure to define local styles.
+ # Of course, rewriting such Tcl/Tk scripts isn't difficult for
+ # Tcl/Tk users. However, it may be troublesome for Ruby/Tk users
+ # who use such Tcl/Tk scripts as it is.
+ # This method may help Ruby/Tk users who don't want to modify old
+ # Tcl/Tk scripts for the latest version of Ttk (Tile) extension.
+ # This method defines a comaptible 'LoadImages' procedure on the
+ # Tcl/Tk interpreter working under Ruby/Tk.
+ # Please give attention to use this method. It may conflict with
+ # some definitions on Tcl/Tk scripts.
+ klass_name = self.name
+ proc_name = 'LoadImages'
+ if Tk::Tile::USE_TTK_NAMESPACE
+ ns_list = ['::tile']
+ if Tk.info(:commands, "::ttk::#{proc_name}").empty?
+ ns_list << '::ttk'
+ end
+ else # Tk::Tile::USE_TILE_NAMESPACE
+ ns_list = ['::ttk']
+ if Tk.info(:commands, "::tile::#{proc_name}").empty?
+ ns_list << '::tile'
+ end
+ end
+
+ ns_list.each{|ns|
+ cmd = "#{ns}::#{proc_name}"
+ unless Tk.info(:commands, cmd).empty?
+ #fail RuntimeError, "can't define '#{cmd}' command (already exist)"
+
+ # do nothing !!!
+ warn "Warning: can't define '#{cmd}' command (already exist)" if $DEBUG
+ next
+ end
+ TkNamespace.eval(ns){
+ TkCore::INTERP.add_tk_procs(proc_name, 'imgdir {patterns {*.gif}}',
+ <<-'EOS')
+ foreach pattern $patterns {
+ foreach file [glob -directory $imgdir $pattern] {
+ set img [file tail [file rootname $file]]
+ if {![info exists images($img)]} {
+ set images($img) [image create photo -file $file]
+ }
+ }
+ }
+ return [array get images]
+ EOS
+ }
+ }
+ end
+
+ def self.load_images(imgdir, pat=nil)
+ if Tk::Tile::TILE_SPEC_VERSION_ID < 8
+ if Tk::Tile::USE_TTK_NAMESPACE
+ cmd = '::ttk::LoadImages'
+ else # Tk::Tile::USE_TILE_NAMESPACE
+ cmd = '::tile::LoadImages'
+ end
+ pat ||= TkComm::None
+ images = Hash[*TkComm.simplelist(Tk.tk_call(cmd, imgdir, pat))]
+ images.keys.each{|k|
+ images[k] = TkPhotoImage.new(:imagename=>images[k],
+ :without_creating=>true)
+ }
+ else ## TILE_SPEC_VERSION_ID >= 8
+ pat ||= '*.gif'
+ if pat.kind_of?(Array)
+ pat_list = pat
+ else
+ pat_list = [ pat ]
+ end
+ Dir.chdir(imgdir){
+ pat_list.each{|pat|
+ Dir.glob(pat).each{|f|
+ img = File.basename(f, '.*')
+ unless TkComm.bool(Tk.info('exists', "images(#{img})"))
+ Tk.tk_call('set', "images(#{img})",
+ Tk.tk_call('image', 'create', 'photo', '-file', f))
+ end
+ }
+ }
+ }
+ images = Hash[*TkComm.simplelist(Tk.tk_call('array', 'get', 'images'))]
+ images.keys.each{|k|
+ images[k] = TkPhotoImage.new(:imagename=>images[k],
+ :without_creating=>true)
+ }
+ end
+
+ images
+ end
+
+ def self.style(*args)
+ args.map!{|arg| TkComm._get_eval_string(arg)}.join('.')
+ end
+
+ def self.themes(glob_ptn = nil)
+ if TILE_SPEC_VERSION_ID < 8 && Tk.info(:commands, '::ttk::themes').empty?
+ fail RuntimeError, 'not support glob option' if glob_ptn
+ cmd = ['::tile::availableThemes']
+ else
+ glob_ptn = '*' unless glob_ptn
+ cmd = ['::ttk::themes', glob_ptn]
+ end
+
+ begin
+ TkComm.simplelist(Tk.tk_call_without_enc(*cmd))
+ rescue
+ TkComm.simplelist(Tk.tk_call('lsearch', '-all', '-inline',
+ Tk::Tile::Style.theme_names,
+ glob_ptn))
+ end
+ end
+
+ def self.set_theme(theme)
+ if TILE_SPEC_VERSION_ID < 8 && Tk.info(:commands, '::ttk::setTheme').empty?
+ cmd = '::tile::setTheme'
+ else
+ cmd = '::ttk::setTheme'
+ end
+
+ begin
+ Tk.tk_call_without_enc(cmd, theme)
+ rescue
+ Tk::Tile::Style.theme_use(theme)
+ end
+ end
+
+ module KeyNav
+ if Tk::Tile::TILE_SPEC_VERSION_ID < 8
+ def self.enableMnemonics(w)
+ Tk.tk_call('::keynav::enableMnemonics', w)
+ end
+ def self.defaultButton(w)
+ Tk.tk_call('::keynav::defaultButton', w)
+ end
+ else # dummy
+ def self.enableMnemonics(w)
+ ""
+ end
+ def self.defaultButton(w)
+ ""
+ end
+ end
+ end
+
+ module Font
+ Default = 'TkDefaultFont'
+ Text = 'TkTextFont'
+ Heading = 'TkHeadingFont'
+ Caption = 'TkCaptionFont'
+ Tooltip = 'TkTooltipFont'
+
+ Fixed = 'TkFixedFont'
+ Menu = 'TkMenuFont'
+ SmallCaption = 'TkSmallCaptionFont'
+ Icon = 'TkIconFont'
+
+ TkFont::SYSTEM_FONT_NAMES.add [
+ 'TkDefaultFont', 'TkTextFont', 'TkHeadingFont',
+ 'TkCaptionFont', 'TkTooltipFont', 'TkFixedFont',
+ 'TkMenuFont', 'TkSmallCaptionFont', 'TkIconFont'
+ ]
+ end
+
+ module ParseStyleLayout
+ def _style_layout(lst)
+ ret = []
+ until lst.empty?
+ sub = [lst.shift]
+ keys = {}
+
+ until lst.empty?
+ if lst[0][0] == ?-
+ k = lst.shift[1..-1]
+ children = lst.shift
+ children = _style_layout(children) if children.kind_of?(Array)
+ keys[k] = children
+ else
+ break
+ end
+ end
+
+ sub << keys unless keys.empty?
+ ret << sub
+ end
+ ret
+ end
+ private :_style_layout
+ end
+
+ module TileWidget
+ include Tk::Tile::ParseStyleLayout
+
+ def __val2ruby_optkeys # { key=>proc, ... }
+ # The method is used to convert a opt-value to a ruby's object.
+ # When get the value of the option "key", "proc.call(value)" is called.
+ super().update('style'=>proc{|v| _style_layout(list(v))})
+ end
+ private :__val2ruby_optkeys
+
+ def ttk_instate(state, script=nil, &b)
+ if script
+ tk_send('instate', state, script)
+ elsif b
+ tk_send('instate', state, Proc.new(&b))
+ else
+ bool(tk_send('instate', state))
+ end
+ end
+ alias tile_instate ttk_instate
+
+ def ttk_state(state=nil)
+ if state
+ tk_send('state', state)
+ else
+ list(tk_send('state'))
+ end
+ end
+ alias tile_state ttk_state
+
+ def ttk_identify(x, y)
+ ret = tk_send_without_enc('identify', x, y)
+ (ret.empty?)? nil: ret
+ end
+ alias tile_identify ttk_identify
+
+ # remove instate/state/identify method
+ # to avoid the conflict with widget options
+ if Tk.const_defined?(:USE_OBSOLETE_TILE_STATE_METHOD) && Tk::USE_OBSOLETE_TILE_STATE_METHOD
+ alias instate ttk_instate
+ alias state ttk_state
+ alias identify ttk_identify
+ end
+ end
+
+ ######################################
+
+ autoload :TButton, 'tkextlib/tile/tbutton'
+ autoload :Button, 'tkextlib/tile/tbutton'
+
+ autoload :TCheckButton, 'tkextlib/tile/tcheckbutton'
+ autoload :CheckButton, 'tkextlib/tile/tcheckbutton'
+ autoload :TCheckbutton, 'tkextlib/tile/tcheckbutton'
+ autoload :Checkbutton, 'tkextlib/tile/tcheckbutton'
+
+ autoload :Dialog, 'tkextlib/tile/dialog'
+
+ autoload :TEntry, 'tkextlib/tile/tentry'
+ autoload :Entry, 'tkextlib/tile/tentry'
+
+ autoload :TCombobox, 'tkextlib/tile/tcombobox'
+ autoload :Combobox, 'tkextlib/tile/tcombobox'
+
+ autoload :TFrame, 'tkextlib/tile/tframe'
+ autoload :Frame, 'tkextlib/tile/tframe'
+
+ autoload :TLabelframe, 'tkextlib/tile/tlabelframe'
+ autoload :Labelframe, 'tkextlib/tile/tlabelframe'
+ autoload :TLabelFrame, 'tkextlib/tile/tlabelframe'
+ autoload :LabelFrame, 'tkextlib/tile/tlabelframe'
+
+ autoload :TLabel, 'tkextlib/tile/tlabel'
+ autoload :Label, 'tkextlib/tile/tlabel'
+
+ autoload :TMenubutton, 'tkextlib/tile/tmenubutton'
+ autoload :Menubutton, 'tkextlib/tile/tmenubutton'
+ autoload :TMenuButton, 'tkextlib/tile/tmenubutton'
+ autoload :MenuButton, 'tkextlib/tile/tmenubutton'
+
+ autoload :TNotebook, 'tkextlib/tile/tnotebook'
+ autoload :Notebook, 'tkextlib/tile/tnotebook'
+
+ autoload :TPaned, 'tkextlib/tile/tpaned'
+ autoload :Paned, 'tkextlib/tile/tpaned'
+ autoload :PanedWindow, 'tkextlib/tile/tpaned'
+ autoload :Panedwindow, 'tkextlib/tile/tpaned'
+
+ autoload :TProgressbar, 'tkextlib/tile/tprogressbar'
+ autoload :Progressbar, 'tkextlib/tile/tprogressbar'
+
+ autoload :TRadioButton, 'tkextlib/tile/tradiobutton'
+ autoload :RadioButton, 'tkextlib/tile/tradiobutton'
+ autoload :TRadiobutton, 'tkextlib/tile/tradiobutton'
+ autoload :Radiobutton, 'tkextlib/tile/tradiobutton'
+
+ autoload :TScale, 'tkextlib/tile/tscale'
+ autoload :Scale, 'tkextlib/tile/tscale'
+ autoload :TProgress, 'tkextlib/tile/tscale'
+ autoload :Progress, 'tkextlib/tile/tscale'
+
+ autoload :TScrollbar, 'tkextlib/tile/tscrollbar'
+ autoload :Scrollbar, 'tkextlib/tile/tscrollbar'
+ autoload :XScrollbar, 'tkextlib/tile/tscrollbar'
+ autoload :YScrollbar, 'tkextlib/tile/tscrollbar'
+
+ autoload :TSeparator, 'tkextlib/tile/tseparator'
+ autoload :Separator, 'tkextlib/tile/tseparator'
+
+ autoload :TSpinbox, 'tkextlib/tile/tspinbox'
+ autoload :Spinbox, 'tkextlib/tile/tspinbox'
+
+ autoload :TSquare, 'tkextlib/tile/tsquare'
+ autoload :Square, 'tkextlib/tile/tsquare'
+
+ autoload :SizeGrip, 'tkextlib/tile/sizegrip'
+ autoload :Sizegrip, 'tkextlib/tile/sizegrip'
+
+ autoload :Treeview, 'tkextlib/tile/treeview'
+
+ autoload :Style, 'tkextlib/tile/style'
+ end
+end
+
+Ttk = Tk::Tile
diff --git a/jni/ruby/ext/tk/lib/tkextlib/tile/dialog.rb b/jni/ruby/ext/tk/lib/tkextlib/tile/dialog.rb
new file mode 100644
index 0000000..b112e61
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/tile/dialog.rb
@@ -0,0 +1,102 @@
+#
+# ttk::dialog (tile-0.7+)
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+require 'tk'
+require 'tkextlib/tile.rb'
+
+module Tk
+ module Tile
+ class Dialog < TkWindow
+ end
+ end
+end
+
+begin
+ TkPackage.require('ttk::dialog') # this may be required.
+rescue RuntimeError
+ # ignore
+end
+
+class Tk::Tile::Dialog
+ TkCommandNames = ['::ttk::dialog'.freeze].freeze
+
+ def self.show(*args)
+ dialog = self.new(*args)
+ dialog.show
+ [dialog.status, dialog.value]
+ end
+ def self.display(*args)
+ self.show(*args)
+ end
+
+ def self.define_dialog_type(name, keys)
+ Tk.tk_call('::ttk::dialog::define', name, keys)
+ name
+ end
+
+ def self.style(*args)
+ ['Dialog', *(args.map!{|a| _get_eval_string(a)})].join('.')
+ end
+
+ #########################
+
+ def initialize(keys={})
+ @keys = _symbolkey2str(keys)
+ super(*args)
+ end
+
+ def create_self(keys)
+ # dummy
+ end
+ private :create_self
+
+ def show
+ tk_call(self.class::TkCommandNames[0], @path, *hash_kv(@keys))
+ end
+ alias display show
+
+ def client_frame
+ window(tk_call_without_enc('::ttk::dialog::clientframe', @path))
+ end
+
+ def cget_strict(slot)
+ @keys[slot.to_s]
+ end
+ def cget(slot)
+ @keys[slot.to_s]
+ end
+=begin
+ def cget(slot)
+ unless TkConfigMethod.__IGNORE_UNKNOWN_CONFIGURE_OPTION__
+ cget_strict(slot)
+ else
+ cget_strict(slot) rescue nil
+ end
+ end
+=end
+
+ def configure(slot, value=None)
+ if slot.kind_of?(Hash)
+ slot.each{|k, v| configure(k, v)}
+ else
+ slot = slot.to_s
+ value = _symbolkey2str(value) if value.kind_of?(Hash)
+ if value && value != None
+ @keys[slot] = value
+ else
+ @keys.delete(slot)
+ end
+ end
+ self
+ end
+
+ def configinfo(slot = nil)
+ if slot
+ slot = slot.to_s
+ [ slot, nil, nil, nil, @keys[slot] ]
+ else
+ @keys.collect{|k, v| [ k, nil, nil, nil, v ] }
+ end
+ end
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/tile/setup.rb b/jni/ruby/ext/tk/lib/tkextlib/tile/setup.rb
new file mode 100644
index 0000000..ee406c6
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/tile/setup.rb
@@ -0,0 +1,8 @@
+#
+# setup.rb -- setup script before calling TkPackage.require()
+#
+# If you need some setup operations (for example, add a library path
+# to the library search path) before using Tcl/Tk library packages
+# wrapped by Ruby scripts in this directory, please write the setup
+# operations in this file.
+#
diff --git a/jni/ruby/ext/tk/lib/tkextlib/tile/sizegrip.rb b/jni/ruby/ext/tk/lib/tkextlib/tile/sizegrip.rb
new file mode 100644
index 0000000..9947e0d
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/tile/sizegrip.rb
@@ -0,0 +1,32 @@
+#
+# ttk::sizegrip widget
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+require 'tk'
+require 'tkextlib/tile.rb'
+
+module Tk
+ module Tile
+ class SizeGrip < TkWindow
+ end
+ Sizegrip = SizeGrip
+ end
+end
+
+class Tk::Tile::SizeGrip < TkWindow
+ include Tk::Tile::TileWidget
+
+ TkCommandNames = ['::ttk::sizegrip'.freeze].freeze
+ WidgetClassName = 'TSizegrip'.freeze
+ WidgetClassNames[WidgetClassName] ||= self
+
+ def self.style(*args)
+ [self::WidgetClassName, *(args.map!{|a| _get_eval_string(a)})].join('.')
+ end
+end
+
+#Tk.__set_toplevel_aliases__(:Ttk, Tk::Tile::Sizegrip,
+# :TkSizegrip, :TkSizeGrip)
+Tk.__set_loaded_toplevel_aliases__('tkextlib/tile/sizegrip.rb',
+ :Ttk, Tk::Tile::Sizegrip,
+ :TkSizegrip, :TkSizeGrip)
diff --git a/jni/ruby/ext/tk/lib/tkextlib/tile/style.rb b/jni/ruby/ext/tk/lib/tkextlib/tile/style.rb
new file mode 100644
index 0000000..83a0c9a
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/tile/style.rb
@@ -0,0 +1,336 @@
+#
+# style commands
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+require 'tk'
+require 'tkextlib/tile.rb'
+
+module Tk
+ module Tile
+ module Style
+ end
+ end
+end
+
+module Tk::Tile::Style
+ extend TkCore
+end
+
+class << Tk::Tile::Style
+ if Tk::Tile::TILE_SPEC_VERSION_ID < 8
+ TkCommandNames = ['style'.freeze].freeze
+
+ # --- Tk::Tile::Style.__define_wrapper_proc_for_compatibility__! ---
+ # On Ttk (Tile) extension, 'style' command has incompatible changes
+ # depend on the version of the extension. It requires modifying the
+ # Tcl/Tk scripts to define local styles. The rule for modification
+ # is a simple one. But, if users want to keep compatibility between
+ # versions of the extension, they will have to contrive to do that.
+ # It may be troublesome, especially for Ruby/Tk users.
+ # This method may help such work. This method make some definitions
+ # on the Tcl/Tk interpreter to work with different version of style
+ # command format. Please give attention to use this method. It may
+ # conflict with some definitions on Tcl/Tk scripts.
+ if Tk::Tile::TILE_SPEC_VERSION_ID < 7
+ def __define_wrapper_proc_for_compatibility__!
+ __define_themes_and_setTheme_proc__!
+
+ unless Tk.info(:commands, '::ttk::style').empty?
+ # fail RuntimeError,
+ # "can't define '::ttk::style' command (already exist)"
+
+ # do nothing !!!
+ warn "Warning: can't define '::ttk::style' command (already exist)" if $DEBUG
+ return
+ end
+ TkCore::INTERP.add_tk_procs('::ttk::style', 'args', <<-'EOS')
+ if [string equal [lrange $args 0 1] {element create}] {
+ if [string equal [lindex $args 3] image] {
+ set spec [lindex $args 4]
+ set map [lrange $spec 1 end]
+ if [llength $map] {
+ # return [eval [concat [list ::style element create [lindex $args 2] image [lindex $spec 0] -map $map] [lrange $args 5 end]]]
+ return [uplevel 1 [list ::style element create [lindex $args 2] image [lindex $spec 0] -map $map] [lrange $args 5 end]]
+ }
+ }
+ }
+ # return [eval "::style $args"]
+ return [uplevel 1 ::style $args]
+ EOS
+ #########################
+ end
+ else ### TILE_SPEC_VERSION_ID == 7
+ def __define_wrapper_proc_for_compatibility__!
+ __define_themes_and_setTheme_proc__!
+
+ unless Tk.info(:commands, '::ttk::style').empty?
+ # fail RuntimeError,
+ # "can't define '::ttk::style' command (already exist)"
+
+ # do nothing !!!
+ warn "Warning: can't define '::ttk::style' command (already exist)" if $DEBUG
+ return
+ end
+ TkCore::INTERP.add_tk_procs('::ttk::style', 'args', <<-'EOS')
+ if [string equal [lrange $args 0 1] {element create}] {
+ if [string equal [lindex $args 3] image] {
+ set spec [lindex $args 4]
+ set map [lrange $spec 1 end]
+ if [llength $map] {
+ # return [eval [concat [list ::style element create [lindex $args 2] image [lindex $spec 0] -map $map] [lrange $args 5 end]]]
+ return [uplevel 1 [list ::style element create [lindex $args 2] image [lindex $spec 0] -map $map] [lrange $args 5 end]]]
+ }
+ }
+ } elseif [string equal [lindex $args 0] default] {
+ # return [eval "::style [lreplace $args 0 0 configure]"]
+ return [uplevel 1 ::style [lreplace $args 0 0 configure]]
+ }
+ # return [eval "::style $args"]
+ return [uplevel 1 ::style $args]
+ EOS
+ #########################
+ end
+ end
+ else ### TILE_SPEC_VERSION_ID >= 8
+ TkCommandNames = ['::ttk::style'.freeze].freeze
+
+ def __define_wrapper_proc_for_compatibility__!
+ __define_themes_and_setTheme_proc__!
+
+ unless Tk.info(:commands, '::style').empty?
+ # fail RuntimeError, "can't define '::style' command (already exist)"
+
+ # do nothing !!!
+ warn "Warning: can't define '::style' command (already exist)" if $DEBUG
+ return
+ end
+ TkCore::INTERP.add_tk_procs('::style', 'args', <<-'EOS')
+ if [string equal [lrange $args 0 1] {element create}] {
+ if [string equal [lindex $args 3] image] {
+ set name [lindex $args 4]
+ set opts [lrange $args 5 end]
+ set idx [lsearch $opts -map]
+ if {$idx >= 0 && [expr $idx % 2 == 0]} {
+ # return [eval [concat [list ::ttk::style element create [lindex $args 2] image [concat $name [lindex $opts [expr $idx + 1]]]] [lreplace $opts $idx [expr $idx + 1]]]]
+ return [uplevel 1 [list ::ttk::style element create [lindex $args 2] image [concat $name [lindex $opts [expr $idx + 1]]]] [lreplace $opts $idx [expr $idx + 1]]]
+ }
+ }
+ } elseif [string equal [lindex $args 0] default] {
+ # return [eval "::ttk::style [lreplace $args 0 0 configure]"]
+ return [uplevel 1 ::ttk::style [lreplace $args 0 0 configure]]
+ }
+ # return [eval "::ttk::style $args"]
+ return [uplevel 1 ::ttk::style $args]
+ EOS
+ #########################
+ end
+ end
+
+ def __define_themes_and_setTheme_proc__!
+ TkCore::INTERP.add_tk_procs('::ttk::themes', '{ptn *}', <<-'EOS')
+ #set themes [list]
+ set themes [::ttk::style theme names]
+ foreach pkg [lsearch -inline -all -glob [package names] ttk::theme::$ptn] {
+ set theme [namespace tail $pkg]
+ if {[lsearch -exact $themes $theme] < 0} {
+ lappend themes $theme
+ }
+ }
+ foreach pkg [lsearch -inline -all -glob [package names] tile::theme::$ptn] {
+ set theme [namespace tail $pkg]
+ if {[lsearch -exact $themes $theme] < 0} {
+ lappend themes $theme
+ }
+ }
+ return $themes
+ EOS
+ #########################
+ TkCore::INTERP.add_tk_procs('::ttk::setTheme', 'theme', <<-'EOS')
+ variable currentTheme
+ if {[lsearch -exact [::ttk::style theme names] $theme] < 0} {
+ package require [lsearch -inline -regexp [package names] (ttk|tile)::theme::$theme]
+ }
+ ::ttk::style theme use $theme
+ set currentTheme $theme
+ EOS
+ end
+ private :__define_themes_and_setTheme_proc__!
+
+ def configure(style=nil, keys=nil)
+ if style.kind_of?(Hash)
+ keys = style
+ style = nil
+ end
+ style = '.' unless style
+
+ if Tk::Tile::TILE_SPEC_VERSION_ID < 7
+ sub_cmd = 'default'
+ else
+ sub_cmd = 'configure'
+ end
+
+ if keys && keys != None
+ tk_call(TkCommandNames[0], sub_cmd, style, *hash_kv(keys))
+ else
+ tk_call(TkCommandNames[0], sub_cmd, style)
+ end
+ end
+ alias default configure
+
+ def map(style=nil, keys=nil)
+ if style.kind_of?(Hash)
+ keys = style
+ style = nil
+ end
+ style = '.' unless style
+
+ if keys && keys != None
+ if keys.kind_of?(Hash)
+ tk_call(TkCommandNames[0], 'map', style, *hash_kv(keys))
+ else
+ simplelist(tk_call(TkCommandNames[0], 'map', style, '-' << keys.to_s))
+ end
+ else
+ ret = {}
+ Hash[*(simplelist(tk_call(TkCommandNames[0], 'map', style)))].each{|k, v|
+ ret[k[1..-1]] = list(v)
+ }
+ ret
+ end
+ end
+ alias map_configure map
+
+ def map_configinfo(style=nil, key=None)
+ style = '.' unless style
+ map(style, key)
+ end
+
+ def map_default_configinfo(key=None)
+ map('.', key)
+ end
+
+ def lookup(style, opt, state=None, fallback_value=None)
+ tk_call(TkCommandNames[0], 'lookup', style,
+ '-' << opt.to_s, state, fallback_value)
+ end
+
+ include Tk::Tile::ParseStyleLayout
+
+ def layout(style=nil, spec=nil)
+ if style.kind_of?(Hash)
+ spec = style
+ style = nil
+ end
+ style = '.' unless style
+
+ if spec
+ tk_call(TkCommandNames[0], 'layout', style, spec)
+ else
+ _style_layout(list(tk_call(TkCommandNames[0], 'layout', style)))
+ end
+ end
+
+ def element_create(name, type, *args)
+ if type == 'image' || type == :image
+ element_create_image(name, *args)
+ elsif type == 'vsapi' || type == :vsapi
+ element_create_vsapi(name, *args)
+ else
+ tk_call(TkCommandNames[0], 'element', 'create', name, type, *args)
+ end
+ end
+
+ def element_create_image(name, *args)
+ fail ArgumentError, 'Must supply a base image' unless (spec = args.shift)
+ if (opts = args.shift)
+ if opts.kind_of?(Hash)
+ opts = _symbolkey2str(opts)
+ else
+ fail ArgumentError, 'bad option'
+ end
+ end
+ fail ArgumentError, 'too many arguments' unless args.empty?
+
+ if spec.kind_of?(Array)
+ # probably, command format is tile 0.8+ (Tcl/Tk8.5+) style
+ if Tk::Tile::TILE_SPEC_VERSION_ID >= 8
+ if opts
+ tk_call(TkCommandNames[0],
+ 'element', 'create', name, 'image', spec, opts)
+ else
+ tk_call(TkCommandNames[0], 'element', 'create', name, 'image', spec)
+ end
+ else
+ fail ArgumentError, 'illegal arguments' if opts.key?('map')
+ base = spec.shift
+ opts['map'] = spec
+ tk_call(TkCommandNames[0],
+ 'element', 'create', name, 'image', base, opts)
+ end
+ else
+ # probably, command format is tile 0.7.8 or older style
+ if Tk::Tile::TILE_SPEC_VERSION_ID >= 8
+ spec = [spec, *(opts.delete('map'))] if opts.key?('map')
+ end
+ if opts
+ tk_call(TkCommandNames[0],
+ 'element', 'create', name, 'image', spec, opts)
+ else
+ tk_call(TkCommandNames[0], 'element', 'create', name, 'image', spec)
+ end
+ end
+ end
+
+ def element_create_vsapi(name, class_name, part_id, *args)
+ # supported on Tcl/Tk 8.6 or later
+
+ # argument check
+ if (state_map = args.shift || None)
+ if state_map.kind_of?(Hash)
+ opts = _symbolkey2str(state_map)
+ state_map = None
+ end
+ end
+ opts = args.shift || None
+ fail ArgumentError, "too many arguments" unless args.empty?
+
+ # define a Microsoft Visual Styles element
+ tk_call(TkCommandNames[0], 'element', 'create', name, 'vsapi',
+ class_name, part_id, state_map, opts)
+ end
+
+ def element_names()
+ list(tk_call(TkCommandNames[0], 'element', 'names'))
+ end
+
+ def element_options(elem)
+ simplelist(tk_call(TkCommandNames[0], 'element', 'options', elem))
+ end
+
+ def theme_create(name, keys=nil)
+ name = name.to_s
+ if keys && keys != None
+ tk_call(TkCommandNames[0], 'theme', 'create', name, *hash_kv(keys))
+ else
+ tk_call(TkCommandNames[0], 'theme', 'create', name)
+ end
+ name
+ end
+
+ def theme_settings(name, cmd=nil, &b)
+ name = name.to_s
+ cmd = Proc.new(&b) if !cmd && b
+ tk_call(TkCommandNames[0], 'theme', 'settings', name, cmd)
+ name
+ end
+
+ def theme_names()
+ list(tk_call(TkCommandNames[0], 'theme', 'names'))
+ end
+
+ def theme_use(name)
+ name = name.to_s
+ tk_call(TkCommandNames[0], 'theme', 'use', name)
+ name
+ end
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/tile/tbutton.rb b/jni/ruby/ext/tk/lib/tkextlib/tile/tbutton.rb
new file mode 100644
index 0000000..c852024
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/tile/tbutton.rb
@@ -0,0 +1,34 @@
+#
+# tbutton widget
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+require 'tk'
+require 'tkextlib/tile.rb'
+
+module Tk
+ module Tile
+ class TButton < Tk::Button
+ end
+ Button = TButton
+ end
+end
+
+class Tk::Tile::TButton < Tk::Button
+ include Tk::Tile::TileWidget
+
+ if Tk::Tile::USE_TTK_NAMESPACE
+ TkCommandNames = ['::ttk::button'.freeze].freeze
+ else
+ TkCommandNames = ['::tbutton'.freeze].freeze
+ end
+ WidgetClassName = 'TButton'.freeze
+ WidgetClassNames[WidgetClassName] ||= self
+
+ def self.style(*args)
+ [self::WidgetClassName, *(args.map!{|a| _get_eval_string(a)})].join('.')
+ end
+end
+
+#Tk.__set_toplevel_aliases__(:Ttk, Tk::Tile::Button, :TkButton)
+Tk.__set_loaded_toplevel_aliases__('tkextlib/tile/tbutton.rb',
+ :Ttk, Tk::Tile::Button, :TkButton)
diff --git a/jni/ruby/ext/tk/lib/tkextlib/tile/tcheckbutton.rb b/jni/ruby/ext/tk/lib/tkextlib/tile/tcheckbutton.rb
new file mode 100644
index 0000000..01751ed
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/tile/tcheckbutton.rb
@@ -0,0 +1,38 @@
+#
+# tcheckbutton widget
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+require 'tk'
+require 'tkextlib/tile.rb'
+
+module Tk
+ module Tile
+ class TCheckButton < Tk::CheckButton
+ end
+ TCheckbutton = TCheckButton
+ CheckButton = TCheckButton
+ Checkbutton = TCheckButton
+ end
+end
+
+class Tk::Tile::TCheckButton < Tk::CheckButton
+ include Tk::Tile::TileWidget
+
+ if Tk::Tile::USE_TTK_NAMESPACE
+ TkCommandNames = ['::ttk::checkbutton'.freeze].freeze
+ else
+ TkCommandNames = ['::tcheckbutton'.freeze].freeze
+ end
+ WidgetClassName = 'TCheckbutton'.freeze
+ WidgetClassNames[WidgetClassName] ||= self
+
+ def self.style(*args)
+ [self::WidgetClassName, *(args.map!{|a| _get_eval_string(a)})].join('.')
+ end
+end
+
+#Tk.__set_toplevel_aliases__(:Ttk, Tk::Tile::Checkbutton,
+# :TkCheckbutton, :TkCheckButton)
+Tk.__set_loaded_toplevel_aliases__('tkextlib/tile/tcheckbutton.rb',
+ :Ttk, Tk::Tile::Checkbutton,
+ :TkCheckbutton, :TkCheckButton)
diff --git a/jni/ruby/ext/tk/lib/tkextlib/tile/tcombobox.rb b/jni/ruby/ext/tk/lib/tkextlib/tile/tcombobox.rb
new file mode 100644
index 0000000..b5ab827
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/tile/tcombobox.rb
@@ -0,0 +1,55 @@
+#
+# tcombobox widget
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+require 'tk'
+require 'tkextlib/tile.rb'
+
+module Tk
+ module Tile
+ class TCombobox < Tk::Tile::TEntry
+ end
+ Combobox = TCombobox
+ end
+end
+
+class Tk::Tile::TCombobox < Tk::Tile::TEntry
+ include Tk::Tile::TileWidget
+
+ if Tk::Tile::USE_TTK_NAMESPACE
+ TkCommandNames = ['::ttk::combobox'.freeze].freeze
+ else
+ TkCommandNames = ['::tcombobox'.freeze].freeze
+ end
+ WidgetClassName = 'TCombobox'.freeze
+ WidgetClassNames[WidgetClassName] ||= self
+
+ def __boolval_optkeys
+ super() << 'exportselection'
+ end
+ private :__boolval_optkeys
+
+ def __listval_optkeys
+ super() << 'values'
+ end
+ private :__listval_optkeys
+
+ def self.style(*args)
+ [self::WidgetClassName, *(args.map!{|a| _get_eval_string(a)})].join('.')
+ end
+
+ def current
+ number(tk_send_without_enc('current'))
+ end
+ def current=(idx)
+ tk_send_without_enc('current', idx)
+ end
+
+ def set(val)
+ tk_send('set', val)
+ end
+end
+
+#Tk.__set_toplevel_aliases__(:Ttk, Tk::Tile::Combobox, :TkCombobox)
+Tk.__set_loaded_toplevel_aliases__('tkextlib/tile/tcombobox.rb',
+ :Ttk, Tk::Tile::Combobox, :TkCombobox)
diff --git a/jni/ruby/ext/tk/lib/tkextlib/tile/tentry.rb b/jni/ruby/ext/tk/lib/tkextlib/tile/tentry.rb
new file mode 100644
index 0000000..8d2633a
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/tile/tentry.rb
@@ -0,0 +1,49 @@
+#
+# tentry widget
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+require 'tk'
+require 'tkextlib/tile.rb'
+
+module Tk
+ module Tile
+ class TEntry < Tk::Entry
+ end
+ Entry = TEntry
+ end
+end
+
+class Tk::Tile::TEntry < Tk::Entry
+ include Tk::Tile::TileWidget
+
+ if Tk::Tile::USE_TTK_NAMESPACE
+ TkCommandNames = ['::ttk::entry'.freeze].freeze
+ else
+ TkCommandNames = ['::tentry'.freeze].freeze
+ end
+ WidgetClassName = 'TEntry'.freeze
+ WidgetClassNames[WidgetClassName] ||= self
+
+ def __optkey_aliases
+ {:vcmd=>:validatecommand, :invcmd=>:invalidcommand}
+ end
+ private :__optkey_aliases
+
+ def __boolval_optkeys
+ super() << 'exportselection'
+ end
+ private :__boolval_optkeys
+
+ def __strval_optkeys
+ super() << 'show'
+ end
+ private :__strval_optkeys
+
+ def self.style(*args)
+ [self::WidgetClassName, *(args.map!{|a| _get_eval_string(a)})].join('.')
+ end
+end
+
+#Tk.__set_toplevel_aliases__(:Ttk, Tk::Tile::Entry, :TkEntry)
+Tk.__set_loaded_toplevel_aliases__('tkextlib/tile/tentry.rb',
+ :Ttk, Tk::Tile::Entry, :TkEntry)
diff --git a/jni/ruby/ext/tk/lib/tkextlib/tile/tframe.rb b/jni/ruby/ext/tk/lib/tkextlib/tile/tframe.rb
new file mode 100644
index 0000000..d6d4312
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/tile/tframe.rb
@@ -0,0 +1,34 @@
+#
+# tframe widget
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+require 'tk'
+require 'tkextlib/tile.rb'
+
+module Tk
+ module Tile
+ class TFrame < Tk::Frame
+ end
+ Frame = TFrame
+ end
+end
+
+class Tk::Tile::TFrame < Tk::Frame
+ include Tk::Tile::TileWidget
+
+ if Tk::Tile::USE_TTK_NAMESPACE
+ TkCommandNames = ['::ttk::frame'.freeze].freeze
+ else
+ TkCommandNames = ['::tframe'.freeze].freeze
+ end
+ WidgetClassName = 'TFrame'.freeze
+ WidgetClassNames[WidgetClassName] ||= self
+
+ def self.style(*args)
+ [self::WidgetClassName, *(args.map!{|a| _get_eval_string(a)})].join('.')
+ end
+end
+
+#Tk.__set_toplevel_aliases__(:Ttk, Tk::Tile::Frame, :TkFrame)
+Tk.__set_loaded_toplevel_aliases__('tkextlib/tile/tframe.rb',
+ :Ttk, Tk::Tile::Frame, :TkFrame)
diff --git a/jni/ruby/ext/tk/lib/tkextlib/tile/tlabel.rb b/jni/ruby/ext/tk/lib/tkextlib/tile/tlabel.rb
new file mode 100644
index 0000000..55b98ac
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/tile/tlabel.rb
@@ -0,0 +1,34 @@
+#
+# tlabel widget
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+require 'tk'
+require 'tkextlib/tile.rb'
+
+module Tk
+ module Tile
+ class TLabel < Tk::Label
+ end
+ Label = TLabel
+ end
+end
+
+class Tk::Tile::TLabel < Tk::Label
+ include Tk::Tile::TileWidget
+
+ if Tk::Tile::USE_TTK_NAMESPACE
+ TkCommandNames = ['::ttk::label'.freeze].freeze
+ else
+ TkCommandNames = ['::tlabel'.freeze].freeze
+ end
+ WidgetClassName = 'TLabel'.freeze
+ WidgetClassNames[WidgetClassName] ||= self
+
+ def self.style(*args)
+ [self::WidgetClassName, *(args.map!{|a| _get_eval_string(a)})].join('.')
+ end
+end
+
+#Tk.__set_toplevel_aliases__(:Ttk, Tk::Tile::Label, :TkLabel)
+Tk.__set_loaded_toplevel_aliases__('tkextlib/tile/tlabel.rb',
+ :Ttk, Tk::Tile::Label, :TkLabel)
diff --git a/jni/ruby/ext/tk/lib/tkextlib/tile/tlabelframe.rb b/jni/ruby/ext/tk/lib/tkextlib/tile/tlabelframe.rb
new file mode 100644
index 0000000..a34c985
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/tile/tlabelframe.rb
@@ -0,0 +1,38 @@
+#
+# tlabelframe widget
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+require 'tk'
+require 'tkextlib/tile.rb'
+
+module Tk
+ module Tile
+ class TLabelframe < Tk::Tile::TFrame
+ end
+ TLabelFrame = TLabelframe
+ Labelframe = TLabelframe
+ LabelFrame = TLabelframe
+ end
+end
+
+class Tk::Tile::TLabelframe < Tk::Tile::TFrame
+ include Tk::Tile::TileWidget
+
+ if Tk::Tile::USE_TTK_NAMESPACE
+ TkCommandNames = ['::ttk::labelframe'.freeze].freeze
+ else
+ TkCommandNames = ['::tlabelframe'.freeze].freeze
+ end
+ WidgetClassName = 'TLabelframe'.freeze
+ WidgetClassNames[WidgetClassName] ||= self
+
+ def self.style(*args)
+ [self::WidgetClassName, *(args.map!{|a| _get_eval_string(a)})].join('.')
+ end
+end
+
+#Tk.__set_toplevel_aliases__(:Ttk, Tk::Tile::Labelframe,
+# :TkLabelframe, :TkLabelFrame)
+Tk.__set_loaded_toplevel_aliases__('tkextlib/tile/tlabelframe.rb',
+ :Ttk, Tk::Tile::Labelframe,
+ :TkLabelframe, :TkLabelFrame)
diff --git a/jni/ruby/ext/tk/lib/tkextlib/tile/tmenubutton.rb b/jni/ruby/ext/tk/lib/tkextlib/tile/tmenubutton.rb
new file mode 100644
index 0000000..1cf553e
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/tile/tmenubutton.rb
@@ -0,0 +1,38 @@
+#
+# tmenubutton widget
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+require 'tk'
+require 'tkextlib/tile.rb'
+
+module Tk
+ module Tile
+ class TMenubutton < Tk::Menubutton
+ end
+ TMenuButton = TMenubutton
+ Menubutton = TMenubutton
+ MenuButton = TMenubutton
+ end
+end
+
+class Tk::Tile::TMenubutton < Tk::Menubutton
+ include Tk::Tile::TileWidget
+
+ if Tk::Tile::USE_TTK_NAMESPACE
+ TkCommandNames = ['::ttk::menubutton'.freeze].freeze
+ else
+ TkCommandNames = ['::tmenubutton'.freeze].freeze
+ end
+ WidgetClassName = 'TMenubutton'.freeze
+ WidgetClassNames[WidgetClassName] ||= self
+
+ def self.style(*args)
+ [self::WidgetClassName, *(args.map!{|a| _get_eval_string(a)})].join('.')
+ end
+end
+
+#Tk.__set_toplevel_aliases__(:Ttk, Tk::Tile::Menubutton,
+# :TkMenubutton, :TkMenuButton)
+Tk.__set_loaded_toplevel_aliases__('tkextlib/tile/tmenubutton.rb',
+ :Ttk, Tk::Tile::Menubutton,
+ :TkMenubutton, :TkMenuButton)
diff --git a/jni/ruby/ext/tk/lib/tkextlib/tile/tnotebook.rb b/jni/ruby/ext/tk/lib/tkextlib/tile/tnotebook.rb
new file mode 100644
index 0000000..9e27e2c
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/tile/tnotebook.rb
@@ -0,0 +1,147 @@
+#
+# tnotebook widget
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+require 'tk'
+require 'tkextlib/tile.rb'
+
+module Tk
+ module Tile
+ class TNotebook < TkWindow
+ end
+ Notebook = TNotebook
+ end
+end
+
+class Tk::Tile::TNotebook < TkWindow
+ ################################
+ include TkItemConfigMethod
+
+ def __item_cget_cmd(id)
+ [self.path, 'tab', id]
+ end
+ private :__item_cget_cmd
+
+ def __item_config_cmd(id)
+ [self.path, 'tab', id]
+ end
+ private :__item_config_cmd
+
+ def __item_listval_optkeys(id)
+ []
+ end
+ private :__item_listval_optkeys
+
+ def __item_methodcall_optkeys(id) # { key=>method, ... }
+ {}
+ end
+ private :__item_methodcall_optkeys
+
+ #alias tabcget itemcget
+ #alias tabcget_strict itemcget_strict
+ alias tabconfigure itemconfigure
+ alias tabconfiginfo itemconfiginfo
+ alias current_tabconfiginfo current_itemconfiginfo
+
+ def tabcget_tkstring(tagOrId, option)
+ tk_split_simplelist(tk_call_without_enc(*(__item_confinfo_cmd(tagid(tagOrId)) << "-#{option}")), false, true)[-1]
+ end
+ def tabcget_strict(tagOrId, option)
+ tabconfiginfo(tagOrId, option)[-1]
+ end
+ def tabcget(tagOrId, option)
+ unless TkItemConfigMethod.__IGNORE_UNKNOWN_CONFIGURE_OPTION__
+ tabcget_strict(tagOrId, option)
+ else
+ begin
+ tabcget_strict(tagOrId, option)
+ rescue => e
+ begin
+ if current_tabconfiginfo(tagOrId).has_key?(option.to_s)
+ # not tag error & option is known -> error on known option
+ fail e
+ else
+ # not tag error & option is unknown
+ nil
+ end
+ rescue
+ fail e # tag error
+ end
+ end
+ end
+ end
+ ################################
+
+ include Tk::Tile::TileWidget
+
+ if Tk::Tile::USE_TTK_NAMESPACE
+ TkCommandNames = ['::ttk::notebook'.freeze].freeze
+ else
+ TkCommandNames = ['::tnotebook'.freeze].freeze
+ end
+ WidgetClassName = 'TNotebook'.freeze
+ WidgetClassNames[WidgetClassName] ||= self
+
+ def self.style(*args)
+ [self::WidgetClassName, *(args.map!{|a| _get_eval_string(a)})].join('.')
+ end
+
+ def enable_traversal()
+ if Tk::Tile::TILE_SPEC_VERSION_ID < 5
+ tk_call_without_enc('::tile::enableNotebookTraversal', @path)
+ elsif Tk::Tile::TILE_SPEC_VERSION_ID < 7
+ tk_call_without_enc('::tile::notebook::enableTraversal', @path)
+ else
+ tk_call_without_enc('::ttk::notebook::enableTraversal', @path)
+ end
+ self
+ end
+
+ def add(child, keys=nil)
+ if keys && keys != None
+ tk_send('add', _epath(child), *hash_kv(keys))
+ else
+ tk_send('add', _epath(child))
+ end
+ self
+ end
+
+ def forget(idx)
+ tk_send('forget', idx)
+ self
+ end
+
+ def hide(idx)
+ tk_send('hide', idx)
+ end
+
+ def index(idx)
+ number(tk_send('index', idx))
+ end
+
+ def insert(idx, subwin, keys=nil)
+ if keys && keys != None
+ tk_send('insert', idx, subwin, *hash_kv(keys))
+ else
+ tk_send('insert', idx, subwin)
+ end
+ self
+ end
+
+ def select(idx)
+ tk_send('select', idx)
+ self
+ end
+
+ def selected
+ window(tk_send_without_enc('select'))
+ end
+
+ def tabs
+ list(tk_send('tabs'))
+ end
+end
+
+#Tk.__set_toplevel_aliases__(:Ttk, Tk::Tile::Notebook, :TkNotebook)
+Tk.__set_loaded_toplevel_aliases__('tkextlib/tile/tnotebook.rb',
+ :Ttk, Tk::Tile::Notebook, :TkNotebook)
diff --git a/jni/ruby/ext/tk/lib/tkextlib/tile/tpaned.rb b/jni/ruby/ext/tk/lib/tkextlib/tile/tpaned.rb
new file mode 100644
index 0000000..d6ad234
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/tile/tpaned.rb
@@ -0,0 +1,245 @@
+#
+# tpaned widget
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+require 'tk'
+require 'tkextlib/tile.rb'
+
+module Tk
+ module Tile
+ class TPaned < TkWindow
+ end
+ PanedWindow = Panedwindow = Paned = TPaned
+ end
+end
+
+class Tk::Tile::TPaned < TkWindow
+ include Tk::Tile::TileWidget
+
+ if Tk::Tile::USE_TTK_NAMESPACE
+ if Tk::Tile::TILE_SPEC_VERSION_ID < 8
+ TkCommandNames = ['::ttk::paned'.freeze].freeze
+ else
+ TkCommandNames = ['::ttk::panedwindow'.freeze].freeze
+ end
+ else
+ TkCommandNames = ['::tpaned'.freeze].freeze
+ end
+ WidgetClassName = 'TPaned'.freeze
+ WidgetClassNames[WidgetClassName] ||= self
+
+ def self.style(*args)
+ [self::WidgetClassName, *(args.map!{|a| _get_eval_string(a)})].join('.')
+ end
+
+ def add(*args)
+ keys = args.pop
+ fail ArgumentError, "no window in arguments" unless keys
+
+ if keys && keys.kind_of?(Hash)
+ fail ArgumentError, "no window in arguments" if args == []
+ opts = hash_kv(keys)
+ else
+ args.push(keys) if keys
+ opts = []
+ end
+
+ args.each{|win|
+ tk_send_without_enc('add', _epath(win), *opts)
+ }
+ self
+ end
+
+ def forget(pane)
+ pane = _epath(pane)
+ tk_send_without_enc('forget', pane)
+ self
+ end
+
+ def insert(pos, win, keys)
+ win = _epath(win)
+ tk_send_without_enc('insert', pos, win, *hash_kv(keys))
+ self
+ end
+
+ def panecget_tkstring(pane, slot)
+ pane = _epath(pane)
+ tk_send_without_enc('pane', pane, "-#{slot}")
+ end
+ alias pane_cget_tkstring panecget_tkstring
+
+ def panecget_strict(pane, slot)
+ pane = _epath(pane)
+ tk_tcl2ruby(tk_send_without_enc('pane', pane, "-#{slot}"))
+ end
+ alias pane_cget_strict panecget_strict
+
+ def panecget(pane, slot)
+ unless TkItemConfigMethod.__IGNORE_UNKNOWN_CONFIGURE_OPTION__
+ panecget_strict(pane, slot)
+ else
+ begin
+ panecget_strict(pane, slot)
+ rescue => e
+ begin
+ if current_paneconfiginfo(pane).has_key?(slot.to_s)
+ # not tag error & option is known -> error on known option
+ fail e
+ else
+ # not tag error & option is unknown
+ nil
+ end
+ rescue
+ fail e # tag error
+ end
+ end
+ end
+ end
+ alias pane_cget panecget
+
+ def paneconfigure(pane, key, value=nil)
+ pane = _epath(pane)
+ if key.kind_of? Hash
+ params = []
+ key.each{|k, v|
+ params.push("-#{k}")
+ # params.push((v.kind_of?(TkObject))? v.epath: v)
+ params.push(_epath(v))
+ }
+ tk_send_without_enc('pane', pane, *params)
+ else
+ # value = value.epath if value.kind_of?(TkObject)
+ value = _epath(value)
+ tk_send_without_enc('pane', pane, "-#{key}", value)
+ end
+ self
+ end
+ alias pane_config paneconfigure
+ alias pane_configure paneconfigure
+
+ def paneconfiginfo(win)
+ if TkComm::GET_CONFIGINFO_AS_ARRAY
+ win = _epath(win)
+ if key
+ conf = tk_split_list(tk_send_without_enc('pane', win, "-#{key}"))
+ conf[0] = conf[0][1..-1]
+ if conf[0] == 'hide'
+ conf[3] = bool(conf[3]) unless conf[3].empty?
+ conf[4] = bool(conf[4]) unless conf[4].empty?
+ end
+ conf
+ else
+ tk_split_simplelist(tk_send_without_enc('pane',
+ win)).collect{|conflist|
+ conf = tk_split_simplelist(conflist)
+ conf[0] = conf[0][1..-1]
+ if conf[3]
+ if conf[0] == 'hide'
+ conf[3] = bool(conf[3]) unless conf[3].empty?
+ elsif conf[3].index('{')
+ conf[3] = tk_split_list(conf[3])
+ else
+ conf[3] = tk_tcl2ruby(conf[3])
+ end
+ end
+ if conf[4]
+ if conf[0] == 'hide'
+ conf[4] = bool(conf[4]) unless conf[4].empty?
+ elsif conf[4].index('{')
+ conf[4] = tk_split_list(conf[4])
+ else
+ conf[4] = tk_tcl2ruby(conf[4])
+ end
+ end
+ conf[1] = conf[1][1..-1] if conf.size == 2 # alias info
+ conf
+ }
+ end
+ else # ! TkComm::GET_CONFIGINFO_AS_ARRAY
+ win = _epath(win)
+ if key
+ conf = tk_split_list(tk_send_without_enc('pane', win, "-#{key}"))
+ key = conf.shift[1..-1]
+ if key == 'hide'
+ conf[2] = bool(conf[2]) unless conf[2].empty?
+ conf[3] = bool(conf[3]) unless conf[3].empty?
+ end
+ { key => conf }
+ else
+ ret = {}
+ tk_split_simplelist(tk_send_without_enc('pane',
+ win)).each{|conflist|
+ conf = tk_split_simplelist(conflist)
+ key = conf.shift[1..-1]
+ if key
+ if key == 'hide'
+ conf[2] = bool(conf[2]) unless conf[2].empty?
+ elsif conf[2].index('{')
+ conf[2] = tk_split_list(conf[2])
+ else
+ conf[2] = tk_tcl2ruby(conf[2])
+ end
+ end
+ if conf[3]
+ if key == 'hide'
+ conf[3] = bool(conf[3]) unless conf[3].empty?
+ elsif conf[3].index('{')
+ conf[3] = tk_split_list(conf[3])
+ else
+ conf[3] = tk_tcl2ruby(conf[3])
+ end
+ end
+ if conf.size == 1
+ ret[key] = conf[0][1..-1] # alias info
+ else
+ ret[key] = conf
+ end
+ }
+ ret
+ end
+ end
+ end
+ alias pane_configinfo paneconfiginfo
+
+ def current_paneconfiginfo(win, key=nil)
+ if TkComm::GET_CONFIGINFO_AS_ARRAY
+ if key
+ conf = paneconfiginfo(win, key)
+ {conf[0] => conf[4]}
+ else
+ ret = {}
+ paneconfiginfo(win).each{|conf|
+ ret[conf[0]] = conf[4] if conf.size > 2
+ }
+ ret
+ end
+ else # ! TkComm::GET_CONFIGINFO_AS_ARRAY
+ ret = {}
+ paneconfiginfo(win, key).each{|k, conf|
+ ret[k] = conf[-1] if conf.kind_of?(Array)
+ }
+ ret
+ end
+ end
+ alias current_pane_configinfo current_paneconfiginfo
+
+ def panes
+ tk_split_simplelist(tk_send_without_enc('panes')).map{|w|
+ (obj = window(w))? obj: w
+ }
+ end
+
+ def identify(x, y)
+ num_or_nil(tk_send_without_enc('identify', x, y))
+ end
+
+ def sashpos(idx, newpos=None)
+ num_or_str(tk_send_without_enc('sashpos', idx, newpos))
+ end
+end
+
+#Tk.__set_toplevel_aliases__(:Ttk, Tk::Tile::Panedwindow,
+# :TkPanedwindow, :TkPanedWindow)
+Tk.__set_loaded_toplevel_aliases__('tkextlib/tile/tpaned.rb',
+ :Ttk, Tk::Tile::Panedwindow,
+ :TkPanedwindow, :TkPanedWindow)
diff --git a/jni/ruby/ext/tk/lib/tkextlib/tile/tprogressbar.rb b/jni/ruby/ext/tk/lib/tkextlib/tile/tprogressbar.rb
new file mode 100644
index 0000000..0c9d15e
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/tile/tprogressbar.rb
@@ -0,0 +1,57 @@
+#
+# tprogressbar widget
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+require 'tk'
+require 'tkextlib/tile.rb'
+
+module Tk
+ module Tile
+ class TProgressbar < TkWindow
+ end
+ Progressbar = TProgressbar
+ end
+end
+
+class Tk::Tile::TProgressbar
+ include Tk::Tile::TileWidget
+
+ if Tk::Tile::USE_TTK_NAMESPACE
+ TkCommandNames = ['::ttk::progressbar'.freeze].freeze
+ else
+ TkCommandNames = ['::tprogressbar'.freeze].freeze
+ end
+ WidgetClassName = 'TProgressbar'.freeze
+ WidgetClassNames[WidgetClassName] ||= self
+
+ def self.style(*args)
+ [self::WidgetClassName, *(args.map!{|a| _get_eval_string(a)})].join('.')
+ end
+
+ def step(amount=None)
+ tk_send_without_enc('step', amount).to_f
+ end
+ #def step=(amount)
+ # tk_send_without_enc('step', amount)
+ #end
+
+ def start(interval=None)
+ if Tk::Tile::TILE_SPEC_VERSION_ID < 5
+ tk_call_without_enc('::tile::progressbar::start', @path, interval)
+ else
+ tk_send_without_enc('start', interval)
+ end
+ end
+
+ def stop(amount=None)
+ if Tk::Tile::TILE_SPEC_VERSION_ID < 5
+ tk_call_without_enc('::tile::progressbar::stop', @path)
+ else
+ tk_send_without_enc('stop', amount)
+ end
+ end
+end
+
+#Tk.__set_toplevel_aliases__(:Ttk, Tk::Tile::Progressbar, :TkProgressbar)
+Tk.__set_loaded_toplevel_aliases__('tkextlib/tile/tprogressbar.rb',
+ :Ttk, Tk::Tile::Progressbar, :TkProgressbar)
diff --git a/jni/ruby/ext/tk/lib/tkextlib/tile/tradiobutton.rb b/jni/ruby/ext/tk/lib/tkextlib/tile/tradiobutton.rb
new file mode 100644
index 0000000..5dbf260
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/tile/tradiobutton.rb
@@ -0,0 +1,38 @@
+#
+# tradiobutton widget
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+require 'tk'
+require 'tkextlib/tile.rb'
+
+module Tk
+ module Tile
+ class TRadioButton < Tk::RadioButton
+ end
+ TRadiobutton = TRadioButton
+ RadioButton = TRadioButton
+ Radiobutton = TRadioButton
+ end
+end
+
+class Tk::Tile::TRadioButton < Tk::RadioButton
+ include Tk::Tile::TileWidget
+
+ if Tk::Tile::USE_TTK_NAMESPACE
+ TkCommandNames = ['::ttk::radiobutton'.freeze].freeze
+ else
+ TkCommandNames = ['::tradiobutton'.freeze].freeze
+ end
+ WidgetClassName = 'TRadiobutton'.freeze
+ WidgetClassNames[WidgetClassName] ||= self
+
+ def self.style(*args)
+ [self::WidgetClassName, *(args.map!{|a| _get_eval_string(a)})].join('.')
+ end
+end
+
+#Tk.__set_toplevel_aliases__(:Ttk, Tk::Tile::Radiobutton,
+# :TkRadiobutton, :TkRadioButton)
+Tk.__set_loaded_toplevel_aliases__('tkextlib/tile/tradiobutton.rb',
+ :Ttk, Tk::Tile::Radiobutton,
+ :TkRadiobutton, :TkRadioButton)
diff --git a/jni/ruby/ext/tk/lib/tkextlib/tile/treeview.rb b/jni/ruby/ext/tk/lib/tkextlib/tile/treeview.rb
new file mode 100644
index 0000000..85d7831
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/tile/treeview.rb
@@ -0,0 +1,1336 @@
+#
+# treeview widget
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+require 'tk'
+require 'tkextlib/tile.rb'
+
+module Tk
+ module Tile
+ class Treeview < TkWindow
+ end
+ end
+end
+
+module Tk::Tile::TreeviewConfig
+ include TkItemConfigMethod
+
+ def __item_configinfo_struct(id)
+ # maybe need to override
+ {:key=>0, :alias=>nil, :db_name=>nil, :db_class=>nil,
+ :default_value=>nil, :current_value=>1}
+ end
+ private :__item_configinfo_struct
+
+ def __itemconfiginfo_core(tagOrId, slot = nil)
+ if TkComm::GET_CONFIGINFO_AS_ARRAY
+ if (slot && slot.to_s =~ /^(|latin|ascii|kanji)(#{__item_font_optkeys(tagid(tagOrId)).join('|')})$/)
+ fontkey = $2
+ return [slot.to_s, tagfontobj(tagid(tagOrId), fontkey)]
+ else
+ if slot
+ slot = slot.to_s
+
+ alias_name, real_name = __item_optkey_aliases(tagid(tagOrId)).find{|k, v| k.to_s == slot}
+ if real_name
+ slot = real_name.to_s
+ end
+
+ case slot
+ when /^(#{__tile_specific_item_optkeys(tagid(tagOrId)).join('|')})$/
+ begin
+ # On tile-0.7.{2-8}, 'state' options has no '-' at its head.
+ val = tk_call(*(__item_confinfo_cmd(tagid(tagOrId)) << slot))
+ rescue
+ # Maybe, 'state' option has '-' in future.
+ val = tk_call(*(__item_confinfo_cmd(tagid(tagOrId)) << "-#{slot}"))
+ end
+ return [slot, val]
+
+ when /^(#{__item_val2ruby_optkeys(tagid(tagOrId)).keys.join('|')})$/
+ method = _symbolkey2str(__item_val2ruby_optkeys(tagid(tagOrId)))[slot]
+ optval = tk_call_without_enc(*(__item_confinfo_cmd(tagid(tagOrId)) << "-#{slot}"))
+ begin
+ val = method.call(tagOrId, optval)
+ rescue => e
+ warn("Warning:: #{e.message} (when #{method}lcall(#{tagOrId.inspect}, #{optval.inspect})") if $DEBUG
+ val = optval
+ end
+ return [slot, val]
+
+ when /^(#{__item_methodcall_optkeys(tagid(tagOrId)).keys.join('|')})$/
+ method = _symbolkey2str(__item_methodcall_optkeys(tagid(tagOrId)))[slot]
+ return [slot, self.__send__(method, tagOrId)]
+
+ when /^(#{__item_numval_optkeys(tagid(tagOrId)).join('|')})$/
+ begin
+ val = number(tk_call_without_enc(*(__item_confinfo_cmd(tagid(tagOrId)) << "-#{slot}")))
+ rescue
+ val = nil
+ end
+ return [slot, val]
+
+ when /^(#{__item_numstrval_optkeys(tagid(tagOrId)).join('|')})$/
+ val = num_or_str(tk_call_without_enc(*(__item_confinfo_cmd(tagid(tagOrId)) << "-#{slot}")))
+ return [slot, val]
+
+ when /^(#{__item_boolval_optkeys(tagid(tagOrId)).join('|')})$/
+ begin
+ val = bool(tk_call_without_enc(*(__item_confinfo_cmd(tagid(tagOrId)) << "-#{slot}")))
+ rescue
+ val = nil
+ end
+ return [slot, val]
+
+ when /^(#{__item_listval_optkeys(tagid(tagOrId)).join('|')})$/
+ val = simplelist(tk_call_without_enc(*(__item_confinfo_cmd(tagid(tagOrId)) << "-#{slot}")))
+ return [slot, val]
+
+ when /^(#{__item_numlistval_optkeys(tagid(tagOrId)).join('|')})$/
+ val = tk_call_without_enc(*(__item_confinfo_cmd(tagid(tagOrId)) << "-#{slot}"))
+ if val =~ /^[0-9]/
+ return [slot, list(val)]
+ else
+ return [slot, val]
+ end
+
+ when /^(#{__item_strval_optkeys(tagid(tagOrId)).join('|')})$/
+ val = tk_call_without_enc(*(__item_confinfo_cmd(tagid(tagOrId)) << "-#{slot}"))
+ return [slot, val]
+
+ when /^(#{__item_tkvariable_optkeys(tagid(tagOrId)).join('|')})$/
+ val = tk_call_without_enc(*(__item_confinfo_cmd(tagid(tagOrId)) << "-#{slot}"))
+ if val.empty?
+ return [slot, nil]
+ else
+ return [slot, TkVarAccess.new(val)]
+ end
+
+ else
+ val = tk_call_without_enc(*(__item_confinfo_cmd(tagid(tagOrId)) << "-#{slot}"))
+ if val.index('{')
+ return [slot, tk_split_list(val)]
+ else
+ return [slot, tk_tcl2ruby(val)]
+ end
+ end
+
+ else # ! slot
+ ret = Hash[*(tk_split_simplelist(tk_call_without_enc(*(__item_confinfo_cmd(tagid(tagOrId)))), false, false))].to_a.collect{|conf|
+ conf[0] = conf[0][1..-1] if conf[0][0] == ?-
+ case conf[0]
+ when /^(#{__item_val2ruby_optkeys(tagid(tagOrId)).keys.join('|')})$/
+ method = _symbolkey2str(__item_val2ruby_optkeys(tagid(tagOrId)))[conf[0]]
+ optval = conf[1]
+ begin
+ val = method.call(tagOrId, optval)
+ rescue => e
+ warn("Warning:: #{e.message} (when #{method}.call(#{tagOrId.inspect}, #{optval.inspect})") if $DEBUG
+ val = optval
+ end
+ conf[1] = val
+
+ when /^(#{__item_strval_optkeys(tagid(tagOrId)).join('|')})$/
+ # do nothing
+
+ when /^(#{__item_numval_optkeys(tagid(tagOrId)).join('|')})$/
+ begin
+ conf[1] = number(conf[1])
+ rescue
+ conf[1] = nil
+ end
+
+ when /^(#{__item_numstrval_optkeys(tagid(tagOrId)).join('|')})$/
+ conf[1] = num_or_str(conf[1])
+
+ when /^(#{__item_boolval_optkeys(tagid(tagOrId)).join('|')})$/
+ begin
+ conf[1] = bool(conf[1])
+ rescue
+ conf[1] = nil
+ end
+
+ when /^(#{__item_listval_optkeys(tagid(tagOrId)).join('|')})$/
+ conf[1] = simplelist(conf[1])
+
+ when /^(#{__item_numlistval_optkeys(tagid(tagOrId)).join('|')})$/
+ if conf[1] =~ /^[0-9]/
+ conf[1] = list(conf[1])
+ end
+
+ when /^(#{__item_tkvariable_optkeys(tagid(tagOrId)).join('|')})$/
+ if conf[1].empty?
+ conf[1] = nil
+ else
+ conf[1] = TkVarAccess.new(conf[1])
+ end
+
+ else
+ if conf[1].index('{')
+ conf[1] = tk_split_list(conf[1])
+ else
+ conf[1] = tk_tcl2ruby(conf[1])
+ end
+ end
+
+ conf
+ }
+
+ __item_font_optkeys(tagid(tagOrId)).each{|optkey|
+ optkey = optkey.to_s
+ fontconf = ret.assoc(optkey)
+ if fontconf
+ ret.delete_if{|inf| inf[0] =~ /^(|latin|ascii|kanji)#{optkey}$/}
+ fontconf[1] = tagfontobj(tagid(tagOrId), optkey)
+ ret.push(fontconf)
+ end
+ }
+
+ __item_methodcall_optkeys(tagid(tagOrId)).each{|optkey, method|
+ ret << [optkey.to_s, self.__send__(method, tagOrId)]
+ }
+
+ ret
+ end
+ end
+
+ else # ! TkComm::GET_CONFIGINFO_AS_ARRAY
+ if (slot && slot.to_s =~ /^(|latin|ascii|kanji)(#{__item_font_optkeys(tagid(tagOrId)).join('|')})$/)
+ fontkey = $2
+ return {slot.to_s => tagfontobj(tagid(tagOrId), fontkey)}
+ else
+ if slot
+ slot = slot.to_s
+
+ alias_name, real_name = __item_optkey_aliases(tagid(tagOrId)).find{|k, v| k.to_s == slot}
+ if real_name
+ slot = real_name.to_s
+ end
+
+ case slot
+ when /^(#{__tile_specific_item_optkeys(tagid(tagOrId)).join('|')})$/
+ begin
+ # On tile-0.7.{2-8}, 'state' option has no '-' at its head.
+ val = tk_call(*(__item_confinfo_cmd(tagid(tagOrId)) << slot))
+ rescue
+ # Maybe, 'state' option has '-' in future.
+ val = tk_call(*(__item_confinfo_cmd(tagid(tagOrId)) << "-#{slot}"))
+ end
+ return {slot => val}
+
+ when /^(#{__item_val2ruby_optkeys(tagid(tagOrId)).keys.join('|')})$/
+ method = _symbolkey2str(__item_val2ruby_optkeys(tagid(tagOrId)))[slot]
+ optval = tk_call_without_enc(*(__item_confinfo_cmd(tagid(tagOrId)) << "-#{slot}"))
+ begin
+ val = method.call(tagOrId, optval)
+ rescue => e
+ warn("Warning:: #{e.message} (when #{method}lcall(#{tagOrId.inspect}, #{optval.inspect})") if $DEBUG
+ val = optval
+ end
+ return {slot => val}
+
+ when /^(#{__item_methodcall_optkeys(tagid(tagOrId)).keys.join('|')})$/
+ method = _symbolkey2str(__item_methodcall_optkeys(tagid(tagOrId)))[slot]
+ return {slot => self.__send__(method, tagOrId)}
+
+ when /^(#{__item_numval_optkeys(tagid(tagOrId)).join('|')})$/
+ begin
+ val = number(tk_call_without_enc(*(__item_confinfo_cmd(tagid(tagOrId)) << "-#{slot}")))
+ rescue
+ val = nil
+ end
+ return {slot => val}
+
+ when /^(#{__item_numstrval_optkeys(tagid(tagOrId)).join('|')})$/
+ val = num_or_str(tk_call_without_enc(*(__item_confinfo_cmd(tagid(tagOrId)) << "-#{slot}")))
+ return {slot => val}
+
+ when /^(#{__item_boolval_optkeys(tagid(tagOrId)).join('|')})$/
+ begin
+ val = bool(tk_call_without_enc(*(__item_confinfo_cmd(tagid(tagOrId)) << "-#{slot}")))
+ rescue
+ val = nil
+ end
+ return {slot => val}
+
+ when /^(#{__item_listval_optkeys(tagid(tagOrId)).join('|')})$/
+ val = simplelist(tk_call_without_enc(*(__item_confinfo_cmd(tagid(tagOrId)) << "-#{slot}")))
+ return {slot => val}
+
+ when /^(#{__item_numlistval_optkeys(tagid(tagOrId)).join('|')})$/
+ val = tk_call_without_enc(*(__item_confinfo_cmd(tagid(tagOrId)) << "-#{slot}"))
+ if val =~ /^[0-9]/
+ return {slot => list(val)}
+ else
+ return {slot => val}
+ end
+
+ when /^(#{__item_strval_optkeys(tagid(tagOrId)).join('|')})$/
+ val = tk_call_without_enc(*(__item_confinfo_cmd(tagid(tagOrId)) << "-#{slot}"))
+ return {slot => val}
+
+ when /^(#{__item_tkvariable_optkeys(tagid(tagOrId)).join('|')})$/
+ val = tk_call_without_enc(*(__item_confinfo_cmd(tagid(tagOrId)) << "-#{slot}"))
+ if val.empty?
+ return {slot => nil}
+ else
+ return {slot => TkVarAccess.new(val)}
+ end
+
+ else
+ val = tk_call_without_enc(*(__item_confinfo_cmd(tagid(tagOrId)) << "-#{slot}"))
+ if val.index('{')
+ return {slot => tk_split_list(val)}
+ else
+ return {slot => tk_tcl2ruby(val)}
+ end
+ end
+
+ else # ! slot
+ ret = {}
+ ret = Hash[*(tk_split_simplelist(tk_call_without_enc(*(__item_confinfo_cmd(tagid(tagOrId)))), false, false))].to_a.collect{|conf|
+ conf[0] = conf[0][1..-1] if conf[0][0] == ?-
+
+ optkey = conf[0]
+ case optkey
+ when /^(#{__item_val2ruby_optkeys(tagid(tagOrId)).keys.join('|')})$/
+ method = _symbolkey2str(__item_val2ruby_optkeys(tagid(tagOrId)))[optkey]
+ optval = conf[1]
+ begin
+ val = method.call(tagOrId, optval)
+ rescue => e
+ warn("Warning:: #{e.message} (when #{method}.call(#{tagOrId.inspect}, #{optval.inspect})") if $DEBUG
+ val = optval
+ end
+ conf[1] = val
+
+ when /^(#{__item_strval_optkeys(tagid(tagOrId)).join('|')})$/
+ # do nothing
+
+ when /^(#{__item_numval_optkeys(tagid(tagOrId)).join('|')})$/
+ begin
+ conf[1] = number(conf[1])
+ rescue
+ conf[1] = nil
+ end
+
+ when /^(#{__item_numstrval_optkeys(tagid(tagOrId)).join('|')})$/
+ conf[1] = num_or_str(conf[1])
+
+ when /^(#{__item_boolval_optkeys(tagid(tagOrId)).join('|')})$/
+ begin
+ conf[1] = bool(conf[1])
+ rescue
+ conf[1] = nil
+ end
+
+ when /^(#{__item_listval_optkeys(tagid(tagOrId)).join('|')})$/
+ conf[1] = simplelist(conf[1])
+
+ when /^(#{__item_numlistval_optkeys(tagid(tagOrId)).join('|')})$/
+ if conf[1] =~ /^[0-9]/
+ conf[1] = list(conf[1])
+ end
+
+ when /^(#{__item_tkvariable_optkeys(tagid(tagOrId)).join('|')})$/
+ if conf[1].empty?
+ conf[1] = nil
+ else
+ conf[1] = TkVarAccess.new(conf[1])
+ end
+
+ else
+ if conf[1].index('{')
+ return [slot, tk_split_list(conf[1])]
+ else
+ return [slot, tk_tcl2ruby(conf[1])]
+ end
+ end
+
+ ret[conf[0]] = conf[1]
+ }
+
+ __item_font_optkeys(tagid(tagOrId)).each{|optkey|
+ optkey = optkey.to_s
+ fontconf = ret[optkey]
+ if fontconf.kind_of?(Array)
+ ret.delete(optkey)
+ ret.delete('latin' << optkey)
+ ret.delete('ascii' << optkey)
+ ret.delete('kanji' << optkey)
+ fontconf[1] = tagfontobj(tagid(tagOrId), optkey)
+ ret[optkey] = fontconf
+ end
+ }
+
+ __item_methodcall_optkeys(tagid(tagOrId)).each{|optkey, method|
+ ret[optkey.to_s] = self.__send__(method, tagOrId)
+ }
+
+ ret
+ end
+ end
+ end
+ end
+
+ ###################
+
+ def __item_cget_cmd(id)
+ [self.path, *id]
+ end
+ private :__item_cget_cmd
+
+ def __item_config_cmd(id)
+ [self.path, *id]
+ end
+ private :__item_config_cmd
+
+ def __item_numstrval_optkeys(id)
+ case id[0]
+ when :item, 'item'
+ ['width']
+ when :column, 'column'
+ super(id[1]) + ['minwidth']
+ when :tag, 'tag'
+ super(id[1])
+ when :heading, 'heading'
+ super(id[1])
+ else
+ super(id[1])
+ end
+ end
+ private :__item_numstrval_optkeys
+
+ def __item_strval_optkeys(id)
+ case id[0]
+ when :item, 'item'
+ super(id) + ['id']
+ when :column, 'column'
+ super(id[1])
+ when :tag, 'tag'
+ super(id[1])
+ when :heading, 'heading'
+ super(id[1])
+ else
+ super(id[1])
+ end
+ end
+ private :__item_strval_optkeys
+
+ def __item_boolval_optkeys(id)
+ case id[0]
+ when :item, 'item'
+ ['open']
+ when :column, 'column'
+ super(id[1]) + ['stretch']
+ when :tag, 'tag'
+ super(id[1])
+ when :heading, 'heading'
+ super(id[1])
+ end
+ end
+ private :__item_boolval_optkeys
+
+ def __item_listval_optkeys(id)
+ case id[0]
+ when :item, 'item'
+ ['values']
+ when :column, 'column'
+ []
+ when :heading, 'heading'
+ []
+ else
+ []
+ end
+ end
+ private :__item_listval_optkeys
+
+ def __item_val2ruby_optkeys(id)
+ case id[0]
+ when :item, 'item'
+ {
+ 'tags'=>proc{|arg_id, val|
+ simplelist(val).collect{|tag|
+ Tk::Tile::Treeview::Tag.id2obj(self, tag)
+ }
+ }
+ }
+ when :column, 'column'
+ {}
+ when :heading, 'heading'
+ {}
+ else
+ {}
+ end
+ end
+ private :__item_val2ruby_optkeys
+
+ def __tile_specific_item_optkeys(id)
+ case id[0]
+ when :item, 'item'
+ []
+ when :column, 'column'
+ []
+ when :heading, 'heading'
+ ['state'] # On tile-0.7.{2-8}, 'state' options has no '-' at its head.
+ else
+ []
+ end
+ end
+ private :__item_val2ruby_optkeys
+
+ def itemconfiginfo(tagOrId, slot = nil)
+ __itemconfiginfo_core(tagOrId, slot)
+ end
+
+ def current_itemconfiginfo(tagOrId, slot = nil)
+ if TkComm::GET_CONFIGINFO_AS_ARRAY
+ if slot
+ org_slot = slot
+ begin
+ conf = __itemconfiginfo_core(tagOrId, slot)
+ if ( ! __item_configinfo_struct(tagid(tagOrId))[:alias] \
+ || conf.size > __item_configinfo_struct(tagid(tagOrId))[:alias] + 1 )
+ return {conf[0] => conf[-1]}
+ end
+ slot = conf[__item_configinfo_struct(tagid(tagOrId))[:alias]]
+ end while(org_slot != slot)
+ fail RuntimeError,
+ "there is a configure alias loop about '#{org_slot}'"
+ else
+ ret = {}
+ __itemconfiginfo_core(tagOrId).each{|conf|
+ if ( ! __item_configinfo_struct(tagid(tagOrId))[:alias] \
+ || conf.size > __item_configinfo_struct(tagid(tagOrId))[:alias] + 1 )
+ ret[conf[0]] = conf[-1]
+ end
+ }
+ ret
+ end
+ else # ! TkComm::GET_CONFIGINFO_AS_ARRAY
+ ret = {}
+ __itemconfiginfo_core(tagOrId, slot).each{|key, conf|
+ ret[key] = conf[-1] if conf.kind_of?(Array)
+ }
+ ret
+ end
+ end
+
+ alias __itemcget_tkstring itemcget_tkstring
+ alias __itemcget itemcget
+ alias __itemcget_strict itemcget_strict
+ alias __itemconfigure itemconfigure
+ alias __itemconfiginfo itemconfiginfo
+ alias __current_itemconfiginfo current_itemconfiginfo
+
+ private :__itemcget_tkstring, :__itemcget, :__itemcget_strict
+ private :__itemconfigure, :__itemconfiginfo, :__current_itemconfiginfo
+
+ # Treeview Item
+ def itemcget_tkstring(tagOrId, option)
+ __itemcget_tkstring([:item, tagOrId], option)
+ end
+ def itemcget(tagOrId, option)
+ __itemcget([:item, tagOrId], option)
+ end
+ def itemcget_strict(tagOrId, option)
+ __itemcget_strict([:item, tagOrId], option)
+ end
+ def itemconfigure(tagOrId, slot, value=None)
+ __itemconfigure([:item, tagOrId], slot, value)
+ end
+ def itemconfiginfo(tagOrId, slot=nil)
+ __itemconfiginfo([:item, tagOrId], slot)
+ end
+ def current_itemconfiginfo(tagOrId, slot=nil)
+ __current_itemconfiginfo([:item, tagOrId], slot)
+ end
+
+ # Treeview Column
+ def columncget_tkstring(tagOrId, option)
+ __itemcget_tkstring([:column, tagOrId], option)
+ end
+ def columncget(tagOrId, option)
+ __itemcget([:column, tagOrId], option)
+ end
+ def columncget_strict(tagOrId, option)
+ __itemcget_strict([:column, tagOrId], option)
+ end
+ def columnconfigure(tagOrId, slot, value=None)
+ __itemconfigure([:column, tagOrId], slot, value)
+ end
+ def columnconfiginfo(tagOrId, slot=nil)
+ __itemconfiginfo([:column, tagOrId], slot)
+ end
+ def current_columnconfiginfo(tagOrId, slot=nil)
+ __current_itemconfiginfo([:column, tagOrId], slot)
+ end
+ alias column_cget_tkstring columncget_tkstring
+ alias column_cget columncget
+ alias column_cget_strict columncget_strict
+ alias column_configure columnconfigure
+ alias column_configinfo columnconfiginfo
+ alias current_column_configinfo current_columnconfiginfo
+
+ # Treeview Heading
+ def headingcget_tkstring(tagOrId, option)
+ if __tile_specific_item_optkeys([:heading, tagOrId]).index(option.to_s)
+ begin
+ # On tile-0.7.{2-8}, 'state' options has no '-' at its head.
+ tk_call(*(__item_cget_cmd([:heading, tagOrId]) << option.to_s))
+ rescue
+ # Maybe, 'state' option has '-' in future.
+ tk_call(*(__item_cget_cmd([:heading, tagOrId]) << "-#{option}"))
+ end
+ else
+ __itemcget_tkstring([:heading, tagOrId], option)
+ end
+ end
+ def headingcget_strict(tagOrId, option)
+ if __tile_specific_item_optkeys([:heading, tagOrId]).index(option.to_s)
+ begin
+ # On tile-0.7.{2-8}, 'state' options has no '-' at its head.
+ tk_call(*(__item_cget_cmd([:heading, tagOrId]) << option.to_s))
+ rescue
+ # Maybe, 'state' option has '-' in future.
+ tk_call(*(__item_cget_cmd([:heading, tagOrId]) << "-#{option}"))
+ end
+ else
+ __itemcget_strict([:heading, tagOrId], option)
+ end
+ end
+ def headingcget(tagOrId, option)
+ unless TkItemConfigMethod.__IGNORE_UNKNOWN_CONFIGURE_OPTION__
+ headingcget_strict(tagOrId, option)
+ else
+ begin
+ headingcget_strict(tagOrId, option)
+ rescue => e
+ begin
+ if current_headingconfiginfo(tagOrId).has_key?(option.to_s)
+ # not tag error & option is known -> error on known option
+ fail e
+ else
+ # not tag error & option is unknown
+ nil
+ end
+ rescue
+ fail e # tag error
+ end
+ end
+ end
+ end
+ def headingconfigure(tagOrId, slot, value=None)
+ if slot.kind_of?(Hash)
+ slot = _symbolkey2str(slot)
+ sp_kv = []
+ __tile_specific_item_optkeys([:heading, tagOrId]).each{|k|
+ sp_kv << k << _get_eval_string(slot.delete(k)) if slot.has_key?(k)
+ }
+ tk_call(*(__item_config_cmd([:heading, tagOrId]).concat(sp_kv)))
+ tk_call(*(__item_config_cmd([:heading, tagOrId]).concat(hash_kv(slot))))
+ elsif __tile_specific_item_optkeys([:heading, tagOrId]).index(slot.to_s)
+ begin
+ # On tile-0.7.{2-8}, 'state' options has no '-' at its head.
+ tk_call(*(__item_cget_cmd([:heading, tagOrId]) << slot.to_s << value))
+ rescue
+ # Maybe, 'state' option has '-' in future.
+ tk_call(*(__item_cget_cmd([:heading, tagOrId]) << "-#{slot}" << value))
+ end
+ else
+ __itemconfigure([:heading, tagOrId], slot, value)
+ end
+ self
+ end
+ def headingconfiginfo(tagOrId, slot=nil)
+ __itemconfiginfo([:heading, tagOrId], slot)
+ end
+ def current_headingconfiginfo(tagOrId, slot=nil)
+ __current_itemconfiginfo([:heading, tagOrId], slot)
+ end
+ alias heading_cget_tkstring headingcget_tkstring
+ alias heading_cget headingcget
+ alias heading_cget_strict headingcget_strict
+ alias heading_configure headingconfigure
+ alias heading_configinfo headingconfiginfo
+ alias current_heading_configinfo current_headingconfiginfo
+
+ # Treeview Tag
+ def tagcget_tkstring(tagOrId, option)
+ __itemcget_tkstring([:tag, :configure, tagOrId], option)
+ end
+ def tagcget(tagOrId, option)
+ __itemcget([:tag, :configure, tagOrId], option)
+ end
+ def tagcget_strict(tagOrId, option)
+ __itemcget_strict([:tag, :configure, tagOrId], option)
+ end
+ def tagconfigure(tagOrId, slot, value=None)
+ __itemconfigure([:tag, :configure, tagOrId], slot, value)
+ end
+ def tagconfiginfo(tagOrId, slot=nil)
+ __itemconfiginfo([:tag, :configure, tagOrId], slot)
+ end
+ def current_tagconfiginfo(tagOrId, slot=nil)
+ __current_itemconfiginfo([:tag, :configure, tagOrId], slot)
+ end
+ alias tag_cget_tkstring tagcget_tkstring
+ alias tag_cget tagcget
+ alias tag_cget_strict tagcget_strict
+ alias tag_configure tagconfigure
+ alias tag_configinfo tagconfiginfo
+ alias current_tag_configinfo current_tagconfiginfo
+end
+
+########################
+
+class Tk::Tile::Treeview::Item < TkObject
+ ItemID_TBL = TkCore::INTERP.create_table
+
+ TkCore::INTERP.init_ip_env{
+ Tk::Tile::Treeview::Item::ItemID_TBL.mutex.synchronize{
+ Tk::Tile::Treeview::Item::ItemID_TBL.clear
+ }
+ }
+
+ def self.id2obj(tree, id)
+ tpath = tree.path
+ Tk::Tile::Treeview::Item::ItemID_TBL.mutex.synchronize{
+ if Tk::Tile::Treeview::Item::ItemID_TBL[tpath]
+ (Tk::Tile::Treeview::Item::ItemID_TBL[tpath][id])? \
+ Tk::Tile::Treeview::Item::ItemID_TBL[tpath][id]: id
+ else
+ id
+ end
+ }
+ end
+
+ def self.assign(tree, id)
+ tpath = tree.path
+ obj = nil
+ Tk::Tile::Treeview::Item::ItemID_TBL.mutex.synchronize{
+ if Tk::Tile::Treeview::Item::ItemID_TBL[tpath] &&
+ Tk::Tile::Treeview::Item::ItemID_TBL[tpath][id]
+ return Tk::Tile::Treeview::Item::ItemID_TBL[tpath][id]
+ end
+
+ obj = self.allocate
+ obj.instance_eval{
+ @parent = @t = tree
+ @tpath = tpath
+ @path = @id = id
+ }
+ Tk::Tile::Treeview::Item::ItemID_TBL[tpath] ||= {}
+ Tk::Tile::Treeview::Item::ItemID_TBL[tpath][id] = obj
+ }
+ obj
+ end
+
+ def _insert_item(tree, parent_item, idx, keys={})
+ keys = _symbolkey2str(keys)
+ id = keys.delete('id')
+ if id
+ num_or_str(tk_call(tree, 'insert',
+ parent_item, idx, '-id', id, *hash_kv(keys)))
+ else
+ num_or_str(tk_call(tree, 'insert', parent_item, idx, *hash_kv(keys)))
+ end
+ end
+ private :_insert_item
+
+ def initialize(tree, parent_item = '', idx = 'end', keys = {})
+ if parent_item.kind_of?(Hash)
+ keys = parent_item
+ idx = 'end'
+ parent_item = ''
+ elsif idx.kind_of?(Hash)
+ keys = idx
+ idx = 'end'
+ end
+
+ @parent = @t = tree
+ @tpath = tree.path
+ @path = @id = _insert_item(@t, parent_item, idx, keys)
+ Tk::Tile::Treeview::Item::ItemID_TBL.mutex.synchronize{
+ ItemID_TBL[@tpath] = {} unless ItemID_TBL[@tpath]
+ ItemID_TBL[@tpath][@id] = self
+ }
+ end
+ def id
+ @id
+ end
+
+ def cget_tkstring(option)
+ @t.itemcget_tkstring(@id, option)
+ end
+ def cget(option)
+ @t.itemcget(@id, option)
+ end
+ def cget_strict(option)
+ @t.itemcget_strict(@id, option)
+ end
+
+ def configure(key, value=None)
+ @t.itemconfigure(@id, key, value)
+ self
+ end
+
+ def configinfo(key=nil)
+ @t.itemconfiginfo(@id, key)
+ end
+
+ def current_configinfo(key=nil)
+ @t.current_itemconfiginfo(@id, key)
+ end
+
+ def open?
+ cget('open')
+ end
+ def open
+ configure('open', true)
+ self
+ end
+ def close
+ configure('open', false)
+ self
+ end
+
+ def tag_has?(tag)
+ @t.tag_has?(tag, @id)
+ end
+ alias has_tag? tag_has?
+
+ def bbox(column=None)
+ @t.bbox(@id, column)
+ end
+
+ def children
+ @t.children(@id)
+ end
+ def set_children(*items)
+ @t.set_children(@id, *items)
+ self
+ end
+
+ def delete
+ @t.delete(@id)
+ self
+ end
+
+ def detach
+ @t.detach(@id)
+ self
+ end
+
+ def exist?
+ @t.exist?(@id)
+ end
+
+ def focus
+ @t.focus_item(@id)
+ end
+
+ def index
+ @t.index(@id)
+ end
+
+ def insert(idx='end', keys={})
+ @t.insert(@id, idx, keys)
+ end
+
+ def move(parent, idx)
+ @t.move(@id, parent, idx)
+ self
+ end
+
+ def next_item
+ @t.next_item(@id)
+ end
+
+ def parent_item
+ @t.parent_item(@id)
+ end
+
+ def prev_item
+ @t.prev_item(@id)
+ end
+
+ def see
+ @t.see(@id)
+ self
+ end
+
+ def selection_add
+ @t.selection_add(@id)
+ self
+ end
+
+ def selection_remove
+ @t.selection_remove(@id)
+ self
+ end
+
+ def selection_set
+ @t.selection_set(@id)
+ self
+ end
+
+ def selection_toggle
+ @t.selection_toggle(@id)
+ self
+ end
+
+ def get_directory
+ @t.get_directory(@id)
+ end
+ alias get_dictionary get_directory
+
+ def get(col)
+ @t.get(@id, col)
+ end
+
+ def set(col, value)
+ @t.set(@id, col, value)
+ end
+end
+
+########################
+
+class Tk::Tile::Treeview::Root < Tk::Tile::Treeview::Item
+ def self.new(tree, keys = {})
+ tpath = tree.path
+ obj = nil
+ Tk::Tile::Treeview::Item::ItemID_TBL.mutex.synchronize{
+ if Tk::Tile::Treeview::Item::ItemID_TBL[tpath] &&
+ Tk::Tile::Treeview::Item::ItemID_TBL[tpath]['']
+ obj = Tk::Tile::Treeview::Item::ItemID_TBL[tpath]['']
+ else
+ #super(tree, keys)
+ (obj = self.allocate).instance_eval{
+ @parent = @t = tree
+ @tpath = tree.path
+ @path = @id = ''
+ Tk::Tile::Treeview::Item::ItemID_TBL[@tpath] ||= {}
+ Tk::Tile::Treeview::Item::ItemID_TBL[@tpath][@id] = self
+ }
+ end
+ }
+ obj.configure(keys) if keys && ! keys.empty?
+ obj
+ end
+
+ def initialize(tree, keys = {})
+ # dummy:: not called by 'new' method
+ @parent = @t = tree
+ @tpath = tree.path
+ @path = @id = ''
+ Tk::Tile::Treeview::Item::ItemID_TBL.mutex.synchronize{
+ Tk::Tile::Treeview::Item::ItemID_TBL[@tpath] ||= {}
+ Tk::Tile::Treeview::Item::ItemID_TBL[@tpath][@id] = self
+ }
+ end
+end
+
+########################
+
+class Tk::Tile::Treeview::Tag < TkObject
+ include TkTreatTagFont
+
+ TagID_TBL = TkCore::INTERP.create_table
+
+ (Tag_ID = ['tile_treeview_tag'.freeze, TkUtil.untrust('00000')]).instance_eval{
+ @mutex = Mutex.new
+ def mutex; @mutex; end
+ freeze
+ }
+
+ TkCore::INTERP.init_ip_env{
+ Tk::Tile::Treeview::Tag::TagID_TBL.mutex.synchronize{
+ Tk::Tile::Treeview::Tag::TagID_TBL.clear
+ }
+ }
+
+ def self.id2obj(tree, id)
+ tpath = tree.path
+ Tk::Tile::Treeview::Tag::TagID_TBL.mutex.synchronize{
+ if Tk::Tile::Treeview::Tag::TagID_TBL[tpath]
+ (Tk::Tile::Treeview::Tag::TagID_TBL[tpath][id])? \
+ Tk::Tile::Treeview::Tag::TagID_TBL[tpath][id]: id
+ else
+ id
+ end
+ }
+ end
+
+ def initialize(tree, keys=nil)
+ @parent = @t = tree
+ @tpath = tree.path
+ Tag_ID.mutex.synchronize{
+ @path = @id = Tag_ID.join(TkCore::INTERP._ip_id_)
+ Tag_ID[1].succ!
+ }
+ TagID_TBL.mutex.synchronize{
+ TagID_TBL[@tpath] = {} unless TagID_TBL[@tpath]
+ TagID_TBL[@tpath][@id] = self
+ }
+ if keys && keys != None
+ tk_call_without_enc(@tpath, 'tag', 'configure', @id, *hash_kv(keys,true))
+ end
+ end
+ def id
+ @id
+ end
+
+ def tag_has?(item)
+ @t.tag_has?(@id, item)
+ end
+ alias added? tag_has?
+
+ def tag_has
+ @t.tag_has(@id)
+ end
+
+ def add(*items)
+ @t.tag_add(@id, *items)
+ end
+
+ def remove(*items)
+ @t.tag_remove(@id, *items)
+ end
+
+ def bind(seq, *args)
+ if TkComm._callback_entry?(args[0]) || !block_given?
+ cmd = args.shift
+ else
+ cmd = Proc.new
+ end
+ @t.tag_bind(@id, seq, cmd, *args)
+ self
+ end
+
+ def bind_append(seq, *args)
+ if TkComm._callback_entry?(args[0]) || !block_given?
+ cmd = args.shift
+ else
+ cmd = Proc.new
+ end
+ @t.tag_bind_append(@id, seq, cmd, *args)
+ self
+ end
+
+ def bind_remove(seq)
+ @t.tag_bind_remove(@id, seq)
+ self
+ end
+
+ def bindinfo(seq=nil)
+ @t.tag_bindinfo(@id, seq)
+ end
+
+ def cget_tkstring(option)
+ @t.tagcget_tkstring(@id, option)
+ end
+ def cget(option)
+ @t.tagcget(@id, option)
+ end
+ def cget_strict(option)
+ @t.tagcget_strict(@id, option)
+ end
+
+ def configure(key, value=None)
+ @t.tagconfigure(@id, key, value)
+ self
+ end
+
+ def configinfo(key=nil)
+ @t.tagconfiginfo(@id, key)
+ end
+
+ def current_configinfo(key=nil)
+ @t.current_tagconfiginfo(@id, key)
+ end
+end
+
+########################
+
+class Tk::Tile::Treeview < TkWindow
+ include Tk::Tile::TileWidget
+ include Scrollable
+
+ include Tk::Tile::TreeviewConfig
+
+ if Tk::Tile::USE_TTK_NAMESPACE
+ TkCommandNames = ['::ttk::treeview'.freeze].freeze
+ else
+ TkCommandNames = ['::treeview'.freeze].freeze
+ end
+ WidgetClassName = 'Treeview'.freeze
+ WidgetClassNames[WidgetClassName] ||= self
+
+ def __destroy_hook__
+ Tk::Tile::Treeview::Item::ItemID_TBL.mutex.synchronize{
+ Tk::Tile::Treeview::Item::ItemID_TBL.delete(@path)
+ }
+ Tk::Tile::Treeview::Tag::ItemID_TBL.mutex.synchronize{
+ Tk::Tile::Treeview::Tag::ItemID_TBL.delete(@path)
+ }
+ end
+
+ def self.style(*args)
+ [self::WidgetClassName, *(args.map!{|a| _get_eval_string(a)})].join('.')
+ end
+
+ def tagid(id)
+ if id.kind_of?(Tk::Tile::Treeview::Item) ||
+ id.kind_of?(Tk::Tile::Treeview::Tag)
+ id.id
+ elsif id.kind_of?(Array)
+ # size is 2 or 3
+ id[0..-2] << _get_eval_string(id[-1])
+ else
+ _get_eval_string(id)
+ end
+ end
+
+ def root
+ Tk::Tile::Treeview::Root.new(self)
+ end
+
+ def bbox(item, column=None)
+ list(tk_send('item', 'bbox', item, column))
+ end
+
+ def children(item)
+ simplelist(tk_send_without_enc('children', item)).collect{|id|
+ Tk::Tile::Treeview::Item.id2obj(self, id)
+ }
+ end
+ def set_children(item, *items)
+ tk_send_without_enc('children', item,
+ array2tk_list(items.flatten, true))
+ self
+ end
+
+ def delete(*items)
+ tk_send_without_enc('delete', array2tk_list(items.flatten, true))
+ self
+ end
+
+ def detach(*items)
+ tk_send_without_enc('detach', array2tk_list(items.flatten, true))
+ self
+ end
+
+ def exist?(item)
+ bool(tk_send_without_enc('exists', _get_eval_enc_str(item)))
+ end
+
+ def focus_item(item = nil)
+ if item
+ tk_send('focus', item)
+ item
+ else
+ id = tk_send('focus')
+ (id.empty?)? nil: Tk::Tile::Treeview::Item.id2obj(self, id)
+ end
+ end
+
+ def identify(x, y)
+ # tile-0.7.2 or previous
+ ret = simplelist(tk_send('identify', x, y))
+ case ret[0]
+ when 'heading', 'separator'
+ ret[-1] = num_or_str(ret[-1])
+ when 'cell'
+ ret[1] = Tk::Tile::Treeview::Item.id2obj(self, ret[1])
+ ret[-1] = num_or_str(ret[-1])
+ when 'item', 'row'
+ ret[1] = Tk::Tile::Treeview::Item.id2obj(self, ret[1])
+ end
+ end
+
+ def identify_region(x, y)
+ tk_send('identify', 'region', x, y)
+ end
+
+ def identify_item(x, y)
+ id = tk_send('identify', 'item', x, y)
+ (id.empty?)? nil: Tk::Tile::Treeview::Item.id2obj(self, id)
+ end
+
+ def identify_element(x, y)
+ tk_send('identify', 'element', x, y)
+ end
+
+ def row_identify(x, y)
+ id = tk_send('identify', 'row', x, y)
+ (id.empty?)? nil: Tk::Tile::Treeview::Item.id2obj(self, id)
+ end
+ alias identify_row row_identify
+
+ def column_identify(x, y)
+ tk_send('identify', 'column', x, y)
+ end
+ alias identify_column column_identify
+
+ def index(item)
+ number(tk_send('index', item))
+ end
+
+ # def insert(parent, idx='end', keys={})
+ # keys = _symbolkey2str(keys)
+ # id = keys.delete('id')
+ # if id
+ # num_or_str(tk_send('insert', parent, idx, '-id', id, *hash_kv(keys)))
+ # else
+ # num_or_str(tk_send('insert', parent, idx, *hash_kv(keys)))
+ # end
+ # end
+ def insert(parent, idx='end', keys={})
+ Tk::Tile::Treeview::Item.new(self, parent, idx, keys)
+ end
+
+ # def instate(spec, cmd=Proc.new)
+ # tk_send('instate', spec, cmd)
+ # end
+ # def state(spec=None)
+ # tk_send('state', spec)
+ # end
+
+ def move(item, parent, idx)
+ tk_send('move', item, parent, idx)
+ self
+ end
+
+ def next_item(item)
+ id = tk_send('next', item)
+ (id.empty?)? nil: Tk::Tile::Treeview::Item.id2obj(self, id)
+ end
+
+ def parent_item(item)
+ if (id = tk_send('parent', item)).empty?
+ Tk::Tile::Treeview::Root.new(self)
+ else
+ Tk::Tile::Treeview::Item.id2obj(self, id)
+ end
+ end
+
+ def prev_item(item)
+ id = tk_send('prev', item)
+ (id.empty?)? nil: Tk::Tile::Treeview::Item.id2obj(self, id)
+ end
+
+ def see(item)
+ tk_send('see', item)
+ self
+ end
+
+ def selection
+ simplelist(tk_send('selection')).collect{|id|
+ Tk::Tile::Treeview::Item.id2obj(self, id)
+ }
+ end
+ alias selection_get selection
+
+ def selection_add(*items)
+ tk_send('selection', 'add', array2tk_list(items.flatten, true))
+ self
+ end
+ def selection_remove(*items)
+ tk_send('selection', 'remove', array2tk_list(items.flatten, true))
+ self
+ end
+ def selection_set(*items)
+ tk_send('selection', 'set', array2tk_list(items.flatten, true))
+ self
+ end
+ def selection_toggle(*items)
+ tk_send('selection', 'toggle', array2tk_list(items.flatten, true))
+ self
+ end
+
+ def get_directory(item)
+ # tile-0.7+
+ ret = []
+ lst = simplelist(tk_send('set', item))
+ until lst.empty?
+ col = lst.shift
+ val = lst.shift
+ ret << [col, val]
+ end
+ ret
+ end
+ alias get_dictionary get_directory
+
+ def get(item, col)
+ tk_send('set', item, col)
+ end
+ def set(item, col, value)
+ tk_send('set', item, col, value)
+ self
+ end
+
+ def tag_has?(tag, item)
+ bool(tk_send('tag', 'has', tagid(tag), tagid(item)))
+ end
+ def tag_has(tag)
+ tk_split_simplelist(tk_send('tag', 'has', tagid(tag))).collect{|id|
+ Tk::Tile::Treeview::Item.id2obj(self, id)
+ }
+ end
+
+ def tag_bind(tag, seq, *args)
+ if TkComm._callback_entry?(args[0]) || !block_given?
+ cmd = args.shift
+ else
+ cmd = Proc.new
+ end
+ _bind([@path, 'tag', 'bind', tag], seq, cmd, *args)
+ self
+ end
+ alias tagbind tag_bind
+
+ def tag_bind_append(tag, seq, *args)
+ if TkComm._callback_entry?(args[0]) || !block_given?
+ cmd = args.shift
+ else
+ cmd = Proc.new
+ end
+ _bind_append([@path, 'tag', 'bind', tag], seq, cmd, *args)
+ self
+ end
+ alias tagbind_append tag_bind_append
+
+ def tag_bind_remove(tag, seq)
+ _bind_remove([@path, 'tag', 'bind', tag], seq)
+ self
+ end
+ alias tagbind_remove tag_bind_remove
+
+ def tag_bindinfo(tag, context=nil)
+ _bindinfo([@path, 'tag', 'bind', tag], context)
+ end
+ alias tagbindinfo tag_bindinfo
+
+ def tag_names
+ tk_split_simplelist(tk_send('tag', 'names')).collect{|id|
+ Tk::Tile::Treeview::Tag.id2obj(self, id)
+ }
+ end
+
+ def tag_add(tag, *items)
+ fail ArgumentError, "no target items" if items.empty?
+ tk_send('tag', 'add', tagid(tag), *(items.collect{|item| tagid(item)}))
+ self
+ end
+
+ def tag_remove(tag, *items)
+ tk_send('tag', 'remove', tagid(tag), *(items.collect{|item| tagid(item)}))
+ self
+ end
+
+end
+
+#Tk.__set_toplevel_aliases__(:Ttk, Tk::Tile::Treeview, :TkTreeview)
+Tk.__set_loaded_toplevel_aliases__('tkextlib/tile/treeview.rb',
+ :Ttk, Tk::Tile::Treeview, :TkTreeview)
diff --git a/jni/ruby/ext/tk/lib/tkextlib/tile/tscale.rb b/jni/ruby/ext/tk/lib/tkextlib/tile/tscale.rb
new file mode 100644
index 0000000..7eefcef
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/tile/tscale.rb
@@ -0,0 +1,56 @@
+#
+# tscale & tprogress widget
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+require 'tk'
+require 'tkextlib/tile.rb'
+
+module Tk
+ module Tile
+ class TScale < Tk::Scale
+ end
+ Scale = TScale
+
+ class TProgress < TScale
+ end
+ Progress = TProgress
+ end
+end
+
+class Tk::Tile::TScale < Tk::Scale
+ include Tk::Tile::TileWidget
+
+ if Tk::Tile::USE_TTK_NAMESPACE
+ TkCommandNames = ['::ttk::scale'.freeze].freeze
+ else
+ TkCommandNames = ['::tscale'.freeze].freeze
+ end
+ WidgetClassName = 'TScale'.freeze
+ WidgetClassNames[WidgetClassName] ||= self
+
+ def self.style(*args)
+ [self::WidgetClassName, *(args.map!{|a| _get_eval_string(a)})].join('.')
+ end
+
+ alias identify ttk_identify
+end
+
+class Tk::Tile::TProgress < Tk::Tile::TScale
+ include Tk::Tile::TileWidget
+
+ if Tk::Tile::USE_TTK_NAMESPACE
+ TkCommandNames = ['::ttk::progress'.freeze].freeze
+ else
+ TkCommandNames = ['::tprogress'.freeze].freeze
+ end
+ WidgetClassName = 'TProgress'.freeze
+ WidgetClassNames[WidgetClassName] ||= self
+
+ def self.style(*args)
+ [self::WidgetClassName, *(args.map!{|a| _get_eval_string(a)})].join('.')
+ end
+end
+
+#Tk.__set_toplevel_aliases__(:Ttk, Tk::Tile::Scale, :TkScale)
+Tk.__set_loaded_toplevel_aliases__('tkextlib/tile/tscale.rb',
+ :Ttk, Tk::Tile::Scale, :TkScale)
diff --git a/jni/ruby/ext/tk/lib/tkextlib/tile/tscrollbar.rb b/jni/ruby/ext/tk/lib/tkextlib/tile/tscrollbar.rb
new file mode 100644
index 0000000..c6bba58
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/tile/tscrollbar.rb
@@ -0,0 +1,63 @@
+#
+# tscrollbar widget
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+require 'tk'
+require 'tkextlib/tile.rb'
+
+module Tk
+ module Tile
+ class TScrollbar < Tk::Scrollbar
+ end
+ Scrollbar = TScrollbar
+ end
+end
+
+class Tk::Tile::TScrollbar < Tk::Scrollbar
+ include Tk::Tile::TileWidget
+
+ if Tk::Tile::USE_TTK_NAMESPACE
+ TkCommandNames = ['::ttk::scrollbar'.freeze].freeze
+ else
+ TkCommandNames = ['::tscrollbar'.freeze].freeze
+ end
+ WidgetClassName = 'TScrollbar'.freeze
+ WidgetClassNames[WidgetClassName] ||= self
+
+ def self.style(*args)
+ [self::WidgetClassName, *(args.map!{|a| _get_eval_string(a)})].join('.')
+ end
+
+ alias identify ttk_identify
+end
+
+#Tk.__set_toplevel_aliases__(:Ttk, Tk::Tile::Scrollbar, :TkScrollbar)
+Tk.__set_loaded_toplevel_aliases__('tkextlib/tile/tscrollbar.rb',
+ :Ttk, Tk::Tile::Scrollbar, :TkScrollbar)
+
+#######################################################################
+
+class Tk::Tile::XScrollbar < Tk::Tile::TScrollbar
+ def create_self(keys)
+ keys = {} unless keys
+ keys['orient'] = 'horizontal'
+ super(keys)
+ end
+ private :create_self
+end
+
+class Tk::Tile::YScrollbar < Tk::Tile::TScrollbar
+ def create_self(keys)
+ keys = {} unless keys
+ keys['orient'] = 'vertical'
+ super(keys)
+ end
+ private :create_self
+end
+
+#Tk.__set_toplevel_aliases__(:Ttk, Tk::Tile::XScrollbar, :TkXScrollbar)
+#Tk.__set_toplevel_aliases__(:Ttk, Tk::Tile::YScrollbar, :TkYScrollbar)
+Tk.__set_loaded_toplevel_aliases__('tkextlib/tile/tscrollbar.rb',
+ :Ttk, Tk::Tile::XScrollbar, :TkXScrollbar)
+Tk.__set_loaded_toplevel_aliases__('tkextlib/tile/tscrollbar.rb',
+ :Ttk, Tk::Tile::YScrollbar, :TkYScrollbar)
diff --git a/jni/ruby/ext/tk/lib/tkextlib/tile/tseparator.rb b/jni/ruby/ext/tk/lib/tkextlib/tile/tseparator.rb
new file mode 100644
index 0000000..ffd2f6f
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/tile/tseparator.rb
@@ -0,0 +1,34 @@
+#
+# tseparator widget
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+require 'tk'
+require 'tkextlib/tile.rb'
+
+module Tk
+ module Tile
+ class TSeparator < TkWindow
+ end
+ Separator = TSeparator
+ end
+end
+
+class Tk::Tile::TSeparator < TkWindow
+ include Tk::Tile::TileWidget
+
+ if Tk::Tile::USE_TTK_NAMESPACE
+ TkCommandNames = ['::ttk::separator'.freeze].freeze
+ else
+ TkCommandNames = ['::tseparator'.freeze].freeze
+ end
+ WidgetClassName = 'TSeparator'.freeze
+ WidgetClassNames[WidgetClassName] ||= self
+
+ def self.style(*args)
+ [self::WidgetClassName, *(args.map!{|a| _get_eval_string(a)})].join('.')
+ end
+end
+
+#Tk.__set_toplevel_aliases__(:Ttk, Tk::Tile::Separator, :TkSeparator)
+Tk.__set_loaded_toplevel_aliases__('tkextlib/tile/tseparator.rb',
+ :Ttk, Tk::Tile::Separator, :TkSeparator)
diff --git a/jni/ruby/ext/tk/lib/tkextlib/tile/tspinbox.rb b/jni/ruby/ext/tk/lib/tkextlib/tile/tspinbox.rb
new file mode 100644
index 0000000..2f2d73c
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/tile/tspinbox.rb
@@ -0,0 +1,107 @@
+#
+# ttk::spinbox widget (Tcl/Tk 8.6b1 or later)
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+require 'tk'
+require 'tkextlib/tile.rb'
+
+module Tk
+ module Tile
+ class TSpinbox < Tk::Tile::TEntry
+ end
+ Spinbox = TSpinbox
+ end
+end
+
+class Tk::Tile::TSpinbox < Tk::Tile::TEntry
+ include Tk::Tile::TileWidget
+
+ if Tk::Tile::USE_TTK_NAMESPACE
+ TkCommandNames = ['::ttk::spinbox'.freeze].freeze
+ else
+ TkCommandNames = ['::tspinbox'.freeze].freeze
+ end
+ WidgetClassName = 'TSpinbox'.freeze
+ WidgetClassNames[WidgetClassName] ||= self
+
+ class SpinCommand < TkValidateCommand
+ class ValidateArgs < TkUtil::CallbackSubst
+ KEY_TBL = [
+ [ ?d, ?s, :direction ],
+ [ ?s, ?e, :current ],
+ [ ?W, ?w, :widget ],
+ nil
+ ]
+
+ PROC_TBL = [
+ [ ?s, TkComm.method(:string) ],
+ [ ?w, TkComm.method(:window) ],
+
+ [ ?e, proc{|val|
+ #enc = Tk.encoding
+ enc = ((Tk.encoding)? Tk.encoding : Tk.encoding_system)
+ if enc
+ Tk.fromUTF8(TkComm::string(val), enc)
+ else
+ TkComm::string(val)
+ end
+ }
+ ],
+
+ nil
+ ]
+
+ _setup_subst_table(KEY_TBL, PROC_TBL);
+
+ def self.ret_val(val)
+ (val)? '1': '0'
+ end
+ end
+
+ def self._config_keys
+ ['command']
+ end
+ end
+
+ def __validation_class_list
+ super() << SpinCommand
+ end
+
+ Tk::ValidateConfigure.__def_validcmd(binding, SpinCommand)
+
+ def __boolval_optkeys
+ super() << 'wrap'
+ end
+ private :__boolval_optkeys
+
+ def __strval_optkeys
+ super() << 'buttonbackground' << 'format'
+ end
+ private :__strval_optkeys
+
+ def __listval_optkeys
+ super() << 'values'
+ end
+ private :__listval_optkeys
+
+ def self.style(*args)
+ [self::WidgetClassName, *(args.map!{|a| _get_eval_string(a)})].join('.')
+ end
+
+ def current
+ number(tk_send_without_enc('current'))
+ end
+ def current=(idx)
+ tk_send('current', idx)
+ end
+
+ def set(val)
+ tk_send('set', val)
+ end
+
+ alias identify ttk_identify
+end
+
+#Tk.__set_toplevel_aliases__(:Ttk, Tk::Tile::Spinbox, :TkSpinbox)
+Tk.__set_loaded_toplevel_aliases__('tkextlib/tile/tspinbox.rb',
+ :Ttk, Tk::Tile::Spinbox, :TkSpinbox)
diff --git a/jni/ruby/ext/tk/lib/tkextlib/tile/tsquare.rb b/jni/ruby/ext/tk/lib/tkextlib/tile/tsquare.rb
new file mode 100644
index 0000000..a81cd7b
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/tile/tsquare.rb
@@ -0,0 +1,30 @@
+#
+# tsquare widget
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+require 'tk'
+require 'tkextlib/tile.rb'
+
+module Tk
+ module Tile
+ class TSquare < TkWindow
+ end
+ Square = TSquare
+ end
+end
+
+class Tk::Tile::TSquare < TkWindow
+ include Tk::Tile::TileWidget
+
+ if Tk::Tile::USE_TTK_NAMESPACE
+ TkCommandNames = ['::ttk::square'.freeze].freeze
+ else
+ TkCommandNames = ['::tsquare'.freeze].freeze
+ end
+ WidgetClassName = 'TSquare'.freeze
+ WidgetClassNames[WidgetClassName] ||= self
+
+ def self.style(*args)
+ [self::WidgetClassName, *(args.map!{|a| _get_eval_string(a)})].join('.')
+ end
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/tkDND.rb b/jni/ruby/ext/tk/lib/tkextlib/tkDND.rb
new file mode 100644
index 0000000..5d52e34
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/tkDND.rb
@@ -0,0 +1,18 @@
+#
+# TkDND (Tk Drag & Drop Extension) support
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+require 'tk'
+
+# call setup script for general 'tkextlib' libraries
+require 'tkextlib/setup.rb'
+
+# call setup script
+require 'tkextlib/tkDND/setup.rb'
+
+module Tk
+ module TkDND
+ autoload :DND, 'tkextlib/tkDND/tkdnd'
+ autoload :Shape, 'tkextlib/tkDND/shape'
+ end
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/tkDND/setup.rb b/jni/ruby/ext/tk/lib/tkextlib/tkDND/setup.rb
new file mode 100644
index 0000000..ee406c6
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/tkDND/setup.rb
@@ -0,0 +1,8 @@
+#
+# setup.rb -- setup script before calling TkPackage.require()
+#
+# If you need some setup operations (for example, add a library path
+# to the library search path) before using Tcl/Tk library packages
+# wrapped by Ruby scripts in this directory, please write the setup
+# operations in this file.
+#
diff --git a/jni/ruby/ext/tk/lib/tkextlib/tkDND/shape.rb b/jni/ruby/ext/tk/lib/tkextlib/tkDND/shape.rb
new file mode 100644
index 0000000..d44068e
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/tkDND/shape.rb
@@ -0,0 +1,125 @@
+#
+# tkextlib/tkDND/shape.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+
+require 'tk'
+
+# call setup script for general 'tkextlib' libraries
+require 'tkextlib/setup.rb'
+
+# call setup script
+require 'tkextlib/tkDND/setup.rb'
+
+# TkPackage.require('Shape', '0.3')
+TkPackage.require('Shape')
+
+module Tk
+ module TkDND
+ module Shape
+ extend TkCore
+
+ PACKAGE_NAME = 'Shape'.freeze
+ def self.package_name
+ PACKAGE_NAME
+ end
+
+=begin
+ def self.package_version
+ begin
+ TkPackage.require('Shape')
+ rescue
+ ''
+ end
+ end
+=end
+ class << self
+ def package_version
+ Tk.tk_call('set', 'shape_version')
+ end
+ alias shape_version package_version
+
+ def package_patchlevel
+ Tk.tk_call('set', 'shape_patchLevel')
+ end
+ alias shape_patchlevel package_patchlevel
+
+ def version
+ tk_call('shape', 'version')
+ end
+ alias xshape_version version
+ end
+
+ ############################
+
+ def shape_bounds(kind=nil)
+ if kind
+ ret = tk_call('shape', 'bounds', @path, "-#{kind}")
+ else
+ ret = tk_call('shape', 'bounds', @path)
+ end
+ if ret == ""
+ nil
+ else
+ list(ret)
+ end
+ end
+
+ def shape_get(kind=nil)
+ if kind
+ list(tk_call('shape', 'get', @path, "-#{kind}"))
+ else
+ list(tk_call('shape', 'get', @path))
+ end
+ end
+
+ def shape_offset(x, y, kind=nil)
+ if kind
+ tk_call('shape', 'get', @path, "-#{kind}", x, y)
+ else
+ tk_call('shape', 'get', @path, x, y)
+ end
+ self
+ end
+
+ def _parse_shapespec_param(args)
+ cmd = []
+
+ kind_keys = ['bounding', 'clip', 'both']
+ offset_keys = ['offset']
+ srckind_keys = ['bitmap', 'rectangles', 'reset', 'test', 'window']
+
+ cmd << "-#{args.shift}" if kind_keys.member?(args[0].to_s)
+
+ if offset_keys.member?(args[0].to_s)
+ cmd << "-#{args.shift}"
+ cmd << args.shift # xOffset
+ cmd << args.shift # yOffset
+ end
+
+ if srckind_keys.member?(args[0].to_s)
+ cmd << "-#{args.shift}"
+ end
+
+ cmd.concat(args)
+
+ cmd
+ end
+ private :_parse_shapespec_param
+
+ def shape_set(*args) # ?kind? ?offset <x> <y>? srckind ?arg ...?
+ tk_call('shape', 'set', @path, *(_parse_shapespec_param(args)))
+ self
+ end
+
+ def shape_update(op, *args) # ?kind? ?offset <x> <y>? srckind ?arg ...?
+ tk_call('shape', 'update', @path, op, *(_parse_shapespec_param(args)))
+ self
+ end
+ end
+ end
+end
+
+class TkWindow
+ include Tk::TkDND::Shape
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/tkDND/tkdnd.rb b/jni/ruby/ext/tk/lib/tkextlib/tkDND/tkdnd.rb
new file mode 100644
index 0000000..38e05ce
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/tkDND/tkdnd.rb
@@ -0,0 +1,182 @@
+#
+# tkextlib/tkDND/tkdnd.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+
+require 'tk'
+
+# call setup script for general 'tkextlib' libraries
+require 'tkextlib/setup.rb'
+
+# call setup script
+require 'tkextlib/tkDND/setup.rb'
+
+TkPackage.require('tkdnd')
+
+module Tk
+ module TkDND
+ PACKAGE_NAME = 'tkdnd'.freeze
+ def self.package_name
+ PACKAGE_NAME
+ end
+
+ def self.package_version
+ begin
+ TkPackage.require('tkdnd')
+ rescue
+ ''
+ end
+ end
+
+ class DND_Subst < TkUtil::CallbackSubst
+ KEY_TBL = [
+ [ ?a, ?l, :actions ],
+ [ ?A, ?s, :action ],
+ [ ?b, ?L, :codes ],
+ [ ?c, ?s, :code ],
+ [ ?d, ?l, :descriptions ],
+ [ ?D, ?l, :data ],
+ [ ?L, ?l, :source_types ],
+ [ ?m, ?l, :modifiers ],
+ [ ?t, ?l, :types ],
+ [ ?T, ?s, :type ],
+ [ ?W, ?w, :widget ],
+ [ ?x, ?n, :x ],
+ [ ?X, ?n, :x_root ],
+ [ ?y, ?n, :y ],
+ [ ?Y, ?n, :y_root ],
+ nil
+ ]
+
+ PROC_TBL = [
+ [ ?n, TkComm.method(:num_or_str) ],
+ [ ?s, TkComm.method(:string) ],
+ [ ?l, TkComm.method(:list) ],
+ [ ?L, TkComm.method(:simplelist) ],
+ [ ?w, TkComm.method(:window) ],
+ nil
+ ]
+
+=begin
+ # for Ruby m17n :: ?x --> String --> char-code ( getbyte(0) )
+ KEY_TBL.map!{|inf|
+ if inf.kind_of?(Array)
+ inf[0] = inf[0].getbyte(0) if inf[0].kind_of?(String)
+ inf[1] = inf[1].getbyte(0) if inf[1].kind_of?(String)
+ end
+ inf
+ }
+
+ PROC_TBL.map!{|inf|
+ if inf.kind_of?(Array)
+ inf[0] = inf[0].getbyte(0) if inf[0].kind_of?(String)
+ end
+ inf
+ }
+=end
+
+ # setup tables
+ _setup_subst_table(KEY_TBL, PROC_TBL);
+ end
+
+ module DND
+ def self.version
+ begin
+ TkPackage.require('tkdnd')
+ rescue
+ ''
+ end
+ end
+
+ def dnd_bindtarget_info(type=nil, event=nil)
+ if event
+ procedure(tk_call('dnd', 'bindtarget', @path, type, event))
+ elsif type
+ procedure(tk_call('dnd', 'bindtarget', @path, type))
+ else
+ simplelist(tk_call('dnd', 'bindtarget', @path))
+ end
+ end
+
+ #def dnd_bindtarget(type, event, cmd=Proc.new, prior=50, *args)
+ # event = tk_event_sequence(event)
+ # if prior.kind_of?(Numeric)
+ # tk_call('dnd', 'bindtarget', @path, type, event,
+ # install_bind_for_event_class(DND_Subst, cmd, *args),
+ # prior)
+ # else
+ # tk_call('dnd', 'bindtarget', @path, type, event,
+ # install_bind_for_event_class(DND_Subst, cmd, prior, *args))
+ # end
+ # self
+ #end
+ def dnd_bindtarget(type, event, *args)
+ # if args[0].kind_of?(Proc) || args[0].kind_of?(Method)
+ if TkComm._callback_entry?(args[0]) || !block_given?
+ cmd = args.shift
+ else
+ cmd = Proc.new
+ end
+
+ prior = 50
+ prior = args.shift unless args.empty?
+
+ event = tk_event_sequence(event)
+ if prior.kind_of?(Numeric)
+ tk_call('dnd', 'bindtarget', @path, type, event,
+ install_bind_for_event_class(DND_Subst, cmd, *args),
+ prior)
+ else
+ tk_call('dnd', 'bindtarget', @path, type, event,
+ install_bind_for_event_class(DND_Subst, cmd, prior, *args))
+ end
+ self
+ end
+
+ def dnd_cleartarget
+ tk_call('dnd', 'cleartarget', @path)
+ self
+ end
+
+ def dnd_bindsource_info(type=nil)
+ if type
+ procedure(tk_call('dnd', 'bindsource', @path, type))
+ else
+ simplelist(tk_call('dnd', 'bindsource', @path))
+ end
+ end
+
+ #def dnd_bindsource(type, cmd=Proc.new, prior=None)
+ # tk_call('dnd', 'bindsource', @path, type, cmd, prior)
+ # self
+ #end
+ def dnd_bindsource(type, *args)
+ # if args[0].kind_of?(Proc) || args[0].kind_of?(Method)
+ if TkComm._callback_entry?(args[0]) || !block_given?
+ cmd = args.shift
+ else
+ cmd = Proc.new
+ end
+
+ args = [TkComm::None] if args.empty?
+
+ tk_call('dnd', 'bindsource', @path, type, cmd, *args)
+ self
+ end
+
+ def dnd_clearsource()
+ tk_call('dnd', 'clearsource', @path)
+ self
+ end
+
+ def dnd_drag(keys=nil)
+ tk_call('dnd', 'drag', @path, *hash_kv(keys))
+ self
+ end
+ end
+ end
+end
+
+class TkWindow
+ include Tk::TkDND::DND
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/tkHTML.rb b/jni/ruby/ext/tk/lib/tkextlib/tkHTML.rb
new file mode 100644
index 0000000..5fddde7
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/tkHTML.rb
@@ -0,0 +1,13 @@
+#
+# TkHtml support
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+
+# call setup script for general 'tkextlib' libraries
+require 'tkextlib/setup.rb'
+
+# call setup script
+require 'tkextlib/tkHTML/setup.rb'
+
+# load library
+require 'tkextlib/tkHTML/htmlwidget'
diff --git a/jni/ruby/ext/tk/lib/tkextlib/tkHTML/htmlwidget.rb b/jni/ruby/ext/tk/lib/tkextlib/tkHTML/htmlwidget.rb
new file mode 100644
index 0000000..b9ee90a
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/tkHTML/htmlwidget.rb
@@ -0,0 +1,453 @@
+#
+# tkextlib/tkHTML/htmlwidget.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+
+require 'tk'
+
+# call setup script for general 'tkextlib' libraries
+require 'tkextlib/setup.rb'
+
+# call setup script
+require 'tkextlib/tkHTML/setup.rb'
+
+# TkPackage.require('Tkhtml', '2.0')
+TkPackage.require('Tkhtml')
+
+module Tk
+ class HTML_Widget < TkWindow
+ PACKAGE_NAME = 'Tkhtml'.freeze
+ def self.package_name
+ PACKAGE_NAME
+ end
+
+ def self.package_version
+ begin
+ TkPackage.require('Tkhtml')
+ rescue
+ ''
+ end
+ end
+
+ class ClippingWindow < TkWindow
+ end
+ end
+end
+
+class Tk::HTML_Widget::ClippingWindow
+ WidgetClassName = 'HtmlClip'.freeze
+ WidgetClassNames[WidgetClassName] ||= self
+
+ HtmlClip_TBL = TkCore::INTERP.create_table
+
+ TkCore::INTERP.init_ip_env{
+ HtmlClip_TBL.mutex.synchronize{ HtmlClip_TBL.clear }
+ }
+
+ def self.new(parent, keys={})
+ if parent.kind_of?(Hash)
+ keys = TkComm._symbolkey2str(parent)
+ parent = keys.delete('parent')
+ end
+
+ if parent.kind_of?(String)
+ ppath = parent.path
+ elsif parent
+ ppath = parent
+ else
+ ppath = ''
+ end
+ HtmlClip_TBL.mutex.synchronize{
+ return HtmlClip_TBL[ppath] if HtmlClip_TBL[ppath]
+ }
+
+ widgetname = keys.delete('widgetname')
+ if widgetname =~ /^(.*)\.[^.]+$/
+ ppath2 = $1
+ if ppath2[0] != ?.
+ ppath2 = ppath + '.' + ppath2
+ end
+ HtmlClip_TBL.mutex.synchronize{
+ return HtmlClip_TBL[ppath2] if HtmlClip_TBL[ppath2]
+ }
+
+ ppath = ppath2
+ end
+
+ parent = TkComm._genobj_for_tkwidget(ppath)
+ unless parent.kind_of?(Tk::HTML_Widget)
+ fail ArgumentError, "parent must be a Tk::HTML_Widget instance"
+ end
+
+ super(parent)
+ end
+
+ def initialize(parent)
+ @parent = parent
+ @ppath = parent.path
+ @path = @id = @ppath + '.x'
+ HtmlClip_TBL.mutex.synchronize{
+ HtmlClip_TBL[@ppath] = self
+ }
+ end
+
+ def method_missing(m, *args, &b)
+ @parent.__send__(m, *args, &b)
+ end
+end
+
+class Tk::HTML_Widget
+ include Scrollable
+
+ TkCommandNames = ['html'.freeze].freeze
+ WidgetClassName = 'Html'.freeze
+ WidgetClassNames[WidgetClassName] ||= self
+
+ def create_self(keys)
+ if keys and keys != None
+ tk_call_without_enc(self.class::TkCommandNames[0], @path,
+ *hash_kv(keys, true))
+ else
+ tk_call_without_enc(self.class::TkCommandNames[0], @path)
+ end
+ end
+ private :create_self
+
+ def __strval_optkeys
+ super() << 'base' << 'selectioncolor' << 'unvisitedcolor' << 'visitedcolor'
+ end
+ private :__strval_optkeys
+
+ ###################################
+ # class methods
+ ###################################
+ def self.reformat(src, dst, txt)
+ tk_call('html', 'reformat', src, dst, txt)
+ end
+
+ def self.url_join(*args) # args := sheme authority path query fragment
+ tk_call('html', 'urljoin', *args)
+ end
+
+ def self.url_split(uri)
+ tk_call('html', 'urlsplit', uri)
+ end
+
+ def self.lockcopy(src, dst)
+ tk_call('html', 'lockcopy', src, dst)
+ end
+
+ def self.gzip_file(file, dat)
+ tk_call('html', 'gzip', 'file', file, dat)
+ end
+
+ def self.gunzip_file(file, dat)
+ tk_call('html', 'gunzip', 'file', filet)
+ end
+
+ def self.gzip_data(dat)
+ tk_call('html', 'gzip', 'data', file, dat)
+ end
+
+ def self.gunzip_data(dat)
+ tk_call('html', 'gunzip', 'data', filet)
+ end
+
+ def self.base64_encode(dat)
+ tk_call('html', 'base64', 'encode', dat)
+ end
+
+ def self.base64_decode(dat)
+ tk_call('html', 'base64', 'encode', dat)
+ end
+
+ def self.text_format(dat, len)
+ tk_call('html', 'text', 'format', dat, len)
+ end
+
+ def self.xor(cmd, *args)
+ tk_call('html', 'xor', cmd, *args)
+ end
+
+ def self.stdchan(cmd, channel)
+ tk_call('html', 'stdchan', cmd, channel)
+ end
+
+ def self.crc32(data)
+ tk_call('html', 'crc32', data)
+ end
+
+ ###################################
+ # instance methods
+ ###################################
+ def clipping_window
+ ClippingWindow.new(self)
+ end
+ alias clipwin clipping_window
+ alias htmlclip clipping_window
+
+ def bgimage(image, tid=None)
+ tk_send('bgimage', image, tid)
+ self
+ end
+
+ def clear()
+ tk_send('clear')
+ self
+ end
+
+ def coords(index=None, percent=None)
+ tk_send('coords', index, percent)
+ end
+
+ def forminfo(*args)
+ tk_send('forminfo', *args)
+ end
+ alias form_info forminfo
+
+ def href(x, y)
+ simplelist(tk_send('href', x, y))
+ end
+
+ def image_add(id, img)
+ tk_send('imageadd', id, img)
+ self
+ end
+
+ def image_at(x, y)
+ tk_send('imageat', x, y)
+ end
+
+ def images()
+ list(tk_send('images'))
+ end
+
+ def image_set(id, num)
+ tk_send('imageset', id, num)
+ self
+ end
+
+ def image_update(id, imgs)
+ tk_send('imageupdate', id, imgs)
+ self
+ end
+
+ def index(idx, count=None, unit=None)
+ tk_send('index', idx, count, unit)
+ end
+
+ def insert_cursor(idx)
+ tk_send('insert', idx)
+ end
+
+ def names()
+ simple_list(tk_send('names'))
+ end
+
+ def on_screen(id, x, y)
+ bool(tk_send('onscreen', id, x, y))
+ end
+
+ def over(x, y)
+ list(tk_send('over', x, y))
+ end
+
+ def over_markup(x, y)
+ list(tk_send('over', x, y, '-muponly'))
+ end
+
+ def over_attr(x, y, attrs)
+ list(tk_send('overattr', x, y, attrs))
+ end
+
+ def parse(txt)
+ tk_send('parse', txt)
+ self
+ end
+
+ def resolver(*uri_args)
+ tk_send('resolver', *uri_args)
+ end
+
+ def selection_clear()
+ tk_send('selection', 'clear')
+ self
+ end
+
+ def selection_set(first, last)
+ tk_send('selection', 'set', first, last)
+ self
+ end
+
+ def refresh(*opts)
+ tk_send('refresh', *opts)
+ end
+
+ def layout()
+ tk_send('layout')
+ end
+
+ def sizewindow(*args)
+ tk_send('sizewindow', *args)
+ end
+
+ def postscript(*args)
+ tk_send('postscript', *args)
+ end
+
+ def source()
+ tk_send('source')
+ end
+
+ def plain_text(first, last)
+ tk_send('text', 'ascii', first, last)
+ end
+ alias ascii_text plain_text
+ alias text_ascii plain_text
+
+ def text_delete(first, last)
+ tk_send('text', 'delete', first, last)
+ self
+ end
+
+ def html_text(first, last)
+ tk_send('text', 'html', first, last)
+ end
+ alias text_html html_text
+
+ def text_insert(idx, txt)
+ tk_send('text', 'insert', idx, txt)
+ self
+ end
+
+ def break_text(idx)
+ tk_send('text', 'break', idx)
+ end
+ alias text_break break_text
+
+ def text_find(txt, *args)
+ tk_send('text', 'find', txt, *args)
+ end
+
+ def text_table(idx, imgs=None, attrs=None)
+ tk_send('text', 'table', idx, imgs, attrs)
+ end
+
+ def token_append(tag, *args)
+ tk_send('token', 'append', tag, *args)
+ self
+ end
+
+ def token_delete(first, last=None)
+ tk_send('token', 'delete', first, last)
+ self
+ end
+
+ def token_define(*args)
+ tk_send('token', 'defile', *args)
+ self
+ end
+
+ def token_find(tag, *args)
+ list(tk_send('token', 'find', tag, *args))
+ end
+
+ def token_get(first, last=None)
+ list(tk_send('token', 'get', first, last))
+ end
+
+ def token_list(first, last=None)
+ list(tk_send('token', 'list', first, last))
+ end
+
+ def token_markup(first, last=None)
+ list(tk_send('token', 'markup', first, last))
+ end
+
+ def token_DOM(first, last=None)
+ list(tk_send('token', 'domtokens', first, last))
+ end
+ alias token_dom token_DOM
+ alias token_domtokens token_DOM
+ alias token_dom_tokens token_DOM
+
+ def token_get_end(idx)
+ tk_send('token', 'getend', idx)
+ end
+ alias token_getend token_get_end
+
+ def token_offset(start, num1, num2)
+ list(tk_send('token', 'offset', start, num1, num2))
+ end
+
+ def token_get_attr(idx, name=None)
+ list(tk_send('token', 'attr', idx, name))
+ end
+
+ def token_set_attr(idx, name=None, val=None)
+ tk_send('token', 'attr', idx, name, val)
+ self
+ end
+
+ def token_handler(tag, cmd=nil, &b)
+ cmd = Proc.new(&b) if !cmd && b
+ if cmd
+ tk_send('token', 'handler', tag, cmd)
+ return self
+ else
+ return tk_send('token', 'handler', tag)
+ end
+ end
+
+ def token_insert(idx, tag, *args)
+ tk_send('token', 'insert', idx, tag, *args)
+ self
+ end
+
+ def token_attrs(*args)
+ list(tk_send('token', 'attrs', *args))
+ end
+
+ def token_unique(*args)
+ list(tk_send('token', 'unique', *args))
+ end
+
+ def token_on_events(*args)
+ list(tk_send('token', 'onEvents', *args))
+ end
+
+ def dom_nameidx(tag, name)
+ number(tk_send('dom', 'nameidx', tag, name))
+ end
+ alias dom_name_index dom_nameidx
+
+ def dom_radioidx(tag, name)
+ number(tk_send('dom', 'radioidx', tag, name))
+ end
+ alias dom_radio_index dom_radioidx
+
+ def dom_id(*spec)
+ tk_send('dom', 'id', *spec)
+ end
+
+ def dom_ids(*spec)
+ list(tk_send('dom', 'ids', *spec))
+ end
+
+ def dom_value(*spec)
+ list(tk_send('dom', 'value', *spec))
+ end
+
+ def dom_attr(idx)
+ tk_send('dom', 'attr', idx)
+ end
+
+ def dom_formel(name)
+ tk_send('dom', 'formel', name)
+ end
+ alias dom_form_element dom_formel
+
+ def dom_tree(idx, val)
+ list(tk_send('dom', 'tree', idx, val))
+ end
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/tkHTML/setup.rb b/jni/ruby/ext/tk/lib/tkextlib/tkHTML/setup.rb
new file mode 100644
index 0000000..ee406c6
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/tkHTML/setup.rb
@@ -0,0 +1,8 @@
+#
+# setup.rb -- setup script before calling TkPackage.require()
+#
+# If you need some setup operations (for example, add a library path
+# to the library search path) before using Tcl/Tk library packages
+# wrapped by Ruby scripts in this directory, please write the setup
+# operations in this file.
+#
diff --git a/jni/ruby/ext/tk/lib/tkextlib/tkimg.rb b/jni/ruby/ext/tk/lib/tkextlib/tkimg.rb
new file mode 100644
index 0000000..c01359d
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/tkimg.rb
@@ -0,0 +1,36 @@
+#
+# TkImg extension support
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+
+require 'tk'
+
+# call setup script for general 'tkextlib' libraries
+require 'tkextlib/setup.rb'
+
+# call setup script
+require 'tkextlib/tkimg/setup.rb'
+
+# load all image format handlers
+#TkPackage.require('Img', '1.3')
+TkPackage.require('Img')
+
+module Tk
+ module Img
+ PACKAGE_NAME = 'Img'.freeze
+ def self.package_name
+ PACKAGE_NAME
+ end
+
+ def self.package_version
+ begin
+ TkPackage.require('Img')
+ rescue
+ ''
+ end
+ end
+ end
+end
+
+# autoload
+autoload :TkPixmapImage, 'tkextlib/tkimg/pixmap'
diff --git a/jni/ruby/ext/tk/lib/tkextlib/tkimg/README b/jni/ruby/ext/tk/lib/tkextlib/tkimg/README
new file mode 100644
index 0000000..f5981cb
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/tkimg/README
@@ -0,0 +1,26 @@
+
+ [ Tcl/Tk Image formats (TkImg) support ]
+
+TkImg contains a collection of format handlers for the Tk photo
+image type, and a new image type, pixmaps.
+
+Supported formats of TkImg version 1.3 are
+-------------------------------------------------------
+ bmp : Windows Bitmap Format
+ gif : Graphics Interchange Format
+ ico : Windows Icon Format
+ jpeg : Joint Picture Expert Group format
+ pcx : Paintbrush Format
+ pixmap : Pixmap Image type
+ png : Portable Network Graphics format
+ ppm : Portable Pixmap format
+ ps : Adobe PostScript Format
+ sgi : SGI Native Format
+ sun : Sun Raster Format
+ tga : Truevision Targa Format
+ tiff : Tagged Image File Format
+ window : Tk Windows
+ xbm : X Window Bitmap Format
+ xpm : X Window Pixmap Format
+-------------------------------------------------------
+
diff --git a/jni/ruby/ext/tk/lib/tkextlib/tkimg/bmp.rb b/jni/ruby/ext/tk/lib/tkextlib/tkimg/bmp.rb
new file mode 100644
index 0000000..ea90181
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/tkimg/bmp.rb
@@ -0,0 +1,33 @@
+#
+# TkImg - format 'bmp'
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+require 'tk'
+
+# call setup script for general 'tkextlib' libraries
+require 'tkextlib/setup.rb'
+
+# call setup script
+require 'tkextlib/tkimg/setup.rb'
+
+#TkPackage.require('img::bmp', '1.3')
+TkPackage.require('img::bmp')
+
+module Tk
+ module Img
+ module BMP
+ PACKAGE_NAME = 'img::bmp'.freeze
+ def self.package_name
+ PACKAGE_NAME
+ end
+
+ def self.package_version
+ begin
+ TkPackage.require('img::bmp')
+ rescue
+ ''
+ end
+ end
+ end
+ end
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/tkimg/dted.rb b/jni/ruby/ext/tk/lib/tkextlib/tkimg/dted.rb
new file mode 100644
index 0000000..cae8336
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/tkimg/dted.rb
@@ -0,0 +1,33 @@
+#
+# TkImg - format 'DTED'
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+require 'tk'
+
+# call setup script for general 'tkextlib' libraries
+require 'tkextlib/setup.rb'
+
+# call setup script
+require 'tkextlib/tkimg/setup.rb'
+
+# TkPackage.require('img::dted', '1.4')
+TkPackage.require('img::dted')
+
+module Tk
+ module Img
+ module DTED
+ PACKAGE_NAME = 'img::dted'.freeze
+ def self.package_name
+ PACKAGE_NAME
+ end
+
+ def self.package_version
+ begin
+ TkPackage.require('img::dted')
+ rescue
+ ''
+ end
+ end
+ end
+ end
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/tkimg/gif.rb b/jni/ruby/ext/tk/lib/tkextlib/tkimg/gif.rb
new file mode 100644
index 0000000..d542d47
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/tkimg/gif.rb
@@ -0,0 +1,33 @@
+#
+# TkImg - format 'gif'
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+require 'tk'
+
+# call setup script for general 'tkextlib' libraries
+require 'tkextlib/setup.rb'
+
+# call setup script
+require 'tkextlib/tkimg/setup.rb'
+
+# TkPackage.require('img::gif', '1.3')
+TkPackage.require('img::gif')
+
+module Tk
+ module Img
+ module GIF
+ PACKAGE_NAME = 'img::gif'.freeze
+ def self.package_name
+ PACKAGE_NAME
+ end
+
+ def self.package_version
+ begin
+ TkPackage.require('img::gif')
+ rescue
+ ''
+ end
+ end
+ end
+ end
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/tkimg/ico.rb b/jni/ruby/ext/tk/lib/tkextlib/tkimg/ico.rb
new file mode 100644
index 0000000..e79bdf4
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/tkimg/ico.rb
@@ -0,0 +1,33 @@
+#
+# TkImg - format 'ico'
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+require 'tk'
+
+# call setup script for general 'tkextlib' libraries
+require 'tkextlib/setup.rb'
+
+# call setup script
+require 'tkextlib/tkimg/setup.rb'
+
+# TkPackage.require('img::ico', '1.3')
+TkPackage.require('img::ico')
+
+module Tk
+ module Img
+ module ICO
+ PACKAGE_NAME = 'img::ico'.freeze
+ def self.package_name
+ PACKAGE_NAME
+ end
+
+ def self.package_version
+ begin
+ TkPackage.require('img::ico')
+ rescue
+ ''
+ end
+ end
+ end
+ end
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/tkimg/jpeg.rb b/jni/ruby/ext/tk/lib/tkextlib/tkimg/jpeg.rb
new file mode 100644
index 0000000..2126120
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/tkimg/jpeg.rb
@@ -0,0 +1,33 @@
+#
+# TkImg - format 'jpeg'
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+require 'tk'
+
+# call setup script for general 'tkextlib' libraries
+require 'tkextlib/setup.rb'
+
+# call setup script
+require 'tkextlib/tkimg/setup.rb'
+
+# TkPackage.require('img::jpeg', '1.3')
+TkPackage.require('img::jpeg')
+
+module Tk
+ module Img
+ module JPEG
+ PACKAGE_NAME = 'img::jpeg'.freeze
+ def self.package_name
+ PACKAGE_NAME
+ end
+
+ def self.package_version
+ begin
+ TkPackage.require('img::jpeg')
+ rescue
+ ''
+ end
+ end
+ end
+ end
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/tkimg/pcx.rb b/jni/ruby/ext/tk/lib/tkextlib/tkimg/pcx.rb
new file mode 100644
index 0000000..6831f4d
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/tkimg/pcx.rb
@@ -0,0 +1,33 @@
+#
+# TkImg - format 'pcx'
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)#
+
+require 'tk'
+
+# call setup script for general 'tkextlib' libraries
+require 'tkextlib/setup.rb'
+
+# call setup script
+require 'tkextlib/tkimg/setup.rb'
+
+# TkPackage.require('img::pcx', '1.3')
+TkPackage.require('img::pcx')
+
+module Tk
+ module Img
+ module PCX
+ PACKAGE_NAME = 'img::pcx'.freeze
+ def self.package_name
+ PACKAGE_NAME
+ end
+
+ def self.package_version
+ begin
+ TkPackage.require('img::pcx')
+ rescue
+ ''
+ end
+ end
+ end
+ end
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/tkimg/pixmap.rb b/jni/ruby/ext/tk/lib/tkextlib/tkimg/pixmap.rb
new file mode 100644
index 0000000..bd1b870
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/tkimg/pixmap.rb
@@ -0,0 +1,44 @@
+#
+# TkImg - format 'pixmap'
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+require 'tk'
+
+# call setup script for general 'tkextlib' libraries
+require 'tkextlib/setup.rb'
+
+# call setup script
+require 'tkextlib/tkimg/setup.rb'
+
+# TkPackage.require('img::pixmap', '1.3')
+TkPackage.require('img::pixmap')
+
+module Tk
+ module Img
+ module PIXMAP
+ PACKAGE_NAME = 'img::pixmap'.freeze
+ def self.package_name
+ PACKAGE_NAME
+ end
+
+ def self.package_version
+ begin
+ TkPackage.require('img::pixmap')
+ rescue
+ ''
+ end
+ end
+ end
+ end
+end
+
+class TkPixmapImage<TkImage
+ def self.version
+ Tk::Img::PIXMAP.version
+ end
+
+ def initialize(*args)
+ @type = 'pixmap'
+ super(*args)
+ end
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/tkimg/png.rb b/jni/ruby/ext/tk/lib/tkextlib/tkimg/png.rb
new file mode 100644
index 0000000..5c829f4
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/tkimg/png.rb
@@ -0,0 +1,33 @@
+#
+# TkImg - format 'png'
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+require 'tk'
+
+# call setup script for general 'tkextlib' libraries
+require 'tkextlib/setup.rb'
+
+# call setup script
+require 'tkextlib/tkimg/setup.rb'
+
+# TkPackage.require('img::png', '1.3')
+TkPackage.require('img::png')
+
+module Tk
+ module Img
+ module PNG
+ PACKAGE_NAME = 'img::png'.freeze
+ def self.package_name
+ PACKAGE_NAME
+ end
+
+ def self.package_version
+ begin
+ TkPackage.require('img::png')
+ rescue
+ ''
+ end
+ end
+ end
+ end
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/tkimg/ppm.rb b/jni/ruby/ext/tk/lib/tkextlib/tkimg/ppm.rb
new file mode 100644
index 0000000..eacfae4
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/tkimg/ppm.rb
@@ -0,0 +1,33 @@
+#
+# TkImg - format 'ppm'
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+require 'tk'
+
+# call setup script for general 'tkextlib' libraries
+require 'tkextlib/setup.rb'
+
+# call setup script
+require 'tkextlib/tkimg/setup.rb'
+
+# TkPackage.require('img::ppm', '1.3')
+TkPackage.require('img::ppm')
+
+module Tk
+ module Img
+ module PPM
+ PACKAGE_NAME = 'img::ppm'.freeze
+ def self.package_name
+ PACKAGE_NAME
+ end
+
+ def self.package_version
+ begin
+ TkPackage.require('img::ppm')
+ rescue
+ ''
+ end
+ end
+ end
+ end
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/tkimg/ps.rb b/jni/ruby/ext/tk/lib/tkextlib/tkimg/ps.rb
new file mode 100644
index 0000000..68e9178
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/tkimg/ps.rb
@@ -0,0 +1,33 @@
+#
+# TkImg - format 'ps'
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+require 'tk'
+
+# call setup script for general 'tkextlib' libraries
+require 'tkextlib/setup.rb'
+
+# call setup script
+require 'tkextlib/tkimg/setup.rb'
+
+# TkPackage.require('img::ps', '1.3')
+TkPackage.require('img::ps')
+
+module Tk
+ module Img
+ module PS
+ PACKAGE_NAME = 'img::ps'.freeze
+ def self.package_name
+ PACKAGE_NAME
+ end
+
+ def self.package_version
+ begin
+ TkPackage.require('img::ps')
+ rescue
+ ''
+ end
+ end
+ end
+ end
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/tkimg/raw.rb b/jni/ruby/ext/tk/lib/tkextlib/tkimg/raw.rb
new file mode 100644
index 0000000..5f1cdca
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/tkimg/raw.rb
@@ -0,0 +1,33 @@
+#
+# TkImg - format 'Raw Data'
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+require 'tk'
+
+# call setup script for general 'tkextlib' libraries
+require 'tkextlib/setup.rb'
+
+# call setup script
+require 'tkextlib/tkimg/setup.rb'
+
+# TkPackage.require('img::raw', '1.4')
+TkPackage.require('img::raw')
+
+module Tk
+ module Img
+ module Raw
+ PACKAGE_NAME = 'img::raw'.freeze
+ def self.package_name
+ PACKAGE_NAME
+ end
+
+ def self.package_version
+ begin
+ TkPackage.require('img::raw')
+ rescue
+ ''
+ end
+ end
+ end
+ end
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/tkimg/setup.rb b/jni/ruby/ext/tk/lib/tkextlib/tkimg/setup.rb
new file mode 100644
index 0000000..ee406c6
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/tkimg/setup.rb
@@ -0,0 +1,8 @@
+#
+# setup.rb -- setup script before calling TkPackage.require()
+#
+# If you need some setup operations (for example, add a library path
+# to the library search path) before using Tcl/Tk library packages
+# wrapped by Ruby scripts in this directory, please write the setup
+# operations in this file.
+#
diff --git a/jni/ruby/ext/tk/lib/tkextlib/tkimg/sgi.rb b/jni/ruby/ext/tk/lib/tkextlib/tkimg/sgi.rb
new file mode 100644
index 0000000..ec7038b
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/tkimg/sgi.rb
@@ -0,0 +1,33 @@
+#
+# TkImg - format 'sgi'
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+require 'tk'
+
+# call setup script for general 'tkextlib' libraries
+require 'tkextlib/setup.rb'
+
+# call setup script
+require 'tkextlib/tkimg/setup.rb'
+
+# TkPackage.require('img::sgi', '1.3')
+TkPackage.require('img::sgi')
+
+module Tk
+ module Img
+ module SGI
+ PACKAGE_NAME = 'img::sgi'.freeze
+ def self.package_name
+ PACKAGE_NAME
+ end
+
+ def self.package_version
+ begin
+ TkPackage.require('img::sgi')
+ rescue
+ ''
+ end
+ end
+ end
+ end
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/tkimg/sun.rb b/jni/ruby/ext/tk/lib/tkextlib/tkimg/sun.rb
new file mode 100644
index 0000000..651f946
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/tkimg/sun.rb
@@ -0,0 +1,33 @@
+#
+# TkImg - format 'sun'
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+require 'tk'
+
+# call setup script for general 'tkextlib' libraries
+require 'tkextlib/setup.rb'
+
+# call setup script
+require 'tkextlib/tkimg/setup.rb'
+
+# TkPackage.require('img::sun', '1.3')
+TkPackage.require('img::sun')
+
+module Tk
+ module Img
+ module SUN
+ PACKAGE_NAME = 'img::sun'.freeze
+ def self.package_name
+ PACKAGE_NAME
+ end
+
+ def self.package_version
+ begin
+ TkPackage.require('img::sun')
+ rescue
+ ''
+ end
+ end
+ end
+ end
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/tkimg/tga.rb b/jni/ruby/ext/tk/lib/tkextlib/tkimg/tga.rb
new file mode 100644
index 0000000..1eae407
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/tkimg/tga.rb
@@ -0,0 +1,33 @@
+#
+# TkImg - format 'tga'
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+require 'tk'
+
+# call setup script for general 'tkextlib' libraries
+require 'tkextlib/setup.rb'
+
+# call setup script
+require 'tkextlib/tkimg/setup.rb'
+
+# TkPackage.require('img::tga', '1.3')
+TkPackage.require('img::tga')
+
+module Tk
+ module Img
+ module TGA
+ PACKAGE_NAME = 'img::tga'.freeze
+ def self.package_name
+ PACKAGE_NAME
+ end
+
+ def self.package_version
+ begin
+ TkPackage.require('img::tga')
+ rescue
+ ''
+ end
+ end
+ end
+ end
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/tkimg/tiff.rb b/jni/ruby/ext/tk/lib/tkextlib/tkimg/tiff.rb
new file mode 100644
index 0000000..ed271c2
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/tkimg/tiff.rb
@@ -0,0 +1,33 @@
+#
+# TkImg - format 'tiff'
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+require 'tk'
+
+# call setup script for general 'tkextlib' libraries
+require 'tkextlib/setup.rb'
+
+# call setup script
+require 'tkextlib/tkimg/setup.rb'
+
+# TkPackage.require('img::tiff', '1.3')
+TkPackage.require('img::tiff')
+
+module Tk
+ module Img
+ module TIFF
+ PACKAGE_NAME = 'img::tiff'.freeze
+ def self.package_name
+ PACKAGE_NAME
+ end
+
+ def self.package_version
+ begin
+ TkPackage.require('img::tiff')
+ rescue
+ ''
+ end
+ end
+ end
+ end
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/tkimg/window.rb b/jni/ruby/ext/tk/lib/tkextlib/tkimg/window.rb
new file mode 100644
index 0000000..3b5906f
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/tkimg/window.rb
@@ -0,0 +1,33 @@
+#
+# TkImg - format 'window'
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+require 'tk'
+
+# call setup script for general 'tkextlib' libraries
+require 'tkextlib/setup.rb'
+
+# call setup script
+require 'tkextlib/tkimg/setup.rb'
+
+# TkPackage.require('img::window', '1.3')
+TkPackage.require('img::window')
+
+module Tk
+ module Img
+ module WINDOW
+ PACKAGE_NAME = 'img::window'.freeze
+ def self.package_name
+ PACKAGE_NAME
+ end
+
+ def self.package_version
+ begin
+ TkPackage.require('img::window')
+ rescue
+ ''
+ end
+ end
+ end
+ end
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/tkimg/xbm.rb b/jni/ruby/ext/tk/lib/tkextlib/tkimg/xbm.rb
new file mode 100644
index 0000000..f4bea03
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/tkimg/xbm.rb
@@ -0,0 +1,33 @@
+#
+# TkImg - format 'xbm'
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+require 'tk'
+
+# call setup script for general 'tkextlib' libraries
+require 'tkextlib/setup.rb'
+
+# call setup script
+require 'tkextlib/tkimg/setup.rb'
+
+# TkPackage.require('img::xbm', '1.3')
+TkPackage.require('img::xbm')
+
+module Tk
+ module Img
+ module XBM
+ PACKAGE_NAME = 'img::xbm'.freeze
+ def self.package_name
+ PACKAGE_NAME
+ end
+
+ def self.package_version
+ begin
+ TkPackage.require('img::xbm')
+ rescue
+ ''
+ end
+ end
+ end
+ end
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/tkimg/xpm.rb b/jni/ruby/ext/tk/lib/tkextlib/tkimg/xpm.rb
new file mode 100644
index 0000000..5119c87
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/tkimg/xpm.rb
@@ -0,0 +1,33 @@
+#
+# TkImg - format 'xpm'
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+require 'tk'
+
+# call setup script for general 'tkextlib' libraries
+require 'tkextlib/setup.rb'
+
+# call setup script
+require 'tkextlib/tkimg/setup.rb'
+
+# TkPackage.require('img::xpm', '1.3')
+TkPackage.require('img::xpm')
+
+module Tk
+ module Img
+ module XPM
+ PACKAGE_NAME = 'img::xpm'.freeze
+ def self.package_name
+ PACKAGE_NAME
+ end
+
+ def self.package_version
+ begin
+ TkPackage.require('img::xpm')
+ rescue
+ ''
+ end
+ end
+ end
+ end
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/tktable.rb b/jni/ruby/ext/tk/lib/tkextlib/tktable.rb
new file mode 100644
index 0000000..385eb13
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/tktable.rb
@@ -0,0 +1,14 @@
+#
+# TkTable support
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+require 'tk'
+
+# call setup script for general 'tkextlib' libraries
+require 'tkextlib/setup.rb'
+
+# call setup script
+require 'tkextlib/tktable/setup.rb'
+
+# load library
+require 'tkextlib/tktable/tktable'
diff --git a/jni/ruby/ext/tk/lib/tkextlib/tktable/setup.rb b/jni/ruby/ext/tk/lib/tkextlib/tktable/setup.rb
new file mode 100644
index 0000000..ee406c6
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/tktable/setup.rb
@@ -0,0 +1,8 @@
+#
+# setup.rb -- setup script before calling TkPackage.require()
+#
+# If you need some setup operations (for example, add a library path
+# to the library search path) before using Tcl/Tk library packages
+# wrapped by Ruby scripts in this directory, please write the setup
+# operations in this file.
+#
diff --git a/jni/ruby/ext/tk/lib/tkextlib/tktable/tktable.rb b/jni/ruby/ext/tk/lib/tkextlib/tktable/tktable.rb
new file mode 100644
index 0000000..f707465
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/tktable/tktable.rb
@@ -0,0 +1,966 @@
+#
+# tkextlib/tktable/tktable.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+
+require 'tk'
+require 'tk/validation'
+
+# call setup script for general 'tkextlib' libraries
+require 'tkextlib/setup.rb'
+
+# call setup script
+require 'tkextlib/tktable/setup.rb'
+
+# TkPackage.require('Tktable', '2.8')
+TkPackage.require('Tktable')
+
+module Tk
+ class TkTable < TkWindow
+ PACKAGE_NAME = 'Tktable'.freeze
+ def self.package_name
+ PACKAGE_NAME
+ end
+
+ def self.package_version
+ begin
+ TkPackage.require('Tktable')
+ rescue
+ ''
+ end
+ end
+
+ class CellTag < TkObject
+ end
+
+ module ConfigMethod
+ end
+ end
+end
+
+module Tk::TkTable::ConfigMethod
+ include TkItemConfigMethod
+
+ def __item_cget_cmd(id) # id := [ type, tagOrId ]
+ [self.path, id[0], 'cget', id[1]]
+ end
+ private :__item_cget_cmd
+
+ def __item_config_cmd(id) # id := [ type, tagOrId ]
+ [self.path, id[0], 'configure', id[1]]
+ end
+ private :__item_config_cmd
+
+ def __item_pathname(id)
+ if id.kind_of?(Array)
+ id = tagid(id[1])
+ end
+ [self.path, id].join(';')
+ end
+ private :__item_pathname
+
+ def __item_boolval_optkeys(id)
+ super(id) << 'multiline' << 'showtext' << 'wrap'
+ end
+ private :__item_boolval_optkeys
+
+ def __item_strval_optkeys(id)
+ super(id) << 'ellipsis'
+ end
+ private :__item_strval_optkeys
+
+ def __item_val2ruby_optkeys(id) # { key=>method, ... }
+ super(id).update('window'=>proc{|k,v| window(v)})
+ end
+ private :__item_val2ruby_optkeys
+
+ def tag_cget_tkstring(tagOrId, option)
+ itemcget_tkstring(['tag', tagid(tagOrId)], option)
+ end
+ def tag_cget(tagOrId, option)
+ itemcget(['tag', tagid(tagOrId)], option)
+ end
+ def tag_cget_strict(tagOrId, option)
+ itemcget_strict(['tag', tagid(tagOrId)], option)
+ end
+ def tag_configure(tagOrId, slot, value=None)
+ itemconfigure(['tag', tagid(tagOrId)], slot, value)
+ end
+ def tag_configinfo(tagOrId, slot=nil)
+ itemconfiginfo(['tag', tagid(tagOrId)], slot)
+ end
+ def current_tag_configinfo(tagOrId, slot=nil)
+ current_itemconfiginfo(['tag', tagid(tagOrId)], slot)
+ end
+
+ def window_cget_tkstring(tagOrId, option)
+ itemcget_tkstring(['window', tagid(tagOrId)], option)
+ end
+ def window_cget(tagOrId, option)
+ itemcget(['window', tagid(tagOrId)], option)
+ end
+ def window_cget_strict(tagOrId, option)
+ itemcget_strict(['window', tagid(tagOrId)], option)
+ end
+ def window_configure(tagOrId, slot, value=None)
+ if slot == :window || slot == 'window'
+ value = _epath(value)
+ elsif slot.kind_of?(Hash)
+ if slot.key?(:window) || slot.key?('window')
+ slot = _symbolkey2str(slot)
+ slot['window'] = _epath(slot['window'])
+ end
+ end
+ itemconfigure(['window', tagid(tagOrId)], slot, value)
+ end
+ def window_configinfo(tagOrId, slot=nil)
+ itemconfiginfo(['window', tagid(tagOrId)], slot)
+ end
+ def current_window_configinfo(tagOrId, slot=nil)
+ current_itemconfiginfo(['window', tagid(tagOrId)], slot)
+ end
+
+ private :itemcget_tkstring, :itemcget, :itemcget_strict
+ private :itemconfigure, :itemconfiginfo, :current_itemconfiginfo
+end
+
+#####################################################
+
+class Tk::TkTable::CellTag
+ include TkTreatTagFont
+
+ CellTagID_TBL = TkCore::INTERP.create_table
+
+ (CellTag_ID = ['tktbl:celltag'.freeze, TkUtil.untrust('00000')]).instance_eval{
+ @mutex = Mutex.new
+ def mutex; @mutex; end
+ freeze
+ }
+
+ TkCore::INTERP.init_ip_env{
+ CellTagID_TBL.mutex.synchronize{ CellTagID_TBL.clear }
+ }
+
+ def self.id2obj(table, id)
+ tpath = table.path
+ CellTagID_TBL.mutex.synchronize{
+ if CellTagID_TBL[tpath]
+ CellTagID_TBL[tpath][id]? CellTagID_TBL[tpath][id] : id
+ else
+ id
+ end
+ }
+ end
+
+ def initialize(parent, keys=nil)
+ @parent = @t = parent
+ @tpath - parent.path
+ CellTag_ID.mutex.synchronize{
+ @path = @id = CellTag_ID.join(TkCore::INTERP._ip_id_)
+ CellTag_ID[1].succ!
+ }
+ CellTagID_TBL.mutex.synchronize{
+ CellTagID_TBL[@tpath] = {} unless CellTagID_TBL[@tpath]
+ CellTagID_TBL[@tpath][@id] = self
+ }
+ configure(keys) if keys
+ end
+
+ def id
+ @id
+ end
+
+ def destroy
+ tk_call(@tpath, 'tag', 'delete', @id)
+ CellTagID_TBL.mutex.synchronize{
+ CellTagID_TBL[@tpath].delete(@id) if CellTagID_TBL[@tpath]
+ }
+ self
+ end
+ alias delete destroy
+
+ def exist?
+ @t.tag_exist?(@id)
+ end
+ def include?(idx)
+ @t.tag_include?(@id, idx)
+ end
+
+ def add_cell(*args)
+ @t.tag_cell(@id, *args)
+ end
+ def add_col(*args)
+ @t.tag_col(@id, *args)
+ end
+ def add_row(*args)
+ @t.tag_row(@id, *args)
+ end
+
+ def raise(target=None)
+ @t.tag_raise(@id, target)
+ end
+ def lower(target=None)
+ @t.tag_lower(@id, target)
+ end
+
+ def cget_tkstring(key)
+ @t.tag_cget_tkstring(@id, key)
+ end
+ def cget(key)
+ @t.tag_cget(@id, key)
+ end
+ def cget_strict(key)
+ @t.tag_cget_strict(@id, key)
+ end
+ def configure(key, val=None)
+ @t.tag_configure(@id, key, val)
+ end
+ def configinfo(key=nil)
+ @t.tag_configinfo(@id, key)
+ end
+ def current_configinfo(key=nil)
+ @t.current_tag_configinfo(@id, key)
+ end
+end
+
+class Tk::TkTable::NamedCellTag < Tk::TkTable::CellTag
+ def self.new(parent, name, keys=nil)
+ obj = nil
+ CellTagID_TBL.mutex.synchronize{
+ if CellTagID_TBL[parent.path] && CellTagID_TBL[parent.path][name]
+ obj = CellTagID_TBL[parent.path][name]
+ else
+ #super(parent, name, keys)
+ (obj = self.allocate).instance_eval{
+ @parent = @t = parent
+ @tpath = parent.path
+ @path = @id = name
+ CellTagID_TBL[@tpath] = {} unless CellTagID_TBL[@tpath]
+ CellTagID_TBL[@tpath][@id] = self
+ }
+ end
+ }
+ obj.configure(keys) if keys && ! keys.empty?
+ obj
+ end
+
+ def initialize(parent, name, keys=nil)
+ # dummy:: not called by 'new' method
+ @parent = @t = parent
+ @tpath = parent.path
+ @path = @id = name
+ CellTagID_TBL.mutex.synchronize{
+ CellTagID_TBL[@tpath] = {} unless CellTagID_TBL[@tpath]
+ CellTagID_TBL[@tpath][@id] = self
+ }
+ configure(keys) if keys && ! keys.empty?
+ end
+end
+
+#####################################################
+
+class Tk::TkTable
+ TkCommandNames = ['table'.freeze].freeze
+ WidgetClassName = 'Table'.freeze
+ WidgetClassNames[WidgetClassName] ||= self
+
+ include Scrollable
+ include Tk::TkTable::ConfigMethod
+ include Tk::ValidateConfigure
+
+ def __destroy_hook__
+ Tk::TkTable::CelTag::CellTagID_TBL.mutex.synchronize{
+ Tk::TkTable::CelTag::CellTagID_TBL.delete(@path)
+ }
+ end
+
+ def __boolval_optkeys
+ super() << 'autoclear' << 'flashmode' << 'invertselected' <<
+ 'multiline' << 'selecttitle' << 'wrap'
+ end
+ private :__boolval_optkeys
+
+ def __strval_optkeys
+ super() << 'colseparator' << 'ellipsis' << 'rowseparator' << 'sparsearray'
+ end
+ private :__strval_optkeys
+
+
+ #################################
+
+ class BrowseCommand < TkValidateCommand
+ class ValidateArgs < TkUtil::CallbackSubst
+ KEY_TBL = [
+ [ ?c, ?n, :column ],
+ [ ?C, ?s, :index ],
+ [ ?i, ?x, :cursor ],
+ [ ?r, ?n, :row ],
+ [ ?s, ?s, :last_index ],
+ [ ?S, ?s, :new_index ],
+ [ ?W, ?w, :widget ],
+ nil
+ ]
+
+ PROC_TBL = [
+ [ ?n, TkComm.method(:number) ],
+ [ ?x, TkComm.method(:num_or_str) ],
+ [ ?s, TkComm.method(:string) ],
+ [ ?w, TkComm.method(:window) ],
+ nil
+ ]
+
+=begin
+ # for Ruby m17n :: ?x --> String --> char-code ( getbyte(0) )
+ KEY_TBL.map!{|inf|
+ if inf.kind_of?(Array)
+ inf[0] = inf[0].getbyte(0) if inf[0].kind_of?(String)
+ inf[1] = inf[1].getbyte(0) if inf[1].kind_of?(String)
+ end
+ inf
+ }
+
+ PROC_TBL.map!{|inf|
+ if inf.kind_of?(Array)
+ inf[0] = inf[0].getbyte(0) if inf[0].kind_of?(String)
+ end
+ inf
+ }
+=end
+
+ _setup_subst_table(KEY_TBL, PROC_TBL);
+
+ def self.ret_val(val)
+ val
+ end
+ end
+
+ def self._config_keys
+ ['browsecommand', 'browsecmd']
+ end
+ end
+ #--------------------------------
+ class CellCommand < TkValidateCommand
+ class ValidateArgs < TkUtil::CallbackSubst
+ KEY_TBL = [
+ [ ?c, ?n, :column ],
+ [ ?C, ?s, :index ],
+ [ ?i, ?m, :rw_mode ],
+ [ ?r, ?n, :row ],
+ [ ?s, ?v, :value ],
+ [ ?W, ?w, :widget ],
+ nil
+ ]
+
+ PROC_TBL = [
+ [ ?n, TkComm.method(:number) ],
+ [ ?s, TkComm.method(:string) ],
+ [ ?w, TkComm.method(:window) ],
+ [ ?m, proc{|val| (val == '0')? (:r) : (:w)} ],
+ [ ?v, proc{|val| TkComm.tk_tcl2ruby(val, true, false)} ],
+ nil
+ ]
+
+=begin
+ # for Ruby m17n :: ?x --> String --> char-code ( getbyte(0) )
+ KEY_TBL.map!{|inf|
+ if inf.kind_of?(Array)
+ inf[0] = inf[0].getbyte(0) if inf[0].kind_of?(String)
+ inf[1] = inf[1].getbyte(0) if inf[1].kind_of?(String)
+ end
+ inf
+ }
+
+ PROC_TBL.map!{|inf|
+ if inf.kind_of?(Array)
+ inf[0] = inf[0].getbyte(0) if inf[0].kind_of?(String)
+ end
+ inf
+ }
+=end
+
+ _setup_subst_table(KEY_TBL, PROC_TBL);
+
+ def self.ret_val(val)
+ TkComm._get_eval_string(val)
+ end
+ end
+
+ def self._config_keys
+ ['command']
+ end
+ end
+ #--------------------------------
+ class SelectionCommand < TkValidateCommand
+ class ValidateArgs < TkUtil::CallbackSubst
+ KEY_TBL = [
+ [ ?c, ?n, :sel_columns ],
+ [ ?C, ?s, :sel_area ],
+ [ ?i, ?n, :total ],
+ [ ?r, ?n, :sel_rows ],
+ [ ?s, ?s, :value ],
+ [ ?W, ?w, :widget ],
+ nil
+ ]
+
+ PROC_TBL = [
+ [ ?n, TkComm.method(:number) ],
+ [ ?s, TkComm.method(:string) ],
+ [ ?w, TkComm.method(:window) ],
+ nil
+ ]
+
+=begin
+ # for Ruby m17n :: ?x --> String --> char-code ( getbyte(0) )
+ KEY_TBL.map!{|inf|
+ if inf.kind_of?(Array)
+ inf[0] = inf[0].getbyte(0) if inf[0].kind_of?(String)
+ inf[1] = inf[1].getbyte(0) if inf[1].kind_of?(String)
+ end
+ inf
+ }
+
+ PROC_TBL.map!{|inf|
+ if inf.kind_of?(Array)
+ inf[0] = inf[0].getbyte(0) if inf[0].kind_of?(String)
+ end
+ inf
+ }
+=end
+
+ _setup_subst_table(KEY_TBL, PROC_TBL);
+
+ def self.ret_val(val)
+ val.to_s
+ end
+ end
+
+ def self._config_keys
+ ['selectioncommand', 'selcmd']
+ end
+ end
+ #--------------------------------
+ class ValidateCommand < TkValidateCommand
+ class ValidateArgs < TkUtil::CallbackSubst
+ KEY_TBL = [
+ [ ?c, ?n, :column ],
+ [ ?C, ?s, :index ],
+ [ ?i, ?x, :cursor ],
+ [ ?r, ?n, :row ],
+ [ ?s, ?v, :current_value ],
+ [ ?S, ?v, :new_value ],
+ [ ?W, ?w, :widget ],
+ nil
+ ]
+
+ PROC_TBL = [
+ [ ?n, TkComm.method(:number) ],
+ [ ?x, TkComm.method(:num_or_str) ],
+ [ ?s, TkComm.method(:string) ],
+ [ ?w, TkComm.method(:window) ],
+ [ ?v, proc{|val| TkComm.tk_tcl2ruby(val, true, false)} ],
+ nil
+ ]
+
+=begin
+ # for Ruby m17n :: ?x --> String --> char-code ( getbyte(0) )
+ KEY_TBL.map!{|inf|
+ if inf.kind_of?(Array)
+ inf[0] = inf[0].getbyte(0) if inf[0].kind_of?(String)
+ inf[1] = inf[1].getbyte(0) if inf[1].kind_of?(String)
+ end
+ inf
+ }
+
+ PROC_TBL.map!{|inf|
+ if inf.kind_of?(Array)
+ inf[0] = inf[0].getbyte(0) if inf[0].kind_of?(String)
+ end
+ inf
+ }
+=end
+
+ _setup_subst_table(KEY_TBL, PROC_TBL);
+ end
+
+ def self._config_keys
+ ['vcmd', 'validatecommand']
+ end
+ end
+
+ #################################
+
+ def __validation_class_list
+ super() <<
+ BrowseCommand << CellCommand << SelectionCommand << ValidateCommand
+ end
+
+ Tk::ValidateConfigure.__def_validcmd(binding, BrowseCommand)
+ Tk::ValidateConfigure.__def_validcmd(binding, CellCommand)
+ Tk::ValidateConfigure.__def_validcmd(binding, SelectionCommand)
+ Tk::ValidateConfigure.__def_validcmd(binding, ValidateCommand)
+
+ #################################
+
+ def activate(idx)
+ tk_send('activate', tagid(idx))
+ end
+
+ def bbox(idx)
+ list(tk_send('bbox', tagid(idx)))
+ end
+
+ def border_mark(x, y)
+ simplelist(tk_send('border', 'mark', x, y))
+ end
+ def border_mark_row(x, y)
+ tk_send('border', 'mark', x, y, 'row')
+ end
+ def border_mark_col(x, y)
+ tk_send('border', 'mark', x, y, 'col')
+ end
+ def border_dragto(x, y)
+ tk_send('border', 'dragto', x, y)
+ end
+
+ def clear_cache(first=None, last=None)
+ tk_send('clear', 'cache', tagid(first), tagid(last))
+ self
+ end
+ def clear_sizes(first=None, last=None)
+ tk_send('clear', 'sizes', tagid(first), tagid(last))
+ self
+ end
+ def clear_tags(first=None, last=None)
+ tk_send('clear', 'tags', tagid(first), tagid(last))
+ self
+ end
+ def clear_all(first=None, last=None)
+ tk_send('clear', 'all', tagid(first), tagid(last))
+ self
+ end
+
+ def curselection
+ simplelist(tk_send('curselection'))
+ end
+ def curselection=(val)
+ tk_send('curselection', val)
+ val
+ end
+
+ def curvalue
+ tk_tcl2ruby(tk_send('curvalue'), true, false)
+ end
+ def curvalue=(val)
+ tk_send('curvalue', val)
+ val
+ end
+
+ def delete_active(idx1, idx2=None)
+ tk_send('delete', 'active', tagid(idx1), tagid(idx2))
+ self
+ end
+ def delete_cols(*args) # ?switches_array?, index, ?count?
+ params = []
+ if args[0].kind_of?(Array)
+ switches = args.shift
+ switches.each{|k| params << "-#{k}"}
+ end
+ params << '--'
+ params << tagid(args.shift)
+ params.concat(args)
+ tk_send('delete', 'cols', *params)
+ self
+ end
+ def delete_rows(*args) # ?switches_array?, index, ?count?
+ params = []
+ if args[0].kind_of?(Array)
+ switches = args.shift
+ switches.each{|k| params << "-#{k}"}
+ end
+ params << '--'
+ params << tagid(args.shift)
+ params.concat(args)
+ tk_send('delete', 'rows', *params)
+ self
+ end
+
+ def get(idx)
+ tk_tcl2ruby(tk_send('get', tagid(idx)), true, false)
+ end
+ def get_area(idx1, idx2)
+ simplelist(tk_send('get', tagid(idx1), tagid(idx2))).collect{|v|
+ tk_tcl2ruby(v, true, false)
+ }
+ end
+
+ def height_list
+ list(tk_send('height'))
+ end
+ def height(row)
+ number(tk_send('height', row))
+ end
+ def set_height(*pairs)
+ tk_send('height', *(pairs.flatten))
+ self
+ end
+
+ def hidden_list
+ simplelist(tk_send('hidden'))
+ end
+ def hidden?(idx, *args)
+ if args.empty?
+ if (ret = tk_send('hidden', tagid(idx))) == ''
+ false
+ else
+ ret
+ end
+ else
+ bool(tk_send('hidden', tagid(idx), *(args.collect{|i| tagid(i)})))
+ end
+ end
+
+ def icursor
+ number(tk_send('icursor'))
+ end
+ def icursor_set(idx)
+ number(tk_send('icursor', tagid(idx)))
+ end
+
+ def index(idx)
+ tk_send('index', tagid(idx))
+ end
+ def row_index(idx)
+ number(tk_send('index', tagid(idx), 'row'))
+ end
+ def col_index(idx)
+ number(tk_send('index', tagid(idx), 'col'))
+ end
+
+ def insert_active(idx, val)
+ tk_send('insert', 'active', tagid(idx), val)
+ self
+ end
+ def insert_cols(*args) # ?switches_array?, index, ?count?
+ params = []
+ if args[0].kind_of?(Array)
+ switches = args.shift
+ switches.each{|k| params << "-#{k}"}
+ end
+ params << '--'
+ params.concat(args)
+ params << tagid(args.shift)
+ tk_send('insert', 'cols', *params)
+ self
+ end
+ def insert_rows(*args) # ?switches_array?, index, ?count?
+ params = []
+ if args[0].kind_of?(Array)
+ switches = args.shift
+ switches.each{|k| params << "-#{k}"}
+ end
+ params << '--'
+ params << tagid(args.shift)
+ params.concat(args)
+ tk_send('insert', 'rows', *params)
+ self
+ end
+
+ # def postscript(*args)
+ # tk_send('postscript', *args)
+ # end
+
+ def reread
+ tk_send('reread')
+ self
+ end
+
+ def scan_mark(x, y)
+ tk_send('scan', 'mark', x, y)
+ self
+ end
+ def scan_dragto(x, y)
+ tk_send('scan', 'dragto', x, y)
+ self
+ end
+
+ def see(idx)
+ tk_send('see', tagid(idx))
+ self
+ end
+
+ def selection_anchor(idx)
+ tk_send('selection', 'anchor', tagid(idx))
+ self
+ end
+ def selection_clear(first, last=None)
+ tk_send('selection', 'clear', tagid(first), tagid(last))
+ self
+ end
+ def selection_clear_all
+ selection_clear('all')
+ end
+ def selection_include?(idx)
+ bool(tk_send('selection', 'includes', tagid(idx)))
+ end
+ def selection_present
+ bool(tk_send('selection', 'present'))
+ end
+ def selection_set(first, last=None)
+ tk_send('selection', 'set', tagid(first), tagid(last))
+ self
+ end
+
+ def set(*pairs) # idx, val, idx, val, ...
+ args = []
+ 0.step(pairs.size-1, 2){|i|
+ args << tagid(pairs[i])
+ args << pairs[i+1]
+ }
+ tk_send('set', *args)
+ self
+ end
+ def set_row(*pairs) # idx, val, idx, val, ...
+ args = []
+ 0.step(pairs.size-1, 2){|i|
+ args << tagid(pairs[i])
+ args << pairs[i+1]
+ }
+ tk_send('set', 'row', *args)
+ self
+ end
+ def set_col(*pairs) # idx, val, idx, val, ...
+ args = []
+ 0.step(pairs.size-1, 2){|i|
+ args << tagid(pairs[i])
+ args << pairs[i+1]
+ }
+ tk_send('set', 'col', *args)
+ self
+ end
+=begin
+ def set(*pairs) # idx, val, idx, val, ... OR [idx, val], [idx, val], ...
+ if pairs[0].kind_of?(Array)
+ # [idx, val], [idx, val], ...
+ args = []
+ pairs.each{|idx, val| args << tagid(idx) << val }
+ tk_send('set', *args)
+ else
+ # idx, val, idx, val, ...
+ args = []
+ 0.step(pairs.size-1, 2){|i|
+ args << tagid(pairs[i])
+ args << pairs[i+1]
+ }
+ tk_send('set', *args)
+ end
+ self
+ end
+ def set_row(*pairs)
+ if pairs[0].kind_of?(Array)
+ # [idx, val], [idx, val], ...
+ args = []
+ pairs.each{|idx, val| args << tagid(idx) << val }
+ tk_send('set', 'row', *args)
+ else
+ # idx, val, idx, val, ...
+ args = []
+ 0.step(pairs.size-1, 2){|i|
+ args << tagid(pairs[i])
+ args << pairs[i+1]
+ }
+ tk_send('set', 'row', *args)
+ end
+ self
+ end
+ def set_col(*pairs)
+ if pairs[0].kind_of?(Array)
+ # [idx, val], [idx, val], ...
+ args = []
+ pairs.each{|idx, val| args << idx << val }
+ tk_send('set', 'col', *args)
+ else
+ # idx, val, idx, val, ...
+ args = []
+ 0.step(pairs.size-1, 2){|i|
+ args << tagid(pairs[i])
+ args << pairs[i+1]
+ }
+ tk_send('set', 'col', *args)
+ end
+ self
+ end
+=end
+
+ def spans
+ simplelist(tk_send('spans')).collect{|inf|
+ lst = simplelist(inf)
+ idx = lst[0]
+ rows, cols = lst[1].split(',').map!{|n| Integer(n)}
+ [idx [rows, cols]]
+ }
+ end
+ alias span_list spans
+ def span(idx)
+ lst = simplelist(tk_send('spans', tagid(idx)))
+ idx = lst[0]
+ rows, cols = lst[1].split(',').map!{|n| Integer(n)}
+ [idx [rows, cols]]
+ end
+ def set_spans(*pairs)
+ # idx, val, idx, val, ...
+ args = []
+ 0.step(pairs.size-1, 2){|i|
+ args << tagid(pairs[i])
+ val = pairs[i+1]
+ if val.kind_of?(Array)
+ args << val.join(',')
+ else
+ args << val
+ end
+ }
+ tk_send('spans', *args)
+ self
+ end
+=begin
+ def set_spans(*pairs)
+ if pairs[0].kind_of?(Array)
+ # [idx, val], [idx, val], ...
+ args = []
+ pairs.each{|idx, val|
+ args << tagid(idx)
+ if val.kind_of?(Array)
+ args << val.join(',')
+ else
+ args << val
+ end
+ }
+ tk_send('spans', *args)
+ else
+ # idx, val, idx, val, ...
+ args = []
+ 0.step(pairs.size-1, 2){|i|
+ args << tagid(pairs[i])
+ val = pairs[i+1]
+ if val.kind_of?(Array)
+ args << val.join(',')
+ else
+ args << val
+ end
+ }
+ tk_send('spans', *args)
+ end
+ self
+ end
+=end
+
+ def tagid(tag)
+ if tag.kind_of?(Tk::TkTable::CellTag)
+ tag.id
+ elsif tag.kind_of?(Array)
+ if tag[0].kind_of?(Integer) && tag[1].kind_of?(Integer)
+ # [row, col]
+ tag.join(',')
+ else
+ tag
+ end
+ else
+ tag
+ end
+ end
+
+ def tagid2obj(tagid)
+ Tk::TkTable::CellTag::CellTagID_TBL.mutex.synchronize{
+ if Tk::TkTable::CellTag::CellTagID_TBL.key?(@path)
+ if Tk::TkTable::CellTag::CellTagID_TBL[@path].key?(tagid)
+ Tk::TkTable::CellTag::CellTagID_TBL[@path][tagid]
+ else
+ tagid
+ end
+ else
+ tagid
+ end
+ }
+ end
+
+ def tag_cell(tag, *cells)
+ tk_send('tag', 'cell', tagid(tag), *(cells.collect{|idx| tagid(idx)}))
+ self
+ end
+ def tag_reset(*cells)
+ tk_send('tag', 'cell', '', *(cells.collect{|idx| tagid(idx)}))
+ self
+ end
+ def tag_col(tag, *cols)
+ tk_send('tag', 'col', tagid(tag), *cols)
+ self
+ end
+ def tag_col_reset(*cols)
+ tk_send('tag', 'col', '', *cols)
+ self
+ end
+ def tag_delete(tag)
+ tk_send('tag', 'delete', tagid(tag))
+ Tk::TkTable::CellTag::CellTagID_TBL.mutex.synchronize{
+ if Tk::TkTable::CellTag::CellTagID_TBL[@path]
+ if tag.kind_of? Tk::TkTable::CellTag
+ Tk::TkTable::CellTag::CellTagID_TBL[@path].delete(tag.id)
+ else
+ Tk::TkTable::CellTag::CellTagID_TBL[@path].delete(tag)
+ end
+ end
+ }
+ self
+ end
+ def tag_exist?(tag)
+ bool(tk_send('tag', 'exists', tagid(tag)))
+ end
+ def tag_include?(tag, idx)
+ bool(tk_send('tag', 'includes', tagid(tag), tagid(idx)))
+ end
+ def tag_lower(tag, target=None)
+ tk_send('tag', 'lower', tagid(tag), tagid(target))
+ self
+ end
+ def tag_names(pat=None)
+ simplelist(tk_send('tag', 'names', pat)).collect{|tag| tagid2obj(tag)}
+ end
+ def tag_raise(tag, target=None)
+ tk_send('tag', 'raise', tagid(tag), tagid(target))
+ self
+ end
+ def tag_row(tag, *rows)
+ tk_send('tag', 'row', tagid(tag), *rows)
+ self
+ end
+ def tag_row_reset(*rows)
+ tk_send('tag', 'row', '', *rows)
+ self
+ end
+
+ def validate(idx)
+ bool(tk_send('validate', tagid(idx)))
+ end
+
+ def width_list
+ list(tk_send('width'))
+ end
+ def width(row)
+ number(tk_send('width', row))
+ end
+ def set_width(*pairs)
+ tk_send('width', *(pairs.flatten))
+ self
+ end
+
+ def window_delete(*args)
+ tk_send('window', 'delete', *(args.collect{|idx| tagid(idx)}))
+ self
+ end
+ def window_move(from_idx, to_idx)
+ tk_send('window', 'move', tagid(from_idx), tagid(to_idx))
+ self
+ end
+ def window_names(pat=None)
+ simplelist(tk_send('window', 'names', pat))
+ end
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/tktrans.rb b/jni/ruby/ext/tk/lib/tkextlib/tktrans.rb
new file mode 100644
index 0000000..c5de5be
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/tktrans.rb
@@ -0,0 +1,14 @@
+#
+# TkTrans support (win32 only)
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+require 'tk'
+
+# call setup script for general 'tkextlib' libraries
+require 'tkextlib/setup.rb'
+
+# call setup script
+require 'tkextlib/tktrans/setup.rb'
+
+# load library
+require 'tkextlib/tktrans/tktrans'
diff --git a/jni/ruby/ext/tk/lib/tkextlib/tktrans/setup.rb b/jni/ruby/ext/tk/lib/tkextlib/tktrans/setup.rb
new file mode 100644
index 0000000..ee406c6
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/tktrans/setup.rb
@@ -0,0 +1,8 @@
+#
+# setup.rb -- setup script before calling TkPackage.require()
+#
+# If you need some setup operations (for example, add a library path
+# to the library search path) before using Tcl/Tk library packages
+# wrapped by Ruby scripts in this directory, please write the setup
+# operations in this file.
+#
diff --git a/jni/ruby/ext/tk/lib/tkextlib/tktrans/tktrans.rb b/jni/ruby/ext/tk/lib/tkextlib/tktrans/tktrans.rb
new file mode 100644
index 0000000..e051c09
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/tktrans/tktrans.rb
@@ -0,0 +1,64 @@
+#
+# TkTrans support (win32 only)
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+require 'tk'
+
+# call setup script for general 'tkextlib' libraries
+require 'tkextlib/setup.rb'
+
+# call setup script
+require 'tkextlib/tktrans/setup.rb'
+
+TkPackage.require('tktrans') rescue Tk.load_tcllibrary('tktrans')
+
+module Tk
+ module TkTrans
+ PACKAGE_NAME = 'tktrans'.freeze
+ def self.package_name
+ PACKAGE_NAME
+ end
+
+ def self.package_version
+ begin
+ TkPackage.require('tktrans')
+ rescue
+ ''
+ end
+ end
+ end
+end
+
+class TkWindow
+ def tktrans_set_image(img)
+ tk_send('tktrans::setwidget', @path, img)
+ self
+ end
+ def tktrans_get_image()
+ tk_send('tktrans::setwidget', @path)
+ end
+end
+
+class Tk::Root
+ undef tktrans_set_image, tktrans_get_image
+
+ def tktrans_set_image(img)
+ tk_send('tktrans::settoplevel', @path, img)
+ self
+ end
+ def tktrans_get_image()
+ tk_send('tktrans::settoplevel', @path)
+ end
+end
+
+class Tk::Toplevel
+ undef tktrans_set_image, tktrans_get_image
+
+ def tktrans_set_image(img)
+ tk_send('tktrans::settoplevel', @path, img)
+ self
+ end
+ def tktrans_get_image()
+ tk_send('tktrans::settoplevel', @path)
+ end
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/treectrl.rb b/jni/ruby/ext/tk/lib/tkextlib/treectrl.rb
new file mode 100644
index 0000000..1944fb8
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/treectrl.rb
@@ -0,0 +1,13 @@
+#
+# TkTreeCtrl support
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+
+# call setup script for general 'tkextlib' libraries
+require 'tkextlib/setup.rb'
+
+# call setup script
+require 'tkextlib/treectrl/setup.rb'
+
+# load library
+require 'tkextlib/treectrl/tktreectrl'
diff --git a/jni/ruby/ext/tk/lib/tkextlib/treectrl/setup.rb b/jni/ruby/ext/tk/lib/tkextlib/treectrl/setup.rb
new file mode 100644
index 0000000..ee406c6
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/treectrl/setup.rb
@@ -0,0 +1,8 @@
+#
+# setup.rb -- setup script before calling TkPackage.require()
+#
+# If you need some setup operations (for example, add a library path
+# to the library search path) before using Tcl/Tk library packages
+# wrapped by Ruby scripts in this directory, please write the setup
+# operations in this file.
+#
diff --git a/jni/ruby/ext/tk/lib/tkextlib/treectrl/tktreectrl.rb b/jni/ruby/ext/tk/lib/tkextlib/treectrl/tktreectrl.rb
new file mode 100644
index 0000000..1879a53
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/treectrl/tktreectrl.rb
@@ -0,0 +1,2522 @@
+#
+# tkextlib/treectrl/tktreectrl.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+
+require 'tk'
+
+# call setup script for general 'tkextlib' libraries
+require 'tkextlib/setup.rb'
+
+# call setup script
+require 'tkextlib/treectrl/setup.rb'
+
+# TkPackage.require('treectrl', '1.0')
+# TkPackage.require('treectrl', '1.1')
+TkPackage.require('treectrl')
+
+module Tk
+ class TreeCtrl < TkWindow
+ BindTag_FileList = TkBindTag.new_by_name('TreeCtrlFileList')
+
+ PACKAGE_NAME = 'treectrl'.freeze
+ def self.package_name
+ PACKAGE_NAME
+ end
+
+ def self.package_version
+ begin
+ TkPackage.require('treectrl')
+ rescue
+ ''
+ end
+ end
+
+ HasColumnCreateCommand =
+ (TkPackage.vcompare(self.package_version, '1.1') >= 0)
+
+ # dummy ::
+ # pkgIndex.tcl of TreeCtrl-1.0 doesn't support auto_load for
+ # 'loupe' command (probably it is bug, I think).
+ # So, calling a 'treectrl' command for loading the dll with
+ # the auto_load facility.
+ begin
+ tk_call('treectrl')
+ rescue
+ end
+ def self.loupe(img, x, y, w, h, zoom)
+ # NOTE: platform == 'unix' only
+
+ # img => TkPhotoImage
+ # x, y => screen coords
+ # w, h => magnifier width and height
+ # zoom => zooming rate
+ Tk.tk_call_without_enc('loupe', img, x, y, w, h, zoom)
+ end
+
+ def self.text_layout(font, text, keys={})
+ TkComm.list(Tk.tk_call_without_enc('textlayout', font, text, keys))
+ end
+
+ def self.image_tint(img, color, alpha)
+ Tk.tk_call_without_enc('imagetint', img, color, alpha)
+ end
+
+ class NotifyEvent < TkUtil::CallbackSubst
+ end
+
+ module ConfigMethod
+ end
+ end
+ TreeCtrl_Widget = TreeCtrl
+end
+
+##############################################
+
+class Tk::TreeCtrl::NotifyEvent
+ # [ <'%' subst-key char>, <proc type char>, <instance var (accessor) name>]
+ KEY_TBL = [
+ [ ?c, ?n, :item_num ],
+ [ ?d, ?s, :detail ],
+ [ ?D, ?l, :items ],
+ [ ?e, ?e, :event ],
+ [ ?I, ?n, :id ],
+ [ ?l, ?n, :lower_bound ],
+ [ ?p, ?n, :active_id ],
+ [ ?P, ?e, :pattern ],
+ [ ?S, ?l, :sel_items ],
+ [ ?T, ?w, :widget ],
+ [ ?u, ?n, :upper_bound ],
+ [ ?W, ?o, :object ],
+ [ ??, ?x, :parm_info ],
+ nil
+ ]
+
+ # [ <proc type char>, <proc/method to convert tcl-str to ruby-obj>]
+ PROC_TBL = [
+ [ ?n, TkComm.method(:num_or_str) ],
+ [ ?s, TkComm.method(:string) ],
+ [ ?l, TkComm.method(:list) ],
+ [ ?w, TkComm.method(:window) ],
+
+ [ ?e, proc{|val|
+ case val
+ when /^<<[^<>]+>>$/
+ TkVirtualEvent.getobj(val[1..-2])
+ when /^<[^<>]+>$/
+ val[1..-2]
+ else
+ val
+ end
+ }
+ ],
+
+ [ ?o, proc{|val| TkComm.tk_tcl2ruby(val)} ],
+
+ [ ?x, proc{|val|
+ begin
+ inf = {}
+ Hash[*(TkComm.list(val))].each{|k, v|
+ if keyinfo = KEY_TBL.assoc(k[0])
+ if cmd = PROC_TBL.assoc(keyinfo[1])
+ begin
+ new_v = cmd.call(v)
+ v = new_v
+ rescue
+ end
+ end
+ end
+ inf[k] = v
+ }
+ inf
+ rescue
+ val
+ end
+ } ],
+
+ nil
+ ]
+
+=begin
+ # for Ruby m17n :: ?x --> String --> char-code ( getbyte(0) )
+ KEY_TBL.map!{|inf|
+ if inf.kind_of?(Array)
+ inf[0] = inf[0].getbyte(0) if inf[0].kind_of?(String)
+ inf[1] = inf[1].getbyte(0) if inf[1].kind_of?(String)
+ end
+ inf
+ }
+
+ PROC_TBL.map!{|inf|
+ if inf.kind_of?(Array)
+ inf[0] = inf[0].getbyte(0) if inf[0].kind_of?(String)
+ end
+ inf
+ }
+=end
+
+ # setup tables to be used by scan_args, _get_subst_key, _get_all_subst_keys
+ #
+ # _get_subst_key() and _get_all_subst_keys() generates key-string
+ # which describe how to convert callback arguments to ruby objects.
+ # When binding parameters are given, use _get_subst_key().
+ # But when no parameters are given, use _get_all_subst_keys() to
+ # create a Event class object as a callback parameter.
+ #
+ # scan_args() is used when doing callback. It convert arguments
+ # ( which are Tcl strings ) to ruby objects based on the key string
+ # that is generated by _get_subst_key() or _get_all_subst_keys().
+ #
+ _setup_subst_table(KEY_TBL, PROC_TBL);
+end
+
+##############################################
+
+module Tk::TreeCtrl::ConfigMethod
+ include TkItemConfigMethod
+
+ def treectrl_tagid(key, obj)
+ if key.kind_of?(Array)
+ key = key.join(' ')
+ else
+ key = key.to_s
+ end
+
+ if (obj.kind_of?(Tk::TreeCtrl::Column) ||
+ obj.kind_of?(Tk::TreeCtrl::Element) ||
+ obj.kind_of?(Tk::TreeCtrl::Item) ||
+ obj.kind_of?(Tk::TreeCtrl::Style))
+ obj = obj.id
+ end
+
+ case key
+ when 'column'
+ obj
+
+ when 'debug'
+ None
+
+ when 'dragimage'
+ None
+
+ when 'element'
+ obj
+
+ when 'item element'
+ obj
+
+ when 'marquee'
+ None
+
+ when 'notify'
+ obj
+
+ when 'style'
+ obj
+
+ else
+ obj
+ end
+ end
+
+ def tagid(mixed_id)
+ if mixed_id == 'debug'
+ ['debug', None]
+ elsif mixed_id == 'dragimage'
+ ['dragimage', None]
+ elsif mixed_id == 'marquee'
+ ['marquee', None]
+ elsif mixed_id.kind_of?(Array)
+ [mixed_id[0], treectrl_tagid(*mixed_id)]
+ else
+ tagid(mixed_id.split(':'))
+ end
+ end
+
+ def __item_cget_cmd(mixed_id)
+ if mixed_id[0] == 'column' && mixed_id[1] == 'drag'
+ return [self.path, 'column', 'dragcget']
+ end
+
+ if mixed_id[1].kind_of?(Array)
+ id = mixed_id[1]
+ else
+ id = [mixed_id[1]]
+ end
+
+ if mixed_id[0].kind_of?(Array)
+ ([self.path].concat(mixed_id[0]) << 'cget').concat(id)
+ else
+ [self.path, mixed_id[0], 'cget'].concat(id)
+ end
+ end
+ private :__item_cget_cmd
+
+ def __item_config_cmd(mixed_id)
+ if mixed_id[0] == 'column' && mixed_id[1] == 'drag'
+ return [self.path, 'column', 'dragconfigure']
+ end
+
+ if mixed_id[1].kind_of?(Array)
+ id = mixed_id[1]
+ else
+ id = [mixed_id[1]]
+ end
+
+ if mixed_id[0].kind_of?(Array)
+ ([self.path].concat(mixed_id[0]) << 'configure').concat(id)
+ else
+ [self.path, mixed_id[0], 'configure'].concat(id)
+ end
+ end
+ private :__item_config_cmd
+
+ def __item_pathname(id)
+ if id.kind_of?(Array)
+ key = id[0]
+ if key.kind_of?(Array)
+ key = key.join(' ')
+ end
+
+ tag = id[1]
+ if tag.kind_of?(Array)
+ tag = tag.join(' ')
+ end
+
+ id = [key, tag].join(':')
+ end
+ [self.path, id].join(';')
+ end
+ private :__item_pathname
+
+ def __item_configinfo_struct(id)
+ if id.kind_of?(Array) && id[0].to_s == 'notify'
+ {:key=>0, :alias=>nil, :db_name=>nil, :db_class=>nil,
+ :default_value=>nil, :current_value=>1}
+ else
+ {:key=>0, :alias=>1, :db_name=>1, :db_class=>2,
+ :default_value=>3, :current_value=>4}
+ end
+ end
+ private :__item_configinfo_struct
+
+
+ def __item_font_optkeys(id)
+ if id.kind_of?(Array) && (id[0] == 'element' ||
+ (id[0].kind_of?(Array) && id[0][1] == 'element'))
+ []
+ else
+ ['font']
+ end
+ end
+ private :__item_font_optkeys
+
+ def __item_numstrval_optkeys(id)
+ if id == 'debug'
+ ['displaydelay']
+ else
+ super(id)
+ end
+ end
+ private :__item_numstrval_optkeys
+
+ def __item_boolval_optkeys(id)
+ if id == 'debug'
+ ['data', 'display', 'enable', 'span', 'textlayout']
+ elsif id == 'dragimage'
+ ['visible']
+ elsif id == 'marquee'
+ ['visible']
+ elsif id.kind_of?(Array)
+ case id[0]
+ when 'item'
+ ['visible', 'wrap', 'open', 'returnid', 'visible']
+ when 'column'
+ if id[1] == 'drag'
+ ['enable']
+ else
+ ['button', 'expand', 'resize', 'squeeze', 'sunken',
+ 'visible', 'widthhack']
+ end
+ when 'element'
+ ['draw', 'filled', 'showfocus', 'clip', 'destroy']
+ when 'notify'
+ ['active']
+ when 'style'
+ ['detach', 'indent', 'visible']
+ else
+ if id[0].kind_of?(Array) && id[0][1] == 'element'
+ ['filled', 'showfocus']
+ else
+ super(id)
+ end
+ end
+ else
+ super(id)
+ end
+ end
+ private :__item_boolval_optkeys
+
+ def __item_strval_optkeys(id)
+ if id == 'debug'
+ ['erasecolor']
+ elsif id.kind_of?(Array)
+ case id[0]
+ when 'column'
+ if id[1] == 'drag'
+ ['indicatorcolor']
+ else
+ super(id) << 'textcolor'
+ end
+ when 'element'
+ super(id) << 'fill' << 'outline' << 'format'
+ else
+ super(id)
+ end
+ else
+ super(id)
+ end
+ end
+ private :__item_strval_optkeys
+
+ def __item_listval_optkeys(id)
+ if id.kind_of?(Array)
+ case id[0]
+ when 'column'
+ ['itembackground']
+ when 'element'
+ ['relief']
+ when 'style'
+ ['union']
+ else
+ if id[0].kind_of?(Array) && id[0][1] == 'element'
+ ['relief']
+ else
+ []
+ end
+ end
+ else
+ []
+ end
+ end
+ private :__item_listval_optkeys
+
+ def __item_val2ruby_optkeys(id)
+ if id.kind_of?(Array)
+ case id[0]
+ when 'item'
+ { 'button' => proc{|id,val| (val == 'auto')? val: TkComm.bool(val)} }
+ else
+ []
+ end
+ else
+ []
+ end
+ end
+ private :__item_val2ruby_optkeys
+
+ def __item_keyonly_optkeys(id) # { def_key=>(undef_key|nil), ... }
+ {
+ 'notreally'=>nil,
+ 'increasing'=>'decreasing',
+ 'decreasing'=>'increasing',
+ 'ascii'=>nil,
+ 'dictionary'=>nil,
+ 'integer'=>nil,
+ 'real'=>nil
+ }
+ end
+ private :__item_keyonly_optkeys
+
+ def column_cget_tkstring(tagOrId, option)
+ itemcget_tkstring(['column', tagOrId], option)
+ end
+ def column_cget(tagOrId, option)
+ itemcget(['column', tagOrId], option)
+ end
+ def column_cget_strict(tagOrId, option)
+ itemcget_strict(['column', tagOrId], option)
+ end
+ def column_configure(tagOrId, slot, value=None)
+ itemconfigure(['column', tagOrId], slot, value)
+ end
+ def column_configinfo(tagOrId, slot=nil)
+ itemconfiginfo(['column', tagOrId], slot)
+ end
+ def current_column_configinfo(tagOrId, slot=nil)
+ current_itemconfiginfo(['column', tagOrId], slot)
+ end
+
+ def column_dragcget_tkstring(option)
+ itemcget_tkstring(['column', 'drag'], option)
+ end
+ def column_dragcget(option)
+ itemcget(['column', 'drag'], option)
+ end
+ def column_dragcget_strict(option)
+ itemcget_strict(['column', 'drag'], option)
+ end
+ def column_dragconfigure(slot, value=None)
+ itemconfigure(['column', 'drag'], slot, value)
+ end
+ def column_dragconfiginfo(slot=nil)
+ itemconfiginfo(['column', 'drag'], slot)
+ end
+ def current_column_dragconfiginfo(slot=nil)
+ current_itemconfiginfo(['column', 'drag'], slot)
+ end
+
+ def debug_cget_tkstring(option)
+ itemcget_tkstring('debug', option)
+ end
+ def debug_cget(option)
+ itemcget('debug', option)
+ end
+ def debug_cget_strict(option)
+ itemcget_strict('debug', option)
+ end
+ def debug_configure(slot, value=None)
+ itemconfigure('debug', slot, value)
+ end
+ def debug_configinfo(slot=nil)
+ itemconfiginfo('debug', slot)
+ end
+ def current_debug_configinfo(slot=nil)
+ current_itemconfiginfo('debug', slot)
+ end
+
+ def dragimage_cget_tkstring(option)
+ itemcget_tkstring('dragimage', option)
+ end
+ def dragimage_cget(option)
+ itemcget('dragimage', option)
+ end
+ def dragimage_cget_strict(option)
+ itemcget_strict('dragimage', option)
+ end
+ def dragimage_configure(slot, value=None)
+ itemconfigure('dragimage', slot, value)
+ end
+ def dragimage_configinfo(slot=nil)
+ itemconfiginfo('dragimage', slot)
+ end
+ def current_dragimage_configinfo(slot=nil)
+ current_itemconfiginfo('dragimage', slot)
+ end
+
+ def element_cget_tkstring(tagOrId, option)
+ itemcget_tkstring(['element', tagOrId], option)
+ end
+ def element_cget(tagOrId, option)
+ itemcget(['element', tagOrId], option)
+ end
+ def element_cget_strict(tagOrId, option)
+ itemcget_strict(['element', tagOrId], option)
+ end
+ def element_configure(tagOrId, slot, value=None)
+ itemconfigure(['element', tagOrId], slot, value)
+ end
+ def element_configinfo(tagOrId, slot=nil)
+ itemconfiginfo(['element', tagOrId], slot)
+ end
+ def current_element_configinfo(tagOrId, slot=nil)
+ current_itemconfiginfo(['element', tagOrId], slot)
+ end
+
+ def item_cget_tkstring(tagOrId, option)
+ itemcget_tkstring(['item', tagOrId], option)
+ end
+ def item_cget(tagOrId, option)
+ itemcget(['item', tagOrId], option)
+ end
+ def item_cget_strict(tagOrId, option)
+ itemcget_strict(['item', tagOrId], option)
+ end
+ def item_configure(tagOrId, slot, value=None)
+ itemconfigure(['item', tagOrId], slot, value)
+ end
+ def item_configinfo(tagOrId, slot=nil)
+ itemconfiginfo(['item', tagOrId], slot)
+ end
+ def current_item_configinfo(tagOrId, slot=nil)
+ current_itemconfiginfo(['item', tagOrId], slot)
+ end
+
+ def item_element_cget_tkstring(item, column, elem, option)
+ itemcget_tkstring([['item', 'element'], [item, column, elem]], option)
+ end
+ def item_element_cget(item, column, elem, option)
+ itemcget([['item', 'element'], [item, column, elem]], option)
+ end
+ def item_element_cget_strict(item, column, elem, option)
+ itemcget_strict([['item', 'element'], [item, column, elem]], option)
+ end
+ def item_element_configure(item, column, elem, slot, value=None)
+ itemconfigure([['item', 'element'], [item, column, elem]], slot, value)
+ end
+ def item_element_configinfo(item, column, elem, slot=nil)
+ itemconfiginfo([['item', 'element'], [item, column, elem]], slot)
+ end
+ def current_item_element_configinfo(item, column, elem, slot=nil)
+ current_itemconfiginfo([['item', 'element'], [item, column, elem]], slot)
+ end
+
+ def marquee_cget_tkstring(option)
+ itemcget_tkstring('marquee', option)
+ end
+ def marquee_cget(option)
+ itemcget('marquee', option)
+ end
+ def marquee_cget_strict(option)
+ itemcget_strict('marquee', option)
+ end
+ def marquee_configure(slot, value=None)
+ itemconfigure('marquee', slot, value)
+ end
+ def marquee_configinfo(slot=nil)
+ itemconfiginfo('marquee', slot)
+ end
+ def current_marquee_configinfo(slot=nil)
+ current_itemconfiginfo('marquee', slot)
+ end
+
+ def notify_cget_tkstring(win, pattern, option)
+ pattern = "<#{pattern}>"
+ # "notify" doesn't have cget subcommand.
+ tk_split_simplelist(tk_call_without_enc(*(__item_confinfo_cmd(tagid(['notify', [win, pattern]])) << "-#{option}")), false, true)[-1]
+ end
+ def notify_cget(win, pattern, option)
+ pattern = "<#{pattern}>"
+ # "notify" doesn't have cget subcommand.
+ current_itemconfiginfo(['notify', [win, pattern]])[option.to_s]
+ end
+ def notify_cget_strict(win, pattern, option)
+ pattern = "<#{pattern}>"
+ # "notify" doesn't have cget subcommand.
+ info = current_itemconfiginfo(['notify', [win, pattern]])
+ option = option.to_s
+ unless info.has_key?(option)
+ fail RuntimeError, "unknown option \"#{option}\""
+ else
+ info[option]
+ end
+ end
+ def notify_configure(win, pattern, slot, value=None)
+ pattern = "<#{pattern}>"
+ itemconfigure(['notify', [win, pattern]], slot, value)
+ end
+ def notify_configinfo(win, pattern, slot=nil)
+ pattern = "<#{pattern}>"
+ itemconfiginfo(['notify', [win, pattern]], slot)
+ end
+ def current_notify_configinfo(tagOrId, slot=nil)
+ pattern = "<#{pattern}>"
+ current_itemconfiginfo(['notify', [win, pattern]], slot)
+ end
+
+ def style_cget_tkstring(tagOrId, option)
+ itemcget_tkstring(['style', tagOrId], option)
+ end
+ def style_cget(tagOrId, option)
+ itemcget(['style', tagOrId], option)
+ end
+ def style_cget_strict(tagOrId, option)
+ itemcget_strict(['style', tagOrId], option)
+ end
+ def style_configure(tagOrId, slot, value=None)
+ itemconfigure(['style', tagOrId], slot, value)
+ end
+ def style_configinfo(tagOrId, slot=nil)
+ itemconfiginfo(['style', tagOrId], slot)
+ end
+ def current_style_configinfo(tagOrId, slot=nil)
+ current_itemconfiginfo(['style', tagOrId], slot)
+ end
+
+ private :itemcget_tkstring, :itemcget, :itemcget_strict
+ private :itemconfigure, :itemconfiginfo, :current_itemconfiginfo
+end
+
+##############################################
+
+class Tk::TreeCtrl
+ include Tk::TreeCtrl::ConfigMethod
+ include Scrollable
+
+ TkCommandNames = ['treectrl'.freeze].freeze
+ WidgetClassName = 'TreeCtrl'.freeze
+ WidgetClassNames[WidgetClassName] ||= self
+
+ #########################
+
+ def __destroy_hook__
+ Tk::TreeCtrl::Column::TreeCtrlColumnID_TBL.mutex.synchronize{
+ Tk::TreeCtrl::Column::TreeCtrlColumnID_TBL.delete(@path)
+ }
+ Tk::TreeCtrl::Element::TreeCtrlElementID_TBL.mutex.synchronize{
+ Tk::TreeCtrl::Element::TreeCtrlElementID_TBL.delete(@path)
+ }
+ Tk::TreeCtrl::Item::TreeCtrlItemID_TBL.mutex.synchronize{
+ Tk::TreeCtrl::Item::TreeCtrlItemID_TBL.delete(@path)
+ }
+ Tk::TreeCtrl::Style::TreeCtrlStyleID_TBL.mutex.synchronize{
+ Tk::TreeCtrl::Style::TreeCtrlStyleID_TBL.delete(@path)
+ }
+ end
+
+ #########################
+
+ def __strval_optkeys
+ super() + [
+ 'buttoncolor', 'columnprefix', 'itemprefix', 'linecolor'
+ ]
+ end
+ private :__strval_optkeys
+
+ def __boolval_optkeys
+ [
+ 'itemwidthequal', 'usetheme',
+ 'showbuttons', 'showheader', 'showlines', 'showroot',
+ 'showrootbutton', 'showrootlines', 'showrootchildbuttons'
+ ]
+ end
+ private :__boolval_optkeys
+
+ def __listval_optkeys
+ [ 'defaultstyle' ]
+ end
+ private :__listval_optkeys
+
+ #########################
+
+ def install_bind(cmd, *args)
+ install_bind_for_event_class(Tk::TreeCtrl::NotifyEvent, cmd, *args)
+ end
+
+ #########################
+
+ def create_self(keys)
+ if keys and keys != None
+ tk_call_without_enc(self.class::TkCommandNames[0], @path,
+ *hash_kv(keys, true))
+ else
+ tk_call_without_enc(self.class::TkCommandNames[0], @path)
+ end
+ end
+ private :create_self
+
+ #########################
+
+ def activate(desc)
+ tk_send('activate', desc)
+ self
+ end
+
+ def canvasx(x)
+ number(tk_send('canvasx', x))
+ end
+
+ def canvasy(y)
+ number(tk_send('canvasy', y))
+ end
+
+ def collapse(*dsc)
+ tk_send_without_enc('collapse', *(dsc.map!{|d| _get_eval_string(d, true)}))
+ self
+ end
+
+ def collapse_recurse(*dsc)
+ tk_send_without_enc('collapse', '-recurse',
+ *(dsc.map!{|d| _get_eval_string(d, true)}))
+ self
+ end
+
+ def column_bbox(idx)
+ list(tk_send('column', 'bbox', idx))
+ end
+
+ def column_compare(column1, op, column2)
+ bool(tk_send('column', 'compare', column1, op, column2))
+ end
+
+ def column_count
+ num_or_str(tk_send('column', 'count'))
+ end
+
+ def column_create(keys=nil)
+ if keys && keys.kind_of?(Hash)
+ num_or_str(tk_send('column', 'create', *hash_kv(keys)))
+ else
+ num_or_str(tk_send('column', 'create'))
+ end
+ end
+
+ def column_delete(idx)
+ Tk::TreeCtrl::Column::TreeCtrlColumnID_TBL.mutex.synchronize{
+ if Tk::TreeCtrl::Column::TreeCtrlColumnID_TBL[self.path]
+ Tk::TreeCtrl::Column::TreeCtrlColumnID_TBL[self.path].delete(idx)
+ end
+ }
+ tk_send('column', 'delete', idx)
+ self
+ end
+
+ def column_index(idx)
+ num_or_str(tk_send('column', 'index', idx))
+ end
+
+ def column_id(idx)
+ tk_send('column', 'id', idx)
+ end
+
+ def column_list(visible=false)
+ if visible
+ simplelist(tk_send('column', 'list', '-visible'))
+ else
+ simplelist(tk_send('column', 'list'))
+ end
+ end
+ def column_visible_list
+ column_list(true)
+ end
+
+ def column_move(idx, before)
+ tk_send('column', 'move', idx, before)
+ self
+ end
+
+ def column_needed_width(idx)
+ num_or_str(tk_send('column', 'neededwidth', idx))
+ end
+ alias column_neededwidth column_needed_width
+
+ def column_order(column, visible=false)
+ if visible
+ num_or_str(tk_send('column', 'order', column, '-visible'))
+ else
+ num_or_str(tk_send('column', 'order', column))
+ end
+ end
+ def column_visible_order(column)
+ column_order(column, true)
+ end
+
+ def column_width(idx)
+ num_or_str(tk_send('column', 'width', idx))
+ end
+
+ def compare(item1, op, item2)
+ bool(tk_send('compare', item1, op, item2))
+ end
+
+ def contentbox()
+ list(tk_send('contentbox'))
+ end
+
+ def depth(item=None)
+ num_or_str(tk_send_without_enc('depth', _get_eval_string(item, true)))
+ end
+
+ def dragimage_add(item, *args)
+ tk_send('dragimage', 'add', item, *args)
+ self
+ end
+
+ def dragimage_clear()
+ tk_send('dragimage', 'clear')
+ self
+ end
+
+ def dragimage_offset(*args) # x, y
+ if args.empty?
+ list(tk_send('dragimage', 'offset'))
+ else
+ tk_send('dragimage', 'offset', *args)
+ self
+ end
+ end
+
+ def dragimage_visible(*args) # mode
+ if args..empty?
+ bool(tk_send('dragimage', 'visible'))
+ else
+ tk_send('dragimage', 'visible', *args)
+ self
+ end
+ end
+ def dragimage_visible?
+ dragimage_visible()
+ end
+
+ def debug_dinfo
+ tk_send('debug', 'dinfo')
+ self
+ end
+
+ def debug_scroll
+ tk_send('debug', 'scroll')
+ end
+
+ def element_create(elem, type, keys=nil)
+ if keys && keys.kind_of?(Hash)
+ tk_send('element', 'create', elem, type, *hash_kv(keys))
+ else
+ tk_send('element', 'create', elem, type)
+ end
+ end
+
+ def element_delete(*elems)
+ Tk::TreeCtrl::Element::TreeCtrlElementID_TBL.mutex.synchronize{
+ if Tk::TreeCtrl::Element::TreeCtrlElementID_TBL[self.path]
+ elems.each{|elem|
+ Tk::TreeCtrl::Element::TreeCtrlElementID_TBL[self.path].delete(elem)
+ }
+ end
+ }
+ tk_send('element', 'delete', *elems)
+ self
+ end
+
+ def element_names()
+ list(tk_send('element', 'names')).collect!{|elem|
+ Tk::TreeCtrl::Element.id2obj(self, elem)
+ }
+ end
+
+ def _conv_element_perstate_val(opt, val)
+ case opt
+ when 'background', 'foreground', 'fill', 'outline', 'format'
+ val
+ when 'draw', 'filled', 'showfocus', 'destroy'
+ bool(val)
+ else
+ tk_tcl2ruby(val)
+ end
+ end
+ private :_conv_element_perstate_val
+
+ def element_perstate(elem, opt, st_list)
+ tk_send('element', 'perstate', elem, "-{opt}", st_list)
+ end
+
+ def element_type(elem)
+ tk_send('element', 'type', elem)
+ end
+
+ def element_class(elem)
+ Tk::TreeCtrl::Element.type2class(element_type(elem))
+ end
+
+ def expand(*dsc)
+ tk_send('expand', *dsc)
+ self
+ end
+
+ def expand_recurse(*dsc)
+ tk_send('expand', '-recurse', *dsc)
+ self
+ end
+
+ def identify(x, y)
+ lst = list(tk_send('identify', x, y))
+
+ if lst[0] == 'item'
+ lst[1] = Tk::TreeCtrl::Item.id2obj(self, lst[1])
+ size = lst.size
+ i = 2
+ while i < size
+ case lst[i]
+ when 'line'
+ i += 1
+ lst[i] = Tk::TreeCtrl::Item.id2obj(self, lst[i])
+ i += 1
+
+ when 'button'
+ i += 1
+
+ when 'column'
+ i += 2
+
+ when 'elem'
+ i += 1
+ lst[i] = Tk::TreeCtrl::Element.id2obj(self, lst[i])
+ i += 1
+
+ else
+ i += 1
+ end
+ end
+ end
+
+ lst
+ end
+
+ def index(idx)
+ num_or_str(tk_send('index', idx))
+ end
+
+ def item_ancestors(item)
+ list(tk_send('item', 'ancestors', item)).collect!{|id|
+ Tk::TreeCtrl::Item.id2obj(self, id)
+ }
+ end
+
+ def item_bbox(item, *args)
+ list(tk_send('item', 'bbox', item, *args))
+ end
+
+ def item_children(item)
+ list(tk_send('item', 'children', item)).collect!{|id|
+ Tk::TreeCtrl::Item.id2obj(self, id)
+ }
+ end
+
+ def item_collapse(item)
+ tk_send_without_enc('item', 'collapse', _get_eval_string(item, true))
+ self
+ end
+
+ def item_collapse_recurse(item)
+ tk_send_without_enc('item', 'collapse',
+ _get_eval_string(item, true), '-recurse')
+ self
+ end
+
+ def item_compare(item1, op, item2)
+ bool(tk_send('item', 'compare', item1, op, item2))
+ end
+
+ def item_complex(item, *args)
+ tk_send_without_enc('item', 'complex',
+ _get_eval_string(item, true),
+ *(args.map!{|arg| _get_eval_string(arg, true)}))
+ self
+ end
+
+ def item_count
+ num_or_str(tk_send('item', 'count'))
+ end
+
+ def item_create(keys={})
+ num_or_str(tk_send_without_enc('item', 'create', *hash_kv(keys, true)))
+ end
+
+ def _erase_children(item)
+ item_children(item).each{|i| _erase_children(i)}
+ # table is already locked
+ Tk::TreeCtrl::Item::TreeCtrlItemID_TBL[self.path].delete(item)
+ end
+ private :_erase_children
+
+ def item_delete(first, last=None)
+ Tk::TreeCtrl::Item::TreeCtrlItemID_TBL.mutex.synchronize{
+ if Tk::TreeCtrl::Item::TreeCtrlItemID_TBL[self.path]
+ if first == 'all' || first == :all || last == 'all' || last == :all
+ Tk::TreeCtrl::Item::TreeCtrlItemID_TBL[self.path].clear
+ elsif last == None
+ _erase_children(first)
+ else
+ self.range(first, last).each{|id|
+ _erase_children(id)
+ }
+ end
+ end
+ }
+ tk_send('item', 'delete', first, last)
+ self
+ end
+
+ def item_dump(item)
+ list(tk_send('item', 'dump', item))
+ end
+
+ def item_dump_hash(item)
+ Hash[*list(tk_send('item', 'dump', item))]
+ end
+
+ def item_element_actual(item, column, elem, key)
+ tk_send('item', 'element', 'actual', item, column, elem, "-#{key}")
+ end
+
+ def item_element_perstate(elem, opt, st_list)
+ tk_send('item', 'element', 'perstate', elem, "-{opt}", st_list)
+ end
+
+ def item_expand(item)
+ tk_send('item', 'expand', item)
+ self
+ end
+
+ def item_expand_recurse(item)
+ tk_send('item', 'expand', item, '-recurse')
+ self
+ end
+
+ def item_firstchild(parent, child=nil)
+ if child
+ tk_send_without_enc('item', 'firstchild',
+ _get_eval_string(parent, true),
+ _get_eval_string(child, true))
+ self
+ else
+ id = num_or_str(tk_send_without_enc('item', 'firstchild',
+ _get_eval_string(parent, true)))
+ Tk::TreeCtrl::Item.id2obj(self, id)
+ end
+ end
+ alias item_first_child item_firstchild
+
+ def item_hasbutton(item, st=None)
+ if st == None
+ bool(tk_send_without_enc('item', 'hasbutton',
+ _get_eval_string(item, true)))
+ else
+ tk_send_without_enc('item', 'hasbutton',
+ _get_eval_string(item, true),
+ _get_eval_string(st))
+ self
+ end
+ end
+ alias item_has_button item_hasbutton
+
+ def item_hasbutton?(item)
+ item_hasbutton(item)
+ end
+ alias item_has_button? item_hasbutton?
+
+ def item_id(item)
+ tk_send('item', 'id', item)
+ end
+
+ def item_image(item, column=nil, *args)
+ if args.empty?
+ if column
+ img = tk_send('item', 'image', item, column)
+ TkImage::Tk_IMGTBL[img]? TkImage::Tk_IMGTBL[img] : img
+ else
+ simplelist(tk_send('item', 'image', item)).collect!{|img|
+ TkImage::Tk_IMGTBL[img]? TkImage::Tk_IMGTBL[img] : img
+ }
+ end
+ else
+ tk_send('item', 'image', item, column, *args)
+ self
+ end
+ end
+ def get_item_image(item, column=nil)
+ item_image(item, column)
+ end
+ def set_item_image(item, col, img, *args)
+ item_image(item, col, img, *args)
+ end
+
+ def item_index(item)
+ list(tk_send('item', 'index', item))
+ end
+
+ def item_isancestor(item, des)
+ bool(tk_send('item', 'isancestor', item, des))
+ end
+ alias item_is_ancestor item_isancestor
+ alias item_isancestor? item_isancestor
+ alias item_is_ancestor? item_isancestor
+
+ def item_isopen(item)
+ bool(tk_send('item', 'isopen', item))
+ end
+ alias item_is_open item_isopen
+ alias item_isopen? item_isopen
+ alias item_is_open? item_isopen
+ alias item_isopened? item_isopen
+ alias item_is_opened? item_isopen
+
+ def item_lastchild(parent, child=nil)
+ if child
+ tk_send_without_enc('item', 'lastchild',
+ _get_eval_string(parent, true),
+ _get_eval_string(child, true))
+ self
+ else
+ id = num_or_str(tk_send_without_enc('item', 'lastchild',
+ _get_eval_string(parent, true)))
+ Tk::TreeCtrl::Item.id2obj(self, id)
+ end
+ end
+ alias item_last_child item_lastchild
+
+ def item_nextsibling(sibling, nxt=nil)
+ if nxt
+ tk_send('item', 'nextsibling', sibling, nxt)
+ self
+ else
+ id = num_or_str(tk_send('item', 'nextsibling', sibling))
+ Tk::TreeCtrl::Item.id2obj(self, id)
+ end
+ end
+ alias item_next_sibling item_nextsibling
+
+ def item_numchildren(item)
+ number(tk_send_without_enc('item', 'numchildren',
+ _get_eval_string(item, true)))
+ end
+ alias item_num_children item_numchildren
+ alias item_children_size item_numchildren
+
+ def item_order(item, visible=false)
+ if visible
+ ret = num_or_str(tk_send('item', 'order', item, '-visible'))
+ else
+ ret = num_or_str(tk_send('item', 'order', item))
+ end
+
+ (ret.kind_of?(Fixnum) && ret < 0)? nil: ret
+ end
+ def item_visible_order(item)
+ item_order(item, true)
+ end
+
+ def item_parent(item)
+ id = num_or_str(tk_send('item', 'parent', item))
+ Tk::TreeCtrl::Item.id2obj(self, id)
+ end
+
+ def item_prevsibling(sibling, prev=nil)
+ if prev
+ tk_send('item', 'prevsibling', sibling, prev)
+ self
+ else
+ id = num_or_str(tk_send('item', 'prevsibling', sibling))
+ Tk::TreeCtrl::Item.id2obj(self, id)
+ end
+ end
+ alias item_prev_sibling item_prevsibling
+
+ def item_range(first, last)
+ simplelist(tk_send('item', 'range', first, last))
+ end
+
+ def item_remove(item)
+ tk_send('item', 'remove', item)
+ self
+ end
+
+ def item_rnc(item)
+ list(tk_send('item', 'rnc', item))
+ end
+
+ def _item_sort_core(real_sort, item, *opts)
+ # opts ::= sort_param [, sort_param, ... ]
+ # sort_param ::= {key=>val, ...}
+ # [type, desc, {key=>val, ...}]
+ # param
+ opts = opts.collect{|param|
+ if param.kind_of?(Hash)
+ param = _symbolkey2str(param)
+ if param.key?('column')
+ key = '-column'
+ desc = param.delete('column')
+ elsif param.key?('element')
+ key = '-element'
+ desc = param.delete('element')
+ else
+ key = nil
+ end
+
+ if param.empty?
+ param = None
+ else
+ param = hash_kv(__conv_item_keyonly_opts(item, param))
+ end
+
+ if key
+ [key, desc].concat(param)
+ else
+ param
+ end
+
+ elsif param.kind_of?(Array)
+ if param[2].kind_of?(Hash)
+ param[2] = hash_kv(__conv_item_keyonly_opts(item, param[2]))
+ end
+ param
+
+ elsif param.kind_of?(String) && param =~ /\A[a-z]+\Z/
+ '-' << param
+
+ elsif param.kind_of?(Symbol)
+ '-' << param.to_s
+
+ else
+ param
+ end
+ }.flatten
+
+ if real_sort
+ tk_send('item', 'sort', item, *opts)
+ self
+ else
+ list(tk_send('item', 'sort', item, '-notreally', *opts))
+ end
+ end
+ private :_item_sort_core
+
+ def item_sort(item, *opts)
+ _item_sort_core(true, item, *opts)
+ end
+ def item_sort_not_really(item, *opts)
+ _item_sort_core(false, item, *opts)
+ end
+
+ def item_span(item, column=nil, *args)
+ if args.empty?
+ if column
+ list(tk_send('item', 'span', item, column))
+ else
+ simplelist(tk_send('item', 'span', item)).collect!{|elem| list(elem)}
+ end
+ else
+ tk_send('item', 'span', item, column, *args)
+ self
+ end
+ end
+ def get_item_span(item, column=nil)
+ item_span(item, column)
+ end
+ def set_item_span(item, col, num, *args)
+ item_span(item, col, num, *args)
+ end
+
+ def item_state_forcolumn(item, column, *args)
+ tk_send('item', 'state', 'forcolumn', item, column, *args)
+ end
+ alias item_state_for_column item_state_forcolumn
+
+ def item_state_get(item, *args)
+ if args.empty?
+ list(tk_send('item', 'state', 'get', item *args))
+ else
+ bool(tk_send('item', 'state', 'get', item))
+ end
+ end
+
+ def item_state_set(item, *args)
+ tk_send('item', 'state', 'set', item, *args)
+ end
+
+ def item_style_elements(item, column)
+ list(tk_send('item', 'style', 'elements', item, column)).collect!{|id|
+ Tk::TreeCtrl::Style.id2obj(self, id)
+ }
+ end
+
+ def item_style_map(item, column, style, map)
+ tk_send('item', 'style', 'map', item, column, style, map)
+ self
+ end
+
+ def item_style_set(item, column=nil, *args)
+ if args.empty?
+ if column
+ id = tk_send_without_enc('item', 'style', 'set',
+ _get_eval_string(item, true),
+ _get_eval_string(column, true))
+ Tk::TreeCtrl::Style.id2obj(self, id)
+ else
+ list(tk_send_without_enc('item', 'style', 'set',
+ _get_eval_string(item, true))).collect!{|id|
+ Tk::TreeCtrl::Style.id2obj(self, id)
+ }
+ end
+ else
+ tk_send_without_enc('item', 'style', 'set',
+ _get_eval_string(item, true),
+ _get_eval_string(column, true),
+ *(args.flatten.map!{|arg|
+ _get_eval_string(arg, true)
+ }))
+ self
+ end
+ end
+
+ def item_text(item, column, txt=nil, *args)
+ if args.empty?
+ if txt
+ tk_send('item', 'text', item, column, txt)
+ self
+ else
+ tk_send('item', 'text', item, column)
+ end
+ else
+ tk_send('item', 'text', item, column, txt, *args)
+ self
+ end
+ end
+
+ def item_toggle(item)
+ tk_send('item', 'toggle', item)
+ self
+ end
+
+ def item_toggle_recurse(item)
+ tk_send('item', 'toggle', item, '-recurse')
+ self
+ end
+
+ def item_visible(item, st=None)
+ if st == None
+ bool(tk_send('item', 'visible', item))
+ else
+ tk_send('item', 'visible', item, st)
+ self
+ end
+ end
+ def item_visible?(item)
+ item_visible(item)
+ end
+
+ def marquee_anchor(*args)
+ if args.empty?
+ list(tk_send('marquee', 'anchor'))
+ else
+ tk_send('marquee', 'anchor', *args)
+ self
+ end
+ end
+
+ def marquee_coords(*args)
+ if args.empty?
+ list(tk_send('marquee', 'coords'))
+ else
+ tk_send('marquee', 'coords', *args)
+ self
+ end
+ end
+
+ def marquee_corner(*args)
+ if args.empty?
+ tk_send('marquee', 'corner')
+ else
+ tk_send('marquee', 'corner', *args)
+ self
+ end
+ end
+
+ def marquee_identify()
+ list(tk_send('marquee', 'identify')).collect!{|id|
+ Tk::TreeCtrl::Item.id2obj(self, id)
+ }
+ end
+
+ def marquee_visible(st=None)
+ if st == None
+ bool(tk_send('marquee', 'visible'))
+ else
+ tk_send('marquee', 'visible', st)
+ self
+ end
+ end
+ def marquee_visible?()
+ marquee_visible()
+ end
+
+ #def notify_bind(obj, event, cmd=Proc.new, *args)
+ # _bind([@path, 'notify', 'bind', obj], event, cmd, *args)
+ # self
+ #end
+ def notify_bind(obj, event, *args)
+ # if args[0].kind_of?(Proc) || args[0].kind_of?(Method)
+ if TkComm._callback_entry?(args[0]) || !block_given?
+ cmd = args.shift
+ else
+ cmd = Proc.new
+ end
+ _bind([@path, 'notify', 'bind', obj], event, cmd, *args)
+ self
+ end
+
+ #def notify_bind_append(obj, event, cmd=Proc.new, *args)
+ # _bind_append([@path, 'notify', 'bind', obj], event, cmd, *args)
+ # self
+ #end
+ def notify_bind_append(obj, event, *args)
+ # if args[0].kind_of?(Proc) || args[0].kind_of?(Method)
+ if TkComm._callback_entry?(args[0]) || !block_given?
+ cmd = args.shift
+ else
+ cmd = Proc.new
+ end
+ _bind_append([@path, 'notify', 'bind', obj], event, cmd, *args)
+ self
+ end
+
+ def notify_bind_remove(obj, event)
+ _bind_remove([@path, 'notify', 'bind', obj], event)
+ self
+ end
+
+ def notify_bindinfo(obj, event=nil)
+ _bindinfo([@path, 'notify', 'bind', obj], event)
+ end
+
+ def notify_detailnames(event)
+ list(tk_send('notify', 'detailnames', event))
+ end
+
+ def notify_eventnames()
+ list(tk_send('notify', 'eventnames'))
+ end
+
+ def notify_generate(pattern, char_map=None, percents_cmd=None)
+ pattern = "<#{pattern}>"
+ tk_send('notify', 'generate', pattern, char_map, percents_cmd)
+ self
+ end
+
+ def notify_install(pattern, percents_cmd=nil, &b)
+ pattern = "<#{pattern}>"
+ percents_cmd = Proc.new(&b) if !percents_cmd && b
+ if percents_cmd
+ procedure(tk_send('notify', 'install', pattern, percents_cmd))
+ else
+ procedure(tk_send('notify', 'install', pattern))
+ end
+ end
+
+ def notify_install_detail(event, detail, percents_cmd=nil, &b)
+ percents_cmd = Proc.new(&b) if !percents_cmd && b
+ if percents_cmd
+ tk_send('notify', 'install', 'detail', event, detail, percents_cmd)
+ else
+ tk_send('notify', 'install', 'detail', event, detail)
+ end
+ end
+
+ def notify_install_event(event, percents_cmd=nil, &b)
+ percents_cmd = Proc.new(&b) if !percents_cmd && b
+ if percents_cmd
+ tk_send('notify', 'install', 'event', event, percents_cmd)
+ else
+ tk_send('notify', 'install', 'event', event)
+ end
+ end
+
+ def notify_linkage(pattern, detail=None)
+ if detail != None
+ tk_send('notify', 'linkage', pattern, detail)
+ else
+ begin
+ if pattern.to_s.index(?-)
+ # TreeCtrl 1.1 format?
+ begin
+ tk_send('notify', 'linkage', "<#{pattern}>")
+ rescue
+ # TreeCtrl 1.0?
+ tk_send('notify', 'linkage', pattern)
+ end
+ else
+ # TreeCtrl 1.0 format?
+ begin
+ tk_send('notify', 'linkage', pattern)
+ rescue
+ # TreeCtrl 1.1?
+ tk_send('notify', 'linkage', "<#{pattern}>")
+ end
+ end
+ end
+ end
+ end
+
+ def notify_unbind(pattern=nil)
+ if pattern
+ tk_send('notify', 'unbind', "<#{pattern}>")
+ else
+ tk_send('notify', 'unbind')
+ end
+ self
+ end
+
+ def notify_uninstall(pattern)
+ pattern = "<#{pattern}>"
+ tk_send('notify', 'uninstall', pattern)
+ self
+ end
+
+ def notify_uninstall_detail(event, detail)
+ tk_send('notify', 'uninstall', 'detail', event, detail)
+ self
+ end
+
+ def notify_uninstall_event(event)
+ tk_send('notify', 'uninstall', 'event', event)
+ self
+ end
+
+ def numcolumns()
+ num_or_str(tk_send('numcolumns'))
+ end
+ alias num_columns numcolumns
+ alias columns_size numcolumns
+
+ def numitems()
+ num_or_str(tk_send('numitems'))
+ end
+ alias num_items numitems
+ alias items_size numitems
+
+ def orphans()
+ list(tk_send('orphans')).collect!{|id|
+ Tk::TreeCtrl::Item.id2obj(self, id)
+ }
+ end
+
+ def range(first, last)
+ list(tk_send('range', first, last)).collect!{|id|
+ Tk::TreeCtrl::Item.id2obj(self, id)
+ }
+ end
+
+ def state_define(name)
+ tk_send('state', 'define', name)
+ self
+ end
+
+ def state_linkage(name)
+ tk_send('state', 'linkage', name)
+ end
+
+ def state_names()
+ list(tk_send('state', 'names'))
+ end
+
+ def state_undefine(*names)
+ tk_send('state', 'undefine', *names)
+ self
+ end
+
+ def see(item, column=None, keys={})
+ tk_send('see', item, column, *hash_kv(keys))
+ self
+ end
+
+ def selection_add(first, last=None)
+ tk_send('selection', 'add', first, last)
+ self
+ end
+
+ def selection_anchor(item=None)
+ id = num_or_str(tk_send('selection', 'anchor', item))
+ Tk::TreeCtrl::Item.id2obj(self, id)
+ end
+
+ def selection_clear(*args) # first, last
+ tk_send('selection', 'clear', *args)
+ self
+ end
+
+ def selection_count()
+ number(tk_send('selection', 'count'))
+ end
+
+ def selection_get()
+ list(tk_send('selection', 'get')).collect!{|id|
+ Tk::TreeCtrl::Item.id2obj(self, id)
+ }
+ end
+
+ def selection_includes(item)
+ bool(tk_send('selection', 'includes', item))
+ end
+
+ def selection_modify(sel, desel)
+ tk_send('selection', 'modify', sel, desel)
+ self
+ end
+
+ def style_create(style, keys=None)
+ if keys && keys != None
+ tk_send('style', 'create', style, *hash_kv(keys))
+ else
+ tk_send('style', 'create', style)
+ end
+ end
+
+ def style_delete(*args)
+ Tk::TreeCtrl::Style::TreeCtrlStyleID_TBL.mutex.synchronize{
+ if Tk::TreeCtrl::Style::TreeCtrlStyleID_TBL[self.path]
+ args.each{|sty|
+ Tk::TreeCtrl::Style::TreeCtrlStyleID_TBL[self.path].delete(sty)
+ }
+ end
+ }
+ tk_send('style', 'delete', *args)
+ self
+ end
+
+ def style_elements(style, *elems)
+ if elems.empty?
+ list(tk_send('style', 'elements', style)).collect!{|id|
+ Tk::TreeCtrl::Element.id2obj(self, id)
+ }
+ else
+ tk_send('style', 'elements', style, elems.flatten)
+ self
+ end
+ end
+
+ def _conv_style_layout_val(sty, val)
+ case sty.to_s
+ when 'padx', 'pady', 'ipadx', 'ipady'
+ lst = list(val)
+ (lst.size == 1)? lst[0]: lst
+ when 'detach', 'indent'
+ bool(val)
+ when 'union'
+ simplelist(val).collect!{|elem|
+ Tk::TreeCtrl::Element.id2obj(self, elem)
+ }
+ else
+ val
+ end
+ end
+ private :_conv_style_layout_val
+
+ def style_layout(style, elem, keys=None)
+ if keys && keys != None
+ if keys.kind_of?(Hash)
+ tk_send('style', 'layout', style, elem, *hash_kv(keys))
+ self
+ else
+ _conv_style_layout_val(keys,
+ tk_send('style', 'layout',
+ style, elem, "-#{keys}"))
+ end
+ else
+ ret = Hash.new
+ Hash[*simplelist(tk_send('style', 'layout', style, elem))].each{|k, v|
+ k = k[1..-1]
+ ret[k] = _conv_style_layout_val(k, v)
+ }
+ ret
+ end
+ end
+ def get_style_layout(style, elem, opt=None)
+ style_layout(style, elem, opt)
+ end
+ def set_style_layout(style, elem, slot, value=None)
+ if slot.kind_of?(Hash)
+ style_layout(style, elem, slot)
+ else
+ style_layout(style, elem, {slot=>value})
+ end
+ end
+
+ def style_names()
+ list(tk_send('style', 'names')).collect!{|id|
+ Tk::TreeCtrl::Style.id2obj(self, id)
+ }
+ end
+
+ def toggle(*items)
+ tk_send('toggle', *items)
+ self
+ end
+
+ def toggle_recurse()
+ tk_send('toggle', '-recurse', *items)
+ self
+ end
+end
+
+#####################
+
+class Tk::TreeCtrl::Column < TkObject
+ TreeCtrlColumnID_TBL = TkCore::INTERP.create_table
+
+ (TreeCtrlColumnID = ['treectrl_column'.freeze, TkUtil.untrust('00000')]).instance_eval{
+ @mutex = Mutex.new
+ def mutex; @mutex; end
+ freeze
+ }
+
+ TkCore::INTERP.init_ip_env{
+ Tk::TreeCtrl::Column::TreeCtrlColumnID_TBL.mutex.synchronize{
+ Tk::TreeCtrl::Column::TreeCtrlColumnID_TBL.clear
+ }
+ }
+
+ def self.id2obj(tree, id)
+ tpath = tree.path
+ Tk::TreeCtrl::Column::TreeCtrlColumnID_TBL.mutex.synchronize{
+ if Tk::TreeCtrl::Column::TreeCtrlColumnID_TBL[tpath]
+ Tk::TreeCtrl::Column::TreeCtrlColumnID_TBL[tpath][id]? \
+ Tk::TreeCtrl::Column::TreeCtrlColumnID_TBL[tpath][id] : id
+ else
+ id
+ end
+ }
+ end
+
+ def initialize(parent, keys={})
+ @tree = parent
+ @tpath = parent.path
+
+ keys = _symbolkey2str(keys)
+
+ Tk::TreeCtrl::Column::TreeCtrlColumnID.mutex.synchronize{
+ @path = @id =
+ keys.delete('tag') ||
+ Tk::TreeCtrl::Column::TreeCtrlColumnID.join(TkCore::INTERP._ip_id_)
+ Tk::TreeCtrl::Column::TreeCtrlColumnID[1].succ!
+ }
+
+ keys['tag'] = @id
+
+ Tk::TreeCtrl::Column::TreeCtrlColumnID_TBL.mutex.synchronize{
+ Tk::TreeCtrl::Column::TreeCtrlColumnID_TBL[@tpath] ||= {}
+ Tk::TreeCtrl::Column::TreeCtrlColumnID_TBL[@tpath][@id] = self
+ }
+
+ @tree.column_create(keys)
+ end
+
+ def id
+ @id
+ end
+
+ def to_s
+ @id.to_s.dup
+ end
+
+ def cget_tkstring(opt)
+ @tree.column_cget_tkstring(@tree.column_index(@id), opt)
+ end
+ def cget(opt)
+ @tree.column_cget(@tree.column_index(@id), opt)
+ end
+ def cget_strict(opt)
+ @tree.column_cget_strict(@tree.column_index(@id), opt)
+ end
+
+ def configure(*args)
+ @tree.column_configure(@tree.column_index(@id), *args)
+ end
+
+ def configinfo(*args)
+ @tree.column_configinfo(@tree.column_index(@id), *args)
+ end
+
+ def current_configinfo(*args)
+ @tree.current_column_configinfo(@tree.column_index(@id), *args)
+ end
+
+ def delete
+ @tree.column_delete(@tree.column_index(@id))
+ self
+ end
+
+ def index
+ @tree.column_index(@id)
+ end
+
+ def move(before)
+ @tree.column_move(@tree.column_index(@id), before)
+ self
+ end
+
+ def needed_width
+ @tree.column_needed_width(@tree.column_index(@id))
+ end
+ alias neededwidth needed_width
+
+ def current_width
+ @tree.column_width(@tree.column_index(@id))
+ end
+end
+
+#####################
+
+class Tk::TreeCtrl::Element < TkObject
+ TreeCtrlElementID_TBL = TkCore::INTERP.create_table
+
+ (TreeCtrlElementID = ['treectrl_element'.freeze, TkUtil.untrust('00000')]).instance_eval{
+ @mutex = Mutex.new
+ def mutex; @mutex; end
+ freeze
+ }
+ TreeCtrlElemTypeToClass = {}
+
+ TkCore::INTERP.init_ip_env{
+ Tk::TreeCtrl::Element::TreeCtrlElementID_TBL.mutex.synchronize{
+ Tk::TreeCtrl::Element::TreeCtrlElementID_TBL.clear
+ }
+ }
+
+ def self.type2class(type)
+ TreeCtrlElemTypeToClass[type] || type
+ end
+
+ def self.id2obj(tree, id)
+ tpath = tree.path
+ Tk::TreeCtrl::Element::TreeCtrlElementID_TBL.mutex.synchronize{
+ if Tk::TreeCtrl::Element::TreeCtrlElementID_TBL[tpath]
+ Tk::TreeCtrl::Element::TreeCtrlElementID_TBL[tpath][id]? \
+ Tk::TreeCtrl::Element::TreeCtrlElementID_TBL[tpath][id] : id
+ else
+ id
+ end
+ }
+ end
+
+ def initialize(parent, type, keys=nil)
+ @tree = parent
+ @tpath = parent.path
+ @type = type.to_s
+ Tk::TreeCtrl::Element::TreeCtrlElementID.mutex.synchronize{
+ @path = @id =
+ Tk::TreeCtrl::Element::TreeCtrlElementID.join(TkCore::INTERP._ip_id_)
+ Tk::TreeCtrl::Element::TreeCtrlElementID[1].succ!
+ }
+
+ Tk::TreeCtrl::Element::TreeCtrlElementID_TBL.mutex.synchronize{
+ Tk::TreeCtrl::Element::TreeCtrlElementID_TBL[@tpath] ||= {}
+ Tk::TreeCtrl::Element::TreeCtrlElementID_TBL[@tpath][@id] = self
+ }
+
+ @tree.element_create(@id, @type, keys)
+ end
+
+ def id
+ @id
+ end
+
+ def to_s
+ @id.dup
+ end
+
+ def cget_tkstring(opt)
+ @tree.element_cget_tkstring(@id, opt)
+ end
+ def cget(opt)
+ @tree.element_cget(@id, opt)
+ end
+ def cget_strict(opt)
+ @tree.element_cget_strict(@id, opt)
+ end
+
+ def configure(*args)
+ @tree.element_configure(@id, *args)
+ end
+
+ def configinfo(*args)
+ @tree.element_configinfo(@id, *args)
+ end
+
+ def current_configinfo(*args)
+ @tree.current_element_configinfo(@id, *args)
+ end
+
+ def delete
+ @tree.element_delete(@id)
+ self
+ end
+
+ def element_type
+ @tree.element_type(@id)
+ end
+
+ def element_class
+ @tree.element_class(@id)
+ end
+end
+
+class Tk::TreeCtrl::BitmapElement < Tk::TreeCtrl::Element
+ TreeCtrlElemTypeToClass['bitmap'] = self
+
+ def initialize(parent, keys=nil)
+ super(parent, 'bitmap', keys)
+ end
+end
+
+class Tk::TreeCtrl::BorderElement < Tk::TreeCtrl::Element
+ TreeCtrlElemTypeToClass['border'] = self
+
+ def initialize(parent, keys=nil)
+ super(parent, 'border', keys)
+ end
+end
+
+class Tk::TreeCtrl::ImageElement < Tk::TreeCtrl::Element
+ TreeCtrlElemTypeToClass['image'] = self
+
+ def initialize(parent, keys=nil)
+ super(parent, 'image', keys)
+ end
+end
+
+class Tk::TreeCtrl::RectangleElement < Tk::TreeCtrl::Element
+ TreeCtrlElemTypeToClass['rect'] = self
+
+ def initialize(parent, keys=nil)
+ super(parent, 'rect', keys)
+ end
+end
+
+#####################
+
+class Tk::TreeCtrl::Item < TkObject
+ TreeCtrlItemID_TBL = TkCore::INTERP.create_table
+
+ TkCore::INTERP.init_ip_env{
+ Tk::TreeCtrl::Item::TreeCtrlItemID_TBL.mutex.synchronize{
+ Tk::TreeCtrl::Item::TreeCtrlItemID_TBL.clear
+ }
+ }
+
+ def self.id2obj(tree, id)
+ tpath = tree.path
+ Tk::TreeCtrl::Item::TreeCtrlItemID_TBL.mutex.synchronize{
+ if Tk::TreeCtrl::Item::TreeCtrlItemID_TBL[tpath]
+ Tk::TreeCtrl::Item::TreeCtrlItemID_TBL[tpath][id]? \
+ Tk::TreeCtrl::Item::TreeCtrlItemID_TBL[tpath][id] : id
+ else
+ id
+ end
+ }
+ end
+
+ def initialize(parent, keys={})
+ @tree = parent
+ @tpath = parent.path
+ @path = @id = @tree.item_create(keys)
+
+ Tk::TreeCtrl::Item::TreeCtrlItemID_TBL.mutex.synchronize{
+ Tk::TreeCtrl::Item::TreeCtrlItemID_TBL[@tpath] ||= {}
+ Tk::TreeCtrl::Item::TreeCtrlItemID_TBL[@tpath][@id] = self
+ }
+ end
+
+ def id
+ @id
+ end
+
+ def to_s
+ @id.to_s.dup
+ end
+
+ def ancestors
+ @tree.item_ancestors(@id)
+ end
+
+ def bbox(*args)
+ @tree.item_bbox(@id, *args)
+ end
+
+ def children
+ @tree.item_children(@id)
+ end
+
+ def collapse
+ @tree.item_collapse(@id)
+ self
+ end
+
+ def collapse_recurse
+ @tree.item_collapse_recurse(@id)
+ self
+ end
+
+ def complex(*args)
+ @tree.item_complex(@id, *args)
+ self
+ end
+
+ def cget_tkstring(opt)
+ @tree.item_cget_tkstring(@id, opt)
+ end
+ def cget(opt)
+ @tree.item_cget(@id, opt)
+ end
+ def cget_strict(opt)
+ @tree.item_cget_strict(@id, opt)
+ end
+
+ def configure(*args)
+ @tree.item_configure(@id, *args)
+ end
+
+ def configinfo(*args)
+ @tree.item_configinfo(@id, *args)
+ end
+
+ def current_configinfo(*args)
+ @tree.current_item_configinfo(@id, *args)
+ end
+
+ def delete
+ @tree.item_delete(@id)
+ self
+ end
+
+ def element_dump
+ @tree.item_dump(@id)
+ end
+
+ def element_dump_hash
+ @tree.item_dump_hash(@id)
+ end
+
+ def element_actual(column, elem, key)
+ @tree.item_element_actual(@id, column, elem, key)
+ end
+
+ def element_cget_tkstring(opt)
+ @tree.item_element_cget(@id, opt)
+ end
+ def element_cget_tkstring(opt)
+ @tree.item_element_cget(@id, opt)
+ end
+ def element_cget_strict(opt)
+ @tree.item_element_cget_strict(@id, opt)
+ end
+
+ def element_configure(*args)
+ @tree.item_element_configure(@id, *args)
+ end
+
+ def element_configinfo(*args)
+ @tree.item_element_configinfo(@id, *args)
+ end
+
+ def current_element_configinfo(*args)
+ @tree.current_item_element_configinfo(@id, *args)
+ end
+
+ def expand
+ @tree.item_expand(@id)
+ self
+ end
+
+ def expand_recurse
+ @tree.item_expand_recurse(@id)
+ self
+ end
+
+ def firstchild(child=nil)
+ if child
+ @tree.item_firstchild(@id, child)
+ self
+ else
+ @tree.item_firstchild(@id)
+ end
+ end
+ alias first_child firstchild
+
+ def hasbutton(st=None)
+ if st == None
+ @tree.item_hasbutton(@id)
+ else
+ @tree.item_hasbutton(@id, st)
+ self
+ end
+ end
+ alias has_button hasbutton
+
+ def hasbutton?
+ @tree.item_hasbutton(@id)
+ end
+ alias has_button? hasbutton?
+
+ def index
+ @tree.item_index(@id)
+ end
+
+ def isancestor(des)
+ @tree.item_isancestor(@id, des)
+ end
+ alias is_ancestor isancestor
+ alias isancestor? isancestor
+ alias is_ancestor? isancestor
+ alias ancestor? isancestor
+
+ def isopen
+ @tree.item_isopen(@id)
+ end
+ alias is_open isopen
+ alias isopen? isopen
+ alias is_open? isopen
+ alias isopened? isopen
+ alias is_opened? isopen
+ alias open? isopen
+
+ def lastchild(child=nil)
+ if child
+ @tree.item_lastchild(@id, child)
+ self
+ else
+ @tree.item_lastchild(@id)
+ end
+ end
+ alias last_child lastchild
+
+ def nextsibling(nxt=nil)
+ if nxt
+ @tree.item_nextsibling(@id, nxt)
+ self
+ else
+ @tree.item_nextsibling(@id)
+ end
+ end
+ alias next_sibling nextsibling
+
+ def numchildren
+ @tree.item_numchildren(@id)
+ end
+ alias num_children numchildren
+ alias children_size numchildren
+
+ def parent_index
+ @tree.item_parent(@id)
+ end
+
+ def prevsibling(nxt=nil)
+ if nxt
+ @tree.item_prevsibling(@id, nxt)
+ self
+ else
+ @tree.item_prevsibling(@id)
+ end
+ end
+ alias prev_sibling prevsibling
+
+ def remove
+ @tree.item_remove(@id)
+ end
+
+ def rnc
+ @tree.item_rnc(@id)
+ end
+
+ def sort(*opts)
+ @tree.item_sort(@id, *opts)
+ end
+ def sort_not_really(*opts)
+ @tree.item_sort_not_really(@id, *opts)
+ self
+ end
+
+ def state_forcolumn(column, *args)
+ @tree.item_state_forcolumn(@id, column, *args)
+ self
+ end
+ alias state_for_column state_forcolumn
+
+ def state_get(*args)
+ @tree.item_state_get(@id, *args)
+ end
+
+ def state_set(*args)
+ @tree.item_state_set(@id, *args)
+ self
+ end
+
+ def style_elements(column)
+ @tree.item_style_elements(@id, column)
+ end
+
+ def style_map(column, style, map)
+ @tree.item_style_map(@id, column, style, map)
+ self
+ end
+
+ def style_set(column=nil, *args)
+ if args.empty?
+ @tree.item_style_set(@id, column)
+ else
+ @tree.item_style_set(@id, column, *args)
+ self
+ end
+ end
+
+ def item_text(column, txt=nil, *args)
+ if args.empty?
+ if txt
+ @tree.item_text(@id, column, txt)
+ self
+ else
+ @tree.item_text(@id, column)
+ end
+ else
+ @tree.item_text(@id, column, txt, *args)
+ self
+ end
+ end
+
+ def toggle
+ @tree.item_toggle(@id)
+ self
+ end
+
+ def toggle_recurse
+ @tree.item_toggle_recurse(@id)
+ self
+ end
+
+ def visible(st=None)
+ if st == None
+ @tree.item_visible(@id)
+ else
+ @tree.item_visible(@id, st)
+ self
+ end
+ end
+end
+
+#####################
+
+class Tk::TreeCtrl::Style < TkObject
+ TreeCtrlStyleID_TBL = TkCore::INTERP.create_table
+
+ (TreeCtrlStyleID = ['treectrl_style'.freeze, TkUtil.untrust('00000')]).instance_eval{
+ @mutex = Mutex.new
+ def mutex; @mutex; end
+ freeze
+ }
+
+ TkCore::INTERP.init_ip_env{
+ Tk::TreeCtrl::Style::TreeCtrlStyleID_TBL.mutex.synchronize{
+ Tk::TreeCtrl::Style::TreeCtrlStyleID_TBL.clear
+ }
+ }
+
+ def self.id2obj(tree, id)
+ tpath = tree.path
+ Tk::TreeCtrl::Style::TreeCtrlStyleID_TBL.mutex.synchronize{
+ if Tk::TreeCtrl::Style::TreeCtrlStyleID_TBL[tpath]
+ Tk::TreeCtrl::Style::TreeCtrlStyleID_TBL[tpath][id]? \
+ Tk::TreeCtrl::Style::TreeCtrlStyleID_TBL[tpath][id] : id
+ else
+ id
+ end
+ }
+ end
+
+ def initialize(parent, keys=nil)
+ @tree = parent
+ @tpath = parent.path
+
+ Tk::TreeCtrl::Style::TreeCtrlStyleID.mutex.synchronize{
+ @path = @id =
+ Tk::TreeCtrl::Style::TreeCtrlStyleID.join(TkCore::INTERP._ip_id_)
+ Tk::TreeCtrl::Style::TreeCtrlStyleID[1].succ!
+ }
+
+ Tk::TreeCtrl::Style::TreeCtrlStyleID_TBL.mutex.synchronize{
+ Tk::TreeCtrl::Style::TreeCtrlStyleID_TBL[@tpath] ||= {}
+ Tk::TreeCtrl::Style::TreeCtrlStyleID_TBL[@tpath][@id] = self
+ }
+
+ @tree.style_create(@id, keys)
+ end
+
+ def id
+ @id
+ end
+
+ def to_s
+ @id.dup
+ end
+
+ def cget_tkstring(opt)
+ @tree.style_cget_tkstring(@id, opt)
+ end
+ def cget(opt)
+ @tree.style_cget(@id, opt)
+ end
+ def cget_strict(opt)
+ @tree.style_cget_strict(@id, opt)
+ end
+
+ def configure(*args)
+ @tree.style_configure(@id, *args)
+ end
+
+ def configinfo(*args)
+ @tree.style_configinfo(@id, *args)
+ end
+
+ def current_configinfo(*args)
+ @tree.current_style_configinfo(@id, *args)
+ end
+
+ def delete
+ @tree.style_delete(@id)
+ self
+ end
+
+ def elements(*elems)
+ if elems.empty?
+ @tree.style_elements(@id)
+ else
+ @tree.style_elements(@id, *elems)
+ self
+ end
+ end
+
+ def layout(elem, keys=None)
+ if keys && keys != None && keys.kind_of?(Hash)
+ @tree.style_layout(@id, elem, keys)
+ self
+ else
+ @tree.style_layout(@id, elem, keys)
+ end
+ end
+end
+
+module Tk::TreeCtrl::BindCallback
+ include Tk
+ extend Tk
+end
+
+class << Tk::TreeCtrl::BindCallback
+ def percentsCmd(*args)
+ tk_call('::TreeCtrl::PercentsCmd', *args)
+ end
+ def cursorCheck(w, x, y)
+ tk_call('::TreeCtrl::CursorCheck', w, x, y)
+ end
+ def cursorCheckAux(w)
+ tk_call('::TreeCtrl::CursorCheckAux', w)
+ end
+ def cursorCancel(w)
+ tk_call('::TreeCtrl::CursorCancel', w)
+ end
+ def buttonPress1(w, x, y)
+ tk_call('::TreeCtrl::ButtonPress1', w, x, y)
+ end
+ def doubleButton1(w, x, y)
+ tk_call('::TreeCtrl::DoubleButton1', w, x, y)
+ end
+ def motion1(w, x, y)
+ tk_call('::TreeCtrl::Motion1', w, x, y)
+ end
+ def leave1(w, x, y)
+ tk_call('::TreeCtrl::Leave1', w, x, y)
+ end
+ def release1(w, x, y)
+ tk_call('::TreeCtrl::Release1', w, x, y)
+ end
+ def beginSelect(w, el)
+ tk_call('::TreeCtrl::BeginSelect', w, el)
+ end
+ def motion(w, le)
+ tk_call('::TreeCtrl::Motion', w, el)
+ end
+ def beginExtend(w, el)
+ tk_call('::TreeCtrl::BeginExtend', w, el)
+ end
+ def beginToggle(w, el)
+ tk_call('::TreeCtrl::BeginToggle', w, el)
+ end
+ def cancelRepeat
+ tk_call('::TreeCtrl::CancelRepeat')
+ end
+ def autoScanCheck(w, x, y)
+ tk_call('::TreeCtrl::AutoScanCheck', w, x, y)
+ end
+ def autoScanCheckAux(w)
+ tk_call('::TreeCtrl::AutoScanCheckAux', w)
+ end
+ def autoScanCancel(w)
+ tk_call('::TreeCtrl::AutoScanCancel', w)
+ end
+ def up_down(w, n)
+ tk_call('::TreeCtrl::UpDown', w, n)
+ end
+ def left_right(w, n)
+ tk_call('::TreeCtrl::LeftRight', w, n)
+ end
+ def setActiveItem(w, idx)
+ tk_call('::TreeCtrl::SetActiveItem', w, idx)
+ end
+ def extendUpDown(w, amount)
+ tk_call('::TreeCtrl::ExtendUpDown', w, amount)
+ end
+ def dataExtend(w, el)
+ tk_call('::TreeCtrl::DataExtend', w, el)
+ end
+ def cancel(w)
+ tk_call('::TreeCtrl::Cancel', w)
+ end
+ def selectAll(w)
+ tk_call('::TreeCtrl::selectAll', w)
+ end
+ def marqueeBegin(w, x, y)
+ tk_call('::TreeCtrl::MarqueeBegin', w, x, y)
+ end
+ def marqueeUpdate(w, x, y)
+ tk_call('::TreeCtrl::MarqueeUpdate', w, x, y)
+ end
+ def marqueeEnd(w, x, y)
+ tk_call('::TreeCtrl::MarqueeEnd', w, x, y)
+ end
+ def scanMark(w, x, y)
+ tk_call('::TreeCtrl::ScanMark', w, x, y)
+ end
+ def scanDrag(w, x, y)
+ tk_call('::TreeCtrl::ScanDrag', w, x, y)
+ end
+
+ # filelist-bindings
+ def fileList_button1(w, x, y)
+ tk_call('::TreeCtrl::FileListButton1', w, x, y)
+ end
+ def fileList_motion1(w, x, y)
+ tk_call('::TreeCtrl::FileListMotion1', w, x, y)
+ end
+ def fileList_motion(w, x, y)
+ tk_call('::TreeCtrl::FileListMotion', w, x, y)
+ end
+ def fileList_leave1(w, x, y)
+ tk_call('::TreeCtrl::FileListLeave1', w, x, y)
+ end
+ def fileList_release1(w, x, y)
+ tk_call('::TreeCtrl::FileListRelease1', w, x, y)
+ end
+ def fileList_edit(w, i, s, e)
+ tk_call('::TreeCtrl::FileListEdit', w, i, s, e)
+ end
+ def fileList_editCancel(w)
+ tk_call('::TreeCtrl::FileListEditCancel', w)
+ end
+ def fileList_autoScanCheck(w, x, y)
+ tk_call('::TreeCtrl::FileListAutoScanCheck', w, x, y)
+ end
+ def fileList_autoScanCheckAux(w)
+ tk_call('::TreeCtrl::FileListAutoScanCheckAux', w)
+ end
+
+ def entryOpen(w, item, col, elem)
+ tk_call('::TreeCtrl::EntryOpen', w, item, col, elem)
+ end
+ def entryExpanderOpen(w, item, col, elem)
+ tk_call('::TreeCtrl::EntryExpanderOpen', w, item, col, elem)
+ end
+ def entryClose(w, accept)
+ tk_call('::TreeCtrl::EntryClose', w, accept)
+ end
+ def entryExpanderKeypress(w)
+ tk_call('::TreeCtrl::EntryExpanderKeypress', w)
+ end
+ def textOpen(w, item, col, elem, width=0, height=0)
+ tk_call('::TreeCtrl::TextOpen', w, item, col, elem, width, height)
+ end
+ def textExpanderOpen(w, item, col, elem, width)
+ tk_call('::TreeCtrl::TextOpen', w, item, col, elem, width)
+ end
+ def textClose(w, accept)
+ tk_call('::TreeCtrl::TextClose', w, accept)
+ end
+ def textExpanderKeypress(w)
+ tk_call('::TreeCtrl::TextExpanderKeypress', w)
+ end
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/trofs.rb b/jni/ruby/ext/tk/lib/tkextlib/trofs.rb
new file mode 100644
index 0000000..5914e51
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/trofs.rb
@@ -0,0 +1,13 @@
+#
+# trofs support
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+
+# call setup script for general 'tkextlib' libraries
+require 'tkextlib/setup.rb'
+
+# call setup script
+require 'tkextlib/trofs/setup.rb'
+
+# load library
+require 'tkextlib/trofs/trofs.rb'
diff --git a/jni/ruby/ext/tk/lib/tkextlib/trofs/setup.rb b/jni/ruby/ext/tk/lib/tkextlib/trofs/setup.rb
new file mode 100644
index 0000000..ee406c6
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/trofs/setup.rb
@@ -0,0 +1,8 @@
+#
+# setup.rb -- setup script before calling TkPackage.require()
+#
+# If you need some setup operations (for example, add a library path
+# to the library search path) before using Tcl/Tk library packages
+# wrapped by Ruby scripts in this directory, please write the setup
+# operations in this file.
+#
diff --git a/jni/ruby/ext/tk/lib/tkextlib/trofs/trofs.rb b/jni/ruby/ext/tk/lib/tkextlib/trofs/trofs.rb
new file mode 100644
index 0000000..7a2606a
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/trofs/trofs.rb
@@ -0,0 +1,51 @@
+#
+# tkextlib/trofs/trofs.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+
+require 'tk'
+
+# call setup script for general 'tkextlib' libraries
+require 'tkextlib/setup.rb'
+
+# call setup script
+require 'tkextlib/trofs/setup.rb'
+
+# TkPackage.require('trofs', '0.4')
+TkPackage.require('trofs')
+
+module Tk
+ module Trofs
+ extend TkCore
+
+ PACKAGE_NAME = 'trofs'.freeze
+ def self.package_name
+ PACKAGE_NAME
+ end
+
+ def self.package_version
+ begin
+ TkPackage.require('trofs')
+ rescue
+ ''
+ end
+ end
+
+ ##############################################
+
+ def self.create_archive(dir, archive)
+ tk_call('::trofs::archive', dir, archive)
+ archive
+ end
+
+ def self.mount(archive, mountpoint=None)
+ # returns the normalized path to mountpoint
+ tk_call('::trofs::mount', archive, mountpoint)
+ end
+
+ def self.umount(mountpoint)
+ tk_call('::trofs::umount', mountpoint)
+ mountpoint
+ end
+ end
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/version.rb b/jni/ruby/ext/tk/lib/tkextlib/version.rb
new file mode 100644
index 0000000..4bef78f
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/version.rb
@@ -0,0 +1,6 @@
+#
+# release date of tkextlib
+#
+module Tk
+ Tkextlib_RELEASE_DATE = '2010-02-01'.freeze
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/vu.rb b/jni/ruby/ext/tk/lib/tkextlib/vu.rb
new file mode 100644
index 0000000..d2234eb
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/vu.rb
@@ -0,0 +1,48 @@
+#
+# The vu widget set support
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+
+require 'tk'
+
+# call setup script for general 'tkextlib' libraries
+require 'tkextlib/setup.rb'
+
+# call setup script
+require 'tkextlib/vu/setup.rb'
+
+# load package
+# TkPackage.require('vu', '2.1')
+TkPackage.require('vu')
+
+# autoload
+module Tk
+ module Vu
+ TkComm::TkExtlibAutoloadModule.unshift(self)
+
+ PACKAGE_NAME = 'vu'.freeze
+ def self.package_name
+ PACKAGE_NAME
+ end
+
+ def self.package_version
+ begin
+ TkPackage.require('vu')
+ rescue
+ ''
+ end
+ end
+
+ ##########################################
+
+ autoload :Dial, 'tkextlib/vu/dial'
+
+ autoload :Pie, 'tkextlib/vu/pie'
+ autoload :PieSlice, 'tkextlib/vu/pie'
+ autoload :NamedPieSlice, 'tkextlib/vu/pie'
+
+ autoload :Spinbox, 'tkextlib/vu/spinbox'
+
+ autoload :Bargraph, 'tkextlib/vu/bargraph'
+ end
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/vu/bargraph.rb b/jni/ruby/ext/tk/lib/tkextlib/vu/bargraph.rb
new file mode 100644
index 0000000..b9fcf92
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/vu/bargraph.rb
@@ -0,0 +1,61 @@
+#
+# ::vu::bargraph widget
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+require 'tk'
+
+# create module/class
+module Tk
+ module Vu
+ class Bargraph < TkWindow
+ end
+ end
+end
+
+
+# call setup script -- <libdir>/tkextlib/vu.rb
+require 'tkextlib/vu.rb'
+
+class Tk::Vu::Bargraph < TkWindow
+ TkCommandNames = ['::vu::bargraph'.freeze].freeze
+ WidgetClassName = 'Bargraph'.freeze
+ WidgetClassNames[WidgetClassName] ||= self
+
+ ###############################
+
+ def __boolval_optkeys
+ ['showminmax', 'showvalue']
+ end
+ private :__boolval_optkeys
+
+ def __strval_optkeys
+ super() + [
+ 'title',
+ 'barbackground', 'barcolor', 'barcolour',
+ 'tickcolor', 'tickcolour',
+ 'textcolor', 'textcolour',
+ ]
+ end
+ private :__strval_optkeys
+
+ def __listval_optkeys
+ ['alabels', 'blabels']
+ end
+ private :__listval_optkeys
+
+ def __font_optkeys
+ ['alabfont', 'blabfont']
+ end
+ private :__font_optkeys
+
+ ###############################
+
+ def set(val = None)
+ tk_call_without_enc(@path, 'set', val)
+ self
+ end
+
+ def get()
+ num_or_str(tk_call_without_enc(@path, 'get'))
+ end
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/vu/charts.rb b/jni/ruby/ext/tk/lib/tkextlib/vu/charts.rb
new file mode 100644
index 0000000..8569ac5
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/vu/charts.rb
@@ -0,0 +1,53 @@
+#
+# charts -- Create and manipulate canvas Add-On Items
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+require 'tk'
+require 'tk/canvas'
+
+# call setup script -- <libdir>/tkextlib/vu.rb
+require 'tkextlib/vu.rb'
+
+module Tk
+ module Vu
+ module ChartsConfig
+ include TkItemConfigOptkeys
+ def __item_boolval_optkeys(id)
+ super(id) << 'lefttrunc' << 'autocolor'
+ end
+ private :__item_boolval_optkeys
+
+ def __item_strval_optkeys(id)
+ super(id) << 'bar' << 'color' << 'outline' <<
+ 'fill' << 'scaleline' << 'stripline'
+ end
+ private :__item_strval_optkeys
+
+ def __item_listval_optkeys(id)
+ super(id) << 'values' << 'tags'
+ end
+ private :__item_listval_optkeys
+ end
+
+ class TkcSticker < TkcItem
+ include ChartsConfig
+
+ CItemTypeName = 'sticker'.freeze
+ CItemTypeToClass[CItemTypeName] = self
+ end
+
+ class TkcStripchart < TkcItem
+ include ChartsConfig
+
+ CItemTypeName = 'stripchart'.freeze
+ CItemTypeToClass[CItemTypeName] = self
+ end
+
+ class TkcBarchart < TkcItem
+ include ChartsConfig
+
+ CItemTypeName = 'barchart'.freeze
+ CItemTypeToClass[CItemTypeName] = self
+ end
+ end
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/vu/dial.rb b/jni/ruby/ext/tk/lib/tkextlib/vu/dial.rb
new file mode 100644
index 0000000..4d04974
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/vu/dial.rb
@@ -0,0 +1,102 @@
+#
+# ::vu::dial widget
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+require 'tk'
+
+# create module/class
+module Tk
+ module Vu
+ class Dial < TkWindow
+ end
+ end
+end
+
+# call setup script -- <libdir>/tkextlib/vu.rb
+require 'tkextlib/vu.rb'
+
+# define module/class
+class Tk::Vu::Dial < TkWindow
+ TkCommandNames = ['::vu::dial'.freeze].freeze
+ WidgetClassName = 'Dial'.freeze
+ WidgetClassNames[WidgetClassName] ||= self
+
+ ###############################
+
+ def __methodcall_optkeys # { key=>method, ... }
+ {'coords'=>'coords'}
+ end
+ private :__methodcall_optkeys
+
+ ###############################
+
+ def coords(val = nil)
+ if val
+ tk_send_without_enc('coords', val)
+ self
+ else
+ tk_split_list(tk_send_without_enc('coords'))
+ end
+ end
+
+ def constrain(val = None)
+ num_or_str(tk_call(@path, 'constrain', val))
+ end
+
+ def get(*args)
+ num_or_str(tk_call(@path, 'get', *args))
+ end
+
+ def identify(x, y)
+ tk_call(@path, 'identify', x, y)
+ end
+
+ def get_label(val=nil)
+ if val
+ tk_call(@path, 'label', val)
+ else
+ ret = []
+ lst = simplelist(tk_call(@path, 'label'))
+ while lst.size > 0
+ ret << ([num_or_str(lst.shift)] << lst.shift)
+ end
+ end
+ end
+
+ def set_label(val, str, *args)
+ tk_call(@path, 'label', val, str, *args)
+ self
+ end
+
+ def set_label_constrain(val, str, *args)
+ tk_call(@path, 'label', '-constrain', val, str, *args)
+ self
+ end
+
+ def get_tag(val=nil)
+ if val
+ tk_call(@path, 'tag', val)
+ else
+ ret = []
+ lst = simplelist(tk_call(@path, 'tag'))
+ while lst.size > 0
+ ret << ([num_or_str(lst.shift)] << lst.shift)
+ end
+ end
+ end
+
+ def set_tag(val, str, *args)
+ tk_call(@path, 'tag', val, str, *args)
+ self
+ end
+
+ def set_tag_constrain(val, str, *args)
+ tk_call(@path, 'tag', '-constrain', val, str, *args)
+ self
+ end
+
+ def set(val = None)
+ tk_call_without_enc(@path, 'set', val)
+ self
+ end
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/vu/pie.rb b/jni/ruby/ext/tk/lib/tkextlib/vu/pie.rb
new file mode 100644
index 0000000..6b0c485
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/vu/pie.rb
@@ -0,0 +1,286 @@
+#
+# ::vu::pie widget
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+require 'tk'
+
+# create module/class
+module Tk
+ module Vu
+ module PieSliceConfigMethod
+ end
+ class Pie < TkWindow
+ end
+ class PieSlice < TkObject
+ end
+ class NamedPieSlice < PieSlice
+ end
+ end
+end
+
+# call setup script -- <libdir>/tkextlib/vu.rb
+require 'tkextlib/vu.rb'
+
+module Tk::Vu::PieSliceConfigMethod
+ include TkItemConfigMethod
+
+ def __item_pathname(tagOrId)
+ if tagOrId.kind_of?(Tk::Vu::PieSlice)
+ self.path + ';' + tagOrId.id.to_s
+ else
+ self.path + ';' + tagOrId.to_s
+ end
+ end
+ private :__item_pathname
+end
+
+class Tk::Vu::Pie < TkWindow
+ TkCommandNames = ['::vu::pie'.freeze].freeze
+ WidgetClassName = 'Pie'.freeze
+ WidgetClassNames[WidgetClassName] ||= self
+
+ def __destroy_hook__
+ Tk::Vu::PieSlice::SliceID_TBL.delete(@path)
+ end
+
+ ###############################
+
+ include Tk::Vu::PieSliceConfigMethod
+
+ def tagid(tag)
+ if tag.kind_of?(Tk::Vu::PieSlice)
+ tag.id
+ else
+ # tag
+ _get_eval_string(tag)
+ end
+ end
+
+ ###############################
+
+ def delete(*glob_pats)
+ tk_call(@path, 'delete', *glob_pats)
+ self
+ end
+
+ def explode(slice, *args)
+ tk_call(@path, 'explode', slice, *args)
+ self
+ end
+
+ def explode_value(slice)
+ num_or_str(tk_call(@path, 'explode', slice))
+ end
+
+ def lower(slice, below=None)
+ tk_call(@path, 'lower', slice, below)
+ self
+ end
+
+ def names(*glob_pats)
+ simplelist(tk_call(@path, 'names', *glob_pats))
+ end
+ alias slices names
+
+ def order(*args)
+ tk_call(@path, 'order', *args)
+ self
+ end
+
+ def raise(slice, above=None)
+ tk_call(@path, 'raise', slice, above)
+ self
+ end
+
+ def swap(slice1, slice2)
+ tk_call(@path, 'swap', slice1, slice2)
+ self
+ end
+
+ def set(slice, *args)
+ num_or_str(tk_call(@path, 'set', slice, *args))
+ end
+ alias set_value set
+ alias set_values set
+ alias create set
+
+ def slice_value(slice)
+ num_or_str(tk_call(@path, 'set', slice))
+ end
+
+ def value(val = None)
+ num_or_str(tk_call_without_enc(@path, 'value'))
+ end
+ alias sum_value value
+end
+
+class Tk::Vu::PieSlice
+ SliceID_TBL = TkCore::INTERP.create_table
+
+ (Pie_Slice_ID = ['vu:pie'.freeze, TkUtil.untrust('00000')]).instance_eval{
+ @mutex = Mutex.new
+ def mutex; @mutex; end
+ freeze
+ }
+
+ TkCore::INTERP.init_ip_env{
+ SliceID_TBL.mutex.synchronize{ SliceID_TBL.clear }
+ }
+
+ def self.id2obj(pie, id)
+ pie_path = pie.path
+ SliceID_TBL.mutex.synchronize{
+ if SliceID_TBL[pie_path]
+ SliceID_TBL[pie_path][id]? SliceID_TBL[pie_path][id]: id
+ else
+ id
+ end
+ }
+ end
+
+ def initialize(parent, *args)
+ unless parent.kind_of?(Tk::Vu::Pie)
+ fail ArgumentError, "expect a Tk::Vu::Pie instance for 1st argument"
+ end
+ @parent = @pie = parent
+ @ppath = parent.path
+ Pie_Slice_ID.mutex.synchronize{
+ @path = @id = Pie_Slice_ID.join(TkCore::INTERP._ip_id_)
+ Pie_Slice_ID[1].succ!
+ }
+ SliceID_TBL.mutex.synchronize{
+ SliceID_TBL[@ppath] = {} unless SliceID_TBL[@ppath]
+ SliceID_TBL[@ppath][@id] = self
+ }
+
+ if args[-1].kind_of?(Hash)
+ keys = args.unshift
+ end
+ @pie.set(@id, *args)
+ configure(keys)
+ end
+
+ def id
+ @id
+ end
+
+ def [](key)
+ cget key
+ end
+
+ def []=(key,val)
+ configure key, val
+ val
+ end
+
+ def cget_tkstring(slot)
+ @pie.itemcget_tkstring(@id, slot)
+ end
+
+ def cget(slot)
+ @pie.itemcget(@id, slot)
+ end
+
+ def cget_strict(slot)
+ @pie.itemcget_strict(@id, slot)
+ end
+
+ def configure(*args)
+ @pie.itemconfigure(@id, *args)
+ self
+ end
+
+ def configinfo(*args)
+ @pie.itemconfiginfo(@id, *args)
+ end
+
+ def current_configinfo(*args)
+ @pie.current_itemconfiginfo(@id, *args)
+ end
+
+ def delete
+ @pie.delete(@id)
+ end
+
+ def explode(value)
+ @pie.explode(@id, value)
+ self
+ end
+
+ def explode_value
+ @pie.explode_value(@id)
+ end
+
+ def lower(other=None)
+ @pie.lower(@id, other)
+ self
+ end
+
+ def raise(other=None)
+ @pie.raise(@id, other)
+ self
+ end
+
+ def set(value)
+ @pie.set(@id, value)
+ self
+ end
+ alias set_value set
+
+ def value
+ @pie.set(@id)
+ end
+end
+
+class Tk::Vu::NamedPieSlice
+ def self.new(parent, name, *args)
+ obj = nil
+ SliceID_TBL.mutex.synchronize{
+ if SliceID_TBL[parent.path] && SliceID_TBL[parent.path][name]
+ obj = SliceID_TBL[parent.path][name]
+ else
+ #super(parent, name, *args)
+ unless parent.kind_of?(Tk::Vu::Pie)
+ fail ArgumentError, "expect a Tk::Vu::Pie instance for 1st argument"
+ end
+ obj = self.allocate
+ obj.instance_eval{
+ @parent = @pie = parent
+ @ppath = parent.path
+ @path = @id = name.to_s
+ SliceID_TBL[@ppath] = {} unless SliceID_TBL[@ppath]
+ SliceID_TBL[@ppath][@id] = self
+ }
+ end
+ }
+ obj.instance_eval{
+ if args[-1].kind_of?(Hash)
+ keys = args.unshift
+ end
+ @pie.set(@id, *args)
+ configure(keys)
+ }
+
+ obj
+ end
+
+ def initialize(parent, name, *args)
+ # dummy:: not called by 'new' method
+ unless parent.kind_of?(Tk::Vu::Pie)
+ fail ArgumentError, "expect a Tk::Vu::Pie instance for 1st argument"
+ end
+ @parent = @pie = parent
+ @ppath = parent.path
+ @path = @id = name.to_s
+ SliceID_TBL.mutex.synchronize{
+ SliceID_TBL[@ppath] = {} unless SliceID_TBL[@ppath]
+ SliceID_TBL[@ppath][@id] = self
+ }
+
+ if args[-1].kind_of?(Hash)
+ keys = args.unshift
+ end
+ @pie.set(@id, *args)
+ configure(keys)
+ end
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/vu/setup.rb b/jni/ruby/ext/tk/lib/tkextlib/vu/setup.rb
new file mode 100644
index 0000000..ee406c6
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/vu/setup.rb
@@ -0,0 +1,8 @@
+#
+# setup.rb -- setup script before calling TkPackage.require()
+#
+# If you need some setup operations (for example, add a library path
+# to the library search path) before using Tcl/Tk library packages
+# wrapped by Ruby scripts in this directory, please write the setup
+# operations in this file.
+#
diff --git a/jni/ruby/ext/tk/lib/tkextlib/vu/spinbox.rb b/jni/ruby/ext/tk/lib/tkextlib/vu/spinbox.rb
new file mode 100644
index 0000000..7d6104f
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/vu/spinbox.rb
@@ -0,0 +1,22 @@
+#
+# ::vu::spinbox widget
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+# a standard spinbox (<= 8.3)
+# This is the same as the 8.4 core spinbox widget.
+#
+require 'tk'
+
+if (Tk::TK_MAJOR_VERSION < 8 ||
+ (Tk::TK_MAJOR_VERSION == 8 && Tk::TK_MINOR_VERSION < 4))
+ # call setup script -- <libdir>/tkextlib/vu.rb
+ require 'tkextlib/vu.rb'
+
+ Tk.tk_call('namespace', 'import', '::vu::spinbox')
+end
+
+module Tk
+ module Vu
+ Spinbox = Tk::Spinbox
+ end
+end
diff --git a/jni/ruby/ext/tk/lib/tkextlib/winico.rb b/jni/ruby/ext/tk/lib/tkextlib/winico.rb
new file mode 100644
index 0000000..ce7b8ea
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/winico.rb
@@ -0,0 +1,14 @@
+#
+# winico -- Windows Icon extension support
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+require 'tk'
+
+# call setup script for general 'tkextlib' libraries
+require 'tkextlib/setup.rb'
+
+# call setup script
+require 'tkextlib/tktable/setup.rb'
+
+# load library
+require 'tkextlib/winico/winico'
diff --git a/jni/ruby/ext/tk/lib/tkextlib/winico/setup.rb b/jni/ruby/ext/tk/lib/tkextlib/winico/setup.rb
new file mode 100644
index 0000000..ee406c6
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/winico/setup.rb
@@ -0,0 +1,8 @@
+#
+# setup.rb -- setup script before calling TkPackage.require()
+#
+# If you need some setup operations (for example, add a library path
+# to the library search path) before using Tcl/Tk library packages
+# wrapped by Ruby scripts in this directory, please write the setup
+# operations in this file.
+#
diff --git a/jni/ruby/ext/tk/lib/tkextlib/winico/winico.rb b/jni/ruby/ext/tk/lib/tkextlib/winico/winico.rb
new file mode 100644
index 0000000..9160c29
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkextlib/winico/winico.rb
@@ -0,0 +1,224 @@
+#
+# tkextlib/winico/winico.rb
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+
+require 'tk'
+
+# call setup script for general 'tkextlib' libraries
+require 'tkextlib/setup.rb'
+
+# call setup script
+require 'tkextlib/winico/setup.rb'
+
+# TkPackage.require('winico', '0.5')
+# TkPackage.require('winico', '0.6')
+TkPackage.require('winico')
+
+module Tk
+ class Winico < TkObject
+ PACKAGE_NAME = 'winico'.freeze
+ def self.package_name
+ PACKAGE_NAME
+ end
+
+ def self.package_version
+ begin
+ TkPackage.require('winico')
+ rescue
+ ''
+ end
+ end
+ end
+end
+
+class Tk::Winico
+ WinicoID_TBL = TkCore::INTERP.create_table
+
+ TkCore::INTERP.init_ip_env{
+ WinicoID_TBL.mutex.synchronize{ WinicoID_TBL.clear }
+ }
+
+ def self.id2obj(id)
+ WinicoID_TBL.mutex.synchronize{
+ (WinicoID_TBL.key?(id))? WinicoID_TBL[id] : id
+ }
+ end
+
+ def self.info
+ simplelist(Tk.tk_call('winico', 'info')).collect{|id|
+ Tk::Winico.id2obj(id)
+ }
+ end
+
+ def self.icon_info(id)
+ simplelist(Tk.tk_call('winico', 'info', id)).collect{|inf|
+ h = Hash[*list(inf)]
+ h.keys.each{|k| h[k[1..-1]] = h.delete(k)}
+ }
+ end
+
+ #################################
+
+ def self.new_from_file(file_name)
+ self.new(file_name)
+ end
+
+ def self.new_from_resource(resource_name, file_name = nil)
+ self.new(file_name, resource_name)
+ end
+
+ def initialize(file_name, resource_name=nil, winico_id=nil)
+ if resource_name
+ # from resource
+ if file_name
+ @id = Tk.tk_call('winico', 'load', resource_name, file_name)
+ else
+ @id = Tk.tk_call('winico', 'load', resource_name)
+ end
+ elsif file_name
+ # from .ico file
+ @id = Tk.tk_call('winico', 'createfrom', file_name)
+ elsif winico_id
+ @id = winico_id
+ else
+ fail ArgumentError,
+ "must be given proper information from where loading icons"
+ end
+ @path = @id
+ WinicoID_TBL.mutex.synchronize{
+ WinicoID_TBL[@id] = self
+ }
+ end
+
+ def id
+ @id
+ end
+
+ def set_window(win_id, *opts) # opts := ?'big'|'small'?, ?pos?
+ # NOTE:: the window, which is denoted by win_id, MUST BE MAPPED.
+ # If not, then this may fail or crash.
+ tk_call('winico', 'setwindow', win_id, @id, *opts)
+ end
+
+ def delete
+ tk_call('winico', 'delete', @id)
+ WinicoID_TBL.mutex.synchronize{
+ WinicoID_TBL.delete(@id)
+ }
+ self
+ end
+ alias destroy delete
+
+ def info
+ Tk::Winico.icon_info(@id)
+ end
+
+ #################################
+
+ class Winico_callback < TkValidateCommand
+ class ValidateArgs < TkUtil::CallbackSubst
+ KEY_TBL = [
+ [ ?m, ?s, :message ],
+ [ ?i, ?x, :icon ],
+ [ ?x, ?n, :x ],
+ [ ?y, ?n, :y ],
+ [ ?X, ?n, :last_x ],
+ [ ?Y, ?n, :last_y ],
+ [ ?t, ?n, :tickcount ],
+ [ ?w, ?n, :icon_idnum ],
+ [ ?l, ?n, :msg_idnum ],
+ nil
+ ]
+
+ PROC_TBL = [
+ [ ?n, TkComm.method(:number) ],
+ [ ?s, TkComm.method(:string) ],
+ [ ?x, proc{|id|
+ Tk::Winico::WinicoID_TBL.mutex.synchronize{
+ if Tk::Winico::WinicoID_TBL.key?(id)
+ obj = Tk::Winico::WinicoID_TBL[id]
+ else
+ # Tk::Winico.new(nil, nil, id)
+ obj = Tk::Winico.allocate
+ obj.instance_eval{ @path = @id = id }
+ Tk::Winico::WinicoID_TBL[id] = obj
+ end
+ obj
+ }
+ } ],
+ nil
+ ]
+
+=begin
+ # for Ruby m17n :: ?x --> String --> char-code ( getbyte(0) )
+ KEY_TBL.map!{|inf|
+ if inf.kind_of?(Array)
+ inf[0] = inf[0].getbyte(0) if inf[0].kind_of?(String)
+ inf[1] = inf[1].getbyte(0) if inf[1].kind_of?(String)
+ end
+ inf
+ }
+
+ PROC_TBL.map!{|inf|
+ if inf.kind_of?(Array)
+ inf[0] = inf[0].getbyte(0) if inf[0].kind_of?(String)
+ end
+ inf
+ }
+=end
+
+ _setup_subst_table(KEY_TBL, PROC_TBL);
+
+ def self.ret_val(val)
+ val
+ end
+ end
+
+ def self._config_keys
+ ['callback']
+ end
+ end
+
+ #################################
+
+ def add_to_taskbar(keys = {})
+ keys = _symbolkey2str(keys)
+ Winico_callback._config_keys.each{|k|
+ if keys[k].kind_of?(Array)
+ cmd, *args = keys[k]
+ #keys[k] = Winico_callback.new(cmd, args.join(' '))
+ keys[k] = Winico_callback.new(cmd, *args)
+ # elsif keys[k].kind_of?(Proc)
+ elsif TkComm._callback_entry?(keys[k])
+ keys[k] = Winico_callback.new(keys[k])
+ end
+ }
+ tk_call('winico', 'taskbar', 'add', @id, *(hash_kv(keys)))
+ self
+ end
+ alias taskbar_add add_to_taskbar
+
+ def modify_taskbar(keys = {})
+ keys = _symbolkey2str(keys)
+ Winico_callback._config_keys.each{|k|
+ if keys[k].kind_of?(Array)
+ cmd, *args = keys[k]
+ #keys[k] = Winico_callback.new(cmd, args.join(' '))
+ keys[k] = Winico_callback.new(cmd, *args)
+ # elsif keys[k].kind_of?(Proc)
+ elsif TkComm._callback_entry?(keys[k])
+ keys[k] = Winico_callback.new(keys[k])
+ end
+ }
+ tk_call('winico', 'taskbar', 'modify', @id, *(hash_kv(keys)))
+ self
+ end
+ alias taskbar_modify modify_taskbar
+
+ def delete_from_taskbar
+ tk_call('winico', 'taskbar', 'delete', @id)
+ self
+ end
+ alias taskbar_delete delete_from_taskbar
+end
diff --git a/jni/ruby/ext/tk/lib/tkfont.rb b/jni/ruby/ext/tk/lib/tkfont.rb
new file mode 100644
index 0000000..38a9663
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkfont.rb
@@ -0,0 +1,4 @@
+#
+# tkfont.rb - load tk/font.rb
+#
+require 'tk/font'
diff --git a/jni/ruby/ext/tk/lib/tkmacpkg.rb b/jni/ruby/ext/tk/lib/tkmacpkg.rb
new file mode 100644
index 0000000..35560e7
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkmacpkg.rb
@@ -0,0 +1,4 @@
+#
+# tkmacpkg.rb - load tk/macpkg.rb
+#
+require 'tk/macpkg'
diff --git a/jni/ruby/ext/tk/lib/tkmenubar.rb b/jni/ruby/ext/tk/lib/tkmenubar.rb
new file mode 100644
index 0000000..70214fd
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkmenubar.rb
@@ -0,0 +1,4 @@
+#
+# tkmenubar.rb - load tk/menubar.rb
+#
+require 'tk/menubar'
diff --git a/jni/ruby/ext/tk/lib/tkmngfocus.rb b/jni/ruby/ext/tk/lib/tkmngfocus.rb
new file mode 100644
index 0000000..fe70950
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkmngfocus.rb
@@ -0,0 +1,4 @@
+#
+# tkmngfocus.rb - load tk/mngfocus.rb
+#
+require 'tk/mngfocus'
diff --git a/jni/ruby/ext/tk/lib/tkpalette.rb b/jni/ruby/ext/tk/lib/tkpalette.rb
new file mode 100644
index 0000000..56b203b
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkpalette.rb
@@ -0,0 +1,4 @@
+#
+# tkpalette.rb - load tk/palette.rb
+#
+require 'tk/palette'
diff --git a/jni/ruby/ext/tk/lib/tkscrollbox.rb b/jni/ruby/ext/tk/lib/tkscrollbox.rb
new file mode 100644
index 0000000..6093b2e
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkscrollbox.rb
@@ -0,0 +1,4 @@
+#
+# tkscrollbox.rb - load tk/scrollbox.rb
+#
+require 'tk/scrollbox'
diff --git a/jni/ruby/ext/tk/lib/tktext.rb b/jni/ruby/ext/tk/lib/tktext.rb
new file mode 100644
index 0000000..97ad62a
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tktext.rb
@@ -0,0 +1,4 @@
+#
+# tktext.rb - load tk/text.rb
+#
+require 'tk/text'
diff --git a/jni/ruby/ext/tk/lib/tkvirtevent.rb b/jni/ruby/ext/tk/lib/tkvirtevent.rb
new file mode 100644
index 0000000..f4fae19
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkvirtevent.rb
@@ -0,0 +1,4 @@
+#
+# tkvirtevent.rb - load tk/virtevent.rb
+#
+require 'tk/virtevent'
diff --git a/jni/ruby/ext/tk/lib/tkwinpkg.rb b/jni/ruby/ext/tk/lib/tkwinpkg.rb
new file mode 100644
index 0000000..83371c5
--- /dev/null
+++ b/jni/ruby/ext/tk/lib/tkwinpkg.rb
@@ -0,0 +1,4 @@
+#
+# tkwinpkg.rb - load tk/winpkg.rb
+#
+require 'tk/winpkg'
diff --git a/jni/ruby/ext/tk/old-README.tcltklib.ja b/jni/ruby/ext/tk/old-README.tcltklib.ja
new file mode 100644
index 0000000..e29b389
--- /dev/null
+++ b/jni/ruby/ext/tk/old-README.tcltklib.ja
@@ -0,0 +1,159 @@
+(tof)
+ 2003/06/19 Hidetoshi NAGAI
+
+本ドキュメントã«ã¯å¤ã„ tcltk ライブラリ,tcltklib ライブラリã®èª¬æ˜Ž
+ãŒå«ã¾ã‚Œã¦ã„ã¾ã™ãŒï¼Œãã®è¨˜è¿°å†…容ã¯å¤ã„ã‚‚ã®ã¨ãªã£ã¦ã„ã¾ã™ï¼Ž
+
+ã¾ãšï¼Œç¾åœ¨ã® Ruby/Tk ã®ä¸­å¿ƒã§ã‚ã‚‹ tk.rb 㯠wish を呼ã³å‡ºã—ãŸã‚Šã¯ã›
+ãšï¼Œtcltklib ライブラリを wrap ã—ã¦å‹•ä½œã™ã‚‹ã‚‚ã®ã¨ãªã£ã¦ã„ã¾ã™ï¼Žãã®
+ãŸã‚,å¤ã„説明記述ã§è¿°ã¹ã‚‰ã‚Œã¦ã„るよã†ãªãƒ—ロセス間通信ã«ã‚ˆã‚‹ã‚ªãƒ¼ãƒ
+ヘッドã¯å­˜åœ¨ã—ã¾ã›ã‚“.
+
+ç¾åœ¨ã® tcltklib ライブラリã§ã‚‚,Tcl/Tk ã® C ライブラリをリンクã—ã¦
+直接ã«å‹•ã‹ã™ã“ã¨ã§ï¼Œã‚ªãƒ¼ãƒãƒ˜ãƒƒãƒ‰ã‚’押ã•ãˆã¤ã¤ Tcl/Tk インタープリタ
+ã®ã»ã¼å…¨æ©Ÿèƒ½ï¼ˆæ‹¡å¼µãƒ©ã‚¤ãƒ–ラリをå«ã‚€ï¼‰ã‚’使ãˆã‚‹ç‚¹ã¯åŒã˜ã§ã™ï¼Žã—ã‹ã—,
+ãã®å½¹å‰²ã¯ã»ã¼ã€Œtk.rb 以下ã®ãƒ©ã‚¤ãƒ–ラリを効果的ã«åƒã‹ã›ã‚‹ãŸã‚ã®ã‚‚ã®ã€
+ã¨è¦‹ãªã•ã‚Œã¦ãŠã‚Šï¼Œãã®ç›®çš„ã§ãƒ¡ãƒ³ãƒ†ãƒŠãƒ³ã‚¹ã•ã‚Œã¦ã„ã¾ã™ï¼Ž
+
+tk.rb ã®é«˜æ©Ÿèƒ½åŒ–ã«ä¼´ã£ã¦ï¼Œä¸­æ°´æº–ã®ãƒ©ã‚¤ãƒ–ラリã§ã‚ã‚‹ tcltk ライブラリ
+(tcltk.rb)ã¯ãã®å­˜åœ¨æ„義を減ã˜ã¦ãŠã‚Šï¼Œç¾åœ¨ã§ã¯ãƒ¡ãƒ³ãƒ†ãƒŠãƒ³ã‚¹ã¯è¡Œã‚
+ã‚Œã¦ã„ã¾ã›ã‚“.
+
+ãªãŠï¼Œå¤ã„説明ã§ã¯ãƒã‚¤ãƒ³ãƒ‡ã‚£ãƒ³ã‚°ã«ãŠã‘るスクリプトã®è¿½åŠ ã¯ã§ããªã„ã“
+ã¨ã¨ãªã£ã¦ã„ã¾ã™ãŒï¼Œç¾åœ¨ã® tk.rb ã§ã¯ã“れもå¯èƒ½ã§ã‚ã‚‹ã“ã¨ã‚’補足ã—ã¦
+ãŠãã¾ã™ï¼Ž
+
+以下ãŒãƒ©ã‚¤ãƒ–ラリã®å¤ã„説明文書ã§ã™ï¼Ž
+==============================================================
+ tcltk ライブラリ
+ tcltklib ライブラリ
+ Sep. 19, 1997 Y. Shigehiro
+
+以下, 「tcl/tkã€ã¨ã„ã†è¡¨è¨˜ã¯, tclsh ã‚„ wish を実ç¾ã—ã¦ã„ã‚‹, 一般ã§ã„ã†
+ã¨ã“ã‚ã® tcl/tk を指ã—ã¾ã™. 「tcltk ライブラリã€, 「tcltklib ライブラ
+リã€ã¨ã„ã†è¡¨è¨˜ã¯, 本パッケージã«å«ã¾ã‚Œã‚‹ ruby 用ã®ãƒ©ã‚¤ãƒ–ラリを指ã—ã¾ã™.
+
+[ファイルã«ã¤ã„ã¦]
+
+README.euc : ã“ã®ãƒ•ã‚¡ã‚¤ãƒ«(注æ„, 特徴, インストールã®æ–¹æ³•).
+MANUAL.euc : マニュアル.
+
+lib/, ext/ : ライブラリã®å®Ÿä½“.
+
+sample/ : マニュアル代ã‚ã‚Šã®ã‚µãƒ³ãƒ—ルプログラム.
+sample/sample0.rb : tcltklib ライブラリã®ãƒ†ã‚¹ãƒˆ.
+sample/sample1.rb : tcltk ライブラリã®ãƒ†ã‚¹ãƒˆ.
+ tcl/tk (wish) ã§ã§ããã†ãªã“ã¨ã‚’一通り書ã„ã¦ã¿ã¾ã—ãŸ.
+sample/sample2.rb : tcltk ライブラリã®ã‚µãƒ³ãƒ—ル.
+ maeda shugo (shugo@po.aianet.ne.jp) æ°ã«ã‚ˆã‚‹
+ (`rb.tk' ã§æ›¸ã‹ã‚Œã¦ã„ãŸ) ruby ã®ã‚µãƒ³ãƒ—ルプログラム
+ http://www.aianet.or.jp/~shugo/ruby/othello.rb.gz
+ ã‚’ tcltk ライブラリを使ã†ã‚ˆã†ã«, 機械的ã«å¤‰æ›´ã—ã¦ã¿ã¾ã—ãŸ.
+
+demo/ : 100 本ã®ç·šã‚’ 100 回æãデモプログラム.
+ 最åˆã«ç©ºãƒ«ãƒ¼ãƒ—ã®æ™‚間を測定ã—, 続ã„ã¦å®Ÿéš›ã«ç·šã‚’引ã時間を測定ã—ã¾ã™.
+ tcl/tk ã¯(å†)æç”»ã®ã¨ãã« backing store を使ã‚ãšã«å¾‹ç¾©ã« 10000 本(?)
+ 線を引ãã®ã§, (å†)æ画を始ã‚ã‚‹ã¨, マシンãŒã‹ãªã‚Šé‡ããªã‚Šã¾ã™.
+demo/lines0.tcl : wish 用ã®ã‚¹ã‚¯ãƒªãƒ—ト.
+demo/lines1.rb : `tk.rb' 用ã®ã‚¹ã‚¯ãƒªãƒ—ト.
+demo/lines2.rb : tcltk ライブラリ用ã®ã‚¹ã‚¯ãƒªãƒ—ト.
+
+[注æ„]
+
+コンパイル/実行ã«ã¯, tcl/tk ã® C ライブラリãŒå¿…è¦ã§ã™.
+
+ã“ã®ãƒ©ã‚¤ãƒ–ラリã¯,
+
+ ruby-1.0-970701, ruby-1.0-970911, ruby-1.0-970919
+ FreeBSD 2.2.2-RELEASE
+ ãŠã‚ˆã³ãã®ãƒ‘ッケージ jp-tcl-7.6.tgz, jp-tk-4.2.tgz
+
+ã§ä½œæˆ/動作確èªã—ã¾ã—ãŸ. ä»–ã®ç’°å¢ƒã§ã¯å‹•ä½œã™ã‚‹ã‹ã©ã†ã‹ã‚ã‹ã‚Šã¾ã›ã‚“.
+
+TclTkLib.mainloop を実行中㫠Control-C ãŒåŠ¹ã‹ãªã„ã®ã¯ä¸ä¾¿ãªã®ã§, ruby
+ã®ã‚½ãƒ¼ã‚¹ã‚’å‚考ã«, #include "sig.h" ã—㦠trap_immediate ã‚’æ“作ã—ã¦ã„ã¾
+ã™ãŒ, ruby ã® README.EXT ã«ã‚‚書ã„ã¦ãªã„ã®ã«, ã“ã‚“ãªã“ã¨ã‚’ã—ã¦è‰¯ã„ã®ã‹
+ã©ã†ã‹ã‚ã‹ã‚Šã¾ã›ã‚“.
+
+-d オプションã§ãƒ‡ãƒãƒƒã‚°æƒ…報を表示ã•ã›ã‚‹ãŸã‚ã«, ruby ã®ã‚½ãƒ¼ã‚¹ã‚’å‚考ã«,
+debug ã¨ã„ã†å¤§åŸŸå¤‰æ•°ã‚’å‚ç…§ã—ã¦ã„ã¾ã™ãŒ, ruby ã® README.EXT ã«ã‚‚書ã„ã¦
+ãªã„ã®ã«, ã“ã‚“ãªã“ã¨ã‚’ã—ã¦è‰¯ã„ã®ã‹ã©ã†ã‹ã‚ã‹ã‚Šã¾ã›ã‚“.
+
+extconf.rb ã¯æ›¸ãã¾ã—ãŸãŒ, (ã„ã‚ã„ã‚ãªæ„味ã§)ã“ã‚Œã§è‰¯ã„ã®ã‹è‰¯ã分ã‹ã‚Š
+ã¾ã›ã‚“.
+
+[特徴]
+
+ruby ã‹ã‚‰ tcl/tk ライブラリを利用ã§ãã¾ã™.
+
+tcl/tk インタプリタã®ã‚¹ã‚¯ãƒªãƒ—トã¯, 機械的㫠tcltk ライブラリ用㮠ruby
+スクリプトã«å¤‰æ›ã§ãã¾ã™.
+
+(`tk.rb' ã¨ã®é•ã„)
+
+1. tcl/tk インタプリタã®ã‚¹ã‚¯ãƒªãƒ—トãŒ, ã©ã®ã‚ˆã†ã«, tcltk ライブラリ用ã®
+ ruby スクリプトã«å¤‰æ›ã•ã‚Œã‚‹ã‹ãŒç†è§£ã§ãã‚Œã°, マニュアル類ãŒç„¡ã„ã«ç­‰
+ ã—ã„ `tk.rb' ã¨ã¯ç•°ãªã‚Š
+
+ tcl/tk ã®ãƒžãƒ‹ãƒ¥ã‚¢ãƒ«ã‚„オンラインドキュメントを用ã„ã¦
+
+ 効率良ãプログラミングを行ã†ã“ã¨ãŒã§ãã¾ã™.
+ 記述方法ãŒã‚ã‹ã‚‰ãªã„, コマンドã«ä¸Žãˆã‚‹ãƒ‘ラメータãŒã‚ã‹ã‚‰ãªã„...
+ - Canvas.new { ... } ã¨, ãªãœã‚¤ãƒ†ãƒ¬ãƒ¼ã‚¿ãƒ–ロックを書ã‘ã‚‹ã®??
+ - Canvas ã® bbox ã¯æ•°å€¤ã®ãƒªã‚¹ãƒˆã‚’è¿”ã™ã®ã«, xview ã¯æ–‡å­—列を返ã™ã®??
+ ã¨, ã„ã¡ã„ã¡, ライブラリã®ã‚½ãƒ¼ã‚¹ã‚’追ã„ã‹ã‘ã‚‹å¿…è¦ã¯ã‚ã‚Šã¾ã›ã‚“.
+
+2. 個々ã®æ©Ÿèƒ½(オプション)を個別処ç†ã«ã‚ˆã‚Šã‚µãƒãƒ¼ãƒˆã—ã¦ãŠã‚Š, ãã®ãŸã‚サ
+ ãƒãƒ¼ãƒˆã—ã¦ã„ãªã„機能ã¯ä½¿ã†ã“ã¨ãŒã§ããªã„(本当ã¯ä½¿ãˆãªã„ã“ã¨ã‚‚ãªã„ã®
+ ã§ã™ãŒ) `tk.rb' ã¨ã¯ç•°ãªã‚Š, tcl/tk インタプリタã§å¯èƒ½ãªã“ã¨ã¯
+
+ ã»ã¨ã‚“ã©
+
+ ruby ã‹ã‚‰ã‚‚実行ã§ãã¾ã™. ç¾åœ¨, ruby ã‹ã‚‰å®Ÿè¡Œã§ããªã„ã“ã¨ãŒç¢ºèªã•ã‚Œ
+ ã¦ã„ã‚‹ã®ã¯,
+
+ bind コマンドã§ã‚¹ã‚¯ãƒªãƒ—トを追加ã™ã‚‹æ§‹æ–‡
+ 「bind tag sequence +scriptã€
+ ^
+
+ ã®ã¿ã§ã™.
+ - `. configure -width' ã‚’ã—よã†ã¨ã—ã¦, `Tk.root.height()' ã¨æ›¸ã„
+ ãŸã®ã«, `undefined method `height'' ã¨æ€’られã¦ã—ã¾ã£ãŸ. tk.rb ã‚’
+ 読んã§ã¿ã¦, ガーン. ã§ããªã„ã®ã‹...
+ ã¨ã„ã†ã“ã¨ã¯ã‚ã‚Šã¾ã›ã‚“.
+
+3. wish プロセスを起動ã—プロセス間通信㧠wish を利用ã™ã‚‹ `tk.rb' ã¨ã¯
+ ç•°ãªã‚Š, tcl/tk ã® C ライブラリをリンクã—
+
+ より高速㫠(ã¨ã„ã£ã¦ã‚‚, æ€ã£ãŸç¨‹ã¯é€Ÿããªã„ã§ã™ãŒ)
+
+ 処ç†ã‚’è¡Œã„ã¾ã™.
+
+4. `tk.rb' ã»ã©, 高水準ãªã‚¤ãƒ³ã‚¿ãƒ¼ãƒ•ã‚§ãƒ¼ã‚¹ã‚’å‚™ãˆã¦ã„ãªã„ãŸã‚, tcl/tk イ
+ ンタプリタã®ç”Ÿæˆç­‰
+
+ 何ã‹ã‚‰ä½•ã¾ã§è‡ªåˆ†ã§è¨˜è¿°
+
+ ã—ãªã‘ã‚Œã°ãªã‚Šã¾ã›ã‚“(ãã®ä»£ã‚ã‚Š, tcl/tk ライブラリã®ä»•æ§˜é€šã‚Š,
+ tcl/tk インタプリタを複数生æˆã™ã‚‹ã“ã¨ã‚‚ã§ãã¾ã™ãŒ).
+ インターフェースã¯(ãŠãらã) ruby ã®æ€æƒ³ã«æ²¿ã£ãŸã‚‚ã®ã§ã¯ã‚ã‚Šã¾ã›ã‚“.
+ ã¾ãŸ, スクリプトã®è¨˜è¿°ã¯
+
+ ダサダサ
+
+ ã§ã™. スクリプトã¯, 一見, 読ã¿ã¥ã‚‰ã„ã‚‚ã®ã¨ãªã‚Šã¾ã™. ãŒ, 書ã人ã«ã¨ã£
+ ã¦ã¯, ãã‚Œã»ã©ç…©ã‚ã—ã„ã‚‚ã®ã§ã¯ãªã„ã¨æ€ã„ã¾ã™.
+
+[インストールã®æ–¹æ³•]
+
+0. ruby ã®ã‚½ãƒ¼ã‚¹ãƒ•ã‚¡ã‚¤ãƒ«(ruby-1.0-ãªã‚“ãŸã‚‰.tgz)を展開ã—ã¦ãŠãã¾ã™.
+
+1. ruby-1.0-ãªã‚“ãŸã‚‰/ext ã« ext/tcltklib をコピーã—ã¾ã™.
+ cp -r ext/tcltklib ???/ruby-1.0-ãªã‚“ãŸã‚‰/ext/
+
+2. ruby ã®ã‚¤ãƒ³ã‚¹ãƒˆãƒ¼ãƒ«æ³•ã«å¾“ã„ make 等をã—ã¾ã™.
+
+3. ruby ã®ãƒ©ã‚¤ãƒ–ラリ置場㫠lib/* をコピーã—ã¾ã™.
+ cp lib/* /usr/local/lib/ruby/
+
+(eof)
diff --git a/jni/ruby/ext/tk/old-extconf.rb b/jni/ruby/ext/tk/old-extconf.rb
new file mode 100644
index 0000000..ebc83a0
--- /dev/null
+++ b/jni/ruby/ext/tk/old-extconf.rb
@@ -0,0 +1,440 @@
+# extconf.rb for tcltklib
+
+require 'mkmf'
+
+is_win32 = (/mswin|mingw|cygwin|bccwin/ =~ RUBY_PLATFORM)
+#is_macosx = (/darwin/ =~ RUBY_PLATFORM)
+
+have_func("ruby_native_thread_p", "ruby.h")
+have_func("rb_errinfo", "ruby.h")
+have_func("rb_safe_level", "ruby.h")
+have_struct_member("struct RArray", "ptr", "ruby.h")
+have_struct_member("struct RArray", "len", "ruby.h")
+
+def find_framework(tcl_hdr, tk_hdr)
+ if framework_dir = with_config("tcltk-framework")
+ paths = [framework_dir]
+ else
+ unless tcl_hdr || tk_hdr ||
+ enable_config("tcltk-framework", false) ||
+ enable_config("mac-tcltk-framework", false)
+ return false
+ end
+ paths = ["/Library/Frameworks", "/System/Library/Frameworks"]
+ end
+
+ checking_for('Tcl/Tk Framework') {
+ paths.find{|dir|
+ dir.strip!
+ dir.chomp!('/')
+ (tcl_hdr || FileTest.directory?(dir + "/Tcl.framework/") ) &&
+ (tk_hdr || FileTest.directory?(dir + "/Tk.framework/") )
+ }
+ }
+end
+
+tcl_framework_header = with_config("tcl-framework-header")
+tk_framework_header = with_config("tk-framework-header")
+
+tcltk_framework = find_framework(tcl_framework_header, tk_framework_header)
+
+unless is_win32
+ have_library("nsl", "t_open")
+ have_library("socket", "socket")
+ have_library("dl", "dlopen")
+ have_library("m", "log")
+end
+
+tk_idir, tk_ldir = dir_config("tk")
+tcl_idir, tcl_ldir = dir_config("tcl")
+x11_idir, x11_ldir = dir_config("X11")
+
+tk_ldir2 = with_config("tk-lib")
+tcl_ldir2 = with_config("tcl-lib")
+x11_ldir2 = with_config("X11-lib")
+
+tk_ldir_list = [tk_ldir2, tk_ldir]
+tcl_ldir_list = [tcl_ldir2, tcl_ldir]
+
+tklib = with_config("tklib")
+tcllib = with_config("tcllib")
+stubs = enable_config("tcltk_stubs") || with_config("tcltk_stubs")
+
+tcltk_version = with_config("tcltkversion")
+
+use_X = with_config("X11", (! is_win32))
+
+def parse_tclConfig(file)
+ # check tclConfig.sh/tkConfig.sh
+ tbl = {}
+ IO.foreach(file){|line|
+ line.strip!
+ next if line !~ /^([^\#=][^=]*)=(['"]|)(.*)\2$/
+ key, val = $1, $3
+ tbl[key] = val.gsub(/\$\{([^}]+)\}/){|s| tbl[$1]} rescue nil
+ }
+ tbl
+end
+
+def check_tcltk_version(version)
+ return [nil, nil] unless version
+
+ version = version.strip
+
+ tclver = version.dup
+ tkver = version.dup
+
+ major = dot = minor = dot = plvl = ext = nil
+
+ if version =~ /^(\d)(\.?)(\d)(\.?)(\d*)(.*)$/
+ major = $1; minor_dot = $2; minor = $3; plvl_dot = $4; plvl = $5; ext = $6
+ dot = ! minor_dot.empty?
+ if plvl_dot.empty? && ! plvl.empty?
+ minor << plvl
+ end
+ elsif version =~ /^(\d)(\.?)(\d?)(.*)$/
+ major = $1; minor_dot = $2; minor = $3; ext = $4
+ dot = ! minor_dot.empty?
+ else # unknown -> believe user
+ return [tclver, tkver]
+ end
+
+ # check Tcl7.6 / Tk4.2 ?
+ if major == "7" # Tcl7.6 ( not support Tclversion < 7.6 )
+ # Tk4.2
+ tkver = "4" + ((dot)? ".": "") + ((minor.empty)? "": "2") + ext
+ elsif major == "4" # Tk4.2 ( not support Tkversion < 4.2 )
+ # Tcl7.6
+ tclver = "7" + ((dot)? ".": "") + ((minor.empty)? "": "6") + ext
+ end
+
+ [tclver, tkver]
+end
+
+def find_tcl(tcllib, stubs, version, *opt_paths)
+ default_paths = ["/usr/local/lib", "/usr/pkg/lib", "/usr/lib"]
+ default_paths << "/Tcl/lib" # default for ActiveTcl
+
+ if (paths = opt_paths.compact).empty?
+ paths = default_paths
+ end
+
+ if stubs
+ func = "Tcl_InitStubs"
+ lib = "tclstub"
+ else
+ func = "Tcl_FindExecutable"
+ lib = "tcl"
+ end
+
+ if version && ! version.empty?
+ versions = [version]
+ else
+ versions = %w[8.7 8.6 8.5 8.4 8.3 8.2 8.1 8.0 7.6]
+ end
+
+ if tcllib
+ st = find_library(tcllib, func, *paths)
+ else
+ st = versions.find { |ver|
+ find_library("#{lib}#{ver}", func, *paths) or
+ find_library("#{lib}#{ver.delete('.')}", func, *paths) or
+ find_library("#{lib}#{ver}g", func, *paths) or
+ find_library("#{lib}#{ver.delete('.')}g", func, *paths) or
+ find_library("tcl#{ver}", func, *paths) or
+ find_library("tcl#{ver.delete('.')}", func, *paths) or
+ find_library("tcl#{ver}g", func, *paths) or
+ find_library("tcl#{ver.delete('.')}g", func, *paths)
+ } || (!version && find_library(lib, func, *paths))
+ end
+
+ unless st
+ puts("Warning:: cannot find Tcl library. tcltklib will not be compiled (tcltklib is disabled on your Ruby == Ruby/Tk will not work). Please check configure options.")
+ end
+ st
+end
+
+def find_tk(tklib, stubs, version, *opt_paths)
+ default_paths = ["/usr/local/lib", "/usr/pkg/lib", "/usr/lib"]
+ default_paths << "/Tcl/lib" # default for ActiveTcl
+
+ if (paths = opt_paths.compact).empty?
+ paths = default_paths
+ end
+
+ if stubs
+ func = "Tk_InitStubs"
+ lib = "tkstub"
+ else
+ func = "Tk_Init"
+ lib = "tk"
+ end
+
+ if version && ! version.empty?
+ versions = [version]
+ else
+ versions = %w[8.7 8.6 8.5 8.4 8.3 8.2 8.1 8.0 4.2]
+ end
+
+ if tklib
+ st = find_library(tklib, func, *paths)
+ else
+ st = versions.find { |ver|
+ find_library("#{lib}#{ver}", func, *paths) or
+ find_library("#{lib}#{ver.delete('.')}", func, *paths) or
+ find_library("#{lib}#{ver}g", func, *paths) or
+ find_library("#{lib}#{ver.delete('.')}g", func, *paths) or
+ find_library("tk#{ver}", func, *paths) or
+ find_library("tk#{ver.delete('.')}", func, *paths) or
+ find_library("tk#{ver}g", func, *paths) or
+ find_library("tk#{ver.delete('.')}g", func, *paths)
+ } || (!version && find_library(lib, func, *paths))
+ end
+
+ unless st
+ puts("Warning:: cannot find Tk library. tcltklib will not be compiled (tcltklib is disabled on your Ruby == Ruby/Tk will not work). Please check configure options.")
+ end
+ st
+end
+
+def find_tcltk_header(tclver, tkver)
+ base_dir = ['/usr/local/include', '/usr/pkg/include', '/usr/include']
+ base_dir << '/Tcl/include' # default for ActiveTcl
+
+ unless have_tcl_h = have_header('tcl.h')
+ if tclver && ! tclver.empty?
+ versions = [tclver]
+ else
+ versions = %w[8.7 8.6 8.5 8.4 8.3 8.2 8.1 8.0 7.6]
+ end
+ paths = base_dir.dup
+ versions.each{|ver| paths.concat(base_dir.map{|dir| dir + '/tcl' + ver})}
+ have_tcl_h = find_header('tcl.h', *paths)
+ end
+
+ unless have_tk_h = have_header("tk.h")
+ if tkver && ! tkver.empty?
+ versions = [tkver]
+ else
+ versions = %w[8.7 8.6 8.5 8.4 8.3 8.2 8.1 8.0 4.2]
+ end
+ paths = base_dir.dup
+ versions.each{|ver| paths.concat(base_dir.map{|dir| dir + '/tk' + ver})}
+ have_tk_h = find_header('tk.h', *paths)
+ end
+
+ have_tcl_h && have_tk_h
+end
+
+def find_X11(*opt_paths)
+ default_paths =
+ [ "/usr/X11/lib", "/usr/lib/X11", "/usr/X11R6/lib", "/usr/openwin/lib" ]
+ paths = opt_paths.compact.concat(default_paths)
+ st = find_library("X11", "XOpenDisplay", *paths)
+ unless st
+ puts("Warning:: cannot find X11 library. tcltklib will not be compiled (tcltklib is disabled on your Ruby == Ruby/Tk will not work). Please check configure options. If your Tcl/Tk don't require X11, please try --without-X11.")
+ end
+ st
+end
+
+def pthread_check()
+ tcl_major_ver = nil
+ tcl_minor_ver = nil
+
+ # Is tcl-thread given by user ?
+ case enable_config("tcl-thread")
+ when true
+ tcl_enable_thread = true
+ when false
+ tcl_enable_thread = false
+ else
+ tcl_enable_thread = nil
+ end
+
+ if (tclConfig = with_config("tclConfig-file"))
+ if tcl_enable_thread == true
+ puts("Warning: --with-tclConfig-file option is ignored, because --enable-tcl-thread option is given.")
+ elsif tcl_enable_thread == false
+ puts("Warning: --with-tclConfig-file option is ignored, because --disable-tcl-thread option is given.")
+ else
+ # tcl-thread is unknown and tclConfig.sh is given
+ begin
+ tbl = parse_tclConfig(tclConfig)
+ if tbl['TCL_THREADS']
+ tcl_enable_thread = (tbl['TCL_THREADS'] == "1")
+ else
+ tcl_major_ver = tbl['TCL_MAJOR_VERSION'].to_i
+ tcl_minor_ver = tbl['TCL_MINOR_VERSION'].to_i
+ if tcl_major_ver < 8 || (tcl_major_ver == 8 && tcl_minor_ver == 0)
+ tcl_enable_thread = false
+ end
+ end
+
+ if tcl_enable_thread == nil
+ # cannot find definition
+ if tcl_major_ver
+ puts("Warning: '#{tclConfig}' doesn't include TCL_THREADS definition.")
+ else
+ puts("Warning: '#{tclConfig}' may not be a tclConfig file.")
+ end
+ tclConfig = false
+ end
+ rescue Exception
+ puts("Warning: fail to read '#{tclConfig}'!! --> ignore the file")
+ tclConfig = false
+ end
+ end
+ end
+
+ if tcl_enable_thread == nil && !tclConfig
+ # tcl-thread is unknown and tclConfig is unavailable
+ begin
+ try_run_available = try_run("int main() { exit(0); }")
+ rescue Exception
+ # cannot try_run. Is CROSS-COMPILE environment?
+ puts(%Q'\
+*****************************************************************************
+**
+** PTHREAD SUPPORT CHECK WARNING:
+**
+** We cannot check the consistency of pthread support between Ruby
+** and the Tcl/Tk library in your environment (are you perhaps
+** cross-compiling?). If pthread support for these 2 packages is
+** inconsistent you may find you get errors when running Ruby/Tk
+** (e.g. hangs or segmentation faults). We strongly recommend
+** you to check the consistency manually.
+**
+*****************************************************************************
+')
+ return true
+ end
+ end
+
+ if tcl_enable_thread == nil
+ # tcl-thread is unknown
+ if try_run(<<EOF)
+#include <tcl.h>
+int main() {
+ Tcl_Interp *ip;
+ ip = Tcl_CreateInterp();
+ exit((Tcl_Eval(ip, "set tcl_platform(threaded)") == TCL_OK)? 0: 1);
+}
+EOF
+ tcl_enable_thread = true
+ elsif try_run(<<EOF)
+#include <tcl.h>
+static Tcl_ThreadDataKey dataKey;
+int main() { exit((Tcl_GetThreadData(&dataKey, 1) == dataKey)? 1: 0); }
+EOF
+ tcl_enable_thread = true
+ else
+ tcl_enable_thread = false
+ end
+ end
+
+ # check pthread mode
+ if (macro_defined?('HAVE_NATIVETHREAD', '#include "ruby.h"'))
+ # ruby -> enable
+ unless tcl_enable_thread
+ # ruby -> enable && tcl -> disable
+ puts(%Q'\
+*****************************************************************************
+**
+** PTHREAD SUPPORT MODE WARNING:
+**
+** Ruby is compiled with --enable-pthread, but your Tcl/Tk library
+** seems to be compiled without pthread support. Although you can
+** create the tcltklib library, this combination may cause errors
+** (e.g. hangs or segmentation faults). If you have no reason to
+** keep the current pthread support status, we recommend you reconfigure
+** and recompile the libraries so that both or neither support pthreads.
+**
+** If you want change the status of pthread support, please recompile
+** Ruby without "--enable-pthread" configure option or recompile Tcl/Tk
+** with "--enable-threads" configure option (if your Tcl/Tk is later
+** than or equal to Tcl/Tk 8.1).
+**
+*****************************************************************************
+')
+ end
+
+ # ruby -> enable && tcl -> enable/disable
+ if tcl_enable_thread
+ $CPPFLAGS += ' -DWITH_TCL_ENABLE_THREAD=1'
+ else
+ $CPPFLAGS += ' -DWITH_TCL_ENABLE_THREAD=0'
+ end
+
+ return true
+
+ else
+ # ruby -> disable
+ if tcl_enable_thread
+ # ruby -> disable && tcl -> enable
+ puts(%Q'\
+*****************************************************************************
+**
+** PTHREAD SUPPORT MODE ERROR:
+**
+** Ruby is not compiled with --enable-pthread, but your Tcl/Tk
+** library seems to be compiled with pthread support. This
+** combination may cause frequent hang or segmentation fault
+** errors when Ruby/Tk is working. We recommend that you NEVER
+** create the library with such a combination of pthread support.
+**
+** Please recompile Ruby with the "--enable-pthread" configure option
+** or recompile Tcl/Tk with the "--disable-threads" configure option.
+**
+*****************************************************************************
+')
+ $CPPFLAGS += ' -DWITH_TCL_ENABLE_THREAD=1'
+ return false
+ else
+ # ruby -> disable && tcl -> disable
+ $CPPFLAGS += ' -DWITH_TCL_ENABLE_THREAD=0'
+ return true
+ end
+ end
+end
+
+tclver, tkver = check_tcltk_version(tcltk_version)
+
+if ( tcltk_framework ||
+ ( find_tcltk_header(tclver, tkver) &&
+ ( !use_X || find_X11(x11_ldir2, x11_ldir) ) &&
+ find_tcl(tcllib, stubs, tclver, *tcl_ldir_list) &&
+ find_tk(tklib, stubs, tkver, *tk_ldir_list) ) )
+ $CPPFLAGS += ' -DUSE_TCL_STUBS -DUSE_TK_STUBS' if stubs
+ $CPPFLAGS += ' -D_WIN32' if /cygwin/ =~ RUBY_PLATFORM
+
+ if tcltk_framework
+ if tcl_framework_header
+ $CPPFLAGS += " -I#{tcl_framework_header}"
+ else
+ $CPPFLAGS += " -I#{tcltk_framework}/Tcl.framework/Headers"
+ end
+
+ if tk_framework_header
+ $CPPFLAGS += " -I#{tk_framework_header}"
+ else
+ $CPPFLAGS += " -I#{tcltk_framework}/Tk.framework/Headers"
+ end
+
+ $LDFLAGS += ' -framework Tk -framework Tcl'
+ end
+
+ if stubs or pthread_check
+ # create Makefile
+
+ # for SUPPORT_STATUS
+ $INSTALLFILES ||= []
+ $INSTALLFILES << ["lib/tkextlib/SUPPORT_STATUS", "$(RUBYLIBDIR)", "lib"]
+
+ have_func("rb_hash_lookup", "ruby.h")
+
+ # create
+ $defs << %[-DRUBY_VERSION=\\"#{RUBY_VERSION}\\"]
+ $defs << %[-DRUBY_RELEASE_DATE=\\"#{RUBY_RELEASE_DATE}\\"]
+ create_makefile("tcltklib")
+ end
+end
diff --git a/jni/ruby/ext/tk/sample/24hr_clock.rb b/jni/ruby/ext/tk/sample/24hr_clock.rb
new file mode 100644
index 0000000..29f84e0
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/24hr_clock.rb
@@ -0,0 +1,286 @@
+#!/usr/bin/env ruby
+
+require 'tk'
+
+class Clock
+ def initialize(clock24 = true)
+ @clock = (clock24)? 24: 12
+
+ @size = 200
+ @cdot_size = 5
+
+ @cdot_color = 'black'
+ @hour_hand_color = 'black'
+ @minute_hand_color = 'gray25'
+ @second_hand_color = 'gray50'
+
+ @mark_font = 'Helvetica -14'
+ @mark_width = 3
+ @mark_color = 'black'
+ @submark_color = 'gray50'
+
+ @c = TkCanvas.new(:width=>2*@size, :height=>2*@size,
+ :scrollregion=>[-@size, -@size, @size, @size]
+ ).pack(:fill=>:both, :expand=>true)
+
+ @tag = TkcTag.new(@c)
+ @hand_tag = TkcTag.new(@c)
+
+ @circle_coords = [[-0.9*@size, -0.9*@size], [0.9*@size, 0.9*@size]]
+ @oval = TkcOval.new(@c, @circle_coords, :fill=>'white', :tags=>[@tag])
+
+ f = TkFrame.new.pack
+ TkLabel.new(f, :text=>'CURRENT:').pack(:side=>:left)
+ @now = TkLabel.new(f, :text=>'00:00:00').pack(:side=>:left, :padx=>2)
+ TkLabel.new(f, :text=>' ').pack(:side=>:left)
+ TkLabel.new(f, :text=>' ').pack(:side=>:right)
+ @l = TkLabel.new(f, :text=>'00:00').pack(:side=>:right, :padx=>2)
+ TkLabel.new(f, :text=>'MOUSE-POINTER:').pack(:side=>:right)
+
+ cmd = proc{|x, y|
+ @l.text = '%02d:%02d' % coords_to_time(@c.canvasx(x), @c.canvasy(y))
+ }
+ @c.bind('Motion', cmd, '%x %y')
+ @tag.bind('Motion', cmd, '%x %y')
+
+ _create_hands
+ _create_marks
+
+ timer_proc = proc{
+ t = Time.now
+ @now.text = '%02d:%02d:%02d' % [t.hour, t.min, t.sec]
+ set_hands(t.hour, t.min, t.sec)
+ }
+
+ timer_proc.call
+ @timer = TkRTTimer.start(100, -1, timer_proc)
+ end
+
+ def _create_marks
+ @mark_tag = TkcTag.new(@c)
+
+ TkcLine.new(@c, 0, -0.90*@size, 0, -0.85*@size,
+ :tags=>[@tag, @mark_tag],
+ :width=>@mark_width, :fill=>@mark_color)
+ TkcLine.new(@c, 0.90*@size, 0, 0.85*@size, 0,
+ :tags=>[@tag, @mark_tag],
+ :width=>@mark_width, :fill=>@mark_color)
+ TkcLine.new(@c, 0, 0.90*@size, 0, 0.85*@size,
+ :tags=>[@tag, @mark_tag],
+ :width=>@mark_width, :fill=>@mark_color)
+ TkcLine.new(@c, -0.90*@size, 0, -0.85*@size, 0,
+ :tags=>[@tag, @mark_tag],
+ :width=>@mark_width, :fill=>@mark_color)
+
+ TkcText.new(@c, [0, -0.92*@size], :text=>0,
+ :anchor=>'s', :fill=>@mark_color)
+ TkcText.new(@c, [0.92*@size, 0], :text=>@clock.div(4),
+ :anchor=>'w', :fill=>@mark_color)
+ TkcText.new(@c, [0, 0.92*@size], :text=>@clock.div(2),
+ :anchor=>'n', :fill=>@mark_color)
+ TkcText.new(@c, [-0.92*@size, 0], :text=>@clock.div(4)*3,
+ :anchor=>'e', :fill=>@mark_color)
+
+ [30.0, 60.0].each{|angle|
+ rad = Math::PI * angle / 180.0
+ x_base = @size*Math::sin(rad)
+ y_base = @size*Math::cos(rad)
+
+ x1 = 0.90*x_base
+ y1 = 0.90*y_base
+
+ x2 = 0.85*x_base
+ y2 = 0.85*y_base
+
+ TkcLine.new(@c, x1, y1, x2, y2,
+ :tags=>[@tag, @mark_tag],
+ :width=>@mark_width, :fill=>@mark_color)
+ TkcLine.new(@c, x1, -y1, x2, -y2,
+ :tags=>[@tag, @mark_tag],
+ :width=>@mark_width, :fill=>@mark_color)
+ TkcLine.new(@c, -x1, y1, -x2, y2,
+ :tags=>[@tag, @mark_tag],
+ :width=>@mark_width, :fill=>@mark_color)
+ TkcLine.new(@c, -x1, -y1, -x2, -y2,
+ :tags=>[@tag, @mark_tag],
+ :width=>@mark_width, :fill=>@mark_color)
+
+ x3 = 0.92*x_base
+ y3 = 0.92*y_base
+
+ if @clock == 24
+ dh = angle.to_i/15
+ else # @clock == 12
+ dh = angle.to_i/30
+ end
+
+ TkcText.new(@c, x3, -y3, :text=>dh,
+ :anchor=>'sw', :fill=>@mark_color)
+ TkcText.new(@c, x3, y3, :text=>@clock.div(2)-dh,
+ :anchor=>'nw', :fill=>@mark_color)
+ TkcText.new(@c, -x3, y3, :text=>@clock.div(2)+dh,
+ :anchor=>'ne', :fill=>@mark_color)
+ TkcText.new(@c, -x3, -y3, :text=>@clock-dh,
+ :anchor=>'se', :fill=>@mark_color)
+ }
+
+ if @clock == 24
+ [15.0, 45.0, 75.0].each{|angle|
+ rad = Math::PI * angle / 180.0
+ x_base = @size*Math::sin(rad)
+ y_base = @size*Math::cos(rad)
+
+ x1 = 0.90*x_base
+ y1 = 0.90*y_base
+
+ x2 = 0.875*x_base
+ y2 = 0.875*y_base
+
+ TkcLine.new(@c, x1, y1, x2, y2,
+ :tags=>[@tag, @mark_tag],
+ :width=>@mark_width, :fill=>@submark_color)
+ TkcLine.new(@c, x1, -y1, x2, -y2,
+ :tags=>[@tag, @mark_tag],
+ :width=>@mark_width, :fill=>@submark_color)
+ TkcLine.new(@c, -x1, y1, -x2, y2,
+ :tags=>[@tag, @mark_tag],
+ :width=>@mark_width, :fill=>@submark_color)
+ TkcLine.new(@c, -x1, -y1, -x2, -y2,
+ :tags=>[@tag, @mark_tag],
+ :width=>@mark_width, :fill=>@submark_color)
+ }
+ end
+ end
+
+ def _create_hands
+ hour_hand_len = 0.55*@size
+ minute_hand_len = 0.85*@size
+ second_hand_len = 0.88*@size
+
+ hour_hand_width = 1.8*@cdot_size
+ minute_hand_width = 1.0*@cdot_size
+ second_hand_width = 1 # 0.4*@cdot_size
+
+ @hour_hand_coords = [
+ [0, -0.5*@cdot_size],
+ [hour_hand_width, -0.5*@cdot_size-hour_hand_width],
+ [hour_hand_width, -hour_hand_len+hour_hand_width],
+ [0, -hour_hand_len],
+ [-hour_hand_width, -hour_hand_len+hour_hand_width],
+ [-hour_hand_width, -0.5*@cdot_size-hour_hand_width],
+ ]
+ @minute_hand_coords = [
+ [0, -0.5*@cdot_size],
+ [minute_hand_width, -0.5*@cdot_size - minute_hand_width],
+ [minute_hand_width, -minute_hand_len+minute_hand_width],
+ [0, -minute_hand_len],
+ [-minute_hand_width, -minute_hand_len+minute_hand_width],
+ [-minute_hand_width, -0.5*@cdot_size-minute_hand_width],
+ ]
+ @second_hand_coords = [
+ [0, -0.5*@cdot_size],
+ [second_hand_width, -0.5*@cdot_size - second_hand_width],
+ [second_hand_width, -second_hand_len+second_hand_width],
+ [0, -second_hand_len],
+ [-second_hand_width, -second_hand_len+second_hand_width],
+ [-second_hand_width, -0.5*@cdot_size-second_hand_width],
+ ]
+
+ @hour_hand = TkcPolygon.new(@c, @hour_hand_coords,
+ :tags=>[@tag, @hand_tag],
+ :outline=>@hour_hand_color,
+ :fill=>@hour_hand_color)
+
+ @minute_hand = TkcPolygon.new(@c, @minute_hand_coords,
+ :tags=>[@tag, @hand_tag],
+ :outline=>@minute_hand_color,
+ :fill=>@minute_hand_color)
+
+ @second_hand = TkcPolygon.new(@c, @second_hand_coords,
+ :tags=>[@tag, @hand_tag],
+ :outline=>@second_hand_color,
+ :fill=>@second_hand_color)
+
+ @center_dot = TkcOval.new(@c,
+ [-@cdot_size, -@cdot_size],
+ [@cdot_size, @cdot_size],
+ :outline=>@cdot_color, :fill=>@cdot_color)
+ end
+ private :_create_hands
+
+ def _raise_hands
+ @hour_hand.raise
+ @minute_hand.raise
+ @second_hand.raise
+ @center_dot.raise
+ end
+ private :_raise_hands
+
+ def _raise_marks
+ @mark_tag.raise
+ end
+ private :_raise_marks
+
+ def set_hands(hh, mm, ss)
+ ss_angle = Math::PI * ss / 30.0
+ mm_angle = Math::PI * (mm + ss/60.0) / 30.0
+ hh_angle = Math::PI * (hh + (mm + ss/60.0)/60.0) / (@clock.div(2))
+
+ @second_hand.coords = @second_hand_coords.collect{|x, y|
+ r = Math::hypot(y, x)
+ a = Math::atan2(y, x) + ss_angle
+ [Math::cos(a) * r, Math::sin(a) * r]
+ }
+
+ @minute_hand.coords = @minute_hand_coords.collect{|x, y|
+ r = Math::hypot(y, x)
+ a = Math::atan2(y, x) + mm_angle
+ [Math::cos(a) * r, Math::sin(a) * r]
+ }
+
+ @hour_hand.coords = @hour_hand_coords.collect{|x, y|
+ r = Math::hypot(y, x)
+ a = Math::atan2(y, x) + hh_angle
+ [Math::cos(a) * r, Math::sin(a) * r]
+ }
+
+ _raise_hands
+ _raise_marks
+ end
+
+ def coords_to_time(x, y)
+ return ((y < 0)? [0, 0]: [@clock.div(2), 0]) if x == 0
+ if @clock == 24
+ offset = (x<0&&y<0)? 1800.0: 360.0
+ m_half = 720.0
+ else # @clock == 12
+ offset = (x<0&&y<0)? 900.0: 180.0
+ m_half = 360.0
+ end
+ (offset + m_half*Math.atan2(y,x)/Math::PI).round.divmod(60)
+ end
+
+ def create_pie(hh, mm, span, color='red')
+ if @clock == 24
+ start = 90.0 - (hh*60 + mm)/4.0 # 360.0*(hh*60+mm)/(24*60)
+ extent = -span/4.0
+ else # @clock == 12
+ start = 90.0 - (hh*60 + mm)/2.0 # 360.0*(hh*60+mm)/(12*60)
+ extent = -span/2.0
+ end
+
+ pie = TkcArc.new(@c, @circle_coords, :tags=>[@tag],
+ :outline=>'black', 'fill'=>color,
+ :start=>start, :extent=>extent)
+ _raise_hands
+ _raise_marks
+ pie
+ end
+end
+
+sched = Clock.new
+sched.create_pie(0,0, 60) # 60 minutes from 00:00
+sched.create_pie(6,30, 280, 'green') # 280 minutes from 06:30
+sched.create_pie(15,20, 90, 'blue') # 90 minutes from 15:20
+
+Tk.mainloop
diff --git a/jni/ruby/ext/tk/sample/binding_sample.rb b/jni/ruby/ext/tk/sample/binding_sample.rb
new file mode 100644
index 0000000..3c2eb5e
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/binding_sample.rb
@@ -0,0 +1,87 @@
+#!/usr/bin/env ruby
+
+require 'tk'
+
+class Button_clone < TkLabel
+ def initialize(*args)
+ @command = nil
+
+ if args[-1].kind_of?(Hash)
+ keys = _symbolkey2str(args.pop)
+ @command = keys.delete('command')
+
+ keys['highlightthickness'] = 1 unless keys.key?('highlightthickness')
+ keys['padx'] = '3m' unless keys.key?('padx')
+ keys['pady'] = '1m' unless keys.key?('pady')
+ keys['relief'] = 'raised' unless keys.key?('relief')
+
+ args.push(keys)
+ end
+
+ super(*args)
+
+ @press = false
+
+ self.bind('Enter', proc{self.background(self.activebackground)})
+ self.bind('Leave', proc{
+ @press = false
+ self.background(self.highlightbackground)
+ self.relief('raised')
+ })
+
+ self.bind('ButtonPress-1', proc{@press = true; self.relief('sunken')})
+ self.bind('ButtonRelease-1', proc{
+ self.relief('raised')
+ @command.call if @press && @command
+ @press = false
+ })
+ end
+
+ def command(cmd = Proc.new)
+ @command = cmd
+ end
+
+ def invoke
+ if @command
+ @command.call
+ else
+ ''
+ end
+ end
+end
+
+TkLabel.new(:text=><<EOT).pack
+This is a sample of 'event binding'.
+The first button is a normal button widget.
+And the second one is a normal label widget
+but with some bindings like a button widget.
+EOT
+
+lbl = TkLabel.new(:foreground=>'red').pack(:pady=>3)
+
+v = TkVariable.new(0)
+
+TkFrame.new{|f|
+ TkLabel.new(f, :text=>'click count : ').pack(:side=>:left)
+ TkLabel.new(f, :textvariable=>v).pack(:side=>:left)
+}.pack
+
+TkButton.new(:text=>'normal Button widget',
+ :command=>proc{
+ puts 'button is clicked!!'
+ lbl.text 'button is clicked!!'
+ v.numeric += 1
+ }){
+ pack(:fill=>:x, :expand=>true)
+}
+
+Button_clone.new(:text=>'Label with Button binding',
+ :command=>proc{
+ puts 'label is clicked!!'
+ lbl.text 'label is clicked!!'
+ v.numeric += 1
+ }){
+ pack(:fill=>:x, :expand=>true)
+}
+
+Tk.mainloop
diff --git a/jni/ruby/ext/tk/sample/bindtag_sample.rb b/jni/ruby/ext/tk/sample/bindtag_sample.rb
new file mode 100644
index 0000000..b13364b
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/bindtag_sample.rb
@@ -0,0 +1,127 @@
+#!/usr/bin/env ruby
+require 'tk'
+
+TkLabel.new(:text=><<EOT, :justify=>:left).pack
+This is a sample of bindtags and usage of
+Tk.callback_break/Tk.callback_continue.
+Please check the work of following buttons
+(attend the difference between before/after
+ pressing the bottom button), and see the
+source code.
+EOT
+
+def set_class_bind
+ TkButton.bind('ButtonPress-1',
+ proc{puts 'bind "ButtonPress-1" of TkButton class'})
+ TkButton.bind('ButtonRelease-1',
+ proc{puts 'bind "ButtonRelease-1" of TkButton class'})
+end
+
+# set root binding
+r = TkRoot.new
+r.bind('ButtonPress-1', proc{puts 'bind "ButtonPress-1" of root widget'})
+r.bind('ButtonRelease-1', proc{puts 'bind "ButtonRelease-1" of root widget'})
+
+# set 'all' binding
+TkBindTag::ALL.bind('ButtonPress-1',
+ proc{puts 'bind "ButtonPress-1" of the tag "all"'})
+TkBindTag::ALL.bind('ButtonRelease-1',
+ proc{puts 'bind "ButtonRelease-1" of the tag "all"'})
+
+# create buttons
+b1 = TkButton.new(:text=>'button-1',
+ :command=>proc{puts "command of button-1"}).pack
+b2 = TkButton.new(:text=>'button-2',
+ :command=>proc{puts "command of button-2"}).pack
+b3 = TkButton.new(:text=>'button-3',
+ :command=>proc{puts "command of button-3"}).pack
+b4 = TkButton.new(:text=>'button-4',
+ :command=>proc{puts "command of button-4"}).pack
+b5 = TkButton.new(:text=>'button-5',
+ :command=>proc{puts "command of button-5"}).pack
+
+# set button binding
+b1.bind('ButtonPress-1', proc{puts 'bind "ButtonPress-1" of button-1'})
+b1.bind('ButtonRelease-1', proc{puts 'bind "ButtonRelease-1" of button-1'})
+
+b2.bind('ButtonPress-1', proc{puts 'bind "ButtonPress-1" of button-2'})
+b2.bind('ButtonRelease-1', proc{puts 'bind "ButtonRelease-1" of button-2'})
+
+b3.bind('ButtonPress-1', proc{puts 'bind "ButtonPress-1" of button-3'})
+b3.bind('ButtonRelease-1', proc{puts 'bind "ButtonRelease-1" of button-3'})
+
+b4.bind('ButtonPress-1', proc{puts 'bind "ButtonPress-1" of button-4'})
+b4.bind('ButtonRelease-1', proc{puts 'bind "ButtonRelease-1" of button-4'})
+
+b5.bind('ButtonPress-1', proc{puts 'bind "ButtonPress-1" of button-5'})
+b5.bind('ButtonRelease-1', proc{puts 'bind "ButtonRelease-1" of button-5'})
+
+# create bindtag and set binding
+tag1 = TkBindTag.new
+tag1.bind('ButtonPress-1', proc{puts 'bind "ButtonPress-1" of tag1'})
+tag1.bind('ButtonRelease-1', proc{puts 'bind "ButtonRelease-1" of tag1'})
+
+tag2 = TkBindTag.new
+tag2.bind('ButtonPress-1',
+ proc{
+ puts 'bind "ButtonPress-1" of tag2'
+ puts 'call Tk.callback_continue'
+ Tk.callback_continue
+ puts 'never see this message'
+ })
+tag2.bind('ButtonRelease-1',
+ proc{
+ puts 'bind "ButtonRelease-1" of tag2'
+ puts 'call Tk.callback_continue'
+ Tk.callback_continue
+ puts 'never see this message'
+ })
+
+tag3 = TkBindTag.new
+tag3.bind('ButtonPress-1',
+ proc{
+ puts 'bind "ButtonPress-1" of tag3'
+ puts 'call Tk.callback_break'
+ Tk.callback_break
+ puts 'never see this message'
+ })
+tag3.bind('ButtonRelease-1',
+ proc{
+ puts 'bind "ButtonRelease-1" of tag3'
+ puts 'call Tk.callback_break'
+ Tk.callback_break
+ puts 'never see this message'
+ })
+
+# set bindtags
+p b1.bindtags
+
+tags = b2.bindtags
+tags[2,0] = tag1
+tags[0,0] = tag1
+b2.bindtags(tags)
+p b2.bindtags
+
+tags = b3.bindtags
+tags[2,0] = tag2
+tags[0,0] = tag2
+b3.bindtags(tags)
+p b3.bindtags
+
+tags = b4.bindtags
+tags[2,0] = tag3
+tags[0,0] = tag3
+b4.bindtags(tags)
+p b4.bindtags
+
+b5.bindtags([tag1, TkButton, tag2, b5])
+
+# create button to set button class binding
+TkButton.new(:text=>'set binding to TkButton class',
+ :command=>proc{
+ puts 'call "set_class_bind"'
+ set_class_bind
+ }).pack(:pady=>7)
+
+# start event-loop
+Tk.mainloop
diff --git a/jni/ruby/ext/tk/sample/binstr_usage.rb b/jni/ruby/ext/tk/sample/binstr_usage.rb
new file mode 100644
index 0000000..fa81f98
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/binstr_usage.rb
@@ -0,0 +1,45 @@
+#!/usr/bin/env ruby
+
+require "tk"
+
+TkMessage.new(:width=>360, :text=><<EOM).pack
+This sample shows how to use a binary sequence between Ruby and Tk. \
+This reads the image data from the file as the binary sequence.
+
+To treat the difference of encodings between on Ruby and on Tk seamlessly, \
+Ruby/Tk converts the encoding of string arguments automatically. \
+I think it is comfortable for users on almost all situations. \
+However, when treats a binary sequence, the convert process makes troubles.
+
+Tk::BinaryString class (subclass of Tk::EncodedString class) is the class \
+to avoid such troubles. Please see the source code of this sample. \
+A Tk::BinaryString instance is used to create the image for the center button.
+EOM
+
+ImgFile=[File.dirname(__FILE__), 'images','tcllogo.gif'].join(File::Separator)
+
+ph1 = TkPhotoImage.new(:file=>ImgFile)
+p ph1.configinfo
+
+b_str = Tk::BinaryString(IO.read(ImgFile))
+p [b_str, b_str.encoding]
+
+ph2 = TkPhotoImage.new(:data=>b_str)
+p ph2.configinfo
+p ph2.data(:grayscale=>true)
+
+ph3 = TkPhotoImage.new(:palette=>256)
+ph3.put(ph2.data)
+
+ph4 = TkPhotoImage.new()
+ph4.put(ph2.data(:grayscale=>true))
+
+#p [b_str.encoding, b_str.rb_encoding]
+
+f = TkFrame.new.pack
+TkButton.new(:parent=>f, :image=>ph1, :command=>proc{exit}).pack(:side=>:left)
+TkButton.new(:parent=>f, :image=>ph2, :command=>proc{exit}).pack(:side=>:left)
+TkButton.new(:parent=>f, :image=>ph3, :command=>proc{exit}).pack(:side=>:left)
+TkButton.new(:parent=>f, :image=>ph4, :command=>proc{exit}).pack(:side=>:left)
+
+Tk.mainloop
diff --git a/jni/ruby/ext/tk/sample/btn_with_frame.rb b/jni/ruby/ext/tk/sample/btn_with_frame.rb
new file mode 100644
index 0000000..d04c95a
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/btn_with_frame.rb
@@ -0,0 +1,20 @@
+require 'tk'
+
+class Button_with_Frame < TkButton
+ def create_self(keys)
+ @frame = TkFrame.new('widgetname'=>@path, 'background'=>'yellow')
+ install_win(@path) # create new @path which is a daughter of old @path
+ super(keys)
+ TkPack(@path, :padx=>7, :pady=>7)
+ @epath = @frame.path
+ end
+ def epath
+ @epath
+ end
+end
+
+Button_with_Frame.new(:text=>'QUIT', :command=>proc{exit}) {
+ pack(:padx=>15, :pady=>5)
+}
+
+Tk.mainloop
diff --git a/jni/ruby/ext/tk/sample/cd_timer.rb b/jni/ruby/ext/tk/sample/cd_timer.rb
new file mode 100644
index 0000000..e2611fb
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/cd_timer.rb
@@ -0,0 +1,81 @@
+#!/usr/bin/env ruby
+#
+# countdown timer
+# usage: cd_timer min [, min ... ]
+# ( e.g. cd_timer 0.5 1 3 5 10 )
+#
+require 'tk'
+
+if ARGV.empty?
+ $stderr.puts 'Error:: No time arguments for counting down'
+ exit(1)
+end
+
+width = 10
+
+TkButton.new(:text=>'exit',
+ :command=>proc{exit}).pack(:side=>:bottom, :fill=>:x)
+
+b = TkButton.new(:text=>'start').pack(:side=>:top, :fill=>:x)
+
+f = TkFrame.new(:relief=>:ridge, :borderwidth=>2).pack(:fill=>:x)
+TkLabel.new(f, :relief=>:flat, :pady=>3,
+ :background=>'black', :foreground=>'white',
+ :text=>' elapsed: ').pack(:fill=>:x, :side=>:left, :expand=>true)
+now = TkLabel.new(f, :width=>width, :relief=>:flat, :pady=>3, :anchor=>:w,
+ :background=>'black', :foreground=>'white',
+ :text=>'%4d:%02d.00' % [0, 0]).pack(:side=>:right)
+
+timers = [ TkRTTimer.new(10){|tm|
+ t = (tm.return_value || 0) + 1
+ s, u = t.divmod(100)
+ m, s = s.divmod(60)
+ now.text('%4d:%02d.%02d' % [m, s, u])
+ t
+ }.set_start_proc(0, proc{
+ now.text('%4d:%02d.00' % [0,0])
+ now.foreground('white')
+ 0
+ })
+]
+
+ARGV.collect{|arg| (Float(arg) * 60).to_i}.sort.each_with_index{|time, idx|
+ f = TkFrame.new(:relief=>:ridge, :borderwidth=>2).pack(:fill=>:x)
+ TkLabel.new(f, :relief=>:flat, :pady=>3,
+ :text=>' %4d:%02d --> ' % (time.divmod(60))).pack(:side=>:left)
+ l = TkLabel.new(f, :width=>width, :relief=>:flat, :pady=>3, :anchor=>:w,
+ :text=>'%4d:%02d' % (time.divmod(60))).pack(:side=>:right)
+ timers << TkRTTimer.new(1000){|tm|
+ t = (tm.return_value || time) - 1
+ if t < 0
+ l.text('%4d:%02d' % ((-t).divmod(60)))
+ else
+ l.text('%4d:%02d' % (t.divmod(60)))
+ end
+ if t.zero?
+ l.foreground('red')
+ idx.times{Tk.bell}
+ end
+ t
+ }.set_start_proc(0, proc{
+ l.text('%4d:%02d' % (time.divmod(60)))
+ l.foreground('black')
+ time
+ })
+}
+
+mode = :start
+b.command(proc{
+ if mode == :start
+ timers.each{|timer| timer.restart}
+ b.text('reset')
+ mode = :reset
+ else
+ timers.each{|timer| timer.stop.reset}
+ b.text('start')
+ mode = :start
+ end
+ })
+
+Tk.mainloop
+
diff --git a/jni/ruby/ext/tk/sample/cmd_res_test.rb b/jni/ruby/ext/tk/sample/cmd_res_test.rb
new file mode 100644
index 0000000..8df2e61
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/cmd_res_test.rb
@@ -0,0 +1,17 @@
+require 'tk'
+TkOptionDB.readfile(File.expand_path('cmd_resource',
+ File.dirname(__FILE__)))
+f = TkFrame.new(:class=>'BtnFrame').pack
+b = TkButton.new(:parent=>f, :widgetname=>'hello').pack
+cmd1 = TkOptionDB.new_proc_class(b, [:show_msg, :bye_msg], 3)
+cmd2 = TkOptionDB.new_proc_class(:ZZZ, [:show_msg, :bye_msg], 3, false, cmd1)
+cmd3 = TkOptionDB.new_proc_class(:ZZZ, [:show_msg, :bye_msg], 3, false, b)
+cmd4 = TkOptionDB.new_proc_class(:BTN_CMD, [:show_msg, :bye_msg], 3){
+ def self.__check_proc_string__(str)
+ "{|arg| print [arg, $SAFE].inspect, ': '; Proc.new#{str}.call(arg)}"
+ end
+}
+cmd1.show_msg('cmd1')
+cmd2.show_msg('cmd2')
+cmd3.show_msg('cmd3')
+cmd4.show_msg('cmd4')
diff --git a/jni/ruby/ext/tk/sample/cmd_resource b/jni/ruby/ext/tk/sample/cmd_resource
new file mode 100644
index 0000000..9cc4915
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/cmd_resource
@@ -0,0 +1,5 @@
+*BtnFrame.hello.text: HELLO
+*BtnFrame.hello.command: ruby {puts "Hello World!!"}
+*BTN_CMD.show_msg: {|arg| print "Hello, #{arg}!!\n"}
+*hello.show_msg: {|arg| print "Hello, Hello, #{arg}!!\n"}
+*hello.ZZZ.show_msg: {|arg| print "Hello, Hello, ZZZ:#{arg}!!\n"}
diff --git a/jni/ruby/ext/tk/sample/demos-en/ChangeLog b/jni/ruby/ext/tk/sample/demos-en/ChangeLog
new file mode 100644
index 0000000..c3f66cf
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/demos-en/ChangeLog
@@ -0,0 +1,64 @@
+2002-08-29 16:30 matt
+
+ * ChangeLog: ChangeLog is auto-generated *from* CVS log.
+
+2002-08-29 16:27 matt
+
+ * ChangeLog.prev: [no log message]
+
+2002-08-28 18:07 matt
+
+ * browse1, browse2, hello, ixset, rmt, rolodex, rolodex-j, square,
+ tcolor, timer, widget: Changed #! lines to the slightly more
+ portable '#!/usr/bin/env ruby'.
+
+2002-08-28 17:56 matt
+
+ * icon.rb, items.rb, label.rb, menu.rb, ruler.rb: Changed bitmap
+ file extensions from .bmp to .xbm.
+
+2002-08-28 17:55 matt
+
+ * images/: face.bmp, face.xbm, flagdown.bmp, flagdown.xbm,
+ flagup.bmp, flagup.xbm, gray25.bmp, gray25.xbm, letters.bmp,
+ letters.xbm, noletter.bmp, noletter.xbm, pattern.bmp, pattern.xbm:
+ Changed X bitmap file extensions from .bmp to the more intuitive
+ .xbm.
+
+2002-08-28 17:35 matt
+
+ * bitmap.rb, colors.rb, cscroll.rb, ctext.rb, hello, ixset,
+ menubu.rb, patch_1.1c1, rmt, style.rb, timer, ChangeLog, README,
+ README.tkencoding, arrow.rb, bind.rb, browse1, browse2, button.rb,
+ check.rb, clrpick.rb, dialog1.rb, dialog2.rb, entry1.rb, entry2.rb,
+ filebox.rb, floor.rb, form.rb, hscale.rb, icon.rb, image1.rb,
+ image2.rb, items.rb, label.rb, menu.rb, msgbox.rb, plot.rb,
+ puzzle.rb, radio.rb, rolodex, rolodex-j, ruler.rb, sayings.rb,
+ search.rb, square, states.rb, tcolor, text.rb, tkencoding.rb,
+ twind.rb, vscale.rb, widget, doc.org/README, doc.org/README.JP,
+ doc.org/README.tk80, doc.org/license.terms,
+ doc.org/license.terms.tk80, images/earth.gif, images/earthris.gif,
+ images/face.bmp, images/flagdown.bmp, images/flagup.bmp,
+ images/gray25.bmp, images/grey.25, images/grey.5,
+ images/letters.bmp, images/noletter.bmp, images/pattern.bmp,
+ images/tcllogo.gif, images/teapot.ppm: Initial revision
+
+2002-08-28 17:35 matt
+
+ * bitmap.rb, colors.rb, cscroll.rb, ctext.rb, hello, ixset,
+ menubu.rb, patch_1.1c1, rmt, style.rb, timer, ChangeLog, README,
+ README.tkencoding, arrow.rb, bind.rb, browse1, browse2, button.rb,
+ check.rb, clrpick.rb, dialog1.rb, dialog2.rb, entry1.rb, entry2.rb,
+ filebox.rb, floor.rb, form.rb, hscale.rb, icon.rb, image1.rb,
+ image2.rb, items.rb, label.rb, menu.rb, msgbox.rb, plot.rb,
+ puzzle.rb, radio.rb, rolodex, rolodex-j, ruler.rb, sayings.rb,
+ search.rb, square, states.rb, tcolor, text.rb, tkencoding.rb,
+ twind.rb, vscale.rb, widget, doc.org/README, doc.org/README.JP,
+ doc.org/README.tk80, doc.org/license.terms,
+ doc.org/license.terms.tk80, images/earth.gif, images/earthris.gif,
+ images/face.bmp, images/flagdown.bmp, images/flagup.bmp,
+ images/gray25.bmp, images/grey.25, images/grey.5,
+ images/letters.bmp, images/noletter.bmp, images/pattern.bmp,
+ images/tcllogo.gif, images/teapot.ppm: Taking over demo package
+ from Jonathan Conway.
+
diff --git a/jni/ruby/ext/tk/sample/demos-en/ChangeLog.prev b/jni/ruby/ext/tk/sample/demos-en/ChangeLog.prev
new file mode 100644
index 0000000..ba808ec
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/demos-en/ChangeLog.prev
@@ -0,0 +1,9 @@
+2001-07-26 <rise@leannan.knavery.net>
+
+ * Moved files to directory ruby-tk81-demos-english in tarball.
+
+2001-07-26 <rise@knavery.net>
+
+ * Added test to widget and hello versus Tk::TCL_VERSION & Tk::JAPANIZED_TK (per Guy Decoux in [ruby-talk:18559]) before requiring tkencoding.rb.
+
+
diff --git a/jni/ruby/ext/tk/sample/demos-en/README b/jni/ruby/ext/tk/sample/demos-en/README
new file mode 100644
index 0000000..033dca3
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/demos-en/README
@@ -0,0 +1,138 @@
+Current Maintainer:
+ Jonathan Conway
+ rise@knavery.net
+
+ Please direct all bug reports/requests/suggestions to the above
+ address.
+
+
+Notes:
+
+* The files hello and widget have been changed to test Tk::TCL_VERSION
+ and Tk::JAPANIZED_TK before requiring tkencoding.rb to prevent an
+ infinite loop. This test was taken from a message in
+ [ruby-talk:18559] by Guy Decoux.
+
+* The .bmp files in the images directory are X bitmaps (i.e. XBM to many
+ graphics packages), not Windows bitmaps (.bmp). You will not be
+ able to use images exported by a graphics program as Windows
+ bitmaps with this demo collection nor will you be able to edit the
+ included images without setting the file type correctly.
+
+-- Jonathan Conway, 2001-07-26
+
+
+#------------------------------------------------------------------------------
+# ==== Introduction. ====
+#
+# To create this version of the Ruby/Tk widget demo, I took the
+# ruby-tk81-demos and removed all the Kanji strings and comments. I
+# have tried to restore the original English strings and comments
+# using the Tcl/Tk8.2.2 version of the widget demo.
+#
+# When I tried running the Kanji version, all I got was a mostly blank
+# panel with a non-functional "File" button. I disovered that if all
+# non-ASCII characters were replaced with blanks, then I could get the
+# gutted stuff running.
+#
+# Since English Ruby/Tk documentation is lacking and I needed this
+# code to see how it worked and to use as the basis of my try-it
+# prototype (The Ruby Yielding Interactive Toolkit), plus the fact
+# that no help was forthcoming for making the Kanji version work (plus
+# the fact that I can't read Kanji anyway), I decided to embark on
+# this English restoration project.
+#
+# Thanks to everyone who worked on the original Ruby/Tk widget demo
+# (and the preceding Tcl/Tk version for that matter). The
+# comparatively simple task of changing text strings and comments has
+# made me appreciate the great amount of original work that went into
+# this.
+#
+# -- Conrad Schneiker, 2000-07-23.
+#------------------------------------------------------------------------------
+
+#------------------------------------------------------------------------------
+# ==== Known bugs. ====
+#
+# ^C-ing the demo gives Ruby interrupt and stack message; clean exit needed.
+# Font settings don't work correctly.
+# Dismissing the embedded windows demo (tkwind.rb) kills the widget demo.
+# Rerunning the canvas item demo from the code widow get errors.
+# The "press me" button in the canvas item demo doesn't time out.
+# The simple 2 d plot starts up extremely slow compared to the Tcl version.
+# The first item message on the icon menu on the menu and cascades demo doesn't work.
+#------------------------------------------------------------------------------
+
+
+###################### Original README ########################################
+
+ Ruby/Tk81 widget-demo 1999/08/13
+
+ 北陸先端大情報科学研究科
+ 立石 <ttate@jaist.ac.jp>
+
+Tcl/Tk8.1ã§ã¯unicode(UTF8)ãŒæŽ¡ç”¨ã•ã‚Œã€unicodeã«å¤‰æ›ã•ã‚ŒãŸæ—¥æœ¬èªžã§ã‚ã‚Œã°
+Widgetã«è¡¨ç¤ºã•ã›ã‚‹ã“ã¨ãŒå¯èƒ½ã§ã™ã€‚本アーカイブã«ã¯ä»¥å‰ã«æ°¸äº•ã•ã‚“ãŒä¸­å¿ƒã¨
+ãªã‚‰ã‚Œã¦ä½œæˆã•ã‚ŒãŸRuby/Tkã®ã‚µãƒ³ãƒ—ルã«ä¿®æ­£ã‚’加ãˆã€ä»¥ä¸‹ã®ç’°å¢ƒã«ãŠã„ã¦ã§å‹•ä½œ
+を確èªã—ãŸã‚‚ã®ã§ã™ã€‚
+
+* ruby-1.3.7,ruby-1.4.0
+* tcl8.1, tk8.1
+* linux-2.2
+
+Windows(Cygwin)ã«ãŠã„ã¦ã€ã‚µãƒ³ãƒ—ルを動ã‹ã™ã«ã¯rubyã‚’-Keã¨ã„ã†ã‚ªãƒ—ションを付
+ã‘ã¦èµ·å‹•ã•ã›ã‚‹ã¨è‰¯ã„ãã†ã§ã™ã€‚
+ 情報æ供:渡辺ã•ã‚“
+ <eban@os.rim.or.jp>
+
+----------------------------------------------------------------------------
+ Ruby/Tk widget-demo
+ version 1.1 ( 1998/07/24 )
+ 永井@知能.ä¹å·¥å¤§ (nagai@ai.kyutech.ac.jp)
+
+標準é…布㮠Tcl/Tk 拡張パッケージをå–ã‚Šè¾¼ã‚“ã  Ruby (以下 Ruby/Tk ã¨å‘¼ã³ã¾ã™)
+ã§ã¯ï¼ŒTk widget を用ã„㟠GUI ã®ä½œæˆã‚’è¡Œã†ã“ã¨ãŒã§ãã¾ã™ï¼Žå®Ÿéš›ã« GUI を作æˆ
+ã—ã¦ã„ãå ´åˆã«ã¯æ§˜ã€…ãªå®Ÿä¾‹ãŒã‚µãƒ³ãƒ—ルã¨ã—ã¦å­˜åœ¨ã™ã‚‹ã¨ä¾¿åˆ©ãªã®ã§ã™ãŒï¼ŒRuby/Tk
+ã«ã¯ãã®ã‚ˆã†ãªé©å½“ãªã‚µãƒ³ãƒ—ルスクリプト集åˆã¯å­˜åœ¨ã—ã¾ã›ã‚“ã§ã—ãŸï¼Žãã‚Œã«å¯¾ã—,
+拡張パッケージã®å…ƒã§ã‚ã‚‹ Tcl/Tk ã«ã¯ï¼ŒTk widget を用ã„ã¦ã©ã®ã‚ˆã†ãªã“ã¨ãŒã§
+ãã‚‹ã‹ã‚’示ã™ã‚‚ã®ã¨ã—㦠widget-demo ãŒå­˜åœ¨ã—ãŠã‚Šï¼ŒTcl/Tk を用ã„㟠GUI ã®ä½œæˆ
+ã‚’ç¿’å¾—ã™ã‚‹éš›ã®ä»£è¡¨çš„サンプルã¨ãªã£ã¦ã„ã¾ã™ï¼Žæœ¬ã‚¢ãƒ¼ã‚«ã‚¤ãƒ–ã¯ï¼ŒRuby/Tk ã®ç¿’å¾—ã®
+ãŸã‚ã®ä»£è¡¨çš„ãªã‚µãƒ³ãƒ—ルスクリプトã¨ã™ã¹ã,Tcl/Tk ã® widget-demo を移æ¤ã—ãŸã‚‚
+ã®ã§ã™ï¼Ž
+
+本アーカイブã«å«ã¾ã‚Œã‚‹ã‚¹ã‚¯ãƒªãƒ—トを実行ã™ã‚‹ãŸã‚ã«ã¯ï¼Œruby-1.1c2 以上ã§ã‚ã‚‹ã“
+ã¨ãŒå¿…è¦ã§ã™ï¼Ž1.1c1 ã®å ´åˆã¯ï¼Œæœ¬ã‚¢ãƒ¼ã‚«ã‚¤ãƒ–ã«å«ã¾ã‚Œã‚‹ patck_1.1c1 ã‚’ Ruby ã®
+ライブラリã«ã‚ã¦ã¦ãã ã•ã„.組ã¿è¾¼ã‚€ Tk ã®ãƒãƒ¼ã‚¸ãƒ§ãƒ³ã¯ï¼Œ4.2 ã§ã‚‚ 8.0 ã§ã‚‚ä¿®
+æ­£ãªãå‹•ã‹ã›ã‚‹ã¯ãšã§ã™ï¼ŽãŸã ã—,日本語版ã§ã®ç§»æ¤ã¨ãªã£ã¦ã„ã‚‹ãŸã‚,日本語化ã•
+れ㟠Tk ã‚’ã”利用ãã ã•ã„.スクリプトã®ãƒ†ã‚¹ãƒˆã¯ï¼ŒTk4.2jp 㨠Tk8.0jp ã®ä¸Šã§è¡Œ
+ã„ã¾ã—㟠(完璧ã«ã§ã¯ãªã„ã§ã™ãŒ).
+
+本アーカイブã«å«ã¾ã‚Œã‚‹ã‚¹ã‚¯ãƒªãƒ—トã®å¤šãã¯ï¼Œå…ƒã¨ãªã£ã¦ã„ã‚‹ Tcl/Tk 版ã«æ¯”較的近
+ã„スクリプト記述ã¨ãªã‚‹ã‚ˆã†ã«ã—ã¦ã„ã¾ã™ï¼Žãã®ãŸã‚,Ruby/Tk ã®ã‚µãƒ³ãƒ—ルã¨è¨€ã†ã«
+ã¯ï¼Œã‚ã¾ã‚Š Ruby らã—ããªã„ã¨ã‚‚言ãˆã‚‹ã§ã—ょã†ï¼Žã«ã‚‚ã‹ã‹ã‚らãšï¼Œãã®ã‚ˆã†ãªè¨˜è¿°
+ã‚’å–ã£ã¦ã„ã‚‹ç†ç”±ã¯ï¼ŒRuby/Tk ã®ãƒ‰ã‚­ãƒ¥ãƒ¡ãƒ³ãƒˆä¸è¶³ã«ã‚ã‚Šã¾ã™ï¼Ž
+
+Tcl/Tk ã«ã¯é©å½“ãªå‚考書ãŒä½•å†Šã‹å­˜åœ¨ã—ã¦ã„ã¾ã™ã‹ã‚‰ï¼ŒRuby/Tk スクリプトを作æˆ
+ã™ã‚‹éš›ã¯ï¼Œãã®ã‚ˆã†ãª Tcl/Tk ã®å‚考書ã§æƒ…報を補ã„ãªãŒã‚‰ä½œæˆã™ã‚‹ã“ã¨ã«ãªã‚‹ã¨æ€
+ã„ã¾ã™ï¼Žå„ widget ã®ä½¿ç”¨ä¾‹ã¨ã—ã¦ï¼ŒTcl/Tk ã® widget-demo ã‚’å‚ç…§ã™ã‚‹ã“ã¨ã‚‚ã‚ã‚‹
+ã§ã—ょã†ï¼ŽRuby/Tk 版ã®è¨˜è¿°ã‚’ widget-demo ã‚’ Tcl/Tk 版ã®è¨˜è¿°ã«è¿‘ã„ã‚‚ã®ã«ã—ã¦
+ãŠã‘ã°ï¼Œãã®å¯¾æ¯”ã«ã‚ˆã£ã¦ï¼ŒRuby/Tk ã®ç†è§£ã‚’æ—©ã‚ã‚‹ã“ã¨ãŒã§ãã‚‹ã¨è€ƒãˆã‚‰ã‚Œã¾ã™ï¼Ž
+一旦 Ruby/Tk ã§ã® å„ widget ã®ä½¿ç”¨æ–¹æ³•ã‚’ç¿’å¾—ã—ã¦ã—ã¾ãˆã°ï¼ŒRuby らã—ã„スクリ
+プトを作æˆã™ã‚‹ã“ã¨ã¯é›£ã—ããªã„ã§ã—ょã†ï¼Žæœ¬ã‚¢ãƒ¼ã‚«ã‚¤ãƒ–ã®ã‚¹ã‚¯ãƒªãƒ—トã¯ï¼ŒRuby/Tk
+を最åˆã«ç¿’å¾—ã™ã‚‹ã¾ã§ã®è¸å°ã¨ã—ã¦åˆ©ç”¨ã—ã¦ã„ãŸã ã‘ã‚Œã°å¹¸ã„ã§ã™ï¼Ž
+
+widget-demo ã®ç§»æ¤ã«ã‚ãŸã£ã¦ã¯ï¼Œæ¬¡ã®æ–¹ã«ã‚‚移æ¤ã—ãŸã‚¹ã‚¯ãƒªãƒ—トをæä¾›ã—ã¦ã„ãŸã 
+ãã¾ã—ãŸï¼Žã“ã“ã«æ„Ÿè¬ã®æ„を表ã—ã¾ã™ï¼Ž
+
+ 立石@JAIST (ttate@jaist.ac.jp) ã•ã‚“
+ å¹³æ¾ç¥¥å² (hiramatu@cdrom.co.jp) ã•ã‚“
+
+å¹³æ¾ã•ã‚“ã«ã‚ˆã‚‹ Ruby/Tk 入門㮠Web page (http://www.cdrom.co.jp/~hiramatu/)
+ã‚‚ Ruby/Tk ã®ç¿’å¾—ã«æœ‰ç”¨ã¨æ€ãˆã¾ã™ã®ã§ï¼Œãœã²ã”å‚ç…§ãã ã•ã„.
+
+ã¾ãŸï¼Œå‰æ©‹ (maebashi@iij.ad.jp) ã•ã‚“ã‚’ã¯ã˜ã‚ã¨ã—ã¦ï¼Œwidget-demo ã®ç§»æ¤ã«éš›ã—
+ã¦å¿…è¦ã¨ãªã£ãŸ Ruby ã® Tk 関連ライブラリ修正ã«ã¤ã„ã¦ï¼Œå•é¡Œç‚¹ï¼Œãƒã‚°ã®æŒ‡æ‘˜ã‚’ã—
+ã¦ã„ãŸã ã„ãŸæ–¹ã€…ã«ã‚‚æ„Ÿè¬è‡´ã—ã¾ã™ï¼Ž
+
+ãã—ã¦æœ€å¾Œã«æœ€å¤§ã®æ„Ÿè¬ã‚’ Ruby 設計者㮠ã¾ã¤ã‚‚㨠ゆãã²ã‚ (matz@netlab.co.jp)
+ã•ã‚“ã«æ§ã’ãŸã„ã¨æ€ã„ã¾ã™ï¼Ž
diff --git a/jni/ruby/ext/tk/sample/demos-en/README.1st b/jni/ruby/ext/tk/sample/demos-en/README.1st
new file mode 100644
index 0000000..2ba1e27
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/demos-en/README.1st
@@ -0,0 +1,18 @@
+There are Ruby/Tk demo scripts.
+
+Files with '.rb' extension are sub-scripts which are launched 'widget'
+script. Those files don't work independently. Please call them from
+'widget' script.
+
+If you want start some sub-scripts at same time when the launcher
+script tarts, please give the sub-script names as arguments.
+(e.g. /usr/local/bin/ruby widget button.rb entry1.rb text.rb )
+You can ommit '.rb' of the sub-scripts
+(e.g. /usr/local/bin/ruby widget button entry1 text )
+
+If you don't need launcher's main window, give -n option.
+(e.g. /usr/local/bin/ruby widget -n button.rb entry1.rb text.rb )
+
+Others (browse1, hello, and so on) are standalone scripts.
+
+ 2004/04/14 Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
diff --git a/jni/ruby/ext/tk/sample/demos-en/README.tkencoding b/jni/ruby/ext/tk/sample/demos-en/README.tkencoding
new file mode 100644
index 0000000..cca8734
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/demos-en/README.tkencoding
@@ -0,0 +1,29 @@
+This is a original document of 'tkencoding.rb'.
+The library 'tkencoding.rb' is obsolete.
+Functions of tkencoding.rb is already included into Ruby/Tk.
+
+-------------------------------------------------
+tkencoding.rbを用ã„ãŸæ—¥æœ¬èªžã®è¡¨ç¤ºã«ã¤ã„ã¦
+
+Copyright (C) 1999/07, Takaaki Tateishi <ttate@jaist.ac.jp>
+
+
+1. tkencoding.rbã¨ã¯ï¼Ÿ
+
+tkencoding.rbã¯Tcl/Tk8.1を利用ã—ãŸRuby/Tkã®ãŸã‚ã®ãƒ©ã‚¤ãƒ–ラリ
+ã§ã™ã€‚tkencoding.rbã‚’requireã™ã‚‹ã“ã¨ã«ã‚ˆã£ã¦Wedgetã«è¡¨ç¤ºã•
+れるテキストã¯å…¨ã¦unicode(UTF8)ã¸å¤‰æ›ã•ã‚Œã¾ã™ã€‚
+
+
+2. 使ã„æ–¹
+
+tkencoding.rbã‚’requireã—ã¦Tk.encodingã§ä½¿ç”¨ã—ã¦ã„る文字コード
+を指定ã—ã¦ä¸‹ã•ã„。例ãˆã°ä»¥ä¸‹ã®ã‚ˆã†ãªæ„Ÿã˜ã«ãªã‚Šã¾ã™ã€‚
+
+----
+require 'tk'
+require 'tkencoding'
+
+Tk.encoding = "utf-8"
+# Tk.encoding = "shiftjis"
+---
diff --git a/jni/ruby/ext/tk/sample/demos-en/anilabel.rb b/jni/ruby/ext/tk/sample/demos-en/anilabel.rb
new file mode 100644
index 0000000..ebd84ac
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/demos-en/anilabel.rb
@@ -0,0 +1,174 @@
+#
+# animated label widget demo (called by 'widget')
+#
+# based on Tcl/Tk8.5a2 widget demos
+
+if defined?($anilabel_demo) && $anilabel_demo
+ $anilabel_demo.destroy
+ $anilabel_demo = nil
+end
+
+# demo toplevel widget
+$anilabel_demo = TkToplevel.new {|w|
+ title("Animated Label Demonstration")
+ iconname("anilabel")
+ positionWindow(w)
+}
+
+base_frame = TkFrame.new($anilabel_demo).pack(:fill=>:both, :expand=>true)
+
+# label
+msg = TkLabel.new(base_frame) {
+ font $font
+ wraplength '4i'
+ justify 'left'
+ text "Four animated labels are displayed below; each of the labels on the left is animated by making the text message inside it appear to scroll, and the label on the right is animated by animating the image that it displays."
+}
+msg.pack('side'=>'top')
+
+# frame
+TkFrame.new(base_frame) {|frame|
+ TkButton.new(frame) {
+ text 'Dismiss'
+ command proc{
+ tmppath = $anilabel_demo
+ $anilabel_demo = nil
+ tmppath.destroy
+ }
+ }.pack('side'=>'left', 'expand'=>'yes')
+
+ TkButton.new(frame) {
+ text 'See Code'
+ command proc{showCode 'anilabel'}
+ }.pack('side'=>'left', 'expand'=>'yes')
+
+}.pack('side'=>'bottom', 'fill'=>'x', 'pady'=>'2m')
+
+# create frame for label demo
+f_left = TkLabelFrame.new(base_frame, :text=>'Scrolling Texts')
+f_right = TkLabelFrame.new(base_frame, :text=>'GIF Image')
+Tk.pack(f_left, f_right, 'side'=>'left', 'expand'=>'yes', 'fill'=>'both',
+ 'padx'=>10, 'pady'=>10)
+
+# animated label
+class AnimatedTextLabel < TkLabel
+ def initialize(*args)
+ super(*args)
+ @timer = TkTimer.new{ _animation_callback }
+ @timer.loop_exec = -1
+ # bind('Destroy'){ @timer.stop }
+ @btag = TkBindTag.new('Destroy'){ @timer.stop }
+ self.bindtags_unshift(@btag)
+ end
+
+ def _animation_callback()
+ txt = self.text
+ self.text = (txt[1..-1] << txt[0])
+ end
+ private :_animation_callback
+
+ def start(interval)
+ @timer.set_interval(interval)
+ @timer.start
+ end
+
+ def stop
+ @timer.stop
+ end
+end
+
+# animated image
+class AnimatedImageLabel < AnimatedTextLabel
+ def initialize(*args)
+ super(*args)
+ @destroy_image = false
+ @btag.bind_append('Destroy'){
+ if @destroy_image
+ begin
+ self.image.delete
+ rescue
+ end
+ end
+ }
+ end
+ attr_accessor :destroy_image
+
+ def _animation_callback()
+ img = self.image
+
+ fmt = img.format
+ if fmt.kind_of?(Array)
+ if fmt[1].kind_of?(Hash)
+ # fmt == ['GIF', {'index'=>idx}]
+ idx = fmt[1]['index']
+ else
+ # fmt == ['GIF', '-index', idx] :: Ruby1.8.2 returns this.
+ idx = fmt[2]
+ end
+ elsif fmt.kind_of?(String) && fmt =~ /GIF -index (\d+)/
+ idx = $1.to_i
+ else
+ idx = -1
+ end
+
+ begin
+ img.format("GIF -index #{idx + 1}")
+ rescue => e
+ img.format("GIF -index 0")
+ end
+ end
+ private :_animation_callback
+end
+
+# create labels
+l1 = AnimatedTextLabel.new(f_left, :borderwidth=>4, :relief=>:ridge,
+ :font=>{:family=>'Courier', :size=>10})
+l2 = AnimatedTextLabel.new(f_left, :borderwidth=>4, :relief=>:groove,
+ :font=>{:family=>'Courier', :size=>10})
+l3 = AnimatedTextLabel.new(f_left, :borderwidth=>4, :relief=>:flat,
+ :font=>{:family=>'Courier', :size=>10}, :width=>18)
+Tk.pack(l1, l2, l3,
+ :side=>:top, :expand=>true, :anchor=>:w, :padx=>10, :pady=>10)
+
+limg = AnimatedImageLabel.new(f_right, :borderwidth=>0)
+limg.pack(:side=>:top, :expand=>true, :padx=>10, :pady=>10)
+
+# base64-encoded animated GIF file
+tclPowerdData = <<EOD
+ R0lGODlhKgBAAPQAAP//////zP//AP/MzP/Mmf/MAP+Zmf+ZZv+ZAMz//8zM
+ zMyZmcyZZsxmZsxmAMwzAJnMzJmZzJmZmZlmmZlmZplmM5kzM2aZzGZmzGZm
+ mWZmZmYzZmYzMzNmzDMzZgAzmSH+IE1hZGUgd2l0aCBHSU1QIGJ5IExARGVt
+ YWlsbHkuY29tACH5BAVkAAEALAAAAAAqAEAAAAX+YCCOZEkyTKM2jOm66yPP
+ dF03bx7YcuHIDkGBR7SZeIyhTID4FZ+4Es8nQyCe2EeUNJ0peY2s9mi7PhAM
+ ngEAMGRbUpvzSxskLh1J+Hkg134OdDIDEB+GHxtYMEQMTjMGEYeGFoomezaC
+ DZGSHFmLXTQKkh8eNQVpZ2afmDQGHaOYSoEyhhcklzVmMpuHnaZmDqiGJbg0
+ qFqvh6UNAwB7VA+OwydEjgujkgrPNhbTI8dFvNgEYcHcHx0lB1kX2IYeA2G6
+ NN0YfkXJ2BsAMuAzHB9cZMk3qoEbRzUACsRCUBK5JxsC3iMiKd8GN088SIyT
+ 0RAFSROyeEg38caDiB/+JEgqxsODrZJ1BkT0oHKSmI0ceQxo94HDpg0qsuDk
+ UmRAMgu8OgwQ+uIJgUMVeGXA+IQkzEeHGvD8cIGlDXsLiRjQ+EHroQhea7xY
+ 8IQBSgYYDi1IS+OFBCgaDMGVS3fGi5BPJpBaENdQ0EomKGD56IHwO39EXiSC
+ Ysgxor5+Xfgq0qByYUpiXmwuoredB2aYH4gWWda0B7SeNENpEJHC1ghi+pS4
+ AJpIAwWvKPBi+8YEht5EriEqpFfMlhEdkBNpx0HUhwypx5T4IB1MBg/Ws2sn
+ wV3MSQOkzI8fUd48Aw3dOZto71x85hHtHijYv18Gf/3GqCdDCXHNoICBobSo
+ IqBqJLyCoH8JPrLgdh88CKCFD0CGmAiGYPgffwceZh6FC2ohIIklnkhehTNY
+ 4CIHHGzgwYw01ujBBhvAqKOLLq5AAk9kuSPkkKO40NB+h1gnypJIIvkBf09a
+ N5QIRz5p5ZJXJpmlIVhOGQA2TmIJZZhKKmmll2BqyWSXWUrZpQtpatlmk1c2
+ KaWRHeTZEJF8SqLDn/hhsOeQgBbqAh6DGqronxeARUIIACH5BAUeAAAALAUA
+ LgAFAAUAAAUM4CeKz/OV5YmqaRkCACH5BAUeAAEALAUALgAKAAUAAAUUICCK
+ z/OdJVCaa7p+7aOWcDvTZwgAIfkEBR4AAQAsCwAuAAkABQAABRPgA4zP95zA
+ eZqoWqqpyqLkZ38hACH5BAUKAAEALAcALgANAA4AAAU7ICA+jwiUJEqeKau+
+ r+vGaTmac63v/GP9HM7GQyx+jsgkkoRUHJ3Qx0cK/VQVTKtWwbVKn9suNunc
+ WkMAIfkEBQoAAAAsBwA3AAcABQAABRGgIHzk842j+Yjlt5KuO8JmCAAh+QQF
+ CgAAACwLADcABwAFAAAFEeAnfN9TjqP5oOWziq05lmUIACH5BAUKAAAALA8A
+ NwAHAAUAAAUPoPCJTymS3yiQj4qOcPmEACH5BAUKAAAALBMANwAHAAUAAAUR
+ oCB+z/MJX2o+I2miKimiawgAIfkEBQoAAAAsFwA3AAcABQAABRGgIHzfY47j
+ Q4qk+aHl+pZmCAAh+QQFCgAAACwbADcABwAFAAAFEaAgfs/zCV9qPiNJouo7
+ ll8IACH5BAUKAAAALB8ANwADAAUAAAUIoCB8o0iWZggAOw==
+EOD
+
+l1.text('* Slow Animation *').start(300)
+l2.text('* Fast Animation *').start(80)
+l3.text('This is a longer scrolling text in a widget that will not show the whole message at once. ').start(150)
+
+limg.destroy_image = true
+limg.image(TkPhotoImage.new(:format=>'GIF', :data=>tclPowerdData)).start(100)
diff --git a/jni/ruby/ext/tk/sample/demos-en/aniwave.rb b/jni/ruby/ext/tk/sample/demos-en/aniwave.rb
new file mode 100644
index 0000000..57d5819
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/demos-en/aniwave.rb
@@ -0,0 +1,118 @@
+#
+# animated wave demo (called by 'widget')
+#
+# based on Tcl/Tk8.5a2 widget demos
+
+# destroy toplevel widget for this demo script
+if defined?($aniwave_demo) && $aniwave_demo
+ $aniwave_demo.destroy
+ $aniwave_demo = nil
+end
+
+# create toplevel widget
+$aniwave_demo = TkToplevel.new {|w|
+ title("Animated Wave Demonstration")
+ iconname("aniwave")
+ positionWindow(w)
+}
+
+base_frame = TkFrame.new($aniwave_demo).pack(:fill=>:both, :expand=>true)
+
+# create label
+msg = TkLabel.new(base_frame) {
+ font $font
+ wraplength '4i'
+ justify 'left'
+ text 'This demonstration contains a canvas widget with a line item inside it. The animation routines work by adjusting the coordinates list of the line.'
+}
+msg.pack('side'=>'top')
+
+# create frame
+TkFrame.new(base_frame) {|frame|
+ TkButton.new(frame) {
+ text 'Dismiss'
+ command proc{
+ tmppath = $aniwave_demo
+ $aniwave_demo = nil
+ tmppath.destroy
+ }
+ }.pack('side'=>'left', 'expand'=>'yes')
+
+ TkButton.new(frame) {
+ text 'See Code'
+ command proc{showCode 'aniwave'}
+ }.pack('side'=>'left', 'expand'=>'yes')
+
+}.pack('side'=>'bottom', 'fill'=>'x', 'pady'=>'2m')
+
+# animated wave
+class AnimatedWaveDemo
+ def initialize(frame, dir=:left)
+ @direction = dir
+
+ # create canvas widget
+ @c = TkCanvas.new(frame, :width=>300, :height=>200,
+ :background=>'black')
+ @c.pack(:padx=>10, :pady=>10, :expand=>true)
+
+ # Creates a coordinates list of a wave.
+ @waveCoords = []
+ @backupCoords = []
+ n = 0
+ (-10..300).step(5){|n| @waveCoords << [n, 100]; @backupCoords << [n, 100] }
+ n = 305
+ @waveCoords << [n, 0]; @backupCoords << [n, 0]
+ @waveCoords << [n+5, 200]; @backupCoords << [n+5, 200]
+ @coordsLen = @waveCoords.length
+
+ # Create a smoothed line and arrange for its coordinates to be the
+ # contents of the variable waveCoords.
+ @line = TkcLine.new(@c, @waveCoords,
+ :width=>1, :fill=>'green', :smooth=>true)
+
+ # Main animation "loop".
+ # Theoretically 100 frames-per-second (==10ms between frames)
+ @timer = TkTimer.new(10){ basicMotion; reverser }
+
+ # Arrange for the animation loop to stop when the canvas is deleted
+ @c.bindtags_unshift(TkBindTag.new('Destroy'){ @timer.stop })
+ end
+
+ # Basic motion handler. Given what direction the wave is travelling
+ # in, it advances the y coordinates in the coordinate-list one step in
+ # that direction.
+ def basicMotion
+ @backupCoords, @waveCoords = @waveCoords, @backupCoords
+ (0...@coordsLen).each{|idx|
+ if @direction == :left
+ @waveCoords[idx][1] = @backupCoords[(idx+1 == @coordsLen)? 0: idx+1][1]
+ else
+ @waveCoords[idx][1] = @backupCoords[(idx == 0)? -1: idx-1][1]
+ end
+ }
+ @line.coords(@waveCoords)
+ end
+
+ # Oscillation handler. This detects whether to reverse the direction
+ # of the wave by checking to see if the peak of the wave has moved off
+ # the screen (whose size we know already.)
+ def reverser
+ if @waveCoords[0][1] < 10
+ @direction = :right
+ elsif @waveCoords[-1][1] < 10
+ @direction = :left
+ end
+ end
+
+ # animation control
+ def move
+ @timer.start
+ end
+
+ def stop
+ @timer.stop
+ end
+end
+
+# Start the animation processing
+AnimatedWaveDemo.new(base_frame, :left).move
diff --git a/jni/ruby/ext/tk/sample/demos-en/arrow.rb b/jni/ruby/ext/tk/sample/demos-en/arrow.rb
new file mode 100644
index 0000000..452153d
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/demos-en/arrow.rb
@@ -0,0 +1,249 @@
+# arrow.rb
+#
+# This demonstration script creates a canvas widget that displays a
+# large line with an arrowhead whose shape can be edited interactively.
+#
+# arrowhead widget demo (called by 'widget')
+#
+
+# arrowSetup --
+# This method regenerates all the text and graphics in the canvas
+# window. It's called when the canvas is initially created, and also
+# whenever any of the parameters of the arrow head are changed
+# interactively.
+#
+# Arguments:
+# c - Name of the canvas widget.
+
+def arrowSetup(c)
+ v = $demo_arrowInfo
+
+ # Remember the current box, if there is one.
+ tags = c.gettags('current')
+ if tags != []
+ cur = tags.find{|t| t.kind_of?(String) && t =~ /^box[1-3]$/ }
+ else
+ cur = nil
+ end
+
+ # Create the arrow and outline.
+ c.delete('all')
+ TkcLine.new(c, v.x1, v.y, v.x2, v.y,
+ { 'width'=>10 * v.width,
+ 'arrowshape'=>[10*v.a, 10*v.b, 10*v.c],
+ 'arrow'=>'last'
+ }.update(v.bigLineStyle) )
+ xtip = v.x2 - 10*v.b
+ deltaY = 10*v.c + 5*v.width
+ TkcLine.new(c, v.x2, v.y, xtip, v.y + deltaY,
+ v.x2 - 10*v.a, v.y, xtip, v.y - deltaY, v.x2, v.y,
+ 'width'=>2, 'capstyle'=>'round', 'joinstyle'=>'round')
+
+ # Create the boxes for reshaping the line and arrowhead.
+ TkcRectangle.new(c, v.x2-10*v.a-5, v.y-5, v.x2-10*v.a+5, v.y+5,
+ {'tags'=>['box1', $arrowTag_box]}.update(v.boxStyle) )
+ TkcRectangle.new(c, xtip-5, v.y-deltaY-5, xtip+5, v.y-deltaY+5,
+ {'tags'=>['box2', $arrowTag_box]}.update(v.boxStyle) )
+ TkcRectangle.new(c, v.x1-5, v.y-5*v.width-5, v.x1+5, v.y-5*v.width+5,
+ {'tags'=>['box3', $arrowTag_box]}.update(v.boxStyle) )
+ c.itemconfigure cur, v.activeStyle if cur
+
+ # Create three arrows in actual size with the same parameters
+ TkcLine.new(c, v.x2+50, 0, v.x2+50, 1000, 'width'=>2)
+ tmp = v.x2+100
+ TkcLine.new(c, tmp, v.y-125, tmp, v.y-75, 'width'=>v.width,
+ 'arrow'=>'both', 'arrowshape'=>[v.a, v.b, v.c])
+ TkcLine.new(c, tmp-25, v.y, tmp+25, v.y, 'width'=>v.width,
+ 'arrow'=>'both', 'arrowshape'=>[v.a, v.b, v.c])
+ TkcLine.new(c, tmp-25, v.y+75, tmp+25, v.y+125, 'width'=>v.width,
+ 'arrow'=>'both', 'arrowshape'=>[v.a, v.b, v.c])
+
+ # Create a bunch of other arrows and text items showing the
+ # current dimensions.
+ tmp = v.x2+10
+ TkcLine.new(c, tmp, v.y-5*v.width, tmp, v.y-deltaY,
+ 'arrow'=>'both', 'arrowshape'=>v.smallTips)
+ TkcText.new(c, v.x2+15, v.y-deltaY+5*v.c, 'text'=>v.c, 'anchor'=>'w')
+ tmp = v.x1-10
+ TkcLine.new(c, tmp, v.y-5*v.width, tmp, v.y+5*v.width,
+ 'arrow'=>'both', 'arrowshape'=>v.smallTips)
+ TkcText.new(c, v.x1-15, v.y, 'text'=>v.width, 'anchor'=>'e')
+ tmp = v.y+5*v.width+10*v.c+10
+ TkcLine.new(c, v.x2-10*v.a, tmp, v.x2, tmp,
+ 'arrow'=>'both', 'arrowshape'=>v.smallTips)
+ TkcText.new(c, v.x2-5*v.a, tmp+5, 'text'=>v.a, 'anchor'=>'n')
+ tmp = tmp+25
+ TkcLine.new(c, v.x2-10*v.b, tmp, v.x2, tmp,
+ 'arrow'=>'both', 'arrowshape'=>v.smallTips)
+ TkcText.new(c, v.x2-5*v.b, tmp+5, 'text'=>v.b, 'anchor'=>'n')
+
+ if $tk_version =~ /^4.*/
+ TkcText.new(c, v.x1, 310, 'text'=>"'width'=>#{v.width}", 'anchor'=>'w',
+ 'font'=>'-*-Helvetica-Medium-R-Normal--*-180-*-*-*-*-*-*')
+ TkcText.new(c, v.x1, 330,
+ 'text'=>"'arrowshape'=>[#{v.a}, #{v.b}, #{v.c}]",'anchor'=>'w',
+ 'font'=>'-*-Helvetica-Medium-R-Normal--*-180-*-*-*-*-*-*')
+ else
+ TkcText.new(c, v.x1, 310, 'text'=>"'width'=>#{v.width}", 'anchor'=>'w',
+ 'font'=>'Helvetica 18')
+ TkcText.new(c, v.x1, 330,
+ 'text'=>"'arrowshape'=>[#{v.a}, #{v.b}, #{v.c}]",
+ 'anchor'=>'w', 'font'=>'Helvetica 18')
+ end
+
+ v.count += 1
+end
+
+# toplevel widget
+if defined?($arrow_demo) && $arrow_demo
+ $arrow_demo.destroy
+ $arrow_demo = nil
+end
+
+# demo toplevel widget
+$arrow_demo = TkToplevel.new {|w|
+ title("Arrowhead Editor Demonstration")
+ iconname("arrow")
+ positionWindow(w)
+}
+
+base_frame = TkFrame.new($arrow_demo).pack(:fill=>:both, :expand=>true)
+
+# label
+TkLabel.new(base_frame, 'font'=>$font, 'wraplength'=>'5i', 'justify'=>'left',
+ 'text'=>"This widget allows you to experiment with different widths and arrowhead shapes for lines in canvases. To change the line width or the shape of the arrowhead, drag any of the three boxes attached to the oversized arrow. The arrows on the right give examples at normal scale. The text at the bottom shows the configuration options as you'd enter them for a canvas line item."){
+ pack('side'=>'top')
+}
+
+# frame
+$arrow_buttons = TkFrame.new(base_frame) {|frame|
+ TkButton.new(frame) {
+ text 'Dismiss'
+ command proc{
+ tmppath = $arrow_demo
+ $arrow_demo = nil
+ tmppath.destroy
+ }
+ }.pack('side'=>'left', 'expand'=>'yes')
+
+ TkButton.new(frame) {
+ text 'Show Code'
+ command proc{showCode 'arrow'}
+ }.pack('side'=>'left', 'expand'=>'yes')
+}
+$arrow_buttons.pack('side'=>'bottom', 'fill'=>'x', 'pady'=>'2m')
+
+# canvas
+$arrow_canvas = TkCanvas.new(base_frame, 'width'=>500, 'height'=>350,
+ 'relief'=>'sunken', 'borderwidth'=>2)
+$arrow_canvas.pack('expand'=>'yes', 'fill'=>'both')
+
+#
+unless Struct.const_defined?("ArrowInfo")
+ $demo_arrowInfo = Struct.new("ArrowInfo", :a, :b, :c, :width, :motionProc,
+ :x1, :x2, :y, :smallTips, :count,
+ :bigLineStyle, :boxStyle, :activeStyle).new
+end
+$demo_arrowInfo.a = 8
+$demo_arrowInfo.b = 10
+$demo_arrowInfo.c = 3
+$demo_arrowInfo.width = 2
+$demo_arrowInfo.motionProc = proc{}
+$demo_arrowInfo.x1 = 40
+$demo_arrowInfo.x2 = 350
+$demo_arrowInfo.y = 150
+$demo_arrowInfo.smallTips = [5, 5, 2]
+$demo_arrowInfo.count = 0
+if TkWinfo.depth($arrow_canvas) > 1
+ $demo_arrowInfo.bigLineStyle = {'fill'=>'SkyBlue1'}
+ $demo_arrowInfo.boxStyle = {'fill'=>'', 'outline'=>'black', 'width'=>1}
+ $demo_arrowInfo.activeStyle = {'fill'=>'red', 'outline'=>'black', 'width'=>1}
+else
+ $demo_arrowInfo.bigLineStyle = {'fill'=>'black',
+ 'stipple'=>'@'+[$demo_dir,'..','images','grey.25'].join(File::Separator)}
+ $demo_arrowInfo.boxStyle = {'fill'=>'', 'outline'=>'black', 'width'=>1}
+ $demo_arrowInfo.activeStyle = {'fill'=>'black','outline'=>'black','width'=>1}
+end
+$arrowTag_box = TkcTag.new($arrow_canvas)
+arrowSetup $arrow_canvas
+$arrowTag_box.bind('Enter', proc{$arrow_canvas.itemconfigure('current', $demo_arrowInfo.activeStyle)})
+$arrowTag_box.bind('Leave', proc{$arrow_canvas.itemconfigure('current', $demo_arrowInfo.boxStyle)})
+$arrowTag_box.bind('B1-Enter', proc{})
+$arrowTag_box.bind('B1-Leave', proc{})
+$arrow_canvas.itembind('box1', '1',
+ proc{$demo_arrowInfo.motionProc \
+ = proc{|x,y| arrowMove1 $arrow_canvas, x, y}})
+$arrow_canvas.itembind('box2', '1',
+ proc{$demo_arrowInfo.motionProc \
+ = proc{|x,y| arrowMove2 $arrow_canvas, x, y}})
+$arrow_canvas.itembind('box3', '1',
+ proc{$demo_arrowInfo.motionProc \
+ = proc{|x,y| arrowMove3 $arrow_canvas, x, y}})
+$arrowTag_box.bind('B1-Motion',
+ proc{|x,y| $demo_arrowInfo.motionProc.call(x,y)}, "%x %y")
+$arrow_canvas.bind('Any-ButtonRelease-1', proc{arrowSetup $arrow_canvas})
+
+# arrowMove1 --
+# This method is called for each mouse motion event on box1 (the
+# one at the vertex of the arrow). It updates the controlling parameters
+# for the line and arrowhead.
+#
+# Arguments:
+# c - The name of the canvas window.
+# x, y - The coordinates of the mouse.
+
+def arrowMove1(c,x,y)
+ v = $demo_arrowInfo
+ newA = (v.x2+5-c.canvasx(x).round)/10
+ newA = 0 if newA < 0
+ newA = 25 if newA > 25
+ if newA != v.a
+ c.move('box1', 10*(v.a-newA), 0)
+ v.a = newA
+ end
+end
+
+# arrowMove2 --
+# This method is called for each mouse motion event on box2 (the
+# one at the trailing tip of the arrowhead). It updates the controlling
+# parameters for the line and arrowhead.
+#
+# Arguments:
+# c - The name of the canvas window.
+# x, y - The coordinates of the mouse.
+
+def arrowMove2(c,x,y)
+ v = $demo_arrowInfo
+ newB = (v.x2+5-c.canvasx(x).round)/10
+ newB = 0 if newB < 0
+ newB = 25 if newB > 25
+ newC = (v.y+5-c.canvasy(y).round-5*v.width)/10
+ newC = 0 if newC < 0
+ newC = 20 if newC > 20
+ if newB != v.b || newC != v.c
+ c.move('box2', 10*(v.b-newB), 10*(v.c-newC))
+ v.b = newB
+ v.c = newC
+ end
+end
+
+# arrowMove3 --
+# This method is called for each mouse motion event on box3 (the
+# one that controls the thickness of the line). It updates the
+# controlling parameters for the line and arrowhead.
+#
+# Arguments:
+# c - The name of the canvas window.
+# x, y - The coordinates of the mouse.
+
+def arrowMove3(c,x,y)
+ v = $demo_arrowInfo
+ newWidth = (v.y+2-c.canvasy(y).round)/5
+ newWidth = 0 if newWidth < 0
+ newWidth = 20 if newWidth > 20
+ if newWidth != v.width
+ c.move('box3', 0, 5*(v.width-newWidth))
+ v.width = newWidth
+ end
+end
+
diff --git a/jni/ruby/ext/tk/sample/demos-en/bind.rb b/jni/ruby/ext/tk/sample/demos-en/bind.rb
new file mode 100644
index 0000000..c291e47
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/demos-en/bind.rb
@@ -0,0 +1,127 @@
+# bind.rb
+#
+# This demonstration script creates a text widget with bindings set
+# up for hypertext-like effects.
+#
+# text (tag bindings) widget demo (called by 'widget')
+#
+
+# toplevel widget
+if defined?($bind_demo) && $bind_demo
+ $bind_demo.destroy
+ $bind_demo = nil
+end
+
+# demo toplevel widget
+$bind_demo = TkToplevel.new {|w|
+ title("Text Demonstration - Tag Bindings")
+ iconname("bind")
+ positionWindow(w)
+}
+
+base_frame = TkFrame.new($bind_demo).pack(:fill=>:both, :expand=>true)
+
+# frame
+TkFrame.new(base_frame) {|frame|
+ TkButton.new(frame) {
+ text 'Dismiss'
+ command proc{
+ tmppath = $bind_demo
+ $bind_demo = nil
+ tmppath.destroy
+ }
+ }.pack('side'=>'left', 'expand'=>'yes')
+
+ TkButton.new(frame) {
+ text 'Show Code'
+ command proc{showCode 'bind'}
+ }.pack('side'=>'left', 'expand'=>'yes')
+}.pack('side'=>'bottom', 'fill'=>'x', 'pady'=>'2m')
+
+# bind
+def tag_binding_for_bind_demo(tag, enter_style, leave_style)
+ tag.bind('Any-Enter', proc{tag.configure enter_style})
+ tag.bind('Any-Leave', proc{tag.configure leave_style})
+end
+
+# text
+txt = TkText.new(base_frame){|t|
+ #
+ setgrid 'true'
+ #width 60
+ #height 24
+ font $font
+ wrap 'word'
+ TkScrollbar.new(base_frame) {|s|
+ pack('side'=>'right', 'fill'=>'y')
+ command proc{|*args| t.yview(*args)}
+ t.yscrollcommand proc{|first,last| s.set first,last}
+ }
+ pack('expand'=>'yes', 'fill'=>'both')
+
+ #
+ if TkWinfo.depth($root).to_i > 1
+ tagstyle_bold = {'background'=>'#43ce80', 'relief'=>'raised',
+ 'borderwidth'=>1}
+ tagstyle_normal = {'background'=>'', 'relief'=>'flat'}
+ else
+ tagstyle_bold = {'foreground'=>'white', 'background'=>'black'}
+ tagstyle_normal = {'foreground'=>'', 'background'=>''}
+ end
+
+ # insert text
+ insert 'insert', "The same tag mechanism that controls display styles in text widgets can also be used to associate Tcl commands with regions of text, so that mouse or keyboard actions on the text cause particular Tcl commands to be invoked. For example, in the text below the descriptions of the canvas demonstrations have been tagged. When you move the mouse over a demo description the description lights up, and when you press button 1 over a description then that particular demonstration is invoked.
+
+"
+ insert('end', '1. Samples of all the different types of items that can be created in canvas widgets.', (d1 = TkTextTag.new(t)) )
+ insert('end', "\n\n")
+ insert('end', '2. A simple two-dimensional plot that allows you to adjust the positions of the data points.', (d2 = TkTextTag.new(t)) )
+ insert('end', "\n\n")
+ insert('end', '3. Anchoring and justification modes for text items.',
+ (d3 = TkTextTag.new(t)) )
+ insert('end', "\n\n")
+ insert('end', '4. An editor for arrow-head shapes for line items.',
+ (d4 = TkTextTag.new(t)) )
+ insert('end', "\n\n")
+ insert('end', '5. A ruler with facilities for editing tab stops.',
+ (d5 = TkTextTag.new(t)) )
+ insert('end', "\n\n")
+ insert('end',
+ '6. A grid that demonstrates how canvases can be scrolled.',
+ (d6 = TkTextTag.new(t)) )
+
+ # binding
+ [d1, d2, d3, d4, d5, d6].each{|tag|
+ tag_binding_for_bind_demo(tag, tagstyle_bold, tagstyle_normal)
+ }
+ d1.bind('1',
+ proc{
+ eval_samplecode(`cat #{[$demo_dir,'items.rb'].join(File::Separator)}`, 'items.rb')
+ })
+ d2.bind('1',
+ proc{
+ eval_samplecode(`cat #{[$demo_dir,'plot.rb'].join(File::Separator)}`, 'plot.rb')
+ })
+ d3.bind('1',
+ proc{
+ eval_samplecode(`cat #{[$demo_dir,'ctext.rb'].join(File::Separator)}`, 'ctext.rb')
+ })
+ d4.bind('1',
+ proc{
+ eval_samplecode(`cat #{[$demo_dir,'arrow.rb'].join(File::Separator)}`, 'arrow.rb')
+ })
+ d5.bind('1',
+ proc{
+ eval_samplecode(`cat #{[$demo_dir,'ruler.rb'].join(File::Separator)}`, 'ruler.rb')
+ })
+ d6.bind('1',
+ proc{
+ eval_samplecode(`cat #{[$demo_dir,'cscroll.rb'].join(File::Separator)}`, 'cscroll.rb')
+ })
+
+ TkTextMarkInsert.new(t, '0.0')
+ configure('state','disabled')
+}
+
+txt.width 60
+txt.height 24
diff --git a/jni/ruby/ext/tk/sample/demos-en/bitmap.rb b/jni/ruby/ext/tk/sample/demos-en/bitmap.rb
new file mode 100644
index 0000000..858d067
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/demos-en/bitmap.rb
@@ -0,0 +1,75 @@
+# bitmap.rb
+#
+# This demonstration script creates a toplevel window that displays
+# all of Tk's built-in bitmaps.#
+# bitmap widget demo (called by 'widget')
+#
+
+# bitmapRow --
+# Create a row of bitmap items in a window.
+#
+# Arguments:
+# w - The parent window that is to contain the row.
+# args - The names of one or more bitmaps, which will be displayed
+# in a new row across the bottom of w along with their
+# names.
+
+def bitmapRow(w,*args)
+ TkFrame.new(w){|row|
+ pack('side'=>'top', 'fill'=>'both')
+ for bitmap in args
+ TkFrame.new(row){|base|
+ pack('side'=>'left', 'fill'=>'both', 'pady'=>'.25c', 'padx'=>'.25c')
+ TkLabel.new(base, 'text'=>bitmap, 'width'=>9).pack('side'=>'bottom')
+ Tk::Label.new(base, 'bitmap'=>bitmap).pack('side'=>'bottom')
+ }
+ end
+ }
+end
+
+# toplevel widget
+if defined?($bitmap_demo) && $bitmap_demo
+ $bitmap_demo.destroy
+ $bitmap_demo = nil
+end
+
+# demo toplevel widget
+$bitmap_demo = TkToplevel.new {|w|
+ title("Bitmap Demonstration")
+ iconname("bitmap")
+ positionWindow(w)
+}
+
+base_frame = TkFrame.new($bitmap_demo).pack(:fill=>:both, :expand=>true)
+
+# label
+TkLabel.new(base_frame,'font'=>$font,'wraplength'=>'4i','justify'=>'left',
+ 'text'=>"This window displays all of Tk's built-in bitmaps, along with the names you can use for them in Tcl scripts."){
+ pack('side'=>'top')
+}
+
+# frame
+$bitmap_buttons = TkFrame.new(base_frame) {|frame|
+ TkButton.new(frame) {
+ text 'Dismiss'
+ command proc{
+ tmppath = $bitmap_demo
+ $bitmap_demo = nil
+ tmppath.destroy
+ }
+ }.pack('side'=>'left', 'expand'=>'yes')
+
+ TkButton.new(frame) {
+ text 'Show Code'
+ command proc{showCode 'bitmap'}
+ }.pack('side'=>'left', 'expand'=>'yes')
+}
+$bitmap_buttons.pack('side'=>'bottom', 'fill'=>'x', 'pady'=>'2m')
+
+# frame
+TkFrame.new(base_frame){|f|
+ bitmapRow(f,'error','gray25','gray50','hourglass')
+ bitmapRow(f,'info','question','questhead','warning')
+ pack('side'=>'top', 'expand'=>'yes', 'fill'=>'both')
+}
+
diff --git a/jni/ruby/ext/tk/sample/demos-en/browse1 b/jni/ruby/ext/tk/sample/demos-en/browse1
new file mode 100644
index 0000000..568892e
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/demos-en/browse1
@@ -0,0 +1,63 @@
+#!/usr/bin/env ruby
+
+# browse --
+# This script generates a directory browser, which lists the working
+# directory and allow you to open files or subdirectories by
+# double-clicking.
+
+require 'tk'
+
+# Create a scrollbar on the right side of the main window and a listbox
+# on the left side.
+
+listbox = TkListbox.new(nil, 'relief'=>'sunken',
+ 'width'=>20, 'height'=>20, 'setgrid'=>'yes') {|l|
+ TkScrollbar.new(nil, 'command'=>proc{|*args| l.yview *args}) {|s|
+ pack('side'=>'right', 'fill'=>'y')
+ l.yscrollcommand(proc{|first,last| s.set(first,last)})
+ }
+
+ pack('side'=>'left', 'fill'=>'both', 'expand'=>'yes')
+}
+
+root = TkRoot.new
+root.minsize(1,1)
+
+# The procedure below is invoked to open a browser on a given file; if the
+# file is a directory then another instance of this program is invoked; if
+# the file is a regular file then the Mx editor is invoked to display
+# the file.
+
+def browse (dir, file)
+ file = dir + File::Separator + file if dir != '.'
+ type = File.ftype(file)
+ if type == 'directory'
+ system($0 + ' ' + file + ' &')
+ else
+ if type == 'file'
+ if ENV['EDITOR']
+ system(ENV['EDITOR'] + ' ' + file + ' &')
+ else
+ system('xedit ' + file + ' &')
+ end
+ else
+ STDOUT.print "\"#{file}\" isn't a directory or regular file"
+ end
+ end
+end
+
+# Fill the listbox with a list of all the files in the directory (run
+# the "ls" command to get that information).
+
+dir = ARGV[0] ? ARGV[0] : '.'
+open("|ls -a #{dir}", 'r'){|fid| fid.readlines}.each{|fname|
+ listbox.insert('end', fname.chomp)
+}
+
+# Set up bindings for the browser.
+
+Tk.bind_all('Control-c', proc{root.destroy})
+listbox.bind('Double-Button-1',
+ proc{TkSelection.get.each{|f| browse dir, f}})
+
+Tk.mainloop
diff --git a/jni/ruby/ext/tk/sample/demos-en/browse2 b/jni/ruby/ext/tk/sample/demos-en/browse2
new file mode 100644
index 0000000..1a511c8
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/demos-en/browse2
@@ -0,0 +1,82 @@
+#!/usr/bin/env ruby
+
+# browse --
+# This script generates a directory browser, which lists the working
+# directory and allow you to open files or subdirectories by
+# double-clicking.
+
+require 'tk'
+
+class Browse
+ BROWSE_WIN_COUNTER = TkVariable.new(0)
+
+ def initialize(dir)
+ BROWSE_WIN_COUNTER.value = BROWSE_WIN_COUNTER.to_i + 1
+
+ # create base frame
+ base = TkToplevel.new {
+ minsize(1,1)
+ title('Browse : ' + dir)
+ }
+
+ # Create a scrollbar on the right side of the main window and a listbox
+ # on the left side.
+ list = TkListbox.new(base, 'relief'=>'sunken',
+ 'width'=>20, 'height'=>20, 'setgrid'=>'yes') {|l|
+ TkScrollbar.new(base, 'command'=>proc{|*args| l.yview *args}) {|s|
+ pack('side'=>'right', 'fill'=>'y')
+ l.yscrollcommand(proc{|first,last| s.set(first,last)})
+ }
+
+ pack('side'=>'left', 'fill'=>'both', 'expand'=>'yes')
+
+ # Fill the listbox with a list of all the files in the directory (run
+ # the "ls" command to get that information).
+ open("|ls -a #{dir}", 'r'){|fid| fid.readlines}.each{|fname|
+ l.insert('end', fname.chomp)
+ }
+
+ }
+
+ # Set up bindings for the browser.
+ base.bind('Destroy', proc{
+ Browse::BROWSE_WIN_COUNTER.value = \
+ Browse::BROWSE_WIN_COUNTER.to_i - 1
+ })
+ base.bind('Control-c', proc{base.destroy})
+ list.bind('Double-Button-1',
+ proc{TkSelection.get.each{|f| self.browse dir, f}})
+ end
+
+ # The method below is invoked to open a browser on a given file; if the
+ # file is a directory then another instance of this program is invoked; if
+ # the file is a regular file then the Mx editor is invoked to display
+ # the file.
+ def browse (dir, file)
+ file = dir + File::Separator + file if dir != '.'
+ type = File.ftype(file)
+ if type == 'directory'
+ Browse.new(file)
+ else
+ if type == 'file'
+ if ENV['EDITOR']
+ system(ENV['EDITOR'] + ' ' + file + ' &')
+ else
+ system('xedit ' + file + ' &')
+ end
+ else
+ STDOUT.print "\"#{file}\" isn't a directory or regular file"
+ end
+ end
+ end
+
+end
+
+Browse.new(ARGV[0] ? ARGV[0] : '.')
+
+TkRoot.new {
+ withdraw
+ Browse::BROWSE_WIN_COUNTER.trace('w', proc{exit if Browse::BROWSE_WIN_COUNTER.to_i == 0})
+}
+
+Tk.mainloop
diff --git a/jni/ruby/ext/tk/sample/demos-en/button.rb b/jni/ruby/ext/tk/sample/demos-en/button.rb
new file mode 100644
index 0000000..f63a2f3
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/demos-en/button.rb
@@ -0,0 +1,84 @@
+# button.rb
+#
+# This demonstration script creates a toplevel window containing
+# several button widgets.
+#
+# button widget demo (called by 'widget')
+#
+
+# toplevel widget
+if defined?($button_demo) && $button_demo
+ $button_demo.destroy
+ $button_demo = nil
+end
+
+# demo toplevel widget
+$button_demo = TkToplevel.new {|w|
+ title("Button Demonstration")
+ iconname("button")
+ positionWindow(w)
+}
+
+# label
+msg = TkLabel.new($button_demo) {
+ font $kanji_font
+ wraplength '4i'
+ justify 'left'
+ text "If you click on any of the four buttons below, the background of the button area will change to the color indicated in the button. You can press Tab to move among the buttons, then press Space to invoke the current button."
+}
+msg.pack('side'=>'top')
+
+# frame
+$button_buttons = Tk::Frame.new($button_demo) {|frame|
+ TkButton.new(frame) {
+ text 'Dismiss'
+ command proc{
+ tmppath = $button_demo
+ $button_demo = nil
+ tmppath.destroy
+ }
+ }.pack('side'=>'left', 'expand'=>'yes')
+
+ TkButton.new(frame) {
+ text 'See Code'
+ command proc{showCode 'button'}
+ }.pack('side'=>'left', 'expand'=>'yes')
+
+}.pack('side'=>'bottom', 'fill'=>'x', 'pady'=>'2m')
+
+# button
+TkButton.new($button_demo){
+ text "Peach Puff"
+ width 10
+ command proc{
+ $button_demo.configure('bg','PeachPuff1')
+ $button_buttons.configure('bg','PeachPuff1')
+ }
+}.pack('side'=>'top', 'expand'=>'yes', 'pady'=>2)
+
+TkButton.new($button_demo){
+ text "Light Blue"
+ width 10
+ command proc{
+ $button_demo.configure('bg','LightBlue1')
+ $button_buttons.configure('bg','LightBlue1')
+ }
+}.pack('side'=>'top', 'expand'=>'yes', 'pady'=>2)
+
+TkButton.new($button_demo){
+ text "Sea Green"
+ width 10
+ command proc{
+ $button_demo.configure('bg','SeaGreen2')
+ $button_buttons.configure('bg','SeaGreen2')
+ }
+}.pack('side'=>'top', 'expand'=>'yes', 'pady'=>2)
+
+TkButton.new($button_demo){
+ text "Yellow"
+ width 10
+ command proc{
+ $button_demo.configure('bg','Yellow1')
+ $button_buttons.configure('bg','Yellow1')
+ }
+}.pack('side'=>'top', 'expand'=>'yes', 'pady'=>2)
diff --git a/jni/ruby/ext/tk/sample/demos-en/check.rb b/jni/ruby/ext/tk/sample/demos-en/check.rb
new file mode 100644
index 0000000..bf0b734
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/demos-en/check.rb
@@ -0,0 +1,72 @@
+# check.rb
+#
+# This demonstration script creates a toplevel window containing
+# several checkbuttons.
+#
+# checkbutton widget demo (called by 'widget')
+#
+
+# toplevel widget
+if defined?($check_demo) && $check_demo
+ $check_demo.destroy
+ $check_demo = nil
+end
+
+# demo toplevel widget
+$check_demo = TkToplevel.new {|w|
+ title("Checkbutton Demonstration")
+ iconname("check")
+ positionWindow(w)
+}
+
+base_frame = TkFrame.new($check_demo).pack(:fill=>:both, :expand=>true)
+
+# label
+msg = TkLabel.new(base_frame) {
+ font $font
+ wraplength '4i'
+ justify 'left'
+ text "Three checkbuttons are displayed below. If you click on a button, it will toggle the button's selection state and set a Tcl variable to a value indicating the state of the checkbutton. Click the \"See Variables\" button to see the current values of the variables."
+}
+msg.pack('side'=>'top')
+
+#
+wipers = TkVariable.new(0)
+brakes = TkVariable.new(0)
+sober = TkVariable.new(0)
+
+# frame
+TkFrame.new(base_frame) {|frame|
+ TkButton.new(frame) {
+ text 'Dismiss'
+ command proc{
+ tmppath = $check_demo
+ $check_demo = nil
+ $showVarsWin[tmppath.path] = nil
+ tmppath.destroy
+ }
+ }.pack('side'=>'left', 'expand'=>'yes')
+
+ TkButton.new(frame) {
+ text 'Show Code'
+ command proc{showCode 'check'}
+ }.pack('side'=>'left', 'expand'=>'yes')
+
+
+ TkButton.new(frame) {
+ text 'See Variables'
+ command proc{
+ showVars(base_frame,
+ ['wipers', wipers], ['brakes', brakes], ['sober', sober])
+ }
+ }.pack('side'=>'left', 'expand'=>'yes')
+
+}.pack('side'=>'bottom', 'fill'=>'x', 'pady'=>'2m')
+
+
+# checkbutton
+[ TkCheckButton.new(base_frame, 'text'=>'Wipers OK', 'variable'=>wipers),
+ TkCheckButton.new(base_frame, 'text'=>'Brakes OK', 'variable'=>brakes),
+ TkCheckButton.new(base_frame, 'text'=>'Driver Sober', 'variable'=>sober)
+].each{|w| w.relief('flat'); w.pack('side'=>'top', 'pady'=>2, 'anchor'=>'w')}
+
diff --git a/jni/ruby/ext/tk/sample/demos-en/check2.rb b/jni/ruby/ext/tk/sample/demos-en/check2.rb
new file mode 100644
index 0000000..4f7b1f0
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/demos-en/check2.rb
@@ -0,0 +1,109 @@
+#
+# checkbutton widget demo2 (called by 'widget')
+#
+
+# delete old toplevel widget
+if defined?($check2_demo) && $check2_demo
+ $check2_demo.destroy
+ $check2_demo = nil
+end
+
+# create demo toplevel widget
+$check2_demo = TkToplevel.new {|w|
+ title("Checkbutton Demonstration 2")
+ iconname("check2")
+ positionWindow(w)
+}
+
+base_frame = TkFrame.new($check2_demo).pack(:fill=>:both, :expand=>true)
+
+# label
+msg = TkLabel.new(base_frame) {
+ font $font
+ wraplength '4i'
+ justify 'left'
+ text "Four checkbuttons are displayed below. If you click on a button, it will toggle the button's selection state and set a Tcl variable to a value indicating the state of the checkbutton. The first button also follows the state of the other three. If only some of the three are checked, the first button will display the tri-state mode. Click the \"See Variables\" button to see the current values of the variables."
+}
+msg.pack('side'=>'top')
+
+# variable
+safety = TkVariable.new(0)
+wipers = TkVariable.new(0)
+brakes = TkVariable.new(0)
+sober = TkVariable.new(0)
+
+# frame
+TkFrame.new(base_frame) {|frame|
+ TkGrid(TkFrame.new(frame, :height=>2, :relief=>:sunken, :bd=>2),
+ :columnspan=>4, :row=>0, :sticky=>'ew', :pady=>2)
+ TkGrid('x',
+ TkButton.new(frame, :text=>'See Variables',
+ :image=>$image['view'], :compound=>:left,
+ :command=>proc{
+ showVars($check2_demo,
+ ['safety', safety], ['wipers', wipers],
+ ['brakes', brakes], ['sober', sober])
+ }),
+ TkButton.new(frame, :text=>'See Code',
+ :image=>$image['view'], :compound=>:left,
+ :command=>proc{showCode 'check2'}),
+ TkButton.new(frame, :text=>'Dismiss',
+ :image=>$image['delete'], :compound=>:left,
+ :command=>proc{
+ tmppath = $check2_demo
+ $check2_demo = nil
+ $showVarsWin[tmppath.path] = nil
+ tmppath.destroy
+ }),
+ :padx=>4, :pady=>4)
+ frame.grid_columnconfigure(0, :weight=>1)
+}.pack('side'=>'bottom', 'fill'=>'x')
+
+
+# checkbutton
+TkCheckButton.new(base_frame, :text=>'Safety Check', :variable=>safety,
+ :relief=>:flat, :onvalue=>'all', :offvalue=>'none',
+ :tristatevalue=>'partial'){
+ pack('side'=>'top', 'pady'=>2, 'anchor'=>'w')
+}
+
+[ TkCheckButton.new(base_frame, 'text'=>'Wipers OK', 'variable'=>wipers),
+ TkCheckButton.new(base_frame, 'text'=>'Brakes OK', 'variable'=>brakes),
+ TkCheckButton.new(base_frame, 'text'=>'Driver Sober', 'variable'=>sober)
+].each{|w|
+ w.relief('flat')
+ w.pack('side'=>'top', 'padx'=>15, 'pady'=>2, 'anchor'=>'w')
+}
+
+# tristate check
+in_check = false
+tristate_check = proc{|n1,n2,op|
+ unless in_check
+ in_check = true
+ begin
+ if n1 == safety
+ if safety == 'none'
+ wipers.value = 0
+ brakes.value = 0
+ sober.value = 0
+ elsif safety == 'all'
+ wipers.value = 1
+ brakes.value = 1
+ sober.value = 1
+ end
+ else
+ if wipers == 1 && brakes == 1 && sober == 1
+ safety.value = 'all'
+ elsif wipers == 1 || brakes == 1 || sober == 1
+ safety.value = 'partial'
+ else
+ safety.value = 'none'
+ end
+ end
+ ensure
+ in_check = false
+ end
+ end
+}
+
+[wipers, brakes, sober, safety].each{|v| v.trace('w', tristate_check)}
diff --git a/jni/ruby/ext/tk/sample/demos-en/clrpick.rb b/jni/ruby/ext/tk/sample/demos-en/clrpick.rb
new file mode 100644
index 0000000..6da28cb
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/demos-en/clrpick.rb
@@ -0,0 +1,87 @@
+# clrpick.rb
+#
+# This demonstration script prompts the user to select a color.
+#
+# widget demo prompts the user to select a color (called by 'widget')
+#
+# Note: don't support ttk_wrapper. work with standard widgets only.
+#
+
+# toplevel widget
+if defined?($clrpick_demo) && $clrpick_demo
+ $clrpick_demo.destroy
+ $clrpick_demo = nil
+end
+
+# demo toplevel widget
+$clrpick_demo = TkToplevel.new {|w|
+ title("Color Selection Dialogs")
+ iconname("colors")
+ positionWindow(w)
+}
+
+base_frame = TkFrame.new($clrpick_demo).pack(:fill=>:both, :expand=>true)
+
+# label
+#TkLabel.new($clrpick_demo,'font'=>$font,'wraplength'=>'4i','justify'=>'left',
+Tk::Label.new($clrpick_demo,'font'=>$font,'wraplength'=>'4i','justify'=>'left',
+ 'text'=>"Press the buttons below to choose the foreground and background colors for the widgets in this window.").pack('side'=>'top')
+
+# frame
+#TkFrame.new($clrpick_demo) {|frame|
+Tk::Frame.new($clrpick_demo) {|frame|
+ # TkButton.new(frame) {
+ Tk::Button.new(frame) {
+ text 'Dismiss'
+ command proc{
+ tmppath = $clrpick_demo
+ $clrpick_demo = nil
+ tmppath.destroy
+ }
+ }.pack('side'=>'left', 'expand'=>'yes')
+
+ # TkButton.new(frame) {
+ Tk::Button.new(frame) {
+ text 'Show Code'
+ command proc{showCode 'clrpick'}
+ }.pack('side'=>'left', 'expand'=>'yes')
+}.pack('side'=>'bottom', 'fill'=>'x', 'pady'=>'2m')
+
+# button
+# TkButton.new($clrpick_demo, 'text'=>'Set background color ...') {|b|
+Tk::Button.new($clrpick_demo, 'text'=>'Set background color ...') {|b|
+ command(proc{setColor $clrpick_demo, b, 'background',
+ ['background', 'highlightbackground']})
+ pack('side'=>'top', 'anchor'=>'c', 'pady'=>'2m')
+}
+
+# TkButton.new($clrpick_demo, 'text'=>'Set foreground color ...') {|b|
+Tk::Button.new($clrpick_demo, 'text'=>'Set foreground color ...') {|b|
+ command(proc{setColor $clrpick_demo, b, 'foreground', ['foreground']})
+ pack('side'=>'top', 'anchor'=>'c', 'pady'=>'2m')
+}
+
+def setColor(w,button,name,options)
+ w.grab
+ initialColor = button[name]
+ color = Tk.chooseColor('title'=>"Choose a #{name} color", 'parent'=>w,
+ 'initialcolor'=>initialColor)
+ if color != ""
+ setColor_helper(w,options,color)
+ end
+
+ w.grab('release')
+end
+
+def setColor_helper(w, options, color)
+ options.each{|opt|
+ begin
+ w[opt] = color
+ rescue
+ end
+ }
+ TkWinfo.children(w).each{|child|
+ setColor_helper child, options, color
+ }
+end
+
diff --git a/jni/ruby/ext/tk/sample/demos-en/colors.rb b/jni/ruby/ext/tk/sample/demos-en/colors.rb
new file mode 100644
index 0000000..b0ef959
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/demos-en/colors.rb
@@ -0,0 +1,158 @@
+# colors.rb
+#
+# This demonstration script creates a listbox widget that displays
+# many of the colors from the X color database. You can click on
+# a color to change the application's palette.
+#
+# listbox widget demo 'colors' (called by 'widget')
+#
+
+# toplevel widget
+if defined?($colors_demo) && $colors_demo
+ $colors_demo.destroy
+ $colors_demo = nil
+end
+
+# demo toplevel widget
+$colors_demo = TkToplevel.new {|w|
+ title("Listbox Demonstration (colors)")
+ iconname("colors")
+ positionWindow(w)
+}
+
+base_frame = TkFrame.new($colors_demo).pack(:fill=>:both, :expand=>true)
+
+# label
+msg = TkLabel.new(base_frame) {
+ font $font
+ wraplength '4i'
+ justify 'left'
+ text "A listbox containing several color names is displayed below, along with a scrollbar. You can scan the list either using the scrollbar or by dragging in the listbox window with button 2 pressed. If you double-click button 1 on a color, then the application's color palette will be set to match that color"
+}
+msg.pack('side'=>'top')
+
+# frame
+TkFrame.new(base_frame) {|frame|
+ TkButton.new(frame) {
+ text 'Dismiss'
+ command proc{
+ tmppath = $colors_demo
+ $colors_demo = nil
+ tmppath.destroy
+ }
+ }.pack('side'=>'left', 'expand'=>'yes')
+
+ TkButton.new(frame) {
+ text 'Show Code'
+ command proc{showCode 'colors'}
+ }.pack('side'=>'left', 'expand'=>'yes')
+
+}.pack('side'=>'bottom', 'fill'=>'x', 'pady'=>'2m')
+
+# frame
+colors_lbox = nil
+TkFrame.new(base_frame, 'borderwidth'=>10) {|w|
+ s = TkScrollbar.new(w)
+ colors_lbox = TkListbox.new(w) {
+ setgrid 1
+ width 10
+ height 12
+ yscrollcommand proc{|first,last| s.set first,last}
+ }
+ s.command(proc{|*args| colors_lbox.yview(*args)})
+ s.pack('side'=>'right', 'fill'=>'y')
+ colors_lbox.pack('side'=>'left', 'expand'=>1, 'fill'=>'both')
+}.pack('side'=>'top', 'expand'=>'yes', 'fill'=>'y')
+
+#colors_lbox.bind('Double-1', proc{TkPalette.setPalette TkSelection.get})
+colors_lbox.bind('Double-1', proc{
+ begin
+ TkPalette.setPalette TkSelection.get
+ rescue => e
+ p e
+ Tk.tk_call_without_enc('destroy', '.___tk_set_palette')
+ end
+ })
+
+ins_data = [
+ 'gray60','gray70','gray80','gray85','gray90','gray95',
+ 'snow1','snow2','snow3','snow4','seashell1','seashell2',
+ 'seashell3','seashell4','AntiqueWhite1','AntiqueWhite2',
+ 'AntiqueWhite3','AntiqueWhite4','bisque1','bisque2',
+ 'bisque3','bisque4','PeachPuff1','PeachPuff2',
+ 'PeachPuff3','PeachPuff4','NavajoWhite1','NavajoWhite2',
+ 'NavajoWhite3','NavajoWhite4','LemonChiffon1',
+ 'LemonChiffon2','LemonChiffon3','LemonChiffon4',
+ 'cornsilk1','cornsilk2','cornsilk3','cornsilk4',
+ 'ivory1','ivory2','ivory3','ivory4','honeydew1',
+ 'honeydew2','honeydew3','honeydew4','LavenderBlush1',
+ 'LavenderBlush2','LavenderBlush3','LavenderBlush4',
+ 'MistyRose1','MistyRose2','MistyRose3','MistyRose4',
+ 'azure1','azure2','azure3','azure4','SlateBlue1',
+ 'SlateBlue2','SlateBlue3','SlateBlue4','RoyalBlue1',
+ 'RoyalBlue2','RoyalBlue3','RoyalBlue4','blue1','blue2',
+ 'blue3','blue4','DodgerBlue1','DodgerBlue2',
+ 'DodgerBlue3','DodgerBlue4','SteelBlue1','SteelBlue2',
+ 'SteelBlue3','SteelBlue4','DeepSkyBlue1','DeepSkyBlue2',
+ 'DeepSkyBlue3','DeepSkyBlue4','SkyBlue1','SkyBlue2',
+ 'SkyBlue3','SkyBlue4','LightSkyBlue1','LightSkyBlue2',
+ 'LightSkyBlue3','LightSkyBlue4','SlateGray1',
+ 'SlateGray2','SlateGray3','SlateGray4',
+ 'LightSteelBlue1','LightSteelBlue2','LightSteelBlue3',
+ 'LightSteelBlue4','LightBlue1','LightBlue2',
+ 'LightBlue3','LightBlue4','LightCyan1','LightCyan2',
+ 'LightCyan3','LightCyan4','PaleTurquoise1',
+ 'PaleTurquoise2','PaleTurquoise3','PaleTurquoise4',
+ 'CadetBlue1','CadetBlue2','CadetBlue3','CadetBlue4',
+ 'turquoise1','turquoise2','turquoise3','turquoise4',
+ 'cyan1','cyan2','cyan3','cyan4','DarkSlateGray1',
+ 'DarkSlateGray2','DarkSlateGray3','DarkSlateGray4',
+ 'aquamarine1','aquamarine2','aquamarine3','aquamarine4',
+ 'DarkSeaGreen1','DarkSeaGreen2','DarkSeaGreen3',
+ 'DarkSeaGreen4','SeaGreen1','SeaGreen2','SeaGreen3',
+ 'SeaGreen4','PaleGreen1','PaleGreen2','PaleGreen3',
+ 'PaleGreen4','SpringGreen1','SpringGreen2',
+ 'SpringGreen3','SpringGreen4','green1','green2',
+ 'green3','green4','chartreuse1','chartreuse2',
+ 'chartreuse3','chartreuse4','OliveDrab1','OliveDrab2',
+ 'OliveDrab3','OliveDrab4','DarkOliveGreen1',
+ 'DarkOliveGreen2','DarkOliveGreen3','DarkOliveGreen4',
+ 'khaki1','khaki2','khaki3','khaki4','LightGoldenrod1',
+ 'LightGoldenrod2','LightGoldenrod3','LightGoldenrod4',
+ 'LightYellow1','LightYellow2','LightYellow3',
+ 'LightYellow4','yellow1','yellow2','yellow3','yellow4',
+ 'gold1','gold2','gold3','gold4','goldenrod1',
+ 'goldenrod2','goldenrod3','goldenrod4','DarkGoldenrod1',
+ 'DarkGoldenrod2','DarkGoldenrod3','DarkGoldenrod4',
+ 'RosyBrown1','RosyBrown2','RosyBrown3','RosyBrown4',
+ 'IndianRed1','IndianRed2','IndianRed3','IndianRed4',
+ 'sienna1','sienna2','sienna3','sienna4','burlywood1',
+ 'burlywood2','burlywood3','burlywood4','wheat1',
+ 'wheat2','wheat3','wheat4','tan1','tan2','tan3','tan4',
+ 'chocolate1','chocolate2','chocolate3','chocolate4',
+ 'firebrick1','firebrick2','firebrick3','firebrick4',
+ 'brown1','brown2','brown3','brown4','salmon1','salmon2',
+ 'salmon3','salmon4','LightSalmon1','LightSalmon2',
+ 'LightSalmon3','LightSalmon4','orange1','orange2',
+ 'orange3','orange4','DarkOrange1','DarkOrange2',
+ 'DarkOrange3','DarkOrange4','coral1','coral2','coral3',
+ 'coral4','tomato1','tomato2','tomato3','tomato4',
+ 'OrangeRed1','OrangeRed2','OrangeRed3','OrangeRed4',
+ 'red1','red2','red3','red4','DeepPink1','DeepPink2',
+ 'DeepPink3','DeepPink4','HotPink1','HotPink2',
+ 'HotPink3','HotPink4','pink1','pink2','pink3','pink4',
+ 'LightPink1','LightPink2','LightPink3','LightPink4',
+ 'PaleVioletRed1','PaleVioletRed2','PaleVioletRed3',
+ 'PaleVioletRed4','maroon1','maroon2','maroon3',
+ 'maroon4','VioletRed1','VioletRed2','VioletRed3',
+ 'VioletRed4','magenta1','magenta2','magenta3',
+ 'magenta4','orchid1','orchid2','orchid3','orchid4',
+ 'plum1','plum2','plum3','plum4','MediumOrchid1',
+ 'MediumOrchid2','MediumOrchid3','MediumOrchid4',
+ 'DarkOrchid1','DarkOrchid2','DarkOrchid3',
+ 'DarkOrchid4','purple1','purple2','purple3','purple4',
+ 'MediumPurple1','MediumPurple2','MediumPurple3',
+ 'MediumPurple4','thistle1','thistle2','thistle3', 'thistle4'
+]
+
+colors_lbox.insert(0, *ins_data)
diff --git a/jni/ruby/ext/tk/sample/demos-en/combo.rb b/jni/ruby/ext/tk/sample/demos-en/combo.rb
new file mode 100644
index 0000000..d776600
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/demos-en/combo.rb
@@ -0,0 +1,96 @@
+# combo.rb --
+#
+# This demonstration script creates several combobox widgets.
+#
+# based on "Id: combo.tcl,v 1.3 2007/12/13 15:27:07 dgp Exp"
+
+if defined?($combo_demo) && $combo_demo
+ $combo_demo.destroy
+ $combo_demo = nil
+end
+
+$combo_demo = TkToplevel.new {|w|
+ title("Combobox Demonstration")
+ iconname("combo")
+ positionWindow(w)
+}
+
+base_frame = TkFrame.new($combo_demo).pack(:fill=>:both, :expand=>true)
+
+Ttk::Label.new(base_frame, :font=>$font, :wraplength=>'5i', :justify=>:left,
+ :text=><<EOL).pack(:side=>:top, :fill=>:x)
+Three different combo-boxes are displayed below. \
+You can add characters to the first \
+one by pointing, clicking and typing, just as with an entry; pressing \
+Return will cause the current value to be added to the list that is \
+selectable from the drop-down list, and you can choose other values \
+by pressing the Down key, using the arrow keys to pick another one, \
+and pressing Return again. The second combo-box is fixed to a \
+particular value, and cannot be modified at all. The third one only \
+allows you to select values from its drop-down list of Australian \
+cities.
+EOL
+
+## variables
+firstValue = TkVariable.new
+secondValue = TkVariable.new
+ozCity = TkVariable.new
+
+## See Code / Dismiss buttons
+Ttk::Frame.new(base_frame) {|frame|
+ sep = Ttk::Separator.new(frame)
+ Tk.grid(sep, :columnspan=>4, :row=>0, :sticky=>'ew', :pady=>2)
+ TkGrid('x',
+ Ttk::Button.new(frame, :text=>'See Variables',
+ :image=>$image['view'], :compound=>:left,
+ :command=>proc{
+ showVars(base_frame,
+ ['firstVariable', firstValue],
+ ['secondVariable', secondValue],
+ ['ozCity', ozCity])
+ }),
+ Ttk::Button.new(frame, :text=>'See Code',
+ :image=>$image['view'], :compound=>:left,
+ :command=>proc{showCode 'combo'}),
+ Ttk::Button.new(frame, :text=>'Dismiss',
+ :image=>$image['delete'], :compound=>:left,
+ :command=>proc{
+ $combo_demo.destroy
+ $combo_demo = nil
+ }),
+ :padx=>4, :pady=>4)
+ grid_columnconfigure(0, :weight=>1)
+ pack(:side=>:bottom, :fill=>:x)
+}
+
+frame = Ttk::Frame.new(base_frame).pack(:fill=>:both, :expand=>true)
+
+australianCities = [
+ 'Canberra', 'Sydney', 'Melbourne', 'Perth', 'Adelaide', 'Brisbane',
+ 'Hobart', 'Darwin', 'Alice Springs'
+]
+
+
+secondValue.value = 'unchangable'
+ozCity.value = 'Sydney'
+
+Tk.pack(Ttk::Labelframe.new(frame, :text=>'Fully Editable'){|f|
+ Ttk::Combobox.new(f, :textvariable=>firstValue){|b|
+ b.bind('Return', '%W'){|w|
+ w.values <<= w.value unless w.values.include?(w.value)
+ }
+ }.pack(:pady=>5, :padx=>10)
+ },
+
+ Ttk::LabelFrame.new(frame, :text=>'Disabled'){|f|
+ Ttk::Combobox.new(f, :textvariable=>secondValue, :state=>:disabled) .
+ pack(:pady=>5, :padx=>10)
+ },
+
+ Ttk::LabelFrame.new(frame, :text=>'Defined List Only'){|f|
+ Ttk::Combobox.new(f, :textvariable=>ozCity, :state=>:readonly,
+ :values=>australianCities) .
+ pack(:pady=>5, :padx=>10)
+ },
+
+ :side=>:top, :pady=>5, :padx=>10)
diff --git a/jni/ruby/ext/tk/sample/demos-en/cscroll.rb b/jni/ruby/ext/tk/sample/demos-en/cscroll.rb
new file mode 100644
index 0000000..40a3afc
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/demos-en/cscroll.rb
@@ -0,0 +1,136 @@
+# cscroll.rb
+#
+# This demonstration script creates a simple canvas that can be
+# scrolled in two dimensions.
+#
+# simple scrollable canvas widget demo (called by 'widget')
+#
+
+# toplevel widget
+if defined?($cscroll_demo) && $cscroll_demo
+ $cscroll_demo.destroy
+ $cscroll_demo = nil
+end
+
+# demo toplevel widget
+$cscroll_demo = TkToplevel.new {|w|
+ title("Scrollable Canvas Demonstration")
+ iconname("cscroll")
+ positionWindow(w)
+}
+
+base_frame = TkFrame.new($cscroll_demo).pack(:fill=>:both, :expand=>true)
+
+# label
+TkLabel.new(base_frame, 'font'=>$font, 'wraplength'=>'4i',
+ 'justify'=>'left', 'text'=>"This window displays a canvas widget that can be scrolled either using the scrollbars or by dragging with button 2 in the canvas. If you click button 1 on one of the rectangles, its indices will be printed on stdout."){
+ pack('side'=>'top')
+}
+
+# frame
+$cscroll_buttons = TkFrame.new(base_frame) {|frame|
+ TkButton.new(frame) {
+ text 'Dismiss'
+ command proc{
+ tmppath = $cscroll_demo
+ $cscroll_demo = nil
+ tmppath.destroy
+ }
+ }.pack('side'=>'left', 'expand'=>'yes')
+
+ TkButton.new(frame) {
+ text 'Show Code'
+ command proc{showCode 'cscroll'}
+ }.pack('side'=>'left', 'expand'=>'yes')
+}
+$cscroll_buttons.pack('side'=>'bottom', 'fill'=>'x', 'pady'=>'2m')
+
+# frame
+unless $tk_version =~ /^4\.[01]/
+ $cscroll_grid = TkFrame.new(base_frame) {
+ pack('expand'=>'yes', 'fill'=>'both', 'padx'=>1, 'pady'=>1)
+ }
+ TkGrid.rowconfigure($cscroll_grid, 0, 'weight'=>1, 'minsize'=>0)
+ TkGrid.columnconfigure($cscroll_grid, 0, 'weight'=>1, 'minsize'=>0)
+end
+
+# canvas
+$cscroll_canvas = TkCanvas.new(base_frame,
+ 'relief'=>'sunken', 'borderwidth'=>2,
+ 'scrollregion'=>['-11c', '-11c', '50c', '20c']
+ ) {|c|
+ if $tk_version =~ /^4\.[01]/
+ pack('expand'=>'yes', 'fill'=>'both')
+ else
+ grid('in'=>$cscroll_grid, 'padx'=>1, 'pady'=>1, 'row'=>0, 'column'=>0,
+ 'rowspan'=>1, 'columnspan'=>1, 'sticky'=>'news')
+ end
+
+ TkScrollbar.new(base_frame, 'command'=>proc{|*args| c.yview(*args)}) {|vs|
+ c.yscrollcommand(proc{|first,last| vs.set first,last})
+ if $tk_version =~ /^4\.[01]/
+ pack('side'=>'right', 'fill'=>'y')
+ else
+ grid('in'=>$cscroll_grid, 'padx'=>1, 'pady'=>1, 'row'=>0, 'column'=>1,
+ 'rowspan'=>1, 'columnspan'=>1, 'sticky'=>'news')
+ end
+ }
+
+ TkScrollbar.new(base_frame, 'orient'=>'horiz',
+ 'command'=>proc{|*args| c.xview(*args)}) {|hs|
+ c.xscrollcommand(proc{|first,last| hs.set first,last})
+ if $tk_version =~ /^4\.[01]/
+ pack('side'=>'bottom', 'fill'=>'x')
+ else
+ grid('in'=>$cscroll_grid, 'padx'=>1, 'pady'=>1, 'row'=>1, 'column'=>0,
+ 'rowspan'=>1, 'columnspan'=>1, 'sticky'=>'news')
+ end
+ }
+}
+
+bg = $cscroll_canvas.configinfo('bg')[4]
+(0..19).each{|i|
+ x = -10+3*i
+ y = -10
+ (0..9).each{|j|
+ TkcRectangle.new($cscroll_canvas, "#{x}c", "#{y}c", "#{x+2}c", "#{y+2}c",
+ 'outline'=>'black', 'fill'=>bg, 'tags'=>'rect')
+ TkcText.new($cscroll_canvas, "#{x+1}c", "#{y+1}c",
+ 'text'=>"#{i},#{j}", 'anchor'=>'center', 'tags'=>'text')
+ y += 3
+ }
+}
+
+$cscroll_canvas.itembind('all', 'Any-Enter', proc{scrollEnter $cscroll_canvas})
+$cscroll_canvas.itembind('all', 'Any-Leave', proc{scrollLeave $cscroll_canvas})
+$cscroll_canvas.itembind('all', '1', proc{scrollButton $cscroll_canvas})
+$cscroll_canvas.itembind('all', 'Any-Enter', proc{scrollEnter $cscroll_canvas})
+$cscroll_canvas.bind('2', proc{|x,y| $cscroll_canvas.scan_mark(x,y)}, '%x %y')
+$cscroll_canvas.bind('B2-Motion',
+ proc{|x,y| $cscroll_canvas.scan_dragto(x,y)}, '%x %y')
+
+def scrollEnter(c)
+ id = c.find_withtag('current')[0].id
+ id -= 1 if c.gettags('current').include?('text')
+ $oldFill = c.itemconfiginfo(id, 'fill')[4]
+ if TkWinfo.depth(c) > 1
+ c.itemconfigure(id, 'fill'=>'SeaGreen1')
+ else
+ c.itemconfigure(id, 'fill'=>'black')
+ c.itemconfigure(id+1, 'fill'=>'white')
+ end
+end
+
+def scrollLeave(c)
+ id = c.find_withtag('current')[0].id
+ id -= 1 if c.gettags('current').include?('text')
+ c.itemconfigure(id, 'fill'=>$oldFill)
+ c.itemconfigure(id+1, 'fill'=>'black')
+end
+
+def scrollButton(c)
+ id = c.find_withtag('current')[0].id
+ id += 1 unless c.gettags('current').include?('text')
+ print "You buttoned at #{c.itemconfiginfo(id,'text')[4]}\n"
+end
+
diff --git a/jni/ruby/ext/tk/sample/demos-en/ctext.rb b/jni/ruby/ext/tk/sample/demos-en/ctext.rb
new file mode 100644
index 0000000..e04cb28
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/demos-en/ctext.rb
@@ -0,0 +1,207 @@
+# ctext.rb
+#
+# This demonstration script creates a canvas widget with a text
+# item that can be edited and reconfigured in various ways.
+#
+# Canvas Text widget demo (called by 'widget')
+#
+
+# toplevel widget
+if defined?($ctext_demo) && $ctext_demo
+ $ctext_demo.destroy
+ $ctext_demo = nil
+end
+
+# demo toplevel widget
+$ctext_demo = TkToplevel.new {|w|
+ title("Canvas Text Demonstration")
+ iconname("Text")
+ positionWindow(w)
+}
+
+base_frame = TkFrame.new($ctext_demo).pack(:fill=>:both, :expand=>true)
+
+# label
+TkLabel.new(base_frame, 'font'=>$font, 'wraplength'=>'5i', 'justify'=>'left',
+ 'text'=>"This window displays a string of text to demonstrate the text facilities of canvas widgets. You can click in the boxes to adjust the position of the text relative to its positioning point or change its justification. The text also supports the following simple bindings for editing:
+ 1. You can point, click, and type.
+ 2. You can also select with button 1.
+ 3. You can copy the selection to the mouse position with button 2.
+ 4. Backspace and Control+h delete the selection if there is one;
+ otherwise they delete the character just before the insertion cursor.
+ 5. Delete deletes the selection if there is one; otherwise it deletes
+ the character just after the insertion cursor."){
+ pack('side'=>'top')
+}
+
+# frame
+$ctext_buttons = TkFrame.new(base_frame) {|frame|
+ TkButton.new(frame) {
+ text 'Dismiss'
+ command proc{
+ tmppath = $ctext_demo
+ $ctext_demo = nil
+ tmppath.destroy
+ }
+ }.pack('side'=>'left', 'expand'=>'yes')
+
+ TkButton.new(frame) {
+ text 'Show Code'
+ command proc{showCode 'ctext'}
+ }.pack('side'=>'left', 'expand'=>'yes')
+}
+$ctext_buttons.pack('side'=>'bottom', 'fill'=>'x', 'pady'=>'2m')
+
+# canvas
+$ctext_canvas = TkCanvas.new(base_frame, 'relief'=>'flat',
+ 'borderwidth'=>0, 'width'=>500, 'height'=>350)
+$ctext_canvas.pack('side'=>'top', 'expand'=>'yes', 'fill'=>'both')
+
+# font
+if $tk_version =~ /^4.*/
+ textFont = '-*-Helvetica-Medium-R-Normal--*-240-*-*-*-*-*-*'
+else
+ textFont = 'Helvetica 24'
+end
+
+# canvas
+TkcRectangle.new($ctext_canvas, 245, 195, 255, 205,
+ 'outline'=>'black', 'fill'=>'red')
+
+ctag_text_param = {
+ 'text'=>"This is just a string of text to demonstrate the text facilities of canvas widgets. Bindings have been been defined to support editing (see above).",
+ 'width'=>440, 'anchor'=>'n', 'justify'=>'left'
+}
+if $tk_version =~ /^4.*/
+ ctag_text_param['font'] = '-*-Helvetica-Medium-R-Normal--*-240-*-*-*-*-*-*'
+else
+ ctag_text_param['font'] = 'Helvetica 24'
+end
+
+$ctag_text = TkcTag.new($ctext_canvas)
+$ctag_text.withtag(TkcText.new($ctext_canvas, 250, 200, ctag_text_param))
+
+$ctag_text.bind('1', proc{|x,y| textB1Press $ctext_canvas,x,y}, "%x %y")
+$ctag_text.bind('B1-Motion', proc{|x,y| textB1Move $ctext_canvas,x,y}, "%x %y")
+$ctag_text.bind('Shift-1',
+ proc{|x,y| $ctext_canvas.seleect_adjust 'current', "@#{x},#{y}"},
+ "%x %y")
+$ctag_text.bind('Shift-B1-Motion',
+ proc{|x,y| textB1Move $ctext_canvas,x,y}, "%x %y")
+$ctag_text.bind('KeyPress', proc{|a| textInsert $ctext_canvas,a}, "%A")
+$ctag_text.bind('Return', proc{textInsert $ctext_canvas,"\n"})
+$ctag_text.bind('Control-h', proc{textBs $ctext_canvas})
+$ctag_text.bind('BackSpace', proc{textBs $ctext_canvas})
+$ctag_text.bind('Delete', proc{textDel $ctext_canvas})
+$ctag_text.bind('2', proc{|x,y| textPaste $ctext_canvas, "@#{x},#{y}"},
+ "%x %y")
+
+# Next, create some items that allow the text's anchor position
+# to be edited.
+
+def mkTextConfig(w,x,y,option,value,color)
+ item = TkcRectangle.new(w, x, y, x+30, y+30,
+ 'outline'=>'black', 'fill'=>color, 'width'=>1)
+ item.bind('1', proc{$ctag_text.configure option, value})
+ w.addtag_withtag('config', item)
+end
+
+x = 50
+y = 50
+color = 'LightSkyBlue1'
+mkTextConfig $ctext_canvas, x, y, 'anchor', 'se', color
+mkTextConfig $ctext_canvas, x+30, y, 'anchor', 's', color
+mkTextConfig $ctext_canvas, x+60, y, 'anchor', 'sw', color
+mkTextConfig $ctext_canvas, x, y+30, 'anchor', 'e', color
+mkTextConfig $ctext_canvas, x+30, y+30, 'anchor', 'center', color
+mkTextConfig $ctext_canvas, x+60, y+30, 'anchor', 'w', color
+mkTextConfig $ctext_canvas, x, y+60, 'anchor', 'ne', color
+mkTextConfig $ctext_canvas, x+30, y+60, 'anchor', 'n', color
+mkTextConfig $ctext_canvas, x+60, y+60, 'anchor', 'nw', color
+item = TkcRectangle.new($ctext_canvas, x+40, y+40, x+50, y+50,
+ 'outline'=>'black', 'fill'=>'red')
+item.bind('1', proc{$ctag_text.configure 'anchor', 'center'})
+if $tk_version =~ /^4.*/
+ TkcText.new($ctext_canvas, x+45, y-5, 'text'=>'Text Position',
+ 'font'=>'-*-times-medium-r-normal--*-240-*-*-*-*-*-*',
+ 'anchor'=>'s', 'fill'=>'brown')
+else
+ TkcText.new($ctext_canvas, x+45, y-5, 'text'=>'Text Position',
+ 'font'=>'Times 24', 'anchor'=>'s', 'fill'=>'brown')
+end
+
+# Lastly, create some items that allow the text's justification to be
+# changed.
+
+x = 350
+y = 50
+color = 'SeaGreen2'
+mkTextConfig $ctext_canvas, x, y, 'justify', 'left', color
+mkTextConfig $ctext_canvas, x+30, y, 'justify', 'center', color
+mkTextConfig $ctext_canvas, x+60, y, 'justify', 'right', color
+if $tk_version =~ /^4.*/
+ TkcText.new($ctext_canvas, x+45, y-5, 'text'=>'Justification',
+ 'font'=>'-*-times-medium-r-normal--*-240-*-*-*-*-*-*',
+ 'anchor'=>'s', 'fill'=>'brown')
+else
+ TkcText.new($ctext_canvas, x+45, y-5, 'text'=>'Justification',
+ 'font'=>'Times 24', 'anchor'=>'s', 'fill'=>'brown')
+end
+
+$ctext_canvas.itembind('config', 'Enter', proc{textEnter $ctext_canvas})
+$ctext_canvas.itembind('config', 'Leave',
+ proc{$ctext_canvas\
+ .itemconfigure('current',
+ 'fill'=>$textConfigFill)})
+
+$textConfigFill = ''
+
+def textEnter(w)
+ $textConfigFill = (w.itemconfiginfo 'current', 'fill')[4]
+ w.itemconfigure 'current', 'fill', 'black'
+end
+
+def textInsert(w, string)
+ return if string == ""
+ begin
+ $ctag_text.dchars 'sel.first', 'sel.last'
+ rescue
+ end
+ $ctag_text.insert 'insert', string
+end
+
+def textPaste(w, pos)
+ begin
+ $ctag_text.insert pos, TkSelection.get
+ rescue
+ end
+end
+
+def textB1Press(w,x,y)
+ w.icursor 'current', "@#{x},#{y}"
+ w.itemfocus 'current'
+ w.focus
+ w.select_from 'current', "@#{x},#{y}"
+end
+
+def textB1Move(w,x,y)
+ w.select_to 'current', "@#{x},#{y}"
+end
+
+def textBs(w)
+ begin
+ $ctag_text.dchars 'sel.first', 'sel.last'
+ rescue
+ char = $ctag_text.index('insert').to_i - 1
+ $ctag_text.dchars(char) if char >= 0
+ end
+end
+
+def textDel(w)
+ begin
+ $ctag_text.dchars 'sel.first', 'sel.last'
+ rescue
+ $ctag_text.dchars 'insert'
+ end
+end
+
diff --git a/jni/ruby/ext/tk/sample/demos-en/dialog1.rb b/jni/ruby/ext/tk/sample/demos-en/dialog1.rb
new file mode 100644
index 0000000..af476ec
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/demos-en/dialog1.rb
@@ -0,0 +1,38 @@
+#
+# a dialog box with a local grab (called by 'widget')
+#
+class TkDialog_Demo1 < TkDialog
+ ###############
+ private
+ ###############
+ def title
+ "Dialog with local grab"
+ end
+
+ def message
+ 'This is a modal dialog box. It uses Tk\'s "grab" command to create a "local grab" on the dialog box. The grab prevents any pointer-related events from getting to any other windows in the application until you have answered the dialog by invoking one of the buttons below. However, you can still interact with other applications.'
+ end
+
+ def bitmap
+ 'info'
+ end
+
+ def default_button
+ 0
+ end
+
+ def buttons
+ # ["Dismiss", "", "Show Code"]
+ ["OK", "Cancel", "Show Code"]
+ end
+end
+
+ret = TkDialog_Demo1.new('message_config'=>{'wraplength'=>'4i'}).value
+case ret
+when 0
+ print "You pressed OK\n"
+when 1
+ print "You pressed Cancel\n"
+when 2
+ showCode 'dialog1'
+end
diff --git a/jni/ruby/ext/tk/sample/demos-en/dialog2.rb b/jni/ruby/ext/tk/sample/demos-en/dialog2.rb
new file mode 100644
index 0000000..efc4b71
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/demos-en/dialog2.rb
@@ -0,0 +1,41 @@
+#
+# a dialog box with a global grab (called by 'widget')
+#
+class TkDialog_Demo2 < TkDialog
+ ###############
+ private
+ ###############
+ def title
+ "Dialog with global grab"
+ end
+
+ def message
+ "This dialog box uses a global grab, so it prevents you from interacting with anything on your display until you invoke one of the buttons below. Global grabs are almost always a bad idea; don't use them unless you're truly desperate."
+ end
+
+ def bitmap
+ 'info'
+ end
+
+ def default_button
+ 0
+ end
+
+ def buttons
+ ["OK", "Cancel", "Show Code"]
+ end
+end
+
+ret = TkDialog_Demo2.new('message_config'=>{'wraplength'=>'4i'},
+ 'prev_command'=>proc{|dialog|
+ Tk.after 100, proc{dialog.grab('global')}
+ }).value
+case ret
+when 0
+ print "\You pressed OK\n"
+when 1
+ print "You pressed Cancel\n"
+when 2
+ showCode 'dialog2'
+end
+
diff --git a/jni/ruby/ext/tk/sample/demos-en/doc.org/README b/jni/ruby/ext/tk/sample/demos-en/doc.org/README
new file mode 100644
index 0000000..90677d3
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/demos-en/doc.org/README
@@ -0,0 +1,7 @@
+This directory contains a collection of demonstration programs that
+are translated into Japanese. You need to use a Japanized "wish" to
+see these Japanese-translated demonstration programs. You also need
+to put this directory ("demos.jp") at the next to "demos" since some
+of the programs refer to the image files at "demos".
+
+Please refer to the README file at "demos" for more detail.
diff --git a/jni/ruby/ext/tk/sample/demos-en/doc.org/README.JP b/jni/ruby/ext/tk/sample/demos-en/doc.org/README.JP
new file mode 100644
index 0000000..42b4929
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/demos-en/doc.org/README.JP
@@ -0,0 +1,14 @@
+This directory contains "widget" demo for the Japanized Tcl7.6/Tk4.2.
+Most of the messages in the original are translated to Japanese.
+But other tools in this directory are not translated.
+
+Following 2 kanji fonts are defined at the beginning of the file "widget."
+
+ -*--24-*-jisx0208.1983-0
+ -*--16-*-jisx0208.1983-0
+
+These fonts are all part of the core distribution of X11R5, so
+if you are running X11R5, you don't have to modify the file.
+
+But if you don't have these fonts, replace them with appropriate ones.
+"-*--14-*-jisx0208.1983-0" will be a good choice.
diff --git a/jni/ruby/ext/tk/sample/demos-en/doc.org/README.tk80 b/jni/ruby/ext/tk/sample/demos-en/doc.org/README.tk80
new file mode 100644
index 0000000..c71f977
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/demos-en/doc.org/README.tk80
@@ -0,0 +1,46 @@
+This directory contains a collection of programs to demonstrate
+the features of the Tk toolkit. The programs are all scripts for
+"wish", a windowing shell. If wish has been installed in /usr/local
+then you can invoke any of the programs in this directory just
+by typing its file name to your command shell. Otherwise invoke
+wish with the file as its first argument, e.g., "wish hello".
+The rest of this file contains a brief description of each program.
+Files with names ending in ".tcl" are procedure packages used by one
+or more of the demo programs; they can't be used as programs by
+themselves so they aren't described below.
+
+hello - Creates a single button; if you click on it, a message
+ is typed and the application terminates.
+
+widget - Contains a collection of demonstrations of the widgets
+ currently available in the Tk library. Most of the .tcl
+ files are scripts for individual demos available through
+ the "widget" program.
+
+ixset - A simple Tk-based wrapper for the "xset" program, which
+ allows you to interactively query and set various X options
+ such as mouse acceleration and bell volume. Thanks to
+ Pierre David for contributing this example.
+
+rolodex - A mock-up of a simple rolodex application. It has much of
+ the user interface for such an application but no back-end
+ database. This program was written in response to Tom
+ LaStrange's toolkit benchmark challenge.
+
+tcolor - A color editor. Allows you to edit colors in several
+ different ways, and will also perform automatic updates
+ using "send".
+
+rmt - Allows you to "hook-up" remotely to any Tk application
+ on the display. Select an application with the menu,
+ then just type commands: they'll go to that application.
+
+timer - Displays a seconds timer with start and stop buttons.
+ Control-c and control-q cause it to exit.
+
+browse - A simple directory browser. Invoke it with and argument
+ giving the name of the directory you'd like to browse.
+ Double-click on files or subdirectories to browse them.
+ Control-c and control-q cause the program to exit.
+
+sccs id = SCCS: @(#) README 1.3 96/02/16 10:49:14
diff --git a/jni/ruby/ext/tk/sample/demos-en/doc.org/license.terms b/jni/ruby/ext/tk/sample/demos-en/doc.org/license.terms
new file mode 100644
index 0000000..c0a44d3
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/demos-en/doc.org/license.terms
@@ -0,0 +1,39 @@
+This software is copyrighted by the Regents of the University of
+California, Sun Microsystems, Inc., and other parties. The following
+terms apply to all files associated with the software unless explicitly
+disclaimed in individual files.
+
+The authors hereby grant permission to use, copy, modify, distribute,
+and license this software and its documentation for any purpose, provided
+that existing copyright notices are retained in all copies and that this
+notice is included verbatim in any distributions. No written agreement,
+license, or royalty fee is required for any of the authorized uses.
+Modifications to this software may be copyrighted by their authors
+and need not follow the licensing terms described here, provided that
+the new terms are clearly indicated on the first page of each file where
+they apply.
+
+IN NO EVENT SHALL THE AUTHORS OR DISTRIBUTORS BE LIABLE TO ANY PARTY
+FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
+ARISING OUT OF THE USE OF THIS SOFTWARE, ITS DOCUMENTATION, OR ANY
+DERIVATIVES THEREOF, EVEN IF THE AUTHORS HAVE BEEN ADVISED OF THE
+POSSIBILITY OF SUCH DAMAGE.
+
+THE AUTHORS AND DISTRIBUTORS SPECIFICALLY DISCLAIM ANY WARRANTIES,
+INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE, AND NON-INFRINGEMENT. THIS SOFTWARE
+IS PROVIDED ON AN "AS IS" BASIS, AND THE AUTHORS AND DISTRIBUTORS HAVE
+NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR
+MODIFICATIONS.
+
+GOVERNMENT USE: If you are acquiring this software on behalf of the
+U.S. government, the Government shall have only "Restricted Rights"
+in the software and related documentation as defined in the Federal
+Acquisition Regulations (FARs) in Clause 52.227.19 (c) (2). If you
+are acquiring the software on behalf of the Department of Defense, the
+software shall be classified as "Commercial Computer Software" and the
+Government shall have only "Restricted Rights" as defined in Clause
+252.227-7013 (c) (1) of DFARs. Notwithstanding the foregoing, the
+authors grant the U.S. Government and others acting in its behalf
+permission to use and distribute the software in accordance with the
+terms specified in this license.
diff --git a/jni/ruby/ext/tk/sample/demos-en/doc.org/license.terms.tk80 b/jni/ruby/ext/tk/sample/demos-en/doc.org/license.terms.tk80
new file mode 100644
index 0000000..c0a44d3
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/demos-en/doc.org/license.terms.tk80
@@ -0,0 +1,39 @@
+This software is copyrighted by the Regents of the University of
+California, Sun Microsystems, Inc., and other parties. The following
+terms apply to all files associated with the software unless explicitly
+disclaimed in individual files.
+
+The authors hereby grant permission to use, copy, modify, distribute,
+and license this software and its documentation for any purpose, provided
+that existing copyright notices are retained in all copies and that this
+notice is included verbatim in any distributions. No written agreement,
+license, or royalty fee is required for any of the authorized uses.
+Modifications to this software may be copyrighted by their authors
+and need not follow the licensing terms described here, provided that
+the new terms are clearly indicated on the first page of each file where
+they apply.
+
+IN NO EVENT SHALL THE AUTHORS OR DISTRIBUTORS BE LIABLE TO ANY PARTY
+FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
+ARISING OUT OF THE USE OF THIS SOFTWARE, ITS DOCUMENTATION, OR ANY
+DERIVATIVES THEREOF, EVEN IF THE AUTHORS HAVE BEEN ADVISED OF THE
+POSSIBILITY OF SUCH DAMAGE.
+
+THE AUTHORS AND DISTRIBUTORS SPECIFICALLY DISCLAIM ANY WARRANTIES,
+INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE, AND NON-INFRINGEMENT. THIS SOFTWARE
+IS PROVIDED ON AN "AS IS" BASIS, AND THE AUTHORS AND DISTRIBUTORS HAVE
+NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR
+MODIFICATIONS.
+
+GOVERNMENT USE: If you are acquiring this software on behalf of the
+U.S. government, the Government shall have only "Restricted Rights"
+in the software and related documentation as defined in the Federal
+Acquisition Regulations (FARs) in Clause 52.227.19 (c) (2). If you
+are acquiring the software on behalf of the Department of Defense, the
+software shall be classified as "Commercial Computer Software" and the
+Government shall have only "Restricted Rights" as defined in Clause
+252.227-7013 (c) (1) of DFARs. Notwithstanding the foregoing, the
+authors grant the U.S. Government and others acting in its behalf
+permission to use and distribute the software in accordance with the
+terms specified in this license.
diff --git a/jni/ruby/ext/tk/sample/demos-en/entry1.rb b/jni/ruby/ext/tk/sample/demos-en/entry1.rb
new file mode 100644
index 0000000..fac0afc
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/demos-en/entry1.rb
@@ -0,0 +1,58 @@
+#
+# entry (no scrollbars) widget demo (called by 'widget')
+#
+
+# toplevel widget
+if defined?($entry1_demo) && $entry1_demo
+ $entry1_demo.destroy
+ $entry1_demo = nil
+end
+
+# demo toplevel widget
+$entry1_demo = TkToplevel.new {|w|
+ title("Entry Demonstration (no scrollbars)")
+ iconname("entry1")
+ positionWindow(w)
+}
+
+base_frame = TkFrame.new($entry1_demo).pack(:fill=>:both, :expand=>true)
+
+# label
+msg = TkLabel.new(base_frame) {
+ font $font
+ wraplength '5i'
+ justify 'left'
+ text "Three different entries are displayed below. You can add characters by pointing, clicking and typing. The normal Motif editing characters are supported, along with many Emacs bindings. For example, Backspace and Control-h delete the character to the left of the insertion cursor and Delete and Control-d delete the chararacter to the right of the insertion cursor. For entries that are too large to fit in the window all at once, you can scan through the entries by dragging with mouse button2 pressed."
+}
+msg.pack('side'=>'top')
+
+# frame
+TkFrame.new(base_frame) {|frame|
+ TkButton.new(frame) {
+ text 'Dismiss'
+ command proc{
+ tmppath = $entry1_demo
+ $entry1_demo = nil
+ tmppath.destroy
+ }
+ }.pack('side'=>'left', 'expand'=>'yes')
+
+ TkButton.new(frame) {
+ text 'Show Code'
+ command proc{showCode 'entry1'}
+ }.pack('side'=>'left', 'expand'=>'yes')
+}.pack('side'=>'bottom', 'fill'=>'x', 'pady'=>'2m')
+
+#
+e1 = TkEntry.new(base_frame, 'relief'=>'sunken')
+e2 = TkEntry.new(base_frame, 'relief'=>'sunken')
+e3 = TkEntry.new(base_frame, 'relief'=>'sunken')
+[e1,e2,e3].each{|w| w.pack('side'=>'top', 'padx'=>10, 'pady'=>5, 'fill'=>'x')}
+
+#
+e1.insert(0, 'Initial value')
+e2.insert('end', "This entry contains a long value, much too long ")
+e2.insert('end', "to fit in the window at one time, so long in fact ")
+e2.insert('end', "that you'll have to scan or scroll to see the end.")
+e2.insert('end', "")
+
diff --git a/jni/ruby/ext/tk/sample/demos-en/entry2.rb b/jni/ruby/ext/tk/sample/demos-en/entry2.rb
new file mode 100644
index 0000000..05a6c83
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/demos-en/entry2.rb
@@ -0,0 +1,93 @@
+# entry2.rb
+#
+# This demonstration script is the same as the entry1.tcl script
+# except that it creates scrollbars for the entries.
+#
+# entry (with scrollbars) widget demo (called by 'widget')
+#
+
+# toplevel widget
+if defined?($entry2_demo) && $entry2_demo
+ $entry2_demo.destroy
+ $entry2_demo = nil
+end
+
+# demo toplevel widget
+$entry2_demo = TkToplevel.new {|w|
+ title("Entry Demonstration (with scrollbars)")
+ iconname("entry2")
+ positionWindow(w)
+}
+
+base_frame = TkFrame.new($entry2_demo).pack(:fill=>:both, :expand=>true)
+
+# label
+msg = TkLabel.new(base_frame) {
+ font $font
+ wraplength '5i'
+ justify 'left'
+ text "Three different entries are displayed below, with a scrollbar for each entry. You can add characters by pointing, clicking and typing. The normal Motif editing characters are supported, along with many Emacs bindings. For example, Backspace and Control-h delete the character to the left of the insertion cursor and Delete and Control-d delete the chararacter to the right of the insertion cursor. For entries that are too large to fit in the window all at once, you can scan through the entries with the scrollbars, or by dragging with mouse button2 pressed."
+}
+msg.pack('side'=>'top')
+
+# frame
+TkFrame.new(base_frame) {|frame|
+ TkButton.new(frame) {
+ text 'Dismiss'
+ command proc{
+ tmppath = $entry2_demo
+ $entry2_demo = nil
+ tmppath.destroy
+ }
+ }.pack('side'=>'left', 'expand'=>'yes')
+
+ TkButton.new(frame) {
+ text 'Show Code'
+ command proc{showCode 'entry2'}
+ }.pack('side'=>'left', 'expand'=>'yes')
+}.pack('side'=>'bottom', 'fill'=>'x', 'pady'=>'2m')
+
+# frame
+TkFrame.new(base_frame, 'borderwidth'=>10) {|w|
+ # entry 1
+ s1 = TkScrollbar.new(w, 'relief'=>'sunken', 'orient'=>'horiz')
+ e1 = TkEntry.new(w, 'relief'=>'sunken') {
+ xscrollcommand proc{|first,last| s1.set first,last}
+ }
+ s1.command(proc{|*args| e1.xview(*args)})
+ e1.pack('side'=>'top', 'fill'=>'x')
+ s1.pack('side'=>'top', 'fill'=>'x')
+
+ # spacer
+ TkFrame.new(w, 'width'=>20, 'height'=>10).pack('side'=>'top', 'fill'=>'x')
+
+ # entry 2
+ s2 = TkScrollbar.new(w, 'relief'=>'sunken', 'orient'=>'horiz')
+ e2 = TkEntry.new(w, 'relief'=>'sunken') {
+ xscrollcommand proc{|first,last| s2.set first,last}
+ }
+ s2.command(proc{|*args| e2.xview(*args)})
+ e2.pack('side'=>'top', 'fill'=>'x')
+ s2.pack('side'=>'top', 'fill'=>'x')
+
+ # spacer
+ TkFrame.new(w, 'width'=>20, 'height'=>10).pack('side'=>'top', 'fill'=>'x')
+
+ # entry 3
+ s3 = TkScrollbar.new(w, 'relief'=>'sunken', 'orient'=>'horiz')
+ e3 = TkEntry.new(w, 'relief'=>'sunken') {
+ xscrollcommand proc{|first,last| s3.set first,last}
+ }
+ s3.command(proc{|*args| e3.xview(*args)})
+ e3.pack('side'=>'top', 'fill'=>'x')
+ s3.pack('side'=>'top', 'fill'=>'x')
+
+ #
+ e1.insert(0, 'Initial value')
+ e2.insert('end', "This entry contains a long value, much too long ")
+ e2.insert('end', "to fit in the window at one time, so long in fact ")
+ e2.insert('end', "that you'll have to scan or scroll to see the end.")
+ e2.insert('end', "")
+
+}.pack('side'=>'top', 'fill'=>'x', 'expand'=>'yes')
+
diff --git a/jni/ruby/ext/tk/sample/demos-en/entry3.rb b/jni/ruby/ext/tk/sample/demos-en/entry3.rb
new file mode 100644
index 0000000..d3bc629
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/demos-en/entry3.rb
@@ -0,0 +1,220 @@
+# entry3.rb --
+#
+# This demonstration script creates several entry widgets whose
+# permitted input is constrained in some way. It also shows off a
+# password entry.
+#
+# based on Tcl/Tk8.4.4 widget demos
+
+if defined?($entry3_demo) && $entry3_demo
+ $entry3_demo.destroy
+ $entry3_demo = nil
+end
+
+$entry3_demo = TkToplevel.new {|w|
+ title("Constrained Entry Demonstration")
+ iconname("entry3")
+ positionWindow(w)
+}
+
+base_frame = TkFrame.new($entry3_demo).pack(:fill=>:both, :expand=>true)
+
+TkLabel.new(base_frame,
+ :font=>$font, :wraplength=>'5i', :justify=>:left,
+ :text=><<EOL).pack(:side=>:top)
+Four different entries are displayed below. You can add characters \
+by pointing, clicking and typing, though each is constrained in what \
+it will accept. The first only accepts integers or the empty string \
+(checking when focus leaves it) and will flash to indicate any \
+problem. The second only accepts strings with fewer than ten \
+characters and sounds the bell when an attempt to go over the limit \
+is made. The third accepts US phone numbers, mapping letters to \
+their digit equivalent and sounding the bell on encountering an \
+invalid character or if trying to type over a character that is not \
+a digit. The fourth is a password field that accepts up to eight \
+characters (silently ignoring further ones), and displaying them as \
+asterisk characters.
+EOL
+
+TkFrame.new(base_frame){|f|
+ pack(:side=>:bottom, :fill=>:x, :pady=>'2m')
+
+ TkButton.new(f, :text=>'Dismiss', :width=>15, :command=>proc{
+ $entry3_demo.destroy
+ $entry3_demo = nil
+ }).pack(:side=>:left, :expand=>true)
+
+ TkButton.new(f, :text=>'See Code', :width=>15, :command=>proc{
+ showCode 'entry3'
+ }).pack(:side=>:left, :expand=>true)
+}
+
+# focusAndFlash --
+# Error handler for entry widgets that forces the focus onto the
+# widget and makes the widget flash by exchanging the foreground and
+# background colours at intervals of 200ms (i.e. at approximately
+# 2.5Hz).
+#
+# Arguments:
+# widget - entry widget to flash
+# fg - Initial foreground colour
+# bg - Initial background colour
+# count - Counter to control the number of times flashed
+def focusAndFlash(widget, fg, bg, count=5)
+ return if count <= 0
+ if fg && !fg.empty? && bg && !bg.empty?
+ TkTimer.new(200, count,
+ proc{widget.configure(:foreground=>bg, :background=>fg)},
+ proc{widget.configure(:foreground=>fg, :background=>bg)}
+ ).start
+ else
+ # TkTimer.new(150, 3){Tk.bell}.start
+ Tk.bell
+ TkTimer.new(200, count,
+ proc{widget.configure(:foreground=>'white',
+ :background=>'black')},
+ proc{widget.configure(:foreground=>'black',
+ :background=>'white')}
+ ).at_end{begin
+ widget.configure(:foreground=>fg,
+ :background=>bg)
+ rescue
+ # ignore
+ end}.start
+ end
+ widget.focus(true)
+end
+
+l1 = TkLabelFrame.new(base_frame, :text=>"Integer Entry")
+TkEntry.new(l1, :validate=>:focus,
+ :vcmd=>[
+ proc{|s| s == '' || /^[+-]?\d+$/ =~ s }, '%P'
+ ]) {|e|
+ fg = e.foreground
+ bg = e.background
+ invalidcommand [proc{|w| focusAndFlash(w, fg, bg)}, '%W']
+ pack(:fill=>:x, :expand=>true, :padx=>'1m', :pady=>'1m')
+}
+
+l2 = TkLabelFrame.new(base_frame, :text=>"Length-Constrained Entry")
+TkEntry.new(l2, :validate=>:key, :invcmd=>proc{Tk.bell},
+ :vcmd=>[proc{|s| s.length < 10}, '%P']
+ ).pack(:fill=>:x, :expand=>true, :padx=>'1m', :pady=>'1m')
+
+### PHONE NUMBER ENTRY ###
+# Note that the source to this is quite a bit longer as the behaviour
+# demonstrated is a lot more ambitious than with the others.
+
+# Initial content for the third entry widget
+entry3content = TkVariable.new("1-(000)-000-0000")
+
+# Mapping from alphabetic characters to numbers.
+$phoneNumberMap = {}
+Hash[*(%w(abc 2 def 3 ghi 4 jkl 5 mno 6 pqrs 7 tuv 8 wxyz 9))].each{|chars, n|
+ chars.split('').each{|c|
+ $phoneNumberMap[c] = n
+ $phoneNumberMap[c.upcase] = n
+ }
+}
+
+# phoneSkipLeft --
+# Skip over fixed characters in a phone-number string when moving left.
+#
+# Arguments:
+# widget - The entry widget containing the phone-number.
+def phoneSkipLeft(widget)
+ idx = widget.index('insert')
+ if idx == 8
+ # Skip back two extra characters
+ widget.cursor = idx - 2
+ elsif idx == 7 || idx == 12
+ # Skip back one extra character
+ widget.cursor = idx - 1
+ elsif idx <= 3
+ # Can't move any further
+ Tk.bell
+ Tk.callback_break
+ end
+end
+
+# phoneSkipRight --
+# Skip over fixed characters in a phone-number string when moving right.
+#
+# Arguments:
+# widget - The entry widget containing the phone-number.
+# add - Offset to add to index before calculation (used by validation.)
+def phoneSkipRight(widget, add = 0)
+ idx = widget.index('insert')
+ if (idx + add == 5)
+ # Skip forward two extra characters
+ widget.cursor = idx + 2
+ elsif (idx + add == 6 || idx + add == 10)
+ # Skip forward one extra character
+ widget.cursor = idx + 1
+ elsif (idx + add == 15 && add == 0)
+ # Can't move any further
+ Tk.bell
+ Tk.callback_break
+ end
+end
+
+# validatePhoneChange --
+# Checks that the replacement (mapped to a digit) of the given
+# character in an entry widget at the given position will leave a
+# valid phone number in the widget.
+#
+# widget - entry widget to validate
+# vmode - The widget's validation mode
+# idx - The index where replacement is to occur
+# char - The character (or string, though that will always be
+# refused) to be overwritten at that point.
+
+def validatePhoneChange(widget, vmode, idx, char)
+ return true if idx == nil
+ Tk.after_idle(proc{widget.configure(:validate=>vmode,
+ :invcmd=>proc{Tk.bell})})
+ if !(idx<3 || idx==6 || idx==7 || idx==11 || idx>15) && char =~ /[0-9A-Za-z]/
+ widget.delete(idx)
+ widget.insert(idx, $phoneNumberMap[char] || char)
+ Tk.after_idle(proc{phoneSkipRight(widget, -1)})
+ return true
+ # Tk.update(true) # <- Don't work 'update' inter validation callback.
+ # It depends on Tcl/Tk side (tested on Tcl/Tk8.5a1).
+ end
+ return false
+end
+
+
+l3 = TkLabelFrame.new(base_frame, :text=>"US Phone-Number Entry")
+TkEntry.new(l3, :validate=>:key, :invcmd=>proc{Tk.bell},
+ :textvariable=>entry3content,
+ :vcmd=>[
+ proc{|w,v,i,s| validatePhoneChange(w,v,i,s)},
+ "%W %v %i %S"
+ ]){|e|
+ # Click to focus goes to the first editable character...
+ bind('FocusIn', proc{|d,w|
+ if d != "NotifyAncestor"
+ w.cursor = 3
+ Tk.after_idle(proc{w.selection_clear})
+ end
+ }, '%d %W')
+ bind('Left', proc{|w| phoneSkipLeft(w)}, '%W')
+ bind('Right', proc{|w| phoneSkipRight(w)}, '%W')
+ pack(:fill=>:x, :expand=>true, :padx=>'1m', :pady=>'1m')
+}
+
+l4 = TkLabelFrame.new(base_frame, :text=>"Password Entry")
+TkEntry.new(l4, :validate=>:key, :show=>'*',
+ :vcmd=>[
+ proc{|s| s.length <= 8},
+ '%P'
+ ]).pack(:fill=>:x, :expand=>true, :padx=>'1m', :pady=>'1m')
+
+TkFrame.new(base_frame){|f|
+ lower
+ TkGrid.configure(l1, l2, :in=>f, :padx=>'3m', :pady=>'1m', :sticky=>:ew)
+ TkGrid.configure(l3, l4, :in=>f, :padx=>'3m', :pady=>'1m', :sticky=>:ew)
+ TkGrid.columnconfigure(f, [0,1], :uniform=>1)
+ pack(:fill=>:both, :expand=>true)
+}
diff --git a/jni/ruby/ext/tk/sample/demos-en/filebox.rb b/jni/ruby/ext/tk/sample/demos-en/filebox.rb
new file mode 100644
index 0000000..0c284c1
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/demos-en/filebox.rb
@@ -0,0 +1,102 @@
+# filebox.rb
+#
+# This demonstration script prompts the user to select a file.#
+# widget demo prompts the user to select a file (called by 'widget')
+#
+
+# toplevel widget
+if defined?($filebox_demo) && $filebox_demo
+ $filebox_demo.destroy
+ $filebox_demo = nil
+end
+
+# demo toplevel widget
+$filebox_demo = TkToplevel.new {|w|
+ title("File Selection Dialogs")
+ iconname("filebox")
+ positionWindow(w)
+}
+
+base_frame = TkFrame.new($filebox_demo).pack(:fill=>:both, :expand=>true)
+
+# label
+TkLabel.new(base_frame,'font'=>$font,'wraplength'=>'4i','justify'=>'left',
+ 'text'=>"Enter a file name in the entry box or click on the \"Browse\" buttons to select a file name using the file selection dialog.").pack('side'=>'top')
+
+# frame
+TkFrame.new(base_frame) {|frame|
+ TkButton.new(frame) {
+ text 'Dismiss'
+ command proc{
+ tmppath = $filebox_demo
+ $filebox_demo = nil
+ tmppath.destroy
+ }
+ }.pack('side'=>'left', 'expand'=>'yes')
+
+ TkButton.new(frame) {
+ text 'Show Code'
+ command proc{showCode 'filebox'}
+ }.pack('side'=>'left', 'expand'=>'yes')
+}.pack('side'=>'bottom', 'fill'=>'x', 'pady'=>'2m')
+
+# frame
+['open', 'save'].each{|type|
+ TkFrame.new(base_frame) {|f|
+ TkLabel.new(f, 'text'=>"Select a file to #{type}: ", 'anchor'=>'e')\
+ .pack('side'=>'left')
+
+ TkEntry.new(f, 'width'=>20) {|e|
+ pack('side'=>'left', 'expand'=>'yes', 'fill'=>'x')
+
+ TkButton.new(f, 'text'=>'Browse ...',
+ 'command'=>proc{fileDialog base_frame,e,type})\
+ .pack('side'=>'left')
+ }
+
+ pack('fill'=>'x', 'padx'=>'1c', 'pady'=>3)
+ }
+}
+
+$tk_strictMotif = TkVarAccess.new('tk_strictMotif')
+if ($tk_platform['platform'] == 'unix')
+ TkCheckButton.new(base_frame,
+ 'text'=>'Use Motif Style Dialog',
+ 'variable'=>$tk_strictMotif,
+ 'onvalue'=>1, 'offvalue'=>0 ).pack('anchor'=>'c')
+end
+
+def fileDialog(w,ent,operation)
+ # Type names Extension(s) Mac File Type(s)
+ #
+ #--------------------------------------------------------
+ types = [
+ ['Text files', ['.txt','.doc'] ],
+ ['Text files', [], 'TEXT' ],
+ ['Ruby Scripts', ['.rb'], 'TEXT' ],
+ ['Tcl Scripts', ['.tcl'], 'TEXT' ],
+ ['C Source Files', ['.c','.h'] ],
+ ['All Source Files', ['.rb','.tcl','.c','.h'] ],
+ ['Image Files', ['.gif'] ],
+ ['Image Files', ['.jpeg','.jpg'] ],
+ ['Image Files', [], ['GIFF','JPEG']],
+ ['All files', '*' ]
+ ]
+
+ if operation == 'open'
+ file = Tk.getOpenFile('filetypes'=>types, 'parent'=>w)
+ else
+ file = Tk.getSaveFile('filetypes'=>types, 'parent'=>w,
+ 'initialfile'=>'Untitled',
+ 'defaultextension'=>'.txt')
+ end
+ if file != ""
+ ent.delete 0, 'end'
+ ent.insert 0, file
+ # ent.xview 'end'
+ Tk.update_idletasks # need this for Tk::Tile::Entry
+ # (to find right position of 'xview').
+ ent.xview(ent.index('end'))
+ end
+end
+
diff --git a/jni/ruby/ext/tk/sample/demos-en/floor.rb b/jni/ruby/ext/tk/sample/demos-en/floor.rb
new file mode 100644
index 0000000..eb8b23e
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/demos-en/floor.rb
@@ -0,0 +1,1723 @@
+# floor.rb
+#
+# This demonstration script creates a canvas widet that displays the
+# floorplan for DEC's Western Research Laboratory.
+#
+# floorDisplay widget demo (called by 'widget')
+#
+
+# floorDisplay --
+# Recreate the floorplan display in the canvas given by "w". The
+# floor given by "active" is displayed on top with its office structure
+# visible.
+#
+# Arguments:
+# w - Name of the canvas window.
+# active - Number of active floor (1, 2, or 3).
+
+def floorDisplay(w,active)
+ return if $activeFloor == active
+
+ w.delete('all')
+ $activeFloor = active
+
+ # First go through the three floors, displaying the backgrounds for
+ # each floor.
+
+ floor_bg1(w,$floor_colors['bg1'],$floor_colors['outline1'])
+ floor_bg2(w,$floor_colors['bg2'],$floor_colors['outline2'])
+ floor_bg3(w,$floor_colors['bg3'],$floor_colors['outline3'])
+
+ # Raise the background for the active floor so that it's on top.
+
+ w.raise("floor#{active}")
+
+ # Create a dummy item just to mark this point in the display list,
+ # so we can insert highlights here.
+
+ TkcRectangle.new(w,0,100,1,101, 'fill'=>'', 'outline'=>'', 'tags'=>'marker')
+
+ # Add the walls and labels for the active floor, along with
+ # transparent polygons that define the rooms on the floor.
+ # Make sure that the room polygons are on top.
+
+ $floorLabels.clear
+ $floorItems.clear
+ send("floor_fg#{active}", w, $floor_colors['offices'])
+ w.raise('room')
+
+ # Offset the floors diagonally from each other.
+
+ w.move('floor1', '2c', '2c')
+ w.move('floor2', '1c', '1c')
+
+ # Create items for the room entry and its label.
+ TkcWindow.new(w, 600, 100, 'anchor'=>'w', 'window'=>$floor_entry)
+ TkcText.new(w, 600, 100, 'anchor'=>'e', 'text'=>"Room: ")
+ w['scrollregion'] = w.bbox('all')
+end
+
+# newRoom --
+# This method is invoked whenever the mouse enters a room
+# in the floorplan. It changes tags so that the current room is
+# highlighted.
+#
+# Arguments:
+# w - The name of the canvas window.
+
+def newRoom(w)
+ id = w.find_withtag('current')[0]
+ $currentRoom.value = $floorLabels[id.id] if id != ""
+ Tk.update(true)
+end
+
+# roomChanged --
+# This method is invoked whenever the currentRoom variable changes.
+# It highlights the current room and unhighlights any previous room.
+#
+# Arguments:
+# w - The canvas window displaying the floorplan.
+# args - Not used.
+
+def roomChanged(w,*args)
+ w.delete('highlight')
+ item = $floorItems[$currentRoom.value]
+ return if item == nil
+ new = TkcPolygon.new(w, *(w.coords(item)))
+ new.configure('fill'=>$floor_colors['active'], 'tags'=>'highlight')
+ w.raise(new, 'marker')
+end
+
+# floor_bg1 --
+# This method represents part of the floorplan database. When
+# invoked, it instantiates the background information for the first
+# floor.
+#
+# Arguments:
+# w - The canvas window.
+# fill - Fill color to use for the floor's background.
+# outline - Color to use for the floor's outline.
+
+def floor_bg1(w,fill,outline)
+ TkcPolygon.new(w,347,80,349,82,351,84,353,85,363,92,375,99,386,104,
+ 386,129,398,129,398,162,484,162,484,129,559,129,559,133,725,
+ 133,725,129,802,129,802,389,644,389,644,391,559,391,559,327,
+ 508,327,508,311,484,311,484,278,395,278,395,288,400,288,404,
+ 288,409,290,413,292,418,297,421,302,422,309,421,318,417,325,
+ 411,330,405,332,397,333,344,333,340,334,336,336,335,338,332,
+ 342,331,347,332,351,334,354,336,357,341,359,340,360,335,363,
+ 331,365,326,366,304,366,304,355,258,355,258,387,60,387,60,391,
+ 0,391,0,337,3,337,3,114,8,114,8,25,30,25,30,5,93,5,98,5,104,7,
+ 110,10,116,16,119,20,122,28,123,32,123,68,220,68,220,34,221,
+ 22,223,17,227,13,231,8,236,4,242,2,246,0,260,0,283,1,300,5,
+ 321,14,335,22,348,25,365,29,363,39,358,48,352,56,337,70,
+ 344,76,347,80, 'tags'=>['floor1','bg'], 'fill'=>fill)
+ TkcLine.new(w,386,129,398,129, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ TkcLine.new(w,258,355,258,387, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ TkcLine.new(w,60,387,60,391, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ TkcLine.new(w,0,337,0,391, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ TkcLine.new(w,60,391,0,391, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ TkcLine.new(w,3,114,3,337, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ TkcLine.new(w,258,387,60,387, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ TkcLine.new(w,484,162,398,162, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ TkcLine.new(w,398,162,398,129, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ TkcLine.new(w,484,278,484,311, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ TkcLine.new(w,484,311,508,311, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ TkcLine.new(w,508,327,508,311, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ TkcLine.new(w,559,327,508,327, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ TkcLine.new(w,644,391,559,391, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ TkcLine.new(w,644,389,644,391, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ TkcLine.new(w,559,129,484,129, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ TkcLine.new(w,484,162,484,129, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ TkcLine.new(w,725,133,559,133, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ TkcLine.new(w,559,129,559,133, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ TkcLine.new(w,725,129,802,129, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ TkcLine.new(w,802,389,802,129, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ TkcLine.new(w,3,337,0,337, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ TkcLine.new(w,559,391,559,327, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ TkcLine.new(w,802,389,644,389, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ TkcLine.new(w,725,133,725,129, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ TkcLine.new(w,8,25,8,114, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ TkcLine.new(w,8,114,3,114, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ TkcLine.new(w,30,25,8,25, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ TkcLine.new(w,484,278,395,278, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ TkcLine.new(w,30,25,30,5, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ TkcLine.new(w,93,5,30,5, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ TkcLine.new(w,98,5,93,5, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ TkcLine.new(w,104,7,98,5, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ TkcLine.new(w,110,10,104,7, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ TkcLine.new(w,116,16,110,10, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ TkcLine.new(w,119,20,116,16, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ TkcLine.new(w,122,28,119,20, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ TkcLine.new(w,123,32,122,28, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ TkcLine.new(w,123,68,123,32, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ TkcLine.new(w,220,68,123,68, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ TkcLine.new(w,386,129,386,104, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ TkcLine.new(w,386,104,375,99, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ TkcLine.new(w,375,99,363,92, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ TkcLine.new(w,353,85,363,92, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ TkcLine.new(w,220,68,220,34, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ TkcLine.new(w,337,70,352,56, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ TkcLine.new(w,352,56,358,48, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ TkcLine.new(w,358,48,363,39, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ TkcLine.new(w,363,39,365,29, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ TkcLine.new(w,365,29,348,25, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ TkcLine.new(w,348,25,335,22, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ TkcLine.new(w,335,22,321,14, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ TkcLine.new(w,321,14,300,5, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ TkcLine.new(w,300,5,283,1, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ TkcLine.new(w,283,1,260,0, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ TkcLine.new(w,260,0,246,0, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ TkcLine.new(w,246,0,242,2, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ TkcLine.new(w,242,2,236,4, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ TkcLine.new(w,236,4,231,8, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ TkcLine.new(w,231,8,227,13, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ TkcLine.new(w,223,17,227,13, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ TkcLine.new(w,221,22,223,17, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ TkcLine.new(w,220,34,221,22, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ TkcLine.new(w,340,360,335,363, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ TkcLine.new(w,335,363,331,365, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ TkcLine.new(w,331,365,326,366, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ TkcLine.new(w,326,366,304,366, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ TkcLine.new(w,304,355,304,366, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ TkcLine.new(w,395,288,400,288, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ TkcLine.new(w,404,288,400,288, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ TkcLine.new(w,409,290,404,288, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ TkcLine.new(w,413,292,409,290, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ TkcLine.new(w,418,297,413,292, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ TkcLine.new(w,421,302,418,297, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ TkcLine.new(w,422,309,421,302, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ TkcLine.new(w,421,318,422,309, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ TkcLine.new(w,421,318,417,325, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ TkcLine.new(w,417,325,411,330, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ TkcLine.new(w,411,330,405,332, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ TkcLine.new(w,405,332,397,333, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ TkcLine.new(w,397,333,344,333, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ TkcLine.new(w,344,333,340,334, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ TkcLine.new(w,340,334,336,336, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ TkcLine.new(w,336,336,335,338, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ TkcLine.new(w,335,338,332,342, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ TkcLine.new(w,331,347,332,342, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ TkcLine.new(w,332,351,331,347, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ TkcLine.new(w,334,354,332,351, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ TkcLine.new(w,336,357,334,354, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ TkcLine.new(w,341,359,336,357, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ TkcLine.new(w,341,359,340,360, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ TkcLine.new(w,395,288,395,278, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ TkcLine.new(w,304,355,258,355, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ TkcLine.new(w,347,80,344,76, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ TkcLine.new(w,344,76,337,70, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ TkcLine.new(w,349,82,347,80, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ TkcLine.new(w,351,84,349,82, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ TkcLine.new(w,353,85,351,84, 'fill'=>outline, 'tags'=>['floor1','bg'])
+end
+
+# floor_bg2 --
+# This method represents part of the floorplan database. When
+# invoked, it instantiates the background information for the first
+# floor.
+#
+# Arguments:
+# w - The canvas window.
+# fill - Fill color to use for the floor's background.
+# outline - Color to use for the floor's outline.
+
+def floor_bg2(w,fill,outline)
+ TkcPolygon.new(w,559,129,484,129,484,162,398,162,398,129,315,129,
+ 315,133,176,133,176,129,96,129,96,133,3,133,3,339,0,339,0,391,
+ 60,391,60,387,258,387,258,329,350,329,350,311,395,311,395,280,
+ 484,280,484,311,508,311,508,327,558,327,558,391,644,391,644,
+ 367,802,367,802,129,725,129,725,133,559,133,559,129,
+ 'tags'=>['floor2','bg'], 'fill'=>fill)
+ TkcLine.new(w,350,311,350,329, 'fill'=>outline, 'tags'=>['floor2','bg'])
+ TkcLine.new(w,398,129,398,162, 'fill'=>outline, 'tags'=>['floor2','bg'])
+ TkcLine.new(w,802,367,802,129, 'fill'=>outline, 'tags'=>['floor2','bg'])
+ TkcLine.new(w,802,129,725,129, 'fill'=>outline, 'tags'=>['floor2','bg'])
+ TkcLine.new(w,725,133,725,129, 'fill'=>outline, 'tags'=>['floor2','bg'])
+ TkcLine.new(w,559,129,559,133, 'fill'=>outline, 'tags'=>['floor2','bg'])
+ TkcLine.new(w,559,133,725,133, 'fill'=>outline, 'tags'=>['floor2','bg'])
+ TkcLine.new(w,484,162,484,129, 'fill'=>outline, 'tags'=>['floor2','bg'])
+ TkcLine.new(w,559,129,484,129, 'fill'=>outline, 'tags'=>['floor2','bg'])
+ TkcLine.new(w,802,367,644,367, 'fill'=>outline, 'tags'=>['floor2','bg'])
+ TkcLine.new(w,644,367,644,391, 'fill'=>outline, 'tags'=>['floor2','bg'])
+ TkcLine.new(w,644,391,558,391, 'fill'=>outline, 'tags'=>['floor2','bg'])
+ TkcLine.new(w,558,327,558,391, 'fill'=>outline, 'tags'=>['floor2','bg'])
+ TkcLine.new(w,558,327,508,327, 'fill'=>outline, 'tags'=>['floor2','bg'])
+ TkcLine.new(w,508,327,508,311, 'fill'=>outline, 'tags'=>['floor2','bg'])
+ TkcLine.new(w,484,311,508,311, 'fill'=>outline, 'tags'=>['floor2','bg'])
+ TkcLine.new(w,484,280,484,311, 'fill'=>outline, 'tags'=>['floor2','bg'])
+ TkcLine.new(w,398,162,484,162, 'fill'=>outline, 'tags'=>['floor2','bg'])
+ TkcLine.new(w,484,280,395,280, 'fill'=>outline, 'tags'=>['floor2','bg'])
+ TkcLine.new(w,395,280,395,311, 'fill'=>outline, 'tags'=>['floor2','bg'])
+ TkcLine.new(w,258,387,60,387, 'fill'=>outline, 'tags'=>['floor2','bg'])
+ TkcLine.new(w,3,133,3,339, 'fill'=>outline, 'tags'=>['floor2','bg'])
+ TkcLine.new(w,3,339,0,339, 'fill'=>outline, 'tags'=>['floor2','bg'])
+ TkcLine.new(w,60,391,0,391, 'fill'=>outline, 'tags'=>['floor2','bg'])
+ TkcLine.new(w,0,339,0,391, 'fill'=>outline, 'tags'=>['floor2','bg'])
+ TkcLine.new(w,60,387,60,391, 'fill'=>outline, 'tags'=>['floor2','bg'])
+ TkcLine.new(w,258,329,258,387, 'fill'=>outline, 'tags'=>['floor2','bg'])
+ TkcLine.new(w,350,329,258,329, 'fill'=>outline, 'tags'=>['floor2','bg'])
+ TkcLine.new(w,395,311,350,311, 'fill'=>outline, 'tags'=>['floor2','bg'])
+ TkcLine.new(w,398,129,315,129, 'fill'=>outline, 'tags'=>['floor2','bg'])
+ TkcLine.new(w,176,133,315,133, 'fill'=>outline, 'tags'=>['floor2','bg'])
+ TkcLine.new(w,176,129,96,129, 'fill'=>outline, 'tags'=>['floor2','bg'])
+ TkcLine.new(w,3,133,96,133, 'fill'=>outline, 'tags'=>['floor2','bg'])
+ TkcLine.new(w,315,133,315,129, 'fill'=>outline, 'tags'=>['floor2','bg'])
+ TkcLine.new(w,176,133,176,129, 'fill'=>outline, 'tags'=>['floor2','bg'])
+ TkcLine.new(w,96,133,96,129, 'fill'=>outline, 'tags'=>['floor2','bg'])
+end
+
+# floor_bg3 --
+# This method represents part of the floorplan database. When
+# invoked, it instantiates the background information for the first
+# floor.
+#
+# Arguments:
+# w - The canvas window.
+# fill - Fill color to use for the floor's background.
+# outline - Color to use for the floor's outline.
+
+def floor_bg3(w,fill,outline)
+ TkcPolygon.new(w,159,300,107,300,107,248,159,248,159,129,96,129,96,
+ 133,21,133,21,331,0,331,0,391,60,391,60,370,159,370,159,300,
+ 'tags'=>['floor3','bg'], 'fill'=>fill)
+ TkcPolygon.new(w,258,370,258,329,350,329,350,311,399,311,399,129,
+ 315,129,315,133,176,133,176,129,159,129,159,370,258,370,
+ 'tags'=>['floor3','bg'], 'fill'=>fill)
+ TkcLine.new(w,96,133,96,129, 'fill'=>outline, 'tags'=>['floor3','bg'])
+ TkcLine.new(w,176,129,96,129, 'fill'=>outline, 'tags'=>['floor3','bg'])
+ TkcLine.new(w,176,129,176,133, 'fill'=>outline, 'tags'=>['floor3','bg'])
+ TkcLine.new(w,315,133,176,133, 'fill'=>outline, 'tags'=>['floor3','bg'])
+ TkcLine.new(w,315,133,315,129, 'fill'=>outline, 'tags'=>['floor3','bg'])
+ TkcLine.new(w,399,129,315,129, 'fill'=>outline, 'tags'=>['floor3','bg'])
+ TkcLine.new(w,399,311,399,129, 'fill'=>outline, 'tags'=>['floor3','bg'])
+ TkcLine.new(w,399,311,350,311, 'fill'=>outline, 'tags'=>['floor3','bg'])
+ TkcLine.new(w,350,329,350,311, 'fill'=>outline, 'tags'=>['floor3','bg'])
+ TkcLine.new(w,350,329,258,329, 'fill'=>outline, 'tags'=>['floor3','bg'])
+ TkcLine.new(w,258,370,258,329, 'fill'=>outline, 'tags'=>['floor3','bg'])
+ TkcLine.new(w,60,370,258,370, 'fill'=>outline, 'tags'=>['floor3','bg'])
+ TkcLine.new(w,60,370,60,391, 'fill'=>outline, 'tags'=>['floor3','bg'])
+ TkcLine.new(w,60,391,0,391, 'fill'=>outline, 'tags'=>['floor3','bg'])
+ TkcLine.new(w,0,391,0,331, 'fill'=>outline, 'tags'=>['floor3','bg'])
+ TkcLine.new(w,21,331,0,331, 'fill'=>outline, 'tags'=>['floor3','bg'])
+ TkcLine.new(w,21,331,21,133, 'fill'=>outline, 'tags'=>['floor3','bg'])
+ TkcLine.new(w,96,133,21,133, 'fill'=>outline, 'tags'=>['floor3','bg'])
+ TkcLine.new(w,107,300,159,300,159,248,107,248,107,300,
+ 'fill'=>outline, 'tags'=>['floor3','bg'])
+end
+
+# floor_fg1 --
+# This method represents part of the floorplan database. When
+# invoked, it instantiates the foreground information for the first
+# floor (office outlines and numbers).
+#
+# Arguments:
+# w - The canvas window.
+# color - Color to use for drawing foreground information.
+
+def floor_fg1(w,color)
+ i = TkcPolygon.new(w,375,246,375,172,341,172,341,246,
+ 'fill'=>'', 'tags'=>['floor1','room'])
+ $floorLabels[i.id] = '101'
+ $floorItems['101'] = i
+ TkcText.new(w,358,209, 'text'=>'101', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor1','label'])
+ i = TkcPolygon.new(w,307,240,339,240,339,206,307,206,
+ 'fill'=>'', 'tags'=>['floor1','room'])
+ $floorLabels[i.id] = 'Pub Lift1'
+ $floorItems['Pub Lift1'] = i
+ TkcText.new(w,323,223, 'text'=>'Pub Lift1', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor1','label'])
+ i = TkcPolygon.new(w,339,205,307,205,307,171,339,171,
+ 'fill'=>'', 'tags'=>['floor1','room'])
+ $floorLabels[i.id] = 'Priv Lift1'
+ $floorItems['Priv Lift1'] = i
+ TkcText.new(w,323,188, 'text'=>'Priv Lift1', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor1','label'])
+ i = TkcPolygon.new(w,42,389,42,337,1,337,1,389,
+ 'fill'=>'', 'tags'=>['floor1','room'])
+ $floorLabels[i.id] = '110'
+ $floorItems['110'] = i
+ TkcText.new(w,21.5,363, 'text'=>'110', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor1','label'])
+ i = TkcPolygon.new(w,59,389,59,385,90,385,90,337,44,337,44,389,
+ 'fill'=>'', 'tags'=>['floor1','room'])
+ $floorLabels[i.id] = '109'
+ $floorItems['109'] = i
+ TkcText.new(w,67,363, 'text'=>'109', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor1','label'])
+ i = TkcPolygon.new(w,51,300,51,253,6,253,6,300,
+ 'fill'=>'', 'tags'=>['floor1','room'])
+ $floorLabels[i.id] = '111'
+ $floorItems['111'] = i
+ TkcText.new(w,28.5,276.5, 'text'=>'111', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor1','label'])
+ i = TkcPolygon.new(w,98,248,98,309,79,309,79,248,
+ 'fill'=>'', 'tags'=>['floor1','room'])
+ $floorLabels[i.id] = '117B'
+ $floorItems['117B'] = i
+ TkcText.new(w,88.5,278.5, 'text'=>'117B', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor1','label'])
+ i = TkcPolygon.new(w,51,251,51,204,6,204,6,251,
+ 'fill'=>'', 'tags'=>['floor1','room'])
+ $floorLabels[i.id] = '112'
+ $floorItems['112'] = i
+ TkcText.new(w,28.5,227.5, 'text'=>'112', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor1','label'])
+ i = TkcPolygon.new(w,6,156,51,156,51,203,6,203,
+ 'fill'=>'', 'tags'=>['floor1','room'])
+ $floorLabels[i.id] = '113'
+ $floorItems['113'] = i
+ TkcText.new(w,28.5,179.5, 'text'=>'113', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor1','label'])
+ i = TkcPolygon.new(w,85,169,79,169,79,192,85,192,
+ 'fill'=>'', 'tags'=>['floor1','room'])
+ $floorLabels[i.id] = '117A'
+ $floorItems['117A'] = i
+ TkcText.new(w,82,180.5, 'text'=>'117A', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor1','label'])
+ i = TkcPolygon.new(w,77,302,77,168,53,168,53,302,
+ 'fill'=>'', 'tags'=>['floor1','room'])
+ $floorLabels[i.id] = '117'
+ $floorItems['117'] = i
+ TkcText.new(w,65,235, 'text'=>'117', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor1','label'])
+ i = TkcPolygon.new(w,51,155,51,115,6,115,6,155,
+ 'fill'=>'', 'tags'=>['floor1','room'])
+ $floorLabels[i.id] = '114'
+ $floorItems['114'] = i
+ TkcText.new(w,28.5,135, 'text'=>'114', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor1','label'])
+ i = TkcPolygon.new(w,95,115,53,115,53,168,95,168,
+ 'fill'=>'', 'tags'=>['floor1','room'])
+ $floorLabels[i.id] = '115'
+ $floorItems['115'] = i
+ TkcText.new(w,74,141.5, 'text'=>'115', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor1','label'])
+ i = TkcPolygon.new(w,87,113,87,27,10,27,10,113,
+ 'fill'=>'', 'tags'=>['floor1','room'])
+ $floorLabels[i.id] = '116'
+ $floorItems['116'] = i
+ TkcText.new(w,48.5,70, 'text'=>'116', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor1','label'])
+ i = TkcPolygon.new(w,89,91,128,91,128,113,89,131,
+ 'fill'=>'', 'tags'=>['floor1','room'])
+ $floorLabels[i.id] = '118'
+ $floorItems['118'] = i
+ TkcText.new(w,108.5,102, 'text'=>'118', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor1','label'])
+ i = TkcPolygon.new(w,178,128,178,132,216,132,216,91,
+ 163,91,163,112,149,112,149,128,
+ 'fill'=>'', 'tags'=>['floor1','room'])
+ $floorLabels[i.id] = '120'
+ $floorItems['120'] = i
+ TkcText.new(w,189.5,111.5, 'text'=>'120', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor1','label'])
+ i = TkcPolygon.new(w,79,193,87,193,87,169,136,169,136,192,
+ 156,192,156,169,175,169,175,246,79,246,
+ 'fill'=>'', 'tags'=>['floor1','room'])
+ $floorLabels[i.id] = '122'
+ $floorItems['122'] = i
+ TkcText.new(w,131,207.5, 'text'=>'122', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor1','label'])
+ i = TkcPolygon.new(w,138,169,154,169,154,191,138,191,
+ 'fill'=>'', 'tags'=>['floor1','room'])
+ $floorLabels[i.id] = '121'
+ $floorItems['121'] = i
+ TkcText.new(w,146,180, 'text'=>'121', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor1','label'])
+ i = TkcPolygon.new(w,99,300,126,300,126,309,99,309,
+ 'fill'=>'', 'tags'=>['floor1','room'])
+ $floorLabels[i.id] = '106A'
+ $floorItems['106A'] = i
+ TkcText.new(w,112.5,304.5, 'text'=>'106A', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor1','label'])
+ i = TkcPolygon.new(w,128,299,128,309,150,309,150,248,99,248,99,299,
+ 'fill'=>'', 'tags'=>['floor1','room'])
+ $floorLabels[i.id] = '105'
+ $floorItems['105'] = i
+ TkcText.new(w,124.5,278.5, 'text'=>'105', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor1','label'])
+ i = TkcPolygon.new(w,174,309,174,300,152,300,152,309,
+ 'fill'=>'', 'tags'=>['floor1','room'])
+ $floorLabels[i.id] = '106B'
+ $floorItems['106B'] = i
+ TkcText.new(w,163,304.5, 'text'=>'106B', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor1','label'])
+ i = TkcPolygon.new(w,176,299,176,309,216,309,216,248,152,248,152,299,
+ 'fill'=>'', 'tags'=>['floor1','room'])
+ $floorLabels[i.id] = '104'
+ $floorItems['104'] = i
+ TkcText.new(w,184,278.5, 'text'=>'104', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor1','label'])
+ i = TkcPolygon.new(w,138,385,138,337,91,337,91,385,
+ 'fill'=>'', 'tags'=>['floor1','room'])
+ $floorLabels[i.id] = '108'
+ $floorItems['108'] = i
+ TkcText.new(w,114.5,361, 'text'=>'108', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor1','label'])
+ i = TkcPolygon.new(w,256,337,140,337,140,385,256,385,
+ 'fill'=>'', 'tags'=>['floor1','room'])
+ $floorLabels[i.id] = '107'
+ $floorItems['107'] = i
+ TkcText.new(w,198,361, 'text'=>'107', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor1','label'])
+ i = TkcPolygon.new(w,300,353,300,329,260,329,260,353,
+ 'fill'=>'', 'tags'=>['floor1','room'])
+ $floorLabels[i.id] = 'Smoking'
+ $floorItems['Smoking'] = i
+ TkcText.new(w,280,341, 'text'=>'Smoking', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor1','label'])
+ i = TkcPolygon.new(w,314,135,314,170,306,170,306,246,177,246,177,135,
+ 'fill'=>'', 'tags'=>['floor1','room'])
+ $floorLabels[i.id] = '123'
+ $floorItems['123'] = i
+ TkcText.new(w,245.5,190.5, 'text'=>'123', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor1','label'])
+ i = TkcPolygon.new(w,217,248,301,248,301,326,257,326,257,310,217,310,
+ 'fill'=>'', 'tags'=>['floor1','room'])
+ $floorLabels[i.id] = '103'
+ $floorItems['103'] = i
+ TkcText.new(w,259,287, 'text'=>'103', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor1','label'])
+ i = TkcPolygon.new(w,396,188,377,188,377,169,316,169,316,131,396,131,
+ 'fill'=>'', 'tags'=>['floor1','room'])
+ $floorLabels[i.id] = '124'
+ $floorItems['124'] = i
+ TkcText.new(w,356,150, 'text'=>'124', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor1','label'])
+ i = TkcPolygon.new(w,397,226,407,226,407,189,377,189,377,246,397,246,
+ 'fill'=>'', 'tags'=>['floor1','room'])
+ $floorLabels[i.id] = '125'
+ $floorItems['125'] = i
+ TkcText.new(w,392,217.5, 'text'=>'125', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor1','label'])
+ i = TkcPolygon.new(w,399,187,409,187,409,207,474,207,474,164,399,164,
+ 'fill'=>'', 'tags'=>['floor1','room'])
+ $floorLabels[i.id] = '126'
+ $floorItems['126'] = i
+ TkcText.new(w,436.5,185.5, 'text'=>'126', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor1','label'])
+ i = TkcPolygon.new(w,409,209,409,229,399,229,399,253,
+ 486,253,486,239,474,239,474,209,
+ 'fill'=>'', 'tags'=>['floor1','room'])
+ $floorLabels[i.id] = '127'
+ $floorItems['127'] = i
+ TkcText.new(w,436.5,'231', 'text'=>'127', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor1','label'])
+ i = TkcPolygon.new(w,501,164,501,174,495,174,495,188,
+ 490,188,490,204,476,204,476,164,
+ 'fill'=>'', 'tags'=>['floor1','room'])
+ $floorLabels[i.id] = 'MShower'
+ $floorItems['MShower'] = i
+ TkcText.new(w,488.5,'184', 'text'=>'MShower', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor1','label'])
+ i = TkcPolygon.new(w,497,176,513,176,513,204,492,204,492,190,497,190,
+ 'fill'=>'', 'tags'=>['floor1','room'])
+ $floorLabels[i.id] = 'Closet'
+ $floorItems['Closet'] = i
+ TkcText.new(w,502.5,190, 'text'=>'Closet', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor1','label'])
+ i = TkcPolygon.new(w,476,237,476,206,513,206,513,254,488,254,488,237,
+ 'fill'=>'', 'tags'=>['floor1','room'])
+ $floorLabels[i.id] = 'WShower'
+ $floorItems['WShower'] = i
+ TkcText.new(w,494.5,230, 'text'=>'WShower', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor1','label'])
+ i = TkcPolygon.new(w,486,131,558,131,558,135,724,135,724,166,
+ 697,166,697,275,553,275,531,254,515,254,
+ 515,174,503,174,503,161,486,161,
+ 'fill'=>'', 'tags'=>['floor1','room'])
+ $floorLabels[i.id] = '130'
+ $floorItems['130'] = i
+ TkcText.new(w,638.5,205, 'text'=>'130', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor1','label'])
+ i = TkcPolygon.new(w,308,242,339,242,339,248,342,248,
+ 342,246,397,246,397,276,393,276,
+ 393,309,300,309,300,248,308,248,
+ 'fill'=>'', 'tags'=>['floor1','room'])
+ $floorLabels[i.id] = '102'
+ $floorItems['102'] = i
+ TkcText.new(w,367.5,278.5, 'text'=>'102', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor1','label'])
+ i = TkcPolygon.new(w,397,255,486,255,486,276,397,276,
+ 'fill'=>'', 'tags'=>['floor1','room'])
+ $floorLabels[i.id] = '128'
+ $floorItems['128'] = i
+ TkcText.new(w,441.5,265.5, 'text'=>'128', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor1','label'])
+ i = TkcPolygon.new(w,510,309,486,309,486,255,530,255,
+ 552,277,561,277,561,325,510,325,
+ 'fill'=>'', 'tags'=>['floor1','room'])
+ $floorLabels[i.id] = '129'
+ $floorItems['129'] = i
+ TkcText.new(w,535.5,293, 'text'=>'129', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor1','label'])
+ i = TkcPolygon.new(w,696,281,740,281,740,387,642,387,
+ 642,389,561,389,561,277,696,277,
+ 'fill'=>'', 'tags'=>['floor1','room'])
+ $floorLabels[i.id] = '133'
+ $floorItems['133'] = i
+ TkcText.new(w,628.5,335, 'text'=>'133', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor1','label'])
+ i = TkcPolygon.new(w,742,387,742,281,800,281,800,387,
+ 'fill'=>'', 'tags'=>['floor1','room'])
+ $floorLabels[i.id] = '132'
+ $floorItems['132'] = i
+ TkcText.new(w,771,334, 'text'=>'132', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor1','label'])
+ i = TkcPolygon.new(w,800,168,800,280,699,280,699,168,
+ 'fill'=>'', 'tags'=>['floor1','room'])
+ $floorLabels[i.id] = '134'
+ $floorItems['134'] = i
+ TkcText.new(w,749.5,224, 'text'=>'134', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor1','label'])
+ i = TkcPolygon.new(w,726,131,726,166,800,166,800,131,
+ 'fill'=>'', 'tags'=>['floor1','room'])
+ $floorLabels[i.id] = '135'
+ $floorItems['135'] = i
+ TkcText.new(w,763,148.5, 'text'=>'135', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor1','label'])
+ i = TkcPolygon.new(w,340,360,335,363,331,365,326,366,304,366,
+ 304,312,396,312,396,288,400,288,404,288,
+ 409,290,413,292,418,297,421,302,422,309,
+ 421,318,417,325,411,330,405,332,397,333,
+ 344,333,340,334,336,336,335,338,332,342,
+ 331,347,332,351,334,354,336,357,341,359,
+ 'fill'=>'', 'tags'=>['floor1','room'])
+ $floorLabels[i.id] = 'Ramona Stair'
+ $floorItems['Ramona Stair'] = i
+ TkcText.new(w,368,323, 'text'=>'Ramona Stair', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor1','label'])
+ i = TkcPolygon.new(w,30,23,30,5,93,5,98,5,104,7,110,10,116,16,119,20,
+ 122,28,123,32,123,68,220,68,220,87,90,87,90,23,
+ 'fill'=>'', 'tags'=>['floor1','room'])
+ $floorLabels[i.id] = 'University Stair'
+ $floorItems['University Stair'] = i
+ TkcText.new(w,155,77.5, 'text'=>'University Stair', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor1','label'])
+ i = TkcPolygon.new(w,282,37,295,40,312,49,323,56,337,70,352,56,
+ 358,48,363,39,365,29,348,25,335,22,321,14,
+ 300,5,283,1,260,0,246,0,242,2,236,4,231,8,
+ 227,13,223,17,221,22,220,34,260,34,
+ 'fill'=>'', 'tags'=>['floor1','room'])
+ $floorLabels[i.id] = 'Plaza Stair'
+ $floorItems['Plaza Stair'] = i
+ TkcText.new(w,317.5,28.5, 'text'=>'Plaza Stair', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor1','label'])
+ i = TkcPolygon.new(w,220,34,260,34,282,37,295,40,312,49,
+ 323,56,337,70,350,83,365,94,377,100,
+ 386,104,386,128,220,128,
+ 'fill'=>'', 'tags'=>['floor1','room'])
+ $floorLabels[i.id] = 'Plaza Deck'
+ $floorItems['Plaza Deck'] = i
+ TkcText.new(w,303,81, 'text'=>'Plaza Deck', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor1','label'])
+ i = TkcPolygon.new(w,257,336,77,336,6,336,6,301,77,301,77,310,257,310,
+ 'fill'=>'', 'tags'=>['floor1','room'])
+ $floorLabels[i.id] = '106'
+ $floorItems['106'] = i
+ TkcText.new(w,131.5,318.5, 'text'=>'106', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor1','label'])
+ i = TkcPolygon.new(w,146,110,162,110,162,91,130,91,130,115,95,115,
+ 95,128,114,128,114,151,157,151,157,153,112,153,
+ 112,130,97,130,97,168,175,168,175,131,146,131,
+ 'fill'=>'', 'tags'=>['floor1','room'])
+ $floorLabels[i.id] = '119'
+ $floorItems['119'] = i
+ TkcText.new(w,143.5,133, 'text'=>'119', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor1','label'])
+ TkcLine.new(w,155,191,155,189, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,155,177,155,169, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,96,129,96,169, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,78,169,176,169, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,176,247,176,129, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,340,206,307,206, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,340,187,340,170, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,340,210,340,201, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,340,247,340,224, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,340,241,307,241, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,376,246,376,170, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,307,247,307,170, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,376,170,307,170, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,315,129,315,170, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,147,129,176,129, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,202,133,176,133, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,398,129,315,129, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,258,352,258,387, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,60,387,60,391, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,0,337,0,391, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,60,391,0,391, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,3,114,3,337, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,258,387,60,387, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,52,237,52,273, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,52,189,52,225, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,52,140,52,177, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,395,306,395,311, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,531,254,398,254, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,475,178,475,238, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,502,162,398,162, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,398,129,398,188, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,383,188,376,188, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,408,188,408,194, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,398,227,398,254, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,408,227,398,227, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,408,222,408,227, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,408,206,408,210, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,408,208,475,208, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,484,278,484,311, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,484,311,508,311, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,508,327,508,311, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,559,327,508,327, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,644,391,559,391, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,644,389,644,391, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,514,205,475,205, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,496,189,496,187, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,559,129,484,129, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,484,162,484,129, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,725,133,559,133, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,559,129,559,133, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,725,149,725,167, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,725,129,802,129, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,802,389,802,129, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,739,167,802,167, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,396,188,408,188, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,0,337,9,337, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,58,337,21,337, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,43,391,43,337, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,105,337,75,337, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,91,387,91,337, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,154,337,117,337, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,139,387,139,337, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,227,337,166,337, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,258,337,251,337, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,258,328,302,328, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,302,355,302,311, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,395,311,302,311, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,484,278,395,278, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,395,294,395,278, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,473,278,473,275, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,473,256,473,254, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,533,257,531,254, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,553,276,551,274, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,698,276,553,276, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,559,391,559,327, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,802,389,644,389, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,741,314,741,389, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,698,280,698,167, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,707,280,698,280, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,802,280,731,280, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,741,280,741,302, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,698,167,727,167, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,725,137,725,129, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,514,254,514,175, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,496,175,514,175, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,502,175,502,162, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,475,166,475,162, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,496,176,496,175, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,491,189,496,189, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,491,205,491,189, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,487,238,475,238, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,487,240,487,238, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,487,252,487,254, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,315,133,304,133, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,256,133,280,133, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,78,247,270,247, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,307,247,294,247, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,214,133,232,133, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,217,247,217,266, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,217,309,217,291, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,217,309,172,309, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,154,309,148,309, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,175,300,175,309, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,151,300,175,300, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,151,247,151,309, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,78,237,78,265, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,78,286,78,309, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,106,309,78,309, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,130,309,125,309, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,99,309,99,247, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,127,299,99,299, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,127,309,127,299, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,155,191,137,191, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,137,169,137,191, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,78,171,78,169, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,78,190,78,218, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,86,192,86,169, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,86,192,78,192, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,52,301,3,301, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,52,286,52,301, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,52,252,3,252, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,52,203,3,203, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,3,156,52,156, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,8,25,8,114, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,63,114,3,114, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,75,114,97,114, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,108,114,129,114, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,129,114,129,89, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,52,114,52,128, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,132,89,88,89, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,88,25,88,89, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,88,114,88,89, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,218,89,144,89, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,147,111,147,129, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,162,111,147,111, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,162,109,162,111, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,162,96,162,89, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,218,89,218,94, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,218,89,218,119, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,8,25,88,25, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,258,337,258,328, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,113,129,96,129, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,302,355,258,355, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,386,104,386,129, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,377,100,386,104, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,365,94,377,100, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,350,83,365,94, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,337,70,350,83, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,337,70,323,56, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,312,49,323,56, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,295,40,312,49, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,282,37,295,40, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,260,34,282,37, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,253,34,260,34, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,386,128,386,104, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,113,152,156,152, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,113,152,156,152, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,113,152,113,129, 'fill'=>color, 'tags'=>['floor1','wall'])
+end
+
+# floor_fg2 --
+# This method represents part of the floorplan database. When
+# invoked, it instantiates the foreground information for the second
+# floor (office outlines and numbers).
+#
+# Arguments:
+# w - The canvas window.
+# color - Color to use for drawing foreground information.
+
+def floor_fg2(w,color)
+ i = TkcPolygon.new(w,748,188,755,188,755,205,758,205,758,222,
+ 800,222,800,168,748,168,
+ 'fill'=>'', 'tags'=>['floor2','room'])
+ $floorLabels[i.id] = '238'
+ $floorItems['238'] = i
+ TkcText.new(w,774,195, 'text'=>'238', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor2','label'])
+ i = TkcPolygon.new(w,726,188,746,188,746,166,800,166,800,131,726,131,
+ 'fill'=>'', 'tags'=>['floor2','room'])
+ $floorLabels[i.id] = '237'
+ $floorItems['237'] = i
+ TkcText.new(w,763,148.5, 'text'=>'237', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor2','label'])
+ i = TkcPolygon.new(w,497,187,497,204,559,204,559,324,641,324,
+ 643,324,643,291,641,291,641,205,696,205,
+ 696,291,694,291,694,314,715,314,715,291,
+ 715,205,755,205,755,190,724,190,724,187,
+ 'fill'=>'', 'tags'=>['floor2','room'])
+ $floorLabels[i.id] = '246'
+ $floorItems['246'] = i
+ TkcText.new(w,600,264, 'text'=>'246', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor2','label'])
+ i = TkcPolygon.new(w,694,279,643,279,643,314,694,314,
+ 'fill'=>'', 'tags'=>['floor2','room'])
+ $floorLabels[i.id] = '247'
+ $floorItems['247'] = i
+ TkcText.new(w,668.5,296.5, 'text'=>'247', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor2','label'])
+ i = TkcPolygon.new(w,232,250,308,250,308,242,339,242,339,246,
+ 397,246,397,255,476,255,476,250,482,250,559,250,
+ 559,274,482,274,482,278,396,278,396,274,232,274,
+ 'fill'=>'', 'tags'=>['floor2','room'])
+ $floorLabels[i.id] = '202'
+ $floorItems['202'] = i
+ TkcText.new(w,285.5,260, 'text'=>'202', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor2','label'])
+ i = TkcPolygon.new(w,53,228,53,338,176,338,233,338,233,196,
+ 306,196,306,180,175,180,175,169,156,169,
+ 156,196,176,196,176,228,
+ 'fill'=>'', 'tags'=>['floor2','room'])
+ $floorLabels[i.id] = '206'
+ $floorItems['206'] = i
+ TkcText.new(w,143,267, 'text'=>'206', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor2','label'])
+ i = TkcPolygon.new(w,51,277,6,277,6,338,51,338,
+ 'fill'=>'', 'tags'=>['floor2','room'])
+ $floorLabels[i.id] = '212'
+ $floorItems['212'] = i
+ TkcText.new(w,28.5,307.5, 'text'=>'212', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor2','label'])
+ i = TkcPolygon.new(w,557,276,486,276,486,309,510,309,510,325,557,325,
+ 'fill'=>'', 'tags'=>['floor2','room'])
+ $floorLabels[i.id] = '245'
+ $floorItems['245'] = i
+ TkcText.new(w,521.5,300.5, 'text'=>'245', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor2','label'])
+ i = TkcPolygon.new(w,560,389,599,389,599,326,560,326,
+ 'fill'=>'', 'tags'=>['floor2','room'])
+ $floorLabels[i.id] = '244'
+ $floorItems['244'] = i
+ TkcText.new(w,579.5,357.5, 'text'=>'244', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor2','label'])
+ i = TkcPolygon.new(w,601,389,601,326,643,326,643,389,
+ 'fill'=>'', 'tags'=>['floor2','room'])
+ $floorLabels[i.id] = '243'
+ $floorItems['243'] = i
+ TkcText.new(w,622,357.5, 'text'=>'243', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor2','label'])
+ i = TkcPolygon.new(w,688,316,645,316,645,365,688,365,
+ 'fill'=>'', 'tags'=>['floor2','room'])
+ $floorLabels[i.id] = '242'
+ $floorItems['242'] = i
+ TkcText.new(w,666.5,340.5, 'text'=>'242', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor2','label'])
+ i = TkcPolygon.new(w,802,367,759,367,759,226,802,226,
+ 'fill'=>'', 'tags'=>['floor2','room'])
+ $floorLabels[i.id] = 'Barbecue Deck'
+ $floorItems['Barbecue Deck'] = i
+ TkcText.new(w,780.5,296.5, 'text'=>'Barbecue Deck', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor2','label'])
+ i = TkcPolygon.new(w,755,262,755,314,717,314,717,262,
+ 'fill'=>'', 'tags'=>['floor2','room'])
+ $floorLabels[i.id] = '240'
+ $floorItems['240'] = i
+ TkcText.new(w,736,288, 'text'=>'240', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor2','label'])
+ i = TkcPolygon.new(w,755,316,689,316,689,365,755,365,
+ 'fill'=>'', 'tags'=>['floor2','room'])
+ $floorLabels[i.id] = '241'
+ $floorItems['241'] = i
+ TkcText.new(w,722,340.5, 'text'=>'241', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor2','label'])
+ i = TkcPolygon.new(w,755,206,717,206,717,261,755,261,
+ 'fill'=>'', 'tags'=>['floor2','room'])
+ $floorLabels[i.id] = '239'
+ $floorItems['239'] = i
+ TkcText.new(w,736,233.5, 'text'=>'239', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor2','label'])
+ i = TkcPolygon.new(w,695,277,643,277,643,206,695,206,
+ 'fill'=>'', 'tags'=>['floor2','room'])
+ $floorLabels[i.id] = '248'
+ $floorItems['248'] = i
+ TkcText.new(w,669,241.5, 'text'=>'248', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor2','label'])
+ i = TkcPolygon.new(w,676,135,676,185,724,185,724,135,
+ 'fill'=>'', 'tags'=>['floor2','room'])
+ $floorLabels[i.id] = '236'
+ $floorItems['236'] = i
+ TkcText.new(w,700,160, 'text'=>'236', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor2','label'])
+ i = TkcPolygon.new(w,675,135,635,135,635,145,628,145,628,185,675,185,
+ 'fill'=>'', 'tags'=>['floor2','room'])
+ $floorLabels[i.id] = '235'
+ $floorItems['235'] = i
+ TkcText.new(w,651.5,160, 'text'=>'235', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor2','label'])
+ i = TkcPolygon.new(w,626,143,633,143,633,135,572,135,
+ 572,143,579,143,579,185,626,185,
+ 'fill'=>'', 'tags'=>['floor2','room'])
+ $floorLabels[i.id] = '234'
+ $floorItems['234'] = i
+ TkcText.new(w,606,160, 'text'=>'234', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor2','label'])
+ i = TkcPolygon.new(w,557,135,571,135,571,145,578,145,
+ 578,185,527,185,527,131,557,131,
+ 'fill'=>'', 'tags'=>['floor2','room'])
+ $floorLabels[i.id] = '233'
+ $floorItems['233'] = i
+ TkcText.new(w,552.5,158, 'text'=>'233', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor2','label'])
+ i = TkcPolygon.new(w,476,249,557,249,557,205,476,205,
+ 'fill'=>'', 'tags'=>['floor2','room'])
+ $floorLabels[i.id] = '230'
+ $floorItems['230'] = i
+ TkcText.new(w,516.5,227, 'text'=>'230', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor2','label'])
+ i = TkcPolygon.new(w,476,164,486,164,486,131,525,131,525,185,476,185,
+ 'fill'=>'', 'tags'=>['floor2','room'])
+ $floorLabels[i.id] = '232'
+ $floorItems['232'] = i
+ TkcText.new(w,500.5,158, 'text'=>'232', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor2','label'])
+ i = TkcPolygon.new(w,476,186,495,186,495,204,476,204,
+ 'fill'=>'', 'tags'=>['floor2','room'])
+ $floorLabels[i.id] = '229'
+ $floorItems['229'] = i
+ TkcText.new(w,485.5,195, 'text'=>'229', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor2','label'])
+ i = TkcPolygon.new(w,474,207,409,207,409,187,399,187,399,164,474,164,
+ 'fill'=>'', 'tags'=>['floor2','room'])
+ $floorLabels[i.id] = '227'
+ $floorItems['227'] = i
+ TkcText.new(w,436.5,185.5, 'text'=>'227', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor2','label'])
+ i = TkcPolygon.new(w,399,228,399,253,474,253,474,209,409,209,409,228,
+ 'fill'=>'', 'tags'=>['floor2','room'])
+ $floorLabels[i.id] = '228'
+ $floorItems['228'] = i
+ TkcText.new(w,436.5,231, 'text'=>'228', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor2','label'])
+ i = TkcPolygon.new(w,397,246,397,226,407,226,407,189,377,189,377,246,
+ 'fill'=>'', 'tags'=>['floor2','room'])
+ $floorLabels[i.id] = '226'
+ $floorItems['226'] = i
+ TkcText.new(w,392,217.5, 'text'=>'226', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor2','label'])
+ i = TkcPolygon.new(w,377,169,316,169,316,131,397,131,397,188,377,188,
+ 'fill'=>'', 'tags'=>['floor2','room'])
+ $floorLabels[i.id] = '225'
+ $floorItems['225'] = i
+ TkcText.new(w,356.5,150, 'text'=>'225', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor2','label'])
+ i = TkcPolygon.new(w,234,198,306,198,306,249,234,249,
+ 'fill'=>'', 'tags'=>['floor2','room'])
+ $floorLabels[i.id] = '224'
+ $floorItems['224'] = i
+ TkcText.new(w,270,223.5, 'text'=>'224', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor2','label'])
+ i = TkcPolygon.new(w,270,179,306,179,306,170,314,170,314,135,270,135,
+ 'fill'=>'', 'tags'=>['floor2','room'])
+ $floorLabels[i.id] = '223'
+ $floorItems['223'] = i
+ TkcText.new(w,292,157, 'text'=>'223', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor2','label'])
+ i = TkcPolygon.new(w,268,179,221,179,221,135,268,135,
+ 'fill'=>'', 'tags'=>['floor2','room'])
+ $floorLabels[i.id] = '222'
+ $floorItems['222'] = i
+ TkcText.new(w,244.5,157, 'text'=>'222', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor2','label'])
+ i = TkcPolygon.new(w,177,179,219,179,219,135,177,135,
+ 'fill'=>'', 'tags'=>['floor2','room'])
+ $floorLabels[i.id] = '221'
+ $floorItems['221'] = i
+ TkcText.new(w,198,157, 'text'=>'221', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor2','label'])
+ i = TkcPolygon.new(w,299,327,349,327,349,284,341,284,341,276,299,276,
+ 'fill'=>'', 'tags'=>['floor2','room'])
+ $floorLabels[i.id] = '204'
+ $floorItems['204'] = i
+ TkcText.new(w,324,301.5, 'text'=>'204', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor2','label'])
+ i = TkcPolygon.new(w,234,276,297,276,297,327,257,327,257,338,234,338,
+ 'fill'=>'', 'tags'=>['floor2','room'])
+ $floorLabels[i.id] = '205'
+ $floorItems['205'] = i
+ TkcText.new(w,265.5,307, 'text'=>'205', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor2','label'])
+ i = TkcPolygon.new(w,256,385,256,340,212,340,212,385,
+ 'fill'=>'', 'tags'=>['floor2','room'])
+ $floorLabels[i.id] = '207'
+ $floorItems['207'] = i
+ TkcText.new(w,234,362.5, 'text'=>'207', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor2','label'])
+ i = TkcPolygon.new(w,210,340,164,340,164,385,210,385,
+ 'fill'=>'', 'tags'=>['floor2','room'])
+ $floorLabels[i.id] = '208'
+ $floorItems['208'] = i
+ TkcText.new(w,187,362.5, 'text'=>'208', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor2','label'])
+ i = TkcPolygon.new(w,115,340,162,340,162,385,115,385,
+ 'fill'=>'', 'tags'=>['floor2','room'])
+ $floorLabels[i.id] = '209'
+ $floorItems['209'] = i
+ TkcText.new(w,138.5,362.5, 'text'=>'209', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor2','label'])
+ i = TkcPolygon.new(w,89,228,89,156,53,156,53,228,
+ 'fill'=>'', 'tags'=>['floor2','room'])
+ $floorLabels[i.id] = '217'
+ $floorItems['217'] = i
+ TkcText.new(w,71,192, 'text'=>'217', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor2','label'])
+ i = TkcPolygon.new(w,89,169,97,169,97,190,89,190,
+ 'fill'=>'', 'tags'=>['floor2','room'])
+ $floorLabels[i.id] = '217A'
+ $floorItems['217A'] = i
+ TkcText.new(w,93,179.5, 'text'=>'217A', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor2','label'])
+ i = TkcPolygon.new(w,89,156,89,168,95,168,95,135,53,135,53,156,
+ 'fill'=>'', 'tags'=>['floor2','room'])
+ $floorLabels[i.id] = '216'
+ $floorItems['216'] = i
+ TkcText.new(w,71,145.5, 'text'=>'216', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor2','label'])
+ i = TkcPolygon.new(w,51,179,51,135,6,135,6,179,
+ 'fill'=>'', 'tags'=>['floor2','room'])
+ $floorLabels[i.id] = '215'
+ $floorItems['215'] = i
+ TkcText.new(w,28.5,157, 'text'=>'215', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor2','label'])
+ i = TkcPolygon.new(w,51,227,6,227,6,180,51,180,
+ 'fill'=>'', 'tags'=>['floor2','room'])
+ $floorLabels[i.id] = '214'
+ $floorItems['214'] = i
+ TkcText.new(w,28.5,203.5, 'text'=>'214', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor2','label'])
+ i = TkcPolygon.new(w,51,275,6,275,6,229,51,229,
+ 'fill'=>'', 'tags'=>['floor2','room'])
+ $floorLabels[i.id] = '213'
+ $floorItems['213'] = i
+ TkcText.new(w,28.5,252, 'text'=>'213', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor2','label'])
+ i = TkcPolygon.new(w,114,340,67,340,67,385,114,385,
+ 'fill'=>'', 'tags'=>['floor2','room'])
+ $floorLabels[i.id] = '210'
+ $floorItems['210'] = i
+ TkcText.new(w,90.5,362.5, 'text'=>'210', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor2','label'])
+ i = TkcPolygon.new(w,59,389,59,385,65,385,65,340,1,340,1,389,
+ 'fill'=>'', 'tags'=>['floor2','room'])
+ $floorLabels[i.id] = '211'
+ $floorItems['211'] = i
+ TkcText.new(w,33,364.5, 'text'=>'211', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor2','label'])
+ i = TkcPolygon.new(w,393,309,350,309,350,282,342,282,342,276,393,276,
+ 'fill'=>'', 'tags'=>['floor2','room'])
+ $floorLabels[i.id] = '203'
+ $floorItems['203'] = i
+ TkcText.new(w,367.5,292.5, 'text'=>'203', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor2','label'])
+ i = TkcPolygon.new(w,99,191,91,191,91,226,174,226,174,198,
+ 154,198,154,192,109,192,109,169,99,169,
+ 'fill'=>'', 'tags'=>['floor2','room'])
+ $floorLabels[i.id] = '220'
+ $floorItems['220'] = i
+ TkcText.new(w,132.5,208.5, 'text'=>'220', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor2','label'])
+ i = TkcPolygon.new(w,339,205,307,205,307,171,339,171,
+ 'fill'=>'', 'tags'=>['floor2','room'])
+ $floorLabels[i.id] = 'Priv Lift2'
+ $floorItems['Priv Lift2'] = i
+ TkcText.new(w,323,188, 'text'=>'Priv Lift2', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor2','label'])
+ i = TkcPolygon.new(w,307,240,339,240,339,206,307,206,
+ 'fill'=>'', 'tags'=>['floor2','room'])
+ $floorLabels[i.id] = 'Pub Lift 2'
+ $floorItems['Pub Lift 2'] = i
+ TkcText.new(w,323,223, 'text'=>'Pub Lift 2', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor2','label'])
+ i = TkcPolygon.new(w,175,168,97,168,97,131,175,131,
+ 'fill'=>'', 'tags'=>['floor2','room'])
+ $floorLabels[i.id] = '218'
+ $floorItems['218'] = i
+ TkcText.new(w,136,149.5, 'text'=>'218', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor2','label'])
+ i = TkcPolygon.new(w,154,191,111,191,111,169,154,169,
+ 'fill'=>'', 'tags'=>['floor2','room'])
+ $floorLabels[i.id] = '219'
+ $floorItems['219'] = i
+ TkcText.new(w,132.5,180, 'text'=>'219', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor2','label'])
+ i = TkcPolygon.new(w,375,246,375,172,341,172,341,246,
+ 'fill'=>'', 'tags'=>['floor2','room'])
+ $floorLabels[i.id] = '201'
+ $floorItems['201'] = i
+ TkcText.new(w,358,209, 'text'=>'201', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor2','label'])
+ TkcLine.new(w,641,186,678,186, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,757,350,757,367, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,634,133,634,144, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,634,144,627,144, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,572,133,572,144, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,572,144,579,144, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,398,129,398,162, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,174,197,175,197, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,175,197,175,227, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,757,206,757,221, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,396,188,408,188, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,727,189,725,189, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,747,167,802,167, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,747,167,747,189, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,755,189,739,189, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,769,224,757,224, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,802,224,802,129, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,802,129,725,129, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,725,189,725,129, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,725,186,690,186, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,676,133,676,186, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,627,144,627,186, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,629,186,593,186, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,579,144,579,186, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,559,129,559,133, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,725,133,559,133, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,484,162,484,129, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,559,129,484,129, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,526,129,526,186, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,540,186,581,186, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,528,186,523,186, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,511,186,475,186, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,496,190,496,186, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,496,205,496,202, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,475,205,527,205, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,558,205,539,205, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,558,205,558,249, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,558,249,475,249, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,662,206,642,206, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,695,206,675,206, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,695,278,642,278, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,642,291,642,206, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,695,291,695,206, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,716,208,716,206, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,757,206,716,206, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,757,221,757,224, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,793,224,802,224, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,757,262,716,262, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,716,220,716,264, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,716,315,716,276, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,757,315,703,315, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,757,325,757,224, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,757,367,644,367, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,689,367,689,315, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,647,315,644,315, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,659,315,691,315, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,600,325,600,391, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,627,325,644,325, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,644,391,644,315, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,615,325,575,325, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,644,391,558,391, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,563,325,558,325, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,558,391,558,314, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,558,327,508,327, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,558,275,484,275, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,558,302,558,275, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,508,327,508,311, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,484,311,508,311, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,484,275,484,311, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,475,208,408,208, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,408,206,408,210, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,408,222,408,227, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,408,227,398,227, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,398,227,398,254, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,408,188,408,194, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,383,188,376,188, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,398,188,398,162, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,398,162,484,162, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,475,162,475,254, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,398,254,475,254, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,484,280,395,280, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,395,311,395,275, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,307,197,293,197, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,278,197,233,197, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,233,197,233,249, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,307,179,284,179, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,233,249,278,249, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,269,179,269,133, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,220,179,220,133, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,155,191,110,191, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,90,190,98,190, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,98,169,98,190, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,52,133,52,165, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,52,214,52,177, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,52,226,52,262, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,52,274,52,276, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,234,275,234,339, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,226,339,258,339, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,211,387,211,339, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,214,339,177,339, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,258,387,60,387, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,3,133,3,339, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,165,339,129,339, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,117,339,80,339, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,68,339,59,339, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,0,339,46,339, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,60,391,0,391, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,0,339,0,391, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,60,387,60,391, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,258,329,258,387, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,350,329,258,329, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,395,311,350,311, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,398,129,315,129, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,176,133,315,133, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,176,129,96,129, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,3,133,96,133, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,66,387,66,339, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,115,387,115,339, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,163,387,163,339, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,234,275,276,275, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,288,275,309,275, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,298,275,298,329, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,341,283,350,283, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,321,275,341,275, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,375,275,395,275, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,315,129,315,170, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,376,170,307,170, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,307,250,307,170, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,376,245,376,170, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,340,241,307,241, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,340,245,340,224, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,340,210,340,201, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,340,187,340,170, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,340,206,307,206, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,293,250,307,250, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,271,179,238,179, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,226,179,195,179, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,176,129,176,179, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,182,179,176,179, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,174,169,176,169, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,162,169,90,169, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,96,169,96,129, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,175,227,90,227, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,90,190,90,227, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,52,179,3,179, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,52,228,3,228, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,52,276,3,276, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,155,177,155,169, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,110,191,110,169, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,155,189,155,197, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,350,283,350,329, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,162,197,155,197, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,341,275,341,283, 'fill'=>color, 'tags'=>['floor2','wall'])
+end
+
+# floor_fg3 --
+# This method represents part of the floorplan database. When
+# invoked, it instantiates the foreground information for the third
+# floor (office outlines and numbers).
+#
+# Arguments:
+# w - The canvas window.
+# color - Color to use for drawing foreground information.
+
+def floor_fg3(w,color)
+ i = TkcPolygon.new(w,89,228,89,180,70,180,70,228,
+ 'fill'=>'', 'tags'=>['floor3','room'])
+ $floorLabels[i.id] = '316'
+ $floorItems['316'] = i
+ TkcText.new(w,79.5,204, 'text'=>'316', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor3','label'])
+ i = TkcPolygon.new(w,115,368,162,368,162,323,115,323,
+ 'fill'=>'', 'tags'=>['floor3','room'])
+ $floorLabels[i.id] = '309'
+ $floorItems['309'] = i
+ TkcText.new(w,138.5,345.5, 'text'=>'309', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor3','label'])
+ i = TkcPolygon.new(w,164,323,164,368,211,368,211,323,
+ 'fill'=>'', 'tags'=>['floor3','room'])
+ $floorLabels[i.id] = '308'
+ $floorItems['308'] = i
+ TkcText.new(w,187.5,345.5, 'text'=>'308', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor3','label'])
+ i = TkcPolygon.new(w,256,368,212,368,212,323,256,323,
+ 'fill'=>'', 'tags'=>['floor3','room'])
+ $floorLabels[i.id] = '307'
+ $floorItems['307'] = i
+ TkcText.new(w,234,345.5, 'text'=>'307', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor3','label'])
+ i = TkcPolygon.new(w,244,276,297,276,297,327,260,327,260,321,244,321,
+ 'fill'=>'', 'tags'=>['floor3','room'])
+ $floorLabels[i.id] = '305'
+ $floorItems['305'] = i
+ TkcText.new(w,270.5,301.5, 'text'=>'305', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor3','label'])
+ i = TkcPolygon.new(w,251,219,251,203,244,203,244,219,
+ 'fill'=>'', 'tags'=>['floor3','room'])
+ $floorLabels[i.id] = '324B'
+ $floorItems['324B'] = i
+ TkcText.new(w,247.5,211, 'text'=>'324B', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor3','label'])
+ i = TkcPolygon.new(w,251,249,244,249,244,232,251,232,
+ 'fill'=>'', 'tags'=>['floor3','room'])
+ $floorLabels[i.id] = '324A'
+ $floorItems['324A'] = i
+ TkcText.new(w,247.5,240.5, 'text'=>'324A', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor3','label'])
+ i = TkcPolygon.new(w,223,135,223,179,177,179,177,135,
+ 'fill'=>'', 'tags'=>['floor3','room'])
+ $floorLabels[i.id] = '320'
+ $floorItems['320'] = i
+ TkcText.new(w,200,157, 'text'=>'320', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor3','label'])
+ i = TkcPolygon.new(w,114,368,114,323,67,323,67,368,
+ 'fill'=>'', 'tags'=>['floor3','room'])
+ $floorLabels[i.id] = '310'
+ $floorItems['310'] = i
+ TkcText.new(w,90.5,345.5, 'text'=>'310', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor3','label'])
+ i = TkcPolygon.new(w,23,277,23,321,68,321,68,277,
+ 'fill'=>'', 'tags'=>['floor3','room'])
+ $floorLabels[i.id] = '312'
+ $floorItems['312'] = i
+ TkcText.new(w,45.5,299, 'text'=>'312', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor3','label'])
+ i = TkcPolygon.new(w,23,229,68,229,68,275,23,275,
+ 'fill'=>'', 'tags'=>['floor3','room'])
+ $floorLabels[i.id] = '313'
+ $floorItems['313'] = i
+ TkcText.new(w,45.5,252, 'text'=>'313', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor3','label'])
+ i = TkcPolygon.new(w,68,227,23,227,23,180,68,180,
+ 'fill'=>'', 'tags'=>['floor3','room'])
+ $floorLabels[i.id] = '314'
+ $floorItems['314'] = i
+ TkcText.new(w,40.5,203.5, 'text'=>'314', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor3','label'])
+ i = TkcPolygon.new(w,95,179,95,135,23,135,23,179,
+ 'fill'=>'', 'tags'=>['floor3','room'])
+ $floorLabels[i.id] = '315'
+ $floorItems['315'] = i
+ TkcText.new(w,59,157, 'text'=>'315', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor3','label'])
+ i = TkcPolygon.new(w,99,226,99,204,91,204,91,226,
+ 'fill'=>'', 'tags'=>['floor3','room'])
+ $floorLabels[i.id] = '316B'
+ $floorItems['316B'] = i
+ TkcText.new(w,95,215, 'text'=>'316B', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor3','label'])
+ i = TkcPolygon.new(w,91,202,99,202,99,180,91,180,
+ 'fill'=>'', 'tags'=>['floor3','room'])
+ $floorLabels[i.id] = '316A'
+ $floorItems['316A'] = i
+ TkcText.new(w,95,191, 'text'=>'316A', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor3','label'])
+ i = TkcPolygon.new(w,97,169,109,169,109,192,154,192,154,198,
+ 174,198,174,226,101,226,101,179,97,179,
+ 'fill'=>'', 'tags'=>['floor3','room'])
+ $floorLabels[i.id] = '319'
+ $floorItems['319'] = i
+ TkcText.new(w,141.5,209, 'text'=>'319', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor3','label'])
+ i = TkcPolygon.new(w,65,368,58,368,58,389,1,389,1,333,23,333,23,323,65,323,
+ 'fill'=>'', 'tags'=>['floor3','room'])
+ $floorLabels[i.id] = '311'
+ $floorItems['311'] = i
+ TkcText.new(w,29.5,361, 'text'=>'311', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor3','label'])
+ i = TkcPolygon.new(w,154,191,111,191,111,169,154,169,
+ 'fill'=>'', 'tags'=>['floor3','room'])
+ $floorLabels[i.id] = '318'
+ $floorItems['318'] = i
+ TkcText.new(w,132.5,180, 'text'=>'318', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor3','label'])
+ i = TkcPolygon.new(w,175,168,97,168,97,131,175,131,
+ 'fill'=>'', 'tags'=>['floor3','room'])
+ $floorLabels[i.id] = '317'
+ $floorItems['317'] = i
+ TkcText.new(w,136,149.5, 'text'=>'317', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor3','label'])
+ i = TkcPolygon.new(w,274,194,274,221,306,221,306,194,
+ 'fill'=>'', 'tags'=>['floor3','room'])
+ $floorLabels[i.id] = '323'
+ $floorItems['323'] = i
+ TkcText.new(w,290,207.5, 'text'=>'323', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor3','label'])
+ i = TkcPolygon.new(w,306,222,274,222,274,249,306,249,
+ 'fill'=>'', 'tags'=>['floor3','room'])
+ $floorLabels[i.id] = '325'
+ $floorItems['325'] = i
+ TkcText.new(w,290,235.5, 'text'=>'325', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor3','label'])
+ i = TkcPolygon.new(w,263,179,224,179,224,135,263,135,
+ 'fill'=>'', 'tags'=>['floor3','room'])
+ $floorLabels[i.id] = '321'
+ $floorItems['321'] = i
+ TkcText.new(w,243.5,157, 'text'=>'321', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor3','label'])
+ i = TkcPolygon.new(w,314,169,306,169,306,192,273,192,
+ 264,181,264,135,314,135,
+ 'fill'=>'', 'tags'=>['floor3','room'])
+ $floorLabels[i.id] = '322'
+ $floorItems['322'] = i
+ TkcText.new(w,293.5,163.5, 'text'=>'322', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor3','label'])
+ i = TkcPolygon.new(w,307,240,339,240,339,206,307,206,
+ 'fill'=>'', 'tags'=>['floor3','room'])
+ $floorLabels[i.id] = 'Pub Lift3'
+ $floorItems['Pub Lift3'] = i
+ TkcText.new(w,323,223, 'text'=>'Pub Lift3', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor3','label'])
+ i = TkcPolygon.new(w,339,205,307,205,307,171,339,171,
+ 'fill'=>'', 'tags'=>['floor3','room'])
+ $floorLabels[i.id] = 'Priv Lift3'
+ $floorItems['Priv Lift3'] = i
+ TkcText.new(w,323,188, 'text'=>'Priv Lift3', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor3','label'])
+ i = TkcPolygon.new(w,350,284,376,284,376,276,397,276,397,309,350,309,
+ 'fill'=>'', 'tags'=>['floor3','room'])
+ $floorLabels[i.id] = '303'
+ $floorItems['303'] = i
+ TkcText.new(w,373.5,292.5, 'text'=>'303', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor3','label'])
+ i = TkcPolygon.new(w,272,203,272,249,252,249,252,230,
+ 244,230,244,221,252,221,252,203,
+ 'fill'=>'', 'tags'=>['floor3','room'])
+ $floorLabels[i.id] = '324'
+ $floorItems['324'] = i
+ TkcText.new(w,262,226, 'text'=>'324', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor3','label'])
+ i = TkcPolygon.new(w,299,276,299,327,349,327,349,284,341,284,341,276,
+ 'fill'=>'', 'tags'=>['floor3','room'])
+ $floorLabels[i.id] = '304'
+ $floorItems['304'] = i
+ TkcText.new(w,324,301.5, 'text'=>'304', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor3','label'])
+ i = TkcPolygon.new(w,375,246,375,172,341,172,341,246,
+ 'fill'=>'', 'tags'=>['floor3','room'])
+ $floorLabels[i.id] = '301'
+ $floorItems['301'] = i
+ TkcText.new(w,358,209, 'text'=>'301', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor3','label'])
+ i = TkcPolygon.new(w,397,246,377,246,377,185,397,185,
+ 'fill'=>'', 'tags'=>['floor3','room'])
+ $floorLabels[i.id] = '327'
+ $floorItems['327'] = i
+ TkcText.new(w,387,215.5, 'text'=>'327', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor3','label'])
+ i = TkcPolygon.new(w,316,131,316,169,377,169,377,185,397,185,397,131,
+ 'fill'=>'', 'tags'=>['floor3','room'])
+ $floorLabels[i.id] = '326'
+ $floorItems['326'] = i
+ TkcText.new(w,365.5,150, 'text'=>'326', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor3','label'])
+ i = TkcPolygon.new(w,308,251,242,251,242,274,342,274,342,282,375, 282,
+ 375,274,397,274,397,248,339,248,339,242,308,242,
+ 'fill'=>'', 'tags'=>['floor3','room'])
+ $floorLabels[i.id] = '302'
+ $floorItems['302'] = i
+ TkcText.new(w,319.5,261, 'text'=>'302', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor3','label'])
+ i = TkcPolygon.new(w,70,321,242,321,242,200,259,200,259,203,272,203,
+ 272,193,263,180,242,180,175,180,175,169,156,169,
+ 156,196,177,196,177,228,107,228,70,228,70,275,107,275,
+ 107,248,160,248,160,301,107,301,107,275,70,275,
+ 'fill'=>'', 'tags'=>['floor3','room'])
+ $floorLabels[i.id] = '306'
+ $floorItems['306'] = i
+ TkcText.new(w,200.5,284.5, 'text'=>'306', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor3','label'])
+ TkcLine.new(w,341,275,341,283, 'fill'=>color, 'tags'=>['floor3','wall'])
+ TkcLine.new(w,162,197,155,197, 'fill'=>color, 'tags'=>['floor3','wall'])
+ TkcLine.new(w,396,247,399,247, 'fill'=>color, 'tags'=>['floor3','wall'])
+ TkcLine.new(w,399,129,399,311, 'fill'=>color, 'tags'=>['floor3','wall'])
+ TkcLine.new(w,258,202,243,202, 'fill'=>color, 'tags'=>['floor3','wall'])
+ TkcLine.new(w,350,283,350,329, 'fill'=>color, 'tags'=>['floor3','wall'])
+ TkcLine.new(w,251,231,243,231, 'fill'=>color, 'tags'=>['floor3','wall'])
+ TkcLine.new(w,243,220,251,220, 'fill'=>color, 'tags'=>['floor3','wall'])
+ TkcLine.new(w,243,250,243,202, 'fill'=>color, 'tags'=>['floor3','wall'])
+ TkcLine.new(w,155,197,155,190, 'fill'=>color, 'tags'=>['floor3','wall'])
+ TkcLine.new(w,110,192,110,169, 'fill'=>color, 'tags'=>['floor3','wall'])
+ TkcLine.new(w,155,192,110,192, 'fill'=>color, 'tags'=>['floor3','wall'])
+ TkcLine.new(w,155,177,155,169, 'fill'=>color, 'tags'=>['floor3','wall'])
+ TkcLine.new(w,176,197,176,227, 'fill'=>color, 'tags'=>['floor3','wall'])
+ TkcLine.new(w,69,280,69,274, 'fill'=>color, 'tags'=>['floor3','wall'])
+ TkcLine.new(w,21,276,69,276, 'fill'=>color, 'tags'=>['floor3','wall'])
+ TkcLine.new(w,69,262,69,226, 'fill'=>color, 'tags'=>['floor3','wall'])
+ TkcLine.new(w,21,228,69,228, 'fill'=>color, 'tags'=>['floor3','wall'])
+ TkcLine.new(w,21,179,75,179, 'fill'=>color, 'tags'=>['floor3','wall'])
+ TkcLine.new(w,69,179,69,214, 'fill'=>color, 'tags'=>['floor3','wall'])
+ TkcLine.new(w,90,220,90,227, 'fill'=>color, 'tags'=>['floor3','wall'])
+ TkcLine.new(w,90,204,90,202, 'fill'=>color, 'tags'=>['floor3','wall'])
+ TkcLine.new(w,90,203,100,203, 'fill'=>color, 'tags'=>['floor3','wall'])
+ TkcLine.new(w,90,187,90,179, 'fill'=>color, 'tags'=>['floor3','wall'])
+ TkcLine.new(w,90,227,176,227, 'fill'=>color, 'tags'=>['floor3','wall'])
+ TkcLine.new(w,100,179,100,227, 'fill'=>color, 'tags'=>['floor3','wall'])
+ TkcLine.new(w,100,179,87,179, 'fill'=>color, 'tags'=>['floor3','wall'])
+ TkcLine.new(w,96,179,96,129, 'fill'=>color, 'tags'=>['floor3','wall'])
+ TkcLine.new(w,162,169,96,169, 'fill'=>color, 'tags'=>['floor3','wall'])
+ TkcLine.new(w,173,169,176,169, 'fill'=>color, 'tags'=>['floor3','wall'])
+ TkcLine.new(w,182,179,176,179, 'fill'=>color, 'tags'=>['floor3','wall'])
+ TkcLine.new(w,176,129,176,179, 'fill'=>color, 'tags'=>['floor3','wall'])
+ TkcLine.new(w,195,179,226,179, 'fill'=>color, 'tags'=>['floor3','wall'])
+ TkcLine.new(w,224,133,224,179, 'fill'=>color, 'tags'=>['floor3','wall'])
+ TkcLine.new(w,264,179,264,133, 'fill'=>color, 'tags'=>['floor3','wall'])
+ TkcLine.new(w,238,179,264,179, 'fill'=>color, 'tags'=>['floor3','wall'])
+ TkcLine.new(w,273,207,273,193, 'fill'=>color, 'tags'=>['floor3','wall'])
+ TkcLine.new(w,273,235,273,250, 'fill'=>color, 'tags'=>['floor3','wall'])
+ TkcLine.new(w,273,224,273,219, 'fill'=>color, 'tags'=>['floor3','wall'])
+ TkcLine.new(w,273,193,307,193, 'fill'=>color, 'tags'=>['floor3','wall'])
+ TkcLine.new(w,273,222,307,222, 'fill'=>color, 'tags'=>['floor3','wall'])
+ TkcLine.new(w,273,250,307,250, 'fill'=>color, 'tags'=>['floor3','wall'])
+ TkcLine.new(w,384,247,376,247, 'fill'=>color, 'tags'=>['floor3','wall'])
+ TkcLine.new(w,340,206,307,206, 'fill'=>color, 'tags'=>['floor3','wall'])
+ TkcLine.new(w,340,187,340,170, 'fill'=>color, 'tags'=>['floor3','wall'])
+ TkcLine.new(w,340,210,340,201, 'fill'=>color, 'tags'=>['floor3','wall'])
+ TkcLine.new(w,340,247,340,224, 'fill'=>color, 'tags'=>['floor3','wall'])
+ TkcLine.new(w,340,241,307,241, 'fill'=>color, 'tags'=>['floor3','wall'])
+ TkcLine.new(w,376,247,376,170, 'fill'=>color, 'tags'=>['floor3','wall'])
+ TkcLine.new(w,307,250,307,170, 'fill'=>color, 'tags'=>['floor3','wall'])
+ TkcLine.new(w,376,170,307,170, 'fill'=>color, 'tags'=>['floor3','wall'])
+ TkcLine.new(w,315,129,315,170, 'fill'=>color, 'tags'=>['floor3','wall'])
+ TkcLine.new(w,376,283,366,283, 'fill'=>color, 'tags'=>['floor3','wall'])
+ TkcLine.new(w,376,283,376,275, 'fill'=>color, 'tags'=>['floor3','wall'])
+ TkcLine.new(w,399,275,376,275, 'fill'=>color, 'tags'=>['floor3','wall'])
+ TkcLine.new(w,341,275,320,275, 'fill'=>color, 'tags'=>['floor3','wall'])
+ TkcLine.new(w,341,283,350,283, 'fill'=>color, 'tags'=>['floor3','wall'])
+ TkcLine.new(w,298,275,298,329, 'fill'=>color, 'tags'=>['floor3','wall'])
+ TkcLine.new(w,308,275,298,275, 'fill'=>color, 'tags'=>['floor3','wall'])
+ TkcLine.new(w,243,322,243,275, 'fill'=>color, 'tags'=>['floor3','wall'])
+ TkcLine.new(w,243,275,284,275, 'fill'=>color, 'tags'=>['floor3','wall'])
+ TkcLine.new(w,258,322,226,322, 'fill'=>color, 'tags'=>['floor3','wall'])
+ TkcLine.new(w,212,370,212,322, 'fill'=>color, 'tags'=>['floor3','wall'])
+ TkcLine.new(w,214,322,177,322, 'fill'=>color, 'tags'=>['floor3','wall'])
+ TkcLine.new(w,163,370,163,322, 'fill'=>color, 'tags'=>['floor3','wall'])
+ TkcLine.new(w,165,322,129,322, 'fill'=>color, 'tags'=>['floor3','wall'])
+ TkcLine.new(w,84,322,117,322, 'fill'=>color, 'tags'=>['floor3','wall'])
+ TkcLine.new(w,71,322,64,322, 'fill'=>color, 'tags'=>['floor3','wall'])
+ TkcLine.new(w,115,322,115,370, 'fill'=>color, 'tags'=>['floor3','wall'])
+ TkcLine.new(w,66,322,66,370, 'fill'=>color, 'tags'=>['floor3','wall'])
+ TkcLine.new(w,52,322,21,322, 'fill'=>color, 'tags'=>['floor3','wall'])
+ TkcLine.new(w,21,331,0,331, 'fill'=>color, 'tags'=>['floor3','wall'])
+ TkcLine.new(w,21,331,21,133, 'fill'=>color, 'tags'=>['floor3','wall'])
+ TkcLine.new(w,96,133,21,133, 'fill'=>color, 'tags'=>['floor3','wall'])
+ TkcLine.new(w,176,129,96,129, 'fill'=>color, 'tags'=>['floor3','wall'])
+ TkcLine.new(w,315,133,176,133, 'fill'=>color, 'tags'=>['floor3','wall'])
+ TkcLine.new(w,315,129,399,129, 'fill'=>color, 'tags'=>['floor3','wall'])
+ TkcLine.new(w,399,311,350,311, 'fill'=>color, 'tags'=>['floor3','wall'])
+ TkcLine.new(w,350,329,258,329, 'fill'=>color, 'tags'=>['floor3','wall'])
+ TkcLine.new(w,258,322,258,370, 'fill'=>color, 'tags'=>['floor3','wall'])
+ TkcLine.new(w,60,370,258,370, 'fill'=>color, 'tags'=>['floor3','wall'])
+ TkcLine.new(w,60,370,60,391, 'fill'=>color, 'tags'=>['floor3','wall'])
+ TkcLine.new(w,0,391,0,331, 'fill'=>color, 'tags'=>['floor3','wall'])
+ TkcLine.new(w,60,391,0,391, 'fill'=>color, 'tags'=>['floor3','wall'])
+ TkcLine.new(w,307,250,307,242, 'fill'=>color, 'tags'=>['floor3','wall'])
+ TkcLine.new(w,273,250,307,250, 'fill'=>color, 'tags'=>['floor3','wall'])
+ TkcLine.new(w,258,250,243,250, 'fill'=>color, 'tags'=>['floor3','wall'])
+end
+
+# Below is the "main program" that creates the floorplan demonstration.
+
+# toplevel widget
+if defined?($floor_demo) && $floor_demo
+ $floor_demo.destroy
+ $floor_demo = nil
+end
+
+# demo toplevel widget
+$floor_demo = TkToplevel.new {|w|
+ title("Floorplan Canvas Demonstration")
+ iconname("Floorplan")
+ positionWindow(w)
+ geometry('+20+20')
+ minsize(100,100)
+}
+
+base_frame = TkFrame.new($floor_demo).pack(:fill=>:both, :expand=>true)
+
+# label
+TkLabel.new(base_frame, 'font'=>$font, 'wraplength'=>'8i', 'justify'=>'left',
+ 'text'=>"This window contains a canvas widget showing the floorplan of Digital Equipment Corporation's Western Research Laboratory. It has three levels. At any given time one of the levels is active, meaning that you can see its room structure. To activate a level, click the left mouse button anywhere on it. As the mouse moves over the active level, the room under the mouse lights up and its room number appears in the \"Room:\" entry. You can also type a room number in the entry and the room will light up."){
+ pack('side'=>'top')
+}
+
+# frame
+$floor_buttons = TkFrame.new(base_frame) {|frame|
+ TkButton.new(frame) {
+ text 'Dismiss'
+ command proc{
+ tmppath = $floor_demo
+ $floor_demo = nil
+ tmppath.destroy
+ }
+ }.pack('side'=>'left', 'expand'=>'yes')
+
+ TkButton.new(frame) {
+ text 'Show Code'
+ command proc{showCode 'floor'}
+ }.pack('side'=>'left', 'expand'=>'yes')
+}
+$floor_buttons.pack('side'=>'bottom', 'fill'=>'x', 'pady'=>'2m')
+
+#
+$floorLabels = {}
+$floorItems = {}
+
+# canvas
+if $tk_version =~ /^4\.[01]/
+ $floor_canvas_frame = TkFrame.new(base_frame,'bd'=>2,'relief'=>'sunken',
+ 'highlightthickness'=>2)
+ $floor_canvas = TkCanvas.new($floor_canvas_frame,
+ 'width'=>900, 'height'=>500, 'borderwidth'=>0,
+ 'highlightthickness'=>0) {|c|
+ TkScrollbar.new(base_frame, 'orient'=>'horiz',
+ 'command'=>proc{|*args| c.xview(*args)}){|hs|
+ c.xscrollcommand(proc{|first,last| hs.set first,last})
+ pack('side'=>'bottom', 'fill'=>'x')
+ }
+ TkScrollbar.new(base_frame, 'command'=>proc{|*args| c.yview(*args)}){|vs|
+ c.yscrollcommand(proc{|first,last| vs.set first,last})
+ pack('side'=>'right', 'fill'=>'y')
+ }
+ }
+ $floor_canvas_frame.pack('side'=>'top','fill'=>'both', 'expand'=>'yes')
+ $floor_canvas.pack('expand'=>'yes', 'fill'=>'both')
+
+else
+ TkFrame.new(base_frame) {|f|
+ pack('side'=>'top', 'fill'=>'both', 'expand'=>'yes')
+
+ h = TkScrollbar.new(f, 'highlightthickness'=>0, 'orient'=>'horizontal')
+ v = TkScrollbar.new(f, 'highlightthickness'=>0, 'orient'=>'vertical')
+
+ TkFrame.new(f, 'bd'=>2, 'relief'=>'sunken') {|f1|
+ $floor_canvas = TkCanvas.new(f1, 'width'=>900, 'height'=>500,
+ 'borderwidth'=>0,
+ 'highlightthickness'=>0) {
+ xscrollcommand(proc{|first,last| h.set first,last})
+ yscrollcommand(proc{|first,last| v.set first,last})
+ pack('expand'=>'yes', 'fill'=>'both')
+ }
+ grid('padx'=>1, 'pady'=>1, 'row'=>0, 'column'=>0,
+ 'rowspan'=>1, 'columnspan'=>1, 'sticky'=>'news')
+ }
+
+ v.grid('padx'=>1, 'pady'=>1, 'row'=>0, 'column'=>1,
+ 'rowspan'=>1, 'columnspan'=>1, 'sticky'=>'news')
+ h.grid('padx'=>1, 'pady'=>1, 'row'=>1, 'column'=>0,
+ 'rowspan'=>1, 'columnspan'=>1, 'sticky'=>'news')
+
+ TkGrid.rowconfigure(f, 0, 'weight'=>1, 'minsize'=>0)
+ TkGrid.columnconfigure(f, 0, 'weight'=>1, 'minsize'=>0)
+
+ pack('expand'=>'yes', 'fill'=>'both', 'padx'=>1, 'pady'=>1)
+
+ v.command(proc{|*args| $floor_canvas.yview(*args)})
+ h.command(proc{|*args| $floor_canvas.xview(*args)})
+ }
+end
+
+
+# Create an entry for displaying and typing in current room.
+
+$currentRoom = TkVariable.new
+$floor_entry = TkEntry.new($floor_canvas, 'width'=>10, 'relief'=>'sunken',
+ 'bd'=>2, 'textvariable'=>$currentRoom)
+
+# Choose colors, then fill in the floorplan.
+
+$floor_colors = {}
+if TkWinfo.depth($floor_canvas) > 1
+ $floor_colors['bg1'] = '#a9c1da'
+ $floor_colors['outline1'] = '#77889a'
+ $floor_colors['bg2'] = '#9ab0c6'
+ $floor_colors['outline2'] = '#687786'
+ $floor_colors['bg3'] = '#8ba0b3'
+ $floor_colors['outline3'] = '#596673'
+ $floor_colors['offices'] = 'Black'
+ $floor_colors['active'] = '#c4d1df'
+else
+ $floor_colors['bg1'] = 'white'
+ $floor_colors['outline1'] = 'black'
+ $floor_colors['bg2'] = 'white'
+ $floor_colors['outline2'] = 'black'
+ $floor_colors['bg3'] = 'white'
+ $floor_colors['outline3'] = 'black'
+ $floor_colors['offices'] = 'Black'
+ $floor_colors['active'] = 'black'
+end
+
+$activeFloor = ''
+floorDisplay $floor_canvas,3
+
+# Set up event bindings for canvas:
+
+$floor_canvas.itembind('floor1', '1', proc{floorDisplay $floor_canvas,1})
+$floor_canvas.itembind('floor2', '1', proc{floorDisplay $floor_canvas,2})
+$floor_canvas.itembind('floor3', '1', proc{floorDisplay $floor_canvas,3})
+$floor_canvas.itembind('room', 'Enter', proc{newRoom $floor_canvas})
+$floor_canvas.itembind('room', 'Leave', proc{$currentRoom.value = ''})
+$floor_canvas.bind('2', proc{|x,y| $floor_canvas.scan_mark x,y}, '%x %y')
+$floor_canvas.bind('B2-Motion',
+ proc{|x,y| $floor_canvas.scan_dragto x,y}, '%x %y')
+$floor_canvas.bind('Destroy', proc{$currentRoom.unset})
+$currentRoom.value = ''
+$currentRoom.trace('w',proc{roomChanged $floor_canvas})
+
diff --git a/jni/ruby/ext/tk/sample/demos-en/floor2.rb b/jni/ruby/ext/tk/sample/demos-en/floor2.rb
new file mode 100644
index 0000000..3bfa89a
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/demos-en/floor2.rb
@@ -0,0 +1,1722 @@
+%# floor2.rb
+#
+# This demonstration script creates a canvas widet that displays the
+# floorplan for DEC's Western Research Laboratory.
+#
+# floorDisplay widget demo (called by 'widget')
+#
+
+# floorDisplay2 --
+# Recreate the floorplan display in the canvas given by "w". The
+# floor given by "active" is displayed on top with its office structure
+# visible.
+#
+# Arguments:
+# w - Name of the canvas window.
+# active - Number of active floor (1, 2, or 3).
+
+def floorDisplay2(w,active)
+ return if $activeFloor2 == active
+
+ w.delete('all')
+ $activeFloor2 = active
+
+ # First go through the three floors, displaying the backgrounds for
+ # each floor.
+
+ floor2_bg1(w,$floor2_colors['bg1'],$floor2_colors['outline1'])
+ floor2_bg2(w,$floor2_colors['bg2'],$floor2_colors['outline2'])
+ floor2_bg3(w,$floor2_colors['bg3'],$floor2_colors['outline3'])
+
+ # Raise the background for the active floor so that it's on top.
+
+ w.raise("floor#{active}")
+
+ # Create a dummy item just to mark this point in the display list,
+ # so we can insert highlights here.
+
+ w.create(TkcRectangle,0,100,1,101,'fill'=>'','outline'=>'','tags'=>'marker')
+
+ # Add the walls and labels for the active floor, along with
+ # transparent polygons that define the rooms on the floor.
+ # Make sure that the room polygons are on top.
+
+ $floorLabels2.clear
+ $floorItems2.clear
+ send("floor2_fg#{active}", w, $floor2_colors['offices'])
+ w.raise('room')
+
+ # Offset the floors diagonally from each other.
+
+ w.move('floor1', '2c', '2c')
+ w.move('floor2', '1c', '1c')
+
+ # Create items for the room entry and its label.
+ w.create(TkcWindow, 600, 100, 'anchor'=>'w', 'window'=>$floor2_entry)
+ w.create(TkcText, 600, 100, 'anchor'=>'e', 'text'=>"Room: ")
+ w['scrollregion'] = w.bbox('all')
+end
+
+# newRoom2 --
+# This method is invoked whenever the mouse enters a room
+# in the floorplan. It changes tags so that the current room is
+# highlighted.
+#
+# Arguments:
+# w - The name of the canvas window.
+
+def newRoom2(w)
+ id = w.find_withtag('current')[0]
+ $currentRoom2.value = $floorLabels2[id.id] if id != ""
+ Tk.update(true)
+end
+
+# roomChanged2 --
+# This method is invoked whenever the currentRoom variable changes.
+# It highlights the current room and unhighlights any previous room.
+#
+# Arguments:
+# w - The canvas window displaying the floorplan.
+# args - Not used.
+
+def roomChanged2(w,*args)
+ w.delete('highlight')
+ item = $floorItems2[$currentRoom2.value]
+ return if item == nil
+ new = TkcPolygon.new(w, *(w.coords(item)))
+ new.configure('fill'=>$floor2_colors['active'], 'tags'=>'highlight')
+ w.raise(new, 'marker')
+end
+
+# floor2_bg1 --
+# This method represents part of the floorplan database. When
+# invoked, it instantiates the background information for the first
+# floor.
+#
+# Arguments:
+# w - The canvas window.
+# fill - Fill color to use for the floor's background.
+# outline - Color to use for the floor's outline.
+
+def floor2_bg1(w,fill,outline)
+ w.create(TkcPolygon,347,80,349,82,351,84,353,85,363,92,375,99,386,104,
+ 386,129,398,129,398,162,484,162,484,129,559,129,559,133,725,
+ 133,725,129,802,129,802,389,644,389,644,391,559,391,559,327,
+ 508,327,508,311,484,311,484,278,395,278,395,288,400,288,404,
+ 288,409,290,413,292,418,297,421,302,422,309,421,318,417,325,
+ 411,330,405,332,397,333,344,333,340,334,336,336,335,338,332,
+ 342,331,347,332,351,334,354,336,357,341,359,340,360,335,363,
+ 331,365,326,366,304,366,304,355,258,355,258,387,60,387,60,391,
+ 0,391,0,337,3,337,3,114,8,114,8,25,30,25,30,5,93,5,98,5,104,7,
+ 110,10,116,16,119,20,122,28,123,32,123,68,220,68,220,34,221,
+ 22,223,17,227,13,231,8,236,4,242,2,246,0,260,0,283,1,300,5,
+ 321,14,335,22,348,25,365,29,363,39,358,48,352,56,337,70,
+ 344,76,347,80, 'tags'=>['floor1','bg'], 'fill'=>fill)
+ w.create(TkcLine,386,129,398,129, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ w.create(TkcLine,258,355,258,387, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ w.create(TkcLine,60,387,60,391, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ w.create(TkcLine,0,337,0,391, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ w.create(TkcLine,60,391,0,391, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ w.create(TkcLine,3,114,3,337, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ w.create(TkcLine,258,387,60,387, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ w.create(TkcLine,484,162,398,162, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ w.create(TkcLine,398,162,398,129, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ w.create(TkcLine,484,278,484,311, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ w.create(TkcLine,484,311,508,311, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ w.create(TkcLine,508,327,508,311, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ w.create(TkcLine,559,327,508,327, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ w.create(TkcLine,644,391,559,391, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ w.create(TkcLine,644,389,644,391, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ w.create(TkcLine,559,129,484,129, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ w.create(TkcLine,484,162,484,129, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ w.create(TkcLine,725,133,559,133, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ w.create(TkcLine,559,129,559,133, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ w.create(TkcLine,725,129,802,129, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ w.create(TkcLine,802,389,802,129, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ w.create(TkcLine,3,337,0,337, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ w.create(TkcLine,559,391,559,327, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ w.create(TkcLine,802,389,644,389, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ w.create(TkcLine,725,133,725,129, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ w.create(TkcLine,8,25,8,114, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ w.create(TkcLine,8,114,3,114, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ w.create(TkcLine,30,25,8,25, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ w.create(TkcLine,484,278,395,278, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ w.create(TkcLine,30,25,30,5, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ w.create(TkcLine,93,5,30,5, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ w.create(TkcLine,98,5,93,5, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ w.create(TkcLine,104,7,98,5, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ w.create(TkcLine,110,10,104,7, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ w.create(TkcLine,116,16,110,10, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ w.create(TkcLine,119,20,116,16, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ w.create(TkcLine,122,28,119,20, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ w.create(TkcLine,123,32,122,28, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ w.create(TkcLine,123,68,123,32, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ w.create(TkcLine,220,68,123,68, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ w.create(TkcLine,386,129,386,104, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ w.create(TkcLine,386,104,375,99, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ w.create(TkcLine,375,99,363,92, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ w.create(TkcLine,353,85,363,92, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ w.create(TkcLine,220,68,220,34, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ w.create(TkcLine,337,70,352,56, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ w.create(TkcLine,352,56,358,48, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ w.create(TkcLine,358,48,363,39, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ w.create(TkcLine,363,39,365,29, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ w.create(TkcLine,365,29,348,25, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ w.create(TkcLine,348,25,335,22, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ w.create(TkcLine,335,22,321,14, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ w.create(TkcLine,321,14,300,5, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ w.create(TkcLine,300,5,283,1, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ w.create(TkcLine,283,1,260,0, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ w.create(TkcLine,260,0,246,0, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ w.create(TkcLine,246,0,242,2, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ w.create(TkcLine,242,2,236,4, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ w.create(TkcLine,236,4,231,8, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ w.create(TkcLine,231,8,227,13, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ w.create(TkcLine,223,17,227,13, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ w.create(TkcLine,221,22,223,17, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ w.create(TkcLine,220,34,221,22, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ w.create(TkcLine,340,360,335,363, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ w.create(TkcLine,335,363,331,365, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ w.create(TkcLine,331,365,326,366, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ w.create(TkcLine,326,366,304,366, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ w.create(TkcLine,304,355,304,366, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ w.create(TkcLine,395,288,400,288, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ w.create(TkcLine,404,288,400,288, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ w.create(TkcLine,409,290,404,288, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ w.create(TkcLine,413,292,409,290, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ w.create(TkcLine,418,297,413,292, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ w.create(TkcLine,421,302,418,297, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ w.create(TkcLine,422,309,421,302, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ w.create(TkcLine,421,318,422,309, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ w.create(TkcLine,421,318,417,325, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ w.create(TkcLine,417,325,411,330, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ w.create(TkcLine,411,330,405,332, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ w.create(TkcLine,405,332,397,333, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ w.create(TkcLine,397,333,344,333, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ w.create(TkcLine,344,333,340,334, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ w.create(TkcLine,340,334,336,336, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ w.create(TkcLine,336,336,335,338, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ w.create(TkcLine,335,338,332,342, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ w.create(TkcLine,331,347,332,342, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ w.create(TkcLine,332,351,331,347, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ w.create(TkcLine,334,354,332,351, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ w.create(TkcLine,336,357,334,354, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ w.create(TkcLine,341,359,336,357, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ w.create(TkcLine,341,359,340,360, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ w.create(TkcLine,395,288,395,278, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ w.create(TkcLine,304,355,258,355, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ w.create(TkcLine,347,80,344,76, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ w.create(TkcLine,344,76,337,70, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ w.create(TkcLine,349,82,347,80, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ w.create(TkcLine,351,84,349,82, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ w.create(TkcLine,353,85,351,84, 'fill'=>outline, 'tags'=>['floor1','bg'])
+end
+
+# floor2_bg2 --
+# This method represents part of the floorplan database. When
+# invoked, it instantiates the background information for the first
+# floor.
+#
+# Arguments:
+# w - The canvas window.
+# fill - Fill color to use for the floor's background.
+# outline - Color to use for the floor's outline.
+
+def floor2_bg2(w,fill,outline)
+ w.create(TkcPolygon,559,129,484,129,484,162,398,162,398,129,315,129,
+ 315,133,176,133,176,129,96,129,96,133,3,133,3,339,0,339,0,391,
+ 60,391,60,387,258,387,258,329,350,329,350,311,395,311,395,280,
+ 484,280,484,311,508,311,508,327,558,327,558,391,644,391,644,
+ 367,802,367,802,129,725,129,725,133,559,133,559,129,
+ 'tags'=>['floor2','bg'], 'fill'=>fill)
+ w.create(TkcLine,350,311,350,329, 'fill'=>outline, 'tags'=>['floor2','bg'])
+ w.create(TkcLine,398,129,398,162, 'fill'=>outline, 'tags'=>['floor2','bg'])
+ w.create(TkcLine,802,367,802,129, 'fill'=>outline, 'tags'=>['floor2','bg'])
+ w.create(TkcLine,802,129,725,129, 'fill'=>outline, 'tags'=>['floor2','bg'])
+ w.create(TkcLine,725,133,725,129, 'fill'=>outline, 'tags'=>['floor2','bg'])
+ w.create(TkcLine,559,129,559,133, 'fill'=>outline, 'tags'=>['floor2','bg'])
+ w.create(TkcLine,559,133,725,133, 'fill'=>outline, 'tags'=>['floor2','bg'])
+ w.create(TkcLine,484,162,484,129, 'fill'=>outline, 'tags'=>['floor2','bg'])
+ w.create(TkcLine,559,129,484,129, 'fill'=>outline, 'tags'=>['floor2','bg'])
+ w.create(TkcLine,802,367,644,367, 'fill'=>outline, 'tags'=>['floor2','bg'])
+ w.create(TkcLine,644,367,644,391, 'fill'=>outline, 'tags'=>['floor2','bg'])
+ w.create(TkcLine,644,391,558,391, 'fill'=>outline, 'tags'=>['floor2','bg'])
+ w.create(TkcLine,558,327,558,391, 'fill'=>outline, 'tags'=>['floor2','bg'])
+ w.create(TkcLine,558,327,508,327, 'fill'=>outline, 'tags'=>['floor2','bg'])
+ w.create(TkcLine,508,327,508,311, 'fill'=>outline, 'tags'=>['floor2','bg'])
+ w.create(TkcLine,484,311,508,311, 'fill'=>outline, 'tags'=>['floor2','bg'])
+ w.create(TkcLine,484,280,484,311, 'fill'=>outline, 'tags'=>['floor2','bg'])
+ w.create(TkcLine,398,162,484,162, 'fill'=>outline, 'tags'=>['floor2','bg'])
+ w.create(TkcLine,484,280,395,280, 'fill'=>outline, 'tags'=>['floor2','bg'])
+ w.create(TkcLine,395,280,395,311, 'fill'=>outline, 'tags'=>['floor2','bg'])
+ w.create(TkcLine,258,387,60,387, 'fill'=>outline, 'tags'=>['floor2','bg'])
+ w.create(TkcLine,3,133,3,339, 'fill'=>outline, 'tags'=>['floor2','bg'])
+ w.create(TkcLine,3,339,0,339, 'fill'=>outline, 'tags'=>['floor2','bg'])
+ w.create(TkcLine,60,391,0,391, 'fill'=>outline, 'tags'=>['floor2','bg'])
+ w.create(TkcLine,0,339,0,391, 'fill'=>outline, 'tags'=>['floor2','bg'])
+ w.create(TkcLine,60,387,60,391, 'fill'=>outline, 'tags'=>['floor2','bg'])
+ w.create(TkcLine,258,329,258,387, 'fill'=>outline, 'tags'=>['floor2','bg'])
+ w.create(TkcLine,350,329,258,329, 'fill'=>outline, 'tags'=>['floor2','bg'])
+ w.create(TkcLine,395,311,350,311, 'fill'=>outline, 'tags'=>['floor2','bg'])
+ w.create(TkcLine,398,129,315,129, 'fill'=>outline, 'tags'=>['floor2','bg'])
+ w.create(TkcLine,176,133,315,133, 'fill'=>outline, 'tags'=>['floor2','bg'])
+ w.create(TkcLine,176,129,96,129, 'fill'=>outline, 'tags'=>['floor2','bg'])
+ w.create(TkcLine,3,133,96,133, 'fill'=>outline, 'tags'=>['floor2','bg'])
+ w.create(TkcLine,315,133,315,129, 'fill'=>outline, 'tags'=>['floor2','bg'])
+ w.create(TkcLine,176,133,176,129, 'fill'=>outline, 'tags'=>['floor2','bg'])
+ w.create(TkcLine,96,133,96,129, 'fill'=>outline, 'tags'=>['floor2','bg'])
+end
+
+# floor2_bg3 --
+# This method represents part of the floorplan database. When
+# invoked, it instantiates the background information for the first
+# floor.
+#
+# Arguments:
+# w - The canvas window.
+# fill - Fill color to use for the floor's background.
+# outline - Color to use for the floor's outline.
+
+def floor2_bg3(w,fill,outline)
+ w.create(TkcPolygon,159,300,107,300,107,248,159,248,159,129,96,129,96,
+ 133,21,133,21,331,0,331,0,391,60,391,60,370,159,370,159,300,
+ 'tags'=>['floor3','bg'], 'fill'=>fill)
+ w.create(TkcPolygon,258,370,258,329,350,329,350,311,399,311,399,129,
+ 315,129,315,133,176,133,176,129,159,129,159,370,258,370,
+ 'tags'=>['floor3','bg'], 'fill'=>fill)
+ w.create(TkcLine,96,133,96,129, 'fill'=>outline, 'tags'=>['floor3','bg'])
+ w.create(TkcLine,176,129,96,129, 'fill'=>outline, 'tags'=>['floor3','bg'])
+ w.create(TkcLine,176,129,176,133, 'fill'=>outline, 'tags'=>['floor3','bg'])
+ w.create(TkcLine,315,133,176,133, 'fill'=>outline, 'tags'=>['floor3','bg'])
+ w.create(TkcLine,315,133,315,129, 'fill'=>outline, 'tags'=>['floor3','bg'])
+ w.create(TkcLine,399,129,315,129, 'fill'=>outline, 'tags'=>['floor3','bg'])
+ w.create(TkcLine,399,311,399,129, 'fill'=>outline, 'tags'=>['floor3','bg'])
+ w.create(TkcLine,399,311,350,311, 'fill'=>outline, 'tags'=>['floor3','bg'])
+ w.create(TkcLine,350,329,350,311, 'fill'=>outline, 'tags'=>['floor3','bg'])
+ w.create(TkcLine,350,329,258,329, 'fill'=>outline, 'tags'=>['floor3','bg'])
+ w.create(TkcLine,258,370,258,329, 'fill'=>outline, 'tags'=>['floor3','bg'])
+ w.create(TkcLine,60,370,258,370, 'fill'=>outline, 'tags'=>['floor3','bg'])
+ w.create(TkcLine,60,370,60,391, 'fill'=>outline, 'tags'=>['floor3','bg'])
+ w.create(TkcLine,60,391,0,391, 'fill'=>outline, 'tags'=>['floor3','bg'])
+ w.create(TkcLine,0,391,0,331, 'fill'=>outline, 'tags'=>['floor3','bg'])
+ w.create(TkcLine,21,331,0,331, 'fill'=>outline, 'tags'=>['floor3','bg'])
+ w.create(TkcLine,21,331,21,133, 'fill'=>outline, 'tags'=>['floor3','bg'])
+ w.create(TkcLine,96,133,21,133, 'fill'=>outline, 'tags'=>['floor3','bg'])
+ w.create(TkcLine,107,300,159,300,159,248,107,248,107,300,
+ 'fill'=>outline, 'tags'=>['floor3','bg'])
+end
+
+# floor2_fg1 --
+# This method represents part of the floorplan database. When
+# invoked, it instantiates the foreground information for the first
+# floor (office outlines and numbers).
+#
+# Arguments:
+# w - The canvas window.
+# color - Color to use for drawing foreground information.
+
+def floor2_fg1(w,color)
+ i = TkcPolygon.new(w,375,246,375,172,341,172,341,246,
+ 'fill'=>'', 'tags'=>['floor1','room'])
+ $floorLabels2[i.id] = '101'
+ $floorItems2['101'] = i
+ w.create(TkcText,358,209, 'text'=>'101', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor1','label'])
+ i = TkcPolygon.new(w,307,240,339,240,339,206,307,206,
+ 'fill'=>'', 'tags'=>['floor1','room'])
+ $floorLabels2[i.id] = 'Pub Lift1'
+ $floorItems2['Pub Lift1'] = i
+ w.create(TkcText,323,223, 'text'=>'Pub Lift1', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor1','label'])
+ i = TkcPolygon.new(w,339,205,307,205,307,171,339,171,
+ 'fill'=>'', 'tags'=>['floor1','room'])
+ $floorLabels2[i.id] = 'Priv Lift1'
+ $floorItems2['Priv Lift1'] = i
+ w.create(TkcText,323,188, 'text'=>'Priv Lift1', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor1','label'])
+ i = TkcPolygon.new(w,42,389,42,337,1,337,1,389,
+ 'fill'=>'', 'tags'=>['floor1','room'])
+ $floorLabels2[i.id] = '110'
+ $floorItems2['110'] = i
+ w.create(TkcText,21.5,363, 'text'=>'110', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor1','label'])
+ i = TkcPolygon.new(w,59,389,59,385,90,385,90,337,44,337,44,389,
+ 'fill'=>'', 'tags'=>['floor1','room'])
+ $floorLabels2[i.id] = '109'
+ $floorItems2['109'] = i
+ w.create(TkcText,67,363, 'text'=>'109', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor1','label'])
+ i = TkcPolygon.new(w,51,300,51,253,6,253,6,300,
+ 'fill'=>'', 'tags'=>['floor1','room'])
+ $floorLabels2[i.id] = '111'
+ $floorItems2['111'] = i
+ w.create(TkcText,28.5,276.5, 'text'=>'111', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor1','label'])
+ i = TkcPolygon.new(w,98,248,98,309,79,309,79,248,
+ 'fill'=>'', 'tags'=>['floor1','room'])
+ $floorLabels2[i.id] = '117B'
+ $floorItems2['117B'] = i
+ w.create(TkcText,88.5,278.5, 'text'=>'117B', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor1','label'])
+ i = TkcPolygon.new(w,51,251,51,204,6,204,6,251,
+ 'fill'=>'', 'tags'=>['floor1','room'])
+ $floorLabels2[i.id] = '112'
+ $floorItems2['112'] = i
+ w.create(TkcText,28.5,227.5, 'text'=>'112', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor1','label'])
+ i = TkcPolygon.new(w,6,156,51,156,51,203,6,203,
+ 'fill'=>'', 'tags'=>['floor1','room'])
+ $floorLabels2[i.id] = '113'
+ $floorItems2['113'] = i
+ w.create(TkcText,28.5,179.5, 'text'=>'113', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor1','label'])
+ i = TkcPolygon.new(w,85,169,79,169,79,192,85,192,
+ 'fill'=>'', 'tags'=>['floor1','room'])
+ $floorLabels2[i.id] = '117A'
+ $floorItems2['117A'] = i
+ w.create(TkcText,82,180.5, 'text'=>'117A', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor1','label'])
+ i = TkcPolygon.new(w,77,302,77,168,53,168,53,302,
+ 'fill'=>'', 'tags'=>['floor1','room'])
+ $floorLabels2[i.id] = '117'
+ $floorItems2['117'] = i
+ w.create(TkcText,65,235, 'text'=>'117', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor1','label'])
+ i = TkcPolygon.new(w,51,155,51,115,6,115,6,155,
+ 'fill'=>'', 'tags'=>['floor1','room'])
+ $floorLabels2[i.id] = '114'
+ $floorItems2['114'] = i
+ w.create(TkcText,28.5,135, 'text'=>'114', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor1','label'])
+ i = TkcPolygon.new(w,95,115,53,115,53,168,95,168,
+ 'fill'=>'', 'tags'=>['floor1','room'])
+ $floorLabels2[i.id] = '115'
+ $floorItems2['115'] = i
+ w.create(TkcText,74,141.5, 'text'=>'115', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor1','label'])
+ i = TkcPolygon.new(w,87,113,87,27,10,27,10,113,
+ 'fill'=>'', 'tags'=>['floor1','room'])
+ $floorLabels2[i.id] = '116'
+ $floorItems2['116'] = i
+ w.create(TkcText,48.5,70, 'text'=>'116', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor1','label'])
+ i = TkcPolygon.new(w,89,91,128,91,128,113,89,131,
+ 'fill'=>'', 'tags'=>['floor1','room'])
+ $floorLabels2[i.id] = '118'
+ $floorItems2['118'] = i
+ w.create(TkcText,108.5,102, 'text'=>'118', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor1','label'])
+ i = TkcPolygon.new(w,178,128,178,132,216,132,216,91,
+ 163,91,163,112,149,112,149,128,
+ 'fill'=>'', 'tags'=>['floor1','room'])
+ $floorLabels2[i.id] = '120'
+ $floorItems2['120'] = i
+ w.create(TkcText,189.5,111.5, 'text'=>'120', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor1','label'])
+ i = TkcPolygon.new(w,79,193,87,193,87,169,136,169,136,192,
+ 156,192,156,169,175,169,175,246,79,246,
+ 'fill'=>'', 'tags'=>['floor1','room'])
+ $floorLabels2[i.id] = '122'
+ $floorItems2['122'] = i
+ w.create(TkcText,131,207.5, 'text'=>'122', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor1','label'])
+ i = TkcPolygon.new(w,138,169,154,169,154,191,138,191,
+ 'fill'=>'', 'tags'=>['floor1','room'])
+ $floorLabels2[i.id] = '121'
+ $floorItems2['121'] = i
+ w.create(TkcText,146,180, 'text'=>'121', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor1','label'])
+ i = TkcPolygon.new(w,99,300,126,300,126,309,99,309,
+ 'fill'=>'', 'tags'=>['floor1','room'])
+ $floorLabels2[i.id] = '106A'
+ $floorItems2['106A'] = i
+ w.create(TkcText,112.5,304.5, 'text'=>'106A', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor1','label'])
+ i = TkcPolygon.new(w,128,299,128,309,150,309,150,248,99,248,99,299,
+ 'fill'=>'', 'tags'=>['floor1','room'])
+ $floorLabels2[i.id] = '105'
+ $floorItems2['105'] = i
+ w.create(TkcText,124.5,278.5, 'text'=>'105', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor1','label'])
+ i = TkcPolygon.new(w,174,309,174,300,152,300,152,309,
+ 'fill'=>'', 'tags'=>['floor1','room'])
+ $floorLabels2[i.id] = '106B'
+ $floorItems2['106B'] = i
+ w.create(TkcText,163,304.5, 'text'=>'106B', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor1','label'])
+ i = TkcPolygon.new(w,176,299,176,309,216,309,216,248,152,248,152,299,
+ 'fill'=>'', 'tags'=>['floor1','room'])
+ $floorLabels2[i.id] = '104'
+ $floorItems2['104'] = i
+ w.create(TkcText,184,278.5, 'text'=>'104', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor1','label'])
+ i = TkcPolygon.new(w,138,385,138,337,91,337,91,385,
+ 'fill'=>'', 'tags'=>['floor1','room'])
+ $floorLabels2[i.id] = '108'
+ $floorItems2['108'] = i
+ w.create(TkcText,114.5,361, 'text'=>'108', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor1','label'])
+ i = TkcPolygon.new(w,256,337,140,337,140,385,256,385,
+ 'fill'=>'', 'tags'=>['floor1','room'])
+ $floorLabels2[i.id] = '107'
+ $floorItems2['107'] = i
+ w.create(TkcText,198,361, 'text'=>'107', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor1','label'])
+ i = TkcPolygon.new(w,300,353,300,329,260,329,260,353,
+ 'fill'=>'', 'tags'=>['floor1','room'])
+ $floorLabels2[i.id] = 'Smoking'
+ $floorItems2['Smoking'] = i
+ w.create(TkcText,280,341, 'text'=>'Smoking', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor1','label'])
+ i = TkcPolygon.new(w,314,135,314,170,306,170,306,246,177,246,177,135,
+ 'fill'=>'', 'tags'=>['floor1','room'])
+ $floorLabels2[i.id] = '123'
+ $floorItems2['123'] = i
+ w.create(TkcText,245.5,190.5, 'text'=>'123', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor1','label'])
+ i = TkcPolygon.new(w,217,248,301,248,301,326,257,326,257,310,217,310,
+ 'fill'=>'', 'tags'=>['floor1','room'])
+ $floorLabels2[i.id] = '103'
+ $floorItems2['103'] = i
+ w.create(TkcText,259,287, 'text'=>'103', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor1','label'])
+ i = TkcPolygon.new(w,396,188,377,188,377,169,316,169,316,131,396,131,
+ 'fill'=>'', 'tags'=>['floor1','room'])
+ $floorLabels2[i.id] = '124'
+ $floorItems2['124'] = i
+ w.create(TkcText,356,150, 'text'=>'124', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor1','label'])
+ i = TkcPolygon.new(w,397,226,407,226,407,189,377,189,377,246,397,246,
+ 'fill'=>'', 'tags'=>['floor1','room'])
+ $floorLabels2[i.id] = '125'
+ $floorItems2['125'] = i
+ w.create(TkcText,392,217.5, 'text'=>'125', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor1','label'])
+ i = TkcPolygon.new(w,399,187,409,187,409,207,474,207,474,164,399,164,
+ 'fill'=>'', 'tags'=>['floor1','room'])
+ $floorLabels2[i.id] = '126'
+ $floorItems2['126'] = i
+ w.create(TkcText,436.5,185.5, 'text'=>'126', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor1','label'])
+ i = TkcPolygon.new(w,409,209,409,229,399,229,399,253,
+ 486,253,486,239,474,239,474,209,
+ 'fill'=>'', 'tags'=>['floor1','room'])
+ $floorLabels2[i.id] = '127'
+ $floorItems2['127'] = i
+ w.create(TkcText,436.5,'231', 'text'=>'127', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor1','label'])
+ i = TkcPolygon.new(w,501,164,501,174,495,174,495,188,
+ 490,188,490,204,476,204,476,164,
+ 'fill'=>'', 'tags'=>['floor1','room'])
+ $floorLabels2[i.id] = 'MShower'
+ $floorItems2['MShower'] = i
+ w.create(TkcText,488.5,'184', 'text'=>'MShower', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor1','label'])
+ i = TkcPolygon.new(w,497,176,513,176,513,204,492,204,492,190,497,190,
+ 'fill'=>'', 'tags'=>['floor1','room'])
+ $floorLabels2[i.id] = 'Closet'
+ $floorItems2['Closet'] = i
+ w.create(TkcText,502.5,190, 'text'=>'Closet', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor1','label'])
+ i = TkcPolygon.new(w,476,237,476,206,513,206,513,254,488,254,488,237,
+ 'fill'=>'', 'tags'=>['floor1','room'])
+ $floorLabels2[i.id] = 'WShower'
+ $floorItems2['WShower'] = i
+ w.create(TkcText,494.5,230, 'text'=>'WShower', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor1','label'])
+ i = TkcPolygon.new(w,486,131,558,131,558,135,724,135,724,166,
+ 697,166,697,275,553,275,531,254,515,254,
+ 515,174,503,174,503,161,486,161,
+ 'fill'=>'', 'tags'=>['floor1','room'])
+ $floorLabels2[i.id] = '130'
+ $floorItems2['130'] = i
+ w.create(TkcText,638.5,205, 'text'=>'130', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor1','label'])
+ i = TkcPolygon.new(w,308,242,339,242,339,248,342,248,
+ 342,246,397,246,397,276,393,276,
+ 393,309,300,309,300,248,308,248,
+ 'fill'=>'', 'tags'=>['floor1','room'])
+ $floorLabels2[i.id] = '102'
+ $floorItems2['102'] = i
+ w.create(TkcText,367.5,278.5, 'text'=>'102', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor1','label'])
+ i = TkcPolygon.new(w,397,255,486,255,486,276,397,276,
+ 'fill'=>'', 'tags'=>['floor1','room'])
+ $floorLabels2[i.id] = '128'
+ $floorItems2['128'] = i
+ w.create(TkcText,441.5,265.5, 'text'=>'128', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor1','label'])
+ i = TkcPolygon.new(w,510,309,486,309,486,255,530,255,
+ 552,277,561,277,561,325,510,325,
+ 'fill'=>'', 'tags'=>['floor1','room'])
+ $floorLabels2[i.id] = '129'
+ $floorItems2['129'] = i
+ w.create(TkcText,535.5,293, 'text'=>'129', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor1','label'])
+ i = TkcPolygon.new(w,696,281,740,281,740,387,642,387,
+ 642,389,561,389,561,277,696,277,
+ 'fill'=>'', 'tags'=>['floor1','room'])
+ $floorLabels2[i.id] = '133'
+ $floorItems2['133'] = i
+ w.create(TkcText,628.5,335, 'text'=>'133', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor1','label'])
+ i = TkcPolygon.new(w,742,387,742,281,800,281,800,387,
+ 'fill'=>'', 'tags'=>['floor1','room'])
+ $floorLabels2[i.id] = '132'
+ $floorItems2['132'] = i
+ w.create(TkcText,771,334, 'text'=>'132', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor1','label'])
+ i = TkcPolygon.new(w,800,168,800,280,699,280,699,168,
+ 'fill'=>'', 'tags'=>['floor1','room'])
+ $floorLabels2[i.id] = '134'
+ $floorItems2['134'] = i
+ w.create(TkcText,749.5,224, 'text'=>'134', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor1','label'])
+ i = TkcPolygon.new(w,726,131,726,166,800,166,800,131,
+ 'fill'=>'', 'tags'=>['floor1','room'])
+ $floorLabels2[i.id] = '135'
+ $floorItems2['135'] = i
+ w.create(TkcText,763,148.5, 'text'=>'135', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor1','label'])
+ i = TkcPolygon.new(w,340,360,335,363,331,365,326,366,304,366,
+ 304,312,396,312,396,288,400,288,404,288,
+ 409,290,413,292,418,297,421,302,422,309,
+ 421,318,417,325,411,330,405,332,397,333,
+ 344,333,340,334,336,336,335,338,332,342,
+ 331,347,332,351,334,354,336,357,341,359,
+ 'fill'=>'', 'tags'=>['floor1','room'])
+ $floorLabels2[i.id] = 'Ramona Stair'
+ $floorItems2['Ramona Stair'] = i
+ w.create(TkcText,368,323, 'text'=>'Ramona Stair', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor1','label'])
+ i = TkcPolygon.new(w,30,23,30,5,93,5,98,5,104,7,110,10,116,16,119,20,
+ 122,28,123,32,123,68,220,68,220,87,90,87,90,23,
+ 'fill'=>'', 'tags'=>['floor1','room'])
+ $floorLabels2[i.id] = 'University Stair'
+ $floorItems2['University Stair'] = i
+ w.create(TkcText,155,77.5, 'text'=>'University Stair', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor1','label'])
+ i = TkcPolygon.new(w,282,37,295,40,312,49,323,56,337,70,352,56,
+ 358,48,363,39,365,29,348,25,335,22,321,14,
+ 300,5,283,1,260,0,246,0,242,2,236,4,231,8,
+ 227,13,223,17,221,22,220,34,260,34,
+ 'fill'=>'', 'tags'=>['floor1','room'])
+ $floorLabels2[i.id] = 'Plaza Stair'
+ $floorItems2['Plaza Stair'] = i
+ w.create(TkcText,317.5,28.5, 'text'=>'Plaza Stair', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor1','label'])
+ i = TkcPolygon.new(w,220,34,260,34,282,37,295,40,312,49,
+ 323,56,337,70,350,83,365,94,377,100,
+ 386,104,386,128,220,128,
+ 'fill'=>'', 'tags'=>['floor1','room'])
+ $floorLabels2[i.id] = 'Plaza Deck'
+ $floorItems2['Plaza Deck'] = i
+ w.create(TkcText,303,81, 'text'=>'Plaza Deck', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor1','label'])
+ i = TkcPolygon.new(w,257,336,77,336,6,336,6,301,77,301,77,310,257,310,
+ 'fill'=>'', 'tags'=>['floor1','room'])
+ $floorLabels2[i.id] = '106'
+ $floorItems2['106'] = i
+ w.create(TkcText,131.5,318.5, 'text'=>'106', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor1','label'])
+ i = TkcPolygon.new(w,146,110,162,110,162,91,130,91,130,115,95,115,
+ 95,128,114,128,114,151,157,151,157,153,112,153,
+ 112,130,97,130,97,168,175,168,175,131,146,131,
+ 'fill'=>'', 'tags'=>['floor1','room'])
+ $floorLabels2[i.id] = '119'
+ $floorItems2['119'] = i
+ w.create(TkcText,143.5,133, 'text'=>'119', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor1','label'])
+ w.create(TkcLine,155,191,155,189, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,155,177,155,169, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,96,129,96,169, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,78,169,176,169, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,176,247,176,129, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,340,206,307,206, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,340,187,340,170, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,340,210,340,201, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,340,247,340,224, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,340,241,307,241, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,376,246,376,170, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,307,247,307,170, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,376,170,307,170, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,315,129,315,170, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,147,129,176,129, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,202,133,176,133, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,398,129,315,129, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,258,352,258,387, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,60,387,60,391, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,0,337,0,391, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,60,391,0,391, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,3,114,3,337, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,258,387,60,387, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,52,237,52,273, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,52,189,52,225, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,52,140,52,177, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,395,306,395,311, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,531,254,398,254, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,475,178,475,238, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,502,162,398,162, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,398,129,398,188, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,383,188,376,188, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,408,188,408,194, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,398,227,398,254, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,408,227,398,227, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,408,222,408,227, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,408,206,408,210, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,408,208,475,208, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,484,278,484,311, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,484,311,508,311, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,508,327,508,311, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,559,327,508,327, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,644,391,559,391, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,644,389,644,391, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,514,205,475,205, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,496,189,496,187, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,559,129,484,129, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,484,162,484,129, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,725,133,559,133, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,559,129,559,133, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,725,149,725,167, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,725,129,802,129, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,802,389,802,129, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,739,167,802,167, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,396,188,408,188, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,0,337,9,337, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,58,337,21,337, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,43,391,43,337, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,105,337,75,337, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,91,387,91,337, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,154,337,117,337, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,139,387,139,337, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,227,337,166,337, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,258,337,251,337, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,258,328,302,328, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,302,355,302,311, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,395,311,302,311, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,484,278,395,278, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,395,294,395,278, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,473,278,473,275, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,473,256,473,254, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,533,257,531,254, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,553,276,551,274, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,698,276,553,276, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,559,391,559,327, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,802,389,644,389, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,741,314,741,389, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,698,280,698,167, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,707,280,698,280, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,802,280,731,280, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,741,280,741,302, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,698,167,727,167, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,725,137,725,129, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,514,254,514,175, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,496,175,514,175, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,502,175,502,162, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,475,166,475,162, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,496,176,496,175, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,491,189,496,189, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,491,205,491,189, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,487,238,475,238, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,487,240,487,238, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,487,252,487,254, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,315,133,304,133, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,256,133,280,133, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,78,247,270,247, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,307,247,294,247, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,214,133,232,133, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,217,247,217,266, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,217,309,217,291, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,217,309,172,309, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,154,309,148,309, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,175,300,175,309, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,151,300,175,300, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,151,247,151,309, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,78,237,78,265, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,78,286,78,309, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,106,309,78,309, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,130,309,125,309, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,99,309,99,247, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,127,299,99,299, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,127,309,127,299, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,155,191,137,191, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,137,169,137,191, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,78,171,78,169, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,78,190,78,218, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,86,192,86,169, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,86,192,78,192, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,52,301,3,301, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,52,286,52,301, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,52,252,3,252, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,52,203,3,203, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,3,156,52,156, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,8,25,8,114, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,63,114,3,114, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,75,114,97,114, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,108,114,129,114, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,129,114,129,89, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,52,114,52,128, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,132,89,88,89, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,88,25,88,89, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,88,114,88,89, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,218,89,144,89, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,147,111,147,129, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,162,111,147,111, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,162,109,162,111, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,162,96,162,89, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,218,89,218,94, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,218,89,218,119, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,8,25,88,25, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,258,337,258,328, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,113,129,96,129, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,302,355,258,355, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,386,104,386,129, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,377,100,386,104, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,365,94,377,100, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,350,83,365,94, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,337,70,350,83, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,337,70,323,56, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,312,49,323,56, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,295,40,312,49, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,282,37,295,40, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,260,34,282,37, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,253,34,260,34, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,386,128,386,104, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,113,152,156,152, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,113,152,156,152, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,113,152,113,129, 'fill'=>color, 'tags'=>['floor1','wall'])
+end
+
+# floor2_fg2 --
+# This method represents part of the floorplan database. When
+# invoked, it instantiates the foreground information for the second
+# floor (office outlines and numbers).
+#
+# Arguments:
+# w - The canvas window.
+# color - Color to use for drawing foreground information.
+
+def floor2_fg2(w,color)
+ i = TkcPolygon.new(w,748,188,755,188,755,205,758,205,758,222,
+ 800,222,800,168,748,168,
+ 'fill'=>'', 'tags'=>['floor2','room'])
+ $floorLabels2[i.id] = '238'
+ $floorItems2['238'] = i
+ w.create(TkcText,774,195, 'text'=>'238', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor2','label'])
+ i = TkcPolygon.new(w,726,188,746,188,746,166,800,166,800,131,726,131,
+ 'fill'=>'', 'tags'=>['floor2','room'])
+ $floorLabels2[i.id] = '237'
+ $floorItems2['237'] = i
+ w.create(TkcText,763,148.5, 'text'=>'237', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor2','label'])
+ i = TkcPolygon.new(w,497,187,497,204,559,204,559,324,641,324,
+ 643,324,643,291,641,291,641,205,696,205,
+ 696,291,694,291,694,314,715,314,715,291,
+ 715,205,755,205,755,190,724,190,724,187,
+ 'fill'=>'', 'tags'=>['floor2','room'])
+ $floorLabels2[i.id] = '246'
+ $floorItems2['246'] = i
+ w.create(TkcText,600,264, 'text'=>'246', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor2','label'])
+ i = TkcPolygon.new(w,694,279,643,279,643,314,694,314,
+ 'fill'=>'', 'tags'=>['floor2','room'])
+ $floorLabels2[i.id] = '247'
+ $floorItems2['247'] = i
+ w.create(TkcText,668.5,296.5, 'text'=>'247', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor2','label'])
+ i = TkcPolygon.new(w,232,250,308,250,308,242,339,242,339,246,
+ 397,246,397,255,476,255,476,250,482,250,559,250,
+ 559,274,482,274,482,278,396,278,396,274,232,274,
+ 'fill'=>'', 'tags'=>['floor2','room'])
+ $floorLabels2[i.id] = '202'
+ $floorItems2['202'] = i
+ w.create(TkcText,285.5,260, 'text'=>'202', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor2','label'])
+ i = TkcPolygon.new(w,53,228,53,338,176,338,233,338,233,196,
+ 306,196,306,180,175,180,175,169,156,169,
+ 156,196,176,196,176,228,
+ 'fill'=>'', 'tags'=>['floor2','room'])
+ $floorLabels2[i.id] = '206'
+ $floorItems2['206'] = i
+ w.create(TkcText,143,267, 'text'=>'206', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor2','label'])
+ i = TkcPolygon.new(w,51,277,6,277,6,338,51,338,
+ 'fill'=>'', 'tags'=>['floor2','room'])
+ $floorLabels2[i.id] = '212'
+ $floorItems2['212'] = i
+ w.create(TkcText,28.5,307.5, 'text'=>'212', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor2','label'])
+ i = TkcPolygon.new(w,557,276,486,276,486,309,510,309,510,325,557,325,
+ 'fill'=>'', 'tags'=>['floor2','room'])
+ $floorLabels2[i.id] = '245'
+ $floorItems2['245'] = i
+ w.create(TkcText,521.5,300.5, 'text'=>'245', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor2','label'])
+ i = TkcPolygon.new(w,560,389,599,389,599,326,560,326,
+ 'fill'=>'', 'tags'=>['floor2','room'])
+ $floorLabels2[i.id] = '244'
+ $floorItems2['244'] = i
+ w.create(TkcText,579.5,357.5, 'text'=>'244', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor2','label'])
+ i = TkcPolygon.new(w,601,389,601,326,643,326,643,389,
+ 'fill'=>'', 'tags'=>['floor2','room'])
+ $floorLabels2[i.id] = '243'
+ $floorItems2['243'] = i
+ w.create(TkcText,622,357.5, 'text'=>'243', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor2','label'])
+ i = TkcPolygon.new(w,688,316,645,316,645,365,688,365,
+ 'fill'=>'', 'tags'=>['floor2','room'])
+ $floorLabels2[i.id] = '242'
+ $floorItems2['242'] = i
+ w.create(TkcText,666.5,340.5, 'text'=>'242', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor2','label'])
+ i = TkcPolygon.new(w,802,367,759,367,759,226,802,226,
+ 'fill'=>'', 'tags'=>['floor2','room'])
+ $floorLabels2[i.id] = 'Barbecue Deck'
+ $floorItems2['Barbecue Deck'] = i
+ w.create(TkcText,780.5,296.5, 'text'=>'Barbecue Deck', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor2','label'])
+ i = TkcPolygon.new(w,755,262,755,314,717,314,717,262,
+ 'fill'=>'', 'tags'=>['floor2','room'])
+ $floorLabels2[i.id] = '240'
+ $floorItems2['240'] = i
+ w.create(TkcText,736,288, 'text'=>'240', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor2','label'])
+ i = TkcPolygon.new(w,755,316,689,316,689,365,755,365,
+ 'fill'=>'', 'tags'=>['floor2','room'])
+ $floorLabels2[i.id] = '241'
+ $floorItems2['241'] = i
+ w.create(TkcText,722,340.5, 'text'=>'241', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor2','label'])
+ i = TkcPolygon.new(w,755,206,717,206,717,261,755,261,
+ 'fill'=>'', 'tags'=>['floor2','room'])
+ $floorLabels2[i.id] = '239'
+ $floorItems2['239'] = i
+ w.create(TkcText,736,233.5, 'text'=>'239', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor2','label'])
+ i = TkcPolygon.new(w,695,277,643,277,643,206,695,206,
+ 'fill'=>'', 'tags'=>['floor2','room'])
+ $floorLabels2[i.id] = '248'
+ $floorItems2['248'] = i
+ w.create(TkcText,669,241.5, 'text'=>'248', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor2','label'])
+ i = TkcPolygon.new(w,676,135,676,185,724,185,724,135,
+ 'fill'=>'', 'tags'=>['floor2','room'])
+ $floorLabels2[i.id] = '236'
+ $floorItems2['236'] = i
+ w.create(TkcText,700,160, 'text'=>'236', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor2','label'])
+ i = TkcPolygon.new(w,675,135,635,135,635,145,628,145,628,185,675,185,
+ 'fill'=>'', 'tags'=>['floor2','room'])
+ $floorLabels2[i.id] = '235'
+ $floorItems2['235'] = i
+ w.create(TkcText,651.5,160, 'text'=>'235', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor2','label'])
+ i = TkcPolygon.new(w,626,143,633,143,633,135,572,135,
+ 572,143,579,143,579,185,626,185,
+ 'fill'=>'', 'tags'=>['floor2','room'])
+ $floorLabels2[i.id] = '234'
+ $floorItems2['234'] = i
+ w.create(TkcText,606,160, 'text'=>'234', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor2','label'])
+ i = TkcPolygon.new(w,557,135,571,135,571,145,578,145,
+ 578,185,527,185,527,131,557,131,
+ 'fill'=>'', 'tags'=>['floor2','room'])
+ $floorLabels2[i.id] = '233'
+ $floorItems2['233'] = i
+ w.create(TkcText,552.5,158, 'text'=>'233', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor2','label'])
+ i = TkcPolygon.new(w,476,249,557,249,557,205,476,205,
+ 'fill'=>'', 'tags'=>['floor2','room'])
+ $floorLabels2[i.id] = '230'
+ $floorItems2['230'] = i
+ w.create(TkcText,516.5,227, 'text'=>'230', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor2','label'])
+ i = TkcPolygon.new(w,476,164,486,164,486,131,525,131,525,185,476,185,
+ 'fill'=>'', 'tags'=>['floor2','room'])
+ $floorLabels2[i.id] = '232'
+ $floorItems2['232'] = i
+ w.create(TkcText,500.5,158, 'text'=>'232', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor2','label'])
+ i = TkcPolygon.new(w,476,186,495,186,495,204,476,204,
+ 'fill'=>'', 'tags'=>['floor2','room'])
+ $floorLabels2[i.id] = '229'
+ $floorItems2['229'] = i
+ w.create(TkcText,485.5,195, 'text'=>'229', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor2','label'])
+ i = TkcPolygon.new(w,474,207,409,207,409,187,399,187,399,164,474,164,
+ 'fill'=>'', 'tags'=>['floor2','room'])
+ $floorLabels2[i.id] = '227'
+ $floorItems2['227'] = i
+ w.create(TkcText,436.5,185.5, 'text'=>'227', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor2','label'])
+ i = TkcPolygon.new(w,399,228,399,253,474,253,474,209,409,209,409,228,
+ 'fill'=>'', 'tags'=>['floor2','room'])
+ $floorLabels2[i.id] = '228'
+ $floorItems2['228'] = i
+ w.create(TkcText,436.5,231, 'text'=>'228', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor2','label'])
+ i = TkcPolygon.new(w,397,246,397,226,407,226,407,189,377,189,377,246,
+ 'fill'=>'', 'tags'=>['floor2','room'])
+ $floorLabels2[i.id] = '226'
+ $floorItems2['226'] = i
+ w.create(TkcText,392,217.5, 'text'=>'226', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor2','label'])
+ i = TkcPolygon.new(w,377,169,316,169,316,131,397,131,397,188,377,188,
+ 'fill'=>'', 'tags'=>['floor2','room'])
+ $floorLabels2[i.id] = '225'
+ $floorItems2['225'] = i
+ w.create(TkcText,356.5,150, 'text'=>'225', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor2','label'])
+ i = TkcPolygon.new(w,234,198,306,198,306,249,234,249,
+ 'fill'=>'', 'tags'=>['floor2','room'])
+ $floorLabels2[i.id] = '224'
+ $floorItems2['224'] = i
+ w.create(TkcText,270,223.5, 'text'=>'224', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor2','label'])
+ i = TkcPolygon.new(w,270,179,306,179,306,170,314,170,314,135,270,135,
+ 'fill'=>'', 'tags'=>['floor2','room'])
+ $floorLabels2[i.id] = '223'
+ $floorItems2['223'] = i
+ w.create(TkcText,292,157, 'text'=>'223', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor2','label'])
+ i = TkcPolygon.new(w,268,179,221,179,221,135,268,135,
+ 'fill'=>'', 'tags'=>['floor2','room'])
+ $floorLabels2[i.id] = '222'
+ $floorItems2['222'] = i
+ w.create(TkcText,244.5,157, 'text'=>'222', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor2','label'])
+ i = TkcPolygon.new(w,177,179,219,179,219,135,177,135,
+ 'fill'=>'', 'tags'=>['floor2','room'])
+ $floorLabels2[i.id] = '221'
+ $floorItems2['221'] = i
+ w.create(TkcText,198,157, 'text'=>'221', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor2','label'])
+ i = TkcPolygon.new(w,299,327,349,327,349,284,341,284,341,276,299,276,
+ 'fill'=>'', 'tags'=>['floor2','room'])
+ $floorLabels2[i.id] = '204'
+ $floorItems2['204'] = i
+ w.create(TkcText,324,301.5, 'text'=>'204', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor2','label'])
+ i = TkcPolygon.new(w,234,276,297,276,297,327,257,327,257,338,234,338,
+ 'fill'=>'', 'tags'=>['floor2','room'])
+ $floorLabels2[i.id] = '205'
+ $floorItems2['205'] = i
+ w.create(TkcText,265.5,307, 'text'=>'205', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor2','label'])
+ i = TkcPolygon.new(w,256,385,256,340,212,340,212,385,
+ 'fill'=>'', 'tags'=>['floor2','room'])
+ $floorLabels2[i.id] = '207'
+ $floorItems2['207'] = i
+ w.create(TkcText,234,362.5, 'text'=>'207', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor2','label'])
+ i = TkcPolygon.new(w,210,340,164,340,164,385,210,385,
+ 'fill'=>'', 'tags'=>['floor2','room'])
+ $floorLabels2[i.id] = '208'
+ $floorItems2['208'] = i
+ w.create(TkcText,187,362.5, 'text'=>'208', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor2','label'])
+ i = TkcPolygon.new(w,115,340,162,340,162,385,115,385,
+ 'fill'=>'', 'tags'=>['floor2','room'])
+ $floorLabels2[i.id] = '209'
+ $floorItems2['209'] = i
+ w.create(TkcText,138.5,362.5, 'text'=>'209', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor2','label'])
+ i = TkcPolygon.new(w,89,228,89,156,53,156,53,228,
+ 'fill'=>'', 'tags'=>['floor2','room'])
+ $floorLabels2[i.id] = '217'
+ $floorItems2['217'] = i
+ w.create(TkcText,71,192, 'text'=>'217', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor2','label'])
+ i = TkcPolygon.new(w,89,169,97,169,97,190,89,190,
+ 'fill'=>'', 'tags'=>['floor2','room'])
+ $floorLabels2[i.id] = '217A'
+ $floorItems2['217A'] = i
+ w.create(TkcText,93,179.5, 'text'=>'217A', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor2','label'])
+ i = TkcPolygon.new(w,89,156,89,168,95,168,95,135,53,135,53,156,
+ 'fill'=>'', 'tags'=>['floor2','room'])
+ $floorLabels2[i.id] = '216'
+ $floorItems2['216'] = i
+ w.create(TkcText,71,145.5, 'text'=>'216', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor2','label'])
+ i = TkcPolygon.new(w,51,179,51,135,6,135,6,179,
+ 'fill'=>'', 'tags'=>['floor2','room'])
+ $floorLabels2[i.id] = '215'
+ $floorItems2['215'] = i
+ w.create(TkcText,28.5,157, 'text'=>'215', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor2','label'])
+ i = TkcPolygon.new(w,51,227,6,227,6,180,51,180,
+ 'fill'=>'', 'tags'=>['floor2','room'])
+ $floorLabels2[i.id] = '214'
+ $floorItems2['214'] = i
+ w.create(TkcText,28.5,203.5, 'text'=>'214', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor2','label'])
+ i = TkcPolygon.new(w,51,275,6,275,6,229,51,229,
+ 'fill'=>'', 'tags'=>['floor2','room'])
+ $floorLabels2[i.id] = '213'
+ $floorItems2['213'] = i
+ w.create(TkcText,28.5,252, 'text'=>'213', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor2','label'])
+ i = TkcPolygon.new(w,114,340,67,340,67,385,114,385,
+ 'fill'=>'', 'tags'=>['floor2','room'])
+ $floorLabels2[i.id] = '210'
+ $floorItems2['210'] = i
+ w.create(TkcText,90.5,362.5, 'text'=>'210', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor2','label'])
+ i = TkcPolygon.new(w,59,389,59,385,65,385,65,340,1,340,1,389,
+ 'fill'=>'', 'tags'=>['floor2','room'])
+ $floorLabels2[i.id] = '211'
+ $floorItems2['211'] = i
+ w.create(TkcText,33,364.5, 'text'=>'211', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor2','label'])
+ i = TkcPolygon.new(w,393,309,350,309,350,282,342,282,342,276,393,276,
+ 'fill'=>'', 'tags'=>['floor2','room'])
+ $floorLabels2[i.id] = '203'
+ $floorItems2['203'] = i
+ w.create(TkcText,367.5,292.5, 'text'=>'203', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor2','label'])
+ i = TkcPolygon.new(w,99,191,91,191,91,226,174,226,174,198,
+ 154,198,154,192,109,192,109,169,99,169,
+ 'fill'=>'', 'tags'=>['floor2','room'])
+ $floorLabels2[i.id] = '220'
+ $floorItems2['220'] = i
+ w.create(TkcText,132.5,208.5, 'text'=>'220', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor2','label'])
+ i = TkcPolygon.new(w,339,205,307,205,307,171,339,171,
+ 'fill'=>'', 'tags'=>['floor2','room'])
+ $floorLabels2[i.id] = 'Priv Lift2'
+ $floorItems2['Priv Lift2'] = i
+ w.create(TkcText,323,188, 'text'=>'Priv Lift2', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor2','label'])
+ i = TkcPolygon.new(w,307,240,339,240,339,206,307,206,
+ 'fill'=>'', 'tags'=>['floor2','room'])
+ $floorLabels2[i.id] = 'Pub Lift 2'
+ $floorItems2['Pub Lift 2'] = i
+ w.create(TkcText,323,223, 'text'=>'Pub Lift 2', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor2','label'])
+ i = TkcPolygon.new(w,175,168,97,168,97,131,175,131,
+ 'fill'=>'', 'tags'=>['floor2','room'])
+ $floorLabels2[i.id] = '218'
+ $floorItems2['218'] = i
+ w.create(TkcText,136,149.5, 'text'=>'218', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor2','label'])
+ i = TkcPolygon.new(w,154,191,111,191,111,169,154,169,
+ 'fill'=>'', 'tags'=>['floor2','room'])
+ $floorLabels2[i.id] = '219'
+ $floorItems2['219'] = i
+ w.create(TkcText,132.5,180, 'text'=>'219', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor2','label'])
+ i = TkcPolygon.new(w,375,246,375,172,341,172,341,246,
+ 'fill'=>'', 'tags'=>['floor2','room'])
+ $floorLabels2[i.id] = '201'
+ $floorItems2['201'] = i
+ w.create(TkcText,358,209, 'text'=>'201', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor2','label'])
+ w.create(TkcLine,641,186,678,186, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,757,350,757,367, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,634,133,634,144, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,634,144,627,144, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,572,133,572,144, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,572,144,579,144, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,398,129,398,162, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,174,197,175,197, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,175,197,175,227, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,757,206,757,221, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,396,188,408,188, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,727,189,725,189, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,747,167,802,167, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,747,167,747,189, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,755,189,739,189, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,769,224,757,224, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,802,224,802,129, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,802,129,725,129, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,725,189,725,129, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,725,186,690,186, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,676,133,676,186, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,627,144,627,186, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,629,186,593,186, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,579,144,579,186, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,559,129,559,133, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,725,133,559,133, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,484,162,484,129, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,559,129,484,129, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,526,129,526,186, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,540,186,581,186, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,528,186,523,186, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,511,186,475,186, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,496,190,496,186, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,496,205,496,202, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,475,205,527,205, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,558,205,539,205, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,558,205,558,249, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,558,249,475,249, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,662,206,642,206, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,695,206,675,206, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,695,278,642,278, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,642,291,642,206, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,695,291,695,206, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,716,208,716,206, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,757,206,716,206, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,757,221,757,224, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,793,224,802,224, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,757,262,716,262, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,716,220,716,264, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,716,315,716,276, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,757,315,703,315, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,757,325,757,224, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,757,367,644,367, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,689,367,689,315, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,647,315,644,315, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,659,315,691,315, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,600,325,600,391, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,627,325,644,325, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,644,391,644,315, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,615,325,575,325, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,644,391,558,391, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,563,325,558,325, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,558,391,558,314, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,558,327,508,327, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,558,275,484,275, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,558,302,558,275, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,508,327,508,311, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,484,311,508,311, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,484,275,484,311, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,475,208,408,208, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,408,206,408,210, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,408,222,408,227, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,408,227,398,227, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,398,227,398,254, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,408,188,408,194, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,383,188,376,188, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,398,188,398,162, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,398,162,484,162, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,475,162,475,254, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,398,254,475,254, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,484,280,395,280, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,395,311,395,275, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,307,197,293,197, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,278,197,233,197, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,233,197,233,249, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,307,179,284,179, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,233,249,278,249, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,269,179,269,133, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,220,179,220,133, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,155,191,110,191, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,90,190,98,190, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,98,169,98,190, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,52,133,52,165, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,52,214,52,177, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,52,226,52,262, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,52,274,52,276, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,234,275,234,339, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,226,339,258,339, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,211,387,211,339, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,214,339,177,339, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,258,387,60,387, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,3,133,3,339, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,165,339,129,339, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,117,339,80,339, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,68,339,59,339, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,0,339,46,339, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,60,391,0,391, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,0,339,0,391, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,60,387,60,391, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,258,329,258,387, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,350,329,258,329, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,395,311,350,311, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,398,129,315,129, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,176,133,315,133, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,176,129,96,129, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,3,133,96,133, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,66,387,66,339, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,115,387,115,339, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,163,387,163,339, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,234,275,276,275, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,288,275,309,275, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,298,275,298,329, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,341,283,350,283, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,321,275,341,275, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,375,275,395,275, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,315,129,315,170, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,376,170,307,170, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,307,250,307,170, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,376,245,376,170, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,340,241,307,241, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,340,245,340,224, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,340,210,340,201, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,340,187,340,170, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,340,206,307,206, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,293,250,307,250, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,271,179,238,179, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,226,179,195,179, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,176,129,176,179, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,182,179,176,179, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,174,169,176,169, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,162,169,90,169, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,96,169,96,129, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,175,227,90,227, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,90,190,90,227, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,52,179,3,179, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,52,228,3,228, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,52,276,3,276, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,155,177,155,169, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,110,191,110,169, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,155,189,155,197, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,350,283,350,329, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,162,197,155,197, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,341,275,341,283, 'fill'=>color, 'tags'=>['floor2','wall'])
+end
+
+# floor2_fg3 --
+# This method represents part of the floorplan database. When
+# invoked, it instantiates the foreground information for the third
+# floor (office outlines and numbers).
+#
+# Arguments:
+# w - The canvas window.
+# color - Color to use for drawing foreground information.
+
+def floor2_fg3(w,color)
+ i = TkcPolygon.new(w,89,228,89,180,70,180,70,228,
+ 'fill'=>'', 'tags'=>['floor3','room'])
+ $floorLabels2[i.id] = '316'
+ $floorItems2['316'] = i
+ w.create(TkcText,79.5,204, 'text'=>'316', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor3','label'])
+ i = TkcPolygon.new(w,115,368,162,368,162,323,115,323,
+ 'fill'=>'', 'tags'=>['floor3','room'])
+ $floorLabels2[i.id] = '309'
+ $floorItems2['309'] = i
+ w.create(TkcText,138.5,345.5, 'text'=>'309', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor3','label'])
+ i = TkcPolygon.new(w,164,323,164,368,211,368,211,323,
+ 'fill'=>'', 'tags'=>['floor3','room'])
+ $floorLabels2[i.id] = '308'
+ $floorItems2['308'] = i
+ w.create(TkcText,187.5,345.5, 'text'=>'308', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor3','label'])
+ i = TkcPolygon.new(w,256,368,212,368,212,323,256,323,
+ 'fill'=>'', 'tags'=>['floor3','room'])
+ $floorLabels2[i.id] = '307'
+ $floorItems2['307'] = i
+ w.create(TkcText,234,345.5, 'text'=>'307', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor3','label'])
+ i = TkcPolygon.new(w,244,276,297,276,297,327,260,327,260,321,244,321,
+ 'fill'=>'', 'tags'=>['floor3','room'])
+ $floorLabels2[i.id] = '305'
+ $floorItems2['305'] = i
+ w.create(TkcText,270.5,301.5, 'text'=>'305', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor3','label'])
+ i = TkcPolygon.new(w,251,219,251,203,244,203,244,219,
+ 'fill'=>'', 'tags'=>['floor3','room'])
+ $floorLabels2[i.id] = '324B'
+ $floorItems2['324B'] = i
+ w.create(TkcText,247.5,211, 'text'=>'324B', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor3','label'])
+ i = TkcPolygon.new(w,251,249,244,249,244,232,251,232,
+ 'fill'=>'', 'tags'=>['floor3','room'])
+ $floorLabels2[i.id] = '324A'
+ $floorItems2['324A'] = i
+ w.create(TkcText,247.5,240.5, 'text'=>'324A', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor3','label'])
+ i = TkcPolygon.new(w,223,135,223,179,177,179,177,135,
+ 'fill'=>'', 'tags'=>['floor3','room'])
+ $floorLabels2[i.id] = '320'
+ $floorItems2['320'] = i
+ w.create(TkcText,200,157, 'text'=>'320', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor3','label'])
+ i = TkcPolygon.new(w,114,368,114,323,67,323,67,368,
+ 'fill'=>'', 'tags'=>['floor3','room'])
+ $floorLabels2[i.id] = '310'
+ $floorItems2['310'] = i
+ w.create(TkcText,90.5,345.5, 'text'=>'310', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor3','label'])
+ i = TkcPolygon.new(w,23,277,23,321,68,321,68,277,
+ 'fill'=>'', 'tags'=>['floor3','room'])
+ $floorLabels2[i.id] = '312'
+ $floorItems2['312'] = i
+ w.create(TkcText,45.5,299, 'text'=>'312', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor3','label'])
+ i = TkcPolygon.new(w,23,229,68,229,68,275,23,275,
+ 'fill'=>'', 'tags'=>['floor3','room'])
+ $floorLabels2[i.id] = '313'
+ $floorItems2['313'] = i
+ w.create(TkcText,45.5,252, 'text'=>'313', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor3','label'])
+ i = TkcPolygon.new(w,68,227,23,227,23,180,68,180,
+ 'fill'=>'', 'tags'=>['floor3','room'])
+ $floorLabels2[i.id] = '314'
+ $floorItems2['314'] = i
+ w.create(TkcText,40.5,203.5, 'text'=>'314', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor3','label'])
+ i = TkcPolygon.new(w,95,179,95,135,23,135,23,179,
+ 'fill'=>'', 'tags'=>['floor3','room'])
+ $floorLabels2[i.id] = '315'
+ $floorItems2['315'] = i
+ w.create(TkcText,59,157, 'text'=>'315', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor3','label'])
+ i = TkcPolygon.new(w,99,226,99,204,91,204,91,226,
+ 'fill'=>'', 'tags'=>['floor3','room'])
+ $floorLabels2[i.id] = '316B'
+ $floorItems2['316B'] = i
+ w.create(TkcText,95,215, 'text'=>'316B', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor3','label'])
+ i = TkcPolygon.new(w,91,202,99,202,99,180,91,180,
+ 'fill'=>'', 'tags'=>['floor3','room'])
+ $floorLabels2[i.id] = '316A'
+ $floorItems2['316A'] = i
+ w.create(TkcText,95,191, 'text'=>'316A', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor3','label'])
+ i = TkcPolygon.new(w,97,169,109,169,109,192,154,192,154,198,
+ 174,198,174,226,101,226,101,179,97,179,
+ 'fill'=>'', 'tags'=>['floor3','room'])
+ $floorLabels2[i.id] = '319'
+ $floorItems2['319'] = i
+ w.create(TkcText,141.5,209, 'text'=>'319', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor3','label'])
+ i = TkcPolygon.new(w,65,368,58,368,58,389,1,389,1,333,23,333,23,323,65,323,
+ 'fill'=>'', 'tags'=>['floor3','room'])
+ $floorLabels2[i.id] = '311'
+ $floorItems2['311'] = i
+ w.create(TkcText,29.5,361, 'text'=>'311', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor3','label'])
+ i = TkcPolygon.new(w,154,191,111,191,111,169,154,169,
+ 'fill'=>'', 'tags'=>['floor3','room'])
+ $floorLabels2[i.id] = '318'
+ $floorItems2['318'] = i
+ w.create(TkcText,132.5,180, 'text'=>'318', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor3','label'])
+ i = TkcPolygon.new(w,175,168,97,168,97,131,175,131,
+ 'fill'=>'', 'tags'=>['floor3','room'])
+ $floorLabels2[i.id] = '317'
+ $floorItems2['317'] = i
+ w.create(TkcText,136,149.5, 'text'=>'317', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor3','label'])
+ i = TkcPolygon.new(w,274,194,274,221,306,221,306,194,
+ 'fill'=>'', 'tags'=>['floor3','room'])
+ $floorLabels2[i.id] = '323'
+ $floorItems2['323'] = i
+ w.create(TkcText,290,207.5, 'text'=>'323', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor3','label'])
+ i = TkcPolygon.new(w,306,222,274,222,274,249,306,249,
+ 'fill'=>'', 'tags'=>['floor3','room'])
+ $floorLabels2[i.id] = '325'
+ $floorItems2['325'] = i
+ w.create(TkcText,290,235.5, 'text'=>'325', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor3','label'])
+ i = TkcPolygon.new(w,263,179,224,179,224,135,263,135,
+ 'fill'=>'', 'tags'=>['floor3','room'])
+ $floorLabels2[i.id] = '321'
+ $floorItems2['321'] = i
+ w.create(TkcText,243.5,157, 'text'=>'321', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor3','label'])
+ i = TkcPolygon.new(w,314,169,306,169,306,192,273,192,
+ 264,181,264,135,314,135,
+ 'fill'=>'', 'tags'=>['floor3','room'])
+ $floorLabels2[i.id] = '322'
+ $floorItems2['322'] = i
+ w.create(TkcText,293.5,163.5, 'text'=>'322', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor3','label'])
+ i = TkcPolygon.new(w,307,240,339,240,339,206,307,206,
+ 'fill'=>'', 'tags'=>['floor3','room'])
+ $floorLabels2[i.id] = 'Pub Lift3'
+ $floorItems2['Pub Lift3'] = i
+ w.create(TkcText,323,223, 'text'=>'Pub Lift3', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor3','label'])
+ i = TkcPolygon.new(w,339,205,307,205,307,171,339,171,
+ 'fill'=>'', 'tags'=>['floor3','room'])
+ $floorLabels2[i.id] = 'Priv Lift3'
+ $floorItems2['Priv Lift3'] = i
+ w.create(TkcText,323,188, 'text'=>'Priv Lift3', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor3','label'])
+ i = TkcPolygon.new(w,350,284,376,284,376,276,397,276,397,309,350,309,
+ 'fill'=>'', 'tags'=>['floor3','room'])
+ $floorLabels2[i.id] = '303'
+ $floorItems2['303'] = i
+ w.create(TkcText,373.5,292.5, 'text'=>'303', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor3','label'])
+ i = TkcPolygon.new(w,272,203,272,249,252,249,252,230,
+ 244,230,244,221,252,221,252,203,
+ 'fill'=>'', 'tags'=>['floor3','room'])
+ $floorLabels2[i.id] = '324'
+ $floorItems2['324'] = i
+ w.create(TkcText,262,226, 'text'=>'324', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor3','label'])
+ i = TkcPolygon.new(w,299,276,299,327,349,327,349,284,341,284,341,276,
+ 'fill'=>'', 'tags'=>['floor3','room'])
+ $floorLabels2[i.id] = '304'
+ $floorItems2['304'] = i
+ w.create(TkcText,324,301.5, 'text'=>'304', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor3','label'])
+ i = TkcPolygon.new(w,375,246,375,172,341,172,341,246,
+ 'fill'=>'', 'tags'=>['floor3','room'])
+ $floorLabels2[i.id] = '301'
+ $floorItems2['301'] = i
+ w.create(TkcText,358,209, 'text'=>'301', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor3','label'])
+ i = TkcPolygon.new(w,397,246,377,246,377,185,397,185,
+ 'fill'=>'', 'tags'=>['floor3','room'])
+ $floorLabels2[i.id] = '327'
+ $floorItems2['327'] = i
+ w.create(TkcText,387,215.5, 'text'=>'327', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor3','label'])
+ i = TkcPolygon.new(w,316,131,316,169,377,169,377,185,397,185,397,131,
+ 'fill'=>'', 'tags'=>['floor3','room'])
+ $floorLabels2[i.id] = '326'
+ $floorItems2['326'] = i
+ w.create(TkcText,365.5,150, 'text'=>'326', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor3','label'])
+ i = TkcPolygon.new(w,308,251,242,251,242,274,342,274,342,282,375, 282,
+ 375,274,397,274,397,248,339,248,339,242,308,242,
+ 'fill'=>'', 'tags'=>['floor3','room'])
+ $floorLabels2[i.id] = '302'
+ $floorItems2['302'] = i
+ w.create(TkcText,319.5,261, 'text'=>'302', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor3','label'])
+ i = TkcPolygon.new(w,70,321,242,321,242,200,259,200,259,203,272,203,
+ 272,193,263,180,242,180,175,180,175,169,156,169,
+ 156,196,177,196,177,228,107,228,70,228,70,275,107,275,
+ 107,248,160,248,160,301,107,301,107,275,70,275,
+ 'fill'=>'', 'tags'=>['floor3','room'])
+ $floorLabels2[i.id] = '306'
+ $floorItems2['306'] = i
+ w.create(TkcText,200.5,284.5, 'text'=>'306', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor3','label'])
+ w.create(TkcLine,341,275,341,283, 'fill'=>color, 'tags'=>['floor3','wall'])
+ w.create(TkcLine,162,197,155,197, 'fill'=>color, 'tags'=>['floor3','wall'])
+ w.create(TkcLine,396,247,399,247, 'fill'=>color, 'tags'=>['floor3','wall'])
+ w.create(TkcLine,399,129,399,311, 'fill'=>color, 'tags'=>['floor3','wall'])
+ w.create(TkcLine,258,202,243,202, 'fill'=>color, 'tags'=>['floor3','wall'])
+ w.create(TkcLine,350,283,350,329, 'fill'=>color, 'tags'=>['floor3','wall'])
+ w.create(TkcLine,251,231,243,231, 'fill'=>color, 'tags'=>['floor3','wall'])
+ w.create(TkcLine,243,220,251,220, 'fill'=>color, 'tags'=>['floor3','wall'])
+ w.create(TkcLine,243,250,243,202, 'fill'=>color, 'tags'=>['floor3','wall'])
+ w.create(TkcLine,155,197,155,190, 'fill'=>color, 'tags'=>['floor3','wall'])
+ w.create(TkcLine,110,192,110,169, 'fill'=>color, 'tags'=>['floor3','wall'])
+ w.create(TkcLine,155,192,110,192, 'fill'=>color, 'tags'=>['floor3','wall'])
+ w.create(TkcLine,155,177,155,169, 'fill'=>color, 'tags'=>['floor3','wall'])
+ w.create(TkcLine,176,197,176,227, 'fill'=>color, 'tags'=>['floor3','wall'])
+ w.create(TkcLine,69,280,69,274, 'fill'=>color, 'tags'=>['floor3','wall'])
+ w.create(TkcLine,21,276,69,276, 'fill'=>color, 'tags'=>['floor3','wall'])
+ w.create(TkcLine,69,262,69,226, 'fill'=>color, 'tags'=>['floor3','wall'])
+ w.create(TkcLine,21,228,69,228, 'fill'=>color, 'tags'=>['floor3','wall'])
+ w.create(TkcLine,21,179,75,179, 'fill'=>color, 'tags'=>['floor3','wall'])
+ w.create(TkcLine,69,179,69,214, 'fill'=>color, 'tags'=>['floor3','wall'])
+ w.create(TkcLine,90,220,90,227, 'fill'=>color, 'tags'=>['floor3','wall'])
+ w.create(TkcLine,90,204,90,202, 'fill'=>color, 'tags'=>['floor3','wall'])
+ w.create(TkcLine,90,203,100,203, 'fill'=>color, 'tags'=>['floor3','wall'])
+ w.create(TkcLine,90,187,90,179, 'fill'=>color, 'tags'=>['floor3','wall'])
+ w.create(TkcLine,90,227,176,227, 'fill'=>color, 'tags'=>['floor3','wall'])
+ w.create(TkcLine,100,179,100,227, 'fill'=>color, 'tags'=>['floor3','wall'])
+ w.create(TkcLine,100,179,87,179, 'fill'=>color, 'tags'=>['floor3','wall'])
+ w.create(TkcLine,96,179,96,129, 'fill'=>color, 'tags'=>['floor3','wall'])
+ w.create(TkcLine,162,169,96,169, 'fill'=>color, 'tags'=>['floor3','wall'])
+ w.create(TkcLine,173,169,176,169, 'fill'=>color, 'tags'=>['floor3','wall'])
+ w.create(TkcLine,182,179,176,179, 'fill'=>color, 'tags'=>['floor3','wall'])
+ w.create(TkcLine,176,129,176,179, 'fill'=>color, 'tags'=>['floor3','wall'])
+ w.create(TkcLine,195,179,226,179, 'fill'=>color, 'tags'=>['floor3','wall'])
+ w.create(TkcLine,224,133,224,179, 'fill'=>color, 'tags'=>['floor3','wall'])
+ w.create(TkcLine,264,179,264,133, 'fill'=>color, 'tags'=>['floor3','wall'])
+ w.create(TkcLine,238,179,264,179, 'fill'=>color, 'tags'=>['floor3','wall'])
+ w.create(TkcLine,273,207,273,193, 'fill'=>color, 'tags'=>['floor3','wall'])
+ w.create(TkcLine,273,235,273,250, 'fill'=>color, 'tags'=>['floor3','wall'])
+ w.create(TkcLine,273,224,273,219, 'fill'=>color, 'tags'=>['floor3','wall'])
+ w.create(TkcLine,273,193,307,193, 'fill'=>color, 'tags'=>['floor3','wall'])
+ w.create(TkcLine,273,222,307,222, 'fill'=>color, 'tags'=>['floor3','wall'])
+ w.create(TkcLine,273,250,307,250, 'fill'=>color, 'tags'=>['floor3','wall'])
+ w.create(TkcLine,384,247,376,247, 'fill'=>color, 'tags'=>['floor3','wall'])
+ w.create(TkcLine,340,206,307,206, 'fill'=>color, 'tags'=>['floor3','wall'])
+ w.create(TkcLine,340,187,340,170, 'fill'=>color, 'tags'=>['floor3','wall'])
+ w.create(TkcLine,340,210,340,201, 'fill'=>color, 'tags'=>['floor3','wall'])
+ w.create(TkcLine,340,247,340,224, 'fill'=>color, 'tags'=>['floor3','wall'])
+ w.create(TkcLine,340,241,307,241, 'fill'=>color, 'tags'=>['floor3','wall'])
+ w.create(TkcLine,376,247,376,170, 'fill'=>color, 'tags'=>['floor3','wall'])
+ w.create(TkcLine,307,250,307,170, 'fill'=>color, 'tags'=>['floor3','wall'])
+ w.create(TkcLine,376,170,307,170, 'fill'=>color, 'tags'=>['floor3','wall'])
+ w.create(TkcLine,315,129,315,170, 'fill'=>color, 'tags'=>['floor3','wall'])
+ w.create(TkcLine,376,283,366,283, 'fill'=>color, 'tags'=>['floor3','wall'])
+ w.create(TkcLine,376,283,376,275, 'fill'=>color, 'tags'=>['floor3','wall'])
+ w.create(TkcLine,399,275,376,275, 'fill'=>color, 'tags'=>['floor3','wall'])
+ w.create(TkcLine,341,275,320,275, 'fill'=>color, 'tags'=>['floor3','wall'])
+ w.create(TkcLine,341,283,350,283, 'fill'=>color, 'tags'=>['floor3','wall'])
+ w.create(TkcLine,298,275,298,329, 'fill'=>color, 'tags'=>['floor3','wall'])
+ w.create(TkcLine,308,275,298,275, 'fill'=>color, 'tags'=>['floor3','wall'])
+ w.create(TkcLine,243,322,243,275, 'fill'=>color, 'tags'=>['floor3','wall'])
+ w.create(TkcLine,243,275,284,275, 'fill'=>color, 'tags'=>['floor3','wall'])
+ w.create(TkcLine,258,322,226,322, 'fill'=>color, 'tags'=>['floor3','wall'])
+ w.create(TkcLine,212,370,212,322, 'fill'=>color, 'tags'=>['floor3','wall'])
+ w.create(TkcLine,214,322,177,322, 'fill'=>color, 'tags'=>['floor3','wall'])
+ w.create(TkcLine,163,370,163,322, 'fill'=>color, 'tags'=>['floor3','wall'])
+ w.create(TkcLine,165,322,129,322, 'fill'=>color, 'tags'=>['floor3','wall'])
+ w.create(TkcLine,84,322,117,322, 'fill'=>color, 'tags'=>['floor3','wall'])
+ w.create(TkcLine,71,322,64,322, 'fill'=>color, 'tags'=>['floor3','wall'])
+ w.create(TkcLine,115,322,115,370, 'fill'=>color, 'tags'=>['floor3','wall'])
+ w.create(TkcLine,66,322,66,370, 'fill'=>color, 'tags'=>['floor3','wall'])
+ w.create(TkcLine,52,322,21,322, 'fill'=>color, 'tags'=>['floor3','wall'])
+ w.create(TkcLine,21,331,0,331, 'fill'=>color, 'tags'=>['floor3','wall'])
+ w.create(TkcLine,21,331,21,133, 'fill'=>color, 'tags'=>['floor3','wall'])
+ w.create(TkcLine,96,133,21,133, 'fill'=>color, 'tags'=>['floor3','wall'])
+ w.create(TkcLine,176,129,96,129, 'fill'=>color, 'tags'=>['floor3','wall'])
+ w.create(TkcLine,315,133,176,133, 'fill'=>color, 'tags'=>['floor3','wall'])
+ w.create(TkcLine,315,129,399,129, 'fill'=>color, 'tags'=>['floor3','wall'])
+ w.create(TkcLine,399,311,350,311, 'fill'=>color, 'tags'=>['floor3','wall'])
+ w.create(TkcLine,350,329,258,329, 'fill'=>color, 'tags'=>['floor3','wall'])
+ w.create(TkcLine,258,322,258,370, 'fill'=>color, 'tags'=>['floor3','wall'])
+ w.create(TkcLine,60,370,258,370, 'fill'=>color, 'tags'=>['floor3','wall'])
+ w.create(TkcLine,60,370,60,391, 'fill'=>color, 'tags'=>['floor3','wall'])
+ w.create(TkcLine,0,391,0,331, 'fill'=>color, 'tags'=>['floor3','wall'])
+ w.create(TkcLine,60,391,0,391, 'fill'=>color, 'tags'=>['floor3','wall'])
+ w.create(TkcLine,307,250,307,242, 'fill'=>color, 'tags'=>['floor3','wall'])
+ w.create(TkcLine,273,250,307,250, 'fill'=>color, 'tags'=>['floor3','wall'])
+ w.create(TkcLine,258,250,243,250, 'fill'=>color, 'tags'=>['floor3','wall'])
+end
+
+# Below is the "main program" that creates the floorplan demonstration.
+
+# toplevel widget
+if defined?($floor2_demo) && $floor2_demo
+ $floor2_demo.destroy
+ $floor2_demo = nil
+end
+
+# demo toplevel widget
+$floor2_demo = TkToplevel.new {|w|
+ title("Floorplan Canvas Demonstration 2")
+ iconname("Floorplan2")
+ positionWindow(w)
+ geometry('+20+20')
+ minsize(100,100)
+}
+
+base_frame = TkFrame.new($floor2_demo).pack(:fill=>:both, :expand=>true)
+
+# label
+TkLabel.new(base_frame, 'font'=>$font, 'wraplength'=>'8i', 'justify'=>'left',
+ 'text'=>"This window contains a canvas widget showing the floorplan of Digital Equipment Corporation's Western Research Laboratory. It has three levels. At any given time one of the levels is active, meaning that you can see its room structure. To activate a level, click the left mouse button anywhere on it. As the mouse moves over the active level, the room under the mouse lights up and its room number appears in the \"Room:\" entry. You can also type a room number in the entry and the room will light up."){
+ pack('side'=>'top')
+}
+
+# frame
+$floor2_buttons = TkFrame.new(base_frame) {|frame|
+ TkButton.new(frame) {
+ text 'Dismiss'
+ command proc{
+ tmppath = $floor2_demo
+ $floor2_demo = nil
+ tmppath.destroy
+ }
+ }.pack('side'=>'left', 'expand'=>'yes')
+
+ TkButton.new(frame) {
+ text 'Show Code'
+ command proc{showCode 'floor2'}
+ }.pack('side'=>'left', 'expand'=>'yes')
+}
+$floor2_buttons.pack('side'=>'bottom', 'fill'=>'x', 'pady'=>'2m')
+
+#
+$floorLabels2 = {}
+$floorItems2 = {}
+
+# canvas
+if $tk_version =~ /^4\.[01]/
+ $floor2_canvas_frame = TkFrame.new(base_frame,'bd'=>2,'relief'=>'sunken',
+ 'highlightthickness'=>2)
+ $floor2_canvas = TkCanvas.new($floor2_canvas_frame,
+ 'width'=>900, 'height'=>500, 'borderwidth'=>0,
+ 'highlightthickness'=>0) {|c|
+ TkScrollbar.new(base_frame, 'orient'=>'horiz',
+ 'command'=>proc{|*args| c.xview(*args)}){|hs|
+ c.xscrollcommand(proc{|first,last| hs.set first,last})
+ pack('side'=>'bottom', 'fill'=>'x')
+ }
+ TkScrollbar.new(base_frame, 'command'=>proc{|*args| c.yview(*args)}){|vs|
+ c.yscrollcommand(proc{|first,last| vs.set first,last})
+ pack('side'=>'right', 'fill'=>'y')
+ }
+ }
+ $floor2_canvas_frame.pack('side'=>'top','fill'=>'both', 'expand'=>'yes')
+ $floor2_canvas.pack('expand'=>'yes', 'fill'=>'both')
+
+else
+ TkFrame.new(base_frame) {|f|
+ pack('side'=>'top', 'fill'=>'both', 'expand'=>'yes')
+
+ h = TkScrollbar.new(f, 'highlightthickness'=>0, 'orient'=>'horizontal')
+ v = TkScrollbar.new(f, 'highlightthickness'=>0, 'orient'=>'vertical')
+
+ TkFrame.new(f, 'bd'=>2, 'relief'=>'sunken') {|f1|
+ $floor2_canvas = TkCanvas.new(f1, 'width'=>900, 'height'=>500,
+ 'borderwidth'=>0,
+ 'highlightthickness'=>0) {
+ xscrollcommand(proc{|first,last| h.set first,last})
+ yscrollcommand(proc{|first,last| v.set first,last})
+ pack('expand'=>'yes', 'fill'=>'both')
+ }
+ grid('padx'=>1, 'pady'=>1, 'row'=>0, 'column'=>0,
+ 'rowspan'=>1, 'columnspan'=>1, 'sticky'=>'news')
+ }
+
+ v.grid('padx'=>1, 'pady'=>1, 'row'=>0, 'column'=>1,
+ 'rowspan'=>1, 'columnspan'=>1, 'sticky'=>'news')
+ h.grid('padx'=>1, 'pady'=>1, 'row'=>1, 'column'=>0,
+ 'rowspan'=>1, 'columnspan'=>1, 'sticky'=>'news')
+
+ TkGrid.rowconfigure(f, 0, 'weight'=>1, 'minsize'=>0)
+ TkGrid.columnconfigure(f, 0, 'weight'=>1, 'minsize'=>0)
+
+ pack('expand'=>'yes', 'fill'=>'both', 'padx'=>1, 'pady'=>1)
+
+ v.command(proc{|*args| $floor2_canvas.yview(*args)})
+ h.command(proc{|*args| $floor2_canvas.xview(*args)})
+ }
+end
+
+
+# Create an entry for displaying and typing in current room.
+
+$currentRoom2 = TkVariable.new
+$floor2_entry = TkEntry.new($floor2_canvas, 'width'=>10, 'relief'=>'sunken',
+ 'bd'=>2, 'textvariable'=>$currentRoom2)
+
+# Choose colors, then fill in the floorplan.
+
+$floor2_colors = {}
+if TkWinfo.depth($floor2_canvas) > 1
+ $floor2_colors['bg1'] = '#a9c1da'
+ $floor2_colors['outline1'] = '#77889a'
+ $floor2_colors['bg2'] = '#9ab0c6'
+ $floor2_colors['outline2'] = '#687786'
+ $floor2_colors['bg3'] = '#8ba0b3'
+ $floor2_colors['outline3'] = '#596673'
+ $floor2_colors['offices'] = 'Black'
+ $floor2_colors['active'] = '#c4d1df'
+else
+ $floor2_colors['bg1'] = 'white'
+ $floor2_colors['outline1'] = 'black'
+ $floor2_colors['bg2'] = 'white'
+ $floor2_colors['outline2'] = 'black'
+ $floor2_colors['bg3'] = 'white'
+ $floor2_colors['outline3'] = 'black'
+ $floor2_colors['offices'] = 'Black'
+ $floor2_colors['active'] = 'black'
+end
+
+$activeFloor2 = ''
+floorDisplay2 $floor2_canvas,3
+
+# Set up event bindings for canvas:
+
+$floor2_canvas.itembind('floor1', '1', proc{floorDisplay2 $floor2_canvas,1})
+$floor2_canvas.itembind('floor2', '1', proc{floorDisplay2 $floor2_canvas,2})
+$floor2_canvas.itembind('floor3', '1', proc{floorDisplay2 $floor2_canvas,3})
+$floor2_canvas.itembind('room', 'Enter', proc{newRoom2 $floor2_canvas})
+$floor2_canvas.itembind('room', 'Leave', proc{$currentRoom2.value = ''})
+$floor2_canvas.bind('2', proc{|x,y| $floor2_canvas.scan_mark x,y}, '%x %y')
+$floor2_canvas.bind('B2-Motion',
+ proc{|x,y| $floor2_canvas.scan_dragto x,y}, '%x %y')
+$floor2_canvas.bind('Destroy', proc{$currentRoom2.unset})
+$currentRoom2.value = ''
+$currentRoom2.trace('w',proc{roomChanged2 $floor2_canvas})
diff --git a/jni/ruby/ext/tk/sample/demos-en/form.rb b/jni/ruby/ext/tk/sample/demos-en/form.rb
new file mode 100644
index 0000000..abb3e0e
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/demos-en/form.rb
@@ -0,0 +1,64 @@
+#
+# form widget demo (called by 'widget')
+#
+
+# toplevel widget
+if defined?($form_demo) && $form_demo
+ $form_demo.destroy
+ $form_demo = nil
+end
+
+# demo toplevel widget
+$form_demo = TkToplevel.new {|w|
+ title("Form Demonstration")
+ iconname("form")
+ positionWindow(w)
+}
+
+base_frame = TkFrame.new($form_demo).pack(:fill=>:both, :expand=>true)
+
+# label
+msg = TkLabel.new(base_frame) {
+ font $font
+ wraplength '4i'
+ justify 'left'
+ text "This window contains a simple form where you can type in the various entries and use tabs to move circularly between the entries."
+}
+msg.pack('side'=>'top', 'fill'=>'x')
+
+# frame
+TkFrame.new(base_frame) {|frame|
+ TkButton.new(frame) {
+ text 'Dismiss'
+ command proc{
+ tmppath = $form_demo
+ $form_demo = nil
+ tmppath.destroy
+ }
+ }.pack('side'=>'left', 'expand'=>'yes')
+
+ TkButton.new(frame) {
+ text 'Show Code'
+ command proc{showCode 'form'}
+ }.pack('side'=>'left', 'expand'=>'yes')
+}.pack('side'=>'bottom', 'fill'=>'x', 'pady'=>'2m')
+
+# entry
+form_data = []
+(1..5).each{|i|
+ f = TkFrame.new(base_frame, 'bd'=>2)
+ e = TkEntry.new(f, 'relief'=>'sunken', 'width'=>40)
+ l = TkLabel.new(f)
+ e.pack('side'=>'right')
+ l.pack('side'=>'left')
+ form_data[i] = {'frame'=>f, 'entry'=>e, 'label'=>l}
+}
+
+#
+form_data[1]['label'].text('Name:')
+form_data[2]['label'].text('Address:')
+form_data[5]['label'].text('Phone:')
+
+# pack
+(1..5).each{|i| form_data[i]['frame'].pack('side'=>'top', 'fill'=>'x')}
+
diff --git a/jni/ruby/ext/tk/sample/demos-en/goldberg.rb b/jni/ruby/ext/tk/sample/demos-en/goldberg.rb
new file mode 100644
index 0000000..d3956ef
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/demos-en/goldberg.rb
@@ -0,0 +1,2006 @@
+#
+# Ruby/Tk Goldverg demo (called by 'widget')
+#
+# Based on Tcl/Tk8.5a2 widget demos.
+# The following is the original comment of TkGoldberg.tcl.
+#
+#>>##+#################################################################
+#>>#
+#>># TkGoldberg.tcl
+#>># by Keith Vetter, March 13, 2003
+#>>#
+#>># "Man will always find a difficult means to perform a simple task"
+#>># Rube Goldberg
+#>>#
+#>># Reproduced here with permission.
+#>>#
+#>>##+#################################################################
+#>>#
+#>># Keith Vetter 2003-03-21: this started out as a simple little program
+#>># but was so much fun that it grew and grew. So I apologize about the
+#>># size but I just couldn't resist sharing it.
+#>>#
+#>># This is a whizzlet that does a Rube Goldberg type animation, the
+#>># design of which comes from an New Years e-card from IncrediMail.
+#>># That version had nice sound effects which I eschewed. On the other
+#>># hand, that version was in black and white (actually dark blue and
+#>># light blue) and this one is fully colorized.
+#>>#
+#>># One thing I learned from this project is that drawing filled complex
+#>># objects on a canvas is really hard. More often than not I had to
+#>># draw each item twice--once with the desired fill color but no
+#>># outline, and once with no fill but with the outline. Another trick
+#>># is erasing by drawing with the background color. Having a flood fill
+#>># command would have been extremely helpful.
+#>>#
+#>># Two wiki pages were extremely helpful: Drawing rounded rectangles
+#>># which I generalized into Drawing rounded polygons, and regular
+#>># polygons which allowed me to convert ovals and arcs into polygons
+#>># which could then be rotated (see Canvas Rotation). I also wrote
+#>># Named Colors to aid in the color selection.
+#>>#
+#>># I could comment on the code, but it's just 26 state machines with
+#>># lots of canvas create and move calls.
+
+if defined?($goldberg_demo) && $goldberg_demo
+ $goldberg_demo.destroy
+ $goldberg_demo = nil
+end
+
+# demo toplevel widget
+$goldberg_demo = TkToplevel.new {|w|
+ title("Tk Goldberg (demonstration)")
+ iconname("goldberg")
+# positionWindow(w)
+}
+
+base_frame = TkFrame.new($goldberg_demo).pack(:fill=>:both, :expand=>true)
+
+=begin
+# label
+msg = TkLabel.new($goldberg_demo) {
+ font 'Arial 10'
+ wraplength '4i'
+ justify 'left'
+ text "This is a demonstration of just how complex you can make your animations become. Click the ball to start things moving!\n\n\"Man will always find a difficult means to perform a simple task\"\n - Rube Goldberg"
+}
+msg.pack('side'=>'top')
+=end
+
+=begin
+# frame
+TkFrame.new($goldberg_demo) {|frame|
+ TkButton.new(frame) {
+ text 'Dismiss'
+ command proc{
+ tmppath = $goldberg_demo
+ $goldberg_demo = nil
+ tmppath.destroy
+ }
+ }.pack('side'=>'left', 'expand'=>'yes')
+
+ TkButton.new(frame) {
+ text 'See Code'
+ command proc{showCode 'goldberg'}
+ }.pack('side'=>'left', 'expand'=>'yes')
+
+}.pack('side'=>'bottom', 'fill'=>'x', 'pady'=>'2m')
+=end
+
+#########################################
+
+class TkGoldberg_Demo
+ def initialize(parent)
+ @parent = parent
+
+ @S = {}
+ @S['title'] = 'Tk Goldberg'
+ @S['speed'] = TkVariable.new(5)
+ @S['cnt'] = TkVariable.new(0)
+ @S['message'] = TkVariable.new("\\nWelcome\\nto\\nRuby/Tk")
+ @S['pause'] = TkVariable.new
+ @S['details'] = TkVariable.new(true)
+
+ @S['mode'] = TkVariable.new(:MSTART, :symbol)
+ # :MSTART, :MGO, :MPAUSE, :MSSTEP, :MBSTEP, :MDONE, :MDEBUG
+
+ # 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10
+ @speed = [1, 10, 20, 50, 80, 100, 150, 200, 300, 400, 500]
+
+ # colors
+ @C = {}
+ @C['fg'] = 'black'
+ # @C['bg'] = 'gray75'
+ @C['bg'] = 'cornflowerblue'
+
+ @C['0'] = 'white'; @C['1a'] = 'darkgreen'; @C['1b'] = 'yellow'
+ @C['2'] = 'red'; @C['3a'] = 'green'; @C['3b'] = 'darkblue'
+ @C['4'] = @C['fg']; @C['5a'] = 'brown'; @C['5b'] = 'white'
+ @C['6'] = 'magenta'; @C['7'] = 'green'; @C['8'] = @C['fg']
+ @C['9'] = 'blue4'; @C['10a'] = 'white'; @C['10b'] = 'cyan'
+ @C['11a'] = 'yellow'; @C['11b'] = 'mediumblue'; @C['12'] = 'tan2'
+ @C['13a'] = 'yellow'; @C['13b'] = 'red'; @C['14'] = 'white'
+ @C['15a'] = 'green'; @C['15b'] = 'yellow'; @C['16'] = 'gray65'
+ @C['17'] = '#A65353'; @C['18'] = @C['fg']; @C['19'] = 'gray50'
+ @C['20'] = 'cyan'; @C['21'] = 'gray65'; @C['22'] = @C['20']
+ @C['23a'] = 'blue'; @C['23b'] = 'red'; @C['23c'] = 'yellow'
+ @C['24a'] = 'red'; @C['24b'] = 'white';
+
+ @STEP = TkVariable.new_hash
+ @STEP.default_value_type = :numeric
+
+ @XY = {}
+
+ @XY6 = {
+ '-1'=>[366, 207], '-2'=>[349, 204], '-3'=>[359, 193], '-4'=>[375, 192],
+ '-5'=>[340, 190], '-6'=>[349, 177], '-7'=>[366, 177], '-8'=>[380, 176],
+ '-9'=>[332, 172], '-10'=>[342, 161], '-11'=>[357, 164],
+ '-12'=>[372, 163], '-13'=>[381, 149], '-14'=>[364, 151],
+ '-15'=>[349, 146], '-16'=>[333, 148], '0'=>[357, 219],
+ '1'=>[359, 261], '2'=>[359, 291], '3'=>[359, 318], '4'=>[361, 324],
+ '5'=>[365, 329], '6'=>[367, 334], '7'=>[367, 340], '8'=>[366, 346],
+ '9'=>[364, 350], '10'=>[361, 355], '11'=>[359, 370], '12'=>[359, 391],
+ '13,0'=>[360, 456], '13,1'=>[376, 456], '13,2'=>[346, 456],
+ '13,3'=>[330, 456], '13,4'=>[353, 444], '13,5'=>[368, 443],
+ '13,6'=>[339, 442], '13,7'=>[359, 431], '13,8'=>[380, 437],
+ '13,9'=>[345, 428], '13,10'=>[328, 434], '13,11'=>[373, 424],
+ '13,12'=>[331, 420], '13,13'=>[360, 417], '13,14'=>[345, 412],
+ '13,15'=>[376, 410], '13,16'=>[360, 403]
+ }
+
+ @timer = TkTimer.new(@speed[@S['speed'].numeric]){|timer|
+ timer.set_interval(go)
+ }
+
+ do_display
+ reset
+
+ # Start everything going
+ @timer.start
+ end
+
+ def do_display()
+ @ctrl = TkFrame.new(@parent, :relief=>:ridge, :bd=>2, :padx=>5, :pady=>5)
+ @screen = TkFrame.new(@parent, :bd=>2,
+ :relief=>:raised).pack(:side=>:left, :fill=>:both,
+ :expand=>true)
+
+ @canvas = TkCanvas.new(@parent, :width=>850, :height=>700,
+ :bg=>@C['bg'], :highlightthickness=>0){
+ scrollregion([0, 0, 1000, 1000]) # Kludge to move everything up
+ yview_moveto(0.05)
+ }.pack(:in=>@screen, :side=>:top, :fill=>:both, :expand=>true)
+
+ @canvas.bind('3'){ @pause.invoke }
+ @canvas.bind('Destroy'){ @timer.stop }
+
+ do_ctrl_frame
+ do_detail_frame
+
+ # msg = TkLabel.new(@parent, :bg=>@C['bg'], :fg=>'white') {
+ msg = Tk::Label.new(@parent, :bg=>@C['bg'], :fg=>'white') {
+ font 'Arial 10'
+ wraplength 600
+ justify 'left'
+ text "This is a demonstration of just how complex you can make your animations become. Click the ball to start things moving!\n\"Man will always find a difficult means to perform a simple task\" - Rube Goldberg"
+ }
+ msg.place(:in=>@canvas, :relx=>0, :rely=>0, :anchor=>:nw)
+
+ frame = TkFrame.new(@parent, :bg=>@C['bg'])
+
+ # TkButton.new(frame, :bg=>@C['bg'], :activebackground=>@C['bg']) {
+ Tk::Button.new(frame, :bg=>@C['bg'], :activebackground=>@C['bg']) {
+ text 'Dismiss'
+ command proc{
+ tmppath = $goldberg_demo
+ $goldberg_demo = nil
+ tmppath.destroy
+ }
+ }.pack('side'=>'left')
+
+ # TkButton.new(frame, :bg=>@C['bg'], :activebackground=>@C['bg']) {
+ Tk::Button.new(frame, :bg=>@C['bg'], :activebackground=>@C['bg']) {
+ text 'See Code'
+ command proc{showCode 'goldberg'}
+ }.pack('side'=>'left', 'padx'=>5)
+
+ # @show = TkButton.new(frame, :text=>'>>', :command=>proc{show_ctrl},
+ @show = Tk::Button.new(frame, :text=>'>>', :command=>proc{show_ctrl},
+ :bg=>@C['bg'], :activebackground=>@C['bg'])
+ @show.pack('side'=>'left')
+ frame.place(:in=>@canvas, :relx=>1, :rely=>0, :anchor=>:ne)
+
+ Tk.update
+ end
+
+ def do_ctrl_frame
+ @start = Tk::Button.new(@parent, :text=>'Start', :bd=>6,
+ :command=>proc{do_button(0)})
+ if font = @start['font']
+ @start.font(font.weight('bold'))
+ end
+
+ @pause = TkCheckbutton.new(@parent, :text=>'Pause', :font=>font,
+ :command=>proc{do_button(1)}, :relief=>:raised,
+ :variable=>@S['pause'])
+
+ @step = TkButton.new(@parent, :text=>'Single Step', :font=>font,
+ :command=>proc{do_button(2)})
+ @bstep = TkButton.new(@parent, :text=>'Big Step', :font=>font,
+ :command=>proc{do_button(4)})
+ @reset = TkButton.new(@parent, :text=>'Reset', :font=>font,
+ :command=>proc{do_button(3)})
+
+ @details = TkFrame.new(@parent, :bd=>2, :relief=>:ridge)
+ @detail = TkCheckbutton.new(@parent, :text=>'Details', :font=>font,
+ :relief=>:raised, :variable=>@S['details'])
+
+ @msg_entry = TkEntry.new(@parent, :textvariable=>@S['message'],
+ :justify=>:center)
+ @speed_scale = TkScale.new(@parent, :orient=>:horizontal,
+ :from=>1, :to=>10, :font=>font,
+ :variable=>@S['speed'], :bd=>2,
+ :relief=>:ridge, :showvalue=>false)
+ @about = TkButton.new(@parent, :text=>'About',
+ :command=>proc{about}, :font=>font)
+
+ Tk.grid(@start, :in=>@ctrl, :row=>0, :sticky=>:ew)
+ @ctrl.grid_rowconfigure(1, :minsize=>10)
+ Tk.grid(@pause, :in=>@ctrl, :row=>2, :sticky=>:ew)
+ Tk.grid(@step, :in=>@ctrl, :sticky=>:ew)
+ Tk.grid(@bstep, :in=>@ctrl, :sticky=>:ew)
+ Tk.grid(@reset, :in=>@ctrl, :sticky=>:ew)
+ @ctrl.grid_rowconfigure(10, :minsize=>20)
+ Tk.grid(@details, :in=>@ctrl, :row=>11, :sticky=>:ew)
+ Tk.grid(@detail, :in=>@details, :row=>0, :sticky=>:ew)
+ @ctrl.grid_rowconfigure(50, :weight=>1)
+
+ @S['mode'].trace('w', proc{|*args| active_GUI(*args)})
+ @S['details'].trace('w', proc{|*args| active_GUI(*args)})
+ @S['speed'].trace('w', proc{|*args| active_GUI(*args)})
+
+ Tk.grid(@msg_entry, :in=>@ctrl, :row=>98, :sticky=>:ew, :pady=>5)
+ Tk.grid(@speed_scale, :in=>@ctrl, :row=>99, :sticky=>:ew)
+ Tk.grid(@about, :in=>@ctrl, :row=>100, :sticky=>:ew)
+
+ @reset.bind('3'){@S['mode'].value = -1} # Debugging
+ end
+
+ def do_detail_frame
+ @f_details = TkFrame.new(@details)
+
+ @label = TkLabel.new(@f_details, :textvariable=>@S['cnt'],
+ :bd=>1, :relief=>:solid, :bg=>'white')
+ Tk.grid(@label, '-', '-', '-', :sticky=>:ew, :row=>0)
+
+ idx = 1
+ loop {
+ break unless respond_to?("move#{idx}")
+ l = TkLabel.new(@f_details, :text=>idx, :anchor=>:e,
+ :width=>2, :bd=>1, :relief=>:solid, :bg=>'white')
+ @STEP[idx] = 0
+ ll = TkLabel.new(@f_details, :textvariable=>@STEP.ref(idx),
+ :width=>5, :bd=>1, :relief=>:solid, :bg=>'white')
+ row = (idx + 1)/2
+ col = ((idx + 1) & 1) * 2
+ Tk.grid(l, :sticky=>:ew, :row=>row, :column=>col)
+ Tk.grid(ll, :sticky=>:ew, :row=>row, :column=>(col + 1))
+ idx += 1
+ }
+ @f_details.grid_columnconfigure(1, :weight=>1)
+ end
+
+ def show_ctrl
+ if @ctrl.winfo_mapped?
+ @ctrl.pack_forget
+ @show.text('>>')
+ else
+ @ctrl.pack(:side=>:right, :fill=>:both, :ipady=>5)
+ @show.text('<<')
+ end
+ end
+
+ def draw_all
+ reset_step
+ @canvas.delete(:all)
+ idx = 0
+ loop{
+ m = "draw#{idx}"
+ break unless respond_to?(m)
+ send(m)
+ idx += 1
+ }
+ end
+
+ def active_GUI(var1, var2, op)
+ st = {false=>:disabled, true=>:normal}
+
+ m = @S['mode'].to_sym
+ @S['pause'].value = (m == :MPAUSE)
+ @start.state(st[m != :MGO])
+ @pause.state(st[m != :MSTART && m != :MDONE])
+ @step.state(st[m != :MGO && m != :MDONE])
+ @bstep.state(st[m != :MGO && m != :MDONE])
+ @reset.state(st[m != :MSTART])
+
+ if @S['details'].bool
+ Tk.grid(@f_details, :in=>@details, :row=>2, :sticky=>:ew)
+ else
+ Tk.grid_forget(@f_details)
+ end
+ @speed_scale.label("Speed: #{@S['speed'].value}")
+ end
+
+ def start
+ @S['mode'].value = :MGO
+ end
+
+ def do_button(what)
+ case what
+ when 0 # Start
+ reset if @S['mode'].to_sym == :MDONE
+ @S['mode'].value = :MGO
+
+ when 1 # Pause
+ @S['mode'].value = ((@S['pause'].bool)? :MPAUSE: :MGO)
+
+ when 2 # Step
+ @S['mode'].value = :MSSTEP
+
+ when 3 # Reset
+ reset
+
+ when 4 # Big step
+ @S['mode'].value = :MBSTEP
+ end
+ end
+
+ def go(who = nil)
+ now = Tk::Clock.clicks(:miliseconds)
+ if who # Start here for debugging
+ @S['active'] = [who]
+ @S['mode'].value = :MGO
+ end
+ return if @S['mode'].to_sym == :MDEBUG # Debugging
+ # If not paused, do the next move
+ n = next_step if @S['mode'].to_sym != :MPAUSE
+ @S['mode'].value = :MPAUSE if @S['mode'].to_sym == :MSSTEP # Single step
+ @S['mode'].value = :MSSTEP if @S['mode'].to_sym == :MBSTEP && n # big step
+ elapsed = Tk::Clock.clicks(:miliseconds) - now
+ delay = @speed[@S['speed'].to_i] - elapsed
+ delay = 1 if delay <= 0
+ return delay
+ end
+
+ def next_step
+ retval = false # Return value
+
+ if @S['mode'].to_sym != :MSTART && @S['mode'].to_sym != :MDONE
+ @S['cnt'].numeric += 1
+ end
+ alive = []
+ @S['active'].each{|who|
+ who = who.to_i
+ n = send("move#{who}")
+ if (n & 1).nonzero? # This guy still alive
+ alive << who
+ end
+ if (n & 2).nonzero? # Next guy is active
+ alive << (who + 1)
+ retval = true
+ end
+ if (n & 4).nonzero? # End of puzzle flag
+ @S['mode'].value = :MDONE # Done mode
+ @S['active'] = [] # No more animation
+ return true
+ end
+ }
+ @S['active'] = alive
+ return retval
+ end
+
+ def about
+ msg = "Ruby/Tk Version ::\nby Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)\n\n"
+ msg += "Original Version ::\n"
+ msg += "#{@S['title']}\nby Keith Vetter, March 2003\n(Reproduced by kind permission of the author)\n\n"
+ msg += "Man will always find a difficult means to perform a simple task"
+ msg += "\nRube Goldberg"
+ Tk.messageBox(:message=>msg, :title=>'About')
+ end
+
+ ################################################################
+ #
+ # All the drawing and moving routines
+ #
+
+ # START HERE! banner
+ def draw0
+ color = @C['0']
+ TkcText.new(@canvas, [579, 119], :text=>'START HERE!',
+ :fill=>color, :anchor=>:w,
+ :tag=>'I0', :font=>['Times Roman', 12, :italic, :bold])
+ TkcLine.new(@canvas, [719, 119, 763, 119], :tag=>'I0', :fill=>color,
+ :width=>5, :arrow=>:last, :arrowshape=>[18, 18, 5])
+ @canvas.itembind('I0', '1'){ start }
+ end
+
+ def move0(step = nil)
+ step = get_step(0, step)
+
+ if @S['mode'].to_sym != :MSTART # Start the ball rolling
+ move_abs('I0', [-100, -100]) # Hide the banner
+ return 2
+ end
+
+ pos = [
+ [673, 119], [678, 119], [683, 119], [688, 119],
+ [693, 119], [688, 119], [683, 119], [678, 119]
+ ]
+ step = step % pos.length
+ move_abs('I0', pos[step])
+ return 1
+ end
+
+ # Dropping ball
+ def draw1
+ color = @C['1a']
+ color2 = @C['1b']
+ TkcPolygon.new(@canvas,
+ [ 844, 133, 800, 133, 800, 346, 820, 346,
+ 820, 168, 844, 168, 844, 133 ],
+ :width=>3, :fill=>color, :outline=>'')
+ TkcPolygon.new(@canvas,
+ [ 771, 133, 685, 133, 685, 168, 751, 168,
+ 751, 346, 771, 346, 771, 133 ],
+ :width=>3, :fill=>color, :outline=>'')
+ TkcOval.new(@canvas, box(812, 122, 9),
+ :tag=>'I1', :fill=>color2, :outline=>'')
+
+ @canvas.itembind('I1', '1'){ start }
+ end
+
+ def move1(step = nil)
+ step = get_step(1, step)
+ pos = [
+ [807, 122], [802, 122], [797, 123], [793, 124], [789, 129], [785, 153],
+ [785, 203], [785, 278, :x], [785, 367], [810, 392], [816, 438],
+ [821, 503], [824, 585, :y], [838, 587], [848, 593], [857, 601],
+ [-100, -100]
+ ]
+ return 0 if step >= pos.length
+ where = pos[step]
+ move_abs('I1', where)
+ move15a if where[2] == :y
+ return 3 if where[2] == :x
+ return 1
+ end
+
+ # Lighting the match
+ def draw2
+ color = @C['2']
+
+ # Fulcrum
+ TkcPolygon.new(@canvas, [750, 369, 740, 392, 760, 392],
+ :fill=>@C['fg'], :outline=>@C['fg'])
+
+ # Strike box
+ TkcRectangle.new(@canvas, [628, 335, 660, 383],
+ :fill=>'', :outline=>@C['fg'])
+ (0..2).each{|y|
+ yy = 335 + y*16
+ TkcBitmap.new(@canvas, [628, yy], :bitmap=>'gray25',
+ :anchor=>:nw, :foreground=>@C['fg'])
+ TkcBitmap.new(@canvas, [644, yy], :bitmap=>'gray25',
+ :anchor=>:nw, :foreground=>@C['fg'])
+ }
+
+ # Lever
+ TkcLine.new(@canvas, [702, 366, 798, 366],
+ :fill=>@C['fg'], :width=>6, :tag=>'I2_0')
+
+ # R strap
+ TkcLine.new(@canvas, [712, 363, 712, 355],
+ :fill=>@C['fg'], :width=>3, :tag=>'I2_1')
+
+ # L strap
+ TkcLine.new(@canvas, [705, 363, 705, 355],
+ :fill=>@C['fg'], :width=>3, :tag=>'I2_2')
+
+ # Match stick
+ TkcLine.new(@canvas, [679, 356, 679, 360, 717, 360, 717, 356, 679, 356],
+ :fill=>@C['fg'], :width=>3, :tag=>'I2_3')
+
+ # Match head
+ TkcPolygon.new(@canvas,
+ [ 671, 352, 677.4, 353.9, 680, 358.5, 677.4, 363.1,
+ 671, 365, 664.6, 363.1, 662, 358.5, 664.6, 353.9 ],
+ :fill=>color, :outline=>color, :tag=>'I2_4')
+ end
+
+ def move2(step = nil)
+ step = get_step(2, step)
+
+ stages = [0, 0, 1, 2, 0, 2, 1, 0, 1, 2, 0, 2, 1]
+ xy = []
+ xy[0] = [
+ 686, 333, 692, 323, 682, 316, 674, 309, 671, 295, 668, 307,
+ 662, 318, 662, 328, 671, 336
+ ]
+ xy[1] = [
+ 687, 331, 698, 322, 703, 295, 680, 320, 668, 297, 663, 311,
+ 661, 327, 671, 335
+ ]
+ xy[2] = [
+ 686, 331, 704, 322, 688, 300, 678, 283, 678, 283, 674, 298,
+ 666, 309, 660, 324, 672, 336
+ ]
+
+ if step >= stages.length
+ @canvas.delete('I2')
+ return 0
+ end
+
+ if step == 0 # Rotate the match
+ beta = 20
+
+ ox, oy = anchor('I2_0', :s) # Where to pivot
+
+ i = 0
+ until @canvas.find_withtag("I2_#{i}").empty?
+ rotate_item("I2_#{i}", ox, oy, beta)
+ i += 1
+ end
+
+ # For the flame
+ TkcPolygon.new(@canvas, [], :tag=>'I2', :smooth=>true, :fill=>@C['2'])
+
+ return 1
+ end
+ @canvas.coords('I2', xy[stages[step]])
+ return ((step == 7)? 3: 1)
+ end
+
+ # Weight and pulleys
+ def draw3
+ color = @C['3a']
+ color2 = @C['3b']
+
+ xy = [ [602, 296], [577, 174], [518, 174] ]
+ xy.each{|x, y| # 3 Pulleys
+ TkcOval.new(@canvas, box(x, y, 13),
+ :fill=>color, :outline=>@C['fg'], :width=>3)
+ TkcOval.new(@canvas, box(x, y, 2), :fill=>@C['fg'], :outline=>@C['fg'])
+ }
+
+ # Wall to flame
+ TkcLine.new(@canvas, [750, 309, 670, 309], :tag=>'I3_s',
+ :width=>3, :fill=>@C['fg'], :smooth=>true)
+
+ # Flame to pulley 1
+ TkcLine.new(@canvas, [670, 309, 650, 309], :tag=>'I3_0',
+ :width=>3, :fill=>@C['fg'], :smooth=>true)
+ TkcLine.new(@canvas, [650, 309, 600, 309], :tag=>'I3_1',
+ :width=>3, :fill=>@C['fg'], :smooth=>true)
+
+ # Pulley 1 half way to 2
+ TkcLine.new(@canvas, [589, 296, 589, 235], :tag=>'I3_2',
+ :width=>3, :fill=>@C['fg'])
+
+ # Pulley 1 other half to 2
+ TkcLine.new(@canvas, [589, 235, 589, 174], :width=>3, :fill=>@C['fg'])
+
+ # Across the top
+ TkcLine.new(@canvas, [577, 161, 518, 161], :width=>3, :fill=>@C['fg'])
+
+ # Down to weight
+ TkcLine.new(@canvas, [505, 174, 505, 205], :tag=>'I3_w',
+ :width=>3, :fill=>@C['fg'])
+
+ # Draw the weight as 2 circles, two rectangles and 1 rounded rectangle
+ x1, y1, x2, y2 = [515, 207, 495, 207]
+ TkcOval.new(@canvas, box(x1, y1, 6),
+ :tag=>'I3_', :fill=>color2, :outline=>color2)
+ TkcOval.new(@canvas, box(x2, y2, 6),
+ :tag=>'I3_', :fill=>color2, :outline=>color2)
+ TkcRectangle.new(@canvas, x1, y1 - 6, x2, y2 + 6,
+ :tag=>'I3_', :fill=>color2, :outline=>color2)
+
+ TkcPolygon.new(@canvas, round_rect([492, 220, 518, 263], 15),
+ :smooth=>true, :tag=>'I3_', :fill=>color2, :outline=>color2)
+
+ TkcLine.new(@canvas, [500, 217, 511, 217],
+ :tag=>'I3_', :fill=>color2, :width=>10)
+
+ # Bottom weight target
+ TkcLine.new(@canvas, [502, 393, 522, 393, 522, 465],
+ :tag=>'I3__', :fill=>@C['fg'], :joinstyle=>:miter, :width=>10)
+ end
+
+ def move3(step = nil)
+ step = get_step(3, step)
+
+ pos = [ [505, 247], [505, 297], [505, 386.5], [505, 386.5] ]
+ rope = []
+ rope[0] = [750, 309, 729, 301, 711, 324, 690, 300]
+ rope[1] = [750, 309, 737, 292, 736, 335, 717, 315, 712, 320]
+ rope[2] = [750, 309, 737, 309, 740, 343, 736, 351, 725, 340]
+ rope[3] = [750, 309, 738, 321, 746, 345, 742, 356]
+
+ return 0 if step >= pos.length
+
+ @canvas.delete("I3_#{step}") # Delete part of the rope
+ move_abs('I3_', pos[step]) # Move weight down
+ @canvas.coords('I3_s', rope[step]) # Flapping rope end
+ @canvas.coords('I3_w', [505, 174].concat(pos[step]))
+ if step == 2
+ @canvas.move('I3__', 0, 30)
+ return 2
+ end
+ return 1
+ end
+
+ # Cage and door
+ def draw4
+ color = @C['4']
+ x0, y0, x1, y1 = [527, 356, 611, 464]
+
+ # Horizontal bars
+ y0.step(y1, 12){|y|
+ TkcLine.new(@canvas, [x0, y, x1, y], :fill=>color, :width=>1)
+ }
+
+ # Vertical bars
+ x0.step(x1, 12){|x|
+ TkcLine.new(@canvas, [x, y0, x, y1], :fill=>color, :width=>1)
+ }
+
+ # Swing gate
+ TkcLine.new(@canvas, [518, 464, 518, 428],
+ :tag=>'I4', :fill=>color, :width=>1)
+ end
+
+ def move4(step = nil)
+ step = get_step(4, step)
+
+ angles = [-10, -20, -30, -30]
+ return 0 if step >= angles.length
+
+ rotate_item('I4', 518, 464, angles[step])
+ @canvas.raise('I4')
+
+ return((step == 3)? 3: 1)
+ end
+
+ # Mouse
+ def draw5
+ color = @C['5a']
+ color2 = @C['5b']
+
+ xy = [377, 248, 410, 248, 410, 465, 518, 465] # Mouse course
+ xy.concat [518, 428, 451, 428, 451, 212, 377, 212]
+
+ TkcPolygon.new(@canvas, xy, :fill=>color2, :outline=>@C['fg'], :width=>3)
+
+ xy = [
+ 534.5, 445.5, 541, 440, 552, 436, 560, 436, 569, 440, 574, 446,
+ 575, 452, 574, 454, 566, 456, 554, 456, 545, 456, 537, 454, 530, 452
+ ]
+ TkcPolygon.new(@canvas, xy, :tag=>['I5', 'I5_0'], :fill=>color)
+
+ TkcLine.new(@canvas, [573, 452, 592, 458, 601, 460, 613, 456], # Tail
+ :tag=>['I5', 'I5_1'], :fill=>color, :smooth=>true, :width=>3)
+
+ xy = box(540, 446, 2) # Eye
+ xy = [540, 444, 541, 445, 541, 447, 540, 448, 538, 447, 538, 445]
+ TkcPolygon.new(@canvas, xy, :tag=>['I5', 'I5_2'], :fill=>@C['bg'],
+ :outline=>'', :smooth=>true)
+
+ xy = [538, 454, 535, 461] # Front leg
+ TkcLine.new(@canvas, xy, :tag=>['I5', 'I5_3'], :fill=>color, :width=>2)
+
+ xy = [566, 455, 569, 462] # Back leg
+ TkcLine.new(@canvas, xy, :tag=>['I5', 'I5_4'], :fill=>color, :width=>2)
+
+ xy = [544, 455, 545, 460] # 2nd front leg
+ TkcLine.new(@canvas, xy, :tag=>['I5', 'I5_5'], :fill=>color, :width=>2)
+
+ xy = [560, 455, 558, 460] # 2nd back leg
+ TkcLine.new(@canvas, xy, :tag=>['I5', 'I5_6'], :fill=>color, :width=>2)
+ end
+
+ def move5(step = nil)
+ step = get_step(5, step)
+
+ pos = [
+ [553, 452], [533, 452], [513, 452], [493, 452], [473, 452],
+ [463, 442, 30], [445.5, 441.5, 30], [425.5, 434.5, 30], [422, 414],
+ [422, 394], [422, 374], [422, 354], [422, 334], [422, 314], [422, 294],
+ [422, 274, -30], [422, 260.5, -30, :x], [422.5, 248.5, -28], [425, 237]
+ ]
+
+ return 0 if step >= pos.length
+
+ x, y, beta, nxt = pos[step]
+ move_abs('I5', [x, y])
+ if beta
+ ox, oy = centroid('I5_0')
+ (0..6).each{|id| rotate_item("I5_#{id}", ox, oy, beta) }
+ end
+ return 3 if nxt == :x
+ return 1
+ end
+
+ # Dropping gumballs
+ def draw6
+ color = @C['6']
+ xy = [324, 130, 391, 204] # Ball holder
+ xy = round_rect(xy, 10)
+ TkcPolygon.new(@canvas, xy, :smooth=>true,
+ :outline=>@C['fg'], :width=>3, :fill=>color)
+ xy = [339, 204, 376, 253] # Below the ball holder
+ TkcRectangle.new(@canvas, xy, :outline=>@C['fg'], :width=>3,
+ :fill=>color, :tag=>'I6c')
+ xy = box(346, 339, 28)
+ TkcOval.new(@canvas, xy, :fill=>color, :outline=>'') # Roter
+ TkcArc.new(@canvas, xy, :outline=>@C['fg'], :width=>2, :style=>:arc,
+ :start=>80, :extent=>205)
+ TkcArc.new(@canvas, xy, :outline=>@C['fg'], :width=>2, :style=>:arc,
+ :start=>-41, :extent=>85)
+
+ xy = box(346, 339, 15) # Center of rotor
+ TkcOval.new(@canvas, xy, :outline=>@C['fg'], :fill=>@C['fg'], :tag=>'I6m')
+ xy = [352, 312, 352, 254, 368, 254, 368, 322] # Top drop to rotor
+ TkcPolygon.new(@canvas, xy, :fill=>color, :outline=>'')
+ TkcLine.new(@canvas, xy, :fill=>@C['fg'], :width=>2)
+
+ xy = [353, 240, 367, 300] # Poke bottom hole
+ TkcRectangle.new(@canvas, xy, :fill=>color, :outline=>'')
+ xy = [341, 190, 375, 210] # Poke another hole
+ TkcRectangle.new(@canvas, xy, :fill=>color, :outline=>'')
+
+ xy = [
+ 368, 356, 368, 403, 389, 403, 389, 464, 320, 464, 320, 403,
+ 352, 403, 352, 366
+ ]
+ TkcPolygon.new(@canvas, xy, :fill=>color, :outline=>'',
+ :width=>2) # Below rotor
+ TkcLine.new(@canvas, xy, :fill=>@C['fg'], :width=>2)
+ xy = box(275, 342, 7) # On/off rotor
+ TkcOval.new(@canvas, xy, :outline=>@C['fg'], :fill=>@C['fg'])
+ xy = [276, 334, 342, 325] # Fan belt top
+ TkcLine.new(@canvas, xy, :fill=>@C['fg'], :width=>3)
+ xy = [276, 349, 342, 353] # Fan belt bottom
+ TkcLine.new(@canvas, xy, :fill=>@C['fg'], :width=>3)
+
+ xy = [337, 212, 337, 247] # What the mouse pushes
+ TkcLine.new(@canvas, xy, :fill=>@C['fg'], :width=>3, :tag=>'I6_')
+ xy = [392, 212, 392, 247]
+ TkcLine.new(@canvas, xy, :fill=>@C['fg'], :width=>3, :tag=>'I6_')
+ xy = [337, 230, 392, 230]
+ TkcLine.new(@canvas, xy, :fill=>@C['fg'], :width=>7, :tag=>'I6_')
+
+ who = -1 # All the balls
+ colors = %w(red cyan orange green blue darkblue)
+ colors *= 3
+
+ (0..16).each{|i|
+ loc = -i
+ color = colors[i]
+ x, y = @XY6["#{loc}"]
+ TkcOval.new(@canvas, box(x, y, 5),
+ :fill=>color, :outline=>color, :tag=>"I6_b#{i}")
+ }
+ draw6a(12) # The wheel
+ end
+
+ def draw6a(beta)
+ @canvas.delete('I6_0')
+ ox, oy = [346, 339]
+ (0..3).each{|i|
+ b = beta + i * 45
+ x, y = rotate_c(28, 0, 0, 0, b)
+ xy = [ox + x, oy + y, ox - x, oy - y]
+ TkcLine.new(@canvas, xy, :tag=>'I6_0', :fill=>@C['fg'], :width=>2)
+ }
+ end
+
+ def move6(step = nil)
+ step = get_step(6, step)
+
+ return 0 if step > 62
+
+ if step < 2 # Open gate for balls to drop
+ @canvas.move('I6_', -7, 0)
+ if step == 1 # Poke a hole
+ xy = [348, 226, 365, 240]
+ TkcRectangle.new(@canvas, xy, :fill=>@canvas.itemcget('I6c', :fill),
+ :outline=>'')
+ end
+ return 1
+ end
+
+ s = step - 1 # Do the gumball drop dance
+ (0..(((s - 1)/3).to_i)).each{|i|
+ tag = "I6_b#{i}"
+ break if @canvas.find_withtag(tag).empty?
+ loc = s - 3*i
+
+ if @XY6["#{loc},#{i}"]
+ move_abs(tag, @XY6["#{loc},#{i}"])
+ elsif @XY6["#{loc}"]
+ move_abs(tag, @XY6["#{loc}"])
+ end
+ }
+ if s % 3 == 1
+ first = (s + 2)/3
+ i = first
+ loop {
+ tag = "I6_b#{i}"
+ break if @canvas.find_withtag(tag).empty?
+ loc = first - i
+ move_abs(tag, @XY6["#{loc}"])
+ i += 1
+ }
+ end
+ if s >= 3 # Rotate the motor
+ idx = s % 3
+ draw6a(12 + s * 15)
+ end
+ return((s == 3)? 3 : 1)
+ end
+
+ # On/off switch
+ def draw7
+ color = @C['7']
+ xy = [198, 306, 277, 374] # Box
+ TkcRectangle.new(@canvas, xy, :outline=>@C['fg'], :width=>2,
+ :fill=>color, :tag=>'I7z')
+ @canvas.lower('I7z')
+ xy = [275, 343, 230, 349]
+ TkcLine.new(@canvas, xy, :tag=>'I7', :fill=>@C['fg'], :arrow=>:last,
+ :arrowshape=>[23, 23, 8], :width=>6)
+ xy = [225, 324] # On button
+ x, y = xy
+ TkcOval.new(@canvas, box(x, y, 3), :fill=>@C['fg'], :outline=>@C['fg'])
+ xy = [218, 323] # On text
+ font = ['Times Roman', 8]
+ TkcText.new(@canvas, xy, :text=>'on', :anchor=>:e,
+ :fill=>@C['fg'], :font=>font)
+ xy = [225, 350] # Off button
+ x, y = xy
+ TkcOval.new(@canvas, box(x, y, 3), :fill=>@C['fg'], :outline=>@C['fg'])
+ xy = [218, 349] # Off text
+ TkcText.new(@canvas, xy, :text=>'off', :anchor=>:e,
+ :fill=>@C['fg'], :font=>font)
+ end
+
+ def move7(step = nil)
+ step = get_step(7, step)
+
+ numsteps = 30
+ return 0 if step > numsteps
+ beta = 30.0 / numsteps
+ rotate_item('I7', 275, 343, beta)
+
+ return((step == numsteps)? 3: 1)
+ end
+
+ # Electricity to the fan
+ def draw8
+ sine([271, 248, 271, 306], 5, 8, :tag=>'I8_s', :fill=>@C['8'], :width=>3)
+ end
+
+ def move8(step = nil)
+ step = get_step(8, step)
+
+ return 0 if step > 3
+ if step == 0
+ sparkle(anchor('I8_s', :s), 'I8')
+ return 1
+ elsif step == 1
+ move_abs('I8', anchor('I8_s', :c))
+ elsif step == 2
+ move_abs('I8', anchor('I8_s', :n))
+ else
+ @canvas.delete('I8')
+ end
+ return((step == 2)? 3: 1)
+ end
+
+ # Fan
+ def draw9
+ color = @C['9']
+ xy = [266, 194, 310, 220]
+ TkcOval.new(@canvas, xy, :outline=>color, :fill=>color)
+ xy = [280, 209, 296, 248]
+ TkcOval.new(@canvas, xy, :outline=>color, :fill=>color)
+ xy = [
+ 288, 249, 252, 249, 260, 240, 280, 234,
+ 296, 234, 316, 240, 324, 249, 288, 249
+ ]
+ TkcPolygon.new(@canvas, xy, :fill=>color, :smooth=>true)
+
+ xy = [248, 205, 265, 214, 264, 205, 265, 196] # Spinner
+ TkcPolygon.new(@canvas, xy, :fill=>color)
+
+ xy = [255, 206, 265, 234] # Fan blades
+ TkcOval.new(@canvas, xy, :fill=>'', :outline=>@C['fg'],
+ :width=>3, :tag=>'I9_0')
+ xy = [255, 176, 265, 204]
+ TkcOval.new(@canvas, xy, :fill=>'', :outline=>@C['fg'],
+ :width=>3, :tag=>'I9_0')
+ xy = [255, 206, 265, 220]
+ TkcOval.new(@canvas, xy, :fill=>'', :outline=>@C['fg'],
+ :width=>1, :tag=>'I9_1')
+ xy = [255, 190, 265, 204]
+ TkcOval.new(@canvas, xy, :fill=>'', :outline=>@C['fg'],
+ :width=>1, :tag=>'I9_1')
+ end
+
+ def move9(step = nil)
+ step = get_step(9, step)
+
+ if (step & 1).nonzero?
+ @canvas.itemconfigure('I9_0', :width=>4)
+ @canvas.itemconfigure('I9_1', :width=>1)
+ @canvas.lower('I9_1', 'I9_0')
+ else
+ @canvas.itemconfigure('I9_0', :width=>1)
+ @canvas.itemconfigure('I9_1', :width=>4)
+ @canvas.lower('I9_0', 'I9_1')
+ end
+ return 3 if step == 0
+ return 1
+ end
+
+ # Boat
+ def draw10
+ color = @C['10a']
+ color2 = @C['10b']
+ xy = [191, 230, 233, 230, 233, 178, 191, 178] # Sail
+ TkcPolygon.new(@canvas, xy, :fill=>color, :width=>3, :outline=>@C['fg'],
+ :tag=>'I10')
+ xy = box(209, 204, 31) # Front
+ TkcArc.new(@canvas, xy, :outline=>'', :fill=>color, :style=>:pie,
+ :start=>120, :extent=>120, :tag=>'I10')
+ TkcArc.new(@canvas, xy, :outline=>@C['fg'], :width=>3, :style=>:arc,
+ :start=>120, :extent=>120, :tag=>'I10')
+ xy = box(249, 204, 31) # Back
+ TkcArc.new(@canvas, xy, :outline=>'', :fill=>@C['bg'], :width=>3,
+ :style=>:pie, :start=>120, :extent=>120, :tag=>'I10')
+ TkcArc.new(@canvas, xy, :outline=>@C['fg'], :width=>3, :style=>:arc,
+ :start=>120, :extent=>120, :tag=>'I10')
+
+ xy = [200, 171, 200, 249] # Mast
+ TkcLine.new(@canvas, xy, :fill=>@C['fg'], :width=>3, :tag=>'I10')
+ xy = [159, 234, 182, 234] # Bow sprit
+ TkcLine.new(@canvas, xy, :fill=>@C['fg'], :width=>3, :tag=>'I10')
+ xy = [180, 234, 180, 251, 220, 251] # Hull
+ TkcLine.new(@canvas, xy, :fill=>@C['fg'], :width=>6, :tag=>'I10')
+
+ xy = [92, 255, 221, 255] # Waves
+ sine(xy, 2, 25, :fill=>color2, :width=>1, :tag=>'I10w')
+
+ xy = @canvas.coords('I10w')[4..-5] # Water
+ xy.concat([222, 266, 222, 277, 99, 277])
+ TkcPolygon.new(@canvas, xy, :fill=>color2, :outline=>color2)
+ xy = [222, 266, 222, 277, 97, 277, 97, 266] # Water bottom
+ TkcLine.new(@canvas, xy, :fill=>@C['fg'], :width=>3)
+
+ xy = box(239, 262, 17)
+ TkcArc.new(@canvas, xy, :outline=>@C['fg'], :width=>3, :style=>:arc,
+ :start=>95, :extent=>103)
+ xy = box(76, 266, 21)
+ TkcArc.new(@canvas, xy, :outline=>@C['fg'], :width=>3, :style=>:arc,
+ :extent=>190)
+ end
+
+ def move10(step = nil)
+ step = get_step(10, step)
+
+ pos = [
+ [195, 212], [193, 212], [190, 212], [186, 212], [181, 212], [176, 212],
+ [171, 212], [166, 212], [161, 212], [156, 212], [151, 212], [147, 212],
+ [142, 212], [137, 212], [132, 212, :x], [127, 212], [121, 212],
+ [116, 212], [111, 212]
+ ]
+
+ return 0 if step >= pos.length
+
+ where = pos[step]
+ move_abs('I10', where)
+
+ return 3 if where[2] == :x
+ return 1
+ end
+
+ # 2nd ball drop
+ def draw11
+ color = @C['11a']
+ color2 = @C['11b']
+ xy = [23, 264, 55, 591] # Color the down tube
+ TkcRectangle.new(@canvas, xy, :fill=>color, :outline=>'')
+ xy = box(71, 460, 48) # Color the outer loop
+ TkcOval.new(@canvas, xy, :fill=>color, :outline=>'')
+
+ xy = [55, 264, 55, 458] # Top right side
+ TkcLine.new(@canvas, xy, :fill=>@C['fg'], :width=>3)
+ xy = [55, 504, 55, 591] # Bottom right side
+ TkcLine.new(@canvas, xy, :fill=>@C['fg'], :width=>3)
+ xy = box(71, 460, 48) # Outer loop
+ TkcArc.new(@canvas, xy, :outline=>@C['fg'], :width=>3, :style=>:arc,
+ :start=>110, :extent=>-290, :tag=>'I11i')
+ xy = box(71, 460, 16) # Inner loop
+ TkcOval.new(@canvas, xy, :outline=>@C['fg'], :fill=>'',
+ :width=>3, :tag=>'I11i')
+ TkcOval.new(@canvas, xy, :outline=>@C['fg'], :fill=>@C['bg'], :width=>3)
+
+ xy = [23, 264, 23, 591] # Left side
+ TkcLine.new(@canvas, xy, :fill=>@C['fg'], :width=>3)
+ xy = box(1, 266, 23) # Top left curve
+ TkcArc.new(@canvas, xy, :outline=>@C['fg'], :width=>3,
+ :style=>:arc, :extent=>90)
+
+ xy = box(75, 235, 9) # The ball
+ TkcOval.new(@canvas, xy, :fill=>color2, :outline=>'',
+ :width=>3, :tag=>'I11')
+ end
+
+ def move11(step = nil)
+ step = get_step(11, step)
+
+ pos = [
+ [75, 235], [70, 235], [65, 237], [56, 240], [46, 247], [38, 266],
+ [38, 296], [38, 333], [38, 399], [38, 475], [74, 496], [105, 472],
+ [100, 437], [65, 423], [-100, -100], [38, 505], [38, 527, :x], [38, 591]
+ ]
+
+ return 0 if step >= pos.length
+ where = pos[step]
+ move_abs('I11', where)
+ return 3 if where[2] == :x
+ return 1
+ end
+
+ # Hand
+ def draw12
+ xy = [
+ 20, 637, 20, 617, 20, 610, 20, 590, 40, 590, 40, 590,
+ 60, 590, 60, 610, 60, 610
+ ]
+ xy.concat([60, 610, 65, 620, 60, 631]) # Thumb
+ xy.concat([60, 631, 60, 637, 60, 662, 60, 669, 52, 669,
+ 56, 669, 50, 669, 50, 662, 50, 637])
+
+ y0 = 637 # Bumps for fingers
+ y1 = 645
+ 50.step(21, -10){|x|
+ x1 = x - 5
+ x2 = x - 10
+ xy << x << y0 << x1 << y1 << x2 << y0
+ }
+ TkcPolygon.new(@canvas, xy, :fill=>@C['12'], :outline=>@C['fg'],
+ :smooth=>true, :tag=>'I12', :width=>3)
+ end
+
+ def move12(step = nil)
+ step = get_step(12, step)
+
+ pos = [[42.5, 641, :x]]
+ return 0 if step >= pos.length
+ where = pos[step]
+ move_abs('I12', where)
+ return 3 if where[2] == :x
+ return 1
+ end
+
+ # Fax
+ def draw13
+ color = @C['13a']
+ xy = [86, 663, 149, 663, 149, 704, 50, 704, 50, 681, 64, 681, 86, 671]
+ xy2 = [
+ 784, 663, 721, 663, 721, 704, 820, 704, 820, 681, 806, 681, 784, 671
+ ]
+ radii = [2, 9, 9, 8, 5, 5, 2]
+
+ round_poly(@canvas, xy, radii, :width=>3,
+ :outline=>@C['fg'], :fill=>color)
+ round_poly(@canvas, xy2, radii, :width=>3,
+ :outline=>@C['fg'], :fill=>color)
+
+ xy = [56, 677]
+ x, y = xy
+ TkcRectangle.new(@canvas, box(x, y, 4), :fill=>'', :outline=>@C['fg'],
+ :width=>3, :tag=>'I13')
+ xy = [809, 677]
+ x, y = xy
+ TkcRectangle.new(@canvas, box(x, y, 4), :fill=>'', :outline=>@C['fg'],
+ :width=>3, :tag=>'I13R')
+
+ xy = [112, 687] # Label
+ TkcText.new(@canvas, xy, :text=>'FAX', :fill=>@C['fg'],
+ :font=>['Times Roman', 12, :bold])
+ xy = [762, 687]
+ TkcText.new(@canvas, xy, :text=>'FAX', :fill=>@C['fg'],
+ :font=>['Times Roman', 12, :bold])
+
+ xy = [138, 663, 148, 636, 178, 636] # Paper guide
+ TkcLine.new(@canvas, xy, :smooth=>true, :fill=>@C['fg'], :width=>3)
+ xy = [732, 663, 722, 636, 692, 636]
+ TkcLine.new(@canvas, xy, :smooth=>true, :fill=>@C['fg'], :width=>3)
+
+ sine([149, 688, 720, 688], 5, 15,
+ :tag=>'I13_s', :fill=>@C['fg'], :width=>3)
+ end
+
+ def move13(step = nil)
+ step = get_step(13, step)
+
+ numsteps = 7
+
+ if step == numsteps + 2
+ move_abs('I13_star', [-100, -100])
+ @canvas.itemconfigure('I13R', :fill=>@C['13b'], :width=>2)
+ return 2
+ end
+ if step == 0 # Button down
+ @canvas.delete('I13')
+ sparkle([-100, -100], 'I13_star') # Create off screen
+ return 1
+ end
+ x0, y0 = anchor('I13_s', :w)
+ x1, y1 = anchor('I13_s', :e)
+ x = x0 + (x1 - x0) * (step - 1) / numsteps.to_f
+ move_abs('I13_star', [x, y0])
+ return 1
+ end
+
+ # Paper in fax
+ def draw14
+ color = @C['14']
+ xy = [102, 661, 113, 632, 130, 618] # Left paper edge
+ TkcLine.new(@canvas, xy, :smooth=>true, :fill=>color,
+ :width=>3, :tag=>'I14L_0')
+ xy = [148, 629, 125, 640, 124, 662] # Right paper edge
+ TkcLine.new(@canvas, xy, :smooth=>true, :fill=>color,
+ :width=>3, :tag=>'I14L_1')
+ draw14a('L')
+
+ xy = [
+ 768.0, 662.5, 767.991316225, 662.433786215, 767.926187912, 662.396880171
+ ]
+ TkcLine.new(@canvas, xy, :smooth=>true, :fill=>color,
+ :width=>3, :tag=>'I14R_0')
+ @canvas.lower('I14R_0')
+ # NB. these numbers are VERY sensitive, you must start with final size
+ # and shrink down to get the values
+ xy = [
+ 745.947897349, 662.428358855, 745.997829056, 662.452239237, 746.0, 662.5
+ ]
+ TkcLine.new(@canvas, xy, :smooth=>true, :fill=>color,
+ :width=>3, :tag=>'I14R_1')
+ @canvas.lower('I14R_1')
+ end
+
+ def draw14a(side)
+ color = @C['14']
+ xy = @canvas.coords("I14#{side}_0")
+ xy2 = @canvas.coords("I14#{side}_1")
+ x0, y0, x1, y1, x2, y2 = xy
+ x3, y3, x4, y4, x5, y5 = xy2
+
+ zz = [
+ x0, y0, x0, y0, xy, x2, y2, x2, y2,
+ x3, y3, x3, y3, xy2, x5, y5, x5, y5
+ ].flatten
+ @canvas.delete("I14#{side}")
+ TkcPolygon.new(@canvas, zz, :tag=>"I14#{side}", :smooth=>true,
+ :fill=>color, :outline=>color, :width=>3)
+ @canvas.lower("I14#{side}")
+ end
+
+ def move14(step = nil)
+ step = get_step(14, step)
+
+ # Paper going down
+ sc = 0.9 - 0.05*step
+ if sc < 0.3
+ @canvas.delete('I14L')
+ return 0
+ end
+
+ ox, oy = @canvas.coords('I14L_0')
+ @canvas.scale('I14L_0', ox, oy, sc, sc)
+ ox, oy = @canvas.coords('I14L_1')[-2..-1]
+ @canvas.scale('I14L_1', ox, oy, sc, sc)
+ draw14a('L')
+
+ # Paper going up
+ sc = 0.35 + 0.05*step
+ sc = 1/sc
+
+ ox, oy = @canvas.coords('I14R_0')
+ @canvas.scale('I14R_0', ox, oy, sc, sc)
+ ox, oy = @canvas.coords('I14R_1')[-2..-1]
+ @canvas.scale('I14R_1', ox, oy, sc, sc)
+ draw14a('R')
+
+ return((step == 10)? 3: 1)
+ end
+
+ # Light beam
+ def draw15
+ color = @C['15a']
+ xy = [824, 599, 824, 585, 820, 585, 829, 585]
+ TkcLine.new(@canvas, xy, :fill=>@C['fg'], :width=>3, :tag=>'I15a')
+ xy = [789, 599, 836, 643]
+ TkcRectangle.new(@canvas, xy, :fill=>color, :outline=>@C['fg'], :width=>3)
+ xy = [778, 610, 788, 632]
+ TkcRectangle.new(@canvas, xy, :fill=>color, :outline=>@C['fg'], :width=>3)
+ xy = [766, 617, 776, 625]
+ TkcRectangle.new(@canvas, xy, :fill=>color, :outline=>@C['fg'], :width=>3)
+
+ xy = [633, 600, 681, 640]
+ TkcRectangle.new(@canvas, xy, :fill=>color, :outline=>@C['fg'], :width=>3)
+ xy = [635, 567, 657, 599]
+ TkcRectangle.new(@canvas, xy, :fill=>color, :outline=>@C['fg'], :width=>2)
+ xy = [765, 557, 784, 583]
+ TkcRectangle.new(@canvas, xy, :fill=>color, :outline=>@C['fg'], :width=>2)
+
+ sine([658, 580, 765, 580], 3, 15,
+ :tag=>'I15_s', :fill=>@C['fg'], :width=>3)
+ end
+
+ def move15a
+ color = @C['15b']
+ @canvas.scale('I15a', 824, 599, 1, 0.3) # Button down
+ xy = [765, 621, 681, 621]
+ TkcLine.new(@canvas, xy, :dash=>'-', :width=>3, :fill=>color, :tag=>'I15')
+ end
+
+ def move15(step = nil)
+ step = get_step(15, step)
+
+ numsteps = 6
+
+ if step == numsteps + 2
+ move_abs('I15_star', [-100, -100])
+ return 2
+ end
+ if step == 0 # Break the light beam
+ sparkle([-100, -100], 'I15_star')
+ xy = [765, 621, 745, 621]
+ @canvas.coords('I15', xy)
+ return 1
+ end
+ x0, y0 = anchor('I15_s', :w)
+ x1, y1 = anchor('I15_s', :e)
+ x = x0 + (x1 - x0) * (step - 1) / numsteps.to_f
+ move_abs('I15_star', [x, y0])
+ return 1
+ end
+
+ # Bell
+ def draw16
+ color = @C['16']
+ xy = [722, 485, 791, 556]
+ TkcRectangle.new(@canvas, xy, :fill=>'', :outline=>@C['fg'], :width=>3)
+ xy = box(752, 515, 25) # Bell
+ TkcOval.new(@canvas, xy, :fill=>color, :outline=>'black',
+ :tag=>'I16b', :width=>2)
+ xy = box(752, 515, 5) # Bell button
+ TkcOval.new(@canvas, xy, :fill=>'black', :outline=>'black', :tag=>'I16b')
+
+ xy = [784, 523, 764, 549] # Clapper
+ TkcLine.new(@canvas, xy, :width=>3, :tag=>'I16c', :fill=>@C['fg'])
+ xy = box(784, 523, 4)
+ TkcOval.new(@canvas, xy, :fill=>@C['fg'], :outline=>@C['fg'], :tag=>'I16d')
+ end
+
+ def move16(step = nil)
+ step = get_step(16, step)
+
+ # Note: we never stop
+ ox, oy = [760, 553]
+ if (step & 1).nonzero?
+ beta = 12
+ @canvas.move('I16b', 3, 0)
+ else
+ beta = -12
+ @canvas.move('I16b', -3, 0)
+ end
+ rotate_item('I16c', ox, oy, beta)
+ rotate_item('I16d', ox, oy, beta)
+
+ return ((step == 1)? 3: 1)
+ end
+
+ # Cat
+ def draw17
+ color = @C['17']
+
+ xy = [584, 556, 722, 556]
+ TkcLine.new(@canvas, xy, :fill=>@C['fg'], :width=>3)
+ xy = [584, 485, 722, 485]
+ TkcLine.new(@canvas, xy, :fill=>@C['fg'], :width=>3)
+
+ xy = [664, 523, 717, 549] # Body
+ TkcArc.new(@canvas, xy, :outline=>@C['fg'], :fill=>color, :width=>3,
+ :style=>:chord, :start=>128, :extent=>260, :tag=>'I17')
+
+ xy = [709, 554, 690, 543] # Paw
+ TkcOval.new(@canvas, xy, :outline=>@C['fg'], :fill=>color,
+ :width=>3, :tag=>'I17')
+ xy = [657, 544, 676, 555]
+ TkcOval.new(@canvas, xy, :outline=>@C['fg'], :fill=>color,
+ :width=>3, :tag=>'I17')
+
+ xy = box(660, 535, 15) # Lower face
+ TkcArc.new(@canvas, xy, :outline=>@C['fg'], :width=>3, :style=>:arc,
+ :start=>150, :extent=>240, :tag=>'I17_')
+ TkcArc.new(@canvas, xy, :outline=>'', :fill=>color, :width=>1,
+ :style=>:chord, :start=>150, :extent=>240, :tag=>'I17_')
+ xy = [674, 529, 670, 513, 662, 521, 658, 521, 650, 513, 647, 529] # Ears
+ TkcLine.new(@canvas, xy, :fill=>@C['fg'], :width=>3, :tag=>'I17_')
+ TkcPolygon.new(@canvas, xy, :fill=>color, :outline=>'', :width=>1,
+ :tag=>['I17_', 'I17_c'])
+ xy = [652, 542, 628, 539] # Whiskers
+ TkcLine.new(@canvas, xy, :fill=>@C['fg'], :width=>3, :tag=>'I17_')
+ xy = [652, 543, 632, 545]
+ TkcLine.new(@canvas, xy, :fill=>@C['fg'], :width=>3, :tag=>'I17_')
+ xy = [652, 546, 632, 552]
+ TkcLine.new(@canvas, xy, :fill=>@C['fg'], :width=>3, :tag=>'I17_')
+
+ xy = [668, 543, 687, 538]
+ TkcLine.new(@canvas, xy, :fill=>@C['fg'], :width=>3,
+ :tag=>['I17_', 'I17_w'])
+ xy = [668, 544, 688, 546]
+ TkcLine.new(@canvas, xy, :fill=>@C['fg'], :width=>3,
+ :tag=>['I17_', 'I17_w'])
+ xy = [668, 547, 688, 553]
+ TkcLine.new(@canvas, xy, :fill=>@C['fg'], :width=>3,
+ :tag=>['I17_', 'I17_w'])
+
+ xy = [649, 530, 654, 538, 659, 530] # Left eye
+ TkcLine.new(@canvas, xy, :fill=>@C['fg'], :width=>2,
+ :smooth=>true, :tag=>'I17')
+ xy = [671, 530, 666, 538, 661, 530] # Right eye
+ TkcLine.new(@canvas, xy, :fill=>@C['fg'], :width=>2,
+ :smooth=>true, :tag=>'I17')
+ xy = [655, 543, 660, 551, 665, 543] # Mouth
+ TkcLine.new(@canvas, xy, :fill=>@C['fg'], :width=>2,
+ :smooth=>true, :tag=>'I17')
+ end
+
+ def move17(step = nil)
+ step = get_step(17, step)
+
+ if step == 0
+ @canvas.delete('I17') # Delete most of the cat
+ xy = [655, 543, 660, 535, 665, 543] # Mouth
+ TkcLine.new(@canvas, xy, :fill=>@C['fg'], :width=>3,
+ :smooth=>true, :tag=>'I17_')
+ xy = box(654, 530, 4) # Left eye
+ TkcOval.new(@canvas, xy, :outline=>@C['fg'], :width=>3, :fill=>'',
+ :tag=>'I17_')
+ xy = box(666, 530, 4) # Right eye
+ TkcOval.new(@canvas, xy, :outline=>@C['fg'], :width=>3, :fill=>'',
+ :tag=>'I17_')
+
+ @canvas.move('I17_', 0, -20) # Move face up
+ xy = [652, 528, 652, 554] # Front leg
+ TkcLine.new(@canvas, xy, :fill=>@C['fg'], :width=>3, :tag=>'I17_')
+ xy = [670, 528, 670, 554] # 2nd front leg
+ TkcLine.new(@canvas, xy, :fill=>@C['fg'], :width=>3, :tag=>'I17_')
+
+ xy = [ # Body
+ 675, 506, 694, 489, 715, 513, 715, 513, 715, 513, 716, 525,
+ 716, 525, 716, 525, 706, 530, 695, 530, 679, 535, 668, 527,
+ 668, 527, 668, 527, 675, 522, 676, 517, 677, 512
+ ]
+ TkcPolygon.new(@canvas, xy, :fill=>@canvas.itemcget('I17_c', :fill),
+ :outline=>@C['fg'], :width=>3, :smooth=>true,
+ :tag=>'I17_')
+ xy = [716, 514, 716, 554] # Back leg
+ TkcLine.new(@canvas, xy, :fill=>@C['fg'], :width=>3, :tag=>'I17_')
+ xy = [694, 532, 694, 554] # 2nd back leg
+ TkcLine.new(@canvas, xy, :fill=>@C['fg'], :width=>3, :tag=>'I17_')
+ xy = [715, 514, 718, 506, 719, 495, 716, 488] # Tail
+ TkcLine.new(@canvas, xy, :fill=>@C['fg'], :width=>3,
+ :smooth=>true, :tag=>'I17_')
+
+ @canvas.raise('I17w') # Make whiskers visible
+ @canvas.move('I17_', -5, 0) # Move away from the wall a bit
+ return 2
+ end
+ return 0
+ end
+
+ # Sling shot
+ def draw18
+ color = @C['18']
+ xy = [721, 506, 627, 506] # Sling hold
+ TkcLine.new(@canvas, xy, :width=>4, :fill=>@C['fg'], :tag=>'I18')
+
+ xy = [607, 500, 628, 513] # Sling rock
+ TkcOval.new(@canvas, xy, :fill=>color, :outline=>'', :tag=>'I18a')
+
+ xy = [526, 513, 606, 507, 494, 502] # Sling band
+ TkcLine.new(@canvas, xy, :fill=>@C['fg'], :width=>4, :tag=>'I18b')
+ xy = [485, 490, 510, 540, 510, 575, 510, 540, 535, 491] # Sling
+ TkcLine.new(@canvas, xy, :fill=>@C['fg'], :width=>6)
+ end
+
+ def move18(step = nil)
+ step = get_step(18, step)
+
+ pos = [
+ [587, 506], [537, 506], [466, 506], [376, 506], [266, 506, :x],
+ [136, 506], [16, 506], [-100, -100]
+ ]
+
+ b = []
+ b[0] = [490, 502, 719, 507, 524, 512] # Band collapsing
+ b[1] = [
+ 491, 503, 524, 557, 563, 505, 559, 496, 546, 506, 551, 525,
+ 553, 536, 538, 534, 532, 519, 529, 499
+ ]
+ b[2] = [
+ 491, 503, 508, 563, 542, 533, 551, 526, 561, 539, 549, 550, 530, 500
+ ]
+ b[3] = [
+ 491, 503, 508, 563, 530, 554, 541, 562, 525, 568, 519, 544, 530, 501
+ ]
+
+ return 0 if step >= pos.length
+
+ if step == 0
+ @canvas.delete('I18')
+ @canvas.itemconfigure('I18b', :smooth=>true)
+ end
+ if b[step]
+ @canvas.coords('I18b', b[step])
+ end
+
+ where = pos[step]
+ move_abs('I18a', where)
+ return 3 if where[2] == :x
+ return 1
+ end
+
+ # Water pipe
+ def draw19
+ color = @C['19']
+ xx = [[249, 181], [155, 118], [86, 55], [22, 0]]
+ xx.each{|x1, x2|
+ TkcRectangle.new(@canvas, x1, 453, x2, 467,
+ :fill=>color, :outline=>'', :tag=>'I19')
+ TkcLine.new(@canvas, x1, 453, x2, 453,
+ :fill=>@C['fg'], :width=>1) # Pipe top
+ TkcLine.new(@canvas, x1, 467, x2, 467,
+ :fill=>@C['fg'], :width=>1) # Pipe bottom
+ }
+ @canvas.raise('I11i')
+
+ xy = box(168, 460, 16) # Bulge by the joint
+ TkcOval.new(@canvas, xy, :fill=>color, :outline=>'')
+ TkcArc.new(@canvas, xy, :outline=>@C['fg'], :width=>1, :style=>:arc,
+ :start=>21, :extent=>136)
+ TkcArc.new(@canvas, xy, :outline=>@C['fg'], :width=>1, :style=>:arc,
+ :start=>-21, :extent=>-130)
+
+ xy = [249, 447, 255, 473] # First joint 26x6
+ TkcRectangle.new(@canvas, xy, :fill=>color, :outline=>@C['fg'], :width=>1)
+
+ xy = box(257, 433, 34) # Bend up
+ TkcArc.new(@canvas, xy, :outline=>'', :fill=>color, :width=>1,
+ :style=>:pie, :start=>0, :extent=>-91)
+ TkcArc.new(@canvas, xy, :outline=>@C['fg'], :width=>1,
+ :style=>:arc, :start=>0, :extent=>-90)
+ xy = box(257, 433, 20)
+ TkcArc.new(@canvas, xy, :outline=>'', :fill=>@C['bg'], :width=>1,
+ :style=>:pie, :start=>0, :extent=>-92)
+ TkcArc.new(@canvas, xy, :outline=>@C['fg'], :width=>1,
+ :style=>:arc, :start=>0, :extent=>-90)
+ xy = box(257, 421, 34) # Bend left
+ TkcArc.new(@canvas, xy, :outline=>'', :fill=>color, :width=>1,
+ :style=>:pie, :start=>0, :extent=>91)
+ TkcArc.new(@canvas, xy, :outline=>@C['fg'], :width=>1,
+ :style=>:arc, :start=>0, :extent=>90)
+ xy = box(257, 421, 20)
+ TkcArc.new(@canvas, xy, :outline=>'', :fill=>@C['bg'], :width=>1,
+ :style=>:pie, :start=>0, :extent=>90)
+ TkcArc.new(@canvas, xy, :outline=>@C['fg'], :width=>1,
+ :style=>:arc, :start=>0, :extent=>90)
+ xy = box(243, 421, 34) # Bend down
+ TkcArc.new(@canvas, xy, :outline=>'', :fill=>color, :width=>1,
+ :style=>:pie, :start=>90, :extent=>90)
+ TkcArc.new(@canvas, xy, :outline=>@C['fg'], :width=>1,
+ :style=>:arc, :start=>90, :extent=>90)
+ xy = box(243, 421, 20)
+ TkcArc.new(@canvas, xy, :outline=>'', :fill=>@C['bg'], :width=>1,
+ :style=>:pie, :start=>90, :extent=>90)
+ TkcArc.new(@canvas, xy, :outline=>@C['fg'], :width=>1,
+ :style=>:arc, :start=>90, :extent=>90)
+
+ xy = [270, 427, 296, 433] # 2nd joint bottom
+ TkcRectangle.new(@canvas, xy, :fill=>color, :outline=>@C['fg'], :width=>1)
+ xy = [270, 421, 296, 427] # 2nd joint top
+ TkcRectangle.new(@canvas, xy, :fill=>color, :outline=>@C['fg'], :width=>1)
+ xy = [249, 382, 255, 408] # Third joint right
+ TkcRectangle.new(@canvas, xy, :fill=>color, :outline=>@C['fg'], :width=>1)
+ xy = [243, 382, 249, 408] # Third joint left
+ TkcRectangle.new(@canvas, xy, :fill=>color, :outline=>@C['fg'], :width=>1)
+ xy = [203, 420, 229, 426] # Last joint
+ TkcRectangle.new(@canvas, xy, :fill=>color, :outline=>@C['fg'], :width=>1)
+
+ xy = box(168, 460, 6) # Handle joint
+ TkcOval.new(@canvas, xy, :fill=>@C['fg'], :outline=>'', :tag=>'I19a')
+ xy = [168, 460, 168, 512] # Handle bar
+ TkcLine.new(@canvas, xy, :fill=>@C['fg'], :width=>5, :tag=>'I19b')
+ end
+
+ def move19(step = nil)
+ step = get_step(19, step)
+
+ angles = [30, 30, 30]
+ return 2 if step == angles.length
+ ox, oy = centroid('I19a')
+ rotate_item('I19b', ox, oy, angles[step])
+
+ return 1
+ end
+
+ # Water pouring
+ def draw20
+ # do nothing
+ end
+
+ def move20(step = nil)
+ step = get_step(20, step)
+
+ pos = [451, 462, 473, 484, 496, 504, 513, 523, 532]
+ freq = [20, 40, 40, 40, 40, 40, 40, 40, 40]
+ pos = [
+ [451, 20], [462, 40], [473, 40], [484, 40], [496, 40],
+ [504, 40], [513, 40], [523, 40], [532, 40, :x]
+ ]
+ return 0 if step >= pos.length
+
+ @canvas.delete('I20')
+ where = pos[step]
+ y, f = where
+ h20(y, f)
+ return 3 if where[2] == :x
+ return 1
+ end
+
+ def h20(y, f)
+ color = @C['20']
+ @canvas.delete('I20')
+
+ sine([208, 428, 208, y], 4, f, :tag=>['I20', 'I20s'],
+ :width=>3, :fill=>color, :smooth=>true)
+ TkcLine.new(@canvas, @canvas.coords('I20s'), :width=>3,
+ :fill=>color, :smooth=>1, :tag=>['I20', 'I20a'])
+ TkcLine.new(@canvas, @canvas.coords('I20s'), :width=>3,
+ :fill=>color, :smooth=>1, :tag=>['I20', 'I20b'])
+ @canvas.move('I20a', 8, 0)
+ @canvas.move('I20b', 16, 0)
+ end
+
+ # Bucket
+ def draw21
+ color = @C['21']
+ xy = [217, 451, 244, 490] # Right handle
+ TkcLine.new(@canvas, xy, :fill=>@C['fg'], :width=>2, :tag=>'I21_a')
+ xy = [201, 467, 182, 490] # Left handle
+ TkcLine.new(@canvas, xy, :fill=>@C['fg'], :width=>2, :tag=>'I21_a')
+
+ xy = [245, 490, 237, 535] # Right side
+ xy2 = [189, 535, 181, 490] # Left side
+ TkcPolygon.new(@canvas, xy + xy2, :fill=>color, :outline=>'',
+ :tag=>['I21', 'I21f'])
+ TkcLine.new(@canvas, xy, :fill=>@C['fg'], :width=>2, :tag=>'I21')
+ TkcLine.new(@canvas, xy2, :fill=>@C['fg'], :width=>2, :tag=>'I21')
+
+ xy = [182, 486, 244, 498] # Top
+ TkcOval.new(@canvas, xy, :fill=>color, :outline=>'', :width=>2,
+ :tag=>['I21', 'I21f'])
+ TkcOval.new(@canvas, xy, :fill=>'', :outline=>@C['fg'], :width=>2,
+ :tag=>['I21', 'I21t'])
+ xy = [189, 532, 237, 540] # Bottom
+ TkcOval.new(@canvas, xy, :fill=>color, :outline=>@C['fg'], :width=>2,
+ :tag=>['I21', 'I21b'])
+ end
+
+ def move21(step = nil)
+ step = get_step(21, step)
+
+ numsteps = 30
+ return 0 if step >= numsteps
+
+ x1, y1, x2, y2 = @canvas.coords('I21b')
+ # lx1, ly1, lx2, ly2 = @canvas.coords('I21t')
+ lx1, ly1, lx2, ly2 = [183, 492, 243, 504]
+
+ f = step / numsteps.to_f
+ y2 = y2 - 3
+ xx1 = x1 + (lx1 - x1) * f
+ yy1 = y1 + (ly1 - y1) * f
+ xx2 = x2 + (lx2 - x2) * f
+ yy2 = y2 + (ly2 - y2) * f
+
+ @canvas.itemconfigure('I21b', :fill=>@C['20'])
+ @canvas.delete('I21w')
+ TkcPolygon.new(@canvas, x2, y2, x1, y1, xx1, yy1, xx2, yy1,
+ :tag=>['I21', 'I21w'], :outline=>'', :fill=>@C['20'])
+ @canvas.lower('I21w', 'I21')
+ @canvas.raise('I21b')
+ @canvas.lower('I21f')
+
+ return((step == numsteps - 1)? 3: 1)
+ end
+
+ # Bucket drop
+ def draw22
+ # do nothing
+ end
+
+ def move22(step = nil)
+ step = get_step(22, step)
+ pos = [[213, 513], [213, 523], [213, 543, :x], [213, 583], [213, 593]]
+
+ @canvas.itemconfigure('I21f', :fill=>@C['22']) if step == 0
+ return 0 if step >= pos.length
+ where = pos[step]
+ move_abs('I21', where)
+ h20(where[1], 40)
+ @canvas.delete('I21_a') # Delete handles
+
+ return 3 if where[2] == :x
+ return 1
+ end
+
+ # Blow dart
+ def draw23
+ color = @C['23a']
+ color2 = @C['23b']
+ color3 = @C['23c']
+
+ xy = [185, 623, 253, 650] # Block
+ TkcRectangle.new(@canvas, xy, :fill=>'black', :outline=>@C['fg'],
+ :width=>2, :tag=>'I23a')
+ xy = [187, 592, 241, 623] # Balloon
+ TkcOval.new(@canvas, xy, :outline=>'', :fill=>color, :tag=>'I23b')
+ TkcArc.new(@canvas, xy, :outline=>@C['fg'], :width=>3, :tag=>'I23b',
+ :style=>:arc, :start=>12, :extent=>336)
+ xy = [239, 604, 258, 589, 258, 625, 239, 610] # Balloon nozzle
+ TkcPolygon.new(@canvas, xy, :outline=>'', :fill=>color, :tag=>'I23b')
+ TkcLine.new(@canvas, xy, :fill=>@C['fg'], :width=>3, :tag=>'I23b')
+
+ xy = [285, 611, 250, 603] # Dart body
+ TkcOval.new(@canvas, xy, :fill=>color2, :outline=>@C['fg'],
+ :width=>3, :tag=>'I23d')
+ xy = [249, 596, 249, 618, 264, 607, 249, 596] # Dart tail
+ TkcPolygon.new(@canvas, xy, :fill=>color3, :outline=>@C['fg'],
+ :width=>3, :tag=>'I23d')
+ xy = [249, 607, 268, 607] # Dart detail
+ TkcLine.new(@canvas, xy, :fill=>@C['fg'], :width=>3, :tag=>'I23d')
+ xy = [285, 607, 305, 607] # Dart needle
+ TkcLine.new(@canvas, xy, :fill=>@C['fg'], :width=>3, :tag=>'I23d')
+ end
+
+ def move23(step = nil)
+ step = get_step(23, step)
+
+ pos = [
+ [277, 607], [287, 607], [307, 607, :x], [347, 607], [407, 607],
+ [487, 607], [587, 607], [687, 607], [787, 607], [-100, -100]
+ ]
+
+ return 0 if step >= pos.length
+ if step <= 1
+ ox, oy = anchor('I23a', :n)
+ @canvas.scale('I23b', ox, oy, 0.9, 0.5)
+ end
+ where = pos[step]
+ move_abs('I23d', where)
+
+ return 3 if where[2] == :x
+ return 1
+ end
+
+ # Balloon
+ def draw24
+ color = @C['24a']
+ xy = [366, 518, 462, 665] # Balloon
+ TkcOval.new(@canvas, xy, :fill=>color, :outline=>@C['fg'],
+ :width=>3, :tag=>'I24')
+ xy = [414, 666, 414, 729] # String
+ TkcLine.new(@canvas, xy, :fill=>@C['fg'], :width=>3, :tag=>'I24')
+ xy = [410, 666, 404, 673, 422, 673, 418, 666] # Nozzle
+ TkcPolygon.new(@canvas, xy, :fill=>color, :outline=>@C['fg'],
+ :width=>3, :tag=>'I24')
+
+ xy = [387, 567, 390, 549, 404, 542] # Reflections
+ TkcLine.new(@canvas, xy, :fill=>@C['fg'], :smooth=>true,
+ :width=>2, :tag=>'I24')
+ xy = [395, 568, 399, 554, 413, 547]
+ TkcLine.new(@canvas, xy, :fill=>@C['fg'], :smooth=>true,
+ :width=>2, :tag=>'I24')
+ xy = [403, 570, 396, 555, 381, 553]
+ TkcLine.new(@canvas, xy, :fill=>@C['fg'], :smooth=>true,
+ :width=>2, :tag=>'I24')
+ xy = [408, 564, 402, 547, 386, 545]
+ TkcLine.new(@canvas, xy, :fill=>@C['fg'], :smooth=>true,
+ :width=>2, :tag=>'I24')
+ end
+
+ def move24(step = nil)
+ step = get_step(24, step)
+
+ return 0 if step > 4
+ return 2 if step == 4
+
+ if step == 0
+ @canvas.delete('I24') # Exploding balloon
+ xy = [
+ 347, 465, 361, 557, 271, 503, 272, 503, 342, 574, 259, 594,
+ 259, 593, 362, 626, 320, 737, 320, 740, 398, 691, 436, 738,
+ 436, 739, 476, 679, 528, 701, 527, 702, 494, 627, 548, 613,
+ 548, 613, 480, 574, 577, 473, 577, 473, 474, 538, 445, 508,
+ 431, 441, 431, 440, 400, 502, 347, 465, 347, 465
+ ]
+ TkcPolygon.new(@canvas, xy, :tag=>'I24', :fill=>@C['24b'],
+ :outline=>@C['24a'], :width=>10, :smooth=>true)
+ msg = Tk.subst(@S['message'].value)
+ TkcText.new(@canvas, centroid('I24'), :text=>msg, :tag=>['I24', 'I24t'],
+ :justify=>:center, :font=>['Times Roman', 18, :bold])
+ return 1
+ end
+
+ @canvas.itemconfigure('I24t', :font=>['Times Roman', 18 + 6*step, :bold])
+ @canvas.move('I24', 0, -60)
+ ox, oy = centroid('I24')
+ @canvas.scale('I24', ox, oy, 1.25, 1.25)
+ return 1
+ end
+
+ # Displaying the message
+ def move25(step = nil)
+ step = get_step(25, step)
+
+ if step == 0
+ @XY['25'] = Tk::Clock.clicks(:miliseconds)
+ return 1
+ end
+ elapsed = Tk::Clock.clicks(:miliseconds) - @XY['25']
+ return 1 if elapsed < 5000
+ return 2
+ end
+
+ # Collapsing balloon
+ def move26(step = nil)
+ step = get_step(26, step)
+
+ if step >= 3
+ @canvas.delete('I24', 'I26')
+ TkcText.new(@canvas, 430, 740, :anchor=>:s, :tag=>'I26',
+ :text=>'click to continue',
+ :font=>['Times Roman', 24, :bold])
+ @canvas.bind('1', proc{reset})
+ return 4
+ end
+
+ ox, oy = centroid('I24')
+ @canvas.scale('I24', ox, oy, 0.8, 0.8)
+ @canvas.move('I24', 0, 60)
+ @canvas.itemconfigure('I24t', :font=>['Times Roman', 30 - 6*step, :bold])
+ return 1
+ end
+
+ ################################################################
+ #
+ # Helper functions
+ #
+ def box(x, y, r)
+ [x - r, y - r, x + r, y + r]
+ end
+
+ def move_abs(item, xy)
+ x, y = xy
+ ox, oy = centroid(item)
+ dx = x - ox
+ dy = y - oy
+ @canvas.move(item, dx, dy)
+ end
+
+ def rotate_item(item, ox, oy, beta)
+ xy = @canvas.coords(item)
+ xy2 = []
+ 0.step(xy.length - 1, 2){|idx|
+ x, y = xy[idx, 2]
+ xy2.concat(rotate_c(x, y, ox, oy, beta))
+ }
+ @canvas.coords(item, xy2)
+ end
+
+ def rotate_c(x, y, ox, oy, beta)
+ # rotates vector (ox,oy)->(x,y) by beta degrees clockwise
+
+ x -= ox # Shift to origin
+ y -= oy
+
+ beta = beta * Math.atan(1) * 4 / 180.0 # Radians
+ xx = x * Math.cos(beta) - y * Math.sin(beta) # Rotate
+ yy = x * Math.sin(beta) + y * Math.cos(beta)
+
+ xx += ox # Shift back
+ yy += oy
+
+ [xx, yy]
+ end
+
+ def reset
+ draw_all
+ @canvas.bind_remove('1')
+ @S['mode'].value = :MSTART
+ @S['active'] = [0]
+ end
+
+ # Each Move## keeps its state info in STEP, this retrieves and increments it
+ def get_step(who, step)
+ if step
+ @STEP[who] = step
+ else
+ if !@STEP.exist?(who) || @STEP[who] == ""
+ @STEP[who] = 0
+ else
+ @STEP[who] += 1
+ end
+ end
+ @STEP[who]
+ end
+
+ def reset_step
+ @S['cnt'].value = 0
+ @STEP.keys.each{|k| @STEP[k] = ''}
+ end
+
+ def sine(xy0, amp, freq, opts = {})
+ x0, y0, x1, y1 = xy0
+ step = 2
+ xy = []
+ if y0 == y1 # Horizontal
+ x0.step(x1, step){|x|
+ beta = (x - x0) * 2 * Math::PI / freq
+ y = y0 + amp * Math.sin(beta)
+ xy << x << y
+ }
+ else
+ y0.step(y1, step){|y|
+ beta = (y - y0) * 2 * Math::PI / freq
+ x = x0 + amp * Math.sin(beta)
+ xy << x << y
+ }
+ end
+ TkcLine.new(@canvas, xy, opts)
+ end
+
+ def round_rect(xy, radius, opts={})
+ x0, y0, x3, y3 = xy
+ r = @canvas.winfo_pixels(radius)
+ d = 2 * r
+
+ # Make sure that the radius of the curve is less than 3/8 size of the box!
+ maxr = 0.75
+ if d > maxr * (x3 - x0)
+ d = maxr * (x3 - x0)
+ end
+ if d > maxr * (y3 - y0)
+ d = maxr * (y3 - y0)
+ end
+
+ x1 = x0 + d
+ x2 = x3 - d
+ y1 = y0 + d
+ y2 = y3 - d
+
+ xy = [x0, y0, x1, y0, x2, y0, x3, y0, x3, y1, x3, y2]
+ xy.concat([x3, y3, x2, y3, x1, y3, x0, y3, x0, y2, x0, y1])
+ return xy
+ end
+
+ def round_poly(canv, xy, radii, opts)
+ lenXY = xy.length
+ lenR = radii.length
+ if lenXY != 2*lenR
+ raise "wrong number of vertices and radii"
+ end
+
+ knots = []
+ x0 = xy[-2]; y0 = xy[-1]
+ x1 = xy[0]; y1 = xy[1]
+ xy << xy[0] << xy[1]
+
+ 0.step(lenXY - 1, 2){|i|
+ radius = radii[i/2]
+ r = canv.winfo_pixels(radius)
+
+ x2 = xy[i+2]; y2 = xy[i+3]
+ z = _round_poly2(x0, y0, x1, y1, x2, y2, r)
+ knots.concat(z)
+
+ x0 = x1; y0 = y1
+ x1 = x2; y1 = y2
+ }
+ TkcPolygon.new(canv, knots, {:smooth=>true}.update(opts))
+ end
+
+ def _round_poly2(x0, y0, x1, y1, x2, y2, radius)
+ d = 2 * radius
+ maxr = 0.75
+
+ v1x = x0 - x1
+ v1y = y0 - y1
+ v2x = x2 - x1
+ v2y = y2 - y1
+
+ vlen1 = Math.sqrt(v1x*v1x + v1y*v1y)
+ vlen2 = Math.sqrt(v2x*v2x + v2y*v2y)
+
+ if d > maxr * vlen1
+ d = maxr * vlen1
+ end
+ if d > maxr * vlen2
+ d = maxr * vlen2
+ end
+
+ xy = []
+ xy << (x1 + d * v1x / vlen1) << (y1 + d * v1y / vlen1)
+ xy << x1 << y1
+ xy << (x1 + d * v2x / vlen2) << (y1 + d * v2y / vlen2)
+
+ return xy
+ end
+
+ def sparkle(oxy, tag)
+ xy = [
+ [299, 283], [298, 302], [295, 314], [271, 331],
+ [239, 310], [242, 292], [256, 274], [281, 273]
+ ]
+ xy.each{|x, y|
+ TkcLine.new(@canvas, 271, 304, x, y,
+ :fill=>'white', :width=>3, :tag=>tag)
+ }
+ move_abs(tag, oxy)
+ end
+
+ def centroid(item)
+ anchor(item, :c)
+ end
+
+ def anchor(item, where)
+ x1, y1, x2, y2 = @canvas.bbox(item)
+ case(where)
+ when :n
+ y = y1
+ when :s
+ y = y2
+ else
+ y = (y1 + y2) / 2.0
+ end
+ case(where)
+ when :w
+ x = x1
+ when :e
+ x = x2
+ else
+ x = (x1 + x2) / 2.0
+ end
+ return [x, y]
+ end
+end
+
+TkGoldberg_Demo.new(base_frame)
diff --git a/jni/ruby/ext/tk/sample/demos-en/hello b/jni/ruby/ext/tk/sample/demos-en/hello
new file mode 100644
index 0000000..5e86ad7
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/demos-en/hello
@@ -0,0 +1,14 @@
+#!/usr/bin/env ruby
+require 'tk'
+
+#unless /^8\.[1-9]/ =~ Tk::TCL_VERSION && !Tk::JAPANIZED_TK
+# require 'tkencoding'
+#end
+
+TkButton.new(nil,
+ 'text'=>"Hello Ruby world!",
+ 'font'=>TkFont.new('k14'),
+ 'command'=>proc{print "Hello Ruby world!\n"; exit}
+).pack
+
+Tk.mainloop
diff --git a/jni/ruby/ext/tk/sample/demos-en/hscale.rb b/jni/ruby/ext/tk/sample/demos-en/hscale.rb
new file mode 100644
index 0000000..e660216
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/demos-en/hscale.rb
@@ -0,0 +1,75 @@
+require "tkcanvas"
+
+if defined?($hscale_demo) && $hscale_demo
+ $hscale_demo.destroy
+ $hscale_demo = nil
+end
+
+$hscale_demo = TkToplevel.new {|w|
+ title("Horizontal Scale Demonstration")
+ iconname("hscale")
+}
+positionWindow($hscale_demo)
+
+base_frame = TkFrame.new($hscale_demo).pack(:fill=>:both, :expand=>true)
+
+msg = TkLabel.new(base_frame) {
+ font $font
+ wraplength '3.5i'
+ justify 'left'
+ text "An arrow and a horizontal scale are displayed below. If you click or drag mouse button 1 in the scale, you can change the length of the arrow."
+}
+msg.pack('side'=>'top')
+
+TkFrame.new(base_frame) {|frame|
+ TkButton.new(frame) {
+ text 'Dismiss'
+ command proc {
+ tmppath = $hscale_demo
+ $hscale_demo = nil
+ tmppath.destroy
+ }
+ }.pack('side'=>'left', 'expand'=>'yes')
+
+ TkButton.new(frame) {
+ text 'Show Code'
+ command proc { showCode 'hscale' }
+ }.pack('side'=>'left', 'expand'=>'yes')
+}.pack('side'=>'bottom', 'fill'=>'x', 'pady'=>'2m')
+
+
+def setWidth(w, width)
+ width = width + 21
+ x2 = width - 30
+ if x2 < 21
+ x2 = 21
+ end
+ w.coords 'poly',20,15,20,35,x2,35,x2,45,width,25,x2,5,x2,15,20,15
+ w.coords 'line',20,15,20,35,x2,35,x2,45,width,25,x2,5,x2,15,20,15
+end
+
+TkFrame.new(base_frame) {|frame|
+ canvas = TkCanvas.new(frame) {|c|
+ width 50
+ height 50
+ bd 0
+ highlightthickness 0
+ TkcPolygon.new(c, '0', '0', '1', '1', '2', '2') {
+ fill 'DeepSkyBlue'
+ tags 'poly'
+ }
+ TkcLine.new(c, '0', '0', '1', '1', '2', '2', '0', '0') {
+ fill 'black'
+ tags 'line'
+ }
+ }.pack('side'=>'top', 'expand'=>'yes', 'anchor'=>'s', 'fill'=>'x', 'padx'=>'15')
+ scale = TkScale.new(frame) {
+ orient 'horizontal'
+ length 284
+ from 0
+ to 250
+ command proc{|value| setWidth(canvas, value)}
+ tickinterval 50
+ }.pack('side'=>'bottom', 'expand'=>'yes', 'anchor'=>'n')
+ scale.set 75
+}.pack('side'=>'top', 'fill'=>'x')
diff --git a/jni/ruby/ext/tk/sample/demos-en/icon.rb b/jni/ruby/ext/tk/sample/demos-en/icon.rb
new file mode 100644
index 0000000..bab40da
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/demos-en/icon.rb
@@ -0,0 +1,105 @@
+# icon.rb
+#
+# This demonstration script creates a toplevel window containing
+# buttons that display bitmaps instead of text.
+#
+# iconic button widget demo (called by 'widget')
+#
+
+# toplevel widget
+if defined?($icon_demo) && $icon_demo
+ $icon_demo.destroy
+ $icon_demo = nil
+end
+
+# demo toplevel widget
+$icon_demo = TkToplevel.new {|w|
+ title("Iconic Button Demonstration")
+ iconname("icon")
+ positionWindow(w)
+}
+
+base_frame = TkFrame.new($icon_demo).pack(:fill=>:both, :expand=>true)
+
+# label
+msg = TkLabel.new(base_frame) {
+ font $font
+ wraplength '5i'
+ justify 'left'
+ text "This window shows three ways of using bitmaps or images in radiobuttons and checkbuttons. On the left are two radiobuttons, each of which displays a bitmap and an indicator. In the middle is a checkbutton that displays a different image depending on whether it is selected or not. On the right is a checkbutton that displays a single bitmap but changes its background color to indicate whether or not it is selected. (This change is visible when the mouse pointer is not directy over the button.)"
+}
+msg.pack('side'=>'top')
+
+# frame
+TkFrame.new(base_frame) {|frame|
+ TkButton.new(frame) {
+ text 'Dismiss'
+ command proc{
+ tmppath = $icon_demo
+ $icon_demo = nil
+ tmppath.destroy
+ }
+ }.pack('side'=>'left', 'expand'=>'yes')
+
+ TkButton.new(frame) {
+ text 'Show Code'
+ command proc{showCode 'icon'}
+ }.pack('side'=>'left', 'expand'=>'yes')
+
+}.pack('side'=>'bottom', 'fill'=>'x', 'pady'=>'2m')
+
+# image
+flagup = \
+TkBitmapImage.new('file'=>[$demo_dir,'..',
+ 'images','flagup.xbm'].join(File::Separator),
+ 'maskfile'=>\
+ [$demo_dir,'..','images','flagup.xbm'].join(File::Separator))
+flagdown = \
+TkBitmapImage.new('file'=>[$demo_dir,'..',
+ 'images','flagdown.xbm'].join(File::Separator),
+ 'maskfile'=>\
+ [$demo_dir,'..',
+ 'images','flagdown.xbm'].join(File::Separator))
+
+# create variable
+letters = TkVariable.new
+
+# frame
+TkFrame.new(base_frame, 'borderwidth'=>10){|w|
+ TkFrame.new(w) {|f|
+ # TkRadioButton.new(f){
+ Tk::RadioButton.new(f){
+ bitmap '@' + [$demo_dir,'..',
+ 'images','letters.xbm'].join(File::Separator)
+ variable letters
+ value 'full'
+ }.pack('side'=>'top', 'expand'=>'yes')
+
+ # TkRadioButton.new(f){
+ Tk::RadioButton.new(f){
+ bitmap '@' + [$demo_dir,'..',
+ 'images','noletter.xbm'].join(File::Separator)
+ variable letters
+ value 'empty'
+ }.pack('side'=>'top', 'expand'=>'yes')
+
+ }.pack('side'=>'left', 'expand'=>'yes', 'padx'=>'5m')
+
+ # TkCheckButton.new(w) {
+ Tk::CheckButton.new(w) {
+ image flagdown
+ selectimage flagup
+ indicatoron 0
+ selectcolor self['background']
+ }.pack('side'=>'left', 'expand'=>'yes', 'padx'=>'5m')
+
+ # TkCheckButton.new(w) {
+ Tk::CheckButton.new(w) {
+ bitmap '@' + [$demo_dir,'..',
+ 'images','letters.xbm'].join(File::Separator)
+ indicatoron 0
+ selectcolor 'SeaGreen1'
+ }.pack('side'=>'left', 'expand'=>'yes', 'padx'=>'5m')
+
+}.pack('side'=>'top')
+
diff --git a/jni/ruby/ext/tk/sample/demos-en/image1.rb b/jni/ruby/ext/tk/sample/demos-en/image1.rb
new file mode 100644
index 0000000..233cb96
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/demos-en/image1.rb
@@ -0,0 +1,65 @@
+## image1.rb
+#
+# This demonstration script displays two image widgets.
+#
+# two image widgets demo (called by 'widget')
+#
+
+# toplevel widget
+if defined?($image1_demo) && $image1_demo
+ $image1_demo.destroy
+ $image1_demo = nil
+end
+
+# demo toplevel widget
+$image1_demo = TkToplevel.new {|w|
+ title('Image Demonstration #1')
+ iconname("Image1")
+ positionWindow(w)
+}
+
+base_frame = TkFrame.new($image1_demo).pack(:fill=>:both, :expand=>true)
+
+# label
+msg = TkLabel.new(base_frame) {
+ font $font
+ wraplength '4i'
+ justify 'left'
+ text "This demonstration displays two images, each in a separate label widget."
+}
+msg.pack('side'=>'top')
+
+# frame
+TkFrame.new(base_frame) {|frame|
+ TkButton.new(frame) {
+ text 'Dismiss'
+ command proc{
+ tmppath = $image1_demo
+ $image1_demo = nil
+ tmppath.destroy
+ }
+ }.pack('side'=>'left', 'expand'=>'yes')
+
+ TkButton.new(frame) {
+ text 'Show Code'
+ command proc{showCode 'image1'}
+ }.pack('side'=>'left', 'expand'=>'yes')
+
+}.pack('side'=>'bottom', 'fill'=>'x', 'pady'=>'2m')
+
+# image
+image1a = \
+TkPhotoImage.new('file'=>[$demo_dir,'..',
+ 'images','earth.gif'].join(File::Separator))
+image1b = \
+TkPhotoImage.new('file'=>[$demo_dir,'..',
+ 'images','earthris.gif'].join(File::Separator))
+
+# label
+#[ TkLabel.new(base_frame, 'image'=>image1a, 'bd'=>1, 'relief'=>'sunken'),
+# TkLabel.new(base_frame, 'image'=>image1b, 'bd'=>1, 'relief'=>'sunken')
+#].each{|w| w.pack('side'=>'top', 'padx'=>'.5m', 'pady'=>'.5m')}
+[ Tk::Label.new(base_frame, 'image'=>image1a, 'bd'=>1, 'relief'=>'sunken'),
+ Tk::Label.new(base_frame, 'image'=>image1b, 'bd'=>1, 'relief'=>'sunken')
+].each{|w| w.pack('side'=>'top', 'padx'=>'.5m', 'pady'=>'.5m')}
+
diff --git a/jni/ruby/ext/tk/sample/demos-en/image2.rb b/jni/ruby/ext/tk/sample/demos-en/image2.rb
new file mode 100644
index 0000000..13098af
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/demos-en/image2.rb
@@ -0,0 +1,107 @@
+# image2.rb
+#
+# This demonstration script creates a simple collection of widgets
+# that allow you to select and view images in a Tk label.
+#
+# widget demo 'load image' (called by 'widget')
+#
+
+# toplevel widget
+if defined?($image2_demo) && $image2_demo
+ $image2_demo.destroy
+ $image2_demo = nil
+end
+
+# demo toplevel widget
+$image2_demo = TkToplevel.new {|w|
+ title('Image Demonstration #2')
+ iconname("Image2")
+ positionWindow(w)
+}
+
+base_frame = TkFrame.new($image2_demo).pack(:fill=>:both, :expand=>true)
+
+# label
+msg = TkLabel.new(base_frame) {
+ font $font
+ wraplength '4i'
+ justify 'left'
+ text "This demonstration allows you to view images using a Tk \"photo\" image. First type a directory name in the listbox, then press Enter to load the directory into the listbox. Then double-click on a file name in the listbox to see that image."
+}
+msg.pack('side'=>'top')
+
+# frame
+TkFrame.new(base_frame) {|frame|
+ TkButton.new(frame) {
+ text 'Dismiss'
+ command proc{
+ tmppath = $image2_demo
+ $image2_demo = nil
+ tmppath.destroy
+ }
+ }.pack('side'=>'left', 'expand'=>'yes')
+
+ TkButton.new(frame) {
+ text 'Show Code'
+ command proc{showCode 'image2'}
+ }.pack('side'=>'left', 'expand'=>'yes')
+
+}.pack('side'=>'bottom', 'fill'=>'x', 'pady'=>'2m')
+
+# create variable
+$dirName = TkVariable.new([$demo_dir,'..','images'].join(File::Separator))
+
+# image
+$image2a = TkPhotoImage.new
+
+#
+TkLabel.new(base_frame, 'text'=>'Directory:')\
+.pack('side'=>'top', 'anchor'=>'w')
+
+image2_e = TkEntry.new(base_frame) {
+ width 30
+ textvariable $dirName
+}.pack('side'=>'top', 'anchor'=>'w')
+
+TkFrame.new(base_frame, 'height'=>'3m', 'width'=>20)\
+.pack('side'=>'top', 'anchor'=>'w')
+
+TkLabel.new(base_frame, 'text'=>'File:')\
+.pack('side'=>'top', 'anchor'=>'w')
+
+TkFrame.new(base_frame){|w|
+ s = TkScrollbar.new(w)
+ l = TkListbox.new(w) {
+ width 20
+ height 10
+ yscrollcommand proc{|first,last| s.set first,last}
+ }
+ s.command(proc{|*args| l.yview(*args)})
+ l.pack('side'=>'left', 'expand'=>'yes', 'fill'=>'y')
+ s.pack('side'=>'left', 'expand'=>'yes', 'fill'=>'y')
+ #l.insert(0,'earth.gif', 'earthris.gif', 'mickey.gif', 'teapot.ppm')
+ l.insert(0,'earth.gif', 'earthris.gif', 'teapot.ppm')
+ l.bind('Double-1', proc{|x,y| loadImage $image2a,l,x,y}, '%x %y')
+
+ image2_e.bind 'Return', proc{loadDir l}
+
+}.pack('side'=>'top', 'anchor'=>'w')
+
+# image
+[ TkFrame.new(base_frame, 'height'=>'3m', 'width'=>20),
+ TkLabel.new(base_frame, 'text'=>'Image:'),
+ TkLabel.new(base_frame, 'image'=>$image2a)
+].each{|w| w.pack('side'=>'top', 'anchor'=>'w')}
+
+#
+def loadDir(w)
+ w.delete(0,'end')
+ Dir.glob([$dirName,'*'].join(File::Separator)).sort.each{|f|
+ w.insert('end',File.basename(f))
+ }
+end
+
+def loadImage(img,w,x,y)
+ img.file([$dirName, w.get("@#{x},#{y}")].join(File::Separator))
+end
+
diff --git a/jni/ruby/ext/tk/sample/demos-en/image3.rb b/jni/ruby/ext/tk/sample/demos-en/image3.rb
new file mode 100644
index 0000000..edb6d23
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/demos-en/image3.rb
@@ -0,0 +1,125 @@
+# image3.rb
+#
+# This demonstration script creates a simple collection of widgets
+# that allow you to select and view images in a Tk label.
+#
+# widget demo 'load image' (called by 'widget')
+#
+
+# toplevel widget
+if defined?($image3_demo) && $image3_demo
+ $image3_demo.destroy
+ $image3_demo = nil
+end
+
+# demo toplevel widget
+$image3_demo = TkToplevel.new {|w|
+ title('Image Demonstration #3')
+ iconname("Image3")
+ positionWindow(w)
+}
+
+base_frame = TkFrame.new($image3_demo).pack(:fill=>:both, :expand=>true)
+
+#
+def loadDir3(w)
+ w.delete(0,'end')
+ Dir.glob([$dirName,'*'].join(File::Separator)).sort.each{|f|
+ w.insert('end',File.basename(f))
+ }
+end
+
+# selectAndLoadDir3 --
+# This procedure pops up a dialog to ask for a directory to load into
+# the listobx and (if the user presses OK) reloads the directory
+# listbox from the directory named in the demo's entry.
+#
+# Arguments:
+# w - Name of the toplevel window of the demo.
+def selectAndLoadDir3(w, lbox)
+ dir = Tk.chooseDirectory(:initialdir=>$dirName.value,
+ :parent=>w, :mustexist=>true)
+ if dir.length > 0
+ $dirName.value = dir
+ loadDir3(lbox)
+ end
+end
+
+def loadImage(w,x,y)
+ $image3a.file([$dirName, w.get("@#{x},#{y}")].join(File::Separator))
+end
+
+
+# label
+msg = TkLabel.new(base_frame) {
+ font $font
+ wraplength '4i'
+ justify 'left'
+ text "This demonstration allows you to view images using a Tk \"photo\" image. First type a directory name in the listbox, then type Return to load the directory into the listbox. Then double-click on a file name in the listbox to see that image."
+}
+msg.pack('side'=>'top')
+
+# frame
+TkFrame.new(base_frame) {|frame|
+ TkButton.new(frame) {
+ text 'Dismiss'
+ command proc{
+ tmppath = $image3_demo
+ $image3_demo = nil
+ tmppath.destroy
+ }
+ }.pack('side'=>'left', 'expand'=>'yes')
+
+ TkButton.new(frame) {
+ text 'Show Code'
+ command proc{showCode 'image3'}
+ }.pack('side'=>'left', 'expand'=>'yes')
+
+}.pack('side'=>'bottom', 'fill'=>'x', 'pady'=>'2m')
+
+# variable
+$dirName = TkVariable.new([$demo_dir,'..','images'].join(File::Separator))
+
+# image
+begin
+ $image3a.delete
+rescue
+end
+$image3a = TkPhotoImage.new
+
+#
+image3_f = TkFrame.new(base_frame).pack(:fill=>:both, :expand=>true)
+
+image3_df = TkLabelFrame.new(base_frame, :text=>'Directory:')
+
+image3_ff = TkLabelFrame.new(base_frame, :text=>'File:',
+ :padx=>'2m', :pady=>'2m')
+image3_lbx = TkListbox.new(image3_ff, :width=>20, :height=>10) {
+ pack(:side=>:left, :fill=>:y, :expand=>true)
+ yscrollbar(TkScrollbar.new(image3_ff).pack(:side=>:left, :fill=>:y,
+ :expand=>true))
+ insert(0, *(%w(earth.gif earthris.gif teapot.ppm)))
+ bind('Double-1', proc{|x,y| loadImage(self, x, y)}, '%x %y')
+}
+
+image3_ent = TkEntry.new(image3_df, :width=>30, :textvariable=>$dirName){
+ pack(:side=>:left, :fill=>:both, :padx=>'2m', :pady=>'2m', :expand=>true)
+ bind('Return', proc{loadDir3(image3_lbx)})
+}
+
+TkButton.new(image3_df, :pady=>0, :padx=>'2m', :text=>"Select Dir.",
+ :command=>proc{selectAndLoadDir3(image3_ent, image3_lbx)}) {
+ pack(:side=>:left, :fill=>:y, :padx=>[0, '2m'], :pady=>'2m')
+}
+
+image3_if = TkLabelFrame.new(base_frame, :text=>'Image:') {|f|
+ # TkLabel.new(f, :image=>$image3a).pack(:padx=>'2m', :pady=>'2m')
+ Tk::Label.new(f, :image=>$image3a).pack(:padx=>'2m', :pady=>'2m')
+}
+
+Tk.grid(image3_df, '-',
+ :sticky=>:ew, :padx=>'1m', :pady=>'1m', :in=>image3_f)
+Tk.grid(image3_ff, image3_if,
+ :sticky=>:nw, :padx=>'1m', :pady=>'1m', :in=>image3_f)
+TkGrid.columnconfigure(image3_f, 1, :weight=>1)
+
diff --git a/jni/ruby/ext/tk/sample/demos-en/items.rb b/jni/ruby/ext/tk/sample/demos-en/items.rb
new file mode 100644
index 0000000..01a4072
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/demos-en/items.rb
@@ -0,0 +1,381 @@
+# items.rb
+#
+# This demonstration script creates a canvas that displays the
+# canvas item types.
+#
+# canvas item types widget demo (called by 'widget')
+#
+
+# toplevel widget
+if defined?($items_demo) && $items_demo
+ $items_demo.destroy
+ $items_demo = nil
+end
+
+# demo toplevel widget
+$items_demo = TkToplevel.new {|w|
+ title("Canvas Item Demonstration")
+ iconname("Items")
+ positionWindow(w)
+}
+
+base_frame = TkFrame.new($items_demo).pack(:fill=>:both, :expand=>true)
+
+# label
+TkLabel.new(base_frame) {
+ font $font
+ wraplength '5i'
+ justify 'left'
+ text "This window contains a canvas widget with examples of the various kinds of items supported by canvases. The following operations are supported:\n Button-1 drag:\tmoves item under pointer.\n Button-2 drag:\trepositions view.\n Button-3 drag:\tstrokes out area.\n Ctrl+f:\t\tprints items under area."
+}.pack('side'=>'top')
+
+# frame
+TkFrame.new(base_frame) {|frame|
+ TkButton.new(frame) {
+ text 'Dismiss'
+ command proc{
+ tmppath = $items_demo
+ $items_demo = nil
+ tmppath.destroy
+ }
+ }.pack('side'=>'left', 'expand'=>'yes')
+
+ TkButton.new(frame) {
+ text 'Show Code'
+ command proc{showCode 'items'}
+ }.pack('side'=>'left', 'expand'=>'yes')
+}.pack('side'=>'bottom', 'fill'=>'x', 'pady'=>'2m')
+
+# frame
+cvs = nil
+TkFrame.new(base_frame) {|cf|
+ # canvas
+ cvs = TkCanvas.new(cf) {|c|
+ focus
+ scrollregion '0c 0c 30c 24c'
+ width '15c'
+ height '10c'
+ relief 'sunken'
+ borderwidth 2
+
+ hs = TkScrollbar.new(cf) {|s|
+ orient 'horizontal'
+ command proc{|*args| c.xview(*args)}
+ c.xscrollcommand proc{|first,last| s.set first,last}
+ }
+
+ vs = TkScrollbar.new(cf) {|s|
+ command proc{|*args| c.yview(*args)}
+ c.yscrollcommand proc{|first,last| s.set first,last}
+ }
+
+ if $tk_version =~ /^4\.[01]/
+ hs.pack('side'=>'bottom', 'fill'=>'x')
+ vs.pack('side'=>'right', 'fill'=>'y')
+ c.pack('in'=>cf, 'expand'=>'yes', 'fill'=>'both')
+
+ else
+ c.grid('in'=>cf, 'row'=>0, 'column'=>0,
+ 'rowspan'=>1, 'columnspan'=>1, 'sticky'=>'news')
+ vs.grid('row'=>0, 'column'=>1,
+ 'rowspan'=>1, 'columnspan'=>1, 'sticky'=>'news')
+ hs.grid('row'=>1, 'column'=>0,
+ 'rowspan'=>1, 'columnspan'=>1, 'sticky'=>'news')
+ TkGrid.rowconfigure(cf, 0, 'weight'=>1, 'minsize'=>0)
+ TkGrid.columnconfigure(cf, 0, 'weight'=>1, 'minsize'=>0)
+
+ end
+
+ }
+}.pack('side'=>'top', 'fill'=>'both', 'expand'=>'yes')
+
+# Display a 3x3 rectangular grid
+TkcRectangle.new(cvs, '0c', '0c', '30c', '24c', 'width'=>2)
+TkcLine.new(cvs, '0c', '8c', '30c', '8c', 'width'=>2)
+TkcLine.new(cvs, '0c', '16c', '30c', '16c', 'width'=>2)
+TkcLine.new(cvs, '10c', '0c', '10c', '24c', 'width'=>2)
+TkcLine.new(cvs, '20c', '0c', '20c', '24c', 'width'=>2)
+
+if $tk_version =~ /^4.*/
+ font1 = '-Adobe-Helvetica-Medium-R-Normal--*-120-*-*-*-*-*-*'
+ font2 = '-Adobe-Helvetica-Bold-R-Normal--*-240-*-*-*-*-*-*'
+else
+ font1 = 'Helvetica 12'
+ font2 = 'Helvetica 24 bold'
+end
+if TkWinfo.depth($root).to_i > 1
+ blue = 'DeepSkyBlue3'
+ red = 'red'
+ bisque = 'bisque3'
+ green = 'SeaGreen3'
+else
+ blue = 'black'
+ red = 'black'
+ bisque = 'black'
+ green = 'black'
+end
+
+# tag
+$tag_item = TkcGroup.new(cvs)
+
+# Set up demos within each of the areas of the grid.
+TkcText.new(cvs, '5c', '.2c', 'text'=>'Lines', 'anchor'=>'n')
+TkcLine.new(cvs, '1c', '1c', '3c', '1c', '1c', '4c', '3c', '4c',
+ 'width'=>2, 'fill'=>blue, 'capstyle'=>'butt',
+ 'join'=>'miter', 'tags'=>$tag_item )
+TkcLine.new(cvs, '4.67c','1c','4.67c','4c', 'arrow'=>'last', 'tags'=>$tag_item)
+TkcLine.new(cvs, '6.33c','1c','6.33c','4c', 'arrow'=>'both', 'tags'=>$tag_item)
+TkcLine.new(cvs, '5c','6c','9c','6c','9c','1c','8c','1c','8c','4.8c','8.8c',
+ '4.8c','8.8c','1.2c','8.2c','1.2c','8.2c','4.6c','8.6c','4.6c',
+ '8.6c','1.4c','8.4c','1.4c','8.4c','4.4c',
+ 'width'=>3, 'fill'=>red, 'tags'=>$tag_item )
+TkcLine.new(cvs, '1c','5c','7c','5c','7c','7c','9c','7c', 'width'=>'.5c',
+ 'stipple'=>'@'+[$demo_dir,'..',
+ 'images','gray25.xbm'].join(File::Separator),
+ 'arrow'=>'both', 'arrowshape'=>'15 15 7', 'tags'=>$tag_item )
+TkcLine.new(cvs, '1c','7c','1.75c','5.8c','2.5c','7c','3.25c','5.8c','4c','7c',
+ 'width'=>'.5c', 'capstyle'=>'round', 'join'=>'round',
+ 'tags'=>$tag_item )
+
+TkcText.new(cvs, '15c', '.2c',
+ 'text'=>'Curves (smoothed lines)', 'anchor'=>'n')
+TkcLine.new(cvs, '11c','4c','11.5c','1c','13.5c','1c','14c','4c',
+ 'smooth'=>'on', 'fill'=>blue, 'tags'=>$tag_item )
+TkcLine.new(cvs, '15.5c','1c','19.5c','1.5c','15.5c','4.5c','19.5c','4c',
+ 'smooth'=>'on', 'arrow'=>'both', 'width'=>3, 'tags'=>$tag_item )
+TkcLine.new(cvs, '12c','6c','13.5c','4.5c','16.5c','7.5c','18c','6c',
+ '16.5c','4.5c','13.5c','7.5c','12c','6c',
+ 'smooth'=>'on', 'width'=>'3m', 'capstyle'=>'round',
+ 'stipple'=>'@'+[$demo_dir, '..',
+ 'images', 'gray25.xbm'].join(File::Separator),
+ 'fill'=>red, 'tags'=>$tag_item )
+
+TkcText.new(cvs, '25c', '.2c', 'text'=>'Polygons', 'anchor'=>'n')
+TkcPolygon.new(cvs, '21c','1.0c','22.5c','1.75c','24c','1.0c','23.25c','2.5c',
+ '24c','4.0c','22.5c','3.25c','21c','4.0c','21.75c','2.5c',
+ 'fill'=>'green', 'outline'=>'black', 'width'=>4,
+ 'tags'=>$tag_item )
+TkcPolygon.new(cvs, '25c','4c','25c','4c','25c','1c','26c','1c','27c','4c',
+ '28c','1c','29c','1c','29c','4c','29c','4c',
+ 'fill'=>red, 'smooth'=>'on', 'tags'=> $tag_item)
+TkcPolygon.new(cvs, '22c','4.5c','25c','4.5c','25c','6.75c','28c','6.75c',
+ '28c','5.25c','24c','5.25c','24c','6.0c','26c','6c','26c',
+ '7.5c','22c','7.5c',
+ 'stipple'=>'@' + [$demo_dir, '..',
+ 'images', 'gray25.xbm'].join(File::Separator),
+ 'outline'=>'black', 'tags'=>$tag_item )
+
+TkcText.new(cvs, '5c', '8.2c', 'text'=>'Rectangles', 'anchor'=>'n')
+TkcRectangle.new(cvs, '1c','9.5c','4c','12.5c',
+ 'outline'=>red, 'width'=>'3m', 'tags'=>$tag_item)
+TkcRectangle.new(cvs, '0.5c','13.5c','4.5c','15.5c',
+ 'fill'=>green, 'tags'=>$tag_item )
+TkcRectangle.new(cvs, '6c','10c','9c','15c', 'outline'=>'',
+ 'stipple'=>'@'+[$demo_dir,'..',
+ 'images','gray25.xbm'].join(File::Separator),
+ 'fill'=>blue, 'tags'=>$tag_item )
+
+TkcText.new(cvs, '15c', '8.2c', 'text'=>'Ovals', 'anchor'=>'n')
+TkcOval.new(cvs, '11c','9.5c','14c','12.5c',
+ 'outline'=>red, 'width'=>'3m', 'tags'=>$tag_item)
+TkcOval.new(cvs, '10.5c','13.5c','14.5c','15.5c',
+ 'fill'=>green, 'tags'=>$tag_item )
+TkcOval.new(cvs, '16c','10c','19c','15c', 'outline'=>'',
+ 'stipple'=>'@'+[$demo_dir,'..',
+ 'images','gray25.xbm'].join(File::Separator),
+ 'fill'=>blue, 'tags'=>$tag_item )
+
+TkcText.new(cvs, '25c', '8.2c', 'text'=>'Text', 'anchor'=>'n')
+TkcRectangle.new(cvs, '22.4c','8.9c','22.6c','9.1c')
+TkcText.new(cvs, '22.5c', '9c', 'anchor'=>'n', 'font'=>font1, 'width'=>'4c',
+ 'text'=>'A short string of text, word-wrapped, justified left, and anchored north (at the top). The rectangles show the anchor points for each piece of text.', 'tags'=>$tag_item )
+TkcRectangle.new(cvs, '25.4c','10.9c','25.6c','11.1c')
+TkcText.new(cvs, '25.5c', '11c', 'anchor'=>'w', 'font'=>font1, 'fill'=>blue,
+ 'text'=>"Several lines,\n each centered\nindividually,\nand all anchored\nat the left edge.", 'justify'=>'center', 'tags'=>$tag_item )
+TkcRectangle.new(cvs, '24.9c','13.9c','25.1c','14.1c')
+if $tk_version =~ /^4\.[01]/
+ TkcText.new(cvs, '25c', '14c', 'anchor'=>'c', 'font'=>font2, 'fill'=>red,
+ 'stipple'=>'@' + [$demo_dir, '..',
+ 'images', 'grey.5'].join(File::Separator),
+ 'text'=>'Stippled characters', 'tags'=>$tag_item )
+else
+ TkcText.new(cvs, '25c', '14c', 'anchor'=>'c', 'font'=>font2, 'fill'=>red,
+ 'stipple'=>'gray50', 'text'=>'Stippled characters',
+ 'tags'=>$tag_item )
+end
+
+TkcText.new(cvs, '5c', '16.2c', 'text'=>'Arcs', 'anchor'=>'n')
+TkcArc.new(cvs, '0.5c','17c','7c','20c', 'fill'=>green, 'outline'=>'black',
+ 'start'=>45, 'extent'=>270, 'style'=>'pieslice', 'tags'=>$tag_item)
+#TkcArc.new(cvs, '6.5c','17c','9.5c','20c', 'width'=>'4m', 'style'=>'arc',
+# 'outline'=>blue, 'start'=>135, 'extent'=>270,
+# 'outlinestipple'=>'@' + ['images', 'grey.25'].join(File::Separator),
+# 'tags'=>$tag_item)
+TkcArc.new(cvs, '6.5c','17c','9.5c','20c', 'width'=>'4m', 'style'=>'arc',
+ 'outline'=>blue, 'start'=>135, 'extent'=>270,
+ 'outlinestipple'=>'@'+[$demo_dir, '..',
+ 'images','gray25.xbm'].join(File::Separator),
+ 'tags'=>$tag_item)
+TkcArc.new(cvs, '0.5c','20c','9.5c','24c', 'width'=>'4m', 'style'=>'pieslice',
+ 'fill'=>'', 'outline'=>red, 'start'=>225, 'extent'=>90,
+ 'tags'=>$tag_item)
+TkcArc.new(cvs, '5.5c','20.5c','9.5c','23.5c', 'width'=>'4m', 'style'=>'chord',
+ 'fill'=>blue, 'outline'=>'', 'start'=>45, 'extent'=>270,
+ 'tags'=>$tag_item)
+
+TkcText.new(cvs, '15c', '16.2c', 'text'=>'Bitmaps', 'anchor'=>'n')
+#TkcBitmap.new(cvs, '13c','20c',
+# 'bitmap'=>'@' + ['images', 'face'].join(File::Separator),
+# 'tags'=>$tag_item)
+TkcBitmap.new(cvs, '13c','20c',
+ 'bitmap'=>'@' + [$demo_dir, '..',
+ 'images', 'face.xbm'].join(File::Separator),
+ 'tags'=>$tag_item)
+#TkcBitmap.new(cvs, '17c','18.5c',
+# 'bitmap'=>'@' + ['images', 'noletters'].join(File::Separator),
+# 'tags'=>$tag_item)
+TkcBitmap.new(cvs, '17c','18.5c',
+ 'bitmap'=>'@' + [$demo_dir, '..',
+ 'images', 'noletter.xbm'].join(File::Separator),
+ 'tags'=>$tag_item)
+#TkcBitmap.new(cvs, '17c','21.5c',
+# 'bitmap'=>'@' + ['images', 'letters'].join(File::Separator),
+# 'tags'=>$tag_item)
+#
+TkcBitmap.new(cvs, '17c','21.5c') {
+ bitmap '@' + [$demo_dir, '..', 'images', 'letters.xbm'].join(File::Separator)
+ tags $tag_item
+}
+#TkcBitmap.new(cvs, '17c','21.5c') {
+# bitmap '@' + ['images', 'letters'].join(File::Separator)
+# tags $tag_item
+#}
+
+TkcText.new(cvs, '25c', '16.2c', 'text'=>'Windows', 'anchor'=>'n')
+TkButton.new(cvs) {|b|
+ text 'Press Me'
+ command proc{butPress cvs, red}
+ TkcWindow.new(cvs, '21c','18c',
+ 'window'=>b, 'anchor'=>'nw', 'tags'=>$tag_item)
+}
+TkEntry.new(cvs, 'width'=>20, 'relief'=>'sunken') {|e|
+ insert 'end', 'Edit this text'
+ TkcWindow.new(cvs, '21c','21c',
+ 'window'=>e, 'anchor'=>'nw', 'tags'=>$tag_item)
+}
+TkScale.new(cvs, 'from'=>0, 'to'=>100, 'length'=>'6c', 'sliderlength'=>'.4c',
+ 'width'=>'.5c', 'tickinterval'=>0 ) {|scl|
+ TkcWindow.new(cvs, '28.5c','17.5c',
+ 'window'=>scl, 'anchor'=>'n', 'tags'=>$tag_item)
+}
+TkcText.new(cvs, '21c', '17.9c', 'text'=>'Button:', 'anchor'=>'sw')
+TkcText.new(cvs, '21c', '20.9c', 'text'=>'Entry:', 'anchor'=>'sw')
+TkcText.new(cvs, '28.5c', '17.4c', 'text'=>'Scale:', 'anchor'=>'s')
+
+# Set up event bindings for canvas:
+cvs.itembind($tag_item, 'Any-Enter', proc{itemEnter cvs})
+cvs.itembind($tag_item, 'Any-Leave', proc{itemLeave cvs})
+cvs.bind('2', proc{|x,y| cvs.scan_mark x,y}, '%x %y')
+cvs.bind('B2-Motion', proc{|x,y| cvs.scan_dragto x,y}, '%x %y')
+cvs.bind('3', proc{|x,y| itemMark cvs,x,y}, '%x %y')
+cvs.bind('B3-Motion', proc{|x,y| itemStroke cvs,x,y}, '%x %y')
+cvs.bind('Control-f', proc{itemsUnderArea cvs})
+cvs.bind('1', proc{|x,y| itemStartDrag cvs,x,y}, '%x %y')
+cvs.bind('B1-Motion', proc{|x,y| itemDrag cvs,x,y}, '%x %y')
+# Utility methods for highlighting the item under the pointer
+
+$restoreCmd = nil
+def itemEnter (c)
+ if TkWinfo.depth(c).to_i == 1
+ $restoreCmd = nil
+ return
+ end
+ type = c.itemtype('current')
+ if type == TkcWindow
+ $restoreCmd = nil
+ return
+ end
+ if type == TkcBitmap
+ bg = (c.itemconfiginfo('current', 'background'))[4]
+ $restoreCmd = proc{c.itemconfigure 'current', 'background', bg}
+ c.itemconfigure 'current', 'background', 'SteelBlue2'
+ return
+ end
+ fill = (c.itemconfiginfo('current', 'fill'))[4]
+ if (type == TkcRectangle || type == TkcOval || type == TkcArc) && fill == []
+ outline = (c.itemconfiginfo('current', 'outline'))[4]
+ $restoreCmd = proc{c.itemconfigure 'current', 'outline', outline}
+ c.itemconfigure 'current', 'outline', 'SteelBlue2'
+ else
+ $restoreCmd = proc{c.itemconfigure 'current', 'fill', fill}
+ c.itemconfigure 'current', 'fill', 'SteelBlue2'
+ end
+end
+
+def itemLeave(c)
+ $restoreCmd.call if $restoreCmd
+end
+
+# Utility methods for stroking out a rectangle and printing what's
+# underneath the rectangle's area.
+
+def itemMark(c,x,y)
+ $areaX1 = c.canvasx(x)
+ $areaY1 = c.canvasy(y)
+ c.delete 'area'
+end
+
+def itemStroke(c,x,y)
+ x = c.canvasx(x)
+ y = c.canvasy(y)
+ if $areaX1 != x && $areaY1 != y
+ c.delete 'area'
+ c.addtag_withtag 'area', TkcRectangle.new(c, $areaX1, $areaY1, x, y,
+ '-outline', 'black')
+ $areaX2 = x
+ $areaY2 = y
+ end
+end
+
+def itemsUnderArea(c)
+ area = c.find_withtag('area')
+ items = []
+ c.find_enclosed($areaX1,$areaY1,$areaX2,$areaY2).each{|i|
+ items.push(i) if i.gettags.include?($tag_item)
+ }
+ print "Items enclosed by area: #{items.inspect}\n"; STDOUT.flush
+ items.clear
+ c.find_overlapping($areaX1,$areaY1,$areaX2,$areaY2).each{|i|
+ items.push(i) if i.gettags.include?($tag_item)
+ }
+ print "Items overlapping area: #{items.inspect}\n"; STDOUT.flush
+end
+
+$areaX1 = 0
+$areaY1 = 0
+$areaX2 = 0
+$areaY2 = 0
+
+# Utility methods to support dragging of items.
+
+def itemStartDrag(c,x,y)
+ $lastX = c.canvasx(x)
+ $lastY = c.canvasy(y)
+end
+
+def itemDrag(c,x,y)
+ x = c.canvasx(x)
+ y = c.canvasy(y)
+ c.move 'current', x - $lastX, y - $lastY
+ $lastX = x
+ $lastY = y
+end
+
+# Method that's invoked when the button embedded in the canvas
+# is invoked.
+
+def butPress(w,color)
+ i = TkcText.new(w, '25c', '18.1c',
+ 'text'=>'Ouch!!', 'fill'=>color, 'anchor'=>'n')
+ Tk.after(500, proc{w.delete i})
+end
diff --git a/jni/ruby/ext/tk/sample/demos-en/ixset b/jni/ruby/ext/tk/sample/demos-en/ixset
new file mode 100644
index 0000000..40a77f4
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/demos-en/ixset
@@ -0,0 +1,333 @@
+#!/usr/bin/env ruby
+
+# ixset --
+# A nice interface to "xset" to change X server settings
+#
+
+require 'tk'
+
+class Xsettings
+ #
+ # Button actions
+ #
+ def quit
+ @root.destroy
+ end
+
+ def ok
+ writesettings
+ quit
+ end
+
+ def cancel
+ readsettings
+ dispsettings
+ end
+
+ # apply is just "writesettings"
+
+
+ #
+ # Read current settings
+ #
+ def readsettings
+ xfd = open("|xset q", 'r')
+ xfd.readlines.each{|line|
+ fields = line.chomp.strip.split(/\s+/)
+ case fields[0]
+ when "auto"
+ if fields[1] == 'repeat:'
+ @kbdrep = fields[2]
+ @w_kbdrep.set(@kbdrep)
+ @kbdcli = fields[6]
+ end
+
+ when "bell"
+ @bellvol = fields[2]
+ @bellpit = fields[5]
+ @belldur = fields[8]
+
+ when "acceleration:"
+ @mouseacc = fields[1]
+ @mousethr = fields[3]
+
+ when "prefer"
+ if fields[2] == 'yes'
+ @screenbla = 'blank'
+ else
+ @screenbla = 'noblank'
+ end
+ @w_screenbla.set(@screenbla)
+
+ when "timeout:"
+ @screentim = fields[1]
+ @screencyc = fields[3]
+
+ end
+ }
+
+ xfd.close
+ end
+
+ #
+ # Write settings into the X server
+ #
+ def writesettings
+ @bellvol = @w_bellvol.get
+ @bellpit = @w_bellpit.get
+ @belldur = @w_belldur.get
+
+ @kbdrep = @w_kbdrep.get
+ if @kbdrep == 'on'
+ @kbdcli = @w_kbdcli.get
+ else
+ @kbdcli = 'off'
+ end
+
+ @mouseacc = @w_mouseacc.get
+ @mousethr = @w_mousethr.get
+
+ @screentim = @w_screentim.get
+ @screencyc = @w_screencyc.get
+ @screenbla = @w_screenbla.get
+
+ system("xset \
+ b #{@bellvol} #{@bellpit} #{@belldur} \
+ c #{@kbdcli} \
+ r #{@kbdrep} \
+ m #{@mouseacc} #{@mousethr} \
+ s #{@screentim} #{@screencyc} \
+ s #{@screenbla}")
+ end
+
+ #
+ # Sends all settings to the window
+ #
+ def dispsettings
+ @w_bellvol.set(@bellvol)
+ @w_bellpit.set(@bellpit)
+ @w_belldur.set(@belldur)
+
+ @w_kbdonoff.set(@w_kbdrep.get)
+ @w_kbdcli.set(@kbdcli)
+
+ @w_mouseacc.set(@mouseacc)
+ @w_mousethr.set(@mousethr)
+
+ @w_screenblank.set(@w_screenbla.get)
+ @w_screenpat.set(@w_screenbla.get)
+
+ @w_screentim.set(@screentim)
+ @w_screencyc.set(@screencyc)
+ end
+
+ #
+ # Create all windows, and pack them
+ #
+ class LabelEntry
+ def initialize(parent, text, length)
+ @frame = TkFrame.new(parent)
+ TkLabel.new(@frame, 'text'=>text).pack('side'=>'left','expand'=>'y')
+ @entry = TkEntry.new(@frame, 'width'=>length, 'relief'=>'sunken') {
+ pack('side'=>'left','expand'=>'y')
+ }
+ end
+ def pack(keys)
+ @frame.pack(keys)
+ end
+ def get
+ @entry.value
+ end
+ def set(value)
+ @entry.delete(0,'end')
+ @entry.insert(0, value)
+ end
+ end
+
+ def createwindows
+ win = self
+
+ #
+ # Buttons
+ #
+ buttons = TkFrame.new(@root) {|f|
+ [ TkButton.new(f, 'command'=>proc{win.ok}, 'text'=>'Ok'),
+ TkButton.new(f, 'command'=>proc{win.writesettings}, 'text'=>'Apply'),
+ TkButton.new(f, 'command'=>proc{win.cancel}, 'text'=>'Cancel'),
+ TkButton.new(f, 'command'=>proc{win.quit}, 'text'=>'Quit') ].each{|b|
+ b.pack('side'=>'left', 'expand'=>'yes', 'pady'=>5)
+ }
+ }
+
+ #
+ # Bell settings
+ #
+ bell = TkFrame.new(@root, 'relief'=>'raised', 'borderwidth'=>2)
+ l = TkLabel.new(bell, 'text'=>'Bell Settings')
+ @w_bellvol = TkScale.new(bell, 'from'=>0, 'to'=>100, 'length'=>200,
+ 'tickinterval'=>20, 'orient'=>'horizontal',
+ 'label'=>"Volume (%)")
+
+ f = TkFrame.new(bell)
+ @w_bellpit = LabelEntry.new(f, "Pitch (Hz)", 6)
+ @w_bellpit.pack('side'=>'left', 'padx'=>5)
+ @w_belldur = LabelEntry.new(f, "Duration (ms)", 6)
+ @w_belldur.pack('side'=>'right', 'padx'=>5)
+
+ l.pack('side'=>'top', 'expand'=>'yes')
+ @w_bellvol.pack('side'=>'top', 'expand'=>'yes')
+ f.pack('side'=>'top', 'expand'=>'yes')
+
+ #
+ # Keyboard settings
+ #
+ kbdonoff = nil
+ kbdcli = nil
+ kbd = TkFrame.new(@root, 'relief'=>'raised', 'borderwidth'=>2)
+ l = TkLabel.new(kbd, 'text'=>'Keyboard Repeat Settings')
+ f = TkFrame.new(kbd)
+ @w_kbdonoff = TkCheckButton.new(f, 'text'=>'On', 'relief'=>'flat',
+ 'onvalue'=>'on', 'offvalue'=>'off',
+ 'variable'=>@w_kbdrep ) {
+ def self.set(value)
+ if value == 'on'
+ self.select
+ else
+ self.deselect
+ end
+ end
+ pack('side'=>'left', 'expand'=>'yes', 'fill'=>'both')
+ }
+ @w_kbdcli = TkScale.new(f, 'from'=>0, 'to'=>100, 'length'=>200,
+ 'tickinterval'=>20, 'orient'=>'horizontal',
+ 'label'=>'Click Volume (%)')
+ @w_kbdcli.pack('side'=>'left', 'expand'=>'yes')
+ l.pack('side'=>'top', 'expand'=>'yes')
+ f.pack('side'=>'top', 'expand'=>'yes', 'pady'=>2, 'fill'=>'x')
+
+ #
+ # Mouse settings
+ #
+ mouse = TkFrame.new(@root, 'relief'=>'raised', 'borderwidth'=>2)
+ l = TkLabel.new(mouse, 'text'=>'Mouse Settings')
+ f = TkFrame.new(mouse)
+ @w_mouseacc = LabelEntry.new(f, 'Acceleration', 3)
+ @w_mouseacc.pack('side'=>'left')
+ @w_mousethr = LabelEntry.new(f, 'Threshold (pixels)', 3)
+ @w_mousethr.pack('side'=>'right')
+ l.pack('side'=>'top')
+ f.pack('side'=>'top', 'expand'=>'yes')
+
+ #
+ # Screen Saver settings
+ #
+ screen = TkFrame.new(@root, 'relief'=>'raised', 'borderwidth'=>2)
+ l = TkLabel.new(screen, 'text'=>'Screen-saver Settings')
+ f = TkFrame.new(screen)
+ ff1 = TkFrame.new(f)
+ [ @w_screenblank = TkRadioButton.new(ff1, 'text'=>'Blank',
+ 'relief'=>'flat',
+ 'variable'=>@w_screenbla,
+ 'value'=>'blank') {
+ def self.set(value)
+ if value == 'blank'
+ self.select
+ else
+ self.deselect
+ end
+ end
+ },
+ @w_screenpat = TkRadioButton.new(ff1, 'text'=>'Pattern',
+ 'relief'=>'flat',
+ 'variable'=>@w_screenbla,
+ 'value'=>'noblank') {
+ def self.set(value)
+ if value != 'blank'
+ self.select
+ else
+ self.deselect
+ end
+ end
+ }
+ ].each {|w| w.pack('side'=>'top', 'pady'=>2, 'anchor'=>'w') }
+
+ ff2 = TkFrame.new(f)
+ [ @w_screentim = LabelEntry.new(ff2, 'Timeout (s)', 5),
+ @w_screencyc = LabelEntry.new(ff2, 'Cycle (s)', 5) ].each{|w|
+ w.pack('side'=>'top', 'pady'=>2, 'anchor'=>'e')
+ }
+
+ ff1.pack('side'=>'left')
+ ff2.pack('side'=>'left')
+
+ l.pack('side'=>'top')
+ f.pack('side'=>'top', 'expand'=>'yes')
+
+ #
+ # Main window
+ #
+ buttons.pack('side'=>'top', 'fill'=>'both')
+ bell.pack('side'=>'top', 'fill'=>'both', 'ipady'=>5, 'expand'=>'yes')
+ kbd.pack('side'=>'top', 'fill'=>'both', 'ipady'=>5, 'expand'=>'yes')
+ mouse.pack('side'=>'top', 'fill'=>'both', 'ipady'=>5, 'expand'=>'yes')
+ screen.pack('side'=>'top', 'fill'=>'both', 'ipady'=>5, 'expand'=>'yes')
+
+ #
+ # Let the user resize our window
+ #
+ @root.minsize(10,10)
+ end
+
+ def initialize
+ @root = TkRoot.new
+
+ @kbdrep = 'on'
+ @w_kbdrep = TkVariable.new(@kbdrep)
+ def @w_kbdrep.get
+ self.value
+ end
+ def @w_kbdrep.set(val)
+ self.value=val
+ end
+
+ @kbdcli = 0
+
+ @bellvol = 100
+ @bellpit = 440
+ @belldur = 100
+
+ @mouseacc = "3/1"
+ @mousethr = 4
+
+ @screenbla = "blank"
+ @w_screenbla = TkVariable.new(@screenbla)
+ def @w_screenbla.get
+ self.value
+ end
+ def @w_screenbla.set(val)
+ self.value=val
+ end
+
+ @screentim = 600
+ @screencyc = 600
+
+ #
+ # Listen what "xset" tells us...
+ #
+ readsettings
+
+ #
+ # Create all windows
+ #
+ createwindows
+
+ #
+ # Write xset parameters
+ #
+ dispsettings
+ end
+end
+
+Xsettings.new
+
+Tk.mainloop
diff --git a/jni/ruby/ext/tk/sample/demos-en/ixset2 b/jni/ruby/ext/tk/sample/demos-en/ixset2
new file mode 100644
index 0000000..cb99c60
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/demos-en/ixset2
@@ -0,0 +1,367 @@
+#!/usr/bin/env ruby
+#
+# ixset --
+# A nice interface to "xset" to change X server settings
+#
+
+require 'tk'
+
+class Xsettings
+ #
+ # Button actions
+ #
+ def quit
+ @root.destroy
+ end
+
+ def ok
+ writesettings
+ quit
+ end
+
+ def cancel
+ readsettings
+ dispsettings
+ @btn_APPLY.state(:disabled)
+ @btn_CANCEL.state(:disabled)
+ end
+
+ # apply is just "writesettings"
+ def apply
+ writesettings
+ @btn_APPLY.state(:disabled)
+ @btn_CANCEL.state(:disabled)
+ end
+
+ #
+ # Read current settings
+ #
+ def readsettings
+ xfd = open("|xset q", 'r')
+ xfd.readlines.each{|line|
+ fields = line.chomp.strip.split(/\s+/)
+ case fields[0]
+ when "auto"
+ if fields[1] == 'repeat:'
+ @kbdrep = fields[2]
+ @w_kbdrep.set(@kbdrep)
+ @kbdcli = fields[6]
+ end
+
+ when "bell"
+ @bellvol = fields[2]
+ @bellpit = fields[5]
+ @belldur = fields[8]
+
+ when "acceleration:"
+ @mouseacc = fields[1]
+ @mousethr = fields[3]
+
+ when "prefer"
+ if fields[2] == 'yes'
+ @screenbla = 'blank'
+ else
+ @screenbla = 'noblank'
+ end
+ @w_screenbla.set(@screenbla)
+
+ when "timeout:"
+ @screentim = fields[1]
+ @screencyc = fields[3]
+
+ end
+ }
+
+ xfd.close
+ end
+
+ #
+ # Write settings into the X server
+ #
+ def writesettings
+ @bellvol = @w_bellvol.get
+ @bellpit = @w_bellpit.get
+ @belldur = @w_belldur.get
+
+ @kbdrep = @w_kbdrep.get
+ if @kbdrep == 'on'
+ @kbdcli = @w_kbdcli.get
+ else
+ @kbdcli = 'off'
+ end
+
+ @mouseacc = @w_mouseacc.get
+ @mousethr = @w_mousethr.get
+
+ @screentim = @w_screentim.get
+ @screencyc = @w_screencyc.get
+ @screenbla = @w_screenbla.get
+
+ system("xset \
+ b #{@bellvol} #{@bellpit} #{@belldur} \
+ c #{@kbdcli} \
+ r #{@kbdrep} \
+ m #{@mouseacc} #{@mousethr} \
+ s #{@screentim} #{@screencyc} \
+ s #{@screenbla}")
+ end
+
+ #
+ # Sends all settings to the window
+ #
+ def dispsettings
+ @w_bellvol.set(@bellvol)
+ @w_bellpit.set(@bellpit)
+ @w_belldur.set(@belldur)
+
+ @w_kbdonoff.set(@w_kbdrep.get)
+ @w_kbdcli.set(@kbdcli)
+
+ @w_mouseacc.set(@mouseacc)
+ @w_mousethr.set(@mousethr)
+
+ @w_screenblank.set(@w_screenbla.get)
+ @w_screenpat.set(@w_screenbla.get)
+
+ @w_screentim.set(@screentim)
+ @w_screencyc.set(@screencyc)
+ end
+
+ #
+ # Create all windows, and pack them
+ #
+ class LabelEntry
+ def initialize(parent, text, length, range=[])
+ @frame = TkFrame.new(parent)
+ TkLabel.new(@frame, 'text'=>text).pack('side'=>'left')
+ if range.size > 0
+ @entry = TkSpinbox.new(@frame, 'width'=>length, 'relief'=>'sunken',
+ 'from'=>range[0], 'to'=>range[1])
+ else
+ @entry = TkEntry.new(@frame, 'width'=>length, 'relief'=>'sunken')
+ end
+ @entry.pack('side'=>'right','expand'=>'y', 'fill'=>'x')
+ end
+ def epath
+ @frame
+ end
+ def pack(keys)
+ @frame.pack(keys)
+ end
+ def get
+ @entry.value
+ end
+ def set(value)
+ @entry.delete(0,'end')
+ @entry.insert(0, value)
+ end
+ end
+
+ def createwindows
+ win = self
+
+ #
+ # Buttons
+ #
+ btn_frame = TkFrame.new(@root)
+ buttons = [
+ @btn_OK = TkButton.new(btn_frame, 'command'=>proc{win.ok},
+ 'default'=>'active', 'text'=>'Ok'),
+ @btn_APPLY = TkButton.new(btn_frame, 'command'=>proc{win.writesettings},
+ 'default'=>'normal', 'text'=>'Apply',
+ 'state'=>'disabled'),
+ @btn_CANCEL = TkButton.new(btn_frame, 'command'=>proc{win.cancel},
+ 'default'=>'normal', 'text'=>'Cancel',
+ 'state'=>'disabled'),
+ @btn_QUIT = TkButton.new(btn_frame, 'command'=>proc{win.quit},
+ 'default'=>'normal', 'text'=>'Quit')
+ ]
+ buttons.each{|b| b.pack('side'=>'left', 'expand'=>'yes', 'pady'=>5) }
+
+ @root.bind('Return', proc{@btn_OK.flash; @btn_OK.invoke})
+ @root.bind('Escape', proc{@btn_QUIT.flash; @btn_QUIT.invoke})
+ @root.bind('1', proc{|w|
+ unless buttons.index(w)
+ @btn_APPLY.state(:normal)
+ @btn_CANCEL.state(:normal)
+ end
+ }, '%W')
+ @root.bind('Key', proc{|w, k|
+ unless buttons.index(w)
+ case k
+ when 'Return', 'Escape', 'Tab', /.*Shift.*/
+ # do nothing
+ else
+ @btn_APPLY.state(:normal)
+ @btn_CANCEL.state(:normal)
+ end
+ end
+ }, '%W %K')
+
+ #
+ # Bell settings
+ #
+ bell = TkLabelframe.new(@root, 'text'=>'Bell Settings',
+ 'padx'=>'1.5m', 'pady'=>'1.5m')
+ @w_bellvol = TkScale.new(bell, 'from'=>0, 'to'=>100, 'length'=>200,
+ 'tickinterval'=>20, 'orient'=>'horizontal',
+ 'label'=>"Volume (%)")
+
+ f = TkFrame.new(bell)
+ @w_bellpit = LabelEntry.new(f, "Pitch (Hz)", 6, [25, 20000])
+ @w_bellpit.pack('side'=>'left', 'padx'=>5)
+ @w_belldur = LabelEntry.new(f, "Duration (ms)", 6, [1, 10000])
+ @w_belldur.pack('side'=>'right', 'padx'=>5)
+
+ @w_bellvol.pack('side'=>'top', 'expand'=>'yes')
+ f.pack('side'=>'top', 'expand'=>'yes')
+
+ #
+ # Keyboard settings
+ #
+ kbdonoff = nil
+ kbdcli = nil
+ kbd = TkLabelframe.new(@root, 'text'=>'Keyboard Repeat Settings',
+ 'padx'=>'1.5m', 'pady'=>'1.5m')
+ f = TkFrame.new(kbd)
+ @w_kbdonoff = TkCheckButton.new(f, 'text'=>'On', 'relief'=>'flat',
+ 'onvalue'=>'on', 'offvalue'=>'off',
+ 'variable'=>@w_kbdrep ) {
+ def self.set(value)
+ if value == 'on'
+ self.select
+ else
+ self.deselect
+ end
+ end
+ pack('side'=>'left', 'expand'=>'yes', 'fill'=>'x', 'padx'=>[0, '1m'])
+ }
+ @w_kbdcli = TkScale.new(f, 'from'=>0, 'to'=>100, 'length'=>200,
+ 'tickinterval'=>20, 'orient'=>'horizontal',
+ 'label'=>'Click Volume (%)')
+ @w_kbdcli.pack('side'=>'left', 'expand'=>'yes',
+ 'fill'=>'x', 'padx'=>['1m', 0])
+ f.pack('side'=>'top', 'expand'=>'yes', 'pady'=>2, 'fill'=>'x')
+
+ #
+ # Mouse settings
+ #
+ mouse = TkLabelframe.new(@root, 'text'=>'Mouse Settings',
+ 'padx'=>'1.5m', 'pady'=>'1.5m')
+ f = TkFrame.new(mouse)
+ @w_mouseacc = LabelEntry.new(f, 'Acceleration', 5)
+ @w_mouseacc.pack('side'=>'left', 'padx'=>[0, '1m'])
+ @w_mousethr = LabelEntry.new(f, 'Threshold (pixels)', 3, [1, 2000])
+ @w_mousethr.pack('side'=>'right', 'padx'=>['1m', 0])
+ f.pack('side'=>'top', 'expand'=>'yes')
+
+ #
+ # Screen Saver settings
+ #
+ screen = TkLabelframe.new(@root, 'text'=>'Screen-saver Settings',
+ 'padx'=>'1.5m', 'pady'=>'1.5m')
+ @w_screenblank = TkRadioButton.new(screen, 'text'=>'Blank',
+ 'relief'=>'flat', 'anchor'=>'w',
+ 'variable'=>@w_screenbla,
+ 'value'=>'blank') {
+ def self.set(value)
+ if value == 'blank'
+ self.select
+ else
+ self.deselect
+ end
+ end
+ }
+
+ @w_screenpat = TkRadioButton.new(screen, 'text'=>'Pattern',
+ 'relief'=>'flat', 'anchor'=>'w',
+ 'variable'=>@w_screenbla,
+ 'value'=>'noblank') {
+ def self.set(value)
+ if value != 'blank'
+ self.select
+ else
+ self.deselect
+ end
+ end
+ }
+
+ @w_screentim = LabelEntry.new(screen, 'Timeout (s)', 5, [1, 100000])
+ @w_screencyc = LabelEntry.new(screen, 'Cycle (s)', 5, [1, 100000])
+
+ Tk.grid(@w_screenblank, @w_screentim, 'sticky'=>'e')
+ Tk.grid(@w_screenpat, @w_screencyc, 'sticky'=>'e')
+ TkGrid.configure(@w_screenblank, @w_screenpat, 'sticky'=>'ew')
+
+ #
+ # Main window
+ #
+ param = {
+ 'side'=>'top', 'fill'=>'both', 'expand'=>'yes',
+ 'padx'=>'1m', 'pady'=>'1m'
+ }
+ btn_frame.pack('side'=>'top', 'fill'=>'both')
+ bell.pack(param)
+ kbd.pack(param)
+ mouse.pack(param)
+ screen.pack(param)
+
+ #
+ # Let the user resize our window
+ #
+ @root.minsize(10,10)
+ end
+
+ def initialize(title)
+ @root = TkRoot.new('title'=>title)
+
+ @kbdrep = 'on'
+ @w_kbdrep = TkVariable.new(@kbdrep)
+ def @w_kbdrep.get
+ self.value
+ end
+ def @w_kbdrep.set(val)
+ self.value=val
+ end
+
+ @kbdcli = 0
+
+ @bellvol = 100
+ @bellpit = 440
+ @belldur = 100
+
+ @mouseacc = "3/1"
+ @mousethr = 4
+
+ @screenbla = "blank"
+ @w_screenbla = TkVariable.new(@screenbla)
+ def @w_screenbla.get
+ self.value
+ end
+ def @w_screenbla.set(val)
+ self.value=val
+ end
+
+ @screentim = 600
+ @screencyc = 600
+
+ #
+ # Listen what "xset" tells us...
+ #
+ readsettings
+
+ #
+ # Create all windows
+ #
+ createwindows
+
+ #
+ # Write xset parameters
+ #
+ dispsettings
+ end
+end
+
+Xsettings.new(File.basename($0,'.rb'))
+
+Tk.mainloop
diff --git a/jni/ruby/ext/tk/sample/demos-en/knightstour.rb b/jni/ruby/ext/tk/sample/demos-en/knightstour.rb
new file mode 100644
index 0000000..6f96a5b
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/demos-en/knightstour.rb
@@ -0,0 +1,271 @@
+# Based on the widget demo of Tcl/Tk8.5.2
+# The following is the original copyright text.
+#----------------------------------------------------------------------------
+# Copyright (C) 2008 Pat Thoyts <patthoyts@users.sourceforge.net>
+#
+# Calculate a Knight's tour of a chessboard.
+#
+# This uses Warnsdorff's rule to calculate the next square each
+# time. This specifies that the next square should be the one that
+# has the least number of available moves.
+#
+# Using this rule it is possible to get to a position where
+# there are no squares available to move into. In this implementation
+# this occurs when the starting square is d6.
+#
+# To solve this fault an enhancement to the rule is that if we
+# have a choice of squares with an equal score, we should choose
+# the one nearest the edge of the board.
+#
+# If the call to the Edgemost function is commented out you can see
+# this occur.
+#
+# You can drag the knight to a specific square to start if you wish.
+# If you let it repeat then it will choose random start positions
+# for each new tour.
+#----------------------------------------------------------------------------
+require 'tk'
+
+class Knights_Tour
+ # Return a list of accessible squares from a given square
+ def valid_moves(square)
+ moves = []
+ [
+ [-1,-2], [-2,-1], [-2,1], [-1,2], [1,2], [2,1], [2,-1], [1,-2]
+ ].each{|col_delta, row_delta|
+ col = (square % 8) + col_delta
+ row = (square.div(8)) + row_delta
+ moves << (row * 8 + col) if row > -1 && row < 8 && col > -1 && col < 8
+ }
+ moves
+ end
+
+ # Return the number of available moves for this square
+ def check_square(square)
+ valid_moves(square).find_all{|pos| ! @visited.include?(pos)}.length
+ end
+
+ # Select the next square to move to. Returns -1 if there are no available
+ # squares remaining that we can move to.
+ def next_square(square)
+ minimum = 9
+ nxt = -1
+ valid_moves(square).each{|pos|
+ unless @visited.include?(pos)
+ cnt = check_square(pos)
+ if cnt < minimum
+ minimum = cnt
+ nxt = pos
+ elsif cnt == minimum
+ nxt = edgemost(nxt, pos)
+ end
+ end
+ }
+ nxt
+ end
+
+ # Select the square nearest the edge of the board
+ def edgemost(nxt, pos)
+ col_A = 3 - ((3.5 - nxt % 8).abs.to_i)
+ col_B = 3 - ((3.5 - pos % 8).abs.to_i)
+ row_A = 3 - ((3.5 - nxt.div(8)).abs.to_i)
+ row_B = 3 - ((3.5 - pos.div(8)).abs.to_i)
+ (col_A * row_A < col_B * row_B)? nxt : pos
+ end
+
+ # Display a square number as a standard chess square notation.
+ def _N(square)
+ '%c%d' % [(97 + square % 8), (square.div(8) + 1)]
+ end
+
+ # Perform a Knight's move and schedule the next move.
+ def move_piece(last, square)
+ @log.insert(:end, "#{@visited.length}. #{_N last} -> #{_N square}\n", '')
+ @log.see(:end)
+ @board.itemconfigure(1+last, :state=>:normal, :outline=>'black')
+ @board.itemconfigure(1+square, :state=>:normal, :outline=>'red')
+ @knight.coords(@board.coords(1+square)[0..1])
+ @visited << square
+ if (nxt = next_square(square)) != -1
+ @after_id = Tk.after(@delay.numeric){move_piece(square, nxt) rescue nil}
+ else
+ @start_btn.state :normal
+ if @visited.length == 64
+ if @initial == square
+ @log.insert :end, 'Closed tour!'
+ else
+ @log.insert :end, "Success\n", {}
+ Tk.after(@delay.numeric * 2){tour(rand(64))} if @continuous.bool
+ end
+ else
+ @log.insert :end, "FAILED!\n", {}
+ end
+ end
+ end
+
+ # Begin a new tour of the board given a random start position
+ def tour(square = nil)
+ @visited.clear
+ @log.clear
+ @start_btn.state :disabled
+ 1.upto(64){|n|
+ @board.itemconfigure(n, :state=>:disabled, :outline=>'black')
+ }
+ unless square
+ square = @board.find_closest(*(@knight.coords << 0 << 65))[0].to_i - 1
+ end
+ @initial = square
+ Tk.after_idle{ move_piece(@initial, @initial) rescue nil }
+ end
+
+ def _stop
+ Tk.after_cancel(@after_id) rescue nil
+ end
+
+ def _exit
+ _stop
+ $knightstour.destroy
+ end
+
+ def set_delay(new)
+ @delay.numeric = new.to_i
+ end
+
+ def drag_start(w, x, y)
+ w.dtag('selected')
+ w.addtag('selected', :withtag, 'current')
+ @dragging = [x, y]
+ end
+
+ def drag_motion(w, x, y)
+ return unless @dragging
+ w.move('selected', x - @dragging[0], y - @dragging[1])
+ @dragging = [x, y]
+ end
+
+ def drag_end(w, x, y)
+ square = w.find_closest(x, y, 0, 65)
+ w.coords('selected', w.coords(square)[0..1])
+ w.dtag('selected')
+ @dragging = nil
+ end
+
+ def make_SeeDismiss
+ ## See Code / Dismiss
+ frame = Ttk::Frame.new($knightstour)
+ sep = Ttk::Separator.new(frame)
+ Tk.grid(sep, :columnspan=>4, :row=>0, :sticky=>'ew', :pady=>2)
+ TkGrid('x',
+ Ttk::Button.new(frame, :text=>'See Code',
+ :image=>$image['view'], :compound=>:left,
+ :command=>proc{showCode 'knightstour'}),
+ Ttk::Button.new(frame, :text=>'Dismiss',
+ :image=>$image['delete'], :compound=>:left,
+ :command=>proc{
+ $knightstour.destroy
+ $knightstour = nil
+ }),
+ :padx=>4, :pady=>4)
+ frame.grid_columnconfigure(0, :weight=>1)
+ frame
+ end
+
+ def create_gui(parent = nil)
+ $knightstour.destroy rescue nil
+ $knightstour = Tk::Toplevel.new(parent, :title=>"Knight's tour")
+ $knightstour.withdraw
+ base_f = Ttk::Frame.new($knightstour)
+ @board = Tk::Canvas.new(base_f, :width=>240, :height=>240)
+ @log = Tk::Text.new(base_f, :width=>12, :height=>1,
+ :font=>'Arial 8', :background=>'white')
+ scr = @log.yscrollbar(Ttk::Scrollbar.new(base_f))
+
+ @visited = []
+ @delay = TkVariable.new(600)
+ @continuous = TkVariable.new(false)
+
+ tool_f = Ttk::Frame.new($knightstour)
+ label = Ttk::Label.new(tool_f, :text=>'Speed')
+ scale = Ttk::Scale.new(tool_f, :from=>8, :to=>2000, :variable=>@delay,
+ :command=>proc{|n| set_delay(n)})
+ check = Ttk::Checkbutton.new(tool_f, :text=>'Repeat',
+ :variable=>@continuous)
+ @start_btn = Ttk::Button.new(tool_f, :text=>'Start',
+ :command=>proc{tour()})
+ @exit_btn = Ttk::Button.new(tool_f, :text=>'Exit',
+ :command=>proc{_exit()})
+
+ 7.downto(0){|row|
+ 0.upto(7){|col|
+ if ((col & 1) ^ (row & 1)).zero?
+ fill = 'bisque'
+ dfill = 'bisque3'
+ else
+ fill = 'tan3'
+ dfill = 'tan4'
+ end
+ coords = [col * 30 + 4, row * 30 + 4, col * 30 + 30, row * 30 + 30]
+ @board.create(TkcRectangle, coords,
+ :fill=>fill, :disabledfill=>dfill,
+ :width=>2, :state=>:disabled)
+ }
+ }
+
+ @knight_font = TkFont.new(:size=>-24)
+ @knight = TkcText.new(@board, 0, 0, :font=>@knight_font,
+ :text=>Tk::UTF8_String.new('\u265e'),
+ :anchor=>'nw', # :tags=>'knight',
+ :fill=>'black', :activefill=>'#600000')
+ @knight.coords(@board.coords(rand(64)+1)[0..1])
+ @knight.bind('ButtonPress-1', '%W %x %y'){|w,x,y| drag_start(w,x,y)}
+ @knight.bind('Motion', '%W %x %y'){|w,x,y| drag_motion(w,x,y)}
+ @knight.bind('ButtonRelease-1', '%W %x %y'){|w,x,y| drag_end(w,x,y)}
+
+ Tk.grid(@board, @log, scr, :sticky=>'news')
+ base_f.grid_rowconfigure(0, :weight=>1)
+ base_f.grid_columnconfigure(0, :weight=>1)
+
+ Tk.grid(base_f, '-', '-', '-', '-', '-', :sticky=>'news')
+ widgets = [label, scale, check, @start_btn]
+ sg = nil
+ unless $RubyTk_WidgetDemo
+ widgets << @exit_btn
+ if Tk.windowingsystem != 'aqua'
+ #widgets.unshift(Ttk::SizeGrip.new(tool_f))
+ Ttk::SizeGrip.new(tool_f).pack(:side=>:right, :anchor=>'se')
+ end
+ end
+ Tk.pack(widgets, :side=>:right)
+ if Tk.windowingsystem == 'aqua'
+ TkPack.configure(widgets, :padx=>[4, 4], :pady=>[12, 12])
+ TkPack.configure(widgets[0], :padx=>[4, 24])
+ TkPack.configure(widgets[-1], :padx=>[16, 4])
+ end
+
+ Tk.grid(tool_f, '-', '-', '-', '-', '-', :sticky=>'ew')
+
+ if $RubyTk_WidgetDemo
+ Tk.grid(make_SeeDismiss(), '-', '-', '-', '-', '-', :sticky=>'ew')
+ end
+
+ $knightstour.grid_rowconfigure(0, :weight=>1)
+ $knightstour.grid_columnconfigure(0, :weight=>1)
+
+ $knightstour.bind('Control-F2'){TkConsole.show}
+ $knightstour.bind('Return'){@start_btn.invoke}
+ $knightstour.bind('Escape'){@exit_btn.invoke}
+ $knightstour.bind('Destroy'){ _stop }
+ $knightstour.protocol('WM_DELETE_WINDOW'){ _exit }
+
+ $knightstour.deiconify
+ $knightstour.tkwait_destroy
+ end
+
+ def initialize(parent = nil)
+ create_gui(parent)
+ end
+end
+
+Tk.root.withdraw unless $RubyTk_WidgetDemo
+Thread.new{Tk.mainloop} if __FILE__ == $0
+Knights_Tour.new
diff --git a/jni/ruby/ext/tk/sample/demos-en/label.rb b/jni/ruby/ext/tk/sample/demos-en/label.rb
new file mode 100644
index 0000000..5be06ea
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/demos-en/label.rb
@@ -0,0 +1,72 @@
+# label.rb
+#
+# This demonstration script creates a toplevel window containing
+# several label widgets.
+#
+# label widget demo (called by 'widget')
+#
+
+# toplevel widget
+if defined?($label_demo) && $label_demo
+ $label_demo.destroy
+ $label_demo = nil
+end
+
+# demo toplevel widget
+$label_demo = TkToplevel.new {|w|
+ title("Label Demonstration")
+ iconname("label")
+ positionWindow(w)
+}
+
+base_frame = TkFrame.new($label_demo).pack(:fill=>:both, :expand=>true)
+
+# label
+msg = TkLabel.new(base_frame) {
+ font $font
+ wraplength '4i'
+ justify 'left'
+ text "Five labels are displayed below: three textual ones on the left, and a bitmap label and a text label on the right. Labels are pretty boring because you can't do anything with them."
+}
+msg.pack('side'=>'top')
+
+# frame
+TkFrame.new(base_frame) {|frame|
+ TkButton.new(frame) {
+ text 'Dismiss'
+ command proc{
+ tmppath = $label_demo
+ $label_demo = nil
+ tmppath.destroy
+ }
+ }.pack('side'=>'left', 'expand'=>'yes')
+
+ TkButton.new(frame) {
+ text 'See Code'
+ command proc{showCode 'label'}
+ }.pack('side'=>'left', 'expand'=>'yes')
+
+}.pack('side'=>'bottom', 'fill'=>'x', 'pady'=>'2m')
+
+# label demo
+f_left = TkFrame.new(base_frame)
+f_right = TkFrame.new(base_frame)
+[f_left, f_right].each{|w| w.pack('side'=>'left', 'expand'=>'yes',
+ 'padx'=>10, 'pady'=>10, 'fill'=>'both')}
+
+# label
+[ TkLabel.new(f_left, 'text'=>'First label'),
+ TkLabel.new(f_left, 'text'=>'Second label, raised',
+ 'relief'=>'raised'),
+ TkLabel.new(f_left, 'text'=>'Third label, sunken', 'relief'=>'sunken')
+].each{|w| w.pack('side'=>'top', 'expand'=>'yes', 'pady'=>2, 'anchor'=>'w')}
+
+# TkLabel.new(f_right) {
+Tk::Label.new(f_right) {
+ bitmap('@' + [$demo_dir,'..','images','face.xbm'].join(File::Separator))
+ borderwidth 2
+ relief 'sunken'
+}.pack('side'=>'top')
+
+TkLabel.new(f_right) { text 'Tcl/Tk Proprietor' }.pack('side'=>'top')
+
diff --git a/jni/ruby/ext/tk/sample/demos-en/labelframe.rb b/jni/ruby/ext/tk/sample/demos-en/labelframe.rb
new file mode 100644
index 0000000..ad968bc
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/demos-en/labelframe.rb
@@ -0,0 +1,95 @@
+# labelframe.rb
+#
+# This demonstration script creates a toplevel window containing
+# several labelframe widgets.
+#
+# based on "Id: labelframe.tcl,v 1.2 2001/10/30 11:21:50 dkf Exp"
+
+
+if defined?($labelframe_demo) && $labelframe_demo
+ $labelframe_demo.destroy
+ $labelframe_demo = nil
+end
+
+$labelframe_demo = TkToplevel.new {|w|
+ title("Labelframe Demonstration")
+ iconname("labelframe")
+ positionWindow(w)
+}
+
+base_frame = TkFrame.new($labelframe_demo).pack(:fill=>:both, :expand=>true)
+
+# Some information
+TkLabel.new(base_frame,
+ :font=>$font, :wraplength=>'4i', :justify=>:left,
+ :text=><<EOL).pack(:side=>:top)
+Labelframes are used to group related widgets together. \
+The label may be either plain text or another widget. \
+If your Tk library linked to Ruby doesn't include a 'labelframe' widget, \
+this demo doesn't work. Please use later version of Tk \
+which supports a 'labelframe' widget.
+EOL
+
+# The bottom buttons
+TkFrame.new(base_frame){|f|
+ pack(:side=>:bottom, :fill=>:x, :pady=>'2m')
+
+ TkButton.new(f, :text=>'Dismiss', :width=>15, :command=>proc{
+ $labelframe_demo.destroy
+ $labelframe_demo = nil
+ }).pack(:side=>:left, :expand=>true)
+
+ TkButton.new(f, :text=>'See Code', :width=>15, :command=>proc{
+ showCode 'labelframe'
+ }).pack(:side=>:left, :expand=>true)
+}
+
+# Demo area
+w = TkFrame.new(base_frame).pack(:side=>:bottom, :fill=>:both,
+ :expand=>true)
+
+# A group of radiobuttons in a labelframe
+TkLabelFrame.new(w, :text=>'Value',
+ :padx=>2, :pady=>2) {|f|
+ grid(:row=>0, :column=>0, :pady=>'2m', :padx=>'2m')
+
+ v = TkVariable.new
+ (1..4).each{|i|
+ TkRadiobutton.new(f, :text=>"This is value #{i}",
+ :variable=>v, :value=>i) {
+ pack(:side=>:top, :fill=>:x, :pady=>2)
+ }
+ }
+}
+
+
+# Using a label window to control a group of options.
+$lfdummy = TkVariable.new(0)
+
+def lfEnableButtons(w)
+ TkWinfo.children(w).each{|child|
+ next if child.path =~ /\.cb$/
+ if $lfdummy == 1
+ child.state(:normal)
+ else
+ child.state(:disabled)
+ end
+ }
+end
+
+TkLabelFrame.new(w, :pady=>2, :padx=>2){|f|
+ TkCheckButton.new(f, :widgetname=>'cb', :variable=>$lfdummy,
+ :text=>"Use this option.", :padx=>0) {|cb|
+ command proc{lfEnableButtons(f)}
+ f.labelwidget(cb)
+ }
+ grid(:row=>0, :column=>1, :pady=>'2m', :padx=>'2m')
+
+ %w(Option1 Option2 Option3).each{|str|
+ TkCheckbutton.new(f, :text=>str).pack(:side=>:top, :fill=>:x, :pady=>2)
+ }
+
+ lfEnableButtons(f)
+}
+
+TkGrid.columnconfigure(w, [0,1], :weight=>1)
diff --git a/jni/ruby/ext/tk/sample/demos-en/mclist.rb b/jni/ruby/ext/tk/sample/demos-en/mclist.rb
new file mode 100644
index 0000000..17019bb
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/demos-en/mclist.rb
@@ -0,0 +1,117 @@
+# mclist.rb --
+#
+# This demonstration script creates a toplevel window containing a Ttk
+# tree widget configured as a multi-column listbox.
+#
+# based on "Id: mclist.tcl,v 1.3 2007/12/13 15:27:07 dgp Exp"
+
+if defined?($mclist_demo) && $mclist_demo
+ $mclist_demo.destroy
+ $mclist_demo = nil
+end
+
+$mclist_demo = TkToplevel.new {|w|
+ title("Multi-Column List")
+ iconname("mclist")
+ positionWindow(w)
+}
+
+base_frame = TkFrame.new($mclist_demo).pack(:fill=>:both, :expand=>true)
+
+## Explanatory text
+Ttk::Label.new(base_frame, :font=>$font, :wraplength=>'4i',
+ :justify=>:left, :anchor=>'n', :padding=>[10, 2, 10, 6],
+ :text=><<EOL).pack(:fill=>:x)
+Ttk is the new Tk themed widget set. \
+One of the widgets it includes is a tree widget, \
+which can be configured to display multiple columns of informational data \
+without displaying the tree itself. \
+This is a simple way to build a listbox that has multiple columns. \
+Clicking on the heading for a column will sort the data by that column. \
+You can also change the width of the columns \
+by dragging the boundary between them.
+EOL
+
+## See Code / Dismiss
+Ttk::Frame.new(base_frame) {|frame|
+ sep = Ttk::Separator.new(frame)
+ Tk.grid(sep, :columnspan=>4, :row=>0, :sticky=>'ew', :pady=>2)
+ TkGrid('x',
+ Ttk::Button.new(frame, :text=>'See Code',
+ :image=>$image['view'], :compound=>:left,
+ :command=>proc{showCode 'mclist'}),
+ Ttk::Button.new(frame, :text=>'Dismiss',
+ :image=>$image['delete'], :compound=>:left,
+ :command=>proc{
+ $mclist_demo.destroy
+ $mclist_demo = nil
+ }),
+ :padx=>4, :pady=>4)
+ grid_columnconfigure(0, :weight=>1)
+ pack(:side=>:bottom, :fill=>:x)
+}
+
+container = Ttk::Frame.new(base_frame)
+tree = Ttk::Treeview.new(base_frame, :columns=>%w(country capital currency),
+ :show=>:headings)
+if Tk.windowingsystem != 'aqua'
+ vsb = tree.yscrollbar(Ttk::Scrollbar.new(base_frame))
+ hsb = tree.xscrollbar(Ttk::Scrollbar.new(base_frame))
+else
+ vsb = tree.yscrollbar(Tk::Scrollbar.new(base_frame))
+ hsb = tree.xscrollbar(Tk::Scrollbar.new(base_frame))
+end
+
+container.pack(:fill=>:both, :expand=>true)
+Tk.grid(tree, vsb, :in=>container, :sticky=>'nsew')
+Tk.grid(hsb, :in=>container, :sticky=>'nsew')
+container.grid_columnconfigure(0, :weight=>1)
+container.grid_rowconfigure(0, :weight=>1)
+
+## The data we're going to insert
+data = [
+ ['Argentina', 'Buenos Aires', 'ARS'],
+ ['Australia', 'Canberra', 'AUD'],
+ ['Brazil', 'Brazilia', 'BRL'],
+ ['Canada', 'Ottawa', 'CAD'],
+ ['China', 'Beijing', 'CNY'],
+ ['France', 'Paris', 'EUR'],
+ ['Germany', 'Berlin', 'EUR'],
+ ['India', 'New Delhi', 'INR'],
+ ['Italy', 'Rome', 'EUR'],
+ ['Japan', 'Tokyo', 'JPY'],
+ ['Mexico', 'Mexico City', 'MXN'],
+ ['Russia', 'Moscow', 'RUB'],
+ ['South Africa', 'Pretoria', 'ZAR'],
+ ['United Kingdom', 'London', 'GBP'],
+ ['United States', 'Washington, D.C.', 'USD'],
+]
+
+## Code to insert the data nicely
+font = Ttk::Style.lookup(tree[:style], :font)
+cols = %w(country capital currency)
+cols.zip(%w(Country Capital Currency)).each{|col, name|
+ tree.heading_configure(col, :text=>name,
+ :command=>proc{sort_by(tree, col, false)})
+ tree.column_configure(col, :width=>TkFont.measure(font, name))
+}
+
+data.each{|country, capital, currency|
+ #tree.insert('', :end, :values=>[country, capital, currency])
+ tree.insert(nil, :end, :values=>[country, capital, currency])
+ cols.zip([country, capital, currency]).each{|col, val|
+ len = TkFont.measure(font, "#{val} ")
+ if tree.column_cget(col, :width) < len
+ tree.column_configure(col, :width=>len)
+ end
+ }
+}
+
+## Code to do the sorting of the tree contents when clicked on
+def sort_by(tree, col, direction)
+ tree.children(nil).map!{|row| [tree.get(row, col), row.id]} .
+ sort(&((direction)? proc{|x, y| y <=> x}: proc{|x, y| x <=> y})) .
+ each_with_index{|info, idx| tree.move(info[1], nil, idx)}
+
+ tree.heading_configure(col, :command=>proc{sort_by(tree, col, ! direction)})
+end
diff --git a/jni/ruby/ext/tk/sample/demos-en/menu.rb b/jni/ruby/ext/tk/sample/demos-en/menu.rb
new file mode 100644
index 0000000..a458dbb
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/demos-en/menu.rb
@@ -0,0 +1,196 @@
+#
+# menus widget demo (called by 'widget')
+#
+
+# toplevel widget
+if defined?($menu_demo) && $menu_demo
+ $menu_demo.destroy
+ $menu_demo = nil
+end
+
+# demo toplevel widget
+$menu_demo = TkToplevel.new {|w|
+ title("File Selection Dialogs")
+ iconname("menu")
+ positionWindow(w)
+}
+
+base_frame = TkFrame.new($menu_demo).pack(:fill=>:both, :expand=>true)
+
+# menu frame
+$menu_frame = TkFrame.new(base_frame, 'relief'=>'raised', 'bd'=>2)
+$menu_frame.pack('side'=>'top', 'fill'=>'x')
+
+begin
+ windowingsystem = Tk.windowingsystem()
+rescue
+ windowingsystem = ""
+end
+
+# label
+TkLabel.new(base_frame,'font'=>$font,'wraplength'=>'4i','justify'=>'left') {
+ if $tk_platform['platform'] == 'macintosh' ||
+ windowingsystem == "classic" || windowingsystem == "aqua"
+ text("This window contains a menubar with cascaded menus. You can invoke entries with an accelerator by typing Command+x, where \"x\" is the character next to the command key symbol. The rightmost menu can be torn off into a palette by dragging outside of its bounds and releasing the mouse.")
+ else
+ text("This window contains a menubar with cascaded menus. You can post a menu from the keyboard by typing Alt+x, where \"x\" is the character underlined on the menu. You can then traverse among the menus using the arrow keys. When a menu is posted, you can invoke the current entry by typing space, or you can invoke any entry by typing its underlined character. If a menu entry has an accelerator, you can invoke the entry without posting the menu just by typing the accelerator. The rightmost menu can be torn off into a palette by selecting the first item in the menu.")
+ end
+}.pack('side'=>'top')
+
+# frame
+TkFrame.new(base_frame) {|frame|
+ TkButton.new(frame) {
+ text 'Dismiss'
+ command proc{
+ tmppath = $menu_demo
+ $menu_demo = nil
+ tmppath.destroy
+ }
+ }.pack('side'=>'left', 'expand'=>'yes')
+
+ TkButton.new(frame) {
+ text 'Show Code'
+ command proc{showCode 'menu'}
+ }.pack('side'=>'left', 'expand'=>'yes')
+}.pack('side'=>'bottom', 'fill'=>'x', 'pady'=>'2m')
+
+# menu
+TkMenubutton.new($menu_frame, 'text'=>'File', 'underline'=>0) {|m|
+ pack('side'=>'left')
+ TkMenu.new(m, 'tearoff'=>false) {|file_menu|
+ m.configure('menu'=>file_menu)
+ add('command', 'label'=>'Open...', 'command'=>proc{fail 'this is just a demo: no action has been defined for the "Open..." entry'})
+ add('command', 'label'=>'New', 'command'=>proc{fail 'this is just a demo: no action has been defined for the "New" entry'})
+ add('command', 'label'=>'Save', 'command'=>proc{fail 'this is just a demo: no action has been defined for the "Save" entry'})
+ add('command', 'label'=>'Save As...', 'command'=>proc{fail 'this is just a demo: no action has been defined for the "Save As..." entry'})
+ add('separator')
+ add('command', 'label'=>'Print Setup...', 'command'=>proc{fail 'this is just a demo: no action has been defined for the "Print Setup..." entry'})
+ add('command', 'label'=>'Print...', 'command'=>proc{fail 'this is just a demo: no action has been defined for the "Print..." entry'})
+ add('separator')
+ add('command', 'label'=>'Dismiss Menus Demo', 'command'=>proc{$menu_demo.destroy})
+ }
+}
+
+if $tk_platform['platform'] == 'macintosh' ||
+ windowingsystem == "classic" || windowingsystem == "aqua"
+ modifier = 'Command'
+elsif $tk_platform['platform'] == 'windows'
+ modifier = 'Control'
+else
+ modifier = 'Meta'
+end
+
+TkMenubutton.new($menu_frame, 'text'=>'Basic', 'underline'=>0) {|m|
+ pack('side'=>'left')
+ TkMenu.new(m, 'tearoff'=>false) {|basic_menu|
+ m.configure('menu'=>basic_menu)
+ add('command', 'label'=>'Long entry that does nothing')
+ ['A','B','C','D','E','F','G'].each{|c|
+ add('command', 'label'=>"Print letter \"#{c}\"",
+ 'underline'=>14, 'accelerator'=>"Meta+#{c}",
+ 'command'=>proc{print c,"\n"}, 'accelerator'=>"#{modifier}+#{c}")
+ $menu_demo.bind("#{modifier}-#{c.downcase}", proc{print c,"\n"})
+ }
+ }
+}
+
+TkMenubutton.new($menu_frame, 'text'=>'Cascades', 'underline'=>0) {|m|
+ pack('side'=>'left')
+ TkMenu.new(m, 'tearoff'=>false) {|cascade_menu|
+ m.configure('menu'=>cascade_menu)
+ add('command', 'label'=>'Print hello',
+ 'command'=>proc{print "Hello\n"},
+ 'accelerator'=>"#{modifier}+H", 'underline'=>6)
+ $menu_demo.bind("#{modifier}-h", proc{print "Hello\n"})
+ add('command', 'label'=>'Print goodbye',
+ 'command'=>proc{print "Goodbye\n"},
+ 'accelerator'=>"#{modifier}+G", 'underline'=>6)
+ $menu_demo.bind("#{modifier}-g", proc{print "Goodbye\n"})
+
+ TkMenu.new(cascade_menu, 'tearoff'=>false) {|cascade_check|
+ cascade_menu.add('cascade', 'label'=>'Check buttons',
+ 'menu'=>cascade_check, 'underline'=>0)
+ oil = TkVariable.new(0)
+ add('check', 'label'=>'Oil checked', 'variable'=>oil)
+ trans = TkVariable.new(0)
+ add('check', 'label'=>'Transmission checked', 'variable'=>trans)
+ brakes = TkVariable.new(0)
+ add('check', 'label'=>'Brakes checked', 'variable'=>brakes)
+ lights = TkVariable.new(0)
+ add('check', 'label'=>'Lights checked', 'variable'=>lights)
+ add('separator')
+ add('command', 'label'=>'Show current values',
+ 'command'=>proc{showVars($menu_demo,
+ ['oil', oil],
+ ['trans', trans],
+ ['brakes', brakes],
+ ['lights', lights])} )
+ invoke 1
+ invoke 3
+ }
+
+ TkMenu.new(cascade_menu, 'tearoff'=>false) {|cascade_radio|
+ cascade_menu.add('cascade', 'label'=>'Radio buttons',
+ 'menu'=>cascade_radio, 'underline'=>0)
+ pointSize = TkVariable.new
+ add('radio', 'label'=>'10 point', 'variable'=>pointSize, 'value'=>10)
+ add('radio', 'label'=>'14 point', 'variable'=>pointSize, 'value'=>14)
+ add('radio', 'label'=>'18 point', 'variable'=>pointSize, 'value'=>18)
+ add('radio', 'label'=>'24 point', 'variable'=>pointSize, 'value'=>24)
+ add('radio', 'label'=>'32 point', 'variable'=>pointSize, 'value'=>32)
+ add('separator')
+ style = TkVariable.new
+ add('radio', 'label'=>'Roman', 'variable'=>style, 'value'=>'roman')
+ add('radio', 'label'=>'Bold', 'variable'=>style, 'value'=>'bold')
+ add('radio', 'label'=>'Italic', 'variable'=>style, 'value'=>'italic')
+ add('separator')
+ add('command', 'label'=>'Show current values',
+ 'command'=>proc{showVars($menu_demo,
+ ['pointSize', pointSize],
+ ['style', style])} )
+ invoke 1
+ invoke 7
+ }
+ }
+}
+
+TkMenubutton.new($menu_frame, 'text'=>'Icons', 'underline'=>0) {|m|
+ pack('side'=>'left')
+ TkMenu.new(m, 'tearoff'=>false) {|icon_menu|
+ m.configure('menu'=>icon_menu)
+ add('command',
+ 'bitmap'=>'@'+[$demo_dir,'..',
+ 'images','pattern.xbm'].join(File::Separator),
+ 'command'=>proc{TkDialog.new('title'=>'Bitmap Menu Entry',
+ 'text'=>'The menu entry you invoked displays a bitmap rather than a text string. Other than this, it is just like any other menu entry.',
+ 'bitmap'=>'', 'default'=>0,
+ 'buttons'=>'Dismiss')} )
+ ['info', 'questhead', 'error'].each{|icon|
+ add('command', 'bitmap'=>icon,
+ 'command'=>proc{print "You invoked the #{icon} bitmap\n"})
+ }
+ }
+}
+
+TkMenubutton.new($menu_frame, 'text'=>'More', 'underline'=>0) {|m|
+ pack('side'=>'left')
+ TkMenu.new(m, 'tearoff'=>false) {|more_menu|
+ m.configure('menu'=>more_menu)
+ [ 'An entry','Another entry','Does nothing','Does almost nothing',
+ 'Make life meaningful' ].each{|i|
+ add('command', 'label'=>i,
+ 'command'=>proc{print "You invoked \"#{i}\"\n"})
+ }
+ }
+}
+
+TkMenubutton.new($menu_frame, 'text'=>'Colors', 'underline'=>0) {|m|
+ pack('side'=>'left')
+ TkMenu.new(m) {|colors_menu|
+ m.configure('menu'=>colors_menu)
+ ['red', 'orange', 'yellow', 'green', 'blue'].each{|c|
+ add('command', 'label'=>c, 'background'=>c,
+ 'command'=>proc{print "You invoked \"#{c}\"\n"})
+ }
+ }
+}
diff --git a/jni/ruby/ext/tk/sample/demos-en/menu84.rb b/jni/ruby/ext/tk/sample/demos-en/menu84.rb
new file mode 100644
index 0000000..4fc5396
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/demos-en/menu84.rb
@@ -0,0 +1,215 @@
+#
+# menus widget demo (called by 'widget')
+#
+
+# toplevel widget
+if defined?($menu84_demo) && $menu84_demo
+ $menu84_demo.destroy
+ $menu84_demo = nil
+end
+
+# demo toplevel widget
+$menu84_demo = TkToplevel.new {|w|
+ title("File Selection Dialogs")
+ iconname("menu84")
+ positionWindow(w)
+}
+
+base_frame = TkFrame.new($menu84_demo).pack(:fill=>:both, :expand=>true)
+
+begin
+ windowingsystem = Tk.windowingsystem()
+rescue
+ windowingsystem = ""
+end
+
+# label
+TkLabel.new(base_frame,'font'=>$font,'wraplength'=>'4i','justify'=>'left') {
+ if $tk_platform['platform'] == 'macintosh' ||
+ windowingsystem == "classic" || windowingsystem == "aqua"
+ text("This window contains a menubar with cascaded menus. You can invoke entries with an accelerator by typing Command+x, where \"x\" is the character next to the command key symbol. The rightmost menu can be torn off into a palette by dragging outside of its bounds and releasing the mouse.")
+ else
+ text("This window contains a menubar with cascaded menus. You can post a menu from the keyboard by typing Alt+x, where \"x\" is the character underlined on the menu. You can then traverse among the menus using the arrow keys. When a menu is posted, you can invoke the current entry by typing space, or you can invoke any entry by typing its underlined character. If a menu entry has an accelerator, you can invoke the entry without posting the menu just by typing the accelerator. The rightmost menu can be torn off into a palette by selecting the first item in the menu.")
+ end
+}.pack('side'=>'top')
+
+
+menustatus = TkVariable.new(" ")
+TkFrame.new(base_frame) {|frame|
+ TkLabel.new(frame, 'textvariable'=>menustatus, 'relief'=>'sunken',
+ 'bd'=>1, 'font'=>['Helvetica', '10'],
+ 'anchor'=>'w').pack('side'=>'left', 'padx'=>2,
+ 'expand'=>true, 'fill'=>'both')
+ pack('side'=>'bottom', 'fill'=>'x', 'pady'=>2)
+}
+
+
+# frame
+TkFrame.new(base_frame) {|frame|
+ TkButton.new(frame) {
+ text 'Dismiss'
+ command proc{
+ tmppath = $menu84_demo
+ $menu84_demo = nil
+ tmppath.destroy
+ }
+ }.pack('side'=>'left', 'expand'=>'yes')
+
+ TkButton.new(frame) {
+ text 'Show Code'
+ command proc{showCode 'menu84'}
+ }.pack('side'=>'left', 'expand'=>'yes')
+}.pack('side'=>'bottom', 'fill'=>'x', 'pady'=>'2m')
+
+
+# create menu frame
+$menu84_frame = TkMenu.new($menu84_demo, 'tearoff'=>false)
+
+# menu
+TkMenu.new($menu84_frame, 'tearoff'=>false) {|m|
+ $menu84_frame.add('cascade', 'label'=>'File', 'menu'=>m, 'underline'=>0)
+ add('command', 'label'=>'Open...', 'command'=>proc{fail 'this is just a demo: no action has been defined for the "Open..." entry'})
+ add('command', 'label'=>'New', 'command'=>proc{fail 'this is just a demo: no action has been defined for the "New" entry'})
+ add('command', 'label'=>'Save', 'command'=>proc{fail 'this is just a demo: no action has been defined for the "Save" entry'})
+ add('command', 'label'=>'Save As...', 'command'=>proc{fail 'this is just a demo: no action has been defined for the "Save As..." entry'})
+ add('separator')
+ add('command', 'label'=>'Print Setup...', 'command'=>proc{fail 'this is just a demo: no action has been defined for the "Print Setup..." entry'})
+ add('command', 'label'=>'Print...', 'command'=>proc{fail 'this is just a demo: no action has been defined for the "Print..." entry'})
+ add('separator')
+ add('command', 'label'=>'Dismiss Menus Demo', 'command'=>proc{$menu84_demo.destroy})
+}
+
+if $tk_platform['platform'] == 'macintosh' ||
+ windowingsystem = "classic" || windowingsystem = "aqua"
+ modifier = 'Command'
+elsif $tk_platform['platform'] == 'windows'
+ modifier = 'Control'
+else
+ modifier = 'Meta'
+end
+
+TkMenu.new($menu84_frame, 'tearoff'=>false) {|m|
+ $menu84_frame.add('cascade', 'label'=>'Basic', 'menu'=>m, 'underline'=>0)
+ add('command', 'label'=>'Long entry that does nothing')
+ ['A','B','C','D','E','F','G'].each{|c|
+ add('command', 'label'=>"Print letter \"#{c}\"",
+ 'underline'=>14, 'accelerator'=>"Meta+#{c}",
+ 'command'=>proc{print c,"\n"}, 'accelerator'=>"#{modifier}+#{c}")
+ $menu84_demo.bind("#{modifier}-#{c.downcase}", proc{print c,"\n"})
+ }
+}
+
+TkMenu.new($menu84_frame, 'tearoff'=>false) {|m|
+ $menu84_frame.add('cascade', 'label'=>'Cascades', 'menu'=>m, 'underline'=>0)
+ add('command', 'label'=>'Print hello',
+ 'command'=>proc{print "Hello\n"},
+ 'accelerator'=>"#{modifier}+H", 'underline'=>6)
+ $menu84_demo.bind("#{modifier}-h", proc{print "Hello\n"})
+ add('command', 'label'=>'Print goodbye',
+ 'command'=>proc{print "Goodbye\n"},
+ 'accelerator'=>"#{modifier}+G", 'underline'=>6)
+ $menu84_demo.bind("#{modifier}-g", proc{print "Goodbye\n"})
+
+ TkMenu.new(m, 'tearoff'=>false) {|cascade_check|
+ m.add('cascade', 'label'=>'Check buttons',
+ 'menu'=>cascade_check, 'underline'=>0)
+ oil = TkVariable.new(0)
+ add('check', 'label'=>'Oil checked', 'variable'=>oil)
+ trans = TkVariable.new(0)
+ add('check', 'label'=>'Transmission checked', 'variable'=>trans)
+ brakes = TkVariable.new(0)
+ add('check', 'label'=>'Brakes checked', 'variable'=>brakes)
+ lights = TkVariable.new(0)
+ add('check', 'label'=>'Lights checked', 'variable'=>lights)
+ add('separator')
+ add('command', 'label'=>'Show current values',
+ 'command'=>proc{showVars($menu84_demo,
+ ['oil', oil],
+ ['trans', trans],
+ ['brakes', brakes],
+ ['lights', lights])} )
+ invoke 1
+ invoke 3
+ }
+
+ TkMenu.new(m, 'tearoff'=>false) {|cascade_radio|
+ m.add('cascade', 'label'=>'Radio buttons',
+ 'menu'=>cascade_radio, 'underline'=>0)
+ pointSize = TkVariable.new
+ add('radio', 'label'=>'10 point', 'variable'=>pointSize, 'value'=>10)
+ add('radio', 'label'=>'14 point', 'variable'=>pointSize, 'value'=>14)
+ add('radio', 'label'=>'18 point', 'variable'=>pointSize, 'value'=>18)
+ add('radio', 'label'=>'24 point', 'variable'=>pointSize, 'value'=>24)
+ add('radio', 'label'=>'32 point', 'variable'=>pointSize, 'value'=>32)
+ add('separator')
+ style = TkVariable.new
+ add('radio', 'label'=>'Roman', 'variable'=>style, 'value'=>'roman')
+ add('radio', 'label'=>'Bold', 'variable'=>style, 'value'=>'bold')
+ add('radio', 'label'=>'Italic', 'variable'=>style, 'value'=>'italic')
+ add('separator')
+ add('command', 'label'=>'Show current values',
+ 'command'=>proc{showVars($menu84_demo,
+ ['pointSize', pointSize],
+ ['style', style])} )
+ invoke 1
+ invoke 7
+ }
+}
+
+TkMenu.new($menu84_frame, 'tearoff'=>false) {|m|
+ $menu84_frame.add('cascade', 'label'=>'Icons', 'menu'=>m, 'underline'=>0)
+ add('command', 'hidemargin'=>1,
+ 'bitmap'=>'@'+[$demo_dir,'..',
+ 'images','pattern.xbm'].join(File::Separator),
+ 'command'=>proc{TkDialog.new('title'=>'Bitmap Menu Entry',
+ 'text'=>'The menu entry you invoked displays a bitmap rather than a text string. Other than this, it is just like any other menu entry.',
+ 'bitmap'=>'', 'default'=>0,
+ 'buttons'=>'Dismiss')} )
+ ['info', 'questhead', 'error'].each{|icon|
+ add('command', 'bitmap'=>icon, 'hidemargin'=>1,
+ 'command'=>proc{print "You invoked the #{icon} bitmap\n"})
+ }
+
+ entryconfigure(2, :columnbreak=>true)
+}
+
+TkMenu.new($menu84_frame, 'tearoff'=>false) {|m|
+ $menu84_frame.add('cascade', 'label'=>'More', 'menu'=>m, 'underline'=>0)
+ [ 'An entry','Another entry','Does nothing','Does almost nothing',
+ 'Make life meaningful' ].each{|i|
+ add('command', 'label'=>i,
+ 'command'=>proc{print "You invoked \"#{i}\"\n"})
+ }
+
+ m.entryconfigure('Does almost nothing',
+ 'bitmap'=>'questhead', 'compound'=>'left',
+ 'command'=>proc{
+ TkDialog.new('title'=>'Compound Menu Entry',
+ 'message'=>'The menu entry you invoked'+
+ 'displays both a bitmap and '+
+ 'a text string. Other than '+
+ 'this, it isjust like any '+
+ 'other menu entry.',
+ 'buttons'=>['OK'], 'bitmap'=>'')
+ })
+}
+
+TkMenu.new($menu84_frame) {|m|
+ $menu84_frame.add('cascade', 'label'=>'Colors', 'menu'=>m, 'underline'=>0)
+ ['red', 'orange', 'yellow', 'green', 'blue'].each{|c|
+ add('command', 'label'=>c, 'background'=>c,
+ 'command'=>proc{print "You invoked \"#{c}\"\n"})
+ }
+}
+
+$menu84_demo.menu($menu84_frame)
+
+TkMenu.bind('<MenuSelect>', proc{|w|
+ begin
+ label = w.entrycget('active', 'label')
+ rescue
+ label = " "
+ end
+ menustatus.value = label
+ Tk.update(true)
+ }, '%W')
diff --git a/jni/ruby/ext/tk/sample/demos-en/menubu.rb b/jni/ruby/ext/tk/sample/demos-en/menubu.rb
new file mode 100644
index 0000000..6e28e81
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/demos-en/menubu.rb
@@ -0,0 +1,237 @@
+# menubutton.rb
+#
+# This demonstration script creates a window with a bunch of menus
+# and cascaded menus using menubuttons.
+
+require "tkcanvas"
+
+def optionMenu(menubutton, varName, firstValue, *rest)
+ varName.value = firstValue
+ configoptions = {'textvariable'=>varName,'indicatoron'=>'on',
+ 'relief'=>'raised','borderwidth'=>2,'highlightthickness'=>2,
+ 'anchor'=>'c','direction'=>'flush'}
+ configoptions.each {|key, value|
+ menubutton.configure(key, value)
+ }
+ menu = TkMenu.new(menubutton) {
+ tearoff 'off'
+ add 'radio', 'label'=>firstValue, 'variable'=>varName
+ }
+ menubutton.menu(menu)
+ for i in rest
+ menu.add 'radio', 'label'=>i, 'variable'=>varName
+ end
+
+ return menu
+end
+
+if defined?($menubu_demo) && $menubu_demo
+ $menubu_demo.destroy
+ $menubu_demo = nil
+end
+
+$menubu_demo = TkToplevel.new {|w|
+ title("Menu Button Demonstration")
+ iconname("menubutton")
+}
+
+positionWindow($menubu_demo)
+
+base_frame = TkFrame.new($menubu_demo).pack(:fill=>:both, :expand=>true)
+
+# version check
+if $tk_version.to_f < 8.0
+
+# label
+TkLabel.new(base_frame,'font'=>$font,'wraplength'=>'4i','justify'=>'left') {
+ text("This is a demonstration of menubuttons. The \"Below\" menubutton pops its menu below the button; the \"Right\" button pops to the right, etc. There are two option menus directly below this text; one is just a standard menu and the other is a 16-color palette.")
+}.pack('side'=>'top')
+
+# frame
+TkFrame.new(base_frame) {|frame|
+ TkButton.new(frame) {
+ text 'Dismiss'
+ command proc{
+ tmppath = $menubu_demo
+ $menubu_demo = nil
+ tmppath.destroy
+ }
+ }.pack('side'=>'left', 'expand'=>'yes')
+
+ TkButton.new(frame) {
+ text 'Show Code'
+ command proc{showCode 'menubu'}
+ }.pack('side'=>'left', 'expand'=>'yes')
+}.pack('side'=>'bottom', 'fill'=>'x', 'pady'=>'2m')
+
+else ; # Tk8.x
+
+body = TkFrame.new(base_frame)
+body.pack('expand'=>'yes', 'fill'=>'both')
+
+below = TkMenubutton.new(body) {
+ text "Below"
+ underline 0
+ direction 'below'
+ relief 'raised'
+}
+belowMenu = TkMenu.new(below) {
+ tearoff 0
+ add 'command', 'label'=>"Below menu: first item", 'command'=>proc {puts "\"You have selected the first item from the Below menu.\""}
+ add 'command', 'label'=>"Below menu: second item", 'command'=>proc {puts "\"You have selected the second item from the Below menu.\""}
+}
+below.menu(belowMenu)
+below.grid('row'=>0, 'column'=>1, 'sticky'=>'n')
+
+below = TkMenubutton.new(body) {
+ text "Below"
+ underline 0
+ direction 'below'
+ relief 'raised'
+}
+belowMenu = TkMenu.new(below) {
+ tearoff 0
+ add 'command', 'label'=>"Below menu: first item", 'command'=>proc {puts "\"You have selected the first item from the Below menu.\""}
+ add 'command', 'label'=>"Below menu: second item", 'command'=>proc {puts "\"You have selected the second item from the Below menu.\""}
+}
+below.menu(belowMenu)
+below.grid('row'=>0, 'column'=>1, 'sticky'=>'n')
+
+below = TkMenubutton.new(body) {
+ text "Below"
+ underline 0
+ direction 'below'
+ relief 'raised'
+}
+belowMenu = TkMenu.new(below) {
+ tearoff 0
+ add 'command', 'label'=>"Below menu: first item", 'command'=>proc {puts "\"You have selected the first item from the Below menu.\""}
+ add 'command', 'label'=>"Below menu: second item", 'command'=>proc {puts "\"You have selected the second item from the Below menu.\""}
+}
+below.menu(belowMenu)
+below.grid('row'=>0, 'column'=>1, 'sticky'=>'n')
+
+right = TkMenubutton.new(body) {
+ text "Right"
+ underline 0
+ direction 'right'
+ relief 'raised'
+}
+rightMenu = TkMenu.new(right) {
+ tearoff 0
+ add 'command', 'label'=>"Right menu: first item", 'command'=>proc {puts "\"You have selected the first item from the Left menu.\""}
+ add 'command', 'label'=>"Right menu: second item", 'command'=>proc {puts "\"You have selected the second item from the Right menu.\""}
+}
+right.menu(rightMenu)
+right.grid('row'=>1, 'column'=>0, 'sticky'=>'w')
+
+left = TkMenubutton.new(body) {
+ text "Left"
+ underline 0
+ direction 'left'
+ relief 'raised'
+}
+leftMenu = TkMenu.new(left) {
+ tearoff 0
+ add 'command', 'label'=>"Left menu: first item", 'command'=>proc {puts "\"You have selected the first item from the Left menu.\""}
+ add 'command', 'label'=>"Left menu: second item", 'command'=>proc {puts "\"You have selected the second item from the Left menu.\""}
+}
+left.menu(leftMenu)
+left.grid('row'=>1, 'column'=>2, 'sticky'=>'e')
+
+center = TkFrame.new(body) {
+ grid('row'=>1, 'column'=>1, 'sticky'=>'news')
+}
+
+above = TkMenubutton.new(body) {
+ text "Above"
+ underline 0
+ direction 'above'
+ relief 'raised'
+}
+aboveMenu = TkMenu.new(above) {
+ tearoff 0
+ add 'command', 'label'=>"Above menu: first item", 'command'=>proc {puts "\"You have selected the first item from the Above menu.\""}
+ add 'command', 'label'=>"Above menu: second item", 'command'=>proc {puts "\"You have selected the second item from the Above menu.\""}
+}
+above.menu(aboveMenu)
+above.grid('row'=>2, 'column'=>1, 'sticky'=>'s')
+
+center = TkFrame.new(body) {
+ grid('row'=>1, 'column'=>1, 'sticky'=>'news')
+}
+
+TkFrame.new(base_frame) {|frame|
+ TkButton.new(frame) {
+ text 'Dismiss'
+ command proc {
+ tmppath = $menubu_demo
+ $menubu_demo = nil
+ tmppath.destroy
+ }
+ }.pack('side'=>'left', 'expand'=>'yes')
+
+ TkButton.new(frame) {
+ text 'Show Code'
+ command proc { showCode 'menubu' }
+ }.pack('side'=>'left', 'expand'=>'yes')
+}.pack('side'=>'bottom', 'expand'=>'yes', 'fill'=>'x', 'pady'=>'2m')
+
+msg = TkLabel.new(center) {
+# font $font
+ wraplength '4i'
+ justify 'left'
+ text "This is a demonstration of menubuttons. The \"Below\" menubutton pops its menu below the button; the \"Right\" button pops to the right, etc. There are two option menus directly below this text; one is just a standard menu and the other is a 16-color palette."
+}
+msg.pack('side'=>'top', 'padx'=>25, 'pady'=>25)
+
+TkFrame.new(center) {|f|
+ menubuttonoptions = TkVariable.new
+ mbutton = TkMenubutton.new(f)
+ options = optionMenu(mbutton, menubuttonoptions,
+ 'one', 'two', 'three')
+ mbutton.pack('side'=>'left', 'padx'=>25, 'pady'=>25)
+ paletteColor = TkVariable.new
+ colors = ['Black','red4','DarkGreen','NavyBlue', 'gray75',
+ 'Red','Green','Blue','gray50','Yellow','Cyan','Magenta',
+ 'White','Brown','DarkSeaGreen','DarkViolet']
+ colorMenuButton = TkMenubutton.new(f)
+ m = optionMenu(colorMenuButton, paletteColor, *colors)
+ begin
+ windowingsystem = Tk.windowingsystem()
+ rescue
+ windowingsystem = ""
+ end
+ if windowingsystem == "classic" || windowingsystem == "aqua"
+ topBorderColor = 'Black'
+ bottomBorderColor = 'Black'
+ else
+ topBorderColor = 'gray50'
+ bottomBorderColor = 'gray75'
+ end
+ for i in 0..15
+ image = TkPhotoImage.new('height'=>16, 'width'=>16)
+ image.put(topBorderColor, 0, 0, 16, 1)
+ image.put(topBorderColor, 0, 1, 1, 16)
+ image.put(bottomBorderColor, 0, 15, 16, 16)
+ image.put(bottomBorderColor, 15, 1, 16, 16)
+ image.put(colors[i], 1, 1, 15, 15)
+
+ selectimage = TkPhotoImage.new('height'=>16, 'width'=>16)
+ selectimage.put('Black', 0, 0, 16, 2)
+ selectimage.put('Black', 0, 2, 2, 16)
+ selectimage.put('Black', 2, 14, 16, 16)
+ selectimage.put('Black', 14, 2, 16, 14)
+ selectimage.put(colors[i], 2, 2, 14, 14)
+
+ m.entryconfigure(i, 'image'=>image, 'selectimage'=>selectimage, 'hidemargin'=>'on')
+ end
+ m.configure('tearoff', 'on')
+ for c in ['Black', 'gray75', 'gray50', 'White']
+ m.entryconfigure(c, 'columnbreak'=>1)
+ end
+ colorMenuButton.pack('side'=>'left', 'padx'=>25, 'pady'=>25)
+ pack 'padx'=>25, 'pady'=>25
+}
+
+end ; # Tk8.x
diff --git a/jni/ruby/ext/tk/sample/demos-en/msgbox.rb b/jni/ruby/ext/tk/sample/demos-en/msgbox.rb
new file mode 100644
index 0000000..d3d66bf
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/demos-en/msgbox.rb
@@ -0,0 +1,90 @@
+# msgbox.rb
+#
+# This demonstration script creates message boxes of various type
+#
+# message boxes widget demo (called by 'widget')
+#
+
+# toplevel widget
+if defined?($msgbox_demo) && $msgbox_demo
+ $msgbox_demo.destroy
+ $msgbox_demo = nil
+end
+
+# demo toplevel widget
+$msgbox_demo = TkToplevel.new {|w|
+ title("Message Box Demonstration")
+ iconname("messagebox")
+ positionWindow(w)
+}
+
+base_frame = TkFrame.new($msgbox_demo).pack(:fill=>:both, :expand=>true)
+
+# label
+TkLabel.new(base_frame, 'font'=>$font, 'wraplength'=>'4i', 'justify'=>'left',
+ 'text'=>"Choose the icon and type option of the message box. Then press the \"Message Box\" button to see the message box.").pack('side'=>'top')
+
+# frame
+TkFrame.new(base_frame) {|frame|
+ TkButton.new(frame) {
+ text 'Dismiss'
+ command proc{
+ tmppath = $msgbox_demo
+ $msgbox_demo = nil
+ tmppath.destroy
+ }
+ }.pack('side'=>'left', 'expand'=>'yes')
+
+ TkButton.new(frame) {
+ text 'Show Code'
+ command proc{showCode 'msgbox'}
+ }.pack('side'=>'left', 'expand'=>'yes')
+
+ TkButton.new(frame) {
+ text 'Message Box'
+ command proc{showMessageBox $msgbox_demo}
+ }.pack('side'=>'left', 'expand'=>'yes')
+}.pack('side'=>'bottom', 'fill'=>'x', 'pady'=>'2m')
+
+# frame
+$msgbox_leftframe = TkFrame.new(base_frame)
+$msgbox_rightframe = TkFrame.new(base_frame)
+$msgbox_leftframe .pack('side'=>'left', 'expand'=>'yes', 'fill'=>'y',
+ 'pady'=>'.5c', 'padx'=>'.5c')
+$msgbox_rightframe.pack('side'=>'left', 'expand'=>'yes', 'fill'=>'y',
+ 'pady'=>'.5c', 'padx'=>'.5c')
+
+TkLabel.new($msgbox_leftframe, 'text'=>'Icon').pack('side'=>'top')
+TkFrame.new($msgbox_leftframe, 'relief'=>'ridge', 'bd'=>1, 'height'=>2)\
+.pack('side'=>'top', 'fill'=>'x', 'expand'=>'no')
+
+$msgboxIcon = TkVariable.new('info')
+['error', 'info', 'question', 'warning'].each {|icon|
+ TkRadioButton.new($msgbox_leftframe, 'text'=>icon, 'variable'=>$msgboxIcon,
+ 'relief'=>'flat', 'value'=>icon, 'width'=>16,
+ 'anchor'=>'w').pack('side'=>'top', 'pady'=>2,
+ 'anchor'=>'w', 'fill'=>'x')
+}
+
+TkLabel.new($msgbox_rightframe, 'text'=>'Type').pack('side'=>'top')
+TkFrame.new($msgbox_rightframe, 'relief'=>'ridge', 'bd'=>1, 'height'=>2)\
+.pack('side'=>'top', 'fill'=>'x', 'expand'=>'no')
+
+$msgboxType = TkVariable.new('ok')
+['abortretryignore', 'ok', 'okcancel',
+ 'retrycancel', 'yesno', 'yesnocancel'].each {|type|
+ TkRadioButton.new($msgbox_rightframe, 'text'=>type, 'variable'=>$msgboxType,
+ 'relief'=>'flat', 'value'=>type, 'width'=>16,
+ 'anchor'=>'w').pack('side'=>'top', 'pady'=>2,
+ 'anchor'=>'w', 'fill'=>'x')
+}
+
+def showMessageBox(w)
+ button = Tk.messageBox('icon'=>$msgboxIcon.value, 'type'=>$msgboxType.value,
+ 'title'=>'Message', 'parent'=>w,
+ 'message'=>"This is a \"#{$msgboxType.value}\" type messagebox with the \"#{$msgboxIcon.value}\" icon")
+
+ Tk.messageBox('icon'=>'info', 'type'=>'ok', 'parent'=>w,
+ 'message'=>"You have selected \"#{button}\"")
+end
+
diff --git a/jni/ruby/ext/tk/sample/demos-en/msgbox2.rb b/jni/ruby/ext/tk/sample/demos-en/msgbox2.rb
new file mode 100644
index 0000000..c227b59
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/demos-en/msgbox2.rb
@@ -0,0 +1,91 @@
+# msgbox2.rb
+#
+# This demonstration script creates message boxes of various type
+#
+# message boxes widget demo (called by 'widget')
+#
+
+# toplevel widget
+if defined?($msgbox2_demo) && $msgbox2_demo
+ $msgbox2_demo.destroy
+ $msgbox2_demo = nil
+end
+
+# demo toplevel widget
+$msgbox2_demo = TkToplevel.new {|w|
+ title("Message Box Demonstration")
+ iconname("messagebox")
+ positionWindow(w)
+}
+
+base_frame = TkFrame.new($msgbox2_demo).pack(:fill=>:both, :expand=>true)
+
+# label
+TkLabel.new(base_frame, 'font'=>$font, 'wraplength'=>'4i', 'justify'=>'left',
+ 'text'=>"Choose the icon and type option of the message box. Then press the \"Message Box\" button to see the message box with both of a message and a detail.").pack('side'=>'top')
+
+# frame
+TkFrame.new(base_frame) {|frame|
+ TkButton.new(frame) {
+ text 'Dismiss'
+ command proc{
+ tmppath = $msgbox2_demo
+ $msgbox2_demo = nil
+ tmppath.destroy
+ }
+ }.pack('side'=>'left', 'expand'=>'yes')
+
+ TkButton.new(frame) {
+ text 'Show Code'
+ command proc{showCode 'msgbox2'}
+ }.pack('side'=>'left', 'expand'=>'yes')
+
+ TkButton.new(frame) {
+ text 'Message Box'
+ command proc{showMessageBox2 $msgbox2_demo}
+ }.pack('side'=>'left', 'expand'=>'yes')
+}.pack('side'=>'bottom', 'fill'=>'x', 'pady'=>'2m')
+
+# frame
+$msgbox_leftframe = TkFrame.new(base_frame)
+$msgbox_rightframe = TkFrame.new(base_frame)
+$msgbox_leftframe .pack('side'=>'left', 'expand'=>'yes', 'fill'=>'y',
+ 'pady'=>'.5c', 'padx'=>'.5c')
+$msgbox_rightframe.pack('side'=>'left', 'expand'=>'yes', 'fill'=>'y',
+ 'pady'=>'.5c', 'padx'=>'.5c')
+
+TkLabel.new($msgbox_leftframe, 'text'=>'Icon').pack('side'=>'top')
+TkFrame.new($msgbox_leftframe, 'relief'=>'ridge', 'bd'=>1, 'height'=>2)\
+.pack('side'=>'top', 'fill'=>'x', 'expand'=>'no')
+
+$msgboxIcon = TkVariable.new('info')
+['error', 'info', 'question', 'warning'].each {|icon|
+ TkRadioButton.new($msgbox_leftframe, 'text'=>icon, 'variable'=>$msgboxIcon,
+ 'relief'=>'flat', 'value'=>icon, 'width'=>16,
+ 'anchor'=>'w').pack('side'=>'top', 'pady'=>2,
+ 'anchor'=>'w', 'fill'=>'x')
+}
+
+TkLabel.new($msgbox_rightframe, 'text'=>'Type').pack('side'=>'top')
+TkFrame.new($msgbox_rightframe, 'relief'=>'ridge', 'bd'=>1, 'height'=>2)\
+.pack('side'=>'top', 'fill'=>'x', 'expand'=>'no')
+
+$msgboxType = TkVariable.new('ok')
+['abortretryignore', 'ok', 'okcancel',
+ 'retrycancel', 'yesno', 'yesnocancel'].each {|type|
+ TkRadioButton.new($msgbox_rightframe, 'text'=>type, 'variable'=>$msgboxType,
+ 'relief'=>'flat', 'value'=>type, 'width'=>16,
+ 'anchor'=>'w').pack('side'=>'top', 'pady'=>2,
+ 'anchor'=>'w', 'fill'=>'x')
+}
+
+def showMessageBox2(w)
+ button = Tk.messageBox('icon'=>$msgboxIcon.value, 'type'=>$msgboxType.value,
+ 'title'=>'Message', 'parent'=>w,
+ 'message'=>"\"#{$msgboxType.value}\" Type MessageBox",
+ 'detail'=>"This is a \"#{$msgboxType.value}\" type messagebox with the \"#{$msgboxIcon.value}\" icon. Please click one of the following button.")
+
+ Tk.messageBox('icon'=>'info', 'type'=>'ok', 'parent'=>w,
+ 'message'=>"You have selected \"#{button}\"")
+end
+
diff --git a/jni/ruby/ext/tk/sample/demos-en/paned1.rb b/jni/ruby/ext/tk/sample/demos-en/paned1.rb
new file mode 100644
index 0000000..d3d66d1
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/demos-en/paned1.rb
@@ -0,0 +1,47 @@
+# paned1.rb
+#
+# This demonstration script creates a toplevel window containing
+# a paned window that separates two windows horizontally.
+#
+# based on "Id: paned1.tcl,v 1.1 2002/02/22 14:07:01 dkf Exp"
+
+if defined?($paned1_demo) && $paned1_demo
+ $paned1_demo.destroy
+ $paned1_demo = nil
+end
+
+$paned1_demo = TkToplevel.new {|w|
+ title("Horizontal Paned Window Demonstration")
+ iconname("paned1")
+ positionWindow(w)
+}
+
+base_frame = TkFrame.new($paned1_demo).pack(:fill=>:both, :expand=>true)
+
+TkLabel.new(base_frame,
+ :font=>$font, :wraplength=>'4i', :justify=>:left,
+ :text=><<EOL).pack(:side=>:top)
+The sash between the two coloured windows below can be used to divide the area between them. Use the left mouse button to resize without redrawing by just moving the sash, and use the middle mouse button to resize opaquely (always redrawing the windows in each position.)
+If your Tk library linked to Ruby doesn't include a 'panedwindow', this demo doesn't work. Please use later version of Tk which supports a 'panedwindow'.
+EOL
+
+# The bottom buttons
+TkFrame.new(base_frame){|f|
+ pack(:side=>:bottom, :fill=>:x, :pady=>'2m')
+
+ TkButton.new(f, :text=>'Dismiss', :width=>15, :command=>proc{
+ $paned1_demo.destroy
+ $paned1_demo = nil
+ }).pack(:side=>:left, :expand=>true)
+
+ TkButton.new(f, :text=>'See Code', :width=>15, :command=>proc{
+ showCode 'paned1'
+ }).pack(:side=>:left, :expand=>true)
+}
+
+TkPanedwindow.new(base_frame, :orient=>:horizontal){|f|
+ add(Tk::Label.new(f, :text=>"This is the\nleft side", :bg=>'yellow'),
+ Tk::Label.new(f, :text=>"This is the\nright side", :bg=>'cyan'))
+
+ pack(:side=>:top, :expand=>true, :fill=>:both, :pady=>2, :padx=>'2m')
+}
diff --git a/jni/ruby/ext/tk/sample/demos-en/paned2.rb b/jni/ruby/ext/tk/sample/demos-en/paned2.rb
new file mode 100644
index 0000000..02293b0
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/demos-en/paned2.rb
@@ -0,0 +1,94 @@
+# paned2.rb --
+#
+# This demonstration script creates a toplevel window containing
+# a paned window that separates two windows vertically.
+#
+# based on "Id: paned2.tcl,v 1.1 2002/02/22 14:07:01 dkf Exp"
+
+if defined?($paned2_demo) && $paned2_demo
+ $paned2_demo.destroy
+ $paned2_demo = nil
+end
+
+$paned2_demo = TkToplevel.new {|w|
+ title("Vertical Paned Window Demonstration")
+ iconname("paned2")
+ positionWindow(w)
+}
+
+base_frame = TkFrame.new($paned2_demo).pack(:fill=>:both, :expand=>true)
+
+TkLabel.new(base_frame,
+ :font=>$font, :wraplength=>'4i', :justify=>:left,
+ :text=><<EOL).pack(:side=>:top)
+The sash between the two scrolled windows below can be used to divide the area between them. Use the left mouse button to resize without redrawing by just moving the sash, and use the middle mouse button to resize opaquely (always redrawing the windows in each position.)
+If your Tk library linked to Ruby doesn't include a 'panedwindow', this demo doesn't work. Please use later version of Tk which supports a 'panedwindow'.
+EOL
+
+# The bottom buttons
+TkFrame.new(base_frame){|f|
+ pack(:side=>:bottom, :fill=>:x, :pady=>'2m')
+
+ TkButton.new(f, :text=>'Dismiss', :width=>15, :command=>proc{
+ $paned2_demo.destroy
+ $paned2_demo = nil
+ }).pack(:side=>:left, :expand=>true)
+
+ TkButton.new(f, :text=>'See Code', :width=>15, :command=>proc{
+ showCode 'paned2'
+ }).pack(:side=>:left, :expand=>true)
+}
+
+paneList = TkVariable.new # define as normal variable (not array)
+paneList.value = [ # ruby's array --> tcl's list
+ 'List of Ruby/Tk Widgets',
+ 'TkButton',
+ 'TkCanvas',
+ 'TkCheckbutton',
+ 'TkEntry',
+ 'TkFrame',
+ 'TkLabel',
+ 'TkLabelframe',
+ 'TkListbox',
+ 'TkMenu',
+ 'TkMenubutton',
+ 'TkMessage',
+ 'TkPanedwindow',
+ 'TkRadiobutton',
+ 'TkScale',
+ 'TkScrollbar',
+ 'TkSpinbox',
+ 'TkText',
+ 'TkToplevel'
+]
+
+# Create the pane itself
+TkPanedwindow.new(base_frame, :orient=>:vertical){|f|
+ pack(:side=>:top, :expand=>true, :fill=>:both, :pady=>2, :padx=>'2m')
+
+ add(TkFrame.new(f){|paned2_top|
+ TkListbox.new(paned2_top, :listvariable=>paneList) {
+ # Invert the first item to highlight it
+ itemconfigure(0, :background=>self.cget(:foreground),
+ :foreground=>self.cget(:background) )
+ yscrollbar(TkScrollbar.new(paned2_top).pack(:side=>:right,
+ :fill=>:y))
+ pack(:fill=>:both, :expand=>true)
+ }
+ },
+
+ TkFrame.new(f, :height=>120) {|paned2_bottom|
+ # The bottom window is a text widget with scrollbar
+ paned2_xscr = TkScrollbar.new(paned2_bottom)
+ paned2_yscr = TkScrollbar.new(paned2_bottom)
+ paned2_text = TkText.new(paned2_bottom, :width=>30, :wrap=>:non) {
+ insert('1.0', "This is just a normal text widget")
+ xscrollbar(paned2_xscr)
+ yscrollbar(paned2_yscr)
+ }
+ Tk.grid(paned2_text, paned2_yscr, :sticky=>'nsew')
+ Tk.grid(paned2_xscr, :sticky=>'nsew')
+ TkGrid.columnconfigure(paned2_bottom, 0, :weight=>1)
+ TkGrid.rowconfigure(paned2_bottom, 0, :weight=>1)
+ } )
+}
diff --git a/jni/ruby/ext/tk/sample/demos-en/pendulum.rb b/jni/ruby/ext/tk/sample/demos-en/pendulum.rb
new file mode 100644
index 0000000..306ac94
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/demos-en/pendulum.rb
@@ -0,0 +1,240 @@
+#
+# This demonstration illustrates how Tcl/Tk can be used to construct
+# simulations of physical systems.
+# (called by 'widget')
+#
+# based on Tcl/Tk8.5a2 widget demos
+
+# destroy toplevel widget for this demo script
+if defined?($pendulum_demo) && $pendulum_demo
+ $pendulum_demo.destroy
+ $pendulum_demo = nil
+end
+
+# create toplevel widget
+$pendulum_demo = TkToplevel.new {|w|
+ title("Pendulum Animation Demonstration")
+ iconname("pendulum")
+ positionWindow(w)
+}
+
+base_frame = TkFrame.new($pendulum_demo).pack(:fill=>:both, :expand=>true)
+
+# create label
+msg = TkLabel.new(base_frame) {
+ font $font
+ wraplength '4i'
+ justify 'left'
+ text 'This demonstration shows how Ruby/Tk can be used to carry out animations that are linked to simulations of physical systems. In the left canvas is a graphical representation of the physical system itself, a simple pendulum, and in the right canvas is a graph of the phase space of the system, which is a plot of the angle (relative to the vertical) against the angular velocity. The pendulum bob may be repositioned by clicking and dragging anywhere on the left canvas.'
+}
+msg.pack('side'=>'top')
+
+# create frame
+TkFrame.new(base_frame) {|frame|
+ TkButton.new(frame) {
+ text 'Dismiss'
+ command proc{
+ tmppath = $pendulum_demo
+ $pendulum_demo = nil
+ tmppath.destroy
+ }
+ }.pack('side'=>'left', 'expand'=>'yes')
+
+ TkButton.new(frame) {
+ text 'See Code'
+ command proc{showCode 'pendulum'}
+ }.pack('side'=>'left', 'expand'=>'yes')
+
+}.pack('side'=>'bottom', 'fill'=>'x', 'pady'=>'2m')
+
+# animated wave
+class PendulumAnimationDemo
+ def initialize(frame)
+ # Create some structural widgets
+ @pane = TkPanedWindow.new(frame, :orient=>:horizontal).pack(:fill=>:both, :expand=>true)
+# @pane.add(@lf1 = TkLabelFrame.new(@pane, :text=>'Pendulum Simulation'))
+# @pane.add(@lf2 = TkLabelFrame.new(@pane, :text=>'Phase Space'))
+ @lf1 = TkLabelFrame.new(@pane, :text=>'Pendulum Simulation')
+ @lf2 = TkLabelFrame.new(@pane, :text=>'Phase Space')
+
+ # Create the canvas containing the graphical representation of the
+ # simulated system.
+ @c = TkCanvas.new(@lf1, :width=>320, :height=>200, :background=>'white',
+ :borderwidth=>2, :relief=>:sunken)
+ TkcText.new(@c, 5, 5, :anchor=>:nw,
+ :text=>'Click to Adjust Bob Start Position')
+ # Coordinates of these items don't matter; they will be set properly below
+ @plate = TkcLine.new(@c, 0, 25, 320, 25, :width=>2, :fill=>'grey50')
+ @rod = TkcLine.new(@c, 1, 1, 1, 1, :width=>3, :fill=>'black')
+ @bob = TkcOval.new(@c, 1, 1, 2, 2,
+ :width=>3, :fill=>'yellow', :outline=>'black')
+ TkcOval.new(@c, 155, 20, 165, 30, :fill=>'grey50', :outline=>'')
+
+ # pack
+ @c.pack(:fill=>:both, :expand=>true)
+
+ # Create the canvas containing the phase space graph; this consists of
+ # a line that gets gradually paler as it ages, which is an extremely
+ # effective visual trick.
+ @k = TkCanvas.new(@lf2, :width=>320, :height=>200, :background=>'white',
+ :borderwidth=>2, :relief=>:sunken)
+ @y_axis = TkcLine.new(@k, 160, 200, 160, 0, :fill=>'grey75', :arrow=>:last)
+ @x_axis = TkcLine.new(@k, 0, 100, 320, 100, :fill=>'grey75', :arrow=>:last)
+
+ @graph = {}
+ 90.step(0, -10){|i|
+ # Coordinates of these items don't matter;
+ # they will be set properly below
+ @graph[i] = TkcLine.new(@k, 0, 0, 1, 1, :smooth=>true, :fill=>"grey#{i}")
+ }
+
+ # labels
+ @label_theta = TkcText.new(@k, 0, 0, :anchor=>:ne,
+ :text=>'q', :font=>'Symbol 8')
+ @label_dtheta = TkcText.new(@k, 0, 0, :anchor=>:ne,
+ :text=>'dq', :font=>'Symbol 8')
+
+ # pack
+ @k.pack(:fill=>:both, :expand=>true)
+
+ # Initialize some variables
+ @points = []
+ @theta = 45.0
+ @dTheta = 0.0
+ @length = 150
+
+ # animation loop
+ @timer = TkTimer.new(15){ repeat }
+
+ # binding
+ @c.bindtags_unshift(btag = TkBindTag.new)
+ btag.bind('Destroy'){ @timer.stop }
+ btag.bind('1', proc{|x, y| @timer.stop; showPendulum(x.to_i, y.to_i)},
+ '%x %y')
+ btag.bind('B1-Motion', proc{|x, y| showPendulum(x.to_i, y.to_i)}, '%x %y')
+ btag.bind('ButtonRelease-1',
+ proc{|x, y| showPendulum(x.to_i, y.to_i); @timer.start },
+ '%x %y')
+
+ btag.bind('Configure', proc{|w| @plate.coords(0, 25, w.to_i, 25)}, '%w')
+
+ @k.bind('Configure', proc{|h, w|
+ h = h.to_i
+ w = w.to_i
+ @psh = h/2;
+ @psw = w/2
+ @x_axis.coords(2, @psh, w-2, @psh)
+ @y_axis.coords(@psw, h-2, @psw, 2)
+ @label_theta.coords(@psw-4, 6)
+ @label_dtheta.coords(w-6, @psh+4)
+ }, '%h %w')
+
+ # add
+ Tk.update
+ @pane.add(@lf1)
+ @pane.add(@lf2)
+
+ # init display
+ showPendulum
+
+ # animation start
+ @timer.start(500)
+ end
+
+ # This procedure makes the pendulum appear at the correct place on the
+ # canvas. If the additional arguments x, y are passed instead of computing
+ # the position of the pendulum from the length of the pendulum rod and its
+ # angle, the length and angle are computed in reverse from the given
+ # location (which is taken to be the centre of the pendulum bob.)
+ def showPendulum(x=nil, y=nil)
+ if x && y && (x != 160 || y != 25)
+ @dTheta = 0.0
+ x2 = x - 160
+ y2 = y - 25
+ @length = Math.hypot(x2, y2)
+ @theta = Math.atan2(x2,y2)*180/Math::PI
+ else
+ angle = @theta*Math::PI/180
+ x = 160 + @length*Math.sin(angle)
+ y = 25 + @length*Math.cos(angle)
+ end
+
+ @rod.coords(160, 25, x, y)
+ @bob.coords(x-15, y-15, x+15, y+15)
+ end
+
+ # Update the phase-space graph according to the current angle and the
+ # rate at which the angle is changing (the first derivative with
+ # respect to time.)
+ def showPhase
+ unless @psw && @psh
+ @psw = @k.width/2
+ @psh = @k.height/2
+ end
+ @points << @theta + @psw << -20*@dTheta + @psh
+ if @points.length > 100
+ @points = @points[-100..-1]
+ end
+ (0...100).step(10){|i|
+ first = - i
+ last = 11 - i
+ last = -1 if last >= 0
+ next if first > last
+ lst = @points[first..last]
+ @graph[i].coords(lst) if lst && lst.length >= 4
+ }
+ end
+
+ # This procedure is the "business" part of the simulation that does
+ # simple numerical integration of the formula for a simple rotational
+ # pendulum.
+ def recomputeAngle
+ scaling = 3000.0/@length/@length
+
+ # To estimate the integration accurately, we really need to
+ # compute the end-point of our time-step. But to do *that*, we
+ # need to estimate the integration accurately! So we try this
+ # technique, which is inaccurate, but better than doing it in a
+ # single step. What we really want is bound up in the
+ # differential equation:
+ # .. - sin theta
+ # theta + theta = -----------
+ # length
+ # But my math skills are not good enough to solve this!
+
+ # first estimate
+ firstDDTheta = -Math.sin(@theta * Math::PI/180) * scaling
+ midDTheta = @dTheta + firstDDTheta
+ midTheta = @theta + (@dTheta + midDTheta)/2
+ # second estimate
+ midDDTheta = -Math.sin(midTheta * Math::PI/180) * scaling
+ midDTheta = @dTheta + (firstDDTheta + midDDTheta)/2
+ midTheta = @theta + (@dTheta + midDTheta)/2
+ # Now we do a double-estimate approach for getting the final value
+ # first estimate
+ midDDTheta = -Math.sin(midTheta * Math::PI/180) * scaling
+ lastDTheta = midDTheta + midDDTheta
+ lastTheta = midTheta + (midDTheta+ lastDTheta)/2
+ # second estimate
+ lastDDTheta = -Math.sin(lastTheta * Math::PI/180) * scaling
+ lastDTheta = midDTheta + (midDDTheta + lastDDTheta)/2
+ lastTheta = midTheta + (midDTheta + lastDTheta)/2
+ # Now put the values back in our globals
+ @dTheta = lastDTheta
+ @theta = lastTheta
+ end
+
+ # This method ties together the simulation engine and the graphical
+ # display code that visualizes it.
+ def repeat
+ # Simulate
+ recomputeAngle
+
+ # Update the display
+ showPendulum
+ showPhase
+ end
+end
+
+# Start the animation processing
+PendulumAnimationDemo.new(base_frame)
diff --git a/jni/ruby/ext/tk/sample/demos-en/plot.rb b/jni/ruby/ext/tk/sample/demos-en/plot.rb
new file mode 100644
index 0000000..f70daa3
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/demos-en/plot.rb
@@ -0,0 +1,124 @@
+# plot.rb
+#
+# This demonstration script creates a canvas widget showing a 2-D
+# plot with data points that can be dragged with the mouse.
+#
+# 2-D plot widget demo (called by 'widget')
+#
+
+# toplevel widget
+if defined?($plot_demo) && $plot_demo
+ $plot_demo.destroy
+ $plot_demo = nil
+end
+
+# demo toplevel widget
+$plot_demo = TkToplevel.new {|w|
+ title("Plot Demonstration")
+ iconname("Plot")
+ positionWindow(w)
+}
+
+base_frame = TkFrame.new($plot_demo).pack(:fill=>:both, :expand=>true)
+
+# label
+TkLabel.new(base_frame, 'font'=>$font, 'wraplength'=>'4i', 'justify'=>'left',
+ 'text'=>"This window displays a canvas widget containing a simple 2-dimensional plot. You can doctor the data by dragging any of the points with mouse button 1."){
+ pack('side'=>'top')
+}
+
+# frame
+$plot_buttons = TkFrame.new(base_frame) {|frame|
+ TkButton.new(frame) {
+ text 'Dismiss'
+ command proc{
+ tmppath = $plot_demo
+ $plot_demo = nil
+ tmppath.destroy
+ }
+ }.pack('side'=>'left', 'expand'=>'yes')
+
+ TkButton.new(frame) {
+ text 'Show Code'
+ command proc{showCode 'plot'}
+ }.pack('side'=>'left', 'expand'=>'yes')
+}
+$plot_buttons.pack('side'=>'bottom', 'fill'=>'x', 'pady'=>'2m')
+
+# font
+plotFont = '-*-Helvetica-Medium-R-Normal--*-180-*-*-*-*-*-*'
+
+# canvas
+$plot_canvas = TkCanvas.new(base_frame,'relief'=>'raised','width'=>450,'height'=>300)
+$plot_canvas.pack('side'=>'top', 'fill'=>'x')
+
+# plot
+TkcLine.new($plot_canvas, 100, 250, 400, 250, 'width'=>2)
+TkcLine.new($plot_canvas, 100, 250, 100, 50, 'width'=>2)
+TkcText.new($plot_canvas, 225, 20,
+ 'text'=>"A Simple Plot", 'font'=>plotFont, 'fill'=>'brown')
+
+(0..10).each {|i|
+ x = 100 + (i * 30)
+ TkcLine.new($plot_canvas, x, 250, x, 245, 'width'=>2)
+ TkcText.new($plot_canvas, x, 254,
+ 'text'=>10*i, 'font'=>plotFont, 'anchor'=>'n')
+}
+(0..5).each {|i|
+ y = 250 - (i * 40)
+ TkcLine.new($plot_canvas, 100, y, 105, y, 'width'=>2)
+ TkcText.new($plot_canvas, 96, y,
+ 'text'=>"#{i*50}.0", 'font'=>plotFont, 'anchor'=>'e')
+}
+
+for xx, yy in [[12,56],[20,94],[33,98],[32,120],[61,180],[75,160],[98,223]]
+ x = 100 + (3*xx)
+ y = 250 - (4*yy)/5
+ item = TkcOval.new($plot_canvas, x-6, y-6, x+6, y+6,
+ 'width'=>1, 'outline'=>'black', 'fill'=>'SkyBlue2')
+ item.addtag 'point'
+end
+
+$plot_canvas.itembind('point', 'Any-Enter',
+ proc{$plot_canvas.itemconfigure 'current','fill','red'})
+$plot_canvas.itembind('point', 'Any-Leave',
+ proc{$plot_canvas.itemconfigure 'current','fill','SkyBlue2'})
+$plot_canvas.itembind('point', '1',
+ proc{|x,y| plotDown $plot_canvas,x,y}, "%x %y")
+$plot_canvas.itembind('point', 'ButtonRelease-1',
+ proc{$plot_canvas.dtag 'selected'})
+$plot_canvas.bind('B1-Motion',
+ proc{|x,y| plotMove $plot_canvas,x,y}, "%x %y")
+
+$plot = {'lastX'=>0, 'lastY'=>0}
+
+# plotDown --
+# This method is invoked when the mouse is pressed over one of the
+# data points. It sets up state to allow the point to be dragged.
+#
+# Arguments:
+# w - The canvas window.
+# x, y - The coordinates of the mouse press.
+
+def plotDown (w, x, y)
+ w.dtag 'selected'
+ w.addtag_withtag 'selected', 'current'
+ w.raise 'current'
+ $plot['lastX'] = x
+ $plot['lastY'] = y
+end
+
+# plotMove --
+# This method is invoked during mouse motion events. It drags the
+# current item.
+#
+# Arguments:
+# w - The canvas window.
+# x, y - The coordinates of the mouse.
+
+def plotMove (w, x, y)
+ w.move 'selected', x - $plot['lastX'], y - $plot['lastY']
+ $plot['lastX'] = x
+ $plot['lastY'] = y
+end
+
diff --git a/jni/ruby/ext/tk/sample/demos-en/puzzle.rb b/jni/ruby/ext/tk/sample/demos-en/puzzle.rb
new file mode 100644
index 0000000..f16414a
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/demos-en/puzzle.rb
@@ -0,0 +1,134 @@
+# puzzle.rb
+#
+# This demonstration script creates a 15-puzzle game using a collection
+# of buttons.
+#
+# widet demo 'puzzle' (called by 'widget')
+#
+
+# toplevel widget
+if defined?($puzzle_demo) && $puzzle_demo
+ $puzzle_demo.destroy
+ $puzzle_demo = nil
+end
+
+# demo toplevel widget
+$puzzle_demo = TkToplevel.new {|w|
+ title("15-Puzzle Demonstration")
+ iconname("15-Puzzle")
+ positionWindow(w)
+}
+
+base_frame = TkFrame.new($puzzle_demo).pack(:fill=>:both, :expand=>true)
+
+# label
+msg = TkLabel.new(base_frame) {
+ font $font
+ wraplength '4i'
+ justify 'left'
+ text "A 15-puzzle appears below as a collection of buttons. Click on any of the pieces next to the space, and that piece will slide over the space. Continue this until the pieces are arranged in numerical order from upper-left to lower-right."
+}
+msg.pack('side'=>'top')
+
+# frame
+TkFrame.new(base_frame) {|frame|
+ TkButton.new(frame) {
+ text 'Dismiss'
+ command proc{
+ tmppath = $puzzle_demo
+ $puzzle_demo = nil
+ tmppath.destroy
+ }
+ }.pack('side'=>'left', 'expand'=>'yes')
+
+ TkButton.new(frame) {
+ text 'Show Code'
+ command proc{showCode 'puzzle'}
+ }.pack('side'=>'left', 'expand'=>'yes')
+
+}.pack('side'=>'bottom', 'fill'=>'x', 'pady'=>'2m')
+
+# frame
+
+# Special trick: select a darker color for the space by creating a
+# scrollbar widget and using its trough color.
+begin
+ if Tk.windowingsystem() == 'aqua'
+ frameWidth = 168
+ frameHeight = 168
+ elsif Tk.default_widget_set == :Ttk
+ frameWidth = 148
+ frameHeight = 124
+ else
+ frameWidth = 120
+ frameHeight = 120
+ end
+rescue
+ frameWidth = 120
+ frameHeight = 120
+end
+
+# depend_on_button_width = true
+depend_on_button_width = false
+
+s = TkScrollbar.new(base_frame)
+base = TkFrame.new(base_frame) {
+ width frameWidth
+ height frameHeight
+ borderwidth 2
+ relief 'sunken'
+ bg s['troughcolor']
+}
+s.destroy
+base.pack('side'=>'top', 'padx'=>'1c', 'pady'=>'1c')
+
+def def_puzzleswitch_proc(w, num)
+ proc{puzzleSwitch w, num}
+end
+
+$xpos = {}
+$ypos = {}
+order = [3,1,6,2,5,7,15,13,4,11,8,9,14,10,12]
+(0..14).each{|i|
+ num = order[i]
+ $xpos[num] = (i % 4) * 0.25
+ $ypos[num] = (i / 4) * 0.25
+ TkButton.new(base) {|w|
+ relief 'raised'
+ text num
+ highlightthickness 0
+ command def_puzzleswitch_proc(w, num)
+ if depend_on_button_width && (w.winfo_reqwidth * 4 > base.width)
+ base.width = w.winfo_reqwidth * 4
+ end
+ }.place('relx'=>$xpos[num], 'rely'=>$ypos[num],
+ 'relwidth'=>0.25, 'relheight'=>0.25)
+}
+$xpos['space'] = 0.75
+$ypos['space'] = 0.75
+
+
+# puzzleSwitch --
+# This procedure is invoked when the user clicks on a particular button;
+# if the button is next to the empty space, it moves the button into the
+# empty space.
+
+def puzzleSwitch(w, num)
+ if ( ($ypos[num] >= ($ypos['space'] - 0.01)) \
+ && ($ypos[num] <= ($ypos['space'] + 0.01)) \
+ && ($xpos[num] >= ($xpos['space'] - 0.26)) \
+ && ($xpos[num] <= ($xpos['space'] + 0.26))) \
+ || (($xpos[num] >= ($xpos['space'] - 0.01)) \
+ && ($xpos[num] <= ($xpos['space'] + 0.01)) \
+ && ($ypos[num] >= ($ypos['space'] - 0.26)) \
+ && ($ypos[num] <= ($ypos['space'] + 0.26)))
+ tmp = $xpos['space']
+ $xpos['space'] = $xpos[num]
+ $xpos[num] = tmp
+ tmp = $ypos['space']
+ $ypos['space'] = $ypos[num]
+ $ypos[num] = tmp
+ w.place('relx'=>$xpos[num], 'rely'=>$ypos[num])
+ end
+end
+
diff --git a/jni/ruby/ext/tk/sample/demos-en/radio.rb b/jni/ruby/ext/tk/sample/demos-en/radio.rb
new file mode 100644
index 0000000..bde3150
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/demos-en/radio.rb
@@ -0,0 +1,86 @@
+# radio.rb
+#
+# This demonstration script creates a toplevel window containing
+# several radiobutton widgets.
+#
+# radiobutton widget demo (called by 'widget')
+#
+
+# toplevel widget
+if defined?($radio_demo) && $radio_demo
+ $radio_demo.destroy
+ $radio_demo = nil
+end
+
+# demo toplevel widget
+$radio_demo = TkToplevel.new {|w|
+ title("Radiobutton Demonstration")
+ iconname("radio")
+ positionWindow(w)
+}
+
+base_frame = TkFrame.new($radio_demo).pack(:fill=>:both, :expand=>true)
+
+# label
+msg = TkLabel.new(base_frame) {
+ font $font
+ wraplength '4i'
+ justify 'left'
+ text "Two groups of radiobuttons are displayed below. If you click on a button then the button will become selected exclusively among all the buttons in its group. A Tcl variable is associated with each group to indicate which of the group's buttons is selected. Click the \"See Variables\" button to see the current values of the variables."
+}
+msg.pack('side'=>'top')
+
+#
+size = TkVariable.new
+color = TkVariable.new
+
+# frame
+TkFrame.new(base_frame) {|frame|
+ TkButton.new(frame) {
+ text 'Dismiss'
+ command proc{
+ tmppath = $radio_demo
+ $radio_demo = nil
+ $showVarsWin[tmppath.path] = nil
+ tmppath.destroy
+ }
+ }.pack('side'=>'left', 'expand'=>'yes')
+
+ TkButton.new(frame) {
+ text 'Show Code'
+ command proc{showCode 'radio'}
+ }.pack('side'=>'left', 'expand'=>'yes')
+
+ TkButton.new(frame) {
+ text 'See Variables'
+ command proc{
+ showVars(base_frame, ['size', size], ['color', color])
+ }
+ }.pack('side'=>'left', 'expand'=>'yes')
+}.pack('side'=>'bottom', 'fill'=>'x', 'pady'=>'2m')
+
+# frame
+f_left = TkFrame.new(base_frame)
+f_right = TkFrame.new(base_frame)
+f_left.pack('side'=>'left', 'expand'=>'yes', 'padx'=>'.5c', 'pady'=>'.5c')
+f_right.pack('side'=>'left', 'expand'=>'yes', 'padx'=>'.5c', 'pady'=>'.5c')
+
+# radiobutton
+[10, 12, 18, 24].each {|sz|
+ TkRadioButton.new(f_left) {
+ text "Point Size #{sz}"
+ variable size
+ relief 'flat'
+ value sz
+ }.pack('side'=>'top', 'pady'=>2, 'anchor'=>'w')
+}
+
+['Red', 'Green', 'Blue', 'Yellow', 'Orange', 'Purple'].each {|col|
+ TkRadioButton.new(f_right) {
+ text col
+ variable color
+ relief 'flat'
+ value col.downcase
+ }.pack('side'=>'top', 'pady'=>2, 'anchor'=>'w')
+}
+
diff --git a/jni/ruby/ext/tk/sample/demos-en/radio2.rb b/jni/ruby/ext/tk/sample/demos-en/radio2.rb
new file mode 100644
index 0000000..72fc2c6
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/demos-en/radio2.rb
@@ -0,0 +1,109 @@
+# radio2.rb
+#
+# This demonstration script creates a toplevel window containing
+# several radiobutton widgets.
+#
+# radiobutton widget demo (called by 'widget')
+#
+
+# toplevel widget
+if defined?($radio2_demo) && $radio2_demo
+ $radio2_demo.destroy
+ $radio2_demo = nil
+end
+
+# demo toplevel widget
+$radio2_demo = TkToplevel.new {|w|
+ title("Radiobutton Demonstration 2")
+ iconname("radio2")
+ positionWindow(w)
+}
+
+base_frame = TkFrame.new($radio2_demo).pack(:fill=>:both, :expand=>true)
+
+# label
+msg = TkLabel.new(base_frame) {
+ font $font
+ wraplength '5i'
+ justify 'left'
+ text "Three groups of radiobuttons are displayed below. If you click on a button then the button will become selected exclusively among all the buttons in its group. A Tcl variable is associated with each group to indicate which of the group's buttons is selected. Click the \"See Variables\" button to see the current values of the variables."
+}
+msg.pack('side'=>'top')
+
+#
+size = TkVariable.new
+color = TkVariable.new
+align = TkVariable.new
+
+# frame
+TkFrame.new(base_frame) {|frame|
+ TkButton.new(frame) {
+ text 'Dismiss'
+ command proc{
+ tmppath = $radio2_demo
+ $radio2_demo = nil
+ $showVarsWin[tmppath.path] = nil
+ tmppath.destroy
+ }
+ }.pack('side'=>'left', 'expand'=>'yes')
+
+ TkButton.new(frame) {
+ text 'Show Code'
+ command proc{showCode 'radio2'}
+ }.pack('side'=>'left', 'expand'=>'yes')
+
+ TkButton.new(frame) {
+ text 'See Variables'
+ command proc{
+ showVars(base_frame,
+ ['size', size], ['color', color], ['compound', align])
+ }
+ }.pack('side'=>'left', 'expand'=>'yes')
+}.pack('side'=>'bottom', 'fill'=>'x', 'pady'=>'2m')
+
+# frame
+f_left = TkLabelFrame.new(base_frame, 'text'=>'Point Size',
+ 'pady'=>2, 'padx'=>2)
+f_mid = TkLabelFrame.new(base_frame, 'text'=>'Color',
+ 'pady'=>2, 'padx'=>2)
+f_right = TkLabelFrame.new(base_frame, 'text'=>'Alignment',
+ 'pady'=>2, 'padx'=>2)
+f_left.pack('side'=>'left', 'expand'=>'yes', 'padx'=>'.5c', 'pady'=>'.5c')
+f_mid.pack('side'=>'left', 'expand'=>'yes', 'padx'=>'.5c', 'pady'=>'.5c')
+f_right.pack('side'=>'left', 'expand'=>'yes', 'padx'=>'.5c', 'pady'=>'.5c')
+
+# radiobutton
+[10, 12, 18, 24].each {|sz|
+ TkRadioButton.new(f_left) {
+ text "Point Size #{sz}"
+ variable size
+ relief 'flat'
+ value sz
+ }.pack('side'=>'top', 'pady'=>2, 'anchor'=>'w', 'fill'=>'x')
+}
+
+['Red', 'Green', 'Blue', 'Yellow', 'Orange', 'Purple'].each {|col|
+ TkRadioButton.new(f_mid) {
+ text col
+ variable color
+ relief 'flat'
+ value col.downcase
+ anchor 'w'
+ }.pack('side'=>'top', 'pady'=>2, 'fill'=>'x')
+}
+
+# label = TkLabel.new(f_right, 'text'=>'Label', 'bitmap'=>'questhead',
+label = Tk::Label.new(f_right, 'text'=>'Label', 'bitmap'=>'questhead',
+ 'compound'=>'left')
+label.configure('width'=>TkWinfo.reqwidth(label), 'compound'=>'top')
+label.height(TkWinfo.reqheight(label))
+abtn = ['Top', 'Left', 'Right', 'Bottom'].collect{|a|
+ lower = a.downcase
+ TkRadioButton.new(f_right, 'text'=>a, 'variable'=>align, 'relief'=>'flat',
+ 'value'=>lower, 'indicatoron'=>0, 'width'=>7,
+ 'command'=>proc{label.compound(align.value)})
+}
+
+Tk.grid('x', abtn[0])
+Tk.grid(abtn[1], label, abtn[2])
+Tk.grid('x', abtn[3])
diff --git a/jni/ruby/ext/tk/sample/demos-en/radio3.rb b/jni/ruby/ext/tk/sample/demos-en/radio3.rb
new file mode 100644
index 0000000..8a147ed
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/demos-en/radio3.rb
@@ -0,0 +1,117 @@
+# radio3.rb
+#
+# This demonstration script creates a toplevel window containing
+# several radiobutton widgets.
+#
+# radiobutton widget demo (called by 'widget')
+#
+
+# toplevel widget
+if defined?($radio3_demo) && $radio3_demo
+ $radio3_demo.destroy
+ $radio3_demo = nil
+end
+
+# demo toplevel widget
+$radio3_demo = TkToplevel.new {|w|
+ title("Radiobutton Demonstration 3")
+ iconname("radio3")
+ positionWindow(w)
+}
+
+base_frame = TkFrame.new($radio3_demo).pack(:fill=>:both, :expand=>true)
+
+# label
+msg = TkLabel.new(base_frame) {
+ font $font
+ wraplength '5i'
+ justify 'left'
+ text "Three groups of radiobuttons are displayed below. If you click on a button then the button will become selected exclusively among all the buttons in its group. A Tcl variable is associated with each group to indicate which of the group's buttons is selected. When the 'Tristate' button is pressed, the radio buttons will display the tri-state mode. Selecting any radio button will return the buttons to their respective on/off state. Click the \"See Variables\" button to see the current values of the variables."
+}
+msg.grid(:row=>0, :column=>0, :columnspan=>3, :sticky=>'nsew')
+
+# variable
+size = TkVariable.new
+color = TkVariable.new
+align = TkVariable.new
+
+# frame
+TkFrame.new(base_frame) {|frame|
+ TkGrid(TkFrame.new(frame, :height=>2, :relief=>:sunken, :bd=>2),
+ :columnspan=>4, :row=>0, :sticky=>'ew', :pady=>2)
+ TkGrid('x',
+ TkButton.new(frame, :text=>'See Variables',
+ :image=>$image['view'], :compound=>:left,
+ :command=>proc{
+ showVars(base_frame, ['size', size],
+ ['color', color], ['compound', align])
+ }),
+ TkButton.new(frame, :text=>'See Code',
+ :image=>$image['view'], :compound=>:left,
+ :command=>proc{showCode 'radio3'}),
+ TkButton.new(frame, :text=>'Dismiss',
+ :image=>$image['delete'], :compound=>:left,
+ :command=>proc{
+ tmppath = $radio3_demo
+ $radio3_demo = nil
+ $showVarsWin[tmppath.path] = nil
+ tmppath.destroy
+ }),
+ :padx=>4, :pady=>4)
+ frame.grid_columnconfigure(0, :weight=>1)
+ TkGrid(frame, :row=>3, :column=>0, :columnspan=>3, :sticky=>'nsew')
+}
+
+# frame
+f_left = TkLabelFrame.new(base_frame, 'text'=>'Point Size',
+ 'pady'=>2, 'padx'=>2)
+f_mid = TkLabelFrame.new(base_frame, 'text'=>'Color',
+ 'pady'=>2, 'padx'=>2)
+f_right = TkLabelFrame.new(base_frame, 'text'=>'Alignment',
+ 'pady'=>2, 'padx'=>2)
+f_left .grid('column'=>0, 'row'=>1, 'pady'=>'.5c', 'padx'=>'.5c', 'rowspan'=>2)
+f_mid .grid('column'=>1, 'row'=>1, 'pady'=>'.5c', 'padx'=>'.5c', 'rowspan'=>2)
+f_right.grid('column'=>2, 'row'=>1, 'pady'=>'.5c', 'padx'=>'.5c')
+
+TkButton.new(base_frame, 'text'=>'Tristate',
+ 'command'=>proc{size.value = 'multi'; color.value = 'multi'}){
+ grid('column'=>2, 'row'=>2, 'pady'=>'.5c', 'padx'=>'.5c')
+}
+
+# radiobutton
+[10, 12, 14, 18, 24].each {|sz|
+ TkRadioButton.new(f_left) {
+ text "Point Size #{sz}"
+ variable size
+ relief 'flat'
+ value sz
+ tristatevalue 'multi'
+ }.pack('side'=>'top', 'pady'=>2, 'anchor'=>'w', 'fill'=>'x')
+}
+
+['Red', 'Green', 'Blue', 'Yellow', 'Orange', 'Purple'].each {|col|
+ TkRadioButton.new(f_mid) {
+ text col
+ variable color
+ relief 'flat'
+ value col.downcase
+ anchor 'w'
+ tristatevalue 'multi'
+ command proc{f_mid.fg(color.value)}
+ }.pack('side'=>'top', 'pady'=>2, 'fill'=>'x')
+}
+
+# label = TkLabel.new(f_right, 'text'=>'Label', 'bitmap'=>'questhead',
+label = Tk::Label.new(f_right, 'text'=>'Label', 'bitmap'=>'questhead',
+ 'compound'=>'left')
+label.configure('width'=>TkWinfo.reqwidth(label), 'compound'=>'top')
+label.height(TkWinfo.reqheight(label))
+a_btn = ['Top', 'Left', 'Right', 'Bottom'].collect{|a|
+ TkRadioButton.new(f_right, 'text'=>a, 'variable'=>align, 'relief'=>'flat',
+ 'value'=>a.downcase, 'indicatoron'=>0, 'width'=>7,
+ 'command'=>proc{label.compound(align.value)})
+}
+
+Tk.grid('x', a_btn[0])
+Tk.grid(a_btn[1], label, a_btn[2])
+Tk.grid('x', a_btn[3])
diff --git a/jni/ruby/ext/tk/sample/demos-en/rmt b/jni/ruby/ext/tk/sample/demos-en/rmt
new file mode 100644
index 0000000..dcfb328
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/demos-en/rmt
@@ -0,0 +1,268 @@
+#!/usr/bin/env ruby
+
+# rmt --
+# This script implements a simple remote-control mechanism for
+# Tk applications. It allows you to select an application and
+# then type commands to that application.
+
+require 'tk'
+
+class Rmt
+ def initialize(parent=nil)
+ win = self
+
+ unless parent
+ parent = TkRoot.new
+ end
+ root = TkWinfo.toplevel(parent)
+ root.minsize(1,1)
+
+ # The instance variable below keeps track of the remote application
+ # that we're sending to. If it's an empty string then we execute
+ # the commands locally.
+ @app = 'local'
+ @mode = 'Ruby'
+
+ # The instance variable below keeps track of whether we're in the
+ # middle of executing a command entered via the text.
+ @executing = 0
+
+ # The instance variable below keeps track of the last command executed,
+ # so it can be re-executed in response to !! commands.
+ @lastCommand = ""
+
+ # Create menu bar. Arrange to recreate all the information in the
+ # applications sub-menu whenever it is cascaded to.
+
+ TkFrame.new(root, 'relief'=>'raised', 'bd'=>2) {|f|
+ pack('side'=>'top', 'fill'=>'x')
+ TkMenubutton.new(f, 'text'=>'File', 'underline'=>0) {|mb|
+ TkMenu.new(mb) {|mf|
+ mb.menu(mf)
+ TkMenu.new(mf) {|ma|
+ postcommand proc{win.fillAppsMenu ma}
+ mf.add('cascade', 'label'=>'Select Application',
+ 'menu'=>ma, 'underline'=>0)
+ }
+ add('command', 'label'=>'Quit',
+ 'command'=>proc{root.destroy}, 'underline'=>0)
+ }
+ pack('side'=>'left')
+ }
+ }
+
+ # Create text window and scrollbar.
+
+ @txt = TkText.new(root, 'relief'=>'sunken', 'bd'=>2, 'setgrid'=>true) {
+ yscrollbar(TkScrollbar.new(root){pack('side'=>'right', 'fill'=>'y')})
+ pack('side'=>'left')
+ }
+
+ @promptEnd = TkTextMark.new(@txt, 'insert')
+
+ # Create a binding to forward commands to the target application,
+ # plus modify many of the built-in bindings so that only information
+ # in the current command can be deleted (can still set the cursor
+ # earlier in the text and select and insert; just can't delete).
+
+ @txt.bindtags([@txt, TkText, root, 'all'])
+ @txt.bind('Return', proc{
+ @txt.set_insert('end - 1c')
+ @txt.insert('insert', "\n")
+ win.invoke
+ Tk.callback_break
+ })
+ @txt.bind('Delete', proc{
+ begin
+ @txt.tag_remove('sel', 'sel.first', @promptEnd)
+ rescue
+ end
+ if @txt.tag_nextrange('sel', '1.0', 'end') == []
+ if @txt.compare('insert', '<', @promptEnd)
+ Tk.callback_break
+ end
+ end
+ })
+ @txt.bind('BackSpace', proc{
+ begin
+ @txt.tag_remove('sel', 'sel.first', @promptEnd)
+ rescue
+ end
+ if @txt.tag_nextrange('sel', '1.0', 'end') == []
+ if @txt.compare('insert', '<', @promptEnd)
+ Tk.callback_break
+ end
+ end
+ })
+ @txt.bind('Control-d', proc{
+ if @txt.compare('insert', '<', @promptEnd)
+ Tk.callback_break
+ end
+ })
+ @txt.bind('Control-k', proc{
+ if @txt.compare('insert', '<', @promptEnd)
+ @txt.set_insert(@promptEnd)
+ end
+ })
+ @txt.bind('Control-t', proc{
+ if @txt.compare('insert', '<', @promptEnd)
+ Tk.callback_break
+ end
+ })
+ @txt.bind('Meta-d', proc{
+ if @txt.compare('insert', '<', @promptEnd)
+ Tk.callback_break
+ end
+ })
+ @txt.bind('Meta-BackSpace', proc{
+ if @txt.compare('insert', '<=', @promptEnd)
+ Tk.callback_break
+ end
+ })
+ @txt.bind('Control-h', proc{
+ if @txt.compare('insert', '<=', @promptEnd)
+ Tk.callback_break
+ end
+ })
+
+ @txt.tag_configure('bold', 'font'=>['Courier', 12, 'bold'])
+
+ @app = Tk.appname('rmt')
+ if (@app =~ /^rmt(.*)$/)
+ root.title("Tk Remote Controller#{$1}")
+ root.iconname("Tk Remote#{$1}")
+ end
+ prompt
+ @txt.focus
+ #@app = TkWinfo.appname(TkRoot.new)
+ end
+
+ def tkTextInsert(w,s)
+ return if s == ""
+ begin
+ if w.compare('sel.first','<=','insert') \
+ && w.compare('sel.last','>=','insert')
+ w.tag_remove('sel', 'sel.first', @promptEnd)
+ w.delete('sel.first', 'sel.last')
+ end
+ rescue
+ end
+ w.insert('insert', s)
+ w.see('insert')
+ end
+
+ # The method below is used to print out a prompt at the
+ # insertion point (which should be at the beginning of a line
+ # right now).
+
+ def prompt
+ @txt.insert('insert', "#{@app}: ")
+ @promptEnd.set('insert')
+ @promptEnd.gravity = 'left'
+ @txt.tag_add('bold', "#{@promptEnd.path} linestart", @promptEnd)
+ end
+
+ # The method below executes a command (it takes everything on the
+ # current line after the prompt and either sends it to the remote
+ # application or executes it locally, depending on "app".
+
+ def invoke
+ cmd = @txt.get(@promptEnd, 'insert')
+ @executing += 1
+ case (@mode)
+ when 'Tcl'
+ if Tk.info('complete', cmd)
+ if (cmd == "!!\n")
+ cmd = @lastCommand
+ else
+ @lastCommand = cmd
+ end
+ begin
+ msg = Tk.appsend(@app, false, cmd)
+ rescue
+ msg = "Error: #{$!}"
+ end
+ @txt.insert('insert', msg + "\n") if msg != ""
+ prompt
+ @promptEnd.set('insert')
+ end
+
+ when 'Ruby'
+ if (cmd == "!!\n")
+ cmd = @lastCommand
+ end
+ complete = true
+ begin
+ eval("proc{#{cmd}}")
+ rescue
+ complete = false
+ end
+ if complete
+ @lastCommand = cmd
+ begin
+# msg = Tk.appsend(@app, false,
+# 'ruby',
+# '"(' + cmd.gsub(/[][$"]/, '\\\\\&') + ').to_s"')
+ msg = Tk.rb_appsend(@app, false, cmd)
+ rescue
+ msg = "Error: #{$!}"
+ end
+ @txt.insert('insert', msg + "\n") if msg != ""
+ prompt
+ @promptEnd.set('insert')
+ end
+ end
+
+ @executing -= 1
+ @txt.yview_pickplace('insert')
+ end
+
+ # The following method is invoked to change the application that
+ # we're talking to. It also updates the prompt for the current
+ # command, unless we're in the middle of executing a command from
+ # the text item (in which case a new prompt is about to be output
+ # so there's no need to change the old one).
+
+ def newApp(appName, mode)
+ @app = appName
+ @mode = mode
+ if @executing == 0
+ @promptEnd.gravity = 'right'
+ @txt.delete("#{@promptEnd.path} linestart", @promptEnd)
+ @txt.insert(@promptEnd, "#{appName}: ")
+ @txt.tag_add('bold', "#{@promptEnd.path} linestart", @promptEnd)
+ @promptEnd.gravity = 'left'
+ end
+ end
+
+ # The method below will fill in the applications sub-menu with a list
+ # of all the applications that currently exist.
+
+ def fillAppsMenu(menu)
+ win = self
+ begin
+ menu.delete(0,'last')
+ rescue
+ end
+ TkWinfo.interps.sort.each{|ip|
+ begin
+ if Tk.appsend(ip, false, 'info commands ruby') == ""
+ mode = 'Tcl'
+ else
+ mode = 'Ruby'
+ end
+ menu.add('command', 'label'=>format("%s (#{mode}/Tk)", ip),
+ 'command'=>proc{win.newApp ip, mode})
+ rescue
+ menu.add('command', 'label'=>format("%s (unknown Tk)", ip),
+ 'command'=>proc{win.newApp ip, mode}, 'state'=>'disabled')
+ end
+ }
+ menu.add('command', 'label'=>format("local (Ruby/Tk)"),
+ 'command'=>proc{win.newApp 'local', 'Ruby'})
+ end
+end
+
+Rmt.new
+
+Tk.mainloop
diff --git a/jni/ruby/ext/tk/sample/demos-en/rolodex b/jni/ruby/ext/tk/sample/demos-en/rolodex
new file mode 100644
index 0000000..dfc4b2b
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/demos-en/rolodex
@@ -0,0 +1,320 @@
+#!/usr/bin/env ruby
+#
+# rolodex --
+# This script is a part of Tom LaStrange's rolodex
+#
+# Copyright (C) 1998 by Takaaki Tateishi <ttate@jaist.ac.jp>
+# Time-stamp: "03/08/02 06:23:06 nagai"
+#
+
+require "tk"
+
+
+def show_help(topic,x=0,y=0)
+ if( topic.is_a?(TkWindow) )
+ w = TkWinfo.containing(x,y)
+ if( TkWinfo.exist?(w) )
+ topic = w
+ end
+ end
+
+ if( $helpTopics.include?(topic) )
+ msg = $helpTopics[topic]
+ else
+ msg = "Sorry, but no help is available for this topic"
+ end
+ TkDialog.new("title"=>"Rolodex Help",
+ "message"=>"Information on #{topic}:\n\n#{msg}",
+ "default_button"=>0,
+ "buttons"=>["OK"])
+end
+
+def fillCard
+ clearAction
+ $root.frame.entry[1].insert(0,"Takaaki Tateishi")
+ $root.frame.entry[2].insert(0,"Japan Advanced Institute of Science and Techonology")
+ $root.frame.entry[3].insert(0,"1-1 Asahidai, Tatsunokuchi")
+ $root.frame.entry[4].insert(0,"Ishikawa 923-1292, Japan")
+ $root.frame.entry[5].insert(0,"private")
+ $root.frame.entry[6].insert(0,"***-***-****")
+ $root.frame.entry[7].insert(0,"***-***-****")
+end
+
+def addAction
+ for i in 1..7
+ STDERR.print format("%-12s %s\n",
+ RolodexFrame::LABEL[i],
+ $root.frame.entry[i].value)
+ end
+end
+
+def clearAction
+ for i in 1..7
+ $root.frame.entry[i].delete(0,"end")
+ end
+end
+
+def fileAction
+ TkDialog.new("title"=>"File Selection",
+ "message"=>"This is a dummy file selection dialog box.\n",
+ "default_button"=>0,
+ "buttons"=>["OK"])
+ STDERR.print "dummy file name\n"
+end
+
+def deleteAction
+ result = TkDialog.new("title"=>"Confirm Action",
+ "message"=>"Are you sure?",
+ "default_button"=>0,
+ "buttons"=>["Cancel"])
+ if( result.value == 0 )
+ clearAction
+ end
+end
+
+
+class RolodexFrame < TkFrame
+ attr_reader :entry, :label
+
+ LABEL = ["","Name:","Address:","","","Home Phone:","Work Phone:","Fax:"]
+
+ def initialize(parent=nil,keys=nil)
+ super(parent,keys)
+ self["relief"] = "flat"
+
+ @i = []
+ @label = []
+ @entry = []
+ for i in 1..7
+ @i[i] = TkFrame.new(self)
+ @i[i].pack("side"=>"top",
+ "pady"=>2,
+ "anchor"=>"e")
+ @label[i] = TkLabel.new(@i[i],
+ "text"=>LABEL[i],
+ "anchor"=>"e")
+ @entry[i] = TkEntry.new(@i[i],
+ "width"=>30,
+ "relief"=>"sunken")
+ @entry[i].pack("side"=>"right")
+ @label[i].pack("side"=>"right")
+ end
+ end
+end
+
+class RolodexButtons < TkFrame
+ attr_reader :clear, :add, :search, :delete
+
+ def initialize(parent,keys=nil)
+ super(parent,keys)
+ @clear = TkButton.new(self,
+ "text" => "Clear")
+ @add = TkButton.new(self,
+ "text" => "Add")
+ @search = TkButton.new(self,
+ "text" => "Search")
+ @delete = TkButton.new(self,
+ "text" => "Delete")
+ for w in [@clear,@add,@search,@delete]
+ w.pack("side"=>"left", "padx"=>2)
+ end
+ end
+end
+
+class RolodexMenuFrame < TkFrame
+ attr_reader :file_menu, :help_menu, :file, :help
+
+ def initialize(parent,keys=nil)
+ super(parent,keys)
+ configure("relief"=>"raised",
+ "borderwidth"=>1)
+
+ @file = TkMenubutton.new(self,
+ "text"=>"File",
+ "underline"=>0)
+ @file_menu = TkMenu.new(@file)
+ @file_menu.add("command",
+ "label" => "Load ...",
+ "command" => proc{fileAction},
+ "underline" => 0)
+ @file_menu.add("command",
+ "label" => "Exit",
+ "command" => proc{$root.destroy},
+ "underline" => 0)
+ @file.menu(@file_menu)
+ @file.pack("side"=>"left")
+
+ @help = TkMenubutton.new(self,
+ "text"=>"Help",
+ "underline"=>0)
+ @help_menu = TkMenu.new(@help)
+ @help_menu.add("command",
+ "label"=>"On Context...",
+ "command"=>proc{show_help("context")},
+ "underline"=>3)
+ @help_menu.add("command",
+ "label"=>"On Help...",
+ "command"=>proc{show_help("help")},
+ "underline"=>3)
+ @help_menu.add("command",
+ "label"=>"On Window...",
+ "command"=>proc{show_help("window")},
+ "underline"=>3)
+ @help_menu.add("command",
+ "label"=>"On Keys...",
+ "command"=>proc{show_help("keys")},
+ "underline"=>3)
+ @help_menu.add("command",
+ "label"=>"On version...",
+ "command"=>proc{show_help("version")},
+ "underline"=>3)
+ @help.menu(@help_menu)
+ @help.pack("side"=>"right")
+ end
+end
+
+class Rolodex < TkRoot
+ attr_reader :frame, :buttons, :menu
+
+ def initialize(*args)
+ super(*args)
+ @frame = RolodexFrame.new(self)
+ @frame.pack("side"=>"top",
+ "fill"=>"y",
+ "anchor"=>"center")
+ @buttons = RolodexButtons.new(self)
+ @buttons.pack("side"=>"bottom",
+ "pady"=>2,
+ "anchor"=>"center")
+ @menu = RolodexMenuFrame.new(self)
+ @menu.pack("before"=>@frame,
+ "side"=>"top",
+ "fill"=>"x")
+ end
+end
+
+$root = Rolodex.new
+
+$root.buttons.delete.configure("command"=>proc{deleteAction})
+$root.buttons.add.configure("command"=>proc{addAction})
+$root.buttons.clear.configure("command"=>proc{clearAction})
+$root.buttons.search.configure("command"=>proc{addAction; fillCard})
+
+$root.buttons.clear.configure("text"=>"Clear Ctrl+C")
+$root.bind("Control-c",proc{clearAction})
+
+$root.buttons.add.configure("text"=>"Add Ctrl+A")
+$root.bind("Control-a",proc{addAction})
+
+$root.buttons.search.configure("text"=>"Search Ctrl+S")
+$root.bind("Control-s",proc{addAction; fillCard})
+
+$root.buttons.delete.configure("text"=>"Delete... Ctrl+D")
+$root.bind("Control-d",proc{deleteAction})
+
+$root.menu.file_menu.entryconfigure(1, "accel"=>"Ctrl+F")
+$root.bind("Control-f",proc{fileAction})
+
+$root.menu.file_menu.entryconfigure(2, "accel"=>"Ctrl+Q")
+$root.bind("Control-q",proc{$root.destroy})
+
+$root.frame.entry[1].focus
+
+$root.bind("Any-F1",
+ proc{|event| show_help(event.widget, event.x_root, event.y_root)})
+$root.bind("Any-Help",
+ proc{|event| show_help(event.widget, event.x_root, event.y_root)})
+
+
+$helpTopics = {}
+
+$helpTopics[$root.menu.file] = <<EOF
+This is the "file" menu. It can be used to invoke\
+some overall operations on the rolodex applications,\
+such as loading a file or exiting.
+EOF
+
+$helpTopics[$root.menu.file_menu.index(0)] = <<EOF
+The "Load" entry in the "File" menu posts a dialog box\
+that you can use to select a rolodex file
+EOF
+
+$helpTopics[$root.menu.file_menu.index(1)] = <<EOF
+The "Exit" entry in the "File" menu causes the rolodex\
+application to terminate
+EOF
+
+$helpTopics[$root.frame.entry[1]] = <<EOF
+In this field of the rolodex entry you should\
+type the person's name
+EOF
+
+$helpTopics[$root.frame.entry[2]] = <<EOF
+In this field of the rolodex entry you should\
+type the first line of the person's address
+EOF
+
+$helpTopics[$root.frame.entry[3]] = <<EOF
+In this field of the rolodex entry you should\
+type the second line of the person's address
+EOF
+
+$helpTopics[$root.frame.entry[4]] = <<EOF
+In this field of the rolodex entry you should\
+type the third line of the person's address
+EOF
+
+$helpTopics[$root.frame.entry[5]] = <<EOF
+In this field of the rolodex entry you should\
+type the person's home phone number, or "private"\
+if the person doesn't want his or he number publicized
+EOF
+
+$helpTopics[$root.frame.entry[6]] = <<EOF
+In this field of the rolodex entry you should\
+type the person's work phone number
+EOF
+
+$helpTopics[$root.frame.entry[7]] = <<EOF
+In this field of the rolodex entry you should\
+type the phone number for the person's FAX machine
+EOF
+
+$helpTopics["context"] = <<EOF
+Unfortunately, this application doesn't support context-sensitive\
+help in the usual way, because when this demo was written Ruby/Tk\
+didn't have a grab mechanism and this is needed for context-sensitive\
+help. Instead, you can achive much the same effect by simply moving\
+the mouse over the window you're curious about and pressing the\
+Help or F1 keys. You can do this anytime.
+EOF
+
+$helpTopics["help"] = <<EOF
+This application provides only very crude help. Besides the\
+entries in this menu, you can get help on individual windows\
+by moving the mouse cursor over the window and pressing the\
+Help or F1 keys.
+EOF
+
+$helpTopics["window"] = <<EOF
+This window is a dummy rolodex application created as part of\
+Tom LaStrange's toolkit benchmark. It doesn't really do anything\
+useful except to demonstrate a few features of the Ruby/Tk.
+EOF
+
+$helpTopics["keys"] = <<EOF
+The following accelerator keys are defined for this application\
+(in addition to those already available for the entry windows):
+Ctrl+A: Add
+Ctrl+C: Clear
+Ctrl+D: Delete
+Ctrl+F: Enter file name
+Ctrl+Q: Exit application (quit)
+Ctrl+S: Search (dummy operation)
+EOF
+
+$helpTopics["version"] = <<EOF
+This is version 1.0.1.
+EOF
+
+Tk.mainloop
diff --git a/jni/ruby/ext/tk/sample/demos-en/ruler.rb b/jni/ruby/ext/tk/sample/demos-en/ruler.rb
new file mode 100644
index 0000000..a977369
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/demos-en/ruler.rb
@@ -0,0 +1,205 @@
+# ruler.rb
+#
+# This demonstration script creates a canvas widget that displays a ruler
+# with tab stops that can be set, moved, and deleted.
+#
+# ruler widget demo (called by 'widget')
+#
+
+# rulerMkTab --
+# This method creates a new triangular polygon in a canvas to
+# represent a tab stop.
+#
+# Arguments:
+# c - The canvas window.
+# x, y - Coordinates at which to create the tab stop.
+
+def rulerMkTab(c,x,y)
+ v = $demo_rulerInfo
+ TkcPolygon.new(c, x, y, x+v.size, y+v.size, x-v.size, y+v.size)
+end
+
+# toplevel widget
+if defined?($ruler_demo) && $ruler_demo
+ $ruler_demo.destroy
+ $ruler_demo = nil
+end
+
+# demo toplevel widget
+$ruler_demo = TkToplevel.new {|w|
+ title("Ruler Demonstration")
+ iconname("ruler")
+ positionWindow(w)
+}
+
+base_frame = TkFrame.new($ruler_demo).pack(:fill=>:both, :expand=>true)
+
+# label
+TkLabel.new(base_frame, 'font'=>$font, 'wraplength'=>'5i', 'justify'=>'left',
+ 'text'=>"This canvas widget shows a mock-up of a ruler. You can create tab stops by dragging them out of the well to the right of the ruler. You can also drag existing tab stops. If you drag a tab stop far enough up or down so that it turns dim, it will be deleted when you release the mouse button."){
+ pack('side'=>'top')
+}
+
+# frame
+$ruler_buttons = TkFrame.new(base_frame) {|frame|
+ TkButton.new(frame) {
+ text 'Dismiss'
+ command proc{
+ tmppath = $ruler_demo
+ $ruler_demo = nil
+ tmppath.destroy
+ }
+ }.pack('side'=>'left', 'expand'=>'yes')
+
+ TkButton.new(frame) {
+ text 'Show Code'
+ command proc{showCode 'ruler'}
+ }.pack('side'=>'left', 'expand'=>'yes')
+}
+$ruler_buttons.pack('side'=>'bottom', 'fill'=>'x', 'pady'=>'2m')
+
+# canvas
+$ruler_canvas = TkCanvas.new(base_frame, 'width'=>'14.8c', 'height'=>'2.5c')
+$ruler_canvas.pack('side'=>'top', 'fill'=>'x')
+
+#
+unless Struct.const_defined?("RulerInfo")
+ $demo_rulerInfo = Struct.new("RulerInfo", :grid, :left, :right, :x, :y,
+ :top, :bottom, :size, :normalStyle,
+ :activeStyle, :deleteStyle).new
+end
+$demo_rulerInfo.grid = '.25c'
+$demo_rulerInfo.left = TkWinfo.fpixels($ruler_canvas, '1c')
+$demo_rulerInfo.right = TkWinfo.fpixels($ruler_canvas, '13c')
+$demo_rulerInfo.top = TkWinfo.fpixels($ruler_canvas, '1c')
+$demo_rulerInfo.bottom = TkWinfo.fpixels($ruler_canvas, '1.5c')
+$demo_rulerInfo.size = TkWinfo.fpixels($ruler_canvas, '.2c')
+$demo_rulerInfo.normalStyle = {'fill'=>'black'}
+if TkWinfo.depth($ruler_canvas) > 1
+ $demo_rulerInfo.activeStyle = {'fill'=>'red', 'stipple'=>''}
+ $demo_rulerInfo.deleteStyle = {'fill'=>'red',
+ 'stipple'=>'@'+[$demo_dir, '..',
+ 'images', 'gray25.xbm'].join(File::Separator)}
+else
+ $demo_rulerInfo.activeStyle = {'fill'=>'black', 'stipple'=>''}
+ $demo_rulerInfo.deleteStyle = {'fill'=>'black',
+ 'stipple'=>'@'+[$demo_dir, '..',
+ 'images', 'gray25.xbm'].join(File::Separator)}
+end
+
+TkcLine.new($ruler_canvas,
+ '1c', '0.5c', '1c', '1c', '13c', '1c', '13c', '0.5c', 'width'=>1)
+(0..11).each{|i|
+ x = i+1
+ TkcLine.new($ruler_canvas, "#{x}c", '1c', "#{x}c", '0.6c', 'width'=>1)
+ TkcLine.new($ruler_canvas, "#{x}.25c", '1c', "#{x}.25c", '0.8c', 'width'=>1)
+ TkcLine.new($ruler_canvas, "#{x}.5c", '1c', "#{x}.5c", '0.7c', 'width'=>1)
+ TkcLine.new($ruler_canvas, "#{x}.75c", '1c', "#{x}.75c", '0.8c', 'width'=>1)
+ TkcText.new($ruler_canvas, "#{x}.15c", '0.75c', 'text'=>i, 'anchor'=>'sw')
+}
+
+$rulerTag_well = TkcTag.new($ruler_canvas)
+$ruler_canvas\
+.addtag_withtag($rulerTag_well,
+ TkcRectangle.new($ruler_canvas,
+ '13.2c', '1c', '13.8c', '0.5c',
+ 'outline'=>'black',
+ 'fill'=>($ruler_canvas\
+ .configinfo('background'))[4]) )
+$ruler_canvas\
+.addtag_withtag($rulerTag_well,
+ rulerMkTab($ruler_canvas,
+ TkWinfo.pixels($ruler_canvas, '13.5c'),
+ TkWinfo.pixels($ruler_canvas, '.65c') ) )
+
+$rulerTag_well.bind('1', proc{|x,y| rulerNewTab($ruler_canvas,x,y)}, '%x %y')
+$ruler_canvas.itembind('tab', '1',
+ proc{|x,y| rulerSelectTab($ruler_canvas,x,y)}, '%x %y')
+$ruler_canvas.bind('B1-Motion',
+ proc{|x,y| rulerMoveTab($ruler_canvas,x,y)}, '%x %y')
+$ruler_canvas.bind('Any-ButtonRelease-1', proc{rulerReleaseTab($ruler_canvas)})
+
+# rulerNewTab --
+# Does all the work of creating a tab stop, including creating the
+# triangle object and adding tags to it to give it tab behavior.
+#
+# Arguments:
+# c - The canvas window.
+# x, y - The coordinates of the tab stop.
+
+def rulerNewTab(c,x,y)
+ v = $demo_rulerInfo
+ c.addtag_withtag('active', rulerMkTab(c,x,y))
+ c.addtag_withtag('tab', 'active')
+ v.x = x
+ v.y = y
+ rulerMoveTab(c,x,y)
+end
+
+# rulerSelectTab --
+# This method is invoked when mouse button 1 is pressed over
+# a tab. It remembers information about the tab so that it can
+# be dragged interactively.
+#
+# Arguments:
+# c - The canvas widget.
+# x, y - The coordinates of the mouse (identifies the point by
+# which the tab was picked up for dragging).
+
+def rulerSelectTab(c,x,y)
+ v = $demo_rulerInfo
+ v.x = c.canvasx(x, v.grid)
+ v.y = v.top+2
+ c.addtag_withtag('active', 'current')
+ c.itemconfigure('active', v.activeStyle)
+ c.raise('active')
+end
+
+# rulerMoveTab --
+# This method is invoked during mouse motion events to drag a tab.
+# It adjusts the position of the tab, and changes its appearance if
+# it is about to be dragged out of the ruler.
+#
+# Arguments:
+# c - The canvas widget.
+# x, y - The coordinates of the mouse.
+
+def rulerMoveTab(c,x,y)
+ v = $demo_rulerInfo
+ return if c.find_withtag('active') == []
+ cx = c.canvasx(x,v.grid)
+ cy = c.canvasy(y)
+ cx = v.left if cx < v.left
+ cx = v.right if cx > v.right
+ if (cy >= v.top && cy <= v.bottom)
+ cy = v.top+2
+ c.itemconfigure('active', v.activeStyle)
+ else
+ cy = cy-v.size-2
+ c.itemconfigure('active', v.deleteStyle)
+ end
+ c.move('active', cx-v.x, cy-v.y)
+ v.x = cx
+ v.y = cy
+end
+
+# rulerReleaseTab --
+# This method is invoked during button release events that end
+# a tab drag operation. It deselects the tab and deletes the tab if
+# it was dragged out of the ruler.
+#
+# Arguments:
+# c - The canvas widget.
+# x, y - The coordinates of the mouse.
+
+def rulerReleaseTab(c)
+ v = $demo_rulerInfo
+ return if c.find_withtag('active') == []
+ if v.y != v.top+2
+ c.delete('active')
+ else
+ c.itemconfigure('active', v.normalStyle)
+ c.dtag('active')
+ end
+end
+
diff --git a/jni/ruby/ext/tk/sample/demos-en/sayings.rb b/jni/ruby/ext/tk/sample/demos-en/sayings.rb
new file mode 100644
index 0000000..a4dcf37
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/demos-en/sayings.rb
@@ -0,0 +1,106 @@
+# sayings.rb
+#
+# This demonstration script creates a listbox that can be scrolled
+# both horizontally and vertically. It displays a collection of
+# well-known sayings.
+#
+# listbox widget demo 'sayings' (called by 'widget')
+#
+
+# toplevel widget
+if defined?($sayings_demo) && $sayings_demo
+ $sayings_demo.destroy
+ $sayings_demo = nil
+end
+
+# demo toplevel widget
+$sayings_demo = TkToplevel.new {|w|
+ title("Listbox Demonstration (well-known sayings)")
+ iconname("sayings")
+ positionWindow(w)
+}
+
+base_frame = TkFrame.new($sayings_demo).pack(:fill=>:both, :expand=>true)
+
+# label
+msg = TkLabel.new(base_frame) {
+ font $font
+ wraplength '4i'
+ justify 'left'
+ text "The listbox below contains a collection of well-known sayings. You can scan the list using either of the scrollbars or by dragging in the listbox window with button 2 pressed."
+}
+msg.pack('side'=>'top')
+
+# frame
+TkFrame.new(base_frame) {|frame|
+ TkButton.new(frame) {
+ text 'Dismiss'
+ command proc{
+ tmppath = $sayings_demo
+ $sayings_demo = nil
+ tmppath.destroy
+ }
+ }.pack('side'=>'left', 'expand'=>'yes')
+
+ TkButton.new(frame) {
+ text 'Show Code'
+ command proc{showCode 'sayings'}
+ }.pack('side'=>'left', 'expand'=>'yes')
+
+}.pack('side'=>'bottom', 'fill'=>'x', 'pady'=>'2m')
+
+# frame
+sayings_lbox = nil
+TkFrame.new(base_frame, 'borderwidth'=>10) {|w|
+ sv = TkScrollbar.new(w)
+ sh = TkScrollbar.new(w, 'orient'=>'horizontal')
+ sayings_lbox = TkListbox.new(w) {
+ setgrid 1
+ width 20
+ height 10
+ yscrollcommand proc{|first,last| sv.set first,last}
+ xscrollcommand proc{|first,last| sh.set first,last}
+ }
+ sv.command(proc{|*args| sayings_lbox.yview(*args)})
+ sh.command(proc{|*args| sayings_lbox.xview(*args)})
+
+ if $tk_version =~ /^4\.[01]/
+ sv.pack('side'=>'right', 'fill'=>'y')
+ sh.pack('side'=>'bottom', 'fill'=>'x')
+ sayings_lbox.pack('expand'=>'yes', 'fill'=>'y')
+
+ else
+ sayings_lbox.grid('row'=>0, 'column'=>0,
+ 'rowspan'=>1, 'columnspan'=>1, 'sticky'=>'news')
+ sv.grid('row'=>0, 'column'=>1,
+ 'rowspan'=>1, 'columnspan'=>1, 'sticky'=>'news')
+ sh.grid('row'=>1, 'column'=>0,
+ 'rowspan'=>1, 'columnspan'=>1, 'sticky'=>'news')
+ TkGrid.rowconfigure(w, 0, 'weight'=>1, 'minsize'=>0)
+ TkGrid.columnconfigure(w, 0, 'weight'=>1, 'minsize'=>0)
+ end
+
+}.pack('side'=>'top', 'expand'=>'yes', 'fill'=>'y')
+
+sayings_lbox.insert(0,
+"Waste not, want not",
+"Early to bed and early to rise makes a man healthy, wealthy, and wise",
+"Ask not what your country can do for you, ask what you can do for your country",
+"I shall return",
+"NOT",
+"A picture is worth a thousand words",
+"User interfaces are hard to build",
+"Thou shalt not steal",
+"A penny for your thoughts",
+"Fool me once, shame on you; fool me twice, shame on me",
+"Every cloud has a silver lining",
+"Where there's smoke there's fire",
+"It takes one to know one",
+"Curiosity killed the cat; but satisfaction brought it back",
+"Take this job and shove it",
+"Up a creek without a paddle",
+"I'm mad as hell and I'm not going to take it any more",
+"An apple a day keeps the doctor away",
+"Don't look a gift horse in the mouth"
+)
+
diff --git a/jni/ruby/ext/tk/sample/demos-en/search.rb b/jni/ruby/ext/tk/sample/demos-en/search.rb
new file mode 100644
index 0000000..7fb40d8
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/demos-en/search.rb
@@ -0,0 +1,187 @@
+# search.rb
+#
+# This demonstration script creates a collection of widgets that
+# allow you to load a file into a text widget, then perform searches
+# on that file.
+#
+# Text Search widget demo (called by 'widget')
+#
+
+# textLoadFile --
+# This method below loads a file into a text widget, discarding
+# the previous contents of the widget. Tags for the old widget are
+# not affected, however.
+#
+# Arguments:
+# w - The window into which to load the file. Must be a
+# text widget.
+# file - The name of the file to load. Must be readable.
+
+def textLoadFile(w,file)
+ w.delete('1.0', 'end')
+ f = open(file, 'r')
+ while(!f.eof?)
+ w.insert('end', f.read(1000))
+ end
+ f.close
+end
+
+# textSearch --
+# Search for all instances of a given string in a text widget and
+# apply a given tag to each instance found.
+#
+# Arguments:
+# w - The window in which to search. Must be a text widget.
+# string - The string to search for. The search is done using
+# exact matching only; no special characters.
+# tag - Tag to apply to each instance of a matching string.
+
+def textSearch(w, string, tag)
+ tag.remove('0.0', 'end')
+ return if string == ""
+ cur = '1.0'
+ loop {
+ cur, len = w.search_with_length(string, cur, 'end')
+ break if cur == ""
+ tag.add(cur, "#{cur} + #{len} char")
+ cur = w.index("#{cur} + #{len} char")
+ }
+end
+
+# textToggle --
+# This method is invoked repeatedly to invoke two commands at
+# periodic intervals. It normally reschedules itself after each
+# execution but if an error occurs (e.g. because the window was
+# deleted) then it doesn't reschedule itself.
+#
+# Arguments:
+# cmd1 - Command to execute when method is called.
+# sleep1 - Ms to sleep after executing cmd1 before executing cmd2.
+# cmd2 - Command to execute in the *next* invocation of this method.
+# sleep2 - Ms to sleep after executing cmd2 before executing cmd1 again.
+
+def textToggle(cmd1,sleep1,cmd2,sleep2)
+ sleep_list = [sleep2, sleep1]
+ TkAfter.new(proc{sleep = sleep_list.shift; sleep_list.push(sleep); sleep},
+ -1, cmd1, cmd2).start(sleep1)
+end
+
+# toplevel widget
+if defined?($search_demo) && $search_demo
+ $search_demo.destroy
+ $search_demo = nil
+end
+
+# demo toplevel widget
+$search_demo = TkToplevel.new {|w|
+ title("Text Demonstration - Search and Highlight")
+ iconname("search")
+ positionWindow(w)
+}
+
+base_frame = TkFrame.new($search_demo).pack(:fill=>:both, :expand=>true)
+
+# frame
+$search_buttons = TkFrame.new(base_frame) {|frame|
+ TkButton.new(frame) {
+ text 'Dismiss'
+ command proc{
+ tmppath = $search_demo
+ $search_demo = nil
+ tmppath.destroy
+ }
+ }.pack('side'=>'left', 'expand'=>'yes')
+
+ TkButton.new(frame) {
+ text 'Show Code'
+ command proc{showCode 'search'}
+ }.pack('side'=>'left', 'expand'=>'yes')
+}
+$search_buttons.pack('side'=>'bottom', 'fill'=>'x', 'pady'=>'2m')
+
+# frame
+TkFrame.new(base_frame) {|f|
+ TkLabel.new(f, 'text'=>'File name:',
+ 'width'=>13, 'anchor'=>'w').pack('side'=>'left')
+ $search_fileName = TkVariable.new
+ TkEntry.new(f, 'width'=>40,
+ 'textvariable'=>$search_fileName) {
+ pack('side'=>'left')
+ bind('Return', proc{textLoadFile($search_text, $search_fileName.value)
+ $search_string_entry.focus})
+ focus
+ }
+ TkButton.new(f, 'text'=>'Load File',
+ 'command'=>proc{textLoadFile($search_text,
+ $search_fileName.value)})\
+ .pack('side'=>'left', 'pady'=>5, 'padx'=>10)
+}.pack('side'=>'top', 'fill'=>'x')
+
+TkFrame.new(base_frame) {|f|
+ TkLabel.new(f, 'text'=>'Search string:',
+ 'width'=>13, 'anchor'=>'w').pack('side'=>'left')
+ $search_searchString = TkVariable.new
+ $search_string_entry = TkEntry.new(f, 'width'=>40,
+ 'textvariable'=>$search_searchString) {
+ pack('side'=>'left')
+ bind('Return', proc{textSearch($search_text, $search_searchString.value,
+ $search_Tag)})
+ }
+ TkButton.new(f, 'text'=>'Highlight',
+ 'command'=>proc{textSearch($search_text,
+ $search_searchString.value,
+ $search_Tag)}) {
+ pack('side'=>'left', 'pady'=>5, 'padx'=>10)
+ }
+}.pack('side'=>'top', 'fill'=>'x')
+
+$search_text = TkText.new(base_frame, 'setgrid'=>true, 'wrap'=>'word') {|t|
+ $search_Tag = TkTextTag.new(t)
+ TkScrollbar.new(base_frame, 'command'=>proc{|*args| t.yview(*args)}) {|sc|
+ t.yscrollcommand(proc{|first,last| sc.set first,last})
+ pack('side'=>'right', 'fill'=>'y')
+ }
+ pack('expand'=>'yes', 'fill'=>'both')
+}
+
+# Set up display styles for text highlighting.
+
+if TkWinfo.depth($search_demo) > 1
+ textToggle(proc{
+ $search_Tag.configure('background'=>'#ce5555',
+ 'foreground'=>'white')
+ },
+ 800,
+ proc{
+ $search_Tag.configure('background'=>'', 'foreground'=>'')
+ },
+ 200 )
+else
+ textToggle(proc{
+ $search_Tag.configure('background'=>'black',
+ 'foreground'=>'white')
+ },
+ 800,
+ proc{
+ $search_Tag.configure('background'=>'', 'foreground'=>'')
+ },
+ 200 )
+end
+$search_text.insert('1.0', "\
+This window demonstrates how to use the tagging facilities in text \
+widgets to implement a searching mechanism. First, type a file name \
+in the top entry, then type <Return> or click on \"Load File\". Then \
+type a string in the lower entry and type <Return> or click on \
+\"Load File\". This will cause all of the instances of the string to \
+be tagged with the tag \"search\", and it will arrange for the tag\'s \
+display attributes to change to make all of the strings blink.")
+$search_text.insert('end', "\
+The current directory to load a file is \"#{Dir.pwd}\".\
+")
+$search_text.set_insert '0.0'
+
+$search_fileName.value = ''
+$search_searchString.value = ''
+
+$search_text.width = 60
+$search_text.height = 20
diff --git a/jni/ruby/ext/tk/sample/demos-en/spin.rb b/jni/ruby/ext/tk/sample/demos-en/spin.rb
new file mode 100644
index 0000000..d51b7e6
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/demos-en/spin.rb
@@ -0,0 +1,65 @@
+# spin.rb --
+#
+# This demonstration script creates several spinbox widgets.
+#
+# based on Tcl/Tk8.4.4 widget demos
+
+if defined?($spin_demo) && $spin_demo
+ $spin_demo.destroy
+ $spin_demo = nil
+end
+
+$spin_demo = TkToplevel.new {|w|
+ title("Spinbox Demonstration")
+ iconname("spin")
+ positionWindow(w)
+}
+
+base_frame = TkFrame.new($spin_demo).pack(:fill=>:both, :expand=>true)
+
+TkLabel.new(base_frame,
+ :font=>$font, :wraplength=>'5i', :justify=>:left,
+ :text=><<EOL).pack(:side=>:top)
+Three different spin-boxes are displayed below. \
+You can add characters by pointing, clicking and typing. \
+The normal Motif editing characters are supported, along with \
+many Emacs bindings. For example, Backspace and Control-h \
+delete the character to the left of the insertion cursor and \
+Delete and Control-d delete the chararacter to the right of the \
+insertion cursor. For values that are too large to fit in the \
+window all at once, you can scan through the value by dragging \
+with mouse button2 pressed. Note that the first spin-box will \
+only permit you to type in integers, and the third selects from \
+a list of Australian cities.
+If your Tk library linked to Ruby doesn't include a 'spinbox' widget, \
+this demo doesn't work. Please use later version of Tk \
+which supports a 'spinbox' widget.
+EOL
+
+TkFrame.new(base_frame){|f|
+ pack(:side=>:bottom, :fill=>:x, :pady=>'2m')
+
+ TkButton.new(f, :text=>'Dismiss', :width=>15, :command=>proc{
+ $spin_demo.destroy
+ $spin_demo = nil
+ }).pack(:side=>:left, :expand=>true)
+
+ TkButton.new(f, :text=>'See Code', :width=>15, :command=>proc{
+ showCode 'spin'
+ }).pack(:side=>:left, :expand=>true)
+}
+
+australianCities = [
+ 'Canberra', 'Sydney', 'Melbourne', 'Perth', 'Adelaide',
+ 'Brisbane', 'Hobart', 'Darwin', 'Alice Springs'
+]
+
+[
+ TkSpinbox.new(base_frame, :from=>1, :to=>10, :width=>10, :validate=>:key,
+ :validatecommand=>[
+ proc{|s| s == '' || /^[+-]?\d+$/ =~ s }, '%P'
+ ]),
+ TkSpinbox.new(base_frame, :from=>0, :to=>3, :increment=>0.5,
+ :format=>'%05.2f', :width=>10),
+ TkSpinbox.new(base_frame, :values=>australianCities, :width=>10)
+].each{|sbox| sbox.pack(:side=>:top, :pady=>5, :padx=>10)}
diff --git a/jni/ruby/ext/tk/sample/demos-en/square b/jni/ruby/ext/tk/sample/demos-en/square
new file mode 100644
index 0000000..bb66282
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/demos-en/square
@@ -0,0 +1,81 @@
+#!/usr/bin/env ruby
+
+# square --
+# This script generates a demo application containing only
+# a "square" widget. It's only usable if Tk has been compiled
+# with tkSquare.c and with the -DSQUARE_DEMO compiler switch.
+# This demo arranges the following bindings for the widget:
+#
+# Button-1 press/drag: moves square to mouse
+# "a": toggle size animation on/off
+#
+
+require 'tk'
+require 'tkafter'
+
+class TkSquare<TkWindow
+ def create_self
+ begin
+ tk_call 'square', path
+ rescue
+ STDERR.print "\nSorry. Your Tk interpreter does not contain " +
+ 'a "square" demonstration widget.' +
+ "\n ( See documents included the Tcl/Tk source archive. )\n\n"
+ exit
+ end
+ end
+ def size(amount=nil)
+ if amount
+ tk_send 'size', amount
+ else
+ number(tk_send('size'))
+ end
+ end
+ def position(x,y)
+ tk_send 'position', x, y
+ end
+end
+
+$s = TkSquare.new{
+ pack('expand'=>'yes', 'fill'=>'both')
+ bind('1', proc{|x,y| center(x,y)}, '%s %y')
+ bind('B1-Motion', proc{|x,y| center(x,y)}, '%s %y')
+ bind('a', proc{animate})
+ focus
+}
+TkRoot.new.minsize(1,1)
+
+# The procedure below centers the square on a given position.
+
+def center(x,y)
+ a = $s.size
+ $s.position(x-(a/2), y-(a/2))
+end
+
+# The procedures below provide a simple form of animation where
+# the box changes size in a pulsing pattern: larger, smaller, larger,
+# and so on.
+
+$inc = 0
+
+def timer_proc
+ a = $s.size
+ return if $inc == 0
+ $inc = -3 if a >= 40
+ $inc = 3 if a <= 10
+ $s.size(a+$inc)
+end
+
+$timer = TkAfter.new(30, -1, proc{timer_proc})
+
+def animate
+ if $inc == 0
+ $inc = 3
+ $timer.start
+ else
+ $inc = 0
+ $timer.stop
+ end
+end
+
+Tk.mainloop
diff --git a/jni/ruby/ext/tk/sample/demos-en/states.rb b/jni/ruby/ext/tk/sample/demos-en/states.rb
new file mode 100644
index 0000000..a5c01a8
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/demos-en/states.rb
@@ -0,0 +1,80 @@
+# states.rb
+#
+# This demonstration script creates a listbox widget that displays
+# the names of the 50 states in the United States of America.
+#
+# listbox widget demo 'states' (called by 'widget')
+#
+
+# toplevel widget
+if defined?($states_demo) && $states_demo
+ $states_demo.destroy
+ $states_demo = nil
+end
+
+# demo toplevel widget
+$states_demo = TkToplevel.new {|w|
+ title("Listbox Demonstration (states)")
+ iconname("states")
+ positionWindow(w)
+}
+
+base_frame = TkFrame.new($states_demo).pack(:fill=>:both, :expand=>true)
+
+# label
+msg = TkLabel.new(base_frame) {
+ font $font
+ wraplength '4i'
+ justify 'left'
+ text "A listbox containing the 50 states is displayed below, along with a scrollbar. You can scan the list either using the scrollbar or by scanning. To scan, press button 2 in the widget and drag up or down."
+}
+msg.pack('side'=>'top')
+
+# frame
+TkFrame.new(base_frame) {|frame|
+ TkButton.new(frame) {
+ text 'Dismiss'
+ command proc{
+ tmppath = $states_demo
+ $states_demo = nil
+ tmppath.destroy
+ }
+ }.pack('side'=>'left', 'expand'=>'yes')
+
+ TkButton.new(frame) {
+ text 'Show Code'
+ command proc{showCode 'states'}
+ }.pack('side'=>'left', 'expand'=>'yes')
+
+}.pack('side'=>'bottom', 'fill'=>'x', 'pady'=>'2m')
+
+# frame
+states_lbox = nil
+TkFrame.new(base_frame, 'borderwidth'=>'.5c') {|w|
+ s = TkScrollbar.new(w)
+ states_lbox = TkListbox.new(w) {
+ setgrid 1
+ height 12
+ yscrollcommand proc{|first,last| s.set first,last}
+ }
+ s.command(proc{|*args| states_lbox.yview(*args)})
+ s.pack('side'=>'right', 'fill'=>'y')
+ states_lbox.pack('side'=>'left', 'expand'=>1, 'fill'=>'both')
+}.pack('side'=>'top', 'expand'=>'yes', 'fill'=>'y')
+
+ins_data = [
+ 'Alabama', 'Alaska', 'Arizona', 'Arkansas', 'California',
+ 'Colorado', 'Connecticut', 'Delaware', 'Florida', 'Georgia',
+ 'Hawaii', 'Idaho', 'Illinois',
+ 'Indiana', 'Iowa', 'Kansas', 'Kentucky', 'Louisiana', 'Maine', 'Maryland',
+ 'Massachusetts', 'Michigan', 'Minnesota', 'Mississippi', 'Missouri',
+ 'Montana', 'Nebraska', 'Nevada', 'New_Hampshire', 'New_Jersey', 'New_Mexico',
+ 'New_York', 'North_Carolina', 'North_Dakota',
+ 'Ohio', 'Oklahoma', 'Oregon', 'Pennsylvania', 'Rhode_Island',
+ 'South_Carolina', 'South_Dakota',
+ 'Tennessee', 'Texas', 'Utah', 'Vermont', 'Virginia', 'Washington',
+ 'West_Virginia', 'Wisconsin', 'Wyoming'
+]
+
+states_lbox.insert(0, *ins_data)
+
diff --git a/jni/ruby/ext/tk/sample/demos-en/style.rb b/jni/ruby/ext/tk/sample/demos-en/style.rb
new file mode 100644
index 0000000..5c87773
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/demos-en/style.rb
@@ -0,0 +1,231 @@
+# style.rb
+#
+# This demonstration script creates a text widget that illustrates the
+# various display styles that may be set for tags.
+#
+# text (display styles) widget demo (called by 'widget')
+#
+
+# toplevel widget
+if defined?($style_demo) && $style_demo
+ $style_demo.destroy
+ $style_demo = nil
+end
+
+# demo toplevel widget
+$style_demo = TkToplevel.new {|w|
+ title("Text Demonstration - Display Styles")
+ iconname("style")
+ positionWindow(w)
+}
+
+base_frame = TkFrame.new($style_demo).pack(:fill=>:both, :expand=>true)
+
+# frame
+TkFrame.new(base_frame) {|frame|
+ TkButton.new(frame) {
+ text 'Dismiss'
+ command proc{
+ tmppath = $style_demo
+ $style_demo = nil
+ tmppath.destroy
+ }
+ }.pack('side'=>'left', 'expand'=>'yes')
+
+ TkButton.new(frame) {
+ text 'Show Code'
+ command proc{showCode 'style'}
+ }.pack('side'=>'left', 'expand'=>'yes')
+}.pack('side'=>'bottom', 'fill'=>'x', 'pady'=>'2m')
+
+# text
+txt = TkText.new(base_frame){|t|
+ #
+ setgrid 'true'
+ #width 70
+ #height 32
+ wrap 'word'
+ font $font
+ TkScrollbar.new(base_frame) {|s|
+ pack('side'=>'right', 'fill'=>'y')
+ command proc{|*args| t.yview(*args)}
+ t.yscrollcommand proc{|first,last| s.set first,last}
+ }
+ pack('expand'=>'yes', 'fill'=>'both')
+
+ #
+ family = 'Courier'
+
+ if $tk_version =~ /^4.*/
+ style_tag_bold = TkTextTag.new(t, 'font'=>'-*-Courier-Bold-O-Normal--*-120-*-*-*-*-*-*')
+ style_tag_big = TkTextTag.new(t, 'font'=>'-*-Courier-Bold-R-Normal--*-140-*-*-*-*-*-*', 'kanjifont'=>$msg_kanji_font)
+ style_tag_verybig = TkTextTag.new(t, 'font'=>'-*-Helvetica-Bold-R-Normal--*-240-*-*-*-*-*-*')
+ # style_tag_small = TkTextTag.new(t, 'font'=>'-Adobe-Helvetica-Bold-R-Normal-*-100-*', 'kanjifont'=>$kanji_font)
+ style_tag_small = TkTextTag.new(t, 'font'=>'-Adobe-Helvetica-Bold-R-Normal-*-100-*')
+ else
+ style_tag_bold = TkTextTag.new(t, 'font'=>[family, 12, :bold, :italic])
+ style_tag_big = TkTextTag.new(t, 'font'=>[family, 14, :bold])
+ style_tag_verybig = TkTextTag.new(t, 'font'=>['Helvetica', 24, :bold])
+ style_tag_small = TkTextTag.new(t, 'font'=>'Times 8 bold')
+ end
+###
+# case($tk_version)
+# when /^4.*/
+# style_tag_big = TkTextTag.new(t, 'font'=>'-*-Courier-Bold-R-Normal--*-140-*-*-*-*-*-*', 'kanjifont'=>$msg_kanji_font)
+# style_tag_small = TkTextTag.new(t, 'font'=>'-Adobe-Helvetica-Bold-R-Normal-*-100-*', 'kanjifont'=>$kanji_font)
+# when /^8.*/
+# unless $style_demo_do_first
+# $style_demo_do_first = true
+# Tk.tk_call('font', 'create', '@bigascii',
+# '-copy', '-*-Courier-Bold-R-Normal--*-140-*-*-*-*-*-*')
+# Tk.tk_call('font', 'create', '@smallascii',
+# '-copy', '-Adobe-Helvetica-Bold-R-Normal-*-100-*')
+# Tk.tk_call('font', 'create', '@cBigFont',
+# '-compound', '@bigascii @msg_knj')
+# Tk.tk_call('font', 'create', '@cSmallFont',
+# '-compound', '@smallascii @kanji')
+# end
+# style_tag_big = TkTextTag.new(t, 'font'=>'@cBigFont')
+# style_tag_small = TkTextTag.new(t, 'font'=>'@cSmallFont')
+# end
+
+ #
+ if TkWinfo.depth($root).to_i > 1
+ style_tag_color1 = TkTextTag.new(t, 'background'=>'#a0b7ce')
+ style_tag_color2 = TkTextTag.new(t, 'foreground'=>'red')
+ style_tag_raised = TkTextTag.new(t, 'relief'=>'raised', 'borderwidth'=>1)
+ style_tag_sunken = TkTextTag.new(t, 'relief'=>'sunken', 'borderwidth'=>1)
+ else
+ style_tag_color1 = TkTextTag.new(t, 'background'=>'black',
+ 'foreground'=>'white')
+ style_tag_color2 = TkTextTag.new(t, 'background'=>'black',
+ 'foreground'=>'white')
+ style_tag_raised = TkTextTag.new(t, 'background'=>'white',
+ 'relief'=>'raised', 'borderwidth'=>1)
+ style_tag_sunken = TkTextTag.new(t, 'background'=>'white',
+ 'relief'=>'sunken', 'borderwidth'=>1)
+ end
+
+ #
+ if $tk_version =~ /^4\.[01]/
+ style_tag_bgstipple = TkTextTag.new(t, 'background'=>'black',
+ 'borderwidth'=>0,
+ 'bgstipple'=>'gray25')
+ else
+ style_tag_bgstipple = TkTextTag.new(t, 'background'=>'black',
+ 'borderwidth'=>0,
+ 'bgstipple'=>'gray12')
+ end
+ style_tag_fgstipple = TkTextTag.new(t, 'fgstipple'=>'gray50')
+ style_tag_underline = TkTextTag.new(t, 'underline'=>'on')
+ style_tag_overstrike = TkTextTag.new(t, 'overstrike'=>'on')
+ style_tag_right = TkTextTag.new(t, 'justify'=>'right')
+ style_tag_center = TkTextTag.new(t, 'justify'=>'center')
+ if $tk_version =~ /^4.*/
+ style_tag_super = TkTextTag.new(t, 'offset'=>'4p', 'font'=>'-Adobe-Courier-Medium-R-Normal--*-100-*-*-*-*-*-*')
+ style_tag_sub = TkTextTag.new(t, 'offset'=>'-2p', 'font'=>'-Adobe-Courier-Medium-R-Normal--*-100-*-*-*-*-*-*')
+ else
+ style_tag_super = TkTextTag.new(t, 'offset'=>'4p', 'font'=>[family, 10])
+ style_tag_sub = TkTextTag.new(t, 'offset'=>'-2p', 'font'=>[family, 10])
+ end
+ style_tag_margins = TkTextTag.new(t, 'lmargin1'=>'12m', 'lmargin2'=>'6m',
+ 'rmargin'=>'10m')
+ style_tag_spacing = TkTextTag.new(t, 'spacing1'=>'10p', 'spacing2'=>'2p',
+ 'lmargin1'=>'12m', 'lmargin2'=>'6m',
+ 'rmargin'=>'10m')
+
+ #
+ insert('end', 'Text widgets like this one allow you to display information in a
+variety of styles. Display styles are controlled using a mechanism
+called ')
+ insert('end', 'tags', style_tag_big)
+ insert('end', '. Tags are just textual names that you can apply to one
+or more ranges of characters within a text widget. You can configure
+tags with various display styles. If you do this, then the tagged
+characters will be displayed with the styles you chose. The
+available display styles are:
+')
+ insert('end', "\n1. Font.", style_tag_big)
+ insert('end', " You can choose any X font, ")
+ insert('end', "large", style_tag_verybig)
+ insert('end', " or ")
+ insert('end', "small", style_tag_small)
+ insert('end', ".\n")
+ insert('end', "\n2. Color.", style_tag_big)
+ insert('end', " You can change either the ")
+ insert('end', "background", style_tag_color1)
+ insert('end', " or ")
+ insert('end', "foreground", style_tag_color2)
+ insert('end', "\ncolor, or ")
+ insert('end', "both", style_tag_color1, style_tag_color2)
+ insert('end', ".\n")
+ insert('end', "\n3. Stippling.", style_tag_big)
+ insert('end', " You can cause either the ")
+ insert('end', "background", style_tag_bgstipple)
+ insert('end', " or ")
+ insert('end', "foreground", style_tag_fgstipple)
+ insert('end', "\ninformation to be drawn with a stipple fill instead of a solid fill.\n")
+ insert('end', "\n4. Underlining.", style_tag_big)
+ insert('end', " You can ")
+ insert('end', "underline", style_tag_underline)
+ insert('end', " ranges of text.\n")
+ insert('end', "\n5. Overstrikes.", style_tag_big)
+ insert('end', " You can ")
+ insert('end', "draw lines through", style_tag_overstrike)
+ insert('end', " ranges of text.\n")
+ insert('end', "\n6. 3-D effects.", style_tag_big)
+ insert('end', " You can arrange for the background to be drawn\nwith a border that makes characters appear either\n")
+ insert('end', "raised", style_tag_raised)
+ insert('end', " or ")
+ insert('end', "sunken", style_tag_sunken)
+ insert('end', ".\n")
+ insert('end', "\n7. Justification.", style_tag_big)
+ insert('end', " You can arrange for lines to be displayed\n")
+ insert('end', "left-justified,\n")
+ insert('end', "right-justified, or\n", style_tag_right)
+ insert('end', "centered.\n", style_tag_center)
+ insert('end', "\n8. Superscripts and subscripts.", style_tag_big)
+ insert('end', " You can control the vertical\n")
+ insert('end', "position of text to generate superscript effects like 10")
+ insert('end', "n", style_tag_super)
+ insert('end', " or\nsubscript effects like X")
+ insert('end', "i", style_tag_sub)
+ insert('end', ".\n")
+ insert('end', "\n9. Margins.", style_tag_big)
+ insert('end', " You can control the amount of extra space left")
+ insert('end', " on\neach side of the text:\n")
+ insert('end', "This paragraph is an example of the use of ", style_tag_margins)
+ insert('end', "margins. It consists of a single line of text ", style_tag_margins)
+ insert('end', "that wraps around on the screen. There are two ", style_tag_margins)
+ insert('end', "separate left margin values, one for the first ", style_tag_margins)
+ insert('end', "display line associated with the text line, ", style_tag_margins)
+ insert('end', "and one for the subsequent display lines, which ", style_tag_margins)
+ insert('end', "occur because of wrapping. There is also a ", style_tag_margins)
+ insert('end', "separate specification for the right margin, ", style_tag_margins)
+ insert('end', "which is used to choose wrap points for lines.\n", style_tag_margins)
+ insert('end', "\n10. Spacing.", style_tag_big)
+ insert('end', " You can control the spacing of lines with three\n")
+ insert('end', "separate parameters. \"Spacing1\" tells how much ")
+ insert('end', "extra space to leave\nabove a line, \"spacing3\" ")
+ insert('end', "tells how much space to leave below a line,\nand ")
+ insert('end', "if a text line wraps, \"spacing2\" tells how much ")
+ insert('end', "space to leave\nbetween the display lines that ")
+ insert('end', "make up the text line.\n")
+ insert('end', "These indented paragraphs illustrate how spacing ", style_tag_spacing)
+ insert('end', "can be used. Each paragraph is actually a ", style_tag_spacing)
+ insert('end', "single line in the text widget, which is ", style_tag_spacing)
+ insert('end', "word-wrapped by the widget.\n", style_tag_spacing)
+ insert('end', "Spacing1 is set to 10 points for this text, ", style_tag_spacing)
+ insert('end', "which results in relatively large gaps between ", style_tag_spacing)
+ insert('end', "the paragraphs. Spacing2 is set to 2 points, ", style_tag_spacing)
+ insert('end', "which results in just a bit of extra space ", style_tag_spacing)
+ insert('end', "within a pararaph. Spacing3 isn't used ", style_tag_spacing)
+ insert('end', "in this example.\n", style_tag_spacing)
+ insert('end', "To see where the space is, select ranges of ", style_tag_spacing)
+ insert('end', "text within these paragraphs. The selection ", style_tag_spacing)
+ insert('end', "highlight will cover the extra space.", style_tag_spacing)
+
+}
+
+txt.width 70
+txt.height 32
diff --git a/jni/ruby/ext/tk/sample/demos-en/tcolor b/jni/ruby/ext/tk/sample/demos-en/tcolor
new file mode 100644
index 0000000..48cda6d
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/demos-en/tcolor
@@ -0,0 +1,526 @@
+#!/usr/bin/env ruby
+#
+# tcolor --
+# simple color editor which supports RGB, HSB and CYM color space
+#
+# Copyright (C) 1998 Takaaki Tateishi(ttate@jaist.ac.jp)
+# last update: Thu Jun 18 06:32:35 JST 1998
+#
+
+require "tk"
+
+
+# use TkVariable instance for the variable which is changed by Tk interpreter
+
+$colorSpace = TkVariable.new(:rgb)
+$master = nil
+$red = 65535
+$green = 0
+$blue = 0
+$color = "#ffff00000000"
+$updating = TkVariable.new(0)
+$autoUpdate = TkVariable.new(1)
+$name = TkVariable.new($color)
+$command = TkVariable.new("print(%%,\"\n\")")
+# $command = TkVariable.new("")
+$label1 = TkVariable.new("label1")
+$label2 = TkVariable.new("label2")
+$label3 = TkVariable.new("label3")
+
+
+# setup the entry of the resourc database
+if (TkVarAccess.new('tcl_platform')['platform'] == 'unix')
+ TkOptionDB.add('*Entry.background', 'white')
+end
+
+
+# methods for events
+
+def rgbToHsv(red,green,blue)
+
+ if ( red > green )
+ max = red
+ min = green
+ else
+ max = green
+ min = red
+ end
+
+ if ( blue > max )
+ max = blue
+ else
+ if ( blue < min )
+ min = blue
+ end
+ end
+
+ range = max - min
+
+ if ( max == 0 )
+ sat = 0.0
+ else
+ sat = (max-min)/max
+ end
+
+ if ( sat == 0 )
+ hue = 0.0
+ else
+ rc = (max-red)/range
+ gc = (max-green)/range
+ bc = (max-blue)/range
+ if ( red == max )
+ hue = 0.166667 * (bc - gc)
+ else
+ if ( green == max )
+ hue = 0.166667 * (2.0 + rc - bc)
+ else
+ hue = 0.166667 * (4.0 + gc - rc)
+ end
+ end
+ if ( hue < 0.0 )
+ hue = hue + 1.0
+ end
+ end
+
+ [hue,sat,max/65535]
+end
+
+
+def hsbToRgb(hue,sat,value)
+ v = 65535.0 * value
+ if( sat == 0 )
+ ans = [v,v,v]
+ else
+ hue = hue*6.0
+ if ( hue >= 6 )
+ hue = 0.0
+ end
+ i = hue.to_i
+ f = hue - i
+ p = 65535.0 * value * (1.0 - sat)
+ q = 65535.0 * value * (1.0 - (sat * f))
+ t = 65535.0 * value * (1.0 - (sat * (1.0 - f)))
+ case i
+ when 0
+ ans = [v,t,p]
+ when 1
+ ans = [q,v,p]
+ when 2
+ ans = [p,v,t]
+ when 3
+ ans = [p,q,v]
+ when 4
+ ans = [t,p,v]
+ when 5
+ ans = [v,p,q]
+ else
+ raise(eException,"i value #{i} is out of range")
+ end
+ end
+ return ans
+end
+
+
+def _null_binding
+ Module.new.instance_eval{binding}
+end
+private :_null_binding
+
+def doUpdate
+ newCmd = $command.to_s.gsub("%%","\"#{$color}\"")
+ eval(newCmd, _null_binding)
+end
+
+
+def tc_scaleChanged
+ if( $updating.to_i == 1 )
+ return
+ end
+
+ $master = :scale if $master == nil
+
+ scale1 = $root.middle.middle.scale1
+ scale2 = $root.middle.middle.scale2
+ scale3 = $root.middle.middle.scale3
+
+ case $colorSpace.value.intern
+ when :rgb
+ $red = (scale1.get * 65.535).to_i
+ $green = (scale2.get * 65.535).to_i
+ $blue = (scale3.get * 65.535).to_i
+ when :cmy
+ $red = (65535 - scale1.get * 65.535).to_i
+ $green = (65535 - scale2.get * 65.535).to_i
+ $blue = (65535 - scale3.get * 65.535).to_i
+ when :hsb
+ list = hsbToRgb(scale1.get / 1000.0,
+ scale2.get / 1000.0,
+ scale3.get / 1000.0)
+ $red = list[0]
+ $green = list[1]
+ $blue = list[2]
+ else
+ raise(Exception,"unknown colorSpace")
+ end
+ $color = format("#%04x%04x%04x",$red.to_i,$green.to_i,$blue.to_i)
+ $name.value = $color if $master == :scale
+ $root.middle.right.set_color($color)
+ if( $autoUpdate.to_i == 1 )
+ doUpdate
+ end
+ Tk.update(true)
+ $master = nil if $master == :scale
+end
+
+
+def tc_setScales
+ $updating.value = 1
+
+ scale1 = $root.middle.middle.scale1
+ scale2 = $root.middle.middle.scale2
+ scale3 = $root.middle.middle.scale3
+
+ case $colorSpace.value.intern
+ when :rgb
+ scale1.set($red / 65.535)
+ scale2.set($green / 65.535)
+ scale3.set($blue / 65.535)
+ when :cmy
+ scale1.set((65535 - $red) / 65.535)
+ scale2.set((65535 - $green) / 65.535)
+ scale3.set((65535 - $blue) / 65.535)
+ when :hsb
+ list = rgbToHsv($red,$green,$blue)
+ scale1.set( list[0] * 1000.0 )
+ scale2.set( list[1] * 1000.0 )
+ scale3.set( list[2] * 1000.0 )
+ else
+ raise(Exception,"unknown colorSpace")
+ end
+
+ $updating.value = 0
+end
+
+
+def tc_loadNamedColor(name)
+ $name.value = name
+ $master = :name if $master == nil
+ if name[0,1] != "#"
+ list = TkWinfo.rgb($root.middle.right.swatch,name)
+ $red = list[0]
+ $green = list[1]
+ $blue = list[2]
+ else
+ case name.length
+ when 4
+ fmt = /#(.{1})(.{1})(.{1})/
+ shift = 12
+ when 7
+ fmt = /#(.{2})(.{2})(.{2})/
+ shift = 8
+ when 10
+ fmt = /#(.{3})(.{3})(.{3})/
+ shift = 4
+ when 13
+ fmt = /#(.{4})(.{4})(.{4})/
+ shift = 0
+ else
+ raise(eException,"syntax error in color name \"#{name}\"")
+ end
+ name.scan(fmt){|strlist|
+ if strlist.length != 3
+ raise(eException,"syntax error in color name \"#{name}\"")
+ end
+ $red = strlist[0].hex
+ $green = strlist[1].hex
+ $blue = strlist[2].hex
+ }
+ $red = $red << shift
+ $green = $green << shift
+ $blue = $blue << shift
+ end
+
+ tc_setScales
+ $color = format("#%04x%04x%04x",$red,$green,$blue)
+ $root.middle.right.set_color($color)
+ if $autoUpdate.to_i == 1
+ doUpdate
+ end
+ Tk.update(true)
+ $master = nil if $master == :name
+end
+
+
+def changeColorSpace(space)
+ case space
+ when :rgb
+ $label1.value = "Red"
+ $label2.value = "Green"
+ $label3.value = "Blue"
+ when :cmy
+ $label1.value = "Cyan"
+ $label2.value = "Magenta"
+ $label3.value = "Yellow"
+ when :hsb
+ $label1.value = "Hue"
+ $label2.value = "Saturation"
+ $label3.value = "Brightness"
+ end
+ tc_setScales
+end
+
+
+# menu
+
+class TkColorMenuFrame<TkFrame
+ def initialize(parent)
+ super(parent,
+ "relief"=>"raised",
+ "borderwidth"=>"2")
+
+ # File menubutton
+ @file = TkMenubutton.new(self){|button|
+
+ # File menu
+ @file_menu = TkMenu.new(button){
+ add "radio",
+ "label" => "RGB color space",
+ "variable" => $colorSpace,
+ "value" => :rgb,
+ "underline" => "0",
+ "command" => proc{changeColorSpace(:rgb)}
+ add "radio",
+ "label" => "CMY color space",
+ "variable" => $colorSpace,
+ "value" => :cmy,
+ "underline" => "0",
+ "command" => proc{changeColorSpace(:cmy)}
+ add "radio",
+ "label" => "HSB color space",
+ "variable" => $colorSpace,
+ "value" => :hsb,
+ "underline" => "0",
+ "command" => proc{changeColorSpace(:hsb)}
+ add "separator"
+ add "radio",
+ "label" => "Automatic updates",
+ "variable" => $autoUpdate,
+ "value" => "1",
+ "underline" => "0"
+ add "radio",
+ "label" => "Manual updates",
+ "variable" => $autoUpdate,
+ "value" => "0",
+ "underline" => "0"
+ add "separator"
+ add "command",
+ "label" => "Exit program",
+ "underline" => "0",
+ "command" => proc{exit}
+ }
+
+ # assign File menu to File button
+ menu @file_menu
+
+ text "File"
+ underline "0"
+ }.pack("side"=>"left")
+
+ self
+ end
+end
+
+
+# bottom frame
+class TkColorBotFrame<TkFrame
+ def initialize(parent)
+ super(parent,
+ "relief"=> "raised",
+ "borderwidth"=> 2)
+
+ @commandLabel = TkLabel.new(self,
+ "text"=> "Command:")
+ @command = TkEntry.new(self,
+ "relief"=> "sunken",
+ "borderwidth"=> "2",
+ "textvariable"=> $command,
+ "font"=> "-Adobe-Courier-Medium-R-Normal--*-120-*-*-*-*-*-*")
+ @update = TkButton.new(self,
+ "text"=> "Update",
+ "command"=> proc{doUpdate})
+ @commandLabel.pack("side"=>"left")
+ @update.pack("side"=>"right","pady"=>".1c","padx"=>".25c")
+ @command.pack("expand"=>"yes","fill"=>"x","ipadx"=>".25c")
+
+ self
+ end
+end
+
+
+# left side frame of middle level
+class TkColorMiddleLeftFrame<TkFrame
+ def initialize(parent)
+ super(parent)
+
+ for i in ["/usr/local/lib/X11rgb.txt","/usr/lib/X11/rgb.txt",
+ "/X11/R5/lib/X11/rgb.txt","/X11/R4/lib/rgb/rgb.txt",
+ "/usr/openwin/lib/X11/rgb.txt"]
+ if !File.readable?(i)
+ next
+ end
+ f = File.open(i)
+ @scroll = TkScrollbar.new(self,
+ "orient"=>"vertical",
+ "relief"=>"sunken",
+ "borderwidth"=>"2")
+ @scroll.pack("side"=>"right","fill"=>"y")
+ @names = TkListbox.new(self,
+ "width"=>"20",
+ "height"=>"12",
+ "yscrollcommand"=> proc{|first,last| @scroll.set first,last},
+ "relief"=>"sunken",
+ "borderwidth"=>"2",
+ "exportselection"=>"false")
+ @scroll.command(proc{|*args| @names.yview(*args)})
+ @names.bind("Double-1",proc{
+ tc_loadNamedColor(@names.get(@names.curselection))})
+ @names.pack("side"=>"left")
+ while (line = f.gets)
+ line.chop!
+ linelist = line.split(/[ \t]+/)
+ if linelist.length == 4
+ @names.insert("end",linelist[3])
+ end
+ end
+ f.close
+ break
+ end
+
+ self
+ end
+end
+
+
+# middle frame of middle level
+class TkColorMiddleMiddleFrame<TkFrame
+ attr_reader :scale1, :scale2, :scale3
+
+ def initialize(parent)
+ super(parent)
+
+ @f1 = TkFrame.new(self)
+ @f2 = TkFrame.new(self)
+ @f3 = TkFrame.new(self)
+ @f4 = TkFrame.new(self)
+
+ for f in [@f1,@f2,@f3]
+ f.pack("side"=>"top","expand"=>"yes")
+ end
+ @f4.pack("side"=>"top","expand"=>"yes","fill"=>"x")
+
+ @label1 = TkLabel.new(self,"textvariable"=>$label1)
+ @scale1 = TkScale.new(self,"from"=>"0","to"=>"1000","length"=>"6c",
+ "orient"=>"horizontal",
+ "command"=>proc{tc_scaleChanged})
+ @scale1.pack("side"=>"top","anchor"=>"w")
+ @label1.pack("side"=>"top","anchor"=>"w")
+
+ @label2 = TkLabel.new(self,"textvariable"=>$label2)
+ @scale2 = TkScale.new(self,"from"=>"0","to"=>"1000","length"=>"6c",
+ "orient"=>"horizontal",
+ "command"=>proc{tc_scaleChanged})
+ @scale2.pack("side"=>"top","anchor"=>"w")
+ @label2.pack("side"=>"top","anchor"=>"w")
+
+ @label3 = TkLabel.new(self,"textvariable"=>$label3)
+ @scale3 = TkScale.new(self,"from"=>"0","to"=>"1000","length"=>"6c",
+ "orient"=>"horizontal",
+ "command"=>proc{tc_scaleChanged})
+ @scale3.pack("side"=>"top","anchor"=>"w")
+ @label3.pack("side"=>"top","anchor"=>"w")
+
+ @nameLabel = TkLabel.new(self,"text"=>"Name:")
+ @name = TkEntry.new(self,"relief"=>"sunken","borderwidth"=>"2",
+ "textvariable"=>$name,"width"=>"10",
+ "font"=>"-Adobe-Courier-Medium-R-Normal--*-120-*-*-*-*-*-*")
+ @nameLabel.pack("side"=>"left")
+ @name.pack("side"=>"right", "expand"=>"1", "fill"=>"x")
+ @name.bind("Return",proc{tc_loadNamedColor $name.to_s})
+
+ self
+ end
+end
+
+
+class TkColorMiddleRightFrame<TkFrame
+ attr_reader :swatch
+
+ def initialize(parent)
+ super(parent)
+ @swatch = TkFrame.new(self, "width"=>"2c", "height"=>"5c",
+ "background"=>$color)
+ @value = TkLabel.new(self,
+ "text"=>$color,
+ "width"=>"13",
+ "font"=>"-Adobe-Courier-Medium-R-Normal--*-120-*-*-*-*-*-*")
+ @swatch.pack("side"=>"top","expand"=>"yes","fill"=>"both")
+ @value.pack("side"=>"bottom","pady"=>".25c")
+
+ self
+ end
+
+ def set_color(color)
+ @swatch["background"] = color
+ @value["text"] = color
+ end
+end
+
+
+
+# middle level frame
+class TkColorMiddleFrame<TkFrame
+ attr_reader :left, :middle, :right
+
+ def initialize(parent)
+ super(parent,
+ "relief"=> "raised",
+ "borderwidth"=> "2")
+
+ @left = TkColorMiddleLeftFrame.new(self)
+ @left.pack("side"=>"left","padx"=>".25c","pady"=>".25c")
+
+ @middle = TkColorMiddleMiddleFrame.new(self)
+ @middle.pack("side"=>"left","expand"=>"yes","fill"=>"y")
+
+ @right = TkColorMiddleRightFrame.new(self)
+ @right.pack("side"=>"left","padx"=>".25c","pady"=>".25c","anchor"=>"s")
+
+ self
+ end
+end
+
+
+class TkColor<TkRoot
+ attr_reader :menu, :bottom, :middle
+
+ def initialize(*args)
+ super(*args)
+ @menu = TkColorMenuFrame.new(self)
+ @menu.pack("side"=>"top", "fill"=>"x")
+
+ @bottom = TkColorBotFrame.new(self)
+ @bottom.pack("side"=>"bottom","fill"=>"x")
+
+ @middle = TkColorMiddleFrame.new(self)
+ @middle.pack("side"=>"top","fill"=>"both")
+
+ self
+ end
+end
+
+
+$root = TkColor.new
+changeColorSpace :rgb
+
+# start eventloop
+Tk.mainloop
diff --git a/jni/ruby/ext/tk/sample/demos-en/text.rb b/jni/ruby/ext/tk/sample/demos-en/text.rb
new file mode 100644
index 0000000..2f72de7
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/demos-en/text.rb
@@ -0,0 +1,128 @@
+# text.rb
+#
+# This demonstration script creates a text widget that describes
+# the basic editing functions.
+#
+# text (basic facilities) widget demo (called by 'widget')
+#
+
+# toplevel widget
+if defined?($text_demo) && $text_demo
+ $text_demo.destroy
+ $text_demo = nil
+end
+
+# demo toplevel widget
+$text_demo = TkToplevel.new {|w|
+ title("Text Demonstration - Basic Facilities")
+ iconname("text")
+ positionWindow(w)
+}
+
+base_frame = TkFrame.new($text_demo).pack(:fill=>:both, :expand=>true)
+
+# version check
+if ((Tk::TK_VERSION.split('.').collect{|n| n.to_i} <=> [8,4]) < 0)
+ undo_support = false
+else
+ undo_support = true
+end
+
+# frame
+TkFrame.new(base_frame) {|frame|
+ TkButton.new(frame) {
+ text 'Dismiss'
+ command proc{
+ tmppath = $text_demo
+ $text_demo = nil
+ tmppath.destroy
+ }
+ }.pack('side'=>'left', 'expand'=>'yes')
+
+ TkButton.new(frame) {
+ text 'Show Code'
+ command proc{showCode 'text'}
+ }.pack('side'=>'left', 'expand'=>'yes')
+}.pack('side'=>'bottom', 'fill'=>'x', 'pady'=>'2m')
+
+# text
+TkText.new(base_frame){|t|
+ relief 'sunken'
+ bd 2
+ setgrid 1
+ height 30
+ if undo_support
+ undo true
+ autoseparators true
+ end
+ TkScrollbar.new(base_frame) {|s|
+ pack('side'=>'right', 'fill'=>'y')
+ command proc{|*args| t.yview(*args)}
+ t.yscrollcommand proc{|first,last| s.set first,last}
+ }
+ pack('expand'=>'yes', 'fill'=>'both')
+
+ #
+ insert('0.0', <<EOT)
+This window is a text widget. It displays one or more lines of text
+and allows you to edit the text. Here is a summary of the things you
+can do to a text widget:
+
+1. Scrolling. Use the scrollbar to adjust the view in the text window.
+
+2. Scanning. Press mouse button 2 in the text window and drag up or down.
+This will drag the text at high speed to allow you to scan its contents.
+
+3. Insert text. Press mouse button 1 to set the insertion cursor, then
+type text. What you type will be added to the widget.
+
+4. Select. Press mouse button 1 and drag to select a range of characters.
+Once you've released the button, you can adjust the selection by pressing
+button 1 with the shift key down. This will reset the end of the
+selection nearest the mouse cursor and you can drag that end of the
+selection by dragging the mouse before releasing the mouse button.
+You can double-click to select whole words or triple-click to select
+whole lines.
+
+5. Delete and replace. To delete text, select the characters you'd like
+to delete and type Backspace or Delete. Alternatively, you can type new
+text, in which case it will replace the selected text.
+
+6. Copy the selection. To copy the selection into this window, select
+what you want to copy (either here or in another application), then
+click button 2 to copy the selection to the point of the mouse cursor.
+
+7. Edit. Text widgets support the standard Motif editing characters
+plus many Emacs editing characters. Backspace and Control-h erase the
+character to the left of the insertion cursor. Delete and Control-d
+erase the character to the right of the insertion cursor. Meta-backspace
+deletes the word to the left of the insertion cursor, and Meta-d deletes
+the word to the right of the insertion cursor. Control-k deletes from
+the insertion cursor to the end of the line, or it deletes the newline
+character if that is the only thing left on the line. Control-o opens
+a new line by inserting a newline character to the right of the insertion
+cursor. Control-t transposes the two characters on either side of the
+insertion cursor. #{
+ if undo_support
+ undo_text = "Control-z undoes the last editing action performed,\nand "
+ case $tk_platform['platform']
+ when "unix", "macintosh"
+ undo_text << "Control-Shift-z"
+ else # 'windows'
+ undo_text << "Control-y"
+ end
+ undo_text << "redoes undone edits."
+ else
+ ""
+ end
+}
+
+8. Resize the window. This widget has been configured with the "setGrid"
+option on, so that if you resize the window it will always resize to an
+even number of characters high and wide. Also, if you make the window
+narrow you can see that long lines automatically wrap around onto
+additional lines so that all the information is always visible.
+EOT
+
+ set_insert('0.0')
+}
diff --git a/jni/ruby/ext/tk/sample/demos-en/textpeer.rb b/jni/ruby/ext/tk/sample/demos-en/textpeer.rb
new file mode 100644
index 0000000..20192fc
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/demos-en/textpeer.rb
@@ -0,0 +1,76 @@
+#
+# text widget peering demo (called by 'widget')
+#
+# based on Tcl/Tk8.5.0 widget demos
+
+if defined?($textpeer_demo) && $textpeer_demo
+ $textpeer_demo.destroy
+ $textpeer_demo = nil
+end
+
+# demo toplevel widget
+$textpeer_demo = TkToplevel.new {|w|
+ title("Text Wdget Peering Demonstration")
+ iconname("textpeer")
+ positionWindow(w)
+}
+
+base_frame = TkFrame.new($textpeer_demo).pack(:fill=>:both, :expand=>true)
+
+count = [0]
+
+## Define a widget that we peer from; it won't ever actually be shown though
+first = TkText.new(base_frame, :widgetname=>"text#{count[0] += 1}")
+first.insert :end,"This is a coupled pair of text widgets; they are peers to "
+first.insert :end,"each other. They have the same underlying data model, but "
+first.insert :end,"can show different locations, have different current edit "
+first.insert :end,"locations, and have different selections. You can also "
+first.insert :end,"create additional peers of any of these text widgets using "
+first.insert :end,"the Make Peer button beside the text widget to clone, and "
+first.insert :end,"delete a particular peer widget using the Delete Peer "
+first.insert :end,"button."
+
+Tk.update_idletasks ## for 'first' widget
+
+## Procedures to make and kill clones; most of this is just so that the demo
+## looks nice...
+def makeClone(count, win, txt)
+ cnt = (count[0] += 1)
+ peer = TkText::Peer.new(txt, win, :widgetname=>"text#{cnt}")
+ sbar = TkScrollbar.new(win, :widgetname=>"sb#{cnt}")
+ peer.yscrollbar sbar
+ b1 = TkButton.new(win, :widgetname=>"clone#{cnt}", :text=>'Make Peer',
+ :command=>proc{makeClone(count, win, peer)})
+ b2 = TkButton.new(win, :widgetname=>"kill#{cnt}", :text=>'Delete Peer',
+ :command=>proc{killClone(win, cnt)})
+ row = cnt * 2
+ TkGrid.configure(peer, sbar, b1, :sticky=>'nsew', :row=>row)
+ TkGrid.configure('^', '^', b2, :sticky=>'nsew', :row=>(row+=1))
+ TkGrid.configure(b1, b2, :sticky=>'new')
+ TkGrid.rowconfigure(win, b2, :weight=>1)
+end
+
+def killClone(win, cnt)
+ Tk.destroy("#{win.path}.text#{cnt}", "#{win.path}.sb#{cnt}",
+ "#{win.path}.clone#{cnt}", "#{win.path}.kill#{cnt}")
+end
+
+## Now set up the GUI
+makeClone(count, base_frame, first)
+makeClone(count, base_frame, first)
+first.destroy
+
+## See Code / Dismiss buttons
+TkFrame.new(base_frame){|f|
+ TkButton.new(f, :text=>'Dismiss', :width=>15, :command=>proc{
+ $textpeer_demo.destroy
+ $textpeer_demo = nil
+ }).pack(:side=>:left, :expand=>true)
+
+ TkButton.new(f, :text=>'See Code', :width=>15, :command=>proc{
+ showCode 'textpeer'
+ }).pack(:side=>:left, :expand=>true)
+
+ TkGrid.configure(f, '-', '-', :sticky=>'ew', :row=>5000)
+}
+TkGrid.columnconfigure(base_frame, 0, :weight=>1)
diff --git a/jni/ruby/ext/tk/sample/demos-en/timer b/jni/ruby/ext/tk/sample/demos-en/timer
new file mode 100644
index 0000000..6cb7c87
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/demos-en/timer
@@ -0,0 +1,136 @@
+#!/usr/bin/env ruby
+#
+# timer --
+# This script generates a counter with start,stop and reset buttons.
+#
+# Copyright (C) 1998 Takaaki Tateishi (ttate@jaist.ac.jp)
+# last update: Sat Jun 27 12:24:14 JST 1998
+#
+
+require "tk"
+require "thread"
+require "tkafter"
+
+$time = "0.00"
+$m = Mutex.new
+$loop = false
+
+def timer_stop
+ $loop = false
+ $m.lock
+end
+
+def timer_start
+ $loop = true
+ $m.unlock
+end
+
+def timer_reset
+ $time = "0.00"
+ $root.countframe.counter['text'] = $time
+end
+
+def timer_loop
+ if $loop
+ $time = $time.succ
+ $root.countframe.counter['text'] = $time
+ end
+ Tk.after(10,proc{timer_loop})
+end
+
+
+#
+# thread version
+#
+def timer_loop2
+ while true
+ $m.lock
+ $time = $time.succ
+ $root.countframe.counter['text'] = $time
+ sleep(0.01)
+ $m.unlock
+ end
+end
+
+#
+# TkAfter
+#
+def timer_loop3
+ if $loop
+ $time = $time.succ
+ $root.countframe.counter['text'] = $time
+ end
+end
+
+
+class CountFrame < TkFrame
+ attr_reader :counter
+
+ def initialize(parent=nil,keys=nil)
+ super(parent,keys)
+ @counter = TkLabel.new(self,
+ 'text'=>$time,
+ 'relief'=>'raised')
+ @counter.pack('fill'=>'both')
+ self
+ end
+end
+
+
+class ButtonFrame < TkFrame
+ def initialize(parent=nil,keys=nil)
+ super(parent,keys)
+=begin
+ @stop = TkButton.new(self,
+ 'text'=>'Stop',
+ 'command'=>proc{timer_stop})
+ @start = TkButton.new(self,
+ 'text'=>'Start',
+ 'command'=>proc{timer_start})
+=end
+ @stop = TkButton.new(self, :text=>'Stop', :state=>:disabled)
+ @start = TkButton.new(self, :text=>'Start', :state=>:normal)
+
+ @stop.command proc{
+ timer_stop
+ @start.state(:normal)
+ @stop.state(:disabled)
+ }
+ @start.command proc{
+ timer_start
+ @stop.state(:normal)
+ @start.state(:disabled)
+ }
+
+ @reset = TkButton.new(self,
+ 'text'=>'Reset',
+ 'command'=>proc{timer_reset})
+ for b in [@stop,@start,@reset]
+ b.pack('side'=>'left', 'fill'=>'both', 'expand'=>'yes')
+ end
+ end
+end
+
+
+class Timer < TkRoot
+ attr_reader :countframe
+
+ def initialize(*args)
+ super(*args)
+ @countframe = CountFrame.new(self)
+ @buttonframe = ButtonFrame.new(self)
+ for f in [@buttonframe,@countframe]
+ f.pack('side'=>'top', 'fill'=>'both')
+ end
+ self
+ end
+end
+
+
+$root = Timer.new
+
+#$thread = Thread.start{timer_loop2}
+#timer_loop
+TkAfter.new(10,-1,proc{timer_loop3}).start
+
+Tk.mainloop
diff --git a/jni/ruby/ext/tk/sample/demos-en/tkencoding.rb b/jni/ruby/ext/tk/sample/demos-en/tkencoding.rb
new file mode 100644
index 0000000..727491a
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/demos-en/tkencoding.rb
@@ -0,0 +1,42 @@
+# -*- ruby -*-
+#
+# tkencoding.rb
+# written by ttate@jaist.ac.jp
+
+class TclTkIp
+ alias __eval _eval
+ alias __invoke _invoke
+ private :__eval
+ private :__invoke
+
+ attr_accessor :encoding
+
+ def _eval(cmd)
+ if( @encoding )
+ _fromUTF8(__eval(_toUTF8(cmd,@encoding)),@encoding)
+ else
+ __eval(cmd)
+ end
+ end
+
+ def _invoke(*cmds)
+ if( @encoding )
+ cmds = cmds.collect{|cmd| _toUTF8(cmd,@encoding)}
+ _fromUTF8(__invoke(*cmds),@encoding)
+ else
+ __invoke(*cmds)
+ end
+ end
+end
+
+module Tk
+ INTERP = TkCore::INTERP
+
+ def encoding=(name)
+ INTERP.encoding = name
+ end
+
+ def encoding
+ INTERP.encoding
+ end
+end
diff --git a/jni/ruby/ext/tk/sample/demos-en/toolbar.rb b/jni/ruby/ext/tk/sample/demos-en/toolbar.rb
new file mode 100644
index 0000000..e7cbeb4
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/demos-en/toolbar.rb
@@ -0,0 +1,130 @@
+# toolbar.rb --
+#
+# This demonstration script creates a toolbar that can be torn off.
+#
+# based on "Id: toolbar.tcl,v 1.3 2007/12/13 15:27:07 dgp Exp"
+
+if defined?($toolbar_demo) && $toolbar_demo
+ $toolbar_demo.destroy
+ $toolbar_demo = nil
+end
+
+$toolbar_demo = TkToplevel.new {|w|
+ title("Ttk Menu Buttons")
+ iconname("toolbar")
+ positionWindow(w)
+}
+
+base_frame = Ttk::Frame.new($toolbar_demo).pack(:fill=>:both, :expand=>true)
+
+if Tk.windowingsystem != 'aqua'
+ msg = Ttk::Label.new(base_frame, :wraplength=>'4i',
+ :text=>Tk::UTF8_String.new(<<EOL))
+This is a demonstration of how to do \
+a toolbar that is styled correctly \
+and which can be torn off (this feature reqrires Tcl/Tk8.5). \
+The buttons are configured to be \\u201Ctoolbar style\\u201D buttons by \
+telling them that they are to use the Toolbutton style. At the left \
+end of the toolbar is a simple marker that the cursor changes to a \
+movement icon over; drag that away from the toolbar to tear off the \
+whole toolbar into a separate toplevel widget. When the dragged-off \
+toolbar is no longer needed, just close it like any normal toplevel \
+and it will reattach to the window it was torn off from.
+EOL
+else
+ msg = Ttk::Label.new(base_frame, :wraplength=>'4i',
+ :text=>Tk::UTF8_String.new(<<EOL))
+This is a demonstration of how to do \
+a toolbar that is styled correctly. The buttons are configured to \
+be \\u201Ctoolbar style\\u201D buttons by telling them that they are \
+to use the Toolbutton style.
+EOL
+end
+
+## Set up the toolbar hull
+tbar_base = Tk::Frame.new(base_frame, # Must be a starndard Tk frame!
+ :widgetname=>'toolbar') # for window title
+sep = Ttk::Separator.new(base_frame)
+to_base = Ttk::Frame.new(tbar_base, :cursor=>'fleur')
+if Tk.windowingsystem != 'aqua'
+ to = Ttk::Separator.new(to_base, :orient=>:vertical)
+ to2 = Ttk::Separator.new(to_base, :orient=>:vertical)
+ to.pack(:fill=>:y, :expand=>true, :padx=>2, :side=>:left)
+ to2.pack(:fill=>:y, :expand=>true, :side=>:left)
+end
+
+contents = Ttk::Frame.new(tbar_base)
+Tk.grid(to_base, contents, :sticky=>'nsew')
+tbar_base.grid_columnconfigure(contents, :weight=>1)
+contents.grid_columnconfigure(1000, :weight=>1)
+
+if Tk.windowingsystem != 'aqua'
+ ## Bindings so that the toolbar can be torn off and reattached
+ to_base.bind('B1-Motion', '%X %Y'){|x, y| tbar_base.tearoff(to_base, x, y)}
+ to. bind('B1-Motion', '%X %Y'){|x, y| tbar_base.tearoff(to_base, x, y)}
+ to2. bind('B1-Motion', '%X %Y'){|x, y| tbar_base.tearoff(to_base, x, y)}
+ def tbar_base.tearoff(w, x, y)
+ on_win = TkWinfo.containing(x, y)
+ return unless (on_win && on_win.path =~ /^#{@path}(\.|$)/)
+ self.grid_remove
+ w.grid_remove
+ self.wm_manage
+ # self.wm_title('Toolbar') # if you don't want to use its widget name as a window title.
+ self.wm_protocol('WM_DELETE_WINDOW'){ self.untearoff(w) }
+ end
+ def tbar_base.untearoff(w)
+ self.wm_forget
+ w.grid
+ self.grid
+ end
+end
+
+## Some content for the rest of the toplevel
+text = TkText.new(base_frame, :width=>40, :height=>10)
+
+## Toolbar contents
+tb_btn = Ttk::Button.new(tbar_base, :text=>'Button', :style=>'Toolbutton',
+ :command=>proc{text.insert(:end, "Button Pressed\n")})
+tb_chk = Ttk::Checkbutton.new(tbar_base, :text=>'Check', :style=>'Toolbutton',
+ :variable=>(check = TkVariable.new),
+ :command=>proc{
+ text.insert(:end, "Check is #{check.value}\n")
+ })
+tb_mbtn = Ttk::Menubutton.new(tbar_base, :text=>'Menu')
+tb_combo = Ttk::Combobox.new(tbar_base, :value=>TkFont.families,
+ :state=>:readonly)
+tb_mbtn.menu(menu = Tk::Menu.new(tb_mbtn))
+menu.add(:command, :label=>'Just', :command=>proc{text.insert(:end, "Just\n")})
+menu.add(:command, :label=>'An', :command=>proc{text.insert(:end, "An\n")})
+menu.add(:command, :label=>'Example',
+ :command=>proc{text.insert(:end, "Example\n")})
+tb_combo.bind('<ComboboxSelected>'){ text.font.family = tb_combo.get }
+
+## Arrange contents
+Tk.grid(tb_btn, tb_chk, tb_mbtn, tb_combo,
+ :in=>contents, :padx=>2, :sticky=>'ns')
+Tk.grid(tbar_base, :sticky=>'ew')
+Tk.grid(sep, :sticky=>'ew')
+Tk.grid(msg, :sticky=>'ew')
+Tk.grid(text, :sticky=>'nsew')
+base_frame.grid_rowconfigure(text, :weight=>1)
+base_frame.grid_columnconfigure(text, :weight=>1)
+
+## See Code / Dismiss buttons
+Ttk::Frame.new(base_frame) {|frame|
+ sep = Ttk::Separator.new(frame)
+ Tk.grid(sep, :columnspan=>4, :row=>0, :sticky=>'ew', :pady=>2)
+ TkGrid('x',
+ Ttk::Button.new(frame, :text=>'See Code',
+ :image=>$image['view'], :compound=>:left,
+ :command=>proc{showCode 'toolbar'}),
+ Ttk::Button.new(frame, :text=>'Dismiss',
+ :image=>$image['delete'], :compound=>:left,
+ :command=>proc{
+ $toolbar_demo.destroy
+ $toolbar_demo = nil
+ }),
+ :padx=>4, :pady=>4)
+ grid_columnconfigure(0, :weight=>1)
+ Tk.grid(frame, :sticky=>'ew')
+}
diff --git a/jni/ruby/ext/tk/sample/demos-en/tree.rb b/jni/ruby/ext/tk/sample/demos-en/tree.rb
new file mode 100644
index 0000000..69154ee
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/demos-en/tree.rb
@@ -0,0 +1,119 @@
+# tree.rb --
+#
+# This demonstration script creates a toplevel window containing a Ttk
+# tree widget.
+#
+# based on "Id: tree.tcl,v 1.4 2007/12/13 15:27:07 dgp Exp"
+
+if defined?($tree_demo) && $tree_demo
+ $tree_demo.destroy
+ $tree_demo = nil
+end
+
+$tree_demo = TkToplevel.new {|w|
+ title("Directory Browser")
+ iconname("tree")
+ positionWindow(w)
+}
+
+base_frame = TkFrame.new($tree_demo).pack(:fill=>:both, :expand=>true)
+
+## Explanatory text
+Ttk::Label.new(base_frame, :font=>$font, :wraplength=>'4i',
+ :justify=>:left, :anchor=>'n', :padding=>[10, 2, 10, 6],
+ :text=><<EOL).pack(:fill=>:x)
+Ttk is the new Tk themed widget set. \
+One of the widgets it includes is a tree widget, \
+which allows the user to browse a hierarchical data-set such as a filesystem. \
+The tree widget not only allows for the tree part itself, \
+but it also supports an arbitrary number of additional columns \
+which can show additional data (in this case, the size of the files \
+found in your filesystem). \
+You can also change the width of the columns \
+by dragging the boundary between them.
+EOL
+
+## See Code / Dismiss
+Ttk::Frame.new(base_frame) {|frame|
+ sep = Ttk::Separator.new(frame)
+ Tk.grid(sep, :columnspan=>4, :row=>0, :sticky=>'ew', :pady=>2)
+ TkGrid('x',
+ Ttk::Button.new(frame, :text=>'See Code',
+ :image=>$image['view'], :compound=>:left,
+ :command=>proc{showCode 'tree'}),
+ Ttk::Button.new(frame, :text=>'Dismiss',
+ :image=>$image['delete'], :compound=>:left,
+ :command=>proc{
+ $tree_demo.destroy
+ $tree_demo = nil
+ }),
+ :padx=>4, :pady=>4)
+ grid_columnconfigure(0, :weight=>1)
+ pack(:side=>:bottom, :fill=>:x)
+}
+
+## Code to populate the roots of the tree (can be more than one on Windows)
+def populate_roots(tree)
+ TkComm.simplelist(Tk.tk_call('file', 'volumes')).sort.each{|dir|
+ populate_tree(tree, tree.insert(nil, :end, :text=>dir,
+ :values=>[dir, 'directory']))
+ }
+end
+
+## Code to populate a node of the tree
+def populate_tree(tree, node)
+ return if tree.get(node, :type) != 'directory'
+
+ path = tree.get(node, :fullpath)
+ tree.delete(tree.children(node))
+ Dir.glob("#{path}/*").sort.each{|f|
+ type = File.ftype(f) rescue nil
+ id = tree.insert(node, :end,
+ :text=>File.basename(f), :values=>[f, type]).id
+ if type == 'directory'
+ ## Make it so that this node is openable
+ tree.insert(id, 0, :text=>'dummy')
+ tree.itemconfigure(id, :text=>File.basename(f))
+ elsif type == 'file'
+ size = File.size(f)
+ if size >= 1024*1024*1024
+ size = '%.1f GB' % (size.to_f/1024/1024/1024)
+ elsif size >= 1024*1024
+ size = '%.1f MB' % (size.to_f/1024/1024)
+ elsif size >= 1024
+ size = '%.1f KB' % (size.to_f/1024)
+ else
+ size = '%.1f bytes' % (size.to_f/1024)
+ end
+ tree.set(id, :size, size)
+ end
+ }
+
+ # Stop this code from rerunning on the current node
+ tree.set(node, :type, 'processed_directory')
+end
+
+## Create the tree and set it up
+tree = Ttk::Treeview.new(base_frame, :columns=>%w(fullpath type size),
+ :displaycolumns=>['size'])
+if Tk.windowingsystem != 'aqua'
+ vsb = tree.yscrollbar(Ttk::Scrollbar.new(base_frame))
+ hsb = tree.xscrollbar(Ttk::Scrollbar.new(base_frame))
+else
+ vsb = tree.yscrollbar(Tk::Scrollbar.new(base_frame))
+ hsb = tree.xscrollbar(Tk::Scrollbar.new(base_frame))
+end
+
+tree.heading_configure('#0', :text=>'Directory Structure')
+tree.heading_configure('size', :text=>'File Size')
+tree.column_configure('size', :stretch=>0, :width=>70)
+populate_roots(tree)
+tree.bind('<TreeviewOpen>', '%W'){|w| populate_tree(w, w.focus_item)}
+
+## Arrange the tree and its scrollbars in the toplevel
+container = Ttk::Frame.new(base_frame).pack(:fill=>:both, :expand=>true)
+container.lower
+Tk.grid(tree, vsb, :in=>container, :sticky=>'nsew')
+Tk.grid(hsb, :in=>container, :sticky=>'nsew')
+container.grid_columnconfigure(0, :weight=>1)
+container.grid_rowconfigure(0, :weight=>1)
diff --git a/jni/ruby/ext/tk/sample/demos-en/ttkbut.rb b/jni/ruby/ext/tk/sample/demos-en/ttkbut.rb
new file mode 100644
index 0000000..a784efc
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/demos-en/ttkbut.rb
@@ -0,0 +1,139 @@
+# ttkbut.rb
+#
+# This demonstration script creates a toplevel window containing several
+# simple Ttk widgets, such as labels, labelframes, buttons, checkbuttons and
+# radiobuttons.
+#
+# based on "Id: ttkbut.tcl,v 1.4 2007/12/13 15:27:07 dgp Exp"
+
+if defined?($ttkbut_demo) && $ttkbut_demo
+ $ttkbut_demo.destroy
+ $ttkbut_demo = nil
+end
+
+$ttkbut_demo = TkToplevel.new {|w|
+ title("Simple Ttk Widgets")
+ iconname("ttkbut")
+ positionWindow(w)
+}
+
+base_frame = TkFrame.new($ttkbut_demo).pack(:fill=>:both, :expand=>true)
+
+Ttk::Label.new(base_frame, :font=>$font, :wraplength=>'4i', :justify=>:left,
+ :text=><<EOL).pack(:side=>:top, :fill=>:x)
+Ttk is the new Tk themed widget set. This is a Ttk themed label, \
+and below are three groups of Ttk widgets in Ttk labelframes. \
+The first group are all buttons that set the current application theme \
+when pressed. The second group contains three sets of checkbuttons, \
+with a separator widget between the sets. Note that the "Enabled" \
+button controls whether all the other themed widgets in this toplevel are \
+in the disabled state. The third group has a collection of linked \
+radiobuttons.
+EOL
+
+## Add buttons for setting the theme
+buttons = Ttk::Labelframe.new(base_frame, :text=>'Buttons')
+# Ttk::Style.theme_names.each{|theme|
+# Ttk::Button.new(buttons, :text=>theme,
+# :command=>proc{Ttk::Style.theme_use theme}).pack(:pady=>2)
+# }
+Ttk.themes.each{|theme|
+ Ttk::Button.new(buttons, :text=>theme,
+ :command=>proc{Ttk.set_theme theme}).pack(:pady=>2)
+}
+
+## Helper procedure for the top checkbutton
+def setState(root, value, *excepts)
+ return if excepts.member?(root)
+
+ ## Non-Ttk widgets (e.g. the toplevel) will fail, so make it silent
+ begin
+ root.state = value
+ rescue
+ end
+
+ ## Recursively invoke on all children of this root that are in the same
+ ## toplevel widget
+ root.winfo_children.each{|w|
+ setState(w, value, *excepts) if w.winfo_toplevel == root.winfo_toplevel
+ }
+end
+
+## Set up the checkbutton group
+checks = Ttk::Labelframe.new(base_frame, :text=>'Checkbuttons')
+enabled = TkVariable.new(true)
+e = Ttk::Checkbutton.new(checks, :text=>'Enabled', :variable=>enabled,
+ :command=>proc{
+ setState($ttkbut_demo,
+ ((enabled.bool)? "!disabled" : "disabled"),
+ e)
+ })
+
+## See ttk_widget(n) for other possible state flags
+sep1 = Ttk::Separator.new(checks)
+sep2 = Ttk::Separator.new(checks)
+
+cheese = TkVariable.new
+tomato = TkVariable.new
+basil = TkVariable.new
+oregano = TkVariable.new
+
+c1 = Ttk::Checkbutton.new(checks, :text=>'Cheese', :variable=>cheese)
+c2 = Ttk::Checkbutton.new(checks, :text=>'Tomato', :variable=>tomato)
+c3 = Ttk::Checkbutton.new(checks, :text=>'Basil', :variable=>basil)
+c4 = Ttk::Checkbutton.new(checks, :text=>'Oregano', :variable=>oregano)
+
+Tk.pack(e, sep1, c1, c2, sep2, c3, c4, :fill=>:x, :pady=>2)
+
+## Set up the radiobutton group
+radios = Ttk::Labelframe.new(base_frame, :text=>'Radiobuttons')
+
+happyness = TkVariable.new
+
+r1 = Ttk::Radiobutton.new(radios, :variable=>happyness,
+ :text=>'Great', :value=>'great')
+r2 = Ttk::Radiobutton.new(radios, :variable=>happyness,
+ :text=>'Good', :value=>'good')
+r3 = Ttk::Radiobutton.new(radios, :variable=>happyness,
+ :text=>'Ok', :value=>'ok')
+r4 = Ttk::Radiobutton.new(radios, :variable=>happyness,
+ :text=>'Poor', :value=>'poor')
+r5 = Ttk::Radiobutton.new(radios, :variable=>happyness,
+ :text=>'Awful', :value=>'awful')
+
+Tk.pack(r1, r2, r3, r4, r5, :fill=>:x, :padx=>3, :pady=>2)
+
+## See Code / Dismiss
+Ttk::Frame.new(base_frame) {|frame|
+ sep = Ttk::Separator.new(frame)
+ Tk.grid(sep, :columnspan=>4, :row=>0, :sticky=>'ew', :pady=>2)
+ TkGrid('x',
+ Ttk::Button.new(frame, :text=>'See Variables',
+ :image=>$image['view'], :compound=>:left,
+ :command=>proc{
+ showVars(base_frame, ['enabled', enabled],
+ ['cheese', cheese], ['tomato', tomato],
+ ['basil', basil], ['oregano', oregano],
+ ['happyness', happyness])
+ }),
+ Ttk::Button.new(frame, :text=>'See Code',
+ :image=>$image['view'], :compound=>:left,
+ :command=>proc{showCode 'ttkbut'}),
+ Ttk::Button.new(frame, :text=>'Dismiss',
+ :image=>$image['delete'], :compound=>:left,
+ :command=>proc{
+ tmppath = $ttkbut_demo
+ $ttkbut_demo = nil
+ $showVarsWin[tmppath.path] = nil
+ tmppath.destroy
+ }),
+ :padx=>4, :pady=>4)
+ grid_columnconfigure(0, :weight=>1)
+ pack(:side=>:bottom, :fill=>:x, :expand=>true)
+}
+
+## Arrange things neatly
+f = Ttk::Frame.new(base_frame).pack(:fill=>:both, :expand=>true)
+f.lower
+Tk.grid(buttons, checks, radios, :in=>f, :sticky=>'nwe', :pady=>2, :padx=>3)
+f.grid_columnconfigure([0, 1, 2], :weight=>1, :uniform=>:yes)
diff --git a/jni/ruby/ext/tk/sample/demos-en/ttkmenu.rb b/jni/ruby/ext/tk/sample/demos-en/ttkmenu.rb
new file mode 100644
index 0000000..9399568
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/demos-en/ttkmenu.rb
@@ -0,0 +1,85 @@
+# ttkmenu.rb --
+#
+# This demonstration script creates a toplevel window containing several Ttk
+# menubutton widgets.
+#
+# based on "Id: ttkmenu.tcl,v 1.3 2007/12/13 15:27:07 dgp Exp"
+
+if defined?($ttkmenu_demo) && $ttkmenu_demo
+ $ttkmenu_demo.destroy
+ $ttkmenu_demo = nil
+end
+
+$ttkmenu_demo = TkToplevel.new {|w|
+ title("Ttk Menu Buttons")
+ iconname("ttkmenu")
+ positionWindow(w)
+}
+
+base_frame = Ttk::Frame.new($ttkmenu_demo).pack(:fill=>:both, :expand=>true)
+
+Ttk::Label.new(base_frame, :font=>$font, :wraplength=>'4i', :justify=>:left,
+ :text=><<EOL).pack(:side=>:top, :fill=>:x)
+Ttk is the new Tk themed widget set, \
+and one widget that is available in themed form is the menubutton. \
+Below are some themed menu buttons \
+that allow you to pick the current theme in use. \
+Notice how picking a theme changes the way \
+that the menu buttons themselves look, \
+and that the central menu button is styled differently \
+(in a way that is normally suitable for toolbars). \
+However, there are no themed menus; the standard Tk menus were judged \
+to have a sufficiently good look-and-feel on all platforms, \
+especially as they are implemented as native controls in many places.
+EOL
+
+Ttk::Separator.new(base_frame).pack(:side=>:top, :fill=>:x)
+
+## See Code / Dismiss
+Ttk::Frame.new($ttkmenu_demo) {|frame|
+ sep = Ttk::Separator.new(frame)
+ Tk.grid(sep, :columnspan=>4, :row=>0, :sticky=>'ew', :pady=>2)
+ TkGrid('x',
+ Ttk::Button.new(frame, :text=>'See Code',
+ :image=>$image['view'], :compound=>:left,
+ :command=>proc{showCode 'ttkmenu'}),
+ Ttk::Button.new(frame, :text=>'Dismiss',
+ :image=>$image['delete'], :compound=>:left,
+ :command=>proc{
+ $ttkmenu_demo.destroy
+ $ttkmenu_demo = nil
+ }),
+ :padx=>4, :pady=>4)
+ grid_columnconfigure(0, :weight=>1)
+ pack(:side=>:bottom, :fill=>:x)
+}
+
+b1 = Ttk::Menubutton.new(base_frame,:text=>'Select a theme',:direction=>:above)
+b2 = Ttk::Menubutton.new(base_frame,:text=>'Select a theme',:direction=>:left)
+b3 = Ttk::Menubutton.new(base_frame,:text=>'Select a theme',:direction=>:right)
+b4 = Ttk::Menubutton.new(base_frame,:text=>'Select a theme',:direction=>:flush,
+ :style=>Ttk::Menubutton.style('Toolbutton'))
+b5 = Ttk::Menubutton.new(base_frame,:text=>'Select a theme',:direction=>:below)
+
+b1.menu(m1 = Tk::Menu.new(b1, :tearoff=>false))
+b2.menu(m2 = Tk::Menu.new(b2, :tearoff=>false))
+b3.menu(m3 = Tk::Menu.new(b3, :tearoff=>false))
+b4.menu(m4 = Tk::Menu.new(b4, :tearoff=>false))
+b5.menu(m5 = Tk::Menu.new(b5, :tearoff=>false))
+
+Ttk.themes.each{|theme|
+ m1.add(:command, :label=>theme, :command=>proc{Ttk.set_theme theme})
+ m2.add(:command, :label=>theme, :command=>proc{Ttk.set_theme theme})
+ m3.add(:command, :label=>theme, :command=>proc{Ttk.set_theme theme})
+ m4.add(:command, :label=>theme, :command=>proc{Ttk.set_theme theme})
+ m5.add(:command, :label=>theme, :command=>proc{Ttk.set_theme theme})
+}
+
+f = Ttk::Frame.new(base_frame).pack(:fill=>:x)
+f1 = Ttk::Frame.new(base_frame).pack(:fill=>:both, :expand=>true)
+f.lower
+
+f.grid_anchor(:center)
+TkGrid('x', b1, 'x', :in=>f, :padx=>3, :pady=>2)
+TkGrid(b2, b4, b3, :in=>f, :padx=>3, :pady=>2)
+TkGrid('x', b5, 'x', :in=>f, :padx=>3, :pady=>2)
diff --git a/jni/ruby/ext/tk/sample/demos-en/ttknote.rb b/jni/ruby/ext/tk/sample/demos-en/ttknote.rb
new file mode 100644
index 0000000..bc0c7b3
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/demos-en/ttknote.rb
@@ -0,0 +1,89 @@
+# ttknote.rb --
+#
+# This demonstration script creates a toplevel window containing a Ttk
+# notebook widget.
+#
+# based on "Id: ttknote.tcl,v 1.5 2007/12/13 15:27:07 dgp Exp"
+
+if defined?($ttknote_demo) && $ttknote_demo
+ $ttknote_demo.destroy
+ $ttknote_demo = nil
+end
+
+$ttknote_demo = TkToplevel.new {|w|
+ title("Ttk Notebook Widget")
+ iconname("ttknote")
+ positionWindow(w)
+}
+
+## See Code / Dismiss
+Ttk::Frame.new($ttknote_demo) {|frame|
+ sep = Ttk::Separator.new(frame)
+ Tk.grid(sep, :columnspan=>4, :row=>0, :sticky=>'ew', :pady=>2)
+ TkGrid('x',
+ Ttk::Button.new(frame, :text=>'See Code',
+ :image=>$image['view'], :compound=>:left,
+ :command=>proc{showCode 'ttknote'}),
+ Ttk::Button.new(frame, :text=>'Dismiss',
+ :image=>$image['delete'], :compound=>:left,
+ :command=>proc{
+ $ttknote_demo.destroy
+ $ttknote_demo = nil
+ }),
+ :padx=>4, :pady=>4)
+ grid_columnconfigure(0, :weight=>1)
+ pack(:side=>:bottom, :fill=>:x)
+}
+
+base_frame = Ttk::Frame.new($ttknote_demo).pack(:fill=>:both, :expand=>true)
+
+## Make the notebook and set up Ctrl+Tab traversal
+notebook = Ttk::Notebook.new(base_frame).pack(:fill=>:both, :expand=>true,
+ :padx=>2, :pady=>3)
+notebook.enable_traversal
+
+## Popuplate the first pane
+f_msg = Ttk::Frame.new(notebook)
+msg_m = Ttk::Label.new(f_msg, :font=>$font, :wraplength=>'4i',
+ :justify=>:left, :anchor=>'n', :text=><<EOL)
+Ttk is the new Tk themed widget set. \
+One of the widgets it includes is the notebook widget, \
+which provides a set of tabs that allow the selection of a group of panels, \
+each with distinct content. \
+They are a feature of many modern user interfaces. \
+Not only can the tabs be selected with the mouse, \
+but they can also be switched between using Ctrl+Tab \
+when the notebook page heading itself is selected. \
+Note that the second tab is disabled, and cannot be selected.
+EOL
+neat = TkVariable.new
+after_id = nil
+msg_b = Ttk::Button.new(f_msg, :text=>'Neat!', :underline=>0,
+ :command=>proc{
+ neat.value = 'Yeah, I know...'
+ Tk.after_cancel(after_id) if after_id
+ after_id = Tk.after(500){neat.value = ''}
+ })
+msg_b.winfo_toplevel.bind('Alt-n'){ msg_b.focus; msg_b.invoke }
+msg_l = Ttk::Label.new(f_msg, :textvariable=>neat)
+notebook.add(f_msg, :text=>'Description', :underline=>0, :padding=>2)
+Tk.grid(msg_m, '-', :sticky=>'new', :pady=>2)
+Tk.grid(msg_b, msg_l, :pady=>[2, 4])
+f_msg.grid_rowconfigure(1, :weight=>1)
+f_msg.grid_columnconfigure([0, 1], :weight=>1, :uniform=>1)
+
+## Populate the second pane. Note that the content doesn't really matter
+f_disabled = Ttk::Frame.new(notebook)
+notebook.add(f_disabled, :text=>'Disabled', :state=>:disabled)
+
+## Popuplate the third pane
+f_editor = Ttk::Frame.new(notebook)
+notebook.add(f_editor, :text=>'Text Editor', :underline=>0)
+editor_t = Tk::Text.new(f_editor, :width=>40, :height=>10, :wrap=>:char)
+if Tk.windowingsystem != 'aqua'
+ editor_s = editor_t.yscrollbar(Ttk::Scrollbar.new(f_editor))
+else
+ editor_s = editor_t.yscrollbar(Tk::Scrollbar.new(f_editor))
+end
+editor_s.pack(:side=>:right, :fill=>:y, :padx=>[0,2], :pady=>2)
+editor_t.pack(:fill=>:both, :expand=>true, :padx=>[2,0], :pady=>2)
diff --git a/jni/ruby/ext/tk/sample/demos-en/ttkpane.rb b/jni/ruby/ext/tk/sample/demos-en/ttkpane.rb
new file mode 100644
index 0000000..87c4ded
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/demos-en/ttkpane.rb
@@ -0,0 +1,213 @@
+# ttkpane.rb --
+#
+# This demonstration script creates a Ttk pane with some content.
+#
+# based on "Id: ttkpane.tcl,v 1.3 2007/12/13 15:27:07 dgp Exp"
+
+if defined?($ttkpane_demo) && $ttkpane_demo
+ $ttkpane_demo.destroy
+ $ttkpane_demo = nil
+end
+
+$ttkpane_demo = TkToplevel.new {|w|
+ title("Themed Nested Panes")
+ iconname("ttkpane")
+ positionWindow(w)
+}
+
+base_frame = TkFrame.new($ttkpane_demo).pack(:fill=>:both, :expand=>true)
+
+Ttk::Label.new(base_frame, :font=>$font, :wraplength=>'4i', :justify=>:left,
+ :text=><<EOL).pack(:side=>:top, :fill=>:x)
+This demonstration shows off a nested set of themed paned windows. \
+Their sizes can be changed by grabbing the area \
+between each contained pane and dragging the divider.
+EOL
+
+Ttk::Separator.new(base_frame).pack(:side=>:top, :fill=>:x)
+
+## See Code / Dismiss
+Ttk::Frame.new(base_frame) {|frame|
+ sep = Ttk::Separator.new(frame)
+ Tk.grid(sep, :columnspan=>4, :row=>0, :sticky=>'ew', :pady=>2)
+ TkGrid('x',
+ Ttk::Button.new(frame, :text=>'See Code',
+ :image=>$image['view'], :compound=>:left,
+ :command=>proc{showCode 'ttkpane'}),
+ Ttk::Button.new(frame, :text=>'Dismiss',
+ :image=>$image['delete'], :compound=>:left,
+ :command=>proc{
+ $ttkpane_demo.destroy
+ $ttkpane_demo = nil
+ }),
+ :padx=>4, :pady=>4)
+ grid_columnconfigure(0, :weight=>1)
+ pack(:side=>:bottom, :fill=>:x)
+}
+
+frame = Ttk::Frame.new(base_frame).pack(:fill=>:both, :expand=>true)
+
+outer = Ttk::Panedwindow.new(frame, :orient=>:horizontal)
+outer.add(in_left = Ttk::Panedwindow.new(outer, :orient=>:vertical))
+outer.add(in_right = Ttk::Panedwindow.new(outer, :orient=>:vertical))
+in_left.add(left_top = Ttk::Labelframe.new(in_left, :text=>'Button'))
+in_left.add(left_bot = Ttk::Labelframe.new(in_left, :text=>'Clocks'))
+in_right.add(right_top = Ttk::Labelframe.new(in_right, :text=>'Progress'))
+in_right.add(right_bot = Ttk::Labelframe.new(in_right, :text=>'Text'))
+if Tk.windowingsystem == 'aqua'
+ [left_top, left_bot, right_top, right_bot].each{|w| w.padding(3) }
+end
+
+# Fill the button pane
+Ttk::Button.new(left_top, :text=>'Press Me',
+ :command=>proc{
+ Tk.messageBox(:type=>'ok', :icon=>'info', :message=>'Ouch!',
+ :detail=>'That hurt...', :parent=>base_frame,
+ :title=>'Button Pressed')
+ }).pack(:padx=>2, :pady=>5)
+
+
+zones_list = [
+ [':Europe/Berlin'],
+ [':America/Argentina/Buenos_Aires', ':America/Buenos_Aires'],
+ [':Africa/Johannesburg'],
+ [':Europe/London'],
+ [':America/Los_Angeles'],
+ [':Europe/Moscow'],
+ [':America/New_York'],
+ [':Asia/Singapore'],
+ [':Australia/Sydney'],
+ [':Asia/Tokyo'],
+]
+
+zones = []
+
+# Check tzinfo support
+if $tk_major_ver > 8 || ($tk_major_ver == 8 && $tk_minor_ver >= 5)
+ tzinfo = :tcl
+
+ # Force a pre-load of all the timezones needed; otherwise can end up
+ # poor-looking synch problems!
+ zones_list.each{|list|
+ list.each{|zone|
+ begin
+ Tk.tk_call('clock', 'format', '0', '-timezone', zone)
+ rescue RuntimeError
+ # ignore
+ else
+ zones << [zone, zone[%r<[^/:]+$>].tr('_', ' ')]
+ break
+ end
+ }
+ }
+
+else
+ begin
+ require 'tzinfo'
+ tzinfo = :tzinfo
+ rescue Exception
+ begin
+ require 'tzfile'
+ tzinfo = :tzfile
+ rescue Exception
+ tzinfo = nil
+ end
+ end
+
+ case tzinfo
+ when :tzinfo
+ zones_list.each{|list|
+ list.each{|zone|
+ begin
+ tz = TZInfo::Timezone.get(zone[%r<[^:]+$>])
+ rescue Exception
+ # ignore
+ else
+ zones << [tz, zone[%r<[^/:]+$>].tr('_', ' ')]
+ break
+ end
+ }
+ }
+
+ when :tzfile
+ zones_list.each{|list|
+ list.each{|zone|
+ begin
+ tz = TZFile.create(zone[%r<[^:]+$>])
+ rescue Exception
+ # ignore
+ else
+ zones << [tz, zone[%r<[^/:]+$>].tr('_', ' ')]
+ break
+ end
+ }
+ }
+
+ else
+ [ -7, -4, -2, -1, 0, +1, +3, +8, +9, +10 ].each{|zone|
+ zones << [zone, 'UTC%+03d00' % zone]
+ }
+ end
+end
+
+time = TkVariable.new_hash
+
+case tzinfo
+when :tcl
+ update_proc = proc{|now, tz, label|
+ time[label] = Tk.tk_call('clock', 'format', now.tv_sec,
+ '-timezone', tz, '-format', '%T')
+ }
+when :tzinfo
+ update_proc = proc{|now, tz, label|
+ time[label] = tz.utc_to_local(now).strftime('%H:%M:%S')
+ }
+when :tzfile
+ update_proc = proc{|now, tz, label|
+ time[label] = tz.at(now.tv_sec).strftime('%H:%M:%S')
+ }
+else
+ update_proc = proc{|now, tz, label|
+ time[label] = (now + (tz * 3600)).strftime('%H:%M:%S')
+ }
+end
+
+# Fill the clocks pane
+zones.each_with_index{|(zone, label), idx|
+ Ttk::Separator.new(left_bot).pack(:fill=>:x) if idx > 0
+ Ttk::Label.new(left_bot, :text=>label, :anchor=>'w').pack(:fill=>:x)
+ Ttk::Label.new(left_bot, :textvariable=>time.ref(label),
+ :anchor=>'w').pack(:fill=>:x)
+}
+
+# Timer start
+every = proc{
+ now = Time.now.utc
+ zones.each{|zone, label| update_proc.call(now, zone, label) }
+}
+TkRTTimer.new(1000, -1, every).start(0, every)
+
+# Fill the progress pane
+Ttk::Progressbar.new(right_top, :mode=>:indeterminate).pack(:fill=>:both, :expand=>true).start
+
+# Fill the text pane
+if Tk.windowingsystem != 'aqua'
+ # The trick with the ttk::frame makes the text widget look like it fits with
+ # the current Ttk theme despite not being a themed widget itself. It is done
+ # by styling the frame like an entry, turning off the border in the text
+ # widget, and putting the text widget in the frame with enough space to allow
+ # the surrounding border to show through (2 pixels seems to be enough).
+ f = Ttk::Frame.new(right_bot, :style=>Ttk::Entry)
+ txt = TkText.new(frame, :wrap=>:word, :width=>30, :borderwidth=>0)
+ txt.pack(:fill=>:both, :expand=>true, :in=>f, :pady=>2, :padx=>2)
+ scr = txt.yscrollbar(Ttk::Scrollbar.new(frame))
+ scr.pack(:side=>:right, :fill=>:y, :in=>right_bot)
+ f.pack(:fill=>:both, :expand=>true)
+ outer.pack(:fill=>:both, :expand=>true)
+else
+ txt = TkText.new(frame, :wrap=>:word, :width=>30, :borderwidth=>0)
+ scr = txt.yscrollbar(TkScrollbar.new(frame))
+ scr.pack(:side=>:right, :fill=>:y, :in=>right_bot)
+ txt.pack(:fill=>:both, :expand=>true, :in=>right_bot)
+ outer.pack(:fill=>:both, :expand=>true, :padx=>10, :pady=>[6, 10])
+end
diff --git a/jni/ruby/ext/tk/sample/demos-en/ttkprogress.rb b/jni/ruby/ext/tk/sample/demos-en/ttkprogress.rb
new file mode 100644
index 0000000..c341a93
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/demos-en/ttkprogress.rb
@@ -0,0 +1,66 @@
+# ttkprogress.rb --
+#
+# This demonstration script creates several progress bar widgets.
+#
+# based on "Id: ttkprogress.tcl,v 1.3 2007/12/13 15:27:07 dgp Exp"
+
+if defined?($ttkprogress_demo) && $ttkprogress_demo
+ $ttkprogress_demo.destroy
+ $ttkprogress_demo = nil
+end
+
+$ttkprogress_demo = TkToplevel.new {|w|
+ title("Progress Bar Demonstration")
+ iconname("ttkprogress")
+ positionWindow(w)
+}
+
+base_frame = TkFrame.new($ttkprogress_demo).pack(:fill=>:both, :expand=>true)
+
+Ttk::Label.new(base_frame, :font=>$font, :wraplength=>'4i', :justify=>:left,
+ :text=>Tk::UTF8_String.new(<<EOL)).pack(:side=>:top, :fill=>:x)
+Below are two progress bars. \
+The top one is a \\u201Cdeterminate\\u201D progress bar, \
+which is used for showing how far through a defined task the program has got. \
+The bottom one is an \\u201Cindeterminate\\u201D progress bar, \
+which is used to show that the program is busy \
+but does not know how long for. Both are run here in self-animated mode, \
+which can be turned on and off using the buttons underneath.
+EOL
+
+## See Code / Dismiss buttons
+Ttk::Frame.new(base_frame) {|frame|
+ sep = Ttk::Separator.new(frame)
+ Tk.grid(sep, :columnspan=>4, :row=>0, :sticky=>'ew', :pady=>2)
+ TkGrid('x',
+ Ttk::Button.new(frame, :text=>'See Code',
+ :image=>$image['view'], :compound=>:left,
+ :command=>proc{showCode 'ttkprogress'}),
+ Ttk::Button.new(frame, :text=>'Dismiss',
+ :image=>$image['delete'], :compound=>:left,
+ :command=>proc{
+ $ttkprogress_demo.destroy
+ $ttkprogress_demo = nil
+ }),
+ :padx=>4, :pady=>4)
+ grid_columnconfigure(0, :weight=>1)
+ pack(:side=>:bottom, :fill=>:x)
+}
+
+frame = Ttk::Frame.new(base_frame).pack(:fill=>:both, :expand=>true)
+
+p1 = Ttk::Progressbar.new(frame, :mode=>:determinate)
+p2 = Ttk::Progressbar.new(frame, :mode=>:indeterminate)
+
+start = Ttk::Button.new(frame, :text=>'Start Progress',
+ :command=>proc{ p1.start; p2.start })
+stop = Ttk::Button.new(frame, :text=>'Stop Progress',
+ :command=>proc{ p1.stop; p2.stop })
+
+Tk.grid(p1, '-', :pady=>5, :padx=>10)
+Tk.grid(p2, '-', :pady=>5, :padx=>10)
+Tk.grid(start, stop, :padx=>10, :pady=>5)
+start.grid_configure(:sticky=>'e')
+stop.grid_configure(:sticky=>'w')
+frame.grid_columnconfigure(:all, :weight=>1)
+
diff --git a/jni/ruby/ext/tk/sample/demos-en/twind.rb b/jni/ruby/ext/tk/sample/demos-en/twind.rb
new file mode 100644
index 0000000..60a345d
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/demos-en/twind.rb
@@ -0,0 +1,291 @@
+# twind.rb
+#
+# This demonstration script creates a text widget with a bunch of
+# embedded windows.
+#
+# text (embedded windows) widget demo (called by 'widget')
+#
+
+# toplevel widget
+if defined?($twind_demo) && $twind_demo
+ $twind_demo.destroy
+ $twind_demo = nil
+end
+
+# demo toplevel widget
+$twind_demo = TkToplevel.new {|w|
+ title("Text Demonstration - Embedded Windows")
+ iconname("Embedded Windows")
+ positionWindow(w)
+}
+
+base_frame = TkFrame.new($twind_demo).pack(:fill=>:both, :expand=>true)
+
+# frame
+$twind_buttons = TkFrame.new(base_frame) {|frame|
+ TkButton.new(frame) {
+ text 'Dismiss'
+ command proc{
+ tmppath = $twind_demo
+ $twind_demo = nil
+ tmppath.destroy
+ }
+ }.pack('side'=>'left', 'expand'=>'yes')
+
+ TkButton.new(frame) {
+ text 'Show Code'
+ command proc{showCode 'twind'}
+ }.pack('side'=>'left', 'expand'=>'yes')
+}
+$twind_buttons.pack('side'=>'bottom', 'fill'=>'x', 'pady'=>'2m')
+
+# frame
+$twind_text = nil
+TkFrame.new(base_frame, 'highlightthickness'=>2, 'borderwidth'=>2,
+ 'relief'=>'sunken') {|f|
+ $twind_text = TkText.new(f, 'setgrid'=>'true', 'font'=>$font,
+ 'width'=>'70', 'height'=>35, 'wrap'=>'word',
+ 'highlightthickness'=>0, 'borderwidth'=>0 ){|t|
+ TkScrollbar.new(f) {|s|
+ command proc{|*args| t.yview(*args)}
+ t.yscrollcommand proc{|first,last| s.set first,last}
+ }.pack('side'=>'right', 'fill'=>'y')
+ }.pack('expand'=>'yes', 'fill'=>'both')
+}.pack('expand'=>'yes', 'fill'=>'both')
+
+#
+$tag_center = TkTextTag.new($twind_text,
+ 'justify' =>'center',
+ 'spacing1'=>'5m',
+ 'spacing3'=>'5m' )
+$tag_buttons = TkTextTag.new($twind_text,
+ 'lmargin1'=>'1c',
+ 'lmargin2'=>'1c',
+ 'rmargin' =>'1c',
+ 'spacing1'=>'3m',
+ 'spacing2'=>0,
+ 'spacing3'=>0 )
+
+$twind_text.insert('end', "A text widget can contain other widgets embedded ")
+$twind_text.insert('end', "it. These are called \"embedded windows\", ")
+$twind_text.insert('end', "and they can consist of arbitrary widgets. ")
+$twind_text.insert('end', "For example, here are two embedded button ")
+$twind_text.insert('end', "widgets. You can click on the first button to ")
+TkTextWindow.new($twind_text, 'end',
+ 'window'=>TkButton.new($twind_text) {
+ #text 'ON'
+ text 'Turn On'
+ command proc{textWindOn $twind_text,$twind_buttons}
+ cursor 'top_left_arrow'
+ })
+$twind_text.insert('end', " horizontal scrolling, which also turns off ")
+$twind_text.insert('end', "word wrapping. Or, you can click on the second ")
+$twind_text.insert('end', "button to\n")
+TkTextWindow.new($twind_text, 'end',
+ 'window'=>TkButton.new($twind_text) {
+ #text 'OFF'
+ text 'Turn Off'
+ command proc{textWindOff $twind_text}
+ cursor 'top_left_arrow'
+ })
+
+$twind_text.insert('end', " horizontal scrolling and turn back on word wrapping.\n\n")
+$twind_text.insert('end', "Or, here is another example. If you ")
+TkTextWindow.new($twind_text, 'end',
+ 'window'=>TkButton.new($twind_text) {
+ text 'Click Here'
+ command proc{textWindPlot $twind_text}
+ cursor 'top_left_arrow'
+ })
+$twind_text.insert('end', " a canvas displaying an x-y plot will appear right here.")
+$mark_plot = TkTextMark.new($twind_text, 'insert')
+$mark_plot.gravity='left'
+$twind_text.insert('end', " You can drag the data points around with the mouse, ")
+$twind_text.insert('end', "or you can click here to ")
+TkTextWindow.new($twind_text, 'end',
+ 'window'=>TkButton.new($twind_text) {
+ text 'Delete'
+ command proc{textWindDel $twind_text}
+ cursor 'top_left_arrow'
+ })
+
+$twind_text.insert('end', " the plot again.\n\n")
+$twind_text.insert('end', "You may also find it useful to put embedded windows in ")
+$twind_text.insert('end', "a text without any actual text. In this case the ")
+$twind_text.insert('end', "text widget acts like a geometry manager. For ")
+$twind_text.insert('end', "example, here is a collection of buttons laid out ")
+$twind_text.insert('end', "neatly into rows by the text widget. These buttons ")
+$twind_text.insert('end', "can be used to change the background color of the ")
+$twind_text.insert('end', "text widget (\"Default\" restores the color to ")
+$twind_text.insert('end', "its default). If you click on the button labeled ")
+$twind_text.insert('end', "\"Short\", it changes to a longer string so that ")
+$twind_text.insert('end', "you can see how the text widget automatically ")
+$twind_text.insert('end', "changes the layout. Click on the button again ")
+$twind_text.insert('end', "to restore the short string.\n")
+
+
+TkTextWindow.new($twind_text, 'end',
+ 'window'=>TkButton.new($twind_text) {|b|
+ text 'Default'
+ command proc{embDefBg $twind_text}
+ cursor 'top_left_arrow'
+ $tag_buttons.add('end')
+ },
+ 'padx'=>3 )
+embToggle = TkVariable.new('Short')
+TkTextWindow.new($twind_text, 'end',
+ 'window'=>TkCheckButton.new($twind_text) {
+ textvariable embToggle
+ indicatoron 0
+ variable embToggle
+ onvalue 'A much longer string'
+ offvalue 'Short'
+ cursor 'top_left_arrow'
+ pady 5
+ padx 2
+ },
+ 'padx'=>3,
+ 'pady'=>2 )
+
+[ 'AntiqueWhite3', 'Bisque1', 'Bisque2', 'Bisque3', 'Bisque4',
+ 'SlateBlue3', 'RoyalBlue1', 'SteelBlue2', 'DeepSkyBlue3', 'LightBlue1',
+ 'DarkSlateGray1', 'Aquamarine2', 'DarkSeaGreen2', 'SeaGreen1',
+ 'Yellow1', 'IndianRed1', 'IndianRed2', 'Tan1', 'Tan4'
+].each{|twind_color|
+ TkTextWindow.new($twind_text, 'end',
+ 'window'=>TkButton.new($twind_text) {
+ text twind_color
+ cursor 'top_left_arrow'
+ command proc{$twind_text.bg twind_color}
+ },
+ 'padx'=>3,
+ 'pady'=>2 )
+}
+
+#
+def textWindOn (w,f)
+ if defined? $twind_scroll
+ begin
+ $twind_scroll.destroy
+ rescue
+ end
+ $twind_scroll = nil
+ end
+
+ base = TkWinfo.parent( TkWinfo.parent(w) )
+ $twind_scroll = TkScrollbar.new(base) {|s|
+ orient 'horizontal'
+ command proc{|*args| w.xview(*args)}
+ w.xscrollcommand proc{|first,last| s.set first,last}
+ w.wrap 'none'
+ pack('after'=>f, 'side'=>'bottom', 'fill'=>'x')
+ }
+
+ return nil
+end
+
+def textWindOff (w)
+ if defined? $twind_scroll
+ begin
+ $twind_scroll.destroy
+ rescue
+ end
+ $twind_scroll = nil
+ end
+ w.xscrollcommand ''
+ w.wrap 'word'
+end
+
+def textWindPlot (t)
+ if (defined? $twind_plot) && TkWinfo.exist?($twind_plot)
+ return
+ end
+
+ $twind_plot = TkCanvas.new(t) {
+ relief 'sunken'
+ width 450
+ height 300
+ cursor 'top_left_arrow'
+ }
+
+ if $tk_version =~ /^4.*/
+ font = '-Adobe-Helvetica-Medium-R-Normal--*-180-*-*-*-*-*-*'
+ else
+ font = 'Helvetica 18'
+ end
+
+ TkcLine.new($twind_plot, 100, 250, 400, 250, 'width'=>2)
+ TkcLine.new($twind_plot, 100, 250, 100, 50, 'width'=>2)
+ TkcText.new($twind_plot, 225, 20,
+ 'text'=>"A Simple Plot", 'font'=>font, 'fill'=>'brown')
+
+ (0..10).each {|i|
+ x = 100 + (i * 30)
+ TkcLine.new($twind_plot, x, 250, x, 245, 'width'=>2)
+ TkcText.new($twind_plot, x, 254,
+ 'text'=>10*i, 'font'=>font, 'anchor'=>'n')
+ }
+ (0..5).each {|i|
+ y = 250 - (i * 40)
+ TkcLine.new($twind_plot, 100, y, 105, y, 'width'=>2)
+ TkcText.new($twind_plot, 96, y,
+ 'text'=>"#{i*50}.0", 'font'=>font, 'anchor'=>'e')
+ }
+
+ for xx, yy in [[12,56],[20,94],[33,98],[32,120],[61,180],[75,160],[98,223]]
+ x = 100 + (3*xx)
+ y = 250 - (4*yy)/5
+ item = TkcOval.new($twind_plot, x-6, y-6, x+6, y+6,
+ 'width'=>1, 'outline'=>'black', 'fill'=>'SkyBlue2')
+ item.addtag 'point'
+ end
+
+ $twind_plot.itembind('point', 'Any-Enter',
+ proc{$twind_plot.itemconfigure 'current', 'fill', 'red'})
+ $twind_plot.itembind('point', 'Any-Leave',
+ proc{$twind_plot.itemconfigure 'current', 'fill', 'SkyBlue2'})
+ $twind_plot.itembind('point', '1',
+ proc{|x,y| embPlotDown $twind_plot,x,y}, "%x %y")
+ $twind_plot.itembind('point', 'ButtonRelease-1',
+ proc{$twind_plot.dtag 'selected'})
+ $twind_plot.bind('B1-Motion',
+ proc{|x,y| embPlotMove $twind_plot,x,y}, "%x %y")
+ while ($twind_text.get($mark_plot) =~ /[ \t\n]/)
+ $twind_text.delete $mark_plot
+ end
+ $twind_text.insert $mark_plot,"\n"
+ TkTextWindow.new($twind_text, $mark_plot, 'window'=>$twind_plot)
+ $tag_center.add $mark_plot
+ $twind_text.insert $mark_plot,"\n"
+end
+
+$embPlot = {'lastX'=>0, 'lastY'=>0}
+
+def embPlotDown (w, x, y)
+ w.dtag 'selected'
+ w.addtag_withtag 'selected', 'current'
+ w.raise 'current'
+ $embPlot['lastX'] = x
+ $embPlot['lastY'] = y
+end
+
+def embPlotMove (w, x, y)
+ w.move 'selected', x - $embPlot['lastX'], y - $embPlot['lastY']
+ $embPlot['lastX'] = x
+ $embPlot['lastY'] = y
+end
+
+def textWindDel (w)
+ if (defined? $twind_text) && TkWinfo.exist?($twind_plot)
+ $twind_text.delete $twind_plot
+ $twind_plot = nil
+ while ($twind_text.get($mark_plot) =~ /[ \t\n]/)
+ $twind_text.delete $mark_plot
+ end
+ $twind_text.insert $mark_plot," "
+ end
+end
+
+def embDefBg (w)
+ w['background'] = w.configinfo('background')[3]
+end
diff --git a/jni/ruby/ext/tk/sample/demos-en/twind2.rb b/jni/ruby/ext/tk/sample/demos-en/twind2.rb
new file mode 100644
index 0000000..af7313d
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/demos-en/twind2.rb
@@ -0,0 +1,384 @@
+#
+# text (embedded windows) widget demo 2 (called by 'widget')
+#
+
+# delete toplevel widget
+if defined?($twind2_demo) && $twind2_demo
+ $twind2_demo.destroy
+ $twind2_demo = nil
+end
+
+# demo toplevel widget
+$twind2_demo = TkToplevel.new {|w|
+ title("Text Demonstration - Embedded Windows 2")
+ iconname("Embedded Windows")
+ positionWindow(w)
+}
+
+base_frame = TkFrame.new($twind2_demo).pack(:fill=>:both, :expand=>true)
+
+# frame
+$twind2_buttons = TkFrame.new(base_frame) {|frame|
+ TkGrid(TkFrame.new(frame, :height=>2, :relief=>:sunken, :bd=>2),
+ :columnspan=>4, :row=>0, :sticky=>'ew', :pady=>2)
+ TkGrid('x',
+ TkButton.new(frame, :text=>'See Code',
+ :image=>$image['view'], :compound=>:left,
+ :command=>proc{showCode 'twind2'}),
+ TkButton.new(frame, :text=>'Dismiss',
+ :image=>$image['delete'], :compound=>:left,
+ :command=>proc{
+ tmppath = $twind2_demo
+ $twind2_demo = nil
+ $showVarsWin[tmppath.path] = nil
+ tmppath.destroy
+ }),
+ :padx=>4, :pady=>4)
+ frame.grid_columnconfigure(0, :weight=>1)
+}
+$twind2_buttons.pack('side'=>'bottom', 'fill'=>'x', 'pady'=>'2m')
+
+# frame
+$twind2_text = nil
+TkFrame.new(base_frame, 'highlightthickness'=>2, 'borderwidth'=>2,
+ 'relief'=>'sunken') {|f|
+ $twind2_text = TkText.new(f, 'setgrid'=>true, 'font'=>$font,
+ # 'width'=>'70', 'height'=>35, 'wrap'=>'word',
+ 'width'=>'70', 'height'=>35, 'wrap'=>'char',
+ 'highlightthickness'=>0, 'borderwidth'=>0 ){|t|
+ TkScrollbar.new(f) {|s|
+ command proc{|*args| t.yview(*args)}
+ t.yscrollcommand proc{|first,last| s.set first,last}
+ }.pack('side'=>'right', 'fill'=>'y')
+ }.pack('expand'=>'yes', 'fill'=>'both')
+}.pack('expand'=>'yes', 'fill'=>'both')
+
+# text tags
+$tag2_center = TkTextTag.new($twind2_text,
+ 'justify' =>'center',
+ 'spacing1'=>'5m',
+ 'spacing3'=>'5m' )
+$tag2_buttons = TkTextTag.new($twind2_text,
+ 'lmargin1'=>'1c',
+ 'lmargin2'=>'1c',
+ 'rmargin' =>'1c',
+ 'spacing1'=>'3m',
+ 'spacing2'=>0,
+ 'spacing3'=>0 )
+
+# insert text
+$twind2_text.insert('end',
+ 'A text widget can contain many different kinds of items, ')
+$twind2_text.insert('end',
+ "both active and passive. It can lay these out in various ")
+$twind2_text.insert('end',
+ "ways, with wrapping, tabs, centering, etc. In addition, ")
+$twind2_text.insert('end',
+ "when the contents are too big for the window, smooth ")
+$twind2_text.insert('end', "scrolling in all directions is provided.\n\n")
+
+$twind2_text.insert('end', "A text widget can contain other widgets embedded ")
+$twind2_text.insert('end', "it. These are called \"embedded windows\", ")
+$twind2_text.insert('end', "and they can consist of arbitrary widgets. ")
+$twind2_text.insert('end', "For example, here are two embedded button ")
+$twind2_text.insert('end', "widgets. You can click on the first button to ")
+TkTextWindow.new($twind2_text, 'end',
+ 'window'=>TkButton.new($twind2_text) {
+ text 'ON'
+ command proc{textWindOn2 $twind2_text,$twind2_buttons}
+ cursor 'top_left_arrow'
+ })
+$twind2_text.insert('end', " horizontal scrolling, which also turns off ")
+$twind2_text.insert('end', "word wrapping. Or, you can click on the second ")
+$twind2_text.insert('end', "button to\n")
+TkTextWindow.new($twind2_text, 'end',
+ 'window'=>TkButton.new($twind2_text) {
+ text 'OFF'
+ command proc{textWindOff2 $twind2_text}
+ cursor 'top_left_arrow'
+ })
+$twind2_text.insert('end',
+ " horizontal scrolling and turn back on word wrapping.\n\n")
+
+$twind2_text.insert('end', "Or, here is another example. If you ")
+TkTextWindow.new($twind2_text, 'end',
+ 'window'=>TkButton.new($twind2_text) {
+ text 'Click Here'
+ command proc{textWindPlot2 $twind2_text}
+ cursor 'top_left_arrow'
+ })
+$twind2_text.insert('end',
+ " a canvas displaying an x-y plot will appear right here.")
+$mark2_plot = TkTextMark.new($twind2_text, 'insert')
+$mark2_plot.gravity='left'
+$twind2_text.insert('end',
+ " You can drag the data points around with the mouse, ")
+$twind2_text.insert('end', "or you can click here to ")
+TkTextWindow.new($twind2_text, 'end',
+ 'window'=>TkButton.new($twind2_text) {
+ text 'Delete'
+ command proc{textWindDel2 $twind2_text}
+ cursor 'top_left_arrow'
+ })
+$twind2_text.insert('end', " the plot again.\n\n")
+
+$twind2_text.insert('end',
+ "You may also find it useful to put embedded windows in ")
+$twind2_text.insert('end',
+ "a text without any actual text. In this case the ")
+$twind2_text.insert('end', "text widget acts like a geometry manager. For ")
+$twind2_text.insert('end',
+ "example, here is a collection of buttons laid out ")
+$twind2_text.insert('end',
+ "neatly into rows by the text widget. These buttons ")
+$twind2_text.insert('end',
+ "can be used to change the background color of the ")
+$twind2_text.insert('end', "text widget (\"Default\" restores the color to ")
+$twind2_text.insert('end',
+ "its default). If you click on the button labeled ")
+$twind2_text.insert('end', "\"Short\", it changes to a longer string so that ")
+$twind2_text.insert('end', "you can see how the text widget automatically ")
+$twind2_text.insert('end', "changes the layout. Click on the button again ")
+$twind2_text.insert('end', "to restore the short string.\n")
+
+btn_default = TkButton.new($twind2_text) {|b|
+ text 'Default'
+ command proc{embDefBg2 $twind2_text}
+ cursor 'top_left_arrow'
+}
+TkTextWindow.new($twind2_text, 'end', 'window'=>btn_default, 'padx'=>3)
+embToggle = TkVariable.new('Short')
+TkTextWindow.new($twind2_text, 'end',
+ 'window'=>TkCheckButton.new($twind2_text) {
+ textvariable embToggle
+ indicatoron 0
+ variable embToggle
+ onvalue 'A much longer string'
+ offvalue 'Short'
+ cursor 'top_left_arrow'
+ pady 5
+ padx 2
+ },
+ 'padx'=>3,
+ 'pady'=>2 )
+
+[ 'AntiqueWhite3', 'Bisque1', 'Bisque2', 'Bisque3', 'Bisque4',
+ 'SlateBlue3', 'RoyalBlue1', 'SteelBlue2', 'DeepSkyBlue3', 'LightBlue1',
+ 'DarkSlateGray1', 'Aquamarine2', 'DarkSeaGreen2', 'SeaGreen1',
+ 'Yellow1', 'IndianRed1', 'IndianRed2', 'Tan1', 'Tan4'
+].each{|twind_color|
+ TkTextWindow.new($twind2_text, 'end',
+ 'window'=>TkButton.new($twind2_text) {
+ text twind_color
+ cursor 'top_left_arrow'
+ command proc{$twind2_text.bg twind_color}
+ },
+ 'padx'=>3,
+ 'pady'=>2 )
+}
+
+$tag2_buttons.add(btn_default, 'end')
+
+$text_normal2 = {}
+$text_normal2['border'] = $twind2_text.cget('borderwidth')
+$text_normal2['highlight'] = $twind2_text.cget('highlightthickness')
+$text_normal2['pad'] = $twind2_text.cget('padx')
+
+$twind2_text.insert('end', "\nYou can also change the usual border width and ")
+$twind2_text.insert('end', "highlightthickness and padding.\n")
+
+TkTextWindow.new($twind2_text, 'end',
+ 'window'=>TkButton.new($twind2_text, :text=>"Big borders",
+ :cursor=>'top_left_arrow',
+ 'command'=>proc{
+ textWinBigB2 $twind2_text
+ }))
+
+TkTextWindow.new($twind2_text, 'end',
+ 'window'=>TkButton.new($twind2_text, :text=>"Small borders",
+ :cursor=>'top_left_arrow',
+ 'command'=>proc{
+ textWinSmallB2 $twind2_text
+ }))
+
+TkTextWindow.new($twind2_text, 'end',
+ 'window'=>TkButton.new($twind2_text, :text=>"Big highlight",
+ :cursor=>'top_left_arrow',
+ 'command'=>proc{
+ textWinBigH2 $twind2_text
+ }))
+
+TkTextWindow.new($twind2_text, 'end',
+ 'window'=>TkButton.new($twind2_text, :text=>"Small highlight",
+ :cursor=>'top_left_arrow',
+ 'command'=>proc{
+ textWinSmallH2 $twind2_text
+ }))
+
+TkTextWindow.new($twind2_text, 'end',
+ 'window'=>TkButton.new($twind2_text, :text=>"Big pad",
+ :cursor=>'top_left_arrow',
+ 'command'=>proc{
+ textWinBigP2 $twind2_text
+ }))
+
+TkTextWindow.new($twind2_text, 'end',
+ 'window'=>TkButton.new($twind2_text, :text=>"Small pad",
+ :cursor=>'top_left_arrow',
+ 'command'=>proc{
+ textWinSmallP2 $twind2_text
+ }))
+
+$twind2_text.insert('end',
+ "\n\nFinally, images fit comfortably in text widgets too:")
+
+TkTextImage.new($twind2_text, 'end',
+ 'image'=>TkBitmapImage.new(:file=>[
+ $demo_dir, '..',
+ 'images', 'face.xbm'
+ ].join(File::Separator)))
+
+# methods
+def textWinBigB2(w)
+ w.borderwidth 15
+end
+def textWinSmallB2(w)
+ w.borderwidth $text_normal2['border']
+end
+def textWinBigH2(w)
+ w.highlightthickness 15
+end
+def textWinSmallH2(w)
+ w.highlightthickness $text_normal2['highlight']
+end
+def textWinBigP2(w)
+ w.configure(:padx=>15, :pady=>15)
+end
+def textWinSmallP2(w)
+ w.configure(:padx=>$text_normal2['pad'], :pady=>$text_normal2['pad'])
+end
+
+def textWindOn2 (w,f)
+ if defined? $twind2_scroll
+ begin
+ $twind2_scroll.destroy
+ rescue
+ end
+ $twind2_scroll = nil
+ end
+
+ base = TkWinfo.parent( TkWinfo.parent(w) )
+ $twind2_scroll = TkScrollbar.new(base) {|s|
+ orient 'horizontal'
+ command proc{|*args| w.xview(*args)}
+ w.xscrollcommand proc{|first,last| s.set first,last}
+ w.wrap 'none'
+ pack('after'=>f, 'side'=>'bottom', 'fill'=>'x')
+ }
+
+ return nil
+end
+
+def textWindOff2 (w)
+ if defined? $twind2_scroll
+ begin
+ $twind2_scroll.destroy
+ rescue
+ end
+ $twind2_scroll = nil
+ end
+ w.xscrollcommand ''
+ #w.wrap 'word'
+ w.wrap 'char'
+end
+
+def textWindPlot2 (t)
+ if (defined? $twind2_plot) && (TkWinfo.exist?($twind2_plot))
+ return
+ end
+
+ $twind2_plot = TkCanvas.new(t) {
+ relief 'sunken'
+ width 450
+ height 300
+ cursor 'top_left_arrow'
+ }
+
+ #font = '-Adobe-Helvetica-Medium-R-Normal--*-180-*-*-*-*-*-*'
+ font = 'Helvetica 18'
+
+ TkcLine.new($twind2_plot, 100, 250, 400, 250, 'width'=>2)
+ TkcLine.new($twind2_plot, 100, 250, 100, 50, 'width'=>2)
+ TkcText.new($twind2_plot, 225, 20,
+ 'text'=>"A Simple Plot", 'font'=>font, 'fill'=>'brown')
+
+ (0..10).each {|i|
+ x = 100 + (i * 30)
+ TkcLine.new($twind2_plot, x, 250, x, 245, 'width'=>2)
+ TkcText.new($twind2_plot, x, 254,
+ 'text'=>10*i, 'font'=>font, 'anchor'=>'n')
+ }
+ (0..5).each {|i|
+ y = 250 - (i * 40)
+ TkcLine.new($twind2_plot, 100, y, 105, y, 'width'=>2)
+ TkcText.new($twind2_plot, 96, y,
+ 'text'=>"#{i*50}.0", 'font'=>font, 'anchor'=>'e')
+ }
+
+ for xx, yy in [[12,56],[20,94],[33,98],[32,120],[61,180],[75,160],[98,223]]
+ x = 100 + (3*xx)
+ y = 250 - (4*yy)/5
+ item = TkcOval.new($twind2_plot, x-6, y-6, x+6, y+6,
+ 'width'=>1, 'outline'=>'black', 'fill'=>'SkyBlue2')
+ item.addtag 'point'
+ end
+
+ $twind2_plot.itembind('point', 'Any-Enter',
+ proc{$twind2_plot.itemconfigure 'current', 'fill', 'red'})
+ $twind2_plot.itembind('point', 'Any-Leave',
+ proc{$twind2_plot.itemconfigure 'current', 'fill', 'SkyBlue2'})
+ $twind2_plot.itembind('point', '1',
+ proc{|x,y| embPlotDown2 $twind2_plot,x,y}, "%x %y")
+ $twind2_plot.itembind('point', 'ButtonRelease-1',
+ proc{$twind2_plot.dtag 'selected'})
+ $twind2_plot.bind('B1-Motion',
+ proc{|x,y| embPlotMove2 $twind2_plot,x,y}, "%x %y")
+ while ($twind2_text.get($mark2_plot) =~ /[ \t\n]/)
+ $twind2_text.delete $mark2_plot
+ end
+ $twind2_text.insert $mark2_plot,"\n"
+ TkTextWindow.new($twind2_text, $mark2_plot, 'window'=>$twind2_plot)
+ $tag2_center.add $mark2_plot
+ $twind2_text.insert $mark2_plot,"\n"
+end
+
+$embPlot2 = {'lastX'=>0, 'lastY'=>0}
+
+def embPlotDown2 (w, x, y)
+ w.dtag 'selected'
+ w.addtag_withtag 'selected', 'current'
+ w.raise 'current'
+ $embPlot2['lastX'] = x
+ $embPlot2['lastY'] = y
+end
+
+def embPlotMove2 (w, x, y)
+ w.move 'selected', x - $embPlot2['lastX'], y - $embPlot2['lastY']
+ $embPlot2['lastX'] = x
+ $embPlot2['lastY'] = y
+end
+
+def textWindDel2 (w)
+ if (defined? $twind2_text) && TkWinfo.exist?($twind2_plot)
+ $twind2_text.delete $twind2_plot
+ $twind2_plot = nil
+ while ($twind2_text.get($mark2_plot) =~ /[ \t\n]/)
+ $twind2_text.delete $mark2_plot
+ end
+ $twind2_text.insert $mark2_plot," "
+ end
+end
+
+def embDefBg2 (w)
+ w['background'] = w.configinfo('background')[3]
+end
diff --git a/jni/ruby/ext/tk/sample/demos-en/unicodeout.rb b/jni/ruby/ext/tk/sample/demos-en/unicodeout.rb
new file mode 100644
index 0000000..ee7b5af
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/demos-en/unicodeout.rb
@@ -0,0 +1,114 @@
+# unicodeout.rb --
+#
+# This demonstration script shows how you can produce output (in label
+# widgets) using many different alphabets.
+#
+# based on Tcl/Tk8.4.4 widget demos
+
+if defined?($unicodeout_demo) && $unicodeout_demo
+ $unicodeout_demo.destroy
+ $unicodeout_demo = nil
+end
+
+$unicodeout_demo = TkToplevel.new {|w|
+ title("Unicode Label Demonstration")
+ iconname("unicodeout")
+ positionWindow(w)
+}
+
+base_frame = TkFrame.new($unicodeout_demo).pack(:fill=>:both, :expand=>true)
+
+TkLabel.new(base_frame,
+ :font=>$font, :wraplength=>'5.4i', :justify=>:left,
+ :text=><<EOL).pack(:side=>:top)
+This is a sample of Tk's support for languages that use non-Western \
+character sets. However, what you will actually see below depends \
+largely on what character sets you have installed, and what you see \
+for characters that are not present varies greatly between platforms as well. \
+Please try to click the 'See Code' button, \
+and click the 'Rerun Demo' button after editing \
+(the source file is not changed) \
+the definition of @@font on the Unicodeout_SampleFrame class.
+The strings are written in Tcl using UNICODE characters \
+using the \\uXXXX escape so as to do so in a portable fashion.
+
+ATTENTION:
+The strings are converted to the encoded string objects \
+(completed to rewrite Tcl's escapes) by Tk::UTF8_String method. \
+And the Tk::UTF8_String objects are passed to the label widgets.
+EOL
+
+TkFrame.new(base_frame){|f|
+ pack(:side=>:bottom, :fill=>:x, :pady=>'2m')
+
+ TkButton.new(f, :text=>'Dismiss', :width=>15, :command=>proc{
+ $unicodeout_demo.destroy
+ $unicodeout_demo = nil
+ }).pack(:side=>:left, :expand=>true)
+
+ TkButton.new(f, :text=>'See Code', :width=>15, :command=>proc{
+ showCode 'unicodeout'
+ }).pack(:side=>:left, :expand=>true)
+}
+
+wait_msg = TkLabel.new(base_frame,
+ :text=>"Please wait while loading fonts...",
+ :font=>"Helvetica 12 italic").pack
+
+class Unicodeout_SampleFrame < TkFrame
+ @@font = $font
+ # @@font = 'Helvetica 14'
+ # @@font = 'Courier 12'
+ # @@font = 'clearlyu 16'
+ # @@font = 'fixed 12'
+ # @@font = 'Times 12'
+ # @@font = 'Newspaper 12'
+ # @@font = '{New century schoolbook} 12'
+
+ def initialize(base)
+ super(base)
+ grid_columnconfig(1, :weight=>1)
+ end
+
+ def add_sample(lang, *args)
+ sample_txt = Tk::UTF8_String(args.join(''))
+ l = TkLabel.new(self, :font=>@@font, :text=>lang+':',
+ :anchor=>:nw, :pady=>0)
+ #s = TkLabel.new(self, :font=>@@font, :text=>sample_txt,
+ s = TkLabel.new(self, :font=>TkFont.new(@@font), :text=>sample_txt,
+ :anchor=>:nw, :width=>30, :pady=>0)
+ Tk.grid(l, s, :sticky=>:ew, :pady=>0)
+ l.grid_config(:padx, '1m')
+ end
+end
+f = Unicodeout_SampleFrame.new(base_frame)
+f.pack(:expand=>true, :fill=>:both, :padx=>'2m', :pady=>'1m')
+
+# Processing when some characters are missing might take a while, so make
+# sure we're displaying something in the meantime...
+
+oldCursor = $unicodeout_demo.cursor
+$unicodeout_demo.cursor('watch')
+Tk.update
+
+f.add_sample('Arabic',
+ '\uFE94\uFEF4\uFE91\uFEAE\uFECC\uFEDF\uFE8D\uFE94',
+ '\uFEE4\uFEE0\uFEDC\uFEDF\uFE8D')
+f.add_sample('Trad. Chinese', '\u4E2D\u570B\u7684\u6F22\u5B57')
+f.add_sample('Simpl. Chinese', '\u6C49\u8BED')
+f.add_sample('Greek',
+ '\u0395\u03BB\u03BB\u03B7\u03BD\u03B9\u03BA\u03AE ',
+ '\u03B3\u03BB\u03CE\u03C3\u03C3\u03B1')
+f.add_sample('Hebrew',
+ '\u05DD\u05D9\u05DC\u05E9\u05D5\u05E8\u05D9 ',
+ '\u05DC\u05D9\u05D0\u05E8\u05E9\u05D9')
+f.add_sample('Japanese',
+ '\u65E5\u672C\u8A9E\u306E\u3072\u3089\u304C\u306A, ',
+ '\u6F22\u5B57\u3068\u30AB\u30BF\u30AB\u30CA')
+f.add_sample('Korean', '\uB300\uD55C\uBBFC\uAD6D\uC758 \uD55C\uAE00')
+f.add_sample('Russian',
+ '\u0420\u0443\u0441\u0441\u043A\u0438\u0439 ',
+ '\u044F\u0437\u044B\u043A')
+
+wait_msg.destroy
+$unicodeout_demo.cursor(oldCursor)
diff --git a/jni/ruby/ext/tk/sample/demos-en/vscale.rb b/jni/ruby/ext/tk/sample/demos-en/vscale.rb
new file mode 100644
index 0000000..b05ed12
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/demos-en/vscale.rb
@@ -0,0 +1,79 @@
+# vscale.rb
+#
+# This demonstration script shows an example with a vertical scale.
+
+require "tkcanvas"
+
+if defined?($vscale_demo) && $vscale_demo
+ $vscale_demo.destroy
+ $vscale_demo = nil
+end
+
+$vscale_demo = TkToplevel.new {|w|
+ title("Vertical Scale Demonstration")
+ iconname("vscale")
+}
+positionWindow($vscale_demo)
+
+base_frame = TkFrame.new($vscale_demo).pack(:fill=>:both, :expand=>true)
+
+msg = TkLabel.new(base_frame) {
+ font $font
+ wraplength '3.5i'
+ justify 'left'
+ text "An arrow and a vertical scale are displayed below. If you click or drag mouse button 1 in the scale, you can change the size of the arrow."
+}
+msg.pack('side'=>'top', 'padx'=>'.5c')
+
+TkFrame.new(base_frame) {|frame|
+ TkButton.new(frame) {
+ text 'Dismiss'
+ command proc {
+ tmppath = $vscale_demo
+ $vscale_demo = nil
+ tmppath.destroy
+ }
+ }.pack('side'=>'left', 'expand'=>'yes')
+
+ TkButton.new(frame) {
+ text 'Show Code'
+ command proc { showCode 'vscale' }
+ }.pack('side'=>'left', 'expand'=>'yes')
+}.pack('side'=>'bottom', 'fill'=>'x', 'pady'=>'2m')
+
+def setHeight(w, height)
+ height = height + 21
+ y2 = height - 30
+ if y2 < 21
+ y2 = 21
+ end
+ w.coords 'poly',15,20,35,20,35,y2,45,y2,25,height,5,y2,15,y2,15,20
+ w.coords 'line',15,20,35,20,35,y2,45,y2,25,height,5,y2,15,y2,15,20
+end
+
+TkFrame.new(base_frame) {|frame|
+ borderwidth 10
+ canvas = TkCanvas.new(frame) {|c|
+ width 50
+ height 50
+ bd 0
+ highlightthickness 0
+ TkcPolygon.new(c, 0, 0, 1, 1, 2, 2) {
+ fill 'SeaGreen3'
+ tags 'poly'
+ }
+ TkcLine.new(c, 0, 0, 1, 1, 2, 2, 0, 0) {
+ fill 'black'
+ tags 'line'
+ }
+ }.pack('side'=>'left', 'anchor'=>'nw', 'fill'=>'y')
+ scale = TkScale.new(frame) {
+ orient 'vertical'
+ length 284
+ from 0
+ to 250
+ command proc{|value| setHeight(canvas, value)}
+ tickinterval 50
+ }.pack('side'=>'left', 'anchor'=>'ne')
+ scale.set 75
+}.pack
diff --git a/jni/ruby/ext/tk/sample/demos-en/widget b/jni/ruby/ext/tk/sample/demos-en/widget
new file mode 100644
index 0000000..fb49a74
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/demos-en/widget
@@ -0,0 +1,1087 @@
+#!/usr/bin/env ruby
+
+# widget --
+# This script demonstrates the various widgets provided by Tk,
+# along with many of the features of the Tk toolkit. This file
+# only contains code to generate the main window for the
+# application, which invokes individual demonstrations. The
+# code for the actual demonstrations is contained in separate
+# ".rb" files is this directory, which are sourced by this script
+# as needed.
+
+require 'tk'
+# require 'tkafter'
+
+### $DEBUG=1 ##########
+
+$RubyTk_WidgetDemo = true
+
+#----------------------------------------------------------------
+# The code below create the main window, consisting of a menu bar
+# and a text widget that explains how to use the program, plus lists
+# all of the demos as hypertext items.
+#----------------------------------------------------------------
+
+# widget demo directory
+# $demo_dir = File.dirname($0)
+$demo_dir = File.dirname(__FILE__)
+
+# root
+$root = TkRoot.new{title "Ruby/Tk Widget Demonstration"}
+
+# tk
+$tk_version = Tk::TK_VERSION
+$tk_major_ver, $tk_minor_ver = $tk_version.split('.').map{|n| n.to_i}
+$tk_patchlevel = Tk::TK_PATCHLEVEL
+
+# tcl_platform
+$tk_platform = TkVarAccess.new('tcl_platform')
+
+#
+case($tk_version)
+when /^4.*/
+ $font = TkFont.new('-*-Helvetica-Medium-R-Normal--*-140-*-*-*-*-*-*', nil)
+else
+ $font = TkFont.new('Helvetica -12')
+end
+
+# images
+$image = {}
+
+if $tk_major_ver >= 8
+$image['refresh'] = TkPhotoImage.new(:height=>16, :format=>'GIF', :data=><<EOD)
+ R0lGODlhEAAQAPMAAMz/zCpnKdb/1z9mPypbKBtLGy9NMPL/9Or+6+P+4j1Y
+ PwQKBP7//xMLFAYBCAEBASH5BAEAAAAALAAAAAAQABAAAwR0EAD3Gn0Vyw0e
+ ++CncU7IIAezMA/nhUqSLJizvSdCEEjy2ZIV46AwDAoDHwPYGSoEiUJAAGJ6
+ EDHBNCFINW5OqABKSFk/B9lUa94IDwIFgewFMwQDQwCZQCztTgM9Sl8SOEMG
+ KSAthiaOjBMPDhQONBiXABEAOw==
+EOD
+end
+
+if $tk_major_ver >= 8
+$image['view'] = TkPhotoImage.new(:height=>16, :format=>'GIF', :data=><<EOD)
+ R0lGODlhEAAQAPMAAMz/zP///8DAwICAgH9/fwAAAAAAAAAAAAAAAAAAAAAA
+ AAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAwRIcMhJB7h3hM33
+ KFjWdQQYap1QrCaGBmrRrS4nj5b53jOgbwXBKGACoYLDIuAoHCmZyYvR1rT5
+ RMAq8LqcIYGsrjPsW1XOmFUEADs=
+EOD
+end
+
+if $tk_major_ver >= 8
+$image['delete'] = TkPhotoImage.new(:height=>16, :format=>'GIF', :data=><<EOD)
+ R0lGODlhEAAOAKEAAIQAAO/n3v///////yH5BAEKAAIALAAAAAAQAA4AAAIm
+ lI9pAKHbIHNoVhYhTdjlJ2AWKG2g+CldmB6rxo2uybYhbS80eRQAOw==
+EOD
+end
+
+if $tk_major_ver >= 8
+$image['print'] = TkPhotoImage.new(:height=>19, :format=>'GIF', :data=><<EOD)
+ R0lGODlhGgATAPcAACEQOTEpQjEpUkIpc0IxY0I5c0oxjEo5SlJCY1JCe1JK
+ UlpChFpCjFpGkFpSc1paa2NKc2NKnGNja2tapWtjc29KnHNanHNjc3NjrXNr
+ jHNrnHNzc3tjpXtrtXtzhICAgIRzvYSEjIZzqox7tYyEnIyMjJSEtZSEvZSM
+ lJyMtZyMvZyUlJyUrZyUvZycnKWctaWlpa2czq2lzrWtvbWtzrW1tb21xr21
+ 1sa9zs693s7OztbO3tbO597W1t7W7+fe7+fn5////+/n7+/v7+/v9////wAA
+ AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+ AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+ AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+ AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+ AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+ AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+ AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+ AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+ AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+ AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+ AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+ AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+ AAAAAAAAAAAAAAAAAAAAACH5BAEAAEEALAAAAAAaABMAQAj/AIMIHBhkg0GC
+ CBMGIQEiQgseQT4oeCBBAokgRYYQ0JBixg8hRIiUUEBBYYmTByBwiCBCRYwH
+ CxY8cKFw4AogRXLqLAJkQ80gCBBg3BkxZswTNGh4MGqgQQUMJRHCwMkTSE+D
+ Pn8eCKBhxIMhO3ei2OHDBw6sWSlMMMoWgwwfMDZI8GBjx44NARZwEGGi5MkS
+ PcIWKRGz5YgLbAco+KkQBQoJIRgjdGEVq+SaJajqtNrzMgsPCmoIzqmDgmWE
+ KOBuUKAAwYabYTfs4OHjY0giGyhk4MAWRI4eKyRQqPgggYUXPH4A+XBAgwoK
+ DiIsCFxjA9sFEVQQCRJCAYAFDJxiKhAxvMTonEFimrhhYinTBgWiCvxLNX3M
+ DkkpsKV5OYhjBxCMYAICAigUEAA7
+EOD
+end
+
+#
+if $tk_major_ver >= 8
+ $root.add_menubar([[['File', 0],
+ ['About ... ', proc{aboutBox}, 0, '<F1>'],
+ '---',
+ ['Quit', proc{exit}, 0, 'Ctrl-Q']
+ ]])
+else
+ TkMenubar.new($root,
+ [[['File', 0],
+ ['About ... ', proc{aboutBox}, 0, '<F1>'],
+ '---',
+ ['Quit', proc{exit}, 0, 'Ctrl-Q']
+ ]]).pack('side'=>'top', 'fill'=>'x')
+end
+$root.bind('F1', proc{aboutBox})
+$root.bind('Control-q', proc{exit})
+
+=begin
+TkFrame.new($root){|frame|
+ TkMenubutton.new(frame){|button|
+ m = TkMenu.new(button) {
+ add 'command', 'label'=>'Quit', 'command'=>proc{exit}, 'underline'=>0
+ }
+ menu m
+ text 'File'
+ underline 0
+ }.pack('side'=>'left')
+}.pack('side'=>'top', 'fill'=>'x')
+=end
+
+#
+if $tk_version =~ /^4\.[01]/
+ scr = TkScrollbar.new($root, 'orient'=>'vertical')
+ txt = TkText.new($root) {
+ wrap 'word'
+ width 70
+ height 30
+ font $font
+ setgrid 'yes'
+ yscrollcommand proc{|first,last| scr.set first,last}
+ }
+ scr.command(proc{|*args| txt.yview(*args)})
+ scr.pack('side'=>'right', 'fill'=>'y')
+ txt.pack('expand'=>'yes', 'fill'=>'both')
+else
+ textFrame = TkFrame.new($root)
+ scr = TkScrollbar.new($root, 'orient'=>'vertical',
+ 'highlightthickness'=>0, 'takefocus'=>1) {
+ pack('in'=>textFrame, 'side'=>'right', 'fill'=>'y', 'padx'=>1)
+ }
+ txt = TkText.new($root) {
+ wrap 'word'
+ width 70
+ height 30
+ font $font
+ setgrid 'yes'
+ highlightthickness 0
+ padx 4
+ pady 2
+ takefocus 0
+ bd 1
+ yscrollcommand proc{|first,last| scr.set first,last}
+ }
+ scr.command(proc{|*args| txt.yview(*args)})
+# txt.pack('in'=>textFrame, 'expand'=>'yes', 'fill'=>'both', 'padx'=>1)
+# txt.pack('in'=>textFrame, 'expand'=>'yes', 'fill'=>'both')
+# textFrame.pack('expand'=>'yes', 'fill'=>'both', 'padx'=>1, 'pady'=>2)
+ textFrame.pack('expand'=>'yes', 'fill'=>'both')
+ # $root.withdraw.deiconify
+ Tk.update_idletasks
+ txt.pack('in'=>textFrame, 'expand'=>'yes', 'fill'=>'both')
+
+ statusBar = TkFrame.new($root) {|f|
+ if $tk_version =~ /^4.*/
+ statusfont = '-*-Helvetica-Medium-R-Normal--*-120-*-*-*-*-*-*'
+ else
+ statusfont = 'Helvetica 10'
+ end
+ $statusBarLabel = \
+ TkLabel.new(f, 'text'=>" ", 'relief'=>'sunken', 'bd'=>1, 'anchor'=>'w',
+ 'font'=>statusfont) \
+ .pack('side'=>'left', 'padx'=>2, 'expand'=>'yes', 'fill'=>'both')
+ TkLabel.new(f, 'width'=>8, 'relief'=>'sunken', 'bd'=>1, 'anchor'=>'w',
+ 'font'=>statusfont) \
+ .pack('side'=>'left', 'padx'=>2)
+ }.pack('side'=>'bottom', 'fill'=>'x', 'pady'=>2)
+end
+
+# Create a bunch of tags to use in the text widget, such as those for
+# section titles and demo descriptions. Also define the bindings for
+# tags.
+
+if $tk_version =~ /^4.*/
+ tag_title = TkTextTag.new(txt, 'font'=>'-*-Helvetica-Bold-R-Normal--*-180-*-*-*-*-*-*')
+else
+ tag_title = TkTextTag.new(txt, 'font'=>'Helvetica 18 bold')
+end
+
+# We put some "space" characters to the left and right of each demo description
+# so that the descriptions are highlighted only when the mouse cursor
+# is right over them (but not when the cursor is to their left or right)
+
+tag_demospace = TkTextTag.new(txt, 'lmargin1'=>'1c', 'lmargin2'=>'1c')
+
+if TkWinfo.depth($root) == 1
+ tag_demo = TkTextTag.new(txt, 'lmargin1'=>'1c', 'lmargin2'=>'1c',
+ 'underline'=>1)
+ $tag_visited = TkTextTag.new(txt, 'lmargin1'=>'1c', 'lmargin2'=>'1c',
+ 'underline'=>1)
+ tag_hot = TkTextTag.new(txt, 'background'=>'black', 'foreground'=>'white')
+else
+ tag_demo = TkTextTag.new(txt, 'lmargin1'=>'1c', 'lmargin2'=>'1c',
+ 'foreground'=>'blue', 'underline'=>1)
+ $tag_visited = TkTextTag.new(txt, 'lmargin1'=>'1c', 'lmargin2'=>'1c',
+ 'foreground'=>'#303080', 'underline'=>1)
+# tag_hot = TkTextTag.new(txt, 'relief'=>'raised', 'borderwidth'=>1,
+# 'background'=>'SeaGreen3')
+ tag_hot = TkTextTag.new(txt, 'borderwidth'=>1, 'foreground'=>'red')
+end
+
+#tag_demo.bind('Button-1', proc{invoke txt, txt.index('current')})
+tag_demo.bind('ButtonRelease-1',
+ proc{|x,y|invoke txt, txt.index("@#{x},#{y}")}, '%x %y')
+
+lastLine = TkVariable.new("")
+newLine = TkVariable.new("")
+tag_demo.bind('Enter', proc{|x,y|
+ lastLine.value = txt.index("@#{x},#{y} linestart")
+ tag_hot.add(lastLine.value, "#{lastLine.value} lineend")
+ showStatus txt, txt.index("@#{x},#{y}")
+ },
+ '%x %y')
+tag_demo.bind('Leave',
+ proc{
+ tag_hot.remove('1.0','end')
+ txt.configure('cursor','xterm')
+ $statusBarLabel.configure('text'=>"")
+ })
+tag_demo.bind('Motion', proc{|x, y|
+ newLine.value = txt.index("@#{x},#{y} linestart")
+ if newLine.value != lastLine.value
+ tag_hot.remove('1.0','end')
+ lastLine.value = newLine.value
+ if ( txt.tag_names("@#{x},#{y}").find{|t|
+ t.kind_of?(String) && t =~ /^demo-/
+ } )
+ tag_hot.add(lastLine.value,
+ "#{lastLine.value} lineend -1 chars")
+ end
+ end
+ showStatus txt, txt.index("@#{x},#{y}")
+ },
+ '%x %y')
+
+# Create the text for the text widget.
+
+txt.insert('end', "Ruby/Tk Widget Demonstrations\n\n", tag_title)
+txt.insert('end', <<EOT)
+This application provides a front end for several short scripts that \
+demonstrate what you can do with Tk widgets. Each of the numbered \
+lines below describes a demonstration; you can click on it to invoke \
+the demonstration. Once the demonstration window appears, you can \
+click the "See Code" button to see the Ruby/Tk code that created the \
+demonstration. If you wish, you can edit the code and click the \
+"Rerun Demo" button in the code window to reinvoke the demonstration \
+with the modified code. \
+Don't worry about breaking the source code. \
+Your modifications are not reflected on the original file. \
+Please try many kind of changes.
+
+Some demo scripts require the recent version of Tk library \
+(e.g. Tk8.4 or later) \
+If your Tk library linked to Ruby doesn't support the functions \
+required by the demo script, the demo doesn't work. \
+In such a case, please re-compile tcltklib with the later Tk library \
+which supports the required functions.
+
+If your Tk supports Ttk (Tile) extension (included or installed), \
+please try the demo of Ttk extension (sample/tkextlib/tile/demo.rb) too.
+( Probably, Ttk extension \
+#{
+begin
+ require 'tkextlib/tile'
+ "is already installed on your environment"
+rescue
+ "is not installed on your environment yet"
+end
+}\
+. )
+Ttk extension is a standard feature of Tk8.5 or later.
+
+
+EOT
+
+txt.insert('end', "Labels, buttons, checkbuttons, and radiobuttons.\n", tag_title)
+txt.insert('end', " \n ", tag_demospace)
+txt.insert('end', "1. Labels (text and bitmaps).\n", tag_demo, "demo-label")
+txt.insert('end', " \n ", tag_demospace)
+txt.insert('end', "2. Labels and UNICODE text. (if supported)\n", tag_demo, "demo-unicodeout")
+txt.insert('end', " \n ", tag_demospace)
+txt.insert('end', "3. Buttons.\n", tag_demo, "demo-button")
+txt.insert('end', " \n ", tag_demospace)
+txt.insert('end', "4. Checkbuttons (select any of a group).\n", tag_demo, "demo-check")
+txt.insert('end', " \n ", tag_demospace)
+txt.insert('end', "5. Checkbuttons (if supported).\n", tag_demo, "demo-check2")
+txt.insert('end', " \n ", tag_demospace)
+txt.insert('end', "6. Radiobuttons (select one of a group).\n", tag_demo, "demo-radio")
+txt.insert('end', " \n ", tag_demospace)
+txt.insert('end', "7. Radiobuttons (if supported 'compound' option).\n", tag_demo, "demo-radio2")
+txt.insert('end', " \n ", tag_demospace)
+txt.insert('end', "8. Radiobuttons (if supported).\n", tag_demo, "demo-radio3")
+txt.insert('end', " \n ", tag_demospace)
+txt.insert('end', "9. A 15-puzzle game made out of buttons.\n", tag_demo, "demo-puzzle")
+txt.insert('end', " \n ", tag_demospace)
+txt.insert('end', "10. Iconic buttons that use bitmaps.\n", tag_demo, "demo-icon")
+txt.insert('end', " \n ", tag_demospace)
+txt.insert('end', "11. Two labels displaying images.\n", tag_demo, "demo-image1")
+txt.insert('end', " \n ", tag_demospace)
+txt.insert('end', "12. A simple user interface for viewing images.\n", tag_demo, "demo-image2")
+txt.insert('end', " \n ", tag_demospace)
+txt.insert('end', "13. A simple user interface for viewing images. (if supported)\n", tag_demo, "demo-image3")
+txt.insert('end', " \n ", tag_demospace)
+txt.insert('end', "14. Labelled frames (if supported)\n", tag_demo, "demo-labelframe")
+txt.insert('end', " \n ", tag_demospace)
+txt.insert('end', "15. The simple Themed Tk widgets (require Tile/Ttk extension)\n", tag_demo, "demo-ttkbut")
+txt.insert('end', " \n ", tag_demospace)
+
+txt.insert('end', "\n")
+txt.insert('end', "Listboxes\n", tag_title)
+txt.insert('end', " \n ", tag_demospace)
+txt.insert('end', "1. 50 states.\n", tag_demo, "demo-states")
+txt.insert('end', " \n ", tag_demospace)
+txt.insert('end', "2. Colors: change the color scheme for the application.\n", "#{tag_demo.id} demo-colors")
+txt.insert('end', " \n ", tag_demospace)
+txt.insert('end', "3. A collection of famous sayings.\n", tag_demo, "demo-sayings")
+txt.insert('end', " \n ", tag_demospace)
+txt.insert('end', "4. A multi-column list of contries. (require Tile/Ttk extension)\n", tag_demo, "demo-mclist")
+txt.insert('end', " \n ", tag_demospace)
+txt.insert('end', "5. A directory browser tree. (require Tile/Ttk extension)\n", tag_demo, "demo-tree")
+txt.insert('end', " \n ", tag_demospace)
+
+txt.insert('end', "\n")
+txt.insert('end', "Entries and Spin-boxes\n", tag_title)
+txt.insert('end', " \n ", tag_demospace)
+txt.insert('end', "1. Without scrollbars.\n", tag_demo, "demo-entry1")
+txt.insert('end', " \n ", tag_demospace)
+txt.insert('end', "2. With scrollbars.\n", tag_demo, "demo-entry2")
+txt.insert('end', " \n ", tag_demospace)
+txt.insert('end',
+ "3. Validated entries and password fields. (if supported)\n",
+ tag_demo, "demo-entry3")
+txt.insert('end', " \n ", tag_demospace)
+txt.insert('end', "4. Spin-boxes. (if supported)\n", tag_demo, "demo-spin")
+txt.insert('end', " \n ", tag_demospace)
+txt.insert('end', "5. Combo-boxes. (require Tile/Ttk extension)\n", tag_demo, "demo-combo")
+txt.insert('end', " \n ", tag_demospace)
+txt.insert('end', "6. Simple Rolodex-like form.\n", tag_demo, "demo-form")
+txt.insert('end', " \n ", tag_demospace)
+
+txt.insert('end', "\n")
+txt.insert('end', "Text\n", tag_title)
+txt.insert('end', " \n ", tag_demospace)
+txt.insert('end', "1. Basic editable text.\n", tag_demo, "demo-text")
+txt.insert('end', " \n ", tag_demospace)
+txt.insert('end', "2. Text display styles.\n", tag_demo, "demo-style")
+txt.insert('end', " \n ", tag_demospace)
+txt.insert('end', "3. Hypertext (tag bindings).\n", tag_demo, "demo-bind")
+txt.insert('end', " \n ", tag_demospace)
+txt.insert('end', "4. A text widget with embedded windows.\n", tag_demo, "demo-twind")
+txt.insert('end', " \n ", tag_demospace)
+txt.insert('end', "5. A text widget with embedded windows. (if supported)\n", tag_demo, "demo-twind2")
+txt.insert('end', " \n ", tag_demospace)
+txt.insert('end', "6. A search tool built with a text widget.\n", tag_demo, "demo-search")
+txt.insert('end', " \n ", tag_demospace)
+txt.insert('end', "7. Peering text widgets. (if supported)\n", tag_demo, "demo-textpeer")
+txt.insert('end', " \n ", tag_demospace)
+
+txt.insert('end', "\n")
+txt.insert('end', "Canvases\n", tag_title)
+txt.insert('end', " \n ", tag_demospace)
+txt.insert('end', "1. The canvas item types.\n", tag_demo, "demo-items")
+txt.insert('end', " \n ", tag_demospace)
+txt.insert('end', "2. A simple 2-D plot.\n", tag_demo, "demo-plot")
+txt.insert('end', " \n ", tag_demospace)
+txt.insert('end', "3. Text items in canvases.\n", tag_demo, "demo-ctext")
+txt.insert('end', " \n ", tag_demospace)
+txt.insert('end', "4. An editor for arrowheads on canvas lines.\n", tag_demo, "demo-arrow")
+txt.insert('end', " \n ", tag_demospace)
+txt.insert('end', "5. A ruler with adjustable tab stops.\n", tag_demo, "demo-ruler")
+txt.insert('end', " \n ", tag_demospace)
+txt.insert('end', "6. A building floor plan.\n", tag_demo, "demo-floor")
+txt.insert('end', " \n ", tag_demospace)
+txt.insert('end', "7. A building floor plan. (another way to create canvas items)\n", tag_demo, "demo-floor2")
+txt.insert('end', " \n ", tag_demospace)
+txt.insert('end', "8. A simple scrollable canvas.\n", tag_demo, "demo-cscroll")
+txt.insert('end', " \n ", tag_demospace)
+txt.insert('end', "9. A Knight's tour of the chess board. (require Tile/Ttk extension)\n", tag_demo, "demo-knightstour")
+txt.insert('end', " \n ", tag_demospace)
+
+txt.insert('end', "\n")
+txt.insert('end', "Scales and Progress Bars\n", tag_title)
+txt.insert('end', " \n ", tag_demospace)
+txt.insert('end', "1. Vertical scale.\n", tag_demo.id, "demo-vscale")
+txt.insert('end', " \n ", tag_demospace)
+txt.insert('end', "2. Horizontal scale.\n", tag_demo.id, "demo-hscale")
+txt.insert('end', " \n ", tag_demospace)
+txt.insert('end', "3. Progress bar. (require Tile/Ttk extension)\n", tag_demo.id, "demo-ttkprogress")
+txt.insert('end', " \n ", tag_demospace)
+
+txt.insert('end', "\n")
+txt.insert('end', "Paned Windows and Notebooks\n", tag_title)
+txt.insert('end', " \n ", tag_demospace)
+txt.insert('end', "1. Horizontal paned window. (if supported)\n", tag_demo.id, "demo-paned1")
+txt.insert('end', " \n ", tag_demospace)
+txt.insert('end', "2. Vertical paned window. (if supported)\n", tag_demo.id, "demo-paned2")
+txt.insert('end', " \n ", tag_demospace)
+txt.insert('end', "3. Themed nested panes. (require Tile/Ttk extension)\n", tag_demo.id, "demo-ttkpane")
+txt.insert('end', " \n ", tag_demospace)
+txt.insert('end', "4. Notebook widget. (require Tile/Ttk extension)\n", tag_demo.id, "demo-ttknote")
+txt.insert('end', " \n ", tag_demospace)
+
+txt.insert('end', "\n")
+txt.insert('end', "Menus and Toolbars\n", tag_title)
+txt.insert('end', " \n ", tag_demospace)
+txt.insert('end', "1. Menus and cascades.\n", tag_demo, "demo-menu")
+txt.insert('end', " \n ", tag_demospace)
+txt.insert('end', "2. Menus and cascades. (if supported)\n", tag_demo, "demo-menu84")
+txt.insert('end', " \n ", tag_demospace)
+txt.insert('end', "3. Menubuttons.\n", tag_demo, "demo-menubu")
+txt.insert('end', " \n ", tag_demospace)
+txt.insert('end', "4. Themed menu buttons. (require Tile/Ttk extension)\n", tag_demo, "demo-ttkmenu")
+txt.insert('end', " \n ", tag_demospace)
+txt.insert('end', "5. Themed toolbar. (require Tile/Ttk extension)\n", tag_demo, "demo-toolbar")
+txt.insert('end', " \n ", tag_demospace)
+
+txt.insert('end', "\n")
+txt.insert('end', "Common Dialogs\n", tag_title)
+txt.insert('end', " \n ", tag_demospace)
+txt.insert('end', "1. Message boxes.\n", tag_demo, "demo-msgbox")
+txt.insert('end', " \n ", tag_demospace)
+txt.insert('end', "2. Message boxes with detail text. (if supported)\n", tag_demo, "demo-msgbox2")
+txt.insert('end', " \n ", tag_demospace)
+txt.insert('end', "3. File selection dialog.\n", tag_demo, "demo-filebox")
+txt.insert('end', " \n ", tag_demospace)
+txt.insert('end', "4. Color picker.\n", tag_demo, "demo-clrpick")
+txt.insert('end', " \n ", tag_demospace)
+
+txt.insert('end', "\n")
+txt.insert('end', "Animation\n", tag_title)
+txt.insert('end', " \n ", tag_demospace)
+txt.insert('end', "1. Animated labels (if supported)\n", tag_demo, "demo-anilabel")
+txt.insert('end', " \n ", tag_demospace)
+txt.insert('end', "2. Animated wave (if supported)\n", tag_demo, "demo-aniwave")
+txt.insert('end', " \n ", tag_demospace)
+txt.insert('end', "3. Pendulum simulation (if supported)\n", tag_demo, "demo-pendulum")
+txt.insert('end', " \n ", tag_demospace)
+txt.insert('end', "4. A celebration of Rube Goldberg (if supported)\n", tag_demo, "demo-goldberg")
+
+txt.insert('end', "\n")
+txt.insert('end', "Miscellaneous\n", tag_title)
+txt.insert('end', " \n ", tag_demospace)
+txt.insert('end', "1. The built-in bitmaps.\n", tag_demo, "demo-bitmap")
+txt.insert('end', " \n ", tag_demospace)
+txt.insert('end', "2. A dialog box with a local grab.\n", tag_demo, "demo-dialog1")
+txt.insert('end', " \n ", tag_demospace)
+txt.insert('end', "3. A dialog box with a global grab.\n", tag_demo, "demo-dialog2")
+txt.insert('end', " \n ", tag_demospace)
+
+txt.state('disabled')
+scr.focus
+
+# positionWindow --
+# This procedure is invoked by most of the demos to position a
+# new demo window.
+#
+# Arguments:
+# w - The name of the window to position.
+
+def positionWindow(w)
+ w.geometry('+300+300')
+end
+
+# showVars --
+# Displays the values of one or more variables in a window, and
+# updates the display whenever any of the variables changes.
+#
+# Arguments:
+# w - Name of new window to create for display.
+# args - Any number of names of variables.
+
+$showVarsWin = {}
+def showVars1(parent, *args)
+ if $showVarsWin[parent.path]
+ begin
+ $showVarsWin[parent.path].destroy
+ rescue
+ end
+ end
+ w = TkToplevel.new(parent) {|w|
+ title "Variable values"
+ base = TkFrame.new(w).pack(:fill=>:both, :expand=>true)
+ TkLabel.new(base) {
+ text "Variable values:"
+ width 20
+ anchor 'center'
+ if $tk_version =~ /^4.*/
+ font '-Adobe-helvetica-medium-r-normal--*-180-*-*-*-*-*-*'
+ else
+ font 'Helvetica 14'
+ end
+ }.pack('side'=>'top', 'fill'=>'x')
+ len = 1
+ args.each{|vnam,vbody|
+ len = vnam.to_s.length if vnam.to_s.length > len
+ }
+ args.each{|vnam,vbody|
+ TkFrame.new(w){|f|
+ #TkLabel.new(f, 'text'=>"#{vnam}: ").pack('side'=>'left')
+ TkLabel.new(f, 'text'=>"#{vnam}: ",'width'=>len+2).pack('side'=>'left')
+ TkLabel.new(f, 'textvariable'=>vbody, 'anchor'=>'w')\
+ .pack('side'=>'left', 'expand'=>'yes', 'fill'=>'x')
+ }.pack('side'=>'top', 'anchor'=>'w', 'fill'=>'x')
+ }
+ TkButton.new(base) {
+ text "OK"
+ command proc{w.destroy}
+ }.pack('side'=>'bottom', 'pady'=>2)
+ }
+ $showVarsWin[parent.path] = w
+end
+
+def showVars2(parent, *args)
+ if $showVarsWin[parent.path]
+ begin
+ $showVarsWin[parent.path].destroy
+ rescue
+ end
+ end
+ $showVarsWin[parent.path] = TkToplevel.new(parent) {|top|
+ title "Variable values"
+
+ base = TkFrame.new(top).pack(:fill=>:both, :expand=>true)
+
+ TkLabelFrame.new(base, :text=>"Variable values:",
+ :font=>{:family=>'Helvetica', :size=>14}){|f|
+ args.each{|vnam,vbody|
+ TkGrid(TkLabel.new(f, :text=>"#{vnam}: ", :anchor=>'w'),
+ TkLabel.new(f, :textvariable=>vbody, :anchor=>'w'),
+ :padx=>2, :pady=>2, :sticky=>'w')
+ }
+
+ f.grid(:sticky=>'news', :padx=>4)
+ f.grid_columnconfig(1, :weight=>1)
+ f.grid_rowconfig(100, :weight=>1)
+ }
+ TkButton.new(base, :text=>"OK", :width=>8, :default=>:active,
+ :command=>proc{top.destroy}){|b|
+ top.bind('Return', proc{b.invoke})
+ top.bind('Escape', proc{b.invoke})
+
+ b.grid(:sticky=>'e', :padx=>4, :pady=>[6, 4])
+ }
+ base.grid_columnconfig(0, :weight=>1)
+ base.grid_rowconfig(0, :weight=>1)
+ }
+end
+
+if $tk_major_ver < 8
+ alias showVars showVars1
+elsif $tk_major_ver == 8 && $tk_minor_ver < 4
+ alias showVars showVars1
+else # ver >= 8.4
+ alias showVars showVars2
+end
+
+# Pseudo-Toplevel support
+module PseudoToplevel_Evaluable
+ def pseudo_toplevel_eval(body = Proc.new)
+ Thread.current[:TOPLEVEL] = self
+ begin
+ body.call
+ ensure
+ Thread.current[:TOPLEVEL] = nil
+ end
+ end
+
+ def pseudo_toplevel_evaluable?
+ @pseudo_toplevel_evaluable
+ end
+ def pseudo_toplevel_evaluable=(mode)
+ @pseudo_toplevel_evaluable = (mode)? true: false
+ end
+
+ def self.extended(mod)
+ mod.__send__(:extend_object, mod)
+ mod.instance_variable_set('@pseudo_toplevel_evaluable', true)
+ end
+end
+
+class Object
+ alias __method_missing__ method_missing
+ private :__method_missing__
+
+ def method_missing(id, *args)
+ begin
+ has_top = (top = Thread.current[:TOPLEVEL]) &&
+ top.respond_to?(:pseudo_toplevel_evaluable?) &&
+ top.pseudo_toplevel_evaluable? &&
+ top.respond_to?(id)
+ rescue Exception => e
+ has_top = false
+ end
+
+ if has_top
+ top.__send__(id, *args)
+ else
+ __method_missing__(id, *args)
+ end
+ end
+end
+
+class Proc
+ def initialize(*args)
+ super
+ @__pseudo_toplevel__ = Thread.current[:TOPLEVEL]
+ end
+
+ alias __call__ call
+ def call(*args, &b)
+ if top = @__pseudo_toplevel__
+ orig_top = Thread.current[:TOPLEVEL]
+ Thread.current[:TOPLEVEL] = top
+ begin
+ __call__(*args, &b)
+ ensure
+ Thread.current[:TOPLEVEL] = orig_top
+ end
+ else
+ __call__(*args, &b)
+ end
+ end
+end
+
+def proc(&b)
+ Proc.new(&b)
+end
+def lambda(&b)
+ Proc.new(&b)
+end
+
+def _null_binding
+ Module.new.instance_eval{extend PseudoToplevel_Evaluable}
+ # binding
+ # Module.new.instance_eval{binding}
+end
+private :_null_binding
+
+def eval_samplecode(code, file=nil)
+ #eval(code)
+ #_null_binding.pseudo_toplevel_eval{ eval(code) }
+ #Thread.new{ _null_binding.pseudo_toplevel_eval{ eval(code) } }
+ Thread.new{
+ _null_binding.pseudo_toplevel_eval{
+ begin
+ if file
+ eval(code, binding, "(eval:#{file})")
+ else
+ eval(code)
+ end
+ rescue Exception=>e
+ #p e
+ TkBgError.show(e.class.inspect + ': ' + e.message + "\n" +
+ "\n---< backtrace of Ruby side >-----\n" +
+ e.backtrace.join("\n") +
+ "\n---< backtrace of Tk side >-------")
+ end
+ }
+ }
+ Tk.update rescue nil
+end
+
+# invoke --
+# This procedure is called when the user clicks on a demo description.
+# It is responsible for invoking the demonstration.
+#
+# Arguments:
+# txt - Name of text widget
+# index - The index of the character that the user clicked on.
+def invoke(txt, idx)
+ tag = txt.tag_names(idx).find{|t| t.kind_of?(String) && t =~ /^demo-/}
+ return unless tag
+
+ cursor = txt.cget('cursor')
+ txt.cursor('watch')
+ Tk.update rescue nil
+ # eval(IO.readlines("#{[$demo_dir, tag[5..-1]].join(File::Separator)}.rb").join, _null_binding)
+ # Tk.update
+ eval_samplecode(IO.readlines("#{[$demo_dir, tag[5..-1]].join(File::Separator)}.rb").join, tag[5..-1] + '.rb')
+ txt.cursor(cursor)
+
+ $tag_visited.add("#{idx} linestart +1 chars", "#{idx} lineend +1 chars")
+end
+=begin
+def invoke (txt, idx)
+ tag = txt.tag_names(idx).find{|t| t.kind_of?(String) && t =~ /^demo-/}
+ return unless tag
+ current_cursor = txt.cget('cursor')
+ txt.cursor('watch')
+ Tk.update
+# eval `cat #{tag[5..-1]}.rb`
+# eval `cat #{[$demo_dir, tag[5..-1]].join(File::Separator)}.rb`
+ eval IO.readlines("#{[$demo_dir, tag[5..-1]].join(File::Separator)}.rb").join
+ Tk.update
+# txt.cursor('xterm')
+ txt.cursor(current_cursor)
+
+ $tag_visited.add("#{idx} linestart +1 chars", "#{idx} lineend +1 chars")
+end
+=end
+# showStatus --
+#
+# Show the name of the demo program in the status bar. This procedure
+# is called when the user moves the cursor over a demo description.
+#
+
+def showStatus (txt, index)
+ tag = txt.tag_names(index).find{|t| t.kind_of?(String) && t =~ /^demo-/}
+ cursor = txt.cget('cursor')
+ unless tag
+ $statusBarLabel.configure('text', " ")
+ newcursor = 'xterm'
+ else
+ demoname = tag[5..-1]
+ $statusBarLabel.configure('text',
+ "Run the \"#{demoname}\" sample program")
+ newcursor = 'hand2'
+ end
+ txt.configure('cursor'=>newcursor) if cursor != newcursor
+end
+
+# showCode --
+# This procedure creates a toplevel window that displays the code for
+# a demonstration and allows it to be edited and reinvoked.
+#
+# Arguments:
+# demo - The name of the demonstration's window, which can be
+# used to derive the name of the file containing its code.
+
+def showCode1(demo)
+ file = "#{demo}.rb"
+ $code_window = nil unless defined? $code_window
+ if $code_window == nil || TkWinfo.exist?($code_window) == false
+ $code_window = TkToplevel.new(nil)
+ f = TkFrame.new($code_window)
+
+ TkButton.new(f) {
+ text "Dismiss"
+ command proc{
+ $code_window.destroy
+ $code_window = nil
+ }
+ }.pack('side'=>'right', 'expand'=>'false', 'pady'=>2, 'padx'=>25)
+ TkButton.new(f) {
+ text "Rerun Demo"
+ # command proc{eval($code_text.get('1.0','end'), _null_binding)}
+ command proc{eval_samplecode($code_text.get('1.0','end'), '<viewer>')}
+ }.pack('side'=>'right', 'expand'=>'false', 'pady'=>2)
+
+ TkLabel.new(f,'text'=>'line:').pack('side'=>'left')
+ linenum =TkLabel.new(f,'text'=>'').pack('side'=>'left')
+ TkLabel.new(f,'text'=>' pos:').pack('side'=>'left')
+ posnum =TkLabel.new(f,'text'=>'').pack('side'=>'left')
+
+ $set_linenum = proc{|w|
+ line, pos = w.index('insert').split('.')
+ linenum.text = line
+ posnum.text = pos
+ }
+
+ f.pack('side'=>'bottom', 'expand'=>'true', 'fill'=>'x')
+
+ if $tk_version =~ /^4\.[01]/
+ s = TkScrollbar.new($code_window, 'orient'=>'vertical')
+ $code_text = TkText.new($code_window) {
+ height 40
+ setgrid 'yes'
+ yscrollcommand proc{|first,last| s.set first,last}
+ }
+ s.command(proc{|*args| $code_text.yview(*args)})
+ s.pack('side'=>'right', 'fill'=>'y')
+ $code_text.pack('side'=>'left', 'expand'=>'yes', 'fill'=>'both')
+ else
+ TkFrame.new($code_window) {|f|
+ pack('expand'=>'yes', 'fill'=>'both', 'padx'=>1, 'pady'=>1)
+
+ hs = TkScrollbar.new($code_window, 'highlightthickness'=>0,
+ 'orient'=>'horizontal')
+ vs = TkScrollbar.new($code_window, 'highlightthickness'=>0,
+ 'orient'=>'vertical')
+ $code_text = TkText.new($code_window) {|t|
+ height 40
+ wrap 'word'
+ xscrollcommand proc{|first,last| hs.set first,last}
+ yscrollcommand proc{|first,last| vs.set first,last}
+ setgrid 'yes'
+ highlightthickness 0
+ pady 2
+ padx 3
+ hs.command(proc{|*args| $code_text.xview(*args)})
+ vs.command(proc{|*args| $code_text.yview(*args)})
+ }
+
+ $code_text.grid('in'=>f, 'padx'=>1, 'pady'=>1, 'row'=>0, 'column'=>0,
+ 'rowspan'=>1, 'columnspan'=>1, 'sticky'=>'news')
+ vs.grid('in'=>f, 'padx'=>1, 'pady'=>1, 'row'=>0, 'column'=>1,
+ 'rowspan'=>1, 'columnspan'=>1, 'sticky'=>'news')
+# xs.grid('in'=>f, 'padx'=>1, 'pady'=>1, 'row'=>1, 'column'=>0,
+# 'rowspan'=>1, 'columnspan'=>1, 'sticky'=>'news')
+
+# JKC 2001-07-26: segfaults under 1.7.1 (2001-06-19) [i686-linux]
+ TkGrid.rowconfigure(f, 0, 'weight'=>1, 'minsize'=>0)
+ TkGrid.columnconfigure(f, 0, 'weight'=>1, 'minsize'=>0)
+ }
+ end
+
+ btag = TkBindTag.new
+
+ btag.bind('Key', $set_linenum, '%W')
+ btag.bind('Button', $set_linenum, '%W')
+
+ btags = $code_text.bindtags
+ btags.insert(btags.index($code_text.class) + 1, btag)
+ $code_text.bindtags = btags
+
+ else
+ $code_window.deiconify
+ $code_window.raise
+ end
+
+ $code_window.title("Demo code: #{file}")
+ $code_window.iconname(file)
+# fid = open(file, 'r')
+ fid = open([$demo_dir, file].join(File::Separator), 'r')
+ $code_text.delete('1.0', 'end')
+ #$code_text.insert('1.0', `cat #{file}`)
+ $code_text.insert('1.0', fid.read)
+ #$code_mark = TkTextMark.new($code_text, '1.0')
+ #$code_text.set_insert('1.0')
+ TkTextMarkInsert.new($code_text,'1.0')
+
+ $set_linenum.call($code_text)
+
+ fid.close
+end
+
+def showCode2(demo)
+ file = "#{demo}.rb"
+ $code_window = nil unless defined? $code_window
+ if $code_window == nil || TkWinfo.exist?($code_window) == false
+ $code_window = TkToplevel.new(nil)
+ tf = TkFrame.new($code_window)
+ $code_text = TkText.new(tf, :font=>'Courier 10', :height=>30,
+ :wrap=>'word', :bd=>1, :setgrid=>true,
+ :highlightthickness=>0, :pady=>2, :padx=>3)
+ xscr = TkScrollbar.new(tf, :bd=>1){assign($code_text)}
+ yscr = TkScrollbar.new(tf, :bd=>1){assign($code_text)}
+ TkGrid($code_text, yscr, :sticky=>'news')
+ #TkGrid(xscr)
+ tf.grid_rowconfigure(0, :weight=>1)
+ tf.grid_columnconfigure(0, :weight=>1)
+
+ bf = TkFrame.new($code_window)
+
+ lf = TkFrame.new(bf)
+ TkLabel.new(lf, :text=>'line:').pack(:side=>:left)
+ linenum =TkLabel.new(lf, :text=>'').pack(:side=>:left)
+ TkLabel.new(lf, :text=>' pos:').pack(:side=>:left)
+ posnum =TkLabel.new(lf, :text=>'').pack(:side=>:left)
+
+ $set_linenum = proc{|w|
+ line, pos = w.index('insert').split('.')
+ linenum.text = line
+ posnum.text = pos
+ }
+
+ b_dis = TkButton.new(bf, :text=>'Dismiss', :default=>:active,
+ :command=>proc{
+ $code_window.destroy
+ $code_window = nil
+ },
+ :image=>$image['delete'], :compound=>:left)
+ b_prn = TkButton.new(bf, :text=>'Print Code',
+ :command=>proc{printCode($code_text, file)},
+ :image=>$image['print'], :compound=>:left)
+ b_run = TkButton.new(bf, :text=>'Rerun Demo',
+ :command=>proc{
+ # eval($code_text.get('1.0','end'), _null_binding)
+ eval_samplecode($code_text.get('1.0','end'), '<viewer>')
+ },
+ :image=>$image['refresh'], :compound=>:left)
+
+ TkGrid(lf, 'x', b_run, b_prn, b_dis, :padx=>4, :pady=>[6,4])
+ bf.grid_columnconfigure(1, :weight=>1)
+
+ TkGrid(tf, :sticky=>'news')
+ TkGrid(bf, :sticky=>'ew')
+ $code_window.grid_columnconfigure(0, :weight=>1)
+ $code_window.grid_rowconfigure(0, :weight=>1)
+
+ $code_window.bind('Return', proc{|win|
+ b_dis.invoke unless win.kind_of?(TkText)
+ }, '%W')
+ $code_window.bindinfo('Return').each{|cmd, arg|
+ $code_window.bind_append('Escape', cmd, arg)
+ }
+
+ btag = TkBindTag.new
+
+ btag.bind('Key', $set_linenum, '%W')
+ btag.bind('Button', $set_linenum, '%W')
+ btag.bind('Configure', $set_linenum, '%W')
+
+ btags = $code_text.bindtags
+ btags.insert(btags.index($code_text.class) + 1, btag)
+ $code_text.bindtags = btags
+
+ else
+ $code_window.deiconify
+ $code_window.raise
+ end
+
+ $code_window.title("Demo code: #{file}")
+ $code_window.iconname(file)
+ fid = open([$demo_dir, file].join(File::Separator), 'r')
+ $code_text.delete('1.0', 'end')
+ $code_text.insert('1.0', fid.read)
+ TkTextMarkInsert.new($code_text,'1.0')
+
+ $set_linenum.call($code_text)
+
+ fid.close
+end
+
+if $tk_major_ver < 8
+ alias showCode showCode1
+elsif $tk_major_ver == 8 && $tk_minor_ver < 4
+ alias showCode showCode1
+else # ver >= 8.4
+ alias showCode showCode2
+end
+
+
+# printCode --
+# Prints the source code currently displayed in the See Code dialog.
+# Much thanks to Arjen Markus for this.
+#
+# Arguments:
+# txt - Name of text widget containing code to print
+# file - Name of the original file (implicitly for title)
+
+def printCode(txt, file)
+ code = txt.get('1.0', 'end - 1c')
+ dir = '.'
+ dir = ENV['HOME'] if ENV['HOME']
+ dir = ENV['TMP'] if ENV['TMP']
+ dir = ENV['TEMP'] if ENV['TEMP']
+
+ fname = [dir, 'tkdemo-' + file].join(File::Separator)
+ open(fname, 'w'){|fid| fid.print(code)}
+ begin
+ case Tk::TCL_PLATFORM('platform')
+ when 'unix'
+ msg = `lp -c #{fname}`
+ unless $?.exitstatus == 0
+ Tk.messageBox(:title=>'Print spooling failure',
+ :message=>'Print spooling probably failed: ' + msg)
+ end
+ when 'windows'
+ begin
+ printTextWin32(fname)
+ rescue => e
+ Tk.messageBox(:title=>'Print spooling failure',
+ :message=>'Print spooling probably failed: ' +
+ e.message)
+ end
+ when 'macintosh'
+ Tk.messageBox(:title=>'Operation not Implemented',
+ :message=>'Oops, sorry: not implemented yet!')
+ else
+ Tk.messageBox(:title=>'Operation not Implemented',
+ :message=>'Wow! Unknown platform: ' +
+ Tk::TCL_PLATFORM('platform'))
+ end
+ ensure
+ File.delete(fname)
+ end
+end
+
+# printTextWin32 --
+# Print a file under Windows
+#
+# Arguments:
+# filename - Name of the file
+#
+def printTextWin32(fname)
+ require 'win32/registry'
+ begin
+ app = Win32::Registry::HKEY_CLASSES_ROOT['.txt']
+ pcmd = nil
+ Win32::Registry::HKEY_CLASSES_ROOT.open("#{app}\\shell\\print"){|reg|
+ pcmd = reg['command']
+ }
+ rescue
+ app = Tk.tk_call('auto_execok', 'notepad.exe')
+ pcmd = "#{app} /p %1"
+ end
+
+ pcmd.gsub!('%1', fname)
+ puts pcmd
+ cmd = Tk.tk_call('auto_execok', 'start') + ' /min ' + pcmd
+
+ msg = `#{cmd}`
+ unless $?.exitstatus == 0
+ fail RuntimeError, msg
+ end
+end
+
+# aboutBox
+#
+# Pops up a message box with an "about" message
+#
+def aboutBox
+ Tk.messageBox('icon'=>'info', 'type'=>'ok', 'title'=>'About Widget Demo',
+ 'message'=>"Ruby/Tk widget demonstration Ver.1.7.1-en\n\n" +
+ "based on demos of Tk8.1 -- 8.5 " +
+ "( Copyright of Tcl/Tk demos:: " +
+ "(c) 1996-1997 Sun Microsystems, Inc. / " +
+ "(c) 1997-2000 Ajuba Solutions, Inc. / " +
+ "(c) 2001-2007 Donal K. Fellows / " +
+ "(c) 2002-2007 Daniel A. Steffen )\n\n" +
+ "Your Ruby & Tk Version ::\n" +
+ "Ruby#{RUBY_VERSION}(#{RUBY_RELEASE_DATE})[#{RUBY_PLATFORM}] / Tk#{$tk_patchlevel}#{(Tk::JAPANIZED_TK)? '-jp': ''}\n\n" +
+ "Ruby/Tk release date :: tcltklib #{TclTkLib::RELEASE_DATE}; tk #{Tk::RELEASE_DATE}")
+end
+
+#########################################
+# start demos if given at command line
+no_launcher = false
+if ARGV[0] == '-n'
+ ARGV.shift
+ no_launcher = true if ARGV.size > 0
+else
+ # show the root widget to make it lower then demo windows
+ Tk.update rescue nil
+end
+ARGV.each{|cmd|
+ if cmd =~ /(.*).rb/
+ cmd = $1
+ end
+ #eval(IO.readlines("#{[$demo_dir, cmd].join(File::Separator)}.rb").join,
+ # _null_binding)
+ eval_samplecode(IO.readlines("#{[$demo_dir, cmd].join(File::Separator)}.rb").join, cmd + '.rb')
+}
+if no_launcher
+ $root.withdraw # hide root window
+ Thread.start{
+ loop do
+ count = 0
+ $root.winfo_children.each{|w|
+ count += 1 if w.kind_of?(TkToplevel)
+ }
+ $root.destroy if count == 0
+ end
+ }
+end
+
+#########################################
+# start eventloop
+Tk.mainloop
+
diff --git a/jni/ruby/ext/tk/sample/demos-jp/README b/jni/ruby/ext/tk/sample/demos-jp/README
new file mode 100644
index 0000000..4278124
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/demos-jp/README
@@ -0,0 +1,54 @@
+
+ Ruby/Tk widget-demo
+ version 1.2 ( 2000/04/08 )
+ 永井@知能.ä¹å·¥å¤§ (nagai@ai.kyutech.ac.jp)
+
+標準é…布㮠Tcl/Tk 拡張パッケージをå–ã‚Šè¾¼ã‚“ã  Ruby (以下 Ruby/Tk ã¨å‘¼ã³ã¾ã™)
+ã§ã¯ï¼ŒTk widget を用ã„㟠GUI ã®ä½œæˆã‚’è¡Œã†ã“ã¨ãŒã§ãã¾ã™ï¼Žå®Ÿéš›ã« GUI を作æˆ
+ã—ã¦ã„ãå ´åˆã«ã¯æ§˜ã€…ãªå®Ÿä¾‹ãŒã‚µãƒ³ãƒ—ルã¨ã—ã¦å­˜åœ¨ã™ã‚‹ã¨ä¾¿åˆ©ãªã®ã§ã™ãŒï¼ŒRuby/Tk
+ã«ã¯ãã®ã‚ˆã†ãªé©å½“ãªã‚µãƒ³ãƒ—ルスクリプト集åˆã¯å­˜åœ¨ã—ã¾ã›ã‚“ã§ã—ãŸï¼Žãã‚Œã«å¯¾ã—,
+拡張パッケージã®å…ƒã§ã‚ã‚‹ Tcl/Tk ã«ã¯ï¼ŒTk widget を用ã„ã¦ã©ã®ã‚ˆã†ãªã“ã¨ãŒã§
+ãã‚‹ã‹ã‚’示ã™ã‚‚ã®ã¨ã—㦠widget-demo ãŒå­˜åœ¨ã—ãŠã‚Šï¼ŒTcl/Tk を用ã„㟠GUI ã®ä½œæˆ
+ã‚’ç¿’å¾—ã™ã‚‹éš›ã®ä»£è¡¨çš„サンプルã¨ãªã£ã¦ã„ã¾ã™ï¼Žæœ¬ã‚¢ãƒ¼ã‚«ã‚¤ãƒ–ã¯ï¼ŒRuby/Tk ã®ç¿’å¾—ã®
+ãŸã‚ã®ä»£è¡¨çš„ãªã‚µãƒ³ãƒ—ルスクリプトã¨ã™ã¹ã,Tcl/Tk ã® widget-demo を移æ¤ã—ãŸã‚‚
+ã®ã§ã™ï¼Ž
+
+今回ã®ãƒãƒ¼ã‚¸ãƒ§ãƒ³ã¯ ruby-1.4.x ã«å¯¾å¿œã¨ã—ã¦ãŠãã¾ã™ãŒï¼Œæ—§ãƒãƒ¼ã‚¸ãƒ§ãƒ³ã«æ¯”ã¹ã¦ï¼Œ
+ã»ã¨ã‚“ã©å¤‰æ›´ã¯ã‚ã‚Šã¾ã›ã‚“.ruby-1.1c2 以上ãªã‚‰å‹•ãã¨æ€ã„ã¾ã™ï¼Žruby-1.5.x ã«ã¤
+ã„ã¦ã¯ãƒ†ã‚¹ãƒˆã—ã¦ã„ã¾ã›ã‚“.ãã®ãŸã‚,éžäº’æ›ã®å½±éŸ¿ãŒå‡ºã‚‹ã“ã¨ãŒã‚ã‚‹ã‹ã‚‚ã—ã‚Œã¾ã›
+ã‚“ãŒï¼Œãã®å ´åˆã§ã‚‚å°‘ã—ã®ä¿®æ­£ã§å‹•ã‹ã›ã‚‹ã¨æ€ã„ã¾ã™ï¼Žçµ„ã¿è¾¼ã‚€ Tk ã®ãƒãƒ¼ã‚¸ãƒ§ãƒ³ã¯ï¼Œ
+4.2 ã§ã‚‚ 8.0 ã§ã‚‚修正ãªãå‹•ã‹ã›ã‚‹ã¯ãšã§ã™ï¼ŽãŸã ã—,日本語版ã§ã®ç§»æ¤ã¨ãªã£ã¦
+ã„ã‚‹ãŸã‚,日本語化ã•ã‚ŒãŸ Tk ã‚’ã”利用ãã ã•ã„.スクリプトã®ãƒ†ã‚¹ãƒˆã¯ï¼Œæ—§ãƒãƒ¼ã‚¸ãƒ§
+ンã®éš›ã« Tk4.2jp 㨠Tk8.0jp ã®ä¸Šã§è¡Œã£ã¦ã„ã¾ã™ (完璧ã«ã§ã¯ãªã„ã§ã™ãŒ).今回
+ã®ãƒãƒ¼ã‚¸ãƒ§ãƒ³ã§ã¯ ruby-1.4.x + Tk8.0jp 上ã§ã®ç°¡å˜ãªãƒ†ã‚¹ãƒˆã—ã‹è¡Œã£ã¦ã„ã¾ã›ã‚“ãŒï¼Œ
+修正ã¨ã„ã†ã»ã©ã®ä¿®æ­£ã¯ã—ã¦ã„ã¾ã›ã‚“ã®ã§å•é¡Œã¯ãªã„ã¨è€ƒãˆã¦ã„ã¾ã™ï¼Ž
+
+本アーカイブã«å«ã¾ã‚Œã‚‹ã‚¹ã‚¯ãƒªãƒ—トã®å¤šãã¯ï¼Œå…ƒã¨ãªã£ã¦ã„ã‚‹ Tcl/Tk 版ã«æ¯”較的近
+ã„スクリプト記述ã¨ãªã‚‹ã‚ˆã†ã«ã—ã¦ã„ã¾ã™ï¼Žãã®ãŸã‚,Ruby/Tk ã®ã‚µãƒ³ãƒ—ルã¨è¨€ã†ã«
+ã¯ï¼Œã‚ã¾ã‚Š Ruby らã—ããªã„ã¨ã‚‚言ãˆã‚‹ã§ã—ょã†ï¼Žã«ã‚‚ã‹ã‹ã‚らãšï¼Œãã®ã‚ˆã†ãªè¨˜è¿°
+ã‚’å–ã£ã¦ã„ã‚‹ç†ç”±ã¯ï¼ŒRuby/Tk ã®ãƒ‰ã‚­ãƒ¥ãƒ¡ãƒ³ãƒˆä¸è¶³ã«ã‚ã‚Šã¾ã™ï¼Ž
+
+Tcl/Tk ã«ã¯é©å½“ãªå‚考書ãŒä½•å†Šã‹å­˜åœ¨ã—ã¦ã„ã¾ã™ã‹ã‚‰ï¼ŒRuby/Tk スクリプトを作æˆ
+ã™ã‚‹éš›ã¯ï¼Œãã®ã‚ˆã†ãª Tcl/Tk ã®å‚考書ã§æƒ…報を補ã„ãªãŒã‚‰ä½œæˆã™ã‚‹ã“ã¨ã«ãªã‚‹ã¨æ€
+ã„ã¾ã™ï¼Žå„ widget ã®ä½¿ç”¨ä¾‹ã¨ã—ã¦ï¼ŒTcl/Tk ã® widget-demo ã‚’å‚ç…§ã™ã‚‹ã“ã¨ã‚‚ã‚ã‚‹
+ã§ã—ょã†ï¼ŽRuby/Tk 版ã®è¨˜è¿°ã‚’ widget-demo ã‚’ Tcl/Tk 版ã®è¨˜è¿°ã«è¿‘ã„ã‚‚ã®ã«ã—ã¦
+ãŠã‘ã°ï¼Œãã®å¯¾æ¯”ã«ã‚ˆã£ã¦ï¼ŒRuby/Tk ã®ç†è§£ã‚’æ—©ã‚ã‚‹ã“ã¨ãŒã§ãã‚‹ã¨è€ƒãˆã‚‰ã‚Œã¾ã™ï¼Ž
+一旦 Ruby/Tk ã§ã® å„ widget ã®ä½¿ç”¨æ–¹æ³•ã‚’ç¿’å¾—ã—ã¦ã—ã¾ãˆã°ï¼ŒRuby らã—ã„スクリ
+プトを作æˆã™ã‚‹ã“ã¨ã¯é›£ã—ããªã„ã§ã—ょã†ï¼Žæœ¬ã‚¢ãƒ¼ã‚«ã‚¤ãƒ–ã®ã‚¹ã‚¯ãƒªãƒ—トã¯ï¼ŒRuby/Tk
+を最åˆã«ç¿’å¾—ã™ã‚‹ã¾ã§ã®è¸å°ã¨ã—ã¦åˆ©ç”¨ã—ã¦ã„ãŸã ã‘ã‚Œã°å¹¸ã„ã§ã™ï¼Ž
+
+widget-demo ã®ç§»æ¤ã«ã‚ãŸã£ã¦ã¯ï¼Œæ¬¡ã®æ–¹ã«ã‚‚移æ¤ã—ãŸã‚¹ã‚¯ãƒªãƒ—トをæä¾›ã—ã¦ã„ãŸã 
+ãã¾ã—ãŸï¼Žã“ã“ã«æ„Ÿè¬ã®æ„を表ã—ã¾ã™ï¼Ž
+
+ 立石@JAIST (ttate@jaist.ac.jp) ã•ã‚“
+ å¹³æ¾ç¥¥å² (hiramatu@cdrom.co.jp) ã•ã‚“
+
+å¹³æ¾ã•ã‚“ã«ã‚ˆã‚‹ Ruby/Tk 入門㮠Web page (http://www.cdrom.co.jp/~hiramatu/)
+ã‚‚ Ruby/Tk ã®ç¿’å¾—ã«æœ‰ç”¨ã¨æ€ãˆã¾ã™ã®ã§ï¼Œãœã²ã”å‚ç…§ãã ã•ã„.
+
+ã¾ãŸï¼Œå‰æ©‹ (maebashi@iij.ad.jp) ã•ã‚“ã‚’ã¯ã˜ã‚ã¨ã—ã¦ï¼Œwidget-demo ã®ç§»æ¤ã«éš›ã—
+ã¦å¿…è¦ã¨ãªã£ãŸ Ruby ã® Tk 関連ライブラリ修正ã«ã¤ã„ã¦ï¼Œå•é¡Œç‚¹ï¼Œãƒã‚°ã®æŒ‡æ‘˜ã‚’ã—
+ã¦ã„ãŸã ã„ãŸæ–¹ã€…ã«ã‚‚æ„Ÿè¬è‡´ã—ã¾ã™ï¼Ž
+
+ãã—ã¦æœ€å¾Œã«æœ€å¤§ã®æ„Ÿè¬ã‚’ Ruby 設計者㮠ã¾ã¤ã‚‚㨠ゆãã²ã‚ (matz@netlab.co.jp)
+ã•ã‚“ã«æ§ã’ãŸã„ã¨æ€ã„ã¾ã™ï¼Ž
diff --git a/jni/ruby/ext/tk/sample/demos-jp/README.1st b/jni/ruby/ext/tk/sample/demos-jp/README.1st
new file mode 100644
index 0000000..68caf8b
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/demos-jp/README.1st
@@ -0,0 +1,20 @@
+ã“ã®ãƒ‡ã‚£ãƒ¬ã‚¯ãƒˆãƒªã«ã¯ Ruby/Tk ã®ãƒ‡ãƒ¢ã‚¹ã‚¯ãƒªãƒ—トãŒåŽã‚られã¦ã„ã¾ã™ï¼Ž
+
+'.rb' ã¨ã„ã†æ‹¡å¼µå­ã‚’æŒã£ã¦ã„るファイルã¯ï¼Œãƒ©ãƒ³ãƒãƒ£â”€ã‚¹ã‚¯ãƒªãƒ—トã§
+ã‚ã‚‹ 'widget' ã‹ã‚‰å‘¼ã³å‡ºã•ã‚Œã‚‹ã‚µãƒ–スクリプトã§ã™ï¼Žãã‚Œãžã‚Œç‹¬ç«‹ã«
+ã¯å‹•ãã¾ã›ã‚“.'widget' スクリプトã‹ã‚‰å‘¼ã³å‡ºã—ã¦ãã ã•ã„.
+
+ã‚‚ã—ランãƒãƒ£â”€ã‚¹ã‚¯ãƒªãƒ—ト 'widget' ã®èµ·å‹•ã¨åŒæ™‚ã«ã„ãã¤ã‹ã®ã‚µãƒ–ス
+クリプトを起動ã—ãŸã‘ã‚Œã°ï¼Œãã®ã‚µãƒ–スクリプトã®åå‰ã‚’引数ã¨ã—ã¦ä¸Ž
+ãˆã¦ãã ã•ã„.
+( 例: /usr/local/bin/ruby widget button.rb entry1.rb text.rb )
+サブスクリプトã®æ‹¡å¼µå­ '.rb' ã¯çœç•¥ã™ã‚‹ã“ã¨ã‚‚ã§ãã¾ã™ï¼Ž
+( 例: /usr/local/bin/ruby widget button entry1 text )
+
+ã‚‚ã—ランãƒãƒ£â”€ã‚¹ã‚¯ãƒªãƒ—トã®ã‚¦ã‚£ãƒ³ãƒ‰ã‚¦ãŒå¿…è¦ãªã„å ´åˆã«ã¯ï¼Œ'-n' オ
+プションを与ãˆã¦ãã ã•ã„.
+( 例: /usr/local/bin/ruby widget -n button.rb entry1.rb text.rb )
+
+ä»–ã®ãƒ•ã‚¡ã‚¤ãƒ« (browse1 ã‚„ hello ãªã©) ã¯å˜ç‹¬ã§å‹•ã‹ã™ã“ã¨ãŒå¯èƒ½ã§ã™ï¼Ž
+
+ 2004/04/14 Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
diff --git a/jni/ruby/ext/tk/sample/demos-jp/anilabel.rb b/jni/ruby/ext/tk/sample/demos-jp/anilabel.rb
new file mode 100644
index 0000000..c882f43
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/demos-jp/anilabel.rb
@@ -0,0 +1,177 @@
+# -*- coding: utf-8 -*-
+#
+# animated label widget demo (called by 'widget')
+#
+# based on Tcl/Tk8.5a2 widget demos
+
+# toplevel widget ãŒå­˜åœ¨ã™ã‚Œã°å‰Šé™¤ã™ã‚‹
+if defined?($anilabel_demo) && $anilabel_demo
+ $anilabel_demo.destroy
+ $anilabel_demo = nil
+end
+
+# demo 用㮠toplevel widget を生æˆ
+$anilabel_demo = TkToplevel.new {|w|
+ title("Animated Label Demonstration")
+ iconname("anilabel")
+ positionWindow(w)
+}
+
+base_frame = TkFrame.new($anilabel_demo).pack(:fill=>:both, :expand=>true)
+
+# label 生æˆ
+msg = TkLabel.new(base_frame) {
+ font $font
+ wraplength '4i'
+ justify 'left'
+ text "下ã«ã¯4ã¤ã®ã‚¢ãƒ‹ãƒ¡ãƒ¼ã‚·ãƒ§ãƒ³ãƒ©ãƒ™ãƒ«ãŒè¡¨ç¤ºã•ã‚Œã¦ã„ã¾ã™ã€‚å·¦å´ã«ã‚るラベルã¯ã€å†…部ã®ãƒ†ã‚­ã‚¹ãƒˆãƒ¡ãƒƒã‚»ãƒ¼ã‚¸ã‚’スクロールã—ãŸã‚ˆã†ã«è¦‹ã›ã‚‹ã“ã¨ã§å‹•ãを付ã‘ã¦ã„ã¾ã™ã€‚å³å´ã®ãƒ©ãƒ™ãƒ«ã¯ã€è¡¨ç¤ºã™ã‚‹ã‚¤ãƒ¡ãƒ¼ã‚¸ã‚’変化ã•ã›ã‚‹ã“ã¨ã§å‹•ãを与ãˆã¦ã„ã¾ã™ã€‚"
+}
+msg.pack('side'=>'top')
+
+# frame 生æˆ
+TkFrame.new(base_frame) {|frame|
+ TkButton.new(frame) {
+ #text '了解'
+ text 'é–‰ã˜ã‚‹'
+ command proc{
+ tmppath = $anilabel_demo
+ $anilabel_demo = nil
+ tmppath.destroy
+ }
+ }.pack('side'=>'left', 'expand'=>'yes')
+
+ TkButton.new(frame) {
+ text 'コードå‚ç…§'
+ command proc{showCode 'anilabel'}
+ }.pack('side'=>'left', 'expand'=>'yes')
+
+}.pack('side'=>'bottom', 'fill'=>'x', 'pady'=>'2m')
+
+# label demo 用フレーム生æˆ
+f_left = TkLabelFrame.new(base_frame, :text=>'Scrolling Texts')
+f_right = TkLabelFrame.new(base_frame, :text=>'GIF Image')
+Tk.pack(f_left, f_right, 'side'=>'left', 'expand'=>'yes', 'fill'=>'both',
+ 'padx'=>10, 'pady'=>10)
+
+# animated label
+class AnimatedTextLabel < TkLabel
+ def initialize(*args)
+ super(*args)
+ @timer = TkTimer.new{ _animation_callback }
+ @timer.loop_exec = -1
+ # bind('Destroy'){ @timer.stop }
+ @btag = TkBindTag.new('Destroy'){ @timer.stop }
+ self.bindtags_unshift(@btag)
+ end
+
+ def _animation_callback()
+ txt = self.text
+ self.text = (txt[1..-1] << txt[0])
+ end
+ private :_animation_callback
+
+ def start(interval)
+ @timer.set_interval(interval)
+ @timer.start
+ end
+
+ def stop
+ @timer.stop
+ end
+end
+
+# animated image
+class AnimatedImageLabel < AnimatedTextLabel
+ def initialize(*args)
+ super(*args)
+ @destroy_image = false
+ @btag.bind_append('Destroy'){
+ if @destroy_image
+ begin
+ self.image.delete
+ rescue
+ end
+ end
+ }
+ end
+ attr_accessor :destroy_image
+
+ def _animation_callback()
+ img = self.image
+
+ fmt = img.format
+ if fmt.kind_of?(Array)
+ if fmt[1].kind_of?(Hash)
+ # fmt == ['GIF', {'index'=>idx}]
+ idx = fmt[1]['index']
+ else
+ # fmt == ['GIF', '-index', idx] :: Ruby1.8.2 returns this.
+ idx = fmt[2]
+ end
+ elsif fmt.kind_of?(String) && fmt =~ /GIF -index (\d+)/
+ idx = $1.to_i
+ else
+ idx = -1
+ end
+
+ begin
+ img.format("GIF -index #{idx + 1}")
+ rescue => e
+ img.format("GIF -index 0")
+ end
+ end
+ private :_animation_callback
+end
+
+# label 生æˆ
+l1 = AnimatedTextLabel.new(f_left, :borderwidth=>4, :relief=>:ridge,
+ :font=>{:family=>'Courier', :size=>10})
+l2 = AnimatedTextLabel.new(f_left, :borderwidth=>4, :relief=>:groove,
+ :font=>{:family=>'Courier', :size=>10})
+l3 = AnimatedTextLabel.new(f_left, :borderwidth=>4, :relief=>:flat,
+ :font=>{:family=>'Courier', :size=>10}, :width=>18)
+Tk.pack(l1, l2, l3,
+ :side=>:top, :expand=>true, :anchor=>:w, :padx=>10, :pady=>10)
+
+limg = AnimatedImageLabel.new(f_right, :borderwidth=>0)
+limg.pack(:side=>:top, :expand=>true, :padx=>10, :pady=>10)
+
+# base64-encoded animated GIF file
+tclPowerdData = <<EOD
+ R0lGODlhKgBAAPQAAP//////zP//AP/MzP/Mmf/MAP+Zmf+ZZv+ZAMz//8zM
+ zMyZmcyZZsxmZsxmAMwzAJnMzJmZzJmZmZlmmZlmZplmM5kzM2aZzGZmzGZm
+ mWZmZmYzZmYzMzNmzDMzZgAzmSH+IE1hZGUgd2l0aCBHSU1QIGJ5IExARGVt
+ YWlsbHkuY29tACH5BAVkAAEALAAAAAAqAEAAAAX+YCCOZEkyTKM2jOm66yPP
+ dF03bx7YcuHIDkGBR7SZeIyhTID4FZ+4Es8nQyCe2EeUNJ0peY2s9mi7PhAM
+ ngEAMGRbUpvzSxskLh1J+Hkg134OdDIDEB+GHxtYMEQMTjMGEYeGFoomezaC
+ DZGSHFmLXTQKkh8eNQVpZ2afmDQGHaOYSoEyhhcklzVmMpuHnaZmDqiGJbg0
+ qFqvh6UNAwB7VA+OwydEjgujkgrPNhbTI8dFvNgEYcHcHx0lB1kX2IYeA2G6
+ NN0YfkXJ2BsAMuAzHB9cZMk3qoEbRzUACsRCUBK5JxsC3iMiKd8GN088SIyT
+ 0RAFSROyeEg38caDiB/+JEgqxsODrZJ1BkT0oHKSmI0ceQxo94HDpg0qsuDk
+ UmRAMgu8OgwQ+uIJgUMVeGXA+IQkzEeHGvD8cIGlDXsLiRjQ+EHroQhea7xY
+ 8IQBSgYYDi1IS+OFBCgaDMGVS3fGi5BPJpBaENdQ0EomKGD56IHwO39EXiSC
+ Ysgxor5+Xfgq0qByYUpiXmwuoredB2aYH4gWWda0B7SeNENpEJHC1ghi+pS4
+ AJpIAwWvKPBi+8YEht5EriEqpFfMlhEdkBNpx0HUhwypx5T4IB1MBg/Ws2sn
+ wV3MSQOkzI8fUd48Aw3dOZto71x85hHtHijYv18Gf/3GqCdDCXHNoICBobSo
+ IqBqJLyCoH8JPrLgdh88CKCFD0CGmAiGYPgffwceZh6FC2ohIIklnkhehTNY
+ 4CIHHGzgwYw01ujBBhvAqKOLLq5AAk9kuSPkkKO40NB+h1gnypJIIvkBf09a
+ N5QIRz5p5ZJXJpmlIVhOGQA2TmIJZZhKKmmll2BqyWSXWUrZpQtpatlmk1c2
+ KaWRHeTZEJF8SqLDn/hhsOeQgBbqAh6DGqronxeARUIIACH5BAUeAAAALAUA
+ LgAFAAUAAAUM4CeKz/OV5YmqaRkCACH5BAUeAAEALAUALgAKAAUAAAUUICCK
+ z/OdJVCaa7p+7aOWcDvTZwgAIfkEBR4AAQAsCwAuAAkABQAABRPgA4zP95zA
+ eZqoWqqpyqLkZ38hACH5BAUKAAEALAcALgANAA4AAAU7ICA+jwiUJEqeKau+
+ r+vGaTmac63v/GP9HM7GQyx+jsgkkoRUHJ3Qx0cK/VQVTKtWwbVKn9suNunc
+ WkMAIfkEBQoAAAAsBwA3AAcABQAABRGgIHzk842j+Yjlt5KuO8JmCAAh+QQF
+ CgAAACwLADcABwAFAAAFEeAnfN9TjqP5oOWziq05lmUIACH5BAUKAAAALA8A
+ NwAHAAUAAAUPoPCJTymS3yiQj4qOcPmEACH5BAUKAAAALBMANwAHAAUAAAUR
+ oCB+z/MJX2o+I2miKimiawgAIfkEBQoAAAAsFwA3AAcABQAABRGgIHzfY47j
+ Q4qk+aHl+pZmCAAh+QQFCgAAACwbADcABwAFAAAFEaAgfs/zCV9qPiNJouo7
+ ll8IACH5BAUKAAAALB8ANwADAAUAAAUIoCB8o0iWZggAOw==
+EOD
+
+l1.text('* Slow Animation *').start(300)
+l2.text('* Fast Animation *').start(80)
+l3.text('This is a longer scrolling text in a widget that will not show the whole message at once. ').start(150)
+
+limg.destroy_image = true
+limg.image(TkPhotoImage.new(:format=>'GIF', :data=>tclPowerdData)).start(100)
diff --git a/jni/ruby/ext/tk/sample/demos-jp/aniwave.rb b/jni/ruby/ext/tk/sample/demos-jp/aniwave.rb
new file mode 100644
index 0000000..866316c
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/demos-jp/aniwave.rb
@@ -0,0 +1,120 @@
+# -*- coding: utf-8 -*-
+#
+# animated wave demo (called by 'widget')
+#
+# based on Tcl/Tk8.5a2 widget demos
+
+# destroy toplevel widget for this demo script
+if defined?($aniwave_demo) && $aniwave_demo
+ $aniwave_demo.destroy
+ $aniwave_demo = nil
+end
+
+# create toplevel widget
+$aniwave_demo = TkToplevel.new {|w|
+ title("Animated Wave Demonstration")
+ iconname("aniwave")
+ positionWindow(w)
+}
+
+base_frame = TkFrame.new($aniwave_demo).pack(:fill=>:both, :expand=>true)
+
+# create label
+msg = TkLabel.new(base_frame) {
+ font $font
+ wraplength '4i'
+ justify 'left'
+ text 'ã“ã®ãƒ‡ãƒ¢ã§ã¯ã€ãƒ©ã‚¤ãƒ³ã‚¢ã‚¤ãƒ†ãƒ ãŒä¸€ã¤ã ã‘æã‹ã‚ŒãŸã‚­ãƒ£ãƒ³ãƒã‚¹ã‚¦ã‚£ã‚¸ã‚§ãƒƒãƒˆãŒè¡¨ç¤ºã•ã‚Œã¦ã„ã¾ã™ã€‚アニメーション処ç†ã¯ã€ãã®ãƒ©ã‚¤ãƒ³ã‚¢ã‚¤ãƒ†ãƒ ã®åº§æ¨™å€¤ã‚’変更ã™ã‚‹ã“ã¨ã§å®Ÿç¾ã—ã¦ã„ã¾ã™ã€‚'
+}
+msg.pack('side'=>'top')
+
+# create frame
+TkFrame.new(base_frame) {|frame|
+ TkButton.new(frame) {
+ #text '了解'
+ text 'é–‰ã˜ã‚‹'
+ command proc{
+ tmppath = $aniwave_demo
+ $aniwave_demo = nil
+ tmppath.destroy
+ }
+ }.pack('side'=>'left', 'expand'=>'yes')
+
+ TkButton.new(frame) {
+ text 'コードå‚ç…§'
+ command proc{showCode 'aniwave'}
+ }.pack('side'=>'left', 'expand'=>'yes')
+
+}.pack('side'=>'bottom', 'fill'=>'x', 'pady'=>'2m')
+
+# animated wave
+class AnimatedWaveDemo
+ def initialize(frame, dir=:left)
+ @direction = dir
+
+ # create canvas widget
+ @c = TkCanvas.new(frame, :width=>300, :height=>200,
+ :background=>'black')
+ @c.pack(:padx=>10, :pady=>10, :expand=>true)
+
+ # Creates a coordinates list of a wave.
+ @waveCoords = []
+ @backupCoords = []
+ n = 0
+ (-10..300).step(5){|n| @waveCoords << [n, 100]; @backupCoords << [n, 100] }
+ n = 305
+ @waveCoords << [n, 0]; @backupCoords << [n, 0]
+ @waveCoords << [n+5, 200]; @backupCoords << [n+5, 200]
+ @coordsLen = @waveCoords.length
+
+ # Create a smoothed line and arrange for its coordinates to be the
+ # contents of the variable waveCoords.
+ @line = TkcLine.new(@c, @waveCoords,
+ :width=>1, :fill=>'green', :smooth=>true)
+
+ # Main animation "loop".
+ # Theoretically 100 frames-per-second (==10ms between frames)
+ @timer = TkTimer.new(10){ basicMotion; reverser }
+
+ # Arrange for the animation loop to stop when the canvas is deleted
+ @c.bindtags_unshift(TkBindTag.new('Destroy'){ @timer.stop })
+ end
+
+ # Basic motion handler. Given what direction the wave is travelling
+ # in, it advances the y coordinates in the coordinate-list one step in
+ # that direction.
+ def basicMotion
+ @backupCoords, @waveCoords = @waveCoords, @backupCoords
+ (0...@coordsLen).each{|idx|
+ if @direction == :left
+ @waveCoords[idx][1] = @backupCoords[(idx+1 == @coordsLen)? 0: idx+1][1]
+ else
+ @waveCoords[idx][1] = @backupCoords[(idx == 0)? -1: idx-1][1]
+ end
+ }
+ @line.coords(@waveCoords)
+ end
+
+ # Oscillation handler. This detects whether to reverse the direction
+ # of the wave by checking to see if the peak of the wave has moved off
+ # the screen (whose size we know already.)
+ def reverser
+ if @waveCoords[0][1] < 10
+ @direction = :right
+ elsif @waveCoords[-1][1] < 10
+ @direction = :left
+ end
+ end
+
+ # animation control
+ def move
+ @timer.start
+ end
+
+ def stop
+ @timer.stop
+ end
+end
+
+# Start the animation processing
+AnimatedWaveDemo.new(base_frame, :left).move
diff --git a/jni/ruby/ext/tk/sample/demos-jp/arrow.rb b/jni/ruby/ext/tk/sample/demos-jp/arrow.rb
new file mode 100644
index 0000000..2995f96
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/demos-jp/arrow.rb
@@ -0,0 +1,247 @@
+# -*- coding: utf-8 -*-
+#
+# arrowhead widget demo (called by 'widget')
+#
+
+# arrowSetup --
+# This method regenerates all the text and graphics in the canvas
+# window. It's called when the canvas is initially created, and also
+# whenever any of the parameters of the arrow head are changed
+# interactively.
+#
+# Arguments:
+# c - Name of the canvas widget.
+
+def arrowSetup(c)
+ v = $demo_arrowInfo
+
+ # Remember the current box, if there is one.
+ tags = c.gettags('current')
+ if tags != []
+ cur = tags.find{|t| t.kind_of?(String) && t =~ /^box[1-3]$/ }
+ else
+ cur = nil
+ end
+
+ # Create the arrow and outline.
+ c.delete('all')
+ TkcLine.new(c, v.x1, v.y, v.x2, v.y,
+ { 'width'=>10 * v.width,
+ 'arrowshape'=>[10*v.a, 10*v.b, 10*v.c],
+ 'arrow'=>'last'
+ }.update(v.bigLineStyle) )
+ xtip = v.x2 - 10*v.b
+ deltaY = 10*v.c + 5*v.width
+ TkcLine.new(c, v.x2, v.y, xtip, v.y + deltaY,
+ v.x2 - 10*v.a, v.y, xtip, v.y - deltaY, v.x2, v.y,
+ 'width'=>2, 'capstyle'=>'round', 'joinstyle'=>'round')
+
+ # Create the boxes for reshaping the line and arrowhead.
+ TkcRectangle.new(c, v.x2-10*v.a-5, v.y-5, v.x2-10*v.a+5, v.y+5,
+ {'tags'=>['box1', $arrowTag_box]}.update(v.boxStyle) )
+ TkcRectangle.new(c, xtip-5, v.y-deltaY-5, xtip+5, v.y-deltaY+5,
+ {'tags'=>['box2', $arrowTag_box]}.update(v.boxStyle) )
+ TkcRectangle.new(c, v.x1-5, v.y-5*v.width-5, v.x1+5, v.y-5*v.width+5,
+ {'tags'=>['box3', $arrowTag_box]}.update(v.boxStyle) )
+ c.itemconfigure cur, v.activeStyle if cur
+
+ # Create three arrows in actual size with the same parameters
+ TkcLine.new(c, v.x2+50, 0, v.x2+50, 1000, 'width'=>2)
+ tmp = v.x2+100
+ TkcLine.new(c, tmp, v.y-125, tmp, v.y-75, 'width'=>v.width,
+ 'arrow'=>'both', 'arrowshape'=>[v.a, v.b, v.c])
+ TkcLine.new(c, tmp-25, v.y, tmp+25, v.y, 'width'=>v.width,
+ 'arrow'=>'both', 'arrowshape'=>[v.a, v.b, v.c])
+ TkcLine.new(c, tmp-25, v.y+75, tmp+25, v.y+125, 'width'=>v.width,
+ 'arrow'=>'both', 'arrowshape'=>[v.a, v.b, v.c])
+
+ # Create a bunch of other arrows and text items showing the
+ # current dimensions.
+ tmp = v.x2+10
+ TkcLine.new(c, tmp, v.y-5*v.width, tmp, v.y-deltaY,
+ 'arrow'=>'both', 'arrowshape'=>v.smallTips)
+ TkcText.new(c, v.x2+15, v.y-deltaY+5*v.c, 'text'=>v.c, 'anchor'=>'w')
+ tmp = v.x1-10
+ TkcLine.new(c, tmp, v.y-5*v.width, tmp, v.y+5*v.width,
+ 'arrow'=>'both', 'arrowshape'=>v.smallTips)
+ TkcText.new(c, v.x1-15, v.y, 'text'=>v.width, 'anchor'=>'e')
+ tmp = v.y+5*v.width+10*v.c+10
+ TkcLine.new(c, v.x2-10*v.a, tmp, v.x2, tmp,
+ 'arrow'=>'both', 'arrowshape'=>v.smallTips)
+ TkcText.new(c, v.x2-5*v.a, tmp+5, 'text'=>v.a, 'anchor'=>'n')
+ tmp = tmp+25
+ TkcLine.new(c, v.x2-10*v.b, tmp, v.x2, tmp,
+ 'arrow'=>'both', 'arrowshape'=>v.smallTips)
+ TkcText.new(c, v.x2-5*v.b, tmp+5, 'text'=>v.b, 'anchor'=>'n')
+
+ if $tk_version =~ /^4.*/
+ TkcText.new(c, v.x1, 310, 'text'=>"'width'=>#{v.width}", 'anchor'=>'w',
+ 'font'=>'-*-Helvetica-Medium-R-Normal--*-180-*-*-*-*-*-*')
+ TkcText.new(c, v.x1, 330,
+ 'text'=>"'arrowshape'=>[#{v.a}, #{v.b}, #{v.c}]",'anchor'=>'w',
+ 'font'=>'-*-Helvetica-Medium-R-Normal--*-180-*-*-*-*-*-*')
+ else
+ TkcText.new(c, v.x1, 310, 'text'=>"'width'=>#{v.width}", 'anchor'=>'w',
+ 'font'=>'Helvetica 18')
+ TkcText.new(c, v.x1, 330,
+ 'text'=>"'arrowshape'=>[#{v.a}, #{v.b}, #{v.c}]",
+ 'anchor'=>'w', 'font'=>'Helvetica 18')
+ end
+
+ v.count += 1
+end
+
+# toplevel widget ãŒå­˜åœ¨ã™ã‚Œã°å‰Šé™¤ã™ã‚‹
+if defined?($arrow_demo) && $arrow_demo
+ $arrow_demo.destroy
+ $arrow_demo = nil
+end
+
+# demo 用㮠toplevel widget を生æˆ
+$arrow_demo = TkToplevel.new {|w|
+ title("Arrowhead Editor Demonstration")
+ iconname("arrow")
+ positionWindow(w)
+}
+
+base_frame = TkFrame.new($arrow_demo).pack(:fill=>:both, :expand=>true)
+
+# label 生æˆ
+TkLabel.new(base_frame, 'font'=>$font, 'wraplength'=>'5i', 'justify'=>'left',
+ 'text'=>"ã“ã® widget ã§ã€ã‚­ãƒ£ãƒ³ãƒã‚¹ã§ä½¿ã‚れるラインã«ã¤ã„ã¦æ§˜ã€…ãªå¹…や矢å°ã®é ­ã®å½¢ã‚’試ã—ã¦ã¿ã‚‹ã“ã¨ãŒã§ãã¾ã™ã€‚ç·šã®å¹…や矢å°ã®å½¢ã‚’変ãˆã‚‹ã«ã¯ã€æ‹¡å¤§ã•ã‚ŒãŸçŸ¢å°ã«ã¤ã„ã¦ã„ã‚‹ 3ã¤ã®å››è§’をドラッグã—ã¦ãã ã•ã„。å³å´ã®çŸ¢å°ã¯æ™®é€šã®å¤§ãã•ã§ã®ã‚µãƒ³ãƒ—ルを示ã—ã¦ã„ã¾ã™ã€‚下ã®ãƒ†ã‚­ã‚¹ãƒˆã¯ãƒ©ã‚¤ãƒ³ã‚¢ã‚¤ãƒ†ãƒ ã«å¯¾ã™ã‚‹è¨­å®šã‚ªãƒ—ションã§ã™ã€‚"){
+ pack('side'=>'top')
+}
+
+# frame 生æˆ
+$arrow_buttons = TkFrame.new(base_frame) {|frame|
+ TkButton.new(frame) {
+ #text '了解'
+ text 'é–‰ã˜ã‚‹'
+ command proc{
+ tmppath = $arrow_demo
+ $arrow_demo = nil
+ tmppath.destroy
+ }
+ }.pack('side'=>'left', 'expand'=>'yes')
+
+ TkButton.new(frame) {
+ text 'コードå‚ç…§'
+ command proc{showCode 'arrow'}
+ }.pack('side'=>'left', 'expand'=>'yes')
+}
+$arrow_buttons.pack('side'=>'bottom', 'fill'=>'x', 'pady'=>'2m')
+
+# canvas 設定
+$arrow_canvas = TkCanvas.new(base_frame, 'width'=>500, 'height'=>350,
+ 'relief'=>'sunken', 'borderwidth'=>2)
+$arrow_canvas.pack('expand'=>'yes', 'fill'=>'both')
+
+# 値設定
+unless Struct.const_defined?("ArrowInfo")
+ $demo_arrowInfo = Struct.new("ArrowInfo", :a, :b, :c, :width, :motionProc,
+ :x1, :x2, :y, :smallTips, :count,
+ :bigLineStyle, :boxStyle, :activeStyle).new
+end
+$demo_arrowInfo.a = 8
+$demo_arrowInfo.b = 10
+$demo_arrowInfo.c = 3
+$demo_arrowInfo.width = 2
+$demo_arrowInfo.motionProc = proc{}
+$demo_arrowInfo.x1 = 40
+$demo_arrowInfo.x2 = 350
+$demo_arrowInfo.y = 150
+$demo_arrowInfo.smallTips = [5, 5, 2]
+$demo_arrowInfo.count = 0
+if TkWinfo.depth($arrow_canvas) > 1
+ $demo_arrowInfo.bigLineStyle = {'fill'=>'SkyBlue1'}
+ $demo_arrowInfo.boxStyle = {'fill'=>'', 'outline'=>'black', 'width'=>1}
+ $demo_arrowInfo.activeStyle = {'fill'=>'red', 'outline'=>'black', 'width'=>1}
+else
+ $demo_arrowInfo.bigLineStyle = {'fill'=>'black',
+ 'stipple'=>'@'+[$demo_dir,'..','images','grey.25'].join(File::Separator)}
+ $demo_arrowInfo.boxStyle = {'fill'=>'', 'outline'=>'black', 'width'=>1}
+ $demo_arrowInfo.activeStyle = {'fill'=>'black','outline'=>'black','width'=>1}
+end
+$arrowTag_box = TkcTag.new($arrow_canvas)
+arrowSetup $arrow_canvas
+$arrowTag_box.bind('Enter', proc{$arrow_canvas.itemconfigure('current', $demo_arrowInfo.activeStyle)})
+$arrowTag_box.bind('Leave', proc{$arrow_canvas.itemconfigure('current', $demo_arrowInfo.boxStyle)})
+$arrowTag_box.bind('B1-Enter', proc{})
+$arrowTag_box.bind('B1-Leave', proc{})
+$arrow_canvas.itembind('box1', '1',
+ proc{$demo_arrowInfo.motionProc \
+ = proc{|x,y| arrowMove1 $arrow_canvas, x, y}})
+$arrow_canvas.itembind('box2', '1',
+ proc{$demo_arrowInfo.motionProc \
+ = proc{|x,y| arrowMove2 $arrow_canvas, x, y}})
+$arrow_canvas.itembind('box3', '1',
+ proc{$demo_arrowInfo.motionProc \
+ = proc{|x,y| arrowMove3 $arrow_canvas, x, y}})
+$arrowTag_box.bind('B1-Motion',
+ proc{|x,y| $demo_arrowInfo.motionProc.call(x,y)}, "%x %y")
+$arrow_canvas.bind('Any-ButtonRelease-1', proc{arrowSetup $arrow_canvas})
+
+# arrowMove1 --
+# This method is called for each mouse motion event on box1 (the
+# one at the vertex of the arrow). It updates the controlling parameters
+# for the line and arrowhead.
+#
+# Arguments:
+# c - The name of the canvas window.
+# x, y - The coordinates of the mouse.
+
+def arrowMove1(c,x,y)
+ v = $demo_arrowInfo
+ newA = (v.x2+5-c.canvasx(x).round)/10
+ newA = 0 if newA < 0
+ newA = 25 if newA > 25
+ if newA != v.a
+ c.move('box1', 10*(v.a-newA), 0)
+ v.a = newA
+ end
+end
+
+# arrowMove2 --
+# This method is called for each mouse motion event on box2 (the
+# one at the trailing tip of the arrowhead). It updates the controlling
+# parameters for the line and arrowhead.
+#
+# Arguments:
+# c - The name of the canvas window.
+# x, y - The coordinates of the mouse.
+
+def arrowMove2(c,x,y)
+ v = $demo_arrowInfo
+ newB = (v.x2+5-c.canvasx(x).round)/10
+ newB = 0 if newB < 0
+ newB = 25 if newB > 25
+ newC = (v.y+5-c.canvasy(y).round-5*v.width)/10
+ newC = 0 if newC < 0
+ newC = 20 if newC > 20
+ if newB != v.b || newC != v.c
+ c.move('box2', 10*(v.b-newB), 10*(v.c-newC))
+ v.b = newB
+ v.c = newC
+ end
+end
+
+# arrowMove3 --
+# This method is called for each mouse motion event on box3 (the
+# one that controls the thickness of the line). It updates the
+# controlling parameters for the line and arrowhead.
+#
+# Arguments:
+# c - The name of the canvas window.
+# x, y - The coordinates of the mouse.
+
+def arrowMove3(c,x,y)
+ v = $demo_arrowInfo
+ newWidth = (v.y+2-c.canvasy(y).round)/5
+ newWidth = 0 if newWidth < 0
+ newWidth = 20 if newWidth > 20
+ if newWidth != v.width
+ c.move('box3', 0, 5*(v.width-newWidth))
+ v.width = newWidth
+ end
+end
+
diff --git a/jni/ruby/ext/tk/sample/demos-jp/bind.rb b/jni/ruby/ext/tk/sample/demos-jp/bind.rb
new file mode 100644
index 0000000..efba6e6
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/demos-jp/bind.rb
@@ -0,0 +1,125 @@
+# -*- coding: utf-8 -*-
+#
+# text (tag bindings) widget demo (called by 'widget')
+#
+
+# toplevel widget ãŒå­˜åœ¨ã™ã‚Œã°å‰Šé™¤ã™ã‚‹
+if defined?($bind_demo) && $bind_demo
+ $bind_demo.destroy
+ $bind_demo = nil
+end
+
+# demo 用㮠toplevel widget を生æˆ
+$bind_demo = TkToplevel.new {|w|
+ title("Text Demonstration - Tag Bindings")
+ iconname("bind")
+ positionWindow(w)
+}
+
+base_frame = TkFrame.new($bind_demo).pack(:fill=>:both, :expand=>true)
+
+# frame 生æˆ
+TkFrame.new(base_frame) {|frame|
+ TkButton.new(frame) {
+ #text '了解'
+ text 'é–‰ã˜ã‚‹'
+ command proc{
+ tmppath = $bind_demo
+ $bind_demo = nil
+ tmppath.destroy
+ }
+ }.pack('side'=>'left', 'expand'=>'yes')
+
+ TkButton.new(frame) {
+ text 'コードå‚ç…§'
+ command proc{showCode 'bind'}
+ }.pack('side'=>'left', 'expand'=>'yes')
+}.pack('side'=>'bottom', 'fill'=>'x', 'pady'=>'2m')
+
+# bind 用メソッド
+def tag_binding_for_bind_demo(tag, enter_style, leave_style)
+ tag.bind('Any-Enter', proc{tag.configure enter_style})
+ tag.bind('Any-Leave', proc{tag.configure leave_style})
+end
+
+# text 生æˆ
+txt = TkText.new(base_frame){|t|
+ # 生æˆ
+ setgrid 'true'
+ #width 60
+ #height 24
+ font $font
+ wrap 'word'
+ TkScrollbar.new(base_frame) {|s|
+ pack('side'=>'right', 'fill'=>'y')
+ command proc{|*args| t.yview(*args)}
+ t.yscrollcommand proc{|first,last| s.set first,last}
+ }
+ pack('expand'=>'yes', 'fill'=>'both')
+
+ # スタイル設定
+ if TkWinfo.depth($root).to_i > 1
+ tagstyle_bold = {'background'=>'#43ce80', 'relief'=>'raised',
+ 'borderwidth'=>1}
+ tagstyle_normal = {'background'=>'', 'relief'=>'flat'}
+ else
+ tagstyle_bold = {'foreground'=>'white', 'background'=>'black'}
+ tagstyle_normal = {'foreground'=>'', 'background'=>''}
+ end
+
+ # テキスト挿入
+ insert 'insert', "テキストwidgetã®è¡¨ç¤ºã‚¹ã‚¿ã‚¤ãƒ«ã‚’制御ã™ã‚‹ã®ã¨åŒã˜ã‚¿ã‚°ã®ãƒ¡ã‚«ãƒ‹ã‚ºãƒ ã‚’使ã£ã¦ã€ãƒ†ã‚­ã‚¹ãƒˆã«Tclã®ã‚³ãƒžãƒ³ãƒ‰ã‚’割り当ã¦ã‚‹ã“ã¨ãŒã§ãã¾ã™ã€‚ã“ã‚Œã«ã‚ˆã‚Šã€ãƒžã‚¦ã‚¹ã‚„キーボードã®ã‚¢ã‚¯ã‚·ãƒ§ãƒ³ã§ç‰¹å®šã®Tclã®ã‚³ãƒžãƒ³ãƒ‰ãŒå®Ÿè¡Œã•ã‚Œã‚‹ã‚ˆã†ã«ãªã‚Šã¾ã™ã€‚例ãˆã°ã€ä¸‹ã®ã‚­ãƒ£ãƒ³ãƒã‚¹ã®ãƒ‡ãƒ¢ãƒ—ログラムã«ã¤ã„ã¦ã®èª¬æ˜Žæ–‡ã«ã¯ãã®ã‚ˆã†ãªã‚¿ã‚°ãŒã¤ã„ã¦ã„ã¾ã™ã€‚マウスを説明文ã®ä¸Šã«æŒã£ã¦ã„ãã¨èª¬æ˜Žæ–‡ãŒå…‰ã‚Šã€ãƒœã‚¿ãƒ³1を押ã™ã¨ãã®èª¬æ˜Žã®ãƒ‡ãƒ¢ãŒå§‹ã¾ã‚Šã¾ã™ã€‚
+
+"
+ insert('end', '1. キャンãƒã‚¹ widget ã«ä½œã‚‹ã“ã¨ã®ã§ãるアイテムã®ç¨®é¡žå…¨ã¦ã«é–¢ã™ã‚‹ã‚µãƒ³ãƒ—ル。', (d1 = TkTextTag.new(t)) )
+ insert('end', "\n\n")
+ insert('end', '2. ç°¡å˜ãª 2次元ã®ãƒ—ロット。データを表ã™ç‚¹ã‚’å‹•ã‹ã™ã“ã¨ãŒã§ãる。', (d2 = TkTextTag.new(t)) )
+ insert('end', "\n\n")
+ insert('end', '3. テキストアイテムã®ã‚¢ãƒ³ã‚«ãƒ¼ã¨è¡Œæƒãˆã€‚',
+ (d3 = TkTextTag.new(t)) )
+ insert('end', "\n\n")
+ insert('end', '4. ラインアイテムã®ãŸã‚ã®çŸ¢å°ã®é ­ã®å½¢ã®ã‚¨ãƒ‡ã‚£ã‚¿ã€‚',
+ (d4 = TkTextTag.new(t)) )
+ insert('end', "\n\n")
+ insert('end', '5. タブストップを変更ã™ã‚‹ãŸã‚ã®æ©Ÿèƒ½ã¤ãã®ãƒ«ãƒ¼ãƒ©ãƒ¼ã€‚',
+ (d5 = TkTextTag.new(t)) )
+ insert('end', "\n\n")
+ insert('end',
+ '6. キャンãƒã‚¹ãŒã©ã†ã‚„ã£ã¦ã‚¹ã‚¯ãƒ­ãƒ¼ãƒ«ã™ã‚‹ã®ã‹ã‚’示ã™ã‚°ãƒªãƒƒãƒ‰ã€‚',
+ (d6 = TkTextTag.new(t)) )
+
+ # binding
+ [d1, d2, d3, d4, d5, d6].each{|tag|
+ tag_binding_for_bind_demo(tag, tagstyle_bold, tagstyle_normal)
+ }
+ d1.bind('1',
+ proc{
+ eval_samplecode(`cat #{[$demo_dir,'items.rb'].join(File::Separator)}`, 'items.rb')
+ })
+ d2.bind('1',
+ proc{
+ eval_samplecode(`cat #{[$demo_dir,'plot.rb'].join(File::Separator)}`, 'plot.rb')
+ })
+ d3.bind('1',
+ proc{
+ eval_samplecode(`cat #{[$demo_dir,'ctext.rb'].join(File::Separator)}`, 'ctext.rb')
+ })
+ d4.bind('1',
+ proc{
+ eval_samplecode(`cat #{[$demo_dir,'arrow.rb'].join(File::Separator)}`, 'arrow.rb')
+ })
+ d5.bind('1',
+ proc{
+ eval_samplecode(`cat #{[$demo_dir,'ruler.rb'].join(File::Separator)}`, 'ruler.rb')
+ })
+ d6.bind('1',
+ proc{
+ eval_samplecode(`cat #{[$demo_dir,'cscroll.rb'].join(File::Separator)}`, 'cscroll.rb')
+ })
+
+ TkTextMarkInsert.new(t, '0.0')
+ configure('state','disabled')
+}
+
+txt.width 60
+txt.height 24
diff --git a/jni/ruby/ext/tk/sample/demos-jp/bitmap.rb b/jni/ruby/ext/tk/sample/demos-jp/bitmap.rb
new file mode 100644
index 0000000..d84e9a5
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/demos-jp/bitmap.rb
@@ -0,0 +1,74 @@
+# -*- coding: utf-8 -*-
+#
+# bitmap widget demo (called by 'widget')
+#
+
+# bitmapRow --
+# Create a row of bitmap items in a window.
+#
+# Arguments:
+# w - The parent window that is to contain the row.
+# args - The names of one or more bitmaps, which will be displayed
+# in a new row across the bottom of w along with their
+# names.
+
+def bitmapRow(w,*args)
+ TkFrame.new(w){|row|
+ pack('side'=>'top', 'fill'=>'both')
+ for bitmap in args
+ TkFrame.new(row){|base|
+ pack('side'=>'left', 'fill'=>'both', 'pady'=>'.25c', 'padx'=>'.25c')
+ TkLabel.new(base, 'text'=>bitmap, 'width'=>9).pack('side'=>'bottom')
+ Tk::Label.new(base, 'bitmap'=>bitmap).pack('side'=>'bottom')
+ }
+ end
+ }
+end
+
+# toplevel widget ãŒå­˜åœ¨ã™ã‚Œã°å‰Šé™¤ã™ã‚‹
+if defined?($bitmap_demo) && $bitmap_demo
+ $bitmap_demo.destroy
+ $bitmap_demo = nil
+end
+
+# demo 用㮠toplevel widget を生æˆ
+$bitmap_demo = TkToplevel.new {|w|
+ title("Bitmap Demonstration")
+ iconname("bitmap")
+ positionWindow(w)
+}
+
+base_frame = TkFrame.new($bitmap_demo).pack(:fill=>:both, :expand=>true)
+
+# label 生æˆ
+TkLabel.new(base_frame,'font'=>$font,'wraplength'=>'4i','justify'=>'left',
+ 'text'=>"ã“ã®ã‚¦ã‚£ãƒ³ãƒ‰ã‚¦ã«ã¯ã€Tk ã«çµ„ã¿è¾¼ã¾ã‚ŒãŸã™ã¹ã¦ã®ãƒ“ットマップãŒã€ãれらã®åå‰ã¨å…±ã«è¡¨ç¤ºã•ã‚Œã¦ã„ã¾ã™ã€‚Tcl ã®ã‚¹ã‚¯ãƒªãƒ—ト中ã§ã¯ã€ãã‚Œãžã‚Œã®åå‰ã‚’用ã„ã¦å‚ç…§ã—ã¾ã™ã€‚"){
+ pack('side'=>'top')
+}
+
+# frame 生æˆ
+$bitmap_buttons = TkFrame.new(base_frame) {|frame|
+ TkButton.new(frame) {
+ #text '了解'
+ text 'é–‰ã˜ã‚‹'
+ command proc{
+ tmppath = $bitmap_demo
+ $bitmap_demo = nil
+ tmppath.destroy
+ }
+ }.pack('side'=>'left', 'expand'=>'yes')
+
+ TkButton.new(frame) {
+ text 'コードå‚ç…§'
+ command proc{showCode 'bitmap'}
+ }.pack('side'=>'left', 'expand'=>'yes')
+}
+$bitmap_buttons.pack('side'=>'bottom', 'fill'=>'x', 'pady'=>'2m')
+
+# frame 設定
+TkFrame.new(base_frame){|f|
+ bitmapRow(f,'error','gray25','gray50','hourglass')
+ bitmapRow(f,'info','question','questhead','warning')
+ pack('side'=>'top', 'expand'=>'yes', 'fill'=>'both')
+}
+
diff --git a/jni/ruby/ext/tk/sample/demos-jp/browse1 b/jni/ruby/ext/tk/sample/demos-jp/browse1
new file mode 100644
index 0000000..568892e
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/demos-jp/browse1
@@ -0,0 +1,63 @@
+#!/usr/bin/env ruby
+
+# browse --
+# This script generates a directory browser, which lists the working
+# directory and allow you to open files or subdirectories by
+# double-clicking.
+
+require 'tk'
+
+# Create a scrollbar on the right side of the main window and a listbox
+# on the left side.
+
+listbox = TkListbox.new(nil, 'relief'=>'sunken',
+ 'width'=>20, 'height'=>20, 'setgrid'=>'yes') {|l|
+ TkScrollbar.new(nil, 'command'=>proc{|*args| l.yview *args}) {|s|
+ pack('side'=>'right', 'fill'=>'y')
+ l.yscrollcommand(proc{|first,last| s.set(first,last)})
+ }
+
+ pack('side'=>'left', 'fill'=>'both', 'expand'=>'yes')
+}
+
+root = TkRoot.new
+root.minsize(1,1)
+
+# The procedure below is invoked to open a browser on a given file; if the
+# file is a directory then another instance of this program is invoked; if
+# the file is a regular file then the Mx editor is invoked to display
+# the file.
+
+def browse (dir, file)
+ file = dir + File::Separator + file if dir != '.'
+ type = File.ftype(file)
+ if type == 'directory'
+ system($0 + ' ' + file + ' &')
+ else
+ if type == 'file'
+ if ENV['EDITOR']
+ system(ENV['EDITOR'] + ' ' + file + ' &')
+ else
+ system('xedit ' + file + ' &')
+ end
+ else
+ STDOUT.print "\"#{file}\" isn't a directory or regular file"
+ end
+ end
+end
+
+# Fill the listbox with a list of all the files in the directory (run
+# the "ls" command to get that information).
+
+dir = ARGV[0] ? ARGV[0] : '.'
+open("|ls -a #{dir}", 'r'){|fid| fid.readlines}.each{|fname|
+ listbox.insert('end', fname.chomp)
+}
+
+# Set up bindings for the browser.
+
+Tk.bind_all('Control-c', proc{root.destroy})
+listbox.bind('Double-Button-1',
+ proc{TkSelection.get.each{|f| browse dir, f}})
+
+Tk.mainloop
diff --git a/jni/ruby/ext/tk/sample/demos-jp/browse2 b/jni/ruby/ext/tk/sample/demos-jp/browse2
new file mode 100644
index 0000000..1a511c8
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/demos-jp/browse2
@@ -0,0 +1,82 @@
+#!/usr/bin/env ruby
+
+# browse --
+# This script generates a directory browser, which lists the working
+# directory and allow you to open files or subdirectories by
+# double-clicking.
+
+require 'tk'
+
+class Browse
+ BROWSE_WIN_COUNTER = TkVariable.new(0)
+
+ def initialize(dir)
+ BROWSE_WIN_COUNTER.value = BROWSE_WIN_COUNTER.to_i + 1
+
+ # create base frame
+ base = TkToplevel.new {
+ minsize(1,1)
+ title('Browse : ' + dir)
+ }
+
+ # Create a scrollbar on the right side of the main window and a listbox
+ # on the left side.
+ list = TkListbox.new(base, 'relief'=>'sunken',
+ 'width'=>20, 'height'=>20, 'setgrid'=>'yes') {|l|
+ TkScrollbar.new(base, 'command'=>proc{|*args| l.yview *args}) {|s|
+ pack('side'=>'right', 'fill'=>'y')
+ l.yscrollcommand(proc{|first,last| s.set(first,last)})
+ }
+
+ pack('side'=>'left', 'fill'=>'both', 'expand'=>'yes')
+
+ # Fill the listbox with a list of all the files in the directory (run
+ # the "ls" command to get that information).
+ open("|ls -a #{dir}", 'r'){|fid| fid.readlines}.each{|fname|
+ l.insert('end', fname.chomp)
+ }
+
+ }
+
+ # Set up bindings for the browser.
+ base.bind('Destroy', proc{
+ Browse::BROWSE_WIN_COUNTER.value = \
+ Browse::BROWSE_WIN_COUNTER.to_i - 1
+ })
+ base.bind('Control-c', proc{base.destroy})
+ list.bind('Double-Button-1',
+ proc{TkSelection.get.each{|f| self.browse dir, f}})
+ end
+
+ # The method below is invoked to open a browser on a given file; if the
+ # file is a directory then another instance of this program is invoked; if
+ # the file is a regular file then the Mx editor is invoked to display
+ # the file.
+ def browse (dir, file)
+ file = dir + File::Separator + file if dir != '.'
+ type = File.ftype(file)
+ if type == 'directory'
+ Browse.new(file)
+ else
+ if type == 'file'
+ if ENV['EDITOR']
+ system(ENV['EDITOR'] + ' ' + file + ' &')
+ else
+ system('xedit ' + file + ' &')
+ end
+ else
+ STDOUT.print "\"#{file}\" isn't a directory or regular file"
+ end
+ end
+ end
+
+end
+
+Browse.new(ARGV[0] ? ARGV[0] : '.')
+
+TkRoot.new {
+ withdraw
+ Browse::BROWSE_WIN_COUNTER.trace('w', proc{exit if Browse::BROWSE_WIN_COUNTER.to_i == 0})
+}
+
+Tk.mainloop
diff --git a/jni/ruby/ext/tk/sample/demos-jp/button.rb b/jni/ruby/ext/tk/sample/demos-jp/button.rb
new file mode 100644
index 0000000..301100b
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/demos-jp/button.rb
@@ -0,0 +1,83 @@
+# -*- coding: utf-8 -*-
+#
+# button widget demo (called by 'widget')
+#
+#
+
+# toplevel widget ãŒå­˜åœ¨ã™ã‚Œã°å‰Šé™¤ã™ã‚‹
+if defined?($button_demo) && $button_demo
+ $button_demo.destroy
+ $button_demo = nil
+end
+
+# demo 用㮠toplevel widget を生æˆ
+$button_demo = TkToplevel.new {|w|
+ title("Button Demonstration")
+ iconname("button")
+ positionWindow(w)
+}
+
+# label 生æˆ
+msg = TkLabel.new($button_demo) {
+ font $kanji_font
+ wraplength '4i'
+ justify 'left'
+ text "ボタンをクリックã™ã‚‹ã¨ã€ãƒœã‚¿ãƒ³ã®èƒŒæ™¯è‰²ãŒãã®ãƒœã‚¿ãƒ³ã«æ›¸ã‹ã‚Œã¦ã„る色ã«ãªã‚Šã¾ã™ã€‚ボタンã‹ã‚‰ãƒœã‚¿ãƒ³ã¸ã®ç§»å‹•ã¯ã‚¿ãƒ–を押ã™ã“ã¨ã§ã‚‚å¯èƒ½ã§ã™ã€‚ã¾ãŸã‚¹ãƒšãƒ¼ã‚¹ã§å®Ÿè¡Œã™ã‚‹ã“ã¨ãŒã§ãã¾ã™ã€‚"
+}
+msg.pack('side'=>'top')
+
+# frame 生æˆ
+$button_buttons = Tk::Frame.new($button_demo) {|frame|
+ TkButton.new(frame) {
+ #text '了解'
+ text 'é–‰ã˜ã‚‹'
+ command proc{
+ tmppath = $button_demo
+ $button_demo = nil
+ tmppath.destroy
+ }
+ }.pack('side'=>'left', 'expand'=>'yes')
+
+ TkButton.new(frame) {
+ text 'コードå‚ç…§'
+ command proc{showCode 'button'}
+ }.pack('side'=>'left', 'expand'=>'yes')
+
+}.pack('side'=>'bottom', 'fill'=>'x', 'pady'=>'2m')
+
+# button 生æˆ
+TkButton.new($button_demo){
+ text "Peach Puff"
+ width 10
+ command proc{
+ $button_demo.configure('bg','PeachPuff1')
+ $button_buttons.configure('bg','PeachPuff1')
+ }
+}.pack('side'=>'top', 'expand'=>'yes', 'pady'=>2)
+
+TkButton.new($button_demo){
+ text "Light Blue"
+ width 10
+ command proc{
+ $button_demo.configure('bg','LightBlue1')
+ $button_buttons.configure('bg','LightBlue1')
+ }
+}.pack('side'=>'top', 'expand'=>'yes', 'pady'=>2)
+
+TkButton.new($button_demo){
+ text "Sea Green"
+ width 10
+ command proc{
+ $button_demo.configure('bg','SeaGreen2')
+ $button_buttons.configure('bg','SeaGreen2')
+ }
+}.pack('side'=>'top', 'expand'=>'yes', 'pady'=>2)
+
+TkButton.new($button_demo){
+ text "Yellow"
+ width 10
+ command proc{
+ $button_demo.configure('bg','Yellow1')
+ $button_buttons.configure('bg','Yellow1')
+ }
+}.pack('side'=>'top', 'expand'=>'yes', 'pady'=>2)
diff --git a/jni/ruby/ext/tk/sample/demos-jp/check.rb b/jni/ruby/ext/tk/sample/demos-jp/check.rb
new file mode 100644
index 0000000..422e898
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/demos-jp/check.rb
@@ -0,0 +1,70 @@
+# -*- coding: utf-8 -*-
+#
+# checkbutton widget demo (called by 'widget')
+#
+
+# toplevel widget ãŒå­˜åœ¨ã™ã‚Œã°å‰Šé™¤ã™ã‚‹
+if defined?($check_demo) && $check_demo
+ $check_demo.destroy
+ $check_demo = nil
+end
+
+# demo 用㮠toplevel widget を生æˆ
+$check_demo = TkToplevel.new {|w|
+ title("Checkbutton Demonstration")
+ iconname("check")
+ positionWindow(w)
+}
+
+base_frame = TkFrame.new($check_demo).pack(:fill=>:both, :expand=>true)
+
+# label 生æˆ
+msg = TkLabel.new(base_frame) {
+ font $font
+ wraplength '4i'
+ justify 'left'
+ text "下ã«ã¯ 3 ã¤ã®ãƒã‚§ãƒƒã‚¯ãƒœã‚¿ãƒ³ãŒè¡¨ç¤ºã•ã‚Œã¦ã„ã¾ã™ã€‚クリックã™ã‚‹ã¨ãƒœã‚¿ãƒ³ã®é¸æŠžçŠ¶æ…‹ãŒå¤‰ã‚ã‚Šã€Tcl 変数 ( TkVariable オブジェクトã§ã‚¢ã‚¯ã‚»ã‚¹ã§ãã¾ã™ ) ã«ãã®ãƒœã‚¿ãƒ³ã®çŠ¶æ…‹ã‚’示ã™å€¤ã‚’設定ã—ã¾ã™ã€‚ç¾åœ¨ã®å¤‰æ•°ã®å€¤ã‚’見るã«ã¯ã€Œå¤‰æ•°å‚ç…§ã€ãƒœã‚¿ãƒ³ã‚’クリックã—ã¦ãã ã•ã„。"
+}
+msg.pack('side'=>'top')
+
+# 変数生æˆ
+wipers = TkVariable.new(0)
+brakes = TkVariable.new(0)
+sober = TkVariable.new(0)
+
+# frame 生æˆ
+TkFrame.new(base_frame) {|frame|
+ TkButton.new(frame) {
+ #text '了解'
+ text 'é–‰ã˜ã‚‹'
+ command proc{
+ tmppath = $check_demo
+ $check_demo = nil
+ $showVarsWin[tmppath.path] = nil
+ tmppath.destroy
+ }
+ }.pack('side'=>'left', 'expand'=>'yes')
+
+ TkButton.new(frame) {
+ text 'コードå‚ç…§'
+ command proc{showCode 'check'}
+ }.pack('side'=>'left', 'expand'=>'yes')
+
+
+ TkButton.new(frame) {
+ text '変数å‚ç…§'
+ command proc{
+ showVars(base_frame,
+ ['wipers', wipers], ['brakes', brakes], ['sober', sober])
+ }
+ }.pack('side'=>'left', 'expand'=>'yes')
+
+}.pack('side'=>'bottom', 'fill'=>'x', 'pady'=>'2m')
+
+
+# checkbutton 生æˆ
+[ TkCheckButton.new(base_frame, 'text'=>'ワイパー OK', 'variable'=>wipers),
+ TkCheckButton.new(base_frame, 'text'=>'ブレーキ OK', 'variable'=>brakes),
+ TkCheckButton.new(base_frame, 'text'=>'é‹è»¢æ‰‹ ç´ é¢', 'variable'=>sober)
+].each{|w| w.relief('flat'); w.pack('side'=>'top', 'pady'=>2, 'anchor'=>'w')}
+
diff --git a/jni/ruby/ext/tk/sample/demos-jp/check2.rb b/jni/ruby/ext/tk/sample/demos-jp/check2.rb
new file mode 100644
index 0000000..558e588
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/demos-jp/check2.rb
@@ -0,0 +1,110 @@
+# -*- coding: utf-8 -*-
+#
+# checkbutton widget demo2 (called by 'widget')
+#
+
+# toplevel widget ãŒå­˜åœ¨ã™ã‚Œã°å‰Šé™¤ã™ã‚‹
+if defined?($check2_demo) && $check2_demo
+ $check2_demo.destroy
+ $check2_demo = nil
+end
+
+# demo 用㮠toplevel widget を生æˆ
+$check2_demo = TkToplevel.new {|w|
+ title("Checkbutton Demonstration 2")
+ iconname("check2")
+ positionWindow(w)
+}
+
+base_frame = TkFrame.new($check2_demo).pack(:fill=>:both, :expand=>true)
+
+# label 生æˆ
+msg = TkLabel.new(base_frame) {
+ font $font
+ wraplength '4i'
+ justify 'left'
+ text "下ã«ã¯ï¼”ã¤ã®ãƒã‚§ãƒƒã‚¯ãƒœã‚¿ãƒ³ãŒè¡¨ç¤ºã•ã‚Œã¦ã„ã¾ã™ã€‚クリックã™ã‚‹ã¨ãƒœã‚¿ãƒ³ã®é¸æŠžçŠ¶æ…‹ãŒå¤‰ã‚ã‚Šã€Tcl変数(TkVariableオブジェクトã§ã‚¢ã‚¯ã‚»ã‚¹ã§ãã¾ã™ï¼‰ã«ãã®ãƒœã‚¿ãƒ³ã®çŠ¶æ…‹ã‚’示ã™å€¤ã‚’設定ã—ã¾ã™ã€‚最åˆã®ãƒœã‚¿ãƒ³ã®çŠ¶æ…‹ã¯ä»–ã®ï¼“ã¤ã®ãƒœã‚¿ãƒ³ã®çŠ¶æ…‹ã«ã‚‚ä¾å­˜ã—ã¦å¤‰åŒ–ã—ã¾ã™ã€‚ã‚‚ã—3ã¤ã®ãƒœã‚¿ãƒ³ã®ä¸€éƒ¨ã ã‘ã«ãƒã‚§ãƒƒã‚¯ãŒä»˜ã‘られã¦ã„ã‚‹å ´åˆã€æœ€åˆã®ãƒœã‚¿ãƒ³ã¯ãƒˆãƒ©ã‚¤ã‚¹ãƒ†ãƒ¼ãƒˆï¼ˆï¼“状態)モードã§ã®è¡¨ç¤ºã‚’è¡Œã„ã¾ã™ã€‚ç¾åœ¨ã®å¤‰æ•°ã®å€¤ã‚’見るã«ã¯ã€Œå¤‰æ•°å‚ç…§ã€ãƒœã‚¿ãƒ³ã‚’クリックã—ã¦ãã ã•ã„。"
+}
+msg.pack('side'=>'top')
+
+# 変数生æˆ
+safety = TkVariable.new(0)
+wipers = TkVariable.new(0)
+brakes = TkVariable.new(0)
+sober = TkVariable.new(0)
+
+# frame 生æˆ
+TkFrame.new(base_frame) {|frame|
+ TkGrid(TkFrame.new(frame, :height=>2, :relief=>:sunken, :bd=>2),
+ :columnspan=>4, :row=>0, :sticky=>'ew', :pady=>2)
+ TkGrid('x',
+ TkButton.new(frame, :text=>'変数å‚ç…§',
+ :image=>$image['view'], :compound=>:left,
+ :command=>proc{
+ showVars($check2_demo,
+ ['safety', safety], ['wipers', wipers],
+ ['brakes', brakes], ['sober', sober])
+ }),
+ TkButton.new(frame, :text=>'コードå‚ç…§',
+ :image=>$image['view'], :compound=>:left,
+ :command=>proc{showCode 'check2'}),
+ TkButton.new(frame, :text=>'é–‰ã˜ã‚‹',
+ :image=>$image['delete'], :compound=>:left,
+ :command=>proc{
+ tmppath = $check2_demo
+ $check2_demo = nil
+ $showVarsWin[tmppath.path] = nil
+ tmppath.destroy
+ }),
+ :padx=>4, :pady=>4)
+ frame.grid_columnconfigure(0, :weight=>1)
+}.pack('side'=>'bottom', 'fill'=>'x')
+
+
+# checkbutton 生æˆ
+TkCheckButton.new(base_frame, :text=>'安全性検査', :variable=>safety,
+ :relief=>:flat, :onvalue=>'all', :offvalue=>'none',
+ :tristatevalue=>'partial'){
+ pack('side'=>'top', 'pady'=>2, 'anchor'=>'w')
+}
+
+[ TkCheckButton.new(base_frame, 'text'=>'ワイパー OK', 'variable'=>wipers),
+ TkCheckButton.new(base_frame, 'text'=>'ブレーキ OK', 'variable'=>brakes),
+ TkCheckButton.new(base_frame, 'text'=>'é‹è»¢æ‰‹ ç´ é¢', 'variable'=>sober)
+].each{|w|
+ w.relief('flat')
+ w.pack('side'=>'top', 'padx'=>15, 'pady'=>2, 'anchor'=>'w')
+}
+
+# tristate check
+in_check = false
+tristate_check = proc{|n1,n2,op|
+ unless in_check
+ in_check = true
+ begin
+ if n1 == safety
+ if safety == 'none'
+ wipers.value = 0
+ brakes.value = 0
+ sober.value = 0
+ elsif safety == 'all'
+ wipers.value = 1
+ brakes.value = 1
+ sober.value = 1
+ end
+ else
+ if wipers == 1 && brakes == 1 && sober == 1
+ safety.value = 'all'
+ elsif wipers == 1 || brakes == 1 || sober == 1
+ safety.value = 'partial'
+ else
+ safety.value = 'none'
+ end
+ end
+ ensure
+ in_check = false
+ end
+ end
+}
+
+[wipers, brakes, sober, safety].each{|v| v.trace('w', tristate_check)}
diff --git a/jni/ruby/ext/tk/sample/demos-jp/clrpick.rb b/jni/ruby/ext/tk/sample/demos-jp/clrpick.rb
new file mode 100644
index 0000000..df8c76a
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/demos-jp/clrpick.rb
@@ -0,0 +1,84 @@
+# -*- coding: utf-8 -*-
+#
+# widget demo prompts the user to select a color (called by 'widget')
+#
+# Note: don't support ttk_wrapper. work with standard widgets only.
+#
+
+# toplevel widget ãŒå­˜åœ¨ã™ã‚Œã°å‰Šé™¤ã™ã‚‹
+if defined?($clrpick_demo) && $clrpick_demo
+ $clrpick_demo.destroy
+ $clrpick_demo = nil
+end
+
+# demo 用㮠toplevel widget を生æˆ
+$clrpick_demo = TkToplevel.new {|w|
+ title("Color Selection Dialogs")
+ iconname("colors")
+ positionWindow(w)
+}
+
+# label 生æˆ
+#TkLabel.new($clrpick_demo,'font'=>$font,'wraplength'=>'4i','justify'=>'left',
+Tk::Label.new($clrpick_demo,'font'=>$font,'wraplength'=>'4i','justify'=>'left',
+ 'text'=>"以下ã®ãƒœã‚¿ãƒ³ã‚’押ã—ã¦ã€ã“ã®ã‚¦ã‚£ãƒ³ãƒ‰ã‚¦ä¸Šã«ã‚るウィジェットã®å‰æ™¯è‰²ã¨èƒŒæ™¯è‰²ã‚’é¸æŠžã—ã¦ä¸‹ã•ã„。").pack('side'=>'top')
+
+# frame 生æˆ
+# TkFrame.new($clrpick_demo) {|frame|
+Tk::Frame.new($clrpick_demo) {|frame|
+ # TkButton.new(frame) {
+ Tk::Button.new(frame) {
+ #text '了解'
+ text 'é–‰ã˜ã‚‹'
+ command proc{
+ tmppath = $clrpick_demo
+ $clrpick_demo = nil
+ tmppath.destroy
+ }
+ }.pack('side'=>'left', 'expand'=>'yes')
+
+ # TkButton.new(frame) {
+ Tk::Button.new(frame) {
+ text 'コードå‚ç…§'
+ command proc{showCode 'clrpick'}
+ }.pack('side'=>'left', 'expand'=>'yes')
+}.pack('side'=>'bottom', 'fill'=>'x', 'pady'=>'2m')
+
+# button 生æˆ
+# TkButton.new($clrpick_demo, 'text'=>'背景色を設定 ...') {|b|
+Tk::Button.new($clrpick_demo, 'text'=>'背景色を設定 ...') {|b|
+ command(proc{setColor $clrpick_demo, b, 'background',
+ ['background', 'highlightbackground']})
+ pack('side'=>'top', 'anchor'=>'c', 'pady'=>'2m')
+}
+
+# TkButton.new($clrpick_demo, 'text'=>'å‰æ™¯è‰²ã‚’設定 ...') {|b|
+Tk::Button.new($clrpick_demo, 'text'=>'å‰æ™¯è‰²ã‚’設定 ...') {|b|
+ command(proc{setColor $clrpick_demo, b, 'foreground', ['foreground']})
+ pack('side'=>'top', 'anchor'=>'c', 'pady'=>'2m')
+}
+
+def setColor(w,button,name,options)
+ w.grab
+ initialColor = button[name]
+ color = Tk.chooseColor('title'=>"Choose a #{name} color", 'parent'=>w,
+ 'initialcolor'=>initialColor)
+ if color != ""
+ setColor_helper(w,options,color)
+ end
+
+ w.grab('release')
+end
+
+def setColor_helper(w, options, color)
+ options.each{|opt|
+ begin
+ w[opt] = color
+ rescue
+ end
+ }
+ TkWinfo.children(w).each{|child|
+ setColor_helper child, options, color
+ }
+end
+
diff --git a/jni/ruby/ext/tk/sample/demos-jp/colors.rb b/jni/ruby/ext/tk/sample/demos-jp/colors.rb
new file mode 100644
index 0000000..5e5f47c
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/demos-jp/colors.rb
@@ -0,0 +1,155 @@
+# -*- coding: utf-8 -*-
+#
+# listbox widget demo 'colors' (called by 'widget')
+#
+
+# toplevel widget ãŒå­˜åœ¨ã™ã‚Œã°å‰Šé™¤ã™ã‚‹
+if defined?($colors_demo) && $colors_demo
+ $colors_demo.destroy
+ $colors_demo = nil
+end
+
+# demo 用㮠toplevel widget を生æˆ
+$colors_demo = TkToplevel.new {|w|
+ title("Listbox Demonstration (colors)")
+ iconname("colors")
+ positionWindow(w)
+}
+
+base_frame = TkFrame.new($colors_demo).pack(:fill=>:both, :expand=>true)
+
+# label 生æˆ
+msg = TkLabel.new(base_frame) {
+ font $font
+ wraplength '4i'
+ justify 'left'
+ text "下ã«ã¯è‰²ã®åå‰ãŒå…¥ã£ãŸã‚¹ã‚¯ãƒ­ãƒ¼ãƒ«ãƒãƒ¼ä»˜ã®ãƒªã‚¹ãƒˆãƒœãƒƒã‚¯ã‚¹ãŒè¡¨ç¤ºã•ã‚Œã¦ã„ã¾ã™ã€‚リストをスクロールã•ã›ã‚‹ã®ã¯ã‚¹ã‚¯ãƒ­ãƒ¼ãƒ«ãƒãƒ¼ã§ã‚‚ã§ãã¾ã™ã—ã€ãƒªã‚¹ãƒˆãƒœãƒƒã‚¯ã‚¹ã®ä¸­ã§ãƒžã‚¦ã‚¹ã®ãƒœã‚¿ãƒ³2(中ボタン)を押ã—ãŸã¾ã¾ãƒ‰ãƒ©ãƒƒã‚°ã—ã¦ã‚‚ã§ãã¾ã™ã€‚ã‚る色をボタン1(左ボタン)ã§ãƒ€ãƒ–ルクリックã™ã‚‹ã¨ã‚¢ãƒ—リケーション全体ãŒãã®è‰²ã«ãªã‚Šã¾ã™ã€‚"
+}
+msg.pack('side'=>'top')
+
+# frame 生æˆ
+TkFrame.new(base_frame) {|frame|
+ TkButton.new(frame) {
+ #text '了解'
+ text 'é–‰ã˜ã‚‹'
+ command proc{
+ tmppath = $colors_demo
+ $colors_demo = nil
+ tmppath.destroy
+ }
+ }.pack('side'=>'left', 'expand'=>'yes')
+
+ TkButton.new(frame) {
+ text 'コードå‚ç…§'
+ command proc{showCode 'colors'}
+ }.pack('side'=>'left', 'expand'=>'yes')
+
+}.pack('side'=>'bottom', 'fill'=>'x', 'pady'=>'2m')
+
+# frame 生æˆ
+colors_lbox = nil
+TkFrame.new(base_frame, 'borderwidth'=>10) {|w|
+ s = TkScrollbar.new(w)
+ colors_lbox = TkListbox.new(w) {
+ setgrid 1
+ width 10
+ height 12
+ yscrollcommand proc{|first,last| s.set first,last}
+ }
+ s.command(proc{|*args| colors_lbox.yview(*args)})
+ s.pack('side'=>'right', 'fill'=>'y')
+ colors_lbox.pack('side'=>'left', 'expand'=>1, 'fill'=>'both')
+}.pack('side'=>'top', 'expand'=>'yes', 'fill'=>'y')
+
+#colors_lbox.bind('Double-1', proc{TkPalette.setPalette TkSelection.get})
+colors_lbox.bind('Double-1', proc{
+ begin
+ TkPalette.setPalette TkSelection.get
+ rescue => e
+ p e
+ Tk.tk_call_without_enc('destroy', '.___tk_set_palette')
+ end
+ })
+
+ins_data = [
+ 'gray60','gray70','gray80','gray85','gray90','gray95',
+ 'snow1','snow2','snow3','snow4','seashell1','seashell2',
+ 'seashell3','seashell4','AntiqueWhite1','AntiqueWhite2',
+ 'AntiqueWhite3','AntiqueWhite4','bisque1','bisque2',
+ 'bisque3','bisque4','PeachPuff1','PeachPuff2',
+ 'PeachPuff3','PeachPuff4','NavajoWhite1','NavajoWhite2',
+ 'NavajoWhite3','NavajoWhite4','LemonChiffon1',
+ 'LemonChiffon2','LemonChiffon3','LemonChiffon4',
+ 'cornsilk1','cornsilk2','cornsilk3','cornsilk4',
+ 'ivory1','ivory2','ivory3','ivory4','honeydew1',
+ 'honeydew2','honeydew3','honeydew4','LavenderBlush1',
+ 'LavenderBlush2','LavenderBlush3','LavenderBlush4',
+ 'MistyRose1','MistyRose2','MistyRose3','MistyRose4',
+ 'azure1','azure2','azure3','azure4','SlateBlue1',
+ 'SlateBlue2','SlateBlue3','SlateBlue4','RoyalBlue1',
+ 'RoyalBlue2','RoyalBlue3','RoyalBlue4','blue1','blue2',
+ 'blue3','blue4','DodgerBlue1','DodgerBlue2',
+ 'DodgerBlue3','DodgerBlue4','SteelBlue1','SteelBlue2',
+ 'SteelBlue3','SteelBlue4','DeepSkyBlue1','DeepSkyBlue2',
+ 'DeepSkyBlue3','DeepSkyBlue4','SkyBlue1','SkyBlue2',
+ 'SkyBlue3','SkyBlue4','LightSkyBlue1','LightSkyBlue2',
+ 'LightSkyBlue3','LightSkyBlue4','SlateGray1',
+ 'SlateGray2','SlateGray3','SlateGray4',
+ 'LightSteelBlue1','LightSteelBlue2','LightSteelBlue3',
+ 'LightSteelBlue4','LightBlue1','LightBlue2',
+ 'LightBlue3','LightBlue4','LightCyan1','LightCyan2',
+ 'LightCyan3','LightCyan4','PaleTurquoise1',
+ 'PaleTurquoise2','PaleTurquoise3','PaleTurquoise4',
+ 'CadetBlue1','CadetBlue2','CadetBlue3','CadetBlue4',
+ 'turquoise1','turquoise2','turquoise3','turquoise4',
+ 'cyan1','cyan2','cyan3','cyan4','DarkSlateGray1',
+ 'DarkSlateGray2','DarkSlateGray3','DarkSlateGray4',
+ 'aquamarine1','aquamarine2','aquamarine3','aquamarine4',
+ 'DarkSeaGreen1','DarkSeaGreen2','DarkSeaGreen3',
+ 'DarkSeaGreen4','SeaGreen1','SeaGreen2','SeaGreen3',
+ 'SeaGreen4','PaleGreen1','PaleGreen2','PaleGreen3',
+ 'PaleGreen4','SpringGreen1','SpringGreen2',
+ 'SpringGreen3','SpringGreen4','green1','green2',
+ 'green3','green4','chartreuse1','chartreuse2',
+ 'chartreuse3','chartreuse4','OliveDrab1','OliveDrab2',
+ 'OliveDrab3','OliveDrab4','DarkOliveGreen1',
+ 'DarkOliveGreen2','DarkOliveGreen3','DarkOliveGreen4',
+ 'khaki1','khaki2','khaki3','khaki4','LightGoldenrod1',
+ 'LightGoldenrod2','LightGoldenrod3','LightGoldenrod4',
+ 'LightYellow1','LightYellow2','LightYellow3',
+ 'LightYellow4','yellow1','yellow2','yellow3','yellow4',
+ 'gold1','gold2','gold3','gold4','goldenrod1',
+ 'goldenrod2','goldenrod3','goldenrod4','DarkGoldenrod1',
+ 'DarkGoldenrod2','DarkGoldenrod3','DarkGoldenrod4',
+ 'RosyBrown1','RosyBrown2','RosyBrown3','RosyBrown4',
+ 'IndianRed1','IndianRed2','IndianRed3','IndianRed4',
+ 'sienna1','sienna2','sienna3','sienna4','burlywood1',
+ 'burlywood2','burlywood3','burlywood4','wheat1',
+ 'wheat2','wheat3','wheat4','tan1','tan2','tan3','tan4',
+ 'chocolate1','chocolate2','chocolate3','chocolate4',
+ 'firebrick1','firebrick2','firebrick3','firebrick4',
+ 'brown1','brown2','brown3','brown4','salmon1','salmon2',
+ 'salmon3','salmon4','LightSalmon1','LightSalmon2',
+ 'LightSalmon3','LightSalmon4','orange1','orange2',
+ 'orange3','orange4','DarkOrange1','DarkOrange2',
+ 'DarkOrange3','DarkOrange4','coral1','coral2','coral3',
+ 'coral4','tomato1','tomato2','tomato3','tomato4',
+ 'OrangeRed1','OrangeRed2','OrangeRed3','OrangeRed4',
+ 'red1','red2','red3','red4','DeepPink1','DeepPink2',
+ 'DeepPink3','DeepPink4','HotPink1','HotPink2',
+ 'HotPink3','HotPink4','pink1','pink2','pink3','pink4',
+ 'LightPink1','LightPink2','LightPink3','LightPink4',
+ 'PaleVioletRed1','PaleVioletRed2','PaleVioletRed3',
+ 'PaleVioletRed4','maroon1','maroon2','maroon3',
+ 'maroon4','VioletRed1','VioletRed2','VioletRed3',
+ 'VioletRed4','magenta1','magenta2','magenta3',
+ 'magenta4','orchid1','orchid2','orchid3','orchid4',
+ 'plum1','plum2','plum3','plum4','MediumOrchid1',
+ 'MediumOrchid2','MediumOrchid3','MediumOrchid4',
+ 'DarkOrchid1','DarkOrchid2','DarkOrchid3',
+ 'DarkOrchid4','purple1','purple2','purple3','purple4',
+ 'MediumPurple1','MediumPurple2','MediumPurple3',
+ 'MediumPurple4','thistle1','thistle2','thistle3', 'thistle4'
+]
+
+colors_lbox.insert(0, *ins_data)
diff --git a/jni/ruby/ext/tk/sample/demos-jp/combo.rb b/jni/ruby/ext/tk/sample/demos-jp/combo.rb
new file mode 100644
index 0000000..8bbe369
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/demos-jp/combo.rb
@@ -0,0 +1,98 @@
+# -*- coding: utf-8 -*-
+#
+# combo.rb --
+#
+# This demonstration script creates several combobox widgets.
+#
+# based on "Id: combo.tcl,v 1.3 2007/12/13 15:27:07 dgp Exp"
+
+if defined?($combo_demo) && $combo_demo
+ $combo_demo.destroy
+ $combo_demo = nil
+end
+
+$combo_demo = TkToplevel.new {|w|
+ title("Combobox Demonstration")
+ iconname("combo")
+ positionWindow(w)
+}
+
+base_frame = TkFrame.new($combo_demo).pack(:fill=>:both, :expand=>true)
+
+Ttk::Label.new(base_frame, :font=>$font, :wraplength=>'5i', :justify=>:left,
+ :text=><<EOL).pack(:side=>:top, :fill=>:x)
+以下ã§ã¯3種類ã®ã‚³ãƒ³ãƒœãƒœãƒƒã‚¯ã‚¹ãŒè¡¨ç¤ºã•ã‚Œã¦ã„ã¾ã™ï¼Ž\
+最åˆã®ã‚‚ã®ã¯ï¼Œã‚¨ãƒ³ãƒˆãƒªã‚¦ã‚£ã‚¸ã‚§ãƒƒãƒˆã¨åŒã˜æ§˜ã«ï¼Œ\
+ãƒã‚¤ãƒ³ãƒˆã—ãŸã‚Šï¼Œã‚¯ãƒªãƒƒã‚¯ã—ãŸã‚Šï¼Œã‚¿ã‚¤ãƒ—ã—ãŸã‚Šã™ã‚‹ã“ã¨ãŒã§ãã¾ã™ï¼Ž\
+ã¾ãŸï¼ŒReturnキーを入力ã™ã‚Œã°ç¾åœ¨ã®å€¤ãŒãƒªã‚¹ãƒˆã«è¿½åŠ ã•ã‚Œï¼Œ\
+ドロップダウンリストã‹ã‚‰é¸æŠžã™ã‚‹ã“ã¨ãŒã§ãるよã†ã«ãªã‚Šã¾ã™ï¼Ž\
+↓(下å‘ã矢å°)キーを押ã—ã¦è¡¨ç¤ºã•ã‚ŒãŸãƒªã‚¹ãƒˆã‹ã‚‰\
+矢å°ã‚­ãƒ¼ã§ä»–ã®å€™è£œã‚’é¸ã‚“ã§Returnキーを押ã›ã°ï¼Œå€¤ã‚’é¸æŠžã§ãã¾ã™ï¼Ž\
+2番目ã®ã‚³ãƒ³ãƒœãƒœãƒƒã‚¯ã‚¹ã¯ç‰¹å®šã®å€¤ã«å›ºå®šã•ã‚Œã¦ãŠã‚Šï¼Œä¸€åˆ‡å¤‰æ›´ã§ãã¾ã›ã‚“.\
+3番目ã®ã‚‚ã®ã¯ã‚ªãƒ¼ã‚¹ãƒˆãƒ©ãƒªã‚¢ã®éƒ½å¸‚ã®ãƒ‰ãƒ­ãƒƒãƒ—ダウンリストã‹ã‚‰\
+é¸æŠžã™ã‚‹ã“ã¨ã ã‘ãŒå¯èƒ½ã¨ãªã£ã¦ã„ã¾ã™ï¼Ž
+EOL
+
+## variables
+firstValue = TkVariable.new
+secondValue = TkVariable.new
+ozCity = TkVariable.new
+
+## See Code / Dismiss buttons
+Ttk::Frame.new(base_frame) {|frame|
+ sep = Ttk::Separator.new(frame)
+ Tk.grid(sep, :columnspan=>4, :row=>0, :sticky=>'ew', :pady=>2)
+ TkGrid('x',
+ Ttk::Button.new(frame, :text=>'変数å‚ç…§',
+ :image=>$image['view'], :compound=>:left,
+ :command=>proc{
+ showVars(base_frame,
+ ['firstVariable', firstValue],
+ ['secondVariable', secondValue],
+ ['ozCity', ozCity])
+ }),
+ Ttk::Button.new(frame, :text=>'コードå‚ç…§',
+ :image=>$image['view'], :compound=>:left,
+ :command=>proc{showCode 'combo'}),
+ Ttk::Button.new(frame, :text=>'é–‰ã˜ã‚‹',
+ :image=>$image['delete'], :compound=>:left,
+ :command=>proc{
+ $combo_demo.destroy
+ $combo_demo = nil
+ }),
+ :padx=>4, :pady=>4)
+ grid_columnconfigure(0, :weight=>1)
+ pack(:side=>:bottom, :fill=>:x)
+}
+
+frame = Ttk::Frame.new(base_frame).pack(:fill=>:both, :expand=>true)
+
+australianCities = [
+ 'キャンベラ', 'シドニー', 'メルボルン', 'パース', 'アデレード',
+ 'ブリスベーン', 'ホãƒãƒ¼ãƒˆ', 'ダーウィン', 'アリス スプリングス'
+]
+
+
+secondValue.value = '変更ä¸å¯'
+ozCity.value = 'シドニー'
+
+Tk.pack(Ttk::Labelframe.new(frame, :text=>'Fully Editable'){|f|
+ Ttk::Combobox.new(f, :textvariable=>firstValue){|b|
+ b.bind('Return', '%W'){|w|
+ w.values <<= w.value unless w.values.include?(w.value)
+ }
+ }.pack(:pady=>5, :padx=>10)
+ },
+
+ Ttk::LabelFrame.new(frame, :text=>'Disabled'){|f|
+ Ttk::Combobox.new(f, :textvariable=>secondValue, :state=>:disabled) .
+ pack(:pady=>5, :padx=>10)
+ },
+
+ Ttk::LabelFrame.new(frame, :text=>'Defined List Only'){|f|
+ Ttk::Combobox.new(f, :textvariable=>ozCity, :state=>:readonly,
+ :values=>australianCities) .
+ pack(:pady=>5, :padx=>10)
+ },
+
+ :side=>:top, :pady=>5, :padx=>10)
diff --git a/jni/ruby/ext/tk/sample/demos-jp/cscroll.rb b/jni/ruby/ext/tk/sample/demos-jp/cscroll.rb
new file mode 100644
index 0000000..e993326
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/demos-jp/cscroll.rb
@@ -0,0 +1,134 @@
+# -*- coding: utf-8 -*-
+#
+# simple scrollable canvas widget demo (called by 'widget')
+#
+
+# toplevel widget ãŒå­˜åœ¨ã™ã‚Œã°å‰Šé™¤ã™ã‚‹
+if defined?($cscroll_demo) && $cscroll_demo
+ $cscroll_demo.destroy
+ $cscroll_demo = nil
+end
+
+# demo 用㮠toplevel widget を生æˆ
+$cscroll_demo = TkToplevel.new {|w|
+ title("Scrollable Canvas Demonstration")
+ iconname("cscroll")
+ positionWindow(w)
+}
+
+base_frame = TkFrame.new($cscroll_demo).pack(:fill=>:both, :expand=>true)
+
+# label 生æˆ
+TkLabel.new(base_frame, 'font'=>$font, 'wraplength'=>'4i',
+ 'justify'=>'left', 'text'=>"ã“ã®ã‚¦ã‚£ãƒ³ãƒ‰ã‚¦ã«ã¯ã‚¹ã‚¯ãƒ­ãƒ¼ãƒ«ãƒãƒ¼ã‚„マウスã®ãƒœã‚¿ãƒ³2 ã§ã‚¹ã‚¯ãƒ­ãƒ¼ãƒ«ã§ãるキャンãƒã‚¹ widget ãŒè¡¨ç¤ºã•ã‚Œã¦ã„ã¾ã™ã€‚四角ã®ä¸Šã§ãƒœã‚¿ãƒ³1 をクリックã™ã‚‹ã¨ã€ãã®ã‚¤ãƒ³ãƒ‡ãƒƒã‚¯ã‚¹ãŒæ¨™æº–出力ã«å‡ºåŠ›ã•ã‚Œã¾ã™ã€‚"){
+ pack('side'=>'top')
+}
+
+# frame 生æˆ
+$cscroll_buttons = TkFrame.new(base_frame) {|frame|
+ TkButton.new(frame) {
+ #text '了解'
+ text 'é–‰ã˜ã‚‹'
+ command proc{
+ tmppath = $cscroll_demo
+ $cscroll_demo = nil
+ tmppath.destroy
+ }
+ }.pack('side'=>'left', 'expand'=>'yes')
+
+ TkButton.new(frame) {
+ text 'コードå‚ç…§'
+ command proc{showCode 'cscroll'}
+ }.pack('side'=>'left', 'expand'=>'yes')
+}
+$cscroll_buttons.pack('side'=>'bottom', 'fill'=>'x', 'pady'=>'2m')
+
+# frame 設定
+unless $tk_version =~ /^4\.[01]/
+ $cscroll_grid = TkFrame.new(base_frame) {
+ pack('expand'=>'yes', 'fill'=>'both', 'padx'=>1, 'pady'=>1)
+ }
+ TkGrid.rowconfigure($cscroll_grid, 0, 'weight'=>1, 'minsize'=>0)
+ TkGrid.columnconfigure($cscroll_grid, 0, 'weight'=>1, 'minsize'=>0)
+end
+
+# canvas 設定
+$cscroll_canvas = TkCanvas.new(base_frame,
+ 'relief'=>'sunken', 'borderwidth'=>2,
+ 'scrollregion'=>['-11c', '-11c', '50c', '20c']
+ ) {|c|
+ if $tk_version =~ /^4\.[01]/
+ pack('expand'=>'yes', 'fill'=>'both')
+ else
+ grid('in'=>$cscroll_grid, 'padx'=>1, 'pady'=>1, 'row'=>0, 'column'=>0,
+ 'rowspan'=>1, 'columnspan'=>1, 'sticky'=>'news')
+ end
+
+ TkScrollbar.new(base_frame, 'command'=>proc{|*args| c.yview(*args)}) {|vs|
+ c.yscrollcommand(proc{|first,last| vs.set first,last})
+ if $tk_version =~ /^4\.[01]/
+ pack('side'=>'right', 'fill'=>'y')
+ else
+ grid('in'=>$cscroll_grid, 'padx'=>1, 'pady'=>1, 'row'=>0, 'column'=>1,
+ 'rowspan'=>1, 'columnspan'=>1, 'sticky'=>'news')
+ end
+ }
+
+ TkScrollbar.new(base_frame, 'orient'=>'horiz',
+ 'command'=>proc{|*args| c.xview(*args)}) {|hs|
+ c.xscrollcommand(proc{|first,last| hs.set first,last})
+ if $tk_version =~ /^4\.[01]/
+ pack('side'=>'bottom', 'fill'=>'x')
+ else
+ grid('in'=>$cscroll_grid, 'padx'=>1, 'pady'=>1, 'row'=>1, 'column'=>0,
+ 'rowspan'=>1, 'columnspan'=>1, 'sticky'=>'news')
+ end
+ }
+}
+
+bg = $cscroll_canvas.configinfo('bg')[4]
+(0..19).each{|i|
+ x = -10+3*i
+ y = -10
+ (0..9).each{|j|
+ TkcRectangle.new($cscroll_canvas, "#{x}c", "#{y}c", "#{x+2}c", "#{y+2}c",
+ 'outline'=>'black', 'fill'=>bg, 'tags'=>'rect')
+ TkcText.new($cscroll_canvas, "#{x+1}c", "#{y+1}c",
+ 'text'=>"#{i},#{j}", 'anchor'=>'center', 'tags'=>'text')
+ y += 3
+ }
+}
+
+$cscroll_canvas.itembind('all', 'Any-Enter', proc{scrollEnter $cscroll_canvas})
+$cscroll_canvas.itembind('all', 'Any-Leave', proc{scrollLeave $cscroll_canvas})
+$cscroll_canvas.itembind('all', '1', proc{scrollButton $cscroll_canvas})
+$cscroll_canvas.itembind('all', 'Any-Enter', proc{scrollEnter $cscroll_canvas})
+$cscroll_canvas.bind('2', proc{|x,y| $cscroll_canvas.scan_mark(x,y)}, '%x %y')
+$cscroll_canvas.bind('B2-Motion',
+ proc{|x,y| $cscroll_canvas.scan_dragto(x,y)}, '%x %y')
+
+def scrollEnter(c)
+ id = c.find_withtag('current')[0].id
+ id -= 1 if c.gettags('current').include?('text')
+ $oldFill = c.itemconfiginfo(id, 'fill')[4]
+ if TkWinfo.depth(c) > 1
+ c.itemconfigure(id, 'fill'=>'SeaGreen1')
+ else
+ c.itemconfigure(id, 'fill'=>'black')
+ c.itemconfigure(id+1, 'fill'=>'white')
+ end
+end
+
+def scrollLeave(c)
+ id = c.find_withtag('current')[0].id
+ id -= 1 if c.gettags('current').include?('text')
+ c.itemconfigure(id, 'fill'=>$oldFill)
+ c.itemconfigure(id+1, 'fill'=>'black')
+end
+
+def scrollButton(c)
+ id = c.find_withtag('current')[0].id
+ id += 1 unless c.gettags('current').include?('text')
+ print "You buttoned at #{c.itemconfiginfo(id,'text')[4]}\n"
+end
+
diff --git a/jni/ruby/ext/tk/sample/demos-jp/ctext.rb b/jni/ruby/ext/tk/sample/demos-jp/ctext.rb
new file mode 100644
index 0000000..bb354c4
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/demos-jp/ctext.rb
@@ -0,0 +1,204 @@
+# -*- coding: utf-8 -*-
+#
+# Canvas Text widget demo (called by 'widget')
+#
+
+# toplevel widget ãŒå­˜åœ¨ã™ã‚Œã°å‰Šé™¤ã™ã‚‹
+if defined?($ctext_demo) && $ctext_demo
+ $ctext_demo.destroy
+ $ctext_demo = nil
+end
+
+# demo 用㮠toplevel widget を生æˆ
+$ctext_demo = TkToplevel.new {|w|
+ title("Canvas Text Demonstration")
+ iconname("Text")
+ positionWindow(w)
+}
+
+base_frame = TkFrame.new($ctext_demo).pack(:fill=>:both, :expand=>true)
+
+# label 生æˆ
+TkLabel.new(base_frame, 'font'=>$font, 'wraplength'=>'5i', 'justify'=>'left',
+ 'text'=>"ã“ã®ã‚¦ã‚£ãƒ³ãƒ‰ã‚¦ã«ã¯ã‚­ãƒ£ãƒ³ãƒã‚¹widgetã®ãƒ†ã‚­ã‚¹ãƒˆæ©Ÿèƒ½ã‚’デモã™ã‚‹ãŸã‚ã®ãƒ†ã‚­ã‚¹ãƒˆæ–‡å­—列ãŒè¡¨ç¤ºã•ã‚Œã¦ã„ã¾ã™ã€‚マウスを四角ã®ä¸­ã«æŒã£ã¦ã„ãã€ã‚¯ãƒªãƒƒã‚¯ã™ã‚‹ã¨ä½ç½®ãŽã‚用ã®ç‚¹ã‹ã‚‰ã®ç›¸å¯¾ä½ç½®ã‚’変ãˆãŸã‚Šã€è¡Œæƒãˆã‚’変ãˆãŸã‚Šã™ã‚‹ã“ã¨ãŒã§ãã¾ã™ã€‚ã¾ãŸä»¥ä¸‹ã®ã‚ˆã†ãªç·¨é›†ã®ãŸã‚ã®ç°¡å˜ãªãƒã‚¤ãƒ³ãƒ‡ã‚£ãƒ³ã‚°ã‚’サãƒãƒ¼ãƒˆã—ã¦ã„ã¾ã™ã€‚
+
+ 1. マウスをæŒã£ã¦ã„ãã€ã‚¯ãƒªãƒƒã‚¯ã—ã€å…¥åŠ›ã§ãã¾ã™ã€‚
+ 2. ボタン1ã§é¸æŠžã§ãã¾ã™ã€‚
+ 3. マウスã®ä½ç½®ã«ãƒœã‚¿ãƒ³2ã§é¸æŠžã—ãŸãƒ†ã‚­ã‚¹ãƒˆã‚’コピーã§ãã¾ã™ã€‚
+ 4.ãƒãƒƒã‚¯ã‚¹ãƒšãƒ¼ã‚¹ã‚’コントロール-Hã§æŒ¿å…¥ã‚«ãƒ¼ã‚½ãƒ«ã®ç›´å‰ã®æ–‡å­—を削除ã—ã¾ã™ã€‚
+ 5. Deleteキーã¯æŒ¿å…¥ã‚«ãƒ¼ã‚½ãƒ«ã®ç›´å¾Œã®æ–‡å­—を削除ã—ã¾ã™ã€‚"){
+ pack('side'=>'top')
+}
+
+# frame 生æˆ
+$ctext_buttons = TkFrame.new(base_frame) {|frame|
+ TkButton.new(frame) {
+ #text '了解'
+ text 'é–‰ã˜ã‚‹'
+ command proc{
+ tmppath = $ctext_demo
+ $ctext_demo = nil
+ tmppath.destroy
+ }
+ }.pack('side'=>'left', 'expand'=>'yes')
+
+ TkButton.new(frame) {
+ text 'コードå‚ç…§'
+ command proc{showCode 'ctext'}
+ }.pack('side'=>'left', 'expand'=>'yes')
+}
+$ctext_buttons.pack('side'=>'bottom', 'fill'=>'x', 'pady'=>'2m')
+
+# canvas 生æˆ
+$ctext_canvas = TkCanvas.new(base_frame, 'relief'=>'flat',
+ 'borderwidth'=>0, 'width'=>500, 'height'=>350)
+$ctext_canvas.pack('side'=>'top', 'expand'=>'yes', 'fill'=>'both')
+
+# font 設定
+if $tk_version =~ /^4.*/
+ textFont = '-*-Helvetica-Medium-R-Normal--*-240-*-*-*-*-*-*'
+else
+ textFont = 'Helvetica 24'
+end
+
+# canvas 設定
+TkcRectangle.new($ctext_canvas, 245, 195, 255, 205,
+ 'outline'=>'black', 'fill'=>'red')
+
+ctag_text_param = {
+ 'text'=>"ã“ã‚Œã¯ã‚­ãƒ£ãƒ³ãƒã‚¹widgetã®ãƒ†ã‚­ã‚¹ãƒˆæ©Ÿèƒ½ã‚’デモã™ã‚‹ãŸã‚ã®æ–‡å­—列ã§ã™ã€‚\n上ã§è¿°ã¹ãŸã‚ˆã†ãªç·¨é›†ã‚’å¯èƒ½ã¨ã™ã‚‹ãŸã‚ã®ãƒã‚¤ãƒ³ãƒ‡ã‚£ãƒ³ã‚°ã‚’æ–½ã—ã¦ã„ã¾ã™ã€‚",
+ 'width'=>440, 'anchor'=>'n', 'justify'=>'left'
+}
+if $tk_version =~ /^4.*/
+ ctag_text_param['font'] = '-*-Helvetica-Medium-R-Normal--*-240-*-*-*-*-*-*'
+ ctag_text_param['kanjifont'] = '-*-r-*--24-*-jisx0208.1983-0'
+else
+ ctag_text_param['font'] = 'Helvetica 24'
+end
+$ctag_text = TkcTag.new($ctext_canvas)
+$ctag_text.withtag(TkcText.new($ctext_canvas, 250, 200, ctag_text_param))
+
+$ctag_text.bind('1', proc{|x,y| textB1Press $ctext_canvas,x,y}, "%x %y")
+$ctag_text.bind('B1-Motion', proc{|x,y| textB1Move $ctext_canvas,x,y}, "%x %y")
+$ctag_text.bind('Shift-1',
+ proc{|x,y| $ctext_canvas.seleect_adjust 'current', "@#{x},#{y}"},
+ "%x %y")
+$ctag_text.bind('Shift-B1-Motion',
+ proc{|x,y| textB1Move $ctext_canvas,x,y}, "%x %y")
+$ctag_text.bind('KeyPress', proc{|a| textInsert $ctext_canvas,a}, "%A")
+$ctag_text.bind('Return', proc{textInsert $ctext_canvas,"\n"})
+$ctag_text.bind('Control-h', proc{textBs $ctext_canvas})
+$ctag_text.bind('BackSpace', proc{textBs $ctext_canvas})
+$ctag_text.bind('Delete', proc{textDel $ctext_canvas})
+$ctag_text.bind('2', proc{|x,y| textPaste $ctext_canvas, "@#{x},#{y}"},
+ "%x %y")
+
+# Next, create some items that allow the text's anchor position
+# to be edited.
+
+def mkTextConfig(w,x,y,option,value,color)
+ item = TkcRectangle.new(w, x, y, x+30, y+30,
+ 'outline'=>'black', 'fill'=>color, 'width'=>1)
+ item.bind('1', proc{$ctag_text.configure option, value})
+ w.addtag_withtag('config', item)
+end
+
+x = 50
+y = 50
+color = 'LightSkyBlue1'
+mkTextConfig $ctext_canvas, x, y, 'anchor', 'se', color
+mkTextConfig $ctext_canvas, x+30, y, 'anchor', 's', color
+mkTextConfig $ctext_canvas, x+60, y, 'anchor', 'sw', color
+mkTextConfig $ctext_canvas, x, y+30, 'anchor', 'e', color
+mkTextConfig $ctext_canvas, x+30, y+30, 'anchor', 'center', color
+mkTextConfig $ctext_canvas, x+60, y+30, 'anchor', 'w', color
+mkTextConfig $ctext_canvas, x, y+60, 'anchor', 'ne', color
+mkTextConfig $ctext_canvas, x+30, y+60, 'anchor', 'n', color
+mkTextConfig $ctext_canvas, x+60, y+60, 'anchor', 'nw', color
+item = TkcRectangle.new($ctext_canvas, x+40, y+40, x+50, y+50,
+ 'outline'=>'black', 'fill'=>'red')
+item.bind('1', proc{$ctag_text.configure 'anchor', 'center'})
+if $tk_version =~ /^4.*/
+ TkcText.new($ctext_canvas, x+45, y-5, 'text'=>'Text Position',
+ 'font'=>'-*-times-medium-r-normal--*-240-*-*-*-*-*-*',
+ 'anchor'=>'s', 'fill'=>'brown')
+else
+ TkcText.new($ctext_canvas, x+45, y-5, 'text'=>'Text Position',
+ 'font'=>'Times 24', 'anchor'=>'s', 'fill'=>'brown')
+end
+
+# Lastly, create some items that allow the text's justification to be
+# changed.
+
+x = 350
+y = 50
+color = 'SeaGreen2'
+mkTextConfig $ctext_canvas, x, y, 'justify', 'left', color
+mkTextConfig $ctext_canvas, x+30, y, 'justify', 'center', color
+mkTextConfig $ctext_canvas, x+60, y, 'justify', 'right', color
+if $tk_version =~ /^4.*/
+ TkcText.new($ctext_canvas, x+45, y-5, 'text'=>'Justification',
+ 'font'=>'-*-times-medium-r-normal--*-240-*-*-*-*-*-*',
+ 'anchor'=>'s', 'fill'=>'brown')
+else
+ TkcText.new($ctext_canvas, x+45, y-5, 'text'=>'Justification',
+ 'font'=>'Times 24', 'anchor'=>'s', 'fill'=>'brown')
+end
+
+$ctext_canvas.itembind('config', 'Enter', proc{textEnter $ctext_canvas})
+$ctext_canvas.itembind('config', 'Leave',
+ proc{$ctext_canvas\
+ .itemconfigure('current',
+ 'fill'=>$textConfigFill)})
+
+$textConfigFill = ''
+
+def textEnter(w)
+ $textConfigFill = (w.itemconfiginfo 'current', 'fill')[4]
+ w.itemconfigure 'current', 'fill', 'black'
+end
+
+def textInsert(w, string)
+ return if string == ""
+ begin
+ $ctag_text.dchars 'sel.first', 'sel.last'
+ rescue
+ end
+ $ctag_text.insert 'insert', string
+end
+
+def textPaste(w, pos)
+ begin
+ $ctag_text.insert pos, TkSelection.get
+ rescue
+ end
+end
+
+def textB1Press(w,x,y)
+ w.icursor 'current', "@#{x},#{y}"
+ w.itemfocus 'current'
+ w.focus
+ w.select_from 'current', "@#{x},#{y}"
+end
+
+def textB1Move(w,x,y)
+ w.select_to 'current', "@#{x},#{y}"
+end
+
+def textBs(w)
+ begin
+ $ctag_text.dchars 'sel.first', 'sel.last'
+ rescue
+ char = $ctag_text.index('insert').to_i - 1
+ $ctag_text.dchars(char) if char >= 0
+ end
+end
+
+def textDel(w)
+ begin
+ $ctag_text.dchars 'sel.first', 'sel.last'
+ rescue
+ $ctag_text.dchars 'insert'
+ end
+end
+
diff --git a/jni/ruby/ext/tk/sample/demos-jp/dialog1.rb b/jni/ruby/ext/tk/sample/demos-jp/dialog1.rb
new file mode 100644
index 0000000..e50c907
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/demos-jp/dialog1.rb
@@ -0,0 +1,39 @@
+# -*- coding: utf-8 -*-
+#
+# a dialog box with a local grab (called by 'widget')
+#
+class TkDialog_Demo1 < TkDialog
+ ###############
+ private
+ ###############
+ def title
+ "Dialog with local grab"
+ end
+
+ def message
+ 'モーダルダイアログボックスã§ã™ã€‚Tk ã® "grab" コマンドを使用ã—ã¦ãƒ€ã‚¤ã‚¢ãƒ­ã‚°ãƒœãƒƒã‚¯ã‚¹ã§ã€Œãƒ­ãƒ¼ã‚«ãƒ«ã‚°ãƒ©ãƒ–ã€ã—ã¦ã„ã¾ã™ã€‚下ã®ã„ãšã‚Œã‹ã®ãƒœã‚¿ãƒ³ã‚’実行ã™ã‚‹ã“ã¨ã«ã‚ˆã£ã¦ã€ã“ã®ãƒ€ã‚¤ã‚¢ãƒ­ã‚°ã«ç­”ãˆã‚‹ã¾ã§ã€ã“ã®ã‚°ãƒ©ãƒ–ã«ã‚ˆã£ã¦ã‚¢ãƒ—リケーションã®ä»–ã®ã‚¦ã‚£ãƒ³ãƒ‰ã‚¦ã§ã¯ã€ãƒã‚¤ãƒ³ã‚¿é–¢ä¿‚ã®ã‚¤ãƒ™ãƒ³ãƒˆã‚’å—ã‘å–ã‚‹ã“ã¨ãŒã§ããªããªã£ã¦ã„ã¾ã™ã€‚'
+ end
+
+ def bitmap
+ 'info'
+ end
+
+ def default_button
+ 0
+ end
+
+ def buttons
+# "了解 キャンセル コードå‚ç…§"
+ ["了解", "キャンセル", "コードå‚ç…§"]
+ end
+end
+
+ret = TkDialog_Demo1.new('message_config'=>{'wraplength'=>'4i'}).value
+case ret
+when 0
+ print "ã‚ãªãŸã¯ã€Œäº†è§£ã€ã‚’押ã—ã¾ã—ãŸã­ã€‚\n"
+when 1
+ print "ã‚ãªãŸã¯ã€Œã‚­ãƒ£ãƒ³ã‚»ãƒ«ã€ã‚’押ã—ã¾ã—ãŸã­ã€‚\n"
+when 2
+ showCode 'dialog1'
+end
diff --git a/jni/ruby/ext/tk/sample/demos-jp/dialog2.rb b/jni/ruby/ext/tk/sample/demos-jp/dialog2.rb
new file mode 100644
index 0000000..3e7d961
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/demos-jp/dialog2.rb
@@ -0,0 +1,43 @@
+# -*- coding: utf-8 -*-
+#
+# a dialog box with a global grab (called by 'widget')
+#
+class TkDialog_Demo2 < TkDialog
+ ###############
+ private
+ ###############
+ def title
+ "Dialog with global grab"
+ end
+
+ def message
+ 'ã“ã®ãƒ€ã‚¤ã‚¢ãƒ­ã‚°ãƒœãƒƒã‚¯ã‚¹ã¯ã‚°ãƒ­ãƒ¼ãƒãƒ«ã‚°ãƒ©ãƒ–を使用ã—ã¦ã„ã¾ã™ã€‚下ã®ãƒœã‚¿ãƒ³ã‚’実行ã™ã‚‹ã¾ã§ã€ãƒ‡ã‚£ã‚¹ãƒ—レイ上ã®ã„ã‹ãªã‚‹ã‚‚ã®ã¨ã‚‚対話ã§ãã¾ã›ã‚“。グローãƒãƒ«ã‚°ãƒ©ãƒ–を使用ã™ã‚‹ã“ã¨ã¯ã€ã¾ãšè‰¯ã„考ãˆã§ã¯ã‚ã‚Šã¾ã›ã‚“。ã©ã†ã—ã¦ã‚‚å¿…è¦ã«ãªã‚‹ã¾ã§ä½¿ãŠã†ã¨æ€ã‚ãªã„ã§ä¸‹ã•ã„。'
+ end
+
+ def bitmap
+ 'info'
+ end
+
+ def default_button
+ 0
+ end
+
+ def buttons
+# "了解 キャンセル コードå‚ç…§"
+ ["了解", "キャンセル", "コードå‚ç…§"]
+ end
+end
+
+ret = TkDialog_Demo2.new('message_config'=>{'wraplength'=>'4i'},
+ 'prev_command'=>proc{|dialog|
+ Tk.after 100, proc{dialog.grab('global')}
+ }).value
+case ret
+when 0
+ print "ã‚ãªãŸã¯ã€Œäº†è§£ã€ã‚’押ã—ã¾ã—ãŸã­ã€‚\n"
+when 1
+ print "ã‚ãªãŸã¯ã€Œã‚­ãƒ£ãƒ³ã‚»ãƒ«ã€ã‚’押ã—ã¾ã—ãŸã­ã€‚\n"
+when 2
+ showCode 'dialog2'
+end
+
diff --git a/jni/ruby/ext/tk/sample/demos-jp/doc.org/README b/jni/ruby/ext/tk/sample/demos-jp/doc.org/README
new file mode 100644
index 0000000..90677d3
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/demos-jp/doc.org/README
@@ -0,0 +1,7 @@
+This directory contains a collection of demonstration programs that
+are translated into Japanese. You need to use a Japanized "wish" to
+see these Japanese-translated demonstration programs. You also need
+to put this directory ("demos.jp") at the next to "demos" since some
+of the programs refer to the image files at "demos".
+
+Please refer to the README file at "demos" for more detail.
diff --git a/jni/ruby/ext/tk/sample/demos-jp/doc.org/README.JP b/jni/ruby/ext/tk/sample/demos-jp/doc.org/README.JP
new file mode 100644
index 0000000..42b4929
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/demos-jp/doc.org/README.JP
@@ -0,0 +1,14 @@
+This directory contains "widget" demo for the Japanized Tcl7.6/Tk4.2.
+Most of the messages in the original are translated to Japanese.
+But other tools in this directory are not translated.
+
+Following 2 kanji fonts are defined at the beginning of the file "widget."
+
+ -*--24-*-jisx0208.1983-0
+ -*--16-*-jisx0208.1983-0
+
+These fonts are all part of the core distribution of X11R5, so
+if you are running X11R5, you don't have to modify the file.
+
+But if you don't have these fonts, replace them with appropriate ones.
+"-*--14-*-jisx0208.1983-0" will be a good choice.
diff --git a/jni/ruby/ext/tk/sample/demos-jp/doc.org/README.tk80 b/jni/ruby/ext/tk/sample/demos-jp/doc.org/README.tk80
new file mode 100644
index 0000000..c71f977
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/demos-jp/doc.org/README.tk80
@@ -0,0 +1,46 @@
+This directory contains a collection of programs to demonstrate
+the features of the Tk toolkit. The programs are all scripts for
+"wish", a windowing shell. If wish has been installed in /usr/local
+then you can invoke any of the programs in this directory just
+by typing its file name to your command shell. Otherwise invoke
+wish with the file as its first argument, e.g., "wish hello".
+The rest of this file contains a brief description of each program.
+Files with names ending in ".tcl" are procedure packages used by one
+or more of the demo programs; they can't be used as programs by
+themselves so they aren't described below.
+
+hello - Creates a single button; if you click on it, a message
+ is typed and the application terminates.
+
+widget - Contains a collection of demonstrations of the widgets
+ currently available in the Tk library. Most of the .tcl
+ files are scripts for individual demos available through
+ the "widget" program.
+
+ixset - A simple Tk-based wrapper for the "xset" program, which
+ allows you to interactively query and set various X options
+ such as mouse acceleration and bell volume. Thanks to
+ Pierre David for contributing this example.
+
+rolodex - A mock-up of a simple rolodex application. It has much of
+ the user interface for such an application but no back-end
+ database. This program was written in response to Tom
+ LaStrange's toolkit benchmark challenge.
+
+tcolor - A color editor. Allows you to edit colors in several
+ different ways, and will also perform automatic updates
+ using "send".
+
+rmt - Allows you to "hook-up" remotely to any Tk application
+ on the display. Select an application with the menu,
+ then just type commands: they'll go to that application.
+
+timer - Displays a seconds timer with start and stop buttons.
+ Control-c and control-q cause it to exit.
+
+browse - A simple directory browser. Invoke it with and argument
+ giving the name of the directory you'd like to browse.
+ Double-click on files or subdirectories to browse them.
+ Control-c and control-q cause the program to exit.
+
+sccs id = SCCS: @(#) README 1.3 96/02/16 10:49:14
diff --git a/jni/ruby/ext/tk/sample/demos-jp/doc.org/license.terms b/jni/ruby/ext/tk/sample/demos-jp/doc.org/license.terms
new file mode 100644
index 0000000..c0a44d3
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/demos-jp/doc.org/license.terms
@@ -0,0 +1,39 @@
+This software is copyrighted by the Regents of the University of
+California, Sun Microsystems, Inc., and other parties. The following
+terms apply to all files associated with the software unless explicitly
+disclaimed in individual files.
+
+The authors hereby grant permission to use, copy, modify, distribute,
+and license this software and its documentation for any purpose, provided
+that existing copyright notices are retained in all copies and that this
+notice is included verbatim in any distributions. No written agreement,
+license, or royalty fee is required for any of the authorized uses.
+Modifications to this software may be copyrighted by their authors
+and need not follow the licensing terms described here, provided that
+the new terms are clearly indicated on the first page of each file where
+they apply.
+
+IN NO EVENT SHALL THE AUTHORS OR DISTRIBUTORS BE LIABLE TO ANY PARTY
+FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
+ARISING OUT OF THE USE OF THIS SOFTWARE, ITS DOCUMENTATION, OR ANY
+DERIVATIVES THEREOF, EVEN IF THE AUTHORS HAVE BEEN ADVISED OF THE
+POSSIBILITY OF SUCH DAMAGE.
+
+THE AUTHORS AND DISTRIBUTORS SPECIFICALLY DISCLAIM ANY WARRANTIES,
+INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE, AND NON-INFRINGEMENT. THIS SOFTWARE
+IS PROVIDED ON AN "AS IS" BASIS, AND THE AUTHORS AND DISTRIBUTORS HAVE
+NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR
+MODIFICATIONS.
+
+GOVERNMENT USE: If you are acquiring this software on behalf of the
+U.S. government, the Government shall have only "Restricted Rights"
+in the software and related documentation as defined in the Federal
+Acquisition Regulations (FARs) in Clause 52.227.19 (c) (2). If you
+are acquiring the software on behalf of the Department of Defense, the
+software shall be classified as "Commercial Computer Software" and the
+Government shall have only "Restricted Rights" as defined in Clause
+252.227-7013 (c) (1) of DFARs. Notwithstanding the foregoing, the
+authors grant the U.S. Government and others acting in its behalf
+permission to use and distribute the software in accordance with the
+terms specified in this license.
diff --git a/jni/ruby/ext/tk/sample/demos-jp/doc.org/license.terms.tk80 b/jni/ruby/ext/tk/sample/demos-jp/doc.org/license.terms.tk80
new file mode 100644
index 0000000..c0a44d3
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/demos-jp/doc.org/license.terms.tk80
@@ -0,0 +1,39 @@
+This software is copyrighted by the Regents of the University of
+California, Sun Microsystems, Inc., and other parties. The following
+terms apply to all files associated with the software unless explicitly
+disclaimed in individual files.
+
+The authors hereby grant permission to use, copy, modify, distribute,
+and license this software and its documentation for any purpose, provided
+that existing copyright notices are retained in all copies and that this
+notice is included verbatim in any distributions. No written agreement,
+license, or royalty fee is required for any of the authorized uses.
+Modifications to this software may be copyrighted by their authors
+and need not follow the licensing terms described here, provided that
+the new terms are clearly indicated on the first page of each file where
+they apply.
+
+IN NO EVENT SHALL THE AUTHORS OR DISTRIBUTORS BE LIABLE TO ANY PARTY
+FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
+ARISING OUT OF THE USE OF THIS SOFTWARE, ITS DOCUMENTATION, OR ANY
+DERIVATIVES THEREOF, EVEN IF THE AUTHORS HAVE BEEN ADVISED OF THE
+POSSIBILITY OF SUCH DAMAGE.
+
+THE AUTHORS AND DISTRIBUTORS SPECIFICALLY DISCLAIM ANY WARRANTIES,
+INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE, AND NON-INFRINGEMENT. THIS SOFTWARE
+IS PROVIDED ON AN "AS IS" BASIS, AND THE AUTHORS AND DISTRIBUTORS HAVE
+NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR
+MODIFICATIONS.
+
+GOVERNMENT USE: If you are acquiring this software on behalf of the
+U.S. government, the Government shall have only "Restricted Rights"
+in the software and related documentation as defined in the Federal
+Acquisition Regulations (FARs) in Clause 52.227.19 (c) (2). If you
+are acquiring the software on behalf of the Department of Defense, the
+software shall be classified as "Commercial Computer Software" and the
+Government shall have only "Restricted Rights" as defined in Clause
+252.227-7013 (c) (1) of DFARs. Notwithstanding the foregoing, the
+authors grant the U.S. Government and others acting in its behalf
+permission to use and distribute the software in accordance with the
+terms specified in this license.
diff --git a/jni/ruby/ext/tk/sample/demos-jp/entry1.rb b/jni/ruby/ext/tk/sample/demos-jp/entry1.rb
new file mode 100644
index 0000000..9be677d
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/demos-jp/entry1.rb
@@ -0,0 +1,60 @@
+# -*- coding: utf-8 -*-
+#
+# entry (no scrollbars) widget demo (called by 'widget')
+#
+
+# toplevel widget ãŒå­˜åœ¨ã™ã‚Œã°å‰Šé™¤ã™ã‚‹
+if defined?($entry1_demo) && $entry1_demo
+ $entry1_demo.destroy
+ $entry1_demo = nil
+end
+
+# demo 用㮠toplevel widget を生æˆ
+$entry1_demo = TkToplevel.new {|w|
+ title("Entry Demonstration (no scrollbars)")
+ iconname("entry1")
+ positionWindow(w)
+}
+
+base_frame = TkFrame.new($entry1_demo).pack(:fill=>:both, :expand=>true)
+
+# label 生æˆ
+msg = TkLabel.new(base_frame) {
+ font $font
+ wraplength '5i'
+ justify 'left'
+ text "3種類ã®ç•°ãªã‚‹ã‚¨ãƒ³ãƒˆãƒªãŒè¡¨ç¤ºã•ã‚Œã¦ã„ã¾ã™ã€‚文字を入力ã™ã‚‹ã«ã¯ãƒã‚¤ãƒ³ã‚¿ã‚’æŒã£ã¦è¡Œãã€ã‚¯ãƒªãƒƒã‚¯ã—ã¦ã‹ã‚‰ã‚¿ã‚¤ãƒ—ã—ã¦ãã ã•ã„。標準的ãªMotifã®ç·¨é›†æ©Ÿèƒ½ãŒã€Emacsã®ã‚­ãƒ¼ãƒã‚¤ãƒ³ãƒ‰ã¨ã¨ã‚‚ã«ã€ã‚µãƒãƒ¼ãƒˆã•ã‚Œã¦ã„ã¾ã™ã€‚例ãˆã°ã€ãƒãƒƒã‚¯ã‚¹ãƒšãƒ¼ã‚¹ã¨ã‚³ãƒ³ãƒˆãƒ­ãƒ¼ãƒ«-Hã¯ã‚«ãƒ¼ã‚½ãƒ«ã®å·¦ã®æ–‡å­—を削除ã—ã€ãƒ‡ãƒªãƒ¼ãƒˆã‚­ãƒ¼ã¨ã‚³ãƒ³ãƒˆãƒ­ãƒ¼ãƒ«-Dã¯ã‚«ãƒ¼ã‚½ãƒ«ã®å³å´ã®æ–‡å­—を削除ã—ã¾ã™ã€‚é•·éŽãŽã¦ã‚¦ã‚£ãƒ³ãƒ‰ã‚¦ã«å…¥ã‚Šåˆ‡ã‚‰ãªã„ã‚‚ã®ã¯ã€ãƒžã‚¦ã‚¹ã®ãƒœã‚¿ãƒ³2を押ã—ãŸã¾ã¾ãƒ‰ãƒ©ãƒƒã‚°ã™ã‚‹ã“ã¨ã§ã‚¹ã‚¯ãƒ­ãƒ¼ãƒ«ã•ã›ã‚‹ã“ã¨ãŒã§ãã¾ã™ã€‚日本語を入力ã™ã‚‹ã®ã¯ã‚³ãƒ³ãƒˆãƒ­ãƒ¼ãƒ«-ãƒãƒƒã‚¯ã‚¹ãƒ©ãƒƒã‚·ãƒ¥ã§ã™ã€‚kinput2ãŒå‹•ã„ã¦ã„ã‚Œã°å…¥åŠ›ã™ã‚‹ã“ã¨ãŒã§ãã¾ã™ã€‚"
+}
+msg.pack('side'=>'top')
+
+# frame 生æˆ
+TkFrame.new(base_frame) {|frame|
+ TkButton.new(frame) {
+ #text '了解'
+ text 'é–‰ã˜ã‚‹'
+ command proc{
+ tmppath = $entry1_demo
+ $entry1_demo = nil
+ tmppath.destroy
+ }
+ }.pack('side'=>'left', 'expand'=>'yes')
+
+ TkButton.new(frame) {
+ text 'コードå‚ç…§'
+ command proc{showCode 'entry1'}
+ }.pack('side'=>'left', 'expand'=>'yes')
+}.pack('side'=>'bottom', 'fill'=>'x', 'pady'=>'2m')
+
+# entry 生æˆ
+e1 = TkEntry.new(base_frame, 'relief'=>'sunken')
+e2 = TkEntry.new(base_frame, 'relief'=>'sunken')
+e3 = TkEntry.new(base_frame, 'relief'=>'sunken')
+[e1,e2,e3].each{|w| w.pack('side'=>'top', 'padx'=>10, 'pady'=>5, 'fill'=>'x')}
+
+# åˆæœŸå€¤æŒ¿å…¥
+e1.insert(0, 'åˆæœŸå€¤')
+e2.insert('end', "ã“ã®ã‚¨ãƒ³ãƒˆãƒªã«ã¯é•·ã„文字列ãŒå…¥ã£ã¦ã„ã¦ã€")
+e2.insert('end', "é•·ã™ãŽã¦ã‚¦ã‚£ãƒ³ãƒ‰ã‚¦ã«ã¯å…¥ã‚Šåˆ‡ã‚‰ãªã„ã®ã§ã€")
+e2.insert('end', "実際ã®æ‰€çµ‚ã‚Šã¾ã§è¦‹ã‚‹ã«ã¯ã‚¹ã‚¯ãƒ­ãƒ¼ãƒ«ã•ã›ãªã‘ã‚Œã°")
+e2.insert('end', "ãªã‚‰ãªã„ã§ã—ょã†ã€‚")
+
diff --git a/jni/ruby/ext/tk/sample/demos-jp/entry2.rb b/jni/ruby/ext/tk/sample/demos-jp/entry2.rb
new file mode 100644
index 0000000..5476d24
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/demos-jp/entry2.rb
@@ -0,0 +1,91 @@
+# -*- coding: utf-8 -*-
+#
+# entry (with scrollbars) widget demo (called by 'widget')
+#
+
+# toplevel widget ãŒå­˜åœ¨ã™ã‚Œã°å‰Šé™¤ã™ã‚‹
+if defined?($entry2_demo) && $entry2_demo
+ $entry2_demo.destroy
+ $entry2_demo = nil
+end
+
+# demo 用㮠toplevel widget を生æˆ
+$entry2_demo = TkToplevel.new {|w|
+ title("Entry Demonstration (with scrollbars)")
+ iconname("entry2")
+ positionWindow(w)
+}
+
+base_frame = TkFrame.new($entry2_demo).pack(:fill=>:both, :expand=>true)
+
+# label 生æˆ
+msg = TkLabel.new(base_frame) {
+ font $font
+ wraplength '5i'
+ justify 'left'
+ text "3種類ã®ç•°ãªã‚‹ã‚¨ãƒ³ãƒˆãƒªãŒå„々スクロールãƒãƒ¼ä»˜ã§è¡¨ç¤ºã•ã‚Œã¦ã„ã¾ã™ã€‚文字を入力ã™ã‚‹ã«ã¯ãƒã‚¤ãƒ³ã‚¿ã‚’æŒã£ã¦è¡Œãã€ã‚¯ãƒªãƒƒã‚¯ã—ã¦ã‹ã‚‰ã‚¿ã‚¤ãƒ—ã—ã¦ãã ã•ã„。標準的ãªMotifã®ç·¨é›†æ©Ÿèƒ½ãŒã€Emacsã®ã‚­ãƒ¼ãƒã‚¤ãƒ³ãƒ‰ã¨ã¨ã‚‚ã«ã€ã‚µãƒãƒ¼ãƒˆã•ã‚Œã¦ã„ã¾ã™ã€‚例ãˆã°ã€ãƒãƒƒã‚¯ã‚¹ãƒšãƒ¼ã‚¹ã¨ã‚³ãƒ³ãƒˆãƒ­ãƒ¼ãƒ«-Hã¯ã‚«ãƒ¼ã‚½ãƒ«ã®å·¦ã®æ–‡å­—を削除ã—ã€ãƒ‡ãƒªãƒ¼ãƒˆã‚­ãƒ¼ã¨ã‚³ãƒ³ãƒˆãƒ­ãƒ¼ãƒ«-Dã¯ã‚«ãƒ¼ã‚½ãƒ«ã®å³å´ã®æ–‡å­—を削除ã—ã¾ã™ã€‚é•·éŽãŽã¦ã‚¦ã‚£ãƒ³ãƒ‰ã‚¦ã«å…¥ã‚Šåˆ‡ã‚‰ãªã„ã‚‚ã®ã¯ã€ãƒžã‚¦ã‚¹ã®ãƒœã‚¿ãƒ³2を押ã—ãŸã¾ã¾ãƒ‰ãƒ©ãƒƒã‚°ã™ã‚‹ã“ã¨ã§ã‚¹ã‚¯ãƒ­ãƒ¼ãƒ«ã•ã›ã‚‹ã“ã¨ãŒã§ãã¾ã™ã€‚日本語を入力ã™ã‚‹ã®ã¯ã‚³ãƒ³ãƒˆãƒ­ãƒ¼ãƒ«-ãƒãƒƒã‚¯ã‚¹ãƒ©ãƒƒã‚·ãƒ¥ã§ã™ã€‚kinput2ãŒå‹•ã„ã¦ã„ã‚Œã°å…¥åŠ›ã™ã‚‹ã“ã¨ãŒã§ãã¾ã™ã€‚"
+}
+msg.pack('side'=>'top')
+
+# frame 生æˆ
+TkFrame.new(base_frame) {|frame|
+ TkButton.new(frame) {
+ #text '了解'
+ text 'é–‰ã˜ã‚‹'
+ command proc{
+ tmppath = $entry2_demo
+ $entry2_demo = nil
+ tmppath.destroy
+ }
+ }.pack('side'=>'left', 'expand'=>'yes')
+
+ TkButton.new(frame) {
+ text 'コードå‚ç…§'
+ command proc{showCode 'entry2'}
+ }.pack('side'=>'left', 'expand'=>'yes')
+}.pack('side'=>'bottom', 'fill'=>'x', 'pady'=>'2m')
+
+# frame 生æˆ
+TkFrame.new(base_frame, 'borderwidth'=>10) {|w|
+ # entry 1
+ s1 = TkScrollbar.new(w, 'relief'=>'sunken', 'orient'=>'horiz')
+ e1 = TkEntry.new(w, 'relief'=>'sunken') {
+ xscrollcommand proc{|first,last| s1.set first,last}
+ }
+ s1.command(proc{|*args| e1.xview(*args)})
+ e1.pack('side'=>'top', 'fill'=>'x')
+ s1.pack('side'=>'top', 'fill'=>'x')
+
+ # spacer
+ TkFrame.new(w, 'width'=>20, 'height'=>10).pack('side'=>'top', 'fill'=>'x')
+
+ # entry 2
+ s2 = TkScrollbar.new(w, 'relief'=>'sunken', 'orient'=>'horiz')
+ e2 = TkEntry.new(w, 'relief'=>'sunken') {
+ xscrollcommand proc{|first,last| s2.set first,last}
+ }
+ s2.command(proc{|*args| e2.xview(*args)})
+ e2.pack('side'=>'top', 'fill'=>'x')
+ s2.pack('side'=>'top', 'fill'=>'x')
+
+ # spacer
+ TkFrame.new(w, 'width'=>20, 'height'=>10).pack('side'=>'top', 'fill'=>'x')
+
+ # entry 3
+ s3 = TkScrollbar.new(w, 'relief'=>'sunken', 'orient'=>'horiz')
+ e3 = TkEntry.new(w, 'relief'=>'sunken') {
+ xscrollcommand proc{|first,last| s3.set first,last}
+ }
+ s3.command(proc{|*args| e3.xview(*args)})
+ e3.pack('side'=>'top', 'fill'=>'x')
+ s3.pack('side'=>'top', 'fill'=>'x')
+
+ # åˆæœŸå€¤æŒ¿å…¥
+ e1.insert(0, 'åˆæœŸå€¤')
+ e2.insert('end', "ã“ã®ã‚¨ãƒ³ãƒˆãƒªã«ã¯é•·ã„文字列ãŒå…¥ã£ã¦ã„ã¦ã€")
+ e2.insert('end', "é•·ã™ãŽã¦ã‚¦ã‚£ãƒ³ãƒ‰ã‚¦ã«ã¯å…¥ã‚Šåˆ‡ã‚‰ãªã„ã®ã§ã€")
+ e2.insert('end', "実際ã®æ‰€çµ‚ã‚Šã¾ã§è¦‹ã‚‹ã«ã¯ã‚¹ã‚¯ãƒ­ãƒ¼ãƒ«ã•ã›ãªã‘ã‚Œã°")
+ e2.insert('end', "ãªã‚‰ãªã„ã§ã—ょã†ã€‚")
+
+}.pack('side'=>'top', 'fill'=>'x', 'expand'=>'yes')
+
diff --git a/jni/ruby/ext/tk/sample/demos-jp/entry3.rb b/jni/ruby/ext/tk/sample/demos-jp/entry3.rb
new file mode 100644
index 0000000..59c698d
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/demos-jp/entry3.rb
@@ -0,0 +1,225 @@
+# -*- coding: utf-8 -*-
+# entry3.rb --
+#
+# This demonstration script creates several entry widgets whose
+# permitted input is constrained in some way. It also shows off a
+# password entry.
+#
+# based on Tcl/Tk8.4.4 widget demos
+
+if defined?($entry3_demo) && $entry3_demo
+ $entry3_demo.destroy
+ $entry3_demo = nil
+end
+
+$entry3_demo = TkToplevel.new {|w|
+ title("Constrained Entry Demonstration")
+ iconname("entry3")
+ positionWindow(w)
+}
+
+base_frame = TkFrame.new($entry3_demo).pack(:fill=>:both, :expand=>true)
+
+TkLabel.new(base_frame,
+ :font=>$font, :wraplength=>'5i', :justify=>:left,
+ :text=><<EOL).pack(:side=>:top)
+以下ã«ã¯ï¼”種類ã®ã‚¨ãƒ³ãƒˆãƒªãƒœãƒƒã‚¯ã‚¹ãŒè¡¨ç¤ºã•ã‚Œã¦ã„ã¾ã™ï¼Žå„エントリボックスã¯ï¼Œ\
+マウスクリックã§é¸æŠžã—文字を打ã¡è¾¼ã‚€ã“ã¨ãŒå¯èƒ½ã§ã™ãŒï¼Œãã‚Œãžã‚ŒãŒã©ã®ã‚ˆã†ãª\
+入力をå—ã‘付ã‘ã‚‹ã“ã¨ãŒã§ãã‚‹ã‹ã«ã¯åˆ¶ç´„ãŒè¨­ã‘られã¦ã„ã¾ã™ï¼Ž\
+一ã¤ã‚ã®ã‚¨ãƒ³ãƒˆãƒªãƒœãƒƒã‚¯ã‚¹ã¯æ•´æ•°ã¨è¦‹ãªã•ã‚Œã‚‹æ–‡å­—列ã‹å…¥åŠ›æ–‡å­—ãŒãªã„空ã®çŠ¶æ…‹ã‹\
+ã®å ´åˆã ã‘ã‚’å—ã‘付ã‘,å•é¡ŒãŒã‚ã‚‹å ´åˆã¯ã‚¨ãƒ³ãƒˆãƒªãƒœãƒƒã‚¯ã‚¹ãŒç‚¹æ»…ã—ã¾ã™\
+(フォーカスãŒåŽ»ã‚‹æ™‚ã«ãƒã‚§ãƒƒã‚¯ã•ã‚Œã¾ã™ï¼‰ï¼Ž\
+二ã¤ã‚ã®ã‚¨ãƒ³ãƒˆãƒªãƒœãƒƒã‚¯ã‚¹ã¯ï¼Œå…¥åŠ›ã•ã‚ŒãŸæ–‡å­—列ã®é•·ã•ãŒ\
+1ï¼æ–‡å­—未満ã®å ´åˆã ã‘ã‚’å—ã‘付ã‘,制é™ã‚’越ãˆã¦æ›¸ã込もã†ã¨ã—ãŸã¨ãã«ã¯\
+ベルを鳴らã—ã¦çŸ¥ã‚‰ã›ã¾ã™ï¼Ž\
+三ã¤ã‚ã¯ç±³å›½ã®é›»è©±ç•ªå·ã‚’å—ã‘付ã‘るエントリボックスã§ã™ï¼Ž\
+アルファベットã¯ï¼Œé›»è©±æ©Ÿã®ãƒ€ã‚¤ãƒ¤ãƒ«ä¸Šã§å¯¾å¿œã¥ã‘られã¦ã„ã‚‹æ•°å­—ã«å¤‰æ›ã•ã‚Œã¾ã™ï¼Ž\
+ä¸é©åˆ‡ãªæ–‡å­—ãŒå…¥åŠ›ã•ã‚ŒãŸã‚Šæ•°å­—以外ã®æ–‡å­—ã®ä½ç½®ã«æ•°å­—を入力ã—よã†ã¨ã—ãŸã‚Š\
+ã—ãŸå ´åˆã«ã¯è­¦å‘Šã®ãƒ™ãƒ«ãŒé³´ã‚Šã¾ã™ï¼Ž\
+å››ã¤ã‚ã®ã‚¨ãƒ³ãƒˆãƒªãƒœãƒƒã‚¯ã‚¹ã¯ï¼Œï¼˜æ–‡å­—ã¾ã§ã®å…¥åŠ›ã‚’å—ã‘付ã‘ã‚‹\
+パスワードフィールドã§ã™ï¼ˆï¼˜æ–‡å­—以上ã¯ç‰¹ã«è­¦å‘Šã‚’出ã™ã“ã¨ãªã無視ã•ã‚Œã¾ã™ï¼‰ï¼Ž\
+入力ã•ã‚ŒãŸæ–‡å­—ã¯ã‚¢ã‚¹ã‚¿ãƒªã‚¹ã‚¯è¨˜å·ã«ç½®ãæ›ãˆã¦è¡¨ç¤ºã•ã‚Œã¾ã™ï¼Ž
+EOL
+
+TkFrame.new(base_frame){|f|
+ pack(:side=>:bottom, :fill=>:x, :pady=>'2m')
+
+ TkButton.new(f, :text=>'é–‰ã˜ã‚‹', :width=>15, :command=>proc{
+ $entry3_demo.destroy
+ $entry3_demo = nil
+ }).pack(:side=>:left, :expand=>true)
+
+ TkButton.new(f, :text=>'コードå‚ç…§', :width=>15, :command=>proc{
+ showCode 'entry3'
+ }).pack(:side=>:left, :expand=>true)
+}
+
+# focusAndFlash --
+# Error handler for entry widgets that forces the focus onto the
+# widget and makes the widget flash by exchanging the foreground and
+# background colours at intervals of 200ms (i.e. at approximately
+# 2.5Hz).
+#
+# Arguments:
+# widget - entry widget to flash
+# fg - Initial foreground colour
+# bg - Initial background colour
+# count - Counter to control the number of times flashed
+def focusAndFlash(widget, fg, bg, count=5)
+ return if count <= 0
+ if fg && !fg.empty? && bg && !bg.empty?
+ TkTimer.new(200, count,
+ proc{widget.configure(:foreground=>bg, :background=>fg)},
+ proc{widget.configure(:foreground=>fg, :background=>bg)}
+ ).start
+ else
+ # TkTimer.new(150, 3){Tk.bell}.start
+ Tk.bell
+ TkTimer.new(200, count,
+ proc{widget.configure(:foreground=>'white',
+ :background=>'black')},
+ proc{widget.configure(:foreground=>'black',
+ :background=>'white')}
+ ).at_end{begin
+ widget.configure(:foreground=>fg,
+ :background=>bg)
+ rescue
+ # ignore
+ end}.start
+ end
+ widget.focus(true)
+end
+
+l1 = TkLabelFrame.new(base_frame, :text=>"整数エントリ")
+TkEntry.new(l1, :validate=>:focus,
+ :vcmd=>[
+ proc{|s| s == '' || /^[+-]?\d+$/ =~ s }, '%P'
+ ]) {|e|
+ fg = e.foreground
+ bg = e.background
+ invalidcommand [proc{|w| focusAndFlash(w, fg, bg)}, '%W']
+ pack(:fill=>:x, :expand=>true, :padx=>'1m', :pady=>'1m')
+}
+
+l2 = TkLabelFrame.new(base_frame, :text=>"é•·ã•åˆ¶ç´„付ãエントリ")
+TkEntry.new(l2, :validate=>:key, :invcmd=>proc{Tk.bell},
+ :vcmd=>[proc{|s| s.length < 10}, '%P']
+ ).pack(:fill=>:x, :expand=>true, :padx=>'1m', :pady=>'1m')
+
+### PHONE NUMBER ENTRY ###
+# Note that the source to this is quite a bit longer as the behaviour
+# demonstrated is a lot more ambitious than with the others.
+
+# Initial content for the third entry widget
+entry3content = TkVariable.new("1-(000)-000-0000")
+
+# Mapping from alphabetic characters to numbers.
+$phoneNumberMap = {}
+Hash[*(%w(abc 2 def 3 ghi 4 jkl 5 mno 6 pqrs 7 tuv 8 wxyz 9))].each{|chars, n|
+ chars.split('').each{|c|
+ $phoneNumberMap[c] = n
+ $phoneNumberMap[c.upcase] = n
+ }
+}
+
+# phoneSkipLeft --
+# Skip over fixed characters in a phone-number string when moving left.
+#
+# Arguments:
+# widget - The entry widget containing the phone-number.
+def phoneSkipLeft(widget)
+ idx = widget.index('insert')
+ if idx == 8
+ # Skip back two extra characters
+ widget.cursor = idx - 2
+ elsif idx == 7 || idx == 12
+ # Skip back one extra character
+ widget.cursor = idx - 1
+ elsif idx <= 3
+ # Can't move any further
+ Tk.bell
+ Tk.callback_break
+ end
+end
+
+# phoneSkipRight --
+# Skip over fixed characters in a phone-number string when moving right.
+#
+# Arguments:
+# widget - The entry widget containing the phone-number.
+# add - Offset to add to index before calculation (used by validation.)
+def phoneSkipRight(widget, add = 0)
+ idx = widget.index('insert')
+ if (idx + add == 5)
+ # Skip forward two extra characters
+ widget.cursor = idx + 2
+ elsif (idx + add == 6 || idx + add == 10)
+ # Skip forward one extra character
+ widget.cursor = idx + 1
+ elsif (idx + add == 15 && add == 0)
+ # Can't move any further
+ Tk.bell
+ Tk.callback_break
+ end
+end
+
+# validatePhoneChange --
+# Checks that the replacement (mapped to a digit) of the given
+# character in an entry widget at the given position will leave a
+# valid phone number in the widget.
+#
+# widget - entry widget to validate
+# vmode - The widget's validation mode
+# idx - The index where replacement is to occur
+# char - The character (or string, though that will always be
+# refused) to be overwritten at that point.
+
+def validatePhoneChange(widget, vmode, idx, char)
+ return true if idx == nil
+ Tk.after_idle(proc{widget.configure(:validate=>vmode,
+ :invcmd=>proc{Tk.bell})})
+ if !(idx<3 || idx==6 || idx==7 || idx==11 || idx>15) && char =~ /[0-9A-Za-z]/
+ widget.delete(idx)
+ widget.insert(idx, $phoneNumberMap[char] || char)
+ Tk.after_idle(proc{phoneSkipRight(widget, -1)})
+ # Tk.update(true) # <- Don't work 'update' inter validation callback.
+ # It depends on Tcl/Tk side (tested on Tcl/Tk8.5a1).
+ return true
+ end
+ return false
+end
+
+
+l3 = TkLabelFrame.new(base_frame, :text=>"米国電話番å·ã‚¨ãƒ³ãƒˆãƒª")
+TkEntry.new(l3, :validate=>:key, :invcmd=>proc{Tk.bell},
+ :textvariable=>entry3content,
+ :vcmd=>[
+ proc{|w,v,i,s| validatePhoneChange(w,v,i,s)},
+ "%W %v %i %S"
+ ]){|e|
+ # Click to focus goes to the first editable character...
+ bind('FocusIn', proc{|d,w|
+ if d != "NotifyAncestor"
+ w.cursor = 3
+ Tk.after_idle(proc{w.selection_clear})
+ end
+ }, '%d %W')
+ bind('Left', proc{|w| phoneSkipLeft(w)}, '%W')
+ bind('Right', proc{|w| phoneSkipRight(w)}, '%W')
+ pack(:fill=>:x, :expand=>true, :padx=>'1m', :pady=>'1m')
+}
+
+l4 = TkLabelFrame.new(base_frame, :text=>"パスワードエントリ")
+TkEntry.new(l4, :validate=>:key, :show=>'*',
+ :vcmd=>[
+ proc{|s| s.length <= 8},
+ '%P'
+ ]).pack(:fill=>:x, :expand=>true, :padx=>'1m', :pady=>'1m')
+
+TkFrame.new(base_frame){|f|
+ lower
+ TkGrid.configure(l1, l2, :in=>f, :padx=>'3m', :pady=>'1m', :sticky=>:ew)
+ TkGrid.configure(l3, l4, :in=>f, :padx=>'3m', :pady=>'1m', :sticky=>:ew)
+ TkGrid.columnconfigure(f, [0,1], :uniform=>1)
+ pack(:fill=>:both, :expand=>true)
+}
diff --git a/jni/ruby/ext/tk/sample/demos-jp/filebox.rb b/jni/ruby/ext/tk/sample/demos-jp/filebox.rb
new file mode 100644
index 0000000..fc014bc
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/demos-jp/filebox.rb
@@ -0,0 +1,102 @@
+# -*- coding: utf-8 -*-
+#
+# widget demo prompts the user to select a file (called by 'widget')
+#
+
+# toplevel widget ãŒå­˜åœ¨ã™ã‚Œã°å‰Šé™¤ã™ã‚‹
+if defined?($filebox_demo) && $entry2_demo
+ $filebox_demo.destroy
+ $filebox_demo = nil
+end
+
+# demo 用㮠toplevel widget を生æˆ
+$filebox_demo = TkToplevel.new {|w|
+ title("File Selection Dialogs")
+ iconname("filebox")
+ positionWindow(w)
+}
+
+base_frame = TkFrame.new($filebox_demo).pack(:fill=>:both, :expand=>true)
+
+# label 生æˆ
+TkLabel.new(base_frame,'font'=>$font,'wraplength'=>'4i','justify'=>'left',
+ 'text'=>"エントリã«ãƒ•ã‚¡ã‚¤ãƒ«åを直接入力ã™ã‚‹ã‹ã€\"Browse\" ボタンを押ã—ã¦ãƒ•ã‚¡ã‚¤ãƒ«é¸æŠžãƒ€ã‚¤ã‚¢ãƒ­ã‚°ã‹ã‚‰ãƒ•ã‚¡ã‚¤ãƒ«åã‚’é¸ã‚“ã§ä¸‹ã•ã„。").pack('side'=>'top')
+
+# frame 生æˆ
+TkFrame.new(base_frame) {|frame|
+ TkButton.new(frame) {
+ #text '了解'
+ text 'é–‰ã˜ã‚‹'
+ command proc{
+ tmppath = $filebox_demo
+ $filebox_demo = nil
+ tmppath.destroy
+ }
+ }.pack('side'=>'left', 'expand'=>'yes')
+
+ TkButton.new(frame) {
+ text 'コードå‚ç…§'
+ command proc{showCode 'filebox'}
+ }.pack('side'=>'left', 'expand'=>'yes')
+}.pack('side'=>'bottom', 'fill'=>'x', 'pady'=>'2m')
+
+# frame 生æˆ
+['é–‹ã', 'ä¿å­˜'].each{|type|
+ TkFrame.new(base_frame) {|f|
+ TkLabel.new(f, 'text'=>"ファイルを#{type}: ", 'anchor'=>'e')\
+ .pack('side'=>'left')
+
+ TkEntry.new(f, 'width'=>20) {|e|
+ pack('side'=>'left', 'expand'=>'yes', 'fill'=>'x')
+
+ TkButton.new(f, 'text'=>'Browse ...',
+ 'command'=>proc{fileDialog base_frame,e,type})\
+ .pack('side'=>'left')
+ }
+
+ pack('fill'=>'x', 'padx'=>'1c', 'pady'=>3)
+ }
+}
+
+$tk_strictMotif = TkVarAccess.new('tk_strictMotif')
+if ($tk_platform['platform'] == 'unix')
+ TkCheckButton.new(base_frame,
+ 'text'=>'Motifスタイルã®ãƒ€ã‚¤ã‚¢ãƒ­ã‚°ã‚’用ã„ã‚‹',
+ 'variable'=>$tk_strictMotif,
+ 'onvalue'=>1, 'offvalue'=>0 ).pack('anchor'=>'c')
+end
+
+def fileDialog(w,ent,operation)
+ # Type names Extension(s) Mac File Type(s)
+ #
+ #--------------------------------------------------------
+ types = [
+ ['Text files', ['.txt','.doc'] ],
+ ['Text files', [], 'TEXT' ],
+ ['Ruby Scripts', ['.rb'], 'TEXT' ],
+ ['Tcl Scripts', ['.tcl'], 'TEXT' ],
+ ['C Source Files', ['.c','.h'] ],
+ ['All Source Files', ['.rb','.tcl','.c','.h'] ],
+ ['Image Files', ['.gif'] ],
+ ['Image Files', ['.jpeg','.jpg'] ],
+ ['Image Files', [], ['GIFF','JPEG']],
+ ['All files', '*' ]
+ ]
+
+ if operation == 'é–‹ã'
+ file = Tk.getOpenFile('filetypes'=>types, 'parent'=>w)
+ else
+ file = Tk.getSaveFile('filetypes'=>types, 'parent'=>w,
+ 'initialfile'=>'Untitled',
+ 'defaultextension'=>'.txt')
+ end
+ if file != ""
+ ent.delete 0, 'end'
+ ent.insert 0, file
+ # ent.xview 'end'
+ Tk.update_idletasks # need this for Tk::Tile::Entry
+ # (to find right position of 'xview').
+ ent.xview(ent.index('end'))
+ end
+end
+
diff --git a/jni/ruby/ext/tk/sample/demos-jp/floor.rb b/jni/ruby/ext/tk/sample/demos-jp/floor.rb
new file mode 100644
index 0000000..5101a02
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/demos-jp/floor.rb
@@ -0,0 +1,1721 @@
+# -*- coding: utf-8 -*-
+#
+# floorDisplay widget demo (called by 'widget')
+#
+
+# floorDisplay --
+# Recreate the floorplan display in the canvas given by "w". The
+# floor given by "active" is displayed on top with its office structure
+# visible.
+#
+# Arguments:
+# w - Name of the canvas window.
+# active - Number of active floor (1, 2, or 3).
+
+def floorDisplay(w,active)
+ return if $activeFloor == active
+
+ w.delete('all')
+ $activeFloor = active
+
+ # First go through the three floors, displaying the backgrounds for
+ # each floor.
+
+ floor_bg1(w,$floor_colors['bg1'],$floor_colors['outline1'])
+ floor_bg2(w,$floor_colors['bg2'],$floor_colors['outline2'])
+ floor_bg3(w,$floor_colors['bg3'],$floor_colors['outline3'])
+
+ # Raise the background for the active floor so that it's on top.
+
+ w.raise("floor#{active}")
+
+ # Create a dummy item just to mark this point in the display list,
+ # so we can insert highlights here.
+
+ TkcRectangle.new(w,0,100,1,101, 'fill'=>'', 'outline'=>'', 'tags'=>'marker')
+
+ # Add the walls and labels for the active floor, along with
+ # transparent polygons that define the rooms on the floor.
+ # Make sure that the room polygons are on top.
+
+ $floorLabels.clear
+ $floorItems.clear
+ send("floor_fg#{active}", w, $floor_colors['offices'])
+ w.raise('room')
+
+ # Offset the floors diagonally from each other.
+
+ w.move('floor1', '2c', '2c')
+ w.move('floor2', '1c', '1c')
+
+ # Create items for the room entry and its label.
+ TkcWindow.new(w, 600, 100, 'anchor'=>'w', 'window'=>$floor_entry)
+ TkcText.new(w, 600, 100, 'anchor'=>'e', 'text'=>"部屋番å·: ")
+ w['scrollregion'] = w.bbox('all')
+end
+
+# newRoom --
+# This method is invoked whenever the mouse enters a room
+# in the floorplan. It changes tags so that the current room is
+# highlighted.
+#
+# Arguments:
+# w - The name of the canvas window.
+
+def newRoom(w)
+ id = w.find_withtag('current')[0]
+ $currentRoom.value = $floorLabels[id.id] if id != ""
+ Tk.update(true)
+end
+
+# roomChanged --
+# This method is invoked whenever the currentRoom variable changes.
+# It highlights the current room and unhighlights any previous room.
+#
+# Arguments:
+# w - The canvas window displaying the floorplan.
+# args - Not used.
+
+def roomChanged(w,*args)
+ w.delete('highlight')
+ item = $floorItems[$currentRoom.value]
+ return if item == nil
+ new = TkcPolygon.new(w, *(w.coords(item)))
+ new.configure('fill'=>$floor_colors['active'], 'tags'=>'highlight')
+ w.raise(new, 'marker')
+end
+
+# floor_bg1 --
+# This method represents part of the floorplan database. When
+# invoked, it instantiates the background information for the first
+# floor.
+#
+# Arguments:
+# w - The canvas window.
+# fill - Fill color to use for the floor's background.
+# outline - Color to use for the floor's outline.
+
+def floor_bg1(w,fill,outline)
+ TkcPolygon.new(w,347,80,349,82,351,84,353,85,363,92,375,99,386,104,
+ 386,129,398,129,398,162,484,162,484,129,559,129,559,133,725,
+ 133,725,129,802,129,802,389,644,389,644,391,559,391,559,327,
+ 508,327,508,311,484,311,484,278,395,278,395,288,400,288,404,
+ 288,409,290,413,292,418,297,421,302,422,309,421,318,417,325,
+ 411,330,405,332,397,333,344,333,340,334,336,336,335,338,332,
+ 342,331,347,332,351,334,354,336,357,341,359,340,360,335,363,
+ 331,365,326,366,304,366,304,355,258,355,258,387,60,387,60,391,
+ 0,391,0,337,3,337,3,114,8,114,8,25,30,25,30,5,93,5,98,5,104,7,
+ 110,10,116,16,119,20,122,28,123,32,123,68,220,68,220,34,221,
+ 22,223,17,227,13,231,8,236,4,242,2,246,0,260,0,283,1,300,5,
+ 321,14,335,22,348,25,365,29,363,39,358,48,352,56,337,70,
+ 344,76,347,80, 'tags'=>['floor1','bg'], 'fill'=>fill)
+ TkcLine.new(w,386,129,398,129, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ TkcLine.new(w,258,355,258,387, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ TkcLine.new(w,60,387,60,391, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ TkcLine.new(w,0,337,0,391, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ TkcLine.new(w,60,391,0,391, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ TkcLine.new(w,3,114,3,337, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ TkcLine.new(w,258,387,60,387, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ TkcLine.new(w,484,162,398,162, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ TkcLine.new(w,398,162,398,129, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ TkcLine.new(w,484,278,484,311, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ TkcLine.new(w,484,311,508,311, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ TkcLine.new(w,508,327,508,311, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ TkcLine.new(w,559,327,508,327, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ TkcLine.new(w,644,391,559,391, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ TkcLine.new(w,644,389,644,391, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ TkcLine.new(w,559,129,484,129, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ TkcLine.new(w,484,162,484,129, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ TkcLine.new(w,725,133,559,133, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ TkcLine.new(w,559,129,559,133, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ TkcLine.new(w,725,129,802,129, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ TkcLine.new(w,802,389,802,129, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ TkcLine.new(w,3,337,0,337, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ TkcLine.new(w,559,391,559,327, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ TkcLine.new(w,802,389,644,389, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ TkcLine.new(w,725,133,725,129, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ TkcLine.new(w,8,25,8,114, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ TkcLine.new(w,8,114,3,114, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ TkcLine.new(w,30,25,8,25, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ TkcLine.new(w,484,278,395,278, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ TkcLine.new(w,30,25,30,5, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ TkcLine.new(w,93,5,30,5, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ TkcLine.new(w,98,5,93,5, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ TkcLine.new(w,104,7,98,5, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ TkcLine.new(w,110,10,104,7, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ TkcLine.new(w,116,16,110,10, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ TkcLine.new(w,119,20,116,16, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ TkcLine.new(w,122,28,119,20, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ TkcLine.new(w,123,32,122,28, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ TkcLine.new(w,123,68,123,32, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ TkcLine.new(w,220,68,123,68, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ TkcLine.new(w,386,129,386,104, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ TkcLine.new(w,386,104,375,99, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ TkcLine.new(w,375,99,363,92, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ TkcLine.new(w,353,85,363,92, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ TkcLine.new(w,220,68,220,34, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ TkcLine.new(w,337,70,352,56, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ TkcLine.new(w,352,56,358,48, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ TkcLine.new(w,358,48,363,39, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ TkcLine.new(w,363,39,365,29, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ TkcLine.new(w,365,29,348,25, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ TkcLine.new(w,348,25,335,22, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ TkcLine.new(w,335,22,321,14, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ TkcLine.new(w,321,14,300,5, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ TkcLine.new(w,300,5,283,1, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ TkcLine.new(w,283,1,260,0, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ TkcLine.new(w,260,0,246,0, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ TkcLine.new(w,246,0,242,2, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ TkcLine.new(w,242,2,236,4, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ TkcLine.new(w,236,4,231,8, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ TkcLine.new(w,231,8,227,13, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ TkcLine.new(w,223,17,227,13, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ TkcLine.new(w,221,22,223,17, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ TkcLine.new(w,220,34,221,22, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ TkcLine.new(w,340,360,335,363, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ TkcLine.new(w,335,363,331,365, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ TkcLine.new(w,331,365,326,366, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ TkcLine.new(w,326,366,304,366, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ TkcLine.new(w,304,355,304,366, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ TkcLine.new(w,395,288,400,288, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ TkcLine.new(w,404,288,400,288, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ TkcLine.new(w,409,290,404,288, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ TkcLine.new(w,413,292,409,290, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ TkcLine.new(w,418,297,413,292, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ TkcLine.new(w,421,302,418,297, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ TkcLine.new(w,422,309,421,302, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ TkcLine.new(w,421,318,422,309, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ TkcLine.new(w,421,318,417,325, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ TkcLine.new(w,417,325,411,330, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ TkcLine.new(w,411,330,405,332, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ TkcLine.new(w,405,332,397,333, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ TkcLine.new(w,397,333,344,333, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ TkcLine.new(w,344,333,340,334, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ TkcLine.new(w,340,334,336,336, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ TkcLine.new(w,336,336,335,338, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ TkcLine.new(w,335,338,332,342, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ TkcLine.new(w,331,347,332,342, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ TkcLine.new(w,332,351,331,347, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ TkcLine.new(w,334,354,332,351, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ TkcLine.new(w,336,357,334,354, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ TkcLine.new(w,341,359,336,357, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ TkcLine.new(w,341,359,340,360, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ TkcLine.new(w,395,288,395,278, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ TkcLine.new(w,304,355,258,355, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ TkcLine.new(w,347,80,344,76, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ TkcLine.new(w,344,76,337,70, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ TkcLine.new(w,349,82,347,80, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ TkcLine.new(w,351,84,349,82, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ TkcLine.new(w,353,85,351,84, 'fill'=>outline, 'tags'=>['floor1','bg'])
+end
+
+# floor_bg2 --
+# This method represents part of the floorplan database. When
+# invoked, it instantiates the background information for the first
+# floor.
+#
+# Arguments:
+# w - The canvas window.
+# fill - Fill color to use for the floor's background.
+# outline - Color to use for the floor's outline.
+
+def floor_bg2(w,fill,outline)
+ TkcPolygon.new(w,559,129,484,129,484,162,398,162,398,129,315,129,
+ 315,133,176,133,176,129,96,129,96,133,3,133,3,339,0,339,0,391,
+ 60,391,60,387,258,387,258,329,350,329,350,311,395,311,395,280,
+ 484,280,484,311,508,311,508,327,558,327,558,391,644,391,644,
+ 367,802,367,802,129,725,129,725,133,559,133,559,129,
+ 'tags'=>['floor2','bg'], 'fill'=>fill)
+ TkcLine.new(w,350,311,350,329, 'fill'=>outline, 'tags'=>['floor2','bg'])
+ TkcLine.new(w,398,129,398,162, 'fill'=>outline, 'tags'=>['floor2','bg'])
+ TkcLine.new(w,802,367,802,129, 'fill'=>outline, 'tags'=>['floor2','bg'])
+ TkcLine.new(w,802,129,725,129, 'fill'=>outline, 'tags'=>['floor2','bg'])
+ TkcLine.new(w,725,133,725,129, 'fill'=>outline, 'tags'=>['floor2','bg'])
+ TkcLine.new(w,559,129,559,133, 'fill'=>outline, 'tags'=>['floor2','bg'])
+ TkcLine.new(w,559,133,725,133, 'fill'=>outline, 'tags'=>['floor2','bg'])
+ TkcLine.new(w,484,162,484,129, 'fill'=>outline, 'tags'=>['floor2','bg'])
+ TkcLine.new(w,559,129,484,129, 'fill'=>outline, 'tags'=>['floor2','bg'])
+ TkcLine.new(w,802,367,644,367, 'fill'=>outline, 'tags'=>['floor2','bg'])
+ TkcLine.new(w,644,367,644,391, 'fill'=>outline, 'tags'=>['floor2','bg'])
+ TkcLine.new(w,644,391,558,391, 'fill'=>outline, 'tags'=>['floor2','bg'])
+ TkcLine.new(w,558,327,558,391, 'fill'=>outline, 'tags'=>['floor2','bg'])
+ TkcLine.new(w,558,327,508,327, 'fill'=>outline, 'tags'=>['floor2','bg'])
+ TkcLine.new(w,508,327,508,311, 'fill'=>outline, 'tags'=>['floor2','bg'])
+ TkcLine.new(w,484,311,508,311, 'fill'=>outline, 'tags'=>['floor2','bg'])
+ TkcLine.new(w,484,280,484,311, 'fill'=>outline, 'tags'=>['floor2','bg'])
+ TkcLine.new(w,398,162,484,162, 'fill'=>outline, 'tags'=>['floor2','bg'])
+ TkcLine.new(w,484,280,395,280, 'fill'=>outline, 'tags'=>['floor2','bg'])
+ TkcLine.new(w,395,280,395,311, 'fill'=>outline, 'tags'=>['floor2','bg'])
+ TkcLine.new(w,258,387,60,387, 'fill'=>outline, 'tags'=>['floor2','bg'])
+ TkcLine.new(w,3,133,3,339, 'fill'=>outline, 'tags'=>['floor2','bg'])
+ TkcLine.new(w,3,339,0,339, 'fill'=>outline, 'tags'=>['floor2','bg'])
+ TkcLine.new(w,60,391,0,391, 'fill'=>outline, 'tags'=>['floor2','bg'])
+ TkcLine.new(w,0,339,0,391, 'fill'=>outline, 'tags'=>['floor2','bg'])
+ TkcLine.new(w,60,387,60,391, 'fill'=>outline, 'tags'=>['floor2','bg'])
+ TkcLine.new(w,258,329,258,387, 'fill'=>outline, 'tags'=>['floor2','bg'])
+ TkcLine.new(w,350,329,258,329, 'fill'=>outline, 'tags'=>['floor2','bg'])
+ TkcLine.new(w,395,311,350,311, 'fill'=>outline, 'tags'=>['floor2','bg'])
+ TkcLine.new(w,398,129,315,129, 'fill'=>outline, 'tags'=>['floor2','bg'])
+ TkcLine.new(w,176,133,315,133, 'fill'=>outline, 'tags'=>['floor2','bg'])
+ TkcLine.new(w,176,129,96,129, 'fill'=>outline, 'tags'=>['floor2','bg'])
+ TkcLine.new(w,3,133,96,133, 'fill'=>outline, 'tags'=>['floor2','bg'])
+ TkcLine.new(w,315,133,315,129, 'fill'=>outline, 'tags'=>['floor2','bg'])
+ TkcLine.new(w,176,133,176,129, 'fill'=>outline, 'tags'=>['floor2','bg'])
+ TkcLine.new(w,96,133,96,129, 'fill'=>outline, 'tags'=>['floor2','bg'])
+end
+
+# floor_bg3 --
+# This method represents part of the floorplan database. When
+# invoked, it instantiates the background information for the first
+# floor.
+#
+# Arguments:
+# w - The canvas window.
+# fill - Fill color to use for the floor's background.
+# outline - Color to use for the floor's outline.
+
+def floor_bg3(w,fill,outline)
+ TkcPolygon.new(w,159,300,107,300,107,248,159,248,159,129,96,129,96,
+ 133,21,133,21,331,0,331,0,391,60,391,60,370,159,370,159,300,
+ 'tags'=>['floor3','bg'], 'fill'=>fill)
+ TkcPolygon.new(w,258,370,258,329,350,329,350,311,399,311,399,129,
+ 315,129,315,133,176,133,176,129,159,129,159,370,258,370,
+ 'tags'=>['floor3','bg'], 'fill'=>fill)
+ TkcLine.new(w,96,133,96,129, 'fill'=>outline, 'tags'=>['floor3','bg'])
+ TkcLine.new(w,176,129,96,129, 'fill'=>outline, 'tags'=>['floor3','bg'])
+ TkcLine.new(w,176,129,176,133, 'fill'=>outline, 'tags'=>['floor3','bg'])
+ TkcLine.new(w,315,133,176,133, 'fill'=>outline, 'tags'=>['floor3','bg'])
+ TkcLine.new(w,315,133,315,129, 'fill'=>outline, 'tags'=>['floor3','bg'])
+ TkcLine.new(w,399,129,315,129, 'fill'=>outline, 'tags'=>['floor3','bg'])
+ TkcLine.new(w,399,311,399,129, 'fill'=>outline, 'tags'=>['floor3','bg'])
+ TkcLine.new(w,399,311,350,311, 'fill'=>outline, 'tags'=>['floor3','bg'])
+ TkcLine.new(w,350,329,350,311, 'fill'=>outline, 'tags'=>['floor3','bg'])
+ TkcLine.new(w,350,329,258,329, 'fill'=>outline, 'tags'=>['floor3','bg'])
+ TkcLine.new(w,258,370,258,329, 'fill'=>outline, 'tags'=>['floor3','bg'])
+ TkcLine.new(w,60,370,258,370, 'fill'=>outline, 'tags'=>['floor3','bg'])
+ TkcLine.new(w,60,370,60,391, 'fill'=>outline, 'tags'=>['floor3','bg'])
+ TkcLine.new(w,60,391,0,391, 'fill'=>outline, 'tags'=>['floor3','bg'])
+ TkcLine.new(w,0,391,0,331, 'fill'=>outline, 'tags'=>['floor3','bg'])
+ TkcLine.new(w,21,331,0,331, 'fill'=>outline, 'tags'=>['floor3','bg'])
+ TkcLine.new(w,21,331,21,133, 'fill'=>outline, 'tags'=>['floor3','bg'])
+ TkcLine.new(w,96,133,21,133, 'fill'=>outline, 'tags'=>['floor3','bg'])
+ TkcLine.new(w,107,300,159,300,159,248,107,248,107,300,
+ 'fill'=>outline, 'tags'=>['floor3','bg'])
+end
+
+# floor_fg1 --
+# This method represents part of the floorplan database. When
+# invoked, it instantiates the foreground information for the first
+# floor (office outlines and numbers).
+#
+# Arguments:
+# w - The canvas window.
+# color - Color to use for drawing foreground information.
+
+def floor_fg1(w,color)
+ i = TkcPolygon.new(w,375,246,375,172,341,172,341,246,
+ 'fill'=>'', 'tags'=>['floor1','room'])
+ $floorLabels[i.id] = '101'
+ $floorItems['101'] = i
+ TkcText.new(w,358,209, 'text'=>'101', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor1','label'])
+ i = TkcPolygon.new(w,307,240,339,240,339,206,307,206,
+ 'fill'=>'', 'tags'=>['floor1','room'])
+ $floorLabels[i.id] = 'Pub Lift1'
+ $floorItems['Pub Lift1'] = i
+ TkcText.new(w,323,223, 'text'=>'Pub Lift1', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor1','label'])
+ i = TkcPolygon.new(w,339,205,307,205,307,171,339,171,
+ 'fill'=>'', 'tags'=>['floor1','room'])
+ $floorLabels[i.id] = 'Priv Lift1'
+ $floorItems['Priv Lift1'] = i
+ TkcText.new(w,323,188, 'text'=>'Priv Lift1', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor1','label'])
+ i = TkcPolygon.new(w,42,389,42,337,1,337,1,389,
+ 'fill'=>'', 'tags'=>['floor1','room'])
+ $floorLabels[i.id] = '110'
+ $floorItems['110'] = i
+ TkcText.new(w,21.5,363, 'text'=>'110', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor1','label'])
+ i = TkcPolygon.new(w,59,389,59,385,90,385,90,337,44,337,44,389,
+ 'fill'=>'', 'tags'=>['floor1','room'])
+ $floorLabels[i.id] = '109'
+ $floorItems['109'] = i
+ TkcText.new(w,67,363, 'text'=>'109', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor1','label'])
+ i = TkcPolygon.new(w,51,300,51,253,6,253,6,300,
+ 'fill'=>'', 'tags'=>['floor1','room'])
+ $floorLabels[i.id] = '111'
+ $floorItems['111'] = i
+ TkcText.new(w,28.5,276.5, 'text'=>'111', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor1','label'])
+ i = TkcPolygon.new(w,98,248,98,309,79,309,79,248,
+ 'fill'=>'', 'tags'=>['floor1','room'])
+ $floorLabels[i.id] = '117B'
+ $floorItems['117B'] = i
+ TkcText.new(w,88.5,278.5, 'text'=>'117B', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor1','label'])
+ i = TkcPolygon.new(w,51,251,51,204,6,204,6,251,
+ 'fill'=>'', 'tags'=>['floor1','room'])
+ $floorLabels[i.id] = '112'
+ $floorItems['112'] = i
+ TkcText.new(w,28.5,227.5, 'text'=>'112', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor1','label'])
+ i = TkcPolygon.new(w,6,156,51,156,51,203,6,203,
+ 'fill'=>'', 'tags'=>['floor1','room'])
+ $floorLabels[i.id] = '113'
+ $floorItems['113'] = i
+ TkcText.new(w,28.5,179.5, 'text'=>'113', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor1','label'])
+ i = TkcPolygon.new(w,85,169,79,169,79,192,85,192,
+ 'fill'=>'', 'tags'=>['floor1','room'])
+ $floorLabels[i.id] = '117A'
+ $floorItems['117A'] = i
+ TkcText.new(w,82,180.5, 'text'=>'117A', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor1','label'])
+ i = TkcPolygon.new(w,77,302,77,168,53,168,53,302,
+ 'fill'=>'', 'tags'=>['floor1','room'])
+ $floorLabels[i.id] = '117'
+ $floorItems['117'] = i
+ TkcText.new(w,65,235, 'text'=>'117', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor1','label'])
+ i = TkcPolygon.new(w,51,155,51,115,6,115,6,155,
+ 'fill'=>'', 'tags'=>['floor1','room'])
+ $floorLabels[i.id] = '114'
+ $floorItems['114'] = i
+ TkcText.new(w,28.5,135, 'text'=>'114', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor1','label'])
+ i = TkcPolygon.new(w,95,115,53,115,53,168,95,168,
+ 'fill'=>'', 'tags'=>['floor1','room'])
+ $floorLabels[i.id] = '115'
+ $floorItems['115'] = i
+ TkcText.new(w,74,141.5, 'text'=>'115', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor1','label'])
+ i = TkcPolygon.new(w,87,113,87,27,10,27,10,113,
+ 'fill'=>'', 'tags'=>['floor1','room'])
+ $floorLabels[i.id] = '116'
+ $floorItems['116'] = i
+ TkcText.new(w,48.5,70, 'text'=>'116', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor1','label'])
+ i = TkcPolygon.new(w,89,91,128,91,128,113,89,131,
+ 'fill'=>'', 'tags'=>['floor1','room'])
+ $floorLabels[i.id] = '118'
+ $floorItems['118'] = i
+ TkcText.new(w,108.5,102, 'text'=>'118', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor1','label'])
+ i = TkcPolygon.new(w,178,128,178,132,216,132,216,91,
+ 163,91,163,112,149,112,149,128,
+ 'fill'=>'', 'tags'=>['floor1','room'])
+ $floorLabels[i.id] = '120'
+ $floorItems['120'] = i
+ TkcText.new(w,189.5,111.5, 'text'=>'120', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor1','label'])
+ i = TkcPolygon.new(w,79,193,87,193,87,169,136,169,136,192,
+ 156,192,156,169,175,169,175,246,79,246,
+ 'fill'=>'', 'tags'=>['floor1','room'])
+ $floorLabels[i.id] = '122'
+ $floorItems['122'] = i
+ TkcText.new(w,131,207.5, 'text'=>'122', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor1','label'])
+ i = TkcPolygon.new(w,138,169,154,169,154,191,138,191,
+ 'fill'=>'', 'tags'=>['floor1','room'])
+ $floorLabels[i.id] = '121'
+ $floorItems['121'] = i
+ TkcText.new(w,146,180, 'text'=>'121', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor1','label'])
+ i = TkcPolygon.new(w,99,300,126,300,126,309,99,309,
+ 'fill'=>'', 'tags'=>['floor1','room'])
+ $floorLabels[i.id] = '106A'
+ $floorItems['106A'] = i
+ TkcText.new(w,112.5,304.5, 'text'=>'106A', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor1','label'])
+ i = TkcPolygon.new(w,128,299,128,309,150,309,150,248,99,248,99,299,
+ 'fill'=>'', 'tags'=>['floor1','room'])
+ $floorLabels[i.id] = '105'
+ $floorItems['105'] = i
+ TkcText.new(w,124.5,278.5, 'text'=>'105', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor1','label'])
+ i = TkcPolygon.new(w,174,309,174,300,152,300,152,309,
+ 'fill'=>'', 'tags'=>['floor1','room'])
+ $floorLabels[i.id] = '106B'
+ $floorItems['106B'] = i
+ TkcText.new(w,163,304.5, 'text'=>'106B', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor1','label'])
+ i = TkcPolygon.new(w,176,299,176,309,216,309,216,248,152,248,152,299,
+ 'fill'=>'', 'tags'=>['floor1','room'])
+ $floorLabels[i.id] = '104'
+ $floorItems['104'] = i
+ TkcText.new(w,184,278.5, 'text'=>'104', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor1','label'])
+ i = TkcPolygon.new(w,138,385,138,337,91,337,91,385,
+ 'fill'=>'', 'tags'=>['floor1','room'])
+ $floorLabels[i.id] = '108'
+ $floorItems['108'] = i
+ TkcText.new(w,114.5,361, 'text'=>'108', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor1','label'])
+ i = TkcPolygon.new(w,256,337,140,337,140,385,256,385,
+ 'fill'=>'', 'tags'=>['floor1','room'])
+ $floorLabels[i.id] = '107'
+ $floorItems['107'] = i
+ TkcText.new(w,198,361, 'text'=>'107', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor1','label'])
+ i = TkcPolygon.new(w,300,353,300,329,260,329,260,353,
+ 'fill'=>'', 'tags'=>['floor1','room'])
+ $floorLabels[i.id] = 'Smoking'
+ $floorItems['Smoking'] = i
+ TkcText.new(w,280,341, 'text'=>'Smoking', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor1','label'])
+ i = TkcPolygon.new(w,314,135,314,170,306,170,306,246,177,246,177,135,
+ 'fill'=>'', 'tags'=>['floor1','room'])
+ $floorLabels[i.id] = '123'
+ $floorItems['123'] = i
+ TkcText.new(w,245.5,190.5, 'text'=>'123', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor1','label'])
+ i = TkcPolygon.new(w,217,248,301,248,301,326,257,326,257,310,217,310,
+ 'fill'=>'', 'tags'=>['floor1','room'])
+ $floorLabels[i.id] = '103'
+ $floorItems['103'] = i
+ TkcText.new(w,259,287, 'text'=>'103', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor1','label'])
+ i = TkcPolygon.new(w,396,188,377,188,377,169,316,169,316,131,396,131,
+ 'fill'=>'', 'tags'=>['floor1','room'])
+ $floorLabels[i.id] = '124'
+ $floorItems['124'] = i
+ TkcText.new(w,356,150, 'text'=>'124', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor1','label'])
+ i = TkcPolygon.new(w,397,226,407,226,407,189,377,189,377,246,397,246,
+ 'fill'=>'', 'tags'=>['floor1','room'])
+ $floorLabels[i.id] = '125'
+ $floorItems['125'] = i
+ TkcText.new(w,392,217.5, 'text'=>'125', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor1','label'])
+ i = TkcPolygon.new(w,399,187,409,187,409,207,474,207,474,164,399,164,
+ 'fill'=>'', 'tags'=>['floor1','room'])
+ $floorLabels[i.id] = '126'
+ $floorItems['126'] = i
+ TkcText.new(w,436.5,185.5, 'text'=>'126', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor1','label'])
+ i = TkcPolygon.new(w,409,209,409,229,399,229,399,253,
+ 486,253,486,239,474,239,474,209,
+ 'fill'=>'', 'tags'=>['floor1','room'])
+ $floorLabels[i.id] = '127'
+ $floorItems['127'] = i
+ TkcText.new(w,436.5,'231', 'text'=>'127', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor1','label'])
+ i = TkcPolygon.new(w,501,164,501,174,495,174,495,188,
+ 490,188,490,204,476,204,476,164,
+ 'fill'=>'', 'tags'=>['floor1','room'])
+ $floorLabels[i.id] = 'MShower'
+ $floorItems['MShower'] = i
+ TkcText.new(w,488.5,'184', 'text'=>'MShower', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor1','label'])
+ i = TkcPolygon.new(w,497,176,513,176,513,204,492,204,492,190,497,190,
+ 'fill'=>'', 'tags'=>['floor1','room'])
+ $floorLabels[i.id] = 'Closet'
+ $floorItems['Closet'] = i
+ TkcText.new(w,502.5,190, 'text'=>'Closet', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor1','label'])
+ i = TkcPolygon.new(w,476,237,476,206,513,206,513,254,488,254,488,237,
+ 'fill'=>'', 'tags'=>['floor1','room'])
+ $floorLabels[i.id] = 'WShower'
+ $floorItems['WShower'] = i
+ TkcText.new(w,494.5,230, 'text'=>'WShower', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor1','label'])
+ i = TkcPolygon.new(w,486,131,558,131,558,135,724,135,724,166,
+ 697,166,697,275,553,275,531,254,515,254,
+ 515,174,503,174,503,161,486,161,
+ 'fill'=>'', 'tags'=>['floor1','room'])
+ $floorLabels[i.id] = '130'
+ $floorItems['130'] = i
+ TkcText.new(w,638.5,205, 'text'=>'130', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor1','label'])
+ i = TkcPolygon.new(w,308,242,339,242,339,248,342,248,
+ 342,246,397,246,397,276,393,276,
+ 393,309,300,309,300,248,308,248,
+ 'fill'=>'', 'tags'=>['floor1','room'])
+ $floorLabels[i.id] = '102'
+ $floorItems['102'] = i
+ TkcText.new(w,367.5,278.5, 'text'=>'102', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor1','label'])
+ i = TkcPolygon.new(w,397,255,486,255,486,276,397,276,
+ 'fill'=>'', 'tags'=>['floor1','room'])
+ $floorLabels[i.id] = '128'
+ $floorItems['128'] = i
+ TkcText.new(w,441.5,265.5, 'text'=>'128', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor1','label'])
+ i = TkcPolygon.new(w,510,309,486,309,486,255,530,255,
+ 552,277,561,277,561,325,510,325,
+ 'fill'=>'', 'tags'=>['floor1','room'])
+ $floorLabels[i.id] = '129'
+ $floorItems['129'] = i
+ TkcText.new(w,535.5,293, 'text'=>'129', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor1','label'])
+ i = TkcPolygon.new(w,696,281,740,281,740,387,642,387,
+ 642,389,561,389,561,277,696,277,
+ 'fill'=>'', 'tags'=>['floor1','room'])
+ $floorLabels[i.id] = '133'
+ $floorItems['133'] = i
+ TkcText.new(w,628.5,335, 'text'=>'133', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor1','label'])
+ i = TkcPolygon.new(w,742,387,742,281,800,281,800,387,
+ 'fill'=>'', 'tags'=>['floor1','room'])
+ $floorLabels[i.id] = '132'
+ $floorItems['132'] = i
+ TkcText.new(w,771,334, 'text'=>'132', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor1','label'])
+ i = TkcPolygon.new(w,800,168,800,280,699,280,699,168,
+ 'fill'=>'', 'tags'=>['floor1','room'])
+ $floorLabels[i.id] = '134'
+ $floorItems['134'] = i
+ TkcText.new(w,749.5,224, 'text'=>'134', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor1','label'])
+ i = TkcPolygon.new(w,726,131,726,166,800,166,800,131,
+ 'fill'=>'', 'tags'=>['floor1','room'])
+ $floorLabels[i.id] = '135'
+ $floorItems['135'] = i
+ TkcText.new(w,763,148.5, 'text'=>'135', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor1','label'])
+ i = TkcPolygon.new(w,340,360,335,363,331,365,326,366,304,366,
+ 304,312,396,312,396,288,400,288,404,288,
+ 409,290,413,292,418,297,421,302,422,309,
+ 421,318,417,325,411,330,405,332,397,333,
+ 344,333,340,334,336,336,335,338,332,342,
+ 331,347,332,351,334,354,336,357,341,359,
+ 'fill'=>'', 'tags'=>['floor1','room'])
+ $floorLabels[i.id] = 'Ramona Stair'
+ $floorItems['Ramona Stair'] = i
+ TkcText.new(w,368,323, 'text'=>'Ramona Stair', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor1','label'])
+ i = TkcPolygon.new(w,30,23,30,5,93,5,98,5,104,7,110,10,116,16,119,20,
+ 122,28,123,32,123,68,220,68,220,87,90,87,90,23,
+ 'fill'=>'', 'tags'=>['floor1','room'])
+ $floorLabels[i.id] = 'University Stair'
+ $floorItems['University Stair'] = i
+ TkcText.new(w,155,77.5, 'text'=>'University Stair', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor1','label'])
+ i = TkcPolygon.new(w,282,37,295,40,312,49,323,56,337,70,352,56,
+ 358,48,363,39,365,29,348,25,335,22,321,14,
+ 300,5,283,1,260,0,246,0,242,2,236,4,231,8,
+ 227,13,223,17,221,22,220,34,260,34,
+ 'fill'=>'', 'tags'=>['floor1','room'])
+ $floorLabels[i.id] = 'Plaza Stair'
+ $floorItems['Plaza Stair'] = i
+ TkcText.new(w,317.5,28.5, 'text'=>'Plaza Stair', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor1','label'])
+ i = TkcPolygon.new(w,220,34,260,34,282,37,295,40,312,49,
+ 323,56,337,70,350,83,365,94,377,100,
+ 386,104,386,128,220,128,
+ 'fill'=>'', 'tags'=>['floor1','room'])
+ $floorLabels[i.id] = 'Plaza Deck'
+ $floorItems['Plaza Deck'] = i
+ TkcText.new(w,303,81, 'text'=>'Plaza Deck', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor1','label'])
+ i = TkcPolygon.new(w,257,336,77,336,6,336,6,301,77,301,77,310,257,310,
+ 'fill'=>'', 'tags'=>['floor1','room'])
+ $floorLabels[i.id] = '106'
+ $floorItems['106'] = i
+ TkcText.new(w,131.5,318.5, 'text'=>'106', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor1','label'])
+ i = TkcPolygon.new(w,146,110,162,110,162,91,130,91,130,115,95,115,
+ 95,128,114,128,114,151,157,151,157,153,112,153,
+ 112,130,97,130,97,168,175,168,175,131,146,131,
+ 'fill'=>'', 'tags'=>['floor1','room'])
+ $floorLabels[i.id] = '119'
+ $floorItems['119'] = i
+ TkcText.new(w,143.5,133, 'text'=>'119', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor1','label'])
+ TkcLine.new(w,155,191,155,189, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,155,177,155,169, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,96,129,96,169, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,78,169,176,169, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,176,247,176,129, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,340,206,307,206, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,340,187,340,170, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,340,210,340,201, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,340,247,340,224, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,340,241,307,241, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,376,246,376,170, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,307,247,307,170, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,376,170,307,170, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,315,129,315,170, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,147,129,176,129, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,202,133,176,133, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,398,129,315,129, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,258,352,258,387, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,60,387,60,391, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,0,337,0,391, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,60,391,0,391, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,3,114,3,337, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,258,387,60,387, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,52,237,52,273, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,52,189,52,225, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,52,140,52,177, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,395,306,395,311, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,531,254,398,254, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,475,178,475,238, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,502,162,398,162, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,398,129,398,188, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,383,188,376,188, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,408,188,408,194, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,398,227,398,254, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,408,227,398,227, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,408,222,408,227, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,408,206,408,210, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,408,208,475,208, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,484,278,484,311, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,484,311,508,311, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,508,327,508,311, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,559,327,508,327, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,644,391,559,391, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,644,389,644,391, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,514,205,475,205, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,496,189,496,187, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,559,129,484,129, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,484,162,484,129, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,725,133,559,133, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,559,129,559,133, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,725,149,725,167, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,725,129,802,129, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,802,389,802,129, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,739,167,802,167, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,396,188,408,188, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,0,337,9,337, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,58,337,21,337, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,43,391,43,337, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,105,337,75,337, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,91,387,91,337, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,154,337,117,337, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,139,387,139,337, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,227,337,166,337, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,258,337,251,337, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,258,328,302,328, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,302,355,302,311, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,395,311,302,311, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,484,278,395,278, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,395,294,395,278, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,473,278,473,275, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,473,256,473,254, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,533,257,531,254, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,553,276,551,274, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,698,276,553,276, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,559,391,559,327, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,802,389,644,389, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,741,314,741,389, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,698,280,698,167, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,707,280,698,280, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,802,280,731,280, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,741,280,741,302, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,698,167,727,167, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,725,137,725,129, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,514,254,514,175, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,496,175,514,175, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,502,175,502,162, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,475,166,475,162, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,496,176,496,175, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,491,189,496,189, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,491,205,491,189, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,487,238,475,238, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,487,240,487,238, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,487,252,487,254, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,315,133,304,133, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,256,133,280,133, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,78,247,270,247, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,307,247,294,247, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,214,133,232,133, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,217,247,217,266, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,217,309,217,291, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,217,309,172,309, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,154,309,148,309, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,175,300,175,309, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,151,300,175,300, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,151,247,151,309, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,78,237,78,265, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,78,286,78,309, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,106,309,78,309, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,130,309,125,309, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,99,309,99,247, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,127,299,99,299, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,127,309,127,299, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,155,191,137,191, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,137,169,137,191, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,78,171,78,169, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,78,190,78,218, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,86,192,86,169, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,86,192,78,192, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,52,301,3,301, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,52,286,52,301, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,52,252,3,252, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,52,203,3,203, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,3,156,52,156, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,8,25,8,114, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,63,114,3,114, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,75,114,97,114, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,108,114,129,114, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,129,114,129,89, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,52,114,52,128, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,132,89,88,89, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,88,25,88,89, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,88,114,88,89, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,218,89,144,89, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,147,111,147,129, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,162,111,147,111, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,162,109,162,111, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,162,96,162,89, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,218,89,218,94, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,218,89,218,119, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,8,25,88,25, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,258,337,258,328, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,113,129,96,129, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,302,355,258,355, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,386,104,386,129, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,377,100,386,104, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,365,94,377,100, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,350,83,365,94, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,337,70,350,83, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,337,70,323,56, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,312,49,323,56, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,295,40,312,49, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,282,37,295,40, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,260,34,282,37, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,253,34,260,34, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,386,128,386,104, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,113,152,156,152, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,113,152,156,152, 'fill'=>color, 'tags'=>['floor1','wall'])
+ TkcLine.new(w,113,152,113,129, 'fill'=>color, 'tags'=>['floor1','wall'])
+end
+
+# floor_fg2 --
+# This method represents part of the floorplan database. When
+# invoked, it instantiates the foreground information for the second
+# floor (office outlines and numbers).
+#
+# Arguments:
+# w - The canvas window.
+# color - Color to use for drawing foreground information.
+
+def floor_fg2(w,color)
+ i = TkcPolygon.new(w,748,188,755,188,755,205,758,205,758,222,
+ 800,222,800,168,748,168,
+ 'fill'=>'', 'tags'=>['floor2','room'])
+ $floorLabels[i.id] = '238'
+ $floorItems['238'] = i
+ TkcText.new(w,774,195, 'text'=>'238', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor2','label'])
+ i = TkcPolygon.new(w,726,188,746,188,746,166,800,166,800,131,726,131,
+ 'fill'=>'', 'tags'=>['floor2','room'])
+ $floorLabels[i.id] = '237'
+ $floorItems['237'] = i
+ TkcText.new(w,763,148.5, 'text'=>'237', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor2','label'])
+ i = TkcPolygon.new(w,497,187,497,204,559,204,559,324,641,324,
+ 643,324,643,291,641,291,641,205,696,205,
+ 696,291,694,291,694,314,715,314,715,291,
+ 715,205,755,205,755,190,724,190,724,187,
+ 'fill'=>'', 'tags'=>['floor2','room'])
+ $floorLabels[i.id] = '246'
+ $floorItems['246'] = i
+ TkcText.new(w,600,264, 'text'=>'246', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor2','label'])
+ i = TkcPolygon.new(w,694,279,643,279,643,314,694,314,
+ 'fill'=>'', 'tags'=>['floor2','room'])
+ $floorLabels[i.id] = '247'
+ $floorItems['247'] = i
+ TkcText.new(w,668.5,296.5, 'text'=>'247', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor2','label'])
+ i = TkcPolygon.new(w,232,250,308,250,308,242,339,242,339,246,
+ 397,246,397,255,476,255,476,250,482,250,559,250,
+ 559,274,482,274,482,278,396,278,396,274,232,274,
+ 'fill'=>'', 'tags'=>['floor2','room'])
+ $floorLabels[i.id] = '202'
+ $floorItems['202'] = i
+ TkcText.new(w,285.5,260, 'text'=>'202', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor2','label'])
+ i = TkcPolygon.new(w,53,228,53,338,176,338,233,338,233,196,
+ 306,196,306,180,175,180,175,169,156,169,
+ 156,196,176,196,176,228,
+ 'fill'=>'', 'tags'=>['floor2','room'])
+ $floorLabels[i.id] = '206'
+ $floorItems['206'] = i
+ TkcText.new(w,143,267, 'text'=>'206', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor2','label'])
+ i = TkcPolygon.new(w,51,277,6,277,6,338,51,338,
+ 'fill'=>'', 'tags'=>['floor2','room'])
+ $floorLabels[i.id] = '212'
+ $floorItems['212'] = i
+ TkcText.new(w,28.5,307.5, 'text'=>'212', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor2','label'])
+ i = TkcPolygon.new(w,557,276,486,276,486,309,510,309,510,325,557,325,
+ 'fill'=>'', 'tags'=>['floor2','room'])
+ $floorLabels[i.id] = '245'
+ $floorItems['245'] = i
+ TkcText.new(w,521.5,300.5, 'text'=>'245', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor2','label'])
+ i = TkcPolygon.new(w,560,389,599,389,599,326,560,326,
+ 'fill'=>'', 'tags'=>['floor2','room'])
+ $floorLabels[i.id] = '244'
+ $floorItems['244'] = i
+ TkcText.new(w,579.5,357.5, 'text'=>'244', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor2','label'])
+ i = TkcPolygon.new(w,601,389,601,326,643,326,643,389,
+ 'fill'=>'', 'tags'=>['floor2','room'])
+ $floorLabels[i.id] = '243'
+ $floorItems['243'] = i
+ TkcText.new(w,622,357.5, 'text'=>'243', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor2','label'])
+ i = TkcPolygon.new(w,688,316,645,316,645,365,688,365,
+ 'fill'=>'', 'tags'=>['floor2','room'])
+ $floorLabels[i.id] = '242'
+ $floorItems['242'] = i
+ TkcText.new(w,666.5,340.5, 'text'=>'242', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor2','label'])
+ i = TkcPolygon.new(w,802,367,759,367,759,226,802,226,
+ 'fill'=>'', 'tags'=>['floor2','room'])
+ $floorLabels[i.id] = 'Barbecue Deck'
+ $floorItems['Barbecue Deck'] = i
+ TkcText.new(w,780.5,296.5, 'text'=>'Barbecue Deck', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor2','label'])
+ i = TkcPolygon.new(w,755,262,755,314,717,314,717,262,
+ 'fill'=>'', 'tags'=>['floor2','room'])
+ $floorLabels[i.id] = '240'
+ $floorItems['240'] = i
+ TkcText.new(w,736,288, 'text'=>'240', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor2','label'])
+ i = TkcPolygon.new(w,755,316,689,316,689,365,755,365,
+ 'fill'=>'', 'tags'=>['floor2','room'])
+ $floorLabels[i.id] = '241'
+ $floorItems['241'] = i
+ TkcText.new(w,722,340.5, 'text'=>'241', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor2','label'])
+ i = TkcPolygon.new(w,755,206,717,206,717,261,755,261,
+ 'fill'=>'', 'tags'=>['floor2','room'])
+ $floorLabels[i.id] = '239'
+ $floorItems['239'] = i
+ TkcText.new(w,736,233.5, 'text'=>'239', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor2','label'])
+ i = TkcPolygon.new(w,695,277,643,277,643,206,695,206,
+ 'fill'=>'', 'tags'=>['floor2','room'])
+ $floorLabels[i.id] = '248'
+ $floorItems['248'] = i
+ TkcText.new(w,669,241.5, 'text'=>'248', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor2','label'])
+ i = TkcPolygon.new(w,676,135,676,185,724,185,724,135,
+ 'fill'=>'', 'tags'=>['floor2','room'])
+ $floorLabels[i.id] = '236'
+ $floorItems['236'] = i
+ TkcText.new(w,700,160, 'text'=>'236', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor2','label'])
+ i = TkcPolygon.new(w,675,135,635,135,635,145,628,145,628,185,675,185,
+ 'fill'=>'', 'tags'=>['floor2','room'])
+ $floorLabels[i.id] = '235'
+ $floorItems['235'] = i
+ TkcText.new(w,651.5,160, 'text'=>'235', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor2','label'])
+ i = TkcPolygon.new(w,626,143,633,143,633,135,572,135,
+ 572,143,579,143,579,185,626,185,
+ 'fill'=>'', 'tags'=>['floor2','room'])
+ $floorLabels[i.id] = '234'
+ $floorItems['234'] = i
+ TkcText.new(w,606,160, 'text'=>'234', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor2','label'])
+ i = TkcPolygon.new(w,557,135,571,135,571,145,578,145,
+ 578,185,527,185,527,131,557,131,
+ 'fill'=>'', 'tags'=>['floor2','room'])
+ $floorLabels[i.id] = '233'
+ $floorItems['233'] = i
+ TkcText.new(w,552.5,158, 'text'=>'233', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor2','label'])
+ i = TkcPolygon.new(w,476,249,557,249,557,205,476,205,
+ 'fill'=>'', 'tags'=>['floor2','room'])
+ $floorLabels[i.id] = '230'
+ $floorItems['230'] = i
+ TkcText.new(w,516.5,227, 'text'=>'230', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor2','label'])
+ i = TkcPolygon.new(w,476,164,486,164,486,131,525,131,525,185,476,185,
+ 'fill'=>'', 'tags'=>['floor2','room'])
+ $floorLabels[i.id] = '232'
+ $floorItems['232'] = i
+ TkcText.new(w,500.5,158, 'text'=>'232', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor2','label'])
+ i = TkcPolygon.new(w,476,186,495,186,495,204,476,204,
+ 'fill'=>'', 'tags'=>['floor2','room'])
+ $floorLabels[i.id] = '229'
+ $floorItems['229'] = i
+ TkcText.new(w,485.5,195, 'text'=>'229', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor2','label'])
+ i = TkcPolygon.new(w,474,207,409,207,409,187,399,187,399,164,474,164,
+ 'fill'=>'', 'tags'=>['floor2','room'])
+ $floorLabels[i.id] = '227'
+ $floorItems['227'] = i
+ TkcText.new(w,436.5,185.5, 'text'=>'227', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor2','label'])
+ i = TkcPolygon.new(w,399,228,399,253,474,253,474,209,409,209,409,228,
+ 'fill'=>'', 'tags'=>['floor2','room'])
+ $floorLabels[i.id] = '228'
+ $floorItems['228'] = i
+ TkcText.new(w,436.5,231, 'text'=>'228', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor2','label'])
+ i = TkcPolygon.new(w,397,246,397,226,407,226,407,189,377,189,377,246,
+ 'fill'=>'', 'tags'=>['floor2','room'])
+ $floorLabels[i.id] = '226'
+ $floorItems['226'] = i
+ TkcText.new(w,392,217.5, 'text'=>'226', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor2','label'])
+ i = TkcPolygon.new(w,377,169,316,169,316,131,397,131,397,188,377,188,
+ 'fill'=>'', 'tags'=>['floor2','room'])
+ $floorLabels[i.id] = '225'
+ $floorItems['225'] = i
+ TkcText.new(w,356.5,150, 'text'=>'225', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor2','label'])
+ i = TkcPolygon.new(w,234,198,306,198,306,249,234,249,
+ 'fill'=>'', 'tags'=>['floor2','room'])
+ $floorLabels[i.id] = '224'
+ $floorItems['224'] = i
+ TkcText.new(w,270,223.5, 'text'=>'224', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor2','label'])
+ i = TkcPolygon.new(w,270,179,306,179,306,170,314,170,314,135,270,135,
+ 'fill'=>'', 'tags'=>['floor2','room'])
+ $floorLabels[i.id] = '223'
+ $floorItems['223'] = i
+ TkcText.new(w,292,157, 'text'=>'223', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor2','label'])
+ i = TkcPolygon.new(w,268,179,221,179,221,135,268,135,
+ 'fill'=>'', 'tags'=>['floor2','room'])
+ $floorLabels[i.id] = '222'
+ $floorItems['222'] = i
+ TkcText.new(w,244.5,157, 'text'=>'222', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor2','label'])
+ i = TkcPolygon.new(w,177,179,219,179,219,135,177,135,
+ 'fill'=>'', 'tags'=>['floor2','room'])
+ $floorLabels[i.id] = '221'
+ $floorItems['221'] = i
+ TkcText.new(w,198,157, 'text'=>'221', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor2','label'])
+ i = TkcPolygon.new(w,299,327,349,327,349,284,341,284,341,276,299,276,
+ 'fill'=>'', 'tags'=>['floor2','room'])
+ $floorLabels[i.id] = '204'
+ $floorItems['204'] = i
+ TkcText.new(w,324,301.5, 'text'=>'204', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor2','label'])
+ i = TkcPolygon.new(w,234,276,297,276,297,327,257,327,257,338,234,338,
+ 'fill'=>'', 'tags'=>['floor2','room'])
+ $floorLabels[i.id] = '205'
+ $floorItems['205'] = i
+ TkcText.new(w,265.5,307, 'text'=>'205', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor2','label'])
+ i = TkcPolygon.new(w,256,385,256,340,212,340,212,385,
+ 'fill'=>'', 'tags'=>['floor2','room'])
+ $floorLabels[i.id] = '207'
+ $floorItems['207'] = i
+ TkcText.new(w,234,362.5, 'text'=>'207', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor2','label'])
+ i = TkcPolygon.new(w,210,340,164,340,164,385,210,385,
+ 'fill'=>'', 'tags'=>['floor2','room'])
+ $floorLabels[i.id] = '208'
+ $floorItems['208'] = i
+ TkcText.new(w,187,362.5, 'text'=>'208', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor2','label'])
+ i = TkcPolygon.new(w,115,340,162,340,162,385,115,385,
+ 'fill'=>'', 'tags'=>['floor2','room'])
+ $floorLabels[i.id] = '209'
+ $floorItems['209'] = i
+ TkcText.new(w,138.5,362.5, 'text'=>'209', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor2','label'])
+ i = TkcPolygon.new(w,89,228,89,156,53,156,53,228,
+ 'fill'=>'', 'tags'=>['floor2','room'])
+ $floorLabels[i.id] = '217'
+ $floorItems['217'] = i
+ TkcText.new(w,71,192, 'text'=>'217', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor2','label'])
+ i = TkcPolygon.new(w,89,169,97,169,97,190,89,190,
+ 'fill'=>'', 'tags'=>['floor2','room'])
+ $floorLabels[i.id] = '217A'
+ $floorItems['217A'] = i
+ TkcText.new(w,93,179.5, 'text'=>'217A', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor2','label'])
+ i = TkcPolygon.new(w,89,156,89,168,95,168,95,135,53,135,53,156,
+ 'fill'=>'', 'tags'=>['floor2','room'])
+ $floorLabels[i.id] = '216'
+ $floorItems['216'] = i
+ TkcText.new(w,71,145.5, 'text'=>'216', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor2','label'])
+ i = TkcPolygon.new(w,51,179,51,135,6,135,6,179,
+ 'fill'=>'', 'tags'=>['floor2','room'])
+ $floorLabels[i.id] = '215'
+ $floorItems['215'] = i
+ TkcText.new(w,28.5,157, 'text'=>'215', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor2','label'])
+ i = TkcPolygon.new(w,51,227,6,227,6,180,51,180,
+ 'fill'=>'', 'tags'=>['floor2','room'])
+ $floorLabels[i.id] = '214'
+ $floorItems['214'] = i
+ TkcText.new(w,28.5,203.5, 'text'=>'214', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor2','label'])
+ i = TkcPolygon.new(w,51,275,6,275,6,229,51,229,
+ 'fill'=>'', 'tags'=>['floor2','room'])
+ $floorLabels[i.id] = '213'
+ $floorItems['213'] = i
+ TkcText.new(w,28.5,252, 'text'=>'213', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor2','label'])
+ i = TkcPolygon.new(w,114,340,67,340,67,385,114,385,
+ 'fill'=>'', 'tags'=>['floor2','room'])
+ $floorLabels[i.id] = '210'
+ $floorItems['210'] = i
+ TkcText.new(w,90.5,362.5, 'text'=>'210', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor2','label'])
+ i = TkcPolygon.new(w,59,389,59,385,65,385,65,340,1,340,1,389,
+ 'fill'=>'', 'tags'=>['floor2','room'])
+ $floorLabels[i.id] = '211'
+ $floorItems['211'] = i
+ TkcText.new(w,33,364.5, 'text'=>'211', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor2','label'])
+ i = TkcPolygon.new(w,393,309,350,309,350,282,342,282,342,276,393,276,
+ 'fill'=>'', 'tags'=>['floor2','room'])
+ $floorLabels[i.id] = '203'
+ $floorItems['203'] = i
+ TkcText.new(w,367.5,292.5, 'text'=>'203', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor2','label'])
+ i = TkcPolygon.new(w,99,191,91,191,91,226,174,226,174,198,
+ 154,198,154,192,109,192,109,169,99,169,
+ 'fill'=>'', 'tags'=>['floor2','room'])
+ $floorLabels[i.id] = '220'
+ $floorItems['220'] = i
+ TkcText.new(w,132.5,208.5, 'text'=>'220', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor2','label'])
+ i = TkcPolygon.new(w,339,205,307,205,307,171,339,171,
+ 'fill'=>'', 'tags'=>['floor2','room'])
+ $floorLabels[i.id] = 'Priv Lift2'
+ $floorItems['Priv Lift2'] = i
+ TkcText.new(w,323,188, 'text'=>'Priv Lift2', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor2','label'])
+ i = TkcPolygon.new(w,307,240,339,240,339,206,307,206,
+ 'fill'=>'', 'tags'=>['floor2','room'])
+ $floorLabels[i.id] = 'Pub Lift 2'
+ $floorItems['Pub Lift 2'] = i
+ TkcText.new(w,323,223, 'text'=>'Pub Lift 2', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor2','label'])
+ i = TkcPolygon.new(w,175,168,97,168,97,131,175,131,
+ 'fill'=>'', 'tags'=>['floor2','room'])
+ $floorLabels[i.id] = '218'
+ $floorItems['218'] = i
+ TkcText.new(w,136,149.5, 'text'=>'218', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor2','label'])
+ i = TkcPolygon.new(w,154,191,111,191,111,169,154,169,
+ 'fill'=>'', 'tags'=>['floor2','room'])
+ $floorLabels[i.id] = '219'
+ $floorItems['219'] = i
+ TkcText.new(w,132.5,180, 'text'=>'219', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor2','label'])
+ i = TkcPolygon.new(w,375,246,375,172,341,172,341,246,
+ 'fill'=>'', 'tags'=>['floor2','room'])
+ $floorLabels[i.id] = '201'
+ $floorItems['201'] = i
+ TkcText.new(w,358,209, 'text'=>'201', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor2','label'])
+ TkcLine.new(w,641,186,678,186, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,757,350,757,367, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,634,133,634,144, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,634,144,627,144, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,572,133,572,144, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,572,144,579,144, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,398,129,398,162, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,174,197,175,197, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,175,197,175,227, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,757,206,757,221, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,396,188,408,188, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,727,189,725,189, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,747,167,802,167, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,747,167,747,189, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,755,189,739,189, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,769,224,757,224, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,802,224,802,129, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,802,129,725,129, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,725,189,725,129, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,725,186,690,186, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,676,133,676,186, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,627,144,627,186, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,629,186,593,186, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,579,144,579,186, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,559,129,559,133, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,725,133,559,133, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,484,162,484,129, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,559,129,484,129, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,526,129,526,186, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,540,186,581,186, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,528,186,523,186, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,511,186,475,186, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,496,190,496,186, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,496,205,496,202, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,475,205,527,205, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,558,205,539,205, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,558,205,558,249, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,558,249,475,249, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,662,206,642,206, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,695,206,675,206, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,695,278,642,278, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,642,291,642,206, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,695,291,695,206, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,716,208,716,206, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,757,206,716,206, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,757,221,757,224, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,793,224,802,224, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,757,262,716,262, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,716,220,716,264, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,716,315,716,276, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,757,315,703,315, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,757,325,757,224, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,757,367,644,367, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,689,367,689,315, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,647,315,644,315, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,659,315,691,315, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,600,325,600,391, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,627,325,644,325, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,644,391,644,315, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,615,325,575,325, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,644,391,558,391, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,563,325,558,325, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,558,391,558,314, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,558,327,508,327, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,558,275,484,275, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,558,302,558,275, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,508,327,508,311, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,484,311,508,311, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,484,275,484,311, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,475,208,408,208, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,408,206,408,210, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,408,222,408,227, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,408,227,398,227, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,398,227,398,254, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,408,188,408,194, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,383,188,376,188, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,398,188,398,162, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,398,162,484,162, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,475,162,475,254, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,398,254,475,254, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,484,280,395,280, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,395,311,395,275, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,307,197,293,197, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,278,197,233,197, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,233,197,233,249, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,307,179,284,179, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,233,249,278,249, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,269,179,269,133, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,220,179,220,133, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,155,191,110,191, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,90,190,98,190, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,98,169,98,190, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,52,133,52,165, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,52,214,52,177, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,52,226,52,262, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,52,274,52,276, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,234,275,234,339, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,226,339,258,339, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,211,387,211,339, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,214,339,177,339, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,258,387,60,387, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,3,133,3,339, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,165,339,129,339, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,117,339,80,339, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,68,339,59,339, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,0,339,46,339, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,60,391,0,391, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,0,339,0,391, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,60,387,60,391, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,258,329,258,387, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,350,329,258,329, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,395,311,350,311, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,398,129,315,129, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,176,133,315,133, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,176,129,96,129, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,3,133,96,133, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,66,387,66,339, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,115,387,115,339, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,163,387,163,339, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,234,275,276,275, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,288,275,309,275, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,298,275,298,329, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,341,283,350,283, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,321,275,341,275, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,375,275,395,275, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,315,129,315,170, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,376,170,307,170, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,307,250,307,170, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,376,245,376,170, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,340,241,307,241, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,340,245,340,224, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,340,210,340,201, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,340,187,340,170, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,340,206,307,206, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,293,250,307,250, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,271,179,238,179, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,226,179,195,179, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,176,129,176,179, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,182,179,176,179, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,174,169,176,169, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,162,169,90,169, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,96,169,96,129, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,175,227,90,227, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,90,190,90,227, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,52,179,3,179, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,52,228,3,228, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,52,276,3,276, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,155,177,155,169, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,110,191,110,169, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,155,189,155,197, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,350,283,350,329, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,162,197,155,197, 'fill'=>color, 'tags'=>['floor2','wall'])
+ TkcLine.new(w,341,275,341,283, 'fill'=>color, 'tags'=>['floor2','wall'])
+end
+
+# floor_fg3 --
+# This method represents part of the floorplan database. When
+# invoked, it instantiates the foreground information for the third
+# floor (office outlines and numbers).
+#
+# Arguments:
+# w - The canvas window.
+# color - Color to use for drawing foreground information.
+
+def floor_fg3(w,color)
+ i = TkcPolygon.new(w,89,228,89,180,70,180,70,228,
+ 'fill'=>'', 'tags'=>['floor3','room'])
+ $floorLabels[i.id] = '316'
+ $floorItems['316'] = i
+ TkcText.new(w,79.5,204, 'text'=>'316', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor3','label'])
+ i = TkcPolygon.new(w,115,368,162,368,162,323,115,323,
+ 'fill'=>'', 'tags'=>['floor3','room'])
+ $floorLabels[i.id] = '309'
+ $floorItems['309'] = i
+ TkcText.new(w,138.5,345.5, 'text'=>'309', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor3','label'])
+ i = TkcPolygon.new(w,164,323,164,368,211,368,211,323,
+ 'fill'=>'', 'tags'=>['floor3','room'])
+ $floorLabels[i.id] = '308'
+ $floorItems['308'] = i
+ TkcText.new(w,187.5,345.5, 'text'=>'308', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor3','label'])
+ i = TkcPolygon.new(w,256,368,212,368,212,323,256,323,
+ 'fill'=>'', 'tags'=>['floor3','room'])
+ $floorLabels[i.id] = '307'
+ $floorItems['307'] = i
+ TkcText.new(w,234,345.5, 'text'=>'307', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor3','label'])
+ i = TkcPolygon.new(w,244,276,297,276,297,327,260,327,260,321,244,321,
+ 'fill'=>'', 'tags'=>['floor3','room'])
+ $floorLabels[i.id] = '305'
+ $floorItems['305'] = i
+ TkcText.new(w,270.5,301.5, 'text'=>'305', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor3','label'])
+ i = TkcPolygon.new(w,251,219,251,203,244,203,244,219,
+ 'fill'=>'', 'tags'=>['floor3','room'])
+ $floorLabels[i.id] = '324B'
+ $floorItems['324B'] = i
+ TkcText.new(w,247.5,211, 'text'=>'324B', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor3','label'])
+ i = TkcPolygon.new(w,251,249,244,249,244,232,251,232,
+ 'fill'=>'', 'tags'=>['floor3','room'])
+ $floorLabels[i.id] = '324A'
+ $floorItems['324A'] = i
+ TkcText.new(w,247.5,240.5, 'text'=>'324A', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor3','label'])
+ i = TkcPolygon.new(w,223,135,223,179,177,179,177,135,
+ 'fill'=>'', 'tags'=>['floor3','room'])
+ $floorLabels[i.id] = '320'
+ $floorItems['320'] = i
+ TkcText.new(w,200,157, 'text'=>'320', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor3','label'])
+ i = TkcPolygon.new(w,114,368,114,323,67,323,67,368,
+ 'fill'=>'', 'tags'=>['floor3','room'])
+ $floorLabels[i.id] = '310'
+ $floorItems['310'] = i
+ TkcText.new(w,90.5,345.5, 'text'=>'310', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor3','label'])
+ i = TkcPolygon.new(w,23,277,23,321,68,321,68,277,
+ 'fill'=>'', 'tags'=>['floor3','room'])
+ $floorLabels[i.id] = '312'
+ $floorItems['312'] = i
+ TkcText.new(w,45.5,299, 'text'=>'312', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor3','label'])
+ i = TkcPolygon.new(w,23,229,68,229,68,275,23,275,
+ 'fill'=>'', 'tags'=>['floor3','room'])
+ $floorLabels[i.id] = '313'
+ $floorItems['313'] = i
+ TkcText.new(w,45.5,252, 'text'=>'313', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor3','label'])
+ i = TkcPolygon.new(w,68,227,23,227,23,180,68,180,
+ 'fill'=>'', 'tags'=>['floor3','room'])
+ $floorLabels[i.id] = '314'
+ $floorItems['314'] = i
+ TkcText.new(w,40.5,203.5, 'text'=>'314', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor3','label'])
+ i = TkcPolygon.new(w,95,179,95,135,23,135,23,179,
+ 'fill'=>'', 'tags'=>['floor3','room'])
+ $floorLabels[i.id] = '315'
+ $floorItems['315'] = i
+ TkcText.new(w,59,157, 'text'=>'315', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor3','label'])
+ i = TkcPolygon.new(w,99,226,99,204,91,204,91,226,
+ 'fill'=>'', 'tags'=>['floor3','room'])
+ $floorLabels[i.id] = '316B'
+ $floorItems['316B'] = i
+ TkcText.new(w,95,215, 'text'=>'316B', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor3','label'])
+ i = TkcPolygon.new(w,91,202,99,202,99,180,91,180,
+ 'fill'=>'', 'tags'=>['floor3','room'])
+ $floorLabels[i.id] = '316A'
+ $floorItems['316A'] = i
+ TkcText.new(w,95,191, 'text'=>'316A', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor3','label'])
+ i = TkcPolygon.new(w,97,169,109,169,109,192,154,192,154,198,
+ 174,198,174,226,101,226,101,179,97,179,
+ 'fill'=>'', 'tags'=>['floor3','room'])
+ $floorLabels[i.id] = '319'
+ $floorItems['319'] = i
+ TkcText.new(w,141.5,209, 'text'=>'319', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor3','label'])
+ i = TkcPolygon.new(w,65,368,58,368,58,389,1,389,1,333,23,333,23,323,65,323,
+ 'fill'=>'', 'tags'=>['floor3','room'])
+ $floorLabels[i.id] = '311'
+ $floorItems['311'] = i
+ TkcText.new(w,29.5,361, 'text'=>'311', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor3','label'])
+ i = TkcPolygon.new(w,154,191,111,191,111,169,154,169,
+ 'fill'=>'', 'tags'=>['floor3','room'])
+ $floorLabels[i.id] = '318'
+ $floorItems['318'] = i
+ TkcText.new(w,132.5,180, 'text'=>'318', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor3','label'])
+ i = TkcPolygon.new(w,175,168,97,168,97,131,175,131,
+ 'fill'=>'', 'tags'=>['floor3','room'])
+ $floorLabels[i.id] = '317'
+ $floorItems['317'] = i
+ TkcText.new(w,136,149.5, 'text'=>'317', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor3','label'])
+ i = TkcPolygon.new(w,274,194,274,221,306,221,306,194,
+ 'fill'=>'', 'tags'=>['floor3','room'])
+ $floorLabels[i.id] = '323'
+ $floorItems['323'] = i
+ TkcText.new(w,290,207.5, 'text'=>'323', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor3','label'])
+ i = TkcPolygon.new(w,306,222,274,222,274,249,306,249,
+ 'fill'=>'', 'tags'=>['floor3','room'])
+ $floorLabels[i.id] = '325'
+ $floorItems['325'] = i
+ TkcText.new(w,290,235.5, 'text'=>'325', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor3','label'])
+ i = TkcPolygon.new(w,263,179,224,179,224,135,263,135,
+ 'fill'=>'', 'tags'=>['floor3','room'])
+ $floorLabels[i.id] = '321'
+ $floorItems['321'] = i
+ TkcText.new(w,243.5,157, 'text'=>'321', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor3','label'])
+ i = TkcPolygon.new(w,314,169,306,169,306,192,273,192,
+ 264,181,264,135,314,135,
+ 'fill'=>'', 'tags'=>['floor3','room'])
+ $floorLabels[i.id] = '322'
+ $floorItems['322'] = i
+ TkcText.new(w,293.5,163.5, 'text'=>'322', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor3','label'])
+ i = TkcPolygon.new(w,307,240,339,240,339,206,307,206,
+ 'fill'=>'', 'tags'=>['floor3','room'])
+ $floorLabels[i.id] = 'Pub Lift3'
+ $floorItems['Pub Lift3'] = i
+ TkcText.new(w,323,223, 'text'=>'Pub Lift3', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor3','label'])
+ i = TkcPolygon.new(w,339,205,307,205,307,171,339,171,
+ 'fill'=>'', 'tags'=>['floor3','room'])
+ $floorLabels[i.id] = 'Priv Lift3'
+ $floorItems['Priv Lift3'] = i
+ TkcText.new(w,323,188, 'text'=>'Priv Lift3', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor3','label'])
+ i = TkcPolygon.new(w,350,284,376,284,376,276,397,276,397,309,350,309,
+ 'fill'=>'', 'tags'=>['floor3','room'])
+ $floorLabels[i.id] = '303'
+ $floorItems['303'] = i
+ TkcText.new(w,373.5,292.5, 'text'=>'303', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor3','label'])
+ i = TkcPolygon.new(w,272,203,272,249,252,249,252,230,
+ 244,230,244,221,252,221,252,203,
+ 'fill'=>'', 'tags'=>['floor3','room'])
+ $floorLabels[i.id] = '324'
+ $floorItems['324'] = i
+ TkcText.new(w,262,226, 'text'=>'324', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor3','label'])
+ i = TkcPolygon.new(w,299,276,299,327,349,327,349,284,341,284,341,276,
+ 'fill'=>'', 'tags'=>['floor3','room'])
+ $floorLabels[i.id] = '304'
+ $floorItems['304'] = i
+ TkcText.new(w,324,301.5, 'text'=>'304', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor3','label'])
+ i = TkcPolygon.new(w,375,246,375,172,341,172,341,246,
+ 'fill'=>'', 'tags'=>['floor3','room'])
+ $floorLabels[i.id] = '301'
+ $floorItems['301'] = i
+ TkcText.new(w,358,209, 'text'=>'301', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor3','label'])
+ i = TkcPolygon.new(w,397,246,377,246,377,185,397,185,
+ 'fill'=>'', 'tags'=>['floor3','room'])
+ $floorLabels[i.id] = '327'
+ $floorItems['327'] = i
+ TkcText.new(w,387,215.5, 'text'=>'327', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor3','label'])
+ i = TkcPolygon.new(w,316,131,316,169,377,169,377,185,397,185,397,131,
+ 'fill'=>'', 'tags'=>['floor3','room'])
+ $floorLabels[i.id] = '326'
+ $floorItems['326'] = i
+ TkcText.new(w,365.5,150, 'text'=>'326', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor3','label'])
+ i = TkcPolygon.new(w,308,251,242,251,242,274,342,274,342,282,375, 282,
+ 375,274,397,274,397,248,339,248,339,242,308,242,
+ 'fill'=>'', 'tags'=>['floor3','room'])
+ $floorLabels[i.id] = '302'
+ $floorItems['302'] = i
+ TkcText.new(w,319.5,261, 'text'=>'302', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor3','label'])
+ i = TkcPolygon.new(w,70,321,242,321,242,200,259,200,259,203,272,203,
+ 272,193,263,180,242,180,175,180,175,169,156,169,
+ 156,196,177,196,177,228,107,228,70,228,70,275,107,275,
+ 107,248,160,248,160,301,107,301,107,275,70,275,
+ 'fill'=>'', 'tags'=>['floor3','room'])
+ $floorLabels[i.id] = '306'
+ $floorItems['306'] = i
+ TkcText.new(w,200.5,284.5, 'text'=>'306', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor3','label'])
+ TkcLine.new(w,341,275,341,283, 'fill'=>color, 'tags'=>['floor3','wall'])
+ TkcLine.new(w,162,197,155,197, 'fill'=>color, 'tags'=>['floor3','wall'])
+ TkcLine.new(w,396,247,399,247, 'fill'=>color, 'tags'=>['floor3','wall'])
+ TkcLine.new(w,399,129,399,311, 'fill'=>color, 'tags'=>['floor3','wall'])
+ TkcLine.new(w,258,202,243,202, 'fill'=>color, 'tags'=>['floor3','wall'])
+ TkcLine.new(w,350,283,350,329, 'fill'=>color, 'tags'=>['floor3','wall'])
+ TkcLine.new(w,251,231,243,231, 'fill'=>color, 'tags'=>['floor3','wall'])
+ TkcLine.new(w,243,220,251,220, 'fill'=>color, 'tags'=>['floor3','wall'])
+ TkcLine.new(w,243,250,243,202, 'fill'=>color, 'tags'=>['floor3','wall'])
+ TkcLine.new(w,155,197,155,190, 'fill'=>color, 'tags'=>['floor3','wall'])
+ TkcLine.new(w,110,192,110,169, 'fill'=>color, 'tags'=>['floor3','wall'])
+ TkcLine.new(w,155,192,110,192, 'fill'=>color, 'tags'=>['floor3','wall'])
+ TkcLine.new(w,155,177,155,169, 'fill'=>color, 'tags'=>['floor3','wall'])
+ TkcLine.new(w,176,197,176,227, 'fill'=>color, 'tags'=>['floor3','wall'])
+ TkcLine.new(w,69,280,69,274, 'fill'=>color, 'tags'=>['floor3','wall'])
+ TkcLine.new(w,21,276,69,276, 'fill'=>color, 'tags'=>['floor3','wall'])
+ TkcLine.new(w,69,262,69,226, 'fill'=>color, 'tags'=>['floor3','wall'])
+ TkcLine.new(w,21,228,69,228, 'fill'=>color, 'tags'=>['floor3','wall'])
+ TkcLine.new(w,21,179,75,179, 'fill'=>color, 'tags'=>['floor3','wall'])
+ TkcLine.new(w,69,179,69,214, 'fill'=>color, 'tags'=>['floor3','wall'])
+ TkcLine.new(w,90,220,90,227, 'fill'=>color, 'tags'=>['floor3','wall'])
+ TkcLine.new(w,90,204,90,202, 'fill'=>color, 'tags'=>['floor3','wall'])
+ TkcLine.new(w,90,203,100,203, 'fill'=>color, 'tags'=>['floor3','wall'])
+ TkcLine.new(w,90,187,90,179, 'fill'=>color, 'tags'=>['floor3','wall'])
+ TkcLine.new(w,90,227,176,227, 'fill'=>color, 'tags'=>['floor3','wall'])
+ TkcLine.new(w,100,179,100,227, 'fill'=>color, 'tags'=>['floor3','wall'])
+ TkcLine.new(w,100,179,87,179, 'fill'=>color, 'tags'=>['floor3','wall'])
+ TkcLine.new(w,96,179,96,129, 'fill'=>color, 'tags'=>['floor3','wall'])
+ TkcLine.new(w,162,169,96,169, 'fill'=>color, 'tags'=>['floor3','wall'])
+ TkcLine.new(w,173,169,176,169, 'fill'=>color, 'tags'=>['floor3','wall'])
+ TkcLine.new(w,182,179,176,179, 'fill'=>color, 'tags'=>['floor3','wall'])
+ TkcLine.new(w,176,129,176,179, 'fill'=>color, 'tags'=>['floor3','wall'])
+ TkcLine.new(w,195,179,226,179, 'fill'=>color, 'tags'=>['floor3','wall'])
+ TkcLine.new(w,224,133,224,179, 'fill'=>color, 'tags'=>['floor3','wall'])
+ TkcLine.new(w,264,179,264,133, 'fill'=>color, 'tags'=>['floor3','wall'])
+ TkcLine.new(w,238,179,264,179, 'fill'=>color, 'tags'=>['floor3','wall'])
+ TkcLine.new(w,273,207,273,193, 'fill'=>color, 'tags'=>['floor3','wall'])
+ TkcLine.new(w,273,235,273,250, 'fill'=>color, 'tags'=>['floor3','wall'])
+ TkcLine.new(w,273,224,273,219, 'fill'=>color, 'tags'=>['floor3','wall'])
+ TkcLine.new(w,273,193,307,193, 'fill'=>color, 'tags'=>['floor3','wall'])
+ TkcLine.new(w,273,222,307,222, 'fill'=>color, 'tags'=>['floor3','wall'])
+ TkcLine.new(w,273,250,307,250, 'fill'=>color, 'tags'=>['floor3','wall'])
+ TkcLine.new(w,384,247,376,247, 'fill'=>color, 'tags'=>['floor3','wall'])
+ TkcLine.new(w,340,206,307,206, 'fill'=>color, 'tags'=>['floor3','wall'])
+ TkcLine.new(w,340,187,340,170, 'fill'=>color, 'tags'=>['floor3','wall'])
+ TkcLine.new(w,340,210,340,201, 'fill'=>color, 'tags'=>['floor3','wall'])
+ TkcLine.new(w,340,247,340,224, 'fill'=>color, 'tags'=>['floor3','wall'])
+ TkcLine.new(w,340,241,307,241, 'fill'=>color, 'tags'=>['floor3','wall'])
+ TkcLine.new(w,376,247,376,170, 'fill'=>color, 'tags'=>['floor3','wall'])
+ TkcLine.new(w,307,250,307,170, 'fill'=>color, 'tags'=>['floor3','wall'])
+ TkcLine.new(w,376,170,307,170, 'fill'=>color, 'tags'=>['floor3','wall'])
+ TkcLine.new(w,315,129,315,170, 'fill'=>color, 'tags'=>['floor3','wall'])
+ TkcLine.new(w,376,283,366,283, 'fill'=>color, 'tags'=>['floor3','wall'])
+ TkcLine.new(w,376,283,376,275, 'fill'=>color, 'tags'=>['floor3','wall'])
+ TkcLine.new(w,399,275,376,275, 'fill'=>color, 'tags'=>['floor3','wall'])
+ TkcLine.new(w,341,275,320,275, 'fill'=>color, 'tags'=>['floor3','wall'])
+ TkcLine.new(w,341,283,350,283, 'fill'=>color, 'tags'=>['floor3','wall'])
+ TkcLine.new(w,298,275,298,329, 'fill'=>color, 'tags'=>['floor3','wall'])
+ TkcLine.new(w,308,275,298,275, 'fill'=>color, 'tags'=>['floor3','wall'])
+ TkcLine.new(w,243,322,243,275, 'fill'=>color, 'tags'=>['floor3','wall'])
+ TkcLine.new(w,243,275,284,275, 'fill'=>color, 'tags'=>['floor3','wall'])
+ TkcLine.new(w,258,322,226,322, 'fill'=>color, 'tags'=>['floor3','wall'])
+ TkcLine.new(w,212,370,212,322, 'fill'=>color, 'tags'=>['floor3','wall'])
+ TkcLine.new(w,214,322,177,322, 'fill'=>color, 'tags'=>['floor3','wall'])
+ TkcLine.new(w,163,370,163,322, 'fill'=>color, 'tags'=>['floor3','wall'])
+ TkcLine.new(w,165,322,129,322, 'fill'=>color, 'tags'=>['floor3','wall'])
+ TkcLine.new(w,84,322,117,322, 'fill'=>color, 'tags'=>['floor3','wall'])
+ TkcLine.new(w,71,322,64,322, 'fill'=>color, 'tags'=>['floor3','wall'])
+ TkcLine.new(w,115,322,115,370, 'fill'=>color, 'tags'=>['floor3','wall'])
+ TkcLine.new(w,66,322,66,370, 'fill'=>color, 'tags'=>['floor3','wall'])
+ TkcLine.new(w,52,322,21,322, 'fill'=>color, 'tags'=>['floor3','wall'])
+ TkcLine.new(w,21,331,0,331, 'fill'=>color, 'tags'=>['floor3','wall'])
+ TkcLine.new(w,21,331,21,133, 'fill'=>color, 'tags'=>['floor3','wall'])
+ TkcLine.new(w,96,133,21,133, 'fill'=>color, 'tags'=>['floor3','wall'])
+ TkcLine.new(w,176,129,96,129, 'fill'=>color, 'tags'=>['floor3','wall'])
+ TkcLine.new(w,315,133,176,133, 'fill'=>color, 'tags'=>['floor3','wall'])
+ TkcLine.new(w,315,129,399,129, 'fill'=>color, 'tags'=>['floor3','wall'])
+ TkcLine.new(w,399,311,350,311, 'fill'=>color, 'tags'=>['floor3','wall'])
+ TkcLine.new(w,350,329,258,329, 'fill'=>color, 'tags'=>['floor3','wall'])
+ TkcLine.new(w,258,322,258,370, 'fill'=>color, 'tags'=>['floor3','wall'])
+ TkcLine.new(w,60,370,258,370, 'fill'=>color, 'tags'=>['floor3','wall'])
+ TkcLine.new(w,60,370,60,391, 'fill'=>color, 'tags'=>['floor3','wall'])
+ TkcLine.new(w,0,391,0,331, 'fill'=>color, 'tags'=>['floor3','wall'])
+ TkcLine.new(w,60,391,0,391, 'fill'=>color, 'tags'=>['floor3','wall'])
+ TkcLine.new(w,307,250,307,242, 'fill'=>color, 'tags'=>['floor3','wall'])
+ TkcLine.new(w,273,250,307,250, 'fill'=>color, 'tags'=>['floor3','wall'])
+ TkcLine.new(w,258,250,243,250, 'fill'=>color, 'tags'=>['floor3','wall'])
+end
+
+# Below is the "main program" that creates the floorplan demonstration.
+
+# toplevel widget ãŒå­˜åœ¨ã™ã‚Œã°å‰Šé™¤ã™ã‚‹
+if defined?($floor_demo) && $floor_demo
+ $floor_demo.destroy
+ $floor_demo = nil
+end
+
+# demo 用㮠toplevel widget を生æˆ
+$floor_demo = TkToplevel.new {|w|
+ title("Floorplan Canvas Demonstration")
+ iconname("Floorplan")
+ positionWindow(w)
+ geometry('+20+20')
+ minsize(100,100)
+}
+
+base_frame = TkFrame.new($floor_demo).pack(:fill=>:both, :expand=>true)
+
+# label 生æˆ
+TkLabel.new(base_frame, 'font'=>$font, 'wraplength'=>'8i', 'justify'=>'left',
+ 'text'=>"ã“ã®ã‚¦ã‚£ãƒ³ãƒ‰ã‚¦ã«ã¯ãƒ‡ã‚£ã‚¸ã‚¿ãƒ«ã‚¨ã‚¯ã‚¤ãƒƒãƒ—メント社ã®ã‚¦ã‚§ã‚¹ã‚¿ãƒ³ãƒªã‚µãƒ¼ãƒãƒ©ãƒœãƒ©ãƒˆãƒª (DECWRL) ã®é–“å–ã‚ŠãŒæ›¸ã‹ã‚ŒãŸã‚­ãƒ£ãƒ³ãƒã‚¹ widget ãŒå…¥ã£ã¦ã„ã¾ã™ã€‚ã“れ㯠3階建ã¦ã§ã€å¸¸ã«ãã®ã†ã¡ã®1階分ãŒé¸æŠžã€ã¤ã¾ã‚Šãã®é–“å–ã‚ŠãŒè¡¨ç¤ºã•ã‚Œã‚‹ã‚ˆã†ã«ãªã£ã¦ã„ã¾ã™ã€‚ã‚る階をé¸æŠžã™ã‚‹ã«ã¯ã€ãã®ä¸Šã§ãƒžã‚¦ã‚¹ã®å·¦ãƒœã‚¿ãƒ³ã‚’クリックã—ã¦ãã ã•ã„。マウスãŒé¸æŠžã•ã‚Œã¦ã„る階ã®ä¸Šã‚’å‹•ãã¨ã€ãã®ä¸‹ã«ã‚る部屋ã®è‰²ãŒå¤‰ã‚ã‚Šã€éƒ¨å±‹ç•ªå·ãŒã€Œéƒ¨å±‹ç•ªå·:ã€ã‚¨ãƒ³ãƒˆãƒªã«è¡¨ç¤ºã•ã‚Œã¾ã™ã€‚ã¾ãŸã€ã‚¨ãƒ³ãƒˆãƒªã«éƒ¨å±‹ç•ªå·ã‚’書ãã¨ãã®éƒ¨å±‹ã®è‰²ãŒå¤‰ã‚ã‚Šã¾ã™ã€‚"){
+ pack('side'=>'top')
+}
+
+# frame 生æˆ
+$floor_buttons = TkFrame.new(base_frame) {|frame|
+ TkButton.new(frame) {
+ #text '了解'
+ text 'é–‰ã˜ã‚‹'
+ command proc{
+ tmppath = $floor_demo
+ $floor_demo = nil
+ tmppath.destroy
+ }
+ }.pack('side'=>'left', 'expand'=>'yes')
+
+ TkButton.new(frame) {
+ text 'コードå‚ç…§'
+ command proc{showCode 'floor'}
+ }.pack('side'=>'left', 'expand'=>'yes')
+}
+$floor_buttons.pack('side'=>'bottom', 'fill'=>'x', 'pady'=>'2m')
+
+# 変数設定
+$floorLabels = {}
+$floorItems = {}
+
+# canvas 設定
+if $tk_version =~ /^4\.[01]/
+ $floor_canvas_frame = TkFrame.new(base_frame,'bd'=>2,'relief'=>'sunken',
+ 'highlightthickness'=>2)
+ $floor_canvas = TkCanvas.new($floor_canvas_frame,
+ 'width'=>900, 'height'=>500, 'borderwidth'=>0,
+ 'highlightthickness'=>0) {|c|
+ TkScrollbar.new(base_frame, 'orient'=>'horiz',
+ 'command'=>proc{|*args| c.xview(*args)}){|hs|
+ c.xscrollcommand(proc{|first,last| hs.set first,last})
+ pack('side'=>'bottom', 'fill'=>'x')
+ }
+ TkScrollbar.new(base_frame, 'command'=>proc{|*args| c.yview(*args)}){|vs|
+ c.yscrollcommand(proc{|first,last| vs.set first,last})
+ pack('side'=>'right', 'fill'=>'y')
+ }
+ }
+ $floor_canvas_frame.pack('side'=>'top','fill'=>'both', 'expand'=>'yes')
+ $floor_canvas.pack('expand'=>'yes', 'fill'=>'both')
+
+else
+ TkFrame.new(base_frame) {|f|
+ pack('side'=>'top', 'fill'=>'both', 'expand'=>'yes')
+
+ h = TkScrollbar.new(f, 'highlightthickness'=>0, 'orient'=>'horizontal')
+ v = TkScrollbar.new(f, 'highlightthickness'=>0, 'orient'=>'vertical')
+
+ TkFrame.new(f, 'bd'=>2, 'relief'=>'sunken') {|f1|
+ $floor_canvas = TkCanvas.new(f1, 'width'=>900, 'height'=>500,
+ 'borderwidth'=>0,
+ 'highlightthickness'=>0) {
+ xscrollcommand(proc{|first,last| h.set first,last})
+ yscrollcommand(proc{|first,last| v.set first,last})
+ pack('expand'=>'yes', 'fill'=>'both')
+ }
+ grid('padx'=>1, 'pady'=>1, 'row'=>0, 'column'=>0,
+ 'rowspan'=>1, 'columnspan'=>1, 'sticky'=>'news')
+ }
+
+ v.grid('padx'=>1, 'pady'=>1, 'row'=>0, 'column'=>1,
+ 'rowspan'=>1, 'columnspan'=>1, 'sticky'=>'news')
+ h.grid('padx'=>1, 'pady'=>1, 'row'=>1, 'column'=>0,
+ 'rowspan'=>1, 'columnspan'=>1, 'sticky'=>'news')
+
+ TkGrid.rowconfigure(f, 0, 'weight'=>1, 'minsize'=>0)
+ TkGrid.columnconfigure(f, 0, 'weight'=>1, 'minsize'=>0)
+
+ pack('expand'=>'yes', 'fill'=>'both', 'padx'=>1, 'pady'=>1)
+
+ v.command(proc{|*args| $floor_canvas.yview(*args)})
+ h.command(proc{|*args| $floor_canvas.xview(*args)})
+ }
+end
+
+
+# Create an entry for displaying and typing in current room.
+
+$currentRoom = TkVariable.new
+$floor_entry = TkEntry.new($floor_canvas, 'width'=>10, 'relief'=>'sunken',
+ 'bd'=>2, 'textvariable'=>$currentRoom)
+
+# Choose colors, then fill in the floorplan.
+
+$floor_colors = {}
+if TkWinfo.depth($floor_canvas) > 1
+ $floor_colors['bg1'] = '#a9c1da'
+ $floor_colors['outline1'] = '#77889a'
+ $floor_colors['bg2'] = '#9ab0c6'
+ $floor_colors['outline2'] = '#687786'
+ $floor_colors['bg3'] = '#8ba0b3'
+ $floor_colors['outline3'] = '#596673'
+ $floor_colors['offices'] = 'Black'
+ $floor_colors['active'] = '#c4d1df'
+else
+ $floor_colors['bg1'] = 'white'
+ $floor_colors['outline1'] = 'black'
+ $floor_colors['bg2'] = 'white'
+ $floor_colors['outline2'] = 'black'
+ $floor_colors['bg3'] = 'white'
+ $floor_colors['outline3'] = 'black'
+ $floor_colors['offices'] = 'Black'
+ $floor_colors['active'] = 'black'
+end
+
+$activeFloor = ''
+floorDisplay $floor_canvas,3
+
+# Set up event bindings for canvas:
+
+$floor_canvas.itembind('floor1', '1', proc{floorDisplay $floor_canvas,1})
+$floor_canvas.itembind('floor2', '1', proc{floorDisplay $floor_canvas,2})
+$floor_canvas.itembind('floor3', '1', proc{floorDisplay $floor_canvas,3})
+$floor_canvas.itembind('room', 'Enter', proc{newRoom $floor_canvas})
+$floor_canvas.itembind('room', 'Leave', proc{$currentRoom.value = ''})
+$floor_canvas.bind('2', proc{|x,y| $floor_canvas.scan_mark x,y}, '%x %y')
+$floor_canvas.bind('B2-Motion',
+ proc{|x,y| $floor_canvas.scan_dragto x,y}, '%x %y')
+$floor_canvas.bind('Destroy', proc{$currentRoom.unset})
+$currentRoom.value = ''
+$currentRoom.trace('w',proc{roomChanged $floor_canvas})
+
diff --git a/jni/ruby/ext/tk/sample/demos-jp/floor2.rb b/jni/ruby/ext/tk/sample/demos-jp/floor2.rb
new file mode 100644
index 0000000..7ca705c
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/demos-jp/floor2.rb
@@ -0,0 +1,1719 @@
+# -*- coding: utf-8 -*-
+#
+# floorDisplay widget demo 2 (called by 'widget')
+#
+
+# floorDisplay2 --
+# Recreate the floorplan display in the canvas given by "w". The
+# floor given by "active" is displayed on top with its office structure
+# visible.
+#
+# Arguments:
+# w - Name of the canvas window.
+# active - Number of active floor (1, 2, or 3).
+
+def floorDisplay2(w,active)
+ return if $activeFloor2 == active
+
+ w.delete('all')
+ $activeFloor2 = active
+
+ # First go through the three floors, displaying the backgrounds for
+ # each floor.
+
+ floor2_bg1(w,$floor2_colors['bg1'],$floor2_colors['outline1'])
+ floor2_bg2(w,$floor2_colors['bg2'],$floor2_colors['outline2'])
+ floor2_bg3(w,$floor2_colors['bg3'],$floor2_colors['outline3'])
+
+ # Raise the background for the active floor so that it's on top.
+
+ w.raise("floor#{active}")
+
+ # Create a dummy item just to mark this point in the display list,
+ # so we can insert highlights here.
+
+ w.create(TkcRectangle,0,100,1,101,'fill'=>'','outline'=>'','tags'=>'marker')
+
+ # Add the walls and labels for the active floor, along with
+ # transparent polygons that define the rooms on the floor.
+ # Make sure that the room polygons are on top.
+
+ $floorLabels2.clear
+ $floorItems2.clear
+ send("floor2_fg#{active}", w, $floor2_colors['offices'])
+ w.raise('room')
+
+ # Offset the floors diagonally from each other.
+
+ w.move('floor1', '2c', '2c')
+ w.move('floor2', '1c', '1c')
+
+ # Create items for the room entry and its label.
+ w.create(TkcWindow, 600, 100, 'anchor'=>'w', 'window'=>$floor2_entry)
+ w.create(TkcText, 600, 100, 'anchor'=>'e', 'text'=>"部屋番å·: ")
+ w['scrollregion'] = w.bbox('all')
+end
+
+# newRoom2 --
+# This method is invoked whenever the mouse enters a room
+# in the floorplan. It changes tags so that the current room is
+# highlighted.
+#
+# Arguments:
+# w - The name of the canvas window.
+
+def newRoom2(w)
+ id = w.find_withtag('current')[0]
+ $currentRoom2.value = $floorLabels2[id.id] if id != ""
+ Tk.update(true)
+end
+
+# roomChanged2 --
+# This method is invoked whenever the currentRoom variable changes.
+# It highlights the current room and unhighlights any previous room.
+#
+# Arguments:
+# w - The canvas window displaying the floorplan.
+# args - Not used.
+
+def roomChanged2(w,*args)
+ w.delete('highlight')
+ item = $floorItems2[$currentRoom2.value]
+ return if item == nil
+ new = TkcPolygon.new(w, *(w.coords(item)))
+ new.configure('fill'=>$floor2_colors['active'], 'tags'=>'highlight')
+ w.raise(new, 'marker')
+end
+
+# floor2_bg1 --
+# This method represents part of the floorplan database. When
+# invoked, it instantiates the background information for the first
+# floor.
+#
+# Arguments:
+# w - The canvas window.
+# fill - Fill color to use for the floor's background.
+# outline - Color to use for the floor's outline.
+
+def floor2_bg1(w,fill,outline)
+ w.create(TkcPolygon,347,80,349,82,351,84,353,85,363,92,375,99,386,104,
+ 386,129,398,129,398,162,484,162,484,129,559,129,559,133,725,
+ 133,725,129,802,129,802,389,644,389,644,391,559,391,559,327,
+ 508,327,508,311,484,311,484,278,395,278,395,288,400,288,404,
+ 288,409,290,413,292,418,297,421,302,422,309,421,318,417,325,
+ 411,330,405,332,397,333,344,333,340,334,336,336,335,338,332,
+ 342,331,347,332,351,334,354,336,357,341,359,340,360,335,363,
+ 331,365,326,366,304,366,304,355,258,355,258,387,60,387,60,391,
+ 0,391,0,337,3,337,3,114,8,114,8,25,30,25,30,5,93,5,98,5,104,7,
+ 110,10,116,16,119,20,122,28,123,32,123,68,220,68,220,34,221,
+ 22,223,17,227,13,231,8,236,4,242,2,246,0,260,0,283,1,300,5,
+ 321,14,335,22,348,25,365,29,363,39,358,48,352,56,337,70,
+ 344,76,347,80, 'tags'=>['floor1','bg'], 'fill'=>fill)
+ w.create(TkcLine,386,129,398,129, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ w.create(TkcLine,258,355,258,387, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ w.create(TkcLine,60,387,60,391, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ w.create(TkcLine,0,337,0,391, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ w.create(TkcLine,60,391,0,391, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ w.create(TkcLine,3,114,3,337, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ w.create(TkcLine,258,387,60,387, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ w.create(TkcLine,484,162,398,162, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ w.create(TkcLine,398,162,398,129, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ w.create(TkcLine,484,278,484,311, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ w.create(TkcLine,484,311,508,311, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ w.create(TkcLine,508,327,508,311, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ w.create(TkcLine,559,327,508,327, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ w.create(TkcLine,644,391,559,391, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ w.create(TkcLine,644,389,644,391, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ w.create(TkcLine,559,129,484,129, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ w.create(TkcLine,484,162,484,129, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ w.create(TkcLine,725,133,559,133, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ w.create(TkcLine,559,129,559,133, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ w.create(TkcLine,725,129,802,129, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ w.create(TkcLine,802,389,802,129, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ w.create(TkcLine,3,337,0,337, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ w.create(TkcLine,559,391,559,327, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ w.create(TkcLine,802,389,644,389, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ w.create(TkcLine,725,133,725,129, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ w.create(TkcLine,8,25,8,114, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ w.create(TkcLine,8,114,3,114, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ w.create(TkcLine,30,25,8,25, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ w.create(TkcLine,484,278,395,278, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ w.create(TkcLine,30,25,30,5, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ w.create(TkcLine,93,5,30,5, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ w.create(TkcLine,98,5,93,5, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ w.create(TkcLine,104,7,98,5, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ w.create(TkcLine,110,10,104,7, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ w.create(TkcLine,116,16,110,10, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ w.create(TkcLine,119,20,116,16, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ w.create(TkcLine,122,28,119,20, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ w.create(TkcLine,123,32,122,28, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ w.create(TkcLine,123,68,123,32, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ w.create(TkcLine,220,68,123,68, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ w.create(TkcLine,386,129,386,104, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ w.create(TkcLine,386,104,375,99, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ w.create(TkcLine,375,99,363,92, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ w.create(TkcLine,353,85,363,92, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ w.create(TkcLine,220,68,220,34, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ w.create(TkcLine,337,70,352,56, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ w.create(TkcLine,352,56,358,48, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ w.create(TkcLine,358,48,363,39, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ w.create(TkcLine,363,39,365,29, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ w.create(TkcLine,365,29,348,25, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ w.create(TkcLine,348,25,335,22, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ w.create(TkcLine,335,22,321,14, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ w.create(TkcLine,321,14,300,5, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ w.create(TkcLine,300,5,283,1, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ w.create(TkcLine,283,1,260,0, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ w.create(TkcLine,260,0,246,0, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ w.create(TkcLine,246,0,242,2, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ w.create(TkcLine,242,2,236,4, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ w.create(TkcLine,236,4,231,8, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ w.create(TkcLine,231,8,227,13, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ w.create(TkcLine,223,17,227,13, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ w.create(TkcLine,221,22,223,17, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ w.create(TkcLine,220,34,221,22, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ w.create(TkcLine,340,360,335,363, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ w.create(TkcLine,335,363,331,365, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ w.create(TkcLine,331,365,326,366, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ w.create(TkcLine,326,366,304,366, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ w.create(TkcLine,304,355,304,366, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ w.create(TkcLine,395,288,400,288, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ w.create(TkcLine,404,288,400,288, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ w.create(TkcLine,409,290,404,288, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ w.create(TkcLine,413,292,409,290, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ w.create(TkcLine,418,297,413,292, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ w.create(TkcLine,421,302,418,297, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ w.create(TkcLine,422,309,421,302, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ w.create(TkcLine,421,318,422,309, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ w.create(TkcLine,421,318,417,325, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ w.create(TkcLine,417,325,411,330, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ w.create(TkcLine,411,330,405,332, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ w.create(TkcLine,405,332,397,333, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ w.create(TkcLine,397,333,344,333, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ w.create(TkcLine,344,333,340,334, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ w.create(TkcLine,340,334,336,336, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ w.create(TkcLine,336,336,335,338, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ w.create(TkcLine,335,338,332,342, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ w.create(TkcLine,331,347,332,342, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ w.create(TkcLine,332,351,331,347, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ w.create(TkcLine,334,354,332,351, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ w.create(TkcLine,336,357,334,354, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ w.create(TkcLine,341,359,336,357, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ w.create(TkcLine,341,359,340,360, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ w.create(TkcLine,395,288,395,278, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ w.create(TkcLine,304,355,258,355, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ w.create(TkcLine,347,80,344,76, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ w.create(TkcLine,344,76,337,70, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ w.create(TkcLine,349,82,347,80, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ w.create(TkcLine,351,84,349,82, 'fill'=>outline, 'tags'=>['floor1','bg'])
+ w.create(TkcLine,353,85,351,84, 'fill'=>outline, 'tags'=>['floor1','bg'])
+end
+
+# floor2_bg2 --
+# This method represents part of the floorplan database. When
+# invoked, it instantiates the background information for the first
+# floor.
+#
+# Arguments:
+# w - The canvas window.
+# fill - Fill color to use for the floor's background.
+# outline - Color to use for the floor's outline.
+
+def floor2_bg2(w,fill,outline)
+ w.create(TkcPolygon,559,129,484,129,484,162,398,162,398,129,315,129,
+ 315,133,176,133,176,129,96,129,96,133,3,133,3,339,0,339,0,391,
+ 60,391,60,387,258,387,258,329,350,329,350,311,395,311,395,280,
+ 484,280,484,311,508,311,508,327,558,327,558,391,644,391,644,
+ 367,802,367,802,129,725,129,725,133,559,133,559,129,
+ 'tags'=>['floor2','bg'], 'fill'=>fill)
+ w.create(TkcLine,350,311,350,329, 'fill'=>outline, 'tags'=>['floor2','bg'])
+ w.create(TkcLine,398,129,398,162, 'fill'=>outline, 'tags'=>['floor2','bg'])
+ w.create(TkcLine,802,367,802,129, 'fill'=>outline, 'tags'=>['floor2','bg'])
+ w.create(TkcLine,802,129,725,129, 'fill'=>outline, 'tags'=>['floor2','bg'])
+ w.create(TkcLine,725,133,725,129, 'fill'=>outline, 'tags'=>['floor2','bg'])
+ w.create(TkcLine,559,129,559,133, 'fill'=>outline, 'tags'=>['floor2','bg'])
+ w.create(TkcLine,559,133,725,133, 'fill'=>outline, 'tags'=>['floor2','bg'])
+ w.create(TkcLine,484,162,484,129, 'fill'=>outline, 'tags'=>['floor2','bg'])
+ w.create(TkcLine,559,129,484,129, 'fill'=>outline, 'tags'=>['floor2','bg'])
+ w.create(TkcLine,802,367,644,367, 'fill'=>outline, 'tags'=>['floor2','bg'])
+ w.create(TkcLine,644,367,644,391, 'fill'=>outline, 'tags'=>['floor2','bg'])
+ w.create(TkcLine,644,391,558,391, 'fill'=>outline, 'tags'=>['floor2','bg'])
+ w.create(TkcLine,558,327,558,391, 'fill'=>outline, 'tags'=>['floor2','bg'])
+ w.create(TkcLine,558,327,508,327, 'fill'=>outline, 'tags'=>['floor2','bg'])
+ w.create(TkcLine,508,327,508,311, 'fill'=>outline, 'tags'=>['floor2','bg'])
+ w.create(TkcLine,484,311,508,311, 'fill'=>outline, 'tags'=>['floor2','bg'])
+ w.create(TkcLine,484,280,484,311, 'fill'=>outline, 'tags'=>['floor2','bg'])
+ w.create(TkcLine,398,162,484,162, 'fill'=>outline, 'tags'=>['floor2','bg'])
+ w.create(TkcLine,484,280,395,280, 'fill'=>outline, 'tags'=>['floor2','bg'])
+ w.create(TkcLine,395,280,395,311, 'fill'=>outline, 'tags'=>['floor2','bg'])
+ w.create(TkcLine,258,387,60,387, 'fill'=>outline, 'tags'=>['floor2','bg'])
+ w.create(TkcLine,3,133,3,339, 'fill'=>outline, 'tags'=>['floor2','bg'])
+ w.create(TkcLine,3,339,0,339, 'fill'=>outline, 'tags'=>['floor2','bg'])
+ w.create(TkcLine,60,391,0,391, 'fill'=>outline, 'tags'=>['floor2','bg'])
+ w.create(TkcLine,0,339,0,391, 'fill'=>outline, 'tags'=>['floor2','bg'])
+ w.create(TkcLine,60,387,60,391, 'fill'=>outline, 'tags'=>['floor2','bg'])
+ w.create(TkcLine,258,329,258,387, 'fill'=>outline, 'tags'=>['floor2','bg'])
+ w.create(TkcLine,350,329,258,329, 'fill'=>outline, 'tags'=>['floor2','bg'])
+ w.create(TkcLine,395,311,350,311, 'fill'=>outline, 'tags'=>['floor2','bg'])
+ w.create(TkcLine,398,129,315,129, 'fill'=>outline, 'tags'=>['floor2','bg'])
+ w.create(TkcLine,176,133,315,133, 'fill'=>outline, 'tags'=>['floor2','bg'])
+ w.create(TkcLine,176,129,96,129, 'fill'=>outline, 'tags'=>['floor2','bg'])
+ w.create(TkcLine,3,133,96,133, 'fill'=>outline, 'tags'=>['floor2','bg'])
+ w.create(TkcLine,315,133,315,129, 'fill'=>outline, 'tags'=>['floor2','bg'])
+ w.create(TkcLine,176,133,176,129, 'fill'=>outline, 'tags'=>['floor2','bg'])
+ w.create(TkcLine,96,133,96,129, 'fill'=>outline, 'tags'=>['floor2','bg'])
+end
+
+# floor2_bg3 --
+# This method represents part of the floorplan database. When
+# invoked, it instantiates the background information for the first
+# floor.
+#
+# Arguments:
+# w - The canvas window.
+# fill - Fill color to use for the floor's background.
+# outline - Color to use for the floor's outline.
+
+def floor2_bg3(w,fill,outline)
+ w.create(TkcPolygon,159,300,107,300,107,248,159,248,159,129,96,129,96,
+ 133,21,133,21,331,0,331,0,391,60,391,60,370,159,370,159,300,
+ 'tags'=>['floor3','bg'], 'fill'=>fill)
+ w.create(TkcPolygon,258,370,258,329,350,329,350,311,399,311,399,129,
+ 315,129,315,133,176,133,176,129,159,129,159,370,258,370,
+ 'tags'=>['floor3','bg'], 'fill'=>fill)
+ w.create(TkcLine,96,133,96,129, 'fill'=>outline, 'tags'=>['floor3','bg'])
+ w.create(TkcLine,176,129,96,129, 'fill'=>outline, 'tags'=>['floor3','bg'])
+ w.create(TkcLine,176,129,176,133, 'fill'=>outline, 'tags'=>['floor3','bg'])
+ w.create(TkcLine,315,133,176,133, 'fill'=>outline, 'tags'=>['floor3','bg'])
+ w.create(TkcLine,315,133,315,129, 'fill'=>outline, 'tags'=>['floor3','bg'])
+ w.create(TkcLine,399,129,315,129, 'fill'=>outline, 'tags'=>['floor3','bg'])
+ w.create(TkcLine,399,311,399,129, 'fill'=>outline, 'tags'=>['floor3','bg'])
+ w.create(TkcLine,399,311,350,311, 'fill'=>outline, 'tags'=>['floor3','bg'])
+ w.create(TkcLine,350,329,350,311, 'fill'=>outline, 'tags'=>['floor3','bg'])
+ w.create(TkcLine,350,329,258,329, 'fill'=>outline, 'tags'=>['floor3','bg'])
+ w.create(TkcLine,258,370,258,329, 'fill'=>outline, 'tags'=>['floor3','bg'])
+ w.create(TkcLine,60,370,258,370, 'fill'=>outline, 'tags'=>['floor3','bg'])
+ w.create(TkcLine,60,370,60,391, 'fill'=>outline, 'tags'=>['floor3','bg'])
+ w.create(TkcLine,60,391,0,391, 'fill'=>outline, 'tags'=>['floor3','bg'])
+ w.create(TkcLine,0,391,0,331, 'fill'=>outline, 'tags'=>['floor3','bg'])
+ w.create(TkcLine,21,331,0,331, 'fill'=>outline, 'tags'=>['floor3','bg'])
+ w.create(TkcLine,21,331,21,133, 'fill'=>outline, 'tags'=>['floor3','bg'])
+ w.create(TkcLine,96,133,21,133, 'fill'=>outline, 'tags'=>['floor3','bg'])
+ w.create(TkcLine,107,300,159,300,159,248,107,248,107,300,
+ 'fill'=>outline, 'tags'=>['floor3','bg'])
+end
+
+# floor2_fg1 --
+# This method represents part of the floorplan database. When
+# invoked, it instantiates the foreground information for the first
+# floor (office outlines and numbers).
+#
+# Arguments:
+# w - The canvas window.
+# color - Color to use for drawing foreground information.
+
+def floor2_fg1(w,color)
+ i = TkcPolygon.new(w,375,246,375,172,341,172,341,246,
+ 'fill'=>'', 'tags'=>['floor1','room'])
+ $floorLabels2[i.id] = '101'
+ $floorItems2['101'] = i
+ w.create(TkcText,358,209, 'text'=>'101', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor1','label'])
+ i = TkcPolygon.new(w,307,240,339,240,339,206,307,206,
+ 'fill'=>'', 'tags'=>['floor1','room'])
+ $floorLabels2[i.id] = 'Pub Lift1'
+ $floorItems2['Pub Lift1'] = i
+ w.create(TkcText,323,223, 'text'=>'Pub Lift1', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor1','label'])
+ i = TkcPolygon.new(w,339,205,307,205,307,171,339,171,
+ 'fill'=>'', 'tags'=>['floor1','room'])
+ $floorLabels2[i.id] = 'Priv Lift1'
+ $floorItems2['Priv Lift1'] = i
+ w.create(TkcText,323,188, 'text'=>'Priv Lift1', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor1','label'])
+ i = TkcPolygon.new(w,42,389,42,337,1,337,1,389,
+ 'fill'=>'', 'tags'=>['floor1','room'])
+ $floorLabels2[i.id] = '110'
+ $floorItems2['110'] = i
+ w.create(TkcText,21.5,363, 'text'=>'110', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor1','label'])
+ i = TkcPolygon.new(w,59,389,59,385,90,385,90,337,44,337,44,389,
+ 'fill'=>'', 'tags'=>['floor1','room'])
+ $floorLabels2[i.id] = '109'
+ $floorItems2['109'] = i
+ w.create(TkcText,67,363, 'text'=>'109', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor1','label'])
+ i = TkcPolygon.new(w,51,300,51,253,6,253,6,300,
+ 'fill'=>'', 'tags'=>['floor1','room'])
+ $floorLabels2[i.id] = '111'
+ $floorItems2['111'] = i
+ w.create(TkcText,28.5,276.5, 'text'=>'111', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor1','label'])
+ i = TkcPolygon.new(w,98,248,98,309,79,309,79,248,
+ 'fill'=>'', 'tags'=>['floor1','room'])
+ $floorLabels2[i.id] = '117B'
+ $floorItems2['117B'] = i
+ w.create(TkcText,88.5,278.5, 'text'=>'117B', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor1','label'])
+ i = TkcPolygon.new(w,51,251,51,204,6,204,6,251,
+ 'fill'=>'', 'tags'=>['floor1','room'])
+ $floorLabels2[i.id] = '112'
+ $floorItems2['112'] = i
+ w.create(TkcText,28.5,227.5, 'text'=>'112', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor1','label'])
+ i = TkcPolygon.new(w,6,156,51,156,51,203,6,203,
+ 'fill'=>'', 'tags'=>['floor1','room'])
+ $floorLabels2[i.id] = '113'
+ $floorItems2['113'] = i
+ w.create(TkcText,28.5,179.5, 'text'=>'113', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor1','label'])
+ i = TkcPolygon.new(w,85,169,79,169,79,192,85,192,
+ 'fill'=>'', 'tags'=>['floor1','room'])
+ $floorLabels2[i.id] = '117A'
+ $floorItems2['117A'] = i
+ w.create(TkcText,82,180.5, 'text'=>'117A', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor1','label'])
+ i = TkcPolygon.new(w,77,302,77,168,53,168,53,302,
+ 'fill'=>'', 'tags'=>['floor1','room'])
+ $floorLabels2[i.id] = '117'
+ $floorItems2['117'] = i
+ w.create(TkcText,65,235, 'text'=>'117', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor1','label'])
+ i = TkcPolygon.new(w,51,155,51,115,6,115,6,155,
+ 'fill'=>'', 'tags'=>['floor1','room'])
+ $floorLabels2[i.id] = '114'
+ $floorItems2['114'] = i
+ w.create(TkcText,28.5,135, 'text'=>'114', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor1','label'])
+ i = TkcPolygon.new(w,95,115,53,115,53,168,95,168,
+ 'fill'=>'', 'tags'=>['floor1','room'])
+ $floorLabels2[i.id] = '115'
+ $floorItems2['115'] = i
+ w.create(TkcText,74,141.5, 'text'=>'115', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor1','label'])
+ i = TkcPolygon.new(w,87,113,87,27,10,27,10,113,
+ 'fill'=>'', 'tags'=>['floor1','room'])
+ $floorLabels2[i.id] = '116'
+ $floorItems2['116'] = i
+ w.create(TkcText,48.5,70, 'text'=>'116', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor1','label'])
+ i = TkcPolygon.new(w,89,91,128,91,128,113,89,131,
+ 'fill'=>'', 'tags'=>['floor1','room'])
+ $floorLabels2[i.id] = '118'
+ $floorItems2['118'] = i
+ w.create(TkcText,108.5,102, 'text'=>'118', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor1','label'])
+ i = TkcPolygon.new(w,178,128,178,132,216,132,216,91,
+ 163,91,163,112,149,112,149,128,
+ 'fill'=>'', 'tags'=>['floor1','room'])
+ $floorLabels2[i.id] = '120'
+ $floorItems2['120'] = i
+ w.create(TkcText,189.5,111.5, 'text'=>'120', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor1','label'])
+ i = TkcPolygon.new(w,79,193,87,193,87,169,136,169,136,192,
+ 156,192,156,169,175,169,175,246,79,246,
+ 'fill'=>'', 'tags'=>['floor1','room'])
+ $floorLabels2[i.id] = '122'
+ $floorItems2['122'] = i
+ w.create(TkcText,131,207.5, 'text'=>'122', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor1','label'])
+ i = TkcPolygon.new(w,138,169,154,169,154,191,138,191,
+ 'fill'=>'', 'tags'=>['floor1','room'])
+ $floorLabels2[i.id] = '121'
+ $floorItems2['121'] = i
+ w.create(TkcText,146,180, 'text'=>'121', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor1','label'])
+ i = TkcPolygon.new(w,99,300,126,300,126,309,99,309,
+ 'fill'=>'', 'tags'=>['floor1','room'])
+ $floorLabels2[i.id] = '106A'
+ $floorItems2['106A'] = i
+ w.create(TkcText,112.5,304.5, 'text'=>'106A', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor1','label'])
+ i = TkcPolygon.new(w,128,299,128,309,150,309,150,248,99,248,99,299,
+ 'fill'=>'', 'tags'=>['floor1','room'])
+ $floorLabels2[i.id] = '105'
+ $floorItems2['105'] = i
+ w.create(TkcText,124.5,278.5, 'text'=>'105', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor1','label'])
+ i = TkcPolygon.new(w,174,309,174,300,152,300,152,309,
+ 'fill'=>'', 'tags'=>['floor1','room'])
+ $floorLabels2[i.id] = '106B'
+ $floorItems2['106B'] = i
+ w.create(TkcText,163,304.5, 'text'=>'106B', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor1','label'])
+ i = TkcPolygon.new(w,176,299,176,309,216,309,216,248,152,248,152,299,
+ 'fill'=>'', 'tags'=>['floor1','room'])
+ $floorLabels2[i.id] = '104'
+ $floorItems2['104'] = i
+ w.create(TkcText,184,278.5, 'text'=>'104', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor1','label'])
+ i = TkcPolygon.new(w,138,385,138,337,91,337,91,385,
+ 'fill'=>'', 'tags'=>['floor1','room'])
+ $floorLabels2[i.id] = '108'
+ $floorItems2['108'] = i
+ w.create(TkcText,114.5,361, 'text'=>'108', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor1','label'])
+ i = TkcPolygon.new(w,256,337,140,337,140,385,256,385,
+ 'fill'=>'', 'tags'=>['floor1','room'])
+ $floorLabels2[i.id] = '107'
+ $floorItems2['107'] = i
+ w.create(TkcText,198,361, 'text'=>'107', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor1','label'])
+ i = TkcPolygon.new(w,300,353,300,329,260,329,260,353,
+ 'fill'=>'', 'tags'=>['floor1','room'])
+ $floorLabels2[i.id] = 'Smoking'
+ $floorItems2['Smoking'] = i
+ w.create(TkcText,280,341, 'text'=>'Smoking', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor1','label'])
+ i = TkcPolygon.new(w,314,135,314,170,306,170,306,246,177,246,177,135,
+ 'fill'=>'', 'tags'=>['floor1','room'])
+ $floorLabels2[i.id] = '123'
+ $floorItems2['123'] = i
+ w.create(TkcText,245.5,190.5, 'text'=>'123', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor1','label'])
+ i = TkcPolygon.new(w,217,248,301,248,301,326,257,326,257,310,217,310,
+ 'fill'=>'', 'tags'=>['floor1','room'])
+ $floorLabels2[i.id] = '103'
+ $floorItems2['103'] = i
+ w.create(TkcText,259,287, 'text'=>'103', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor1','label'])
+ i = TkcPolygon.new(w,396,188,377,188,377,169,316,169,316,131,396,131,
+ 'fill'=>'', 'tags'=>['floor1','room'])
+ $floorLabels2[i.id] = '124'
+ $floorItems2['124'] = i
+ w.create(TkcText,356,150, 'text'=>'124', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor1','label'])
+ i = TkcPolygon.new(w,397,226,407,226,407,189,377,189,377,246,397,246,
+ 'fill'=>'', 'tags'=>['floor1','room'])
+ $floorLabels2[i.id] = '125'
+ $floorItems2['125'] = i
+ w.create(TkcText,392,217.5, 'text'=>'125', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor1','label'])
+ i = TkcPolygon.new(w,399,187,409,187,409,207,474,207,474,164,399,164,
+ 'fill'=>'', 'tags'=>['floor1','room'])
+ $floorLabels2[i.id] = '126'
+ $floorItems2['126'] = i
+ w.create(TkcText,436.5,185.5, 'text'=>'126', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor1','label'])
+ i = TkcPolygon.new(w,409,209,409,229,399,229,399,253,
+ 486,253,486,239,474,239,474,209,
+ 'fill'=>'', 'tags'=>['floor1','room'])
+ $floorLabels2[i.id] = '127'
+ $floorItems2['127'] = i
+ w.create(TkcText,436.5,'231', 'text'=>'127', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor1','label'])
+ i = TkcPolygon.new(w,501,164,501,174,495,174,495,188,
+ 490,188,490,204,476,204,476,164,
+ 'fill'=>'', 'tags'=>['floor1','room'])
+ $floorLabels2[i.id] = 'MShower'
+ $floorItems2['MShower'] = i
+ w.create(TkcText,488.5,'184', 'text'=>'MShower', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor1','label'])
+ i = TkcPolygon.new(w,497,176,513,176,513,204,492,204,492,190,497,190,
+ 'fill'=>'', 'tags'=>['floor1','room'])
+ $floorLabels2[i.id] = 'Closet'
+ $floorItems2['Closet'] = i
+ w.create(TkcText,502.5,190, 'text'=>'Closet', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor1','label'])
+ i = TkcPolygon.new(w,476,237,476,206,513,206,513,254,488,254,488,237,
+ 'fill'=>'', 'tags'=>['floor1','room'])
+ $floorLabels2[i.id] = 'WShower'
+ $floorItems2['WShower'] = i
+ w.create(TkcText,494.5,230, 'text'=>'WShower', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor1','label'])
+ i = TkcPolygon.new(w,486,131,558,131,558,135,724,135,724,166,
+ 697,166,697,275,553,275,531,254,515,254,
+ 515,174,503,174,503,161,486,161,
+ 'fill'=>'', 'tags'=>['floor1','room'])
+ $floorLabels2[i.id] = '130'
+ $floorItems2['130'] = i
+ w.create(TkcText,638.5,205, 'text'=>'130', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor1','label'])
+ i = TkcPolygon.new(w,308,242,339,242,339,248,342,248,
+ 342,246,397,246,397,276,393,276,
+ 393,309,300,309,300,248,308,248,
+ 'fill'=>'', 'tags'=>['floor1','room'])
+ $floorLabels2[i.id] = '102'
+ $floorItems2['102'] = i
+ w.create(TkcText,367.5,278.5, 'text'=>'102', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor1','label'])
+ i = TkcPolygon.new(w,397,255,486,255,486,276,397,276,
+ 'fill'=>'', 'tags'=>['floor1','room'])
+ $floorLabels2[i.id] = '128'
+ $floorItems2['128'] = i
+ w.create(TkcText,441.5,265.5, 'text'=>'128', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor1','label'])
+ i = TkcPolygon.new(w,510,309,486,309,486,255,530,255,
+ 552,277,561,277,561,325,510,325,
+ 'fill'=>'', 'tags'=>['floor1','room'])
+ $floorLabels2[i.id] = '129'
+ $floorItems2['129'] = i
+ w.create(TkcText,535.5,293, 'text'=>'129', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor1','label'])
+ i = TkcPolygon.new(w,696,281,740,281,740,387,642,387,
+ 642,389,561,389,561,277,696,277,
+ 'fill'=>'', 'tags'=>['floor1','room'])
+ $floorLabels2[i.id] = '133'
+ $floorItems2['133'] = i
+ w.create(TkcText,628.5,335, 'text'=>'133', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor1','label'])
+ i = TkcPolygon.new(w,742,387,742,281,800,281,800,387,
+ 'fill'=>'', 'tags'=>['floor1','room'])
+ $floorLabels2[i.id] = '132'
+ $floorItems2['132'] = i
+ w.create(TkcText,771,334, 'text'=>'132', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor1','label'])
+ i = TkcPolygon.new(w,800,168,800,280,699,280,699,168,
+ 'fill'=>'', 'tags'=>['floor1','room'])
+ $floorLabels2[i.id] = '134'
+ $floorItems2['134'] = i
+ w.create(TkcText,749.5,224, 'text'=>'134', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor1','label'])
+ i = TkcPolygon.new(w,726,131,726,166,800,166,800,131,
+ 'fill'=>'', 'tags'=>['floor1','room'])
+ $floorLabels2[i.id] = '135'
+ $floorItems2['135'] = i
+ w.create(TkcText,763,148.5, 'text'=>'135', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor1','label'])
+ i = TkcPolygon.new(w,340,360,335,363,331,365,326,366,304,366,
+ 304,312,396,312,396,288,400,288,404,288,
+ 409,290,413,292,418,297,421,302,422,309,
+ 421,318,417,325,411,330,405,332,397,333,
+ 344,333,340,334,336,336,335,338,332,342,
+ 331,347,332,351,334,354,336,357,341,359,
+ 'fill'=>'', 'tags'=>['floor1','room'])
+ $floorLabels2[i.id] = 'Ramona Stair'
+ $floorItems2['Ramona Stair'] = i
+ w.create(TkcText,368,323, 'text'=>'Ramona Stair', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor1','label'])
+ i = TkcPolygon.new(w,30,23,30,5,93,5,98,5,104,7,110,10,116,16,119,20,
+ 122,28,123,32,123,68,220,68,220,87,90,87,90,23,
+ 'fill'=>'', 'tags'=>['floor1','room'])
+ $floorLabels2[i.id] = 'University Stair'
+ $floorItems2['University Stair'] = i
+ w.create(TkcText,155,77.5, 'text'=>'University Stair', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor1','label'])
+ i = TkcPolygon.new(w,282,37,295,40,312,49,323,56,337,70,352,56,
+ 358,48,363,39,365,29,348,25,335,22,321,14,
+ 300,5,283,1,260,0,246,0,242,2,236,4,231,8,
+ 227,13,223,17,221,22,220,34,260,34,
+ 'fill'=>'', 'tags'=>['floor1','room'])
+ $floorLabels2[i.id] = 'Plaza Stair'
+ $floorItems2['Plaza Stair'] = i
+ w.create(TkcText,317.5,28.5, 'text'=>'Plaza Stair', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor1','label'])
+ i = TkcPolygon.new(w,220,34,260,34,282,37,295,40,312,49,
+ 323,56,337,70,350,83,365,94,377,100,
+ 386,104,386,128,220,128,
+ 'fill'=>'', 'tags'=>['floor1','room'])
+ $floorLabels2[i.id] = 'Plaza Deck'
+ $floorItems2['Plaza Deck'] = i
+ w.create(TkcText,303,81, 'text'=>'Plaza Deck', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor1','label'])
+ i = TkcPolygon.new(w,257,336,77,336,6,336,6,301,77,301,77,310,257,310,
+ 'fill'=>'', 'tags'=>['floor1','room'])
+ $floorLabels2[i.id] = '106'
+ $floorItems2['106'] = i
+ w.create(TkcText,131.5,318.5, 'text'=>'106', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor1','label'])
+ i = TkcPolygon.new(w,146,110,162,110,162,91,130,91,130,115,95,115,
+ 95,128,114,128,114,151,157,151,157,153,112,153,
+ 112,130,97,130,97,168,175,168,175,131,146,131,
+ 'fill'=>'', 'tags'=>['floor1','room'])
+ $floorLabels2[i.id] = '119'
+ $floorItems2['119'] = i
+ w.create(TkcText,143.5,133, 'text'=>'119', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor1','label'])
+ w.create(TkcLine,155,191,155,189, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,155,177,155,169, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,96,129,96,169, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,78,169,176,169, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,176,247,176,129, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,340,206,307,206, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,340,187,340,170, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,340,210,340,201, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,340,247,340,224, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,340,241,307,241, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,376,246,376,170, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,307,247,307,170, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,376,170,307,170, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,315,129,315,170, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,147,129,176,129, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,202,133,176,133, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,398,129,315,129, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,258,352,258,387, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,60,387,60,391, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,0,337,0,391, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,60,391,0,391, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,3,114,3,337, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,258,387,60,387, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,52,237,52,273, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,52,189,52,225, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,52,140,52,177, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,395,306,395,311, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,531,254,398,254, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,475,178,475,238, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,502,162,398,162, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,398,129,398,188, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,383,188,376,188, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,408,188,408,194, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,398,227,398,254, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,408,227,398,227, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,408,222,408,227, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,408,206,408,210, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,408,208,475,208, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,484,278,484,311, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,484,311,508,311, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,508,327,508,311, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,559,327,508,327, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,644,391,559,391, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,644,389,644,391, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,514,205,475,205, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,496,189,496,187, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,559,129,484,129, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,484,162,484,129, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,725,133,559,133, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,559,129,559,133, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,725,149,725,167, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,725,129,802,129, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,802,389,802,129, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,739,167,802,167, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,396,188,408,188, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,0,337,9,337, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,58,337,21,337, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,43,391,43,337, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,105,337,75,337, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,91,387,91,337, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,154,337,117,337, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,139,387,139,337, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,227,337,166,337, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,258,337,251,337, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,258,328,302,328, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,302,355,302,311, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,395,311,302,311, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,484,278,395,278, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,395,294,395,278, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,473,278,473,275, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,473,256,473,254, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,533,257,531,254, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,553,276,551,274, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,698,276,553,276, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,559,391,559,327, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,802,389,644,389, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,741,314,741,389, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,698,280,698,167, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,707,280,698,280, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,802,280,731,280, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,741,280,741,302, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,698,167,727,167, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,725,137,725,129, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,514,254,514,175, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,496,175,514,175, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,502,175,502,162, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,475,166,475,162, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,496,176,496,175, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,491,189,496,189, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,491,205,491,189, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,487,238,475,238, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,487,240,487,238, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,487,252,487,254, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,315,133,304,133, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,256,133,280,133, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,78,247,270,247, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,307,247,294,247, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,214,133,232,133, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,217,247,217,266, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,217,309,217,291, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,217,309,172,309, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,154,309,148,309, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,175,300,175,309, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,151,300,175,300, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,151,247,151,309, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,78,237,78,265, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,78,286,78,309, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,106,309,78,309, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,130,309,125,309, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,99,309,99,247, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,127,299,99,299, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,127,309,127,299, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,155,191,137,191, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,137,169,137,191, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,78,171,78,169, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,78,190,78,218, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,86,192,86,169, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,86,192,78,192, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,52,301,3,301, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,52,286,52,301, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,52,252,3,252, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,52,203,3,203, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,3,156,52,156, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,8,25,8,114, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,63,114,3,114, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,75,114,97,114, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,108,114,129,114, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,129,114,129,89, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,52,114,52,128, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,132,89,88,89, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,88,25,88,89, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,88,114,88,89, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,218,89,144,89, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,147,111,147,129, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,162,111,147,111, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,162,109,162,111, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,162,96,162,89, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,218,89,218,94, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,218,89,218,119, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,8,25,88,25, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,258,337,258,328, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,113,129,96,129, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,302,355,258,355, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,386,104,386,129, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,377,100,386,104, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,365,94,377,100, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,350,83,365,94, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,337,70,350,83, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,337,70,323,56, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,312,49,323,56, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,295,40,312,49, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,282,37,295,40, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,260,34,282,37, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,253,34,260,34, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,386,128,386,104, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,113,152,156,152, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,113,152,156,152, 'fill'=>color, 'tags'=>['floor1','wall'])
+ w.create(TkcLine,113,152,113,129, 'fill'=>color, 'tags'=>['floor1','wall'])
+end
+
+# floor2_fg2 --
+# This method represents part of the floorplan database. When
+# invoked, it instantiates the foreground information for the second
+# floor (office outlines and numbers).
+#
+# Arguments:
+# w - The canvas window.
+# color - Color to use for drawing foreground information.
+
+def floor2_fg2(w,color)
+ i = TkcPolygon.new(w,748,188,755,188,755,205,758,205,758,222,
+ 800,222,800,168,748,168,
+ 'fill'=>'', 'tags'=>['floor2','room'])
+ $floorLabels2[i.id] = '238'
+ $floorItems2['238'] = i
+ w.create(TkcText,774,195, 'text'=>'238', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor2','label'])
+ i = TkcPolygon.new(w,726,188,746,188,746,166,800,166,800,131,726,131,
+ 'fill'=>'', 'tags'=>['floor2','room'])
+ $floorLabels2[i.id] = '237'
+ $floorItems2['237'] = i
+ w.create(TkcText,763,148.5, 'text'=>'237', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor2','label'])
+ i = TkcPolygon.new(w,497,187,497,204,559,204,559,324,641,324,
+ 643,324,643,291,641,291,641,205,696,205,
+ 696,291,694,291,694,314,715,314,715,291,
+ 715,205,755,205,755,190,724,190,724,187,
+ 'fill'=>'', 'tags'=>['floor2','room'])
+ $floorLabels2[i.id] = '246'
+ $floorItems2['246'] = i
+ w.create(TkcText,600,264, 'text'=>'246', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor2','label'])
+ i = TkcPolygon.new(w,694,279,643,279,643,314,694,314,
+ 'fill'=>'', 'tags'=>['floor2','room'])
+ $floorLabels2[i.id] = '247'
+ $floorItems2['247'] = i
+ w.create(TkcText,668.5,296.5, 'text'=>'247', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor2','label'])
+ i = TkcPolygon.new(w,232,250,308,250,308,242,339,242,339,246,
+ 397,246,397,255,476,255,476,250,482,250,559,250,
+ 559,274,482,274,482,278,396,278,396,274,232,274,
+ 'fill'=>'', 'tags'=>['floor2','room'])
+ $floorLabels2[i.id] = '202'
+ $floorItems2['202'] = i
+ w.create(TkcText,285.5,260, 'text'=>'202', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor2','label'])
+ i = TkcPolygon.new(w,53,228,53,338,176,338,233,338,233,196,
+ 306,196,306,180,175,180,175,169,156,169,
+ 156,196,176,196,176,228,
+ 'fill'=>'', 'tags'=>['floor2','room'])
+ $floorLabels2[i.id] = '206'
+ $floorItems2['206'] = i
+ w.create(TkcText,143,267, 'text'=>'206', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor2','label'])
+ i = TkcPolygon.new(w,51,277,6,277,6,338,51,338,
+ 'fill'=>'', 'tags'=>['floor2','room'])
+ $floorLabels2[i.id] = '212'
+ $floorItems2['212'] = i
+ w.create(TkcText,28.5,307.5, 'text'=>'212', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor2','label'])
+ i = TkcPolygon.new(w,557,276,486,276,486,309,510,309,510,325,557,325,
+ 'fill'=>'', 'tags'=>['floor2','room'])
+ $floorLabels2[i.id] = '245'
+ $floorItems2['245'] = i
+ w.create(TkcText,521.5,300.5, 'text'=>'245', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor2','label'])
+ i = TkcPolygon.new(w,560,389,599,389,599,326,560,326,
+ 'fill'=>'', 'tags'=>['floor2','room'])
+ $floorLabels2[i.id] = '244'
+ $floorItems2['244'] = i
+ w.create(TkcText,579.5,357.5, 'text'=>'244', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor2','label'])
+ i = TkcPolygon.new(w,601,389,601,326,643,326,643,389,
+ 'fill'=>'', 'tags'=>['floor2','room'])
+ $floorLabels2[i.id] = '243'
+ $floorItems2['243'] = i
+ w.create(TkcText,622,357.5, 'text'=>'243', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor2','label'])
+ i = TkcPolygon.new(w,688,316,645,316,645,365,688,365,
+ 'fill'=>'', 'tags'=>['floor2','room'])
+ $floorLabels2[i.id] = '242'
+ $floorItems2['242'] = i
+ w.create(TkcText,666.5,340.5, 'text'=>'242', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor2','label'])
+ i = TkcPolygon.new(w,802,367,759,367,759,226,802,226,
+ 'fill'=>'', 'tags'=>['floor2','room'])
+ $floorLabels2[i.id] = 'Barbecue Deck'
+ $floorItems2['Barbecue Deck'] = i
+ w.create(TkcText,780.5,296.5, 'text'=>'Barbecue Deck', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor2','label'])
+ i = TkcPolygon.new(w,755,262,755,314,717,314,717,262,
+ 'fill'=>'', 'tags'=>['floor2','room'])
+ $floorLabels2[i.id] = '240'
+ $floorItems2['240'] = i
+ w.create(TkcText,736,288, 'text'=>'240', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor2','label'])
+ i = TkcPolygon.new(w,755,316,689,316,689,365,755,365,
+ 'fill'=>'', 'tags'=>['floor2','room'])
+ $floorLabels2[i.id] = '241'
+ $floorItems2['241'] = i
+ w.create(TkcText,722,340.5, 'text'=>'241', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor2','label'])
+ i = TkcPolygon.new(w,755,206,717,206,717,261,755,261,
+ 'fill'=>'', 'tags'=>['floor2','room'])
+ $floorLabels2[i.id] = '239'
+ $floorItems2['239'] = i
+ w.create(TkcText,736,233.5, 'text'=>'239', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor2','label'])
+ i = TkcPolygon.new(w,695,277,643,277,643,206,695,206,
+ 'fill'=>'', 'tags'=>['floor2','room'])
+ $floorLabels2[i.id] = '248'
+ $floorItems2['248'] = i
+ w.create(TkcText,669,241.5, 'text'=>'248', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor2','label'])
+ i = TkcPolygon.new(w,676,135,676,185,724,185,724,135,
+ 'fill'=>'', 'tags'=>['floor2','room'])
+ $floorLabels2[i.id] = '236'
+ $floorItems2['236'] = i
+ w.create(TkcText,700,160, 'text'=>'236', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor2','label'])
+ i = TkcPolygon.new(w,675,135,635,135,635,145,628,145,628,185,675,185,
+ 'fill'=>'', 'tags'=>['floor2','room'])
+ $floorLabels2[i.id] = '235'
+ $floorItems2['235'] = i
+ w.create(TkcText,651.5,160, 'text'=>'235', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor2','label'])
+ i = TkcPolygon.new(w,626,143,633,143,633,135,572,135,
+ 572,143,579,143,579,185,626,185,
+ 'fill'=>'', 'tags'=>['floor2','room'])
+ $floorLabels2[i.id] = '234'
+ $floorItems2['234'] = i
+ w.create(TkcText,606,160, 'text'=>'234', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor2','label'])
+ i = TkcPolygon.new(w,557,135,571,135,571,145,578,145,
+ 578,185,527,185,527,131,557,131,
+ 'fill'=>'', 'tags'=>['floor2','room'])
+ $floorLabels2[i.id] = '233'
+ $floorItems2['233'] = i
+ w.create(TkcText,552.5,158, 'text'=>'233', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor2','label'])
+ i = TkcPolygon.new(w,476,249,557,249,557,205,476,205,
+ 'fill'=>'', 'tags'=>['floor2','room'])
+ $floorLabels2[i.id] = '230'
+ $floorItems2['230'] = i
+ w.create(TkcText,516.5,227, 'text'=>'230', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor2','label'])
+ i = TkcPolygon.new(w,476,164,486,164,486,131,525,131,525,185,476,185,
+ 'fill'=>'', 'tags'=>['floor2','room'])
+ $floorLabels2[i.id] = '232'
+ $floorItems2['232'] = i
+ w.create(TkcText,500.5,158, 'text'=>'232', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor2','label'])
+ i = TkcPolygon.new(w,476,186,495,186,495,204,476,204,
+ 'fill'=>'', 'tags'=>['floor2','room'])
+ $floorLabels2[i.id] = '229'
+ $floorItems2['229'] = i
+ w.create(TkcText,485.5,195, 'text'=>'229', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor2','label'])
+ i = TkcPolygon.new(w,474,207,409,207,409,187,399,187,399,164,474,164,
+ 'fill'=>'', 'tags'=>['floor2','room'])
+ $floorLabels2[i.id] = '227'
+ $floorItems2['227'] = i
+ w.create(TkcText,436.5,185.5, 'text'=>'227', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor2','label'])
+ i = TkcPolygon.new(w,399,228,399,253,474,253,474,209,409,209,409,228,
+ 'fill'=>'', 'tags'=>['floor2','room'])
+ $floorLabels2[i.id] = '228'
+ $floorItems2['228'] = i
+ w.create(TkcText,436.5,231, 'text'=>'228', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor2','label'])
+ i = TkcPolygon.new(w,397,246,397,226,407,226,407,189,377,189,377,246,
+ 'fill'=>'', 'tags'=>['floor2','room'])
+ $floorLabels2[i.id] = '226'
+ $floorItems2['226'] = i
+ w.create(TkcText,392,217.5, 'text'=>'226', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor2','label'])
+ i = TkcPolygon.new(w,377,169,316,169,316,131,397,131,397,188,377,188,
+ 'fill'=>'', 'tags'=>['floor2','room'])
+ $floorLabels2[i.id] = '225'
+ $floorItems2['225'] = i
+ w.create(TkcText,356.5,150, 'text'=>'225', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor2','label'])
+ i = TkcPolygon.new(w,234,198,306,198,306,249,234,249,
+ 'fill'=>'', 'tags'=>['floor2','room'])
+ $floorLabels2[i.id] = '224'
+ $floorItems2['224'] = i
+ w.create(TkcText,270,223.5, 'text'=>'224', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor2','label'])
+ i = TkcPolygon.new(w,270,179,306,179,306,170,314,170,314,135,270,135,
+ 'fill'=>'', 'tags'=>['floor2','room'])
+ $floorLabels2[i.id] = '223'
+ $floorItems2['223'] = i
+ w.create(TkcText,292,157, 'text'=>'223', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor2','label'])
+ i = TkcPolygon.new(w,268,179,221,179,221,135,268,135,
+ 'fill'=>'', 'tags'=>['floor2','room'])
+ $floorLabels2[i.id] = '222'
+ $floorItems2['222'] = i
+ w.create(TkcText,244.5,157, 'text'=>'222', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor2','label'])
+ i = TkcPolygon.new(w,177,179,219,179,219,135,177,135,
+ 'fill'=>'', 'tags'=>['floor2','room'])
+ $floorLabels2[i.id] = '221'
+ $floorItems2['221'] = i
+ w.create(TkcText,198,157, 'text'=>'221', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor2','label'])
+ i = TkcPolygon.new(w,299,327,349,327,349,284,341,284,341,276,299,276,
+ 'fill'=>'', 'tags'=>['floor2','room'])
+ $floorLabels2[i.id] = '204'
+ $floorItems2['204'] = i
+ w.create(TkcText,324,301.5, 'text'=>'204', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor2','label'])
+ i = TkcPolygon.new(w,234,276,297,276,297,327,257,327,257,338,234,338,
+ 'fill'=>'', 'tags'=>['floor2','room'])
+ $floorLabels2[i.id] = '205'
+ $floorItems2['205'] = i
+ w.create(TkcText,265.5,307, 'text'=>'205', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor2','label'])
+ i = TkcPolygon.new(w,256,385,256,340,212,340,212,385,
+ 'fill'=>'', 'tags'=>['floor2','room'])
+ $floorLabels2[i.id] = '207'
+ $floorItems2['207'] = i
+ w.create(TkcText,234,362.5, 'text'=>'207', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor2','label'])
+ i = TkcPolygon.new(w,210,340,164,340,164,385,210,385,
+ 'fill'=>'', 'tags'=>['floor2','room'])
+ $floorLabels2[i.id] = '208'
+ $floorItems2['208'] = i
+ w.create(TkcText,187,362.5, 'text'=>'208', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor2','label'])
+ i = TkcPolygon.new(w,115,340,162,340,162,385,115,385,
+ 'fill'=>'', 'tags'=>['floor2','room'])
+ $floorLabels2[i.id] = '209'
+ $floorItems2['209'] = i
+ w.create(TkcText,138.5,362.5, 'text'=>'209', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor2','label'])
+ i = TkcPolygon.new(w,89,228,89,156,53,156,53,228,
+ 'fill'=>'', 'tags'=>['floor2','room'])
+ $floorLabels2[i.id] = '217'
+ $floorItems2['217'] = i
+ w.create(TkcText,71,192, 'text'=>'217', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor2','label'])
+ i = TkcPolygon.new(w,89,169,97,169,97,190,89,190,
+ 'fill'=>'', 'tags'=>['floor2','room'])
+ $floorLabels2[i.id] = '217A'
+ $floorItems2['217A'] = i
+ w.create(TkcText,93,179.5, 'text'=>'217A', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor2','label'])
+ i = TkcPolygon.new(w,89,156,89,168,95,168,95,135,53,135,53,156,
+ 'fill'=>'', 'tags'=>['floor2','room'])
+ $floorLabels2[i.id] = '216'
+ $floorItems2['216'] = i
+ w.create(TkcText,71,145.5, 'text'=>'216', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor2','label'])
+ i = TkcPolygon.new(w,51,179,51,135,6,135,6,179,
+ 'fill'=>'', 'tags'=>['floor2','room'])
+ $floorLabels2[i.id] = '215'
+ $floorItems2['215'] = i
+ w.create(TkcText,28.5,157, 'text'=>'215', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor2','label'])
+ i = TkcPolygon.new(w,51,227,6,227,6,180,51,180,
+ 'fill'=>'', 'tags'=>['floor2','room'])
+ $floorLabels2[i.id] = '214'
+ $floorItems2['214'] = i
+ w.create(TkcText,28.5,203.5, 'text'=>'214', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor2','label'])
+ i = TkcPolygon.new(w,51,275,6,275,6,229,51,229,
+ 'fill'=>'', 'tags'=>['floor2','room'])
+ $floorLabels2[i.id] = '213'
+ $floorItems2['213'] = i
+ w.create(TkcText,28.5,252, 'text'=>'213', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor2','label'])
+ i = TkcPolygon.new(w,114,340,67,340,67,385,114,385,
+ 'fill'=>'', 'tags'=>['floor2','room'])
+ $floorLabels2[i.id] = '210'
+ $floorItems2['210'] = i
+ w.create(TkcText,90.5,362.5, 'text'=>'210', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor2','label'])
+ i = TkcPolygon.new(w,59,389,59,385,65,385,65,340,1,340,1,389,
+ 'fill'=>'', 'tags'=>['floor2','room'])
+ $floorLabels2[i.id] = '211'
+ $floorItems2['211'] = i
+ w.create(TkcText,33,364.5, 'text'=>'211', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor2','label'])
+ i = TkcPolygon.new(w,393,309,350,309,350,282,342,282,342,276,393,276,
+ 'fill'=>'', 'tags'=>['floor2','room'])
+ $floorLabels2[i.id] = '203'
+ $floorItems2['203'] = i
+ w.create(TkcText,367.5,292.5, 'text'=>'203', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor2','label'])
+ i = TkcPolygon.new(w,99,191,91,191,91,226,174,226,174,198,
+ 154,198,154,192,109,192,109,169,99,169,
+ 'fill'=>'', 'tags'=>['floor2','room'])
+ $floorLabels2[i.id] = '220'
+ $floorItems2['220'] = i
+ w.create(TkcText,132.5,208.5, 'text'=>'220', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor2','label'])
+ i = TkcPolygon.new(w,339,205,307,205,307,171,339,171,
+ 'fill'=>'', 'tags'=>['floor2','room'])
+ $floorLabels2[i.id] = 'Priv Lift2'
+ $floorItems2['Priv Lift2'] = i
+ w.create(TkcText,323,188, 'text'=>'Priv Lift2', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor2','label'])
+ i = TkcPolygon.new(w,307,240,339,240,339,206,307,206,
+ 'fill'=>'', 'tags'=>['floor2','room'])
+ $floorLabels2[i.id] = 'Pub Lift 2'
+ $floorItems2['Pub Lift 2'] = i
+ w.create(TkcText,323,223, 'text'=>'Pub Lift 2', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor2','label'])
+ i = TkcPolygon.new(w,175,168,97,168,97,131,175,131,
+ 'fill'=>'', 'tags'=>['floor2','room'])
+ $floorLabels2[i.id] = '218'
+ $floorItems2['218'] = i
+ w.create(TkcText,136,149.5, 'text'=>'218', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor2','label'])
+ i = TkcPolygon.new(w,154,191,111,191,111,169,154,169,
+ 'fill'=>'', 'tags'=>['floor2','room'])
+ $floorLabels2[i.id] = '219'
+ $floorItems2['219'] = i
+ w.create(TkcText,132.5,180, 'text'=>'219', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor2','label'])
+ i = TkcPolygon.new(w,375,246,375,172,341,172,341,246,
+ 'fill'=>'', 'tags'=>['floor2','room'])
+ $floorLabels2[i.id] = '201'
+ $floorItems2['201'] = i
+ w.create(TkcText,358,209, 'text'=>'201', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor2','label'])
+ w.create(TkcLine,641,186,678,186, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,757,350,757,367, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,634,133,634,144, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,634,144,627,144, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,572,133,572,144, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,572,144,579,144, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,398,129,398,162, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,174,197,175,197, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,175,197,175,227, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,757,206,757,221, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,396,188,408,188, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,727,189,725,189, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,747,167,802,167, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,747,167,747,189, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,755,189,739,189, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,769,224,757,224, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,802,224,802,129, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,802,129,725,129, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,725,189,725,129, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,725,186,690,186, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,676,133,676,186, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,627,144,627,186, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,629,186,593,186, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,579,144,579,186, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,559,129,559,133, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,725,133,559,133, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,484,162,484,129, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,559,129,484,129, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,526,129,526,186, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,540,186,581,186, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,528,186,523,186, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,511,186,475,186, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,496,190,496,186, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,496,205,496,202, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,475,205,527,205, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,558,205,539,205, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,558,205,558,249, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,558,249,475,249, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,662,206,642,206, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,695,206,675,206, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,695,278,642,278, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,642,291,642,206, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,695,291,695,206, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,716,208,716,206, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,757,206,716,206, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,757,221,757,224, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,793,224,802,224, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,757,262,716,262, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,716,220,716,264, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,716,315,716,276, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,757,315,703,315, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,757,325,757,224, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,757,367,644,367, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,689,367,689,315, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,647,315,644,315, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,659,315,691,315, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,600,325,600,391, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,627,325,644,325, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,644,391,644,315, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,615,325,575,325, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,644,391,558,391, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,563,325,558,325, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,558,391,558,314, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,558,327,508,327, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,558,275,484,275, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,558,302,558,275, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,508,327,508,311, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,484,311,508,311, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,484,275,484,311, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,475,208,408,208, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,408,206,408,210, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,408,222,408,227, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,408,227,398,227, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,398,227,398,254, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,408,188,408,194, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,383,188,376,188, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,398,188,398,162, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,398,162,484,162, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,475,162,475,254, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,398,254,475,254, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,484,280,395,280, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,395,311,395,275, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,307,197,293,197, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,278,197,233,197, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,233,197,233,249, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,307,179,284,179, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,233,249,278,249, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,269,179,269,133, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,220,179,220,133, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,155,191,110,191, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,90,190,98,190, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,98,169,98,190, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,52,133,52,165, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,52,214,52,177, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,52,226,52,262, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,52,274,52,276, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,234,275,234,339, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,226,339,258,339, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,211,387,211,339, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,214,339,177,339, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,258,387,60,387, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,3,133,3,339, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,165,339,129,339, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,117,339,80,339, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,68,339,59,339, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,0,339,46,339, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,60,391,0,391, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,0,339,0,391, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,60,387,60,391, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,258,329,258,387, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,350,329,258,329, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,395,311,350,311, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,398,129,315,129, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,176,133,315,133, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,176,129,96,129, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,3,133,96,133, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,66,387,66,339, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,115,387,115,339, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,163,387,163,339, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,234,275,276,275, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,288,275,309,275, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,298,275,298,329, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,341,283,350,283, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,321,275,341,275, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,375,275,395,275, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,315,129,315,170, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,376,170,307,170, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,307,250,307,170, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,376,245,376,170, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,340,241,307,241, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,340,245,340,224, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,340,210,340,201, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,340,187,340,170, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,340,206,307,206, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,293,250,307,250, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,271,179,238,179, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,226,179,195,179, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,176,129,176,179, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,182,179,176,179, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,174,169,176,169, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,162,169,90,169, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,96,169,96,129, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,175,227,90,227, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,90,190,90,227, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,52,179,3,179, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,52,228,3,228, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,52,276,3,276, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,155,177,155,169, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,110,191,110,169, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,155,189,155,197, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,350,283,350,329, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,162,197,155,197, 'fill'=>color, 'tags'=>['floor2','wall'])
+ w.create(TkcLine,341,275,341,283, 'fill'=>color, 'tags'=>['floor2','wall'])
+end
+
+# floor2_fg3 --
+# This method represents part of the floorplan database. When
+# invoked, it instantiates the foreground information for the third
+# floor (office outlines and numbers).
+#
+# Arguments:
+# w - The canvas window.
+# color - Color to use for drawing foreground information.
+
+def floor2_fg3(w,color)
+ i = TkcPolygon.new(w,89,228,89,180,70,180,70,228,
+ 'fill'=>'', 'tags'=>['floor3','room'])
+ $floorLabels2[i.id] = '316'
+ $floorItems2['316'] = i
+ w.create(TkcText,79.5,204, 'text'=>'316', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor3','label'])
+ i = TkcPolygon.new(w,115,368,162,368,162,323,115,323,
+ 'fill'=>'', 'tags'=>['floor3','room'])
+ $floorLabels2[i.id] = '309'
+ $floorItems2['309'] = i
+ w.create(TkcText,138.5,345.5, 'text'=>'309', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor3','label'])
+ i = TkcPolygon.new(w,164,323,164,368,211,368,211,323,
+ 'fill'=>'', 'tags'=>['floor3','room'])
+ $floorLabels2[i.id] = '308'
+ $floorItems2['308'] = i
+ w.create(TkcText,187.5,345.5, 'text'=>'308', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor3','label'])
+ i = TkcPolygon.new(w,256,368,212,368,212,323,256,323,
+ 'fill'=>'', 'tags'=>['floor3','room'])
+ $floorLabels2[i.id] = '307'
+ $floorItems2['307'] = i
+ w.create(TkcText,234,345.5, 'text'=>'307', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor3','label'])
+ i = TkcPolygon.new(w,244,276,297,276,297,327,260,327,260,321,244,321,
+ 'fill'=>'', 'tags'=>['floor3','room'])
+ $floorLabels2[i.id] = '305'
+ $floorItems2['305'] = i
+ w.create(TkcText,270.5,301.5, 'text'=>'305', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor3','label'])
+ i = TkcPolygon.new(w,251,219,251,203,244,203,244,219,
+ 'fill'=>'', 'tags'=>['floor3','room'])
+ $floorLabels2[i.id] = '324B'
+ $floorItems2['324B'] = i
+ w.create(TkcText,247.5,211, 'text'=>'324B', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor3','label'])
+ i = TkcPolygon.new(w,251,249,244,249,244,232,251,232,
+ 'fill'=>'', 'tags'=>['floor3','room'])
+ $floorLabels2[i.id] = '324A'
+ $floorItems2['324A'] = i
+ w.create(TkcText,247.5,240.5, 'text'=>'324A', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor3','label'])
+ i = TkcPolygon.new(w,223,135,223,179,177,179,177,135,
+ 'fill'=>'', 'tags'=>['floor3','room'])
+ $floorLabels2[i.id] = '320'
+ $floorItems2['320'] = i
+ w.create(TkcText,200,157, 'text'=>'320', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor3','label'])
+ i = TkcPolygon.new(w,114,368,114,323,67,323,67,368,
+ 'fill'=>'', 'tags'=>['floor3','room'])
+ $floorLabels2[i.id] = '310'
+ $floorItems2['310'] = i
+ w.create(TkcText,90.5,345.5, 'text'=>'310', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor3','label'])
+ i = TkcPolygon.new(w,23,277,23,321,68,321,68,277,
+ 'fill'=>'', 'tags'=>['floor3','room'])
+ $floorLabels2[i.id] = '312'
+ $floorItems2['312'] = i
+ w.create(TkcText,45.5,299, 'text'=>'312', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor3','label'])
+ i = TkcPolygon.new(w,23,229,68,229,68,275,23,275,
+ 'fill'=>'', 'tags'=>['floor3','room'])
+ $floorLabels2[i.id] = '313'
+ $floorItems2['313'] = i
+ w.create(TkcText,45.5,252, 'text'=>'313', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor3','label'])
+ i = TkcPolygon.new(w,68,227,23,227,23,180,68,180,
+ 'fill'=>'', 'tags'=>['floor3','room'])
+ $floorLabels2[i.id] = '314'
+ $floorItems2['314'] = i
+ w.create(TkcText,40.5,203.5, 'text'=>'314', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor3','label'])
+ i = TkcPolygon.new(w,95,179,95,135,23,135,23,179,
+ 'fill'=>'', 'tags'=>['floor3','room'])
+ $floorLabels2[i.id] = '315'
+ $floorItems2['315'] = i
+ w.create(TkcText,59,157, 'text'=>'315', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor3','label'])
+ i = TkcPolygon.new(w,99,226,99,204,91,204,91,226,
+ 'fill'=>'', 'tags'=>['floor3','room'])
+ $floorLabels2[i.id] = '316B'
+ $floorItems2['316B'] = i
+ w.create(TkcText,95,215, 'text'=>'316B', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor3','label'])
+ i = TkcPolygon.new(w,91,202,99,202,99,180,91,180,
+ 'fill'=>'', 'tags'=>['floor3','room'])
+ $floorLabels2[i.id] = '316A'
+ $floorItems2['316A'] = i
+ w.create(TkcText,95,191, 'text'=>'316A', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor3','label'])
+ i = TkcPolygon.new(w,97,169,109,169,109,192,154,192,154,198,
+ 174,198,174,226,101,226,101,179,97,179,
+ 'fill'=>'', 'tags'=>['floor3','room'])
+ $floorLabels2[i.id] = '319'
+ $floorItems2['319'] = i
+ w.create(TkcText,141.5,209, 'text'=>'319', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor3','label'])
+ i = TkcPolygon.new(w,65,368,58,368,58,389,1,389,1,333,23,333,23,323,65,323,
+ 'fill'=>'', 'tags'=>['floor3','room'])
+ $floorLabels2[i.id] = '311'
+ $floorItems2['311'] = i
+ w.create(TkcText,29.5,361, 'text'=>'311', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor3','label'])
+ i = TkcPolygon.new(w,154,191,111,191,111,169,154,169,
+ 'fill'=>'', 'tags'=>['floor3','room'])
+ $floorLabels2[i.id] = '318'
+ $floorItems2['318'] = i
+ w.create(TkcText,132.5,180, 'text'=>'318', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor3','label'])
+ i = TkcPolygon.new(w,175,168,97,168,97,131,175,131,
+ 'fill'=>'', 'tags'=>['floor3','room'])
+ $floorLabels2[i.id] = '317'
+ $floorItems2['317'] = i
+ w.create(TkcText,136,149.5, 'text'=>'317', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor3','label'])
+ i = TkcPolygon.new(w,274,194,274,221,306,221,306,194,
+ 'fill'=>'', 'tags'=>['floor3','room'])
+ $floorLabels2[i.id] = '323'
+ $floorItems2['323'] = i
+ w.create(TkcText,290,207.5, 'text'=>'323', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor3','label'])
+ i = TkcPolygon.new(w,306,222,274,222,274,249,306,249,
+ 'fill'=>'', 'tags'=>['floor3','room'])
+ $floorLabels2[i.id] = '325'
+ $floorItems2['325'] = i
+ w.create(TkcText,290,235.5, 'text'=>'325', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor3','label'])
+ i = TkcPolygon.new(w,263,179,224,179,224,135,263,135,
+ 'fill'=>'', 'tags'=>['floor3','room'])
+ $floorLabels2[i.id] = '321'
+ $floorItems2['321'] = i
+ w.create(TkcText,243.5,157, 'text'=>'321', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor3','label'])
+ i = TkcPolygon.new(w,314,169,306,169,306,192,273,192,
+ 264,181,264,135,314,135,
+ 'fill'=>'', 'tags'=>['floor3','room'])
+ $floorLabels2[i.id] = '322'
+ $floorItems2['322'] = i
+ w.create(TkcText,293.5,163.5, 'text'=>'322', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor3','label'])
+ i = TkcPolygon.new(w,307,240,339,240,339,206,307,206,
+ 'fill'=>'', 'tags'=>['floor3','room'])
+ $floorLabels2[i.id] = 'Pub Lift3'
+ $floorItems2['Pub Lift3'] = i
+ w.create(TkcText,323,223, 'text'=>'Pub Lift3', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor3','label'])
+ i = TkcPolygon.new(w,339,205,307,205,307,171,339,171,
+ 'fill'=>'', 'tags'=>['floor3','room'])
+ $floorLabels2[i.id] = 'Priv Lift3'
+ $floorItems2['Priv Lift3'] = i
+ w.create(TkcText,323,188, 'text'=>'Priv Lift3', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor3','label'])
+ i = TkcPolygon.new(w,350,284,376,284,376,276,397,276,397,309,350,309,
+ 'fill'=>'', 'tags'=>['floor3','room'])
+ $floorLabels2[i.id] = '303'
+ $floorItems2['303'] = i
+ w.create(TkcText,373.5,292.5, 'text'=>'303', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor3','label'])
+ i = TkcPolygon.new(w,272,203,272,249,252,249,252,230,
+ 244,230,244,221,252,221,252,203,
+ 'fill'=>'', 'tags'=>['floor3','room'])
+ $floorLabels2[i.id] = '324'
+ $floorItems2['324'] = i
+ w.create(TkcText,262,226, 'text'=>'324', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor3','label'])
+ i = TkcPolygon.new(w,299,276,299,327,349,327,349,284,341,284,341,276,
+ 'fill'=>'', 'tags'=>['floor3','room'])
+ $floorLabels2[i.id] = '304'
+ $floorItems2['304'] = i
+ w.create(TkcText,324,301.5, 'text'=>'304', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor3','label'])
+ i = TkcPolygon.new(w,375,246,375,172,341,172,341,246,
+ 'fill'=>'', 'tags'=>['floor3','room'])
+ $floorLabels2[i.id] = '301'
+ $floorItems2['301'] = i
+ w.create(TkcText,358,209, 'text'=>'301', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor3','label'])
+ i = TkcPolygon.new(w,397,246,377,246,377,185,397,185,
+ 'fill'=>'', 'tags'=>['floor3','room'])
+ $floorLabels2[i.id] = '327'
+ $floorItems2['327'] = i
+ w.create(TkcText,387,215.5, 'text'=>'327', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor3','label'])
+ i = TkcPolygon.new(w,316,131,316,169,377,169,377,185,397,185,397,131,
+ 'fill'=>'', 'tags'=>['floor3','room'])
+ $floorLabels2[i.id] = '326'
+ $floorItems2['326'] = i
+ w.create(TkcText,365.5,150, 'text'=>'326', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor3','label'])
+ i = TkcPolygon.new(w,308,251,242,251,242,274,342,274,342,282,375, 282,
+ 375,274,397,274,397,248,339,248,339,242,308,242,
+ 'fill'=>'', 'tags'=>['floor3','room'])
+ $floorLabels2[i.id] = '302'
+ $floorItems2['302'] = i
+ w.create(TkcText,319.5,261, 'text'=>'302', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor3','label'])
+ i = TkcPolygon.new(w,70,321,242,321,242,200,259,200,259,203,272,203,
+ 272,193,263,180,242,180,175,180,175,169,156,169,
+ 156,196,177,196,177,228,107,228,70,228,70,275,107,275,
+ 107,248,160,248,160,301,107,301,107,275,70,275,
+ 'fill'=>'', 'tags'=>['floor3','room'])
+ $floorLabels2[i.id] = '306'
+ $floorItems2['306'] = i
+ w.create(TkcText,200.5,284.5, 'text'=>'306', 'fill'=>color,
+ 'anchor'=>'c', 'tags'=>['floor3','label'])
+ w.create(TkcLine,341,275,341,283, 'fill'=>color, 'tags'=>['floor3','wall'])
+ w.create(TkcLine,162,197,155,197, 'fill'=>color, 'tags'=>['floor3','wall'])
+ w.create(TkcLine,396,247,399,247, 'fill'=>color, 'tags'=>['floor3','wall'])
+ w.create(TkcLine,399,129,399,311, 'fill'=>color, 'tags'=>['floor3','wall'])
+ w.create(TkcLine,258,202,243,202, 'fill'=>color, 'tags'=>['floor3','wall'])
+ w.create(TkcLine,350,283,350,329, 'fill'=>color, 'tags'=>['floor3','wall'])
+ w.create(TkcLine,251,231,243,231, 'fill'=>color, 'tags'=>['floor3','wall'])
+ w.create(TkcLine,243,220,251,220, 'fill'=>color, 'tags'=>['floor3','wall'])
+ w.create(TkcLine,243,250,243,202, 'fill'=>color, 'tags'=>['floor3','wall'])
+ w.create(TkcLine,155,197,155,190, 'fill'=>color, 'tags'=>['floor3','wall'])
+ w.create(TkcLine,110,192,110,169, 'fill'=>color, 'tags'=>['floor3','wall'])
+ w.create(TkcLine,155,192,110,192, 'fill'=>color, 'tags'=>['floor3','wall'])
+ w.create(TkcLine,155,177,155,169, 'fill'=>color, 'tags'=>['floor3','wall'])
+ w.create(TkcLine,176,197,176,227, 'fill'=>color, 'tags'=>['floor3','wall'])
+ w.create(TkcLine,69,280,69,274, 'fill'=>color, 'tags'=>['floor3','wall'])
+ w.create(TkcLine,21,276,69,276, 'fill'=>color, 'tags'=>['floor3','wall'])
+ w.create(TkcLine,69,262,69,226, 'fill'=>color, 'tags'=>['floor3','wall'])
+ w.create(TkcLine,21,228,69,228, 'fill'=>color, 'tags'=>['floor3','wall'])
+ w.create(TkcLine,21,179,75,179, 'fill'=>color, 'tags'=>['floor3','wall'])
+ w.create(TkcLine,69,179,69,214, 'fill'=>color, 'tags'=>['floor3','wall'])
+ w.create(TkcLine,90,220,90,227, 'fill'=>color, 'tags'=>['floor3','wall'])
+ w.create(TkcLine,90,204,90,202, 'fill'=>color, 'tags'=>['floor3','wall'])
+ w.create(TkcLine,90,203,100,203, 'fill'=>color, 'tags'=>['floor3','wall'])
+ w.create(TkcLine,90,187,90,179, 'fill'=>color, 'tags'=>['floor3','wall'])
+ w.create(TkcLine,90,227,176,227, 'fill'=>color, 'tags'=>['floor3','wall'])
+ w.create(TkcLine,100,179,100,227, 'fill'=>color, 'tags'=>['floor3','wall'])
+ w.create(TkcLine,100,179,87,179, 'fill'=>color, 'tags'=>['floor3','wall'])
+ w.create(TkcLine,96,179,96,129, 'fill'=>color, 'tags'=>['floor3','wall'])
+ w.create(TkcLine,162,169,96,169, 'fill'=>color, 'tags'=>['floor3','wall'])
+ w.create(TkcLine,173,169,176,169, 'fill'=>color, 'tags'=>['floor3','wall'])
+ w.create(TkcLine,182,179,176,179, 'fill'=>color, 'tags'=>['floor3','wall'])
+ w.create(TkcLine,176,129,176,179, 'fill'=>color, 'tags'=>['floor3','wall'])
+ w.create(TkcLine,195,179,226,179, 'fill'=>color, 'tags'=>['floor3','wall'])
+ w.create(TkcLine,224,133,224,179, 'fill'=>color, 'tags'=>['floor3','wall'])
+ w.create(TkcLine,264,179,264,133, 'fill'=>color, 'tags'=>['floor3','wall'])
+ w.create(TkcLine,238,179,264,179, 'fill'=>color, 'tags'=>['floor3','wall'])
+ w.create(TkcLine,273,207,273,193, 'fill'=>color, 'tags'=>['floor3','wall'])
+ w.create(TkcLine,273,235,273,250, 'fill'=>color, 'tags'=>['floor3','wall'])
+ w.create(TkcLine,273,224,273,219, 'fill'=>color, 'tags'=>['floor3','wall'])
+ w.create(TkcLine,273,193,307,193, 'fill'=>color, 'tags'=>['floor3','wall'])
+ w.create(TkcLine,273,222,307,222, 'fill'=>color, 'tags'=>['floor3','wall'])
+ w.create(TkcLine,273,250,307,250, 'fill'=>color, 'tags'=>['floor3','wall'])
+ w.create(TkcLine,384,247,376,247, 'fill'=>color, 'tags'=>['floor3','wall'])
+ w.create(TkcLine,340,206,307,206, 'fill'=>color, 'tags'=>['floor3','wall'])
+ w.create(TkcLine,340,187,340,170, 'fill'=>color, 'tags'=>['floor3','wall'])
+ w.create(TkcLine,340,210,340,201, 'fill'=>color, 'tags'=>['floor3','wall'])
+ w.create(TkcLine,340,247,340,224, 'fill'=>color, 'tags'=>['floor3','wall'])
+ w.create(TkcLine,340,241,307,241, 'fill'=>color, 'tags'=>['floor3','wall'])
+ w.create(TkcLine,376,247,376,170, 'fill'=>color, 'tags'=>['floor3','wall'])
+ w.create(TkcLine,307,250,307,170, 'fill'=>color, 'tags'=>['floor3','wall'])
+ w.create(TkcLine,376,170,307,170, 'fill'=>color, 'tags'=>['floor3','wall'])
+ w.create(TkcLine,315,129,315,170, 'fill'=>color, 'tags'=>['floor3','wall'])
+ w.create(TkcLine,376,283,366,283, 'fill'=>color, 'tags'=>['floor3','wall'])
+ w.create(TkcLine,376,283,376,275, 'fill'=>color, 'tags'=>['floor3','wall'])
+ w.create(TkcLine,399,275,376,275, 'fill'=>color, 'tags'=>['floor3','wall'])
+ w.create(TkcLine,341,275,320,275, 'fill'=>color, 'tags'=>['floor3','wall'])
+ w.create(TkcLine,341,283,350,283, 'fill'=>color, 'tags'=>['floor3','wall'])
+ w.create(TkcLine,298,275,298,329, 'fill'=>color, 'tags'=>['floor3','wall'])
+ w.create(TkcLine,308,275,298,275, 'fill'=>color, 'tags'=>['floor3','wall'])
+ w.create(TkcLine,243,322,243,275, 'fill'=>color, 'tags'=>['floor3','wall'])
+ w.create(TkcLine,243,275,284,275, 'fill'=>color, 'tags'=>['floor3','wall'])
+ w.create(TkcLine,258,322,226,322, 'fill'=>color, 'tags'=>['floor3','wall'])
+ w.create(TkcLine,212,370,212,322, 'fill'=>color, 'tags'=>['floor3','wall'])
+ w.create(TkcLine,214,322,177,322, 'fill'=>color, 'tags'=>['floor3','wall'])
+ w.create(TkcLine,163,370,163,322, 'fill'=>color, 'tags'=>['floor3','wall'])
+ w.create(TkcLine,165,322,129,322, 'fill'=>color, 'tags'=>['floor3','wall'])
+ w.create(TkcLine,84,322,117,322, 'fill'=>color, 'tags'=>['floor3','wall'])
+ w.create(TkcLine,71,322,64,322, 'fill'=>color, 'tags'=>['floor3','wall'])
+ w.create(TkcLine,115,322,115,370, 'fill'=>color, 'tags'=>['floor3','wall'])
+ w.create(TkcLine,66,322,66,370, 'fill'=>color, 'tags'=>['floor3','wall'])
+ w.create(TkcLine,52,322,21,322, 'fill'=>color, 'tags'=>['floor3','wall'])
+ w.create(TkcLine,21,331,0,331, 'fill'=>color, 'tags'=>['floor3','wall'])
+ w.create(TkcLine,21,331,21,133, 'fill'=>color, 'tags'=>['floor3','wall'])
+ w.create(TkcLine,96,133,21,133, 'fill'=>color, 'tags'=>['floor3','wall'])
+ w.create(TkcLine,176,129,96,129, 'fill'=>color, 'tags'=>['floor3','wall'])
+ w.create(TkcLine,315,133,176,133, 'fill'=>color, 'tags'=>['floor3','wall'])
+ w.create(TkcLine,315,129,399,129, 'fill'=>color, 'tags'=>['floor3','wall'])
+ w.create(TkcLine,399,311,350,311, 'fill'=>color, 'tags'=>['floor3','wall'])
+ w.create(TkcLine,350,329,258,329, 'fill'=>color, 'tags'=>['floor3','wall'])
+ w.create(TkcLine,258,322,258,370, 'fill'=>color, 'tags'=>['floor3','wall'])
+ w.create(TkcLine,60,370,258,370, 'fill'=>color, 'tags'=>['floor3','wall'])
+ w.create(TkcLine,60,370,60,391, 'fill'=>color, 'tags'=>['floor3','wall'])
+ w.create(TkcLine,0,391,0,331, 'fill'=>color, 'tags'=>['floor3','wall'])
+ w.create(TkcLine,60,391,0,391, 'fill'=>color, 'tags'=>['floor3','wall'])
+ w.create(TkcLine,307,250,307,242, 'fill'=>color, 'tags'=>['floor3','wall'])
+ w.create(TkcLine,273,250,307,250, 'fill'=>color, 'tags'=>['floor3','wall'])
+ w.create(TkcLine,258,250,243,250, 'fill'=>color, 'tags'=>['floor3','wall'])
+end
+
+# Below is the "main program" that creates the floorplan demonstration.
+
+# toplevel widget ãŒå­˜åœ¨ã™ã‚Œã°å‰Šé™¤ã™ã‚‹
+if defined?($floor2_demo) && $floor2_demo
+ $floor2_demo.destroy
+ $floor2_demo = nil
+end
+
+# demo 用㮠toplevel widget を生æˆ
+$floor2_demo = TkToplevel.new {|w|
+ title("Floorplan Canvas Demonstration 2")
+ iconname("Floorplan2")
+ positionWindow(w)
+ geometry('+20+20')
+ minsize(100,100)
+}
+
+base_frame = TkFrame.new($floor2_demo).pack(:fill=>:both, :expand=>true)
+
+# label 生æˆ
+TkLabel.new(base_frame, 'font'=>$font, 'wraplength'=>'8i', 'justify'=>'left',
+ 'text'=>"ã“ã®ã‚¦ã‚£ãƒ³ãƒ‰ã‚¦ã«ã¯ãƒ‡ã‚£ã‚¸ã‚¿ãƒ«ã‚¨ã‚¯ã‚¤ãƒƒãƒ—メント社ã®ã‚¦ã‚§ã‚¹ã‚¿ãƒ³ãƒªã‚µãƒ¼ãƒãƒ©ãƒœãƒ©ãƒˆãƒª (DECWRL) ã®é–“å–ã‚ŠãŒæ›¸ã‹ã‚ŒãŸã‚­ãƒ£ãƒ³ãƒã‚¹ widget ãŒå…¥ã£ã¦ã„ã¾ã™ã€‚ã“れ㯠3階建ã¦ã§ã€å¸¸ã«ãã®ã†ã¡ã®1階分ãŒé¸æŠžã€ã¤ã¾ã‚Šãã®é–“å–ã‚ŠãŒè¡¨ç¤ºã•ã‚Œã‚‹ã‚ˆã†ã«ãªã£ã¦ã„ã¾ã™ã€‚ã‚る階をé¸æŠžã™ã‚‹ã«ã¯ã€ãã®ä¸Šã§ãƒžã‚¦ã‚¹ã®å·¦ãƒœã‚¿ãƒ³ã‚’クリックã—ã¦ãã ã•ã„。マウスãŒé¸æŠžã•ã‚Œã¦ã„る階ã®ä¸Šã‚’å‹•ãã¨ã€ãã®ä¸‹ã«ã‚る部屋ã®è‰²ãŒå¤‰ã‚ã‚Šã€éƒ¨å±‹ç•ªå·ãŒã€Œéƒ¨å±‹ç•ªå·:ã€ã‚¨ãƒ³ãƒˆãƒªã«è¡¨ç¤ºã•ã‚Œã¾ã™ã€‚ã¾ãŸã€ã‚¨ãƒ³ãƒˆãƒªã«éƒ¨å±‹ç•ªå·ã‚’書ãã¨ãã®éƒ¨å±‹ã®è‰²ãŒå¤‰ã‚ã‚Šã¾ã™ã€‚"){
+ pack('side'=>'top')
+}
+
+# frame 生æˆ
+$floor2_buttons = TkFrame.new(base_frame) {|frame|
+ TkButton.new(frame) {
+ #text '了解'
+ text 'é–‰ã˜ã‚‹'
+ command proc{
+ tmppath = $floor2_demo
+ $floor2_demo = nil
+ tmppath.destroy
+ }
+ }.pack('side'=>'left', 'expand'=>'yes')
+
+ TkButton.new(frame) {
+ text 'コードå‚ç…§'
+ command proc{showCode 'floor2'}
+ }.pack('side'=>'left', 'expand'=>'yes')
+}
+$floor2_buttons.pack('side'=>'bottom', 'fill'=>'x', 'pady'=>'2m')
+
+# 変数設定
+$floorLabels2 = {}
+$floorItems2 = {}
+
+# canvas 設定
+if $tk_version =~ /^4\.[01]/
+ $floor2_canvas_frame = TkFrame.new(base_frame,'bd'=>2,'relief'=>'sunken',
+ 'highlightthickness'=>2)
+ $floor2_canvas = TkCanvas.new($floor2_canvas_frame,
+ 'width'=>900, 'height'=>500, 'borderwidth'=>0,
+ 'highlightthickness'=>0) {|c|
+ TkScrollbar.new(base_frame, 'orient'=>'horiz',
+ 'command'=>proc{|*args| c.xview(*args)}){|hs|
+ c.xscrollcommand(proc{|first,last| hs.set first,last})
+ pack('side'=>'bottom', 'fill'=>'x')
+ }
+ TkScrollbar.new(base_frame, 'command'=>proc{|*args| c.yview(*args)}){|vs|
+ c.yscrollcommand(proc{|first,last| vs.set first,last})
+ pack('side'=>'right', 'fill'=>'y')
+ }
+ }
+ $floor2_canvas_frame.pack('side'=>'top','fill'=>'both', 'expand'=>'yes')
+ $floor2_canvas.pack('expand'=>'yes', 'fill'=>'both')
+
+else
+ TkFrame.new(base_frame) {|f|
+ pack('side'=>'top', 'fill'=>'both', 'expand'=>'yes')
+
+ h = TkScrollbar.new(f, 'highlightthickness'=>0, 'orient'=>'horizontal')
+ v = TkScrollbar.new(f, 'highlightthickness'=>0, 'orient'=>'vertical')
+
+ TkFrame.new(f, 'bd'=>2, 'relief'=>'sunken') {|f1|
+ $floor2_canvas = TkCanvas.new(f1, 'width'=>900, 'height'=>500,
+ 'borderwidth'=>0,
+ 'highlightthickness'=>0) {
+ xscrollcommand(proc{|first,last| h.set first,last})
+ yscrollcommand(proc{|first,last| v.set first,last})
+ pack('expand'=>'yes', 'fill'=>'both')
+ }
+ grid('padx'=>1, 'pady'=>1, 'row'=>0, 'column'=>0,
+ 'rowspan'=>1, 'columnspan'=>1, 'sticky'=>'news')
+ }
+
+ v.grid('padx'=>1, 'pady'=>1, 'row'=>0, 'column'=>1,
+ 'rowspan'=>1, 'columnspan'=>1, 'sticky'=>'news')
+ h.grid('padx'=>1, 'pady'=>1, 'row'=>1, 'column'=>0,
+ 'rowspan'=>1, 'columnspan'=>1, 'sticky'=>'news')
+
+ TkGrid.rowconfigure(f, 0, 'weight'=>1, 'minsize'=>0)
+ TkGrid.columnconfigure(f, 0, 'weight'=>1, 'minsize'=>0)
+
+ pack('expand'=>'yes', 'fill'=>'both', 'padx'=>1, 'pady'=>1)
+
+ v.command(proc{|*args| $floor2_canvas.yview(*args)})
+ h.command(proc{|*args| $floor2_canvas.xview(*args)})
+ }
+end
+
+# Create an entry for displaying and typing in current room.
+
+$currentRoom2 = TkVariable.new
+$floor2_entry = TkEntry.new($floor2_canvas, 'width'=>10, 'relief'=>'sunken',
+ 'bd'=>2, 'textvariable'=>$currentRoom2)
+
+# Choose colors, then fill in the floorplan.
+
+$floor2_colors = {}
+if TkWinfo.depth($floor2_canvas) > 1
+ $floor2_colors['bg1'] = '#a9c1da'
+ $floor2_colors['outline1'] = '#77889a'
+ $floor2_colors['bg2'] = '#9ab0c6'
+ $floor2_colors['outline2'] = '#687786'
+ $floor2_colors['bg3'] = '#8ba0b3'
+ $floor2_colors['outline3'] = '#596673'
+ $floor2_colors['offices'] = 'Black'
+ $floor2_colors['active'] = '#c4d1df'
+else
+ $floor2_colors['bg1'] = 'white'
+ $floor2_colors['outline1'] = 'black'
+ $floor2_colors['bg2'] = 'white'
+ $floor2_colors['outline2'] = 'black'
+ $floor2_colors['bg3'] = 'white'
+ $floor2_colors['outline3'] = 'black'
+ $floor2_colors['offices'] = 'Black'
+ $floor2_colors['active'] = 'black'
+end
+
+$activeFloor2 = ''
+floorDisplay2 $floor2_canvas,3
+
+# Set up event bindings for canvas:
+
+$floor2_canvas.itembind('floor1', '1', proc{floorDisplay2 $floor2_canvas,1})
+$floor2_canvas.itembind('floor2', '1', proc{floorDisplay2 $floor2_canvas,2})
+$floor2_canvas.itembind('floor3', '1', proc{floorDisplay2 $floor2_canvas,3})
+$floor2_canvas.itembind('room', 'Enter', proc{newRoom2 $floor2_canvas})
+$floor2_canvas.itembind('room', 'Leave', proc{$currentRoom2.value = ''})
+$floor2_canvas.bind('2', proc{|x,y| $floor2_canvas.scan_mark x,y}, '%x %y')
+$floor2_canvas.bind('B2-Motion',
+ proc{|x,y| $floor2_canvas.scan_dragto x,y}, '%x %y')
+$floor2_canvas.bind('Destroy', proc{$currentRoom2.unset})
+$currentRoom2.value = ''
+$currentRoom2.trace('w',proc{roomChanged2 $floor2_canvas})
diff --git a/jni/ruby/ext/tk/sample/demos-jp/form.rb b/jni/ruby/ext/tk/sample/demos-jp/form.rb
new file mode 100644
index 0000000..000fcb5
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/demos-jp/form.rb
@@ -0,0 +1,66 @@
+# -*- coding: utf-8 -*-
+#
+# form widget demo (called by 'widget')
+#
+
+# toplevel widget ãŒå­˜åœ¨ã™ã‚Œã°å‰Šé™¤ã™ã‚‹
+if defined?($form_demo) && $form_demo
+ $form_demo.destroy
+ $form_demo = nil
+end
+
+# demo 用㮠toplevel widget を生æˆ
+$form_demo = TkToplevel.new {|w|
+ title("Form Demonstration")
+ iconname("form")
+ positionWindow(w)
+}
+
+base_frame = TkFrame.new($form_demo).pack(:fill=>:both, :expand=>true)
+
+# label 生æˆ
+msg = TkLabel.new(base_frame) {
+ font $font
+ wraplength '4i'
+ justify 'left'
+ text "ã“ã®ã‚¦ã‚£ãƒ³ãƒ‰ã‚¦ã¯ç°¡å˜ãªãƒ•ã‚©ãƒ¼ãƒ å…¥åŠ›ç”¨ã«ãªã£ã¦ã„ã¦ã€ã•ã¾ã–ã¾ãªã‚¨ãƒ³ãƒˆãƒªã«å…¥åŠ›ãŒã§ãã¾ã™ã€‚タブã§ã‚¨ãƒ³ãƒˆãƒªã®åˆ‡æ›¿ãˆãŒã§ãã¾ã™ã€‚"
+}
+msg.pack('side'=>'top', 'fill'=>'x')
+
+# frame 生æˆ
+TkFrame.new(base_frame) {|frame|
+ TkButton.new(frame) {
+ #text '了解'
+ text 'é–‰ã˜ã‚‹'
+ command proc{
+ tmppath = $form_demo
+ $form_demo = nil
+ tmppath.destroy
+ }
+ }.pack('side'=>'left', 'expand'=>'yes')
+
+ TkButton.new(frame) {
+ text 'コードå‚ç…§'
+ command proc{showCode 'form'}
+ }.pack('side'=>'left', 'expand'=>'yes')
+}.pack('side'=>'bottom', 'fill'=>'x', 'pady'=>'2m')
+
+# entry 生æˆ
+form_data = []
+(1..5).each{|i|
+ f = TkFrame.new(base_frame, 'bd'=>2)
+ e = TkEntry.new(f, 'relief'=>'sunken', 'width'=>40)
+ l = TkLabel.new(f)
+ e.pack('side'=>'right')
+ l.pack('side'=>'left')
+ form_data[i] = {'frame'=>f, 'entry'=>e, 'label'=>l}
+}
+
+# 文字列設定
+form_data[1]['label'].text('åå‰:')
+form_data[2]['label'].text('ä½æ‰€:')
+form_data[5]['label'].text('電話:')
+
+# pack
+(1..5).each{|i| form_data[i]['frame'].pack('side'=>'top', 'fill'=>'x')}
+
diff --git a/jni/ruby/ext/tk/sample/demos-jp/goldberg.rb b/jni/ruby/ext/tk/sample/demos-jp/goldberg.rb
new file mode 100644
index 0000000..fc38d87
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/demos-jp/goldberg.rb
@@ -0,0 +1,2011 @@
+# -*- coding: utf-8 -*-
+#
+# Ruby/Tk Goldverg demo (called by 'widget')
+#
+# Based on Tcl/Tk8.5a2 widget demos.
+# The following is the original comment of TkGoldberg.tcl.
+#
+#>>##+#################################################################
+#>>#
+#>># TkGoldberg.tcl
+#>># by Keith Vetter, March 13, 2003
+#>>#
+#>># "Man will always find a difficult means to perform a simple task"
+#>># Rube Goldberg
+#>>#
+#>># Reproduced here with permission.
+#>>#
+#>>##+#################################################################
+#>>#
+#>># Keith Vetter 2003-03-21: this started out as a simple little program
+#>># but was so much fun that it grew and grew. So I apologize about the
+#>># size but I just couldn't resist sharing it.
+#>>#
+#>># This is a whizzlet that does a Rube Goldberg type animation, the
+#>># design of which comes from an New Years e-card from IncrediMail.
+#>># That version had nice sound effects which I eschewed. On the other
+#>># hand, that version was in black and white (actually dark blue and
+#>># light blue) and this one is fully colorized.
+#>>#
+#>># One thing I learned from this project is that drawing filled complex
+#>># objects on a canvas is really hard. More often than not I had to
+#>># draw each item twice--once with the desired fill color but no
+#>># outline, and once with no fill but with the outline. Another trick
+#>># is erasing by drawing with the background color. Having a flood fill
+#>># command would have been extremely helpful.
+#>>#
+#>># Two wiki pages were extremely helpful: Drawing rounded rectangles
+#>># which I generalized into Drawing rounded polygons, and regular
+#>># polygons which allowed me to convert ovals and arcs into polygons
+#>># which could then be rotated (see Canvas Rotation). I also wrote
+#>># Named Colors to aid in the color selection.
+#>>#
+#>># I could comment on the code, but it's just 26 state machines with
+#>># lots of canvas create and move calls.
+
+if defined?($goldberg_demo) && $goldberg_demo
+ $goldberg_demo.destroy
+ $goldberg_demo = nil
+end
+
+# demo toplevel widget
+$goldberg_demo = TkToplevel.new {|w|
+ title("Tk Goldberg (demonstration)")
+ iconname("goldberg")
+# positionWindow(w)
+}
+
+base_frame = TkFrame.new($goldberg_demo).pack(:fill=>:both, :expand=>true)
+
+=begin
+# label
+msg = TkLabel.new($goldberg_demo) {
+ font 'Arial 10'
+ wraplength '4i'
+ justify 'left'
+ text "ã“ã‚Œã¯ã€ã‚ãªãŸãŒè‡ªåˆ†ã®ã‚¢ãƒ‹ãƒ¡ãƒ¼ã‚·ãƒ§ãƒ³ã‚’ã„ã‹ã«å…¥ã‚Šçµ„ã‚“ã ã‚‚ã®ã«ã§ãã‚‹ã‹ã‚’示ã™ã¨ã„ã†ã ã‘ã®ãŸã‚ã®ãƒ‡ãƒ¢ã§ã™ã€‚ボールをクリックã™ã‚Œã°ç‰©ãŒå‹•ã始ã‚ã¾ã™ï¼\n\n\"Man will always find a difficult means to perform a simple task\"\n - Rube Goldberg"
+}
+msg.pack('side'=>'top')
+=end
+
+=begin
+# frame
+TkFrame.new($goldberg_demo) {|frame|
+ TkButton.new(frame) {
+ text 'é–‰ã˜ã‚‹'
+ command proc{
+ tmppath = $goldberg_demo
+ $goldberg_demo = nil
+ tmppath.destroy
+ }
+ }.pack('side'=>'left', 'expand'=>'yes')
+
+ TkButton.new(frame) {
+ text 'コードå‚ç…§'
+ command proc{showCode 'goldberg'}
+ }.pack('side'=>'left', 'expand'=>'yes')
+
+}.pack('side'=>'bottom', 'fill'=>'x', 'pady'=>'2m')
+=end
+
+#########################################
+
+class TkGoldberg_Demo
+ def initialize(parent)
+ @parent = parent
+
+ @S = {}
+ @S['title'] = 'Tk Goldberg'
+ @S['speed'] = TkVariable.new(5)
+ @S['cnt'] = TkVariable.new(0)
+ # @S['message'] = TkVariable.new("\\nWelcome\\nto\\nRuby/Tk")
+ @S['message'] = TkVariable.new("\\n よã†ã“ãï¼\\nRuby/Tk\\nã®\\n世界ã¸")
+ @S['pause'] = TkVariable.new
+ @S['details'] = TkVariable.new(true)
+
+ @S['mode'] = TkVariable.new(:MSTART, :symbol)
+ # :MSTART, :MGO, :MPAUSE, :MSSTEP, :MBSTEP, :MDONE, :MDEBUG
+
+ # 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10
+ @speed = [1, 10, 20, 50, 80, 100, 150, 200, 300, 400, 500]
+
+ # colors
+ @C = {}
+ @C['fg'] = 'black'
+ # @C['bg'] = 'gray75'
+ @C['bg'] = 'cornflowerblue'
+
+ @C['0'] = 'white'; @C['1a'] = 'darkgreen'; @C['1b'] = 'yellow'
+ @C['2'] = 'red'; @C['3a'] = 'green'; @C['3b'] = 'darkblue'
+ @C['4'] = @C['fg']; @C['5a'] = 'brown'; @C['5b'] = 'white'
+ @C['6'] = 'magenta'; @C['7'] = 'green'; @C['8'] = @C['fg']
+ @C['9'] = 'blue4'; @C['10a'] = 'white'; @C['10b'] = 'cyan'
+ @C['11a'] = 'yellow'; @C['11b'] = 'mediumblue'; @C['12'] = 'tan2'
+ @C['13a'] = 'yellow'; @C['13b'] = 'red'; @C['14'] = 'white'
+ @C['15a'] = 'green'; @C['15b'] = 'yellow'; @C['16'] = 'gray65'
+ @C['17'] = '#A65353'; @C['18'] = @C['fg']; @C['19'] = 'gray50'
+ @C['20'] = 'cyan'; @C['21'] = 'gray65'; @C['22'] = @C['20']
+ @C['23a'] = 'blue'; @C['23b'] = 'red'; @C['23c'] = 'yellow'
+ @C['24a'] = 'red'; @C['24b'] = 'white';
+
+ @STEP = TkVariable.new_hash
+ @STEP.default_value_type = :numeric
+
+ @XY = {}
+
+ @XY6 = {
+ '-1'=>[366, 207], '-2'=>[349, 204], '-3'=>[359, 193], '-4'=>[375, 192],
+ '-5'=>[340, 190], '-6'=>[349, 177], '-7'=>[366, 177], '-8'=>[380, 176],
+ '-9'=>[332, 172], '-10'=>[342, 161], '-11'=>[357, 164],
+ '-12'=>[372, 163], '-13'=>[381, 149], '-14'=>[364, 151],
+ '-15'=>[349, 146], '-16'=>[333, 148], '0'=>[357, 219],
+ '1'=>[359, 261], '2'=>[359, 291], '3'=>[359, 318], '4'=>[361, 324],
+ '5'=>[365, 329], '6'=>[367, 334], '7'=>[367, 340], '8'=>[366, 346],
+ '9'=>[364, 350], '10'=>[361, 355], '11'=>[359, 370], '12'=>[359, 391],
+ '13,0'=>[360, 456], '13,1'=>[376, 456], '13,2'=>[346, 456],
+ '13,3'=>[330, 456], '13,4'=>[353, 444], '13,5'=>[368, 443],
+ '13,6'=>[339, 442], '13,7'=>[359, 431], '13,8'=>[380, 437],
+ '13,9'=>[345, 428], '13,10'=>[328, 434], '13,11'=>[373, 424],
+ '13,12'=>[331, 420], '13,13'=>[360, 417], '13,14'=>[345, 412],
+ '13,15'=>[376, 410], '13,16'=>[360, 403]
+ }
+
+ @timer = TkTimer.new(@speed[@S['speed'].numeric]){|timer|
+ timer.set_interval(go)
+ }
+
+ do_display
+ reset
+
+ # Start everything going
+ @timer.start
+ end
+
+ def do_display()
+ @ctrl = TkFrame.new(@parent, :relief=>:ridge, :bd=>2, :padx=>5, :pady=>5)
+ @screen = TkFrame.new(@parent, :bd=>2,
+ :relief=>:raised).pack(:side=>:left, :fill=>:both,
+ :expand=>true)
+
+ @canvas = TkCanvas.new(@parent, :width=>850, :height=>700,
+ :bg=>@C['bg'], :highlightthickness=>0){
+ scrollregion([0, 0, 1000, 1000]) # Kludge to move everything up
+ yview_moveto(0.05)
+ }.pack(:in=>@screen, :side=>:top, :fill=>:both, :expand=>true)
+
+ @canvas.bind('3'){ @pause.invoke }
+ @canvas.bind('Destroy'){ @timer.stop }
+
+ do_ctrl_frame
+ do_detail_frame
+
+ # msg = TkLabel.new(@parent, :bg=>@C['bg'], :fg=>'white') {
+ msg = Tk::Label.new(@parent, :bg=>@C['bg'], :fg=>'white') {
+ font 'Arial 10'
+ wraplength 600
+ justify 'left'
+ text "ã“ã‚Œã¯ã€ã‚ãªãŸãŒè‡ªåˆ†ã®ã‚¢ãƒ‹ãƒ¡ãƒ¼ã‚·ãƒ§ãƒ³ã‚’ã„ã‹ã«å…¥ã‚Šçµ„ã‚“ã ã‚‚ã®ã«ã§ãã‚‹ã‹ã‚’示ã™ã¨ã„ã†ã ã‘ã®ãŸã‚ã®ãƒ‡ãƒ¢ã§ã™ã€‚ボールをクリックã™ã‚Œã°ç‰©ãŒå‹•ã始ã‚ã¾ã™ï¼\n\"Man will always find a difficult means to perform a simple task\" - Rube Goldberg"
+ }
+ msg.place(:in=>@canvas, :relx=>0, :rely=>0, :anchor=>:nw)
+
+ frame = TkFrame.new(@parent, :bg=>@C['bg'])
+
+ # TkButton.new(frame, :bg=>@C['bg'], :activebackground=>@C['bg']) {
+ Tk::Button.new(frame, :bg=>@C['bg'], :activebackground=>@C['bg']) {
+ text 'é–‰ã˜ã‚‹'
+ command proc{
+ tmppath = $goldberg_demo
+ $goldberg_demo = nil
+ tmppath.destroy
+ }
+ }.pack('side'=>'left')
+
+ # TkButton.new(frame, :bg=>@C['bg'], :activebackground=>@C['bg']) {
+ Tk::Button.new(frame, :bg=>@C['bg'], :activebackground=>@C['bg']) {
+ text 'コードå‚ç…§'
+ command proc{showCode 'goldberg'}
+ }.pack('side'=>'left', 'padx'=>5)
+
+ # @show = TkButton.new(frame, :text=>'>>', :command=>proc{show_ctrl},
+ @show = Tk::Button.new(frame, :text=>'>>', :command=>proc{show_ctrl},
+ :bg=>@C['bg'], :activebackground=>@C['bg'])
+ @show.pack('side'=>'left')
+ frame.place(:in=>@canvas, :relx=>1, :rely=>0, :anchor=>:ne)
+
+ Tk.update
+ end
+
+ def do_ctrl_frame
+ @start = Tk::Button.new(@parent, :text=>'Start', :bd=>6,
+ :command=>proc{do_button(0)})
+ if font = @start['font']
+ @start.font(font.weight('bold'))
+ end
+
+ @pause = TkCheckbutton.new(@parent, :text=>'Pause', :font=>font,
+ :command=>proc{do_button(1)}, :relief=>:raised,
+ :variable=>@S['pause'])
+
+ @step = TkButton.new(@parent, :text=>'Single Step', :font=>font,
+ :command=>proc{do_button(2)})
+ @bstep = TkButton.new(@parent, :text=>'Big Step', :font=>font,
+ :command=>proc{do_button(4)})
+ @reset = TkButton.new(@parent, :text=>'Reset', :font=>font,
+ :command=>proc{do_button(3)})
+
+ @details = TkFrame.new(@parent, :bd=>2, :relief=>:ridge)
+ @detail = TkCheckbutton.new(@parent, :text=>'Details', :font=>font,
+ :relief=>:raised, :variable=>@S['details'])
+
+ @msg_entry = TkEntry.new(@parent, :textvariable=>@S['message'],
+ :justify=>:center)
+ @speed_scale = TkScale.new(@parent, :orient=>:horizontal,
+ :from=>1, :to=>10, :font=>font,
+ :variable=>@S['speed'], :bd=>2,
+ :relief=>:ridge, :showvalue=>false)
+ @about = TkButton.new(@parent, :text=>'About',
+ :command=>proc{about}, :font=>font)
+
+ Tk.grid(@start, :in=>@ctrl, :row=>0, :sticky=>:ew)
+ @ctrl.grid_rowconfigure(1, :minsize=>10)
+ Tk.grid(@pause, :in=>@ctrl, :row=>2, :sticky=>:ew)
+ Tk.grid(@step, :in=>@ctrl, :sticky=>:ew)
+ Tk.grid(@bstep, :in=>@ctrl, :sticky=>:ew)
+ Tk.grid(@reset, :in=>@ctrl, :sticky=>:ew)
+ @ctrl.grid_rowconfigure(10, :minsize=>20)
+ Tk.grid(@details, :in=>@ctrl, :row=>11, :sticky=>:ew)
+ Tk.grid(@detail, :in=>@details, :row=>0, :sticky=>:ew)
+ @ctrl.grid_rowconfigure(50, :weight=>1)
+
+ @S['mode'].trace('w', proc{|*args| active_GUI(*args)})
+ @S['details'].trace('w', proc{|*args| active_GUI(*args)})
+ @S['speed'].trace('w', proc{|*args| active_GUI(*args)})
+
+ Tk.grid(@msg_entry, :in=>@ctrl, :row=>98, :sticky=>:ew, :pady=>5)
+ Tk.grid(@speed_scale, :in=>@ctrl, :row=>99, :sticky=>:ew)
+ Tk.grid(@about, :in=>@ctrl, :row=>100, :sticky=>:ew)
+
+ @reset.bind('3'){@S['mode'].value = -1} # Debugging
+ end
+
+ def do_detail_frame
+ @f_details = TkFrame.new(@details)
+
+ @label = TkLabel.new(@f_details, :textvariable=>@S['cnt'],
+ :bd=>1, :relief=>:solid, :bg=>'white')
+ Tk.grid(@label, '-', '-', '-', :sticky=>:ew, :row=>0)
+
+ idx = 1
+ loop {
+ break unless respond_to?("move#{idx}")
+ l = TkLabel.new(@f_details, :text=>idx, :anchor=>:e,
+ :width=>2, :bd=>1, :relief=>:solid, :bg=>'white')
+ @STEP[idx] = 0
+ ll = TkLabel.new(@f_details, :textvariable=>@STEP.ref(idx),
+ :width=>5, :bd=>1, :relief=>:solid, :bg=>'white')
+ row = (idx + 1)/2
+ col = ((idx + 1) & 1) * 2
+ Tk.grid(l, :sticky=>:ew, :row=>row, :column=>col)
+ Tk.grid(ll, :sticky=>:ew, :row=>row, :column=>(col + 1))
+ idx += 1
+ }
+ @f_details.grid_columnconfigure(1, :weight=>1)
+ end
+
+ def show_ctrl
+ if @ctrl.winfo_mapped?
+ @ctrl.pack_forget
+ @show.text('>>')
+ else
+ @ctrl.pack(:side=>:right, :fill=>:both, :ipady=>5)
+ @show.text('<<')
+ end
+ end
+
+ def draw_all
+ reset_step
+ @canvas.delete(:all)
+ idx = 0
+ loop{
+ m = "draw#{idx}"
+ break unless respond_to?(m)
+ send(m)
+ idx += 1
+ }
+ end
+
+ def active_GUI(var1, var2, op)
+ st = {false=>:disabled, true=>:normal}
+
+ m = @S['mode'].to_sym
+ @S['pause'].value = (m == :MPAUSE)
+ @start.state(st[m != :MGO])
+ @pause.state(st[m != :MSTART && m != :MDONE])
+ @step.state(st[m != :MGO && m != :MDONE])
+ @bstep.state(st[m != :MGO && m != :MDONE])
+ @reset.state(st[m != :MSTART])
+
+ if @S['details'].bool
+ Tk.grid(@f_details, :in=>@details, :row=>2, :sticky=>:ew)
+ else
+ Tk.grid_forget(@f_details)
+ end
+ @speed_scale.label("Speed: #{@S['speed'].value}")
+ end
+
+ def start
+ @S['mode'].value = :MGO
+ end
+
+ def do_button(what)
+ case what
+ when 0 # Start
+ reset if @S['mode'].to_sym == :MDONE
+ @S['mode'].value = :MGO
+
+ when 1 # Pause
+ @S['mode'].value = ((@S['pause'].bool)? :MPAUSE: :MGO)
+
+ when 2 # Step
+ @S['mode'].value = :MSSTEP
+
+ when 3 # Reset
+ reset
+
+ when 4 # Big step
+ @S['mode'].value = :MBSTEP
+ end
+ end
+
+ def go(who = nil)
+ now = Tk::Clock.clicks(:miliseconds)
+ if who # Start here for debugging
+ @S['active'] = [who]
+ @S['mode'].value = :MGO
+ end
+ return if @S['mode'].to_sym == :MDEBUG # Debugging
+ # If not paused, do the next move
+ n = next_step if @S['mode'].to_sym != :MPAUSE
+ @S['mode'].value = :MPAUSE if @S['mode'].to_sym == :MSSTEP # Single step
+ @S['mode'].value = :MSSTEP if @S['mode'].to_sym == :MBSTEP && n # big step
+ elapsed = Tk::Clock.clicks(:miliseconds) - now
+ delay = @speed[@S['speed'].to_i] - elapsed
+ delay = 1 if delay <= 0
+ return delay
+ end
+
+ def next_step
+ retval = false # Return value
+
+ if @S['mode'].to_sym != :MSTART && @S['mode'].to_sym != :MDONE
+ @S['cnt'].numeric += 1
+ end
+ alive = []
+ @S['active'].each{|who|
+ who = who.to_i
+ n = send("move#{who}")
+ if (n & 1).nonzero? # This guy still alive
+ alive << who
+ end
+ if (n & 2).nonzero? # Next guy is active
+ alive << (who + 1)
+ retval = true
+ end
+ if (n & 4).nonzero? # End of puzzle flag
+ @S['mode'].value = :MDONE # Done mode
+ @S['active'] = [] # No more animation
+ return true
+ end
+ }
+ @S['active'] = alive
+ return retval
+ end
+
+ def about
+ msg = "Ruby/Tk Version ::\nby Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)\n\n"
+ msg += "Original Version ::\n"
+ msg += "#{@S['title']}\nby Keith Vetter, March 2003\n(Reproduced by kind permission of the author)\n\n"
+ msg += "Man will always find a difficult means to perform a simple task"
+ msg += "\nRube Goldberg"
+ Tk.messageBox(:message=>msg, :title=>'About')
+ end
+
+ ################################################################
+ #
+ # All the drawing and moving routines
+ #
+
+ # START HERE! banner
+ def draw0
+ color = @C['0']
+ TkcText.new(@canvas,
+ # [579, 119], :text=>'START HERE!',
+ [558, 119], :text=>'ã“ã“ã‹ã‚‰ã‚¹ã‚¿ãƒ¼ãƒˆï¼',
+ :fill=>color, :anchor=>:w,
+ :tag=>'I0', :font=>['Times Roman', 12, :italic, :bold])
+ TkcLine.new(@canvas, [719, 119, 763, 119], :tag=>'I0', :fill=>color,
+ :width=>5, :arrow=>:last, :arrowshape=>[18, 18, 5])
+ @canvas.itembind('I0', '1'){ start }
+ end
+
+ def move0(step = nil)
+ step = get_step(0, step)
+
+ if @S['mode'].to_sym != :MSTART # Start the ball rolling
+ move_abs('I0', [-100, -100]) # Hide the banner
+ return 2
+ end
+
+ pos = [
+ [673, 119], [678, 119], [683, 119], [688, 119],
+ [693, 119], [688, 119], [683, 119], [678, 119]
+ ]
+ step = step % pos.length
+ move_abs('I0', pos[step])
+ return 1
+ end
+
+ # Dropping ball
+ def draw1
+ color = @C['1a']
+ color2 = @C['1b']
+ TkcPolygon.new(@canvas,
+ [ 844, 133, 800, 133, 800, 346, 820, 346,
+ 820, 168, 844, 168, 844, 133 ],
+ :width=>3, :fill=>color, :outline=>'')
+ TkcPolygon.new(@canvas,
+ [ 771, 133, 685, 133, 685, 168, 751, 168,
+ 751, 346, 771, 346, 771, 133 ],
+ :width=>3, :fill=>color, :outline=>'')
+ TkcOval.new(@canvas, box(812, 122, 9),
+ :tag=>'I1', :fill=>color2, :outline=>'')
+
+ @canvas.itembind('I1', '1'){ start }
+ end
+
+ def move1(step = nil)
+ step = get_step(1, step)
+ pos = [
+ [807, 122], [802, 122], [797, 123], [793, 124], [789, 129], [785, 153],
+ [785, 203], [785, 278, :x], [785, 367], [810, 392], [816, 438],
+ [821, 503], [824, 585, :y], [838, 587], [848, 593], [857, 601],
+ [-100, -100]
+ ]
+ return 0 if step >= pos.length
+ where = pos[step]
+ move_abs('I1', where)
+ move15a if where[2] == :y
+ return 3 if where[2] == :x
+ return 1
+ end
+
+ # Lighting the match
+ def draw2
+ color = @C['2']
+
+ # Fulcrum
+ TkcPolygon.new(@canvas, [750, 369, 740, 392, 760, 392],
+ :fill=>@C['fg'], :outline=>@C['fg'])
+
+ # Strike box
+ TkcRectangle.new(@canvas, [628, 335, 660, 383],
+ :fill=>'', :outline=>@C['fg'])
+ (0..2).each{|y|
+ yy = 335 + y*16
+ TkcBitmap.new(@canvas, [628, yy], :bitmap=>'gray25',
+ :anchor=>:nw, :foreground=>@C['fg'])
+ TkcBitmap.new(@canvas, [644, yy], :bitmap=>'gray25',
+ :anchor=>:nw, :foreground=>@C['fg'])
+ }
+
+ # Lever
+ TkcLine.new(@canvas, [702, 366, 798, 366],
+ :fill=>@C['fg'], :width=>6, :tag=>'I2_0')
+
+ # R strap
+ TkcLine.new(@canvas, [712, 363, 712, 355],
+ :fill=>@C['fg'], :width=>3, :tag=>'I2_1')
+
+ # L strap
+ TkcLine.new(@canvas, [705, 363, 705, 355],
+ :fill=>@C['fg'], :width=>3, :tag=>'I2_2')
+
+ # Match stick
+ TkcLine.new(@canvas, [679, 356, 679, 360, 717, 360, 717, 356, 679, 356],
+ :fill=>@C['fg'], :width=>3, :tag=>'I2_3')
+
+ # Match head
+ TkcPolygon.new(@canvas,
+ [ 671, 352, 677.4, 353.9, 680, 358.5, 677.4, 363.1,
+ 671, 365, 664.6, 363.1, 662, 358.5, 664.6, 353.9 ],
+ :fill=>color, :outline=>color, :tag=>'I2_4')
+ end
+
+ def move2(step = nil)
+ step = get_step(2, step)
+
+ stages = [0, 0, 1, 2, 0, 2, 1, 0, 1, 2, 0, 2, 1]
+ xy = []
+ xy[0] = [
+ 686, 333, 692, 323, 682, 316, 674, 309, 671, 295, 668, 307,
+ 662, 318, 662, 328, 671, 336
+ ]
+ xy[1] = [
+ 687, 331, 698, 322, 703, 295, 680, 320, 668, 297, 663, 311,
+ 661, 327, 671, 335
+ ]
+ xy[2] = [
+ 686, 331, 704, 322, 688, 300, 678, 283, 678, 283, 674, 298,
+ 666, 309, 660, 324, 672, 336
+ ]
+
+ if step >= stages.length
+ @canvas.delete('I2')
+ return 0
+ end
+
+ if step == 0 # Rotate the match
+ beta = 20
+
+ ox, oy = anchor('I2_0', :s) # Where to pivot
+
+ i = 0
+ until @canvas.find_withtag("I2_#{i}").empty?
+ rotate_item("I2_#{i}", ox, oy, beta)
+ i += 1
+ end
+
+ # For the flame
+ TkcPolygon.new(@canvas, [], :tag=>'I2', :smooth=>true, :fill=>@C['2'])
+
+ return 1
+ end
+ @canvas.coords('I2', xy[stages[step]])
+ return ((step == 7)? 3: 1)
+ end
+
+ # Weight and pulleys
+ def draw3
+ color = @C['3a']
+ color2 = @C['3b']
+
+ xy = [ [602, 296], [577, 174], [518, 174] ]
+ xy.each{|x, y| # 3 Pulleys
+ TkcOval.new(@canvas, box(x, y, 13),
+ :fill=>color, :outline=>@C['fg'], :width=>3)
+ TkcOval.new(@canvas, box(x, y, 2), :fill=>@C['fg'], :outline=>@C['fg'])
+ }
+
+ # Wall to flame
+ TkcLine.new(@canvas, [750, 309, 670, 309], :tag=>'I3_s',
+ :width=>3, :fill=>@C['fg'], :smooth=>true)
+
+ # Flame to pulley 1
+ TkcLine.new(@canvas, [670, 309, 650, 309], :tag=>'I3_0',
+ :width=>3, :fill=>@C['fg'], :smooth=>true)
+ TkcLine.new(@canvas, [650, 309, 600, 309], :tag=>'I3_1',
+ :width=>3, :fill=>@C['fg'], :smooth=>true)
+
+ # Pulley 1 half way to 2
+ TkcLine.new(@canvas, [589, 296, 589, 235], :tag=>'I3_2',
+ :width=>3, :fill=>@C['fg'])
+
+ # Pulley 1 other half to 2
+ TkcLine.new(@canvas, [589, 235, 589, 174], :width=>3, :fill=>@C['fg'])
+
+ # Across the top
+ TkcLine.new(@canvas, [577, 161, 518, 161], :width=>3, :fill=>@C['fg'])
+
+ # Down to weight
+ TkcLine.new(@canvas, [505, 174, 505, 205], :tag=>'I3_w',
+ :width=>3, :fill=>@C['fg'])
+
+ # Draw the weight as 2 circles, two rectangles and 1 rounded rectangle
+ x1, y1, x2, y2 = [515, 207, 495, 207]
+ TkcOval.new(@canvas, box(x1, y1, 6),
+ :tag=>'I3_', :fill=>color2, :outline=>color2)
+ TkcOval.new(@canvas, box(x2, y2, 6),
+ :tag=>'I3_', :fill=>color2, :outline=>color2)
+ TkcRectangle.new(@canvas, x1, y1 - 6, x2, y2 + 6,
+ :tag=>'I3_', :fill=>color2, :outline=>color2)
+
+ TkcPolygon.new(@canvas, round_rect([492, 220, 518, 263], 15),
+ :smooth=>true, :tag=>'I3_', :fill=>color2, :outline=>color2)
+
+ TkcLine.new(@canvas, [500, 217, 511, 217],
+ :tag=>'I3_', :fill=>color2, :width=>10)
+
+ # Bottom weight target
+ TkcLine.new(@canvas, [502, 393, 522, 393, 522, 465],
+ :tag=>'I3__', :fill=>@C['fg'], :joinstyle=>:miter, :width=>10)
+ end
+
+ def move3(step = nil)
+ step = get_step(3, step)
+
+ pos = [ [505, 247], [505, 297], [505, 386.5], [505, 386.5] ]
+ rope = []
+ rope[0] = [750, 309, 729, 301, 711, 324, 690, 300]
+ rope[1] = [750, 309, 737, 292, 736, 335, 717, 315, 712, 320]
+ rope[2] = [750, 309, 737, 309, 740, 343, 736, 351, 725, 340]
+ rope[3] = [750, 309, 738, 321, 746, 345, 742, 356]
+
+ return 0 if step >= pos.length
+
+ @canvas.delete("I3_#{step}") # Delete part of the rope
+ move_abs('I3_', pos[step]) # Move weight down
+ @canvas.coords('I3_s', rope[step]) # Flapping rope end
+ @canvas.coords('I3_w', [505, 174].concat(pos[step]))
+ if step == 2
+ @canvas.move('I3__', 0, 30)
+ return 2
+ end
+ return 1
+ end
+
+ # Cage and door
+ def draw4
+ color = @C['4']
+ x0, y0, x1, y1 = [527, 356, 611, 464]
+
+ # Horizontal bars
+ y0.step(y1, 12){|y|
+ TkcLine.new(@canvas, [x0, y, x1, y], :fill=>color, :width=>1)
+ }
+
+ # Vertical bars
+ x0.step(x1, 12){|x|
+ TkcLine.new(@canvas, [x, y0, x, y1], :fill=>color, :width=>1)
+ }
+
+ # Swing gate
+ TkcLine.new(@canvas, [518, 464, 518, 428],
+ :tag=>'I4', :fill=>color, :width=>1)
+ end
+
+ def move4(step = nil)
+ step = get_step(4, step)
+
+ angles = [-10, -20, -30, -30]
+ return 0 if step >= angles.length
+
+ rotate_item('I4', 518, 464, angles[step])
+ @canvas.raise('I4')
+
+ return((step == 3)? 3: 1)
+ end
+
+ # Mouse
+ def draw5
+ color = @C['5a']
+ color2 = @C['5b']
+
+ xy = [377, 248, 410, 248, 410, 465, 518, 465] # Mouse course
+ xy.concat [518, 428, 451, 428, 451, 212, 377, 212]
+
+ TkcPolygon.new(@canvas, xy, :fill=>color2, :outline=>@C['fg'], :width=>3)
+
+ xy = [
+ 534.5, 445.5, 541, 440, 552, 436, 560, 436, 569, 440, 574, 446,
+ 575, 452, 574, 454, 566, 456, 554, 456, 545, 456, 537, 454, 530, 452
+ ]
+ TkcPolygon.new(@canvas, xy, :tag=>['I5', 'I5_0'], :fill=>color)
+
+ TkcLine.new(@canvas, [573, 452, 592, 458, 601, 460, 613, 456], # Tail
+ :tag=>['I5', 'I5_1'], :fill=>color, :smooth=>true, :width=>3)
+
+ xy = box(540, 446, 2) # Eye
+ xy = [540, 444, 541, 445, 541, 447, 540, 448, 538, 447, 538, 445]
+ TkcPolygon.new(@canvas, xy, :tag=>['I5', 'I5_2'], :fill=>@C['bg'],
+ :outline=>'', :smooth=>true)
+
+ xy = [538, 454, 535, 461] # Front leg
+ TkcLine.new(@canvas, xy, :tag=>['I5', 'I5_3'], :fill=>color, :width=>2)
+
+ xy = [566, 455, 569, 462] # Back leg
+ TkcLine.new(@canvas, xy, :tag=>['I5', 'I5_4'], :fill=>color, :width=>2)
+
+ xy = [544, 455, 545, 460] # 2nd front leg
+ TkcLine.new(@canvas, xy, :tag=>['I5', 'I5_5'], :fill=>color, :width=>2)
+
+ xy = [560, 455, 558, 460] # 2nd back leg
+ TkcLine.new(@canvas, xy, :tag=>['I5', 'I5_6'], :fill=>color, :width=>2)
+ end
+
+ def move5(step = nil)
+ step = get_step(5, step)
+
+ pos = [
+ [553, 452], [533, 452], [513, 452], [493, 452], [473, 452],
+ [463, 442, 30], [445.5, 441.5, 30], [425.5, 434.5, 30], [422, 414],
+ [422, 394], [422, 374], [422, 354], [422, 334], [422, 314], [422, 294],
+ [422, 274, -30], [422, 260.5, -30, :x], [422.5, 248.5, -28], [425, 237]
+ ]
+
+ return 0 if step >= pos.length
+
+ x, y, beta, nxt = pos[step]
+ move_abs('I5', [x, y])
+ if beta
+ ox, oy = centroid('I5_0')
+ (0..6).each{|id| rotate_item("I5_#{id}", ox, oy, beta) }
+ end
+ return 3 if nxt == :x
+ return 1
+ end
+
+ # Dropping gumballs
+ def draw6
+ color = @C['6']
+ xy = [324, 130, 391, 204] # Ball holder
+ xy = round_rect(xy, 10)
+ TkcPolygon.new(@canvas, xy, :smooth=>true,
+ :outline=>@C['fg'], :width=>3, :fill=>color)
+ xy = [339, 204, 376, 253] # Below the ball holder
+ TkcRectangle.new(@canvas, xy, :outline=>@C['fg'], :width=>3,
+ :fill=>color, :tag=>'I6c')
+ xy = box(346, 339, 28)
+ TkcOval.new(@canvas, xy, :fill=>color, :outline=>'') # Roter
+ TkcArc.new(@canvas, xy, :outline=>@C['fg'], :width=>2, :style=>:arc,
+ :start=>80, :extent=>205)
+ TkcArc.new(@canvas, xy, :outline=>@C['fg'], :width=>2, :style=>:arc,
+ :start=>-41, :extent=>85)
+
+ xy = box(346, 339, 15) # Center of rotor
+ TkcOval.new(@canvas, xy, :outline=>@C['fg'], :fill=>@C['fg'], :tag=>'I6m')
+ xy = [352, 312, 352, 254, 368, 254, 368, 322] # Top drop to rotor
+ TkcPolygon.new(@canvas, xy, :fill=>color, :outline=>'')
+ TkcLine.new(@canvas, xy, :fill=>@C['fg'], :width=>2)
+
+ xy = [353, 240, 367, 300] # Poke bottom hole
+ TkcRectangle.new(@canvas, xy, :fill=>color, :outline=>'')
+ xy = [341, 190, 375, 210] # Poke another hole
+ TkcRectangle.new(@canvas, xy, :fill=>color, :outline=>'')
+
+ xy = [
+ 368, 356, 368, 403, 389, 403, 389, 464, 320, 464, 320, 403,
+ 352, 403, 352, 366
+ ]
+ TkcPolygon.new(@canvas, xy, :fill=>color, :outline=>'',
+ :width=>2) # Below rotor
+ TkcLine.new(@canvas, xy, :fill=>@C['fg'], :width=>2)
+ xy = box(275, 342, 7) # On/off rotor
+ TkcOval.new(@canvas, xy, :outline=>@C['fg'], :fill=>@C['fg'])
+ xy = [276, 334, 342, 325] # Fan belt top
+ TkcLine.new(@canvas, xy, :fill=>@C['fg'], :width=>3)
+ xy = [276, 349, 342, 353] # Fan belt bottom
+ TkcLine.new(@canvas, xy, :fill=>@C['fg'], :width=>3)
+
+ xy = [337, 212, 337, 247] # What the mouse pushes
+ TkcLine.new(@canvas, xy, :fill=>@C['fg'], :width=>3, :tag=>'I6_')
+ xy = [392, 212, 392, 247]
+ TkcLine.new(@canvas, xy, :fill=>@C['fg'], :width=>3, :tag=>'I6_')
+ xy = [337, 230, 392, 230]
+ TkcLine.new(@canvas, xy, :fill=>@C['fg'], :width=>7, :tag=>'I6_')
+
+ who = -1 # All the balls
+ colors = %w(red cyan orange green blue darkblue)
+ colors *= 3
+
+ (0..16).each{|i|
+ loc = -i
+ color = colors[i]
+ x, y = @XY6["#{loc}"]
+ TkcOval.new(@canvas, box(x, y, 5),
+ :fill=>color, :outline=>color, :tag=>"I6_b#{i}")
+ }
+ draw6a(12) # The wheel
+ end
+
+ def draw6a(beta)
+ @canvas.delete('I6_0')
+ ox, oy = [346, 339]
+ (0..3).each{|i|
+ b = beta + i * 45
+ x, y = rotate_c(28, 0, 0, 0, b)
+ xy = [ox + x, oy + y, ox - x, oy - y]
+ TkcLine.new(@canvas, xy, :tag=>'I6_0', :fill=>@C['fg'], :width=>2)
+ }
+ end
+
+ def move6(step = nil)
+ step = get_step(6, step)
+
+ return 0 if step > 62
+
+ if step < 2 # Open gate for balls to drop
+ @canvas.move('I6_', -7, 0)
+ if step == 1 # Poke a hole
+ xy = [348, 226, 365, 240]
+ TkcRectangle.new(@canvas, xy, :fill=>@canvas.itemcget('I6c', :fill),
+ :outline=>'')
+ end
+ return 1
+ end
+
+ s = step - 1 # Do the gumball drop dance
+ (0..(((s - 1)/3).to_i)).each{|i|
+ tag = "I6_b#{i}"
+ break if @canvas.find_withtag(tag).empty?
+ loc = s - 3*i
+
+ if @XY6["#{loc},#{i}"]
+ move_abs(tag, @XY6["#{loc},#{i}"])
+ elsif @XY6["#{loc}"]
+ move_abs(tag, @XY6["#{loc}"])
+ end
+ }
+ if s % 3 == 1
+ first = (s + 2)/3
+ i = first
+ loop {
+ tag = "I6_b#{i}"
+ break if @canvas.find_withtag(tag).empty?
+ loc = first - i
+ move_abs(tag, @XY6["#{loc}"])
+ i += 1
+ }
+ end
+ if s >= 3 # Rotate the motor
+ idx = s % 3
+ draw6a(12 + s * 15)
+ end
+ return((s == 3)? 3 : 1)
+ end
+
+ # On/off switch
+ def draw7
+ color = @C['7']
+ xy = [198, 306, 277, 374] # Box
+ TkcRectangle.new(@canvas, xy, :outline=>@C['fg'], :width=>2,
+ :fill=>color, :tag=>'I7z')
+ @canvas.lower('I7z')
+ xy = [275, 343, 230, 349]
+ TkcLine.new(@canvas, xy, :tag=>'I7', :fill=>@C['fg'], :arrow=>:last,
+ :arrowshape=>[23, 23, 8], :width=>6)
+ xy = [225, 324] # On button
+ x, y = xy
+ TkcOval.new(@canvas, box(x, y, 3), :fill=>@C['fg'], :outline=>@C['fg'])
+ xy = [218, 323] # On text
+ font = ['Times Roman', 8]
+ TkcText.new(@canvas, xy, :text=>'on', :anchor=>:e,
+ :fill=>@C['fg'], :font=>font)
+ xy = [225, 350] # Off button
+ x, y = xy
+ TkcOval.new(@canvas, box(x, y, 3), :fill=>@C['fg'], :outline=>@C['fg'])
+ xy = [218, 349] # Off text
+ TkcText.new(@canvas, xy, :text=>'off', :anchor=>:e,
+ :fill=>@C['fg'], :font=>font)
+ end
+
+ def move7(step = nil)
+ step = get_step(7, step)
+
+ numsteps = 30
+ return 0 if step > numsteps
+ beta = 30.0 / numsteps
+ rotate_item('I7', 275, 343, beta)
+
+ return((step == numsteps)? 3: 1)
+ end
+
+ # Electricity to the fan
+ def draw8
+ sine([271, 248, 271, 306], 5, 8, :tag=>'I8_s', :fill=>@C['8'], :width=>3)
+ end
+
+ def move8(step = nil)
+ step = get_step(8, step)
+
+ return 0 if step > 3
+ if step == 0
+ sparkle(anchor('I8_s', :s), 'I8')
+ return 1
+ elsif step == 1
+ move_abs('I8', anchor('I8_s', :c))
+ elsif step == 2
+ move_abs('I8', anchor('I8_s', :n))
+ else
+ @canvas.delete('I8')
+ end
+ return((step == 2)? 3: 1)
+ end
+
+ # Fan
+ def draw9
+ color = @C['9']
+ xy = [266, 194, 310, 220]
+ TkcOval.new(@canvas, xy, :outline=>color, :fill=>color)
+ xy = [280, 209, 296, 248]
+ TkcOval.new(@canvas, xy, :outline=>color, :fill=>color)
+ xy = [
+ 288, 249, 252, 249, 260, 240, 280, 234,
+ 296, 234, 316, 240, 324, 249, 288, 249
+ ]
+ TkcPolygon.new(@canvas, xy, :fill=>color, :smooth=>true)
+
+ xy = [248, 205, 265, 214, 264, 205, 265, 196] # Spinner
+ TkcPolygon.new(@canvas, xy, :fill=>color)
+
+ xy = [255, 206, 265, 234] # Fan blades
+ TkcOval.new(@canvas, xy, :fill=>'', :outline=>@C['fg'],
+ :width=>3, :tag=>'I9_0')
+ xy = [255, 176, 265, 204]
+ TkcOval.new(@canvas, xy, :fill=>'', :outline=>@C['fg'],
+ :width=>3, :tag=>'I9_0')
+ xy = [255, 206, 265, 220]
+ TkcOval.new(@canvas, xy, :fill=>'', :outline=>@C['fg'],
+ :width=>1, :tag=>'I9_1')
+ xy = [255, 190, 265, 204]
+ TkcOval.new(@canvas, xy, :fill=>'', :outline=>@C['fg'],
+ :width=>1, :tag=>'I9_1')
+ end
+
+ def move9(step = nil)
+ step = get_step(9, step)
+
+ if (step & 1).nonzero?
+ @canvas.itemconfigure('I9_0', :width=>4)
+ @canvas.itemconfigure('I9_1', :width=>1)
+ @canvas.lower('I9_1', 'I9_0')
+ else
+ @canvas.itemconfigure('I9_0', :width=>1)
+ @canvas.itemconfigure('I9_1', :width=>4)
+ @canvas.lower('I9_0', 'I9_1')
+ end
+ return 3 if step == 0
+ return 1
+ end
+
+ # Boat
+ def draw10
+ color = @C['10a']
+ color2 = @C['10b']
+ xy = [191, 230, 233, 230, 233, 178, 191, 178] # Sail
+ TkcPolygon.new(@canvas, xy, :fill=>color, :width=>3, :outline=>@C['fg'],
+ :tag=>'I10')
+ xy = box(209, 204, 31) # Front
+ TkcArc.new(@canvas, xy, :outline=>'', :fill=>color, :style=>:pie,
+ :start=>120, :extent=>120, :tag=>'I10')
+ TkcArc.new(@canvas, xy, :outline=>@C['fg'], :width=>3, :style=>:arc,
+ :start=>120, :extent=>120, :tag=>'I10')
+ xy = box(249, 204, 31) # Back
+ TkcArc.new(@canvas, xy, :outline=>'', :fill=>@C['bg'], :width=>3,
+ :style=>:pie, :start=>120, :extent=>120, :tag=>'I10')
+ TkcArc.new(@canvas, xy, :outline=>@C['fg'], :width=>3, :style=>:arc,
+ :start=>120, :extent=>120, :tag=>'I10')
+
+ xy = [200, 171, 200, 249] # Mast
+ TkcLine.new(@canvas, xy, :fill=>@C['fg'], :width=>3, :tag=>'I10')
+ xy = [159, 234, 182, 234] # Bow sprit
+ TkcLine.new(@canvas, xy, :fill=>@C['fg'], :width=>3, :tag=>'I10')
+ xy = [180, 234, 180, 251, 220, 251] # Hull
+ TkcLine.new(@canvas, xy, :fill=>@C['fg'], :width=>6, :tag=>'I10')
+
+ xy = [92, 255, 221, 255] # Waves
+ sine(xy, 2, 25, :fill=>color2, :width=>1, :tag=>'I10w')
+
+ xy = @canvas.coords('I10w')[4..-5] # Water
+ xy.concat([222, 266, 222, 277, 99, 277])
+ TkcPolygon.new(@canvas, xy, :fill=>color2, :outline=>color2)
+ xy = [222, 266, 222, 277, 97, 277, 97, 266] # Water bottom
+ TkcLine.new(@canvas, xy, :fill=>@C['fg'], :width=>3)
+
+ xy = box(239, 262, 17)
+ TkcArc.new(@canvas, xy, :outline=>@C['fg'], :width=>3, :style=>:arc,
+ :start=>95, :extent=>103)
+ xy = box(76, 266, 21)
+ TkcArc.new(@canvas, xy, :outline=>@C['fg'], :width=>3, :style=>:arc,
+ :extent=>190)
+ end
+
+ def move10(step = nil)
+ step = get_step(10, step)
+
+ pos = [
+ [195, 212], [193, 212], [190, 212], [186, 212], [181, 212], [176, 212],
+ [171, 212], [166, 212], [161, 212], [156, 212], [151, 212], [147, 212],
+ [142, 212], [137, 212], [132, 212, :x], [127, 212], [121, 212],
+ [116, 212], [111, 212]
+ ]
+
+ return 0 if step >= pos.length
+
+ where = pos[step]
+ move_abs('I10', where)
+
+ return 3 if where[2] == :x
+ return 1
+ end
+
+ # 2nd ball drop
+ def draw11
+ color = @C['11a']
+ color2 = @C['11b']
+ xy = [23, 264, 55, 591] # Color the down tube
+ TkcRectangle.new(@canvas, xy, :fill=>color, :outline=>'')
+ xy = box(71, 460, 48) # Color the outer loop
+ TkcOval.new(@canvas, xy, :fill=>color, :outline=>'')
+
+ xy = [55, 264, 55, 458] # Top right side
+ TkcLine.new(@canvas, xy, :fill=>@C['fg'], :width=>3)
+ xy = [55, 504, 55, 591] # Bottom right side
+ TkcLine.new(@canvas, xy, :fill=>@C['fg'], :width=>3)
+ xy = box(71, 460, 48) # Outer loop
+ TkcArc.new(@canvas, xy, :outline=>@C['fg'], :width=>3, :style=>:arc,
+ :start=>110, :extent=>-290, :tag=>'I11i')
+ xy = box(71, 460, 16) # Inner loop
+ TkcOval.new(@canvas, xy, :outline=>@C['fg'], :fill=>'',
+ :width=>3, :tag=>'I11i')
+ TkcOval.new(@canvas, xy, :outline=>@C['fg'], :fill=>@C['bg'], :width=>3)
+
+ xy = [23, 264, 23, 591] # Left side
+ TkcLine.new(@canvas, xy, :fill=>@C['fg'], :width=>3)
+ xy = box(1, 266, 23) # Top left curve
+ TkcArc.new(@canvas, xy, :outline=>@C['fg'], :width=>3,
+ :style=>:arc, :extent=>90)
+
+ xy = box(75, 235, 9) # The ball
+ TkcOval.new(@canvas, xy, :fill=>color2, :outline=>'',
+ :width=>3, :tag=>'I11')
+ end
+
+ def move11(step = nil)
+ step = get_step(11, step)
+
+ pos = [
+ [75, 235], [70, 235], [65, 237], [56, 240], [46, 247], [38, 266],
+ [38, 296], [38, 333], [38, 399], [38, 475], [74, 496], [105, 472],
+ [100, 437], [65, 423], [-100, -100], [38, 505], [38, 527, :x], [38, 591]
+ ]
+
+ return 0 if step >= pos.length
+ where = pos[step]
+ move_abs('I11', where)
+ return 3 if where[2] == :x
+ return 1
+ end
+
+ # Hand
+ def draw12
+ xy = [
+ 20, 637, 20, 617, 20, 610, 20, 590, 40, 590, 40, 590,
+ 60, 590, 60, 610, 60, 610
+ ]
+ xy.concat([60, 610, 65, 620, 60, 631]) # Thumb
+ xy.concat([60, 631, 60, 637, 60, 662, 60, 669, 52, 669,
+ 56, 669, 50, 669, 50, 662, 50, 637])
+
+ y0 = 637 # Bumps for fingers
+ y1 = 645
+ 50.step(21, -10){|x|
+ x1 = x - 5
+ x2 = x - 10
+ xy << x << y0 << x1 << y1 << x2 << y0
+ }
+ TkcPolygon.new(@canvas, xy, :fill=>@C['12'], :outline=>@C['fg'],
+ :smooth=>true, :tag=>'I12', :width=>3)
+ end
+
+ def move12(step = nil)
+ step = get_step(12, step)
+
+ pos = [[42.5, 641, :x]]
+ return 0 if step >= pos.length
+ where = pos[step]
+ move_abs('I12', where)
+ return 3 if where[2] == :x
+ return 1
+ end
+
+ # Fax
+ def draw13
+ color = @C['13a']
+ xy = [86, 663, 149, 663, 149, 704, 50, 704, 50, 681, 64, 681, 86, 671]
+ xy2 = [
+ 784, 663, 721, 663, 721, 704, 820, 704, 820, 681, 806, 681, 784, 671
+ ]
+ radii = [2, 9, 9, 8, 5, 5, 2]
+
+ round_poly(@canvas, xy, radii, :width=>3,
+ :outline=>@C['fg'], :fill=>color)
+ round_poly(@canvas, xy2, radii, :width=>3,
+ :outline=>@C['fg'], :fill=>color)
+
+ xy = [56, 677]
+ x, y = xy
+ TkcRectangle.new(@canvas, box(x, y, 4), :fill=>'', :outline=>@C['fg'],
+ :width=>3, :tag=>'I13')
+ xy = [809, 677]
+ x, y = xy
+ TkcRectangle.new(@canvas, box(x, y, 4), :fill=>'', :outline=>@C['fg'],
+ :width=>3, :tag=>'I13R')
+
+ xy = [112, 687] # Label
+ TkcText.new(@canvas, xy, :text=>'FAX', :fill=>@C['fg'],
+ :font=>['Times Roman', 12, :bold])
+ xy = [762, 687]
+ TkcText.new(@canvas, xy, :text=>'FAX', :fill=>@C['fg'],
+ :font=>['Times Roman', 12, :bold])
+
+ xy = [138, 663, 148, 636, 178, 636] # Paper guide
+ TkcLine.new(@canvas, xy, :smooth=>true, :fill=>@C['fg'], :width=>3)
+ xy = [732, 663, 722, 636, 692, 636]
+ TkcLine.new(@canvas, xy, :smooth=>true, :fill=>@C['fg'], :width=>3)
+
+ sine([149, 688, 720, 688], 5, 15,
+ :tag=>'I13_s', :fill=>@C['fg'], :width=>3)
+ end
+
+ def move13(step = nil)
+ step = get_step(13, step)
+
+ numsteps = 7
+
+ if step == numsteps + 2
+ move_abs('I13_star', [-100, -100])
+ @canvas.itemconfigure('I13R', :fill=>@C['13b'], :width=>2)
+ return 2
+ end
+ if step == 0 # Button down
+ @canvas.delete('I13')
+ sparkle([-100, -100], 'I13_star') # Create off screen
+ return 1
+ end
+ x0, y0 = anchor('I13_s', :w)
+ x1, y1 = anchor('I13_s', :e)
+ x = x0 + (x1 - x0) * (step - 1) / numsteps.to_f
+ move_abs('I13_star', [x, y0])
+ return 1
+ end
+
+ # Paper in fax
+ def draw14
+ color = @C['14']
+ xy = [102, 661, 113, 632, 130, 618] # Left paper edge
+ TkcLine.new(@canvas, xy, :smooth=>true, :fill=>color,
+ :width=>3, :tag=>'I14L_0')
+ xy = [148, 629, 125, 640, 124, 662] # Right paper edge
+ TkcLine.new(@canvas, xy, :smooth=>true, :fill=>color,
+ :width=>3, :tag=>'I14L_1')
+ draw14a('L')
+
+ xy = [
+ 768.0, 662.5, 767.991316225, 662.433786215, 767.926187912, 662.396880171
+ ]
+ TkcLine.new(@canvas, xy, :smooth=>true, :fill=>color,
+ :width=>3, :tag=>'I14R_0')
+ @canvas.lower('I14R_0')
+ # NB. these numbers are VERY sensitive, you must start with final size
+ # and shrink down to get the values
+ xy = [
+ 745.947897349, 662.428358855, 745.997829056, 662.452239237, 746.0, 662.5
+ ]
+ TkcLine.new(@canvas, xy, :smooth=>true, :fill=>color,
+ :width=>3, :tag=>'I14R_1')
+ @canvas.lower('I14R_1')
+ end
+
+ def draw14a(side)
+ color = @C['14']
+ xy = @canvas.coords("I14#{side}_0")
+ xy2 = @canvas.coords("I14#{side}_1")
+ x0, y0, x1, y1, x2, y2 = xy
+ x3, y3, x4, y4, x5, y5 = xy2
+
+ zz = [
+ x0, y0, x0, y0, xy, x2, y2, x2, y2,
+ x3, y3, x3, y3, xy2, x5, y5, x5, y5
+ ].flatten
+ @canvas.delete("I14#{side}")
+ TkcPolygon.new(@canvas, zz, :tag=>"I14#{side}", :smooth=>true,
+ :fill=>color, :outline=>color, :width=>3)
+ @canvas.lower("I14#{side}")
+ end
+
+ def move14(step = nil)
+ step = get_step(14, step)
+
+ # Paper going down
+ sc = 0.9 - 0.05*step
+ if sc < 0.3
+ @canvas.delete('I14L')
+ return 0
+ end
+
+ ox, oy = @canvas.coords('I14L_0')
+ @canvas.scale('I14L_0', ox, oy, sc, sc)
+ ox, oy = @canvas.coords('I14L_1')[-2..-1]
+ @canvas.scale('I14L_1', ox, oy, sc, sc)
+ draw14a('L')
+
+ # Paper going up
+ sc = 0.35 + 0.05*step
+ sc = 1/sc
+
+ ox, oy = @canvas.coords('I14R_0')
+ @canvas.scale('I14R_0', ox, oy, sc, sc)
+ ox, oy = @canvas.coords('I14R_1')[-2..-1]
+ @canvas.scale('I14R_1', ox, oy, sc, sc)
+ draw14a('R')
+
+ return((step == 10)? 3: 1)
+ end
+
+ # Light beam
+ def draw15
+ color = @C['15a']
+ xy = [824, 599, 824, 585, 820, 585, 829, 585]
+ TkcLine.new(@canvas, xy, :fill=>@C['fg'], :width=>3, :tag=>'I15a')
+ xy = [789, 599, 836, 643]
+ TkcRectangle.new(@canvas, xy, :fill=>color, :outline=>@C['fg'], :width=>3)
+ xy = [778, 610, 788, 632]
+ TkcRectangle.new(@canvas, xy, :fill=>color, :outline=>@C['fg'], :width=>3)
+ xy = [766, 617, 776, 625]
+ TkcRectangle.new(@canvas, xy, :fill=>color, :outline=>@C['fg'], :width=>3)
+
+ xy = [633, 600, 681, 640]
+ TkcRectangle.new(@canvas, xy, :fill=>color, :outline=>@C['fg'], :width=>3)
+ xy = [635, 567, 657, 599]
+ TkcRectangle.new(@canvas, xy, :fill=>color, :outline=>@C['fg'], :width=>2)
+ xy = [765, 557, 784, 583]
+ TkcRectangle.new(@canvas, xy, :fill=>color, :outline=>@C['fg'], :width=>2)
+
+ sine([658, 580, 765, 580], 3, 15,
+ :tag=>'I15_s', :fill=>@C['fg'], :width=>3)
+ end
+
+ def move15a
+ color = @C['15b']
+ @canvas.scale('I15a', 824, 599, 1, 0.3) # Button down
+ xy = [765, 621, 681, 621]
+ TkcLine.new(@canvas, xy, :dash=>'-', :width=>3, :fill=>color, :tag=>'I15')
+ end
+
+ def move15(step = nil)
+ step = get_step(15, step)
+
+ numsteps = 6
+
+ if step == numsteps + 2
+ move_abs('I15_star', [-100, -100])
+ return 2
+ end
+ if step == 0 # Break the light beam
+ sparkle([-100, -100], 'I15_star')
+ xy = [765, 621, 745, 621]
+ @canvas.coords('I15', xy)
+ return 1
+ end
+ x0, y0 = anchor('I15_s', :w)
+ x1, y1 = anchor('I15_s', :e)
+ x = x0 + (x1 - x0) * (step - 1) / numsteps.to_f
+ move_abs('I15_star', [x, y0])
+ return 1
+ end
+
+ # Bell
+ def draw16
+ color = @C['16']
+ xy = [722, 485, 791, 556]
+ TkcRectangle.new(@canvas, xy, :fill=>'', :outline=>@C['fg'], :width=>3)
+ xy = box(752, 515, 25) # Bell
+ TkcOval.new(@canvas, xy, :fill=>color, :outline=>'black',
+ :tag=>'I16b', :width=>2)
+ xy = box(752, 515, 5) # Bell button
+ TkcOval.new(@canvas, xy, :fill=>'black', :outline=>'black', :tag=>'I16b')
+
+ xy = [784, 523, 764, 549] # Clapper
+ TkcLine.new(@canvas, xy, :width=>3, :tag=>'I16c', :fill=>@C['fg'])
+ xy = box(784, 523, 4)
+ TkcOval.new(@canvas, xy, :fill=>@C['fg'], :outline=>@C['fg'], :tag=>'I16d')
+ end
+
+ def move16(step = nil)
+ step = get_step(16, step)
+
+ # Note: we never stop
+ ox, oy = [760, 553]
+ if (step & 1).nonzero?
+ beta = 12
+ @canvas.move('I16b', 3, 0)
+ else
+ beta = -12
+ @canvas.move('I16b', -3, 0)
+ end
+ rotate_item('I16c', ox, oy, beta)
+ rotate_item('I16d', ox, oy, beta)
+
+ return ((step == 1)? 3: 1)
+ end
+
+ # Cat
+ def draw17
+ color = @C['17']
+
+ xy = [584, 556, 722, 556]
+ TkcLine.new(@canvas, xy, :fill=>@C['fg'], :width=>3)
+ xy = [584, 485, 722, 485]
+ TkcLine.new(@canvas, xy, :fill=>@C['fg'], :width=>3)
+
+ xy = [664, 523, 717, 549] # Body
+ TkcArc.new(@canvas, xy, :outline=>@C['fg'], :fill=>color, :width=>3,
+ :style=>:chord, :start=>128, :extent=>260, :tag=>'I17')
+
+ xy = [709, 554, 690, 543] # Paw
+ TkcOval.new(@canvas, xy, :outline=>@C['fg'], :fill=>color,
+ :width=>3, :tag=>'I17')
+ xy = [657, 544, 676, 555]
+ TkcOval.new(@canvas, xy, :outline=>@C['fg'], :fill=>color,
+ :width=>3, :tag=>'I17')
+
+ xy = box(660, 535, 15) # Lower face
+ TkcArc.new(@canvas, xy, :outline=>@C['fg'], :width=>3, :style=>:arc,
+ :start=>150, :extent=>240, :tag=>'I17_')
+ TkcArc.new(@canvas, xy, :outline=>'', :fill=>color, :width=>1,
+ :style=>:chord, :start=>150, :extent=>240, :tag=>'I17_')
+ xy = [674, 529, 670, 513, 662, 521, 658, 521, 650, 513, 647, 529] # Ears
+ TkcLine.new(@canvas, xy, :fill=>@C['fg'], :width=>3, :tag=>'I17_')
+ TkcPolygon.new(@canvas, xy, :fill=>color, :outline=>'', :width=>1,
+ :tag=>['I17_', 'I17_c'])
+ xy = [652, 542, 628, 539] # Whiskers
+ TkcLine.new(@canvas, xy, :fill=>@C['fg'], :width=>3, :tag=>'I17_')
+ xy = [652, 543, 632, 545]
+ TkcLine.new(@canvas, xy, :fill=>@C['fg'], :width=>3, :tag=>'I17_')
+ xy = [652, 546, 632, 552]
+ TkcLine.new(@canvas, xy, :fill=>@C['fg'], :width=>3, :tag=>'I17_')
+
+ xy = [668, 543, 687, 538]
+ TkcLine.new(@canvas, xy, :fill=>@C['fg'], :width=>3,
+ :tag=>['I17_', 'I17_w'])
+ xy = [668, 544, 688, 546]
+ TkcLine.new(@canvas, xy, :fill=>@C['fg'], :width=>3,
+ :tag=>['I17_', 'I17_w'])
+ xy = [668, 547, 688, 553]
+ TkcLine.new(@canvas, xy, :fill=>@C['fg'], :width=>3,
+ :tag=>['I17_', 'I17_w'])
+
+ xy = [649, 530, 654, 538, 659, 530] # Left eye
+ TkcLine.new(@canvas, xy, :fill=>@C['fg'], :width=>2,
+ :smooth=>true, :tag=>'I17')
+ xy = [671, 530, 666, 538, 661, 530] # Right eye
+ TkcLine.new(@canvas, xy, :fill=>@C['fg'], :width=>2,
+ :smooth=>true, :tag=>'I17')
+ xy = [655, 543, 660, 551, 665, 543] # Mouth
+ TkcLine.new(@canvas, xy, :fill=>@C['fg'], :width=>2,
+ :smooth=>true, :tag=>'I17')
+ end
+
+ def move17(step = nil)
+ step = get_step(17, step)
+
+ if step == 0
+ @canvas.delete('I17') # Delete most of the cat
+ xy = [655, 543, 660, 535, 665, 543] # Mouth
+ TkcLine.new(@canvas, xy, :fill=>@C['fg'], :width=>3,
+ :smooth=>true, :tag=>'I17_')
+ xy = box(654, 530, 4) # Left eye
+ TkcOval.new(@canvas, xy, :outline=>@C['fg'], :width=>3, :fill=>'',
+ :tag=>'I17_')
+ xy = box(666, 530, 4) # Right eye
+ TkcOval.new(@canvas, xy, :outline=>@C['fg'], :width=>3, :fill=>'',
+ :tag=>'I17_')
+
+ @canvas.move('I17_', 0, -20) # Move face up
+ xy = [652, 528, 652, 554] # Front leg
+ TkcLine.new(@canvas, xy, :fill=>@C['fg'], :width=>3, :tag=>'I17_')
+ xy = [670, 528, 670, 554] # 2nd front leg
+ TkcLine.new(@canvas, xy, :fill=>@C['fg'], :width=>3, :tag=>'I17_')
+
+ xy = [ # Body
+ 675, 506, 694, 489, 715, 513, 715, 513, 715, 513, 716, 525,
+ 716, 525, 716, 525, 706, 530, 695, 530, 679, 535, 668, 527,
+ 668, 527, 668, 527, 675, 522, 676, 517, 677, 512
+ ]
+ TkcPolygon.new(@canvas, xy, :fill=>@canvas.itemcget('I17_c', :fill),
+ :outline=>@C['fg'], :width=>3, :smooth=>true,
+ :tag=>'I17_')
+ xy = [716, 514, 716, 554] # Back leg
+ TkcLine.new(@canvas, xy, :fill=>@C['fg'], :width=>3, :tag=>'I17_')
+ xy = [694, 532, 694, 554] # 2nd back leg
+ TkcLine.new(@canvas, xy, :fill=>@C['fg'], :width=>3, :tag=>'I17_')
+ xy = [715, 514, 718, 506, 719, 495, 716, 488] # Tail
+ TkcLine.new(@canvas, xy, :fill=>@C['fg'], :width=>3,
+ :smooth=>true, :tag=>'I17_')
+
+ @canvas.raise('I17w') # Make whiskers visible
+ @canvas.move('I17_', -5, 0) # Move away from the wall a bit
+ return 2
+ end
+ return 0
+ end
+
+ # Sling shot
+ def draw18
+ color = @C['18']
+ xy = [721, 506, 627, 506] # Sling hold
+ TkcLine.new(@canvas, xy, :width=>4, :fill=>@C['fg'], :tag=>'I18')
+
+ xy = [607, 500, 628, 513] # Sling rock
+ TkcOval.new(@canvas, xy, :fill=>color, :outline=>'', :tag=>'I18a')
+
+ xy = [526, 513, 606, 507, 494, 502] # Sling band
+ TkcLine.new(@canvas, xy, :fill=>@C['fg'], :width=>4, :tag=>'I18b')
+ xy = [485, 490, 510, 540, 510, 575, 510, 540, 535, 491] # Sling
+ TkcLine.new(@canvas, xy, :fill=>@C['fg'], :width=>6)
+ end
+
+ def move18(step = nil)
+ step = get_step(18, step)
+
+ pos = [
+ [587, 506], [537, 506], [466, 506], [376, 506], [266, 506, :x],
+ [136, 506], [16, 506], [-100, -100]
+ ]
+
+ b = []
+ b[0] = [490, 502, 719, 507, 524, 512] # Band collapsing
+ b[1] = [
+ 491, 503, 524, 557, 563, 505, 559, 496, 546, 506, 551, 525,
+ 553, 536, 538, 534, 532, 519, 529, 499
+ ]
+ b[2] = [
+ 491, 503, 508, 563, 542, 533, 551, 526, 561, 539, 549, 550, 530, 500
+ ]
+ b[3] = [
+ 491, 503, 508, 563, 530, 554, 541, 562, 525, 568, 519, 544, 530, 501
+ ]
+
+ return 0 if step >= pos.length
+
+ if step == 0
+ @canvas.delete('I18')
+ @canvas.itemconfigure('I18b', :smooth=>true)
+ end
+ if b[step]
+ @canvas.coords('I18b', b[step])
+ end
+
+ where = pos[step]
+ move_abs('I18a', where)
+ return 3 if where[2] == :x
+ return 1
+ end
+
+ # Water pipe
+ def draw19
+ color = @C['19']
+ xx = [[249, 181], [155, 118], [86, 55], [22, 0]]
+ xx.each{|x1, x2|
+ TkcRectangle.new(@canvas, x1, 453, x2, 467,
+ :fill=>color, :outline=>'', :tag=>'I19')
+ TkcLine.new(@canvas, x1, 453, x2, 453,
+ :fill=>@C['fg'], :width=>1) # Pipe top
+ TkcLine.new(@canvas, x1, 467, x2, 467,
+ :fill=>@C['fg'], :width=>1) # Pipe bottom
+ }
+ @canvas.raise('I11i')
+
+ xy = box(168, 460, 16) # Bulge by the joint
+ TkcOval.new(@canvas, xy, :fill=>color, :outline=>'')
+ TkcArc.new(@canvas, xy, :outline=>@C['fg'], :width=>1, :style=>:arc,
+ :start=>21, :extent=>136)
+ TkcArc.new(@canvas, xy, :outline=>@C['fg'], :width=>1, :style=>:arc,
+ :start=>-21, :extent=>-130)
+
+ xy = [249, 447, 255, 473] # First joint 26x6
+ TkcRectangle.new(@canvas, xy, :fill=>color, :outline=>@C['fg'], :width=>1)
+
+ xy = box(257, 433, 34) # Bend up
+ TkcArc.new(@canvas, xy, :outline=>'', :fill=>color, :width=>1,
+ :style=>:pie, :start=>0, :extent=>-91)
+ TkcArc.new(@canvas, xy, :outline=>@C['fg'], :width=>1,
+ :style=>:arc, :start=>0, :extent=>-90)
+ xy = box(257, 433, 20)
+ TkcArc.new(@canvas, xy, :outline=>'', :fill=>@C['bg'], :width=>1,
+ :style=>:pie, :start=>0, :extent=>-92)
+ TkcArc.new(@canvas, xy, :outline=>@C['fg'], :width=>1,
+ :style=>:arc, :start=>0, :extent=>-90)
+ xy = box(257, 421, 34) # Bend left
+ TkcArc.new(@canvas, xy, :outline=>'', :fill=>color, :width=>1,
+ :style=>:pie, :start=>0, :extent=>91)
+ TkcArc.new(@canvas, xy, :outline=>@C['fg'], :width=>1,
+ :style=>:arc, :start=>0, :extent=>90)
+ xy = box(257, 421, 20)
+ TkcArc.new(@canvas, xy, :outline=>'', :fill=>@C['bg'], :width=>1,
+ :style=>:pie, :start=>0, :extent=>90)
+ TkcArc.new(@canvas, xy, :outline=>@C['fg'], :width=>1,
+ :style=>:arc, :start=>0, :extent=>90)
+ xy = box(243, 421, 34) # Bend down
+ TkcArc.new(@canvas, xy, :outline=>'', :fill=>color, :width=>1,
+ :style=>:pie, :start=>90, :extent=>90)
+ TkcArc.new(@canvas, xy, :outline=>@C['fg'], :width=>1,
+ :style=>:arc, :start=>90, :extent=>90)
+ xy = box(243, 421, 20)
+ TkcArc.new(@canvas, xy, :outline=>'', :fill=>@C['bg'], :width=>1,
+ :style=>:pie, :start=>90, :extent=>90)
+ TkcArc.new(@canvas, xy, :outline=>@C['fg'], :width=>1,
+ :style=>:arc, :start=>90, :extent=>90)
+
+ xy = [270, 427, 296, 433] # 2nd joint bottom
+ TkcRectangle.new(@canvas, xy, :fill=>color, :outline=>@C['fg'], :width=>1)
+ xy = [270, 421, 296, 427] # 2nd joint top
+ TkcRectangle.new(@canvas, xy, :fill=>color, :outline=>@C['fg'], :width=>1)
+ xy = [249, 382, 255, 408] # Third joint right
+ TkcRectangle.new(@canvas, xy, :fill=>color, :outline=>@C['fg'], :width=>1)
+ xy = [243, 382, 249, 408] # Third joint left
+ TkcRectangle.new(@canvas, xy, :fill=>color, :outline=>@C['fg'], :width=>1)
+ xy = [203, 420, 229, 426] # Last joint
+ TkcRectangle.new(@canvas, xy, :fill=>color, :outline=>@C['fg'], :width=>1)
+
+ xy = box(168, 460, 6) # Handle joint
+ TkcOval.new(@canvas, xy, :fill=>@C['fg'], :outline=>'', :tag=>'I19a')
+ xy = [168, 460, 168, 512] # Handle bar
+ TkcLine.new(@canvas, xy, :fill=>@C['fg'], :width=>5, :tag=>'I19b')
+ end
+
+ def move19(step = nil)
+ step = get_step(19, step)
+
+ angles = [30, 30, 30]
+ return 2 if step == angles.length
+ ox, oy = centroid('I19a')
+ rotate_item('I19b', ox, oy, angles[step])
+
+ return 1
+ end
+
+ # Water pouring
+ def draw20
+ # do nothing
+ end
+
+ def move20(step = nil)
+ step = get_step(20, step)
+
+ pos = [451, 462, 473, 484, 496, 504, 513, 523, 532]
+ freq = [20, 40, 40, 40, 40, 40, 40, 40, 40]
+ pos = [
+ [451, 20], [462, 40], [473, 40], [484, 40], [496, 40],
+ [504, 40], [513, 40], [523, 40], [532, 40, :x]
+ ]
+ return 0 if step >= pos.length
+
+ @canvas.delete('I20')
+ where = pos[step]
+ y, f = where
+ h20(y, f)
+ return 3 if where[2] == :x
+ return 1
+ end
+
+ def h20(y, f)
+ color = @C['20']
+ @canvas.delete('I20')
+
+ sine([208, 428, 208, y], 4, f, :tag=>['I20', 'I20s'],
+ :width=>3, :fill=>color, :smooth=>true)
+ TkcLine.new(@canvas, @canvas.coords('I20s'), :width=>3,
+ :fill=>color, :smooth=>1, :tag=>['I20', 'I20a'])
+ TkcLine.new(@canvas, @canvas.coords('I20s'), :width=>3,
+ :fill=>color, :smooth=>1, :tag=>['I20', 'I20b'])
+ @canvas.move('I20a', 8, 0)
+ @canvas.move('I20b', 16, 0)
+ end
+
+ # Bucket
+ def draw21
+ color = @C['21']
+ xy = [217, 451, 244, 490] # Right handle
+ TkcLine.new(@canvas, xy, :fill=>@C['fg'], :width=>2, :tag=>'I21_a')
+ xy = [201, 467, 182, 490] # Left handle
+ TkcLine.new(@canvas, xy, :fill=>@C['fg'], :width=>2, :tag=>'I21_a')
+
+ xy = [245, 490, 237, 535] # Right side
+ xy2 = [189, 535, 181, 490] # Left side
+ TkcPolygon.new(@canvas, xy + xy2, :fill=>color, :outline=>'',
+ :tag=>['I21', 'I21f'])
+ TkcLine.new(@canvas, xy, :fill=>@C['fg'], :width=>2, :tag=>'I21')
+ TkcLine.new(@canvas, xy2, :fill=>@C['fg'], :width=>2, :tag=>'I21')
+
+ xy = [182, 486, 244, 498] # Top
+ TkcOval.new(@canvas, xy, :fill=>color, :outline=>'', :width=>2,
+ :tag=>['I21', 'I21f'])
+ TkcOval.new(@canvas, xy, :fill=>'', :outline=>@C['fg'], :width=>2,
+ :tag=>['I21', 'I21t'])
+ xy = [189, 532, 237, 540] # Bottom
+ TkcOval.new(@canvas, xy, :fill=>color, :outline=>@C['fg'], :width=>2,
+ :tag=>['I21', 'I21b'])
+ end
+
+ def move21(step = nil)
+ step = get_step(21, step)
+
+ numsteps = 30
+ return 0 if step >= numsteps
+
+ x1, y1, x2, y2 = @canvas.coords('I21b')
+ # lx1, ly1, lx2, ly2 = @canvas.coords('I21t')
+ lx1, ly1, lx2, ly2 = [183, 492, 243, 504]
+
+ f = step / numsteps.to_f
+ y2 = y2 - 3
+ xx1 = x1 + (lx1 - x1) * f
+ yy1 = y1 + (ly1 - y1) * f
+ xx2 = x2 + (lx2 - x2) * f
+ yy2 = y2 + (ly2 - y2) * f
+
+ @canvas.itemconfigure('I21b', :fill=>@C['20'])
+ @canvas.delete('I21w')
+ TkcPolygon.new(@canvas, x2, y2, x1, y1, xx1, yy1, xx2, yy1,
+ :tag=>['I21', 'I21w'], :outline=>'', :fill=>@C['20'])
+ @canvas.lower('I21w', 'I21')
+ @canvas.raise('I21b')
+ @canvas.lower('I21f')
+
+ return((step == numsteps - 1)? 3: 1)
+ end
+
+ # Bucket drop
+ def draw22
+ # do nothing
+ end
+
+ def move22(step = nil)
+ step = get_step(22, step)
+ pos = [[213, 513], [213, 523], [213, 543, :x], [213, 583], [213, 593]]
+
+ @canvas.itemconfigure('I21f', :fill=>@C['22']) if step == 0
+ return 0 if step >= pos.length
+ where = pos[step]
+ move_abs('I21', where)
+ h20(where[1], 40)
+ @canvas.delete('I21_a') # Delete handles
+
+ return 3 if where[2] == :x
+ return 1
+ end
+
+ # Blow dart
+ def draw23
+ color = @C['23a']
+ color2 = @C['23b']
+ color3 = @C['23c']
+
+ xy = [185, 623, 253, 650] # Block
+ TkcRectangle.new(@canvas, xy, :fill=>'black', :outline=>@C['fg'],
+ :width=>2, :tag=>'I23a')
+ xy = [187, 592, 241, 623] # Balloon
+ TkcOval.new(@canvas, xy, :outline=>'', :fill=>color, :tag=>'I23b')
+ TkcArc.new(@canvas, xy, :outline=>@C['fg'], :width=>3, :tag=>'I23b',
+ :style=>:arc, :start=>12, :extent=>336)
+ xy = [239, 604, 258, 589, 258, 625, 239, 610] # Balloon nozzle
+ TkcPolygon.new(@canvas, xy, :outline=>'', :fill=>color, :tag=>'I23b')
+ TkcLine.new(@canvas, xy, :fill=>@C['fg'], :width=>3, :tag=>'I23b')
+
+ xy = [285, 611, 250, 603] # Dart body
+ TkcOval.new(@canvas, xy, :fill=>color2, :outline=>@C['fg'],
+ :width=>3, :tag=>'I23d')
+ xy = [249, 596, 249, 618, 264, 607, 249, 596] # Dart tail
+ TkcPolygon.new(@canvas, xy, :fill=>color3, :outline=>@C['fg'],
+ :width=>3, :tag=>'I23d')
+ xy = [249, 607, 268, 607] # Dart detail
+ TkcLine.new(@canvas, xy, :fill=>@C['fg'], :width=>3, :tag=>'I23d')
+ xy = [285, 607, 305, 607] # Dart needle
+ TkcLine.new(@canvas, xy, :fill=>@C['fg'], :width=>3, :tag=>'I23d')
+ end
+
+ def move23(step = nil)
+ step = get_step(23, step)
+
+ pos = [
+ [277, 607], [287, 607], [307, 607, :x], [347, 607], [407, 607],
+ [487, 607], [587, 607], [687, 607], [787, 607], [-100, -100]
+ ]
+
+ return 0 if step >= pos.length
+ if step <= 1
+ ox, oy = anchor('I23a', :n)
+ @canvas.scale('I23b', ox, oy, 0.9, 0.5)
+ end
+ where = pos[step]
+ move_abs('I23d', where)
+
+ return 3 if where[2] == :x
+ return 1
+ end
+
+ # Balloon
+ def draw24
+ color = @C['24a']
+ xy = [366, 518, 462, 665] # Balloon
+ TkcOval.new(@canvas, xy, :fill=>color, :outline=>@C['fg'],
+ :width=>3, :tag=>'I24')
+ xy = [414, 666, 414, 729] # String
+ TkcLine.new(@canvas, xy, :fill=>@C['fg'], :width=>3, :tag=>'I24')
+ xy = [410, 666, 404, 673, 422, 673, 418, 666] # Nozzle
+ TkcPolygon.new(@canvas, xy, :fill=>color, :outline=>@C['fg'],
+ :width=>3, :tag=>'I24')
+
+ xy = [387, 567, 390, 549, 404, 542] # Reflections
+ TkcLine.new(@canvas, xy, :fill=>@C['fg'], :smooth=>true,
+ :width=>2, :tag=>'I24')
+ xy = [395, 568, 399, 554, 413, 547]
+ TkcLine.new(@canvas, xy, :fill=>@C['fg'], :smooth=>true,
+ :width=>2, :tag=>'I24')
+ xy = [403, 570, 396, 555, 381, 553]
+ TkcLine.new(@canvas, xy, :fill=>@C['fg'], :smooth=>true,
+ :width=>2, :tag=>'I24')
+ xy = [408, 564, 402, 547, 386, 545]
+ TkcLine.new(@canvas, xy, :fill=>@C['fg'], :smooth=>true,
+ :width=>2, :tag=>'I24')
+ end
+
+ def move24(step = nil)
+ step = get_step(24, step)
+
+ return 0 if step > 4
+ return 2 if step == 4
+
+ if step == 0
+ @canvas.delete('I24') # Exploding balloon
+ xy = [
+ 347, 465, 361, 557, 271, 503, 272, 503, 342, 574, 259, 594,
+ 259, 593, 362, 626, 320, 737, 320, 740, 398, 691, 436, 738,
+ 436, 739, 476, 679, 528, 701, 527, 702, 494, 627, 548, 613,
+ 548, 613, 480, 574, 577, 473, 577, 473, 474, 538, 445, 508,
+ 431, 441, 431, 440, 400, 502, 347, 465, 347, 465
+ ]
+ TkcPolygon.new(@canvas, xy, :tag=>'I24', :fill=>@C['24b'],
+ :outline=>@C['24a'], :width=>10, :smooth=>true)
+ msg = Tk.subst(@S['message'].value)
+ TkcText.new(@canvas, centroid('I24'), :text=>msg, :tag=>['I24', 'I24t'],
+ :justify=>:center, :font=>['Times Roman', 18, :bold])
+ return 1
+ end
+
+ @canvas.itemconfigure('I24t', :font=>['Times Roman', 18 + 6*step, :bold])
+ @canvas.move('I24', 0, -60)
+ ox, oy = centroid('I24')
+ @canvas.scale('I24', ox, oy, 1.25, 1.25)
+ return 1
+ end
+
+ # Displaying the message
+ def move25(step = nil)
+ step = get_step(25, step)
+
+ if step == 0
+ @XY['25'] = Tk::Clock.clicks(:miliseconds)
+ return 1
+ end
+ elapsed = Tk::Clock.clicks(:miliseconds) - @XY['25']
+ return 1 if elapsed < 5000
+ return 2
+ end
+
+ # Collapsing balloon
+ def move26(step = nil)
+ step = get_step(26, step)
+
+ if step >= 3
+ @canvas.delete('I24', 'I26')
+ TkcText.new(@canvas, 430, 735, :anchor=>:s, :tag=>'I26',
+ #:text=>'click to continue',
+ :text=>'クリックã§ãƒªã‚»ãƒƒãƒˆã—ã¾ã™',
+ :font=>['Times Roman', 20, :bold])
+ @canvas.bind('1', proc{reset})
+ return 4
+ end
+
+ ox, oy = centroid('I24')
+ @canvas.scale('I24', ox, oy, 0.8, 0.8)
+ @canvas.move('I24', 0, 60)
+ @canvas.itemconfigure('I24t', :font=>['Times Roman', 30 - 6*step, :bold])
+ return 1
+ end
+
+ ################################################################
+ #
+ # Helper functions
+ #
+ def box(x, y, r)
+ [x - r, y - r, x + r, y + r]
+ end
+
+ def move_abs(item, xy)
+ x, y = xy
+ ox, oy = centroid(item)
+ dx = x - ox
+ dy = y - oy
+ @canvas.move(item, dx, dy)
+ end
+
+ def rotate_item(item, ox, oy, beta)
+ xy = @canvas.coords(item)
+ xy2 = []
+ 0.step(xy.length - 1, 2){|idx|
+ x, y = xy[idx, 2]
+ xy2.concat(rotate_c(x, y, ox, oy, beta))
+ }
+ @canvas.coords(item, xy2)
+ end
+
+ def rotate_c(x, y, ox, oy, beta)
+ # rotates vector (ox,oy)->(x,y) by beta degrees clockwise
+
+ x -= ox # Shift to origin
+ y -= oy
+
+ beta = beta * Math.atan(1) * 4 / 180.0 # Radians
+ xx = x * Math.cos(beta) - y * Math.sin(beta) # Rotate
+ yy = x * Math.sin(beta) + y * Math.cos(beta)
+
+ xx += ox # Shift back
+ yy += oy
+
+ [xx, yy]
+ end
+
+ def reset
+ draw_all
+ @canvas.bind_remove('1')
+ @S['mode'].value = :MSTART
+ @S['active'] = [0]
+ end
+
+ # Each Move## keeps its state info in STEP, this retrieves and increments it
+ def get_step(who, step)
+ if step
+ @STEP[who] = step
+ else
+ if !@STEP.exist?(who) || @STEP[who] == ""
+ @STEP[who] = 0
+ else
+ @STEP[who] += 1
+ end
+ end
+ @STEP[who]
+ end
+
+ def reset_step
+ @S['cnt'].value = 0
+ @STEP.keys.each{|k| @STEP[k] = ''}
+ end
+
+ def sine(xy0, amp, freq, opts = {})
+ x0, y0, x1, y1 = xy0
+ step = 2
+ xy = []
+ if y0 == y1 # Horizontal
+ x0.step(x1, step){|x|
+ beta = (x - x0) * 2 * Math::PI / freq
+ y = y0 + amp * Math.sin(beta)
+ xy << x << y
+ }
+ else
+ y0.step(y1, step){|y|
+ beta = (y - y0) * 2 * Math::PI / freq
+ x = x0 + amp * Math.sin(beta)
+ xy << x << y
+ }
+ end
+ TkcLine.new(@canvas, xy, opts)
+ end
+
+ def round_rect(xy, radius, opts={})
+ x0, y0, x3, y3 = xy
+ r = @canvas.winfo_pixels(radius)
+ d = 2 * r
+
+ # Make sure that the radius of the curve is less than 3/8 size of the box!
+ maxr = 0.75
+ if d > maxr * (x3 - x0)
+ d = maxr * (x3 - x0)
+ end
+ if d > maxr * (y3 - y0)
+ d = maxr * (y3 - y0)
+ end
+
+ x1 = x0 + d
+ x2 = x3 - d
+ y1 = y0 + d
+ y2 = y3 - d
+
+ xy = [x0, y0, x1, y0, x2, y0, x3, y0, x3, y1, x3, y2]
+ xy.concat([x3, y3, x2, y3, x1, y3, x0, y3, x0, y2, x0, y1])
+ return xy
+ end
+
+ def round_poly(canv, xy, radii, opts)
+ lenXY = xy.length
+ lenR = radii.length
+ if lenXY != 2*lenR
+ raise "wrong number of vertices and radii"
+ end
+
+ knots = []
+ x0 = xy[-2]; y0 = xy[-1]
+ x1 = xy[0]; y1 = xy[1]
+ xy << xy[0] << xy[1]
+
+ 0.step(lenXY - 1, 2){|i|
+ radius = radii[i/2]
+ r = canv.winfo_pixels(radius)
+
+ x2 = xy[i+2]; y2 = xy[i+3]
+ z = _round_poly2(x0, y0, x1, y1, x2, y2, r)
+ knots.concat(z)
+
+ x0 = x1; y0 = y1
+ x1 = x2; y1 = y2
+ }
+ TkcPolygon.new(canv, knots, {:smooth=>true}.update(opts))
+ end
+
+ def _round_poly2(x0, y0, x1, y1, x2, y2, radius)
+ d = 2 * radius
+ maxr = 0.75
+
+ v1x = x0 - x1
+ v1y = y0 - y1
+ v2x = x2 - x1
+ v2y = y2 - y1
+
+ vlen1 = Math.sqrt(v1x*v1x + v1y*v1y)
+ vlen2 = Math.sqrt(v2x*v2x + v2y*v2y)
+
+ if d > maxr * vlen1
+ d = maxr * vlen1
+ end
+ if d > maxr * vlen2
+ d = maxr * vlen2
+ end
+
+ xy = []
+ xy << (x1 + d * v1x / vlen1) << (y1 + d * v1y / vlen1)
+ xy << x1 << y1
+ xy << (x1 + d * v2x / vlen2) << (y1 + d * v2y / vlen2)
+
+ return xy
+ end
+
+ def sparkle(oxy, tag)
+ xy = [
+ [299, 283], [298, 302], [295, 314], [271, 331],
+ [239, 310], [242, 292], [256, 274], [281, 273]
+ ]
+ xy.each{|x, y|
+ TkcLine.new(@canvas, 271, 304, x, y,
+ :fill=>'white', :width=>3, :tag=>tag)
+ }
+ move_abs(tag, oxy)
+ end
+
+ def centroid(item)
+ anchor(item, :c)
+ end
+
+ def anchor(item, where)
+ x1, y1, x2, y2 = @canvas.bbox(item)
+ case(where)
+ when :n
+ y = y1
+ when :s
+ y = y2
+ else
+ y = (y1 + y2) / 2.0
+ end
+ case(where)
+ when :w
+ x = x1
+ when :e
+ x = x2
+ else
+ x = (x1 + x2) / 2.0
+ end
+ return [x, y]
+ end
+end
+
+TkGoldberg_Demo.new(base_frame)
diff --git a/jni/ruby/ext/tk/sample/demos-jp/hello b/jni/ruby/ext/tk/sample/demos-jp/hello
new file mode 100644
index 0000000..e942f3d
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/demos-jp/hello
@@ -0,0 +1,10 @@
+#!/usr/bin/env ruby
+# -*- coding: utf-8 -*-
+require 'tk'
+
+TkButton.new(nil,
+ 'text'=>"ã“ã‚“ã«ã¡ã¯ã€ä¸–ç•Œ",
+ 'command'=>proc{print "ã“ã‚“ã«ã¡ã¯ã€ä¸–ç•Œ\n"; exit}
+).pack
+
+Tk.mainloop
diff --git a/jni/ruby/ext/tk/sample/demos-jp/hscale.rb b/jni/ruby/ext/tk/sample/demos-jp/hscale.rb
new file mode 100644
index 0000000..2dfbf38
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/demos-jp/hscale.rb
@@ -0,0 +1,78 @@
+# -*- coding: utf-8 -*-
+require "tkcanvas"
+
+if defined?($hscale_demo) && $hscale_deom
+ $hscale_demo.destroy
+ $hscale_demo = nil
+end
+
+$hscale_demo = TkToplevel.new {|w|
+ title("Horizontal Scale Demonstration")
+ iconname("hscale")
+}
+positionWindow($hscale_demo)
+
+base_frame = TkFrame.new($hscale_demo).pack(:fill=>:both, :expand=>true)
+
+msg = TkLabel.new(base_frame) {
+ font $font
+ wraplength '3.5i'
+ justify 'left'
+ text "下ã«ã¯çŸ¢å°ãŒ1ã¤ã¨æ°´å¹³ãªã‚¹ã‚±ãƒ¼ãƒ«ãŒè¡¨ç¤ºã•ã‚Œã¦ã„ã¾ã™ã€‚\
+スケール上ã§ãƒžã‚¦ã‚¹ãƒœã‚¿ãƒ³1をクリックã€ã¾ãŸã¯ãƒ‰ãƒ©ãƒƒã‚°ã™ã‚‹ã¨\
+矢å°ã®é•·ã•ã‚’変ãˆã‚‹ã“ã¨ãŒã§ãã¾ã™ã€‚"
+}
+msg.pack('side'=>'top')
+
+TkFrame.new(base_frame) {|frame|
+ TkButton.new(frame) {
+ #text '了解'
+ text 'é–‰ã˜ã‚‹'
+ command proc {
+ tmppath = $hscale_demo
+ $hscale_demo = nil
+ tmppath.destroy
+ }
+ }.pack('side'=>'left', 'expand'=>'yes')
+
+ TkButton.new(frame) {
+ text 'コードå‚ç…§'
+ command proc { showCode 'hscale' }
+ }.pack('side'=>'left', 'expand'=>'yes')
+}.pack('side'=>'bottom', 'fill'=>'x', 'pady'=>'2m')
+
+def setWidth(w, width)
+ width = width + 21
+ x2 = width - 30
+ if x2 < 21
+ x2 = 21
+ end
+ w.coords 'poly',20,15,20,35,x2,35,x2,45,width,25,x2,5,x2,15,20,15
+ w.coords 'line',20,15,20,35,x2,35,x2,45,width,25,x2,5,x2,15,20,15
+end
+
+TkFrame.new(base_frame) {|frame|
+ canvas = TkCanvas.new(frame) {|c|
+ width 50
+ height 50
+ bd 0
+ highlightthickness 0
+ TkcPolygon.new(c, '0', '0', '1', '1', '2', '2') {
+ fill 'DeepSkyBlue'
+ tags 'poly'
+ }
+ TkcLine.new(c, '0', '0', '1', '1', '2', '2', '0', '0') {
+ fill 'black'
+ tags 'line'
+ }
+ }.pack('side'=>'top', 'expand'=>'yes', 'anchor'=>'s', 'fill'=>'x', 'padx'=>'15')
+ scale = TkScale.new(frame) {
+ orient 'horizontal'
+ length 284
+ from 0
+ to 250
+ command proc{|value| setWidth(canvas, value)}
+ tickinterval 50
+ }.pack('side'=>'bottom', 'expand'=>'yes', 'anchor'=>'n')
+ scale.set 75
+}.pack('side'=>'top', 'fill'=>'x')
diff --git a/jni/ruby/ext/tk/sample/demos-jp/icon.rb b/jni/ruby/ext/tk/sample/demos-jp/icon.rb
new file mode 100644
index 0000000..6b9e1a5
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/demos-jp/icon.rb
@@ -0,0 +1,103 @@
+# -*- coding: utf-8 -*-
+#
+# iconic button widget demo (called by 'widget')
+#
+
+# toplevel widget ãŒå­˜åœ¨ã™ã‚Œã°å‰Šé™¤ã™ã‚‹
+if defined?($icon_demo) && $icon_demo
+ $icon_demo.destroy
+ $icon_demo = nil
+end
+
+# demo 用㮠toplevel widget を生æˆ
+$icon_demo = TkToplevel.new {|w|
+ title("Iconic Button Demonstration")
+ iconname("icon")
+ positionWindow(w)
+}
+
+base_frame = TkFrame.new($icon_demo).pack(:fill=>:both, :expand=>true)
+
+# label 生æˆ
+msg = TkLabel.new(base_frame) {
+ font $font
+ wraplength '5i'
+ justify 'left'
+ text "ã“ã®ã‚¦ã‚£ãƒ³ãƒ‰ã‚¦ã«ã¯ãƒ©ã‚¸ã‚ªãƒœã‚¿ãƒ³ã¨ãƒã‚§ãƒƒã‚¯ãƒœã‚¿ãƒ³ä¸Šã«ãƒ“ットマップや画åƒã‚’表示ã™ã‚‹ 3 ã¤ã®æ–¹æ³•ã‚’示ã—ã¦ã„ã¾ã™ã€‚å·¦ã«ã‚ã‚‹ã®ã¯2ã¤ã®ãƒ©ã‚¸ã‚ªãƒœã‚¿ãƒ³ã§ã€ãã‚Œãžã‚ŒãŒã€ãƒ“ットマップã¨é¸æŠžã‚’示ã™ã‚¤ãƒ³ã‚¸ã‚±ãƒ¼ã‚¿ã§ã§ãã¦ã„ã¾ã™ã€‚中央ã«ã‚ã‚‹ã®ã¯ã€é¸æŠžæ¸ˆã¿ã‹ã©ã†ã‹ã«ã‚ˆã£ã¦ç•°ãªã‚‹ç”»åƒã‚’表示ã™ã‚‹ãƒã‚§ãƒƒã‚¯ãƒœã‚¿ãƒ³ã§ã™ã€‚å³å´ã«ã‚ã‚‹ã®ã¯é¸æŠžæ¸ˆã¿ã‹ã©ã†ã‹ã«ã‚ˆã£ã¦èƒŒæ™¯è‰²ãŒå¤‰ã‚るビットマップを表示ã™ã‚‹ãƒã‚§ãƒƒã‚¯ãƒœã‚¿ãƒ³ã§ã™ã€‚"
+}
+msg.pack('side'=>'top')
+
+# frame 生æˆ
+TkFrame.new(base_frame) {|frame|
+ TkButton.new(frame) {
+ #text '了解'
+ text 'é–‰ã˜ã‚‹'
+ command proc{
+ tmppath = $icon_demo
+ $icon_demo = nil
+ tmppath.destroy
+ }
+ }.pack('side'=>'left', 'expand'=>'yes')
+
+ TkButton.new(frame) {
+ text 'コードå‚ç…§'
+ command proc{showCode 'icon'}
+ }.pack('side'=>'left', 'expand'=>'yes')
+
+}.pack('side'=>'bottom', 'fill'=>'x', 'pady'=>'2m')
+
+# image 生æˆ
+flagup = \
+TkBitmapImage.new('file'=>[$demo_dir,'..',
+ 'images','flagup.xbm'].join(File::Separator),
+ 'maskfile'=>\
+ [$demo_dir,'..','images','flagup.xbm'].join(File::Separator))
+flagdown = \
+TkBitmapImage.new('file'=>[$demo_dir,'..',
+ 'images','flagdown.xbm'].join(File::Separator),
+ 'maskfile'=>\
+ [$demo_dir,'..',
+ 'images','flagdown.xbm'].join(File::Separator))
+
+# 変数生æˆ
+letters = TkVariable.new
+
+# frame 生æˆ
+TkFrame.new(base_frame, 'borderwidth'=>10){|w|
+ TkFrame.new(w) {|f|
+ # TkRadioButton.new(f){
+ Tk::RadioButton.new(f){
+ bitmap '@' + [$demo_dir,'..',
+ 'images','letters.xbm'].join(File::Separator)
+ variable letters
+ value 'full'
+ }.pack('side'=>'top', 'expand'=>'yes')
+
+ # TkRadioButton.new(f){
+ Tk::RadioButton.new(f){
+ bitmap '@' + [$demo_dir,'..',
+ 'images','noletter.xbm'].join(File::Separator)
+ variable letters
+ value 'empty'
+ }.pack('side'=>'top', 'expand'=>'yes')
+
+ }.pack('side'=>'left', 'expand'=>'yes', 'padx'=>'5m')
+
+ # TkCheckButton.new(w) {
+ Tk::CheckButton.new(w) {
+ image flagdown
+ selectimage flagup
+ indicatoron 0
+ selectcolor self['background']
+ }.pack('side'=>'left', 'expand'=>'yes', 'padx'=>'5m')
+
+ # TkCheckButton.new(w) {
+ Tk::CheckButton.new(w) {
+ bitmap '@' + [$demo_dir,'..',
+ 'images','letters.xbm'].join(File::Separator)
+ indicatoron 0
+ selectcolor 'SeaGreen1'
+ }.pack('side'=>'left', 'expand'=>'yes', 'padx'=>'5m')
+
+}.pack('side'=>'top')
+
diff --git a/jni/ruby/ext/tk/sample/demos-jp/image1.rb b/jni/ruby/ext/tk/sample/demos-jp/image1.rb
new file mode 100644
index 0000000..0c69b2a
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/demos-jp/image1.rb
@@ -0,0 +1,64 @@
+# -*- coding: utf-8 -*-
+#
+# two image widgets demo (called by 'widget')
+#
+
+# toplevel widget ãŒå­˜åœ¨ã™ã‚Œã°å‰Šé™¤ã™ã‚‹
+if defined?($image1_demo) && $image1_demo
+ $image1_demo.destroy
+ $image1_demo = nil
+end
+
+# demo 用㮠toplevel widget を生æˆ
+$image1_demo = TkToplevel.new {|w|
+ title('Image Demonstration #1')
+ iconname("Image1")
+ positionWindow(w)
+}
+
+base_frame = TkFrame.new($image1_demo).pack(:fill=>:both, :expand=>true)
+
+# label 生æˆ
+msg = TkLabel.new(base_frame) {
+ font $font
+ wraplength '4i'
+ justify 'left'
+ text "ã“ã®ãƒ‡ãƒ¢ã§ã¯2ã¤ã®ãƒ©ãƒ™ãƒ«ä¸Šã«ç”»åƒã‚’ãã‚Œãžã‚Œè¡¨ç¤ºã—ã¦ã„ã¾ã™ã€‚"
+}
+msg.pack('side'=>'top')
+
+# frame 生æˆ
+TkFrame.new(base_frame) {|frame|
+ TkButton.new(frame) {
+ #text '了解'
+ text 'é–‰ã˜ã‚‹'
+ command proc{
+ tmppath = $image1_demo
+ $image1_demo = nil
+ tmppath.destroy
+ }
+ }.pack('side'=>'left', 'expand'=>'yes')
+
+ TkButton.new(frame) {
+ text 'コードå‚ç…§'
+ command proc{showCode 'image1'}
+ }.pack('side'=>'left', 'expand'=>'yes')
+
+}.pack('side'=>'bottom', 'fill'=>'x', 'pady'=>'2m')
+
+# image 生æˆ
+image1a = \
+TkPhotoImage.new('file'=>[$demo_dir,'..',
+ 'images','earth.gif'].join(File::Separator))
+image1b = \
+TkPhotoImage.new('file'=>[$demo_dir,'..',
+ 'images','earthris.gif'].join(File::Separator))
+
+# label 生æˆ
+#[ TkLabel.new(base_frame, 'image'=>image1a, 'bd'=>1, 'relief'=>'sunken'),
+# TkLabel.new(base_frame, 'image'=>image1b, 'bd'=>1, 'relief'=>'sunken')
+#].each{|w| w.pack('side'=>'top', 'padx'=>'.5m', 'pady'=>'.5m')}
+[ Tk::Label.new(base_frame, 'image'=>image1a, 'bd'=>1, 'relief'=>'sunken'),
+ Tk::Label.new(base_frame, 'image'=>image1b, 'bd'=>1, 'relief'=>'sunken')
+].each{|w| w.pack('side'=>'top', 'padx'=>'.5m', 'pady'=>'.5m')}
+
diff --git a/jni/ruby/ext/tk/sample/demos-jp/image2.rb b/jni/ruby/ext/tk/sample/demos-jp/image2.rb
new file mode 100644
index 0000000..aa507c5
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/demos-jp/image2.rb
@@ -0,0 +1,106 @@
+# -*- coding: utf-8 -*-
+#
+# widget demo 'load image' (called by 'widget')
+#
+
+# toplevel widget ãŒå­˜åœ¨ã™ã‚Œã°å‰Šé™¤ã™ã‚‹
+if defined?($image2_demo) && $image2_demo
+ $image2_demo.destroy
+ $image2_demo = nil
+end
+
+# demo 用㮠toplevel widget を生æˆ
+$image2_demo = TkToplevel.new {|w|
+ title('Image Demonstration #2')
+ iconname("Image2")
+ positionWindow(w)
+}
+
+base_frame = TkFrame.new($image2_demo).pack(:fill=>:both, :expand=>true)
+
+# label 生æˆ
+msg = TkLabel.new(base_frame) {
+ font $font
+ wraplength '4i'
+ justify 'left'
+ text "ã“ã®ãƒ‡ãƒ¢ã§ã¯Tkã® photo image を使用ã—ã¦ç”»åƒã‚’見るã“ã¨ãŒã§ãã¾ã™ã€‚最åˆã«ã‚¨ãƒ³ãƒˆãƒªå†…ã«ã«ãƒ‡ã‚£ãƒ¬ã‚¯ãƒˆãƒªåを入れã¦ä¸‹ã•ã„。次ã«ä¸‹ã®ãƒªã‚¹ãƒˆãƒœãƒƒã‚¯ã‚¹ã«ã“ã®ãƒ‡ã‚£ãƒ¬ã‚¯ãƒˆãƒªã‚’ロードã™ã‚‹ãŸã‚ã€ãƒªã‚¿ãƒ¼ãƒ³ã‚’押ã—ã¦ãã ã•ã„。ãã®å¾Œã€ç”»åƒã‚’é¸æŠžã™ã‚‹ãŸã‚ã«ãƒªã‚¹ãƒˆãƒœãƒƒã‚¯ã‚¹ã®ä¸­ã®ãƒ•ã‚¡ã‚¤ãƒ«åをダブルクリックã—ã¦ä¸‹ã•ã„。"
+}
+msg.pack('side'=>'top')
+
+# frame 生æˆ
+TkFrame.new(base_frame) {|frame|
+ TkButton.new(frame) {
+ #text '了解'
+ text 'é–‰ã˜ã‚‹'
+ command proc{
+ tmppath = $image2_demo
+ $image2_demo = nil
+ tmppath.destroy
+ }
+ }.pack('side'=>'left', 'expand'=>'yes')
+
+ TkButton.new(frame) {
+ text 'コードå‚ç…§'
+ command proc{showCode 'image2'}
+ }.pack('side'=>'left', 'expand'=>'yes')
+
+}.pack('side'=>'bottom', 'fill'=>'x', 'pady'=>'2m')
+
+# 変数生æˆ
+$dirName = TkVariable.new([$demo_dir,'..','images'].join(File::Separator))
+
+# image 生æˆ
+$image2a = TkPhotoImage.new
+
+# ファイルå入力部
+TkLabel.new(base_frame, 'text'=>'ディレクトリ:')\
+.pack('side'=>'top', 'anchor'=>'w')
+
+image2_e = TkEntry.new(base_frame) {
+ width 30
+ textvariable $dirName
+}.pack('side'=>'top', 'anchor'=>'w')
+
+TkFrame.new(base_frame, 'height'=>'3m', 'width'=>20)\
+.pack('side'=>'top', 'anchor'=>'w')
+
+TkLabel.new(base_frame, 'text'=>'ファイル:')\
+.pack('side'=>'top', 'anchor'=>'w')
+
+TkFrame.new(base_frame){|w|
+ s = TkScrollbar.new(w)
+ l = TkListbox.new(w) {
+ width 20
+ height 10
+ yscrollcommand proc{|first,last| s.set first,last}
+ }
+ s.command(proc{|*args| l.yview(*args)})
+ l.pack('side'=>'left', 'expand'=>'yes', 'fill'=>'y')
+ s.pack('side'=>'left', 'expand'=>'yes', 'fill'=>'y')
+ #l.insert(0,'earth.gif', 'earthris.gif', 'mickey.gif', 'teapot.ppm')
+ l.insert(0,'earth.gif', 'earthris.gif', 'teapot.ppm')
+ l.bind('Double-1', proc{|x,y| loadImage $image2a,l,x,y}, '%x %y')
+
+ image2_e.bind 'Return', proc{loadDir l}
+
+}.pack('side'=>'top', 'anchor'=>'w')
+
+# image é…ç½®
+[ TkFrame.new(base_frame, 'height'=>'3m', 'width'=>20),
+ TkLabel.new(base_frame, 'text'=>'ç”»åƒ:'),
+ # TkLabel.new(base_frame, 'image'=>$image2a)
+ Tk::Label.new(base_frame, 'image'=>$image2a)
+].each{|w| w.pack('side'=>'top', 'anchor'=>'w')}
+
+# メソッド定義
+def loadDir(w)
+ w.delete(0,'end')
+ Dir.glob([$dirName,'*'].join(File::Separator)).sort.each{|f|
+ w.insert('end',File.basename(f))
+ }
+end
+
+def loadImage(img,w,x,y)
+ img.file([$dirName, w.get("@#{x},#{y}")].join(File::Separator))
+end
+
diff --git a/jni/ruby/ext/tk/sample/demos-jp/image3.rb b/jni/ruby/ext/tk/sample/demos-jp/image3.rb
new file mode 100644
index 0000000..5c1ceb2
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/demos-jp/image3.rb
@@ -0,0 +1,127 @@
+# -*- coding: utf-8 -*-
+# image3.rb
+#
+# This demonstration script creates a simple collection of widgets
+# that allow you to select and view images in a Tk label.
+#
+# widget demo 'load image' (called by 'widget')
+#
+
+# toplevel widget
+if defined?($image3_demo) && $image3_demo
+ $image3_demo.destroy
+ $image3_demo = nil
+end
+
+# demo toplevel widget
+$image3_demo = TkToplevel.new {|w|
+ title('Image Demonstration #3')
+ iconname("Image3")
+ positionWindow(w)
+}
+
+base_frame = TkFrame.new($image3_demo).pack(:fill=>:both, :expand=>true)
+
+#
+def loadDir3(w)
+ w.delete(0,'end')
+ Dir.glob([$dirName,'*'].join(File::Separator)).sort.each{|f|
+ w.insert('end',File.basename(f))
+ }
+end
+
+# selectAndLoadDir3 --
+# This procedure pops up a dialog to ask for a directory to load into
+# the listobx and (if the user presses OK) reloads the directory
+# listbox from the directory named in the demo's entry.
+#
+# Arguments:
+# w - Name of the toplevel window of the demo.
+def selectAndLoadDir3(w, lbox)
+ dir = Tk.chooseDirectory(:initialdir=>$dirName.value,
+ :parent=>w, :mustexist=>true)
+ if dir.length > 0
+ $dirName.value = dir
+ loadDir3(lbox)
+ end
+end
+
+def loadImage3(w,x,y)
+ $image3a.file([$dirName, w.get("@#{x},#{y}")].join(File::Separator))
+end
+
+
+# label
+msg = TkLabel.new(base_frame) {
+ font $font
+ wraplength '4i'
+ justify 'left'
+ text "ã“ã®ãƒ‡ãƒ¢ã§ã¯Tkã® photo image を使用ã—ã¦ç”»åƒã‚’ 見るã“ã¨ãŒã§ãã¾ã™ã€‚最åˆã«ã‚¨ãƒ³ãƒˆãƒªå†…ã«ã«ãƒ‡ã‚£ãƒ¬ã‚¯ãƒˆãƒªåを入れã¦ä¸‹ã•ã„。次ã«ä¸‹ã®ãƒªã‚¹ãƒˆãƒœãƒƒã‚¯ã‚¹ã«ã“ã®ãƒ‡ã‚£ãƒ¬ã‚¯ãƒˆãƒªã‚’ロードã™ã‚‹ãŸã‚ã€ãƒªã‚¿ãƒ¼ãƒ³ã‚’押ã—ã¦ãã ã•ã„。ãã®å¾Œã€ç”»åƒã‚’é¸æŠžã™ã‚‹ãŸã‚ã«ãƒªã‚¹ãƒˆãƒœãƒƒã‚¯ã‚¹ã®ä¸­ã®ãƒ•ã‚¡ã‚¤ãƒ«åをダブルクリックã—ã¦ä¸‹ã•ã„。"
+}
+msg.pack('side'=>'top')
+
+# frame
+TkFrame.new(base_frame) {|frame|
+ TkButton.new(frame) {
+ #text '了解'
+ text 'é–‰ã˜ã‚‹'
+ command proc{
+ tmppath = $image3_demo
+ $image3_demo = nil
+ tmppath.destroy
+ }
+ }.pack('side'=>'left', 'expand'=>'yes')
+
+ TkButton.new(frame) {
+ text 'コードå‚ç…§'
+ command proc{showCode 'image3'}
+ }.pack('side'=>'left', 'expand'=>'yes')
+
+}.pack('side'=>'bottom', 'fill'=>'x', 'pady'=>'2m')
+
+# variable
+$dirName = TkVariable.new([$demo_dir,'..','images'].join(File::Separator))
+
+# image
+begin
+ $image3a.delete
+rescue
+end
+$image3a = TkPhotoImage.new
+
+#
+image3_f = TkFrame.new(base_frame).pack(:fill=>:both, :expand=>true)
+
+image3_df = TkLabelFrame.new(base_frame, :text=>'ディレクトリ:')
+
+image3_ff = TkLabelFrame.new(base_frame, :text=>'ファイル:',
+ :padx=>'2m', :pady=>'2m')
+image3_lbx = TkListbox.new(image3_ff, :width=>20, :height=>10) {
+ pack(:side=>:left, :fill=>:y, :expand=>true)
+ yscrollbar(TkScrollbar.new(image3_ff).pack(:side=>:left, :fill=>:y,
+ :expand=>true))
+ insert(0, *(%w(earth.gif earthris.gif teapot.ppm)))
+ bind('Double-1', proc{|x,y| loadImage3(self, x, y)}, '%x %y')
+}
+
+image3_ent = TkEntry.new(image3_df, :width=>30, :textvariable=>$dirName){
+ pack(:side=>:left, :fill=>:both, :padx=>'2m', :pady=>'2m', :expand=>true)
+ bind('Return', proc{loadDir3(image3_lbx)})
+}
+
+TkButton.new(image3_df, :pady=>0, :padx=>'2m', :text=>"ディレクトリé¸æŠž",
+ :command=>proc{selectAndLoadDir3(image3_ent, image3_lbx)}) {
+ pack(:side=>:left, :fill=>:y, :padx=>[0, '2m'], :pady=>'2m')
+}
+
+image3_if = TkLabelFrame.new(base_frame, :text=>'イメージ:') {|f|
+ # TkLabel.new(f, :image=>$image3a).pack(:padx=>'2m', :pady=>'2m')
+ Tk::Label.new(f, :image=>$image3a).pack(:padx=>'2m', :pady=>'2m')
+}
+
+Tk.grid(image3_df, '-',
+ :sticky=>:ew, :padx=>'1m', :pady=>'1m', :in=>image3_f)
+Tk.grid(image3_ff, image3_if,
+ :sticky=>:nw, :padx=>'1m', :pady=>'1m', :in=>image3_f)
+TkGrid.columnconfigure(image3_f, 1, :weight=>1)
+
diff --git a/jni/ruby/ext/tk/sample/demos-jp/items.rb b/jni/ruby/ext/tk/sample/demos-jp/items.rb
new file mode 100644
index 0000000..b1d66f3
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/demos-jp/items.rb
@@ -0,0 +1,379 @@
+# -*- coding: utf-8 -*-
+#
+# canvas item types widget demo (called by 'widget')
+#
+
+# toplevel widget ãŒå­˜åœ¨ã™ã‚Œã°å‰Šé™¤ã™ã‚‹
+if defined?($items_demo) && $items_demo
+ $items_demo.destroy
+ $items_demo = nil
+end
+
+# demo 用㮠toplevel widget を生æˆ
+$items_demo = TkToplevel.new {|w|
+ title("Canvas Item Demonstration")
+ iconname("Items")
+ positionWindow(w)
+}
+
+base_frame = TkFrame.new($items_demo).pack(:fill=>:both, :expand=>true)
+
+# label 生æˆ
+TkLabel.new(base_frame) {
+ font $font
+ wraplength '5i'
+ justify 'left'
+ text "ã“ã®ã‚¦ã‚£ãƒ³ãƒ‰ã‚¦ã«ã¯ã‚­ãƒ£ãƒ³ãƒã‚¹ widget ãŒå…¥ã£ã¦ãŠã‚Šã€ãã®ä¸­ã«ã¯ã‚­ãƒ£ãƒ³ãƒã‚¹ widget ãŒã‚µãƒãƒ¼ãƒˆã™ã‚‹æ§˜ã€…ãªã‚¿ã‚¤ãƒ—ã®ã‚¢ã‚¤ãƒ†ãƒ ã®ä¾‹ãŒå…¥ã£ã¦ã„ã¾ã™ã€‚次ã®ã‚ˆã†ãªæ“作ãŒã§ãã¾ã™ã€‚\n ボタン-1 ドラッグ:\tアイテムを動ã‹ã™ã€‚\n ボタン-2 ドラッグ:\t見ãˆã¦ã„る部分をãšã‚‰ã™ã€‚\n ボタン-3 ドラッグ:\t領域を囲ã†ã€‚\n コントロール-F:\t領域ã®ä¸‹ã®ã‚¢ã‚¤ãƒ†ãƒ ã‚’表示ã™ã‚‹ã€‚"
+}.pack('side'=>'top')
+
+# frame 生æˆ
+TkFrame.new(base_frame) {|frame|
+ TkButton.new(frame) {
+ #text '了解'
+ text 'é–‰ã˜ã‚‹'
+ command proc{
+ tmppath = $items_demo
+ $items_demo = nil
+ tmppath.destroy
+ }
+ }.pack('side'=>'left', 'expand'=>'yes')
+
+ TkButton.new(frame) {
+ text 'コードå‚ç…§'
+ command proc{showCode 'items'}
+ }.pack('side'=>'left', 'expand'=>'yes')
+}.pack('side'=>'bottom', 'fill'=>'x', 'pady'=>'2m')
+
+# frame 生æˆ
+cvs = nil
+TkFrame.new(base_frame) {|cf|
+ # canvas 生æˆ
+ cvs = TkCanvas.new(cf) {|c|
+ focus
+ scrollregion '0c 0c 30c 24c'
+ width '15c'
+ height '10c'
+ relief 'sunken'
+ borderwidth 2
+
+ hs = TkScrollbar.new(cf) {|s|
+ orient 'horizontal'
+ command proc{|*args| c.xview(*args)}
+ c.xscrollcommand proc{|first,last| s.set first,last}
+ }
+
+ vs = TkScrollbar.new(cf) {|s|
+ command proc{|*args| c.yview(*args)}
+ c.yscrollcommand proc{|first,last| s.set first,last}
+ }
+
+ if $tk_version =~ /^4\.[01]/
+ hs.pack('side'=>'bottom', 'fill'=>'x')
+ vs.pack('side'=>'right', 'fill'=>'y')
+ c.pack('in'=>cf, 'expand'=>'yes', 'fill'=>'both')
+
+ else
+ c.grid('in'=>cf, 'row'=>0, 'column'=>0,
+ 'rowspan'=>1, 'columnspan'=>1, 'sticky'=>'news')
+ vs.grid('row'=>0, 'column'=>1,
+ 'rowspan'=>1, 'columnspan'=>1, 'sticky'=>'news')
+ hs.grid('row'=>1, 'column'=>0,
+ 'rowspan'=>1, 'columnspan'=>1, 'sticky'=>'news')
+ TkGrid.rowconfigure(cf, 0, 'weight'=>1, 'minsize'=>0)
+ TkGrid.columnconfigure(cf, 0, 'weight'=>1, 'minsize'=>0)
+
+ end
+
+ }
+}.pack('side'=>'top', 'fill'=>'both', 'expand'=>'yes')
+
+# Display a 3x3 rectangular grid
+TkcRectangle.new(cvs, '0c', '0c', '30c', '24c', 'width'=>2)
+TkcLine.new(cvs, '0c', '8c', '30c', '8c', 'width'=>2)
+TkcLine.new(cvs, '0c', '16c', '30c', '16c', 'width'=>2)
+TkcLine.new(cvs, '10c', '0c', '10c', '24c', 'width'=>2)
+TkcLine.new(cvs, '20c', '0c', '20c', '24c', 'width'=>2)
+
+if $tk_version =~ /^4.*/
+ font1 = '-Adobe-Helvetica-Medium-R-Normal--*-120-*-*-*-*-*-*'
+ font2 = '-Adobe-Helvetica-Bold-R-Normal--*-240-*-*-*-*-*-*'
+else
+ font1 = 'Helvetica 12'
+ font2 = 'Helvetica 24 bold'
+end
+if TkWinfo.depth($root).to_i > 1
+ blue = 'DeepSkyBlue3'
+ red = 'red'
+ bisque = 'bisque3'
+ green = 'SeaGreen3'
+else
+ blue = 'black'
+ red = 'black'
+ bisque = 'black'
+ green = 'black'
+end
+
+# tag オブジェクトを生æˆ
+$tag_item = TkcGroup.new(cvs)
+
+# Set up demos within each of the areas of the grid.
+TkcText.new(cvs, '5c', '.2c', 'text'=>'ライン', 'anchor'=>'n')
+TkcLine.new(cvs, '1c', '1c', '3c', '1c', '1c', '4c', '3c', '4c',
+ 'width'=>2, 'fill'=>blue, 'capstyle'=>'butt',
+ 'join'=>'miter', 'tags'=>$tag_item )
+TkcLine.new(cvs, '4.67c','1c','4.67c','4c', 'arrow'=>'last', 'tags'=>$tag_item)
+TkcLine.new(cvs, '6.33c','1c','6.33c','4c', 'arrow'=>'both', 'tags'=>$tag_item)
+TkcLine.new(cvs, '5c','6c','9c','6c','9c','1c','8c','1c','8c','4.8c','8.8c',
+ '4.8c','8.8c','1.2c','8.2c','1.2c','8.2c','4.6c','8.6c','4.6c',
+ '8.6c','1.4c','8.4c','1.4c','8.4c','4.4c',
+ 'width'=>3, 'fill'=>red, 'tags'=>$tag_item )
+TkcLine.new(cvs, '1c','5c','7c','5c','7c','7c','9c','7c', 'width'=>'.5c',
+ 'stipple'=>'@'+[$demo_dir,'..',
+ 'images','gray25.xbm'].join(File::Separator),
+ 'arrow'=>'both', 'arrowshape'=>'15 15 7', 'tags'=>$tag_item )
+TkcLine.new(cvs, '1c','7c','1.75c','5.8c','2.5c','7c','3.25c','5.8c','4c','7c',
+ 'width'=>'.5c', 'capstyle'=>'round', 'join'=>'round',
+ 'tags'=>$tag_item )
+
+TkcText.new(cvs, '15c', '.2c',
+ 'text'=>'曲線 (滑らã‹ã«ã¤ãªã„ã ç›´ç·š)', 'anchor'=>'n')
+TkcLine.new(cvs, '11c','4c','11.5c','1c','13.5c','1c','14c','4c',
+ 'smooth'=>'on', 'fill'=>blue, 'tags'=>$tag_item )
+TkcLine.new(cvs, '15.5c','1c','19.5c','1.5c','15.5c','4.5c','19.5c','4c',
+ 'smooth'=>'on', 'arrow'=>'both', 'width'=>3, 'tags'=>$tag_item )
+TkcLine.new(cvs, '12c','6c','13.5c','4.5c','16.5c','7.5c','18c','6c',
+ '16.5c','4.5c','13.5c','7.5c','12c','6c',
+ 'smooth'=>'on', 'width'=>'3m', 'capstyle'=>'round',
+ 'stipple'=>'@'+[$demo_dir, '..',
+ 'images', 'gray25.xbm'].join(File::Separator),
+ 'fill'=>red, 'tags'=>$tag_item )
+
+TkcText.new(cvs, '25c', '.2c', 'text'=>'多角形', 'anchor'=>'n')
+TkcPolygon.new(cvs, '21c','1.0c','22.5c','1.75c','24c','1.0c','23.25c','2.5c',
+ '24c','4.0c','22.5c','3.25c','21c','4.0c','21.75c','2.5c',
+ 'fill'=>'green', 'outline'=>'black', 'width'=>4,
+ 'tags'=>$tag_item )
+TkcPolygon.new(cvs, '25c','4c','25c','4c','25c','1c','26c','1c','27c','4c',
+ '28c','1c','29c','1c','29c','4c','29c','4c',
+ 'fill'=>red, 'smooth'=>'on', 'tags'=> $tag_item)
+TkcPolygon.new(cvs, '22c','4.5c','25c','4.5c','25c','6.75c','28c','6.75c',
+ '28c','5.25c','24c','5.25c','24c','6.0c','26c','6c','26c',
+ '7.5c','22c','7.5c',
+ 'stipple'=>'@' + [$demo_dir, '..',
+ 'images', 'gray25.xbm'].join(File::Separator),
+ 'outline'=>'black', 'tags'=>$tag_item )
+
+TkcText.new(cvs, '5c', '8.2c', 'text'=>'矩形', 'anchor'=>'n')
+TkcRectangle.new(cvs, '1c','9.5c','4c','12.5c',
+ 'outline'=>red, 'width'=>'3m', 'tags'=>$tag_item)
+TkcRectangle.new(cvs, '0.5c','13.5c','4.5c','15.5c',
+ 'fill'=>green, 'tags'=>$tag_item )
+TkcRectangle.new(cvs, '6c','10c','9c','15c', 'outline'=>'',
+ 'stipple'=>'@'+[$demo_dir,'..',
+ 'images','gray25.xbm'].join(File::Separator),
+ 'fill'=>blue, 'tags'=>$tag_item )
+
+TkcText.new(cvs, '15c', '8.2c', 'text'=>'楕円', 'anchor'=>'n')
+TkcOval.new(cvs, '11c','9.5c','14c','12.5c',
+ 'outline'=>red, 'width'=>'3m', 'tags'=>$tag_item)
+TkcOval.new(cvs, '10.5c','13.5c','14.5c','15.5c',
+ 'fill'=>green, 'tags'=>$tag_item )
+TkcOval.new(cvs, '16c','10c','19c','15c', 'outline'=>'',
+ 'stipple'=>'@'+[$demo_dir,'..',
+ 'images','gray25.xbm'].join(File::Separator),
+ 'fill'=>blue, 'tags'=>$tag_item )
+
+TkcText.new(cvs, '25c', '8.2c', 'text'=>'テキスト', 'anchor'=>'n')
+TkcRectangle.new(cvs, '22.4c','8.9c','22.6c','9.1c')
+TkcText.new(cvs, '22.5c', '9c', 'anchor'=>'n', 'font'=>font1, 'width'=>'4c',
+ 'text'=>'短ã„テキスト。ワードラップã€å·¦æƒãˆã€ã‚¢ãƒ³ã‚«ãƒ¼ã¯åŒ—(上)。□ã¯å„テキストã®ã‚¢ãƒ³ã‚«ãƒ¼ãƒã‚¤ãƒ³ãƒˆã‚’示ã™ã€‚', 'tags'=>$tag_item )
+TkcRectangle.new(cvs, '25.4c','10.9c','25.6c','11.1c')
+TkcText.new(cvs, '25.5c', '11c', 'anchor'=>'w', 'font'=>font1, 'fill'=>blue,
+ 'text'=>"ã„ãã¤ã‹ã®è¡Œã€‚\nãã‚Œãžã‚Œç‹¬ç«‹ã«\nè¡Œæƒãˆã€‚\nå…¨ã¦å·¦ç«¯ãŒã‚¢ãƒ³ã‚«ãƒ¼ã•ã‚Œã¦ã„る。", 'justify'=>'center', 'tags'=>$tag_item )
+TkcRectangle.new(cvs, '24.9c','13.9c','25.1c','14.1c')
+if $tk_version =~ /^4\.[01]/
+ TkcText.new(cvs, '25c', '14c', 'anchor'=>'c', 'font'=>font2, 'fill'=>red,
+ 'stipple'=>'@' + [$demo_dir, '..',
+ 'images', 'grey.5'].join(File::Separator),
+ 'text'=>'Stippled characters', 'tags'=>$tag_item )
+else
+ TkcText.new(cvs, '25c', '14c', 'anchor'=>'c', 'font'=>font2, 'fill'=>red,
+ 'stipple'=>'gray50', 'text'=>'Stippled characters',
+ 'tags'=>$tag_item )
+end
+
+TkcText.new(cvs, '5c', '16.2c', 'text'=>'弧', 'anchor'=>'n')
+TkcArc.new(cvs, '0.5c','17c','7c','20c', 'fill'=>green, 'outline'=>'black',
+ 'start'=>45, 'extent'=>270, 'style'=>'pieslice', 'tags'=>$tag_item)
+#TkcArc.new(cvs, '6.5c','17c','9.5c','20c', 'width'=>'4m', 'style'=>'arc',
+# 'outline'=>blue, 'start'=>135, 'extent'=>270,
+# 'outlinestipple'=>'@' + ['images', 'grey.25'].join(File::Separator),
+# 'tags'=>$tag_item)
+TkcArc.new(cvs, '6.5c','17c','9.5c','20c', 'width'=>'4m', 'style'=>'arc',
+ 'outline'=>blue, 'start'=>135, 'extent'=>270,
+ 'outlinestipple'=>'@'+[$demo_dir, '..',
+ 'images','gray25.xbm'].join(File::Separator),
+ 'tags'=>$tag_item)
+TkcArc.new(cvs, '0.5c','20c','9.5c','24c', 'width'=>'4m', 'style'=>'pieslice',
+ 'fill'=>'', 'outline'=>red, 'start'=>225, 'extent'=>90,
+ 'tags'=>$tag_item)
+TkcArc.new(cvs, '5.5c','20.5c','9.5c','23.5c', 'width'=>'4m', 'style'=>'chord',
+ 'fill'=>blue, 'outline'=>'', 'start'=>45, 'extent'=>270,
+ 'tags'=>$tag_item)
+
+TkcText.new(cvs, '15c', '16.2c', 'text'=>'ビットマップ', 'anchor'=>'n')
+#TkcBitmap.new(cvs, '13c','20c',
+# 'bitmap'=>'@' + ['images', 'face'].join(File::Separator),
+# 'tags'=>$tag_item)
+TkcBitmap.new(cvs, '13c','20c',
+ 'bitmap'=>'@' + [$demo_dir, '..',
+ 'images', 'face.xbm'].join(File::Separator),
+ 'tags'=>$tag_item)
+#TkcBitmap.new(cvs, '17c','18.5c',
+# 'bitmap'=>'@' + ['images', 'noletters'].join(File::Separator),
+# 'tags'=>$tag_item)
+TkcBitmap.new(cvs, '17c','18.5c',
+ 'bitmap'=>'@' + [$demo_dir, '..',
+ 'images', 'noletter.xbm'].join(File::Separator),
+ 'tags'=>$tag_item)
+#TkcBitmap.new(cvs, '17c','21.5c',
+# 'bitmap'=>'@' + ['images', 'letters'].join(File::Separator),
+# 'tags'=>$tag_item)
+# ↓ã®å½¢å¼ã§ã‚‚å¯èƒ½
+TkcBitmap.new(cvs, '17c','21.5c') {
+ bitmap '@' + [$demo_dir, '..', 'images', 'letters.xbm'].join(File::Separator)
+ tags $tag_item
+}
+#TkcBitmap.new(cvs, '17c','21.5c') {
+# bitmap '@' + ['images', 'letters'].join(File::Separator)
+# tags $tag_item
+#}
+
+TkcText.new(cvs, '25c', '16.2c', 'text'=>'ウィンドウ', 'anchor'=>'n')
+TkButton.new(cvs) {|b|
+ text '押ã—ã¦ã­'
+ command proc{butPress cvs, red}
+ TkcWindow.new(cvs, '21c','18c',
+ 'window'=>b, 'anchor'=>'nw', 'tags'=>$tag_item)
+}
+TkEntry.new(cvs, 'width'=>20, 'relief'=>'sunken') {|e|
+ insert 'end', '編集ã—ã¦ã­'
+ TkcWindow.new(cvs, '21c','21c',
+ 'window'=>e, 'anchor'=>'nw', 'tags'=>$tag_item)
+}
+TkScale.new(cvs, 'from'=>0, 'to'=>100, 'length'=>'6c', 'sliderlength'=>'.4c',
+ 'width'=>'.5c', 'tickinterval'=>0 ) {|scl|
+ TkcWindow.new(cvs, '28.5c','17.5c',
+ 'window'=>scl, 'anchor'=>'n', 'tags'=>$tag_item)
+}
+TkcText.new(cvs, '21c', '17.9c', 'text'=>'ボタン:', 'anchor'=>'sw')
+TkcText.new(cvs, '21c', '20.9c', 'text'=>'エントリ:', 'anchor'=>'sw')
+TkcText.new(cvs, '28.5c', '17.4c', 'text'=>'スケール:', 'anchor'=>'s')
+
+# Set up event bindings for canvas:
+cvs.itembind($tag_item, 'Any-Enter', proc{itemEnter cvs})
+cvs.itembind($tag_item, 'Any-Leave', proc{itemLeave cvs})
+cvs.bind('2', proc{|x,y| cvs.scan_mark x,y}, '%x %y')
+cvs.bind('B2-Motion', proc{|x,y| cvs.scan_dragto x,y}, '%x %y')
+cvs.bind('3', proc{|x,y| itemMark cvs,x,y}, '%x %y')
+cvs.bind('B3-Motion', proc{|x,y| itemStroke cvs,x,y}, '%x %y')
+cvs.bind('Control-f', proc{itemsUnderArea cvs})
+cvs.bind('1', proc{|x,y| itemStartDrag cvs,x,y}, '%x %y')
+cvs.bind('B1-Motion', proc{|x,y| itemDrag cvs,x,y}, '%x %y')
+# Utility methods for highlighting the item under the pointer
+
+$restoreCmd = nil
+def itemEnter (c)
+ if TkWinfo.depth(c).to_i == 1
+ $restoreCmd = nil
+ return
+ end
+ type = c.itemtype('current')
+ if type == TkcWindow
+ $restoreCmd = nil
+ return
+ end
+ if type == TkcBitmap
+ bg = (c.itemconfiginfo('current', 'background'))[4]
+ $restoreCmd = proc{c.itemconfigure 'current', 'background', bg}
+ c.itemconfigure 'current', 'background', 'SteelBlue2'
+ return
+ end
+ fill = (c.itemconfiginfo('current', 'fill'))[4]
+ if (type == TkcRectangle || type == TkcOval || type == TkcArc) && fill == []
+ outline = (c.itemconfiginfo('current', 'outline'))[4]
+ $restoreCmd = proc{c.itemconfigure 'current', 'outline', outline}
+ c.itemconfigure 'current', 'outline', 'SteelBlue2'
+ else
+ $restoreCmd = proc{c.itemconfigure 'current', 'fill', fill}
+ c.itemconfigure 'current', 'fill', 'SteelBlue2'
+ end
+end
+
+def itemLeave(c)
+ $restoreCmd.call if $restoreCmd
+end
+
+# Utility methods for stroking out a rectangle and printing what's
+# underneath the rectangle's area.
+
+def itemMark(c,x,y)
+ $areaX1 = c.canvasx(x)
+ $areaY1 = c.canvasy(y)
+ c.delete 'area'
+end
+
+def itemStroke(c,x,y)
+ x = c.canvasx(x)
+ y = c.canvasy(y)
+ if $areaX1 != x && $areaY1 != y
+ c.delete 'area'
+ c.addtag_withtag 'area', TkcRectangle.new(c, $areaX1, $areaY1, x, y,
+ '-outline', 'black')
+ $areaX2 = x
+ $areaY2 = y
+ end
+end
+
+def itemsUnderArea(c)
+ area = c.find_withtag('area')
+ items = []
+ c.find_enclosed($areaX1,$areaY1,$areaX2,$areaY2).each{|i|
+ items.push(i) if i.gettags.include?($tag_item)
+ }
+ print "Items enclosed by area: #{items.inspect}\n"; STDOUT.flush
+ items.clear
+ c.find_overlapping($areaX1,$areaY1,$areaX2,$areaY2).each{|i|
+ items.push(i) if i.gettags.include?($tag_item)
+ }
+ print "Items overlapping area: #{items.inspect}\n"; STDOUT.flush
+end
+
+$areaX1 = 0
+$areaY1 = 0
+$areaX2 = 0
+$areaY2 = 0
+
+# Utility methods to support dragging of items.
+
+def itemStartDrag(c,x,y)
+ $lastX = c.canvasx(x)
+ $lastY = c.canvasy(y)
+end
+
+def itemDrag(c,x,y)
+ x = c.canvasx(x)
+ y = c.canvasy(y)
+ c.move('current', x - $lastX, y - $lastY)
+ $lastX = x
+ $lastY = y
+end
+
+# Method that's invoked when the button embedded in the canvas
+# is invoked.
+
+def butPress(w,color)
+ i = TkcText.new(w, '25c', '18.1c',
+ 'text'=>'ã„ã¦ã¦!!', 'fill'=>color, 'anchor'=>'n')
+ Tk.after(500, proc{w.delete i})
+end
diff --git a/jni/ruby/ext/tk/sample/demos-jp/ixset b/jni/ruby/ext/tk/sample/demos-jp/ixset
new file mode 100644
index 0000000..40a77f4
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/demos-jp/ixset
@@ -0,0 +1,333 @@
+#!/usr/bin/env ruby
+
+# ixset --
+# A nice interface to "xset" to change X server settings
+#
+
+require 'tk'
+
+class Xsettings
+ #
+ # Button actions
+ #
+ def quit
+ @root.destroy
+ end
+
+ def ok
+ writesettings
+ quit
+ end
+
+ def cancel
+ readsettings
+ dispsettings
+ end
+
+ # apply is just "writesettings"
+
+
+ #
+ # Read current settings
+ #
+ def readsettings
+ xfd = open("|xset q", 'r')
+ xfd.readlines.each{|line|
+ fields = line.chomp.strip.split(/\s+/)
+ case fields[0]
+ when "auto"
+ if fields[1] == 'repeat:'
+ @kbdrep = fields[2]
+ @w_kbdrep.set(@kbdrep)
+ @kbdcli = fields[6]
+ end
+
+ when "bell"
+ @bellvol = fields[2]
+ @bellpit = fields[5]
+ @belldur = fields[8]
+
+ when "acceleration:"
+ @mouseacc = fields[1]
+ @mousethr = fields[3]
+
+ when "prefer"
+ if fields[2] == 'yes'
+ @screenbla = 'blank'
+ else
+ @screenbla = 'noblank'
+ end
+ @w_screenbla.set(@screenbla)
+
+ when "timeout:"
+ @screentim = fields[1]
+ @screencyc = fields[3]
+
+ end
+ }
+
+ xfd.close
+ end
+
+ #
+ # Write settings into the X server
+ #
+ def writesettings
+ @bellvol = @w_bellvol.get
+ @bellpit = @w_bellpit.get
+ @belldur = @w_belldur.get
+
+ @kbdrep = @w_kbdrep.get
+ if @kbdrep == 'on'
+ @kbdcli = @w_kbdcli.get
+ else
+ @kbdcli = 'off'
+ end
+
+ @mouseacc = @w_mouseacc.get
+ @mousethr = @w_mousethr.get
+
+ @screentim = @w_screentim.get
+ @screencyc = @w_screencyc.get
+ @screenbla = @w_screenbla.get
+
+ system("xset \
+ b #{@bellvol} #{@bellpit} #{@belldur} \
+ c #{@kbdcli} \
+ r #{@kbdrep} \
+ m #{@mouseacc} #{@mousethr} \
+ s #{@screentim} #{@screencyc} \
+ s #{@screenbla}")
+ end
+
+ #
+ # Sends all settings to the window
+ #
+ def dispsettings
+ @w_bellvol.set(@bellvol)
+ @w_bellpit.set(@bellpit)
+ @w_belldur.set(@belldur)
+
+ @w_kbdonoff.set(@w_kbdrep.get)
+ @w_kbdcli.set(@kbdcli)
+
+ @w_mouseacc.set(@mouseacc)
+ @w_mousethr.set(@mousethr)
+
+ @w_screenblank.set(@w_screenbla.get)
+ @w_screenpat.set(@w_screenbla.get)
+
+ @w_screentim.set(@screentim)
+ @w_screencyc.set(@screencyc)
+ end
+
+ #
+ # Create all windows, and pack them
+ #
+ class LabelEntry
+ def initialize(parent, text, length)
+ @frame = TkFrame.new(parent)
+ TkLabel.new(@frame, 'text'=>text).pack('side'=>'left','expand'=>'y')
+ @entry = TkEntry.new(@frame, 'width'=>length, 'relief'=>'sunken') {
+ pack('side'=>'left','expand'=>'y')
+ }
+ end
+ def pack(keys)
+ @frame.pack(keys)
+ end
+ def get
+ @entry.value
+ end
+ def set(value)
+ @entry.delete(0,'end')
+ @entry.insert(0, value)
+ end
+ end
+
+ def createwindows
+ win = self
+
+ #
+ # Buttons
+ #
+ buttons = TkFrame.new(@root) {|f|
+ [ TkButton.new(f, 'command'=>proc{win.ok}, 'text'=>'Ok'),
+ TkButton.new(f, 'command'=>proc{win.writesettings}, 'text'=>'Apply'),
+ TkButton.new(f, 'command'=>proc{win.cancel}, 'text'=>'Cancel'),
+ TkButton.new(f, 'command'=>proc{win.quit}, 'text'=>'Quit') ].each{|b|
+ b.pack('side'=>'left', 'expand'=>'yes', 'pady'=>5)
+ }
+ }
+
+ #
+ # Bell settings
+ #
+ bell = TkFrame.new(@root, 'relief'=>'raised', 'borderwidth'=>2)
+ l = TkLabel.new(bell, 'text'=>'Bell Settings')
+ @w_bellvol = TkScale.new(bell, 'from'=>0, 'to'=>100, 'length'=>200,
+ 'tickinterval'=>20, 'orient'=>'horizontal',
+ 'label'=>"Volume (%)")
+
+ f = TkFrame.new(bell)
+ @w_bellpit = LabelEntry.new(f, "Pitch (Hz)", 6)
+ @w_bellpit.pack('side'=>'left', 'padx'=>5)
+ @w_belldur = LabelEntry.new(f, "Duration (ms)", 6)
+ @w_belldur.pack('side'=>'right', 'padx'=>5)
+
+ l.pack('side'=>'top', 'expand'=>'yes')
+ @w_bellvol.pack('side'=>'top', 'expand'=>'yes')
+ f.pack('side'=>'top', 'expand'=>'yes')
+
+ #
+ # Keyboard settings
+ #
+ kbdonoff = nil
+ kbdcli = nil
+ kbd = TkFrame.new(@root, 'relief'=>'raised', 'borderwidth'=>2)
+ l = TkLabel.new(kbd, 'text'=>'Keyboard Repeat Settings')
+ f = TkFrame.new(kbd)
+ @w_kbdonoff = TkCheckButton.new(f, 'text'=>'On', 'relief'=>'flat',
+ 'onvalue'=>'on', 'offvalue'=>'off',
+ 'variable'=>@w_kbdrep ) {
+ def self.set(value)
+ if value == 'on'
+ self.select
+ else
+ self.deselect
+ end
+ end
+ pack('side'=>'left', 'expand'=>'yes', 'fill'=>'both')
+ }
+ @w_kbdcli = TkScale.new(f, 'from'=>0, 'to'=>100, 'length'=>200,
+ 'tickinterval'=>20, 'orient'=>'horizontal',
+ 'label'=>'Click Volume (%)')
+ @w_kbdcli.pack('side'=>'left', 'expand'=>'yes')
+ l.pack('side'=>'top', 'expand'=>'yes')
+ f.pack('side'=>'top', 'expand'=>'yes', 'pady'=>2, 'fill'=>'x')
+
+ #
+ # Mouse settings
+ #
+ mouse = TkFrame.new(@root, 'relief'=>'raised', 'borderwidth'=>2)
+ l = TkLabel.new(mouse, 'text'=>'Mouse Settings')
+ f = TkFrame.new(mouse)
+ @w_mouseacc = LabelEntry.new(f, 'Acceleration', 3)
+ @w_mouseacc.pack('side'=>'left')
+ @w_mousethr = LabelEntry.new(f, 'Threshold (pixels)', 3)
+ @w_mousethr.pack('side'=>'right')
+ l.pack('side'=>'top')
+ f.pack('side'=>'top', 'expand'=>'yes')
+
+ #
+ # Screen Saver settings
+ #
+ screen = TkFrame.new(@root, 'relief'=>'raised', 'borderwidth'=>2)
+ l = TkLabel.new(screen, 'text'=>'Screen-saver Settings')
+ f = TkFrame.new(screen)
+ ff1 = TkFrame.new(f)
+ [ @w_screenblank = TkRadioButton.new(ff1, 'text'=>'Blank',
+ 'relief'=>'flat',
+ 'variable'=>@w_screenbla,
+ 'value'=>'blank') {
+ def self.set(value)
+ if value == 'blank'
+ self.select
+ else
+ self.deselect
+ end
+ end
+ },
+ @w_screenpat = TkRadioButton.new(ff1, 'text'=>'Pattern',
+ 'relief'=>'flat',
+ 'variable'=>@w_screenbla,
+ 'value'=>'noblank') {
+ def self.set(value)
+ if value != 'blank'
+ self.select
+ else
+ self.deselect
+ end
+ end
+ }
+ ].each {|w| w.pack('side'=>'top', 'pady'=>2, 'anchor'=>'w') }
+
+ ff2 = TkFrame.new(f)
+ [ @w_screentim = LabelEntry.new(ff2, 'Timeout (s)', 5),
+ @w_screencyc = LabelEntry.new(ff2, 'Cycle (s)', 5) ].each{|w|
+ w.pack('side'=>'top', 'pady'=>2, 'anchor'=>'e')
+ }
+
+ ff1.pack('side'=>'left')
+ ff2.pack('side'=>'left')
+
+ l.pack('side'=>'top')
+ f.pack('side'=>'top', 'expand'=>'yes')
+
+ #
+ # Main window
+ #
+ buttons.pack('side'=>'top', 'fill'=>'both')
+ bell.pack('side'=>'top', 'fill'=>'both', 'ipady'=>5, 'expand'=>'yes')
+ kbd.pack('side'=>'top', 'fill'=>'both', 'ipady'=>5, 'expand'=>'yes')
+ mouse.pack('side'=>'top', 'fill'=>'both', 'ipady'=>5, 'expand'=>'yes')
+ screen.pack('side'=>'top', 'fill'=>'both', 'ipady'=>5, 'expand'=>'yes')
+
+ #
+ # Let the user resize our window
+ #
+ @root.minsize(10,10)
+ end
+
+ def initialize
+ @root = TkRoot.new
+
+ @kbdrep = 'on'
+ @w_kbdrep = TkVariable.new(@kbdrep)
+ def @w_kbdrep.get
+ self.value
+ end
+ def @w_kbdrep.set(val)
+ self.value=val
+ end
+
+ @kbdcli = 0
+
+ @bellvol = 100
+ @bellpit = 440
+ @belldur = 100
+
+ @mouseacc = "3/1"
+ @mousethr = 4
+
+ @screenbla = "blank"
+ @w_screenbla = TkVariable.new(@screenbla)
+ def @w_screenbla.get
+ self.value
+ end
+ def @w_screenbla.set(val)
+ self.value=val
+ end
+
+ @screentim = 600
+ @screencyc = 600
+
+ #
+ # Listen what "xset" tells us...
+ #
+ readsettings
+
+ #
+ # Create all windows
+ #
+ createwindows
+
+ #
+ # Write xset parameters
+ #
+ dispsettings
+ end
+end
+
+Xsettings.new
+
+Tk.mainloop
diff --git a/jni/ruby/ext/tk/sample/demos-jp/ixset2 b/jni/ruby/ext/tk/sample/demos-jp/ixset2
new file mode 100644
index 0000000..e11ce2a
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/demos-jp/ixset2
@@ -0,0 +1,369 @@
+#!/usr/bin/env ruby
+# -*- coding: utf-8 -*-
+#
+# ixset --
+# A nice interface to "xset" to change X server settings
+#
+
+require 'tk'
+
+class Xsettings
+ #
+ # Button actions
+ #
+ def quit
+ @root.destroy
+ end
+
+ def ok
+ writesettings
+ quit
+ end
+
+ def cancel
+ readsettings
+ dispsettings
+ @btn_APPLY.state(:disabled)
+ @btn_CANCEL.state(:disabled)
+ end
+
+ # apply is just "writesettings"
+ def apply
+ writesettings
+ @btn_APPLY.state(:disabled)
+ @btn_CANCEL.state(:disabled)
+ end
+
+ #
+ # Read current settings
+ #
+ def readsettings
+ xfd = open("|xset q", 'r')
+ xfd.readlines.each{|line|
+ fields = line.chomp.strip.split(/\s+/)
+ case fields[0]
+ when "auto"
+ if fields[1] == 'repeat:'
+ @kbdrep = fields[2]
+ @w_kbdrep.set(@kbdrep)
+ @kbdcli = fields[6]
+ end
+
+ when "bell"
+ @bellvol = fields[2]
+ @bellpit = fields[5]
+ @belldur = fields[8]
+
+ when "acceleration:"
+ @mouseacc = fields[1]
+ @mousethr = fields[3]
+
+ when "prefer"
+ if fields[2] == 'yes'
+ @screenbla = 'blank'
+ else
+ @screenbla = 'noblank'
+ end
+ @w_screenbla.set(@screenbla)
+
+ when "timeout:"
+ @screentim = fields[1]
+ @screencyc = fields[3]
+
+ end
+ }
+
+ xfd.close
+ end
+
+ #
+ # Write settings into the X server
+ #
+ def writesettings
+ @bellvol = @w_bellvol.get
+ @bellpit = @w_bellpit.get
+ @belldur = @w_belldur.get
+
+ @kbdrep = @w_kbdrep.get
+ if @kbdrep == 'on'
+ @kbdcli = @w_kbdcli.get
+ else
+ @kbdcli = 'off'
+ end
+
+ @mouseacc = @w_mouseacc.get
+ @mousethr = @w_mousethr.get
+
+ @screentim = @w_screentim.get
+ @screencyc = @w_screencyc.get
+ @screenbla = @w_screenbla.get
+
+ system("xset \
+ b #{@bellvol} #{@bellpit} #{@belldur} \
+ c #{@kbdcli} \
+ r #{@kbdrep} \
+ m #{@mouseacc} #{@mousethr} \
+ s #{@screentim} #{@screencyc} \
+ s #{@screenbla}")
+ end
+
+ #
+ # Sends all settings to the window
+ #
+ def dispsettings
+ @w_bellvol.set(@bellvol)
+ @w_bellpit.set(@bellpit)
+ @w_belldur.set(@belldur)
+
+ @w_kbdonoff.set(@w_kbdrep.get)
+ @w_kbdcli.set(@kbdcli)
+
+ @w_mouseacc.set(@mouseacc)
+ @w_mousethr.set(@mousethr)
+
+ @w_screenblank.set(@w_screenbla.get)
+ @w_screenpat.set(@w_screenbla.get)
+
+ @w_screentim.set(@screentim)
+ @w_screencyc.set(@screencyc)
+ end
+
+ #
+ # Create all windows, and pack them
+ #
+ class LabelEntry
+ def initialize(parent, text, length, range=[])
+ @frame = TkFrame.new(parent)
+ TkLabel.new(@frame, 'text'=>text).pack('side'=>'left')
+ if range.size > 0
+ @entry = TkSpinbox.new(@frame, 'width'=>length, 'relief'=>'sunken',
+ 'from'=>range[0], 'to'=>range[1])
+ else
+ @entry = TkEntry.new(@frame, 'width'=>length, 'relief'=>'sunken')
+ end
+ @entry.pack('side'=>'right','expand'=>'y', 'fill'=>'x')
+ end
+ def epath
+ @frame
+ end
+ def pack(keys)
+ @frame.pack(keys)
+ end
+ def get
+ @entry.value
+ end
+ def set(value)
+ @entry.delete(0,'end')
+ @entry.insert(0, value)
+ end
+ end
+
+ def createwindows
+ win = self
+
+ #
+ # Buttons
+ #
+ btn_frame = TkFrame.new(@root)
+ buttons = [
+ @btn_OK = TkButton.new(btn_frame, 'command'=>proc{win.ok},
+ 'default'=>'active', 'text'=>'了解'),
+ @btn_APPLY = TkButton.new(btn_frame, 'command'=>proc{win.writesettings},
+ 'default'=>'normal', 'text'=>'é©ç”¨',
+ 'state'=>'disabled'),
+ @btn_CANCEL = TkButton.new(btn_frame, 'command'=>proc{win.cancel},
+ 'default'=>'normal', 'text'=>'å–消',
+ 'state'=>'disabled'),
+ @btn_QUIT = TkButton.new(btn_frame, 'command'=>proc{win.quit},
+ 'default'=>'normal', 'text'=>'中止')
+ ]
+ buttons.each{|b| b.pack('side'=>'left', 'expand'=>'yes', 'pady'=>5) }
+
+ @root.bind('Return', proc{@btn_OK.flash; @btn_OK.invoke})
+ @root.bind('Escape', proc{@btn_QUIT.flash; @btn_QUIT.invoke})
+ @root.bind('1', proc{|w|
+ unless buttons.index(w)
+ @btn_APPLY.state(:normal)
+ @btn_CANCEL.state(:normal)
+ end
+ }, '%W')
+ @root.bind('Key', proc{|w, k|
+ unless buttons.index(w)
+ case k
+ when 'Return', 'Escape', 'Tab', /.*Shift.*/
+ # do nothing
+ else
+ @btn_APPLY.state(:normal)
+ @btn_CANCEL.state(:normal)
+ end
+ end
+ }, '%W %K')
+
+ #
+ # Bell settings
+ #
+ bell = TkLabelframe.new(@root, 'text'=>'ベル設定',
+ 'padx'=>'1.5m', 'pady'=>'1.5m')
+ @w_bellvol = TkScale.new(bell, 'from'=>0, 'to'=>100, 'length'=>200,
+ 'tickinterval'=>20, 'orient'=>'horizontal',
+ 'label'=>"éŸ³é‡ (%)")
+
+ f = TkFrame.new(bell)
+ @w_bellpit = LabelEntry.new(f, "音程 (Hz)", 6, [25, 20000])
+ @w_bellpit.pack('side'=>'left', 'padx'=>5)
+ @w_belldur = LabelEntry.new(f, "æŒç¶šæ™‚é–“ (ms)", 6, [1, 10000])
+ @w_belldur.pack('side'=>'right', 'padx'=>5)
+
+ @w_bellvol.pack('side'=>'top', 'expand'=>'yes')
+ f.pack('side'=>'top', 'expand'=>'yes')
+
+ #
+ # Keyboard settings
+ #
+ kbdonoff = nil
+ kbdcli = nil
+ kbd = TkLabelframe.new(@root, 'text'=>'キーボードリピート設定',
+ 'padx'=>'1.5m', 'pady'=>'1.5m')
+ f = TkFrame.new(kbd)
+ @w_kbdonoff = TkCheckButton.new(f, 'text'=>'クリック音ã‚ã‚Š',
+ 'relief'=>'flat',
+ 'onvalue'=>'on', 'offvalue'=>'off',
+ 'variable'=>@w_kbdrep ) {
+ def self.set(value)
+ if value == 'on'
+ self.select
+ else
+ self.deselect
+ end
+ end
+ pack('side'=>'left', 'expand'=>'yes', 'fill'=>'x', 'padx'=>[0, '1m'])
+ }
+ @w_kbdcli = TkScale.new(f, 'from'=>0, 'to'=>100, 'length'=>200,
+ 'tickinterval'=>20, 'orient'=>'horizontal',
+ 'label'=>'ã‚¯ãƒªãƒƒã‚¯éŸ³é‡ (%)')
+ @w_kbdcli.pack('side'=>'left', 'expand'=>'yes',
+ 'fill'=>'x', 'padx'=>['1m', 0])
+ f.pack('side'=>'top', 'expand'=>'yes', 'pady'=>2, 'fill'=>'x')
+
+ #
+ # Mouse settings
+ #
+ mouse = TkLabelframe.new(@root, 'text'=>'マウス設定',
+ 'padx'=>'1.5m', 'pady'=>'1.5m')
+ f = TkFrame.new(mouse)
+ @w_mouseacc = LabelEntry.new(f, '加速é‡', 5)
+ @w_mouseacc.pack('side'=>'left', 'padx'=>[0, '1m'])
+ @w_mousethr = LabelEntry.new(f, '閾値 (pixels)', 3, [1, 2000])
+ @w_mousethr.pack('side'=>'right', 'padx'=>['1m', 0])
+ f.pack('side'=>'top', 'expand'=>'yes')
+
+ #
+ # Screen Saver settings
+ #
+ screen = TkLabelframe.new(@root, 'text'=>'スクリーンセーãƒè¨­å®š',
+ 'padx'=>'1.5m', 'pady'=>'1.5m')
+ @w_screenblank = TkRadioButton.new(screen, 'text'=>'ブランク表示',
+ 'relief'=>'flat', 'anchor'=>'w',
+ 'variable'=>@w_screenbla,
+ 'value'=>'blank') {
+ def self.set(value)
+ if value == 'blank'
+ self.select
+ else
+ self.deselect
+ end
+ end
+ }
+
+ @w_screenpat = TkRadioButton.new(screen, 'text'=>'パターン表示',
+ 'relief'=>'flat', 'anchor'=>'w',
+ 'variable'=>@w_screenbla,
+ 'value'=>'noblank') {
+ def self.set(value)
+ if value != 'blank'
+ self.select
+ else
+ self.deselect
+ end
+ end
+ }
+
+ @w_screentim = LabelEntry.new(screen, 'タイムアウト (s)', 5, [1, 100000])
+ @w_screencyc = LabelEntry.new(screen, '周期 (s)', 5, [1, 100000])
+
+ Tk.grid(@w_screenblank, @w_screentim, 'sticky'=>'e')
+ Tk.grid(@w_screenpat, @w_screencyc, 'sticky'=>'e')
+ TkGrid.configure(@w_screenblank, @w_screenpat, 'sticky'=>'ew')
+
+ #
+ # Main window
+ #
+ param = {
+ 'side'=>'top', 'fill'=>'both', 'expand'=>'yes',
+ 'padx'=>'1m', 'pady'=>'1m'
+ }
+ btn_frame.pack('side'=>'top', 'fill'=>'both')
+ bell.pack(param)
+ kbd.pack(param)
+ mouse.pack(param)
+ screen.pack(param)
+
+ #
+ # Let the user resize our window
+ #
+ @root.minsize(10,10)
+ end
+
+ def initialize(title)
+ @root = TkRoot.new('title'=>title)
+
+ @kbdrep = 'on'
+ @w_kbdrep = TkVariable.new(@kbdrep)
+ def @w_kbdrep.get
+ self.value
+ end
+ def @w_kbdrep.set(val)
+ self.value=val
+ end
+
+ @kbdcli = 0
+
+ @bellvol = 100
+ @bellpit = 440
+ @belldur = 100
+
+ @mouseacc = "3/1"
+ @mousethr = 4
+
+ @screenbla = "blank"
+ @w_screenbla = TkVariable.new(@screenbla)
+ def @w_screenbla.get
+ self.value
+ end
+ def @w_screenbla.set(val)
+ self.value=val
+ end
+
+ @screentim = 600
+ @screencyc = 600
+
+ #
+ # Listen what "xset" tells us...
+ #
+ readsettings
+
+ #
+ # Create all windows
+ #
+ createwindows
+
+ #
+ # Write xset parameters
+ #
+ dispsettings
+ end
+end
+
+Xsettings.new(File.basename($0,'.rb'))
+
+Tk.mainloop
diff --git a/jni/ruby/ext/tk/sample/demos-jp/knightstour.rb b/jni/ruby/ext/tk/sample/demos-jp/knightstour.rb
new file mode 100644
index 0000000..835a24c
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/demos-jp/knightstour.rb
@@ -0,0 +1,273 @@
+# -*- coding: utf-8 -*-
+#
+# Based on the widget demo of Tcl/Tk8.5.2
+# The following is the original copyright text.
+#----------------------------------------------------------------------------
+# Copyright (C) 2008 Pat Thoyts <patthoyts@users.sourceforge.net>
+#
+# Calculate a Knight's tour of a chessboard.
+#
+# This uses Warnsdorff's rule to calculate the next square each
+# time. This specifies that the next square should be the one that
+# has the least number of available moves.
+#
+# Using this rule it is possible to get to a position where
+# there are no squares available to move into. In this implementation
+# this occurs when the starting square is d6.
+#
+# To solve this fault an enhancement to the rule is that if we
+# have a choice of squares with an equal score, we should choose
+# the one nearest the edge of the board.
+#
+# If the call to the Edgemost function is commented out you can see
+# this occur.
+#
+# You can drag the knight to a specific square to start if you wish.
+# If you let it repeat then it will choose random start positions
+# for each new tour.
+#----------------------------------------------------------------------------
+require 'tk'
+
+class Knights_Tour
+ # Return a list of accessible squares from a given square
+ def valid_moves(square)
+ moves = []
+ [
+ [-1,-2], [-2,-1], [-2,1], [-1,2], [1,2], [2,1], [2,-1], [1,-2]
+ ].each{|col_delta, row_delta|
+ col = (square % 8) + col_delta
+ row = (square.div(8)) + row_delta
+ moves << (row * 8 + col) if row > -1 && row < 8 && col > -1 && col < 8
+ }
+ moves
+ end
+
+ # Return the number of available moves for this square
+ def check_square(square)
+ valid_moves(square).find_all{|pos| ! @visited.include?(pos)}.length
+ end
+
+ # Select the next square to move to. Returns -1 if there are no available
+ # squares remaining that we can move to.
+ def next_square(square)
+ minimum = 9
+ nxt = -1
+ valid_moves(square).each{|pos|
+ unless @visited.include?(pos)
+ cnt = check_square(pos)
+ if cnt < minimum
+ minimum = cnt
+ nxt = pos
+ elsif cnt == minimum
+ nxt = edgemost(nxt, pos)
+ end
+ end
+ }
+ nxt
+ end
+
+ # Select the square nearest the edge of the board
+ def edgemost(nxt, pos)
+ col_A = 3 - ((3.5 - nxt % 8).abs.to_i)
+ col_B = 3 - ((3.5 - pos % 8).abs.to_i)
+ row_A = 3 - ((3.5 - nxt.div(8)).abs.to_i)
+ row_B = 3 - ((3.5 - pos.div(8)).abs.to_i)
+ (col_A * row_A < col_B * row_B)? nxt : pos
+ end
+
+ # Display a square number as a standard chess square notation.
+ def _N(square)
+ '%c%d' % [(97 + square % 8), (square.div(8) + 1)]
+ end
+
+ # Perform a Knight's move and schedule the next move.
+ def move_piece(last, square)
+ @log.insert(:end, "#{@visited.length}. #{_N last} -> #{_N square}\n", '')
+ @log.see(:end)
+ @board.itemconfigure(1+last, :state=>:normal, :outline=>'black')
+ @board.itemconfigure(1+square, :state=>:normal, :outline=>'red')
+ @knight.coords(@board.coords(1+square)[0..1])
+ @visited << square
+ if (nxt = next_square(square)) != -1
+ @after_id = Tk.after(@delay.numeric){move_piece(square, nxt) rescue nil}
+ else
+ @start_btn.state :normal
+ if @visited.length == 64
+ if @initial == square
+ @log.insert :end, '周éŠ(closed tour)æˆåŠŸï¼'
+ else
+ @log.insert :end, "æˆåŠŸ\n", {}
+ Tk.after(@delay.numeric * 2){tour(rand(64))} if @continuous.bool
+ end
+ else
+ @log.insert :end, "失敗ï¼\n", {}
+ end
+ end
+ end
+
+ # Begin a new tour of the board given a random start position
+ def tour(square = nil)
+ @visited.clear
+ @log.clear
+ @start_btn.state :disabled
+ 1.upto(64){|n|
+ @board.itemconfigure(n, :state=>:disabled, :outline=>'black')
+ }
+ unless square
+ square = @board.find_closest(*(@knight.coords << 0 << 65))[0].to_i - 1
+ end
+ @initial = square
+ Tk.after_idle{ move_piece(@initial, @initial) rescue nil }
+ end
+
+ def _stop
+ Tk.after_cancel(@after_id) rescue nil
+ end
+
+ def _exit
+ _stop
+ $knightstour.destroy
+ end
+
+ def set_delay(new)
+ @delay.numeric = new.to_i
+ end
+
+ def drag_start(w, x, y)
+ w.dtag('selected')
+ w.addtag('selected', :withtag, 'current')
+ @dragging = [x, y]
+ end
+
+ def drag_motion(w, x, y)
+ return unless @dragging
+ w.move('selected', x - @dragging[0], y - @dragging[1])
+ @dragging = [x, y]
+ end
+
+ def drag_end(w, x, y)
+ square = w.find_closest(x, y, 0, 65)
+ w.coords('selected', w.coords(square)[0..1])
+ w.dtag('selected')
+ @dragging = nil
+ end
+
+ def make_SeeDismiss
+ ## See Code / Dismiss
+ frame = Ttk::Frame.new($knightstour)
+ sep = Ttk::Separator.new(frame)
+ Tk.grid(sep, :columnspan=>4, :row=>0, :sticky=>'ew', :pady=>2)
+ TkGrid('x',
+ Ttk::Button.new(frame, :text=>'コードå‚ç…§',
+ :image=>$image['view'], :compound=>:left,
+ :command=>proc{showCode 'knightstour'}),
+ Ttk::Button.new(frame, :text=>'é–‰ã˜ã‚‹',
+ :image=>$image['delete'], :compound=>:left,
+ :command=>proc{
+ $knightstour.destroy
+ $knightstour = nil
+ }),
+ :padx=>4, :pady=>4)
+ frame.grid_columnconfigure(0, :weight=>1)
+ frame
+ end
+
+ def create_gui(parent = nil)
+ $knightstour.destroy rescue nil
+ $knightstour = Tk::Toplevel.new(parent, :title=>"Knight's tour")
+ $knightstour.withdraw
+ base_f = Ttk::Frame.new($knightstour)
+ @board = Tk::Canvas.new(base_f, :width=>240, :height=>240)
+ @log = Tk::Text.new(base_f, :width=>12, :height=>1,
+ :font=>'Arial 8', :background=>'white')
+ scr = @log.yscrollbar(Ttk::Scrollbar.new(base_f))
+
+ @visited = []
+ @delay = TkVariable.new(600)
+ @continuous = TkVariable.new(false)
+
+ tool_f = Ttk::Frame.new($knightstour)
+ label = Ttk::Label.new(tool_f, :text=>'実行速度')
+ scale = Ttk::Scale.new(tool_f, :from=>8, :to=>2000, :variable=>@delay,
+ :command=>proc{|n| set_delay(n)})
+ check = Ttk::Checkbutton.new(tool_f, :text=>'å復',
+ :variable=>@continuous)
+ @start_btn = Ttk::Button.new(tool_f, :text=>'開始',
+ :command=>proc{tour()})
+ @exit_btn = Ttk::Button.new(tool_f, :text=>'終了',
+ :command=>proc{_exit()})
+
+ 7.downto(0){|row|
+ 0.upto(7){|col|
+ if ((col & 1) ^ (row & 1)).zero?
+ fill = 'bisque'
+ dfill = 'bisque3'
+ else
+ fill = 'tan3'
+ dfill = 'tan4'
+ end
+ coords = [col * 30 + 4, row * 30 + 4, col * 30 + 30, row * 30 + 30]
+ @board.create(TkcRectangle, coords,
+ :fill=>fill, :disabledfill=>dfill,
+ :width=>2, :state=>:disabled)
+ }
+ }
+
+ @knight_font = TkFont.new(:size=>-24)
+ @knight = TkcText.new(@board, 0, 0, :font=>@knight_font,
+ :text=>Tk::UTF8_String.new('\u265e'),
+ :anchor=>'nw', # :tags=>'knight',
+ :fill=>'black', :activefill=>'#600000')
+ @knight.coords(@board.coords(rand(64)+1)[0..1])
+ @knight.bind('ButtonPress-1', '%W %x %y'){|w,x,y| drag_start(w,x,y)}
+ @knight.bind('Motion', '%W %x %y'){|w,x,y| drag_motion(w,x,y)}
+ @knight.bind('ButtonRelease-1', '%W %x %y'){|w,x,y| drag_end(w,x,y)}
+
+ Tk.grid(@board, @log, scr, :sticky=>'news')
+ base_f.grid_rowconfigure(0, :weight=>1)
+ base_f.grid_columnconfigure(0, :weight=>1)
+
+ Tk.grid(base_f, '-', '-', '-', '-', '-', :sticky=>'news')
+ widgets = [label, scale, check, @start_btn]
+ sg = nil
+ unless $RubyTk_WidgetDemo
+ widgets << @exit_btn
+ if Tk.windowingsystem != 'aqua'
+ #widgets.unshift(Ttk::SizeGrip.new(tool_f))
+ Ttk::SizeGrip.new(tool_f).pack(:side=>:right, :anchor=>'se')
+ end
+ end
+ Tk.pack(widgets, :side=>:right)
+ if Tk.windowingsystem == 'aqua'
+ TkPack.configure(widgets, :padx=>[4, 4], :pady=>[12, 12])
+ TkPack.configure(widgets[0], :padx=>[4, 24])
+ TkPack.configure(widgets[-1], :padx=>[16, 4])
+ end
+
+ Tk.grid(tool_f, '-', '-', '-', '-', '-', :sticky=>'ew')
+
+ if $RubyTk_WidgetDemo
+ Tk.grid(make_SeeDismiss(), '-', '-', '-', '-', '-', :sticky=>'ew')
+ end
+
+ $knightstour.grid_rowconfigure(0, :weight=>1)
+ $knightstour.grid_columnconfigure(0, :weight=>1)
+
+ $knightstour.bind('Control-F2'){TkConsole.show}
+ $knightstour.bind('Return'){@start_btn.invoke}
+ $knightstour.bind('Escape'){@exit_btn.invoke}
+ $knightstour.bind('Destroy'){ _stop }
+ $knightstour.protocol('WM_DELETE_WINDOW'){ _exit }
+
+ $knightstour.deiconify
+ $knightstour.tkwait_destroy
+ end
+
+ def initialize(parent = nil)
+ create_gui(parent)
+ end
+end
+
+Tk.root.withdraw unless $RubyTk_WidgetDemo
+Thread.new{Tk.mainloop} if __FILE__ == $0
+Knights_Tour.new
diff --git a/jni/ruby/ext/tk/sample/demos-jp/label.rb b/jni/ruby/ext/tk/sample/demos-jp/label.rb
new file mode 100644
index 0000000..700e6a6
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/demos-jp/label.rb
@@ -0,0 +1,69 @@
+# -*- coding: utf-8 -*-
+#
+# label widget demo (called by 'widget')
+#
+
+# toplevel widget ãŒå­˜åœ¨ã™ã‚Œã°å‰Šé™¤ã™ã‚‹
+if defined?($label_demo) && $label_demo
+ $label_demo.destroy
+ $label_demo = nil
+end
+
+# demo 用㮠toplevel widget を生æˆ
+$label_demo = TkToplevel.new {|w|
+ title("Label Demonstration")
+ iconname("label")
+ positionWindow(w)
+}
+
+base_frame = TkFrame.new($label_demo).pack(:fill=>:both, :expand=>true)
+
+# label 生æˆ
+msg = TkLabel.new(base_frame) {
+ font $font
+ wraplength '4i'
+ justify 'left'
+ text "下ã«ã¯5ã¤ã®ãƒ©ãƒ™ãƒ«ãŒè¡¨ç¤ºã•ã‚Œã¦ã„ã¾ã™ã€‚å·¦å´ã«ã¯ãƒ†ã‚­ã‚¹ãƒˆãƒ©ãƒ™ãƒ«ãŒ3ã¤ã‚ã‚Šã€å³å´ã«ã¯ãƒ“ットマップラベルã¨ãƒ†ã‚­ã‚¹ãƒˆãƒ©ãƒ™ãƒ«ãŒã‚ã‚Šã¾ã™ã€‚ラベルã¨ã„ã†ã®ã¯ã‚ã¾ã‚Šé¢ç™½ã„ã‚‚ã®ã§ã¯ã‚ã‚Šã¾ã›ã‚“。ãªãœãªã‚‰çœºã‚る以外何もã§ããªã„ã‹ã‚‰ã§ã™ã€‚"
+}
+msg.pack('side'=>'top')
+
+# frame 生æˆ
+TkFrame.new(base_frame) {|frame|
+ TkButton.new(frame) {
+ #text '了解'
+ text 'é–‰ã˜ã‚‹'
+ command proc{
+ tmppath = $label_demo
+ $label_demo = nil
+ tmppath.destroy
+ }
+ }.pack('side'=>'left', 'expand'=>'yes')
+
+ TkButton.new(frame) {
+ text 'コードå‚ç…§'
+ command proc{showCode 'label'}
+ }.pack('side'=>'left', 'expand'=>'yes')
+
+}.pack('side'=>'bottom', 'fill'=>'x', 'pady'=>'2m')
+
+# label demo 用フレーム生æˆ
+f_left = TkFrame.new(base_frame)
+f_right = TkFrame.new(base_frame)
+[f_left, f_right].each{|w| w.pack('side'=>'left', 'expand'=>'yes',
+ 'padx'=>10, 'pady'=>10, 'fill'=>'both')}
+
+# label 生æˆ
+[ TkLabel.new(f_left, 'text'=>'最åˆã®ãƒ©ãƒ™ãƒ«'),
+ TkLabel.new(f_left, 'text'=>'2 番目。ã¡ã‚‡ã£ã¨æµ®ã上ãŒã‚‰ã›ã¦ã¿ã¾ã—ãŸ',
+ 'relief'=>'raised'),
+ TkLabel.new(f_left, 'text'=>'3 番目。沈んã§ã„ã¾ã™ ', 'relief'=>'sunken')
+].each{|w| w.pack('side'=>'top', 'expand'=>'yes', 'pady'=>2, 'anchor'=>'w')}
+
+# TkLabel.new(f_right) {
+Tk::Label.new(f_right) {
+ bitmap('@' + [$demo_dir,'..','images','face.xbm'].join(File::Separator))
+ borderwidth 2
+ relief 'sunken'
+}.pack('side'=>'top')
+
+TkLabel.new(f_right) { text 'Tcl/Tk 所有者' }.pack('side'=>'top')
diff --git a/jni/ruby/ext/tk/sample/demos-jp/labelframe.rb b/jni/ruby/ext/tk/sample/demos-jp/labelframe.rb
new file mode 100644
index 0000000..80e106c
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/demos-jp/labelframe.rb
@@ -0,0 +1,102 @@
+# -*- coding: utf-8 -*-
+#
+# labelframe.rb
+#
+# This demonstration script creates a toplevel window containing
+# several labelframe widgets.
+#
+# based on "Id: labelframe.tcl,v 1.2 2001/10/30 11:21:50 dkf Exp"
+
+
+if defined?($labelframe_demo) && $labelframe_demo
+ $labelframe_demo.destroy
+ $labelframe_demo = nil
+end
+
+$labelframe_demo = TkToplevel.new {|w|
+ title("Labelframe Demonstration")
+ iconname("labelframe")
+ positionWindow(w)
+}
+
+base_frame = TkFrame.new($labelframe_demo).pack(:fill=>:both, :expand=>true)
+
+# Some information
+TkLabel.new(base_frame,
+ :font=>$font, :wraplength=>'4i', :justify=>:left,
+ :text=><<EOL).pack(:side=>:top)
+TkLabelFrame ウィジェットã¯é–¢é€£ã™ã‚‹ widget
+群をã¾ã¨ã‚ã¦å–り扱ã†ãŸã‚ã«ç”¨ã„られã¾ã™ã€‚ラ
+ベルã¯é€šå¸¸ã®æ–‡å­—列ã§ã‚‚何らã‹ã®ã‚¦ã‚£ã‚¸ã‚§ãƒƒãƒˆ
+ã§ã‚‚ã‹ã¾ã„ã¾ã›ã‚“。もã—ã‚ãªãŸãŒä½¿ã£ã¦ã„ã‚‹
+Ruby ã«ãƒªãƒ³ã‚¯ã•ã‚Œã¦ã„ã‚‹ Tk ライブラリãŒ
+labelframe ウィジェットを実装ã—ã¦ã„ãªã„
+å ´åˆã€ã“ã®ãƒ‡ãƒ¢ã¯ã†ã¾ãå‹•ã‹ãªã„ã¯ãšã§ã™ã€‚
+ãã®å ´åˆã«ã¯ labelframe ウィジェットãŒå®Ÿè£…
+ã•ã‚Œã¦ã„るよã†ãªã‚ˆã‚Šæ–°ã—ã„ãƒãƒ¼ã‚¸ãƒ§ãƒ³ã® Tk
+を組ã¿åˆã‚ã›ã¦è©¦ã™ã‚ˆã†ã«ã—ã¦ãã ã•ã„。
+EOL
+
+# The bottom buttons
+TkFrame.new(base_frame){|f|
+ pack(:side=>:bottom, :fill=>:x, :pady=>'2m')
+
+ TkButton.new(f, :text=>'é–‰ã˜ã‚‹', :width=>15, :command=>proc{
+ $labelframe_demo.destroy
+ $labelframe_demo = nil
+ }).pack(:side=>:left, :expand=>true)
+
+ TkButton.new(f, :text=>'コードå‚ç…§', :width=>15, :command=>proc{
+ showCode 'labelframe'
+ }).pack(:side=>:left, :expand=>true)
+}
+
+# Demo area
+w = TkFrame.new(base_frame).pack(:side=>:bottom, :fill=>:both,
+ :expand=>true)
+
+# A group of radiobuttons in a labelframe
+TkLabelFrame.new(w, :text=>'é¸æŠžå€¤',
+ :padx=>2, :pady=>2) {|f|
+ grid(:row=>0, :column=>0, :pady=>'2m', :padx=>'2m')
+
+ v = TkVariable.new
+ (1..4).each{|i|
+ TkRadiobutton.new(f, :text=>"This is value #{i}",
+ :variable=>v, :value=>i) {
+ pack(:side=>:top, :fill=>:x, :pady=>2)
+ }
+ }
+}
+
+
+# Using a label window to control a group of options.
+$lfdummy = TkVariable.new(0)
+
+def lfEnableButtons(w)
+ TkWinfo.children(w).each{|child|
+ next if child.path =~ /\.cb$/
+ if $lfdummy == 1
+ child.state(:normal)
+ else
+ child.state(:disabled)
+ end
+ }
+end
+
+TkLabelFrame.new(w, :pady=>2, :padx=>2){|f|
+ TkCheckButton.new(f, :widgetname=>'cb', :variable=>$lfdummy,
+ :text=>"オプションを使用", :padx=>0) {|cb|
+ command proc{lfEnableButtons(f)}
+ f.labelwidget(cb)
+ }
+ grid(:row=>0, :column=>1, :pady=>'2m', :padx=>'2m')
+
+ %w(オプション1 オプション2 オプション3).each{|str|
+ TkCheckbutton.new(f, :text=>str).pack(:side=>:top, :fill=>:x, :pady=>2)
+ }
+
+ lfEnableButtons(f)
+}
+
+TkGrid.columnconfigure(w, [0,1], :weight=>1)
diff --git a/jni/ruby/ext/tk/sample/demos-jp/mclist.rb b/jni/ruby/ext/tk/sample/demos-jp/mclist.rb
new file mode 100644
index 0000000..67cec63
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/demos-jp/mclist.rb
@@ -0,0 +1,121 @@
+# -*- coding: utf-8 -*-
+#
+# mclist.rb --
+#
+# This demonstration script creates a toplevel window containing a Ttk
+# tree widget configured as a multi-column listbox.
+#
+# based on "Id: mclist.tcl,v 1.3 2007/12/13 15:27:07 dgp Exp"
+
+if defined?($mclist_demo) && $mclist_demo
+ $mclist_demo.destroy
+ $mclist_demo = nil
+end
+
+$mclist_demo = TkToplevel.new {|w|
+ title("Multi-Column List")
+ iconname("mclist")
+ positionWindow(w)
+}
+
+base_frame = TkFrame.new($mclist_demo).pack(:fill=>:both, :expand=>true)
+
+## Explanatory text
+Ttk::Label.new(base_frame, :font=>$font, :wraplength=>'4i',
+ :justify=>:left, :anchor=>'n', :padding=>[10, 2, 10, 6],
+ :text=><<EOL).pack(:fill=>:x)
+Ttkã¨ã¯ï¼Œãƒ†ãƒ¼ãƒžæŒ‡å®šå¯èƒ½ãªæ–°ã—ã„ウィジェット集åˆã§ã™ï¼Ž\
+Ttk::Treeviewウィジェットã¯\
+Ttkウィジェットセットã«å«ã¾ã‚Œã‚‹ã‚¦ã‚£ã‚¸ã‚§ãƒƒãƒˆã®ä¸€ã¤ã§ï¼Œ\
+ãã‚ŒãŒä¿æŒã™ã‚‹æœ¨æ§‹é€ ã®ãƒ‡ãƒ¼ã‚¿ãã®ã‚‚ã®ã¾ã§ã¯è¡¨ç¤ºã™ã‚‹ã“ã¨ãªã,\
+示ã—ãŸã„情報をマルãƒã‚«ãƒ©ãƒ ã§è¡¨ç¤ºã•ã›ã‚‹ã“ã¨ãŒã§ãã¾ã™ï¼Ž
+ã“ã®ã‚µãƒ³ãƒ—ルã¯ï¼Œè¤‡æ•°ã®ã‚«ãƒ©ãƒ ã‚’æŒã£ãŸãƒªã‚¹ãƒˆãƒœãƒƒã‚¯ã‚¹ã‚’作æˆã™ã‚‹ç°¡å˜ãªä¾‹ã§ã™ï¼Ž
+å„カラムã®ã‚¿ã‚¤ãƒˆãƒ«(heading)をクリックã™ã‚Œã°ï¼Œ\
+ãã®ã‚«ãƒ©ãƒ ã®æƒ…å ±ã«åŸºã¥ã„ã¦ãƒªã‚¹ãƒˆã®ä¸¦ã¹æ›¿ãˆãŒãªã•ã‚Œã‚‹ã¯ãšã§ã™ï¼Ž\
+ã¾ãŸï¼Œã‚«ãƒ©ãƒ ã®ã‚¿ã‚¤ãƒˆãƒ«é–“ã®åŒºåˆ‡ã‚Šéƒ¨åˆ†ã‚’ドラッグã™ã‚‹ã“ã¨ã§ï¼Œ\
+カラムã®å¹…を変更ã™ã‚‹ã“ã¨ã‚‚å¯èƒ½ã§ã™ï¼Ž
+EOL
+
+## See Code / Dismiss
+Ttk::Frame.new(base_frame) {|frame|
+ sep = Ttk::Separator.new(frame)
+ Tk.grid(sep, :columnspan=>4, :row=>0, :sticky=>'ew', :pady=>2)
+ TkGrid('x',
+ Ttk::Button.new(frame, :text=>'コードå‚ç…§',
+ :image=>$image['view'], :compound=>:left,
+ :command=>proc{showCode 'mclist'}),
+ Ttk::Button.new(frame, :text=>'é–‰ã˜ã‚‹',
+ :image=>$image['delete'], :compound=>:left,
+ :command=>proc{
+ $mclist_demo.destroy
+ $mclist_demo = nil
+ }),
+ :padx=>4, :pady=>4)
+ grid_columnconfigure(0, :weight=>1)
+ pack(:side=>:bottom, :fill=>:x)
+}
+
+container = Ttk::Frame.new(base_frame)
+tree = Ttk::Treeview.new(base_frame, :columns=>%w(country capital currency),
+ :show=>:headings)
+if Tk.windowingsystem != 'aquq'
+ vsb = tree.yscrollbar(Ttk::Scrollbar.new(base_frame))
+ hsb = tree.xscrollbar(Ttk::Scrollbar.new(base_frame))
+else
+ vsb = tree.yscrollbar(Tk::Scrollbar.new(base_frame))
+ hsb = tree.xscrollbar(Tk::Scrollbar.new(base_frame))
+end
+
+container.pack(:fill=>:both, :expand=>true)
+Tk.grid(tree, vsb, :in=>container, :sticky=>'nsew')
+Tk.grid(hsb, :in=>container, :sticky=>'nsew')
+container.grid_columnconfigure(0, :weight=>1)
+container.grid_rowconfigure(0, :weight=>1)
+
+## The data we're going to insert
+data = [
+ ['アルゼンãƒãƒ³', 'ブエノスアイレス', 'ARS'],
+ ['オーストラリア', 'キャンベラ', 'AUD'],
+ ['ブラジル', 'ブラジリア', 'BRL'],
+ ['カナダ', 'オタワ', 'CAD'],
+ ['中国', '北京', 'CNY'],
+ ['フランス', 'パリ', 'EUR'],
+ ['ドイツ', 'ベルリン', 'EUR'],
+ ['インド', 'ニューデリー', 'INR'],
+ ['イタリア', 'ローマ', 'EUR'],
+ ['日本', 'æ±äº¬', 'JPY'],
+ ['メキシコ', 'メキシコシティ', 'MXN'],
+ ['ロシア', 'モスクワ', 'RUB'],
+ ['å—アフリカ', 'プレトリア', 'ZAR'],
+ ['英国', 'ロンドン', 'GBP'],
+ ['アメリカ', 'ワシントン D.C.', 'USD'],
+]
+
+## Code to insert the data nicely
+font = Ttk::Style.lookup(tree[:style], :font)
+cols = %w(country capital currency)
+cols.zip(%w(国å 首都 通貨)).each{|col, name|
+ tree.heading_configure(col, :text=>name,
+ :command=>proc{sort_by(tree, col, false)})
+ tree.column_configure(col, :width=>TkFont.measure(font, name))
+}
+
+data.each{|country, capital, currency|
+ #tree.insert('', :end, :values=>[country, capital, currency])
+ tree.insert(nil, :end, :values=>[country, capital, currency])
+ cols.zip([country, capital, currency]).each{|col, val|
+ len = TkFont.measure(font, "#{val} ")
+ if tree.column_cget(col, :width) < len
+ tree.column_configure(col, :width=>len)
+ end
+ }
+}
+
+## Code to do the sorting of the tree contents when clicked on
+def sort_by(tree, col, direction)
+ tree.children(nil).map!{|row| [tree.get(row, col), row.id]} .
+ sort(&((direction)? proc{|x, y| y <=> x}: proc{|x, y| x <=> y})) .
+ each_with_index{|info, idx| tree.move(info[1], nil, idx)}
+
+ tree.heading_configure(col, :command=>proc{sort_by(tree, col, ! direction)})
+end
diff --git a/jni/ruby/ext/tk/sample/demos-jp/menu.rb b/jni/ruby/ext/tk/sample/demos-jp/menu.rb
new file mode 100644
index 0000000..05ea7a9
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/demos-jp/menu.rb
@@ -0,0 +1,201 @@
+# -*- coding: utf-8 -*-
+#
+# menus widget demo (called by 'widget')
+#
+
+# toplevel widget ãŒå­˜åœ¨ã™ã‚Œã°å‰Šé™¤ã™ã‚‹
+if defined?($menu_demo) && $menu_demo
+ $menu_demo.destroy
+ $menu_demo = nil
+end
+
+# demo 用㮠toplevel widget を生æˆ
+$menu_demo = TkToplevel.new {|w|
+ title("File Selection Dialogs")
+ iconname("menu")
+ positionWindow(w)
+}
+
+base_frame = TkFrame.new($menu_demo).pack(:fill=>:both, :expand=>true)
+
+# menu frame 生æˆ
+$menu_frame = TkFrame.new(base_frame, 'relief'=>'raised', 'bd'=>2)
+$menu_frame.pack('side'=>'top', 'fill'=>'x')
+
+begin
+ windowingsystem = Tk.windowingsystem()
+rescue
+ windowingsystem = ""
+end
+
+# label 生æˆ
+TkLabel.new(base_frame,'font'=>$font,'wraplength'=>'4i','justify'=>'left') {
+ if $tk_platform['platform'] == 'macintosh' ||
+ windowingsystem == "classic" || windowingsystem == "aqua"
+ text("ã“ã®ã‚¦ã‚£ãƒ³ãƒ‰ã‚¦ã¯æ§˜ã€…ãªãƒ¡ãƒ‹ãƒ¥ãƒ¼ã¨ã‚«ã‚¹ã‚±ãƒ¼ãƒ‰ãƒ¡ãƒ‹ãƒ¥ãƒ¼ã‹ã‚‰æ§‹æˆã•ã‚Œã¦ã„ã¾ã™ã€‚Command-X を入力ã™ã‚‹ã¨ã€XãŒã‚³ãƒžãƒ³ãƒ‰ã‚­ãƒ¼è¨˜å·ã«ç¶šã„ã¦è¡¨ç¤ºã•ã‚Œã¦ã„る文字ãªã‚‰ã°ã€ã‚¢ã‚¯ã‚»ãƒ©ãƒ¬ãƒ¼ã‚¿ã‚’使ã£ãŸé …目起動を行ã†ã“ã¨ãŒã§ãã¾ã™ã€‚メニューè¦ç´ ä¸­ã€æœ€å¾Œã®ã‚‚ã®ã¯ã€ãã®ãƒ¡ãƒ‹ãƒ¥ãƒ¼ã®æœ€åˆã®é …目をé¸æŠžã™ã‚‹ã“ã¨ã§ç‹¬ç«‹ã•ã›ã‚‹ã“ã¨ãŒã§ãã¾ã™ã€‚")
+ else
+ text("ã“ã®ã‚¦ã‚£ãƒ³ãƒ‰ã‚¦ã¯æ§˜ã€…ãªãƒ¡ãƒ‹ãƒ¥ãƒ¼ã¨ã‚«ã‚¹ã‚±ãƒ¼ãƒ‰ãƒ¡ãƒ‹ãƒ¥ãƒ¼ã‹ã‚‰æ§‹æˆã•ã‚Œã¦ã„ã¾ã™ã€‚Alt-X を入力ã™ã‚‹ã¨ã€XãŒãƒ¡ãƒ‹ãƒ¥ãƒ¼ã«ã‚¢ãƒ³ãƒ€ãƒ¼ãƒ©ã‚¤ãƒ³ä»˜ãã§è¡¨ç¤ºã•ã‚Œã¦ã„る文字ãªã‚‰ã°ã€ã‚­ãƒ¼ãƒœãƒ¼ãƒ‰ã‹ã‚‰ã®æŒ‡å®šãŒã§ãã¾ã™ã€‚矢å°ã‚­ãƒ¼ã§ãƒ¡ãƒ‹ãƒ¥ãƒ¼ã®ãƒˆãƒ©ãƒãƒ¼ã‚¹ã‚‚å¯èƒ½ã§ã™ã€‚メニューãŒæŒ‡å®šã•ã‚ŒãŸéš›ã«ã¯ã€ã‚¹ãƒšãƒ¼ã‚¹ã‚­ãƒ¼ã§å®Ÿè¡Œã™ã‚‹ã“ã¨ãŒã§ãã¾ã™ã€‚ã‚ã‚‹ã„ã¯ã€ã‚¢ãƒ³ãƒ€ãƒ¼ãƒ©ã‚¤ãƒ³ä»˜ãã®æ–‡å­—を入力ã™ã‚‹ã“ã¨ã§ã‚‚実行ã§ãã¾ã™ã€‚メニューã®ã‚¨ãƒ³ãƒˆãƒªãŒã‚¢ã‚¯ã‚»ãƒ©ãƒ¬ãƒ¼ã‚¿ã‚’æŒã£ã¦ã„ã‚‹å ´åˆã¯ã€ãã®ã‚¢ã‚¯ã‚»ãƒ©ãƒ¬ãƒ¼ã‚¿ã‚’入力ã™ã‚‹ã“ã¨ã§ãƒ¡ãƒ‹ãƒ¥ãƒ¼ã‚’指定ã™ã‚‹ã“ã¨ãªã—ã«å®Ÿè¡Œã™ã‚‹ã“ã¨ãŒã§ãã¾ã™ã€‚メニューè¦ç´ ä¸­ã€æœ€å¾Œã®ã‚‚ã®ã¯ã€ãã®ãƒ¡ãƒ‹ãƒ¥ãƒ¼ã®æœ€åˆã®é …目をé¸æŠžã™ã‚‹ã“ã¨ã§ç‹¬ç«‹ã•ã›ã‚‹ã“ã¨ãŒã§ãã¾ã™ã€‚")
+ end
+}.pack('side'=>'top')
+
+# frame 生æˆ
+TkFrame.new(base_frame) {|frame|
+ TkButton.new(frame) {
+ #text '了解'
+ text 'é–‰ã˜ã‚‹'
+ command proc{
+ tmppath = $menu_demo
+ $menu_demo = nil
+ tmppath.destroy
+ }
+ }.pack('side'=>'left', 'expand'=>'yes')
+
+ TkButton.new(frame) {
+ text 'コードå‚ç…§'
+ command proc{showCode 'menu'}
+ }.pack('side'=>'left', 'expand'=>'yes')
+}.pack('side'=>'bottom', 'fill'=>'x', 'pady'=>'2m')
+
+# menu 生æˆ
+TkMenubutton.new($menu_frame, 'text'=>'File', 'underline'=>0) {|m|
+ pack('side'=>'left')
+ TkMenu.new(m, 'tearoff'=>false) {|file_menu|
+ m.configure('menu'=>file_menu)
+ add('command', 'label'=>'é–‹ã ...', 'command'=>proc{fail 'ã“ã‚Œã¯ã€ãƒ‡ãƒ¢ã§ã™ã®ã§"é–‹ã ..."ã«å¯¾ã™ã‚‹ã‚¢ã‚¯ã‚·ãƒ§ãƒ³ã¯å®šç¾©ã•ã‚Œã¦ã„ã¾ã›ã‚“。'})
+ add('command', 'label'=>'æ–°è¦', 'command'=>proc{fail 'ã“ã‚Œã¯ã€ãƒ‡ãƒ¢ã§ã™ã®ã§"æ–°è¦"ã«å¯¾ã™ã‚‹ã‚¢ã‚¯ã‚·ãƒ§ãƒ³ã¯å®šç¾©ã•ã‚Œã¦ã„ã¾ã›ã‚“。'})
+ add('command', 'label'=>'ä¿å­˜', 'command'=>proc{fail 'ã“ã‚Œã¯ã€ãƒ‡ãƒ¢ã§ã™ã®ã§"ä¿å­˜"ã«å¯¾ã™ã‚‹ã‚¢ã‚¯ã‚·ãƒ§ãƒ³ã¯å®šç¾©ã•ã‚Œã¦ã„ã¾ã›ã‚“。'})
+ add('command', 'label'=>'ä¿å­˜(指定) ...', 'command'=>proc{fail 'ã“ã‚Œã¯ã€ãƒ‡ãƒ¢ã§ã™ã®ã§"ä¿å­˜(指定) ..."ã«å¯¾ã™ã‚‹ã‚¢ã‚¯ã‚·ãƒ§ãƒ³ã¯å®šç¾©ã•ã‚Œã¦ã„ã¾ã›ã‚“。'})
+ add('separator')
+ add('command', 'label'=>'プリント設定 ...', 'command'=>proc{fail 'ã“ã‚Œã¯ã€ãƒ‡ãƒ¢ã§ã™ã®ã§"プリント設定 ..."ã«å¯¾ã™ã‚‹ã‚¢ã‚¯ã‚·ãƒ§ãƒ³ã¯å®šç¾©ã•ã‚Œã¦ã„ã¾ã›ã‚“。'})
+ add('command', 'label'=>'プリント ...', 'command'=>proc{fail 'ã“ã‚Œã¯ã€ãƒ‡ãƒ¢ã§ã™ã®ã§"プリント ..."ã«å¯¾ã™ã‚‹ã‚¢ã‚¯ã‚·ãƒ§ãƒ³ã¯å®šç¾©ã•ã‚Œã¦ã„ã¾ã›ã‚“。'})
+ add('separator')
+ add('command', 'label'=>'終了', 'command'=>proc{$menu_demo.destroy})
+ }
+}
+
+if $tk_platform['platform'] == 'macintosh' ||
+ windowingsystem == "classic" || windowingsystem == "aqua"
+ modifier = 'Command'
+elsif $tk_platform['platform'] == 'windows'
+ modifier = 'Control'
+else
+ modifier = 'Meta'
+end
+
+TkMenubutton.new($menu_frame, 'text'=>'Basic', 'underline'=>0) {|m|
+ pack('side'=>'left')
+ TkMenu.new(m, 'tearoff'=>false) {|basic_menu|
+ m.configure('menu'=>basic_menu)
+ add('command', 'label'=>'何もã—ãªã„é•·ã„エントリ')
+ ['A','B','C','D','E','F','G'].each{|c|
+ # add('command', 'label'=>"文字 \"#{c}\" ã‚’å°å­—", 'underline'=>4,
+ add('command', 'label'=>"Print letter \"#{c}\" (文字 \"#{c}\" ã‚’å°å­—)",
+ 'underline'=>14, 'accelerator'=>"Meta+#{c}",
+ 'command'=>proc{print c,"\n"}, 'accelerator'=>"#{modifier}+#{c}")
+ $menu_demo.bind("#{modifier}-#{c.downcase}", proc{print c,"\n"})
+ }
+ }
+}
+
+TkMenubutton.new($menu_frame, 'text'=>'Cascades', 'underline'=>0) {|m|
+ pack('side'=>'left')
+ TkMenu.new(m, 'tearoff'=>false) {|cascade_menu|
+ m.configure('menu'=>cascade_menu)
+ add('command', 'label'=>'Print hello(ã“ã‚“ã«ã¡ã¯)',
+ 'command'=>proc{print "Hello(ã“ã‚“ã«ã¡ã¯)\n"},
+ 'accelerator'=>"#{modifier}+H", 'underline'=>6)
+ $menu_demo.bind("#{modifier}-h", proc{print "Hello(ã“ã‚“ã«ã¡ã¯)\n"})
+ add('command', 'label'=>'Print goodbye(ã•ã‚ˆã†ãªã‚‰)',
+ 'command'=>proc{print "Goodbye(ã•ã‚ˆã†ãªã‚‰)\n"},
+ 'accelerator'=>"#{modifier}+G", 'underline'=>6)
+ $menu_demo.bind("#{modifier}-g", proc{print "Goodbye(ã•ã‚ˆã†ãªã‚‰)\n"})
+
+ # TkMenu.new(m, 'tearoff'=>false) {|cascade_check|
+ TkMenu.new(cascade_menu, 'tearoff'=>false) {|cascade_check|
+ cascade_menu.add('cascade', 'label'=>'Check buttons(ãƒã‚§ãƒƒã‚¯ãƒœã‚¿ãƒ³)',
+ 'menu'=>cascade_check, 'underline'=>0)
+ oil = TkVariable.new(0)
+ add('check', 'label'=>'オイル点検', 'variable'=>oil)
+ trans = TkVariable.new(0)
+ add('check', 'label'=>'トランスミッション点検', 'variable'=>trans)
+ brakes = TkVariable.new(0)
+ add('check', 'label'=>'ブレーキ点検', 'variable'=>brakes)
+ lights = TkVariable.new(0)
+ add('check', 'label'=>'ライト点検', 'variable'=>lights)
+ add('separator')
+ add('command', 'label'=>'ç¾åœ¨ã®å€¤ã‚’表示',
+ 'command'=>proc{showVars($menu_demo,
+ ['オイル点検', oil],
+ ['トランスミッション点検', trans],
+ ['ブレーキ点検', brakes],
+ ['ライト点検', lights])} )
+ invoke 1
+ invoke 3
+ }
+
+ #TkMenu.new(m, 'tearoff'=>false) {|cascade_radio|
+ TkMenu.new(cascade_menu, 'tearoff'=>false) {|cascade_radio|
+ cascade_menu.add('cascade', 'label'=>'Radio buttons(ラジオボタン)',
+ 'menu'=>cascade_radio, 'underline'=>0)
+ pointSize = TkVariable.new
+ add('radio', 'label'=>'10 ãƒã‚¤ãƒ³ãƒˆ', 'variable'=>pointSize, 'value'=>10)
+ add('radio', 'label'=>'14 ãƒã‚¤ãƒ³ãƒˆ', 'variable'=>pointSize, 'value'=>14)
+ add('radio', 'label'=>'18 ãƒã‚¤ãƒ³ãƒˆ', 'variable'=>pointSize, 'value'=>18)
+ add('radio', 'label'=>'24 ãƒã‚¤ãƒ³ãƒˆ', 'variable'=>pointSize, 'value'=>24)
+ add('radio', 'label'=>'32 ãƒã‚¤ãƒ³ãƒˆ', 'variable'=>pointSize, 'value'=>32)
+ add('separator')
+ style = TkVariable.new
+ add('radio', 'label'=>'ローマン', 'variable'=>style, 'value'=>'roman')
+ add('radio', 'label'=>'ボールド', 'variable'=>style, 'value'=>'bold')
+ add('radio', 'label'=>'イタリック', 'variable'=>style, 'value'=>'italic')
+ add('separator')
+ add('command', 'label'=>'ç¾åœ¨ã®å€¤ã‚’表示',
+ 'command'=>proc{showVars($menu_demo,
+ ['ãƒã‚¤ãƒ³ãƒˆã‚µã‚¤ã‚º', pointSize],
+ ['スタイル', style])} )
+ invoke 1
+ invoke 7
+ }
+ }
+}
+
+TkMenubutton.new($menu_frame, 'text'=>'Icons', 'underline'=>0) {|m|
+ pack('side'=>'left')
+ TkMenu.new(m, 'tearoff'=>false) {|icon_menu|
+ m.configure('menu'=>icon_menu)
+ add('command',
+ 'bitmap'=>'@'+[$demo_dir,'..',
+ 'images','pattern.xbm'].join(File::Separator),
+ 'command'=>proc{TkDialog.new('title'=>'Bitmap Menu Entry',
+ 'text'=>'今ã‚ãªãŸãŒé¸æŠžã—ãŸãƒ¡ãƒ‹ãƒ¥ãƒ¼ã®é …ç›®ã¯ãƒ†ã‚­ã‚¹ãƒˆã§ã¯ãªãビットマップを表示ã—ã¦ã„ã¾ã—ãŸã€‚ãれ以外ã®ç‚¹ã§ã¯ä»–ã®ãƒ¡ãƒ‹ãƒ¥ãƒ¼é …ç›®ã¨å¤‰ã‚ã‚Šã¾ã›ã‚“。',
+ 'bitmap'=>'', 'default'=>0,
+ 'buttons'=>'了解')} )
+ ['info', 'questhead', 'error'].each{|icon|
+ add('command', 'bitmap'=>icon,
+ 'command'=>proc{print "You invoked the #{icon} bitmap\n"})
+ }
+ }
+}
+
+TkMenubutton.new($menu_frame, 'text'=>'More', 'underline'=>0) {|m|
+ pack('side'=>'left')
+ TkMenu.new(m, 'tearoff'=>false) {|more_menu|
+ m.configure('menu'=>more_menu)
+ [ 'エントリ','別ã®ã‚¨ãƒ³ãƒˆãƒª','何もã—ãªã„','ã»ã¨ã‚“ã©ä½•ã‚‚ã—ãªã„',
+ '人生をæ„義ã‚ã‚‹ã‚‚ã®ã«' ].each{|i|
+ add('command', 'label'=>i,
+ 'command'=>proc{print "You invoked \"#{i}\"\n"})
+ }
+ }
+}
+
+TkMenubutton.new($menu_frame, 'text'=>'Colors', 'underline'=>0) {|m|
+ pack('side'=>'left')
+ TkMenu.new(m) {|colors_menu|
+ m.configure('menu'=>colors_menu)
+ ['red', 'orange', 'yellow', 'green', 'blue'].each{|c|
+ add('command', 'label'=>c, 'background'=>c,
+ 'command'=>proc{print "You invoked \"#{c}\"\n"})
+ }
+ }
+}
diff --git a/jni/ruby/ext/tk/sample/demos-jp/menu84.rb b/jni/ruby/ext/tk/sample/demos-jp/menu84.rb
new file mode 100644
index 0000000..6a57279
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/demos-jp/menu84.rb
@@ -0,0 +1,213 @@
+# -*- coding: utf-8 -*-
+#
+# menus widget demo (called by 'widget')
+#
+
+# toplevel widget
+if defined?($menu84_demo) && $menu84_demo
+ $menu84_demo.destroy
+ $menu84_demo = nil
+end
+
+# demo toplevel widget
+$menu84_demo = TkToplevel.new {|w|
+ title("File Selection Dialogs")
+ iconname("menu84")
+ positionWindow(w)
+}
+
+base_frame = TkFrame.new($menu84_demo).pack(:fill=>:both, :expand=>true)
+
+begin
+ windowingsystem = Tk.windowingsystem()
+rescue
+ windowingsystem = ""
+end
+
+# label
+TkLabel.new(base_frame,'font'=>$font,'wraplength'=>'4i','justify'=>'left') {
+ if $tk_platform['platform'] == 'macintosh' ||
+ windowingsystem == "classic" || windowingsystem == "aqua"
+ text("ã“ã®ã‚¦ã‚£ãƒ³ãƒ‰ã‚¦ã«ã¯ã‚«ã‚¹ã‚±ãƒ¼ãƒ‰ãƒ¡ãƒ‹ãƒ¥ãƒ¼ã‚’æŒã¤ãƒ¡ãƒ‹ãƒ¥ãƒ¼ãƒãƒ¼ãŒä»˜ã‘られã¦ã„ã¾ã™ã€‚Command+x ('x'ã¯ã‚³ãƒžãƒ³ãƒ‰ã‚­ãƒ¼ã‚·ãƒ³ãƒœãƒ«ã«ç¶šã‘ã¦è¡¨ç¤ºã•ã‚Œã¦ã„る文字ã§ã™) ã¨ã‚¿ã‚¤ãƒ—ã™ã‚‹ã“ã¨ã«ã‚ˆã£ã¦ã‚‚é …ç›®ã®æ©Ÿèƒ½ã‚’呼ã³å‡ºã™ã“ã¨ãŒã§ãã¾ã™ã€‚最後ã®ãƒ¡ãƒ‹ãƒ¥ãƒ¼ã¯ã€ãƒžã‚¦ã‚¹ã§ã‚¦ã‚£ãƒ³ãƒ‰ã‚¦ã®å¤–ã«ãƒ‰ãƒ©ãƒƒã‚°ã™ã‚‹ã“ã¨ã«ã‚ˆã£ã¦ã€ç‹¬ç«‹ã—ãŸãƒ‘レットã¨ãªã‚‹ã‚ˆã†ã«åˆ‡ã‚Šæ”¾ã™ã“ã¨ãŒå¯èƒ½ã§ã™ã€‚")
+ else
+ text("ã“ã®ã‚¦ã‚£ãƒ³ãƒ‰ã‚¦ã«ã¯ã‚«ã‚¹ã‚±ãƒ¼ãƒ‰ãƒ¡ãƒ‹ãƒ¥ãƒ¼ã‚’æŒã¤ãƒ¡ãƒ‹ãƒ¥ãƒ¼ãƒãƒ¼ãŒä»˜ã‘られã¦ã„ã¾ã™ã€‚Alt+x ('x'ã¯ãƒ¡ãƒ‹ãƒ¥ãƒ¼ä¸Šã§ä¸‹ç·šãŒå¼•ã‹ã‚ŒãŸæ–‡å­—ã§ã™) ã¨ã‚¿ã‚¤ãƒ—ã™ã‚‹ã“ã¨ã«ã‚ˆã£ã¦ã‚‚メニューを呼ã³å‡ºã™ã“ã¨ãŒã§ãã¾ã™ã€‚矢å°ã‚­ãƒ¼ã‚’使ã£ã¦ã€ãƒ¡ãƒ‹ãƒ¥ãƒ¼é–“を移動ã™ã‚‹ã“ã¨ã‚‚å¯èƒ½ã§ã™ã€‚メニューãŒè¡¨ç¤ºã•ã‚Œã¦ã„る時ã«ã¯ã€ç¾åœ¨ä½ç½®ã®é …目をスペースキーã§é¸æŠžã—ãŸã‚Šã€ä¸‹ç·šãŒå¼•ã‹ã‚ŒãŸæ–‡å­—を入力ã™ã‚‹ã“ã¨ã§ãã®é …目をé¸æŠžã—ãŸã‚Šã™ã‚‹ã“ã¨ãŒã§ãã¾ã™ã€‚ã‚‚ã—é …ç›®ã«ã‚¢ã‚¯ã‚»ãƒ©ãƒ¬ãƒ¼ã‚¿ã®æŒ‡å®šãŒãªã•ã‚Œã¦ã„ãŸãªã‚‰ã°ã€ãã®æŒ‡å®šã•ã‚ŒãŸã‚­ãƒ¼å…¥åŠ›ã‚’è¡Œã†ã“ã¨ã§ã€ãƒ¡ãƒ‹ãƒ¥ãƒ¼ã‚’表示ã•ã›ã‚‹ã“ã¨ãªã直接ãã®é …ç›®ã®æ©Ÿèƒ½ã‚’呼ã³å‡ºã›ã¾ã™ã€‚最後ã®ãƒ¡ãƒ‹ãƒ¥ãƒ¼ã¯ã€ãƒ¡ãƒ‹ãƒ¥ãƒ¼ã®æœ€åˆã®é …目をé¸æŠžã™ã‚‹ã“ã¨ã«ã‚ˆã£ã¦ã€ç‹¬ç«‹ã—ãŸãƒ‘レットã¨ãªã‚‹ã‚ˆã†ã«åˆ‡ã‚Šæ”¾ã™ã“ã¨ãŒå¯èƒ½ã§ã™ã€‚")
+ end
+}.pack('side'=>'top')
+
+
+menustatus = TkVariable.new(" ")
+TkFrame.new(base_frame) {|frame|
+ TkLabel.new(frame, 'textvariable'=>menustatus, 'relief'=>'sunken',
+ 'bd'=>1, 'font'=>['Helvetica', '10'],
+ 'anchor'=>'w').pack('side'=>'left', 'padx'=>2,
+ 'expand'=>true, 'fill'=>'both')
+ pack('side'=>'bottom', 'fill'=>'x', 'pady'=>2)
+}
+
+
+# frame
+TkFrame.new(base_frame) {|frame|
+ TkButton.new(frame) {
+ #text '了解'
+ text 'é–‰ã˜ã‚‹'
+ command proc{
+ tmppath = $menu84_demo
+ $menu84_demo = nil
+ tmppath.destroy
+ }
+ }.pack('side'=>'left', 'expand'=>'yes')
+
+ TkButton.new(frame) {
+ text 'コードå‚ç…§'
+ command proc{showCode 'menu84'}
+ }.pack('side'=>'left', 'expand'=>'yes')
+}.pack('side'=>'bottom', 'fill'=>'x', 'pady'=>'2m')
+
+
+# create menu frame
+$menu84_frame = TkMenu.new($menu84_demo, 'tearoff'=>false)
+
+# menu
+TkMenu.new($menu84_frame, 'tearoff'=>false) {|m|
+ $menu84_frame.add('cascade', 'label'=>'File', 'menu'=>m, 'underline'=>0)
+ add('command', 'label'=>'Open...', 'command'=>proc{fail 'ã“ã‚Œã¯å˜ãªã‚‹ãƒ‡ãƒ¢ã§ã™ã‹ã‚‰ã€"Open..." é …ç›®ã®æ©Ÿèƒ½ã¯ç‰¹ã«å®šç¾©ã•ã‚Œã¦ã¯ã„ã¾ã›ã‚“。'})
+ add('command', 'label'=>'New', 'command'=>proc{fail 'ã“ã‚Œã¯å˜ãªã‚‹ãƒ‡ãƒ¢ã§ã™ã‹ã‚‰ã€"New" é …ç›®ã®æ©Ÿèƒ½ã¯ç‰¹ã«å®šç¾©ã•ã‚Œã¦ã¯ã„ã¾ã›ã‚“。'})
+ add('command', 'label'=>'Save', 'command'=>proc{fail 'ã“ã‚Œã¯å˜ãªã‚‹ãƒ‡ãƒ¢ã§ã™ã‹ã‚‰ã€"Save" é …ç›®ã®æ©Ÿèƒ½ã¯ç‰¹ã«å®šç¾©ã•ã‚Œã¦ã¯ã„ã¾ã›ã‚“。'})
+ add('command', 'label'=>'Save As...', 'command'=>proc{fail 'ã“ã‚Œã¯å˜ãªã‚‹ãƒ‡ãƒ¢ã§ã™ã‹ã‚‰ã€"Save As..." é …ç›®ã®æ©Ÿèƒ½ã¯ç‰¹ã«å®šç¾©ã•ã‚Œã¦ã¯ã„ã¾ã›ã‚“。'})
+ add('separator')
+ add('command', 'label'=>'Print Setup...', 'command'=>proc{fail 'ã“ã‚Œã¯å˜ãªã‚‹ãƒ‡ãƒ¢ã§ã™ã‹ã‚‰ã€"Print Setup..." é …ç›®ã®æ©Ÿèƒ½ã¯ç‰¹ã«å®šç¾©ã•ã‚Œã¦ã¯ã„ã¾ã›ã‚“。'})
+ add('command', 'label'=>'Print...', 'command'=>proc{fail 'ã“ã‚Œã¯å˜ãªã‚‹ãƒ‡ãƒ¢ã§ã™ã‹ã‚‰ã€"Print..." é …ç›®ã®æ©Ÿèƒ½ã¯ç‰¹ã«å®šç¾©ã•ã‚Œã¦ã¯ã„ã¾ã›ã‚“。'})
+ add('separator')
+ add('command', 'label'=>'Dismiss Menus Demo', 'command'=>proc{$menu84_demo.destroy})
+}
+
+if $tk_platform['platform'] == 'macintosh' ||
+ windowingsystem = "classic" || windowingsystem = "aqua"
+ modifier = 'Command'
+elsif $tk_platform['platform'] == 'windows'
+ modifier = 'Control'
+else
+ modifier = 'Meta'
+end
+
+TkMenu.new($menu84_frame, 'tearoff'=>false) {|m|
+ $menu84_frame.add('cascade', 'label'=>'Basic', 'menu'=>m, 'underline'=>0)
+ add('command', 'label'=>'Long entry that does nothing')
+ ['A','B','C','D','E','F','G'].each{|c|
+ add('command', 'label'=>"Print letter \"#{c}\"",
+ 'underline'=>14, 'accelerator'=>"Meta+#{c}",
+ 'command'=>proc{print c,"\n"}, 'accelerator'=>"#{modifier}+#{c}")
+ $menu84_demo.bind("#{modifier}-#{c.downcase}", proc{print c,"\n"})
+ }
+}
+
+TkMenu.new($menu84_frame, 'tearoff'=>false) {|m|
+ $menu84_frame.add('cascade', 'label'=>'Cascades', 'menu'=>m, 'underline'=>0)
+ add('command', 'label'=>'Print hello',
+ 'command'=>proc{print "Hello\n"},
+ 'accelerator'=>"#{modifier}+H", 'underline'=>6)
+ $menu84_demo.bind("#{modifier}-h", proc{print "Hello\n"})
+ add('command', 'label'=>'Print goodbye',
+ 'command'=>proc{print "Goodbye\n"},
+ 'accelerator'=>"#{modifier}+G", 'underline'=>6)
+ $menu84_demo.bind("#{modifier}-g", proc{print "Goodbye\n"})
+
+ TkMenu.new(m, 'tearoff'=>false) {|cascade_check|
+ m.add('cascade', 'label'=>'Check button',
+ 'menu'=>cascade_check, 'underline'=>0)
+ oil = TkVariable.new(0)
+ add('check', 'label'=>'オイル検査', 'variable'=>oil)
+ trans = TkVariable.new(0)
+ add('check', 'label'=>'トランスミッション検査', 'variable'=>trans)
+ brakes = TkVariable.new(0)
+ add('check', 'label'=>'ブレーキ検査', 'variable'=>brakes)
+ lights = TkVariable.new(0)
+ add('check', 'label'=>'ライト検査', 'variable'=>lights)
+ add('separator')
+ add('command', 'label'=>'Show current values',
+ 'command'=>proc{showVars($menu84_demo,
+ ['オイル', oil],
+ ['トランスミッション', trans],
+ ['ブレーキ', brakes],
+ ['ライト', lights])} )
+ invoke 1
+ invoke 3
+ }
+
+ TkMenu.new(m, 'tearoff'=>false) {|cascade_radio|
+ m.add('cascade', 'label'=>'Radio buttons',
+ 'menu'=>cascade_radio, 'underline'=>0)
+ pointSize = TkVariable.new
+ add('radio', 'label'=>'10 point', 'variable'=>pointSize, 'value'=>10)
+ add('radio', 'label'=>'14 point', 'variable'=>pointSize, 'value'=>14)
+ add('radio', 'label'=>'18 point', 'variable'=>pointSize, 'value'=>18)
+ add('radio', 'label'=>'24 point', 'variable'=>pointSize, 'value'=>24)
+ add('radio', 'label'=>'32 point', 'variable'=>pointSize, 'value'=>32)
+ add('separator')
+ style = TkVariable.new
+ add('radio', 'label'=>'Roman', 'variable'=>style, 'value'=>'roman')
+ add('radio', 'label'=>'Bold', 'variable'=>style, 'value'=>'bold')
+ add('radio', 'label'=>'Italic', 'variable'=>style, 'value'=>'italic')
+ add('separator')
+ add('command', 'label'=>'ç¾åœ¨å€¤ã®è¡¨ç¤º',
+ 'command'=>proc{showVars($menu84_demo,
+ ['pointSize', pointSize],
+ ['style', style])} )
+ invoke 1
+ invoke 7
+ }
+}
+
+TkMenu.new($menu84_frame, 'tearoff'=>false) {|m|
+ $menu84_frame.add('cascade', 'label'=>'Icons', 'menu'=>m, 'underline'=>0)
+ add('command', 'hidemargin'=>1,
+ 'bitmap'=>'@'+[$demo_dir,'..',
+ 'images','pattern.xbm'].join(File::Separator),
+ 'command'=>proc{TkDialog.new('title'=>'Bitmap Menu Entry',
+ 'text'=>'ã‚ãªãŸãŒé¸æŠžã—ãŸãƒ¡ãƒ‹ãƒ¥ãƒ¼é …ç›®ã¯ã€æ–‡å­—列ã®ä»£ã‚ã‚Šã«ãƒ“ットマップイメージã§é …目を表示ã—ãŸã‚‚ã®ã§ã™ã€‚ãれ以外ã®ç‚¹ã§ã¯ã€ã»ã‹ã®ãƒ¡ãƒ‹ãƒ¥ãƒ¼é …ç›®ã¨ã®é–“ã§ç‰¹ã«é•ã„ãŒã‚ã‚‹ã‚ã‘ã§ã¯ã‚ã‚Šã¾ã›ã‚“。',
+ 'bitmap'=>'', 'default'=>0,
+ 'buttons'=>'é–‰ã˜ã‚‹')} )
+ ['info', 'questhead', 'error'].each{|icon|
+ add('command', 'bitmap'=>icon, 'hidemargin'=>1,
+ 'command'=>proc{print "You invoked the #{icon} bitmap\n"})
+ }
+
+ entryconfigure(2, :columnbreak=>true)
+}
+
+TkMenu.new($menu84_frame, 'tearoff'=>false) {|m|
+ $menu84_frame.add('cascade', 'label'=>'More', 'menu'=>m, 'underline'=>0)
+ [ 'An entry','Another entry','Does nothing','Does almost nothing',
+ 'Make life meaningful' ].each{|i|
+ add('command', 'label'=>i,
+ 'command'=>proc{print "You invoked \"#{i}\"\n"})
+ }
+
+ m.entryconfigure('Does almost nothing',
+ 'bitmap'=>'questhead', 'compound'=>'left',
+ 'command'=>proc{
+ TkDialog.new('title'=>'Compound Menu Entry',
+ 'message'=>'ã‚ãªãŸãŒé¸æŠžã—ãŸãƒ¡ãƒ‹ãƒ¥ãƒ¼é …ç›®ã¯ã€ãƒ“ットマップイメージã¨æ–‡å­—列ã¨ã‚’åŒæ™‚ã«ä¸€ã¤ã®é …ç›®ã«è¡¨ç¤ºã™ã‚‹ã‚ˆã†ã«ã—ãŸã‚‚ã®ã§ã™ã€‚ãれ以外ã®ç‚¹ã§ã¯ã€ã»ã‹ã®ãƒ¡ãƒ‹ãƒ¥ãƒ¼é …ç›®ã¨ã®é–“ã§ç‰¹ã«é•ã„ãŒã‚ã‚‹ã‚ã‘ã§ã¯ã‚ã‚Šã¾ã›ã‚“。',
+ 'buttons'=>['了解'], 'bitmap'=>'')
+ })
+}
+
+TkMenu.new($menu84_frame) {|m|
+ $menu84_frame.add('cascade', 'label'=>'Colors', 'menu'=>m, 'underline'=>0)
+ ['red', 'orange', 'yellow', 'green', 'blue'].each{|c|
+ add('command', 'label'=>c, 'background'=>c,
+ 'command'=>proc{print "You invoked \"#{c}\"\n"})
+ }
+}
+
+$menu84_demo.menu($menu84_frame)
+
+TkMenu.bind('<MenuSelect>', proc{|w|
+ begin
+ label = w.entrycget('active', 'label')
+ rescue
+ label = " "
+ end
+ menustatus.value = label
+ Tk.update(true)
+ }, '%W')
diff --git a/jni/ruby/ext/tk/sample/demos-jp/menu8x.rb b/jni/ruby/ext/tk/sample/demos-jp/menu8x.rb
new file mode 100644
index 0000000..77ecb5b
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/demos-jp/menu8x.rb
@@ -0,0 +1,233 @@
+# -*- coding: utf-8 -*-
+#
+# menus widget demo (called by 'widget')
+#
+
+# toplevel widget ãŒå­˜åœ¨ã™ã‚Œã°å‰Šé™¤ã™ã‚‹
+if defined?($menu8x_demo) && $menu8x_demo
+ $menu8x_demo.destroy
+ $menu8x_demo = nil
+end
+
+# demo 用㮠toplevel widget を生æˆ
+$menu8x_demo = TkToplevel.new {|w|
+ title("Menu Demonstration (Tk8.x)")
+ iconname("menu")
+ positionWindow(w)
+}
+
+base_frame = TkFrame.new($menu8x_demo).pack(:fill=>:both, :expand=>true)
+
+# version check
+if $tk_version.to_f < 8.0
+
+# label 生æˆ
+TkLabel.new(base_frame,'font'=>$font,'wraplength'=>'4i','justify'=>'left') {
+ text("実行ã—よã†ã¨ã—ãŸã‚¹ã‚¯ãƒªãƒ—ト㯠Tk8.0 以上ã§åˆ©ç”¨ã§ãる機能を利用ã—ã¦ã„ã‚‹ãŸã‚ã€ã‚ãªãŸã® Ruby#{VERSION}/Tk#{$tk_version}#{(Tk::JAPANIZED_TK)? 'jp': ''} ã§ã¯æ­£å¸¸ã«å®Ÿè¡Œã§ãã¾ã›ã‚“。よã£ã¦ãƒ‡ãƒ¢ã®å®Ÿè¡Œã‚’中止ã—ã¾ã—ãŸã€‚ãŸã ã—ã€ä¸‹ã®ã‚³ãƒ¼ãƒ‰å‚照ボタンを押ã™ã“ã¨ã§ã€å®Ÿè¡ŒãŒä¸­æ­¢ã•ã‚ŒãŸã‚¹ã‚¯ãƒªãƒ—トã®ã‚½ãƒ¼ã‚¹ã‚’å‚ç…§ã™ã‚‹ã“ã¨ã¯å¯èƒ½ã§ã™ã€‚")
+}.pack('side'=>'top')
+
+# frame 生æˆ
+TkFrame.new(base_frame) {|frame|
+ TkButton.new(frame) {
+ #text '了解'
+ text 'é–‰ã˜ã‚‹'
+ command proc{
+ tmppath = $menu8x_demo
+ $menu8x_demo = nil
+ tmppath.destroy
+ }
+ }.pack('side'=>'left', 'expand'=>'yes')
+
+ TkButton.new(frame) {
+ text 'コードå‚ç…§'
+ command proc{showCode 'menu8x'}
+ }.pack('side'=>'left', 'expand'=>'yes')
+}.pack('side'=>'bottom', 'fill'=>'x', 'pady'=>'2m')
+
+else ; # Tk8.x
+
+begin
+ windowingsystem = Tk.windowingsystem()
+rescue
+ windowingsystem = ""
+end
+
+# label 生æˆ
+TkLabel.new(base_frame,'font'=>$font,'wraplength'=>'4i','justify'=>'left') {
+ if $tk_platform['platform'] == 'macintosh' ||
+ windowingsystem == "classic" || windowingsystem == "aqua"
+ text("ã“ã®ã‚¦ã‚£ãƒ³ãƒ‰ã‚¦ã¯æ§˜ã€…ãªãƒ¡ãƒ‹ãƒ¥ãƒ¼ã¨ã‚«ã‚¹ã‚±ãƒ¼ãƒ‰ãƒ¡ãƒ‹ãƒ¥ãƒ¼ã‹ã‚‰æ§‹æˆã•ã‚Œã¦ã„ã¾ã™ã€‚Command-X を入力ã™ã‚‹ã¨ã€XãŒã‚³ãƒžãƒ³ãƒ‰ã‚­ãƒ¼è¨˜å·ã«ç¶šã„ã¦è¡¨ç¤ºã•ã‚Œã¦ã„る文字ãªã‚‰ã°ã€ã‚¢ã‚¯ã‚»ãƒ©ãƒ¬ãƒ¼ã‚¿ã‚’使ã£ãŸé …目起動を行ã†ã“ã¨ãŒã§ãã¾ã™ã€‚メニューè¦ç´ ä¸­ã€æœ€å¾Œã®ã‚‚ã®ã¯ã€ãã®ãƒ¡ãƒ‹ãƒ¥ãƒ¼ã®æœ€åˆã®é …目をé¸æŠžã™ã‚‹ã“ã¨ã§ç‹¬ç«‹ã•ã›ã‚‹ã“ã¨ãŒã§ãã¾ã™ã€‚")
+ else
+ text("ã“ã®ã‚¦ã‚£ãƒ³ãƒ‰ã‚¦ã¯æ§˜ã€…ãªãƒ¡ãƒ‹ãƒ¥ãƒ¼ã¨ã‚«ã‚¹ã‚±ãƒ¼ãƒ‰ãƒ¡ãƒ‹ãƒ¥ãƒ¼ã‹ã‚‰æ§‹æˆã•ã‚Œã¦ã„ã¾ã™ã€‚Alt-X を入力ã™ã‚‹ã¨ã€XãŒãƒ¡ãƒ‹ãƒ¥ãƒ¼ã«ã‚¢ãƒ³ãƒ€ãƒ¼ãƒ©ã‚¤ãƒ³ä»˜ãã§è¡¨ç¤ºã•ã‚Œã¦ã„る文字ãªã‚‰ã°ã€ã‚­ãƒ¼ãƒœãƒ¼ãƒ‰ã‹ã‚‰ã®æŒ‡å®šãŒã§ãã¾ã™ã€‚矢å°ã‚­ãƒ¼ã§ãƒ¡ãƒ‹ãƒ¥ãƒ¼ã®ãƒˆãƒ©ãƒãƒ¼ã‚¹ã‚‚å¯èƒ½ã§ã™ã€‚メニューãŒæŒ‡å®šã•ã‚ŒãŸéš›ã«ã¯ã€ã‚¹ãƒšãƒ¼ã‚¹ã‚­ãƒ¼ã§å®Ÿè¡Œã™ã‚‹ã“ã¨ãŒã§ãã¾ã™ã€‚ã‚ã‚‹ã„ã¯ã€ã‚¢ãƒ³ãƒ€ãƒ¼ãƒ©ã‚¤ãƒ³ä»˜ãã®æ–‡å­—を入力ã™ã‚‹ã“ã¨ã§ã‚‚実行ã§ãã¾ã™ã€‚メニューã®ã‚¨ãƒ³ãƒˆãƒªãŒã‚¢ã‚¯ã‚»ãƒ©ãƒ¬ãƒ¼ã‚¿ã‚’æŒã£ã¦ã„ã‚‹å ´åˆã¯ã€ãã®ã‚¢ã‚¯ã‚»ãƒ©ãƒ¬ãƒ¼ã‚¿ã‚’入力ã™ã‚‹ã“ã¨ã§ãƒ¡ãƒ‹ãƒ¥ãƒ¼ã‚’指定ã™ã‚‹ã“ã¨ãªã—ã«å®Ÿè¡Œã™ã‚‹ã“ã¨ãŒã§ãã¾ã™ã€‚メニューè¦ç´ ä¸­ã€æœ€å¾Œã®ã‚‚ã®ã¯ã€ãã®ãƒ¡ãƒ‹ãƒ¥ãƒ¼ã®æœ€åˆã®é …目をé¸æŠžã™ã‚‹ã“ã¨ã§ç‹¬ç«‹ã•ã›ã‚‹ã“ã¨ãŒã§ãã¾ã™ã€‚")
+ end
+}.pack('side'=>'top')
+
+# 状態表示ã®ç”Ÿæˆ
+$menu8xstatus = TkVariable.new(" ")
+TkFrame.new(base_frame) {|frame|
+ TkLabel.new(frame, 'textvariable'=>$menu8xstatus, 'relief'=>'sunken',
+ 'bd'=>1, 'font'=>['Helvetica', '10'], 'anchor'=>'w')\
+ .pack('side'=>'left', 'padx'=>2, 'expand'=>'yes', 'fill'=>'both')
+}.pack('side'=>'bottom', 'fill'=>'x', 'pady'=>2)
+
+# frame 生æˆ
+TkFrame.new(base_frame) {|frame|
+ TkButton.new(frame) {
+ #text '了解'
+ text 'é–‰ã˜ã‚‹'
+ command proc{
+ tmppath = $menu8x_demo
+ $menu8x_demo = nil
+ tmppath.destroy
+ }
+ }.pack('side'=>'left', 'expand'=>'yes')
+
+ TkButton.new(frame) {
+ text 'コードå‚ç…§'
+ command proc{showCode 'menu8x'}
+ }.pack('side'=>'left', 'expand'=>'yes')
+}.pack('side'=>'bottom', 'fill'=>'x', 'pady'=>'2m')
+
+# menu 生æˆ
+TkMenu.new($menu8x_demo, 'tearoff'=>false) {|m|
+ TkMenu.new(m, 'tearoff'=>false) {|file_menu|
+ m.add('cascade', 'label'=>'File', 'menu'=>file_menu, 'underline'=>0)
+ add('command', 'label'=>'é–‹ã ...', 'command'=>proc{fail 'ã“ã‚Œã¯ã€ãƒ‡ãƒ¢ã§ã™ã®ã§"é–‹ã ..."ã«å¯¾ã™ã‚‹ã‚¢ã‚¯ã‚·ãƒ§ãƒ³ã¯å®šç¾©ã•ã‚Œã¦ã„ã¾ã›ã‚“。'})
+ add('command', 'label'=>'æ–°è¦', 'command'=>proc{fail 'ã“ã‚Œã¯ã€ãƒ‡ãƒ¢ã§ã™ã®ã§"æ–°è¦"ã«å¯¾ã™ã‚‹ã‚¢ã‚¯ã‚·ãƒ§ãƒ³ã¯å®šç¾©ã•ã‚Œã¦ã„ã¾ã›ã‚“。'})
+ add('command', 'label'=>'ä¿å­˜', 'command'=>proc{fail 'ã“ã‚Œã¯ã€ãƒ‡ãƒ¢ã§ã™ã®ã§"ä¿å­˜"ã«å¯¾ã™ã‚‹ã‚¢ã‚¯ã‚·ãƒ§ãƒ³ã¯å®šç¾©ã•ã‚Œã¦ã„ã¾ã›ã‚“。'})
+ add('command', 'label'=>'ä¿å­˜(指定) ...', 'command'=>proc{fail 'ã“ã‚Œã¯ã€ãƒ‡ãƒ¢ã§ã™ã®ã§"ä¿å­˜(指定) ..."ã«å¯¾ã™ã‚‹ã‚¢ã‚¯ã‚·ãƒ§ãƒ³ã¯å®šç¾©ã•ã‚Œã¦ã„ã¾ã›ã‚“。'})
+ add('separator')
+ add('command', 'label'=>'プリント設定 ...', 'command'=>proc{fail 'ã“ã‚Œã¯ã€ãƒ‡ãƒ¢ã§ã™ã®ã§"プリント設定 ..."ã«å¯¾ã™ã‚‹ã‚¢ã‚¯ã‚·ãƒ§ãƒ³ã¯å®šç¾©ã•ã‚Œã¦ã„ã¾ã›ã‚“。'})
+ add('command', 'label'=>'プリント ...', 'command'=>proc{fail 'ã“ã‚Œã¯ã€ãƒ‡ãƒ¢ã§ã™ã®ã§"プリント ..."ã«å¯¾ã™ã‚‹ã‚¢ã‚¯ã‚·ãƒ§ãƒ³ã¯å®šç¾©ã•ã‚Œã¦ã„ã¾ã›ã‚“。'})
+ add('separator')
+ add('command', 'label'=>'終了', 'command'=>proc{$menu8x_demo.destroy})
+ }
+
+ if $tk_platform['platform'] == 'macintosh' ||
+ windowingsystem == "classic" || windowingsystem == "aqua"
+ modifier = 'Command'
+ elsif $tk_platform['platform'] == 'windows'
+ modifier = 'Control'
+ else
+ modifier = 'Meta'
+ end
+
+ TkMenu.new(m, 'tearoff'=>false) {|basic_menu|
+ m.add('cascade', 'label'=>'Basic', 'menu'=>basic_menu, 'underline'=>0)
+ add('command', 'label'=>'何もã—ãªã„é•·ã„エントリ')
+ ['A','B','C','D','E','F','G'].each{|c|
+ # add('command', 'label'=>"文字 \"#{c}\" ã‚’å°å­—", 'underline'=>4,
+ add('command', 'label'=>"Print letter \"#{c}\" (文字 \"#{c}\" ã‚’å°å­—)",
+ 'underline'=>14, 'accelerator'=>"Meta+#{c}",
+ 'command'=>proc{print c,"\n"}, 'accelerator'=>"#{modifier}+#{c}")
+ $menu8x_demo.bind("#{modifier}-#{c.downcase}", proc{print c,"\n"})
+ }
+ }
+
+ TkMenu.new(m, 'tearoff'=>false) {|cascade_menu|
+ m.add('cascade', 'label'=>'Cascades', 'menu'=>cascade_menu, 'underline'=>0)
+ add('command', 'label'=>'Print hello(ã“ã‚“ã«ã¡ã¯)',
+ 'command'=>proc{print "Hello(ã“ã‚“ã«ã¡ã¯)\n"},
+ 'accelerator'=>"#{modifier}+H", 'underline'=>6)
+ $menu8x_demo.bind("#{modifier}-h", proc{print "Hello(ã“ã‚“ã«ã¡ã¯)\n"})
+ add('command', 'label'=>'Print goodbye(ã•ã‚ˆã†ãªã‚‰)',
+ 'command'=>proc{print "Goodbye(ã•ã‚ˆã†ãªã‚‰)\n"},
+ 'accelerator'=>"#{modifier}+G", 'underline'=>6)
+ $menu8x_demo.bind("#{modifier}-g", proc{print "Goodbye(ã•ã‚ˆã†ãªã‚‰)\n"})
+
+ TkMenu.new(m, 'tearoff'=>false) {|cascade_check|
+ cascade_menu.add('cascade', 'label'=>'Check buttons(ãƒã‚§ãƒƒã‚¯ãƒœã‚¿ãƒ³)',
+ 'menu'=>cascade_check, 'underline'=>0)
+ oil = TkVariable.new(0)
+ add('check', 'label'=>'オイル点検', 'variable'=>oil)
+ trans = TkVariable.new(0)
+ add('check', 'label'=>'トランスミッション点検', 'variable'=>trans)
+ brakes = TkVariable.new(0)
+ add('check', 'label'=>'ブレーキ点検', 'variable'=>brakes)
+ lights = TkVariable.new(0)
+ add('check', 'label'=>'ライト点検', 'variable'=>lights)
+ add('separator')
+ add('command', 'label'=>'ç¾åœ¨ã®å€¤ã‚’表示',
+ 'command'=>proc{showVars($menu8x_demo,
+ ['オイル点検', oil],
+ ['トランスミッション点検', trans],
+ ['ブレーキ点検', brakes],
+ ['ライト点検', lights])} )
+ invoke 1
+ invoke 3
+ }
+
+ TkMenu.new(m, 'tearoff'=>false) {|cascade_radio|
+ cascade_menu.add('cascade', 'label'=>'Radio buttons(ラジオボタン)',
+ 'menu'=>cascade_radio, 'underline'=>0)
+ pointSize = TkVariable.new
+ add('radio', 'label'=>'10 ãƒã‚¤ãƒ³ãƒˆ', 'variable'=>pointSize, 'value'=>10)
+ add('radio', 'label'=>'14 ãƒã‚¤ãƒ³ãƒˆ', 'variable'=>pointSize, 'value'=>14)
+ add('radio', 'label'=>'18 ãƒã‚¤ãƒ³ãƒˆ', 'variable'=>pointSize, 'value'=>18)
+ add('radio', 'label'=>'24 ãƒã‚¤ãƒ³ãƒˆ', 'variable'=>pointSize, 'value'=>24)
+ add('radio', 'label'=>'32 ãƒã‚¤ãƒ³ãƒˆ', 'variable'=>pointSize, 'value'=>32)
+ add('separator')
+ style = TkVariable.new
+ add('radio', 'label'=>'ローマン', 'variable'=>style, 'value'=>'roman')
+ add('radio', 'label'=>'ボールド', 'variable'=>style, 'value'=>'bold')
+ add('radio', 'label'=>'イタリック', 'variable'=>style, 'value'=>'italic')
+ add('separator')
+ add('command', 'label'=>'ç¾åœ¨ã®å€¤ã‚’表示',
+ 'command'=>proc{showVars($menu8x_demo,
+ ['ãƒã‚¤ãƒ³ãƒˆã‚µã‚¤ã‚º', pointSize],
+ ['スタイル', style])} )
+ invoke 1
+ invoke 7
+ }
+ }
+
+ TkMenu.new(m, 'tearoff'=>false) {|icon_menu|
+ m.add('cascade', 'label'=>'Icons', 'menu'=>icon_menu, 'underline'=>0)
+ add('command',
+ 'bitmap'=>'@'+[$demo_dir,'..',
+ 'images','pattern.xbm'].join(File::Separator),
+ 'hidemargin'=>1,
+ 'command'=>proc{TkDialog.new('title'=>'Bitmap Menu Entry',
+ 'text'=>'今ã‚ãªãŸãŒé¸æŠžã—ãŸãƒ¡ãƒ‹ãƒ¥ãƒ¼ã®é …ç›®ã¯ãƒ†ã‚­ã‚¹ãƒˆã§ã¯ãªãビットマップを表示ã—ã¦ã„ã¾ã—ãŸã€‚ãれ以外ã®ç‚¹ã§ã¯ä»–ã®ãƒ¡ãƒ‹ãƒ¥ãƒ¼é …ç›®ã¨å¤‰ã‚ã‚Šã¾ã›ã‚“。',
+ 'bitmap'=>'', 'default'=>0,
+ 'buttons'=>'了解')} )
+ ['info', 'questhead', 'error'].each{|icon|
+ add('command', 'bitmap'=>icon, 'hidemargin'=>1,
+ 'command'=>proc{print "You invoked the #{icon} bitmap\n"})
+ }
+
+ entryconfigure(2, 'columnbreak'=>1)
+ }
+
+ TkMenu.new(m, 'tearoff'=>false) {|more_menu|
+ m.add('cascade', 'label'=>'More', 'menu'=>more_menu, 'underline'=>0)
+ [ 'エントリ','別ã®ã‚¨ãƒ³ãƒˆãƒª','何もã—ãªã„','ã»ã¨ã‚“ã©ä½•ã‚‚ã—ãªã„',
+ '人生をæ„義ã‚ã‚‹ã‚‚ã®ã«' ].each{|i|
+ add('command', 'label'=>i,
+ 'command'=>proc{print "You invoked \"#{i}\"\n"})
+ }
+ }
+
+ TkMenu.new(m) {|colors_menu|
+ m.add('cascade', 'label'=>'Colors', 'menu'=>colors_menu, 'underline'=>1)
+ ['red', 'orange', 'yellow', 'green', 'blue'].each{|c|
+ add('command', 'label'=>c, 'background'=>c,
+ 'command'=>proc{print "You invoked \"#{c}\"\n"})
+ }
+ }
+
+ $menu8x_demo.configure('menu'=>m)
+}
+
+TkMenu.bind('<MenuSelect>',
+ proc{|w|
+ begin
+ label = w.entrycget('active', 'label')
+ rescue
+ label = ' '
+ end
+ $menu8xstatus.value = label
+ Tk.update('idletasks')
+ }, '%W')
+
+end ; # Tk 8.x
diff --git a/jni/ruby/ext/tk/sample/demos-jp/menubu.rb b/jni/ruby/ext/tk/sample/demos-jp/menubu.rb
new file mode 100644
index 0000000..06f9eb8
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/demos-jp/menubu.rb
@@ -0,0 +1,238 @@
+# -*- coding: utf-8 -*-
+require "tkcanvas"
+
+def optionMenu(menubutton, varName, firstValue, *rest)
+ varName.value = firstValue
+ configoptions = {'textvariable'=>varName,'indicatoron'=>'on',
+ 'relief'=>'raised','borderwidth'=>2,'highlightthickness'=>2,
+ 'anchor'=>'c','direction'=>'flush'}
+ configoptions.each {|key, value|
+ menubutton.configure(key, value)
+ }
+ menu = TkMenu.new(menubutton) {
+ tearoff 'off'
+ add 'radio', 'label'=>firstValue, 'variable'=>varName
+ }
+ menubutton.menu(menu)
+ for i in rest
+ menu.add 'radio', 'label'=>i, 'variable'=>varName
+ end
+
+ return menu
+end
+
+if defined?($menubu_demo) && $menubu_demo
+ $menubu_demo.destroy
+ $menubu_demo = nil
+end
+
+$menubu_demo = TkToplevel.new {|w|
+ title("Menu Button Demonstration")
+ iconname("menubutton")
+}
+
+positionWindow($menubu_demo)
+
+base_frame = TkFrame.new($menubu_demo).pack(:fill=>:both, :expand=>true)
+
+# version check
+if $tk_version.to_f < 8.0
+
+# label 生æˆ
+TkLabel.new(base_frame,'font'=>$font,'wraplength'=>'4i','justify'=>'left') {
+ text("実行ã—よã†ã¨ã—ãŸã‚¹ã‚¯ãƒªãƒ—ト㯠Tk8.0 以上ã§åˆ©ç”¨ã§ãる機能を利用ã—ã¦ã„ã‚‹ãŸã‚ã€ã‚ãªãŸã® Ruby#{VERSION}/Tk#{$tk_version}#{(Tk::JAPANIZED_TK)? 'jp': ''} ã§ã¯æ­£å¸¸ã«å®Ÿè¡Œã§ãã¾ã›ã‚“。よã£ã¦ãƒ‡ãƒ¢ã®å®Ÿè¡Œã‚’中止ã—ã¾ã—ãŸã€‚ãŸã ã—ã€ä¸‹ã®ã‚³ãƒ¼ãƒ‰å‚照ボタンを押ã™ã“ã¨ã§ã€å®Ÿè¡ŒãŒä¸­æ­¢ã•ã‚ŒãŸã‚¹ã‚¯ãƒªãƒ—トã®ã‚½ãƒ¼ã‚¹ã‚’å‚ç…§ã™ã‚‹ã“ã¨ã¯å¯èƒ½ã§ã™ã€‚")
+}.pack('side'=>'top')
+
+# frame 生æˆ
+TkFrame.new(base_frame) {|frame|
+ TkButton.new(frame) {
+ #text '了解'
+ text 'é–‰ã˜ã‚‹'
+ command proc{
+ tmppath = $menubu_demo
+ $menubu_demo = nil
+ tmppath.destroy
+ }
+ }.pack('side'=>'left', 'expand'=>'yes')
+
+ TkButton.new(frame) {
+ text 'コードå‚ç…§'
+ command proc{showCode 'menubu'}
+ }.pack('side'=>'left', 'expand'=>'yes')
+}.pack('side'=>'bottom', 'fill'=>'x', 'pady'=>'2m')
+
+else ; # Tk8.x
+
+body = TkFrame.new(base_frame)
+body.pack('expand'=>'yes', 'fill'=>'both')
+
+below = TkMenubutton.new(body) {
+ text "Below"
+ underline 0
+ direction 'below'
+ relief 'raised'
+}
+belowMenu = TkMenu.new(below) {
+ tearoff 0
+ add 'command', 'label'=>"Below menu: first item", 'command'=>proc {puts "\"You have selected the first item from the Below menu.\""}
+ add 'command', 'label'=>"Below menu: second item", 'command'=>proc {puts "\"You have selected the second item from the Below menu.\""}
+}
+below.menu(belowMenu)
+below.grid('row'=>0, 'column'=>1, 'sticky'=>'n')
+
+below = TkMenubutton.new(body) {
+ text "Below"
+ underline 0
+ direction 'below'
+ relief 'raised'
+}
+belowMenu = TkMenu.new(below) {
+ tearoff 0
+ add 'command', 'label'=>"Below menu: first item", 'command'=>proc {puts "\"You have selected the first item from the Below menu.\""}
+ add 'command', 'label'=>"Below menu: second item", 'command'=>proc {puts "\"You have selected the second item from the Below menu.\""}
+}
+below.menu(belowMenu)
+below.grid('row'=>0, 'column'=>1, 'sticky'=>'n')
+
+below = TkMenubutton.new(body) {
+ text "Below"
+ underline 0
+ direction 'below'
+ relief 'raised'
+}
+belowMenu = TkMenu.new(below) {
+ tearoff 0
+ add 'command', 'label'=>"Below menu: first item", 'command'=>proc {puts "\"You have selected the first item from the Below menu.\""}
+ add 'command', 'label'=>"Below menu: second item", 'command'=>proc {puts "\"You have selected the second item from the Below menu.\""}
+}
+below.menu(belowMenu)
+below.grid('row'=>0, 'column'=>1, 'sticky'=>'n')
+
+right = TkMenubutton.new(body) {
+ text "Right"
+ underline 0
+ direction 'right'
+ relief 'raised'
+}
+rightMenu = TkMenu.new(right) {
+ tearoff 0
+ add 'command', 'label'=>"Right menu: first item", 'command'=>proc {puts "\"You have selected the first item from the Left menu.\""}
+ add 'command', 'label'=>"Right menu: second item", 'command'=>proc {puts "\"You have selected the second item from the Right menu.\""}
+}
+right.menu(rightMenu)
+right.grid('row'=>1, 'column'=>0, 'sticky'=>'w')
+
+left = TkMenubutton.new(body) {
+ text "Left"
+ underline 0
+ direction 'left'
+ relief 'raised'
+}
+leftMenu = TkMenu.new(left) {
+ tearoff 0
+ add 'command', 'label'=>"Left menu: first item", 'command'=>proc {puts "\"You have selected the first item from the Left menu.\""}
+ add 'command', 'label'=>"Left menu: second item", 'command'=>proc {puts "\"You have selected the second item from the Left menu.\""}
+}
+left.menu(leftMenu)
+left.grid('row'=>1, 'column'=>2, 'sticky'=>'e')
+
+center = TkFrame.new(body) {
+ grid('row'=>1, 'column'=>1, 'sticky'=>'news')
+}
+
+above = TkMenubutton.new(body) {
+ text "Above"
+ underline 0
+ direction 'above'
+ relief 'raised'
+}
+aboveMenu = TkMenu.new(above) {
+ tearoff 0
+ add 'command', 'label'=>"Above menu: first item", 'command'=>proc {puts "\"You have selected the first item from the Above menu.\""}
+ add 'command', 'label'=>"Above menu: second item", 'command'=>proc {puts "\"You have selected the second item from the Above menu.\""}
+}
+above.menu(aboveMenu)
+above.grid('row'=>2, 'column'=>1, 'sticky'=>'s')
+
+center = TkFrame.new(body) {
+ grid('row'=>1, 'column'=>1, 'sticky'=>'news')
+}
+
+TkFrame.new(base_frame) {|frame|
+ TkButton.new(frame) {
+ #text '了解'
+ text 'é–‰ã˜ã‚‹'
+ command proc {
+ tmppath = $menubu_demo
+ $menubu_demo = nil
+ tmppath.destroy
+ }
+ }.pack('side'=>'left', 'expand'=>'yes')
+
+ TkButton.new(frame) {
+ text 'コードå‚ç…§'
+ command proc { showCode 'menubu' }
+ }.pack('side'=>'left', 'expand'=>'yes')
+}.pack('side'=>'bottom', 'expand'=>'yes', 'fill'=>'x', 'pady'=>'2m')
+
+msg = TkLabel.new(center) {
+# font $font
+ wraplength '4i'
+ justify 'left'
+ text "ã“ã‚Œã¯ãƒ¡ãƒ‹ãƒ¥ãƒ¼ãƒœã‚¿ãƒ³ã®ãƒ‡ãƒ¢ã§ã™ã€‚\"Below\"ã®ãƒœã‚¿ãƒ³ã¯\
+下ã«ãƒ¡ãƒ‹ãƒ¥ãƒ¼ã‚’出ã—ã€\"Right\"ã®ãƒœã‚¿ãƒ³ã¯å³ã«ãƒ¡ãƒ‹ãƒ¥ãƒ¼ã‚’出ã—ã¦ã€\
+……ã¨ãªã‚Šã¾ã™ã€‚ã“ã®æ–‡ç« ã®ä¸‹ã«ã¯2ã¤ã®ã‚ªãƒ—ションメニューãŒã‚ã‚Šã¾ã™ã€‚\
+1ã¤ã¯æ™®é€šã®ãƒ¡ãƒ‹ãƒ¥ãƒ¼ã§ã€ã‚‚ã†1ã¤ã¯16色ã®ãƒ‘レットã§ã™ã€‚"
+}
+msg.pack('side'=>'top', 'padx'=>25, 'pady'=>25)
+
+TkFrame.new(center) {|f|
+ menubuttonoptions = TkVariable.new
+ mbutton = TkMenubutton.new(f)
+ options = optionMenu(mbutton, menubuttonoptions,
+ 'one', 'two', 'three')
+ mbutton.pack('side'=>'left', 'padx'=>25, 'pady'=>25)
+ paletteColor = TkVariable.new
+ colors = ['Black','red4','DarkGreen','NavyBlue', 'gray75',
+ 'Red','Green','Blue','gray50','Yellow','Cyan','Magenta',
+ 'White','Brown','DarkSeaGreen','DarkViolet']
+ colorMenuButton = TkMenubutton.new(f)
+ m = optionMenu(colorMenuButton, paletteColor, *colors)
+ begin
+ windowingsystem = Tk.windowingsystem()
+ rescue
+ windowingsystem = ""
+ end
+ if windowingsystem == "classic" || windowingsystem == "aqua"
+ topBorderColor = 'Black'
+ bottomBorderColor = 'Black'
+ else
+ topBorderColor = 'gray50'
+ bottomBorderColor = 'gray75'
+ end
+ for i in 0..15
+ image = TkPhotoImage.new('height'=>16, 'width'=>16)
+ image.put(topBorderColor, 0, 0, 16, 1)
+ image.put(topBorderColor, 0, 1, 1, 16)
+ image.put(bottomBorderColor, 0, 15, 16, 16)
+ image.put(bottomBorderColor, 15, 1, 16, 16)
+ image.put(colors[i], 1, 1, 15, 15)
+
+ selectimage = TkPhotoImage.new('height'=>16, 'width'=>16)
+ selectimage.put('Black', 0, 0, 16, 2)
+ selectimage.put('Black', 0, 2, 2, 16)
+ selectimage.put('Black', 2, 14, 16, 16)
+ selectimage.put('Black', 14, 2, 16, 14)
+ selectimage.put(colors[i], 2, 2, 14, 14)
+
+ m.entryconfigure(i, 'image'=>image, 'selectimage'=>selectimage, 'hidemargin'=>'on')
+ end
+ m.configure('tearoff', 'on')
+ for c in ['Black', 'gray75', 'gray50', 'White']
+ m.entryconfigure(c, 'columnbreak'=>1)
+ end
+ colorMenuButton.pack('side'=>'left', 'padx'=>25, 'pady'=>25)
+ pack 'padx'=>25, 'pady'=>25
+}
+
+end ; # Tk8.x
diff --git a/jni/ruby/ext/tk/sample/demos-jp/msgbox.rb b/jni/ruby/ext/tk/sample/demos-jp/msgbox.rb
new file mode 100644
index 0000000..ec7b4f2
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/demos-jp/msgbox.rb
@@ -0,0 +1,89 @@
+# -*- coding: utf-8 -*-
+#
+# message boxes widget demo (called by 'widget')
+#
+
+# toplevel widget ãŒå­˜åœ¨ã™ã‚Œã°å‰Šé™¤ã™ã‚‹
+if defined?($msgbox_demo) && $msgbox_demo
+ $msgbox_demo.destroy
+ $msgbox_demo = nil
+end
+
+# demo 用㮠toplevel widget を生æˆ
+$msgbox_demo = TkToplevel.new {|w|
+ title("Message Box Demonstration")
+ iconname("messagebox")
+ positionWindow(w)
+}
+
+base_frame = TkFrame.new($msgbox_demo).pack(:fill=>:both, :expand=>true)
+
+# label 生æˆ
+TkLabel.new(base_frame, 'font'=>$font, 'wraplength'=>'4i', 'justify'=>'left',
+ 'text'=>"ã¾ãšè¡¨ç¤ºã™ã‚‹ã‚¢ã‚¤ã‚³ãƒ³ã¨ãƒ¡ãƒƒã‚»ãƒ¼ã‚¸ãƒœãƒƒã‚¯ã‚¹ã®ç¨®é¡žã‚’é¸ã‚“ã§ä¸‹ã•ã„。ãã®å¾Œã«\"メッセージボックス\"ボタンを押ã™ã¨ã€æŒ‡å®šã—ãŸãƒ¡ãƒƒã‚»ãƒ¼ã‚¸ãƒœãƒƒã‚¯ã‚¹ãŒè¡¨ç¤ºã•ã‚Œã¾ã™ã€‚").pack('side'=>'top')
+
+# frame 生æˆ
+TkFrame.new(base_frame) {|frame|
+ TkButton.new(frame) {
+ #text '了解'
+ text 'é–‰ã˜ã‚‹'
+ command proc{
+ tmppath = $msgbox_demo
+ $msgbox_demo = nil
+ tmppath.destroy
+ }
+ }.pack('side'=>'left', 'expand'=>'yes')
+
+ TkButton.new(frame) {
+ text 'コードå‚ç…§'
+ command proc{showCode 'msgbox'}
+ }.pack('side'=>'left', 'expand'=>'yes')
+
+ TkButton.new(frame) {
+ text 'メッセージボックス'
+ command proc{showMessageBox $msgbox_demo}
+ }.pack('side'=>'left', 'expand'=>'yes')
+}.pack('side'=>'bottom', 'fill'=>'x', 'pady'=>'2m')
+
+# frame 生æˆ
+$msgbox_leftframe = TkFrame.new(base_frame)
+$msgbox_rightframe = TkFrame.new(base_frame)
+$msgbox_leftframe .pack('side'=>'left', 'expand'=>'yes', 'fill'=>'y',
+ 'pady'=>'.5c', 'padx'=>'.5c')
+$msgbox_rightframe.pack('side'=>'left', 'expand'=>'yes', 'fill'=>'y',
+ 'pady'=>'.5c', 'padx'=>'.5c')
+
+TkLabel.new($msgbox_leftframe, 'text'=>'アイコン').pack('side'=>'top')
+TkFrame.new($msgbox_leftframe, 'relief'=>'ridge', 'bd'=>1, 'height'=>2)\
+.pack('side'=>'top', 'fill'=>'x', 'expand'=>'no')
+
+$msgboxIcon = TkVariable.new('info')
+['error', 'info', 'question', 'warning'].each {|icon|
+ TkRadioButton.new($msgbox_leftframe, 'text'=>icon, 'variable'=>$msgboxIcon,
+ 'relief'=>'flat', 'value'=>icon, 'width'=>16,
+ 'anchor'=>'w').pack('side'=>'top', 'pady'=>2,
+ 'anchor'=>'w', 'fill'=>'x')
+}
+
+TkLabel.new($msgbox_rightframe, 'text'=>'種類').pack('side'=>'top')
+TkFrame.new($msgbox_rightframe, 'relief'=>'ridge', 'bd'=>1, 'height'=>2)\
+.pack('side'=>'top', 'fill'=>'x', 'expand'=>'no')
+
+$msgboxType = TkVariable.new('ok')
+['abortretryignore', 'ok', 'okcancel',
+ 'retrycancel', 'yesno', 'yesnocancel'].each {|type|
+ TkRadioButton.new($msgbox_rightframe, 'text'=>type, 'variable'=>$msgboxType,
+ 'relief'=>'flat', 'value'=>type, 'width'=>16,
+ 'anchor'=>'w').pack('side'=>'top', 'pady'=>2,
+ 'anchor'=>'w', 'fill'=>'x')
+}
+
+def showMessageBox(w)
+ button = Tk.messageBox('icon'=>$msgboxIcon.value, 'type'=>$msgboxType.value,
+ 'title'=>'Message', 'parent'=>w,
+ 'message'=>"ã“ã‚Œã¯\"#{$msgboxType.value}\"ã¨ã„ã†ç¨®é¡žã®ãƒ¡ãƒƒã‚»ãƒ¼ã‚¸ãƒœãƒƒã‚¯ã‚¹ã§ã€\"#{$msgboxIcon.value}\"ã®ã‚¢ã‚¤ã‚³ãƒ³ãŒè¡¨ç¤ºã•ã‚Œã¦ã„ã¾ã™ã€‚")
+
+ Tk.messageBox('icon'=>'info', 'type'=>'ok', 'parent'=>w,
+ 'message'=>"ã‚ãªãŸã¯ \"#{button}\" を押ã—ã¾ã—ãŸã­ã€‚")
+end
+
diff --git a/jni/ruby/ext/tk/sample/demos-jp/msgbox2.rb b/jni/ruby/ext/tk/sample/demos-jp/msgbox2.rb
new file mode 100644
index 0000000..ad6d936
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/demos-jp/msgbox2.rb
@@ -0,0 +1,90 @@
+# -*- coding: utf-8 -*-
+#
+# message boxes widget demo (called by 'widget')
+#
+
+# toplevel widget ãŒå­˜åœ¨ã™ã‚Œã°å‰Šé™¤ã™ã‚‹
+if defined?($msgbox2_demo) && $msgbox2_demo
+ $msgbox2_demo.destroy
+ $msgbox2_demo = nil
+end
+
+# demo 用㮠toplevel widget を生æˆ
+$msgbox2_demo = TkToplevel.new {|w|
+ title("Message Box Demonstration")
+ iconname("messagebox")
+ positionWindow(w)
+}
+
+base_frame = TkFrame.new($msgbox2_demo).pack(:fill=>:both, :expand=>true)
+
+# label 生æˆ
+TkLabel.new(base_frame, 'font'=>$font, 'wraplength'=>'4i', 'justify'=>'left',
+ 'text'=>"ã¾ãšè¡¨ç¤ºã™ã‚‹ã‚¢ã‚¤ã‚³ãƒ³ã¨ãƒ¡ãƒƒã‚»ãƒ¼ã‚¸ãƒœãƒƒã‚¯ã‚¹ã®ç¨®é¡žã‚’é¸ã‚“ã§ä¸‹ã•ã„。ãã®å¾Œã«\"メッセージボックス\"ボタンを押ã™ã¨ã€æŒ‡å®šã•ã‚ŒãŸå½¢å¼ã§ã€ãƒ¡ãƒƒã‚»ãƒ¼ã‚¸ã¨è©³ç´°ãƒ†ã‚­ã‚¹ãƒˆã¨ã‚’æŒã£ãŸãƒ¡ãƒƒã‚»ãƒ¼ã‚¸ãƒœãƒƒã‚¯ã‚¹ãŒè¡¨ç¤ºã•ã‚Œã¾ã™ã€‚").pack('side'=>'top')
+
+# frame 生æˆ
+TkFrame.new(base_frame) {|frame|
+ TkButton.new(frame) {
+ #text '了解'
+ text 'é–‰ã˜ã‚‹'
+ command proc{
+ tmppath = $msgbox2_demo
+ $msgbox2_demo = nil
+ tmppath.destroy
+ }
+ }.pack('side'=>'left', 'expand'=>'yes')
+
+ TkButton.new(frame) {
+ text 'コードå‚ç…§'
+ command proc{showCode 'msgbox2'}
+ }.pack('side'=>'left', 'expand'=>'yes')
+
+ TkButton.new(frame) {
+ text 'メッセージボックス'
+ command proc{showMessageBox2 $msgbox2_demo}
+ }.pack('side'=>'left', 'expand'=>'yes')
+}.pack('side'=>'bottom', 'fill'=>'x', 'pady'=>'2m')
+
+# frame 生æˆ
+$msgbox_leftframe = TkFrame.new(base_frame)
+$msgbox_rightframe = TkFrame.new(base_frame)
+$msgbox_leftframe .pack('side'=>'left', 'expand'=>'yes', 'fill'=>'y',
+ 'pady'=>'.5c', 'padx'=>'.5c')
+$msgbox_rightframe.pack('side'=>'left', 'expand'=>'yes', 'fill'=>'y',
+ 'pady'=>'.5c', 'padx'=>'.5c')
+
+TkLabel.new($msgbox_leftframe, 'text'=>'アイコン').pack('side'=>'top')
+TkFrame.new($msgbox_leftframe, 'relief'=>'ridge', 'bd'=>1, 'height'=>2)\
+.pack('side'=>'top', 'fill'=>'x', 'expand'=>'no')
+
+$msgboxIcon = TkVariable.new('info')
+['error', 'info', 'question', 'warning'].each {|icon|
+ TkRadioButton.new($msgbox_leftframe, 'text'=>icon, 'variable'=>$msgboxIcon,
+ 'relief'=>'flat', 'value'=>icon, 'width'=>16,
+ 'anchor'=>'w').pack('side'=>'top', 'pady'=>2,
+ 'anchor'=>'w', 'fill'=>'x')
+}
+
+TkLabel.new($msgbox_rightframe, 'text'=>'種類').pack('side'=>'top')
+TkFrame.new($msgbox_rightframe, 'relief'=>'ridge', 'bd'=>1, 'height'=>2)\
+.pack('side'=>'top', 'fill'=>'x', 'expand'=>'no')
+
+$msgboxType = TkVariable.new('ok')
+['abortretryignore', 'ok', 'okcancel',
+ 'retrycancel', 'yesno', 'yesnocancel'].each {|type|
+ TkRadioButton.new($msgbox_rightframe, 'text'=>type, 'variable'=>$msgboxType,
+ 'relief'=>'flat', 'value'=>type, 'width'=>16,
+ 'anchor'=>'w').pack('side'=>'top', 'pady'=>2,
+ 'anchor'=>'w', 'fill'=>'x')
+}
+
+def showMessageBox2(w)
+ button = Tk.messageBox('icon'=>$msgboxIcon.value, 'type'=>$msgboxType.value,
+ 'title'=>'Message', 'parent'=>w,
+ 'message'=>"\"#{$msgboxType.value}\"タイプã®ãƒ¡ãƒƒã‚»ãƒ¼ã‚¸ãƒœãƒƒã‚¯ã‚¹",
+ 'detail'=>"ã“ã‚Œã¯\"#{$msgboxType.value}\"ã¨ã„ã†ç¨®é¡žã®ãƒ¡ãƒƒã‚»ãƒ¼ã‚¸ãƒœãƒƒã‚¯ã‚¹ã§ã€\"#{$msgboxIcon.value}\"ã®ã‚¢ã‚¤ã‚³ãƒ³ãŒè¡¨ç¤ºã•ã‚Œã¦ã„ã¾ã™ã€‚下ã®ãƒœã‚¿ãƒ³ã®ã„ãšã‚Œã‹ã‚’é¸æŠžã—ã¦ã‚¯ãƒªãƒƒã‚¯ã—ã¦ãã ã•ã„。")
+
+ Tk.messageBox('icon'=>'info', 'type'=>'ok', 'parent'=>w,
+ 'message'=>"ã‚ãªãŸã¯ \"#{button}\" を押ã—ã¾ã—ãŸã­ã€‚")
+end
+
diff --git a/jni/ruby/ext/tk/sample/demos-jp/paned1.rb b/jni/ruby/ext/tk/sample/demos-jp/paned1.rb
new file mode 100644
index 0000000..53d2e71
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/demos-jp/paned1.rb
@@ -0,0 +1,52 @@
+# -*- coding: utf-8 -*-
+#
+# paned1.rb
+#
+# This demonstration script creates a toplevel window containing
+# a paned window that separates two windows horizontally.
+#
+# based on "Id: paned1.tcl,v 1.1 2002/02/22 14:07:01 dkf Exp"
+
+if defined?($paned1_demo) && $paned1_demo
+ $paned1_demo.destroy
+ $paned1_demo = nil
+end
+
+$paned1_demo = TkToplevel.new {|w|
+ title("Horizontal Paned Window Demonstration")
+ iconname("paned1")
+ positionWindow(w)
+}
+
+base_frame = TkFrame.new($paned1_demo).pack(:fill=>:both, :expand=>true)
+
+TkLabel.new(base_frame,
+ :font=>$font, :wraplength=>'4i', :justify=>:left,
+ :text=><<EOL).pack(:side=>:top)
+下ã®è‰²ä»˜ã‘ã•ã‚ŒãŸäºŒã¤ã®ã‚¦ã‚£ãƒ³ãƒ‰ã‚¦ã®é–“ã®ä»•åˆ‡ã‚Šæž ã¯ã€ä¸€ã¤ã®é ˜åŸŸã‚’ãã‚Œãžã‚Œã®ã‚¦ã‚£ãƒ³ãƒ‰ã‚¦ã®ãŸã‚ã«åˆ†å‰²ã™ã‚‹ãŸã‚ã®ã‚‚ã®ã§ã™ã€‚左ボタンã§ä»•åˆ‡ã‚Šã‚’æ“作ã™ã‚‹ã¨ã€åˆ†å‰²ã‚µã‚¤ã‚ºå¤‰æ›´ã®æ“作途中ã§ã¯å†è¡¨ç¤ºã¯ãªã•ã‚Œãšã€ç¢ºå®šã•ã›ãŸã¨ãã«è¡¨ç¤ºãŒæ›´æ–°ã•ã‚Œã¾ã™ã€‚マウスã«ã‚ˆã‚‹ä»•åˆ‡ã‚Šã®æ“作ã«è¿½éšã—ã¦ã‚µã‚¤ã‚ºã‚’変更ã—ãŸè¡¨ç¤ºãŒãªã‚れるよã†ã«ã—ãŸã„å ´åˆã¯ã€ãƒžã‚¦ã‚¹ã®ä¸­å¤®ãƒœã‚¿ãƒ³ã‚’使ã£ã¦ãã ã•ã„。
+ã‚‚ã—ã‚ãªãŸãŒä½¿ã£ã¦ã„ã‚‹ Ruby ã«ãƒªãƒ³ã‚¯ã•ã‚Œã¦ã„ã‚‹ Tk ライブラリ㌠panedwindow を実装ã—ã¦ã„ãªã„
+å ´åˆã€ã“ã®ãƒ‡ãƒ¢ã¯ã†ã¾ãå‹•ã‹ãªã„ã¯ãšã§ã™ã€‚ãã®å ´åˆã«ã¯ panedwindow ãŒå®Ÿè£…ã•ã‚Œã¦ã„るよã†ãª
+より新ã—ã„ãƒãƒ¼ã‚¸ãƒ§ãƒ³ã® Tk を組ã¿åˆã‚ã›ã¦è©¦ã™
+よã†ã«ã—ã¦ãã ã•ã„。
+EOL
+
+# The bottom buttons
+TkFrame.new(base_frame){|f|
+ pack(:side=>:bottom, :fill=>:x, :pady=>'2m')
+
+ TkButton.new(f, :text=>'é–‰ã˜ã‚‹', :width=>15, :command=>proc{
+ $paned1_demo.destroy
+ $paned1_demo = nil
+ }).pack(:side=>:left, :expand=>true)
+
+ TkButton.new(f, :text=>'コードå‚ç…§', :width=>15, :command=>proc{
+ showCode 'paned1'
+ }).pack(:side=>:left, :expand=>true)
+}
+
+TkPanedwindow.new(base_frame, :orient=>:horizontal){|f|
+ add(Tk::Label.new(f, :text=>"This is the\nleft side", :bg=>'yellow'),
+ Tk::Label.new(f, :text=>"This is the\nright side", :bg=>'cyan'))
+
+ pack(:side=>:top, :expand=>true, :fill=>:both, :pady=>2, :padx=>'2m')
+}
diff --git a/jni/ruby/ext/tk/sample/demos-jp/paned2.rb b/jni/ruby/ext/tk/sample/demos-jp/paned2.rb
new file mode 100644
index 0000000..65bd41c
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/demos-jp/paned2.rb
@@ -0,0 +1,100 @@
+# -*- coding: utf-8 -*-
+#
+# paned2.rb --
+#
+# This demonstration script creates a toplevel window containing
+# a paned window that separates two windows vertically.
+#
+# based on "Id: paned2.tcl,v 1.1 2002/02/22 14:07:01 dkf Exp"
+
+if defined?($paned2_demo) && $paned2_demo
+ $paned2_demo.destroy
+ $paned2_demo = nil
+end
+
+$paned2_demo = TkToplevel.new {|w|
+ title("Vertical Paned Window Demonstration")
+ iconname("paned2")
+ positionWindow(w)
+}
+
+base_frame = TkFrame.new($paned2_demo).pack(:fill=>:both, :expand=>true)
+
+TkLabel.new(base_frame,
+ :font=>$font, :wraplength=>'4i', :justify=>:left,
+ :text=><<EOL).pack(:side=>:top)
+下ã®ã‚¹ã‚¯ãƒ­ãƒ¼ãƒ«ãƒãƒ¼ä»˜ãã®ã‚¦ã‚£ã‚¸ã‚§ãƒƒãƒˆãŒç½®ã‹ã‚ŒãŸäºŒã¤ã®ã‚¦ã‚£ãƒ³ãƒ‰ã‚¦ã®é–“ã®ä»•åˆ‡ã‚Šæž ã¯ã€ä¸€ã¤ã®é ˜åŸŸã‚’ãã‚Œãžã‚Œã®ã‚¦ã‚£ãƒ³ãƒ‰ã‚¦ã®ãŸã‚ã«åˆ†å‰²ã™ã‚‹ãŸã‚ã®ã‚‚ã®ã§ã™ã€‚左ボタンã§ä»•åˆ‡ã‚Šã‚’æ“作ã™ã‚‹ã¨ã€åˆ†å‰²ã‚µã‚¤ã‚ºå¤‰æ›´ã®æ“作途中ã§ã¯å†è¡¨ç¤ºã¯ãªã•ã‚Œãšã€ç¢ºå®šã•ã›ãŸã¨ãã«è¡¨ç¤ºãŒæ›´æ–°ã•ã‚Œã¾ã™ã€‚マウスã«ã‚ˆã‚‹ä»•åˆ‡ã‚Šã®æ“作ã«è¿½éšã—ã¦ã‚µã‚¤ã‚ºã‚’変更ã—ãŸè¡¨ç¤ºãŒãªã‚れるよã†ã«ã—ãŸã„å ´åˆã¯ã€ãƒžã‚¦ã‚¹ã®ä¸­å¤®ãƒœã‚¿ãƒ³ã‚’使ã£ã¦ãã ã•ã„。
+ã‚‚ã—ã‚ãªãŸãŒä½¿ã£ã¦ã„ã‚‹ Ruby ã«ãƒªãƒ³ã‚¯ã•ã‚Œã¦ã„ã‚‹ Tk ライブラリ㌠panedwindow を実装ã—ã¦ã„ãªã„
+å ´åˆã€ã“ã®ãƒ‡ãƒ¢ã¯ã†ã¾ãå‹•ã‹ãªã„ã¯ãšã§ã™ã€‚ãã®å ´åˆã«ã¯ panedwindow ãŒå®Ÿè£…ã•ã‚Œã¦ã„るよã†ãª
+より新ã—ã„ãƒãƒ¼ã‚¸ãƒ§ãƒ³ã® Tk を組ã¿åˆã‚ã›ã¦è©¦ã™
+よã†ã«ã—ã¦ãã ã•ã„。
+EOL
+
+# The bottom buttons
+TkFrame.new(base_frame){|f|
+ pack(:side=>:bottom, :fill=>:x, :pady=>'2m')
+
+ TkButton.new(f, :text=>'é–‰ã˜ã‚‹', :width=>15, :command=>proc{
+ $paned2_demo.destroy
+ $paned2_demo = nil
+ }).pack(:side=>:left, :expand=>true)
+
+ TkButton.new(f, :text=>'コードå‚ç…§', :width=>15, :command=>proc{
+ showCode 'paned2'
+ }).pack(:side=>:left, :expand=>true)
+}
+
+paneList = TkVariable.new # define as normal variable (not array)
+paneList.value = [ # ruby's array --> tcl's list
+ 'Ruby/Tk ã®ã‚¦ã‚£ã‚¸ã‚§ãƒƒãƒˆä¸€è¦§',
+ 'TkButton',
+ 'TkCanvas',
+ 'TkCheckbutton',
+ 'TkEntry',
+ 'TkFrame',
+ 'TkLabel',
+ 'TkLabelframe',
+ 'TkListbox',
+ 'TkMenu',
+ 'TkMenubutton',
+ 'TkMessage',
+ 'TkPanedwindow',
+ 'TkRadiobutton',
+ 'TkScale',
+ 'TkScrollbar',
+ 'TkSpinbox',
+ 'TkText',
+ 'TkToplevel'
+]
+
+# Create the pane itself
+TkPanedwindow.new(base_frame, :orient=>:vertical){|f|
+ pack(:side=>:top, :expand=>true, :fill=>:both, :pady=>2, :padx=>'2m')
+
+ add(TkFrame.new(f){|paned2_top|
+ TkListbox.new(paned2_top, :listvariable=>paneList) {
+ # Invert the first item to highlight it
+ itemconfigure(0, :background=>self.cget(:foreground),
+ :foreground=>self.cget(:background) )
+ yscrollbar(TkScrollbar.new(paned2_top).pack(:side=>:right,
+ :fill=>:y))
+ pack(:fill=>:both, :expand=>true)
+ }
+ },
+
+ TkFrame.new(f, :height=>120) {|paned2_bottom|
+ # The bottom window is a text widget with scrollbar
+ paned2_xscr = TkScrollbar.new(paned2_bottom)
+ paned2_yscr = TkScrollbar.new(paned2_bottom)
+ paned2_text = TkText.new(paned2_bottom, :width=>30, :wrap=>:non) {
+ insert('1.0', 'ã“ã“ã«é…ç½®ã•ã‚Œã¦ã„ã‚‹ã®ã¯ã€' +
+ 'ã”ã普通ã®ãƒ†ã‚­ã‚¹ãƒˆã‚¦ã‚£ã‚¸ã‚§ãƒƒãƒˆã§ã™ã€‚')
+ xscrollbar(paned2_xscr)
+ yscrollbar(paned2_yscr)
+ }
+ Tk.grid(paned2_text, paned2_yscr, :sticky=>'nsew')
+ Tk.grid(paned2_xscr, :sticky=>'nsew')
+ TkGrid.columnconfigure(paned2_bottom, 0, :weight=>1)
+ TkGrid.rowconfigure(paned2_bottom, 0, :weight=>1)
+ } )
+}
diff --git a/jni/ruby/ext/tk/sample/demos-jp/pendulum.rb b/jni/ruby/ext/tk/sample/demos-jp/pendulum.rb
new file mode 100644
index 0000000..60556fd
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/demos-jp/pendulum.rb
@@ -0,0 +1,242 @@
+# -*- coding: utf-8 -*-
+#
+# This demonstration illustrates how Tcl/Tk can be used to construct
+# simulations of physical systems.
+# (called by 'widget')
+#
+# based on Tcl/Tk8.5a2 widget demos
+
+# destroy toplevel widget for this demo script
+if defined?($pendulum_demo) && $pendulum_demo
+ $pendulum_demo.destroy
+ $pendulum_demo = nil
+end
+
+# create toplevel widget
+$pendulum_demo = TkToplevel.new {|w|
+ title("Pendulum Animation Demonstration")
+ iconname("pendulum")
+ positionWindow(w)
+}
+
+base_frame = TkFrame.new($pendulum_demo).pack(:fill=>:both, :expand=>true)
+
+# create label
+msg = TkLabel.new(base_frame) {
+ font $font
+ wraplength '4i'
+ justify 'left'
+ text 'ã“ã®ãƒ‡ãƒ¢ã¯ã€ç‰©ç†ç³»ã®ã‚·ãƒŸãƒ¥ãƒ¬ãƒ¼ã‚·ãƒ§ãƒ³ã«é–¢ã‚るよã†ãªã‚¢ãƒ‹ãƒ¡ãƒ¼ã‚·ãƒ§ãƒ³å®Ÿè¡Œã™ã‚‹ãŸã‚ã« Ruby/Tk ã‚’ã©ã®ã‚ˆã†ã«ç”¨ã„ã‚‹ã“ã¨ãŒã§ãã‚‹ã‹ã‚’示ã—ã¦ã„ã¾ã™ã€‚å·¦å´ã®ã‚­ãƒ£ãƒ³ãƒã‚¹ã¯å˜ç´”ãªæŒ¯ã‚Šå­ã§ã‚る物ç†ç³»è‡ªä½“ã®ã‚°ãƒ©ãƒ•ã‚£ã‚«ãƒ«è¡¨ç¾ã§ã‚ã‚‹ã®ã«å¯¾ã—ã€å³å´ã®ã‚­ãƒ£ãƒ³ãƒã‚¹ã¯ç³»ã®ä½ç›¸ç©ºé–“ã®ã‚°ãƒ©ãƒ•ï¼ˆè§’速度ã¨è§’度ã¨ã‚’プロットã—ãŸã‚‚ã®ï¼‰ã«ãªã£ã¦ã„ã¾ã™ã€‚å·¦å´ã®ã‚­ãƒ£ãƒ³ãƒã‚¹ä¸Šã§ã‚¯ãƒªãƒƒã‚¯ãŠã‚ˆã³ãƒ‰ãƒ©ãƒƒã‚°ã‚’è¡Œã£ã¦æŒ¯ã‚Šå­ã®é‡ã‚Šã®ä½ç½®ã‚’変ãˆã¦ã¿ã¦ãã ã•ã„。'
+}
+msg.pack('side'=>'top')
+
+# create frame
+TkFrame.new(base_frame) {|frame|
+ TkButton.new(frame) {
+ #text '了解'
+ text 'é–‰ã˜ã‚‹'
+ command proc{
+ tmppath = $pendulum_demo
+ $pendulum_demo = nil
+ tmppath.destroy
+ }
+ }.pack('side'=>'left', 'expand'=>'yes')
+
+ TkButton.new(frame) {
+ text 'コードå‚ç…§'
+ command proc{showCode 'pendulum'}
+ }.pack('side'=>'left', 'expand'=>'yes')
+
+}.pack('side'=>'bottom', 'fill'=>'x', 'pady'=>'2m')
+
+# animated wave
+class PendulumAnimationDemo
+ def initialize(frame)
+ # Create some structural widgets
+ @pane = TkPanedWindow.new(frame, :orient=>:horizontal).pack(:fill=>:both, :expand=>true)
+# @pane.add(@lf1 = TkLabelFrame.new(@pane, :text=>'Pendulum Simulation'))
+# @pane.add(@lf2 = TkLabelFrame.new(@pane, :text=>'Phase Space'))
+ @lf1 = TkLabelFrame.new(@pane, :text=>'Pendulum Simulation')
+ @lf2 = TkLabelFrame.new(@pane, :text=>'Phase Space')
+
+ # Create the canvas containing the graphical representation of the
+ # simulated system.
+ @c = TkCanvas.new(@lf1, :width=>320, :height=>200, :background=>'white',
+ :borderwidth=>2, :relief=>:sunken)
+ TkcText.new(@c, 5, 5, :anchor=>:nw,
+ :text=>'Click to Adjust Bob Start Position')
+ # Coordinates of these items don't matter; they will be set properly below
+ @plate = TkcLine.new(@c, 0, 25, 320, 25, :width=>2, :fill=>'grey50')
+ @rod = TkcLine.new(@c, 1, 1, 1, 1, :width=>3, :fill=>'black')
+ @bob = TkcOval.new(@c, 1, 1, 2, 2,
+ :width=>3, :fill=>'yellow', :outline=>'black')
+ TkcOval.new(@c, 155, 20, 165, 30, :fill=>'grey50', :outline=>'')
+
+ # pack
+ @c.pack(:fill=>:both, :expand=>true)
+
+ # Create the canvas containing the phase space graph; this consists of
+ # a line that gets gradually paler as it ages, which is an extremely
+ # effective visual trick.
+ @k = TkCanvas.new(@lf2, :width=>320, :height=>200, :background=>'white',
+ :borderwidth=>2, :relief=>:sunken)
+ @y_axis = TkcLine.new(@k, 160, 200, 160, 0, :fill=>'grey75', :arrow=>:last)
+ @x_axis = TkcLine.new(@k, 0, 100, 320, 100, :fill=>'grey75', :arrow=>:last)
+
+ @graph = {}
+ 90.step(0, -10){|i|
+ # Coordinates of these items don't matter;
+ # they will be set properly below
+ @graph[i] = TkcLine.new(@k, 0, 0, 1, 1, :smooth=>true, :fill=>"grey#{i}")
+ }
+
+ # labels
+ @label_theta = TkcText.new(@k, 0, 0, :anchor=>:ne,
+ :text=>'q', :font=>'Symbol 8')
+ @label_dtheta = TkcText.new(@k, 0, 0, :anchor=>:ne,
+ :text=>'dq', :font=>'Symbol 8')
+
+ # pack
+ @k.pack(:fill=>:both, :expand=>true)
+
+ # Initialize some variables
+ @points = []
+ @theta = 45.0
+ @dTheta = 0.0
+ @length = 150
+
+ # animation loop
+ @timer = TkTimer.new(15){ repeat }
+
+ # binding
+ @c.bindtags_unshift(btag = TkBindTag.new)
+ btag.bind('Destroy'){ @timer.stop }
+ btag.bind('1', proc{|x, y| @timer.stop; showPendulum(x.to_i, y.to_i)},
+ '%x %y')
+ btag.bind('B1-Motion', proc{|x, y| showPendulum(x.to_i, y.to_i)}, '%x %y')
+ btag.bind('ButtonRelease-1',
+ proc{|x, y| showPendulum(x.to_i, y.to_i); @timer.start },
+ '%x %y')
+
+ btag.bind('Configure', proc{|w| @plate.coords(0, 25, w.to_i, 25)}, '%w')
+
+ @k.bind('Configure', proc{|h, w|
+ h = h.to_i
+ w = w.to_i
+ @psh = h/2;
+ @psw = w/2
+ @x_axis.coords(2, @psh, w-2, @psh)
+ @y_axis.coords(@psw, h-2, @psw, 2)
+ @label_theta.coords(@psw-4, 6)
+ @label_dtheta.coords(w-6, @psh+4)
+ }, '%h %w')
+
+ # add
+ Tk.update
+ @pane.add(@lf1)
+ @pane.add(@lf2)
+
+ # init display
+ showPendulum
+
+ # animation start
+ @timer.start(500)
+ end
+
+ # This procedure makes the pendulum appear at the correct place on the
+ # canvas. If the additional arguments x, y are passed instead of computing
+ # the position of the pendulum from the length of the pendulum rod and its
+ # angle, the length and angle are computed in reverse from the given
+ # location (which is taken to be the centre of the pendulum bob.)
+ def showPendulum(x=nil, y=nil)
+ if x && y && (x != 160 || y != 25)
+ @dTheta = 0.0
+ x2 = x - 160
+ y2 = y - 25
+ @length = Math.hypot(x2, y2)
+ @theta = Math.atan2(x2,y2)*180/Math::PI
+ else
+ angle = @theta*Math::PI/180
+ x = 160 + @length*Math.sin(angle)
+ y = 25 + @length*Math.cos(angle)
+ end
+
+ @rod.coords(160, 25, x, y)
+ @bob.coords(x-15, y-15, x+15, y+15)
+ end
+
+ # Update the phase-space graph according to the current angle and the
+ # rate at which the angle is changing (the first derivative with
+ # respect to time.)
+ def showPhase
+ unless @psw && @psh
+ @psw = @k.width/2
+ @psh = @k.height/2
+ end
+ @points << @theta + @psw << -20*@dTheta + @psh
+ if @points.length > 100
+ @points = @points[-100..-1]
+ end
+ (0...100).step(10){|i|
+ first = - i
+ last = 11 - i
+ last = -1 if last >= 0
+ next if first > last
+ lst = @points[first..last]
+ @graph[i].coords(lst) if lst && lst.length >= 4
+ }
+ end
+
+ # This procedure is the "business" part of the simulation that does
+ # simple numerical integration of the formula for a simple rotational
+ # pendulum.
+ def recomputeAngle
+ scaling = 3000.0/@length/@length
+
+ # To estimate the integration accurately, we really need to
+ # compute the end-point of our time-step. But to do *that*, we
+ # need to estimate the integration accurately! So we try this
+ # technique, which is inaccurate, but better than doing it in a
+ # single step. What we really want is bound up in the
+ # differential equation:
+ # .. - sin theta
+ # theta + theta = -----------
+ # length
+ # But my math skills are not good enough to solve this!
+
+ # first estimate
+ firstDDTheta = -Math.sin(@theta * Math::PI/180) * scaling
+ midDTheta = @dTheta + firstDDTheta
+ midTheta = @theta + (@dTheta + midDTheta)/2
+ # second estimate
+ midDDTheta = -Math.sin(midTheta * Math::PI/180) * scaling
+ midDTheta = @dTheta + (firstDDTheta + midDDTheta)/2
+ midTheta = @theta + (@dTheta + midDTheta)/2
+ # Now we do a double-estimate approach for getting the final value
+ # first estimate
+ midDDTheta = -Math.sin(midTheta * Math::PI/180) * scaling
+ lastDTheta = midDTheta + midDDTheta
+ lastTheta = midTheta + (midDTheta+ lastDTheta)/2
+ # second estimate
+ lastDDTheta = -Math.sin(lastTheta * Math::PI/180) * scaling
+ lastDTheta = midDTheta + (midDDTheta + lastDDTheta)/2
+ lastTheta = midTheta + (midDTheta + lastDTheta)/2
+ # Now put the values back in our globals
+ @dTheta = lastDTheta
+ @theta = lastTheta
+ end
+
+ # This method ties together the simulation engine and the graphical
+ # display code that visualizes it.
+ def repeat
+ # Simulate
+ recomputeAngle
+
+ # Update the display
+ showPendulum
+ showPhase
+ end
+end
+
+# Start the animation processing
+PendulumAnimationDemo.new(base_frame)
diff --git a/jni/ruby/ext/tk/sample/demos-jp/plot.rb b/jni/ruby/ext/tk/sample/demos-jp/plot.rb
new file mode 100644
index 0000000..4147b35
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/demos-jp/plot.rb
@@ -0,0 +1,126 @@
+# -*- coding: utf-8 -*-
+#
+# 2-D plot widget demo (called by 'widget')
+#
+
+# toplevel widget ãŒå­˜åœ¨ã™ã‚Œã°å‰Šé™¤ã™ã‚‹
+if defined?($plot_demo) && $plot_demo
+ $plot_demo.destroy
+ $plot_demo = nil
+end
+
+# demo 用㮠toplevel widget を生æˆ
+$plot_demo = TkToplevel.new {|w|
+ title("Plot Demonstration")
+ iconname("Plot")
+ positionWindow(w)
+}
+
+base_frame = TkFrame.new($plot_demo).pack(:fill=>:both, :expand=>true)
+
+# label 生æˆ
+TkLabel.new(base_frame, 'font'=>$font, 'wraplength'=>'4i', 'justify'=>'left',
+ 'text'=>"ã“ã®ã‚¦ã‚£ãƒ³ãƒ‰ã‚¦ã¯ç°¡å˜ãª2次元ã®ãƒ—ロットをå«ã‚“ã ã‚­ãƒ£ãƒ³ãƒã‚¹ widgetã§ã™ã€‚表示ã•ã‚ŒãŸç‚¹ã‚’マウスボタン1ã§ãƒ‰ãƒ©ãƒƒã‚°ã—ã¦ãƒ‡ãƒ¼ã‚¿ã‚’ã„ã˜ã‚‹ã“ã¨ãŒã§ãã¾ã™ã€‚"){
+ pack('side'=>'top')
+}
+
+# frame 生æˆ
+$plot_buttons = TkFrame.new(base_frame) {|frame|
+ TkButton.new(frame) {
+ #text '了解'
+ text 'é–‰ã˜ã‚‹'
+ command proc{
+ tmppath = $plot_demo
+ $plot_demo = nil
+ tmppath.destroy
+ }
+ }.pack('side'=>'left', 'expand'=>'yes')
+
+ TkButton.new(frame) {
+ text 'コードå‚ç…§'
+ command proc{showCode 'plot'}
+ }.pack('side'=>'left', 'expand'=>'yes')
+}
+$plot_buttons.pack('side'=>'bottom', 'fill'=>'x', 'pady'=>'2m')
+
+# font 設定
+ if $tk_version =~ /^4.*/
+ plotFont = '-*-Helvetica-Medium-R-Normal--*-180-*-*-*-*-*-*'
+ else
+ font = 'Helvetica 18'
+ end
+
+# canvas 設定
+$plot_canvas = TkCanvas.new(base_frame,'relief'=>'raised','width'=>450,'height'=>300)
+$plot_canvas.pack('side'=>'top', 'fill'=>'x')
+
+# plot 生æˆ
+TkcLine.new($plot_canvas, 100, 250, 400, 250, 'width'=>2)
+TkcLine.new($plot_canvas, 100, 250, 100, 50, 'width'=>2)
+TkcText.new($plot_canvas, 225, 20,
+ 'text'=>"ç°¡å˜ãªãƒ—ロット", 'font'=>plotFont, 'fill'=>'brown')
+
+(0..10).each {|i|
+ x = 100 + (i * 30)
+ TkcLine.new($plot_canvas, x, 250, x, 245, 'width'=>2)
+ TkcText.new($plot_canvas, x, 254,
+ 'text'=>10*i, 'font'=>plotFont, 'anchor'=>'n')
+}
+(0..5).each {|i|
+ y = 250 - (i * 40)
+ TkcLine.new($plot_canvas, 100, y, 105, y, 'width'=>2)
+ TkcText.new($plot_canvas, 96, y,
+ 'text'=>"#{i*50}.0", 'font'=>plotFont, 'anchor'=>'e')
+}
+
+for xx, yy in [[12,56],[20,94],[33,98],[32,120],[61,180],[75,160],[98,223]]
+ x = 100 + (3*xx)
+ y = 250 - (4*yy)/5
+ item = TkcOval.new($plot_canvas, x-6, y-6, x+6, y+6,
+ 'width'=>1, 'outline'=>'black', 'fill'=>'SkyBlue2')
+ item.addtag 'point'
+end
+
+$plot_canvas.itembind('point', 'Any-Enter',
+ proc{$plot_canvas.itemconfigure 'current','fill','red'})
+$plot_canvas.itembind('point', 'Any-Leave',
+ proc{$plot_canvas.itemconfigure 'current','fill','SkyBlue2'})
+$plot_canvas.itembind('point', '1',
+ proc{|x,y| plotDown $plot_canvas,x,y}, "%x %y")
+$plot_canvas.itembind('point', 'ButtonRelease-1',
+ proc{$plot_canvas.dtag 'selected'})
+$plot_canvas.bind('B1-Motion',
+ proc{|x,y| plotMove $plot_canvas,x,y}, "%x %y")
+
+$plot = {'lastX'=>0, 'lastY'=>0}
+
+# plotDown --
+# This method is invoked when the mouse is pressed over one of the
+# data points. It sets up state to allow the point to be dragged.
+#
+# Arguments:
+# w - The canvas window.
+# x, y - The coordinates of the mouse press.
+
+def plotDown (w, x, y)
+ w.dtag 'selected'
+ w.addtag_withtag 'selected', 'current'
+ w.raise 'current'
+ $plot['lastX'] = x
+ $plot['lastY'] = y
+end
+
+# plotMove --
+# This method is invoked during mouse motion events. It drags the
+# current item.
+#
+# Arguments:
+# w - The canvas window.
+# x, y - The coordinates of the mouse.
+
+def plotMove (w, x, y)
+ w.move 'selected', x - $plot['lastX'], y - $plot['lastY']
+ $plot['lastX'] = x
+ $plot['lastY'] = y
+end
+
diff --git a/jni/ruby/ext/tk/sample/demos-jp/puzzle.rb b/jni/ruby/ext/tk/sample/demos-jp/puzzle.rb
new file mode 100644
index 0000000..dbcb423
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/demos-jp/puzzle.rb
@@ -0,0 +1,131 @@
+# -*- coding: utf-8 -*-
+#
+# widet demo 'puzzle' (called by 'widget')
+#
+
+# toplevel widget ãŒå­˜åœ¨ã™ã‚Œã°å‰Šé™¤ã™ã‚‹
+if defined?($puzzle_demo) && $puzzle_demo
+ $puzzle_demo.destroy
+ $puzzle_demo = nil
+end
+
+# demo 用㮠toplevel widget を生æˆ
+$puzzle_demo = TkToplevel.new {|w|
+ title("15-Puzzle Demonstration")
+ iconname("15-Puzzle")
+ positionWindow(w)
+}
+
+base_frame = TkFrame.new($puzzle_demo).pack(:fill=>:both, :expand=>true)
+
+# label 生æˆ
+msg = TkLabel.new(base_frame) {
+ font $font
+ wraplength '4i'
+ justify 'left'
+ text "下ã®15-パズルã¯ãƒœã‚¿ãƒ³ã‚’集ã‚ã¦ã§ãã¦ã„ã¾ã™ã€‚空ã„ã¦ã„る所ã®éš£ã®ãƒ”ースをクリックã™ã‚‹ã¨ã€ãã®ãƒ”ースãŒãã®ç©ºã„ã¦ã„る場所ã«ã‚¹ãƒ©ã‚¤ãƒ‰ã—ã¾ã™ã€‚ã“ã®æ“作を続ã‘ã€ãƒ”ースãŒãã®æ•°ã®é †ã«ä¸Šã‹ã‚‰ä¸‹ã€å·¦ã‹ã‚‰å³ã«ä¸¦ã¶ã‚ˆã†ã«ã—ã¦ãã ã•ã„。"
+}
+msg.pack('side'=>'top')
+
+# frame 生æˆ
+TkFrame.new(base_frame) {|frame|
+ TkButton.new(frame) {
+ #text '了解'
+ text 'é–‰ã˜ã‚‹'
+ command proc{
+ tmppath = $puzzle_demo
+ $puzzle_demo = nil
+ tmppath.destroy
+ }
+ }.pack('side'=>'left', 'expand'=>'yes')
+
+ TkButton.new(frame) {
+ text 'コードå‚ç…§'
+ command proc{showCode 'puzzle'}
+ }.pack('side'=>'left', 'expand'=>'yes')
+
+}.pack('side'=>'bottom', 'fill'=>'x', 'pady'=>'2m')
+
+# frame 生æˆ
+#
+# Special trick: scrollbar widget を生æˆã—ã¦ãã® trough color を用ã„ã‚‹ã“ã¨ã§
+# 空白部分ã®ãŸã‚ã®æš—色をé¸æŠžã—,設定ã™ã‚‹
+#
+begin
+ if Tk.windowingsystem() == 'aqua'
+ frameWidth = 168
+ frameHeight = 168
+ elsif Tk.default_widget_set == :Ttk
+ frameWidth = 148
+ frameHeight = 124
+ else
+ frameWidth = 120
+ frameHeight = 120
+ end
+rescue
+ frameWidth = 120
+ frameHeight = 120
+end
+
+# depend_on_button_width = true
+depend_on_button_width = false
+
+s = TkScrollbar.new(base_frame)
+base = TkFrame.new(base_frame) {
+ width frameWidth
+ height frameHeight
+ borderwidth 2
+ relief 'sunken'
+ bg s['troughcolor']
+}
+s.destroy
+base.pack('side'=>'top', 'padx'=>'1c', 'pady'=>'1c')
+
+# proc ã®ã‚¹ã‚³ãƒ¼ãƒ—ã‚’é–‰ã˜ã‚‹ãŸã‚,proc 生æˆãƒ¡ã‚½ãƒƒãƒ‰ã‚’用æ„
+# ã“ã†ã—ã¦ãŠã‹ã­ã°ï¼Œãƒ«ãƒ¼ãƒ—中ã§å€¤ãŒå¤‰åŒ–ã™ã‚‹ num ã®å½±éŸ¿ã‚’å—ã‘ã¦
+# puzzleSwitch ã®ç¬¬ 2 引数ãŒå¤‰åŒ–ã—ã¦ã—ã¾ã„,期待通りã«ã¯ãªã‚‰ãªã„.
+def def_puzzleswitch_proc(w, num)
+ proc{puzzleSwitch w, num}
+end
+
+$xpos = {}
+$ypos = {}
+order = [3,1,6,2,5,7,15,13,4,11,8,9,14,10,12]
+(0..14).each{|i|
+ num = order[i]
+ $xpos[num] = (i % 4) * 0.25
+ $ypos[num] = (i / 4) * 0.25
+ TkButton.new(base) {|w|
+ relief 'raised'
+ text num
+ highlightthickness 0
+ command def_puzzleswitch_proc(w, num)
+ if depend_on_button_width && (w.winfo_reqwidth * 4 > base.width)
+ base.width = w.winfo_reqwidth * 4
+ end
+ }.place('relx'=>$xpos[num], 'rely'=>$ypos[num],
+ 'relwidth'=>0.25, 'relheight'=>0.25)
+}
+$xpos['space'] = 0.75
+$ypos['space'] = 0.75
+
+############
+def puzzleSwitch(w, num)
+ if ( ($ypos[num] >= ($ypos['space'] - 0.01)) \
+ && ($ypos[num] <= ($ypos['space'] + 0.01)) \
+ && ($xpos[num] >= ($xpos['space'] - 0.26)) \
+ && ($xpos[num] <= ($xpos['space'] + 0.26))) \
+ || (($xpos[num] >= ($xpos['space'] - 0.01)) \
+ && ($xpos[num] <= ($xpos['space'] + 0.01)) \
+ && ($ypos[num] >= ($ypos['space'] - 0.26)) \
+ && ($ypos[num] <= ($ypos['space'] + 0.26)))
+ tmp = $xpos['space']
+ $xpos['space'] = $xpos[num]
+ $xpos[num] = tmp
+ tmp = $ypos['space']
+ $ypos['space'] = $ypos[num]
+ $ypos[num] = tmp
+ w.place('relx'=>$xpos[num], 'rely'=>$ypos[num])
+ end
+end
+
diff --git a/jni/ruby/ext/tk/sample/demos-jp/radio.rb b/jni/ruby/ext/tk/sample/demos-jp/radio.rb
new file mode 100644
index 0000000..efb6135
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/demos-jp/radio.rb
@@ -0,0 +1,84 @@
+# -*- coding: utf-8 -*-
+#
+# radiobutton widget demo (called by 'widget')
+#
+
+# toplevel widget ãŒå­˜åœ¨ã™ã‚Œã°å‰Šé™¤ã™ã‚‹
+if defined?($radio_demo) && $radio_demo
+ $radio_demo.destroy
+ $radio_demo = nil
+end
+
+# demo 用㮠toplevel widget を生æˆ
+$radio_demo = TkToplevel.new {|w|
+ title("Radiobutton Demonstration")
+ iconname("radio")
+ positionWindow(w)
+}
+
+base_frame = TkFrame.new($radio_demo).pack(:fill=>:both, :expand=>true)
+
+# label 生æˆ
+msg = TkLabel.new(base_frame) {
+ font $font
+ wraplength '4i'
+ justify 'left'
+ text "下ã«ã¯2ã¤ã®ãƒ©ã‚¸ã‚ªãƒœã‚¿ãƒ³ã‚°ãƒ«ãƒ¼ãƒ—ãŒè¡¨ç¤ºã•ã‚Œã¦ã„ã¾ã™ã€‚ボタンをクリックã™ã‚‹ã¨ã€ãã®ãƒœã‚¿ãƒ³ã ã‘ãŒãã®ã‚°ãƒ«ãƒ¼ãƒ—ã®ä¸­ã§é¸æŠžã•ã‚Œã¾ã™ã€‚å„グループã«å¯¾ã—ã¦ãã®ã‚°ãƒ«ãƒ¼ãƒ—ã®ä¸­ã®ã©ã®ãƒœã‚¿ãƒ³ãŒé¸æŠžã•ã‚Œã¦ã„ã‚‹ã‹ã‚’示ã™å¤‰æ•°ãŒå‰²ã‚Šå½“ã¦ã‚‰ã‚Œã¦ã„ã¾ã™ã€‚ç¾åœ¨ã®å¤‰æ•°ã®å€¤ã‚’見るã«ã¯ã€Œå¤‰æ•°å‚ç…§ã€ãƒœã‚¿ãƒ³ã‚’クリックã—ã¦ãã ã•ã„。"
+}
+msg.pack('side'=>'top')
+
+# 変数生æˆ
+size = TkVariable.new
+color = TkVariable.new
+
+# frame 生æˆ
+TkFrame.new(base_frame) {|frame|
+ TkButton.new(frame) {
+ #text '了解'
+ text 'é–‰ã˜ã‚‹'
+ command proc{
+ tmppath = $radio_demo
+ $radio_demo = nil
+ $showVarsWin[tmppath.path] = nil
+ tmppath.destroy
+ }
+ }.pack('side'=>'left', 'expand'=>'yes')
+
+ TkButton.new(frame) {
+ text 'コードå‚ç…§'
+ command proc{showCode 'radio'}
+ }.pack('side'=>'left', 'expand'=>'yes')
+
+ TkButton.new(frame) {
+ text '変数å‚ç…§'
+ command proc{
+ showVars(base_frame, ['size', size], ['color', color])
+ }
+ }.pack('side'=>'left', 'expand'=>'yes')
+}.pack('side'=>'bottom', 'fill'=>'x', 'pady'=>'2m')
+
+# frame 生æˆ
+f_left = TkFrame.new(base_frame)
+f_right = TkFrame.new(base_frame)
+f_left.pack('side'=>'left', 'expand'=>'yes', 'padx'=>'.5c', 'pady'=>'.5c')
+f_right.pack('side'=>'left', 'expand'=>'yes', 'padx'=>'.5c', 'pady'=>'.5c')
+
+# radiobutton 生æˆ
+[10, 12, 18, 24].each {|sz|
+ TkRadioButton.new(f_left) {
+ text "ãƒã‚¤ãƒ³ãƒˆã‚µã‚¤ã‚º #{sz}"
+ variable size
+ relief 'flat'
+ value sz
+ }.pack('side'=>'top', 'pady'=>2, 'anchor'=>'w')
+}
+
+['赤', 'ç·‘', 'é’', '黄', 'æ©™', 'ç´«'].each {|col|
+ TkRadioButton.new(f_right) {
+ text col
+ variable color
+ relief 'flat'
+ value col.downcase
+ }.pack('side'=>'top', 'pady'=>2, 'anchor'=>'w')
+}
+
diff --git a/jni/ruby/ext/tk/sample/demos-jp/radio2.rb b/jni/ruby/ext/tk/sample/demos-jp/radio2.rb
new file mode 100644
index 0000000..0633a8d
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/demos-jp/radio2.rb
@@ -0,0 +1,112 @@
+# -*- coding: utf-8 -*-
+#
+# radio2.rb
+#
+# This demonstration script creates a toplevel window containing
+# several radiobutton widgets.
+#
+# radiobutton widget demo (called by 'widget')
+#
+
+# toplevel widget
+if defined?($radio2_demo) && $radio2_demo
+ $radio2_demo.destroy
+ $radio2_demo = nil
+end
+
+# demo toplevel widget
+$radio2_demo = TkToplevel.new {|w|
+ title("Radiobutton Demonstration 2")
+ iconname("radio2")
+ positionWindow(w)
+}
+
+base_frame = TkFrame.new($radio2_demo).pack(:fill=>:both, :expand=>true)
+
+# label
+msg = TkLabel.new(base_frame) {
+ font $font
+ wraplength '5i'
+ justify 'left'
+ text "下ã«ã¯3ã¤ã®ãƒ©ã‚¸ã‚ªãƒœã‚¿ãƒ³ã‚°ãƒ«ãƒ¼ãƒ—ãŒè¡¨ç¤ºã•ã‚Œã¦ã„ã¾ã™ã€‚ボタンをクリックã™ã‚‹ã¨ã€ãã®ãƒœã‚¿ãƒ³ã ã‘ãŒãã®ã‚°ãƒ«ãƒ¼ãƒ—ã®ä¸­ã§é¸æŠžã•ã‚Œã¾ã™ã€‚å„グループã«å¯¾ã—ã¦ãã®ã‚°ãƒ«ãƒ¼ãƒ—ã®ä¸­ã®ã©ã®ãƒœã‚¿ãƒ³ãŒé¸æŠžã•ã‚Œã¦ã„ã‚‹ã‹ã‚’示ã™å¤‰æ•°ãŒå‰²ã‚Šå½“ã¦ã‚‰ã‚Œã¦ã„ã¾ã™ã€‚ç¾åœ¨ã®å¤‰æ•°ã®å€¤ã‚’見るã«ã¯ã€Œå¤‰æ•°å‚ç…§ã€ãƒœã‚¿ãƒ³ã‚’クリックã—ã¦ãã ã•ã„。"
+}
+msg.pack('side'=>'top')
+
+#
+size = TkVariable.new
+color = TkVariable.new
+align = TkVariable.new
+
+# frame
+TkFrame.new(base_frame) {|frame|
+ TkButton.new(frame) {
+ #text '了解'
+ text 'é–‰ã˜ã‚‹'
+ command proc{
+ tmppath = $radio2_demo
+ $radio2_demo = nil
+ $showVarsWin[tmppath.path] = nil
+ tmppath.destroy
+ }
+ }.pack('side'=>'left', 'expand'=>'yes')
+
+ TkButton.new(frame) {
+ text 'コードå‚ç…§'
+ command proc{showCode 'radio2'}
+ }.pack('side'=>'left', 'expand'=>'yes')
+
+ TkButton.new(frame) {
+ text '変数å‚ç…§'
+ command proc{
+ showVars(base_frame,
+ ['size', size], ['color', color], ['compound', align])
+ }
+ }.pack('side'=>'left', 'expand'=>'yes')
+}.pack('side'=>'bottom', 'fill'=>'x', 'pady'=>'2m')
+
+# frame
+f_left = TkLabelFrame.new(base_frame, 'text'=>'文字サイズ',
+ 'pady'=>2, 'padx'=>2)
+f_mid = TkLabelFrame.new(base_frame, 'text'=>'色',
+ 'pady'=>2, 'padx'=>2)
+f_right = TkLabelFrame.new(base_frame, 'text'=>'ビットマップé…ç½®',
+ 'pady'=>2, 'padx'=>2)
+f_left.pack('side'=>'left', 'expand'=>'yes', 'padx'=>'.5c', 'pady'=>'.5c')
+f_mid.pack('side'=>'left', 'expand'=>'yes', 'padx'=>'.5c', 'pady'=>'.5c')
+f_right.pack('side'=>'left', 'expand'=>'yes', 'padx'=>'.5c', 'pady'=>'.5c')
+
+# radiobutton
+[10, 12, 18, 24].each {|sz|
+ TkRadioButton.new(f_left) {
+ text "ãƒã‚¤ãƒ³ãƒˆã‚µã‚¤ã‚º #{sz}"
+ variable size
+ relief 'flat'
+ value sz
+ }.pack('side'=>'top', 'pady'=>2, 'anchor'=>'w', 'fill'=>'x')
+}
+
+['赤', 'ç·‘', 'é’', '黄', 'æ©™', 'ç´«'].each {|col|
+ TkRadioButton.new(f_mid) {
+ text col
+ variable color
+ relief 'flat'
+ value col.downcase
+ anchor 'w'
+ }.pack('side'=>'top', 'pady'=>2, 'fill'=>'x')
+}
+
+# label = TkLabel.new(f_right, 'text'=>'ラベル', 'bitmap'=>'questhead',
+label = Tk::Label.new(f_right, 'text'=>'ラベル', 'bitmap'=>'questhead',
+ 'compound'=>'left')
+label.configure('width'=>TkWinfo.reqwidth(label), 'compound'=>'top')
+label.height(TkWinfo.reqheight(label))
+abtn = ['Top', 'Left', 'Right', 'Bottom'].collect{|a|
+ lower = a.downcase
+ TkRadioButton.new(f_right, 'text'=>a, 'variable'=>align, 'relief'=>'flat',
+ 'value'=>lower, 'indicatoron'=>0, 'width'=>7,
+ 'command'=>proc{label.compound(align.value)})
+}
+
+Tk.grid('x', abtn[0])
+Tk.grid(abtn[1], label, abtn[2])
+Tk.grid('x', abtn[3])
diff --git a/jni/ruby/ext/tk/sample/demos-jp/radio3.rb b/jni/ruby/ext/tk/sample/demos-jp/radio3.rb
new file mode 100644
index 0000000..3356b69
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/demos-jp/radio3.rb
@@ -0,0 +1,119 @@
+# -*- coding: utf-8 -*-
+#
+# radio3.rb
+#
+# This demonstration script creates a toplevel window containing
+# several radiobutton widgets.
+#
+# radiobutton widget demo (called by 'widget')
+#
+
+# toplevel widget
+if defined?($radio3_demo) && $radio3_demo
+ $radio3_demo.destroy
+ $radio3_demo = nil
+end
+
+# demo toplevel widget
+$radio3_demo = TkToplevel.new {|w|
+ title("Radiobutton Demonstration 3")
+ iconname("radio3")
+ positionWindow(w)
+}
+
+base_frame = TkFrame.new($radio3_demo).pack(:fill=>:both, :expand=>true)
+
+# label
+msg = TkLabel.new(base_frame) {
+ font $font
+ wraplength '5i'
+ justify 'left'
+ text '下ã«ã¯3ã¤ã®ãƒ©ã‚¸ã‚ªãƒœã‚¿ãƒ³ã‚°ãƒ«ãƒ¼ãƒ—ãŒè¡¨ç¤ºã•ã‚Œã¦ã„ã¾ã™ã€‚ボタンをクリックã™ã‚‹ã¨ã€ãã®ã‚°ãƒ«ãƒ¼ãƒ—ã«å±žã™ã‚‹ã™ã¹ã¦ã®ãƒœã‚¿ãƒ³ã®ä¸­ã§ã‚¯ãƒªãƒƒã‚¯ã—ãŸãƒœã‚¿ãƒ³ã ã‘ãŒé¸æŠžã•ã‚ŒãŸçŠ¶æ…‹ã«ãªã‚Šã¾ã™ã€‚å„グループã«ã¯ã€ãã®ã‚°ãƒ«ãƒ¼ãƒ—ã®ä¸­ã®ã©ã®ãƒœã‚¿ãƒ³ãŒé¸æŠžã•ã‚Œã¦ã„ã‚‹ã‹ã‚’示ã™å¤‰æ•°ãŒå‰²ã‚Šå½“ã¦ã‚‰ã‚Œã¦ã„ã¾ã™ã€‚「トライステートã€ãƒœã‚¿ãƒ³ãŒæŠ¼ã•ã‚ŒãŸã¨ãã«ã¯ã€ãƒ©ã‚¸ã‚ªãƒœã‚¿ãƒ³ã®è¡¨ç¤ºãŒãƒˆãƒ©ã‚¤ã‚¹ãƒ†ãƒ¼ãƒˆãƒ¢ãƒ¼ãƒ‰ã«ãªã‚Šã¾ã™ã€‚ã„ãšã‚Œã‹ã®ãƒœã‚¿ãƒ³ã‚’é¸æŠžã™ã‚Œã°ã€ãƒœã‚¿ãƒ³ã®çŠ¶æ…‹ã¯å…ƒã®ã‚ˆã†ã«å€‹ã€…ã®ãƒœã‚¿ãƒ³ã®on/off状態を示ã™ã‚ˆã†ã«ãªã‚Šã¾ã™ã€‚ç¾åœ¨ã®å¤‰æ•°ã®å€¤ã‚’見るã«ã¯ã€Œå¤‰æ•°å‚ç…§ã€ãƒœã‚¿ãƒ³ã‚’クリックã—ã¦ãã ã•ã„。'
+}
+msg.grid(:row=>0, :column=>0, :columnspan=>3, :sticky=>'nsew')
+
+# variable
+size = TkVariable.new
+color = TkVariable.new
+align = TkVariable.new
+
+# frame
+TkFrame.new(base_frame) {|frame|
+ TkGrid(TkFrame.new(frame, :height=>2, :relief=>:sunken, :bd=>2),
+ :columnspan=>4, :row=>0, :sticky=>'ew', :pady=>2)
+ TkGrid('x',
+ TkButton.new(frame, :text=>'変数å‚ç…§',
+ :image=>$image['view'], :compound=>:left,
+ :command=>proc{
+ showVars(base_frame, ['size', size],
+ ['color', color], ['compound', align])
+ }),
+ TkButton.new(frame, :text=>'コードå‚ç…§',
+ :image=>$image['view'], :compound=>:left,
+ :command=>proc{showCode 'radio3'}),
+ TkButton.new(frame, :text=>'é–‰ã˜ã‚‹',
+ :image=>$image['delete'], :compound=>:left,
+ :command=>proc{
+ tmppath = $radio3_demo
+ $radio3_demo = nil
+ $showVarsWin[tmppath.path] = nil
+ tmppath.destroy
+ }),
+ :padx=>4, :pady=>4)
+ frame.grid_columnconfigure(0, :weight=>1)
+ TkGrid(frame, :row=>3, :column=>0, :columnspan=>3, :sticky=>'nsew')
+}
+
+# frame
+f_left = TkLabelFrame.new(base_frame, 'text'=>'文字サイズ',
+ 'pady'=>2, 'padx'=>2)
+f_mid = TkLabelFrame.new(base_frame, 'text'=>'色',
+ 'pady'=>2, 'padx'=>2)
+f_right = TkLabelFrame.new(base_frame, 'text'=>'ビットマップé…ç½®',
+ 'pady'=>2, 'padx'=>2)
+f_left .grid('column'=>0, 'row'=>1, 'pady'=>'.5c', 'padx'=>'.5c', 'rowspan'=>2)
+f_mid .grid('column'=>1, 'row'=>1, 'pady'=>'.5c', 'padx'=>'.5c', 'rowspan'=>2)
+f_right.grid('column'=>2, 'row'=>1, 'pady'=>'.5c', 'padx'=>'.5c')
+
+TkButton.new(base_frame, 'text'=>'トライステート',
+ 'command'=>proc{size.value = 'multi'; color.value = 'multi'}){
+ grid('column'=>2, 'row'=>2, 'pady'=>'.5c', 'padx'=>'.5c')
+}
+
+# radiobutton
+[10, 12, 14, 18, 24].each {|sz|
+ TkRadioButton.new(f_left) {
+ text "ãƒã‚¤ãƒ³ãƒˆã‚µã‚¤ã‚º #{sz}"
+ variable size
+ relief 'flat'
+ value sz
+ tristatevalue 'multi'
+ }.pack('side'=>'top', 'pady'=>2, 'anchor'=>'w', 'fill'=>'x')
+}
+
+['Red', 'Green', 'Blue', 'Yellow', 'Orange', 'Purple'].each {|col|
+ TkRadioButton.new(f_mid) {
+ text col
+ variable color
+ relief 'flat'
+ value col.downcase
+ anchor 'w'
+ tristatevalue 'multi'
+ command proc{f_mid.fg(color.value)}
+ }.pack('side'=>'top', 'pady'=>2, 'fill'=>'x')
+}
+
+# label = TkLabel.new(f_right, 'text'=>'ラベル', 'bitmap'=>'questhead',
+label = Tk::Label.new(f_right, 'text'=>'ラベル', 'bitmap'=>'questhead',
+ 'compound'=>'left')
+label.configure('width'=>TkWinfo.reqwidth(label), 'compound'=>'top')
+label.height(TkWinfo.reqheight(label))
+a_btn = ['Top', 'Left', 'Right', 'Bottom'].collect{|a|
+ TkRadioButton.new(f_right, 'text'=>a, 'variable'=>align, 'relief'=>'flat',
+ 'value'=>a.downcase, 'indicatoron'=>0, 'width'=>7,
+ 'command'=>proc{label.compound(align.value)})
+}
+
+Tk.grid('x', a_btn[0])
+Tk.grid(a_btn[1], label, a_btn[2])
+Tk.grid('x', a_btn[3])
diff --git a/jni/ruby/ext/tk/sample/demos-jp/rmt b/jni/ruby/ext/tk/sample/demos-jp/rmt
new file mode 100644
index 0000000..dcfb328
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/demos-jp/rmt
@@ -0,0 +1,268 @@
+#!/usr/bin/env ruby
+
+# rmt --
+# This script implements a simple remote-control mechanism for
+# Tk applications. It allows you to select an application and
+# then type commands to that application.
+
+require 'tk'
+
+class Rmt
+ def initialize(parent=nil)
+ win = self
+
+ unless parent
+ parent = TkRoot.new
+ end
+ root = TkWinfo.toplevel(parent)
+ root.minsize(1,1)
+
+ # The instance variable below keeps track of the remote application
+ # that we're sending to. If it's an empty string then we execute
+ # the commands locally.
+ @app = 'local'
+ @mode = 'Ruby'
+
+ # The instance variable below keeps track of whether we're in the
+ # middle of executing a command entered via the text.
+ @executing = 0
+
+ # The instance variable below keeps track of the last command executed,
+ # so it can be re-executed in response to !! commands.
+ @lastCommand = ""
+
+ # Create menu bar. Arrange to recreate all the information in the
+ # applications sub-menu whenever it is cascaded to.
+
+ TkFrame.new(root, 'relief'=>'raised', 'bd'=>2) {|f|
+ pack('side'=>'top', 'fill'=>'x')
+ TkMenubutton.new(f, 'text'=>'File', 'underline'=>0) {|mb|
+ TkMenu.new(mb) {|mf|
+ mb.menu(mf)
+ TkMenu.new(mf) {|ma|
+ postcommand proc{win.fillAppsMenu ma}
+ mf.add('cascade', 'label'=>'Select Application',
+ 'menu'=>ma, 'underline'=>0)
+ }
+ add('command', 'label'=>'Quit',
+ 'command'=>proc{root.destroy}, 'underline'=>0)
+ }
+ pack('side'=>'left')
+ }
+ }
+
+ # Create text window and scrollbar.
+
+ @txt = TkText.new(root, 'relief'=>'sunken', 'bd'=>2, 'setgrid'=>true) {
+ yscrollbar(TkScrollbar.new(root){pack('side'=>'right', 'fill'=>'y')})
+ pack('side'=>'left')
+ }
+
+ @promptEnd = TkTextMark.new(@txt, 'insert')
+
+ # Create a binding to forward commands to the target application,
+ # plus modify many of the built-in bindings so that only information
+ # in the current command can be deleted (can still set the cursor
+ # earlier in the text and select and insert; just can't delete).
+
+ @txt.bindtags([@txt, TkText, root, 'all'])
+ @txt.bind('Return', proc{
+ @txt.set_insert('end - 1c')
+ @txt.insert('insert', "\n")
+ win.invoke
+ Tk.callback_break
+ })
+ @txt.bind('Delete', proc{
+ begin
+ @txt.tag_remove('sel', 'sel.first', @promptEnd)
+ rescue
+ end
+ if @txt.tag_nextrange('sel', '1.0', 'end') == []
+ if @txt.compare('insert', '<', @promptEnd)
+ Tk.callback_break
+ end
+ end
+ })
+ @txt.bind('BackSpace', proc{
+ begin
+ @txt.tag_remove('sel', 'sel.first', @promptEnd)
+ rescue
+ end
+ if @txt.tag_nextrange('sel', '1.0', 'end') == []
+ if @txt.compare('insert', '<', @promptEnd)
+ Tk.callback_break
+ end
+ end
+ })
+ @txt.bind('Control-d', proc{
+ if @txt.compare('insert', '<', @promptEnd)
+ Tk.callback_break
+ end
+ })
+ @txt.bind('Control-k', proc{
+ if @txt.compare('insert', '<', @promptEnd)
+ @txt.set_insert(@promptEnd)
+ end
+ })
+ @txt.bind('Control-t', proc{
+ if @txt.compare('insert', '<', @promptEnd)
+ Tk.callback_break
+ end
+ })
+ @txt.bind('Meta-d', proc{
+ if @txt.compare('insert', '<', @promptEnd)
+ Tk.callback_break
+ end
+ })
+ @txt.bind('Meta-BackSpace', proc{
+ if @txt.compare('insert', '<=', @promptEnd)
+ Tk.callback_break
+ end
+ })
+ @txt.bind('Control-h', proc{
+ if @txt.compare('insert', '<=', @promptEnd)
+ Tk.callback_break
+ end
+ })
+
+ @txt.tag_configure('bold', 'font'=>['Courier', 12, 'bold'])
+
+ @app = Tk.appname('rmt')
+ if (@app =~ /^rmt(.*)$/)
+ root.title("Tk Remote Controller#{$1}")
+ root.iconname("Tk Remote#{$1}")
+ end
+ prompt
+ @txt.focus
+ #@app = TkWinfo.appname(TkRoot.new)
+ end
+
+ def tkTextInsert(w,s)
+ return if s == ""
+ begin
+ if w.compare('sel.first','<=','insert') \
+ && w.compare('sel.last','>=','insert')
+ w.tag_remove('sel', 'sel.first', @promptEnd)
+ w.delete('sel.first', 'sel.last')
+ end
+ rescue
+ end
+ w.insert('insert', s)
+ w.see('insert')
+ end
+
+ # The method below is used to print out a prompt at the
+ # insertion point (which should be at the beginning of a line
+ # right now).
+
+ def prompt
+ @txt.insert('insert', "#{@app}: ")
+ @promptEnd.set('insert')
+ @promptEnd.gravity = 'left'
+ @txt.tag_add('bold', "#{@promptEnd.path} linestart", @promptEnd)
+ end
+
+ # The method below executes a command (it takes everything on the
+ # current line after the prompt and either sends it to the remote
+ # application or executes it locally, depending on "app".
+
+ def invoke
+ cmd = @txt.get(@promptEnd, 'insert')
+ @executing += 1
+ case (@mode)
+ when 'Tcl'
+ if Tk.info('complete', cmd)
+ if (cmd == "!!\n")
+ cmd = @lastCommand
+ else
+ @lastCommand = cmd
+ end
+ begin
+ msg = Tk.appsend(@app, false, cmd)
+ rescue
+ msg = "Error: #{$!}"
+ end
+ @txt.insert('insert', msg + "\n") if msg != ""
+ prompt
+ @promptEnd.set('insert')
+ end
+
+ when 'Ruby'
+ if (cmd == "!!\n")
+ cmd = @lastCommand
+ end
+ complete = true
+ begin
+ eval("proc{#{cmd}}")
+ rescue
+ complete = false
+ end
+ if complete
+ @lastCommand = cmd
+ begin
+# msg = Tk.appsend(@app, false,
+# 'ruby',
+# '"(' + cmd.gsub(/[][$"]/, '\\\\\&') + ').to_s"')
+ msg = Tk.rb_appsend(@app, false, cmd)
+ rescue
+ msg = "Error: #{$!}"
+ end
+ @txt.insert('insert', msg + "\n") if msg != ""
+ prompt
+ @promptEnd.set('insert')
+ end
+ end
+
+ @executing -= 1
+ @txt.yview_pickplace('insert')
+ end
+
+ # The following method is invoked to change the application that
+ # we're talking to. It also updates the prompt for the current
+ # command, unless we're in the middle of executing a command from
+ # the text item (in which case a new prompt is about to be output
+ # so there's no need to change the old one).
+
+ def newApp(appName, mode)
+ @app = appName
+ @mode = mode
+ if @executing == 0
+ @promptEnd.gravity = 'right'
+ @txt.delete("#{@promptEnd.path} linestart", @promptEnd)
+ @txt.insert(@promptEnd, "#{appName}: ")
+ @txt.tag_add('bold', "#{@promptEnd.path} linestart", @promptEnd)
+ @promptEnd.gravity = 'left'
+ end
+ end
+
+ # The method below will fill in the applications sub-menu with a list
+ # of all the applications that currently exist.
+
+ def fillAppsMenu(menu)
+ win = self
+ begin
+ menu.delete(0,'last')
+ rescue
+ end
+ TkWinfo.interps.sort.each{|ip|
+ begin
+ if Tk.appsend(ip, false, 'info commands ruby') == ""
+ mode = 'Tcl'
+ else
+ mode = 'Ruby'
+ end
+ menu.add('command', 'label'=>format("%s (#{mode}/Tk)", ip),
+ 'command'=>proc{win.newApp ip, mode})
+ rescue
+ menu.add('command', 'label'=>format("%s (unknown Tk)", ip),
+ 'command'=>proc{win.newApp ip, mode}, 'state'=>'disabled')
+ end
+ }
+ menu.add('command', 'label'=>format("local (Ruby/Tk)"),
+ 'command'=>proc{win.newApp 'local', 'Ruby'})
+ end
+end
+
+Rmt.new
+
+Tk.mainloop
diff --git a/jni/ruby/ext/tk/sample/demos-jp/rolodex b/jni/ruby/ext/tk/sample/demos-jp/rolodex
new file mode 100644
index 0000000..2cc73e1
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/demos-jp/rolodex
@@ -0,0 +1,320 @@
+#!/usr/bin/env ruby
+#
+# rolodex --
+# This script is a part of Tom LaStrange's rolodex
+#
+# Copyright (C) 1998 by Takaaki Tateishi <ttate@jaist.ac.jp>
+# Time-stamp: "03/08/02 12:45:21 nagai"
+#
+
+require "tk"
+
+
+def show_help(topic,x=0,y=0)
+ if( topic.is_a?(TkWindow) )
+ w = TkWinfo.containing(x,y)
+ if( TkWinfo.exist?(w) )
+ topic = w
+ end
+ end
+
+ if( $helpTopics.include?(topic) )
+ msg = $helpTopics[topic]
+ else
+ msg = "Sorry, but no help is available for this topic"
+ end
+ TkDialog.new("title"=>"Rolodex Help",
+ "message"=>"Information on #{topic}:\n\n#{msg}",
+ "default_button"=>0,
+ "buttons"=>["OK"])
+end
+
+def fillCard
+ clearAction
+ $root.frame.entry[1].insert(0,"Takaaki Tateishi")
+ $root.frame.entry[2].insert(0,"Japan Advanced Institute of Science and Techonology")
+ $root.frame.entry[3].insert(0,"1-1 Asahidai, Tatsunokuchi")
+ $root.frame.entry[4].insert(0,"Ishikawa 923-1292, Japan")
+ $root.frame.entry[5].insert(0,"private")
+ $root.frame.entry[6].insert(0,"***-***-****")
+ $root.frame.entry[7].insert(0,"***-***-****")
+end
+
+def addAction
+ for i in 1..7
+ STDERR.print format("%-12s %s\n",
+ RolodexFrame::LABEL[i],
+ $root.frame.entry[i].value)
+ end
+end
+
+def clearAction
+ for i in 1..7
+ $root.frame.entry[i].delete(0,"end")
+ end
+end
+
+def fileAction
+ TkDialog.new("title"=>"File Selection",
+ "message"=>"This is a dummy file selection dialog box.\n",
+ "default_button"=>0,
+ "buttons"=>["OK"])
+ STDERR.print "dummy file name\n"
+end
+
+def deleteAction
+ result = TkDialog.new("title"=>"Confirm Action",
+ "message"=>"Are you sure?",
+ "default_button"=>0,
+ "buttons"=>["Cancel"])
+ if( result.value == 0 )
+ clearAction
+ end
+end
+
+
+class RolodexFrame < TkFrame
+ attr_reader :entry, :label
+
+ LABEL = ["","Name:","Address:","","","Home Phone:","Work Phone:","Fax:"]
+
+ def initialize(parent=nil,keys=nil)
+ super(parent,keys)
+ self["relief"] = "flat"
+
+ @i = []
+ @label = []
+ @entry = []
+ for i in 1..7
+ @i[i] = TkFrame.new(self)
+ @i[i].pack("side"=>"top",
+ "pady"=>2,
+ "anchor"=>"e")
+ @label[i] = TkLabel.new(@i[i],
+ "text"=>LABEL[i],
+ "anchor"=>"e")
+ @entry[i] = TkEntry.new(@i[i],
+ "width"=>30,
+ "relief"=>"sunken")
+ @entry[i].pack("side"=>"right")
+ @label[i].pack("side"=>"right")
+ end
+ end
+end
+
+class RolodexButtons < TkFrame
+ attr_reader :clear, :add, :search, :delete
+
+ def initialize(parent,keys=nil)
+ super(parent,keys)
+ @clear = TkButton.new(self,
+ "text" => "Clear")
+ @add = TkButton.new(self,
+ "text" => "Add")
+ @search = TkButton.new(self,
+ "text" => "Search")
+ @delete = TkButton.new(self,
+ "text" => "Delete")
+ for w in [@clear,@add,@search,@delete]
+ w.pack("side"=>"left", "padx"=>2)
+ end
+ end
+end
+
+class RolodexMenuFrame < TkFrame
+ attr_reader :file_menu, :help_menu, :file, :help
+
+ def initialize(parent,keys=nil)
+ super(parent,keys)
+ configure("relief"=>"raised",
+ "borderwidth"=>1)
+
+ @file = TkMenubutton.new(self,
+ "text"=>"File",
+ "underline"=>0)
+ @file_menu = TkMenu.new(@file)
+ @file_menu.add("command",
+ "label" => "Load ...",
+ "command" => proc{fileAction},
+ "underline" => 0)
+ @file_menu.add("command",
+ "label" => "Exit",
+ "command" => proc{$root.destroy},
+ "underline" => 0)
+ @file.menu(@file_menu)
+ @file.pack("side"=>"left")
+
+ @help = TkMenubutton.new(self,
+ "text"=>"Help",
+ "underline"=>0)
+ @help_menu = TkMenu.new(@help)
+ @help_menu.add("command",
+ "label"=>"On Context...",
+ "command"=>proc{show_help("context")},
+ "underline"=>3)
+ @help_menu.add("command",
+ "label"=>"On Help...",
+ "command"=>proc{show_help("help")},
+ "underline"=>3)
+ @help_menu.add("command",
+ "label"=>"On Window...",
+ "command"=>proc{show_help("window")},
+ "underline"=>3)
+ @help_menu.add("command",
+ "label"=>"On Keys...",
+ "command"=>proc{show_help("keys")},
+ "underline"=>3)
+ @help_menu.add("command",
+ "label"=>"On version...",
+ "command"=>proc{show_help("version")},
+ "underline"=>3)
+ @help.menu(@help_menu)
+ @help.pack("side"=>"right")
+ end
+end
+
+class Rolodex < TkRoot
+ attr_reader :frame, :buttons, :menu
+
+ def initialize(*args)
+ super(*args)
+ @frame = RolodexFrame.new(self)
+ @frame.pack("side"=>"top",
+ "fill"=>"y",
+ "anchor"=>"center")
+ @buttons = RolodexButtons.new(self)
+ @buttons.pack("side"=>"bottom",
+ "pady"=>2,
+ "anchor"=>"center")
+ @menu = RolodexMenuFrame.new(self)
+ @menu.pack("before"=>@frame,
+ "side"=>"top",
+ "fill"=>"x")
+ end
+end
+
+$root = Rolodex.new
+
+$root.buttons.delete.configure("command"=>proc{deleteAction})
+$root.buttons.add.configure("command"=>proc{addAction})
+$root.buttons.clear.configure("command"=>proc{clearAction})
+$root.buttons.search.configure("command"=>proc{addAction; fillCard})
+
+$root.buttons.clear.configure("text"=>"Clear Ctrl+C")
+$root.bind("Control-c",proc{clearAction})
+
+$root.buttons.add.configure("text"=>"Add Ctrl+A")
+$root.bind("Control-a",proc{addAction})
+
+$root.buttons.search.configure("text"=>"Search Ctrl+S")
+$root.bind("Control-s",proc{addAction; fillCard})
+
+$root.buttons.delete.configure("text"=>"Delete... Ctrl+D")
+$root.bind("Control-d",proc{deleteAction})
+
+$root.menu.file_menu.entryconfigure(1, "accel"=>"Ctrl+F")
+$root.bind("Control-f",proc{fileAction})
+
+$root.menu.file_menu.entryconfigure(2, "accel"=>"Ctrl+Q")
+$root.bind("Control-q",proc{$root.destroy})
+
+$root.frame.entry[1].focus
+
+$root.bind("Any-F1",
+ proc{|event| show_help(event.widget, event.x_root, event.y_root)})
+$root.bind("Any-Help",
+ proc{|event| show_help(event.widget, event.x_root, event.y_root)})
+
+
+$helpTopics = {}
+
+$helpTopics[$root.menu.file] = <<EOF
+This is the "file" menu. It can be used to invoke\
+some overall operations on the rolodex applications,\
+such as loading a file or exiting.
+EOF
+
+$helpTopics[$root.menu.file_menu.index(0)] = <<EOF
+The "Load" entry in the "File" menu posts a dialog box\
+that you can use to select a rolodex file
+EOF
+
+$helpTopics[$root.menu.file_menu.index(1)] = <<EOF
+The "Exit" entry in the "File" menu causes the rolodex\
+application to terminate
+EOF
+
+$helpTopics[$root.frame.entry[1]] = <<EOF
+In this field of the rolodex entry you should\
+type the person's name
+EOF
+
+$helpTopics[$root.frame.entry[2]] = <<EOF
+In this field of the rolodex entry you should\
+type the first line of the person's address
+EOF
+
+$helpTopics[$root.frame.entry[3]] = <<EOF
+In this field of the rolodex entry you should\
+type the second line of the person's address
+EOF
+
+$helpTopics[$root.frame.entry[4]] = <<EOF
+In this field of the rolodex entry you should\
+type the third line of the person's address
+EOF
+
+$helpTopics[$root.frame.entry[5]] = <<EOF
+In this field of the rolodex entry you should\
+type the person's home phone number, or "private"\
+if the person doesn't want his or he number publicized
+EOF
+
+$helpTopics[$root.frame.entry[6]] = <<EOF
+In this field of the rolodex entry you should\
+type the person's work phone number
+EOF
+
+$helpTopics[$root.frame.entry[7]] = <<EOF
+In this field of the rolodex entry you should\
+type the phone number for the person's FAX machine
+EOF
+
+$helpTopics["context"] = <<EOF
+Unfortunately, this application doesn't support context-sensitive\
+help in the usual way, because when this demo was written Ruby/Tk\
+didn't have a grab mechanism and this is needed for context-sensitive\
+help. Instead, you can achive much the same effect by simply moving\
+the mouse over the window you're curious about and pressing the\
+Help or F1 keys. You can do this anytime.
+EOF
+
+$helpTopics["help"] = <<EOF
+This application provides only very crude help. Besides the\
+entries in this menu, you can get help on individual windows\
+by moving the mouse cursor over the window and pressing the\
+Help or F1 keys.
+EOF
+
+$helpTopics["window"] = <<EOF
+This window is a dummy rolodex application created as part of\
+Tom LaStrange's toolkit benchmark. It doesn't really do anything\
+useful except to demonstrate a few features of the Ruby/Tk.
+EOF
+
+$helpTopics["keys"] = <<EOF
+The following accelerator keys are defined for this application\
+(in addition to those already available for the entry windows):
+Ctrl+A: Add
+Ctrl+C: Clear
+Ctrl+D: Delete
+Ctrl+F: Enter file name
+Ctrl+Q: Exit application (quit)
+Ctrl+S: Search (dummy operation)
+EOF
+
+$helpTopics["version"] = <<EOF
+This is version 1.0.1.
+EOF
+
+Tk.mainloop
diff --git a/jni/ruby/ext/tk/sample/demos-jp/rolodex-j b/jni/ruby/ext/tk/sample/demos-jp/rolodex-j
new file mode 100644
index 0000000..f6e3afd
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/demos-jp/rolodex-j
@@ -0,0 +1,300 @@
+#!/usr/bin/env ruby
+# -*- coding: utf-8 -*-
+#
+# rolodex --
+# ã“ã®ã‚¹ã‚¯ãƒªãƒ—ト㯠Tom LaStrange ã® rolodex ã®ä¸€éƒ¨ã§ã™ã€‚
+#
+# Copyright (C) 1998 by Takaaki Tateishi <ttate@jaist.ac.jp>
+# Time-stamp: "04/04/09 00:32:12 nagai"
+#
+
+require "tk"
+Tk.encoding = "utf-8"
+
+def show_help(topic,x=0,y=0)
+ if( topic.is_a?(TkWindow) )
+ w = TkWinfo.containing(x,y)
+ if( w.is_a?(TkWindow) )
+ if( TkWinfo.exist?(w) )
+ topic = w
+ end
+ end
+ end
+
+ if( $helpTopics.include?(topic) )
+ msg = $helpTopics[topic]
+ else
+ msg = "ã“ã®ãƒˆãƒ”ックã«ã¤ã„ã¦ã®ãƒ˜ãƒ«ãƒ—ã¯ã¾ã ä½¿ç”¨ã§ãã¾ã›ã‚“"
+ end
+ TkDialog.new("title"=>"Rolodex Help",
+ "message"=>"「#{topic}ã€\n\n#{msg}",
+ "default_button"=>0,
+ "buttons"=>["OK"])
+end
+
+def fillCard
+ clearAction
+ $root.frame.entry[1].insert(0, "立石 å­å½°")
+ $root.frame.entry[2].insert(0, "923-1292 石å·çœŒ")
+ $root.frame.entry[3].insert(0, "è¾°å£ç”º æ—­å° 1-1")
+ $root.frame.entry[4].insert(0, "北陸先端科学技術大学院大学")
+ $root.frame.entry[5].insert(0,"private")
+ $root.frame.entry[6].insert(0,"***-***-****")
+ $root.frame.entry[7].insert(0,"***-***-****")
+end
+
+def addAction
+ for i in 1..7
+ STDERR.print format("%-12s %s\n",
+ RolodexFrame::LABEL[i],
+ $root.frame.entry[i].value)
+ end
+end
+
+def clearAction
+ for i in 1..7
+ $root.frame.entry[i].delete(0,"end")
+ end
+end
+
+def fileAction
+ TkDialog.new("title"=>"File Selection",
+ "message"=>"ã“ã‚Œã¯ãƒ•ã‚¡ã‚¤ãƒ«é¸æŠžãƒ€ã‚¤ã‚¢ãƒ­ã‚°ã®ãƒ€ãƒŸãƒ¼ã§ã™ã€‚\n",
+ "default_button"=>0,
+ "buttons"=>["OK"])
+ STDERR.print "dummy file name\n"
+end
+
+def deleteAction
+ result = TkDialog.new("title"=>"Confirm Action",
+ "message"=>"よã‚ã—ã„ã§ã™ã‹ï¼Ÿ",
+ "default_button"=>0,
+ "buttons"=>["キャンセル"])
+ if( result.value == 0 )
+ clearAction
+ end
+end
+
+
+class RolodexFrame < TkFrame
+ attr_reader :entry, :label
+
+ LABEL = ["","åå‰:","ä½æ‰€","","","電話(自宅):","電話(会社):","Fax:"]
+
+ def initialize(parent=nil,keys=nil)
+ super(parent,keys)
+ self["relief"] = "flat"
+ @i = []
+ @label = []
+ @entry = []
+ for i in 1..7
+ @i[i] = TkFrame.new(self)
+ @i[i].pack("side"=>"top",
+ "pady"=>2,
+ "anchor"=>"e")
+ @label[i] = TkLabel.new(@i[i],
+ "text"=>LABEL[i],
+ "anchor"=>"e")
+ @entry[i] = TkEntry.new(@i[i],
+ "width"=>30,
+ "relief"=>"sunken")
+ @entry[i].pack("side"=>"right")
+ @label[i].pack("side"=>"right")
+ end
+ end
+end
+
+class RolodexButtons < TkFrame
+ attr_reader :clear, :add, :search, :delete
+
+ def initialize(parent,keys=nil)
+ super(parent,keys)
+ @clear = TkButton.new(self,"text" => "クリアー")
+ @add = TkButton.new(self, "text" => "追加")
+ @search = TkButton.new(self, "text" => "検索")
+ @delete = TkButton.new(self, "text" => "消去")
+ for w in [@clear,@add,@search,@delete]
+ w.pack("side"=>"left", "padx"=>2)
+ end
+ end
+end
+
+class RolodexMenuFrame < TkFrame
+ attr_reader :file_menu, :help_menu, :file, :help
+
+ def initialize(parent,keys=nil)
+ super(parent,keys)
+ configure("relief"=>"raised",
+ "borderwidth"=>1)
+
+ @file = TkMenubutton.new(self,
+ "text"=> "ファイル",
+ "underline"=>0)
+ @file_menu = TkMenu.new(@file)
+ @file_menu.add("command",
+ "label" => "読ã¿è¾¼ã¿ ...",
+ "command" => proc{fileAction},
+ "underline" => 0)
+ @file_menu.add("command",
+ "label" => "終了",
+ "command" => proc{$root.destroy},
+ "underline" => 0)
+ @file.menu(@file_menu)
+ @file.pack("side"=>"left")
+
+ @help = TkMenubutton.new(self,
+ "text"=> "ヘルプ",
+ "underline"=>0)
+ @help_menu = TkMenu.new(@help)
+ @help_menu.add("command",
+ "label"=> "コンテキストã«ã¤ã„ã¦",
+ "command"=>proc{show_help("コンテキスト")},
+ "underline"=>3)
+ @help_menu.add("command",
+ "label"=> "ヘルプã«ã¤ã„ã¦",
+ "command"=>proc{show_help("ヘルプ")},
+ "underline"=>3)
+ @help_menu.add("command",
+ "label"=> "ウィンドウã«ã¤ã„ã¦",
+ "command"=>proc{show_help("ウィンドウ")},
+ "underline"=>3)
+ @help_menu.add("command",
+ "label"=> "キーæ“作ã«ã¤ã„ã¦",
+ "command"=>proc{show_help("キーæ“作")},
+ "underline"=>3)
+ @help_menu.add("command",
+ "label"=> "ãƒãƒ¼ã‚¸ãƒ§ãƒ³æƒ…å ±",
+ "command"=>proc{show_help("ãƒãƒ¼ã‚¸ãƒ§ãƒ³æƒ…å ±")},
+ "underline"=>3)
+ @help.menu(@help_menu)
+ @help.pack("side"=>"right")
+ end
+end
+
+class Rolodex < TkRoot
+ attr_reader :frame, :buttons, :menu
+
+ def initialize(*args)
+ super(*args)
+ @frame = RolodexFrame.new(self)
+ @frame.pack("side"=>"top",
+ "fill"=>"y",
+ "anchor"=>"center")
+ @buttons = RolodexButtons.new(self)
+ @buttons.pack("side"=>"bottom",
+ "pady"=>2,
+ "anchor"=>"center")
+ @menu = RolodexMenuFrame.new(self)
+ @menu.pack("before"=>@frame,
+ "side"=>"top",
+ "fill"=>"x")
+ end
+end
+
+$root = Rolodex.new
+
+$root.buttons.delete.configure("command"=>proc{deleteAction})
+$root.buttons.add.configure("command"=>proc{addAction})
+$root.buttons.clear.configure("command"=>proc{clearAction})
+$root.buttons.search.configure("command"=>proc{addAction; fillCard})
+
+$root.buttons.clear.configure("text"=> "クリアー Ctrl+C")
+$root.bind("Control-c",proc{clearAction})
+
+$root.buttons.add.configure("text"=> "追加 Ctrl+A")
+$root.bind("Control-a",proc{addAction})
+
+$root.buttons.search.configure("text"=> "検索 Ctrl+S")
+$root.bind("Control-s",proc{addAction; fillCard})
+
+$root.buttons.delete.configure("text"=> "消去 Ctrl+D")
+$root.bind("Control-d",proc{deleteAction})
+
+$root.menu.file_menu.entryconfigure(1, "accel"=>"Ctrl+F")
+$root.bind("Control-f",proc{fileAction})
+
+$root.menu.file_menu.entryconfigure(2, "accel"=>"Ctrl+Q")
+$root.bind("Control-q",proc{$root.destroy})
+
+$root.frame.entry[1].focus
+
+$root.bind("Any-F1",
+ proc{|event| show_help(event.widget, event.x_root, event.y_root)})
+$root.bind("Any-Help",
+ proc{|event| show_help(event.widget, event.x_root, event.y_root)})
+
+
+$helpTopics = {}
+
+$helpTopics[$root.menu.file] = <<EOF
+ã“ã‚Œã¯ã€Œãƒ•ã‚¡ã‚¤ãƒ«ã€ãƒ¡ãƒ‹ãƒ¥ãƒ¼ã§ã™ã€‚「読ã¿è¾¼ã¿ã€ã‚„「終了ã€ãªã©ã‚’
+è¡Œãªã†ã“ã¨ãŒã§ãã¾ã™ã€‚
+EOF
+
+$helpTopics[$root.menu.file_menu.index(0)] = <<EOF
+ファイルã®èª­ã¿è¾¼ã¿ã‚’è¡Œãªã†ã¨ãã«ä½¿ã„ã¾ã™ã€‚
+EOF
+
+$helpTopics[$root.menu.file_menu.index(1)] = <<EOF
+アプリケーションを終了ã™ã‚‹ã¨ãã«ä½¿ã„ã¾ã™ã€‚
+EOF
+
+$helpTopics[$root.frame.entry[1]] = <<EOF
+åå‰ã‚’記入ã™ã‚‹ã‚¨ãƒ³ãƒˆãƒªã§ã™ã€‚
+EOF
+
+$helpTopics[$root.frame.entry[2]] = <<EOF
+ä½æ‰€ã‚’記入ã™ã‚‹ã‚¨ãƒ³ãƒˆãƒªã§ã™ã€‚
+EOF
+
+$helpTopics[$root.frame.entry[3]] = <<EOF
+ä½æ‰€ã‚’記入ã™ã‚‹ã‚¨ãƒ³ãƒˆãƒªã§ã™ã€‚
+EOF
+
+$helpTopics[$root.frame.entry[4]] = <<EOF
+ä½æ‰€ã‚’記入ã™ã‚‹ã‚¨ãƒ³ãƒˆãƒªã§ã™ã€‚
+EOF
+
+$helpTopics[$root.frame.entry[5]] = <<EOF
+自宅ã®é›»è©±ç•ªå·ã‚’記入ã™ã‚‹ã‚¨ãƒ³ãƒˆãƒªã§ã™ã€‚公開\
+ã—ãŸããªã„ã¨ã㯠private ã¨è¨˜å…¥ã—ã¾ã™ã€‚
+EOF
+
+$helpTopics[$root.frame.entry[6]] = <<EOF
+会社ã®é›»è©±ç•ªå·ã‚’記入ã™ã‚‹ã‚¨ãƒ³ãƒˆãƒªã§ã™ã€‚
+EOF
+
+$helpTopics[$root.frame.entry[7]] = <<EOF
+FAX番å·ã‚’記入ã™ã‚‹ã‚¨ãƒ³ãƒˆãƒªã§ã™ã€‚
+EOF
+
+$helpTopics["コンテキスト"] = <<EOF
+Ruby/Tkã§ã¯grabã®æ©Ÿæ§‹ãŒãªã„ãŸã‚ã“ã®ã‚¢ãƒ—リケーションã§ã¯\
+コンテキストヘルプã¯ã‚µãƒãƒ¼ãƒˆã•ã‚Œã¦ã„ã¾ã›ã‚“。
+ã—ã‹ã—åŒã˜ã‚ˆã†ãªåŠ¹æžœã‚’bindã¨ãƒžã‚¦ã‚¹ã®ä½ç½®ã®Wedgetを知る\
+ã“ã¨ã§å¾—ã‚‹ã“ã¨ãŒã§ãã¾ã™ã€‚
+EOF
+
+$helpTopics["ヘルプ"] = <<EOF
+マウスをウィンドウã«ã‚ã‚ã›ã¦F1キーを押ã™ã“ã¨ã«ã‚ˆã£ã¦\
+ãã®ãƒ˜ãƒ«ãƒ—を見るã“ã¨ãŒã§ãã¾ã™ã€‚
+EOF
+
+$helpTopics["ウィンドウ"] = <<EOF
+ã“ã®ã‚¦ã‚£ãƒ³ãƒ‰ã‚¦ã¯ãƒ€ãƒŸãƒ¼ã§ã™ã€‚
+EOF
+
+$helpTopics["キーæ“作"] = <<EOF
+Ctrl+A: 追加
+Ctrl+C: クリアー
+Ctrl+D: 消去
+Ctrl+F: ファイルé¸æŠž
+Ctrl+Q: 終了
+Ctrl+S: 検索
+EOF
+
+$helpTopics["ãƒãƒ¼ã‚¸ãƒ§ãƒ³æƒ…å ±"] = <<EOF
+ãƒãƒ¼ã‚¸ãƒ§ãƒ³ã¯ 1.0.1j ã§ã™ã€‚
+EOF
+
+Tk.mainloop
diff --git a/jni/ruby/ext/tk/sample/demos-jp/ruler.rb b/jni/ruby/ext/tk/sample/demos-jp/ruler.rb
new file mode 100644
index 0000000..5c34a5a
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/demos-jp/ruler.rb
@@ -0,0 +1,203 @@
+# -*- coding: utf-8 -*-
+#
+# ruler widget demo (called by 'widget')
+#
+
+# rulerMkTab --
+# This method creates a new triangular polygon in a canvas to
+# represent a tab stop.
+#
+# Arguments:
+# c - The canvas window.
+# x, y - Coordinates at which to create the tab stop.
+
+def rulerMkTab(c,x,y)
+ v = $demo_rulerInfo
+ TkcPolygon.new(c, x, y, x+v.size, y+v.size, x-v.size, y+v.size)
+end
+
+# toplevel widget ãŒå­˜åœ¨ã™ã‚Œã°å‰Šé™¤ã™ã‚‹
+if defined?($ruler_demo) && $ruler_demo
+ $ruler_demo.destroy
+ $ruler_demo = nil
+end
+
+# demo 用㮠toplevel widget を生æˆ
+$ruler_demo = TkToplevel.new {|w|
+ title("Ruler Demonstration")
+ iconname("ruler")
+ positionWindow(w)
+}
+
+base_frame = TkFrame.new($ruler_demo).pack(:fill=>:both, :expand=>true)
+
+# label 生æˆ
+TkLabel.new(base_frame, 'font'=>$font, 'wraplength'=>'5i', 'justify'=>'left',
+ 'text'=>"ã“ã®ã‚­ãƒ£ãƒ³ãƒã‚¹widgetã¯ãƒ«ãƒ¼ãƒ©ãƒ¼ã®æ¨¡åž‹ã§ã™ã€‚ルーラーã®å³ã«ã‚ã‚‹ã®ã¯ã‚¿ãƒ–ストップã®äº•æˆ¸ã§ã€ã“ã“ã‹ã‚‰å¼•ã£å¼µã£ã¦ãã‚‹ã“ã¨ã«ã‚ˆã£ã¦ã‚¿ãƒ–ストップを作るã“ã¨ãŒã§ãã¾ã™ã€‚ã¾ãŸã€ã™ã§ã«ã‚るタブストップを動ã‹ã™ã“ã¨ã‚‚ã§ãã¾ã™ã€‚タブストップを上方ã¾ãŸã¯ä¸‹æ–¹ã«ã‹ã™ã‚Œã¦è¡¨ç¤ºã•ã‚Œã‚‹ã¾ã§ãƒ‰ãƒ©ãƒƒã‚°ã™ã‚‹ã¨ã€ãƒžã‚¦ã‚¹ãƒœã‚¿ãƒ³ã‚’離ã—ãŸæ™‚ã«ãã®ã‚¿ãƒ–ストップã¯æ¶ˆãˆã¾ã™ã€‚"){
+ pack('side'=>'top')
+}
+
+# frame 生æˆ
+$ruler_buttons = TkFrame.new(base_frame) {|frame|
+ TkButton.new(frame) {
+ #text '了解'
+ text 'é–‰ã˜ã‚‹'
+ command proc{
+ tmppath = $ruler_demo
+ $ruler_demo = nil
+ tmppath.destroy
+ }
+ }.pack('side'=>'left', 'expand'=>'yes')
+
+ TkButton.new(frame) {
+ text 'コードå‚ç…§'
+ command proc{showCode 'ruler'}
+ }.pack('side'=>'left', 'expand'=>'yes')
+}
+$ruler_buttons.pack('side'=>'bottom', 'fill'=>'x', 'pady'=>'2m')
+
+# canvas 設定
+$ruler_canvas = TkCanvas.new(base_frame, 'width'=>'14.8c', 'height'=>'2.5c')
+$ruler_canvas.pack('side'=>'top', 'fill'=>'x')
+
+# 値設定
+unless Struct.const_defined?("RulerInfo")
+ $demo_rulerInfo = Struct.new("RulerInfo", :grid, :left, :right, :x, :y,
+ :top, :bottom, :size, :normalStyle,
+ :activeStyle, :deleteStyle).new
+end
+$demo_rulerInfo.grid = '.25c'
+$demo_rulerInfo.left = TkWinfo.fpixels($ruler_canvas, '1c')
+$demo_rulerInfo.right = TkWinfo.fpixels($ruler_canvas, '13c')
+$demo_rulerInfo.top = TkWinfo.fpixels($ruler_canvas, '1c')
+$demo_rulerInfo.bottom = TkWinfo.fpixels($ruler_canvas, '1.5c')
+$demo_rulerInfo.size = TkWinfo.fpixels($ruler_canvas, '.2c')
+$demo_rulerInfo.normalStyle = {'fill'=>'black'}
+if TkWinfo.depth($ruler_canvas) > 1
+ $demo_rulerInfo.activeStyle = {'fill'=>'red', 'stipple'=>''}
+ $demo_rulerInfo.deleteStyle = {'fill'=>'red',
+ 'stipple'=>'@'+[$demo_dir, '..',
+ 'images', 'gray25.xbm'].join(File::Separator)}
+else
+ $demo_rulerInfo.activeStyle = {'fill'=>'black', 'stipple'=>''}
+ $demo_rulerInfo.deleteStyle = {'fill'=>'black',
+ 'stipple'=>'@'+[$demo_dir, '..',
+ 'images', 'gray25.xbm'].join(File::Separator)}
+end
+
+TkcLine.new($ruler_canvas,
+ '1c', '0.5c', '1c', '1c', '13c', '1c', '13c', '0.5c', 'width'=>1)
+(0..11).each{|i|
+ x = i+1
+ TkcLine.new($ruler_canvas, "#{x}c", '1c', "#{x}c", '0.6c', 'width'=>1)
+ TkcLine.new($ruler_canvas, "#{x}.25c", '1c', "#{x}.25c", '0.8c', 'width'=>1)
+ TkcLine.new($ruler_canvas, "#{x}.5c", '1c', "#{x}.5c", '0.7c', 'width'=>1)
+ TkcLine.new($ruler_canvas, "#{x}.75c", '1c', "#{x}.75c", '0.8c', 'width'=>1)
+ TkcText.new($ruler_canvas, "#{x}.15c", '0.75c', 'text'=>i, 'anchor'=>'sw')
+}
+
+$rulerTag_well = TkcTag.new($ruler_canvas)
+$ruler_canvas\
+.addtag_withtag($rulerTag_well,
+ TkcRectangle.new($ruler_canvas,
+ '13.2c', '1c', '13.8c', '0.5c',
+ 'outline'=>'black',
+ 'fill'=>($ruler_canvas\
+ .configinfo('background'))[4]) )
+$ruler_canvas\
+.addtag_withtag($rulerTag_well,
+ rulerMkTab($ruler_canvas,
+ TkWinfo.pixels($ruler_canvas, '13.5c'),
+ TkWinfo.pixels($ruler_canvas, '.65c') ) )
+
+$rulerTag_well.bind('1', proc{|x,y| rulerNewTab($ruler_canvas,x,y)}, '%x %y')
+$ruler_canvas.itembind('tab', '1',
+ proc{|x,y| rulerSelectTab($ruler_canvas,x,y)}, '%x %y')
+$ruler_canvas.bind('B1-Motion',
+ proc{|x,y| rulerMoveTab($ruler_canvas,x,y)}, '%x %y')
+$ruler_canvas.bind('Any-ButtonRelease-1', proc{rulerReleaseTab($ruler_canvas)})
+
+# rulerNewTab --
+# Does all the work of creating a tab stop, including creating the
+# triangle object and adding tags to it to give it tab behavior.
+#
+# Arguments:
+# c - The canvas window.
+# x, y - The coordinates of the tab stop.
+
+def rulerNewTab(c,x,y)
+ v = $demo_rulerInfo
+ c.addtag_withtag('active', rulerMkTab(c,x,y))
+ c.addtag_withtag('tab', 'active')
+ v.x = x
+ v.y = y
+ rulerMoveTab(c,x,y)
+end
+
+# rulerSelectTab --
+# This method is invoked when mouse button 1 is pressed over
+# a tab. It remembers information about the tab so that it can
+# be dragged interactively.
+#
+# Arguments:
+# c - The canvas widget.
+# x, y - The coordinates of the mouse (identifies the point by
+# which the tab was picked up for dragging).
+
+def rulerSelectTab(c,x,y)
+ v = $demo_rulerInfo
+ v.x = c.canvasx(x, v.grid)
+ v.y = v.top+2
+ c.addtag_withtag('active', 'current')
+ c.itemconfigure('active', v.activeStyle)
+ c.raise('active')
+end
+
+# rulerMoveTab --
+# This method is invoked during mouse motion events to drag a tab.
+# It adjusts the position of the tab, and changes its appearance if
+# it is about to be dragged out of the ruler.
+#
+# Arguments:
+# c - The canvas widget.
+# x, y - The coordinates of the mouse.
+
+def rulerMoveTab(c,x,y)
+ v = $demo_rulerInfo
+ return if c.find_withtag('active') == []
+ cx = c.canvasx(x,v.grid)
+ cy = c.canvasy(y)
+ cx = v.left if cx < v.left
+ cx = v.right if cx > v.right
+ if (cy >= v.top && cy <= v.bottom)
+ cy = v.top+2
+ c.itemconfigure('active', v.activeStyle)
+ else
+ cy = cy-v.size-2
+ c.itemconfigure('active', v.deleteStyle)
+ end
+ c.move('active', cx-v.x, cy-v.y)
+ v.x = cx
+ v.y = cy
+end
+
+# rulerReleaseTab --
+# This method is invoked during button release events that end
+# a tab drag operation. It deselects the tab and deletes the tab if
+# it was dragged out of the ruler.
+#
+# Arguments:
+# c - The canvas widget.
+# x, y - The coordinates of the mouse.
+
+def rulerReleaseTab(c)
+ v = $demo_rulerInfo
+ return if c.find_withtag('active') == []
+ if v.y != v.top+2
+ c.delete('active')
+ else
+ c.itemconfigure('active', v.normalStyle)
+ c.dtag('active')
+ end
+end
+
diff --git a/jni/ruby/ext/tk/sample/demos-jp/sayings.rb b/jni/ruby/ext/tk/sample/demos-jp/sayings.rb
new file mode 100644
index 0000000..cf4fe7b
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/demos-jp/sayings.rb
@@ -0,0 +1,103 @@
+# -*- coding: utf-8 -*-
+#
+# listbox widget demo 'sayings' (called by 'widget')
+#
+
+# toplevel widget ãŒå­˜åœ¨ã™ã‚Œã°å‰Šé™¤ã™ã‚‹
+if defined?($sayings_demo) && $sayings_demo
+ $sayings_demo.destroy
+ $sayings_demo = nil
+end
+
+# demo 用㮠toplevel widget を生æˆ
+$sayings_demo = TkToplevel.new {|w|
+ title("Listbox Demonstration (well-known sayings)")
+ iconname("sayings")
+ positionWindow(w)
+}
+
+base_frame = TkFrame.new($sayings_demo).pack(:fill=>:both, :expand=>true)
+
+# label 生æˆ
+msg = TkLabel.new(base_frame) {
+ font $font
+ wraplength '4i'
+ justify 'left'
+ text "下ã®ãƒªã‚¹ãƒˆãƒœãƒƒã‚¯ã‚¹ã«ã¯ã„ã‚ã„ã‚ãªæ ¼è¨€ãŒå…¥ã£ã¦ã„ã¾ã™ã€‚リストをスクロールã•ã›ã‚‹ã®ã¯ã‚¹ã‚¯ãƒ­ãƒ¼ãƒ«ãƒãƒ¼ã§ã‚‚ã§ãã¾ã™ã—ã€ãƒªã‚¹ãƒˆãƒœãƒƒã‚¯ã‚¹ã®ä¸­ã§ãƒžã‚¦ã‚¹ã®ãƒœã‚¿ãƒ³2(中ボタン)を押ã—ãŸã¾ã¾ãƒ‰ãƒ©ãƒƒã‚°ã—ã¦ã‚‚ã§ãã¾ã™ã€‚"
+}
+msg.pack('side'=>'top')
+
+# frame 生æˆ
+TkFrame.new(base_frame) {|frame|
+ TkButton.new(frame) {
+ #text '了解'
+ text 'é–‰ã˜ã‚‹'
+ command proc{
+ tmppath = $sayings_demo
+ $sayings_demo = nil
+ tmppath.destroy
+ }
+ }.pack('side'=>'left', 'expand'=>'yes')
+
+ TkButton.new(frame) {
+ text 'コードå‚ç…§'
+ command proc{showCode 'sayings'}
+ }.pack('side'=>'left', 'expand'=>'yes')
+
+}.pack('side'=>'bottom', 'fill'=>'x', 'pady'=>'2m')
+
+# frame 生æˆ
+sayings_lbox = nil
+TkFrame.new(base_frame, 'borderwidth'=>10) {|w|
+ sv = TkScrollbar.new(w)
+ sh = TkScrollbar.new(w, 'orient'=>'horizontal')
+ sayings_lbox = TkListbox.new(w) {
+ setgrid 1
+ width 20
+ height 10
+ yscrollcommand proc{|first,last| sv.set first,last}
+ xscrollcommand proc{|first,last| sh.set first,last}
+ }
+ sv.command(proc{|*args| sayings_lbox.yview(*args)})
+ sh.command(proc{|*args| sayings_lbox.xview(*args)})
+
+ if $tk_version =~ /^4\.[01]/
+ sv.pack('side'=>'right', 'fill'=>'y')
+ sh.pack('side'=>'bottom', 'fill'=>'x')
+ sayings_lbox.pack('expand'=>'yes', 'fill'=>'y')
+
+ else
+ sayings_lbox.grid('row'=>0, 'column'=>0,
+ 'rowspan'=>1, 'columnspan'=>1, 'sticky'=>'news')
+ sv.grid('row'=>0, 'column'=>1,
+ 'rowspan'=>1, 'columnspan'=>1, 'sticky'=>'news')
+ sh.grid('row'=>1, 'column'=>0,
+ 'rowspan'=>1, 'columnspan'=>1, 'sticky'=>'news')
+ TkGrid.rowconfigure(w, 0, 'weight'=>1, 'minsize'=>0)
+ TkGrid.columnconfigure(w, 0, 'weight'=>1, 'minsize'=>0)
+ end
+
+}.pack('side'=>'top', 'expand'=>'yes', 'fill'=>'y')
+
+sayings_lbox.insert(0,
+"Waste not, want not",
+"Early to bed and early to rise makes a man healthy, wealthy, and wise",
+"Ask not what your country can do for you, ask what you can do for your country",
+"I shall return",
+"NOT",
+"A picture is worth a thousand words",
+"User interfaces are hard to build",
+"Thou shalt not steal",
+"A penny for your thoughts",
+"Fool me once, shame on you; fool me twice, shame on me",
+"Every cloud has a silver lining",
+"Where there's smoke there's fire",
+"It takes one to know one",
+"Curiosity killed the cat",
+"Take this job and shove it",
+"Up a creek without a paddle",
+"I'm mad as hell and I'm not going to take it any more",
+"An apple a day keeps the doctor away",
+"Don't look a gift horse in the mouth"
+)
+
diff --git a/jni/ruby/ext/tk/sample/demos-jp/search.rb b/jni/ruby/ext/tk/sample/demos-jp/search.rb
new file mode 100644
index 0000000..238450a
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/demos-jp/search.rb
@@ -0,0 +1,184 @@
+# -*- coding: utf-8 -*-
+#
+# Text Search widget demo (called by 'widget')
+#
+
+# textLoadFile --
+# This method below loads a file into a text widget, discarding
+# the previous contents of the widget. Tags for the old widget are
+# not affected, however.
+#
+# Arguments:
+# w - The window into which to load the file. Must be a
+# text widget.
+# file - The name of the file to load. Must be readable.
+
+def textLoadFile(w,file)
+ w.delete('1.0', 'end')
+ f = open(file, 'r')
+ while(!f.eof?)
+ w.insert('end', f.read(1000))
+ end
+ f.close
+end
+
+# textSearch --
+# Search for all instances of a given string in a text widget and
+# apply a given tag to each instance found.
+#
+# Arguments:
+# w - The window in which to search. Must be a text widget.
+# string - The string to search for. The search is done using
+# exact matching only; no special characters.
+# tag - Tag to apply to each instance of a matching string.
+
+def textSearch(w, string, tag)
+ tag.remove('0.0', 'end')
+ return if string == ""
+ cur = '1.0'
+ loop {
+ cur, len = w.search_with_length(string, cur, 'end')
+ break if cur == ""
+ tag.add(cur, "#{cur} + #{len} char")
+ cur = w.index("#{cur} + #{len} char")
+ }
+end
+
+# textToggle --
+# This method is invoked repeatedly to invoke two commands at
+# periodic intervals. It normally reschedules itself after each
+# execution but if an error occurs (e.g. because the window was
+# deleted) then it doesn't reschedule itself.
+#
+# Arguments:
+# cmd1 - Command to execute when method is called.
+# sleep1 - Ms to sleep after executing cmd1 before executing cmd2.
+# cmd2 - Command to execute in the *next* invocation of this method.
+# sleep2 - Ms to sleep after executing cmd2 before executing cmd1 again.
+
+def textToggle(cmd1,sleep1,cmd2,sleep2)
+ sleep_list = [sleep2, sleep1]
+ TkAfter.new(proc{sleep = sleep_list.shift; sleep_list.push(sleep); sleep},
+ -1, cmd1, cmd2).start(sleep1)
+end
+
+# toplevel widget ãŒå­˜åœ¨ã™ã‚Œã°å‰Šé™¤ã™ã‚‹
+if defined?($search_demo) && $search_demo
+ $search_demo.destroy
+ $search_demo = nil
+end
+
+# demo 用㮠toplevel widget を生æˆ
+$search_demo = TkToplevel.new {|w|
+ title("Text Demonstration - Search and Highlight")
+ iconname("search")
+ positionWindow(w)
+}
+
+base_frame = TkFrame.new($search_demo).pack(:fill=>:both, :expand=>true)
+
+# frame 生æˆ
+$search_buttons = TkFrame.new(base_frame) {|frame|
+ TkButton.new(frame) {
+ #text '了解'
+ text 'é–‰ã˜ã‚‹'
+ command proc{
+ tmppath = $search_demo
+ $search_demo = nil
+ tmppath.destroy
+ }
+ }.pack('side'=>'left', 'expand'=>'yes')
+
+ TkButton.new(frame) {
+ text 'コードå‚ç…§'
+ command proc{showCode 'search'}
+ }.pack('side'=>'left', 'expand'=>'yes')
+}
+$search_buttons.pack('side'=>'bottom', 'fill'=>'x', 'pady'=>'2m')
+
+# frame 生æˆ
+TkFrame.new(base_frame) {|f|
+ TkLabel.new(f, 'text'=>'ファイルå:',
+ 'width'=>13, 'anchor'=>'w').pack('side'=>'left')
+ $search_fileName = TkVariable.new
+ TkEntry.new(f, 'width'=>40,
+ 'textvariable'=>$search_fileName) {
+ pack('side'=>'left')
+ bind('Return', proc{textLoadFile($search_text, $search_fileName.value)
+ $search_string_entry.focus})
+ focus
+ }
+ TkButton.new(f, 'text'=>'読ã¿è¾¼ã¿',
+ 'command'=>proc{textLoadFile($search_text,
+ $search_fileName.value)})\
+ .pack('side'=>'left', 'pady'=>5, 'padx'=>10)
+}.pack('side'=>'top', 'fill'=>'x')
+
+TkFrame.new(base_frame) {|f|
+ TkLabel.new(f, 'text'=>'検索文字列:',
+ 'width'=>13, 'anchor'=>'w').pack('side'=>'left')
+ $search_searchString = TkVariable.new
+ $search_string_entry = TkEntry.new(f, 'width'=>40,
+ 'textvariable'=>$search_searchString) {
+ pack('side'=>'left')
+ bind('Return', proc{textSearch($search_text, $search_searchString.value,
+ $search_Tag)})
+ }
+ TkButton.new(f, 'text'=>'å転',
+ 'command'=>proc{textSearch($search_text,
+ $search_searchString.value,
+ $search_Tag)}) {
+ pack('side'=>'left', 'pady'=>5, 'padx'=>10)
+ }
+}.pack('side'=>'top', 'fill'=>'x')
+
+$search_text = TkText.new(base_frame, 'setgrid'=>true) {|t|
+ $search_Tag = TkTextTag.new(t)
+ TkScrollbar.new(base_frame, 'command'=>proc{|*args| t.yview(*args)}) {|sc|
+ t.yscrollcommand(proc{|first,last| sc.set first,last})
+ pack('side'=>'right', 'fill'=>'y')
+ }
+ pack('expand'=>'yes', 'fill'=>'both')
+}
+
+# Set up display styles for text highlighting.
+
+if TkWinfo.depth($search_demo) > 1
+ textToggle(proc{
+ $search_Tag.configure('background'=>'#ce5555',
+ 'foreground'=>'white')
+ },
+ 800,
+ proc{
+ $search_Tag.configure('background'=>'', 'foreground'=>'')
+ },
+ 200 )
+else
+ textToggle(proc{
+ $search_Tag.configure('background'=>'black',
+ 'foreground'=>'white')
+ },
+ 800,
+ proc{
+ $search_Tag.configure('background'=>'', 'foreground'=>'')
+ },
+ 200 )
+end
+$search_text.insert('1.0', "\
+ã“ã®ã‚¦ã‚£ãƒ³ãƒ‰ã‚¦ã¯æ¤œç´¢æ©Ÿæ§‹ã‚’実ç¾ã™ã‚‹ã®ã«ãƒ†ã‚­ã‚¹ãƒˆ widget ã®ã‚¿ã‚°æ©Ÿèƒ½ãŒã©ã® \
+よã†ã«ä½¿ã‚れるã®ã‹ã‚’デモã™ã‚‹ã‚‚ã®ã§ã™ã€‚ã¾ãšä¸Šã®ã‚¨ãƒ³ãƒˆãƒªã«ãƒ•ã‚¡ã‚¤ãƒ«åã‚’å…¥ \
+ã‚Œã€<リターン> を押ã™ã‹ã€Œãƒ­ãƒ¼ãƒ‰ã€ãƒœã‚¿ãƒ³ã‚’押ã—ã¦ãã ã•ã„。次ã«ãã®ä¸‹ã® \
+エントリã«æ–‡å­—列を入力ã—ã€<リターン> を押ã™ã‹ã€Œå転ã€ãƒœã‚¿ãƒ³ã‚’押ã—ã¦ã \
+ã ã•ã„。ã™ã‚‹ã¨ãƒ•ã‚¡ã‚¤ãƒ«ä¸­ã®ã€æ¤œç´¢æ–‡å­—列ã¨ä¸€è‡´ã™ã‚‹éƒ¨åˆ†ã«å…¨ã¦ \"search_Tag\" \
+ã¨ã„ã†ã‚¿ã‚°ãŒã¤ã‘られã€ã‚¿ã‚°ã®è¡¨ç¤ºå±žæ€§ã¨ã—ã¦ãã®æ–‡å­—列ãŒç‚¹æ»…ã™ã‚‹ã‚ˆã†ã« \
+設定ã•ã‚Œã¾ã™ã€‚\n")
+$search_text.insert('end', "\
+ファイル読ã¿è¾¼ã¿ã®ã‚«ãƒ¬ãƒ³ãƒˆãƒ‡ã‚£ãƒ¬ã‚¯ãƒˆãƒªã¯ \"#{Dir.pwd}\" ã§ã™ã€‚\
+")
+$search_text.set_insert '0.0'
+
+$search_fileName.value = ''
+$search_searchString.value = ''
+
+$search_text.width = 60
+$search_text.height = 20
diff --git a/jni/ruby/ext/tk/sample/demos-jp/spin.rb b/jni/ruby/ext/tk/sample/demos-jp/spin.rb
new file mode 100644
index 0000000..fd51a3f
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/demos-jp/spin.rb
@@ -0,0 +1,71 @@
+# -*- coding: utf-8 -*-
+#
+# spin.rb --
+#
+# This demonstration script creates several spinbox widgets.
+#
+# based on Tcl/Tk8.4.4 widget demos
+
+if defined?($spin_demo) && $spin_demo
+ $spin_demo.destroy
+ $spin_demo = nil
+end
+
+$spin_demo = TkToplevel.new {|w|
+ title("Spinbox Demonstration")
+ iconname("spin")
+ positionWindow(w)
+}
+
+base_frame = TkFrame.new($spin_demo).pack(:fill=>:both, :expand=>true)
+
+TkLabel.new(base_frame,
+ :font=>$font, :wraplength=>'5i', :justify=>:left,
+ :text=><<EOL).pack(:side=>:top)
+下ã«ã¯ï¼“種類ã®ã‚¹ãƒ”ンボックスãŒè¡¨ç¤ºã•ã‚Œã¦ã„ã¾ã™ã€‚
+ãã‚Œãžã‚Œã€ãƒžã‚¦ã‚¹ã§é¸æŠžã—ã¦æ–‡å­—を入力ã™ã‚‹ã“ã¨ãŒã§ãã¾ã™ã€‚
+編集æ“作ã¨ã—ã¦ã¯ã€Emacs å½¢å¼ã®å¤šãã«åŠ ãˆã¦ã€ä¸€èˆ¬çš„ãª
+Motif å½¢å¼ã®ã‚­ãƒ¼æ“作ãŒã‚µãƒãƒ¼ãƒˆã•ã‚Œã¦ã„ã¾ã™ã€‚ãŸã¨ãˆã°ã€
+Backspace 㨠Control-h ã¨ã¯å…¥åŠ›ã‚«ãƒ¼ã‚½ãƒ«ã®å·¦å´ã®æ–‡å­—ã‚’
+削除ã—ã€Delete 㨠Control-d ã¨ã¯å³å´ã®æ–‡å­—を削除ã—ã¾ã™ã€‚
+入力枠ã®é•·ã•ã‚’越ãˆã‚‹ã‚ˆã†ãªé•·ã„文字列を入力ã—ãŸå ´åˆã«ã¯ã€
+マウスã®ãƒœã‚¿ãƒ³ï¼’を押ã—ã¦ãƒ‰ãƒ©ãƒƒã‚°ã™ã‚‹ã“ã¨ã§ã€å…¥åŠ›æ–‡å­—列
+をスキャンã™ã‚‹ã“ã¨ãŒå¯èƒ½ã§ã™ã€‚
+ãªãŠã€æœ€åˆã®ã‚¹ãƒ”ンボックスã¯ã€æ•´æ•°å€¤ã¨ã¿ãªã•ã‚Œã‚‹ã‚ˆã†ãª
+文字列ã—ã‹å…¥åŠ›ãŒè¨±ã•ã‚Œãªã„ã“ã¨ã«æ³¨æ„ã—ã¦ãã ã•ã„。ã¾ãŸã€
+3番目ã®ã‚¹ãƒ”ンボックスã§é¸æŠžå€™è£œã«ç¾ã‚Œã‚‹ã®ã¯ã‚ªãƒ¼ã‚¹ãƒˆãƒ©
+リアã®éƒ½å¸‚åã®ãƒªã‚¹ãƒˆã¨ãªã£ã¦ã„ã¾ã™ã€‚
+ã‚‚ã—ã‚ãªãŸãŒä½¿ã£ã¦ã„ã‚‹ Ruby ã«ãƒªãƒ³ã‚¯ã•ã‚Œã¦ã„ã‚‹ Tk ライ
+ブラリ㌠spinbox ウィジェットを実装ã—ã¦ã„ãªã„å ´åˆã€ã“ã®
+デモã¯ã†ã¾ãå‹•ã‹ãªã„ã¯ãšã§ã™ã€‚ãã®å ´åˆã«ã¯ spinbox ウィ
+ジェットãŒå®Ÿè£…ã•ã‚Œã¦ã„るよã†ãªã‚ˆã‚Šæ–°ã—ã„ãƒãƒ¼ã‚¸ãƒ§ãƒ³ã® Tk
+を組ã¿åˆã‚ã›ã¦è©¦ã™ã‚ˆã†ã«ã—ã¦ãã ã•ã„。
+EOL
+
+TkFrame.new(base_frame){|f|
+ pack(:side=>:bottom, :fill=>:x, :pady=>'2m')
+
+ TkButton.new(f, :text=>'é–‰ã˜ã‚‹', :width=>15, :command=>proc{
+ $spin_demo.destroy
+ $spin_demo = nil
+ }).pack(:side=>:left, :expand=>true)
+
+ TkButton.new(f, :text=>'コードå‚ç…§', :width=>15, :command=>proc{
+ showCode 'spin'
+ }).pack(:side=>:left, :expand=>true)
+}
+
+australianCities = [
+ 'Canberra', 'Sydney', 'Melbourne', 'Perth', 'Adelaide',
+ 'Brisbane', 'Hobart', 'Darwin', 'Alice Springs'
+]
+
+[
+ TkSpinbox.new(base_frame, :from=>1, :to=>10, :width=>10, :validate=>:key,
+ :validatecommand=>[
+ proc{|s| s == '' || /^[+-]?\d+$/ =~ s }, '%P'
+ ]),
+ TkSpinbox.new(base_frame, :from=>0, :to=>3, :increment=>0.5,
+ :format=>'%05.2f', :width=>10),
+ TkSpinbox.new(base_frame, :values=>australianCities, :width=>10)
+].each{|sbox| sbox.pack(:side=>:top, :pady=>5, :padx=>10)}
diff --git a/jni/ruby/ext/tk/sample/demos-jp/square b/jni/ruby/ext/tk/sample/demos-jp/square
new file mode 100644
index 0000000..bb66282
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/demos-jp/square
@@ -0,0 +1,81 @@
+#!/usr/bin/env ruby
+
+# square --
+# This script generates a demo application containing only
+# a "square" widget. It's only usable if Tk has been compiled
+# with tkSquare.c and with the -DSQUARE_DEMO compiler switch.
+# This demo arranges the following bindings for the widget:
+#
+# Button-1 press/drag: moves square to mouse
+# "a": toggle size animation on/off
+#
+
+require 'tk'
+require 'tkafter'
+
+class TkSquare<TkWindow
+ def create_self
+ begin
+ tk_call 'square', path
+ rescue
+ STDERR.print "\nSorry. Your Tk interpreter does not contain " +
+ 'a "square" demonstration widget.' +
+ "\n ( See documents included the Tcl/Tk source archive. )\n\n"
+ exit
+ end
+ end
+ def size(amount=nil)
+ if amount
+ tk_send 'size', amount
+ else
+ number(tk_send('size'))
+ end
+ end
+ def position(x,y)
+ tk_send 'position', x, y
+ end
+end
+
+$s = TkSquare.new{
+ pack('expand'=>'yes', 'fill'=>'both')
+ bind('1', proc{|x,y| center(x,y)}, '%s %y')
+ bind('B1-Motion', proc{|x,y| center(x,y)}, '%s %y')
+ bind('a', proc{animate})
+ focus
+}
+TkRoot.new.minsize(1,1)
+
+# The procedure below centers the square on a given position.
+
+def center(x,y)
+ a = $s.size
+ $s.position(x-(a/2), y-(a/2))
+end
+
+# The procedures below provide a simple form of animation where
+# the box changes size in a pulsing pattern: larger, smaller, larger,
+# and so on.
+
+$inc = 0
+
+def timer_proc
+ a = $s.size
+ return if $inc == 0
+ $inc = -3 if a >= 40
+ $inc = 3 if a <= 10
+ $s.size(a+$inc)
+end
+
+$timer = TkAfter.new(30, -1, proc{timer_proc})
+
+def animate
+ if $inc == 0
+ $inc = 3
+ $timer.start
+ else
+ $inc = 0
+ $timer.stop
+ end
+end
+
+Tk.mainloop
diff --git a/jni/ruby/ext/tk/sample/demos-jp/states.rb b/jni/ruby/ext/tk/sample/demos-jp/states.rb
new file mode 100644
index 0000000..2966e6d
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/demos-jp/states.rb
@@ -0,0 +1,74 @@
+# -*- coding: utf-8 -*-
+#
+# listbox widget demo 'states' (called by 'widget')
+#
+
+# toplevel widget ãŒå­˜åœ¨ã™ã‚Œã°å‰Šé™¤ã™ã‚‹
+if defined?($states_demo) && $states_demo
+ $states_demo.destroy
+ $states_demo = nil
+end
+
+# demo 用㮠toplevel widget を生æˆ
+$states_demo = TkToplevel.new {|w|
+ title("Listbox Demonstration (states)")
+ iconname("states")
+ positionWindow(w)
+}
+
+base_frame = TkFrame.new($states_demo).pack(:fill=>:both, :expand=>true)
+
+# label 生æˆ
+msg = TkLabel.new(base_frame) {
+ font $font
+ wraplength '4i'
+ justify 'left'
+ text "下ã«ã‚ã‚‹ã®ã¯éƒ½é“府県åãŒå…¥ã£ãŸã‚¹ã‚¯ãƒ­ãƒ¼ãƒ«ãƒãƒ¼ä»˜ã®ãƒªã‚¹ãƒˆãƒœãƒƒã‚¯ã‚¹ã§ã™ã€‚リストをスクロールã•ã›ã‚‹ã®ã¯ã‚¹ã‚¯ãƒ­ãƒ¼ãƒ«ãƒãƒ¼ã§ã‚‚ã§ãã¾ã™ã—ã€ãƒªã‚¹ãƒˆãƒœãƒƒã‚¯ã‚¹ã®ä¸­ã§ãƒžã‚¦ã‚¹ã®ãƒœã‚¿ãƒ³2(中ボタン)を押ã—ãŸã¾ã¾ãƒ‰ãƒ©ãƒƒã‚°ã—ã¦ã‚‚ã§ãã¾ã™ã€‚"
+}
+msg.pack('side'=>'top')
+
+# frame 生æˆ
+TkFrame.new(base_frame) {|frame|
+ TkButton.new(frame) {
+ #text '了解'
+ text 'é–‰ã˜ã‚‹'
+ command proc{
+ tmppath = $states_demo
+ $states_demo = nil
+ tmppath.destroy
+ }
+ }.pack('side'=>'left', 'expand'=>'yes')
+
+ TkButton.new(frame) {
+ text 'コードå‚ç…§'
+ command proc{showCode 'states'}
+ }.pack('side'=>'left', 'expand'=>'yes')
+
+}.pack('side'=>'bottom', 'fill'=>'x', 'pady'=>'2m')
+
+# frame 生æˆ
+states_lbox = nil
+TkFrame.new(base_frame, 'borderwidth'=>'.5c') {|w|
+ s = TkScrollbar.new(w)
+ states_lbox = TkListbox.new(w) {
+ setgrid 1
+ height 12
+ yscrollcommand proc{|first,last| s.set first,last}
+ }
+ s.command(proc{|*args| states_lbox.yview(*args)})
+ s.pack('side'=>'right', 'fill'=>'y')
+ states_lbox.pack('side'=>'left', 'expand'=>1, 'fill'=>'both')
+}.pack('side'=>'top', 'expand'=>'yes', 'fill'=>'y')
+
+ins_data = [
+ '愛知','é’森','秋田','石å·','茨城','岩手','愛媛',
+ '大分','大阪','岡山','沖縄','香å·','鹿å…島','神奈å·',
+ 'å²é˜œ','京都','熊本','群馬','高知','埼玉','ä½è³€',
+ '滋賀','é™å²¡','島根','åƒè‘‰','æ±äº¬','徳島','栃木',
+ 'é³¥å–','富山','é•·å´Ž','長野','奈良','新潟','兵庫',
+ '広島','ç¦äº•','ç¦å²¡','ç¦å³¶','北海é“','三é‡','宮城',
+ '宮崎','山形','å±±å£','山梨','和歌山'
+]
+
+states_lbox.insert(0, *ins_data)
+
diff --git a/jni/ruby/ext/tk/sample/demos-jp/style.rb b/jni/ruby/ext/tk/sample/demos-jp/style.rb
new file mode 100644
index 0000000..813fde7
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/demos-jp/style.rb
@@ -0,0 +1,270 @@
+# -*- coding: utf-8 -*-
+#
+# text (display styles) widget demo (called by 'widget')
+#
+
+# toplevel widget ãŒå­˜åœ¨ã™ã‚Œã°å‰Šé™¤ã™ã‚‹
+if defined?($style_demo) && $style_demo
+ $style_demo.destroy
+ $style_demo = nil
+end
+
+
+# demo 用㮠toplevel widget を生æˆ
+$style_demo = TkToplevel.new {|w|
+ title("Text Demonstration - Display Styles")
+ iconname("style")
+ positionWindow(w)
+}
+
+base_frame = TkFrame.new($style_demo).pack(:fill=>:both, :expand=>true)
+
+# frame 生æˆ
+TkFrame.new(base_frame) {|frame|
+ TkButton.new(frame) {
+ #text '了解'
+ text 'é–‰ã˜ã‚‹'
+ command proc{
+ tmppath = $style_demo
+ $style_demo = nil
+ tmppath.destroy
+ }
+ }.pack('side'=>'left', 'expand'=>'yes')
+
+ TkButton.new(frame) {
+ text 'コードå‚ç…§'
+ command proc{showCode 'style'}
+ }.pack('side'=>'left', 'expand'=>'yes')
+}.pack('side'=>'bottom', 'fill'=>'x', 'pady'=>'2m')
+
+
+# text 生æˆ
+txt = TkText.new(base_frame){|t|
+ # 生æˆ
+ setgrid 'true'
+ #width 70
+ #height 32
+ wrap 'word'
+ font $font
+ TkScrollbar.new(base_frame) {|s|
+ pack('side'=>'right', 'fill'=>'y')
+ command proc{|*args| t.yview(*args)}
+ t.yscrollcommand proc{|first,last| s.set first,last}
+ }
+ pack('expand'=>'yes', 'fill'=>'both')
+
+ # テキストタグ設定 (フォント関連)
+ family = 'Courier'
+
+ if $tk_version =~ /^4.*/
+ style_tag_bold = TkTextTag.new(t, 'font'=>'-*-Courier-Bold-O-Normal--*-120-*-*-*-*-*-*')
+ style_tag_big = TkTextTag.new(t, 'font'=>'-*-Courier-Bold-R-Normal--*-140-*-*-*-*-*-*', 'kanjifont'=>$msg_kanji_font)
+ style_tag_verybig = TkTextTag.new(t, 'font'=>'-*-Helvetica-Bold-R-Normal--*-240-*-*-*-*-*-*')
+ # style_tag_small = TkTextTag.new(t, 'font'=>'-Adobe-Helvetica-Bold-R-Normal-*-100-*', 'kanjifont'=>$kanji_font)
+ style_tag_small = TkTextTag.new(t, 'font'=>'-Adobe-Helvetica-Bold-R-Normal-*-100-*')
+ else
+ style_tag_bold = TkTextTag.new(t, 'font'=>[family, 12, :bold, :italic])
+ style_tag_big = TkTextTag.new(t, 'font'=>[family, 14, :bold])
+ style_tag_verybig = TkTextTag.new(t, 'font'=>['Helvetica', 24, :bold])
+ style_tag_small = TkTextTag.new(t, 'font'=>'Times 8 bold')
+ end
+###
+# case($tk_version)
+# when /^4.*/
+# style_tag_big = TkTextTag.new(t, 'font'=>'-*-Courier-Bold-R-Normal--*-140-*-*-*-*-*-*', 'kanjifont'=>$msg_kanji_font)
+# style_tag_small = TkTextTag.new(t, 'font'=>'-Adobe-Helvetica-Bold-R-Normal-*-100-*', 'kanjifont'=>$kanji_font)
+# when /^8.*/
+# unless $style_demo_do_first
+# $style_demo_do_first = true
+# Tk.tk_call('font', 'create', '@bigascii',
+# '-copy', '-*-Courier-Bold-R-Normal--*-140-*-*-*-*-*-*')
+# Tk.tk_call('font', 'create', '@smallascii',
+# '-copy', '-Adobe-Helvetica-Bold-R-Normal-*-100-*')
+# Tk.tk_call('font', 'create', '@cBigFont',
+# '-compound', '@bigascii @msg_knj')
+# Tk.tk_call('font', 'create', '@cSmallFont',
+# '-compound', '@smallascii @kanji')
+# end
+# style_tag_big = TkTextTag.new(t, 'font'=>'@cBigFont')
+# style_tag_small = TkTextTag.new(t, 'font'=>'@cSmallFont')
+# end
+
+ # テキストタグ設定 (色,レリーフ関連)
+ if TkWinfo.depth($root).to_i > 1
+ style_tag_color1 = TkTextTag.new(t, 'background'=>'#a0b7ce')
+ style_tag_color2 = TkTextTag.new(t, 'foreground'=>'red')
+ style_tag_raised = TkTextTag.new(t, 'relief'=>'raised', 'borderwidth'=>1)
+ style_tag_sunken = TkTextTag.new(t, 'relief'=>'sunken', 'borderwidth'=>1)
+ else
+ style_tag_color1 = TkTextTag.new(t, 'background'=>'black',
+ 'foreground'=>'white')
+ style_tag_color2 = TkTextTag.new(t, 'background'=>'black',
+ 'foreground'=>'white')
+ style_tag_raised = TkTextTag.new(t, 'background'=>'white',
+ 'relief'=>'raised', 'borderwidth'=>1)
+ style_tag_sunken = TkTextTag.new(t, 'background'=>'white',
+ 'relief'=>'sunken', 'borderwidth'=>1)
+ end
+
+ # テキストタグ設定 (ãã®ä»–)
+ if $tk_version =~ /^4\.[01]/
+ style_tag_bgstipple = TkTextTag.new(t, 'background'=>'black',
+ 'borderwidth'=>0,
+ 'bgstipple'=>'gray25')
+ else
+ style_tag_bgstipple = TkTextTag.new(t, 'background'=>'black',
+ 'borderwidth'=>0,
+ 'bgstipple'=>'gray12')
+ end
+ style_tag_fgstipple = TkTextTag.new(t, 'fgstipple'=>'gray50')
+ style_tag_underline = TkTextTag.new(t, 'underline'=>'on')
+ style_tag_overstrike = TkTextTag.new(t, 'overstrike'=>'on')
+ style_tag_right = TkTextTag.new(t, 'justify'=>'right')
+ style_tag_center = TkTextTag.new(t, 'justify'=>'center')
+ if $tk_version =~ /^4.*/
+ style_tag_super = TkTextTag.new(t, 'offset'=>'4p', 'font'=>'-Adobe-Courier-Medium-R-Normal--*-100-*-*-*-*-*-*')
+ style_tag_sub = TkTextTag.new(t, 'offset'=>'-2p', 'font'=>'-Adobe-Courier-Medium-R-Normal--*-100-*-*-*-*-*-*')
+ else
+ style_tag_super = TkTextTag.new(t, 'offset'=>'4p', 'font'=>[family, 10])
+ style_tag_sub = TkTextTag.new(t, 'offset'=>'-2p', 'font'=>[family, 10])
+ end
+ style_tag_margins = TkTextTag.new(t, 'lmargin1'=>'12m', 'lmargin2'=>'6m',
+ 'rmargin'=>'10m')
+ style_tag_spacing = TkTextTag.new(t, 'spacing1'=>'10p', 'spacing2'=>'2p',
+ 'lmargin1'=>'12m', 'lmargin2'=>'6m',
+ 'rmargin'=>'10m')
+
+ # テキスト挿入
+ insert('end', 'ã“ã®ã‚ˆã†ã«ãƒ†ã‚­ã‚¹ãƒˆ widget ã¯æƒ…報を様々ãªã‚¹ã‚¿ã‚¤ãƒ«ã§è¡¨ç¤ºã™ã‚‹ã“ã¨
+ãŒã§ãã¾ã™ã€‚')
+ insert('end', 'ã‚¿ã‚°', style_tag_big)
+ insert('end', 'ã¨ã„ã†ãƒ¡ã‚«ãƒ‹ã‚ºãƒ ã§ã‚³ãƒ³ãƒˆãƒ­ãƒ¼ãƒ«ã•ã‚Œã¾ã™ã€‚
+ã‚¿ã‚°ã¨ã¯ãƒ†ã‚­ã‚¹ãƒˆ widget 内ã®ã‚る文字 (ã®ç¯„囲)ã«å¯¾ã—ã¦é©ç”¨ã§ãã‚‹
+å˜ãªã‚‹åå‰ã®ã“ã¨ã§ã™ã€‚ã‚¿ã‚°ã¯æ§˜ã€…ãªè¡¨ç¤ºã‚¹ã‚¿ã‚¤ãƒ«ã«è¨­å®šã§ãã¾ã™ã€‚
+設定ã™ã‚‹ã¨ã€ãã®ã‚¿ã‚°ã®ã¤ã„ãŸæ–‡å­—ã¯æŒ‡å®šã—ãŸã‚¹ã‚¿ã‚¤ãƒ«ã§è¡¨ç¤ºã•ã‚Œã‚‹
+よã†ã«ãªã‚Šã¾ã™ã€‚使用ã§ãる表示スタイルã¯æ¬¡ã®é€šã‚Šã§ã™ã€‚
+')
+ insert('end', '
+1. フォント', style_tag_big)
+ insert('end', ' ã©ã‚“㪠X ã®ãƒ•ã‚©ãƒ³ãƒˆã§ã‚‚使ãˆã¾ã™ã€‚')
+ insert('end', 'large', style_tag_verybig)
+ insert('end', '
+ã¨ã‹')
+# insert('end', 'å°ã•ã„', style_tag_small)
+ insert('end', 'small', style_tag_small)
+ insert('end', 'ã¨ã‹ã€‚
+')
+ insert('end', '
+2. 色', style_tag_big)
+ insert('end', ' ')
+ insert('end', '背景色', style_tag_color1)
+ insert('end', 'ã‚‚')
+ insert('end', 'å‰æ™¯è‰²', style_tag_color2)
+ insert('end', 'ã‚‚')
+ insert('end', '両方', style_tag_color1, style_tag_color2)
+ insert('end', 'ã¨ã‚‚変ãˆã‚‹ã“ã¨ãŒã§ãã¾ã™ã€‚
+')
+ insert('end', '
+3. 網ã‹ã‘', style_tag_big)
+ insert('end', ' ã“ã®ã‚ˆã†ã«æç”»ã®éš›ã«')
+ insert('end', '背景も', style_tag_bgstipple)
+ insert('end', '文字も', style_tag_fgstipple)
+ insert('end', 'å˜ãªã‚‹å¡—ã‚Šã¤ã¶ã—
+ã§ãªãã€ç¶²ã‹ã‘を使ã†ã“ã¨ãŒã§ãã¾ã™ã€‚
+')
+ insert('end', '
+4. 下線', style_tag_big)
+ insert('end', ' ã“ã®ã‚ˆã†ã«')
+ insert('end', '文字ã«ä¸‹ç·šã‚’引ã', style_tag_underline)
+ insert('end', 'ã“ã¨ãŒã§ãã¾ã™ã€‚
+')
+ insert('end', '
+5. 打ã¡æ¶ˆã—ç·š', style_tag_big)
+ insert('end', ' ã“ã®ã‚ˆã†ã«')
+ insert('end', '文字ã«é‡ã­ã¦ç·šã‚’引ã', style_tag_overstrike)
+ insert('end', 'ã“ã¨ãŒã§ãã¾ã™ã€‚
+')
+ insert('end', '
+6. 3D 効果', style_tag_big)
+ insert('end', ' 背景ã«æž ã‚’ã¤ã‘ã¦ã€æ–‡å­—ã‚’')
+ insert('end', '飛ã³å‡ºã™', style_tag_raised)
+ insert('end', 'よã†ã«ã—ãŸã‚Š')
+ insert('end', '沈む', style_tag_sunken)
+ insert('end', '
+よã†ã«ã§ãã¾ã™ã€‚
+')
+ insert('end', '
+7. è¡Œæƒãˆ', style_tag_big)
+ insert('end', ' ã“ã®ã‚ˆã†ã«è¡Œã‚’
+')
+ insert('end', 'å·¦ã«æƒãˆãŸã‚Š
+')
+ insert('end', 'å³ã«æƒãˆãŸã‚Š
+', style_tag_right)
+ insert('end', '真中ã«æƒãˆãŸã‚Šã§ãã¾ã™ã€‚
+', style_tag_center)
+ insert('end', '
+8. 肩付ã文字ã¨æ·»å­—', style_tag_big)
+ insert('end', ' 10')
+ insert('end', 'n', style_tag_super)
+ insert('end', ' ã®ã‚ˆã†ã«è‚©ä»˜ã文字ã®åŠ¹æžœã‚„ã€')
+ insert('end', '
+X')
+ insert('end', 'i', style_tag_sub)
+ insert('end', 'ã®ã‚ˆã†ã«æ·»å­—ã®åŠ¹æžœã‚’出ã™ã“ã¨ãŒã§ãã¾ã™ã€‚
+')
+ insert('end', '
+9. マージン', style_tag_big)
+ insert('end', 'テキストã®å·¦å´ã«ä½™åˆ†ãªç©ºç™½ã‚’ç½®ãã“ã¨ãŒã§ãã¾ã™:
+')
+ insert('end', 'ã“ã®æ®µè½ã¯ãƒžãƒ¼ã‚¸ãƒ³ã®ä½¿ç”¨ä¾‹ã§ã™ã€‚スクリーン',
+ style_tag_margins)
+ insert('end', '上ã§æŠ˜ã‚Šè¿”ã•ã‚Œã¦è¡¨ç¤ºã•ã‚Œã¦ã„ã‚‹1è¡Œã®ãƒ†ã‚­ã‚¹ãƒˆã§ã™ã€‚',
+ style_tag_margins)
+ insert('end', 'å·¦å´ã«ã¯2種類ã®ãƒžãƒ¼ã‚¸ãƒ³ã‚’æŒã¡ã¾ã™ã€‚', style_tag_margins)
+ insert('end', '1行目ã«å¯¾ã™ã‚‹ã‚‚ã®ã¨ã€', style_tag_margins)
+ insert('end', '2行目以é™ã®é€£ç¶šã—ãŸãƒžãƒ¼ã‚¸ãƒ³', style_tag_margins)
+ insert('end', 'ã§ã™ã€‚ã¾ãŸå³å´ã«ã‚‚マージンãŒã‚ã‚Šã¾ã™ã€‚', style_tag_margins)
+ insert('end', 'è¡Œã®æŠ˜ã‚Šè¿”ã—ä½ç½®ã‚’決ã‚ã‚‹ãŸã‚ã«ä½¿ç”¨ã™ã‚‹ã“ã¨ãŒã§ãã¾ã™ã€‚
+', style_tag_margins)
+ insert('end', '
+10. スペーシング', style_tag_big)
+ insert('end', '3ã¤ã®ãƒ‘ラメータã§è¡Œã®ã‚¹ãƒšãƒ¼ã‚·ãƒ³ã‚°ã‚’')
+ insert('end', '制御ã™
+ã‚‹ã“ã¨ãŒã§ãã¾ã™ã€‚Spacing1ã§ã€è¡Œã®')
+ insert('end', '上ã«ã©ã®ãらã„ã®ç©ºé–“ã‚’ç½®ãã‹ã€
+spacing3')
+ insert('end', 'ã§è¡Œã®ä¸‹ã«ã©ã®ãらã„ã®ç©ºé–“ã‚’ç½®ãã‹ã€')
+ insert('end', 'è¡ŒãŒæŠ˜ã‚Šè¿”ã•ã‚Œã¦ã„ã‚‹ãªã‚‰
+ã°ã€spacing2ã§ã€')
+ insert('end', 'テキスト行を生æˆã—ã¦ã„ã‚‹è¡Œã®é–“ã«ã©ã®ãらã„')
+ insert('end', 'ã®ç©ºé–“ã‚’ç½®
+ãã‹ã‚’示ã—ã¾ã™ã€‚
+')
+ insert('end', 'ã“れらã®ã‚¤ãƒ³ãƒ‡ãƒ³ãƒˆã•ã‚ŒãŸæ®µè½ã¯ã©ã®ã‚ˆã†ã«',
+ style_tag_spacing)
+ insert('end', 'スペーシングãŒãŒè¡Œã‚れるã®ã‹ã‚’示ã—ã¾ã™ã€‚',
+ style_tag_spacing)
+ insert('end', 'å„段è½ã¯å®Ÿéš›ã¯ãƒ†ã‚­ã‚¹ãƒˆwidget', style_tag_spacing)
+ insert('end', 'ã®1è¡Œã§ã€widgetã«ã‚ˆã£ã¦æŠ˜ã‚Šç•³ã¾ã‚Œã¦ã„ã¾ã™ã€‚
+', style_tag_spacing)
+ insert('end', 'Spacing1ã¯ã“ã®ãƒ†ã‚­ã‚¹ãƒˆã§ã¯10pointã«', style_tag_spacing)
+ insert('end', '設定ã•ã‚Œã¦ã„ã¾ã™ã€‚', style_tag_spacing)
+ insert('end', 'ã“ã‚Œã«ã‚ˆã‚Šã€æ®µè½ã®é–“ã«å¤§ããªé–“éš”ãŒ', style_tag_spacing)
+ insert('end', '存在ã—ã¦ã„ã¾ã™ã€‚', style_tag_spacing)
+ insert('end', 'Spacing2ã¯2pointã«è¨­å®šã•ã‚Œã¦ã„ã¾ã™ã€‚', style_tag_spacing)
+ insert('end', 'ã“ã‚Œã§æ®µè½ã®ä¸­ã«ã»ã‚“ã®å°‘ã—é–“éš”ãŒå­˜åœ¨ã—ã¦ã„ã¾ã™ã€‚',
+ style_tag_spacing)
+ insert('end', 'Spacing3ã¯ã“ã®ä¾‹ã§ã¯ä½¿ç”¨ã•ã‚Œã¦ã„ã¾ã›ã‚“。
+', style_tag_spacing)
+ insert('end', 'é–“éš”ãŒã©ã“ã«ã‚ã‚‹ã‹ã‚’見ãŸã‘ã‚Œã°ã€ã“れらã®æ®µè½ã®',
+ style_tag_spacing)
+ insert('end', 'ãªã‹ã§ãƒ†ã‚­ã‚¹ãƒˆã‚’é¸æŠžã—ã¦ãã ã•ã„。é¸æŠžã®', style_tag_spacing)
+ insert('end', 'å転ã—ãŸéƒ¨åˆ†ã«ã¯ä½™åˆ†ã«ã¨ã‚‰ã‚ŒãŸé–“éš”ãŒ', style_tag_spacing)
+ insert('end', 'å«ã¾ã‚Œã¦ã„ã¾ã™ã€‚
+', style_tag_spacing)
+
+}
+
+txt.width 70
+txt.height 32
diff --git a/jni/ruby/ext/tk/sample/demos-jp/tcolor b/jni/ruby/ext/tk/sample/demos-jp/tcolor
new file mode 100644
index 0000000..f2d5458
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/demos-jp/tcolor
@@ -0,0 +1,534 @@
+#!/usr/bin/env ruby
+# -*- coding: utf-8 -*-
+#
+# tcolor --
+# ã“ã®ã‚¹ã‚¯ãƒªãƒ—トã¯RGB,HSB,CYMå½¢å¼ã‚’サãƒãƒ¼ãƒˆã™ã‚‹
+# 簡易カラーエディタã§ã™ã€‚
+#
+# Copyright (C) 1998 Takaaki Tateishi(ttate@jaist.ac.jp)
+# last update: Thu Jun 18 06:32:35 JST 1998
+#
+
+# ã¾ãšã¯tk.rbを読ã¿è¾¼ã‚€ã€‚
+
+require "tk"
+
+
+# Tkã«ã‚ˆã£ã¦å¤‰æ›´ã•ã‚Œã‚‹å¤‰æ•°ã¯TkVariableã®ã‚¤ãƒ³ã‚¹ã‚¿ãƒ³ã‚¹ã‚’使ã†ã€‚
+
+$colorSpace = TkVariable.new(:rgb)
+$master = nil
+$red = 65535
+$green = 0
+$blue = 0
+$color = "#ffff00000000"
+$updating = TkVariable.new(0)
+$autoUpdate = TkVariable.new(1)
+$name = TkVariable.new($color)
+$command = TkVariable.new("print(%%,\"\n\")")
+# $command = TkVariable.new("")
+$label1 = TkVariable.new("label1")
+$label2 = TkVariable.new("label2")
+$label3 = TkVariable.new("label3")
+
+
+# リソースデータベースã®è¨­å®š
+if (TkVarAccess.new('tcl_platform')['platform'] == 'unix')
+ TkOptionDB.add('*Entry.background', 'white')
+end
+
+
+# å„イベント用ã®ãƒ¡ã‚½ãƒƒãƒ‰
+
+def rgbToHsv(red,green,blue)
+
+ if ( red > green )
+ max = red
+ min = green
+ else
+ max = green
+ min = red
+ end
+
+ if ( blue > max )
+ max = blue
+ else
+ if ( blue < min )
+ min = blue
+ end
+ end
+
+ range = max - min
+
+ if ( max == 0 )
+ sat = 0.0
+ else
+ sat = (max-min)/max
+ end
+
+ if ( sat == 0 )
+ hue = 0.0
+ else
+ rc = (max-red)/range
+ gc = (max-green)/range
+ bc = (max-blue)/range
+ if ( red == max )
+ hue = 0.166667 * (bc - gc)
+ else
+ if ( green == max )
+ hue = 0.166667 * (2.0 + rc - bc)
+ else
+ hue = 0.166667 * (4.0 + gc - rc)
+ end
+ end
+ if ( hue < 0.0 )
+ hue = hue + 1.0
+ end
+ end
+
+ [hue,sat,max/65535]
+end
+
+
+def hsbToRgb(hue,sat,value)
+ v = 65535.0 * value
+ if( sat == 0 )
+ ans = [v,v,v]
+ else
+ hue = hue*6.0
+ if ( hue >= 6 )
+ hue = 0.0
+ end
+ i = hue.to_i
+ f = hue - i
+ p = 65535.0 * value * (1.0 - sat)
+ q = 65535.0 * value * (1.0 - (sat * f))
+ t = 65535.0 * value * (1.0 - (sat * (1.0 - f)))
+ case i
+ when 0
+ ans = [v,t,p]
+ when 1
+ ans = [q,v,p]
+ when 2
+ ans = [p,v,t]
+ when 3
+ ans = [p,q,v]
+ when 4
+ ans = [t,p,v]
+ when 5
+ ans = [v,p,q]
+ else
+ raise(eException,"i value #{i} is out of range")
+ end
+ end
+ return ans
+end
+
+
+def _null_binding
+ Module.new.instance_eval{binding}
+end
+private :_null_binding
+
+def doUpdate
+ newCmd = $command.to_s.gsub("%%","\"#{$color}\"")
+ eval(newCmd, _null_binding)
+end
+
+
+def tc_scaleChanged
+ if( $updating.to_i == 1 )
+ return
+ end
+
+ $master = :scale if $master == nil
+
+ scale1 = $root.middle.middle.scale1
+ scale2 = $root.middle.middle.scale2
+ scale3 = $root.middle.middle.scale3
+
+ case $colorSpace.value.intern
+ when :rgb
+ $red = (scale1.get * 65.535).to_i
+ $green = (scale2.get * 65.535).to_i
+ $blue = (scale3.get * 65.535).to_i
+ when :cmy
+ $red = (65535 - scale1.get * 65.535).to_i
+ $green = (65535 - scale2.get * 65.535).to_i
+ $blue = (65535 - scale3.get * 65.535).to_i
+ when :hsb
+ list = hsbToRgb(scale1.get / 1000.0,
+ scale2.get / 1000.0,
+ scale3.get / 1000.0)
+ $red = list[0]
+ $green = list[1]
+ $blue = list[2]
+ else
+ raise(Exception,"unknown colorSpace")
+ end
+ $color = format("#%04x%04x%04x",$red.to_i,$green.to_i,$blue.to_i)
+ $name.value = $color if $master == :scale
+ $root.middle.right.set_color($color)
+ if( $autoUpdate.to_i == 1 )
+ doUpdate
+ end
+ Tk.update(true)
+ $master = nil if $master == :scale
+end
+
+
+def tc_setScales
+ $updating.value = 1
+
+ scale1 = $root.middle.middle.scale1
+ scale2 = $root.middle.middle.scale2
+ scale3 = $root.middle.middle.scale3
+
+ case $colorSpace.value.intern
+ when :rgb
+ scale1.set($red / 65.535)
+ scale2.set($green / 65.535)
+ scale3.set($blue / 65.535)
+ when :cmy
+ scale1.set((65535 - $red) / 65.535)
+ scale2.set((65535 - $green) / 65.535)
+ scale3.set((65535 - $blue) / 65.535)
+ when :hsb
+ list = rgbToHsv($red,$green,$blue)
+ scale1.set( list[0] * 1000.0 )
+ scale2.set( list[1] * 1000.0 )
+ scale3.set( list[2] * 1000.0 )
+ else
+ raise(Exception,"unknown colorSpace")
+ end
+
+ $updating.value = 0
+end
+
+
+def tc_loadNamedColor(name)
+ $name.value = name
+ $master = :name if $master == nil
+ if name[0,1] != "#"
+ list = TkWinfo.rgb($root.middle.right.swatch,name)
+ $red = list[0]
+ $green = list[1]
+ $blue = list[2]
+ else
+ case name.length
+ when 4
+ fmt = /#(.{1})(.{1})(.{1})/
+ shift = 12
+ when 7
+ fmt = /#(.{2})(.{2})(.{2})/
+ shift = 8
+ when 10
+ fmt = /#(.{3})(.{3})(.{3})/
+ shift = 4
+ when 13
+ fmt = /#(.{4})(.{4})(.{4})/
+ shift = 0
+ else
+ raise(eException,"syntax error in color name \"#{name}\"")
+ end
+ name.scan(fmt){|strlist|
+ if strlist.length != 3
+ raise(eException,"syntax error in color name \"#{name}\"")
+ end
+ $red = strlist[0].hex
+ $green = strlist[1].hex
+ $blue = strlist[2].hex
+ }
+ $red = $red << shift
+ $green = $green << shift
+ $blue = $blue << shift
+ end
+
+ tc_setScales
+ $color = format("#%04x%04x%04x",$red,$green,$blue)
+ $root.middle.right.set_color($color)
+ if $autoUpdate.to_i == 1
+ doUpdate
+ end
+ Tk.update(true)
+ $master = nil if $master == :name
+end
+
+
+def changeColorSpace(space)
+ case space
+ when :rgb
+ $label1.value = "Red"
+ $label2.value = "Green"
+ $label3.value = "Blue"
+ when :cmy
+ $label1.value = "Cyan"
+ $label2.value = "Magenta"
+ $label3.value = "Yellow"
+ when :hsb
+ $label1.value = "Hue"
+ $label2.value = "Saturation"
+ $label3.value = "Brightness"
+ end
+ tc_setScales
+end
+
+
+
+
+
+# tcolor用ã®ãƒ¡ãƒ‹ãƒ¥ãƒ¼
+
+class TkColorMenuFrame<TkFrame
+ def initialize(parent)
+ super(parent,
+ "relief"=>"raised",
+ "borderwidth"=>"2")
+
+ # Fileメニューボタンã®ç”Ÿæˆ
+ @file = TkMenubutton.new(self){|button|
+
+ # Fileメニューã®ä½œæˆ
+ @file_menu = TkMenu.new(button){
+ add "radio",
+ "label" => "RGB color space",
+ "variable" => $colorSpace,
+ "value" => :rgb,
+ "underline" => "0",
+ "command" => proc{changeColorSpace(:rgb)}
+ add "radio",
+ "label" => "CMY color space",
+ "variable" => $colorSpace,
+ "value" => :cmy,
+ "underline" => "0",
+ "command" => proc{changeColorSpace(:cmy)}
+ add "radio",
+ "label" => "HSB color space",
+ "variable" => $colorSpace,
+ "value" => :hsb,
+ "underline" => "0",
+ "command" => proc{changeColorSpace(:hsb)}
+ add "separator"
+ add "radio",
+ "label" => "Automatic updates",
+ "variable" => $autoUpdate,
+ "value" => "1",
+ "underline" => "0"
+ add "radio",
+ "label" => "Manual updates",
+ "variable" => $autoUpdate,
+ "value" => "0",
+ "underline" => "0"
+ add "separator"
+ add "command",
+ "label" => "Exit program",
+ "underline" => "0",
+ "command" => proc{exit}
+ }
+
+ # Fileメニューã¨Fileボタンを関連付ã‘ã‚‹
+ menu @file_menu
+
+ text "File"
+ underline "0"
+ }.pack("side"=>"left")
+
+ self
+ end
+end
+
+
+# 下部ã®ãƒ•ãƒ¬ãƒ¼ãƒ ã®ãŸã‚ã®ã‚¯ãƒ©ã‚¹
+class TkColorBotFrame<TkFrame
+ def initialize(parent)
+ super(parent,
+ "relief"=> "raised",
+ "borderwidth"=> 2)
+
+ @commandLabel = TkLabel.new(self,
+ "text"=> "Command:")
+ @command = TkEntry.new(self,
+ "relief"=> "sunken",
+ "borderwidth"=> "2",
+ "textvariable"=> $command,
+ "font"=> "-Adobe-Courier-Medium-R-Normal--*-120-*-*-*-*-*-*")
+ @update = TkButton.new(self,
+ "text"=> "Update",
+ "command"=> proc{doUpdate})
+ @commandLabel.pack("side"=>"left")
+ @update.pack("side"=>"right","pady"=>".1c","padx"=>".25c")
+ @command.pack("expand"=>"yes","fill"=>"x","ipadx"=>".25c")
+
+ self
+ end
+end
+
+
+# 中段左ã®ãƒ•ãƒ¬ãƒ¼ãƒ 
+class TkColorMiddleLeftFrame<TkFrame
+ def initialize(parent)
+ super(parent)
+
+ for i in ["/usr/local/lib/X11rgb.txt","/usr/lib/X11/rgb.txt",
+ "/X11/R5/lib/X11/rgb.txt","/X11/R4/lib/rgb/rgb.txt",
+ "/usr/openwin/lib/X11/rgb.txt"]
+ if !File.readable?(i)
+ next
+ end
+ f = File.open(i)
+ @scroll = TkScrollbar.new(self,
+ "orient"=>"vertical",
+ "relief"=>"sunken",
+ "borderwidth"=>"2")
+ @scroll.pack("side"=>"right","fill"=>"y")
+ @names = TkListbox.new(self,
+ "width"=>"20",
+ "height"=>"12",
+ "yscrollcommand"=> proc{|first,last| @scroll.set first,last},
+ "relief"=>"sunken",
+ "borderwidth"=>"2",
+ "exportselection"=>"false")
+ @scroll.command(proc{|*args| @names.yview(*args)})
+ @names.bind("Double-1",proc{
+ tc_loadNamedColor(@names.get(@names.curselection))})
+ @names.pack("side"=>"left")
+ while (line = f.gets)
+ line.chop!
+ linelist = line.split(/[ \t]+/)
+ if linelist.length == 4
+ @names.insert("end",linelist[3])
+ end
+ end
+ f.close
+ break
+ end
+
+ self
+ end
+end
+
+
+# 中段中央ã®ãƒ•ãƒ¬ãƒ¼ãƒ 
+class TkColorMiddleMiddleFrame<TkFrame
+ # @scale1,@scale2,@scale3を外部ã‹ã‚‰å‚ç…§ã®ã¿è¨±å¯ã™ã‚‹ã€‚(変更ä¸å¯)
+ attr_reader :scale1, :scale2, :scale3
+
+ def initialize(parent)
+ super(parent)
+
+ @f1 = TkFrame.new(self)
+ @f2 = TkFrame.new(self)
+ @f3 = TkFrame.new(self)
+ @f4 = TkFrame.new(self)
+
+ for f in [@f1,@f2,@f3]
+ f.pack("side"=>"top","expand"=>"yes")
+ end
+ @f4.pack("side"=>"top","expand"=>"yes","fill"=>"x")
+
+ @label1 = TkLabel.new(self,"textvariable"=>$label1)
+ @scale1 = TkScale.new(self,"from"=>"0","to"=>"1000","length"=>"6c",
+ "orient"=>"horizontal",
+ "command"=>proc{tc_scaleChanged})
+ @scale1.pack("side"=>"top","anchor"=>"w")
+ @label1.pack("side"=>"top","anchor"=>"w")
+
+ @label2 = TkLabel.new(self,"textvariable"=>$label2)
+ @scale2 = TkScale.new(self,"from"=>"0","to"=>"1000","length"=>"6c",
+ "orient"=>"horizontal",
+ "command"=>proc{tc_scaleChanged})
+ @scale2.pack("side"=>"top","anchor"=>"w")
+ @label2.pack("side"=>"top","anchor"=>"w")
+
+ @label3 = TkLabel.new(self,"textvariable"=>$label3)
+ @scale3 = TkScale.new(self,"from"=>"0","to"=>"1000","length"=>"6c",
+ "orient"=>"horizontal",
+ "command"=>proc{tc_scaleChanged})
+ @scale3.pack("side"=>"top","anchor"=>"w")
+ @label3.pack("side"=>"top","anchor"=>"w")
+
+ @nameLabel = TkLabel.new(self,"text"=>"Name:")
+ @name = TkEntry.new(self,"relief"=>"sunken","borderwidth"=>"2",
+ "textvariable"=>$name,"width"=>"10",
+ "font"=>"-Adobe-Courier-Medium-R-Normal--*-120-*-*-*-*-*-*")
+ @nameLabel.pack("side"=>"left")
+ @name.pack("side"=>"right", "expand"=>"1", "fill"=>"x")
+ @name.bind("Return",proc{tc_loadNamedColor $name.to_s})
+
+ self
+ end
+end
+
+
+class TkColorMiddleRightFrame<TkFrame
+ attr_reader :swatch
+
+ def initialize(parent)
+ super(parent)
+ @swatch = TkFrame.new(self, "width"=>"2c", "height"=>"5c",
+ "background"=>$color)
+ @value = TkLabel.new(self,
+ "text"=>$color,
+ "width"=>"13",
+ "font"=>"-Adobe-Courier-Medium-R-Normal--*-120-*-*-*-*-*-*")
+ @swatch.pack("side"=>"top","expand"=>"yes","fill"=>"both")
+ @value.pack("side"=>"bottom","pady"=>".25c")
+
+ self
+ end
+
+ def set_color(color)
+ @swatch["background"] = color
+ @value["text"] = color
+ end
+end
+
+
+
+# 中段ã®ãƒ•ãƒ¬ãƒ¼ãƒ 
+class TkColorMiddleFrame<TkFrame
+ attr_reader :left, :middle, :right
+
+ def initialize(parent)
+ super(parent,
+ "relief"=> "raised",
+ "borderwidth"=> "2")
+
+ @left = TkColorMiddleLeftFrame.new(self)
+ @left.pack("side"=>"left","padx"=>".25c","pady"=>".25c")
+
+ @middle = TkColorMiddleMiddleFrame.new(self)
+ @middle.pack("side"=>"left","expand"=>"yes","fill"=>"y")
+
+ @right = TkColorMiddleRightFrame.new(self)
+ @right.pack("side"=>"left","padx"=>".25c","pady"=>".25c","anchor"=>"s")
+
+ self
+ end
+end
+
+
+class TkColor<TkRoot
+ attr_reader :menu, :bottom, :middle
+
+ def initialize(*args)
+ super(*args)
+ @menu = TkColorMenuFrame.new(self)
+ @menu.pack("side"=>"top", "fill"=>"x")
+
+ @bottom = TkColorBotFrame.new(self)
+ @bottom.pack("side"=>"bottom","fill"=>"x")
+
+ @middle = TkColorMiddleFrame.new(self)
+ @middle.pack("side"=>"top","fill"=>"both")
+
+ self
+ end
+end
+
+
+$root = TkColor.new
+
+# イベントを待ã¤ç‚ºã«ãƒ«ãƒ¼ãƒ—ã«å…¥ã‚‹ã€‚
+changeColorSpace :rgb
+Tk.mainloop
diff --git a/jni/ruby/ext/tk/sample/demos-jp/text.rb b/jni/ruby/ext/tk/sample/demos-jp/text.rb
new file mode 100644
index 0000000..e698a79
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/demos-jp/text.rb
@@ -0,0 +1,120 @@
+# -*- coding: utf-8 -*-
+#
+# text (basic facilities) widget demo (called by 'widget')
+#
+
+# toplevel widget ãŒå­˜åœ¨ã™ã‚Œã°å‰Šé™¤ã™ã‚‹
+if defined?($text_demo) && $text_demo
+ $text_demo.destroy
+ $text_demo = nil
+end
+
+# demo 用㮠toplevel widget を生æˆ
+$text_demo = TkToplevel.new {|w|
+ title("Text Demonstration - Basic Facilities")
+ iconname("text")
+ positionWindow(w)
+}
+
+base_frame = TkFrame.new($text_demo).pack(:fill=>:both, :expand=>true)
+
+# version check
+if ((Tk::TK_VERSION.split('.').collect{|n| n.to_i} <=> [8,4]) < 0)
+ undo_support = false
+else
+ undo_support = true
+end
+
+# frame 生æˆ
+TkFrame.new(base_frame) {|frame|
+ TkButton.new(frame) {
+ #text '了解'
+ text 'é–‰ã˜ã‚‹'
+ command proc{
+ tmppath = $text_demo
+ $text_demo = nil
+ tmppath.destroy
+ }
+ }.pack('side'=>'left', 'expand'=>'yes')
+
+ TkButton.new(frame) {
+ text 'コードå‚ç…§'
+ command proc{showCode 'text'}
+ }.pack('side'=>'left', 'expand'=>'yes')
+}.pack('side'=>'bottom', 'fill'=>'x', 'pady'=>'2m')
+
+# text 生æˆ
+TkText.new(base_frame){|t|
+ # 生æˆ
+ relief 'sunken'
+ bd 2
+ setgrid 1
+ height 30
+ TkScrollbar.new(base_frame) {|s|
+ pack('side'=>'right', 'fill'=>'y')
+ command proc{|*args| t.yview(*args)}
+ t.yscrollcommand proc{|first,last| s.set first,last}
+ }
+ pack('expand'=>'yes', 'fill'=>'both')
+
+ # テキスト挿入
+ insert('0.0', <<EOT)
+ã“ã®ã‚¦ã‚£ãƒ³ãƒ‰ã‚¦ã¯ãƒ†ã‚­ã‚¹ãƒˆ widget ã§ã™ã€‚1è¡Œã¾ãŸã¯ãれ以上ã®ãƒ†ã‚­ã‚¹ãƒˆã‚’表
+示・編集ã™ã‚‹ã“ã¨ãŒã§ãã¾ã™ã€‚以下ã¯ãƒ†ã‚­ã‚¹ãƒˆ widget ã§ã§ãã‚‹æ“作ã«ã¤ã„ã¦
+ã¾ã¨ã‚ãŸã‚‚ã®ã§ã™ã€‚
+
+1. スクロール。スクロールãƒãƒ¼ã§ãƒ†ã‚­ã‚¹ãƒˆã®è¡¨ç¤ºéƒ¨åˆ†ã‚’å‹•ã‹ã™ã“ã¨ãŒã§ãã¾ã™ã€‚
+
+2. スキャニング。テキストã®ã‚¦ã‚£ãƒ³ãƒ‰ã‚¦ã§ãƒžã‚¦ã‚¹ãƒœã‚¿ãƒ³2 (中ボタンを) を押
+ã—ã¦ä¸Šä¸‹ã«ãƒ‰ãƒ©ãƒƒã‚°ã—ã¦ãã ã•ã„。ãã†ã™ã‚‹ã¨ãƒ†ã‚­ã‚¹ãƒˆãŒé«˜é€Ÿã§ãƒ‰ãƒ©ãƒƒã‚°ã•ã‚Œã€
+内容をã–ã£ã¨çœºã‚ã‚‹ã“ã¨ãŒã§ãã¾ã™ã€‚
+
+3. テキストã®æŒ¿å…¥ã€‚マウスボタン1 (左ボタン) を押ã—ã€æŒ¿å…¥ã‚«ãƒ¼ã‚½ãƒ«ã‚’セッ
+トã—ã¦ã‹ã‚‰ãƒ†ã‚­ã‚¹ãƒˆã‚’入力ã—ã¦ãã ã•ã„。入力ã—ãŸã‚‚ã®ãŒ widget ã«å…¥ã‚Šã¾ã™ã€‚
+
+4. é¸æŠžã€‚ã‚る範囲ã®æ–‡å­—ã‚’é¸æŠžã™ã‚‹ã«ã¯ãƒžã‚¦ã‚¹ãƒœã‚¿ãƒ³1 を押ã—ã€ãƒ‰ãƒ©ãƒƒã‚°ã—
+ã¦ãã ã•ã„。一度ボタンを離ã—ãŸã‚‰ã€ã‚·ãƒ•ãƒˆã‚­ãƒ¼ã‚’押ã—ãªãŒã‚‰ãƒœã‚¿ãƒ³1 を押ã™
+ã“ã¨ã§é¸æŠžç¯„囲ã®èª¿æ•´ãŒã§ãã¾ã™ã€‚ã“ã‚Œã¯é¸æŠžç¯„囲ã®æœ€å¾Œã‚’マウスカーソルã«
+最も近ã„ä½ç½®ã«ãƒªã‚»ãƒƒãƒˆã—ã€ãƒœã‚¿ãƒ³ã‚’離ã™å‰ã«ãƒžã‚¦ã‚¹ã‚’ドラッグã™ã‚‹ã“ã¨ã§ã•
+らã«é¸æŠžç¯„囲を調整ã§ãã¾ã™ã€‚ダブルクリックã§ãƒ¯ãƒ¼ãƒ‰ã‚’ã€ã¾ãŸãƒˆãƒªãƒ—ルクリッ
+クã§è¡Œå…¨ä½“ã‚’é¸æŠžã™ã‚‹ã“ã¨ãŒã§ãã¾ã™ã€‚
+
+5. 消去ã¨ç½®æ›ã€‚テキストを消去ã™ã‚‹ã«ã¯ã€æ¶ˆåŽ»ã—ãŸã„文字をé¸æŠžã—ã¦ãƒãƒƒã‚¯
+スペースã‹ãƒ‡ãƒªãƒ¼ãƒˆã‚­ãƒ¼ã‚’入力ã—ã¦ãã ã•ã„。ã‚ã‚‹ã„ã¯ã€æ–°ã—ã„テキストを
+入力ã™ã‚‹ã¨é¸æŠžã•ã‚ŒãŸãƒ†ã‚­ã‚¹ãƒˆã¨ç½®æ›ã•ã‚Œã¾ã™ã€‚
+
+6. é¸æŠžéƒ¨åˆ†ã®ã‚³ãƒ”ー。é¸æŠžéƒ¨åˆ†ã‚’ã“ã®ã‚¦ã‚£ãƒ³ãƒ‰ã‚¦ã®ä¸­ã®ã©ã“ã‹ã«ã‚³ãƒ”ーã™ã‚‹
+ã«ã¯ã€ã¾ãšã‚³ãƒ”ーã—ãŸã„所をé¸æŠž(ã“ã“ã§ã€ã‚ã‚‹ã„ã¯åˆ¥ã®ã‚¢ãƒ—リケーションã§)
+ã—ã€ãƒœã‚¿ãƒ³ 2 をクリックã—ã¦ã€æŒ¿å…¥ã‚«ãƒ¼ã‚½ãƒ«ã®ä½ç½®ã«ã‚³ãƒ”ーã—ã¦ãã ã•ã„。
+
+7. 編集。テキスト widget 㯠Emacs ã®ã‚­ãƒ¼ãƒã‚¤ãƒ³ãƒ‰ã«åŠ ãˆã¦æ¨™æº–çš„ãªã® Motif
+ã®ç·¨é›†æ©Ÿèƒ½ã‚’サãƒãƒ¼ãƒˆã—ã¦ã„ã¾ã™ã€‚ãƒãƒƒã‚¯ã‚¹ãƒšãƒ¼ã‚¹ã¨ã‚³ãƒ³ãƒˆãƒ­ãƒ¼ãƒ«-H ã¯æŒ¿å…¥
+カーソルã®å·¦å´ã®æ–‡å­—を削除ã—ã¾ã™ã€‚デリートキーã¨ã‚³ãƒ³ãƒˆãƒ­ãƒ¼ãƒ«-D ã¯æŒ¿å…¥
+カーソルã®å³å´ã®æ–‡å­—を削除ã—ã¾ã™ã€‚Meta-ãƒãƒƒã‚¯ã‚¹ãƒšãƒ¼ã‚¹ã¯æŒ¿å…¥ã‚«ãƒ¼ã‚½ãƒ«ã®
+å³å´ã®å˜èªžã‚’削除ã—ã€Meta-D ã¯æŒ¿å…¥ã‚«ãƒ¼ã‚½ãƒ«ã®å·¦å´ã®å˜èªžã‚’削除ã—ã¾ã™ã€‚
+コントロール-K ã¯æŒ¿å…¥ã‚«ãƒ¼ã‚½ãƒ«ã‹ã‚‰è¡Œæœ«ã¾ã§ã‚’削除ã—ã€ãã®ä½ç½®ã«æ”¹è¡Œ
+ã—ã‹ãªã‹ã£ãŸå ´åˆã¯ã€æ”¹è¡Œã‚’削除ã—ã¾ã™ã€‚#{
+ if undo_support
+ undo_text = "Control-z ã¯æœ€å¾Œã«è¡Œã£ãŸå¤‰æ›´ã®å–り消ã—(undo)ã‚’è¡Œã„ã€"
+ case $tk_platform['platform']
+ when "unix", "macintosh"
+ undo_text << "Control-Shift-z"
+ else # 'windows'
+ undo_text << "Control-y"
+ end
+ undo_text << "ã¯undoã—ãŸå¤‰æ›´ã®å†é©ç”¨(redo)ã‚’è¡Œã„ã¾ã™ã€‚"
+ else
+ ""
+ end
+}
+
+
+8. ウィンドウã®ãƒªã‚µã‚¤ã‚ºã€‚ã“ã® widget 㯠"setGrid" オプションをオンã«ã—
+ã¦ã‚ã‚Šã¾ã™ã®ã§ã€ã‚¦ã‚£ãƒ³ãƒ‰ã‚¦ã‚’リサイズã™ã‚‹æ™‚ã«ã¯é«˜ã•ã¨å¹…ã¯å¸¸ã«æ–‡å­—高ã¨æ–‡
+å­—å¹…ã®æ•´æ•°å€ã«ãªã‚Šã¾ã™ã€‚ã¾ãŸã€ã‚¦ã‚£ãƒ³ãƒ‰ã‚¦ã‚’ç‹­ãã—ãŸå ´åˆã«ã¯é•·ã„è¡ŒãŒè‡ªå‹•
+çš„ã«æŠ˜ã‚Šè¿”ã•ã‚Œã€å¸¸ã«å…¨ã¦ã®å†…容ãŒè¦‹ãˆã‚‹ã‚ˆã†ã«ãªã£ã¦ã„ã¾ã™ã€‚
+EOT
+
+ set_insert('0.0')
+}
+
diff --git a/jni/ruby/ext/tk/sample/demos-jp/textpeer.rb b/jni/ruby/ext/tk/sample/demos-jp/textpeer.rb
new file mode 100644
index 0000000..4d896d2
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/demos-jp/textpeer.rb
@@ -0,0 +1,82 @@
+# -*- coding: utf-8 -*-
+#
+# text widget peering demo (called by 'widget')
+#
+# based on Tcl/Tk8.5.0 widget demos
+
+if defined?($textpeer_demo) && $textpeer_demo
+ $textpeer_demo.destroy
+ $textpeer_demo = nil
+end
+
+# demo toplevel widget
+$textpeer_demo = TkToplevel.new {|w|
+ title("Text Wdget Peering Demonstration")
+ iconname("textpeer")
+ positionWindow(w)
+}
+
+base_frame = TkFrame.new($textpeer_demo).pack(:fill=>:both, :expand=>true)
+
+count = [0]
+
+## Define a widget that we peer from; it won't ever actually be shown though
+first = TkText.new(base_frame, :widgetname=>"text#{count[0] += 1}")
+first.insert :end,"ã“ã®ãƒ‡ãƒ¢ã¯ä¸€ã¤ã®çµ„ã‚’æˆã—ãŸãƒ†ã‚­ã‚¹ãƒˆã‚¦ã‚£ã‚¸ã‚§ãƒƒãƒˆã‚’示ã—ã¾ã™ã€‚"
+first.insert :end,"ãれらã®ãƒ†ã‚­ã‚¹ãƒˆã‚¦ã‚£ã‚¸ã‚§ãƒƒãƒˆã¯å¯¾ç­‰(ピア;peer)ã®é–¢ä¿‚ã«"
+first.insert :end,"ãªã£ã¦ã„ã¾ã™ã€‚"
+first.insert :end,"ãれらã¯ã€åŸºç›¤ã¨ãªã‚‹ãƒ‡ãƒ¼ã‚¿ãƒ¢ãƒ‡ãƒ«ã¯å…±é€šã®ã‚‚ã®ã‚’æŒã¡ã¾ã™ãŒã€"
+first.insert :end,"ç”»é¢è¡¨ç¤ºä½ç½®ã€ç·¨é›†ä½ç½®ã€é¸æŠžç¯„囲(selection)ã«ã¤ã„ã¦ã¯"
+first.insert :end,"独立ã«æŒã¤ã“ã¨ãŒã§ãã¾ã™ã€‚"
+first.insert :end,"å„テキストウィジェットã®è„‡ã«ã‚ã‚‹"
+first.insert :end,"「ピア(peer)ã®ä½œæˆã€ãƒœã‚¿ãƒ³ã‚’使ãˆã°ã€"
+first.insert :end,"æ–°ãŸãªãƒ”アを追加ã™ã‚‹ã“ã¨ãŒå¯èƒ½ã§ã™ã€‚"
+first.insert :end,"ã¾ãŸã€Œãƒ”ã‚¢(peer)ã®æ¶ˆåŽ»ã€ãƒœã‚¿ãƒ³ã‚’使ãˆã°ã€"
+first.insert :end,"特定ã®ãƒ”アウィジェットを消去ã™ã‚‹ã“ã¨ã‚‚ã§ãã¾ã™ã€‚"
+
+Tk.update_idletasks ## for 'first' widget
+
+## Procedures to make and kill clones; most of this is just so that the demo
+## looks nice...
+def makeClone(count, win, txt)
+ cnt = (count[0] += 1)
+ peer = TkText::Peer.new(txt, win, :widgetname=>"text#{cnt}")
+ sbar = TkScrollbar.new(win, :widgetname=>"sb#{cnt}")
+ peer.yscrollbar sbar
+ b1 = TkButton.new(win, :widgetname=>"clone#{cnt}",
+ :text=>'ピア(peer)ã®ä½œæˆ',
+ :command=>proc{makeClone(count, win, peer)})
+ b2 = TkButton.new(win, :widgetname=>"kill#{cnt}",
+ :text=>'ピア(peer)ã®æ¶ˆåŽ»',
+ :command=>proc{killClone(win, cnt)})
+ row = cnt * 2
+ TkGrid.configure(peer, sbar, b1, :sticky=>'nsew', :row=>row)
+ TkGrid.configure('^', '^', b2, :sticky=>'nsew', :row=>(row+=1))
+ TkGrid.configure(b1, b2, :sticky=>'new')
+ TkGrid.rowconfigure(win, b2, :weight=>1)
+end
+
+def killClone(win, cnt)
+ Tk.destroy("#{win.path}.text#{cnt}", "#{win.path}.sb#{cnt}",
+ "#{win.path}.clone#{cnt}", "#{win.path}.kill#{cnt}")
+end
+
+## Now set up the GUI
+makeClone(count, base_frame, first)
+makeClone(count, base_frame, first)
+first.destroy
+
+## See Code / Dismiss buttons
+TkFrame.new(base_frame){|f|
+ TkButton.new(f, :text=>'é–‰ã˜ã‚‹', :width=>15, :command=>proc{
+ $textpeer_demo.destroy
+ $textpeer_demo = nil
+ }).pack(:side=>:left, :expand=>true)
+
+ TkButton.new(f, :text=>'コードå‚ç…§', :width=>15, :command=>proc{
+ showCode 'textpeer'
+ }).pack(:side=>:left, :expand=>true)
+
+ TkGrid.configure(f, '-', '-', :sticky=>'ew', :row=>5000)
+}
+TkGrid.columnconfigure(base_frame, 0, :weight=>1)
diff --git a/jni/ruby/ext/tk/sample/demos-jp/timer b/jni/ruby/ext/tk/sample/demos-jp/timer
new file mode 100644
index 0000000..6cb7c87
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/demos-jp/timer
@@ -0,0 +1,136 @@
+#!/usr/bin/env ruby
+#
+# timer --
+# This script generates a counter with start,stop and reset buttons.
+#
+# Copyright (C) 1998 Takaaki Tateishi (ttate@jaist.ac.jp)
+# last update: Sat Jun 27 12:24:14 JST 1998
+#
+
+require "tk"
+require "thread"
+require "tkafter"
+
+$time = "0.00"
+$m = Mutex.new
+$loop = false
+
+def timer_stop
+ $loop = false
+ $m.lock
+end
+
+def timer_start
+ $loop = true
+ $m.unlock
+end
+
+def timer_reset
+ $time = "0.00"
+ $root.countframe.counter['text'] = $time
+end
+
+def timer_loop
+ if $loop
+ $time = $time.succ
+ $root.countframe.counter['text'] = $time
+ end
+ Tk.after(10,proc{timer_loop})
+end
+
+
+#
+# thread version
+#
+def timer_loop2
+ while true
+ $m.lock
+ $time = $time.succ
+ $root.countframe.counter['text'] = $time
+ sleep(0.01)
+ $m.unlock
+ end
+end
+
+#
+# TkAfter
+#
+def timer_loop3
+ if $loop
+ $time = $time.succ
+ $root.countframe.counter['text'] = $time
+ end
+end
+
+
+class CountFrame < TkFrame
+ attr_reader :counter
+
+ def initialize(parent=nil,keys=nil)
+ super(parent,keys)
+ @counter = TkLabel.new(self,
+ 'text'=>$time,
+ 'relief'=>'raised')
+ @counter.pack('fill'=>'both')
+ self
+ end
+end
+
+
+class ButtonFrame < TkFrame
+ def initialize(parent=nil,keys=nil)
+ super(parent,keys)
+=begin
+ @stop = TkButton.new(self,
+ 'text'=>'Stop',
+ 'command'=>proc{timer_stop})
+ @start = TkButton.new(self,
+ 'text'=>'Start',
+ 'command'=>proc{timer_start})
+=end
+ @stop = TkButton.new(self, :text=>'Stop', :state=>:disabled)
+ @start = TkButton.new(self, :text=>'Start', :state=>:normal)
+
+ @stop.command proc{
+ timer_stop
+ @start.state(:normal)
+ @stop.state(:disabled)
+ }
+ @start.command proc{
+ timer_start
+ @stop.state(:normal)
+ @start.state(:disabled)
+ }
+
+ @reset = TkButton.new(self,
+ 'text'=>'Reset',
+ 'command'=>proc{timer_reset})
+ for b in [@stop,@start,@reset]
+ b.pack('side'=>'left', 'fill'=>'both', 'expand'=>'yes')
+ end
+ end
+end
+
+
+class Timer < TkRoot
+ attr_reader :countframe
+
+ def initialize(*args)
+ super(*args)
+ @countframe = CountFrame.new(self)
+ @buttonframe = ButtonFrame.new(self)
+ for f in [@buttonframe,@countframe]
+ f.pack('side'=>'top', 'fill'=>'both')
+ end
+ self
+ end
+end
+
+
+$root = Timer.new
+
+#$thread = Thread.start{timer_loop2}
+#timer_loop
+TkAfter.new(10,-1,proc{timer_loop3}).start
+
+Tk.mainloop
diff --git a/jni/ruby/ext/tk/sample/demos-jp/toolbar.rb b/jni/ruby/ext/tk/sample/demos-jp/toolbar.rb
new file mode 100644
index 0000000..3ee7a5f
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/demos-jp/toolbar.rb
@@ -0,0 +1,136 @@
+# -*- coding: utf-8 -*-
+#
+# toolbar.rb --
+#
+# This demonstration script creates a toolbar that can be torn off.
+#
+# based on "Id: toolbar.tcl,v 1.3 2007/12/13 15:27:07 dgp Exp"
+
+if defined?($toolbar_demo) && $toolbar_demo
+ $toolbar_demo.destroy
+ $toolbar_demo = nil
+end
+
+$toolbar_demo = TkToplevel.new {|w|
+ title("Ttk Menu Buttons")
+ iconname("toolbar")
+ positionWindow(w)
+}
+
+base_frame = Ttk::Frame.new($toolbar_demo).pack(:fill=>:both, :expand=>true)
+
+if Tk.windowingsystem != 'aqua'
+ msg = Ttk::Label.new(base_frame, :wraplength=>'4i', :text=><<EOL)
+ã“ã®ãƒ‡ãƒ¢ã§ã¯ï¼Œãƒ„ールãƒãƒ¼ã‚’ã©ã®ã‚ˆã†ã«ã—ã¦é©åˆ‡ã«ãƒ†ãƒ¼ãƒžå¯¾å¿œã•ã›ã‚‹ã‹ï¼Œ\
+ã¾ãŸï¼Œã©ã®ã‚ˆã†ã«ã—ã¦åˆ‡ã‚Šé›¢ã—å¯èƒ½ã«ã™ã‚‹ã‹ã‚’示ã—ã¦ã„ã¾ã™\
+(ãŸã ã—,ツールãƒãƒ¼ã®åˆ‡ã‚Šé›¢ã—ã«ã¯Tcl/Tk8.5以上ã®æ©Ÿèƒ½ãŒå¿…è¦ã§ã™ï¼‰ï¼Ž\
+ツールãƒãƒ¼ã®ãƒœã‚¿ãƒ³ã¯ï¼Œ'Toolbutton'スタイルを使用ã™ã‚‹ã‚ˆã†ã«æ˜Žç¤ºã™ã‚‹ã“ã¨ã§ï¼Œ\
+"toolbar style"ボタンã¨ãªã‚‹ã‚ˆã†ã«å±žæ€§è¨­å®šã•ã‚Œã¦ã„ã¾ã™ï¼Ž\
+ツールãƒãƒ¼ã®å·¦ç«¯ã«ã¯ç°¡å˜ãªãƒžãƒ¼ã‚«ãƒ¼ãŒç½®ã‹ã‚Œã¦ã„ã¾ã™ï¼Ž\
+マーカー上ã«ãƒžã‚¦ã‚¹ã‚«ãƒ¼ã‚½ãƒ«ãŒæ¥ã‚‹ã¨ç§»å‹•ã‚¢ã‚¤ã‚³ãƒ³ã«ã‚«ãƒ¼ã‚½ãƒ«ãŒå¤‰åŒ–ã—ã¾ã™ï¼Ž\
+ãã“ã§ãƒ„ールãƒãƒ¼ã‚’å‹•ã‹ã™ã‚ˆã†ã«ãƒ‰ãƒ©ãƒƒã‚°ã™ã‚‹ã¨ï¼Œ\
+ツールãƒãƒ¼å…¨ä½“を切り離ã—ã¦ç‹¬ç«‹ã—ãŸãƒˆãƒƒãƒ—レベルウィジェットã«\
+ã™ã‚‹ã“ã¨ãŒã§ãã¾ã™ï¼Ž\
+切り離ã—ãŸãƒ„ールãƒãƒ¼ãŒä¸è¦ã¨ãªã£ãŸæ™‚ã«ã¯ï¼Œ\
+一般的ãªãƒˆãƒƒãƒ—レベルウィジェットã¨åŒæ§˜ã«å˜ç´”ã«é–‰ã˜ã‚‹ã“ã¨ã§ï¼Œ
+å†ã³å…ƒã®ã‚¦ã‚£ãƒ³ãƒ‰ã‚¦ã«å¼µã‚Šä»˜ã‘られるã§ã—ょã†ï¼Ž
+EOL
+else
+ msg = Ttk::Label.new(base_frame, :wraplength=>'4i', :text=><<EOL)
+ã“ã®ãƒ‡ãƒ¢ã§ã¯ï¼Œãƒ„ールãƒãƒ¼ã‚’ã©ã®ã‚ˆã†ã«ã—ã¦é©åˆ‡ã«ãƒ†ãƒ¼ãƒžå¯¾å¿œã•ã›ã‚‹ã‹ã‚’\
+示ã—ã¦ã„ã¾ã™ï¼Ž\
+ツールãƒãƒ¼ã®ãƒœã‚¿ãƒ³ã¯ï¼Œ'Toolbutton'スタイルを使用ã™ã‚‹ã‚ˆã†ã«æ˜Žç¤ºã™ã‚‹ã“ã¨ã§ï¼Œ\
+"toolbar style"ボタンã¨ãªã‚‹ã‚ˆã†ã«å±žæ€§è¨­å®šã•ã‚Œã¦ã„ã¾ã™ï¼Ž
+EOL
+end
+
+## Set up the toolbar hull
+tbar_base = Tk::Frame.new(base_frame, # Tk 標準㮠frame ã§ãªã‘ã‚Œã°ãªã‚Šã¾ã›ã‚“.
+ :widgetname=>'toolbar') # ウィンドウタイトル文字列ã¨ã™ã‚‹ãŸã‚ã«ï¼Œã‚¦ã‚£ã‚¸ã‚§ãƒƒãƒˆåを明示ã—ã¦ã„ã¾ã™ï¼Ž
+sep = Ttk::Separator.new(base_frame)
+to_base = Ttk::Frame.new(tbar_base, :cursor=>'fleur')
+if Tk.windowingsystem != 'aqua'
+ to = Ttk::Separator.new(to_base, :orient=>:vertical)
+ to2 = Ttk::Separator.new(to_base, :orient=>:vertical)
+ to.pack(:fill=>:y, :expand=>true, :padx=>2, :side=>:left)
+ to2.pack(:fill=>:y, :expand=>true, :side=>:left)
+end
+
+contents = Ttk::Frame.new(tbar_base)
+Tk.grid(to_base, contents, :sticky=>'nsew')
+tbar_base.grid_columnconfigure(contents, :weight=>1)
+contents.grid_columnconfigure(1000, :weight=>1)
+
+if Tk.windowingsystem != 'aqua'
+ ## Bindings so that the toolbar can be torn off and reattached
+ to_base.bind('B1-Motion', '%X %Y'){|x, y| tbar_base.tearoff(to_base, x, y)}
+ to. bind('B1-Motion', '%X %Y'){|x, y| tbar_base.tearoff(to_base, x, y)}
+ to2. bind('B1-Motion', '%X %Y'){|x, y| tbar_base.tearoff(to_base, x, y)}
+ def tbar_base.tearoff(w, x, y)
+ on_win = TkWinfo.containing(x, y)
+ return unless (on_win && on_win.path =~ /^#{@path}(\.|$)/)
+ self.grid_remove
+ w.grid_remove
+ self.wm_manage
+ # self.wm_title('Toolbar') # ã‚‚ã—ウィジェットåをウィンドウタイトルã«ã—ãŸããªã„ãªã‚‰ï¼Œã“ã“ã§è¨­å®šã—ã¦ãã ã•ã„
+ self.wm_protocol('WM_DELETE_WINDOW'){ self.untearoff(w) }
+ end
+ def tbar_base.untearoff(w)
+ self.wm_forget
+ w.grid
+ self.grid
+ end
+end
+
+## Some content for the rest of the toplevel
+text = TkText.new(base_frame, :width=>40, :height=>10)
+
+## Toolbar contents
+tb_btn = Ttk::Button.new(tbar_base, :text=>'ボタン', :style=>'Toolbutton',
+ :command=>proc{
+ text.insert(:end, "ボタンãŒæŠ¼ã•ã‚Œã¾ã—ãŸï¼Ž\n")
+ })
+tb_chk = Ttk::Checkbutton.new(tbar_base, :text=>'ãƒã‚§ãƒƒã‚¯ãƒœã‚¿ãƒ³',
+ :style=>'Toolbutton',
+ :variable=>(check = TkVariable.new),
+ :command=>proc{
+ text.insert(:end, "ãƒã‚§ãƒƒã‚¯ãƒœã‚¿ãƒ³ã®å€¤ã¯#{check.value}ã§ã™ï¼Ž\n")
+ })
+tb_mbtn = Ttk::Menubutton.new(tbar_base, :text=>'メニュー')
+tb_combo = Ttk::Combobox.new(tbar_base, :value=>TkFont.families,
+ :state=>:readonly)
+tb_mbtn.menu(menu = Tk::Menu.new(tb_mbtn))
+menu.add(:command, :label=>'Just', :command=>proc{text.insert(:end, "Just\n")})
+menu.add(:command, :label=>'An', :command=>proc{text.insert(:end, "An\n")})
+menu.add(:command, :label=>'Example',
+ :command=>proc{text.insert(:end, "Example\n")})
+tb_combo.bind('<ComboboxSelected>'){ text.font.family = tb_combo.get }
+
+## Arrange contents
+Tk.grid(tb_btn, tb_chk, tb_mbtn, tb_combo,
+ :in=>contents, :padx=>2, :sticky=>'ns')
+Tk.grid(tbar_base, :sticky=>'ew')
+Tk.grid(sep, :sticky=>'ew')
+Tk.grid(msg, :sticky=>'ew')
+Tk.grid(text, :sticky=>'nsew')
+base_frame.grid_rowconfigure(text, :weight=>1)
+base_frame.grid_columnconfigure(text, :weight=>1)
+
+## See Code / Dismiss buttons
+Ttk::Frame.new(base_frame) {|frame|
+ sep = Ttk::Separator.new(frame)
+ Tk.grid(sep, :columnspan=>4, :row=>0, :sticky=>'ew', :pady=>2)
+ TkGrid('x',
+ Ttk::Button.new(frame, :text=>'コードå‚ç…§',
+ :image=>$image['view'], :compound=>:left,
+ :command=>proc{showCode 'toolbar'}),
+ Ttk::Button.new(frame, :text=>'é–‰ã˜ã‚‹',
+ :image=>$image['delete'], :compound=>:left,
+ :command=>proc{
+ $toolbar_demo.destroy
+ $toolbar_demo = nil
+ }),
+ :padx=>4, :pady=>4)
+ grid_columnconfigure(0, :weight=>1)
+ Tk.grid(frame, :sticky=>'ew')
+}
diff --git a/jni/ruby/ext/tk/sample/demos-jp/tree.rb b/jni/ruby/ext/tk/sample/demos-jp/tree.rb
new file mode 100644
index 0000000..3f3b18b
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/demos-jp/tree.rb
@@ -0,0 +1,120 @@
+# -*- coding: utf-8 -*-
+#
+# tree.rb --
+#
+# This demonstration script creates a toplevel window containing a Ttk
+# tree widget.
+#
+# based on "Id: tree.tcl,v 1.4 2007/12/13 15:27:07 dgp Exp"
+
+if defined?($tree_demo) && $tree_demo
+ $tree_demo.destroy
+ $tree_demo = nil
+end
+
+$tree_demo = TkToplevel.new {|w|
+ title("Directory Browser")
+ iconname("tree")
+ positionWindow(w)
+}
+
+base_frame = TkFrame.new($tree_demo).pack(:fill=>:both, :expand=>true)
+
+## Explanatory text
+Ttk::Label.new(base_frame, :font=>$font, :wraplength=>'4i',
+ :justify=>:left, :anchor=>'n', :padding=>[10, 2, 10, 6],
+ :text=><<EOL).pack(:fill=>:x)
+Ttkã¨ã¯ï¼Œãƒ†ãƒ¼ãƒžæŒ‡å®šå¯èƒ½ãªæ–°ã—ã„ウィジェット集åˆã§ã™ï¼Ž\
+ã“ã®ã‚µãƒ³ãƒ—ルã¯ï¼Œãƒ•ã‚¡ã‚¤ãƒ«ã‚·ã‚¹ãƒ†ãƒ ã®ã‚ˆã†ãªéšŽå±¤çš„ãªãƒ‡ãƒ¼ã‚¿é›†åˆã‚’\
+å‚ç…§ã§ãるよã†ã«ã—ãŸTtk::Treeviewウィジェットをå«ã‚“ã§ã„ã¾ã™ï¼Ž\
+Ttk::Treeviewウィジェットã¯ï¼Œæœ¨æ§‹é€ è‡ªä½“ã®è¡¨ç¤ºã‚’å¯èƒ½ã«ã™ã‚‹ã ã‘ã§ãªã,\
+追加情報(ã“ã®ã‚µãƒ³ãƒ—ルã®å ´åˆã¯ãƒ•ã‚¡ã‚¤ãƒ«ã‚µã‚¤ã‚º)を表示ã™ã‚‹ãŸã‚ã«\
+ä»»æ„ã®å€‹æ•°ã®è¿½åŠ ã‚«ãƒ©ãƒ ã‚‚扱ã†ã“ã¨ã‚‚ã§ãã¾ã™ï¼Ž\
+ã¾ãŸï¼Œã‚«ãƒ©ãƒ ã®ã‚¿ã‚¤ãƒˆãƒ«é–“ã®åŒºåˆ‡ã‚Šéƒ¨åˆ†ã‚’ドラッグã™ã‚‹ã“ã¨ã§ï¼Œ\
+カラムã®å¹…を変更ã™ã‚‹ã“ã¨ã‚‚å¯èƒ½ã§ã™ï¼Ž
+EOL
+
+## See Code / Dismiss
+Ttk::Frame.new(base_frame) {|frame|
+ sep = Ttk::Separator.new(frame)
+ Tk.grid(sep, :columnspan=>4, :row=>0, :sticky=>'ew', :pady=>2)
+ TkGrid('x',
+ Ttk::Button.new(frame, :text=>'コードå‚ç…§',
+ :image=>$image['view'], :compound=>:left,
+ :command=>proc{showCode 'tree'}),
+ Ttk::Button.new(frame, :text=>'é–‰ã˜ã‚‹',
+ :image=>$image['delete'], :compound=>:left,
+ :command=>proc{
+ $tree_demo.destroy
+ $tree_demo = nil
+ }),
+ :padx=>4, :pady=>4)
+ grid_columnconfigure(0, :weight=>1)
+ pack(:side=>:bottom, :fill=>:x)
+}
+
+## Code to populate the roots of the tree (can be more than one on Windows)
+def populate_roots(tree)
+ TkComm.simplelist(Tk.tk_call('file', 'volumes')).sort.each{|dir|
+ populate_tree(tree, tree.insert(nil, :end, :text=>dir,
+ :values=>[dir, 'directory']))
+ }
+end
+
+## Code to populate a node of the tree
+def populate_tree(tree, node)
+ return if tree.get(node, :type) != 'directory'
+
+ path = tree.get(node, :fullpath)
+ tree.delete(tree.children(node))
+ Dir.glob("#{path}/*").sort.each{|f|
+ type = File.ftype(f) rescue nil
+ id = tree.insert(node, :end,
+ :text=>File.basename(f), :values=>[f, type]).id
+ if type == 'directory'
+ ## Make it so that this node is openable
+ tree.insert(id, 0, :text=>'dummy')
+ tree.itemconfigure(id, :text=>File.basename(f))
+ elsif type == 'file'
+ size = File.size(f)
+ if size >= 1024*1024*1024
+ size = '%.1f GB' % (size.to_f/1024/1024/1024)
+ elsif size >= 1024*1024
+ size = '%.1f MB' % (size.to_f/1024/1024)
+ elsif size >= 1024
+ size = '%.1f KB' % (size.to_f/1024)
+ else
+ size = '%.1f bytes' % (size.to_f/1024)
+ end
+ tree.set(id, :size, size)
+ end
+ }
+
+ # Stop this code from rerunning on the current node
+ tree.set(node, :type, 'processed_directory')
+end
+
+## Create the tree and set it up
+tree = Ttk::Treeview.new(base_frame, :columns=>%w(fullpath type size),
+ :displaycolumns=>['size'])
+if Tk.windowingsystem != 'aqua'
+ vsb = tree.yscrollbar(Ttk::Scrollbar.new(base_frame))
+ hsb = tree.xscrollbar(Ttk::Scrollbar.new(base_frame))
+else
+ vsb = tree.yscrollbar(Tk::Scrollbar.new(base_frame))
+ hsb = tree.xscrollbar(Tk::Scrollbar.new(base_frame))
+end
+
+tree.heading_configure('#0', :text=>'Directory Structure')
+tree.heading_configure('size', :text=>'File Size')
+tree.column_configure('size', :stretch=>0, :width=>70)
+populate_roots(tree)
+tree.bind('<TreeviewOpen>', '%W'){|w| populate_tree(w, w.focus_item)}
+
+## Arrange the tree and its scrollbars in the toplevel
+container = Ttk::Frame.new(base_frame).pack(:fill=>:both, :expand=>true)
+container.lower
+Tk.grid(tree, vsb, :in=>container, :sticky=>'nsew')
+Tk.grid(hsb, :in=>container, :sticky=>'nsew')
+container.grid_columnconfigure(0, :weight=>1)
+container.grid_rowconfigure(0, :weight=>1)
diff --git a/jni/ruby/ext/tk/sample/demos-jp/ttkbut.rb b/jni/ruby/ext/tk/sample/demos-jp/ttkbut.rb
new file mode 100644
index 0000000..ccde541
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/demos-jp/ttkbut.rb
@@ -0,0 +1,145 @@
+# -*- coding: utf-8 -*-
+#
+# ttkbut.rb
+#
+# This demonstration script creates a toplevel window containing several
+# simple Ttk widgets, such as labels, labelframes, buttons, checkbuttons and
+# radiobuttons.
+#
+# based on "Id: ttkbut.tcl,v 1.4 2007/12/13 15:27:07 dgp Exp"
+
+if defined?($ttkbut_demo) && $ttkbut_demo
+ $ttkbut_demo.destroy
+ $ttkbut_demo = nil
+end
+
+$ttkbut_demo = TkToplevel.new {|w|
+ title("Simple Ttk Widgets")
+ iconname("ttkbut")
+ positionWindow(w)
+}
+
+base_frame = TkFrame.new($ttkbut_demo).pack(:fill=>:both, :expand=>true)
+
+Ttk::Label.new(base_frame, :font=>$font, :wraplength=>'4i', :justify=>:left,
+ :text=><<EOL).pack(:side=>:top, :fill=>:x)
+Ttkã¨ã¯ï¼Œãƒ†ãƒ¼ãƒžæŒ‡å®šå¯èƒ½ãªæ–°ã—ã„ウィジェット集åˆã§ã™ï¼Ž\
+今,ã‚ãªãŸãŒç›®ã«ã—ã¦ã„ã‚‹ã®ã¯Ttkã®ãƒ†ãƒ¼ãƒžåŒ–ラベルã§ï¼Œ\
+下ã«ã¯Ttkã®ãƒ©ãƒ™ãƒ«ãƒ•ãƒ¬ãƒ¼ãƒ ã®ä¸­ã«ä¸‰ã¤ã®ã‚°ãƒ«ãƒ¼ãƒ—ã®TtkウィジェットãŒ\
+表示ã•ã‚Œã¦ã„ã¾ã™ï¼Ž
+最åˆã®ã‚°ãƒ«ãƒ¼ãƒ—ã¯å…¨ã¦ãƒœã‚¿ãƒ³ã§ã‚り,\
+ãã‚Œãžã‚Œã‚¯ãƒªãƒƒã‚¯ã™ã‚Œã°ç¾åœ¨ã®ã‚¢ãƒ—リケーションã®ãƒ†ãƒ¼ãƒžãŒè¨­å®šã•ã‚Œã¾ã™ï¼Ž
+2番目ã®ã‚°ãƒ«ãƒ¼ãƒ—ã¯ä¸‰ã¤ã®ãƒã‚§ãƒƒã‚¯ãƒœã‚¿ãƒ³é›†åˆã§ã™ï¼Ž\
+å„集åˆã®é–“ã«ã¯ï¼Œã‚»ãƒ‘レータウィジェットãŒç½®ã‹ã‚Œã¦ã„ã¾ã™ï¼Ž\
+ãªãŠã€Œæœ‰åŠ¹åŒ–ã€ãƒœã‚¿ãƒ³ã¯ï¼Œã“ã®ãƒˆãƒƒãƒ—レベルウィジェット内ã®\
+ä»–ã®ã™ã¹ã¦ã®ãƒ†ãƒ¼ãƒžåŒ–ウィジェットã®çŠ¶æ…‹(state)ãŒ"disabled"ã‹ã©ã†ã‹ã‚’\
+コントロールã™ã‚‹ã“ã¨ã«æ³¨æ„ã—ã¦ãã ã•ã„.
+3番目ã®ã‚°ãƒ«ãƒ¼ãƒ—ã¯é–¢é€£ä»˜ã‘られãŸãƒ©ã‚¸ã‚ªãƒœã‚¿ãƒ³é›†åˆã¨ãªã£ã¦ã„ã¾ã™ï¼Ž
+EOL
+
+## Add buttons for setting the theme
+buttons = Ttk::Labelframe.new(base_frame, :text=>'ボタン')
+# Ttk::Style.theme_names.each{|theme|
+# Ttk::Button.new(buttons, :text=>theme,
+# :command=>proc{Ttk::Style.theme_use theme}).pack(:pady=>2)
+# }
+Ttk.themes.each{|theme|
+ Ttk::Button.new(buttons, :text=>theme,
+ :command=>proc{Ttk.set_theme theme}).pack(:pady=>2)
+}
+
+## Helper procedure for the top checkbutton
+def setState(root, value, *excepts)
+ return if excepts.member?(root)
+
+ ## Non-Ttk widgets (e.g. the toplevel) will fail, so make it silent
+ begin
+ root.state = value
+ rescue
+ end
+
+ ## Recursively invoke on all children of this root that are in the same
+ ## toplevel widget
+ root.winfo_children.each{|w|
+ setState(w, value, *excepts) if w.winfo_toplevel == root.winfo_toplevel
+ }
+end
+
+## Set up the checkbutton group
+checks = Ttk::Labelframe.new(base_frame, :text=>'ãƒã‚§ãƒƒã‚¯ãƒœã‚¿ãƒ³')
+enabled = TkVariable.new(true)
+e = Ttk::Checkbutton.new(checks, :text=>'有効化', :variable=>enabled,
+ :command=>proc{
+ setState($ttkbut_demo,
+ ((enabled.bool)? "!disabled" : "disabled"),
+ e)
+ })
+
+## See ttk_widget(n) for other possible state flags
+sep1 = Ttk::Separator.new(checks)
+sep2 = Ttk::Separator.new(checks)
+
+cheese = TkVariable.new
+tomato = TkVariable.new
+basil = TkVariable.new
+oregano = TkVariable.new
+
+c1 = Ttk::Checkbutton.new(checks, :text=>'ãƒãƒ¼ã‚º', :variable=>cheese)
+c2 = Ttk::Checkbutton.new(checks, :text=>'トマト', :variable=>tomato)
+c3 = Ttk::Checkbutton.new(checks, :text=>'ãƒã‚¸ãƒ«', :variable=>basil)
+c4 = Ttk::Checkbutton.new(checks, :text=>'オレガノ', :variable=>oregano)
+
+Tk.pack(e, sep1, c1, c2, sep2, c3, c4, :fill=>:x, :pady=>2)
+
+## Set up the radiobutton group
+radios = Ttk::Labelframe.new(base_frame, :text=>'ラジオボタン')
+
+happyness = TkVariable.new
+
+r1 = Ttk::Radiobutton.new(radios, :variable=>happyness,
+ :text=>'Great', :value=>'great')
+r2 = Ttk::Radiobutton.new(radios, :variable=>happyness,
+ :text=>'Good', :value=>'good')
+r3 = Ttk::Radiobutton.new(radios, :variable=>happyness,
+ :text=>'Ok', :value=>'ok')
+r4 = Ttk::Radiobutton.new(radios, :variable=>happyness,
+ :text=>'Poor', :value=>'poor')
+r5 = Ttk::Radiobutton.new(radios, :variable=>happyness,
+ :text=>'Awful', :value=>'awful')
+
+Tk.pack(r1, r2, r3, r4, r5, :fill=>:x, :padx=>3, :pady=>2)
+
+## See Code / Dismiss
+Ttk::Frame.new(base_frame) {|frame|
+ sep = Ttk::Separator.new(frame)
+ Tk.grid(sep, :columnspan=>4, :row=>0, :sticky=>'ew', :pady=>2)
+ TkGrid('x',
+ Ttk::Button.new(frame, :text=>'変数å‚ç…§',
+ :image=>$image['view'], :compound=>:left,
+ :command=>proc{
+ showVars(base_frame, ['有効化', enabled],
+ ['ãƒãƒ¼ã‚º', cheese], ['トマト', tomato],
+ ['ãƒã‚¸ãƒ«', basil], ['オレガノ', oregano],
+ ['幸ç¦åº¦', happyness])
+ }),
+ Ttk::Button.new(frame, :text=>'コードå‚ç…§',
+ :image=>$image['view'], :compound=>:left,
+ :command=>proc{showCode 'ttkbut'}),
+ Ttk::Button.new(frame, :text=>'é–‰ã˜ã‚‹',
+ :image=>$image['delete'], :compound=>:left,
+ :command=>proc{
+ tmppath = $ttkbut_demo
+ $ttkbut_demo = nil
+ $showVarsWin[tmppath.path] = nil
+ tmppath.destroy
+ }),
+ :padx=>4, :pady=>4)
+ grid_columnconfigure(0, :weight=>1)
+ pack(:side=>:bottom, :fill=>:x, :expand=>true)
+}
+
+## Arrange things neatly
+f = Ttk::Frame.new(base_frame).pack(:fill=>:both, :expand=>true)
+f.lower
+Tk.grid(buttons, checks, radios, :in=>f, :sticky=>'nwe', :pady=>2, :padx=>3)
+f.grid_columnconfigure([0, 1, 2], :weight=>1, :uniform=>:yes)
diff --git a/jni/ruby/ext/tk/sample/demos-jp/ttkmenu.rb b/jni/ruby/ext/tk/sample/demos-jp/ttkmenu.rb
new file mode 100644
index 0000000..aa9db50
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/demos-jp/ttkmenu.rb
@@ -0,0 +1,91 @@
+# -*- coding: utf-8 -*-
+#
+# ttkmenu.rb --
+#
+# This demonstration script creates a toplevel window containing several Ttk
+# menubutton widgets.
+#
+# based on "Id: ttkmenu.tcl,v 1.3 2007/12/13 15:27:07 dgp Exp"
+
+if defined?($ttkmenu_demo) && $ttkmenu_demo
+ $ttkmenu_demo.destroy
+ $ttkmenu_demo = nil
+end
+
+$ttkmenu_demo = TkToplevel.new {|w|
+ title("Ttk Menu Buttons")
+ iconname("ttkmenu")
+ positionWindow(w)
+}
+
+base_frame = Ttk::Frame.new($ttkmenu_demo).pack(:fill=>:both, :expand=>true)
+
+Ttk::Label.new(base_frame, :font=>$font, :wraplength=>'4i', :justify=>:left,
+ :text=><<EOL).pack(:side=>:top, :fill=>:x)
+Ttkã¨ã¯ï¼Œãƒ†ãƒ¼ãƒžæŒ‡å®šå¯èƒ½ãªæ–°ã—ã„ウィジェット集åˆã§ã™ï¼Ž\
+ã“ã‚Œã«ã‚ˆã‚Šãƒ†ãƒ¼ãƒžã«å¯¾å¿œã™ã‚‹ã“ã¨ãŒã§ãるよã†ã«ãªã£ãŸã‚¦ã‚£ã‚¸ã‚§ãƒƒãƒˆã®ã²ã¨ã¤ã«\
+メニューボタンãŒã‚ã‚Šã¾ã™ï¼Ž\
+以下ã§ã¯ï¼Œãƒ†ãƒ¼ãƒžã«å¯¾å¿œã—ãŸãƒ¡ãƒ‹ãƒ¥ãƒ¼ãƒœã‚¿ãƒ³ãŒã„ãã¤ã‹è¡¨ç¤ºã•ã‚Œã¦ã„ã¾ã™ï¼Ž\
+ãれらを使ã£ã¦ï¼Œç¾åœ¨ä½¿ç”¨ä¸­ã®ãƒ†ãƒ¼ãƒžã‚’変更ã™ã‚‹ã“ã¨ãŒå¯èƒ½ã§ã™ï¼Ž\
+テーマã®é¸æŠžãŒãƒ¡ãƒ‹ãƒ¥ãƒ¼ãƒœã‚¿ãƒ³è‡ªèº«ã®è¦‹æŽ›ã‘を変化ã•ã›ã‚‹æ§˜å­ã‚„,\
+中央ã®ãƒ¡ãƒ‹ãƒ¥ãƒ¼ãƒœã‚¿ãƒ³ã ã‘ãŒç•°ãªã‚‹ã‚¹ã‚¿ã‚¤ãƒ«\
+(ツールãƒãƒ¼ã§ã®ä¸€èˆ¬çš„ãªè¡¨ç¤ºã«é©ã—ãŸã‚‚ã®)ã§è¡¨ç¤ºã•ã‚Œã¦ã„る様å­ã«\
+注目ã—ã¦ãã ã•ã„.\
+ãªãŠï¼Œãƒ¡ãƒ‹ãƒ¥ãƒ¼ãƒœã‚¿ãƒ³ã«ã¤ã„ã¦ã¯ãƒ†ãƒ¼ãƒžã«å¯¾å¿œã—ãŸã‚¦ã‚£ã‚¸ã‚§ãƒƒãƒˆãŒã‚ã‚Šã¾ã™ãŒï¼Œ\
+メニューã«ã¤ã„ã¦ã¯ãƒ†ãƒ¼ãƒžã«å¯¾å¿œã—ãŸã‚¦ã‚£ã‚¸ã‚§ãƒƒãƒˆã¯å«ã¾ã‚Œã¦ã„ã¾ã›ã‚“.\
+ãã®ç†ç”±ã¯ï¼Œæ¨™æº–ã®Tkã®ãƒ¡ãƒ‹ãƒ¥ãƒ¼ã‚¦ã‚£ã‚¸ã‚§ãƒƒãƒˆãŒ\
+ã™ã¹ã¦ã®ãƒ—ラットホームã§å分ã«è‰¯å¥½ãªè¦‹æŽ›ã‘ã¨æ“作性をæŒã£ã¦ã„る,\
+特ã«ï¼Œå¤šãã®ç’°å¢ƒã§ãã®ç’°å¢ƒæœ¬æ¥ã®æ“作体系ã¨ãªã‚‹ã‚ˆã†ã«å®Ÿè£…ã•ã‚Œã¦ã„ã‚‹ã¨\
+判断ã•ã‚ŒãŸã“ã¨ã«ã‚ˆã‚Šã¾ã™ï¼Ž
+EOL
+
+Ttk::Separator.new(base_frame).pack(:side=>:top, :fill=>:x)
+
+## See Code / Dismiss
+Ttk::Frame.new($ttkmenu_demo) {|frame|
+ sep = Ttk::Separator.new(frame)
+ Tk.grid(sep, :columnspan=>4, :row=>0, :sticky=>'ew', :pady=>2)
+ TkGrid('x',
+ Ttk::Button.new(frame, :text=>'コードå‚ç…§',
+ :image=>$image['view'], :compound=>:left,
+ :command=>proc{showCode 'ttkmenu'}),
+ Ttk::Button.new(frame, :text=>'é–‰ã˜ã‚‹',
+ :image=>$image['delete'], :compound=>:left,
+ :command=>proc{
+ $ttkmenu_demo.destroy
+ $ttkmenu_demo = nil
+ }),
+ :padx=>4, :pady=>4)
+ grid_columnconfigure(0, :weight=>1)
+ pack(:side=>:bottom, :fill=>:x)
+}
+
+b1 = Ttk::Menubutton.new(base_frame,:text=>'テーマをé¸æŠž',:direction=>:above)
+b2 = Ttk::Menubutton.new(base_frame,:text=>'テーマをé¸æŠž',:direction=>:left)
+b3 = Ttk::Menubutton.new(base_frame,:text=>'テーマをé¸æŠž',:direction=>:right)
+b4 = Ttk::Menubutton.new(base_frame,:text=>'テーマをé¸æŠž',:direction=>:flush,
+ :style=>Ttk::Menubutton.style('Toolbutton'))
+b5 = Ttk::Menubutton.new(base_frame,:text=>'テーマをé¸æŠž',:direction=>:below)
+
+b1.menu(m1 = Tk::Menu.new(b1, :tearoff=>false))
+b2.menu(m2 = Tk::Menu.new(b2, :tearoff=>false))
+b3.menu(m3 = Tk::Menu.new(b3, :tearoff=>false))
+b4.menu(m4 = Tk::Menu.new(b4, :tearoff=>false))
+b5.menu(m5 = Tk::Menu.new(b5, :tearoff=>false))
+
+Ttk.themes.each{|theme|
+ m1.add(:command, :label=>theme, :command=>proc{Ttk.set_theme theme})
+ m2.add(:command, :label=>theme, :command=>proc{Ttk.set_theme theme})
+ m3.add(:command, :label=>theme, :command=>proc{Ttk.set_theme theme})
+ m4.add(:command, :label=>theme, :command=>proc{Ttk.set_theme theme})
+ m5.add(:command, :label=>theme, :command=>proc{Ttk.set_theme theme})
+}
+
+f = Ttk::Frame.new(base_frame).pack(:fill=>:x)
+f1 = Ttk::Frame.new(base_frame).pack(:fill=>:both, :expand=>true)
+f.lower
+
+f.grid_anchor(:center)
+TkGrid('x', b1, 'x', :in=>f, :padx=>3, :pady=>2)
+TkGrid(b2, b4, b3, :in=>f, :padx=>3, :pady=>2)
+TkGrid('x', b5, 'x', :in=>f, :padx=>3, :pady=>2)
diff --git a/jni/ruby/ext/tk/sample/demos-jp/ttknote.rb b/jni/ruby/ext/tk/sample/demos-jp/ttknote.rb
new file mode 100644
index 0000000..f3b2fa5
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/demos-jp/ttknote.rb
@@ -0,0 +1,97 @@
+# -*- coding: utf-8 -*-
+#
+# ttknote.rb --
+#
+# This demonstration script creates a toplevel window containing a Ttk
+# notebook widget.
+#
+# based on "Id: ttknote.tcl,v 1.5 2007/12/13 15:27:07 dgp Exp"
+
+if defined?($ttknote_demo) && $ttknote_demo
+ $ttknote_demo.destroy
+ $ttknote_demo = nil
+end
+
+$ttknote_demo = TkToplevel.new {|w|
+ title("Ttk Notebook Widget")
+ iconname("ttknote")
+ positionWindow(w)
+}
+
+## See Code / Dismiss
+Ttk::Frame.new($ttknote_demo) {|frame|
+ sep = Ttk::Separator.new(frame)
+ Tk.grid(sep, :columnspan=>4, :row=>0, :sticky=>'ew', :pady=>2)
+ TkGrid('x',
+ Ttk::Button.new(frame, :text=>'コードå‚ç…§',
+ :image=>$image['view'], :compound=>:left,
+ :command=>proc{showCode 'ttknote'}),
+ Ttk::Button.new(frame, :text=>'é–‰ã˜ã‚‹',
+ :image=>$image['delete'], :compound=>:left,
+ :command=>proc{
+ $ttknote_demo.destroy
+ $ttknote_demo = nil
+ }),
+ :padx=>4, :pady=>4)
+ grid_columnconfigure(0, :weight=>1)
+ pack(:side=>:bottom, :fill=>:x)
+}
+
+base_frame = Ttk::Frame.new($ttknote_demo).pack(:fill=>:both, :expand=>true)
+
+## Make the notebook and set up Ctrl+Tab traversal
+notebook = Ttk::Notebook.new(base_frame).pack(:fill=>:both, :expand=>true,
+ :padx=>2, :pady=>3)
+notebook.enable_traversal
+
+## Popuplate the first pane
+f_msg = Ttk::Frame.new(notebook)
+msg_m = Ttk::Label.new(f_msg, :font=>$font, :wraplength=>'5i',
+ :justify=>:left, :anchor=>'n', :text=><<EOL)
+Ttkã¨ã¯ï¼Œãƒ†ãƒ¼ãƒžæŒ‡å®šå¯èƒ½ãªæ–°ã—ã„ウィジェット集åˆã§ã™ï¼Ž\
+ãã®ä¸­ã«å«ã¾ã‚Œã‚‹ã‚¦ã‚£ã‚¸ã‚§ãƒƒãƒˆã®ã²ã¨ã¤ã«ãƒŽãƒ¼ãƒˆãƒ–ックウィジェットãŒã‚ã‚Šã¾ã™ï¼Ž\
+ノートブックウィジェットã¯ï¼Œ\
+個別ã®å†…容をæŒã£ãŸãƒ‘ãƒãƒ«ã‹ã‚‰ã®é¸æŠžã‚’å¯èƒ½ã«ã™ã‚‹ã‚ˆã†ãª\
+タブã®é›†åˆï¼ˆã‚¿ãƒ–セット)を定ã‚ã¾ã™ï¼Ž\
+タブセットã¯æœ€è¿‘ã®å¤šãã®ãƒ¦ãƒ¼ã‚¶ã‚¤ãƒ³ã‚¿ãƒ¼ãƒ•ã‚§ãƒ¼ã‚¹ã§è¦‹ã‚‰ã‚Œã‚‹æ©Ÿèƒ½ã§ã™ï¼Ž\
+タブã®é¸æŠžã¯ï¼Œãƒžã‚¦ã‚¹ã«ã‚ˆã‚‹ã ã‘ã§ãªã,\
+ノートブックウィジェットã®ãƒšãƒ¼ã‚¸ã®è¦‹å‡ºã—ãŒé¸æŠžã•ã‚Œã¦ã„る時ã§ã‚ã‚Œã°\
+Ctrl+Tabキーã®å…¥åŠ›ã«ã‚ˆã£ã¦ã‚‚è¡Œã†ã“ã¨ãŒã§ãã¾ã™ï¼Ž\
+ã“ã®ãƒ‡ãƒ¢ã§ã¯ï¼Œè¦‹å‡ºã—ã§ä¸‹ç·šä»˜ãã®æ–‡å­—ã®ã‚­ãƒ¼ã¨Altキーã¨ã‚’組ã¿åˆã‚ã›ã‚‹ã“ã¨ã§\
+ページをé¸æŠžã™ã‚‹ã“ã¨ãŒã§ãるよã†ã«ã‚‚設定ã—ã¦ã„ã¾ã™ï¼Ž\
+ãŸã ã—,2番目ã®ã‚¿ãƒ–ã¯ç„¡åŠ¹åŒ–ã•ã‚Œã¦é¸æŠžã§ããªã„よã†ã«ãªã£ã¦ã„ã‚‹ã“ã¨ã«ã¯\
+注æ„ã—ã¦ãã ã•ã„.
+EOL
+neat = TkVariable.new
+after_id = nil
+msg_b = Ttk::Button.new(f_msg, :text=>'ã™ã¦ãã ï¼(Neat!)', :underline=>6,
+ :command=>proc{
+ neat.value = 'ã‚ã,ãã®ã¨ãŠã‚Šã•ï¼Žï¼Žï¼Ž'
+ Tk.after_cancel(after_id) if after_id
+ after_id = Tk.after(500){neat.value = ''}
+ })
+msg_b.winfo_toplevel.bind('Alt-n'){ msg_b.focus; msg_b.invoke }
+msg_l = Ttk::Label.new(f_msg, :textvariable=>neat)
+notebook.add(f_msg, :text=>'説明(Description)', :underline=>3, :padding=>2)
+Tk.grid(msg_m, '-', :sticky=>'new', :pady=>2)
+Tk.grid(msg_b, msg_l, :pady=>[2, 4], :padx=>20)
+msg_b.grid_configure(:sticky=>'e')
+msg_l.grid_configure(:sticky=>'w')
+f_msg.grid_rowconfigure(1, :weight=>1)
+f_msg.grid_columnconfigure([0, 1], :weight=>1, :uniform=>1)
+
+## Populate the second pane. Note that the content doesn't really matter
+f_disabled = Ttk::Frame.new(notebook)
+notebook.add(f_disabled, :text=>'無効化ã•ã‚ŒãŸã‚¿ãƒ–', :state=>:disabled)
+
+## Popuplate the third pane
+f_editor = Ttk::Frame.new(notebook)
+notebook.add(f_editor, :text=>'テキストエディタ(Text Editor)', :underline=>9)
+editor_t = Tk::Text.new(f_editor, :width=>40, :height=>10, :wrap=>:char)
+if Tk.windowingsystem != 'aqua'
+ editor_s = editor_t.yscrollbar(Ttk::Scrollbar.new(f_editor))
+else
+ editor_s = editor_t.yscrollbar(Tk::Scrollbar.new(f_editor))
+end
+editor_s.pack(:side=>:right, :fill=>:y, :padx=>[0,2], :pady=>2)
+editor_t.pack(:fill=>:both, :expand=>true, :padx=>[2,0], :pady=>2)
diff --git a/jni/ruby/ext/tk/sample/demos-jp/ttkpane.rb b/jni/ruby/ext/tk/sample/demos-jp/ttkpane.rb
new file mode 100644
index 0000000..a5c1a08
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/demos-jp/ttkpane.rb
@@ -0,0 +1,216 @@
+# -*- coding: utf-8 -*-
+#
+# ttkpane.rb --
+#
+# This demonstration script creates a Ttk pane with some content.
+#
+# based on "Id: ttkpane.tcl,v 1.3 2007/12/13 15:27:07 dgp Exp"
+
+if defined?($ttkpane_demo) && $ttkpane_demo
+ $ttkpane_demo.destroy
+ $ttkpane_demo = nil
+end
+
+$ttkpane_demo = TkToplevel.new {|w|
+ title("Themed Nested Panes")
+ iconname("ttkpane")
+ positionWindow(w)
+}
+
+base_frame = TkFrame.new($ttkpane_demo).pack(:fill=>:both, :expand=>true)
+
+Ttk::Label.new(base_frame, :font=>$font, :wraplength=>'4i', :justify=>:left,
+ :text=><<EOL).pack(:side=>:top, :fill=>:x)
+ã“ã®ãƒ‡ãƒ¢ã¯ï¼ŒåŸ‹ã‚è¾¼ã¿é–¢ä¿‚ã«ã‚るテーマ付ãペインドウィンドウを示ã—ã¦ã„ã¾ã™ï¼Ž\
+ãã‚Œãžã‚Œã®å¤§ãã•ã¯ï¼Œå«ã¾ã‚Œã¦ã„るペインã®é–“ã«ã‚るエリアをã¤ã‹ã‚“ã§\
+境界をドラッグã™ã‚‹ã“ã¨ã§å¤‰æ›´ã§ãã¾ã™ï¼Ž
+EOL
+
+Ttk::Separator.new(base_frame).pack(:side=>:top, :fill=>:x)
+
+## See Code / Dismiss
+Ttk::Frame.new(base_frame) {|frame|
+ sep = Ttk::Separator.new(frame)
+ Tk.grid(sep, :columnspan=>4, :row=>0, :sticky=>'ew', :pady=>2)
+ TkGrid('x',
+ Ttk::Button.new(frame, :text=>'コードå‚ç…§',
+ :image=>$image['view'], :compound=>:left,
+ :command=>proc{showCode 'ttkpane'}),
+ Ttk::Button.new(frame, :text=>'é–‰ã˜ã‚‹',
+ :image=>$image['delete'], :compound=>:left,
+ :command=>proc{
+ $ttkpane_demo.destroy
+ $ttkpane_demo = nil
+ }),
+ :padx=>4, :pady=>4)
+ grid_columnconfigure(0, :weight=>1)
+ pack(:side=>:bottom, :fill=>:x)
+}
+
+frame = Ttk::Frame.new(base_frame).pack(:fill=>:both, :expand=>true)
+
+outer = Ttk::Panedwindow.new(frame, :orient=>:horizontal)
+outer.add(in_left = Ttk::Panedwindow.new(outer, :orient=>:vertical))
+outer.add(in_right = Ttk::Panedwindow.new(outer, :orient=>:vertical))
+in_left.add(left_top = Ttk::Labelframe.new(in_left, :text=>'ボタン'))
+in_left.add(left_bot = Ttk::Labelframe.new(in_left, :text=>'時計'))
+in_right.add(right_top = Ttk::Labelframe.new(in_right, :text=>'プログレス'))
+in_right.add(right_bot = Ttk::Labelframe.new(in_right, :text=>'テキスト'))
+if Tk.windowingsystem == 'aqua'
+ [left_top, left_bot, right_top, right_bot].each{|w| w.padding(3) }
+end
+
+# Fill the button pane
+Ttk::Button.new(left_top, :text=>'押ã—ã¦ã­',
+ :command=>proc{
+ Tk.messageBox(:type=>'ok', :icon=>'info',
+ :message=>'ã„ã¦ã¦ï¼',
+ :detail=>'That hurt...', :parent=>base_frame,
+ :title=>'Button Pressed')
+ }).pack(:padx=>2, :pady=>5)
+
+
+zones_list = [
+ [':Europe/Berlin'],
+ [':America/Argentina/Buenos_Aires', ':America/Buenos_Aires'],
+ [':Africa/Johannesburg'],
+ [':Europe/London'],
+ [':America/Los_Angeles'],
+ [':Europe/Moscow'],
+ [':America/New_York'],
+ [':Asia/Singapore'],
+ [':Australia/Sydney'],
+ [':Asia/Tokyo'],
+]
+
+zones = []
+
+# Check tzinfo support
+if $tk_major_ver > 8 || ($tk_major_ver == 8 && $tk_minor_ver >= 5)
+ tzinfo = :tcl
+
+ zones_list.each{|list|
+ list.each{|zone|
+ begin
+ # Force a pre-load of all the timezones needed; otherwise can end up
+ # poor-looking synch problems!
+ Tk.tk_call('clock', 'format', '0', '-timezone', zone)
+ rescue RuntimeError
+ # ignore
+ else
+ zones << [zone, zone[%r<[^/:]+$>].tr('_', ' ')]
+ break
+ end
+ }
+ }
+
+else
+ begin
+ require 'tzinfo'
+ tzinfo = :tzinfo
+ rescue Exception
+ begin
+ require 'tzfile'
+ tzinfo = :tzfile
+ rescue Exception
+ tzinfo = nil
+ end
+ end
+
+ case tzinfo
+ when :tzinfo
+ zones_list.each{|list|
+ list.each{|zone|
+ begin
+ tz = TZInfo::Timezone.get(zone[%r<[^:]+$>])
+ rescue Exception
+ # ignore
+ else
+ zones << [tz, zone[%r<[^/:]+$>].tr('_', ' ')]
+ break
+ end
+ }
+ }
+
+ when :tzfile
+ zones_list.each{|list|
+ list.each{|zone|
+ begin
+ tz = TZFile.create(zone[%r<[^:]+$>])
+ rescue Exception
+ # ignore
+ else
+ zones << [tz, zone[%r<[^/:]+$>].tr('_', ' ')]
+ break
+ end
+ }
+ }
+
+ else
+ [ -7, -4, -2, -1, 0, +1, +3, +8, +9, +10 ].each{|zone|
+ zones << [zone, 'UTC%+03d00' % zone]
+ }
+ end
+end
+
+time = TkVariable.new_hash
+
+case tzinfo
+when :tcl
+ update_proc = proc{|now, tz, label|
+ time[label] = Tk.tk_call('clock', 'format', now.tv_sec,
+ '-timezone', tz, '-format', '%T')
+ }
+when :tzinfo
+ update_proc = proc{|now, tz, label|
+ time[label] = tz.utc_to_local(now).strftime('%H:%M:%S')
+ }
+when :tzfile
+ update_proc = proc{|now, tz, label|
+ time[label] = tz.at(now.tv_sec).strftime('%H:%M:%S')
+ }
+else
+ update_proc = proc{|now, tz, label|
+ time[label] = (now + (tz * 3600)).strftime('%H:%M:%S')
+ }
+end
+
+# Fill the clocks pane
+zones.each_with_index{|(zone, label), idx|
+ Ttk::Separator.new(left_bot).pack(:fill=>:x) if idx > 0
+ Ttk::Label.new(left_bot, :text=>label, :anchor=>'w').pack(:fill=>:x)
+ Ttk::Label.new(left_bot, :textvariable=>time.ref(label),
+ :anchor=>'w').pack(:fill=>:x)
+}
+
+# Timer start
+every = proc{
+ now = Time.now.utc
+ zones.each{|zone, label| update_proc.call(now, zone, label) }
+}
+TkRTTimer.new(1000, -1, every).start(0, every)
+
+# Fill the progress pane
+Ttk::Progressbar.new(right_top, :mode=>:indeterminate).pack(:fill=>:both, :expand=>true).start
+
+# Fill the text pane
+if Tk.windowingsystem != 'aqua'
+ # The trick with the ttk::frame makes the text widget look like it fits with
+ # the current Ttk theme despite not being a themed widget itself. It is done
+ # by styling the frame like an entry, turning off the border in the text
+ # widget, and putting the text widget in the frame with enough space to allow
+ # the surrounding border to show through (2 pixels seems to be enough).
+ f = Ttk::Frame.new(right_bot, :style=>Ttk::Entry)
+ txt = TkText.new(frame, :wrap=>:word, :width=>30, :borderwidth=>0)
+ txt.pack(:fill=>:both, :expand=>true, :in=>f, :pady=>2, :padx=>2)
+ scr = txt.yscrollbar(Ttk::Scrollbar.new(frame))
+ scr.pack(:side=>:right, :fill=>:y, :in=>right_bot)
+ f.pack(:fill=>:both, :expand=>true)
+ outer.pack(:fill=>:both, :expand=>true)
+else
+ txt = TkText.new(frame, :wrap=>:word, :width=>30, :borderwidth=>0)
+ scr = txt.yscrollbar(TkScrollbar.new(frame))
+ scr.pack(:side=>:right, :fill=>:y, :in=>right_bot)
+ txt.pack(:fill=>:both, :expand=>true, :in=>right_bot)
+ outer.pack(:fill=>:both, :expand=>true, :padx=>10, :pady=>[6, 10])
+end
diff --git a/jni/ruby/ext/tk/sample/demos-jp/ttkprogress.rb b/jni/ruby/ext/tk/sample/demos-jp/ttkprogress.rb
new file mode 100644
index 0000000..ec28253
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/demos-jp/ttkprogress.rb
@@ -0,0 +1,71 @@
+# -*- coding: utf-8 -*-
+#
+# ttkprogress.rb --
+#
+# This demonstration script creates several progress bar widgets.
+#
+# based on "Id: ttkprogress.tcl,v 1.3 2007/12/13 15:27:07 dgp Exp"
+
+if defined?($ttkprogress_demo) && $ttkprogress_demo
+ $ttkprogress_demo.destroy
+ $ttkprogress_demo = nil
+end
+
+$ttkprogress_demo = TkToplevel.new {|w|
+ title("Progress Bar Demonstration")
+ iconname("ttkprogress")
+ positionWindow(w)
+}
+
+base_frame = TkFrame.new($ttkprogress_demo).pack(:fill=>:both, :expand=>true)
+
+Ttk::Label.new(base_frame, :font=>$font, :wraplength=>'4i', :justify=>:left,
+ :text=><<EOL).pack(:side=>:top, :fill=>:x)
+下ã«ã‚ã‚‹ã®ã¯äºŒã¤ã®ãƒ—ログレスãƒãƒ¼ã§ã™ï¼Ž\
+上ã®ã‚‚ã®ã¯"determinate"タイプã®ãƒ—ログレスãƒãƒ¼ã§ï¼Œ\
+例ãˆã°ãƒ—ログラムãŒä¸Žãˆã‚‰ã‚ŒãŸã‚¿ã‚¹ã‚¯ã‚’終了ã™ã‚‹ã¾ã§ã«ã©ã®ãらã„ã‹ã‹ã‚‹ã‹ã‚’\
+示ã™ã¨ããªã©ã«ç”¨ã„られã¾ã™ï¼Ž\
+下ã®ã‚‚ã®ã¯"indeterminate"タイプã®ãƒ—ログレスãƒãƒ¼ã§ï¼Œ\
+例ãˆã°ãƒ—ログラムãŒå®Ÿè¡Œä¸­(busy)ã§ã‚ã‚‹ã‚‚ã®ã®\
+終了ã¾ã§ã«ã©ã‚Œãらã„ã‹ã‹ã‚‹ã‹ã¯åˆ†ã‹ã‚‰ãªã„ã¨ã„ã†çŠ¶æ…‹ã‚’\
+示ã™ã¨ããªã©ã«ç”¨ã„られã¾ã™ï¼Ž\
+ã„ãšã‚Œã®ãƒ—ログレスãƒãƒ¼ã‚‚,ã™ã下ã«ã‚るボタンを使ã†ã“ã¨ã§\
+自動アニメーションモードã®ON/OFFを切替ãˆã‚‹ã“ã¨ãŒã§ãã¾ã™ï¼Ž
+EOL
+
+## See Code / Dismiss buttons
+Ttk::Frame.new(base_frame) {|frame|
+ sep = Ttk::Separator.new(frame)
+ Tk.grid(sep, :columnspan=>4, :row=>0, :sticky=>'ew', :pady=>2)
+ TkGrid('x',
+ Ttk::Button.new(frame, :text=>'コードå‚ç…§',
+ :image=>$image['view'], :compound=>:left,
+ :command=>proc{showCode 'ttkprogress'}),
+ Ttk::Button.new(frame, :text=>'é–‰ã˜ã‚‹',
+ :image=>$image['delete'], :compound=>:left,
+ :command=>proc{
+ $ttkprogress_demo.destroy
+ $ttkprogress_demo = nil
+ }),
+ :padx=>4, :pady=>4)
+ grid_columnconfigure(0, :weight=>1)
+ pack(:side=>:bottom, :fill=>:x)
+}
+
+frame = Ttk::Frame.new(base_frame).pack(:fill=>:both, :expand=>true)
+
+p1 = Ttk::Progressbar.new(frame, :mode=>:determinate)
+p2 = Ttk::Progressbar.new(frame, :mode=>:indeterminate)
+
+start = Ttk::Button.new(frame, :text=>'Start Progress',
+ :command=>proc{ p1.start; p2.start })
+stop = Ttk::Button.new(frame, :text=>'Stop Progress',
+ :command=>proc{ p1.stop; p2.stop })
+
+Tk.grid(p1, '-', :pady=>5, :padx=>10)
+Tk.grid(p2, '-', :pady=>5, :padx=>10)
+Tk.grid(start, stop, :padx=>10, :pady=>5)
+start.grid_configure(:sticky=>'e')
+stop.grid_configure(:sticky=>'w')
+frame.grid_columnconfigure(:all, :weight=>1)
+
diff --git a/jni/ruby/ext/tk/sample/demos-jp/twind.rb b/jni/ruby/ext/tk/sample/demos-jp/twind.rb
new file mode 100644
index 0000000..f13a137
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/demos-jp/twind.rb
@@ -0,0 +1,292 @@
+# -*- coding: utf-8 -*-
+#
+# text (embedded windows) widget demo (called by 'widget')
+#
+
+# toplevel widget ãŒå­˜åœ¨ã™ã‚Œã°å‰Šé™¤ã™ã‚‹
+if defined?($twind_demo) && $twind_demo
+ $twind_demo.destroy
+ $twind_demo = nil
+end
+
+# demo 用㮠toplevel widget を生æˆ
+$twind_demo = TkToplevel.new {|w|
+ title("Text Demonstration - Embedded Windows")
+ iconname("Embedded Windows")
+ positionWindow(w)
+}
+
+base_frame = TkFrame.new($twind_demo).pack(:fill=>:both, :expand=>true)
+
+# frame 生æˆ
+$twind_buttons = TkFrame.new(base_frame) {|frame|
+ TkButton.new(frame) {
+ #text '了解'
+ text 'é–‰ã˜ã‚‹'
+ command proc{
+ tmppath = $twind_demo
+ $twind_demo = nil
+ tmppath.destroy
+ }
+ }.pack('side'=>'left', 'expand'=>'yes')
+
+ TkButton.new(frame) {
+ text 'コードå‚ç…§'
+ command proc{showCode 'twind'}
+ }.pack('side'=>'left', 'expand'=>'yes')
+}
+$twind_buttons.pack('side'=>'bottom', 'fill'=>'x', 'pady'=>'2m')
+
+# frame 生æˆ
+$twind_text = nil
+TkFrame.new(base_frame, 'highlightthickness'=>2, 'borderwidth'=>2,
+ 'relief'=>'sunken') {|f|
+ $twind_text = TkText.new(f, 'setgrid'=>'true', 'font'=>$font,
+ 'width'=>'70', 'height'=>35, 'wrap'=>'word',
+ 'highlightthickness'=>0, 'borderwidth'=>0 ){|t|
+ TkScrollbar.new(f) {|s|
+ command proc{|*args| t.yview(*args)}
+ t.yscrollcommand proc{|first,last| s.set first,last}
+ }.pack('side'=>'right', 'fill'=>'y')
+ }.pack('expand'=>'yes', 'fill'=>'both')
+}.pack('expand'=>'yes', 'fill'=>'both')
+
+# タグ生æˆ
+$tag_center = TkTextTag.new($twind_text,
+ 'justify' =>'center',
+ 'spacing1'=>'5m',
+ 'spacing3'=>'5m' )
+$tag_buttons = TkTextTag.new($twind_text,
+ 'lmargin1'=>'1c',
+ 'lmargin2'=>'1c',
+ 'rmargin' =>'1c',
+ 'spacing1'=>'3m',
+ 'spacing2'=>0,
+ 'spacing3'=>0 )
+
+# テキストã®ç”Ÿæˆ
+$twind_text.insert('end',
+ 'テキストwidget上ã«ä»–ã®widgetを組ã¿è¾¼ã‚€ã“ã¨ãŒã§ãã¾ã™ã€‚')
+$twind_text.insert('end',
+ '組ã¿è¾¼ã¿ã‚¦ã‚£ãƒ³ãƒ‰ã‚¦ã¨å‘¼ã°ã‚Œã€ä»»æ„ã®widgetãŒå¯èƒ½ã§ã™ã€‚')
+$twind_text.insert('end',
+ '例ãˆã°ã€ã“ã“ã«2ã¤ã®ãƒœã‚¿ãƒ³widgetãŒçµ„ã¿è¾¼ã¾ã‚Œã¦ã„ã¾ã™ã€‚')
+$twind_text.insert('end', '最åˆã®ãƒœã‚¿ãƒ³ã‚’クリックã™ã¨æ°´å¹³æ–¹å‘ã®ã‚¹ã‚¯ãƒ­ãƒ¼ãƒ«ã‚’')
+TkTextWindow.new($twind_text, 'end',
+ 'window'=>TkButton.new($twind_text) {
+ #text 'ON'
+ text 'オン'
+ command proc{textWindOn $twind_text,$twind_buttons}
+ cursor 'top_left_arrow'
+ })
+$twind_text.insert('end', "ã«ã—ã¾ã™ã€‚ã¾ãŸ2ã¤ã‚ã®ãƒœã‚¿ãƒ³ã‚’クリックã™ã‚‹ã¨\n")
+$twind_text.insert('end', '水平方å‘ã®ã‚¹ã‚¯ãƒ­ãƒ¼ãƒ«ã‚’')
+TkTextWindow.new($twind_text, 'end',
+ 'window'=>TkButton.new($twind_text) {
+ #text 'OFF'
+ text 'オフ'
+ command proc{textWindOff $twind_text}
+ cursor 'top_left_arrow'
+ })
+$twind_text.insert('end', 'ã«ã—ã¾ã™ã€‚')
+
+$twind_text.insert('end', 'ã‚‚ã†ã²ã¨ã¤ã®ä¾‹ã§ã™ã€‚')
+TkTextWindow.new($twind_text, 'end',
+ 'window'=>TkButton.new($twind_text) {
+ text 'ã“ã“をクリック'
+ command proc{textWindPlot $twind_text}
+ cursor 'top_left_arrow'
+ })
+$twind_text.insert('end', 'ã™ã‚‹ã¨ã€x-yプロットãŒã“ã“ã«ç¾ã‚Œã¾ã™ã€‚')
+$mark_plot = TkTextMark.new($twind_text, 'insert')
+$mark_plot.gravity='left'
+$twind_text.insert('end', 'マウスã§ãƒ‡ãƒ¼ã‚¿ã‚’æç”»ã™ã‚‹ã“ã¨ãŒã§ãã¾ã™ã€‚')
+TkTextWindow.new($twind_text, 'end',
+ 'window'=>TkButton.new($twind_text) {
+ text '消去'
+ command proc{textWindDel $twind_text}
+ cursor 'top_left_arrow'
+ })
+$twind_text.insert('end', 'をクリックã™ã‚‹ã¨å…ƒã«æˆ»ã‚Šã¾ã™ã€‚
+
+')
+
+$twind_text.insert('end', '組ã¿è¾¼ã¿ã‚¦ã‚£ãƒ³ãƒ‰ã‚¦ã ã‘をテキストwidget上ã«ã€å®Ÿéš›ã®')
+$twind_text.insert('end', 'テキストã¯ãªã—ã§çµ„ã¿è¾¼ã‚€ã“ã¨ã¯ä¾¿åˆ©ã§ã™ã€‚')
+$twind_text.insert('end', 'ã“ã®å ´åˆã¯ã€ãƒ†ã‚­ã‚¹ãƒˆwidgetã¯ã‚¦ã‚£ãƒ³ãƒ‰ã‚¦ãƒžãƒãƒ¼ã‚¸ãƒ£ã®')
+$twind_text.insert('end', 'よã†ã«å‹•ä½œã—ã¾ã™ã€‚例ãˆã°ã€ã“ã“ã«ã¯ãƒ†ã‚­ã‚¹ãƒˆwidgetã«')
+$twind_text.insert('end', 'よã£ã¦ãƒœã‚¿ãƒ³ãŒãã‚Œã„ã«ä¸¦ã¹ã‚‰ã‚Œã¦ã„ã¾ã™ã€‚')
+$twind_text.insert('end', 'ã“れらã®ãƒœã‚¿ãƒ³ã§èƒŒæ™¯è‰²ã‚’変ãˆã‚‹ã“ã¨ãŒã§ãã¾ã™')
+$twind_text.insert('end', '("Default"ã§å…ƒã®è‰²ã«æˆ»ã™ã“ã¨ãŒã§ãã¾ã™)。')
+$twind_text.insert('end', '"Short"ã¨ã„ã†ãƒœã‚¿ãƒ³ã‚’クリックã™ã‚‹ã¨æ–‡å­—列ã®é•·ã•ãŒ')
+$twind_text.insert('end', '変ã‚ã‚Šã¾ã™ã€‚ã™ã‚‹ã¨è‡ªå‹•çš„ã«ãƒ†ã‚­ã‚¹ãƒˆwidgetãŒ')
+$twind_text.insert('end', 'レイアウトを整ãˆã¦ãã‚Œã¾ã™ã€‚')
+$twind_text.insert('end', 'ã‚‚ã†ä¸€åº¦åŒã˜ãƒœã‚¿ãƒ³ã‚’押ã™ã¨å…ƒã«æˆ»ã‚Šã¾ã™ã€‚
+
+')
+
+TkTextWindow.new($twind_text, 'end',
+ 'window'=>TkButton.new($twind_text) {|b|
+ text 'デフォルト'
+ command proc{embDefBg $twind_text}
+ cursor 'top_left_arrow'
+ $tag_buttons.add('end')
+ },
+ 'padx'=>3 )
+embToggle = TkVariable.new('Short')
+TkTextWindow.new($twind_text, 'end',
+ 'window'=>TkCheckButton.new($twind_text) {
+ textvariable embToggle
+ indicatoron 0
+ variable embToggle
+ onvalue 'A much longer string'
+ offvalue 'Short'
+ cursor 'top_left_arrow'
+ pady 5
+ padx 2
+ },
+ 'padx'=>3,
+ 'pady'=>2 )
+
+[ 'AntiqueWhite3', 'Bisque1', 'Bisque2', 'Bisque3', 'Bisque4',
+ 'SlateBlue3', 'RoyalBlue1', 'SteelBlue2', 'DeepSkyBlue3', 'LightBlue1',
+ 'DarkSlateGray1', 'Aquamarine2', 'DarkSeaGreen2', 'SeaGreen1',
+ 'Yellow1', 'IndianRed1', 'IndianRed2', 'Tan1', 'Tan4'
+].each{|twind_color|
+ TkTextWindow.new($twind_text, 'end',
+ 'window'=>TkButton.new($twind_text) {
+ text twind_color
+ cursor 'top_left_arrow'
+ command proc{$twind_text.bg twind_color}
+ },
+ 'padx'=>3,
+ 'pady'=>2 )
+}
+
+# メソッド定義
+def textWindOn (w,f)
+ if defined? $twind_scroll
+ begin
+ $twind_scroll.destroy
+ rescue
+ end
+ $twind_scroll = nil
+ end
+
+ base = TkWinfo.parent( TkWinfo.parent(w) )
+ $twind_scroll = TkScrollbar.new(base) {|s|
+ orient 'horizontal'
+ command proc{|*args| w.xview(*args)}
+ w.xscrollcommand proc{|first,last| s.set first,last}
+ w.wrap 'none'
+ pack('after'=>f, 'side'=>'bottom', 'fill'=>'x')
+ }
+
+ return nil
+end
+
+def textWindOff (w)
+ if defined? $twind_scroll
+ begin
+ $twind_scroll.destroy
+ rescue
+ end
+ $twind_scroll = nil
+ end
+ w.xscrollcommand ''
+ w.wrap 'word'
+end
+
+def textWindPlot (t)
+ if (defined? $twind_plot) && (TkWinfo.exist?($twind_plot))
+ return
+ end
+
+ $twind_plot = TkCanvas.new(t) {
+ relief 'sunken'
+ width 450
+ height 300
+ cursor 'top_left_arrow'
+ }
+
+ if $tk_version =~ /^4.*/
+ font = '-Adobe-Helvetica-Medium-R-Normal--*-180-*-*-*-*-*-*'
+ else
+ font = 'Helvetica 18'
+ end
+
+ TkcLine.new($twind_plot, 100, 250, 400, 250, 'width'=>2)
+ TkcLine.new($twind_plot, 100, 250, 100, 50, 'width'=>2)
+ TkcText.new($twind_plot, 225, 20,
+ 'text'=>"A Simple Plot", 'font'=>font, 'fill'=>'brown')
+
+ (0..10).each {|i|
+ x = 100 + (i * 30)
+ TkcLine.new($twind_plot, x, 250, x, 245, 'width'=>2)
+ TkcText.new($twind_plot, x, 254,
+ 'text'=>10*i, 'font'=>font, 'anchor'=>'n')
+ }
+ (0..5).each {|i|
+ y = 250 - (i * 40)
+ TkcLine.new($twind_plot, 100, y, 105, y, 'width'=>2)
+ TkcText.new($twind_plot, 96, y,
+ 'text'=>"#{i*50}.0", 'font'=>font, 'anchor'=>'e')
+ }
+
+ for xx, yy in [[12,56],[20,94],[33,98],[32,120],[61,180],[75,160],[98,223]]
+ x = 100 + (3*xx)
+ y = 250 - (4*yy)/5
+ item = TkcOval.new($twind_plot, x-6, y-6, x+6, y+6,
+ 'width'=>1, 'outline'=>'black', 'fill'=>'SkyBlue2')
+ item.addtag 'point'
+ end
+
+ $twind_plot.itembind('point', 'Any-Enter',
+ proc{$twind_plot.itemconfigure 'current', 'fill', 'red'})
+ $twind_plot.itembind('point', 'Any-Leave',
+ proc{$twind_plot.itemconfigure 'current', 'fill', 'SkyBlue2'})
+ $twind_plot.itembind('point', '1',
+ proc{|x,y| embPlotDown $twind_plot,x,y}, "%x %y")
+ $twind_plot.itembind('point', 'ButtonRelease-1',
+ proc{$twind_plot.dtag 'selected'})
+ $twind_plot.bind('B1-Motion',
+ proc{|x,y| embPlotMove $twind_plot,x,y}, "%x %y")
+ while ($twind_text.get($mark_plot) =~ /[ \t\n]/)
+ $twind_text.delete $mark_plot
+ end
+ $twind_text.insert $mark_plot,"\n"
+ TkTextWindow.new($twind_text, $mark_plot, 'window'=>$twind_plot)
+ $tag_center.add $mark_plot
+ $twind_text.insert $mark_plot,"\n"
+end
+
+$embPlot = {'lastX'=>0, 'lastY'=>0}
+
+def embPlotDown (w, x, y)
+ w.dtag 'selected'
+ w.addtag_withtag 'selected', 'current'
+ w.raise 'current'
+ $embPlot['lastX'] = x
+ $embPlot['lastY'] = y
+end
+
+def embPlotMove (w, x, y)
+ w.move 'selected', x - $embPlot['lastX'], y - $embPlot['lastY']
+ $embPlot['lastX'] = x
+ $embPlot['lastY'] = y
+end
+
+def textWindDel (w)
+ if (defined? $twind_text) && TkWinfo.exist?($twind_plot)
+ $twind_text.delete $twind_plot
+ $twind_plot = nil
+ while ($twind_text.get($mark_plot) =~ /[ \t\n]/)
+ $twind_text.delete $mark_plot
+ end
+ $twind_text.insert $mark_plot," "
+ end
+end
+
+def embDefBg (w)
+ w['background'] = w.configinfo('background')[3]
+end
diff --git a/jni/ruby/ext/tk/sample/demos-jp/twind2.rb b/jni/ruby/ext/tk/sample/demos-jp/twind2.rb
new file mode 100644
index 0000000..a783ba4
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/demos-jp/twind2.rb
@@ -0,0 +1,384 @@
+# -*- coding: utf-8 -*-
+#
+# text (embedded windows) widget demo 2 (called by 'widget')
+#
+
+# toplevel widget ãŒå­˜åœ¨ã™ã‚Œã°å‰Šé™¤ã™ã‚‹
+if defined?($twind2_demo) && $twind2_demo
+ $twind2_demo.destroy
+ $twind2_demo = nil
+end
+
+# demo 用㮠toplevel widget を生æˆ
+$twind2_demo = TkToplevel.new {|w|
+ title("Text Demonstration - Embedded Windows 2")
+ iconname("Embedded Windows")
+ positionWindow(w)
+}
+
+base_frame = TkFrame.new($twind2_demo).pack(:fill=>:both, :expand=>true)
+
+# frame 生æˆ
+$twind2_buttons = TkFrame.new(base_frame) {|frame|
+ TkGrid(TkFrame.new(frame, :height=>2, :relief=>:sunken, :bd=>2),
+ :columnspan=>4, :row=>0, :sticky=>'ew', :pady=>2)
+ TkGrid('x',
+ TkButton.new(frame, :text=>'コードå‚ç…§',
+ :image=>$image['view'], :compound=>:left,
+ :command=>proc{showCode 'twind2'}),
+ TkButton.new(frame, :text=>'é–‰ã˜ã‚‹',
+ :image=>$image['delete'], :compound=>:left,
+ :command=>proc{
+ tmppath = $twind2_demo
+ $twind2_demo = nil
+ $showVarsWin[tmppath.path] = nil
+ tmppath.destroy
+ }),
+ :padx=>4, :pady=>4)
+ frame.grid_columnconfigure(0, :weight=>1)
+}
+$twind2_buttons.pack('side'=>'bottom', 'fill'=>'x', 'pady'=>'2m')
+
+# frame 生æˆ
+$twind2_text = nil
+TkFrame.new(base_frame, 'highlightthickness'=>2, 'borderwidth'=>2,
+ 'relief'=>'sunken') {|f|
+ $twind2_text = TkText.new(f, 'setgrid'=>true, 'font'=>$font,
+ # 'width'=>'70', 'height'=>35, 'wrap'=>'word',
+ 'width'=>'70', 'height'=>35, 'wrap'=>'char',
+ 'highlightthickness'=>0, 'borderwidth'=>0 ){|t|
+ TkScrollbar.new(f) {|s|
+ command proc{|*args| t.yview(*args)}
+ t.yscrollcommand proc{|first,last| s.set first,last}
+ }.pack('side'=>'right', 'fill'=>'y')
+ }.pack('expand'=>'yes', 'fill'=>'both')
+}.pack('expand'=>'yes', 'fill'=>'both')
+
+# タグ生æˆ
+$tag2_center = TkTextTag.new($twind2_text,
+ 'justify' =>'center',
+ 'spacing1'=>'5m',
+ 'spacing3'=>'5m' )
+$tag2_buttons = TkTextTag.new($twind2_text,
+ 'lmargin1'=>'1c',
+ 'lmargin2'=>'1c',
+ 'rmargin' =>'1c',
+ 'spacing1'=>'3m',
+ 'spacing2'=>0,
+ 'spacing3'=>0 )
+
+# テキストã®ç”Ÿæˆ
+$twind2_text.insert('end', 'テキストウィジェットã«ã¯è‰²ã€…ãªç¨®é¡žã®ã‚¢ã‚¤ãƒ†ãƒ ')
+$twind2_text.insert('end', '(動的ãªã‚‚ã®ã‚„é™çš„ãªã‚‚ã®ã®ä¸¡æ–¹ãŒã‚ã‚Šã¾ã™ï¼‰ã‚’')
+$twind2_text.insert('end', '数多ãå«ã‚ã‚‹ã“ã¨ãŒã§ãã¾ã™ã€‚ãã†ã—ãŸã‚¢ã‚¤ãƒ†ãƒ ã¯')
+$twind2_text.insert('end', '行替ãˆã€ã‚¿ãƒ–ã€ä¸­å¤®æƒãˆãªã©ã®æ§˜ã€…ãªæ–¹æ³•ã§')
+$twind2_text.insert('end', 'é…ç½®ã™ã‚‹ã“ã¨ãŒã§ãã¾ã™ã€‚')
+$twind2_text.insert('end', '加ãˆã¦ã€ãƒ†ã‚­ã‚¹ãƒˆã‚¦ã‚£ã‚¸ã‚§ãƒƒãƒˆã®å†…容物ãŒ')
+$twind2_text.insert('end', 'ウィンドウサイズã«æ¯”ã¹ã¦å¤§ãã™ãŽã‚‹å ´åˆã§ã‚‚')
+$twind2_text.insert('end', 'ã™ã¹ã¦ã®æ–¹å‘ã«ã‚¹ãƒ ãƒ¼ã‚ºã«ã‚¹ã‚¯ãƒ­ãƒ¼ãƒ«ã•ã›ã¦')
+$twind2_text.insert('end', '確èªã™ã‚‹ã“ã¨ãŒå¯èƒ½ã§ã™ã€‚')
+$twind2_text.insert('end', "\n\n")
+$twind2_text.insert('end', 'テキストウィジェット上ã«ã¯ä»–ã®ã‚¦ã‚£ã‚¸ã‚§ãƒƒãƒˆã‚’')
+$twind2_text.insert('end', 'å«ã‚ã‚‹ã“ã¨ã‚‚ã§ãã¾ã™ã€‚ã“ã†ã—ãŸã‚‚ã®ã¯')
+$twind2_text.insert('end', '「埋ã‚è¾¼ã¿ã‚¦ã‚£ãƒ³ãƒ‰ã‚¦ã€ã¨å‘¼ã°ã‚Œã€ãã®ä¸­ã«')
+$twind2_text.insert('end', 'ã„ã‹ãªã‚‹ã‚¦ã‚£ã‚¸ã‚§ãƒƒãƒˆã§ã‚‚è©°ã‚込むã“ã¨ãŒã§ãã¾ã™ã€‚')
+$twind2_text.insert('end', '例ãˆã°ï¼Œã“ã“ã«ã¯ï¼’ã¤ã®')
+$twind2_text.insert('end', 'ボタンウィジェットãŒåŸ‹ã‚è¾¼ã¾ã‚Œã¦ã„ã¾ã™ã€‚')
+$twind2_text.insert('end', '最åˆã®ãƒœã‚¿ãƒ³ã‚’クリックã™ã‚‹ã¨ã€')
+$twind2_text.insert('end', '水平方å‘ã®ã‚¹ã‚¯ãƒ­ãƒ¼ãƒ«ã‚’ ')
+TkTextWindow.new($twind2_text, 'end',
+ 'window'=>TkButton.new($twind2_text) {
+ #text 'ON'
+ text 'オン'
+ command proc{textWindOn2 $twind2_text,$twind2_buttons}
+ cursor 'top_left_arrow'
+ })
+$twind2_text.insert('end', "ã«ã—ã¾ã™ã€‚ã¾ãŸã€ï¼’ã¤ã‚ã®ãƒœã‚¿ãƒ³ã‚’クリックã™ã‚‹ã¨\n")
+$twind2_text.insert('end', '水平方å‘ã®ã‚¹ã‚¯ãƒ­ãƒ¼ãƒ«ã‚’')
+TkTextWindow.new($twind2_text, 'end',
+ 'window'=>TkButton.new($twind2_text) {
+ #text 'OFF'
+ text 'オフ'
+ command proc{textWindOff2 $twind2_text}
+ cursor 'top_left_arrow'
+ })
+$twind2_text.insert('end', "ã«ã—ã¾ã™ã€‚\n\n")
+
+$twind2_text.insert('end', '次ã¯ã‚‚ã†ã²ã¨ã¤ã®ä¾‹ã§ã™ã€‚')
+TkTextWindow.new($twind2_text, 'end',
+ 'window'=>TkButton.new($twind2_text) {
+ text 'ã“ã“をクリック'
+ command proc{textWindPlot2 $twind2_text}
+ cursor 'top_left_arrow'
+ })
+$twind2_text.insert('end', 'ã™ã‚‹ã¨ã€x-yプロットãŒã“ã“ã«ç¾ã‚Œã¾ã™ã€‚')
+$mark2_plot = TkTextMark.new($twind2_text, 'insert')
+$mark2_plot.gravity='left'
+$twind2_text.insert('end', 'マウスã§ãƒ‰ãƒ©ãƒƒã‚°ã™ã‚‹ã“ã¨ã§ã€')
+$twind2_text.insert('end', 'プロット上ã®ãƒ‡ãƒ¼ã‚¿ç‚¹ã‚’移動ã™ã‚‹ã“ã¨ãŒã§ãã¾ã™ã€‚')
+TkTextWindow.new($twind2_text, 'end',
+ 'window'=>TkButton.new($twind2_text) {
+ text '消去'
+ command proc{textWindDel2 $twind2_text}
+ cursor 'top_left_arrow'
+ })
+$twind2_text.insert('end', 'をクリックã™ã‚‹ã¨å…ƒã«æˆ»ã‚Šã¾ã™ã€‚')
+$twind2_text.insert('end', "\n\n")
+
+$twind2_text.insert('end', '表示ã™ã‚‹ãƒ†ã‚­ã‚¹ãƒˆãªã—ã«åŸ‹ã‚è¾¼ã¿ã‚¦ã‚£ãƒ³ãƒ‰ã‚¦ã ã‘ã‚’')
+$twind2_text.insert('end', 'テキストウィジェットã«å«ã‚ã‚‹ã“ã¨ã‚‚有用ã§ã—ょã†ã€‚')
+$twind2_text.insert('end', 'ã“ã®å ´åˆã€ãƒ†ã‚­ã‚¹ãƒˆã‚¦ã‚£ã‚¸ã‚§ãƒƒãƒˆã¯')
+$twind2_text.insert('end', 'ジオメトリマãƒãƒ¼ã‚¸ãƒ£ã®ã‚ˆã†ã«åƒãã¾ã™ã€‚')
+$twind2_text.insert('end', '例ãˆã°ã€ã“ã“ã«ã¯ãƒ†ã‚­ã‚¹ãƒˆã‚¦ã‚£ã‚¸ã‚§ãƒƒãƒˆã«')
+$twind2_text.insert('end', 'よã£ã¦ãƒœã‚¿ãƒ³ãŒãã‚Œã„ã«æ•´åˆ—ã—ã¦é…ç½®ã•ã‚Œã¦ã„ã¾ã™ã€‚')
+$twind2_text.insert('end', 'ã“れらã®ãƒœã‚¿ãƒ³ã‚’クリックã™ã‚‹ã“ã¨ã§ã€')
+$twind2_text.insert('end', 'ã“ã®ãƒ†ã‚­ã‚¹ãƒˆã‚¦ã‚£ã‚¸ã‚§ãƒƒãƒˆã®èƒŒæ™¯è‰²ã‚’')
+$twind2_text.insert('end', '変ãˆã‚‹ã“ã¨ãŒã§ãã¾ã™("デフォルト"ボタンã§')
+$twind2_text.insert('end', 'å…ƒã®è‰²ã«æˆ»ã™ã“ã¨ãŒã§ãã¾ã™)。')
+$twind2_text.insert('end', '"Short"ã¨ã„ã†ãƒœã‚¿ãƒ³ã‚’クリックã™ã‚‹ã¨æ–‡å­—列ã®é•·ã•ãŒ')
+$twind2_text.insert('end', '変ã‚ã‚Šã€ãƒ†ã‚­ã‚¹ãƒˆã‚¦ã‚£ã‚¸ã‚§ãƒƒãƒˆãŒè‡ªå‹•çš„ã«')
+$twind2_text.insert('end', 'レイアウトを整ãˆã‚‹æ§˜å­ã‚’見るã“ã¨ãŒã§ãã¾ã™ã€‚')
+$twind2_text.insert('end', 'ã‚‚ã†ä¸€åº¦åŒã˜ãƒœã‚¿ãƒ³ã‚’押ã™ã¨å…ƒã«æˆ»ã‚Šã¾ã™ã€‚')
+$twind2_text.insert('end', "\n")
+
+btn_default = TkButton.new($twind2_text) {|b|
+ text 'デフォルト'
+ command proc{embDefBg2 $twind2_text}
+ cursor 'top_left_arrow'
+}
+TkTextWindow.new($twind2_text, 'end', 'window'=>btn_default, 'padx'=>3)
+embToggle = TkVariable.new('Short')
+TkTextWindow.new($twind2_text, 'end',
+ 'window'=>TkCheckButton.new($twind2_text) {
+ textvariable embToggle
+ indicatoron 0
+ variable embToggle
+ onvalue 'A much longer string'
+ offvalue 'Short'
+ cursor 'top_left_arrow'
+ pady 5
+ padx 2
+ },
+ 'padx'=>3,
+ 'pady'=>2 )
+
+[ 'AntiqueWhite3', 'Bisque1', 'Bisque2', 'Bisque3', 'Bisque4',
+ 'SlateBlue3', 'RoyalBlue1', 'SteelBlue2', 'DeepSkyBlue3', 'LightBlue1',
+ 'DarkSlateGray1', 'Aquamarine2', 'DarkSeaGreen2', 'SeaGreen1',
+ 'Yellow1', 'IndianRed1', 'IndianRed2', 'Tan1', 'Tan4'
+].each{|twind_color|
+ TkTextWindow.new($twind2_text, 'end',
+ 'window'=>TkButton.new($twind2_text) {
+ text twind_color
+ cursor 'top_left_arrow'
+ command proc{$twind2_text.bg twind_color}
+ },
+ 'padx'=>3,
+ 'pady'=>2 )
+}
+
+$tag2_buttons.add(btn_default, 'end')
+
+$text_normal2 = {}
+$text_normal2['border'] = $twind2_text.cget('borderwidth')
+$text_normal2['highlight'] = $twind2_text.cget('highlightthickness')
+$text_normal2['pad'] = $twind2_text.cget('padx')
+
+$twind2_text.insert('end', "\nborder width ã‚„ highlightthickness, ")
+$twind2_text.insert('end', "padding を通常ã®å€¤ã‹ã‚‰å¤‰æ›´ã™ã‚‹ã“ã¨ã‚‚å¯èƒ½ã§ã™ã€‚\n")
+
+TkTextWindow.new($twind2_text, 'end',
+ 'window'=>TkButton.new($twind2_text, :text=>"Big borders",
+ :cursor=>'top_left_arrow',
+ 'command'=>proc{
+ textWinBigB2 $twind2_text
+ }))
+
+TkTextWindow.new($twind2_text, 'end',
+ 'window'=>TkButton.new($twind2_text, :text=>"Small borders",
+ :cursor=>'top_left_arrow',
+ 'command'=>proc{
+ textWinSmallB2 $twind2_text
+ }))
+
+TkTextWindow.new($twind2_text, 'end',
+ 'window'=>TkButton.new($twind2_text, :text=>"Big highlight",
+ :cursor=>'top_left_arrow',
+ 'command'=>proc{
+ textWinBigH2 $twind2_text
+ }))
+
+TkTextWindow.new($twind2_text, 'end',
+ 'window'=>TkButton.new($twind2_text, :text=>"Small highlight",
+ :cursor=>'top_left_arrow',
+ 'command'=>proc{
+ textWinSmallH2 $twind2_text
+ }))
+
+TkTextWindow.new($twind2_text, 'end',
+ 'window'=>TkButton.new($twind2_text, :text=>"Big pad",
+ :cursor=>'top_left_arrow',
+ 'command'=>proc{
+ textWinBigP2 $twind2_text
+ }))
+
+TkTextWindow.new($twind2_text, 'end',
+ 'window'=>TkButton.new($twind2_text, :text=>"Small pad",
+ :cursor=>'top_left_arrow',
+ 'command'=>proc{
+ textWinSmallP2 $twind2_text
+ }))
+
+$twind2_text.insert('end', "\n\næ›´ã«ã‚¤ãƒ¡ãƒ¼ã‚¸ã‚‚テキストウィジェットã«")
+$twind2_text.insert('end', "ã†ã¾ãé…ç½®ã§ãã¾ã™ï¼š")
+
+TkTextImage.new($twind2_text, 'end',
+ 'image'=>TkBitmapImage.new(:file=>[
+ $demo_dir, '..',
+ 'images', 'face.xbm'
+ ].join(File::Separator)))
+
+# メソッド定義
+def textWinBigB2(w)
+ w.borderwidth 15
+end
+def textWinSmallB2(w)
+ w.borderwidth $text_normal2['border']
+end
+def textWinBigH2(w)
+ w.highlightthickness 15
+end
+def textWinSmallH2(w)
+ w.highlightthickness $text_normal2['highlight']
+end
+def textWinBigP2(w)
+ w.configure(:padx=>15, :pady=>15)
+end
+def textWinSmallP2(w)
+ w.configure(:padx=>$text_normal2['pad'], :pady=>$text_normal2['pad'])
+end
+
+def textWindOn2 (w,f)
+ if defined? $twind2_scroll
+ begin
+ $twind2_scroll.destroy
+ rescue
+ end
+ $twind2_scroll = nil
+ end
+
+ base = TkWinfo.parent( TkWinfo.parent(w) )
+ $twind2_scroll = TkScrollbar.new(base) {|s|
+ orient 'horizontal'
+ command proc{|*args| w.xview(*args)}
+ w.xscrollcommand proc{|first,last| s.set first,last}
+ w.wrap 'none'
+ pack('after'=>f, 'side'=>'bottom', 'fill'=>'x')
+ }
+
+ return nil
+end
+
+def textWindOff2 (w)
+ if defined? $twind2_scroll
+ begin
+ $twind2_scroll.destroy
+ rescue
+ end
+ $twind2_scroll = nil
+ end
+ w.xscrollcommand ''
+ #w.wrap 'word'
+ w.wrap 'char'
+end
+
+def textWindPlot2 (t)
+ if (defined? $twind2_plot) && (TkWinfo.exist?($twind2_plot))
+ return
+ end
+
+ $twind2_plot = TkCanvas.new(t) {
+ relief 'sunken'
+ width 450
+ height 300
+ cursor 'top_left_arrow'
+ }
+
+ #font = '-Adobe-Helvetica-Medium-R-Normal--*-180-*-*-*-*-*-*'
+ font = 'Helvetica 18'
+
+ TkcLine.new($twind2_plot, 100, 250, 400, 250, 'width'=>2)
+ TkcLine.new($twind2_plot, 100, 250, 100, 50, 'width'=>2)
+ TkcText.new($twind2_plot, 225, 20,
+ 'text'=>"A Simple Plot", 'font'=>font, 'fill'=>'brown')
+
+ (0..10).each {|i|
+ x = 100 + (i * 30)
+ TkcLine.new($twind2_plot, x, 250, x, 245, 'width'=>2)
+ TkcText.new($twind2_plot, x, 254,
+ 'text'=>10*i, 'font'=>font, 'anchor'=>'n')
+ }
+ (0..5).each {|i|
+ y = 250 - (i * 40)
+ TkcLine.new($twind2_plot, 100, y, 105, y, 'width'=>2)
+ TkcText.new($twind2_plot, 96, y,
+ 'text'=>"#{i*50}.0", 'font'=>font, 'anchor'=>'e')
+ }
+
+ for xx, yy in [[12,56],[20,94],[33,98],[32,120],[61,180],[75,160],[98,223]]
+ x = 100 + (3*xx)
+ y = 250 - (4*yy)/5
+ item = TkcOval.new($twind2_plot, x-6, y-6, x+6, y+6,
+ 'width'=>1, 'outline'=>'black', 'fill'=>'SkyBlue2')
+ item.addtag 'point'
+ end
+
+ $twind2_plot.itembind('point', 'Any-Enter',
+ proc{$twind2_plot.itemconfigure 'current', 'fill', 'red'})
+ $twind2_plot.itembind('point', 'Any-Leave',
+ proc{$twind2_plot.itemconfigure 'current', 'fill', 'SkyBlue2'})
+ $twind2_plot.itembind('point', '1',
+ proc{|x,y| embPlotDown2 $twind2_plot,x,y}, "%x %y")
+ $twind2_plot.itembind('point', 'ButtonRelease-1',
+ proc{$twind2_plot.dtag 'selected'})
+ $twind2_plot.bind('B1-Motion',
+ proc{|x,y| embPlotMove2 $twind2_plot,x,y}, "%x %y")
+ while ($twind2_text.get($mark2_plot) =~ /[ \t\n]/)
+ $twind2_text.delete $mark2_plot
+ end
+ $twind2_text.insert $mark2_plot,"\n"
+ TkTextWindow.new($twind2_text, $mark2_plot, 'window'=>$twind2_plot)
+ $tag2_center.add $mark2_plot
+ $twind2_text.insert $mark2_plot,"\n"
+end
+
+$embPlot2 = {'lastX'=>0, 'lastY'=>0}
+
+def embPlotDown2 (w, x, y)
+ w.dtag 'selected'
+ w.addtag_withtag 'selected', 'current'
+ w.raise 'current'
+ $embPlot2['lastX'] = x
+ $embPlot2['lastY'] = y
+end
+
+def embPlotMove2 (w, x, y)
+ w.move 'selected', x - $embPlot2['lastX'], y - $embPlot2['lastY']
+ $embPlot2['lastX'] = x
+ $embPlot2['lastY'] = y
+end
+
+def textWindDel2 (w)
+ if (defined? $twind2_text) && TkWinfo.exist?($twind2_plot)
+ $twind2_text.delete $twind2_plot
+ $twind2_plot = nil
+ while ($twind2_text.get($mark2_plot) =~ /[ \t\n]/)
+ $twind2_text.delete $mark2_plot
+ end
+ $twind2_text.insert $mark2_plot," "
+ end
+end
+
+def embDefBg2 (w)
+ w['background'] = w.configinfo('background')[3]
+end
diff --git a/jni/ruby/ext/tk/sample/demos-jp/unicodeout.rb b/jni/ruby/ext/tk/sample/demos-jp/unicodeout.rb
new file mode 100644
index 0000000..31596cf
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/demos-jp/unicodeout.rb
@@ -0,0 +1,119 @@
+# -*- coding: utf-8 -*-
+#
+# unicodeout.rb --
+#
+# This demonstration script shows how you can produce output (in label
+# widgets) using many different alphabets.
+#
+# based on Tcl/Tk8.4.4 widget demos
+
+if defined?($unicodeout_demo) && $unicodeout_demo
+ $unicodeout_demo.destroy
+ $unicodeout_demo = nil
+end
+
+$unicodeout_demo = TkToplevel.new {|w|
+ title("Unicode Label Demonstration")
+ iconname("unicodeout")
+ positionWindow(w)
+}
+
+base_frame = TkFrame.new($unicodeout_demo).pack(:fill=>:both, :expand=>true)
+
+TkLabel.new(base_frame,
+ :font=>$font, :wraplength=>'5.4i', :justify=>:left,
+ :text=><<EOL).pack(:side=>:top)
+ã“ã‚Œã¯ï¼ŒTkã«ãŠã‘ã‚‹éžæ¬§ç±³æ–‡å­—集åˆã‚’用ã„る言語ã«å¯¾ã™ã‚‹ã‚µãƒãƒ¼ãƒˆã«ã¤ã„ã¦ã®\
+サンプルã§ã™ï¼ŽãŸã ã—,下ã®è¡¨ç¤ºã«ãŠã„ã¦ã‚ãªãŸãŒå®Ÿéš›ã«ã©ã®ã‚ˆã†ãªè¡¨ç¤ºã‚’\
+ç›®ã«ã™ã‚‹ã‹ã¯ï¼Œã‚ãªãŸã®ç’°å¢ƒã«ã©ã®ã‚ˆã†ãªæ–‡å­—集åˆãŒã‚¤ãƒ³ã‚¹ãƒˆãƒ¼ãƒ«ã•ã‚Œã¦ã„ã‚‹ã‹ã«\
+大ããä¾å­˜ã—ã¾ã™ï¼Žã¾ãŸï¼Œå¯¾è±¡ã¨ãªã‚‹æ–‡å­—集åˆãŒã‚¤ãƒ³ã‚¹ãƒˆãƒ¼ãƒ«ã•ã‚Œã¦ã„ãªã„å ´åˆã«\
+ã©ã®ã‚ˆã†ãªè¡¨ç¤ºãŒãªã•ã‚Œã‚‹ã‹ã‚‚ã‚ãªãŸã®ç’°å¢ƒæ¬¡ç¬¬ã§ã™ï¼Ž\
+「コードå‚ç…§ã€ãƒœã‚¿ãƒ³ã‚’押ã—ã¦ã‚½ãƒ¼ã‚¹ã‚’表示ã—,\
+Unicodeout_SampleFrameクラスã®@@fontã®å®šç¾©ã‚’書ãæ›ãˆã¦\
+(ファイルã®å†…容ã¯å¤‰æ›´ã•ã‚Œã¾ã›ã‚“)\
+「å†å®Ÿè¡Œã€ãƒœã‚¿ãƒ³ã®ã‚¯ãƒªãƒƒã‚¯ã‚’試ã—ã¦ã¿ã¦ãã ã•ã„.
+スクリプトãŒå¯æ¬æ€§ã‚’æŒã¤ã‚ˆã†ã«ï¼Œæ–‡å­—列ã¯\\uXXXXã¨ã„ã†\
+Tclã®ã‚¨ã‚¹ã‚±ãƒ¼ãƒ—表ç¾ã‚’用ã„ãŸUNICODE文字列ã§æ›¸ã‹ã‚Œã¦ã„ã¾ã™ï¼Ž\
+文字列ã¯ï¼ŒTk::UTF8_Stringメソッドã«ã‚ˆã£ã¦ï¼Œ\
+「UTF8å½¢å¼ã®æ–‡å­—列ã§ã‚ã‚‹ã€ã¨ã„ã†\
+エンコード情報付ãã®æ–‡å­—列オブジェクト\
+(Tclã®ã‚¨ã‚¹ã‚±ãƒ¼ãƒ—表ç¾ã®å¤‰æ›æ¸ˆã¿)ã«å¤‰æ›ã—ã¦\
+ラベルウィジェットã«æ¸¡ã—ã¦ã„る点ã«æ³¨æ„ã—ã¦ãã ã•ã„.
+EOL
+#'
+
+TkFrame.new(base_frame){|f|
+ pack(:side=>:bottom, :fill=>:x, :pady=>'2m')
+
+ TkButton.new(f, :text=>'é–‰ã˜ã‚‹', :width=>15, :command=>proc{
+ $unicodeout_demo.destroy
+ $unicodeout_demo = nil
+ }).pack(:side=>:left, :expand=>true)
+
+ TkButton.new(f, :text=>'コードå‚ç…§', :width=>15, :command=>proc{
+ showCode 'unicodeout'
+ }).pack(:side=>:left, :expand=>true)
+}
+
+wait_msg = TkLabel.new(base_frame,
+ :text=>"フォント読ã¿è¾¼ã¿ã®å®Œäº†ã¾ã§" +
+ "ã—ã°ã‚‰ããŠå¾…ã¡ä¸‹ã•ã„...",
+ :font=>"Helvetica 12 italic").pack
+
+class Unicodeout_SampleFrame < TkFrame
+ @@font = $font
+ # @@font = 'Helvetica 14'
+ # @@font = 'Courier 12'
+ # @@font = 'clearlyu 16'
+ # @@font = 'fixed 12'
+ # @@font = 'Times 12'
+ # @@font = 'Newspaper 12'
+ # @@font = '{New century schoolbook} 12'
+
+ def initialize(base)
+ super(base)
+ grid_columnconfig(1, :weight=>1)
+ end
+
+ def add_sample(lang, *args)
+ sample_txt = Tk::UTF8_String(args.join(''))
+ l = TkLabel.new(self, :font=>@@font, :text=>lang+':',
+ :anchor=>:nw, :pady=>0)
+ #s = TkLabel.new(self, :font=>@@font, :text=>sample_txt,
+ s = TkLabel.new(self, :font=>TkFont.new(@@font), :text=>sample_txt,
+ :anchor=>:nw, :width=>30, :pady=>0)
+ Tk.grid(l, s, :sticky=>:ew, :pady=>0)
+ l.grid_config(:padx, '1m')
+ end
+end
+f = Unicodeout_SampleFrame.new(base_frame)
+f.pack(:expand=>true, :fill=>:both, :padx=>'2m', :pady=>'1m')
+
+# Processing when some characters are missing might take a while, so make
+# sure we're displaying something in the meantime...
+
+oldCursor = $unicodeout_demo.cursor
+$unicodeout_demo.cursor('watch')
+Tk.update
+
+f.add_sample('Arabic',
+ '\uFE94\uFEF4\uFE91\uFEAE\uFECC\uFEDF\uFE8D\uFE94',
+ '\uFEE4\uFEE0\uFEDC\uFEDF\uFE8D')
+f.add_sample('Trad. Chinese', '\u4E2D\u570B\u7684\u6F22\u5B57')
+f.add_sample('Simpl. Chinese', '\u6C49\u8BED')
+f.add_sample('Greek',
+ '\u0395\u03BB\u03BB\u03B7\u03BD\u03B9\u03BA\u03AE ',
+ '\u03B3\u03BB\u03CE\u03C3\u03C3\u03B1')
+f.add_sample('Hebrew',
+ '\u05DD\u05D9\u05DC\u05E9\u05D5\u05E8\u05D9 ',
+ '\u05DC\u05D9\u05D0\u05E8\u05E9\u05D9')
+f.add_sample('Japanese',
+ '\u65E5\u672C\u8A9E\u306E\u3072\u3089\u304C\u306A, ',
+ '\u6F22\u5B57\u3068\u30AB\u30BF\u30AB\u30CA')
+f.add_sample('Korean', '\uB300\uD55C\uBBFC\uAD6D\uC758 \uD55C\uAE00')
+f.add_sample('Russian',
+ '\u0420\u0443\u0441\u0441\u043A\u0438\u0439 ',
+ '\u044F\u0437\u044B\u043A')
+
+wait_msg.destroy
+$unicodeout_demo.cursor(oldCursor)
diff --git a/jni/ruby/ext/tk/sample/demos-jp/vscale.rb b/jni/ruby/ext/tk/sample/demos-jp/vscale.rb
new file mode 100644
index 0000000..6ae513b
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/demos-jp/vscale.rb
@@ -0,0 +1,80 @@
+# -*- coding: utf-8 -*-
+require "tkcanvas"
+
+if defined?($vscale_demo) && $vscale_demo
+ $vscale_demo.destroy
+ $vscale_demo = nil
+end
+
+$vscale_demo = TkToplevel.new {|w|
+ title("Vertical Scale Demonstration")
+ iconname("vscale")
+}
+positionWindow($vscale_demo)
+
+base_frame = TkFrame.new($vscale_demo).pack(:fill=>:both, :expand=>true)
+
+msg = TkLabel.new(base_frame) {
+ font $font
+ wraplength '3.5i'
+ justify 'left'
+# text "下ã«ã¯çŸ¢å°ãŒ1ã¤ã¨ä¹—ç›´ãªã‚¹ã‚±ãƒ¼ãƒ«ãŒè¡¨ç¤ºã•ã‚Œã¦ã„ã¾ã™ã€‚\
+#スケール上ã§ãƒžã‚¦ã‚¹ãƒœã‚¿ãƒ³1をクリックã€ã¾ãŸã¯ãƒ‰ãƒ©ãƒƒã‚°ã™ã‚‹ã¨\
+#矢å°ã®é•·ã•ã‚’変ãˆã‚‹ã“ã¨ãŒã§ãã¾ã™ã€‚"
+ text "ã«ã¯ãƒãƒ¼ã¨ç¸¦åž‹ã®ã‚¹ã‚±ãƒ¼ãƒ«ãŒè¡¨ç¤ºã•ã‚Œã¦ã„ã¾ã™ã€‚スケールã§ãƒžã‚¦ã‚¹ã®ãƒœã‚¿ãƒ³1 をクリックã™ã‚‹ã‹ãƒ‰ãƒ©ãƒƒã‚°ã—ã¦ãƒãƒ¼ã®é«˜ã•ã‚’変ãˆã‚‹ã“ã¨ãŒã§ãã¾ã™ã€‚終ã£ãŸã‚‰ã€Œäº†è§£ã€ãƒœã‚¿ãƒ³ã‚’押ã—ã¦ãã ã•ã„。"
+}
+msg.pack('side'=>'top', 'padx'=>'.5c')
+
+TkFrame.new(base_frame) {|frame|
+ TkButton.new(frame) {
+ #text '了解'
+ text 'é–‰ã˜ã‚‹'
+ command proc {
+ tmppath = $vscale_demo
+ $vscale_demo = nil
+ tmppath.destroy
+ }
+ }.pack('side'=>'left', 'expand'=>'yes')
+
+ TkButton.new(frame) {
+ text 'コードå‚ç…§'
+ command proc { showCode 'vscale' }
+ }.pack('side'=>'left', 'expand'=>'yes')
+}.pack('side'=>'bottom', 'fill'=>'x', 'pady'=>'2m')
+
+def setHeight(w, height)
+ height = height + 21
+ y2 = height - 30
+ if y2 < 21
+ y2 = 21
+ end
+ w.coords 'poly',15,20,35,20,35,y2,45,y2,25,height,5,y2,15,y2,15,20
+ w.coords 'line',15,20,35,20,35,y2,45,y2,25,height,5,y2,15,y2,15,20
+end
+
+TkFrame.new(base_frame) {|frame|
+ borderwidth 10
+ canvas = TkCanvas.new(frame) {|c|
+ width 50
+ height 50
+ bd 0
+ highlightthickness 0
+ TkcPolygon.new(c, 0, 0, 1, 1, 2, 2) {
+ fill 'SeaGreen3'
+ tags 'poly'
+ }
+ TkcLine.new(c, 0, 0, 1, 1, 2, 2, 0, 0) {
+ fill 'black'
+ tags 'line'
+ }
+ }.pack('side'=>'left', 'anchor'=>'nw', 'fill'=>'y')
+ scale = TkScale.new(frame) {
+ orient 'vertical'
+ length 284
+ from 0
+ to 250
+ command proc{|value| setHeight(canvas, value)}
+ tickinterval 50
+ }.pack('side'=>'left', 'anchor'=>'ne')
+ scale.set 75
+}.pack
diff --git a/jni/ruby/ext/tk/sample/demos-jp/widget b/jni/ruby/ext/tk/sample/demos-jp/widget
new file mode 100644
index 0000000..5f5dfb9
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/demos-jp/widget
@@ -0,0 +1,1122 @@
+#!/usr/bin/env ruby
+# -*- coding: utf-8 -*-
+
+# 漢字コード設定 ( tk.rb ã®ãƒ­ãƒ¼ãƒ‰æ™‚ã® encoding 推定/設定ã«ä½¿ã‚れる )
+#if RUBY_VERSION < '1.9.0' ### !!!!!!!!!!!!!!
+unless defined?(::Encoding.default_external)
+ $KCODE = 'euc'
+else
+ DEFAULT_TK_ENCODING = 'EUC-JP'
+end
+
+# tk 関係ライブラリã®èª­ã¿è¾¼ã¿
+require 'tk'
+# require 'tkafter'
+
+$RubyTk_WidgetDemo = true
+
+# widget demo directory ä½ç½®ã®ç²å¾—
+# $demo_dir = File.dirname($0)
+$demo_dir = File.dirname(__FILE__)
+
+# root ã®ç”Ÿæˆ
+$root = TkRoot.new{title "Ruby/Tk Widget Demonstration"}
+
+# tk ãƒãƒ¼ã‚¸ãƒ§ãƒ³ã®å–å¾—
+$tk_version = Tk::TK_VERSION
+$tk_major_ver, $tk_minor_ver = $tk_version.split('.').map{|n| n.to_i}
+$tk_patchlevel = Tk::TK_PATCHLEVEL
+
+# tcl_platform 情報ã¸ã®ã‚¢ã‚¯ã‚»ã‚¹ã‚ªãƒ–ジェクト
+$tk_platform = TkVarAccess.new('tcl_platform')
+
+# フォント設定
+#######
+case($tk_version)
+when /^4.*/
+ $font = TkFont.new('-*-Helvetica-Medium-R-Normal--*-140-*-*-*-*-*-*', nil)
+ knjfont = '-*--16-*-jisx0208.1983-0'
+ $kanji_font = TkFont.new('-*-Helvetica-Medium-R-Normal--*-140-*-*-*-*-*-*',
+ knjfont)
+ TkOption.add('*kanjiFont', knjfont, 'startupFile')
+ $msg_kanji_font=TkFont.new('-*-Helvetica-Medium-R-Normal--*-140-*-*-*-*-*-*',
+ '-*--24-*-jisx0208.1983-0')
+
+#when '8.0'
+# $font = TkFont.new('Helvetica -12')
+# $kanji_font = TkFont.new('Helvetica -12', 'Mincho -12')
+# TkOption.add('*kanjiFont', knjfont, 'startupFile')
+# $msg_kanji_font=TkFont.new('Helvetica 16', 'Gothic 16 bold')
+
+when /^8.*/
+ $font = TkFont.new('Helvetica -12')
+ $kanji_font = TkFont.new('Helvetica -12', 'Mincho -12')
+ TkOption.add('*kanjiFont', knjfont, 'startupFile')
+ $msg_kanji_font=TkFont.new('Helvetica 14 bold', 'Gothic 14 bold')
+
+else
+ $font = TkFont.new('Helvetica 14', nil)
+ knjfont = '-*--16-*-jisx0208.1983-0'
+ $kanji_font = TkFont.new('Helvetic 14', knjfont)
+ TkOption.add('*kanjiFont', knjfont, 'startupFile')
+ $msg_kanji_font=TkFont.new('Helvetica 14',
+ '-*--24-*-jisx0208.1983-0')
+end
+#######
+
+# イメージ設定
+$image = {}
+
+if $tk_major_ver >= 8
+$image['refresh'] = TkPhotoImage.new(:height=>16, :format=>'GIF', :data=><<EOD)
+ R0lGODlhEAAQAPMAAMz/zCpnKdb/1z9mPypbKBtLGy9NMPL/9Or+6+P+4j1Y
+ PwQKBP7//xMLFAYBCAEBASH5BAEAAAAALAAAAAAQABAAAwR0EAD3Gn0Vyw0e
+ ++CncU7IIAezMA/nhUqSLJizvSdCEEjy2ZIV46AwDAoDHwPYGSoEiUJAAGJ6
+ EDHBNCFINW5OqABKSFk/B9lUa94IDwIFgewFMwQDQwCZQCztTgM9Sl8SOEMG
+ KSAthiaOjBMPDhQONBiXABEAOw==
+EOD
+end
+
+if $tk_major_ver >= 8
+$image['view'] = TkPhotoImage.new(:height=>16, :format=>'GIF', :data=><<EOD)
+ R0lGODlhEAAQAPMAAMz/zP///8DAwICAgH9/fwAAAAAAAAAAAAAAAAAAAAAA
+ AAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAwRIcMhJB7h3hM33
+ KFjWdQQYap1QrCaGBmrRrS4nj5b53jOgbwXBKGACoYLDIuAoHCmZyYvR1rT5
+ RMAq8LqcIYGsrjPsW1XOmFUEADs=
+EOD
+end
+
+if $tk_major_ver >= 8
+$image['delete'] = TkPhotoImage.new(:height=>16, :format=>'GIF', :data=><<EOD)
+ R0lGODlhEAAOAKEAAIQAAO/n3v///////yH5BAEKAAIALAAAAAAQAA4AAAIm
+ lI9pAKHbIHNoVhYhTdjlJ2AWKG2g+CldmB6rxo2uybYhbS80eRQAOw==
+EOD
+end
+
+if $tk_major_ver >= 8
+$image['print'] = TkPhotoImage.new(:height=>19, :format=>'GIF', :data=><<EOD)
+ R0lGODlhGgATAPcAACEQOTEpQjEpUkIpc0IxY0I5c0oxjEo5SlJCY1JCe1JK
+ UlpChFpCjFpGkFpSc1paa2NKc2NKnGNja2tapWtjc29KnHNanHNjc3NjrXNr
+ jHNrnHNzc3tjpXtrtXtzhICAgIRzvYSEjIZzqox7tYyEnIyMjJSEtZSEvZSM
+ lJyMtZyMvZyUlJyUrZyUvZycnKWctaWlpa2czq2lzrWtvbWtzrW1tb21xr21
+ 1sa9zs693s7OztbO3tbO597W1t7W7+fe7+fn5////+/n7+/v7+/v9////wAA
+ AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+ AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+ AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+ AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+ AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+ AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+ AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+ AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+ AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+ AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+ AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+ AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+ AAAAAAAAAAAAAAAAAAAAACH5BAEAAEEALAAAAAAaABMAQAj/AIMIHBhkg0GC
+ CBMGIQEiQgseQT4oeCBBAokgRYYQ0JBixg8hRIiUUEBBYYmTByBwiCBCRYwH
+ CxY8cKFw4AogRXLqLAJkQ80gCBBg3BkxZswTNGh4MGqgQQUMJRHCwMkTSE+D
+ Pn8eCKBhxIMhO3ei2OHDBw6sWSlMMMoWgwwfMDZI8GBjx44NARZwEGGi5MkS
+ PcIWKRGz5YgLbAco+KkQBQoJIRgjdGEVq+SaJajqtNrzMgsPCmoIzqmDgmWE
+ KOBuUKAAwYabYTfs4OHjY0giGyhk4MAWRI4eKyRQqPgggYUXPH4A+XBAgwoK
+ DiIsCFxjA9sFEVQQCRJCAYAFDJxiKhAxvMTonEFimrhhYinTBgWiCvxLNX3M
+ DkkpsKV5OYhjBxCMYAICAigUEAA7
+EOD
+end
+
+# メニュー設定
+if $tk_major_ver >= 8
+ $root.add_menubar([[['File', 0],
+ ['About ... ', proc{aboutBox}, 0, '<F1>'],
+ '---',
+ ['Quit', proc{exit}, 0, 'Ctrl-Q']
+ ]])
+else
+ TkMenubar.new($root,
+ [[['File', 0],
+ ['About ... ', proc{aboutBox}, 0, '<F1>'],
+ '---',
+ ['Quit', proc{exit}, 0, 'Ctrl-Q']
+ ]]).pack('side'=>'top', 'fill'=>'x')
+end
+$root.bind('F1', proc{aboutBox})
+$root.bind('Control-q', proc{exit})
+
+=begin
+TkFrame.new($root){|frame|
+ TkMenubutton.new(frame){|button|
+ m = TkMenu.new(button) {
+ add 'command', 'label'=>'Quit', 'command'=>proc{exit}, 'underline'=>0
+ }
+ menu m
+ text 'File'
+ underline 0
+ }.pack('side'=>'left')
+}.pack('side'=>'top', 'fill'=>'x')
+=end
+
+# テキストボックスã®ç”Ÿæˆ
+if $tk_version =~ /^4\.[01]/
+ scr = TkScrollbar.new($root, 'orient'=>'vertical')
+ txt = TkText.new($root) {
+ #wrap 'word'
+ wrap 'char'
+ width 70
+ height 30
+ font $font
+ setgrid 'yes'
+ yscrollcommand proc{|first,last| scr.set first,last}
+ }
+ scr.command(proc{|*args| txt.yview(*args)})
+ scr.pack('side'=>'right', 'fill'=>'y')
+ txt.pack('expand'=>'yes', 'fill'=>'both')
+else
+ textFrame = TkFrame.new($root)
+ scr = TkScrollbar.new($root, 'orient'=>'vertical',
+ 'highlightthickness'=>0, 'takefocus'=>1) {
+ pack('in'=>textFrame, 'side'=>'right', 'fill'=>'y', 'padx'=>1)
+ }
+ txt = TkText.new($root) {
+ #wrap 'word'
+ wrap 'char'
+ width 70
+ height 30
+ font $font
+ setgrid 'yes'
+ highlightthickness 0
+ padx 4
+ pady 2
+ takefocus 0
+ bd 1
+ yscrollcommand proc{|first,last| scr.set first,last}
+ }
+ scr.command(proc{|*args| txt.yview(*args)})
+
+# txt.pack('in'=>textFrame, 'expand'=>'yes', 'fill'=>'both', 'padx'=>1)
+# txt.pack('in'=>textFrame, 'expand'=>'yes', 'fill'=>'both')
+# textFrame.pack('expand'=>'yes', 'fill'=>'both', 'padx'=>1, 'pady'=>2)
+ textFrame.pack('expand'=>'yes', 'fill'=>'both')
+ # $root.withdraw.deiconify
+ Tk.update_idletasks
+ txt.pack('in'=>textFrame, 'expand'=>'yes', 'fill'=>'both')
+
+ statusBar = TkFrame.new($root) {|f|
+ if $tk_version =~ /^4.*/
+ statusfont = '-*-Helvetica-Medium-R-Normal--*-120-*-*-*-*-*-*'
+ else
+ statusfont = 'Helvetica 10'
+ end
+ $statusBarLabel = \
+ TkLabel.new(f, 'text'=>" ", 'relief'=>'sunken', 'bd'=>1, 'anchor'=>'w',
+ 'font'=>statusfont) \
+ .pack('side'=>'left', 'padx'=>2, 'expand'=>'yes', 'fill'=>'both')
+ TkLabel.new(f, 'width'=>8, 'relief'=>'sunken', 'bd'=>1, 'anchor'=>'w',
+ 'font'=>statusfont) \
+ .pack('side'=>'left', 'padx'=>2)
+ }.pack('side'=>'bottom', 'fill'=>'x', 'pady'=>2)
+end
+
+# テキストタグ設定
+if $tk_version =~ /^4.*/
+ tag_title = TkTextTag.new(txt, 'font'=>'-*-Helvetica-Bold-R-Normal--*-180-*-*-*-*-*-*')
+else
+ tag_title = TkTextTag.new(txt, 'font'=>'Helvetica 18 bold')
+end
+#tag_kanji_title = TkTextTag.new(txt, 'kanjifont'=>$msg_kanji_font)
+#tag_middle = TkTextTag.new(txt, 'kanjifont'=>$kanji_font)
+tag_kanji_title = TkTextTag.new(txt, 'font'=>$msg_kanji_font)
+tag_middle = TkTextTag.new(txt, 'font'=>$kanji_font)
+tag_demospace = TkTextTag.new(txt, 'lmargin1'=>'1c', 'lmargin2'=>'1c')
+
+if TkWinfo.depth($root) == 1
+ tag_demo = TkTextTag.new(txt, 'lmargin1'=>'1c', 'lmargin2'=>'1c',
+ 'underline'=>1)
+ $tag_visited = TkTextTag.new(txt, 'lmargin1'=>'1c', 'lmargin2'=>'1c',
+ 'underline'=>1)
+ tag_hot = TkTextTag.new(txt, 'background'=>'black', 'foreground'=>'white')
+else
+ tag_demo = TkTextTag.new(txt, 'lmargin1'=>'1c', 'lmargin2'=>'1c',
+ 'foreground'=>'blue', 'underline'=>1)
+ $tag_visited = TkTextTag.new(txt, 'lmargin1'=>'1c', 'lmargin2'=>'1c',
+ 'foreground'=>'#303080', 'underline'=>1)
+# tag_hot = TkTextTag.new(txt, 'relief'=>'raised', 'borderwidth'=>1,
+# 'background'=>'SeaGreen3')
+ tag_hot = TkTextTag.new(txt, 'borderwidth'=>1, 'foreground'=>'red')
+end
+
+#tag_demo.bind('Button-1', proc{invoke txt, txt.index('current')})
+tag_demo.bind('ButtonRelease-1',
+ proc{|x,y|invoke txt, txt.index("@#{x},#{y}")}, '%x %y')
+
+lastLine = TkVariable.new("")
+newLine = TkVariable.new("")
+tag_demo.bind('Enter', proc{|x,y|
+ lastLine.value = txt.index("@#{x},#{y} linestart")
+ tag_hot.add(lastLine.value, "#{lastLine.value} lineend")
+ showStatus txt, txt.index("@#{x},#{y}")
+ },
+ '%x %y')
+tag_demo.bind('Leave',
+ proc{
+ tag_hot.remove('1.0','end')
+ txt.configure('cursor','xterm')
+ $statusBarLabel.configure('text'=>"")
+ })
+tag_demo.bind('Motion', proc{|x, y|
+ newLine.value = txt.index("@#{x},#{y} linestart")
+ if newLine.value != lastLine.value
+ tag_hot.remove('1.0','end')
+ lastLine.value = newLine.value
+ if ( txt.tag_names("@#{x},#{y}").find{|t|
+ t.kind_of?(String) && t =~ /^demo-/
+ } )
+ tag_hot.add(lastLine.value,
+ "#{lastLine.value} lineend -1 chars")
+ end
+ end
+ showStatus txt, txt.index("@#{x},#{y}")
+ },
+ '%x %y')
+
+# テキスト生æˆ
+txt.insert('end', 'Ruby/Tk : Widget', tag_title)
+#txt.insert('end', " デモンストレーション\n", tag_middle)
+txt.insert('end', " デモンストレーション\n", tag_kanji_title)
+txt.insert('end', <<"EOT")
+
+ã“ã®ã‚¢ãƒ—リケーションã¯ã€Tk Widget を用ã„ã¦ã©ã®ã‚ˆã†ãªã“ã¨ãŒã§ãã‚‹ã‹\
+を示ã™ãŸã‚ã®ã€ã„ãã¤ã‹ã®å°ã•ãªã‚¹ã‚¯ãƒªãƒ—トã«å¯¾ã™ã‚‹ãƒ•ãƒ­ãƒ³ãƒˆã‚¨ãƒ³ãƒ‰ã‚’æ\
+ä¾›ã—ã¦ã„ã¾ã™ã€‚以下ã«é †ç•ªã«æŒ™ã’られã¦ã„るデモンストレーションを実行\
+ã™ã‚‹ã«ã¯ãƒžã‚¦ã‚¹ã§ã‚¯ãƒªãƒƒã‚¯ã—ã¦ãã ã•ã„。デモンストレーションã®ã‚¦ã‚£ãƒ³\
+ドウãŒç¾ã‚Œã‚‹ã¨ã€ãƒ‡ãƒ¢ãƒ³ã‚¹ãƒˆãƒ¬ãƒ¼ã‚·ãƒ§ãƒ³ã‚’生æˆã—㟠Ruby/Tk ã®ã‚³ãƒ¼ãƒ‰ã‚’見\
+ã‚‹ãŸã‚ã«ã€"コードå‚ç…§"ボタンをクリックã™ã‚‹ã“ã¨ãŒã§ãã¾ã™ã€‚ã‚ãªãŸãŒ\
+望むãªã‚‰ã€ãã®ã‚³ãƒ¼ãƒ‰ã‚’修正ã™ã‚‹ã“ã¨ãŒã§ãã¾ã™ã€‚修正ã—ãŸã‚³ãƒ¼ãƒ‰ã§ãƒ‡ãƒ¢\
+ンストレーションをå†å®Ÿè¡Œã™ã‚‹ãŸã‚ã«ã¯ã€ã‚³ãƒ¼ãƒ‰ãŒæ›¸ã‹ã‚ŒãŸã‚¦ã‚£ãƒ³ãƒ‰ã‚¦ã«\
+ã‚ã‚‹"デモå†å®Ÿè¡Œ" ボタンをクリックã—ã¦ãã ã•ã„。\
+コードを修正ã—ã¦ã‚‚オリジナルã®ãƒ•ã‚¡ã‚¤ãƒ«ãŒæ›¸ãæ›ãˆã‚‰ã‚Œã‚‹ã“ã¨ã¯\
+ã‚ã‚Šã¾ã›ã‚“ã‹ã‚‰ã€å¿ƒé…ã›ãšã«è‰²ã€…ãªå¤‰æ›´ã‚’試ã—ã¦ã¿ã¦ãã ã•ã„。
+
+一部ã®ãƒ‡ãƒ¢ã§ã¯ã€æ¯”較的最近ã®ãƒãƒ¼ã‚¸ãƒ§ãƒ³ã® Tk ã§ãªã‘ã‚Œã°ã‚µãƒãƒ¼ãƒˆã—ã¦\
+ã„ãªã„機能を使ã£ã¦å®Ÿè£…ã—ã¦ã„ã¾ã™(例ãˆã° Tk8.4 以上ãªã©)。ãã®ãŸã‚ã€\
+ãã†ã—ãŸæ©Ÿèƒ½ã‚’æŒãŸãªã„ Tk ライブラリを使ã£ã¦ã„ã‚‹å ´åˆã«ã¯ã€ãã†ã—ãŸ\
+デモã¯æ­£ã—ãå‹•ãã¾ã›ã‚“。ãã®ã‚ˆã†ãªæ©Ÿèƒ½ãŒå¿…è¦ã§ã‚ã‚Œã°ã€ãれをサãƒãƒ¼ãƒˆ\
+ã—ã¦ã„ã‚‹ Tk ライブラリを使ã†ã‚ˆã†ã« tcltklib をコンパイルã—ãªãŠã—ã¦\
+ãã ã•ã„。
+
+ã‚‚ã—ã‚ãªãŸã® Tk ㌠(最åˆã‹ã‚‰å«ã‚€ã‹ã‚¤ãƒ³ã‚¹ãƒˆãƒ¼ãƒ«ã—ãŸã‹ã«ã‚ˆã‚Š) \
+Ttk (Tile) 拡張を利用ã§ãる状態ã§ã‚ã‚‹ãªã‚‰ã€\
+Ttk æ‹¡å¼µã®ãƒ‡ãƒ¢ (sample/tkextlib/tile/demo.rb) ã‚‚ãœã²è©¦ã—ã¦ã¿ã¦ãã ã•ã„。
+( 多分,ç¾åœ¨ã®ã‚ãªãŸã®ç’°å¢ƒã«ã¯ Ttk æ‹¡å¼µã¯\
+#{
+begin
+ require 'tkextlib/tile'
+ "ã™ã§ã«å°Žå…¥ã•ã‚Œã¦ã„ã¾ã™"
+rescue
+ "ã¾ã ã‚¤ãƒ³ã‚¹ãƒˆãƒ¼ãƒ«ã•ã‚Œã¦ã„ã¾ã›ã‚“"
+end
+}\
+。)
+Ttk æ‹¡å¼µã¯ã€Tk8.5 以上ã§ã¯æ¨™æº–ã®æ©Ÿèƒ½ã¨ã—ã¦çµ„ã¿è¾¼ã¾ã‚Œã¦ã„ã¾ã™ã€‚
+
+
+EOT
+
+#txt.insert('end',"ラベル, ボタン, ãƒã‚§ãƒƒã‚¯ãƒœã‚¿ãƒ³, ラジオボタン\n",tag_middle)
+txt.insert('end', "ラベル, ボタン, ãƒã‚§ãƒƒã‚¯ãƒœã‚¿ãƒ³, ラジオボタン\n",
+ tag_kanji_title)
+txt.insert('end', " \n ", tag_demospace)
+txt.insert('end', "1. ラベル (テキスト, ビットマップ)\n",
+ tag_demo, "demo-label")
+txt.insert('end', " \n ", tag_demospace)
+txt.insert('end', "2. ラベルã¨UNICODEテキスト (機能ã«å¯¾å¿œã—ãŸãƒãƒ¼ã‚¸ãƒ§ãƒ³ã®TkãŒå¿…è¦)\n", tag_demo, "demo-unicodeout")
+txt.insert('end', " \n ", tag_demospace)
+txt.insert('end', "3. ボタン \n", tag_demo, "demo-button")
+txt.insert('end', " \n ", tag_demospace)
+txt.insert('end', "4. ãƒã‚§ãƒƒã‚¯ãƒœã‚¿ãƒ³ (複数をé¸æŠžå¯èƒ½)\n",
+ tag_demo, "demo-check")
+txt.insert('end', " \n ", tag_demospace)
+txt.insert('end', "5. 3状態ãƒã‚§ãƒƒã‚¯ãƒœã‚¿ãƒ³ (機能ã«å¯¾å¿œã—ãŸãƒãƒ¼ã‚¸ãƒ§ãƒ³ã®TkãŒå¿…è¦)\n",
+ tag_demo, "demo-check2")
+txt.insert('end', " \n ", tag_demospace)
+txt.insert('end', "6. ラジオボタン (ä»»æ„ã®ä¸€ã¤ã‚’é¸æŠžå¯èƒ½)\n",
+ tag_demo, "demo-radio")
+txt.insert('end', " \n ", tag_demospace)
+txt.insert('end', "7. ラジオボタン (機能ã«å¯¾å¿œã—ãŸãƒãƒ¼ã‚¸ãƒ§ãƒ³ã®TkãŒå¿…è¦)\n",
+ tag_demo, "demo-radio2")
+txt.insert('end', " \n ", tag_demospace)
+txt.insert('end', "8. 3状態ラジオボタン (機能ã«å¯¾å¿œã—ãŸãƒãƒ¼ã‚¸ãƒ§ãƒ³ã®TkãŒå¿…è¦)\n",
+ tag_demo, "demo-radio3")
+txt.insert('end', " \n ", tag_demospace)
+txt.insert('end', "9. ボタンã§ä½œã‚‰ã‚ŒãŸ15-パズルゲーム\n",
+ tag_demo, "demo-puzzle")
+txt.insert('end', " \n ", tag_demospace)
+txt.insert('end', "10. ビットマップを使用ã—ãŸã‚¢ã‚¤ã‚³ãƒ³ãƒœã‚¿ãƒ³\n",
+ tag_demo, "demo-icon")
+txt.insert('end', " \n ", tag_demospace)
+txt.insert('end', "11. ç”»åƒã‚’表示ã™ã‚‹äºŒã¤ã®ãƒ©ãƒ™ãƒ«\n",
+ tag_demo, "demo-image1")
+txt.insert('end', " \n ", tag_demospace)
+txt.insert('end', "12. ç”»åƒã‚’見るãŸã‚ã®ç°¡å˜ãªãƒ¦ãƒ¼ã‚¶ã‚¤ãƒ³ã‚¿ãƒ¼ãƒ•ã‚§ãƒ¼ã‚¹\n",
+ tag_demo, "demo-image2")
+txt.insert('end', " \n ", tag_demospace)
+txt.insert('end', "13. ç”»åƒã‚’見るãŸã‚ã®ç°¡å˜ãªãƒ¦ãƒ¼ã‚¶ã‚¤ãƒ³ã‚¿ãƒ¼ãƒ•ã‚§ãƒ¼ã‚¹ (機能ã«å¯¾å¿œã—ãŸãƒãƒ¼ã‚¸ãƒ§ãƒ³ã®TkãŒå¿…è¦)\n",
+ tag_demo, "demo-image3")
+txt.insert('end', " \n ", tag_demospace)
+txt.insert('end', "14. ラベル付ãフレーム (機能ã«å¯¾å¿œã—ãŸãƒãƒ¼ã‚¸ãƒ§ãƒ³ã®TkãŒå¿…è¦)\n",
+ tag_demo, "demo-labelframe")
+txt.insert('end', " \n ", tag_demospace)
+txt.insert('end', "15. テーマã«å¯¾å¿œã—ãŸã‚¦ã‚£ã‚¸ã‚§ãƒƒãƒˆã®ç°¡å˜ãªä¾‹ (Tile/Ttkæ‹¡å¼µã¸ã®å¯¾å¿œãŒå¿…è¦)\n",
+ tag_demo, "demo-ttkbut")
+txt.insert('end', " \n ", tag_demospace)
+
+txt.insert('end', "\n")
+#txt.insert('end', "リストボックス\n", tag_middle)
+txt.insert('end', "リストボックス\n", tag_kanji_title)
+txt.insert('end', " \n ", tag_demospace)
+txt.insert('end', "1. 都é“府県.\n", tag_demo, "demo-states")
+txt.insert('end', " \n ", tag_demospace)
+txt.insert('end', "2. 色: アプリケーションã®ãŸã‚ã®é…色を変ãˆã‚‹\n",
+ "#{tag_demo.id} demo-colors")
+txt.insert('end', " \n ", tag_demospace)
+txt.insert('end', "3. 格言集\n", tag_demo, "demo-sayings")
+txt.insert('end', " \n ", tag_demospace)
+txt.insert('end', "4. 国ã«ã¤ã„ã¦ã®ãƒžãƒ«ãƒã‚«ãƒ©ãƒ ãƒªã‚¹ãƒˆ (Tile/Ttkæ‹¡å¼µã¸ã®å¯¾å¿œãŒå¿…è¦)\n",
+ tag_demo, "demo-mclist")
+txt.insert('end', " \n ", tag_demospace)
+txt.insert('end', "5. ディレクトリブラウザ (Tile/Ttkæ‹¡å¼µã¸ã®å¯¾å¿œãŒå¿…è¦)\n",
+ tag_demo, "demo-tree")
+txt.insert('end', " \n ", tag_demospace)
+
+txt.insert('end', "\n")
+#txt.insert('end', "エントリã¨ã‚¹ãƒ”ンボックス\n", tag_middle)
+txt.insert('end', "エントリ\n", tag_kanji_title)
+txt.insert('end', " \n ", tag_demospace)
+txt.insert('end', "1. スクロールãƒãƒ¼ãªã—\n", tag_demo, "demo-entry1")
+txt.insert('end', " \n ", tag_demospace)
+txt.insert('end', "2. スクロールãƒãƒ¼ã‚ã‚Š\n", tag_demo, "demo-entry2")
+txt.insert('end', " \n ", tag_demospace)
+txt.insert('end', "3. èªè¨¼å‡¦ç†ä»˜ãã®ã‚¨ãƒ³ãƒˆãƒªãƒœãƒƒã‚¯ã‚¹ã¨ãƒ‘スワードフィールド (機能ã«å¯¾å¿œã—ãŸãƒãƒ¼ã‚¸ãƒ§ãƒ³ã®TkãŒå¿…è¦)\n",
+ tag_demo, "demo-entry3")
+txt.insert('end', " \n ", tag_demospace)
+txt.insert('end', "4. スピンボックス (機能ã«å¯¾å¿œã—ãŸãƒãƒ¼ã‚¸ãƒ§ãƒ³ã®TkãŒå¿…è¦)\n",
+ tag_demo, "demo-spin")
+txt.insert('end', " \n ", tag_demospace)
+txt.insert('end', "5. コンボボックス (Tile/Ttkæ‹¡å¼µã¸ã®å¯¾å¿œãŒå¿…è¦)\n",
+ tag_demo, "demo-combo")
+txt.insert('end', " \n ", tag_demospace)
+txt.insert('end', "6. ç°¡å˜ãªãƒ•ã‚©ãƒ¼ãƒ \n", tag_demo, "demo-form")
+txt.insert('end', " \n ", tag_demospace)
+
+txt.insert('end', "\n")
+#txt.insert('end', "テキスト\n", tag_middle)
+txt.insert('end', "テキスト\n", tag_kanji_title)
+txt.insert('end', " \n ", tag_demospace)
+txt.insert('end', "1. 基本的ãªãƒ†ã‚­ã‚¹ãƒˆ\n", tag_demo, "demo-text")
+txt.insert('end', " \n ", tag_demospace)
+txt.insert('end', "2. 表示スタイル.\n", tag_demo, "demo-style")
+txt.insert('end', " \n ", tag_demospace)
+txt.insert('end', "3. ãƒã‚¤ãƒ‘ーテキスト(ã‚¿ã‚°ãƒã‚¤ãƒ³ãƒ‰).\n",
+ tag_demo, "demo-bind")
+txt.insert('end', " \n ", tag_demospace)
+txt.insert('end', "4. ウィンドウを埋ã‚込んã ãƒ†ã‚­ã‚¹ãƒˆ\n",
+ tag_demo, "demo-twind")
+txt.insert('end', " \n ", tag_demospace)
+txt.insert('end', "5. ウィンドウを埋ã‚込んã ãƒ†ã‚­ã‚¹ãƒˆ (機能ã«å¯¾å¿œã—ãŸãƒãƒ¼ã‚¸ãƒ§ãƒ³ã®TkãŒå¿…è¦)\n",
+ tag_demo, "demo-twind2")
+txt.insert('end', " \n ", tag_demospace)
+txt.insert('end', "6. 検索\n", tag_demo, "demo-search")
+txt.insert('end', " \n ", tag_demospace)
+txt.insert('end', "7. テキストウィジェットã®å¯¾ç­‰åŒ–(peering) (機能ã«å¯¾å¿œã—ãŸãƒãƒ¼ã‚¸ãƒ§ãƒ³ã®TkãŒå¿…è¦)\n", tag_demo, "demo-textpeer")
+txt.insert('end', " \n ", tag_demospace)
+
+txt.insert('end', "\n")
+#txt.insert('end', "キャンãƒã‚¹\n", tag_middle)
+txt.insert('end', "キャンãƒã‚¹\n", tag_kanji_title)
+txt.insert('end', " \n ", tag_demospace)
+txt.insert('end', "1. アイテムã®åž‹\n", tag_demo, "demo-items")
+txt.insert('end', " \n ", tag_demospace)
+txt.insert('end', "2. 2 次元ã®ãƒ—ロット\n", tag_demo, "demo-plot")
+txt.insert('end', " \n ", tag_demospace)
+txt.insert('end', "3. テキスト\n", tag_demo, "demo-ctext")
+txt.insert('end', " \n ", tag_demospace)
+txt.insert('end', "4. 矢å°ã®å½¢\n", tag_demo, "demo-arrow")
+txt.insert('end', " \n ", tag_demospace)
+txt.insert('end', "5. ルーラー\n", tag_demo, "demo-ruler")
+txt.insert('end', " \n ", tag_demospace)
+txt.insert('end', "6. フロアプラン\n", tag_demo, "demo-floor")
+txt.insert('end', " \n ", tag_demospace)
+txt.insert('end', "7. フロアプラン (ç•°ãªã‚‹ã‚­ãƒ£ãƒ³ãƒã‚¹ã‚¢ã‚¤ãƒ†ãƒ ä½œæˆæ–¹æ³•ã‚’使用)\n", tag_demo, "demo-floor2")
+txt.insert('end', " \n ", tag_demospace)
+txt.insert('end', "8. スクロールå¯èƒ½ãªã‚­ãƒ£ãƒ³ãƒã‚¹\n",
+ tag_demo, "demo-cscroll")
+txt.insert('end', " \n ", tag_demospace)
+txt.insert('end', "9. ãƒã‚§ã‚¹ãƒœãƒ¼ãƒ‰ä¸Šã®é¨Žå£«ã®å·¡å›ž (Tile/Ttkæ‹¡å¼µã¸ã®å¯¾å¿œãŒå¿…è¦)\n",
+ tag_demo, "demo-knightstour")
+txt.insert('end', " \n ", tag_demospace)
+
+txt.insert('end', "\n")
+#txt.insert('end', "スケールã¨ãƒ—ログレスãƒãƒ¼\n", tag_middle)
+txt.insert('end', "スケールã¨ãƒ—ログレスãƒãƒ¼\n", tag_kanji_title)
+txt.insert('end', " \n ", tag_demospace)
+txt.insert('end', "1. 垂直スケール\n", tag_demo.id, "demo-vscale")
+txt.insert('end', " \n ", tag_demospace)
+txt.insert('end', "2. 水平スケール\n", tag_demo.id, "demo-hscale")
+txt.insert('end', " \n ", tag_demospace)
+txt.insert('end', "3. プログレスãƒãƒ¼ (Tile/Ttkæ‹¡å¼µã¸ã®å¯¾å¿œãŒå¿…è¦)\n", tag_demo.id, "demo-ttkprogress")
+txt.insert('end', " \n ", tag_demospace)
+
+txt.insert('end', "\n")
+txt.insert('end', "ペインドウィンドウã¨ãƒŽãƒ¼ãƒˆãƒ–ック\n", tag_kanji_title)
+txt.insert('end', " \n ", tag_demospace)
+txt.insert('end', "1. æ°´å¹³æ–¹å‘ (機能ã«å¯¾å¿œã—ãŸãƒãƒ¼ã‚¸ãƒ§ãƒ³ã®TkãŒå¿…è¦)\n",
+ tag_demo.id, "demo-paned1")
+txt.insert('end', " \n ", tag_demospace)
+txt.insert('end', "2. åž‚ç›´æ–¹å‘ (機能ã«å¯¾å¿œã—ãŸãƒãƒ¼ã‚¸ãƒ§ãƒ³ã®TkãŒå¿…è¦)\n",
+ tag_demo.id, "demo-paned2")
+txt.insert('end', " \n ", tag_demospace)
+txt.insert('end', "3. テーマã«å¯¾å¿œã—ãŸåŸ‹ã‚è¾¼ã¿ãƒšã‚¤ãƒ³ (Tile/Ttkæ‹¡å¼µã¸ã®å¯¾å¿œãŒå¿…è¦)\n",
+ tag_demo.id, "demo-ttkpane")
+txt.insert('end', " \n ", tag_demospace)
+txt.insert('end', "4. ノートブックウィジェット (Tile/Ttkæ‹¡å¼µã¸ã®å¯¾å¿œãŒå¿…è¦)\n",
+ tag_demo.id, "demo-ttknote")
+txt.insert('end', " \n ", tag_demospace)
+
+txt.insert('end', "\n")
+#txt.insert('end', "メニューã¨ãƒ„ールãƒãƒ¼\n", tag_middle)
+txt.insert('end', "メニューã¨ãƒ„ールãƒãƒ¼\n", tag_kanji_title)
+txt.insert('end', " \n ", tag_demospace)
+txt.insert('end', "1. メニューã¨ã‚«ã‚¹ã‚±ãƒ¼ãƒ‰ã‚’å«ã‚“ã ã‚¦ã‚£ãƒ³ãƒ‰ã‚¦\n",
+ tag_demo, "demo-menu")
+txt.insert('end', " \n ", tag_demospace)
+txt.insert('end', "2. メニューã¨ã‚«ã‚¹ã‚±ãƒ¼ãƒ‰ã‚’å«ã‚“ã ã‚¦ã‚£ãƒ³ãƒ‰ã‚¦ (Tk8.x 専用)\n",
+ tag_demo, "demo-menu8x")
+txt.insert('end', " \n ", tag_demospace)
+txt.insert('end', "3. 〃 (機能ã«å¯¾å¿œã—ãŸãƒãƒ¼ã‚¸ãƒ§ãƒ³ã®TkãŒå¿…è¦)\n",
+ tag_demo, "demo-menu84")
+txt.insert('end', " \n ", tag_demospace)
+txt.insert('end', "4. メニューボタン (Tk8.x 専用)\n",
+ tag_demo, "demo-menubu")
+txt.insert('end', " \n ", tag_demospace)
+txt.insert('end', "5. テーマã«å¯¾å¿œã—ãŸãƒ¡ãƒ‹ãƒ¥ãƒ¼ãƒœã‚¿ãƒ³ (Tile/Ttkæ‹¡å¼µã¸ã®å¯¾å¿œãŒå¿…è¦)\n",
+ tag_demo.id, "demo-ttkmenu")
+txt.insert('end', " \n ", tag_demospace)
+txt.insert('end', "6. テーマã«å¯¾å¿œã—ãŸãƒ„ールãƒãƒ¼ (Tile/Ttkæ‹¡å¼µã¸ã®å¯¾å¿œãŒå¿…è¦)\n",
+ tag_demo.id, "demo-toolbar")
+txt.insert('end', " \n ", tag_demospace)
+
+txt.insert('end', "\n")
+#txt.insert('end', "ダイアログウィンドウ\n", tag_middle)
+txt.insert('end', "ダイアログウィンドウ\n", tag_kanji_title)
+txt.insert('end', " \n ", tag_demospace)
+txt.insert('end', "1. メッセージボックス\n", tag_demo, "demo-msgbox")
+txt.insert('end', " \n ", tag_demospace)
+txt.insert('end', "2. 詳細テキスト付ãã®ãƒ¡ãƒƒã‚»ãƒ¼ã‚¸ãƒœãƒƒã‚¯ã‚¹ (機能ã«å¯¾å¿œã—ãŸãƒãƒ¼ã‚¸ãƒ§ãƒ³ã®TkãŒå¿…è¦)\n", tag_demo, "demo-msgbox2")
+txt.insert('end', " \n ", tag_demospace)
+txt.insert('end', "3. ファイルé¸æŠžãƒ€ã‚¤ã‚¢ãƒ­ã‚°\n", tag_demo, "demo-filebox")
+txt.insert('end', " \n ", tag_demospace)
+txt.insert('end', "4. 色é¸æŠžãƒ€ã‚¤ã‚¢ãƒ­ã‚°\n", tag_demo, "demo-clrpick")
+txt.insert('end', " \n ", tag_demospace)
+
+txt.insert('end', "\n")
+#txt.insert('end', "アニメーション\n", tag_middle)
+txt.insert('end', "アニメーション\n", tag_kanji_title)
+txt.insert('end', " \n ", tag_demospace)
+txt.insert('end', "1. アニメーションラベル (機能ã«å¯¾å¿œã—ãŸãƒãƒ¼ã‚¸ãƒ§ãƒ³ã®TkãŒå¿…è¦)\n", tag_demo, "demo-anilabel")
+txt.insert('end', " \n ", tag_demospace)
+txt.insert('end', "2. 波形ã®ã‚¢ãƒ‹ãƒ¡ãƒ¼ã‚·ãƒ§ãƒ³ (機能ã«å¯¾å¿œã—ãŸãƒãƒ¼ã‚¸ãƒ§ãƒ³ã®TkãŒå¿…è¦)\n", tag_demo, "demo-aniwave")
+txt.insert('end', " \n ", tag_demospace)
+txt.insert('end', "3. 振りå­ã®ã‚·ãƒŸãƒ¥ãƒ¬ãƒ¼ã‚·ãƒ§ãƒ³ (機能ã«å¯¾å¿œã—ãŸãƒãƒ¼ã‚¸ãƒ§ãƒ³ã®TkãŒå¿…è¦)\n", tag_demo, "demo-pendulum")
+txt.insert('end', " \n ", tag_demospace)
+txt.insert('end', "4. A celebration of Rube Goldberg (機能ã«å¯¾å¿œã—ãŸãƒãƒ¼ã‚¸ãƒ§ãƒ³ã®TkãŒå¿…è¦)\n", tag_demo, "demo-goldberg")
+
+txt.insert('end', "\n")
+#txt.insert('end', "ãã®ä»–\n", tag_middle)
+txt.insert('end', "ãã®ä»–\n", tag_kanji_title)
+txt.insert('end', " \n ", tag_demospace)
+txt.insert('end', "1. 組ã¿è¾¼ã¿ã®ãƒ“ットマップ\n", tag_demo, "demo-bitmap")
+txt.insert('end', " \n ", tag_demospace)
+txt.insert('end', "2. モーダルダイアログ(ローカルグラブ)\n",
+ tag_demo, "demo-dialog1")
+txt.insert('end', " \n ", tag_demospace)
+txt.insert('end', "3. モーダルダイアログ(グローãƒãƒ«ã‚°ãƒ©ãƒ–)\n",
+ tag_demo, "demo-dialog2")
+txt.insert('end', " \n ", tag_demospace)
+
+txt.state('disabled')
+scr.focus
+
+################################
+# method 定義
+################################
+def positionWindow(w)
+ w.geometry('+300+300')
+end
+
+# 親ウィジェットã¨ï¼Œå¤‰æ•°å㨠TkVariable ã¨ã®çµ„(é…列)ã®ä¸¦ã³ã‚’渡ã™
+$showVarsWin = {}
+def showVars1(parent, *args)
+ if $showVarsWin[parent.path]
+ begin
+ $showVarsWin[parent.path].destroy
+ rescue
+ end
+ end
+ top = TkToplevel.new(parent) {|w|
+ title "Variable values"
+ base = TkFrame.new(w).pack(:fill=>:both, :expand=>true)
+ TkLabel.new(base) {
+ text "変数値:"
+ width 20
+ anchor 'center'
+ if $tk_version =~ /^4.*/
+ font '-Adobe-helvetica-medium-r-normal--*-180-*-*-*-*-*-*'
+ else
+ font 'Helvetica 14'
+ end
+ }.pack('side'=>'top', 'fill'=>'x')
+ len = 1
+ args.each{|vnam,vbody|
+ len = vnam.to_s.length if vnam.to_s.length > len
+ }
+ args.each{|vnam,vbody|
+ TkFrame.new(base){|f|
+ #TkLabel.new(f, 'text'=>"#{vnam}: ").pack('side'=>'left')
+ TkLabel.new(f, 'text'=>"#{vnam}: ",'width'=>len+2).pack('side'=>'left')
+ TkLabel.new(f, 'textvariable'=>vbody, 'anchor'=>'w')\
+ .pack('side'=>'left', 'expand'=>'yes', 'fill'=>'x')
+ }.pack('side'=>'top', 'anchor'=>'w', 'fill'=>'x')
+ }
+ TkButton.new(base) {
+ text "了解"
+ command proc{w.destroy}
+ }.pack('side'=>'bottom', 'pady'=>2)
+ }
+ $showVarsWin[parent.path] = top
+end
+
+def showVars2(parent, *args)
+ if $showVarsWin[parent.path]
+ begin
+ $showVarsWin[parent.path].destroy
+ rescue
+ end
+ end
+ $showVarsWin[parent.path] = TkToplevel.new(parent) {|top|
+ title "Variable values"
+
+ base = TkFrame.new(top).pack(:fill=>:both, :expand=>true)
+
+ TkLabelFrame.new(base, :text=>"変数値:",
+ :font=>{:family=>'Helvetica', :size=>14}){|f|
+ args.each{|vnam,vbody|
+ TkGrid(TkLabel.new(f, :text=>"#{vnam}: ", :anchor=>'w'),
+ TkLabel.new(f, :textvariable=>vbody, :anchor=>'w'),
+ :padx=>2, :pady=>2, :sticky=>'w')
+ }
+
+ f.grid(:sticky=>'news', :padx=>4)
+ f.grid_columnconfig(1, :weight=>1)
+ f.grid_rowconfig(100, :weight=>1)
+ }
+ TkButton.new(base, :text=>"了解", :width=>8, :default=>:active,
+ :command=>proc{top.destroy}){|b|
+ top.bind('Return', proc{b.invoke})
+ top.bind('Escape', proc{b.invoke})
+
+ b.grid(:sticky=>'e', :padx=>4, :pady=>[6, 4])
+ }
+ base.grid_columnconfig(0, :weight=>1)
+ base.grid_rowconfig(0, :weight=>1)
+ }
+end
+
+if $tk_major_ver < 8
+ alias showVars showVars1
+elsif $tk_major_ver == 8 && $tk_minor_ver < 4
+ alias showVars showVars1
+else # ver >= 8.4
+ alias showVars showVars2
+end
+
+# 疑似トップレベルサãƒãƒ¼ãƒˆ
+module PseudoToplevel_Evaluable
+ def pseudo_toplevel_eval(body = Proc.new)
+ Thread.current[:TOPLEVEL] = self
+ begin
+ body.call
+ ensure
+ Thread.current[:TOPLEVEL] = nil
+ end
+ end
+
+ def pseudo_toplevel_evaluable?
+ @pseudo_toplevel_evaluable
+ end
+ def pseudo_toplevel_evaluable=(mode)
+ @pseudo_toplevel_evaluable = (mode)? true: false
+ end
+
+ def self.extended(mod)
+ mod.__send__(:extend_object, mod)
+ mod.instance_variable_set('@pseudo_toplevel_evaluable', true)
+ end
+end
+
+class Object
+ alias __method_missing__ method_missing
+ private :__method_missing__
+
+ def method_missing(id, *args)
+ begin
+ has_top = (top = Thread.current[:TOPLEVEL]) &&
+ top.respond_to?(:pseudo_toplevel_evaluable?) &&
+ top.pseudo_toplevel_evaluable? &&
+ top.respond_to?(id)
+ rescue Exception => e
+ has_top = false
+ end
+
+ if has_top
+ top.__send__(id, *args)
+ else
+ __method_missing__(id, *args)
+ end
+ end
+end
+
+class Proc
+ def initialize(*args, &b)
+ super
+ @__pseudo_toplevel__ = Thread.current[:TOPLEVEL]
+ end
+
+ alias __call__ call
+ def call(*args, &b)
+ if top = @__pseudo_toplevel__
+ orig_top = Thread.current[:TOPLEVEL]
+ Thread.current[:TOPLEVEL] = top
+ begin
+ __call__(*args, &b)
+ ensure
+ Thread.current[:TOPLEVEL] = orig_top
+ end
+ else
+ __call__(*args, &b)
+ end
+ end
+end
+
+def proc(&b)
+ Proc.new(&b)
+end
+def lambda(&b)
+ Proc.new(&b)
+end
+
+def _null_binding
+ Module.new.instance_eval{extend PseudoToplevel_Evaluable}
+ # binding
+ # Module.new.instance_eval{binding}
+end
+private :_null_binding
+
+def eval_samplecode(code, file=nil)
+ #eval(code)
+ #_null_binding.pseudo_toplevel_eval{ eval(code) }
+ #Thread.new{ _null_binding.pseudo_toplevel_eval{ eval(code) } }
+ Thread.new{
+ _null_binding.pseudo_toplevel_eval{
+ begin
+ if file
+ eval(code, binding, "(eval:#{file})")
+ else
+ eval(code)
+ end
+ rescue Exception=>e
+ #p e
+ TkBgError.show(e.message + "\n" +
+ "\n---< backtrace of Ruby side >-----\n" +
+ e.backtrace.join("\n") +
+ "\n---< backtrace of Tk side >-------")
+ end
+ }
+ }
+ Tk.update rescue nil
+end
+
+# テキスト上ã§ã® click ã«å¯¾ã™ã‚‹å‹•ä½œ
+def invoke(txt, idx)
+ tag = txt.tag_names(idx).find{|t| t.kind_of?(String) && t =~ /^demo-/}
+ return unless tag
+
+ cursor = txt.cget('cursor')
+ txt.cursor('watch')
+ Tk.update rescue nil
+ # eval(IO.readlines("#{[$demo_dir, tag[5..-1]].join(File::Separator)}.rb").join, _null_binding)
+ # Tk.update
+ eval_samplecode(IO.readlines("#{[$demo_dir, tag[5..-1]].join(File::Separator)}.rb").join, tag[5..-1] + '.rb')
+ txt.cursor(cursor)
+
+ $tag_visited.add("#{idx} linestart +1 chars", "#{idx} lineend +1 chars")
+end
+=begin
+def invoke (txt, idx)
+ tag = txt.tag_names(idx).find{|t| t.kind_of?(String) && t =~ /^demo-/}
+ return unless tag
+ current_cursor = txt.cget('cursor')
+ txt.cursor('watch')
+ Tk.update
+# eval `cat #{tag[5..-1]}.rb`
+# eval `cat #{[$demo_dir, tag[5..-1]].join(File::Separator)}.rb`
+ eval IO.readlines("#{[$demo_dir, tag[5..-1]].join(File::Separator)}.rb").join
+ Tk.update
+# txt.cursor('xterm')
+ txt.cursor(current_cursor)
+
+ $tag_visited.add("#{idx} linestart +1 chars", "#{idx} lineend +1 chars")
+end
+=end
+
+# 状態表示
+def showStatus (txt, index)
+ tag = txt.tag_names(index).find{|t| t.kind_of?(String) && t =~ /^demo-/}
+ cursor = txt.cget('cursor')
+ unless tag
+ $statusBarLabel.configure('text', " ")
+ newcursor = 'xterm'
+ else
+ demoname = tag[5..-1]
+ $statusBarLabel.configure('text',
+ "サンプルプログラム \"#{demoname}\" ã®å®Ÿè¡Œ ")
+ newcursor = 'hand2'
+ end
+ txt.configure('cursor'=>newcursor) if cursor != newcursor
+end
+
+# ソースコードã®è¡¨ç¤º
+def showCode1(demo)
+ file = "#{demo}.rb"
+ $code_window = nil unless defined? $code_window
+ if $code_window == nil || TkWinfo.exist?($code_window) == false
+ $code_window = TkToplevel.new(nil)
+ f = TkFrame.new($code_window)
+
+ TkButton.new(f) {
+ #text "了解"
+ text "é–‰ã˜ã‚‹"
+ command proc{
+ $code_window.destroy
+ $code_window = nil
+ }
+ }.pack('side'=>'right', 'expand'=>'false', 'pady'=>2)
+ TkButton.new(f) {
+ text "å†å®Ÿè¡Œ"
+ # command proc{eval($code_text.get('1.0','end'), _null_binding)}
+ command proc{eval_samplecode($code_text.get('1.0','end'), '<viewer>')}
+ }.pack('side'=>'right', 'expand'=>'false', 'pady'=>2)
+
+ TkLabel.new(f,'text'=>'line:').pack('side'=>'left')
+ linenum =TkLabel.new(f,'text'=>'').pack('side'=>'left')
+ TkLabel.new(f,'text'=>' pos:').pack('side'=>'left')
+ posnum =TkLabel.new(f,'text'=>'').pack('side'=>'left')
+
+ $set_linenum = proc{|w|
+ line, pos = w.index('insert').split('.')
+ linenum.text = line
+ posnum.text = pos
+ }
+
+ f.pack('side'=>'bottom', 'expand'=>'true', 'fill'=>'x')
+
+ if $tk_version =~ /^4\.[01]/
+ s = TkScrollbar.new($code_window, 'orient'=>'vertical')
+ $code_text = TkText.new($code_window) {
+ height 40
+ setgrid 'yes'
+ yscrollcommand proc{|first,last| s.set first,last}
+ }
+ s.command(proc{|*args| $code_text.yview(*args)})
+ s.pack('side'=>'right', 'fill'=>'y')
+ $code_text.pack('side'=>'left', 'expand'=>'yes', 'fill'=>'both')
+ else
+ TkFrame.new($code_window) {|f|
+ pack('expand'=>'yes', 'fill'=>'both', 'padx'=>1, 'pady'=>1)
+
+ hs = TkScrollbar.new($code_window, 'highlightthickness'=>0,
+ 'orient'=>'horizontal')
+ vs = TkScrollbar.new($code_window, 'highlightthickness'=>0,
+ 'orient'=>'vertical')
+ $code_text = TkText.new($code_window) {|t|
+ height 40
+ #wrap 'word'
+ wrap 'char'
+ xscrollcommand proc{|first,last| hs.set first,last}
+ yscrollcommand proc{|first,last| vs.set first,last}
+ setgrid 'yes'
+ highlightthickness 0
+ pady 2
+ padx 3
+ hs.command(proc{|*args| $code_text.xview(*args)})
+ vs.command(proc{|*args| $code_text.yview(*args)})
+ }
+
+ $code_text.grid('in'=>f, 'padx'=>1, 'pady'=>1, 'row'=>0, 'column'=>0,
+ 'rowspan'=>1, 'columnspan'=>1, 'sticky'=>'news')
+ vs.grid('in'=>f, 'padx'=>1, 'pady'=>1, 'row'=>0, 'column'=>1,
+ 'rowspan'=>1, 'columnspan'=>1, 'sticky'=>'news')
+# xs.grid('in'=>f, 'padx'=>1, 'pady'=>1, 'row'=>1, 'column'=>0,
+# 'rowspan'=>1, 'columnspan'=>1, 'sticky'=>'news')
+ TkGrid.rowconfigure(f, 0, 'weight'=>1, 'minsize'=>0)
+ TkGrid.columnconfigure(f, 0, 'weight'=>1, 'minsize'=>0)
+ }
+ end
+
+ btag = TkBindTag.new
+
+ btag.bind('Key', $set_linenum, '%W')
+ btag.bind('Button', $set_linenum, '%W')
+
+ btags = $code_text.bindtags
+ btags.insert(btags.index($code_text.class) + 1, btag)
+ $code_text.bindtags = btags
+
+ else
+ $code_window.deiconify
+ $code_window.raise
+ end
+
+ $code_window.title("Demo code: #{file}")
+ $code_window.iconname(file)
+ code = open([$demo_dir, file].join(File::Separator), 'r'){|fid| fid.read }
+ $code_text.delete('1.0', 'end')
+ code.force_encoding('EUC-JP') if defined?(::Encoding.default_external)
+ $code_text.insert('1.0', code)
+ TkTextMarkInsert.new($code_text,'1.0')
+ $set_linenum.call($code_text)
+end
+
+def showCode2(demo)
+ file = "#{demo}.rb"
+ $code_window = nil unless defined? $code_window
+ if $code_window == nil || TkWinfo.exist?($code_window) == false
+ $code_window = TkToplevel.new(nil)
+ tf = TkFrame.new($code_window)
+ $code_text = TkText.new(tf, :font=>'Courier 10', :height=>30,
+ :wrap=>'word', :bd=>1, :setgrid=>true,
+ :highlightthickness=>0, :pady=>2, :padx=>3)
+ xscr = TkScrollbar.new(tf, :bd=>1){assign($code_text)}
+ yscr = TkScrollbar.new(tf, :bd=>1){assign($code_text)}
+ TkGrid($code_text, yscr, :sticky=>'news')
+ #TkGrid(xscr)
+ tf.grid_rowconfigure(0, :weight=>1)
+ tf.grid_columnconfigure(0, :weight=>1)
+
+ bf = TkFrame.new($code_window)
+
+ lf = TkFrame.new(bf)
+ TkLabel.new(lf, :text=>'line:').pack(:side=>:left)
+ linenum =TkLabel.new(lf, :text=>'').pack(:side=>:left)
+ TkLabel.new(lf, :text=>' pos:').pack(:side=>:left)
+ posnum =TkLabel.new(lf, :text=>'').pack(:side=>:left)
+
+ $set_linenum = proc{|w|
+ line, pos = w.index('insert').split('.')
+ linenum.text = line
+ posnum.text = pos
+ }
+
+ #b_dis = TkButton.new(bf, :text=>'了解', :default=>:active,
+ b_dis = TkButton.new(bf, :text=>'é–‰ã˜ã‚‹', :default=>:active,
+ :command=>proc{
+ $code_window.destroy
+ $code_window = nil
+ },
+ :image=>$image['delete'], :compound=>:left)
+ b_prn = TkButton.new(bf, :text=>'å°åˆ·',
+ :command=>proc{printCode($code_text, file)},
+ :image=>$image['print'], :compound=>:left)
+ b_run = TkButton.new(bf, :text=>'å†å®Ÿè¡Œ',
+ :command=>proc{
+ # eval($code_text.get('1.0','end'), _null_binding)
+ eval_samplecode($code_text.get('1.0','end'), '<viewer>')
+ },
+ :image=>$image['refresh'], :compound=>:left)
+
+ TkGrid(lf, 'x', b_run, b_prn, b_dis, :padx=>4, :pady=>[6,4])
+ bf.grid_columnconfigure(1, :weight=>1)
+
+ TkGrid(tf, :sticky=>'news')
+ TkGrid(bf, :sticky=>'ew')
+ $code_window.grid_columnconfigure(0, :weight=>1)
+ $code_window.grid_rowconfigure(0, :weight=>1)
+
+ $code_window.bind('Return', proc{|win|
+ b_dis.invoke unless win.kind_of?(TkText)
+ }, '%W')
+ $code_window.bindinfo('Return').each{|cmd, arg|
+ $code_window.bind_append('Escape', cmd, arg)
+ }
+
+ btag = TkBindTag.new
+
+ btag.bind('Key', $set_linenum, '%W')
+ btag.bind('Button', $set_linenum, '%W')
+
+ btags = $code_text.bindtags
+ btags.insert(btags.index($code_text.class) + 1, btag)
+ $code_text.bindtags = btags
+
+ else
+ $code_window.deiconify
+ $code_window.raise
+ end
+
+ $code_window.title("Demo code: #{file}")
+ $code_window.iconname(file)
+ code = open([$demo_dir, file].join(File::Separator), 'r'){|fid| fid.read }
+ $code_text.delete('1.0', 'end')
+ code.force_encoding('EUC-JP') if defined?(::Encoding.default_external)
+ $code_text.insert('1.0', code)
+ TkTextMarkInsert.new($code_text,'1.0')
+ $set_linenum.call($code_text)
+end
+
+if $tk_major_ver < 8
+ alias showCode showCode1
+elsif $tk_major_ver == 8 && $tk_minor_ver < 4
+ alias showCode showCode1
+else # ver >= 8.4
+ alias showCode showCode2
+end
+
+
+# printCode --
+# Prints the source code currently displayed in the See Code dialog.
+# Much thanks to Arjen Markus for this.
+#
+# Arguments:
+# txt - Name of text widget containing code to print
+# file - Name of the original file (implicitly for title)
+
+def printCode(txt, file)
+ code = txt.get('1.0', 'end - 1c')
+ dir = '.'
+ dir = ENV['HOME'] if ENV['HOME']
+ dir = ENV['TMP'] if ENV['TMP']
+ dir = ENV['TEMP'] if ENV['TEMP']
+
+ fname = [dir, 'tkdemo-' + file].join(File::Separator)
+ open(fname, 'w'){|fid| fid.print(code)}
+ begin
+ case Tk::TCL_PLATFORM('platform')
+ when 'unix'
+ msg = `lp -c #{fname}`
+ unless $?.exitstatus == 0
+ Tk.messageBox(:title=>'Print spooling failure',
+ :message=>'エラーãŒç™ºç”Ÿã—ã¾ã—ãŸï¼Ž' +
+ 'å°åˆ·ã«å¤±æ•—ã—ãŸã‚‚ã®ã¨æ€ã‚ã‚Œã¾ã™ : ' + msg)
+ end
+ when 'windows'
+ begin
+ printTextWin32(fname)
+ rescue => e
+ Tk.messageBox(:title=>'Print spooling failure',
+ :message=>'エラーãŒç™ºç”Ÿã—ã¾ã—ãŸï¼Ž' +
+ 'å°åˆ·ã«å¤±æ•—ã—ãŸã‚‚ã®ã¨æ€ã‚ã‚Œã¾ã™ : ' +
+ e.message)
+ end
+ when 'macintosh'
+ Tk.messageBox(:title=>'Operation not Implemented',
+ :message=>'å°åˆ·æ©Ÿèƒ½ã¯ã¾ã å®Ÿè£…ã•ã‚Œã¦ã„ã¾ã›ã‚“')
+ else
+ Tk.messageBox(:title=>'Operation not Implemented',
+ :message=>'検出ã•ã‚ŒãŸç’°å¢ƒ ' +
+ Tk::TCL_PLATFORM('platform') +
+ ' ã¯æœªçŸ¥ã®ç’°å¢ƒã§ã‚ã‚‹ãŸã‚,' +
+ 'å°åˆ·æ©Ÿèƒ½ã¯å®Ÿè£…ã•ã‚Œã¦ã„ã¾ã›ã‚“: ')
+ end
+ ensure
+ File.delete(fname)
+ end
+end
+
+# printTextWin32 --
+# Print a file under Windows
+#
+# Arguments:
+# filename - Name of the file
+#
+def printTextWin32(fname)
+ require 'win32/registry'
+ begin
+ app = Win32::Registry::HKEY_CLASSES_ROOT['.txt']
+ pcmd = nil
+ Win32::Registry::HKEY_CLASSES_ROOT.open("#{app}\\shell\\print"){|reg|
+ pcmd = reg['command']
+ }
+ rescue
+ app = Tk.tk_call('auto_execok', 'notepad.exe')
+ pcmd = "#{app} /p %1"
+ end
+
+ pcmd.gsub!('%1', fname)
+ puts pcmd
+ cmd = Tk.tk_call('auto_execok', 'start') + ' /min ' + pcmd
+
+ msg = `#{cmd}`
+ unless $?.exitstatus == 0
+ fail RuntimeError, msg
+ end
+end
+
+# aboutBox
+#
+# Pops up a message box with an "about" message
+#
+def aboutBox
+ Tk.messageBox('icon'=>'info', 'type'=>'ok', 'title'=>'About Widget Demo',
+ 'message'=>"Ruby/Tk ウィジェットデモ Ver.1.7.1-jp\n\n" +
+ "based on demos of Tk8.1 -- 8.5 " +
+ "( Copyright of Tcl/Tk demos:: " +
+ "(c) 1996-1997 Sun Microsystems, Inc. / " +
+ "(c) 1997-2000 Ajuba Solutions, Inc. / " +
+ "(c) 2001-2007 Donal K. Fellows / " +
+ "(c) 2002-2007 Daniel A. Steffen )\n\n" +
+ "Your Ruby & Tk Version ::\n" +
+ "Ruby#{RUBY_VERSION}(#{RUBY_RELEASE_DATE})[#{RUBY_PLATFORM}] / Tk#{$tk_patchlevel}#{(Tk::JAPANIZED_TK)? '-jp': ''}\n\n" +
+ "Ruby/Tk release date :: tcltklib #{TclTkLib::RELEASE_DATE}; tk #{Tk::RELEASE_DATE}")
+end
+
+####################################
+# 引数ã§æŒ‡å®šã•ã‚ŒãŸãƒ‡ãƒ¢ã‚’èµ·å‹•ã™ã‚‹
+no_launcher = false
+if ARGV[0] == '-n'
+ ARGV.shift
+ no_launcher = true if ARGV.size > 0
+else
+ # show the root widget to make it lower then demo windows
+ Tk.update rescue nil
+end
+ARGV.each{|cmd|
+ if cmd =~ /(.*).rb/
+ cmd = $1
+ end
+ #eval(IO.readlines("#{[$demo_dir, cmd].join(File::Separator)}.rb").join,
+ # _null_binding)
+ eval_samplecode(IO.readlines("#{[$demo_dir, cmd].join(File::Separator)}.rb").join, cmd + '.rb')
+}
+if no_launcher
+ $root.withdraw # hide root window
+ Thread.start{
+ loop do
+ count = 0
+ $root.winfo_children.each{|w|
+ count += 1 if w.kind_of?(TkToplevel)
+ }
+ $root.destroy if count == 0
+ end
+ }
+end
+
+################################
+# イベント待ã¡ã«å…¥ã‚‹
+Tk.mainloop
diff --git a/jni/ruby/ext/tk/sample/editable_listbox.rb b/jni/ruby/ext/tk/sample/editable_listbox.rb
new file mode 100644
index 0000000..890aec0
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/editable_listbox.rb
@@ -0,0 +1,148 @@
+#
+# Tk::RbWidget::Editable_Listbox class
+#
+# When "DoubleClick-1" on a listbox item, the entry box is opend on the
+# item. And when hit "Return" key on the entry box after modifying the
+# text, the entry box is closed and the item is changed. Or when hit
+# "Escape" key, the entry box is closed without modification.
+#
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+require 'tk'
+
+module Tk
+ module RbWidget
+ class Editable_Listbox < TkListbox
+ end
+ end
+end
+
+
+class Tk::RbWidget::Editable_Listbox < TkListbox
+ #------------------------------------
+ BindTag = TkBindTag.new_by_name(self.to_s.gsub(/::/, '#'))
+
+ BindTag.bind('FocusIn', :widget){|w|
+ w.instance_eval{
+ if idx = @ebox.pos
+ see(idx) if bbox(idx).empty?
+ @ebox.focus(true)
+ end
+ }
+ }
+
+ BindTag.bind('Double-1', :widget, :y){|w, y|
+ w.instance_eval{ _ebox_placer(nearest(y)) }
+ }
+
+ BindTag.bind('Return', :widget){|w|
+ w.instance_eval{
+ if idx = index(:active)
+ _ebox_placer(idx)
+ end
+ }
+ }
+ #------------------------------------
+
+ def configure(*args)
+ ret = super
+
+ case cget(:state)
+ when 'normal'
+ # do nothing
+ when 'disabled'
+ _ebox_erase
+ else # unknown
+ # do nothing
+
+ end
+
+ ret
+ end
+
+ def _ebox_move(idx)
+ return nil if cget(:state) == 'disabled'
+ x, y, w, h = bbox(idx)
+ return nil unless y && h
+ @ebox.place(:x => 0, :relwidth => 1.0,
+ :y => y - selectborderwidth,
+ :height => h + 2 * selectborderwidth)
+ @ebox.pos = idx
+ @ebox.focus
+ end
+
+ def _ebox_placer(idx)
+ return nil unless _ebox_move(idx)
+ @ebox.value = listvariable.list[idx]
+ @ebox.xview_moveto(self.xview[0])
+ end
+
+ def _ebox_erase
+ @ebox.place_forget
+ @ebox.pos = nil
+ end
+ private :_ebox_move, :_ebox_placer, :_ebox_erase
+
+ def _setup_ebox_bindings
+ # bindings for entry
+ @ebox.bind('Return'){
+ list = listvariable.list
+ list[@ebox.pos] = @ebox.value if @ebox.pos
+ listvariable.value = list
+ _ebox_erase
+ focus
+ }
+
+ @ebox.bind('Escape'){ _ebox_erase }
+ end
+ def _setup_listbox_bindings
+ # bindings for listbox
+ tags = bindtags
+ bindtags(tags.insert(tags.index(self) + 1, self.class::BindTag))
+ end
+ private :_setup_ebox_bindings, :_setup_listbox_bindings
+
+ def yview(*args)
+ if !@ebox.pos || bbox(@ebox.pos).empty?
+ @ebox.place_forget
+ else
+ _ebox_move(@ebox.pos)
+ end
+ super
+ end
+
+ def create_self(keys)
+ super(keys)
+
+ unless self.listvariable
+ self.listvariable = TkVariable.new(self.get(0, :end))
+ end
+
+ @ebox = TkEntry.new(self){
+ @pos = nil
+ def self.pos; @pos; end
+ def self.pos=(idx); @pos = idx; end
+ }
+
+ _setup_ebox_bindings
+ _setup_listbox_bindings
+ end
+end
+
+if $0 == __FILE__
+ #lbox0 = TkListbox.new.pack(:side=>:left)
+ #lbox0.insert(:end, 0,1,2,3,4,5,6,7,8,9,0,1,2,3)
+
+ scr = TkScrollbar.new.pack(:side=>:right, :fill=>:y)
+
+ lbox1 = Tk::RbWidget::Editable_Listbox.new.pack(:side=>:left)
+ lbox2 = Tk::RbWidget::Editable_Listbox.new.pack(:side=>:left)
+
+ scr.assign(lbox1, lbox2)
+
+ lbox1.insert(:end, *%w(a b c d e f g h i j k l m n))
+ lbox2.insert(:end, 0,1,2,3,4,5,6,7,8,9,0,1,2,3)
+
+
+ Tk.mainloop
+end
diff --git a/jni/ruby/ext/tk/sample/encstr_usage.rb b/jni/ruby/ext/tk/sample/encstr_usage.rb
new file mode 100644
index 0000000..39dc9c4
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/encstr_usage.rb
@@ -0,0 +1,30 @@
+require 'tk'
+
+TkMessage.new(:width=>400, :text=><<EOM).pack
+This sample shows how to use Tk::EncodedString class. \
+This reads 'iso2022-kr' text (from discription of \
+Korean language environment of GNU Emacs 20.7.2) \
+and inserts the text into the text widget.
+EOM
+
+t1 = TkText.new(:height=>5).pack
+t2 = TkText.new(:height=>5).pack
+t3 = TkText.new(:height=>5).pack
+
+src_str = IO.readlines(File.join(File.dirname(__FILE__),'iso2022-kr.txt')).join
+
+t1.insert('end',
+ "use neither Tk::EncodedString class nor Tk.encoding= method\n\n")
+t1.insert('end', src_str)
+
+enc_str = Tk::EncodedString(src_str, 'iso2022-kr')
+t2.insert('end',
+ "use Tk::EncodedString class (Tk.encoding => '#{Tk.encoding}')\n\n")
+t2.insert('end', enc_str)
+
+Tk.encoding = 'iso2022-kr'
+t3.insert('end', "use Tk.encoding = 'iso2022-kr' (Tk.force_default_encoding? == #{Tk.force_default_encoding?})\n\n")
+
+t3.insert('end', src_str)
+
+Tk.mainloop
diff --git a/jni/ruby/ext/tk/sample/figmemo_sample.rb b/jni/ruby/ext/tk/sample/figmemo_sample.rb
new file mode 100644
index 0000000..da6c417
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/figmemo_sample.rb
@@ -0,0 +1,456 @@
+#!/usr/bin/env ruby
+require 'tk'
+
+begin
+ # try to use Img extension
+ require 'tkextlib/tkimg'
+rescue Exception
+ # cannot use Img extension --> ignore
+end
+
+
+############################
+# scrolled_canvas
+class TkScrolledCanvas < TkCanvas
+ include TkComposite
+
+ def initialize_composite(keys={})
+ @h_scr = TkScrollbar.new(@frame)
+ @v_scr = TkScrollbar.new(@frame)
+
+ @canvas = TkCanvas.new(@frame)
+ @path = @canvas.path
+
+ @canvas.xscrollbar(@h_scr)
+ @canvas.yscrollbar(@v_scr)
+
+ TkGrid.rowconfigure(@frame, 0, :weight=>1, :minsize=>0)
+ TkGrid.columnconfigure(@frame, 0, :weight=>1, :minsize=>0)
+
+ @canvas.grid(:row=>0, :column=>0, :sticky=>'news')
+ @h_scr.grid(:row=>1, :column=>0, :sticky=>'ew')
+ @v_scr.grid(:row=>0, :column=>1, :sticky=>'ns')
+
+ delegate('DEFAULT', @canvas)
+ delegate('background', @canvas, @h_scr, @v_scr)
+ delegate('activebackground', @h_scr, @v_scr)
+ delegate('troughcolor', @h_scr, @v_scr)
+ delegate('repeatdelay', @h_scr, @v_scr)
+ delegate('repeatinterval', @h_scr, @v_scr)
+ delegate('borderwidth', @frame)
+ delegate('relief', @frame)
+
+ delegate_alias('canvasborderwidth', 'borderwidth', @canvas)
+ delegate_alias('canvasrelief', 'relief', @canvas)
+
+ delegate_alias('scrollbarborderwidth', 'borderwidth', @h_scr, @v_scr)
+ delegate_alias('scrollbarrelief', 'relief', @h_scr, @v_scr)
+
+ configure(keys) unless keys.empty?
+ end
+end
+
+############################
+class PhotoCanvas < TkScrolledCanvas
+
+USAGE = <<EOT
+--- WHAT IS ---
+You can write comments on the loaded image, and save it as a Postscipt
+file (original image file is not modified). Each comment is drawn as a
+set of an indicator circle, an arrow, and a memo text. See the following
+how to write comments.
+This can save the list of memo texts to another file. It may useful to
+search the saved Postscript file by the comments on them.
+This may not support multibyte characters (multibyte texts are broken on
+a Postscript file). It depends on features of canvas widgets of Tcl/Tk
+libraries linked your Ruby/Tk. If you use Tcl/Tk8.0-jp (Japanized Tcl/Tk),
+you can (possibly) get a Japanese Postscript file.
+
+--- BINDINGS ---
+* Button-1 : draw comments by following steps
+ 1st - Set center of a indicator circle.
+ 2nd - Set head position of an arrow.
+ 3rd - Set tail position of an arrow, and show an entry box.
+ Input a memo text and hit 'Enter' key to entry the comment.
+
+* Button-2-drag : scroll the canvas
+
+* Button-3 : when drawing, cancel current drawing
+
+* Double-Button-3 : delete the clicked comment (text, arrow, and circle)
+EOT
+
+ def initialize(*args)
+ super(*args)
+
+ self.highlightthickness = 0
+ self.selectborderwidth = 0
+
+ @photo = TkPhotoImage.new
+ @img = TkcImage.new(self, 0, 0, :image=>@photo)
+
+ width = self.width
+ height = self.height
+ @scr_region = [-width, -height, width, height]
+ self.scrollregion(@scr_region)
+ self.xview_moveto(0.25)
+ self.yview_moveto(0.25)
+
+ @col = 'red'
+ @font = 'Helvetica -12'
+
+ @memo_id_num = -1
+ @memo_id_head = 'memo_'
+ @memo_id_tag = nil
+ @overlap_d = 2
+
+ @state = TkVariable.new
+ @border = 2
+ @selectborder = 1
+ @delta = @border + @selectborder
+ @entry = TkEntry.new(self, :relief=>:ridge, :borderwidth=>@border,
+ :selectborderwidth=>@selectborder,
+ :highlightthickness=>0)
+ @entry.bind('Return'){@state.value = 0}
+
+ @mode = old_mode = 0
+
+ _state0()
+
+ bind('2', :x, :y){|x,y| scan_mark(x,y)}
+ bind('B2-Motion', :x, :y){|x,y| scan_dragto(x,y)}
+
+ bind('3'){
+ next if (old_mode = @mode) == 0
+ @items.each{|item| item.delete }
+ _state0()
+ }
+
+ bind('Double-3', :widget, :x, :y){|w, x, y|
+ next if old_mode != 0
+ x = w.canvasx(x)
+ y = w.canvasy(y)
+ tag = nil
+ w.find_overlapping(x - @overlap_d, y - @overlap_d,
+ x + @overlap_d, y + @overlap_d).find{|item|
+ ! (item.tags.find{|name|
+ if name =~ /^(#{@memo_id_head}\d+)$/
+ tag = $1
+ end
+ }.empty?)
+ }
+ w.delete(tag) if tag
+ }
+ end
+
+ #-----------------------------------
+ private
+ def _state0() # init
+ @mode = 0
+
+ @memo_id_num += 1
+ @memo_id_tag = @memo_id_head + @memo_id_num.to_s
+
+ @target = nil
+ @items = []
+ @mark = [0, 0]
+ bind_remove('Motion')
+ bind('ButtonRelease-1', proc{|x,y| _state1(x,y)}, '%x', '%y')
+ end
+
+ def _state1(x,y) # set center
+ @mode = 1
+
+ @target = TkcOval.new(self,
+ [canvasx(x), canvasy(y)], [canvasx(x), canvasy(y)],
+ :outline=>@col, :width=>3, :tags=>[@memo_id_tag])
+ @items << @target
+ @mark = [x,y]
+
+ bind('Motion', proc{|x,y| _state2(x,y)}, '%x', '%y')
+ bind('ButtonRelease-1', proc{|x,y| _state3(x,y)}, '%x', '%y')
+ end
+
+ def _state2(x,y) # create circle
+ @mode = 2
+
+ r = Integer(Math.sqrt((x-@mark[0])**2 + (y-@mark[1])**2))
+ @target.coords([canvasx(@mark[0] - r), canvasy(@mark[1] - r)],
+ [canvasx(@mark[0] + r), canvasy(@mark[1] + r)])
+ end
+
+ def _state3(x,y) # set line start
+ @mode = 3
+
+ @target = TkcLine.new(self,
+ [canvasx(x), canvasy(y)], [canvasx(x), canvasy(y)],
+ :arrow=>:first, :arrowshape=>[10, 14, 5],
+ :fill=>@col, :tags=>[@memo_id_tag])
+ @items << @target
+ @mark = [x, y]
+
+ bind('Motion', proc{|x,y| _state4(x,y)}, '%x', '%y')
+ bind('ButtonRelease-1', proc{|x,y| _state5(x,y)}, '%x', '%y')
+ end
+
+ def _state4(x,y) # create line
+ @mode = 4
+
+ @target.coords([canvasx(@mark[0]), canvasy(@mark[1])],
+ [canvasx(x), canvasy(y)])
+ end
+
+ def _state5(x,y) # set text
+ @mode = 5
+
+ if x - @mark[0] >= 0
+ justify = 'left'
+ dx = - @delta
+
+ if y - @mark[1] >= 0
+ anchor = 'nw'
+ dy = - @delta
+ else
+ anchor = 'sw'
+ dy = @delta
+ end
+ else
+ justify = 'right'
+ dx = @delta
+
+ if y - @mark[1] >= 0
+ anchor = 'ne'
+ dy = - @delta
+ else
+ anchor = 'se'
+ dy = @delta
+ end
+ end
+
+ bind_remove('Motion')
+
+ @entry.value = ''
+ @entry.configure(:justify=>justify, :font=>@font, :foreground=>@col)
+
+ ewin = TkcWindow.new(self, [canvasx(x)+dx, canvasy(y)+dy],
+ :window=>@entry, :state=>:normal, :anchor=>anchor,
+ :tags=>[@memo_id_tag])
+
+ @entry.focus
+ @entry.grab
+ @state.wait
+ @entry.grab_release
+
+ ewin.delete
+
+ @target = TkcText.new(self, [canvasx(x), canvasy(y)],
+ :anchor=>anchor, :justify=>justify,
+ :fill=>@col, :font=>@font, :text=>@entry.value,
+ :tags=>[@memo_id_tag])
+
+ _state0()
+ end
+
+ #-----------------------------------
+ public
+ def load_photo(filename)
+ @photo.configure(:file=>filename)
+ end
+
+ def modified?
+ ! ((find_withtag('all') - [@img]).empty?)
+ end
+
+ def fig_erase
+ (find_withtag('all') - [@img]).each{|item| item.delete}
+ end
+
+ def reset_region
+ width = @photo.width
+ height = @photo.height
+
+ if width > @scr_region[2]
+ @scr_region[0] = -width
+ @scr_region[2] = width
+ end
+
+ if height > @scr_region[3]
+ @scr_region[1] = -height
+ @scr_region[3] = height
+ end
+
+ self.scrollregion(@scr_region)
+ self.xview_moveto(0.25)
+ self.yview_moveto(0.25)
+ end
+
+ def get_texts
+ ret = []
+ find_withtag('all').each{|item|
+ if item.kind_of?(TkcText)
+ ret << item[:text]
+ end
+ }
+ ret
+ end
+end
+############################
+
+# define methods for menu
+def open_file(canvas, fname)
+ if canvas.modified?
+ ret = Tk.messageBox(:icon=>'warning',:type=>'okcancel',:default=>'cancel',
+ :message=>'Canvas may be modified. Realy erase? ')
+ return if ret == 'cancel'
+ end
+
+ filetypes = [
+ ['GIF Files', '.gif'],
+ ['GIF Files', [], 'GIFF'],
+ ['PPM Files', '.ppm'],
+ ['PGM Files', '.pgm']
+ ]
+
+ begin
+ if Tk::Img::package_version != ''
+ filetypes << ['JPEG Files', ['.jpg', '.jpeg']]
+ filetypes << ['PNG Files', '.png']
+ filetypes << ['PostScript Files', '.ps']
+ filetypes << ['PDF Files', '.pdf']
+ filetypes << ['Windows Bitmap Files', '.bmp']
+ filetypes << ['Windows Icon Files', '.ico']
+ filetypes << ['PCX Files', '.pcx']
+ filetypes << ['Pixmap Files', '.pixmap']
+ filetypes << ['SGI Files', '.sgi']
+ filetypes << ['Sun Raster Files', '.sun']
+ filetypes << ['TGA Files', '.tga']
+ filetypes << ['TIFF Files', '.tiff']
+ filetypes << ['XBM Files', '.xbm']
+ filetypes << ['XPM Files', '.xpm']
+ end
+ rescue
+ end
+
+ filetypes << ['ALL Files', '*']
+
+ fpath = Tk.getOpenFile(:filetypes=>filetypes)
+ return if fpath.empty?
+
+ begin
+ canvas.load_photo(fpath)
+ rescue => e
+ Tk.messageBox(:icon=>'error', :type=>'ok',
+ :message=>"Fail to read '#{fpath}'.\n#{e.message}")
+ end
+
+ canvas.fig_erase
+ canvas.reset_region
+
+ fname.value = fpath
+end
+
+# --------------------------------
+def save_memo(canvas, fname)
+ initname = fname.value
+ if initname != '-'
+ initname = File.basename(initname, File.extname(initname))
+ fpath = Tk.getSaveFile(:filetypes=>[ ['Text Files', '.txt'],
+ ['ALL Files', '*'] ],
+ :initialfile=>initname)
+ else
+ fpath = Tk.getSaveFile(:filetypes=>[ ['Text Files', '.txt'],
+ ['ALL Files', '*'] ])
+ end
+ return if fpath.empty?
+
+ begin
+ fid = open(fpath, 'w')
+ rescue => e
+ Tk.messageBox(:icon=>'error', :type=>'ok',
+ :message=>"Fail to open '#{fname.value}'.\n#{e.message}")
+ end
+
+ begin
+ canvas.get_texts.each{|txt|
+ fid.print(txt, "\n")
+ }
+ ensure
+ fid.close
+ end
+end
+
+# --------------------------------
+def ps_print(canvas, fname)
+ initname = fname.value
+ if initname != '-'
+ initname = File.basename(initname, File.extname(initname))
+ fpath = Tk.getSaveFile(:filetypes=>[ ['Postscript Files', '.ps'],
+ ['ALL Files', '*'] ],
+ :initialfile=>initname)
+ else
+ fpath = Tk.getSaveFile(:filetypes=>[ ['Postscript Files', '.ps'],
+ ['ALL Files', '*'] ])
+ end
+ return if fpath.empty?
+
+ bbox = canvas.bbox('all')
+ canvas.postscript(:file=>fpath, :x=>bbox[0], :y=>bbox[1],
+ :width=>bbox[2] - bbox[0], :height=>bbox[3] - bbox[1])
+end
+
+# --------------------------------
+def quit(canvas)
+ ret = Tk.messageBox(:icon=>'warning', :type=>'okcancel',
+ :default=>'cancel',
+ :message=>'Realy quit? ')
+ exit if ret == 'ok'
+end
+
+# --------------------------------
+# setup root
+root = TkRoot.new(:title=>'Fig Memo')
+
+# create canvas frame
+canvas = PhotoCanvas.new(root).pack(:fill=>:both, :expand=>true)
+usage_frame = TkFrame.new(root, :relief=>:ridge, :borderwidth=>2)
+hide_btn = TkButton.new(usage_frame, :text=>'hide usage',
+ :font=>{:size=>8}, :pady=>1,
+ :command=>proc{usage_frame.unpack})
+hide_btn.pack(:anchor=>'e', :padx=>5)
+usage = TkLabel.new(usage_frame, :text=>PhotoCanvas::USAGE,
+ :font=>'Helvetica 8', :justify=>:left).pack
+
+show_usage = proc{
+ usage_frame.pack(:before=>canvas, :fill=>:x, :expand=>true)
+}
+
+fname = TkVariable.new('-')
+f = TkFrame.new(root, :relief=>:sunken, :borderwidth=>1).pack(:fill=>:x)
+label = TkLabel.new(f, :textvariable=>fname,
+ :font=>{:size=>-12, :weight=>:bold},
+ :anchor=>'w').pack(:side=>:left, :fill=>:x, :padx=>10)
+
+# create menu
+mspec = [
+ [ ['File', 0],
+ ['Show Usage', proc{show_usage.call}, 5],
+ '---',
+ ['Open Image File', proc{open_file(canvas, fname)}, 0],
+ ['Save Memo Texts', proc{save_memo(canvas, fname)}, 0],
+ '---',
+ ['Save Postscript', proc{ps_print(canvas, fname)}, 5],
+ '---',
+ ['Quit', proc{quit(canvas)}, 0]
+ ]
+]
+root.add_menubar(mspec)
+
+# manage wm_protocol
+root.protocol(:WM_DELETE_WINDOW){quit(canvas)}
+
+# show usage
+show_usage.call
+
+# --------------------------------
+# start eventloop
+Tk.mainloop
diff --git a/jni/ruby/ext/tk/sample/images/earth.gif b/jni/ruby/ext/tk/sample/images/earth.gif
new file mode 100644
index 0000000..2c229eb
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/images/earth.gif
Binary files differ
diff --git a/jni/ruby/ext/tk/sample/images/earthris.gif b/jni/ruby/ext/tk/sample/images/earthris.gif
new file mode 100644
index 0000000..c4ee473
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/images/earthris.gif
Binary files differ
diff --git a/jni/ruby/ext/tk/sample/images/face.xbm b/jni/ruby/ext/tk/sample/images/face.xbm
new file mode 100644
index 0000000..03d829f
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/images/face.xbm
@@ -0,0 +1,173 @@
+#define face_width 108
+#define face_height 144
+#define face_x_hot 48
+#define face_y_hot 80
+static char face_bits[] = {
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x09,
+ 0x20, 0x80, 0x24, 0x05, 0x00, 0x80, 0x08, 0x00, 0x00, 0x00, 0x00, 0x88,
+ 0x24, 0x20, 0x80, 0x24, 0x00, 0x00, 0x00, 0x10, 0x80, 0x04, 0x00, 0x01,
+ 0x00, 0x01, 0x40, 0x0a, 0x09, 0x00, 0x92, 0x04, 0x80, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x10, 0x40, 0x12, 0x00, 0x00, 0x10, 0x40, 0x00, 0x00, 0x84,
+ 0x24, 0x40, 0x22, 0xa8, 0x02, 0x14, 0x84, 0x92, 0x40, 0x42, 0x12, 0x04,
+ 0x10, 0x00, 0x00, 0x00, 0x00, 0x52, 0x00, 0x52, 0x11, 0x00, 0x12, 0x00,
+ 0x40, 0x02, 0x00, 0x20, 0x00, 0x08, 0x00, 0xaa, 0x02, 0x54, 0x85, 0x24,
+ 0x00, 0x10, 0x12, 0x00, 0x00, 0x81, 0x44, 0x00, 0x90, 0x5a, 0x00, 0xea,
+ 0x1b, 0x00, 0x80, 0x40, 0x40, 0x02, 0x00, 0x08, 0x00, 0x20, 0xa2, 0x05,
+ 0x8a, 0xb4, 0x6e, 0x45, 0x12, 0x04, 0x08, 0x00, 0x00, 0x00, 0x10, 0x02,
+ 0xa8, 0x92, 0x00, 0xda, 0x5f, 0x10, 0x00, 0x10, 0xa1, 0x04, 0x20, 0x41,
+ 0x02, 0x00, 0x5a, 0x25, 0xa0, 0xff, 0xfb, 0x05, 0x41, 0x02, 0x04, 0x00,
+ 0x00, 0x08, 0x40, 0x80, 0xec, 0x9b, 0xec, 0xfe, 0x7f, 0x01, 0x04, 0x20,
+ 0x90, 0x02, 0x04, 0x00, 0x08, 0x20, 0xfb, 0x2e, 0xf5, 0xff, 0xff, 0x57,
+ 0x00, 0x04, 0x02, 0x00, 0x00, 0x20, 0x01, 0xc1, 0x6e, 0xab, 0xfa, 0xff,
+ 0xff, 0x05, 0x90, 0x20, 0x48, 0x02, 0x00, 0x04, 0x20, 0xa8, 0xdf, 0xb5,
+ 0xfe, 0xff, 0xff, 0x0b, 0x01, 0x00, 0x01, 0x00, 0x80, 0x80, 0x04, 0xe0,
+ 0xbb, 0xef, 0xff, 0xff, 0x7f, 0x01, 0x00, 0x04, 0x48, 0x02, 0x00, 0x20,
+ 0x80, 0xf4, 0x6f, 0xfb, 0xff, 0xff, 0xff, 0x20, 0x90, 0x40, 0x02, 0x00,
+ 0x00, 0x04, 0x08, 0xb8, 0xf6, 0xff, 0xff, 0xdf, 0xbe, 0x12, 0x45, 0x10,
+ 0x90, 0x04, 0x90, 0x00, 0x22, 0xfa, 0xff, 0xff, 0xff, 0xbb, 0xd7, 0xe9,
+ 0x3a, 0x02, 0x02, 0x00, 0x04, 0x90, 0x80, 0xfe, 0xdf, 0xf6, 0xb7, 0xef,
+ 0xbe, 0x56, 0x57, 0x40, 0x48, 0x09, 0x00, 0x04, 0x00, 0xfa, 0xf5, 0xdf,
+ 0xed, 0x5a, 0xd5, 0xea, 0xbd, 0x09, 0x00, 0x00, 0x40, 0x00, 0x92, 0xfe,
+ 0xbf, 0x7d, 0xb7, 0x6a, 0x55, 0xbf, 0xf7, 0x02, 0x11, 0x01, 0x00, 0x91,
+ 0x00, 0xff, 0xff, 0xaf, 0x55, 0x55, 0x5b, 0xeb, 0xef, 0x22, 0x04, 0x04,
+ 0x04, 0x00, 0xa4, 0xff, 0xf7, 0xad, 0xaa, 0xaa, 0xaa, 0xbe, 0xfe, 0x03,
+ 0x20, 0x00, 0x10, 0x44, 0x80, 0xff, 0x7f, 0x55, 0x12, 0x91, 0x2a, 0xeb,
+ 0xbf, 0x0b, 0x82, 0x02, 0x00, 0x00, 0xd1, 0x7f, 0xdf, 0xa2, 0xa4, 0x54,
+ 0x55, 0xfd, 0xfd, 0x47, 0x08, 0x08, 0x00, 0x21, 0xe4, 0xff, 0x37, 0x11,
+ 0x09, 0xa5, 0xaa, 0xb6, 0xff, 0x0d, 0x80, 0x00, 0x00, 0x04, 0xd0, 0xff,
+ 0x4f, 0x44, 0x20, 0x48, 0x55, 0xfb, 0xff, 0x27, 0x11, 0x02, 0x40, 0x40,
+ 0xe2, 0xfb, 0x15, 0x11, 0x4a, 0x55, 0x4a, 0x7d, 0xf7, 0x0f, 0x00, 0x00,
+ 0x04, 0x08, 0xf8, 0xdf, 0x52, 0x44, 0x01, 0x52, 0xb5, 0xfa, 0xff, 0x0f,
+ 0x49, 0x02, 0x00, 0x02, 0xe9, 0xf6, 0x0a, 0x11, 0xa4, 0x88, 0x4a, 0x6d,
+ 0xff, 0x5f, 0x00, 0x00, 0x10, 0x20, 0xf0, 0x2f, 0x21, 0x44, 0x10, 0x52,
+ 0xb5, 0xfa, 0xff, 0x0f, 0x44, 0x04, 0x80, 0x08, 0xf8, 0xab, 0x8a, 0x00,
+ 0x81, 0xa4, 0xd4, 0xd6, 0xfe, 0x2f, 0x00, 0x00, 0x04, 0x40, 0xb5, 0x2d,
+ 0x21, 0x08, 0x04, 0x90, 0xaa, 0xfa, 0xff, 0x1f, 0x11, 0x01, 0x00, 0x04,
+ 0xf0, 0x57, 0x0a, 0x22, 0x40, 0x4a, 0xda, 0x5e, 0xfb, 0x1f, 0x40, 0x00,
+ 0x40, 0x20, 0xba, 0x95, 0x90, 0x00, 0x01, 0xa0, 0xaa, 0xea, 0xff, 0x5f,
+ 0x02, 0x02, 0x00, 0x01, 0xe8, 0x57, 0x05, 0x00, 0x00, 0x12, 0xd5, 0xfe,
+ 0xfd, 0x1f, 0x48, 0x00, 0x04, 0x48, 0x7a, 0x95, 0x08, 0x02, 0x10, 0x40,
+ 0xaa, 0x55, 0xf7, 0x1f, 0x00, 0x09, 0x20, 0x00, 0xf8, 0x57, 0x22, 0x10,
+ 0x00, 0x28, 0xa9, 0xfa, 0xff, 0x5f, 0x02, 0x00, 0x00, 0x49, 0xdd, 0x29,
+ 0x01, 0x00, 0x80, 0x80, 0xaa, 0xd7, 0xff, 0x0f, 0x10, 0x00, 0x08, 0x00,
+ 0xf8, 0x96, 0x08, 0x00, 0x00, 0x20, 0x54, 0xfa, 0xee, 0x3f, 0x81, 0x04,
+ 0x40, 0x24, 0xfe, 0x55, 0x82, 0x00, 0x00, 0x82, 0xd2, 0xad, 0xff, 0x0f,
+ 0x08, 0x00, 0x04, 0x80, 0x6c, 0x97, 0x00, 0x00, 0x02, 0x20, 0xa9, 0xf6,
+ 0xdf, 0x5f, 0x00, 0x02, 0x20, 0x09, 0xfa, 0x49, 0x12, 0x00, 0x20, 0x84,
+ 0x54, 0xdb, 0xfe, 0x1f, 0x91, 0x00, 0x00, 0x00, 0xf8, 0x2b, 0x00, 0x20,
+ 0x00, 0x40, 0xa4, 0xf6, 0xbb, 0x1f, 0x04, 0x00, 0x44, 0x92, 0x7e, 0x95,
+ 0x02, 0x00, 0x00, 0x89, 0xaa, 0xdd, 0xff, 0x1f, 0x20, 0x09, 0x10, 0x00,
+ 0xf4, 0x57, 0x20, 0x01, 0x08, 0x20, 0xa9, 0x76, 0xff, 0x5f, 0x02, 0x00,
+ 0x00, 0x21, 0xfc, 0x4a, 0x05, 0x00, 0x01, 0x80, 0x54, 0xdb, 0xff, 0x1e,
+ 0x08, 0x02, 0x04, 0x08, 0xf9, 0x2b, 0x00, 0x00, 0x40, 0x28, 0xd2, 0xf6,
+ 0xff, 0xbf, 0x80, 0x00, 0x90, 0x00, 0xbc, 0x92, 0x08, 0x10, 0x00, 0x82,
+ 0x54, 0xdb, 0xff, 0x1f, 0x20, 0x00, 0x00, 0x44, 0xf9, 0x55, 0x02, 0x01,
+ 0x00, 0x20, 0xaa, 0xbd, 0xfd, 0x3f, 0x08, 0x04, 0x04, 0x10, 0xf4, 0x2a,
+ 0x01, 0x00, 0x22, 0x80, 0xd4, 0xf6, 0xff, 0x5f, 0x82, 0x00, 0x40, 0x02,
+ 0xf8, 0x55, 0x20, 0x00, 0x00, 0x50, 0x6a, 0xdf, 0xfe, 0x3f, 0x00, 0x00,
+ 0x00, 0x48, 0xe9, 0x4a, 0x05, 0x08, 0x00, 0xa5, 0xd5, 0xf5, 0xff, 0x3f,
+ 0x10, 0x01, 0x10, 0x01, 0xb0, 0xab, 0x92, 0x02, 0x40, 0xf8, 0xbf, 0xde,
+ 0xfe, 0x5f, 0x02, 0x04, 0x04, 0x48, 0xfa, 0xd4, 0x6f, 0x20, 0x84, 0xef,
+ 0xff, 0xfb, 0xff, 0x1f, 0x20, 0x00, 0x00, 0x00, 0xe0, 0xed, 0xbf, 0x0b,
+ 0xa1, 0x7e, 0xff, 0xbf, 0xfd, 0x5f, 0x04, 0x01, 0x20, 0x49, 0xd2, 0xfb,
+ 0xfe, 0x55, 0xd4, 0xff, 0xff, 0xf6, 0xff, 0x07, 0x00, 0x04, 0x00, 0x00,
+ 0xc0, 0xaa, 0xfb, 0x2b, 0xa2, 0xfe, 0xff, 0xdf, 0xee, 0x1f, 0x91, 0x00,
+ 0x82, 0xa4, 0xa4, 0xf5, 0xff, 0x57, 0xd5, 0xff, 0xbf, 0xfd, 0xff, 0x4d,
+ 0x00, 0x00, 0x20, 0x00, 0x88, 0x5b, 0xff, 0x2f, 0x69, 0xff, 0xff, 0xdb,
+ 0xfe, 0x1f, 0x24, 0x02, 0x00, 0x49, 0xa2, 0xd6, 0xff, 0x5f, 0xea, 0xff,
+ 0x7f, 0x7f, 0x7f, 0x0d, 0x00, 0x00, 0x10, 0x00, 0x40, 0xab, 0xf7, 0xbb,
+ 0xf0, 0xdf, 0xff, 0xd5, 0xff, 0xbf, 0x82, 0x04, 0x42, 0x24, 0x91, 0xd5,
+ 0xaa, 0xae, 0xd4, 0xaa, 0x52, 0x7b, 0xff, 0x15, 0x08, 0x00, 0x00, 0x01,
+ 0x04, 0x55, 0xd5, 0x55, 0x70, 0x5b, 0x75, 0xdd, 0xdf, 0x1f, 0x40, 0x00,
+ 0x08, 0x48, 0xa0, 0x4a, 0xa9, 0x56, 0xea, 0x56, 0xad, 0x6a, 0x7d, 0x9b,
+ 0x04, 0x01, 0x00, 0x02, 0x42, 0x2a, 0xd5, 0xaa, 0xa8, 0xaa, 0xaa, 0xfa,
+ 0xdf, 0x2f, 0x10, 0x04, 0x22, 0x48, 0x08, 0x45, 0x2a, 0x15, 0x68, 0x55,
+ 0x55, 0xd7, 0x76, 0x1b, 0x00, 0x00, 0x00, 0x01, 0x40, 0x2a, 0x80, 0xa0,
+ 0xb2, 0x09, 0x48, 0xb9, 0xdf, 0x17, 0x22, 0x01, 0x00, 0x24, 0x45, 0x8a,
+ 0x24, 0x4a, 0x54, 0x51, 0x91, 0xf6, 0x6e, 0x4b, 0x00, 0x04, 0x90, 0x00,
+ 0x80, 0x52, 0x00, 0x20, 0x69, 0x05, 0xa4, 0xaa, 0xff, 0x1e, 0x48, 0x00,
+ 0x02, 0x92, 0x08, 0x05, 0x81, 0x94, 0xd4, 0x92, 0x40, 0xfd, 0xb6, 0x8b,
+ 0x00, 0x01, 0x40, 0x00, 0x82, 0x54, 0x00, 0x48, 0x68, 0x05, 0x90, 0xa4,
+ 0xef, 0x06, 0x24, 0x00, 0x08, 0x12, 0x10, 0x05, 0x00, 0x10, 0xb5, 0x01,
+ 0x42, 0xfb, 0xbf, 0x43, 0x00, 0x09, 0x00, 0x40, 0x81, 0xa8, 0x08, 0x4a,
+ 0xaa, 0x96, 0x90, 0xac, 0x6d, 0x15, 0x22, 0x00, 0x20, 0x09, 0x04, 0x15,
+ 0x80, 0x28, 0xdc, 0x01, 0x24, 0xfb, 0xbf, 0x01, 0x80, 0x04, 0x09, 0x00,
+ 0x40, 0x48, 0x02, 0x45, 0xb2, 0x2e, 0x41, 0x6d, 0xef, 0x05, 0x11, 0x00,
+ 0x40, 0x52, 0x02, 0x15, 0x29, 0x2a, 0xac, 0x42, 0x54, 0xfb, 0x3b, 0x51,
+ 0x84, 0x00, 0x08, 0x00, 0x20, 0x54, 0x80, 0x05, 0xb5, 0x3d, 0xa2, 0xb6,
+ 0xdf, 0x00, 0x20, 0x04, 0x20, 0x49, 0x89, 0xa8, 0x6a, 0x29, 0xac, 0xd6,
+ 0x54, 0xff, 0x3f, 0x84, 0x00, 0x01, 0x04, 0x10, 0x00, 0x94, 0xa8, 0x56,
+ 0xda, 0x5f, 0xab, 0xd5, 0x1e, 0x10, 0x48, 0x00, 0x90, 0x82, 0x48, 0xa8,
+ 0xb2, 0xac, 0xfd, 0x55, 0xd5, 0xfe, 0x9f, 0x80, 0x00, 0x0a, 0x02, 0x08,
+ 0x02, 0x55, 0x5a, 0x75, 0xff, 0xaf, 0xb6, 0xf7, 0x2d, 0x12, 0x92, 0x00,
+ 0x10, 0x20, 0x10, 0xa8, 0x54, 0xd5, 0xbf, 0x5d, 0xad, 0xdd, 0x0f, 0x00,
+ 0x00, 0x04, 0x40, 0x09, 0x84, 0xa8, 0xaa, 0x5a, 0xed, 0xeb, 0x6a, 0xff,
+ 0x9f, 0xa4, 0x24, 0x01, 0x02, 0xa0, 0x20, 0x50, 0x55, 0xd5, 0xbe, 0xae,
+ 0xad, 0xfd, 0x16, 0x00, 0x10, 0x04, 0x20, 0x0a, 0x08, 0xb4, 0xaa, 0x95,
+ 0xaa, 0x7b, 0xb7, 0xdb, 0x5f, 0x92, 0x04, 0x01, 0x84, 0x20, 0x21, 0x51,
+ 0xd5, 0x2a, 0xa9, 0xee, 0xd5, 0xfe, 0x0d, 0x00, 0x20, 0x04, 0x10, 0x00,
+ 0x08, 0x50, 0xe9, 0xd7, 0xd4, 0xfb, 0xb5, 0xff, 0x9f, 0x24, 0x09, 0x01,
+ 0x42, 0x4a, 0xa2, 0x64, 0xd5, 0x55, 0x7b, 0x7f, 0xda, 0x7d, 0x4f, 0x00,
+ 0x20, 0x04, 0x00, 0x80, 0x00, 0xa0, 0x2a, 0x13, 0x84, 0x6a, 0x55, 0xff,
+ 0x1d, 0x48, 0x8a, 0x00, 0x94, 0x24, 0x8a, 0xc8, 0xaa, 0x42, 0x20, 0x5d,
+ 0xf5, 0xff, 0x5f, 0x01, 0x00, 0x02, 0x01, 0x00, 0x20, 0xa2, 0x4a, 0x1a,
+ 0x82, 0x56, 0xda, 0xbd, 0x3f, 0x92, 0x92, 0x00, 0x90, 0x92, 0x00, 0x40,
+ 0x95, 0x6a, 0xf4, 0x55, 0x6d, 0xff, 0xd6, 0x00, 0x00, 0x0a, 0x04, 0x20,
+ 0x14, 0x49, 0x4b, 0xaa, 0xaa, 0x56, 0xf5, 0xff, 0xbf, 0xab, 0xa4, 0x00,
+ 0x20, 0x89, 0x40, 0x80, 0xaa, 0xaa, 0xaa, 0xaa, 0xde, 0xbf, 0xeb, 0x03,
+ 0x00, 0x02, 0x04, 0x02, 0x0a, 0x10, 0x2b, 0x2a, 0x55, 0x5b, 0xf5, 0xff,
+ 0xd7, 0x2f, 0x92, 0x00, 0x10, 0x28, 0x21, 0x01, 0x56, 0x95, 0xa0, 0x56,
+ 0xdf, 0xef, 0xea, 0x87, 0x40, 0x0a, 0x42, 0x41, 0x00, 0x90, 0xaa, 0x52,
+ 0xb6, 0xad, 0xfa, 0xff, 0xd5, 0x2f, 0x14, 0x00, 0x00, 0x04, 0x95, 0x04,
+ 0xaa, 0xac, 0x55, 0x6b, 0xff, 0xb7, 0xea, 0x9f, 0x40, 0x02, 0x28, 0x51,
+ 0x00, 0x40, 0x58, 0xd5, 0xda, 0xd6, 0x6e, 0x7f, 0xf9, 0x3f, 0x12, 0x04,
+ 0x02, 0x04, 0x49, 0x25, 0x55, 0xaa, 0x77, 0xab, 0xff, 0x2b, 0xfd, 0x3f,
+ 0x48, 0x01, 0x20, 0x41, 0x00, 0x00, 0x58, 0xa9, 0xda, 0xea, 0xfd, 0xaf,
+ 0xfa, 0xff, 0x02, 0x04, 0x08, 0x14, 0x29, 0x49, 0x52, 0x55, 0x55, 0x55,
+ 0xff, 0x8d, 0xfe, 0x3f, 0xa8, 0x00, 0x02, 0x41, 0x00, 0x02, 0xa0, 0xa2,
+ 0xaa, 0xea, 0xff, 0x53, 0xfd, 0xff, 0x02, 0x04, 0x50, 0x04, 0x25, 0xa8,
+ 0x54, 0x49, 0x52, 0xb5, 0xbf, 0x8a, 0xfe, 0xff, 0xa9, 0x08, 0x04, 0x50,
+ 0x80, 0x02, 0xa1, 0x2a, 0x95, 0xea, 0xff, 0xa1, 0xff, 0xff, 0x03, 0x02,
+ 0x90, 0x02, 0x09, 0x08, 0x44, 0x49, 0x52, 0xbd, 0x7f, 0xca, 0xff, 0xff,
+ 0x2b, 0x09, 0x04, 0x48, 0x40, 0x82, 0x90, 0x56, 0xa9, 0xf6, 0xbf, 0xd0,
+ 0xff, 0xff, 0x47, 0x00, 0x50, 0x02, 0x15, 0x11, 0x40, 0x95, 0xaa, 0xfd,
+ 0x2f, 0xe9, 0xff, 0xff, 0x8f, 0x0a, 0x84, 0x50, 0x40, 0x84, 0x14, 0xaa,
+ 0x6a, 0xff, 0x5f, 0xf2, 0xff, 0xff, 0x7f, 0x00, 0x10, 0x02, 0x09, 0x10,
+ 0x40, 0x7d, 0xf7, 0xff, 0x0b, 0xfc, 0xff, 0xff, 0xaf, 0x02, 0x84, 0x50,
+ 0x42, 0x85, 0x12, 0xd0, 0xdd, 0xff, 0xa7, 0xf2, 0xff, 0xff, 0xff, 0x04,
+ 0x00, 0x0a, 0x08, 0x10, 0x48, 0xf8, 0xff, 0xff, 0x0a, 0xfe, 0xff, 0xff,
+ 0x7f, 0x03, 0xa4, 0x80, 0xa2, 0x8a, 0x02, 0x68, 0xff, 0xff, 0x52, 0xfd,
+ 0xff, 0xff, 0xff, 0x07, 0x00, 0x2a, 0x08, 0x20, 0x28, 0xdc, 0xff, 0x5f,
+ 0x05, 0xff, 0xff, 0xff, 0xff, 0x0d, 0x92, 0x40, 0x22, 0x09, 0x02, 0xea,
+ 0xfb, 0xaf, 0x48, 0xff, 0xff, 0xff, 0xff, 0x0f, 0x00, 0x12, 0x81, 0xa0,
+ 0x48, 0x9c, 0x6e, 0x93, 0xa2, 0xff, 0xff, 0xff, 0xff, 0x07, 0xa8, 0x40,
+ 0x28, 0x0a, 0x02, 0x74, 0xb5, 0x45, 0x81, 0xff, 0xff, 0xff, 0xff, 0x0f,
+ 0x02, 0x0a, 0x81, 0x20, 0x08, 0xae, 0xaa, 0x90, 0xe8, 0xff, 0xff, 0xff,
+ 0xff, 0x0f, 0x90, 0x40, 0x28, 0x88, 0x12, 0x58, 0x15, 0x50, 0xd0, 0xff,
+ 0xff, 0xff, 0xff, 0x0f, 0x44, 0x0a, 0x41, 0x21, 0x08, 0xae, 0x04, 0x14,
+ 0xf0, 0xff, 0xff, 0xff, 0xff, 0x0f, 0x10, 0x40, 0x14, 0x88, 0x04, 0xba,
+ 0x02, 0x28, 0xe8, 0xff, 0xff, 0xff, 0xff, 0x0f, 0x42, 0x15, 0x41, 0x21,
+ 0x05, 0xad, 0x00, 0x05, 0xf8, 0xff, 0xff, 0xff, 0xff, 0x0f, 0x10, 0x40,
+ 0x24, 0x8a, 0x0e, 0x36, 0x00, 0x0a, 0xf4, 0xff, 0xff, 0xff, 0xff, 0x0f,
+ 0x42, 0x25, 0x90, 0xd0, 0x8b, 0xc2, 0x41, 0x05, 0xfc, 0xff, 0xff, 0xff,
+ 0xff, 0x0f, 0x10, 0x08, 0x05, 0xe8, 0x8e, 0x58, 0x80, 0x02, 0xfa, 0xff,
+ 0xff, 0xff, 0xff, 0x0f, 0x4a, 0x20, 0xa8, 0xba, 0x0b, 0x2b, 0x51, 0x01,
+ 0xfe, 0xff, 0xff, 0xff, 0xff, 0x0f, 0x00, 0x8a, 0x02, 0xe8, 0xaf, 0x84,
+ 0x90, 0x04, 0xfd, 0xff, 0xff, 0xff, 0xff, 0x0f, 0x52, 0x21, 0x54, 0xbf,
+ 0x1f, 0x15, 0xa5, 0x02, 0xfe, 0xff, 0xff, 0xff, 0xff, 0x0f, 0x00, 0x08,
+ 0x01, 0xfa, 0xb6, 0xa4, 0x52, 0x40, 0xff, 0xff, 0xff, 0xff, 0xff, 0x0f,
+ 0x4a, 0xa2, 0x54, 0xef, 0x5f, 0x4b, 0xa4, 0x80, 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0x0f, 0x80, 0x10, 0x82, 0xfe, 0xbf, 0x92, 0x52, 0x42, 0xff, 0xff,
+ 0xff, 0xff, 0xff, 0x0f, 0x12, 0x42, 0xa8, 0xbf, 0x1f, 0x24, 0x80, 0xa0,
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0x0f, 0x84, 0x28, 0x8a, 0xf7, 0x37, 0x80,
+ 0x52, 0x80, 0xff, 0xff, 0xff, 0xff, 0xff, 0x0f, 0x10, 0x82, 0xe0, 0xff,
+ 0x1f, 0x00, 0x20, 0xe1, 0xff, 0xff, 0xff, 0xff, 0xff, 0x0f, 0x84, 0x28,
+ 0xca, 0xff, 0x1f, 0x00, 0x00, 0xc0, 0xff, 0xff, 0xff, 0xff, 0xff, 0x0f,
+ 0x10, 0x42, 0xf0, 0xfd, 0x1b, 0x00, 0x50, 0xf0, 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0x0f, 0xa4, 0x10, 0xc5, 0xff, 0x1f, 0x00, 0x00, 0xe0, 0xff, 0xff,
+ 0xff, 0xff, 0xff, 0x0f, 0x00, 0x22, 0xf8, 0xff, 0x0e, 0x00, 0x00, 0xf0,
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0x0f, 0xaa, 0x88, 0xe2, 0xff, 0x0f, 0x10,
+ 0x00, 0xf0, 0xff, 0xff, 0xff, 0xff, 0xff, 0x0f, 0x00, 0x25, 0xfa, 0xff,
+ 0x0f, 0x01, 0x11, 0xfd, 0xff, 0xff, 0xff, 0xff, 0xff, 0x0f, 0xff, 0xfb,
+ 0xfb, 0xff, 0x7f, 0x5d, 0xd5, 0xfa, 0xff, 0xff, 0xff, 0xff, 0xff, 0x0f};
diff --git a/jni/ruby/ext/tk/sample/images/flagdown.xbm b/jni/ruby/ext/tk/sample/images/flagdown.xbm
new file mode 100644
index 0000000..55abc51
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/images/flagdown.xbm
@@ -0,0 +1,27 @@
+#define flagdown_width 48
+#define flagdown_height 48
+static char flagdown_bits[] = {
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x00,
+ 0x00, 0x00, 0x80, 0x7f, 0x00, 0x00, 0x00, 0x00, 0xe0, 0xe1, 0x00, 0x00,
+ 0x00, 0x00, 0x70, 0x80, 0x01, 0x00, 0x00, 0x00, 0x18, 0x00, 0x03, 0x00,
+ 0x00, 0x00, 0x0c, 0x00, 0x03, 0x00, 0x00, 0x00, 0x06, 0x00, 0x06, 0x04,
+ 0x00, 0x00, 0x03, 0x00, 0x06, 0x06, 0x00, 0x80, 0x01, 0x00, 0x06, 0x07,
+ 0x00, 0xc0, 0x1f, 0x00, 0x87, 0x07, 0x00, 0xe0, 0x7f, 0x80, 0xc7, 0x07,
+ 0x00, 0x70, 0xe0, 0xc0, 0xe5, 0x07, 0x00, 0x38, 0x80, 0xe1, 0x74, 0x07,
+ 0x00, 0x18, 0x80, 0x71, 0x3c, 0x07, 0x00, 0x0c, 0x00, 0x3b, 0x1e, 0x03,
+ 0x00, 0x0c, 0x00, 0x1f, 0x0f, 0x00, 0x00, 0x86, 0x1f, 0x8e, 0x07, 0x00,
+ 0x00, 0x06, 0x06, 0xc6, 0x05, 0x00, 0x00, 0x06, 0x00, 0xc6, 0x05, 0x00,
+ 0x00, 0x06, 0x00, 0xc6, 0x04, 0x00, 0x00, 0x06, 0x00, 0x06, 0x04, 0x00,
+ 0x7f, 0x06, 0x00, 0x06, 0xe4, 0xff, 0x00, 0x06, 0x00, 0x06, 0x04, 0x00,
+ 0x00, 0x06, 0x00, 0x06, 0x04, 0x00, 0x00, 0x06, 0x00, 0x06, 0x06, 0x00,
+ 0x00, 0x06, 0x00, 0x06, 0x03, 0x00, 0x00, 0x06, 0x00, 0x86, 0x01, 0x00,
+ 0x00, 0x06, 0x00, 0xc6, 0x00, 0x00, 0x00, 0x06, 0x00, 0x66, 0x00, 0x00,
+ 0x00, 0x06, 0x00, 0x36, 0x00, 0x00, 0x00, 0x06, 0x00, 0x3e, 0x00, 0x00,
+ 0x00, 0xfe, 0xff, 0x2f, 0x00, 0x00, 0x00, 0xfc, 0xff, 0x27, 0x00, 0x00,
+ 0x00, 0x00, 0x88, 0x20, 0x00, 0x00, 0x00, 0x00, 0x88, 0x20, 0x00, 0x00,
+ 0x00, 0x00, 0x88, 0x20, 0x00, 0x00, 0x00, 0x00, 0x88, 0x20, 0x00, 0x00,
+ 0x00, 0x00, 0x88, 0x20, 0x00, 0x00, 0x00, 0x00, 0x88, 0x20, 0x00, 0x00,
+ 0x00, 0x00, 0x88, 0x20, 0x00, 0x00, 0x00, 0x00, 0x88, 0x20, 0x00, 0x00,
+ 0xf7, 0xbf, 0x8e, 0xfc, 0xdf, 0xf8, 0x9d, 0xeb, 0x9b, 0x76, 0xd2, 0x7a,
+ 0x46, 0x30, 0xe2, 0x0f, 0xe1, 0x47, 0x55, 0x84, 0x48, 0x11, 0x84, 0x19};
diff --git a/jni/ruby/ext/tk/sample/images/flagup.xbm b/jni/ruby/ext/tk/sample/images/flagup.xbm
new file mode 100644
index 0000000..6eb0d84
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/images/flagup.xbm
@@ -0,0 +1,27 @@
+#define flagup_width 48
+#define flagup_height 48
+static char flagup_bits[] = {
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe0, 0x7f, 0x00,
+ 0x00, 0x00, 0x00, 0xe0, 0x7f, 0x00, 0x00, 0x00, 0x00, 0xef, 0x6a, 0x00,
+ 0x00, 0x00, 0xc0, 0x7b, 0x75, 0x00, 0x00, 0x00, 0xe0, 0xe0, 0x6a, 0x00,
+ 0x00, 0x00, 0x30, 0x60, 0x75, 0x00, 0x00, 0x00, 0x18, 0xe0, 0x7f, 0x00,
+ 0x00, 0x00, 0x0c, 0xe0, 0x7f, 0x00, 0x00, 0x00, 0x06, 0xe0, 0x04, 0x00,
+ 0x00, 0x00, 0x03, 0xe0, 0x04, 0x00, 0x00, 0x80, 0x01, 0xe0, 0x06, 0x00,
+ 0x00, 0xc0, 0x1f, 0xe0, 0x07, 0x00, 0x00, 0xe0, 0x7f, 0xe0, 0x07, 0x00,
+ 0x00, 0x70, 0xe0, 0xe0, 0x05, 0x00, 0x00, 0x38, 0x80, 0xe1, 0x04, 0x00,
+ 0x00, 0x18, 0x80, 0xf1, 0x04, 0x00, 0x00, 0x0c, 0x00, 0xfb, 0x04, 0x00,
+ 0x00, 0x0c, 0x00, 0xff, 0x04, 0x00, 0x00, 0x86, 0x1f, 0xee, 0x04, 0x00,
+ 0x00, 0x06, 0x06, 0xe6, 0x04, 0x00, 0x00, 0x06, 0x00, 0xe6, 0x04, 0x00,
+ 0x00, 0x06, 0x00, 0xe6, 0x04, 0x00, 0x00, 0x06, 0x00, 0x66, 0x04, 0x00,
+ 0x7f, 0x56, 0x52, 0x06, 0xe4, 0xff, 0x00, 0x76, 0x55, 0x06, 0x04, 0x00,
+ 0x00, 0x56, 0x57, 0x06, 0x04, 0x00, 0x00, 0x56, 0x55, 0x06, 0x06, 0x00,
+ 0x00, 0x56, 0xd5, 0x06, 0x03, 0x00, 0x00, 0x06, 0x00, 0x86, 0x01, 0x00,
+ 0x54, 0x06, 0x00, 0xc6, 0x54, 0x55, 0xaa, 0x06, 0x00, 0x66, 0xaa, 0x2a,
+ 0x54, 0x06, 0x00, 0x36, 0x55, 0x55, 0xaa, 0x06, 0x00, 0xbe, 0xaa, 0x2a,
+ 0x54, 0xfe, 0xff, 0x6f, 0x55, 0x55, 0xaa, 0xfc, 0xff, 0xa7, 0xaa, 0x2a,
+ 0x54, 0x01, 0x88, 0x60, 0x55, 0x55, 0xaa, 0xaa, 0x8a, 0xa0, 0xaa, 0x2a,
+ 0x54, 0x55, 0x8d, 0x60, 0x55, 0x55, 0xaa, 0xaa, 0x8a, 0xa0, 0xaa, 0x2a,
+ 0x54, 0x55, 0x8d, 0x60, 0x55, 0x55, 0xaa, 0xaa, 0x8a, 0xa0, 0xaa, 0x2a,
+ 0x54, 0x55, 0x8d, 0x50, 0x55, 0x55, 0xaa, 0xaa, 0x8a, 0xa8, 0xaa, 0x2a,
+ 0x54, 0x55, 0x95, 0x54, 0x55, 0x55, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0x2a,
+ 0x54, 0x55, 0x55, 0x55, 0x55, 0x15, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
diff --git a/jni/ruby/ext/tk/sample/images/gray25.xbm b/jni/ruby/ext/tk/sample/images/gray25.xbm
new file mode 100644
index 0000000..b234b3c
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/images/gray25.xbm
@@ -0,0 +1,6 @@
+#define grey_width 16
+#define grey_height 16
+static char grey_bits[] = {
+ 0x11, 0x11, 0x44, 0x44, 0x11, 0x11, 0x44, 0x44, 0x11, 0x11, 0x44, 0x44,
+ 0x11, 0x11, 0x44, 0x44, 0x11, 0x11, 0x44, 0x44, 0x11, 0x11, 0x44, 0x44,
+ 0x11, 0x11, 0x44, 0x44, 0x11, 0x11, 0x44, 0x44};
diff --git a/jni/ruby/ext/tk/sample/images/grey.25 b/jni/ruby/ext/tk/sample/images/grey.25
new file mode 100644
index 0000000..b234b3c
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/images/grey.25
@@ -0,0 +1,6 @@
+#define grey_width 16
+#define grey_height 16
+static char grey_bits[] = {
+ 0x11, 0x11, 0x44, 0x44, 0x11, 0x11, 0x44, 0x44, 0x11, 0x11, 0x44, 0x44,
+ 0x11, 0x11, 0x44, 0x44, 0x11, 0x11, 0x44, 0x44, 0x11, 0x11, 0x44, 0x44,
+ 0x11, 0x11, 0x44, 0x44, 0x11, 0x11, 0x44, 0x44};
diff --git a/jni/ruby/ext/tk/sample/images/grey.5 b/jni/ruby/ext/tk/sample/images/grey.5
new file mode 100644
index 0000000..3768889
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/images/grey.5
@@ -0,0 +1,6 @@
+#define grey_width 16
+#define grey_height 16
+static char grey_bits[] = {
+ 0x55, 0x55, 0xaa, 0xaa, 0x55, 0x55, 0xaa, 0xaa, 0x55, 0x55, 0xaa, 0xaa,
+ 0x55, 0x55, 0xaa, 0xaa, 0x55, 0x55, 0xaa, 0xaa, 0x55, 0x55, 0xaa, 0xaa,
+ 0x55, 0x55, 0xaa, 0xaa, 0x55, 0x55, 0xaa, 0xaa};
diff --git a/jni/ruby/ext/tk/sample/images/letters.xbm b/jni/ruby/ext/tk/sample/images/letters.xbm
new file mode 100644
index 0000000..0f12568
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/images/letters.xbm
@@ -0,0 +1,27 @@
+#define letters_width 48
+#define letters_height 48
+static char letters_bits[] = {
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0xfe, 0xff, 0xff, 0xff, 0x3f, 0x00, 0x02, 0x00, 0x00, 0x00, 0x20,
+ 0x00, 0xfa, 0x00, 0x00, 0x00, 0x2e, 0x00, 0x02, 0x00, 0x00, 0x00, 0x2a,
+ 0x00, 0x3a, 0x00, 0x00, 0x00, 0x2a, 0x00, 0x02, 0x00, 0x00, 0x00, 0x2e,
+ 0xe0, 0xff, 0xff, 0xff, 0xff, 0x21, 0x20, 0x00, 0x00, 0x00, 0x00, 0x21,
+ 0xa0, 0x03, 0x00, 0x00, 0x70, 0x21, 0x20, 0x00, 0x00, 0x00, 0x50, 0x21,
+ 0xa0, 0x1f, 0x00, 0x00, 0x50, 0x21, 0x20, 0x00, 0x00, 0x00, 0x70, 0x21,
+ 0xfe, 0xff, 0xff, 0xff, 0x0f, 0x21, 0x02, 0x00, 0x00, 0x00, 0x08, 0x21,
+ 0xfa, 0x01, 0x00, 0x80, 0x0b, 0x21, 0x02, 0x00, 0x00, 0x80, 0x0a, 0x21,
+ 0xba, 0x01, 0x00, 0x80, 0x0a, 0x21, 0x02, 0x00, 0x00, 0x80, 0x0b, 0x21,
+ 0x3a, 0x00, 0x00, 0x00, 0x08, 0x21, 0x02, 0x00, 0x00, 0x00, 0x08, 0x21,
+ 0x02, 0xc0, 0xfb, 0x03, 0x08, 0x21, 0x02, 0x00, 0x00, 0x00, 0x08, 0x3f,
+ 0x02, 0xc0, 0xbd, 0x0f, 0x08, 0x01, 0x02, 0x00, 0x00, 0x00, 0x08, 0x01,
+ 0x02, 0xc0, 0x7f, 0x7b, 0x08, 0x01, 0x02, 0x00, 0x00, 0x00, 0x08, 0x01,
+ 0x02, 0x00, 0x00, 0x00, 0xf8, 0x01, 0x02, 0x00, 0x00, 0x00, 0x08, 0x00,
+ 0x02, 0x00, 0x00, 0x00, 0x08, 0x00, 0x02, 0x00, 0x00, 0x00, 0x08, 0x00,
+ 0x02, 0x00, 0x00, 0x00, 0x08, 0x00, 0x02, 0x00, 0x00, 0x00, 0x08, 0x00,
+ 0xfe, 0xff, 0xff, 0xff, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
diff --git a/jni/ruby/ext/tk/sample/images/noletter.xbm b/jni/ruby/ext/tk/sample/images/noletter.xbm
new file mode 100644
index 0000000..5774124
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/images/noletter.xbm
@@ -0,0 +1,27 @@
+#define noletters_width 48
+#define noletters_height 48
+static char noletters_bits[] = {
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf0, 0x1f, 0x00, 0x00,
+ 0x00, 0x00, 0xff, 0xff, 0x01, 0x00, 0x00, 0xc0, 0xff, 0xff, 0x07, 0x00,
+ 0x00, 0xf0, 0x0f, 0xe0, 0x1f, 0x00, 0x00, 0xfc, 0x01, 0x00, 0x7f, 0x00,
+ 0x00, 0x3e, 0x00, 0x00, 0xf8, 0x00, 0x00, 0x1f, 0x00, 0x00, 0xf0, 0x01,
+ 0x80, 0x07, 0x00, 0x00, 0xc0, 0x03, 0xc0, 0x03, 0x00, 0x00, 0xe0, 0x07,
+ 0xe0, 0x01, 0x00, 0x00, 0xf0, 0x0f, 0xe0, 0x00, 0x00, 0x00, 0x78, 0x0e,
+ 0xf0, 0x00, 0x00, 0x00, 0x3c, 0x1e, 0x70, 0x00, 0x00, 0x00, 0x1e, 0x1c,
+ 0x38, 0x00, 0x00, 0x00, 0x0f, 0x38, 0x38, 0x00, 0x00, 0x80, 0x07, 0x38,
+ 0x3c, 0xfc, 0xff, 0xff, 0x7f, 0x78, 0x1c, 0x04, 0x00, 0xe0, 0x41, 0x70,
+ 0x1c, 0x04, 0x00, 0xf0, 0x40, 0x70, 0x1c, 0x74, 0x00, 0x78, 0x4e, 0x70,
+ 0x0e, 0x04, 0x00, 0x3c, 0x4a, 0xe0, 0x0e, 0x74, 0x03, 0x1e, 0x4a, 0xe0,
+ 0x0e, 0x04, 0x00, 0x0f, 0x4e, 0xe0, 0x0e, 0x04, 0x80, 0x07, 0x40, 0xe0,
+ 0x0e, 0x04, 0xf8, 0x0f, 0x40, 0xe0, 0x0e, 0x04, 0xe0, 0x01, 0x40, 0xe0,
+ 0x0e, 0x04, 0xf8, 0x00, 0x40, 0xe0, 0x0e, 0x04, 0x78, 0x00, 0x40, 0xe0,
+ 0x0e, 0x04, 0xfc, 0xf3, 0x40, 0xe0, 0x1c, 0x04, 0x1e, 0x00, 0x40, 0x70,
+ 0x1c, 0x04, 0x0f, 0x00, 0x40, 0x70, 0x1c, 0x84, 0x07, 0x00, 0x40, 0x70,
+ 0x3c, 0xfc, 0xff, 0xff, 0x7f, 0x78, 0x38, 0xe0, 0x01, 0x00, 0x00, 0x38,
+ 0x38, 0xf0, 0x00, 0x00, 0x00, 0x38, 0x70, 0x78, 0x00, 0x00, 0x00, 0x1c,
+ 0xf0, 0x3c, 0x00, 0x00, 0x00, 0x1e, 0xe0, 0x1e, 0x00, 0x00, 0x00, 0x0e,
+ 0xe0, 0x0f, 0x00, 0x00, 0x00, 0x0f, 0xc0, 0x07, 0x00, 0x00, 0x80, 0x07,
+ 0x80, 0x07, 0x00, 0x00, 0xc0, 0x03, 0x00, 0x1f, 0x00, 0x00, 0xf0, 0x01,
+ 0x00, 0x3e, 0x00, 0x00, 0xf8, 0x00, 0x00, 0xfc, 0x01, 0x00, 0x7f, 0x00,
+ 0x00, 0xf0, 0x0f, 0xe0, 0x1f, 0x00, 0x00, 0xc0, 0xff, 0xff, 0x07, 0x00,
+ 0x00, 0x00, 0xff, 0xff, 0x01, 0x00, 0x00, 0x00, 0xf0, 0x1f, 0x00, 0x00};
diff --git a/jni/ruby/ext/tk/sample/images/pattern.xbm b/jni/ruby/ext/tk/sample/images/pattern.xbm
new file mode 100644
index 0000000..df31baf
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/images/pattern.xbm
@@ -0,0 +1,6 @@
+#define foo_width 16
+#define foo_height 16
+static char foo_bits[] = {
+ 0x60, 0x06, 0x90, 0x09, 0x90, 0x09, 0xb0, 0x0d, 0x4e, 0x72, 0x49, 0x92,
+ 0x71, 0x8e, 0x8e, 0x71, 0x8e, 0x71, 0x71, 0x8e, 0x49, 0x92, 0x4e, 0x72,
+ 0xb0, 0x0d, 0x90, 0x09, 0x90, 0x09, 0x60, 0x06};
diff --git a/jni/ruby/ext/tk/sample/images/tcllogo.gif b/jni/ruby/ext/tk/sample/images/tcllogo.gif
new file mode 100644
index 0000000..4603d4f
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/images/tcllogo.gif
Binary files differ
diff --git a/jni/ruby/ext/tk/sample/images/teapot.ppm b/jni/ruby/ext/tk/sample/images/teapot.ppm
new file mode 100644
index 0000000..b8ab85f
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/images/teapot.ppm
@@ -0,0 +1,31 @@
+P6
+256 256
+255
+\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À[7 eOLjQLmSMoTMnSMlRMhPL_9 \À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\ÀnSMtVMzYN~[N~[N\N\O€\O€]O€]O€]O€]O€\O€\O}[NyYNtVM\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\ÀG-wXN}[N€]O„^O†_O†`O‡`Oˆ`Oˆ`OˆaO‰aO‰aO‰aO‰aO‰aO‰aOˆaOˆ`O†_Oƒ^O\N \À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\ÀaMLyYN…_O‰aP‹bPcPŽcPŽdPŽdPdPdPdPdPdPdPdPeP‘eP’eP’eP‘ePdPcP…_OpUM\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\ÀwXN…_OdP“fP•gQ–hQ˜hQ˜iQ™iQ™iQšiQšiQšjQ›jQ›jQœjQœjQœjQœjQœjQ›jQœjQ™iQ“fP‡`O\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\ÀNCJiQL‹bP—hQkQ¡mR¤nR¥oR¥oR¥oR¥oR¥oR¥oR¦oR¦oR¦pR¨pS©qSªqS«rS¬rS«rS©qS¤oRœjQ€]O\KK\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\ÀfOLrUMcPŸlR©qS¯tS²uTµwT·xT¸xT¹yTºyT»zT»zU¼zU¼zU¼zU»zUºyT¸xT¶wT¯tS¡mR‰aOhPL\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\Àa0 cNLqUM€\O”fQ¦pS²wVºzV¿|VÂ}VÄVÆVÇ€VÉ‚WÌ…[Õeæ w÷³‹êª…Ĉg§qT“fQ{ZNYIK9\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\ÀO1{G#‘JkRMqUMtVN–iS¨v\·€d¹bµzZ±vU°uT®sSªqS¤nRœjQ’eP„^OrUMHh>!T4\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\ÀG-V5wE"~I#†M%U+¥e7²l:°g2®b*­a(­`(©^(¥])¡^-›]1ŠS,qC$`9 R3G-\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À@)J/i>!pA"tD"wF$yH&xH&tE$wE#yG%}M+ƒT4S5mE*Z7!K/B*;'\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À‰aO¦oR½{UÇ€VÏ…X<(F-a: e<!h>!j@#k@$h>"d<!c=$hD-fF2[<)K0@);'5$Ë‚VÇ€V¿|U_LKYIK\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À…_O·xTÉ‚Wó«€ûµ‹Ö’k¼|X×>µf-¨^(¡Z'šW&–T&œN>)F-J/b; g>#nD(jB&c<!b=%jH2_A/I0!<(8&5$”J¥Y’S%8&;'?)E,<:HA=HE?IJAISFJYIKXIK\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À£nRÁ}UܘqÊŠe±vU²e,™V&¥V†C €@ |> y< u: r9 o7 l6
+j5
+h4
+g3
+5$D,K/b; h>"wM1tK.e="a<#cA,U8&E-<(9&.!a0 b1 c1    
+
++3#@)46G<:HMCIXHK\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\ÀU*´vT¿~X¸{YÃk+›W&‰N$|> u: p8 k5
+f3
+a0 _/ ]. [- I¡\*ª_(‘LkRMmSMmSMnSMnSMD,R3W5mA"|O0|P1j?"c<!a=%Y7"N1F,;'NCJNCJNDJODJODJODJh>!a: X/K%
+g3
+a0 Z- \/ T*Q(ŠHµm8kRMmSMnTMoTMpTMpUM15G15G05G04G04GpUMpTM5^9 d<!yF#O+€N,rC#qB"pB#k?"a: Z7 6ODJPDJPEJQEJQEJREJREJREJRFJSFJSFJSFJSFJe<!X/
+^/ V+Q(L&I$r9  TlRMnSM46G47G47G46G46G46G46G46G36G36G25G25G15G04G/4F.3F
+
+X&pUMuWMwXNxXN<:H<:H<:H<:H<;H<;H<;H<;H=;H=;H=;H=;H>;H>;H?<H@<HA=HC>HG@ILBIREJ[JKcNLjQL§pR±uTºzUÃ~VÈWË‚XÖŽcäsÒŽe¼{V²vT¨pSžkR•gQŒbP†_O‚^O]O€\O€\O€\O€\O€]O]O]O]O]O]O]O]O]O]O]O€\O€\O~\N}[N|ZNxXN•T%H$
+›W&rVMvWNyYNzYN|ZN}[N}[N><H?<H?<H?<H?<H?<H@<H@<H@<HA=HA=HB=HC>HE?IG@IIAIKBIODJSFJWHK—hQŸlR§pR°b(¾i*Én+Ù|7Û|6Ïr,Íq+Êp-Ãl+»g)±b(®sS§pS lRšiQ•gQePcPŠaPˆaO‡`O‡`O†_O†_O…_O…_O…_O…_O…_O…_O…_O„_O„^O„^Oƒ^Oƒ^O‚]O]O€\O~[N{ZN•T%
+
+ 
+@%<-$G?@…pfdNLuWM\NdNL\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\ÀTFJvWN‰aP./01„E}[N]O…_Oˆ`O‰aP‹bPŒbPcPcPŽcPdPdPdPeP‘eP’eP’eP“fP“fQ”fQ•gQ•gQ–gQ–hQ—hQ˜hQ™iQšiQ›jQœjQkQkRžlRŸlRžY&¤\'¨^'µ^½bÀcÃeÇi ÄgÀc½b¼a¹`µ^´]¯X¢[' Z'žY&¢mR¡mR¡mR lRŸlRŸlRžkRkQœkQœjQ›jQšjQšiQ™iQ™iQ˜iQ˜hQ—hQ—hQ—hQ–gQ–gQ•gQ•gQ•gQ”fQ”fQ“fQ“fP’eP‘ePdPcP‰aP—O
+ B\À\À\À\À\À\À\À\À\À\À%7!!C*F#P) {dYœze»p€\OgPL\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\ÀSFJ`LKvWNŠaPm6
+ 
+$5 ¬`(¶e)£nRœjQƒ^OJAI\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\ÀXIK^KKdNLhPLuWM‚]OŒbP”fQeP m6
+†`OŽcP“fQ—hQ˜hQ™iQšiQšjQ›jQ›jQ›jQœjQœjQœjQœkQkQkQkRžkRžkRžkRžlRŸlRŸlRŸlR lR lR lR¡mR¡mR¡mR¡mRºg)³c(²c(±b(­V¿cÂeÅi!Åi!Àd¼bº`¹`·_·_¶^¢Q§]'ª_(­`(¹f)£nR£nR£nR£nR£nR£nR£nR¢nR¢nR¢nR¢nR¢nR¢nR¢mR¢mR¢mR¢mR¢mR¢mR¢mR¢mR¢mR¢nR¢mR¢mR£nR¢mR¢mR¡mR mRkR—hQˆGa0 ŠbP mRœjQ“fQ‰aP}[NrUMmSM…L$\À\À\À\À\À\À\À\À B B #C, 8&H.Z7 §pR›jQ{ZN\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\ÀQEJ[JK`LKdNLhQLqUM{ZN…_OŽcP–gQ—hQ
+‹bP‘eP–hQšiQ›jQœjQkQkQkRžkRžkRžlRžlRŸlRŸlRŸlRŸlRŸlR lR lR lR mR¡mR¡mR¡mR¡mR¡mR¢mR¢mR¢mR¢nR£nRÀj*ºg)·e)¶d)Âd°XÅgÅhÂe¿c½b½b¾bªU­`(®a(¯a(³c(¾i*¤oR¤oR¤nR¤nR¤nR¤nR¤nR¤nR¤nR¤nR¤nR¤nR¤nR¤nR¤nR¤nR¤nR¤oR¤oR¥oR¥oR¥oR¥oR¥oR¥oR¦oR¦oR¥oR¥oR¤nR¡mR›jQŽQ%Z- œjQ£nRŸlR—hQŽdP…_OuWMpTMnSMkRLa: \À\À\À\À\À\À\À B B&D2 @*S6#G@IPDJ˜hQmSM\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\ÀVGJ]KKbMLeOLiQLlRMvWN\OˆaO‘eP—hQœjQ•gQ
+!C+E'0F.4F7%8%U/lG.SFJZIK]KKZIKB=H\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\ÀREJZJK`LKdNLgPLjQLlRMnSMpTMqUMtWMxXN{ZN~[N]O„^O†`O‰aO‹bPdP•gQ™iQœkQ lR¤nR§pSªrS­sS¯tT²uT´vT¶wT·xT¹yT¹yTºyTºyT¹yT¶xT´vT¬rS¢nR—hQ¿|U¿|UÀ|UÀ|UÀ|UÀ|UÀ|UÀ|UÀ|UÀ|UÀ|UÀ|UÀ|UÀ|UÀ}UÀ}UÁ}UÁ}UÁ}UÁ}UÂ}UÂ~UÃ~UÃ~VÃ~VÄVÅ€WÆX®a(ŸlRªrS´vT¸yT¼zU¾|UÁ~VÃXÆ‚[Ɇ_΋dÓ‘jÔ“mÔ“nБlÊŒhĆd½_¶{[°vWªsU¦pS¢nRžkRšiQ˜hQ•gQ“fQ‘ePdPŒbP‰aO†_Oƒ^O€\O|ZNxXNsVMpTMnTMmSMjQL€C B)D&/F-3F47G6%>" Y7 kA$YIK]KK^KKSFJ\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\ÀVGJ\KKbMLeOLhPLkRLmSMnTMpTMrUMuWNyYN|ZN\N‚]O„_O‡`OŠaPŒbPŽcPeP“fP—hQ›jQžlR¢nR¥oS©qT¬sT¯uU²vU´wV¶xV¸yV¹yUºzU»zU¼{U½{U¾{U¾|U¿|U¿|U¿|U¿|U¾{U½{U¼{U¼zU»zTºyT¹yT¸xTµwT³vT´vT´vT´vT´wT´wTµwT·xT¹yTºzT¼zU½{U¾{U¿|UÀ|UÂ}UÄVÅ€WÇ‚YÉ„\͈_ÑŒdÙ”láuç£|쩂ſt명æ¦ÞŸ{Õ—sËŽl†d¹^³yZ­uW¨qU¤oSŸlRžkRœjQšiQ˜hQ–gQ”fQ‘ePdPcPŠaP‡`O„^O]O}[NyYNuWMpTMoTMmSMkRLgPL&D#.E,3F46G;'<(D"iB(VGJ]KK`LK[JKB>H\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\ÀNCJYIK^LKcNLfOLiQLkRMmSMoTMqUMsVMvXNzYN}[N€\O‚^O…_Oˆ`OŠaPŒcPdP‘eP“fQ•gQ—hQ™iQkR mS¤oT¨rU¬tW°wY´zZ¸}\»]¾€^À^Á‚^‚^Â\Á€ZÁYÁXÁ~WÁ~WÂ~VÂ~VÂ~VÃ~VÃ~UÃ~UÄ~UÄ~UÄUÄUÅVÅVÅVÅVÆVÆ€VÆ€VÇ€WÇWÈ‚XɃZË…[͇^ЊaÓdØ’iÜ—nâtè£zî©ó¯‡ø´û¸‘üº“û¹“÷¶ñ±Œé©…à¡~Ö˜vËmÇf»€`´z[®vX©rU¥pT£oS¢nS lRžkRœkRšjQ˜iQ–hQ”fQ’ePdPcP‹bPˆ`O…_O‚]O~[NzYNvWNpTMoTMnSMkRMhQLo7 ,2F36G99HC+@ ]8 nA"\JK`ML_LKSFJ\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\ÀSFJ[JK`LKdNLgPLjQLlRMnSMpTMqUMtVMwXNzZN}[N€]Oƒ^O†_OˆaO‹bPcPdP‘eP“fQ•gQ—hQ™iQ›jRžlR mS£oU§rW¬vZ²{]¹€a¿…fÅŠjËnГqÓ•sÕ–sÕ–rÕ–qÕ”oÓ’mÑjÏgÍŠcˈaɆ^È„\Ç‚[ÆYÅ€XÅ€WÅWÅWÅVÅVÅWÅ€WÆ€WÇXÈ‚YɃ[Ê…\͇_ÏŠaÒeÕ‘hÙ•mÝ™qávä¡zç¤}꧀멃몄騃奀ߠ|Ù›wÓ•rÌmƉh¿„c¸~^²yZ®vX¬tWªsV¨qU¦pT¤oS¢nS mRžlRœkR›jQ™iQ—hQ•gQ“fPePŽcP‹bPˆaO…_O‚^O\N{ZNwXNsVMoTMnSMlRMiQL~I#26G99G?<HA*E$ i@$ZIKaMLbML[JK;:H\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\ÀWHJ]KKbMLeOLhPLjRLlSMnTMpTMrUMuWMxXN{ZN~\N]O„^O†`O‰aO‹bPŽcPdP’eP”fQ–gQ˜hQšiQœkRžlS mT£oU¦rWªuZ¯y]´~aºƒfŠlË’sÔšzÜ¡€ã§†è«‰ë®‹í¯Œí®‹ë¬ˆè¨„ã£~ßžyÚ™tÖ•oÒjÎŒfˈbÈ…_ƃ\ÅZÄ€YÃXÂWÂ~WÂ~WÂ~WÃXÀXÄ€YÅZƃ\Ç…^Ɇ`ˈbÌŠdÍ‹fÎgÎŽiÎŽjÎŽjÍŽjËŒiljgÆd¿ƒaº^¸}]¶|\´{[²yZ°xY®vX¬tWªsV¨qU¦pT¤oS¢nS mRžlRkR›jQ™iQ—hQ•gQ“fP‘ePŽdPŒbP‰aO†_Oƒ^O€\O|ZNxXNtVMpTMnSMmSMjQLgPL99G?<HG-E&b;!YIK`MLdOM`LKNCJ\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\ÀŸlRºyTÄ~UÊ‚XʃYÄXº{W­tUšW'¢[(—hQ lRcP€\OhQL\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\ÀNCJYIK^LKcNLfOLiQLkRLmSMoTMqUMrVMvWNyYN|ZN\N‚]O„_O‡`O‰aPŒbPŽcPdP’fP”gQ–hQ˜iQšjRœkRžlS¡nT¤pU§sW«vZ°z]µb»„gŠlÉ‘sИyØžÞ¤…ã©Šè­ì±ï³‘ﳑ뭊穅⣀ݞzؘtÒ“nÎiɉdÆ…`Â]Á€[¿~Y¾}X½|W½|V¼{V¼{V¼{V¼{V¼{V¼|W¼|W½}X½}Y½~Z½~Z¼~Z»}[º}[º}[º~\º~\º~]º~]¹~]¸~]·}]¶|\´z[²yZ°wY®vX¬tWªsV¨rU¦pT¤oS¢nS mRŸlRkR›jQšiQ˜hQ–gQ“fQ‘ePdPŒcPŠaP‡`O„^O]O}[NyYNuWNpTMnTMmSMkRLhPL|H$D>IQ2P+XHK_LLfQOcNLXIK\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À©qSºyTÃ~VΈ`遲ޜv¾€]ªqS–LŽG|> g3
+S)?*%.—hQ—hQ‘eP‡`OuWM\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\ÀSFJ[JK`LKdNLgPLjQLlRMnSMoTMqUMsVMwXNzYN}[N€\O‚^O…_O‡`OŠaPŒbPŽdP‘eP“fP•gQ—hQ˜iQšjRœkRŸlS¡nT¤pV§sX«vZ°z^¶b¼…gËmÊ’sјzØŸ€Þ¤…ã©Šè­ê¯ë°ê¯Žè¬‹å¨‡à¤‚Ûž|Ö™wÑ“qÌŽlljgÃ…bÀ‚_½\»}Zº{X¹zW¸yV·yU·xU·xU·xT·xT·xU·xU·xU·yV·yV·yW¸zW¸{X¹{Y¹|Zº}[º}[º}\º~\¹~]¹~]¸}]·|\µ{\´z[²yZ°wY®vX¬tWªsV¨rU¦pT¤oS¢nS¡mRŸlRkRœjQšiQ˜hQ–gQ”fQ’ePdPcPŠbP‡`O…_O‚]O~[NzZNvWNrUMoTMmSMlRMiQLeOLJAIJ(h>!]KKfQOgQN_LKD>I\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À\À™iQ°tS¸yT¼{UÂYÎŒeï­ˆô´Õ—u¶|\ Z'™LˆD |>
+
+ &3#.$-% .% .& /&!,#,#@70A71XNHXNHWNHWNHZRLYQLYQLXQLWQLWPLUOLSNLQMKOLJMJJ0//.-.,,-&(+"(!'
+ %' %$#" ! !$ 
diff --git a/jni/ruby/ext/tk/sample/irbtk.rb b/jni/ruby/ext/tk/sample/irbtk.rb
new file mode 100644
index 0000000..70dd33e
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/irbtk.rb
@@ -0,0 +1,30 @@
+#!/usr/local/bin/ruby
+#
+# irbtk.rb - irb with Ruby/Tk
+#
+# If you want to use 'multi-tk.rb', give option '--multi-tk'.
+# And if you want to use 'remote-tk.rb', give option '--remote-tk'.
+# If you want both, you don't need to give both options, because
+# 'remote-tk.rb' includes 'multi-tk.rb'.
+# ( There is no trouble even if you give both options. )
+#
+require 'remote-tk' if ARGV.delete('--remote-tk')
+require 'multi-tk' if ARGV.delete('--multi-tk')
+
+require "tk"
+module Tk
+ MAINLOOP = Thread.new{ mainloop }
+end
+
+require "irb"
+
+if __FILE__ == $0
+ IRB.start(__FILE__)
+else
+ # check -e option
+ if /^-e$/ =~ $0
+ IRB.start(__FILE__)
+ else
+ IRB.setup(__FILE__)
+ end
+end
diff --git a/jni/ruby/ext/tk/sample/irbtkw.rbw b/jni/ruby/ext/tk/sample/irbtkw.rbw
new file mode 100644
index 0000000..b75ebca
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/irbtkw.rbw
@@ -0,0 +1,156 @@
+#!/usr/bin/env ruby
+#
+# irbtkw.rb : IRB console with Ruby/Tk
+#
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+release = '2008/03/08'
+
+require 'tk'
+begin
+ require 'tktextio'
+rescue LoadError
+ require File.join(File.dirname(File.expand_path(__FILE__)), 'tktextio.rb')
+end
+
+require 'irb'
+
+if TkCore::WITH_ENCODING
+else
+ # $KCODE setup
+ case Tk.encoding
+ when 'shiftjis', 'cp932'
+ $KCODE='SJIS'
+ when 'euc-jp'
+ $KCODE='EUC'
+ when 'utf-8', 'unicode'
+ $KCODE='UTF8'
+ else
+ # unknown
+ end
+end
+
+# console setup
+top = TkToplevel.new(:title=>'IRB console')
+top.protocol(:WM_DELETE_WINDOW){ Tk.exit }
+
+case (Tk.windowingsystem)
+when 'win32'
+ fnt = ['MS Gothic', '-12']
+else
+ fnt = ['courier', '-12']
+end
+
+console = TkTextIO.new(top, :mode=>:console,
+ :width=>80).pack(:side=>:left,
+ :expand=>true, :fill=>:both)
+console.yscrollbar(TkScrollbar.new(top, :width=>10).pack(:before=>console,
+ :side=>:right,
+ :expand=>false,
+ :fill=>:y))
+
+# save original I/O
+out = $stdout
+err = $stderr
+
+irb_thread = nil
+ev_loop = Thread.new{
+ begin
+ Tk.mainloop
+ ensure
+ $stdout = out
+ $stderr = err
+ irb_thread.kill if irb_thread
+ end
+}
+
+# window position control
+root = Tk.root
+
+r_x = root.winfo_rootx
+r_y = root.winfo_rooty
+r_w = root.winfo_width
+
+t_x = top.winfo_rootx
+t_y = top.winfo_rooty
+t_w = top.winfo_width
+
+delta = 10
+
+ratio = 0.8
+s_w = (ratio * root.winfo_screenwidth).to_i
+
+if r_x < t_x
+ r_x, t_x = t_x, r_x
+end
+if t_x + t_w + r_w + delta < s_w
+ r_x = t_x + t_w + delta
+elsif t_w + r_w + delta < s_w
+ r_x = s_w - r_w
+ t_x = r_x - t_w
+else
+ r_x = s_w - r_w
+ t_x = 0
+end
+
+root.geometry("+#{r_x}+#{r_y}")
+top.geometry("+#{t_x}+#{t_y}")
+
+root.raise
+console.focus
+
+# I/O setup
+$stdin = console
+$stdout = console
+$stderr = console
+
+# dummy for rubyw.exe on Windows
+def STDIN.tty?
+ true
+end
+
+# IRB setup
+IRB.init_config(nil)
+IRB.conf[:USE_READLINE] = false
+IRB.init_error
+irb = IRB::Irb.new
+IRB.conf[:MAIN_CONTEXT] = irb.context
+
+class IRB::StdioInputMethod
+ def gets
+ prompt = "\n" << @prompt
+ $stdin.instance_eval{
+ flush
+ @prompt = prompt
+ _set_console_line
+ @prompt = nil
+ _see_pos
+ }
+
+ @line[@line_no += 1] = $stdin.gets
+ end
+end
+
+# IRB start
+$stdout.print("*** IRB console on Ruby/Tk (#{release}) ")
+irb_thread = Thread.new{
+ catch(:IRB_EXIT){
+ loop {
+ begin
+ irb.eval_input
+ rescue Exception
+ end
+ }
+ }
+}
+
+console.bind('Control-c'){
+ console.insert('end', "^C\n")
+ irb_thread.raise RubyLex::TerminateLineInput
+}
+
+irb_thread.join
+
+# exit
+ev_loop.kill
+Tk.exit
diff --git a/jni/ruby/ext/tk/sample/iso2022-kr.txt b/jni/ruby/ext/tk/sample/iso2022-kr.txt
new file mode 100644
index 0000000..2e3fe6e
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/iso2022-kr.txt
@@ -0,0 +1,2 @@
+Sample text:
+$)C Hangul (GQ1[) >H3gGO<<?d, >H3gGO=J4O1n
diff --git a/jni/ruby/ext/tk/sample/menubar1.rb b/jni/ruby/ext/tk/sample/menubar1.rb
new file mode 100644
index 0000000..a233c6e
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/menubar1.rb
@@ -0,0 +1,51 @@
+#
+# menubar sample 1 : use frame and menubuttons
+#
+
+require 'tk'
+
+radio_var = TkVariable.new('y')
+
+menu_spec = [
+ [['File', 0],
+ {:label=>'Open', :command=>proc{puts('Open clicked')}, :underline=>0},
+ '---',
+ ['Check_A', TkVariable.new(true), 6],
+ {:type=>'checkbutton', :label=>'Check_B',
+ :variable=>TkVariable.new, :underline=>6},
+ '---',
+ ['Radio_X', [radio_var, 'x'], 6, '', {:foreground=>'black'}],
+ ['Radio_Y', [radio_var, 'y'], 6],
+ ['Radio_Z', [radio_var, 'z'], 6],
+ '---',
+ ['cascade', [
+ ['sss', proc{p 'sss'}, 0],
+ ['ttt', proc{p 'ttt'}, 0],
+ ['uuu', proc{p 'uuu'}, 0],
+ ['vvv', proc{p 'vvv'}, 0],
+ ],
+ 0, '',
+ {:font=>'Courier 16 italic',
+ :menu_config=>{:font=>'Times -18 bold', :foreground=>'black'}}],
+ '---',
+ ['Quit', proc{exit}, 0]],
+
+ [['Edit', 0],
+ ['Cut', proc{puts('Cut clicked')}, 2],
+ ['Copy', proc{puts('Copy clicked')}, 0],
+ ['Paste', proc{puts('Paste clicked')}, 0]],
+
+ [['Help', 0, {:menu_name=>'help'}],
+ ['About This', proc{puts('Ruby/Tk menubar sample 1')}, 6]]
+]
+
+menubar = TkMenubar.new(nil, menu_spec,
+ 'tearoff'=>false,
+ 'foreground'=>'grey40',
+ 'activeforeground'=>'red',
+ 'font'=>'Helvetia 12 bold')
+menubar.pack('side'=>'top', 'fill'=>'x')
+
+TkText.new(:wrap=>'word').pack.insert('1.0', 'Please read the sample source, and check how to override default configure options of menu entries on a menu_spec. Maybe, on windows, this menubar does not work properly about keyboard shortcuts. Then, please use "menu" option of root/toplevel widget (see sample/menubar2.rb).')
+
+Tk.mainloop
diff --git a/jni/ruby/ext/tk/sample/menubar2.rb b/jni/ruby/ext/tk/sample/menubar2.rb
new file mode 100644
index 0000000..e3cd68e
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/menubar2.rb
@@ -0,0 +1,56 @@
+#
+# menubar sample 2 : use 'menu' option of root/toplevel widget
+#
+
+require 'tk'
+
+radio_var = TkVariable.new('y')
+
+menu_spec = [
+ [['File', 0],
+ {:label=>'Open', :command=>proc{puts('Open clicked')}, :underline=>0},
+ '---',
+ ['Check_A', TkVariable.new(true), 6],
+ {:type=>'checkbutton', :label=>'Check_B',
+ :variable=>TkVariable.new, :underline=>6},
+ '---',
+ ['Radio_X', [radio_var, 'x'], 6, '', {:foreground=>'black'}],
+ ['Radio_Y', [radio_var, 'y'], 6],
+ ['Radio_Z', [radio_var, 'z'], 6],
+ '---',
+ ['cascade', [
+ ['sss', proc{p 'sss'}, 0],
+ ['ttt', proc{p 'ttt'}, 0],
+ ['uuu', proc{p 'uuu'}, 0],
+ ['vvv', proc{p 'vvv'}, 0],
+ ],
+ 0, '',
+ {:font=>'Courier 16 italic',
+ :menu_config=>{:font=>'Times -18 bold', :foreground=>'black'}}],
+ '---',
+ ['Quit', proc{exit}, 0]],
+
+ [['Edit', 0],
+ ['Cut', proc{puts('Cut clicked')}, 2],
+ ['Copy', proc{puts('Copy clicked')}, 0],
+ ['Paste', proc{puts('Paste clicked')}, 0]],
+
+ [['Help', 0, {:menu_name=>'help'}],
+ ['About This', proc{puts('Ruby/Tk menubar sample 2')}, 6]]
+]
+
+mbar = Tk.root.add_menubar(menu_spec,
+ # followings are default configure options
+ 'tearoff'=>'false',
+ 'foreground'=>'grey40',
+ 'activeforeground'=>'red',
+ 'font'=>'Helvetia 12 bold')
+# This (default configure options) is NOT same the following.
+#
+# mbar = Tk.root.add_menubar(menu_spec)
+# mbar.configure('foreground'=>'grey40', 'activeforeground'=>'red',
+# 'font'=>'Helvetia 12 bold')
+
+TkText.new(:wrap=>'word').pack.insert('1.0', 'Please read the sample source, and check how to override default configure options of menu entries on a menu_spec.')
+
+Tk.mainloop
diff --git a/jni/ruby/ext/tk/sample/menubar3.rb b/jni/ruby/ext/tk/sample/menubar3.rb
new file mode 100644
index 0000000..4f42f81
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/menubar3.rb
@@ -0,0 +1,72 @@
+#
+# menubar sample 3 : vertical layout menubar; use frame and menubuttons
+#
+
+require 'tk'
+
+radio_var = TkVariable.new('y')
+
+menu_spec = [
+ [['&File', true], # when underline option is ture, '&' index is the position
+ {:label=>'Open', :command=>proc{puts('Open clicked')}, :underline=>0},
+ '---',
+ ['Check_A', TkVariable.new(true), 6],
+ {:type=>'checkbutton', :label=>'Check_B',
+ :variable=>TkVariable.new, :underline=>6},
+ '---',
+ ['Radio_X', [radio_var, 'x'], /[XYZ]/, '', {:foreground=>'black'}],
+ ['Radio_Y', [radio_var, 'y'], /[XYZ]/],
+ ['Radio_Z', [radio_var, 'z'], /[XYZ]/], # use Regexp for underline position
+ '---',
+ ['cascade', [
+ ['sss', proc{p 'sss'}, 0],
+ ['ttt', proc{p 'ttt'}, 0],
+ ['uuu', proc{p 'uuu'}, 0],
+ ['vvv', proc{p 'vvv'}, 0],
+ ],
+ 0, '',
+ {:font=>'Courier 16 italic',
+ :menu_config=>{:font=>'Times -18 bold', :foreground=>'black'}}],
+ '---',
+ ['Quit', proc{exit}, 0]],
+
+ [['Edit', 0],
+ ['Cut', proc{puts('Cut clicked')}, 2],
+ ['Copy', proc{puts('Copy clicked')}, 0],
+ ['Paste', proc{puts('Paste clicked')}, 0]],
+
+ [['Help', 0, {:menu_name=>'help'}],
+ ['About This', proc{puts('Ruby/Tk menubar sample 3')}, "This"]]
+ # use string index for underline position
+]
+
+layout_proc = 'vertical'
+# The following procedure is same to 'layout_proc'=>'vertical'
+=begin
+layout_proc = proc{|parent, mbtn|
+ mbtn.direction :right
+ mbtn.pack(:side=>:top, :fill=>:x)
+
+ menu = mbtn.menu
+ cmd = proc{|m, dir|
+ Tk::Menu::TkInternalFunction.next_menu(m, dir) rescue nil
+ # ignore error when the internal function doesn't exist
+ }
+ menu.bind('Tab', cmd, :widget, 'forward')
+ menu.bind('Alt-Tab', cmd, :widget, 'backward')
+}
+=end
+
+menubar = TkMenubar.new(nil, menu_spec,
+ 'layout_proc'=>layout_proc,
+ 'tearoff'=>false,
+ 'foreground'=>'grey40',
+ 'activeforeground'=>'red',
+ 'font'=>'Helvetia 12 bold')
+menubar.pack('side'=>'left', 'fill'=>'y')
+
+TkText.new(:wrap=>'word').pack.insert('1.0', 'This sample script generates "Menu Sidebar".
+If "::tk::MenuNextMenuon" function is available your Tcl/Tk library, you will be able to move to the next menu by Tab key on the posted menu, or the previous menu by Alt + Tab key.
+Please read the sample source, and check how to override default configure options of menu entries on a menu_spec. Maybe, on windows, this menubar does not work properly about keyboard shortcuts. Then, please use "menu" option of root/toplevel widget (see sample/menubar3.rb).')
+
+Tk.mainloop
diff --git a/jni/ruby/ext/tk/sample/msgs_rb/README b/jni/ruby/ext/tk/sample/msgs_rb/README
new file mode 100644
index 0000000..781dda9
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/msgs_rb/README
@@ -0,0 +1,3 @@
+Message catalogs in this directory depend on Tcl/Tk's message catalogs.
+Texts of each locale are copied from Tcl/Tk8.5a1 widget demos.
+Please refer to '../msgs_tk/README'.
diff --git a/jni/ruby/ext/tk/sample/msgs_rb/cs.msg b/jni/ruby/ext/tk/sample/msgs_rb/cs.msg
new file mode 100644
index 0000000..199f2a7
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/msgs_rb/cs.msg
@@ -0,0 +1,84 @@
+TkMsgCatalog.new('::tkmsgcat_demo') {
+ cs "Application Error", "Chyba programu"
+ cs "Blue", "Modr\341"
+ cs "Color", "Barva"
+ cs "Delete", "Smazat"
+ cs "Error", "Chyba"
+ cs "Exit", "Konec"
+ cs "Green", "Zelen\341"
+ cs "Red", "\\u010cerven\341"
+ cs "blue", "modr\341"
+ cs "green", "zelen\341"
+ cs "red", "\\u010derven\341"
+}
+
+TkMsgCatalog.new('::tk') {
+ cs "&Abort", "&P\\u0159eru\\u0161it"
+ cs "About...", "O programu..."
+ cs "All Files", "V\\u0161echny soubory"
+ cs "Application Error", "Chyba programu"
+ cs "&Blue", "&Modr\341"
+ cs "&Cancel", "&Zru\\u0161it"
+ cs "Cannot change to the directory \"%1\$s\".\nPermission denied.", "Nemohu zm\\u011bnit atku\341ln\355 adres\341\\u0159 na \"%1\$s\".\nP\\u0159\355stup odm\355tnut."
+ cs "Choose Directory", "V\375b\\u011br adres\341\\u0159e"
+ cs "Clear", "Smazat"
+ cs "Color", "Barva"
+ cs "Console", "Konzole"
+ cs "Copy", "Kop\355rovat"
+ cs "Cut", "Vy\\u0159\355znout"
+ cs "Delete", "Smazat"
+ cs "Details >>", "Detaily >>"
+ cs "Directory \"%1\$s\" does not exist.", "Adres\341\\u0159 \"%1\$s\" neexistuje."
+ cs "&Directory:", "&Adres\341\\u0159:"
+ cs "Error: %1\$s", "Chyba: %1\$s"
+ cs "Exit", "Konec"
+ cs "File \"%1\$s\" already exists.\n\n", "Soubor \"%1\$s\" ji\\u017e existuje.\n\n"
+ cs "File \"%1\$s\" already exists.\nDo you want to overwrite it?", "Soubor \"%1\$s\" ji\\u017e existuje.\nChcete jej p\\u0159epsat?"
+ cs "File \"%1\$s\" does not exist.", "Soubor \"%1\$s\" neexistuje."
+ cs "File &name:", "&Jm\351no souboru:"
+ cs "File &names:", "&Jm\351na soubor\\u016f:"
+ cs "Files of &type:", "&Typy soubor\\u016f:"
+ cs "Fi&les:", "Sou&bory:"
+ cs "&Filter", "&Filtr"
+ cs "Fil&ter:", "Fil&tr:"
+ cs "&Green", "Ze&len\341"
+ cs "Hi"
+ cs "Hide Console", "Skr\375t konsolu"
+ cs "&Ignore", "&Ignorovat"
+ cs "Invalid file name \"%1\$s\".", "\\u0160patn\351 jm\351no souboru \"%1\$s\"."
+ cs "Log Files", "Log soubory"
+ cs "&No", "&Ne"
+ cs "&OK"
+ cs "Ok"
+ cs "Open", "Otev\\u0159\355t"
+ cs "&Open", "&Otev\\u0159\355t"
+ cs "Open Multiple Files", "Otev\\u0159\355t v\355ce soubor\\u016f"
+ cs "Paste", "Vlo\\u017eit"
+ cs "Quit", "Skon\\u010dit"
+ cs "&Red", " \\u010ce&rven\341"
+ cs "Replace existing file?", "Nahradit st\341vaj\355c\355 soubor?"
+ cs "&Retry", "Z&novu"
+ cs "&Save", "&Ulo\\u017eit"
+ cs "Save As", "Ulo\\u017eit jako"
+ cs "Save To Log", "Ulo\\u017eit do logu"
+ cs "Select Log File", "Vybrat log soubor"
+ cs "Select a file to source", "Vybrat soubor k nahr\341n\355"
+ cs "&Selection:", "&V\375b\\u011br:"
+ cs "Skip Messages", "P\\u0159esko\\u010dit zpr\341vy"
+ cs "Source...", "Nahr\341t..."
+ cs "Tcl Scripts", "Tcl skripty"
+ cs "Tcl for Windows", "Tcl pro Windows"
+ cs "Text Files", "Textov\351 soubory"
+ cs "&Yes", "&Ano"
+ cs "abort", "p\\u0159eru\\u0161it"
+ cs "blue", "modr\341"
+ cs "cancel", "zru\\u0161it"
+ cs "extension", "p\\u0159\355pona"
+ cs "extensions", "p\\u0159\355pony"
+ cs "green", "zelen\341"
+ cs "ignore", "ignorovat"
+ cs "ok"
+ cs "red", "\\u010derven\341"
+ cs "retry", "znovu"
+ cs "yes", "ano"
+}
diff --git a/jni/ruby/ext/tk/sample/msgs_rb/de.msg b/jni/ruby/ext/tk/sample/msgs_rb/de.msg
new file mode 100644
index 0000000..283874d
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/msgs_rb/de.msg
@@ -0,0 +1,88 @@
+TkMsgCatalog.new('::tkmsgcat_demo') {
+ de "Application Error", "Applikationsfehler"
+ de "Blue", "Blau"
+ de "Color", "Farbe"
+ de "Delete", "L\\u00f6schen"
+ de "Error", "Fehler"
+ de "Exit", "Ende"
+ de "Green", "Gr\\u00fcn"
+ de "Red", "Rot"
+ de "blue", "blau"
+ de "green", "gr\\u00fcn"
+ de "red", "rot"
+}
+
+TkMsgCatalog.new('::tk') {
+ de "&Abort", "&Abbruch"
+ de "&About...", "&\\u00dcber..."
+ de "All Files", "Alle Dateien"
+ de "Application Error", "Applikationsfehler"
+ de "&Blue", "&Blau"
+ de "&Cancel", "&Abbruch"
+ de "Cannot change to the directory \"%1\$s\".\nPermission denied.", "Kann nicht in das Verzeichnis \"%1\$s\" wechseln.\nKeine Rechte vorhanden."
+ de "Choose Directory", "W\\u00e4hle Verzeichnis"
+ de "&Clear", "&R\\u00fccksetzen"
+ de "&Clear Console", "&Konsole l\\u00f6schen"
+ de "Color", "Farbe"
+ de "Console", "Konsole"
+ de "&Copy", "&Kopieren"
+ de "Cu&t", "Aus&schneiden"
+ de "&Delete", "&L\\u00f6schen"
+ de "Details >>"
+ de "Directory \"%1\$s\" does not exist.", "Das Verzeichnis \"%1\$s\" existiert nicht."
+ de "&Directory:", "&Verzeichnis:"
+ de "&Edit", "&Bearbieten"
+ de "Error: %1\$s", "Fehler: %1\$s"
+ de "E&xit", "&Ende"
+ de "&File", "&Datei"
+ de "File \"%1\$s\" already exists.\nDo you want to overwrite it?", "Die Datei \"%1\$s\" ist bereits vorhanden.\nWollen sie diese Datei \\u00fcberschreiben ?"
+ de "File \"%1\$s\" already exists.\n\n", "Die Datei \"%1\$s\" ist bereits vorhanden.\n\n"
+ de "File \"%1\$s\" does not exist.", "Die Datei \"%1\$s\" existiert nicht."
+ de "File &name:", "Datei&name:"
+ de "File &names:", "Datei&namen:"
+ de "Files of &type:", "Dateien des &Typs:"
+ de "Fi&les:", "Dat&eien:"
+ de "&Filter"
+ de "Fil&ter:"
+ de "&Green", "&Gr\\u00fcn"
+ de "&Help", "&Hilfe"
+ de "Hi", "Hallo"
+ de "&Hide Console", "&Konsole unsichtbar machen"
+ de "&Ignore", "&Ignorieren"
+ de "Invalid file name \"%1\$s\".", "Ung\\u00fcltiger Dateiname \"%1\$s\"."
+ de "Log Files", "Protokolldatei"
+ de "&No", "&Nein"
+ de "OK"
+ de "Ok"
+ de "Open", "\\u00d6ffnen"
+ de "&Open", "\\u00d6&ffnen"
+ de "Open Multiple Files"
+ de "P&aste", "E&inf\\u00fcgen"
+ de "&Quit", "&Beenden"
+ de "&Red", "&Rot"
+ de "Replace existing file?", "Existierende Datei ersetzen?"
+ de "&Retry", "&Wiederholen"
+ de "&Save", "&Speichern"
+ de "Save As", "Speichern unter"
+ de "Save To Log", "In Protokoll speichern"
+ de "Select Log File", "Protokolldatei ausw\\u00e4hlen"
+ de "Select a file to source", "Auszuf\\u00fchrende Datei ausw\\u00e4hlen"
+ de "&Selection:", "Auswah&l:"
+ de "Skip Messages", "Weitere Nachrichten \\u00fcberspringen"
+ de "&Source...", "&Ausf\\u00fchren..."
+ de "Tcl Scripts", "Tcl-Skripte"
+ de "Tcl for Windows", "Tcl f\\u00fcr Windows"
+ de "Text Files", "Textdateien"
+ de "&Yes", "&Ja"
+ de "abort", "abbrechen"
+ de "blue", "blau"
+ de "cancel", "abbrechen"
+ de "extension", "Erweiterung"
+ de "extensions", "Erweiterungen"
+ de "green", "gr\\u00fcn"
+ de "ignore", "ignorieren"
+ de "ok"
+ de "red", "rot"
+ de "retry", "wiederholen"
+ de "yes", "ja"
+}
diff --git a/jni/ruby/ext/tk/sample/msgs_rb/el.msg b/jni/ruby/ext/tk/sample/msgs_rb/el.msg
new file mode 100644
index 0000000..f314ae0
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/msgs_rb/el.msg
@@ -0,0 +1,98 @@
+TkMsgCatalog.new('::tkmsgcat_demo') {
+ el 'Application Error', '\u039b\u03ac\u03b8\u03bf\u03c2 \u0395\u03c6\u03b1\u03c1\u03bc\u03bf\u03b3\u03ae\u03c2'
+ el 'Blue', '\u039c\u03c0\u03bb\u03b5'
+ el 'Color', '\u03a7\u03c1\u03ce\u03bc\u03b1'
+ el 'Delete', '\u0394\u03b9\u03b1\u03b3\u03c1\u03b1\u03c6\u03ae'
+ el 'Error', '\u039b\u03ac\u03b8\u03bf\u03c2'
+ el 'Exit', '\u0388\u03be\u03bf\u03b4\u03bf\u03c2'
+ el 'Green', '\u03a0\u03c1\u03ac\u03c3\u03b9\u03bd\u03bf'
+ el 'Red', '\u039a\u03cc\u03ba\u03ba\u03b9\u03bd\u03bf'
+ el 'blue', '\u03bc\u03c0\u03bb\u03b5'
+ el 'green', '\u03c0\u03c1\u03ac\u03c3\u03b9\u03bd\u03bf'
+ el 'red', '\u03ba\u03cc\u03ba\u03ba\u03b9\u03bd\u03bf'
+}
+
+TkMsgCatalog.new('::tk') {
+ el '&Abort', '\u03a4\u03b5\u03c1\u03bc\u03b1\u03c4\u03b9\u03c3\u03bc\u03cc\u03c2'
+ el 'About...', '\u03a3\u03c7\u03b5\u03c4\u03b9\u03ba\u03ac...'
+ el 'All Files', '\u038c\u03bb\u03b1 \u03c4\u03b1 \u0391\u03c1\u03c7\u03b5\u03af\u03b1'
+ el 'Application Error', '\u039b\u03ac\u03b8\u03bf\u03c2 \u0395\u03c6\u03b1\u03c1\u03bc\u03bf\u03b3\u03ae\u03c2'
+ el '&Blue', '\u039c\u03c0\u03bb\u03b5'
+ el '&Cancel', '\u0391\u03ba\u03cd\u03c1\u03c9\u03c3\u03b7'
+ el 'Cannot change to the directory "%1\$s".' "\n" 'Permission denied.', \
+ '\u0394\u03b5\u03bd \u03b5\u03af\u03bd\u03b1\u03b9 \u03b4\u03c5\u03bd\u03b1\u03c4\u03ae \u03b7 \u03b1\u03bb\u03bb\u03b1\u03b3\u03ae \u03ba\u03b1\u03c4\u03b1\u03bb\u03cc\u03b3\u03bf\u03c5 \u03c3\u03b5 "%1\$s".' \
+ "\n" \
+ '\u0397 \u03c0\u03c1\u03cc\u03c3\u03b2\u03b1\u03c3\u03b7 \u03b4\u03b5\u03bd \u03b5\u03c0\u03b9\u03c4\u03c1\u03ad\u03c0\u03b5\u03c4\u03b1\u03b9.'
+ el 'Choose Directory', '\u0395\u03c0\u03b9\u03bb\u03bf\u03b3\u03ae \u039a\u03b1\u03c4\u03b1\u03bb\u03cc\u03b3\u03bf\u03c5'
+ el 'Clear', '\u039a\u03b1\u03b8\u03b1\u03c1\u03b9\u03c3\u03bc\u03cc\u03c2'
+ el 'Color', '\u03a7\u03c1\u03ce\u03bc\u03b1'
+ el 'Console', '\u039a\u03bf\u03bd\u03c3\u03cc\u03bb\u03b1'
+ el 'Copy', '\u0391\u03bd\u03c4\u03b9\u03b3\u03c1\u03b1\u03c6\u03ae'
+ el 'Cut', '\u0391\u03c0\u03bf\u03ba\u03bf\u03c0\u03ae'
+ el 'Delete', '\u0394\u03b9\u03b1\u03b3\u03c1\u03b1\u03c6\u03ae'
+ el 'Details >>', '\u039b\u03b5\u03c0\u03c4\u03bf\u03bc\u03ad\u03c1\u03b5\u03b9\u03b5\u03c2 >>'
+ el 'Directory "%1\$s", does not exist.', \
+ '\u039f \u03ba\u03b1\u03c4\u03ac\u03bb\u03bf\u03b3\u03bf\u03c2 \'%1\$s\' \u03b4\u03b5\u03bd \u03c5\u03c0\u03ac\u03c1\u03c7\u03b5\u03b9.'
+ el '&Directory:', '&\u039a\u03b1\u03c4\u03ac\u03bb\u03bf\u03b3\u03bf\u03c2:'
+ el 'Error: %1\$s', '\u039b\u03ac\u03b8\u03bf\u03c2: %1\$s'
+ el 'Exit', '\u0388\u03be\u03bf\u03b4\u03bf\u03c2'
+ el 'File "%1\$s" already exists.' "\n" 'Do you want to overwrite it?', \
+ '\u03a4\u03bf \u03b1\u03c1\u03c7\u03b5\u03af\u03bf "%1\$s" \u03ae\u03b4\u03b7 \u03c5\u03c0\u03ac\u03c1\u03c7\u03b5\u03b9.' \
+ "\n" \
+ '\u0398\u03ad\u03bb\u03b5\u03c4\u03b5 \u03bd\u03b1 \u03b5\u03c0\u03b9\u03ba\u03b1\u03bb\u03c5\u03c6\u03b8\u03b5\u03af;'
+ el 'File "%1\$s" already exists.' "\n\n", \
+ '\u03a4\u03bf \u03b1\u03c1\u03c7\u03b5\u03af\u03bf "%1\$s" \u03ae\u03b4\u03b7 \u03c5\u03c0\u03ac\u03c1\u03c7\u03b5\u03b9.' "\n\n"
+ el 'File "%1\$s" does not exist.', \
+ '\u03a4\u03bf \u03b1\u03c1\u03c7\u03b5\u03af\u03bf "%1\$s" \u03b4\u03b5\u03bd \u03c5\u03c0\u03ac\u03c1\u03c7\u03b5\u03b9.'
+ el 'File &name:', '\u038c&\u03bd\u03bf\u03bc\u03b1 \u03b1\u03c1\u03c7\u03b5\u03af\u03bf\u03c5:'
+ el 'File &names:', '\u038c&\u03bd\u03bf\u03bc\u03b1 \u03b1\u03c1\u03c7\u03b5\u03af\u03c9\u03bd:'
+ el 'Files of &type:', '\u0391\u03c1\u03c7\u03b5\u03af\u03b1 \u03c4\u03bf\u03c5 &\u03c4\u03cd\u03c0\u03bf\u03c5:'
+ el 'Fi&les:', '\u0391\u03c1\u03c7\u03b5\u03af\u03b1:'
+ el '&Filter', '\u03a6\u03af\u03bb\u03c4\u03c1\u03bf'
+ el 'Fil&ter:', '\u03a6\u03af\u03bb\u03c4\u03c1\u03bf:'
+ el '&Green', '\u03a0\u03c1\u03ac\u03c3\u03b9\u03bd\u03bf'
+ el 'Hi', '\u0393\u03b5\u03b9\u03b1'
+ el 'Hide Console', '\u0391\u03c0\u03cc\u03ba\u03c1\u03c5\u03c8\u03b7 \u03ba\u03bf\u03bd\u03c3\u03cc\u03bb\u03b1\u03c2'
+ el '&Ignore', '\u0391\u03b3\u03bd\u03cc\u03b7\u03c3\u03b7'
+ el 'Invalid file name "%1\$s".', \
+ '\u0386\u03ba\u03c5\u03c1\u03bf \u03cc\u03bd\u03bf\u03bc\u03b1 \u03b1\u03c1\u03c7\u03b5\u03af\u03bf\u03c5 "%1\$s".'
+ el 'Log Files', '\u0391\u03c1\u03c7\u03b5\u03af\u03b1 \u039a\u03b1\u03c4\u03b1\u03b3\u03c1\u03b1\u03c6\u03ae\u03c2'
+ el '&No', '\u038c\u03c7\u03b9'
+ el '&OK', '\u0395\u03bd\u03c4\u03ac\u03be\u03b5\u03b9'
+ el '&Ok', '\u0395\u03bd\u03c4\u03ac\u03be\u03b5\u03b9'
+ el 'Open', '\u0386\u03bd\u03bf\u03b9\u03b3\u03bc\u03b1'
+ el '&Open', '\u0386\u03bd\u03bf\u03b9\u03b3\u03bc\u03b1'
+ el 'Open Multiple Files', \
+ '\u0386\u03bd\u03bf\u03b9\u03b3\u03bc\u03b1 \u03c0\u03bf\u03bb\u03bb\u03b1\u03c0\u03bb\u03ce\u03bd \u03b1\u03c1\u03c7\u03b5\u03af\u03c9\u03bd'
+ el 'Paste', '\u0395\u03c0\u03b9\u03ba\u03cc\u03bb\u03bb\u03b7\u03c3\u03b7'
+ el 'Quit', '\u0388\u03be\u03bf\u03b4\u03bf\u03c2'
+ el '&Red', '\u039a\u03cc\u03ba\u03ba\u03b9\u03bd\u03bf'
+ el 'Replace existing file?', \
+ '\u0395\u03c0\u03b9\u03ba\u03ac\u03bb\u03c5\u03c8\u03b7 \u03c5\u03c0\u03ac\u03c1\u03c7\u03bf\u03bd\u03c4\u03bf\u03c2 \u03b1\u03c1\u03c7\u03b5\u03af\u03bf\u03c5;'
+ el '&Retry', '\u03a0\u03c1\u03bf\u03c3\u03c0\u03ac\u03b8\u03b7\u03c3\u03b5 \u03be\u03b1\u03bd\u03ac'
+ el '&Save', '\u0391\u03c0\u03bf\u03b8\u03ae\u03ba\u03b5\u03c5\u03c3\u03b7'
+ el 'Save As', '\u0391\u03c0\u03bf\u03b8\u03ae\u03ba\u03b5\u03c5\u03c3\u03b7 \u03c3\u03b1\u03bd'
+ el 'Save To Log', '\u0391\u03c0\u03bf\u03b8\u03ae\u03ba\u03b5\u03c5\u03c3\u03b7 \u03c3\u03c4\u03bf \u03b1\u03c1\u03c7\u03b5\u03af\u03bf \u03ba\u03b1\u03c4\u03b1\u03b3\u03c1\u03b1\u03c6\u03ae\u03c2'
+ el 'Select Log File', '\u0395\u03c0\u03b9\u03bb\u03bf\u03b3\u03ae \u03b1\u03c1\u03c7\u03b5\u03af\u03bf\u03c5 \u03ba\u03b1\u03c4\u03b1\u03b3\u03c1\u03b1\u03c6\u03ae\u03c2'
+ el 'Select a file to source', \
+ '\u0395\u03c0\u03b9\u03bb\u03ad\u03be\u03c4\u03b5 \u03b1\u03c1\u03c7\u03b5\u03af\u03bf \u03b3\u03b9\u03b1 \u03b5\u03ba\u03c4\u03ad\u03bb\u03b5\u03c3\u03b7'
+ el '&Selection:', '\u0395\u03c0\u03b9\u03bb\u03bf\u03b3\u03ae:'
+ el 'Skip Messages', '\u0391\u03c0\u03bf\u03c6\u03c5\u03b3\u03ae \u03bc\u03c5\u03bd\u03b7\u03bc\u03ac\u03c4\u03c9\u03bd'
+ el 'Source...', '\u0395\u03ba\u03c4\u03ad\u03bb\u03b5\u03c3\u03b7...'
+ el 'Tcl Scripts', 'Tcl Scripts'
+ el 'Tcl for Windows', 'Tcl \u03b3\u03b9\u03b1 Windows'
+ el 'Text Files', '\u0391\u03c1\u03c7\u03b5\u03af\u03b1 \u039a\u03b5\u03b9\u03bc\u03ad\u03bd\u03bf\u03c5'
+ el '&Yes', '\u039d\u03b1\u03b9'
+ el 'abort', '\u03c4\u03b5\u03c1\u03bc\u03b1\u03c4\u03b9\u03c3\u03bc\u03cc\u03c2'
+ el 'blue', '\u03bc\u03c0\u03bb\u03b5'
+ el 'cancel', '\u03b1\u03ba\u03cd\u03c1\u03c9\u03c3\u03b7'
+ el 'extension', '\u03b5\u03c0\u03ad\u03ba\u03c4\u03b1\u03c3\u03b7'
+ el 'extensions', '\u03b5\u03c0\u03b5\u03ba\u03c4\u03ac\u03c3\u03b5\u03b9\u03c2'
+ el 'green', '\u03c0\u03c1\u03ac\u03c3\u03b9\u03bd\u03bf'
+ el 'ignore', '\u03b1\u03b3\u03bd\u03cc\u03b7\u03c3\u03b7'
+ el 'ok', '\u03b5\u03bd\u03c4\u03ac\u03be\u03b5\u03b9'
+ el 'red', '\u03ba\u03cc\u03ba\u03ba\u03b9\u03bd\u03bf'
+ el 'retry', '\u03c0\u03c1\u03bf\u03c3\u03c0\u03ac\u03b8\u03b7\u03c3\u03b5 \u03be\u03b1\u03bd\u03ac'
+ el 'yes', '\u03bd\u03b1\u03b9'
+}
+
diff --git a/jni/ruby/ext/tk/sample/msgs_rb/en.msg b/jni/ruby/ext/tk/sample/msgs_rb/en.msg
new file mode 100644
index 0000000..9b70239
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/msgs_rb/en.msg
@@ -0,0 +1,83 @@
+TkMsgCatalog.new('::tkmsgcat_demo') {
+ en "Application Error"
+ en "Blue"
+ en "Color"
+ en "Delete"
+ en "Error"
+ en "Green"
+ en "Red"
+ en "blue"
+ en "green"
+ en "red"
+}
+
+TkMsgCatalog.new('::tk') {
+ en "&Abort"
+ en "About..."
+ en "All Files"
+ en "Application Error"
+ en "&Blue"
+ en "&Cancel"
+ en "Cannot change to the directory \"%1\$s\".\nPermission denied."
+ en "Choose Directory"
+ en "Clear"
+ en "Color"
+ en "Console"
+ en "Copy"
+ en "Cut"
+ en "Delete"
+ en "Details >>"
+ en "Directory \"%1\$s\" does not exist."
+ en "&Directory:"
+ en "Error: %1\$s"
+ en "Exit"
+ en "File \"%1\$s\" already exists.\nDo you want to overwrite it?"
+ en "File \"%1\$s\" already exists.\n\n"
+ en "File \"%1\$s\" does not exist."
+ en "File &name:"
+ en "File &names:"
+ en "Files of &type:"
+ en "Fi&les:"
+ en "&Filter"
+ en "Fil&ter:"
+ en "&Green"
+ en "Hi"
+ en "Hide Console"
+ en "&Ignore"
+ en "Invalid file name \"%1\$s\"."
+ en "Log Files"
+ en "&No"
+ en "&OK"
+ en "Ok"
+ en "Open"
+ en "&Open"
+ en "Open Multiple Files"
+ en "Paste"
+ en "Quit"
+ en "&Red"
+ en "Replace existing file?"
+ en "&Retry"
+ en "&Save"
+ en "Save As"
+ en "Save To Log"
+ en "Select Log File"
+ en "Select a file to source"
+ en "&Selection:"
+ en "Skip Messages"
+ en "Source..."
+ en "Tcl Scripts"
+ en "Tcl for Windows"
+ en "Text Files"
+ en "&Yes"
+ en "abort"
+ en "blue"
+ en "cancel"
+ en "extension"
+ en "extensions"
+ en "green"
+ en "ignore"
+ en "ok"
+ en "red"
+ en "retry"
+ en "yes"
+}
diff --git a/jni/ruby/ext/tk/sample/msgs_rb/en_gb.msg b/jni/ruby/ext/tk/sample/msgs_rb/en_gb.msg
new file mode 100644
index 0000000..97c5895
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/msgs_rb/en_gb.msg
@@ -0,0 +1,7 @@
+TkMsgCatalog.new('::tkmsgcat_demo') {
+ en_gb 'Color', 'Colour'
+}
+
+TkMsgCatalog.new('::tk') {
+ en_gb 'Color', 'Colour'
+}
diff --git a/jni/ruby/ext/tk/sample/msgs_rb/eo.msg b/jni/ruby/ext/tk/sample/msgs_rb/eo.msg
new file mode 100644
index 0000000..1630df5
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/msgs_rb/eo.msg
@@ -0,0 +1,87 @@
+TkMsgCatalog.new('::tkmsgcat_demo') {
+ eo 'Application Error', 'Aplikoerraro'
+ eo 'Blue', 'Blua'
+ eo 'Color', 'Farbo'
+ eo 'Delete', 'Forprenu'
+ eo 'Error', 'Eraro'
+ eo 'Exit', 'Eliru'
+ eo 'Green', 'Verda'
+ eo 'Red', 'Rosa'
+ eo 'blue', 'blua'
+ eo 'green', 'verda'
+ eo 'red', 'ru\u011da'
+}
+
+TkMsgCatalog.new('::tk') {
+ eo '&Abort', '&\u0108esigo'
+ eo '&About...', 'Pri...'
+ eo 'All Files', '\u0108ioj dosieroj'
+ eo 'Application Error', 'Aplikoerraro'
+ eo '&Blue', '&Blua'
+ eo '&Cancel', '&Rezignu'
+ eo 'Cannot change to the directory "%1\$s".' "\n" 'Permission denied.', 'Neeble \u0109angi al dosierulon "%1\$s".' "\n" 'Vi ne rajtas tion.'
+ eo 'Choose Directory', 'Elektu Dosierujo'
+ eo '&Clear', '&Klaru'
+ eo '&Clear Console', '&Klaru konzolon'
+ eo 'Color', 'Farbo'
+ eo 'Console', 'Konzolo'
+ eo '&Copy', '&Kopiu'
+ eo 'Cu&t', '&Enpo\u015digu'
+ eo '&Delete', '&Forprenu'
+ eo 'Details >>', 'Detaloj >>'
+ eo 'Directory "%1\$s" does not exist.', 'La dosierujo "%1\$s" ne ekzistas.'
+ eo '&Directory:', '&Dosierujo:'
+ eo '&Edit', '&Redaktu'
+ eo 'Error: %1\$s', 'Eraro: %1\$s'
+ eo 'E&xit', '&Eliru'
+ eo '&File', '&Dosiero'
+ eo 'File "%1\$s" already exists.' "\n" 'Do you want to overwrite it?', 'La dosiero "%1\$s" jam ekzistas.' "\n" '\u0108u vi volas anstata\u00fbigi la dosieron?'
+ eo 'File "%1\$s" already exists.' "\n\n", 'La dosiero "%1\$s" jam egzistas.' "\n\n"
+ eo 'File "%1\$s" does not exist.', 'La dosierp "%1\$s" ne estas.'
+ eo 'File &name:', 'Dosiero&nomo:'
+ eo 'File &names:', 'Dosiero&nomoj:'
+ eo 'Files of &type:', 'Dosieroj de &Typo:'
+ eo 'Fi&les:', 'Do&sieroj:'
+ eo '&Filter', '&Filtrilo'
+ eo 'Fil&ter:', '&Filtrilo:'
+ eo '&Green', '&Verda'
+ eo '&Help', '&Helpu'
+ eo 'Hi', 'Saluton'
+ eo '&Hide Console', '&Ka\u015du konzolon'
+ eo '&Ignore', '&Ignoru'
+ eo 'Invalid file name "%1\$s".', 'Malvalida dosieronomo "%1\$s".'
+ eo 'Log Files', 'Protokolo'
+ eo '&No', '&Ne'
+ eo 'OK'
+ eo 'Ok'
+ eo 'Open', 'Malfermu'
+ eo '&Open', '&Malfermu'
+ eo 'Open Multiple Files', 'Melfermu multan dosierojn'
+ eo 'P&aste', '&Elpo\u015digi'
+ eo '&Quit', '&Finigu'
+ eo '&Red', '&Rosa'
+ eo 'Replace existing file?', '\u0108u anstata\u00fbu ekzistantan dosieron?'
+ eo '&Retry', '&Ripetu'
+ eo '&Save', '&Savu'
+ eo 'Save As', 'Savu kiel'
+ eo 'Save To Log', 'Savu en protokolon'
+ eo 'Select Log File', 'Elektu prokolodosieron'
+ eo 'Select a file to source', 'Elektu dosieron por interpreti'
+ eo '&Selection:', '&Elekto:'
+ eo 'Skip Messages', 'transsaltu pluajn mesa\u011dojn'
+ eo '&Source...', '&Fontoprogramo...'
+ eo 'Tcl Scripts', 'Tcl-skriptoj'
+ eo 'Tcl for Windows', 'Tcl por vindoso'
+ eo 'Text Files', 'Tekstodosierojn'
+ eo '&Yes', '&Jes'
+ eo 'abort', '\u0109esigo'
+ eo 'blue', 'blua'
+ eo 'cancel', 'rezignu'
+ eo 'extension', 'ekspansio'
+ eo 'extensions', 'ekspansioj'
+ eo 'green', 'verda'
+ eo 'ignore', 'ignorieren'
+ eo 'red', 'ru\u011da'
+ eo 'retry', 'ripetu'
+ eo 'yes', 'jes'
+}
diff --git a/jni/ruby/ext/tk/sample/msgs_rb/es.msg b/jni/ruby/ext/tk/sample/msgs_rb/es.msg
new file mode 100644
index 0000000..38ca28f
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/msgs_rb/es.msg
@@ -0,0 +1,84 @@
+TkMsgCatalog.new('::tkmsgcat_demo') {
+ es "Application Error", "Error de la aplicaci\\u00f3n"
+ es "Blue", "Azul"
+ es "Color", "Color"
+ es "Delete", "Borrar"
+ es "Error", "Error"
+ es "Exit", "Salir"
+ es "Green", "Verde"
+ es "Red", "Rojo"
+ es "blue", "azul"
+ es "green", "verde"
+ es "red", "rojo"
+}
+
+TkMsgCatalog.new('::tk') {
+ es "&Abort", "&Abortar"
+ es "About...", "Acerca de ..."
+ es "All Files", "Todos los archivos"
+ es "Application Error", "Error de la aplicaci\\u00f3n"
+ es "&Blue", "&Azul"
+ es "&Cancel", "&Cancelar"
+ es "Cannot change to the directory \"%1\$s\".\nPermission denied.", "No es posible acceder al directorio \"%1\$s\".\nPermiso denegado."
+ es "Choose Directory", "Elegir directorio"
+ es "Clear", "Borrar"
+ es "Color", "Color"
+ es "Console", "Consola"
+ es "Copy", "Copiar"
+ es "Cut", "Cortar"
+ es "Delete", "Borrar"
+ es "Details >>", "Detalles >>"
+ es "Directory \"%1\$s\" does not exist.", "El directorio \"%1\$s\" no existe."
+ es "&Directory:", "&Directorio:"
+ es "Error: %1\$s", "Error: %1\$s"
+ es "Exit", "Salir"
+ es "File \"%1\$s\" already exists.\nDo you want to overwrite it?", "El archivo \"%1\$s\" ya existe.\nDesea sobreescribirlo?"
+ es "File \"%1\$s\" already exists.\n\n", "El archivo \"%1\$s\" ya existe.\n\n"
+ es "File \"%1\$s\" does not exist.", "El archivo \"%1\$s\" no existe."
+ es "File &name:", "&Nombre de archivo:"
+ es "File &names:", "&Nombres de archivo:"
+ es "Files of &type:", "Archivos de &tipo:"
+ es "Fi&les:", "&Archivos:"
+ es "&Filter", "&Filtro"
+ es "Fil&ter:", "Fil&tro:"
+ es "&Green", "&Verde"
+ es "Hi", "Hola"
+ es "Hide Console", "Esconder la consola"
+ es "&Ignore", "&Ignorar"
+ es "Invalid file name \"%1\$s\".", "Nombre de archivo inv\\u00e1lido \"%1\$s\"."
+ es "Log Files", "Ficheros de traza"
+ es "&No", "&No"
+ es "&OK", "&OK"
+ es "Ok", "Ok"
+ es "Open", "Abrir"
+ es "&Open", "&Abrir"
+ es "Open Multiple Files", "Abrir m\\u00faltiples archivos"
+ es "Paste", "Pegar"
+ es "Quit", "Abandonar"
+ es "&Red", "&Rojo"
+ es "Replace existing file?", "Reemplazar el archivo existente?"
+ es "&Retry", "&Reintentar"
+ es "&Save", "&Salvar"
+ es "Save As", "Salvar como"
+ es "Save To Log", "Salvar al archivo de traza"
+ es "Select Log File", "Elegir un archivo de traza"
+ es "Select a file to source", "Seleccionar un archivo a evaluar"
+ es "&Selection:", "&Selecci\\u00f3n:"
+ es "Skip Messages", "Omitir los mensajes"
+ es "Source...", "Evaluar..."
+ es "Tcl Scripts", "Scripts Tcl"
+ es "Tcl for Windows", "Tcl para Windows"
+ es "Text Files", "Archivos de texto"
+ es "&Yes", "&S\\u00ed"
+ es "abort", "abortar"
+ es "blue", "azul"
+ es "cancel", "cancelar"
+ es "extension", "extensi\\u00f3n"
+ es "extensions", "extensiones"
+ es "green", "verde"
+ es "ignore", "ignorar"
+ es "ok", "ok"
+ es "red", "rojo"
+ es "retry", "reintentar"
+ es "yes", "s\\u00ed"
+}
diff --git a/jni/ruby/ext/tk/sample/msgs_rb/fr.msg b/jni/ruby/ext/tk/sample/msgs_rb/fr.msg
new file mode 100644
index 0000000..ea85cf1
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/msgs_rb/fr.msg
@@ -0,0 +1,84 @@
+TkMsgCatalog.new('::tkmsgcat_demo') {
+ fr 'Application Error', "Erreur d'application"
+ fr 'Blue', 'Bleu'
+ fr 'Color', 'Couleur'
+ fr 'Delete', 'Effacer'
+ fr 'Error', 'Erreur'
+ fr 'Exit', 'Quitter'
+ fr 'Green', 'Vert'
+ fr 'Red', 'Rouge'
+ fr 'blue', 'bleu'
+ fr 'green', 'vert'
+ fr 'red', 'rouge'
+}
+
+TkMsgCatalog.new('::tk') {
+ fr '&Abort', '&Annuler'
+ fr 'About...', '\u00c0 propos...'
+ fr 'All Files', 'Tous les fichiers'
+ fr 'Application Error', "Erreur d'application"
+ fr '&Blue', '&Bleu'
+ fr '&Cancel', '&Annuler'
+ fr 'Cannot change to the directory "%1\$s".' "\n" 'Permission denied.', 'Impossible d\'acc\u00e9der au r\u00e9pertoire "%1\$s".' "\n" 'Permission refus\u00e9e.'
+ fr 'Choose Directory', 'Choisir r\u00e9pertoire'
+ fr 'Clear', 'Effacer'
+ fr 'Color', 'Couleur'
+ fr 'Console'
+ fr 'Copy', 'Copier'
+ fr 'Cut', 'Couper'
+ fr 'Delete', 'Effacer'
+ fr 'Details >>', 'D\u00e9tails >>'
+ fr 'Directory "%1\$s" does not exist.', 'Le r\u00e9pertoire "%1\$s" n\'existe pas.'
+ fr '&Directory:', '&R\u00e9pertoire:'
+ fr 'Error: %1\$s', 'Erreur: %1\$s'
+ fr 'Exit', 'Quitter'
+ fr 'File "%1\$s" already exists.' "\n" 'Do you want to overwrite it?', 'Le fichier "%1\$s" existe d\u00e9j\u00e0.' "\n" 'Voulez-vous l\'\u00e9craser?'
+ fr 'File "%1\$s" already exists.' "\n\n", 'Le fichier "%1\$s" existe d\u00e9j\u00e0.' "\n\n"
+ fr 'File "%1\$s" does not exist.', 'Le fichier "%1\$s" n\'existe pas.'
+ fr 'File &name:', '&Nom de fichier:'
+ fr 'File &names:', '&Noms de fichiers:'
+ fr 'Files of &type:', '&Type de fichiers:'
+ fr 'Fi&les:', 'Fich&iers:'
+ fr '&Filter', '&Filtre'
+ fr 'Fil&ter:', 'Fil&tre:'
+ fr '&Green', '&Vert'
+ fr 'Hi', 'Salut'
+ fr 'Hide Console', 'Cacher la Console'
+ fr '&Ignore', '&Ignorer'
+ fr 'Invalid file name "%1\$s".', 'Nom de fichier invalide "%1\$s".'
+ fr 'Log Files', 'Fichiers de trace'
+ fr '&No', '&Non'
+ fr '&OK'
+ fr 'Ok'
+ fr 'Open', 'Ouvrir'
+ fr '&Open', '&Ouvrir'
+ fr 'Open Multiple Files', 'Ouvrir plusieurs fichiers'
+ fr 'Paste', 'Coller'
+ fr 'Quit', 'Quitter'
+ fr '&Red', '&Rouge'
+ fr 'Replace existing file?', 'Remplacer le fichier existant?'
+ fr '&Retry', '&R\u00e9-essayer'
+ fr '&Save', '&Sauvegarder'
+ fr 'Save As', 'Sauvegarder sous'
+ fr 'Save To Log', 'Sauvegarde au fichier de trace'
+ fr 'Select Log File', 'Choisir un fichier de trace'
+ fr 'Select a file to source', 'Choisir un fichier \u00e0 \u00e9valuer'
+ fr '&Selection:', '&S\u00e9lection:'
+ fr 'Skip Messages', 'Omettre les messages'
+ fr 'Source...', '\u00c9valuer...'
+ fr 'Tcl Scripts', 'Scripts Tcl'
+ fr 'Tcl for Windows', 'Tcl pour Windows'
+ fr 'Text Files', 'Fichiers texte'
+ fr '&Yes', '&Oui'
+ fr 'abort', 'abandonner'
+ fr 'blue', 'bleu'
+ fr 'cancel', 'annuler'
+ fr 'extension'
+ fr 'extensions'
+ fr 'green', 'vert'
+ fr 'ignore', 'ignorer'
+ fr 'ok'
+ fr 'red', 'rouge'
+ fr 'retry', 'r\u00e9essayer'
+ fr 'yes', 'oui'
+}
diff --git a/jni/ruby/ext/tk/sample/msgs_rb/it.msg b/jni/ruby/ext/tk/sample/msgs_rb/it.msg
new file mode 100644
index 0000000..a180bdb
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/msgs_rb/it.msg
@@ -0,0 +1,84 @@
+TkMsgCatalog.new('::tkmsgcat_demo') {
+ it "Application Error", "Errore dell' applicazione"
+ it "Blue", "Blu"
+ it "Color", "Colore"
+ it "Delete", "Incolla"
+ it "Error", "Errore"
+ it "Exit", "Esci"
+ it "Green", "Verde"
+ it "Red", "Rosso"
+ it "blue", "blu"
+ it "green", "verde"
+ it "red", "rosso"
+}
+
+TkMsgCatalog.new('::tk') {
+ it "&Abort", "&Interrompi"
+ it "About...", "Informazioni ..."
+ it "All Files", "Tutti i file"
+ it "Application Error", "Errore dell' applicazione"
+ it "&Blue", "&Blu"
+ it "&Cancel", "&Annulla"
+ it "Cannot change to the directory \"%1\$s\".\nPermission denied.", "Impossibile accedere alla directory \"%1\$s\".\nPermesso negato."
+ it "Choose Directory", "Scegli directory"
+ it "Clear", "Azzera"
+ it "Color", "Colore"
+ it "Console"
+ it "Copy", "Copia"
+ it "Cut", "Taglia"
+ it "Delete", "Incolla"
+ it "Details >>", "Dettagli >>"
+ it "Directory \"%1\$s\" does not exist.", "La directory \"%1\$s\" non esiste."
+ it "&Directory:"
+ it "Error: %1\$s", "Errore: %1\$s"
+ it "Exit", "Esci"
+ it "File \"%1\$s\" already exists.\nDo you want to overwrite it?", "Il file \"%1\$s\" esiste gi\\u00e0.\nVuoi sovrascriverlo?"
+ it "File \"%1\$s\" already exists.\n\n", "Il file \"%1\$s\" esiste gi\\u00e0.\n\n"
+ it "File \"%1\$s\" does not exist.", "Il file \"%1\$s\" non esiste."
+ it "File &name:", "&Nome del file:"
+ it "File &names:", "&Nomi dei file:"
+ it "Files of &type:", "File di &tipo:"
+ it "Fi&les:", "Fi&le:"
+ it "&Filter", "&Filtro"
+ it "Fil&ter:", "Fil&tro:"
+ it "&Green", "&Verde"
+ it "Hi", "Salve"
+ it "Hide Console", "Nascondi la console"
+ it "&Ignore", "&Ignora"
+ it "Invalid file name \"%1\$s\".", "Nome di file non valido \"%1\$s\"."
+ it "Log Files", "File di log"
+ it "&No"
+ it "&OK"
+ it "Ok"
+ it "&Open", "A&pri"
+ it "Open", "Apri"
+ it "Open Multiple Files", "Apri file multipli"
+ it "Paste", "Incolla"
+ it "Quit", "Esci"
+ it "&Red", "&Rosso"
+ it "Replace existing file?", "Sostituisci il file esistente?"
+ it "&Retry", "&Riprova"
+ it "&Save", "&Salva"
+ it "Save As", "Salva come"
+ it "Save To Log", "Salva il log"
+ it "Select Log File", "Scegli un file di log"
+ it "Select a file to source", "Scegli un file da eseguire"
+ it "&Selection:", "&Selezione:"
+ it "Skip Messages", "Salta i messaggi"
+ it "Source...", "Esegui..."
+ it "Tcl Scripts", "Scripts Tcl"
+ it "Tcl for Windows", "Tcl per Windows"
+ it "Text Files", "File di testo"
+ it "&Yes", "&Si"
+ it "abort", "interrompi"
+ it "blue", "blu"
+ it "cancel", "annulla"
+ it "extension", "estensione"
+ it "extensions", "estensioni"
+ it "green", "verde"
+ it "ignore", "ignora"
+ it "ok"
+ it "red", "rosso"
+ it "retry", "riprova"
+ it "yes", "si"
+}
diff --git a/jni/ruby/ext/tk/sample/msgs_rb/ja.msg b/jni/ruby/ext/tk/sample/msgs_rb/ja.msg
new file mode 100644
index 0000000..40587c1
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/msgs_rb/ja.msg
@@ -0,0 +1,13 @@
+TkMsgCatalog.new('::tkmsgcat_demo') {
+ ja 'Application Error', '\u30A2\u30D7\u30EA\u30B1\u30FC\u30B7\u30E7\u30F3\u30A8\u30E9\u30FC'
+ ja 'Blue', '\u9752'
+ ja 'Color', '\u80CC\u666F\u8272'
+ ja 'Delete', '\u6D88\u53BB'
+ ja 'Error', '\u30A8\u30E9\u30FC'
+ ja 'Exit', '\u7D42\u4E86'
+ ja 'Green', '\u7DD1'
+ ja 'Red', '\u8D64'
+ ja 'blue', '\u9752'
+ ja 'green', '\u7DD1'
+ ja 'red', '\u8D64'
+}
diff --git a/jni/ruby/ext/tk/sample/msgs_rb/nl.msg b/jni/ruby/ext/tk/sample/msgs_rb/nl.msg
new file mode 100644
index 0000000..24e41da
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/msgs_rb/nl.msg
@@ -0,0 +1,123 @@
+TkMsgCatalog.new('::tkmsgcat_demo') {
+ nl "Application Error", "Toepassingsfout"
+ nl "Blue", "Blauw"
+ nl "Color", "Kleur"
+ nl "Delete", "Wissen"
+ nl "Error", "Fout"
+ nl "Exit", "Be\\u00ebindigen"
+ nl "Green", "Groen"
+ nl "Red", "Rood"
+ nl "blue", "blauw"
+ nl "green", "groen"
+ nl "red", "rood"
+}
+
+TkMsgCatalog.new('::tk') {
+ nl "\"%1\$s\" must be an absolute pathname", "\"%1\$s\" moet een absolute pad-naam zijn"
+ nl "%1\$s is not a toplevel window", "%1\$s is geen toplevel window"
+ nl ", or", ", of"
+ nl "-default, -icon, -message, -parent, -title, or -type", "-default, -icon, -message, -parent, -title, of -type"
+ nl "-initialdir, -mustexist, -parent, or -title", "-initialdir, -mustexist, -parent, of -title"
+ nl "&Abort", "&Afbreken"
+ nl "About...", "Over..."
+ nl "All Files", "Alle Bestanden"
+ nl "Application Error", "Toepassingsfout"
+ nl "&Blue", "&Blauw"
+ nl "&Cancel", "&Annuleren"
+ nl "Cannot change to the directory \"%1\$s\".\nPermission denied.", "Kan niet naar map \"%1\$s\" gaan.\nU heeft hiervoor geen toestemming."
+ nl "Choose Directory", "Kies map"
+ nl "Clear", "Wissen"
+ nl "Clear entry, Press OK; Enter %1\$s, press OK", "Wis veld, Druk op OK; typ %1\$s in, druk op OK"
+ nl "&Clear Console", "&Wis Console"
+ nl "Color", "Kleur"
+ nl "Console"
+ nl "Copy", "Kopi\\u00ebren"
+ nl "Cut", "Knippen"
+ nl "Delete", "Wissen"
+ nl "Details"
+ nl "Details >>"
+ nl "Directory \"%1\$s\" does not exist.", "Map \"%1\$s\" bestaat niet."
+ nl "&Directory:", "&Map:"
+ nl "Edit", "Bewerken"
+ nl "Enter \"%1\$s\", press OK", "Typ \"%1\$s\", druk op OK"
+ nl "Enter \"%1\$s\", press OK, enter \"%2\$s\", press OK", "Typ \"%1\$s\", druk op OK, typ \"%2\$s\", druk op OK"
+ nl "Error: %1\$s", "Fout: %1\$s"
+ nl "Exit", "Be\\u00ebindigen"
+ nl "File", "Bestand"
+ nl "File \"%1\$s\" already exists.\n\n", "Bestand \"%1\$s\" bestaat al.\n\n"
+ nl "File \"%1\$s\" already exists.\nDo you want to overwrite it?", "Bestand \"%1\$s\" bestaat al.\nWilt u het overschrijven?"
+ nl "File \"%1\$s\" does not exist.", "Bestand \"%1\$s\" bestaat niet."
+ nl "File &name:", "Bestands&naam:"
+ nl "File &names:", "Bestands&namen:"
+ nl "Files of &type:", "Bestanden van het &type:"
+ nl "Fi&les:", "&Bestanden:"
+ nl "&Filter"
+ nl "Fil&ter:"
+ nl "&Green", "&Groen"
+ nl "Hi", "H\\u00e9"
+ nl "Hide Console", "Verberg Console"
+ nl "&Ignore", "&Negeren"
+ nl "Invalid file name \"%1\$s\".", "Ongeldige bestandsnaam \"%1\$s\"."
+ nl "Log Files", "Log Bestanden"
+ nl "&No", "&Nee"
+ nl "&OK"
+ nl "Ok"
+ nl "&Open", "&Openen"
+ nl "Open", "Openen"
+ nl "Open Multiple Files", "Open meerdere bestanden"
+ nl "Paste", "Plakken"
+ nl "Please press %1\$s", "Druk op %1\$s, A.U.B."
+ nl "Please press ok", "Druk op ok, A.U.B."
+ nl "Press Cancel", "Druk op Annuleren"
+ nl "Press Ok", "Druk op Ok"
+ nl "Quit", "Stoppen"
+ nl "&Red", "&Rood"
+ nl "Replace existing file?", "Vervang bestaand bestand?"
+ nl "&Retry", "&Herhalen"
+ nl "&Save", "Op&slaan"
+ nl "Save As", "Opslaan als"
+ nl "Save To Log", "Opslaan naar Log"
+ nl "Select Log File", "Selecteer Log bestand"
+ nl "Select a file to source", "Selecteer bronbestand"
+ nl "&Selection:", "&Selectie:"
+ nl "Skip Messages", "Berichten overslaan"
+ nl "Source...", "Bron..."
+ nl "Tcl Scripts"
+ nl "Tcl for Windows", "Tcl voor Windows"
+ nl "Text Files", "Tekstbestanden"
+ nl "&Yes", "&Ja"
+ nl "abort", "afbreken"
+ nl "abort, retry, ignore, ok, cancel, no, or yes", "afbreken, opnieuw, negeren, ok, annuleren, nee, of ja"
+ nl "abortretryignore, ok, okcancel, retrycancel, yesno, or yesnocancel", "abortretryignore, ok, okcancel, retrycancel, yesno, of yesnocancel"
+ nl "bad %1\$s value \"%2\$s\": must be %3\$s", "verkeerde %1\$s waarde \"%2\$s\": moet zijn %3\$s"
+ nl "bad file type \"%1\$s\", should be", "verkeerd bestandstype \"%1\$s\", moet zijn"
+ nl "bad option \"%1\$s\": should be %2\$s", "verkeerde optie \"%1\$s\": moet zijn %2\$s"
+ nl "bad window path name \"%1\$s\"", "verkeerde window-padnaam \"%1\$s\""
+ nl "blue", "blauw"
+ nl "can't post %1\$s: it isn't a descendant of %2\$s (this is a new requirement in Tk versions 3.0 and later)", "kan %1\$s niet verzenden: het is geen afstammeling van %2\$s (dit is een nieuwe eis in Tk versies 3.0 en later)"
+ nl "cancel", "annuleren"
+ nl "default button index greater than number of buttons specified for tk_dialog", "default knop index is groter dan het aantal knoppen beschikbaar voor tk_dialog"
+ nl "display name to use (current one otherwise)", "te gebruiken schermnaam (anders huidige scherm)"
+ nl "error, info, question, or warning", "error, info, question, of warning"
+ nl "extension"
+ nl "extensions"
+ nl "focus group \"%1\$s\" doesn't exist", "focusgroep \"%1\$s\" bestaat niet"
+ nl "green", "groen"
+ nl "history event %1\$s"
+ nl "ignore", "negeren"
+ nl "invalid default button \"%1\$s\"", "ongeldige default knop \"%1\$s\""
+ nl "macType"
+ nl "macTypes"
+ nl "must specify a background color", "een achtergrondkleur is verplicht"
+ nl "name of the slave interpreter", "naam van de slaaf-interpreter"
+ nl "no winfo screen . nor env(DISPLAY)", "geen winfo scherm . noch env(DISPLAY)"
+ nl "ok"
+ nl "red", "rood"
+ nl "retry", "opnieuw"
+ nl "should contain 5 or 4 elements", "moet 4 of 5 elementen bevatten"
+ nl "spec"
+ nl "tk_chooseDirectory command", "tk_chooseDirectory opdracht"
+ nl "tk_chooseDirectory command, cancel gives null", "tk_chooseDirectory opdracht, annuleren geeft lege waarde"
+ nl "tk_chooseDirectory command, initialdir", "tk_chooseDirectory opdracht, initi\\u00eble map"
+ nl "yes", "ja"
+}
diff --git a/jni/ruby/ext/tk/sample/msgs_rb/pl.msg b/jni/ruby/ext/tk/sample/msgs_rb/pl.msg
new file mode 100644
index 0000000..0b3b444
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/msgs_rb/pl.msg
@@ -0,0 +1,87 @@
+TkMsgCatalog.new('::tkmsgcat_demo') {
+ pl 'Application Error', 'Bl\u0105d w Programie'
+ pl 'Blue', 'Niebieski'
+ pl 'Color', 'Kolor'
+ pl 'Delete', 'Usu\u0144'
+ pl 'Error', 'B\u0142\u0105d'
+ pl 'Exit', 'Zako\u0144cz'
+ pl 'Green', 'Zielony'
+ pl 'Red', 'Czerwonz'
+ pl 'blue', 'niebieski'
+ pl 'green', 'zielony'
+ pl 'red', 'czerwony'
+}
+
+TkMsgCatalog.new('::tk') {
+ pl '&Abort', '&Anuluj'
+ pl '&About...', 'O Programie...'
+ pl 'All Files', 'Wszystkie pliki'
+ pl 'Application Error', 'Bl\u0105d w Programie'
+ pl '&Blue', '&Niebieski'
+ pl '&Cancel', '&Anuluj'
+ pl 'Cannot change to the directory "%1\$s".' "\n" 'Permission denied.', 'Katalog "%1\$s" nie mo\u017ce zosta\u0107 odczytany lub nie istnieje.'
+ pl 'Choose Directory', 'Wybierz katalog'
+ pl '&Clear', '&Wyczy\u015b\u0107'
+ pl '&Clear Console', '&Wyczy\u015b\u0107 konsol\u0119'
+ pl 'Color', 'Kolor'
+ pl 'Console', 'Konsola'
+ pl '&Copy', '&Kopiuj'
+ pl 'Cu&t', '&Wytnij'
+ pl '&Delete', '&Usu\u0144'
+ pl 'Details >>', 'Detale >>'
+ pl 'Directory "%1\$s" does not exist.', 'Katalog "%1\$s" nie istniej.'
+ pl '&Directory:', '&Katalog:'
+ pl '&Edit', '&Edytuj'
+ pl 'Error: %1\$s', 'B\u0142\u0105d: %1\$s'
+ pl 'E&xit', '&Zako\u0144cz'
+ pl '&File', '&Plik'
+ pl 'File "%1\$s" already exists.' "\n" 'Do you want to overwrite it?', 'Plik "%1\$s" ju\u017c istnieje.' "\n" 'Czy chcesz go zast\u0105pi\u0107?'
+ pl 'File "%1\$s" already exists.' "\n\n", 'Plik "%1\$s" ju\u017c istnieje. ' "\n\n"
+ pl 'File "%1\$s" does not exist.', 'Plik "%1\$s" nie istnieje.'
+ pl 'File &name:', 'Nazwa &pliku:'
+ pl 'File &names:', 'Nazwy &plik\u00f3w:'
+ pl 'Files of &type:', 'Pliki &typu:'
+ pl 'Fi&les:', 'Pli&ki:'
+ pl '&Filter', '&Filter'
+ pl 'Fil&ter:', '&Filter:'
+ pl '&Green', '&Zielony'
+ pl '&Help', '&Pomoc'
+ pl 'Hi', 'Witaj'
+ pl '&Hide Console', '&Schowaj konsol\u0119'
+ pl '&Ignore', '&Ignoruj'
+ pl 'Invalid file name "%1\$s".', 'Niew\u0142a\u015bciwa nazwa pliku "%1\$s".'
+ pl 'Log Files', 'Protoko\u0142uj'
+ pl '&No', '&Nie'
+ pl 'OK'
+ pl 'Ok'
+ pl 'Open', 'Wczytaj'
+ pl '&Open', '&Wczytaj'
+ pl 'Open Multiple Files', 'Wczytuj wiele plik\u00f3w'
+ pl 'P&aste', '&Wklej'
+ pl '&Quit', '&Zako\u0144cz'
+ pl '&Red', '&Czerwonz'
+ pl 'Replace existing file?', 'Czy zost\u0105pi\u0107 instniej\u0105cy plik?'
+ pl '&Retry', '&Powt\u00f3rz'
+ pl '&Save', '&Zapisz'
+ pl 'Save As', 'Zapisz jako'
+ pl 'Save To Log', 'Wpisz do protoko\u0142u'
+ pl 'Select Log File', 'Wybierz plik proko\u0142u'
+ pl 'Select a file to source', 'Wybierz plik do wykonania'
+ pl '&Selection:', '&Wyb\u00f3r:'
+ pl 'Skip Messages', 'Omi\u0144 pozosta\u0142e komunikaty'
+ pl '&Source...', '&Kod \u017ar\u00f3d\u0142owy...'
+ pl 'Tcl Scripts', 'Tcl-skrypty'
+ pl 'Tcl for Windows', 'Tcl dla Okienek (Windows)'
+ pl 'Text Files', 'Pliki Tekstowe'
+ pl '&Yes', '&Tak'
+ pl 'abort', 'zako\u0144cz'
+ pl 'blue', 'niebieski'
+ pl 'cancel', 'anuluj'
+ pl 'extension', 'rozszerzenie'
+ pl 'extensions', 'rozszerzenia'
+ pl 'green', 'zielony'
+ pl 'ignore', 'ignoruj'
+ pl 'red', 'czerwony'
+ pl 'retry', 'potw\u00f3rz'
+ pl 'yes', 'tak'
+}
diff --git a/jni/ruby/ext/tk/sample/msgs_rb/ru.msg b/jni/ruby/ext/tk/sample/msgs_rb/ru.msg
new file mode 100644
index 0000000..752cd42
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/msgs_rb/ru.msg
@@ -0,0 +1,87 @@
+TkMsgCatalog.new('::tkmsgcat_demo') {
+ ru 'Application Error', '\u041e\u0448\u0438\u0431\u043a\u0430 \u0432 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0435'
+ ru 'Blue', ' \u0413\u043e\u043b\u0443\u0431\u043e\u0439'
+ ru 'Color', '\u0426\u0432\u0435\u0442'
+ ru 'Delete', '\u0423\u0434\u0430\u043b\u0438\u0442\u044c'
+ ru 'Error', '\u041e\u0448\u0438\u0431\u043a\u0430'
+ ru 'Exit', '\u0412\u044b\u0445\u043e\u0434'
+ ru 'Green', '\u0417\u0435\u043b\u0435\u043d\u044b\u0439'
+ ru 'Red', '\u041a\u0440\u0430\u0441\u043d\u044b\u0439'
+ ru 'blue', ' \u0433\u043e\u043b\u0443\u0431\u043e\u0439'
+ ru 'green', ' \u0437\u0435\u043b\u0435\u043d\u044b\u0439'
+ ru 'red', ' \u043a\u0440\u0430\u0441\u043d\u044b\u0439'
+}
+
+TkMsgCatalog.new('::tk') {
+ ru '&Abort', '&\u041e\u0442\u043c\u0435\u043d\u0438\u0442\u044c'
+ ru 'About...', '\u041f\u0440\u043e...'
+ ru 'All Files', '\u0412\u0441\u0435 \u0444\u0430\u0439\u043b\u044b'
+ ru 'Application Error', '\u041e\u0448\u0438\u0431\u043a\u0430 \u0432 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0435'
+ ru '&Blue', ' &\u0413\u043e\u043b\u0443\u0431\u043e\u0439'
+ ru '&Cancel', '\u041e\u0442&\u043c\u0435\u043d\u0430'
+ ru 'Cannot change to the directory "%1\$s".' "\n" 'Permission denied.' \
+ '\u041d\u0435 \u043c\u043e\u0433\u0443 \u043f\u0435\u0440\u0435\u0439\u0442\u0438 \u0432 \u043a\u0430\u0442\u0430\u043b\u043e\u0433 "%1\$s".' "\n" '\u041d\u0435\u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u043f\u0440\u0430\u0432 \u0434\u043e\u0441\u0442\u0443\u043f\u0430'
+ ru 'Choose Directory', '\u0412\u044b\u0431\u0435\u0440\u0438\u0442\u0435 \u043a\u0430\u0442\u0430\u043b\u043e\u0433'
+ ru 'Clear', '\u041e\u0447\u0438\u0441\u0442\u0438\u0442\u044c'
+ ru 'Color', '\u0426\u0432\u0435\u0442'
+ ru 'Console', '\u041a\u043e\u043d\u0441\u043e\u043b\u044c'
+ ru 'Copy', '\u041a\u043e\u043f\u0438\u0440\u043e\u0432\u0430\u0442\u044c'
+ ru 'Cut', '\u0412\u044b\u0440\u0435\u0437\u0430\u0442\u044c'
+ ru 'Delete', '\u0423\u0434\u0430\u043b\u0438\u0442\u044c'
+ ru 'Details >>', '\u041f\u043e\u0434\u0440\u043e\u0431\u043d\u0435\u0435 >>'
+ ru 'Directory "%1\$s" does not exist.', '\u041a\u0430\u0442\u0430\u043b\u043e\u0433\u0430 "%1\$s" \u043d\u0435 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442.'
+ ru '&Directory:', '&\u041a\u0430\u0442\u0430\u043b\u043e\u0433:'
+ ru 'Error: %1\$s', '\u041e\u0448\u0438\u0431\u043a\u0430: %1\$s'
+ ru 'Exit', '\u0412\u044b\u0445\u043e\u0434'
+ ru 'File "%1\$s" already exists.' "\n" 'Do you want to overwrite it?' \
+ '\u0424\u0430\u0439\u043b "%1\$s" \u0443\u0436\u0435 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442.' "\n" '\u0417\u0430\u043c\u0435\u043d\u0438\u0442\u044c \u0435\u0433\u043e?'
+ ru 'File "%1\$s" already exists.' "\n\n", '\u0424\u0430\u0439\u043b "%1\$s" \u0443\u0436\u0435 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442.' "\n\n"
+ ru 'File "%1\$s" does not exist.', '\u0424\u0430\u0439\u043b "%1\$s" \u043d\u0435 \u043d\u0430\u0439\u0434\u0435\u043d.'
+ ru 'File &name:', '&\u0418\u043c\u044f \u0444\u0430\u0439\u043b\u0430:'
+ ru 'File &names:', '&\u0418\u043c\u0435\u043d\u0430 \u0444\u0430\u0439\u043b\u043e\u0432:'
+ ru 'Files of &type:', '&\u0422\u0438\u043f \u0444\u0430\u0439\u043b\u043e\u0432:'
+ ru 'Fi&les:', '\u0424\u0430\u0439&\u043b\u044b:'
+ ru '&Filter', '&\u0424\u0438\u043b\u044c\u0442\u0440'
+ ru 'Fil&ter:', '\u0424\u0438\u043b\u044c&\u0442\u0440:'
+ ru '&Green', ' &\u0417\u0435\u043b\u0435\u043d\u044b\u0439'
+ ru 'Hi', '\u041f\u0440\u0438\u0432\u0435\u0442'
+ ru 'Hide Console', '\u0421\u043f\u0440\u044f\u0442\u0430\u0442\u044c \u043a\u043e\u043d\u0441\u043e\u043b\u044c'
+ ru '&Ignore', '&\u0418\u0433\u043d\u043e\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c'
+ ru 'Invalid file name "%1\$s".', '\u041d\u0435\u0432\u0435\u0440\u043d\u043e\u0435 \u0438\u043c\u044f \u0444\u0430\u0439\u043b\u0430 "%1\$s".'
+ ru 'Log Files', '\u0424\u0430\u0439\u043b\u044b \u0436\u0443\u0440\u043d\u0430\u043b\u0430'
+ ru '&No', '&\u041d\u0435\u0442'
+ ru '&OK', '&\u041e\u041a'
+ ru 'Ok', '\u0414\u0430'
+ ru 'Open', '\u041e\u0442\u043a\u0440\u044b\u0442\u044c'
+ ru '&Open', '&\u041e\u0442\u043a\u0440\u044b\u0442\u044c'
+ ru 'Open Multiple Files', '\u041e\u0442\u043a\u0440\u044b\u0442\u044c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0444\u0430\u0439\u043b\u043e\u0432'
+ ru 'Paste', '\u0412\u0441\u0442\u0430\u0432\u0438\u0442\u044c'
+ ru 'Quit', '\u0412\u044b\u0445\u043e\u0434'
+ ru '&Red', ' &\u041a\u0440\u0430\u0441\u043d\u044b\u0439'
+ ru 'Replace existing file?', '\u0417\u0430\u043c\u0435\u043d\u0438\u0442\u044c \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0439 \u0444\u0430\u0439\u043b?'
+ ru '&Retry', '&\u041f\u043e\u0432\u0442\u043e\u0440\u0438\u0442\u044c'
+ ru '&Save', '&\u0421\u043e\u0445\u0440\u0430\u043d\u0438\u0442\u044c'
+ ru 'Save As', '\u0421\u043e\u0445\u0440\u0430\u043d\u0438\u0442\u044c \u043a\u0430\u043a'
+ ru 'Save To Log', '\u0421\u043e\u0445\u0440\u0430\u043d\u0438\u0442\u044c \u0432 \u0436\u0443\u0440\u043d\u0430\u043b'
+ ru 'Select Log File', '\u0412\u044b\u0431\u0440\u0430\u0442\u044c \u0436\u0443\u0440\u043d\u0430\u043b'
+ ru 'Select a file to source', '\u0412\u044b\u0431\u0435\u0440\u0438\u0442\u0435 \u0444\u0430\u0439\u043b \u0434\u043b\u044f \u0438\u043d\u0442\u0435\u0440\u043f\u0440\u0435\u0442\u0430\u0446\u0438\u0438'
+ ru '&Selection:', '&Selection:'
+ ru 'Skip Messages', '\u041f\u0440\u043e\u043f\u0443\u0441\u0442\u0438\u0442\u044c \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f'
+ ru 'Source...', '\u0418\u043d\u0442\u0435\u0440\u043f\u0440\u0435\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0444\u0430\u0439\u043b...'
+ ru 'Tcl Scripts', '\u041f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0430 \u043d\u0430 \u044f\u0437\u044b\u043a\u0435 TCL'
+ ru 'Tcl for Windows', 'TCL \u0434\u043b\u044f Windows'
+ ru 'Text Files', '\u0422\u0435\u043a\u0441\u0442\u043e\u0432\u044b\u0435 \u0444\u0430\u0439\u043b\u044b'
+ ru '&Yes', '&\u0414\u0430'
+ ru 'abort', '\u043e\u0442\u043c\u0435\u043d\u0430'
+ ru 'blue', ' \u0433\u043e\u043b\u0443\u0431\u043e\u0439'
+ ru 'cancel', '\u043e\u0442\u043c\u0435\u043d\u0430'
+ ru 'extension', '\u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u0435'
+ ru 'extensions', '\u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u044f'
+ ru 'green', ' \u0437\u0435\u043b\u0435\u043d\u044b\u0439'
+ ru 'ignore', '\u043f\u0440\u043e\u043f\u0443\u0441\u0442\u0438\u0442\u044c'
+ ru 'ok', '\u043e\u043a'
+ ru 'red', ' \u043a\u0440\u0430\u0441\u043d\u044b\u0439'
+ ru 'retry', '\u043f\u043e\u0432\u0442\u043e\u0440\u0438\u0442\u044c'
+ ru 'yes', '\u0434\u0430'
+}
+
diff --git a/jni/ruby/ext/tk/sample/msgs_rb2/README b/jni/ruby/ext/tk/sample/msgs_rb2/README
new file mode 100644
index 0000000..f6a904b
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/msgs_rb2/README
@@ -0,0 +1,5 @@
+Message catalogs in this directory are written in encodings except
+UTF-8. As if you have a trouble to edit UTF-8 text, you can write
+message catalogs in your familier encoding.
+
+Please see '../msgs_rb/README' too.
diff --git a/jni/ruby/ext/tk/sample/msgs_rb2/de.msg b/jni/ruby/ext/tk/sample/msgs_rb2/de.msg
new file mode 100644
index 0000000..0d6c82d
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/msgs_rb2/de.msg
@@ -0,0 +1,88 @@
+TkMsgCatalog.new('::tkmsgcat_demo') {
+ de 'Application Error', 'Applikationsfehler'
+ de 'Blue', 'Blau'
+ de 'Color', 'Farbe'
+ de 'Delete', 'Löschen', 'iso8859-1'
+ de 'Error', 'Fehler'
+ de 'Exit', 'Ende'
+ de 'Green', 'Grün', 'iso8859-1'
+ de 'Red', 'Rot'
+ de 'blue', 'blau'
+ de 'green', 'grün', 'iso8859-1'
+ de 'red', 'rot'
+}
+
+TkMsgCatalog.new('::tk') {
+ de "&Abort", "&Abbruch"
+ de "&About...", "&Über...", 'iso8859-1'
+ de "All Files", "Alle Dateien"
+ de "Application Error", "Applikationsfehler"
+ de "&Blue", "&Blau"
+ de "&Cancel", "&Abbruch"
+ de "Cannot change to the directory \"%1\$s\".\nPermission denied.", "Kann nicht in das Verzeichnis \"%1\$s\" wechseln.\nKeine Rechte vorhanden."
+ de "Choose Directory", "Wähle Verzeichnis", 'iso8859-1'
+ de "&Clear", "&Rücksetzen", 'iso8859-1'
+ de "&Clear Console", "&Konsole löschen", 'iso8859-1'
+ de "Color", "Farbe"
+ de "Console", "Konsole"
+ de "&Copy", "&Kopieren"
+ de "Cu&t", "Aus&schneiden"
+ de '&Delete', '&Löschen', 'iso8859-1'
+ de "Details >>"
+ de "Directory \"%1\$s\" does not exist.", "Das Verzeichnis \"%1\$s\" existiert nicht."
+ de "&Directory:", "&Verzeichnis:"
+ de "&Edit", "&Bearbieten"
+ de "Error: %1\$s", "Fehler: %1\$s"
+ de "E&xit", "&Ende"
+ de "&File", "&Datei"
+ de "File \"%1\$s\" already exists.\nDo you want to overwrite it?", "Die Datei \"%1\$s\" ist bereits vorhanden.\nWollen sie diese Datei überschreiben ?", 'iso8859-1'
+ de "File \"%1\$s\" already exists.\n\n", "Die Datei \"%1\$s\" ist bereits vorhanden.\n\n"
+ de "File \"%1\$s\" does not exist.", "Die Datei \"%1\$s\" existiert nicht."
+ de "File &name:", "Datei&name:"
+ de "File &names:", "Datei&namen:"
+ de "Files of &type:", "Dateien des &Typs:"
+ de "Fi&les:", "Dat&eien:"
+ de "&Filter"
+ de "Fil&ter:"
+ de '&Green', '&Grün', 'iso8859-1'
+ de "&Help", "&Hilfe"
+ de "Hi", "Hallo"
+ de "&Hide Console", "&Konsole unsichtbar machen"
+ de "&Ignore", "&Ignorieren"
+ de "Invalid file name \"%1\$s\".", "Ungültiger Dateiname \"%1\$s\".", 'iso8859-1'
+ de "Log Files", "Protokolldatei"
+ de "&No", "&Nein"
+ de "OK"
+ de "Ok"
+ de "Open", "Öffnen", 'iso8859-1'
+ de "&Open", "Ö&ffnen", 'iso8859-1'
+ de "Open Multiple Files"
+ de "P&aste", "E&infügen", 'iso8859-1'
+ de "&Quit", "&Beenden"
+ de "&Red", "&Rot"
+ de "Replace existing file?", "Existierende Datei ersetzen?"
+ de "&Retry", "&Wiederholen"
+ de "&Save", "&Speichern"
+ de "Save As", "Speichern unter"
+ de "Save To Log", "In Protokoll speichern"
+ de "Select Log File", "Protokolldatei auswählen", 'iso8859-1'
+ de "Select a file to source", "Auszuführende Datei auswählen", 'iso8859-1'
+ de "&Selection:", "Auswah&l:"
+ de "Skip Messages", "Weitere Nachrichten überspringen", 'iso8859-1'
+ de "&Source...", "&Ausführen...", 'iso8859-1'
+ de "Tcl Scripts", "Tcl-Skripte"
+ de "Tcl for Windows", "Tcl für Windows", 'iso8859-1'
+ de "Text Files", "Textdateien"
+ de "&Yes", "&Ja"
+ de "abort", "abbrechen"
+ de "blue", "blau"
+ de "cancel", "abbrechen"
+ de "extension", "Erweiterung"
+ de "extensions", "Erweiterungen"
+ de 'green', 'grün', 'iso8859-1'
+ de "ignore", "ignorieren"
+ de "ok"
+ de "red", "rot"
+ de "retry", "wiederholen"
+ de "yes", "ja"
+}
diff --git a/jni/ruby/ext/tk/sample/msgs_rb2/ja.msg b/jni/ruby/ext/tk/sample/msgs_rb2/ja.msg
new file mode 100644
index 0000000..54a105b
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/msgs_rb2/ja.msg
@@ -0,0 +1,85 @@
+TkMsgCatalog.new('::tkmsgcat_demo') {
+ ja 'Application Error', 'アプリケーションエラー', 'utf-8'
+ ja 'Blue', 'é’', 'utf-8'
+ ja 'Color', '色é¸æŠž', 'utf-8'
+ ja 'Delete', '消去', 'utf-8'
+ ja 'Error', 'エラー', 'utf-8'
+ ja 'Exit', '終了', 'utf-8'
+ ja 'Green', 'ç·‘', 'utf-8'
+ ja 'Red', '赤', 'utf-8'
+ ja 'blue', 'é’', 'utf-8'
+ ja 'green', 'ç·‘', 'utf-8'
+ ja 'red', '赤', 'utf-8'
+}
+
+TkMsgCatalog.new('::tk') {
+ ja "&Abort", '中止', 'utf-8'
+ ja "About..."
+ ja "All Files", 'ã™ã¹ã¦ã®ãƒ•ã‚¡ã‚¤ãƒ«', 'utf-8'
+ ja "Application Error", 'アプリケーションエラー', 'utf-8'
+ ja "&Blue", 'é’', 'utf-8'
+ ja "&Cancel", 'å–り消ã—', 'utf-8'
+ ja "Cannot change to the directory \"%1\$s\".\nPermission denied.", "ディレクトリ \"%1\$s\" ã«å¤‰æ›´ã§ãã¾ã›ã‚“.\n許å¯ãŒã‚ã‚Šã¾ã›ã‚“.", 'utf-8'
+ ja "Choose Directory", 'ディレクトリをé¸æŠž', 'utf-8'
+ ja "Clear", '消去', 'utf-8'
+ ja "Color", '色', 'utf-8'
+ ja "Console", 'コンソール', 'utf-8'
+ ja "Copy", 'コピー', 'utf-8'
+ ja "Cut", '切りå–ã‚Š', 'utf-8'
+ ja "Delete", '消去', 'utf-8'
+ ja "Details >>", '詳細 >>', 'utf-8'
+ ja "Directory \"%1\$s\" does not exist.", '"%1$s" ã¨ã„ã†ãƒ‡ã‚£ãƒ¬ã‚¯ãƒˆãƒªã¯å­˜åœ¨ã—ã¾ã›ã‚“.', 'utf-8'
+ ja "&Directory:", 'ディレクトリ', 'utf-8'
+ ja "Error: %1\$s"
+ ja "Exit", '終了', 'utf-8'
+ ja "File \"%1\$s\" already exists.\nDo you want to overwrite it?", "\"%1\$s\" ã¨ã„ã†ãƒ•ã‚¡ã‚¤ãƒ«ã¯æ—¢ã«å­˜åœ¨ã—ã¦ã„ã¾ã™ï¼Ž\n書ãæ›ãˆã¾ã™ã‹ï¼Ÿ", 'utf-8'
+ ja "File \"%1\$s\" already exists.\n\n", "\"%1\$s\" ã¨ã„ã†ãƒ•ã‚¡ã‚¤ãƒ«ã¯æ—¢ã«å­˜åœ¨ã—ã¦ã„ã¾ã™ï¼Ž\n\n", 'utf-8'
+ ja "File \"%1\$s\" does not exist.", '"%1$s" ã¨ã„ã†ãƒ•ã‚¡ã‚¤ãƒ«ã¯å­˜åœ¨ã—ã¾ã›ã‚“.', 'utf-8'
+ ja "File &name:", 'ファイルå', 'utf-8'
+ ja "File &names:", 'ファイルå', 'utf-8'
+ ja "Files of &type:", 'ファイル形å¼', 'utf-8'
+ ja "Fi&les:", 'ファイル', 'utf-8'
+ ja "&Filter", 'フィルター', 'utf-8'
+ ja "Fil&ter:", 'フィルター', 'utf-8'
+ ja "&Green", 'ç·‘', 'utf-8'
+ ja "Hi", 'ã“ã‚“ã«ã¡ã¯', 'utf-8'
+ ja "Hide Console", 'コンソールを隠ã™', 'utf-8'
+ ja "&Ignore", '無視', 'utf-8'
+ ja "Invalid file name \"%1\$s\".", '"%1$s" ã¯ä¸æ­£ãªãƒ•ã‚¡ã‚¤ãƒ«åã§ã™ï¼Ž', 'utf-8'
+ ja "Log Files", 'ログファイル', 'utf-8'
+ ja "&No", 'ã„ã„ãˆ', 'utf-8'
+ ja "&OK", '了解', 'utf-8'
+ ja "OK", '了解', 'utf-8'
+ ja "Ok", '了解', 'utf-8'
+ ja "Open", 'é–‹ã', 'utf-8'
+ ja "&Open", 'é–‹ã', 'utf-8'
+ ja "Open Multiple Files", '複数ã®ãƒ•ã‚¡ã‚¤ãƒ«ã‚’é–‹ã', 'utf-8'
+ ja "Paste", '貼り付ã‘', 'utf-8'
+ ja "Quit", '終了', 'utf-8'
+ ja "&Red", '赤', 'utf-8'
+ ja "Replace existing file?", '既存ã®ãƒ•ã‚¡ã‚¤ãƒ«ã‚’ç½®ãæ›ãˆã¾ã™ã‹ï¼Ÿ', 'utf-8'
+ ja "&Retry", 'å†å®Ÿè¡Œ', 'utf-8'
+ ja "&Save", 'ä¿å­˜', 'utf-8'
+ ja "Save As", 'åå‰ã‚’付ã‘ã¦ä¿å­˜', 'utf-8'
+ ja "Save To Log", 'ログをä¿å­˜', 'utf-8'
+ ja "Select Log File", 'ログファイルをé¸æŠž', 'utf-8'
+ ja "Select a file to source", 'ソースファイルをé¸æŠž', 'utf-8'
+ ja "&Selection:", 'é¸æŠž', 'utf-8'
+ ja "Skip Messages", 'メッセージをã¨ã°ã™', 'utf-8'
+ ja "Source...", 'ソース...', 'utf-8'
+ ja "Tcl Scripts", 'Tcl スクリプト', 'utf-8'
+ ja "Tcl for Windows"
+ ja "Text Files", 'テキストファイル', 'utf-8'
+ ja "&Yes", 'ã¯ã„', 'utf-8'
+ ja "abort", '中止', 'utf-8'
+ ja "blue", 'é’', 'utf-8'
+ ja "cancel", 'å–り消ã—', 'utf-8'
+ ja "extension", 'æ‹¡å¼µå­', 'utf-8'
+ ja "extensions", 'æ‹¡å¼µå­', 'utf-8'
+ ja "green", 'ç·‘', 'utf-8'
+ ja "ignore", '無視', 'utf-8'
+ ja "ok", '了解', 'utf-8'
+ ja "red", '赤', 'utf-8'
+ ja "retry", 'å†å®Ÿè¡Œ', 'utf-8'
+ ja "yes", 'ã¯ã„', 'utf-8'
+}
diff --git a/jni/ruby/ext/tk/sample/msgs_tk/README b/jni/ruby/ext/tk/sample/msgs_tk/README
new file mode 100644
index 0000000..949ee7a
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/msgs_tk/README
@@ -0,0 +1,4 @@
+Almost all of Message-Catalog files in this directory are quoted
+from Tcl/Tk8.5a1 source archive (only a little are modified for
+'tkmsgcat-load_tk.rb'). Please read the file 'license.terms' in
+this directory (That was included in demo directory of Tcl/Tk8.5a1).
diff --git a/jni/ruby/ext/tk/sample/msgs_tk/cs.msg b/jni/ruby/ext/tk/sample/msgs_tk/cs.msg
new file mode 100644
index 0000000..6970709
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/msgs_tk/cs.msg
@@ -0,0 +1,84 @@
+namespace eval ::tkmsgcat_demo {
+ ::msgcat::mcset cs "Application Error" "Chyba programu"
+ ::msgcat::mcset cs "Blue" "Modr\341"
+ ::msgcat::mcset cs "Color" "Barva"
+ ::msgcat::mcset cs "Delete" "Smazat"
+ ::msgcat::mcset cs "Error" "Chyba"
+ ::msgcat::mcset cs "Exit" "Konec"
+ ::msgcat::mcset cs "Green" "Zelen\341"
+ ::msgcat::mcset cs "Red" "\u010cerven\341"
+ ::msgcat::mcset cs "blue" "modr\341"
+ ::msgcat::mcset cs "green" "zelen\341"
+ ::msgcat::mcset cs "red" "\u010derven\341"
+}
+
+namespace eval ::tk {
+ ::msgcat::mcset cs "&Abort" "&P\u0159eru\u0161it"
+ ::msgcat::mcset cs "About..." "O programu..."
+ ::msgcat::mcset cs "All Files" "V\u0161echny soubory"
+ ::msgcat::mcset cs "Application Error" "Chyba programu"
+ ::msgcat::mcset cs "&Blue" "&Modr\341"
+ ::msgcat::mcset cs "&Cancel" "&Zru\u0161it"
+ ::msgcat::mcset cs "Cannot change to the directory \"%1\$s\".\nPermission denied." "Nemohu zm\u011bnit atku\341ln\355 adres\341\u0159 na \"%1\$s\".\nP\u0159\355stup odm\355tnut."
+ ::msgcat::mcset cs "Choose Directory" "V\375b\u011br adres\341\u0159e"
+ ::msgcat::mcset cs "Clear" "Smazat"
+ ::msgcat::mcset cs "Color" "Barva"
+ ::msgcat::mcset cs "Console" "Konzole"
+ ::msgcat::mcset cs "Copy" "Kop\355rovat"
+ ::msgcat::mcset cs "Cut" "Vy\u0159\355znout"
+ ::msgcat::mcset cs "Delete" "Smazat"
+ ::msgcat::mcset cs "Details >>" "Detaily >>"
+ ::msgcat::mcset cs "Directory \"%1\$s\" does not exist." "Adres\341\u0159 \"%1\$s\" neexistuje."
+ ::msgcat::mcset cs "&Directory:" "&Adres\341\u0159:"
+ ::msgcat::mcset cs "Error: %1\$s" "Chyba: %1\$s"
+ ::msgcat::mcset cs "Exit" "Konec"
+ ::msgcat::mcset cs "File \"%1\$s\" already exists.\n\n" "Soubor \"%1\$s\" ji\u017e existuje.\n\n"
+ ::msgcat::mcset cs "File \"%1\$s\" already exists.\nDo you want to overwrite it?" "Soubor \"%1\$s\" ji\u017e existuje.\nChcete jej p\u0159epsat?"
+ ::msgcat::mcset cs "File \"%1\$s\" does not exist." "Soubor \"%1\$s\" neexistuje."
+ ::msgcat::mcset cs "File &name:" "&Jm\351no souboru:"
+ ::msgcat::mcset cs "File &names:" "&Jm\351na soubor\u016f:"
+ ::msgcat::mcset cs "Files of &type:" "&Typy soubor\u016f:"
+ ::msgcat::mcset cs "Fi&les:" "Sou&bory:"
+ ::msgcat::mcset cs "&Filter" "&Filtr"
+ ::msgcat::mcset cs "Fil&ter:" "Fil&tr:"
+ ::msgcat::mcset cs "&Green" "Ze&len\341"
+ ::msgcat::mcset cs "Hi"
+ ::msgcat::mcset cs "Hide Console" "Skr\375t konsolu"
+ ::msgcat::mcset cs "&Ignore" "&Ignorovat"
+ ::msgcat::mcset cs "Invalid file name \"%1\$s\"." "\u0160patn\351 jm\351no souboru \"%1\$s\"."
+ ::msgcat::mcset cs "Log Files" "Log soubory"
+ ::msgcat::mcset cs "&No" "&Ne"
+ ::msgcat::mcset cs "&OK"
+ ::msgcat::mcset cs "Ok"
+ ::msgcat::mcset cs "Open" "Otev\u0159\355t"
+ ::msgcat::mcset cs "&Open" "&Otev\u0159\355t"
+ ::msgcat::mcset cs "Open Multiple Files" "Otev\u0159\355t v\355ce soubor\u016f"
+ ::msgcat::mcset cs "Paste" "Vlo\u017eit"
+ ::msgcat::mcset cs "Quit" "Skon\u010dit"
+ ::msgcat::mcset cs "&Red" " \u010ce&rven\341"
+ ::msgcat::mcset cs "Replace existing file?" "Nahradit st\341vaj\355c\355 soubor?"
+ ::msgcat::mcset cs "&Retry" "Z&novu"
+ ::msgcat::mcset cs "&Save" "&Ulo\u017eit"
+ ::msgcat::mcset cs "Save As" "Ulo\u017eit jako"
+ ::msgcat::mcset cs "Save To Log" "Ulo\u017eit do logu"
+ ::msgcat::mcset cs "Select Log File" "Vybrat log soubor"
+ ::msgcat::mcset cs "Select a file to source" "Vybrat soubor k nahr\341n\355"
+ ::msgcat::mcset cs "&Selection:" "&V\375b\u011br:"
+ ::msgcat::mcset cs "Skip Messages" "P\u0159esko\u010dit zpr\341vy"
+ ::msgcat::mcset cs "Source..." "Nahr\341t..."
+ ::msgcat::mcset cs "Tcl Scripts" "Tcl skripty"
+ ::msgcat::mcset cs "Tcl for Windows" "Tcl pro Windows"
+ ::msgcat::mcset cs "Text Files" "Textov\351 soubory"
+ ::msgcat::mcset cs "&Yes" "&Ano"
+ ::msgcat::mcset cs "abort" "p\u0159eru\u0161it"
+ ::msgcat::mcset cs "blue" "modr\341"
+ ::msgcat::mcset cs "cancel" "zru\u0161it"
+ ::msgcat::mcset cs "extension" "p\u0159\355pona"
+ ::msgcat::mcset cs "extensions" "p\u0159\355pony"
+ ::msgcat::mcset cs "green" "zelen\341"
+ ::msgcat::mcset cs "ignore" "ignorovat"
+ ::msgcat::mcset cs "ok"
+ ::msgcat::mcset cs "red" "\u010derven\341"
+ ::msgcat::mcset cs "retry" "znovu"
+ ::msgcat::mcset cs "yes" "ano"
+}
diff --git a/jni/ruby/ext/tk/sample/msgs_tk/de.msg b/jni/ruby/ext/tk/sample/msgs_tk/de.msg
new file mode 100644
index 0000000..437f2ed
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/msgs_tk/de.msg
@@ -0,0 +1,88 @@
+namespace eval ::tkmsgcat_demo {
+ ::msgcat::mcset de "Application Error" "Applikationsfehler"
+ ::msgcat::mcset de "Blue" "Blau"
+ ::msgcat::mcset de "Color" "Farbe"
+ ::msgcat::mcset de "Delete" "L\u00f6schen"
+ ::msgcat::mcset de "Error" "Fehler"
+ ::msgcat::mcset de "Exit" "Ende"
+ ::msgcat::mcset de "Green" "Gr\u00fcn"
+ ::msgcat::mcset de "Red" "Rot"
+ ::msgcat::mcset de "blue" "blau"
+ ::msgcat::mcset de "green" "gr\u00fcn"
+ ::msgcat::mcset de "red" "rot"
+}
+
+namespace eval ::tk {
+ ::msgcat::mcset de "&Abort" "&Abbruch"
+ ::msgcat::mcset de "&About..." "&\u00dcber..."
+ ::msgcat::mcset de "All Files" "Alle Dateien"
+ ::msgcat::mcset de "Application Error" "Applikationsfehler"
+ ::msgcat::mcset de "&Blue" "&Blau"
+ ::msgcat::mcset de "&Cancel" "&Abbruch"
+ ::msgcat::mcset de "Cannot change to the directory \"%1\$s\".\nPermission denied." "Kann nicht in das Verzeichnis \"%1\$s\" wechseln.\nKeine Rechte vorhanden."
+ ::msgcat::mcset de "Choose Directory" "W\u00e4hle Verzeichnis"
+ ::msgcat::mcset de "&Clear" "&R\u00fccksetzen"
+ ::msgcat::mcset de "&Clear Console" "&Konsole l\u00f6schen"
+ ::msgcat::mcset de "Color" "Farbe"
+ ::msgcat::mcset de "Console" "Konsole"
+ ::msgcat::mcset de "&Copy" "&Kopieren"
+ ::msgcat::mcset de "Cu&t" "Aus&schneiden"
+ ::msgcat::mcset de "&Delete" "&L\u00f6schen"
+ ::msgcat::mcset de "Details >>"
+ ::msgcat::mcset de "Directory \"%1\$s\" does not exist." "Das Verzeichnis \"%1\$s\" existiert nicht."
+ ::msgcat::mcset de "&Directory:" "&Verzeichnis:"
+ ::msgcat::mcset de "&Edit" "&Bearbieten"
+ ::msgcat::mcset de "Error: %1\$s" "Fehler: %1\$s"
+ ::msgcat::mcset de "E&xit" "&Ende"
+ ::msgcat::mcset de "&File" "&Datei"
+ ::msgcat::mcset de "File \"%1\$s\" already exists.\nDo you want to overwrite it?" "Die Datei \"%1\$s\" ist bereits vorhanden.\nWollen sie diese Datei \u00fcberschreiben ?"
+ ::msgcat::mcset de "File \"%1\$s\" already exists.\n\n" "Die Datei \"%1\$s\" ist bereits vorhanden.\n\n"
+ ::msgcat::mcset de "File \"%1\$s\" does not exist." "Die Datei \"%1\$s\" existiert nicht."
+ ::msgcat::mcset de "File &name:" "Datei&name:"
+ ::msgcat::mcset de "File &names:" "Datei&namen:"
+ ::msgcat::mcset de "Files of &type:" "Dateien des &Typs:"
+ ::msgcat::mcset de "Fi&les:" "Dat&eien:"
+ ::msgcat::mcset de "&Filter"
+ ::msgcat::mcset de "Fil&ter:"
+ ::msgcat::mcset de "&Green" "&Gr\u00fcn"
+ ::msgcat::mcset de "&Help" "&Hilfe"
+ ::msgcat::mcset de "Hi" "Hallo"
+ ::msgcat::mcset de "&Hide Console" "&Konsole unsichtbar machen"
+ ::msgcat::mcset de "&Ignore" "&Ignorieren"
+ ::msgcat::mcset de "Invalid file name \"%1\$s\"." "Ung\u00fcltiger Dateiname \"%1\$s\"."
+ ::msgcat::mcset de "Log Files" "Protokolldatei"
+ ::msgcat::mcset de "&No" "&Nein"
+ ::msgcat::mcset de "OK"
+ ::msgcat::mcset de "Ok"
+ ::msgcat::mcset de "Open" "\u00d6ffnen"
+ ::msgcat::mcset de "&Open" "\u00d6&ffnen"
+ ::msgcat::mcset de "Open Multiple Files"
+ ::msgcat::mcset de "P&aste" "E&inf\u00fcgen"
+ ::msgcat::mcset de "&Quit" "&Beenden"
+ ::msgcat::mcset de "&Red" "&Rot"
+ ::msgcat::mcset de "Replace existing file?" "Existierende Datei ersetzen?"
+ ::msgcat::mcset de "&Retry" "&Wiederholen"
+ ::msgcat::mcset de "&Save" "&Speichern"
+ ::msgcat::mcset de "Save As" "Speichern unter"
+ ::msgcat::mcset de "Save To Log" "In Protokoll speichern"
+ ::msgcat::mcset de "Select Log File" "Protokolldatei ausw\u00e4hlen"
+ ::msgcat::mcset de "Select a file to source" "Auszuf\u00fchrende Datei ausw\u00e4hlen"
+ ::msgcat::mcset de "&Selection:" "Auswah&l:"
+ ::msgcat::mcset de "Skip Messages" "Weitere Nachrichten \u00fcberspringen"
+ ::msgcat::mcset de "&Source..." "&Ausf\u00fchren..."
+ ::msgcat::mcset de "Tcl Scripts" "Tcl-Skripte"
+ ::msgcat::mcset de "Tcl for Windows" "Tcl f\u00fcr Windows"
+ ::msgcat::mcset de "Text Files" "Textdateien"
+ ::msgcat::mcset de "&Yes" "&Ja"
+ ::msgcat::mcset de "abort" "abbrechen"
+ ::msgcat::mcset de "blue" "blau"
+ ::msgcat::mcset de "cancel" "abbrechen"
+ ::msgcat::mcset de "extension" "Erweiterung"
+ ::msgcat::mcset de "extensions" "Erweiterungen"
+ ::msgcat::mcset de "green" "gr\u00fcn"
+ ::msgcat::mcset de "ignore" "ignorieren"
+ ::msgcat::mcset de "ok"
+ ::msgcat::mcset de "red" "rot"
+ ::msgcat::mcset de "retry" "wiederholen"
+ ::msgcat::mcset de "yes" "ja"
+}
diff --git a/jni/ruby/ext/tk/sample/msgs_tk/el.msg b/jni/ruby/ext/tk/sample/msgs_tk/el.msg
new file mode 100644
index 0000000..ee75af3
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/msgs_tk/el.msg
@@ -0,0 +1,103 @@
+namespace eval ::tkmsgcat_demo {
+ ::msgcat::mcset el "Application Error" "\u039b\u03ac\u03b8\u03bf\u03c2 \u0395\u03c6\u03b1\u03c1\u03bc\u03bf\u03b3\u03ae\u03c2"
+ ::msgcat::mcset el "Blue" "\u039c\u03c0\u03bb\u03b5"
+ ::msgcat::mcset el "Color" "\u03a7\u03c1\u03ce\u03bc\u03b1"
+ ::msgcat::mcset el "Delete" "\u0394\u03b9\u03b1\u03b3\u03c1\u03b1\u03c6\u03ae"
+ ::msgcat::mcset el "Error" "\u039b\u03ac\u03b8\u03bf\u03c2"
+ ::msgcat::mcset el "Exit" "\u0388\u03be\u03bf\u03b4\u03bf\u03c2"
+ ::msgcat::mcset el "Green" "\u03a0\u03c1\u03ac\u03c3\u03b9\u03bd\u03bf"
+ ::msgcat::mcset el "Red" "\u039a\u03cc\u03ba\u03ba\u03b9\u03bd\u03bf"
+ ::msgcat::mcset el "blue" "\u03bc\u03c0\u03bb\u03b5"
+ ::msgcat::mcset el "green" "\u03c0\u03c1\u03ac\u03c3\u03b9\u03bd\u03bf"
+ ::msgcat::mcset el "red" "\u03ba\u03cc\u03ba\u03ba\u03b9\u03bd\u03bf"
+}
+
+
+# followings are same to original file included into Tk8.5a1's widget demos.
+
+## Messages for the Greek (Hellenic - "el") language.
+## Please report any changes/suggestions to:
+## petasis@iit.demokritos.gr
+
+namespace eval ::tk {
+ ::msgcat::mcset el "&Abort" "\u03a4\u03b5\u03c1\u03bc\u03b1\u03c4\u03b9\u03c3\u03bc\u03cc\u03c2"
+ ::msgcat::mcset el "About..." "\u03a3\u03c7\u03b5\u03c4\u03b9\u03ba\u03ac..."
+ ::msgcat::mcset el "All Files" "\u038c\u03bb\u03b1 \u03c4\u03b1 \u0391\u03c1\u03c7\u03b5\u03af\u03b1"
+ ::msgcat::mcset el "Application Error" "\u039b\u03ac\u03b8\u03bf\u03c2 \u0395\u03c6\u03b1\u03c1\u03bc\u03bf\u03b3\u03ae\u03c2"
+ ::msgcat::mcset el "&Blue" "\u039c\u03c0\u03bb\u03b5"
+ ::msgcat::mcset el "&Cancel" "\u0391\u03ba\u03cd\u03c1\u03c9\u03c3\u03b7"
+ ::msgcat::mcset el \
+"Cannot change to the directory \"%1\$s\".\nPermission denied." \
+"\u0394\u03b5\u03bd \u03b5\u03af\u03bd\u03b1\u03b9 \u03b4\u03c5\u03bd\u03b1\u03c4\u03ae \u03b7 \u03b1\u03bb\u03bb\u03b1\u03b3\u03ae \u03ba\u03b1\u03c4\u03b1\u03bb\u03cc\u03b3\u03bf\u03c5 \u03c3\u03b5 \"%1\$s\".\n\u0397 \u03c0\u03c1\u03cc\u03c3\u03b2\u03b1\u03c3\u03b7 \u03b4\u03b5\u03bd \u03b5\u03c0\u03b9\u03c4\u03c1\u03ad\u03c0\u03b5\u03c4\u03b1\u03b9."
+ ::msgcat::mcset el "Choose Directory" "\u0395\u03c0\u03b9\u03bb\u03bf\u03b3\u03ae \u039a\u03b1\u03c4\u03b1\u03bb\u03cc\u03b3\u03bf\u03c5"
+ ::msgcat::mcset el "Clear" "\u039a\u03b1\u03b8\u03b1\u03c1\u03b9\u03c3\u03bc\u03cc\u03c2"
+ ::msgcat::mcset el "Color" "\u03a7\u03c1\u03ce\u03bc\u03b1"
+ ::msgcat::mcset el "Console" "\u039a\u03bf\u03bd\u03c3\u03cc\u03bb\u03b1"
+ ::msgcat::mcset el "Copy" "\u0391\u03bd\u03c4\u03b9\u03b3\u03c1\u03b1\u03c6\u03ae"
+ ::msgcat::mcset el "Cut" "\u0391\u03c0\u03bf\u03ba\u03bf\u03c0\u03ae"
+ ::msgcat::mcset el "Delete" "\u0394\u03b9\u03b1\u03b3\u03c1\u03b1\u03c6\u03ae"
+ ::msgcat::mcset el "Details >>" "\u039b\u03b5\u03c0\u03c4\u03bf\u03bc\u03ad\u03c1\u03b5\u03b9\u03b5\u03c2 >>"
+ ::msgcat::mcset el "Directory \"%1\$s\" does not exist." \
+ "\u039f \u03ba\u03b1\u03c4\u03ac\u03bb\u03bf\u03b3\u03bf\u03c2 \"%1\$s\" \u03b4\u03b5\u03bd \u03c5\u03c0\u03ac\u03c1\u03c7\u03b5\u03b9."
+ ::msgcat::mcset el "&Directory:" "&\u039a\u03b1\u03c4\u03ac\u03bb\u03bf\u03b3\u03bf\u03c2:"
+ ::msgcat::mcset el "Error: %1\$s" "\u039b\u03ac\u03b8\u03bf\u03c2: %1\$s"
+ ::msgcat::mcset el "Exit" "\u0388\u03be\u03bf\u03b4\u03bf\u03c2"
+ ::msgcat::mcset el \
+ "File \"%1\$s\" already exists.\nDo you want to overwrite it?" \
+ "\u03a4\u03bf \u03b1\u03c1\u03c7\u03b5\u03af\u03bf \"%1\$s\" \u03ae\u03b4\u03b7 \u03c5\u03c0\u03ac\u03c1\u03c7\u03b5\u03b9.\n\u0398\u03ad\u03bb\u03b5\u03c4\u03b5 \u03bd\u03b1 \u03b5\u03c0\u03b9\u03ba\u03b1\u03bb\u03c5\u03c6\u03b8\u03b5\u03af;"
+ ::msgcat::mcset el "File \"%1\$s\" already exists.\n\n" \
+ "\u03a4\u03bf \u03b1\u03c1\u03c7\u03b5\u03af\u03bf \"%1\$s\" \u03ae\u03b4\u03b7 \u03c5\u03c0\u03ac\u03c1\u03c7\u03b5\u03b9.\n\n"
+ ::msgcat::mcset el "File \"%1\$s\" does not exist." \
+ "\u03a4\u03bf \u03b1\u03c1\u03c7\u03b5\u03af\u03bf \"%1\$s\" \u03b4\u03b5\u03bd \u03c5\u03c0\u03ac\u03c1\u03c7\u03b5\u03b9."
+ ::msgcat::mcset el "File &name:" "\u038c&\u03bd\u03bf\u03bc\u03b1 \u03b1\u03c1\u03c7\u03b5\u03af\u03bf\u03c5:"
+ ::msgcat::mcset el "File &names:" "\u038c&\u03bd\u03bf\u03bc\u03b1 \u03b1\u03c1\u03c7\u03b5\u03af\u03c9\u03bd:"
+ ::msgcat::mcset el "Files of &type:" "\u0391\u03c1\u03c7\u03b5\u03af\u03b1 \u03c4\u03bf\u03c5 &\u03c4\u03cd\u03c0\u03bf\u03c5:"
+ ::msgcat::mcset el "Fi&les:" "\u0391\u03c1\u03c7\u03b5\u03af\u03b1:"
+ ::msgcat::mcset el "&Filter" "\u03a6\u03af\u03bb\u03c4\u03c1\u03bf"
+ ::msgcat::mcset el "Fil&ter:" "\u03a6\u03af\u03bb\u03c4\u03c1\u03bf:"
+ ::msgcat::mcset el "&Green" "\u03a0\u03c1\u03ac\u03c3\u03b9\u03bd\u03bf"
+ ::msgcat::mcset el "Hi" "\u0393\u03b5\u03b9\u03b1"
+ ::msgcat::mcset el "Hide Console" "\u0391\u03c0\u03cc\u03ba\u03c1\u03c5\u03c8\u03b7 \u03ba\u03bf\u03bd\u03c3\u03cc\u03bb\u03b1\u03c2"
+ ::msgcat::mcset el "&Ignore" "\u0391\u03b3\u03bd\u03cc\u03b7\u03c3\u03b7"
+ ::msgcat::mcset el "Invalid file name \"%1\$s\"." \
+ "\u0386\u03ba\u03c5\u03c1\u03bf \u03cc\u03bd\u03bf\u03bc\u03b1 \u03b1\u03c1\u03c7\u03b5\u03af\u03bf\u03c5 \"%1\$s\"."
+ ::msgcat::mcset el "Log Files" "\u0391\u03c1\u03c7\u03b5\u03af\u03b1 \u039a\u03b1\u03c4\u03b1\u03b3\u03c1\u03b1\u03c6\u03ae\u03c2"
+ ::msgcat::mcset el "&No" "\u038c\u03c7\u03b9"
+ ::msgcat::mcset el "&OK" "\u0395\u03bd\u03c4\u03ac\u03be\u03b5\u03b9"
+ ::msgcat::mcset el "&Ok" "\u0395\u03bd\u03c4\u03ac\u03be\u03b5\u03b9"
+ ::msgcat::mcset el "Open" "\u0386\u03bd\u03bf\u03b9\u03b3\u03bc\u03b1"
+ ::msgcat::mcset el "&Open" "\u0386\u03bd\u03bf\u03b9\u03b3\u03bc\u03b1"
+ ::msgcat::mcset el "Open Multiple Files" \
+ "\u0386\u03bd\u03bf\u03b9\u03b3\u03bc\u03b1 \u03c0\u03bf\u03bb\u03bb\u03b1\u03c0\u03bb\u03ce\u03bd \u03b1\u03c1\u03c7\u03b5\u03af\u03c9\u03bd"
+ ::msgcat::mcset el "Paste" "\u0395\u03c0\u03b9\u03ba\u03cc\u03bb\u03bb\u03b7\u03c3\u03b7"
+ ::msgcat::mcset el "Quit" "\u0388\u03be\u03bf\u03b4\u03bf\u03c2"
+ ::msgcat::mcset el "&Red" "\u039a\u03cc\u03ba\u03ba\u03b9\u03bd\u03bf"
+ ::msgcat::mcset el "Replace existing file?" \
+ "\u0395\u03c0\u03b9\u03ba\u03ac\u03bb\u03c5\u03c8\u03b7 \u03c5\u03c0\u03ac\u03c1\u03c7\u03bf\u03bd\u03c4\u03bf\u03c2 \u03b1\u03c1\u03c7\u03b5\u03af\u03bf\u03c5;"
+ ::msgcat::mcset el "&Retry" "\u03a0\u03c1\u03bf\u03c3\u03c0\u03ac\u03b8\u03b7\u03c3\u03b5 \u03be\u03b1\u03bd\u03ac"
+ ::msgcat::mcset el "&Save" "\u0391\u03c0\u03bf\u03b8\u03ae\u03ba\u03b5\u03c5\u03c3\u03b7"
+ ::msgcat::mcset el "Save As" "\u0391\u03c0\u03bf\u03b8\u03ae\u03ba\u03b5\u03c5\u03c3\u03b7 \u03c3\u03b1\u03bd"
+ ::msgcat::mcset el "Save To Log" "\u0391\u03c0\u03bf\u03b8\u03ae\u03ba\u03b5\u03c5\u03c3\u03b7 \u03c3\u03c4\u03bf \u03b1\u03c1\u03c7\u03b5\u03af\u03bf \u03ba\u03b1\u03c4\u03b1\u03b3\u03c1\u03b1\u03c6\u03ae\u03c2"
+ ::msgcat::mcset el "Select Log File" "\u0395\u03c0\u03b9\u03bb\u03bf\u03b3\u03ae \u03b1\u03c1\u03c7\u03b5\u03af\u03bf\u03c5 \u03ba\u03b1\u03c4\u03b1\u03b3\u03c1\u03b1\u03c6\u03ae\u03c2"
+ ::msgcat::mcset el "Select a file to source" \
+ "\u0395\u03c0\u03b9\u03bb\u03ad\u03be\u03c4\u03b5 \u03b1\u03c1\u03c7\u03b5\u03af\u03bf \u03b3\u03b9\u03b1 \u03b5\u03ba\u03c4\u03ad\u03bb\u03b5\u03c3\u03b7"
+ ::msgcat::mcset el "&Selection:" "\u0395\u03c0\u03b9\u03bb\u03bf\u03b3\u03ae:"
+ ::msgcat::mcset el "Skip Messages" "\u0391\u03c0\u03bf\u03c6\u03c5\u03b3\u03ae \u03bc\u03c5\u03bd\u03b7\u03bc\u03ac\u03c4\u03c9\u03bd"
+ ::msgcat::mcset el "Source..." "\u0395\u03ba\u03c4\u03ad\u03bb\u03b5\u03c3\u03b7..."
+ ::msgcat::mcset el "Tcl Scripts" "Tcl Scripts"
+ ::msgcat::mcset el "Tcl for Windows" "Tcl \u03b3\u03b9\u03b1 Windows"
+ ::msgcat::mcset el "Text Files" "\u0391\u03c1\u03c7\u03b5\u03af\u03b1 \u039a\u03b5\u03b9\u03bc\u03ad\u03bd\u03bf\u03c5"
+ ::msgcat::mcset el "&Yes" "\u039d\u03b1\u03b9"
+ ::msgcat::mcset el "abort" "\u03c4\u03b5\u03c1\u03bc\u03b1\u03c4\u03b9\u03c3\u03bc\u03cc\u03c2"
+ ::msgcat::mcset el "blue" "\u03bc\u03c0\u03bb\u03b5"
+ ::msgcat::mcset el "cancel" "\u03b1\u03ba\u03cd\u03c1\u03c9\u03c3\u03b7"
+ ::msgcat::mcset el "extension" "\u03b5\u03c0\u03ad\u03ba\u03c4\u03b1\u03c3\u03b7"
+ ::msgcat::mcset el "extensions" "\u03b5\u03c0\u03b5\u03ba\u03c4\u03ac\u03c3\u03b5\u03b9\u03c2"
+ ::msgcat::mcset el "green" "\u03c0\u03c1\u03ac\u03c3\u03b9\u03bd\u03bf"
+ ::msgcat::mcset el "ignore" "\u03b1\u03b3\u03bd\u03cc\u03b7\u03c3\u03b7"
+ ::msgcat::mcset el "ok" "\u03b5\u03bd\u03c4\u03ac\u03be\u03b5\u03b9"
+ ::msgcat::mcset el "red" "\u03ba\u03cc\u03ba\u03ba\u03b9\u03bd\u03bf"
+ ::msgcat::mcset el "retry" "\u03c0\u03c1\u03bf\u03c3\u03c0\u03ac\u03b8\u03b7\u03c3\u03b5 \u03be\u03b1\u03bd\u03ac"
+ ::msgcat::mcset el "yes" "\u03bd\u03b1\u03b9"
+}
+
diff --git a/jni/ruby/ext/tk/sample/msgs_tk/en.msg b/jni/ruby/ext/tk/sample/msgs_tk/en.msg
new file mode 100644
index 0000000..de586d1
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/msgs_tk/en.msg
@@ -0,0 +1,83 @@
+namespace eval ::tkmsgcat_demo {
+ ::msgcat::mcset en "Application Error"
+ ::msgcat::mcset en "Blue"
+ ::msgcat::mcset en "Color"
+ ::msgcat::mcset en "Delete"
+ ::msgcat::mcset en "Error"
+ ::msgcat::mcset en "Green"
+ ::msgcat::mcset en "Red"
+ ::msgcat::mcset en "blue"
+ ::msgcat::mcset en "green"
+ ::msgcat::mcset en "red"
+}
+
+namespace eval ::tk {
+ ::msgcat::mcset en "&Abort"
+ ::msgcat::mcset en "About..."
+ ::msgcat::mcset en "All Files"
+ ::msgcat::mcset en "Application Error"
+ ::msgcat::mcset en "&Blue"
+ ::msgcat::mcset en "&Cancel"
+ ::msgcat::mcset en "Cannot change to the directory \"%1\$s\".\nPermission denied."
+ ::msgcat::mcset en "Choose Directory"
+ ::msgcat::mcset en "Clear"
+ ::msgcat::mcset en "Color"
+ ::msgcat::mcset en "Console"
+ ::msgcat::mcset en "Copy"
+ ::msgcat::mcset en "Cut"
+ ::msgcat::mcset en "Delete"
+ ::msgcat::mcset en "Details >>"
+ ::msgcat::mcset en "Directory \"%1\$s\" does not exist."
+ ::msgcat::mcset en "&Directory:"
+ ::msgcat::mcset en "Error: %1\$s"
+ ::msgcat::mcset en "Exit"
+ ::msgcat::mcset en "File \"%1\$s\" already exists.\nDo you want to overwrite it?"
+ ::msgcat::mcset en "File \"%1\$s\" already exists.\n\n"
+ ::msgcat::mcset en "File \"%1\$s\" does not exist."
+ ::msgcat::mcset en "File &name:"
+ ::msgcat::mcset en "File &names:"
+ ::msgcat::mcset en "Files of &type:"
+ ::msgcat::mcset en "Fi&les:"
+ ::msgcat::mcset en "&Filter"
+ ::msgcat::mcset en "Fil&ter:"
+ ::msgcat::mcset en "&Green"
+ ::msgcat::mcset en "Hi"
+ ::msgcat::mcset en "Hide Console"
+ ::msgcat::mcset en "&Ignore"
+ ::msgcat::mcset en "Invalid file name \"%1\$s\"."
+ ::msgcat::mcset en "Log Files"
+ ::msgcat::mcset en "&No"
+ ::msgcat::mcset en "&OK"
+ ::msgcat::mcset en "Ok"
+ ::msgcat::mcset en "Open"
+ ::msgcat::mcset en "&Open"
+ ::msgcat::mcset en "Open Multiple Files"
+ ::msgcat::mcset en "Paste"
+ ::msgcat::mcset en "Quit"
+ ::msgcat::mcset en "&Red"
+ ::msgcat::mcset en "Replace existing file?"
+ ::msgcat::mcset en "&Retry"
+ ::msgcat::mcset en "&Save"
+ ::msgcat::mcset en "Save As"
+ ::msgcat::mcset en "Save To Log"
+ ::msgcat::mcset en "Select Log File"
+ ::msgcat::mcset en "Select a file to source"
+ ::msgcat::mcset en "&Selection:"
+ ::msgcat::mcset en "Skip Messages"
+ ::msgcat::mcset en "Source..."
+ ::msgcat::mcset en "Tcl Scripts"
+ ::msgcat::mcset en "Tcl for Windows"
+ ::msgcat::mcset en "Text Files"
+ ::msgcat::mcset en "&Yes"
+ ::msgcat::mcset en "abort"
+ ::msgcat::mcset en "blue"
+ ::msgcat::mcset en "cancel"
+ ::msgcat::mcset en "extension"
+ ::msgcat::mcset en "extensions"
+ ::msgcat::mcset en "green"
+ ::msgcat::mcset en "ignore"
+ ::msgcat::mcset en "ok"
+ ::msgcat::mcset en "red"
+ ::msgcat::mcset en "retry"
+ ::msgcat::mcset en "yes"
+}
diff --git a/jni/ruby/ext/tk/sample/msgs_tk/en_gb.msg b/jni/ruby/ext/tk/sample/msgs_tk/en_gb.msg
new file mode 100644
index 0000000..1aa5b49
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/msgs_tk/en_gb.msg
@@ -0,0 +1,7 @@
+namespace eval ::tkmsgcat_demo {
+ ::msgcat::mcset en_gb Color Colour
+}
+
+namespace eval ::tk {
+ ::msgcat::mcset en_gb Color Colour
+}
diff --git a/jni/ruby/ext/tk/sample/msgs_tk/eo.msg b/jni/ruby/ext/tk/sample/msgs_tk/eo.msg
new file mode 100644
index 0000000..e683cef
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/msgs_tk/eo.msg
@@ -0,0 +1,87 @@
+namespace eval ::tkmsgcat_demo {
+ ::msgcat::mcset eo "Application Error" "Aplikoerraro"
+ ::msgcat::mcset eo "Blue" "Blua"
+ ::msgcat::mcset eo "Color" "Farbo"
+ ::msgcat::mcset eo "Delete" "Forprenu"
+ ::msgcat::mcset eo "Error" "Eraro"
+ ::msgcat::mcset eo "Exit" "Eliru"
+ ::msgcat::mcset eo "Green" "Verda"
+ ::msgcat::mcset eo "Red" "Rosa"
+ ::msgcat::mcset eo "blue" "blua"
+ ::msgcat::mcset eo "green" "verda"
+ ::msgcat::mcset eo "red" "ru\u011da"
+}
+
+namespace eval ::tk {
+ ::msgcat::mcset eo "&Abort" "&\u0108esigo"
+ ::msgcat::mcset eo "&About..." "Pri..."
+ ::msgcat::mcset eo "All Files" "\u0108ioj dosieroj"
+ ::msgcat::mcset eo "Application Error" "Aplikoerraro"
+ ::msgcat::mcset eo "&Blue" "&Blua"
+ ::msgcat::mcset eo "&Cancel" "&Rezignu"
+ ::msgcat::mcset eo "Cannot change to the directory \"%1\$s\".\nPermission denied." "Neeble \u0109angi al dosierulon \"%1\$s\".\nVi ne rajtas tion."
+ ::msgcat::mcset eo "Choose Directory" "Elektu Dosierujo"
+ ::msgcat::mcset eo "&Clear" "&Klaru"
+ ::msgcat::mcset eo "&Clear Console" "&Klaru konzolon"
+ ::msgcat::mcset eo "Color" "Farbo"
+ ::msgcat::mcset eo "Console" "Konzolo"
+ ::msgcat::mcset eo "&Copy" "&Kopiu"
+ ::msgcat::mcset eo "Cu&t" "&Enpo\u015digu"
+ ::msgcat::mcset eo "&Delete" "&Forprenu"
+ ::msgcat::mcset eo "Details >>" "Detaloj >>"
+ ::msgcat::mcset eo "Directory \"%1\$s\" does not exist." "La dosierujo \"%1\$s\" ne ekzistas."
+ ::msgcat::mcset eo "&Directory:" "&Dosierujo:"
+ ::msgcat::mcset eo "&Edit" "&Redaktu"
+ ::msgcat::mcset eo "Error: %1\$s" "Eraro: %1\$s"
+ ::msgcat::mcset eo "E&xit" "&Eliru"
+ ::msgcat::mcset eo "&File" "&Dosiero"
+ ::msgcat::mcset eo "File \"%1\$s\" already exists.\nDo you want to overwrite it?" "La dosiero \"%1\$s\" jam ekzistas.\n\u0108u vi volas anstata\u00fbigi la dosieron?"
+ ::msgcat::mcset eo "File \"%1\$s\" already exists.\n\n" "La dosiero \"%1\$s\" jam egzistas. \n\n"
+ ::msgcat::mcset eo "File \"%1\$s\" does not exist." "La dosierp \"%1\$s\" ne estas."
+ ::msgcat::mcset eo "File &name:" "Dosiero&nomo:"
+ ::msgcat::mcset eo "File &names:" "Dosiero&nomoj:"
+ ::msgcat::mcset eo "Files of &type:" "Dosieroj de &Typo:"
+ ::msgcat::mcset eo "Fi&les:" "Do&sieroj:"
+ ::msgcat::mcset eo "&Filter" "&Filtrilo"
+ ::msgcat::mcset eo "Fil&ter:" "&Filtrilo:"
+ ::msgcat::mcset eo "&Green" "&Verda"
+ ::msgcat::mcset eo "&Help" "&Helpu"
+ ::msgcat::mcset eo "Hi" "Saluton"
+ ::msgcat::mcset eo "&Hide Console" "&Ka\u015du konzolon"
+ ::msgcat::mcset eo "&Ignore" "&Ignoru"
+ ::msgcat::mcset eo "Invalid file name \"%1\$s\"." "Malvalida dosieronomo \"%1\$s\"."
+ ::msgcat::mcset eo "Log Files" "Protokolo"
+ ::msgcat::mcset eo "&No" "&Ne"
+ ::msgcat::mcset eo "OK"
+ ::msgcat::mcset eo "Ok"
+ ::msgcat::mcset eo "Open" "Malfermu"
+ ::msgcat::mcset eo "&Open" "&Malfermu"
+ ::msgcat::mcset eo "Open Multiple Files" "Melfermu multan dosierojn"
+ ::msgcat::mcset eo "P&aste" "&Elpo\u015digi"
+ ::msgcat::mcset eo "&Quit" "&Finigu"
+ ::msgcat::mcset eo "&Red" "&Rosa"
+ ::msgcat::mcset eo "Replace existing file?" "\u0108u anstata\u00fbu ekzistantan dosieron?"
+ ::msgcat::mcset eo "&Retry" "&Ripetu"
+ ::msgcat::mcset eo "&Save" "&Savu"
+ ::msgcat::mcset eo "Save As" "Savu kiel"
+ ::msgcat::mcset eo "Save To Log" "Savu en protokolon"
+ ::msgcat::mcset eo "Select Log File" "Elektu prokolodosieron"
+ ::msgcat::mcset eo "Select a file to source" "Elektu dosieron por interpreti"
+ ::msgcat::mcset eo "&Selection:" "&Elekto:"
+ ::msgcat::mcset eo "Skip Messages" "transsaltu pluajn mesa\u011dojn"
+ ::msgcat::mcset eo "&Source..." "&Fontoprogramo..."
+ ::msgcat::mcset eo "Tcl Scripts" "Tcl-skriptoj"
+ ::msgcat::mcset eo "Tcl for Windows" "Tcl por vindoso"
+ ::msgcat::mcset eo "Text Files" "Tekstodosierojn"
+ ::msgcat::mcset eo "&Yes" "&Jes"
+ ::msgcat::mcset eo "abort" "\u0109esigo"
+ ::msgcat::mcset eo "blue" "blua"
+ ::msgcat::mcset eo "cancel" "rezignu"
+ ::msgcat::mcset eo "extension" "ekspansio"
+ ::msgcat::mcset eo "extensions" "ekspansioj"
+ ::msgcat::mcset eo "green" "verda"
+ ::msgcat::mcset eo "ignore" "ignorieren"
+ ::msgcat::mcset eo "red" "ru\u011da"
+ ::msgcat::mcset eo "retry" "ripetu"
+ ::msgcat::mcset eo "yes" "jes"
+}
diff --git a/jni/ruby/ext/tk/sample/msgs_tk/es.msg b/jni/ruby/ext/tk/sample/msgs_tk/es.msg
new file mode 100644
index 0000000..62ce33d
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/msgs_tk/es.msg
@@ -0,0 +1,84 @@
+namespace eval ::tkmsgcat_demo {
+ ::msgcat::mcset es "Application Error" "Error de la aplicaci\u00f3n"
+ ::msgcat::mcset es "Blue" "Azul"
+ ::msgcat::mcset es "Color" "Color"
+ ::msgcat::mcset es "Delete" "Borrar"
+ ::msgcat::mcset es "Error" "Error"
+ ::msgcat::mcset es "Exit" "Salir"
+ ::msgcat::mcset es "Green" "Verde"
+ ::msgcat::mcset es "Red" "Rojo"
+ ::msgcat::mcset es "blue" "azul"
+ ::msgcat::mcset es "green" "verde"
+ ::msgcat::mcset es "red" "rojo"
+}
+
+namespace eval ::tk {
+ ::msgcat::mcset es "&Abort" "&Abortar"
+ ::msgcat::mcset es "About..." "Acerca de ..."
+ ::msgcat::mcset es "All Files" "Todos los archivos"
+ ::msgcat::mcset es "Application Error" "Error de la aplicaci\u00f3n"
+ ::msgcat::mcset es "&Blue" "&Azul"
+ ::msgcat::mcset es "&Cancel" "&Cancelar"
+ ::msgcat::mcset es "Cannot change to the directory \"%1\$s\".\nPermission denied." "No es posible acceder al directorio \"%1\$s\".\nPermiso denegado."
+ ::msgcat::mcset es "Choose Directory" "Elegir directorio"
+ ::msgcat::mcset es "Clear" "Borrar"
+ ::msgcat::mcset es "Color" "Color"
+ ::msgcat::mcset es "Console" "Consola"
+ ::msgcat::mcset es "Copy" "Copiar"
+ ::msgcat::mcset es "Cut" "Cortar"
+ ::msgcat::mcset es "Delete" "Borrar"
+ ::msgcat::mcset es "Details >>" "Detalles >>"
+ ::msgcat::mcset es "Directory \"%1\$s\" does not exist." "El directorio \"%1\$s\" no existe."
+ ::msgcat::mcset es "&Directory:" "&Directorio:"
+ ::msgcat::mcset es "Error: %1\$s" "Error: %1\$s"
+ ::msgcat::mcset es "Exit" "Salir"
+ ::msgcat::mcset es "File \"%1\$s\" already exists.\nDo you want to overwrite it?" "El archivo \"%1\$s\" ya existe.\nDesea sobreescribirlo?"
+ ::msgcat::mcset es "File \"%1\$s\" already exists.\n\n" "El archivo \"%1\$s\" ya existe.\n\n"
+ ::msgcat::mcset es "File \"%1\$s\" does not exist." "El archivo \"%1\$s\" no existe."
+ ::msgcat::mcset es "File &name:" "&Nombre de archivo:"
+ ::msgcat::mcset es "File &names:" "&Nombres de archivo:"
+ ::msgcat::mcset es "Files of &type:" "Archivos de &tipo:"
+ ::msgcat::mcset es "Fi&les:" "&Archivos:"
+ ::msgcat::mcset es "&Filter" "&Filtro"
+ ::msgcat::mcset es "Fil&ter:" "Fil&tro:"
+ ::msgcat::mcset es "&Green" "&Verde"
+ ::msgcat::mcset es "Hi" "Hola"
+ ::msgcat::mcset es "Hide Console" "Esconder la consola"
+ ::msgcat::mcset es "&Ignore" "&Ignorar"
+ ::msgcat::mcset es "Invalid file name \"%1\$s\"." "Nombre de archivo inv\u00e1lido \"%1\$s\"."
+ ::msgcat::mcset es "Log Files" "Ficheros de traza"
+ ::msgcat::mcset es "&No" "&No"
+ ::msgcat::mcset es "&OK" "&OK"
+ ::msgcat::mcset es "Ok" "Ok"
+ ::msgcat::mcset es "Open" "Abrir"
+ ::msgcat::mcset es "&Open" "&Abrir"
+ ::msgcat::mcset es "Open Multiple Files" "Abrir m\u00faltiples archivos"
+ ::msgcat::mcset es "Paste" "Pegar"
+ ::msgcat::mcset es "Quit" "Abandonar"
+ ::msgcat::mcset es "&Red" "&Rojo"
+ ::msgcat::mcset es "Replace existing file?" "Reemplazar el archivo existente?"
+ ::msgcat::mcset es "&Retry" "&Reintentar"
+ ::msgcat::mcset es "&Save" "&Salvar"
+ ::msgcat::mcset es "Save As" "Salvar como"
+ ::msgcat::mcset es "Save To Log" "Salvar al archivo de traza"
+ ::msgcat::mcset es "Select Log File" "Elegir un archivo de traza"
+ ::msgcat::mcset es "Select a file to source" "Seleccionar un archivo a evaluar"
+ ::msgcat::mcset es "&Selection:" "&Selecci\u00f3n:"
+ ::msgcat::mcset es "Skip Messages" "Omitir los mensajes"
+ ::msgcat::mcset es "Source..." "Evaluar..."
+ ::msgcat::mcset es "Tcl Scripts" "Scripts Tcl"
+ ::msgcat::mcset es "Tcl for Windows" "Tcl para Windows"
+ ::msgcat::mcset es "Text Files" "Archivos de texto"
+ ::msgcat::mcset es "&Yes" "&S\u00ed"
+ ::msgcat::mcset es "abort" "abortar"
+ ::msgcat::mcset es "blue" "azul"
+ ::msgcat::mcset es "cancel" "cancelar"
+ ::msgcat::mcset es "extension" "extensi\u00f3n"
+ ::msgcat::mcset es "extensions" "extensiones"
+ ::msgcat::mcset es "green" "verde"
+ ::msgcat::mcset es "ignore" "ignorar"
+ ::msgcat::mcset es "ok" "ok"
+ ::msgcat::mcset es "red" "rojo"
+ ::msgcat::mcset es "retry" "reintentar"
+ ::msgcat::mcset es "yes" "s\u00ed"
+}
diff --git a/jni/ruby/ext/tk/sample/msgs_tk/fr.msg b/jni/ruby/ext/tk/sample/msgs_tk/fr.msg
new file mode 100644
index 0000000..ebbba48
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/msgs_tk/fr.msg
@@ -0,0 +1,84 @@
+namespace eval ::tkmsgcat_demo {
+ ::msgcat::mcset fr "Application Error" "Erreur d'application"
+ ::msgcat::mcset fr "Blue" "Bleu"
+ ::msgcat::mcset fr "Color" "Couleur"
+ ::msgcat::mcset fr "Delete" "Effacer"
+ ::msgcat::mcset fr "Error" "Erreur"
+ ::msgcat::mcset fr "Exit" "Quitter"
+ ::msgcat::mcset fr "Green" "Vert"
+ ::msgcat::mcset fr "Red" "Rouge"
+ ::msgcat::mcset fr "blue" "bleu"
+ ::msgcat::mcset fr "green" "vert"
+ ::msgcat::mcset fr "red" "rouge"
+}
+
+namespace eval ::tk {
+ ::msgcat::mcset fr "&Abort" "&Annuler"
+ ::msgcat::mcset fr "About..." "\u00c0 propos..."
+ ::msgcat::mcset fr "All Files" "Tous les fichiers"
+ ::msgcat::mcset fr "Application Error" "Erreur d'application"
+ ::msgcat::mcset fr "&Blue" "&Bleu"
+ ::msgcat::mcset fr "&Cancel" "&Annuler"
+ ::msgcat::mcset fr "Cannot change to the directory \"%1\$s\".\nPermission denied." "Impossible d'acc\u00e9der au r\u00e9pertoire \"%1\$s\".\nPermission refus\u00e9e."
+ ::msgcat::mcset fr "Choose Directory" "Choisir r\u00e9pertoire"
+ ::msgcat::mcset fr "Clear" "Effacer"
+ ::msgcat::mcset fr "Color" "Couleur"
+ ::msgcat::mcset fr "Console"
+ ::msgcat::mcset fr "Copy" "Copier"
+ ::msgcat::mcset fr "Cut" "Couper"
+ ::msgcat::mcset fr "Delete" "Effacer"
+ ::msgcat::mcset fr "Details >>" "D\u00e9tails >>"
+ ::msgcat::mcset fr "Directory \"%1\$s\" does not exist." "Le r\u00e9pertoire \"%1\$s\" n'existe pas."
+ ::msgcat::mcset fr "&Directory:" "&R\u00e9pertoire:"
+ ::msgcat::mcset fr "Error: %1\$s" "Erreur: %1\$s"
+ ::msgcat::mcset fr "Exit" "Quitter"
+ ::msgcat::mcset fr "File \"%1\$s\" already exists.\nDo you want to overwrite it?" "Le fichier \"%1\$s\" existe d\u00e9j\u00e0.\nVoulez-vous l'\u00e9craser?"
+ ::msgcat::mcset fr "File \"%1\$s\" already exists.\n\n" "Le fichier \"%1\$s\" existe d\u00e9j\u00e0.\n\n"
+ ::msgcat::mcset fr "File \"%1\$s\" does not exist." "Le fichier \"%1\$s\" n'existe pas."
+ ::msgcat::mcset fr "File &name:" "&Nom de fichier:"
+ ::msgcat::mcset fr "File &names:" "&Noms de fichiers:"
+ ::msgcat::mcset fr "Files of &type:" "&Type de fichiers:"
+ ::msgcat::mcset fr "Fi&les:" "Fich&iers:"
+ ::msgcat::mcset fr "&Filter" "&Filtre"
+ ::msgcat::mcset fr "Fil&ter:" "Fil&tre:"
+ ::msgcat::mcset fr "&Green" "&Vert"
+ ::msgcat::mcset fr "Hi" "Salut"
+ ::msgcat::mcset fr "Hide Console" "Cacher la Console"
+ ::msgcat::mcset fr "&Ignore" "&Ignorer"
+ ::msgcat::mcset fr "Invalid file name \"%1\$s\"." "Nom de fichier invalide \"%1\$s\"."
+ ::msgcat::mcset fr "Log Files" "Fichiers de trace"
+ ::msgcat::mcset fr "&No" "&Non"
+ ::msgcat::mcset fr "&OK"
+ ::msgcat::mcset fr "Ok"
+ ::msgcat::mcset fr "Open" "Ouvrir"
+ ::msgcat::mcset fr "&Open" "&Ouvrir"
+ ::msgcat::mcset fr "Open Multiple Files" "Ouvrir plusieurs fichiers"
+ ::msgcat::mcset fr "Paste" "Coller"
+ ::msgcat::mcset fr "Quit" "Quitter"
+ ::msgcat::mcset fr "&Red" "&Rouge"
+ ::msgcat::mcset fr "Replace existing file?" "Remplacer le fichier existant?"
+ ::msgcat::mcset fr "&Retry" "&R\u00e9-essayer"
+ ::msgcat::mcset fr "&Save" "&Sauvegarder"
+ ::msgcat::mcset fr "Save As" "Sauvegarder sous"
+ ::msgcat::mcset fr "Save To Log" "Sauvegarde au fichier de trace"
+ ::msgcat::mcset fr "Select Log File" "Choisir un fichier de trace"
+ ::msgcat::mcset fr "Select a file to source" "Choisir un fichier \u00e0 \u00e9valuer"
+ ::msgcat::mcset fr "&Selection:" "&S\u00e9lection:"
+ ::msgcat::mcset fr "Skip Messages" "Omettre les messages"
+ ::msgcat::mcset fr "Source..." "\u00c9valuer..."
+ ::msgcat::mcset fr "Tcl Scripts" "Scripts Tcl"
+ ::msgcat::mcset fr "Tcl for Windows" "Tcl pour Windows"
+ ::msgcat::mcset fr "Text Files" "Fichiers texte"
+ ::msgcat::mcset fr "&Yes" "&Oui"
+ ::msgcat::mcset fr "abort" "abandonner"
+ ::msgcat::mcset fr "blue" "bleu"
+ ::msgcat::mcset fr "cancel" "annuler"
+ ::msgcat::mcset fr "extension"
+ ::msgcat::mcset fr "extensions"
+ ::msgcat::mcset fr "green" "vert"
+ ::msgcat::mcset fr "ignore" "ignorer"
+ ::msgcat::mcset fr "ok"
+ ::msgcat::mcset fr "red" "rouge"
+ ::msgcat::mcset fr "retry" "r\u00e9essayer"
+ ::msgcat::mcset fr "yes" "oui"
+}
diff --git a/jni/ruby/ext/tk/sample/msgs_tk/it.msg b/jni/ruby/ext/tk/sample/msgs_tk/it.msg
new file mode 100644
index 0000000..b144fcc
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/msgs_tk/it.msg
@@ -0,0 +1,84 @@
+namespace eval ::tkmsgcat_demo {
+ ::msgcat::mcset it "Application Error" "Errore dell' applicazione"
+ ::msgcat::mcset it "Blue" "Blu"
+ ::msgcat::mcset it "Color" "Colore"
+ ::msgcat::mcset it "Delete" "Incolla"
+ ::msgcat::mcset it "Error" "Errore"
+ ::msgcat::mcset it "Exit" "Esci"
+ ::msgcat::mcset it "Green" "Verde"
+ ::msgcat::mcset it "Red" "Rosso"
+ ::msgcat::mcset it "blue" "blu"
+ ::msgcat::mcset it "green" "verde"
+ ::msgcat::mcset it "red" "rosso"
+}
+
+namespace eval ::tk {
+ ::msgcat::mcset it "&Abort" "&Interrompi"
+ ::msgcat::mcset it "About..." "Informazioni ..."
+ ::msgcat::mcset it "All Files" "Tutti i file"
+ ::msgcat::mcset it "Application Error" "Errore dell' applicazione"
+ ::msgcat::mcset it "&Blue" "&Blu"
+ ::msgcat::mcset it "&Cancel" "&Annulla"
+ ::msgcat::mcset it "Cannot change to the directory \"%1\$s\".\nPermission denied." "Impossibile accedere alla directory \"%1\$s\".\nPermesso negato."
+ ::msgcat::mcset it "Choose Directory" "Scegli directory"
+ ::msgcat::mcset it "Clear" "Azzera"
+ ::msgcat::mcset it "Color" "Colore"
+ ::msgcat::mcset it "Console"
+ ::msgcat::mcset it "Copy" "Copia"
+ ::msgcat::mcset it "Cut" "Taglia"
+ ::msgcat::mcset it "Delete" "Incolla"
+ ::msgcat::mcset it "Details >>" "Dettagli >>"
+ ::msgcat::mcset it "Directory \"%1\$s\" does not exist." "La directory \"%1\$s\" non esiste."
+ ::msgcat::mcset it "&Directory:"
+ ::msgcat::mcset it "Error: %1\$s" "Errore: %1\$s"
+ ::msgcat::mcset it "Exit" "Esci"
+ ::msgcat::mcset it "File \"%1\$s\" already exists.\nDo you want to overwrite it?" "Il file \"%1\$s\" esiste gi\u00e0.\nVuoi sovrascriverlo?"
+ ::msgcat::mcset it "File \"%1\$s\" already exists.\n\n" "Il file \"%1\$s\" esiste gi\u00e0.\n\n"
+ ::msgcat::mcset it "File \"%1\$s\" does not exist." "Il file \"%1\$s\" non esiste."
+ ::msgcat::mcset it "File &name:" "&Nome del file:"
+ ::msgcat::mcset it "File &names:" "&Nomi dei file:"
+ ::msgcat::mcset it "Files of &type:" "File di &tipo:"
+ ::msgcat::mcset it "Fi&les:" "Fi&le:"
+ ::msgcat::mcset it "&Filter" "&Filtro"
+ ::msgcat::mcset it "Fil&ter:" "Fil&tro:"
+ ::msgcat::mcset it "&Green" "&Verde"
+ ::msgcat::mcset it "Hi" "Salve"
+ ::msgcat::mcset it "Hide Console" "Nascondi la console"
+ ::msgcat::mcset it "&Ignore" "&Ignora"
+ ::msgcat::mcset it "Invalid file name \"%1\$s\"." "Nome di file non valido \"%1\$s\"."
+ ::msgcat::mcset it "Log Files" "File di log"
+ ::msgcat::mcset it "&No"
+ ::msgcat::mcset it "&OK"
+ ::msgcat::mcset it "Ok"
+ ::msgcat::mcset it "&Open" "A&pri"
+ ::msgcat::mcset it "Open" "Apri"
+ ::msgcat::mcset it "Open Multiple Files" "Apri file multipli"
+ ::msgcat::mcset it "Paste" "Incolla"
+ ::msgcat::mcset it "Quit" "Esci"
+ ::msgcat::mcset it "&Red" "&Rosso"
+ ::msgcat::mcset it "Replace existing file?" "Sostituisci il file esistente?"
+ ::msgcat::mcset it "&Retry" "&Riprova"
+ ::msgcat::mcset it "&Save" "&Salva"
+ ::msgcat::mcset it "Save As" "Salva come"
+ ::msgcat::mcset it "Save To Log" "Salva il log"
+ ::msgcat::mcset it "Select Log File" "Scegli un file di log"
+ ::msgcat::mcset it "Select a file to source" "Scegli un file da eseguire"
+ ::msgcat::mcset it "&Selection:" "&Selezione:"
+ ::msgcat::mcset it "Skip Messages" "Salta i messaggi"
+ ::msgcat::mcset it "Source..." "Esegui..."
+ ::msgcat::mcset it "Tcl Scripts" "Scripts Tcl"
+ ::msgcat::mcset it "Tcl for Windows" "Tcl per Windows"
+ ::msgcat::mcset it "Text Files" "File di testo"
+ ::msgcat::mcset it "&Yes" "&Si"
+ ::msgcat::mcset it "abort" "interrompi"
+ ::msgcat::mcset it "blue" "blu"
+ ::msgcat::mcset it "cancel" "annulla"
+ ::msgcat::mcset it "extension" "estensione"
+ ::msgcat::mcset it "extensions" "estensioni"
+ ::msgcat::mcset it "green" "verde"
+ ::msgcat::mcset it "ignore" "ignora"
+ ::msgcat::mcset it "ok"
+ ::msgcat::mcset it "red" "rosso"
+ ::msgcat::mcset it "retry" "riprova"
+ ::msgcat::mcset it "yes" "si"
+}
diff --git a/jni/ruby/ext/tk/sample/msgs_tk/ja.msg b/jni/ruby/ext/tk/sample/msgs_tk/ja.msg
new file mode 100644
index 0000000..44a2583
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/msgs_tk/ja.msg
@@ -0,0 +1,13 @@
+namespace eval ::tkmsgcat_demo {
+ ::msgcat::mcset ja "Application Error" "\u30A2\u30D7\u30EA\u30B1\u30FC\u30B7\u30E7\u30F3\u30A8\u30E9\u30FC"
+ ::msgcat::mcset ja "Blue" "\u9752"
+ ::msgcat::mcset ja "Color" "\u80CC\u666F\u8272"
+ ::msgcat::mcset ja "Delete" "\u6D88\u53BB"
+ ::msgcat::mcset ja "Error" "\u30A8\u30E9\u30FC"
+ ::msgcat::mcset ja "Exit" "\u7D42\u4E86"
+ ::msgcat::mcset ja "Green" "\u7DD1"
+ ::msgcat::mcset ja "Red" "\u8D64"
+ ::msgcat::mcset ja "blue" "\u9752"
+ ::msgcat::mcset ja "green" "\u7DD1"
+ ::msgcat::mcset ja "red" "\u8D64"
+}
diff --git a/jni/ruby/ext/tk/sample/msgs_tk/license.terms b/jni/ruby/ext/tk/sample/msgs_tk/license.terms
new file mode 100644
index 0000000..c0a44d3
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/msgs_tk/license.terms
@@ -0,0 +1,39 @@
+This software is copyrighted by the Regents of the University of
+California, Sun Microsystems, Inc., and other parties. The following
+terms apply to all files associated with the software unless explicitly
+disclaimed in individual files.
+
+The authors hereby grant permission to use, copy, modify, distribute,
+and license this software and its documentation for any purpose, provided
+that existing copyright notices are retained in all copies and that this
+notice is included verbatim in any distributions. No written agreement,
+license, or royalty fee is required for any of the authorized uses.
+Modifications to this software may be copyrighted by their authors
+and need not follow the licensing terms described here, provided that
+the new terms are clearly indicated on the first page of each file where
+they apply.
+
+IN NO EVENT SHALL THE AUTHORS OR DISTRIBUTORS BE LIABLE TO ANY PARTY
+FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
+ARISING OUT OF THE USE OF THIS SOFTWARE, ITS DOCUMENTATION, OR ANY
+DERIVATIVES THEREOF, EVEN IF THE AUTHORS HAVE BEEN ADVISED OF THE
+POSSIBILITY OF SUCH DAMAGE.
+
+THE AUTHORS AND DISTRIBUTORS SPECIFICALLY DISCLAIM ANY WARRANTIES,
+INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE, AND NON-INFRINGEMENT. THIS SOFTWARE
+IS PROVIDED ON AN "AS IS" BASIS, AND THE AUTHORS AND DISTRIBUTORS HAVE
+NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR
+MODIFICATIONS.
+
+GOVERNMENT USE: If you are acquiring this software on behalf of the
+U.S. government, the Government shall have only "Restricted Rights"
+in the software and related documentation as defined in the Federal
+Acquisition Regulations (FARs) in Clause 52.227.19 (c) (2). If you
+are acquiring the software on behalf of the Department of Defense, the
+software shall be classified as "Commercial Computer Software" and the
+Government shall have only "Restricted Rights" as defined in Clause
+252.227-7013 (c) (1) of DFARs. Notwithstanding the foregoing, the
+authors grant the U.S. Government and others acting in its behalf
+permission to use and distribute the software in accordance with the
+terms specified in this license.
diff --git a/jni/ruby/ext/tk/sample/msgs_tk/nl.msg b/jni/ruby/ext/tk/sample/msgs_tk/nl.msg
new file mode 100644
index 0000000..d9642e8
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/msgs_tk/nl.msg
@@ -0,0 +1,123 @@
+namespace eval ::tkmsgcat_demo {
+ ::msgcat::mcset nl "Application Error" "Toepassingsfout"
+ ::msgcat::mcset nl "Blue" "Blauw"
+ ::msgcat::mcset nl "Color" "Kleur"
+ ::msgcat::mcset nl "Delete" "Wissen"
+ ::msgcat::mcset nl "Error" "Fout"
+ ::msgcat::mcset nl "Exit" "Be\u00ebindigen"
+ ::msgcat::mcset nl "Green" "Groen"
+ ::msgcat::mcset nl "Red" "Rood"
+ ::msgcat::mcset nl "blue" "blauw"
+ ::msgcat::mcset nl "green" "groen"
+ ::msgcat::mcset nl "red" "rood"
+}
+
+namespace eval ::tk {
+ ::msgcat::mcset nl "\"%1\$s\" must be an absolute pathname" "\"%1\$s\" moet een absolute pad-naam zijn"
+ ::msgcat::mcset nl "%1\$s is not a toplevel window" "%1\$s is geen toplevel window"
+ ::msgcat::mcset nl ", or" ", of"
+ ::msgcat::mcset nl "-default, -icon, -message, -parent, -title, or -type" "-default, -icon, -message, -parent, -title, of -type"
+ ::msgcat::mcset nl "-initialdir, -mustexist, -parent, or -title" "-initialdir, -mustexist, -parent, of -title"
+ ::msgcat::mcset nl "&Abort" "&Afbreken"
+ ::msgcat::mcset nl "About..." "Over..."
+ ::msgcat::mcset nl "All Files" "Alle Bestanden"
+ ::msgcat::mcset nl "Application Error" "Toepassingsfout"
+ ::msgcat::mcset nl "&Blue" "&Blauw"
+ ::msgcat::mcset nl "&Cancel" "&Annuleren"
+ ::msgcat::mcset nl "Cannot change to the directory \"%1\$s\".\nPermission denied." "Kan niet naar map \"%1\$s\" gaan.\nU heeft hiervoor geen toestemming."
+ ::msgcat::mcset nl "Choose Directory" "Kies map"
+ ::msgcat::mcset nl "Clear" "Wissen"
+ ::msgcat::mcset nl "Clear entry, Press OK; Enter %1\$s, press OK" "Wis veld, Druk op OK; typ %1\$s in, druk op OK"
+ ::msgcat::mcset nl "&Clear Console" "&Wis Console"
+ ::msgcat::mcset nl "Color" "Kleur"
+ ::msgcat::mcset nl "Console"
+ ::msgcat::mcset nl "Copy" "Kopi\u00ebren"
+ ::msgcat::mcset nl "Cut" "Knippen"
+ ::msgcat::mcset nl "Delete" "Wissen"
+ ::msgcat::mcset nl "Details"
+ ::msgcat::mcset nl "Details >>"
+ ::msgcat::mcset nl "Directory \"%1\$s\" does not exist." "Map \"%1\$s\" bestaat niet."
+ ::msgcat::mcset nl "&Directory:" "&Map:"
+ ::msgcat::mcset nl "Edit" "Bewerken"
+ ::msgcat::mcset nl "Enter \"%1\$s\", press OK" "Typ \"%1\$s\", druk op OK"
+ ::msgcat::mcset nl "Enter \"%1\$s\", press OK, enter \"%2\$s\", press OK" "Typ \"%1\$s\", druk op OK, typ \"%2\$s\", druk op OK"
+ ::msgcat::mcset nl "Error: %1\$s" "Fout: %1\$s"
+ ::msgcat::mcset nl "Exit" "Be\u00ebindigen"
+ ::msgcat::mcset nl "File" "Bestand"
+ ::msgcat::mcset nl "File \"%1\$s\" already exists.\n\n" "Bestand \"%1\$s\" bestaat al.\n\n"
+ ::msgcat::mcset nl "File \"%1\$s\" already exists.\nDo you want to overwrite it?" "Bestand \"%1\$s\" bestaat al.\nWilt u het overschrijven?"
+ ::msgcat::mcset nl "File \"%1\$s\" does not exist." "Bestand \"%1\$s\" bestaat niet."
+ ::msgcat::mcset nl "File &name:" "Bestands&naam:"
+ ::msgcat::mcset nl "File &names:" "Bestands&namen:"
+ ::msgcat::mcset nl "Files of &type:" "Bestanden van het &type:"
+ ::msgcat::mcset nl "Fi&les:" "&Bestanden:"
+ ::msgcat::mcset nl "&Filter"
+ ::msgcat::mcset nl "Fil&ter:"
+ ::msgcat::mcset nl "&Green" "&Groen"
+ ::msgcat::mcset nl "Hi" "H\u00e9"
+ ::msgcat::mcset nl "Hide Console" "Verberg Console"
+ ::msgcat::mcset nl "&Ignore" "&Negeren"
+ ::msgcat::mcset nl "Invalid file name \"%1\$s\"." "Ongeldige bestandsnaam \"%1\$s\"."
+ ::msgcat::mcset nl "Log Files" "Log Bestanden"
+ ::msgcat::mcset nl "&No" "&Nee"
+ ::msgcat::mcset nl "&OK"
+ ::msgcat::mcset nl "Ok"
+ ::msgcat::mcset nl "&Open" "&Openen"
+ ::msgcat::mcset nl "Open" "Openen"
+ ::msgcat::mcset nl "Open Multiple Files" "Open meerdere bestanden"
+ ::msgcat::mcset nl "Paste" "Plakken"
+ ::msgcat::mcset nl "Please press %1\$s" "Druk op %1\$s, A.U.B."
+ ::msgcat::mcset nl "Please press ok" "Druk op ok, A.U.B."
+ ::msgcat::mcset nl "Press Cancel" "Druk op Annuleren"
+ ::msgcat::mcset nl "Press Ok" "Druk op Ok"
+ ::msgcat::mcset nl "Quit" "Stoppen"
+ ::msgcat::mcset nl "&Red" "&Rood"
+ ::msgcat::mcset nl "Replace existing file?" "Vervang bestaand bestand?"
+ ::msgcat::mcset nl "&Retry" "&Herhalen"
+ ::msgcat::mcset nl "&Save" "Op&slaan"
+ ::msgcat::mcset nl "Save As" "Opslaan als"
+ ::msgcat::mcset nl "Save To Log" "Opslaan naar Log"
+ ::msgcat::mcset nl "Select Log File" "Selecteer Log bestand"
+ ::msgcat::mcset nl "Select a file to source" "Selecteer bronbestand"
+ ::msgcat::mcset nl "&Selection:" "&Selectie:"
+ ::msgcat::mcset nl "Skip Messages" "Berichten overslaan"
+ ::msgcat::mcset nl "Source..." "Bron..."
+ ::msgcat::mcset nl "Tcl Scripts"
+ ::msgcat::mcset nl "Tcl for Windows" "Tcl voor Windows"
+ ::msgcat::mcset nl "Text Files" "Tekstbestanden"
+ ::msgcat::mcset nl "&Yes" "&Ja"
+ ::msgcat::mcset nl "abort" "afbreken"
+ ::msgcat::mcset nl "abort, retry, ignore, ok, cancel, no, or yes" "afbreken, opnieuw, negeren, ok, annuleren, nee, of ja"
+ ::msgcat::mcset nl "abortretryignore, ok, okcancel, retrycancel, yesno, or yesnocancel" "abortretryignore, ok, okcancel, retrycancel, yesno, of yesnocancel"
+ ::msgcat::mcset nl "bad %1\$s value \"%2\$s\": must be %3\$s" "verkeerde %1\$s waarde \"%2\$s\": moet zijn %3\$s"
+ ::msgcat::mcset nl "bad file type \"%1\$s\", should be" "verkeerd bestandstype \"%1\$s\", moet zijn"
+ ::msgcat::mcset nl "bad option \"%1\$s\": should be %2\$s" "verkeerde optie \"%1\$s\": moet zijn %2\$s"
+ ::msgcat::mcset nl "bad window path name \"%1\$s\"" "verkeerde window-padnaam \"%1\$s\""
+ ::msgcat::mcset nl "blue" "blauw"
+ ::msgcat::mcset nl "can't post %1\$s: it isn't a descendant of %2\$s (this is a new requirement in Tk versions 3.0 and later)" "kan %1\$s niet verzenden: het is geen afstammeling van %2\$s (dit is een nieuwe eis in Tk versies 3.0 en later)"
+ ::msgcat::mcset nl "cancel" "annuleren"
+ ::msgcat::mcset nl "default button index greater than number of buttons specified for tk_dialog" "default knop index is groter dan het aantal knoppen beschikbaar voor tk_dialog"
+ ::msgcat::mcset nl "display name to use (current one otherwise)" "te gebruiken schermnaam (anders huidige scherm)"
+ ::msgcat::mcset nl "error, info, question, or warning" "error, info, question, of warning"
+ ::msgcat::mcset nl "extension"
+ ::msgcat::mcset nl "extensions"
+ ::msgcat::mcset nl "focus group \"%1\$s\" doesn't exist" "focusgroep \"%1\$s\" bestaat niet"
+ ::msgcat::mcset nl "green" "groen"
+ ::msgcat::mcset nl "history event %1\$s"
+ ::msgcat::mcset nl "ignore" "negeren"
+ ::msgcat::mcset nl "invalid default button \"%1\$s\"" "ongeldige default knop \"%1\$s\""
+ ::msgcat::mcset nl "macType"
+ ::msgcat::mcset nl "macTypes"
+ ::msgcat::mcset nl "must specify a background color" "een achtergrondkleur is verplicht"
+ ::msgcat::mcset nl "name of the slave interpreter" "naam van de slaaf-interpreter"
+ ::msgcat::mcset nl "no winfo screen . nor env(DISPLAY)" "geen winfo scherm . noch env(DISPLAY)"
+ ::msgcat::mcset nl "ok"
+ ::msgcat::mcset nl "red" "rood"
+ ::msgcat::mcset nl "retry" "opnieuw"
+ ::msgcat::mcset nl "should contain 5 or 4 elements" "moet 4 of 5 elementen bevatten"
+ ::msgcat::mcset nl "spec"
+ ::msgcat::mcset nl "tk_chooseDirectory command" "tk_chooseDirectory opdracht"
+ ::msgcat::mcset nl "tk_chooseDirectory command, cancel gives null" "tk_chooseDirectory opdracht, annuleren geeft lege waarde"
+ ::msgcat::mcset nl "tk_chooseDirectory command, initialdir" "tk_chooseDirectory opdracht, initi\u00eble map"
+ ::msgcat::mcset nl "yes" "ja"
+}
diff --git a/jni/ruby/ext/tk/sample/msgs_tk/pl.msg b/jni/ruby/ext/tk/sample/msgs_tk/pl.msg
new file mode 100644
index 0000000..2699e42
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/msgs_tk/pl.msg
@@ -0,0 +1,87 @@
+namespace eval ::tkmsgcat_demo {
+ ::msgcat::mcset pl "Application Error" "Bl\u0105d w Programie"
+ ::msgcat::mcset pl "Blue" "Niebieski"
+ ::msgcat::mcset pl "Color" "Kolor"
+ ::msgcat::mcset pl "Delete" "Usu\u0144"
+ ::msgcat::mcset pl "Error" "B\u0142\u0105d"
+ ::msgcat::mcset pl "Exit" "Zako\u0144cz"
+ ::msgcat::mcset pl "Green" "Zielony"
+ ::msgcat::mcset pl "Red" "Czerwonz"
+ ::msgcat::mcset pl "blue" "niebieski"
+ ::msgcat::mcset pl "green" "zielony"
+ ::msgcat::mcset pl "red" "czerwony"
+}
+
+namespace eval ::tk {
+ ::msgcat::mcset pl "&Abort" "&Anuluj"
+ ::msgcat::mcset pl "&About..." "O Programie..."
+ ::msgcat::mcset pl "All Files" "Wszystkie pliki"
+ ::msgcat::mcset pl "Application Error" "Bl\u0105d w Programie"
+ ::msgcat::mcset pl "&Blue" "&Niebieski"
+ ::msgcat::mcset pl "&Cancel" "&Anuluj"
+ ::msgcat::mcset pl "Cannot change to the directory \"%1\$s\".\nPermission denied." "Katalog \"%1\$s\" nie mo\u017ce zosta\u0107 odczytany lub nie istnieje."
+ ::msgcat::mcset pl "Choose Directory" "Wybierz katalog"
+ ::msgcat::mcset pl "&Clear" "&Wyczy\u015b\u0107"
+ ::msgcat::mcset pl "&Clear Console" "&Wyczy\u015b\u0107 konsol\u0119"
+ ::msgcat::mcset pl "Color" "Kolor"
+ ::msgcat::mcset pl "Console" "Konsola"
+ ::msgcat::mcset pl "&Copy" "&Kopiuj"
+ ::msgcat::mcset pl "Cu&t" "&Wytnij"
+ ::msgcat::mcset pl "&Delete" "&Usu\u0144"
+ ::msgcat::mcset pl "Details >>" "Detale >>"
+ ::msgcat::mcset pl "Directory \"%1\$s\" does not exist." "Katalog \"%1\$s\" nie istniej."
+ ::msgcat::mcset pl "&Directory:" "&Katalog:"
+ ::msgcat::mcset pl "&Edit" "&Edytuj"
+ ::msgcat::mcset pl "Error: %1\$s" "B\u0142\u0105d: %1\$s"
+ ::msgcat::mcset pl "E&xit" "&Zako\u0144cz"
+ ::msgcat::mcset pl "&File" "&Plik"
+ ::msgcat::mcset pl "File \"%1\$s\" already exists.\nDo you want to overwrite it?" "Plik \"%1\$s\" ju\u017c istnieje.\nCzy chcesz go zast\u0105pi\u0107?"
+ ::msgcat::mcset pl "File \"%1\$s\" already exists.\n\n" "Plik \"%1\$s\" ju\u017c istnieje. \n\n"
+ ::msgcat::mcset pl "File \"%1\$s\" does not exist." "Plik \"%1\$s\" nie istnieje."
+ ::msgcat::mcset pl "File &name:" "Nazwa &pliku:"
+ ::msgcat::mcset pl "File &names:" "Nazwy &plik\u00f3w:"
+ ::msgcat::mcset pl "Files of &type:" "Pliki &typu:"
+ ::msgcat::mcset pl "Fi&les:" "Pli&ki:"
+ ::msgcat::mcset pl "&Filter" "&Filter"
+ ::msgcat::mcset pl "Fil&ter:" "&Filter:"
+ ::msgcat::mcset pl "&Green" "&Zielony"
+ ::msgcat::mcset pl "&Help" "&Pomoc"
+ ::msgcat::mcset pl "Hi" "Witaj"
+ ::msgcat::mcset pl "&Hide Console" "&Schowaj konsol\u0119"
+ ::msgcat::mcset pl "&Ignore" "&Ignoruj"
+ ::msgcat::mcset pl "Invalid file name \"%1\$s\"." "Niew\u0142a\u015bciwa nazwa pliku \"%1\$s\"."
+ ::msgcat::mcset pl "Log Files" "Protoko\u0142uj"
+ ::msgcat::mcset pl "&No" "&Nie"
+ ::msgcat::mcset pl "OK"
+ ::msgcat::mcset pl "Ok"
+ ::msgcat::mcset pl "Open" "Wczytaj"
+ ::msgcat::mcset pl "&Open" "&Wczytaj"
+ ::msgcat::mcset pl "Open Multiple Files" "Wczytuj wiele plik\u00f3w"
+ ::msgcat::mcset pl "P&aste" "&Wklej"
+ ::msgcat::mcset pl "&Quit" "&Zako\u0144cz"
+ ::msgcat::mcset pl "&Red" "&Czerwonz"
+ ::msgcat::mcset pl "Replace existing file?" "Czy zost\u0105pi\u0107 instniej\u0105cy plik?"
+ ::msgcat::mcset pl "&Retry" "&Powt\u00f3rz"
+ ::msgcat::mcset pl "&Save" "&Zapisz"
+ ::msgcat::mcset pl "Save As" "Zapisz jako"
+ ::msgcat::mcset pl "Save To Log" "Wpisz do protoko\u0142u"
+ ::msgcat::mcset pl "Select Log File" "Wybierz plik proko\u0142u"
+ ::msgcat::mcset pl "Select a file to source" "Wybierz plik do wykonania"
+ ::msgcat::mcset pl "&Selection:" "&Wyb\u00f3r:"
+ ::msgcat::mcset pl "Skip Messages" "Omi\u0144 pozosta\u0142e komunikaty"
+ ::msgcat::mcset pl "&Source..." "&Kod \u017ar\u00f3d\u0142owy..."
+ ::msgcat::mcset pl "Tcl Scripts" "Tcl-skrypty"
+ ::msgcat::mcset pl "Tcl for Windows" "Tcl dla Okienek (Windows)"
+ ::msgcat::mcset pl "Text Files" "Pliki Tekstowe"
+ ::msgcat::mcset pl "&Yes" "&Tak"
+ ::msgcat::mcset pl "abort" "zako\u0144cz"
+ ::msgcat::mcset pl "blue" "niebieski"
+ ::msgcat::mcset pl "cancel" "anuluj"
+ ::msgcat::mcset pl "extension" "rozszerzenie"
+ ::msgcat::mcset pl "extensions" "rozszerzenia"
+ ::msgcat::mcset pl "green" "zielony"
+ ::msgcat::mcset pl "ignore" "ignoruj"
+ ::msgcat::mcset pl "red" "czerwony"
+ ::msgcat::mcset pl "retry" "potw\u00f3rz"
+ ::msgcat::mcset pl "yes" "tak"
+}
diff --git a/jni/ruby/ext/tk/sample/msgs_tk/ru.msg b/jni/ruby/ext/tk/sample/msgs_tk/ru.msg
new file mode 100644
index 0000000..db009a4
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/msgs_tk/ru.msg
@@ -0,0 +1,87 @@
+namespace eval ::tkmsgcat_demo {
+ ::msgcat::mcset ru "Application Error" "\u041e\u0448\u0438\u0431\u043a\u0430 \u0432 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0435"
+ ::msgcat::mcset ru "Blue" " \u0413\u043e\u043b\u0443\u0431\u043e\u0439"
+ ::msgcat::mcset ru "Color" "\u0426\u0432\u0435\u0442"
+ ::msgcat::mcset ru "Delete" "\u0423\u0434\u0430\u043b\u0438\u0442\u044c"
+ ::msgcat::mcset ru "Error" "\u041e\u0448\u0438\u0431\u043a\u0430"
+ ::msgcat::mcset ru "Exit" "\u0412\u044b\u0445\u043e\u0434"
+ ::msgcat::mcset ru "Green" "\u0417\u0435\u043b\u0435\u043d\u044b\u0439"
+ ::msgcat::mcset ru "Red" "\u041a\u0440\u0430\u0441\u043d\u044b\u0439"
+ ::msgcat::mcset ru "blue" " \u0433\u043e\u043b\u0443\u0431\u043e\u0439"
+ ::msgcat::mcset ru "green" " \u0437\u0435\u043b\u0435\u043d\u044b\u0439"
+ ::msgcat::mcset ru "red" " \u043a\u0440\u0430\u0441\u043d\u044b\u0439"
+}
+
+namespace eval ::tk {
+ ::msgcat::mcset ru "&Abort" "&\u041e\u0442\u043c\u0435\u043d\u0438\u0442\u044c"
+ ::msgcat::mcset ru "About..." "\u041f\u0440\u043e..."
+ ::msgcat::mcset ru "All Files" "\u0412\u0441\u0435 \u0444\u0430\u0439\u043b\u044b"
+ ::msgcat::mcset ru "Application Error" "\u041e\u0448\u0438\u0431\u043a\u0430 \u0432 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0435"
+ ::msgcat::mcset ru "&Blue" " &\u0413\u043e\u043b\u0443\u0431\u043e\u0439"
+ ::msgcat::mcset ru "&Cancel" "\u041e\u0442&\u043c\u0435\u043d\u0430"
+ ::msgcat::mcset ru "Cannot change to the directory \"%1\$s\".\nPermission denied." \
+ "\u041d\u0435 \u043c\u043e\u0433\u0443 \u043f\u0435\u0440\u0435\u0439\u0442\u0438 \u0432 \u043a\u0430\u0442\u0430\u043b\u043e\u0433 \"%1\$s\".\n\u041d\u0435\u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u043f\u0440\u0430\u0432 \u0434\u043e\u0441\u0442\u0443\u043f\u0430"
+ ::msgcat::mcset ru "Choose Directory" "\u0412\u044b\u0431\u0435\u0440\u0438\u0442\u0435 \u043a\u0430\u0442\u0430\u043b\u043e\u0433"
+ ::msgcat::mcset ru "Clear" "\u041e\u0447\u0438\u0441\u0442\u0438\u0442\u044c"
+ ::msgcat::mcset ru "Color" "\u0426\u0432\u0435\u0442"
+ ::msgcat::mcset ru "Console" "\u041a\u043e\u043d\u0441\u043e\u043b\u044c"
+ ::msgcat::mcset ru "Copy" "\u041a\u043e\u043f\u0438\u0440\u043e\u0432\u0430\u0442\u044c"
+ ::msgcat::mcset ru "Cut" "\u0412\u044b\u0440\u0435\u0437\u0430\u0442\u044c"
+ ::msgcat::mcset ru "Delete" "\u0423\u0434\u0430\u043b\u0438\u0442\u044c"
+ ::msgcat::mcset ru "Details >>" "\u041f\u043e\u0434\u0440\u043e\u0431\u043d\u0435\u0435 >>"
+ ::msgcat::mcset ru "Directory \"%1\$s\" does not exist." "\u041a\u0430\u0442\u0430\u043b\u043e\u0433\u0430 \"%1\$s\" \u043d\u0435 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442."
+ ::msgcat::mcset ru "&Directory:" "&\u041a\u0430\u0442\u0430\u043b\u043e\u0433:"
+ ::msgcat::mcset ru "Error: %1\$s" "\u041e\u0448\u0438\u0431\u043a\u0430: %1\$s"
+ ::msgcat::mcset ru "Exit" "\u0412\u044b\u0445\u043e\u0434"
+ ::msgcat::mcset ru "File \"%1\$s\" already exists.\nDo you want to overwrite it?" \
+ "\u0424\u0430\u0439\u043b \"%1\$s\" \u0443\u0436\u0435 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442.\n\u0417\u0430\u043c\u0435\u043d\u0438\u0442\u044c \u0435\u0433\u043e?"
+ ::msgcat::mcset ru "File \"%1\$s\" already exists.\n\n" "\u0424\u0430\u0439\u043b \"%1\$s\" \u0443\u0436\u0435 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442.\n\n"
+ ::msgcat::mcset ru "File \"%1\$s\" does not exist." "\u0424\u0430\u0439\u043b \"%1\$s\" \u043d\u0435 \u043d\u0430\u0439\u0434\u0435\u043d."
+ ::msgcat::mcset ru "File &name:" "&\u0418\u043c\u044f \u0444\u0430\u0439\u043b\u0430:"
+ ::msgcat::mcset ru "File &names:" "&\u0418\u043c\u0435\u043d\u0430 \u0444\u0430\u0439\u043b\u043e\u0432:"
+ ::msgcat::mcset ru "Files of &type:" "&\u0422\u0438\u043f \u0444\u0430\u0439\u043b\u043e\u0432:"
+ ::msgcat::mcset ru "Fi&les:" "\u0424\u0430\u0439&\u043b\u044b:"
+ ::msgcat::mcset ru "&Filter" "&\u0424\u0438\u043b\u044c\u0442\u0440"
+ ::msgcat::mcset ru "Fil&ter:" "\u0424\u0438\u043b\u044c&\u0442\u0440:"
+ ::msgcat::mcset ru "&Green" " &\u0417\u0435\u043b\u0435\u043d\u044b\u0439"
+ ::msgcat::mcset ru "Hi" "\u041f\u0440\u0438\u0432\u0435\u0442"
+ ::msgcat::mcset ru "Hide Console" "\u0421\u043f\u0440\u044f\u0442\u0430\u0442\u044c \u043a\u043e\u043d\u0441\u043e\u043b\u044c"
+ ::msgcat::mcset ru "&Ignore" "&\u0418\u0433\u043d\u043e\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c"
+ ::msgcat::mcset ru "Invalid file name \"%1\$s\"." "\u041d\u0435\u0432\u0435\u0440\u043d\u043e\u0435 \u0438\u043c\u044f \u0444\u0430\u0439\u043b\u0430 \"%1\$s\"."
+ ::msgcat::mcset ru "Log Files" "\u0424\u0430\u0439\u043b\u044b \u0436\u0443\u0440\u043d\u0430\u043b\u0430"
+ ::msgcat::mcset ru "&No" "&\u041d\u0435\u0442"
+ ::msgcat::mcset ru "&OK" "&\u041e\u041a"
+ ::msgcat::mcset ru "Ok" "\u0414\u0430"
+ ::msgcat::mcset ru "Open" "\u041e\u0442\u043a\u0440\u044b\u0442\u044c"
+ ::msgcat::mcset ru "&Open" "&\u041e\u0442\u043a\u0440\u044b\u0442\u044c"
+ ::msgcat::mcset ru "Open Multiple Files" "\u041e\u0442\u043a\u0440\u044b\u0442\u044c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0444\u0430\u0439\u043b\u043e\u0432"
+ ::msgcat::mcset ru "Paste" "\u0412\u0441\u0442\u0430\u0432\u0438\u0442\u044c"
+ ::msgcat::mcset ru "Quit" "\u0412\u044b\u0445\u043e\u0434"
+ ::msgcat::mcset ru "&Red" " &\u041a\u0440\u0430\u0441\u043d\u044b\u0439"
+ ::msgcat::mcset ru "Replace existing file?" "\u0417\u0430\u043c\u0435\u043d\u0438\u0442\u044c \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0439 \u0444\u0430\u0439\u043b?"
+ ::msgcat::mcset ru "&Retry" "&\u041f\u043e\u0432\u0442\u043e\u0440\u0438\u0442\u044c"
+ ::msgcat::mcset ru "&Save" "&\u0421\u043e\u0445\u0440\u0430\u043d\u0438\u0442\u044c"
+ ::msgcat::mcset ru "Save As" "\u0421\u043e\u0445\u0440\u0430\u043d\u0438\u0442\u044c \u043a\u0430\u043a"
+ ::msgcat::mcset ru "Save To Log" "\u0421\u043e\u0445\u0440\u0430\u043d\u0438\u0442\u044c \u0432 \u0436\u0443\u0440\u043d\u0430\u043b"
+ ::msgcat::mcset ru "Select Log File" "\u0412\u044b\u0431\u0440\u0430\u0442\u044c \u0436\u0443\u0440\u043d\u0430\u043b"
+ ::msgcat::mcset ru "Select a file to source" "\u0412\u044b\u0431\u0435\u0440\u0438\u0442\u0435 \u0444\u0430\u0439\u043b \u0434\u043b\u044f \u0438\u043d\u0442\u0435\u0440\u043f\u0440\u0435\u0442\u0430\u0446\u0438\u0438"
+ ::msgcat::mcset ru "&Selection:" "&Selection:"
+ ::msgcat::mcset ru "Skip Messages" "\u041f\u0440\u043e\u043f\u0443\u0441\u0442\u0438\u0442\u044c \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f"
+ ::msgcat::mcset ru "Source..." "\u0418\u043d\u0442\u0435\u0440\u043f\u0440\u0435\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0444\u0430\u0439\u043b..."
+ ::msgcat::mcset ru "Tcl Scripts" "\u041f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0430 \u043d\u0430 \u044f\u0437\u044b\u043a\u0435 TCL"
+ ::msgcat::mcset ru "Tcl for Windows" "TCL \u0434\u043b\u044f Windows"
+ ::msgcat::mcset ru "Text Files" "\u0422\u0435\u043a\u0441\u0442\u043e\u0432\u044b\u0435 \u0444\u0430\u0439\u043b\u044b"
+ ::msgcat::mcset ru "&Yes" "&\u0414\u0430"
+ ::msgcat::mcset ru "abort" "\u043e\u0442\u043c\u0435\u043d\u0430"
+ ::msgcat::mcset ru "blue" " \u0433\u043e\u043b\u0443\u0431\u043e\u0439"
+ ::msgcat::mcset ru "cancel" "\u043e\u0442\u043c\u0435\u043d\u0430"
+ ::msgcat::mcset ru "extension" "\u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u0435"
+ ::msgcat::mcset ru "extensions" "\u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u044f"
+ ::msgcat::mcset ru "green" " \u0437\u0435\u043b\u0435\u043d\u044b\u0439"
+ ::msgcat::mcset ru "ignore" "\u043f\u0440\u043e\u043f\u0443\u0441\u0442\u0438\u0442\u044c"
+ ::msgcat::mcset ru "ok" "\u043e\u043a"
+ ::msgcat::mcset ru "red" " \u043a\u0440\u0430\u0441\u043d\u044b\u0439"
+ ::msgcat::mcset ru "retry" "\u043f\u043e\u0432\u0442\u043e\u0440\u0438\u0442\u044c"
+ ::msgcat::mcset ru "yes" "\u0434\u0430"
+}
+
diff --git a/jni/ruby/ext/tk/sample/multi-ip_sample.rb b/jni/ruby/ext/tk/sample/multi-ip_sample.rb
new file mode 100644
index 0000000..eccf020
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/multi-ip_sample.rb
@@ -0,0 +1,103 @@
+#!/usr/bin/env ruby
+# This script is a sample of MultiTkIp class
+
+require "multi-tk"
+
+# create slave interpreters
+trusted_slave = MultiTkIp.new_slave
+safe_slave1 = MultiTkIp.new_safeTk
+safe_slave2 = MultiTkIp.new_safeTk('fill'=>:none, 'expand'=>false)
+#safe_slave2 = MultiTkIp.new_safeTk('fill'=>:none)
+#safe_slave2 = MultiTkIp.new_safeTk('expand'=>false)
+
+cmd = Proc.new{|txt|
+ #####################
+ ## from TkTimer2.rb
+
+ if TkCore::INTERP.safe?
+ # safeTk doesn't have permission to call 'wm' command
+ else
+ root = TkRoot.new(:title=>'timer sample')
+ end
+ label = TkLabel.new(:parent=>root, :relief=>:raised, :width=>10) \
+ .pack(:side=>:bottom, :fill=>:both)
+
+ tick = proc{|aobj|
+ cnt = aobj.return_value + 5
+ label.text format("%d.%02d", *(cnt.divmod(100)))
+ cnt
+ }
+
+ timer = TkTimer.new(50, -1, tick).start(0, proc{ label.text('0.00'); 0 })
+
+=begin
+ TkButton.new(:text=>'Start') {
+ command proc{ timer.continue unless timer.running? }
+ pack(:side=>:left, :fill=>:both, :expand=>true)
+ }
+ TkButton.new(:text=>'Restart') {
+ command proc{ timer.restart(0, proc{ label.text('0.00'); 0 }) }
+ pack('side'=>'right','fill'=>'both','expand'=>'yes')
+ }
+ TkButton.new(:text=>'Stop') {
+ command proc{ timer.stop if timer.running? }
+ pack('side'=>'right','fill'=>'both','expand'=>'yes')
+ }
+=end
+ b_start = TkButton.new(:text=>'Start', :state=>:disabled) {
+ pack(:side=>:left, :fill=>:both, :expand=>true)
+ }
+
+ b_stop = TkButton.new(:text=>'Stop', :state=>:normal) {
+ pack('side'=>'left', 'fill'=>'both', 'expand'=>'yes')
+ }
+
+ b_start.command {
+ timer.continue
+ b_stop.state(:normal)
+ b_start.state(:disabled)
+ }
+
+ b_stop.command {
+ timer.stop
+ b_start.state(:normal)
+ b_stop.state(:disabled)
+ }
+
+ TkButton.new(:text=>'Reset', :state=>:normal) {
+ command { timer.reset }
+ pack('side'=>'right', 'fill'=>'both', 'expand'=>'yes')
+ }
+
+ ev_quit = TkVirtualEvent.new('Control-c', 'Control-q')
+ Tk.root.bind(ev_quit, proc{Tk.exit}).focus
+}
+
+# call on the default master interpreter
+trusted_slave.eval_proc(cmd, 'trusted') # label -> .w00012
+safe_slave1.eval_proc(cmd, 'safe1') # label -> .w00016
+safe_slave2.eval_proc(cmd, 'safe2') # label -> .w00020
+cmd.call('master') # label -> .w00024
+
+#second_master = MultiTkIp.new(&cmd)
+#second_master = MultiTkIp.new(:safe=>2){p [:second_master, $SAFE]}
+
+TkTimer.new(2000, -1, proc{p ['safe1', safe_slave1.deleted?]}).start
+TkTimer.new(2000, -1, proc{p ['safe2', safe_slave2.deleted?]}).start
+TkTimer.new(2000, -1, proc{p ['trusted', trusted_slave.deleted?]}).start
+
+TkTimer.new(5000, 1,
+ proc{
+ safe_slave1.eval_proc{Tk.root.destroy}
+ safe_slave1.delete
+ print "*** The safe_slave1 is deleted by the timer.\n"
+ }).start
+
+TkTimer.new(10000, 1,
+ proc{
+ trusted_slave.eval_proc{Tk.root.destroy}
+ trusted_slave.delete
+ print "*** The trusted_slave is deleted by the timer.\n"
+ }).start
+
+Tk.mainloop
diff --git a/jni/ruby/ext/tk/sample/multi-ip_sample2.rb b/jni/ruby/ext/tk/sample/multi-ip_sample2.rb
new file mode 100644
index 0000000..79c78de
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/multi-ip_sample2.rb
@@ -0,0 +1,29 @@
+require 'multi-tk.rb'
+
+th = Thread.new{Tk.mainloop}
+
+TkLabel.new(:text=>'this is a primary master').pack
+
+ip1 = MultiTkIp.new_slave(:safe=>1)
+ip2 = MultiTkIp.new_slave(:safe=>2)
+
+cmd = proc{|s|
+ require 'tk'
+
+ TkButton.new(:text=>'b1: p self', :command=>proc{p self}).pack(:fill=>:x)
+ sleep s
+ TkButton.new(:text=>'b2: p $SAFE', :command=>proc{p $SAFE}).pack(:fill=>:x)
+ sleep s
+ TkButton.new(:text=>'b3: p MultiTkIp.ip_name',
+ :command=>proc{p MultiTkIp.ip_name}).pack(:fill=>:x)
+ sleep s
+ TkButton.new(:text=>'EXIT', :command=>proc{exit}).pack(:fill=>:x)
+
+ Tk.mainloop
+}
+
+Thread.new{ip1.eval_proc(cmd, 1.1)}
+Thread.new{ip2.eval_proc(cmd, 0.3)}
+cmd.call(0.7)
+
+th.join
diff --git a/jni/ruby/ext/tk/sample/optobj_sample.rb b/jni/ruby/ext/tk/sample/optobj_sample.rb
new file mode 100644
index 0000000..a781254
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/optobj_sample.rb
@@ -0,0 +1,67 @@
+#!/usr/bin/env ruby
+#
+# sample script of Tk::OptionObj
+#
+require "tk"
+
+optobj = Tk::OptionObj.new('foreground'=>'red', 'background'=>'black')
+
+f = TkFrame.new.pack(:side=>:left, :anchor=>:n, :padx=>5, :pady=>30)
+
+b1 = TkButton.new(f, :text=>'AAA').pack(:fill=>:x)
+b2 = TkButton.new(f, :text=>'BBB').pack(:fill=>:x)
+b3 = TkButton.new(f, :text=>'CCC').pack(:fill=>:x)
+
+optobj.assign( b1,
+ [ b2, 'configure',
+ { 'foreground'=>'background',
+ 'background'=>'foreground' } ],
+ [ b3, nil,
+ { 'foreground'=>'background',
+ 'activeforeground'=>nil,
+ 'background'=>['foreground', 'activeforeground'] } ] )
+
+optobj.update('activeforeground'=>'yellow')
+
+TkButton.new(f){
+ configure( optobj.assign(self) + {:text=>'DDD'} )
+ pack(:fill=>:x)
+}
+
+TkButton.new(f){
+ configure( optobj.assign([self, nil,
+ {'foreground'=>'activeforeground',
+ 'background'=>'foreground',
+ 'activeforeground'=>'background'}]) \
+ + {:text=>'EEE', :relief=>:groove, :borderwidth=>5} )
+ pack(:fill=>:x)
+}
+
+optobj.notify # To apply the convert_key ( 3rd element of widget info
+ # (that is, {'foreground'=>'activeforeground', ,,, } )
+ # of the 'EEE' button
+
+TkButton.new(f, :text=>'toggle',
+ :command=>proc{
+ fg = optobj['foreground']
+ bg = optobj['background']
+ optobj.configure('foreground'=>bg, 'background'=>fg)
+ }).pack(:fill=>:x, :pady=>10)
+
+TkButton.new(f, :text=>'exit',
+ :command=>proc{exit}).pack(:fill=>:x, :pady=>10)
+
+TkFrame.new{|f|
+ pack(:side=>:right, :expand=>true, :fill=>:both)
+ TkLabel.new(f, :text=>'source::').pack(:anchor=>:w)
+ TkFrame.new(f){|ff|
+ TkText.new(ff){
+ yscrollbar(TkScrollbar.new(ff){pack(:fill=>:y, :side=>:right)})
+ insert('end', File.read(__FILE__))
+ pack(:side=>:left, :expand=>true, :fill=>:both)
+ }
+ pack(:expand=>true, :fill=>:both)
+ }
+}
+
+Tk.mainloop
diff --git a/jni/ruby/ext/tk/sample/propagate.rb b/jni/ruby/ext/tk/sample/propagate.rb
new file mode 100644
index 0000000..66f14ae
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/propagate.rb
@@ -0,0 +1,30 @@
+#!/usr/bin/env ruby
+require 'tk'
+
+TkLabel.new(:text=>"Please click the bottom frame").pack
+
+f = TkFrame.new(:width=>400, :height=>100, :background=>'yellow',
+ :relief=>'ridge', :borderwidth=>5).pack
+
+# TkPack.propagate(f, false) # <== important!!
+f.pack_propagate(false) # <== important!!
+
+list = (1..3).collect{|n|
+ TkButton.new(f, :text=>"button#{'-X'*n}"){
+ command proc{
+ puts "button#{'-X'*n}"
+ self.unpack
+ }
+ }
+}
+
+list.unshift(nil)
+
+f.bind('1', proc{
+ w = list.shift
+ w.unpack if w
+ list.push(w)
+ list[0].pack(:expand=>true, :anchor=>:center) if list[0]
+ })
+
+Tk.mainloop
diff --git a/jni/ruby/ext/tk/sample/remote-ip_sample.rb b/jni/ruby/ext/tk/sample/remote-ip_sample.rb
new file mode 100644
index 0000000..f6eed9e
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/remote-ip_sample.rb
@@ -0,0 +1,33 @@
+#!/usr/bin/env ruby
+require 'remote-tk'
+
+puts <<EOM
+This sample controls the other Tk interpreter (Ruby/Tk, Tcl/Tk, and so on)
+which running on the other process. For this purpose, Ruby/Tk uses Tcl/Tk's
+'send' command. Availability of the command depends on your GUI environment.
+If this script doesn't work, please check your environment (see Tcl/Tk FAQ).
+EOM
+#'
+
+unless (wish = TkWinfo.interps.find{|ip| ip =~ /^wish/})
+ puts ''
+ puts 'Please start "wish" (Tcl/Tk shell) before running this sample script.'
+ exit 1
+end
+
+ip = RemoteTkIp.new(wish)
+ip.eval_proc{TkButton.new(:command=>proc{puts 'This procesure is on the controller-ip (Ruby/Tk)'}, :text=>'print on Ruby/Tk (controller-ip)').pack(:fill=>:x)}
+ip.eval_proc{TkButton.new(:command=>'puts {This procesure is on the remote-ip (wish)}', :text=>'print on wish (remote-ip)').pack(:fill=>:x)}
+
+# If your remote-ip is Ruby/Tk, you can control the remote Ruby by
+# 'ruby' or 'ruby_eval' or 'ruby_cmd' on the Tk interpreter.
+if ip.is_rubytk?
+ ip.eval_proc{TkButton.new(:command=>'ruby {p 111; p Array.new(3,"ruby")}', :text=>'ruby cmd on the remote-ip').pack(:fill=>:x)}
+end
+
+ip.eval_proc{TkButton.new(:command=>'exit', :text=>'QUIT').pack(:fill=>:x)}
+
+TkButton.new(:command=>proc{exit}, :text=>'QUIT',
+ :padx=>10, :pady=>7).pack(:padx=>10, :pady=>7)
+
+Tk.mainloop
diff --git a/jni/ruby/ext/tk/sample/remote-ip_sample2.rb b/jni/ruby/ext/tk/sample/remote-ip_sample2.rb
new file mode 100644
index 0000000..d8cf3c7
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/remote-ip_sample2.rb
@@ -0,0 +1,56 @@
+#!/usr/bin/env ruby
+
+require 'remote-tk'
+
+# start sub-process
+ip_name = 'remote_ip'
+ip_list = TkWinfo.interps
+fork{
+ exec "/usr/bin/env ruby -r tk -e \"Tk.appname('#{ip_name}');Tk.mainloop\""
+}
+sleep 1 until (app = (TkWinfo.interps - ip_list)[0]) && app =~ /^#{ip_name}/
+p TkWinfo.interps
+
+# create RemoteTkIp object
+ip = RemoteTkIp.new(app)
+
+# setup remote-ip window
+btns = []
+ip.eval_proc{
+ btns <<
+ TkButton.new(:command=>proc{
+ puts 'This procesure is on the controller-ip (Ruby-side)'
+ },
+ :text=>'print on controller-ip (Ruby-side)').pack(:fill=>:x)
+
+ btns <<
+ TkButton.new(:command=>
+ 'puts {This procesure is on the remote-ip (Tk-side)}',
+ :text=>'print on remote-ip (Tk-side)').pack(:fill=>:x)
+
+ btns <<
+ TkButton.new(:command=>
+ 'ruby {
+ puts "This procedure is on the remote-ip (Ruby-side)"
+ p Array.new(3,"ruby")
+ }',
+ :text=>'ruby cmd on the remote-ip').pack(:fill=>:x)
+
+ TkButton.new(:command=>'exit', :text=>'QUIT').pack(:fill=>:x)
+}
+
+# setup controller-ip window
+btns.each_with_index{|btn, idx|
+ # The scope of the eval-block of 'eval_proc' method is different from
+ # the enternal. If you want to pass local values to the eval-block,
+ # use arguments of eval_proc method. They are passed to block-arguments.
+ TkButton.new(:command=>proc{ip.eval_proc(btn){|b| b.flash}},
+ :text=>"flash button-#{idx}",
+ :padx=>10).pack(:padx=>10, :pady=>2)
+}
+
+TkButton.new(:command=>proc{exit}, :text=>'QUIT',
+ :padx=>10, :pady=>7).pack(:padx=>10, :pady=>7)
+
+# start eventloop
+Tk.mainloop
diff --git a/jni/ruby/ext/tk/sample/resource.en b/jni/ruby/ext/tk/sample/resource.en
new file mode 100644
index 0000000..39b4013
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/resource.en
@@ -0,0 +1,13 @@
+!
+! see Tcl/Tk's "options" manual for "Database Name" and "Database Class"
+!
+*BtnFrame.borderWidth: 5
+*BtnFrame.relief: ridge
+*BtnFrame.Button.background: wheat
+*BtnFrame.Button.foreground: red
+*hello.text: HELLO
+*quit.text: QUIT
+*BTN_CMD.show_msg: {|arg| print "($SAFE=#{$SAFE}) ";\
+ print "Hello!! This is a sample of #{arg}.";\
+ print "(<<< $SAFE=#{$SAFE})\n"}
+*BTN_CMD.bye_msg: {print "($SAFE=#{$SAFE} >>>) Good-bye¡¥(<<< $SAFE=#{$SAFE})\n"}
diff --git a/jni/ruby/ext/tk/sample/resource.ja b/jni/ruby/ext/tk/sample/resource.ja
new file mode 100644
index 0000000..a61390f
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/resource.ja
@@ -0,0 +1,13 @@
+!
+! see Tcl/Tk's "options" manual for "Database Name" and "Database Class"
+!
+*BtnFrame.borderWidth: 5
+*BtnFrame.relief: ridge
+*BtnFrame.Button.background: wheat
+*BtnFrame.Button.foreground: red
+*hello.text: ¤³¤ó¤Ë¤Á¤Ï
+*quit.text: ½ªÎ»
+*BTN_CMD.show_msg: {|arg| print "($SAFE=#{$SAFE} >>>) ";\
+ print "¤³¤ó¤Ë¤Á¤Ï¡ª¡ª #{arg} ¤Î¥µ¥ó¥×¥ë¤Ç¤¹¡¥";\
+ print "(<<< $SAFE=#{$SAFE})\n"}
+*BTN_CMD.bye_msg: {print "($SAFE=#{$SAFE} >>>) ¤µ¤è¤¦¤Ê¤é¡¥(<<< $SAFE=#{$SAFE})\n"}
diff --git a/jni/ruby/ext/tk/sample/safe-tk.rb b/jni/ruby/ext/tk/sample/safe-tk.rb
new file mode 100644
index 0000000..38131c0
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/safe-tk.rb
@@ -0,0 +1,134 @@
+#!/usr/bin/env ruby
+# This script is a sample of MultiTkIp class
+
+require "multi-tk"
+
+###############################
+
+TkLabel.new(:text=>'This is the Default Master Ipnterpreter').pack(:padx=>5, :pady=>3)
+TkButton.new(:text=>'QUIT', :command=>proc{exit}).pack(:pady=>3)
+TkFrame.new(:borderwidth=>2, :height=>3,
+ :relief=>:sunken).pack(:fill=>:x, :expand=>true,
+ :padx=>10, :pady=>7)
+
+safe0_p = proc{|*args| p args}
+
+###############################
+
+puts "---- create a safe slave IP with Ruby's safe-level == 1 ----------"
+ip = MultiTkIp.new_safe_slave(1){|*args| safe0_p["safe_slave safe_level == #{$SAFE}", args]}
+
+puts "\n---- create procs ----------"
+puts 'x = proc{p [\'proc x\', "$SAFE==#{$SAFE}"]; exit}'
+#x = proc{p ['proc x', "$SAFE==#{$SAFE}"]; exit}
+x = proc{p ['proc x', "$SAFE==#{$SAFE}"]; exit}
+TkLabel.new(:text=>'x = proc{p [\'proc x\', "$SAFE==#{$SAFE}"]; exit}',
+ :anchor=>:w).pack(:fill=>:x)
+
+puts 'y = proc{|label| p [\'proc y\', "$SAFE==#{$SAFE}", label]; label.text($SAFE)}'
+y = proc{|label| p ['proc y', "$SAFE==#{$SAFE}", label]; label.text($SAFE)}
+TkLabel.new(:text=>'y = proc{|label| p [\'proc y\', "$SAFE==#{$SAFE}", label]; label.text($SAFE)}',
+ :anchor=>:w).pack(:fill=>:x)
+
+puts 'z = proc{p [\'proc z\', "$SAFE==#{$SAFE}"]; exit}'
+z = proc{p ['proc z', "$SAFE==#{$SAFE}"]; exit}
+TkLabel.new(:text=>'z = proc{p [\'proc z\', "$SAFE==#{$SAFE}"]; exit}',
+ :anchor=>:w).pack(:fill=>:x)
+
+puts "\n---- call 1st eval_proc ----------"
+print 'lbl = '
+p lbl = ip.eval_proc{
+ TkLabel.new(:text=>"1st eval_proc : $SAFE == #{$SAFE}").pack
+
+ f = TkFrame.new.pack
+ TkLabel.new(f, :text=>"$SAFE == ").pack(:side=>:left)
+ # TkLabel.new(f, :text=>" (<-- 'lbl' widget is here)").pack(:side=>:right)
+ l = TkLabel.new(f).pack(:side=>:right)
+
+ TkButton.new(:text=>':command=>proc{l.text($SAFE)}',
+ :command=>proc{l.text($SAFE)}).pack(:fill=>:x, :padx=>5)
+ TkButton.new(:text=>':command=>x', :command=>x).pack(:fill=>:x, :padx=>5)
+ TkButton.new(:text=>':command=>proc{exit}',
+ :command=>proc{
+ safe0_p["'exit' is called at $SAFE=#{$SAFE}"];exit}
+ ).pack(:fill=>:x, :padx=>5)
+ TkFrame.new(:borderwidth=>2, :height=>3,
+ :relief=>:sunken).pack(:fill=>:x, :expand=>true,
+ :padx=>10, :pady=>7)
+ l # return the label widget
+}
+
+puts "\n---- change the safe slave IP's safe-level ==> 3 ----------"
+ip.safe_level = 3
+
+puts "\n---- call 2nd eval_proc ----------"
+p ip.eval_proc(proc{
+ TkLabel.new(:text=>"2nd eval_proc : $SAFE == #{$SAFE}").pack
+ f = TkFrame.new.pack
+ TkLabel.new(f, :text=>"$SAFE == ").pack(:side=>:left)
+ l = TkLabel.new(f, :text=>$SAFE).pack(:side=>:right)
+ TkButton.new(:text=>':command=>proc{l.text($SAFE)}',
+ :command=>proc{l.text($SAFE)}).pack(:fill=>:x,
+ :padx=>5)
+ TkButton.new(:text=>':command=>proc{y.call(l)}',
+ :command=>proc{y.call(l)}).pack(:fill=>:x,
+ :padx=>5)
+ TkButton.new(:text=>':command=>proc{Proc.new(&y).call(l)}',
+ :command=>proc{
+ Proc.new(&y).call(l)
+ }).pack(:fill=>:x, :padx=>5)
+ TkButton.new(:text=>':command=>proc{MultiTkIp._proc_on_current_safelevel(y).call(l)}',
+ :command=>proc{
+ MultiTkIp._proc_on_current_safelevel(y).call(l)
+ }).pack(:fill=>:x, :padx=>5)
+if false && Object.const_defined?(:RubyVM) && ::RubyVM.class == Class
+ TkButton.new(:text=>':command=>proc{Thread.new(l, &y).value}',
+ :command=>proc{
+ Thread.new(l, &y).value
+ }).pack(:fill=>:x, :padx=>5)
+else
+ # KNOWN BUG::
+ # Current multi-tk.rb cannot support long term threads on callbacks.
+ # Such a thread freezes the Ruby/Tk process.
+end
+ TkButton.new(:text=>':command=>proc{z.call}',
+ :command=>proc{z.call}).pack(:fill=>:x, :padx=>5)
+ TkFrame.new(:borderwidth=>2, :height=>3,
+ :relief=>:sunken).pack(:fill=>:x, :expand=>true,
+ :padx=>10, :pady=>7)
+ })
+
+puts "\n---- call 1st and 2nd eval_str ----------"
+p bind = ip.eval_str('
+ TkLabel.new(:text=>"1st and 2nd eval_str : $SAFE == #{$SAFE}").pack
+ f = TkFrame.new.pack
+ TkLabel.new(f, :text=>"$SAFE == ").pack(:side=>:left)
+ l = TkLabel.new(f, :text=>$SAFE).pack(:side=>:right)
+ TkButton.new(:text=>":command=>proc{y.call(l)}",
+ :command=>proc{y.call(l)}).pack(:fill=>:x, :padx=>5)
+ binding
+', binding)
+
+p ip.eval_str("
+ TkButton.new(:text=>':command=>proc{ l.text = $SAFE }',
+ :command=>proc{ l.text = $SAFE }).pack(:fill=>:x, :padx=>5)
+ TkFrame.new(:borderwidth=>2, :height=>3,
+ :relief=>:sunken).pack(:fill=>:x, :expand=>true,
+ :padx=>10, :pady=>7)
+", bind)
+
+puts "\n---- change the safe slave IP's safe-level ==> 4 ----------"
+ip.safe_level = 4
+
+puts "\n---- call 3rd and 4th eval_proc ----------"
+p ip.eval_proc{
+ TkLabel.new(:text=>"3rd and 4th eval_proc : $SAFE == #{$SAFE}").pack
+}
+p ip.eval_proc{
+ TkButton.new(:text=>':command=>proc{ lbl.text = $SAFE }',
+ :command=>proc{ lbl.text = $SAFE }).pack(:fill=>:x, :padx=>5)
+}
+
+puts "\n---- start event-loop ( current $SAFE == #{$SAFE} ) ----------"
+
+Tk.mainloop
diff --git a/jni/ruby/ext/tk/sample/scrollframe.rb b/jni/ruby/ext/tk/sample/scrollframe.rb
new file mode 100644
index 0000000..e9d8af7
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/scrollframe.rb
@@ -0,0 +1,249 @@
+#
+# Tk::RbWidget::ScrollFrame class
+#
+# This widget class is a frame widget with scrollbars.
+# The ScrollFrame doesn't propagate the size of embedded widgets.
+# When it is configured, scrollregion of the container is changed.
+#
+# Scrollbars can be toggled by Tk::RbWidget::ScrollFrame#vscroll & hscroll.
+# If horizontal or virtical scrollbar is turned off, the horizontal
+# or virtical size of embedded widgets is propagated.
+#
+# Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+require 'tk'
+
+module Tk::RbWidget; end
+
+class Tk::RbWidget::ScrollFrame < TkFrame
+ include TkComposite
+
+ DEFAULT_WIDTH = 200
+ DEFAULT_HEIGHT = 200
+
+ def initialize_composite(keys={})
+ @frame.configure(:width=>DEFAULT_WIDTH, :height=>DEFAULT_HEIGHT)
+
+ # create scrollbars
+ @h_scroll = TkScrollbar.new(@frame, 'orient'=>'horizontal')
+ @v_scroll = TkScrollbar.new(@frame, 'orient'=>'vertical')
+
+ # create a canvas widget
+ @canvas = TkCanvas.new(@frame,
+ :borderwidth=>0, :selectborderwidth=>0,
+ :highlightthickness=>0)
+
+ # allignment
+ TkGrid.rowconfigure(@frame, 0, 'weight'=>1, 'minsize'=>0)
+ TkGrid.columnconfigure(@frame, 0, 'weight'=>1, 'minsize'=>0)
+ @canvas.grid('row'=>0, 'column'=>0, 'sticky'=>'news')
+ @frame.grid_propagate(false)
+
+ # assign scrollbars
+ @canvas.xscrollbar(@h_scroll)
+ @canvas.yscrollbar(@v_scroll)
+
+ # convert hash keys
+ keys = _symbolkey2str(keys)
+
+ # check options for the frame
+ framekeys = {}
+ if keys.key?('classname')
+ keys['class'] = keys.delete('classname')
+ end
+ if @classname = keys.delete('class')
+ framekeys['class'] = @classname
+ end
+ if @colormap = keys.delete('colormap')
+ framekeys['colormap'] = @colormap
+ end
+ if @container = keys.delete('container')
+ framekeys['container'] = @container
+ end
+ if @visual = keys.delete('visual')
+ framekeys['visual'] = @visual
+ end
+ if @classname.kind_of? TkBindTag
+ @db_class = @classname
+ @classname = @classname.id
+ elsif @classname
+ @db_class = TkDatabaseClass.new(@classname)
+ else
+ @db_class = self.class
+ @classname = @db_class::WidgetClassName
+ end
+
+ # create base frame
+ @base = TkFrame.new(@canvas, framekeys)
+
+ # embed base frame
+ @cwin = TkcWindow.new(@canvas, [0, 0], :window=>@base, :anchor=>'nw')
+ @canvas.scrollregion(@cwin.bbox)
+
+ # binding to reset scrollregion
+ @base.bind('Configure'){ _reset_scrollregion(nil, nil) }
+
+ # set default receiver of method calls
+ @path = @base.path
+
+ # scrollbars ON
+ vscroll(keys.delete('vscroll'){true})
+ hscroll(keys.delete('hscroll'){true})
+
+ # please check the differences of the following definitions
+ option_methods(
+ :scrollbarwidth
+ )
+
+ # set receiver widgets for configure methods (with alias)
+ delegate_alias('scrollbarrelief', 'relief', @h_scroll, @v_scroll)
+
+ # set receiver widgets for configure methods
+ delegate('DEFAULT', @base)
+ delegate('background', @frame, @base, @canvas, @h_scroll, @v_scroll)
+ delegate('width', @frame)
+ delegate('height', @frame)
+ delegate('activebackground', @h_scroll, @v_scroll)
+ delegate('troughcolor', @h_scroll, @v_scroll)
+ delegate('repeatdelay', @h_scroll, @v_scroll)
+ delegate('repeatinterval', @h_scroll, @v_scroll)
+ delegate('borderwidth', @frame)
+ delegate('relief', @frame)
+
+ # do configure
+ configure keys unless keys.empty?
+ end
+
+ # callback for Configure event
+ def _reset_scrollregion(h_mod=nil, v_mod=nil)
+ cx1, cy1, cx2, cy2 = @canvas.scrollregion
+ x1, y1, x2, y2 = @cwin.bbox
+ @canvas.scrollregion([x1, y1, x2, y2])
+
+ if h_mod.nil? && v_mod.nil?
+ if x2 != cx2 && TkGrid.info(@h_scroll).size == 0
+ @frame.grid_propagate(true)
+ @canvas.width = x2
+ Tk.update_idletasks
+ @frame.grid_propagate(false)
+ end
+ if y2 != cy2 && TkGrid.info(@v_scroll).size == 0
+ @frame.grid_propagate(true)
+ @canvas.height = y2
+ Tk.update_idletasks
+ @frame.grid_propagate(false)
+ end
+ else
+ @h_scroll.ungrid if h_mod == false
+ @v_scroll.ungrid if v_mod == false
+
+ h_flag = (TkGrid.info(@h_scroll).size == 0)
+ v_flag = (TkGrid.info(@v_scroll).size == 0)
+
+ @frame.grid_propagate(true)
+
+ @canvas.width = (h_flag)? x2: @canvas.winfo_width
+ @canvas.height = (v_flag)? y2: @canvas.winfo_height
+
+ @h_scroll.grid('row'=>1, 'column'=>0, 'sticky'=>'ew') if h_mod
+ @v_scroll.grid('row'=>0, 'column'=>1, 'sticky'=>'ns') if v_mod
+
+ Tk.update_idletasks
+
+ @frame.grid_propagate(false)
+ end
+ end
+ private :_reset_scrollregion
+
+ # forbid to change binding of @base frame
+ def bind(*args)
+ @frame.bind(*args)
+ end
+ def bind_append(*args)
+ @frame.bind_append(*args)
+ end
+ def bind_remove(*args)
+ @frame.bind_remove(*args)
+ end
+ def bindinfo(*args)
+ @frame.bindinfo(*args)
+ end
+
+ # set width of scrollbar
+ def scrollbarwidth(width = nil)
+ if width
+ @h_scroll.width(width)
+ @v_scroll.width(width)
+ else
+ @h_scroll.width
+ end
+ end
+
+ # vertical scrollbar : ON/OFF
+ def vscroll(mode)
+ Tk.update_idletasks
+ st = TkGrid.info(@v_scroll)
+ if mode && st.size == 0 then
+ @v_scroll.grid('row'=>0, 'column'=>1, 'sticky'=>'ns')
+ _reset_scrollregion(nil, true)
+ elsif !mode && st.size != 0 then
+ _reset_scrollregion(nil, false)
+ else
+ _reset_scrollregion(nil, nil)
+ end
+ self
+ end
+
+ # horizontal scrollbar : ON/OFF
+ def hscroll(mode)
+ Tk.update_idletasks
+ st = TkGrid.info(@h_scroll)
+ if mode && st.size == 0 then
+ _reset_scrollregion(true, nil)
+ elsif !mode && st.size != 0 then
+ _reset_scrollregion(false, nil)
+ else
+ _reset_scrollregion(nil, nil)
+ end
+ self
+ end
+end
+
+# test
+if __FILE__ == $0
+ f = Tk::RbWidget::ScrollFrame.new(:scrollbarwidth=>10,
+ :width=>300, :height=>200)
+ f.pack(:expand=>true, :fill=>:both)
+
+ TkButton.new(f, :text=>'foo button', :command=>proc{puts 'foo'}).pack
+ TkButton.new(f, :text=>'baaar button', :command=>proc{puts 'baaar'}).pack
+ TkButton.new(f, :text=>'baz button', :command=>proc{puts 'baz'}).pack
+ TkButton.new(f, :text=>'hoge hoge button',
+ :command=>proc{puts 'hoge hoge'}).pack(:side=>:bottom)
+
+ # f.hscroll(false)
+
+ # add a text widget
+ Tk.after(3000){
+ t = TkText.new(f).pack(:expand=>true, :fill=>:both)
+ t.insert(:end, "An example of Tk::RbWidget::ScrollFrame widget.\n\n")
+ t.insert(:end, "Here is a text widget.\n")
+ t.insert(:end, "Please resize the application window, ")
+ t.insert(:end, "and try the scrollbars ")
+ t.insert(:end, "to move the view of packed widgets.\n")
+ }
+
+ # remove a vertical scrollbar, and then the scrollframe is not scrollable.
+ Tk.after(6000){ f.vscroll(false) }
+
+ # add a vertical scrollbar, and make the scrollframe scrollable.
+ Tk.after(9000){ f.vscroll(true) }
+
+ # remove a horizontal scrollbar, and then the scrollframe is not scrollable.
+ Tk.after(12000){ f.hscroll(false) }
+
+ # add a horizontal scrollbar, and make the scrollframe scrollable.
+ Tk.after(15000){ f.hscroll(true) }
+
+ Tk.mainloop
+end
diff --git a/jni/ruby/ext/tk/sample/tcltklib/batsu.gif b/jni/ruby/ext/tk/sample/tcltklib/batsu.gif
new file mode 100644
index 0000000..880cc73
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tcltklib/batsu.gif
Binary files differ
diff --git a/jni/ruby/ext/tk/sample/tcltklib/lines0.tcl b/jni/ruby/ext/tk/sample/tcltklib/lines0.tcl
new file mode 100644
index 0000000..8ed3c5e
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tcltklib/lines0.tcl
@@ -0,0 +1,42 @@
+#! /usr/local/bin/wish
+
+proc drawlines {} {
+ puts [clock format [clock seconds]]
+
+ for {set j 0} {$j < 100} {incr j} {
+ puts -nonewline "*"
+ flush stdout
+ if {$j & 1} {
+ set c "blue"
+ } {
+ set c "red"
+ }
+ for {set i 0} {$i < 100} {incr i} {
+# .a create line $i 0 0 [expr 500 - $i] -fill $c
+ }
+ }
+
+ puts [clock format [clock seconds]]
+
+ for {set j 0} {$j < 100} {incr j} {
+ puts -nonewline "*"
+ flush stdout
+ if {$j & 1} {
+ set c "blue"
+ } {
+ set c "red"
+ }
+ for {set i 0} {$i < 100} {incr i} {
+ .a create line $i 0 0 [expr 500 - $i] -fill $c
+ }
+ }
+
+ puts [clock format [clock seconds]]
+# destroy .
+}
+
+canvas .a -height 500 -width 500
+button .b -text draw -command drawlines
+pack .a .b -side left
+
+# eof
diff --git a/jni/ruby/ext/tk/sample/tcltklib/lines1.rb b/jni/ruby/ext/tk/sample/tcltklib/lines1.rb
new file mode 100644
index 0000000..9f21ae6
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tcltklib/lines1.rb
@@ -0,0 +1,50 @@
+#! /usr/local/bin/ruby
+
+require "tcltk"
+
+def drawlines()
+ print Time.now, "\n"
+
+ for j in 0 .. 99
+ print "*"
+ $stdout.flush
+ if (j & 1) != 0
+ col = "blue"
+ else
+ col = "red"
+ end
+ for i in 0 .. 99
+# $a.e("create line", i, 0, 0, 500 - i, "-fill", col)
+ end
+ end
+
+ print Time.now, "\n"
+
+ for j in 0 .. 99
+ print "*"
+ $stdout.flush
+ if (j & 1) != 0
+ col = "blue"
+ else
+ col = "red"
+ end
+ for i in 0 .. 99
+ $a.e("create line", i, 0, 0, 500 - i, "-fill", col)
+ end
+ end
+
+ print Time.now, "\n"
+# $ip.commands()["destroy"].e($root)
+end
+
+$ip = TclTkInterpreter.new()
+$root = $ip.rootwidget()
+$a = TclTkWidget.new($ip, $root, "canvas", "-height 500 -width 500")
+$c = TclTkCallback.new($ip, proc{drawlines()})
+$b = TclTkWidget.new($ip, $root, "button", "-text draw -command", $c)
+
+$ip.commands()["pack"].e($a, $b, "-side left")
+
+TclTk.mainloop
+
+# eof
diff --git a/jni/ruby/ext/tk/sample/tcltklib/lines2.rb b/jni/ruby/ext/tk/sample/tcltklib/lines2.rb
new file mode 100644
index 0000000..e459589
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tcltklib/lines2.rb
@@ -0,0 +1,54 @@
+#! /usr/local/bin/ruby
+
+require "tk"
+
+def drawlines()
+ print Time.now, "\n"
+
+ for j in 0 .. 99
+ print "*"
+ $stdout.flush
+ if (j & 1) != 0
+ col = "blue"
+ else
+ col = "red"
+ end
+ for i in 0 .. 99
+# TkcLine.new($a, i, 0, 0, 500 - i, "-fill", col)
+ end
+ end
+
+ print Time.now, "\n"
+
+ for j in 0 .. 99
+ print "*"
+ $stdout.flush
+ if (j & 1) != 0
+ col = "blue"
+ else
+ col = "red"
+ end
+ for i in 0 .. 99
+ TkcLine.new($a, i, 0, 0, 500 - i, "-fill", col)
+ end
+ end
+
+ print Time.now, "\n"
+# Tk.root.destroy
+end
+
+$a = TkCanvas.new{
+ height(500)
+ width(500)
+}
+
+$b = TkButton.new{
+ text("draw")
+ command(proc{drawlines()})
+}
+
+TkPack.configure($a, $b, {"side"=>"left"})
+
+Tk.mainloop
+
+# eof
diff --git a/jni/ruby/ext/tk/sample/tcltklib/lines3.rb b/jni/ruby/ext/tk/sample/tcltklib/lines3.rb
new file mode 100644
index 0000000..caa50f9
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tcltklib/lines3.rb
@@ -0,0 +1,54 @@
+#! /usr/local/bin/ruby
+
+require "tk"
+
+def drawlines()
+ print Time.now, "\n"
+
+ for j in 0 .. 99
+ print "*"
+ $stdout.flush
+ if (j & 1) != 0
+ col = "blue"
+ else
+ col = "red"
+ end
+ for i in 0 .. 99
+# $a.create(TkcLine, i, 0, 0, 500 - i, "fill"=>col)
+ end
+ end
+
+ print Time.now, "\n"
+
+ for j in 0 .. 99
+ print "*"
+ $stdout.flush
+ if (j & 1) != 0
+ col = "blue"
+ else
+ col = "red"
+ end
+ for i in 0 .. 99
+ $a.create(TkcLine, i, 0, 0, 500 - i, "fill"=>col)
+ end
+ end
+
+ print Time.now, "\n"
+# Tk.root.destroy
+end
+
+$a = TkCanvas.new{
+ height(500)
+ width(500)
+}
+
+$b = TkButton.new{
+ text("draw")
+ command(proc{drawlines()})
+}
+
+TkPack.configure($a, $b, {"side"=>"left"})
+
+Tk.mainloop
+
+# eof
diff --git a/jni/ruby/ext/tk/sample/tcltklib/lines4.rb b/jni/ruby/ext/tk/sample/tcltklib/lines4.rb
new file mode 100644
index 0000000..7a1175b
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tcltklib/lines4.rb
@@ -0,0 +1,54 @@
+#! /usr/local/bin/ruby
+
+require "tk"
+
+def drawlines()
+ print Time.now, "\n"
+
+ for j in 0 .. 99
+ print "*"
+ $stdout.flush
+ if (j & 1) != 0
+ col = "blue"
+ else
+ col = "red"
+ end
+ for i in 0 .. 99
+# TkCore::INTERP.__invoke($a.path, "create", "line", i.to_s, '0', '0', (500 - i).to_s, "-fill", col)
+ end
+ end
+
+ print Time.now, "\n"
+
+ for j in 0 .. 99
+ print "*"
+ $stdout.flush
+ if (j & 1) != 0
+ col = "blue"
+ else
+ col = "red"
+ end
+ for i in 0 .. 99
+ TkCore::INTERP.__invoke($a.path, "create", "line", i.to_s, '0', '0', (500 - i).to_s, "-fill", col)
+ end
+ end
+
+ print Time.now, "\n"
+# Tk.root.destroy
+end
+
+$a = TkCanvas.new{
+ height(500)
+ width(500)
+}
+
+$b = TkButton.new{
+ text("draw")
+ command(proc{drawlines()})
+}
+
+TkPack.configure($a, $b, {"side"=>"left"})
+
+Tk.mainloop
+
+# eof
diff --git a/jni/ruby/ext/tk/sample/tcltklib/maru.gif b/jni/ruby/ext/tk/sample/tcltklib/maru.gif
new file mode 100644
index 0000000..2c02028
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tcltklib/maru.gif
Binary files differ
diff --git a/jni/ruby/ext/tk/sample/tcltklib/safeTk.rb b/jni/ruby/ext/tk/sample/tcltklib/safeTk.rb
new file mode 100644
index 0000000..5d2c60e
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tcltklib/safeTk.rb
@@ -0,0 +1,22 @@
+#!/usr/bin/env ruby
+require 'tcltklib'
+
+master = TclTkIp.new
+slave_name = 'slave0'
+slave = master.create_slave(slave_name, true)
+master._eval("::safe::interpInit #{slave_name}")
+master._eval("::safe::loadTk #{slave_name}")
+
+master._invoke('label', '.l1', '-text', 'master')
+master._invoke('pack', '.l1', '-padx', '30', '-pady', '50')
+master._eval('label .l2 -text {root widget of master-ip}')
+master._eval('pack .l2 -padx 30 -pady 50')
+
+slave._invoke('label', '.l1', '-text', 'slave')
+slave._invoke('pack', '.l1', '-padx', '30', '-pady', '50')
+slave._eval('label .l2 -text {root widget of slave-ip}')
+slave._eval('pack .l2 -padx 30 -pady 20')
+slave._eval('label .l3 -text {( container frame widget of master-ip )}')
+slave._eval('pack .l3 -padx 30 -pady 20')
+
+TclTkLib.mainloop
diff --git a/jni/ruby/ext/tk/sample/tcltklib/sample0.rb b/jni/ruby/ext/tk/sample/tcltklib/sample0.rb
new file mode 100644
index 0000000..0ac303a
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tcltklib/sample0.rb
@@ -0,0 +1,39 @@
+#! /usr/local/bin/ruby -vd
+
+# tcltklib ライブラリã®ãƒ†ã‚¹ãƒˆ
+
+require "tcltklib"
+
+def test
+ # インタプリタを生æˆã™ã‚‹
+ ip1 = TclTkIp.new()
+
+ # 評価ã—ã¦ã¿ã‚‹
+ print ip1._return_value().inspect, "\n"
+ print ip1._eval("puts {abc}").inspect, "\n"
+
+ # ボタンを作ã£ã¦ã¿ã‚‹
+ print ip1._return_value().inspect, "\n"
+ print ip1._eval("button .lab -text exit -command \"destroy .\"").inspect,
+ "\n"
+ print ip1._return_value().inspect, "\n"
+ print ip1._eval("pack .lab").inspect, "\n"
+ print ip1._return_value().inspect, "\n"
+
+ # インタプリタã‹ã‚‰ ruby コマンドを評価ã—ã¦ã¿ã‚‹
+# print ip1._eval(%q/ruby {print "print by ruby\n"}/).inspect, "\n"
+ print ip1._eval(%q+puts [ruby {print "print by ruby\n"; "puts by tcl/tk"}]+).inspect, "\n"
+ print ip1._return_value().inspect, "\n"
+
+ # ã‚‚ã†ä¸€ã¤ã‚¤ãƒ³ã‚¿ãƒ—リタを生æˆã—ã¦ã¿ã‚‹
+ ip2 = TclTkIp.new()
+ ip2._eval("button .lab -text test -command \"puts test ; destroy .\"")
+ ip2._eval("pack .lab")
+
+ TclTkLib.mainloop
+end
+
+test
+GC.start
+
+print "exit\n"
diff --git a/jni/ruby/ext/tk/sample/tcltklib/sample1.rb b/jni/ruby/ext/tk/sample/tcltklib/sample1.rb
new file mode 100644
index 0000000..3235edf
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tcltklib/sample1.rb
@@ -0,0 +1,634 @@
+#! /usr/local/bin/ruby -d
+# -*- encoding: utf-8 -*-
+# -d オプションを付ã‘ã‚‹ã¨, デãƒãƒƒã‚°æƒ…報を表示ã™ã‚‹.
+
+# tcltk ライブラリã®ã‚µãƒ³ãƒ—ル
+
+# ã¾ãš, ライブラリを require ã™ã‚‹.
+require "tcltk"
+
+# 以下ã¯, Test1 ã®ã‚¤ãƒ³ã‚¹ã‚¿ãƒ³ã‚¹ã® initialize() ã§,
+# tcl/tk ã«é–¢ã™ã‚‹å‡¦ç†ã‚’è¡Œã†ä¾‹ã§ã‚ã‚‹.
+# å¿…ãšã—ã‚‚ãã®ã‚ˆã†ã«ã™ã‚‹å¿…è¦ã¯ç„¡ã,
+# (ã‚‚ã—, ãã†ã—ãŸã‘ã‚Œã°) class ã®å¤–㧠tcl/tk ã«é–¢ã™ã‚‹å‡¦ç†ã‚’è¡Œã£ã¦ã‚‚良ã„.
+
+class Test1
+ # åˆæœŸåŒ–(インタプリタを生æˆã—ã¦ã‚¦ã‚£ã‚¸ã‚§ãƒƒãƒˆã‚’生æˆã™ã‚‹).
+ def initialize()
+
+ #### 使ã†å‰ã®ãŠã¾ã˜ãªã„
+
+ # インタプリタã®ç”Ÿæˆ.
+ ip = TclTkInterpreter.new()
+ # コマンドã«å¯¾å¿œã™ã‚‹ã‚ªãƒ–ジェクトを c ã«è¨­å®šã—ã¦ãŠã.
+ c = ip.commands()
+ # 使用ã™ã‚‹ã‚³ãƒžãƒ³ãƒ‰ã«å¯¾å¿œã™ã‚‹ã‚ªãƒ–ジェクトã¯å¤‰æ•°ã«å…¥ã‚Œã¦ãŠã.
+ append, bind, button, destroy, incr, info, label, place, set, wm =
+ c.values_at(
+ "append", "bind", "button", "destroy", "incr", "info", "label", "place",
+ "set", "wm")
+
+ #### tcl/tk ã®ã‚³ãƒžãƒ³ãƒ‰ã«å¯¾å¿œã™ã‚‹ã‚ªãƒ–ジェクト(TclTkCommand)ã®æ“作
+
+ # 実行ã™ã‚‹æ™‚ã¯, e() メソッドを使ã†.
+ # (以下ã¯, tcl/tk ã«ãŠã‘ã‚‹ info command r* を実行.)
+ print info.e("command", "r*"), "\n"
+ # 引数ã¯, ã¾ã¨ã‚ãŸæ–‡å­—列ã«ã—ã¦ã‚‚åŒã˜.
+ print info.e("command r*"), "\n"
+ # 変数を用ã„ãªãã¨ã‚‚実行ã§ãã‚‹ãŒ, 見ãŸã‚ãŒæ‚ªã„.
+ print c["info"].e("command", "r*"), "\n"
+ # インタプリタã®ãƒ¡ã‚½ãƒƒãƒ‰ã¨ã—ã¦ã‚‚実行ã§ãã‚‹ãŒ, 効率ãŒæ‚ªã„.
+ print ip.info("command", "r*"), "\n"
+
+ ####
+
+ # 以下, 生æˆã—ãŸã‚ªãƒ–ジェクトã¯å¤‰æ•°ã«ä»£å…¥ã—ã¦ãŠã‹ãªã„ã¨
+ # GC ã®å¯¾è±¡ã«ãªã£ã¦ã—ã¾ã†.
+
+ #### tcl/tk ã®å¤‰æ•°ã«å¯¾å¿œã™ã‚‹ã‚ªãƒ–ジェクト(TclTkVariable)ã®æ“作
+
+ # 生æˆã¨åŒæ™‚ã«å€¤ã‚’設定ã™ã‚‹.
+ v1 = TclTkVariable.new(ip, "20")
+ # 読ã¿å‡ºã—㯠get メソッドを使ã†.
+ print v1.get(), "\n"
+ # 設定㯠set メソッドを使ã†.
+ v1.set(40)
+ print v1.get(), "\n"
+ # set コマンドを使ã£ã¦èª­ã¿å‡ºã—, 設定ã¯å¯èƒ½ã ãŒè¦‹ãŸã‚ãŒæ‚ªã„.
+ # e() メソッド等ã®å¼•æ•°ã«ç›´æŽ¥ TclTkObject や数値を書ã„ã¦ã‚‚良ã„.
+ set.e(v1, 30)
+ print set.e(v1), "\n"
+ # tcl/tk ã®ã‚³ãƒžãƒ³ãƒ‰ã§å¤‰æ•°ã‚’æ“作ã§ãã‚‹.
+ incr.e(v1)
+ print v1.get(), "\n"
+ append.e(v1, 10)
+ print v1.get(), "\n"
+
+ #### tcl/tk ã®ã‚¦ã‚£ã‚¸ã‚§ãƒƒãƒˆã«å¯¾å¿œã™ã‚‹ã‚ªãƒ–ジェクト(TclTkWidget)ã®æ“作
+
+ # ルートウィジェットをå–り出ã™.
+ root = ip.rootwidget()
+ # ウィジェットã®æ“作.
+ root.e("configure -height 300 -width 300")
+ # タイトルを付ã‘ã‚‹ã¨ã㯠wm を使ã†.
+ wm.e("title", root, $0)
+ # 親ウィジェットã¨ã‚³ãƒžãƒ³ãƒ‰ã‚’指定ã—ã¦, ウィジェットを作る.
+ l1 = TclTkWidget.new(ip, root, label, "-text {type `x' to print}")
+ # place ã™ã‚‹ã¨è¡¨ç¤ºã•ã‚Œã‚‹.
+ place.e(l1, "-x 0 -rely 0.0 -relwidth 1 -relheight 0.1")
+ # コマンドåã¯æ–‡å­—列ã§æŒ‡å®šã—ã¦ã‚‚良ã„ãŒ, 見ãŸã‚ãŒæ‚ªã„.
+ # (コマンドåã¯ç‹¬ç«‹ã—ãŸå¼•æ•°ã§ãªã‘ã‚Œã°ãªã‚‰ãªã„.)
+ l2 = TclTkWidget.new(ip, root, "label")
+ # ウィジェットã®æ“作.
+ l2.e("configure -text {type `q' to exit}")
+ place.e(l2, "-x 0 -rely 0.1 -relwidth 1 -relheight 0.1")
+
+ #### tcl/tk ã®ã‚³ãƒ¼ãƒ«ãƒãƒƒã‚¯ã«å¯¾å¿œã™ã‚‹ã‚ªãƒ–ジェクト(TclTkCallback)ã®æ“作
+
+ # コールãƒãƒƒã‚¯ã‚’生æˆã™ã‚‹.
+ c1 = TclTkCallback.new(ip, proc{sample(ip, root)})
+ # コールãƒãƒƒã‚¯ã‚’æŒã¤ã‚¦ã‚£ã‚¸ã‚§ãƒƒãƒˆã‚’生æˆã™ã‚‹.
+ b1 = TclTkWidget.new(ip, root, button, "-text sample -command", c1)
+ place.e(b1, "-x 0 -rely 0.2 -relwidth 1 -relheight 0.1")
+ # イベントループを抜ã‘ã‚‹ã«ã¯ destroy.e(root) ã™ã‚‹.
+ c2 = TclTkCallback.new(ip, proc{destroy.e(root)})
+ b2 = TclTkWidget.new(ip, root, button, "-text exit -command", c2)
+ place.e(b2, "-x 0 -rely 0.3 -relwidth 1 -relheight 0.1")
+
+ #### イベントã®ãƒã‚¤ãƒ³ãƒ‰
+ # script ã®è¿½åŠ  (bind tag sequence +script) ã¯ä»Šã®ã¨ã“ã‚ã§ããªã„.
+ # (イテレータ変数ã®è¨­å®šãŒã†ã¾ãã„ã‹ãªã„.)
+
+ # 基本的ã«ã¯ã‚¦ã‚£ã‚¸ã‚§ãƒƒãƒˆã«å¯¾ã™ã‚‹ã‚³ãƒ¼ãƒ«ãƒãƒƒã‚¯ã¨åŒã˜.
+ c3 = TclTkCallback.new(ip, proc{print("q pressed\n"); destroy.e(root)})
+ bind.e(root, "q", c3)
+ # bind コマンド㧠% ç½®æ›ã«ã‚ˆã‚Šãƒ‘ラメータをå—ã‘å–ã‚ŠãŸã„ã¨ãã¯,
+ # proc{} ã®å¾Œã‚ã«æ–‡å­—列ã§æŒ‡å®šã™ã‚‹ã¨,
+ # ç½®æ›çµæžœã‚’イテレータ変数を通ã—ã¦å—ã‘å–ã‚‹ã“ã¨ãŒã§ãã‚‹.
+ # ãŸã ã— proc{} ã®å¾Œã‚ã®æ–‡å­—列ã¯,
+ # bind コマンドã«ä¸Žãˆã‚‹ã‚³ãƒ¼ãƒ«ãƒãƒƒã‚¯ä»¥å¤–ã§æŒ‡å®šã—ã¦ã¯ã„ã‘ãªã„.
+ c4 = TclTkCallback.new(ip, proc{|i| print("#{i} pressed\n")}, "%A")
+ bind.e(root, "x", c4)
+ # TclTkCallback ã‚’ GC ã®å¯¾è±¡ã«ã—ãŸã‘ã‚Œã°,
+ # dcb() (ã¾ãŸã¯ deletecallbackkeys()) ã™ã‚‹å¿…è¦ãŒã‚ã‚‹.
+ cb = [c1, c2, c3, c4]
+ c5 = TclTkCallback.new(ip, proc{|w| TclTk.dcb(cb, root, w)}, "%W")
+ bind.e(root, "<Destroy>", c5)
+ cb.push(c5)
+
+ #### tcl/tk ã®ã‚¤ãƒ¡ãƒ¼ã‚¸ã«å¯¾å¿œã™ã‚‹ã‚ªãƒ–ジェクト(TclTkImage)ã®æ“作
+
+ # データを指定ã—ã¦ç”Ÿæˆã™ã‚‹.
+ i1 = TclTkImage.new(ip, "photo", "-file maru.gif")
+ # ラベルã«å¼µã‚Šä»˜ã‘ã¦ã¿ã‚‹.
+ l3 = TclTkWidget.new(ip, root, label, "-relief raised -image", i1)
+ place.e(l3, "-x 0 -rely 0.4 -relwidth 0.2 -relheight 0.2")
+ # 空ã®ã‚¤ãƒ¡ãƒ¼ã‚¸ã‚’生æˆã—ã¦å¾Œã§æ“作ã™ã‚‹.
+ i2 = TclTkImage.new(ip, "photo")
+ # イメージをæ“作ã™ã‚‹.
+ i2.e("copy", i1)
+ i2.e("configure -gamma 0.5")
+ l4 = TclTkWidget.new(ip, root, label, "-relief raised -image", i2)
+ place.e(l4, "-relx 0.2 -rely 0.4 -relwidth 0.2 -relheight 0.2")
+
+ ####
+ end
+
+ # サンプルã®ãŸã‚ã®ã‚¦ã‚£ã‚¸ã‚§ãƒƒãƒˆã‚’生æˆã™ã‚‹.
+ def sample(ip, parent)
+ bind, button, destroy, grid, toplevel, wm = ip.commands().values_at(
+ "bind", "button", "destroy", "grid", "toplevel", "wm")
+
+ ## toplevel
+
+ # æ–°ã—ã„ウインドウを開ãã«ã¯, toplevel を使ã†.
+ t1 = TclTkWidget.new(ip, parent, toplevel)
+ # タイトルを付ã‘ã¦ãŠã
+ wm.e("title", t1, "sample")
+
+ # ウィジェットãŒç ´å£Šã•ã‚ŒãŸã¨ã, コールãƒãƒƒã‚¯ãŒ GC ã®å¯¾è±¡ã«ãªã‚‹ã‚ˆã†ã«ã™ã‚‹.
+ cb = []
+ cb.push(c = TclTkCallback.new(ip, proc{|w| TclTk.dcb(cb, t1, w)}, "%W"))
+ bind.e(t1, "<Destroy>", c)
+
+ # ボタンã®ç”Ÿæˆ.
+ wid = []
+ # toplevel ウィジェットを破壊ã™ã‚‹ã«ã¯ destroy ã™ã‚‹.
+ cb.push(c = TclTkCallback.new(ip, proc{destroy.e(t1)}))
+ wid.push(TclTkWidget.new(ip, t1, button, "-text close -command", c))
+ cb.push(c = TclTkCallback.new(ip, proc{test_label(ip, t1)}))
+ wid.push(TclTkWidget.new(ip, t1, button, "-text label -command", c))
+ cb.push(c = TclTkCallback.new(ip, proc{test_button(ip, t1)}))
+ wid.push(TclTkWidget.new(ip, t1, button, "-text button -command", c))
+ cb.push(c = TclTkCallback.new(ip, proc{test_checkbutton(ip, t1)}))
+ wid.push(TclTkWidget.new(ip, t1, button, "-text checkbutton -command", c))
+ cb.push(c = TclTkCallback.new(ip, proc{test_radiobutton(ip, t1)}))
+ wid.push(TclTkWidget.new(ip, t1, button, "-text radiobutton -command", c))
+ cb.push(c = TclTkCallback.new(ip, proc{test_scale(ip, t1)}))
+ wid.push(TclTkWidget.new(ip, t1, button, "-text scale -command", c))
+ cb.push(c = TclTkCallback.new(ip, proc{test_entry(ip, t1)}))
+ wid.push(TclTkWidget.new(ip, t1, button, "-text entry -command", c))
+ cb.push(c = TclTkCallback.new(ip, proc{test_text(ip, t1)}))
+ wid.push(TclTkWidget.new(ip, t1, button, "-text text -command", c))
+ cb.push(c = TclTkCallback.new(ip, proc{test_raise(ip, t1)}))
+ wid.push(TclTkWidget.new(ip, t1, button, "-text raise/lower -command", c))
+ cb.push(c = TclTkCallback.new(ip, proc{test_modal(ip, t1)}))
+ wid.push(TclTkWidget.new(ip, t1, button, "-text message/modal -command",
+ c))
+ cb.push(c = TclTkCallback.new(ip, proc{test_menu(ip, t1)}))
+ wid.push(TclTkWidget.new(ip, t1, button, "-text menu -command", c))
+ cb.push(c = TclTkCallback.new(ip, proc{test_listbox(ip, t1)}))
+ wid.push(TclTkWidget.new(ip, t1, button, "-text listbox/scrollbar",
+ "-command", c))
+ cb.push(c = TclTkCallback.new(ip, proc{test_canvas(ip, t1)}))
+ wid.push(TclTkWidget.new(ip, t1, button, "-text canvas -command", c))
+
+ # grid ã§è¡¨ç¤ºã™ã‚‹.
+ ro = co = 0
+ wid.each{|w|
+ grid.e(w, "-row", ro, "-column", co, "-sticky news")
+ ro += 1
+ if ro == 7
+ ro = 0
+ co += 1
+ end
+ }
+ end
+
+ # inittoplevel(ip, parent, title)
+ # 以下ã®å‡¦ç†ã‚’ã¾ã¨ã‚ã¦è¡Œã†.
+ # 1. toplevel ウィジェットを作æˆã™ã‚‹.
+ # 2. コールãƒãƒƒã‚¯ã‚’登録ã™ã‚‹é…列を用æ„ã—, toplevel ウィジェットã®
+ # <Destroy> イベントã«ã‚³ãƒ¼ãƒ«ãƒãƒƒã‚¯ã‚’削除ã™ã‚‹æ‰‹ç¶šãを登録ã™ã‚‹.
+ # 3. クローズボタンを作る.
+ # 作æˆã—㟠toplevel ウィジェット, クローズボタン, コールãƒãƒƒã‚¯ç™»éŒ²ç”¨å¤‰æ•°
+ # ã‚’è¿”ã™.
+ # ip: インタプリタ
+ # parent: 親ウィジェット
+ # title: toplevel ウィジェットã®ã‚¦ã‚¤ãƒ³ãƒ‰ã‚¦ã®ã‚¿ã‚¤ãƒˆãƒ«
+ def inittoplevel(ip, parent, title)
+ bind, button, destroy, toplevel, wm = ip.commands().values_at(
+ "bind", "button", "destroy", "toplevel", "wm")
+
+ # æ–°ã—ã„ウインドウを開ãã«ã¯, toplevel を使ã†.
+ t1 = TclTkWidget.new(ip, parent, toplevel)
+ # タイトルを付ã‘ã¦ãŠã
+ wm.e("title", t1, title)
+
+ # ウィジェットãŒç ´å£Šã•ã‚ŒãŸã¨ã, コールãƒãƒƒã‚¯ãŒ GC ã®å¯¾è±¡ã«ãªã‚‹ã‚ˆã†ã«ã™ã‚‹.
+ cb = []
+ cb.push(c = TclTkCallback.new(ip, proc{|w| TclTk.dcb(cb, t1, w)}, "%W"))
+ bind.e(t1, "<Destroy>", c)
+ # close ボタンを作ã£ã¦ãŠã.
+ # toplevel ウィジェットを破壊ã™ã‚‹ã«ã¯ destroy ã™ã‚‹.
+ cb.push(c = TclTkCallback.new(ip, proc{destroy.e(t1)}))
+ b1 = TclTkWidget.new(ip, t1, button, "-text close -command", c)
+
+ return t1, b1, cb
+ end
+
+ # label ã®ã‚µãƒ³ãƒ—ル.
+ def test_label(ip, parent)
+ button, global, label, pack = ip.commands().values_at(
+ "button", "global", "label", "pack")
+ t1, b1, cb = inittoplevel(ip, parent, "label")
+
+ ## label
+
+ # ã„ã‚ã„ã‚ãªå½¢ã®ãƒ©ãƒ™ãƒ«.
+ l1 = TclTkWidget.new(ip, t1, label, "-text {default(flat)}")
+ l2 = TclTkWidget.new(ip, t1, label, "-text raised -relief raised")
+ l3 = TclTkWidget.new(ip, t1, label, "-text sunken -relief sunken")
+ l4 = TclTkWidget.new(ip, t1, label, "-text groove -relief groove")
+ l5 = TclTkWidget.new(ip, t1, label, "-text ridge -relief ridge")
+ l6 = TclTkWidget.new(ip, t1, label, "-bitmap error")
+ l7 = TclTkWidget.new(ip, t1, label, "-bitmap questhead")
+
+ # pack ã—ã¦ã‚‚表示ã•ã‚Œã‚‹.
+ pack.e(b1, l1, l2, l3, l4, l5, l6, l7, "-pady 3")
+
+ ## -textvariable
+
+ # tcltk ライブラリã®å®Ÿè£…ã§ã¯, コールãƒãƒƒã‚¯ã¯ tcl/tk ã®``手続ã''を通ã—ã¦
+ # 呼ã°ã‚Œã‚‹. ã—ãŸãŒã£ã¦, コールãƒãƒƒã‚¯ã®ä¸­ã§(大域)変数ã«ã‚¢ã‚¯ã‚»ã‚¹ã™ã‚‹ã¨ãã¯,
+ # global ã™ã‚‹å¿…è¦ãŒã‚ã‚‹.
+ # global ã™ã‚‹å‰ã«å¤‰æ•°ã«å€¤ã‚’設定ã—ã¦ã—ã¾ã†ã¨ã‚¨ãƒ©ãƒ¼ã«ãªã‚‹ã®ã§,
+ # tcl/tk ã«ãŠã‘る表ç¾å½¢ã ã‘生æˆã—ã¦, 実際ã«å€¤ã‚’設定ã—ãªã„よã†ã«,
+ # 2 番目ã®å¼•æ•°ã«ã¯ nil を与ãˆã‚‹.
+ v1 = TclTkVariable.new(ip, nil)
+ global.e(v1)
+ v1.set(100)
+ # -textvariable ã§å¤‰æ•°ã‚’設定ã™ã‚‹.
+ l6 = TclTkWidget.new(ip, t1, label, "-textvariable", v1)
+ # コールãƒãƒƒã‚¯ã®ä¸­ã‹ã‚‰å¤‰æ•°ã‚’æ“作ã™ã‚‹.
+ cb.push(c = TclTkCallback.new(ip, proc{
+ global.e(v1); v1.set(v1.get().to_i + 10)}))
+ b2 = TclTkWidget.new(ip, t1, button, "-text +10 -command", c)
+ cb.push(c = TclTkCallback.new(ip, proc{
+ global.e(v1); v1.set(v1.get().to_i - 10)}))
+ b3 = TclTkWidget.new(ip, t1, button, "-text -10 -command", c)
+ pack.e(l6, b2, b3)
+ end
+
+ # button ã®ã‚µãƒ³ãƒ—ル.
+ def test_button(ip, parent)
+ button, pack = ip.commands().values_at("button", "pack")
+ t1, b1, cb = inittoplevel(ip, parent, "button")
+
+ ## button
+
+ # コールãƒãƒƒã‚¯å†…ã§å‚ç…§ã™ã‚‹å¤‰æ•°ã¯å…ˆã«å®£è¨€ã—ã¦ãŠã‹ãªã‘ã‚Œã°ãªã‚‰ãªã„.
+ b3 = b4 = nil
+ cb.push(c = TclTkCallback.new(ip, proc{b3.e("flash"); b4.e("flash")}))
+ b2 = TclTkWidget.new(ip, t1, button, "-text flash -command", c)
+ cb.push(c = TclTkCallback.new(ip, proc{b2.e("configure -state normal")}))
+ b3 = TclTkWidget.new(ip, t1, button, "-text normal -command", c)
+ cb.push(c = TclTkCallback.new(ip, proc{b2.e("configure -state disabled")}))
+ b4 = TclTkWidget.new(ip, t1, button, "-text disable -command", c)
+ pack.e(b1, b2, b3, b4)
+ end
+
+ # checkbutton ã®ã‚µãƒ³ãƒ—ル.
+ def test_checkbutton(ip, parent)
+ checkbutton, global, pack = ip.commands().values_at(
+ "checkbutton", "global", "pack")
+ t1, b1, cb = inittoplevel(ip, parent, "checkbutton")
+
+ ## checkbutton
+
+ v1 = TclTkVariable.new(ip, nil)
+ global.e(v1)
+ # -variable ã§å¤‰æ•°ã‚’設定ã™ã‚‹.
+ ch1 = TclTkWidget.new(ip, t1, checkbutton, "-onvalue on -offvalue off",
+ "-textvariable", v1, "-variable", v1)
+ pack.e(b1, ch1)
+ end
+
+ # radiobutton ã®ã‚µãƒ³ãƒ—ル.
+ def test_radiobutton(ip, parent)
+ global, label, pack, radiobutton = ip.commands().values_at(
+ "global", "label", "pack", "radiobutton")
+ t1, b1, cb = inittoplevel(ip, parent, "radiobutton")
+
+ ## radiobutton
+
+ v1 = TclTkVariable.new(ip, nil)
+ global.e(v1)
+ # ヌルストリング㯠"{}" ã§æŒ‡å®šã™ã‚‹.
+ v1.set("{}")
+ l1 = TclTkWidget.new(ip, t1, label, "-textvariable", v1)
+ # -variable ã§åŒã˜å¤‰æ•°ã‚’指定ã™ã‚‹ã¨åŒã˜ã‚°ãƒ«ãƒ¼ãƒ—ã«ãªã‚‹.
+ ra1 = TclTkWidget.new(ip, t1, radiobutton,
+ "-text radio1 -value r1 -variable", v1)
+ ra2 = TclTkWidget.new(ip, t1, radiobutton,
+ "-text radio2 -value r2 -variable", v1)
+ cb.push(c = TclTkCallback.new(ip, proc{global.e(v1); v1.set("{}")}))
+ ra3 = TclTkWidget.new(ip, t1, radiobutton,
+ "-text clear -value r3 -variable", v1, "-command", c)
+ pack.e(b1, l1, ra1, ra2, ra3)
+ end
+
+ # scale ã®ã‚µãƒ³ãƒ—ル.
+ def test_scale(ip, parent)
+ global, pack, scale = ip.commands().values_at(
+ "global", "pack", "scale")
+ t1, b1, cb = inittoplevel(ip, parent, "scale")
+
+ ## scale
+
+ v1 = TclTkVariable.new(ip, nil)
+ global.e(v1)
+ v1.set(219)
+ # コールãƒãƒƒã‚¯å†…ã§å‚ç…§ã™ã‚‹å¤‰æ•°ã¯å…ˆã«å®£è¨€ã—ã¦ãŠã‹ãªã‘ã‚Œã°ãªã‚‰ãªã„.
+ sca1 = nil
+ cb.push(c = TclTkCallback.new(ip, proc{global.e(v1); v = v1.get();
+ sca1.e("configure -background", format("#%02x%02x%02x", v, v, v))}))
+ sca1 = TclTkWidget.new(ip, t1, scale,
+ "-label scale -orient h -from 0 -to 255 -variable", v1, "-command", c)
+ pack.e(b1, sca1)
+ end
+
+ # entry ã®ã‚µãƒ³ãƒ—ル.
+ def test_entry(ip, parent)
+ button, entry, global, pack = ip.commands().values_at(
+ "button", "entry", "global", "pack")
+ t1, b1, cb = inittoplevel(ip, parent, "entry")
+
+ ## entry
+
+ v1 = TclTkVariable.new(ip, nil)
+ global.e(v1)
+ # ヌルストリング㯠"{}" ã§æŒ‡å®šã™ã‚‹.
+ v1.set("{}")
+ en1 = TclTkWidget.new(ip, t1, entry, "-textvariable", v1)
+ cb.push(c = TclTkCallback.new(ip, proc{
+ global.e(v1); print(v1.get(), "\n"); v1.set("{}")}))
+ b2 = TclTkWidget.new(ip, t1, button, "-text print -command", c)
+ pack.e(b1, en1, b2)
+ end
+
+ # text ã®ã‚µãƒ³ãƒ—ル.
+ def test_text(ip, parent)
+ button, pack, text = ip.commands().values_at(
+ "button", "pack", "text")
+ t1, b1, cb = inittoplevel(ip, parent, "text")
+
+ ## text
+
+ te1 = TclTkWidget.new(ip, t1, text)
+ cb.push(c = TclTkCallback.new(ip, proc{
+ # 1 行目㮠0 文字目ã‹ã‚‰æœ€å¾Œã¾ã§ã‚’表示ã—, 削除ã™ã‚‹.
+ print(te1.e("get 1.0 end")); te1.e("delete 1.0 end")}))
+ b2 = TclTkWidget.new(ip, t1, button, "-text print -command", c)
+ pack.e(b1, te1, b2)
+ end
+
+ # raise/lower ã®ã‚µãƒ³ãƒ—ル.
+ def test_raise(ip, parent)
+ button, frame, lower, pack, raise = ip.commands().values_at(
+ "button", "frame", "lower", "pack", "raise")
+ t1, b1, cb = inittoplevel(ip, parent, "raise/lower")
+
+ ## raise/lower
+
+ # button ã‚’éš ã™ãƒ†ã‚¹ãƒˆã®ãŸã‚ã«, frame を使ã†.
+ f1 = TclTkWidget.new(ip, t1, frame)
+ # コールãƒãƒƒã‚¯å†…ã§å‚ç…§ã™ã‚‹å¤‰æ•°ã¯å…ˆã«å®£è¨€ã—ã¦ãŠã‹ãªã‘ã‚Œã°ãªã‚‰ãªã„.
+ b2 = nil
+ cb.push(c = TclTkCallback.new(ip, proc{raise.e(f1, b2)}))
+ b2 = TclTkWidget.new(ip, t1, button, "-text raise -command", c)
+ cb.push(c = TclTkCallback.new(ip, proc{lower.e(f1, b2)}))
+ b3 = TclTkWidget.new(ip, t1, button, "-text lower -command", c)
+ lower.e(f1, b3)
+
+ pack.e(b2, b3, "-in", f1)
+ pack.e(b1, f1)
+ end
+
+ # modal ãªã‚¦ã‚£ã‚¸ã‚§ãƒƒãƒˆã®ã‚µãƒ³ãƒ—ル.
+ def test_modal(ip, parent)
+ button, frame, message, pack, tk_chooseColor, tk_getOpenFile,
+ tk_messageBox = ip.commands().values_at(
+ "button", "frame", "message", "pack", "tk_chooseColor",
+ "tk_getOpenFile", "tk_messageBox")
+ # 最åˆã« load ã•ã‚Œã¦ã„ãªã„ライブラリ㯠ip.commands() ã«å­˜åœ¨ã—ãªã„ã®ã§,
+ # TclTkLibCommand を生æˆã™ã‚‹å¿…è¦ãŒã‚ã‚‹.
+ tk_dialog = TclTkLibCommand.new(ip, "tk_dialog")
+ t1, b1, cb = inittoplevel(ip, parent, "message/modal")
+
+ ## message
+
+ mes = "ã“れ㯠message ウィジェットã®ãƒ†ã‚¹ãƒˆã§ã™."
+ mes += "以下㯠modal ãªã‚¦ã‚£ã‚¸ã‚§ãƒƒãƒˆã®ãƒ†ã‚¹ãƒˆã§ã™."
+ me1 = TclTkWidget.new(ip, t1, message, "-text {#{mes}}")
+
+ ## modal
+
+ # tk_messageBox
+ cb.push(c = TclTkCallback.new(ip, proc{
+ print tk_messageBox.e("-type yesnocancel -message messageBox",
+ "-icon error -default cancel -title messageBox"), "\n"}))
+ b2 = TclTkWidget.new(ip, t1, button, "-text messageBox -command", c)
+ # tk_dialog
+ cb.push(c = TclTkCallback.new(ip, proc{
+ # ウィジェットåを生æˆã™ã‚‹ãŸã‚ã«ãƒ€ãƒŸãƒ¼ã® frame を生æˆ.
+ print tk_dialog.e(TclTkWidget.new(ip, t1, frame),
+ "dialog dialog error 2 yes no cancel"), "\n"}))
+ b3 = TclTkWidget.new(ip, t1, button, "-text dialog -command", c)
+ # tk_chooseColor
+ cb.push(c = TclTkCallback.new(ip, proc{
+ print tk_chooseColor.e("-title chooseColor"), "\n"}))
+ b4 = TclTkWidget.new(ip, t1, button, "-text chooseColor -command", c)
+ # tk_getOpenFile
+ cb.push(c = TclTkCallback.new(ip, proc{
+ print tk_getOpenFile.e("-defaultextension .rb",
+ "-filetypes {{{Ruby Script} {.rb}} {{All Files} {*}}}",
+ "-title getOpenFile"), "\n"}))
+ b5 = TclTkWidget.new(ip, t1, button, "-text getOpenFile -command", c)
+
+ pack.e(b1, me1, b2, b3, b4, b5)
+ end
+
+ # menu ã®ã‚µãƒ³ãƒ—ル.
+ def test_menu(ip, parent)
+ global, menu, menubutton, pack = ip.commands().values_at(
+ "global", "menu", "menubutton", "pack")
+ tk_optionMenu = TclTkLibCommand.new(ip, "tk_optionMenu")
+ t1, b1, cb = inittoplevel(ip, parent, "menu")
+
+ ## menu
+
+ # menubutton を生æˆã™ã‚‹.
+ mb1 = TclTkWidget.new(ip, t1, menubutton, "-text menu")
+ # menu を生æˆã™ã‚‹.
+ me1 = TclTkWidget.new(ip, mb1, menu)
+ # mb1 ã‹ã‚‰ me1 ãŒèµ·å‹•ã•ã‚Œã‚‹ã‚ˆã†ã«ã™ã‚‹.
+ mb1.e("configure -menu", me1)
+
+ # cascade ã§èµ·å‹•ã•ã‚Œã‚‹ menu を生æˆã™ã‚‹.
+ me11 = TclTkWidget.new(ip, me1, menu)
+ # radiobutton ã®ã‚µãƒ³ãƒ—ル.
+ v1 = TclTkVariable.new(ip, nil); global.e(v1); v1.set("r1")
+ me11.e("add radiobutton -label radio1 -value r1 -variable", v1)
+ me11.e("add radiobutton -label radio2 -value r2 -variable", v1)
+ me11.e("add radiobutton -label radio3 -value r3 -variable", v1)
+ # cascade ã«ã‚ˆã‚Š mb11 ãŒèµ·å‹•ã•ã‚Œã‚‹ã‚ˆã†ã«ã™ã‚‹.
+ me1.e("add cascade -label cascade -menu", me11)
+
+ # checkbutton ã®ã‚µãƒ³ãƒ—ル.
+ v2 = TclTkVariable.new(ip, nil); global.e(v2); v2.set("none")
+ me1.e("add checkbutton -label check -variable", v2)
+ # separator ã®ã‚µãƒ³ãƒ—ル.
+ me1.e("add separator")
+ # command ã®ã‚µãƒ³ãƒ—ル.
+ v3 = nil
+ cb.push(c = TclTkCallback.new(ip, proc{
+ global.e(v1, v2, v3); print "v1: ", v1.get(), ", v2: ", v2.get(),
+ ", v3: ", v3.get(), "\n"}))
+ me1.e("add command -label print -command", c)
+
+ ## tk_optionMenu
+
+ v3 = TclTkVariable.new(ip, nil); global.e(v3); v3.set("opt2")
+ om1 = TclTkWidget.new(ip, t1, tk_optionMenu, v3, "opt1 opt2 opt3 opt4")
+
+ pack.e(b1, mb1, om1, "-side left")
+ end
+
+ # listbox ã®ã‚µãƒ³ãƒ—ル.
+ def test_listbox(ip, parent)
+ clipboard, frame, grid, listbox, lower, menu, menubutton, pack, scrollbar,
+ selection = ip.commands().values_at(
+ "clipboard", "frame", "grid", "listbox", "lower", "menu", "menubutton",
+ "pack", "scrollbar", "selection")
+ t1, b1, cb = inittoplevel(ip, parent, "listbox")
+
+ ## listbox/scrollbar
+
+ f1 = TclTkWidget.new(ip, t1, frame)
+ # コールãƒãƒƒã‚¯å†…ã§å‚ç…§ã™ã‚‹å¤‰æ•°ã¯å…ˆã«å®£è¨€ã—ã¦ãŠã‹ãªã‘ã‚Œã°ãªã‚‰ãªã„.
+ li1 = sc1 = sc2 = nil
+ # 実行時ã«, 後ã‚ã«ãƒ‘ラメータãŒã¤ãコールãƒãƒƒã‚¯ã¯,
+ # イテレータ変数ã§ãã®ãƒ‘ラメータをå—ã‘å–ã‚‹ã“ã¨ãŒã§ãã‚‹.
+ # (複数ã®ãƒ‘ラメータã¯ã²ã¨ã¤ã®æ–‡å­—列ã«ã¾ã¨ã‚られる.)
+ cb.push(c1 = TclTkCallback.new(ip, proc{|i| li1.e("xview", i)}))
+ cb.push(c2 = TclTkCallback.new(ip, proc{|i| li1.e("yview", i)}))
+ cb.push(c3 = TclTkCallback.new(ip, proc{|i| sc1.e("set", i)}))
+ cb.push(c4 = TclTkCallback.new(ip, proc{|i| sc2.e("set", i)}))
+ # listbox
+ li1 = TclTkWidget.new(ip, f1, listbox,
+ "-xscrollcommand", c3, "-yscrollcommand", c4,
+ "-selectmode extended -exportselection true")
+ for i in 1..20
+ li1.e("insert end {line #{i} line #{i} line #{i} line #{i} line #{i}}")
+ end
+ # scrollbar
+ sc1 = TclTkWidget.new(ip, f1, scrollbar, "-orient horizontal -command", c1)
+ sc2 = TclTkWidget.new(ip, f1, scrollbar, "-orient vertical -command", c2)
+
+ ## selection/clipboard
+
+ mb1 = TclTkWidget.new(ip, t1, menubutton, "-text edit")
+ me1 = TclTkWidget.new(ip, mb1, menu)
+ mb1.e("configure -menu", me1)
+ cb.push(c = TclTkCallback.new(ip, proc{
+ # clipboard をクリア.
+ clipboard.e("clear")
+ # selection ã‹ã‚‰æ–‡å­—列を読ã¿è¾¼ã¿ clipboard ã«è¿½åŠ ã™ã‚‹.
+ clipboard.e("append {#{selection.e('get')}}")}))
+ me1.e("add command -label {selection -> clipboard} -command",c)
+ cb.push(c = TclTkCallback.new(ip, proc{
+ # li1 をクリア.
+ li1.e("delete 0 end")
+ # clipboard ã‹ã‚‰æ–‡å­—列をå–り出ã—, 1 è¡Œãšã¤
+ selection.e("get -selection CLIPBOARD").split(/\n/).each{|line|
+ # li1 ã«æŒ¿å…¥ã™ã‚‹.
+ li1.e("insert end {#{line}}")}}))
+ me1.e("add command -label {clipboard -> listbox} -command",c)
+
+ grid.e(li1, "-row 0 -column 0 -sticky news")
+ grid.e(sc1, "-row 1 -column 0 -sticky ew")
+ grid.e(sc2, "-row 0 -column 1 -sticky ns")
+ grid.e("rowconfigure", f1, "0 -weight 100")
+ grid.e("columnconfigure", f1, "0 -weight 100")
+ f2 = TclTkWidget.new(ip, t1, frame)
+ lower.e(f2, b1)
+ pack.e(b1, mb1, "-in", f2, "-side left")
+ pack.e(f2, f1)
+ end
+
+ # canvas ã®ã‚µãƒ³ãƒ—ル.
+ def test_canvas(ip, parent)
+ canvas, lower, pack = ip.commands().values_at("canvas", "lower", "pack")
+ t1, b1, cb = inittoplevel(ip, parent, "canvas")
+
+ ## canvas
+
+ ca1 = TclTkWidget.new(ip, t1, canvas, "-width 400 -height 300")
+ lower.e(ca1, b1)
+ # rectangle を作る.
+ idr = ca1.e("create rectangle 10 10 20 20")
+ # oval を作る.
+ ca1.e("create oval 60 10 100 50")
+ # polygon を作る.
+ ca1.e("create polygon 110 10 110 30 140 10")
+ # line を作る.
+ ca1.e("create line 150 10 150 30 190 10")
+ # arc を作る.
+ ca1.e("create arc 200 10 250 50 -start 0 -extent 90 -style pieslice")
+ # i1 ã¯æœ¬å½“ã¯, ã©ã“ã‹ã§ç ´å£Šã—ãªã‘ã‚Œã°ãªã‚‰ãªã„ãŒ, é¢å€’ãªã®ã§æ”¾ã£ã¦ã‚ã‚‹.
+ i1 = TclTkImage.new(ip, "photo", "-file maru.gif")
+ # image を作る.
+ ca1.e("create image 100 100 -image", i1)
+ # bitmap を作る.
+ ca1.e("create bitmap 260 50 -bitmap questhead")
+ # text を作る.
+ ca1.e("create text 320 50 -text {drag rectangle}")
+ # window を作る(クローズボタン).
+ ca1.e("create window 200 200 -window", b1)
+
+ # bind ã«ã‚ˆã‚Š rectangle ã‚’ drag ã§ãるよã†ã«ã™ã‚‹.
+ cb.push(c = TclTkCallback.new(ip, proc{|i|
+ # i ã« x 㨠y ã‚’å—ã‘å–ã‚‹ã®ã§, å–り出ã™.
+ x, y = i.split(/ /); x = x.to_f; y = y.to_f
+ # 座標を変更ã™ã‚‹.
+ ca1.e("coords current #{x - 5} #{y - 5} #{x + 5} #{y + 5}")},
+ # x, y 座標を空白ã§åŒºåˆ‡ã£ãŸã‚‚ã®ã‚’イテレータ変数ã¸æ¸¡ã™ã‚ˆã†ã«æŒ‡å®š.
+ "%x %y"))
+ # rectangle ã« bind ã™ã‚‹.
+ ca1.e("bind", idr, "<B1-Motion>", c)
+
+ pack.e(ca1)
+ end
+end
+
+# test driver
+
+if ARGV.size == 0
+ print "#{$0} n ã§, n 個ã®ã‚¤ãƒ³ã‚¿ãƒ—リタを起動ã—ã¾ã™.\n"
+ n = 1
+else
+ n = ARGV[0].to_i
+end
+
+print "start\n"
+ip = []
+
+# インタプリタ, ウィジェット等ã®ç”Ÿæˆ.
+for i in 1 .. n
+ ip.push(Test1.new())
+end
+
+# 用æ„ãŒã§ããŸã‚‰ã‚¤ãƒ™ãƒ³ãƒˆãƒ«ãƒ¼ãƒ—ã«å…¥ã‚‹.
+TclTk.mainloop()
+print "exit from mainloop\n"
+
+# インタプリタ㌠GC ã•ã‚Œã‚‹ã‹ã®ãƒ†ã‚¹ãƒˆ.
+ip = []
+print "GC.start\n" if $DEBUG
+GC.start() if $DEBUG
+print "end\n"
+
+exit
+
+# end
diff --git a/jni/ruby/ext/tk/sample/tcltklib/sample2.rb b/jni/ruby/ext/tk/sample/tcltklib/sample2.rb
new file mode 100644
index 0000000..1acc180
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tcltklib/sample2.rb
@@ -0,0 +1,451 @@
+#!/usr/local/bin/ruby
+#----------------------> pretty simple othello game <-----------------------
+# othello.rb
+#
+# version 0.3
+# maeda shugo (shuto@po.aianet.ne.jp)
+#---------------------------------------------------------------------------
+
+# Sep. 17, 1997 modified by Y. Shigehiro for tcltk library
+# maeda shugo (shugo@po.aianet.ne.jp) æ°ã«ã‚ˆã‚‹
+# (ruby/tk ã§æ›¸ã‹ã‚Œã¦ã„ãŸ) ruby ã®ã‚µãƒ³ãƒ—ルプログラム
+# http://www.aianet.or.jp/~shugo/ruby/othello.rb.gz
+# ã‚’ tcltk ライブラリを使ã†ã‚ˆã†ã«, 機械的ã«å¤‰æ›´ã—ã¦ã¿ã¾ã—ãŸ.
+#
+# ãªã‚‹ã¹ãオリジナルã¨åŒã˜ã«ãªã‚‹ã‚ˆã†ã«ã—ã¦ã‚ã‚Šã¾ã™.
+
+require "observer"
+require "tcltk"
+$ip = TclTkInterpreter.new()
+$root = $ip.rootwidget()
+$button, $canvas, $checkbutton, $frame, $label, $pack, $update, $wm =
+ $ip.commands().values_at(
+ "button", "canvas", "checkbutton", "frame", "label", "pack", "update", "wm")
+
+class Othello
+
+ EMPTY = 0
+ BLACK = 1
+ WHITE = - BLACK
+
+ attr :in_com_turn
+ attr :game_over
+
+ class Board
+
+ include Observable
+
+ DIRECTIONS = [
+ [-1, -1], [-1, 0], [-1, 1],
+ [ 0, -1], [ 0, 1],
+ [ 1, -1], [ 1, 0], [ 1, 1]
+ ]
+
+ attr_accessor :com_disk
+
+ def initialize(othello)
+ @othello = othello
+ reset
+ end
+
+ def notify_observers(*arg)
+ if @observer_peers != nil
+ super(*arg)
+ end
+ end
+
+ def reset
+ @data = [
+ [EMPTY, EMPTY, EMPTY, EMPTY, EMPTY, EMPTY, EMPTY, EMPTY],
+ [EMPTY, EMPTY, EMPTY, EMPTY, EMPTY, EMPTY, EMPTY, EMPTY],
+ [EMPTY, EMPTY, EMPTY, EMPTY, EMPTY, EMPTY, EMPTY, EMPTY],
+ [EMPTY, EMPTY, EMPTY, WHITE, BLACK, EMPTY, EMPTY, EMPTY],
+ [EMPTY, EMPTY, EMPTY, BLACK, WHITE, EMPTY, EMPTY, EMPTY],
+ [EMPTY, EMPTY, EMPTY, EMPTY, EMPTY, EMPTY, EMPTY, EMPTY],
+ [EMPTY, EMPTY, EMPTY, EMPTY, EMPTY, EMPTY, EMPTY, EMPTY],
+ [EMPTY, EMPTY, EMPTY, EMPTY, EMPTY, EMPTY, EMPTY, EMPTY]
+ ]
+ changed
+ notify_observers
+ end
+
+ def man_disk
+ return - @com_disk
+ end
+
+ def other_disk(disk)
+ return - disk
+ end
+
+ def get_disk(row, col)
+ return @data[row][col]
+ end
+
+ def reverse_to(row, col, my_disk, dir_y, dir_x)
+ y = row
+ x = col
+ begin
+ y += dir_y
+ x += dir_x
+ if y < 0 || x < 0 || y > 7 || x > 7 ||
+ @data[y][x] == EMPTY
+ return
+ end
+ end until @data[y][x] == my_disk
+ begin
+ @data[y][x] = my_disk
+ changed
+ notify_observers(y, x)
+ y -= dir_y
+ x -= dir_x
+ end until y == row && x == col
+ end
+
+ def put_disk(row, col, disk)
+ @data[row][col] = disk
+ changed
+ notify_observers(row, col)
+ DIRECTIONS.each do |dir|
+ reverse_to(row, col, disk, *dir)
+ end
+ end
+
+ def count_disk(disk)
+ num = 0
+ @data.each do |rows|
+ rows.each do |d|
+ if d == disk
+ num += 1
+ end
+ end
+ end
+ return num
+ end
+
+ def count_point_to(row, col, my_disk, dir_y, dir_x)
+ return 0 if @data[row][col] != EMPTY
+ count = 0
+ loop do
+ row += dir_y
+ col += dir_x
+ break if row < 0 || col < 0 || row > 7 || col > 7
+ case @data[row][col]
+ when my_disk
+ return count
+ when other_disk(my_disk)
+ count += 1
+ when EMPTY
+ break
+ end
+ end
+ return 0
+ end
+
+ def count_point(row, col, my_disk)
+ count = 0
+ DIRECTIONS.each do |dir|
+ count += count_point_to(row, col, my_disk, *dir)
+ end
+ return count
+ end
+
+ def corner?(row, col)
+ return (row == 0 && col == 0) ||
+ (row == 0 && col == 7) ||
+ (row == 7 && col == 0) ||
+ (row == 7 && col == 7)
+ end
+
+ def search(my_disk)
+ max = 0
+ max_row = nil
+ max_col = nil
+ for row in 0 .. 7
+ for col in 0 .. 7
+ buf = count_point(row, col, my_disk)
+ if (corner?(row, col) && buf > 0) || max < buf
+ max = buf
+ max_row = row
+ max_col = col
+ end
+ end
+ end
+ return max_row, max_col
+ end
+ end #--------------------------> class Board ends here
+
+ class BoardView < TclTkWidget
+
+ BACK_GROUND_COLOR = "DarkGreen"
+ HILIT_BG_COLOR = "green"
+ BORDER_COLOR = "black"
+ BLACK_COLOR = "black"
+ WHITE_COLOR = "white"
+ STOP_COLOR = "red"
+
+ attr :left
+ attr :top
+ attr :right
+ attr :bottom
+
+ class Square
+
+ attr :oval, TRUE
+ attr :row
+ attr :col
+
+ def initialize(view, row, col)
+ @view = view
+ @id = @view.e("create rectangle",
+ *(view.tk_rect(view.left + col,
+ view.top + row,
+ view.left + col + 1,
+ view.top + row + 1) \
+ << "-fill #{BACK_GROUND_COLOR}") )
+ @row = row
+ @col = col
+ @view.e("itemconfigure", @id,
+ "-width 0.5m -outline #{BORDER_COLOR}")
+ @view.e("bind", @id, "<Any-Enter>", TclTkCallback.new($ip, proc{
+ if @oval == nil
+ view.e("itemconfigure", @id, "-fill #{HILIT_BG_COLOR}")
+ end
+ }))
+ @view.e("bind", @id, "<Any-Leave>", TclTkCallback.new($ip, proc{
+ view.e("itemconfigure", @id, "-fill #{BACK_GROUND_COLOR}")
+ }))
+ @view.e("bind", @id, "<ButtonRelease-1>", TclTkCallback.new($ip,
+ proc{
+ view.click_square(self)
+ }))
+ end
+
+ def blink(color)
+ @view.e("itemconfigure", @id, "-fill #{color}")
+ $update.e()
+ sleep(0.1)
+ @view.e("itemconfigure", @id, "-fill #{BACK_GROUND_COLOR}")
+ end
+ end #-----------------------> class Square ends here
+
+ def initialize(othello, board)
+ super($ip, $root, $canvas)
+ @othello = othello
+ @board = board
+ @board.add_observer(self)
+
+ @squares = Array.new(8)
+ for i in 0 .. 7
+ @squares[i] = Array.new(8)
+ end
+ @left = 1
+ @top = 0.5
+ @right = @left + 8
+ @bottom = @top + 8
+
+ i = self.e("create rectangle", *tk_rect(@left, @top, @right, @bottom))
+ self.e("itemconfigure", i,
+ "-width 1m -outline #{BORDER_COLOR} -fill #{BACK_GROUND_COLOR}")
+
+ for row in 0 .. 7
+ for col in 0 .. 7
+ @squares[row][col] = Square.new(self, row, col)
+ end
+ end
+
+ update
+ end
+
+ def tk_rect(left, top, right, bottom)
+ return left.to_s + "c", top.to_s + "c",
+ right.to_s + "c", bottom.to_s + "c"
+ end
+
+ def clear
+ each_square do |square|
+ if square.oval != nil
+ self.e("delete", square.oval)
+ square.oval = nil
+ end
+ end
+ end
+
+ def draw_disk(row, col, disk)
+ if disk == EMPTY
+ if @squares[row][col].oval != nil
+ self.e("delete", @squares[row][col].oval)
+ @squares[row][col].oval = nil
+ end
+ return
+ end
+
+ $update.e()
+ sleep(0.05)
+ oval = @squares[row][col].oval
+ if oval == nil
+ oval = self.e("create oval", *tk_rect(@left + col + 0.2,
+ @top + row + 0.2,
+ @left + col + 0.8,
+ @top + row + 0.8))
+ @squares[row][col].oval = oval
+ end
+ case disk
+ when BLACK
+ color = BLACK_COLOR
+ when WHITE
+ color = WHITE_COLOR
+ else
+ fail format("Unknown disk type: %d", disk)
+ end
+ self.e("itemconfigure", oval, "-outline #{color} -fill #{color}")
+ end
+
+ def update(row = nil, col = nil)
+ if row && col
+ draw_disk(row, col, @board.get_disk(row, col))
+ else
+ each_square do |square|
+ draw_disk(square.row, square.col,
+ @board.get_disk(square.row, square.col))
+ end
+ end
+ @othello.show_point
+ end
+
+ def each_square
+ @squares.each do |rows|
+ rows.each do |square|
+ yield(square)
+ end
+ end
+ end
+
+ def click_square(square)
+ if @othello.in_com_turn || @othello.game_over ||
+ @board.count_point(square.row,
+ square.col,
+ @board.man_disk) == 0
+ square.blink(STOP_COLOR)
+ return
+ end
+ @board.put_disk(square.row, square.col, @board.man_disk)
+ @othello.com_turn
+ end
+
+ private :draw_disk
+ public :update
+ end #----------------------> class BoardView ends here
+
+ def initialize
+ @msg_label = TclTkWidget.new($ip, $root, $label)
+ $pack.e(@msg_label)
+
+ @board = Board.new(self)
+ @board_view = BoardView.new(self, @board)
+ #### added by Y. Shigehiro
+ ## board_view ã®å¤§ãã•ã‚’設定ã™ã‚‹.
+ x1, y1, x2, y2 = @board_view.e("bbox all").split(/ /).collect{|i| i.to_f}
+ @board_view.e("configure -width", x2 - x1)
+ @board_view.e("configure -height", y2 - y1)
+ ## scrollregion を設定ã™ã‚‹.
+ @board_view.e("configure -scrollregion {", @board_view.e("bbox all"),
+ "}")
+ #### ã“ã“ã¾ã§
+ $pack.e(@board_view, "-fill both -expand true")
+
+ panel = TclTkWidget.new($ip, $root, $frame)
+
+ @play_black = TclTkWidget.new($ip, panel, $checkbutton,
+ "-text {com is black} -command", TclTkCallback.new($ip, proc{
+ switch_side
+ }))
+ $pack.e(@play_black, "-side left")
+
+ quit = TclTkWidget.new($ip, panel, $button, "-text Quit -command",
+ TclTkCallback.new($ip, proc{
+ exit
+ }))
+ $pack.e(quit, "-side right -fill x")
+
+ reset = TclTkWidget.new($ip, panel, $button, "-text Reset -command",
+ TclTkCallback.new($ip, proc{
+ reset_game
+ }))
+ $pack.e(reset, "-side right -fill x")
+
+ $pack.e(panel, "-side bottom -fill x")
+
+# root = Tk.root
+ $wm.e("title", $root, "Othello")
+ $wm.e("iconname", $root, "Othello")
+
+ @board.com_disk = WHITE
+ @game_over = FALSE
+
+ TclTk.mainloop
+ end
+
+ def switch_side
+ if @in_com_turn
+ @play_black.e("toggle")
+ else
+ @board.com_disk = @board.man_disk
+ com_turn unless @game_over
+ end
+ end
+
+ def reset_game
+ if @board.com_disk == BLACK
+ @board.com_disk = WHITE
+ @play_black.e("toggle")
+ end
+ @board_view.clear
+ @board.reset
+ $wm.e("title", $root, "Othello")
+ @game_over = FALSE
+ end
+
+ def com_turn
+ @in_com_turn = TRUE
+ $update.e()
+ sleep(0.5)
+ begin
+ com_disk = @board.count_disk(@board.com_disk)
+ man_disk = @board.count_disk(@board.man_disk)
+ if @board.count_disk(EMPTY) == 0
+ if man_disk == com_disk
+ $wm.e("title", $root, "{Othello - Draw!}")
+ elsif man_disk > com_disk
+ $wm.e("title", $root, "{Othello - You Win!}")
+ else
+ $wm.e("title", $root, "{Othello - You Loose!}")
+ end
+ @game_over = TRUE
+ break
+ elsif com_disk == 0
+ $wm.e("title", $root, "{Othello - You Win!}")
+ @game_over = TRUE
+ break
+ elsif man_disk == 0
+ $wm.e("title", $root, "{Othello - You Loose!}")
+ @game_over = TRUE
+ break
+ end
+ row, col = @board.search(@board.com_disk)
+ break if row == nil || col == nil
+ @board.put_disk(row, col, @board.com_disk)
+ end while @board.search(@board.man_disk) == [nil, nil]
+ @in_com_turn = FALSE
+ end
+
+ def show_point
+ black = @board.count_disk(BLACK)
+ white = @board.count_disk(WHITE)
+ @msg_label.e("configure -text",
+ %Q/{#{format("BLACK: %.2d WHITE: %.2d", black, white)}}/)
+ end
+end #----------------------> class Othello ends here
+
+Othello.new
+
+#----------------------------------------------> othello.rb ends here
diff --git a/jni/ruby/ext/tk/sample/tkalignbox.rb b/jni/ruby/ext/tk/sample/tkalignbox.rb
new file mode 100644
index 0000000..f3d083c
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkalignbox.rb
@@ -0,0 +1,235 @@
+#
+# tkalignbox.rb : align widgets with same width/height
+#
+# by Hidetoshi NAGAI
+#
+# The box size depends on 'reqheight' and 'reqwidth' of contained widgets.
+# If you want to give the box size when those requested sizes are 0,
+# please set box.propagate = false (See the test routine at the tail of
+# this file).
+
+require 'tk'
+
+module Tk
+ module RbWidget
+ class AlignBox < TkFrame
+ end
+ end
+end
+
+class Tk::RbWidget::AlignBox < TkFrame
+ def initialize(*args)
+ if self.class == Tk::RbWidget::AlignBox
+ fail RuntimeError, "Tk::AlignBox is an abstract class"
+ end
+ @padx = 0
+ @pady = 0
+ if args[-1].kind_of? Hash
+ keys = _symbolkey2str(args.pop)
+ @padx = keys.delete('padx') || 0
+ @pady = keys.delete('pady') || 0
+ args.push(keys)
+ end
+ super(*args)
+ @max_width = 0
+ @max_height = 0
+ @propagate = true
+ @widgets = []
+ end
+
+ def _set_framesize
+ fail RuntimeError, "Tk::AlignBox is an abstract class"
+ end
+ private :_set_framesize
+
+ def _place_config(widget, idx, cnt)
+ fail RuntimeError, "Tk::AlignBox is an abstract class"
+ end
+ private :_place_config
+
+ def align
+ widgets = []
+ @widgets.each{|w| widgets << w if w.winfo_exist?}
+ @widgets = widgets
+ cnt = @widgets.size.to_f
+ @widgets.each_with_index{|w, idx| _place_config(w, idx, cnt)}
+ @widgets = widgets
+ _set_framesize if @propagate
+ self
+ end
+
+ def add(*widgets)
+ widgets.each{|w|
+ unless w.kind_of? TkWindow
+ fail RuntimeError, "#{w.inspect} is not a widget instance."
+ end
+ @widgets.delete(w)
+ @widgets << w
+ sz = w.winfo_reqwidth
+ @max_width = sz if @max_width < sz
+ sz = w.winfo_reqheight
+ @max_height = sz if @max_height < sz
+ }
+ align
+ end
+
+ def <<(widget)
+ add(widget)
+ end
+
+ def insert(idx, widget)
+ unless widget.kind_of? TkWindow
+ fail RuntimeError, "#{widget.inspect} is not a widget instance."
+ end
+ @widgets.delete(widget)
+ @widgets[idx,0] = widget
+ sz = widget.winfo_reqwidth
+ @max_width = sz if @max_width < sz
+ sz = widget.winfo_reqheight
+ @max_height = sz if @max_height < sz
+ align
+ end
+
+ def delete(idx)
+ ret = @widgets.delete_at(idx)
+ @req_size = 0
+ @widget.each{|w|
+ sz = w.winfo_reqwidth
+ @max_width = sz if @max_width < sz
+ sz = w.winfo_reqheight
+ @max_height = sz if @max_height < sz
+ }
+ align
+ ret
+ end
+
+ def padx(size = nil)
+ if size
+ @padx = size
+ align
+ else
+ @padx
+ end
+ end
+
+ def pady(size = nil)
+ if size
+ @pady = size
+ align
+ else
+ @pady
+ end
+ end
+
+ attr_accessor :propagate
+end
+
+class Tk::RbWidget::HBox < Tk::RbWidget::AlignBox
+ def _set_framesize
+ bd = self.borderwidth
+ self.width((@max_width + 2*@padx) * @widgets.size + 2*bd)
+ self.height(@max_height + 2*@pady + 2*bd)
+ end
+ private :_set_framesize
+
+ def _place_config(widget, idx, cnt)
+ widget.place_in(self,
+ 'relx'=>idx/cnt, 'x'=>@padx,
+ 'rely'=>0, 'y'=>@pady,
+ 'relwidth'=>1.0/cnt, 'width'=>-2*@padx,
+ 'relheight'=>1.0, 'height'=>-2*@pady)
+ end
+ private :_place_config
+end
+Tk::RbWidget::HLBox = Tk::RbWidget::HBox
+
+class Tk::RbWidget::HRBox < Tk::RbWidget::HBox
+ def _place_config(widget, idx, cnt)
+ widget.place_in(self,
+ 'relx'=>(cnt - idx - 1)/cnt, 'x'=>@padx,
+ 'rely'=>0, 'y'=>@pady,
+ 'relwidth'=>1.0/cnt, 'width'=>-2*@padx,
+ 'relheight'=>1.0, 'height'=>-2*@pady)
+ end
+ private :_place_config
+end
+
+class Tk::RbWidget::VBox < Tk::RbWidget::AlignBox
+ def _set_framesize
+ bd = self.borderwidth
+ self.width(@max_width + 2*@padx + 2*bd)
+ self.height((@max_height + 2*@pady) * @widgets.size + 2*bd)
+ end
+ private :_set_framesize
+
+ def _place_config(widget, idx, cnt)
+ widget.place_in(self,
+ 'relx'=>0, 'x'=>@padx,
+ 'rely'=>idx/cnt, 'y'=>@pady,
+ 'relwidth'=>1.0, 'width'=>-2*@padx,
+ 'relheight'=>1.0/cnt, 'height'=>-2*@pady)
+ end
+ private :_place_config
+end
+Tk::RbWidget::VTBox = Tk::RbWidget::VBox
+
+class Tk::RbWidget::VBBox < Tk::RbWidget::VBox
+ def _place_config(widget, idx, cnt)
+ widget.place_in(self,
+ 'relx'=>0, 'x'=>@padx,
+ 'rely'=>(cnt - idx - 1)/cnt, 'y'=>@pady,
+ 'relwidth'=>1.0, 'width'=>-2*@padx,
+ 'relheight'=>1.0/cnt, 'height'=>-2*@pady)
+ end
+ private :_place_config
+end
+
+################################################
+# test
+################################################
+if __FILE__ == $0
+ f = Tk::RbWidget::HBox.new(:borderwidth=>3, :relief=>'ridge').pack
+ f.add(TkButton.new(f, :text=>'a'),
+ TkButton.new(f, :text=>'aa', :font=>'Helvetica 16'),
+ TkButton.new(f, :text=>'aaa'),
+ TkButton.new(f, :text=>'aaaa'))
+
+ f = Tk::RbWidget::HBox.new(:borderwidth=>3, :relief=>'ridge',
+ :padx=>7, :pady=>3, :background=>'yellow').pack
+ f.add(TkButton.new(f, :text=>'a'),
+ TkButton.new(f, :text=>'aa', :font=>'Helvetica 16'),
+ TkButton.new(f, :text=>'aaa'),
+ TkButton.new(f, :text=>'aaaa'))
+
+ f = Tk::RbWidget::VBox.new(:borderwidth=>5,
+ :relief=>'groove').pack(:fill=>:y, :expand=>true)
+ f.add(TkButton.new(f, :text=>'a'),
+ TkButton.new(f, :text=>'aa', :font=>'Helvetica 30'),
+ TkButton.new(f, :text=>'aaa'),
+ TkButton.new(f, :text=>'aaaa'))
+
+ f = Tk::RbWidget::HRBox.new(:borderwidth=>3,
+ :relief=>'raised').pack(:fill=>:x)
+ f.add(TkButton.new(f, :text=>'a'),
+ TkButton.new(f, :text=>'aa'),
+ TkButton.new(f, :text=>'aaa'))
+
+ f = Tk::RbWidget::VBBox.new(:borderwidth=>3,
+ :relief=>'ridge').pack(:fill=>:x)
+ f.propagate = false
+ f.height 100
+ f.add(TkFrame.new(f){|ff|
+ TkButton.new(ff, :text=>'a').pack(:pady=>4, :padx=>6,
+ :fill=>:both, :expand=>true)
+ },
+ TkFrame.new(f){|ff|
+ TkButton.new(ff, :text=>'aa').pack(:pady=>4, :padx=>6,
+ :fill=>:both, :expand=>true)
+ },
+ TkFrame.new(f){|ff|
+ TkButton.new(ff, :text=>'aaaa').pack(:pady=>4, :padx=>6,
+ :fill=>:both, :expand=>true)
+ })
+
+ Tk.mainloop
+end
diff --git a/jni/ruby/ext/tk/sample/tkballoonhelp.rb b/jni/ruby/ext/tk/sample/tkballoonhelp.rb
new file mode 100644
index 0000000..2daa522
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkballoonhelp.rb
@@ -0,0 +1,220 @@
+#
+# tkballoonhelp.rb : simple balloon help widget
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+# Add a balloon help to a widget.
+# This widget has only poor featureas. If you need more useful features,
+# please try to use the Tix extension of Tcl/Tk under Ruby/Tk.
+#
+# The interval time to display a balloon help is defined 'interval' option
+# (default is 750ms).
+#
+require 'tk'
+
+module Tk
+ module RbWidget
+ class BalloonHelp<TkLabel
+ end
+ end
+end
+class Tk::RbWidget::BalloonHelp<TkLabel
+ DEFAULT_FOREGROUND = 'black'
+ DEFAULT_BACKGROUND = 'white'
+ DEFAULT_INTERVAL = 750
+
+ def _balloon_binding(interval)
+ @timer = TkAfter.new(interval, 1, proc{show})
+ def @timer.interval(val)
+ @sleep_time = val
+ end
+ @bindtag = TkBindTag.new
+ @bindtag.bind('Enter', proc{@timer.start})
+ @bindtag.bind('Motion', proc{@timer.restart; erase})
+ @bindtag.bind('Any-ButtonPress', proc{@timer.restart; erase})
+ @bindtag.bind('Leave', proc{@timer.stop; erase})
+ tags = @parent.bindtags
+ idx = tags.index(@parent)
+ unless idx
+ ppath = TkComm.window(@parent.path)
+ idx = tags.index(ppath) || 0
+ end
+ tags[idx,0] = @bindtag
+ @parent.bindtags(tags)
+ end
+ private :_balloon_binding
+
+ def initialize(parent=nil, keys={})
+ @parent = parent || Tk.root
+
+ @frame = TkToplevel.new(@parent)
+ @frame.withdraw
+ @frame.overrideredirect(true)
+ @frame.transient(TkWinfo.toplevel(@parent))
+ @epath = @frame.path
+
+ if keys
+ keys = _symbolkey2str(keys)
+ else
+ keys = {}
+ end
+
+ @command = keys.delete('command')
+
+ @interval = keys.delete('interval'){DEFAULT_INTERVAL}
+ _balloon_binding(@interval)
+
+ # @label = TkLabel.new(@frame, 'background'=>'bisque').pack
+ @label = TkLabel.new(@frame,
+ 'foreground'=>DEFAULT_FOREGROUND,
+ 'background'=>DEFAULT_BACKGROUND).pack
+ @label.configure(_symbolkey2str(keys)) unless keys.empty?
+ @path = @label
+ end
+
+ def epath
+ @epath
+ end
+
+ def interval(val)
+ if val
+ @timer.interval(val)
+ else
+ @interval
+ end
+ end
+
+ def command(cmd = Proc.new)
+ @command = cmd
+ self
+ end
+
+ def show
+ x = TkWinfo.pointerx(@parent)
+ y = TkWinfo.pointery(@parent)
+ @frame.geometry("+#{x+1}+#{y+1}")
+
+ if @command
+ case @command.arity
+ when 0
+ @command.call
+ when 2
+ @command.call(x - TkWinfo.rootx(@parent), y - TkWinfo.rooty(@parent))
+ when 3
+ @command.call(x - TkWinfo.rootx(@parent), y - TkWinfo.rooty(@parent),
+ self)
+ else
+ @command.call(x - TkWinfo.rootx(@parent), y - TkWinfo.rooty(@parent),
+ self, @parent)
+ end
+ end
+
+ @frame.deiconify
+ @frame.raise
+
+ begin
+ @org_cursor = @parent.cget('cursor')
+ rescue
+ @org_cursor = @parent['cursor']
+ end
+ begin
+ @parent.configure('cursor', 'crosshair')
+ rescue
+ @parent.cursor('crosshair')
+ end
+ end
+
+ def erase
+ begin
+ @parent.configure('cursor', @org_cursor)
+ rescue
+ @parent.cursor(@org_cursor)
+ end
+ @frame.withdraw
+ end
+
+ def destroy
+ @frame.destroy
+ end
+end
+
+################################################
+# test
+################################################
+if __FILE__ == $0
+ TkButton.new('text'=>'This button has a balloon help') {|b|
+ pack('fill'=>'x')
+ Tk::RbWidget::BalloonHelp.new(b, 'text'=>' Message ')
+ }
+ TkButton.new('text'=>'This button has another balloon help') {|b|
+ pack('fill'=>'x')
+ Tk::RbWidget::BalloonHelp.new(b,
+ 'text'=>"CONFIGURED MESSAGE\nchange colors, and so on",
+ 'interval'=>200, 'font'=>'courier',
+ 'background'=>'gray', 'foreground'=>'red')
+ }
+
+ sb = TkScrollbox.new.pack(:fill=>:x)
+ sb.insert(:end, *%w(aaa bbb ccc ddd eee fff ggg hhh iii jjj kkk lll mmm))
+=begin
+ # CASE1 : command takes no arguemnt
+ bh = Tk::RbWidget::BalloonHelp.new(sb, :interval=>500,
+ :relief=>:ridge, :background=>'white',
+ :command=>proc{
+ y = TkWinfo.pointery(sb) - TkWinfo.rooty(sb)
+ bh.text "current index == #{sb.nearest(y)}"
+ })
+=end
+=begin
+ # CASE2 : command takes 2 arguemnts
+ bh = Tk::RbWidget::BalloonHelp.new(sb, :interval=>500,
+ :relief=>:ridge, :background=>'white',
+ :command=>proc{|x, y|
+ bh.text "current index == #{sb.nearest(y)}"
+ })
+=end
+=begin
+ # CASE3 : command takes 3 arguemnts
+ Tk::RbWidget::BalloonHelp.new(sb, :interval=>500,
+ :relief=>:ridge, :background=>'white',
+ :command=>proc{|x, y, bhelp|
+ bhelp.text "current index == #{sb.nearest(y)}"
+ })
+=end
+=begin
+ # CASE4a : command is a Proc object and takes 4 arguemnts
+ cmd = proc{|x, y, bhelp, parent|
+ bhelp.text "current index == #{parent.nearest(y)}"
+ }
+
+ Tk::RbWidget::BalloonHelp.new(sb, :interval=>500,
+ :relief=>:ridge, :background=>'white',
+ :command=>cmd)
+
+ sb2 = TkScrollbox.new.pack(:fill=>:x)
+ sb2.insert(:end, *%w(AAA BBB CCC DDD EEE FFF GGG HHH III JJJ KKK LLL MMM))
+ Tk::RbWidget::BalloonHelp.new(sb2, :interval=>500,
+ :padx=>5, :relief=>:raised,
+ :background=>'gray25', :foreground=>'white',
+ :command=>cmd)
+=end
+#=begin
+ # CASE4b : command is a Method object and takes 4 arguemnts
+ def set_msg(x, y, bhelp, parent)
+ bhelp.text "current index == #{parent.nearest(y)}"
+ end
+ cmd = self.method(:set_msg)
+
+ Tk::RbWidget::BalloonHelp.new(sb, :interval=>500,
+ :relief=>:ridge, :background=>'white',
+ :command=>cmd)
+
+ sb2 = TkScrollbox.new.pack(:fill=>:x)
+ sb2.insert(:end, *%w(AAA BBB CCC DDD EEE FFF GGG HHH III JJJ KKK LLL MMM))
+ Tk::RbWidget::BalloonHelp.new(sb2, :interval=>500,
+ :padx=>5, :relief=>:raised,
+ :background=>'gray25', :foreground=>'white',
+ :command=>cmd)
+#=end
+
+ Tk.mainloop
+end
diff --git a/jni/ruby/ext/tk/sample/tkbiff.rb b/jni/ruby/ext/tk/sample/tkbiff.rb
new file mode 100644
index 0000000..c0953a1
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkbiff.rb
@@ -0,0 +1,155 @@
+#!/usr/bin/env ruby
+
+if ARGV[0] != '-d'
+ unless $DEBUG
+ exit if fork
+ end
+else
+ ARGV.shift
+end
+
+if ARGV.length == 0
+ if ENV['MAIL']
+ $spool = ENV['MAIL']
+ else
+ $spool = '/var/spool/mail/' + ENV['USER']
+ end
+else
+ $spool = ARGV[0]
+end
+
+require "parsedate"
+require "base64"
+
+include ParseDate
+
+class Mail
+ def Mail.new(f)
+ if !f.kind_of?(IO)
+ f = open(f, "r")
+ me = super
+ f.close
+ else
+ me = super
+ end
+ return me
+ end
+
+ def initialize(f)
+ @header = {}
+ @body = []
+ while line = f.gets()
+ line.chop!
+ next if /^From / =~ line # skip From-line
+ break if /^$/ =~ line # end of header
+ if /^(\S+):\s*(.*)/ =~ line
+ @header[attr = $1.capitalize] = $2
+ elsif attr
+ sub(/^\s*/, '')
+ @header[attr] += "\n" + $_
+ end
+ end
+
+ return unless $_
+
+ while line = f.gets()
+ break if /^From / =~ line
+ @body.push($_)
+ end
+ end
+
+ def header
+ return @header
+ end
+
+ def body
+ return @body
+ end
+
+end
+
+require "tkscrollbox"
+
+my_appname = Tk.appname('tkbiff')
+$top = TkRoot.new
+if ((TkWinfo.interps($top) - [my_appname]).find{|ip| ip =~ /^tkbiff/})
+ STDERR.print("Probably other 'tkbiff's are running. Bye.\n")
+ exit
+end
+
+$top.withdraw
+$list = TkScrollbox.new($top) {
+ relief 'raised'
+ width 80
+ height 8
+ setgrid 'yes'
+ pack
+}
+TkButton.new($top) {
+ text 'Dismiss'
+ command proc {$top.withdraw}
+ pack('fill'=>'both','expand'=>'yes')
+}
+$top.bind "Control-c", proc{exit}
+$top.bind "Control-q", proc{exit}
+$top.bind "space", proc{exit}
+
+$spool_size = 0
+$check_time = Time.now
+
+def check
+ $check_time = Time.now
+ size = File.size($spool)
+ if size and size != $spool_size
+ $spool_size = size
+ pop_up if size > 0
+ end
+ Tk.after 5000, proc{check}
+end
+
+if defined? Thread
+ Thread.start do
+ loop do
+ sleep 600
+ if Time.now - $check_time > 200
+ Tk.after 5000, proc{check}
+ end
+ end
+ end
+end
+
+def pop_up
+ outcount = 0;
+ $list.delete 0, 'end'
+ f = open($spool, "r")
+ while !f.eof?
+ mail = Mail.new(f)
+ date, from, subj = mail.header['Date'], mail.header['From'], mail.header['Subject']
+ next if !date
+ y = m = d = 0
+ y, m, d = parsedate(date) if date
+ from = "sombody@somewhere" if ! from
+ subj = "(nil)" if ! subj
+ from = decode_b(from)
+ subj = decode_b(subj)
+ $list.insert 'end', format('%-02d/%02d/%02d [%-28.28s] %s',y,m,d,from,subj)
+ outcount += 1
+ end
+ f.close
+ if outcount == 0
+ $list.insert 'end', "You have no mail."
+ else
+ $list.see 'end'
+ end
+ $top.deiconify
+ Tk.after 2000, proc{$top.iconify}
+end
+
+$list.insert 'end', "You have no mail."
+check
+Tk.after 2000, proc{$top.iconify}
+begin
+ Tk.mainloop
+rescue
+ `echo #$! > /tmp/tkbiff`
+end
diff --git a/jni/ruby/ext/tk/sample/tkbrowse.rb b/jni/ruby/ext/tk/sample/tkbrowse.rb
new file mode 100644
index 0000000..56d5a80
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkbrowse.rb
@@ -0,0 +1,79 @@
+#!/usr/bin/env ruby
+#
+# This script generates a directory browser, which lists the working
+# directory and allows you to open files or subdirectories by
+# double-clicking.
+
+# Create a scrollbar on the right side of the main window and a listbox
+# on the left side.
+
+require "tkscrollbox"
+
+# The procedure below is invoked to open a browser on a given file; if the
+# file is a directory then another instance of this program is invoked; if
+# the file is a regular file then the Mx editor is invoked to display
+# the file.
+
+$dirlist = {}
+
+def browsedir (dir)
+ if $dirlist.key? dir
+ $dirlist[dir]
+ else
+ top = if $dirlist.size > 0 then TkToplevel.new else nil end
+ list = TkScrollbox.new(top) {
+ relief 'raised'
+ width 20
+ height 20
+ setgrid 'yes'
+ pack
+ }
+ list.insert 'end', *`ls #{dir}`.split
+
+ # Set up bindings for the browser.
+
+ list.focus
+ list.bind "Control-q", proc{exit}
+ list.bind "Control-c", proc{exit}
+ list.bind "Control-p", proc{
+ print "selection <", TkSelection.get, ">\n"
+ }
+
+ list.bind "Double-Button-1", proc{
+ for i in TkSelection.get.split
+ print "clicked ", i, "\n"
+ browse dir, i
+ end
+ }
+ $dirlist[dir] = list
+ end
+end
+
+def browse (dir, file)
+ file="#{dir}/#{file}"
+ if File.directory? file
+ browsedir(file)
+ else
+ if File.file? file
+ if ENV['EDITOR']
+ system format("%s %s&", ENV['EDITOR'], file)
+ else
+ system "xedit #{file}&"
+ end
+ else
+ STDERR.print "\"#{file}\" isn't a directory or regular file"
+ end
+ end
+end
+
+# Fill the listbox with a list of all the files in the directory (run
+# the "ls" command to get that information).
+
+if ARGV.length>0
+ dir = ARGV[0]
+else
+ dir="."
+end
+
+browsedir(dir)
+Tk.mainloop
diff --git a/jni/ruby/ext/tk/sample/tkcombobox.rb b/jni/ruby/ext/tk/sample/tkcombobox.rb
new file mode 100644
index 0000000..c38bde1
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkcombobox.rb
@@ -0,0 +1,497 @@
+#
+# tkcombobox.rb : auto scrollbox & combobox
+#
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+require 'tk'
+
+module Tk
+ module RbWidget
+ class AutoScrollListbox < TkListbox
+ end
+ class Combobox < TkEntry
+ end
+ end
+end
+
+class Tk::RbWidget::AutoScrollListbox
+ include TkComposite
+
+ @@up_bmp = TkBitmapImage.new(:data=><<EOD)
+#define up_arrow_width 9
+#define up_arrow_height 9
+static unsigned char up_arrow_bits[] = {
+ 0x00, 0x00, 0x10, 0x00, 0x10, 0x00, 0x38, 0x00, 0x38, 0x00, 0x7c, 0x00,
+ 0x7c, 0x00, 0xfe, 0x00, 0x00, 0x00};
+EOD
+
+ @@down_bmp = TkBitmapImage.new(:data=><<EOD)
+#define up_arrow_width 9
+#define up_arrow_height 9
+static unsigned char down_arrow_bits[] = {
+ 0x00, 0x00, 0xfe, 0x00, 0x7c, 0x00, 0x7c, 0x00, 0x38, 0x00, 0x38, 0x00,
+ 0x10, 0x00, 0x10, 0x00, 0x00, 0x00};
+EOD
+
+ ############################
+ private
+ ############################
+ def initialize_composite(keys={})
+ keys = _symbolkey2str(keys)
+
+ @initwait = keys.delete('startwait'){300}
+ @interval = keys.delete('interval'){150}
+ @initwait -= @interval
+ @initwait = 0 if @initwait < 0
+
+ @lbox = TkListbox.new(@frame, :borderwidth=>0)
+ @path = @lbox.path
+ TkPack.propagate(@lbox, false)
+
+ @scr = TkScrollbar.new(@frame, :width=>10)
+
+ @lbox.yscrollcommand(proc{|*args| @scr.set(*args); _config_proc})
+ @scr.command(proc{|*args| @lbox.yview(*args); _config_proc})
+
+ @up_arrow = TkLabel.new(@lbox, :image=>@@up_bmp,
+ :relief=>:raised, :borderwidth=>1)
+ @down_arrow = TkLabel.new(@lbox, :image=>@@down_bmp,
+ :relief=>:raised, :borderwidth=>1)
+
+ _init_binding
+
+ @lbox.pack(:side=>:left, :fill=>:both, :expand=>:true)
+
+ delegate('DEFAULT', @lbox)
+ delegate('background', @frame, @scr)
+ delegate('activebackground', @scr)
+ delegate('troughcolor', @scr)
+ delegate('repeatdelay', @scr)
+ delegate('repeatinterval', @scr)
+ delegate('relief', @frame)
+ delegate('borderwidth', @frame)
+
+ delegate_alias('arrowrelief', 'relief', @up_arrow, @down_arrow)
+ delegate_alias('arrowborderwidth', 'borderwidth', @up_arrow, @down_arrow)
+
+ scrollbar(keys.delete('scrollbar')){false}
+
+ configure keys unless keys.empty?
+ end
+
+ def _show_up_arrow
+ unless @up_arrow.winfo_mapped?
+ @up_arrow.pack(:side=>:top, :fill=>:x)
+ end
+ end
+
+ def _show_down_arrow
+ unless @down_arrow.winfo_mapped?
+ @down_arrow.pack(:side=>:bottom, :fill=>:x)
+ end
+ end
+
+ def _set_sel(idx)
+ @lbox.activate(idx)
+ @lbox.selection_clear(0, 'end')
+ @lbox.selection_set(idx)
+ end
+
+ def _check_sel(cidx, tidx = nil, bidx = nil)
+ _set_sel(cidx)
+ unless tidx
+ tidx = @lbox.nearest(0)
+ tidx += 1 if tidx > 0
+ end
+ unless bidx
+ bidx = @lbox.nearest(10000)
+ bidx -= 1 if bidx < @lbox.index('end') - 1
+ end
+ if cidx > bidx
+ _set_sel(bidx)
+ end
+ if cidx < tidx
+ _set_sel(tidx)
+ end
+ end
+
+ def _up_proc
+ cidx = @lbox.curselection[0]
+ idx = @lbox.nearest(0)
+ if idx >= 0
+ @lbox.see(idx - 1)
+ _set_sel(idx)
+ @up_arrow.pack_forget if idx == 1
+ @up_timer.stop if idx == 0
+ _show_down_arrow if @lbox.bbox('end') == []
+ end
+ if cidx && cidx > 0 && (idx == 0 || cidx == @lbox.nearest(10000))
+ _set_sel(cidx - 1)
+ end
+ end
+
+ def _down_proc
+ cidx = @lbox.curselection[0]
+ eidx = @lbox.index('end') - 1
+ idx = @lbox.nearest(10000)
+ if idx <= eidx
+ @lbox.see(idx + 1)
+ _set_sel(cidx + 1) if cidx < eidx
+ @down_arrow.pack_forget if idx + 1 == eidx
+ @down_timer.stop if idx == eidx
+ _show_up_arrow if @lbox.bbox(0) == []
+ end
+ if cidx && cidx < eidx && (eidx == idx || cidx == @lbox.nearest(0))
+ _set_sel(cidx + 1)
+ end
+ end
+
+ def _key_UP_proc
+ cidx = @lbox.curselection[0]
+ _set_sel(cidx = @lbox.index('activate')) unless cidx
+ cidx -= 1
+ if cidx == 0
+ @up_arrow.pack_forget
+ elsif cidx == @lbox.nearest(0)
+ @lbox.see(cidx - 1)
+ end
+ end
+
+ def _key_DOWN_proc
+ cidx = @lbox.curselection[0]
+ _set_sel(cidx = @lbox.index('activate')) unless cidx
+ cidx += 1
+ if cidx == @lbox.index('end') - 1
+ @down_arrow.pack_forget
+ elsif cidx == @lbox.nearest(10000)
+ @lbox.see(cidx + 1)
+ end
+ end
+
+ def _config_proc
+ if @lbox.size == 0
+ @up_arrow.pack_forget
+ @down_arrow.pack_forget
+ return
+ end
+ tidx = @lbox.nearest(0)
+ bidx = @lbox.nearest(10000)
+ if tidx > 0
+ _show_up_arrow
+ tidx += 1
+ else
+ @up_arrow.pack_forget unless @up_timer.running?
+ end
+ if bidx < @lbox.index('end') - 1
+ _show_down_arrow
+ bidx -= 1
+ else
+ @down_arrow.pack_forget unless @down_timer.running?
+ end
+ cidx = @lbox.curselection[0]
+ _check_sel(cidx, tidx, bidx) if cidx
+ end
+
+ def _init_binding
+ @up_timer = TkAfter.new(@interval, -1, proc{_up_proc})
+ @down_timer = TkAfter.new(@interval, -1, proc{_down_proc})
+
+ @up_timer.set_start_proc(@initwait, proc{})
+ @down_timer.set_start_proc(@initwait, proc{})
+
+ @up_arrow.bind('Enter', proc{@up_timer.start})
+ @up_arrow.bind('Leave', proc{@up_timer.stop if @up_arrow.winfo_mapped?})
+ @down_arrow.bind('Enter', proc{@down_timer.start})
+ @down_arrow.bind('Leave', proc{@down_timer.stop if @down_arrow.winfo_mapped?})
+
+ @lbox.bind('Configure', proc{_config_proc})
+ @lbox.bind('Enter', proc{|y| _set_sel(@lbox.nearest(y))}, '%y')
+ @lbox.bind('Motion', proc{|y|
+ @up_timer.stop if @up_timer.running?
+ @down_timer.stop if @down_timer.running?
+ _check_sel(@lbox.nearest(y))
+ }, '%y')
+
+ @lbox.bind('Up', proc{_key_UP_proc})
+ @lbox.bind('Down', proc{_key_DOWN_proc})
+ end
+
+ ############################
+ public
+ ############################
+ def scrollbar(mode)
+ if mode
+ @scr.pack(:side=>:right, :fill=>:y)
+ else
+ @scr.pack_forget
+ end
+ end
+end
+
+################################################
+
+class Tk::RbWidget::Combobox < TkEntry
+ include TkComposite
+
+ @@down_btn_bmp = TkBitmapImage.new(:data=><<EOD)
+#define down_arrow_width 11
+#define down_arrow_height 11
+static unsigned char down_arrow_bits[] = {
+ 0x00, 0x00, 0xfe, 0x03, 0xfc, 0x01, 0xfc, 0x01, 0xf8, 0x00, 0xf8, 0x00,
+ 0x70, 0x00, 0x70, 0x00, 0x20, 0x00, 0x20, 0x00, 0x00, 0x00};
+EOD
+
+ @@up_btn_bmp = TkBitmapImage.new(:data=><<EOD)
+#define up_arrow_width 11
+#define up_arrow_height 11
+static unsigned char up_arrow_bits[] = {
+ 0x00, 0x00, 0x20, 0x00, 0x20, 0x00, 0x70, 0x00, 0x70, 0x00, 0xf8, 0x00,
+ 0xf8, 0x00, 0xfc, 0x01, 0xfc, 0x01, 0xfe, 0x03, 0x00, 0x00};
+EOD
+
+ def _button_proc(dir = true)
+ return if @ent.state == 'disabled'
+ @btn.relief(:sunken)
+ x = @frame.winfo_rootx
+ y = @frame.winfo_rooty
+ if dir
+ @top.geometry("+#{x}+#{y + @frame.winfo_height}")
+ else
+ @btn.image(@@up_btn_bmp)
+ @top.geometry("+#{x}+#{y - @top.winfo_reqheight}")
+ end
+ @top.deiconify
+ @lst.focus
+
+ if (idx = values.index(@ent.value))
+ @lst.see(idx - 1)
+ @lst.activate(idx)
+ @lst.selection_set(idx)
+ elsif @lst.size > 0
+ @lst.see(0)
+ @lst.activate(0)
+ @lst.selection_set(0)
+ end
+ @top.grab
+
+ begin
+ @wait_var.tkwait
+ if (idx = @wait_var.to_i) >= 0
+ # @ent.value = @lst.get(idx)
+ _set_entry_value(@lst.get(idx))
+ end
+ @top.withdraw
+ @btn.relief(:raised)
+ @btn.image(@@down_btn_bmp)
+ rescue
+ ensure
+ begin
+ @top.grab(:release)
+ @ent.focus
+ rescue
+ end
+ end
+ end
+ private :_button_proc
+
+ def _init_bindings
+ @btn.bind('1', proc{_button_proc(true)})
+ @btn.bind('3', proc{_button_proc(false)})
+
+ @lst.bind('1', proc{|y| @wait_var.value = @lst.nearest(y)}, '%y')
+ @lst.bind('Return', proc{@wait_var.value = @lst.curselection[0]})
+
+ cancel = TkVirtualEvent.new('2', '3', 'Escape')
+ @lst.bind(cancel, proc{@wait_var.value = -1})
+ end
+ private :_init_bindings
+
+ def _set_entry_value(val)
+ @ent.textvariable.value = val
+ end
+ private :_set_entry_value
+
+ #----------------------------------------------------
+
+ def _state_control(value = None)
+ if value == None
+ # get
+ @ent.state
+ else
+ # set
+ @ent.state(value.to_s)
+ case value = @ent.state # regulate 'state' string
+ when 'normal', 'readonly'
+ @btn.state 'normal'
+ when 'disabled'
+ @btn.state 'disabled'
+ else
+ # unknown : do nothing
+ end
+ end
+ end
+ private :_state_control
+
+ def __methodcall_optkeys # { key=>method, ... }
+ {'state' => :_state_control}
+ end
+ private :__methodcall_optkeys
+
+ #----------------------------------------------------
+
+ def _textvariable_control(var = None)
+ if var == None
+ # get
+ ((var = @ent.textvariable) === @default_var)? nil: var
+ else
+ # set
+ @var = var
+ tk_send('configure', '-textvariable', (@var)? var: @default_var)
+ end
+ end
+ private :_textvariable_control
+
+ #----------------------------------------------------
+
+ def initialize_composite(keys={})
+ keys = _symbolkey2str(keys)
+
+ @btn = TkLabel.new(@frame, :relief=>:raised, :borderwidth=>2,
+ :image=>@@down_btn_bmp).pack(:side=>:right,
+ :ipadx=>2, :fill=>:y)
+ @ent = TkEntry.new(@frame).pack(:side=>:left)
+ @path = @ent.path
+
+ @top = TkToplevel.new(@btn, :borderwidth=>1, :relief=>:raised) {
+ withdraw
+ transient
+ overrideredirect(true)
+ }
+
+ startwait = keys.delete('startwait'){300}
+ interval = keys.delete('interval'){150}
+ @lst = Tk::RbWidget::AutoScrollListbox.new(@top, :scrollbar=>true,
+ :startwait=>startwait,
+ :interval=>interval)
+ @lst.pack(:fill=>:both, :expand=>true)
+ @ent_list = []
+
+ @wait_var = TkVariable.new
+ @var = @default_var = TkVariable.new
+
+ @ent.textvariable @default_var
+
+ _init_bindings
+
+ option_methods('textvariable' => :_textvariable_control)
+
+ delegate('DEFAULT', @ent)
+ delegate('height', @lst)
+ delegate('relief', @frame)
+ delegate('borderwidth', @frame)
+
+ delegate('arrowrelief', @lst)
+ delegate('arrowborderwidth', @lst)
+
+ delegate('state', false)
+
+ if mode = keys.delete('scrollbar')
+ scrollbar(mode)
+ end
+
+ configure keys unless keys.empty?
+ end
+ private :initialize_composite
+
+ def scrollbar(mode)
+ @lst.scrollbar(mode)
+ end
+
+ def _reset_width
+ len = @ent.width
+ @lst.get(0, 'end').each{|l| len = l.length if l.length > len}
+ @lst.width(len + 1)
+ end
+ private :_reset_width
+
+ def add(ent)
+ ent = ent.to_s
+ unless @ent_list.index(ent)
+ @ent_list << ent
+ @lst.insert('end', ent)
+ end
+ _reset_width
+ self
+ end
+
+ def remove(ent)
+ ent = ent.to_s
+ @ent_list.delete(ent)
+ if idx = @lst.get(0, 'end').index(ent)
+ @lst.delete(idx)
+ end
+ _reset_width
+ self
+ end
+
+ def values(ary = nil)
+ if ary
+ @lst.delete(0, 'end')
+ @ent_list.clear
+ ary.each{|ent| add(ent)}
+ _reset_width
+ self
+ else
+ @lst.get(0, 'end')
+ end
+ end
+
+ def see(idx)
+ @lst.see(@lst.index(idx) - 1)
+ end
+
+ def list_index(idx)
+ @lst.index(idx)
+ end
+end
+
+
+################################################
+# test
+################################################
+if __FILE__ == $0
+# e0 = Tk::RbWidget::Combobox.new.pack
+# e0.values(%w(aa bb cc dd ee ff gg hh ii jj kk ll mm nn oo pp qq rr ss tt uu))
+
+ v = TkVariable.new
+ e = Tk::RbWidget::Combobox.new(:height=>7, :scrollbar=>true,
+ :textvariable=>v,
+ :arrowrelief=>:flat, :arrowborderwidth=>0,
+ :startwait=>400, :interval=>200).pack
+ e.values(%w(aa bb cc dd ee ff gg hh ii jj kk ll mm nn oo pp qq rr ss tt uu))
+ #e.see(e.list_index('end') - 2)
+ e.value = 'cc'
+ TkFrame.new{|f|
+ fnt = TkFont.new('Helvetica 10')
+ TkLabel.new(f, :font=>fnt, :text=>'TkCombobox value :').pack(:side=>:left)
+ TkLabel.new(f, :font=>fnt, :textvariable=>v).pack(:side=>:left)
+ }.pack
+
+ TkFrame.new(:relief=>:raised, :borderwidth=>2,
+ :height=>3).pack(:fill=>:x, :expand=>true, :padx=>5, :pady=>3)
+
+ l = Tk::RbWidget::AutoScrollListbox.new(nil, :relief=>:groove,
+ :borderwidth=>4,:height=>7,
+ :width=>20).pack(:fill=>:both,
+ :expand=>true)
+ (0..20).each{|i| l.insert('end', "line #{i}")}
+
+ TkFrame.new(:relief=>:ridge, :borderwidth=>3){
+ TkButton.new(self, :text=>'ON',
+ :command=>proc{l.scrollbar(true)}).pack(:side=>:left)
+ TkButton.new(self, :text=>'OFF',
+ :command=>proc{l.scrollbar(false)}).pack(:side=>:right)
+ pack(:fill=>:x)
+ }
+ Tk.mainloop
+end
diff --git a/jni/ruby/ext/tk/sample/tkdialog.rb b/jni/ruby/ext/tk/sample/tkdialog.rb
new file mode 100644
index 0000000..eb8cd04
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkdialog.rb
@@ -0,0 +1,61 @@
+#!/usr/bin/env ruby
+require "tk"
+
+root = TkFrame.new
+top = TkFrame.new(root) {
+ relief 'raised'
+ border 1
+}
+msg = TkMessage.new(top) {
+ text "File main.c hasn't been saved to disk since \
+it was last modified. What should I do?"
+ justify 'center'
+ aspect 200
+ font '-Adobe-helvetica-medium-r-normal--*-240*'
+ pack('padx'=>5, 'pady'=>5, 'expand'=>'yes')
+}
+top.pack('fill'=>'both')
+root.pack
+
+bot = TkFrame.new(root) {
+ relief 'raised'
+ border 1
+}
+
+TkFrame.new(bot) { |left|
+ relief 'sunken'
+ border 1
+ pack('side'=>'left', 'expand'=>'yes', 'padx'=>10, 'pady'=> 10)
+ TkButton.new(left) {
+ text "Save File"
+ command "quit 'save'"
+ pack('expand'=>'yes','padx'=>6,'pady'=> 6)
+ top.bind "Enter", proc{state 'active'}
+ msg.bind "Enter", proc{state 'active'}
+ bot.bind "Enter", proc{state 'active'}
+ top.bind "Leave", proc{state 'normal'}
+ msg.bind "Leave", proc{state 'normal'}
+ bot.bind "Leave", proc{state 'normal'}
+ Tk.root.bind "ButtonRelease-1", proc{quit 'save'}
+ Tk.root.bind "Return", proc{quit 'save'}
+ }
+}
+TkButton.new(bot) {
+ text "Quit Anyway"
+ command "quit 'quit'"
+ pack('side'=>'left', 'expand'=>'yes', 'padx'=>10)
+}
+TkButton.new(bot) {
+ text "Return To Editor"
+ command "quit 'return'"
+ pack('side'=>'left', 'expand'=>'yes', 'padx'=>10)
+}
+bot.pack
+root.pack('side'=>'top', 'fill'=>'both', 'expand'=>'yes')
+
+def quit(button)
+ print "You pressed the \"#{button}\" button; bye-bye!\n"
+ exit
+end
+
+Tk.mainloop
diff --git a/jni/ruby/ext/tk/sample/tkextlib/ICONS/Orig_LICENSE.txt b/jni/ruby/ext/tk/sample/tkextlib/ICONS/Orig_LICENSE.txt
new file mode 100644
index 0000000..71e3595
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkextlib/ICONS/Orig_LICENSE.txt
@@ -0,0 +1,61 @@
+
+ #########################################################################
+ ### The following text is the original file of the Tcl/Tk extension. ###
+ ### Icon data files ( those are 'tkIcons', 'tkIcons-sample.kde', and ###
+ ### 'tkIcons.kde' ) are quoted from the source archive of ICONS ###
+ ### extension. As the following document describes, those icon images ###
+ ### are not applied the license. ###
+ #########################################################################
+
+
+IMPORTANT LICENSE INFORMATION
+=============================
+
+The following terms (based on the standard TCL/TK license) apply to all files
+contained in this package, <b>except</b> the icon images.
+
+The icon images can be freely distributed. If you require clarification of
+copyright/license details for the images, please contact the appropriate
+creator/maintainer.
+
+ICONS: LICENSE TERMS
+====================
+
+This software (ICONS) is Copyright 2002 by Adrian Davis (adrian@satisoft.com).
+The following terms apply to all files associated with the software except
+where noted above.
+
+The author hereby grants permission to use, copy, modify, distribute,
+and license this software and its documentation for any purpose, provided
+that existing copyright notices are retained in all copies and that
+this notice is included verbatim in any distributions. No written agreement,
+license, or royalty fee is required for any of the authorized uses.
+Modifications to this software may be copyrighted by their authors
+and need not follow the licensing terms described here, provided that
+the new terms are clearly indicated on the first page of each file
+where they apply.
+
+IN NO EVENT SHALL THE AUTHORS OR DISTRIBUTORS BE LIABLE TO ANY PARTY
+FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
+ARISING OUT OF THE USE OF THIS SOFTWARE, ITS DOCUMENTATION, OR ANY
+DERIVATIVES THEREOF, EVEN IF THE AUTHORS HAVE BEEN ADVISED OF THE POSSIBILITY
+OF SUCH DAMAGE.
+
+THE AUTHORS AND DISTRIBUTORS SPECIFICALLY DISCLAIM ANY WARRANTIES,
+INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE, AND NON-INFRINGEMENT. THIS SOFTWARE
+IS PROVIDED ON AN "AS IS" BASIS, AND THE AUTHORS AND DISTRIBUTORS HAVE
+NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS,
+OR MODIFICATIONS.
+
+GOVERNMENT USE: If you are acquiring this software on behalf of the
+U.S. government, the Government shall have only "Restricted Rights"
+in the software and related documentation as defined in the Federal
+Acquisition Regulations (FARs) in Clause 52.227.19 (c) (2). If you
+are acquiring the software on behalf of the Department of Defense,
+the software shall be classified as "Commercial Computer Software"
+and the Government shall have only "Restricted Rights" as defined in
+Clause 252.227-7013 (c) (1) of DFARs. Notwithstanding the foregoing,
+the authors grant the U.S. Government and others acting in its behalf
+permission to use and distribute the software in accordance with the
+terms specified in this license.
diff --git a/jni/ruby/ext/tk/sample/tkextlib/ICONS/tkIcons b/jni/ruby/ext/tk/sample/tkextlib/ICONS/tkIcons
new file mode 100644
index 0000000..0d5b2c8
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkextlib/ICONS/tkIcons
@@ -0,0 +1,195 @@
+actattach16:act act16 16:photo:16 16:R0lGODlhEAAQAIEAAPwCBPz+/AQCBAAAACH5BAEAAAAALAAAAAAQABAAAAI2hAOCxg2h0nJHyEshi9HpxU1GOCLdZoKpQ15nibUoprKp9lh2oucUxsBRXsJh4Hjs/QTMpr8AACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+actbookmark16:act act16 16:photo:16 16:R0lGODlhEAAQAIQAAPwCBCwqLLSytLy+vERGRFRWVDQ2NKSmpAQCBKyurMTGxISChJyanHR2dIyKjGxubHRydGRmZIyOjFxeXHx6fAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAVbICACwWieY1CibCCsrBkMb0zchSEcNYskCtqBBzshFkOGQFk0IRqOxqPBODRHCMhCQKteRc9FI/KQWGOIyFYgkDC+gPR4snCcfRGKOIKIgSMQE31+f4OEYCZ+IQAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+actbookmarknew16:act act16 16:photo:16 16:R0lGODlhEAAQAIQAAPwCBCwqLLSytLy6vERGRFRWVDQyNKSipAQCBMTGxKyurISChJSSlJyanHR2dIyKjPz+xISGhPz+BGxubMTCBHx+fPz+/AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAVfICACwWieY1CibCCsrBkMb0zchTEcNYsIiYHiwIOdEAvigdFQGE0Ix4NBbSAgsWjk+jBIAlcUYrJASChnSXZSoUDelKfoKpFALJA61ueGI2IAZmhogGFmCGGAgXsifiEAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+actcheck16:act act16 16:photo:16 16:R0lGODlhEAAQAIIAAPwCBMT+xATCBASCBARCBAQCBEQCBAAAACH5BAEAAAAALAAAAAAQABAAAAM2CLrc/itAF8RkdVyVye4FpzUgJwijORCGUhDDOZbLG6Nd2xjwibIQ2y80sRGIl4IBuWk6Af4EACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+actcross16:act act16 16:photo:16 16:R0lGODlhEAAQAIIAAASC/PwCBMQCBEQCBIQCBAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAMuCLrc/hCGFyYLQjQsquLDQ2ScEEJjZkYfyQKlJa2j7AQnMM7NfucLze1FLD78CQAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+actexit16:act act16 16:photo:16 16:R0lGODlhEAAQAIEAAPwCBAQCBDQyNHR2dCH5BAEAAAAALAAAAAAQABAAAAI4hI+pFrHb3nEg1iWiDiINCwYDko0V9XUTda6I1TIsUMpGinyzbB6ZeGuoEr+GUDL4CXqSphPhLwAAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+acthelp16:act act16 16:photo:16 16:R0lGODlhEAAQAIMAAPwCBAQ6XAQCBCyCvARSjAQ+ZGSm1ARCbEyWzESOxIy63ARalAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAQ/EEgQqhUz00GEJx2WFUY3BZw5HYh4cu6mSkEy06B72LHkiYFST0NRLIaa4I0oQyZhTKInSq2eAlaaMAuYEv0RACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+actitemadd16:act act16 16:photo:16 16:R0lGODlhEAAQAIQAAPwCBARCZPz+/Mzq9BTC3ITC1HSyzGSivAw+XBSStIS6zHy2zAQCDFyatAQOHFSStEyOtAQSJBSq1DR2nCxunCRmlAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAVbICCOQTmeaCAMRIC+AVu47xkTBl2Ld16XQNYBQTQBVIOkMHFQJBeMI4tAbSSu2IRDSnhAvFfI97sFRM6RwOMacbjLKckVvgvIJ5EdSU7J648VgXQ7Dmd/hyJ+IQAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+actitemdelete16:act act16 16:photo:16 16:R0lGODlhEAAQAIMAAPwCBARCZPz+/Mzq9BTC3AQCDAQOHFSStAQSJAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAQwEMhJq704681n+GAISoEwnGg6EAUQrEQsz4ThEkeu77kNIAagMEj0dY7IpHI58UcAACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+actlock16:act act16 16:photo:16 16:R0lGODlhEAAQAIUAAPwCBFxaVAQCBKSipDQyNMTCxISChFxaLFxSJEQ+FExGHCQiDBwaDGxiLHxyNHRuPIR+TIyGZJSSfFxaRFxWJGRiLJyaXNzWpNTOnMzGnLy2hJSKTGReLKyqjPTu1NzarMS+jLSyfKyibJySXIyGVCQeDLSytPT29Ozu7OTi5NTS1KyurJSSjGxqVFxaXLS2tKSebOzuzLSufJSOXExGLGRiTExONAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAaTQIBwGCgGhkhkQDBoEpLKQoBACAyOUID1qTVwoQGvMPxNFgVjAxp6QCQUicSCwVgkG44HJCKRRCYUCAxIFRYXhxgZGhYbHINEHR4fGCAhIiMkFSVKJicoKSoFKwMsLZtDLison6GjLA92qCueoAUvpC2xQhWqrLYDErmEMDEXlDIwMxAHukI0NS01EzY2NAmPAH5BACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+actredo16:act act16 16:photo:16 16:R0lGODlhEAAQAIUAAPwCBBxOHBxSHBRGHKzCtNzu3MTSzBQ2FLzSxIzCjCSKFCyeHDzCLAxGHAwuFDSCNBxKLES+NHSmfBQ6FBxWJAQaDAQWFAw+HDSyLJzOnISyjMTexAQOBAwmDAw+FMzizAQODDymNKzWrAQKDAwaDEy6TFTGTFSyXDyKTAQCBAwiFBQyHAwSFAwmHAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAZ2QIBwSCwaj0hAICBICgcDQsEgaB4PiIRiW0AEiE3sdsFgcK2CBsCheEAcjgYjoigwJRM2pUK0XDAKGRobDRwKHUcegAsfExUdIEcVCgshImojfEUkCiUmJygHACkqHEQpqKkpogAgK5FOQywtprFDKRwptrZ+QQAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+actreload16:act act16 16:photo:16 16:R0lGODlhEAAQAIUAAPwCBCRaJBxWJBxOHBRGBCxeLLTatCSKFCymJBQ6BAwmBNzu3AQCBAQOBCRSJKzWrGy+ZDy+NBxSHFSmTBxWHLTWtCyaHCSSFCx6PETKNBQ+FBwaHCRKJMTixLy6vExOTKyqrFxaXDQyNDw+PBQSFHx6fCwuLJyenDQ2NISChLSytJSSlFxeXAwODCQmJBweHAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAaBQIBQGBAMBALCcCksGA4IQkJBUDIDC6gVwGhshY5HlMn9DiCRL1MyYE8iiapaSKlALBdMRiPckDkdeXt9HgxkGhWDXB4fH4ZMGnxcICEiI45kQiQkDCUmJZskmUIiJyiPQgyoQwwpH35LqqgMKiEjq5obqh8rLCMtowAkLqovuH5BACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+actrun16:act act16 16:photo:16 16:R0lGODlhEAAQAIMAAPwCBAQCBPz+/ISChKSipMTCxLS2tLy+vMzOzMTGxNTS1AAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAARlEMgJQqDYyiDGrR8oWJxnCcQXDMU4GEYqFN4UEHB+FEhtv7EBIYEohkjBkwJBqggEMB+ncHhaBsDUZmbAXq67EecQ02x2CMWzkAs504gCO3qcDZjkl11FMJVIN0cqHSpuGYYSfhEAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+actstop16:act act16 16:photo:16 16:R0lGODlhEAAQAIUAAASC/Gw6NGQuLHQ6NGQmJFweHFQaFPTm5PTa3PTW1Oy+vOS6tNSinKReVDQWFPz+/Nx6fNyCfNyGhNR+dMxybMRiXLxGRIwWFNx2dNx+fNx2bMxuZLQWFBwWFPTu7Pzy9NRqZNRuZMRSVLwmJGwWFNR2dMQiHPTKxMxmXMQyLMxmZNx6dMxiXMRSRMRaVKxybMxaVEQWFMQuJAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAaaQIAQEBAMCAWDYcgkHhAJxYLRcDQBggckIplQKpaLdRh4YDIaSWa94Vw6woAHgv6AMKGPaMQhwQMJJRkfhHmEJhdvRCcgGSCEkCgpbnAECiorGYYfLCItlAAFCygQj5AfbYlwBQwVE5AukG6KBi8tMC0fLi0pHxyzcAAxFxwmMny/wEwOxMm/qlcdJCSJ1H5XQh3a28HY3kx+QQAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+actundo16:act act16 16:photo:16 16:R0lGODlhEAAQAIUAAPwCBBxSHBxOHMTSzNzu3KzCtBRGHCSKFIzCjLzSxBQ2FAxGHDzCLCyeHBQ+FHSmfAwuFBxKLDSCNMzizISyjJzOnDSyLAw+FAQSDAQeDBxWJAwmDAQOBKzWrDymNAQaDAQODAwaDDyKTFSyXFTGTEy6TAQCBAQKDAwiFBQyHAwSFAwmHAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAZ1QIBwSCwaj0hiQCBICpcDQsFgGAaIguhhi0gohIsrQEDYMhiNrRfgeAQC5fMCAolIDhD2hFI5WC4YRBkaBxsOE2l/RxsHHA4dHmkfRyAbIQ4iIyQlB5NFGCAACiakpSZEJyinTgAcKSesACorgU4mJ6uxR35BACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+actunlock16:act act16 16:photo:16 16:R0lGODlhEAAQAIUAAPwCBFxaVAQCBKSipDQyNMTCxISChFxaLFxSJExGHEQ+FCQiDBwaDBweDGxiLHxyNHRuPIR+RIyGZJSSfFxaRGxmLJyaXNzWpNTOnMzGnMS+jJSKTGReLKyqjPTu1NzarLSufKyibJySXIyGVGxiNFxaXLSytPT29Ozu7OTi5NTS1KyurGxqVCQeDJSSjLS2tNTW1KSmpGRiLKSebOzuzJSOXExONExGLAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAaVQIBwOAwYA8SkMCAYOAnKYiFAIAQGyOgVCggYuEovVxztMpdnwAGRSCgUCwOjIeQ6HpCIZDKRUNYMRBUWF4UYGRoWGxyBRR0eHxgaICEiIyR0QyUmJygpKgUrAxMsLUQlKyieoKIuEAunK52fBS8DLiywQySpnjC1Mbi6QjIzNBeSIBY1EQfDQgosLAEUNjY3Co1DfkEAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+appbook16:app app16 16:photo:16 16:R0lGODlhEAAQAIQAAPwCBAQCBDyKhDSChGSinFSWlEySjCx+fHSqrGSipESOjCR6dKTGxISytIy6vFSalBxydAQeHHyurAxubARmZCR+fBx2dDyKjPz+/MzKzLTS1IyOjAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAVkICCOZGmKQXCWqTCoa0oUxnDAZIrsSaEMCxwgwGggHI3E47eA4AKRogQxcy0mFFhgEW3MCoOKBZsdUrhFxSUMyT7P3bAlhcnk4BoHvb4RBuABGHwpJn+BGX1CLAGJKzmKjpF+IQAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+appbookopen16:app app16 16:photo:16 16:R0lGODlhEAAQAIUAAPwCBAQCBExCNGSenHRmVCwqJPTq1GxeTHRqXPz+/DwyJPTq3Ny+lOzexPzy5HRuVFSWlNzClPTexIR2ZOzevPz29AxqbPz6/IR+ZDyKjPTy5IyCZPz27ESOjJySfDSGhPTm1PTizJSKdDSChNzWxMS2nIR6ZKyijNzOrOzWtIx+bLSifNTGrMy6lIx+ZCRWRAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAaeQEAAQCwWBYJiYEAoGAFIw0E5QCScAIVikUgQqNargtFwdB9KSDhxiEjMiUlgHlB3E48IpdKdLCxzEAQJFxUTblwJGH9zGQgVGhUbbhxdG4wBHQQaCwaTb10emB8EBiAhInp8CSKYIw8kDRSfDiUmJ4xCIxMoKSoRJRMrJyy5uhMtLisTLCQkC8bHGBMj1daARgEjLyN03kPZc09FfkEAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+appboxes16:app app16 16:photo:16 16:R0lGODlhEAAQAIMAAPwCBAQCBMT+xAT+BASCBATCBMT+/AT+/ASChATCxPz+xPz+BISCBMTCBAAAAAAAACH5BAEAAAAALAAAAAAQABAAAARaEEgZwrwYBCFqvhs3DNYXjChRlWBRjIRqGN4UuEUczMZxsDeXykdEsDQVVSLhQxhBCkVlmXA+KVHFYhFYOoHbMGN6pTQaW8YYiQmcG+q16a0+Zipw+4e9B/gjACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+appbox16:app app16 16:photo:16 16:R0lGODlhEAAQAIIAAPwCBAQCBPz+xISCBMTCBAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAANECKoR6ys2IVqokF08yMTA1gwkYX5WQK5ma4VceTYPxXnBWdtY6+0834/Bowgzm6APWRQcH4TiMhPK2WYRiZWW7XK7/gQAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+appbrowser16:app app16 16:photo:16 16:R0lGODlhEAAQAIYAAPwCBFxONCROfCRKfKx6LNy+bNTOpGSS1DRupAwyXBRSnPTSjPTqvOzqzMzSvHSSlKy6ZDxutAxCpBQ2XBxepLTKvPzqzPzy5OTShLS2dLSqRFR2jBRerBQ+jOTixOzetNS2XHx6XDR2tCRexBwyTDyKzOTavPzq1OzKdCx23BRKtCQ6VCQmHFSa7IyirOzSnGSGpIR+bFSO1DyK7DR+5CRixBw2VDQuHFye7IS27NzGXISuhEyS5DR25BRWxBQ+lBQyXCQqPCxSfGyu7GyerKy2ZFR+rERqfCRmxBROtBQ+fBwuTBwmNDSW9JyabLyqRIx+TExSXBQ6bAQCBBQ6ZBxapDR+zBxq3LyaLJySRHxqPGxeNBxGbCRmrHRyRERONDRKNDQ2JCQuLAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAeygACCg4SFhgABAQIDh4MBBAUGBwgDCYcKCwwNDg8QERIThRQVFhcNGBkaGxwdoYMDHhcXHxggISIjEiSvJSYXJwsoISkpIyorLIIDLS4WLzAxMjM0NSo2N8o4OS46OzwzPSk+P0BBgkI8Q0NERUZHCEhJSktMgwk4Qy1NTk9QUVJLphCiUsWKlStYsmjZQiJgIS4KuijQ4iXAFxYCDVFJwGUFmDBhMjYSw0KMyEYoBfkJBAAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+appcalc16:app app16 16:photo:16 16:R0lGODlhEAAQAIEAAPwCBISChPz+/AQCBCH5BAEAAAAALAAAAAAQABAAAAI4hI9pwe0Ogpi00hHF2LzzzFlTsIHD45SSx6oCeW4wjK2tl83y7t64pIsJaxrfh2bEAJIlhRPhLwAAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+appclock16:app app16 16:photo:16 16:R0lGODlhEAAQAIIAALy+vAQCBPwCBMQCBIQCBISChPz+/MTCxCH5BAAAAAAALAAAAAAQABAAAANbCLHcrSLKOZcYmDSCsR1aUABAsXDDJwJGa5SBFwgaWxbCG3CWaBwG3C8Y67FawpYiNQscg65fsVkYuoAmJs1pBR522lQB6ILJLqHRwQQOZzYdZnw+dzruDIA/AQAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+appdate16:app app16 16:photo:16 16:R0lGODlhEAAQAIQAAASC/AQCBPzerPyqXMRaBIQCBISChPz+/KSipMTCxPz+BMTCBPwCBPz+xPzCxMQCBISCBAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAVxICCOQGCeJjkGwkC8RFEEavkax2G8dB0QuRyhhzoBg8MSYsncJXKJZIDZHCoWP1ogGIwGrtnSgUFmHLyNRHhrdpjRamnO/SYkromHdnxwnwkKVxByZW8DgQsQM2JcfwZXO0MBCZSVBgMuLzJaRZ0pfiEAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+apppencil16:app app16 16:photo:16 16:R0lGODlhEAAQAIMAAASC/IQCBMQCBPzCxAQCBPz+/MTCxISChDQyNKSipEQCBAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAARDEMhJZRBD1H2z3lMnjKCFjUJQimOgcmcbELCXzjXq0hV785WCQYcDFQjDXeloMByKG6YTAdwIDAlqSZJSVFeKLcUfAQAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+appsheet16:app app16 16:photo:16 16:R0lGODlhEAAQAIIAAPwCBAQCBAT+/Pz+/KSipPz+BAAAAAAAACH5BAEAAAAALAAAAAAQABAAAANFCBDc7iqIKUW98WkWpx1DAIphR41ouWya+YVpoBAaCKtMoRfsyue8WGC3YxBii5+RtiEWmASFdDVs6GRTKfCa7UK6AH8CACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+apptool16:app app16 16:photo:16 16:R0lGODlhEAAQAIMAAPwCBAQCBISChGRmZMTCxKSipLS2tHx6fPz+/OTm5FxaXOzu7DQyNMzOzAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAReEMhAq7wYBDECKVSGBcbRfcEYauSZXgFCrEEXgDCSeIEyzKSXZoBYVCoJVIqBGByKu0Cy8QHxmgNngWCkGgqsGWFseu6oMApoXHAWhWnKrv0UqeYDe0YO10/6fhJ+EQAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+apptools16:app app16 16:photo:16 16:R0lGODlhEAAQAIUAAPwCBExKTERCRAQCBOzu7Nze3MzKzLy+vCxqZBQ2NJyanKyqrGRiZDRydKza3FRWVPT29LSytDw6PMTm5EySjCxaXGRaJFSanCRSVGxqbPTmvMSqVJTW1GSurHS6vOzq7KSipISChFRKHJSGNPz23GxKFBQ6PKyurCwqLMyufJx2RAQGBJSWlEwyDIRiLNy+lLSKVDwmDJRuNOTOrLyabGRCFDx2dKSCVOzWtHzCxOTGnNSyhAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAahQIBwCAgIBAOiUiggFAyHASKxDAwUC8Zg0HAglA9IZPGQABoTSqJCFTIOEIsFgHBcEhhHUpKJFCwaGxYYHB0VEx4IEh8gIQwiIyQbJRMcHokmEicfDygAkCkqJQgIGG0rLElCLS4vMCWqQwMCQg0UMTIzNDVLQjaIGDE3ODQlS785CEkxKjowvEOHybG4O6JDCdNKuDUxRAmxRDHeveUAfkEAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+appuser16:app app16 16:photo:16 16:R0lGODlhEAAQAIMAAPwCBAQCBPz+/MTCxISChMT+/ATCxASChFxaXAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAARaEMg5gw00yyDGIAR1YUDggeFWFIZhnSBZrsZxdIOFEGTA2oeBAHeyuGwvzxBlYdUOLROMFzDQntJPrNoqAKUBaqnV+k57ZORruykHDj2LqIzUVKp1u0iuB/gjACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+appusers16:app app16 16:photo:16 16:R0lGODlhEAAQAIMAAPwCBAQCBMTCxISChAT+BMRaBPyqXARCBPz+/FxaXAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAARLEIRJa5Ui673nsGAgeKE1Bl9AUEXbiqTlFlZaGUZoszm4BzhDAVf5BYbAXI+TAR6CS2ZGSZSEiIIqYIsSIEaJ7GRrlY7J1lKA7I8AACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+appwp16:app app16 16:photo:16 16:R0lGODlhEAAQAIUAAPwCBKSinJyOfPz27Pzy7AwKDExOTJyWlERCRKSelPz69LyyrKymnPz+/MS2fDQyJAQCBOTazLSiXOzivMS2jKSSVOzmxPz25NzSpPTu5KyebOzixNTGjOTWpMSydMSybCwqFGReVKyaXNzSnGxeNJSCVMS2nPz23MSuZIR+bJyShLyqnOTOtGxiXIR6XOTSvIx6RMSubIyCdKSalMS6pOTWxMzKvKSabJyKTOzezHxuPGRmZKyurMTCvPTq3AAAACH5BAEAAAAALAAAAAAQABAAAAajQIBwCAgIiEhiYEA4FgwHRDKhIBAWz4OhgGQ0FAPHA7qFEBONb0Qy0ULeQ2+aUrFcMI+3GYBOZzQbHB0eHyAhIQByDREiEwMjFRIkJQImAgJ+jScjHigkKSorLC0AKg2NFSMoki4qCy+IQgITKDAxkjIzNDWkQxQoJaskMgk2Eb1DNzgoOCoHDDY5yEIwJToAOzw9ET7TQiREAhkZ3kmy5QB+QQAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+cal1day16:cal cal16 16:photo:16 16:R0lGODlhEAAQAIIAAAQCBPwCBAQC/AQCjPz+/MTCxKSipAAAACH5BAEAAAEALAAAAAAQABAAAANOCLrMEUDIOUS9AFLLhx8LIRZjKYZmMRCkaChFLHty/AIiS3y6q+QtT49wq8VotRtQJGwRf6Zmrlj7DJLQXsupTJmeEIN4TB5nII20wp8AACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+cal5days16:cal cal16 16:photo:16 16:R0lGODlhEAAQAIIAAAQCBPwCBAQC/AQCjPz+/MTCxKSipAAAACH5BAEAAAEALAAAAAAQABAAAANMCLrMEUDIOUS9AFLLhx8LIRZjKYbj55GioRRwoQ5x4QIiIdMmcec7jy53q81qP9OO5VMAj8RXTFWzOZW95HDLdEEM4LA4nIE0zgp/AgAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+cal7days16:cal cal16 16:photo:16 16:R0lGODlhEAAQAIIAAAQCBPwCBAQC/AQCjPz+/MTCxKSipAAAACH5BAEAAAEALAAAAAAQABAAAANPCLrMEUDIOUS9AFLLhx8LIRZjKYbj55GioRRwoQ5x4QIiwcp0fucsj873qvGMv5Jw2FIACUsW4WakGW1O046I05qmGYBhTC6TM5CGWuFPAAAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+calappointment16:cal cal16 16:photo:16 16:R0lGODlhEAAQAIMAAAQCBPwCBAQC/AQCjPz+/MTCxPz+BISCBISChKSipAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAEALAAAAAAQABAAAARbEMhJaQhA6D1E/wDGeeRgDhOhFoTBEi+REgdrIHScSEVvAD9Xr7cDqGSGpFEnQSqTv2NxCFQOiU1VEAiTZmstHFg1vQKuw+LxxfYaV/AuOQRI2O/4ewhT6Uv8EQAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+calbell16:cal cal16 16:photo:16 16:R0lGODlhDwAOAIIAAPwCBISCBPz+BIQCBMTCxISChPz+/AQCBCH5BAEAAAAALAAAAAAPAA4AAAM+CLrR+zCIAWsgLVRGRBhOVQiG94WPVAbHaZHYAWqRYLbge88RsbInGuBCEhRYrZYm4xk4nYdoKzKIbiKHawIAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+callist16:cal cal16 16:photo:16 16:R0lGODlhEAAQAIMAAAQCBPwCBAQC/AQCjPz+/KSipPzerMRaBEQCBAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAEALAAAAAAQABAAAARDEMhJaQhA6D1E/wDGeeRgDhOhruyatjBRSIRxxOsMEAdC0BUZDcfSEYvDo3Bn++2Cxt7RqFxWhZiCdsvdhjCVsMQfAQAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+calmonth16:cal cal16 16:photo:16 16:R0lGODlhEAAQAIIAAAQCBPwCBAQC/AQCjPz+/MTCxKSipAAAACH5BAEAAAEALAAAAAAQABAAAANSCLrMEUDIOUS9AFLLhx8LIRZjKYbiRxLFIBpK0Q6z7MkwkJIe8b0KEeuWchFysuStVsjtfMbeMQitWpG25YfmNK1WU53XNIUYzug0OgNpuBX+BAAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+caltoday16:cal cal16 16:photo:16 16:R0lGODlhEAAQAIMAAAQCBPwCBAQC/AQCjPz+/MTCxKSipPyCBMRaBPyqXAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAEALAAAAAAQABAAAARTEMhJaQhA6D1E/wDGeeRgDhOhFmurpi5LyIQhFfiBIAfuFzaAioBIJBCummRYPCaDPh3vhwsOZdihNfa8Ub/AJXemFZPPNBvGwG672yFMZS7xRwAAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+caltodo16:cal cal16 16:photo:16 16:R0lGODlhEAAQAIMAAAQCBAT+BAQC/AQCjPz+/MTCxPzCxKSipPwCBMQCBIQCBAAAAAAAAAAAAAAAAAAAACH5BAEAAAEALAAAAAAQABAAAARaEMhJaQhA6D1E/wDGeeRgDhOhFmurpi5LyMYhFXiuFwZiA6qZYbbqJX5BIw2RAPxwAAWCyWMCCsiXFGEEErKz6LQZfOqiTR1YJiGq1rFyyHmo2+/1EKbCl/gjACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+connecting16:connect connect16 16:photo:16 16:R0lGODlhEAAQAIMAAPwCBPz+BMTCBISCBAQCBPz+/MTCxMTGxISChFxaXMzGzKSipAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAARaEMhJZbihUiz60FPnfaA0iBpBVGdHEYWxToEoSHBRHHM9AgSEQRcj+AYkYAJxIPKQFUJiOdTJQFIDU6dYzKKFhTCM+E5g4mXaDAyrlogEG+DGTecA7wsP8EcAACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+connectno16:connect connect16 16:photo:16 16:R0lGODlhEAAQAIMAAPwCBPz+BMTCBAQCBERCBPz+/MTCxMTGxISChFxaXMzGzKSipAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAARPEMhJq704axBEHoPUEdhQGMNYFuwxkKInDYjBniEnwMCQIIebSzXx/WwsFK+YMABZikWuYlrUCtZpEYv4WRPaHhb064YB41kCfJFSQBh/BAAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+connectyes16:connect connect16 16:photo:16 16:R0lGODlhEAAQAIMAAPwCBAQCBPz+/KSipDQyNMTCxMTGxISChFxaXMzGzAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAARaEMhJZxCjgsAtDtUlCOA1gJQ4kl/IDatAoF7xxkS6GgEBr6jAobCyBX42SQBxMOx6A8MhiGASR8YDgrYsNEeJ0zaEGZY7uoH2oB6nOUwtbdLaVOeTUwo/8UcAACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+devcdmount16:dev dev16 16:photo:16 16:R0lGODlhEAAQAIUAAPwCBFxaXISChNTS1MzKzMTGxMy+vNSytAQCBOzq7OTi5Nza3Oy6vPy2tOTStPz6/Ozu7Nze3MTKxOS2tOzOvNTqvLT2tDw+BPTy9MzOzLS2tPy+tLz+tLz2tLSynLzqvLzavLTOtNTW1KSipPz+/LzKvMTCxDQyNASCBARCBDTSJIT+bAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAa0QIBQGBAYA8Ok0DggFAwHBEIJECQUi8GT0XBMh9YHJDKQTBqUiuUCVmAeiYzmsKlwOt/AAKFIFAIIFx4WHyAhUwIDIgsZFyMkFxchJSYmiBkSBBoIJJwIGgOhiCYFJSEnFyQjFwNZewABISAfFiYnCAEmCREIrwAIFhwVGwcaBAkPGApsQsAVFA0GBQMRbxBTKM0ODQwTEq192ClDgROkBHvYKuNJUu5CKCorX1RDKCkpUn5BACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+devcdunmount16:dev dev16 16:photo:16 16:R0lGODlhEAAQAIUAAPwCBFxaXISChNTS1MzKzMTGxMy+vNSytAQCBOzq7OTi5Nza3Oy6vPy2tOTStPz6/Ozu7Nze3MTKxOS2tNzmvLT2tDw+BPTy9MzOzLS2tPy+tLz+tLz2tLSynLzqvLzavLTOtNTW1KSipPz+/MTCxLy6vDQyNOTm5AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAapQIBQGBAYA8Ok0DggFAwHBEIJECQUi8GT0XBMh9YHJDKQTLqUigWsuDwSmMxBQ9lwvoEBQpEoBBAWHRseHyBTAgMhCxgWIiMWFiASJCSHEgQSGQgjmwglGKCHBQUSICYWIyIWAwshIVMBIB8eFSQmCAEFCREIekIIFRsUGgcZEgkPFydrvxUUDg0GBSEREGJfv9AMEySsJxDYQ4DcEhh64UpS6lTs7QB+QQAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+devdiskmount16:dev dev16 16:photo:16 16:R0lGODlhEAAQAIUAAPwCBAQCBDQyNIRuVKyCXMSKROzSrOzKpOTGnLSafLySZKxuLMSOVPTWvPzixLSehNyibOzOrGxaVJx+XOzGnFw2FJRuPKx+TPTSrHRWPKyKZPTOpHxOJKyKXFw+HKSipISChMTCxFxaXIRiPNSWXExOTOS2hLR+PLRyLPTWtMyOTASCBARCBPz+/DTSJIyKjIT+bAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAaTQIBwCAgYA8SkMCAYDARI5ZJQMBwQiWgyoFgwrA3HQ7scQAqFAcEQOUi0zAkFUSFYLghMBloUCDQNGxwdHhwHekcfICEhICIfIxkLJBABJUYCICABIhAOBiYnKJaXmH4CGSkYCCqkSAEfTKenrkOwsrQll0IrS7G5uwArLLaxLbXCLsTFLyDBKy4wZEVHvCwsRn5BACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+devdiskunmount16:dev dev16 16:photo:16 16:R0lGODlhEAAQAIUAAPwCBAQCBDQyNIRuVKyCXMSKRPTWtOzKpOTGnLSafLySZKxuLMSOVOzOrPzm1LSehNyibGxaVJx+XOzGnFw2FJRuPKx+TPTSrHRWPKyKZPTWvHxOJKyKXFw+HPTOpKSipISChMTCxFxaXIRiPHxaNLRyLNSWXExOTPzixOS2hLR+PMyOTPz+/IyKjAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAaIQIBwCAgYA8SkMCAYDARI5ZJQMBwQiWgyoFgwGgiD46FdDiCFwoDQAEe0TMkEQSFULIcLBloUCDIaDRscHRsNHhhHHyAhISAiHyMkJSYQASdGAiAgASIQKA0pKguXmJl+AiQGFwgrpUgBH0yoqK9DsbO1J5hbsrq8SrgstlJFHy0gwMVFR1J+QQAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+devfloppymount16:dev dev16 16:photo:16 16:R0lGODlhEAAQAIQAAPwCBAQCBMTCxARmZPz+/FSWlLSytKSipERCRIyOjISChOTm5HRydNza3GRiZFRSVASCBARCBDTSJIT+bAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAVrICCOQBCQKBkIw5mqLFG47zoQ+FwbN57TosDhgPD5dMEEIqE04kwlBWKBUEiNVYFpyqAyGEUCgqEtERiNNMLhQKzLQYJg7n7Y4aMAwbCUPvAQeWNgfzQQETAIhSMQEogwgBITQEGGEREmfiEAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+devfloppyunmount16:dev dev16 16:photo:16 16:R0lGODlhEAAQAIMAAPwCBAQCBMTCxARmZPz+/FSWlLSytKSipERCRIyOjISChOTm5HRydNza3GRiZFRSVCH5BAEAAAAALAAAAAAQABAAAARcEMgJQqCYBjFu1hxReN82EOhYGieaklJwHIjrqnGCJLqNWhUFYoFQCG1FgWXIIDIYNQKCoawQGI0swuFAbKsxgmDsfZjBkwDBsNM90Jot9A3DbBD0Dwiur9QnfhEAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+devnetwork16:dev dev16 16:photo:16 16:R0lGODlhEAAQAIQAAPwCBAQCBISChPz+/Nza3ARaZESanCyKlARudARGTLy+vNzq7ARmbMTCxARufAROVMzOzKSipARyfOzq7AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAVmICAGZFmKQiACweCSBImq41AYB5IodLq2hwWO0ejRWDac48Gb/QKNqNRoqspmrVcAUuIJBANS8sBIFCORUgooPEh4J8B67NgdsVBp9C5XWfl9LRMTCyReX19hARNojWlWLH+AAH4hACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+devpc16:dev dev16 16:photo:16 16:R0lGODlhEAAQAIMAAPwCBISChHx+fPz+/AQCBAQC/AT+/AQCxAQChAT+BLy+vAR+BAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAARYEIAgqK1YzsG754QUDERpmkEpkkXrtoK6EcVgHIibhnNx564Yb0TDvQq7FQ34EiqPOhnREqhWSUPsyZSQAbbg7GcMEgwUiYVivTa1R+y4XEGoWO/4AMAfAQAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+devscanner16:dev dev16 16:photo:16 16:R0lGODlhEAAQAIMAAPwCBAQCBPz+/MT+/ASChARCRATCxMTCxFxaXKSipDQyNAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAARTEMgJgqWBVivEldkUdKSXhVjZfenommglDERh3Tc4E4ZRHAGgkEPr9X6H5AHBERSMRyWzkug8jQXFEhWoOo8dRYxqLXSmGjIJnVaz29Q3fAP3RwAAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+devscreen16:dev dev16 16:photo:16 16:R0lGODlhEAAQAIUAAPwCBFxaXFRSVPz+/PT29OTm5OTi5DQyNDw+PERGRExKTHx+fISChIyKjHRydFxeXDQ2NCQmJBQSFAQCBERCRMTGxHR2dGRiZExOTDw6PCQiJAwODCwuLFRWVOzu7BweHAwKDCwqLHx6fBQWFGxqbGRmZAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAanQIBwSCwKAwKkMslEAgSDqDRKqBYKhkNgcDggEorkMrDQchkNhuOhgEQkk0l5S2lUGpYLJqPZTAwMHB0DCmhqAW0Rfh5zAxgOkBcCFAcfIBMECxwBBAEPFw8dChkhcBMDDAcdnQqtFKSWcQMimx4dGRkQBxGxsg6bBQEawx8jl3GnJFoFHRNXVVNRJYIFDAsL1tgiDiQXFx0HABwcXeQH5OjkRutEfkEAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+devspeaker16:dev dev16 16:photo:16 16:R0lGODlhEAAQAIMAAPwCBFxaXAT+/DQyNATCxMTCxPz+/AQCBKSipASChAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAARWEMgJQqCXziDG2JoUEENhZBkmHIWJVptAmqcIW/Js1MiF56TBzkckAAcHoa9nMRKeA4TyJk0knsHhTeK5khBaH2VwLYVh40TJhQ6RzeIQV32Quz8hfwQAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+editcopy16:edit edit16 16:photo:16 16:R0lGODlhEAAQAIUAAFxaXPwCBNze3GxubERCRPz+/Pz29Pzy5OTe3LS2tAQCBPTq3PTizLyulKyqrOzexLymhLy+vPTy9OzWvLyifMTCxHRydOzSrLyihPz6/OTKpLyabOzu7OTm5MS2nMSqjKSipDQyNJyenLSytOTi5NTS1JyanNTW1JSWlLy6vKyurAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAEALAAAAAAQABAAAAaUQIBwCAgYj0eAYLkcEJBIZWFaGBie0ICUOnBiowKq4YBIKIbJcGG8YDQUDoHTKGU/HhBFpHrVIiQHbQ8TFAoVBRZeSoEIgxcYhhkSAmZKghcXGht6EhwdDmcRHh4NHxgbmwkcCwIgZwqwsbAhCR0CCiIKWQAOCQkjJAolJrpQShK2wicoxVEJKSMqDiAizLuysiF+QQAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+editcut16:edit edit16 16:photo:16 16:R0lGODlhEAAQAIEAAPwCBAQCBPz+/ISChCH5BAEAAAAALAAAAAAQABAAAAIwhI9pwaHrGFRBNDdPlYB3bWHQ1YXPtYln+iCpmqCDp6El7Ylsp6ssR1uYSKuW0V8AACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+editdelete16:edit edit16 16:photo:16 16:R0lGODlhEAAQAIUAAPwCBFxaXNze3Ly2rJyanPz+/Ozq7GxqbPT29GxubMzOzDQyNIyKjHRydERCROTi3IyKhPz29Ox6bPzCxPzy7PTm3NS6rIQCBMxCNPTq3PTi1PTezMyynPTm1PTaxOzWvMyulOzGrMymhPTq5OzOtNTKxNTOzNTCtNS+rMSehAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAaKQAAgQCwahcihYMkcBAiBpLJApRoOBWgyIKhSEQkFgrBAcr1URiPhKAsDD3QB8RhA3FM0IlLHnyUTVBMSFBUWfl0XGBMTGBcZGodmcQWKjpAbHIgIBY2LHRoempOdjooTGx8giIOPFYofISJ+DyMXI6AfFySyfiUmJSUnKBYcICIpfgELzM3OZX5BACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+edit16:edit edit16 16:photo:16 16:R0lGODlhEAAQAIYAAPwCBFxaVMR+RPzKjNze3AQCBMR6RPzGjPyODPz+/MzOzPyKDPyKBPz29OTWzPyGDPyGBOx6BOza1OR2BKROBNSOXKRKBBwOBOzu7PTWxPzizOySZPyCDFxaXOy2lNRyRMxmJCQOBPTm1OzStPTKrMR+XIRWLFxGNCQSBDQyNIRSNDQuJERGRLyqlNzSvIx6ZKRuVEw6LLSyrLymhKSShBwaFFROTJyWjMS+vNzW1OTazNzKrHRqXOzezOTOpPTq3OzWvOTStLyedMS+rLy2pMSynMSulAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAewgAAAAYSFhoQCA4IBBI2OjgUGBwiLBAmXlpcKkgsMlZcJBA0JDpIPEBGVjwkSBgOnExSfmBIVBxAMExYXswkYGRobHLq8gh2PHhoeHyAWIYKzIiMkJSYnKCnQg5YNHtQqKywtK9qMBC4vMDEBMjIz2dCMDTQ1Njc4OToz5PEEOzw3ZPToMcLHO23HfogQ0QMIkCA+hPBbhAPHECJFjMyYIUQIvEUpUqwQOXKkSEF+AgEAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+editpaste16:edit edit16 16:photo:16 16:R0lGODlhEAAQAIUAAPwCBCQiFHRqNIx+LFxSBDw6PKSaRPz+/NTOjKyiZDw+POTe3AQCBIR2HPT23Ly2dIR2FMTCxLS2tCQmJKSipExGLHx+fHR2dJyenJyanJSSlERCRGRmZNTW1ERGRNze3GxubBweHMzOzJSWlIyOjHRydPz29MzKzIyKjPTq3Ly2rLy+vISGhPzy5LymhISChPTizOzWvKyurPTexOzSrDQyNHx6fCwuLGxqbOzKpMSabAQGBMS2nLyulMSidAAAACH5BAEAAAAALAAAAAAQABAAAAa7QIBQGBAMCMMkoMAsGA6IBKFZECoWDEbDgXgYIIRIRDJZMigUMKHCrlgul7KCgcloNJu8fsMpFzoZgRoeHx0fHwsgGyEACiIjIxokhAeVByUmG0snkpIbC5YHF4obBREkJCgon5YmKQsqDAUrqiwsrAcmLSkpLrISLC/CrCYOKTAxvgUywhYvGx+6xzM0vjUSNhdvn7zIMdUMNxw4IByKH8fINDk6DABZWTsbYzw9Li4+7UoAHvD+4X6CAAAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+editshred16:edit edit16 16:photo:16 16:R0lGODlhEAAQAIUAAPwCBFxaXNze3Ly2rJyanPz+/Ozq7GxqbGxubMzOzPz69DQyNIyKjERCRPz29PT29OTi3IyKhPz27PTu5PTy5Pz6/Pzy7PTq3OzexLyqlPTm1PTizOzavLyqjOzWvOzaxLyifOzizOTOpAQCBOzezAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAaEQAAgQCwahcihYMkcBAiBpLJApRoOBWgyIKhWEQkFYYHkeqkMxKFBFpq9jgdkEGlPqwrJhCIY2N8FFRYUFxcYGX9dgRKEGhiHiYEOhBcbGBwdiQEOARcBGwEeAZllAgEUnQEfoQEgmp4hrCKtrwEYsrRlTiMBJAG8syN/IyMAxMXHSH5BACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+edittrash16:edit edit16 16:photo:16 16:R0lGODlhEAAQAIIAAPwCBAQCBKSipFxaXPz+/MTCxISChDQyNCH5BAEAAAAALAAAAAAQABAAAANQCKrRsZA5EYZ7K5BdugkdlQVCsRHdoGLMRwqw8UWvIKvGwTICQdmGgY7W+92GEJKPdNwBlMYgMlNkSp3QgOxKXAKFWE0UHHlObI3yyFH2JwAAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+fileclose16:file file16 16:photo:16 16:R0lGODlhEAAQAIQAAPwCBCQiJBwaHAQCBDQyNDw6PFxaXFRSVERGRCwqLAwODGRiZHx6fPz+/GxqbAwKDCQmJAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAVaICCOZGmeqBgEwjCkRGEcSKK4JrEcBrMgAdeLVDg0GguGsYEbBQyGYyN6FDoPDIf0+LCKBIgetQERDgGDBGIpNY8GioAU0m6KXFw883w3+/l9f4AkfimGIn4hACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+filedocument16:file file16 16:photo:16 16:R0lGODlhEAAQAIUAAPwCBFxaXNze3Ly2rJSWjPz+/Ozq7GxqbJyanPT29HRydMzOzDQyNIyKjERCROTi3Pz69PTy7Pzy7PTu5Ozm3LyqlJyWlJSSjJSOhOzi1LyulPz27PTq3PTm1OzezLyqjIyKhJSKfOzaxPz29OzizLyidIyGdIyCdOTOpLymhOzavOTStMTCtMS+rMS6pMSynMSulLyedAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAaQQIAQECgajcNkQMBkDgKEQFK4LFgLhkMBIVUKroWEYlEgMLxbBKLQUBwc52HgAQ4LBo049atWQyIPA3pEdFcQEhMUFYNVagQWFxgZGoxfYRsTHB0eH5UJCJAYICEinUoPIxIcHCQkIiIllQYEGCEhJicoKYwPmiQeKisrKLFKLCwtLi8wHyUlMYwM0tPUDH5BACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+filefind16:file file16 16:photo:16 16:R0lGODlhEAAQAIYAAPwCBCQmJDw+PBQSFAQCBMza3NTm5MTW1HyChOT29Ozq7MTq7Kze5Kzm7Oz6/NTy9Iza5GzGzKzS1Nzy9Nz29Kzq9HTGzHTK1Lza3AwKDLzu9JTi7HTW5GTCzITO1Mzq7Hza5FTK1ESyvHzKzKzW3DQyNDyqtDw6PIzW5HzGzAT+/Dw+RKyurNTOzMTGxMS+tJSGdATCxHRydLSqpLymnLSijBweHERCRNze3Pz69PTy9Oze1OTSxOTGrMSqlLy+vPTu5OzSvMymjNTGvNS+tMy2pMyunMSefAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAe4gACCAAECA4OIiAIEBQYHBAKJgwIICQoLDA0IkZIECQ4PCxARCwSSAxITFA8VEBYXGBmJAQYLGhUbHB0eH7KIGRIMEBAgISIjJKaIJQQLFxERIialkieUGigpKRoIBCqJKyyLBwvJAioEyoICLS4v6QQwMQQyLuqLli8zNDU2BCf1lN3AkUPHDh49fAQAAEnGD1MCCALZEaSHkIUMBQS8wWMIkSJGhBzBmFEGgRsBUqpMiSgdAD+BAAAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+filenew16:file file16 16:photo:16 16:R0lGODlhEAAQAIUAAPwCBFxaXNze3Ly2rJyanPz+/Ozq7GxqbPz6/GxubNTKxDQyNIyKhHRydERCROTi3PT29Pz29Pzy7PTq3My2pPzu5PTi1NS+rPTq5PTezMyynPTm1Pz69OzWvMyqjPTu5PTm3OzOtOzGrMSehNTCtNS+tAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAZ/QAAgQCwWhUhhQMBkDgKEQFIpKFgLhgMiOl1eC4iEYrtIer+MxsFRRgYe3wLkMWC0qXE5/T6sfiMSExR8Z1YRFRMWF4RwYIcYFhkahH6AGBuRk2YCCBwSFZgdHR6UgB8gkR0hpJsSGCAZoiEiI4QKtyQlFBQeHrVmC8HCw21+QQAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+fileopen16:file file16 16:photo:16 16:R0lGODlhEAAQAIUAAPwCBAQCBOSmZPzSnPzChPzGhPyuZEwyHExOTFROTFxaVFRSTMSGTPT29Ozu7Nze3NTS1MzKzMTGxLy6vLS2tLSytDQyNOTm5OTi5Ly+vKyqrKSmpIyOjLR+RNTW1MzOzJyenGxqZBweHKSinJSWlExKTMTCxKyurGxubBQSFAwKDJyanERCRERGRAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAaRQIBwGCgGhkhkEWA8HpNPojFJFU6ryitTiw0IBgRBkxsYFAiGtDodDZwPCERCEV8sEk0CI9FoOB4BEBESExQVFgEEBw8PFxcYEBIZGhscCEwdCxAPGA8eHxkUGyAhIkwHEREQqxEZExUjJCVWCBAZJhEmGRUnoygpQioZGxsnxsQrHByzQiJxz3EsLSwWpkJ+QQAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+fileprint16:file file16 16:photo:16 16:R0lGODlhEAAQAIUAAPwCBFRKNAQCBPz+/MTCxExKLPTq5Pz29Pz6/OzezPT29PTu7PTy7NzClOzm1PTu5LSabJyanPTm3FxaXOzCjOTKrOzi1OzaxOTSvJyenGRmZLyyTKSipDQyNERCROTi5Hx+fMzKzJSSlIyOjISChLS2tAT+BDw6PAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAaYQIBwKAwIBMTkMDAYEApIpVBgOCAOg4RRGlAoEAuGIdGITgWOq4LxcCQgZkEkIHksHgYJOR6ZQCgVFhYJFxgTBVMZihoCfxUYDWUbUBGKGREcjBoQEB2TAB4CAx+Vl5WMhyACHiEhH6IfIiMktCQgE0cZJQStr6O2t6EARxO6vK6iEx4dZsMCxbsmBB4nzUTEutVSSUdmfkEAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+filesave16:file file16 16:photo:16 16:R0lGODlhEAAQAIUAAPwCBAQCBFRSVMTCxKyurPz+/JSWlFRWVJyenKSipJSSlOzu7ISChISGhIyOjHR2dJyanIyKjHx6fMzOzGRiZAQGBFxeXGRmZHRydGxqbAwODOTm5ExOTERGRExKTHx+fGxubNza3Dw+PDQ2NAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAaAQIAQECgOj0jBgFAoBpBHpaFAbRqRh0F1a30ClAhuNZHwZhViqgFhJizSjIZXQCAoHOKHYw5xRBiAElQTFAoVQgINFBYXGBkZFxYHGRqIDBQbmRwdHgKeH2YgHpmkIR0HAhFeTqSZIhwCFIdIrBsjAgcPXlBERZ4Gu7xCRZVDfkEAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+folder16:folder folder16 16:photo:16 16:R0lGODlhEAAQAIYAAPwCBAQCBExKTBwWHMzKzOzq7ERCRExGTCwqLARqnAQ+ZHR2dKyqrNTOzHx2fCQiJMTi9NTu9HzC3AxmnAQ+XPTm7Dy67DymzITC3IzG5AxypHRydKymrMzOzOzu7BweHByy9AyGtFyy1IzG3NTu/ARupFRSVByazBR6rAyGvFyuzJTK3MTm9BR+tAxWhHS61MTi7Pz+/IymvCxulBRelAx2rHS63Pz6/PTy9PTu9Nza3ISitBRupFSixNTS1CxqnDQyNMzGzOTi5MTCxMTGxGxubGxqbLy2vLSutGRiZLy6vLSytKyurDQuNFxaXKSipDw6PAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAfDgACCAAECg4eIAAMEBQYHCImDBgkKCwwNBQIBBw4Bhw8QERITFJYEFQUFnoIPFhcYoRkaFBscHR4Ggh8gIRciEiMQJBkltCa6JyUoKSkXKhIrLCQYuQAPLS4TEyUhKb0qLzDVAjEFMjMuNBMoNcw21QY3ODkFOjs82RM1PfDzFRU3fOggcM7Fj2pAgggRokOHDx9DhhAZUqQaISBGhjwMEvEIkiIHEgUAkgSJkiNLmFSMJChAEydPGBSBwvJQgAc0/QQCACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+folderhtml16:folder folder16 16:photo:16 16:R0lGODlhEAAQAIYAAPwCBAQCBERGRBQWFMzKzOzq7CwqLDw6NARqnAQ+XHR2dKyqrOTm5ExKTERCRHRydMTi7NTu9HS+1KSmpBweHDy67DyixHS61ITG3AxypByu7DxinBw+ZERmdIySjITC3ARypExOTDRurIR2RPTSdJyulEyGvBw+bFSyzJTK3LzKvPzivOTixNTChLSybGyCfCRSnBQqRASGtFyuzDw+PCRShPzy5OzerOTShKyaTEx6pCxerGRufBR+rOTezPTShNy6bER+1BxCfBQuRAxelFSixBw2VISq3GySrPTWlHyanIyitFSO3IymtCRujAxWhCRqlCQ6XGyWvNS2bFyGvDxuvCRSpLy+vMS+vGxqbFyO1GSi3EyO1FRaVCQuPLS2tDxyzKyWNFxaNCQyPGxubCxajERSVExKNJyenAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAfZgACCAAECg4eIAAMEBQICBomDBwgJCgsEDA0BDg8BhwYQERKUDxOYDAyeghQVFhehGBmVlwwOqxobHB0eH6EfIAkPIYIiIyQlJhsnKBcpvrYiKissLS4vMDEyFjOvNAA1LDY3ODk6Oyc8PTIyFzQ1Jj42P0A6QTtCQ0REIEUORkdIkihZwsSekBhNnDyBciCKiSNSplDRUcWKkRhXCGDJYgiGli1cpuTocsILjytfFmRpACAGRTBhRogZgzHlAjKGWnIoY+bMgRgBDHRBo/LAIZoxuhwKatRPIAAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+folderlocked16:folder folder16 16:photo:16 16:R0lGODlhEAAQAIYAAPwCBAQCBExKTBQSFMzKzOTm5CwuLERCRARqnAQ+XHR2dKSmpOzm5GxqbCQiJMTi7NTu9HS+1HRydOTm1Ozq7Dy67DyixHS61ITC3AxypERGRBweHByu7ASGtFyy1DSOtDRmfExOTBSazBR+rCwqLAxWhAxelByGtDSaxAwODHy+1Dw+PPT29IyqvCxujOzu7NTW1Nza3ExGJJyebKyqfMTCpFRSPOTi5DQqHOTezDw2NMTGxKyqhMTGrGxmXDQ2NMTCxMTGpHx6bHx2bBQWFIyOXDQuDAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAfDgACCAAECg4eIAAMEBQICBomDBwgJCgsEDAKFDQGHDg8QEZQSlxMUDJ2CDhUWF6AYGZWXFBqCGxwdFh4XGK8fIAohtiIIIx25EZwBDREHgiQjJSYmGScoKSoRKQ8rggIsDC0uJS4oGygoAyjdAAcsLxQUMDEyMzQ1EzapBy8MDDc36tFwgONFjlQ6dgCEEZBHDx8+ctRIRehHAyAwZASZIGRIEBoUBwUwIGMCiwFEaBQJichIjo9FZLBsacRIAB0A/AQCACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+foldernew16:folder folder16 16:photo:16 16:R0lGODlhEAAQAIUAAPwCBAQCBPz+hPz+BOSmZPzSnPzChFxaXMTCBPyuZPz+xPzGhEwyHExOTPz+/MSGTFROTPT29OTm5KyurDQyNNza3Ozq5Nze3LR+RLy+vJyenMzKzNTS1Ly6vJSWlFRSTMzOzMTGxLS2tKSmpGxubBQSFAwKDKSinJyanIyOjCQiJERCRERGRBweHAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAaNQIBwSCwaj8ikcokMCIqBaEDoBAQG1meAUDAQpIcBQoy1dg2JdBqhECgQ1IWB0WgcBIOBwIHXBwwPEBEREhIBbG4IExR/DBUVFhIXV2NjDVYYDY8SFU4ZVxpVAQwbGxynGxkdTh6XVh8gGSGzGSITIxokJUImGSMTwLcnKCkprgAqDSt1zCssKxQtQ35BACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+folderopen16:folder folder16 16:photo:16 16:R0lGODlhEAAQAIYAAPwCBAQCBExKTBQWFOzi1Ozq7ERCRCwqLPz+/PT29Ozu7OTm5FRSVHRydIR+fISCfMTCvAQ6XARqnJSKfIx6XPz6/MzKxJTa9Mzq9JzO5PTy7OzizJSOhIyCdOTi5Dy65FTC7HS2zMzm7OTSvNTCnIRyVNza3Dw+PASq5BSGrFyqzMyyjMzOzAR+zBRejBxqnBx+rHRmTPTy9IyqvDRylFxaXNze3DRujAQ2VLSyrDQ2NNTW1NTS1AQ6VJyenGxqbMTGxLy6vGRiZKyurKyqrKSmpDw6PDw6NAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAfCgACCAAECg4eIAAMEBQYCB4mHAQgJCgsLDAEGDQGIkw4PBQkJBYwQnRESEREIoRMUE6IVChYGERcYGaoRGhsbHBQdHgu2HyAhGSK6qxsjJCUmJwARKCkpKsjKqislLNIRLS4vLykw2MkRMRAGhDIJMzTiLzDXETUQ0gAGCgU2HjM35N3AkYMdAB0EbCjcwcPCDBguevjIR0jHDwgWLACBECRIBB8GJekQMiRIjhxEIlBMFOBADR9FIhiJ5OnAEQB+AgEAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+mailforward16:mail mail16 16:photo:16 16:R0lGODlhEAAQAIYAAIx+fIRydHxubHxmZGxiXHRmZFxOTFxGPFxKTPwCBLymlMy+pOze3PTq3PTu5Pzy7LSmnOTaxOzm5LyqlNzOtPz69Pz27MzCtLyqrPT27IRubPzuzNTGvNTCxLSelPz25Bw+ZFxKPPzy1Pz65LyupBxKdCxWfPTm1Pz23LyinBxGbGzO5DRafBxWfBxajCymxHTS5BxSdBxKbFTK3EzG1CSGvCyKvCSSxCSavGTO5GRaVPzqzFzK5EzG3BSCtAwiPGxaVPTivPzy3NzKpBxObCRefBxqlPTmzJR2bKyahAwyRPzmvOTOpKyObNS+nPz21AQOFKyOfPzuxAQCBGRORLSadPzyzLymjMy2lOzetDwuJFRCPEw6NEQ6LEQyLEQ6NAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAkALAAAAAAQABAAAAfhgAABAgIDBAQFBgcIBwmOCQIKCwwNDg8OEBESjY8CDBMUFRYVFxgZDJyOGhsPChwVHR4fFSAhjwkaIiMOJBQQDRUVJSa3GicoHw4pEA8SGSorLI8tLtQu19gqLzDECTEyMzQ14zY1Njc3ODkqCTo7MjIxNCs5PD03PjctPwlAQUIihhBpQbCIihtG+CUocASFkAhIkogQ8kFJwkcFlogIkoRJEydPnkBR6GiAxiQLgiiIIkXElFQJqESoMsRKkAhXqkhhApNKFSxZggTJ4nHIEJhaDhzYwoVLFy1avHyB6ScQACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+mailget16:mail mail16 16:photo:16 16:R0lGODlhEAAQAIUAAPwCBAxKdBRSfCyGvFSm1BxKfCSWzCyWzBRCXCRKfBwuRAQGDDw6PHy23Cym1CSSxByCxBxunBQSFKyurMTCxExihNza3NTW1JSSlMzKzFxaXLS2tNze3KSipCQmJGxmbNTS1KSepLy2vISGhJSWlHx+fERGRPz6/IyKjDw+POzq7JyenMzOzKSmpCwuLDQyNIyOjAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAaeQIBwGBAIAsOkUjAgFJRQQMHgjC4PBIEVgAh4D4aEYrGAMhINxwPyiCgYSsmEUmk82grLRZJkYCgXaAEKFxYZcEISGhsZFxwFeY0WHR5CDB8dGCAXG5shGxQicBIMpSMUGxgTGSQlpQwSJicnEwwdI7gdKAwTsykpKiobr8QMKxeHDBcsGRvOzxsT0i0uL9HSHdkT2ZkoMJXF4a8AfkEAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+mail16:mail mail16 16:photo:16 16:R0lGODlhEAAQAIUAAPwCBGxaVOTe1Oze3OTWxOTWvNzStNzKpEQ6LOTezPz+/Pzy7Pz69Pz27Pz25Pz21PzuzPzuxEQyLLyinLSmnPz67Pz23LSafKyObDwuJMzCtLSelPzy1My6nLymjNTCxLyqnPzq1LyihKyOfOzavOzetEQ6NPTq3NzOtLymnNTGxJR2bOTOpPTivNTGvLymlKSShKyahEw+NOTe3PTm1Pzu1Pzy3FRCPPz65LSadFxGPOzm3PzqzPTmzPzmvEw6NCH5BAEAAAAALAAAAAAQABAAAAaqQIBwSCwaj8ikMhloOp/QpmAgqAoIhELBUDgcEIGEYrFgNBoLx+IBiRwkgQnFoWAwKhWLhX3BZAILGhsCDXgODhwdGB5vgAofICBlDiEiIx4kJSYBJ2UoEykqHSMrLC0nLWAnFS4UCycvMAcEMR0RLTIBMwaSahw0NTYtFwclNwEdLws4eoc2DxwQOR06ASk7PBAhIRE9Pj0tLSUY1T8I5gjn6Qgy7D8SfkEAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+mailreplyall16:mail mail16 16:photo:16 16:R0lGODlhEAAQAIYAAIx+fIRubHxubHxqbHxmZGxeXHRmZGROTFRCPFxKTFxGPPwCBLymlMy6pOTa1PTq3PTu5Pz27Dw+POzi3PTm1OTWvPz25FRSVERCRLympPzuzPTu7NTGvFxaXKSmpPzu1Pz65Hx6fHxqZPzq1Pz23HR2dBw+ZHx+fISChJSWlDQmJHRydCxWfBxGbJyenExKTHRiXPzqzPzy3CQmJDRafGTO5ExOTERKTGxWVCRSfHTS5CymxBxajBxWfPTmvPzy1CyixCSaxCySxDSaxDSWxDSSvDyaxGS21PTmzPz21AwiPBRejCSavByGtCSezEzG3FzK5FzG3GzO5FTK3CQ2bPTixBxqlCRefBxSdBxSfBx2nCQ+dHxmXPzmvLSafAwmRAwyRPzyzDw6POzavNzKpAQOFPzuxBwWTBw2ZGRORLyWdMy2lOzetPTivAQCBKyObOTOpAweNBwWVEQyLEw2LEQ2LDwuJAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAsALAAAAAAQABAAAAf4gAABAgMEBQUGBwgJCguOCwEMDQ4PEBESDA4TjY8DFAwVERYXGBkRm4+QGhsMHB0eGB8bDpyOARogEBceIRgXv8COIiMkGB4lJSYnIcwoKb/DGyoXKywtKS4pHinMLzAxJDIzNDUtNjcv6B0hLzgfMh85OjstPDw99zwd7T4/LTVAgggZQqSIECNHevSAgSSJkiVMmjh5AiWKlClAiFARUeVHFSVWmLS40gNLlh5agGzh0kWDlwZfrIDREKaCAjEqrFA5MMYLmTAxlJTxYoZMozNozqRRs4ZNmy5s3LwhA0dBnDNn5MxBoAABnTp17IitowDrmQV+AgEAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+mailreply16:mail mail16 16:photo:16 16:R0lGODlhEAAQAIYAAIx+fIRubHxubHxqbHxmZGxeXHRmZGROTEw+NFxKTFxGPPwCBLymnMy6pOTa1PTm1Pzy7LymlOzi3HxqZOTWvPz69Pz25My+tLympFRGRHxuZPzu1LymjNTGvNTCxBw+ZPz23PzuzPz65PTu5NzOtCxWfBxKbPzq1DRafGTO5BxGbPzy9HTS5CymxBxajHRiXPzqzCyixCSaxCySxDSaxDSSvGS21GxWVAwmRBRejCSavByGtCSezEzG3FzK5FzG3CQ2bPzuxAwiPBxqlBxKdCRefBxWfBxSdBxSfBx2nCQ+dPzy1CRqlAwyRDQmJPTmvPTixLSafOTOpAQOFPz21BwWTBw2ZPzmvNS6nPTivAQCBAweNBwWVNzKpPzyzLyihGRORLyWdMy2lOzetKyObEQyLEw6NEw2LDwuJEQ2LAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAsALAAAAAAQABAAAAfqgAABAgMEBQUGBwgJCguOCwEMDQ4PEJYRDhKNjxMPDBQVFhAXGBUSGY8LGhsQHB0VHh8gFQ6bjgEhIiMMJCUmFbS2CwMnG6IoKSorI7WpEycWFiUsLSou1yXXji8wFiopMTIzNDUz4zbZNxsbODk6Ozw9Pj8pPzEzQDdB60JDOkRFjBw5giRJDCWdlmxwIIRJExAWKDRyMgTIiydLoESRImQKlSUSF1SxUoXAlSBRsGSJoCVICIlbqlThcoBClC5eYFD4EiVIFwUyqywAE0ZMlqNjpJDpIkUBl0dlFChAYOZMmTJoyqQR5icQACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+mailsend16:mail mail16 16:photo:16 16:R0lGODlhEAAQAIYAAIx+fIRubHxubHxqbHxmZGxeXHRmZGROTFRCPFxKTFxGPPwCBHxqZLyqlMy6pOze3PTq3PTu5Pz27Pzy7LyinOTaxOzi3Ozq3LymlOTOtPz69Pzy5My+tLympPzqzNTGvLSelPzy3BxGbBQ6VPzuzPz65LyupNzOtPz+/GzO5BRejPzq1Pz23LymjHTS5CyixCSavBxqlPz25LymnGTO5CymxCSaxByGtHRiXPzy1CySxCSezGxWVPzuxKyOhMy6nDSaxEzG3PTivNzKpKyOfPzu1FzK5PTmzJR2ZLyihLSWfKyObOzmzPzmvDyaxOzavLSafGRORMy2lOzetDwuJEw6NEw2LEQyLAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAsALAAAAAAQABAAAAfUgAABAgMEBQUGBwgJCguOCwwNDg8QERITFBUWjY8DFxgZGhsaHB0aD5yODB4TGB+kICEaIiOPCwEkJRcmJyYPKCIpKrWqKywTmC0SIi4vMDHEDCsyMg8zEyI0NTY3z7U4Hhs5Mx+0IyI6OyPrIzw9Gys+PxIy2EBBxAs8Qjk5Q0RFWFxAZySfgSMsilRAkiRECHQ08hHgJ0TJkCU/mECU2ISEkowUlpAQ4QTfowNPoAzJIeRJCyjm8kVRIkWIzSkXhwxJtYAKgp9VrFi5QoWKFZ5+AgEAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+nav1downarrow16:nav nav16 16:photo:16 16:R0lGODlhEAAQAIAAAPwCBAQCBCH5BAEAAAAALAAAAAAQABAAAAIYhI+py+0PUZi0zmTtypflV0VdRJbm6fgFACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+nav1leftarrow16:nav nav16 16:photo:16 16:R0lGODlhEAAQAIAAAP///wAAACH5BAEAAAAALAAAAAAQABAAAAIdhI+pyxqdwoNGTmgvy9px/IEWBWRkKZ2oWrKu4hcAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+nav1rightarrow16:nav nav16 16:photo:16 16:R0lGODlhEAAQAIAAAPwCBAQCBCH5BAEAAAAALAAAAAAQABAAAAIdhI+pyxCtwoNHTmpvy3rxnnwQh1mUI52o6rCu6hcAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+nav1uparrow16:nav nav16 16:photo:16 16:R0lGODlhEAAQAIAAAPwCBAQCBCH5BAEAAAAALAAAAAAQABAAAAIYhI+py+0PWwhxzmetzFpxnnxfRJbmufgFACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+nav2downarrow16:nav nav16 16:photo:16 16:R0lGODlhEAAQAIAAAPwCBAQCBCH5BAEAAAAALAAAAAAQABAAAAIfhI+pq+EPXYpxUckoO3AjbF3dJwahllXe6AFgC8d+AQAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+nav2leftarrow16:nav nav16 16:photo:16 16:R0lGODlhEAAQAIAAAPwCBAQCBCH5BAEAAAAALAAAAAAQABAAAAImhI+pyxf5VohmSlsxmpjTzAHeN5ak6UHpqKRi2GpwvH3Q3eT64RcAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+nav2rightarrow16:nav nav16 16:photo:16 16:R0lGODlhEAAQAIAAAPwCBAQCBCH5BAEAAAAALAAAAAAQABAAAAImhI+pq5HOAjQyVnqfhHue7oAaKH5kiW0AmnLqaHomkj02g+e6XwAAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+nav2uparrow16:nav nav16 16:photo:16 16:R0lGODlhEAAQAIAAAPwCBAQCBCH5BAEAAAAALAAAAAAQABAAAAIghI+pyxfR0HsRzNnuXVqn3mVQZWFRyIDjp65Ga5Ly4hcAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+navback16:nav nav16 16:photo:16 16:R0lGODlhEAAQAIUAAPwCBBRSdBRObCQ2TBxObISevAQCBNzu/BRGZPz6/FzC3Pz+/HTS5ByyzJze7Mzq9ITC3AQWLAyWvBSavFyuxAwaLAwSHBRafBSOrDzW5AyixCS61ETW3CzG1AQeLAweLAxefBSStEze7CSWtCyatBSCnBRWfAwmPBRWdByixAQSHAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAZiQIBwSCwah4HjUTBQFgkFg3MoKBykU0QhoUAIAuAksbpgNByPxQMSGVsVDYlkIqdUiJYLJqORbDgcHRseRR8gISIaEyMkGCVYRBEmeyAnlgaQkSgpmU4RAZ1OKqFOpFNGfkEAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+navdown16:nav nav16 16:photo:16 16:R0lGODlhEAAQAIUAAPwCBBRObCRKZBxCXAwyTKTK3Ozy/NTm9GSivAQWHNzu/FzC3IzO5CySrAQOHAyuzETS3CSWtAyOtETa5Aw2VLze7ByWtBy61BSavAxWdBRCXAwqPAQCBDR+nKTe7FS+1Eze7ByixBRmjPz+/AyexAyixAQKFBRqjAQGDAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAZeQIBwSCwaj0hAYCkYEJLKguGASEADigWj4bgaHpBINykwSCYRa5HCFFQsF0xGo9lwhpSOwfORYC4gISJ3RAQdIyQYJSAlImNrh4uNJkl5CoKUUBQnjlB4KJ6hokN+QQAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+navforward16:nav nav16 16:photo:16 16:R0lGODlhEAAQAIUAAPwCBAwyTBRObAw2VDR+nCRKZOzy/KTe7Pz+/KTK3Nzu/Lze7FS+1AyexAyuzBSavAyOtBSmzOTy/BRqjNTm9IzO5ETS3ETa5By61AyixByixBRmjAQGDBxCXGSivCySrCSWtBTC3AQOHAQWHAxWdEze7AQKFBRCXAwqPAQCBAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAZjQIBwSCwahYGjUjBQGgWEpHNYMBCaT4G2UDggos+EwmBYMBpf6VBgYDgeEMgjIpmoAQVKxXLBPDIXGhscRB0eHyAgDSGBGyJFASMiIiMkJYImUwAnmJqbjp4AKCmhAKSlTn5BACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+navhome16:nav nav16 16:photo:16 16:R0lGODlhEAAQAIUAAPwCBDw6PBQWFCQiJAQCBFxeXMTCxJyanDwyLDQqLFRSVLSytJSSlISChCQmJERGRFRWVGxubKSmpJyenGRmZLy+vOzq7OTi5Ly6vGRiZPTy9Pz6/OTm5ExOTPT29BwaHNza3NS6tJRqRGQqBNy6pIyKjDwGBPTe1JSWlDQyNOTGrNRiBGwmBIRaLNymdLxWBHxGFNySXCwqLKyqrNR6LKxGBNTS1NTW1Jw+BEweDDQ2NAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAaoQIBwCAgIiEjAgAAoGA6I5DBBUBgWjIZDqnwYGgVIoTGQQgyRiGRCgZCR1nTFcsFkHm9hBp2paDYbHAsZHW9eERkYGh4eGx4ag3gfSgMTIBshIiMkGyAlCCZTEpciJyQjGxcoKUQBEhcbIiorLB4XEltDrhcaLS4vtbcJra8bMDHAGrcyrTMXHjA0NSypEsO6EzY3IzU4OdoTzK0BCAkDMgkIOjJlAH5BACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+navup16:nav nav16 16:photo:16 16:R0lGODlhEAAQAIUAAPwCBBRObAwSHBRSdISevBRWfAweLNzu/BSOrAQWLPz6/FzC3DzW5BxObHTS5ByyzAyixEze7BSStBRWdAyWvByixAQSHCQ2TAQCBBRGZJze7CS61BSavAxefMzq9ETW3CSWtAwmPPz+/CzG1ITC3FyuxBSCnAQeLAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAZfQIBwSCwaj8hhQJAkDggFQxMQIBwQhUSyqlgwsFpjg6BwPCARySSstC4eFAqEURlYhoMLBpPRUDYcHXt7RgUeFB8gIU0BIoiKjAcUIwiLSQUkJRsmGIwJJwmEU6OkfkEAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+playeject16:play play16 16:photo:16 16:R0lGODlhEAAQAIAAAPwCBAQCBCH5BAEAAAAALAAAAAAQABAAAAIbhI+py+0R3IFQUtruXVqn3kkWyIARR4rqKvoFACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+playend16:play play16 16:photo:16 16:R0lGODlhEAAQAIAAAPwCBAQCBCH5BAEAAAAALAAAAAAQABAAAAIjhI+py8Eb3ENRggrxjRnrVIWcIoYd91FaenysMU6wTNeLXwAAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+playpause16:play play16 16:photo:16 16:R0lGODlhEAAQAIAAAPwCBAQCBCH5BAEAAAAALAAAAAAQABAAAAIfhI+py+1vgoxzyUCxrZd18ClfmIyVyJ1lqkHuC0N+AQAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+playstart16:play play16 16:photo:16 16:R0lGODlhEAAQAIAAAPwCBAQCBCH5BAEAAAAALAAAAAAQABAAAAIjhI+pyxudwlNyguqkqRZh3h0gl43hpoElqlHt9UKw7NG27BcAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+playstop16:play play16 16:photo:16 16:R0lGODlhEAAQAIAAAPwCBAQCBCH5BAEAAAAALAAAAAAQABAAAAIahI+py+1vgpySUWpvXXqrHmSaeJEYhKYq6hcAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+textblock16:text text16 16:photo:16 16:R0lGODlhEAAQAIAAAPwCBAQCBCH5BAEAAAAALAAAAAAQABAAAAIahI+py40Bo5SOzRvrwlgrfnkJOIkPaaaJXwAAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+textbold16:text text16 16:photo:16 16:R0lGODlhEAAQAIAAAPwCBAQCBCH5BAEAAAAALAAAAAAQABAAAAIihI+py70BowPQ1HZpwNv212Vg9IGHmIjoWa4ey5DSRNd+AQAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+textbottom16:text text16 16:photo:16 16:R0lGODlhEAAQAIAAAPwCBAQCBCH5BAEAAAAALAAAAAAQABAAAAIVhI+py+0Po5y0hYtzrkB7zH0fN/kFACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+textcenter16:text text16 16:photo:16 16:R0lGODlhEAAQAIAAAPwCBAQCBCH5BAEAAAAALAAAAAAQABAAAAIbhI+pm+EPIZsnRkqtDnhu1zHfFSpjaY4PavgFACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+textitalic16:text text16 16:photo:16 16:R0lGODlhEAAQAIAAAPwCBAQCBCH5BAEAAAAALAAAAAAQABAAAAIahI+py+0BgztwUmmjBXX3jE0auHHhM5Yq4xcAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+textleft16:text text16 16:photo:16 16:R0lGODlhEAAQAIAAAPwCBAQCBCH5BAEAAAAALAAAAAAQABAAAAIbhI+pm+EPIZsgRoqr3Vnt102fFSJjUC6nlPoFACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+textmiddle16:text text16 16:photo:16 16:R0lGODlhEAAQAIAAAPwCBAQCBCH5BAEAAAAALAAAAAAQABAAAAIXhI+py+0PT5i01pisphjt3UmfFZYm5hcAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+textmove16:text text16 16:photo:16 16:R0lGODlhEAAQAIAAAPwCBAQCBCH5BAEAAAAALAAAAAAQABAAAAIbhI+pm+EPIZsg2kfZvblXbwTg10WlA4rjyvgFACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+textright16:text text16 16:photo:16 16:R0lGODlhEAAQAIAAAPwCBAQCBCH5BAEAAAAALAAAAAAQABAAAAIahI+pm+EPIZstSrqsDhhv1ylfFE5jiYwX6hcAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+textsortdec16:text text16 16:photo:16 16:R0lGODlhEAAQAIIAAAT+BPwCBAQCBAQC/FxaXAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAM5CBDM+uKp8KiMsmaAs82dtnGeCHnNp4TjNQ4jq8CbDNOroIe3ROyEx2A4vOgkOBzgFxQ6Xa0owJ8AACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+textsortinc16:text text16 16:photo:16 16:R0lGODlhEAAQAIIAAAT+BAQC/AQCBPwCBFxaXAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAM4CAqxLm61CGBs81FMrQxgpnhKJlaXFJHUGg0w7DrDUmvtPQo8qyuEHoHW6hEVv+DQFvuhWtCFPwEAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+text16:text text16 16:photo:16 16:R0lGODlhEAAQAIAAAPwCBAQCBCH5BAEAAAAALAAAAAAQABAAAAIlhI8Jwe2/AmpTynqPTXSqrnBM+I0kdmpmGmUp+K4nPMvhYx9+AQAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+texttop16:text text16 16:photo:16 16:R0lGODlhEAAQAIAAAPwCBAQCBCH5BAEAAAAALAAAAAAQABAAAAIWhI9pwe2uYnq0yQtqxbz7D4biSIZ+AQAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+textunder16:text text16 16:photo:16 16:R0lGODlhEAAQAIAAAPwCBAQCBCH5BAEAAAAALAAAAAAQABAAAAIjhI+pu+FxXoOIKpds1oBH7hlYxYxRCaIZ01lhJbHy9tTv7BcAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+viewchoose16:view view16 16:photo:16 16:R0lGODlhEAAQAIIAAPwCBDQyNAQCBPz+/PzerAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAMzCLrcGlAs6UAYgwLdLtEcI4ygQo7VVp2oupGpG4vmaUVTemX523qlFcw0a4RqNlkx5k8AACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+viewdetailed16:view view16 16:photo:16 16:R0lGODlhEAAQAIIAAPwCBDQyNAQCBPz+/PzerAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAMmCLrc/i1IAVkYg1Z1iRYUKCqitp1oikqBWV3ZOnhkWNagqu+qnwAAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+viewicon16:view view16 16:photo:16 16:R0lGODlhEAAQAIIAAPwCBDQyNAQCBPz+/PzerAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAMwCLrcG1AwGOQbw6qANeCEB3pCSZpO6pgowJZqLKuUGE0dnuEhf8IL1kz1shSHDX8CACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+viewmag-16:view view16 16:photo:16 16:R0lGODlhEAAQAIUAAPwCBCQmJDw+PAwODAQCBMza3NTm5MTW1HyChOTy9Mzq7Kze5Kzm7OT29Oz6/Nzy9Lzu7JTW3GTCzLza3NTy9Nz29Ize7HTGzHzK1AwKDMTq7Kzq9JTi7HTW5HzGzMzu9KzS1IzW5Iza5FTK1ESyvLTa3HTK1GzGzGzG1DyqtIzK1AT+/AQGBATCxHRydMTCxAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAZ+QIAQEBAMhkikgFAwHAiC5FCASCQUCwYiKiU0HA9IRAIhSAcTSuXBsFwwk0wyYNBANpyOxPMxIzMgCyEiHSMkGCV+SAQQJicoJCllUgBUECEeKhAIBCuUSxMKIFArBIpJBCxmLQQuL6eUAFCusJSzr7Kmpl0CtLGLvbW2Zn5BACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+viewmag16:view view16 16:photo:16 16:R0lGODlhEAAQAIUAAPwCBCQmJDw+PAwODAQCBMza3NTm5MTW1HyChOTy9Mzq7Kze5Kzm7OT29Oz6/Nzy9Lzu7JTW3GTCzLza3NTy9Nz29Ize7HTGzHzK1AwKDMTq7Kzq9JTi7HTW5HzGzMzu9KzS1IzW5Iza5FTK1ESyvLTa3HTK1GzGzGzG1DyqtIzK1AT+/AQGBATCxHRydMTCxAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAZ8QIAQEBAMhkikgFAwHAiC5FCASCQUCwYiKiU0HA9IRAIhSAcTSuXBsFwwk0wyYNBANpyOxPMxIzMgCyEiHSMkGCV+SAQQJicoJCllUgBUECEeKhAIBCuUSxMKIFArBIpJBCxmLQQuL6eUAFCusJSzr7GLArS5Q7O1tmZ+QQAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+viewmag+16:view view16 16:photo:16 16:R0lGODlhEAAQAIUAAPwCBCQmJDw+PAwODAQCBMza3NTm5MTW1HyChOTy9Mzq7Kze5Kzm7OT29Oz6/Nzy9Lzu7JTW3GTCzLza3NTy9Nz29Ize7HTGzHzK1AwKDMTq7Kzq9JTi7HTW5HzGzMzu9KzS1IzW5Iza5FTK1ESyvLTa3HTK1GzGzGzG1DyqtIzK1AT+/AQGBATCxHRydMTCxAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAaBQIAQEBAMhkikgFAwHAiC5FCASCQUCwYiKiU0HA9IRAIhSAcTSuXBsFwwk0wyYNBANpyOxPMxIzMgCyEiHSMkGCV+SAQQJicoJCllUgBUECEeKhAIBCuUSxMKIFArBIpJBCxmLQQuL6cAsLECrqeys7WxpqZdtK9Ct8C0fsHAZn5BACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+viewmulticolumn16:view view16 16:photo:16 16:R0lGODlhEAAQAIIAAPwCBDQyNAQCBPz+/PzerAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAMwCLrc/ixI0WSgKoyBl+beQFACpo1AqXbKCr1wLAMWS08hGG3dSZqin4sxnBmPD38CACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+viewtext16:view view16 16:photo:16 16:R0lGODlhEAAQAIAAAPwCBAQCBCH5BAEAAAAALAAAAAAQABAAAAIchI+py40BTQSwuovp3DXkv1ia1IHmIXLiyWJ+AQAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+viewtree16:view view16 16:photo:16 16:R0lGODlhEAAQAIIAAAQCBPwCBDQyNPz+/PzerAAAAAAAAAAAACH5BAEAAAEALAAAAAAQABAAAAMuCLHcri4yGISlj4kxcANgNRBQCIbL6U1Su7bB62rXvGydG25kqpwfIGxILBr9CQAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+actattach22:act act22 22:photo:22 22:R0lGODlhFgAWAIMAAPwCBMTCxPz+/DQyNKSipAQCBISChFxaXDw6PAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAWABYAAARrEMgJgqA4zzus/gLhFd5HCcZAXqsphYPUdhcYFNRcZnvdtpnDqPTbUWgAJKBYwzBlw+bRo3xmkNWoBgm0OrVLn3GC9RgCk8DhUw7c0rHPr4CDu5SYQNyEt7uSY3p/UAKFhYKDSQOLiwgFdhEAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+actbookmark22:act act22 22:photo:22 22:R0lGODlhFgAWAIQAAPwCBCQmJCwqLMTGxAQCBBwaHMTCxLSytERGRFRWVLy+vKyqrKSmpHR2dJSSlJyanISGhGxubIyOjKyurGxqbFxeXGRmZHx+fKSipLy6vGRiZLS2tFRSVHRydJSWlHx6fCH5BAEAAAAALAAAAAAWABYAAAWWICCOZGmewamaQrq+wUC8azHINGocOI38iIRAceDNaISFYklkGHOEhoNBfUAOhuOLEJE8HoPiRKFdESiQBqViuTDIUAsEcyAeGJmyiqC5RCwJGg0YcEh9D0V3Dxt6JwQVDRYVHBUdi40mjw0PTgwQHgeYJQQJfxUXFxAOoTkFpQ0fsRSimQkWEQ0VtI62HLt7vjl7JQYhACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+actbookmarknew22:act act22 22:photo:22 22:R0lGODlhFgAWAIUAAPwCBCwqLCQiJCQmJMTGxAQCBLy+vLSytERGRFRWVKyurKyqrLS2tKSmpHR2dJSWlKSipISGhGxubIyOjGxqbIyKjFxaXGRmZHx+fPz+NGRiZPz+ZPz+HMTCBKSiHPz+jFxeXPz+XPz+tPz+zPz+/AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAWABYAAAamQIBwSCwaj4Gj0hgQLJ+AAaEAVQoI06pRYDhkoYgwIhEgKBTfZ2FhaBsYDS8VWnA8Go0FJIKeqyUTDw8EDHBpSwUUFQ4UFhcYDQYFfkoFFxEQDG8KEAUZlEeWGBIakw4FG1STiBoYBRwdBR4fHgUdHKBEBSCnIR8iIyIfIblFu6ceIyQjtcXGCbLKzAUKzrq+wMLEVa+xs7W31kOTk6nkWuOf6Ea5QQAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+actexit22:act act22 22:photo:22 22:R0lGODlhFgAWAIEAAPwCBAQCBHR2dDQyNCH5BAEAAAAALAAAAAAWABYAAAJOhI+py90RnIMyRUOxhDfzJkACdoXBuEDDkQFDi5go0MrKx16kns80b7qdELCgBYaEGWwL5nG1ePFiKp9A6kuYRNuho8vxVrrZivmMRtMLACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+acthelp22:act act22 22:photo:22 22:R0lGODlhFgAWAIUAAPwCBAQCBCQuNBwiJAwiLAwaJAwSHAwSFIy+3ERynCw2PCQuPAwmPCxOZCxWdJzG3FSazBwmNAQKDAQGBDRmhBQyTDxujDR2rIy21AwWJDyGxCxmjAwmNDRihAQOFDxmhCxunBQWFAwaLCRahDR6rESGvDQ2PCRWdDRunDSGvCRSdAwWHCwuLDSOzHSmxDyKxBxCZBwqNHSu1DyOzAQSHAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAWABYAAAahQIBwCAgIBAPCoGAgOoeBAyKhWCwYDUf0CX1AIhLiJEGpBLiAAaRxdgYsl7Ybk8igBZoN5xmAdDxoanp8HyANISF8EBsiXBMjJBolBEQmGHFoRScbKHIKDykqK5lFAZRCnyknTaROLA8tq61OChgtKqyzQgEYEJi6UC4vI3LAASkbMBPARAEBdszR0sACEaPSMTIQM8W6KzNl3bo0NOJDdEEAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+actlock22:act act22 22:photo:22 22:R0lGODlhFgAWAIYAAPwCBHRudFxaXExGTERCRAwGDGxubPz+/Pz2/Ozm7Nza3NTS1KympFRSVHR2dNTO1JSSlKyqrKSipDQyNMTGxDw+PLSutKymrMTCxAQCBHRqLBQODJyanDQuFFxSJFRSJFRGJERCHExCHISChHxyLEQ6HGRaJExKHLSmbLy2fOzitPz23KSiZHxuNHxyNJSOTNTOnMTCjLSudKSaXJSKRJyOTOTetNzWpHxuPOTi5MzKzLS2tFxWXOzq7Ly6vOTe5Ix+RLSqdNzSpLyydKyqbKyiZAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAWABYAAAf/gACCg4IBAgMEBQKEjI0GBwgJCgsMDY2XjwkOAgQBDxCLl4QNCaGCBBGWooINCAqqrBKgqwATFKaDFRYVtBMXsIMNGBm0GRADjQIJxKIaGxwdHh8gISIhGyMZzIwkGholJiYfJiAfJyEZISDbg90oKCkqKwcHKyooLC0f7IIuLzD2YMSQgW8GDRri+AFoUMOGvRsxUhSsQQPHvmQSchyQtEAHhh0WJHDQcJERjwsKDvRI0BGDjwgicXhQyCOjSgUKPO6AObIkIQESfmxk6REDT4s0bfaYpDNkT4VAha5s+TLmzEYtatwIOHAiDZIKNQAJYk9IjCFEisyoocFEB4UACtBpm0t3LiF4gQAAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+actredo22:act act22 22:photo:22 22:R0lGODlhFgAWAIUAAPwCBCReDJzGjMzivOTu3Pz+/JTWbHy+VHTCTMTivPT69BxGDESuJDyiHESiHEymJIzKZAQCBFS2LFzKNGzWPDRqHCxqDFSqLHy2XESCHAwaBAQOBBQqBDyWJHyqZDyKFGSiVESeJBQ6BAwSBGTGPFyWPFSSLEyOLESGJBQiDAwiBBQmDCRGFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAWABYAAAaoQIBwSCwaj8hkMcBkKpcBwYAwEDif0YLhwEUkFItFMkAwMBoOR+PxgHwjRDggamhIJpQ8ZbKGKOQLcgEFdhUWEYgRF3sNfhELBHALAhgZFhobRBwREhQdEAIEHpIKHwsaSJwUDQgQIJINARxKESESDQ0dgCIjSpAkDAwPco+ZSJAlJicnKHIAIrNHidOIQxunT0kpCyrZSCss0d5Fj6jjRonn6uvs2QZBACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+actreload22:act act22 22:photo:22 22:R0lGODlhFgAWAIYAAPwCBCRSFCRSHBw+DBxCFCQ6FBwyDBQWBBxGFCxyLGTChMzqzLzmvHzKjDyOTER+RERyNDSqXNzy3LzivFS+fCyCPBQmBCQiBBxKFBQqDOTy3LTitES2dDR+PCxuJOT25KTarCx+PESSTCxKHDSeVCyKRNT21ESWVDSGPBQyDAQCBBQSFDRuLDSyZDySTGzChCRiJKSmpExKTDS2ZGzGhLy+vGxqbISChDSKRMzKzGxubDQ2NIyOjCQiJCwqLBQWFCwuLKSipERCRERGRHR2dAwKDDw6PFRWVIyKjCQmJFRSVBwaHKyurAQGBExOTBweHFxeXAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAWABYAAAf9gACCg4IBAgMEBQYHhI2ECAkKCwwNDg8QBAOOhAQREhMUFQgWBxcHGBmbggkaGxwPB4yDB6SbBJIKHQaqtY0eHyAhsqrDgx4aCiKpqoQHAyMjJBMKJaSxzAAHIRsmJgonKA0LHSmDKiuOBywRLSQuLyEwwyoxMuiN6iUzNBXy5jU2bsgoJugABBz95uXQsUMGD3vpPPgTpKIGwx4+HMr4kW4YkCA2hAzxAQSIECI+imBTwVIFESNHerRUgc0cEiFHkjiiyYzeDiVLdvLcySSkkKGEWiZVweSGkIHMmvQosoQlkaZOjvhosvKJjIAxoOAsgpRZkQNLnvSoqspAIAAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+actrun22:act act22 22:photo:22 22:R0lGODlhFgAWAIYAAPwCBAwKDAwKBCQiHNze3AQCBBwWFDw6NPTy9PTy/Dw2NKyytOTi3LS2tMTKzMzOxLy+tLy+vBQODNze5NTS1JyalIyCbIx6VIRyVISGfJyelOTq7EQ+NMTGxKyurGxeRLyKPOSmROSuVOy2XOSiTLzCzNTOzDw+NCwqLHxuVOy6bPzGfOSuXNTW1LSyrMSWRNymTOSmTKSCTPTGjPzSnPzWnMyaVBQSDMTCxPz+/KyahNSeRHxeLJRyTPzmtPzarOy6fJyajNza1Ly6vLyulFRCJPzirPTOlMS2pNTSzMTCvJyenBQWFNzKtPz6vPzyvPzqtOzGlOTe1AwGBFxWTLy6tPTm1PzSpPzutPz2xPTSnOTSxOy2dPzapPzerOzm5IR+dPzu5Pzu1PzqxPzy5Pz+9GRiXGxuZKympHR2bOTm5Pz6/MzSzBwaFJSSjCQmHPz2/AwODAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAWABYAAAf/gACCg4SFhoeEAQKIjIIDBAQDjYMFBoMHCAkKgwYFhwULDAUKCg0ODxCkBQgRnoUSExMUDxUWFxgZGpAbFIuGHB0eHyAhIiMkIB8lJieIKCUpJCTGIyorLCktKIUDpC4YLzAxIjIyMzQ1NhgdpJI3ODktJTowOyM8Ejc9Pj9AQUIEclAocCMIBQhDiOwgoaKIoCI+jBxBkkSJkCWemIyq0GSHCBVHihRx8gRKFCmpKhGaQqWKFYZXsGR5kkXLFgRUXBUqkCGCFS5AjnTx0sXKlyA6CRVgAAHMAilhxIwhU6ZFkBY5kgKYUoXBAzMKzixZ4AJNGgVm1KxhM0WpmQpUMtooaOPGxAM3Nw60oYLGjNYCbzYJOgAnRzNBJ95oPYQCgpJtkwzFoULlRuRPiy9fNhAIACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+actstop22:act act22 22:photo:22 22:R0lGODlhFgAWAIUAAASC/CQKDBwKDCwODNyKjPzq7My+vIxiXAQCBOSOjPz6/OSelNySjNyGhMR+fLRaTGQ2LPz+/Nx+dNR2bNRybMxuZMxeXMxiZLQSFJQaHFwqJNyKhOSCfNyCfNR6dMxmXMxWVMRORLQODOR+fOSSjNR2dMQ2LJQWFMRWTLwWDNSCfMxeVLwaFKQODNR+fNx+fMxiXKQSDOSWlMRSTMxaVMQ6NMxORMQyJOTS1MxqXLwWFLRORMxKPMQaHMxKTLQWFCH5BAEAAAAALAAAAAAWABYAAAb2QIBwSCwajwGBcikIHIsDQmFKNRwQT2EgoVgsGOCG4wHBIgmRhWRCqVQsF0xGYyYGNgoGh9PpeCQfICEic3UAAWgLIxwRJBsbHSUREyYYJ3RDAQULexGejhueESgpl3WaCxsqJKKsChEUKywtmFoFDC4vCayikzCyMbWHt38NCTKiHhUfMyzBdQIFKsodob0VNDWzwppuKxMRrx6iNjcitNA4bh+iEzkwojc66JkOOxcf7G35PBE9KS1MEUGgIQOIFfk++KjRw9wJgUUIZvhRoyLDFCliQDQisUWLGCJOeNx4hKCGkyhPGnqCoKVLl1liypyZxUAQACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+actundo22:act act22 22:photo:22 22:R0lGODlhFgAWAIUAAPwCBCReDJzGjMzivOTu3PT69MTivHy+VJTWbIzKZEymJESmFESiHDyiHESqLAQCBFzKNGzWPFS2LNTmzCxqDDRqHPz+/KTGnBQqBAQOBAwaBESCHHy2XBxGDOzy7HTCTEyyJDSqFHzWTAwSBBQ6BIy+dESKJFySPFSSNAwiBCRGFBQmDAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAWABYAAAalQIBwSCwaj8ikMsBkKotMwYAwEDiXgYLhwD0gCFZiQKxNKBYMRqPh+D6G16y5AYnYIxBJAyF4AwITTAUJdBESD4gPFBV6Fn6ABBcJDIYPGEQZGhQbHAIdfx4JHw2VSBodGwWfAR4LDSALfkgYAQurBiAhICKfSSMkvQElGyYnGyi9Rxkdj4nOskUYyU9FpxnURikdGtjRKivdRKfQ2Inh5+jpRwZBACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+actunlock22:act act22 22:photo:22 22:R0lGODlhFgAWAIYAAPwCBGxqbFxaXExOTEQ+RAQCBPz+/PTy9Ozq7Nza3NTS1KSipFRSVOTi5Hx2fJSSlKyqrJyenJyWnDw6PMzKzKyurDQyNFxWXMTCxJyanHRuLHxuLGReJFxSLFROJFxWJExCHERCHBQODISChHxyLHRqNIRyNHRmLLSqbKyiZLy6fOTarPz67Pzy3OzitKymZFxSJJySTNTSnPTy3NzSpMTChLSydKyqbKSaXJySVIyGRGReLPz23NTOnMzCjHxuPLy2vKSmpOTe5LS2tLSutHxuNHRuPMS+xFxWLIR+RDw2HFRKJAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAWABYAAAf/gACCg4SDAQIDBAUChY2EAQYHCAkKCwyOjZANDgIEAQoPjJiDAg2iggQQp5gMBwmrDBESl6MTFKuoFQSjABYRF40CGAW8BRm7hQwNxBobHB0eHx4gISIjBdiEAhYFJBslHOHSHh4hBSHlxIUmJygpKissBiwtLi8pGjDqhBoxMjMuaNSwcSMFjhw6dnjYRyrGCh4ueviw4Q5HDB0/PjAUJCBCAwMIGiiggAEIBFk/FgYLIgRkggQkhxAJkqGExkYMFnxsIGRkSQgLHhRRWUjAggQgG8AsSWRBBiP6VrYMOfKIyaBDNwLo+HHSUplOSyDRqiEHjRkretRQkcLgxayNF0wksQGQxsSKMTIq0QpgCba/gAE7IhMIACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+appbook22:app app22 22:photo:22 22:R0lGODlhFgAWAIUAAPwCBAQCBDyGhCyCfFSWlESOjDyKjDSGhCx+fGSinGSenFyanEySjHSqpHSqrGympEySlBx2dISytHyyrCR6dKTGxHyurHSurHyytGSipCR6fARmZFSalEyWlBRubAxubBRydDyKhDSChLSytPz+/MzKzIyOjAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAWABYAAAbFQIBwSCwaj8ikMhBQIpmCQdM5ZBIKhgNiugwkFAsCI7pNMhuOxkNBgBgEiAi3GkBLJpJHYgEpaClyREwVFhcSEhgOGQoMfgMaERtcARQBFRMYExZ6HB0FUYAekkIBHxqWFmlrC1haESAfG6MBGx+VFRgKYH0hInGRklO0ppYXCwwMWQiQHkwjgrWnFRdYZHIBJCTP0LaWGAcDW9jZ2nMAw9IWTOQkJSZMRsOV49nu8E+19PbmR7TY+1TovONH5V7Ag0QMBAEAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+appbookopen22:app app22 22:photo:22 22:R0lGODlhFgAWAIYAAAQCBAQ2NPwCBHSurIS2tBx2dBweHPz+/Ozm1GxiTGyqpPz6/Pz69GSqpOzaxPzy5HxuVLSmlOTazPz27PT29NzClPTexHxuXLSmjAxqbFSinPTy9KyehNy+lPTy5Pz29HxyXNzWxKSahOzexPzy7IR2ZOTWtESenPTy7KSWfIyCbKyijAQGBDyalPTu3KSSdDSOjJyOdCSGhPzu3OzizJSGdPTq1PTq3JySdMy6lAyKhOzWtOzi1OTOrJyKbMS2nJySfMS+rAwCBNzOrNTCpNzKpJSGZKyafLSifLyylIx+ZHx6ZDSChAQuLAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAIALAAAAAAWABYAAAf/gAABAoSFhoeHAAMAiI2IAAQFjI6EAAaJkQeTjwAICYkKBQcLm5WdBwyfhgChB66bp64HCQC1lQ2irqQCAA4PowsLEBESE4wAuLIHFAAVFr+uDBcYxRm1GrmuGxwdFh4Mrh8gGCET1gDYyhsiFSMkDAsMDCUYJhvnJ9kHKCnODwwfPlBQsULCPRYAWogK9sHFiwoOPEyQh0JFPXO1YBSYwBEFghjdHkwQOYGgwQwIZRR44GHGDBogabhAsYEEihrUMAIoUMCEDRs3HODIYQHFA6MPcJA7KICFjgw7eIzo4cOfiwc/gKwIUm2SkKdDdlDt4AABDaU/iIRwwbTSUyJFOow4S3Hkx9oNDDZgXPU0h1wcSIgEGUw4ibVET5WoWMKksePHpdxmyKADAEIWly9HJtQkQJMmlAgZCAQAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+apppencil22:app app22 22:photo:22 22:R0lGODlhFgAWAIMAAASC/IQCBPwCBPyChMQCBPzCxAQCBPz+/MzKzISChKyqrDQyNEQCBAAAAAAAAAAAACH5BAEAAAAALAAAAAAWABYAAARYEMhJ6wxiEMtpIAWxddwXiqRlikSQeiAbuC+wirNR322gv7zcLobzDU+9XypoBBKTR1lz+RTWDgip8nUwZK1XLyIx5XoVicX2RUAo1DVKi7GOBxjxfNwQAQAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+apptool22:app app22 22:photo:22 22:R0lGODlhFgAWAIQAAPwCBAQCBISChFxaXNze3NTS1Ly6vKSipNTO1Ly2vNza3Pz+/MzOzOTe5DQyNOzu7MTCxGRmZMTGxPTy9Ozm7Hx6fPTu9MzGzGxmbAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAWABYAAAW1ICCOZGmeaEoGbBsI6joMRGEcbQwESDIrtVtAF1gwDLNaAmfKiVgLBJKgwB1KxQZrBHU0FAXmavFoQLYiB6TxFXMj5AZBwnJI2I3wcNWALyYEcgoKXxRhOHs7XxEVCwsWFgoUDRYUFwwQB25ZCxiNjo6GkwUXN2NsCxEYqhUHoQ0MEglYRQQXErcHrI55FycuB2YSmoyOBTEtB2sXuhU6XAENC2a6z9AKCwq+1tAN3E2J3ySkIQAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+connecting22:connect connect22 22:photo:22 22:R0lGODlhFgAWAIMAAPwCBPz+BMTCBISCBAQCBPz+/MTCxOTi5AQGBNze3Ly6vISChNza3FxaXKSipAAAACH5BAEAAAAALAAAAAAWABYAAAR4EMhJqwzY6omD+MNGdR8YilNZnug0qGzrqrL1lnV1fyJBVB6VQEMoGH4ADGwQkxQPBwMiKGA2J8VEAnq0tgiKg5aL/C7C2gTjKCM0zowDQ8tuNQznNL7cKzjOUQsNfER+gguIg19+Pm6ChBZFDmWNi5M5FIyYFHQRACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+connectno22:connect connect22 22:photo:22 22:R0lGODlhFgAWAIMAAPwCBPz+BMTCBERCBAQCBPz+/MTCxOTi5Nze3OTm5Ly6vNza3ISChFxaXKSipAAAACH5BAEAAAAALAAAAAAWABYAAARiEMhJq7046827/+AVCKE0Dh9BAGdaGISAToFGFMcBU+11I4hDYseSZQiKwwKoI/QwBIYiuFDCZseGdIlYEjUNg1SpY6w2N4cUIW6cjwW1lsFwo+MqgtZuw0/ydw5vH34lBhEAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+connectyes22:connect connect22 22:photo:22 22:R0lGODlhFgAWAIQAAPwCBAQCBKyirPz+/KymrOTi5KSipMzCzNza3OTe5Ozi7MzGzPTq9OTm5ISChMS+xFxaXNze3GReZIyCjAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAWABYAAAWLICCOZGmeaBkAQpoGg7C6JizTQT7CxPwOwFWgYPChYIXkIHC4uQKGAiKRKCyNpxxUUVViVYNFLkqtLo+DAkMMLXQPXwAy2WCTF4544FGtKuwPDhB6DnxuUmyCcXIQhV1uYoMuEAcOBxEKCHg6TzGFCJUSizuejROKOAM9OY2SnUU7nD89NCcDsLUnIQAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+devscreen22:dev dev22 22:photo:22 22:R0lGODlhFgAWAIcAAPwCBAQCBPTy9PTu9Ozq7OTi5Nze3OTe5Nza3NzW3NTS1MzOzMzKzMzGzMTCxMTGxOzm7AwGDBQOFBQSFCQeHCwmLCwuLDQyNDw6PERCRFROVEQ+RDQ2NLy+vKSipISChGxqbExKTOzu7OTm5Pz+/GRiZMS+xLy6vBQWFLy2vCwiHFQ+NMSmfNSyhIxmTDwuLJx+bLS2tCwmHMyyhMyqfPTqpPzyvLSWbLSWfPzitIx+ZDw2PAwKDCQiJGxWRPTmrPTerMyuhPzqtPz63PTWnPz6zNy+nIRiVDQuLKyWbOTanPz21NS2jNS6lDQqJHRaTPzmrPTSnPzyxOTClPz2xNSuhPTqxPzuvOzSpAQGDOTKnMy2jOzSrPTu1NzKnOzOnBwWHJRuXLSWdPTatPzqvNzClCwmJOzSnOTOnPTuxOzKlOzerOzarOzitJR6ZNTO1IxmXPTWrNSyjPzOjPTSpLSehHRqZOzirOTCjPS+fPzGhOy6bOzKhGROPMy2lPz+1PzmtKRyRHRiNNTCdPz+zNzCjEQ2NKySdDQmJAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAWABYAAAj/AAEIHEiwoMGBARIqXMhQIUIBAwYQIFCggIEDCBIoULBgAYMGDgIIDEBAwMSKBRBk3NjxAciQIwdACBBBwgQKFSxcwJBBwwYMHBx0EAmA5EwPH0CEsCChoYgOQ0cSGCHhA4kSS5syJGDiBNEAFVGUKKEBAwWFFM6SNJHi64gDFEKE4FBBggoKK1i0cPECxokYXw0gsECYggQZM2jAqGHjBo4cOtqOxLhDAg8ePXz8ABJEyBAWRIoYOfJipEoMCZEkuaFkSAslS5jUGJKkSRAnRREo0JDwCZQoTKQAmUKlihQrVa5gKZ1lI+oAK7QM2cJlSZMuU4Z4+TJEx0iNOwKAggkjZkyOFmS8kClzpcUQLRRGbjRD4MgZNEzSqKG+ZgobI2248dUbDDDwABzcxSEHEFpgEcUcdMRRhx1fFejAAx0cgcYdSxiBRx566LEHH0d8QFRRNC3Uhx985CHEH0MAEkhCBxWkgiCDFEFIEYUYUmONMhyCRxVH/PgjBYioYJAdAQEAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+editcopy22:edit edit22 22:photo:22 22:R0lGODlhFgAWAIUAAPwCBBQSFPz+/DQyNISChDw6PMzKzMTGxERGRIyKjFxaXMTCvKSmpHR2dPz6/Pz29PTq3MS2rPz69MTCxFxWVHx6dJyWjNzSzPz27Pzy7Pzu5PTm3NTKvIR+fJyGfHxuZHxqXNTCtPTq5PTi1PTezNS+rExOTFRORMyylPTaxOzWxOzSvNze3NTOxMy2nMyulMyqjAQCBAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAWABYAAAbYQIBwSCwahYGkUnk0BgTQ6IAQaBKfUWhBYKhaAU+CgXAQIAyChLeJzSIQhcH6GFaM0QtGY5kstqEODw8QEQELAhJTc08KBBMEFBUWDRcBE1pca20SGBkaEBscAY5maFRIAgoLHRQRHh8gIQFlZnByqA8ZGSIQIyQjJQEmYgJ5p2ACrK4gJx4gKIZZAgdeAQ4ZI9kjKSor0AwEjeAs1S0cHAslLi4vMDDRWeRIfEsxMeET4ATyVoYLC5fizXEiAR84BeMG+pEm8EsAFhAjSlR4hR6fLxiF0AkCACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+editcut22:edit edit22 22:photo:22 22:R0lGODlhFgAWAIMAAPwCBAQCBAwCBPz+/OTi5JyanOzq7DQyNGxqbAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAWABYAAARbEMhJq704gxBE0Bf3cZo4kRJqBQNRfBucyudgvJS6VaxLzyMa6/bLiWA9HOg4VIIkL5vzuRkcpkvRIIAorphJLzBW84WEuRZWp6uaT7J2Sh1Hit3OY/ZO7WvsEQAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+editdelete22:edit edit22 22:photo:22 22:R0lGODlhFgAWAIYAAASC/FRSVExKTERCRDw6PDQyNCwuLBweHBwaHAwODAwKDAQCBExOTNze3NTW1MTGxLS2tJyanPz+/Ozu7BQSFCwqLDw+POTi5PTu7MzKxIR+fCQmJPz6/Oze1NTGvPz69Pzy7Pz29LyyrPy+vPyupPTm1BQWFIQCBPwCBMS6rPzSzNTOxPTi1NS+rPTezNzOxPTizOzWxMy2pOzaxMy2nPTaxOzOtMyynOzSvMyqjPx+fOzGpMSihPTq3OzKrOTCpNzKxNTCtAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAWABYAAAf8gACCAQIDBAUGBwgJCgsLgpCRAAwNlZYODxALEY+SkAMNEqKjEw0UD5yegqCjrRMVEqidkgWhraMWF7GptLa3EgEWFRSOnhW+vxgZEBqzkBvItxwdHryRCNGjHyAhHSLOgtgSI60c2yQjJd+eJqEnKK0hJCgnJSngAO0SF+8qEvL0VrBogW+BLX4oVKgIyMIFQU8KfDV4R+8FDBcxZBREthAFiRIsOsygsVEUh4Un3pGoUcPGjZInK65QicPlxg8oX5RwqNJGjo0hdJwQ6EIkjRM6dvDYCKIHSBc1Ztjw4eOH0oIrsgIJEqSFDBo0cuTgsdSTo7No0xYTZCcQACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+edit22:edit edit22 22:photo:22 22:R0lGODlhFgAWAIYAAPwCBISGhISChHx+fHx6fHR2dGxqbGxubGRmZGRiZFxeXFxaXFRSVIxSLPyuXMzKzMzKxMTCtExOTPzqrPz+/NTS1MS+tOSaVPyWNPz6/IxeNPzavPyKBNTW1PyCBPyGBJxmNPzOpLx6PNRqBMSCRNySTPyCDPSGBMxiBKROBHRydPSylOyydMxmBJxKBAwODPS2lPTq3OyabJxGBPTy5PTGrOyOXPR+DPz69PzmzPzevNxuPORqLMReFPzy7MyCXKxiNIRKHBQWFNTOxPzixJRaPFxONHRqVPz27PTy7PzStCwqJDQyLJSGdIx6ZPz29PTu5HRmTLSKbMSGZHROPFxKPJSKfJyShKyehMyuhDQmHEQuJJyOfLSijMSynMS6pLSefDQyNHx2bKSahLyqhLymhOzi1FRGNIR+bNzKtOTOtOTKrOTKpLyedAQCBFRWVPTq5NzOvLyunLSmlNTCrOTOrNzGrLyidMS+rLyynKyijLymjLyqjAAAAAAAAAAAACH5BAEAAAAALAAAAAAWABYAAAf/gAAAAQECAwQFBQYHBggJCgsLDAwADQ6CAQ8QD5ydEJ+gERKWE4ICDxSpqhWqqhYNFxMYphCtqaytGRoXGxgcggSoth25u70eH8APFR0VzMzNziAXIRjIvwAFwq3EqSLUGB/iI4LathS4JCXVJh8nKCmCKrXDFCss1eIfLS4v8ssdmgWsAGNDDBnt3s3wJ+jAtlUhaNSwccNEi4WCBBl4SAHHihw6ZOzg0QNjRgAG6KXK4CNEjBU/gDQI8kLISQAIADobAoMIzCINjLw4YvNkAno4kCRRUuNHESNLmDRxUjSjAlRPfECJImUKlSpMrFzBIqWqoKtJaWSJomULAy5XXrp4+QKGYcYFoCBEWRImi5gmY7CQyVLGriAGD2jEMHMmCxc0Xb6kUbOGTRs3N988gLM4jpw5Y+iwqcOGjZ07mE8yiGABz5c8c/Ts4cOnDJkybS7fdMO7t+/fvDMaCAQAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+editpaste22:edit edit22 22:photo:22 22:R0lGODlhFgAWAIYAAPwCBBQWFDw6FHRuFGRaBFxSBAQCBAQKBCQiBIx6HPz6/NTOfKyiXDQuFOTm5Pz+/Ozu7PTq5Pz63PTyxNTOjKSeRExGLMTGxMzKzNTS1NTW1Dw2NKSmpKyqrKSipJyanNzWlLy6ZLSuVIx6FISChIyKhJSSlCQiJLS2tDw6NDQyNCQiFCQmHBQSDGRiZHRydGxubHx6dGxqbFxeXGRmZFxaXCwuLOzq7KyurHx+fDwmFEQuFCweFCQWDBQODBwaHBweHKSinJSWlOTi5JyepHR2dDw6PBQSFNze3ERGRIyKjIyOjISGhPz29Pzy7MS2rMzOzFRWVHx2dHxybDQiFPz27Pzu5PTq3PTm1NTCtJyGdHxuZHxqXPzq3PTaxNS6pFxWVFRKRNS2nPTi1PTStNSulNzOxNSynMymhAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAWABYAAAf/gACCgwABAgMEBYSLggaOjgcICQoLDA2Pj4MGDg8QEZ4FDxITFBUWFxcYGRobjQ8cHR4fCQ8gCyEiFSMWJCUkJieNEB4dKB4pKissK8wrLS4vMDHBAAYQHx8dFx0fJDIzNDU0M+IyHzaNNyg43Ng5Ojs7Ojw9Pj9AMkCNDiZB/h9CSOx4QLCgihItqBkYgqIDESElitAYWJCgkQcXjjRCgi1Ihw4BB5LAQOLCgyQYHihpUU3DBw5ElpAgAYNixSRJjKjQaECDCRPZPDB5IbIGSQwKLnh4wbInLA4kmJB4oaPiAwVNnER40hRK1BIAaVatUZJEFCkmpmjgCeWDCalFe4q4oFKwSRUrEa5gycLzwq8lUnPQ4PEgSpYcUZ5o2cIlS1O/JHLEDdfjQZMIVrpgweLFy5e+M6WSmBGlxYMYYBRzCaOFi5imHWBIfOEiShLTVjaP6eyFTBmN1TA5OvLDjJksWb58OVMGDRqWjAYdmU79SIvpjqJr104nEAAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+editshred22:edit edit22 22:photo:22 22:R0lGODlhFgAWAIUAAPwCBFRSVExKTERCRDw6PDQyNCwuLBweHBwaHAwODAwKDAQCBExOTNze3NTW1MTGxLS2tJyanOze1Pz+/Ozu7BQSFCwqLDw+POTi5MzKxPTu7LyyrIR+fCQmJPz6/Pz69Pzy7Pz29OzaxPTu5PTq3PTm3My6pPzu5PTq5NS+rPTm1PTi1PTezOzWxPz27MyynOzSvMyulOzOtOzKrMymhOzGpAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAWABYAAAbpQIAwIBgMCAXDAZFQLBbCqJTRqFobjgdkEYFKowPJZEyeUBqVR/crHDTKZYplovZKCW84+YKZZNZSBXl6EwEEBhVPXxZihGMaGRscdkIdg4QeEnVfCH2OHyAhIhuUAAiXZSEhIyQlJqWnjiEnKCWupRWoYyEgJK0SKaUKjam0JCorLMFfC6iqx8giLa/MGAsT1wsuCyULKwssC9RSzdkfCyALKuALLQsvpeXYIQso3gsiCzALMfENC+dGcMNHUAY/f+jq3ctncMYCGggFrsvHcEGNh/EyPFmg8cmrJxAVkVO0EUDJklHoBAEAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+edittrash22:edit edit22 22:photo:22 22:R0lGODlhFgAWAIUAAPwCBAQCBERGRExOTDQyNISChBQSFCQiJCwuLPT29Nze3GxqbDw6PGxubHR2dJyanLSytJSWlJSSlOzq7Pz6/Nza3Ly6vFRWVBQWFIyKjMTCxHx6fIyOjLS2tOTi5PTy9OTm5Hx+fNTW1KyurKSmpJyenExKTMzKzKSipFxeXCwqLMzOzKyqrMTGxLy+vHRydBwaHNTS1DQ2NAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAWABYAAAb8QIBwSCwaj8KAMoA8LgUDQsFwQByay4RiwWg4GA9IRGk0SCYJSsUCsVwwGQ1EsmESD5xOp+L5gDwhBRIZDhcDdkMGDgEiIxAkJQ8Ok5MmAohDAQ1xJxUlKCUlEg0pKpiZJRoLCxmtCw1eURhOcR4rbQ8cGRwLAwgGtBYTDywtGRKjvQTARgEZLhMcKC0OrQMvAirMRc7CHCTU1g2+20TO0NIn1RwDCya/wdHT1Rnt5LToKOq79trx0tR02YPX7Jm8fRxMOIhSLhOJE/LCJSTlr5kFEBQsWDiR4UGGBgsuHDg1BEYAfTE6oEBR4AIBAiS5yWBAAAGBAyaPGAgCACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+fileclose22:file file22 22:photo:22 22:R0lGODlhFgAWAIUAAPwCBERGRERCRDw6PCwqLExOTFRWVHRydGxqbGRiZCQiJISChIyKjHx6fDQyNBwaHJSWlKSipBQWFJyanPz+/JSSlCQmJAwKDCwuLBweHBQSFGxubExKTISGhDQ2NFxeXFRSVDw+PAwODAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAWABYAAAbZQIBwSCwaj8jkMSAYDAgEJbFgOBwQCUOAoJAaFgvGonHIBhyP5BcSgUAYDWxggD4WFmx3e3HQngkSRgYMEBMUFG4MCId0BGlEAQeEhocVDYcUdBYKF0QCB3gRlJgUAQEYBBkaRAMbDZMMpAYcT46rQwMJrgsdC6QcfwoPnUMOBgkIV6SHHg6bw0QEAQYfBpggBZjPGsRD0gEchxwCIR6HChnQRQ8DIU4DTR4Em+ncRw8O+fmoXPXdRg+gQLFgIYM/KRIkoDP4QMKFf0o0aBAh4qGUixgzCrETBAAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+filefind22:file file22 22:photo:22 22:R0lGODlhFgAWAIYAAPwCBBQSFJyanLS6vLzCxISChNTe3OTu9Oz6/Nzy9Nzy/NTy/OT2/Nzi5Mzu9Lzq9KTe7LTq9PT+/Pz+/Nz2/Mzu/Kzm9Jza5HzK1LTi9PTu9IzW5ITO3FxaXNT2/KTi7Iza7GzC1LzW3FRSVMzO1MTq7HTS3Fy6zFS2vKzm7Lze5MTGzHzS5FTG1Ey2xEyyvJze7JzW3ITa5FTK3EymrGS+zFxWXKymrMzi7ESirEyqvLSyrKze7MzOzMTCxKSepAz+/NzW3MzKzBwWHLzS3ERCRAzi3KyurNze3MzGzLy2vLSutCQiJAyytHRydOTe5MTGxLy6tLyqpKyelJSCdOze3NS+tLyupLSmnKSOhCwuLPzy9Pzu7Oze1OzazOTOvMyihOTi5PTm3Pzi1PTazPTWxOzOtNSunDQyNPzy7Pzu5OzKrNzSzNzGvNS6rMyynMymjAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAWABYAAAf/gACCgwGFhYOIiYQBAgMEAwKHiokBBQYHCAkKCwwFAZOEBQ0IDAsODxARCZ6gAAEGEhMSFBUWFxgZCJ+TjBoMEpkRERscGBGRih0BBAgeFBQOER8gISEfIruIIwEkCCUVwhcgJicoKSrZg9srCRkRGdMsLS4vMNiK2wIKMRsbMiwzXtCocSydIBs3AuCIwIFDiBMucugAoWvSiB2VNPDg0ELHwA0MkCXr4aNSggg8NoDIQOFHgBtAkgURMiDAEAFEVBCJFKCIkSMGOyDRkETJEkOFmABoUsRJQkQdnkzQACWKlBtTplBR6qopxkFRJ0ytYuWKFCxZtBBq+hRA2AlbRrh08fLlCxi1a51g+dQhDFwuYsaQKWPmDBpKXgNETaNGjJgyhNfcVdTTiWI2XpK0cePmzRk4YA5T5otGixY0qFOXbgXAQCAAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+filenew22:file file22 22:photo:22 22:R0lGODlhFgAWAIUAAPwCBExOTERCRDw6PCwuLBwaHAwODAQCBOze1NTW1OTi5Nze3MTGxLS2tJyanPz+/Ozu7OTi3BQSFCwqLDw+PDQyNFRSVPTu7MzKxLyyrIR+fCQmJPz6/NTOxPz69Pzy7PTu5Pz29Pzu5PTq5PTm1My6pBQWFPTq3PTm3NS+rAwKDPTi1PTezOzWxMy2pPz27PTazOzSvMyynOzaxOzOtPTaxOzKrMyqjOzGpMymhPTizOTCpNzSzNTGvMymjMSihCH5BAEAAAAALAAAAAAWABYAAAboQIBwSCwaiYGAYEAgFAqGg/Q4DCASCsTiymgcHAcqQLB4mM+QiIQBppLPcMjkwQ4bB2X4maKgt4sVCHpnFhQTElNFE3mDDxcYGRp2RBuMgxwIHX9EBZZwHh8gCBmTQ52NISEiIyQlpUImng8hHyInKAgprwAqgnC0IKwrLLpGB4wctLYkwy0uuwd9Z8AnJywsLcVFx2YcL7UnJCwwLTEy0GXJoSgrCCwzNDTnxgjeH9UrKzXwNDY36LRGhEOwLx4NHDmgJbh3QoeOgv127EhojEeHDj16pEhRQoZHHzl+QJNCsqTJSXaCAAAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+fileopen22:file file22 22:photo:22 22:R0lGODlhFgAWAIYAAPwCBAQCBCQWDCwaDDwmFPSubPzGhPzCfPy2dOSmZPzKlPzSnPzOlPzKjBQODPzChPzWnPy2bPSmXPyuZOyeXIRSLEQuFEwyHEQqFDQiFCweDKRuPFRSTPT29PTy9Ozq7OTi3Nze3NTW1MzOzMTGxMTCxLy6tLSytKyurDQyNMzKxOTm5OTi5Nza1NTS1MTCvLS2tLSyrKSmpJyenJSWlIyKjHx+fFxeXBwaHKxuPMzKzLy6vIyOjHx6fDw6NPy6dGxubLy+vISChCQmJNza3KyqrBQSFLR2RKSinJyanGxqZAwGBJSSlCwqLAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAWABYAAAf/gACCg4SFhoeDAYqKiIeLj4wBjQCMhY+NkoiLk5qbhQIDoJyGBAUGBwgEo4MECQoLDA2pDrS1tKQPEAwHERITE77AvxKqhAQNDA8UFRYXFs8YBAQZGqGPxw0RGxwdHR4eHyAhIiMkJSYnKCgpBAYPEhcqHyssLS4kLzAxMjM0NTY3cBA4UCAHBw8gVnhgEcKFjhc7UPDj0cMHAAI/KFgY4YLFio/jRpTYsW8GDyCSCEQw2DChOHIqgsCQSEPIEEEEJFhAoUNECCJEyOk4d6KIyRtGcB7hIJKjixEjHu4oimSGEIs4d8IIUoKECnNB0ElMwkNJJgBLlJBAcQKGiR07KGAURVGViY0mhIwwSTKjr99+THjUoIg0r48hTRIrRtxkiOMhDgrZCQQAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+fileprint22:file file22 22:photo:22 22:R0lGODlhFgAWAIYAAPwCBFxaXDQyNFxSTPTizOzi1FxORDw2NExKLPTi1Pzy9Pz6/FRWVPz29Pz2/PTy7PTu9OzezPzu5OzavAQCBPzy7PTm3OzazOzKrPTu5FxSRERCRGReXPTq5Pzu7ExGTMS+xKSmpOTKpPTq3JSCDNzSfHRydLyadOzCjOzOtOzSvLyyTMTCxKSipGRiZFROLPz+/KyurJyenJyWnGxmbLSabOzClOzm7LSutJSWlJSSlJyanGxqbNze3OTm5IyGjNTO1Nza3NzW3OTe5IyKjHx6fMzGzMTGxMzOzNTW1IR+hISGhKymrLy6vLSytERGRGxubKyqrLy2vLS2tDQ2NEQ+RASKBAT+BFxeXHRudAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAWABYAAAf/gACCg4QBAgOEiYqEAgQFBgcGi5MICQoLmAQDh5OEDA2YCw4ODxARApKUCaGYEAsSCRMUnQysCwoVEhYXGLOLCBCgDqK5GQUXGooCAhscBB0euBUZEAUJvQgIgx8gIR8iCSPiHuIFEREDJCXaANwhJhsnKCnWERcRKiopFCvsBywhQrRwQWGAPAz5EhpQ9wIABRgKYsiYMTEEDQocatiwkUIEP18fbkCAAcMBjhwzdOyQwYNCgBMfKJSgMItBjxs+btwgCSGGjhw/ZoRgQKGZCRMUPgABEgSIkCE3SZok8qNqkR85NtDUEcPIkaVAkCR5SrJBDCVKlmzQ6pCCiRlMTJo4YUH3K5AeMBYYWctW0BOaUH60cBJFypQmII6wyEpFQBVFMSm4UAI3hJUrOGh8oOJrklYKWIromJGDR99Ogz5j4ZGlM+pEnwmBCwQAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+filesave22:file file22 22:photo:22 22:R0lGODlhFgAWAIUAAPwCBGxqbAQCBLy+vERCRExKTHRydIyKjMTCxFxaXGRiZFRSVFRWVPz6/Nze3Nzm5Pz+/JyanDw+PExOTHR2dMTGxBQWFLSytHx+fISChOzy9Ly6vAQGBJSWlMzKzAwODJSSlHx6fIyOjOTi5DQ2NISGhGxubCwuLOzq7ERGRFxeXNTW1CwqLPT29Dw6PGRmZKSmpAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAWABYAAAb/QIBQGBAMj8ikUDAgFAzKKCBwQCQUCcICKh0SEAhGw5EIZAmBrgCxeDQgcDJWyz0GIggJfL+XGwQJRxNgC3yGDwwUFUZDFhdthnwMGAZNQwEZFwQakXANBBQbHIIdERIBnRAOiR4ERx8gsSEMBBmGCyEGG3YGBwcgIr8UCwQHECOgG4xCtRkEJAvBJRklJgkSFBQeJ68hJiEoESkFKiEZIbkGARsLlwEGExENGhorGSkpFAYm66NDLAECpGiBYsUIFA8wLHBBQMWLVkdUCFCwaYVFBOymkVCgYEMgOykEpICBccMBAhhELFigTEqAAgIIwCiQ4eRKDyS6EAlJIAI0EpaudF4iIKDAAn9CkRT5eMROEAAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+foldernew22:folder folder22 22:photo:22 22:R0lGODlhFgAWAIYAAPwCBNzaTPT2FISCBCQaDPz+BExKBDwmFPSubPzChPzCfPy2dPz6BMzOTAQCBOSmZPzKlPzSnPzOlPzKjBQODPz+rPz+3PzWnPyuZPSmXNyaXPTyhISCLIRSLEQuFEwyHPy2bKRuPFRSTPT29PTy9Ozq7Pz+xJyanDQyNPzGhMzKzOTi3Nza3OTiVBQWFDwqFKxuPOTi5JSSjISChHR2dGRmZFxeXPS2dNTSzNTS1OTm5KSipLS2tLSytKyqpIyKhGRiZNze3NTW1MTGxMTCvLy6tIyKjCQmJMTCxMzOzMzKxJyenHx6fLR2RLy6vJSSlHx+fDw6NLy+vIyOjAwGBGxqZKyurCwuLBQSFJSWlCwqLAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAWABYAAAf/gACCg4SFhoeIiYqLjI2MAY6HAgOHBJYEhJCDBQaDmgcICQoLB4MGDA0OAQUBDg2cAAcPEBESE6QUuQasFRYVq5SxCRcSCggYGRjIGgYbFs8bHIMHExIJGR0eHx7cB83PFhsDDuTUEyAhIiMjJCQluwEmvsAnKAcp1x4qKyUrLLupWrByxcnFiwQIYIggEaNEiRgBZMyYQaNADRs2REA6cCODBxw5+OnQgWMHjx4+BND4MQOIg1gI0gUREkTHiplDhhApEoCGkRlHBL3I8MEHEhz+WAhJogTJySVMfthwIehAExE5jubAkYQpESc8fOx4AiXKNA8+ekhBgqSpzh5hPHcsmVLjpSAqVZBY6VGkiJMiPQKLnTvjCiEsWU4o3nGC8YksMmT8YCmC6iAXKLRc2cz5yGYtR0JjKWQgEAAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+mailforward22:mail mail22 22:photo:22 22:R0lGODlhFgAWAIcAAJR6fIxydIxubIRqbIRmZHxeXHRaXHRWVGxSVGROTFxGRFxCRFQ+PEw6PEw2NEQuLPwCBJR2dLyijPTixPz69Pzq3Pzy3Pzu5PTu7Ozi1LyelOzavPz+/DwqLLyafPTmvPz67Pz29Pzy7LSWlPzmzPz6/LyajPTitOTSzMyurPz25PTatPTi3KyOjPzuxAwqVDQiJHxiZPTetKySlPzqvPz27BQ6bAwmTPTexLyinNzGxDRunPzy5KySjCQ+ZNzq9KTO7JzC3Nzq/Ozu/LzW7FSm1BR6vGSWvFyq1AyGxAxytAx6vBSKxAxSjMyujLSunES+5BSi1ByGvAQCBNzCrOTaxNTOvMS6rKyelCx6rBx6tBQKDOTWvPzu1PTq1OzezAQOHAxGdBROhAQGFPzy1NzOvIRqXLyynOzarPz21Jx2XPTWrLSShAw2XKSCbPzuzAwePAQCDPzyzPzqzPTmxOzWtAwGBKyObOTSrNzGrKyGbOzatEQyNKyCZOzWrOTGpNS2lCweHCQaHCQWFBwSFBQODAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAABAALAAAAAAWABYAAAj/AAEEEDCAQAEDBxAkULCAQQMHDyBInBhBwgQKFSpY0HgBQwYNGzh0mDhRAAUPHziACEGBpYgRJDiUGEkSwoCQJk6opNASRQoOFETQJDkggwoOJlYApcCihQuVL2DUhBDjhIqjJmRwwDCDhswaNm5MjYHjKggOOU7o0CGTA9gdYknG2KCCBw8VJVL0uBgihAUfP+CSNGCjsI/DiBPbAMJBsEQbQYQM+UG5smUiRYw0jlvYxhEkSYyIHm1EyRLTTH40EZvAyZPOR4pAmU07ipIkUKQ0mQIhAZUqVq5gKXzkSBYtyLVEyd1ki8QFXLp4+WJFQowbYLJnD5NbzJiJCjaQnhnvpYwZM0/OPFlvQ/f3iQvQpBlvQc0aCWy4VKnCpY0Y5yQxgEYXZFjghgwZUOHGCW90YQEccUwloBwGyjAHHXUoSAMZb0xhx1QOoMHDHSfIwSEOdTjhAQ1d4MFbTQ6Q4MYacrzxhhx04JCHHhvQsMeLJPHRBxpr+LHCGnusgccfgKixQR1ATtTBlDDAEIggggxCCCGFbLGFHVFKZEdAACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+mailget22:mail mail22 22:photo:22 22:R0lGODlhFgAWAIYAAPwCBBQ6bCQ+ZAwePKTC5Ozu/NTi9GSWvAwSJGSu3JS+5CR+rAQOHPTy/AyKzES23AwOHCw+bOTq/BR6xES+5AwmTBw6ZMTW9Ax6tByi1BRGdAw2XAQCBDQuNDRupKzS9FSm1BR2vBym3EzC7CSGxBROhNTW1Pz+/OTm5NTO1AQGFNzW3Ozq7Ozm7IyKjJyWnMzOzNzq9Nze3OTa5Ly6vCQiJGReZISChKyqrAwqVBRWlOTi5MS6xJSWlNza3OTe5Ly2vGxmbKymrIyGjMzGzISGhKSepCQmJDw6PHR2dJSOlPTy9MTGxLy+vLS2tMzKzLSutMTCxLSytKSipJyenKyurJyanCwqLCwmLCwuLAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAWABYAAAf/gACCg4IBhgIBA4SLjAABBAUGBwiNlY4FCQoLDJaNAQ0ODwsQnYwREhMUE5ylFYYRFhcYGRgaGxsDHJUdFR4SHyAhEyIjJCUcuo0cJr0nExihxgwoyYscKSnMHicOIw4lKissLdWDHC4vMCu9McYqMjMyNOUANTY3OPEoOTolDCszdrSgwaMcBxs9TMxYOCMHBx8zfPj48QNINQ5BbMBIIUShDIUoTAhR94PHPEEHbQwZckOGjBQviMxYUWQIDCMmdXE4gqRnkiFETAxR8iKFjJU2evZEdmLJkgJIbqS4wXJIUapImj5FtuSEVyRVV1IVi4RIChhEkLVAgcJHEqVwVJUmYdKkiRNkALMRecKECRG/ff8CEQJFCA5kMKJEoUHDCQ/HkB9LmWKECpUeyKoIMSLEyosen0OD7iH2xg1dV7BkqXGlBpbWNTq4Zn2khu0aAAwEAgAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+mail22:mail mail22 22:photo:22 22:R0lGODlhFgAWAIYAAPwCBDQyNCwqLCQiJBwaHBQSFAwKDAQCBDw6PPz+/Pz69Pz27PTy7PTy5PTu5PTu3PTu1PTq1PTqzOzmzPzuvOzitPTmvOzivAQGBDw+POzevPz67Pz25Pz23Pzy1PzyzPzqvOTavERCRKSilPz21OTevIR+ZExKTOTi3JyanLS2tPz6/Pz65KyihJSKbMS6lExOTNTW1JSWlJSKZMSylNTOrNTKpFRSVPz29MTCxPTmzKymjIyCdOTWxOzexOTWrBQWFFRWVOzu7MzKxJyalOzatLSulMzKtOzmxOTarFxaXKyqnPTmtIyGdIR+bOzetOzixBweHGRiZOzm3NzWzNzSrOTetGRmZOzizOTexOzm1JSKdGxqbHRydJySdHR2dOzapHx6fKyijOTixCwuLHx+fFxeXERGRDQ2NAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAWABYAAAf/gACCg4SFhoeIiYqLAQECjwORAwSUBZYFBpkHmwgJCgsMDA0OD6UQERITFBMVFhcVGBkangq1ChsLGxwcHQ0dHR4fICEGIiMSCbS3uLq8wCQUJSYGJygpKhQJKyvLLM4Nwi0uLwUwDQsxMtmeuQveHR8UMzQ1NgU3Dgo41jk6ns0cKOzgYaOHjx9AgjTAUUvIECLZNmxoUISHkSM9KiBJQkCJA4kKEoBQoWJJAiYtmjh5AmVCsCJRpHzckKCCySlUUvBYUqUHDysSPnxIEuXKA5pPRiRwxwFLFhRaIEDYUoEChCcDuECoOWKFuwW7nHkg4WELkw8/BHRRwESpt10dU8SSHevlRxIBX6C0WBE27q8GZMkKbTADjIAwYlb4GLMYShYoPTRo6FGiSJEKPyzMIFMmzJcvXbhwkSLFjJkbQW6cOHNGhAgEAdAsmk27tm0ABgIBACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+mailreplyall22:mail mail22 22:photo:22 22:R0lGODlhFgAWAIcAAJR6fIxydIxubIRqbIRmZHxeXHRaXHRWVGxSVGROTFxGRFxCRFQ+PEw6PEw2NEQuLPwCBLyejPTixPz29PTu3Pzu5Pzy7Ozi1LyelPTavPz+/DwqLPz67PTetPz69ERCRLSWlPTmzPz6/OzexLyajPzqvDw+PDQ2NMyurDQiJPz23PTatJyenAQCBPTevPz25LSajOzq7HxiZPTexPz65JyanBQ6bKSmpBwuTOTi5OzaxBRCdHySvGRiZHx6fBQSFERGRNzq9IyOjHx+fGxqbPzu3BwaHFSq3Aw6XAxKfPzy3Gy63ByWzJzO7Mzi9OzavBRytAx6vCSazGRKTPzy1AQKHBRGdBRyrDy63ES+3Cym1CR6rBwWVAQSLAx+xCyCtBRmnPzuzAQWLAwePPzyzKSCbAQOJByGvOTWvPTmxBQODFQ6PPTWrPzqzOzatAwGBKyObLSWfPTivKyCZEQyNKyGZOzWrOzWtOTSrOTGpNS2lJx2XDQmJCweHCQaHCQWFBwSFBQKDAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAABAALAAAAAAWABYAAAj/AAEEEDCAQAEDBxAkULCAQQMHDyBInBgggoQJFCpkzGjhAoYMGjZMpMghQgcNFjh4mODhA4gQGkSIHAmBwAgNJEpo8KDSxAkUGjhMSEGz5gUVIiKs2PmBRQudHiwQpUnAxYsXImB0aBqjBcuoU0fKmPGChgUNH2qIqGHjg9u3bicWIFs2rYgbNnDkyGFhb8cccQ3ouJqWQo0dPFr0WMy4h48LFj4gsKriB5AeNngEaSGks+chPnwQOXFAh4oXRYxk9nAEyY7XO2wksWHDx5ATCDIoUXEBsYclTJo4cWJhuIjhSXacSPBEiZLMQY4wgRKluvXqUpyIsDElAxUqVaxcwcGCPQuWLOixaNHCZAsXBU+oqKDSxQqULF6ifNmyn/8VMOtxwcAK36kQRhdJQIFFEmKM4eCDYGyhhYAEkqFEGSuYYcUZLaDxXRpqSNRCEu6twYaFZXTQhgRd2NCCG9918AYELTjoXgNuKAFHB2RQEUYHVbQQRwlUpPHGGFwkyQUEDsgxx4lh9BhCBy2U8UQJcrSg5JIQ0FEHG3bc0QGYK+CRhx57PEGlkhM9sAEffKTQhx9+/AEIIIGoEUgLLRRFR0AAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+mailreply22:mail mail22 22:photo:22 22:R0lGODlhFgAWAIcAAJR6fIxydIxubIRqbIRmZHxeXHRaXHRWVGxSVGROTFxGRFxCRFQ+PEw6PEw2NEQuLPwCBMSihPTixPz69PTq5Pzy1Pzu5PTq1Pzy7Pzu7Ozi1LyelPTavPz+/DwqLLSajPTetPz27LSWlPzmzPz6/PTexPz67Pz29OTSzMyurPz25LyajBRCdPzuvDQmJOzexPTevOzq5BQ6bBwuTDQiJHxiZPz23Pz65LyinPzmvBxCbHySvAQCBOTi3OTq9CweHOzaxFSq3Aw6XGy63ByWzJzO7Mzi9OzavNzq9BRytAx6vBR6tPzy3AwOHDy63Ax+xCSazCym1CR6rBwWVOzizAQSLES+3CyCtBRyrBRmnGRKTPzu1MzGtAxKfAQWLAwePPTizMy6nByGvNzWxOzWrNzOtBQKDJR2ZNS2lPTmvBQODPTatKSCbOTaxLyqlAQKHFQ6PPzyzPzqzPTu1PTivOzWtKyObPzuzOTOtLSWfPzqvAwGBKyCZPTWrPTmxNzKrEQyNOzatOTGpJx2XCQaHCQWFBwSFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAABAALAAAAAAWABYAAAj/AAEEEDCAQAEDBxAkULCAQQMHDyBInBgggoQJFCpYuIDBQgYNGzh08DCR4oQPIDqEmDBhJQYRIzqQIFkSAoESJCKkDGFiwgkUKTpMwECz5IASKjqsSMlSA4sWQjG4qGnzhYoQSmF0iCFjBgmWGWhQrVHCxg2sOHLo2MGjB0sLYmsWQHq1p4wdPtqemGDhB1UDQFSouKHi7oQgQmSwUMyYxcQDZQWz2EFiCJEiRoyQyLzZyGIIB47YKLwDSRAiSZSoXq1kCRHNLBK8YGKjCYskTp4ogeKkt+8oUaBImZKAAxMmVKrctqL7ihTnz7FkAT5FC4cKFbZwadIFdxcvX8KLss8iJcoUBUcq2KgAJoxyMTy4jCFTxoxEHl2GLyCDncmWM2hUIQMPY2CXhhoTfTEcA2tgVwEba7Thxhs88FdBD/ZB8MUUHMJBRhw2sAGCHBKU4UaFc1RAhxnhcdhhHUzYAUIcFdxRAh4R5KGHinu4OIVEDqTBRx81xhGHHzD8wQYQetDRI4cTAcIHGWT0EQgZa1ApCBqDcBAID1Q94IEHLtBAAyGEFGKIIWqYYQYPYNZkQEAAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+mailsend22:mail mail22 22:photo:22 22:R0lGODlhFgAWAIcAAIR6fIRydHxubHRqbHRmZGxeXGxaXGRWVFxSVFxOTFRGRExCREw+PEQ6PDw2NDwuLPwCBLSijOzixPz69PTq3PTu5PTu3PTu7OTi1KyelOzavPz+/DQqLPz67LSafOzetPz27Pz29KyajPTmzPz6/NzSzLyurCwiJPz25Ozi3JyOjPzuxBRGbAwSHOzexPz23KSSlPzqvBROdISavBxSdAwaLHRiZLSinNTGxMy+vBxGZNzu9BSGrAwWJMSyrKSSjFy61ETO3BRWfPz65PTqzHTK3ByqzBSWxEzW5AQWJOTWxBRCXOTu9BSOvDzO3ByavBRKbOzaxOzizKSWlCQ2TAQCBJza7BRWdNzSxJSCbMzq9BSOtCSKrAwiPOTavPzy3LymlCySrAwmPFRKTPzy1NTGrPzu1JR+bOzatPzyzCy61ByGpOzWtJyCbPTmvPzuzIS+3FymxCSuzBR6nJyCZOTWvKSObMSujOzivAwKDOTSrNzKrJyGbDwyNOzWrMy2lIx2XBwWFBQSFBQODAwGBAQGBAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAABAALAAAAAAWABYAAAj/AAEEEDCAQAEDBxAkULCAQQMHDyBInBgggoQJFCpYqMDxAoYMGjZwmEixg4cPGzqA6BBiAggRIzaQGEkSwgAMJCKgnNBhQogSJlKGOFHTpgYUG0TsnJBCxQoSE1i0KErAxYsOJJRuuAAjhkwZM2jUqGnDBQoUHTbciIEjx4YNOmbs4CGjB8kCZlGAALHBx4+YcTcACcJDyFSJBo6iGNIhhQkiG8BOKGLkCBK6SSQisHoWhZIbG5bMYALECI8mTZw8gTL1QJQXZ6VMiUylSpUlVpoYaXLFtm0EGmCjwJLlA2O9MrRsccKlC8kEXr7AdgEmwtkhX2SQ2BIkjBiSYzSQr/nyhUKZLIrJJOcexvlEBV7IvCBjRkmAMzHOaufhxDvJBWiQISAFxUUQQRovJNeEGmu4JxEDbKQhXxsfuFDGGW68IQMcccgxRxUkNRDhC3R8QMQIdZwXQ11JJGFbiB+QYccHaaTxhgt13OFBDGTgkUdRDrhAhx5k2JjGCB/swYcXMXwAYk190OGHHx/4wUaVepTxByAaoPEkSQ5wwMEJZAZipiCDDJIHIYV8OZEdAQEAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+nav1downarrow22:nav nav22 22:photo:22 22:R0lGODlhFgAWAIUAAPwCBAQCBBQSFAQGBDQyNExKTHx6fGxqbFxeXGRiZFRWVDw+PAwKDJSWlOzu7LSytJyenJSSlISGhISChIyOjFxaXDw6PPz+/MTCxLS2tIyKjKSmpKSipJyanAwODDQ2NHRydERCRFRSVAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAWABYAAAZzQIBwSCwaj8ikcslsOp/OgHRKlQoCgymRUDAcEIkwYgxWFBYERpHQcDwgEclEQmk8DhWL2kiIXDBwExMNGRoJaUkEEH8bEQ0cGgcWAksEHX8QHBKSHk1sfxMHH5ROBBsOICGkT2wiq1CIULKztLW2t0h2QQAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+nav1leftarrow22:nav nav22 22:photo:22 22:R0lGODlhFgAWAIUAAPwCBDQyNAQCBExKTJSSlHx6fAQGBOzu7GxqbJyenPz+/LSytFxaXMTCxGRiZKSmpISGhFxeXISChAwKDFRWVHRydJSWlBQSFERCRIyKjDQ2NIyOjLS2tDw6PBwaHFRSVDw+PAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAWABYAAAZ5QIBwSCwaj8ikchgQLJGBgfNZDBAKBirRekBMtYGEYsHIgsWNhOO7tCrShDU18Hg/CJAIG0o4wCUQcksTFBUSCRYSEnpUFxgIGQkJGYyNGggbHBaVjR2QCxEeWkITHQ4IH3tPFwEMA2ajAKUgqlQTTbFEE7W5vUgGQQAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+nav1rightarrow22:nav nav22 22:photo:22 22:R0lGODlhFgAWAIUAAPwCBDQyNGReZAQCBMTCxGRiZMzGzOTm5LSytPTy9Pz+/CwqLOTi5Ly6vCwmLMzKzJyanJSSlBQWFKymrIyGjCQeJJyWnISChISGhHx2fKyurDw6PAwODHx6fHRydDw2PERCRAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAWABYAAAZ2QIBwSCwaj8hkMRBQKgOCgRMZIBSk06XhEM0SA4iE4uoVLhCMhqLrdSAekMgYO5VM4BQ521mxIC4UFxBWdEkSERYYFxETGQGFSBKCGBEaGRuQSBwdeZaPXpsQCB6YZQMdEI6ZSgMepKusHh+wrCC0rLdlursGQQAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+nav1uparrow22:nav nav22 22:photo:22 22:R0lGODlhFgAWAIUAAPwCBAQCBFxeXDw+PMTGxHRudPz+/JSSlLSytIyKjHR2dISChIyGjIyOjLSutLy6vKSepJyanISGhJSOlOzm7Ozu7MzGzKyurJyenDQyNGReZKSmpIR+hCwuLCQiJBwaHBQSFAwKDAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAWABYAAAZtQIBwSCwaj8ikcslsOp9QYyAQFQYEAyr0Sihkn1fDAeHVLsOJNELxVaITC0bDUU6GH5AIQ8KYrNtFVxQVFBYWFxgRCREYdUQZGhYEDwgIGxAHCQocCgWOQhmhGR0epR8gqCFTq1Wtrq+wsUt0QQAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+nav2downarrow22:nav nav22 22:photo:22 22:R0lGODlhFgAWAIUAAPwCBAQCBAQGBBwaHDQyNExKTHx6fGxqbFxeXGRiZFRSVDw+PAwKDJSWlOzu7LSytJyenJSSlISGhISChIyOjFRWVDw6PPz+/MTCxLS2tGRmZDQ2NAwODJyanKSmpKSipIyKjHRydBQSFERCRExOTFxaXAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAWABYAAAasQIBwSCwah4FkQKBsDpoBIqFgOCASCYRWm1AUFgRGkdBwPCARiWRCaTwOFYvYSIhcMOiJpJGZaDYcR0IEHXceEQ0fICEWIoJDhHcQHxIHgI9SEHeVG46YUh8OISOen1INCqWmUnOYTUxQAU9NUlRWWFtbCiRgrYNlZ2lriG8lYUd1khETE24gCZeCkRgeFBAQIAeNn9OTlXKrBJoYnKrcoaPmpmSpq3S+7u50QQAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+nav2leftarrow22:nav nav22 22:photo:22 22:R0lGODlhFgAWAIUAAPwCBDQyNAQCBExKTJSSlHx6fAQGBOzu7GxqbJyenPz+/LSytFxaXMTCxGRiZKSmpISGhFxeXISChAwKDFRWVHRydJSWlBQSFERCRIyKjDQ2NIyOjLS2tDw6PBwaHFRSVDw+PAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAWABYAAAavQIBwSCwaj8gkMiBYNpeDZzEQXRIKBmPgmtUSDgipcAsWjxOKBaN7Tq+n6EbCIQ3E5+KtQk6gjwl7CX11D3sPBBARTQGFDYeJT2R8EhB0koKUfgATFBUSCRYSEoqcnqCiikMXGAgZCQkZqautr7FiFxoIGxwWqQC4ury+qh2tCxEexMbIRhMdDggfYs7Q0kcXAQwDbELY2txEziBmmx3jSRNMR+nk4e2b70ry80QGQQAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+nav2rightarrow22:nav nav22 22:photo:22 22:R0lGODlhFgAWAIUAAPwCBDQyNFxeXAQCBMTGxOzm7CwqLLy2vPTy9Pz+/Ly6vCQiJLSytLS2tLSutOTi5MzGzKSepIyKjJSOlKSmpMzKzJyanIyOjBwaHIyGjISGhJSSlISChBQSFJyenIR+hGxubDw+PHRydHR2dEQ+RHx6fERCRAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAWABYAAAa6QIBwSCwaj8hkIIBcJgEBweAYnTYJUmMAa9USClniFtwlGg6IRFhoUKTXwwWj0FB3F46Hwl6UQyISfAB+EROCQgsUFRYSF3yJEIyBaxgWDBkaGRtclQwSHBIbEGEdGx4fGhcOICEDGBsWHBmqIq1CHRIWGRMMIyRTHRy6Er22tyONq8YdJRe0xkIDwr2/QwMfliMmZQADIxasZd4e4UYDIr7c59rc0eVFA+/m0EQD9PDt0flP/P3+BkEAACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+nav2uparrow22:nav nav22 22:photo:22 22:R0lGODlhFgAWAIUAAPwCBAQCBGReZDQyNMTCxHx6fPz+/JyWnKyurHx2fDw6PJSSlISGhIyKjIyGjISChLy6vJyanOTm5PTy9OTi5MzKzLSytKSepMTGxMzGzLS2tLSutKymrHRydCQiJCwmLBwWHAwODLy2vHx+fAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAWABYAAAajQIBwSCwaj8RAAMkUBgSDZdP4JBSi06TAcEAkFNLp07BgLLzY5njRcDzO3zB1C4lEGI83Wj58SiYUFRUWdg0XEXFFAwIYGRoWGxwRZQUFHZdgRAObmx4fHiChISFKpVlKWUdPaalOAlasp1sHG4myZGZ7Yltsbgu1mUhjdRF5egmxfQJ/gYOFdrZDi40iFgiSCw8jBQmYcpydn6Ego6WorUwGQQAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+navback22:nav nav22 22:photo:22 22:R0lGODlhFgAWAIUAAPwCBAw2VCRGZAxCZGyavExmjHyatOTy9CxihISevPz+/KzO3BRylAw+XAQCBDRWbPz6/FzC3CSuzDyexJzO5Mzq9CxSdAQOFISmxNzu9HTS5BSmxAyexDSuzJTa7Mzu9Kzi7GS21CRmjAQOHHSWtLze7AyWvHzG3BRihAQKFCTO3BS+1AyixBSWvBSOtBSStAQWJBSixDzW5BTC3BSqzBS21CTC1ETW3AQSHEze7BRqlBRmjAQCDBR+pBRefBRSdCH5BAEAAAAALAAAAAAWABYAAAalQIBwSCwaj8ikMqBcMpvHgGAANQYIhWdVGDAcENQtIJBQLBgNx0MQaDuQXcghIplQDhBIxXKJYiAZGhscHR4VHyAhIiNWJBklGhIbJoQnFCcTKIxFKSgbKissJi0mJi4vLiYoMEcXKDEyMzQ1Nje2NisoOEg4KDU5K6g6OwwoKAN9SCOeMmgwz884PEq9PT4NYkPLP9jZQikN3d4AKVrjKePp3gZBACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+navdown22:nav nav22 22:photo:22 22:R0lGODlhFgAWAIUAAPwCBAw2VCRKZDRSbBxCXJTC1Mzi7Nzq9NTm9Bx2nAQCBNzu9JzG3Hy+1HzG3IzO5BRmjPz6/LTe7Dy61AyStCTC1FzC1AyGrETS3ETC1ETa5BRulAyuzBRylAw+XMTe7Gy+3CSqzAyexBTC3DR+nIS21KTW5Nzu/KzO3FzC3Pz+/ByixEze7AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAWABYAAAaRQIBwSCwaj8ikcnkMBAQDgjPAFAYKhsMBkVBUAYEFo+F4QLzVQEQyoVTOX/XBcsHA0+vMRbNBMwkRDhxuHX5GTlIeHh8gISIjFAEeiVRECiQlDAUmgxQjIhwiJHdFlycoKSIUFCEjGiGkRpcqCxYijxorsUezcxYsuoZJsxLAu0qXB7DCTJfHVQrMX9PU1Uh0QQAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+navforward22:nav nav22 22:photo:22 22:R0lGODlhFgAWAIUAAPwCBAw2VAQCBBxCXDR+nIS21Aw+XJTC1Nzu/KzO3Pz+/Nzq9Pz6/MTe7KTW5FzC1Nzu9CRKZMzi7IzK3Lzi7LTe7HzG3Gy+3AyuzAyexFzC3DRSbHy+1Dy61CSqzAySvAyStLze7IzO5AyGrETa5ByixBRmjCTC1ETS3BTC3Bx2nAyWvEze7AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAWABYAAAaYQIBwSCwaj8hkMqBsBgTN5IAAjRoDBaq1aDggtMuAWDzoJhTgY+CwYLgZDccDwkgXI5IJZVGxXDAZGnR2QxsLHB0PHRgeHyAZDyFfVUQDCyIgIyCPIB+QJCUmlEMBEiInKCQnKSkeKSQeomoqJrUmKiArKSwZsmoCwMEBGCyxo1EGHr3HUQEEvltCBtDRAAbMW0zV29xDBkEAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+navhome22:nav nav22 22:photo:22 22:R0lGODlhFgAWAIYAAPwCBAQCBCQiJNze3ERCROTi5MzGzLy6vDw6PKyqrKyurBQSFGRiZGxqbGRmZISChEQ+RExKTExOTHRydDQyNOTe5FROVLSurCwqLMTCxPT29Pz6/LSutFxeXLyytLSytPz+/JSWlKympPTq7KSipNzW3BwaHHx6fKx2VJRWNHQmBFweDOzq7Ly+vNTW1JxWNLSajPTe1Ny6pKxWJNTS1IyOjJRmbPTi3OzKrNSSXMSGVHQiBHx+fJSSlPzy9IxOVOzWxOSyjNSCPLxeDJyWnIRGTOTGtMxmDLRWBHwqBIxGTLRSDDQuNNSunKxKBGwyNMSafMxqHMReDKRGDPTu9LxuPLxaDJQ+DIR+hGQqNIQyBGQiBNTO1EQKBAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAWABYAAAf/gACCg4QBAYSIiYQCAwQCiokEhwACBQYHBAiQhAiHlQYJCgkEC5uCkp8MDQ4NDwylmwgQlgQRERIEBBOkmxQVBgQWFwUFFxEEDLyJGAUZtQoFGhsFHLYdyoOVHsEf0SAbIAUex8mwlAUhtSIFG+3uIyTWvAIGJMEkJe76GyXbEeWUBJg4USKaBhQpVKzYoIFFiwYUBBJa8MAFCw0vYMSQMWOhBhoTKCQSUKMEiw02buDIoWOHBg0GeIhEFKAHDR8afgAJImSIioYliMws1MPkhiJGchxBkmTDCBo1hg4KQMTiBiUyhBxZ8pNFiR5MEtU0WqSJVidJNDyNKraHC5xPNKBEkTLlJ5WvUgWNvfikyhArV34+7ZEXQAAsB2iUyHLlihYtW0pwOYAFgyJDmDNr7jIIWiAAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+navup22:nav nav22 22:photo:22 22:R0lGODlhFgAWAIUAAPwCBAw2VAQCBHSWtBRmjAQOHISmxNzu9BSmxBRihHyatPz6/Lze7CTO3BSixHTS5BTC3DzW5ByyzPz+/OTy9AyexEze7ByixGyavKzO3FzC3AyWvBS+1BR+pAQKFCRGZExmjCxihBRylCSuzBSWvBS21BSOtBRSdAw+XAxCZDyexDSyzCTC1JzO5JTa7DSuzETW3BRqlAQWJDRWbOT2/Mzq9HzG3JzS5Kzi7BSStGS21CxSdCRmjAQOFAQSHAAAACH5BAEAAAAALAAAAAAWABYAAAaeQIBwSCwaj8ikcqkMCJjHwIBQgBIDhgMiUbUGFAtGw0GFfheHByQi4S6/E8pDUoFYLm5kAEPJaBAVGxIcER0JHlEfICEiIxUkGyUmIgknKIhXASkonCorgSwmKQGcKE9IAi0uLxUwMTJWMzQ1NiYwBLBQHws1N7avXgs4NjkcCblMATU6KhvGyG87PAnUKV1MAj0+2zIFp1bg4eJJdkEAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+playeject22:play play22 22:photo:22 22:R0lGODlhFgAWAIUAAPwCBDQyNAwKDJSWlFRSVBQSFKymrOzq7HRydERCRPz+/MzGzISGhJyenKSmpGxqbJyWnJSOlKSepLy2vIyOjGRiZPTu9IyGjLSutFxaXExOTHx2fGReZAQCBAQGBBwaHCQiJLSytKyurJSSlFxeXNze3LS2tIyKjFxWXHRudAwGDBQOFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAWABYAAAa1QIBwSCwaj8ikcqkMCJjHwIBQgBIDhgMiUbVKFQsGItBdBhpgh4PxIJvRC8cA4oiMy8bvQhJhMAYTFBVOURAWEw0QFxcMERAYCBluVxobDxkVHJocmBwEGgmEQx0dHh0CpKmkH6odVlanBR8FtAIFtiCkSB0LISEiGCIGIxAPDySuRwIOBwrOzwoHJRHJRh0jJgMj2gMnERQUCNVFHQQoCBvo6CkICATjRB0qp7b1K6qv+foyQQAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+playend22:play play22 22:photo:22 22:R0lGODlhFgAWAIUAAPwCBDQyNFxeXAQCBMTCxGReZBQSFOzm7AwKDKymrJSSlFRSVCwqLLy6vPTy9OTe5Ozq7CQiJLSytOTi5BwaHPz+/HRydMzKzKSepJSOlKSipJyanIyGjIyKjKyurISGhMzGzJyWnHR2dISChIyOjLSutDw+PERCRHx6fJSWlIR+hJyenGRmZHx2fAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAWABYAAAa6QIBwSCwaj8ikMBBQKgOCgRMZIBSkxYHWoDVWD9EigpBQLLBERsPxCA8NDUhjgTBGJJNGG02RVBQWdUV3FxgZe0IGfoAGdhoXGxwdiAYef4FGFBoeHB8dGSBRihUhIo1FBhkbIyMkJRYmAwYal4JEBh2RChIWJ1IIGxUZFqdECCgkHR6wWAYpFR2YWSobvL5vFgfDaEMDIivMRBEsD9HcQgMWvecDLB0tZ0btsfJa9vLXU/X6/P3+b0EAACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+playpause22:play play22 22:photo:22 22:R0lGODlhFgAWAIQAAPwCBAQCBAwODMTCxKSmpJSWlFRSVAQGBBwaHLSutOzq7Ly6vCQeJPz+/Hx2fBQWFGxubLSytJSOlBQOFAwKDJSSlJyWnIyOjHRydNze3GRiZAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAWABYAAAWBICCOZGmeaKqubOumQSDEgRjPMSoMRGEcol3vh0IkFAtDDWBEKlGMRKPgEIii0yrqIS1ArADu9KuLNCSOSdCMVp8ohEZFC4DL6SaBpXGh6/l4JX8XZACDhXkYCn1LAoqMUBAZEhBLDJKUSyYBGmhPAJyemiU0NDaloy+qq6ytI8whACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+playstart22:play play22 22:photo:22 22:R0lGODlhFgAWAIUAAPwCBDQyNAQCBExOTAwKDAQGBJSSlHx+fBQSFMTCxKymrFRSVOzu7GxqbLSytLy6vJyanPz+/GReZBwaHHRydKSepKSipGRiZJyWnAwODLSutKSmpISChPTu9ISGhFxaXJSWlIyGjJSOlERCRIyKjDw2PIyOjLy2vOzm7Dw6PLS2tCQmJOTe5GxmbDQ2NAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAWABYAAAa7QIBwSCwaj8ik0hgQLJGBgbMoqBIKU2LAcMgOEQmFYeEFbBmNMgDhYDwWBC0k4pCoJ46IgRIXBioRCRYXamwRGBQIfgaBFhiERhkaenxmCoEbBhyQRYaIGVsdghgem4UWegcEBB8UHhsgIaZGBBgRIpUIIxQhChginEQIIBEklWslFyYnBsFfFCi4WQgpFBwqFxNGKxcsxl4IAS0NZEYCF3vlwgEfUuZV8JEuI2pPAARN9kcE9fr+SwaCAAAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+playstop22:play play22 22:photo:22 22:R0lGODlhFgAWAIUAAPwCBAQCBAwKDBQSFBwaHCQmJJSSlISChJSOlJSWlGxqbGRiZNTS1PTy9Pz+/Ozm7OTi5FRSVIyKjOTe5MTCxIR+hExOTHR2dLy6vLSytLy2vHRydFxWXIyGjIyOjPz2/FRWVHx6fExKTMzOzJyanKSmpKyqrKSipAQGBLSutHx2fDw6PAwODAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAWABYAAAa1QIBwSCwaj8ikcslsAgKCAWEQjQ4KgSwyYDAcugZEQqFYYJECA6PhaLcfEEUkgJZAGJB8fkKpWOhHAxcOGBQZGBoaGQgbHIBGAhUOGR0SBxISBh4Xf0iCHxQSlRIIXhsgj0UCIaCXmJgHGyKpRJ+hmB5dHQqOaCENIx0epBIkBhdzngoPGCQlJifQJBvJRygRKRcKGxcXGypys1srEREc5SLnICLiR1koLFVUWfRO9vf4+UwyQQAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+textblock22:text text22 22:photo:22 22:R0lGODlhFgAWAIAAAPwCBAQCBCH5BAEAAAAALAAAAAAWABYAAAImhI+py30Bo5zBWUWzvNzo33GfFl5jVlonlTrr1DbvFi9vjeeNUQAAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+textbold22:text text22 22:photo:22 22:R0lGODlhFgAWAIAAAPwCBAQCBCH5BAEAAAAALAAAAAAWABYAAAIxhI+py+0Powm0VnknjVkH2AEhE45LZ55Wqn6e65TsMc5eYosbksswubJIhsSiccgvAAAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+textcenter22:text text22 22:photo:22 22:R0lGODlhFgAWAIAAAPwCBAQCBCH5BAEAAAAALAAAAAAWABYAAAImhI+py30Bo5zBWUbz3Sh7yIWfFHKjVl4nmFrr1Lpr7LwkjeeIUQAAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+textitalic22:text text22 22:photo:22 22:R0lGODlhFgAWAIAAAPwCBAQCBCH5BAEAAAAALAAAAAAWABYAAAImhI+py+0P4wqUSlQvttrkDnyaOHIdeaGRupplAIauVM3xjeeOUQAAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+textleft22:text text22 22:photo:22 22:R0lGODlhFgAWAIAAAPwCBAQCBCH5BAEAAAAALAAAAAAWABYAAAImhI+pyw0Bo5zB2UXz3Sp7yG2fFJajVjonmIor2TJvfL0wjecIXQAAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+textright22:text text22 22:photo:22 22:R0lGODlhFgAWAIAAAPwCBAQCBCH5BAEAAAAALAAAAAAWABYAAAImhI+py30Bo5zBWUfz3SZ7yIXdF4kWqZkbCqoMO7kXLC+wVOe6YRQAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+text22:text text22 22:photo:22 22:R0lGODlhFgAWAIQAAPwCBAQCBBwaHAwKDBQSFLy+vLS2tJSWlBQWFKyqrFRSVCwqLDQyNNTS1GxqbFxaXJyanIyOjAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAWABYAAAVcICCOZGmKQSoMaZsShBsQBdAapHvgaIDUqUPJlRjSbAoT0fRDKgODRbF0PLUYjZO2F2Bst9evNix+dsvDlGKK5jraudQb7qbX6a2HEJ+ycyF+LRE8ZTI+fX5oGCEAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+textunder22:text text22 22:photo:22 22:R0lGODlhFgAWAIAAAPwCBAQCBCH5BAEAAAAALAAAAAAWABYAAAIvhI+py+0PowmUnhpeVVnb1DkbCI1I2JhX+Z0sOr2cTHpwK7a4rUr+hAnufsTirwAAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+viewchoose22:view view22 22:photo:22 22:R0lGODlhFgAWAIMAAPwCBAQCBFRSVExKTDQyNPz69PTq5Pz+/OzaxOTKpAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAWABYAAARTEMhJq70466Cl+AMxBVwnFIVRAmQHCIeBrC1L3tQgJ/SaEbeeC1PLBHE2ybFI9A1HzstHEIK6YCmhDTmBybQaHYJn7QC5zKeytIQe1+pKNE6P2yMAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+viewdetailed22:view view22 22:photo:22 22:R0lGODlhFgAWAIMAAPwCBFRSVExKTDQyNPz+/Pz69PTq5AQCBOzaxOTKpAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAWABYAAAQ+EMhJq7046817+MLQUQFRGMc4lQaSAkcMx3QltMmrDrSu/sCgEPgJhIiFk89DaL1qPRnlhsgBebWhdstVESIAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+viewicon22:view view22 22:photo:22 22:R0lGODlhFgAWAIMAAPwCBFRSVExKTDQyNPz69PTq5AQCBPz+/OzaxOTKpAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAWABYAAARWEMhJq7046z2DF0PlBeAVEERhiKhqHgWyUgEsX0KczFOO7JeBYciTCImc5ITIXDKHyqhU9AnRqq9UEVDTvmLbGhin2/qAliOUot5OLc81IO5+2+8WewQAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+viewmag-22:view view22 22:photo:22 22:R0lGODlhFgAWAIUAAPwCBBQSFJyanKy2tLzCxHyChNTa3Nzq7Nz29Nzy9Mzy9MTu9OTy9Nzi5Oz6/OT29MTi5Kzi7NTy9KTm7JzW3ITO1Lzq7IzW5HzK1LS+vMTq7Jze7ITW3GTCzGS+zLTS1MzOzLzq9Kzm7Jze5ITW5HTS3FS2vLze5EzCzEyyvEyutJTa5NTu9ITa5FTK1ESirLTm7Mzi5FS6xEy2vESerESmtFSutESmrKyqrAz+/Dw+RAzi3ASutHRydAQCBAAAACH5BAEAAAAALAAAAAAWABYAAAbKQIBQGCgWh8jksCgYEAaCozIZKBgOiIRiwSgEpstCw/HYQiKRhBcMCBgQDodkMaFU0t9pQHCIyy0TFxgYEVF6GQ4LCQkaERscHR4RH3lUIAkWCyEiIyQlHiYjEJVIAQQJJ2gjJSUoKSorlHoCLBQcHC0lLikvHjCGejEiHBgeMjM0NRwPpFQFDBHFNjceHAjAYFWoI7cnCVE4OWxtex8QH1EBOjs4zUpGUjw6Pe3j2fP19u/47vrq9P3s/avno2BBf/MCClSob4iBIAAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+viewmag22:view view22 22:photo:22 22:R0lGODlhFgAWAIUAAPwCBBQSFJyanKy2tLzCxHyChNTa3Nzq7Nz29Nzy9Mzy9MTu9OTy9Nzi5Oz6/OT29MTi5Kzi7NTy9KTm7JzW3ITO1Lzq7IzW5HzK1LS+vMTq7Jze7ITW3GTCzGS+zLTS1MzOzLzq9Kzm7Jze5ITW5HTS3FS2vLze5EzCzEyyvEyutJTa5NTu9ITa5FTK1ESirLTm7Mzi5FS6xEy2vESerESmtFSutESmrKyqrAz+/Dw+RAzi3ASutHRydAAAAAAAACH5BAEAAAAALAAAAAAWABYAAAbIQIBQGCgWh8jksCgYEAaCozIZKBgOiIRiwSgEpstCw/HYQiKRhBcMCBgQDodkMaFU0t9pQHCIyy0TFxgYEVF6GQ4LCQkaERscHR4RH3lUIAkWCyEiIyQlHiYjEJVIAQQJJ2gjJSUoKSorlHoCLBQcHC0lLikvHjCGejEiHBgeMjM0NRwPpFQFDBHFNjceHAjAYFWoI7cnCVE4OWxtex8QH1EBOjs4zUpGUjw6Pe3j2fP19u/47vrq9P3s/cunr9S8gAIRFhTCLAgAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+viewmag+22:view view22 22:photo:22 22:R0lGODlhFgAWAIUAAPwCBBQSFJyanKy2tLzCxHyChNTa3Nzq7Nz29Nzy9Mzy9MTu9OTy9Nzi5Oz6/OT29MTi5Kzi7NTy9KTm7JzW3ITO1Lzq7IzW5HzK1LS+vMTq7Jze7ITW3GTCzGS+zLTS1MzOzLzq9Kzm7Jze5ITW5HTS3FS2vLze5EzCzEyyvEyutJTa5NTu9ITa5FTK1ESirLTm7Mzi5FS6xEy2vESerESmtFSutESmrKyqrAz+/Dw+RAzi3ASutHRydAQCBAAAACH5BAEAAAAALAAAAAAWABYAAAbQQIBQGCgWh8jksCgYEAaCozIZKBgOiIRiwSgEpstCw/HYQiKRhBcMCBgQDodkMaFU0t9pQHCIyy0TFxgYEVF6GQ4LCQkaERscHR4RH3lUIAkWCyEiIyQlHiYjEJVIAQQJJ2gjJSUoKSorlHoCLBQcHC0lLikvHjCGejEiHBgeMjM0NRwPpFQFDBHFNjceHAjAYFWoI7cnCVE4OWxtex8QH1EBOjs4zUpGUjw6Pe3j2fP19u/4zT766vRI+fvHD4CPgwcJ9qg0UB85JA0dDjEQBAAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+viewmulticolumn22:view view22 22:photo:22 22:R0lGODlhFgAWAIMAAPwCBFRSVExKTDQyNPz+/Pz69PTq5AQCBOzaxOTKpAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAWABYAAARTEMhJq7046813+MJQfUF4BURhHGO6noSBsEcNoDJtS4KcsJQe4ncZ1HYT47HDbDqfUAnJRJmKLIGCCjjJbmE5wBI3EyOFxKCPS1EiJW52dE6vZyIAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+viewtext22:view view22 22:photo:22 22:R0lGODlhFgAWAIAAAPwCBAQCBCH5BAEAAAAALAAAAAAWABYAAAIkhI+py+0Po2ShBlOxzbP7n2yaJoLm+ZTcxqHuC6hXzML2HVEFACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+viewtree22:view view22 22:photo:22 22:R0lGODlhFgAWAIMAAPwCBAQCBFRSVExKTDQyNPz+/Pz69Pzu5PTq5OzaxBQOFOzKpFRWVFxWXOzexPTexCH5BAEAAAAALAAAAAAWABYAAARPEMhJq704g6A779kHCORAgNskFMYhakE8FkjyBcoWv+JwJItXaELYCTFHlCSpZKKcoB5jYHpOGgUadLKbIRw3jhEzQDyCSuI4zW673yhDBAAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
diff --git a/jni/ruby/ext/tk/sample/tkextlib/ICONS/tkIcons-sample.kde b/jni/ruby/ext/tk/sample/tkextlib/ICONS/tkIcons-sample.kde
new file mode 100644
index 0000000..51f76a0
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkextlib/ICONS/tkIcons-sample.kde
@@ -0,0 +1,658 @@
+1downarrow-16:actions actions16 16:photo:16 16:R0lGODlhEAAQAIAAAPwCBAQCBCH5BAEAAAAALAAAAAAQABAAAAIYhI+py+0PUZi0zmTtypflV0VdRJbm6fgFACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+1leftarrow-16:actions actions16 16:photo:16 16:R0lGODlhEAAQAIAAAP///wAAACH5BAEAAAAALAAAAAAQABAAAAIdhI+pyxqdwoNGTmgvy9px/IEWBWRkKZ2oWrKu4hcAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+1rightarrow-16:actions actions16 16:photo:16 16:R0lGODlhEAAQAIAAAPwCBAQCBCH5BAEAAAAALAAAAAAQABAAAAIdhI+pyxCtwoNHTmpvy3rxnnwQh1mUI52o6rCu6hcAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+1uparrow-16:actions actions16 16:photo:16 16:R0lGODlhEAAQAIAAAPwCBAQCBCH5BAEAAAAALAAAAAAQABAAAAIYhI+py+0PWwhxzmetzFpxnnxfRJbmufgFACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+2downarrow-16:actions actions16 16:photo:16 16:R0lGODlhEAAQAIAAAPwCBAQCBCH5BAEAAAAALAAAAAAQABAAAAIfhI+pq+EPXYpxUckoO3AjbF3dJwahllXe6AFgC8d+AQAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+2leftarrow-16:actions actions16 16:photo:16 16:R0lGODlhEAAQAIAAAPwCBAQCBCH5BAEAAAAALAAAAAAQABAAAAImhI+pyxf5VohmSlsxmpjTzAHeN5ak6UHpqKRi2GpwvH3Q3eT64RcAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+2rightarrow-16:actions actions16 16:photo:16 16:R0lGODlhEAAQAIAAAPwCBAQCBCH5BAEAAAAALAAAAAAQABAAAAImhI+pq5HOAjQyVnqfhHue7oAaKH5kiW0AmnLqaHomkj02g+e6XwAAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+2uparrow-16:actions actions16 16:photo:16 16:R0lGODlhEAAQAIAAAPwCBAQCBCH5BAEAAAAALAAAAAAQABAAAAIghI+pyxfR0HsRzNnuXVqn3mVQZWFRyIDjp65Ga5Ly4hcAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+abs-16:actions actions16 16:photo:16 16:R0lGODlhEAAQAIEAAPwCBIQChAQCBBQSFCH5BAEAAAAALAAAAAAQABAAAAIwhI95ocn2GlySTiME1iC+DIKdNWxANl4HaqWr055cy6Bs6dahmJsyXVFFJJ7gyF8AACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+airbrush-16:actions actions16 16:photo:16 16:R0lGODlhEAAQAIMAAASC/AQCBPzCxMQCBIQCBPz+/MTCxKSipFxaXDQyNISChAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAARUEMhJZxCjanBH3hY2EFJgVt0YcEW7liLxBoVxzPHL2msqUzSeT2c5HBC5jQmROKgAhCgKEVBQo6YAqVQIHBQ93ZbmBWt+nDJRgiYMvmuoThWXT/wRACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+attach-16:actions actions16 16:photo:16 16:R0lGODlhEAAQAIEAAPwCBPz+/AQCBAAAACH5BAEAAAAALAAAAAAQABAAAAI2hAOCxg2h0nJHyEshi9HpxU1GOCLdZoKpQ15nibUoprKp9lh2oucUxsBRXsJh4Hjs/QTMpr8AACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+back-16:actions actions16 16:photo:16 16:R0lGODlhEAAQAIUAAPwCBBRSdBRObCQ2TBxObISevAQCBNzu/BRGZPz6/FzC3Pz+/HTS5ByyzJze7Mzq9ITC3AQWLAyWvBSavFyuxAwaLAwSHBRafBSOrDzW5AyixCS61ETW3CzG1AQeLAweLAxefBSStEze7CSWtCyatBSCnBRWfAwmPBRWdByixAQSHAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAZiQIBwSCwah4HjUTBQFgkFg3MoKBykU0QhoUAIAuAksbpgNByPxQMSGVsVDYlkIqdUiJYLJqORbDgcHRseRR8gISIaEyMkGCVYRBEmeyAnlgaQkSgpmU4RAZ1OKqFOpFNGfkEAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+blend-16:actions actions16 16:photo:16 16:R0lGODlhEAAQAIIAAPwCBARCRAQCBASChATCxATCBASCBAAAACH5BAEAAAAALAAAAAAQABAAAANHCLrc/izISauYI5NduvlXMIjEQBSnUYCYxnmsSJrouhqh6J4wLo0mWuqWy5heN58seBrGdEdeMgQsNW0ggXbL7Qog4HDDnwAAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+bookmark_add-16:actions actions16 16:photo:16 16:R0lGODlhEAAQAIQAAPwCBCwqLLSytLy6vERGRFRWVDQyNKSipAQCBMTGxKyurISChJSSlJyanHR2dIyKjPz+xISGhPz+BGxubMTCBHx+fPz+/AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAVfICACwWieY1CibCCsrBkMb0zchTEcNYsIiYHiwIOdEAvigdFQGE0Ix4NBbSAgsWjk+jBIAlcUYrJASChnSXZSoUDelKfoKpFALJA61ueGI2IAZmhogGFmCGGAgXsifiEAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+bookmark_folder-16:actions actions16 16:photo:16 16:R0lGODlhEAAQAIUAAPwCBAQCBExKTBQWFOTi5OTm5CwqLPz+/PTy9Ozu7FRSVNza3PT29KSmpAQ6XARqnNTS1JyenGRiZJTa9Mzq9JzO5MTGxIyOjKSipFxeXMzOzDw+PDy65FTC7HS2zMzm7MzKzKSenASq5Bx+rBSGrFyqzLSytDw6NAR+zBRejBxqnLSyrERCRIyqvDRujKyurMTCvOzq7AQ2VDQ2NNze3KyqrGxqbLS2tLy6vCwuLDw6PAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAawQIAQEBAMh4GjcEAoCAQGYSCpDBwQiQJBEVhQj1YGo1DoNqZTx8PhODAWZUik0ZAkHRNKZe0IWC4RGBkBGhsOHB0eFR97bBdcICEbAA4iIyQlioxrGhEmJ5QoKSoqJCOZiw4rGixEYi0uo6WYDi8wkwAsCTFksLIuMi+tADMLNAsLEBAgLSMpMjW4RCc2MCAgFjA3MA4R0kgzGS84Ny8vDqBKSDkKETUOOurqAQagfkEAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+bookmark-16:actions actions16 16:photo:16 16:R0lGODlhEAAQAIQAAPwCBCwqLLSytLy+vERGRFRWVDQ2NKSmpAQCBKyurMTGxISChJyanHR2dIyKjGxubHRydGRmZIyOjFxeXHx6fAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAVbICACwWieY1CibCCsrBkMb0zchSEcNYskCtqBBzshFkOGQFk0IRqOxqPBODRHCMhCQKteRc9FI/KQWGOIyFYgkDC+gPR4snCcfRGKOIKIgSMQE31+f4OEYCZ+IQAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+bookmark_toolbar-16:actions actions16 16:photo:16 16:R0lGODlhEAAQAIQAAPwCBCwqLLSytLy6vERGRFRWVDQ2NKSipAQCBKyqrMTCxKyurISGhJSSlJyanHR2dIyKjGxubIyOjISChHx+fPz+/MTGxAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAVpICACwWieY1CibCCsrBkMb0zchTEcNYskCsXiwIOdEAzioeFIGE2IB6RBbT5HiAhEIpk6Y9kJBMJoHK6iLIU8kZxFlXhlIp/XJ4BKUIGoWIJ9f3x5e32FeoB5goGAfokTCJEIFJKTlX4hACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+bottom-16:actions actions16 16:photo:16 16:R0lGODlhEAAQAIUAAPwCBBRObCRKZBxCXAwyTKTK3Ozy/NTm9GSivAQWHNzu/FzC3IzO5CySrAQOHAyuzETS3CSWtAyOtETa5Aw2VLze7ByWtBy61BSavAxWdBRCXAwqPAQCBDR+nKTe7FS+1Eze7ByixBRmjPz+/AyexAyixAQKFBRqjAQGDAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAZhQIBwSCwaj0hAYCkYEJLKguGASEADigWj4bgaHpBINykwSCYRa5HCFFQsF0xGo9lwhpSOwfORYC4gISJ3RAQdIyQYJSAlImNrh4uNJkl5CoKUUBQnjlB4KFAcoqOknkh+QQAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+brace-16:actions actions16 16:photo:16 16:R0lGODlhEAAQAIEAAPwCBIQChAQCBBQSFCH5BAEAAAAALAAAAAAQABAAAAI2hI9pEXq8mnsNzggsEMJwbHGimFXS4HUfpKUIq3QJ036vuakyWvbjCJLYbL2WgyW5WIw3g78AACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+brackets-16:actions actions16 16:photo:16 16:R0lGODlhEAAQAIEAAPwCBIQChAQCBBQSFCH5BAEAAAAALAAAAAAQABAAAAIzhI8JwXocllMxTlSREGY/2W2iJ1nAEAJklpCfeXAJG8sY6JGowY7jW0sBL0NiqTGBAPwFACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+charset-16:actions actions16 16:photo:16 16:R0lGODlhEAAQAIAAAPwCBAQCBCH5BAEAAAAALAAAAAAQABAAAAInhI+pqxH8kFsvsgtm1vvEaoBZSH6j5FSaRY4me4pyq1ochuf6fvgFACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+colorize-16:actions actions16 16:photo:16 16:R0lGODlhEAAQAIQAAPz+BAQCBPz+/MTCxISC/AQChMTC/ERCBPyqXMRaBATCxASChPzerKSipMT+/MQCBATCBASCBARCRISChMT+xDQyNAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAVnICAGgWieZyCQKGuqZPkGgwyv60gONRDvNlqt9Pv5BgRCYVj8IQ3L4qE4KFiZzRiP90MgEj+FYtGLIRiJQaMxUDjIxFoi8YBAIo3FQjIJ7iAUERNqDTI6PBGJfT0oFVpsMSgzkSh+IQAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+colorpicker-16:actions actions16 16:photo:16 16:R0lGODlhEAAQAIMAAPwCBAQCBARCBDQyNMT+xATCBASCBPz+/FxaXISChAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAQ/EMhJZRCjahBIMdlmeV8gBl3xCabWGarBihwBz+eB2O0WHIFEp1f5BU1EilFI4wCZtGWy+JwWj00OynrNTvwRACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+completion-16:actions actions16 16:photo:16 16:R0lGODlhEAAQAIIAAPwCBAQCBPz+/Ly+vHx+fAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAM/CLrcGjBKCYK4+NoMs+jWIBIdZ50QuWGgMASD+oGnO5beR+x7UE3AyGKV0wxnpeSxyDoGN74Hszl8QhxYhj8BACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+configure-16:actions actions16 16:photo:16 16:R0lGODlhEAAQAIMAAPwCBAQCBISChGRmZMTCxKSipLS2tHx6fPz+/OTm5FxaXOzu7DQyNMzOzAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAReEMhAq7wYBDECKVSGBcbRfcEYauSZXgFCrEEXgDCSeIEyzKSXZoBYVCoJVIqBGByKu0Cy8QHxmgNngWCkGgqsGWFseu6oMApoXHAWhWnKrv0UqeYDe0YO10/6fhJ+EQAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+connect_creating-16:actions actions16 16:photo:16 16:R0lGODlhEAAQAIMAAPwCBPz+BMTCBISCBAQCBPz+/MTCxMTGxISChFxaXMzGzKSipAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAARaEMhJZbihUiz60FPnfaA0iBpBVGdHEYWxToEoSHBRHHM9AgSEQRcj+AYkYAJxIPKQFUJiOdTJQFIDU6dYzKKFhTCM+E5g4mXaDAyrlogEG+DGTecA7wsP8EcAACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+connect_established-16:actions actions16 16:photo:16 16:R0lGODlhEAAQAIMAAPwCBAQCBPz+/KSipDQyNMTCxMTGxISChFxaXMzGzAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAARaEMhJZxCjgsAtDtUlCOA1gJQ4kl/IDatAoF7xxkS6GgEBr6jAobCyBX42SQBxMOx6A8MhiGASR8YDgrYsNEeJ0zaEGZY7uoH2oB6nOUwtbdLaVOeTUwo/8UcAACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+connect_no-16:actions actions16 16:photo:16 16:R0lGODlhEAAQAIMAAPwCBPz+BMTCBAQCBERCBPz+/MTCxMTGxISChFxaXMzGzKSipAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAARPEMhJq704axBEHoPUEdhQGMNYFuwxkKInDYjBniEnwMCQIIebSzXx/WwsFK+YMABZikWuYlrUCtZpEYv4WRPaHhb064YB41kCfJFSQBh/BAAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+contents2-16:actions actions16 16:photo:16 16:R0lGODlhEAAQAIQAAPwCBAQCBDyKhDSChGSinFSWlEySjCx+fHSqrGSipESOjCR6dKTGxISytIy6vFSalBxydAQeHHyurAxubARmZCR+fBx2dDyKjPz+/MzKzLTS1IyOjAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAVkICCOZGmKQXCWqTCoa0oUxnDAZIrsSaEMCxwgwGggHI3E47eA4AKRogQxcy0mFFhgEW3MCoOKBZsdUrhFxSUMyT7P3bAlhcnk4BoHvb4RBuABGHwpJn+BGX1CLAGJKzmKjpF+IQAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+contents-16:actions actions16 16:photo:16 16:R0lGODlhEAAQAIUAAPwCBAQCBExCNGSenHRmVCwqJPTq1GxeTHRqXPz+/DwyJPTq3Ny+lOzexPzy5HRuVFSWlNzClPTexIR2ZOzevPz29AxqbPz6/IR+ZDyKjPTy5IyCZPz27ESOjJySfDSGhPTm1PTizJSKdDSChNzWxMS2nIR6ZKyijNzOrOzWtIx+bLSifNTGrMy6lIx+ZCRWRAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAaeQEAAQCwWBYJiYEAoGAFIw0E5QCScAIVikUgQqNargtFwdB9KSDhxiEjMiUlgHlB3E48IpdKdLCxzEAQJFxUTblwJGH9zGQgVGhUbbhxdG4wBHQQaCwaTb10emB8EBiAhInp8CSKYIw8kDRSfDiUmJ4xCIxMoKSoRJRMrJyy5uhMtLisTLCQkC8bHGBMj1daARgEjLyN03kPZc09FfkEAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+contexthelp-16:actions actions16 16:photo:16 16:R0lGODlhEAAQAIEAAPwCBAQChAQCBAAAACH5BAEAAAAALAAAAAAQABAAAAIzhH+hIeiwVmtOUcjENaxqjVjhByaBSZZVl24Y1V6iEVMzkD4bqD700bshgh1fzwd0IfwFACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+crop-16:actions actions16 16:photo:16 16:R0lGODlhEAAQAIIAAPwCBAQCBMT+xATCBASCBISChPz+/AAAACH5BAEAAAAALAAAAAAQABAAAAM0CLrc/iG+FsQgYapKbp7c4IFCZ2FQOQQE6oSl9Koxabrz/eVDDXat3atAlEEMSKFmyfAnAAAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+decrypted-16:actions actions16 16:photo:16 16:R0lGODlhEAAQAIUAAPwCBFxaVAQCBKSipDQyNMTCxISChFxaLFxSJExGHEQ+FCQiDBwaDBweDGxiLHxyNHRuPIR+RIyGZJSSfFxaRGxmLJyaXNzWpNTOnMzGnMS+jJSKTGReLKyqjPTu1NzarLSufKyibJySXIyGVGxiNFxaXLSytPT29Ozu7OTi5NTS1KyurGxqVCQeDJSSjLS2tNTW1KSmpGRiLKSebOzuzJSOXExONExGLAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAaVQIBwOAwYA8SkMCAYOAnKYiFAIAQGyOgVCggYuEovVxztMpdnwAGRSCgUCwOjIeQ6HpCIZDKRUNYMRBUWF4UYGRoWGxyBRR0eHxgaICEiIyR0QyUmJygpKgUrAxMsLUQlKyieoKIuEAunK52fBS8DLiywQySpnjC1Mbi6QjIzNBeSIBY1EQfDQgosLAEUNjY3Co1DfkEAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+down-16:actions actions16 16:photo:16 16:R0lGODlhEAAQAIUAAPwCBBRObCRKZBxCXAwyTKTK3Ozy/NTm9GSivAQWHNzu/FzC3IzO5CySrAQOHAyuzETS3CSWtAyOtETa5Aw2VLze7ByWtBy61BSavAxWdBRCXAwqPAQCBDR+nKTe7FS+1Eze7ByixBRmjPz+/AyexAyixAQKFBRqjAQGDAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAZeQIBwSCwaj0hAYCkYEJLKguGASEADigWj4bgaHpBINykwSCYRa5HCFFQsF0xGo9lwhpSOwfORYC4gISJ3RAQdIyQYJSAlImNrh4uNJkl5CoKUUBQnjlB4KJ6hokN+QQAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+editclear-16:actions actions16 16:photo:16 16:R0lGODlhEAAQAIEAAPwCBAQCBPz+/ISChCH5BAEAAAAALAAAAAAQABAAAAIuhI+pm+EPnwmi2msDoLgLzQWDV4HlSJof6qki+W0n7LKdCpdyrm/Rr2EIhwp/AQAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+editcopy-16:actions actions16 16:photo:16 16:R0lGODlhEAAQAIUAAFxaXPwCBNze3GxubERCRPz+/Pz29Pzy5OTe3LS2tAQCBPTq3PTizLyulKyqrOzexLymhLy+vPTy9OzWvLyifMTCxHRydOzSrLyihPz6/OTKpLyabOzu7OTm5MS2nMSqjKSipDQyNJyenLSytOTi5NTS1JyanNTW1JSWlLy6vKyurAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAEALAAAAAAQABAAAAaUQIBwCAgYj0eAYLkcEJBIZWFaGBie0ICUOnBiowKq4YBIKIbJcGG8YDQUDoHTKGU/HhBFpHrVIiQHbQ8TFAoVBRZeSoEIgxcYhhkSAmZKghcXGht6EhwdDmcRHh4NHxgbmwkcCwIgZwqwsbAhCR0CCiIKWQAOCQkjJAolJrpQShK2wicoxVEJKSMqDiAizLuysiF+QQAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+editcut-16:actions actions16 16:photo:16 16:R0lGODlhEAAQAIEAAPwCBAQCBPz+/ISChCH5BAEAAAAALAAAAAAQABAAAAIwhI9pwaHrGFRBNDdPlYB3bWHQ1YXPtYln+iCpmqCDp6El7Ylsp6ssR1uYSKuW0V8AACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+editdelete-16:actions actions16 16:photo:16 16:R0lGODlhEAAQAIUAAPwCBFxaXNze3Ly2rJyanPz+/Ozq7GxqbPT29GxubMzOzDQyNIyKjHRydERCROTi3IyKhPz29Ox6bPzCxPzy7PTm3NS6rIQCBMxCNPTq3PTi1PTezMyynPTm1PTaxOzWvMyulOzGrMymhPTq5OzOtNTKxNTOzNTCtNS+rMSehAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAaKQAAgQCwahcihYMkcBAiBpLJApRoOBWgyIKhSEQkFgrBAcr1URiPhKAsDD3QB8RhA3FM0IlLHnyUTVBMSFBUWfl0XGBMTGBcZGodmcQWKjpAbHIgIBY2LHRoempOdjooTGx8giIOPFYofISJ+DyMXI6AfFySyfiUmJSUnKBYcICIpfgELzM3OZX5BACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+edit-16:actions actions16 16:photo:16 16:R0lGODlhEAAQAIYAAPwCBFxaVMR+RPzKjNze3AQCBMR6RPzGjPyODPz+/MzOzPyKDPyKBPz29OTWzPyGDPyGBOx6BOza1OR2BKROBNSOXKRKBBwOBOzu7PTWxPzizOySZPyCDFxaXOy2lNRyRMxmJCQOBPTm1OzStPTKrMR+XIRWLFxGNCQSBDQyNIRSNDQuJERGRLyqlNzSvIx6ZKRuVEw6LLSyrLymhKSShBwaFFROTJyWjMS+vNzW1OTazNzKrHRqXOzezOTOpPTq3OzWvOTStLyedMS+rLy2pMSynMSulAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAewgAAAAYSFhoQCA4IBBI2OjgUGBwiLBAmXlpcKkgsMlZcJBA0JDpIPEBGVjwkSBgOnExSfmBIVBxAMExYXswkYGRobHLq8gh2PHhoeHyAWIYKzIiMkJSYnKCnQg5YNHtQqKywtK9qMBC4vMDEBMjIz2dCMDTQ1Njc4OToz5PEEOzw3ZPToMcLHO23HfogQ0QMIkCA+hPBbhAPHECJFjMyYIUQIvEUpUqwQOXKkSEF+AgEAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+editpaste-16:actions actions16 16:photo:16 16:R0lGODlhEAAQAIUAAPwCBCQiFHRqNIx+LFxSBDw6PKSaRPz+/NTOjKyiZDw+POTe3AQCBIR2HPT23Ly2dIR2FMTCxLS2tCQmJKSipExGLHx+fHR2dJyenJyanJSSlERCRGRmZNTW1ERGRNze3GxubBweHMzOzJSWlIyOjHRydPz29MzKzIyKjPTq3Ly2rLy+vISGhPzy5LymhISChPTizOzWvKyurPTexOzSrDQyNHx6fCwuLGxqbOzKpMSabAQGBMS2nLyulMSidAAAACH5BAEAAAAALAAAAAAQABAAAAa7QIBQGBAMCMMkoMAsGA6IBKFZECoWDEbDgXgYIIRIRDJZMigUMKHCrlgul7KCgcloNJu8fsMpFzoZgRoeHx0fHwsgGyEACiIjIxokhAeVByUmG0snkpIbC5YHF4obBREkJCgon5YmKQsqDAUrqiwsrAcmLSkpLrISLC/CrCYOKTAxvgUywhYvGx+6xzM0vjUSNhdvn7zIMdUMNxw4IByKH8fINDk6DABZWTsbYzw9Li4+7UoAHvD+4X6CAAAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+editshred-16:actions actions16 16:photo:16 16:R0lGODlhEAAQAIUAAPwCBFxaXNze3Ly2rJyanPz+/Ozq7GxqbGxubMzOzPz69DQyNIyKjERCRPz29PT29OTi3IyKhPz27PTu5PTy5Pz6/Pzy7PTq3OzexLyqlPTm1PTizOzavLyqjOzWvOzaxLyifOzizOTOpAQCBOzezAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAaEQAAgQCwahcihYMkcBAiBpLJApRoOBWgyIKhWEQkFYYHkeqkMxKFBFpq9jgdkEGlPqwrJhCIY2N8FFRYUFxcYGX9dgRKEGhiHiYEOhBcbGBwdiQEOARcBGwEeAZllAgEUnQEfoQEgmp4hrCKtrwEYsrRlTiMBJAG8syN/IyMAxMXHSH5BACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+edittrash-16:actions actions16 16:photo:16 16:R0lGODlhEAAQAIIAAPwCBAQCBKSipFxaXPz+/MTCxISChDQyNCH5BAEAAAAALAAAAAAQABAAAANQCKrRsZA5EYZ7K5BdugkdlQVCsRHdoGLMRwqw8UWvIKvGwTICQdmGgY7W+92GEJKPdNwBlMYgMlNkSp3QgOxKXAKFWE0UHHlObI3yyFH2JwAAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+encrypted-16:actions actions16 16:photo:16 16:R0lGODlhEAAQAIUAAPwCBFxaVAQCBKSipDQyNMTCxISChFxaLFxSJEQ+FExGHCQiDBwaDGxiLHxyNHRuPIR+TIyGZJSSfFxaRFxWJGRiLJyaXNzWpNTOnMzGnLy2hJSKTGReLKyqjPTu1NzarMS+jLSyfKyibJySXIyGVCQeDLSytPT29Ozu7OTi5NTS1KyurJSSjGxqVFxaXLS2tKSebOzuzLSufJSOXExGLGRiTExONAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAaTQIBwGCgGhkhkQDBoEpLKQoBACAyOUID1qTVwoQGvMPxNFgVjAxp6QCQUicSCwVgkG44HJCKRRCYUCAxIFRYXhxgZGhYbHINEHR4fGCAhIiMkFSVKJicoKSoFKwMsLZtDLison6GjLA92qCueoAUvpC2xQhWqrLYDErmEMDEXlDIwMxAHukI0NS01EzY2NAmPAH5BACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+eraser-16:actions actions16 16:photo:16 16:R0lGODlhEAAQAIMAAAT+BMTC/AQCBISC/AQChPzCxPz+/MQCBIQCBAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAQ/EMhJZRA120GwnsEgdh8QiqKXnSi5oqNKsbFWGEYrT8Vx4JydpOf7uSrEIkIISPqWtkIS+pH2qCUptgTYavwRACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+exec-16:actions actions16 16:photo:16 16:R0lGODlhEAAQAIYAAPwCBEQ+PBwaHLy+vMzOzGxqZHx+dKyqnKymnIR+dNTW1MTCxJyOfLySVMSaVMSeVMSebJyWhOSmTOSuVNyubPS+dKSWhHR2dDw+PIyKhNymTNSaTEw+JOy+fPzSnLSyrISChDQyNDw6NMzKzLy2rMyiXGxWLAQCBHRqTPzerNy+lMzGvCwuLAwKDDQyLJyWlNy6jPTGhGxaRGxiRPz2vOTStLy2tFRSTMS+tOzGlPzmtPTixGRiXCwqJLy6tOTWxPTq1MzKxMzOxISCfHRybLS2tHR2bCQmJExORMTCvMTGxAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAeogACCg4SFhoIBAYeDAogDA4oAjYQCBAEFBgcICQUBCpODAQsMDQ4PEBGWhgUMDxITFBUUFheDGAYZCA0aGxwcHR4QHwwgISILIyQlGiYnJygpKisEIywALS4vMBoxMjM0KTU2LC2ENzg5wDo6Owo8hT0+Lx8/OztAQR9C1oInQz4FMBAp8sEIhgIEMpwYdASJCwAYkihR5OLGkUUAMmTACK8Hx4+C/AQCACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+exit-16:actions actions16 16:photo:16 16:R0lGODlhEAAQAIEAAPwCBAQCBDQyNHR2dCH5BAEAAAAALAAAAAAQABAAAAI4hI+pFrHb3nEg1iWiDiINCwYDko0V9XUTda6I1TIsUMpGinyzbB6ZeGuoEr+GUDL4CXqSphPhLwAAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+fileclose-16:actions actions16 16:photo:16 16:R0lGODlhEAAQAIQAAPwCBCQiJBwaHAQCBDQyNDw6PFxaXFRSVERGRCwqLAwODGRiZHx6fPz+/GxqbAwKDCQmJAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAVaICCOZGmeqBgEwjCkRGEcSKK4JrEcBrMgAdeLVDg0GguGsYEbBQyGYyN6FDoPDIf0+LCKBIgetQERDgGDBGIpNY8GioAU0m6KXFw883w3+/l9f4AkfimGIn4hACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+filefind-16:actions actions16 16:photo:16 16:R0lGODlhEAAQAIYAAPwCBCQmJDw+PBQSFAQCBMza3NTm5MTW1HyChOT29Ozq7MTq7Kze5Kzm7Oz6/NTy9Iza5GzGzKzS1Nzy9Nz29Kzq9HTGzHTK1Lza3AwKDLzu9JTi7HTW5GTCzITO1Mzq7Hza5FTK1ESyvHzKzKzW3DQyNDyqtDw6PIzW5HzGzAT+/Dw+RKyurNTOzMTGxMS+tJSGdATCxHRydLSqpLymnLSijBweHERCRNze3Pz69PTy9Oze1OTSxOTGrMSqlLy+vPTu5OzSvMymjNTGvNS+tMy2pMyunMSefAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAe4gACCAAECA4OIiAIEBQYHBAKJgwIICQoLDA0IkZIECQ4PCxARCwSSAxITFA8VEBYXGBmJAQYLGhUbHB0eH7KIGRIMEBAgISIjJKaIJQQLFxERIialkieUGigpKRoIBCqJKyyLBwvJAioEyoICLS4v6QQwMQQyLuqLli8zNDU2BCf1lN3AkUPHDh49fAQAAEnGD1MCCALZEaSHkIUMBQS8wWMIkSJGhBzBmFEGgRsBUqpMiSgdAD+BAAAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+filenew-16:actions actions16 16:photo:16 16:R0lGODlhEAAQAIUAAPwCBFxaXNze3Ly2rJyanPz+/Ozq7GxqbPz6/GxubNTKxDQyNIyKhHRydERCROTi3PT29Pz29Pzy7PTq3My2pPzu5PTi1NS+rPTq5PTezMyynPTm1Pz69OzWvMyqjPTu5PTm3OzOtOzGrMSehNTCtNS+tAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAZ/QAAgQCwWhUhhQMBkDgKEQFIpKFgLhgMiOl1eC4iEYrtIer+MxsFRRgYe3wLkMWC0qXE5/T6sfiMSExR8Z1YRFRMWF4RwYIcYFhkahH6AGBuRk2YCCBwSFZgdHR6UgB8gkR0hpJsSGCAZoiEiI4QKtyQlFBQeHrVmC8HCw21+QQAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+fileopen-16:actions actions16 16:photo:16 16:R0lGODlhEAAQAIUAAPwCBAQCBOSmZPzSnPzChPzGhPyuZEwyHExOTFROTFxaVFRSTMSGTPT29Ozu7Nze3NTS1MzKzMTGxLy6vLS2tLSytDQyNOTm5OTi5Ly+vKyqrKSmpIyOjLR+RNTW1MzOzJyenGxqZBweHKSinJSWlExKTMTCxKyurGxubBQSFAwKDJyanERCRERGRAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAaRQIBwGCgGhkhkEWA8HpNPojFJFU6ryitTiw0IBgRBkxsYFAiGtDodDZwPCERCEV8sEk0CI9FoOB4BEBESExQVFgEEBw8PFxcYEBIZGhscCEwdCxAPGA8eHxkUGyAhIkwHEREQqxEZExUjJCVWCBAZJhEmGRUnoygpQioZGxsnxsQrHByzQiJxz3EsLSwWpkJ+QQAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+fileprint-16:actions actions16 16:photo:16 16:R0lGODlhEAAQAIUAAPwCBFRKNAQCBPz+/MTCxExKLPTq5Pz29Pz6/OzezPT29PTu7PTy7NzClOzm1PTu5LSabJyanPTm3FxaXOzCjOTKrOzi1OzaxOTSvJyenGRmZLyyTKSipDQyNERCROTi5Hx+fMzKzJSSlIyOjISChLS2tAT+BDw6PAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAaYQIBwKAwIBMTkMDAYEApIpVBgOCAOg4RRGlAoEAuGIdGITgWOq4LxcCQgZkEkIHksHgYJOR6ZQCgVFhYJFxgTBVMZihoCfxUYDWUbUBGKGREcjBoQEB2TAB4CAx+Vl5WMhyACHiEhH6IfIiMktCQgE0cZJQStr6O2t6EARxO6vK6iEx4dZsMCxbsmBB4nzUTEutVSSUdmfkEAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+filequickprint-16:actions actions16 16:photo:16 16:R0lGODlhEAAQAIMAAASC/AQCBPz+/ISChERCBDQyNPz+xPz+BFxaXPwCBMTCxAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAARWEMhAq5UYBME7D9kkBMNGjqHmeWBoDhwsEIS7coVx1NhbCrmdzROk9SyU4GEJ2twECISOUNokEopsVrobKCgCrZa73IHFYy4VyZ5WNIO4vBhvse8gfwQAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+filesave-16:actions actions16 16:photo:16 16:R0lGODlhEAAQAIUAAPwCBAQCBFRSVMTCxKyurPz+/JSWlFRWVJyenKSipJSSlOzu7ISChISGhIyOjHR2dJyanIyKjHx6fMzOzGRiZAQGBFxeXGRmZHRydGxqbAwODOTm5ExOTERGRExKTHx+fGxubNza3Dw+PDQ2NAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAaAQIAQECgOj0jBgFAoBpBHpaFAbRqRh0F1a30ClAhuNZHwZhViqgFhJizSjIZXQCAoHOKHYw5xRBiAElQTFAoVQgINFBYXGBkZFxYHGRqIDBQbmRwdHgKeH2YgHpmkIR0HAhFeTqSZIhwCFIdIrBsjAgcPXlBERZ4Gu7xCRZVDfkEAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+fill-16:actions actions16 16:photo:16 16:R0lGODlhEAAQAIMAAASC/AQCBMT+xASCBMQCBATCBPwCBIQCBISCBAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAARSEMhJq50hXBvE0JsUEMXwhYFBmOeVDsVqgpS6luRc32RR6hLCTSCQ/VqEwwDhK5Z+Ao3wEPAViL6BR6PSZKyCa6uLAbcAZEznLDHQ1BZDiOKPAAAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+filter-16:actions actions16 16:photo:16 16:R0lGODlhEAAQAIIAAPwCBAQCBKSipMTCxISChMTGxAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAM3CLrcDiGGt6IQQ7pI8PjSVHUeqFVBNxRfFjXSZYqwENoUNFx4rve+wI6WEwKLQ5/CSCw2lQ9/AgAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+find-16:actions actions16 16:photo:16 16:R0lGODlhEAAQAIUAAPwCBCQmJDw+PAwODAQCBMza3NTm5MTW1ISChOTy9Mzq7Kze5Kzm7HyChOT29Oz6/Nzy9Lzu7JTW3GTCzERCRLza3NTy9Nz29Mzu9Kzq9Ize7HTGzHzK1AwKDMTq7JTi7HTW5HzGzKzS1IzW5Hza5FTK1ESyvLTa3HTK1GzG1DyqtLzu9IzK1AT+/Dw+RAQGBATCxHRydMTCxAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAaSQIAQEBAMhkjBUEAoGA4EJXKJSCQUC0ZDCmg0hATHAxKRTCIEYYMiMFYsF0xGs+FUOl0BJRAweCIRHyATIRhpRAEAHSILIyQgJSYhJ4dIBBEoISkmKiuVSQgRIyEsEQgELVNCLgQVCiJRLQSfli9pMAQxMrRcQ1G6tAC9AL+7al+qxALACG1Kw8oxBGt7yWBpfkEAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+finish-16:actions actions16 16:photo:16 16:R0lGODlhEAAQAIUAAPwCBAwyTBRObAw2VDR+nAQCBCRKZOzy/KTe7Pz+/KTK3Nzu/Lze7FS+1AyexAyuzBSavAyOtBSmzOTy/BRqjNTm9IzO5ETS3ETa5By61AyixByixBRmjAQGDBxCXGSivCySrCSWtBTC3AQOHAQWHAxWdEze7AQKFBRCXAwqPAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAZtQIBwSCwahYGjUjBQGgWE5LCgNBwITSFVKOgKDAZEIqodChSLw4HRcIyTW4Dg0HhAIhGIZEIJxA0VFhcYGRAaGBscHXEeHyAhIQ4iiBwjAHEBJCMjJCUmiSdlRyigU0oolURxRSmrTpevsUN+QQAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+flag-16:actions actions16 16:photo:16 16:R0lGODlhEAAQAIIAAASC/AQCBMTCxPz+/MQCBPzCxPwCBAAAACH5BAEAAAAALAAAAAAQABAAAAM5CLrcruG9QCULokqKR44NJQykQGgXSRaEcYJLsLLu6wSFoRMvCuk1kO9ni8GMt6MForQMl89NxJ8AACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+folder_new-16:actions actions16 16:photo:16 16:R0lGODlhEAAQAIUAAPwCBAQCBPz+hPz+BOSmZPzSnPzChFxaXMTCBPyuZPz+xPzGhEwyHExOTPz+/MSGTFROTPT29OTm5KyurDQyNNza3Ozq5Nze3LR+RLy+vJyenMzKzNTS1Ly6vJSWlFRSTMzOzMTGxLS2tKSmpGxubBQSFAwKDKSinJyanIyOjCQiJERCRERGRBweHAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAaNQIBwSCwaj8ikcokMCIqBaEDoBAQG1meAUDAQpIcBQoy1dg2JdBqhECgQ1IWB0WgcBIOBwIHXBwwPEBEREhIBbG4IExR/DBUVFhIXV2NjDVYYDY8SFU4ZVxpVAQwbGxynGxkdTh6XVh8gGSGzGSITIxokJUImGSMTwLcnKCkprgAqDSt1zCssKxQtQ35BACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+forward-16:actions actions16 16:photo:16 16:R0lGODlhEAAQAIUAAPwCBAwyTBRObAw2VDR+nCRKZOzy/KTe7Pz+/KTK3Nzu/Lze7FS+1AyexAyuzBSavAyOtBSmzOTy/BRqjNTm9IzO5ETS3ETa5By61AyixByixBRmjAQGDBxCXGSivCySrCSWtBTC3AQOHAQWHAxWdEze7AQKFBRCXAwqPAQCBAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAZjQIBwSCwahYGjUjBQGgWEpHNYMBCaT4G2UDggos+EwmBYMBpf6VBgYDgeEMgjIpmoAQVKxXLBPDIXGhscRB0eHyAgDSGBGyJFASMiIiMkJYImUwAnmJqbjp4AKCmhAKSlTn5BACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+frac-16:actions actions16 16:photo:16 16:R0lGODlhEAAQAIEAAPwCBAQCBAQGBIQChCH5BAEAAAAALAAAAAAQABAAAAInhA9hig0SAmQOxeouPrFTzHzbCAzmiZ4k2S1ryHKsoo3tptXg3fgFACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+frameprint-16:actions actions16 16:photo:16 16:R0lGODlhEAAQAIUAAPwCBFRKNAQCBPz+/MTCxExKLPTq5Pz29Pz6/OzezPTy7PT29NzClPTu7PTu5PTm3LSabJyanOzi1FxaXOzCjOTKrOTSvJyenGRmZLyyTKSipDQyNERCROTi5MzKzIyOjLS2tAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAaPQIBwKAwIBMTkMDAYEApIpVBgOCAOg4RRGlAsEAqFIcGITqnWRcPxSEDMgkhAonA4DO3yMD6BUCoSCYIWEwVTF4gYAhAMFRUMZRlQEYgXERqKGBAQG5IAHAIDHYiUEUcDpwIcHh4doR0fH02zqAIXIASsrqi0TQBHE7e5HqG0Zr8CwSC9qFJHxbRSU7W1fkEAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+gear-16:actions actions16 16:photo:16 16:R0lGODlhEAAQAIIAAPwCBAQCBISChMTCxDQyNFxaXKSipPz+/CH5BAEAAAAALAAAAAAQABAAAANdCLobwbAFMciLwBFSihBEFHSG8QnmpQQEBX6loI5G5QTlcMgrZSmEmsGxKqRWNV3hMrFlBtDoA1eTEaKHJdMYhR6+gxkF++UMGbiDzvDVioyHAJSHcchuGLQq4k8AACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+gohome-16:actions actions16 16:photo:16 16:R0lGODlhEAAQAIUAAPwCBDw6PBQWFCQiJAQCBFxeXMTCxJyanDwyLDQqLFRSVLSytJSSlISChCQmJERGRFRWVGxubKSmpJyenGRmZLy+vOzq7OTi5Ly6vGRiZPTy9Pz6/OTm5ExOTPT29BwaHNza3NS6tJRqRGQqBNy6pIyKjDwGBPTe1JSWlDQyNOTGrNRiBGwmBIRaLNymdLxWBHxGFNySXCwqLKyqrNR6LKxGBNTS1NTW1Jw+BEweDDQ2NAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAaoQIBwCAgIiEjAgAAoGA6I5DBBUBgWjIZDqnwYGgVIoTGQQgyRiGRCgZCR1nTFcsFkHm9hBp2paDYbHAsZHW9eERkYGh4eGx4ag3gfSgMTIBshIiMkGyAlCCZTEpciJyQjGxcoKUQBEhcbIiorLB4XEltDrhcaLS4vtbcJra8bMDHAGrcyrTMXHjA0NSypEsO6EzY3IzU4OdoTzK0BCAkDMgkIOjJlAH5BACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+goto-16:actions actions16 16:photo:16 16:R0lGODlhEAAQAIEAAPwCBAQCBEQCBAAAACH5BAEAAAAALAAAAAAQABAAAAIohI8RyKciVnMwTlrlDfkm5QFgaHBWMo0lp22dZ57wO8vpGrLk2iJ+AQAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+help-16:actions actions16 16:photo:16 16:R0lGODlhEAAQAIMAAPwCBAQ6XAQCBCyCvARSjAQ+ZGSm1ARCbEyWzESOxIy63ARalAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAQ/EEgQqhUz00GEJx2WFUY3BZw5HYh4cu6mSkEy06B72LHkiYFST0NRLIaa4I0oQyZhTKInSq2eAlaaMAuYEv0RACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+history-16:actions actions16 16:photo:16 16:R0lGODlhEAAQAIUAAPwCBEQ2LEw6POTSrOzWtNS2lAQCBOzatPTm3PTq3MyyjEw+NOzm1Pz29Pz+/Pz6/Pz27FRGPFxKRPTu3Pzy7Pz69Pz67KSGbPzy3Pzu3PTizPzu1Pzq1PTmzOzaxPTixPTmxOzWvOTOtKyWdOTGpOTStNS+nIRmVLymhNzCnOzavLyefAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAaHQIBwGCgOj0jBgFAwGJDJAyJBUDihwgWj4XhAqhEJNDKhVLwUSUDyPJIrlgYlLSG0hYELhgLJTBJOd1kaGxgYHB0egkQfHBwgHyEigkUBIwMkBwcEJSZ3ARYWJCcnKCYpJJ5HAQUqFhSjJysoKItOCgehJBISI4tCtyERa79HTrx2WEiBUH5BACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+idea-16:actions actions16 16:photo:16 16:R0lGODlhEAAQAIMAAPwCBAQCBPz+BPzerPz+xPyqXPz+/ISChFxaXKSipDQyNAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAARMEEgZap14BjG6CJkmEMVQCF+4mQPBpthWtuYJxkJJGK6dbQRCgMBB3XCDzQamMhpDGlvuCFUyoQDLBUsJHBDUKuKQCKsUCIVZtc34IwAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+int-16:actions actions16 16:photo:16 16:R0lGODlhEAAQAIIAAPwCBIQChAQCBAwODAQGBAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAMwCKqx/iw0CNukzuJ8d1yCAAziIyliCKjck1ZuaV4igZ1r+raongE4j8YT6QiJC38CACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+locationbar_erase-16:actions actions16 16:photo:16 16:R0lGODlhEAAQAIEAAPwCBAQCBPz+/AAAACH5BAEAAAAALAAAAAAQABAAAAIshI+py40Bo1SywgSFiDq+oG3hZHDhVpUmagFrl7pgN3oqPNuqpe+8Awwi/AUAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+lock-16:actions actions16 16:photo:16 16:R0lGODlhEAAQAIUAAPwCBFxaVAQCBKSipDQyNMTCxISChFxaLFxSJEQ+FExGHCQiDBwaDGxiLHxyNHRuPIR+TIyGZJSSfFxaRFxWJGRiLJyaXNzWpNTOnMzGnLy2hJSKTGReLKyqjPTu1NzarMS+jLSyfKyibJySXIyGVCQeDLSytPT29Ozu7OTi5NTS1KyurJSSjGxqVFxaXLS2tKSebOzuzLSufJSOXExGLGRiTExONAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAaTQIBwGCgGhkhkQDBoEpLKQoBACAyOUID1qTVwoQGvMPxNFgVjAxp6QCQUicSCwVgkG44HJCKRRCYUCAxIFRYXhxgZGhYbHINEHR4fGCAhIiMkFSVKJicoKSoFKwMsLZtDLison6GjLA92qCueoAUvpC2xQhWqrLYDErmEMDEXlDIwMxAHukI0NS01EzY2NAmPAH5BACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+lsub-16:actions actions16 16:photo:16 16:R0lGODlhEAAQAIEAAPwCBAQCBIQChAAAACH5BAEAAAAALAAAAAAQABAAAAImhI+pFu2+QpxKVppsxkh3fnhh9DyGcC6IwLbqir4HK58tLcfx6xcAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+lsup-16:actions actions16 16:photo:16 16:R0lGODlhEAAQAIEAAPwCBIQChAQCBAAAACH5BAEAAAAALAAAAAAQABAAAAIlhI95YawYonwp0uoukFO7rCXCSJKPcKYKuqqii7BvS892XJZ+AQAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+mail_forward-16:actions actions16 16:photo:16 16:R0lGODlhEAAQAIYAAIx+fIRydHxubHxmZGxiXHRmZFxOTFxGPFxKTPwCBLymlMy+pOze3PTq3PTu5Pzy7LSmnOTaxOzm5LyqlNzOtPz69Pz27MzCtLyqrPT27IRubPzuzNTGvNTCxLSelPz25Bw+ZFxKPPzy1Pz65LyupBxKdCxWfPTm1Pz23LyinBxGbGzO5DRafBxWfBxajCymxHTS5BxSdBxKbFTK3EzG1CSGvCyKvCSSxCSavGTO5GRaVPzqzFzK5EzG3BSCtAwiPGxaVPTivPzy3NzKpBxObCRefBxqlPTmzJR2bKyahAwyRPzmvOTOpKyObNS+nPz21AQOFKyOfPzuxAQCBGRORLSadPzyzLymjMy2lOzetDwuJFRCPEw6NEQ6LEQyLEQ6NAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAkALAAAAAAQABAAAAfhgAABAgIDBAQFBgcIBwmOCQIKCwwNDg8OEBESjY8CDBMUFRYVFxgZDJyOGhsPChwVHR4fFSAhjwkaIiMOJBQQDRUVJSa3GicoHw4pEA8SGSorLI8tLtQu19gqLzDECTEyMzQ14zY1Njc3ODkqCTo7MjIxNCs5PD03PjctPwlAQUIihhBpQbCIihtG+CUocASFkAhIkogQ8kFJwkcFlogIkoRJEydPnkBR6GiAxiQLgiiIIkXElFQJqESoMsRKkAhXqkhhApNKFSxZggTJ4nHIEJhaDhzYwoVLFy1avHyB6ScQACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+mail_generic-16:actions actions16 16:photo:16 16:R0lGODlhEAAQAIUAAPwCBGxaVOTe1Oze3OTWxOTWvNzStNzKpEQ6LOTezPz+/Pzy7Pz69Pz27Pz25Pz21PzuzPzuxEQyLLyinLSmnPz67Pz23LSafKyObDwuJMzCtLSelPzy1My6nLymjNTCxLyqnPzq1LyihKyOfOzavOzetEQ6NPTq3NzOtLymnNTGxJR2bOTOpPTivNTGvLymlKSShKyahEw+NOTe3PTm1Pzu1Pzy3FRCPPz65LSadFxGPOzm3PzqzPTmzPzmvEw6NCH5BAEAAAAALAAAAAAQABAAAAaqQIBwSCwaj8ikMhloOp/QpmAgqAoIhELBUDgcEIGEYrFgNBoLx+IBiRwkgQnFoWAwKhWLhX3BZAILGhsCDXgODhwdGB5vgAofICBlDiEiIx4kJSYBJ2UoEykqHSMrLC0nLWAnFS4UCycvMAcEMR0RLTIBMwaSahw0NTYtFwclNwEdLws4eoc2DxwQOR06ASk7PBAhIRE9Pj0tLSUY1T8I5gjn6Qgy7D8SfkEAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+mail_get-16:actions actions16 16:photo:16 16:R0lGODlhEAAQAIUAAPwCBAxKdBRSfCyGvFSm1BxKfCSWzCyWzBRCXCRKfBwuRAQGDDw6PHy23Cym1CSSxByCxBxunBQSFKyurMTCxExihNza3NTW1JSSlMzKzFxaXLS2tNze3KSipCQmJGxmbNTS1KSepLy2vISGhJSWlHx+fERGRPz6/IyKjDw+POzq7JyenMzOzKSmpCwuLDQyNIyOjAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAaeQIBwGBAIAsOkUjAgFJRQQMHgjC4PBIEVgAh4D4aEYrGAMhINxwPyiCgYSsmEUmk82grLRZJkYCgXaAEKFxYZcEISGhsZFxwFeY0WHR5CDB8dGCAXG5shGxQicBIMpSMUGxgTGSQlpQwSJicnEwwdI7gdKAwTsykpKiobr8QMKxeHDBcsGRvOzxsT0i0uL9HSHdkT2ZkoMJXF4a8AfkEAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+mail_replyall-16:actions actions16 16:photo:16 16:R0lGODlhEAAQAIYAAIx+fIRubHxubHxqbHxmZGxeXHRmZGROTFRCPFxKTFxGPPwCBLymlMy6pOTa1PTq3PTu5Pz27Dw+POzi3PTm1OTWvPz25FRSVERCRLympPzuzPTu7NTGvFxaXKSmpPzu1Pz65Hx6fHxqZPzq1Pz23HR2dBw+ZHx+fISChJSWlDQmJHRydCxWfBxGbJyenExKTHRiXPzqzPzy3CQmJDRafGTO5ExOTERKTGxWVCRSfHTS5CymxBxajBxWfPTmvPzy1CyixCSaxCySxDSaxDSWxDSSvDyaxGS21PTmzPz21AwiPBRejCSavByGtCSezEzG3FzK5FzG3GzO5FTK3CQ2bPTixBxqlCRefBxSdBxSfBx2nCQ+dHxmXPzmvLSafAwmRAwyRPzyzDw6POzavNzKpAQOFPzuxBwWTBw2ZGRORLyWdMy2lOzetPTivAQCBKyObOTOpAweNBwWVEQyLEw2LEQ2LDwuJAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAsALAAAAAAQABAAAAf4gAABAgMEBQUGBwgJCguOCwEMDQ4PEBESDA4TjY8DFAwVERYXGBkRm4+QGhsMHB0eGB8bDpyOARogEBceIRgXv8COIiMkGB4lJSYnIcwoKb/DGyoXKywtKS4pHinMLzAxJDIzNDUtNjcv6B0hLzgfMh85OjstPDw99zwd7T4/LTVAgggZQqSIECNHevSAgSSJkiVMmjh5AiWKlClAiFARUeVHFSVWmLS40gNLlh5agGzh0kWDlwZfrIDREKaCAjEqrFA5MMYLmTAxlJTxYoZMozNozqRRs4ZNmy5s3LwhA0dBnDNn5MxBoAABnTp17IitowDrmQV+AgEAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+mail_reply-16:actions actions16 16:photo:16 16:R0lGODlhEAAQAIYAAIx+fIRubHxubHxqbHxmZGxeXHRmZGROTEw+NFxKTFxGPPwCBLymnMy6pOTa1PTm1Pzy7LymlOzi3HxqZOTWvPz69Pz25My+tLympFRGRHxuZPzu1LymjNTGvNTCxBw+ZPz23PzuzPz65PTu5NzOtCxWfBxKbPzq1DRafGTO5BxGbPzy9HTS5CymxBxajHRiXPzqzCyixCSaxCySxDSaxDSSvGS21GxWVAwmRBRejCSavByGtCSezEzG3FzK5FzG3CQ2bPzuxAwiPBxqlBxKdCRefBxWfBxSdBxSfBx2nCQ+dPzy1CRqlAwyRDQmJPTmvPTixLSafOTOpAQOFPz21BwWTBw2ZPzmvNS6nPTivAQCBAweNBwWVNzKpPzyzLyihGRORLyWdMy2lOzetKyObEQyLEw6NEw2LDwuJEQ2LAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAsALAAAAAAQABAAAAfqgAABAgMEBQUGBwgJCguOCwEMDQ4PEJYRDhKNjxMPDBQVFhAXGBUSGY8LGhsQHB0VHh8gFQ6bjgEhIiMMJCUmFbS2CwMnG6IoKSorI7WpEycWFiUsLSou1yXXji8wFiopMTIzNDUz4zbZNxsbODk6Ozw9Pj8pPzEzQDdB60JDOkRFjBw5giRJDCWdlmxwIIRJExAWKDRyMgTIiydLoESRImQKlSUSF1SxUoXAlSBRsGSJoCVICIlbqlThcoBClC5eYFD4EiVIFwUyqywAE0ZMlqNjpJDpIkUBl0dlFChAYOZMmTJoyqQR5icQACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+mail_send-16:actions actions16 16:photo:16 16:R0lGODlhEAAQAIYAAIx+fIRubHxubHxqbHxmZGxeXHRmZGROTFRCPFxKTFxGPPwCBHxqZLyqlMy6pOze3PTq3PTu5Pz27Pzy7LyinOTaxOzi3Ozq3LymlOTOtPz69Pzy5My+tLympPzqzNTGvLSelPzy3BxGbBQ6VPzuzPz65LyupNzOtPz+/GzO5BRejPzq1Pz23LymjHTS5CyixCSavBxqlPz25LymnGTO5CymxCSaxByGtHRiXPzy1CySxCSezGxWVPzuxKyOhMy6nDSaxEzG3PTivNzKpKyOfPzu1FzK5PTmzJR2ZLyihLSWfKyObOzmzPzmvDyaxOzavLSafGRORMy2lOzetDwuJEw6NEw2LEQyLAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAsALAAAAAAQABAAAAfUgAABAgMEBQUGBwgJCguOCwwNDg8QERITFBUWjY8DFxgZGhsaHB0aD5yODB4TGB+kICEaIiOPCwEkJRcmJyYPKCIpKrWqKywTmC0SIi4vMDHEDCsyMg8zEyI0NTY3z7U4Hhs5Mx+0IyI6OyPrIzw9Gys+PxIy2EBBxAs8Qjk5Q0RFWFxAZySfgSMsilRAkiRECHQ08hHgJ0TJkCU/mECU2ISEkowUlpAQ4QTfowNPoAzJIeRJCyjm8kVRIkWIzSkXhwxJtYAKgp9VrFi5QoWKFZ5+AgEAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+matrix-16:actions actions16 16:photo:16 16:R0lGODlhEAAQAIAAAPwCBIQChCH5BAEAAAAALAAAAAAQABAAAAIrhI9pwQHt4Jru2Vsjna919lXKeEimh6UZp1lrCEvkfILyirOby3q1OEv4CwAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+misc-16:actions actions16 16:photo:16 16:R0lGODlhEAAQAIIAAPwCBAQCBISChMTCxDQyNFxaXKSipPz+/CH5BAEAAAAALAAAAAAQABAAAANdCLobwbAFMciLwBFSihBEFHSG8QnmpQQEBX6loI5G5QTlcMgrZSmEmsGxKqRWNV3hMrFlBtDoA1eTEaKHJdMYhR6+gxkF++UMGbiDzvDVioyHAJSHcchuGLQq4k8AACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+move-16:actions actions16 16:photo:16 16:R0lGODlhEAAQAIAAAPwCBAQCBCH5BAEAAAAALAAAAAAQABAAAAImhA8RyKja2HtRrmrxNfDszm3JMpXmiULg6Hyto4kYO49Tfdc04xcAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+news_subscribe-16:actions actions16 16:photo:16 16:R0lGODlhEAAQAIMAAASC/ERCBDQyNAQCBPz+/FxaXIQCBMQCBKSipMTCxATCBMT+xISChASCBAAAAAAAACH5BAEAAAAALAAAAAAQABAAAARsEEgZxLxYDlJsvsJGDN0nFQRhpKR3DSJxrGMphYQgpDI9WLhdTtjjAFApXZI30m2UQwICVigcEzzolKAYIAIFBAKbQjQX3YGGISZvFtzFQr1uDxT4PH0yYE8FCg0/Jn0MAwsNOiY3IQMBEn4RACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+news_unsubscribe-16:actions actions16 16:photo:16 16:R0lGODlhEAAQAIMAAASC/ERCBDQyNAQCBPz+/FxaXIQCBMQCBMTCxPzCxKSipAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAARiEEgZxLxYDlJsvsJGDN0nFQRhpKR3DSJxrGMphYQgpDI9WLhdTtjjAFApXZI30m2UwxjsiOApB4kNLFtQKKopxeCQxR4GAJIXPCInzmhN9zvCljNq8ZvswmzhZHEfOhpofhEAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+next-16:actions actions16 16:photo:16 16:R0lGODlhEAAQAIMAAPwCBFwyXAQCBOze9BwCHNx21LQCvPSi5NRi7AAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAQ3EMhJqwUhAMG7DQOxdVwFFuI1nYZIethwIK0aFwjtwrfh15cAYUjcvWyvkm1Z4TGfkyN0avFHAAAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+ok-16:actions actions16 16:photo:16 16:R0lGODlhEAAQAIIAAPwCBMT+xATCBASCBARCBAQCBEQCBAAAACH5BAEAAAAALAAAAAAQABAAAAM2CLrc/itAF8RkdVyVye4FpzUgJwijORCGUhDDOZbLG6Nd2xjwibIQ2y80sRGIl4IBuWk6Af4EACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+openterm-16:actions actions16 16:photo:16 16:R0lGODlhEAAQAIUAAPwCBFxaXFRSVPz+/PT29OTm5OTi5DQyNDw+PERGRExKTHx+fISChIyKjHRydFxeXDQ2NCQmJBQSFAQCBERCRMTGxHR2dGRiZExOTDw6PCQiJAwODCwuLFRWVOzu7BweHAwKDCwqLHx6fBQWFGxqbGRmZAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAanQIBwSCwKAwKkMslEAgSDqDRKqBYKhkNgcDggEorkMrDQchkNhuOhgEQkk0l5S2lUGpYLJqPZTAwMHB0DCmhqAW0Rfh5zAxgOkBcCFAcfIBMECxwBBAEPFw8dChkhcBMDDAcdnQqtFKSWcQMimx4dGRkQBxGxsg6bBQEawx8jl3GnJFoFHRNXVVNRJYIFDAsL1tgiDiQXFx0HABwcXeQH5OjkRutEfkEAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+paintbrush-16:actions actions16 16:photo:16 16:R0lGODlhEAAQAIIAAPwCBAQCBMTC/AQChPz+/MTCxKSipDQyNCH5BAEAAAAALAAAAAAQABAAAAM7CLrMIS2qN2Sj1U4xugaYZxFE1wUaURQnKpFBYQTuFRiyXDsCd8y7RYhmCQ2IkiHywmkFN84ibfrxJwAAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+paren-16:actions actions16 16:photo:16 16:R0lGODlhEAAQAIEAAPwCBIQChAQCBBQSFCH5BAEAAAAALAAAAAAQABAAAAI3hI+JEQq8mnvyzSOhEWJ3CgLcOILV4IlfUx1cwirfYiEvXL83arANSer5UipM5tIzXjRCh8ZfAAAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+pencil-16:actions actions16 16:photo:16 16:R0lGODlhEAAQAIMAAASC/IQCBMQCBPzCxAQCBPz+/MTCxISChDQyNKSipEQCBAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAARDEMhJZRBD1H2z3lMnjKCFjUJQimOgcmcbELCXzjXq0hV785WCQYcDFQjDXeloMByKG6YTAdwIDAlqSZJSVFeKLcUfAQAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+player_eject-16:actions actions16 16:photo:16 16:R0lGODlhEAAQAIAAAPwCBAQCBCH5BAEAAAAALAAAAAAQABAAAAIbhI+py+0R3IFQUtruXVqn3kkWyIARR4rqKvoFACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+player_end-16:actions actions16 16:photo:16 16:R0lGODlhEAAQAIAAAPwCBAQCBCH5BAEAAAAALAAAAAAQABAAAAIjhI+py8Eb3ENRggrxjRnrVIWcIoYd91FaenysMU6wTNeLXwAAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+player_pause-16:actions actions16 16:photo:16 16:R0lGODlhEAAQAIAAAPwCBAQCBCH5BAEAAAAALAAAAAAQABAAAAIfhI+py+1vgoxzyUCxrZd18ClfmIyVyJ1lqkHuC0N+AQAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+player_start-16:actions actions16 16:photo:16 16:R0lGODlhEAAQAIAAAPwCBAQCBCH5BAEAAAAALAAAAAAQABAAAAIjhI+pyxudwlNyguqkqRZh3h0gl43hpoElqlHt9UKw7NG27BcAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+player_stop-16:actions actions16 16:photo:16 16:R0lGODlhEAAQAIAAAPwCBAQCBCH5BAEAAAAALAAAAAAQABAAAAIahI+py+1vgpySUWpvXXqrHmSaeJEYhKYq6hcAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+previous-16:actions actions16 16:photo:16 16:R0lGODlhEAAQAIMAAPwCBAQCBFwyXOzC7PTq9OTK7IQyhBwCHNRi7LQCzPSi5IQ6jLwKzORy7AAAAAAAACH5BAEAAAAALAAAAAAQABAAAAQ8EMhJKwg4W5o1EGAIbt8wEERhHJ0mIEmiLAH5IYxi1JcnvTOeTdDYcVo1gfHY+hxs0IkvSpV2qtgswB8BACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+prod-16:actions actions16 16:photo:16 16:R0lGODlhEAAQAIAAAPwCBIQChCH5BAEAAAAALAAAAAAQABAAAAIihI+py50Bo4SKHlsDwk9fn21gJzIcV37miKpuZ0nOTBt+AQAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+queue-16:actions actions16 16:photo:16 16:R0lGODlhEAAQAIEAAPwCBAQCBMTC/Pz+/CH5BAEAAAAALAAAAAAQABAAAAI5hI+pFrEahGgPtCinS2GMlknU0Xkflm2l6YEiw8aRGssTXLe3lZsznvuRViwholEcLZCfynGT8BcAACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+redo-16:actions actions16 16:photo:16 16:R0lGODlhEAAQAIUAAPwCBBxOHBxSHBRGHKzCtNzu3MTSzBQ2FLzSxIzCjCSKFCyeHDzCLAxGHAwuFDSCNBxKLES+NHSmfBQ6FBxWJAQaDAQWFAw+HDSyLJzOnISyjMTexAQOBAwmDAw+FMzizAQODDymNKzWrAQKDAwaDEy6TFTGTFSyXDyKTAQCBAwiFBQyHAwSFAwmHAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAZ2QIBwSCwaj0hAICBICgcDQsEgaB4PiIRiW0AEiE3sdsFgcK2CBsCheEAcjgYjoigwJRM2pUK0XDAKGRobDRwKHUcegAsfExUdIEcVCgshImojfEUkCiUmJygHACkqHEQpqKkpogAgK5FOQywtprFDKRwptrZ+QQAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+reload-16:actions actions16 16:photo:16 16:R0lGODlhEAAQAIUAAPwCBCRaJBxWJBxOHBRGBCxeLLTatCSKFCymJBQ6BAwmBNzu3AQCBAQOBCRSJKzWrGy+ZDy+NBxSHFSmTBxWHLTWtCyaHCSSFCx6PETKNBQ+FBwaHCRKJMTixLy6vExOTKyqrFxaXDQyNDw+PBQSFHx6fCwuLJyenDQ2NISChLSytJSSlFxeXAwODCQmJBweHAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAaBQIBQGBAMBALCcCksGA4IQkJBUDIDC6gVwGhshY5HlMn9DiCRL1MyYE8iiapaSKlALBdMRiPckDkdeXt9HgxkGhWDXB4fH4ZMGnxcICEiI45kQiQkDCUmJZskmUIiJyiPQgyoQwwpH35LqqgMKiEjq5obqh8rLCMtowAkLqovuH5BACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+remove-16:actions actions16 16:photo:16 16:R0lGODlhEAAQAIIAAASC/PwCBMQCBEQCBIQCBAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAMuCLrc/hCGFyYLQjQsquLDQ2ScEEJjZkYfyQKlJa2j7AQnMM7NfucLze1FLD78CQAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+revert-16:actions actions16 16:photo:16 16:R0lGODlhEAAQAIQAAAQCBPwCBPz+/PTizCQeHDQyNBweHAQGBAwKBDQ2NPzu5PTi3ERGRCQiJHR2dPTi1CwqLPz6/Mya/Mxm/GQCzFRWVGRmZAwODFxeXExOTExKTERCRBQWFMTCxKSipMzKzCH5BAEAAAEALAAAAAAQABAAAAV9ICCOQWkGIiqsQloCKCqy7UC8MC4URSsMhsDBNWOJEK4TYJfoGU8vmmJBGI5SyyYj0XDQjMvVQwBxRCQTilowFGwrjG5kTo+0x4OdpcLvV0YXIhcGGH0ZFRobOSccfB2PHR4FiyYAGQwdAI8eEAdQKBsZmR+RBpSVVyMHfiEAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+rotate_ccw-16:actions actions16 16:photo:16 16:R0lGODlhEAAQAIIAAPwCBAQCBFxaXIQChEQCBAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAM0CLrcHjA6JcK4ET68MrNDoIgjOYbdJ4IXagIa3IqVFAMEOqpfn067ErBxG0qGsCJyyQT4EwAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+rotate_cw-16:actions actions16 16:photo:16 16:R0lGODlhEAAQAIIAAPwCBAQCBIQChFxaXEQCBAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAMzCLrcHjA6FaG4YbS6At5BR31UKI4mADGhd31rpbmCuZ6qQLA8XvqT2+QhHLKKxqSy4U8AACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+rotate-16:actions actions16 16:photo:16 16:R0lGODlhEAAQAIIAAPwCBAQCBFxaXIQChEQCBAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAM0CLrcHjA6JcK4ET68MrNDoIgjOYbdJ4IXagIa3IqVFAMEOqpfn067ErBxG0qGsCJyyQT4EwAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+rsub-16:actions actions16 16:photo:16 16:R0lGODlhEAAQAIEAAPwCBAQCBIQChAAAACH5BAEAAAAALAAAAAAQABAAAAInhI8Jwd26YJBUTVvT1Rlt3x2f6DjQeQiGigLCC7crK7+yC9sty/oFACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+rsup-16:actions actions16 16:photo:16 16:R0lGODlhEAAQAIEAAPwCBIQChAQCBAAAACH5BAEAAAAALAAAAAAQABAAAAImhI+pGtZ7gpwQyWofnnQ7I4SiuAjlqZgpmqgti7gxfMh1OY6LXwAAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+run-16:actions actions16 16:photo:16 16:R0lGODlhEAAQAIMAAPwCBAQCBPz+/ISChKSipMTCxLS2tLy+vMzOzMTGxNTS1AAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAARlEMgJQqDYyiDGrR8oWJxnCcQXDMU4GEYqFN4UEHB+FEhtv7EBIYEohkjBkwJBqggEMB+ncHhaBsDUZmbAXq67EecQ02x2CMWzkAs504gCO3qcDZjkl11FMJVIN0cqHSpuGYYSfhEAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+signature-16:actions actions16 16:photo:16 16:R0lGODlhEAAQAIMAAFxaXPwCBAQCBDQyNPz+/KSipERCBAQChISCBMTCBPz+xMTC/AQC/MTCxPzerAAAACH5BAEAAAEALAAAAAAQABAAAARwEMhJZwgCiM17DoMkEGRpAmGhmSxhAOrakim6DgeLJApRhCPCgJRT8AhGEVFIQigAxgSQsBgwms8oIrDKDZNGxJY7GuYQULHhQj4shAmAuNAQsFc9xY4uUNgvMiQOBIMOfncjeUhICocXAx6RfwF+EQAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+spellcheck-16:actions actions16 16:photo:16 16:R0lGODlhEAAQAIIAAASC/AQCBPzCxPwCBMQCBIQCBAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAM7CLrcGuHBNZ+NIOJ9O4MTaH2e1nDoiFYZJjgwIAzwy8yEgy84RhWDQa4HCwAHxJgxSPApC83YyQnwJwAAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+sqrt-16:actions actions16 16:photo:16 16:R0lGODlhEAAQAIIAAPwCBIQChAQCBAwODAQGBAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAMyCLrcDiHK6eIL9WmsmwWCAAyiwkGKGILihzLq8p1s9onE9a48Iy28ko/WgRCLyGTDnwAAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+stamp-16:actions actions16 16:photo:16 16:R0lGODlhEAAQAIIAAPwCBAQCBPz+xMTCBISCBAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAANCCLrR+zAIMQKMguh6GR2g1QEBCBLiGGjo+DSpS3IqXNqxNAnwzisSk3BowRltM8IAZVMqi84lLNoqUVfLrOhoVPgTACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+start-16:actions actions16 16:photo:16 16:R0lGODlhEAAQAIUAAPwCBBRSdBRObCQ2TAQCBBxObISevNzu/BRGZPz6/FzC3Pz+/HTS5ByyzJze7Mzq9ITC3AQWLAyWvBSavFyuxAwaLAQSHBRWfBSOrDzW5AyixCS61ETW3CzG1AQeLAweLAxefBSStEze7CSWtCyatBSCnAwmPBRWdByixAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAZrQIBwSCwah4HjUTBQEogFw/M4BQgMh2pxijAkFAhBYJwUPq8LRsPxWDwgkSHhelA0JJIJnlKRWy4YGRoSGxwcHRsecgAfICEiGhMjJBglVVMRgBkgJp0El0MRJyhaRFqipUoAFqmqrapHfkEAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+stop-16:actions actions16 16:photo:16 16:R0lGODlhEAAQAIUAAASC/Gw6NGQuLHQ6NGQmJFweHFQaFPTm5PTa3PTW1Oy+vOS6tNSinKReVDQWFPz+/Nx6fNyCfNyGhNR+dMxybMRiXLxGRIwWFNx2dNx+fNx2bMxuZLQWFBwWFPTu7Pzy9NRqZNRuZMRSVLwmJGwWFNR2dMQiHPTKxMxmXMQyLMxmZNx6dMxiXMRSRMRaVKxybMxaVEQWFMQuJAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAaaQIAQEBAMCAWDYcgkHhAJxYLRcDQBggckIplQKpaLdRh4YDIaSWa94Vw6woAHgv6AMKGPaMQhwQMJJRkfhHmEJhdvRCcgGSCEkCgpbnAECiorGYYfLCItlAAFCygQj5AfbYlwBQwVE5AukG6KBi8tMC0fLi0pHxyzcAAxFxwmMny/wEwOxMm/qlcdJCSJ1H5XQh3a28HY3kx+QQAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+sum-16:actions actions16 16:photo:16 16:R0lGODlhEAAQAIAAAPwCBIQChCH5BAEAAAAALAAAAAAQABAAAAIdhI+py60BowyPJriwQ3qb7oGNyJCZtZHixHpu4xcAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+text_block-16:actions actions16 16:photo:16 16:R0lGODlhEAAQAIAAAPwCBAQCBCH5BAEAAAAALAAAAAAQABAAAAIahI+py40Bo5SOzRvrwlgrfnkJOIkPaaaJXwAAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+text_bold-16:actions actions16 16:photo:16 16:R0lGODlhEAAQAIAAAPwCBAQCBCH5BAEAAAAALAAAAAAQABAAAAIihI+py70BowPQ1HZpwNv212Vg9IGHmIjoWa4ey5DSRNd+AQAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+text-16:actions actions16 16:photo:16 16:R0lGODlhEAAQAIAAAPwCBAQCBCH5BAEAAAAALAAAAAAQABAAAAIlhI8Jwe2/AmpTynqPTXSqrnBM+I0kdmpmGmUp+K4nPMvhYx9+AQAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+text_italic-16:actions actions16 16:photo:16 16:R0lGODlhEAAQAIAAAPwCBAQCBCH5BAEAAAAALAAAAAAQABAAAAIahI+py+0BgztwUmmjBXX3jE0auHHhM5Yq4xcAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+text_under-16:actions actions16 16:photo:16 16:R0lGODlhEAAQAIAAAPwCBAQCBCH5BAEAAAAALAAAAAAQABAAAAIjhI+pu+FxXoOIKpds1oBH7hlYxYxRCaIZ01lhJbHy9tTv7BcAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+toggle_log-16:actions actions16 16:photo:16 16:R0lGODlhEAAQAIMAAPwCBAQCBATCxMTCBPz+xPz+/ERCBASChISCBARCRAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAARaEIQJqpXBBjFI1oGncYU4EUXxSWQZlum6DXDQpeo0tR6KqqgdLXiLBWepHgyYIxF/TKHv9XvtDDfb0So5YHuTgThYCXgH4Q6hqvEGEIm4PLGSyHX4OkZv8UcAACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+top-16:actions actions16 16:photo:16 16:R0lGODlhEAAQAIUAAPwCBAQCBBRObAQSHBRSdISevBRWfAweLNzu/BSOrAQWLPz6/FzC3DzW5BxObHTS5ByyzAyixEze7BSStBRWdAyWvByixCQ2TBRGZJze7CS61BSavAxefMzq9ETW3CSWtAwmPPz+/CzG1ITC3FyuxBSCnAQeLAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAZjQIBwSCwSA8ik0kgUDJhGQsFwgA4FBUTCoLBiF4zGtmt0FBYPSEQyoZCvWQakUok0LISnkHBBYjIVGhscS0UGHRUeHyBWAAIhiYuNAggVIgmMVgYjJBolAZMKJgpIjaanRH5BACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+transform-16:actions actions16 16:photo:16 16:R0lGODlhEAAQAIIAAPwCBAQCBMTCBPz+/Pz+xFxaXAQChAAAACH5BAEAAAAALAAAAAAQABAAAANOCLrcEDAGt4K4F46wmcVCQIzE4F1DukksehVkiUlDYcdfCAyEGI+D2aP3G+UmPF/MAJpwnpuNgMmcKHKgabWSvRi+ums3a32wzmWKw58AACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+undo-16:actions actions16 16:photo:16 16:R0lGODlhEAAQAIUAAPwCBBxSHBxOHMTSzNzu3KzCtBRGHCSKFIzCjLzSxBQ2FAxGHDzCLCyeHBQ+FHSmfAwuFBxKLDSCNMzizISyjJzOnDSyLAw+FAQSDAQeDBxWJAwmDAQOBKzWrDymNAQaDAQODAwaDDyKTFSyXFTGTEy6TAQCBAQKDAwiFBQyHAwSFAwmHAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAZ1QIBwSCwaj0hiQCBICpcDQsFgGAaIguhhi0gohIsrQEDYMhiNrRfgeAQC5fMCAolIDhD2hFI5WC4YRBkaBxsOE2l/RxsHHA4dHmkfRyAbIQ4iIyQlB5NFGCAACiakpSZEJyinTgAcKSesACorgU4mJ6uxR35BACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+unlock-16:actions actions16 16:photo:16 16:R0lGODlhEAAQAIUAAPwCBFxaVAQCBKSipDQyNMTCxISChFxaLFxSJExGHEQ+FCQiDBwaDBweDGxiLHxyNHRuPIR+RIyGZJSSfFxaRGxmLJyaXNzWpNTOnMzGnMS+jJSKTGReLKyqjPTu1NzarLSufKyibJySXIyGVGxiNFxaXLSytPT29Ozu7OTi5NTS1KyurGxqVCQeDJSSjLS2tNTW1KSmpGRiLKSebOzuzJSOXExONExGLAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAaVQIBwOAwYA8SkMCAYOAnKYiFAIAQGyOgVCggYuEovVxztMpdnwAGRSCgUCwOjIeQ6HpCIZDKRUNYMRBUWF4UYGRoWGxyBRR0eHxgaICEiIyR0QyUmJygpKgUrAxMsLUQlKyieoKIuEAunK52fBS8DLiywQySpnjC1Mbi6QjIzNBeSIBY1EQfDQgosLAEUNjY3Co1DfkEAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+up-16:actions actions16 16:photo:16 16:R0lGODlhEAAQAIUAAPwCBBRObAwSHBRSdISevBRWfAweLNzu/BSOrAQWLPz6/FzC3DzW5BxObHTS5ByyzAyixEze7BSStBRWdAyWvByixAQSHCQ2TAQCBBRGZJze7CS61BSavAxefMzq9ETW3CSWtAwmPPz+/CzG1ITC3FyuxBSCnAQeLAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAZfQIBwSCwaj8hhQJAkDggFQxMQIBwQhUSyqlgwsFpjg6BwPCARySSstC4eFAqEURlYhoMLBpPRUDYcHXt7RgUeFB8gIU0BIoiKjAcUIwiLSQUkJRsmGIwJJwmEU6OkfkEAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+view_choose-16:actions actions16 16:photo:16 16:R0lGODlhEAAQAIIAAPwCBDQyNAQCBPz+/PzerAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAMzCLrcGlAs6UAYgwLdLtEcI4ygQo7VVp2oupGpG4vmaUVTemX523qlFcw0a4RqNlkx5k8AACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+view_detailed-16:actions actions16 16:photo:16 16:R0lGODlhEAAQAIIAAPwCBDQyNAQCBPz+/PzerAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAMmCLrc/i1IAVkYg1Z1iRYUKCqitp1oikqBWV3ZOnhkWNagqu+qnwAAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+view_icon-16:actions actions16 16:photo:16 16:R0lGODlhEAAQAIIAAPwCBDQyNAQCBPz+/PzerAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAMwCLrcG1AwGOQbw6qANeCEB3pCSZpO6pgowJZqLKuUGE0dnuEhf8IL1kz1shSHDX8CACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+viewmag--16:actions actions16 16:photo:16 16:R0lGODlhEAAQAIUAAPwCBCQmJDw+PAwODAQCBMza3NTm5MTW1HyChOTy9Mzq7Kze5Kzm7OT29Oz6/Nzy9Lzu7JTW3GTCzLza3NTy9Nz29Ize7HTGzHzK1AwKDMTq7Kzq9JTi7HTW5HzGzMzu9KzS1IzW5Iza5FTK1ESyvLTa3HTK1GzGzGzG1DyqtIzK1AT+/AQGBATCxHRydMTCxAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAZ+QIAQEBAMhkikgFAwHAiC5FCASCQUCwYiKiU0HA9IRAIhSAcTSuXBsFwwk0wyYNBANpyOxPMxIzMgCyEiHSMkGCV+SAQQJicoJCllUgBUECEeKhAIBCuUSxMKIFArBIpJBCxmLQQuL6eUAFCusJSzr7Kmpl0CtLGLvbW2Zn5BACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+viewmag-16:actions actions16 16:photo:16 16:R0lGODlhEAAQAIUAAPwCBCQmJDw+PAwODAQCBMza3NTm5MTW1HyChOTy9Mzq7Kze5Kzm7OT29Oz6/Nzy9Lzu7JTW3GTCzLza3NTy9Nz29Ize7HTGzHzK1AwKDMTq7Kzq9JTi7HTW5HzGzMzu9KzS1IzW5Iza5FTK1ESyvLTa3HTK1GzGzGzG1DyqtIzK1AT+/AQGBATCxHRydMTCxAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAZ8QIAQEBAMhkikgFAwHAiC5FCASCQUCwYiKiU0HA9IRAIhSAcTSuXBsFwwk0wyYNBANpyOxPMxIzMgCyEiHSMkGCV+SAQQJicoJCllUgBUECEeKhAIBCuUSxMKIFArBIpJBCxmLQQuL6eUAFCusJSzr7GLArS5Q7O1tmZ+QQAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+viewmag+-16:actions actions16 16:photo:16 16:R0lGODlhEAAQAIUAAPwCBCQmJDw+PAwODAQCBMza3NTm5MTW1HyChOTy9Mzq7Kze5Kzm7OT29Oz6/Nzy9Lzu7JTW3GTCzLza3NTy9Nz29Ize7HTGzHzK1AwKDMTq7Kzq9JTi7HTW5HzGzMzu9KzS1IzW5Iza5FTK1ESyvLTa3HTK1GzGzGzG1DyqtIzK1AT+/AQGBATCxHRydMTCxAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAaBQIAQEBAMhkikgFAwHAiC5FCASCQUCwYiKiU0HA9IRAIhSAcTSuXBsFwwk0wyYNBANpyOxPMxIzMgCyEiHSMkGCV+SAQQJicoJCllUgBUECEeKhAIBCuUSxMKIFArBIpJBCxmLQQuL6cAsLECrqeys7WxpqZdtK9Ct8C0fsHAZn5BACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+view_multicolumn-16:actions actions16 16:photo:16 16:R0lGODlhEAAQAIIAAPwCBDQyNAQCBPz+/PzerAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAMwCLrc/ixI0WSgKoyBl+beQFACpo1AqXbKCr1wLAMWS08hGG3dSZqin4sxnBmPD38CACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+view_text-16:actions actions16 16:photo:16 16:R0lGODlhEAAQAIAAAPwCBAQCBCH5BAEAAAAALAAAAAAQABAAAAIchI+py40BTQSwuovp3DXkv1ia1IHmIXLiyWJ+AQAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+view_tree-16:actions actions16 16:photo:16 16:R0lGODlhEAAQAIIAAAQCBPwCBDQyNPz+/PzerAAAAAAAAAAAACH5BAEAAAEALAAAAAAQABAAAAMuCLHcri4yGISlj4kxcANgNRBQCIbL6U1Su7bB62rXvGydG25kqpwfIGxILBr9CQAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+window_fullscreen-16:actions actions16 16:photo:16 16:R0lGODlhEAAQAIQAAASC/AQCBNTW1MzOzMTGxLy6vKyurJyenHR2dOTm5Pz+/IQCBOTm1Pz+9Pz+7Pz+5OTmzOTmxOTm3Pz+3OTmvAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAVuICCOZAkEaKquqzAQRWEYR32gSK7vO5oowKAQmPAtjkPFccEwLoaNhuPYDCSeT2B0+lhAfMHF1kF+PL5W7ZhrjqAk4gW53J0s3AG4nP6Y2BcUKAxLZn1+S4EBDAwQEIsUDBQRFJSJLJcoJpojfiEAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+window_new-16:actions actions16 16:photo:16 16:R0lGODlhEAAQAIUAAFxaXGRmZFRWVGQmhFwmfFxeXOTm5MTCxLyWzLySzKyCvKSCvJxyrJRmrIxipIxWpNze3AQCBMTGxJRWtJRatIxOrIRCpHw+pHw6nHQ2lGwulOzu7Pz+/Pz+9Ozu5Pz+7NzexPz+5Pz+hPz+3NzevPz+BMTCBNzetMTCDPz+xNze1NzezPwCBAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAACwALAAAAAAQABAAAAaVQEBAMCAUj0aCYFkwHBAJhWLBYDQcD8ghIjhIJhRKxXLBZDQaiYQLABDe8PiSu+HY7/dOh+PhQvB4eh8fIH6Adh2DHyGFAn+BiQAiISMkhnmSIQAlI5KXHIkfAiUmpCUnhoKLISgpIikmAlwqtCArkiUlIhwiuSKyEcHCESausMEsycrJEaaly9ARIizN1NPQ0dfJfkEAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+window_nofullscreen-16:actions actions16 16:photo:16 16:R0lGODlhEAAQAIQAAASC/AQCBNTW1MzOzMTGxLy6vKyurJyenHR2dIQCBPz+/OTm5Pz+9OTm1Pz+7OTmzPz+5OTmxPz+3OTmvOTm3AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAVsICCOZAkEaKquqzAQRWEYR32gSK7vO5oowKAQmEAtfr9hgpFoGBWJpDDqcAaOUSHDEU08nkOG2AGBfK/aMYQMiRi7Ywe5674yE3I2JCqZoChLeGwSEgmFfgFNDQ8NjQ0TEROSRSyVKSaYI34hACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+wizard-16:actions actions16 16:photo:16 16:R0lGODlhEAAQAIMAAPwCBAQCBPz+xPz+BMTCBPz+/MTCxISChDQyNAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAREEMhJg6BYWhAGv5k2EKMXToSgEqc1DEIhvGAWpOvJFSXZyoXOxxY0BDahQDGg4xgOxmbgiWDqpoeqlGrVcZuSbLfpjwAAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+abbrowser-16:apps apps16 16:photo:16 16:R0lGODlhEAAQAIMAAPwCBAQCBKSipMTCxISChPyqXPzerPz+xPz+/FxaXAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAARhEMgJQqC4Xms1tkIgDEMYXpMYEEJRCIT6Ea5R2DHFtQZBG6dNoHQrsAyH14DDWiENBsQhBtskEs4Dohe4oiqE5So2zElECEKCrCYgQmcRVnRKnFIdC0L4/az7GXiBg4N+EQAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+access-16:apps apps16 16:photo:16 16:R0lGODlhEAAQAIUAAPwCBGRufLzi7PT6/NTq9OTy9MTm7LTW5LTS5LTO5KzC1FyGrExSXHzG3Gy+3FSStPz+/ESGpFSmxEySvEyKrER6nERylExqjFSSrKze7EyCrDxulKzG3GSuzGSitEyWvER2nEx6pKzO5DxmhLze7DxqjExihERadLS6xERulEyOrLTC1KzK3ERWbERujFRefGR+nKTO3LS6zLS+zFRmbAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAAAAAAALAAAAAAQABAAAAa1QEBgSCwWhYIBocA0CA6IhEKwYAQKDccDAolIJpSK5aKwFhyYDGSQoWgqm4uFYyV0PAeIIPIeayZlVw4OFV19FxoSGoFnH1tcayASIRciVgYfEWoQIxcLk4gHlxQCnJBcJBUSdAEHhQediSV5ExWBBxYQGSZelLkHJyhWsHmSISkHKpsrViwWJ1xPXCAtesIBCiUaGHm6LiYvLybXMAQCMQosBwcoMjIzMTQMAC0M9vf49wB+QQAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+acroread-16:apps apps16 16:photo:16 16:R0lGODlhEAAQAIEAAASC/PwCBPz+/AAAACH5BAEAAAAALAAAAAAQABAAAAIlhI+pELshmkOhzmTvyZrFDglRxVEiGUoUualtx7gOC36gDGt+AQAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+agent-16:apps apps16 16:photo:16 16:R0lGODlhEAAQAIIAAPwCBAQCBKSipISChPz+BMTCBISCBERCBCH5BAEAAAAALAAAAAAQABAAAANLCLrcHkFBt4IY8EYKYCAT9xVBYRhbM5KFeaRVy56oSsgQ/TLrB567ym10ChiCnRIRaJx8lDdd86UkEWjHaURZwlKRHpM0xPOYGf4EACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+aktion-16:apps apps16 16:photo:16 16:R0lGODlhEAAQAIEAAPwCBAQCBPz+/AAAACH5BAEAAAAALAAAAAAQABAAAAI5hG+hIuigAmMvLTlfnJiePQndt4SMFFioeaagaEbvySlQF6I2BLPRwYntDLlaylH8VXLDpaiJ8BcAACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+alevt-16:apps apps16 16:photo:16 16:R0lGODlhEAAQAIIAAASC/Pz+/AQCBAT+BPwCBAT+/Pz+BMTCxCH5BAEAAAAALAAAAAAQABAAAANFCLrc/i3ISadQYQhSehFecAGiYJ6oiJmaZrymSrKCJhinXLYmHo+l2skn0KGOPwyBUHPhOrqKVIWsmhqHyqhhPUG+Cn8CACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+applixware-16:apps apps16 16:photo:16 16:R0lGODlhEAAQAIEAAPwCBAQCBKSipAAAACH5BAEAAAAALAAAAAAQABAAAAIyhI+pGbsBHYtHCGARbMhms1HVB0TieJhcl23liXkinAmhy7732UL9GnsZeixczChB+AsAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+ark-16:apps apps16 16:photo:16 16:R0lGODlhEAAQAIIAAASC/PwCBAQCBPyCBPzerAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAANCCLoQwTBK6dy8WNQgptAbB33DQGzlx3xE65RpBwgtCw9sR7e1gO8EGYs3DMoUH5rPqFylSrzaygcjHqdQVUYL8ScAACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+arts-16:apps apps16 16:photo:16 16:R0lGODlhEAAQAIMAAAQCBPz+/KSipPwCBISChAT+BARCBMTCxDQyNAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAMALAAAAAAQABAAAARTEIQ5xbgYAwJksFhhaFTVdeLpURYwAOL7cp6gpmcZHEQPGyIOLRAkiI4GTqmIDG5QwGihuRIBU8boasLzZbEd082QK7VkrvTwo2pvP5m4GxHP+CMAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+background-16:apps apps16 16:photo:16 16:R0lGODlhEAAQAIYAAAQCBJx6NJR2LIxyNJR6NKSORKyaTJyGRJyORKSWTJyKRKSWRKyOPKSKPHRKLEwiFDwSDEQeDGxGJLSeTKSSRKyaVLyaPLyaTGQqFFwyHGwyFEQWFDQKDDQKFEwmFMSiTMyiVJRuNLx+LOS2VOy2ZNSKTFQeFGRGJLyqXMymVOSiVOy6ZOymZKxyTEQODDQOFLymVKxuNMRyJOSeNMx2FLxiJLRiHFQaDDwOFDQODFw+HLSiVHxSLFQiFIQ+HKxmNJxOLJRSLIxGHDwODGw+HNSSPOSWNNRyFOyyVOSOPARihNSORKRSFLR6TPz+/MTCxKTi9JTW7GSy1Lx2THw+FNSOXJRWNISChASq3ASWxARynEQaFMx+JJRSJFRWVARafARSdHxeLFw6HPz+7Pz+5GxKJDwSFIRSNHxGNPz+3MSCPNSWTMyGNPz+9AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAAAAAAALAAAAAAQABAAAAfXgACCg4SFggECAgMEBQYHBwgJCAoLggsMDA0ODxAREg0TCxQVghYWFxgZGhscHR4LE7GCHyAhIiMkJSatJyi+giApGCokKywtLhwvBzAwgiMxGDIzNDU2Nzg5OjsTghc8PT4/QEFC2EMeCZUARKpFRkdISUr09YIYET0qS0wqTUpOnkCJIkWQhxsbpsigUsWKkidXsGTRIkjHgy0YuMjoYkKJFy9KvoARFEZMBAg3UkIA6MTJGDKCBpQ5aebMGTQsx4xJU/FBBIxq1rAB4KTNS56Gkg7yEwgAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+bell-16:apps apps16 16:photo:16 16:R0lGODlhEAAQAIUAAPwCBEwuFLR6PLRqJHQ6DNyuhLx6LKxiHDwiDMSOXLx2NKxaHAQCBHxSLGw+FKRyLFRSHLR6NIRKFExGHNTStOzm1KyqfIRmNHx6PIyGRFxeJNzavOzq1MTGpKymfKyqhKSmdGxqNDw+FPTy7KyuhNzevISGTJSSXLy6jOzq3Ly+lJyabHRyNCQmDKSifAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAZ6QIBwGCgOj8iAYEAIIJ+BguGAeCYTigXDegw0DI4tl/gQj4WB8hkAgUQeEsaEC6FULBdMRjN/QjYcHR4fICEiVn8jFCAkHxiHfiUjHRYfHyZmR4kdICAeJ5lCECgVKSorJysrLC1IEBgVFSgunSAaoWwTIi28DL5HfkEAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+blender-16:apps apps16 16:photo:16 16:R0lGODlhEAAQAIQAAPwCBDwiDPSyNOyKLDweBFQuDFQyDPSeNEQmDIxSHFQ2DEQqDARWjARGdASO5AR6xAQiPOymNAQ2XARqtAQKHOSmNEQiDAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAVqICCOQBCQKBkIA5G+63C+RW3UrIsSQt8fA+CMREAQgIkaUEdSsBK6hZBUeJ4YjRLQIKoOBgVAw/GAAAqRk+EJBkgmDQrAUDGxTAMBAgCR89oFOgF5YQAWdy8EeTeILyV5jY5nBAGFkpJ+IQAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+clock-16:apps apps16 16:photo:16 16:R0lGODlhEAAQAIQAAASC/AQCBPzerPyqXMRaBIQCBISChPz+/KSipMTCxPz+BMTCBPwCBPz+xPzCxMQCBISCBAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAVxICCOQGCeJjkGwkC8RFEEavkax2G8dB0QuRyhhzoBg8MSYsncJXKJZIDZHCoWP1ogGIwGrtnSgUFmHLyNRHhrdpjRamnO/SYkromHdnxwnwkKVxByZW8DgQsQM2JcfwZXO0MBCZSVBgMuLzJaRZ0pfiEAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+colors-16:apps apps16 16:photo:16 16:R0lGODlhEAAQAIMAAPz+BAQCBAQC/MQCxATCxATCBPyqXPwCBPzerAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAARWEMgZ6rwYBCFsvtXWeWA1DBU3ggRhomJQBm14dlJYFFXrbjKNwVDZ9Vw4TWWoKyCDgcNhyXQClVLpMmANIRAhLdGa+36j07GrfM4GiKTAGfsOlmYZfwQAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+cookie-16:apps apps16 16:photo:16 16:R0lGODlhEAAQAIYAAPwCBNzeDJR+BOzmVNSqPOSmBNSCBKRCJFwuBOSOjMRSTLRaXFQODMxiXOS6vIwiJGwKDHx6fKyqrMSOjNRWVLRaVFwCBJyanJSKhHRydPTy9PT29OyytIQSFPz+/JSSlOTGxIQyLMTGxNTW1Nze3Ozq7OTe3FxSTGxqZNza3Ozu7OTm5MzKzLy6vLS2tNTS1FRKPGxWRMSypJyOhKSOfPTu7LyupFQ6HMzOzEw+NJR2XKyOdFxGNHRSNJx6XGRCLHRCDMy+tGxONDwaBHRiVDwyLEQuHJRyVJyCZLSilIxiPIRePHxOJIRWJFwyFEwqDCwWBBQOBDweBKSCbHRKLHRKHIROHGQyBFwyDDQaBIxqTHxOLGQ2DDwiDAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAe4gACCgwABAoSIiAMEiY0ABQaHjoQHCJOECQoLDJeCDQ4PEJMRERITFBUWFxgZhKQaGhsKHB0WHrcfEQARGxu3HiAKIRgiIyQlJicoGym+KissLRIuIi8jJTAwJjEyGzIYKxszNDU2Nzg5MDY6OyQ8PT4jP0BBQkNERUZHOkhJSktMZDQBcsTJEyhRpOybcuSIEipVrFxBgEVKFigATkiRgkSLki1UgFzh8kRKFEQbN3aR0qULIT+BAAAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+date-16:apps apps16 16:photo:16 16:R0lGODlhEAAQAIQAAASC/AQCBPzerPyqXMRaBIQCBISChPz+/KSipMTCxPz+BMTCBPwCBPz+xPzCxMQCBISCBAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAVxICCOQGCeJjkGwkC8RFEEavkax2G8dB0QuRyhhzoBg8MSYsncJXKJZIDZHCoWP1ogGIwGrtnSgUFmHLyNRHhrdpjRamnO/SYkromHdnxwnwkKVxByZW8DgQsQM2JcfwZXO0MBCZSVBgMuLzJaRZ0pfiEAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+dlgedit-16:apps apps16 16:photo:16 16:R0lGODlhEAAQAIIAAPwCBAQCBMTCxFxaXKSipPz+/AQChAAAACH5BAEAAAAALAAAAAAQABAAAANLCLHcrSLKOVccAuvMLf2Rlw0bYRKFGBGZWQioRc4kPKfB+qFFL9ODF+EmKxh6vZOreETCbLiMESkcxnIgATXK2XgFqmxI4SgvAP4EACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+emacs-16:apps apps16 16:photo:16 16:R0lGODlhEAAQAIIAAPwCBAQCBDQyNKSipPz+/FxaXISChMTCxCH5BAEAAAAALAAAAAAQABAAAANJCBASoXCFoVi8VdL6HHQeB4YjSAxnYQygSLzoSTjbEs9vMF86cbyH34NX+AELQ4zO+Nopm6cBC1PBEQwG6gd3SGo7Xa1STIb4EwAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+email-16:apps apps16 16:photo:16 16:R0lGODlhEAAQAIUAAPwCBGRWVAQCBOTWvKSShDwyLOTazOTaxPTuzLSilOzi1OzezPzy7Pzu1NTKtKySfPzy5Ozm3Pzy3PTq1NTCrMS2rNzWvNzOvMy+rLSmlPz69LSejIx2bPz29ISChPz6/Oze1HR2dOTi5Pz+/EQyLJyanKSipOTm5MTCxHx+fAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAaGQIBwSAQEAoJi8RgYEApK49FgOCAS0CFTsVAwEA2CIysMJB6QCEQyoVQsZOMFk3loJoeNAk4MGBQOFAQcDw8IfFoLDB0cEBMICIRxAV6NEB4aHwICk4wLIBYhIiObSxwLBSQkJaOlfQUFpCYnIyMoSVGbtQK3UQCbKCYprkq8m8S+uL4AfkEAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+energy-16:apps apps16 16:photo:16 16:R0lGODlhEAAQAIUAAPwCBAQCBBQSFASiBHS2/JzK/KzW/JzO/ASWBATCBASKBHy+/Hy6/ByuHASCBAR+BATOBARyBIzC/MS+BASeBASOBARaBFym/Pz6BASuBEyW5AR2BJS+7Gyq7PT2BARKBDyC1FSS3IR+BJyaBLy2BPz+BCxuxAQ+BDw+BOzmBARiBCxyxBxetPTyBAQCPAxOpAQ6BAQ6jAQ2fAQ2hLy6BAQubAQydAQmXAQmVAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAahQIBwSCwaj0hAYBkQBJDLAaFgOBCWxcAAkVAsGIyG4/EUBh4ICCIicUAgkwTZjKBULISL3oHJzAMaDhscHYEODhMeExEfSyAhGxsgICIYHiMWJCUYSyYYJw8kIigoKSomKxgmSywYfC0YGCJ8rSwuS7EYJBYYLi+xE5tkARMoMCoYEzEiJDIzMjQiSzExMxGkNTY2NTc4NTNPTOLjWElHfkEAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+enhanced_browsing-16:apps apps16 16:photo:16 16:R0lGODlhEAAQAIMAAPwCBAQCBOTWzIyCrFRSTMy+tCQmVOzi3ExKhAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAARFEMhJq6UhyHy3GNmnAeNEFAZwpuRRBiIMkkOBjKuKTsHtgbISybTLYX6hGc+lSxk3tVtMVOkFck9MMNjB7jqkEQdMlvgjACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+filetypes-16:apps apps16 16:photo:16 16:R0lGODlhEAAQAIMAAPwCBAQCBMT+/ISChKSipPz+/PyqXMTCxFxaXPzerPz+xAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAARfEEgZqg0zV8EHF5XWEUMxkBwGBB9REIZLfBgrkEaen+l6F4cYgpA4vEC+ASIYSxQRnlrncEgoFFQP0laCHpSmnk+AEJQ8ZeRkw0mDVJT3JZQZw+trC77Ouu8pfn8AfhEAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+fonts-16:apps apps16 16:photo:16 16:R0lGODlhEAAQAIIAAASC/AQCBPz+/KSipMTCxPwCBFxaXMQCBCH5BAEAAAAALAAAAAAQABAAAANBCLoQ/C+I4GAMY1ZGN80UJ2jA0BFbUxhjF6BWsQroawEyWhN37vKxQo0ChPhOPaGDIhhADr5FinE4TG5PrBbiTwAAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+gimp-16:apps apps16 16:photo:16 16:R0lGODlhEAAQAIIAAPwCBAQCBISChPz+/FxaXMTCxAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAM6CLrc/izAJVWoD4MgtL2R0F2k6HFiOgjDSRBq0FLUKxYDTmKBnf6gGqz3egWFhEvSQ9kxJ9CotOFPAAAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+go-16:apps apps16 16:photo:16 16:R0lGODlhEAAQAIUAAPwCBERGRFRSVDw6PDQ2NDw+PPz+/ERCROTi5Pz6/AQCBKyurERGPOzq7ISGhNTS1DQyNLSytExKTLy+vKx+RGRiZPTipEQ6LOzu7PT29JSOjOzWlEw+LIyKjIx+dLy6vOy6ZEwuFHQ+DCwqLGQ6HNSWPMymfIxmPMyqjKSipCwuLMzKzHx+fBweHOTm5GxubJSSlAQGBHR2dAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAadQIBwGAgIiMXhgAAoGAwH4QCRKAgVCwSB8AwwCo2n9ZpwMMSFhyEBGQoLEa5BMnkO3G/Kef2sMIdfCxYXT2oGGAIHCk0ZCBobHE8dHk8MFR+LgSAhXSIRdmNCBxScBiObCAYZI25wJE8SJSYECVVDCg8dERchJygPKSqsQgQNKwQFCw8fLC0KLi+LxH9YMDFX0ngAzzLZ2m4K3kN+QQAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+gv-16:apps apps16 16:photo:16 16:R0lGODlhEAAQAIEAAPwCBAQCBPz+/AAAACH5BAEAAAAALAAAAAAQABAAAAIxhI+pwaHZ2jNMWMFmvXk1GznHF4DhWF4cJlKpynpwB73ms3Etiq00EAr+hJGJ0eAvAAAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+gvim-16:apps apps16 16:photo:16 16:R0lGODlhEAAQAIIAAPwCBAQCBAT+BPz+/ASCBMTCxISChAQChCH5BAEAAAAALAAAAAAQABAAAANUCBDMEqupNWoNJNgBV/mfwYCFqASgmA1h57VaO71lXLtPytZEBggZ0E7Vy2BQJEaRcDghP6iGb/IsNKBWKghZzb5EUau4g1KFz1QId+ydRRZwiD8BACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+help_index-16:apps apps16 16:photo:16 16:R0lGODlhEAAQAIMAAPz+BAQCBPwCBAQC/IQCBATCxMT+/Pz+/ISChAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAARTEIRJJZ1ACjF3GGAYaKNFDNfXldLJqmQWcKhcW6tkl1NhFJhdRmIwHIq8m8R3LAIlykCxiZQNl8XsU3eVZg0Y2LD3CyAQlassbEaz1N32Gz5m+SMAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+hwinfo-16:apps apps16 16:photo:16 16:R0lGODlhEAAQAIYAAPwCBBQ+XBRCZAw+XAw6XBRCXCRObCxihCxqjCRijBRSfAwyVCxehDx6nER+pPz+/BxKZAwmPFyWtGyevCRSbBxWfAxGbHSqxGSatCxulBxahBRKbAQiNEyKrBRKdAw6ZAwiNESSLCyCDBxWBDRulBwyRHS6ZDSWHCyKFDQyNCxqlAQmRAwiPMzalPyCBMQCBCx+DAwuRBQqPITCdFxaXCyOFAQeNAwmRAxKdPz6/GyyVMTCxKSirAQCBGzKZAwqTAweNFyuRDyeJFzCTITOdAQiPAQaNHzCbES6NEy6PESyNDyqLDymJPz+xAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAfBgACCAAECAwSDiYMFBgcICQoLC4qCBQwNDg8PEJERlAYNEhOaFBUWnokBBw4SFxgOGRobCxyJBQkNHZoPpR4fICEiIiMBCSSYmgoKFgslJicoKQQKCSoZmgW+KywtLi8pMDEbFRqaAcwyMyc0NSkiNjc4ObsrKyU6Ozw97j4lNhGSfsgAEkQIDxr7YAwh0qKIDSM2jgRpgbDHPhFIMiZRsoTJkhMgobUDMKKkySYjUKockYJSypcrWypKQbOmTT+BAAAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+icons-16:apps apps16 16:photo:16 16:R0lGODlhEAAQAIQAAASC/AQCBPz+/ISChIQChFxaXKSipPzCxPzC/MQCBISCBPyqXMT+/MTCxPwCBMQCxMT+xPz+xMTCBPzerPz+BAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAV+IBCMZBkAqCgMa8uyJxoMRFHUtz3Eqk0MBhxBwJsRaqTcLhUQ3AyHAMI0EtEI0pGrpU38SANFQazYGY+LqUChYDQUxCbB8YjOFJAIpGEePOpZAhITIxJxAg8JDwQPMxISERESfXSVTRIQAZKHLyuOFI8US1RNnTApqCJUAH4hACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+iconthemes-16:apps apps16 16:photo:16 16:R0lGODlhEAAQAIQAAASC/AQCBPz+xISCBPz+/ISChPz+BIQChFxaXMRaBPyqXIQCBPzC/MT+/MTCxMQCxPzCxMT+xMTCBPzerMQCBPwCBAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAWLIBCMwhgMJqCKRBEIpWAMBRGsQXG8sIAiLpwNZpAFEAcbjlc0OI9BVcAWSDgHT9MtF1AsZrmamNpNBAyjwgCxpo0U5h1jOhg0HAMbPHB4QNIDEQIRDi5xfgFzBBITIxJUBQ8UD305EhIwEi45FQ+dFVMSES+PIy2nLgUSBpcGQVomqKc3K7WwIwB+IQAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+input_devices_settings-16:apps apps16 16:photo:16 16:R0lGODlhEAAQAIMAAPwCBAQCBPz+/MTCxHx+fISChKSipKSirATCxAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAARQEMgQpL03iEEx1gOxdR5YbCJXZUbqjusUhGitZkFri0VFUodXoTfjWCi6oY8Skxl6k4FhxZRRRxMC1TBdWn0CAbcZQFAH4WnGjDPiPICYPwIAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+kab-16:apps apps16 16:photo:16 16:R0lGODlhEAAQAIIAAPwCBAQCBISChFxaXKSipDQyNAAAAAAAACH5BAEAAAAALAAAAAAQABAAAANICLocHiyqIMQYUE5Ses8S1V0FGInFIJTalKpsS5FxKDxB/EzV4GUBQsXR87BQnRtNtxphfJ9FAAqbRqUXVfPaMH5MDRx44U8AACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+kappfinder-16:apps apps16 16:photo:16 16:R0lGODlhEAAQAIUAAPwCBExOTDw+PExKTPz+/ISChAQCBPz6/FRSVIyKjJSSlIyOjGRmZNTS1Ozq7Ozu7AxyzPTy9ERCRBQWFIyqxPT29AQ2vOTi5IzG7DR2zNze3Nza3BQSFISy5CRyvBQenISmvBQitMzOzAQGBAw6rDR61Hx6fMzKzAz+/IzW7ASyvCwuLMTGxMTCxBwWFDQyNAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAahQAAgEBAYj0ahckAoEJ5QgkE5fBYO0SeCOigkFE2DeEFgUAUNBwGBeBAcCMHirF4gnhBCBCE5PydqBBQVFhdTSgJPBk8YGRQaG4dCiQQcDh0eHyAhIiN+BHYXJCUNIggmfhUOAQgbJ6YCKGcVKSUaChwGHCYqCyuIDhkhGyIsLcccCL6TFxsNJ8fRLS7KvyNi2GIrAQwK1AsvVOJULi4AfkEAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+karm-16:apps apps16 16:photo:16 16:R0lGODlhEAAQAIMAAPz+BAQCBPz+/ISChMTC/MTCxPzCxMQCBPwCBAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAARTEIRJa5Ui66H3FETHdcTwdcIofkVbUIJbmAEoZl95aoXxUrNdpnAIDFomgRA3yxxhIdxAlaKhAgUNYshyYVGxnMZInS6VzVSQPG0bkWaJZT4B+CMAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+kcalc-16:apps apps16 16:photo:16 16:R0lGODlhEAAQAIMAAPz+BAQCBATCxARCRASChAT+BMTCxFxaXEQCBPzCxPwCBAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAARPEIBAq5U4iM17wJMwjORIfJkYFCs7nKA2rJQLp0Su66ikGcAg8OYTGA6BA/KAIIYsFudPGJQal8uAFVqxUg2JxBYbUGh7k5J6BppwKyB/BAAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+kcharselect-16:apps apps16 16:photo:16 16:R0lGODlhEAAQAIIAAPwCBAQCBISChPz+/MTCxAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAANBCLrR+zCIGWCcI1cLpNCa5YHZsCmj2QTlxrZmmRFVSs4E7X13TqMTXsl36gSHuSIQQ+QYP0kncPCTokzWh3LhTwAAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+kchart-16:apps apps16 16:photo:16 16:R0lGODlhEAAQAIMAAASC/AQCBPz+/ATCBAS6BPyqXPzerPz6/Pz+BPwC/MQCBAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAARcEMgJQqB4WiFulhvXfaEwiJ4mEgExFCMVcENgBEXepdVhG7dcABGr/IJCQ8ICAt4IUIuSKAW2XMOD0qC42AIHV4277YIqKHKCy5txbIoyDy2Nr80yjyVwn5OYfhEAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+kcmdevices-16:apps apps16 16:photo:16 16:R0lGODlhEAAQAIIAAPwCBAQCBPyCBPyqXPzerPz+xPz+/AAAACH5BAEAAAAALAAAAAAQABAAAANMCLrcHjA6BcW4Q8AWLL7EFSwdOIRoOAKBiZ5EPJYvBMeDba5BQfg52ik4KPgKOVYqZiwYjLzb7/c0JCnSo3VFasFEXE5kMymbzwp/AgAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+kcmdf-16:apps apps16 16:photo:16 16:R0lGODlhEAAQAIMAAPwCBAQCBMT+xAT+BASCBATCBMT+/AT+/ASChATCxPz+xPz+BISCBMTCBAAAAAAAACH5BAEAAAAALAAAAAAQABAAAARaEEgZwrwYBCFqvhs3DNYXjChRlWBRjIRqGN4UuEUczMZxsDeXykdEsDQVVSLhQxhBCkVlmXA+KVHFYhFYOoHbMGN6pTQaW8YYiQmcG+q16a0+Zipw+4e9B/gjACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+kcmdrkonqi-16:apps apps16 16:photo:16 16:R0lGODlhEAAQAIIAAPwCBAQCBPzerPz+/PyqXMTCxPz+xAAAACH5BAEAAAAALAAAAAAQABAAAANKCAoRy+6pIESkVuLaKl8b53lOaA3EyIXBUBjpWHKDYNhxNrWv/aaRiWBwKwoIDZCH2EN+TMQjyzR0yhgqiyo4vT4wl48E8g0C/AkAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+kcmkicker-16:apps apps16 16:photo:16 16:R0lGODlhEAAQAIMAAPwCBAQCBFxaXPz+/ISChMTCxPzerPyqXDQyNAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAARaEEgQqr11AjG6/4FGDEVZBOapWSXbToFhoKkZUjJGEEJvyUDDYQaKATElBOJklB0OgY5SWgnmpFJm4PkMjDxLFYXFGSCyN8mocDaD0xsSO6wUS6K1FBzDD/gjACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+kcmkwm-16:apps apps16 16:photo:16 16:R0lGODlhEAAQAIQAAPwCBCRiXCRaVPz+/CRmZFRWVISGhMTCxESSjPT29DR6dDyOhDyCfPTy9CxqZOzu7Ozq7ERubOTm5ARehAxefPz6/ByaxBSOvBSGrAxynAxqlBR6nBRylAxmhARWdFxaXCH5BAEAAAAALAAAAAAQABAAAAWHICCKQTCeqCgMhJCihXEYSPuKRWIoC6PYsEZikHA4FA4CEJdoJh4QgXRwiOAeQudDIpEZIpPwhCImhyGGAmBSOVgumExG055w1ZPZhpPpUDwzExBqAAUDhxUVTQ0QEgWOOIcDiU1QjoSFFYiKDZYFmAWJlE9bkCM5iouWpiIfBa6frrKYAH4hACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+kcmmemory-16:apps apps16 16:photo:16 16:R0lGODlhEAAQAIEAAPwCBISChAQCBMTCxCH5BAEAAAAALAAAAAAQABAAAAI6hA+Bu+HCmgiiRuNoHZBRXQlc84TmcHzm2WVryE1YvMaZIdbVd2zw7lj4bDKGbxK8hHgX3K2JUDD8BQAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+kcmmidi-16:apps apps16 16:photo:16 16:R0lGODlhEAAQAIIAAPwCBAQCBFxaXKSipMTCxPz+/AAAAAAAACH5BAEAAAAALAAAAAAQABAAAAM7CLEL/pDJAONs1V2W1ebWJ46kKJxomi5D2QZEwRSyVMNyngf7Eg8FYHAIZMRoyCSNMSA0n85oszTxJwAAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+kcmpartitions-16:apps apps16 16:photo:16 16:R0lGODlhEAAQAIMAAPwCBAQCBMT+xAT+BASCBATCBMT+/AT+/ASChATCxPz+xPz+BISCBMTCBAAAAAAAACH5BAEAAAAALAAAAAAQABAAAARaEEgZwrwYBCFqvhs3DNYXjChRlWBRjIRqGN4UuEUczMZxsDeXykdEsDQVVSLhQxhBCkVlmXA+KVHFYhFYOoHbMGN6pTQaW8YYiQmcG+q16a0+Zipw+4e9B/gjACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+kcmpci-16:apps apps16 16:photo:16 16:R0lGODlhEAAQAIMAADQyNATCBASCBKSipFxaXAQCBMTC/ISChAQC/IQCBPyCBPz+xPwCBMTCxPz+/AAAACH5BAEAAAwALAAAAAAQABAAAARVEMhJqww4a33F+EL4jUI3EEXoEWzaFbAKzyUQeLihDqrpHQhBQkHyqY49iWCxbDKfJQbASYUCpJbslcHter+NQ3gsLo8bBYd6zWYf0u24GjWr22f+CAAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+kcmprocessor-16:apps apps16 16:photo:16 16:R0lGODlhEAAQAIIAAPwCBAQCBKSipMTCxISChFxaXDQyNAAAACH5BAEAAAAALAAAAAAQABAAAAM7CLrc/jDGQCWgIleH88jCdgXgB4JVQJxsVgQXIQvrWdwwJc/0jcOG0Y7gqwQVQR3R+EgyJcGjZUoF+BMAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+kcmscsi-16:apps apps16 16:photo:16 16:R0lGODlhEAAQAIIAAPwCBAQCBPz+/MTCxKSipISChAAAAAAAACH5BAEAAAAALAAAAAAQABAAAANCCLoQwZAFIV6UYgxi79Qa52WDE3bKV6YOpFpO3L5pJcckLBB8/wQEDezWAQpZqIWxFNAUkqkg6HmJOqGuArUqwfoTACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+kcmsound-16:apps apps16 16:photo:16 16:R0lGODlhEAAQAIIAAPwCBAQC/AQCxFxaXAQChAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAM7CLrcDiE+F4SQU4UBLH6VoHjT1okQR6mnuTYuJMWaGlkXW2u4QOipRYDws82AjJsHKez9MgrigAkF+BMAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+kcmsystem-16:apps apps16 16:photo:16 16:R0lGODlhEAAQAIMAAPwCBGxqFAQCBPz+/PTqtOTOfMSyPNze3Ozi5KyeLMTCxMzGzKSipOTe5MTGxAAAACH5BAEAAAAALAAAAAAQABAAAARfEMhJQah4ihFunsFAEIVXCVJACIJhoBK6CerawsA8HAhbuAnYZrBDKBYMWpCy4S2QSRazyBIwrrjcoNFQzK4KR1bQcHhZjGM2BgWLMYJ2enForHPJtNj+kfHvcB8AfhEAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+kcmx-16:apps apps16 16:photo:16 16:R0lGODlhEAAQAIAAAASC/PwCBCH5BAEAAAAALAAAAAAQABAAAAIlhI+pm+HB4HkS1flszOCq7C2Qw0wdJ2Lk16BGeK5dSZX2jS9+AQAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+kcontrol-16:apps apps16 16:photo:16 16:R0lGODlhEAAQAIUAAASC/CRyBBxSBExOTNzipOTijOz67NT21LzutJTmlGzaXPz+/OTi5AQCBLy+JKSiJES2NES2LESyLDQyNLy+vLzWhLzWjLS2tGRiZDymJASChIQCBDyuLLzShDyiJMQ2LATCxMQKDDSaHDSWFCQ6tMT+/PzCxLzuvCyKDDSSFKyqrMTCxGzabDw+PISChASSBAT+BDzOPNTW3AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAacQEBgSAwIBsikkFAwHBAJhWBBpTIaAccDAolEJIKJWEzBMiuWCyYjaLjd5exDIsE02A1NY9OIMzkcHRkebW99WFoVahkfbSANIYdCBh52IiOFb2VCByIWIh0kbSUNJpIBJ6CgKJlwDUIJKSooswIUt7crrwEsKC2+rC7CLzAuuzEoycmtbgAAAtDR0DLGztYALbm426/Wht9vzn5BACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+kcron-16:apps apps16 16:photo:16 16:R0lGODlhEAAQAIQAADxePARCBAQuBNTS1OTi3LSytAQeBMTC/Pz+/AQCBOTi5MTCtISCZAQiBISCfKSipFRWZGRiZERCRHRyZMTOxDxOPMTCxIyCjCQiJAQOBLS2tAAAAAAAAAAAAAAAAAAAACH5BAAAAAAALAAAAAAQABAAAAWFIBCMpCCQpDgQLFusLVEYAXEgOJIQOXIkNF5v19MFWQrCgsFYxIC1InEYvOWmuF9QKrw2aoSkYtksOBwEaBeXeEAiiIdD8rUNJw8EBUGobIcQFggXLglgCohLGA95CQMOGVFDEQ4YGhERdAEWCZ2dDwsSEHMOEA0ABqmqGRkGDQ2pDRV+IQAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+kdevelop-16:apps apps16 16:photo:16 16:R0lGODlhEAAQAIYAAPwCBGSKXEx6RFR+RFSORISidJzCjJS+hISydHSqZDxuNIyuhKzOpLTSrKTGlHyybGyqVDx2LHyedKzKpLzWtMzexLzavIS2fFyWTDyCLCxiHNTmzPT29PT69NTm1GSWVESKNCRmFOz27Pz69PT27MTKxJymnIS6dESGNDR6HFyCTIy2fNzm1Ozy5JyenISKhISOhMTKvESGLBxaFOzy7JSWlIySjCx2FBxGDIyOjOTu5BQ+DFSGRDR+JCx6FBxODDx2NGyaXCRyFCx2HCRqFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAexgACCg4SFhgABAgMEh4MFBQYHCAkCCocLDA0MDgcPEAQRhRITFBUWDAcXEBgZGoQIFBscHRweBgkfICGDAQcUIiMdJCUmJxgoKbsAKissLSQuLzAxFgQyKTOCKgk0NS/fNiQtBBk3OIIEEC0cMDkvJiQ6ICk3O4M8FCQcNjAcJBM9fPwgBCQICxI0XtBgQeCGEHuEFGCYwILFBAJCHh7SEGJIRiI/IDaagSNko5OF/AQCACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+kdisknav-16:apps apps16 16:photo:16 16:R0lGODlhEAAQAIUAAPwCBAQCBERCBBQWFPz+xPz+BISCBERCRPz+/OTm5HRydAQ+XHR2dKSmpNTS1Hy+1AxypNTu9ITC3ARypExOTFSyzHS61JTK3MTi7CwqLBR+rASGtDyixFyuzDw+PAxWhAxmnBRypISitCRujAxelAxmlFSixMzKzCRqlMzOzMTGxMS+vGxubLy+vLy6vKyurCwuLGRiZLSytFxaXJyenGxqbDw6PDw6NAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAafQIAQEBAYh0jkQEAoFAxJ5EGAaAoSh8BBEUBSrQtGw5EodwHfgsBgeEAWijGW2XTaDRHJJExBrwl1AhUWFxgRDwdCGWkCGhsbHB0WGB5CjB8fICGOGxaJaWwGIiMfJCUTJh50dk4ODiejHyiff2oGDikqK7osiUIGai0pJyouxi+9v2pEMDEyLTIyDckCy0gBMDM0DTU2flFDARk3AH5BACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+kdmconfig-16:apps apps16 16:photo:16 16:R0lGODlhEAAQAIMAAPwCBAQCBPz+/MTCxISChMT+/ATCxASChFxaXAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAARaEMg5gw00yyDGIAR1YUDggeFWFIZhnSBZrsZxdIOFEGTA2oeBAHeyuGwvzxBlYdUOLROMFzDQntJPrNoqAKUBaqnV+k57ZORruykHDj2LqIzUVKp1u0iuB/gjACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+kdvi-16:apps apps16 16:photo:16 16:R0lGODlhEAAQAIEAAPwCBAQCBPz+/MTCxCH5BAEAAAAALAAAAAAQABAAAAJCRI4ZwCYPo1gsiIHHxY86KXmWdiGkCA1Wp6Htc07NOsEv2oVyldLHbuBgEhORJhOxGEkkiLJybCZ3iqrD08hmF/4CACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+keditbookmarks-16:apps apps16 16:photo:16 16:R0lGODlhEAAQAIQAAPwCBCwqLLSytLy+vERGRFRWVDQ2NKSmpAQCBKyurMTGxISChJyanHR2dIyKjGxubHRydGRmZIyOjFxeXHx6fAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAVbICACwWieY1CibCCsrBkMb0zchSEcNYskCtqBBzshFkOGQFk0IRqOxqPBODRHCMhCQKteRc9FI/KQWGOIyFYgkDC+gPR4snCcfRGKOIKIgSMQE31+f4OEYCZ+IQAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+kedit-16:apps apps16 16:photo:16 16:R0lGODlhEAAQAIMAAPwCBAQCBASCBPz+xPyqXERCBARCBISChMTCxPz+/FxaXAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAARXEMgpQ6B4WnGzDgJHWWMYdkAwEF1QFKe2oqDZztr7GpfKjrvAAeFDpQq8ISIRYBotSoTUkiC2ostqYps49BSKIVfaBbcC4MMWcTAbU+iw21NBk+gjuj8CACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+key_bindings-16:apps apps16 16:photo:16 16:R0lGODlhEAAQAIIAAPwCBAQCBISChPz+/MTCxAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAANMCAoRy2IEuYIQDsrBld0NN4XaJF5iCppWxBGtCscEAbkDfH2wh+ogiudD5AhvoZWoJEFtckBTE1dzKKfQjMtUjfQUzizjeBN7HgB/AgAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+keyboard-16:apps apps16 16:photo:16 16:R0lGODlhEAAQAIIAAPwCBAQCBISChPz+/MTCxAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAANBCLrR+zCIGWCcI1cLpNCa5YHZsCmj2QTlxrZmmRFVSs4E7X13TqMTXsl36gSHuSIQQ+QYP0kncPCTokzWh3LhTwAAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+keyboard_layout-16:apps apps16 16:photo:16 16:R0lGODlhEAAQAIMAAPz+BAQCBPwCBMT+/AQC/Pz+/PzCxKSipISChAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAARSEEgZqr1hUjFIEQXBZVogDt/XYWxgoEVFzEUt3MGNm7SND4aarPfBFQYCQmtpiTErh+ahMK1SqVHoYcvtUptX67SWDXTPXWltva5q0WfEs+WPAAAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+keystone-16:apps apps16 16:photo:16 16:R0lGODlhEAAQAIIAAPwCBAQCBMTCxISChPz+/MT+/AAAAAAAACH5BAEAAAAALAAAAAAQABAAAAM/CBDcHkoFQasVUIrBe8fRNDwMAWpjUThmtmxk0IYwOaPx/V6XG3hAjmsRa0Qkg6NSOVo6F0nG88g4TUNDpT8BACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+kfax-16:apps apps16 16:photo:16 16:R0lGODlhEAAQAIMAAASC/AQCBPz+/MTCxISChERCBFxaXPwCBAT+BARCRAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAARVEMhJQ6C4imEzDkLIXR4ADqFAThYRoFu4ti6YbhfdFm+aEzWgAWhB5QyGAMEwWA4PlpyFCWwOkAhCgla1EqxXKbD7vSJnyuUXyV5JuOxtqZV0z+3+CAAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+kfind-16:apps apps16 16:photo:16 16:R0lGODlhEAAQAIUAAPwCBExOTDw+PExKTPz+/ISChAQCBPz6/FRSVIyKjJSSlIyOjGRmZNTS1Ozq7Ozu7AxyzPTy9ERCRBQWFIyqxPT29AQ2vOTi5IzG7DR2zNze3Nza3BQSFISy5CRyvBQenISmvBQitMzOzAQGBAw6rDR61Hx6fMzKzAz+/IzW7ASyvCwuLMTGxMTCxBwWFDQyNAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAahQAAgEBAYj0ahckAoEJ5QgkE5fBYO0SeCOigkFE2DeEFgUAUNBwGBeBAcCMHirF4gnhBCBCE5PydqBBQVFhdTSgJPBk8YGRQaG4dCiQQcDh0eHyAhIiN+BHYXJCUNIggmfhUOAQgbJ6YCKGcVKSUaChwGHCYqCyuIDhkhGyIsLcccCL6TFxsNJ8fRLS7KvyNi2GIrAQwK1AsvVOJULi4AfkEAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+kfloppy-16:apps apps16 16:photo:16 16:R0lGODlhEAAQAIMAAPz+BAQCBISChKSipFxaXPyCBAQChMQCBPz+/AQC/MTCxATCxAQCxAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAARWEMgZgggz5zAIBp9GFV8oSqRkikFanapBVgccGAiJBDWL74jd4UUxGBI/IcJQMigSimPSsMDcEFCFVkptKhCDgSBB7m4sA2y5eqqMF2YYKMBgys8nfwQAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+kfm-16:apps apps16 16:photo:16 16:R0lGODlhEAAQAIQAAPwCBGRiZERGRPz+/MTCxAQCBMTGxPzerLy+vLy6vPyqXLS2tLSytKyurKyqrKSmpKSipJyenISChJyanJSWlJSSlIyOjIyKjAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAV+IBCMZCAIQKoGw0C8MFEUqmgYrTwXL50GhtegcCgedr4AIpEYHhQKopEWSCwYw1fUeBQxGo3hiBCIUR2OxyAwG8OoD0hkICFABMiZKBKZ0GNkPiIUFBUuEoiIMisVFRZ/MWwqAheVfxICdZIpmZZ1kYIAMxcuJWWhKXl5Kn4hACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+kfm_home-16:apps apps16 16:photo:16 16:R0lGODlhEAAQAIUAAPwCBDw6PBQWFCQiJAQCBFxeXMTCxJyanDwyLDQqLFRSVLSytJSSlISChCQmJERGRFRWVGxubKSmpJyenGRmZLy+vOzq7OTi5Ly6vGRiZPTy9Pz6/OTm5ExOTPT29BwaHNza3NS6tJRqRGQqBNy6pIyKjDwGBPTe1JSWlDQyNOTGrNRiBGwmBIRaLNymdLxWBHxGFNySXCwqLKyqrNR6LKxGBNTS1NTW1Jw+BEweDDQ2NAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAaoQIBwCAgIiEjAgAAoGA6I5DBBUBgWjIZDqnwYGgVIoTGQQgyRiGRCgZCR1nTFcsFkHm9hBp2paDYbHAsZHW9eERkYGh4eGx4ag3gfSgMTIBshIiMkGyAlCCZTEpciJyQjGxcoKUQBEhcbIiorLB4XEltDrhcaLS4vtbcJra8bMDHAGrcyrTMXHjA0NSypEsO6EzY3IzU4OdoTzK0BCAkDMgkIOjJlAH5BACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+kfract-16:apps apps16 16:photo:16 16:R0lGODlhEAAQAIEAAPwCBAQCBAQCxAAAACH5BAEAAAAALAAAAAAQABAAAAInhI+pyxudwoNACiFbuBzHt3XeEYbiBF5mN5HpyayqVrY0hdj4vvgFACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+kghostview-16:apps apps16 16:photo:16 16:R0lGODlhEAAQAIEAAPwCBAQCBPz+/MTCxCH5BAEAAAAALAAAAAAQABAAAAJCRI4ZwCYPo1gsiIHHxY86KXmWdiGkCA1Wp6Htc07NOsEv2oVyldLHbuBgEhORJhOxGEkkiLJybCZ3iqrD08hmF/4CACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+khelpcenter-16:apps apps16 16:photo:16 16:R0lGODlhEAAQAIUAAASC/FRWVExOTKwCBJQCBIwaHFRSVPz6/LxSVOSqrNyanIQKDHwKDHwCBPz+/OTm5Ozu7JwCBMRKTMxubLxCRNTW1IyOjDQyNEwCBGQCBJyanMRaXNyOjKQODIRydKQqLOzCxEQCBNze3Ly6vJQKDDQ2NIQCBCwCBGwCBFwCBDw6PNyipDwCBKSipEQ6PDw+PJR2dMRiZHwSFPz29BQSFIwODJwuLMTGxAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAabQIBwSCwaAQHBgFA4Cg2BwwGRUCwYxobD8YBEBpLJoEGMUA4VywWTaUQOmstww+l45MKM5/DAf0AIDSFFBiIHI3IEHCSDRgEOFSUAJhQNJ0coYikAKpB4RQwrJiycWy0uRQ2AKKQAL3wwKEMCMDEdGEMvWxIKDTICIzMQKZdDKQ0dMSAxBzMPGjRGGCkoNTYaNzTRThgnJ9pFfkEAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+khexedit-16:apps apps16 16:photo:16 16:R0lGODlhEAAQAIMAAPwCBAQCBMTC/Pz+/MTCxFxaXPz+xPyCBKSipAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAARZEEgZ6rw4CB3wrJUggt03nANIoCUQoDDcvqJAaHXqunBxywFDZWArDHy4lOEwTBEKgYJRyeQJEIEnYrQsvU63abBKIYq2m+4s5mTeTLVRSFdmyy6kvGXijwAAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+kicker-16:apps apps16 16:photo:16 16:R0lGODlhEAAQAIIAAPwCBAQCBPz+/FxaXMTCxDQyNAAAAAAAACH5BAEAAAAALAAAAAAQABAAAANECLrcEDDKGYQV4+qbie9eGIJEVxTe+QmjUFgnXLLr615oF8x2v0I8DWpF2GV6slkLKSMdYT4nS0WgSkXYAWUbcXgX/gQAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+kiconedit-16:apps apps16 16:photo:16 16:R0lGODlhEAAQAIQAAPwC/AQCBMRaBPyqXPzerPyCBPzCxPwCBPz+xMTCBPz+BISCBMT+xATCBAT+BASCBMTC/AQCxAQC/AQChAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAVkICCOpBicZQoEwjAE6hgQQwvH81AU8OnfuR3QYDgcgAKhjGj8+UgzQkHHw+2mQlQpgEAkFInEYnGDhr/h8VPGYDQcjcZj/iiv4u84vQ6FQCISERETgxN2AX6AgoQThlBOkCR+IQAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+killustrator-16:apps apps16 16:photo:16 16:R0lGODlhEAAQAIIAAPwCBAQCBAT+/Pz+/KSipPzerPyqXAAAACH5BAEAAAAALAAAAAAQABAAAANHCLrcGzBK+YK4OAcAx4AXIURj4J2fJYhWh35pOHKoG8+mFxS5HimmXU8HBH4MQyJD+FI+kM3Ug9eENALQk9VhDW4c1y/YnwAAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+kit-16:apps apps16 16:photo:16 16:R0lGODlhEAAQAIAAAPwCBAQCxCH5BAEAAAAALAAAAAAQABAAAAIghI+pFrHbXmpRMmoBxXB75IWcKIKk022ZunJtdlSw5BcAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+kjots-16:apps apps16 16:photo:16 16:R0lGODlhEAAQAIIAAPwCBAQCBPzerISChPz+/MTCxMTC/AAAACH5BAEAAAAALAAAAAAQABAAAAM8CAHc7kGsR1mc9d1Md/icIgXDB1YXMZQnZBJEIbdKABPGTbSfnuc8mw8W1OlotYER2fgod5iMKRqiNvwJACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+klaptopdaemon-16:apps apps16 16:photo:16 16:R0lGODlhEAAQAIMAAPwCBAQCBPz+/KSipAT+BISChFxaXPz+BMRaBPyCBMTCBDQyNAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAARtEIBAq5w1TBGEGIM2ESTlVUNhaAFJUAcXgAXCZkFyJEoiIArWYQjj+Xi2yfBA0SU6CuAts4MCk4EdcxbznFhOCsjrWUxRhbRBBk48Z6kCZ2GeuN9xucF8FqcEBnt1OW4saSp7IoRPEjgiGBV+EQAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+klipper-16:apps apps16 16:photo:16 16:R0lGODlhEAAQAIYAAPwCBFQyDEwuFEQuDISGhFRSVEQqFEQuFPz+/PTy7Nze3PT29Ozu7DQyNJx6VIxuRIRiLEwuDIxSFHxSHKSipLSytGRiZGRCHDwmFOzm3HxOHIRWHOTazHRCFHxOFEwyFNTKvHROHFxeXJRqLIxWFFw6DFQ2DNTCrIRaJJxuPMSynHRKHIxqRMSqjGRGHMSifJxeFKyGXHxKFLyaXKyObGxGFEwyDKyOXIxeHKSOdFQ6FIx2THRKFFw+FKx6NKRmFKxuFLyCPLyOTLyabLSefLyijFw6FJRmJIxWHHRGFFQ2FAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAfFgAAAAQIDBAWIiAMGA4IABwgJCgUICwwKDQ4PEBGCEQsSEwUUFQQWDRepGJ4ZEggIDbENrxobAZ4cHa+7uxAeH4IGICEIIsbGFggjJCWCJicovLwpIcAAGCorCBbc3AoILB2rgy2u0q8OLrcAJS8wr8nJrzEy6yUz79sivDQ1jQA2buB4tU8eghw6xgnYwePcqxcdbAjq4eMHECA+ggiZMYRIESPjShyBgQPJBB48OsiokaTDOoACItgwYULJhw8BbIzzEwgAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+kljettool-16:apps apps16 16:photo:16 16:R0lGODlhEAAQAIMAAPwCBAQCBPz+/MTCxKSipISChFxaXATCBDQyNATCxASChAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAReEMg5Q6CYBiFsxhvXXZklimRlDWenBQNRzKJRXCsxHPFcIDGcILYbGHqzAY41NCQSiuNgMLPAmNTElFoFWKecqe8mCRAIq6nt5imb0TC2wZByny3zdslMr3+8fgB+EQAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+klpq-16:apps apps16 16:photo:16 16:R0lGODlhEAAQAIMAAPwCBAQCBMTCxFxaXISChPz+/ISCBPz+BKSipAT+BAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAARaEMhJqwUh3xqEz8EWDKT3aVNAFAVBDqYQYitbjARhGDJt34Nc4SBAZAomoDAhKAwyTZZp5XE+O0lp9QVFeLNWUpflJXheTww2ijiLKSBPW/C+xOmzjQRU8UcAACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+kmail-16:apps apps16 16:photo:16 16:R0lGODlhEAAQAIMAAPwCBAQCBPyqXPz+/PzerMTCxFxaXIQCBPyCBAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAReEMgJgrWU4iAGIUFWFYMldF+okUPJeeAUDEY7FFzXqnNdkIGDgHAKzWgsDuJAFBhbtd1peTAWDFjpaZg6skonYfOZzC3HlduuMj1UZUDZ6RMblTTDokylQYsyFwB+EQAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+kmenuedit-16:apps apps16 16:photo:16 16:R0lGODlhEAAQAIMAAPwCBAQCBMTCxAT+/ATCxASChPyqXPz+xMRaBISChAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAARLEMhAq5UY2B3yFGDIYcFgnuNErGwQCl1VzHSJBsbBUSxBIbnEC0YrxICHhFKZCiATlldn8gSlNE7YEurRQHdd19Aa3m6nmV0F448AACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+kmid-16:apps apps16 16:photo:16 16:R0lGODlhEAAQAIMAAASC/AQCBKSipISChMTCxPz+BAT+BFxaXPwCBATCxARCRAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAARUEMgJgqVYWsFv3lwoeFMwEIQYkkFhouoQlIFhHvCgz9oxjoeDblc6+Q4B4ZBXCSBQx+GIZhNAOURaACsYypq0kNeSSLC2uxm5fGZqAgqFO0OjT/wRACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+kmidi-16:apps apps16 16:photo:16 16:R0lGODlhEAAQAIEAAPwCBAQCBPz+/Lz+/CH5BAEAAAAALAAAAAAQABAAAAIzhI+By7oBo5RH2GvDRRhre0xiVHXZVpqfEI5iKkQxalzQIIPGhI+pSAN4cjqA68VIHvwFACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+kmix-16:apps apps16 16:photo:16 16:R0lGODlhEAAQAIMAAPwCBFxaXAT+/DQyNATCxMTCxPz+/AQCBKSipASChAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAARWEMgJQqCXziDG2JoUEENhZBkmHIWJVptAmqcIW/Js1MiF56TBzkckAAcHoa9nMRKeA4TyJk0knsHhTeK5khBaH2VwLYVh40TJhQ6RzeIQV32Quz8hfwQAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+knewsticker-16:apps apps16 16:photo:16 16:R0lGODlhEAAQAIIAAAQCBPwCBMTCBPz+xPzCxISCBKSipISChCH5BAEAAAEALAAAAAAQABAAAANTCBCsysEpseQDI08KSPdYNmwUYSraUDRC64iAMbIuLGtOS423BhKFmgj2C+5EhsOoWEsOnB0FsKl0jnLUp3IG0O2sMNpRVHBAJpjyA8KOmNsMfwIAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+knode-16:apps apps16 16:photo:16 16:R0lGODlhEAAQAIYAABwaDAQCBPwCBDw6NERCFJSWJAwGBLy+rPz+7IyOJJyeLBQWDIRqZIxydPzCxDQuHPTWzOSypBweDKyqLJyWJKySjPTOxKSCfOyCfOyKhJSSJJSSLFRWTDw+NOSqnOR+dOyWjOzGvNza1ERGFJSWLLy+ZPTGvOTOxOSSjOy6rLSypJSWjKSinAwODHR2HISCJOTWtPTe1Pz+9Ozu5IyKfNzazPy6tExCHMzKfPTy7KyupKSmnEQ2HHx+HKSiLKSiJPz65OzuzOTmrKSmLIyKJLS2TPTyxOzuvNTSlLy6fHx6RLy+RJyaNLS2NNTSnLy6lLy6dMzKpGxqXCQiDKyuNMS+PLy6VMTGPMzKrOzq1CwmDLy+PMzGTNTWxMzOxERCPKSiNCQmJERCRERCHAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAIALAAAAAAQABAAAAffgAABAoQBhoOEAgOGBAUEAocBBoOLBwgBBAkKBAsMAQ0ODwOWEBEBEhMUFAQVFhejCBYYGRCGGhsKFBwdlh4fICEIIoMjBRQkJSYnKCkWCCorLIMtLgUvCjAxMjIzNCw1KoY2NxovFDjbMjk6OjuHNjw9Pj8lMggIQEFCATaDBD4JhhApgsDIESFIkigxJGDEkiJFmDQB4uQJFBxPokgRMIVKkypFrFxBgCVjlnuXtARQUGTLFS4yunipgRLBF0I3moChgsQeAg5hxDBMNCUAlyAcOCBKxJTQmKVNBfgJBAAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+knotes-16:apps apps16 16:photo:16 16:R0lGODlhEAAQAIMAAASC/AQCBISChMTCxPz+xPwCBPz+/ISCBPz+BMTCBIQCBAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAARIEMhJZQg1z6vzxR0VCKE4gCE2lhcRnF1LuAInBjNRfDMn64WCQRCcHS6IRE6nyB0Sx0ACkcwloFiflKp8Pm2bbRblkYJZHX8EACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+knotify-16:apps apps16 16:photo:16 16:R0lGODlhEAAQAIIAAPwCBAQCBPz+/Pz+BPyqXMRaBAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAMyCLoQznAFIUKE09krZ+VS9XBaMBBbZKIBUaSYa40kTIPNhyvazje+G2gFI8l8jaLCnwAAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+konqueror-16:apps apps16 16:photo:16 16:R0lGODlhEAAQAIYAAPwCBFxONCROfCRKfKx6LNy+bNTOpGSS1DRupAwyXBRSnPTSjPTqvOzqzMzSvHSSlKy6ZDxutAxCpBQ2XBxepLTKvPzqzPzy5OTShLS2dLSqRFR2jBRerBQ+jOTixOzetNS2XHx6XDR2tCRexBwyTDyKzOTavPzq1OzKdCx23BRKtCQ6VCQmHFSa7IyirOzSnGSGpIR+bFSO1DyK7DR+5CRixBw2VDQuHFye7IS27NzGXISuhEyS5DR25BRWxBQ+lBQyXCQqPCxSfGyu7GyerKy2ZFR+rERqfCRmxBROtBQ+fBwuTBwmNDSW9JyabLyqRIx+TExSXBQ6bAQCBBQ6ZBxapDR+zBxq3LyaLJySRHxqPGxeNBxGbCRmrHRyRERONDRKNDQ2JCQuLAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAeygACCg4SFhgABAQIDh4MBBAUGBwgDCYcKCwwNDg8QERIThRQVFhcNGBkaGxwdoYMDHhcXHxggISIjEiSvJSYXJwsoISkpIyorLIIDLS4WLzAxMjM0NSo2N8o4OS46OzwzPSk+P0BBgkI8Q0NERUZHCEhJSktMgwk4Qy1NTk9QUVJLphCiUsWKlStYsmjZQiJgIS4KuijQ4iXAFxYCDVFJwGUFmDBhMjYSw0KMyEYoBfkJBAAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+konsole-16:apps apps16 16:photo:16 16:R0lGODlhEAAQAIUAAPwCBFxaXFRSVPz+/PT29OTm5OTi5DQyNDw+PERGRExKTHx+fISChIyKjHRydFxeXDQ2NCQmJBQSFAQCBERCRMTGxHR2dGRiZExOTDw6PCQiJAwODCwuLFRWVOzu7BweHAwKDCwqLHx6fBQWFGxqbGRmZAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAanQIBwSCwKAwKkMslEAgSDqDRKqBYKhkNgcDggEorkMrDQchkNhuOhgEQkk0l5S2lUGpYLJqPZTAwMHB0DCmhqAW0Rfh5zAxgOkBcCFAcfIBMECxwBBAEPFw8dChkhcBMDDAcdnQqtFKSWcQMimx4dGRkQBxGxsg6bBQEawx8jl3GnJFoFHRNXVVNRJYIFDAsL1tgiDiQXFx0HABwcXeQH5OjkRutEfkEAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+korganizer-16:apps apps16 16:photo:16 16:R0lGODlhEAAQAIMAAPwCBAQCBASCBISChFxaXPz+/Pz+vKSipLy+/MTCxPz+BPyqXLxaBAQ+BPy+vAAAACH5BAEAAAAALAAAAAAQABAAAARmEIRJqw1ikM37FsFQjMZ4lAVKBESBjCYsFiuBkkk5KG1dJL+CZjBYMES+l2x3RCBqtxHBOFD6DkHmAQj0yXgzmFdIhY2erBJBwTiczDSWq0Eg1gvYrvyHxcMdUEojYWIYHocbDX4RACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+korn-16:apps apps16 16:photo:16 16:R0lGODlhEAAQAIMAAASC/AQCBMTCxPz+/PwCBMQCBFxaXISChKSipAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAARSEMgQpL03CEExDkO4dR6ghSFBkJa2CSlRcNX0voNQ5Ebn3pvdAWHo/W6IHUJwGFCAm+SrSTm+ZgcY6XnDhlim3wwxKNYymiX17HmCSxO4/OKPAAAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+kpackage-16:apps apps16 16:photo:16 16:R0lGODlhEAAQAIIAAPwCBAQCBPz+xERCBMTCBISCBDQyNAAAACH5BAEAAAAALAAAAAAQABAAAANPCLoR+7AJ0SALYkxd79za12FgOTlAQBDhRxUFqrKEG8PyOqwEfMeKwGDI8zVGul0vFsAFdaxB43ecKZfUKm1lZD6ERZgBZWn0OpYvGeJPAAAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+kpager-16:apps apps16 16:photo:16 16:R0lGODlhEAAQAIMAAAQCBPwCBFxaXISChASChATCxKSipMTCxDQyNERCBPz+/MTC/AAAAAAAAAAAAAAAACH5BAEAAAEALAAAAAAQABAAAARWEMhJZ7hADFI4+RpwBYBxFJ1HmMiYJUgiJPI8Bwmp7HyvyBOfMCHR+QwzhAAhMvZKSFgRIOwtJczqboFoBasGGVNUKVNGaEyTlEYL1sX2pYXOyO8XfwQAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+kpaint-16:apps apps16 16:photo:16 16:R0lGODlhEAAQAIQAAPz+BAQCBMTCxPz+/PwCBPzCxPz+xPyqXASCBMQCxAQC/AQChPyCBATCBMT+/ATCxASChIQCBKSipISChAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAV1ICCOYxCI5kmigTCYBKGW7WAH8QyYrn3LNFesYDgEjCVXIRYzGgWqgA2BICQUx9pMSkUssgsbFOWighW+7c24KDAKDccjCjVCHAEGo/GYl+wPLwwRfF8oT2mDAwuGWVJiARERAxITJkhaJhMSlJY7NDQpAH4hACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+kpixmap2bitmap-16:apps apps16 16:photo:16 16:R0lGODlhEAAQAIQAAPwC/AQCBMRaBPyqXPzerPyCBPzCxPwCBPz+xMTCBPz+BISCBMT+xATCBAT+BASCBMTC/AQCxAQC/AQChAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAVkICCOpBicZQoEwjAE6hgQQwvH81AU8OnfuR3QYDgcgAKhjGj8+UgzQkHHw+2mQlQpgEAkFInEYnGDhr/h8VPGYDQcjcZj/iiv4u84vQ6FQCISERETgxN2AX6AgoQThlBOkCR+IQAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+kpm-16:apps apps16 16:photo:16 16:R0lGODlhEAAQAIMAAPwCBAQCBMTCxKSipPz+/ISChAQChMTCBATCBPyqXAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAARbEIBAa5BYUsHF+FQ2EUTHfUOoFQVpeuAVGAbrnmg603U7FD8UxXDgGQgoYMyAIBoSyI9Sx2seoj/lRlDFTmUBDs0L0gg2CGwFs93oWJdMOwCPiybhguout2f8EQAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+kppp-16:apps apps16 16:photo:16 16:R0lGODlhEAAQAIYAAAT+BGSOhERadDxKbDRKZExWXKzG/KzO9KS+tER+lBQyNERaVOTu5PT6/OTy9Lza5LTatISylHSilCQ6LNzq9MTa/LzevKzKzIS6dBwuZISi9MzizLTW3Iyy1IymjHyGbCwuLDRGXHya3HSe9Jy+/MTe5Pz+nPzmhOTSbGyGXGx+XCwyLHyinISe/NzifFRKTFRqXCQmJExSVFyafFyC9MTCvAQCBMTCxExKTDw+PMTGxLy+vNTS1Ly6vMzOzNza3MzKzHRybERCPDQyNPzCxPQODHR6dAwODAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAengACCggECAwQBg4qDBQIGBwgJCouDCwwNDg8QERITlIUUDhUWFxgBC4mKGRoGFQcbHB0eHyCLISIjJCUmJygpKiuLEywjLRYuLy8pMDGLATIzNMk1Nck2lCDJN9TcLziKOTg63DvcPD0ygjk+P9zcQDVBQekAQkMgPjzcPfLy1wAgiBQBAYIHkH5BbPwTBGKIQBBBjAQBsXCRDYJGZFSkJOhIM45+AgEAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+kpresenter-16:apps apps16 16:photo:16 16:R0lGODlhEAAQAIMAAPwC/AQCBMQCxPwCBAT+/MTCBASChATCxPz+BPz+/ASCBAT+BKSipAQC/AQChARCBCH5BAEAAAAALAAAAAAQABAAAARhEMhJq70YhM2D5UIYDARHBUWxEcRgHKgncWyLuPEc1MOAJLfBRsNSEBYbH8kw3BEUyABjZHzJdsiGI6AYLBQG5qykDSy+jwdLpimj1aVhe7tIr00a6Q4uP02dfRVygRZ+EQAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+kruler-16:apps apps16 16:photo:16 16:R0lGODlhEAAQAIMAAPwCBAQCBFRGDPTijPzmnKSGDOzWdPTahOTGXOzOZOTKXNzCTNy6RNS2NMyqHNSuJCH5BAEAAAAALAAAAAAQABAAAARkEMhJKwg4643FEIQHimHRfaiYmoFxvMLhwi5r3IaA37rBIomgABhEDBM/hHLJVCBYCwFjYVxQBdYFi8GQertSLqshaJgFZbK5wXI4BO63W/Bwt+HzON7BKvj/gIAcgxoWhhN+EQAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+kscd-16:apps apps16 16:photo:16 16:R0lGODlhEAAQAIMAAASC/AQCBKSipFxaXARCRPyqXPwCBAT+BMTCxMT+/AT+/PzCxASCBAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAARbEIRJa5Ui672nsNYgegFhFoRhCuJAEgcsE+wYfHIc0y3JbT2QsOJCGG+/zyShMCICregEsUgEnNCe6/rsPkPTY2LxZLEOh4DEqbBmRQyGen0kjgB4ySSPp+D9EQAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+kscreensaver-16:apps apps16 16:photo:16 16:R0lGODlhEAAQAIUAAPwCBFxaXAQCBOzu7Ozq7OTi5Pz+7Pz+xISChHx+fMTCBARWlARepOTm5ISCBNze3ARalARanKSmpARSlHzC9ARGfLy+vKSipARKhAROhARKfJyenNTW1AROjARSjMTCxJyanNTS1JSWlMzOzNza3MzKzJSSlMTGxLy6vLSytKyqrAT+BIyOjPz+/AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAalQEBgOBQYj0fhYEAoCAyHqPRgDAyIggPikOAeFFVCYMHImqnfaiPAKH8VcLij+ghAGJFFlnuUCAJ1ExR5AnACFRUWF39/CxETXQoYGRoaFht/HAEdE2AeGRgVFBUfIH8hmx4doBihGokifyMPAiQcISEjJR+7HyZ/JScfFigpKSoSFxsiKywCAEjR0QDU1AIJFi0tFgnP1dYJ4QgJ4+Xe1tLTAH5BACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+ksirc-16:apps apps16 16:photo:16 16:R0lGODlhEAAQAIQAAAT+BMROTPz+/KQGBFxaXAQCBDQyNGSGzDRivAw6lAQmbCRGlAw2jHSS1BxGpAwiVGyO1CRWvBRKtJSq3AxCrEx2xAxGtAw+pAw6nDRmxAQmZAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAVYICCOQBCQKCoMaRsMbCvPNE3cRA0QRWEciIQigQLyfAtGqtFwPI6GFgQReex60WJEYr36UpOtQgQlUQAVieUyLoskY8Bhi3liEZJ6MaOmWCgJGjYGhCl+IQAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+ksnapshot-16:apps apps16 16:photo:16 16:R0lGODlhEAAQAIMAAASC/AQCBATCBFxaXISChAT+BASCBAT+/PwCBPzCxAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAARLEMhJKw3YViw6HkRgBUVnCkG4GUV5otthsO6A3KJEHm6R3AOYTtAy2QqzHCDwMpiSk8DsxIFGpc6T9YJ9GpSb7laDSYI1yzNa448AACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+kspreadcalc-16:apps apps16 16:photo:16 16:R0lGODlhEAAQAIMAAPz+BAQCBATCxARCRASChAT+BMTCxFxaXEQCBPzCxPwCBAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAARPEIBAq5U4iM17wJMwjORIfJkYFCs7nKA2rJQLp0Su66ikGcAg8OYTGA6BA/KAIIYsFudPGJQal8uAFVqxUg2JxBYbUGh7k5J6BppwKyB/BAAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+kspread-16:apps apps16 16:photo:16 16:R0lGODlhEAAQAIIAAPwCBAQCBAT+/Pz+/KSipPz+BAAAAAAAACH5BAEAAAAALAAAAAAQABAAAANFCBDc7iqIKUW98WkWpx1DAIphR41ouWya+YVpoBAaCKtMoRfsyue8WGC3YxBii5+RtiEWmASFdDVs6GRTKfCa7UK6AH8CACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+ksysctrl-16:apps apps16 16:photo:16 16:R0lGODlhEAAQAIMAAPwCBISChHx+fPz+/AQCBAQC/AT+/AQCxAQChAT+BLy+vAR+BAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAARYEIAgqK1YzsG754QUDERpmkEpkkXrtoK6EcVgHIibhnNx564Yb0TDvQq7FQ34EiqPOhnREqhWSUPsyZSQAbbg7GcMEgwUiYVivTa1R+y4XEGoWO/4AMAfAQAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+ksysguard-16:apps apps16 16:photo:16 16:R0lGODlhEAAQAIYAAPwCBExKTERCRERGRAQCBFxeXKSinIyOjJSWlKyurKyqrKSqxPTy9LSmxNzS1Nzm7JyitJyipMzOzLS2tOz6/OzW1Ozy9Oy6vNyCjNRydMR+lNza3LSurFReZMTG3Pz29OSmrMx6hDw6PKS2zMTCvOyytOSWnMzi5MTa3NTS1LzCvNTe5Pzm7PTK1PS6vOSapMyKjNTy9KzCzMzS1GxqbISKxOzq7Ozm5Oza3MyytLzS1Nz29OTy9LTS5GyGtOTe3MzKzOT29OTm5KS2vKSurNzy9LTW5OTi5Mza7NTm5KS61KyytOT2/HyChHSChHx6fNTy/LzKzMTCxLS+vMze5KSmpLzS3Ky61JSSlLTGzLTa5FRSVJyanKSipJSWnJyWlAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAfagACCggECAQEDBIOLAAEFBgcHCAgJAYqLAQoICwwNDg8QERKXjQYTFBUWFxgZGhsJHJcdHB4fHxUgrCEiIyQCjRwWthUlJiG7IycoKQQBKisfLC0uLzACJzExMjMBNBI1Njc4FTkBOjs8PT4/3UBBQjc8FkNEQTtFRUZHhyQySEkHOAyxgOCcEhkSLC1ZwSRGEx1OnBx4EgNKFCmKAkyh0uNADBpDOpyQ0YNEAEJVIFjBZg/bFRIRSAXAwiFLDyNaesiYEJMRgS1cupDg4OXLFlI+DwkQgBSAn0AAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+ksysv-16:apps apps16 16:photo:16 16:R0lGODlhEAAQAIIAAPwCBAQCBPz+/MTCxISChIQCBAT+BAAAACH5BAEAAAAALAAAAAAQABAAAANWCLoQzlA5IVyIK1S9L7PDsFHBIJXDFFaViYYEUQpy6orEqq12Aw+FmkjQQxEKwQCBSCz5BrGYkuc06nKU4s8gW4q0UAN3+q3CZJfJRhJ6fDwZOGbhTwAAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+ktalkd-16:apps apps16 16:photo:16 16:R0lGODlhEAAQAIMAAPwCBAQCBKSipMTCxARCRFxaXASChDQyNATCxISChAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAARYEMgZqqXU6gCuDIJQDQTBBQX3hUFpmN2hFaxhIPCJDrRo46dPglf7BTvDXsB2OwaSCd8tZ0kWgZ3Uk+hDvHRV5bfyybACPNmkY2EVZKpM5UBPre8fD94fAQAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+kthememgr-16:apps apps16 16:photo:16 16:R0lGODlhEAAQAIMAAPwCBASCBATCBAQCBDQyNPz+/MTCBPz+xISCBAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAReEMhJaw1V6Bs0HgIWYFMnhSERkiU6ekM1FO9IGMcxIFK3jgGDzRADhAypQipI7A0OId1IaGhKntHDjWogTLCB3JbpvULD2ir5i0SPDYjy9ZgWDuQUwqBLLFq+ehZ+EQAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+ktimemon-16:apps apps16 16:photo:16 16:R0lGODlhEAAQAIIAAPz+BHSG5PxSVDRW9PwuLPQKDFze1AQi7CH5BAEAAAAALAAAAAAQABAAAANDCLrc/lCFGeKi1YktAH5c92mcR4HloA4P4RLAyjovLLdvvD5FX+gqgGFoUPh+N2IRcAQcngch0ehzQqVDas/6xBb9CQAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+ktip-16:apps apps16 16:photo:16 16:R0lGODlhEAAQAIQAAPwCBGxubFxeXAQCBOzu7OTi5NTS1PT29Pz6/Ozq7Nza3PTy9Pz+/Nze3MzKzMzOzOTm5MTCxLS2tKSipNTW1Ly+vKyqrMTGxJyenISChAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAVwICCOQRkIY0oORFEYqCoGw4EcSaHEarAgDESu4RioBIMfA1doPIwpZGJBhTQMEWh04GoqDBLtCKkYNL5hGUAwoZQfFYs46lBQLnK1SICJUCR5egMZGBgZcyoDGAwTh3oiAxMMhogpioyOjwADnIh+IQAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+kuser-16:apps apps16 16:photo:16 16:R0lGODlhEAAQAIMAAPwCBAQCBMTCxISChAT+BMRaBPyqXARCBPz+/FxaXAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAARLEIRJa5Ui673nsGAgeKE1Bl9AUEXbiqTlFlZaGUZoszm4BzhDAVf5BYbAXI+TAR6CS2ZGSZSEiIIqYIsSIEaJ7GRrlY7J1lKA7I8AACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+kview-16:apps apps16 16:photo:16 16:R0lGODlhEAAQAIQAAPz+BAQCBPz+/PzCxFxaXPwCBPyCBPzerPz+xASCBMTC/PyqXATCxMT+/ATCBASChIQCBAQChISChMTCxKSipARCRAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAV0ICCOYxCQaBkIwpmKJsu6qDkIREDMZFwUAYNwRVuxgLfDAUGEsRIJo2LRapUE0ABDsa1aAcZoo+stsnIMwcDQcDQUV9MjF4Q4GJFiQJJuGSYOFHkwezJ+ExUUEicmYDITARATAoomLiuQJhKTlTRgepYBfiEAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+kwin-16:apps apps16 16:photo:16 16:R0lGODlhEAAQAIMAAAQCBPwCBFxaXISChASChATCxKSipMTCxDQyNERCBPz+/MTC/AAAAAAAAAAAAAAAACH5BAEAAAEALAAAAAAQABAAAARWEMhJZ7hADFI4+RpwBYBxFJ1HmMiYJUgiJPI8Bwmp7HyvyBOfMCHR+QwzhAAhMvZKSFgRIOwtJczqboFoBasGGVNUKVNGaEyTlEYL1sX2pYXOyO8XfwQAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+kword-16:apps apps16 16:photo:16 16:R0lGODlhEAAQAIMAAPz+BAQCBPz+/FxaXISChPwCBEQCBIQCBMQCBMTC/ASChARCRAQC/AQChMTCxAAAACH5BAEAAAAALAAAAAAQABAAAARiEMgpQ6B4WnGzDkLIeVs4DAIBWFcpnKJVzCUcz8ZxVOKN/AWNKRQo5HQYELHwQxQSHR7HqDuwMIRisxBQLBbRFdUaYCwYjUZHywIxGI53K0jolRkJdLkhtKwaeWpJYW0AfhEAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+kwrite-16:apps apps16 16:photo:16 16:R0lGODlhEAAQAIUAAPwCBKSinJyOfPz27Pzy7AwKDExOTJyWlERCRKSelPz69LyyrKymnPz+/MS2fDQyJAQCBOTazLSiXOzivMS2jKSSVOzmxPz25NzSpPTu5KyebOzixNTGjOTWpMSydMSybCwqFGReVKyaXNzSnGxeNJSCVMS2nPz23MSuZIR+bJyShLyqnOTOtGxiXIR6XOTSvIx6RMSubIyCdKSalMS6pOTWxMzKvKSabJyKTOzezHxuPGRmZKyurMTCvPTq3AAAACH5BAEAAAAALAAAAAAQABAAAAajQIBwCAgIiEhiYEA4FgwHRDKhIBAWz4OhgGQ0FAPHA7qFEBONb0Qy0ULeQ2+aUrFcMI+3GYBOZzQbHB0eHyAhIQByDREiEwMjFRIkJQImAgJ+jScjHigkKSorLC0AKg2NFSMoki4qCy+IQgITKDAxkjIzNDWkQxQoJaskMgk2Eb1DNzgoOCoHDDY5yEIwJToAOzw9ET7TQiREAhkZ3kmy5QB+QQAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+laptop_battery-16:apps apps16 16:photo:16 16:R0lGODlhEAAQAIMAAPwCBAQCBPz+/KSipAT+BISChFxaXPz+BMRaBPyCBMTCBDQyNAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAARtEIBAq5w1TBGEGIM2ESTlVUNhaAFJUAcXgAXCZkFyJEoiIArWYQjj+Xi2yfBA0SU6CuAts4MCk4EdcxbznFhOCsjrWUxRhbRBBk48Z6kCZ2GeuN9xucF8FqcEBnt1OW4saSp7IoRPEjgiGBV+EQAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+laptop_pcmcia-16:apps apps16 16:photo:16 16:R0lGODlhEAAQAIMAAPwC/AQCBMRaBMTCxPyqXKSipFxaXASChISChMTCBPz+BPz+/PwCBAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAARfEMhJaw3Y2iDGyJoUEIVRfIHGEcaBHCc4jcWbGG2cAuuhKIZE4mX68EgI3M/wORgQGAHr4HICD4NCKoBIJqsv7w6DKDgNi0VuN+O+GIxFl00hlxjakIhbo4cwfnoWfhEAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+locale-16:apps apps16 16:photo:16 16:R0lGODlhEAAQAIUAAASC/AQCBPz+/MTCxISChMxKTKSipFxaXERGRGxqbCQiJDQ2NJQaHMwmJDQyNFRSVOR6fGwSFNxSVKQqLFQODJwaHOyGhOySlNRCRMSuBPz65PzupPyCBJyOLMxyJOTKRLSiNIR6JExCFGxaHAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAaPQEBgGAAYhcWjUMAUEAMDQtIIZRauBaZhKhwIsFjBgFu9HgKHrHNI9QYQCQQarWB313D5Ik68BxgIDQwOCgcJD2wBWwENEBANEQwMEBITFEIOQhWNkhENFhcYl0l/GRobHB0MGBAeo1QdHxsaICEfpyAiQlQhICMiHyMgs8FKASMjRiK/yLrGStDRXNFGfkEAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+looknfeel-16:apps apps16 16:photo:16 16:R0lGODlhEAAQAIQAAASC/ERGRExKTLy+vKSmpAQCBPTy9Pz+/IwKFLQWNPT29GwOFExOTIyKPHx2NPz2pIQSHLwWNMzGXFxaLLSytERCHCQmJNze3GxubLS2tHR2dAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAWNICCKgVCWYwoEwUAMhXEQhhocRuHCMpIgiJVBptC9DojDIrFYwRS4wgGJZAIYuwL00Ej6FjOGEXZwPByQCNjAyrnKj4NkAqYUBIIoXC5pVGYUFgIXU2Z8fgdGFhgZiRqHf1EDFgCJGAcafX9aUSIFlxoFBX8vMYmemKJSY6Ijn6oHF26tKbAEGCaUKX4hACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+lyx-16:apps apps16 16:photo:16 16:R0lGODlhEAAQAIMAAPwCBAQCBAQChARCRKSipASChFxaXISChPyCBATCxPyqXMT+/Pz+xPzerPz+/AAAACH5BAEAAAAALAAAAAAQABAAAARZEMg5Q6C4BnGzHsRgeVZRGIbYaekxuAFijUGRBOqMKPxlJQsLQxjoVWyWBsMxNEp+iRuj2VvVCklHLCZjiRrawGFmNQUajQ129RwYyCMSau2pcNh1AB7jjwAAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+mathematica-16:apps apps16 16:photo:16 16:R0lGODlhEAAQAIMAAPwCBAQCBISChPwC/FxaXIQCBAQCxAQC/KSipAQChPyqXPyCBEQCBARCBASCBDQyNCH5BAEAAAAALAAAAAAQABAAAARlEMhJ6wxChiFFCBUhENtQGIcBUghWDsHxWck7wMpKfXz/ZYBAYeCpKRQLWwkjMCpQJQ3TE8gdUgxPUMDlflINhzfocJB6BNEDqLnKpgRLTJZjBuIUAf1TExR0EyRASWmAFocAfhEAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+mouse-16:apps apps16 16:photo:16 16:R0lGODlhEAAQAIMAAAQCBPwCBDQyNKSipPz+/MTCxISChPzCxATCBISC/MTC/AAAAAAAAAAAAAAAAAAAACH5BAEAAAEALAAAAAAQABAAAARSEIRJqw0Sg32rAANBFNwlhIQhGkNGAaSaouW0iYUBEIdYgzsUIqHAuWAoQlGEE9gMJKaU8IPupqLWy3qVkioAFqkLc9nCg3G5oxFr2ecavOOPAAAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+mozilla-16:apps apps16 16:photo:16 16:R0lGODlhEAAQAIUAAASC/JxqBHRKBGw6BHwuBHQuBKwmBKQmBIRWBGRGBMQeBKwaBHxSBFQ6BDwaBEwqBEQuBGQuBFQOBGwSBGxGBHQ+BOQiBPQmBLQaBKQaBCQGBIwWBLQeBDwKBHQSBGQ+BIRaBHweBIQWBNQiBKQeBJw6BPxGBNQuBLwiBPwmBKweBIQiBJQmBHwyBIxeBAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAZzQIBwSCwahYHA8SgYLI2EwpMoMBwQU2FCsRAYGQ3HwwGJSCYPCNnRoAgrlgsmo8hkLJpNpEjhbBYdHhYZEh9HICEiGRMjJAxPJSYmJxkoSocjKSorExYNSwMXLAwgDhYVSwUtRAMORwGfRR8uRpdGWEJ+QQAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+multimedia-16:apps apps16 16:photo:16 16:R0lGODlhEAAQAIQAAPwCBAQCBIR+hKSipPz+/MTCxMRaBMTGxOTe5MzGzNyytPyqrPyurLz+tKzqrPTy9LSytNTS1Pz6/Nze3AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAWAICCKQWmOKFAKQ9uWacAOJcEWQjDKrxHYJZxONRAQaL+c76DjyY4D4A+RC9B8xkPiQKCySsjAQZAojHMva9pk8iGrCsWC0Wg4HCvT4wApyO0FEAcRJhKGhzUEioolDw8TgYQBEYITCIQqE4IRCnQOEXyYJAFxCwt1dzAxbCcjfiEAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+nedit-16:apps apps16 16:photo:16 16:R0lGODlhEAAQAIIAAAQChPwCBAQCBPz+/MTCxKSipFxaXAAAACH5BAEAAAEALAAAAAAQABAAAANDCBoK8TAC8Vy8QUyGr9BaFwmDZonZp66sIhBwLBMFlRl4rhv1IxiDoHDYuw1yw2Dxl0wugTqnjdkUPmezJWv7QXX8CQAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+netscape-16:apps apps16 16:photo:16 16:R0lGODlhEAAQAIYAAEyStPwCBNTKrHRqPAxSfLR6VNzWvAQCBEyOrFxGPMSWdKx6XPz69Ozm1PTy7NTOtOTOxKRqRGxCJPz6/MzGnMS6jDwmHEyGpPz+/Hx2bGxiPOTexFxWNLSmhMy6jLyGXNSqjHxSLLyuhMSyhLSqhDQeDJyWdJyOVNTKtPTu5KSONMS+rLyqdMy+lFxSNOTezKySPEw+FEQ6JKSOPDw6LNSylHxSNKyWPLSeXExGLDQuFIRiRCRCVEwyJAwODLyyjIx+TNzaxMy+jBwaHNzGvMS2hMS2jKSWXGw+JFw6LKR2XCQ6TDw2HAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAEALAAAAAAQABAAAAfVgAABg4QCA4SIBAQFiAYHiIQICQoLAQwNDg0PgxARg4oSChMOBg0UAgYVBRaDFxcIGA4ZGhscHB0eHISKoxkfARsHICEiI7oBrg0kGiUfpCEBJiIngygbKQ0bG5kjKisbFSwtAi4HLx0cBwYiMDEyJh4zMjSKKBQuNTY3Mb8vODk6kLky0GEHjxUyeiigMMPHJ0UCKvw4sQFIECEqhgQUSCSChRFFWhg5MkMjkk9JlJRY4uIEixk5fOhAsuOkqyFLXF1oQYOJTiQIAigaqohCD6JD/QQCACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+noatun-16:apps apps16 16:photo:16 16:R0lGODlhEAAQAIMAAPwCBCQ2PARehAwODASCtASi5ASq7JTK5PT29MzS1JyipISGjAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAARlEMgJgrg3zDHkCEQoEhrnVYXBDUVRdmagHjT7AnExHPtg3LldzYXr4FA6juHnMXZkqaiGMpEtOdOmETpAIEy473fV9Xphq7P6DEgMFIpFWm1sJ+4JBec8SFAnd3pveH+AeHcSfhEAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+package_applications-16:apps apps16 16:photo:16 16:R0lGODlhEAAQAIUAAFxaXGRmZFRWVARehAxehFxeXOTm5MTGxKze7JzO3ITC1HSyzGSmvFSWtESKpCx6nBxulNze3MTCxAQCBByezByWxBSOtBSGrAx2nAxqlARijARafARWdARSdARKbARGZARCXOzu7Pz+/Pz+9Ozu5Nza3Pz+7NzexPz+5NzivGxqbGxubNze1NS+vPTCvMzKzLz6vLzevPwCBNzevAwOBAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAADIALAAAAAAQABAAAAamQEBAMCAMikfjQMAsGA6IhGLBaDgeEEJEMhFIJBRKxXLBYDKajeTQBQAGG05n7vl8QABBNyTq+/8iIyRdJSJrgCMjJiYnhCIHEn+JiygpXQaGB32JKgErKiuNAoV+iQIGLBItLhOOgYkrmAYvLikwl6+Lo5gTtjFdLMHCKy8vEyITxV2tzBMFMTCWIgYlEzLX2NcwMy4vstngAS4tLyUGNODprdl+QQAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+package_development-16:apps apps16 16:photo:16 16:R0lGODlhEAAQAIUAAASC/GxKFAQCBNSyhFQ2FOTGnJRuNOzWtPz23FRWVERGRJSGNMyyZHRydOzu7PTy9Ly6vOzq7Nza3JyanMTCxHQCBLxWVKQaHOTm5NyOjMxqbJQSFHwGBDw+POTi5LQiJJwWFPz+/Pz6/PT29NyWlMReXNyenLQqLIwSFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAZ9QIBwSCQGBMWkMDAgKIuBgsH5FBIO0+oSka0mFAsGtdpwLMbPxONBgCDJEQkEMnkn1RLKRGF3+CtCDRJ7AoUSEgAWFw+AChB8hYUYGRobHIwAHZGbHh8gayEhIqGiIw9+GBgSJBoliiGUrhcOJq0WJyAbKBUhnrocDr4ofkEAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+package_editors-16:apps apps16 16:photo:16 16:R0lGODlhEAAQAIUAAPwCBAQCBLS2tHx6fOTm5Ozq7OTi5Hx+fPTy9Ozu7PT29Ly+vMTCxPz6/IRuPHROLPz+/LyOdLSCTNSmnOS6vPzmzISGhExOTJSCZPTSxPTKtPS6jPSujNyKZGxqbDQyNDw+PHRaTKRqVLRqRLxqTMxmPOR6NKyurDQqLExCRFxKLKRSFNza3KyqrKSmpDQ6PGwyBNze3NTS1LSytAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAaWQIBwSCwahwFA8kgMOAVLpjMgGBCixamgECAYsELtoUAuXJtPRCCRMBu44ecBoVC0F2aC8qkIKBAICQx5X3INh3UMbQMOD05/AQ0QDQoMERITFBUVThZ1Cg0XFxgZGhobHB1KHp4NCR8gISIjJCQlJmGsCAULAicoKSoqDytIrAkGBCwMLS4vKTBNrAUJCzEBMjMuM35BACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+package_favourite-16:apps apps16 16:photo:16 16:R0lGODlhEAAQAIMAAASC/AQCBPz+xISCBMTCBPyCBMQCBIQCBPwCBPzCxAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAARYEEgZwrQzVyFq6Bj1gQOxgcBYDSzhnl7Azm7tpWT7VhdHmoFXzweqmYZE4I5C5AQKhkMAYbCMfM9EIWBAIKzNLNRbTRHCBUT6ewn6TOlyJuX2sOftS8YfAQAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+package_games-16:apps apps16 16:photo:16 16:R0lGODlhEAAQAIMAAASC/AQCBPz+xISCBMTCBPwCBMTCxMQCBPz+/KSipISChAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAARaEEgZwrQzVyFq6Bj1gQMxgsBYDSxhqunKtu5bpSQdFDfFkS9DgHD5cTwBIdFnFLiSw2IzGGX+AocDNHQ6GhCJQCJsGRqThm/CoMBUCNc1W9HWmD2Jdsh+CfkjACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+package-16:apps apps16 16:photo:16 16:R0lGODlhEAAQAIIAAPwCBAQCBPz+xISCBMTCBAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAANECKoR6ys2IVqokF08yMTA1gwkYX5WQK5ma4VceTYPxXnBWdtY6+0834/Bowgzm6APWRQcH4TiMhPK2WYRiZWW7XK7/gQAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+package_graphics-16:apps apps16 16:photo:16 16:R0lGODlhEAAQAIYAAASC/MQmJPz+/LwuLLw2NLQiJNTKVNTOZOyydNRaXMxGRJQmJFQuXFRypFySdHS+VLTOfNzWhJQeHFwCBGyGtHyqlIzKdPTapAQCBGRCbKTSjOzqxLzG3MzmxJyanBQSFJSSlBwaHCQmJGxqbFxaXNzmxPzmzOSenExKTLSytAwKDAQGBMTS5LzerOSaTFRWVHR2dJzOhLTKdNyiNDw6PFxeXDw+PLSmvKS2zIyynLzSjNTKXNSGNIx2lIx6tISavNzSbLwmJHRWfNzWfIRurIyexOSmPJweHAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAejgACCg4SFAYWIgwECAQMEA4mCBYwGBwgICQoFhowLDA0ODxARCAQSkp0TgwwUFRYHFxeLARITGIUZFBobEgUBC7aRHB0eBcC3iRgfGAIgISKRGCMeIhgkJSYniBkoKSgqKywtES6bgy8iMCgYyhwxMjOb7Bg0NTYr7Dc4OTo7PPIrQoRgJ6iHjx8xgMwIEgmAkIMxhsw4lYgBkSI5LEQwcsRPIAAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+package_multimedia-16:apps apps16 16:photo:16 16:R0lGODlhEAAQAIYAAPwCBFxaXHx+fHR2dGxubISChNTS1MzKzLS2tLSmpNSytAQCBOzu7Ozm1Nza3MTGxNS+vOy6vPy2tOTStOzq7Pz6/Nze3MTCxOzOvNTqvLT2tDw+BOTm5MzOzPy+tLz+tLz2tOTi5LSynLz6tPz+/NTW1KSipMy6THx6fMTKxKyOLNTGVPTmbLTOtBQOBBQSBKySLHReFLzKvLzavAQGBCQiDNzKVOTSXLSWLNzGVLyiPNTCTOTaZLymPMSqROzebOzeZMSuPBwaDMyyRFRKHAwKBOzibMSmPMy6RLSaNLyaNDwyFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAfKgACCgwECAwQBg4qCBQUGBwgJCgsLiwAFDA0OBg8QERITlYMFFBUMFgYXEBIYGRoboxwMFRQdCAoeGR8glAABBgshFA8BCxsiI5QklY4lJQYbJiQbypQnACgpB5ALy92UKissAAQXDyktlBUuLzALMeG+MjPKNDU2LDc47yqC1Qs5dODYwYJHj3f/Yrxb4QPHiR9Aqr0I4kNFDCExdgxRQaSItyA8jJw4YvFFjBdCGtCotECFjhssVgRR8W8QkgVJlOBb8k3UID+BAAAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+package_network-16:apps apps16 16:photo:16 16:R0lGODlhEAAQAIYAAPwCBPz+/CRKfERCRAQCBFxONKx6LDw+PDR2rAwyXMzOzOzq7AwKDHSSlKy2ZDxutAxCpExOTBRavBQ+fBQ2XOTi5OzWhFRSVBw2VGRmZDw6POzKdCQ6ZBRKrCQmHAwODIyirGSGpIR+bCRixBRKtCQ6VDQ2JBw2XIS27DRKNISuhESK5DR+5BQ+jCQqPCxSfFSa5Gyu7GyerOzetBw+XBwuTBwmNFSa7Eye7DSW9JyabLyqRBQ+dBRerDR+zDx+3Bxq3LyaLJySRHxqPGxeNBRSnCRmrHRyRERONDw+NCQuLCwqHAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAeygACCg4SFhoeEAQGJigIChQEDBIIFBgEHBAgCCYMBCgQBCwyhDA0ODxCcAAqRihGXiooSExSCsYoVDBYEFwEEEBiCrBmgGgUbigMcHRgeth8gAR8hIgQECyMkJSaCAicoICkqASssvi0YLoIvMDExMg4zrjQTNTaDCTcxODk6OwQYJmCYNIhHDx8/gAQRMoRIDRcEBwkoYqTIkSMFkNiISCjBCR40UiQxwdGQEg9LSvoJBAAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+package_settings-16:apps apps16 16:photo:16 16:R0lGODlhEAAQAIMAAPwCBAQCBISChGRmZMTCxKSipLS2tHx6fPz+/OTm5FxaXOzu7DQyNMzOzAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAReEMhAq7wYBDECKVSGBcbRfcEYauSZXgFCrEEXgDCSeIEyzKSXZoBYVCoJVIqBGByKu0Cy8QHxmgNngWCkGgqsGWFseu6oMApoXHAWhWnKrv0UqeYDe0YO10/6fhJ+EQAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+package_system-16:apps apps16 16:photo:16 16:R0lGODlhEAAQAIMAAPwCBGxqFAQCBPz+/PTqtOTOfMSyPNze3Ozi5KyeLMTCxMzGzKSipOTe5MTGxAAAACH5BAEAAAAALAAAAAAQABAAAARfEMhJQah4ihFunsFAEIVXCVJACIJhoBK6CerawsA8HAhbuAnYZrBDKBYMWpCy4S2QSRazyBIwrrjcoNFQzK4KR1bQcHhZjGM2BgWLMYJ2enForHPJtNj+kfHvcB8AfhEAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+package_toys-16:apps apps16 16:photo:16 16:R0lGODlhEAAQAIUAAPwCBJxyLJRqJGxKFIReHKR6NJx2NMSmbEwyFKyGTMSibFw6FMSqdCQWDIxeHNS6hAQCBDQiDNS+jOzexCwiDCQiHLyeXFxGHLSWXJwuJGweFHQiFMx2bLRGNGQeFNTClOzSrLxKPLQ+LLxOPGxOHIxmLEwWDOzatNS+lKyKTIRiJJx2PIRmPJRuNKyGRIReJJxuLKyKRMSqbKSCPEw6HNzKnAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAauQIAQEBAMhITCcTg0CA6IhGJwICyYwgWjEQg4HIgHBCuMBCCSM6FBHiIOk4cg0hYiKAFFxUJBtC8YGQgBFhAaBVdMAw8bHB0eHh0cGh9LAAMgAxAhHiKPIxAkH1cXEiVjJiQnKCljECoWCAgEFGUrKBYsYwARKnQIRxG0Ky0QtAAIvwcuAwQpLxDCGDAIMTKyMSczs7sQATQz2mMIMyAXu0IQNDUu6AgQ6EPwu35BACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+package_utilities-16:apps apps16 16:photo:16 16:R0lGODlhEAAQAIUAAPwCBExKTERCRAQCBOzu7Nze3MzKzLy+vCxqZBQ2NJyanKyqrGRiZDRydKza3FRWVPT29LSytDw6PMTm5EySjCxaXGRaJFSanCRSVGxqbPTmvMSqVJTW1GSurHS6vOzq7KSipISChFRKHJSGNPz23GxKFBQ6PKyurCwqLMyufJx2RAQGBJSWlEwyDIRiLNy+lLSKVDwmDJRuNOTOrLyabGRCFDx2dKSCVOzWtHzCxOTGnNSyhAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAahQIBwCAgIBAOiUiggFAyHASKxDAwUC8Zg0HAglA9IZPGQABoTSqJCFTIOEIsFgHBcEhhHUpKJFCwaGxYYHB0VEx4IEh8gIQwiIyQbJRMcHokmEicfDygAkCkqJQgIGG0rLElCLS4vMCWqQwMCQg0UMTIzNDVLQjaIGDE3ODQlS785CEkxKjowvEOHybG4O6JDCdNKuDUxRAmxRDHeveUAfkEAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+package_wordprocessing-16:apps apps16 16:photo:16 16:R0lGODlhEAAQAIUAAPwCBHx6fPT29FxaXPTy9AQCBHRydPT25Pz6/ERGRIR6PJyORHR2LDQyNLy+vNTW1Ozq7Ozu7LSiVKSiTIyKJJyenMTCxMTGxNTGlNTSjLyyRExGTExKTBwaHOzivMy+XBQWFExOTNzOhIyKjFxeXDQuNMSyjNzOnBQSFNTGjDQuLCQiJAwODCwqLGRmZHR2dAwKDCwmJAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAafQIAwQCwWhcihYMkUDJLIAKG5fEILhoOAgGAmCgXFgsEoNByOxwMCiTTAEsmEAq5ULJbLxQEuYCQZGn0JGwkcCR1gCUIeHyCJfX2JIUIHIiANCQMGIwYkCSUgi0KPHSYdJyAnKCkdHQ1IrhgdGCC1s7UqSCsdKLi0wL2xHY/FxMcssS0JIS4vIy8uIQktHUkgKygsMNwwKCAxUOLjAH5BACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+panel-16:apps apps16 16:photo:16 16:R0lGODlhEAAQAIIAAPwCBAQCBPz+/FxaXMTCxDQyNAAAAAAAACH5BAEAAAAALAAAAAAQABAAAANECLrcEDDKGYQV4+qbie9eGIJEVxTe+QmjUFgnXLLr615oF8x2v0I8DWpF2GV6slkLKSMdYT4nS0WgSkXYAWUbcXgX/gQAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+panel_settings-16:apps apps16 16:photo:16 16:R0lGODlhEAAQAIIAAPwCBAQCBMTCxPz+/PzerISChPyqXAAAACH5BAEAAAAALAAAAAAQABAAAANKCLobwRAG4SJw7w5BswoEkQXbRn0h5ggF14FhbIhb68SiOgnbLRsPEovjwwVLRIdhCfwMiR/VZ1A7WS4tntWyynquq+01+h1//AkAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+password-16:apps apps16 16:photo:16 16:R0lGODlhEAAQAIIAAPwCBAQCBPz+/MTCBPz+BISCBPz+xAAAACH5BAEAAAAALAAAAAAQABAAAANECLrcGi6CIAKUKwxSb/ZasXWPMFwBQRQiZwlqAVnEGbRwKz/ndMep3QNUqKV6kpQh6HFoCIaBMDmQTpOsJsaC6XoZ/gQAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+penguin-16:apps apps16 16:photo:16 16:R0lGODlhEAAQAIIAAPwCBAQCBPz+/ISChPz+BMTCBISCBAAAACH5BAEAAAAALAAAAAAQABAAAANHCLrRsTC6F6UId1TYiNtMQRQNqARDOlAgJrzlhr7vqlUufbHMoMO8k+8XY4yGtc9pREIORKRTYVoYDgxUVmBqmGCLJzDYnwAAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+pixie-16:apps apps16 16:photo:16 16:R0lGODlhEAAQAIMAAPwCBFxaXPz+/DQyNAQCBKSipPz+xPzerPyqXPyCBERCBISCBMTCBAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAARdEMg5Q6C4BjEGyZIlCEFHfJQonEERnB8sE6RxIMkAnGtPBzacjqBQLBiMxS+Y2xmRx+WtSTgmkwQLcwhNKqRCz3VRBOeGvh5wqpPMzO3JQFBguWAYxeiNwnRAEn4RACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+plan-16:apps apps16 16:photo:16 16:R0lGODlhEAAQAIMAAPwCBAQCBMTCxPz+/Pz+xMTCBISChASCBMRaBAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAARaEIRJKwU4iD23FwEmDeAwBGYaZiehWutEFK6JqtlM7KZhHhOJbuizIUKBHVGFOOaUPgPlGEsSDNjbKWBgcT0oX5CV2qakIg24OTGA0sxjeSWpUC2ivESf90cAACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+proxy-16:apps apps16 16:photo:16 16:R0lGODlhEAAQAIIAAPwCBAQCBPz+/KSipFxaXAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAANGCAHcziuIuFy44045WxhZpkxCB4GEKA1lpIAiVG7XB1bjPMHxqds3y++S6nGOL1ikpYlkbBSZM/oYfXBVaS8LuXCr2IY/AQAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+pybliographic-16:apps apps16 16:photo:16 16:R0lGODlhEAAQAIUAAPwCBAQCBMTG5OTi7Nze/NTS5LSuxOTm/MTCxGxaFIRmFJR6JLy+zOzq9IRqJJR2HLSaNKSirNTOxKySLIR6VLS2vOzu/LSqhNzOXHxqNMzK1KSGJHxmFKSabLy2pIx2JJyCJIRyNNS+VAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAZhQIBwSCwaj8WAEplULpkAZ0AQgEaVA4K0alQWDAdEQrHgNguMRsHxgJiJgcEg0pA4Jk84ZVCoWC4TGG9CAQkZGnUIG3lDAQocCh0eFB+MjRsgIAsLIYNwASKCnk2WVkR+QQAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+realplayer-16:apps apps16 16:photo:16 16:R0lGODlhEAAQAIYAAAwWVBwC7BwC9BQC3BQOvBQCtBQCrBQCvBQO1AwKPAwOVBwC/AwGnAwCXAQGNAQCJAQCHAQGLAQGTAwKjBwG7AQCNAQKRAQGDAQCBAQGJAQGPAQGFAQKVAQGBGRiZBweHFxaXDw+PExKRBQSFERGPFxeXCQqJLy+vAwCjJSanFRSVLzCxJSSjIyGhGxubNTW1KyurAQGHAwODKyqrHR2dBwO7AwSZCwqRDQyLCwuLAQKFAwSjAQCLAQCFAQCDAwSbAwGbBQKvBQCzBQC1AQSNBQKtAwOdBQKnBQCxAQabCwOLDQSNAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAAAAAAALAAAAAAQABAAAAe/gAABAgGFAwQFBgcIgwEJCguRDA0ODxCXERITFBUWCwMNDxcYpKUYGRobFQEcFx0dGLCxrx6kFQcYHyAhIiIhIyQlJiekESgYHikqKywtLi0vIDCkMQQbLiQyMzQgLDQzJSCkMjU2NzIYOCYyOSYmH+gYOjUBOzw9PT6mGD4P/AORahj4IaECBFI9gAQhJSSSw0g2fGggsEAIw4eRhhBhEGBBgCKkjAgZSRLFESFIRibZx5KlkpYtlbyEuW+Jn0AAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+remote-16:apps apps16 16:photo:16 16:R0lGODlhEAAQAIMAAPwCBDQyNISChJyGPGReLAQCBMy+hERCHKSipAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAARFEEgZqp0Y1KxD9twEapg1kqhwBgKFvqIIjgMRdy4wFIaNbiiCYXDIAUcH328EQsxiIBXAqWn9MtTSTZLNybizEweY8UcAACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+samba-16:apps apps16 16:photo:16 16:R0lGODlhEAAQAIUAAAQCBDQyNFRWVASC/Pz+/PTW1OyytNTW9LSy7PTGxOSenNx2dMTG9Jye5OSKjNxiZMw6PIyK5GRi3AwODMwmJLQCBCQmzPS+DPTejPTaJLR+DPT21OzqtNT21MTCxPTyxOTmnNzedMTyxPz6/ISChOTijNzaZMzOPIzijMzKJLS2BPT29Nza3PTmxKSipOzu7LyGJPTKRNSeDFxaXERCBAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAMALAAAAAAQABAAAAacQIBwCAgIBsjkAEAoGJgHxFC5TCgWAEajyFUCHA8IICJhTggAr4NSGVsAF8wlnSQWBYLMRUNHMjccTB0AGh5dfh8gIQAiAAJCIyRCfiUmJwEokARok0slKSqPApukAZNDRpqbkZMjSROOI5srLAGwS34tGgEuBCMvAjCBA64ALRgxuyzAMnItQmgaMRcypjMByNR9QjQ0adzeaX5BACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+scsi-16:apps apps16 16:photo:16 16:R0lGODlhEAAQAIIAAPwCBAQCBPz+/MTCxKSipISChAAAAAAAACH5BAEAAAAALAAAAAAQABAAAANCCLoQwZAFIV6UYgxi79Qa52WDE3bKV6YOpFpO3L5pJcckLBB8/wQEDezWAQpZqIWxFNAUkqkg6HmJOqGuArUqwfoTACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+style-16:apps apps16 16:photo:16 16:R0lGODlhEAAQAIQAAPwCBAQCBOzqBLS2BPz+HPz+rPz+BPz+lPz+zPz+9Pz+1Pz+nPz+hNyuhPz+pIQCBMTCBIQyBPz+/MTCxFwmfCQiJIxOrHw6nJRWtJxmvJxuvJxyvAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAVvICACwWieYiCUwVCiKVEEhjHA6YEcxooHBURCsXihaAYGglEzngKBhsMmMDhH0YcBAu16SY2IKiApm81RMXTCblPelDCrXJlI6hSL5SJOSewVdRMUGHtGZICChHsmZHeAgxkaG41/bWxnjV6bUH4hACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+terminal-16:apps apps16 16:photo:16 16:R0lGODlhEAAQAIIAAPwCBAQCBMTCxISChPz+/MT+/AAAAAAAACH5BAEAAAAALAAAAAAQABAAAAM/CBDcHkoFQasVUIrBe8fRNDwMAWpjUThmtmxk0IYwOaPx/V6XG3hAjmsRa0Qkg6NSOVo6F0nG88g4TUNDpT8BACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+wabi-16:apps apps16 16:photo:16 16:R0lGODlhEAAQAIMAAPwCBAQCBPz+/ISChPz+xAQC/AQCxPz+BFxaXAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAARUEMhJgw20XsHxvIEwcKQHBESaDkShmqhKsMb7tW1RHPwOH4ZdYcBDGH+8A2JgLH2MzZHAJgmRBAgZAabNqg7cJMGb5BKSZF4Yfb5Uzmp3piqfS/wRACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+window_list-16:apps apps16 16:photo:16 16:R0lGODlhEAAQAIQAAPwCBCRiXCRaVPz+/CRmZFRWVISGhMTCxESSjPT29DR6dDyOhDyCfPTy9CxqZOzu7Ozq7ERubOTm5ARehAxefPz6/ByaxBSOvBSGrAxynAxqlBR6nBRylAxmhARWdFxaXCH5BAEAAAAALAAAAAAQABAAAAWHICCKQTCeqCgMhJCihXEYSPuKRWIoC6PYsEZikHA4FA4CEJdoJh4QgXRwiOAeQudDIpEZIpPwhCImhyGGAmBSOVgumExG055w1ZPZhpPpUDwzExBqAAUDhxUVTQ0QEgWOOIcDiU1QjoSFFYiKDZYFmAWJlE9bkCM5iouWpiIfBa6frrKYAH4hACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+winprops-16:apps apps16 16:photo:16 16:R0lGODlhEAAQAIMAAAQCBPz+/ASChATCxISChFxaXKSipPz+xMTCxMTCBPwCBAAAAAAAAAAAAAAAAAAAACH5BAEAAAoALAAAAAAQABAAAARXEMhJqwxAjM23wBMhjGQJEFKhriwrGUcsE3JsvPWBFAAiT7BaIYAA/HAxWk9CO9wAwd0SkJA9g8NiomnDoYqnHDAGroqRyVy3F2i7326LnKKo2+94hT8CACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+wp-16:apps apps16 16:photo:16 16:R0lGODlhEAAQAIQAAPwCBAQCBAQCxAQChKSipPz+xPz+/ARCRFxaXEQCBMTCxPyqXDQyNPzerISChISCBASCBERCBMTC/AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAV1ICCOZDkGgSgMg0AUZWAExyHc7YCQclLYtxtieAoUEApFUIBgnRYMhUHRCDYcDoUIRUhOlYLkYwcIDLvSpAsBiYx0CPQUgXNv4V0ZWEByDBgRcTMGDislTX+CMgISJk1+AQ4zWiYiCCiRDmRbmJ2eKZWhAH4hACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+xapp-16:apps apps16 16:photo:16 16:R0lGODlhEAAQAIEAAPwCBISChAQCBAAAACH5BAEAAAAALAAAAAAQABAAAAIyhI9pIa0nYAtPUGlTRszJ10UA8xiNRZZmJKoA25boqW7npeHvlKRHyIn9aKYaz6XwFwAAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+xcalc-16:apps apps16 16:photo:16 16:R0lGODlhEAAQAIEAAPwCBISChPz+/AQCBCH5BAEAAAAALAAAAAAQABAAAAI4hI9pwe0Ogpi00hHF2LzzzFlTsIHD45SSx6oCeW4wjK2tl83y7t64pIsJaxrfh2bEAJIlhRPhLwAAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+xclipboard-16:apps apps16 16:photo:16 16:R0lGODlhEAAQAIIAAPwCBAQCBPz+/MTCxPz+xPzerMRaBISChCH5BAEAAAAALAAAAAAQABAAAANICLoQwdBJIaRjgYbBR66Lo1nfowTER61aWGRd1y5GyrLm+QrxMJ81FQ4T2MV+jUPwBgpVdrdcQ6AUIj8Ha/N06Hq/UpLY5E8AACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+xclock-16:apps apps16 16:photo:16 16:R0lGODlhEAAQAIIAALy+vAQCBPwCBMQCBIQCBISChPz+/MTCxCH5BAAAAAAALAAAAAAQABAAAANbCLHcrSLKOZcYmDSCsR1aUABAsXDDJwJGa5SBFwgaWxbCG3CWaBwG3C8Y67FawpYiNQscg65fsVkYuoAmJs1pBR522lQB6ILJLqHRwQQOZzYdZnw+dzruDIA/AQAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+xconsole-16:apps apps16 16:photo:16 16:R0lGODlhEAAQAIIAAPwCBAQCBPz+/ISChMTCxAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAM7CLrcGjBKCYK4OGcohv/gxw2aRgyjYJXCmVpr5loke82dfaO03vI5Ha5mwxGOyOSRF2qKKpMoxEFl+BMAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+xedit-16:apps apps16 16:photo:16 16:R0lGODlhEAAQAIMAAASC/AQCBMRaBPyCBMQCBMTCxPz+BPz+/KSipFxaXPzerPyqXIQCBARCRDQyNISChCH5BAEAAAAALAAAAAAQABAAAARnEMg5gw00yyDGIJi2FUHhDWEWeEXrgaphHEOBJF8KBLKyLINEIAHbyA6/hbDACDSMBt9PIBA6n4HfIElFXTeKg2LbtTSeu7BiPegIvuA1mwrfOB5r4PusCjimZmgUF4F8IhJnhiJ+EQAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+xemacs-16:apps apps16 16:photo:16 16:R0lGODlhEAAQAIIAAPwCBAQCBDQyNKSipPz+/FxaXISChMTCxCH5BAEAAAAALAAAAAAQABAAAANJCBASoXCFoVi8VdL6HHQeB4YjSAxnYQygSLzoSTjbEs9vMF86cbyH34NX+AELQ4zO+Nopm6cBC1PBEQwG6gd3SGo7Xa1STIb4EwAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+xeyes-16:apps apps16 16:photo:16 16:R0lGODlhEAAQAIEAAPwCBAQCBPz+/ISChCH5BAEAAAAALAAAAAAQABAAAAI4hI+py50Bw4lyBiEggFjvi2VcqIFhdnaDSabZKrbjS3W1OHz2CkJD/vHlKD/Er2g4Ah3MptPgLwAAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+xfig-16:apps apps16 16:photo:16 16:R0lGODlhEAAQAIIAAPwCBAQCBPz+BMTCBISCBARCBATCBASCBCH5BAEAAAAALAAAAAAQABAAAANQCLocwbAJ8SIMYgwHHO9Opk2V5xGEplZK0alaui0eDLOB8QTykOKGQ6mnKQWFPILDN8sdng7l69c5CjuKAHNnZb2KnUOhcG3MsmMv7aK2+BMAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+xfmail-16:apps apps16 16:photo:16 16:R0lGODlhEAAQAIIAAPwCBAQCBPyqXMRaBPz+/AAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAANACLHcAVCJSWcYLwaxSPAXBj2bswyiIlUWSr5muGhbdaZjTd1ZzvKMFaOFcbCIpiOnGGs2FM5gLkLrTalQLMCfAAAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+xload-16:apps apps16 16:photo:16 16:R0lGODlhEAAQAIAAAPwCBAQCBCH5BAEAAAAALAAAAAAQABAAAAImhI+py+3hEoxnUmBpyBjNzWXfJnkGKJ4dBlbjS7Jni9Zsjec66hcAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+xmag-16:apps apps16 16:photo:16 16:R0lGODlhEAAQAIIAAPwCBAQCBKSipMTCxPz+/IQCBPyCBMRaBCH5BAEAAAAALAAAAAAQABAAAANICKrR+6+JIRxkc4RBww1TQBBNB21io2rRRKpltaDvis4hvJmzBmuslo+zkZ0yu0rBcwJ1AgXD8gJQMaJTaqRwyGqvzO9M4U8AACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+xosview-16:apps apps16 16:photo:16 16:R0lGODlhEAAQAIMAAPwC/AQCBPz+/MTCxAQChPyCBAT+BPz+BAT+/PwCBAQC/AAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAARFEIRJa5Ui663HFEQojqEXCAVhrCxLmGB4kCJM03aIHEdC5rfaJ6UotlavT3AEIxaNLuAyd2wlT0thYMDter0BiWU8AfgjACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+xpaint-16:apps apps16 16:photo:16 16:R0lGODlhEAAQAIQAAPwCBAQCBPzerMQCBPz+/AQCxPz+BMTCBASCBPyCBPzC/PyqXMQCxIQChKSipMRaBDQyNAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAVtICCOYmCaZGoKLBuMbykMA1EURFwCgWAQwKBAxxMQDocgAjEkrYAsoS6QGEYJCgWhWVq4tgJGY+iAVbcBB5jLq/aMbzJsYXK0Arky7JFY+BcJDyckDgEPh4d1aUSFJ2l6ARApDpSUKkQpmSJ+IQAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+xv-16:apps apps16 16:photo:16 16:R0lGODlhEAAQAIIAAASC/AQCBPyqXPz+xPyCBPwCBAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAM8CLrc/jC+oIK9Lgg7RuietWhCSWkkVZUbEBBnWxXFSVP1eLt7kPM3X86nEhJrtx/P0tuNilCVZEqtNvwJACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+3floppy_mount-16:devices devices16 16:photo:16 16:R0lGODlhEAAQAIQAAPwCBAQCBMTCxARmZPz+/FSWlLSytKSipERCRIyOjISChOTm5HRydNza3GRiZFRSVASCBARCBDTSJIT+bAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAVrICCOQBCQKBkIw5mqLFG47zoQ+FwbN57TosDhgPD5dMEEIqE04kwlBWKBUEiNVYFpyqAyGEUCgqEtERiNNMLhQKzLQYJg7n7Y4aMAwbCUPvAQeWNgfzQQETAIhSMQEogwgBITQEGGEREmfiEAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+3floppy_unmount-16:devices devices16 16:photo:16 16:R0lGODlhEAAQAIMAAPwCBAQCBMTCxARmZPz+/FSWlLSytKSipERCRIyOjISChOTm5HRydNza3GRiZFRSVCH5BAEAAAAALAAAAAAQABAAAARcEMgJQqCYBjFu1hxReN82EOhYGieaklJwHIjrqnGCJLqNWhUFYoFQCG1FgWXIIDIYNQKCoawQGI0swuFAbKsxgmDsfZjBkwDBsNM90Jot9A3DbBD0Dwiur9QnfhEAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+5floppy_mount-16:devices devices16 16:photo:16 16:R0lGODlhEAAQAIMAAPwCBAQCBFxaXPz+/DQyNISChASCBARCBMT+xAT+BAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAARMEMgJQqCYBiFu1sIwdJ+0hSKZnZw4ehPLoW88c0Q7X7JABLlbp+eT/UyzgpADqwgKxKYpeIMZQNWJ4YBhWRHcrgpgQCSkJu3hYPFHAAAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+5floppy_unmount-16:devices devices16 16:photo:16 16:R0lGODlhEAAQAIIAAPwCBAQCBFxaXPz+/DQyNISChAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAM+CLoQwZAFIV6UYox61cwaF32UtlkLSYFnulJEuT6qQATxW9W2enurgo6CaggKvKIn91K6mh0gMepydqwAfwIAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+cdaudio_mount-16:devices devices16 16:photo:16 16:R0lGODlhEAAQAIUAAPwCBFxaXISChNTS1MzKzMTGxMy+vNSytAQCBOzq7OTi5Nza3Oy6vPy2tOTStPz6/Ozu7Nze3MTKxOS2tOzOvNTqvLT2tDw+BPTy9MzOzLS2tPy+tLz+tLz2tLSynLzqvLzavLTOtNTW1KSipPz+/LzKvMTCxDQyNASCBARCBDTSJIT+bAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAa0QIBQGBAYA8Ok0DggFAwHBEIJECQUi8GT0XBMh9YHJDKQTBqUiuUCVmAeiYzmsKlwOt/AAKFIFAIIFx4WHyAhUwIDIgsZFyMkFxchJSYmiBkSBBoIJJwIGgOhiCYFJSEnFyQjFwNZewABISAfFiYnCAEmCREIrwAIFhwVGwcaBAkPGApsQsAVFA0GBQMRbxBTKM0ODQwTEq192ClDgROkBHvYKuNJUu5CKCorX1RDKCkpUn5BACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+cdaudio_unmount-16:devices devices16 16:photo:16 16:R0lGODlhEAAQAIUAAPwCBFxaXISChNTS1MzKzMTGxMy+vNSytAQCBOzq7OTi5Nza3Oy6vPy2tOTStPz6/Ozu7Nze3MTKxOS2tNzmvLT2tDw+BPTy9MzOzLS2tPy+tLz+tLz2tLSynLzqvLzavLTOtNTW1KSipPz+/MTCxLy6vDQyNOTm5AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAapQIBQGBAYA8Ok0DggFAwHBEIJECQUi8GT0XBMh9YHJDKQTLqUigWsuDwSmMxBQ9lwvoEBQpEoBBAWHRseHyBTAgMhCxgWIiMWFiASJCSHEgQSGQgjmwglGKCHBQUSICYWIyIWAwshIVMBIB8eFSQmCAEFCREIekIIFRsUGgcZEgkPFydrvxUUDg0GBSEREGJfv9AMEySsJxDYQ4DcEhh64UpS6lTs7QB+QQAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+cdrom_mount-16:devices devices16 16:photo:16 16:R0lGODlhEAAQAIUAAPwCBFxaXISChNTS1MzKzMTGxMy+vNSytAQCBOzq7OTi5Nza3Oy6vPy2tOTStPz6/Ozu7Nze3MTKxOS2tOzOvNTqvLT2tDw+BPTy9MzOzLS2tPy+tLz+tLz2tLSynLzqvLzavLTOtNTW1KSipPz+/LzKvMTCxDQyNASCBARCBDTSJIT+bAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAa0QIBQGBAYA8Ok0DggFAwHBEIJECQUi8GT0XBMh9YHJDKQTBqUiuUCVmAeiYzmsKlwOt/AAKFIFAIIFx4WHyAhUwIDIgsZFyMkFxchJSYmiBkSBBoIJJwIGgOhiCYFJSEnFyQjFwNZewABISAfFiYnCAEmCREIrwAIFhwVGwcaBAkPGApsQsAVFA0GBQMRbxBTKM0ODQwTEq192ClDgROkBHvYKuNJUu5CKCorX1RDKCkpUn5BACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+cdrom_unmount-16:devices devices16 16:photo:16 16:R0lGODlhEAAQAIUAAPwCBFxaXISChNTS1MzKzMTGxMy+vNSytAQCBOzq7OTi5Nza3Oy6vPy2tOTStPz6/Ozu7Nze3MTKxOS2tNzmvLT2tDw+BPTy9MzOzLS2tPy+tLz+tLz2tLSynLzqvLzavLTOtNTW1KSipPz+/MTCxLy6vDQyNOTm5AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAapQIBQGBAYA8Ok0DggFAwHBEIJECQUi8GT0XBMh9YHJDKQTLqUigWsuDwSmMxBQ9lwvoEBQpEoBBAWHRseHyBTAgMhCxgWIiMWFiASJCSHEgQSGQgjmwglGKCHBQUSICYWIyIWAwshIVMBIB8eFSQmCAEFCREIekIIFRsUGgcZEgkPFydrvxUUDg0GBSEREGJfv9AMEySsJxDYQ4DcEhh64UpS6lTs7QB+QQAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+cdwriter_mount-16:devices devices16 16:photo:16 16:R0lGODlhEAAQAIQAAPwCBFxaXISChERCBMTCxKSipAQCBMTCBPzCxPz+xPzerMT+xDQyNMTC/ASCBPyqXPz+BARCBAT+BAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAWIICCKgWAGYyoKA+EWhGGogOAaB6Lr8ygUCYWCkEMoEovBSHZUFI8LGYloODJkhWijMbMdiAwBQEbYxmpExFlkgN3QrliXAcvNAuVt4coYKtQ9BlwLCQQFMAlVSmwEUX8IB1UJiQAObEE6BA9VEDMOEUsDDzoHkZ4LoCkyqyIOCxI9NCOfETJ+IQAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+cdwriter_unmount-16:devices devices16 16:photo:16 16:R0lGODlhEAAQAIMAAPwCBFxaXISChERCBMTCxKSipAQCBMTCBPzCxPz+xPzerMT+xDQyNMTC/PyqXPz+BCH5BAEAAAAALAAAAAAQABAAAAR3EEgZhA0zSzGIL4RhaIDgGQeiquMkFImiECmiJMswibdS3wsRhWa4MUSFYKMxMh1oDAFARFiGSjTEVWIAnbCeUJMBSo0C1WXhyJgptC0Dc5EgFECJoo5LCL4RB0UJeRkGMSoEDkUPLYUDDioHgY0kIpYkmJkAfhEAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+dvd_mount-16:devices devices16 16:photo:16 16:R0lGODlhEAAQAIUAAPwCBFxaXISChNTS1MzKzMTGxMy+vNSytAQCBOzq7OTi5Nza3Oy6vPy2tOTStPz6/Ozu7Nze3MTKxOS2tOzOvNTqvLT2tDw+BPTy9MzOzLS2tPy+tLz+tLz2tLSynLzqvLzavLTOtNTW1KSipPz+/LzKvMTCxDQyNASCBARCBDTSJIT+bAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAa0QIBQGBAYA8Ok0DggFAwHBEIJECQUi8GT0XBMh9YHJDKQTBqUiuUCVmAeiYzmsKlwOt/AAKFIFAIIFx4WHyAhUwIDIgsZFyMkFxchJSYmiBkSBBoIJJwIGgOhiCYFJSEnFyQjFwNZewABISAfFiYnCAEmCREIrwAIFhwVGwcaBAkPGApsQsAVFA0GBQMRbxBTKM0ODQwTEq192ClDgROkBHvYKuNJUu5CKCorX1RDKCkpUn5BACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+dvd_unmount-16:devices devices16 16:photo:16 16:R0lGODlhEAAQAIUAAPwCBFxaXISChNTS1MzKzMTGxMy+vNSytAQCBOzq7OTi5Nza3Oy6vPy2tOTStPz6/Ozu7Nze3MTKxOS2tNzmvLT2tDw+BPTy9MzOzLS2tPy+tLz+tLz2tLSynLzqvLzavLTOtNTW1KSipPz+/MTCxLy6vDQyNOTm5AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAapQIBQGBAYA8Ok0DggFAwHBEIJECQUi8GT0XBMh9YHJDKQTLqUigWsuDwSmMxBQ9lwvoEBQpEoBBAWHRseHyBTAgMhCxgWIiMWFiASJCSHEgQSGQgjmwglGKCHBQUSICYWIyIWAwshIVMBIB8eFSQmCAEFCREIekIIFRsUGgcZEgkPFydrvxUUDg0GBSEREGJfv9AMEySsJxDYQ4DcEhh64UpS6lTs7QB+QQAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+hdd_mount-16:devices devices16 16:photo:16 16:R0lGODlhEAAQAIUAAPwCBAQCBDQyNIRuVKyCXMSKROzSrOzKpOTGnLSafLySZKxuLMSOVPTWvPzixLSehNyibOzOrGxaVJx+XOzGnFw2FJRuPKx+TPTSrHRWPKyKZPTOpHxOJKyKXFw+HKSipISChMTCxFxaXIRiPNSWXExOTOS2hLR+PLRyLPTWtMyOTASCBARCBPz+/DTSJIyKjIT+bAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAaTQIBwCAgYA8SkMCAYDARI5ZJQMBwQiWgyoFgwrA3HQ7scQAqFAcEQOUi0zAkFUSFYLghMBloUCDQNGxwdHhwHekcfICEhICIfIxkLJBABJUYCICABIhAOBiYnKJaXmH4CGSkYCCqkSAEfTKenrkOwsrQll0IrS7G5uwArLLaxLbXCLsTFLyDBKy4wZEVHvCwsRn5BACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+hdd_unmount-16:devices devices16 16:photo:16 16:R0lGODlhEAAQAIUAAPwCBAQCBDQyNIRuVKyCXMSKRPTWtOzKpOTGnLSafLySZKxuLMSOVOzOrPzm1LSehNyibGxaVJx+XOzGnFw2FJRuPKx+TPTSrHRWPKyKZPTWvHxOJKyKXFw+HPTOpKSipISChMTCxFxaXIRiPHxaNLRyLNSWXExOTPzixOS2hLR+PMyOTPz+/IyKjAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAaIQIBwCAgYA8SkMCAYDARI5ZJQMBwQiWgyoFgwGgiD46FdDiCFwoDQAEe0TMkEQSFULIcLBloUCDIaDRscHRsNHhhHHyAhISAiHyMkJSYQASdGAiAgASIQKA0pKguXmJl+AiQGFwgrpUgBH0yoqK9DsbO1J5hbsrq8SrgstlJFHy0gwMVFR1J+QQAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+memory-16:devices devices16 16:photo:16 16:R0lGODlhEAAQAIEAAPwCBISChAQCBMTCxCH5BAEAAAAALAAAAAAQABAAAAI6hA+Bu+HCmgiiRuNoHZBRXQlc84TmcHzm2WVryE1YvMaZIdbVd2zw7lj4bDKGbxK8hHgX3K2JUDD8BQAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+mo_mount-16:devices devices16 16:photo:16 16:R0lGODlhEAAQAIMAAPwCBAQCBKSipDQyNPz+/MTC/PzC/ISChASCBARCBMT+xAT+BAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAARTEMgJQqCYBjFu1hxBeN82iCIJDgWaYhtntC4ZCzItdhWOD7mdwHLrAAczoKViIh6Vto5lcDjglppp9UpCTALULRaASGS5E4TCnB2rFyqJO5Gw+CMAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+mo_unmount-16:devices devices16 16:photo:16 16:R0lGODlhEAAQAIIAAPwCBAQCBKSipDQyNPz+/MTC/PzC/ISChCH5BAEAAAAALAAAAAAQABAAAANHCLoQwZAFMV6UlBB759Aahw0FGEITZZQmlwoqq1UNDA/xLDhvhQ8rnKPh4f2EropjcDjAhpJl8ylaBJhTaCelvRC7XqLXnwAAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+nfs_mount-16:devices devices16 16:photo:16 16:R0lGODlhEAAQAIQAAPwCBExKTGRmZPz+/ExOTMTCxAQCBDw6PCwqLIyCRHxyNCQiJOzmxMSybFxSHHRmLIx+NFROHERCRFxaXASCBARCBDTSJIT+bAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAVWICCOZGmeaEoGKiCwwUAI5zsUBnAUQ0CLNhxLFEDwDAnFzTAsBRYJRsORSwUeDUiEWYtJIhFj7+eKCUdPHmxyNj0nFABXRam0RBSLvZW/VFN1FQYGfiEAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+nfs_unmount-16:devices devices16 16:photo:16 16:R0lGODlhEAAQAIQAAPwCBExKTGRmZPz+/ExOTMTCxAQCBDw6PCwqLIyCRHxyNCQiJOzmxMSybFxSHHRmLIx+NFROHERCRFxaXAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAVLICCOZGmeaEoGKiCwwUAI5zsUBnAUQ0CLNhxLFEDwDAnFzTAsBRYJRsORSwUeDUiEWYtJIhFj7+eKCUdPHmxyNj0nOa6q2qrbW/4QACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+printer1-16:devices devices16 16:photo:16 16:R0lGODlhEAAQAIUAAPwCBAQCBFRWVPz+/Ly+vISChMTCxFxaXPT29DQyNJSSlHR2dERCRFRSVERGRBSmnExOTExKTAT+/NTW1MzOzMzKzMTGxLy6vLS2tGRiZFxeXOTm5IyKjISGhLSytKyqrGRmZNTS1Nze3Nza3Hx6fKSmpKSipAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAaUQIBwSCwaA0ikkRgQDJCE5LFgOAicUKUwUCAgBuDE9RkFcL3ggbgQUCwYyIIA8VU32ASDwoEcIAoHCQkHbA8EBBARSX0DXQEPEgQCDYpJExQVAWCHBwcNDUkKChQWBBcYARkanaABExsbHB0FGB4fIKoHAWYhpCIBIyQLJSAJGbtbULUTISa4yEVJJSbO0EtmUkR+QQAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+printer2-16:devices devices16 16:photo:16 16:R0lGODlhEAAQAIMAAPwCBKSipAQCBPz+xPz+/MTCBISCBISChMTCxFxaXAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAARaEMggqrwYVDGGzRLXEZ0HhgMpFIXxZZzRBsHxXquAUHqCCBgB6YcoFhNAXMWISCQOv6Dt6DMmQwQntHjwXTVL6mH83Ry31qBO8CSQSmVg2GM74aAVij2UTPojACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+scanner-16:devices devices16 16:photo:16 16:R0lGODlhEAAQAIMAAPwCBAQCBPz+/MT+/ASChARCRATCxMTCxFxaXKSipDQyNAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAARTEMgJgqWBVivEldkUdKSXhVjZfenommglDERh3Tc4E4ZRHAGgkEPr9X6H5AHBERSMRyWzkug8jQXFEhWoOo8dRYxqLXSmGjIJnVaz29Q3fAP3RwAAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+tablet-16:devices devices16 16:photo:16 16:R0lGODlhEAAQAIIAAPwCBAQCBMTC/Pz+/MTCxFxaXKSipAAAACH5BAEAAAAALAAAAAAQABAAAANECLrc/iosCUEQlEYdRp6dZ4lgKBBEp1kmmpLRMBQu6qWLEdYBn+81F0wnC8oCK+LAQDgGDIaG0vOMPnRIaEUBtW6//gQAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+zip_mount-16:devices devices16 16:photo:16 16:R0lGODlhEAAQAIMAAPz+BAQCBFxaXMTCxPz+/ASChPwCBKSipASCBARCBMT+xAT+BAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAARTEMgJQqCYBiFs1lwwdF8VEsR4YVuXoirYFcWbkmY31wPqma2ZwReqBEODQutwEY04oeWqMniGOEzW4HAVZAEImVSCSLDGYIX5/EMoFtNSOWHxRwAAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+zip_unmount-16:devices devices16 16:photo:16 16:R0lGODlhEAAQAIIAAPz+BAQCBFxaXMTCxPz+/ASChPwCBKSipCH5BAEAAAAALAAAAAAQABAAAANICLoQwZAFIVyUNIx6WybE9kBTFYIiVhXFGXJetbYDaHnlathZk2eDQunw0GwomeGoMThmKETS4PAURCMlZccHXXYct60Y4E8AACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+blockdevice-16:filesystems filesystems16 16:photo:16 16:R0lGODlhEAAQAIMAAPwCBAQCBMT+xAT+BASCBMT+/ATCBAT+/ARCRPz+xARCBPz+BATCxISCBDQyNMTCBCH5BAEAAAAALAAAAAAQABAAAARhEMgZwrwYBCFsvhs3eF8wDMJAVBVmnupazKRmGDFxzMVBBjcDQXfYHRA/QmKpKBYRSMoysVgwGEeoJ1ClLhpXhlbiqJobjcA1Sn48qug06+JwP+I1UMCNzmcqaR8lghN+EQAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+chardevice-16:filesystems filesystems16 16:photo:16 16:R0lGODlhEAAQAIIAAASC/AQCBMTCxISChPz+/MQCBPwCBAAAACH5BAEAAAAALAAAAAAQABAAAANCCBDcHkoFQasVUIrBe8fRNDwMAWojMTZmtmzByp6v7LQhTOLadbkxj3AUWZAcxcUgyYwQm8wYoOCCLgoGK5Nq9ScAACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+desktop-16:filesystems filesystems16 16:photo:16 16:R0lGODlhEAAQAIUAAPwCBExKTDQyNHRydFRWVKyqpGxubExOTERCRLy6vFxaXBweHFRKPFxeXAQCBIyKjCwqLMS+tKyurDw+PNze3ERGPPTu5Pz+/Pz6/Nza3MzOzKSipISChOzq7NTW1Ly+vHx2ZOzm3Ix2XJx2XIyOjKyqrJSSlPTexPTixKR2VKxyPCQiJPTy9JSWlHRmTOzSrMzKzJyCbKR+XCwuLOTi5CQmJAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAaeQIBwKAwIiEjkgJBsAgoGwcE5RCQUgAWj0WwcHA8FRLhAcIcKhyIiMSwcwglc2ABTDA2Eo9KQoy0PFxgYGRobDxwBDHRgF44YHQ4bHgkfHBUMHQ8gFp2dISIjEQwfBwIkJR0mICcoJycpKgweCisAEAcPGSwtLi8vsQkNtkMrBxswCQ8uMTINY0kzBCQwNB/DVAArBC0NNdlDM9BDfkEAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+file_broken-16:filesystems filesystems16 16:photo:16 16:R0lGODlhEAAQAIMAAPwCBFxaXDQyNAQCBMTCxPz+/KSipPz+xPzerAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAARWEEgQahVijMmD/oRAbBw1FCgaFFrppeo5didsZTSMDoRBSi/dgfUz6Va7HPIQGB6KnpW0EEB4Oshp5ZlTFRBfFs3ZLDihtTAYwZ14nGbzoS3JfO4ffwQAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+file_important-16:filesystems filesystems16 16:photo:16 16:R0lGODlhEAAQAIIAAPwCBExGTKQqLPz+/KQqNAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAM7CLoQwZAFIV6Es15Jqd2ZtzXUMIhXZqJYaZ5aK7zwp6h0zc05i+c6Eg8oCnWOR0eHQGEKnEWHdDoF+BMAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+file_locked-16:filesystems filesystems16 16:photo:16 16:R0lGODlhEAAQAIMAAPwCBFxaXDQyNAQCBMTCxPz+/KSipPz+xISCBERCBAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAARTEEgQahVijMmD/oRAbBw1FCgaFFrppeo5didsZTSMDoRBSi/dgfUz6Sq7XGp1CByKQZUUWjsgrtcENYXNUodWhAahVRa65G9hmGgnnpzMZ/7xRwAAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+folder_blue-16:filesystems filesystems16 16:photo:16 16:R0lGODlhEAAQAIYAAPwCBAQCBExKTBwWHMzKzOzq7ERCRExGTCwqLARqnAQ+ZHR2dKyqrNTOzHx2fCQiJMTi9NTu9HzC3AxmnAQ+XPTm7Dy67DymzITC3IzG5AxypHRydKymrMzOzOzu7BweHByy9AyGtFyy1IzG3NTu/ARupFRSVByazBR6rAyGvFyuzJTK3MTm9BR+tAxWhHS61MTi7Pz+/IymvCxulBRelAx2rHS63Pz6/PTy9PTu9Nza3ISitBRupFSixNTS1CxqnDQyNMzGzOTi5MTCxMTGxGxubGxqbLy2vLSutGRiZLy6vLSytKyurDQuNFxaXKSipDw6PAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAfDgACCAAECg4eIAAMEBQYHCImDBgkKCwwNBQIBBw4Bhw8QERITFJYEFQUFnoIPFhcYoRkaFBscHR4Ggh8gIRciEiMQJBkltCa6JyUoKSkXKhIrLCQYuQAPLS4TEyUhKb0qLzDVAjEFMjMuNBMoNcw21QY3ODkFOjs82RM1PfDzFRU3fOggcM7Fj2pAgggRokOHDx9DhhAZUqQaISBGhjwMEvEIkiIHEgUAkgSJkiNLmFSMJChAEydPGBSBwvJQgAc0/QQCACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+folder_blue_open-16:filesystems filesystems16 16:photo:16 16:R0lGODlhEAAQAIYAAPwCBAQCBExKTBQWFOzi1Ozq7ERCRCwqLPz+/PT29Ozu7OTm5FRSVHRydIR+fISCfMTCvAQ6XARqnJSKfIx6XPz6/MzKxJTa9Mzq9JzO5PTy7OzizJSOhIyCdOTi5Dy65FTC7HS2zMzm7OTSvNTCnIRyVNza3Dw+PASq5BSGrFyqzMyyjMzOzAR+zBRejBxqnBx+rHRmTPTy9IyqvDRylFxaXNze3DRujAQ2VLSyrDQ2NNTW1NTS1AQ6VJyenGxqbMTGxLy6vGRiZKyurKyqrKSmpDw6PDw6NAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAfCgACCAAECg4eIAAMEBQYCB4mHAQgJCgsLDAEGDQGIkw4PBQkJBYwQnRESEREIoRMUE6IVChYGERcYGaoRGhsbHBQdHgu2HyAhGSK6qxsjJCUmJwARKCkpKsjKqislLNIRLS4vLykw2MkRMRAGhDIJMzTiLzDXETUQ0gAGCgU2HjM35N3AkYMdAB0EbCjcwcPCDBguevjIR0jHDwgWLACBECRIBB8GJekQMiRIjhxEIlBMFOBADR9FIhiJ5OnAEQB+AgEAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+folder_cyan-16:filesystems filesystems16 16:photo:16 16:R0lGODlhEAAQAIYAAPwCBAQCBExKTBwWHNTKzOzq7ExGTCwqLERCRBSKjBRSVGxubKymrNTS1Hx2fCQiJMzq7NTy7IzKxHR2dFTW1Ey2rITKzNzy9JTSzBySlHRydKSipDTW1ByelGzCvIzOzByOjFRSVCy2rCSalGS+tJzSzBxudCR6hCSCjITGxMTm5Pz+/JSutDyChBxydCyOlITKxPz6/PTy9Nza3ISqrGSyrOzm7MzKzDQyNMzGzNze3OTi5MTCxNTO1Ly6vLSutGRiZKyurHRudDw6PAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAe2gACCAAECg4eIAAMEBQYGB4mDCAkKCwwNjYUOAYcPEBESlBMMjAUFnIIPFBUWEBcYGQoaG5gGggMcHRUeFh+fGCCVIakiICMduiQWJa4fCKkdJicoCcjJKSrPAAIrBSwtLtMv1jDaCDEyMgUzNC3SKCA12gYFMjY2KzMzN98uLdo4cujYoa9BAx4IeSywJSgAjgU8evTIgdDHj4WJHAL54cPiDyAMIzkMsSGIkCGREAU4gAOAn0AAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+folder_cyan_open-16:filesystems filesystems16 16:photo:16 16:R0lGODlhEAAQAIYAAPwCBAQCBExKTBQWFNze3Ozq7ERCRCwqLPz+/PT29Ozu7OTm5FRSVHRydIR+fIyCdMzGxAxOTBSGhIx6XJSKfMzKzERGRAxOVKTq5Mzy7KTW1Ozi1OzizEzSxGTWzHzCvNTq5OTSvNTCnIRyVNTS1BzKvCSalGy6tAQ6XMyyjMzOzDw+PByqtCR6fCyGjHRmTMS+vJSytDyChCyWlGReVOTi5AxGRKyurDQ2NNza3NTW1AxKTJyenGxqbMTCxMTGxLy6vLS2tLSurKyqrCwuLFxaXKSmpDw6PAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAfEgACCAAECg4eIAAMEBQYCB4mHAQgJCgsLDAEGDQGIkw4PBQkJBZcQnRESEREIDwoPExSipBUWFxgZGhIXFwkbHBQToQQGFx0eHxoguhEXHCEiIyQGABclJiYnycsSKCkjKisAESwtLi7Y2soXLzDUAaMxMuYuM9kXNDDiAAYFBTU15NGTYeMGNQA4ahAgkEMHiQoxZrTYwWMfIRw9fKio8MMHECAReByUhIPGDSBBhAyJYDFRACJFeBi5cCSSpwM4APgJBAAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+folder-16:filesystems filesystems16 16:photo:16 16:R0lGODlhEAAQAIYAAPwCBAQCBExKTBwWHMzKzOzq7ERCRExGTCwqLARqnAQ+ZHR2dKyqrNTOzHx2fCQiJMTi9NTu9HzC3AxmnAQ+XPTm7Dy67DymzITC3IzG5AxypHRydKymrMzOzOzu7BweHByy9AyGtFyy1IzG3NTu/ARupFRSVByazBR6rAyGvFyuzJTK3MTm9BR+tAxWhHS61MTi7Pz+/IymvCxulBRelAx2rHS63Pz6/PTy9PTu9Nza3ISitBRupFSixNTS1CxqnDQyNMzGzOTi5MTCxMTGxGxubGxqbLy2vLSutGRiZLy6vLSytKyurDQuNFxaXKSipDw6PAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAfDgACCAAECg4eIAAMEBQYHCImDBgkKCwwNBQIBBw4Bhw8QERITFJYEFQUFnoIPFhcYoRkaFBscHR4Ggh8gIRciEiMQJBkltCa6JyUoKSkXKhIrLCQYuQAPLS4TEyUhKb0qLzDVAjEFMjMuNBMoNcw21QY3ODkFOjs82RM1PfDzFRU3fOggcM7Fj2pAgggRokOHDx9DhhAZUqQaISBGhjwMEvEIkiIHEgUAkgSJkiNLmFSMJChAEydPGBSBwvJQgAc0/QQCACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+folder_green-16:filesystems filesystems16 16:photo:16 16:R0lGODlhEAAQAIYAAPwCBAQCBExKTBwWHNTK1Ozq7ExGTCwqLERCRByGRBROLGxubKymrNTS1Hx2fCQiJMzm1NTy3ITGnKSipFzShFSydIzKnMzq1Nzy5JzSrByKTBweHDzOdCSaTGy+jJTOrFRSVDSuZCySVMzq3IzKpBxuRCR+TCSCVGy6hPz+/JSunDyCXCSOTCyWVCyeVPz6/PTy9IyqlCSCTGSuhPTu9Ozm7Nza3Dx+VBxyRDQyNMzGzNze3OTi5MTGxMTCxLy6vLSutGRiZLSytDQuNKyqrHRudDw6PAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAe+gACCAAECg4eIAAMEBQYGB4mDCAkKCwwNjYUOAYcPEBESlA4TjAUFnIIPFBUWFxgZGpWXjYIbHB0VHhKtER+UCyC1ISIdxbkSGSMYJAiCByIlJicaxbgoEhDNAAYpBSorJScnLC0uHRLaCC8wMAUNMeAnMgkz2gY0NDUFKTYNBDE3cKzQlkPHDh42djRo0KNhjwUGBgXIscAHgQY6fPz4AQRioolBhGwUIiRIxEiEhoCYQKSIEZSHAhzIAcBPIAAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+folder_green_open-16:filesystems filesystems16 16:photo:16 16:R0lGODlhEAAQAIYAAPwCBAQCBExKTBQWFNze3Ozq7ERCRCwqLPz+/PTy9PT29FRSVHRydIR+fISCfOzu7OTm5OTi5MzGxAxOLByCRJSKfIRyVERGRKTmvNTu3KTWvOzi1OzizIx6XIyCdFTOfGzSjITClAxGJOTSvNTCnNTW1Dw+PAxKJCTCVCyWVGy2jAQ6XMyyjMzKzByuZCR+TCyGVNTm3HRmTLy6vJSypESCXGReVLSurDQ2NNTS1MzOzKSipGRiZMTGxMTCxJyanDQyNLSytKyqrCwuLDw6PAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAfCgACCAAECg4eIAAMEBQYCB4mHAQgJCowLAQYMAYiTDQ4FCgoPEBESnBMUExMIoBUWFaEKBRIXExgZGqoTChscFR0epQYTHyAhGrkUIhMcIyQWJSYAJygpKSrIyissFi0GABMuLzAv19kaMRMyM+ABojQ15ObYEzYz0wAGBQUbBPHkYNQQcQMcABwEEhLIkUMHjRQvTuzIRwgHjx45evTwMWPGiR8GJQGxcWNGkBtCTlBMFGDIgh9CJhCJ1OkADgB+AgEAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+folder_grey-16:filesystems filesystems16 16:photo:16 16:R0lGODlhEAAQAIUAAPwCBAQCBExKTBwWHMzKzOzq7ERCRExGTCwqLHx2fKyqrNTS1PTy9CQiJNza3OTi5GxubJSSlISChLSytFxWXDQuNKSipBweHISGhFxaXIR+hLSutFROVHR2dFRSVGReZKymrLy6vFxeXNTW1Pz+/KSepERGRPz6/PTu9Ozm7DQyNMzGzMTCxMTGxGxqbNTO1Ly2vHRydKyurHRudDw6PAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAawQIAQEBAMj0jAgFAwHBDJoUGASCgWDEMxETg2HA8FFaJgFgpdYSMiUYAnlErCsmgKL5iMJqJwPzYcCB0eahAZH4gSESAhYAoGQggiBh4eFB8iehEWI5AABiQFFpMeHCIiiCWeJicMDAUOEZMcHBkSngYMKCkpJA4OBCWTk0IqKw8PvwsLLCwtLBCeRCouLC8vK80wGzEHSQEqHxMhMBMyLtLfKh4WCjM0UUgBCCoAfkEAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+folder_grey_open-16:filesystems filesystems16 16:photo:16 16:R0lGODlhEAAQAIUAAPwCBAQCBExOTBQWFNze3Ozq7ERGRCwqLPz+/PTy9Ozu7OTi5HRydIR+fISCfPT29Pz6/PTy7MTCxCwuLJSKfIx6XMzKzDQyNOzizJSOhIyCdOTm5Dw+PJSSlKSipLy+vOzi1OTSvNTCnIRyVNTW1GRiZFxaXAQ6XMyyjNTS1GRmZFxeXHRmTFRWVKSmpKyurMzOzGxqbMTGxLS2tJyenKyqrDw6PAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAauQIAQEBAMj0jAgFAwCA7JYwCRUCwWgoCBEUBOG47CAxJhSrqT5wERplQoC8ijYDEcJASJ4HKIYDAZFRoFGxwXHR4eH3lqICEiIyQcAAcMJSaIeHonKCMpkxMqAismKyuIixMsH5MBDw8eJS0mJpcdByYSkwAcEQUEBC4lo7UHL7sXwMAkKTAeogceu0QXMRIwFjISMxITNNNDARcmLx8zNTUH4F64NDUTNlHsk35BACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+folder_home-16:filesystems filesystems16 16:photo:16 16:R0lGODlhEAAQAIUAAPwCBDw6PBQWFCQiJAQCBFxeXMTCxJyanDwyLDQqLFRSVLSytJSSlISChCQmJERGRFRWVGxubKSmpJyenGRmZLy+vOzq7OTi5Ly6vGRiZPTy9Pz6/OTm5ExOTPT29BwaHNza3NS6tKx6XGQqBNy6pIyKjDwGBOzOvJSWlDQyNIRaLNRiBGwmBNyidLxWBHxGFNySXCwqLKyqrNR6LKxGBNTS1NTW1Jw+BEweDDQ2NAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAaoQIBwCAgIiEjAgAAoGA6I5DBBUBgWjIZDqnwYGgVIoTGQQgyRiGRCgZCR1nTFcsFkHm9hBp2paDYbHAsZHW9eERkYGh4eGx4ag3gfSgMTIBshIiMkGyAlCCZTEpciJyQjGxcoKUQBEhcbKiQrLB4XEltDrhcaKi0utbcJra8bLzDAGrcxrTIXHi8zNCypEsO6EzU2IzQ3ONoTzK0BCAkDMQkIOTFlAH5BACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+folder_html-16:filesystems filesystems16 16:photo:16 16:R0lGODlhEAAQAIYAAPwCBAQCBERGRBQWFMzKzOzq7CwqLDw6NARqnAQ+XHR2dKyqrOTm5ExKTERCRHRydMTi7NTu9HS+1KSmpBweHDy67DyixHS61ITG3AxypByu7DxinBw+ZERmdIySjITC3ARypExOTDRurIR2RPTSdJyulEyGvBw+bFSyzJTK3LzKvPzivOTixNTChLSybGyCfCRSnBQqRASGtFyuzDw+PCRShPzy5OzerOTShKyaTEx6pCxerGRufBR+rOTezPTShNy6bER+1BxCfBQuRAxelFSixBw2VISq3GySrPTWlHyanIyitFSO3IymtCRujAxWhCRqlCQ6XGyWvNS2bFyGvDxuvCRSpLy+vMS+vGxqbFyO1GSi3EyO1FRaVCQuPLS2tDxyzKyWNFxaNCQyPGxubCxajERSVExKNJyenAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAfZgACCAAECg4eIAAMEBQICBomDBwgJCgsEDA0BDg8BhwYQERKUDxOYDAyeghQVFhehGBmVlwwOqxobHB0eH6EfIAkPIYIiIyQlJhsnKBcpvrYiKissLS4vMDEyFjOvNAA1LDY3ODk6Oyc8PTIyFzQ1Jj42P0A6QTtCQ0REIEUORkdIkihZwsSekBhNnDyBciCKiSNSplDRUcWKkRhXCGDJYgiGli1cpuTocsILjytfFmRpACAGRTBhRogZgzHlAjKGWnIoY+bMgRgBDHRBo/LAIZoxuhwKatRPIAAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+folder_image-16:filesystems filesystems16 16:photo:16 16:R0lGODlhEAAQAIYAAPz+BAQCBExKTBQWFMzKzOTm5CwuLERCRARqnAQ+XHR2dKSmpHRydCQiJMTi7NTu9HS+1Dy67DyixITC3BR2pBweHByu7ASGtFSyzHS61AxypExOTBSazBRupJQOFBSCtDxKfKTa9AxelNz61MTaxDw+PPzGpLweHJTO3ESu3DRilFymXCxKRBRypBR+rDwCBNxmVORiRKQWFCyKvJTWhDSOPCRONFSixDQaHNROPNQ2JLRubHTC5DR6rHx6fFSqRCRyLGRmXGxqbIymtCRujAxWhMySjMQ2JMyqrKTW5ERijJSenFSGXGRmZLy+vMTGxMTCvERGRMxCNOzq7NTe5LSurISKhHR2fLy6vLS2tKyurGxubCwqLOSKfOzy9Nza3KSmrIyGjGxmZKyqrIRqZIyKjFxaXJyenDw6PDw6NAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAffgACCAAECg4eIAAMEBQICBomDBwgJCguMAoUMAYcNDg8QlAyXBaWcgg0REhCfExSVpIYAFRYXEhgZE60aCQwbghUcHRQXtri6DxMHgh4fICEiIyTFtxkOJQAeJicoKSojKywtLsUZJS8wMTIpMyA0NTYKIiIaNwc4OTo7PD0+P0BBhAwhUkTFAQNGjiBJomQJExsMmjh5AkVIFANQpEyhsqSKlStXmmDJomVLFC5Gunj5QiALmDAKxGSpMsYiAC5kqjhZUOaKmUdmzoAJgkaQgQYCmogJEmRQAC5pAPgJBAAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+folder_important-16:filesystems filesystems16 16:photo:16 16:R0lGODlhEAAQAIIAAPwCBExGTKQqLPz+/KQqNAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAM7CLoQwZAFIV6Es15Jqd2ZtzXUMIhXZqJYaZ5aK7zwp6h0zc05i+c6Eg8oCnWOR0eHQGEKnEWHdDoF+BMAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+folder_locked-16:filesystems filesystems16 16:photo:16 16:R0lGODlhEAAQAIYAAPwCBAQCBExKTBQSFMzKzOTm5CwuLERCRARqnAQ+XHR2dKSmpOzm5GxqbCQiJMTi7NTu9HS+1HRydOTm1Ozq7Dy67DyixHS61ITC3AxypERGRBweHByu7ASGtFyy1DSOtDRmfExOTBSazBR+rCwqLAxWhAxelByGtDSaxAwODHy+1Dw+PPT29IyqvCxujOzu7NTW1Nza3ExGJJyebKyqfMTCpFRSPOTi5DQqHOTezDw2NMTGxKyqhMTGrGxmXDQ2NMTCxMTGpHx6bHx2bBQWFIyOXDQuDAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAfDgACCAAECg4eIAAMEBQICBomDBwgJCgsEDAKFDQGHDg8QEZQSlxMUDJ2CDhUWF6AYGZWXFBqCGxwdFh4XGK8fIAohtiIIIx25EZwBDREHgiQjJSYmGScoKSoRKQ8rggIsDC0uJS4oGygoAyjdAAcsLxQUMDEyMzQ1EzapBy8MDDc36tFwgONFjlQ6dgCEEZBHDx8+ctRIRehHAyAwZASZIGRIEBoUBwUwIGMCiwFEaBQJichIjo9FZLBsacRIAB0A/AQCACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+folder_man-16:filesystems filesystems16 16:photo:16 16:R0lGODlhEAAQAIYAAPwCBAQCBExKTBQWFMzKzOzq5ERCRCwqLARqnAQ+XHR2dKSmpHRydCQiJMTi7NTu9HS+1KyqrMzOzOTi5Ozu5Dy67DyixHS61ITC3ARypOzq7ERGRFRWVJyanByu7ASGtFyy1Hy+1FRSVOzu7BSazBR+rFSyzJTK3Dw+PFxaXPTy7LSyrAxWhAxelLy6vMTGxNTS1Ly6tFyuzMS+vPz69NTW1MTCvIyOjPT29OTm5HRybFSixLy+tLS2tISGhGxubIymtCRujCRqlHx6fNza1GRiZMTCxGxqZLy+vFxeXLSytKyurGxqbISChFxeZDw6PDw6NAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAffgACCAAECg4eIAAMEBQYCB4mDBggJCguMBgEGDAGHDQ4PEJQKERITFBOdgg0VFhegGBmVlxobABwdHh8WIBchsLIKIiIjCyQZJR+7JhcnoBAoKSoqKywtLi8wMbsyrwYpGhowHTMqNCqkyR8XKBwTNTY3KjgFOTopLS0ZO98wPD0+JhR490MAkCAshHyTsCLCEAlEYEgoIsCIjRlHDNzy0UFBDBtIbBzZ4KJHBB0aAQhIoqCHESQ9dAjooWQJE1uCBBRpkoSDExEcUnRYwOTJIQECNmwQwEFQgANQAPgJBAAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+folder_open-16:filesystems filesystems16 16:photo:16 16:R0lGODlhEAAQAIYAAPwCBAQCBExKTBQWFOzi1Ozq7ERCRCwqLPz+/PT29Ozu7OTm5FRSVHRydIR+fISCfMTCvAQ6XARqnJSKfIx6XPz6/MzKxJTa9Mzq9JzO5PTy7OzizJSOhIyCdOTi5Dy65FTC7HS2zMzm7OTSvNTCnIRyVNza3Dw+PASq5BSGrFyqzMyyjMzOzAR+zBRejBxqnBx+rHRmTPTy9IyqvDRylFxaXNze3DRujAQ2VLSyrDQ2NNTW1NTS1AQ6VJyenGxqbMTGxLy6vGRiZKyurKyqrKSmpDw6PDw6NAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAfCgACCAAECg4eIAAMEBQYCB4mHAQgJCgsLDAEGDQGIkw4PBQkJBYwQnRESEREIoRMUE6IVChYGERcYGaoRGhsbHBQdHgu2HyAhGSK6qxsjJCUmJwARKCkpKsjKqislLNIRLS4vLykw2MkRMRAGhDIJMzTiLzDXETUQ0gAGCgU2HjM35N3AkYMdAB0EbCjcwcPCDBguevjIR0jHDwgWLACBECRIBB8GJekQMiRIjhxEIlBMFOBADR9FIhiJ5OnAEQB+AgEAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+folder_orange-16:filesystems filesystems16 16:photo:16 16:R0lGODlhEAAQAIYAAPwCBAQCBExKTBwWHNTO1Ozq7ExGTDQuNERCRJxmDFw6DGxubKymrMzOzOzu7Hx2fCwqLOzaxPTm1NSyfKSipBweHOSmRMSKRNy2jJxuFFw+DKyqrOSeJKxqFMyaXNSyhNSufFRSVMSCJKRyHLRuFMSORNy6nPTezHxaFIxmFJxqDJxyHPz+/LyqjJR2NPz6/NTS1KyehIxqNJRmDLyWXPTu9PTy9Ozm7Nza3MzKzMzK1OTi5MTCxMTGxDQ2NMzGzLy+vLy2vKyurGRiZLSytLy6vFxaXHRudDw6PDQyNAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAe/gACCAAECg4eIAAMEBQYGB4mDCAkKCwwNDgYBBg8BhxAREhOUDxSMBQWeghUWFxOhGBkaCxuMBqscHRceHyCwCbMhqyIZIx0kJR4gJicSIAiCECMoKSorKyS6yhHQAAYsBS0uKSkZHSsdHc+CCC8vqDAxMtQzJDTdBjU2NwUsODg5Wsxz0e2ADhw7/sEgwKOHwwW3BAXwsYAHARg/eAAJIgRiogAHhhApEoSIkCERI4E0QmHDESSREAWAkASAn0AAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+folder_orange_open-16:filesystems filesystems16 16:photo:16 16:R0lGODlhEAAQAIYAAPwCBAQCBExKTBQWFOTm5ERCRCwqLPz+/PTy9PTy7OTi5FRSVHRydISCfIR+fPT29Ozu7MTCxFw+BJxqBFQ+BJSOhIRyVMTGxPzSlPzmxOTGnOzizIx6XIyCdOyeLPSuTNSubOTSvNTCnNza3Dw+POSGBLRyDMyeXAQ6XMyyjMzKzMyWBKx6FJx2FHRmTLy+xDw6PLyqjJR2LJRyDFxaXOzq7JRuLEw2BKyurDQyNNze3NTW1NTS1MzOzJyenDQ2NGxqbLy6vJyanGRiZLS2tKyqrCwuLKSmpAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAfEgACCAAECg4eIAAMEBAUCBomHAQcICQoECwEFDAGIkw0OBA8PEIwRnRITFBIHDRAVFhWipBcFEhgZGhMSEg8bGxUcHQQKth4fIBoburwbISIWIyQAEiUmJicnyrooKRYqBdQrEywt1yfJGxQuLzCEozEyM+XnEjQv4QAFEDUKCjE2JrRoYeMGjmkAchAYoWPEDh49YrBQ5SMfoR9AXvRQcSFCkBcUhFgcFCDHEBxBiOAoQgFhpABGaPg4IiFHJE8GbPoJBAAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+folder_red-16:filesystems filesystems16 16:photo:16 16:R0lGODlhEAAQAIUAAPwCBAQCBExKTBwWHMzKzOzm7ERCRExGTCwqLIw6FFQiDHx2fKyqrOzu7CQiJOzOxPTe1MySfKymrOzq7Nx2TLxmTNSelJQ+FMzOzNxiNKw+HMR6ZMyWhNSajHRydFRSVLxSLJRKJKRKJKQ+HNSWhNSmnHQ6FIRGHJRCHPz6/LSajIRONPTu9Nza3KyShLR6ZPz+/DQyNOTi5NTS1MTCxGxubGxqbMzGzLy6vLSytGRiZHRudDw6PAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAanQIAQEBAMj0jAgFAwHBDJoSGhWDAIDUHgsAgcHQ9IhLqQMAsTr9BBqUTClktVgmkYhIOMprLhdOBUHh9rICEiIyN8JCVwdwAOIiYnJyiHiRtvjgYpBSorJgknIpYRmikpLAUtLp+hIy+aLKkFMC0tGJ4mK44xBDKqLTMEBDTFNY5EMTY0MzM3NDg4OR7IQwExOjnROTk6B1FC1x8SEjs84EcBCDEAfkEAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+folder_red_open-16:filesystems filesystems16 16:photo:16 16:R0lGODlhEAAQAIYAAPwCBAQCBExKTBQWFOTi5OTm5CwqLPz+/PTy9Ozu7Nze3Ozq7HRydISCfPT29PTy7MTGxFQiDIw6FJSKfIx6XPz6/MzKzERGRNyypPTWzOzi1OzizIyCdDw+PNRuTNyCZMSSfOzW1OTSvNTCnIRyVNTS1ERCRMxGFJxGJIRKJLyCbAQ6XMyyjLRWFHRmTLy+xLSelIxWPEQeBGReVIxOJIRSPKyurDQyNNTW1JxOLEwiDKSipGRiZMTCxLy6vJyenLS2tCwuLFxaXKSmpDQ2NAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAe+gACCAAECg4eIAAMEBQICBomHAQcICQoLAoUMAYiTDQ0LDg4PCgQQnBESEREHoBMUEwUVDgsWFxEYGRiqEQ8aG68cBQQdER4fIBghu6saIiMkJSYAEScoKSrJyxIrLNEd1C0p1ygo2coRLi/gAaIwMSnx5SoyM+uCHQ8LChrv8TQ1ZNiYBuCGgoMKcJSwACNHCh07wAkK0IFHj4UQevjwEeGHREk3ZtjwAcSGjQgfEwUIIuTHEJSROhkgAsBPIAAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+folder_sound-16:filesystems filesystems16 16:photo:16 16:R0lGODlhEAAQAIYAAPwCBAQCBExKTBQWFMzOzOTm5ERCRCwqLARqnAQ+XHR2dKyqrMzKzHRydCQiJMTi7NTu9HS61KSmpDy67DyexExSVITC3AxypBweHByu7FRiZDRiZHy+1ARypExaXBy2xGRqZFSyzJTK3AQ+RByqtASCtASGtFyuzDw+PATC1ByGlFxeXISGhJSWlFRWVAxmlBR2pBR+rAQ2PAS2xHS2vMTCxJyenLS2tCRujAxWhAxelFSixAQaHARibARudAR2hEySnPTy9Nza3GRiZNTS1IymtCRqlARWXDyCjPz6/MTGxLy+vMS+vGxqbAQiJARaZEx+hLy6vKyurERGRBQuNCw6PISanFxaXDw6PCQ2NDRGRDw6NAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAfYgACCAAECg4eIAAMEBQYCB4mDBggJCgsMBQIBBg0Bhw4PEBGUDRKMBQWegg4TFBUVEBYXlZeNghgZGhsCFRyhFh0JDRWCAx4fGg0gCiERIqEcBoIjHyQeDcMlJhQnEQ8oANQpKissLS4vMDEmJhEoMjPxNDU2Ny44OTo6FzsGPD0+fgABEUTIECIMiuAzIk3GkR5IbgRJMoSAkiVKmDSRBsDJEyg1hBQYUqNGlBtSGkwZRGUDEyILWCxYcmPBgiYrB1WxEsBTgANXbCwYggVRFi2Ifm4B4CcQACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+folder_tar-16:filesystems filesystems16 16:photo:16 16:R0lGODlhEAAQAIYAAPwCBAQCBExKTBQWFMzKzOTm5ERCRCwqLARqnAQ+XHR2dKSmpHRydCQiJMTi7NTu9Hy+1ARypDy67DyixHS61ITC3Ozq7BweHJySbJyWbAxypExOTPz21KyqjPz67OzmxFSyzJTK3LSujASGtDw+PKSehPz69Pz23OzitPTqvOzerKSaZBR2pBR+rKSefMy+dKyeTIR2NAxWhAxelFSixJyadOzirLyubLyqVJySPHRmJIymtCRujCRqlPTqzOzW5OzSzNzSrLyqXLSeTJSGNMTGxMS+vLy6vGxqbJSKZOzOxNzGtNzOhKSSRIR+LGReHLy+vKyurOTWlHxyJFxSFLS2tKyqrERGRHRuRNzKfNTGdGxeJGxiNFxaXJyenDw6PDw6NAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAfcgACCAAECg4eIAAMEBQYCB4mDBggJCguMAgEGDAGHDQ4PEBEJDJcFp52CDRITFKAVo6UEFgaCFxgZGRgUFa8apBsAuhwdHh+5IBQhrwYZIh3PHdAdGSMTyQ4kJR4mJycdKCkqKywtIyMUJC4cKR7EKC8wMTIzMxE0BjUmJjY2NzgwcuggsIOHjB7NfPwAEkTIkBxEdBQxUuQIEgNJgihZwgRGEyJOnhyBciTKxSRSpDBh0iRGjClUjlSJYgXJFQBYbmTREmOLDi4BDnTxsgDJl0E5uXBBFBQMAD+BAAAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+folder_txt-16:filesystems filesystems16 16:photo:16 16:R0lGODlhEAAQAIYAAMR6RPwCBAQCBExKTPzGjBQWFMzOzOTm5ERCRCwqLPyGBPzKjARqnAQ+XHR2dKSmpMzKzHRydPyGDNTu9Hy+1OR2BNSOXHS+1MTi7ITC3AxypOzq7KRKBPyCDOySZPzizPTWxFSyzHS61ITG3FROTCQSBMxmJNRyROy2lOy2nASGtDyixJTK3FxGNIRWLMR+XPzStPTKrBRupBR+tFyuzDw+PDQuJIRSNAxWhAxmnBR2pBR+rPT29FxaVEw6LKRuVIx6ZISitCRujAxelAxmlFSixOzu7JyWjBwaFKSShNTW1MTGxDQ2NMTCxNze3Nza3HRqXMS+vGxubGRiZLSytCwuLERGRJyenGxqbAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAEALAAAAAAQABAAAAfLgAABgwIDg4eIAQSCBQYHCAMJiYMKCwAMDQ4PEAcDAggRApQSlhMUmJqOBweiFQoKBBYXGBMZGpkPBhsIHBUdHh8gISIjtCOoJCUcJicoHykqK8MstBQIASUtLi8wMTIzKtE0Ihg1gwg2Ny8xKDg5OjvhItcBCDw9Pj9AQUI4Q0QMipirZ2TDERJIkihZwg+HEHpMmjg58OQIFANLomSUQi+AACZTohiAkDEKFSocJwmoMoWKSSoPpFiZdEhAgh5XHmBhQjORTZ5+AgEAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+folder_video-16:filesystems filesystems16 16:photo:16 16:R0lGODlhEAAQAIYAAPwCBAQCBExOTBQWFMzKzOTm5ERCRCwqLARqnAQ+XHR2dKSmpHRydCQiJMTi7NTu9Hy+1Hx6dJyenLy6vIyOjDy67DyixHS61ITC3ARypOzq7ERGRFxaPKyqrBweHByu7ASGtFSyzITG3KSOPKyurBSazBR+rJTK3HS+1Hx6ZNzObAxWhAxelAxmlBRupBR+tFyuzDw+POzibNzOZIyqvCRujLyiPJyCPJSWlNTS1ISitFSixHxiFGxeJFxWLExKNCRqlDw2BFROHHxqPMSqVISChMzOzGxqZISCbLSaRKSWTFxWPNzGZNTCZLy+vLSytGxubJSSfGRiTMyyVLymTLyiRMSqTEQ+JGxqbNS+XNzKZOTWbLy2ZFxaXDw6PIyGbOzidOzifMy6XCwmFGxmXDw6LAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAfigACCAAECg4eIAAMEBQYCB4mDBggJCguMAgEGDAGHDQ4PEJQREowFBZ0TFA0VFhegGBkJEZcaGxwdHh8gFiEXGKAiowIjHCQlCCYgvL4noCgGKSoGCyssLS4vyxYwrzEyM9MSNDUrK9jKIBcGNiMjNwY4Gjk65dcIOwY8PT0+PwYUAuTIQaDeCiAGgggZMoQDEQNFchghMIHiEQNIkihZwoRJkx8RCDhxMuEJFAMGokiZQoRKFStXjpQk0QHLBgDRrEzJomULlwFHukhYgMWLIANfwIAJw+WKmDFkAjQoA8BPIAAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+folder_violet-16:filesystems filesystems16 16:photo:16 16:R0lGODlhEAAQAIUAAPwCBAQCBExKTBwWHMzKzOzq7ERCRExGTCwqLHQWhEQOVHR2dKyqrNTS1PTy9Hx2fCQiJOTK7OzW9LyKzGxubLRW1JxOtLyCzMSS1HwijKSipLQ61HwinKxuvHQajFRSVJQytIQqlKRqvMSe1GQebHQihLSCxNzG5Pz+/KyStHQ6hPz6/PTu9Nza3KSGrJxmrOzm7MzOzDw6PDQyNOTi5MzGzMTCxGxqbLy6vLSytHRudGRiZLy2vDQuNFxaXDQ6NCH5BAEAAAAALAAAAAAQABAAAAaoQIAQEBAMj0jAgFAwHBDJoSGhWDAaDkPxEThCIpIJlcJgFgpdIaRiuYAxGcVD02gKBxuOpXPBvD1VH2ogISEceiIXI2ATBmohJAklGYaIJieOAAIoBSkqJCUlHJUmmQYrDiwFLS6foRwvpqkwMCstDTGtJCoyQjMELTQttw01Nsc3B0MBMxQ2DSfGNjg5OplHzDs5ODw5DMlRQgE9PhoMOjPh2BA/AH5BACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+folder_violet_open-16:filesystems filesystems16 16:photo:16 16:R0lGODlhEAAQAIYAAPwCBAQCBExKTBQWFOTi5OTm5CwqLPz+/PTy7Ozu7HRydISCfPT29Ozq7Nze3MTGxEQOTGwahDwKRJSKfIx6XOzi1Pz6/MTKxNSi5OTS7Mym1OzizJSOhIyCdDw+PKxSzLRq1LSCxOTSvNTCnIRyVNTW1JwixHwqlKRutOTS5AQ6XMyyjNTS1JwerHQmfIQylHRmTLzCvKyWtHRChHwuhFxaXERCRHQ+fLSytDQ2NKSmpGxqbLy6vDwOTJyenDQyNKyqrCwuLDw6PAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAfDgACCAAECg4eIAAMEBQICBomHAQcICYwChQoBiJMLCwUMBw0NDg+bEBESEAcLDRMUExUMFggXAhAYGRoREBAIGxscFB0EBB4QHyAhGrq8EBsiIyQlHgAQJicnKMspuyorJCzVEi0uLy7Z2xopEDAx1QEMDDIzLjTZ2hI174I2CQ0EHMi4ge7EDQk4qgHI4aChAxYsLsg4J0GHQkI5dsSIeCFGDB49fFwcFOBHDRw8cOAAAmEkpyA1fOjoISQSJwPV/AQCACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+folder_wordprocessing-16:filesystems filesystems16 16:photo:16 16:R0lGODlhEAAQAIYAAPwCBAQCBExOTBQSFMzKzOTm5ERCRDQuLARqnAQ+XHRydKSmpExKTCQiHMTi7NTu9HS+1HR2dCQiJDy67DyixHS61ITC3AxypKyqrBweHGxqbGRmZFxaXFRSVERGRPz+/ITG3JyalOze1PTm3Ozi1PTm1Hx2bJTK3IyOjPTy9CQqJFyuzDw+PNTGnDQyNPTq3Ozq7MS2hASGtKyaXCwqHBwaHFxWTKyahLSijKyehHRmXHRqNFSixHxyNAwKDERCPAQGBCwqLIymtCRujAxWhCRqlMS+vMTGxIyCVJSSfLy6vLS2tLSytGxubCwqJExGJEQ+JBQWFJyanDw6NDQ2NBQaFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAfUgACCAAECg4eIAAMEBQIGB4mDBggJCguMDAEGCgGHDQ4PEJQRlwWmnYISExQVoBYXCREYjAaCGREaGxwdHh8PIJQKhgAhIiMkJSQkJhUnrrUGKCkf1B8pGyoUK60sLSouIS8vMCUhBw0xMjIVBjM0NTY3ODk5Og0NOwgXPCw9AD4BBvwwMABIgCBChhApUqtBhgw1INaIWMPIESMaGiIRsbFjkhpKlmDQYKgGx5MdDyxhgqFJLSdPoMiU+YRGFA5SRk4RRCWDix9TnFRxISiAE6J+AgEAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+folder_yellow-16:filesystems filesystems16 16:photo:16 16:R0lGODlhEAAQAIYAAPwCBAQCBExKTBwWHMzKzOzq7ExGTCwqLERCRJSSDFxWDGxubKyqrNTS1Hx2fCQiJOzqzPTy1NTKfHRydOTWTMSyTNTKjNzOjJyWFHR2dKymrOTaLKyaFLyyRMS6ZFRSVLy2JKSeHNTOnNTKhHR2FISGHIyKHKyeFOzmxPz+/LS2lIyCNJSWJMzKfPz6/PTy9Nze3KyqhLS2XPTu9Ozm7Nza3MzK1LSyjIyONDQyNOTi5NTO1MTGxMTCxMzGzLy6vLSutGRiZLy2vKyurKSipAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAe0gACCAAECg4eIAAMEBQYGB4mDCAkKCwwNjYUOAYcPEBESlBMMjAUFnIIPFBUWnxcYChkajAaCAxscHR4SrREWlBkfqSAYIRy5uyKfIwipISQlJhgnx7oSKM0ABikFKivQCSwn1C3ZCC4vLwUwMd/RGDLZBjPqNCk1NTY33zjZOQQ1dOBrsIMHjx49FtQSFCDHgh47GvhA+AOIwkQNgwARUnHIxUiEcnwgwmBBDpCHAjw46ScQACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+folder_yellow_open-16:filesystems filesystems16 16:photo:16 16:R0lGODlhEAAQAIYAAPwCBAQCBExKTBQWFNze3Ozq7ERCRCwqLPz+/PTy9PT29FRSVHRydIR+fISCfOzu7OTm5MTCxFRWBIyOFFRSBJSKfIRyVOzqnPTuzNzapOzi1OzizIx6XIyCdNzORNzSZMTCfOzqzOTSvNTCnNTW1NTGFKSaHLy6ZAQ6XMyyjMzKzDw+PLS+DHyGHIySJHRmTLy+xLS2lIyKPISGJGReVOTi5ISGNExKBKyqrDQyNNza3NTS1JyeJKSipGxqbMzOzLS2tJyanKyurLy6vKyutCwuLAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAfDgACCAAECg4eIAAMEBQYCB4mHAQgJCowLAQYMAYiTDQ4FCgoPEBARnBITFBIIoBUWFaEKBREGFBcYGaoUChobFRwdBRAGEh4fIBkhuqsbIiMWJAYAFCUmJifJG7ooKRYqK9QsLS4T19kZGxIvMNMBojEyMy4u5xQ0EeEABgUFBDUxbJBzYeMGjmkAchBYqGPHjggxeMy40UMfoRw+IvxQoSICEBgUgiCUlIOGkCFAiOCgYDFRgCILgqxsGYnQgRwA/AQCACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+ftp-16:filesystems filesystems16 16:photo:16 16:R0lGODlhEAAQAIYAAPwCBFxaXNze3LSyrJyanPz+/Ozq7GxqbDxinBw+ZERmdIySjHRydMzOzPT29CwuNDRurIR2RPTSdJyulEyGvBw+bLzCxIyKhGxubERCRLzKvPzivPTmxNTChLSybGyCfCRSnBQqPLy6vLy2rCRShOTixPzy5OzerOTShLyaVEx6nCxerGRyhOTi3OzaxPTShNy6bEx6rER6zDRitBxCfPTq3LyulBw2VISq3GySrPTWlHyanIyitFSO3PTm1Ozi1LyqjDQyNCQ6XHSq3GyWvDxuvCRSpLSqpOzezAQCBCxGZCRKZExGLDQuHAwaLBQWHKymnOzexARCBJzOnGy2bDyePCxKJOzWvLymhAx6DAyGDDROLOTOpHRmVLyidLyedAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAfRgACCAAGFhoaDiQECjIwDAQQBiYKLBZYFBgcFkZMICQoLlwwNDgQPghAREhMUCBUWBRcMGBmnEBobHB0eHyAhIg4CIxenJCUmJygpKisVLAIGLSMPJBQuJi8wMTIzNCEWJjU2Dzc4OTo7PD0yK94DPj9AQUIUQ0QwFDFFRjchRz5IbARJEkLJkiVMmDRx8uQBlCgbgDyQMmUKlYpTqlSsYsXFFSwTK2bRMmWkyCxbuICkmKVlySwvpXTh4mWilJs4c3bB8uXLqUEBHggdSvSBn0AAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+link-16:filesystems filesystems16 16:photo:16 16:R0lGODlhEAAQAIIAAPwCBFxaXPz+/AQCBKSipAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAMgCLrc/jDKSau9OL/AuwxCKAzfOIwlcZIRKLJQMMyz5CcAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+network-16:filesystems filesystems16 16:photo:16 16:R0lGODlhEAAQAIQAAPwCBAQCBISChPz+/Nza3ARaZESanCyKlARudARGTLy+vNzq7ARmbMTCxARufAROVMzOzKSipARyfOzq7AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAVmICAGZFmKQiACweCSBImq41AYB5IodLq2hwWO0ejRWDac48Gb/QKNqNRoqspmrVcAUuIJBANS8sBIFCORUgooPEh4J8B67NgdsVBp9C5XWfl9LRMTCyReX19hARNojWlWLH+AAH4hACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+pipe-16:filesystems filesystems16 16:photo:16 16:R0lGODlhEAAQAIIAAPwCBAQCBISChMTCxPz+/ARCBFxaXASChCH5BAEAAAAALAAAAAAQABAAAAM2CLoazpAFIV6UYZB6Yd5BtwRbEYqkYIqAQRir6KpnN8cdCddXivcbAy+S2qEOAuPx8MtZRP4EACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+shredder-16:filesystems filesystems16 16:photo:16 16:R0lGODlhEAAQAIMAAPwCBERCBAQCBMTCBPz+xFxaXPz+/AQChISCBISC/DQyNPz+BARCRAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAARcEMgZhBUzgzuIH4G2FYThnZUlCab5Ed0hC6nZ3Yh8JIKyLjCYboeZKIK6BDHTGwyViopEoWAkdwfqoKhIKLFUwXY79coUtLG4CFAcOOstWyNWyEXMO57p2/vxfhEAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+socket-16:filesystems filesystems16 16:photo:16 16:R0lGODlhEAAQAIMAAPwCBAQCBPz+xMTCBFxaXKSipDQyNPz+/MTCxISChAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAARKEMgZpr1SjFqx1QHoTaA4AuV2EmmHEUUxsKoHB7FMGPbhI7gCgnchII6+AyJBtBhjx0KC2TsIp9QXcpm1HafNEQF8mhAOCdfEHwEAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+trashcan_empty-16:filesystems filesystems16 16:photo:16 16:R0lGODlhEAAQAIMAAPwCBAQCBKSipERCBARCRPz+/MTCxISChFxaXAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAARREEgZapiYWjGIvVNQjEZ5BKUAApVgjEWJzCtAnIGgC8eZ5bre7ICosQQFVY9Y/CGVwiYmlwwsac7qVRp6WqNGKpQZ9m7DojH2t+lVMtMP3B8BACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+trashcan_full-16:filesystems filesystems16 16:photo:16 16:R0lGODlhEAAQAIMAAPwCBAQCBPz+/Pz+xATCxMTCxMTCBKSipPyqXISCBFxaXISChAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAARbEIAQJJU4BzEoIdSFbcNQnIVhBJ02GAeFIGxZjUl8KoHRagfeYqgo3kaxQOEwXPAyk4Mgtgg6jxYp1foETgPEKzSgBXOx0W9VIfZu2d3R5t3WhA5BEdQSQgP8EQAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+www-16:filesystems filesystems16 16:photo:16 16:R0lGODlhEAAQAIYAAPwCBFxaXNze3LSyrJyanPz+/Ozq7GxqbDxinBw+ZERmdIySjHRydMzOzPT29CwuNDRurIR2RPTSdJyulEyGvBw+bLzCxIyKhGxubERCPLzKvPzivOTixNTChLSybGyCfCRSnBQqPLy6vOTi3Ly2rCRShPzy5OzerLyaVEx6nCxerGRyhOTezPTShNy6bEx6rER6zDRitBxCfPTu5PTq3LyqjBw2VISq3GySrPTWlHyanIyitFSO3LSqpPTm1DQyNCQ6XHSq3GyWvDxuvCRSpKyurOzizAQCBCxGZCRKZExGLDQuHAwaLBQWHKymnPTmxOzaxHx+fMTCvOzWvLymhHRmVExGPOTOpExOTERCRLyedBwaHAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAfWgACCAAGFhoaDiQECjIwDAQQBiYKLBZYFBgcFkZMICQoLlwwNDgQPghAREhMUCBUWBRcMGBmnEBobHB0eHyAhIg4jJBenJRwmJxIoKSoVKwIGwg8lFCwmLS4vMDEyIRYzNDUPNjc4OTo7PDAq3T0+Pj0/QBRBQi4UL0NENiFFPkbijoRAkiSJEiVLmDR54OQJFHEPREQRIWWihYlRMkCZQuXBgyIBihSpIjLAowBWroj7gaUIlpYvXWLJUuWKlgdbHvz44XHnzgdVami5qUinR50/efoJBAAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+zip-16:filesystems filesystems16 16:photo:16 16:R0lGODlhEAAQAIIAAPwCBIQChPzC/AQCBMQCxAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAMeCBCh/i+IAesShNo4+v5gKI5kaZ7oxzCilLVvq/kJACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+cal1day-16:korganizer korganizer16 16:photo:16 16:R0lGODlhEAAQAIIAAAQCBPwCBAQC/AQCjPz+/MTCxKSipAAAACH5BAEAAAEALAAAAAAQABAAAANOCLrMEUDIOUS9AFLLhx8LIRZjKYZmMRCkaChFLHty/AIiS3y6q+QtT49wq8VotRtQJGwRf6Zmrlj7DJLQXsupTJmeEIN4TB5nII20wp8AACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+cal5days-16:korganizer korganizer16 16:photo:16 16:R0lGODlhEAAQAIIAAAQCBPwCBAQC/AQCjPz+/MTCxKSipAAAACH5BAEAAAEALAAAAAAQABAAAANMCLrMEUDIOUS9AFLLhx8LIRZjKYbj55GioRRwoQ5x4QIiIdMmcec7jy53q81qP9OO5VMAj8RXTFWzOZW95HDLdEEM4LA4nIE0zgp/AgAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+cal7days-16:korganizer korganizer16 16:photo:16 16:R0lGODlhEAAQAIIAAAQCBPwCBAQC/AQCjPz+/MTCxKSipAAAACH5BAEAAAEALAAAAAAQABAAAANPCLrMEUDIOUS9AFLLhx8LIRZjKYbj55GioRRwoQ5x4QIiwcp0fucsj873qvGMv5Jw2FIACUsW4WakGW1O046I05qmGYBhTC6TM5CGWuFPAAAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+calappointment-16:korganizer korganizer16 16:photo:16 16:R0lGODlhEAAQAIMAAAQCBPwCBAQC/AQCjPz+/MTCxPz+BISCBISChKSipAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAEALAAAAAAQABAAAARbEMhJaQhA6D1E/wDGeeRgDhOhFoTBEi+REgdrIHScSEVvAD9Xr7cDqGSGpFEnQSqTv2NxCFQOiU1VEAiTZmstHFg1vQKuw+LxxfYaV/AuOQRI2O/4ewhT6Uv8EQAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+calbell-16:korganizer korganizer16 16:photo:16 16:R0lGODlhDwAOAIIAAPwCBISCBPz+BIQCBMTCxISChPz+/AQCBCH5BAEAAAAALAAAAAAPAA4AAAM+CLrR+zCIAWsgLVRGRBhOVQiG94WPVAbHaZHYAWqRYLbge88RsbInGuBCEhRYrZYm4xk4nYdoKzKIbiKHawIAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+callist-16:korganizer korganizer16 16:photo:16 16:R0lGODlhEAAQAIMAAAQCBPwCBAQC/AQCjPz+/KSipPzerMRaBEQCBAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAEALAAAAAAQABAAAARDEMhJaQhA6D1E/wDGeeRgDhOhruyatjBRSIRxxOsMEAdC0BUZDcfSEYvDo3Bn++2Cxt7RqFxWhZiCdsvdhjCVsMQfAQAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+calmonth-16:korganizer korganizer16 16:photo:16 16:R0lGODlhEAAQAIIAAAQCBPwCBAQC/AQCjPz+/MTCxKSipAAAACH5BAEAAAEALAAAAAAQABAAAANSCLrMEUDIOUS9AFLLhx8LIRZjKYbiRxLFIBpK0Q6z7MkwkJIe8b0KEeuWchFysuStVsjtfMbeMQitWpG25YfmNK1WU53XNIUYzug0OgNpuBX+BAAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+caltoday-16:korganizer korganizer16 16:photo:16 16:R0lGODlhEAAQAIMAAAQCBPwCBAQC/AQCjPz+/MTCxKSipPyCBMRaBPyqXAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAEALAAAAAAQABAAAARTEMhJaQhA6D1E/wDGeeRgDhOhFmurpi5LyIQhFfiBIAfuFzaAioBIJBCummRYPCaDPh3vhwsOZdihNfa8Ub/AJXemFZPPNBvGwG672yFMZS7xRwAAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+caltodo-16:korganizer korganizer16 16:photo:16 16:R0lGODlhEAAQAIMAAAQCBAT+BAQC/AQCjPz+/MTCxPzCxKSipPwCBMQCBIQCBAAAAAAAAAAAAAAAAAAAACH5BAEAAAEALAAAAAAQABAAAARaEMhJaQhA6D1E/wDGeeRgDhOhFmurpi5LyMYhFXiuFwZiA6qZYbbqJX5BIw2RAPxwAAWCyWMCCsiXFGEEErKz6LQZfOqiTR1YJiGq1rFyyHmo2+/1EKbCl/gjACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+adjustcol-16:kspread kspread16 16:photo:16 16:R0lGODlhEAAQAIEAAPwCBGRiZAQCBPz+/CH5BAEAAAAALAAAAAAQABAAAAI7hI8JAWL+IgvwUSSY2Lz7VTXXkS2NdJ6TwiSaB3PNQNdCbc/4cO9OjwPmhDQiTxfcHY1MpE35g0IB/gIAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+adjustrow-16:kspread kspread16 16:photo:16 16:R0lGODlhEAAQAIEAAPwCBGRiZAQCBPz+/CH5BAEAAAAALAAAAAAQABAAAAI5hI8JEcItooxG1oEzBoJ7oWlHd4VbNZpbx3LqUFGuajTPhI8kSLfsO0rRUCXT5wPkyHhGhsOJs/gLACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+black_sum-16:kspread kspread16 16:photo:16 16:R0lGODlhEAAQAIAAAPwCBAQCBCH5BAEAAAAALAAAAAAQABAAAAIdhI+py60BY2QwhVYdytpw/WFXF1LjcW6S1LVu6xcAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+border_all-16:kspread kspread16 16:photo:16 16:R0lGODlhEAAQAIAAAAQCBPwCBCH5BAEAAAEALAAAAAAQABAAAAIjhI+pq+FuHjwyRInqfRkDTXkgQ5YLOH6it00pyqqcPJk26RcAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+border_bottom-16:kspread kspread16 16:photo:16 16:R0lGODlhEAAQAIAAAAQCBPwCBCH5BAEAAAEALAAAAAAQABAAAAInRIynGe0PFTQz2kdxzHf72iSiRDpc2F1niaafBroYQNe2fdx6HfgFACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+border_fall-16:kspread kspread16 16:photo:16 16:R0lGODlhEAAQAIAAAAQCBPwCBCH5BAEAAAEALAAAAAAQABAAAAIrRIyneRYP4wPUKWmr3E5b+DVh9GkYuFALiqnsJp6nObYZB5ow2a3Jvwv6CwAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+border_horizontal-16:kspread kspread16 16:photo:16 16:R0lGODlhEAAQAIAAAAQCBPwCBCH5BAEAAAEALAAAAAAQABAAAAImRIynGe0PFTQz2kdxzHf7CoTiSB7kKUpa1Vlc86rtSjvxnOSL4hcAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+border_inside-16:kspread kspread16 16:photo:16 16:R0lGODlhEAAQAIAAAAQCBPwCBCH5BAEAAAEALAAAAAAQABAAAAIrRIygxxYPF4zzyenqxfVk2m0g9lnKiabqqoYl43YwGcqiFWv22zRnD/AXAAAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+border_left-16:kspread kspread16 16:photo:16 16:R0lGODlhEAAQAIAAAAQCBPwCBCH5BAEAAAEALAAAAAAQABAAAAInBHKJmxYPY3TyVCozsjMbrk3gM27KyZDlioVQS3qwO7Nl6KC6q/kFACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+border_outline-16:kspread kspread16 16:photo:16 16:R0lGODlhEAAQAIAAAAQCBPwCBCH5BAEAAAEALAAAAAAQABAAAAIrhI8ZybgQYoTy2YqtwVTunVVfN3HQsaTnc5Kp2Ibw5Zm0PHJ2w7O8I5P5CwAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+border_remove-16:kspread kspread16 16:photo:16 16:R0lGODlhEAAQAIAAAAQCBPwCBCH5BAEAAAEALAAAAAAQABAAAAIjRIynGe0PFTQz2kdxzHf72iSiRDpc2F1niaafBrraSMuQXwAAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+border_right-16:kspread kspread16 16:photo:16 16:R0lGODlhEAAQAIAAAAQCBPwCBCH5BAEAAAEALAAAAAAQABAAAAInRIynaOEPH5hRRVrzbJBLn32g1TXJuWBdpYYiy47hBl+yRqH6HfoFACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+border_top-16:kspread kspread16 16:photo:16 16:R0lGODlhEAAQAIAAAAQCBPwCBCH5BAEAAAEALAAAAAAQABAAAAImhI8ZyRgPo3xgVnmnprbvnUEhx1XmgpLRmH7e+rowFssleuaBXwAAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+border_up-16:kspread kspread16 16:photo:16 16:R0lGODlhEAAQAIAAAAQCBPwCBCH5BAEAAAEALAAAAAAQABAAAAItRIynwOEPH0vRuGkjnFKjpmgX2FVkuBwNhapZKZ3VyMKcGJPv5eJmAkz5RP4CACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+border_vertical-16:kspread kspread16 16:photo:16 16:R0lGODlhEAAQAIAAAAQCBPwCBCH5BAEAAAEALAAAAAAQABAAAAIrRIygxxYPF4zzyenqxfVk2m0g9llmsiCmVjJh65Jh59GtGMuzqqQNDQz4CwAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+cell_edit-16:kspread kspread16 16:photo:16 16:R0lGODlhEAAQAIEAAPwCBAQCBPz+/ISChCH5BAEAAAAALAAAAAAQABAAAAIshI+pm+EPnwmi2msDoLgLzQWDV4HlSJof6qki+W0nrMKlbN9bxGvMDwwG/QUAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+cell_layout-16:kspread kspread16 16:photo:16 16:R0lGODlhEAAQAIIAAPwCBAQCBPz+/PzerMTCxPyqXHx+fAAAACH5BAEAAAAALAAAAAAQABAAAANCCLrc/i3ISacKIuutA8ACxWUeJg0DqBHhd6ZiRpQBag9F2n13FRis0q1QUAmCvFuKRTAYWhIi0bhz+SqQrHbL9ScAACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+chart-16:kspread kspread16 16:photo:16 16:R0lGODlhEAAQAIIAAPwCBAQCBAQCxAQC/AT+/MTC/Pz+BAAAACH5BAEAAAAALAAAAAAQABAAAANMCLocHiyuIASU6lE7Xx7DdgEBQVwBKE4mqlZjeT4vl7VFkYZUjOuGkMFiuJ1yKUNAWTQGkEKDknUESpdXkkYjnWIWzOVX0SyPJwx/AgAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+comment-16:kspread kspread16 16:photo:16 16:R0lGODlhEAAQAIIAAPwCBAQCBPz+BPz+/Hx+BAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAM5CLrc/i3ISacKYuStuwhAMBATKRHkAGJeu60qagqmuHK4B6Pn3N0u147Ha8FyOVCowlRCntAo1J8AACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+deletecell-16:kspread kspread16 16:photo:16 16:R0lGODlhEAAQAIIAAASC/AQCBPz+/PwCBMQCBISChAAAAAAAACH5BAEAAAAALAAAAAAQABAAAANICLrc/i3ISacKIuutA8BcKAwfNwwmQYDZoJ6tWrBZoRKuXIb2XRS7UG4wC25yOIGHFvu9PJ8KcRbQOVzAheoxbRCyDOKj4E8AACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+delete_table-16:kspread kspread16 16:photo:16 16:R0lGODlhEAAQAIIAAASC/AQCBPz+/PwCBMQCBISChAAAAAAAACH5BAEAAAAALAAAAAAQABAAAANPCLHcDDCIOSUVAaqLeY5O+G2XRQVDdA0DNxCEwrwEu9AFORVw3ee6Cu8HFKFgA2AQQ6uNTJNXYZgCNZKFBay4IhQuMBUFW/LKZlkHoOBPAAAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+dissociatecell-16:kspread kspread16 16:photo:16 16:R0lGODlhEAAQAIEAAASC/AQCBPz+/PwCBCH5BAEAAAAALAAAAAAQABAAAAI0hI+pm+EPoQlC0GqxnfV2HUzR6HDWgA5Bqppr+qIhcMUqO5Oki+M87KN1ejCRTsJIKhP+AgAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+first_letter_upper-16:kspread kspread16 16:photo:16 16:R0lGODlhEAAQAIAAAPwCBAQCBCH5BAEAAAAALAAAAAAQABAAAAIohI+py72RIJOHRmBt3QaGz2GVBGJfKW4aiXhX2sHxbKKneDv6zht+AQAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+fontsizedown-16:kspread kspread16 16:photo:16 16:R0lGODlhEAAQAIAAAPwCBAQCBCH5BAEAAAAALAAAAAAQABAAAAInhI+pELHqmIkQNZrwfXYvzE1fBUrWoZniOjWdp0agjLL2i7rhDvgFACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+fontsizeup-16:kspread kspread16 16:photo:16 16:R0lGODlhEAAQAIAAAPwCBAQCBCH5BAEAAAAALAAAAAAQABAAAAImhI+pEeoNIFyIzXStw3q/T4VVhJHHlDGjgZ6n1bLyCrqPyuJe4hcAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+funct-16:kspread kspread16 16:photo:16 16:R0lGODlhEAAQAIAAAPwCBAQCBCH5BAEAAAAALAAAAAAQABAAAAImhI+py60R3IkRVHQzo9BwD1qhqGneRU4gSqlVJ8Zy0mKPhOe6XwAAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+insertcell-16:kspread kspread16 16:photo:16 16:R0lGODlhEAAQAIIAAAQCBPwCBPz+/Pz+BATCBAAAAAAAAAAAACH5BAEAAAEALAAAAAAQABAAAAM7CLoa/k7IKQCEdNobc+UOMCijCD5jGjAMOowrIc/Wm77ATIe2leuETcrEYpSOJ88HpNxwmqdi40Tl+BMAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+inserttable-16:kspread kspread16 16:photo:16 16:R0lGODlhEAAQAIEAAPwCBAQCBPz+/AAAACH5BAEAAAAALAAAAAAQABAAAAIuRI6JwCH/HBSBmUlxbarvO0nQJ0aa5XWodjZsiKbJGrbgaMuzW8M87jPoDgx/AQAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+lower-16:kspread kspread16 16:photo:16 16:R0lGODlhEAAQAIAAAPwCBAQCBCH5BAEAAAAALAAAAAAQABAAAAIqhI+pELHqmIkQNZrwfXYvzE0QKGniQWmNhbYSeqXn6zJOBJLTuuuh4i8AACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+mergecell-16:kspread kspread16 16:photo:16 16:R0lGODlhEAAQAIEAAPwCBAQCBPz+/ATCBCH5BAEAAAAALAAAAAAQABAAAAIyhI+pm+EPoQlC0GqxnfV2HUzR6HDWgKZpCFyBCrMurMoPvZovPsgd39MBbaQI44hU+AsAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+money-16:kspread kspread16 16:photo:16 16:R0lGODlhEAAQAIIAAASC/AQCBPz+BPwCBASCBATCBAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAM+CLrcHMHJIEaUD16sqIUcQAne5pQaBglkZS6lxb6dRoIAQTzuphcFXWeW0xl/utIPGDQOSUdnA7IUhoocfwIAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+oscilloscope-16:kspread kspread16 16:photo:16 16:R0lGODlhEAAQAIIAAPwCBAQCBOTm5Hx+fLy+vAQCfAAAAAAAACH5BAEAAAAALAAAAAAQABAAAANKCLrcGjDK+IS9494AgrbEJ3CeUBRWpp2daaHhhZKuq75jh8pxTRaEQbAgFAIHv1VvR/vsdrnSCmdpagYnjfXS27Q+N29nQuYA/AkAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+percent-16:kspread kspread16 16:photo:16 16:R0lGODlhEAAQAIAAAPwCBAQCBCH5BAEAAAAALAAAAAAQABAAAAIkhI+py70RUHxxQmosu6BOdWkNR35PVm1etqEsaKXnwTn2DfgFACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+precminus-16:kspread kspread16 16:photo:16 16:R0lGODlhEAAQAIEAAPwCBAQCBPz+/AAAACH5BAEAAAAALAAAAAAQABAAAAIthH8RiJvrmHogVoXNtFRDpjUf6JWkeUoXlpGBAMfC+cowbd+uwL54/rMFZf4CACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+precplus-16:kspread kspread16 16:photo:16 16:R0lGODlhEAAQAIEAAPwCBAQCBPz+/AAAACH5BAEAAAAALAAAAAAQABAAAAI2hG8Rp4y9IGgszqhyspLueYHih43hiX7Iui5XprGTQNeCPNNBje86L9vBdr2a7xY0AllHm78AACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+removecell-16:kspread kspread16 16:photo:16 16:R0lGODlhEAAQAIEAAAQCBASC/Pz+/PwCBCH5BAEAAAEALAAAAAAQABAAAAI5hG+hq+IvAGPwydlqxAohvnjHMChkR6YDcKaougZqCMdyGYqSG+jXKQtoNkGTUHPBDJMTH+jJ8RcAACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+removecomment-16:kspread kspread16 16:photo:16 16:R0lGODlhEAAQAIIAAASC/AQCBPz+BPz+/Hx+BPwCBMQCBISChCH5BAEAAAAALAAAAAAQABAAAANVCLrc/i3ISacKYuStuwhAMBATKRHkUIScUBSeahhigBbzK+HGgXmHmYHXC41MqKDwcGDFMryCz4gi3YQwkKiFY+ZAoYrUF5g1HV3G7DFuFBvSx8GfAAAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+resizecol-16:kspread kspread16 16:photo:16 16:R0lGODlhEAAQAIIAAPwCBFxaXAQCBDQyNPz+/AAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAMyCLrcG0A4CZ90saohuv+XEgxYxkDhQp2lyIBwKhB0bct2TuB6zfe7F5D26xV1x9zFnwAAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+resizerow-16:kspread kspread16 16:photo:16 16:R0lGODlhEAAQAIEAAPwCBFxaXAQCBPz+/CH5BAEAAAAALAAAAAAQABAAAAIyhI+pmxHinph0GnqH3hoIDwocd3zZ2F0lmoInWq5s/I60xw5hmF8WPnNAhJUK44hM+AsAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+series-16:kspread kspread16 16:photo:16 16:R0lGODlhEAAQAIEAAPwCBAQCBGRiZAAAACH5BAEAAAAALAAAAAAQABAAAAIjhI+py+0fUGRhGrswVtr1FgiGsGlhZVWAuarr9byyB8f24hcAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+sort_decrease-16:kspread kspread16 16:photo:16 16:R0lGODlhEAAQAIIAAAT+BPwCBAQCBAQC/FxaXAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAM5CBDM+uKp8KiMsmaAs82dtnGeCHnNp4TjNQ4jq8CbDNOroIe3ROyEx2A4vOgkOBzgFxQ6Xa0owJ8AACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+sort_incr-16:kspread kspread16 16:photo:16 16:R0lGODlhEAAQAIIAAAT+BAQC/AQCBPwCBFxaXAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAM4CAqxLm61CGBs81FMrQxgpnhKJlaXFJHUGg0w7DrDUmvtPQo8qyuEHoHW6hEVv+DQFvuhWtCFPwEAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+special_paste-16:kspread kspread16 16:photo:16 16:R0lGODlhEAAQAIMAAPwCBAQCBPz+xPz+BNTS1MzGLMRaBMzOzPz+rPyqXPz+/MzGNDQyNKSipAAAAAAAACH5BAEAAAAALAAAAAAQABAAAARoEMgJQhBySGx7IEQwFKMWGKgRHNZRIAJSVAm6usIwCEo+BDWVJ/CKzYAplWJZItGSgSVPZBEgU9EFQyGyWoK25XJ4DTO2iob6CxVLe2ys4rw9e8HKd8ybVJ7ndgEVQz09e1YUEmQefhEAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+strike_out-16:kspread kspread16 16:photo:16 16:R0lGODlhEAAQAIEAAPwCBAQCBGRiZAAAACH5BAEAAAAALAAAAAAQABAAAAIghI+py+0BgwOS1gXnuS/b6ClCpCUcclJMmKIGWcby5BcAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+text_bottom-16:kspread kspread16 16:photo:16 16:R0lGODlhEAAQAIAAAPwCBAQCBCH5BAEAAAAALAAAAAAQABAAAAIVhI+py+0Po5y0hYtzrkB7zH0fN/kFACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+text_center-16:kspread kspread16 16:photo:16 16:R0lGODlhEAAQAIAAAPwCBAQCBCH5BAEAAAAALAAAAAAQABAAAAIbhI+pm+EPIZsnRkqtDnhu1zHfFSpjaY4PavgFACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+text_left-16:kspread kspread16 16:photo:16 16:R0lGODlhEAAQAIAAAPwCBAQCBCH5BAEAAAAALAAAAAAQABAAAAIbhI+pm+EPIZsgRoqr3Vnt102fFSJjUC6nlPoFACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+text_middle-16:kspread kspread16 16:photo:16 16:R0lGODlhEAAQAIAAAPwCBAQCBCH5BAEAAAAALAAAAAAQABAAAAIXhI+py+0PT5i01pisphjt3UmfFZYm5hcAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+text_multirow-16:kspread kspread16 16:photo:16 16:R0lGODlhEAAQAIAAAPwCBAQCBCH5BAEAAAAALAAAAAAQABAAAAIbhI+pm+EPIZsg2kfZvblXbwTg10WlA4rjyvgFACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+text_right-16:kspread kspread16 16:photo:16 16:R0lGODlhEAAQAIAAAPwCBAQCBCH5BAEAAAAALAAAAAAQABAAAAIahI+pm+EPIZstSrqsDhhv1ylfFE5jiYwX6hcAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+text_top-16:kspread kspread16 16:photo:16 16:R0lGODlhEAAQAIAAAPwCBAQCBCH5BAEAAAAALAAAAAAQABAAAAIWhI9pwe2uYnq0yQtqxbz7D4biSIZ+AQAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+upper-16:kspread kspread16 16:photo:16 16:R0lGODlhEAAQAIAAAPwCBAQCBCH5BAEAAAAALAAAAAAQABAAAAImhI+pEeoNIFyIzXStw3q/dR2hhEVcJqamuq6Z9brlNtKMeHuKXwAAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+vertical_text-16:kspread kspread16 16:photo:16 16:R0lGODlhEAAQAIAAAPwCBAQCBCH5BAEAAAAALAAAAAAQABAAAAIihI+pFrHqQHynTRrvyxQ12YWQWJGMpC0f2E1psr4eaj5+AQAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+applix-16:mimetypes mimetypes16 16:photo:16 16:R0lGODlhEAAQAIUAAPwCBFRSVFxaXFxeXNze3Ly2rJyanOTi3Pz+/Ozq7HRydFxaVISGhGxubMzOzDQuLExKTCwqLIyKjGxqbERCRCwuLJSSlOTi5BQSFPT29IyKhDQyNISChDw6PBweHMS6pPz69Pz29PTq3Ozm3MSynMTGxAwKDPTu5Ozi1LyulExOTCQiJPTm1OzezLyqlLSyrDw2NOTazOzizOzaxLyqjKSipBwaHOTStLymhLymfGRmXNzKtOTOpLyidMTCtMS+rCH5BAEAAAAALAAAAAAQABAAAAa9QIAQEBAMikfjcCkgOJ2FgCGwFAYOiCwioUAYFtUrgtFFNBzeB5OAgESyEsWEUjFYAJYJ4hLBoDMHBRobAAaGehwdHnoZCQcfEUKHCBQBAxsgISIjJIRCeSUmHAYmJSInKCmRkgYqGw4ZKxMiLC0unoUvFBQQMBQRMTIzNBVDFjUrGwO9Nh8zNzi4BhM2LyIvGhgLNzc5akM6DsEyMjsfPDw9uAALPj4/HyQ0ND31q0ICFRv6FTAb/xE2+AkCACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+binary2-16:mimetypes mimetypes16 16:photo:16 16:R0lGODlhEAAQAIYAAPwCBFRSVFxaXFxeXFRWVNze3Ly2tJyalHR2dISCfLSyrPTy9Pz+/Ozq7GxubJyanKSmpMTCxMzKzLy6vNTS1JSSlCwuLLy6tMzGxOTi3KSipKyurHx6fOTi5IyKjGxqbERGRDQyNMzOzOzu7GxmZIyKhHRydLS2tNTW1ERCROzm5MS6pIyOjDw+PPTu5PTq3LSqnOTazOzi1GRmZJSWlCQeHPTm1OzizLyqjISGhExOTGxqZDw6PNzSxOzaxGRiZExKTCQiHEQ+NLyulOzavOzWvLymhHRybLyypNTGtOTOpOzexLyidMTCtMS+rMSynLyedAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAfqgACCAAECAwQCiIiDjAIFj48GAgcBjIIICQoLDAwNDgwPA4MIBhAREgkTmw4UDBUWAxcYFAUZGggbHB0eDh8gIQkiHSMeFRoUDyQRIxkGJRYmFScTKCcHCCkgJyoNGSsWHCwKCCgIASAgLQoZLi8wISUbEyQUJAEDKQEKMS8yMBYeZmCgMcEcghog9tm4gSNEjgEPdEDYEQJEDR4aetzwgcPCjw8VfiAAwqNFECFDehApYiSEoCMQBVjQkQBJkpVKjFhgNGBGzSRLVhZRwsTloAFNmjhZ8WQIDiZQoOwcFMCCVQshrmYN4ScQACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+binary-16:mimetypes mimetypes16 16:photo:16 16:R0lGODlhEAAQAIUAAPwCBFxaXNze3Ly2rJyanPz+/Ozq7GxqbPz69HRydMzOzDQyNIyKhERCRPT29GxubPTy7Pzy7PTu5Ozm3LyulPTq3Ozi1OzezLyqjPz27OzaxLymhPz29OTStLyifPTm1OzavOTOpLyedMS+rMS6pMSynAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAaJQIAQECgajcNkQMBkDgKEQFK4LFgLhgMiOq0WDgVEQrFdKAXfhJWRODTMQ6+64BAMGHAq+pB4hCF2eURoVwgREhMUgl5/EBUWimdWB4cVDxcYiwJiGQcVfBobmhwPEgkWFg8dmWcQEgcWFw99HpoVFR8XGiAhISKLI8EkJRgYGyK/SgvLzM0LfkEAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+colorscm-16:mimetypes mimetypes16 16:photo:16 16:R0lGODlhEAAQAIcAAPz+BFxaXNze3Ly2rJyanPz+/Ozq7GxqbJxaLLxOFLQ+HLQ6NMSOnOzi5GxubMzOzDQyNMx6JOSSXOSedNx+ZMxaXLQ6ZKRalNzW3IyKjERCRNSWPPTKnNReNMRGVLxalJRGpHRanNTS3PTy9OTi3ISGfLySNOzCfPTatOy2dNxuFMw6DJxGrHROvEROnHyKrMSmTOzanNzShOSqRNyCFMxCHJxGnFxavDxqxCRmrCxijPTq3Ozm3LyulLyyZOTenNTGZMS6VISKbCyCzASGxAR6rBxmhKyqpOzi1JyuXLTShJzKdHS+XES2XCy6pDSy3Bym3AySxAR2pBxadKyinPTm1OzezLyqjGSWTHS6ZFy+ZCyyVCS2dDy61Dyq1CSOtBRqjExqZKyilOzaxLymhDyeTCSuVByyZCS6hDS2vDSatCx2lCxabIR+dBSKTByeZCSmhCymnCyanCR6hNTCrOTOpLyedCxmVCR+bCR2bCRmZExqbMy+pOTStKSelKyejMSynLyqlLymfLyifAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAjqAAEIBBCgoEGDAxMGEMCQ4YAABAIkFLiwgMUCBg4UiJgQQQIFCxg0sOjgwUYIAiNImEChgoULGApkcHBAA8oNHDhI6ODhA4gQIkaQGFACgokTKFKoWGGBRQsXLwQIHQABRgwZM2jUsHEDRw4dA3bw6AHBxw8ZQIIIGUKESBEjR3YgIZtEyRImTZw8gRJFyhQqVaxcgYAli5YtXJx08fIFTBgxVsaQQVnGzBk0TtKoWcOmzZExklECcPMGThw5czqLoYOijh3RAO7gyaNnTxsxfOr0cQ2boBg/f44AChRI0KDXCiEoX84cgp+AACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+core-16:mimetypes mimetypes16 16:photo:16 16:R0lGODlhEAAQAIYAAASC/PzuBFxaVNza3Ly2tJyanPyuBPQCBPz+/Ozq7GxqbFRSVHx6dKSmpHRybMzOzDQyNGRiZHRydHx2fExKRCwqLPTy9ISGhERCRCwuLERGTIyOjBQSFGReXJSSlFRSTDQ2NAwKDNze3OTi3Ly2rFxaXAQCBFxeXMzKxOzm3LyqlDw6NCQiJFROTLy2pDw+PGRiXMS2pOzi1CwqJBwaHAwODAQGDJSOhOzWvLymhKSajNTGrJyWhOTOpLSyrKymlKSelMS+rLyidMTCtMS6tMS6pMSynLyedAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAfVgAAAAQAChoeHgoqCAgOOjgQCBQKCBoMABwMImwgJCggFC4sGDAQNDZoIDg+gEAcABhESEwoUFQsWFw4KGBmCGhsFGwoLEBwYCRYEFxCEHRceFwofIBwhDSIjJBCCCxISDiUaGRwmJygpKr4AGAIl4issISYtLuncgi8YLxAs5SYwYshQgQ8AixksaNSwYYLDDRc4chS0USMEQxMhHOjYEbEggBUWTQhwwANiD4mLBPj4AYTHjyA9cPQQsq7bkCFEihhRkSPHkSMeBUDIAGFo0aMZ/AQCACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+deb-16:mimetypes mimetypes16 16:photo:16 16:R0lGODlhEAAQAIUAAASC/FxaXNza3Nze3Ly2rJyanPz+/Ozu7GxqbPz6/JwCBMw+PMQCBLQCBNx6fPT29GxubMzOzIyKhDQyNLwqLLRWVLxaXNyurERCRMzKxOzq5Ozq7MQ2NMRmZLwCDOTi3Ly2tMReXOS2tMTCvPTu5Ozm3LyulMSSlNTOxPTq3Ozi1OSytPTm1OzezLyqjNyqpLxaVNzSxOzaxPTy9Ozm1OzexOzavLymhOzWvOTOpOTStLyidMyShMSulLyifLyedCH5BAEAAAAALAAAAAAQABAAAAa0QIAQECgajcNkQDAYCASEQCGQFC4NWMMBkZhWFQtGw/EwQCIGyWSoaFAqFgblIkEgMGthQ5HRbAQcFAcaBGp6DQEJCx0XFx4ZGx8geQ1ECyECByIMIyQlJnkMRBwnBwYODSgpKqB6RCIcK6gEKiwtLpQKiS8WMAQxKi0yuEOICTM0LSo0NTY2N3kAbhoHBzQ0zjg50EkKHC80LCo2ODo5O9FEBCE8Pe49Pj8/6QET9vf4E35BACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+document2-16:mimetypes mimetypes16 16:photo:16 16:R0lGODlhEAAQAIUAAPwCBFxaXNze3Ly2rJSWjPz+/Ozq7GxqbJyanPT29HRydMzOzDQyNIyKjERCROTi3Pz69PTy7Pzy7PTu5Ozm3LyqlJyWlJSSjJSOhOzi1LyulPz27PTq3PTm1OzezLyqjIyKhJSKfOzaxPz29OzizLyidIyGdIyCdOTOpLymhOzavOTStMTCtMS+rMS6pMSynMSulLyedAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAaQQIAQECgajcNkQMBkDgKEQFK4LFgLhkMBIVUKroWEYlEgMLxbBKLQUBwc52HgAQ4LBo049atWQyIPA3pEdFcQEhMUFYNVagQWFxgZGoxfYRsTHB0eH5UJCJAYICEinUoPIxIcHCQkIiIllQYEGCEhJicoKYwPmiQeKisrKLFKLCwtLi8wHyUlMYwM0tPUDH5BACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+document-16:mimetypes mimetypes16 16:photo:16 16:R0lGODlhEAAQAIUAAPwCBFxaXNze3Ly2rJyanPz+/Ozq7GxqbPz69HRydMzOzDQyNIyKhERCRFQ6LJSKfNTOxJSOhPT29PTy7PTu5Ozm3LyulOzi1PTq3OzezLyqjOzavPz29Pzy7OzWvLymhOTOpOzaxOTStLyedMS+rMTCtMS6pMSynAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAaLQIAQECgajcNkQMBkDgKEQFK4LFgLhgMiOq0WCAREQrFdKAVXKyNxaJgBjgck4khLBAPGm4r+ghETeHtEfVaAFBUWg15gjReKZ4YTFBgYGRpvcQoPDggRnwwMG5hnHB2UFxcbHh+LAh0YDA+zDyCtZ5UXIRsiIiAjiyQlJCYnGhofI8BKC83Ozwt+QQAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+dvi-16:mimetypes mimetypes16 16:photo:16 16:R0lGODlhEAAQAIYAAASC/FxaXNze3Ly2pJyanKyijPz+/Ozq7GxubIx+RIRyLHRyVGxqbMzOzDQyNHxyTHRqNGxiJHRiLJySVIyKhERCRGQmLMy6ZNS+TMSuPLSePIRaNGReLHRuTPT29FxOFKymdIRmLHRiHGxKLDQuDPTy7Ly2tHQqLLwyPIxqVGw6LIx2LGRSHDwyDDwyFNTOxOzm3LyqlIQuNLy+zKSGdKSSfJRSRKSSNExKJLSmnOzi1LyulIyCZIxiPJyGLExGFOTSvOzezLyqjLyyXAQCBNzGRLyeREw+DFRONNzSvOzaxGxqVKSelJSCNEQ6DFRKFKSajMS2pNzOtOTStLyidEQ+FLSunOTOpIyKdMSulLymhLyedAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAfVgACCAAGFhoaDiQECjIwDAQQBiYIBBQUGmAcIBpGTCQqgC5gMDZwOgw8KEBESEwkGFAgMFacAFhcYGRobEBwdHgIDFKcWHwYgBiEhIiMkAyUCJg4nKCgp1SorLC0uBC8wMQ4yMzQnNTM2Nx84LTkNOjunNjY88z0+Hz8kOUBBQqdDiHQoYiREhBZHkORIouSfIAghjCiI8IHEEiYDgAApUAtAEwgfnDzBASWKFCBTqHQE8ONIFRwErFxRcuWKSkU8sBTIkSWLFi1btqwM4KCo0aMO/AQCACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+font_bitmap-16:mimetypes mimetypes16 16:photo:16 16:R0lGODlhEAAQAIYAAASC/FRWVFxaXNze3Ly2tJyanPz+/Ozq7GxubGxqbNTS1DQyNPS+vPw2NNQeHFw6PPTy9IyKjERCRPzi5PyGhHRWVOTi5PT29OTi3IyKhPza3LySlLQGBGQCBNza3Pz69PTy7MS6pKRubPy6vGQ2NKRSVIxmZPTq3LyqjLQqLHRydPxydHwCBNTSzPTu5Ozi1MSynKQCBOQ+PKwCBIReXJwCBExOTMzGtOzezOzWvEQeHLSytOR+fIxaTOzexLymhEwCBDweHNTOzPTm1LRORIQ6PJyOfOTOpOTe1OTSvLyedMTCtMS+rLyulLyifAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAe6gACCAAEChYeGg4oCA42NBAEFAYqCAQMGmAYHCAaSlJaZmAkKnQuKAQwNDg8QBhEJCRKmgwITFA4VFgYXGAQZs5UaGxwdHgYfIAMhwAAiIyQlHCYgECcnKMwpKSoKKywtLicvMMwcHDEyMjM0L+3YgzUsNgH0HCw3ODnvgjU6OwMvBvCQ0cNHjh+zOgAJIqTaECJFOhg5gvAUEmsvksBAAeOIEmYBbixhEgJGExROlHw8taCly5cL/AQCACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+font_truetype-16:mimetypes mimetypes16 16:photo:16 16:R0lGODlhEAAQAIYAAPwCBFRSTFxaXFxeXNze3Ly6vJyanPz+/Ozq7GxubHx6fCwuLDQyNIyKjKSmpPTy9PT29HRydMzOzCQmJAQCBKyqrFRSVLy+vGRiZNTS1GxqbERCRMzKzJyenOTm5JSWlLy2rIyKhMzK9KSm1Kyq3OTi3OTi5JyezBQSJExOTLy6/CwuXLy+5LyulMTC3LSytHx+7Ly2pLSyxLyqlNza3Gxq1OTWxMS6pLyqjPzy7OzexPTq3LyynOzWvLymhPTy7DQ2bOTOpGRmhERCfNzGpLyedMTCtMy+rAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAfIgACCAAECA4WHhoOLAgSOjgUBBgGLggEEB5kHCAkHBgKCCgsKBgwNDg8HEBESngwAExQVBhYXGBmZDREaGwuDHB0CHh+4qgQgIa+CBMEiIyQiJNAlIMoAJgYDJygpKisWLAMtvoIe2S4pLzArMTIBM9YHBRUeNAQ1KwU2NzjWFAwDDEDIgS+GDh39Fl3ykGMHPh46evggJ2gAgR87HAKZYSOID2uECGQUMkRIAiJBioAUYMTIkRs8cODwUUSlQgY4GSzQuVOnn0AAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+font_type1-16:mimetypes mimetypes16 16:photo:16 16:R0lGODlhEAAQAIYAAASC/FxaXNze3Ly2rJyanExKRPz+/Ozq7GRmZPz6/HRydMzOzDQyNJRmZPSmpIQuLGwWFKxeXPTy7IyKhNxSVGxCRLy6vPQ+PPT29GQ2LPTCxOROTPz69KQ2NPSGhPTq3Ozm5LyqlGwODPxiZOzi1LyulLwKDORydBQSDOx+fNw+PNS2tOzi3PTm1OzezLyqjNQaHPRubJx+fMS6rOzizOzaxMwuLKQWFHRaXOQuLJSShNzOvOzavOzWvLymfCwiHHx6dOzexOTOpOTStLyedMTCtMS+rMS6pMSulLymhAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAfFgACCAAGFhoaDiQECjIwDAQQBiYIFAgaXBgcIBgQFk4uYBgkKC5wMiQ0ODxAOERITCggFp4MUFRYCFxUCGAIDE7QAFBkWCRobChIcEr60HR0IHAYeHQQYEh8gIbQbIgjGIw8WEtgkJacmJyjfKSoFKywfLS4vpzAxEAgnHSYyJjMkaNSoB0CEChs3cMjIYULHDho8evig9aPiAQFAHAap0UPIREXYPpAIEnGIECLBABQoYmTGESRIfCQhglIRg5s4czLwEwgAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+gf-16:mimetypes mimetypes16 16:photo:16 16:R0lGODlhEAAQAIMAAPz+BFxaXDQyNAQCBMTCxPz+/ISChKSipERCBMTC/Pz+xPzerMQCBAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAARwEEgQahVijMmD/oRAbBw1FCgaFFrppeo5UtILWxlAGNWZHocA4bAxGAnDg9GA8LQCxGTQoHwVNYYEMEHtKYrEA0tctVIOo0Fl2Ct8AQLlKMnzLFg1KIHBCGoUbiR5VSd3C28TThpubgqIEhkfkh9+EQAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+html-16:mimetypes mimetypes16 16:photo:16 16:R0lGODlhEAAQAIYAAPwCBFRaVNze3Ly2tJyanPz+/Ozq7GxqbDxinBw+ZERmdIySjMzOzPT29DQyNDRurIR2RPTSdJyulFSGxLzCxIyKjHRydERCRLzKvPzivPTmxNTChLSybGyCfCRSpBQqRLy6vPTy7OTi3IyKhCRShOTixPzy5OzerOTShLyaVEx6nCxerGRyhOzi1LSyrEyGvOzaxPTShNy6bEx6rDxyzDRitCRCfPTq3LyulBw2VISq3GySrPTWlHyanIyitEyO1ER6zBxCfLSqnCQ6XHSq3GyWvFyGvDxuvLSqpPTm1OzezLyqjCxajFyO1GSi3NS2bKyaTCQuPGRufOzexLSmlER2vKyWNFxaNHx6dLyunOzWvLymfERSVExKNDRCNKyilMy+pOTOpLyifFxaVLyidMSynMSulLyedAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAfYgACCAAGFhoaDiQECjIwDAQQBiYKLBZYFBgcFkZMICQoLlwcMDQQOgg8QERITnhQFFRYHF6cPGBkaGxwdHh8gISIDI6ckJSYnKCkqKwksAiEtLg4kLzAhMTIzNDU2HxQ3NzgOOTo7PD0+P0A1QR8uNy1CDkMvREUyRjNHHjkfSElKlpxi0sTJjydQAiSIIkXIFBhUTn14UIWGFQhXHHzAkgWGli2nAHxIwIRLFy8bv4DREkZMSEEfYo4hQAVMGJZkXhIaIERImTJmlogRc0ZnAAdIkyp14CcQACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+image-16:mimetypes mimetypes16 16:photo:16 16:R0lGODlhEAAQAIYAAPz+BFxaXNze3Nza3Nza1LS2tJyanPz+/PTu5GRqZOTi3HRydMzOzDQyNJQOFDxKfKTW5OTy/OT23MTaxISKhGxmZERCRCwuLJQSFPzGpLweHJTO3ESu3DRilNz61FymXCxKRMTCxPTy7Ly2rIyKhDwCBORiRKQWFEy23CyKvJTWhDSOPCRONDQaHNROPNQ2JLRubHTC5DR6rHR+jFSqRCRyLGxqbOzm3LyulCwqLMySjMQ2JMyqrERijJSenFSGXGRmXMS6tPTq3Ozi1MS+vMxCNKyqrHR2dPTm1OzezOSKfNTe5KSmpIyGjLy2pOzWvLyqjIRqZIyKjHR2fExKTHx2bLyynOzexLymhERGRGRmZKSWhMS6pOTOpLyedMTCtMS6rMSulLymfAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAfcgACCAAGFhoaDiQECAwICBAUBBgGJggEEB5kHCAkHk5UBCpqZCwyeDYIOAA8QERITmRQLFRYXABgZGhscHR4fICEiAiMkDSUmJicoKQ8qKywLAwgKIxctLi8wMTIzNDUJNiEINzgNOTo7PBA9Pj/QQEFCQzg5F0RFEQQ+RhRHswVIkpS7oEMJgiUhCjBpcqSCkyFPoNjKEYVJCCNSpgSgUsXKlSdYUAG4kCOLlgpAgFTZwuVJFyy2Bi0gEsSJzZYuvYi09OULGC44wmAR48VLDkU5zClt0OACUz+BAAAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+info-16:mimetypes mimetypes16 16:photo:16 16:R0lGODlhEAAQAIYAAPwCBFxaXNze3Ly2rJyanDROXHSSpISetPz+/Nzm7GxqbGyGnMTS3MzW3JyuvERujLzG1HRydMzOzPT29DQyNMze5Iy2zLTS3Cx+pCRijLS+zIyKhGxubERCRFR6lGSivFyavISuxAxajBRejAxGdDxihJyyvCR6pBRqnAxelAxOfPTu5OTi3IyqvFSOtJy+1IyyzFxyhOzm3LyqlGySrAxejAQ6ZFxqfMzKxPTq3Ozi1LyulCxulAQuVISKjMzGvPTm1OzezLyqjBwmLBROdExOTKSinNTOvOzexBQeLAw2XAQmTCwyPLy2pOzaxOTWxLyedCQmJAQKFAQWJKSalOzavOzWvOTOpLymhKyqpMS+rOTStMSulLymfLyidAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAfVgACCAAGFhoaDiQECjIwDAQQBiYIFBgcImAkKCJGJCwwNDg8QmBESEwQUgg4VFhcYGBkaCBsRHB2qHgwfIAghIiMkAhMCAxsUJSYhJygiKc4qCysrLAPILS4oLwgwKcExEisyMxQFNBg1Nb7ONjc4OTo7yAU8IiIIDiIqPT4/QEFCVA0hooJBAg0eehQxciQIEnKCktiYqGQJEwJNnCB5AkWVoChSpkwpQmXAkypWrmDxKAhSlixaTlrZcqWjIi0/BmjhsgNLFy82BwWgQDQK0aNE/QQCACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+kmultiple-16:mimetypes mimetypes16 16:photo:16 16:R0lGODlhEAAQAIMAAPwCBFxaXPz+/AQCBISChPz+xMTCxPzerKSipAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAARWEIRJgb04iLEJwaAmjMTwgVbAjeaESmNcGMGrxmOhDqE8HAOVJ7MSFH4qhOmiOQIPNIGB4JJwnIaDaFaTUL4iYxc0MJidQVvROc4Yfz+a+g3V2sAVfwQAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+log-16:mimetypes mimetypes16 16:photo:16 16:R0lGODlhEAAQAIYAAPwCBFxaXNze3Ly2rJyanPz+/OTm5GxqbMTCxARiTARSPARCNAQ6LAQyJGx+fGxubMzOzDQyNCxGPARyVARqTARaRLSyBCRGHFRuZIyKhERCRDRuXAx+ZPz+BIyOBFRybOTi3AyGbAx2XExaDBROLOzm3PTy7DRORDyeXBx2VEymVHyuJGRyDPTu5LyqlFyGTBxaNAxqVDR6PARKNPTq3Ozi1LyulCRuTCxeNBSCZDxmJEx6bOzWvPTm1OzezLyqjCSSdCSmhBySdBR+ZARqVEx+bNzSxOzizESCdAQCBNzOvOzexLymhOTStOTOpMS6pLyedMS+rAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAfIgACCAAGFhoaDiQECjIwDAQQBiYKLBZYFBgcFkYIICQkKCgsLDA0ODxCbEQASExQJFRYXpBgZDwcaqxscrgkdHqMfBiADGasIIRwiHSMdJB0YJSYCA6snKCkqFgorHSwdIC0lLqsvvx0wMTIWMxgCNDU2xzcdOBw5EzoKOzw9Pj/WgAQRIiTEkAlEihg5wgMgACRBkpwQIpGDRCVLeDCJACGJx48gAzRxspHQoZNPRkJZNSjAkygDntiwwYQJlJWKIujcyTOCn0AAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+make-16:mimetypes mimetypes16 16:photo:16 16:R0lGODlhEAAQAIYAAPwCBFxWVFxaVOTi3Nza3LS2tJyalGRmZMTCxPTy9Pz69Pz+/Ozq7GxubJyWnFRWVHx6fHRydMzKzDQyNHx2bHx+dIyKjERCRGRiZKyilLSifMTCtLy+tISGhOS2bPzerPzuvOzetJSSjFxaXOzu7PTy7MS6pGxqbKSWdPS+dMSidOTerPzqtISCfKyurOzq5LSqnMzKxPS6ZEw6HJSKbOTStHR2dMzGvPTq3OzizLyulFRSTOyyVNymXOy+dKyqpPTm1OzezLyqjJyCTOSqTOSmRLSupNzSxOzaxOzexOzWvOTOpKyinMS6rNTGrLyedMSynAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAfagACCAAEChoeGg4oCAwQEjQUCBgGKggcICQoKCwwNCg4CiwQPCBAFmRESCwYTghQCEgYHDBUSChYNDRetGAQZGhscHAIFDAoDHB2tAQYeHyAhIiMIJAolBCYTAicoKSorLBItGC4DLy8wExExKjIzNB81CBI2Nzg5Oq07KDw9Ph4mdgj4IQFIECGtHrgYQqRIjQoPjBzJkQMJQgANkrngYGFAhB8UkyjR0EpQAAkUKkQQkCGHEiVLLg6y8IDJhiZOXsJ8UtLkhpsmoAgRouIJT0UPJihdynSCn0AAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+man-16:mimetypes mimetypes16 16:photo:16 16:R0lGODlhEAAQAIYAAPwCBFxaXFRWVNze3OTi3Ly2tJyanNza1Pz+/Ozq7GxubMzOzDQyNOzq5KSmpNTS1IyKjGxqbERCRPTy7PT29LSytOTi5MTCvMTCxLy6vMS6rISChLy+vPz69HR2dLSyrLy2rNTW1IyOjOzu7OTm5HRybHx2ZNTOxLyulLS2tIyKhHRuVMS+tHx6fGRmZLyqjISGhJyenMTCtGxqZGxmVMS2pFxeZGxiTMSynLymhHx6dGRiZFxeXFRSVLyifGxmTKSSfLyidMS+rLyedAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAfDgACCAAEChYeGg4oBAwMEjQUCBgGKggEHCJkICQoIBgKKkgSamQoLngyWDQ4PpAgQChESqQACExQVFgkXGA8ZBBobtAENDQsGHB0dEx4fBCC0AhYhGCIjFA0kJSYnKMMPHCkqFg0DIQorLN6WCx8OLQsHIQsuKxovtIQwMR4ZHDIYZtCogU+RjQAeUmDAkELBDRw58hHSsWMDjx4XV6DwIZGYCRc/aNz4AeRFkI4sZAipgePFCx9BhkgUwKCmzZsM/AQCACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+metafont-16:mimetypes mimetypes16 16:photo:16 16:R0lGODlhEAAQAIYAAPwCBFxaXNze3Ly2rJSWlPz+/Ozq7GxqbKSajPT29GxubNTS1DQyNIyKjERCROzi5Ly+vKyqrKSipKSmpKyurISChKyinHRybISGhGRiXJyanIyOjFxeXJyenJSSjMzGxMzOzMTGxLS2tISGjExOTLyulMTCxISWpGx6jExifFxufJyepJymrFRSVLSupLyqjERKROza1OTKzNS6vGRmZLy6vPz29Hx6dMTCvHRydJSKfOTStLymhNTCxLSOjKx6fMS6pLyifLSytHx+fOzWvOTOpLyedMSulLyidAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAfDgACCAAGFhoaDiQECjIwDAQQBiYKLBZYFBgcFCJKKApcFCQoLBQQMnqAFDQoHDqeDAQ8QERITBhQVFhWnF4IVsxgKGRobHB0DrxUeHyAhIiMeGCQVFCWvACYCJygWKSoTFxcD1oMJGissJiwjFC0ZLi+nMBoLMTIPFDMzDS00FvEAYlyQUMNGiBs4OuQgoWMHj2sDe/j44aNCBh1AdgS5BoCGBhNChlxAQGRHESMcYXCI5sHCkRdIkKBUxKCmzZsM/AQCACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+midi-16:mimetypes mimetypes16 16:photo:16 16:R0lGODlhEAAQAIUAAPwCBFxaXNze3Nza3Ly2tJyanPz69Pz+/ISChOzm3GxqbKSipAQCBHRydMzOzDQyNIyKhERCRPT29OTi3PTu5PTy7LyqjOzi1OzezOzWvLyidOzaxOTOpMS6pMSynLymhLyedAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAaOQIAQECgajcOjUTAYEAKFgDBgOFQNiMHhkFAYosQFg2HNbg0Nx/dB3W7NW0hDEWEjxm+BWzIhINhVbnBUFH12eAeDFRQUFoBuiVoGRRQXjgGQiQQLCwELBZaHZJGMARgLGZeZCARRUKgaom8DCAEZGwscqm5YrZyfHLFKRQQdHhYWHxogD0NED9DR0g9+QQAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+mime_empty-16:mimetypes mimetypes16 16:photo:16 16:R0lGODlhEAAQAIUAAPwCBFxaXNze3Ly2rJyanPz+/Ozq7GxqbPz69HRydMzOzDQyNIyKhERCRPT29PTy7Pzy7PTu5Ozm3LyulPTq3Ozi1PTm1OzezLyqjOzexOzavPz29OzWvLymhOzizOTOpOTStLyedMS+rMTCtMSynLymfAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAaBQIAQECgajcNkQMBkDgKEQFK4LFgLhgMiOq1eEQnFdqEUXK2MxKFBHnqvDsGA0aaaz4iHvE68WxEQERITfG+ADxQVhGV/DxEWFBcYhQIIgBEUFBkak2UbgYkZHBwdlIgUHh4aHB+lZZkVF6sgHyGFIiMiAyQYGCUhtkoLw8TFC35BACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+misc_doc-16:mimetypes mimetypes16 16:photo:16 16:R0lGODlhEAAQAIYAAPwCBFRSVFxaXFxeXFRWVOTi3NzW1Nze3Ly2rJyanPz+/Ozq7GxqbMzOzDQyNHRydExKRERGRExKTERCRCQiJIyKjCwuLGxubDw+PDw6PDQ2NBweHAQCBPT29IyKhNz+3HzmfDTCNASaBBxaHCQmJPz69PTu5JTqlGTOZCSmJAR+BBxSHOzm3LyqlFTKVASCBARmBBxGHNTSzPTq3Ozi1MSynAyeDAROBCQ+JBQSFNTOxPTm1OzezLyqjCwuNAQyBCQ2JMzGtOzexAwODOzaxOzWvLymhMzCrOTOpNTKvMS+rLyifMTCtLyulLyedAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAfcgACCAAECAwQCiIiDjAMFBgeRCAMJAYyCAQUKmwoLDAoJA5eZnJsMDaAOAA8BEBESExETFAsVDwwTFgAXAhgOGBkaGhscHQUIHqoDAR8gISIjJBQGJSbHugMSJygpKisU0x0mLC2qAhEuKS8wMRsbMiYzNDW6ARM26zc4ORQ6Mzs8evgAACGDChg3fgDhF6SAECE9VEXQYKGiDwtDKAQRQqSIEV25KGzIQZIDhSNFiiAxomoQAwM6kgRRgiQlkiW6BgVIwkQJghpNeixx4qQlJiAWHCh1kFSpBT+BAAAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+netscape_doc-16:mimetypes mimetypes16 16:photo:16 16:R0lGODlhEAAQAIYAAPwCBFxaXNTW1Nze3Ly2rJyanPz+/Ozq7GxubPz6/OTi1Ozq3GxiTMzOzCwuLMSijGROLLSqjGRiZOze1LSOdIyKjEw+NHxGJNSqjMTGxPTy7Ozm1NzWxLSSfFw+LMzKvHRuVKyeZHxybOTazOTi3Ly2tDQyNOzm3MS6jFxaRPTu5LyulOzi1KSehMTCxKSOdHxuRMzCpJSGXOTStLyqlHRqRIR2TFRKLLyedLyqdGxWLIR6XOzezJyCZJySbEQqHKyKdFRONJSKfOzaxNTCpKSWbJSSjExKNHxuNOzWvLymhIyKhOTOpHRydHx6bIR+dOTOrLyidAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAfVgACCAAGFhoaDiQECA40CBAEFAYmCAQMGmAYHCAmSlAEKCwyZCA2dDoIPEIsREgkTFBUICBaoABcYGRobHAodHhkDBBW2AB8fIBwMESEiIxokJSaDJxAUKAwQESkaKicrqBssLS4vBzAfMTIRMwo00zU2LTc4OToQOzU3DDwr04Ixeljw8QNIiCBCYgyJUIxIESMfjuxAwoDDkCRK/j244CNHjhBIPDxYMoPJA1sXIDRxkuOIkycXHsyAEqUYoRk7GDAh8uJFDhw4/lUy4aCo0aJE/QQCACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+news-16:mimetypes mimetypes16 16:photo:16 16:R0lGODlhEAAQAIMAAASC/AQCBERCBPz+/FxaXIQCBMQCBMTCxISChKSipDQyNAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAARXEEgZwrxYikFsvtUwBN0nEWIhkh4YiIOhjiX1hqIsHlb4jr8VwoJa/XCCBG4ZZA2bRxEi0QkgeLAloUZKYGEDhLgG6H5JBEFrYg4ItmsMCaGomFyEiz8CACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+pdf-16:mimetypes mimetypes16 16:photo:16 16:R0lGODlhEAAQAIYAAASC/FxaXNze3Nza3LyypJSSlPz+/Pz69Pzq5Ozq7GxqbJyanNyGhNx6dGxubMzOzDQyNERCRPz6/My+vLxaVJxeXKSmpNTGxIyKjNTS1OTi5OzCxLRSVMTCxKyWjOTi3Ly2tIyKhLxmZLSWlOTe3MzKzOza3MyytNyOjAQCBKyqrOzm3LyulPSajMRWXOSGhOyGhKxiXOzi1OxyXKRORIxSTNTKzMy6vLyenLRubLwqLMxiZNSurJRybOzezLyqjJxCRGxSTLy6vGQiJMw+LJR+dMzCrOzaxIyOjKyurHxydNxWPNTCrOTStLymhIR2dKyKhIxuZIR+dJyShOTOpHRmZKSKhJyCdKyilMSulNTCpLyedMS+rMS6pLyidAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAfQgACCAAGFhoaDiQECAwKMBAEFAYmCAQMGBwgHCQoGC5OKAgYMDZcODwYFEIkREhMUFRYXGA4OEauCGRkaGxwZHR4ZHyAhuAAdCQgiFR8aHSMkHwS4JRomIicoJykqHh0rLKstLhQcFC8wMR0FHgQy4TM0HDU2Nzg5Ojs8PQQ+P6tAggjRVaLEjiFEihg58k+QBSQdQCTpoITIkhBMmjgxVsBCxydQokiZYoTKxkRVrFy5EgJLFi1NqGwxRohLBy5dsmT54cXLTEUQggodCsFPIAAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+pk-16:mimetypes mimetypes16 16:photo:16 16:R0lGODlhEAAQAIMAAASC/IQChFxaXDQyNAQCBPzC/MTCxMQCxPz+/ISChKSipERCBMTC/Pz+xPzerMQCBCH5BAEAAAAALAAAAAAQABAAAAR6EIAQhLVjECJlKISwjcZgcFNxhATiugKyTaP4wu0JiOyNXBqAIWFpvRQKgUHBSTgNS4UzseBxBMxoMiG1NTcJBpLBLTaaTIVM3fXuFKeQMmk7AwbSU5QocsgkFnAPD0kbFBQdO1hELQ4fK4lWLQ0IASsoEhojIwEjfhEAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+postscript-16:mimetypes mimetypes16 16:photo:16 16:R0lGODlhEAAQAIYAAPwCBFxWVFRWVFxaXOTi3Nze3LS2tKSajPT29Pz+/Ozq7GxqbJyanISChPz6/HRydNTS1CwqLMTCxISGhOzu7ERCRDQyNERGRLy2rIyKhExOTAQCBKyqrOTm5KSmpHR2dNza3AQGBNzSxOzm3LyulBweHBQSFKSilOzaxAwKDOzezDw6PJSSlDw+PKSelNzOvLymhAwODNzGrOTStLyqjExKRHRqZLymfMTCvMS+tMS6rLyynMS6pOTOpLyifMTCtMS+rMS2pMSynLyidLyedAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAfPgACCAAECA4aIA4OLAgSOBQQGAgcBi4KNCAmaCgsJDAKWjQkNCA4JDxCeEYwSDQ4TFKMPCxUWAA0BEQ0GDggQDxcIBBgZthobExwICB0eFRsSHcOrER8QCwYIIA8bIRwiIyS2JSYVHgsQzhsbJygEJKsl6ykeH9zrJyIq4gAp6xsrWLT45+IFChi2YqwLwcLEvxgHZMygsarBOgsCBGioUcNGxBk3bA0SgCOHjh0oeczo4WPVoAA/fgAJIoQGjSFEiIgUNCCCBZ8Wggq14CcQACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+readme-16:mimetypes mimetypes16 16:photo:16 16:R0lGODlhEAAQAIYAAPwCBFxaXNze3Ly2rJyanDROXHSSpISetPz+/Nzm7GxqbGyGnMTS3MzW3JyuvERujLzG1HRydMzOzPT29DQyNMze5Iy2zLTS3Cx+pCRijLS+zIyKhGxubERCRFR6lGSivFyavISuxAxajBRejAxGdDxihJyyvCR6pBRqnAxelAxOfPTu5OTi3IyqvFSOtJy+1IyyzFxyhOzm3LyqlGySrAxejAQ6ZFxqfMzKxPTq3Ozi1LyulCxulAQuVISKjMzGvPTm1OzezLyqjBwmLBROdExOTKSinNTOvOzexBQeLAw2XAQmTCwyPLy2pOzaxOTWxLyedCQmJAQKFAQWJKSalOzavOzWvOTOpLymhKyqpMS+rOTStMSulLymfLyidAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAfVgACCAAGFhoaDiQECjIwDAQQBiYIFBgcImAkKCJGJCwwNDg8QmBESEwQUgg4VFhcYGBkaCBsRHB2qHgwfIAghIiMkAhMCAxsUJSYhJygiKc4qCysrLAPILS4oLwgwKcExEisyMxQFNBg1Nb7ONjc4OTo7yAU8IiIIDiIqPT4/QEFCVA0hooJBAg0eehQxciQIEnKCktiYqGQJEwJNnCB5AkWVoChSpkwpQmXAkypWrmDxKAhSlixaTlrZcqWjIi0/BmjhsgNLFy82BwWgQDQK0aNE/QQCACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+recycled-16:mimetypes mimetypes16 16:photo:16 16:R0lGODlhEAAQAIYAAPwCBFxaXNze3Ly2rJyanGRmZKyqrMTGxPz+/Ozq7KSinOTi3LzatLTGpJSSlMzKzGxubMzWzPT29DQyNMS+rOTy5KzWlEymLDSSDKTClIyKjGxqbERCRGx+bNzu1Hy+ZESeHDSWDCyKDCyGFMTKxHx6fOTi5ISCfFRuVKzGnJzKjDSOFJy2lNTSzJSSjPTy7Ozm3FR6RJzChGSqRFSePHyqdMzOzLSytNTOvLyulExyREyWPESSJMS+vKyurMzKxPTq3Ozi1BxeDDSCHNTS1Ly+vHx+dIyOfPTm1OzezLyqjBw6FBxmDFSKRMzGxERONOzavBQ6DBROBHSOdCxeLDRCJKSelOzexOzWvLymfCw6LBxGHFRiTOTOpERGRKyqpMy+rLyedMTCtLy2pMSynMSulAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAfWgACCAAGFhoaDiQECjIwDAQQBiYIFBgcImAkFCJGJCgsMDQ4PmBAREgQTghQVFhcYGZYIGhAbHKodHh8gISIjJCUCEiYDJxMoKSogGCsjLC0GLgkvMAMTMTIzIjQ1LDYHNxo4CTA5Ezo7PDstEQ8HPT4nP0BB5jpCQxFE7kU3RkcHkCRRomoJkyYHnBQZ0OEJARxJoBAUFEWKjilUolSxMiDJFSxZVAnSEmVLFC4EBnzE0iVkIi8EvnwBs5JlGJGCAogRQ2EMmTJZsoS5qWiC0aNIJ/gJBAAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+resource-16:mimetypes mimetypes16 16:photo:16 16:R0lGODlhEAAQAIYAAPwCBFRSVFxaXFxeXFRWVOTi3NzW1Nze3Ly2rJyanPz+/Ozq7GxqbMzOzDQyNHRydExKRERGRExKTERCRCQiJIyKjCwuLGxubDw+PDw6PDQ2NBweHAQCBPT29IyKhNz+3HzmfDTCNASaBBxaHCQmJPz69PTu5JTqlGTOZCSmJAR+BBxSHOzm3LyqlFTKVASCBARmBBxGHNTSzPTq3Ozi1MSynAyeDAROBCQ+JBQSFNTOxPTm1OzezLyqjCwuNAQyBCQ2JMzGtOzexAwODOzaxOzWvLymhMzCrOTOpNTKvMS+rLyifMTCtLyulLyedAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAfcgACCAAECAwQCiIiDjAMFBgeRCAMJAYyCAQUKmwoLDAoJA5eZnJsMDaAOAA8BEBESExETFAsVDwwTFgAXAhgOGBkaGhscHQUIHqoDAR8gISIjJBQGJSbHugMSJygpKisU0x0mLC2qAhEuKS8wMRsbMiYzNDW6ARM26zc4ORQ6Mzs8evgAACGDChg3fgDhF6SAECE9VEXQYKGiDwtDKAQRQqSIEV25KGzIQZIDhSNFiiAxomoQAwM6kgRRgiQlkiW6BgVIwkQJghpNeixx4qQlJiAWHCh1kFSpBT+BAAAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+rpm-16:mimetypes mimetypes16 16:photo:16 16:R0lGODlhEAAQAIUAAASC/FRaVNze3Ly2tJyanFRSVOTi3PT29Pz+/Ozq7GxqbFxaXHRydNzazDQyNIyKjERCRGRmZExOTLyipOSytLy6vIyCfBweHMzOzNS+vMRqZMRSTNzGxAQCBLxCPMzGvLyulCQmJPz69IxKRIwWFLSGfLyynAwODERGRMTGxGRiXLyqjHR6dIyOjBQWFLSqnNTCpNTKtLyidPTm1OzezOzavOzWvOTOpMTCtMy+rMSynLymfLyedAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAazQIAQECgajcNkQMBkDgKEQFJYMBwQ2ITiEJ0uDFjsgdHgOpIFQRj7UCggZyEksIgoJBPKwVCxnBUXEgwYBgkGGRobHAYDDgUdFx1fawceHh8gDiEdnEthIgcjJCUmDh0nKJwdCCmcKh0WJiumQh0sFR0tFyYuLycwK5u1nBYsFwMuJicTs0MdEhUpDRkxMRkwMDJxQl8zBjM0NTY3N9poKTg5JjorKzsyPNtEDvT19CH0fkEAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+shellscript2-16:mimetypes mimetypes16 16:photo:16 16:R0lGODlhEAAQAIYAAPwCBFxaXNze3LyypJyanPz+/Ozq7GxqbPT29HRydMzOzPz69DQyNHRaJKyONJR2LJyCJKyCHKSCHMSqZNTOvIyKjGxubERCRGxSFIxyRKR+HMyeHOTCLMSOHLyWFMzGtIyKhHx2bKSGZNyiFHxeDOTi3Ly2rMyudOTCpOTKxLyqjJR2VJxuDLSGHLSunPTu5Ozm3LyulJx6NNSyXOTCjOzWvPzi3MyqhGxSLFQ2DLSKLNSqTPTWtPzq7NS2nIxyVIx6ZOzezFxCFOy2POSyROTGlPTazPTWxLSiZLSSVMy+rOzaxKyCJMyeNOSyTNy+dLymXLyePNyqPKSWfOTStLymfKR6HMyaPMyaNJR6TMy6pFxKLHxWFKR2FIxiDOTOpLyedMTCtIyCbMSulAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAfQgACCAAGFhoaDiQECjIwDAQQBiYKLBZYFBgcFkZOVlwgJCgsEDIINDg8QERITFAUVFgcXpYIYGRobHB0eHwgCAyC0giEiIg8bIyQCCCUmtCInKCkpKissLS4vMDGlMjM0NQsINjc4OQ0U26U6OzQ8CAg9Pj8uQBRBKgxCQ0QzRUY2jiDRkURJkCX5ADBp4uQJjRNQokhpMSUIlSqlcFjpQOQKESlYWmTRQuUirS1cumy04qWBlhpUvoARRihMGDFaBoxRUQXMTEUMggodysBPIAAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+shellscript-16:mimetypes mimetypes16 16:photo:16 16:R0lGODlhEAAQAIYAAPwCBFRWVFxaXNza3OTi3Nze3Ly2tJyanPz+/Ozq7GxubNzSxMzOzMTGxHRybDQyNLy+vHRydHx6fKSipISChIyKjGxqbERCRCwuLLy6vGRiZExKTCQiJAwKDLSytLy2rJSSlHx+fDw6PKyqrBQWFPTu5Ozm3LyulLS2tCQmJAQCBPTq3Ozi1MSynCwqLAQGBOTazOzizOzezLyqjBweHNzSvOzaxKyurHRuZNzOtLymhDw+PIyCdOzWvOTOpLyidNzKtOTStLyifMTCtMS+rLyedAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAfZgACCAAEChYeGg4oCAwQFjgYBBwGKggEECJkICQoIkwADCwwNDY2mDA4Lng8QDhESsLARExQVDhYXGBkWExIaGw8cHR4SCQQfFQ8eFgUgIQEiwiMSBMYfGB4atwEXDyQd0wQlJicPKAHoFyIpJCoeDgMrLC0YKBsX6i4kL+4OMDEyZijr5oLGNxUqUCioEcPGDAwjPNyI6MEDChQjcOSwsUDHgw07RIgI4KCkAgs8cvTw8eOBogAxQtXIASTISiEuBwUYMoRIixYnZggpUgTDywdIkWJIitRPIAAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+sound-16:mimetypes mimetypes16 16:photo:16 16:R0lGODlhEAAQAIYAAPwCBFxaXFRWVExSVNze3Ozi1Ly2rJSWlPz+/Gx6dNTS1Ozq7GxubGxqbDRmbDQyNFRiXBy6xFRmZLy6vIyKjERCRAQ+RBy2xByqtHRydIyOjPT29PTy9OTi3ISGhAQ2PATC1ByGlPz6/MS2pAS2xHS2vMTCxJyenLS2tPTq3Ozm3LSmnAQaHARibARudAR2hEySnOTm5MzGvLyulARKTARWXDyCjOzaxAQiJEx+hNza3MzCtOzexOzavLymhBQuNCxqdLy+vKSelOzWvLymfDxOVISipAQCBNzOtOTOpFRybKSejMS6pOTStLyedMS+rAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAfLgACCAAEChYeGg4oDBAUEjwYBBwGKggEICQkKCAsMCJOVAw0OA4wIDZsHD4oQERINDRMIFA0MFauCFhcYARkJGhscHRMeuB8RICEQHgcaBCIcBSOrHyTWJSYnKB4KHCkqK6ssLS4vMA0LMRoyKe0zuDQ1LTYoHBwU7Ck374M4NTkmdHDIsKMAjx4+cAn6ASSIAhRCdvDgMYSIQkJFjBzJsALJjSFJLCoSUKCIkiVMegxpksTJxQATnjwZMWMGER9OXI58wLOnzwd+AgEAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+source_c-16:mimetypes mimetypes16 16:photo:16 16:R0lGODlhEAAQAIUAAPwCBFxaXNze3Ly2rJyanPz+/Ozq7GxqbIyKjMTCtPT29GxubMzOzPz69DQyNHRydERCROTi3IyKhIyOjPzy7PTu5Ozm3LyqjPz29PTq3Ozi1LyqlPTm1OzizOzWvLymhGxudGRmdFxedFRWdERKdDQ+dHR2dFxidAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAaHQIAQECgajcNkQMBkDgKEQFK4LFgLhkMhOl0iElbFgtEgOJQC8BXxOEDOw0DkGhYMJHCq4FuYJBQUEQN5RGlWYBQVFheEVWEYFRkaG40RXw2JGX6MaIiRHGCccQKAkRodHh4fjQ+tICEiIyQkJY0mJg8FJwWzJbVKD7gnI7K+v3EOycrLDn5BACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+source_cpp-16:mimetypes mimetypes16 16:photo:16 16:R0lGODlhEAAQAIUAAPwCBFxaXNze3Ly2rJyanPz+/Ozq7GxqbIyKjMTCtPT29GxubMzOzPz69DQyNHR2bERCROTi3IyKhIyOjPTy7Pz29PTq3Ozm3LyqlPTu5Ozi1LyulPzy7LyqjPTm1OzizOzWvLymhHRydHR2ZHR2XHRyTHRyRHRyPHR2dAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAaHQIAQECgajcNkQMBkDgKEQFK4LFgLhkMhOl0iElbFgtEgOJQC8BXxOEDOw0DkGhYMJHCq4FuYJBQUEQN5RGlWYBUWFxiEVWEVGRYaG40RXw0ckV8djYaZFh5gnGgKnx4fICAhjSIPrSMkJCUmJ6woBQ8FJAUlJ7VKDygPD7G9vo0OycrLDn5BACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+source_f-16:mimetypes mimetypes16 16:photo:16 16:R0lGODlhEAAQAIUAAPwCBFxaXNze3Ly2rJyanPz+/Ozq7GxqbIyKjMTCtPT29GxubMzOzPz69DQyNGR2ZERCROTi3IyKhIyOjPTy7PTm1LyqlPzy7PTq3LyulLyqjPTu5OzexOzWvLymhHRydHR2bFx2XFx2VFR2TEx2RHR2dFR2VAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAaHQIAQECgajcNkQMBkDgKEQFK4LFgLhkMhOl0iElbFgtEgOJQC8BXxOEDOw0DkGo4MJHCq4FuYJBQUdnlEaVZgCgYVFoNVYRcYGBEZjBFfDRePEgkajIUXGxgVYJxoCp+hHBwdHowfIK4PDyEiIyStJSUFDwUmJiS2Sq8PILG+v4wOycrLDn5BACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+source-16:mimetypes mimetypes16 16:photo:16 16:R0lGODlhEAAQAIUAAPwCBFxaXNze3Ly2rJyanPz+/Ozq7GxqbIyKjMS+rPT29GxubMzOzPz69DQyNMTCtHRydERCROTi3IyKhIyOjPzy7PTu5Ozm3LyqjPz29PTq3Ozi1MSynPz27PTm1OzizOzaxOzWvLymhLyifOzexLyedLymfAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAaJQIAQECgajcNkQMBkDgKEQFK4LFgLhkMhOl0iElbFgtEgOJSCx7WAgBwi52FAsi4oBINJnCpAqCkPChUSA3tEEmoFahUWFxiGSwphGRYaGxyQEn4NHZVfj2iLlR5qoHICGYyWHyAhIpB9Dxp+IYAjsGokaiFqJZAJDwkDHBwYJiW+Sg7LzM0OfkEAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+source_h-16:mimetypes mimetypes16 16:photo:16 16:R0lGODlhEAAQAIUAAPwCBFxaXNze3Ly2rJyanPz+/Ozq7GxubPT29IyKjMTCtMzOzDQyNHRydERCROTi3IyChIyOjPzy7Pz27PTu5Ozm3LyulPz29PTq3Ozi1Pz69LymhOzizLyqjPTm1OzWvIyGhIR6dIRubIRmZHxaVHxSTHxCPIRydIReXHxWVHxKRAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAaIQIAQECgajcNkQMBkDgKEQFK4LFgLhgMiOl0mFFbEYVEgMJQC8DXRODjOw8DjGhYMIHCq4FuIKBASDwN5RGlWYBMUFRaEVWEXFBgZjEoPXxoSkX4bjYaZGBxgHZ2AkR4cHx+cSiAJCRAhIiMkJSaNCREgBScFKCkqtkq4sLK0JsFxDMrLzAx+QQAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+source_java-16:mimetypes mimetypes16 16:photo:16 16:R0lGODlhEAAQAIYAAPwCBFRWVFxaXNza3OTi3Nze3Ly2tJyanPz+/Ozq7GxubFRWXHRydMzOzDQyLIyKjGxqbERCRCwuLHx6dKSinKymnLyyrNza1PTy9Ly2rIyKhDQyNGReXKyejKSWhIx+bJSCdIRuZCQiJISCfGxaPJSKdHxuVHReRHxiVHxeVGRGPKSajMS+tMSynAQCBFxeXGROLFxCLFxCNFw6LGxiXFxiZMTCtOzi1ERGRLSytJSWlERKTNzSxOzaxKymlOTi5JSSjISChBwaFNzGrLyqjKSmpDw+PMS+rOTStLyqlLyifGRmZKyqpLyidAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAfWgACCAAEChYeGg4oCAwQFjgYBBwGKggEECJkICQoIk5ULmJoIDA2eDoqXowgPDBAREoIRExQVFhYEBA0XGBkaGwAcHR4dHx4gIRMGDBcEFg4iIyQlJicoISkqISssBC0OLi8lMDAxMiozNDUUNjctEjg5OjklDCEcOy4OFDw9Pg4QfuQAEgTCDglCHAQYMaQHEVRFBhRhIACHAyMLIHg4guShIAg6KDwYMYHBhBVJhiBRgmrQkhxMKlBo0ULlkCYtLbGwYYNmCyJNguYk5KBoUQlGi/oJBAAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+source_l-16:mimetypes mimetypes16 16:photo:16 16:R0lGODlhEAAQAIUAAPwCBFxaXNze3Ly2rJyanPz+/Ozq7GxqbIyKjMTCtPT29GxubMzOzPz69DQyNHRydERCROTi3IyKhIyOjPzy7PTu5Ozm3LyqjPz29PTq3Ozi1LyqlPTm1OzizOzWvLymhGxudGRmdFxedFRWdERKdDQ+dHR2dFxidAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAaHQIAQECgajcNkQMBkDgKEQFK4LFgLhkMhOl0iElbFgtEgOJQC8BXxOEDOw0DkGhYMJHCq4FuYJBQUEQN5RGlWYBQVFheEVWEYFRkaG40RXw2JGX6MaIiRHGCccQKAkRodHh4fjQ+tICEiIyQkJY0mJg8FJwWzJbVKD7gnI7K+v3EOycrLDn5BACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+source_moc-16:mimetypes mimetypes16 16:photo:16 16:R0lGODlhEAAQAIQAAPz+BKSipISChERCBPz+/AQCBMTC/MTCxISC/FxaXDQyNASChARCRPzCxAQC/PzerMRaBPyCBPyqXISCBPwC/MQCxIQChATCxMT+xATCBASCBIQCBARCBPwCBMQCBMTCBCH5BAEAAAAALAAAAAAQABAAAAWOICACQRkI6DCuJOG+JysGL1wIMm0YNHEUBNwqsDMgEL5AIqEYIhZPxqtwUI0CzwRDSih4E6KGeLl1vB4FMAASkTC1icmjmxZBKBXL4YLJaAoPgWoQEBsbGX4JHHR1Ih0eChkTGoqADQ9qMwR+GhwcXlSZAAJzDQNogZeiAUBeaAcNHw2iAygocQkCuQN+IQAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+source_o-16:mimetypes mimetypes16 16:photo:16 16:R0lGODlhEAAQAIUAAPwCBFxaXNze3Ly2rJyanPz+/Ozq7GxqbIyKjMTCtPT29GxubMzOzPz69DQyNGR2ZERCROTi3IyKhIyOjPTy7PTm1LyqlPzy7PTq3LyulLyqjPTu5OzexOzWvLymhHRydHR2bFx2XFx2VFR2TEx2RHR2dFR2VAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAaHQIAQECgajcNkQMBkDgKEQFK4LFgLhkMhOl0iElbFgtEgOJQC8BXxOEDOw0DkGo4MJHCq4FuYJBQUdnlEaVZgCgYVFoNVYRcYGBEZjBFfDRePEgkajIUXGxgVYJxoCp+hHBwdHowfIK4PDyEiIyStJSUFDwUmJiS2Sq8PILG+v4wOycrLDn5BACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+source_p-16:mimetypes mimetypes16 16:photo:16 16:R0lGODlhEAAQAIMAAPwCBAQCBMTCxDQyNPz+/FxaXKSipPz+xPzerISChATCBARCBASCBAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAARVEEgQqrUz3yqGCJlUESRZEFVooWZAfJpbEkU9gNMqo4KBi7vSAfWjyFxIUnEkJAwPy9EugEDFSE+nMzojVKvLREGsKCgWjMVybDaj0eH2OZ2Objb+CAAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+source_pl-16:mimetypes mimetypes16 16:photo:16 16:R0lGODlhEAAQAIUAAPwCBFxaXNze3Ly2rJyanPz+/Ozq7GxqbIyKjMS+rPT29GxubMzOzPz69DQyNMTCtHRydERCROTi3IyKhIyOjPzy7PTu5Ozm3LyqjPz29PTq3Ozi1MSynPz27PTm1OzizOzaxOzWvLymhLyifOzexLyedLymfAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAaJQIAQECgajcNkQMBkDgKEQFK4LFgLhkMhOl0iElbFgtEgOJSCx7WAgBwi52FAsi4oBINJnCpAqCkPChUSA3tEEmoFahUWFxiGSwphGRYaGxyQEn4NHZVfj2iLlR5qoHICGYyWHyAhIpB9Dxp+IYAjsGokaiFqJZAJDwkDHBwYJiW+Sg7LzM0OfkEAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+source_py-16:mimetypes mimetypes16 16:photo:16 16:R0lGODlhEAAQAIYAAPwCBFxaXNza1Nze3Ly2rJyanPz+/Ozq7GxqbPz6/NTSzDQyNKSujIyKhHRydERCRGR2PHyaLLzObIyqNKzCZIymRKy6jPTy7OTi3ISChFx+HISaNKyuPJyaBKTCRKS+VISiVGyKJHSGPLzWdKS+TMzefISCJHRiBGySJJSyNLTGbKzKRHSaHJSWhLyulHSKNJy6RKzCXISWRLTOZJSuVIyuJGyOHHyWLOzaxJSqTGyGJJSmXHySPJS+JHSOHIy2JHR2XLyqlERaHGSGHFRqJHSOJGR+JFxmPNTOxIySbHyORHSWJPTm1ISiHHyiJFRuHMSqjPTu5OzexFx6LMTCtMS+rJyidISqJAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAfKgACCAAGFhoaDiQECAwMCAgQBBQGJggEDBpkGBwgJk5WXmgYJCAqeC4kFAwysCQYNDggPqIMQERITFBUWFxgEGagaGhsVHB0eH8ggvQQLISIjJCUmJygpKissLRcuCy8wMSMqMhszMzQ1Njc43QA5Njo0Ozw9Pig/LCxAQbRCOkM2iBQxgsLGjyJH+CXKoEABkiRKWCxhQYQBLUsYLhxgwkRJEydPoFwkhCEKRylKbNSYIlIRASpVCFj5UeMKhJaDAizYybPnAj+BAAAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+source_s-16:mimetypes mimetypes16 16:photo:16 16:R0lGODlhEAAQAIUAAPwCBFxaXNze3Ly2rJyanPz+/Ozq7GxqbIyKjMTCtPT29GxubMzOzPz69DQyNHRydERCROTi3IyKhIyOjPzy7PTu5Ozm3LyqjPz29PTq3Ozi1LyqlPTm1OzizOzWvLymhGxudGRmdFxedFRWdERKdDQ+dHR2dFxidAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAaHQIAQECgajcNkQMBkDgKEQFK4LFgLhkMhOl0iElbFgtEgOJQC8BXxOEDOw0DkGhYMJHCq4FuYJBQUEQN5RGlWYBQVFheEVWEYFRkaG40RXw2JGX6MaIiRHGCccQKAkRodHh4fjQ+tICEiIyQkJY0mJg8FJwWzJbVKD7gnI7K+v3EOycrLDn5BACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+source_y-16:mimetypes mimetypes16 16:photo:16 16:R0lGODlhEAAQAIUAAPwCBFxaXNze3Ly2rJyanPz+/Ozq7GxubPT29IyKjMTCtMzOzDQyNHRydERCROTi3IyChIyOjPzy7Pz27PTu5Ozm3LyulPz29PTq3Ozi1Pz69LymhOzizLyqjPTm1OzWvIyGhIR6dIRubIRmZHxaVHxSTHxCPIRydIReXHxWVHxKRAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAaIQIAQECgajcNkQMBkDgKEQFK4LFgLhgMiOl0mFFbEYVEgMJQC8DXRODjOw8DjGhYMIHCq4FuIKBASDwN5RGlWYBMUFRaEVWEXFBgZjEoPXxoSkX4bjYaZGBxgHZ2AkR4cHx+cSiAJCRAhIiMkJSaNCREgBScFKCkqtkq4sLK0JsFxDMrLzAx+QQAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+tar-16:mimetypes mimetypes16 16:photo:16 16:R0lGODlhEAAQAIYAAPwCBFxaXNze3Ly2tJyanPz+/Ozq7GxqbJySbJyadPT29Pz69GxubMzOzDQyNPz21LSujPz25OzmxNTS1IyKhERCRKyqjLy2rKSehPz67Pz23OzerKSaZMzGxPTy7PTqvOzirMy+dKyeTIR2NPTq3LyubLyqVJySPHxyJOzi1LyunPTqzOzW5OzSzNzOrJSGNGxiNLy2pPTm1OzezLyqjJSKZOTStOzOxNzGtOTSjKSSRIR+LGReHLyynOzexLymhOTWlNzOhFxSFHRuRNzKfNTGdHxuLGxeJIyCbMy6pLyifLyqlNS+pOTOpLyedHRydJySfAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAfLgACCAAGFhoaDiQECjIwDAQQBiYKLBZYFBgcFkZMICAkICgULDA0LBA6Cnw8QERKgExQHDBWpCBAQFrm4EAkKAhcUqRgRGRqsGxIbHB0eAgOpCRofCw8WICEiIwMkJBDRCwsgICUmIico3CkqtissLS7mJy8wMTIzNKk1Njc4OSI6Xuzg0WOGjx/6gOQIEkTHiB0ohKjwYQOhoCEliBQxcuQIDCRJbNhQkmoQRhgflzAR2cRJSUFPekDpQbMHjR9OXCpywLOnTwd+AgEAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+tex-16:mimetypes mimetypes16 16:photo:16 16:R0lGODlhEAAQAIMAAPwCBAQCBMTCxDQyNPz+/FxaXAQChKSipPz+xPzerAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAARgEEgQqrUz3yqGCJlUESRZEFU4lkQREJ/2skU9BEaezzmRCwccwDCc+XwIFGhI0ZEMxiURxzIQkghp0+qjJlDDHdRnQPSyGu4oEfguRTrs9fqmWAjfPHpSkWMReyIbg34RACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+tgz-16:mimetypes mimetypes16 16:photo:16 16:R0lGODlhEAAQAIYAAPwCBIQChFxaXMQCxNze3Ly2tJyanPzC/Pz+/OTi3GxubJySbJyWbPT29MzOzPz69DQyNPz21LSujPz67OzmxJyadNTS1IyKjGxqbERCRKyqjLymhLy2rIyKhKSehPz23Pz+9OTevOzmtKSaZMzGxPTu5PTqzMy+dKyeTIR2NPTq3LyulOzirLyubLyqVJySPHxyJOzi1OzW5OzOxNzOrJSGNHRmJOzezJSKZOTSjGReHLyunOzaxOTWlNzOhKSSRIR+LFxSFLyynOzWvHRuRNzKfNTGdGxeJGxiNIyCbMy6pNS+pNzSrAQCBHRydLSunMSynAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAfYgACCAQKFhoaCiQOEBI2NBQIGAooHjAiXCAkKCJIAAZ8BCwsMCw2XCg4PBhCCohESExQVCxYXChgZrAsSvBIaGxIbDA0JHB2sHh8gHx8SISIiIyQlBBysFR8mzBIiJygpBSUqK9cPEywiLS4oLzAFKjHkAAwmMjM06y81NgUmNxuscNCYQSIHuxopdOy4wQMgABw9cvjw8SMFEBhBhPAY4hAAkRZFjKQ4cgRJEiWgAiTy2AKJSSFLmAQ4MKDJSidPFggRAmXFhgADNthMJACC0aMQAjRZ6icQACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+txt-16:mimetypes mimetypes16 16:photo:16 16:R0lGODlhEAAQAIYAAPwCBFxaVPzKjMR6RNze3Ly2tJyanPyODPz+/Ozq7GxqbPyKBPyGDPzGjPT29HRydMzOzDQuJOx6BPyGBPyKDOTWzIyKjERGRDQyNKROBOR2BOzezIyKhBwOBKRKBNSOXOza1CQOBPyCDOySZPzizPTWxPTy7Pz69Pz29PTq3LyqlMxmJNRyROy2lPTu5OTi3MSulFxGNIRWLMR+XPTKrOzStPTm3IRSNOzizOzavLymhLSyrEw6LKRuVIx6ZNzSvOzexNzWxNzW1FROTBwaFKSShOzWvOTOpOTazJyWjHRqXNzKrOTStLyifMS+vMS+rMS6pLymfLyedAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAfOgACCAAGFhoaDAgOCAQSOjgUBBgGCB4qEBAiaCAkKCJMACwwNA42bCA4PEA4GERITFKQVpwgWDwoXGBkaE6MDG6cOBAUcGB0eGgsTDR8gmw4OGwURACHIIiMkJSYIJygpKSoYgtYrLC0kLdAuKS8w1IIdMTIzNDUbLjYpG+KDABcRbtRrYWMDjhw6xg0KsCMAjx4+fmwAEiShvwBCChgYQqSIkRpHdMBjZCIFkh1JlCxhcqSJQkZOnjyBAgOGjihSpLwkhAFDBJ9Ae0bwEwgAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+unknown-16:mimetypes mimetypes16 16:photo:16 16:R0lGODlhEAAQAIUAAPwCBFxaXIyKjNTW1Nze3LS2tJyanER2RGS+VPz+/PTu5GxqbPz69BQ6BCxeLFSqRPT29HRydMzOzDQyNERmPKSypCRWHIyKhERCRDyGPKz2nESiLBxGHCyCHGxubPz6/PTy7Ozi1Ly2rKSipOzm3LyqlKSWhCRyFOzizLymhNTKtNzOvOzaxOTStPz27OzWvOTOpLSupLyedMS+rMS6pMSulLyqjLymfLyifAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAamQIAQECgajcOkYEBoDgoBQyAJOCCuiENCsWBIh9aGw9F4HCARiXciRDQoBUnlYRlcIgsMG5CxXAgMGhscBRAEBRd7AB0eBBoIgxUfICEiikSPgyMMIAokJZcBkBybJgomIaBJAZoMpyCmqkMBFCcVCrgKKAwpoSorKqchKCwtvasIFBIhLiYvLzDHsxQNMcMKLDAwMqEz3jQ1NTY3ONyrE+jp6hN+QQAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+vcalendar-16:mimetypes mimetypes16 16:photo:16 16:R0lGODlhEAAQAIMAAPwCBFxaXDQyNAQCBMTCxPz+/ISChAQChKSipAQC/Pz+xPzerPyqXMRaBAAAAAAAACH5BAEAAAAALAAAAAAQABAAAARyEEgQahVijMmD/oRAbBw1FCgaFFrpEbB6jt1g3OpFAscxwATUiIAgBRKJXiqIYJEMBQNSWSAYgptrMDo9FJqKrHArTR4WLGisSkbebE12gXFFGRBFyd3eaFSvbx1xCDBXC2E1e1EECo07ABkaBh4fGn4RACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+vcard-16:mimetypes mimetypes16 16:photo:16 16:R0lGODlhEAAQAIMAAPwCBFxaXDQyNAQCBMTCxPz+/ISChKSipISC/ERCBMTC/Pz+xPzerAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAARvEEgQahVijMmD/oRAbBw1FCgaFFrppeo5drKhXqQUEIfREyweqWIoHo4GDYtkGxwQ0CjitEkUrCyfYjtdbJoFW/agmLJWWZSY3B0EbGJ4uAwcHlK2HpTg7YgHBgQjDH0THoGBCwULjDkAGR+RH34RACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+video-16:mimetypes mimetypes16 16:photo:16 16:R0lGODlhEAAQAIYAAPwCBFxaTFxaXIxuHJyCLHx6ZLy6vJSSlNze3Ly2rMy2RNS+TKyqrMzKzPz+/Ozq7GxubJyanLSePKySNKSSPNTS1JSWlDQyNMSqPLSmVNzKZJyenIyKjHRydGxqbERCROTWXNS6XOzidNzOZPT29MS6rISChLSulMy2TLyeNKSOPJyCPOTi3JSSfHxiFGxaJFxWLFROLPTu5Ozm3ISCdDw2BFRKHHxqPFxWPLymTMzCvPTq3OzezKSWTMzCbNzGZExKNHx6dLyqjMy6XMSqTMSmTEQ+JHRybMSynISCbMyyVOTWbLy2ZBQWFGxqZOzifDw6LCwiDISCZJR6LIRqJBwWDExKRHRuXHxmJGxeJFxSHCQiFFRGFGRSHAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAfhgACCAAECAoWHhoMDBAUGBwiRkQkCBwGCCgsLBQwNDp8ODxAOEQIAChITFJwVoA4QnhYXEhgZBRoFG62fHB0eHxcgIQUiIyO5uyQIJSYXJwUoKSoUKwEWniQkLCUXHy0DLi8vMDEfBw0kMjMnFwAfNDU2Nzc4OTgmOjs87ILvEj04NPj4ASRICR5C2vVrEWAIEQwSihg5giThIHdJiCgJMWIJkyZOLA4K8CHJkycimEAJEcWJQkECEHyQEqIHFAJTqFSxcjGAjhIfrlzAkkWLDS1bel5Y+mELly5YCEyQ4CcQACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+wordprocessing-16:mimetypes mimetypes16 16:photo:16 16:R0lGODlhEAAQAIYAAPwCBFRSVFxaXFxWTNze3Ly2rJyanPz+/Ozq7GxqbHR2dHRydGRmZERGRMzOzCwqLJyWjOzi1Oze1PTm1PTm3IyKjDQyNERCPPTy7HRmXCwqJPT29DQ2NNTGnOzm3PTq3CQqJMS2hDQuLKyaXCQmHBwaHKyahLSijKyehBQaFCQiHHRqNPTu5LyulCwuLHxyNAQGBBQSFERCRBweHOzezIyCVJSSfOzavLyqjOzexOzWvLymhExGJEQ+JExCJExGLCwqHOTOpDw6POTStLyifMTCtMSynMSulLyedAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAfWgACCAAECAwIChYeDjAIEj48FAgYBjIIBBAeaBwgJBwYDjAoLDIkNmgsOnw+CEBESExQSEgsHFQsJDRYAFxWbmhgZGhsEBRUcHQ8cEB4fzhAWICEYxSIjJCUDJicnKBkpKissFC0uLwAwMDEyFzHpDxgfES27DyozMyX6+TMTEzQtWJWoIYGgQRsl/t3AsStFQRoGIYrIkUPHDhcANPDo0cMHxx9AUtzQEWQHKwAcSDy4IAQbh5FDghDZNShAkZsFjBzBgaQnh0YcHojgIMIFBwtBXfgJBAAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+1downarrow-22:actions actions22 22:photo:22 22:R0lGODlhFgAWAIUAAPwCBAQCBBQSFAQGBDQyNExKTHx6fGxqbFxeXGRiZFRWVDw+PAwKDJSWlOzu7LSytJyenJSSlISGhISChIyOjFxaXDw6PPz+/MTCxLS2tIyKjKSmpKSipJyanAwODDQ2NHRydERCRFRSVAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAWABYAAAZzQIBwSCwaj8ikcslsOp/OgHRKlQoCgymRUDAcEIkwYgxWFBYERpHQcDwgEclEQmk8DhWL2kiIXDBwExMNGRoJaUkEEH8bEQ0cGgcWAksEHX8QHBKSHk1sfxMHH5ROBBsOICGkT2wiq1CIULKztLW2t0h2QQAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+1leftarrow-22:actions actions22 22:photo:22 22:R0lGODlhFgAWAIUAAPwCBDQyNAQCBExKTJSSlHx6fAQGBOzu7GxqbJyenPz+/LSytFxaXMTCxGRiZKSmpISGhFxeXISChAwKDFRWVHRydJSWlBQSFERCRIyKjDQ2NIyOjLS2tDw6PBwaHFRSVDw+PAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAWABYAAAZ5QIBwSCwaj8ikchgQLJGBgfNZDBAKBirRekBMtYGEYsHIgsWNhOO7tCrShDU18Hg/CJAIG0o4wCUQcksTFBUSCRYSEnpUFxgIGQkJGYyNGggbHBaVjR2QCxEeWkITHQ4IH3tPFwEMA2ajAKUgqlQTTbFEE7W5vUgGQQAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+1rightarrow-22:actions actions22 22:photo:22 22:R0lGODlhFgAWAIUAAPwCBDQyNGReZAQCBMTCxGRiZMzGzOTm5LSytPTy9Pz+/CwqLOTi5Ly6vCwmLMzKzJyanJSSlBQWFKymrIyGjCQeJJyWnISChISGhHx2fKyurDw6PAwODHx6fHRydDw2PERCRAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAWABYAAAZ2QIBwSCwaj8hkMRBQKgOCgRMZIBSk06XhEM0SA4iE4uoVLhCMhqLrdSAekMgYO5VM4BQ521mxIC4UFxBWdEkSERYYFxETGQGFSBKCGBEaGRuQSBwdeZaPXpsQCB6YZQMdEI6ZSgMepKusHh+wrCC0rLdlursGQQAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+1uparrow-22:actions actions22 22:photo:22 22:R0lGODlhFgAWAIUAAPwCBAQCBFxeXDw+PMTGxHRudPz+/JSSlLSytIyKjHR2dISChIyGjIyOjLSutLy6vKSepJyanISGhJSOlOzm7Ozu7MzGzKyurJyenDQyNGReZKSmpIR+hCwuLCQiJBwaHBQSFAwKDAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAWABYAAAZtQIBwSCwaj8ikcslsOp9QYyAQFQYEAyr0Sihkn1fDAeHVLsOJNELxVaITC0bDUU6GH5AIQ8KYrNtFVxQVFBYWFxgRCREYdUQZGhYEDwgIGxAHCQocCgWOQhmhGR0epR8gqCFTq1Wtrq+wsUt0QQAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+2downarrow-22:actions actions22 22:photo:22 22:R0lGODlhFgAWAIUAAPwCBAQCBAQGBBwaHDQyNExKTHx6fGxqbFxeXGRiZFRSVDw+PAwKDJSWlOzu7LSytJyenJSSlISGhISChIyOjFRWVDw6PPz+/MTCxLS2tGRmZDQ2NAwODJyanKSmpKSipIyKjHRydBQSFERCRExOTFxaXAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAWABYAAAasQIBwSCwah4FkQKBsDpoBIqFgOCASCYRWm1AUFgRGkdBwPCARiWRCaTwOFYvYSIhcMOiJpJGZaDYcR0IEHXceEQ0fICEWIoJDhHcQHxIHgI9SEHeVG46YUh8OISOen1INCqWmUnOYTUxQAU9NUlRWWFtbCiRgrYNlZ2lriG8lYUd1khETE24gCZeCkRgeFBAQIAeNn9OTlXKrBJoYnKrcoaPmpmSpq3S+7u50QQAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+2leftarrow-22:actions actions22 22:photo:22 22:R0lGODlhFgAWAIUAAPwCBDQyNAQCBExKTJSSlHx6fAQGBOzu7GxqbJyenPz+/LSytFxaXMTCxGRiZKSmpISGhFxeXISChAwKDFRWVHRydJSWlBQSFERCRIyKjDQ2NIyOjLS2tDw6PBwaHFRSVDw+PAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAWABYAAAavQIBwSCwaj8gkMiBYNpeDZzEQXRIKBmPgmtUSDgipcAsWjxOKBaN7Tq+n6EbCIQ3E5+KtQk6gjwl7CX11D3sPBBARTQGFDYeJT2R8EhB0koKUfgATFBUSCRYSEoqcnqCiikMXGAgZCQkZqautr7FiFxoIGxwWqQC4ury+qh2tCxEexMbIRhMdDggfYs7Q0kcXAQwDbELY2txEziBmmx3jSRNMR+nk4e2b70ry80QGQQAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+2rightarrow-22:actions actions22 22:photo:22 22:R0lGODlhFgAWAIUAAPwCBDQyNFxeXAQCBMTGxOzm7CwqLLy2vPTy9Pz+/Ly6vCQiJLSytLS2tLSutOTi5MzGzKSepIyKjJSOlKSmpMzKzJyanIyOjBwaHIyGjISGhJSSlISChBQSFJyenIR+hGxubDw+PHRydHR2dEQ+RHx6fERCRAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAWABYAAAa6QIBwSCwaj8hkIIBcJgEBweAYnTYJUmMAa9USClniFtwlGg6IRFhoUKTXwwWj0FB3F46Hwl6UQyISfAB+EROCQgsUFRYSF3yJEIyBaxgWDBkaGRtclQwSHBIbEGEdGx4fGhcOICEDGBsWHBmqIq1CHRIWGRMMIyRTHRy6Er22tyONq8YdJRe0xkIDwr2/QwMfliMmZQADIxasZd4e4UYDIr7c59rc0eVFA+/m0EQD9PDt0flP/P3+BkEAACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+2uparrow-22:actions actions22 22:photo:22 22:R0lGODlhFgAWAIUAAPwCBAQCBGReZDQyNMTCxHx6fPz+/JyWnKyurHx2fDw6PJSSlISGhIyKjIyGjISChLy6vJyanOTm5PTy9OTi5MzKzLSytKSepMTGxMzGzLS2tLSutKymrHRydCQiJCwmLBwWHAwODLy2vHx+fAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAWABYAAAajQIBwSCwaj8RAAMkUBgSDZdP4JBSi06TAcEAkFNLp07BgLLzY5njRcDzO3zB1C4lEGI83Wj58SiYUFRUWdg0XEXFFAwIYGRoWGxwRZQUFHZdgRAObmx4fHiChISFKpVlKWUdPaalOAlasp1sHG4myZGZ7Yltsbgu1mUhjdRF5egmxfQJ/gYOFdrZDi40iFgiSCw8jBQmYcpydn6Ego6WorUwGQQAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+abs-22:actions actions22 22:photo:22 22:R0lGODlhFgAWAIEAAPwCBIQChAQCBBQSFCH5BAEAAAAALAAAAAAWABYAAAJLhI+pF+vW4HMR1InqxbJzBiLCeIxCaIkneQJk6rkl+2qlONzeNi+2YvKhEIOW4iczvJSoSDDIbCpbq2oGBXUtd59r7IPshsHdB70AACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+airbrush-22:actions actions22 22:photo:22 22:R0lGODlhFgAWAIMAAASC/AQCBPyChMwCBIQCBPz+/MzKzKyqrISChDQyNPwCBAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAWABYAAAR8EMhJKw3BahvEyNvWDV+ojQMBAhgmeukaFHSxTqh6FYZx3CyYbtf7XYRAFs8nQ56WxiBpyOEdjLkkrnA9IAKGqXbnTYAP1NDMe0Z8JYR4nPP1seEqTHpWZMupVHx2by03Q4JXbxuBfYoaaVZ3i4YKbo4WaQAKBCxjcEAGEQAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+appearance-22:actions actions22 22:photo:22 22:R0lGODlhFwAWAIYAAPz+BAQCBBweHPTy7Ozq5ExKRPTu5NzStLy2lCQmJAQGBOTezNTKrLyylNTKpOzm3NzWvOzm1MTCpNzaxISuvBSGvLy+pKSehOTexISutKTa7IzS7GSarJTW9HTK7CyazBRypMzGpDw2LOTaxEyKpCSSxARGbERCROTizMS6nDx2jARajIR+bOzi1OTi1MzCnLy6lOSupNx6dGS2rJS6pMy+pOS2pNxGTKwaLDSmpHTOzES2tIyuhLSmjPyqrMw6RLSOhLzSrGyqbFSmXJSyhNTOtGTCvLzm5CyOjEQ+NPRqbOxOVKyKfMzizKzepFyuZJSqlBR6fCRmZJSKdDw6NLxqZLQiNIwyNLSejDSCRJzWnEyiVHySbBRiZDQyJMSijGS6ZHSCZJyafDRmPISKbJyifDw6LAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAXABYAAAf/gACCg4SFhoYBAgGHjIQBAwQEBYwBlYiQAwYGi4UBBwcInIIJA6WRBAqdCwcMDA2pggEEDpUODwSiAAEQnwwHnI8RwBIGsLoLExQVFg4XiwEPD6IKGBjAExkaGxUcocfSgwHV1uITFR0eHyAhIroRERLAC/PVIxMkJSUgJvHH1RAKTixAgQzZhAkpVKwwwYKWrgnzFrRY4IIgBoMTRryQAGPjs4zzYsgYQdIgsgMzaNRw0CCBLgn2bNzAceMgSZITcujYwaNGj2sjcPjw8QNIECFDiEgoYuSIDiQOkoSTMAGHkiU4mAhp4uQJDyhRjOSQMiUXFQdVrOC4giWLFidbRri8QBKlyxQviIp8udKjRhYwYLKEedFAjJgvucI5cFBEgoMxkMm82PjFmCERix1wLCNmcg8viRGZ6aHZcQ8zoRtVWp16UCAAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+attach-22:actions actions22 22:photo:22 22:R0lGODlhFgAWAIMAAPwCBMTCxPz+/DQyNKSipAQCBISChFxaXDw6PAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAWABYAAARrEMgJgqA4zzus/gLhFd5HCcZAXqsphYPUdhcYFNRcZnvdtpnDqPTbUWgAJKBYwzBlw+bRo3xmkNWoBgm0OrVLn3GC9RgCk8DhUw7c0rHPr4CDu5SYQNyEt7uSY3p/UAKFhYKDSQOLiwgFdhEAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+back-22:actions actions22 22:photo:22 22:R0lGODlhFgAWAIUAAPwCBAw2VCRGZAxCZGyavExmjHyatOTy9CxihISevPz+/KzO3BRylAw+XAQCBDRWbPz6/FzC3CSuzDyexJzO5Mzq9CxSdAQOFISmxNzu9HTS5BSmxAyexDSuzJTa7Mzu9Kzi7GS21CRmjAQOHHSWtLze7AyWvHzG3BRihAQKFCTO3BS+1AyixBSWvBSOtBSStAQWJBSixDzW5BTC3BSqzBS21CTC1ETW3AQSHEze7BRqlBRmjAQCDBR+pBRefBRSdCH5BAEAAAAALAAAAAAWABYAAAalQIBwSCwaj8ikMqBcMpvHgGAANQYIhWdVGDAcENQtIJBQLBgNx0MQaDuQXcghIplQDhBIxXKJYiAZGhscHR4VHyAhIiNWJBklGhIbJoQnFCcTKIxFKSgbKissJi0mJi4vLiYoMEcXKDEyMzQ1Nje2NisoOEg4KDU5K6g6OwwoKAN9SCOeMmgwz884PEq9PT4NYkPLP9jZQikN3d4AKVrjKePp3gZBACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+blend-22:actions actions22 22:photo:22 22:R0lGODlhFgAWAIUAAPwCBAQmJAQyNAQ6PARGRARSVARmZARubARuXARmTARiPAReLARaHARKBAROBAQCBERydESChESOjESanESmpESytES+vETKzETKtETCpES+lES2fESybESqXESiRAQ+PARiZARybASGhASWlASmpAS6tASynASqhASiZASaTASSNASKHAR+BARiBARydAR+fAS2tARKTDRaXARaXASOjASKdASCZAR+TAR2PARuJARqFAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAWABYAAAa3QIBwSCwaj8ikcslcBp6CAaFQMBwOiIRiwWg4HA9hAAKJSCaUiuVywWQ0G07H4wkDxp8CKCQakUolJicoKSorLC12eHouL34lMIKEhoiKEFMgLn0kMIGDhSyVYhADjJuAkoWHiaMEMXuOnJ6Tq5alBpp+nSeflKx3l6a6s6CiwKWZm52pvpaue8rEzaPIubLMta2Mscu9ob8BMgIfBDPJNDQ1Njc4OTotDXYP8/T19vZN+fr7SXRBACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+bookmark_add-22:actions actions22 22:photo:22 22:R0lGODlhFgAWAIUAAPwCBCwqLCQiJCQmJMTGxAQCBLy+vLSytERGRFRWVKyurKyqrLS2tKSmpHR2dJSWlKSipISGhGxubIyOjGxqbIyKjFxaXGRmZHx+fPz+NGRiZPz+ZPz+HMTCBKSiHPz+jFxeXPz+XPz+tPz+zPz+/AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAWABYAAAamQIBwSCwaj4Gj0hgQLJ+AAaEAVQoI06pRYDhkoYgwIhEgKBTfZ2FhaBsYDS8VWnA8Go0FJIKeqyUTDw8EDHBpSwUUFQ4UFhcYDQYFfkoFFxEQDG8KEAUZlEeWGBIakw4FG1STiBoYBRwdBR4fHgUdHKBEBSCnIR8iIyIfIblFu6ceIyQjtcXGCbLKzAUKzrq+wMLEVa+xs7W31kOTk6nkWuOf6Ea5QQAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+bookmark-22:actions actions22 22:photo:22 22:R0lGODlhFgAWAIQAAPwCBCQmJCwqLMTGxAQCBBwaHMTCxLSytERGRFRWVLy+vKyqrKSmpHR2dJSSlJyanISGhGxubIyOjKyurGxqbFxeXGRmZHx+fKSipLy6vGRiZLS2tFRSVHRydJSWlHx6fCH5BAEAAAAALAAAAAAWABYAAAWWICCOZGmewamaQrq+wUC8azHINGocOI38iIRAceDNaISFYklkGHOEhoNBfUAOhuOLEJE8HoPiRKFdESiQBqViuTDIUAsEcyAeGJmyiqC5RCwJGg0YcEh9D0V3Dxt6JwQVDRYVHBUdi40mjw0PTgwQHgeYJQQJfxUXFxAOoTkFpQ0fsRSimQkWEQ0VtI62HLt7vjl7JQYhACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+border_all-22:actions actions22 22:photo:22 22:R0lGODlhFgAWAIAAAPwCBAQCBCH5BAEAAAAALAAAAAAWABYAAAI+hI+pyw0Bo5wR0TttUJDv0yWhRopfaYzguaKt6aasrGFYbVPxM/O7Snv9WEAfTIgMKpNGWU63emYc1GrVUAAAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+border_bottom-22:actions actions22 22:photo:22 22:R0lGODlhFgAWAIAAAPwCBAQCBCH5BAEAAAAALAAAAAAWABYAAAIyhI+pyw3xIpwyOgOv1dvl+2lhMzIlyZ1KQLUVm8Zch4ozbcq6l7L+D4QhgsTf7Xi0FwAAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+border_fall-22:actions actions22 22:photo:22 22:R0lGODlhFgAWAIAAAPwCBAQCBCH5BAEAAAAALAAAAAAWABYAAAI/hI+pyw3xIpwypgBRdg/v9h2eyBnZCIKYxX2oEsJruVKjHS8vk3duKZnpHKjeRSTU0HYpTcxWgRqB1KrVYC8AACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+border_horizontal-22:actions actions22 22:photo:22 22:R0lGODlhFgAWAIAAAPwCBAQCBCH5BAEAAAAALAAAAAAWABYAAAIyhI+pyw3xIpwyOgOv1dvl+2lhMzIlyZ1KwLbuyybw7KY216Einpv377FRhhUV78igFwAAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+border_inside-22:actions actions22 22:photo:22 22:R0lGODlhFgAWAIAAAPwCBAQCBCH5BAEAAAAALAAAAAAWABYAAAI7hI+pyw3xIgxTRvcg1oku3njbBx4liV3dqYbsSsXyLBr0Pad1iCovsmOwgjbdz9TrGHWWSeWZikoXhgIAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+border_left-22:actions actions22 22:photo:22 22:R0lGODlhFgAWAIAAAPwCBAQCBCH5BAEAAAAALAAAAAAWABYAAAI6hI+pyw0Rnox0ygNXdG9z43Xal30gUiYhk5LoenJQRVtti5FwE+Kx4+O9RrIda6gwDmvMi+kJjTIMBQAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+border_outline-22:actions actions22 22:photo:22 22:R0lGODlhFgAWAIAAAPwCBAQCBCH5BAEAAAAALAAAAAAWABYAAAI8hI+pyw0Bo5ww0SttcKci/ymgMTZl+Yjbt3Jn26lautX0A+OizHJkjsrper7XbkZ0ATEYDZPii0qnU3sBACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+border_remove-22:actions actions22 22:photo:22 22:R0lGODlhFgAWAIAAAPwCBAQCBCH5BAEAAAAALAAAAAAWABYAAAIthI+pyw3xIpwyOgOv1dvl+2lhMzIlyZ1KQLUVm8Zch4ozbcq6F7s+fgsKb4YCACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+border_right-22:actions actions22 22:photo:22 22:R0lGODlhFgAWAIAAAPwCBAQCBCH5BAEAAAAALAAAAAAWABYAAAI7hI+pyw3xIpzyQRdVuIZj+3nHhogOiZng+I1qoqIdRVfbWy5y1u5M7MFphB1dsDULGXO15goJjUoRhgIAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+border_top-22:actions actions22 22:photo:22 22:R0lGODlhFgAWAIAAAPwCBAQCBCH5BAEAAAAALAAAAAAWABYAAAIyhI+pyw0Bo5ww0SvdCdrw7oGfNnZlczIpKorc+8RwZbZgXOc2uevOqpjJhrCb8QgwFAAAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+border_up-22:actions actions22 22:photo:22 22:R0lGODlhFgAWAIAAAPwCBAQCBCH5BAEAAAAALAAAAAAWABYAAAI/hI+pyw3xIpwyOgNRyPq+zTkcuIQKaV3T1pgHinmfm7AUedMa64Vw3bLJMr9TiZcSFUsnkw54q0Rl1KrVYSgAACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+border_vertical-22:actions actions22 22:photo:22 22:R0lGODlhFgAWAIAAAPwCBAQCBCH5BAEAAAAALAAAAAAWABYAAAI6hI+pyw3xIgxTRvcg1oku3njbBx4liV3dqYbsalFeJTp1iCovcjNsb9iZhMFcJwXUxTJLYuoJjR7sBQAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+bottom-22:actions actions22 22:photo:22 22:R0lGODlhFgAWAIUAAPwCBAw2VCRKZDRSbBxCXJTC1Mzi7Nzq9NTm9Bx2nAQCBNzu9JzG3Hy+1HzG3IzO5BRmjPz6/LTe7Dy61AyStCTC1FzC1AyGrETS3ETC1ETa5BRulAyuzBRylAw+XMTe7Gy+3CSqzAyexBTC3DR+nIS21KTW5Nzu/KzO3FzC3Pz+/ByixEze7AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAWABYAAAaXQIBwSCwaj8ikcnkMBAQDgjPAFAYKhsMBkVBUAYEFo+F4QLzVQEQyoVTOX/XBcsHA0+vMRbNBMwkRDhxuHX5GTlIeHh8gISIjFAEeiVRECiQlDAUmgxQjIhwiJHdFlycoKSIUFCEjGiGkRpcqCxYijxorsUezcxYsuoZJsxLAu0qXB7DCTJfHvArR0tPSSNTX1V/a20J2QQAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+brace-22:actions actions22 22:photo:22 22:R0lGODlhFgAWAIEAAPwCBIQChAQCBBQSFCH5BAEAAAAALAAAAAAWABYAAAJRhI+pGbHYVHzQnUnrtXn7/gEYIJRHKRgYZraGuXLp28LcNL/Dqd4cYmJYRqegsKcY5DRIUhHYFDlQJGMuVn1ljdhqjhoiZrogKbMjFh/LHUMBACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+brackets-22:actions actions22 22:photo:22 22:R0lGODlhFgAWAIEAAPwCBIQChAQCBBQSFCH5BAEAAAAALAAAAAAWABYAAAJRhI+pyw0Bg3vxwImu0Zha2XkbaAjmYQrjh6qnCpwcB8evTGp1PKDrnzglZqTWDsg5DI5IUE1Yatpc0BrRFr2xfiljJlecXEPjDjG5iIRDCHsBACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+centrejust-22:actions actions22 22:photo:22 22:R0lGODlhFgAWAIAAAPwCBAQCBCH5BAEAAAAALAAAAAAWABYAAAIhhI+py+1vgpy0TogztlT7j3CiBJbZWJlqg4rry7jw/BoFACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+charset-22:actions actions22 22:photo:22 22:R0lGODlhFgAWAIIAAPwCBAQCBAQGBFxaXAwKDBQWFAAAAAAAACH5BAEAAAAALAAAAAAWABYAAANLCLrc/jDKuQK1zmKo3/YVJSpBSZYmKaTkAAwYoQwFELjvpisyaTM7H6AH+3lQMZQwExrOOiBh7/cJGokaXHGpQVaUo7B4TC6bw4AEACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+colorize-22:actions actions22 22:photo:22 22:R0lGODlhFwAWAIYAAPz+BAQCBBweHPTy7Ozq5ExKRPTu5NzStLy2lCQmJAQGBOTezNTKrLyylNTKpOzm3NzWvOzm1MTCpNzaxISuvBSGvLy+pKSehOTexISutKTa7IzS7GSarJTW9HTK7CyazBRypMzGpDw2LOTaxEyKpCSSxARGbERCROTizMS6nDx2jARajIR+bOzi1OTi1MzCnLy6lOSupNx6dGS2rJS6pMy+pOS2pNxGTKwaLDSmpHTOzES2tIyuhLSmjPyqrMw6RLSOhLzSrGyqbFSmXJSyhNTOtGTCvLzm5CyOjEQ+NPRqbOxOVKyKfMzizKzepFyuZJSqlBR6fCRmZJSKdDw6NLxqZLQiNIwyNLSejDSCRJzWnEyiVHySbBRiZDQyJMSijGS6ZHSCZJyafDRmPISKbJyifDw6LAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAXABYAAAf/gACCg4SFhoYBAgGHjIQBAwQEBYwBlYiQAwYGi4UBBwcInIIJA6WRBAqdCwcMDA2pggEEDpUODwSiAAEQnwwHnI8RwBIGsLoLExQVFg4XiwEPD6IKGBjAExkaGxUcocfSgwHV1uITFR0eHyAhIroRERLAC/PVIxMkJSUgJvHH1RAKTixAgQzZhAkpVKwwwYKWrgnzFrRY4IIgBoMTRryQAGPjs4zzYsgYQdIgsgMzaNRw0CCBLgn2bNzAceMgSZITcujYwaNGj2sjcPjw8QNIECFDiEgoYuSIDiQOkoSTMAGHkiU4mAhp4uQJDyhRjOSQMiUXFQdVrOC4giWLFidbRri8QBKlyxQviIp8udKjRhYwYLKEedFAjJgvucI5cFBEgoMxkMm82PjFmCERix1wLCNmcg8viRGZ6aHZcQ8zoRtVWp16UCAAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+colorpicker-22:actions actions22 22:photo:22 22:R0lGODlhFgAWAIMAAPwCBAQCBMT+xASaBASyBASCBARCBPz+/KyqrISChAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAWABYAAARZEMhJ6wzBahvEyNvWEcMXcgJBFuApjavRhlgaz6J9u5dQDAUZ73VA+FhDQOAQQCQEQt6ymcjgREznlZatJpXdLZYq1ky137M3qS5zwl8lOR5IIDBx5TpviAAAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+configure-22:actions actions22 22:photo:22 22:R0lGODlhFgAWAIQAAPwCBAQCBISChFxaXNze3NTS1Ly6vKSipNTO1Ly2vNza3Pz+/MzOzOTe5DQyNOzu7MTCxGRmZMTGxPTy9Ozm7Hx6fPTu9MzGzGxmbAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAWABYAAAW1ICCOZGmeaEoGbBsI6joMRGEcbQwESDIrtVtAF1gwDLNaAmfKiVgLBJKgwB1KxQZrBHU0FAXmavFoQLYiB6TxFXMj5AZBwnJI2I3wcNWALyYEcgoKXxRhOHs7XxEVCwsWFgoUDRYUFwwQB25ZCxiNjo6GkwUXN2NsCxEYqhUHoQ0MEglYRQQXErcHrI55FycuB2YSmoyOBTEtB2sXuhU6XAENC2a6z9AKCwq+1tAN3E2J3ySkIQAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+connect_creating-22:actions actions22 22:photo:22 22:R0lGODlhFgAWAIMAAPwCBPz+BMTCBISCBAQCBPz+/MTCxOTi5AQGBNze3Ly6vISChNza3FxaXKSipAAAACH5BAEAAAAALAAAAAAWABYAAAR4EMhJqwzY6omD+MNGdR8YilNZnug0qGzrqrL1lnV1fyJBVB6VQEMoGH4ADGwQkxQPBwMiKGA2J8VEAnq0tgiKg5aL/C7C2gTjKCM0zowDQ8tuNQznNL7cKzjOUQsNfER+gguIg19+Pm6ChBZFDmWNi5M5FIyYFHQRACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+connect_established-22:actions actions22 22:photo:22 22:R0lGODlhFgAWAIQAAPwCBAQCBKyirPz+/KymrOTi5KSipMzCzNza3OTe5Ozi7MzGzPTq9OTm5ISChMS+xFxaXNze3GReZIyCjAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAWABYAAAWLICCOZGmeaBkAQpoGg7C6JizTQT7CxPwOwFWgYPChYIXkIHC4uQKGAiKRKCyNpxxUUVViVYNFLkqtLo+DAkMMLXQPXwAy2WCTF4544FGtKuwPDhB6DnxuUmyCcXIQhV1uYoMuEAcOBxEKCHg6TzGFCJUSizuejROKOAM9OY2SnUU7nD89NCcDsLUnIQAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+connect_no-22:actions actions22 22:photo:22 22:R0lGODlhFgAWAIMAAPwCBPz+BMTCBERCBAQCBPz+/MTCxOTi5Nze3OTm5Ly6vNza3ISChFxaXKSipAAAACH5BAEAAAAALAAAAAAWABYAAARiEMhJq7046827/+AVCKE0Dh9BAGdaGISAToFGFMcBU+11I4hDYseSZQiKwwKoI/QwBIYiuFDCZseGdIlYEjUNg1SpY6w2N4cUIW6cjwW1lsFwo+MqgtZuw0/ydw5vH34lBhEAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+contents2-22:actions actions22 22:photo:22 22:R0lGODlhFgAWAIUAAPwCBAQCBDyGhCyCfFSWlESOjDyKjDSGhCx+fGSinGSenFyanEySjHSqpHSqrGympEySlBx2dISytHyyrCR6dKTGxHyurHSurHyytGSipCR6fARmZFSalEyWlBRubAxubBRydDyKhDSChLSytPz+/MzKzIyOjAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAWABYAAAbFQIBwSCwaj8ikMhBQIpmCQdM5ZBIKhgNiugwkFAsCI7pNMhuOxkNBgBgEiAi3GkBLJpJHYgEpaClyREwVFhcSEhgOGQoMfgMaERtcARQBFRMYExZ6HB0FUYAekkIBHxqWFmlrC1haESAfG6MBGx+VFRgKYH0hInGRklO0ppYXCwwMWQiQHkwjgrWnFRdYZHIBJCTP0LaWGAcDW9jZ2nMAw9IWTOQkJSZMRsOV49nu8E+19PbmR7TY+1TovONH5V7Ag0QMBAEAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+contents-22:actions actions22 22:photo:22 22:R0lGODlhFgAWAIYAAAQCBAQ2NPwCBHSurIS2tBx2dBweHPz+/Ozm1GxiTGyqpPz6/Pz69GSqpOzaxPzy5HxuVLSmlOTazPz27PT29NzClPTexHxuXLSmjAxqbFSinPTy9KyehNy+lPTy5Pz29HxyXNzWxKSahOzexPzy7IR2ZOTWtESenPTy7KSWfIyCbKyijAQGBDyalPTu3KSSdDSOjJyOdCSGhPzu3OzizJSGdPTq1PTq3JySdMy6lAyKhOzWtOzi1OTOrJyKbMS2nJySfMS+rAwCBNzOrNTCpNzKpJSGZKyafLSifLyylIx+ZHx6ZDSChAQuLAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAIALAAAAAAWABYAAAf/gAABAoSFhoeHAAMAiI2IAAQFjI6EAAaJkQeTjwAICYkKBQcLm5WdBwyfhgChB66bp64HCQC1lQ2irqQCAA4PowsLEBESE4wAuLIHFAAVFr+uDBcYxRm1GrmuGxwdFh4Mrh8gGCET1gDYyhsiFSMkDAsMDCUYJhvnJ9kHKCnODwwfPlBQsULCPRYAWogK9sHFiwoOPEyQh0JFPXO1YBSYwBEFghjdHkwQOYGgwQwIZRR44GHGDBogabhAsYEEihrUMAIoUMCEDRs3HODIYQHFA6MPcJA7KICFjgw7eIzo4cOfiwc/gKwIUm2SkKdDdlDt4AABDaU/iIRwwbTSUyJFOow4S3Hkx9oNDDZgXPU0h1wcSIgEGUw4ibVET5WoWMKksePHpdxmyKADAEIWly9HJtQkQJMmlAgZCAQAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+contexthelp-22:actions actions22 22:photo:22 22:R0lGODlhFgAWAIEAAPwCBAQCBAQChAAAACH5BAEAAAAALAAAAAAWABYAAAJQhI8Qy5F/ghBsLuOgpHHy+0hZ94HINiqWwoQrtjYpNqJ0A8Hcjbs73yPNZEHVDygTJohJWqiZe0JPM5ajtXxFMkXnklqNgsPiWzmHPatzhgIAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+crop-22:actions actions22 22:photo:22 22:R0lGODlhFgAWAIMAAPwCBAQCBMT+xASyBASCBASaBISChMTCxPz+/AAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAWABYAAARUEMhJq704681r+EFHBcIwEKFImmfKkURhoh1cyO0rxEWZa7bezIUJ7gg04O62A22MyeeyF1XymrUSs5pZmbA61u+FLBOBhrThozq4D2cgYo6IawwRACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+decrypted-22:actions actions22 22:photo:22 22:R0lGODlhFgAWAIYAAPwCBGxqbFxaXExOTEQ+RAQCBPz+/PTy9Ozq7Nza3NTS1KSipFRSVOTi5Hx2fJSSlKyqrJyenJyWnDw6PMzKzKyurDQyNFxWXMTCxJyanHRuLHxuLGReJFxSLFROJFxWJExCHERCHBQODISChHxyLHRqNIRyNHRmLLSqbKyiZLy6fOTarPz67Pzy3OzitKymZFxSJJySTNTSnPTy3NzSpMTChLSydKyqbKSaXJySVIyGRGReLPz23NTOnMzCjHxuPLy2vKSmpOTe5LS2tLSutHxuNHRuPMS+xFxWLIR+RDw2HFRKJAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAWABYAAAf/gACCg4SDAQIDBAUChY2EAQYHCAkKCwyOjZANDgIEAQoPjJiDAg2iggQQp5gMBwmrDBESl6MTFKuoFQSjABYRF40CGAW8BRm7hQwNxBobHB0eHx4gISIjBdiEAhYFJBslHOHSHh4hBSHlxIUmJygpKissBiwtLi8pGjDqhBoxMjMuaNSwcSMFjhw6dnjYRyrGCh4ueviw4Q5HDB0/PjAUJCBCAwMIGiiggAEIBFk/FgYLIgRkggQkhxAJkqGExkYMFnxsIGRkSQgLHhRRWUjAggQgG8AsSWRBBiP6VrYMOfKIyaBDNwLo+HHSUplOSyDRqiEHjRkretRQkcLgxayNF0wksQGQxsSKMTIq0QpgCba/gAE7whEIACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+down-22:actions actions22 22:photo:22 22:R0lGODlhFgAWAIUAAPwCBAw2VCRKZDRSbBxCXJTC1Mzi7Nzq9NTm9Bx2nAQCBNzu9JzG3Hy+1HzG3IzO5BRmjPz6/LTe7Dy61AyStCTC1FzC1AyGrETS3ETC1ETa5BRulAyuzBRylAw+XMTe7Gy+3CSqzAyexBTC3DR+nIS21KTW5Nzu/KzO3FzC3Pz+/ByixEze7AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAWABYAAAaRQIBwSCwaj8ikcnkMBAQDgjPAFAYKhsMBkVBUAYEFo+F4QLzVQEQyoVTOX/XBcsHA0+vMRbNBMwkRDhxuHX5GTlIeHh8gISIjFAEeiVRECiQlDAUmgxQjIhwiJHdFlycoKSIUFCEjGiGkRpcqCxYijxorsUezcxYsuoZJsxLAu0qXB7DCTJfHVQrMX9PU1Uh0QQAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+editclear-22:actions actions22 22:photo:22 22:R0lGODlhFgAWAIEAAPwCBAQCBPz+/ISChCH5BAEAAAAALAAAAAAWABYAAAJBhI+py+0PYZi0WnqC2Lx7HhjaR3YhMArBUHpnuramCLLy9tY3TuP2nfPtVD3VTxY0DpNDHqo5E12mlYj1is1e7QUAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+editcopy-22:actions actions22 22:photo:22 22:R0lGODlhFgAWAIUAAPwCBBQSFPz+/DQyNISChDw6PMzKzMTGxERGRIyKjFxaXMTCvKSmpHR2dPz6/Pz29PTq3MS2rPz69MTCxFxWVHx6dJyWjNzSzPz27Pzy7Pzu5PTm3NTKvIR+fJyGfHxuZHxqXNTCtPTq5PTi1PTezNS+rExOTFRORMyylPTaxOzWxOzSvNze3NTOxMy2nMyulMyqjAQCBAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAWABYAAAbYQIBwSCwahYGkUnk0BgTQ6IAQaBKfUWhBYKhaAU+CgXAQIAyChLeJzSIQhcH6GFaM0QtGY5kstqEODw8QEQELAhJTc08KBBMEFBUWDRcBE1pca20SGBkaEBscAY5maFRIAgoLHRQRHh8gIQFlZnByqA8ZGSIQIyQjJQEmYgJ5p2ACrK4gJx4gKIZZAgdeAQ4ZI9kjKSor0AwEjeAs1S0cHAslLi4vMDDRWeRIfEsxMeET4ATyVoYLC5fizXEiAR84BeMG+pEm8EsAFhAjSlR4hR6fLxiF0AkCACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+editcut-22:actions actions22 22:photo:22 22:R0lGODlhFgAWAIMAAPwCBAQCBAwCBPz+/OTi5JyanOzq7DQyNGxqbAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAWABYAAARbEMhJq704gxBE0Bf3cZo4kRJqBQNRfBucyudgvJS6VaxLzyMa6/bLiWA9HOg4VIIkL5vzuRkcpkvRIIAorphJLzBW84WEuRZWp6uaT7J2Sh1Hit3OY/ZO7WvsEQAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+editdelete-22:actions actions22 22:photo:22 22:R0lGODlhFgAWAIYAAASC/FRSVExKTERCRDw6PDQyNCwuLBweHBwaHAwODAwKDAQCBExOTNze3NTW1MTGxLS2tJyanPz+/Ozu7BQSFCwqLDw+POTi5PTu7MzKxIR+fCQmJPz6/Oze1NTGvPz69Pzy7Pz29LyyrPy+vPyupPTm1BQWFIQCBPwCBMS6rPzSzNTOxPTi1NS+rPTezNzOxPTizOzWxMy2pOzaxMy2nPTaxOzOtMyynOzSvMyqjPx+fOzGpMSihPTq3OzKrOTCpNzKxNTCtAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAWABYAAAf8gACCAQIDBAUGBwgJCgsLgpCRAAwNlZYODxALEY+SkAMNEqKjEw0UD5yegqCjrRMVEqidkgWhraMWF7GptLa3EgEWFRSOnhW+vxgZEBqzkBvItxwdHryRCNGjHyAhHSLOgtgSI60c2yQjJd+eJqEnKK0hJCgnJSngAO0SF+8qEvL0VrBogW+BLX4oVKgIyMIFQU8KfDV4R+8FDBcxZBREthAFiRIsOsygsVEUh4Un3pGoUcPGjZInK65QicPlxg8oX5RwqNJGjo0hdJwQ6EIkjRM6dvDYCKIHSBc1Ztjw4eOH0oIrsgIJEqSFDBo0cuTgsdSTo7No0xYTZCcQACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+edit-22:actions actions22 22:photo:22 22:R0lGODlhFgAWAIYAAPwCBISGhISChHx+fHx6fHR2dGxqbGxubGRmZGRiZFxeXFxaXFRSVIxSLPyuXMzKzMzKxMTCtExOTPzqrPz+/NTS1MS+tOSaVPyWNPz6/IxeNPzavPyKBNTW1PyCBPyGBJxmNPzOpLx6PNRqBMSCRNySTPyCDPSGBMxiBKROBHRydPSylOyydMxmBJxKBAwODPS2lPTq3OyabJxGBPTy5PTGrOyOXPR+DPz69PzmzPzevNxuPORqLMReFPzy7MyCXKxiNIRKHBQWFNTOxPzixJRaPFxONHRqVPz27PTy7PzStCwqJDQyLJSGdIx6ZPz29PTu5HRmTLSKbMSGZHROPFxKPJSKfJyShKyehMyuhDQmHEQuJJyOfLSijMSynMS6pLSefDQyNHx2bKSahLyqhLymhOzi1FRGNIR+bNzKtOTOtOTKrOTKpLyedAQCBFRWVPTq5NzOvLyunLSmlNTCrOTOrNzGrLyidMS+rLyynKyijLymjLyqjAAAAAAAAAAAACH5BAEAAAAALAAAAAAWABYAAAf/gAAAAQECAwQFBQYHBggJCgsLDAwADQ6CAQ8QD5ydEJ+gERKWE4ICDxSpqhWqqhYNFxMYphCtqaytGRoXGxgcggSoth25u70eH8APFR0VzMzNziAXIRjIvwAFwq3EqSLUGB/iI4LathS4JCXVJh8nKCmCKrXDFCss1eIfLS4v8ssdmgWsAGNDDBnt3s3wJ+jAtlUhaNSwccNEi4WCBBl4SAHHihw6ZOzg0QNjRgAG6KXK4CNEjBU/gDQI8kLISQAIADobAoMIzCINjLw4YvNkAno4kCRRUuNHESNLmDRxUjSjAlRPfECJImUKlSpMrFzBIqWqoKtJaWSJomULAy5XXrp4+QKGYcYFoCBEWRImi5gmY7CQyVLGriAGD2jEMHMmCxc0Xb6kUbOGTRs3N988gLM4jpw5Y+iwqcOGjZ07mE8yiGABz5c8c/Ts4cOnDJkybS7fdMO7t+/fvDMaCAQAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+editpaste-22:actions actions22 22:photo:22 22:R0lGODlhFgAWAIYAAPwCBBQWFDw6FHRuFGRaBFxSBAQCBAQKBCQiBIx6HPz6/NTOfKyiXDQuFOTm5Pz+/Ozu7PTq5Pz63PTyxNTOjKSeRExGLMTGxMzKzNTS1NTW1Dw2NKSmpKyqrKSipJyanNzWlLy6ZLSuVIx6FISChIyKhJSSlCQiJLS2tDw6NDQyNCQiFCQmHBQSDGRiZHRydGxubHx6dGxqbFxeXGRmZFxaXCwuLOzq7KyurHx+fDwmFEQuFCweFCQWDBQODBwaHBweHKSinJSWlOTi5JyepHR2dDw6PBQSFNze3ERGRIyKjIyOjISGhPz29Pzy7MS2rMzOzFRWVHx2dHxybDQiFPz27Pzu5PTq3PTm1NTCtJyGdHxuZHxqXPzq3PTaxNS6pFxWVFRKRNS2nPTi1PTStNSulNzOxNSynMymhAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAWABYAAAf/gACCgwABAgMEBYSLggaOjgcICQoLDA2Pj4MGDg8QEZ4FDxITFBUWFxcYGRobjQ8cHR4fCQ8gCyEiFSMWJCUkJieNEB4dKB4pKissK8wrLS4vMDHBAAYQHx8dFx0fJDIzNDU0M+IyHzaNNyg43Ng5Ojs7Ojw9Pj9AMkCNDiZB/h9CSOx4QLCgihItqBkYgqIDESElitAYWJCgkQcXjjRCgi1Ihw4BB5LAQOLCgyQYHihpUU3DBw5ElpAgAYNixSRJjKjQaECDCRPZPDB5IbIGSQwKLnh4wbInLA4kmJB4oaPiAwVNnER40hRK1BIAaVatUZJEFCkmpmjgCeWDCalFe4q4oFKwSRUrEa5gycLzwq8lUnPQ4PEgSpYcUZ5o2cIlS1O/JHLEDdfjQZMIVrpgweLFy5e+M6WSmBGlxYMYYBRzCaOFi5imHWBIfOEiShLTVjaP6eyFTBmN1TA5OvLDjJksWb58OVMGDRqWjAYdmU79SIvpjqJr104nEAAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+editshred-22:actions actions22 22:photo:22 22:R0lGODlhFgAWAIUAAPwCBFRSVExKTERCRDw6PDQyNCwuLBweHBwaHAwODAwKDAQCBExOTNze3NTW1MTGxLS2tJyanOze1Pz+/Ozu7BQSFCwqLDw+POTi5MzKxPTu7LyyrIR+fCQmJPz6/Pz69Pzy7Pz29OzaxPTu5PTq3PTm3My6pPzu5PTq5NS+rPTm1PTi1PTezOzWxPz27MyynOzSvMyulOzOtOzKrMymhOzGpAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAWABYAAAbpQIAwIBgMCAXDAZFQLBbCqJTRqFobjgdkEYFKowPJZEyeUBqVR/crHDTKZYplovZKCW84+YKZZNZSBXl6EwEEBhVPXxZihGMaGRscdkIdg4QeEnVfCH2OHyAhIhuUAAiXZSEhIyQlJqWnjiEnKCWupRWoYyEgJK0SKaUKjam0JCorLMFfC6iqx8giLa/MGAsT1wsuCyULKwssC9RSzdkfCyALKuALLQsvpeXYIQso3gsiCzALMfENC+dGcMNHUAY/f+jq3ctncMYCGggFrsvHcEGNh/EyPFmg8cmrJxAVkVO0EUDJklHoBAEAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+edittrash-22:actions actions22 22:photo:22 22:R0lGODlhFgAWAIUAAPwCBAQCBERGRExOTDQyNISChBQSFCQiJCwuLPT29Nze3GxqbDw6PGxubHR2dJyanLSytJSWlJSSlOzq7Pz6/Nza3Ly6vFRWVBQWFIyKjMTCxHx6fIyOjLS2tOTi5PTy9OTm5Hx+fNTW1KyurKSmpJyenExKTMzKzKSipFxeXCwqLMzOzKyqrMTGxLy+vHRydBwaHNTS1DQ2NAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAWABYAAAb8QIBwSCwaj8KAMoA8LgUDQsFwQByay4RiwWg4GA9IRGk0SCYJSsUCsVwwGQ1EsmESD5xOp+L5gDwhBRIZDhcDdkMGDgEiIxAkJQ8Ok5MmAohDAQ1xJxUlKCUlEg0pKpiZJRoLCxmtCw1eURhOcR4rbQ8cGRwLAwgGtBYTDywtGRKjvQTARgEZLhMcKC0OrQMvAirMRc7CHCTU1g2+20TO0NIn1RwDCya/wdHT1Rnt5LToKOq79trx0tR02YPX7Jm8fRxMOIhSLhOJE/LCJSTlr5kFEBQsWDiR4UGGBgsuHDg1BEYAfTE6oEBR4AIBAiS5yWBAAAGBAyaPGAgCACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+encrypted-22:actions actions22 22:photo:22 22:R0lGODlhFgAWAIYAAPwCBHRudFxaXExGTERCRAwGDGxubPz+/Pz2/Ozm7Nza3NTS1KympFRSVHR2dNTO1JSSlKyqrKSipDQyNMTGxDw+PLSutKymrMTCxAQCBHRqLBQODJyanDQuFFxSJFRSJFRGJERCHExCHISChHxyLEQ6HGRaJExKHLSmbLy2fOzitPz23KSiZHxuNHxyNJSOTNTOnMTCjLSudKSaXJSKRJyOTOTetNzWpHxuPOTi5MzKzLS2tFxWXOzq7Ly6vOTe5Ix+RLSqdNzSpLyydKyqbKyiZAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAWABYAAAf/gACCg4IBAgMEBQKEjI0GBwgJCgsMDY2XjwkOAgQBDxCLl4QNCaGCBBGWooINCAqqrBKgqwATFKaDFRYVtBMXsIMNGBm0GRADjQIJxKIaGxwdHh8gISIhGyMZzIwkGholJiYfJiAfJyEZISDbg90oKCkqKwcHKyooLC0f7IIuLzD2YMSQgW8GDRri+AFoUMOGvRsxUhSsQQPHvmQSchyQtEAHhh0WJHDQcJERjwsKDvRI0BGDjwgicXhQyCOjSgUKPO6AObIkIQESfmxk6REDT4s0bfaYpDNkT4VAha5s+TLmzEYtatwIOHAiDZIKNQAJYk9IjCFEisyoocFEB4UACtBpm0t3LiEsgQAAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+eraser-22:actions actions22 22:photo:22 22:R0lGODlhFgAWAIMAAPwCBMTC/AQChAQCBISC/PzCxPz+/MQCBIQCBAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAWABYAAARfEMhJKwhi2F0DIRnHeR+oiRRZmqikrmD7wgI6r+EI4+d2l7lNwWDYsTiFw4FI61mSymXxE3xGo8xqBXpVGrQUbveAcG7H0bKowEar12wx2SyMp+lI+7s1ie/5fX8tBhEAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+exec-22:actions actions22 22:photo:22 22:R0lGODlhFgAWAIYAAPwCBAwKDAwKBCQiHNze3AQCBBwWFDw6NPTy9PTy/Dw2NKyytOTi3LS2tMTKzMzOxLy+tLy+vBQODNze5NTS1JyalIyCbIx6VIRyVISGfJyelOTq7EQ+NMTGxKyurGxeRLyKPOSmROSuVOy2XOSiTLzCzNTOzDw+NCwqLHxuVOy6bPzGfOSuXNTW1LSyrMSWRNymTOSmTKSCTPTGjPzSnPzWnMyaVBQSDMTCxPz+/KyahNSeRHxeLJRyTPzmtPzarOy6fJyajNza1Ly6vLyulFRCJPzirPTOlMS2pNTSzMTCvJyenBQWFNzKtPz6vPzyvPzqtOzGlOTe1AwGBFxWTLy6tPTm1PzSpPzutPz2xPTSnOTSxOy2dPzapPzerOzm5IR+dPzu5Pzu1PzqxPzy5Pz+9GRiXGxuZKympHR2bOTm5Pz6/MzSzBwaFJSSjCQmHPz2/AwODAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAWABYAAAf/gACCg4SFhoeEAQKIjIIDBAQDjYMFBoMHCAkKgwYFhwULDAUKCg0ODxCkBQgRnoUSExMUDxUWFxgZGpAbFIuGHB0eHyAhIiMkIB8lJieIKCUpJCTGIyorLCktKIUDpC4YLzAxIjIyMzQ1NhgdpJI3ODktJTowOyM8Ejc9Pj9AQUIEclAocCMIBQhDiOwgoaKIoCI+jBxBkkSJkCWemIyq0GSHCBVHihRx8gRKFCmpKhGaQqWKFYZXsGR5kkXLFgRUXBUqkCGCFS5AjnTx0sXKlyA6CRVgAAHMAilhxIwhU6ZFkBY5kgKYUoXBAzMKzixZ4AJNGgVm1KxhM0WpmQpUMtooaOPGxAM3Nw60oYLGjNYCbzYJOgAnRzNBJ95oPYQCgpJtkwzFoULlRuRPiy9fNhAIACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+exit-22:actions actions22 22:photo:22 22:R0lGODlhFgAWAIEAAPwCBAQCBHR2dDQyNCH5BAEAAAAALAAAAAAWABYAAAJOhI+py90RnIMyRUOxhDfzJkACdoXBuEDDkQFDi5go0MrKx16kns80b7qdELCgBYaEGWwL5nG1ePFiKp9A6kuYRNuho8vxVrrZivmMRtMLACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+fileclose-22:actions actions22 22:photo:22 22:R0lGODlhFgAWAIUAAPwCBERGRERCRDw6PCwqLExOTFRWVHRydGxqbGRiZCQiJISChIyKjHx6fDQyNBwaHJSWlKSipBQWFJyanPz+/JSSlCQmJAwKDCwuLBweHBQSFGxubExKTISGhDQ2NFxeXFRSVDw+PAwODAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAWABYAAAbZQIBwSCwaj8jkMSAYDAgEJbFgOBwQCUOAoJAaFgvGonHIBhyP5BcSgUAYDWxggD4WFmx3e3HQngkSRgYMEBMUFG4MCId0BGlEAQeEhocVDYcUdBYKF0QCB3gRlJgUAQEYBBkaRAMbDZMMpAYcT46rQwMJrgsdC6QcfwoPnUMOBgkIV6SHHg6bw0QEAQYfBpggBZjPGsRD0gEchxwCIR6HChnQRQ8DIU4DTR4Em+ncRw8O+fmoXPXdRg+gQLFgIYM/KRIkoDP4QMKFf0o0aBAh4qGUixgzCrETBAAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+filefind-22:actions actions22 22:photo:22 22:R0lGODlhFgAWAIYAAPwCBBQSFJyanLS6vLzCxISChNTe3OTu9Oz6/Nzy9Nzy/NTy/OT2/Nzi5Mzu9Lzq9KTe7LTq9PT+/Pz+/Nz2/Mzu/Kzm9Jza5HzK1LTi9PTu9IzW5ITO3FxaXNT2/KTi7Iza7GzC1LzW3FRSVMzO1MTq7HTS3Fy6zFS2vKzm7Lze5MTGzHzS5FTG1Ey2xEyyvJze7JzW3ITa5FTK3EymrGS+zFxWXKymrMzi7ESirEyqvLSyrKze7MzOzMTCxKSepAz+/NzW3MzKzBwWHLzS3ERCRAzi3KyurNze3MzGzLy2vLSutCQiJAyytHRydOTe5MTGxLy6tLyqpKyelJSCdOze3NS+tLyupLSmnKSOhCwuLPzy9Pzu7Oze1OzazOTOvMyihOTi5PTm3Pzi1PTazPTWxOzOtNSunDQyNPzy7Pzu5OzKrNzSzNzGvNS6rMyynMymjAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAWABYAAAf/gACCgwGFhYOIiYQBAgMEAwKHiokBBQYHCAkKCwwFAZOEBQ0IDAsODxARCZ6gAAEGEhMSFBUWFxgZCJ+TjBoMEpkRERscGBGRih0BBAgeFBQOER8gISEfIruIIwEkCCUVwhcgJicoKSrZg9srCRkRGdMsLS4vMNiK2wIKMRsbMiwzXtCocSydIBs3AuCIwIFDiBMucugAoWvSiB2VNPDg0ELHwA0MkCXr4aNSggg8NoDIQOFHgBtAkgURMiDAEAFEVBCJFKCIkSMGOyDRkETJEkOFmABoUsRJQkQdnkzQACWKlBtTplBR6qopxkFRJ0ytYuWKFCxZtBBq+hRA2AlbRrh08fLlCxi1a51g+dQhDFwuYsaQKWPmDBpKXgNETaNGjJgyhNfcVdTTiWI2XpK0cePmzRk4YA5T5otGixY0qFOXbgXAQCAAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+filenew-22:actions actions22 22:photo:22 22:R0lGODlhFgAWAIUAAPwCBExOTERCRDw6PCwuLBwaHAwODAQCBOze1NTW1OTi5Nze3MTGxLS2tJyanPz+/Ozu7OTi3BQSFCwqLDw+PDQyNFRSVPTu7MzKxLyyrIR+fCQmJPz6/NTOxPz69Pzy7PTu5Pz29Pzu5PTq5PTm1My6pBQWFPTq3PTm3NS+rAwKDPTi1PTezOzWxMy2pPz27PTazOzSvMyynOzaxOzOtPTaxOzKrMyqjOzGpMymhPTizOTCpNzSzNTGvMymjMSihCH5BAEAAAAALAAAAAAWABYAAAboQIBwSCwaiYGAYEAgFAqGg/Q4DCASCsTiymgcHAcqQLB4mM+QiIQBppLPcMjkwQ4bB2X4maKgt4sVCHpnFhQTElNFE3mDDxcYGRp2RBuMgxwIHX9EBZZwHh8gCBmTQ52NISEiIyQlpUImng8hHyInKAgprwAqgnC0IKwrLLpGB4wctLYkwy0uuwd9Z8AnJywsLcVFx2YcL7UnJCwwLTEy0GXJoSgrCCwzNDTnxgjeH9UrKzXwNDY36LRGhEOwLx4NHDmgJbh3QoeOgv127EhojEeHDj16pEhRQoZHHzl+QJNCsqTJSXaCAAAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+fileopen-22:actions actions22 22:photo:22 22:R0lGODlhFgAWAIYAAPwCBAQCBCQWDCwaDDwmFPSubPzGhPzCfPy2dOSmZPzKlPzSnPzOlPzKjBQODPzChPzWnPy2bPSmXPyuZOyeXIRSLEQuFEwyHEQqFDQiFCweDKRuPFRSTPT29PTy9Ozq7OTi3Nze3NTW1MzOzMTGxMTCxLy6tLSytKyurDQyNMzKxOTm5OTi5Nza1NTS1MTCvLS2tLSyrKSmpJyenJSWlIyKjHx+fFxeXBwaHKxuPMzKzLy6vIyOjHx6fDw6NPy6dGxubLy+vISChCQmJNza3KyqrBQSFLR2RKSinJyanGxqZAwGBJSSlCwqLAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAWABYAAAf/gACCg4SFhoeDAYqKiIeLj4wBjQCMhY+NkoiLk5qbhQIDoJyGBAUGBwgEo4MECQoLDA2pDrS1tKQPEAwHERITE77AvxKqhAQNDA8UFRYXFs8YBAQZGqGPxw0RGxwdHR4eHyAhIiMkJSYnKCgpBAYPEhcqHyssLS4kLzAxMjM0NTY3cBA4UCAHBw8gVnhgEcKFjhc7UPDj0cMHAAI/KFgY4YLFio/jRpTYsW8GDyCSCEQw2DChOHIqgsCQSEPIEEEEJFhAoUNECCJEyOk4d6KIyRtGcB7hIJKjixEjHu4oimSGEIs4d8IIUoKECnNB0ElMwkNJJgBLlJBAcQKGiR07KGAURVGViY0mhIwwSTKjr99+THjUoIg0r48hTRIrRtxkiOMhDgrZCQQAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+fileprint-22:actions actions22 22:photo:22 22:R0lGODlhFgAWAIYAAPwCBFxaXDQyNFxSTPTizOzi1FxORDw2NExKLPTi1Pzy9Pz6/FRWVPz29Pz2/PTy7PTu9OzezPzu5OzavAQCBPzy7PTm3OzazOzKrPTu5FxSRERCRGReXPTq5Pzu7ExGTMS+xKSmpOTKpPTq3JSCDNzSfHRydLyadOzCjOzOtOzSvLyyTMTCxKSipGRiZFROLPz+/KyurJyenJyWnGxmbLSabOzClOzm7LSutJSWlJSSlJyanGxqbNze3OTm5IyGjNTO1Nza3NzW3OTe5IyKjHx6fMzGzMTGxMzOzNTW1IR+hISGhKymrLy6vLSytERGRGxubKyqrLy2vLS2tDQ2NEQ+RASKBAT+BFxeXHRudAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAWABYAAAf/gACCg4QBAgOEiYqEAgQFBgcGi5MICQoLmAQDh5OEDA2YCw4ODxARApKUCaGYEAsSCRMUnQysCwoVEhYXGLOLCBCgDqK5GQUXGooCAhscBB0euBUZEAUJvQgIgx8gIR8iCSPiHuIFEREDJCXaANwhJhsnKCnWERcRKiopFCvsBywhQrRwQWGAPAz5EhpQ9wIABRgKYsiYMTEEDQocatiwkUIEP18fbkCAAcMBjhwzdOyQwYNCgBMfKJSgMItBjxs+btwgCSGGjhw/ZoRgQKGZCRMUPgABEgSIkCE3SZok8qNqkR85NtDUEcPIkaVAkCR5SrJBDCVKlmzQ6pCCiRlMTJo4YUH3K5AeMBYYWctW0BOaUH60cBJFypQmII6wyEpFQBVFMSm4UAI3hJUrOGh8oOJrklYKWIromJGDR99Ogz5j4ZGlM+pEnwmBCwQAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+filesave-22:actions actions22 22:photo:22 22:R0lGODlhFgAWAIUAAPwCBGxqbAQCBLy+vERCRExKTHRydIyKjMTCxFxaXGRiZFRSVFRWVPz6/Nze3Nzm5Pz+/JyanDw+PExOTHR2dMTGxBQWFLSytHx+fISChOzy9Ly6vAQGBJSWlMzKzAwODJSSlHx6fIyOjOTi5DQ2NISGhGxubCwuLOzq7ERGRFxeXNTW1CwqLPT29Dw6PGRmZKSmpAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAWABYAAAb/QIBQGBAMj8ikUDAgFAzKKCBwQCQUCcICKh0SEAhGw5EIZAmBrgCxeDQgcDJWyz0GIggJfL+XGwQJRxNgC3yGDwwUFUZDFhdthnwMGAZNQwEZFwQakXANBBQbHIIdERIBnRAOiR4ERx8gsSEMBBmGCyEGG3YGBwcgIr8UCwQHECOgG4xCtRkEJAvBJRklJgkSFBQeJ68hJiEoESkFKiEZIbkGARsLlwEGExENGhorGSkpFAYm66NDLAECpGiBYsUIFA8wLHBBQMWLVkdUCFCwaYVFBOymkVCgYEMgOykEpICBccMBAhhELFigTEqAAgIIwCiQ4eRKDyS6EAlJIAI0EpaudF4iIKDAAn9CkRT5eMROEAAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+fill-22:actions actions22 22:photo:22 22:R0lGODlhFgAWAIMAAASC/AQCBMT+xASCBMQCBASaBPyChASyBATCBPwCBARmBAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAWABYAAASCEMhJq704axB2DkLnVeAwiCNHDMWZcsbaul5ZyCaKBcZwFDcgDRNbHX7AmW4SMx2MSOFQQlitEAhosrVcDQQE7NMXzVGqA6xAgCUckabQpJoIYBFsxBspUKBiHQEHaoNvBQJTgBIBdnh5B4hLihONeJBTc0uMaphMS4uRGQYfny9EEQAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+filter-22:actions actions22 22:photo:22 22:R0lGODlhFgAWAIQAAPwCBAQCBAwKDMzKzMTGxNTS1MzOzAQGBLS2tLy+vKyqrLSytLy6vMTCxBQWFKyurCQmJBweHAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAWABYAAAV7ICCOZGmeaHoGbKuOAjsQhVG764EgyT7YhaCBVQogFMhFImEABoUBknFxRDAazac2Kg00djystkA0sQ4BgzgYK6+Ch/bBseOmAmMD4gF5ifBCDwoRfiOABgyEhYYFCA6LUo19kH+Nj5QAaQh2kHibmJkFBJydpKCnfnYhACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+find-22:actions actions22 22:photo:22 22:R0lGODlhFgAWAIYAAPwCBBQSFJSWlFxaXJyanKy2tLzCxDw+PHyChNTa3Nzq7Nz29NTy9Mzu9OT29Nzi5Oz6/Mzy9Kzi7Jze5Lze5Nzy9JyenIyKjHR2dMTu9Kzm7JzW3ITW3ISChGxubERGROz+/Lzq9IzW5HzK1LTm7FRSVHTS3GS+zLTS1DQ2NMzOzMTq7Lzq7ITW5FS2vMTi5ExOTKTm7EzCzEy2vEyutJTa5FTK1ESirGy+zMzi5ESerESmtITa5OTy9KTe5KyqrAz+/Azi3ASutERCRExKTFRWVAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAWABYAAAf/gACCggGFhYOIAAIDiYUEBQYFAoeJAweKhAgJCgsLDA0OCAGJg4wBCA8QDhENEhMUFaKDFhcYgwEJCxAQDBkaGxwSFaMAFh0eAx8AAQIKECAODCEaIiMjJJMAtQMlygEGEBkVva4mJycTKKMYJd0pyyoOKyssGhMtIycuGi/EMB/vlhmoQEFDjHsmZMygUUMdqWUCGgCbYMKEjRk3cEjI9jBADg3Wzs3QsYOHA2IdO1SQkI/GjRMtFhBA2RFBDwk+OASrMPMHkIe3AhBA8QLFzAAHgvyg2dEQMSEHPCwltQgooSFSmVpSxKjjh6wPtwINgHVqsVpWESEFeywZ17RkED2s40YEgFirlIq4SwvUQCAAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+finish-22:actions actions22 22:photo:22 22:R0lGODlhFgAWAIUAAPwCBAw2VAQCBBxCXDR+nIS21Aw+XJTC1Nzu/KzO3Pz+/Nzq9Pz6/MTe7KTW5FzC1Nzu9CRKZMzi7IzK3Lzi7LTe7HzG3Gy+3AyuzAyexFzC3DRSbHy+1Dy61CSqzAySvAyStLze7IzO5AyGrEze7BRmjCTC1ETS3ETa5BTC3Bx2nAyWvAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAWABYAAAakQIBwSCwaj8hkMqBsBgTN5IAAJQqqykCBasUmDQcEV3gtBs7oATihGJeJgcOCQWc0HA8Ig/seRiQTFAsVFhcYGRp6VH1CGwscHQ8dGB4fIBkPIWKMAAMLIiAjIJcgH5gkGSWcARIiJicoJikpHikoHqqrKiW8JSogKymoqgCrV8cCARgkuFWcRwYeqVjPRgEExEPVRQbZ2l5IBuBRQ0zk5+hRBkEAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+folder_new-22:actions actions22 22:photo:22 22:R0lGODlhFgAWAIYAAPwCBNzaTPT2FISCBCQaDPz+BExKBDwmFPSubPzChPzCfPy2dPz6BMzOTAQCBOSmZPzKlPzSnPzOlPzKjBQODPz+rPz+3PzWnPyuZPSmXNyaXPTyhISCLIRSLEQuFEwyHPy2bKRuPFRSTPT29PTy9Ozq7Pz+xJyanDQyNPzGhMzKzOTi3Nza3OTiVBQWFDwqFKxuPOTi5JSSjISChHR2dGRmZFxeXPS2dNTSzNTS1OTm5KSipLS2tLSytKyqpIyKhGRiZNze3NTW1MTGxMTCvLy6tIyKjCQmJMTCxMzOzMzKxJyenHx6fLR2RLy6vJSSlHx+fDw6NLy+vIyOjAwGBGxqZKyurCwuLBQSFJSWlCwqLAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAWABYAAAf/gACCg4SFhoeIiYqLjI2MAY6HAgOHBJYEhJCDBQaDmgcICQoLB4MGDA0OAQUBDg2cAAcPEBESE6QUuQasFRYVq5SxCRcSCggYGRjIGgYbFs8bHIMHExIJGR0eHx7cB83PFhsDDuTUEyAhIiMjJCQluwEmvsAnKAcp1x4qKyUrLLupWrByxcnFiwQIYIggEaNEiRgBZMyYQaNADRs2REA6cCODBxw5+OnQgWMHjx4+BND4MQOIg1gI0gUREkTHiplDhhApEoCGkRlHBL3I8MEHEhz+WAhJogTJySVMfthwIehAExE5jubAkYQpESc8fOx4AiXKNA8+ekhBgqSpzh5hPHcsmVLjpSAqVZBY6VGkiJMiPQKLnTvjCiEsWU4o3nGC8YksMmT8YCmC6iAXKLRc2cz5yGYtR0JjKWQgEAAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+forward-22:actions actions22 22:photo:22 22:R0lGODlhFgAWAIUAAPwCBAw2VAQCBBxCXDR+nIS21Aw+XJTC1Nzu/KzO3Pz+/Nzq9Pz6/MTe7KTW5FzC1Nzu9CRKZMzi7IzK3Lzi7LTe7HzG3Gy+3AyuzAyexFzC3DRSbHy+1Dy61CSqzAySvAyStLze7IzO5AyGrETa5ByixBRmjCTC1ETS3BTC3Bx2nAyWvEze7AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAWABYAAAaYQIBwSCwaj8hkMqBsBgTN5IAAjRoDBaq1aDggtMuAWDzoJhTgY+CwYLgZDccDwkgXI5IJZVGxXDAZGnR2QxsLHB0PHRgeHyAZDyFfVUQDCyIgIyCPIB+QJCUmlEMBEiInKCQnKSkeKSQeomoqJrUmKiArKSwZsmoCwMEBGCyxo1EGHr3HUQEEvltCBtDRAAbMW0zV29xDBkEAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+frac-22:actions actions22 22:photo:22 22:R0lGODlhFwAWAIIAAPwCBAQCBAwODAwKDAQGBIQChAAAAAAAACH5BAEAAAAALAAAAAAXABYAAANICLrc/iwEJSEUQA45LcOKMHWeU5XWiUYZsZClOIjj+naqrS9F7/9A326YCYBypREOpMPBVifjkBRw7SpIG+eJIg2IWC5UikoAACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+frameprint-22:actions actions22 22:photo:22 22:R0lGODlhFgAWAIYAAPwCBFxaXDQyNFxSTPTizOzi1FxORDw2NExKLPTi1Pzy9Pz6/FRWVPz29Pz2/PTu9PTu5OzezPzu5OzavAQCBPzy7PTm3OzazOzOtPTu7ERCRGReXPzu7PTq5OzKrExGTMS+xKSmpOTKpPTq3JSCDNzSfHRydLyadOzCjOzSvLyyTMTCxKSipGxmbOzClFROLPz+/LSutJSWlJyWnOzm7JSSlJyenOTe5OTi5MzKzASKBAT+BNzW3OTm5KyurMzGzMTGxMzOzNTW1KyqrLy2vERGRGxubIyGjLSytGRiZISChAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAWABYAAAf/gACCg4QBAgOEiYqEAgQFBgcGi5MICQoLmAQDh5OEDA2YCw4LDxARApKUCaGYDwsSCRMUnQysCxUKEhYXGLOLCBCgow4VEhkFF6mMAhobBRAcChUVGR0FCR4UCAiDHyAhHyIJCRAjHOUJEREDJCXcAN4hJhonKBjXESn5Kdkq7wcrQoRg0YLCgBMuRFxIwTCFgXYvAFCA0SCGjBkYQxQMUE8EBhEUVPj6QOMBDBgLLM6oYYMFhYkvYcSkwOAGDho3TyqIUaPGyZ9AKXzIoWMHDx44bvQ4+WAi0KA1fPwAEiTIjyBCkDp9KlMiBRMzhhAhsqLsD64/fQEo8tLIERZIH8Ru5arow8skSmTMDdpJQ0y0XTsJ2gtU8GCZMBMbCAQAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+funct-22:actions actions22 22:photo:22 22:R0lGODlhFgAWAIAAAPwCBAQCBCH5BAEAAAAALAAAAAAWABYAAAI+hI+py+0PIwhUohpMXfl6103h1nTUNproEU6am62v1pLsPX/siO9Jiou9TD2XyHfMGUs65aVmiUqn1CrCUAAAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+gear-22:actions actions22 22:photo:22 22:R0lGODlhFgAWAIUAAPwCBBQSFCQiJERGRBwaHFxeXHx+fDw+PGRmZExOTGxubKSipDQyNHx6fIyKjJSSlJyanISGhISChLS2tIyOjHR2dAwKDAQGBJyenAQCBCwqLLy+vKyqrAwODMTGxKyurFRWVLSytLy6vMTCxMzOzGRiZNTW1CwuLMzKzFxaXJSWlOTm5Nze3Ozu7OTi5Ozq7GxqbDw6PHRydAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAWABYAAAb/QIBwSBwGBMVkMjAgFAwHBFJpPB4SiQJCsWAQqEJB4prdNhQNx7QYIFwLD0ikQZdMHgelOPGYULQVDg4QEAVfRAEBBwUTEE0WFwcYhAuNF0QDBQULDwwZGUIaEAuVGxgBRAIFEhwHHUQMCxwTHAVrAAwFFRwKFkQZsxseDqBDGXMSHwfFQiAhIiMeJApEBwcOcahDJcLSJCYcGkQKcRAnQhkF0SgmEykHXkObox8q1iEjKN8rENqYD7MmeBCmzwSLFS1I3AqzYIPDESS+sWCxgQMLEgOSJKjozeAKFyskCDigQFwSBhJMjDDhAlyLFyVA+dIzAUUKEi0eaNhAIg8YGiEMenkwASNDDBkLqRQAEEAkup9KDkEFgC4IACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+gohome-22:actions actions22 22:photo:22 22:R0lGODlhFgAWAIYAAPwCBAQCBCQiJNze3ERCROTi5MzGzLy6vDw6PKyqrKyurBQSFGRiZGxqbGRmZISChEQ+RExKTExOTHRydDQyNOTe5FROVLSurCwqLMTCxPT29Pz6/LSutFxeXLyytLSytPz+/JSWlKympPTq7KSipNzW3BwaHHx6fKx2VJRWNHQmBFweDOzq7Ly+vNTW1JxWNLSajPTe1Ny6pKxWJNTS1IyOjJRmbPTi3OzKrNSSXMSGVHQiBHx+fJSSlPzy9IxOVOzWxOSyjNSCPLxeDJyWnIRGTOTGtMxmDLRWBHwqBIxGTLRSDDQuNNSunKxKBGwyNMSafMxqHMReDKRGDPTu9LxuPLxaDJQ+DIR+hGQqNIQyBGQiBNTO1EQKBAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAWABYAAAf/gACCg4QBAYSIiYQCAwQCiokEhwACBQYHBAiQhAiHlQYJCgkEC5uCkp8MDQ4NDwylmwgQlgQRERIEBBOkmxQVBgQWFwUFFxEEDLyJGAUZtQoFGhsFHLYdyoOVHsEf0SAbIAUex8mwlAUhtSIFG+3uIyTWvAIGJMEkJe76GyXbEeWUBJg4USKaBhQpVKzYoIFFiwYUBBJa8MAFCw0vYMSQMWOhBhoTKCQSUKMEiw02buDIoWOHBg0GeIhEFKAHDR8afgAJImSIioYliMws1MPkhiJGchxBkmTDCBo1hg4KQMTiBiUyhBxZ8pNFiR5MEtU0WqSJVidJNDyNKraHC5xPNKBEkTLlJ5WvUgWNvfikyhArV34+7ZEXQAAsB2iUyHLlihYtW0pwOYAFgyJDmDNr7jIIWiAAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+goto-22:actions actions22 22:photo:22 22:R0lGODlhFgAWAIQAAPwCBBQSDAwODAQCBCwiHDQuJExCNFRCNAwGBDwuJEw+NFxKPBQODEQ6LFxOPEw6NCwmHDQmJBwaFCQaFEQ2LCQeFDwyJBwWFDwyLDQqJAwKBAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAWABYAAAWSICCOJBkEQqmWA1EYR4Gsq5Aoy2EYKU0yDcPCkSP4SgShw2FoDI6jQeNxYD6MUBFCEXxAelkRgxCRhEWQiW/wXE2CataAUmiXKo+Fwg6YWxQWfCQEAxckUgoYDRSCR4gKB4ZnFVwUCgUMZ30KCRQUhJpzBRQQjUcSnmyaM32mPgQNmZpRBwmSsxAZBBqzUa4iBiEAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+help-22:actions actions22 22:photo:22 22:R0lGODlhFgAWAIUAAPwCBAQCBCQuNBwiJAwiLAwaJAwSHAwSFIy+3ERynCw2PCQuPAwmPCxOZCxWdJzG3FSazBwmNAQKDAQGBDRmhBQyTDxujDR2rIy21AwWJDyGxCxmjAwmNDRihAQOFDxmhCxunBQWFAwaLCRahDR6rESGvDQ2PCRWdDRunDSGvCRSdAwWHCwuLDSOzHSmxDyKxBxCZBwqNHSu1DyOzAQSHAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAWABYAAAahQIBwCAgIBAPCoGAgOoeBAyKhWCwYDUf0CX1AIhLiJEGpBLiAAaRxdgYsl7Ybk8igBZoN5xmAdDxoanp8HyANISF8EBsiXBMjJBolBEQmGHFoRScbKHIKDykqK5lFAZRCnyknTaROLA8tq61OChgtKqyzQgEYEJi6UC4vI3LAASkbMBPARAEBdszR0sACEaPSMTIQM8W6KzNl3bo0NOJDdEEAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+int-22:actions actions22 22:photo:22 22:R0lGODlhFgAWAIIAAPwCBIQChAQCBBwaHAQGBAAAAAAAAAAAACH5BAEAAAAALAAAAAAWABYAAANJCLrc/iDAuYKlU0r8NHfXB24iEyrCIAjAynakQLQuDS+vrTcnI1M9HyaIykFOKwUhZ6zEWC5oU9GrRY+kkqdUiXCdWW74SzYkAAAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+leftjust-22:actions actions22 22:photo:22 22:R0lGODlhFgAWAIAAAPwCBAQCBCH5BAEAAAAALAAAAAAWABYAAAIihI+py+1vgpy0Tohzs1T7z3CiBJbQWJnqg4rre7jwTBtGAQAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+locationbar_erase-22:actions actions22 22:photo:22 22:R0lGODlhFgAWAIEAAPwCBAQCBPz+/AAAACH5BAEAAAAALAAAAAAWABYAAAJChI+py+0PX5i0VmbzVboHPgmCJVoJJY5haR5VGsCa+6ZqZ2Sy95E2n0OVdi2A8EacIIS+YpC3WUIpi6kygs1qsYYCACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+lock-22:actions actions22 22:photo:22 22:R0lGODlhFgAWAIYAAPwCBHRudFxaXExGTERCRAwGDGxubPz+/Pz2/Ozm7Nza3NTS1KympFRSVHR2dNTO1JSSlKyqrKSipDQyNMTGxDw+PLSutKymrMTCxAQCBHRqLBQODJyanDQuFFxSJFRSJFRGJERCHExCHISChHxyLEQ6HGRaJExKHLSmbLy2fOzitPz23KSiZHxuNHxyNJSOTNTOnMTCjLSudKSaXJSKRJyOTOTetNzWpHxuPOTi5MzKzLS2tFxWXOzq7Ly6vOTe5Ix+RLSqdNzSpLyydKyqbKyiZAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAWABYAAAf/gACCg4IBAgMEBQKEjI0GBwgJCgsMDY2XjwkOAgQBDxCLl4QNCaGCBBGWooINCAqqrBKgqwATFKaDFRYVtBMXsIMNGBm0GRADjQIJxKIaGxwdHh8gISIhGyMZzIwkGholJiYfJiAfJyEZISDbg90oKCkqKwcHKyooLC0f7IIuLzD2YMSQgW8GDRri+AFoUMOGvRsxUhSsQQPHvmQSchyQtEAHhh0WJHDQcJERjwsKDvRI0BGDjwgicXhQyCOjSgUKPO6AObIkIQESfmxk6REDT4s0bfaYpDNkT4VAha5s+TLmzEYtatwIOHAiDZIKNQAJYk9IjCFEisyoocFEB4UACtBpm0t3LiF4gQAAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+lsub-22:actions actions22 22:photo:22 22:R0lGODlhFgAWAIEAAPwCBAQCBIQChAAAACH5BAEAAAAALAAAAAAWABYAAAI9hI+pe+EPHTNhgjox04srn4CI2FgkZaaZurGd+5nRfAiCYVuJzfN6jbvdfrshEZE7ApNGXa+nZDaVVIOhAAAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+lsup-22:actions actions22 22:photo:22 22:R0lGODlhFgAWAIEAAPwCBIQChAQCBAAAACH5BAEAAAAALAAAAAAWABYAAAI5hI+pF2G9YpszKgcgtgtyuX2I44UcRYkM5qmWAMcyzAn1/eKRnfe7vuD9fEGgQlgkHo2JmRPpStgLACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+mail_forward-22:actions actions22 22:photo:22 22:R0lGODlhFgAWAIcAAJR6fIxydIxubIRqbIRmZHxeXHRaXHRWVGxSVGROTFxGRFxCRFQ+PEw6PEw2NEQuLPwCBJR2dLyijPTixPz69Pzq3Pzy3Pzu5PTu7Ozi1LyelOzavPz+/DwqLLyafPTmvPz67Pz29Pzy7LSWlPzmzPz6/LyajPTitOTSzMyurPz25PTatPTi3KyOjPzuxAwqVDQiJHxiZPTetKySlPzqvPz27BQ6bAwmTPTexLyinNzGxDRunPzy5KySjCQ+ZNzq9KTO7JzC3Nzq/Ozu/LzW7FSm1BR6vGSWvFyq1AyGxAxytAx6vBSKxAxSjMyujLSunES+5BSi1ByGvAQCBNzCrOTaxNTOvMS6rKyelCx6rBx6tBQKDOTWvPzu1PTq1OzezAQOHAxGdBROhAQGFPzy1NzOvIRqXLyynOzarPz21Jx2XPTWrLSShAw2XKSCbPzuzAwePAQCDPzyzPzqzPTmxOzWtAwGBKyObOTSrNzGrKyGbOzatEQyNKyCZOzWrOTGpNS2lCweHCQaHCQWFBwSFBQODAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAABAALAAAAAAWABYAAAj/AAEEEDCAQAEDBxAkULCAQQMHDyBInBhBwgQKFSpY0HgBQwYNGzh0mDhRAAUPHziACEGBpYgRJDiUGEkSwoCQJk6opNASRQoOFETQJDkggwoOJlYApcCihQuVL2DUhBDjhIqjJmRwwDCDhswaNm5MjYHjKggOOU7o0CGTA9gdYknG2KCCBw8VJVL0uBgihAUfP+CSNGCjsI/DiBPbAMJBsEQbQYQM+UG5smUiRYw0jlvYxhEkSYyIHm1EyRLTTH40EZvAyZPOR4pAmU07ipIkUKQ0mQIhAZUqVq5gKXzkSBYtyLVEyd1ki8QFXLp4+WJFQowbYLJnD5NbzJiJCjaQnhnvpYwZM0/OPFlvQ/f3iQvQpBlvQc0aCWy4VKnCpY0Y5yQxgEYXZFjghgwZUOHGCW90YQEccUwloBwGyjAHHXUoSAMZb0xhx1QOoMHDHSfIwSEOdTjhAQ1d4MFbTQ6Q4MYacrzxhhx04JCHHhvQsMeLJPHRBxpr+LHCGnusgccfgKixQR1ATtTBlDDAEIggggxCCCGFbLGFHVFKZEdAACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+mail_generic-22:actions actions22 22:photo:22 22:R0lGODlhFgAWAIYAAPwCBDQyNCwqLCQiJBwaHBQSFAwKDAQCBDw6PPz+/Pz69Pz27PTy7PTy5PTu5PTu3PTu1PTq1PTqzOzmzPzuvOzitPTmvOzivAQGBDw+POzevPz67Pz25Pz23Pzy1PzyzPzqvOTavERCRKSilPz21OTevIR+ZExKTOTi3JyanLS2tPz6/Pz65KyihJSKbMS6lExOTNTW1JSWlJSKZMSylNTOrNTKpFRSVPz29MTCxPTmzKymjIyCdOTWxOzexOTWrBQWFFRWVOzu7MzKxJyalOzatLSulMzKtOzmxOTarFxaXKyqnPTmtIyGdIR+bOzetOzixBweHGRiZOzm3NzWzNzSrOTetGRmZOzizOTexOzm1JSKdGxqbHRydJySdHR2dOzapHx6fKyijOTixCwuLHx+fFxeXERGRDQ2NAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAWABYAAAf/gACCg4SFhoeIiYqLAQECjwORAwSUBZYFBpkHmwgJCgsMDA0OD6UQERITFBMVFhcVGBkangq1ChsLGxwcHQ0dHR4fICEGIiMSCbS3uLq8wCQUJSYGJygpKhQJKyvLLM4Nwi0uLwUwDQsxMtmeuQveHR8UMzQ1NgU3Dgo41jk6ns0cKOzgYaOHjx9AgjTAUUvIECLZNmxoUISHkSM9KiBJQkCJA4kKEoBQoWJJAiYtmjh5AmVCsCJRpHzckKCCySlUUvBYUqUHDysSPnxIEuXKA5pPRiRwxwFLFhRaIEDYUoEChCcDuECoOWKFuwW7nHkg4WELkw8/BHRRwESpt10dU8SSHevlRxIBX6C0WBE27q8GZMkKbTADjIAwYlb4GLMYShYoPTRo6FGiSJEKPyzMIFMmzJcvXbhwkSLFjJkbQW6cOHNGhAgEAdAsmk27tm0ABgIBACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+mail_get-22:actions actions22 22:photo:22 22:R0lGODlhFgAWAIYAAPwCBBQ6bCQ+ZAwePKTC5Ozu/NTi9GSWvAwSJGSu3JS+5CR+rAQOHPTy/AyKzES23AwOHCw+bOTq/BR6xES+5AwmTBw6ZMTW9Ax6tByi1BRGdAw2XAQCBDQuNDRupKzS9FSm1BR2vBym3EzC7CSGxBROhNTW1Pz+/OTm5NTO1AQGFNzW3Ozq7Ozm7IyKjJyWnMzOzNzq9Nze3OTa5Ly6vCQiJGReZISChKyqrAwqVBRWlOTi5MS6xJSWlNza3OTe5Ly2vGxmbKymrIyGjMzGzISGhKSepCQmJDw6PHR2dJSOlPTy9MTGxLy+vLS2tMzKzLSutMTCxLSytKSipJyenKyurJyanCwqLCwmLCwuLAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAWABYAAAf/gACCg4IBhgIBA4SLjAABBAUGBwiNlY4FCQoLDJaNAQ0ODwsQnYwREhMUE5ylFYYRFhcYGRgaGxsDHJUdFR4SHyAhEyIjJCUcuo0cJr0nExihxgwoyYscKSnMHicOIw4lKissLdWDHC4vMCu9McYqMjMyNOUANTY3OPEoOTolDCszdrSgwaMcBxs9TMxYOCMHBx8zfPj48QNINQ5BbMBIIUShDIUoTAhR94PHPEEHbQwZckOGjBQviMxYUWQIDCMmdXE4gqRnkiFETAxR8iKFjJU2evZEdmLJkgJIbqS4wXJIUapImj5FtuSEVyRVV1IVi4RIChhEkLVAgcJHEqVwVJUmYdKkiRNkALMRecKECRG/ff8CEQJFCA5kMKJEoUHDCQ/HkB9LmWKECpUeyKoIMSLEyosen0OD7iH2xg1dV7BkqXGlBpbWNTq4Zn2khu0aAAwEAgAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+mail_replyall-22:actions actions22 22:photo:22 22:R0lGODlhFgAWAIcAAJR6fIxydIxubIRqbIRmZHxeXHRaXHRWVGxSVGROTFxGRFxCRFQ+PEw6PEw2NEQuLPwCBLyejPTixPz29PTu3Pzu5Pzy7Ozi1LyelPTavPz+/DwqLPz67PTetPz69ERCRLSWlPTmzPz6/OzexLyajPzqvDw+PDQ2NMyurDQiJPz23PTatJyenAQCBPTevPz25LSajOzq7HxiZPTexPz65JyanBQ6bKSmpBwuTOTi5OzaxBRCdHySvGRiZHx6fBQSFERGRNzq9IyOjHx+fGxqbPzu3BwaHFSq3Aw6XAxKfPzy3Gy63ByWzJzO7Mzi9OzavBRytAx6vCSazGRKTPzy1AQKHBRGdBRyrDy63ES+3Cym1CR6rBwWVAQSLAx+xCyCtBRmnPzuzAQWLAwePPzyzKSCbAQOJByGvOTWvPTmxBQODFQ6PPTWrPzqzOzatAwGBKyObLSWfPTivKyCZEQyNKyGZOzWrOzWtOTSrOTGpNS2lJx2XDQmJCweHCQaHCQWFBwSFBQKDAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAABAALAAAAAAWABYAAAj/AAEEEDCAQAEDBxAkULCAQQMHDyBInBgggoQJFCpkzGjhAoYMGjZMpMghQgcNFjh4mODhA4gQGkSIHAmBwAgNJEpo8KDSxAkUGjhMSEGz5gUVIiKs2PmBRQudHiwQpUnAxYsXImB0aBqjBcuoU0fKmPGChgUNH2qIqGHjg9u3bicWIFs2rYgbNnDkyGFhb8cccQ3ouJqWQo0dPFr0WMy4h48LFj4gsKriB5AeNngEaSGks+chPnwQOXFAh4oXRYxk9nAEyY7XO2wksWHDx5ATCDIoUXEBsYclTJo4cWJhuIjhSXacSPBEiZLMQY4wgRKluvXqUpyIsDElAxUqVaxcwcGCPQuWLOixaNHCZAsXBU+oqKDSxQqULF6ifNmyn/8VMOtxwcAK36kQRhdJQIFFEmKM4eCDYGyhhYAEkqFEGSuYYcUZLaDxXRpqSNRCEu6twYaFZXTQhgRd2NCCG9918AYELTjoXgNuKAFHB2RQEUYHVbQQRwlUpPHGGFwkyQUEDsgxx4lh9BhCBy2U8UQJcrSg5JIQ0FEHG3bc0QGYK+CRhx57PEGlkhM9sAEffKTQhx9+/AEIIIGoEUgLLRRFR0AAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+mail_reply-22:actions actions22 22:photo:22 22:R0lGODlhFgAWAIcAAJR6fIxydIxubIRqbIRmZHxeXHRaXHRWVGxSVGROTFxGRFxCRFQ+PEw6PEw2NEQuLPwCBMSihPTixPz69PTq5Pzy1Pzu5PTq1Pzy7Pzu7Ozi1LyelPTavPz+/DwqLLSajPTetPz27LSWlPzmzPz6/PTexPz67Pz29OTSzMyurPz25LyajBRCdPzuvDQmJOzexPTevOzq5BQ6bBwuTDQiJHxiZPz23Pz65LyinPzmvBxCbHySvAQCBOTi3OTq9CweHOzaxFSq3Aw6XGy63ByWzJzO7Mzi9OzavNzq9BRytAx6vBR6tPzy3AwOHDy63Ax+xCSazCym1CR6rBwWVOzizAQSLES+3CyCtBRyrBRmnGRKTPzu1MzGtAxKfAQWLAwePPTizMy6nByGvNzWxOzWrNzOtBQKDJR2ZNS2lPTmvBQODPTatKSCbOTaxLyqlAQKHFQ6PPzyzPzqzPTu1PTivOzWtKyObPzuzOTOtLSWfPzqvAwGBKyCZPTWrPTmxNzKrEQyNOzatOTGpJx2XCQaHCQWFBwSFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAABAALAAAAAAWABYAAAj/AAEEEDCAQAEDBxAkULCAQQMHDyBInBgggoQJFCpYuIDBQgYNGzh08DCR4oQPIDqEmDBhJQYRIzqQIFkSAoESJCKkDGFiwgkUKTpMwECz5IASKjqsSMlSA4sWQjG4qGnzhYoQSmF0iCFjBgmWGWhQrVHCxg2sOHLo2MGjB0sLYmsWQHq1p4wdPtqemGDhB1UDQFSouKHi7oQgQmSwUMyYxcQDZQWz2EFiCJEiRoyQyLzZyGIIB47YKLwDSRAiSZSoXq1kCRHNLBK8YGKjCYskTp4ogeKkt+8oUaBImZKAAxMmVKrctqL7ihTnz7FkAT5FC4cKFbZwadIFdxcvX8KLss8iJcoUBUcq2KgAJoxyMTy4jCFTxoxEHl2GLyCDncmWM2hUIQMPY2CXhhoTfTEcA2tgVwEba7Thxhs88FdBD/ZB8MUUHMJBRhw2sAGCHBKU4UaFc1RAhxnhcdhhHUzYAUIcFdxRAh4R5KGHinu4OIVEDqTBRx81xhGHHzD8wQYQetDRI4cTAcIHGWT0EQgZa1ApCBqDcBAID1Q94IEHLtBAAyGEFGKIIWqYYQYPYNZkQEAAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+mail_send-22:actions actions22 22:photo:22 22:R0lGODlhFgAWAIcAAIR6fIRydHxubHRqbHRmZGxeXGxaXGRWVFxSVFxOTFRGRExCREw+PEQ6PDw2NDwuLPwCBLSijOzixPz69PTq3PTu5PTu3PTu7OTi1KyelOzavPz+/DQqLPz67LSafOzetPz27Pz29KyajPTmzPz6/NzSzLyurCwiJPz25Ozi3JyOjPzuxBRGbAwSHOzexPz23KSSlPzqvBROdISavBxSdAwaLHRiZLSinNTGxMy+vBxGZNzu9BSGrAwWJMSyrKSSjFy61ETO3BRWfPz65PTqzHTK3ByqzBSWxEzW5AQWJOTWxBRCXOTu9BSOvDzO3ByavBRKbOzaxOzizKSWlCQ2TAQCBJza7BRWdNzSxJSCbMzq9BSOtCSKrAwiPOTavPzy3LymlCySrAwmPFRKTPzy1NTGrPzu1JR+bOzatPzyzCy61ByGpOzWtJyCbPTmvPzuzIS+3FymxCSuzBR6nJyCZOTWvKSObMSujOzivAwKDOTSrNzKrJyGbDwyNOzWrMy2lIx2XBwWFBQSFBQODAwGBAQGBAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAABAALAAAAAAWABYAAAj/AAEEEDCAQAEDBxAkULCAQQMHDyBInBgggoQJFCpYqMDxAoYMGjZwmEixg4cPGzqA6BBiAggRIzaQGEkSwgAMJCKgnNBhQogSJlKGOFHTpgYUG0TsnJBCxQoSE1i0KErAxYsOJJRuuAAjhkwZM2jUqGnDBQoUHTbciIEjx4YNOmbs4CGjB8kCZlGAALHBx4+YcTcACcJDyFSJBo6iGNIhhQkiG8BOKGLkCBK6SSQisHoWhZIbG5bMYALECI8mTZw8gTL1QJQXZ6VMiUylSpUlVpoYaXLFtm0EGmCjwJLlA2O9MrRsccKlC8kEXr7AdgEmwtkhX2SQ2BIkjBiSYzSQr/nyhUKZLIrJJOcexvlEBV7IvCBjRkmAMzHOaufhxDvJBWiQISAFxUUQQRovJNeEGmu4JxEDbKQhXxsfuFDGGW68IQMcccgxRxUkNRDhC3R8QMQIdZwXQ11JJGFbiB+QYccHaaTxhgt13OFBDGTgkUdRDrhAhx5k2JjGCB/swYcXMXwAYk190OGHHx/4wUaVepTxByAaoPEkSQ5wwMEJZAZipiCDDJIHIYV8OZEdAQEAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+matrix-22:actions actions22 22:photo:22 22:R0lGODlhFgAWAIAAAPwCBIQChCH5BAEAAAAALAAAAAAWABYAAAJHhI+pyw0Bw4sTVmmw1C/3/20ex2VUtJ2Uwx7oBb9eR45ziNfgy6tW2+pZhJicjXbTiZA7X2q4AjqIsajSuDsuty5n9SddGAoAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+message_get-22:actions actions22 22:photo:22 22:R0lGODlhFgAWAIYAAPwCBFxatHx+/Hx69GRixFRWtHR29FxaxHx6/Gxq9ExKxGRm/FRW9Dw+xFxavFxazFRS1ExO9ERC/DQy5CQmzBwaxBQSpCwqLMS+xBwatExK/DQy9CQm/BQW3AQCjJyavAQCBMzGzAwOtDQ21DQy/Cwq/BQW9AwK5JSStOTi5AwKDKyurMTGxLS2xISGpNTS1IyKjJyanMTCxAQC1MzKzNza3MzOzCQiJGxqbHx6fKyqrLy61NTO1JSSlNTW1NzW3Nze3HRydKSipISChDw6PLy+vFxaXPTy9ISGhPz+/Ly6vLSytJSWlHx+fCQmJAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAWABYAAAf/gACCg4IBAgIDBISLjIWHiY2RggWHBgeSkYYICQqYjQUICwwNnoMFDg8QDBESExQVFpgXGBkQERoSGxwdHh8gkiAhGCIjJCUmJx4oKb+NKissIS0iHcgeLi8pzI0gMDEyLzIiM9c0NTU2zYQ3ODk6L/A7yvDnPBjqgiA5PTYvPvU+fvh4AeQFDXwgggTBwEIIOB8sakB0iO7gIH05hvToIeQFBo4eNwoJEaIZiAtEUgbhWGQjRxk9hhhJSeQXiCM4jxBxyXMjEiI5bR5JQnRnT5dDiNCgIcNmCiBAfAShSZVmECVKltgc+MIGCxlgw4pdskKHEJtMZRTJuqStW7dCImLEYGLTrJC4PeYy0asXxpAhTZpdGHzBSWHDiBPfWCzIQCAAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+misc-22:actions actions22 22:photo:22 22:R0lGODlhFgAWAIUAAPwCBBQSFCQiJERGRBwaHFxeXHx+fDw+PGRmZExOTGxubKSipDQyNHx6fIyKjJSSlJyanISGhISChLS2tIyOjHR2dAwKDAQGBJyenAQCBCwqLLy+vKyqrAwODMTGxKyurFRWVLSytLy6vMTCxMzOzGRiZNTW1CwuLMzKzFxaXJSWlOTm5Nze3Ozu7OTi5Ozq7GxqbDw6PHRydAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAWABYAAAb/QIBwSBwGBMVkMjAgFAwHBFJpPB4SiQJCsWAQqEJB4prdNhQNx7QYIFwLD0ikQZdMHgelOPGYULQVDg4QEAVfRAEBBwUTEE0WFwcYhAuNF0QDBQULDwwZGUIaEAuVGxgBRAIFEhwHHUQMCxwTHAVrAAwFFRwKFkQZsxseDqBDGXMSHwfFQiAhIiMeJApEBwcOcahDJcLSJCYcGkQKcRAnQhkF0SgmEykHXkObox8q1iEjKN8rENqYD7MmeBCmzwSLFS1I3AqzYIPDESS+sWCxgQMLEgOSJKjozeAKFyskCDigQFwSBhJMjDDhAlyLFyVA+dIzAUUKEi0eaNhAIg8YGiEMenkwASNDDBkLqRQAEEAkup9KDkEFACUIACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+move-22:actions actions22 22:photo:22 22:R0lGODlhFgAWAIAAAPwCBAQCBCH5BAEAAAAALAAAAAAWABYAAAI6hI8RyJ26nAQQzlbrdWrP7nHRNh5gwpxmaZxWylJdRtf2fcux2rr7n8LsQrxQzyhE9mhIplKjPE5wBQAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+news_subscribe-22:actions actions22 22:photo:22 22:R0lGODlhFgAWAIUAAASC/Dw6PAQCBHRydPT29GxqbCQiJPz+9PTy9JwCBKwqLPz6/GRiZERCRPz+/FRSVDQyNBQSFBwaHDQ2NKSipJyanHx+fMzOzNza3FTCFGRmZCwqLAwODLzqpCwuLExOTLzqrFTGFAQGBES+BETCBEzCDDSqBBQ+BLTqnBRCBFRWVAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAWABYAAAb0QIBwCAgIiMgkckAoHJVQgEFAOCCc0WThcEgoDgvGMztFJLiJ83Ws3C4ODIY1jUCIlQ0Bd+FwMLZmCXV3Qw8CCAICfW9wBQhddVgAEIcCCwuJDlxWBQx1AhFPjlyJlwISj1ZWBJQTAImIerGqVwgEiAwUR46ysAeJcKoEoYkTVLGPvrWVDBUWEwEXF1aziMGfAhhiAhAVFdKPyMux2YkAEc3fF3WcdQTAGYkQQxAF3uAIGggbCBwCHfEEeEBiIB0+BB8cgHAQogMIKPXurRMxgkQJExjZELT3jUGDEyhMpDhxIouUOB8qqAhZ0iS9CJMStTQQBAAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+next-22:actions actions22 22:photo:22 22:R0lGODlhFgAWAIMAAPwCBAQCBOze9ORy7Pzy/PSi5LQCvNSG1JQ2nNx21LQCzMRGzNRy3KQCpLwKzAAAACH5BAEAAAAALAAAAAAWABYAAARTEMhJq704axC671WAfR8VCOKUbudApCBHksVgHO+5agFiHwVBAuYZ+RQLBmLHatgMS8mMyREsDI7oRipEeLWsKVG8Fce26EspzeaR2vDQNE7PGCIAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+openterm-22:actions actions22 22:photo:22 22:R0lGODlhFgAWAIcAAPwCBAQCBPTy9PTu9Ozq7OTi5Nze3OTe5Nza3NzW3NTS1MzOzMzKzMzGzMTCxMTGxOzm7AwGDBQOFBQSFCQeHCwmLCwuLDQyNDw6PERCRFROVEQ+RDQ2NLy+vKSipISChGxqbExKTOzu7OTm5Pz+/GRiZMS+xLy6vBQWFLy2vCwiHFQ+NMSmfNSyhIxmTDwuLJx+bLS2tCwmHMyyhMyqfPTqpPzyvLSWbLSWfPzitIx+ZDw2PAwKDCQiJGxWRPTmrPTerMyuhPzqtPz63PTWnPz6zNy+nIRiVDQuLKyWbOTanPz21NS2jNS6lDQqJHRaTPzmrPTSnPzyxOTClPz2xNSuhPTqxPzuvOzSpAQGDOTKnMy2jOzSrPTu1NzKnOzOnBwWHJRuXLSWdPTatPzqvNzClCwmJOzSnOTOnPTuxOzKlOzerOzarOzitJR6ZNTO1IxmXPTWrNSyjPzOjPTSpLSehHRqZOzirOTCjPS+fPzGhOy6bOzKhGROPMy2lPz+1PzmtKRyRHRiNNTCdPz+zNzCjEQ2NKySdDQmJAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAWABYAAAj/AAEIHEiwoMGBARIqXMhQIUIBAwYQIFCggIEDCBIoULBgAYMGDgIIDEBAwMSKBRBk3NjxAciQIwdACBBBwgQKFSxcwJBBwwYMHBx0EAmA5EwPH0CEsCChoYgOQ0cSGCHhA4kSS5syJGDiBNEAFVGUKKEBAwWFFM6SNJHi64gDFEKE4FBBggoKK1i0cPECxokYXw0gsECYggQZM2jAqGHjBo4cOtqOxLhDAg8ePXz8ABJEyBAWRIoYOfJipEoMCZEkuaFkSAslS5jUGJKkSRAnRREo0JDwCZQoTKQAmUKlihQrVa5gKZ1lI+oAK7QM2cJlSZMuU4Z4+TJEx0iNOwKAggkjZkyOFmS8kClzpcUQLRRGbjRD4MgZNEzSqKG+ZgobI2248dUbDDDwABzcxSEHEFpgEcUcdMRRhx1fFejAAx0cgcYdSxiBRx566LEHH0d8QFRRNC3Uhx985CHEH0MAEkhCBxWkgiCDFEFIEYUYUmONMhyCRxVH/PgjBYioYJAdAQEAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+paintbrush-22:actions actions22 22:photo:22 22:R0lGODlhFgAWAIMAAPwCBAQCBMTC/AQCtAQCdPz+/MzKzOzu7KyqrCwuLAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAWABYAAARZEMhJ6wxiDMsp1lvHfRohWuRAmOeVlUTQSukqz3U8A/nd9rtCAWTbAQoGg0q3OyANCOYPA0UgfCdMJnHFimre72sZ7pBWiTLqRUirK5hV7A0P2O3GvD5PjwAAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+paren-22:actions actions22 22:photo:22 22:R0lGODlhFgAWAIEAAPwCBIQChAQCBBQSFCH5BAEAAAAALAAAAAAWABYAAAJThI+pGou9oDuS1hlqnkxu/niVQB6kYHzAiJYoUK7paLrxpr6GMJjWeqlFGirEaQhcDHQJnEQX2/1kMBv08Yu1ttNkFRr1ikHjIiYYjDjSWLIbUAAAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+pencil-22:actions actions22 22:photo:22 22:R0lGODlhFgAWAIMAAASC/IQCBPwCBPyChMQCBPzCxAQCBPz+/MzKzISChKyqrDQyNEQCBAAAAAAAAAAAACH5BAEAAAAALAAAAAAWABYAAARYEMhJ6wxiEMtpIAWxddwXiqRlikSQeiAbuC+wirNR322gv7zcLobzDU+9XypoBBKTR1lz+RTWDgip8nUwZK1XLyIx5XoVicX2RUAo1DVKi7GOBxjxfNwQAQAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+percent-22:actions actions22 22:photo:22 22:R0lGODlhFgAWAIAAAPwCBAQCBCH5BAEAAAAALAAAAAAWABYAAAIzhI+py+0P4wkU1XfDhBdo/zndF4qh1pkGKYFk2XpTqoJr9G5YfmOz3hixfBZa7IhMJg0FACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+player_eject-22:actions actions22 22:photo:22 22:R0lGODlhFgAWAIUAAPwCBDQyNAwKDJSWlFRSVBQSFKymrOzq7HRydERCRPz+/MzGzISGhJyenKSmpGxqbJyWnJSOlKSepLy2vIyOjGRiZPTu9IyGjLSutFxaXExOTHx2fGReZAQCBAQGBBwaHCQiJLSytKyurJSSlFxeXNze3LS2tIyKjFxWXHRudAwGDBQOFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAWABYAAAa1QIBwSCwaj8ikcqkMCJjHwIBQgBIDhgMiUbVKFQsGItBdBhpgh4PxIJvRC8cA4oiMy8bvQhJhMAYTFBVOURAWEw0QFxcMERAYCBluVxobDxkVHJocmBwEGgmEQx0dHh0CpKmkH6odVlanBR8FtAIFtiCkSB0LISEiGCIGIxAPDySuRwIOBwrOzwoHJRHJRh0jJgMj2gMnERQUCNVFHQQoCBvo6CkICATjRB0qp7b1K6qv+foyQQAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+player_end-22:actions actions22 22:photo:22 22:R0lGODlhFgAWAIUAAPwCBDQyNFxeXAQCBMTCxGReZBQSFOzm7AwKDKymrJSSlFRSVCwqLLy6vPTy9OTe5Ozq7CQiJLSytOTi5BwaHPz+/HRydMzKzKSepJSOlKSipJyanIyGjIyKjKyurISGhMzGzJyWnHR2dISChIyOjLSutDw+PERCRHx6fJSWlIR+hJyenGRmZHx2fAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAWABYAAAa6QIBwSCwaj8ikMBBQKgOCgRMZIBSkxYHWoDVWD9EigpBQLLBERsPxCA8NDUhjgTBGJJNGG02RVBQWdUV3FxgZe0IGfoAGdhoXGxwdiAYef4FGFBoeHB8dGSBRihUhIo1FBhkbIyMkJRYmAwYal4JEBh2RChIWJ1IIGxUZFqdECCgkHR6wWAYpFR2YWSobvL5vFgfDaEMDIivMRBEsD9HcQgMWvecDLB0tZ0btsfJa9vLXU/X6/P3+b0EAACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+player_pause-22:actions actions22 22:photo:22 22:R0lGODlhFgAWAIQAAPwCBAQCBAwODMTCxKSmpJSWlFRSVAQGBBwaHLSutOzq7Ly6vCQeJPz+/Hx2fBQWFGxubLSytJSOlBQOFAwKDJSSlJyWnIyOjHRydNze3GRiZAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAWABYAAAWBICCOZGmeaKqubOumQSDEgRjPMSoMRGEcol3vh0IkFAtDDWBEKlGMRKPgEIii0yrqIS1ArADu9KuLNCSOSdCMVp8ohEZFC4DL6SaBpXGh6/l4JX8XZACDhXkYCn1LAoqMUBAZEhBLDJKUSyYBGmhPAJyemiU0NDaloy+qq6ytI8whACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+player_start-22:actions actions22 22:photo:22 22:R0lGODlhFgAWAIUAAPwCBDQyNAQCBExOTAwKDAQGBJSSlHx+fBQSFMTCxKymrFRSVOzu7GxqbLSytLy6vJyanPz+/GReZBwaHHRydKSepKSipGRiZJyWnAwODLSutKSmpISChPTu9ISGhFxaXJSWlIyGjJSOlERCRIyKjDw2PIyOjLy2vOzm7Dw6PLS2tCQmJOTe5GxmbDQ2NAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAWABYAAAa7QIBwSCwaj8ik0hgQLJGBgbMoqBIKU2LAcMgOEQmFYeEFbBmNMgDhYDwWBC0k4pCoJ46IgRIXBioRCRYXamwRGBQIfgaBFhiERhkaenxmCoEbBhyQRYaIGVsdghgem4UWegcEBB8UHhsgIaZGBBgRIpUIIxQhChginEQIIBEklWslFyYnBsFfFCi4WQgpFBwqFxNGKxcsxl4IAS0NZEYCF3vlwgEfUuZV8JEuI2pPAARN9kcE9fr+SwaCAAAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+player_stop-22:actions actions22 22:photo:22 22:R0lGODlhFgAWAIUAAPwCBAQCBAwKDBQSFBwaHCQmJJSSlISChJSOlJSWlGxqbGRiZNTS1PTy9Pz+/Ozm7OTi5FRSVIyKjOTe5MTCxIR+hExOTHR2dLy6vLSytLy2vHRydFxWXIyGjIyOjPz2/FRWVHx6fExKTMzOzJyanKSmpKyqrKSipAQGBLSutHx2fDw6PAwODAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAWABYAAAa1QIBwSCwaj8ikcslsAgKCAWEQjQ4KgSwyYDAcugZEQqFYYJECA6PhaLcfEEUkgJZAGJB8fkKpWOhHAxcOGBQZGBoaGQgbHIBGAhUOGR0SBxISBh4Xf0iCHxQSlRIIXhsgj0UCIaCXmJgHGyKpRJ+hmB5dHQqOaCENIx0epBIkBhdzngoPGCQlJifQJBvJRygRKRcKGxcXGypys1srEREc5SLnICLiR1koLFVUWfRO9vf4+UwyQQAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+prec_minus-22:actions actions22 22:photo:22 22:R0lGODlhFgAWAIEAAPwCBAQCBKSipPz+/CH5BAEAAAAALAAAAAAWABYAAAJAhI+py62RgnRnGguZ3BlTYIHdl13jh3goFpIleggvTK8ctw76Pswav/MtAkCd8NHj9HLFY6S4JEGdqdumtjAUAAAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+prec_plus-22:actions actions22 22:photo:22 22:R0lGODlhFgAWAIEAAPwCBAQCBKSipPz+/CH5BAEAAAAALAAAAAAWABYAAAJHhI+py22hgjwSonktxBZU7GnhkyXc6JmmeDpnG2lg1YCOInT3zrvfxwsMhsSBrkYUDo8MpTEZNH6M0SV058xWi1Tsj9ZjGAoAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+previous-22:actions actions22 22:photo:22 22:R0lGODlhFgAWAIMAAPwCBAQCBOzC7PTq9NSG1MxW3LQCzNRi7MRGzLQCvPz2/NRq3ORy7HQCdJwClAAAACH5BAEAAAAALAAAAAAWABYAAARUEMhJq70Yh813rl1HheInBYIwrEJwktxJFEbRmuOBJIXivp5LQLcj+HCnBaPBMBhdMBBjw0w8ccEA0/EzdQHaHywmnIyDyDSIrG4LQ+64OSqvx+kRACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+prod-22:actions actions22 22:photo:22 22:R0lGODlhFgAWAIAAAPwCBIQChCH5BAEAAAAALAAAAAAWABYAAAI7hI+py+1/gpy0hlVRZlP19mmSE0YjeIoXuqpkarYYbJQeDdiJrrs77gvOZDVg7Eb8JXtFSpMJiUoB9AIAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+queue-22:actions actions22 22:photo:22 22:R0lGODlhFgAWAIIAAPwCBAQCBKSipMTC/Pz+/AAAAAAAAAAAACH5BAEAAAAALAAAAAAWABYAAANfCLrc/jDKEGQMQlDLKM5aZQXDQIHZ9nhleaLqEhAE1bofKCozXZO3l0bmK9qCQ2LRCDQlAb3lkoTZQaVS6jOKpWmt3O5X2fU6wWXfuBM2mmINCpbKkavho56VI9s7DAkAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+redo-22:actions actions22 22:photo:22 22:R0lGODlhFgAWAIUAAPwCBCReDJzGjMzivOTu3Pz+/JTWbHy+VHTCTMTivPT69BxGDESuJDyiHESiHEymJIzKZAQCBFS2LFzKNGzWPDRqHCxqDFSqLHy2XESCHAwaBAQOBBQqBDyWJHyqZDyKFGSiVESeJBQ6BAwSBGTGPFyWPFSSLEyOLESGJBQiDAwiBBQmDCRGFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAWABYAAAaoQIBwSCwaj8hkMcBkKpcBwYAwEDif0YLhwEUkFItFMkAwMBoOR+PxgHwjRDggamhIJpQ8ZbKGKOQLcgEFdhUWEYgRF3sNfhELBHALAhgZFhobRBwREhQdEAIEHpIKHwsaSJwUDQgQIJINARxKESESDQ0dgCIjSpAkDAwPco+ZSJAlJicnKHIAIrNHidOIQxunT0kpCyrZSCss0d5Fj6jjRonn6uvs2QZBACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+reload-22:actions actions22 22:photo:22 22:R0lGODlhFgAWAIYAAPwCBCRSFCRSHBw+DBxCFCQ6FBwyDBQWBBxGFCxyLGTChMzqzLzmvHzKjDyOTER+RERyNDSqXNzy3LzivFS+fCyCPBQmBCQiBBxKFBQqDOTy3LTitES2dDR+PCxuJOT25KTarCx+PESSTCxKHDSeVCyKRNT21ESWVDSGPBQyDAQCBBQSFDRuLDSyZDySTGzChCRiJKSmpExKTDS2ZGzGhLy+vGxqbISChDSKRMzKzGxubDQ2NIyOjCQiJCwqLBQWFCwuLKSipERCRERGRHR2dAwKDDw6PFRWVIyKjCQmJFRSVBwaHKyurAQGBExOTBweHFxeXAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAWABYAAAf9gACCg4IBAgMEBQYHhI2ECAkKCwwNDg8QBAOOhAQREhMUFQgWBxcHGBmbggkaGxwPB4yDB6SbBJIKHQaqtY0eHyAhsqrDgx4aCiKpqoQHAyMjJBMKJaSxzAAHIRsmJgonKA0LHSmDKiuOBywRLSQuLyEwwyoxMuiN6iUzNBXy5jU2bsgoJugABBz95uXQsUMGD3vpPPgTpKIGwx4+HMr4kW4YkCA2hAzxAQSIECI+imBTwVIFESNHerRUgc0cEiFHkjiiyYzeDiVLdvLcySSkkKGEWiZVweSGkIHMmvQosoQlkaZOjvhosvKJjIAxoOAsgpRZkQNLnvSoqspAIAAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+revert-22:actions actions22 22:photo:22 22:R0lGODlhFgAWAIUAAAQCBPwCBPz+/BQSFPTy9CQiJNTW1ERCRLSytAQGBISChMzKzFRWVDQyNCwqLMTCxFxeXOTm1KSipPz69BweHHR2dJSWlMya/Mxm/GQCzOzWxGRmZPzOzMzOzMzOnExOTDw6PNze3Ozq7OTi5AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAEALAAAAAAWABYAAAbrQIBwSAwYAwDjUCloOgUDQlJJFCKfzoLAMF0ih9jmASGQfq3IBECgYC8YCsah4Rgc7+Bw2fCY4pNrCg8QboIIEX5HXXoEjWZ3eAIMgxITcRRVmVdOE50TBRV6TkJsD3EWDBUOoRcXGBmwsAJqT44aoKJNtAoVDAwWFRUFGwKxxhkCQhMEyxEcGrfEuWoGBgsdDwseHhQQvt++Hx8HmUQU4OHiICAJkHcDDB8hBCIj1QYfDomQAOIiHwxCPBiYr507JeNGAOQz8IC+g0YKrAtxAMQDBBgPFDB4EACIAwIHDkQAAhNEKuUStDMQBAAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+rightjust-22:actions actions22 22:photo:22 22:R0lGODlhFgAWAIAAAPwCBAQCBCH5BAEAAAAALAAAAAAWABYAAAIhhI+py+1vgpy0Toizjvbur3WiBJbhSJnqgorri7nwDBoFACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+rsub-22:actions actions22 22:photo:22 22:R0lGODlhFgAWAIEAAPwCBAQCBIQChAAAACH5BAEAAAAALAAAAAAWABYAAAI+hI+pFu3f1gmSVUBrlnt19SUhMk5XaWnnqrYc+2rQfNWHIBi4feP+zssBdkJez5gAIodDYbH2+yGBymXCUAAAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+rsup-22:actions actions22 22:photo:22 22:R0lGODlhFgAWAIEAAPwCBIQChAQCBAAAACH5BAEAAAAALAAAAAAWABYAAAI6hI+pyxBhXlOv1omggxon6VFdGG1laFmkyQLCC8fvJNB2U+M3k/P70gP+FEHiMFFEHhFJJk0GXUkNBQAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+run-22:actions actions22 22:photo:22 22:R0lGODlhFgAWAIUAAPwCBAQCBOzq5MzOzPTy9KyurNze3PTy7IyOjOTi5MTGxNza3MTCxMzKzHx+fOTm5NTSzNTS1NTW1FxaXAQGBLy+vJSWlGxqbGRmZIyKhDw6PAQGDJyenAwKDLy6vLSytBQSFLy6tKyqrHR2dLS2tJyanJSSlISGhKSmpCQiJISGjCwqLBwaHAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAWABYAAAbcQIBwSCwaj8RAAMkUBgSDZdMpBQQIharyGDAclsoDYhtIKKrDwMEgUBMWiwSj3HCg0w+DfgGJQAYSDRMUTAELBhJ8fw0KFXdJBwkLEhYXGAUNDBUZj0pXkxYaARsIDRUMHJ5pAgQHkxEYUh0JFR4fHAVZTgMFCAt+sUIgBB4hIggOI1pKCQO8CB0gAgYkJGNbRQEKEYwNCa7VIhOPaRAKCpoV1QUl5E5mDJrFJAW4JuRlCuMnKB+94yVQ2DGi7QSYABcQgACTDF+VFChULJsiZIUCiRS5sMjIsQidIAAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+showmenu-22:actions actions22 22:photo:22 22:R0lGODlhFgAWAIMAAPwCBAQCBBwaHERCRIyKjBQi/ERO7HR+1Ly+1Pz+/Ozq7MTCxOzu7NTS1AAAAAAAACH5BAEAAAAALAAAAAAWABYAAARkEMhJq7046z2D/2AoDAQVFGiqqsaBmGH8jWWX3Hiu3+YdKglPMIDrDXc+Is92zAmFi5pECWIkjySj0EkUZplb3JP4nV65WCmAqhR3yeo2Emmc0zsyGc3U6Pv/gAAKHISFhoQGEQAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+signature-22:actions actions22 22:photo:22 22:R0lGODlhFgAWAIYAAISGhISChHx+fHx6fHR2dHRydGxubGxqbGRmZGRiZFxeXFxaXFRWVFRSVExOTPwCBAQCBMzKzMzOzMTCtMS2dJSCTCwqLPz+/PTu1MzCtERCRMSydPTqxPz+9Pz6/MS+rNzKlKSSVOTarPz69ISCtGxurJyaxPT29MS6pOzmvNzSnHRyrPz29OTi5LyqXOzavMy6fFxanHR2rOzq5JyKTOzizPTqzKyWVGxqpPTy7LymZGRipLSy1PTu5KSSZFRKLExKTGRaNPz27PTq3LSiXPTq1GRWNDQ2NMTC3FxSNLymXGxqrPzy7IRyPDQyNCQmJGRinJSCdHxuVBQSDPTy5PTm1IR2RJyOfKSSfBweHGRenFxepNzGrKyejNS+pNTCnNzCpLyedBwaFBQWFNzOrOTOtOTOrBQSFOzStOTKpAwKBMS+tMS6rMS2nMSylMSulLymhLymfAQGBAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAA8ALAAAAAAWABYAAAf/gAAAAQIDBAUGBwgJCgsMDQ4OD5MPEAEREpmYmJqaE5IPFBUWAxEXp6ipqJ+TFRgVBaaqsxcZGhUVGxwdBrK0qB4fFSAhIiMYCLIkJSa0JygVKSIhKSoJvhcrqh4sLRUuKR4vITAL2DGpMiMzNBs1FzYiKjcMER6oOKglLDkVOinwRMCAAcKBrx33eMTwkKPHPx8/RGxwEaICkIMXcOBgMaJfCgw/fMCgWCGIhoMlSOQQkmMIkSJGUoysGOTBEVlIZMTg16NHhSJJZCqhOenmqSU5cDDB0JJIzJlNak5yYoqHDBY7hmgN8aPGhhslKU16EgHJDiY9oGz9EcJFkChSaKaIfUC2I5UhMarU+GElyJUrWHzIFZslAtqWVbRs4dIFi5cvYMKImTsmQs8qVVrUePGCDJcyZkCEGUzpTAQMmGts5ozGTJo0XEbPVTNhDRsUbdy82Q0HTpwwwNXMlQOhuPHjyIWLNRAIACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+spellcheck-22:actions actions22 22:photo:22 22:R0lGODlhFgAWAIQAAASC/AQCBFxaXBQWFAwKDPzCxPwaHPwiJNQGBOxKTPQ6PNQCBGwCBPQ+POwCBPwqLMwCBHwCBBwCBFQCBLQCBPwCBBQCBCQCBPQCBOQCBDQCBFwCBJQCBAAAAAAAAAAAACH5BAEAAAAALAAAAAAWABYAAAWGICCOZGmeaAoErMi+4xuQgQAI8yoKw2rfOZ1LRIgJh0hhDncsyXKypNMIKAKbNGpwFjxukcza7jt8xmCAgkpVMKxRhQOCnTAVFAtGqtBwLEgFDxAREigBExQVFRAibYNdJhaIigmODBdvF4gYDwoZDBpvIhKIGYOFoi4bHBGQogESqKlvBiEAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+sqrt-22:actions actions22 22:photo:22 22:R0lGODlhFgAWAIIAAPwCBIQChAQCBBwaHAQGBAAAAAAAAAAAACH5BAEAAAAALAAAAAAWABYAAANPCLrc/jDCQKutkcqQJeCP5k3g6IjCIAjAynYt0brzUn7gW++i0i8CGcNiuyl0NlyysYKhXgQdUvmcNZtDTo/mmvo+ptMvjDOSzWey+mFIAAAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+start-22:actions actions22 22:photo:22 22:R0lGODlhFgAWAIUAAPwCBAw2VAQCBCRGZAxCZGyavExmjHyatOTy9CxihISevPz+/KzO3BRylAw+XDRWbPz6/FzC3CSuzDyexJzO5Mzq9CxSdAQOFISmxNzu9HTS5BSmxAyexDSuzJTa7Mzu9Kzi7GS21CRmjAQOHHSWtLze7AyWvHzG3BRihCTO3BS+1AyixBSWvBSOtBSStAQWJDzW5BTC3BSqzBS21CTC1ETW3AQSHEze7BRqlBRmjAQCDBR+pBRefBRSdAQKFAAAACH5BAEAAAAALAAAAAAWABYAAAa0QIBwSCwaj8ikMqBcMpsCQTEwIDQBUWKgYHgqs8LAAZGwQqWAgGLBaDgEj0Fgjh5mxRBERDKhICAQFRYXRVEBGBAZGhscHR4VHyAhIiOFAiQZJRoSGyaNJxQnEyiVRFEoGykqKyYsJiYtLi0mKC+WFygrMDEyMzQ1wDQqKDaWADYoMzcqsjg5DSgoBISmaCOoMG4v29s2OsZCyDs8DldgQtc95WdFPg7rV0Y+XvHt9ff4SXRBACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+stop-22:actions actions22 22:photo:22 22:R0lGODlhFgAWAIUAAASC/CQKDBwKDCwODNyKjPzq7My+vIxiXAQCBOSOjPz6/OSelNySjNyGhMR+fLRaTGQ2LPz+/Nx+dNR2bNRybMxuZMxeXMxiZLQSFJQaHFwqJNyKhOSCfNyCfNR6dMxmXMxWVMRORLQODOR+fOSSjNR2dMQ2LJQWFMRWTLwWDNSCfMxeVLwaFKQODNR+fNx+fMxiXKQSDOSWlMRSTMxaVMQ6NMxORMQyJOTS1MxqXLwWFLRORMxKPMQaHMxKTLQWFCH5BAEAAAAALAAAAAAWABYAAAb2QIBwSCwajwGBcikIHIsDQmFKNRwQT2EgoVgsGOCG4wHBIgmRhWRCqVQsF0xGYyYGNgoGh9PpeCQfICEic3UAAWgLIxwRJBsbHSUREyYYJ3RDAQULexGejhueESgpl3WaCxsqJKKsChEUKywtmFoFDC4vCayikzCyMbWHt38NCTKiHhUfMyzBdQIFKsodob0VNDWzwppuKxMRrx6iNjcitNA4bh+iEzkwojc66JkOOxcf7G35PBE9KS1MEUGgIQOIFfk++KjRw9wJgUUIZvhRoyLDFCliQDQisUWLGCJOeNx4hKCGkyhPGnqCoKVLl1liypyZxUAQACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+sum-22:actions actions22 22:photo:22 22:R0lGODlhFgAWAIAAAPwCBIQChCH5BAEAAAAALAAAAAAWABYAAAIyhI+py+1/gpyUMrvm1bdhFTgfhIykYZ4pyZ2o5EZwDLSurc7ZFnqZDgLKKsQe7QihFwAAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+text_block-22:actions actions22 22:photo:22 22:R0lGODlhFgAWAIAAAPwCBAQCBCH5BAEAAAAALAAAAAAWABYAAAImhI+py30Bo5zBWUWzvNzo33GfFl5jVlonlTrr1DbvFi9vjeeNUQAAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+text_bold-22:actions actions22 22:photo:22 22:R0lGODlhFgAWAIAAAPwCBAQCBCH5BAEAAAAALAAAAAAWABYAAAIxhI+py+0Powm0VnknjVkH2AEhE45LZ55Wqn6e65TsMc5eYosbksswubJIhsSiccgvAAAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+text_center-22:actions actions22 22:photo:22 22:R0lGODlhFgAWAIAAAPwCBAQCBCH5BAEAAAAALAAAAAAWABYAAAImhI+py30Bo5zBWUbz3Sh7yIWfFHKjVl4nmFrr1Lpr7LwkjeeIUQAAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+text-22:actions actions22 22:photo:22 22:R0lGODlhFgAWAIQAAPwCBAQCBBwaHAwKDBQSFLy+vLS2tJSWlBQWFKyqrFRSVCwqLDQyNNTS1GxqbFxaXJyanIyOjAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAWABYAAAVcICCOZGmKQSoMaZsShBsQBdAapHvgaIDUqUPJlRjSbAoT0fRDKgODRbF0PLUYjZO2F2Bst9evNix+dsvDlGKK5jraudQb7qbX6a2HEJ+ycyF+LRE8ZTI+fX5oGCEAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+text_italic-22:actions actions22 22:photo:22 22:R0lGODlhFgAWAIAAAPwCBAQCBCH5BAEAAAAALAAAAAAWABYAAAImhI+py+0P4wqUSlQvttrkDnyaOHIdeaGRupplAIauVM3xjeeOUQAAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+text_left-22:actions actions22 22:photo:22 22:R0lGODlhFgAWAIAAAPwCBAQCBCH5BAEAAAAALAAAAAAWABYAAAImhI+pyw0Bo5zB2UXz3Sp7yG2fFJajVjonmIor2TJvfL0wjecIXQAAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+text_right-22:actions actions22 22:photo:22 22:R0lGODlhFgAWAIAAAPwCBAQCBCH5BAEAAAAALAAAAAAWABYAAAImhI+py30Bo5zBWUfz3SZ7yIXdF4kWqZkbCqoMO7kXLC+wVOe6YRQAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+text_under-22:actions actions22 22:photo:22 22:R0lGODlhFgAWAIAAAPwCBAQCBCH5BAEAAAAALAAAAAAWABYAAAIvhI+py+0PowmUnhpeVVnb1DkbCI1I2JhX+Z0sOr2cTHpwK7a4rUr+hAnufsTirwAAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+toggle_log-22:actions actions22 22:photo:22 22:R0lGODlhFgAWAIYAAAQCBAQ2NPwCBATW1KSWfBweHATS1Pz+/Ozm1GxiTATOzPz6/Pz69ATGxKSahOzaxPzy5HxuVLSmlOTazPz27AS+vPT29NzClPTexHxuXLSmjAyKhPTy9KyehNy+lPTy5Pz29HxyXNzWxAS2tOzexPzy7IR6ZASytPTy7ASurPTu3KSSdIx+bASqrJyOdIyCbASmpJySfPzu3OzizJyKbKyijASipJSGdOTWtPTq1PTq3NS+lJySdOzWtOzi1My6lMS+rOTOrMS2nNTGrNTCpNzKpJSGZKyafLSifIx+ZHx6ZFR6bFR+dAQyNAQuLAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAIALAAAAAAWABYAAAf/gAABAoSFhoeHAAMAiI2IigSMjoQABYkGBAeSjwAICYkKmQublJ0HDJ+GAA0OB66bpq4HCQC1lA2ZrqMCAA8QBwvBERITFIwAFa2yFgAXGL+uDBkaxRu1FQQLshwdHhgfDK4gIRoiFNYAI8quHA4XJCUMCwwMJhLm6Ce5rigEzhAMQICwYKLcuVopWgUDoWLFhQcfKNCjwOLeQQAtCFDYiAKBC28QKITk8MIgOhgxIHyQIWOGi4cfIHAogYJGjWq1bNzAkSOHjgc0dmBAgQKCUR43S1jjVeFGDx8PcNAAKePDjxg1gOCThOxFEBxBgpJQMQGpkCETEIBYSqkpkSJGOYTyOCJkgg4OIDaybXvjh5ELLpAMUYEAgQ7COPbyTWJEiY3HkCOTaruESYVamDPbQtTESedJhOgEAgAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+top-22:actions actions22 22:photo:22 22:R0lGODlhFgAWAIUAAPwCBAQCBAw2VHSWtBRihAQOHISmxNzu9BSmxHyatPz6/Lze7CTO3AyixAQSHHTS5BTC3DzW5ByyzPz+/OTy9AyexEze7GyavKzO3FzC3AyWvBSqzBR+pAQKFCRGZExmjCxihBRylCSuzBSWvBS21BSStBRSdAw+XAxCZDyexDSuzCTC1BSOtJzO5JTa7ETW3BRqlAQWJDRWbOT2/Mzq9HzG3BRmjJzS5Kzi7GS21BS+1CxSdCRmjAQOFAAAAAAAACH5BAEAAAAALAAAAAAWABYAAAaoQIBwSCwaj8jkMMBsOp3Ip7SpHAoGhELVKDAcENmtNaFYMBoEh1hAPjwgEUlYyZ5QHpIKxALWIgUXFBgZCBUaG3AcBB1HAh4fICEiFRUjJCUhBCYnjEQCAignoikqhissKAKiJwFJAS0uKhovMDFiADIzNDUsLza2Yh4KNDcsEbW3Ago4NSUrBMBbAjQ5KRo60Mk7PATdKH5bAT0xDg4xPa236uvsShRBACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+undo-22:actions actions22 22:photo:22 22:R0lGODlhFgAWAIUAAPwCBCReDJzGjMzivOTu3PT69MTivHy+VJTWbIzKZEymJESmFESiHDyiHESqLAQCBFzKNGzWPFS2LNTmzCxqDDRqHPz+/KTGnBQqBAQOBAwaBESCHHy2XBxGDOzy7HTCTEyyJDSqFHzWTAwSBBQ6BIy+dESKJFySPFSSNAwiBCRGFBQmDAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAWABYAAAalQIBwSCwaj8ikMsBkKotMwYAwEDiXgYLhwD0gCFZiQKxNKBYMRqPh+D6G16y5AYnYIxBJAyF4AwITTAUJdBESD4gPFBV6Fn6ABBcJDIYPGEQZGhQbHAIdfx4JHw2VSBodGwWfAR4LDSALfkgYAQurBiAhICKfSSMkvQElGyYnGyi9Rxkdj4nOskUYyU9FpxnURikdGtjRKivdRKfQ2Inh5+jpRwZBACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+up-22:actions actions22 22:photo:22 22:R0lGODlhFgAWAIUAAPwCBAw2VAQCBHSWtBRmjAQOHISmxNzu9BSmxBRihHyatPz6/Lze7CTO3BSixHTS5BTC3DzW5ByyzPz+/OTy9AyexEze7ByixGyavKzO3FzC3AyWvBS+1BR+pAQKFCRGZExmjCxihBRylCSuzBSWvBS21BSOtBRSdAw+XAxCZDyexDSyzCTC1JzO5JTa7DSuzETW3BRqlAQWJDRWbOT2/Mzq9HzG3JzS5Kzi7BSStGS21CxSdCRmjAQOFAQSHAAAACH5BAEAAAAALAAAAAAWABYAAAaeQIBwSCwaj8ikcqkMCJjHwIBQgBIDhgMiUbUGFAtGw0GFfheHByQi4S6/E8pDUoFYLm5kAEPJaBAVGxIcER0JHlEfICEiIxUkGyUmIgknKIhXASkonCorgSwmKQGcKE9IAi0uLxUwMTJWMzQ1NiYwBLBQHws1N7avXgs4NjkcCblMATU6KhvGyG87PAnUKV1MAj0+2zIFp1bg4eJJdkEAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+view_choose-22:actions actions22 22:photo:22 22:R0lGODlhFgAWAIMAAPwCBAQCBFRSVExKTDQyNPz69PTq5Pz+/OzaxOTKpAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAWABYAAARTEMhJq70466Cl+AMxBVwnFIVRAmQHCIeBrC1L3tQgJ/SaEbeeC1PLBHE2ybFI9A1HzstHEIK6YCmhDTmBybQaHYJn7QC5zKeytIQe1+pKNE6P2yMAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+view_detailed-22:actions actions22 22:photo:22 22:R0lGODlhFgAWAIMAAPwCBFRSVExKTDQyNPz+/Pz69PTq5AQCBOzaxOTKpAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAWABYAAAQ+EMhJq7046817+MLQUQFRGMc4lQaSAkcMx3QltMmrDrSu/sCgEPgJhIiFk89DaL1qPRnlhsgBebWhdstVESIAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+view_icon-22:actions actions22 22:photo:22 22:R0lGODlhFgAWAIMAAPwCBFRSVExKTDQyNPz69PTq5AQCBPz+/OzaxOTKpAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAWABYAAARWEMhJq7046z2DF0PlBeAVEERhiKhqHgWyUgEsX0KczFOO7JeBYciTCImc5ITIXDKHyqhU9AnRqq9UEVDTvmLbGhin2/qAliOUot5OLc81IO5+2+8WewQAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+viewmag--22:actions actions22 22:photo:22 22:R0lGODlhFgAWAIUAAPwCBBQSFJyanKy2tLzCxHyChNTa3Nzq7Nz29Nzy9Mzy9MTu9OTy9Nzi5Oz6/OT29MTi5Kzi7NTy9KTm7JzW3ITO1Lzq7IzW5HzK1LS+vMTq7Jze7ITW3GTCzGS+zLTS1MzOzLzq9Kzm7Jze5ITW5HTS3FS2vLze5EzCzEyyvEyutJTa5NTu9ITa5FTK1ESirLTm7Mzi5FS6xEy2vESerESmtFSutESmrKyqrAz+/Dw+RAzi3ASutHRydAQCBAAAACH5BAEAAAAALAAAAAAWABYAAAbKQIBQGCgWh8jksCgYEAaCozIZKBgOiIRiwSgEpstCw/HYQiKRhBcMCBgQDodkMaFU0t9pQHCIyy0TFxgYEVF6GQ4LCQkaERscHR4RH3lUIAkWCyEiIyQlHiYjEJVIAQQJJ2gjJSUoKSorlHoCLBQcHC0lLikvHjCGejEiHBgeMjM0NRwPpFQFDBHFNjceHAjAYFWoI7cnCVE4OWxtex8QH1EBOjs4zUpGUjw6Pe3j2fP19u/47vrq9P3s/avno2BBf/MCClSob4iBIAAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+viewmag-22:actions actions22 22:photo:22 22:R0lGODlhFgAWAIUAAPwCBBQSFJyanKy2tLzCxHyChNTa3Nzq7Nz29Nzy9Mzy9MTu9OTy9Nzi5Oz6/OT29MTi5Kzi7NTy9KTm7JzW3ITO1Lzq7IzW5HzK1LS+vMTq7Jze7ITW3GTCzGS+zLTS1MzOzLzq9Kzm7Jze5ITW5HTS3FS2vLze5EzCzEyyvEyutJTa5NTu9ITa5FTK1ESirLTm7Mzi5FS6xEy2vESerESmtFSutESmrKyqrAz+/Dw+RAzi3ASutHRydAAAAAAAACH5BAEAAAAALAAAAAAWABYAAAbIQIBQGCgWh8jksCgYEAaCozIZKBgOiIRiwSgEpstCw/HYQiKRhBcMCBgQDodkMaFU0t9pQHCIyy0TFxgYEVF6GQ4LCQkaERscHR4RH3lUIAkWCyEiIyQlHiYjEJVIAQQJJ2gjJSUoKSorlHoCLBQcHC0lLikvHjCGejEiHBgeMjM0NRwPpFQFDBHFNjceHAjAYFWoI7cnCVE4OWxtex8QH1EBOjs4zUpGUjw6Pe3j2fP19u/47vrq9P3s/cunr9S8gAIRFhTCLAgAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+viewmag+-22:actions actions22 22:photo:22 22:R0lGODlhFgAWAIUAAPwCBBQSFJyanKy2tLzCxHyChNTa3Nzq7Nz29Nzy9Mzy9MTu9OTy9Nzi5Oz6/OT29MTi5Kzi7NTy9KTm7JzW3ITO1Lzq7IzW5HzK1LS+vMTq7Jze7ITW3GTCzGS+zLTS1MzOzLzq9Kzm7Jze5ITW5HTS3FS2vLze5EzCzEyyvEyutJTa5NTu9ITa5FTK1ESirLTm7Mzi5FS6xEy2vESerESmtFSutESmrKyqrAz+/Dw+RAzi3ASutHRydAQCBAAAACH5BAEAAAAALAAAAAAWABYAAAbQQIBQGCgWh8jksCgYEAaCozIZKBgOiIRiwSgEpstCw/HYQiKRhBcMCBgQDodkMaFU0t9pQHCIyy0TFxgYEVF6GQ4LCQkaERscHR4RH3lUIAkWCyEiIyQlHiYjEJVIAQQJJ2gjJSUoKSorlHoCLBQcHC0lLikvHjCGejEiHBgeMjM0NRwPpFQFDBHFNjceHAjAYFWoI7cnCVE4OWxtex8QH1EBOjs4zUpGUjw6Pe3j2fP19u/4zT766vRI+fvHD4CPgwcJ9qg0UB85JA0dDjEQBAAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+view_multicolumn-22:actions actions22 22:photo:22 22:R0lGODlhFgAWAIMAAPwCBFRSVExKTDQyNPz+/Pz69PTq5AQCBOzaxOTKpAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAWABYAAARTEMhJq7046813+MJQfUF4BURhHGO6noSBsEcNoDJtS4KcsJQe4ncZ1HYT47HDbDqfUAnJRJmKLIGCCjjJbmE5wBI3EyOFxKCPS1EiJW52dE6vZyIAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+view_sidetree-22:actions actions22 22:photo:22 22:R0lGODlhFgAVAIUAAPwCBFRWVFxWXFxaXExKTNTO1NTS1Nze3Hx6fLSutMzGzLy6vMTCxDQyNMzOzPT29Pz6/Pz+/PTu9Ozq7OTi5Pz2/Ozm7MzKzGxmbIyKjAQCBPTy9FROVFRSVPTq5OzOpMS+xPzu5OTKpExOTJSOlOzu7AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAWABUAAAb/QIBwSCwaAQFBcqlsLgcBAnFQqBqqhwIiUVB4F4wGMeB4QMyPSCFQkEwmlMlCPKRC7pCKmjpxTyxzUwVmEBF6FxiDbxZyUnUFdxERhQUZbX4TDBlEAgUVkQ8DogEDAqYBTwEaAw54eQNusRMPs319Gp0PFZ8PAhMRGpLCwxOrFw/IFRuwwMICHAIEkhK4lxK0A7/Bkh0RHtvFAwp9D27MGugRAh4f29TithIW2c2SBOjgqwxv/AIS9cOEvQPBiBEFetsidOhAQFqEcCDgWLBAwR9AARFCuMPFAMwCEAsQpuMQQkS+EQ1SNkBAwuKwe+kiUDuSzU0JPyUm5HSj4Qi+Bp9A8QEIAgAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+view_text-22:actions actions22 22:photo:22 22:R0lGODlhFgAWAIAAAPwCBAQCBCH5BAEAAAAALAAAAAAWABYAAAIkhI+py+0Po2ShBlOxzbP7n2yaJoLm+ZTcxqHuC6hXzML2HVEFACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+view_tree-22:actions actions22 22:photo:22 22:R0lGODlhFgAWAIMAAPwCBAQCBFRSVExKTDQyNPz+/Pz69Pzu5PTq5OzaxBQOFOzKpFRWVFxWXOzexPTexCH5BAEAAAAALAAAAAAWABYAAARPEMhJq704g6A779kHCORAgNskFMYhakE8FkjyBcoWv+JwJItXaELYCTFHlCSpZKKcoB5jYHpOGgUadLKbIRw3jhEzQDyCSuI4zW673yhDBAAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+window_fullscreen-22:actions actions22 22:photo:22 22:R0lGODlhFgAWAIQAAPwCBAQCBNTW1NTS1MzOzMTGxLy+vLy6vLS2tKyurKyqrKSmpKSipJyenMzKzMTCxLSytFxaXPz+/Pz+9Pz+7IQCBMzOvMzOtPz+1MzOrPz+5Pz+3MzOpMzOnMzOxAAAACH5BAEAAAAALAAAAAAWABYAAAWxICCOZGmeKBqsbOu+rjAQRFEYxoEkibIwjUZMRnAUHjkEpPcLriLQqHQ6XRUk2Kw2O+lSKIUVoUKubLflikVcPnO75cvKkXZL4HG2pK31lilqc1lmfRNfgBQYGBlidl5fGhobGxqMAQNnXYaQkZOLjVgVmpsUkRoVnpZje2SkphtlGBUcbH+br5NptAF0rYe4G4plHSseaaW4irLDcxYOFtDRFhnU1B3X1zDa2indIwYhACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+window_nofullscreen-22:actions actions22 22:photo:22 22:R0lGODlhFgAWAIUAAPwCBAQCBNTW1NTS1MzOzMTGxLy+vLy6vLS2tKyurKyqrKSmpKSipJyenMzKzMTCxLSytFxaXPz+/Pz+9Pz+7IQCBMzOvMzOtPz+5Pz+3MzOrPz+1Pz+zMzOpPz+xMzOxMzOnAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAWABYAAAbKQIBwSCwaj0hkYMlsOp9OwYBAKBQMhgMikVAsGI1GVEpwFB5ZBKT7DS8j8Lh8Pl8WJPiJfr/PTygUBUsEEhV4h4h+ExUUFoMVkIWJhxWLkBeDhZCGiXqbFRiYAYSanId7mxihSwOlphJ6gJ8ZGksOiqd/gKoYGRmipIh7gBSqvhkbtaOuw7sYn8mseJuxxcabGxwdmZ/EvL6f2o+Qz869yBUem9sBH4sYf7znG/Qb6h4gSx8fDh8W/wA1CBTYoSCIfFASQknCcIiBIAAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+wizard-22:actions actions22 22:photo:22 22:R0lGODlhFgAWAIQAAPwCBNzaTPz6BAQCBPz+BExKBMzOTPz+rPz+3ISCBPTyhISCLISChPz+xOTiVPz+/MTCxKSipKyqrExOTDw+PDQyNAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAWABYAAAV+ICCOZAkEZqoKqoqKAzHAb1sIxhAQwWAQhRaJd0AcdgkhqaBAOBUL5WjAaD6TUqog0DAildqcg+cDtgaPACTCiM0AOhV6sG4DWOAHnf2uyfV1b1lsgVIwEgwTFHaGA2yKFYJgiJCSQo6JFJGGcJSalkKPn5wimZukAJWoIgYhACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
diff --git a/jni/ruby/ext/tk/sample/tkextlib/ICONS/tkIcons.kde b/jni/ruby/ext/tk/sample/tkextlib/ICONS/tkIcons.kde
new file mode 100644
index 0000000..0d5b2c8
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkextlib/ICONS/tkIcons.kde
@@ -0,0 +1,195 @@
+actattach16:act act16 16:photo:16 16:R0lGODlhEAAQAIEAAPwCBPz+/AQCBAAAACH5BAEAAAAALAAAAAAQABAAAAI2hAOCxg2h0nJHyEshi9HpxU1GOCLdZoKpQ15nibUoprKp9lh2oucUxsBRXsJh4Hjs/QTMpr8AACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+actbookmark16:act act16 16:photo:16 16:R0lGODlhEAAQAIQAAPwCBCwqLLSytLy+vERGRFRWVDQ2NKSmpAQCBKyurMTGxISChJyanHR2dIyKjGxubHRydGRmZIyOjFxeXHx6fAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAVbICACwWieY1CibCCsrBkMb0zchSEcNYskCtqBBzshFkOGQFk0IRqOxqPBODRHCMhCQKteRc9FI/KQWGOIyFYgkDC+gPR4snCcfRGKOIKIgSMQE31+f4OEYCZ+IQAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+actbookmarknew16:act act16 16:photo:16 16:R0lGODlhEAAQAIQAAPwCBCwqLLSytLy6vERGRFRWVDQyNKSipAQCBMTGxKyurISChJSSlJyanHR2dIyKjPz+xISGhPz+BGxubMTCBHx+fPz+/AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAVfICACwWieY1CibCCsrBkMb0zchTEcNYsIiYHiwIOdEAvigdFQGE0Ix4NBbSAgsWjk+jBIAlcUYrJASChnSXZSoUDelKfoKpFALJA61ueGI2IAZmhogGFmCGGAgXsifiEAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+actcheck16:act act16 16:photo:16 16:R0lGODlhEAAQAIIAAPwCBMT+xATCBASCBARCBAQCBEQCBAAAACH5BAEAAAAALAAAAAAQABAAAAM2CLrc/itAF8RkdVyVye4FpzUgJwijORCGUhDDOZbLG6Nd2xjwibIQ2y80sRGIl4IBuWk6Af4EACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+actcross16:act act16 16:photo:16 16:R0lGODlhEAAQAIIAAASC/PwCBMQCBEQCBIQCBAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAMuCLrc/hCGFyYLQjQsquLDQ2ScEEJjZkYfyQKlJa2j7AQnMM7NfucLze1FLD78CQAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+actexit16:act act16 16:photo:16 16:R0lGODlhEAAQAIEAAPwCBAQCBDQyNHR2dCH5BAEAAAAALAAAAAAQABAAAAI4hI+pFrHb3nEg1iWiDiINCwYDko0V9XUTda6I1TIsUMpGinyzbB6ZeGuoEr+GUDL4CXqSphPhLwAAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+acthelp16:act act16 16:photo:16 16:R0lGODlhEAAQAIMAAPwCBAQ6XAQCBCyCvARSjAQ+ZGSm1ARCbEyWzESOxIy63ARalAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAQ/EEgQqhUz00GEJx2WFUY3BZw5HYh4cu6mSkEy06B72LHkiYFST0NRLIaa4I0oQyZhTKInSq2eAlaaMAuYEv0RACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+actitemadd16:act act16 16:photo:16 16:R0lGODlhEAAQAIQAAPwCBARCZPz+/Mzq9BTC3ITC1HSyzGSivAw+XBSStIS6zHy2zAQCDFyatAQOHFSStEyOtAQSJBSq1DR2nCxunCRmlAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAVbICCOQTmeaCAMRIC+AVu47xkTBl2Ld16XQNYBQTQBVIOkMHFQJBeMI4tAbSSu2IRDSnhAvFfI97sFRM6RwOMacbjLKckVvgvIJ5EdSU7J648VgXQ7Dmd/hyJ+IQAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+actitemdelete16:act act16 16:photo:16 16:R0lGODlhEAAQAIMAAPwCBARCZPz+/Mzq9BTC3AQCDAQOHFSStAQSJAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAQwEMhJq704681n+GAISoEwnGg6EAUQrEQsz4ThEkeu77kNIAagMEj0dY7IpHI58UcAACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+actlock16:act act16 16:photo:16 16:R0lGODlhEAAQAIUAAPwCBFxaVAQCBKSipDQyNMTCxISChFxaLFxSJEQ+FExGHCQiDBwaDGxiLHxyNHRuPIR+TIyGZJSSfFxaRFxWJGRiLJyaXNzWpNTOnMzGnLy2hJSKTGReLKyqjPTu1NzarMS+jLSyfKyibJySXIyGVCQeDLSytPT29Ozu7OTi5NTS1KyurJSSjGxqVFxaXLS2tKSebOzuzLSufJSOXExGLGRiTExONAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAaTQIBwGCgGhkhkQDBoEpLKQoBACAyOUID1qTVwoQGvMPxNFgVjAxp6QCQUicSCwVgkG44HJCKRRCYUCAxIFRYXhxgZGhYbHINEHR4fGCAhIiMkFSVKJicoKSoFKwMsLZtDLison6GjLA92qCueoAUvpC2xQhWqrLYDErmEMDEXlDIwMxAHukI0NS01EzY2NAmPAH5BACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+actredo16:act act16 16:photo:16 16:R0lGODlhEAAQAIUAAPwCBBxOHBxSHBRGHKzCtNzu3MTSzBQ2FLzSxIzCjCSKFCyeHDzCLAxGHAwuFDSCNBxKLES+NHSmfBQ6FBxWJAQaDAQWFAw+HDSyLJzOnISyjMTexAQOBAwmDAw+FMzizAQODDymNKzWrAQKDAwaDEy6TFTGTFSyXDyKTAQCBAwiFBQyHAwSFAwmHAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAZ2QIBwSCwaj0hAICBICgcDQsEgaB4PiIRiW0AEiE3sdsFgcK2CBsCheEAcjgYjoigwJRM2pUK0XDAKGRobDRwKHUcegAsfExUdIEcVCgshImojfEUkCiUmJygHACkqHEQpqKkpogAgK5FOQywtprFDKRwptrZ+QQAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+actreload16:act act16 16:photo:16 16:R0lGODlhEAAQAIUAAPwCBCRaJBxWJBxOHBRGBCxeLLTatCSKFCymJBQ6BAwmBNzu3AQCBAQOBCRSJKzWrGy+ZDy+NBxSHFSmTBxWHLTWtCyaHCSSFCx6PETKNBQ+FBwaHCRKJMTixLy6vExOTKyqrFxaXDQyNDw+PBQSFHx6fCwuLJyenDQ2NISChLSytJSSlFxeXAwODCQmJBweHAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAaBQIBQGBAMBALCcCksGA4IQkJBUDIDC6gVwGhshY5HlMn9DiCRL1MyYE8iiapaSKlALBdMRiPckDkdeXt9HgxkGhWDXB4fH4ZMGnxcICEiI45kQiQkDCUmJZskmUIiJyiPQgyoQwwpH35LqqgMKiEjq5obqh8rLCMtowAkLqovuH5BACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+actrun16:act act16 16:photo:16 16:R0lGODlhEAAQAIMAAPwCBAQCBPz+/ISChKSipMTCxLS2tLy+vMzOzMTGxNTS1AAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAARlEMgJQqDYyiDGrR8oWJxnCcQXDMU4GEYqFN4UEHB+FEhtv7EBIYEohkjBkwJBqggEMB+ncHhaBsDUZmbAXq67EecQ02x2CMWzkAs504gCO3qcDZjkl11FMJVIN0cqHSpuGYYSfhEAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+actstop16:act act16 16:photo:16 16:R0lGODlhEAAQAIUAAASC/Gw6NGQuLHQ6NGQmJFweHFQaFPTm5PTa3PTW1Oy+vOS6tNSinKReVDQWFPz+/Nx6fNyCfNyGhNR+dMxybMRiXLxGRIwWFNx2dNx+fNx2bMxuZLQWFBwWFPTu7Pzy9NRqZNRuZMRSVLwmJGwWFNR2dMQiHPTKxMxmXMQyLMxmZNx6dMxiXMRSRMRaVKxybMxaVEQWFMQuJAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAaaQIAQEBAMCAWDYcgkHhAJxYLRcDQBggckIplQKpaLdRh4YDIaSWa94Vw6woAHgv6AMKGPaMQhwQMJJRkfhHmEJhdvRCcgGSCEkCgpbnAECiorGYYfLCItlAAFCygQj5AfbYlwBQwVE5AukG6KBi8tMC0fLi0pHxyzcAAxFxwmMny/wEwOxMm/qlcdJCSJ1H5XQh3a28HY3kx+QQAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+actundo16:act act16 16:photo:16 16:R0lGODlhEAAQAIUAAPwCBBxSHBxOHMTSzNzu3KzCtBRGHCSKFIzCjLzSxBQ2FAxGHDzCLCyeHBQ+FHSmfAwuFBxKLDSCNMzizISyjJzOnDSyLAw+FAQSDAQeDBxWJAwmDAQOBKzWrDymNAQaDAQODAwaDDyKTFSyXFTGTEy6TAQCBAQKDAwiFBQyHAwSFAwmHAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAZ1QIBwSCwaj0hiQCBICpcDQsFgGAaIguhhi0gohIsrQEDYMhiNrRfgeAQC5fMCAolIDhD2hFI5WC4YRBkaBxsOE2l/RxsHHA4dHmkfRyAbIQ4iIyQlB5NFGCAACiakpSZEJyinTgAcKSesACorgU4mJ6uxR35BACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+actunlock16:act act16 16:photo:16 16:R0lGODlhEAAQAIUAAPwCBFxaVAQCBKSipDQyNMTCxISChFxaLFxSJExGHEQ+FCQiDBwaDBweDGxiLHxyNHRuPIR+RIyGZJSSfFxaRGxmLJyaXNzWpNTOnMzGnMS+jJSKTGReLKyqjPTu1NzarLSufKyibJySXIyGVGxiNFxaXLSytPT29Ozu7OTi5NTS1KyurGxqVCQeDJSSjLS2tNTW1KSmpGRiLKSebOzuzJSOXExONExGLAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAaVQIBwOAwYA8SkMCAYOAnKYiFAIAQGyOgVCggYuEovVxztMpdnwAGRSCgUCwOjIeQ6HpCIZDKRUNYMRBUWF4UYGRoWGxyBRR0eHxgaICEiIyR0QyUmJygpKgUrAxMsLUQlKyieoKIuEAunK52fBS8DLiywQySpnjC1Mbi6QjIzNBeSIBY1EQfDQgosLAEUNjY3Co1DfkEAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+appbook16:app app16 16:photo:16 16:R0lGODlhEAAQAIQAAPwCBAQCBDyKhDSChGSinFSWlEySjCx+fHSqrGSipESOjCR6dKTGxISytIy6vFSalBxydAQeHHyurAxubARmZCR+fBx2dDyKjPz+/MzKzLTS1IyOjAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAVkICCOZGmKQXCWqTCoa0oUxnDAZIrsSaEMCxwgwGggHI3E47eA4AKRogQxcy0mFFhgEW3MCoOKBZsdUrhFxSUMyT7P3bAlhcnk4BoHvb4RBuABGHwpJn+BGX1CLAGJKzmKjpF+IQAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+appbookopen16:app app16 16:photo:16 16:R0lGODlhEAAQAIUAAPwCBAQCBExCNGSenHRmVCwqJPTq1GxeTHRqXPz+/DwyJPTq3Ny+lOzexPzy5HRuVFSWlNzClPTexIR2ZOzevPz29AxqbPz6/IR+ZDyKjPTy5IyCZPz27ESOjJySfDSGhPTm1PTizJSKdDSChNzWxMS2nIR6ZKyijNzOrOzWtIx+bLSifNTGrMy6lIx+ZCRWRAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAaeQEAAQCwWBYJiYEAoGAFIw0E5QCScAIVikUgQqNargtFwdB9KSDhxiEjMiUlgHlB3E48IpdKdLCxzEAQJFxUTblwJGH9zGQgVGhUbbhxdG4wBHQQaCwaTb10emB8EBiAhInp8CSKYIw8kDRSfDiUmJ4xCIxMoKSoRJRMrJyy5uhMtLisTLCQkC8bHGBMj1daARgEjLyN03kPZc09FfkEAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+appboxes16:app app16 16:photo:16 16:R0lGODlhEAAQAIMAAPwCBAQCBMT+xAT+BASCBATCBMT+/AT+/ASChATCxPz+xPz+BISCBMTCBAAAAAAAACH5BAEAAAAALAAAAAAQABAAAARaEEgZwrwYBCFqvhs3DNYXjChRlWBRjIRqGN4UuEUczMZxsDeXykdEsDQVVSLhQxhBCkVlmXA+KVHFYhFYOoHbMGN6pTQaW8YYiQmcG+q16a0+Zipw+4e9B/gjACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+appbox16:app app16 16:photo:16 16:R0lGODlhEAAQAIIAAPwCBAQCBPz+xISCBMTCBAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAANECKoR6ys2IVqokF08yMTA1gwkYX5WQK5ma4VceTYPxXnBWdtY6+0834/Bowgzm6APWRQcH4TiMhPK2WYRiZWW7XK7/gQAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+appbrowser16:app app16 16:photo:16 16:R0lGODlhEAAQAIYAAPwCBFxONCROfCRKfKx6LNy+bNTOpGSS1DRupAwyXBRSnPTSjPTqvOzqzMzSvHSSlKy6ZDxutAxCpBQ2XBxepLTKvPzqzPzy5OTShLS2dLSqRFR2jBRerBQ+jOTixOzetNS2XHx6XDR2tCRexBwyTDyKzOTavPzq1OzKdCx23BRKtCQ6VCQmHFSa7IyirOzSnGSGpIR+bFSO1DyK7DR+5CRixBw2VDQuHFye7IS27NzGXISuhEyS5DR25BRWxBQ+lBQyXCQqPCxSfGyu7GyerKy2ZFR+rERqfCRmxBROtBQ+fBwuTBwmNDSW9JyabLyqRIx+TExSXBQ6bAQCBBQ6ZBxapDR+zBxq3LyaLJySRHxqPGxeNBxGbCRmrHRyRERONDRKNDQ2JCQuLAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAeygACCg4SFhgABAQIDh4MBBAUGBwgDCYcKCwwNDg8QERIThRQVFhcNGBkaGxwdoYMDHhcXHxggISIjEiSvJSYXJwsoISkpIyorLIIDLS4WLzAxMjM0NSo2N8o4OS46OzwzPSk+P0BBgkI8Q0NERUZHCEhJSktMgwk4Qy1NTk9QUVJLphCiUsWKlStYsmjZQiJgIS4KuijQ4iXAFxYCDVFJwGUFmDBhMjYSw0KMyEYoBfkJBAAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+appcalc16:app app16 16:photo:16 16:R0lGODlhEAAQAIEAAPwCBISChPz+/AQCBCH5BAEAAAAALAAAAAAQABAAAAI4hI9pwe0Ogpi00hHF2LzzzFlTsIHD45SSx6oCeW4wjK2tl83y7t64pIsJaxrfh2bEAJIlhRPhLwAAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+appclock16:app app16 16:photo:16 16:R0lGODlhEAAQAIIAALy+vAQCBPwCBMQCBIQCBISChPz+/MTCxCH5BAAAAAAALAAAAAAQABAAAANbCLHcrSLKOZcYmDSCsR1aUABAsXDDJwJGa5SBFwgaWxbCG3CWaBwG3C8Y67FawpYiNQscg65fsVkYuoAmJs1pBR522lQB6ILJLqHRwQQOZzYdZnw+dzruDIA/AQAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+appdate16:app app16 16:photo:16 16:R0lGODlhEAAQAIQAAASC/AQCBPzerPyqXMRaBIQCBISChPz+/KSipMTCxPz+BMTCBPwCBPz+xPzCxMQCBISCBAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAVxICCOQGCeJjkGwkC8RFEEavkax2G8dB0QuRyhhzoBg8MSYsncJXKJZIDZHCoWP1ogGIwGrtnSgUFmHLyNRHhrdpjRamnO/SYkromHdnxwnwkKVxByZW8DgQsQM2JcfwZXO0MBCZSVBgMuLzJaRZ0pfiEAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+apppencil16:app app16 16:photo:16 16:R0lGODlhEAAQAIMAAASC/IQCBMQCBPzCxAQCBPz+/MTCxISChDQyNKSipEQCBAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAARDEMhJZRBD1H2z3lMnjKCFjUJQimOgcmcbELCXzjXq0hV785WCQYcDFQjDXeloMByKG6YTAdwIDAlqSZJSVFeKLcUfAQAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+appsheet16:app app16 16:photo:16 16:R0lGODlhEAAQAIIAAPwCBAQCBAT+/Pz+/KSipPz+BAAAAAAAACH5BAEAAAAALAAAAAAQABAAAANFCBDc7iqIKUW98WkWpx1DAIphR41ouWya+YVpoBAaCKtMoRfsyue8WGC3YxBii5+RtiEWmASFdDVs6GRTKfCa7UK6AH8CACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+apptool16:app app16 16:photo:16 16:R0lGODlhEAAQAIMAAPwCBAQCBISChGRmZMTCxKSipLS2tHx6fPz+/OTm5FxaXOzu7DQyNMzOzAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAReEMhAq7wYBDECKVSGBcbRfcEYauSZXgFCrEEXgDCSeIEyzKSXZoBYVCoJVIqBGByKu0Cy8QHxmgNngWCkGgqsGWFseu6oMApoXHAWhWnKrv0UqeYDe0YO10/6fhJ+EQAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+apptools16:app app16 16:photo:16 16:R0lGODlhEAAQAIUAAPwCBExKTERCRAQCBOzu7Nze3MzKzLy+vCxqZBQ2NJyanKyqrGRiZDRydKza3FRWVPT29LSytDw6PMTm5EySjCxaXGRaJFSanCRSVGxqbPTmvMSqVJTW1GSurHS6vOzq7KSipISChFRKHJSGNPz23GxKFBQ6PKyurCwqLMyufJx2RAQGBJSWlEwyDIRiLNy+lLSKVDwmDJRuNOTOrLyabGRCFDx2dKSCVOzWtHzCxOTGnNSyhAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAahQIBwCAgIBAOiUiggFAyHASKxDAwUC8Zg0HAglA9IZPGQABoTSqJCFTIOEIsFgHBcEhhHUpKJFCwaGxYYHB0VEx4IEh8gIQwiIyQbJRMcHokmEicfDygAkCkqJQgIGG0rLElCLS4vMCWqQwMCQg0UMTIzNDVLQjaIGDE3ODQlS785CEkxKjowvEOHybG4O6JDCdNKuDUxRAmxRDHeveUAfkEAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+appuser16:app app16 16:photo:16 16:R0lGODlhEAAQAIMAAPwCBAQCBPz+/MTCxISChMT+/ATCxASChFxaXAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAARaEMg5gw00yyDGIAR1YUDggeFWFIZhnSBZrsZxdIOFEGTA2oeBAHeyuGwvzxBlYdUOLROMFzDQntJPrNoqAKUBaqnV+k57ZORruykHDj2LqIzUVKp1u0iuB/gjACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+appusers16:app app16 16:photo:16 16:R0lGODlhEAAQAIMAAPwCBAQCBMTCxISChAT+BMRaBPyqXARCBPz+/FxaXAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAARLEIRJa5Ui673nsGAgeKE1Bl9AUEXbiqTlFlZaGUZoszm4BzhDAVf5BYbAXI+TAR6CS2ZGSZSEiIIqYIsSIEaJ7GRrlY7J1lKA7I8AACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+appwp16:app app16 16:photo:16 16:R0lGODlhEAAQAIUAAPwCBKSinJyOfPz27Pzy7AwKDExOTJyWlERCRKSelPz69LyyrKymnPz+/MS2fDQyJAQCBOTazLSiXOzivMS2jKSSVOzmxPz25NzSpPTu5KyebOzixNTGjOTWpMSydMSybCwqFGReVKyaXNzSnGxeNJSCVMS2nPz23MSuZIR+bJyShLyqnOTOtGxiXIR6XOTSvIx6RMSubIyCdKSalMS6pOTWxMzKvKSabJyKTOzezHxuPGRmZKyurMTCvPTq3AAAACH5BAEAAAAALAAAAAAQABAAAAajQIBwCAgIiEhiYEA4FgwHRDKhIBAWz4OhgGQ0FAPHA7qFEBONb0Qy0ULeQ2+aUrFcMI+3GYBOZzQbHB0eHyAhIQByDREiEwMjFRIkJQImAgJ+jScjHigkKSorLC0AKg2NFSMoki4qCy+IQgITKDAxkjIzNDWkQxQoJaskMgk2Eb1DNzgoOCoHDDY5yEIwJToAOzw9ET7TQiREAhkZ3kmy5QB+QQAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+cal1day16:cal cal16 16:photo:16 16:R0lGODlhEAAQAIIAAAQCBPwCBAQC/AQCjPz+/MTCxKSipAAAACH5BAEAAAEALAAAAAAQABAAAANOCLrMEUDIOUS9AFLLhx8LIRZjKYZmMRCkaChFLHty/AIiS3y6q+QtT49wq8VotRtQJGwRf6Zmrlj7DJLQXsupTJmeEIN4TB5nII20wp8AACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+cal5days16:cal cal16 16:photo:16 16:R0lGODlhEAAQAIIAAAQCBPwCBAQC/AQCjPz+/MTCxKSipAAAACH5BAEAAAEALAAAAAAQABAAAANMCLrMEUDIOUS9AFLLhx8LIRZjKYbj55GioRRwoQ5x4QIiIdMmcec7jy53q81qP9OO5VMAj8RXTFWzOZW95HDLdEEM4LA4nIE0zgp/AgAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+cal7days16:cal cal16 16:photo:16 16:R0lGODlhEAAQAIIAAAQCBPwCBAQC/AQCjPz+/MTCxKSipAAAACH5BAEAAAEALAAAAAAQABAAAANPCLrMEUDIOUS9AFLLhx8LIRZjKYbj55GioRRwoQ5x4QIiwcp0fucsj873qvGMv5Jw2FIACUsW4WakGW1O046I05qmGYBhTC6TM5CGWuFPAAAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+calappointment16:cal cal16 16:photo:16 16:R0lGODlhEAAQAIMAAAQCBPwCBAQC/AQCjPz+/MTCxPz+BISCBISChKSipAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAEALAAAAAAQABAAAARbEMhJaQhA6D1E/wDGeeRgDhOhFoTBEi+REgdrIHScSEVvAD9Xr7cDqGSGpFEnQSqTv2NxCFQOiU1VEAiTZmstHFg1vQKuw+LxxfYaV/AuOQRI2O/4ewhT6Uv8EQAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+calbell16:cal cal16 16:photo:16 16:R0lGODlhDwAOAIIAAPwCBISCBPz+BIQCBMTCxISChPz+/AQCBCH5BAEAAAAALAAAAAAPAA4AAAM+CLrR+zCIAWsgLVRGRBhOVQiG94WPVAbHaZHYAWqRYLbge88RsbInGuBCEhRYrZYm4xk4nYdoKzKIbiKHawIAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+callist16:cal cal16 16:photo:16 16:R0lGODlhEAAQAIMAAAQCBPwCBAQC/AQCjPz+/KSipPzerMRaBEQCBAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAEALAAAAAAQABAAAARDEMhJaQhA6D1E/wDGeeRgDhOhruyatjBRSIRxxOsMEAdC0BUZDcfSEYvDo3Bn++2Cxt7RqFxWhZiCdsvdhjCVsMQfAQAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+calmonth16:cal cal16 16:photo:16 16:R0lGODlhEAAQAIIAAAQCBPwCBAQC/AQCjPz+/MTCxKSipAAAACH5BAEAAAEALAAAAAAQABAAAANSCLrMEUDIOUS9AFLLhx8LIRZjKYbiRxLFIBpK0Q6z7MkwkJIe8b0KEeuWchFysuStVsjtfMbeMQitWpG25YfmNK1WU53XNIUYzug0OgNpuBX+BAAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+caltoday16:cal cal16 16:photo:16 16:R0lGODlhEAAQAIMAAAQCBPwCBAQC/AQCjPz+/MTCxKSipPyCBMRaBPyqXAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAEALAAAAAAQABAAAARTEMhJaQhA6D1E/wDGeeRgDhOhFmurpi5LyIQhFfiBIAfuFzaAioBIJBCummRYPCaDPh3vhwsOZdihNfa8Ub/AJXemFZPPNBvGwG672yFMZS7xRwAAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+caltodo16:cal cal16 16:photo:16 16:R0lGODlhEAAQAIMAAAQCBAT+BAQC/AQCjPz+/MTCxPzCxKSipPwCBMQCBIQCBAAAAAAAAAAAAAAAAAAAACH5BAEAAAEALAAAAAAQABAAAARaEMhJaQhA6D1E/wDGeeRgDhOhFmurpi5LyMYhFXiuFwZiA6qZYbbqJX5BIw2RAPxwAAWCyWMCCsiXFGEEErKz6LQZfOqiTR1YJiGq1rFyyHmo2+/1EKbCl/gjACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+connecting16:connect connect16 16:photo:16 16:R0lGODlhEAAQAIMAAPwCBPz+BMTCBISCBAQCBPz+/MTCxMTGxISChFxaXMzGzKSipAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAARaEMhJZbihUiz60FPnfaA0iBpBVGdHEYWxToEoSHBRHHM9AgSEQRcj+AYkYAJxIPKQFUJiOdTJQFIDU6dYzKKFhTCM+E5g4mXaDAyrlogEG+DGTecA7wsP8EcAACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+connectno16:connect connect16 16:photo:16 16:R0lGODlhEAAQAIMAAPwCBPz+BMTCBAQCBERCBPz+/MTCxMTGxISChFxaXMzGzKSipAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAARPEMhJq704axBEHoPUEdhQGMNYFuwxkKInDYjBniEnwMCQIIebSzXx/WwsFK+YMABZikWuYlrUCtZpEYv4WRPaHhb064YB41kCfJFSQBh/BAAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+connectyes16:connect connect16 16:photo:16 16:R0lGODlhEAAQAIMAAPwCBAQCBPz+/KSipDQyNMTCxMTGxISChFxaXMzGzAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAARaEMhJZxCjgsAtDtUlCOA1gJQ4kl/IDatAoF7xxkS6GgEBr6jAobCyBX42SQBxMOx6A8MhiGASR8YDgrYsNEeJ0zaEGZY7uoH2oB6nOUwtbdLaVOeTUwo/8UcAACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+devcdmount16:dev dev16 16:photo:16 16:R0lGODlhEAAQAIUAAPwCBFxaXISChNTS1MzKzMTGxMy+vNSytAQCBOzq7OTi5Nza3Oy6vPy2tOTStPz6/Ozu7Nze3MTKxOS2tOzOvNTqvLT2tDw+BPTy9MzOzLS2tPy+tLz+tLz2tLSynLzqvLzavLTOtNTW1KSipPz+/LzKvMTCxDQyNASCBARCBDTSJIT+bAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAa0QIBQGBAYA8Ok0DggFAwHBEIJECQUi8GT0XBMh9YHJDKQTBqUiuUCVmAeiYzmsKlwOt/AAKFIFAIIFx4WHyAhUwIDIgsZFyMkFxchJSYmiBkSBBoIJJwIGgOhiCYFJSEnFyQjFwNZewABISAfFiYnCAEmCREIrwAIFhwVGwcaBAkPGApsQsAVFA0GBQMRbxBTKM0ODQwTEq192ClDgROkBHvYKuNJUu5CKCorX1RDKCkpUn5BACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+devcdunmount16:dev dev16 16:photo:16 16:R0lGODlhEAAQAIUAAPwCBFxaXISChNTS1MzKzMTGxMy+vNSytAQCBOzq7OTi5Nza3Oy6vPy2tOTStPz6/Ozu7Nze3MTKxOS2tNzmvLT2tDw+BPTy9MzOzLS2tPy+tLz+tLz2tLSynLzqvLzavLTOtNTW1KSipPz+/MTCxLy6vDQyNOTm5AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAapQIBQGBAYA8Ok0DggFAwHBEIJECQUi8GT0XBMh9YHJDKQTLqUigWsuDwSmMxBQ9lwvoEBQpEoBBAWHRseHyBTAgMhCxgWIiMWFiASJCSHEgQSGQgjmwglGKCHBQUSICYWIyIWAwshIVMBIB8eFSQmCAEFCREIekIIFRsUGgcZEgkPFydrvxUUDg0GBSEREGJfv9AMEySsJxDYQ4DcEhh64UpS6lTs7QB+QQAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+devdiskmount16:dev dev16 16:photo:16 16:R0lGODlhEAAQAIUAAPwCBAQCBDQyNIRuVKyCXMSKROzSrOzKpOTGnLSafLySZKxuLMSOVPTWvPzixLSehNyibOzOrGxaVJx+XOzGnFw2FJRuPKx+TPTSrHRWPKyKZPTOpHxOJKyKXFw+HKSipISChMTCxFxaXIRiPNSWXExOTOS2hLR+PLRyLPTWtMyOTASCBARCBPz+/DTSJIyKjIT+bAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAaTQIBwCAgYA8SkMCAYDARI5ZJQMBwQiWgyoFgwrA3HQ7scQAqFAcEQOUi0zAkFUSFYLghMBloUCDQNGxwdHhwHekcfICEhICIfIxkLJBABJUYCICABIhAOBiYnKJaXmH4CGSkYCCqkSAEfTKenrkOwsrQll0IrS7G5uwArLLaxLbXCLsTFLyDBKy4wZEVHvCwsRn5BACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+devdiskunmount16:dev dev16 16:photo:16 16:R0lGODlhEAAQAIUAAPwCBAQCBDQyNIRuVKyCXMSKRPTWtOzKpOTGnLSafLySZKxuLMSOVOzOrPzm1LSehNyibGxaVJx+XOzGnFw2FJRuPKx+TPTSrHRWPKyKZPTWvHxOJKyKXFw+HPTOpKSipISChMTCxFxaXIRiPHxaNLRyLNSWXExOTPzixOS2hLR+PMyOTPz+/IyKjAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAaIQIBwCAgYA8SkMCAYDARI5ZJQMBwQiWgyoFgwGgiD46FdDiCFwoDQAEe0TMkEQSFULIcLBloUCDIaDRscHRsNHhhHHyAhISAiHyMkJSYQASdGAiAgASIQKA0pKguXmJl+AiQGFwgrpUgBH0yoqK9DsbO1J5hbsrq8SrgstlJFHy0gwMVFR1J+QQAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+devfloppymount16:dev dev16 16:photo:16 16:R0lGODlhEAAQAIQAAPwCBAQCBMTCxARmZPz+/FSWlLSytKSipERCRIyOjISChOTm5HRydNza3GRiZFRSVASCBARCBDTSJIT+bAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAVrICCOQBCQKBkIw5mqLFG47zoQ+FwbN57TosDhgPD5dMEEIqE04kwlBWKBUEiNVYFpyqAyGEUCgqEtERiNNMLhQKzLQYJg7n7Y4aMAwbCUPvAQeWNgfzQQETAIhSMQEogwgBITQEGGEREmfiEAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+devfloppyunmount16:dev dev16 16:photo:16 16:R0lGODlhEAAQAIMAAPwCBAQCBMTCxARmZPz+/FSWlLSytKSipERCRIyOjISChOTm5HRydNza3GRiZFRSVCH5BAEAAAAALAAAAAAQABAAAARcEMgJQqCYBjFu1hxReN82EOhYGieaklJwHIjrqnGCJLqNWhUFYoFQCG1FgWXIIDIYNQKCoawQGI0swuFAbKsxgmDsfZjBkwDBsNM90Jot9A3DbBD0Dwiur9QnfhEAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+devnetwork16:dev dev16 16:photo:16 16:R0lGODlhEAAQAIQAAPwCBAQCBISChPz+/Nza3ARaZESanCyKlARudARGTLy+vNzq7ARmbMTCxARufAROVMzOzKSipARyfOzq7AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAVmICAGZFmKQiACweCSBImq41AYB5IodLq2hwWO0ejRWDac48Gb/QKNqNRoqspmrVcAUuIJBANS8sBIFCORUgooPEh4J8B67NgdsVBp9C5XWfl9LRMTCyReX19hARNojWlWLH+AAH4hACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+devpc16:dev dev16 16:photo:16 16:R0lGODlhEAAQAIMAAPwCBISChHx+fPz+/AQCBAQC/AT+/AQCxAQChAT+BLy+vAR+BAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAARYEIAgqK1YzsG754QUDERpmkEpkkXrtoK6EcVgHIibhnNx564Yb0TDvQq7FQ34EiqPOhnREqhWSUPsyZSQAbbg7GcMEgwUiYVivTa1R+y4XEGoWO/4AMAfAQAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+devscanner16:dev dev16 16:photo:16 16:R0lGODlhEAAQAIMAAPwCBAQCBPz+/MT+/ASChARCRATCxMTCxFxaXKSipDQyNAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAARTEMgJgqWBVivEldkUdKSXhVjZfenommglDERh3Tc4E4ZRHAGgkEPr9X6H5AHBERSMRyWzkug8jQXFEhWoOo8dRYxqLXSmGjIJnVaz29Q3fAP3RwAAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+devscreen16:dev dev16 16:photo:16 16:R0lGODlhEAAQAIUAAPwCBFxaXFRSVPz+/PT29OTm5OTi5DQyNDw+PERGRExKTHx+fISChIyKjHRydFxeXDQ2NCQmJBQSFAQCBERCRMTGxHR2dGRiZExOTDw6PCQiJAwODCwuLFRWVOzu7BweHAwKDCwqLHx6fBQWFGxqbGRmZAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAanQIBwSCwKAwKkMslEAgSDqDRKqBYKhkNgcDggEorkMrDQchkNhuOhgEQkk0l5S2lUGpYLJqPZTAwMHB0DCmhqAW0Rfh5zAxgOkBcCFAcfIBMECxwBBAEPFw8dChkhcBMDDAcdnQqtFKSWcQMimx4dGRkQBxGxsg6bBQEawx8jl3GnJFoFHRNXVVNRJYIFDAsL1tgiDiQXFx0HABwcXeQH5OjkRutEfkEAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+devspeaker16:dev dev16 16:photo:16 16:R0lGODlhEAAQAIMAAPwCBFxaXAT+/DQyNATCxMTCxPz+/AQCBKSipASChAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAARWEMgJQqCXziDG2JoUEENhZBkmHIWJVptAmqcIW/Js1MiF56TBzkckAAcHoa9nMRKeA4TyJk0knsHhTeK5khBaH2VwLYVh40TJhQ6RzeIQV32Quz8hfwQAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+editcopy16:edit edit16 16:photo:16 16:R0lGODlhEAAQAIUAAFxaXPwCBNze3GxubERCRPz+/Pz29Pzy5OTe3LS2tAQCBPTq3PTizLyulKyqrOzexLymhLy+vPTy9OzWvLyifMTCxHRydOzSrLyihPz6/OTKpLyabOzu7OTm5MS2nMSqjKSipDQyNJyenLSytOTi5NTS1JyanNTW1JSWlLy6vKyurAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAEALAAAAAAQABAAAAaUQIBwCAgYj0eAYLkcEJBIZWFaGBie0ICUOnBiowKq4YBIKIbJcGG8YDQUDoHTKGU/HhBFpHrVIiQHbQ8TFAoVBRZeSoEIgxcYhhkSAmZKghcXGht6EhwdDmcRHh4NHxgbmwkcCwIgZwqwsbAhCR0CCiIKWQAOCQkjJAolJrpQShK2wicoxVEJKSMqDiAizLuysiF+QQAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+editcut16:edit edit16 16:photo:16 16:R0lGODlhEAAQAIEAAPwCBAQCBPz+/ISChCH5BAEAAAAALAAAAAAQABAAAAIwhI9pwaHrGFRBNDdPlYB3bWHQ1YXPtYln+iCpmqCDp6El7Ylsp6ssR1uYSKuW0V8AACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+editdelete16:edit edit16 16:photo:16 16:R0lGODlhEAAQAIUAAPwCBFxaXNze3Ly2rJyanPz+/Ozq7GxqbPT29GxubMzOzDQyNIyKjHRydERCROTi3IyKhPz29Ox6bPzCxPzy7PTm3NS6rIQCBMxCNPTq3PTi1PTezMyynPTm1PTaxOzWvMyulOzGrMymhPTq5OzOtNTKxNTOzNTCtNS+rMSehAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAaKQAAgQCwahcihYMkcBAiBpLJApRoOBWgyIKhSEQkFgrBAcr1URiPhKAsDD3QB8RhA3FM0IlLHnyUTVBMSFBUWfl0XGBMTGBcZGodmcQWKjpAbHIgIBY2LHRoempOdjooTGx8giIOPFYofISJ+DyMXI6AfFySyfiUmJSUnKBYcICIpfgELzM3OZX5BACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+edit16:edit edit16 16:photo:16 16:R0lGODlhEAAQAIYAAPwCBFxaVMR+RPzKjNze3AQCBMR6RPzGjPyODPz+/MzOzPyKDPyKBPz29OTWzPyGDPyGBOx6BOza1OR2BKROBNSOXKRKBBwOBOzu7PTWxPzizOySZPyCDFxaXOy2lNRyRMxmJCQOBPTm1OzStPTKrMR+XIRWLFxGNCQSBDQyNIRSNDQuJERGRLyqlNzSvIx6ZKRuVEw6LLSyrLymhKSShBwaFFROTJyWjMS+vNzW1OTazNzKrHRqXOzezOTOpPTq3OzWvOTStLyedMS+rLy2pMSynMSulAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAewgAAAAYSFhoQCA4IBBI2OjgUGBwiLBAmXlpcKkgsMlZcJBA0JDpIPEBGVjwkSBgOnExSfmBIVBxAMExYXswkYGRobHLq8gh2PHhoeHyAWIYKzIiMkJSYnKCnQg5YNHtQqKywtK9qMBC4vMDEBMjIz2dCMDTQ1Njc4OToz5PEEOzw3ZPToMcLHO23HfogQ0QMIkCA+hPBbhAPHECJFjMyYIUQIvEUpUqwQOXKkSEF+AgEAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+editpaste16:edit edit16 16:photo:16 16:R0lGODlhEAAQAIUAAPwCBCQiFHRqNIx+LFxSBDw6PKSaRPz+/NTOjKyiZDw+POTe3AQCBIR2HPT23Ly2dIR2FMTCxLS2tCQmJKSipExGLHx+fHR2dJyenJyanJSSlERCRGRmZNTW1ERGRNze3GxubBweHMzOzJSWlIyOjHRydPz29MzKzIyKjPTq3Ly2rLy+vISGhPzy5LymhISChPTizOzWvKyurPTexOzSrDQyNHx6fCwuLGxqbOzKpMSabAQGBMS2nLyulMSidAAAACH5BAEAAAAALAAAAAAQABAAAAa7QIBQGBAMCMMkoMAsGA6IBKFZECoWDEbDgXgYIIRIRDJZMigUMKHCrlgul7KCgcloNJu8fsMpFzoZgRoeHx0fHwsgGyEACiIjIxokhAeVByUmG0snkpIbC5YHF4obBREkJCgon5YmKQsqDAUrqiwsrAcmLSkpLrISLC/CrCYOKTAxvgUywhYvGx+6xzM0vjUSNhdvn7zIMdUMNxw4IByKH8fINDk6DABZWTsbYzw9Li4+7UoAHvD+4X6CAAAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+editshred16:edit edit16 16:photo:16 16:R0lGODlhEAAQAIUAAPwCBFxaXNze3Ly2rJyanPz+/Ozq7GxqbGxubMzOzPz69DQyNIyKjERCRPz29PT29OTi3IyKhPz27PTu5PTy5Pz6/Pzy7PTq3OzexLyqlPTm1PTizOzavLyqjOzWvOzaxLyifOzizOTOpAQCBOzezAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAaEQAAgQCwahcihYMkcBAiBpLJApRoOBWgyIKhWEQkFYYHkeqkMxKFBFpq9jgdkEGlPqwrJhCIY2N8FFRYUFxcYGX9dgRKEGhiHiYEOhBcbGBwdiQEOARcBGwEeAZllAgEUnQEfoQEgmp4hrCKtrwEYsrRlTiMBJAG8syN/IyMAxMXHSH5BACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+edittrash16:edit edit16 16:photo:16 16:R0lGODlhEAAQAIIAAPwCBAQCBKSipFxaXPz+/MTCxISChDQyNCH5BAEAAAAALAAAAAAQABAAAANQCKrRsZA5EYZ7K5BdugkdlQVCsRHdoGLMRwqw8UWvIKvGwTICQdmGgY7W+92GEJKPdNwBlMYgMlNkSp3QgOxKXAKFWE0UHHlObI3yyFH2JwAAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+fileclose16:file file16 16:photo:16 16:R0lGODlhEAAQAIQAAPwCBCQiJBwaHAQCBDQyNDw6PFxaXFRSVERGRCwqLAwODGRiZHx6fPz+/GxqbAwKDCQmJAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAVaICCOZGmeqBgEwjCkRGEcSKK4JrEcBrMgAdeLVDg0GguGsYEbBQyGYyN6FDoPDIf0+LCKBIgetQERDgGDBGIpNY8GioAU0m6KXFw883w3+/l9f4AkfimGIn4hACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+filedocument16:file file16 16:photo:16 16:R0lGODlhEAAQAIUAAPwCBFxaXNze3Ly2rJSWjPz+/Ozq7GxqbJyanPT29HRydMzOzDQyNIyKjERCROTi3Pz69PTy7Pzy7PTu5Ozm3LyqlJyWlJSSjJSOhOzi1LyulPz27PTq3PTm1OzezLyqjIyKhJSKfOzaxPz29OzizLyidIyGdIyCdOTOpLymhOzavOTStMTCtMS+rMS6pMSynMSulLyedAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAaQQIAQECgajcNkQMBkDgKEQFK4LFgLhkMBIVUKroWEYlEgMLxbBKLQUBwc52HgAQ4LBo049atWQyIPA3pEdFcQEhMUFYNVagQWFxgZGoxfYRsTHB0eH5UJCJAYICEinUoPIxIcHCQkIiIllQYEGCEhJicoKYwPmiQeKisrKLFKLCwtLi8wHyUlMYwM0tPUDH5BACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+filefind16:file file16 16:photo:16 16:R0lGODlhEAAQAIYAAPwCBCQmJDw+PBQSFAQCBMza3NTm5MTW1HyChOT29Ozq7MTq7Kze5Kzm7Oz6/NTy9Iza5GzGzKzS1Nzy9Nz29Kzq9HTGzHTK1Lza3AwKDLzu9JTi7HTW5GTCzITO1Mzq7Hza5FTK1ESyvHzKzKzW3DQyNDyqtDw6PIzW5HzGzAT+/Dw+RKyurNTOzMTGxMS+tJSGdATCxHRydLSqpLymnLSijBweHERCRNze3Pz69PTy9Oze1OTSxOTGrMSqlLy+vPTu5OzSvMymjNTGvNS+tMy2pMyunMSefAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAe4gACCAAECA4OIiAIEBQYHBAKJgwIICQoLDA0IkZIECQ4PCxARCwSSAxITFA8VEBYXGBmJAQYLGhUbHB0eH7KIGRIMEBAgISIjJKaIJQQLFxERIialkieUGigpKRoIBCqJKyyLBwvJAioEyoICLS4v6QQwMQQyLuqLli8zNDU2BCf1lN3AkUPHDh49fAQAAEnGD1MCCALZEaSHkIUMBQS8wWMIkSJGhBzBmFEGgRsBUqpMiSgdAD+BAAAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+filenew16:file file16 16:photo:16 16:R0lGODlhEAAQAIUAAPwCBFxaXNze3Ly2rJyanPz+/Ozq7GxqbPz6/GxubNTKxDQyNIyKhHRydERCROTi3PT29Pz29Pzy7PTq3My2pPzu5PTi1NS+rPTq5PTezMyynPTm1Pz69OzWvMyqjPTu5PTm3OzOtOzGrMSehNTCtNS+tAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAZ/QAAgQCwWhUhhQMBkDgKEQFIpKFgLhgMiOl1eC4iEYrtIer+MxsFRRgYe3wLkMWC0qXE5/T6sfiMSExR8Z1YRFRMWF4RwYIcYFhkahH6AGBuRk2YCCBwSFZgdHR6UgB8gkR0hpJsSGCAZoiEiI4QKtyQlFBQeHrVmC8HCw21+QQAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+fileopen16:file file16 16:photo:16 16:R0lGODlhEAAQAIUAAPwCBAQCBOSmZPzSnPzChPzGhPyuZEwyHExOTFROTFxaVFRSTMSGTPT29Ozu7Nze3NTS1MzKzMTGxLy6vLS2tLSytDQyNOTm5OTi5Ly+vKyqrKSmpIyOjLR+RNTW1MzOzJyenGxqZBweHKSinJSWlExKTMTCxKyurGxubBQSFAwKDJyanERCRERGRAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAaRQIBwGCgGhkhkEWA8HpNPojFJFU6ryitTiw0IBgRBkxsYFAiGtDodDZwPCERCEV8sEk0CI9FoOB4BEBESExQVFgEEBw8PFxcYEBIZGhscCEwdCxAPGA8eHxkUGyAhIkwHEREQqxEZExUjJCVWCBAZJhEmGRUnoygpQioZGxsnxsQrHByzQiJxz3EsLSwWpkJ+QQAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+fileprint16:file file16 16:photo:16 16:R0lGODlhEAAQAIUAAPwCBFRKNAQCBPz+/MTCxExKLPTq5Pz29Pz6/OzezPT29PTu7PTy7NzClOzm1PTu5LSabJyanPTm3FxaXOzCjOTKrOzi1OzaxOTSvJyenGRmZLyyTKSipDQyNERCROTi5Hx+fMzKzJSSlIyOjISChLS2tAT+BDw6PAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAaYQIBwKAwIBMTkMDAYEApIpVBgOCAOg4RRGlAoEAuGIdGITgWOq4LxcCQgZkEkIHksHgYJOR6ZQCgVFhYJFxgTBVMZihoCfxUYDWUbUBGKGREcjBoQEB2TAB4CAx+Vl5WMhyACHiEhH6IfIiMktCQgE0cZJQStr6O2t6EARxO6vK6iEx4dZsMCxbsmBB4nzUTEutVSSUdmfkEAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+filesave16:file file16 16:photo:16 16:R0lGODlhEAAQAIUAAPwCBAQCBFRSVMTCxKyurPz+/JSWlFRWVJyenKSipJSSlOzu7ISChISGhIyOjHR2dJyanIyKjHx6fMzOzGRiZAQGBFxeXGRmZHRydGxqbAwODOTm5ExOTERGRExKTHx+fGxubNza3Dw+PDQ2NAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAaAQIAQECgOj0jBgFAoBpBHpaFAbRqRh0F1a30ClAhuNZHwZhViqgFhJizSjIZXQCAoHOKHYw5xRBiAElQTFAoVQgINFBYXGBkZFxYHGRqIDBQbmRwdHgKeH2YgHpmkIR0HAhFeTqSZIhwCFIdIrBsjAgcPXlBERZ4Gu7xCRZVDfkEAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+folder16:folder folder16 16:photo:16 16:R0lGODlhEAAQAIYAAPwCBAQCBExKTBwWHMzKzOzq7ERCRExGTCwqLARqnAQ+ZHR2dKyqrNTOzHx2fCQiJMTi9NTu9HzC3AxmnAQ+XPTm7Dy67DymzITC3IzG5AxypHRydKymrMzOzOzu7BweHByy9AyGtFyy1IzG3NTu/ARupFRSVByazBR6rAyGvFyuzJTK3MTm9BR+tAxWhHS61MTi7Pz+/IymvCxulBRelAx2rHS63Pz6/PTy9PTu9Nza3ISitBRupFSixNTS1CxqnDQyNMzGzOTi5MTCxMTGxGxubGxqbLy2vLSutGRiZLy6vLSytKyurDQuNFxaXKSipDw6PAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAfDgACCAAECg4eIAAMEBQYHCImDBgkKCwwNBQIBBw4Bhw8QERITFJYEFQUFnoIPFhcYoRkaFBscHR4Ggh8gIRciEiMQJBkltCa6JyUoKSkXKhIrLCQYuQAPLS4TEyUhKb0qLzDVAjEFMjMuNBMoNcw21QY3ODkFOjs82RM1PfDzFRU3fOggcM7Fj2pAgggRokOHDx9DhhAZUqQaISBGhjwMEvEIkiIHEgUAkgSJkiNLmFSMJChAEydPGBSBwvJQgAc0/QQCACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+folderhtml16:folder folder16 16:photo:16 16:R0lGODlhEAAQAIYAAPwCBAQCBERGRBQWFMzKzOzq7CwqLDw6NARqnAQ+XHR2dKyqrOTm5ExKTERCRHRydMTi7NTu9HS+1KSmpBweHDy67DyixHS61ITG3AxypByu7DxinBw+ZERmdIySjITC3ARypExOTDRurIR2RPTSdJyulEyGvBw+bFSyzJTK3LzKvPzivOTixNTChLSybGyCfCRSnBQqRASGtFyuzDw+PCRShPzy5OzerOTShKyaTEx6pCxerGRufBR+rOTezPTShNy6bER+1BxCfBQuRAxelFSixBw2VISq3GySrPTWlHyanIyitFSO3IymtCRujAxWhCRqlCQ6XGyWvNS2bFyGvDxuvCRSpLy+vMS+vGxqbFyO1GSi3EyO1FRaVCQuPLS2tDxyzKyWNFxaNCQyPGxubCxajERSVExKNJyenAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAfZgACCAAECg4eIAAMEBQICBomDBwgJCgsEDA0BDg8BhwYQERKUDxOYDAyeghQVFhehGBmVlwwOqxobHB0eH6EfIAkPIYIiIyQlJhsnKBcpvrYiKissLS4vMDEyFjOvNAA1LDY3ODk6Oyc8PTIyFzQ1Jj42P0A6QTtCQ0REIEUORkdIkihZwsSekBhNnDyBciCKiSNSplDRUcWKkRhXCGDJYgiGli1cpuTocsILjytfFmRpACAGRTBhRogZgzHlAjKGWnIoY+bMgRgBDHRBo/LAIZoxuhwKatRPIAAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+folderlocked16:folder folder16 16:photo:16 16:R0lGODlhEAAQAIYAAPwCBAQCBExKTBQSFMzKzOTm5CwuLERCRARqnAQ+XHR2dKSmpOzm5GxqbCQiJMTi7NTu9HS+1HRydOTm1Ozq7Dy67DyixHS61ITC3AxypERGRBweHByu7ASGtFyy1DSOtDRmfExOTBSazBR+rCwqLAxWhAxelByGtDSaxAwODHy+1Dw+PPT29IyqvCxujOzu7NTW1Nza3ExGJJyebKyqfMTCpFRSPOTi5DQqHOTezDw2NMTGxKyqhMTGrGxmXDQ2NMTCxMTGpHx6bHx2bBQWFIyOXDQuDAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAfDgACCAAECg4eIAAMEBQICBomDBwgJCgsEDAKFDQGHDg8QEZQSlxMUDJ2CDhUWF6AYGZWXFBqCGxwdFh4XGK8fIAohtiIIIx25EZwBDREHgiQjJSYmGScoKSoRKQ8rggIsDC0uJS4oGygoAyjdAAcsLxQUMDEyMzQ1EzapBy8MDDc36tFwgONFjlQ6dgCEEZBHDx8+ctRIRehHAyAwZASZIGRIEBoUBwUwIGMCiwFEaBQJichIjo9FZLBsacRIAB0A/AQCACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+foldernew16:folder folder16 16:photo:16 16:R0lGODlhEAAQAIUAAPwCBAQCBPz+hPz+BOSmZPzSnPzChFxaXMTCBPyuZPz+xPzGhEwyHExOTPz+/MSGTFROTPT29OTm5KyurDQyNNza3Ozq5Nze3LR+RLy+vJyenMzKzNTS1Ly6vJSWlFRSTMzOzMTGxLS2tKSmpGxubBQSFAwKDKSinJyanIyOjCQiJERCRERGRBweHAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAaNQIBwSCwaj8ikcokMCIqBaEDoBAQG1meAUDAQpIcBQoy1dg2JdBqhECgQ1IWB0WgcBIOBwIHXBwwPEBEREhIBbG4IExR/DBUVFhIXV2NjDVYYDY8SFU4ZVxpVAQwbGxynGxkdTh6XVh8gGSGzGSITIxokJUImGSMTwLcnKCkprgAqDSt1zCssKxQtQ35BACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+folderopen16:folder folder16 16:photo:16 16:R0lGODlhEAAQAIYAAPwCBAQCBExKTBQWFOzi1Ozq7ERCRCwqLPz+/PT29Ozu7OTm5FRSVHRydIR+fISCfMTCvAQ6XARqnJSKfIx6XPz6/MzKxJTa9Mzq9JzO5PTy7OzizJSOhIyCdOTi5Dy65FTC7HS2zMzm7OTSvNTCnIRyVNza3Dw+PASq5BSGrFyqzMyyjMzOzAR+zBRejBxqnBx+rHRmTPTy9IyqvDRylFxaXNze3DRujAQ2VLSyrDQ2NNTW1NTS1AQ6VJyenGxqbMTGxLy6vGRiZKyurKyqrKSmpDw6PDw6NAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAfCgACCAAECg4eIAAMEBQYCB4mHAQgJCgsLDAEGDQGIkw4PBQkJBYwQnRESEREIoRMUE6IVChYGERcYGaoRGhsbHBQdHgu2HyAhGSK6qxsjJCUmJwARKCkpKsjKqislLNIRLS4vLykw2MkRMRAGhDIJMzTiLzDXETUQ0gAGCgU2HjM35N3AkYMdAB0EbCjcwcPCDBguevjIR0jHDwgWLACBECRIBB8GJekQMiRIjhxEIlBMFOBADR9FIhiJ5OnAEQB+AgEAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+mailforward16:mail mail16 16:photo:16 16:R0lGODlhEAAQAIYAAIx+fIRydHxubHxmZGxiXHRmZFxOTFxGPFxKTPwCBLymlMy+pOze3PTq3PTu5Pzy7LSmnOTaxOzm5LyqlNzOtPz69Pz27MzCtLyqrPT27IRubPzuzNTGvNTCxLSelPz25Bw+ZFxKPPzy1Pz65LyupBxKdCxWfPTm1Pz23LyinBxGbGzO5DRafBxWfBxajCymxHTS5BxSdBxKbFTK3EzG1CSGvCyKvCSSxCSavGTO5GRaVPzqzFzK5EzG3BSCtAwiPGxaVPTivPzy3NzKpBxObCRefBxqlPTmzJR2bKyahAwyRPzmvOTOpKyObNS+nPz21AQOFKyOfPzuxAQCBGRORLSadPzyzLymjMy2lOzetDwuJFRCPEw6NEQ6LEQyLEQ6NAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAkALAAAAAAQABAAAAfhgAABAgIDBAQFBgcIBwmOCQIKCwwNDg8OEBESjY8CDBMUFRYVFxgZDJyOGhsPChwVHR4fFSAhjwkaIiMOJBQQDRUVJSa3GicoHw4pEA8SGSorLI8tLtQu19gqLzDECTEyMzQ14zY1Njc3ODkqCTo7MjIxNCs5PD03PjctPwlAQUIihhBpQbCIihtG+CUocASFkAhIkogQ8kFJwkcFlogIkoRJEydPnkBR6GiAxiQLgiiIIkXElFQJqESoMsRKkAhXqkhhApNKFSxZggTJ4nHIEJhaDhzYwoVLFy1avHyB6ScQACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+mailget16:mail mail16 16:photo:16 16:R0lGODlhEAAQAIUAAPwCBAxKdBRSfCyGvFSm1BxKfCSWzCyWzBRCXCRKfBwuRAQGDDw6PHy23Cym1CSSxByCxBxunBQSFKyurMTCxExihNza3NTW1JSSlMzKzFxaXLS2tNze3KSipCQmJGxmbNTS1KSepLy2vISGhJSWlHx+fERGRPz6/IyKjDw+POzq7JyenMzOzKSmpCwuLDQyNIyOjAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAaeQIBwGBAIAsOkUjAgFJRQQMHgjC4PBIEVgAh4D4aEYrGAMhINxwPyiCgYSsmEUmk82grLRZJkYCgXaAEKFxYZcEISGhsZFxwFeY0WHR5CDB8dGCAXG5shGxQicBIMpSMUGxgTGSQlpQwSJicnEwwdI7gdKAwTsykpKiobr8QMKxeHDBcsGRvOzxsT0i0uL9HSHdkT2ZkoMJXF4a8AfkEAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+mail16:mail mail16 16:photo:16 16:R0lGODlhEAAQAIUAAPwCBGxaVOTe1Oze3OTWxOTWvNzStNzKpEQ6LOTezPz+/Pzy7Pz69Pz27Pz25Pz21PzuzPzuxEQyLLyinLSmnPz67Pz23LSafKyObDwuJMzCtLSelPzy1My6nLymjNTCxLyqnPzq1LyihKyOfOzavOzetEQ6NPTq3NzOtLymnNTGxJR2bOTOpPTivNTGvLymlKSShKyahEw+NOTe3PTm1Pzu1Pzy3FRCPPz65LSadFxGPOzm3PzqzPTmzPzmvEw6NCH5BAEAAAAALAAAAAAQABAAAAaqQIBwSCwaj8ikMhloOp/QpmAgqAoIhELBUDgcEIGEYrFgNBoLx+IBiRwkgQnFoWAwKhWLhX3BZAILGhsCDXgODhwdGB5vgAofICBlDiEiIx4kJSYBJ2UoEykqHSMrLC0nLWAnFS4UCycvMAcEMR0RLTIBMwaSahw0NTYtFwclNwEdLws4eoc2DxwQOR06ASk7PBAhIRE9Pj0tLSUY1T8I5gjn6Qgy7D8SfkEAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+mailreplyall16:mail mail16 16:photo:16 16:R0lGODlhEAAQAIYAAIx+fIRubHxubHxqbHxmZGxeXHRmZGROTFRCPFxKTFxGPPwCBLymlMy6pOTa1PTq3PTu5Pz27Dw+POzi3PTm1OTWvPz25FRSVERCRLympPzuzPTu7NTGvFxaXKSmpPzu1Pz65Hx6fHxqZPzq1Pz23HR2dBw+ZHx+fISChJSWlDQmJHRydCxWfBxGbJyenExKTHRiXPzqzPzy3CQmJDRafGTO5ExOTERKTGxWVCRSfHTS5CymxBxajBxWfPTmvPzy1CyixCSaxCySxDSaxDSWxDSSvDyaxGS21PTmzPz21AwiPBRejCSavByGtCSezEzG3FzK5FzG3GzO5FTK3CQ2bPTixBxqlCRefBxSdBxSfBx2nCQ+dHxmXPzmvLSafAwmRAwyRPzyzDw6POzavNzKpAQOFPzuxBwWTBw2ZGRORLyWdMy2lOzetPTivAQCBKyObOTOpAweNBwWVEQyLEw2LEQ2LDwuJAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAsALAAAAAAQABAAAAf4gAABAgMEBQUGBwgJCguOCwEMDQ4PEBESDA4TjY8DFAwVERYXGBkRm4+QGhsMHB0eGB8bDpyOARogEBceIRgXv8COIiMkGB4lJSYnIcwoKb/DGyoXKywtKS4pHinMLzAxJDIzNDUtNjcv6B0hLzgfMh85OjstPDw99zwd7T4/LTVAgggZQqSIECNHevSAgSSJkiVMmjh5AiWKlClAiFARUeVHFSVWmLS40gNLlh5agGzh0kWDlwZfrIDREKaCAjEqrFA5MMYLmTAxlJTxYoZMozNozqRRs4ZNmy5s3LwhA0dBnDNn5MxBoAABnTp17IitowDrmQV+AgEAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+mailreply16:mail mail16 16:photo:16 16:R0lGODlhEAAQAIYAAIx+fIRubHxubHxqbHxmZGxeXHRmZGROTEw+NFxKTFxGPPwCBLymnMy6pOTa1PTm1Pzy7LymlOzi3HxqZOTWvPz69Pz25My+tLympFRGRHxuZPzu1LymjNTGvNTCxBw+ZPz23PzuzPz65PTu5NzOtCxWfBxKbPzq1DRafGTO5BxGbPzy9HTS5CymxBxajHRiXPzqzCyixCSaxCySxDSaxDSSvGS21GxWVAwmRBRejCSavByGtCSezEzG3FzK5FzG3CQ2bPzuxAwiPBxqlBxKdCRefBxWfBxSdBxSfBx2nCQ+dPzy1CRqlAwyRDQmJPTmvPTixLSafOTOpAQOFPz21BwWTBw2ZPzmvNS6nPTivAQCBAweNBwWVNzKpPzyzLyihGRORLyWdMy2lOzetKyObEQyLEw6NEw2LDwuJEQ2LAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAsALAAAAAAQABAAAAfqgAABAgMEBQUGBwgJCguOCwEMDQ4PEJYRDhKNjxMPDBQVFhAXGBUSGY8LGhsQHB0VHh8gFQ6bjgEhIiMMJCUmFbS2CwMnG6IoKSorI7WpEycWFiUsLSou1yXXji8wFiopMTIzNDUz4zbZNxsbODk6Ozw9Pj8pPzEzQDdB60JDOkRFjBw5giRJDCWdlmxwIIRJExAWKDRyMgTIiydLoESRImQKlSUSF1SxUoXAlSBRsGSJoCVICIlbqlThcoBClC5eYFD4EiVIFwUyqywAE0ZMlqNjpJDpIkUBl0dlFChAYOZMmTJoyqQR5icQACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+mailsend16:mail mail16 16:photo:16 16:R0lGODlhEAAQAIYAAIx+fIRubHxubHxqbHxmZGxeXHRmZGROTFRCPFxKTFxGPPwCBHxqZLyqlMy6pOze3PTq3PTu5Pz27Pzy7LyinOTaxOzi3Ozq3LymlOTOtPz69Pzy5My+tLympPzqzNTGvLSelPzy3BxGbBQ6VPzuzPz65LyupNzOtPz+/GzO5BRejPzq1Pz23LymjHTS5CyixCSavBxqlPz25LymnGTO5CymxCSaxByGtHRiXPzy1CySxCSezGxWVPzuxKyOhMy6nDSaxEzG3PTivNzKpKyOfPzu1FzK5PTmzJR2ZLyihLSWfKyObOzmzPzmvDyaxOzavLSafGRORMy2lOzetDwuJEw6NEw2LEQyLAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAsALAAAAAAQABAAAAfUgAABAgMEBQUGBwgJCguOCwwNDg8QERITFBUWjY8DFxgZGhsaHB0aD5yODB4TGB+kICEaIiOPCwEkJRcmJyYPKCIpKrWqKywTmC0SIi4vMDHEDCsyMg8zEyI0NTY3z7U4Hhs5Mx+0IyI6OyPrIzw9Gys+PxIy2EBBxAs8Qjk5Q0RFWFxAZySfgSMsilRAkiRECHQ08hHgJ0TJkCU/mECU2ISEkowUlpAQ4QTfowNPoAzJIeRJCyjm8kVRIkWIzSkXhwxJtYAKgp9VrFi5QoWKFZ5+AgEAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+nav1downarrow16:nav nav16 16:photo:16 16:R0lGODlhEAAQAIAAAPwCBAQCBCH5BAEAAAAALAAAAAAQABAAAAIYhI+py+0PUZi0zmTtypflV0VdRJbm6fgFACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+nav1leftarrow16:nav nav16 16:photo:16 16:R0lGODlhEAAQAIAAAP///wAAACH5BAEAAAAALAAAAAAQABAAAAIdhI+pyxqdwoNGTmgvy9px/IEWBWRkKZ2oWrKu4hcAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+nav1rightarrow16:nav nav16 16:photo:16 16:R0lGODlhEAAQAIAAAPwCBAQCBCH5BAEAAAAALAAAAAAQABAAAAIdhI+pyxCtwoNHTmpvy3rxnnwQh1mUI52o6rCu6hcAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+nav1uparrow16:nav nav16 16:photo:16 16:R0lGODlhEAAQAIAAAPwCBAQCBCH5BAEAAAAALAAAAAAQABAAAAIYhI+py+0PWwhxzmetzFpxnnxfRJbmufgFACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+nav2downarrow16:nav nav16 16:photo:16 16:R0lGODlhEAAQAIAAAPwCBAQCBCH5BAEAAAAALAAAAAAQABAAAAIfhI+pq+EPXYpxUckoO3AjbF3dJwahllXe6AFgC8d+AQAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+nav2leftarrow16:nav nav16 16:photo:16 16:R0lGODlhEAAQAIAAAPwCBAQCBCH5BAEAAAAALAAAAAAQABAAAAImhI+pyxf5VohmSlsxmpjTzAHeN5ak6UHpqKRi2GpwvH3Q3eT64RcAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+nav2rightarrow16:nav nav16 16:photo:16 16:R0lGODlhEAAQAIAAAPwCBAQCBCH5BAEAAAAALAAAAAAQABAAAAImhI+pq5HOAjQyVnqfhHue7oAaKH5kiW0AmnLqaHomkj02g+e6XwAAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+nav2uparrow16:nav nav16 16:photo:16 16:R0lGODlhEAAQAIAAAPwCBAQCBCH5BAEAAAAALAAAAAAQABAAAAIghI+pyxfR0HsRzNnuXVqn3mVQZWFRyIDjp65Ga5Ly4hcAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+navback16:nav nav16 16:photo:16 16:R0lGODlhEAAQAIUAAPwCBBRSdBRObCQ2TBxObISevAQCBNzu/BRGZPz6/FzC3Pz+/HTS5ByyzJze7Mzq9ITC3AQWLAyWvBSavFyuxAwaLAwSHBRafBSOrDzW5AyixCS61ETW3CzG1AQeLAweLAxefBSStEze7CSWtCyatBSCnBRWfAwmPBRWdByixAQSHAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAZiQIBwSCwah4HjUTBQFgkFg3MoKBykU0QhoUAIAuAksbpgNByPxQMSGVsVDYlkIqdUiJYLJqORbDgcHRseRR8gISIaEyMkGCVYRBEmeyAnlgaQkSgpmU4RAZ1OKqFOpFNGfkEAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+navdown16:nav nav16 16:photo:16 16:R0lGODlhEAAQAIUAAPwCBBRObCRKZBxCXAwyTKTK3Ozy/NTm9GSivAQWHNzu/FzC3IzO5CySrAQOHAyuzETS3CSWtAyOtETa5Aw2VLze7ByWtBy61BSavAxWdBRCXAwqPAQCBDR+nKTe7FS+1Eze7ByixBRmjPz+/AyexAyixAQKFBRqjAQGDAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAZeQIBwSCwaj0hAYCkYEJLKguGASEADigWj4bgaHpBINykwSCYRa5HCFFQsF0xGo9lwhpSOwfORYC4gISJ3RAQdIyQYJSAlImNrh4uNJkl5CoKUUBQnjlB4KJ6hokN+QQAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+navforward16:nav nav16 16:photo:16 16:R0lGODlhEAAQAIUAAPwCBAwyTBRObAw2VDR+nCRKZOzy/KTe7Pz+/KTK3Nzu/Lze7FS+1AyexAyuzBSavAyOtBSmzOTy/BRqjNTm9IzO5ETS3ETa5By61AyixByixBRmjAQGDBxCXGSivCySrCSWtBTC3AQOHAQWHAxWdEze7AQKFBRCXAwqPAQCBAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAZjQIBwSCwahYGjUjBQGgWEpHNYMBCaT4G2UDggos+EwmBYMBpf6VBgYDgeEMgjIpmoAQVKxXLBPDIXGhscRB0eHyAgDSGBGyJFASMiIiMkJYImUwAnmJqbjp4AKCmhAKSlTn5BACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+navhome16:nav nav16 16:photo:16 16:R0lGODlhEAAQAIUAAPwCBDw6PBQWFCQiJAQCBFxeXMTCxJyanDwyLDQqLFRSVLSytJSSlISChCQmJERGRFRWVGxubKSmpJyenGRmZLy+vOzq7OTi5Ly6vGRiZPTy9Pz6/OTm5ExOTPT29BwaHNza3NS6tJRqRGQqBNy6pIyKjDwGBPTe1JSWlDQyNOTGrNRiBGwmBIRaLNymdLxWBHxGFNySXCwqLKyqrNR6LKxGBNTS1NTW1Jw+BEweDDQ2NAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAaoQIBwCAgIiEjAgAAoGA6I5DBBUBgWjIZDqnwYGgVIoTGQQgyRiGRCgZCR1nTFcsFkHm9hBp2paDYbHAsZHW9eERkYGh4eGx4ag3gfSgMTIBshIiMkGyAlCCZTEpciJyQjGxcoKUQBEhcbIiorLB4XEltDrhcaLS4vtbcJra8bMDHAGrcyrTMXHjA0NSypEsO6EzY3IzU4OdoTzK0BCAkDMgkIOjJlAH5BACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+navup16:nav nav16 16:photo:16 16:R0lGODlhEAAQAIUAAPwCBBRObAwSHBRSdISevBRWfAweLNzu/BSOrAQWLPz6/FzC3DzW5BxObHTS5ByyzAyixEze7BSStBRWdAyWvByixAQSHCQ2TAQCBBRGZJze7CS61BSavAxefMzq9ETW3CSWtAwmPPz+/CzG1ITC3FyuxBSCnAQeLAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAZfQIBwSCwaj8hhQJAkDggFQxMQIBwQhUSyqlgwsFpjg6BwPCARySSstC4eFAqEURlYhoMLBpPRUDYcHXt7RgUeFB8gIU0BIoiKjAcUIwiLSQUkJRsmGIwJJwmEU6OkfkEAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+playeject16:play play16 16:photo:16 16:R0lGODlhEAAQAIAAAPwCBAQCBCH5BAEAAAAALAAAAAAQABAAAAIbhI+py+0R3IFQUtruXVqn3kkWyIARR4rqKvoFACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+playend16:play play16 16:photo:16 16:R0lGODlhEAAQAIAAAPwCBAQCBCH5BAEAAAAALAAAAAAQABAAAAIjhI+py8Eb3ENRggrxjRnrVIWcIoYd91FaenysMU6wTNeLXwAAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+playpause16:play play16 16:photo:16 16:R0lGODlhEAAQAIAAAPwCBAQCBCH5BAEAAAAALAAAAAAQABAAAAIfhI+py+1vgoxzyUCxrZd18ClfmIyVyJ1lqkHuC0N+AQAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+playstart16:play play16 16:photo:16 16:R0lGODlhEAAQAIAAAPwCBAQCBCH5BAEAAAAALAAAAAAQABAAAAIjhI+pyxudwlNyguqkqRZh3h0gl43hpoElqlHt9UKw7NG27BcAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+playstop16:play play16 16:photo:16 16:R0lGODlhEAAQAIAAAPwCBAQCBCH5BAEAAAAALAAAAAAQABAAAAIahI+py+1vgpySUWpvXXqrHmSaeJEYhKYq6hcAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+textblock16:text text16 16:photo:16 16:R0lGODlhEAAQAIAAAPwCBAQCBCH5BAEAAAAALAAAAAAQABAAAAIahI+py40Bo5SOzRvrwlgrfnkJOIkPaaaJXwAAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+textbold16:text text16 16:photo:16 16:R0lGODlhEAAQAIAAAPwCBAQCBCH5BAEAAAAALAAAAAAQABAAAAIihI+py70BowPQ1HZpwNv212Vg9IGHmIjoWa4ey5DSRNd+AQAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+textbottom16:text text16 16:photo:16 16:R0lGODlhEAAQAIAAAPwCBAQCBCH5BAEAAAAALAAAAAAQABAAAAIVhI+py+0Po5y0hYtzrkB7zH0fN/kFACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+textcenter16:text text16 16:photo:16 16:R0lGODlhEAAQAIAAAPwCBAQCBCH5BAEAAAAALAAAAAAQABAAAAIbhI+pm+EPIZsnRkqtDnhu1zHfFSpjaY4PavgFACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+textitalic16:text text16 16:photo:16 16:R0lGODlhEAAQAIAAAPwCBAQCBCH5BAEAAAAALAAAAAAQABAAAAIahI+py+0BgztwUmmjBXX3jE0auHHhM5Yq4xcAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+textleft16:text text16 16:photo:16 16:R0lGODlhEAAQAIAAAPwCBAQCBCH5BAEAAAAALAAAAAAQABAAAAIbhI+pm+EPIZsgRoqr3Vnt102fFSJjUC6nlPoFACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+textmiddle16:text text16 16:photo:16 16:R0lGODlhEAAQAIAAAPwCBAQCBCH5BAEAAAAALAAAAAAQABAAAAIXhI+py+0PT5i01pisphjt3UmfFZYm5hcAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+textmove16:text text16 16:photo:16 16:R0lGODlhEAAQAIAAAPwCBAQCBCH5BAEAAAAALAAAAAAQABAAAAIbhI+pm+EPIZsg2kfZvblXbwTg10WlA4rjyvgFACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+textright16:text text16 16:photo:16 16:R0lGODlhEAAQAIAAAPwCBAQCBCH5BAEAAAAALAAAAAAQABAAAAIahI+pm+EPIZstSrqsDhhv1ylfFE5jiYwX6hcAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+textsortdec16:text text16 16:photo:16 16:R0lGODlhEAAQAIIAAAT+BPwCBAQCBAQC/FxaXAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAM5CBDM+uKp8KiMsmaAs82dtnGeCHnNp4TjNQ4jq8CbDNOroIe3ROyEx2A4vOgkOBzgFxQ6Xa0owJ8AACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+textsortinc16:text text16 16:photo:16 16:R0lGODlhEAAQAIIAAAT+BAQC/AQCBPwCBFxaXAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAM4CAqxLm61CGBs81FMrQxgpnhKJlaXFJHUGg0w7DrDUmvtPQo8qyuEHoHW6hEVv+DQFvuhWtCFPwEAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+text16:text text16 16:photo:16 16:R0lGODlhEAAQAIAAAPwCBAQCBCH5BAEAAAAALAAAAAAQABAAAAIlhI8Jwe2/AmpTynqPTXSqrnBM+I0kdmpmGmUp+K4nPMvhYx9+AQAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+texttop16:text text16 16:photo:16 16:R0lGODlhEAAQAIAAAPwCBAQCBCH5BAEAAAAALAAAAAAQABAAAAIWhI9pwe2uYnq0yQtqxbz7D4biSIZ+AQAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+textunder16:text text16 16:photo:16 16:R0lGODlhEAAQAIAAAPwCBAQCBCH5BAEAAAAALAAAAAAQABAAAAIjhI+pu+FxXoOIKpds1oBH7hlYxYxRCaIZ01lhJbHy9tTv7BcAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+viewchoose16:view view16 16:photo:16 16:R0lGODlhEAAQAIIAAPwCBDQyNAQCBPz+/PzerAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAMzCLrcGlAs6UAYgwLdLtEcI4ygQo7VVp2oupGpG4vmaUVTemX523qlFcw0a4RqNlkx5k8AACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+viewdetailed16:view view16 16:photo:16 16:R0lGODlhEAAQAIIAAPwCBDQyNAQCBPz+/PzerAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAMmCLrc/i1IAVkYg1Z1iRYUKCqitp1oikqBWV3ZOnhkWNagqu+qnwAAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+viewicon16:view view16 16:photo:16 16:R0lGODlhEAAQAIIAAPwCBDQyNAQCBPz+/PzerAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAMwCLrcG1AwGOQbw6qANeCEB3pCSZpO6pgowJZqLKuUGE0dnuEhf8IL1kz1shSHDX8CACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+viewmag-16:view view16 16:photo:16 16:R0lGODlhEAAQAIUAAPwCBCQmJDw+PAwODAQCBMza3NTm5MTW1HyChOTy9Mzq7Kze5Kzm7OT29Oz6/Nzy9Lzu7JTW3GTCzLza3NTy9Nz29Ize7HTGzHzK1AwKDMTq7Kzq9JTi7HTW5HzGzMzu9KzS1IzW5Iza5FTK1ESyvLTa3HTK1GzGzGzG1DyqtIzK1AT+/AQGBATCxHRydMTCxAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAZ+QIAQEBAMhkikgFAwHAiC5FCASCQUCwYiKiU0HA9IRAIhSAcTSuXBsFwwk0wyYNBANpyOxPMxIzMgCyEiHSMkGCV+SAQQJicoJCllUgBUECEeKhAIBCuUSxMKIFArBIpJBCxmLQQuL6eUAFCusJSzr7Kmpl0CtLGLvbW2Zn5BACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+viewmag16:view view16 16:photo:16 16:R0lGODlhEAAQAIUAAPwCBCQmJDw+PAwODAQCBMza3NTm5MTW1HyChOTy9Mzq7Kze5Kzm7OT29Oz6/Nzy9Lzu7JTW3GTCzLza3NTy9Nz29Ize7HTGzHzK1AwKDMTq7Kzq9JTi7HTW5HzGzMzu9KzS1IzW5Iza5FTK1ESyvLTa3HTK1GzGzGzG1DyqtIzK1AT+/AQGBATCxHRydMTCxAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAZ8QIAQEBAMhkikgFAwHAiC5FCASCQUCwYiKiU0HA9IRAIhSAcTSuXBsFwwk0wyYNBANpyOxPMxIzMgCyEiHSMkGCV+SAQQJicoJCllUgBUECEeKhAIBCuUSxMKIFArBIpJBCxmLQQuL6eUAFCusJSzr7GLArS5Q7O1tmZ+QQAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+viewmag+16:view view16 16:photo:16 16:R0lGODlhEAAQAIUAAPwCBCQmJDw+PAwODAQCBMza3NTm5MTW1HyChOTy9Mzq7Kze5Kzm7OT29Oz6/Nzy9Lzu7JTW3GTCzLza3NTy9Nz29Ize7HTGzHzK1AwKDMTq7Kzq9JTi7HTW5HzGzMzu9KzS1IzW5Iza5FTK1ESyvLTa3HTK1GzGzGzG1DyqtIzK1AT+/AQGBATCxHRydMTCxAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAaBQIAQEBAMhkikgFAwHAiC5FCASCQUCwYiKiU0HA9IRAIhSAcTSuXBsFwwk0wyYNBANpyOxPMxIzMgCyEiHSMkGCV+SAQQJicoJCllUgBUECEeKhAIBCuUSxMKIFArBIpJBCxmLQQuL6cAsLECrqeys7WxpqZdtK9Ct8C0fsHAZn5BACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+viewmulticolumn16:view view16 16:photo:16 16:R0lGODlhEAAQAIIAAPwCBDQyNAQCBPz+/PzerAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAAMwCLrc/ixI0WSgKoyBl+beQFACpo1AqXbKCr1wLAMWS08hGG3dSZqin4sxnBmPD38CACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+viewtext16:view view16 16:photo:16 16:R0lGODlhEAAQAIAAAPwCBAQCBCH5BAEAAAAALAAAAAAQABAAAAIchI+py40BTQSwuovp3DXkv1ia1IHmIXLiyWJ+AQAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+viewtree16:view view16 16:photo:16 16:R0lGODlhEAAQAIIAAAQCBPwCBDQyNPz+/PzerAAAAAAAAAAAACH5BAEAAAEALAAAAAAQABAAAAMuCLHcri4yGISlj4kxcANgNRBQCIbL6U1Su7bB62rXvGydG25kqpwfIGxILBr9CQAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+actattach22:act act22 22:photo:22 22:R0lGODlhFgAWAIMAAPwCBMTCxPz+/DQyNKSipAQCBISChFxaXDw6PAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAWABYAAARrEMgJgqA4zzus/gLhFd5HCcZAXqsphYPUdhcYFNRcZnvdtpnDqPTbUWgAJKBYwzBlw+bRo3xmkNWoBgm0OrVLn3GC9RgCk8DhUw7c0rHPr4CDu5SYQNyEt7uSY3p/UAKFhYKDSQOLiwgFdhEAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+actbookmark22:act act22 22:photo:22 22:R0lGODlhFgAWAIQAAPwCBCQmJCwqLMTGxAQCBBwaHMTCxLSytERGRFRWVLy+vKyqrKSmpHR2dJSSlJyanISGhGxubIyOjKyurGxqbFxeXGRmZHx+fKSipLy6vGRiZLS2tFRSVHRydJSWlHx6fCH5BAEAAAAALAAAAAAWABYAAAWWICCOZGmewamaQrq+wUC8azHINGocOI38iIRAceDNaISFYklkGHOEhoNBfUAOhuOLEJE8HoPiRKFdESiQBqViuTDIUAsEcyAeGJmyiqC5RCwJGg0YcEh9D0V3Dxt6JwQVDRYVHBUdi40mjw0PTgwQHgeYJQQJfxUXFxAOoTkFpQ0fsRSimQkWEQ0VtI62HLt7vjl7JQYhACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+actbookmarknew22:act act22 22:photo:22 22:R0lGODlhFgAWAIUAAPwCBCwqLCQiJCQmJMTGxAQCBLy+vLSytERGRFRWVKyurKyqrLS2tKSmpHR2dJSWlKSipISGhGxubIyOjGxqbIyKjFxaXGRmZHx+fPz+NGRiZPz+ZPz+HMTCBKSiHPz+jFxeXPz+XPz+tPz+zPz+/AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAWABYAAAamQIBwSCwaj4Gj0hgQLJ+AAaEAVQoI06pRYDhkoYgwIhEgKBTfZ2FhaBsYDS8VWnA8Go0FJIKeqyUTDw8EDHBpSwUUFQ4UFhcYDQYFfkoFFxEQDG8KEAUZlEeWGBIakw4FG1STiBoYBRwdBR4fHgUdHKBEBSCnIR8iIyIfIblFu6ceIyQjtcXGCbLKzAUKzrq+wMLEVa+xs7W31kOTk6nkWuOf6Ea5QQAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+actexit22:act act22 22:photo:22 22:R0lGODlhFgAWAIEAAPwCBAQCBHR2dDQyNCH5BAEAAAAALAAAAAAWABYAAAJOhI+py90RnIMyRUOxhDfzJkACdoXBuEDDkQFDi5go0MrKx16kns80b7qdELCgBYaEGWwL5nG1ePFiKp9A6kuYRNuho8vxVrrZivmMRtMLACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+acthelp22:act act22 22:photo:22 22:R0lGODlhFgAWAIUAAPwCBAQCBCQuNBwiJAwiLAwaJAwSHAwSFIy+3ERynCw2PCQuPAwmPCxOZCxWdJzG3FSazBwmNAQKDAQGBDRmhBQyTDxujDR2rIy21AwWJDyGxCxmjAwmNDRihAQOFDxmhCxunBQWFAwaLCRahDR6rESGvDQ2PCRWdDRunDSGvCRSdAwWHCwuLDSOzHSmxDyKxBxCZBwqNHSu1DyOzAQSHAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAWABYAAAahQIBwCAgIBAPCoGAgOoeBAyKhWCwYDUf0CX1AIhLiJEGpBLiAAaRxdgYsl7Ybk8igBZoN5xmAdDxoanp8HyANISF8EBsiXBMjJBolBEQmGHFoRScbKHIKDykqK5lFAZRCnyknTaROLA8tq61OChgtKqyzQgEYEJi6UC4vI3LAASkbMBPARAEBdszR0sACEaPSMTIQM8W6KzNl3bo0NOJDdEEAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+actlock22:act act22 22:photo:22 22:R0lGODlhFgAWAIYAAPwCBHRudFxaXExGTERCRAwGDGxubPz+/Pz2/Ozm7Nza3NTS1KympFRSVHR2dNTO1JSSlKyqrKSipDQyNMTGxDw+PLSutKymrMTCxAQCBHRqLBQODJyanDQuFFxSJFRSJFRGJERCHExCHISChHxyLEQ6HGRaJExKHLSmbLy2fOzitPz23KSiZHxuNHxyNJSOTNTOnMTCjLSudKSaXJSKRJyOTOTetNzWpHxuPOTi5MzKzLS2tFxWXOzq7Ly6vOTe5Ix+RLSqdNzSpLyydKyqbKyiZAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAWABYAAAf/gACCg4IBAgMEBQKEjI0GBwgJCgsMDY2XjwkOAgQBDxCLl4QNCaGCBBGWooINCAqqrBKgqwATFKaDFRYVtBMXsIMNGBm0GRADjQIJxKIaGxwdHh8gISIhGyMZzIwkGholJiYfJiAfJyEZISDbg90oKCkqKwcHKyooLC0f7IIuLzD2YMSQgW8GDRri+AFoUMOGvRsxUhSsQQPHvmQSchyQtEAHhh0WJHDQcJERjwsKDvRI0BGDjwgicXhQyCOjSgUKPO6AObIkIQESfmxk6REDT4s0bfaYpDNkT4VAha5s+TLmzEYtatwIOHAiDZIKNQAJYk9IjCFEisyoocFEB4UACtBpm0t3LiF4gQAAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+actredo22:act act22 22:photo:22 22:R0lGODlhFgAWAIUAAPwCBCReDJzGjMzivOTu3Pz+/JTWbHy+VHTCTMTivPT69BxGDESuJDyiHESiHEymJIzKZAQCBFS2LFzKNGzWPDRqHCxqDFSqLHy2XESCHAwaBAQOBBQqBDyWJHyqZDyKFGSiVESeJBQ6BAwSBGTGPFyWPFSSLEyOLESGJBQiDAwiBBQmDCRGFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAWABYAAAaoQIBwSCwaj8hkMcBkKpcBwYAwEDif0YLhwEUkFItFMkAwMBoOR+PxgHwjRDggamhIJpQ8ZbKGKOQLcgEFdhUWEYgRF3sNfhELBHALAhgZFhobRBwREhQdEAIEHpIKHwsaSJwUDQgQIJINARxKESESDQ0dgCIjSpAkDAwPco+ZSJAlJicnKHIAIrNHidOIQxunT0kpCyrZSCss0d5Fj6jjRonn6uvs2QZBACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+actreload22:act act22 22:photo:22 22:R0lGODlhFgAWAIYAAPwCBCRSFCRSHBw+DBxCFCQ6FBwyDBQWBBxGFCxyLGTChMzqzLzmvHzKjDyOTER+RERyNDSqXNzy3LzivFS+fCyCPBQmBCQiBBxKFBQqDOTy3LTitES2dDR+PCxuJOT25KTarCx+PESSTCxKHDSeVCyKRNT21ESWVDSGPBQyDAQCBBQSFDRuLDSyZDySTGzChCRiJKSmpExKTDS2ZGzGhLy+vGxqbISChDSKRMzKzGxubDQ2NIyOjCQiJCwqLBQWFCwuLKSipERCRERGRHR2dAwKDDw6PFRWVIyKjCQmJFRSVBwaHKyurAQGBExOTBweHFxeXAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAWABYAAAf9gACCg4IBAgMEBQYHhI2ECAkKCwwNDg8QBAOOhAQREhMUFQgWBxcHGBmbggkaGxwPB4yDB6SbBJIKHQaqtY0eHyAhsqrDgx4aCiKpqoQHAyMjJBMKJaSxzAAHIRsmJgonKA0LHSmDKiuOBywRLSQuLyEwwyoxMuiN6iUzNBXy5jU2bsgoJugABBz95uXQsUMGD3vpPPgTpKIGwx4+HMr4kW4YkCA2hAzxAQSIECI+imBTwVIFESNHerRUgc0cEiFHkjiiyYzeDiVLdvLcySSkkKGEWiZVweSGkIHMmvQosoQlkaZOjvhosvKJjIAxoOAsgpRZkQNLnvSoqspAIAAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+actrun22:act act22 22:photo:22 22:R0lGODlhFgAWAIYAAPwCBAwKDAwKBCQiHNze3AQCBBwWFDw6NPTy9PTy/Dw2NKyytOTi3LS2tMTKzMzOxLy+tLy+vBQODNze5NTS1JyalIyCbIx6VIRyVISGfJyelOTq7EQ+NMTGxKyurGxeRLyKPOSmROSuVOy2XOSiTLzCzNTOzDw+NCwqLHxuVOy6bPzGfOSuXNTW1LSyrMSWRNymTOSmTKSCTPTGjPzSnPzWnMyaVBQSDMTCxPz+/KyahNSeRHxeLJRyTPzmtPzarOy6fJyajNza1Ly6vLyulFRCJPzirPTOlMS2pNTSzMTCvJyenBQWFNzKtPz6vPzyvPzqtOzGlOTe1AwGBFxWTLy6tPTm1PzSpPzutPz2xPTSnOTSxOy2dPzapPzerOzm5IR+dPzu5Pzu1PzqxPzy5Pz+9GRiXGxuZKympHR2bOTm5Pz6/MzSzBwaFJSSjCQmHPz2/AwODAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAWABYAAAf/gACCg4SFhoeEAQKIjIIDBAQDjYMFBoMHCAkKgwYFhwULDAUKCg0ODxCkBQgRnoUSExMUDxUWFxgZGpAbFIuGHB0eHyAhIiMkIB8lJieIKCUpJCTGIyorLCktKIUDpC4YLzAxIjIyMzQ1NhgdpJI3ODktJTowOyM8Ejc9Pj9AQUIEclAocCMIBQhDiOwgoaKIoCI+jBxBkkSJkCWemIyq0GSHCBVHihRx8gRKFCmpKhGaQqWKFYZXsGR5kkXLFgRUXBUqkCGCFS5AjnTx0sXKlyA6CRVgAAHMAilhxIwhU6ZFkBY5kgKYUoXBAzMKzixZ4AJNGgVm1KxhM0WpmQpUMtooaOPGxAM3Nw60oYLGjNYCbzYJOgAnRzNBJ95oPYQCgpJtkwzFoULlRuRPiy9fNhAIACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+actstop22:act act22 22:photo:22 22:R0lGODlhFgAWAIUAAASC/CQKDBwKDCwODNyKjPzq7My+vIxiXAQCBOSOjPz6/OSelNySjNyGhMR+fLRaTGQ2LPz+/Nx+dNR2bNRybMxuZMxeXMxiZLQSFJQaHFwqJNyKhOSCfNyCfNR6dMxmXMxWVMRORLQODOR+fOSSjNR2dMQ2LJQWFMRWTLwWDNSCfMxeVLwaFKQODNR+fNx+fMxiXKQSDOSWlMRSTMxaVMQ6NMxORMQyJOTS1MxqXLwWFLRORMxKPMQaHMxKTLQWFCH5BAEAAAAALAAAAAAWABYAAAb2QIBwSCwajwGBcikIHIsDQmFKNRwQT2EgoVgsGOCG4wHBIgmRhWRCqVQsF0xGYyYGNgoGh9PpeCQfICEic3UAAWgLIxwRJBsbHSUREyYYJ3RDAQULexGejhueESgpl3WaCxsqJKKsChEUKywtmFoFDC4vCayikzCyMbWHt38NCTKiHhUfMyzBdQIFKsodob0VNDWzwppuKxMRrx6iNjcitNA4bh+iEzkwojc66JkOOxcf7G35PBE9KS1MEUGgIQOIFfk++KjRw9wJgUUIZvhRoyLDFCliQDQisUWLGCJOeNx4hKCGkyhPGnqCoKVLl1liypyZxUAQACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+actundo22:act act22 22:photo:22 22:R0lGODlhFgAWAIUAAPwCBCReDJzGjMzivOTu3PT69MTivHy+VJTWbIzKZEymJESmFESiHDyiHESqLAQCBFzKNGzWPFS2LNTmzCxqDDRqHPz+/KTGnBQqBAQOBAwaBESCHHy2XBxGDOzy7HTCTEyyJDSqFHzWTAwSBBQ6BIy+dESKJFySPFSSNAwiBCRGFBQmDAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAWABYAAAalQIBwSCwaj8ikMsBkKotMwYAwEDiXgYLhwD0gCFZiQKxNKBYMRqPh+D6G16y5AYnYIxBJAyF4AwITTAUJdBESD4gPFBV6Fn6ABBcJDIYPGEQZGhQbHAIdfx4JHw2VSBodGwWfAR4LDSALfkgYAQurBiAhICKfSSMkvQElGyYnGyi9Rxkdj4nOskUYyU9FpxnURikdGtjRKivdRKfQ2Inh5+jpRwZBACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+actunlock22:act act22 22:photo:22 22:R0lGODlhFgAWAIYAAPwCBGxqbFxaXExOTEQ+RAQCBPz+/PTy9Ozq7Nza3NTS1KSipFRSVOTi5Hx2fJSSlKyqrJyenJyWnDw6PMzKzKyurDQyNFxWXMTCxJyanHRuLHxuLGReJFxSLFROJFxWJExCHERCHBQODISChHxyLHRqNIRyNHRmLLSqbKyiZLy6fOTarPz67Pzy3OzitKymZFxSJJySTNTSnPTy3NzSpMTChLSydKyqbKSaXJySVIyGRGReLPz23NTOnMzCjHxuPLy2vKSmpOTe5LS2tLSutHxuNHRuPMS+xFxWLIR+RDw2HFRKJAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAWABYAAAf/gACCg4SDAQIDBAUChY2EAQYHCAkKCwyOjZANDgIEAQoPjJiDAg2iggQQp5gMBwmrDBESl6MTFKuoFQSjABYRF40CGAW8BRm7hQwNxBobHB0eHx4gISIjBdiEAhYFJBslHOHSHh4hBSHlxIUmJygpKissBiwtLi8pGjDqhBoxMjMuaNSwcSMFjhw6dnjYRyrGCh4ueviw4Q5HDB0/PjAUJCBCAwMIGiiggAEIBFk/FgYLIgRkggQkhxAJkqGExkYMFnxsIGRkSQgLHhRRWUjAggQgG8AsSWRBBiP6VrYMOfKIyaBDNwLo+HHSUplOSyDRqiEHjRkretRQkcLgxayNF0wksQGQxsSKMTIq0QpgCba/gAE7IhMIACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+appbook22:app app22 22:photo:22 22:R0lGODlhFgAWAIUAAPwCBAQCBDyGhCyCfFSWlESOjDyKjDSGhCx+fGSinGSenFyanEySjHSqpHSqrGympEySlBx2dISytHyyrCR6dKTGxHyurHSurHyytGSipCR6fARmZFSalEyWlBRubAxubBRydDyKhDSChLSytPz+/MzKzIyOjAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAWABYAAAbFQIBwSCwaj8ikMhBQIpmCQdM5ZBIKhgNiugwkFAsCI7pNMhuOxkNBgBgEiAi3GkBLJpJHYgEpaClyREwVFhcSEhgOGQoMfgMaERtcARQBFRMYExZ6HB0FUYAekkIBHxqWFmlrC1haESAfG6MBGx+VFRgKYH0hInGRklO0ppYXCwwMWQiQHkwjgrWnFRdYZHIBJCTP0LaWGAcDW9jZ2nMAw9IWTOQkJSZMRsOV49nu8E+19PbmR7TY+1TovONH5V7Ag0QMBAEAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+appbookopen22:app app22 22:photo:22 22:R0lGODlhFgAWAIYAAAQCBAQ2NPwCBHSurIS2tBx2dBweHPz+/Ozm1GxiTGyqpPz6/Pz69GSqpOzaxPzy5HxuVLSmlOTazPz27PT29NzClPTexHxuXLSmjAxqbFSinPTy9KyehNy+lPTy5Pz29HxyXNzWxKSahOzexPzy7IR2ZOTWtESenPTy7KSWfIyCbKyijAQGBDyalPTu3KSSdDSOjJyOdCSGhPzu3OzizJSGdPTq1PTq3JySdMy6lAyKhOzWtOzi1OTOrJyKbMS2nJySfMS+rAwCBNzOrNTCpNzKpJSGZKyafLSifLyylIx+ZHx6ZDSChAQuLAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAIALAAAAAAWABYAAAf/gAABAoSFhoeHAAMAiI2IAAQFjI6EAAaJkQeTjwAICYkKBQcLm5WdBwyfhgChB66bp64HCQC1lQ2irqQCAA4PowsLEBESE4wAuLIHFAAVFr+uDBcYxRm1GrmuGxwdFh4Mrh8gGCET1gDYyhsiFSMkDAsMDCUYJhvnJ9kHKCnODwwfPlBQsULCPRYAWogK9sHFiwoOPEyQh0JFPXO1YBSYwBEFghjdHkwQOYGgwQwIZRR44GHGDBogabhAsYEEihrUMAIoUMCEDRs3HODIYQHFA6MPcJA7KICFjgw7eIzo4cOfiwc/gKwIUm2SkKdDdlDt4AABDaU/iIRwwbTSUyJFOow4S3Hkx9oNDDZgXPU0h1wcSIgEGUw4ibVET5WoWMKksePHpdxmyKADAEIWly9HJtQkQJMmlAgZCAQAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+apppencil22:app app22 22:photo:22 22:R0lGODlhFgAWAIMAAASC/IQCBPwCBPyChMQCBPzCxAQCBPz+/MzKzISChKyqrDQyNEQCBAAAAAAAAAAAACH5BAEAAAAALAAAAAAWABYAAARYEMhJ6wxiEMtpIAWxddwXiqRlikSQeiAbuC+wirNR322gv7zcLobzDU+9XypoBBKTR1lz+RTWDgip8nUwZK1XLyIx5XoVicX2RUAo1DVKi7GOBxjxfNwQAQAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+apptool22:app app22 22:photo:22 22:R0lGODlhFgAWAIQAAPwCBAQCBISChFxaXNze3NTS1Ly6vKSipNTO1Ly2vNza3Pz+/MzOzOTe5DQyNOzu7MTCxGRmZMTGxPTy9Ozm7Hx6fPTu9MzGzGxmbAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAWABYAAAW1ICCOZGmeaEoGbBsI6joMRGEcbQwESDIrtVtAF1gwDLNaAmfKiVgLBJKgwB1KxQZrBHU0FAXmavFoQLYiB6TxFXMj5AZBwnJI2I3wcNWALyYEcgoKXxRhOHs7XxEVCwsWFgoUDRYUFwwQB25ZCxiNjo6GkwUXN2NsCxEYqhUHoQ0MEglYRQQXErcHrI55FycuB2YSmoyOBTEtB2sXuhU6XAENC2a6z9AKCwq+1tAN3E2J3ySkIQAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+connecting22:connect connect22 22:photo:22 22:R0lGODlhFgAWAIMAAPwCBPz+BMTCBISCBAQCBPz+/MTCxOTi5AQGBNze3Ly6vISChNza3FxaXKSipAAAACH5BAEAAAAALAAAAAAWABYAAAR4EMhJqwzY6omD+MNGdR8YilNZnug0qGzrqrL1lnV1fyJBVB6VQEMoGH4ADGwQkxQPBwMiKGA2J8VEAnq0tgiKg5aL/C7C2gTjKCM0zowDQ8tuNQznNL7cKzjOUQsNfER+gguIg19+Pm6ChBZFDmWNi5M5FIyYFHQRACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+connectno22:connect connect22 22:photo:22 22:R0lGODlhFgAWAIMAAPwCBPz+BMTCBERCBAQCBPz+/MTCxOTi5Nze3OTm5Ly6vNza3ISChFxaXKSipAAAACH5BAEAAAAALAAAAAAWABYAAARiEMhJq7046827/+AVCKE0Dh9BAGdaGISAToFGFMcBU+11I4hDYseSZQiKwwKoI/QwBIYiuFDCZseGdIlYEjUNg1SpY6w2N4cUIW6cjwW1lsFwo+MqgtZuw0/ydw5vH34lBhEAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+connectyes22:connect connect22 22:photo:22 22:R0lGODlhFgAWAIQAAPwCBAQCBKyirPz+/KymrOTi5KSipMzCzNza3OTe5Ozi7MzGzPTq9OTm5ISChMS+xFxaXNze3GReZIyCjAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAWABYAAAWLICCOZGmeaBkAQpoGg7C6JizTQT7CxPwOwFWgYPChYIXkIHC4uQKGAiKRKCyNpxxUUVViVYNFLkqtLo+DAkMMLXQPXwAy2WCTF4544FGtKuwPDhB6DnxuUmyCcXIQhV1uYoMuEAcOBxEKCHg6TzGFCJUSizuejROKOAM9OY2SnUU7nD89NCcDsLUnIQAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+devscreen22:dev dev22 22:photo:22 22:R0lGODlhFgAWAIcAAPwCBAQCBPTy9PTu9Ozq7OTi5Nze3OTe5Nza3NzW3NTS1MzOzMzKzMzGzMTCxMTGxOzm7AwGDBQOFBQSFCQeHCwmLCwuLDQyNDw6PERCRFROVEQ+RDQ2NLy+vKSipISChGxqbExKTOzu7OTm5Pz+/GRiZMS+xLy6vBQWFLy2vCwiHFQ+NMSmfNSyhIxmTDwuLJx+bLS2tCwmHMyyhMyqfPTqpPzyvLSWbLSWfPzitIx+ZDw2PAwKDCQiJGxWRPTmrPTerMyuhPzqtPz63PTWnPz6zNy+nIRiVDQuLKyWbOTanPz21NS2jNS6lDQqJHRaTPzmrPTSnPzyxOTClPz2xNSuhPTqxPzuvOzSpAQGDOTKnMy2jOzSrPTu1NzKnOzOnBwWHJRuXLSWdPTatPzqvNzClCwmJOzSnOTOnPTuxOzKlOzerOzarOzitJR6ZNTO1IxmXPTWrNSyjPzOjPTSpLSehHRqZOzirOTCjPS+fPzGhOy6bOzKhGROPMy2lPz+1PzmtKRyRHRiNNTCdPz+zNzCjEQ2NKySdDQmJAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAWABYAAAj/AAEIHEiwoMGBARIqXMhQIUIBAwYQIFCggIEDCBIoULBgAYMGDgIIDEBAwMSKBRBk3NjxAciQIwdACBBBwgQKFSxcwJBBwwYMHBx0EAmA5EwPH0CEsCChoYgOQ0cSGCHhA4kSS5syJGDiBNEAFVGUKKEBAwWFFM6SNJHi64gDFEKE4FBBggoKK1i0cPECxokYXw0gsECYggQZM2jAqGHjBo4cOtqOxLhDAg8ePXz8ABJEyBAWRIoYOfJipEoMCZEkuaFkSAslS5jUGJKkSRAnRREo0JDwCZQoTKQAmUKlihQrVa5gKZ1lI+oAK7QM2cJlSZMuU4Z4+TJEx0iNOwKAggkjZkyOFmS8kClzpcUQLRRGbjRD4MgZNEzSqKG+ZgobI2248dUbDDDwABzcxSEHEFpgEcUcdMRRhx1fFejAAx0cgcYdSxiBRx566LEHH0d8QFRRNC3Uhx985CHEH0MAEkhCBxWkgiCDFEFIEYUYUmONMhyCRxVH/PgjBYioYJAdAQEAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+editcopy22:edit edit22 22:photo:22 22:R0lGODlhFgAWAIUAAPwCBBQSFPz+/DQyNISChDw6PMzKzMTGxERGRIyKjFxaXMTCvKSmpHR2dPz6/Pz29PTq3MS2rPz69MTCxFxWVHx6dJyWjNzSzPz27Pzy7Pzu5PTm3NTKvIR+fJyGfHxuZHxqXNTCtPTq5PTi1PTezNS+rExOTFRORMyylPTaxOzWxOzSvNze3NTOxMy2nMyulMyqjAQCBAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAWABYAAAbYQIBwSCwahYGkUnk0BgTQ6IAQaBKfUWhBYKhaAU+CgXAQIAyChLeJzSIQhcH6GFaM0QtGY5kstqEODw8QEQELAhJTc08KBBMEFBUWDRcBE1pca20SGBkaEBscAY5maFRIAgoLHRQRHh8gIQFlZnByqA8ZGSIQIyQjJQEmYgJ5p2ACrK4gJx4gKIZZAgdeAQ4ZI9kjKSor0AwEjeAs1S0cHAslLi4vMDDRWeRIfEsxMeET4ATyVoYLC5fizXEiAR84BeMG+pEm8EsAFhAjSlR4hR6fLxiF0AkCACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+editcut22:edit edit22 22:photo:22 22:R0lGODlhFgAWAIMAAPwCBAQCBAwCBPz+/OTi5JyanOzq7DQyNGxqbAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAWABYAAARbEMhJq704gxBE0Bf3cZo4kRJqBQNRfBucyudgvJS6VaxLzyMa6/bLiWA9HOg4VIIkL5vzuRkcpkvRIIAorphJLzBW84WEuRZWp6uaT7J2Sh1Hit3OY/ZO7WvsEQAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+editdelete22:edit edit22 22:photo:22 22:R0lGODlhFgAWAIYAAASC/FRSVExKTERCRDw6PDQyNCwuLBweHBwaHAwODAwKDAQCBExOTNze3NTW1MTGxLS2tJyanPz+/Ozu7BQSFCwqLDw+POTi5PTu7MzKxIR+fCQmJPz6/Oze1NTGvPz69Pzy7Pz29LyyrPy+vPyupPTm1BQWFIQCBPwCBMS6rPzSzNTOxPTi1NS+rPTezNzOxPTizOzWxMy2pOzaxMy2nPTaxOzOtMyynOzSvMyqjPx+fOzGpMSihPTq3OzKrOTCpNzKxNTCtAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAWABYAAAf8gACCAQIDBAUGBwgJCgsLgpCRAAwNlZYODxALEY+SkAMNEqKjEw0UD5yegqCjrRMVEqidkgWhraMWF7GptLa3EgEWFRSOnhW+vxgZEBqzkBvItxwdHryRCNGjHyAhHSLOgtgSI60c2yQjJd+eJqEnKK0hJCgnJSngAO0SF+8qEvL0VrBogW+BLX4oVKgIyMIFQU8KfDV4R+8FDBcxZBREthAFiRIsOsygsVEUh4Un3pGoUcPGjZInK65QicPlxg8oX5RwqNJGjo0hdJwQ6EIkjRM6dvDYCKIHSBc1Ztjw4eOH0oIrsgIJEqSFDBo0cuTgsdSTo7No0xYTZCcQACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+edit22:edit edit22 22:photo:22 22:R0lGODlhFgAWAIYAAPwCBISGhISChHx+fHx6fHR2dGxqbGxubGRmZGRiZFxeXFxaXFRSVIxSLPyuXMzKzMzKxMTCtExOTPzqrPz+/NTS1MS+tOSaVPyWNPz6/IxeNPzavPyKBNTW1PyCBPyGBJxmNPzOpLx6PNRqBMSCRNySTPyCDPSGBMxiBKROBHRydPSylOyydMxmBJxKBAwODPS2lPTq3OyabJxGBPTy5PTGrOyOXPR+DPz69PzmzPzevNxuPORqLMReFPzy7MyCXKxiNIRKHBQWFNTOxPzixJRaPFxONHRqVPz27PTy7PzStCwqJDQyLJSGdIx6ZPz29PTu5HRmTLSKbMSGZHROPFxKPJSKfJyShKyehMyuhDQmHEQuJJyOfLSijMSynMS6pLSefDQyNHx2bKSahLyqhLymhOzi1FRGNIR+bNzKtOTOtOTKrOTKpLyedAQCBFRWVPTq5NzOvLyunLSmlNTCrOTOrNzGrLyidMS+rLyynKyijLymjLyqjAAAAAAAAAAAACH5BAEAAAAALAAAAAAWABYAAAf/gAAAAQECAwQFBQYHBggJCgsLDAwADQ6CAQ8QD5ydEJ+gERKWE4ICDxSpqhWqqhYNFxMYphCtqaytGRoXGxgcggSoth25u70eH8APFR0VzMzNziAXIRjIvwAFwq3EqSLUGB/iI4LathS4JCXVJh8nKCmCKrXDFCss1eIfLS4v8ssdmgWsAGNDDBnt3s3wJ+jAtlUhaNSwccNEi4WCBBl4SAHHihw6ZOzg0QNjRgAG6KXK4CNEjBU/gDQI8kLISQAIADobAoMIzCINjLw4YvNkAno4kCRRUuNHESNLmDRxUjSjAlRPfECJImUKlSpMrFzBIqWqoKtJaWSJomULAy5XXrp4+QKGYcYFoCBEWRImi5gmY7CQyVLGriAGD2jEMHMmCxc0Xb6kUbOGTRs3N988gLM4jpw5Y+iwqcOGjZ07mE8yiGABz5c8c/Ts4cOnDJkybS7fdMO7t+/fvDMaCAQAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+editpaste22:edit edit22 22:photo:22 22:R0lGODlhFgAWAIYAAPwCBBQWFDw6FHRuFGRaBFxSBAQCBAQKBCQiBIx6HPz6/NTOfKyiXDQuFOTm5Pz+/Ozu7PTq5Pz63PTyxNTOjKSeRExGLMTGxMzKzNTS1NTW1Dw2NKSmpKyqrKSipJyanNzWlLy6ZLSuVIx6FISChIyKhJSSlCQiJLS2tDw6NDQyNCQiFCQmHBQSDGRiZHRydGxubHx6dGxqbFxeXGRmZFxaXCwuLOzq7KyurHx+fDwmFEQuFCweFCQWDBQODBwaHBweHKSinJSWlOTi5JyepHR2dDw6PBQSFNze3ERGRIyKjIyOjISGhPz29Pzy7MS2rMzOzFRWVHx2dHxybDQiFPz27Pzu5PTq3PTm1NTCtJyGdHxuZHxqXPzq3PTaxNS6pFxWVFRKRNS2nPTi1PTStNSulNzOxNSynMymhAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAWABYAAAf/gACCgwABAgMEBYSLggaOjgcICQoLDA2Pj4MGDg8QEZ4FDxITFBUWFxcYGRobjQ8cHR4fCQ8gCyEiFSMWJCUkJieNEB4dKB4pKissK8wrLS4vMDHBAAYQHx8dFx0fJDIzNDU0M+IyHzaNNyg43Ng5Ojs7Ojw9Pj9AMkCNDiZB/h9CSOx4QLCgihItqBkYgqIDESElitAYWJCgkQcXjjRCgi1Ihw4BB5LAQOLCgyQYHihpUU3DBw5ElpAgAYNixSRJjKjQaECDCRPZPDB5IbIGSQwKLnh4wbInLA4kmJB4oaPiAwVNnER40hRK1BIAaVatUZJEFCkmpmjgCeWDCalFe4q4oFKwSRUrEa5gycLzwq8lUnPQ4PEgSpYcUZ5o2cIlS1O/JHLEDdfjQZMIVrpgweLFy5e+M6WSmBGlxYMYYBRzCaOFi5imHWBIfOEiShLTVjaP6eyFTBmN1TA5OvLDjJksWb58OVMGDRqWjAYdmU79SIvpjqJr104nEAAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+editshred22:edit edit22 22:photo:22 22:R0lGODlhFgAWAIUAAPwCBFRSVExKTERCRDw6PDQyNCwuLBweHBwaHAwODAwKDAQCBExOTNze3NTW1MTGxLS2tJyanOze1Pz+/Ozu7BQSFCwqLDw+POTi5MzKxPTu7LyyrIR+fCQmJPz6/Pz69Pzy7Pz29OzaxPTu5PTq3PTm3My6pPzu5PTq5NS+rPTm1PTi1PTezOzWxPz27MyynOzSvMyulOzOtOzKrMymhOzGpAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAWABYAAAbpQIAwIBgMCAXDAZFQLBbCqJTRqFobjgdkEYFKowPJZEyeUBqVR/crHDTKZYplovZKCW84+YKZZNZSBXl6EwEEBhVPXxZihGMaGRscdkIdg4QeEnVfCH2OHyAhIhuUAAiXZSEhIyQlJqWnjiEnKCWupRWoYyEgJK0SKaUKjam0JCorLMFfC6iqx8giLa/MGAsT1wsuCyULKwssC9RSzdkfCyALKuALLQsvpeXYIQso3gsiCzALMfENC+dGcMNHUAY/f+jq3ctncMYCGggFrsvHcEGNh/EyPFmg8cmrJxAVkVO0EUDJklHoBAEAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+edittrash22:edit edit22 22:photo:22 22:R0lGODlhFgAWAIUAAPwCBAQCBERGRExOTDQyNISChBQSFCQiJCwuLPT29Nze3GxqbDw6PGxubHR2dJyanLSytJSWlJSSlOzq7Pz6/Nza3Ly6vFRWVBQWFIyKjMTCxHx6fIyOjLS2tOTi5PTy9OTm5Hx+fNTW1KyurKSmpJyenExKTMzKzKSipFxeXCwqLMzOzKyqrMTGxLy+vHRydBwaHNTS1DQ2NAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAWABYAAAb8QIBwSCwaj8KAMoA8LgUDQsFwQByay4RiwWg4GA9IRGk0SCYJSsUCsVwwGQ1EsmESD5xOp+L5gDwhBRIZDhcDdkMGDgEiIxAkJQ8Ok5MmAohDAQ1xJxUlKCUlEg0pKpiZJRoLCxmtCw1eURhOcR4rbQ8cGRwLAwgGtBYTDywtGRKjvQTARgEZLhMcKC0OrQMvAirMRc7CHCTU1g2+20TO0NIn1RwDCya/wdHT1Rnt5LToKOq79trx0tR02YPX7Jm8fRxMOIhSLhOJE/LCJSTlr5kFEBQsWDiR4UGGBgsuHDg1BEYAfTE6oEBR4AIBAiS5yWBAAAGBAyaPGAgCACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+fileclose22:file file22 22:photo:22 22:R0lGODlhFgAWAIUAAPwCBERGRERCRDw6PCwqLExOTFRWVHRydGxqbGRiZCQiJISChIyKjHx6fDQyNBwaHJSWlKSipBQWFJyanPz+/JSSlCQmJAwKDCwuLBweHBQSFGxubExKTISGhDQ2NFxeXFRSVDw+PAwODAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAWABYAAAbZQIBwSCwaj8jkMSAYDAgEJbFgOBwQCUOAoJAaFgvGonHIBhyP5BcSgUAYDWxggD4WFmx3e3HQngkSRgYMEBMUFG4MCId0BGlEAQeEhocVDYcUdBYKF0QCB3gRlJgUAQEYBBkaRAMbDZMMpAYcT46rQwMJrgsdC6QcfwoPnUMOBgkIV6SHHg6bw0QEAQYfBpggBZjPGsRD0gEchxwCIR6HChnQRQ8DIU4DTR4Em+ncRw8O+fmoXPXdRg+gQLFgIYM/KRIkoDP4QMKFf0o0aBAh4qGUixgzCrETBAAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+filefind22:file file22 22:photo:22 22:R0lGODlhFgAWAIYAAPwCBBQSFJyanLS6vLzCxISChNTe3OTu9Oz6/Nzy9Nzy/NTy/OT2/Nzi5Mzu9Lzq9KTe7LTq9PT+/Pz+/Nz2/Mzu/Kzm9Jza5HzK1LTi9PTu9IzW5ITO3FxaXNT2/KTi7Iza7GzC1LzW3FRSVMzO1MTq7HTS3Fy6zFS2vKzm7Lze5MTGzHzS5FTG1Ey2xEyyvJze7JzW3ITa5FTK3EymrGS+zFxWXKymrMzi7ESirEyqvLSyrKze7MzOzMTCxKSepAz+/NzW3MzKzBwWHLzS3ERCRAzi3KyurNze3MzGzLy2vLSutCQiJAyytHRydOTe5MTGxLy6tLyqpKyelJSCdOze3NS+tLyupLSmnKSOhCwuLPzy9Pzu7Oze1OzazOTOvMyihOTi5PTm3Pzi1PTazPTWxOzOtNSunDQyNPzy7Pzu5OzKrNzSzNzGvNS6rMyynMymjAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAWABYAAAf/gACCgwGFhYOIiYQBAgMEAwKHiokBBQYHCAkKCwwFAZOEBQ0IDAsODxARCZ6gAAEGEhMSFBUWFxgZCJ+TjBoMEpkRERscGBGRih0BBAgeFBQOER8gISEfIruIIwEkCCUVwhcgJicoKSrZg9srCRkRGdMsLS4vMNiK2wIKMRsbMiwzXtCocSydIBs3AuCIwIFDiBMucugAoWvSiB2VNPDg0ELHwA0MkCXr4aNSggg8NoDIQOFHgBtAkgURMiDAEAFEVBCJFKCIkSMGOyDRkETJEkOFmABoUsRJQkQdnkzQACWKlBtTplBR6qopxkFRJ0ytYuWKFCxZtBBq+hRA2AlbRrh08fLlCxi1a51g+dQhDFwuYsaQKWPmDBpKXgNETaNGjJgyhNfcVdTTiWI2XpK0cePmzRk4YA5T5otGixY0qFOXbgXAQCAAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+filenew22:file file22 22:photo:22 22:R0lGODlhFgAWAIUAAPwCBExOTERCRDw6PCwuLBwaHAwODAQCBOze1NTW1OTi5Nze3MTGxLS2tJyanPz+/Ozu7OTi3BQSFCwqLDw+PDQyNFRSVPTu7MzKxLyyrIR+fCQmJPz6/NTOxPz69Pzy7PTu5Pz29Pzu5PTq5PTm1My6pBQWFPTq3PTm3NS+rAwKDPTi1PTezOzWxMy2pPz27PTazOzSvMyynOzaxOzOtPTaxOzKrMyqjOzGpMymhPTizOTCpNzSzNTGvMymjMSihCH5BAEAAAAALAAAAAAWABYAAAboQIBwSCwaiYGAYEAgFAqGg/Q4DCASCsTiymgcHAcqQLB4mM+QiIQBppLPcMjkwQ4bB2X4maKgt4sVCHpnFhQTElNFE3mDDxcYGRp2RBuMgxwIHX9EBZZwHh8gCBmTQ52NISEiIyQlpUImng8hHyInKAgprwAqgnC0IKwrLLpGB4wctLYkwy0uuwd9Z8AnJywsLcVFx2YcL7UnJCwwLTEy0GXJoSgrCCwzNDTnxgjeH9UrKzXwNDY36LRGhEOwLx4NHDmgJbh3QoeOgv127EhojEeHDj16pEhRQoZHHzl+QJNCsqTJSXaCAAAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+fileopen22:file file22 22:photo:22 22:R0lGODlhFgAWAIYAAPwCBAQCBCQWDCwaDDwmFPSubPzGhPzCfPy2dOSmZPzKlPzSnPzOlPzKjBQODPzChPzWnPy2bPSmXPyuZOyeXIRSLEQuFEwyHEQqFDQiFCweDKRuPFRSTPT29PTy9Ozq7OTi3Nze3NTW1MzOzMTGxMTCxLy6tLSytKyurDQyNMzKxOTm5OTi5Nza1NTS1MTCvLS2tLSyrKSmpJyenJSWlIyKjHx+fFxeXBwaHKxuPMzKzLy6vIyOjHx6fDw6NPy6dGxubLy+vISChCQmJNza3KyqrBQSFLR2RKSinJyanGxqZAwGBJSSlCwqLAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAWABYAAAf/gACCg4SFhoeDAYqKiIeLj4wBjQCMhY+NkoiLk5qbhQIDoJyGBAUGBwgEo4MECQoLDA2pDrS1tKQPEAwHERITE77AvxKqhAQNDA8UFRYXFs8YBAQZGqGPxw0RGxwdHR4eHyAhIiMkJSYnKCgpBAYPEhcqHyssLS4kLzAxMjM0NTY3cBA4UCAHBw8gVnhgEcKFjhc7UPDj0cMHAAI/KFgY4YLFio/jRpTYsW8GDyCSCEQw2DChOHIqgsCQSEPIEEEEJFhAoUNECCJEyOk4d6KIyRtGcB7hIJKjixEjHu4oimSGEIs4d8IIUoKECnNB0ElMwkNJJgBLlJBAcQKGiR07KGAURVGViY0mhIwwSTKjr99+THjUoIg0r48hTRIrRtxkiOMhDgrZCQQAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+fileprint22:file file22 22:photo:22 22:R0lGODlhFgAWAIYAAPwCBFxaXDQyNFxSTPTizOzi1FxORDw2NExKLPTi1Pzy9Pz6/FRWVPz29Pz2/PTy7PTu9OzezPzu5OzavAQCBPzy7PTm3OzazOzKrPTu5FxSRERCRGReXPTq5Pzu7ExGTMS+xKSmpOTKpPTq3JSCDNzSfHRydLyadOzCjOzOtOzSvLyyTMTCxKSipGRiZFROLPz+/KyurJyenJyWnGxmbLSabOzClOzm7LSutJSWlJSSlJyanGxqbNze3OTm5IyGjNTO1Nza3NzW3OTe5IyKjHx6fMzGzMTGxMzOzNTW1IR+hISGhKymrLy6vLSytERGRGxubKyqrLy2vLS2tDQ2NEQ+RASKBAT+BFxeXHRudAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAWABYAAAf/gACCg4QBAgOEiYqEAgQFBgcGi5MICQoLmAQDh5OEDA2YCw4ODxARApKUCaGYEAsSCRMUnQysCwoVEhYXGLOLCBCgDqK5GQUXGooCAhscBB0euBUZEAUJvQgIgx8gIR8iCSPiHuIFEREDJCXaANwhJhsnKCnWERcRKiopFCvsBywhQrRwQWGAPAz5EhpQ9wIABRgKYsiYMTEEDQocatiwkUIEP18fbkCAAcMBjhwzdOyQwYNCgBMfKJSgMItBjxs+btwgCSGGjhw/ZoRgQKGZCRMUPgABEgSIkCE3SZok8qNqkR85NtDUEcPIkaVAkCR5SrJBDCVKlmzQ6pCCiRlMTJo4YUH3K5AeMBYYWctW0BOaUH60cBJFypQmII6wyEpFQBVFMSm4UAI3hJUrOGh8oOJrklYKWIromJGDR99Ogz5j4ZGlM+pEnwmBCwQAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+filesave22:file file22 22:photo:22 22:R0lGODlhFgAWAIUAAPwCBGxqbAQCBLy+vERCRExKTHRydIyKjMTCxFxaXGRiZFRSVFRWVPz6/Nze3Nzm5Pz+/JyanDw+PExOTHR2dMTGxBQWFLSytHx+fISChOzy9Ly6vAQGBJSWlMzKzAwODJSSlHx6fIyOjOTi5DQ2NISGhGxubCwuLOzq7ERGRFxeXNTW1CwqLPT29Dw6PGRmZKSmpAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAWABYAAAb/QIBQGBAMj8ikUDAgFAzKKCBwQCQUCcICKh0SEAhGw5EIZAmBrgCxeDQgcDJWyz0GIggJfL+XGwQJRxNgC3yGDwwUFUZDFhdthnwMGAZNQwEZFwQakXANBBQbHIIdERIBnRAOiR4ERx8gsSEMBBmGCyEGG3YGBwcgIr8UCwQHECOgG4xCtRkEJAvBJRklJgkSFBQeJ68hJiEoESkFKiEZIbkGARsLlwEGExENGhorGSkpFAYm66NDLAECpGiBYsUIFA8wLHBBQMWLVkdUCFCwaYVFBOymkVCgYEMgOykEpICBccMBAhhELFigTEqAAgIIwCiQ4eRKDyS6EAlJIAI0EpaudF4iIKDAAn9CkRT5eMROEAAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+foldernew22:folder folder22 22:photo:22 22:R0lGODlhFgAWAIYAAPwCBNzaTPT2FISCBCQaDPz+BExKBDwmFPSubPzChPzCfPy2dPz6BMzOTAQCBOSmZPzKlPzSnPzOlPzKjBQODPz+rPz+3PzWnPyuZPSmXNyaXPTyhISCLIRSLEQuFEwyHPy2bKRuPFRSTPT29PTy9Ozq7Pz+xJyanDQyNPzGhMzKzOTi3Nza3OTiVBQWFDwqFKxuPOTi5JSSjISChHR2dGRmZFxeXPS2dNTSzNTS1OTm5KSipLS2tLSytKyqpIyKhGRiZNze3NTW1MTGxMTCvLy6tIyKjCQmJMTCxMzOzMzKxJyenHx6fLR2RLy6vJSSlHx+fDw6NLy+vIyOjAwGBGxqZKyurCwuLBQSFJSWlCwqLAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAWABYAAAf/gACCg4SFhoeIiYqLjI2MAY6HAgOHBJYEhJCDBQaDmgcICQoLB4MGDA0OAQUBDg2cAAcPEBESE6QUuQasFRYVq5SxCRcSCggYGRjIGgYbFs8bHIMHExIJGR0eHx7cB83PFhsDDuTUEyAhIiMjJCQluwEmvsAnKAcp1x4qKyUrLLupWrByxcnFiwQIYIggEaNEiRgBZMyYQaNADRs2REA6cCODBxw5+OnQgWMHjx4+BND4MQOIg1gI0gUREkTHiplDhhApEoCGkRlHBL3I8MEHEhz+WAhJogTJySVMfthwIehAExE5jubAkYQpESc8fOx4AiXKNA8+ekhBgqSpzh5hPHcsmVLjpSAqVZBY6VGkiJMiPQKLnTvjCiEsWU4o3nGC8YksMmT8YCmC6iAXKLRc2cz5yGYtR0JjKWQgEAAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+mailforward22:mail mail22 22:photo:22 22:R0lGODlhFgAWAIcAAJR6fIxydIxubIRqbIRmZHxeXHRaXHRWVGxSVGROTFxGRFxCRFQ+PEw6PEw2NEQuLPwCBJR2dLyijPTixPz69Pzq3Pzy3Pzu5PTu7Ozi1LyelOzavPz+/DwqLLyafPTmvPz67Pz29Pzy7LSWlPzmzPz6/LyajPTitOTSzMyurPz25PTatPTi3KyOjPzuxAwqVDQiJHxiZPTetKySlPzqvPz27BQ6bAwmTPTexLyinNzGxDRunPzy5KySjCQ+ZNzq9KTO7JzC3Nzq/Ozu/LzW7FSm1BR6vGSWvFyq1AyGxAxytAx6vBSKxAxSjMyujLSunES+5BSi1ByGvAQCBNzCrOTaxNTOvMS6rKyelCx6rBx6tBQKDOTWvPzu1PTq1OzezAQOHAxGdBROhAQGFPzy1NzOvIRqXLyynOzarPz21Jx2XPTWrLSShAw2XKSCbPzuzAwePAQCDPzyzPzqzPTmxOzWtAwGBKyObOTSrNzGrKyGbOzatEQyNKyCZOzWrOTGpNS2lCweHCQaHCQWFBwSFBQODAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAABAALAAAAAAWABYAAAj/AAEEEDCAQAEDBxAkULCAQQMHDyBInBhBwgQKFSpY0HgBQwYNGzh0mDhRAAUPHziACEGBpYgRJDiUGEkSwoCQJk6opNASRQoOFETQJDkggwoOJlYApcCihQuVL2DUhBDjhIqjJmRwwDCDhswaNm5MjYHjKggOOU7o0CGTA9gdYknG2KCCBw8VJVL0uBgihAUfP+CSNGCjsI/DiBPbAMJBsEQbQYQM+UG5smUiRYw0jlvYxhEkSYyIHm1EyRLTTH40EZvAyZPOR4pAmU07ipIkUKQ0mQIhAZUqVq5gKXzkSBYtyLVEyd1ki8QFXLp4+WJFQowbYLJnD5NbzJiJCjaQnhnvpYwZM0/OPFlvQ/f3iQvQpBlvQc0aCWy4VKnCpY0Y5yQxgEYXZFjghgwZUOHGCW90YQEccUwloBwGyjAHHXUoSAMZb0xhx1QOoMHDHSfIwSEOdTjhAQ1d4MFbTQ6Q4MYacrzxhhx04JCHHhvQsMeLJPHRBxpr+LHCGnusgccfgKixQR1ATtTBlDDAEIggggxCCCGFbLGFHVFKZEdAACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+mailget22:mail mail22 22:photo:22 22:R0lGODlhFgAWAIYAAPwCBBQ6bCQ+ZAwePKTC5Ozu/NTi9GSWvAwSJGSu3JS+5CR+rAQOHPTy/AyKzES23AwOHCw+bOTq/BR6xES+5AwmTBw6ZMTW9Ax6tByi1BRGdAw2XAQCBDQuNDRupKzS9FSm1BR2vBym3EzC7CSGxBROhNTW1Pz+/OTm5NTO1AQGFNzW3Ozq7Ozm7IyKjJyWnMzOzNzq9Nze3OTa5Ly6vCQiJGReZISChKyqrAwqVBRWlOTi5MS6xJSWlNza3OTe5Ly2vGxmbKymrIyGjMzGzISGhKSepCQmJDw6PHR2dJSOlPTy9MTGxLy+vLS2tMzKzLSutMTCxLSytKSipJyenKyurJyanCwqLCwmLCwuLAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAWABYAAAf/gACCg4IBhgIBA4SLjAABBAUGBwiNlY4FCQoLDJaNAQ0ODwsQnYwREhMUE5ylFYYRFhcYGRgaGxsDHJUdFR4SHyAhEyIjJCUcuo0cJr0nExihxgwoyYscKSnMHicOIw4lKissLdWDHC4vMCu9McYqMjMyNOUANTY3OPEoOTolDCszdrSgwaMcBxs9TMxYOCMHBx8zfPj48QNINQ5BbMBIIUShDIUoTAhR94PHPEEHbQwZckOGjBQviMxYUWQIDCMmdXE4gqRnkiFETAxR8iKFjJU2evZEdmLJkgJIbqS4wXJIUapImj5FtuSEVyRVV1IVi4RIChhEkLVAgcJHEqVwVJUmYdKkiRNkALMRecKECRG/ff8CEQJFCA5kMKJEoUHDCQ/HkB9LmWKECpUeyKoIMSLEyosen0OD7iH2xg1dV7BkqXGlBpbWNTq4Zn2khu0aAAwEAgAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+mail22:mail mail22 22:photo:22 22:R0lGODlhFgAWAIYAAPwCBDQyNCwqLCQiJBwaHBQSFAwKDAQCBDw6PPz+/Pz69Pz27PTy7PTy5PTu5PTu3PTu1PTq1PTqzOzmzPzuvOzitPTmvOzivAQGBDw+POzevPz67Pz25Pz23Pzy1PzyzPzqvOTavERCRKSilPz21OTevIR+ZExKTOTi3JyanLS2tPz6/Pz65KyihJSKbMS6lExOTNTW1JSWlJSKZMSylNTOrNTKpFRSVPz29MTCxPTmzKymjIyCdOTWxOzexOTWrBQWFFRWVOzu7MzKxJyalOzatLSulMzKtOzmxOTarFxaXKyqnPTmtIyGdIR+bOzetOzixBweHGRiZOzm3NzWzNzSrOTetGRmZOzizOTexOzm1JSKdGxqbHRydJySdHR2dOzapHx6fKyijOTixCwuLHx+fFxeXERGRDQ2NAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAWABYAAAf/gACCg4SFhoeIiYqLAQECjwORAwSUBZYFBpkHmwgJCgsMDA0OD6UQERITFBMVFhcVGBkangq1ChsLGxwcHQ0dHR4fICEGIiMSCbS3uLq8wCQUJSYGJygpKhQJKyvLLM4Nwi0uLwUwDQsxMtmeuQveHR8UMzQ1NgU3Dgo41jk6ns0cKOzgYaOHjx9AgjTAUUvIECLZNmxoUISHkSM9KiBJQkCJA4kKEoBQoWJJAiYtmjh5AmVCsCJRpHzckKCCySlUUvBYUqUHDysSPnxIEuXKA5pPRiRwxwFLFhRaIEDYUoEChCcDuECoOWKFuwW7nHkg4WELkw8/BHRRwESpt10dU8SSHevlRxIBX6C0WBE27q8GZMkKbTADjIAwYlb4GLMYShYoPTRo6FGiSJEKPyzMIFMmzJcvXbhwkSLFjJkbQW6cOHNGhAgEAdAsmk27tm0ABgIBACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+mailreplyall22:mail mail22 22:photo:22 22:R0lGODlhFgAWAIcAAJR6fIxydIxubIRqbIRmZHxeXHRaXHRWVGxSVGROTFxGRFxCRFQ+PEw6PEw2NEQuLPwCBLyejPTixPz29PTu3Pzu5Pzy7Ozi1LyelPTavPz+/DwqLPz67PTetPz69ERCRLSWlPTmzPz6/OzexLyajPzqvDw+PDQ2NMyurDQiJPz23PTatJyenAQCBPTevPz25LSajOzq7HxiZPTexPz65JyanBQ6bKSmpBwuTOTi5OzaxBRCdHySvGRiZHx6fBQSFERGRNzq9IyOjHx+fGxqbPzu3BwaHFSq3Aw6XAxKfPzy3Gy63ByWzJzO7Mzi9OzavBRytAx6vCSazGRKTPzy1AQKHBRGdBRyrDy63ES+3Cym1CR6rBwWVAQSLAx+xCyCtBRmnPzuzAQWLAwePPzyzKSCbAQOJByGvOTWvPTmxBQODFQ6PPTWrPzqzOzatAwGBKyObLSWfPTivKyCZEQyNKyGZOzWrOzWtOTSrOTGpNS2lJx2XDQmJCweHCQaHCQWFBwSFBQKDAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAABAALAAAAAAWABYAAAj/AAEEEDCAQAEDBxAkULCAQQMHDyBInBgggoQJFCpkzGjhAoYMGjZMpMghQgcNFjh4mODhA4gQGkSIHAmBwAgNJEpo8KDSxAkUGjhMSEGz5gUVIiKs2PmBRQudHiwQpUnAxYsXImB0aBqjBcuoU0fKmPGChgUNH2qIqGHjg9u3bicWIFs2rYgbNnDkyGFhb8cccQ3ouJqWQo0dPFr0WMy4h48LFj4gsKriB5AeNngEaSGks+chPnwQOXFAh4oXRYxk9nAEyY7XO2wksWHDx5ATCDIoUXEBsYclTJo4cWJhuIjhSXacSPBEiZLMQY4wgRKluvXqUpyIsDElAxUqVaxcwcGCPQuWLOixaNHCZAsXBU+oqKDSxQqULF6ifNmyn/8VMOtxwcAK36kQRhdJQIFFEmKM4eCDYGyhhYAEkqFEGSuYYcUZLaDxXRpqSNRCEu6twYaFZXTQhgRd2NCCG9918AYELTjoXgNuKAFHB2RQEUYHVbQQRwlUpPHGGFwkyQUEDsgxx4lh9BhCBy2U8UQJcrSg5JIQ0FEHG3bc0QGYK+CRhx57PEGlkhM9sAEffKTQhx9+/AEIIIGoEUgLLRRFR0AAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+mailreply22:mail mail22 22:photo:22 22:R0lGODlhFgAWAIcAAJR6fIxydIxubIRqbIRmZHxeXHRaXHRWVGxSVGROTFxGRFxCRFQ+PEw6PEw2NEQuLPwCBMSihPTixPz69PTq5Pzy1Pzu5PTq1Pzy7Pzu7Ozi1LyelPTavPz+/DwqLLSajPTetPz27LSWlPzmzPz6/PTexPz67Pz29OTSzMyurPz25LyajBRCdPzuvDQmJOzexPTevOzq5BQ6bBwuTDQiJHxiZPz23Pz65LyinPzmvBxCbHySvAQCBOTi3OTq9CweHOzaxFSq3Aw6XGy63ByWzJzO7Mzi9OzavNzq9BRytAx6vBR6tPzy3AwOHDy63Ax+xCSazCym1CR6rBwWVOzizAQSLES+3CyCtBRyrBRmnGRKTPzu1MzGtAxKfAQWLAwePPTizMy6nByGvNzWxOzWrNzOtBQKDJR2ZNS2lPTmvBQODPTatKSCbOTaxLyqlAQKHFQ6PPzyzPzqzPTu1PTivOzWtKyObPzuzOTOtLSWfPzqvAwGBKyCZPTWrPTmxNzKrEQyNOzatOTGpJx2XCQaHCQWFBwSFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAABAALAAAAAAWABYAAAj/AAEEEDCAQAEDBxAkULCAQQMHDyBInBgggoQJFCpYuIDBQgYNGzh08DCR4oQPIDqEmDBhJQYRIzqQIFkSAoESJCKkDGFiwgkUKTpMwECz5IASKjqsSMlSA4sWQjG4qGnzhYoQSmF0iCFjBgmWGWhQrVHCxg2sOHLo2MGjB0sLYmsWQHq1p4wdPtqemGDhB1UDQFSouKHi7oQgQmSwUMyYxcQDZQWz2EFiCJEiRoyQyLzZyGIIB47YKLwDSRAiSZSoXq1kCRHNLBK8YGKjCYskTp4ogeKkt+8oUaBImZKAAxMmVKrctqL7ihTnz7FkAT5FC4cKFbZwadIFdxcvX8KLss8iJcoUBUcq2KgAJoxyMTy4jCFTxoxEHl2GLyCDncmWM2hUIQMPY2CXhhoTfTEcA2tgVwEba7Thxhs88FdBD/ZB8MUUHMJBRhw2sAGCHBKU4UaFc1RAhxnhcdhhHUzYAUIcFdxRAh4R5KGHinu4OIVEDqTBRx81xhGHHzD8wQYQetDRI4cTAcIHGWT0EQgZa1ApCBqDcBAID1Q94IEHLtBAAyGEFGKIIWqYYQYPYNZkQEAAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+mailsend22:mail mail22 22:photo:22 22:R0lGODlhFgAWAIcAAIR6fIRydHxubHRqbHRmZGxeXGxaXGRWVFxSVFxOTFRGRExCREw+PEQ6PDw2NDwuLPwCBLSijOzixPz69PTq3PTu5PTu3PTu7OTi1KyelOzavPz+/DQqLPz67LSafOzetPz27Pz29KyajPTmzPz6/NzSzLyurCwiJPz25Ozi3JyOjPzuxBRGbAwSHOzexPz23KSSlPzqvBROdISavBxSdAwaLHRiZLSinNTGxMy+vBxGZNzu9BSGrAwWJMSyrKSSjFy61ETO3BRWfPz65PTqzHTK3ByqzBSWxEzW5AQWJOTWxBRCXOTu9BSOvDzO3ByavBRKbOzaxOzizKSWlCQ2TAQCBJza7BRWdNzSxJSCbMzq9BSOtCSKrAwiPOTavPzy3LymlCySrAwmPFRKTPzy1NTGrPzu1JR+bOzatPzyzCy61ByGpOzWtJyCbPTmvPzuzIS+3FymxCSuzBR6nJyCZOTWvKSObMSujOzivAwKDOTSrNzKrJyGbDwyNOzWrMy2lIx2XBwWFBQSFBQODAwGBAQGBAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAABAALAAAAAAWABYAAAj/AAEEEDCAQAEDBxAkULCAQQMHDyBInBgggoQJFCpYqMDxAoYMGjZwmEixg4cPGzqA6BBiAggRIzaQGEkSwgAMJCKgnNBhQogSJlKGOFHTpgYUG0TsnJBCxQoSE1i0KErAxYsOJJRuuAAjhkwZM2jUqGnDBQoUHTbciIEjx4YNOmbs4CGjB8kCZlGAALHBx4+YcTcACcJDyFSJBo6iGNIhhQkiG8BOKGLkCBK6SSQisHoWhZIbG5bMYALECI8mTZw8gTL1QJQXZ6VMiUylSpUlVpoYaXLFtm0EGmCjwJLlA2O9MrRsccKlC8kEXr7AdgEmwtkhX2SQ2BIkjBiSYzSQr/nyhUKZLIrJJOcexvlEBV7IvCBjRkmAMzHOaufhxDvJBWiQISAFxUUQQRovJNeEGmu4JxEDbKQhXxsfuFDGGW68IQMcccgxRxUkNRDhC3R8QMQIdZwXQ11JJGFbiB+QYccHaaTxhgt13OFBDGTgkUdRDrhAhx5k2JjGCB/swYcXMXwAYk190OGHHx/4wUaVepTxByAaoPEkSQ5wwMEJZAZipiCDDJIHIYV8OZEdAQEAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+nav1downarrow22:nav nav22 22:photo:22 22:R0lGODlhFgAWAIUAAPwCBAQCBBQSFAQGBDQyNExKTHx6fGxqbFxeXGRiZFRWVDw+PAwKDJSWlOzu7LSytJyenJSSlISGhISChIyOjFxaXDw6PPz+/MTCxLS2tIyKjKSmpKSipJyanAwODDQ2NHRydERCRFRSVAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAWABYAAAZzQIBwSCwaj8ikcslsOp/OgHRKlQoCgymRUDAcEIkwYgxWFBYERpHQcDwgEclEQmk8DhWL2kiIXDBwExMNGRoJaUkEEH8bEQ0cGgcWAksEHX8QHBKSHk1sfxMHH5ROBBsOICGkT2wiq1CIULKztLW2t0h2QQAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+nav1leftarrow22:nav nav22 22:photo:22 22:R0lGODlhFgAWAIUAAPwCBDQyNAQCBExKTJSSlHx6fAQGBOzu7GxqbJyenPz+/LSytFxaXMTCxGRiZKSmpISGhFxeXISChAwKDFRWVHRydJSWlBQSFERCRIyKjDQ2NIyOjLS2tDw6PBwaHFRSVDw+PAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAWABYAAAZ5QIBwSCwaj8ikchgQLJGBgfNZDBAKBirRekBMtYGEYsHIgsWNhOO7tCrShDU18Hg/CJAIG0o4wCUQcksTFBUSCRYSEnpUFxgIGQkJGYyNGggbHBaVjR2QCxEeWkITHQ4IH3tPFwEMA2ajAKUgqlQTTbFEE7W5vUgGQQAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+nav1rightarrow22:nav nav22 22:photo:22 22:R0lGODlhFgAWAIUAAPwCBDQyNGReZAQCBMTCxGRiZMzGzOTm5LSytPTy9Pz+/CwqLOTi5Ly6vCwmLMzKzJyanJSSlBQWFKymrIyGjCQeJJyWnISChISGhHx2fKyurDw6PAwODHx6fHRydDw2PERCRAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAWABYAAAZ2QIBwSCwaj8hkMRBQKgOCgRMZIBSk06XhEM0SA4iE4uoVLhCMhqLrdSAekMgYO5VM4BQ521mxIC4UFxBWdEkSERYYFxETGQGFSBKCGBEaGRuQSBwdeZaPXpsQCB6YZQMdEI6ZSgMepKusHh+wrCC0rLdlursGQQAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+nav1uparrow22:nav nav22 22:photo:22 22:R0lGODlhFgAWAIUAAPwCBAQCBFxeXDw+PMTGxHRudPz+/JSSlLSytIyKjHR2dISChIyGjIyOjLSutLy6vKSepJyanISGhJSOlOzm7Ozu7MzGzKyurJyenDQyNGReZKSmpIR+hCwuLCQiJBwaHBQSFAwKDAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAWABYAAAZtQIBwSCwaj8ikcslsOp9QYyAQFQYEAyr0Sihkn1fDAeHVLsOJNELxVaITC0bDUU6GH5AIQ8KYrNtFVxQVFBYWFxgRCREYdUQZGhYEDwgIGxAHCQocCgWOQhmhGR0epR8gqCFTq1Wtrq+wsUt0QQAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+nav2downarrow22:nav nav22 22:photo:22 22:R0lGODlhFgAWAIUAAPwCBAQCBAQGBBwaHDQyNExKTHx6fGxqbFxeXGRiZFRSVDw+PAwKDJSWlOzu7LSytJyenJSSlISGhISChIyOjFRWVDw6PPz+/MTCxLS2tGRmZDQ2NAwODJyanKSmpKSipIyKjHRydBQSFERCRExOTFxaXAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAWABYAAAasQIBwSCwah4FkQKBsDpoBIqFgOCASCYRWm1AUFgRGkdBwPCARiWRCaTwOFYvYSIhcMOiJpJGZaDYcR0IEHXceEQ0fICEWIoJDhHcQHxIHgI9SEHeVG46YUh8OISOen1INCqWmUnOYTUxQAU9NUlRWWFtbCiRgrYNlZ2lriG8lYUd1khETE24gCZeCkRgeFBAQIAeNn9OTlXKrBJoYnKrcoaPmpmSpq3S+7u50QQAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+nav2leftarrow22:nav nav22 22:photo:22 22:R0lGODlhFgAWAIUAAPwCBDQyNAQCBExKTJSSlHx6fAQGBOzu7GxqbJyenPz+/LSytFxaXMTCxGRiZKSmpISGhFxeXISChAwKDFRWVHRydJSWlBQSFERCRIyKjDQ2NIyOjLS2tDw6PBwaHFRSVDw+PAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAWABYAAAavQIBwSCwaj8gkMiBYNpeDZzEQXRIKBmPgmtUSDgipcAsWjxOKBaN7Tq+n6EbCIQ3E5+KtQk6gjwl7CX11D3sPBBARTQGFDYeJT2R8EhB0koKUfgATFBUSCRYSEoqcnqCiikMXGAgZCQkZqautr7FiFxoIGxwWqQC4ury+qh2tCxEexMbIRhMdDggfYs7Q0kcXAQwDbELY2txEziBmmx3jSRNMR+nk4e2b70ry80QGQQAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+nav2rightarrow22:nav nav22 22:photo:22 22:R0lGODlhFgAWAIUAAPwCBDQyNFxeXAQCBMTGxOzm7CwqLLy2vPTy9Pz+/Ly6vCQiJLSytLS2tLSutOTi5MzGzKSepIyKjJSOlKSmpMzKzJyanIyOjBwaHIyGjISGhJSSlISChBQSFJyenIR+hGxubDw+PHRydHR2dEQ+RHx6fERCRAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAWABYAAAa6QIBwSCwaj8hkIIBcJgEBweAYnTYJUmMAa9USClniFtwlGg6IRFhoUKTXwwWj0FB3F46Hwl6UQyISfAB+EROCQgsUFRYSF3yJEIyBaxgWDBkaGRtclQwSHBIbEGEdGx4fGhcOICEDGBsWHBmqIq1CHRIWGRMMIyRTHRy6Er22tyONq8YdJRe0xkIDwr2/QwMfliMmZQADIxasZd4e4UYDIr7c59rc0eVFA+/m0EQD9PDt0flP/P3+BkEAACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+nav2uparrow22:nav nav22 22:photo:22 22:R0lGODlhFgAWAIUAAPwCBAQCBGReZDQyNMTCxHx6fPz+/JyWnKyurHx2fDw6PJSSlISGhIyKjIyGjISChLy6vJyanOTm5PTy9OTi5MzKzLSytKSepMTGxMzGzLS2tLSutKymrHRydCQiJCwmLBwWHAwODLy2vHx+fAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAWABYAAAajQIBwSCwaj8RAAMkUBgSDZdP4JBSi06TAcEAkFNLp07BgLLzY5njRcDzO3zB1C4lEGI83Wj58SiYUFRUWdg0XEXFFAwIYGRoWGxwRZQUFHZdgRAObmx4fHiChISFKpVlKWUdPaalOAlasp1sHG4myZGZ7Yltsbgu1mUhjdRF5egmxfQJ/gYOFdrZDi40iFgiSCw8jBQmYcpydn6Ego6WorUwGQQAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+navback22:nav nav22 22:photo:22 22:R0lGODlhFgAWAIUAAPwCBAw2VCRGZAxCZGyavExmjHyatOTy9CxihISevPz+/KzO3BRylAw+XAQCBDRWbPz6/FzC3CSuzDyexJzO5Mzq9CxSdAQOFISmxNzu9HTS5BSmxAyexDSuzJTa7Mzu9Kzi7GS21CRmjAQOHHSWtLze7AyWvHzG3BRihAQKFCTO3BS+1AyixBSWvBSOtBSStAQWJBSixDzW5BTC3BSqzBS21CTC1ETW3AQSHEze7BRqlBRmjAQCDBR+pBRefBRSdCH5BAEAAAAALAAAAAAWABYAAAalQIBwSCwaj8ikMqBcMpvHgGAANQYIhWdVGDAcENQtIJBQLBgNx0MQaDuQXcghIplQDhBIxXKJYiAZGhscHR4VHyAhIiNWJBklGhIbJoQnFCcTKIxFKSgbKissJi0mJi4vLiYoMEcXKDEyMzQ1Nje2NisoOEg4KDU5K6g6OwwoKAN9SCOeMmgwz884PEq9PT4NYkPLP9jZQikN3d4AKVrjKePp3gZBACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+navdown22:nav nav22 22:photo:22 22:R0lGODlhFgAWAIUAAPwCBAw2VCRKZDRSbBxCXJTC1Mzi7Nzq9NTm9Bx2nAQCBNzu9JzG3Hy+1HzG3IzO5BRmjPz6/LTe7Dy61AyStCTC1FzC1AyGrETS3ETC1ETa5BRulAyuzBRylAw+XMTe7Gy+3CSqzAyexBTC3DR+nIS21KTW5Nzu/KzO3FzC3Pz+/ByixEze7AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAWABYAAAaRQIBwSCwaj8ikcnkMBAQDgjPAFAYKhsMBkVBUAYEFo+F4QLzVQEQyoVTOX/XBcsHA0+vMRbNBMwkRDhxuHX5GTlIeHh8gISIjFAEeiVRECiQlDAUmgxQjIhwiJHdFlycoKSIUFCEjGiGkRpcqCxYijxorsUezcxYsuoZJsxLAu0qXB7DCTJfHVQrMX9PU1Uh0QQAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+navforward22:nav nav22 22:photo:22 22:R0lGODlhFgAWAIUAAPwCBAw2VAQCBBxCXDR+nIS21Aw+XJTC1Nzu/KzO3Pz+/Nzq9Pz6/MTe7KTW5FzC1Nzu9CRKZMzi7IzK3Lzi7LTe7HzG3Gy+3AyuzAyexFzC3DRSbHy+1Dy61CSqzAySvAyStLze7IzO5AyGrETa5ByixBRmjCTC1ETS3BTC3Bx2nAyWvEze7AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAWABYAAAaYQIBwSCwaj8hkMqBsBgTN5IAAjRoDBaq1aDggtMuAWDzoJhTgY+CwYLgZDccDwkgXI5IJZVGxXDAZGnR2QxsLHB0PHRgeHyAZDyFfVUQDCyIgIyCPIB+QJCUmlEMBEiInKCQnKSkeKSQeomoqJrUmKiArKSwZsmoCwMEBGCyxo1EGHr3HUQEEvltCBtDRAAbMW0zV29xDBkEAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+navhome22:nav nav22 22:photo:22 22:R0lGODlhFgAWAIYAAPwCBAQCBCQiJNze3ERCROTi5MzGzLy6vDw6PKyqrKyurBQSFGRiZGxqbGRmZISChEQ+RExKTExOTHRydDQyNOTe5FROVLSurCwqLMTCxPT29Pz6/LSutFxeXLyytLSytPz+/JSWlKympPTq7KSipNzW3BwaHHx6fKx2VJRWNHQmBFweDOzq7Ly+vNTW1JxWNLSajPTe1Ny6pKxWJNTS1IyOjJRmbPTi3OzKrNSSXMSGVHQiBHx+fJSSlPzy9IxOVOzWxOSyjNSCPLxeDJyWnIRGTOTGtMxmDLRWBHwqBIxGTLRSDDQuNNSunKxKBGwyNMSafMxqHMReDKRGDPTu9LxuPLxaDJQ+DIR+hGQqNIQyBGQiBNTO1EQKBAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAWABYAAAf/gACCg4QBAYSIiYQCAwQCiokEhwACBQYHBAiQhAiHlQYJCgkEC5uCkp8MDQ4NDwylmwgQlgQRERIEBBOkmxQVBgQWFwUFFxEEDLyJGAUZtQoFGhsFHLYdyoOVHsEf0SAbIAUex8mwlAUhtSIFG+3uIyTWvAIGJMEkJe76GyXbEeWUBJg4USKaBhQpVKzYoIFFiwYUBBJa8MAFCw0vYMSQMWOhBhoTKCQSUKMEiw02buDIoWOHBg0GeIhEFKAHDR8afgAJImSIioYliMws1MPkhiJGchxBkmTDCBo1hg4KQMTiBiUyhBxZ8pNFiR5MEtU0WqSJVidJNDyNKraHC5xPNKBEkTLlJ5WvUgWNvfikyhArV34+7ZEXQAAsB2iUyHLlihYtW0pwOYAFgyJDmDNr7jIIWiAAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+navup22:nav nav22 22:photo:22 22:R0lGODlhFgAWAIUAAPwCBAw2VAQCBHSWtBRmjAQOHISmxNzu9BSmxBRihHyatPz6/Lze7CTO3BSixHTS5BTC3DzW5ByyzPz+/OTy9AyexEze7ByixGyavKzO3FzC3AyWvBS+1BR+pAQKFCRGZExmjCxihBRylCSuzBSWvBS21BSOtBRSdAw+XAxCZDyexDSyzCTC1JzO5JTa7DSuzETW3BRqlAQWJDRWbOT2/Mzq9HzG3JzS5Kzi7BSStGS21CxSdCRmjAQOFAQSHAAAACH5BAEAAAAALAAAAAAWABYAAAaeQIBwSCwaj8ikcqkMCJjHwIBQgBIDhgMiUbUGFAtGw0GFfheHByQi4S6/E8pDUoFYLm5kAEPJaBAVGxIcER0JHlEfICEiIxUkGyUmIgknKIhXASkonCorgSwmKQGcKE9IAi0uLxUwMTJWMzQ1NiYwBLBQHws1N7avXgs4NjkcCblMATU6KhvGyG87PAnUKV1MAj0+2zIFp1bg4eJJdkEAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+playeject22:play play22 22:photo:22 22:R0lGODlhFgAWAIUAAPwCBDQyNAwKDJSWlFRSVBQSFKymrOzq7HRydERCRPz+/MzGzISGhJyenKSmpGxqbJyWnJSOlKSepLy2vIyOjGRiZPTu9IyGjLSutFxaXExOTHx2fGReZAQCBAQGBBwaHCQiJLSytKyurJSSlFxeXNze3LS2tIyKjFxWXHRudAwGDBQOFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAWABYAAAa1QIBwSCwaj8ikcqkMCJjHwIBQgBIDhgMiUbVKFQsGItBdBhpgh4PxIJvRC8cA4oiMy8bvQhJhMAYTFBVOURAWEw0QFxcMERAYCBluVxobDxkVHJocmBwEGgmEQx0dHh0CpKmkH6odVlanBR8FtAIFtiCkSB0LISEiGCIGIxAPDySuRwIOBwrOzwoHJRHJRh0jJgMj2gMnERQUCNVFHQQoCBvo6CkICATjRB0qp7b1K6qv+foyQQAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+playend22:play play22 22:photo:22 22:R0lGODlhFgAWAIUAAPwCBDQyNFxeXAQCBMTCxGReZBQSFOzm7AwKDKymrJSSlFRSVCwqLLy6vPTy9OTe5Ozq7CQiJLSytOTi5BwaHPz+/HRydMzKzKSepJSOlKSipJyanIyGjIyKjKyurISGhMzGzJyWnHR2dISChIyOjLSutDw+PERCRHx6fJSWlIR+hJyenGRmZHx2fAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAWABYAAAa6QIBwSCwaj8ikMBBQKgOCgRMZIBSkxYHWoDVWD9EigpBQLLBERsPxCA8NDUhjgTBGJJNGG02RVBQWdUV3FxgZe0IGfoAGdhoXGxwdiAYef4FGFBoeHB8dGSBRihUhIo1FBhkbIyMkJRYmAwYal4JEBh2RChIWJ1IIGxUZFqdECCgkHR6wWAYpFR2YWSobvL5vFgfDaEMDIivMRBEsD9HcQgMWvecDLB0tZ0btsfJa9vLXU/X6/P3+b0EAACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+playpause22:play play22 22:photo:22 22:R0lGODlhFgAWAIQAAPwCBAQCBAwODMTCxKSmpJSWlFRSVAQGBBwaHLSutOzq7Ly6vCQeJPz+/Hx2fBQWFGxubLSytJSOlBQOFAwKDJSSlJyWnIyOjHRydNze3GRiZAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAWABYAAAWBICCOZGmeaKqubOumQSDEgRjPMSoMRGEcol3vh0IkFAtDDWBEKlGMRKPgEIii0yrqIS1ArADu9KuLNCSOSdCMVp8ohEZFC4DL6SaBpXGh6/l4JX8XZACDhXkYCn1LAoqMUBAZEhBLDJKUSyYBGmhPAJyemiU0NDaloy+qq6ytI8whACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+playstart22:play play22 22:photo:22 22:R0lGODlhFgAWAIUAAPwCBDQyNAQCBExOTAwKDAQGBJSSlHx+fBQSFMTCxKymrFRSVOzu7GxqbLSytLy6vJyanPz+/GReZBwaHHRydKSepKSipGRiZJyWnAwODLSutKSmpISChPTu9ISGhFxaXJSWlIyGjJSOlERCRIyKjDw2PIyOjLy2vOzm7Dw6PLS2tCQmJOTe5GxmbDQ2NAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAWABYAAAa7QIBwSCwaj8ik0hgQLJGBgbMoqBIKU2LAcMgOEQmFYeEFbBmNMgDhYDwWBC0k4pCoJ46IgRIXBioRCRYXamwRGBQIfgaBFhiERhkaenxmCoEbBhyQRYaIGVsdghgem4UWegcEBB8UHhsgIaZGBBgRIpUIIxQhChginEQIIBEklWslFyYnBsFfFCi4WQgpFBwqFxNGKxcsxl4IAS0NZEYCF3vlwgEfUuZV8JEuI2pPAARN9kcE9fr+SwaCAAAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+playstop22:play play22 22:photo:22 22:R0lGODlhFgAWAIUAAPwCBAQCBAwKDBQSFBwaHCQmJJSSlISChJSOlJSWlGxqbGRiZNTS1PTy9Pz+/Ozm7OTi5FRSVIyKjOTe5MTCxIR+hExOTHR2dLy6vLSytLy2vHRydFxWXIyGjIyOjPz2/FRWVHx6fExKTMzOzJyanKSmpKyqrKSipAQGBLSutHx2fDw6PAwODAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAWABYAAAa1QIBwSCwaj8ikcslsAgKCAWEQjQ4KgSwyYDAcugZEQqFYYJECA6PhaLcfEEUkgJZAGJB8fkKpWOhHAxcOGBQZGBoaGQgbHIBGAhUOGR0SBxISBh4Xf0iCHxQSlRIIXhsgj0UCIaCXmJgHGyKpRJ+hmB5dHQqOaCENIx0epBIkBhdzngoPGCQlJifQJBvJRygRKRcKGxcXGypys1srEREc5SLnICLiR1koLFVUWfRO9vf4+UwyQQAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+textblock22:text text22 22:photo:22 22:R0lGODlhFgAWAIAAAPwCBAQCBCH5BAEAAAAALAAAAAAWABYAAAImhI+py30Bo5zBWUWzvNzo33GfFl5jVlonlTrr1DbvFi9vjeeNUQAAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+textbold22:text text22 22:photo:22 22:R0lGODlhFgAWAIAAAPwCBAQCBCH5BAEAAAAALAAAAAAWABYAAAIxhI+py+0Powm0VnknjVkH2AEhE45LZ55Wqn6e65TsMc5eYosbksswubJIhsSiccgvAAAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+textcenter22:text text22 22:photo:22 22:R0lGODlhFgAWAIAAAPwCBAQCBCH5BAEAAAAALAAAAAAWABYAAAImhI+py30Bo5zBWUbz3Sh7yIWfFHKjVl4nmFrr1Lpr7LwkjeeIUQAAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+textitalic22:text text22 22:photo:22 22:R0lGODlhFgAWAIAAAPwCBAQCBCH5BAEAAAAALAAAAAAWABYAAAImhI+py+0P4wqUSlQvttrkDnyaOHIdeaGRupplAIauVM3xjeeOUQAAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+textleft22:text text22 22:photo:22 22:R0lGODlhFgAWAIAAAPwCBAQCBCH5BAEAAAAALAAAAAAWABYAAAImhI+pyw0Bo5zB2UXz3Sp7yG2fFJajVjonmIor2TJvfL0wjecIXQAAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+textright22:text text22 22:photo:22 22:R0lGODlhFgAWAIAAAPwCBAQCBCH5BAEAAAAALAAAAAAWABYAAAImhI+py30Bo5zBWUfz3SZ7yIXdF4kWqZkbCqoMO7kXLC+wVOe6YRQAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+text22:text text22 22:photo:22 22:R0lGODlhFgAWAIQAAPwCBAQCBBwaHAwKDBQSFLy+vLS2tJSWlBQWFKyqrFRSVCwqLDQyNNTS1GxqbFxaXJyanIyOjAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAWABYAAAVcICCOZGmKQSoMaZsShBsQBdAapHvgaIDUqUPJlRjSbAoT0fRDKgODRbF0PLUYjZO2F2Bst9evNix+dsvDlGKK5jraudQb7qbX6a2HEJ+ycyF+LRE8ZTI+fX5oGCEAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+textunder22:text text22 22:photo:22 22:R0lGODlhFgAWAIAAAPwCBAQCBCH5BAEAAAAALAAAAAAWABYAAAIvhI+py+0PowmUnhpeVVnb1DkbCI1I2JhX+Z0sOr2cTHpwK7a4rUr+hAnufsTirwAAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+viewchoose22:view view22 22:photo:22 22:R0lGODlhFgAWAIMAAPwCBAQCBFRSVExKTDQyNPz69PTq5Pz+/OzaxOTKpAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAWABYAAARTEMhJq70466Cl+AMxBVwnFIVRAmQHCIeBrC1L3tQgJ/SaEbeeC1PLBHE2ybFI9A1HzstHEIK6YCmhDTmBybQaHYJn7QC5zKeytIQe1+pKNE6P2yMAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+viewdetailed22:view view22 22:photo:22 22:R0lGODlhFgAWAIMAAPwCBFRSVExKTDQyNPz+/Pz69PTq5AQCBOzaxOTKpAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAWABYAAAQ+EMhJq7046817+MLQUQFRGMc4lQaSAkcMx3QltMmrDrSu/sCgEPgJhIiFk89DaL1qPRnlhsgBebWhdstVESIAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+viewicon22:view view22 22:photo:22 22:R0lGODlhFgAWAIMAAPwCBFRSVExKTDQyNPz69PTq5AQCBPz+/OzaxOTKpAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAWABYAAARWEMhJq7046z2DF0PlBeAVEERhiKhqHgWyUgEsX0KczFOO7JeBYciTCImc5ITIXDKHyqhU9AnRqq9UEVDTvmLbGhin2/qAliOUot5OLc81IO5+2+8WewQAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+viewmag-22:view view22 22:photo:22 22:R0lGODlhFgAWAIUAAPwCBBQSFJyanKy2tLzCxHyChNTa3Nzq7Nz29Nzy9Mzy9MTu9OTy9Nzi5Oz6/OT29MTi5Kzi7NTy9KTm7JzW3ITO1Lzq7IzW5HzK1LS+vMTq7Jze7ITW3GTCzGS+zLTS1MzOzLzq9Kzm7Jze5ITW5HTS3FS2vLze5EzCzEyyvEyutJTa5NTu9ITa5FTK1ESirLTm7Mzi5FS6xEy2vESerESmtFSutESmrKyqrAz+/Dw+RAzi3ASutHRydAQCBAAAACH5BAEAAAAALAAAAAAWABYAAAbKQIBQGCgWh8jksCgYEAaCozIZKBgOiIRiwSgEpstCw/HYQiKRhBcMCBgQDodkMaFU0t9pQHCIyy0TFxgYEVF6GQ4LCQkaERscHR4RH3lUIAkWCyEiIyQlHiYjEJVIAQQJJ2gjJSUoKSorlHoCLBQcHC0lLikvHjCGejEiHBgeMjM0NRwPpFQFDBHFNjceHAjAYFWoI7cnCVE4OWxtex8QH1EBOjs4zUpGUjw6Pe3j2fP19u/47vrq9P3s/avno2BBf/MCClSob4iBIAAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+viewmag22:view view22 22:photo:22 22:R0lGODlhFgAWAIUAAPwCBBQSFJyanKy2tLzCxHyChNTa3Nzq7Nz29Nzy9Mzy9MTu9OTy9Nzi5Oz6/OT29MTi5Kzi7NTy9KTm7JzW3ITO1Lzq7IzW5HzK1LS+vMTq7Jze7ITW3GTCzGS+zLTS1MzOzLzq9Kzm7Jze5ITW5HTS3FS2vLze5EzCzEyyvEyutJTa5NTu9ITa5FTK1ESirLTm7Mzi5FS6xEy2vESerESmtFSutESmrKyqrAz+/Dw+RAzi3ASutHRydAAAAAAAACH5BAEAAAAALAAAAAAWABYAAAbIQIBQGCgWh8jksCgYEAaCozIZKBgOiIRiwSgEpstCw/HYQiKRhBcMCBgQDodkMaFU0t9pQHCIyy0TFxgYEVF6GQ4LCQkaERscHR4RH3lUIAkWCyEiIyQlHiYjEJVIAQQJJ2gjJSUoKSorlHoCLBQcHC0lLikvHjCGejEiHBgeMjM0NRwPpFQFDBHFNjceHAjAYFWoI7cnCVE4OWxtex8QH1EBOjs4zUpGUjw6Pe3j2fP19u/47vrq9P3s/cunr9S8gAIRFhTCLAgAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+viewmag+22:view view22 22:photo:22 22:R0lGODlhFgAWAIUAAPwCBBQSFJyanKy2tLzCxHyChNTa3Nzq7Nz29Nzy9Mzy9MTu9OTy9Nzi5Oz6/OT29MTi5Kzi7NTy9KTm7JzW3ITO1Lzq7IzW5HzK1LS+vMTq7Jze7ITW3GTCzGS+zLTS1MzOzLzq9Kzm7Jze5ITW5HTS3FS2vLze5EzCzEyyvEyutJTa5NTu9ITa5FTK1ESirLTm7Mzi5FS6xEy2vESerESmtFSutESmrKyqrAz+/Dw+RAzi3ASutHRydAQCBAAAACH5BAEAAAAALAAAAAAWABYAAAbQQIBQGCgWh8jksCgYEAaCozIZKBgOiIRiwSgEpstCw/HYQiKRhBcMCBgQDodkMaFU0t9pQHCIyy0TFxgYEVF6GQ4LCQkaERscHR4RH3lUIAkWCyEiIyQlHiYjEJVIAQQJJ2gjJSUoKSorlHoCLBQcHC0lLikvHjCGejEiHBgeMjM0NRwPpFQFDBHFNjceHAjAYFWoI7cnCVE4OWxtex8QH1EBOjs4zUpGUjw6Pe3j2fP19u/4zT766vRI+fvHD4CPgwcJ9qg0UB85JA0dDjEQBAAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
+viewmulticolumn22:view view22 22:photo:22 22:R0lGODlhFgAWAIMAAPwCBFRSVExKTDQyNPz+/Pz69PTq5AQCBOzaxOTKpAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAWABYAAARTEMhJq7046813+MJQfUF4BURhHGO6noSBsEcNoDJtS4KcsJQe4ncZ1HYT47HDbDqfUAnJRJmKLIGCCjjJbmE5wBI3EyOFxKCPS1EiJW52dE6vZyIAIf5oQ3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxDb3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3dy5kZXZlbGNvci5jb20AOw==
+viewtext22:view view22 22:photo:22 22:R0lGODlhFgAWAIAAAPwCBAQCBCH5BAEAAAAALAAAAAAWABYAAAIkhI+py+0Po2ShBlOxzbP7n2yaJoLm+ZTcxqHuC6hXzML2HVEFACH+aENyZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2ZWxjb3IuY29tADs=
+viewtree22:view view22 22:photo:22 22:R0lGODlhFgAWAIMAAPwCBAQCBFRSVExKTDQyNPz+/Pz69Pzu5PTq5OzaxBQOFOzKpFRWVFxWXOzexPTexCH5BAEAAAAALAAAAAAWABYAAARPEMhJq704g6A779kHCORAgNskFMYhakE8FkjyBcoWv+JwJItXaELYCTFHlCSpZKKcoB5jYHpOGgUadLKbIRw3jhEzQDyCSuI4zW673yhDBAAh/mhDcmVhdGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29yLmNvbQA7
diff --git a/jni/ruby/ext/tk/sample/tkextlib/ICONS/viewIcons.rb b/jni/ruby/ext/tk/sample/tkextlib/ICONS/viewIcons.rb
new file mode 100644
index 0000000..02ba19a
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkextlib/ICONS/viewIcons.rb
@@ -0,0 +1,329 @@
+#!/usr/bin/env ruby
+#
+# viewIcons.rb
+#
+# -- Display icons from icon library.
+#
+# -- Copy the clicked icon data (command string of creating
+# a TkPhotoImage instance) to the clipboard.
+#
+require 'tk'
+require 'tkextlib/ICONS'
+
+class ViewIcons
+ #####################################
+ private
+ #####################################
+ def _create_controls
+ @controls = base = TkFrame.new
+ columns = TkFrame.new(base)
+ line1 = TkFrame.new(base, :height=>2, :borderwidth=>1, :relief=>:sunken)
+ line2 = TkFrame.new(base, :height=>2, :borderwidth=>1, :relief=>:sunken)
+
+ lbl_library = TkLabel.new(base, :font=>@boldfont, :text=>'Library')
+ lbl_groups = TkLabel.new(base, :font=>@boldfont, :text=>'Groups')
+ lbl_columns = TkLabel.new(base, :font=>@boldfont, :text=>'Columns')
+
+ ent_library = TkEntry.new(base, :width=>50, :textvariable=>@library)
+ ent_groups = TkEntry.new(base, :width=>50, :textvariable=>@groups)
+
+ btn_browse = TkButton.new(base, :text=>'Browse',
+ :command=>method(:select_icons))
+ btn_view = TkButton.new(base, :text=>'View',
+ :command=>method(:display_icons))
+ btn_exit = TkButton.new(base, :text=>'Exit', :command=>proc{exit})
+
+ @column_btns = {}
+ 6.step(20, 2){|i|
+ @column_btns[i] = TkButton.new(columns,
+ :text=>i.to_s, :width=>2,
+ :command=>proc{set_columns(i)}
+ ).pack(:side=>:left)
+ }
+ @column_btns[@columns][:relief] = :sunken
+
+ lbl_library.grid(:row=>0, :column=>0, :padx=>4)
+ ent_library.grid(:row=>0, :column=>1)
+ btn_browse.grid(:row=>0, :column=>2, :padx=>4, :pady=>2, :sticky=>:ew)
+
+ line1.grid(:row=>1, :column=>0, :pady=>2, :columnspan=>3, :sticky=>:ew)
+
+ lbl_groups.grid(:row=>2, :column=>0, :padx=>4)
+ ent_groups.grid(:row=>2, :column=>1)
+ btn_view.grid(:row=>2, :column=>2, :padx=>4, :pady=>2, :sticky=>:ew)
+
+ line1.grid(:row=>3, :column=>0, :pady=>2, :columnspan=>3, :sticky=>:ew)
+
+ lbl_columns.grid(:row=>4, :column=>0, :padx=>4)
+ columns.grid(:row=>4, :column=>1, :padx=>2, :sticky=>:ew)
+ btn_exit.grid(:row=>4, :column=>2, :padx=>4, :pady=>2, :sticky=>:ew)
+
+ base.pack
+
+ ent_library.bind('Return', method(:display_icons), '')
+ ent_groups.bind('Return', method(:display_icons), '')
+ end
+
+ def _create_display
+ base = TkFrame.new(:borderwidth=>2, :relief=>:sunken)
+
+ @icons_window = icons = TkCanvas.new(base)
+ xscr = icons.xscrollbar(TkScrollbar.new(base))
+ yscr = icons.yscrollbar(TkScrollbar.new(base))
+
+ icons.grid(:row=>0, :column=>0, :sticky=>:news)
+ yscr.grid(:row=>0, :column=>1, :sticky=>:ns)
+ xscr.grid(:row=>1, :column=>0, :sticky=>:ew)
+ base.grid_columnconfigure(0, :weight=>1)
+ base.grid_columnconfigure(1, :weight=>0)
+ base.grid_rowconfigure(0, :weight=>1)
+ base.grid_rowconfigure(1, :weight=>0)
+ # yscr.pack(:side=>:right, :fill=>:y)
+ # xscr.pack(:side=>:bottom, :fill=>:x)
+ # icons.pack(:side=>:left, :fill=>:both, :expand=>true)
+
+ @icons_layout = TkFrame.new(icons).pack
+ TkcWindow.create(icons, 0, 0, :anchor=>:nw, :window=>@icons_layout)
+ @icons_layout.bind('Configure', method(:layout_resize), '')
+
+ base.pack(:expand=>true, :fill=>:both)
+ end
+
+ def _create_info_window
+ @info_window = TkToplevel.new(:background=>'lightyellow', :borderwidth=>1,
+ :relief=>:solid){|w|
+ lbl_name = TkLabel.new(w, :text=>'Name', :background=>'lightyellow',
+ :font=>@boldfont, :justify=>:left)
+ lbl_grps = TkLabel.new(w, :text=>'Groups', :background=>'lightyellow',
+ :font=>@boldfont, :justify=>:left)
+ lbl_type = TkLabel.new(w, :text=>'Type', :background=>'lightyellow',
+ :font=>@boldfont, :justify=>:left)
+ lbl_size = TkLabel.new(w, :text=>'Size', :background=>'lightyellow',
+ :font=>@boldfont, :justify=>:left)
+
+ lbl_name.grid(:row=>0, :column=>0, :sticky=>:w)
+ lbl_grps.grid(:row=>1, :column=>0, :sticky=>:w)
+ lbl_type.grid(:row=>2, :column=>0, :sticky=>:w)
+ lbl_size.grid(:row=>3, :column=>0, :sticky=>:w)
+
+ @name = TkLabel.new(w, :background=>'lightyellow', :justify=>:left)
+ @grps = TkLabel.new(w, :background=>'lightyellow', :justify=>:left)
+ @type = TkLabel.new(w, :background=>'lightyellow', :justify=>:left)
+ @size = TkLabel.new(w, :background=>'lightyellow', :justify=>:left)
+
+ @name.grid(:row=>0, :column=>1, :sticky=>:w)
+ @grps.grid(:row=>1, :column=>1, :sticky=>:w)
+ @type.grid(:row=>2, :column=>1, :sticky=>:w)
+ @size.grid(:row=>3, :column=>1, :sticky=>:w)
+
+ def name(txt)
+ @name['text'] = txt
+ end
+ def groups(txt)
+ @grps['text'] = txt
+ end
+ def type(txt)
+ @type['text'] = txt
+ end
+ def size(txt)
+ @size['text'] = txt
+ end
+
+ overrideredirect(true)
+ withdraw
+ }
+ end
+
+ def initialize(init_path = Tk::LIBRARY)
+ init_path = Tk::LIBRARY unless init_path
+ init_path = File.expand_path(init_path)
+ if File.directory?(init_path)
+ @initial_dir = init_path
+ @initial_file = 'tkIcons'
+ else
+ @initial_dir = File.dirname(init_path)
+ @initial_file = File.basename(init_path)
+ end
+
+ if Tk::PLATFORM['platform'] == 'unix'
+ TkOption.add('*HighlightThickness', 0)
+ end
+
+ @columns = 14
+ @command = ""
+
+ @delay_timer = nil
+
+ dummy = TkLabel.new
+ @font = dummy.font
+ @boldfont = TkFont.new(@font, :weight=>:bold)
+ @icons = {}
+ @icon_name = {}
+ @icon_info = {}
+
+ @library = TkVariable.new(File.join(@initial_dir, @initial_file))
+ @groups = TkVariable.new('*')
+
+ _create_controls
+
+ _create_display
+
+ _create_info_window
+
+ Tk.root.title('viewIcons')
+ layout_resize
+ Tk.root.resizable(false, true)
+
+ display_icons
+ end
+
+ def init_info(item, name)
+ @icon_name[item] = name
+
+ item.bind('Button-1', method(:clip_info), '%W')
+ item.bind('Enter', method(:delay_info), '%W')
+ item.bind('Leave', method(:cancel_info), '')
+ end
+
+ def delay_info(item)
+ cancel_info
+ @delay_timer = TkTimer.new(200, 1, proc{ show_info(item) }).start
+ end
+
+ def cancel_info
+ if @delay_timer
+ @delay_timer.cancel
+ @delay_timer = nil
+ end
+ @info_window.withdraw
+ end
+
+ def show_info(item)
+ name, groups, type, size = @icon_info[@icon_name[item]]
+ @info_window.name(name)
+ @info_window.groups(groups)
+ @info_window.type(type)
+ @info_window.size(size)
+
+ info_x = item.winfo_rootx + 10
+ info_y = item.winfo_rooty + item.winfo_height
+
+ @info_window.geometry("+#{info_x}+#{info_y}")
+ @info_window.deiconify
+
+ @info_window.raise
+
+ @delay_timer = nil
+ end
+
+ def primary_transfer(offset, max_chars)
+ @command
+ end
+
+ def lost_selection
+ @command = ""
+ end
+
+ def clip_info(item)
+ name = @icon_name[item]
+ data_width = 60
+
+ cmd = "#{name} = TkPhotoImage.new(:data=><<'EOD')\n"
+
+ icon_data = Tk::ICONS.query(name, :file=>@library.value, :items=>'d')[0][0]
+
+ icon_data.scan(/.{1,#{data_width}}/m){|s| cmd << ' ' << s << "\n"}
+
+ cmd << "EOD\n"
+
+ @command = cmd
+
+ TkClipboard.clear
+ TkClipboard.append(@command)
+
+ if Tk::PLATFORM['platform'] == 'unix'
+ TkSelection.handle(Tk.root, method(:primary_transfer),
+ :selection=>'PRIMARY')
+ TkSelection.set_owner(Tk.root, :selection=>'PRIMARY',
+ :command=>method(:lost_selection))
+ end
+
+ Tk.bell
+ end
+
+ def layout_resize
+ Tk.update
+ bbox = @icons_window.bbox('all')
+ width = @controls.winfo_width - @icons_window.yscrollbar.winfo_width - 8
+
+ @icons_window.configure(:width=>width, :scrollregion=>bbox,
+ :xscrollincrement=>'0.1i',
+ :yscrollincrement=>'0.1i')
+ end
+
+ def select_icons
+ new_lib = Tk.getOpenFile(:initialdir=>@initial_dir,
+ :initialfile=>'tkIcons',
+ :title=>'Select Icon Library',
+ :filetypes=>[
+ ['Icon Libraries', ['tkIcons*']],
+ ['All Files', ['*']]
+ ])
+
+ @library.value = new_lib if new_lib.length != 0
+ display_icons
+ end
+
+ def display_icons
+ column = 0
+ limit = @columns - 1
+ row = 0
+
+ unless File.exist?(@library.value)
+ Tk.messageBox(:icon=>'warning', :message=>'File does not exist',
+ :title=>'viewIcons')
+ return
+ end
+
+ cursor = Tk.root[:cursor]
+ Tk.root[:cursor] = 'watch'
+
+ Tk::ICONS.delete(@icons)
+
+ @icons_frame.destroy if @icons_frame
+ @icons_frame = TkFrame.new(@icons_layout).pack
+
+ @icons = Tk::ICONS.create(:file=>@library.value, :group=>@groups.value)
+
+ Tk::ICONS.query(:file=>@library.value, :group=>@groups.value).each{|inf|
+ name = inf[0]
+ @icon_info[name] = inf
+
+ lbl = TkLabel.new(@icons_frame, :image=>"::icon::#{name}")
+ lbl.grid(:column=>column, :row=>row, :padx=>3, :pady=>3)
+ # lbl.grid_columnconfigure column
+
+ init_info(lbl, name)
+
+ if column == limit
+ column = 0
+ row += 1
+ else
+ column += 1
+ end
+ }
+
+ Tk.root[:cursor] = cursor
+ end
+
+ def set_columns(columns)
+ @columns = columns
+ 6.step(20, 2){|i| @column_btns[i][:relief] = :raised }
+ @column_btns[@columns][:relief] = :sunken
+ display_icons
+ end
+end
+
+ViewIcons.new(ARGV[0])
+
+Tk.mainloop
diff --git a/jni/ruby/ext/tk/sample/tkextlib/blt/barchart5.rb b/jni/ruby/ext/tk/sample/tkextlib/blt/barchart5.rb
new file mode 100644
index 0000000..86101b2
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkextlib/blt/barchart5.rb
@@ -0,0 +1,101 @@
+#!/usr/bin/env ruby
+require 'tk'
+require 'tkextlib/blt'
+
+load File.join(File.dirname(File.expand_path(__FILE__)),
+ 'scripts', 'stipples.rb')
+
+TkOption.add('*graph.x.Title', 'X Axis Label')
+TkOption.add('*graph.y.Title', 'Y Axis Label')
+TkOption.add('*graph.title', 'A Simple Barchart')
+TkOption.add('*graph.x.Font', 'Times 10')
+TkOption.add('*graph.Element.Relief', :raised)
+
+visual = Tk.root.winfo_screenvisual
+if visual != 'staticgray' && visual != 'grayscale'
+ TkOption.add('*graph.LineMarker.color', 'yellow')
+ TkOption.add('*graph.Element.Background', 'white')
+ TkOption.add('*graph.Legend.activeForeground', 'pink')
+ TkOption.add('*print.background', 'yellow')
+ TkOption.add('*quit.background', 'red')
+ TkOption.add('*graph.background', 'palegreen')
+ TkOption.add('*graph.plotBackground', 'lightblue')
+end
+
+htext = Tk::BLT::Htext.new(:widgetname=>'.htext', :text=><<EOD)
+ This is an example of the barchart widget. The barchart has
+ many components; x and y axis, legend, crosshairs, elements, etc.
+ To create a postscript file "bar.ps", press the %%
+
+ ruby {
+ b = TkButton.new(Tk::BLT::Htext::Htext_Widget.window,
+ :widgetname=>'print', :text=>'Print',
+ :command=>proc{
+ $graph.postsript(:output=>'bar.ps')
+ })
+ Tk::BLT::Htext::Htext_Widget.window.append(b)
+ }
+
+%% button.
+%%
+
+ ruby {
+ $graph = Tk::BLT::Barchart.new(:widgetname=>'.htext.graph',
+ :relief=>:raised, :borderwidth=>2)
+ $graph.xaxis_configure(:rotate=>90, :stepsize=>0)
+ Tk::BLT::Htext::Htext_Widget.window.append($graph,
+ :fill=>:both, :padx=>4)
+ }
+
+%%
+ Hit the %%
+
+ ruby {
+ b = TkButton.new(Tk::BLT::Htext::Htext_Widget.window,
+ :widgetname=>'quit', :text=>'Quit',
+ :command=>proc{ exit })
+ Tk::BLT::Htext::Htext_Widget.window.append(b)
+ }
+
+%% button when you've seen enough.%%
+
+ ruby {
+ l = TkLabel.new(Tk::BLT::Htext::Htext_Widget.window, :bitmap=>'BLT')
+ Tk::BLT::Htext::Htext_Widget.window.append(l, :padx=>20)
+ }
+
+%%
+EOD
+
+names = %w(One Two Three Four Five Six Seven Eight)
+if visual == 'staticgray' || visual == 'grayscale'
+ fgcolors = %w(white white white white white white white white)
+ bgcolors = %w(black black black black black black black black)
+else
+ fgcolors = %w(yellow orange red magenta purple blue cyan green)
+ bgcolors = %w(yellow4 orange4 red4 magenta4 purple4 blue4 cyan4 green4)
+end
+
+numColors = names.length
+
+Tk::TCL_PRECISION.value = 15
+
+x = Tk::BLT::Vector.new
+y = Tk::BLT::Vector.new
+x.seq(-5.0, 5.0, 0.2)
+y.expr("sin(#{x})")
+barWidth = 0.19
+
+$graph.element_create('sin', :relief=>:raised, :borderwidth=>1,
+ :x=>x, :y=>y, :barwidth=>barWidth)
+
+Tk::BLT::Table.add(Tk.root, htext, :fill=>:both)
+
+Tk.root.minsize(0, 0)
+
+Tk::BLT.zoom_stack($graph)
+Tk::BLT.crosshairs($graph)
+Tk::BLT.active_legend($graph)
+Tk::BLT.closest_point($graph)
+
+Tk.mainloop
diff --git a/jni/ruby/ext/tk/sample/tkextlib/blt/calendar.rb b/jni/ruby/ext/tk/sample/tkextlib/blt/calendar.rb
new file mode 100644
index 0000000..86d3404
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkextlib/blt/calendar.rb
@@ -0,0 +1,117 @@
+#!/usr/bin/env ruby
+
+require 'tk'
+require 'tkextlib/blt'
+
+require 'date'
+
+dir = File.join(File.dirname(File.expand_path(__FILE__)), 'images')
+file = File.join(dir, 'chalk.gif')
+active = File.join(dir, 'rain.gif')
+
+texture1 = TkPhotoImage.new(:file=>file)
+texture2 = TkPhotoImage.new(:file=>active)
+
+TkOption.add('*Tile', texture1)
+
+TkOption.add('*HighlightThickness', 0)
+TkOption.add('*calendar.weekframe*Tile', texture2)
+TkOption.add('*Calendar.Label.borderWidth', 0)
+TkOption.add('*Calendar.Label.relief', :sunken)
+TkOption.add('*Calendar.Frame.borderWidth', 2)
+TkOption.add('*Calendar.Frame.relief', :raised)
+TkOption.add('*Calendar.Label.font', 'Helvetica 11')
+TkOption.add('*Calendar.Label.foreground', 'navyblue')
+TkOption.add('*button.foreground', 'navyblue')
+TkOption.add('*background', 'grey85')
+TkOption.add('*Label.ipadX', 200)
+
+TkOption.add('*tile', texture2)
+
+class BLT_Calendar_sample
+ @@monthInfo = [
+ nil, # dummy
+ ['January', 31],
+ ['February', 28],
+ ['March', 31],
+ ['April', 30],
+ ['May', 31],
+ ['June', 30],
+ ['July', 31],
+ ['August', 31],
+ ['Septembar', 30],
+ ['October', 31],
+ ['November', 30],
+ ['December', 31]
+ ]
+
+ @@abbrDays = [ 'Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat' ]
+
+ def initialize()
+ today = Date.today
+
+ if TkComm.bool(Tk.info(:commands, '.calendar'))
+ Tk.destroy('.calendar')
+ end
+ cal = Tk::BLT::Tile::Frame.new(:widgetname=>'.calendar',
+ :classname=>'Calendar',
+ :width=>'3i', :height=>'3i')
+
+ mon = Tk::BLT::Tile::Label.new(cal, :font=>'Courier 14 bold',
+ :text=>"#{@@monthInfo[today.month][0]} " +
+ "#{today.year}")
+ Tk::BLT::Table.add(cal, mon, [1, 0], :cspan=>7, :pady=>10)
+
+ week_f = Tk::BLT::Tile::Frame.new(cal, :widgetname=>'weekframe',
+ :relief=>:sunken, :borderwidth=>1)
+ Tk::BLT::Table.add(cal, week_f, [2, 0], :columnspan=>7, :fill=>:both)
+
+ @@abbrDays.each_with_index{|dayName, idx|
+ Tk::BLT::Table.add(cal,
+ Tk::BLT::Tile::Label.new(cal, :text=>dayName,
+ :font=>'Helvetica 12'),
+ [2, idx], :pady=>2, :padx=>2)
+ }
+
+ Tk::BLT::Table.itemconfigure(cal, 'c*', 'r2', :pad=>4)
+
+ numDays = @@monthInfo[today.month][1]
+ week = 0
+ cnt = 1
+
+ wkday = today.wday - ((today.day - 1) % 7)
+ wkday += 7 if wkday < 0
+
+ while cnt <= numDays
+ Tk::BLT::Table.add(cal,
+ Tk::BLT::Tile::Label.new(cal, :text=>cnt){
+ self.configure(:borderwidth=>1,
+ :relief=>:sunken) if cnt == today.day
+ },
+ [week+3, wkday], :fill=>:both, :ipadx=>10, :ipady=>4)
+ cnt += 1
+ wkday += 1
+ if wkday == 7
+ week += 1
+ wkday = 0
+ end
+ end
+
+ Tk::BLT::Tile::Frame.new(cal, :borderwidth=>1, :relief=>:sunken){|f|
+ Tk::BLT::Table.add(f,
+ Tk::BLT::Tile::Button.new(f, :widgetname=>'button',
+ :command=>proc{exit},
+ :borderwidth=>2,
+ :text=>'Quit'),
+ :padx=>4, :pady=>4)
+ Tk::BLT::Table.add(cal, f, [week+4, 5], :cspan=>2, :pady=>4)
+ }
+
+ Tk::BLT::Table.add(Tk.root, cal, :fill=>:both)
+ Tk::BLT::Table.itemconfigure(cal, 'r0', :resize=>:none)
+ end
+end
+
+BLT_Calendar_sample.new
+
+Tk.mainloop
diff --git a/jni/ruby/ext/tk/sample/tkextlib/blt/graph6.rb b/jni/ruby/ext/tk/sample/tkextlib/blt/graph6.rb
new file mode 100644
index 0000000..b3eeb81
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkextlib/blt/graph6.rb
@@ -0,0 +1,2222 @@
+#!/usr/bin/env ruby
+
+require 'tk'
+require 'tkextlib/blt'
+
+Tk::TCL_PRECISION.value = 15
+
+[
+ ['*Graph.Width', '10i'],
+ ['*Graph.leftMargin', '.75i'],
+ ['*Graph.Height', '6i'],
+ ['*Graph.plotBackground', 'black'],
+ ['*LineMarker.color', 'white'],
+ ['*LineMarker.Dashes', 5],
+ ['*TextMarker.foreground', 'white'],
+ ['*TextMarker.Background', ''],
+
+ ['*Graph.x.hide', true],
+ ['*Graph.x.title', ''],
+ ['*Graph.y.rotate', 90],
+ # ['*Graph.y.stepSize', 2.0],
+ ['*Graph.title', ''],
+ ['*graph.Title', 'Example s27'],
+ ['*graph.x.hide', false],
+ ['*graph.topMargin', 0],
+ ['*graph.bottomMargin', 0],
+ ['*x.Title', 'Time'],
+ ['*y.Title', 'Signals'],
+ ['*Pixels', 1],
+
+ ['*Reduce', 0.5],
+ ['*bufferElements', false],
+
+ ['*Element.color', 'green4'],
+ ['*Element.ScaleSymbols', true],
+ ['*Element.Color', 'grey70'],
+ ['*Element.Symbol', :none],
+ ['*Element.LineWidth', 1],
+ # ['*Element.Smooth', :natural],
+ ['*Element.Smooth', :catrom],
+
+ ['*activeLine.LineWidth', 2],
+ ['*activeLine.Color', 'white'],
+ ['*activeLine.Color', 'green1'],
+
+ # ['*Legend.Hide', true],
+ ['*Legend.Position', :right],
+ ['*Legend.Relief', :flat],
+ ['*Legend.activeRelief', :sunken],
+ ['*Legend.borderWidth', 2],
+ #['*Legend.Font', '-*-helvetica-medium-r-*-*-10-*-*-*-*-*-*-*'],
+ ['*Legend.Font', 'Helvetica -10'],
+ ['*Grid.hide', false],
+ ['*Grid.dashes', [1, 5]],
+
+ # ['*foreground', 'white'],
+ ['*zoomOutline.outline', 'yellow'],
+].each{|k, v| TkOption.add(k, v)}
+
+##############################
+
+class BLT_Graph_Demo
+ def initialize
+ @graph = Tk::BLT::Graph.new(:widgetname=>'graph')
+
+ @root = Tk.root
+ @root.minsize(0, 0)
+
+ _set_vectors()
+ (1..39).each{|i| @graph.element_create("V#{i}", :x=>@x, :y=>@v[i])}
+
+ @top = Tk::BLT::Tile::Toplevel.new
+=begin
+ legend = Tk::BLT::Graph.new(@top, :widgetname=>'legend',
+ :without_creating=>true)
+ @graph.legend_configure(:position=>legend)
+=end
+ # legend = @graph.legend_window_create(@top, :widgetname=>'legend')
+ legend = @graph.legend_window_create(@top)
+ legend.pack(:fill=>:both, :expand=>true)
+
+ Tk::BLT::Table.add(@root, @graph, [0,0], :fill=>:both)
+
+ @quit_btn = Tk::BLT::Tile::Button.new(:text=>' quit ', :background=>'red',
+ :command=>proc{exit})
+ Tk::BLT::Table.add(@root, @quit_btn, [1,0], :anchor=>:e, :padx=>10)
+
+ @graph.zoom_stack
+ @graph.crosshairs
+ @graph.closest_point
+ @graph.print_key
+
+ @graph.legend_bind(:all, 'ButtonRelease-1',
+ proc{|w| highlightTrace(w)}, '%W')
+ @graph.legend_bind(:all, 'ButtonRelease-3',
+ proc{|w|
+ w.legend_deactivate('*')
+ active = w.element_activate
+ w.element_deactivate(*active)
+ }, '%W')
+ end
+
+ private
+
+ def _set_vectors
+ @x = Tk::BLT::Vector.new(:variable=>'')
+ @v = []
+ (1..39).each{|i| @v[i] = Tk::BLT::Vector.new(:variable=>'')}
+
+ @x.set(<<-'EOD')
+ 0 1e-10 2e-10 3e-10 4e-10 5e-10 6e-10 7e-10 8e-10 9e-10
+ 1e-09 1.1e-09 1.2e-09 1.3e-09 1.4e-09 1.5e-09 1.6e-09 1.7e-09
+ 1.8e-09 1.9e-09 2e-09 2.1e-09 2.2e-09 2.3e-09 2.4e-09 2.5e-09
+ 2.6e-09 2.7e-09 2.8e-09 2.9e-09 3e-09 3.1e-09 3.2e-09 3.3e-09
+ 3.4e-09 3.5e-09 3.6e-09 3.7e-09 3.8e-09 3.9e-09 4e-09 4.1e-09
+ 4.2e-09 4.3e-09 4.4e-09 4.5e-09 4.6e-09 4.7e-09 4.8e-09
+ 4.9e-09 5e-09 5.1e-09 5.2e-09 5.3e-09 5.4e-09 5.5e-09 5.6e-09
+ 5.7e-09 5.8e-09 5.9e-09 6e-09 6.1e-09 6.2e-09 6.3e-09 6.4e-09
+ 6.5e-09 6.6e-09 6.7e-09 6.8e-09 6.9e-09 7e-09 7.1e-09 7.2e-09
+ 7.3e-09 7.4e-09 7.5e-09 7.6e-09 7.7e-09 7.8e-09 7.9e-09
+ 8e-09 8.1e-09 8.2e-09 8.3e-09 8.4e-09 8.5e-09 8.6e-09 8.7e-09
+ 8.8e-09 8.9e-09 9e-09 9.1e-09 9.2e-09 9.3e-09 9.4e-09 9.5e-09
+ 9.6e-09 9.7e-09 9.8e-09 9.9e-09 1e-08 1.01e-08 1.02e-08
+ 1.03e-08 1.04e-08 1.05e-08 1.06e-08 1.07e-08 1.08e-08 1.09e-08
+ 1.1e-08 1.11e-08 1.12e-08 1.13e-08 1.14e-08 1.15e-08 1.16e-08
+ 1.17e-08 1.18e-08 1.19e-08 1.2e-08 1.21e-08 1.22e-08 1.23e-08
+ 1.24e-08 1.25e-08 1.26e-08 1.27e-08 1.28e-08 1.29e-08 1.3e-08
+ 1.31e-08 1.32e-08 1.33e-08 1.34e-08 1.35e-08 1.36e-08 1.37e-08
+ 1.38e-08 1.39e-08 1.4e-08 1.41e-08 1.42e-08 1.43e-08 1.44e-08
+ 1.45e-08 1.46e-08 1.47e-08 1.48e-08 1.49e-08 1.5e-08 1.51e-08
+ 1.52e-08 1.53e-08 1.54e-08 1.55e-08 1.56e-08 1.57e-08 1.58e-08
+ 1.59e-08 1.6e-08 1.61e-08 1.62e-08 1.63e-08 1.64e-08 1.65e-08
+ 1.66e-08 1.67e-08 1.68e-08 1.69e-08 1.7e-08 1.71e-08 1.72e-08
+ 1.73e-08 1.74e-08 1.75e-08 1.76e-08 1.77e-08 1.78e-08 1.79e-08
+ 1.8e-08 1.81e-08 1.82e-08 1.83e-08 1.84e-08 1.85e-08 1.86e-08
+ 1.87e-08 1.88e-08 1.89e-08 1.9e-08 1.91e-08 1.92e-08 1.93e-08
+ 1.94e-08 1.95e-08 1.96e-08 1.97e-08 1.98e-08 1.99e-08 2e-08
+ 2.01e-08 2.02e-08 2.03e-08 2.04e-08 2.05e-08 2.06e-08 2.07e-08
+ 2.08e-08 2.09e-08 2.1e-08 2.11e-08 2.12e-08 2.13e-08 2.14e-08
+ 2.15e-08 2.16e-08 2.17e-08 2.18e-08 2.19e-08 2.2e-08 2.21e-08
+ 2.22e-08 2.23e-08 2.24e-08 2.25e-08 2.26e-08 2.27e-08 2.28e-08
+ 2.29e-08 2.3e-08 2.31e-08 2.32e-08 2.33e-08 2.34e-08 2.35e-08
+ 2.36e-08 2.37e-08 2.38e-08 2.39e-08 2.4e-08 2.41e-08 2.42e-08
+ 2.43e-08 2.44e-08 2.45e-08 2.46e-08 2.47e-08 2.48e-08 2.49e-08
+ 2.5e-08 2.51e-08 2.52e-08 2.53e-08 2.54e-08 2.55e-08 2.56e-08
+ 2.57e-08 2.58e-08 2.59e-08 2.6e-08 2.61e-08 2.62e-08 2.63e-08
+ 2.64e-08 2.65e-08 2.66e-08 2.67e-08 2.68e-08 2.69e-08 2.7e-08
+ 2.71e-08 2.72e-08 2.73e-08 2.74e-08 2.75e-08 2.76e-08 2.77e-08
+ 2.78e-08 2.79e-08 2.8e-08 2.81e-08 2.82e-08 2.83e-08 2.84e-08
+ 2.85e-08 2.86e-08 2.87e-08 2.88e-08 2.89e-08 2.9e-08 2.91e-08
+ 2.92e-08 2.93e-08 2.94e-08 2.95e-08 2.96e-08 2.97e-08 2.98e-08
+ 2.99e-08 3e-08 3.01e-08 3.02e-08 3.03e-08 3.04e-08 3.05e-08
+ 3.06e-08 3.07e-08 3.08e-08 3.09e-08 3.1e-08 3.11e-08 3.12e-08
+ 3.13e-08 3.14e-08 3.15e-08 3.16e-08 3.17e-08 3.18e-08 3.19e-08
+ 3.2e-08 3.21e-08 3.22e-08 3.23e-08 3.24e-08 3.25e-08 3.26e-08
+ 3.27e-08 3.28e-08 3.29e-08 3.3e-08 3.31e-08 3.32e-08 3.33e-08
+ 3.34e-08 3.35e-08 3.36e-08 3.37e-08 3.38e-08 3.39e-08 3.4e-08
+ 3.41e-08 3.42e-08 3.43e-08 3.44e-08 3.45e-08 3.46e-08 3.47e-08
+ 3.48e-08 3.49e-08 3.5e-08 3.51e-08 3.52e-08 3.53e-08 3.54e-08
+ 3.55e-08 3.56e-08 3.57e-08 3.58e-08 3.59e-08 3.6e-08
+ EOD
+
+ @v[1].set(<<-'EOD')
+ 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5
+ 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5
+ 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5
+ 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5
+ 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5
+ 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5
+ 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5
+ 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5
+ 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5
+ 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5
+ 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5
+ 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5
+ 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5
+ EOD
+
+ @v[2].set(<<-'EOD')
+ 0 1 2 3 4 5 5 5 5 5 5 5 5 5 5 5 4 3 2 1 0 0 0 0 0 0 0 0
+ 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+ 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+ 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+ 0 0 0 0 0 0 0 0 0 1 2 3 4 5 5 5 5 5 5 5 5 5 5 5 4 3 2 1
+ 5.32907e-15 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+ 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+ 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+ 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 2 3 4 5 5
+ 5 5 5 5 5 5 5 5 5 4 3 2 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+ 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+ 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+ 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+ 0 0
+ EOD
+
+ @v[3].set(<<-'EOD')
+ 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 4 3 2 1 8.88178e-16
+ 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+ 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+ 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+ 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+ 0 0 0 1 2 3 4 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5
+ 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5
+ 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5
+ 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5
+ 5 5 5 5 5 5 5 5 5 5 5 4 3 2 1 2.13718e-14 0 0 0 0 0 0 0
+ 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+ 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+ 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+ 0 0 0 0
+ EOD
+
+ @v[4].set(<<-'EOD')
+ 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 2 3 4 5 5 5
+ 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5
+ 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5
+ 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5
+ 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5
+ 5 4 3 2 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+ 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+ 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+ 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+ 0 0 0 0 0 0 0 0 0 1 2 3 4 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5
+ 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5
+ 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5
+ 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5
+ EOD
+
+ @v[5].set(<<-'EOD')
+ 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 2 3 4 5 5 5
+ 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5
+ 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5
+ 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5
+ 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5
+ 5 4 3 2 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+ 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+ 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+ 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+ 0 0 0 0 0 0 0 0 0 1 2 3 4 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5
+ 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5
+ 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5
+ 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5
+ EOD
+
+ @v[6].set(<<-'EOD')
+ 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 4 3 2 1 8.88178e-16
+ 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+ 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+ 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+ 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+ 0 0 0 1 2 3 4 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5
+ 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5
+ 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5
+ 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5
+ 5 5 5 5 5 5 5 5 5 5 5 4 3 2 1 2.13718e-14 0 0 0 0 0 0 0
+ 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+ 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+ 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+ 0 0 0 0
+ EOD
+
+ @v[7].set(<<-'EOD')
+ 5 5.16904 4.84159 3.34542 0.317102 0.103304 0.0275721 0.0221534
+ 0.017689 0.0142639 0.0113974 0.00918238 0.00742541 0.00616602
+ 0.00481195 0.00397049 -0.0659889 -0.025671 0.165495 0.986891
+ 3.05229 4.55511 4.91611 4.98192 4.99428 4.99833 4.99095
+ 4.97295 4.95493 4.93428 4.90723 4.94799 4.98584 4.99566
+ 4.99813 4.99907 4.99947 4.99965 4.99976 4.99984 4.99989
+ 4.99992 4.99994 4.99996 4.99998 5.00002 5.00006 5.00002
+ 4.99996 4.99994 4.99999 5.00003 5.00002 5 4.99997 4.99997
+ 4.99997 4.99997 4.99997 4.99996 4.99997 4.99997 4.99998
+ 4.99998 4.99999 5 5 5 5 5 5 5.00001 5.00001 5.00001 5.00001
+ 5.00001 5.00001 5.00001 5.00001 5.00001 5.00001 5.00001
+ 5.00001 5.00001 5 5 5 5 5 5 5 4.99999 4.99999 4.99999 4.99999
+ 4.99999 4.99999 4.99998 4.99998 4.99998 4.99999 4.99999
+ 4.99999 4.99999 4.99999 4.99999 4.99999 4.99999 4.99999
+ 4.99999 4.99999 4.99999 4.99999 4.99999 5 5 5 5 5 5 5 5.16575
+ 4.69986 2.43862 0.0230224 0.035229 -0.0210607 -0.0292766
+ -0.0172693 -0.00271479 -0.000912251 -0.000349106 -0.000116866
+ -4.24733e-05 -1.39536e-05 -3.01179e-05 -0.0657192 -0.0204835
+ 0.183378 1.07181 3.118 4.46472 4.84158 4.94795 4.98173 4.99236
+ 4.99762 5.01939 5.0433 5.05332 5.04959 5.03955 5.02851 5.02052
+ 5.01422 5.00965 5.00631 5.00405 5.00248 5.00083 5.00012
+ 5.00209 5.00387 5.00347 4.99917 4.99213 4.98411 4.97521
+ 4.96332 4.94601 4.9304 4.94633 4.97936 4.99264 4.99685 4.99857
+ 4.99925 4.99954 4.9997 4.99973 4.9997 4.99973 4.99979 4.99983
+ 4.99986 4.99988 4.9999 4.9999 4.99992 4.99993 4.99994 4.99995
+ 4.99996 4.99996 4.99997 4.99997 4.99998 4.99998 4.99998
+ 4.99999 4.99999 4.99999 4.99999 4.99999 4.99999 4.99999
+ 5 5 5 5.00001 5.00001 5.00001 5.00001 5.00002 5.00002 5.00002
+ 5.00002 5.00001 5.00001 5.00001 5 5 5 5 5 5 5 5 4.99999
+ 4.99999 4.99999 4.99999 4.99999 4.99999 4.99999 4.99999
+ 4.99999 4.99999 4.99999 5 5 5.14242 4.76101 3.16003 0.299374
+ 0.0645506 -0.000498424 -2.45108e-05 -2.27986e-05 -5.24401e-05
+ -4.9884e-05 -4.92491e-05 -2.93354e-05 -3.21402e-05 -2.11851e-05
+ -3.37925e-05 -0.0657892 -0.020563 0.182582 1.06058 3.12484
+ 4.46552 4.84146 4.95102 4.98556 4.99472 4.99806 4.99909
+ 4.99955 4.99976 4.99994 4.99992 5.00029 4.99967 4.99849
+ 4.99736 4.99884 5.00099 5.00377 5.00215 4.99994 4.99893
+ 4.99788 4.99862 5.00055 5.00134 5.00127 5.00073 5.00039
+ 5.00018 5.00006 5.00001 4.99985 5.00026 5.00018 5.00003
+ 4.99981 4.99985 4.99987 4.99985 4.99982 4.99982 4.99982
+ 4.99983 4.99985 4.99987 4.99989 4.99991 4.99992 4.99994
+ 4.99995 4.99995 4.99994 4.99994 4.99996 4.99999 5.00002
+ 5.00008 5.00009 5.00006 5.00001 5 4.99999 4.99998 4.99997
+ 4.99996 4.99997 4.99997 4.99998 4.99998 4.99999 4.99999
+ 4.99999 5 5 5 5 5.00001 5.00001 5.00001 5.00001 5.00001
+ 5.00001 5.00001 5.00001 5.00001 5.00001 5.00001 5.00001
+ 5 5 5 5 5 4.99999 4.99999 4.99999 4.99999 4.99998 4.99998
+ 4.99998
+ EOD
+
+ @v[8].set(<<-'EOD')
+ 5 5.03758 5.04711 4.96911 4.20882 3.96295 4.01117 4.15521
+ 4.2967 4.42274 4.5295 4.6176 4.69014 4.74831 4.7966 4.83537
+ 4.80526 4.787 4.79295 4.88588 5.08978 5.15615 5.10778 5.07718
+ 5.06652 5.08225 4.9744 4.52977 3.77452 2.69426 1.15294 0.245509
+ 0.0981544 0.0567527 0.0367487 0.0252578 0.0180599 0.0133837
+ 0.0101497 0.0078616 0.00620186 0.00499056 0.0041027 0.00344223
+ 0.00295808 0.00260089 0.00229887 0.00200817 0.00176397 0.00160116
+ 0.00147381 0.00134645 0.00125029 0.00116043 0.00107371 0.00101981
+ 0.000965921 0.000912028 0.000858135 0.000804242 0.000761669
+ 0.00072672 0.000691771 0.000656823 0.000621874 0.000588722
+ 0.00057041 0.000552098 0.000533785 0.000515473 0.000497162
+ 0.00047885 0.000460537 0.000442226 0.000423914 0.000405601
+ 0.000388399 0.000378694 0.000368989 0.000359284 0.00034958
+ 0.000339875 0.00033017 0.000320465 0.00031076 0.000301055
+ 0.00029135 0.000282207 0.000276247 0.000270287 0.000264327
+ 0.000258367 0.000252407 0.000246447 0.000240487 0.000234527
+ 0.000228567 0.000222607 0.000217086 0.000213696 0.000210307
+ 0.000206918 0.000203528 0.000200139 0.00019675 0.00019336
+ 0.000189971 0.000186582 0.000183192 0.000179803 0.000176414
+ 0.000173025 0.000169635 0.000166246 0.000162857 0.000159467
+ 0.000156078 0.000152689 0.000149299 0.00014591 0.00014255
+ 0.0316021 0.163272 0.348732 0.603651 0.35745 0.135965 0.0707354
+ 0.0314595 0.0201047 0.00994945 0.00389601 0.00138839 0.00060778
+ 0.000329648 0.000492396 -0.0732035 -0.0844077 -0.0789062
+ -0.0390837 0.0197559 0.0183094 -0.00180099 -0.0189565 -0.0424144
+ -0.0735904 -0.0892423 0.285039 1.13702 2.10809 2.95826 3.60164
+ 4.0435 4.35771 4.57254 4.71769 4.81329 4.87534 4.91487 4.94264
+ 4.97375 5.01526 5.06517 5.10154 5.06259 4.89005 4.5787 4.12226
+ 3.46151 2.49023 1.2586 0.32725 0.116753 0.0701865 0.0455509
+ 0.0286914 0.0178176 0.0117599 0.00902715 0.00760583 0.00637745
+ 0.00543811 0.00439377 0.00352448 0.0030151 0.00285771 0.002465
+ 0.00203114 0.00173004 0.0014839 0.00125177 0.00105327 0.000894905
+ 0.000766372 0.000658894 0.000569105 0.000492114 0.000427938
+ 0.000370217 0.000314758 0.000266569 0.000233726 0.000209048
+ 0.000191957 0.000177169 0.000166604 0.000161 0.000157314
+ 0.000143828 0.000130342 0.000116857 0.000103371 8.98855e-05
+ 7.63998e-05 6.29141e-05 5.76583e-05 5.30027e-05 4.8347e-05
+ 4.36913e-05 3.90357e-05 3.438e-05 2.97243e-05 2.72507e-05
+ 2.59083e-05 2.45659e-05 2.32235e-05 2.18811e-05 2.05387e-05
+ 1.91963e-05 1.78539e-05 1.65115e-05 1.51691e-05 1.38267e-05
+ 1.24843e-05 1.11419e-05 9.79954e-06 8.51574e-06 7.69807e-06
+ 6.8804e-06 6.06273e-06 5.24506e-06 0.0287318 0.0317111 -0.0320087
+ -0.103609 0.0369639 0.0121128 0.00961197 0.00934971 0.00820853
+ 0.00699769 0.00607002 0.00535541 0.00476552 0.00427601 0.00376357
+ -0.073012 -0.0866964 -0.0809538 -0.038005 0.0277001 0.0188906
+ 0.00614597 0.00373629 0.00489787 0.0146573 0.0191052 0.0151708
+ 0.0124224 0.0105859 0.00879272 0.00729464 0.0070047 0.00449575
+ -0.00626652 -0.0252417 -0.0147287 0.022538 0.0822905 0.0947372
+ 0.0657516 0.0445506 0.0316753 0.0220971 0.0158101 0.0140971
+ 0.0161498 0.0139876 0.0122447 0.0106994 0.009397 0.00822236
+ 0.00686509 0.00797431 0.00751269 0.00671173 0.00595243 0.00524633
+ 0.00459528 0.00401688 0.00350109 0.00303954 0.00260569 0.00222792
+ 0.00191033 0.00163917 0.00140949 0.00121464 0.0010471 0.000900638
+ 0.000768847 0.000645236 0.000524807 0.000460275 0.000442237
+ 0.000446775 0.000397026 0.000301585 0.000228994 0.000190894
+ 0.000166569 0.000152261 0.000137953 0.000123644 0.000109336
+ 9.50281e-05 8.56557e-05 7.78437e-05 7.00318e-05 6.22198e-05
+ 5.44079e-05 4.87539e-05 4.57761e-05 4.27982e-05 3.98203e-05
+ 3.68425e-05 3.38646e-05 3.08868e-05 2.79089e-05 2.4931e-05
+ 2.19532e-05 1.89753e-05 1.75244e-05 1.64095e-05 1.52946e-05
+ 1.41797e-05 1.30648e-05 1.19499e-05 1.0835e-05 9.72011e-06
+ 8.60521e-06 7.4903e-06 6.5117e-06 6.10334e-06 5.69497e-06
+ 5.2866e-06 4.87824e-06 4.46987e-06 4.06151e-06 3.65314e-06
+ 3.24477e-06
+ EOD
+
+ @v[9].set(<<-'EOD')
+ 1.86175 1.99708 2.07867 2.01211 2.43309 3.27194 3.63896
+ 3.90426 4.11074 4.27932 4.41496 4.52543 4.61491 4.68862
+ 4.7479 4.79666 4.72895 4.68886 4.70354 4.81353 5.01568 5.14184
+ 5.10482 5.07362 5.05143 5.03638 5.02323 5.01465 5.00853
+ 5.00383 4.99985 5.00454 5.00652 5.00546 5.00411 5.003 5.00214
+ 5.00151 5.00106 5.00073 5.0005 5.00034 5.00023 5.00015 5.0001
+ 5.00005 5 5.00001 5.00005 5.00005 5.00003 5 4.99998 4.99996
+ 4.99994 4.99995 4.99997 4.99998 5 5.00001 5.00002 5.00002
+ 5.00003 5.00003 5.00003 5.00003 5.00003 5.00003 5.00002
+ 5.00002 5.00001 5.00001 5.00001 5 5 5 4.99999 4.99999 4.99999
+ 4.99999 4.99999 4.99999 4.99999 4.99999 4.99999 4.99998
+ 4.99998 4.99998 4.99999 4.99999 4.99999 4.99999 5 5 5 5
+ 5.00001 5.00001 5.00001 5.00001 5.00001 5.00001 5.00001
+ 5.00001 5.00001 5.00001 5.00001 5.00001 5.00001 5.00001
+ 5.00001 5.00001 5.00001 5.00001 5.00001 5.00001 5.00001
+ 5.00001 5.00001 5.00001 5.00001 5.17392 4.94828 3.78491
+ 1.52079 0.608874 0.244031 0.127087 0.0552995 0.0361032 0.0169025
+ 0.006364 0.00217624 0.000921391 0.000457305 0.000786754
+ -0.120016 -0.148054 -0.15898 -0.0801463 0.16463 0.174017
+ 0.0799249 0.0318788 0.0129696 0.00483397 0.0025677 0.0042079
+ 0.00350003 0.00178404 -8.72902e-05 -0.00128497 -0.00142213
+ -0.00130018 -0.00106874 -0.000789207 -0.000824335 -0.00104518
+ -0.00136799 -0.004366 -0.0102621 -0.0109254 -0.00649259
+ -0.00194842 0.00029793 0.00148673 0.00221085 0.00228291
+ 0.00185261 0.00139687 0.00148183 0.00562266 0.00844119 0.00754627
+ 0.00657396 0.00591212 0.00539269 0.0049282 0.00448417 0.0040572
+ 0.00363719 0.00320392 0.00279607 0.00243938 0.00211505 0.00182302
+ 0.00156254 0.0013341 0.00113834 0.000971865 0.00082776 0.000706193
+ 0.000602499 0.000515059 0.000441401 0.00037897 0.000325459
+ 0.00028083 0.000242096 0.000207274 0.000176444 0.000150372
+ 0.000126407 0.000103373 9.05522e-05 8.53555e-05 8.63685e-05
+ 9.02593e-05 8.37346e-05 7.72099e-05 7.06852e-05 6.41605e-05
+ 5.76358e-05 5.11112e-05 4.45865e-05 4.08176e-05 3.72497e-05
+ 3.36818e-05 3.01138e-05 2.65459e-05 2.2978e-05 1.94101e-05
+ 1.76154e-05 1.67399e-05 1.58645e-05 1.4989e-05 1.41136e-05
+ 1.32381e-05 1.23626e-05 1.14872e-05 1.06117e-05 9.73629e-06
+ 8.86083e-06 7.98538e-06 7.10993e-06 6.23447e-06 5.44363e-06
+ 5.32578e-06 5.20792e-06 5.09007e-06 4.97222e-06 0.0784323
+ 0.0474527 -0.0764232 -0.151146 0.0615785 0.0144489 0.00974161
+ 0.00947176 0.00849005 0.00728201 0.00630581 0.00554032 0.00487809
+ 0.00441504 0.00384139 -0.118943 -0.149894 -0.161173 -0.0825299
+ 0.171686 0.176912 0.0816085 0.0335236 0.013791 0.0056976
+ 0.00238833 0.00105348 0.000526199 0.00025969 0.000396026
+ 0.000837835 0.00170131 0.00196699 -0.000553314 -0.0061621
+ -0.0111895 -0.0142698 -0.0124608 -0.00795847 -0.00467822
+ -0.0043058 -0.00874449 -0.0118584 -0.00871386 -0.00377892
+ 1.95244e-05 0.00218952 0.00325486 0.00386497 0.00422837
+ 0.00446883 0.00447065 0.00486647 0.00547838 0.00565398 0.00559092
+ 0.00538752 0.00507015 0.00466305 0.00420756 0.00373465 0.00328404
+ 0.00287059 0.00250057 0.00216124 0.00184861 0.00156815 0.00134624
+ 0.00117857 0.00103412 0.0008948 0.000761012 0.000619853
+ 0.000462614 0.000319965 0.000287666 0.000356415 0.000379946
+ 0.000339183 0.00027972 0.000252982 0.000226244 0.000199507
+ 0.000172769 0.000146031 0.000130097 0.000117578 0.000105059
+ 9.25401e-05 8.00213e-05 7.11204e-05 6.67061e-05 6.22918e-05
+ 5.78775e-05 5.34632e-05 4.90489e-05 4.46346e-05 4.02203e-05
+ 3.5806e-05 3.13916e-05 2.69773e-05 2.4827e-05 2.31747e-05
+ 2.15225e-05 1.98702e-05 1.8218e-05 1.65658e-05 1.49135e-05
+ 1.32613e-05 1.1609e-05 9.95678e-06 8.50108e-06 7.86765e-06
+ 7.23422e-06 6.60079e-06 5.96736e-06 5.33393e-06 4.7005e-06
+ 4.06707e-06 3.43363e-06
+ EOD
+
+ @v[10].set(<<-'EOD')
+ 1.86175 1.99308 2.16619 2.46661 3.09359 3.76864 4.31299
+ 4.65564 4.83425 4.92153 4.96157 4.98063 4.98649 4.99039
+ 4.9945 4.9972 4.96206 4.89882 4.83865 4.83202 4.91016 5.04479
+ 5.06078 5.04827 5.03474 5.0246 5.01639 5.00996 5.00569 5.00239
+ 5.00043 5.00296 5.00437 5.00382 5.00287 5.00208 5.00148
+ 5.00104 5.00073 5.0005 5.00034 5.00023 5.00016 5.00011 5.00008
+ 5.00007 5.00007 5.00004 5 4.99998 4.99998 4.99997 4.99998
+ 4.99999 5 5 5.00001 5.00001 5.00001 5.00002 5.00002 5.00001
+ 5.00001 5.00001 5.00001 5 5 5 5 5 5 4.99999 4.99999 4.99999
+ 4.99999 4.99999 4.99999 4.99999 4.99999 4.99999 4.99999
+ 4.99999 4.99999 5 5 5 5 5 5 5 5 5 5.00001 5.00001 5.00001
+ 5.00001 5.00001 5.00001 5.00001 5.00001 5.00001 5.00001
+ 5.00001 5.00001 5.00001 5.00001 5.00001 5.00001 5.00001
+ 5.00001 5.00001 5.00001 5.00001 5 5 5 5 5 5 5 5 5.10081
+ 5.10949 4.98359 5.00733 5.15145 4.37298 2.36126 0.470759
+ 0.0577238 0.0115884 0.00262611 0.000671499 0.000389038 0.000291291
+ 0.000317347 -0.0167823 -0.0158344 -0.0140559 0.0104849 0.0865874
+ 0.107813 0.0524688 0.0214369 0.00876443 0.00341595 0.00170778
+ 0.00259042 0.0022241 0.00118519 1.10217e-06 -0.000784506
+ -0.000948169 -0.000856256 -0.000696719 -0.000485987 -0.000724787
+ -0.000981491 -0.001454 -0.00552498 -0.0114992 -0.0105266
+ -0.00543527 -0.000982798 0.00127356 0.00224212 0.00275439
+ 0.00281098 0.0025471 0.00230368 0.00222576 0.00485522 0.00729453
+ 0.00691796 0.0062615 0.00573987 0.0052688 0.00481185 0.00436934
+ 0.00394326 0.00352712 0.00309978 0.00270038 0.00235335 0.00203742
+ 0.00175256 0.00150067 0.00128126 0.00109323 0.000933619
+ 0.000795113 0.000678182 0.00057843 0.000494345 0.000423609
+ 0.000363821 0.000312766 0.000269856 0.000232389 0.000198382
+ 0.000168126 0.00014267 0.000119293 9.69034e-05 8.5669e-05
+ 8.26828e-05 8.64066e-05 9.26665e-05 8.5454e-05 7.82416e-05
+ 7.10291e-05 6.38167e-05 5.66043e-05 4.93918e-05 4.21794e-05
+ 3.86073e-05 3.53007e-05 3.19941e-05 2.86876e-05 2.5381e-05
+ 2.20744e-05 1.87678e-05 1.70933e-05 1.62648e-05 1.54363e-05
+ 1.46079e-05 1.37794e-05 1.2951e-05 1.21225e-05 1.12941e-05
+ 1.04656e-05 9.63716e-06 8.80871e-06 7.98026e-06 7.1518e-06
+ 6.32335e-06 5.5374e-06 5.08959e-06 4.64178e-06 4.19397e-06
+ 3.74616e-06 0.0438026 0.0242078 -0.0602019 -0.0840866 0.00148461
+ -0.00292489 0.000442098 0.00219489 0.00281478 0.00290756
+ 0.00277945 0.00263896 0.00240099 0.00223283 0.001947 -0.0153629
+ -0.0148815 -0.0128673 0.0126017 0.0905161 0.11051 0.0538958
+ 0.022562 0.00935726 0.00397422 0.00172534 0.000790207 0.000416322
+ 0.000191632 0.000469721 0.0009779 0.00192566 0.00200688
+ -0.0016502 -0.00733932 -0.0128113 -0.0147608 -0.0115456
+ -0.00668995 -0.00401368 -0.00463908 -0.0101197 -0.0118993
+ -0.0076276 -0.00262656 0.000813059 0.00264455 0.00350796
+ 0.00399494 0.0043049 0.00451658 0.00444739 0.00503842 0.00559516
+ 0.00568213 0.00556459 0.0053176 0.00496654 0.00454337 0.00408592
+ 0.00362171 0.00317793 0.00277001 0.00240394 0.00207009 0.00176575
+ 0.00149725 0.00129045 0.00114257 0.00101135 0.000871672
+ 0.000723764 0.000580438 0.000427507 0.000296956 0.000281834
+ 0.000376628 0.000412266 0.000367547 0.000295305 0.000264513
+ 0.000233721 0.000202929 0.000172137 0.000141345 0.000124721
+ 0.000112577 0.000100433 8.82893e-05 7.61453e-05 6.75517e-05
+ 6.33609e-05 5.91701e-05 5.49792e-05 5.07884e-05 4.65976e-05
+ 4.24067e-05 3.82159e-05 3.40251e-05 2.98342e-05 2.56434e-05
+ 2.36401e-05 2.21181e-05 2.05961e-05 1.90741e-05 1.75521e-05
+ 1.60301e-05 1.45081e-05 1.29861e-05 1.14641e-05 9.94208e-06
+ 8.59252e-06 7.96439e-06 7.33626e-06 6.70813e-06 6.07999e-06
+ 5.45186e-06 4.82373e-06 4.1956e-06 3.56747e-06
+ EOD
+
+ @v[11].set(<<-'EOD')
+ 1.86175 1.73419 1.42874 1.04055 0.943004 0.268275 0.0826455
+ 0.0388346 0.0214104 0.0135431 0.00961322 0.00712846 0.00588262
+ 0.00432397 0.00377774 0.00270134 -0.00393731 -0.00542187
+ -0.00126596 0.0113777 0.0134522 0.00477056 -0.00211067 -0.00229253
+ -0.00173355 -0.00122404 -0.00113426 -0.000744931 -0.000520112
+ -0.000410048 -0.000220439 0.000508104 5.15856e-05 -0.000112593
+ -0.000118917 -9.57394e-05 -7.15727e-05 -5.11847e-05 -3.58275e-05
+ -2.47166e-05 -1.68866e-05 -1.14082e-05 -7.66646e-06 -5.12139e-06
+ -3.63426e-06 -3.01815e-06 -2.64862e-06 -1.4947e-06 -1.91403e-07
+ -2.5763e-08 -7.73699e-07 -1.52164e-06 -1.07268e-06 -3.81696e-07
+ 2.6727e-07 4.75489e-07 6.83708e-07 8.91926e-07 1.10014e-06
+ 1.30836e-06 1.2482e-06 1.00726e-06 7.66311e-07 5.25364e-07
+ 2.84417e-07 6.27857e-08 7.43904e-10 -6.12979e-08 -1.2334e-07
+ -1.85382e-07 -2.47423e-07 -3.09465e-07 -3.71507e-07 -4.33549e-07
+ -4.95591e-07 -5.57633e-07 -6.04571e-07 -5.4944e-07 -4.9431e-07
+ -4.3918e-07 -3.84049e-07 -3.28919e-07 -2.73789e-07 -2.18659e-07
+ -1.63528e-07 -1.08398e-07 -5.32678e-08 1.062e-09 5.08502e-08
+ 1.00638e-07 1.50427e-07 2.00215e-07 2.50003e-07 2.99791e-07
+ 3.4958e-07 3.99368e-07 4.49156e-07 4.98944e-07 5.34512e-07
+ 5.01032e-07 4.67553e-07 4.34073e-07 4.00593e-07 3.67113e-07
+ 3.33633e-07 3.00153e-07 2.66674e-07 2.33194e-07 1.99714e-07
+ 1.66234e-07 1.32754e-07 9.92744e-08 6.57945e-08 3.23147e-08
+ -1.16513e-09 -3.4645e-08 -6.81248e-08 -1.01605e-07 -1.35084e-07
+ -1.68564e-07 -2.18729e-07 0.0114926 -0.0245378 -0.111828
+ 0.0964775 1.61491 3.22668 4.22041 4.54492 4.82845 4.94868
+ 4.98588 4.99609 4.9981 4.99908 4.99788 4.98395 4.99294 4.99724
+ 5.01939 5.0471 5.00902 4.98194 4.98496 4.99188 4.99623 4.99862
+ 5.00025 4.99974 4.99953 4.99946 4.99958 5.00012 4.99997
+ 4.99992 4.99988 4.99985 4.9998 4.9997 4.9988 4.99806 4.99982
+ 5.00143 5.00159 5.00098 5.00053 5.00028 5.00007 4.99977
+ 4.99992 5.00005 5.00133 5.0009 4.99993 4.99972 4.99975 4.9998
+ 4.99982 4.99983 4.99983 4.99983 4.99983 4.99984 4.99986
+ 4.99987 4.99989 4.9999 4.99991 4.99992 4.99994 4.99995 4.99995
+ 4.99996 4.99997 4.99997 4.99998 4.99998 4.99998 4.99998
+ 4.99999 4.99999 4.99999 4.99999 4.99999 4.99999 4.99999
+ 5 5 5 5.00001 5.00001 5.00001 5.00002 5.00002 5.00002 5.00002
+ 5.00002 5.00001 5.00001 5.00001 5 5 5 5 5 5 5 5 4.99999
+ 4.99999 4.99999 4.99999 4.99999 4.99999 4.99999 4.99999
+ 4.99999 4.99999 4.99999 5 5 5.01457 4.99482 4.96561 4.99326
+ 5.03452 5.00424 5.00101 5.00045 5.00004 4.99965 4.99997
+ 4.99994 4.99958 4.99999 4.99936 4.9839 4.99248 4.99717 5.01976
+ 5.04869 5.0087 4.98143 4.98488 4.99199 4.99622 4.9983 4.99928
+ 4.99971 4.99986 5.00031 5.00022 5.00035 5.0001 4.99884 4.99811
+ 4.99803 4.99887 5.00078 5.00151 5.00116 5.00007 4.99843
+ 4.99915 5.00107 5.00168 5.00141 5.00092 5.00055 5.0003 5.00016
+ 5.0001 5.00001 5.00016 5.0002 5.00009 4.99993 4.99975 4.99984
+ 4.99991 4.99991 4.99982 4.99974 4.99974 4.99985 4.99995
+ 4.99999 4.99998 5.00004 5.00013 5.00015 5.00007 4.99988
+ 4.99982 4.99985 4.99995 5.00006 5.0002 5.00025 5.0002 5.00009
+ 5.00006 5.00004 5.00002 5 4.99998 4.99997 4.99998 4.99998
+ 4.99999 4.99999 4.99999 5 5 5 5 5 5.00001 5.00001 5.00001
+ 5.00001 5.00001 5.00001 5.00001 5.00001 5.00001 5.00001
+ 5.00001 5.00001 5 5 5 5 5 4.99999 4.99999 4.99999 4.99999
+ 4.99998 4.99998 4.99998
+ EOD
+
+ @v[12].set(<<-'EOD')
+ 5 5.16975 4.78685 2.94241 0.126698 0.0487004 -0.00422591
+ -0.00130689 -0.000486756 -0.000195875 -0.000108988 -6.66736e-05
+ -7.26005e-05 -5.63608e-05 -3.81859e-05 -2.123e-05 -0.0646846
+ -0.0184474 0.182248 1.06731 3.10988 4.46133 4.84133 4.95113
+ 4.98364 4.99455 4.99694 4.99727 4.9994 4.99975 5.0001 5.00132
+ 5.00089 5.00039 5.00019 5.00011 5.00006 5.00005 5.00004
+ 5.00001 4.99992 4.99992 5.00002 5.00013 5.00017 5.00009
+ 4.99992 4.99991 4.99994 4.99996 4.99998 4.99999 5.00001
+ 5.00004 5.00006 5.00005 5.00004 5.00003 5.00002 5.00001
+ 5 4.99999 4.99999 4.99998 4.99998 4.99997 4.99997 4.99998
+ 4.99998 4.99998 4.99998 4.99999 4.99999 4.99999 4.99999
+ 5 5 5 5 5 5 5.00001 5.00001 5.00001 5.00001 5.00001 5.00001
+ 5.00002 5.00001 5.00001 5.00001 5.00001 5.00001 5.00001
+ 5.00001 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 4.99999 4.99999
+ 4.99999 4.99999 4.99999 4.99999 4.99999 5 5.14699 4.78074
+ 3.19424 0.305663 0.0611255 -0.00179951 -0.0012032 0.000405978
+ 0.000989399 0.000445194 0.000191447 8.30476e-05 3.96236e-05
+ 1.91866e-05 1.70665e-05 -0.0655239 -0.0210234 0.1827 1.06848
+ 3.11554 4.46518 4.84212 4.94853 4.98244 4.99434 4.9997 5.00081
+ 5.00009 4.99972 4.99985 4.99974 4.9995 4.99949 4.99958 4.99973
+ 4.99948 4.99914 4.99874 4.99946 5.00309 5.0091 5.01576 5.01835
+ 5.01852 5.0176 5.01625 5.01479 5.01345 5.01264 5.011 5.01092
+ 5.01344 5.01363 5.01289 5.01184 5.01071 5.00956 5.00848
+ 5.00751 5.00663 5.00577 5.00497 5.00427 5.00365 5.0031 5.00264
+ 5.00224 5.00191 5.00163 5.00138 5.00117 5.00099 5.00083
+ 5.00071 5.00061 5.00053 5.00045 5.00037 5.00029 5.00022
+ 5.00019 5.0002 5.00023 5.00024 5.00023 5.00023 5.00022 5.0002
+ 5.00018 5.00016 5.00014 5.00011 5.00009 5.00007 5.00006
+ 5.00005 5.00005 5.00004 5.00003 5.00002 5.00001 5.00001
+ 5.00001 5.00001 5.00001 5.00001 5.00001 5.00001 5.00001
+ 5.00002 5.00002 5.00002 5.00002 5.00002 5.00002 5.00002
+ 5.00002 5.00001 5.00001 5.00001 5.14298 4.79809 3.32704
+ 0.498385 0.105773 0.0160646 0.0319912 0.0299434 0.0240102
+ 0.0185844 0.0130411 0.0106532 0.00864871 0.00744519 0.00660887
+ -0.0612913 -0.0203719 0.174998 0.991787 3.06292 4.60005
+ 4.93058 4.98917 5.00033 4.9999 4.99909 4.9966 4.9955 4.99488
+ 4.99374 4.9943 5.00131 5.00506 4.99311 4.96288 4.93567 4.92439
+ 4.94236 4.9732 4.98864 4.99458 5.00031 5.00694 5.01525 5.01945
+ 5.01998 5.01953 5.01874 5.01766 5.0164 5.01509 5.01326 5.01423
+ 5.01455 5.01361 5.01245 5.01122 5.01002 5.00888 5.00783
+ 5.00687 5.00596 5.00514 5.00442 5.00379 5.00325 5.00279
+ 5.0024 5.00208 5.0018 5.00153 5.00126 5.00107 5.00094 5.00085
+ 5.00078 5.00072 5.00063 5.00053 5.00042 5.00038 5.00034
+ 5.0003 5.00027 5.00023 5.00021 5.00019 5.00017 5.00015 5.00013
+ 5.00012 5.00011 5.0001 5.0001 5.00009 5.00008 5.00007 5.00007
+ 5.00006 5.00005 5.00005 5.00004 5.00004 5.00003 5.00003
+ 5.00002 5.00002 5.00002 5.00001 5.00001 5 5 5 5.00001 5.00001
+ 5.00001 5.00002 5.00002 5.00002 5.00002
+ EOD
+
+ @v[13].set(<<-'EOD')
+ 9.73784e-10 0.0189926 0.0926769 0.206309 0.111533 0.0953491
+ 0.0426966 0.0214177 0.0117943 0.00741442 0.00528816 0.00398417
+ 0.0032967 0.00266499 0.00206647 0.00158788 -0.0371391 -0.0439528
+ -0.0408653 -0.0188706 0.0150241 0.0126852 0.00209817 -0.000239206
+ -5.31488e-05 0.000876324 -0.00451221 -0.0165223 -0.0284127
+ -0.0427584 -0.0502453 -0.0257366 -0.00903938 -0.00376456
+ -0.00233385 -0.00169922 -0.00130397 -0.00102542 -0.000811435
+ -0.000648115 -0.000529266 -0.00043795 -0.00036574 -0.00030716
+ -0.00026221 -0.000229662 -0.000205112 -0.000181038 -0.000162045
+ -0.000148988 -0.000137633 -0.000126278 -0.000115562 -0.000104976
+ -9.49324e-05 -9.0585e-05 -8.62375e-05 -8.18901e-05 -7.75426e-05
+ -7.31952e-05 -6.93752e-05 -6.59106e-05 -6.24461e-05 -5.89815e-05
+ -5.55169e-05 -5.22412e-05 -5.05263e-05 -4.88114e-05 -4.70966e-05
+ -4.53817e-05 -4.36668e-05 -4.19519e-05 -4.0237e-05 -3.85222e-05
+ -3.68073e-05 -3.50924e-05 -3.34782e-05 -3.25442e-05 -3.16102e-05
+ -3.06763e-05 -2.97423e-05 -2.88083e-05 -2.78744e-05 -2.69404e-05
+ -2.60064e-05 -2.50725e-05 -2.41385e-05 -2.32635e-05 -2.27232e-05
+ -2.21829e-05 -2.16426e-05 -2.11023e-05 -2.0562e-05 -2.00217e-05
+ -1.94814e-05 -1.89411e-05 -1.84007e-05 -1.78604e-05 -1.73647e-05
+ -1.70853e-05 -1.68059e-05 -1.65265e-05 -1.62471e-05 -1.59677e-05
+ -1.56883e-05 -1.54089e-05 -1.51295e-05 -1.48501e-05 -1.45707e-05
+ -1.42913e-05 -1.40119e-05 -1.37325e-05 -1.34531e-05 -1.31737e-05
+ -1.28943e-05 -1.26149e-05 -1.23355e-05 -1.20561e-05 -1.17767e-05
+ -1.14973e-05 -1.10954e-05 0.0152675 0.0228237 -0.00460678
+ -0.0341525 0.0232109 -0.0138039 -0.0416538 -0.0458764 -0.0201967
+ -0.00878316 -0.00379173 -0.00164621 -0.000785131 -0.00037575
+ -0.000352375 -0.0545586 -0.0746881 -0.0771865 -0.05386 -0.0022199
+ 0.0136703 0.00633526 0.00138826 -0.00108934 0.0038886 0.0298077
+ 0.0475776 0.0481003 0.0464167 0.047818 0.042789 0.035207
+ 0.0264423 0.0193959 0.0151614 0.00624257 -0.00913057 -0.0310696
+ -0.0430238 0.016426 0.189762 0.49025 0.820116 1.13919 1.43549
+ 1.70658 1.95183 2.17414 2.38506 2.5657 2.73958 2.97905 3.21403
+ 3.43025 3.62645 3.8028 3.96002 4.09996 4.22443 4.33427 4.42886
+ 4.51097 4.5817 4.64326 4.6957 4.74132 4.7797 4.81298 4.84102
+ 4.86512 4.88523 4.90224 4.91649 4.92846 4.93868 4.94755
+ 4.95483 4.96114 4.96682 4.97161 4.97502 4.9776 4.97944 4.98141
+ 4.98319 4.98467 4.98585 4.9869 4.98796 4.98902 4.99008 4.99114
+ 4.9922 4.99326 4.9938 4.99429 4.99479 4.99528 4.99578 4.99628
+ 4.99677 4.99704 4.99718 4.99733 4.99747 4.99762 4.99777
+ 4.99791 4.99806 4.9982 4.99835 4.9985 4.99864 4.99879 4.99893
+ 4.99907 4.99916 4.99925 4.99934 4.99943 5.01473 4.92293
+ 4.61974 4.0316 3.7835 3.74195 3.78344 3.87272 3.97386 4.07319
+ 4.16686 4.25256 4.33126 4.40264 4.46697 4.49249 4.51807
+ 4.55803 4.64055 4.78574 4.86074 4.88334 4.8999 4.91455 4.92814
+ 4.93926 4.94761 4.95433 4.95907 4.9654 4.98317 5.0208 5.05134
+ 4.85852 4.16041 3.00077 1.68376 0.672707 0.240838 0.0794725
+ -0.0106347 -0.00879443 0.107196 0.368163 0.701424 1.03581
+ 1.3601 1.6678 1.95731 2.22701 2.47544 2.69099 2.92327 3.16648
+ 3.3877 3.59067 3.77344 3.93584 4.08066 4.20863 4.32065 4.41791
+ 4.50211 4.57423 4.63614 4.68888 4.73377 4.7721 4.80519 4.83338
+ 4.85732 4.87815 4.89514 4.90927 4.92108 4.93122 4.94014
+ 4.94845 4.95601 4.96251 4.96576 4.969 4.97225 4.9755 4.97874
+ 4.98087 4.98265 4.98442 4.9862 4.98797 4.98924 4.9899 4.99055
+ 4.9912 4.99186 4.99251 4.99316 4.99381 4.99447 4.99512 4.99577
+ 4.99609 4.99634 4.99659 4.99683 4.99708 4.99732 4.99757
+ 4.99782 4.99806 4.99831 4.99853 4.99863 4.99873 4.99883
+ 4.99893 4.99903 4.99913 4.99923 4.99933
+ EOD
+
+ @v[14].set(<<-'EOD')
+ 1.86175 2.00147 1.85141 1.0654 0.275481 0.205547 0.0712627
+ 0.0313387 0.0151431 0.00864531 0.00593861 0.00438111 0.0037479
+ 0.00305857 0.00221221 0.0017081 -0.0896128 -0.109079 -0.121356
+ -0.0542001 0.175821 0.177442 0.0814591 0.0333042 0.0134909
+ 0.00625777 0.00100092 -0.00552776 -0.00411139 -0.00150395
+ -0.000564784 3.48169e-05 -0.000287014 -0.000538515 -0.000456537
+ -0.000325677 -0.000275468 -0.000166452 -8.27481e-05 -8.28704e-05
+ -7.47644e-05 -4.60552e-05 -2.61481e-06 2.26359e-05 2.53852e-05
+ -1.39853e-06 -4.23456e-05 -4.0907e-05 -2.8501e-05 -1.5945e-05
+ -9.01122e-06 -2.07747e-06 1.49328e-06 4.38398e-06 6.84248e-06
+ 4.76711e-06 2.69173e-06 6.16362e-07 -1.45901e-06 -3.53438e-06
+ -4.14256e-06 -3.76238e-06 -3.3822e-06 -3.00202e-06 -2.62184e-06
+ -2.24878e-06 -1.93456e-06 -1.62033e-06 -1.3061e-06 -9.91867e-07
+ -6.77638e-07 -3.63409e-07 -4.91792e-08 2.6505e-07 5.7928e-07
+ 8.93509e-07 1.16076e-06 1.11055e-06 1.06034e-06 1.01014e-06
+ 9.59927e-07 9.09719e-07 8.59511e-07 8.09302e-07 7.59094e-07
+ 7.08886e-07 6.58678e-07 5.99251e-07 4.87523e-07 3.75795e-07
+ 2.64068e-07 1.5234e-07 4.06119e-08 -7.1116e-08 -1.82844e-07
+ -2.94572e-07 -4.063e-07 -5.18027e-07 -6.08517e-07 -5.95879e-07
+ -5.83241e-07 -5.70604e-07 -5.57966e-07 -5.45328e-07 -5.3269e-07
+ -5.20053e-07 -5.07415e-07 -4.94777e-07 -4.8214e-07 -4.69502e-07
+ -4.56864e-07 -4.44226e-07 -4.31589e-07 -4.18951e-07 -4.06313e-07
+ -3.93676e-07 -3.81038e-07 -3.684e-07 -3.55762e-07 -3.43125e-07
+ 1.06736e-05 0.0797407 0.0437947 -0.0645098 -0.0877312 0.0653203
+ -0.00621184 -0.0353188 -0.0491378 -0.0251957 -0.0110996
+ -0.00481123 -0.0020941 -0.000998038 -0.000478747 -0.000445332
+ -0.102046 -0.135753 -0.154351 -0.0827509 0.163348 0.174012
+ 0.0794822 0.0310624 0.0112213 0.00249061 0.00130764 0.00181315
+ 0.00163875 0.00101454 0.000497435 0.000195258 5.31901e-05
+ 2.4607e-05 6.62736e-05 7.90718e-05 4.0372e-05 -0.000141184
+ -0.000280623 5.5608e-05 0.000799565 0.000920189 0.000931616
+ 0.000494527 0.000162303 -8.24884e-05 -0.000183938 -0.000203899
+ -0.000144788 -9.87063e-05 -0.000227929 2.93932e-05 0.000208563
+ 1.88958e-06 -7.6335e-05 -0.000172472 -0.000165656 -0.000145889
+ -0.000177311 -0.000191058 -0.000168287 -0.00015755 -0.00013142
+ -8.10488e-05 -6.36115e-05 -7.8699e-05 -8.11282e-05 -7.98625e-05
+ -5.98807e-05 -3.40879e-05 -1.95464e-05 -1.79247e-05 -4.45514e-05
+ -7.47995e-05 -8.7682e-05 -7.50806e-05 -3.25561e-05 -4.34114e-05
+ -7.69099e-05 -0.000141101 -0.00018743 -0.000148471 -5.06546e-05
+ 0.000120195 0.000177635 0.000177052 0.000146344 9.75126e-05
+ 8.31233e-05 6.8734e-05 5.43447e-05 3.99554e-05 2.55661e-05
+ 1.11768e-05 -3.21253e-06 -3.88937e-06 -3.56628e-06 -3.24318e-06
+ -2.92008e-06 -2.59699e-06 -2.27389e-06 -1.9508e-06 -1.73227e-06
+ -1.56796e-06 -1.40365e-06 -1.23934e-06 -1.07503e-06 -9.10722e-07
+ -7.46412e-07 -5.82101e-07 -4.1779e-07 -2.5348e-07 -8.91694e-08
+ 7.51412e-08 2.39452e-07 4.03762e-07 5.95733e-07 1.00771e-06
+ 1.41969e-06 1.83167e-06 2.24365e-06 0.0828257 0.231038 0.465438
+ 1.54516 2.8461 3.19221 3.40395 3.6382 3.80758 3.93848 4.04882
+ 4.15428 4.247 4.32917 4.40235 4.36941 4.397 4.48862 4.64552
+ 4.86595 5.03475 5.0348 5.02627 5.01967 5.01542 5.00925 4.98613
+ 4.9519 4.91581 4.87357 4.82302 4.80403 4.82565 4.86102 4.89483
+ 4.92253 4.94428 4.96257 4.97608 4.98373 4.98823 4.99182
+ 4.99437 4.99635 4.99745 4.99802 4.99843 4.99873 4.99895
+ 4.99912 4.99925 4.99931 4.99962 4.99973 4.99972 4.99971
+ 4.9997 4.99969 4.9997 4.99971 4.99973 4.99974 4.99976 4.99978
+ 4.9998 4.99982 4.99985 4.99987 4.99989 4.9999 4.99991 4.99991
+ 4.99993 4.99994 4.99997 5.00001 5.00006 5.00008 5.00006
+ 5.00002 5 4.99999 4.99998 4.99997 4.99995 4.99995 4.99995
+ 4.99995 4.99995 4.99995 4.99995 4.99996 4.99997 4.99997
+ 4.99998 4.99999 5 5 5.00001 5.00002 5.00002 5.00002 5.00002
+ 5.00002 5.00002 5.00002 5.00002 5.00002 5.00002 5.00001
+ 5.00001 5.00001 5.00001 5.00001 5 5 5 4.99999 4.99999 4.99999
+ EOD
+
+ @v[15].set(<<-'EOD')
+ 1.86175 2.00199 2.08919 1.84314 1.08254 0.214737 0.0377351
+ 0.00952455 0.00232763 0.000563614 0.000263477 0.000148642
+ 0.000285086 0.000242592 7.34699e-05 -1.53467e-05 -0.0161874
+ -0.0157876 -0.0141194 0.0132576 0.0903272 0.109938 0.0535295
+ 0.0224216 0.00940945 0.00466825 -0.000649972 -0.00654752
+ -0.00333248 -0.00103671 -0.000508276 -5.8896e-05 -0.00043938
+ -0.000544704 -0.00044444 -0.000307093 -0.00024517 -0.000154538
+ -8.78602e-05 -7.10461e-05 -6.06485e-05 -3.91039e-05 -8.45988e-06
+ 9.43442e-06 1.28351e-05 -2.16734e-06 -2.6142e-05 -2.54768e-05
+ -1.88997e-05 -1.17906e-05 -7.3808e-06 -2.97101e-06 1.19146e-07
+ 2.94246e-06 5.38942e-06 3.88851e-06 2.38761e-06 8.86704e-07
+ -6.14201e-07 -2.11511e-06 -2.59565e-06 -2.38885e-06 -2.18205e-06
+ -1.97525e-06 -1.76845e-06 -1.56241e-06 -1.36258e-06 -1.16276e-06
+ -9.62939e-07 -7.63116e-07 -5.63293e-07 -3.6347e-07 -1.63647e-07
+ 3.61756e-08 2.35999e-07 4.35822e-07 6.07653e-07 5.90323e-07
+ 5.72994e-07 5.55665e-07 5.38336e-07 5.21007e-07 5.03678e-07
+ 4.86349e-07 4.6902e-07 4.51691e-07 4.34361e-07 4.11899e-07
+ 3.60315e-07 3.08731e-07 2.57146e-07 2.05562e-07 1.53977e-07
+ 1.02393e-07 5.08082e-08 -7.76222e-10 -5.23607e-08 -1.03945e-07
+ -1.47815e-07 -1.54225e-07 -1.60635e-07 -1.67045e-07 -1.73455e-07
+ -1.79864e-07 -1.86274e-07 -1.92684e-07 -1.99094e-07 -2.05504e-07
+ -2.11914e-07 -2.18324e-07 -2.24734e-07 -2.31144e-07 -2.37554e-07
+ -2.43964e-07 -2.50373e-07 -2.56783e-07 -2.63193e-07 -2.69603e-07
+ -2.76013e-07 -2.82423e-07 2.92534e-06 0.0446777 0.024278
+ -0.0518987 -0.0636547 0.00983929 -0.000518204 -0.000265194
+ 0.000154772 0.000299538 3.12715e-05 -3.18225e-05 -2.48268e-05
+ -1.16701e-05 -6.05117e-06 7.61116e-06 -0.0163668 -0.0158244
+ -0.0141177 0.0100085 0.0857144 0.107784 0.051862 0.0204448
+ 0.00629858 0.000967736 0.00121674 0.00190276 0.00154009
+ 0.000860922 0.000410386 0.000164585 3.99493e-05 1.93797e-05
+ 5.67594e-05 0.000110126 2.49925e-05 -7.17815e-05 -0.000142299
+ -1.63109e-05 0.000439529 0.000562489 0.000594599 0.000326164
+ 0.000126423 -4.26063e-05 -0.000122927 -0.000114152 -6.72706e-05
+ -6.41242e-05 -0.000135588 2.61507e-05 0.000134036 6.43734e-06
+ -4.6223e-05 -0.000112047 -0.000101388 -8.67847e-05 -0.000117664
+ -0.000133957 -0.000116558 -0.000100873 -7.65448e-05 -4.44964e-05
+ -3.6677e-05 -5.26632e-05 -5.45172e-05 -5.13545e-05 -3.73869e-05
+ -1.99732e-05 -1.0907e-05 -1.10081e-05 -3.02609e-05 -5.18517e-05
+ -6.13597e-05 -5.30706e-05 -2.39572e-05 -3.24146e-05 -5.70062e-05
+ -0.000103448 -0.000135376 -0.0001024 -2.39007e-05 0.000110929
+ 0.000151226 0.000142044 0.000105922 5.62834e-05 4.78476e-05
+ 3.94117e-05 3.09759e-05 2.25401e-05 1.41042e-05 5.66837e-06
+ -2.76747e-06 -3.08639e-06 -2.81341e-06 -2.54043e-06 -2.26745e-06
+ -1.99447e-06 -1.72149e-06 -1.44851e-06 -1.26226e-06 -1.12096e-06
+ -9.79661e-07 -8.38363e-07 -6.97065e-07 -5.55768e-07 -4.1447e-07
+ -2.73173e-07 -1.31875e-07 9.42259e-09 1.5072e-07 2.92018e-07
+ 4.33315e-07 5.74613e-07 7.10363e-07 8.01984e-07 8.93604e-07
+ 9.85225e-07 1.07685e-06 0.04474 0.0928765 0.141327 0.0176048
+ -0.071675 -0.0124613 0.989022 2.28104 3.40619 4.21417 4.67173
+ 4.87438 4.96044 4.98996 4.99858 4.96672 4.89502 4.79391
+ 4.76433 4.8387 4.98612 5.0161 5.01722 5.01437 5.01256 4.99827
+ 4.95807 4.9209 4.88217 4.83006 4.78461 4.80759 4.85548 4.89604
+ 4.9254 4.94617 4.96126 4.97374 4.98255 4.98792 4.99126 4.99361
+ 4.99554 4.99699 4.99792 4.99846 4.99881 4.99905 4.99924
+ 4.99938 4.99949 4.99955 4.9997 4.9998 4.99982 4.99982 4.99982
+ 4.99982 4.99982 4.99983 4.99984 4.99985 4.99986 4.99987
+ 4.99988 4.99989 4.9999 4.99992 4.99993 4.99994 4.99995 4.99995
+ 4.99996 4.99996 4.99998 4.99999 5.00001 5.00002 5.00002
+ 5.00001 5.00001 5 4.99999 4.99999 4.99998 4.99998 4.99998
+ 4.99998 4.99998 4.99998 4.99998 4.99998 4.99998 4.99998
+ 4.99999 4.99999 4.99999 4.99999 5 5 5 5 5 5 5.00001 5.00001
+ 5.00001 5.00001 5.00001 5.00001 5.00001 5.00001 5.00001
+ 5.00001 5.00001 5.00001 5.00001 5.00001 5.00001 5.00001
+ EOD
+
+ @v[16].set(<<-'EOD')
+ 1.86175 1.73073 1.50572 1.89001 3.39004 4.36034 4.79012
+ 4.93798 4.98305 4.99539 4.9979 4.99904 4.99772 4.9983 4.99935
+ 4.99975 4.98837 4.99456 4.99728 5.01838 5.04568 5.00759
+ 4.98112 4.98479 4.99197 4.99641 4.99747 4.99775 5.00043
+ 5.0007 5.00035 5.00023 4.99976 5.00002 5.00007 5.0002 4.99993
+ 5.00003 5.00021 5.00006 4.99993 4.99992 5.00002 5.00013
+ 5.00017 5.00009 4.99992 4.99991 4.99993 4.99996 4.99998
+ 4.99999 5.00001 5.00003 5.00005 5.00004 5.00004 5.00003
+ 5.00002 5.00001 5 4.99999 4.99999 4.99998 4.99998 4.99997
+ 4.99997 4.99998 4.99998 4.99998 4.99998 4.99999 4.99999
+ 4.99999 4.99999 5 5 5 5 5 5 5.00001 5.00001 5.00001 5.00001
+ 5.00001 5.00001 5.00002 5.00001 5.00001 5.00001 5.00001
+ 5.00001 5.00001 5.00001 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5
+ 5 4.99999 4.99999 4.99999 4.99999 4.99999 4.99999 4.99999
+ 4.99999 5 5.01498 4.99342 4.96899 5.00301 5.02627 4.9977
+ 4.99548 4.99757 5.00277 5.00245 5.0014 5.00069 5.00032 5.00014
+ 5.00009 4.9867 4.99262 4.99607 5.01805 5.04713 5.00927 4.98184
+ 4.98483 4.9914 4.99616 4.99902 4.9999 4.99987 4.99979 4.99981
+ 4.99989 4.99994 4.99998 5.0002 5.00001 5.00008 5.00008 5.0001
+ 5.00021 5.00032 5.00025 5.00019 5.00006 5.00007 4.99994
+ 4.99997 4.99999 5.00023 5.00008 4.99993 4.99998 4.99986
+ 4.99982 5.00003 4.99985 4.99996 5.00014 5 4.99984 4.99979
+ 4.99982 4.99993 5.00008 5.00011 5.00002 4.99996 4.9999 4.99994
+ 5.00001 5.00007 5.00009 4.99995 4.99978 4.99971 4.99976
+ 4.99997 4.99996 4.99989 4.99972 4.99955 4.99953 4.99959
+ 4.99976 4.9999 5.00005 5.00023 5.00039 5.00034 5.00029 5.00024
+ 5.00019 5.00014 5.00009 5.00004 5.00003 5.00002 5.00001
+ 5 5 4.99999 4.99998 4.99998 4.99998 4.99998 4.99998 4.99999
+ 4.99999 4.99999 4.99999 4.99999 4.99999 4.99999 5 5 5 5
+ 5.00001 5.00002 5.00003 5.00004 5.01564 5.03395 5.04932
+ 5.11868 3.92502 1.31888 0.163888 0.0946876 0.0789578 0.0565084
+ 0.0260333 0.0156986 0.00907667 0.00613629 0.00468417 -0.00174008
+ -0.0021422 0.000586962 0.0124937 0.0147977 0.00838454 0.00039383
+ -0.000522021 -0.000426598 -0.000290214 -0.00173713 -0.00384132
+ -0.00382945 -0.00429219 -0.00580193 -0.00393246 0.0017543
+ 0.00423045 0.00408931 0.0031976 0.00245457 0.00187293 0.00159068
+ 0.00105697 0.000609902 0.000358825 0.000334125 0.000212708
+ 0.000168116 8.97349e-05 5.21578e-05 3.84527e-05 2.93033e-05
+ 2.10067e-05 1.59954e-05 1.13917e-05 5.49738e-06 2.77217e-05
+ 6.51259e-06 -6.65468e-06 2.09837e-06 -6.617e-06 -4.80187e-06
+ 1.55031e-06 4.26536e-06 7.69457e-07 -1.46213e-06 -7.25202e-07
+ 3.26501e-06 6.55807e-06 7.524e-06 6.07209e-06 6.00701e-06
+ 5.41166e-06 3.86573e-06 1.10651e-06 -2.74603e-06 -2.18566e-06
+ 2.3658e-06 8.59956e-06 8.35046e-06 2.90621e-06 -8.75982e-07
+ -1.87189e-06 -2.1528e-06 -1.94875e-06 -1.74471e-06 -1.54067e-06
+ -1.33662e-06 -1.13258e-06 -8.40567e-07 -5.20743e-07 -2.00918e-07
+ 1.18906e-07 4.38731e-07 6.11382e-07 6.01529e-07 5.91675e-07
+ 5.81822e-07 5.71968e-07 5.62115e-07 5.52261e-07 5.42407e-07
+ 5.32554e-07 5.227e-07 5.12847e-07 4.72812e-07 4.26137e-07
+ 3.79462e-07 3.32786e-07 2.86111e-07 2.39436e-07 1.92761e-07
+ 1.46086e-07 9.94107e-08 5.27356e-08 -2.77779e-10 -7.98079e-08
+ -1.59338e-07 -2.38868e-07 -3.18398e-07 -3.97928e-07 -4.77458e-07
+ -5.56988e-07 -6.36519e-07
+ EOD
+
+ @v[17].set(<<-'EOD')
+ 5 5.16963 4.84136 3.33754 0.316206 0.103113 0.0273341 0.0221102
+ 0.0177008 0.0143758 0.0115203 0.00929231 0.00752716 0.00625439
+ 0.00489872 0.00403656 -0.0657317 -0.0256467 0.165394 0.985963
+ 3.05067 4.55799 4.89728 4.92464 4.8882 4.90592 4.97315 4.99241
+ 4.99694 4.99845 4.99905 4.99939 4.99959 4.99971 4.9998 4.99986
+ 4.9999 4.99993 4.99995 4.99996 4.99997 4.99998 4.99998 4.99999
+ 4.99999 4.99999 4.99999 4.99999 5 5.00001 5.00003 5.00005
+ 5.00004 5.00002 5 4.99999 4.99999 4.99998 4.99998 4.99997
+ 4.99997 4.99998 4.99998 4.99999 4.99999 5 5 5 5 5 5.00001
+ 5.00001 5.00001 5.00001 5.00001 5.00001 5.00002 5.00001
+ 5.00001 5.00001 5.00001 5.00001 5.00001 5.00001 5 5 5 5
+ 5 5 5 4.99999 4.99999 4.99999 4.99999 4.99999 4.99999 4.99998
+ 4.99998 4.99998 4.99999 4.99999 4.99999 4.99999 4.99999
+ 4.99999 4.99999 4.99999 4.99999 4.99999 4.99999 4.99999
+ 4.99999 4.99999 5 5 5 5 5 5 5.00025 5.1657 4.69981 2.43895
+ 0.0229743 0.0351406 -0.0211974 -0.0312063 -0.0160331 -0.0021718
+ -0.000766597 -0.000251052 -5.49363e-05 -3.36364e-06 -2.01983e-06
+ -9.70575e-06 -0.0657007 -0.0205247 0.183332 1.07163 3.11839
+ 4.46213 4.84163 4.95195 4.99159 5.02084 5.04029 5.04138
+ 5.0271 5.00445 4.97957 4.95702 4.95231 4.97819 4.99191 4.9963
+ 4.99822 4.99878 4.99903 4.99925 4.99942 4.9995 4.99954 4.99957
+ 4.99961 4.99966 4.9997 4.99974 4.99977 4.99981 4.99983 4.99986
+ 4.99988 4.9999 4.99991 4.99992 4.99994 4.99995 4.99995 4.99996
+ 4.99997 4.99997 4.99998 4.99998 4.99998 4.99999 4.99999
+ 4.99999 4.99999 4.99999 4.99999 4.99999 5 5 5 5 5 5 5 5
+ 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5.00001 5.00001 5.00001
+ 5.00002 5.00002 5.00002 5.00002 5.00002 5.00002 5.00002
+ 5.00002 5.00001 5.00001 5.00001 5.00001 5.00001 5.00001
+ 5.00001 5 5 5 4.99999 4.99998 4.99997 4.99996 5.14239 4.76219
+ 3.16574 0.299969 0.0631609 -0.00118611 -0.00026052 -5.96333e-05
+ -1.44904e-05 -4.3859e-06 -2.99454e-06 1.10547e-06 4.84662e-06
+ 1.30971e-05 2.23082e-05 -0.0655844 -0.0204818 0.182507 1.05954
+ 3.12277 4.46735 4.83915 4.94512 4.97679 4.98654 4.9966 5.00833
+ 5.00776 5.00432 5.00199 5.00086 5.00033 5.00008 5 5.00001
+ 5 5.00005 5.00002 4.99981 4.99991 4.99998 4.99979 4.99979
+ 4.99984 4.9998 4.9998 5.00006 5.00002 5.00001 5 5 4.99992
+ 4.99998 4.99999 5.00002 5.00014 4.99999 4.99987 4.99993
+ 5.00003 5.00011 5.00005 4.99996 4.99987 4.99985 4.99994
+ 5.00009 5.0001 5 4.99993 4.99997 5.00008 5.00015 5.00021
+ 5.00021 5.00007 4.99978 4.99965 4.99973 4.9999 4.99992 4.99995
+ 4.99997 4.99999 5.00001 5.00002 5.00001 5.00001 5.00001
+ 5 5 5 5 5 4.99999 4.99999 4.99999 4.99999 4.99999 4.99999
+ 4.99998 4.99998 4.99999 4.99999 4.99999 4.99999 4.99999
+ 4.99999 4.99999 5 5 5 5 5 5.00001 5.00001 5.00001 5.00002
+ 5.00002 5.00002
+ EOD
+
+ @v[18].set(<<-'EOD')
+ 5 5.0333 5.02472 4.92559 4.18383 3.93923 3.9961 4.14293
+ 4.28591 4.41336 4.52157 4.61101 4.68472 4.7439 4.79294 4.83239
+ 4.80697 4.78808 4.79322 4.8838 5.08529 5.21863 4.88852 3.90198
+ 2.14586 0.383977 0.101103 0.0525711 0.0318287 0.020895 0.0146908
+ 0.010831 0.00830272 0.00656377 0.00532066 0.00440078 0.00369956
+ 0.00315713 0.00272614 0.00237965 0.00209659 0.00186339 0.00167014
+ 0.0015081 0.00137172 0.00125607 0.00115393 0.00106076 0.000980166
+ 0.000918015 0.000862837 0.00080766 0.000763488 0.000721541
+ 0.000680825 0.000653026 0.000625226 0.000597426 0.000569627
+ 0.000541827 0.000519087 0.000499756 0.000480424 0.000461093
+ 0.000441761 0.000423291 0.000411941 0.00040059 0.00038924
+ 0.000377889 0.000366539 0.000355188 0.000343838 0.000332487
+ 0.000321137 0.000309786 0.000299055 0.000292509 0.000285963
+ 0.000279417 0.000272871 0.000266325 0.000259779 0.000253233
+ 0.000246686 0.00024014 0.000233594 0.000227387 0.0002231
+ 0.000218813 0.000214526 0.00021024 0.000205953 0.000201666
+ 0.000197379 0.000193092 0.000188805 0.000184519 0.000180526
+ 0.000177963 0.0001754 0.000172837 0.000170274 0.000167711
+ 0.000165148 0.000162585 0.000160022 0.000157459 0.000154895
+ 0.000152332 0.000149769 0.000147206 0.000144643 0.00014208
+ 0.000139517 0.000136954 0.000134391 0.000131828 0.000129265
+ 0.000126702 0.000132838 0.0311184 0.163151 0.34986 0.604501
+ 0.357125 0.136137 0.0711304 0.0346959 0.0212674 0.00872193
+ 0.00252206 0.000455269 7.59332e-05 2.91532e-05 0.000320562
+ -0.0720911 -0.0840491 -0.0791345 -0.0404143 0.0182035 -0.0235871
+ -0.0426072 -0.0597501 0.00824773 0.481404 1.32496 2.11949
+ 2.57317 2.58202 2.15054 1.33786 0.45702 0.153772 0.0913584
+ 0.0604989 0.0421591 0.0271456 0.0170021 0.0115815 0.00907886
+ 0.00742466 0.00626096 0.00531127 0.00450501 0.00381927 0.00323718
+ 0.00274374 0.00232494 0.00196885 0.00166686 0.00141134 0.00119437
+ 0.0010109 0.000855534 0.000723378 0.000611408 0.000516704
+ 0.000436769 0.000369523 0.000313026 0.00026526 0.000223976
+ 0.000188972 0.000159042 0.000134148 0.000112688 9.49738e-05
+ 7.97877e-05 6.721e-05 5.65115e-05 4.77194e-05 4.03591e-05
+ 3.42848e-05 2.92627e-05 2.50435e-05 2.1412e-05 1.84532e-05
+ 1.58624e-05 1.34673e-05 1.14461e-05 1.00935e-05 9.12375e-06
+ 8.50202e-06 7.81431e-06 7.20729e-06 6.73936e-06 6.3702e-06
+ 5.90049e-06 5.43077e-06 4.96105e-06 4.49133e-06 4.02162e-06
+ 3.5519e-06 3.08218e-06 2.79099e-06 2.51281e-06 2.23463e-06
+ 1.95645e-06 1.67827e-06 1.40009e-06 1.12191e-06 1.01376e-06
+ 9.9375e-07 9.73741e-07 9.53733e-07 9.33724e-07 9.13715e-07
+ 8.93707e-07 8.73698e-07 8.5369e-07 8.33681e-07 8.13673e-07
+ 7.93664e-07 7.73655e-07 7.53647e-07 7.21781e-07 5.956e-07
+ 4.69419e-07 3.43239e-07 2.17058e-07 0.0284032 0.0374438
+ -0.0157543 -0.0680497 0.0504768 0.0100294 0.00222261 0.000528697
+ 0.000132929 3.99489e-05 2.46066e-05 4.56327e-06 -6.54853e-06
+ 1.33783e-05 -3.68221e-05 -0.0724498 -0.0843663 -0.0792935
+ -0.0406426 0.0200019 0.0426259 0.0220753 0.00668555 -0.000968483
+ 0.024662 0.0383437 0.0911513 0.087848 0.0602076 0.0390559
+ 0.0260573 0.0180444 0.012974 0.00985409 0.00788132 0.0064228
+ 0.005545 0.00453571 0.00364245 0.00310278 0.00270523 0.00236439
+ 0.0020945 0.00186808 0.00167493 0.00151731 0.00138594 0.00126945
+ 0.00116695 0.0010762 0.000996366 0.000928387 0.000864414
+ 0.000808258 0.000759574 0.000713865 0.000666712 0.000632716
+ 0.000601262 0.000572163 0.000543986 0.000515253 0.0004897
+ 0.000468112 0.000449313 0.000432981 0.000417911 0.000401307
+ 0.000382712 0.000366678 0.000355736 0.000349171 0.000335727
+ 0.000317091 0.000296086 0.000283543 0.000277366 0.000272233
+ 0.000267001 0.000263147 0.000256699 0.000250251 0.000243803
+ 0.000237355 0.000230907 0.000225424 0.000220247 0.000215069
+ 0.000209892 0.000204714 0.000200213 0.000196548 0.000192884
+ 0.00018922 0.000185556 0.000181892 0.000178228 0.000174564
+ 0.0001709 0.000167236 0.000163572 0.000160824 0.000158279
+ 0.000155733 0.000153187 0.000150641 0.000148095 0.000145549
+ 0.000143003 0.000140457 0.000137911 0.000135457 0.000133386
+ 0.000131315 0.000129245 0.000127174 0.000125103 0.000123032
+ 0.000120961 0.000118891
+ EOD
+
+ @v[19].set(<<-'EOD')
+ 1.86175 1.99994 2.0833 2.01627 2.42503 3.25769 3.62134 3.88827
+ 4.09688 4.26773 4.40529 4.51734 4.60827 4.68313 4.74346
+ 4.79302 4.72815 4.68959 4.70421 4.81316 5.01375 5.14493
+ 5.10305 5.0699 5.04484 5.03751 5.03348 5.02504 5.01799 5.01271
+ 5.00895 5.00628 5.0044 5.00309 5.00216 5.00151 5.00105 5.00073
+ 5.00051 5.00034 5.00023 5.00015 5.0001 5.00007 5.00003 4.99998
+ 4.99993 4.99993 4.99995 4.99999 5.00001 5.00003 5.00002
+ 5.00001 5 5 5 5 4.99999 4.99999 4.99999 5 5 5 5 5 5 5 5
+ 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5
+ 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5.00017 5.17398
+ 4.94779 3.78508 1.52302 0.608808 0.244311 0.126053 0.0597175
+ 0.038422 0.0158174 0.00481338 0.00107847 0.000301256 0.000114861
+ 0.00059489 -0.118904 -0.147478 -0.158986 -0.080544 0.165361
+ 0.171378 0.0776087 0.0435738 0.0428235 0.0423755 0.0347695
+ 0.0225061 0.0155539 0.0121357 0.0107997 0.0103976 0.0124406
+ 0.016814 0.0167556 0.0149852 0.01459 0.0141182 0.0131934
+ 0.0120286 0.0108692 0.0097184 0.00855881 0.00744912 0.00643877
+ 0.00554044 0.00475165 0.00406535 0.00347158 0.00295981 0.00251995
+ 0.00214318 0.00182101 0.00154613 0.00131196 0.0011119 0.000941587
+ 0.000796999 0.000674582 0.000571283 0.000484276 0.000410649
+ 0.000347005 0.000292984 0.000246715 0.000208143 0.00017489
+ 0.000147412 0.000123854 0.000104332 8.77229e-05 7.40686e-05
+ 6.2637e-05 5.32e-05 4.53946e-05 3.88343e-05 3.31864e-05
+ 2.85905e-05 2.45725e-05 2.08671e-05 1.77301e-05 1.55911e-05
+ 1.40153e-05 1.29421e-05 1.18693e-05 1.09815e-05 1.03484e-05
+ 9.87664e-06 9.14446e-06 8.41228e-06 7.68011e-06 6.94793e-06
+ 6.21575e-06 5.48357e-06 4.7514e-06 4.38454e-06 4.04432e-06
+ 3.7041e-06 3.36388e-06 3.02366e-06 2.68344e-06 2.34322e-06
+ 2.15196e-06 2.03791e-06 1.92386e-06 1.80982e-06 1.69577e-06
+ 1.58173e-06 1.46768e-06 1.35363e-06 1.23959e-06 1.12554e-06
+ 1.0115e-06 8.9745e-07 7.83404e-07 6.69358e-07 4.76113e-07
+ -3.47071e-07 -1.17025e-06 -1.99344e-06 -2.81662e-06 0.0783754
+ 0.0500262 -0.0659563 -0.120914 0.0815957 0.0154255 0.00347177
+ 0.000840357 0.000214582 6.54655e-05 3.91709e-05 8.07396e-06
+ -4.44265e-07 1.74384e-05 -4.52725e-05 -0.119379 -0.147984
+ -0.159247 -0.0824604 0.169014 0.177628 0.0758742 0.010558
+ -0.0346506 -0.0710288 -0.0838952 -0.0599521 -0.034568 -0.0181615
+ -0.00968034 -0.00547115 -0.00333511 -0.00232468 -0.00181159
+ -0.00143841 -0.00116601 -0.000839755 -0.000569764 -0.000578683
+ -0.000490551 -0.000411712 -0.000437859 -0.000408185 -0.000356644
+ -0.000311332 -0.000269006 -0.000221396 -0.000210054 -0.0001923
+ -0.000175122 -0.000161039 -0.0001428 -0.000126123 -0.000127893
+ -8.14516e-05 -0.000120166 -0.000154909 -0.000112733 -8.40377e-05
+ -7.11342e-05 -8.09538e-05 -9.77789e-05 -9.82402e-05 -7.73531e-05
+ -5.28255e-05 -3.1096e-05 -1.87967e-05 -1.96552e-05 -4.16655e-05
+ -5.77185e-05 -5.24142e-05 -2.83153e-05 -1.90012e-05 -1.54415e-05
+ -2.52569e-05 -6.23747e-05 -0.000130543 -0.000149394 -0.000110886
+ -4.35517e-05 -4.17084e-05 -3.98651e-05 -3.80218e-05 -3.61785e-05
+ -3.43352e-05 -3.36249e-05 -3.32729e-05 -3.29208e-05 -3.25687e-05
+ -3.22166e-05 -3.17143e-05 -3.10258e-05 -3.03372e-05 -2.96486e-05
+ -2.89601e-05 -2.82715e-05 -2.75829e-05 -2.68944e-05 -2.62058e-05
+ -2.55173e-05 -2.48287e-05 -2.43043e-05 -2.38159e-05 -2.33276e-05
+ -2.28393e-05 -2.2351e-05 -2.18626e-05 -2.13743e-05 -2.0886e-05
+ -2.03977e-05 -1.99093e-05 -1.945e-05 -1.91122e-05 -1.87744e-05
+ -1.84366e-05 -1.80987e-05 -1.77609e-05 -1.74231e-05 -1.70853e-05
+ -1.67474e-05
+ EOD
+
+ @v[20].set(<<-'EOD')
+ 1.86175 1.99724 2.17266 2.48439 3.15933 3.85231 4.38091
+ 4.69033 4.85034 4.92851 4.96453 4.98188 4.98736 4.991 4.99482
+ 4.9973 4.96422 4.89989 4.83907 4.83151 4.90868 5.04854 5.06104
+ 5.04571 5.03219 5.03025 5.02273 5.01707 5.0123 5.0087 5.00611
+ 5.00429 5.00301 5.00211 5.00148 5.00103 5.00072 5.0005 5.00035
+ 5.00024 5.00016 5.00011 5.00007 5.00005 5.00003 5.00001
+ 4.99999 4.99998 4.99998 4.99998 4.99998 4.99998 4.99999
+ 5 5 5.00001 5.00001 5.00002 5.00002 5.00002 5.00002 5.00002
+ 5.00002 5.00001 5.00001 5 5 5 5 5 5 4.99999 4.99999 4.99999
+ 4.99999 4.99999 4.99999 4.99999 4.99999 4.99999 4.99999
+ 4.99999 4.99999 4.99999 5 5 5 5 5 5 5 5 5.00001 5.00001
+ 5.00001 5.00001 5.00001 5.00001 5.00001 5.00001 5.00001
+ 5.00001 5.00001 5.00001 5.00001 5.00001 5.00001 5.00001
+ 5.00001 5.00001 5.00001 5.00001 5.00001 5.00001 5 5 5 5
+ 5 5 4.99981 5.10081 5.10903 4.98404 5.00999 5.14946 4.36501
+ 2.23938 0.325144 0.00660272 -0.0102186 -0.0082401 -0.00556785
+ -0.00374178 -0.00264763 -0.00202823 -0.0182241 -0.0169551
+ -0.0150395 0.0103736 0.0877592 0.104382 0.0515938 0.0373818
+ 0.0411547 0.0397009 0.0308946 0.0205793 0.0154037 0.0129191
+ 0.0119327 0.011527 0.0124295 0.0161152 0.0161076 0.0145391
+ 0.0144541 0.0139287 0.0129215 0.0117239 0.0105795 0.00942983
+ 0.00827423 0.00718354 0.00619954 0.00532868 0.00456631 0.00390448
+ 0.00333254 0.00284003 0.00241714 0.00205524 0.0017458 0.00148202
+ 0.00125739 0.0010655 0.000902213 0.000763611 0.000646279
+ 0.000547291 0.000463934 0.000393401 0.000332424 0.000280655
+ 0.000236328 0.000199386 0.000167536 0.000141218 0.000118654
+ 9.99559e-05 8.40479e-05 7.09694e-05 6.00188e-05 5.09786e-05
+ 4.3502e-05 3.72191e-05 3.18114e-05 2.74071e-05 2.35539e-05
+ 1.99967e-05 1.69871e-05 1.49449e-05 1.3451e-05 1.24492e-05
+ 1.14256e-05 1.05669e-05 9.94487e-06 9.47514e-06 8.77318e-06
+ 8.07123e-06 7.36927e-06 6.66731e-06 5.96536e-06 5.2634e-06
+ 4.56144e-06 4.23044e-06 3.92649e-06 3.62254e-06 3.31858e-06
+ 3.01463e-06 2.71068e-06 2.40673e-06 2.23063e-06 2.12082e-06
+ 2.01102e-06 1.90121e-06 1.7914e-06 1.68159e-06 1.57178e-06
+ 1.46197e-06 1.35216e-06 1.24235e-06 1.13255e-06 1.02274e-06
+ 9.12929e-07 8.0312e-07 6.33171e-07 -1.51288e-08 -6.63428e-07
+ -1.31173e-06 -1.96003e-06 0.0437517 0.0265689 -0.0515377
+ -0.0658688 0.010727 -0.000511921 -8.36924e-05 2.13278e-05
+ 1.45207e-05 4.54862e-06 -6.14726e-06 2.0062e-06 1.02709e-06
+ 1.4152e-05 -3.08225e-05 -0.0166501 -0.0157139 -0.013957
+ 0.0107537 0.0873717 0.111302 0.0454129 -0.00530142 -0.0468336
+ -0.0790063 -0.0826944 -0.0534753 -0.0288705 -0.0149009 -0.00801592
+ -0.0046342 -0.00291835 -0.00213019 -0.00170055 -0.001352
+ -0.00110593 -0.000742655 -0.000532042 -0.000544742 -0.000479206
+ -0.000407307 -0.000403575 -0.000366209 -0.000324161 -0.000286183
+ -0.000247579 -0.000214281 -0.000203435 -0.000186896 -0.000171033
+ -0.00015779 -0.000145259 -0.000128069 -0.000122647 -9.89398e-05
+ -0.000114926 -0.000132195 -0.000107872 -8.91015e-05 -7.87996e-05
+ -8.14061e-05 -8.9098e-05 -8.83368e-05 -7.6122e-05 -6.14668e-05
+ -4.75402e-05 -3.81855e-05 -3.69696e-05 -4.78656e-05 -5.61346e-05
+ -5.35007e-05 -4.1459e-05 -3.35411e-05 -2.52374e-05 -2.37479e-05
+ -4.6406e-05 -9.41884e-05 -0.000109222 -8.52676e-05 -4.25166e-05
+ -4.10125e-05 -3.95085e-05 -3.80045e-05 -3.65004e-05 -3.49964e-05
+ -3.41627e-05 -3.3541e-05 -3.29193e-05 -3.22976e-05 -3.16758e-05
+ -3.10334e-05 -3.03653e-05 -2.96971e-05 -2.9029e-05 -2.83609e-05
+ -2.76928e-05 -2.70246e-05 -2.63565e-05 -2.56884e-05 -2.50203e-05
+ -2.43521e-05 -2.38716e-05 -2.34324e-05 -2.29932e-05 -2.25539e-05
+ -2.21147e-05 -2.16755e-05 -2.12362e-05 -2.0797e-05 -2.03578e-05
+ -1.99186e-05 -1.95079e-05 -1.9217e-05 -1.8926e-05 -1.8635e-05
+ -1.8344e-05 -1.8053e-05 -1.7762e-05 -1.74711e-05 -1.71801e-05
+ EOD
+
+ @v[21].set(<<-'EOD')
+ 1.86175 1.73273 1.42016 1.02483 0.944013 0.274107 0.0823742
+ 0.0379366 0.020816 0.0132952 0.00955525 0.00717008 0.00592286
+ 0.00437379 0.00383557 0.00273694 -0.0037467 -0.0054191 -0.00131454
+ 0.0112179 0.0133918 0.00519747 -0.00260113 -0.00252847 -0.00181292
+ 0.000183398 -0.000667607 -0.000750747 -0.000594314 -0.000433904
+ -0.000308985 -0.000217858 -0.000152926 -0.000107454 -7.54076e-05
+ -5.2675e-05 -3.66299e-05 -2.54341e-05 -1.75095e-05 -1.18848e-05
+ -7.97289e-06 -5.30239e-06 -3.53615e-06 -2.38504e-06 -2.40158e-06
+ -3.84485e-06 -5.29435e-06 -2.57099e-06 1.95189e-06 3.55083e-06
+ 2.06179e-06 5.72753e-07 3.30469e-07 3.40296e-07 3.60221e-07
+ 4.86081e-07 6.1194e-07 7.37799e-07 8.63659e-07 9.89518e-07
+ 9.21274e-07 7.22275e-07 5.23276e-07 3.24277e-07 1.25278e-07
+ -5.59467e-08 -9.03265e-08 -1.24706e-07 -1.59086e-07 -1.93466e-07
+ -2.27846e-07 -2.62226e-07 -2.96605e-07 -3.30985e-07 -3.65365e-07
+ -3.99745e-07 -4.24266e-07 -3.82163e-07 -3.40061e-07 -2.97959e-07
+ -2.55857e-07 -2.13755e-07 -1.71652e-07 -1.2955e-07 -8.7448e-08
+ -4.53457e-08 -3.24353e-09 3.76901e-08 7.19937e-08 1.06297e-07
+ 1.40601e-07 1.74904e-07 2.09208e-07 2.43512e-07 2.77815e-07
+ 3.12119e-07 3.46422e-07 3.80726e-07 4.04507e-07 3.77191e-07
+ 3.49876e-07 3.22561e-07 2.95246e-07 2.67931e-07 2.40616e-07
+ 2.13301e-07 1.85986e-07 1.58671e-07 1.31356e-07 1.04041e-07
+ 7.67256e-08 4.94105e-08 2.20955e-08 -5.21962e-09 -3.25347e-08
+ -5.98498e-08 -8.71649e-08 -1.1448e-07 -1.41795e-07 -1.6911e-07
+ 7.87893e-06 0.0114592 -0.0245712 -0.111637 0.0961324 1.61168
+ 3.22343 4.20442 4.53535 4.83834 4.95464 4.98874 4.99746
+ 4.99883 4.99948 4.99815 4.98431 4.99298 4.99718 5.01948
+ 5.04749 5.008 4.98243 4.98985 4.99781 4.99887 4.99679 4.99616
+ 4.99743 4.99859 4.99936 4.99972 5.00058 5.00123 5.0002 4.99945
+ 4.99983 4.9998 4.99966 4.99958 4.99956 4.99956 4.99956 4.99958
+ 4.99961 4.99965 4.99969 4.99973 4.99977 4.9998 4.99983 4.99985
+ 4.99987 4.99989 4.99991 4.99992 4.99993 4.99994 4.99995
+ 4.99996 4.99997 4.99997 4.99998 4.99998 4.99998 4.99999
+ 4.99999 4.99999 4.99999 4.99999 4.99999 4.99999 5 5 5 5
+ 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5.00001 5.00001
+ 5.00001 5.00002 5.00002 5.00002 5.00002 5.00002 5.00002
+ 5.00002 5.00002 5.00001 5.00001 5.00001 5.00001 5.00001
+ 5.00001 5.00001 5 5 5 4.99999 4.99998 4.99997 4.99996 5.01454
+ 4.99566 4.96796 4.99819 5.03232 5.00034 4.99867 4.99937
+ 4.99977 4.99992 4.99997 4.99999 5.00001 5.00021 4.99974
+ 4.98462 4.99301 4.99723 5.01936 5.04807 5.00929 4.9789 4.97876
+ 4.98244 4.9863 4.99575 5.0069 5.00863 5.00624 5.00357 5.0019
+ 5.00098 5.00048 5.00025 5.00016 5.00011 5.00013 5.00009
+ 4.99982 4.99994 5.00005 4.99994 4.99988 4.99989 4.99997
+ 5.00003 5.00005 5.00002 5.00001 5.00001 5.00001 4.99993
+ 4.99999 5 5.00021 4.99997 4.99981 5 5.00009 5.0001 5.00001
+ 4.99991 4.9999 5 5.00011 5.00017 5.00018 5.00018 5.00014
+ 5.00007 4.99999 4.9999 4.9999 5.00001 5.00016 5.00014 4.99999
+ 4.99993 4.99999 5.00009 5.00007 5.00006 5.00004 5.00003
+ 5.00001 5.00001 5 4.99999 4.99998 4.99997 4.99997 4.99997
+ 4.99998 4.99998 4.99998 4.99998 4.99999 4.99999 4.99999
+ 5 5 5 5 5 5 5.00001 5.00001 5.00001 5.00001 5.00001 5.00002
+ 5.00002 5.00001 5.00001 5.00001 5.00001 5.00001 5.00001
+ 5 5
+ EOD
+
+ @v[22].set(<<-'EOD')
+ 7.10441e-10 0.00107105 0.000637109 -0.00236346 -0.018079
+ -0.0120077 -0.00217059 0.00266679 0.00403383 0.00403836
+ 0.00356705 0.00303303 0.00244716 0.00198586 0.0016855 0.00136497
+ -3.96022e-05 -0.000367409 -3.77079e-05 0.00194085 0.00506964
+ -0.0400214 -0.0402572 0.0524434 0.286234 0.803011 1.44795
+ 2.02473 2.54768 3.02748 3.4415 3.78287 4.09667 4.35152 4.53987
+ 4.67614 4.77407 4.84319 4.89227 4.92702 4.95119 4.96764
+ 4.97846 4.98557 4.98982 4.99209 4.99371 4.99569 4.99727
+ 4.99802 4.99834 4.99867 4.99892 4.99915 4.99936 4.99939
+ 4.99943 4.99946 4.9995 4.99953 4.99957 4.9996 4.99963 4.99967
+ 4.9997 4.99973 4.99974 4.99975 4.99976 4.99977 4.99978 4.9998
+ 4.99981 4.99982 4.99983 4.99984 4.99985 4.99986 4.99986
+ 4.99986 4.99987 4.99987 4.99988 4.99988 4.99989 4.99989
+ 4.9999 4.9999 4.9999 4.9999 4.99991 4.99991 4.99991 4.99991
+ 4.99992 4.99992 4.99992 4.99992 4.99993 4.99993 4.99993
+ 4.99993 4.99993 4.99993 4.99993 4.99993 4.99994 4.99994
+ 4.99994 4.99994 4.99994 4.99994 4.99994 4.99994 4.99995
+ 4.99995 4.99995 4.99995 4.99995 4.99995 4.99995 5.00145
+ 5.00659 5.01209 5.01931 5.00279 4.99273 4.99217 4.99295
+ 4.99471 4.99594 4.99696 4.9978 4.99844 4.99891 4.99924 4.99635
+ 4.99699 4.99813 5.00068 5.00307 5.0588 4.96365 4.54012 3.6307
+ 2.35176 1.0322 0.354379 0.115986 0.0435668 0.0245112 0.020786
+ 0.0164656 0.0118409 0.00849698 0.00597078 0.0040105 0.0026076
+ 0.0016597 0.00118185 0.00121067 0.00153587 0.00174836 0.00136519
+ -0.000189116 -0.00315555 -0.00646603 -0.00898042 -0.010203
+ -0.0110896 -0.0123764 -0.00953841 -0.00225795 0.000818314
+ 0.00152252 0.00150269 0.00119025 0.000767068 0.000308852
+ -3.79272e-05 -0.00019691 -0.000186642 -9.73653e-05 -8.49784e-06
+ 2.04147e-05 -9.91086e-06 -1.55959e-05 -1.80499e-05 -1.77097e-05
+ -1.51548e-05 -1.1978e-05 -9.84916e-06 -1.29728e-05 -1.67235e-05
+ -1.74153e-05 -1.39958e-05 -5.92272e-06 -8.08216e-06 -1.53077e-05
+ -2.92531e-05 -3.91049e-05 -2.98935e-05 -7.32122e-06 3.18534e-05
+ 4.39134e-05 4.18753e-05 3.22759e-05 1.86766e-05 1.58432e-05
+ 1.30098e-05 1.01765e-05 7.34312e-06 4.50975e-06 1.67639e-06
+ -1.15697e-06 -1.23877e-06 -1.11991e-06 -1.00106e-06 -8.82208e-07
+ -7.63355e-07 -6.44502e-07 -5.2565e-07 -4.29318e-07 -3.44661e-07
+ -2.60004e-07 -1.75347e-07 -9.06904e-08 -6.03349e-09 7.86234e-08
+ 1.6328e-07 2.47937e-07 3.32594e-07 4.17251e-07 5.01908e-07
+ 5.86565e-07 6.71222e-07 7.36123e-07 6.43886e-07 5.5165e-07
+ 4.59414e-07 3.67178e-07 0.000334759 -4.60833e-05 -0.00106139
+ -0.00166624 0.000859563 0.00102606 0.00410037 0.00419931
+ 0.00518997 0.00459791 0.00503125 0.00523877 0.00452158 0.00339924
+ 0.00233399 0.000876915 0.000546439 0.000444299 0.000983968
+ 0.00119304 -0.0429422 -0.0403983 0.0534896 0.288013 0.807345
+ 1.44247 2.03448 2.57021 3.05049 3.47332 3.8131 4.1009 4.34677
+ 4.53512 4.67127 4.76531 4.82526 4.86593 4.89586 4.91904
+ 4.93806 4.95348 4.96597 4.97629 4.9843 4.98983 4.99335 4.9957
+ 4.99741 4.99864 4.99946 4.99994 5.00047 5.00073 5.00086
+ 5.00092 5.00094 5.00091 5.00087 5.00081 5.00074 5.00067
+ 5.00059 5.00052 5.00046 5.0004 5.00034 5.0003 5.00026 5.00022
+ 5.00019 5.00016 5.00014 5.00012 5.0001 5.00009 5.00007 5.00006
+ 5.00006 5.00005 5.00004 5.00004 5.00004 5.00003 5.00003
+ 5.00003 5.00002 5.00002 5.00002 5.00002 5.00001 5.00001
+ 5.00001 5.00001 5.00001 5 5 5 5 4.99999 4.99999 4.99999
+ 4.99999 4.99999 4.99999 5 5 5 5 5 5 5 5 5 5.00001 5.00001
+ 5.00001 5.00001 5.00002 5.00002
+ EOD
+
+ @v[23].set(<<-'EOD')
+ 5 5.00284 5.01266 5.01895 4.98936 4.99575 4.99217 4.99545
+ 4.99775 4.99894 4.99946 4.99968 4.99975 4.99977 4.99986
+ 4.9999 4.99528 4.99808 5.00039 5.00392 5.00512 4.99985 4.99863
+ 4.99942 4.99992 5.00017 4.99897 4.99803 4.99784 4.99739
+ 4.99883 5.00365 5.00298 5.00133 5.00048 5.00019 5.00008
+ 5.00005 5.00004 5.00003 5.00002 5.00002 5.00001 5.00001
+ 5.00001 5.00001 5.00001 5 5 4.99999 4.99997 4.99995 4.99996
+ 4.99998 5 5.00001 5.00001 5.00002 5.00002 5.00003 5.00003
+ 5.00002 5.00002 5.00001 5.00001 5 5 5 5 5 4.99999 4.99999
+ 4.99999 4.99999 4.99999 4.99999 4.99998 4.99999 4.99999
+ 4.99999 4.99999 4.99999 4.99999 4.99999 5 5 5 5 5 5 5 5.00001
+ 5.00001 5.00001 5.00001 5.00001 5.00001 5.00001 5.00002
+ 5.00002 5.00001 5.00001 5.00001 5.00001 5.00001 5.00001
+ 5.00001 5.00001 5.00001 5.00001 5.00001 5.00001 5.00001
+ 5.00001 5 5 5 5 5 5 5 5.00217 5.00108 4.99547 4.99658 5.00667
+ 4.99641 4.99532 4.99938 5.00328 5.00222 5.00114 5.00052
+ 5.00024 5.00011 5.00009 4.99285 4.99591 4.99897 5.00403
+ 5.00786 5.00318 4.99942 4.9992 4.99949 5.001 5.00408 5.00319
+ 5.00063 4.99995 5.00014 4.99982 4.99832 4.99838 4.99865
+ 4.99912 4.99836 4.99735 4.99606 4.99814 5.00958 5.02973
+ 5.05293 5.06103 4.99342 4.80726 4.50744 4.07509 3.41358
+ 2.37924 1.03194 0.261552 0.142392 0.0904482 0.0555071 0.0322869
+ 0.018289 0.0113802 0.00875182 0.00757055 0.00629906 0.00523
+ 0.00403349 0.0031953 0.00280864 0.00286119 0.00250389 0.00202815
+ 0.001723 0.00147312 0.0012411 0.00104401 0.000886204 0.000758277
+ 0.000651915 0.00056348 0.000487966 0.000424048 0.000365613
+ 0.000308178 0.000258725 0.000228061 0.000207976 0.000198491
+ 0.00018518 0.000172716 0.000163197 0.000155007 0.000141734
+ 0.000128461 0.000115188 0.000101915 8.86417e-05 7.53686e-05
+ 6.20956e-05 5.69164e-05 5.23275e-05 4.77385e-05 4.31495e-05
+ 3.85605e-05 3.39716e-05 2.93826e-05 2.69449e-05 2.56224e-05
+ 2.42999e-05 2.29774e-05 2.16549e-05 2.03324e-05 1.90099e-05
+ 1.76873e-05 1.63648e-05 1.50423e-05 1.37198e-05 1.23973e-05
+ 1.10748e-05 9.75232e-06 8.48447e-06 7.65129e-06 6.81811e-06
+ 5.98494e-06 5.15176e-06 0.00056893 -0.00787906 -0.0217381
+ -0.0370066 -0.00770505 0.00659312 0.00975477 0.00949456
+ 0.00777552 0.00655645 0.00568776 0.00508782 0.00458121 0.00410187
+ 0.00365665 0.0015121 0.00160863 0.00263181 0.00638941 0.00772607
+ 0.00225583 0.0010843 0.000882939 0.000801563 0.00075632
+ 0.000554992 0.000435131 0.0003474 0.000217667 0.000491602
+ 0.0012267 0.00250446 0.000212058 -0.0174972 -0.0527527 -0.0479071
+ 0.194908 1.45838 3.40677 4.49242 4.86894 4.97215 5.01218
+ 5.04342 5.06228 5.03069 4.87169 4.57056 4.11523 3.38264
+ 2.19691 0.715839 0.172818 0.102162 0.0627162 0.0363388 0.020289
+ 0.0119414 0.00826608 0.0066417 0.00549092 0.00492505 0.00439443
+ 0.0037156 0.00306471 0.00247451 0.00195965 0.0014822 0.0010815
+ 0.000904464 0.0010514 0.00152308 0.00120752 0.000228447
+ -0.00102833 -0.00116644 -0.00042067 4.78758e-05 5.09599e-05
+ -4.45756e-05 -3.22966e-06 3.81163e-05 7.94622e-05 0.000120808
+ 0.000162154 0.000161895 0.000148481 0.000135068 0.000121654
+ 0.000108241 9.81453e-05 9.2164e-05 8.61827e-05 8.02014e-05
+ 7.42201e-05 6.82388e-05 6.22576e-05 5.62763e-05 5.0295e-05
+ 4.43137e-05 3.83324e-05 3.54323e-05 3.321e-05 3.09877e-05
+ 2.87654e-05 2.65431e-05 2.43209e-05 2.20986e-05 1.98763e-05
+ 1.7654e-05 1.54317e-05 1.34612e-05 1.25441e-05 1.1627e-05
+ 1.07099e-05 9.79276e-06 8.87564e-06 7.95851e-06 7.04139e-06
+ 6.12427e-06
+ EOD
+
+ @v[24].set(<<-'EOD')
+ 5 5.01099 5.00866 4.97845 4.92369 4.9273 4.97413 4.9929
+ 4.99826 4.99958 4.99978 5.00005 4.99968 4.99959 5.00014
+ 4.99979 4.99914 4.99982 5.00023 5.00295 5.00664 4.99854
+ 4.99647 5.00438 5.01722 5.03681 5.04766 5.04799 5.04867
+ 5.04873 5.04685 5.04413 5.0367 5.02505 5.01726 5.01183 5.00806
+ 5.00549 5.00371 5.00246 5.00162 5.00105 5.00069 5.00045
+ 5.00031 5.00024 5.00019 5.00012 5.00007 5.00004 5.00001
+ 4.99998 4.99999 4.99999 5 5.00001 5.00001 5.00002 5.00002
+ 5.00003 5.00003 5.00003 5.00002 5.00002 5.00001 5.00001
+ 5.00001 5 5 5 5 5 4.99999 4.99999 4.99999 4.99999 4.99999
+ 4.99999 4.99999 4.99999 4.99999 4.99999 4.99999 4.99999
+ 5 5 5 5 5 5 5 5.00001 5.00001 5.00001 5.00001 5.00001 5.00001
+ 5.00001 5.00002 5.00001 5.00001 5.00001 5.00001 5.00001
+ 5.00001 5.00001 5.00001 5.00001 5.00001 5.00001 5.00001
+ 5.00001 5.00001 5.00001 5 5 5 5 5 5 5 5.00418 4.99953 4.99152
+ 4.99807 5.00497 5.00112 5.00055 5.00038 5.00018 5.00006
+ 5.00006 5.00007 5.00006 5.00004 5.00004 4.99853 4.99945
+ 4.99998 5.00304 5.00935 5.00742 4.99181 4.97421 4.93603
+ 4.8853 4.8927 4.93984 4.97458 4.99039 4.99614 4.99801 4.99851
+ 4.99869 4.99924 5.00108 5.00181 5.00119 5.00059 5.00031
+ 5.00022 5.00018 5.00011 5.00001 5.00006 4.99981 4.99977
+ 4.99982 5.00012 4.99993 5.00008 5.00043 5.00048 5.00024
+ 5.00008 4.99984 4.99993 5.00011 4.99996 4.9998 4.99977 4.9998
+ 4.99993 5.00008 5.00011 5.00002 4.99995 4.99989 4.99993
+ 5 5.00007 5.00009 4.99994 4.99977 4.9997 4.99975 4.99996
+ 4.99996 4.99988 4.9997 4.99952 4.9995 4.99956 4.99973 4.99988
+ 5.00005 5.00025 5.00042 5.00036 5.00031 5.00025 5.0002 5.00014
+ 5.00009 5.00003 5.00002 5.00001 5.00001 5 4.99999 4.99998
+ 4.99998 4.99997 4.99998 4.99998 4.99998 4.99998 4.99998
+ 4.99998 4.99998 4.99999 4.99999 4.99999 4.99999 4.99999
+ 4.99999 4.99999 4.99999 4.99999 4.99999 4.99999 5.00284
+ 5.00442 5.00381 4.98997 4.99092 5.00733 5.07791 4.98237
+ 4.86434 4.76835 4.74067 4.79278 4.85094 4.90068 4.93603
+ 4.95698 4.96984 4.97856 4.98869 4.99904 5.0005 4.99524 5.00181
+ 5.01878 5.05177 5.07986 4.98917 4.56217 3.68 2.3539 1.18541
+ 0.505772 0.221044 0.115287 0.0760938 0.0589194 0.0476784
+ 0.0457213 0.0412911 0.033889 0.0259741 0.0191452 0.0139018
+ 0.0100235 0.00711788 0.00497657 0.00349368 0.00250021 0.00176179
+ 0.00121843 0.000838368 0.000582711 0.000423458 0.000294608
+ 0.000201251 0.000133748 8.6227e-05 5.44252e-05 3.30514e-05
+ 1.93926e-05 1.09814e-05 5.29857e-06 1.92247e-06 3.08708e-07
+ -3.74311e-07 -6.11121e-07 -7.27807e-07 -4.87604e-07 -4.80493e-07
+ -9.15925e-07 -2.03774e-06 -4.01128e-06 -2.46644e-06 2.10626e-06
+ 8.22422e-06 1.04922e-05 9.83047e-06 7.27106e-06 3.29654e-06
+ -2.06736e-06 -2.18019e-06 -2.29303e-06 -2.40586e-06 -2.51869e-06
+ -2.63153e-06 -2.24615e-06 -1.70325e-06 -1.16036e-06 -6.17468e-07
+ -7.45754e-08 2.45198e-07 2.88285e-07 3.31373e-07 3.7446e-07
+ 4.17548e-07 4.60635e-07 5.03723e-07 5.4681e-07 5.89898e-07
+ 6.32985e-07 6.76073e-07 6.19054e-07 5.4001e-07 4.60967e-07
+ 3.81923e-07 3.02879e-07 2.23836e-07 1.44792e-07 6.57488e-08
+ -1.32948e-08 -9.23383e-08 -1.6698e-07 -2.23206e-07 -2.79432e-07
+ -3.35658e-07 -3.91884e-07 -4.48109e-07 -5.04335e-07 -5.60561e-07
+ -6.16787e-07
+ EOD
+
+ @v[25].set(<<-'EOD')
+ 1.34824 1.35838 1.36465 1.34675 1.29167 1.23161 1.2201 1.2185
+ 1.2181 1.21798 1.21793 1.21788 1.21785 1.21782 1.21779 1.21776
+ 1.21655 1.21656 1.21669 1.21871 1.22421 1.22247 1.21858
+ 1.2228 1.23803 1.27737 1.10647 0.395248 0.0600669 0.027687
+ 0.0192374 0.015425 0.0130881 0.00977445 0.00696598 0.00491122
+ 0.00341952 0.00237078 0.00162339 0.00109178 0.000726647
+ 0.000478886 0.00031568 0.000207902 0.000143494 0.000109768
+ 8.62987e-05 5.69775e-05 3.36547e-05 2.30356e-05 1.86108e-05
+ 1.41861e-05 1.08293e-05 7.68835e-06 4.79593e-06 4.51019e-06
+ 4.22444e-06 3.9387e-06 3.65295e-06 3.36721e-06 3.04559e-06
+ 2.69981e-06 2.35403e-06 2.00825e-06 1.66247e-06 1.34508e-06
+ 1.26225e-06 1.17941e-06 1.09657e-06 1.01373e-06 9.30893e-07
+ 8.48054e-07 7.65216e-07 6.82378e-07 5.9954e-07 5.16702e-07
+ 4.37489e-07 3.82774e-07 3.2806e-07 2.73346e-07 2.18632e-07
+ 1.63917e-07 1.09203e-07 5.4489e-08 -2.2523e-10 -5.49395e-08
+ -1.09654e-07 -1.52862e-07 -1.3079e-07 -1.08718e-07 -8.6646e-08
+ -6.45739e-08 -4.25019e-08 -2.04298e-08 1.64229e-09 2.37144e-08
+ 4.57864e-08 6.78585e-08 8.71693e-08 9.30725e-08 9.89758e-08
+ 1.04879e-07 1.10782e-07 1.16685e-07 1.22589e-07 1.28492e-07
+ 1.34395e-07 1.40298e-07 1.46201e-07 1.52105e-07 1.58008e-07
+ 1.63911e-07 1.69814e-07 1.75718e-07 1.81621e-07 1.87524e-07
+ 1.93427e-07 1.9933e-07 2.05234e-07 2.11137e-07 2.19788e-07
+ 0.000393944 -0.000218983 -0.00105784 0.00172403 -0.00027134
+ -0.000204147 8.79968e-06 5.93762e-05 5.83554e-05 4.13815e-05
+ 3.71369e-05 3.03372e-05 2.25336e-05 1.5986e-05 1.07284e-05
+ -7.5239e-05 5.60593e-05 6.97571e-05 0.000667617 0.000960856
+ 0.00131749 -0.00759564 -0.0217897 -0.0450321 -0.076646 -0.128569
+ -0.186391 -0.202175 -0.206953 -0.2082 -0.208416 -0.208669
+ -0.208934 -0.209111 -0.209234 -0.209329 -0.209389 -0.209416
+ -0.2094 -0.209329 -0.20926 -0.209204 -0.209208 -0.209285
+ -0.209454 -0.209641 -0.20977 -0.209811 -0.209833 -0.209887
+ -0.209653 -0.209127 -0.208893 -0.208811 -0.208777 -0.208758
+ -0.208747 -0.20874 -0.208726 -0.208697 -0.208657 -0.208611
+ -0.208565 -0.208524 -0.208488 -0.208451 -0.208412 -0.208373
+ -0.208333 -0.208294 -0.208256 -0.208219 -0.208183 -0.208145
+ -0.208107 -0.208066 -0.208029 -0.207993 -0.207959 -0.207923
+ -0.207883 -0.207838 -0.207789 -0.207747 -0.20771 -0.207675
+ -0.207642 -0.207605 -0.207568 -0.207531 -0.207494 -0.207457
+ -0.20742 -0.207383 -0.207346 -0.207308 -0.207271 -0.207233
+ -0.207196 -0.207158 -0.207121 -0.207084 -0.207046 -0.207009
+ -0.206972 -0.206935 -0.206898 -0.206861 -0.206823 -0.206786
+ -0.206749 -0.206712 -0.206675 -0.206638 -0.2066 -0.206563
+ -0.206526 -0.206489 -0.206452 -0.206415 -0.203384 -0.20015
+ -0.196872 -0.205024 -0.210727 -0.206779 -0.0685263 0.586138
+ 1.4665 2.22945 2.77554 3.076 3.24926 3.34515 3.40164 3.43006
+ 3.43713 3.43075 3.42886 3.4384 3.46567 3.49025 3.51287 3.53821
+ 3.57841 3.39846 2.80753 2.22947 1.7549 1.30429 0.707786
+ 0.303206 0.131352 0.0671706 0.0429955 0.032461 0.0257161
+ 0.0239521 0.0217397 0.0179705 0.0138745 0.0102813 0.00749643
+ 0.0054328 0.00386817 0.0027004 0.00189442 0.00135552 0.000954715
+ 0.000659981 0.000453435 0.000313993 0.000231347 0.000159665
+ 0.000108122 7.10528e-05 4.50233e-05 2.77892e-05 1.62765e-05
+ 8.9893e-06 4.5471e-06 1.54614e-06 -1.6542e-07 -8.68508e-07
+ -1.04369e-06 -9.63086e-07 -8.44294e-07 -6.57339e-07 -7.35885e-07
+ -9.80056e-07 -1.39772e-06 -2.10199e-06 -1.37474e-06 6.13269e-07
+ 3.3028e-06 4.60941e-06 4.91053e-06 4.14186e-06 2.45258e-06
+ -8.7388e-09 -3.59647e-07 -7.10554e-07 -1.06146e-06 -1.41237e-06
+ -1.76328e-06 -1.63073e-06 -1.34534e-06 -1.05995e-06 -7.74561e-07
+ -4.8917e-07 -2.95733e-07 -2.16326e-07 -1.3692e-07 -5.75135e-08
+ 2.18929e-08 1.01299e-07 1.80706e-07 2.60112e-07 3.39519e-07
+ 4.18925e-07 4.98332e-07 4.83984e-07 4.4901e-07 4.14035e-07
+ 3.79061e-07 3.44087e-07 3.09112e-07 2.74138e-07 2.39163e-07
+ 2.04189e-07 1.69215e-07 1.26002e-07 4.83213e-08 -2.9359e-08
+ -1.07039e-07 -1.8472e-07 -2.624e-07 -3.4008e-07 -4.1776e-07
+ -4.95441e-07
+ EOD
+
+ @v[26].set(<<-'EOD')
+ 7.10441e-10 0.000309731 -0.000308186 -0.001694 -0.00360784
+ 8.40909e-05 0.00203175 0.0012896 0.000596548 0.000277191
+ 0.000161134 0.000120439 8.4915e-05 9.49929e-05 6.18812e-05
+ 1.65433e-05 1.89682e-05 3.97578e-05 4.95446e-05 0.000225325
+ 0.000214579 -0.00230134 -0.000451102 0.00997237 0.0341443
+ 0.0449314 0.0424411 0.0341996 0.0315315 0.0308892 0.0291614
+ 0.024365 0.0190282 0.0188976 0.017238 0.0138526 0.0105645
+ 0.00778548 0.00561753 0.0039871 0.00279554 0.00194075 0.0013468
+ 0.000934775 0.000664723 0.000498911 0.000377384 0.000254183
+ 0.000163421 0.000120773 9.65058e-05 7.22384e-05 5.60316e-05
+ 4.14549e-05 2.79516e-05 2.57096e-05 2.34677e-05 2.12257e-05
+ 1.89837e-05 1.67417e-05 1.46737e-05 1.27228e-05 1.07719e-05
+ 8.82099e-06 6.87009e-06 5.0896e-06 4.71705e-06 4.34451e-06
+ 3.97196e-06 3.59941e-06 3.22686e-06 2.85431e-06 2.48176e-06
+ 2.10921e-06 1.73666e-06 1.36411e-06 1.02855e-06 9.42931e-07
+ 8.57316e-07 7.71701e-07 6.86086e-07 6.00471e-07 5.14856e-07
+ 4.29241e-07 3.43626e-07 2.58011e-07 1.72396e-07 9.85409e-08
+ 9.14091e-08 8.42773e-08 7.71456e-08 7.00138e-08 6.2882e-08
+ 5.57503e-08 4.86185e-08 4.14867e-08 3.4355e-08 2.72232e-08
+ 2.05821e-08 1.63235e-08 1.2065e-08 7.80643e-09 3.54786e-09
+ -7.10696e-10 -4.96926e-09 -9.22782e-09 -1.34864e-08 -1.77449e-08
+ -2.20035e-08 -2.62621e-08 -3.05206e-08 -3.47792e-08 -3.90378e-08
+ -4.32963e-08 -4.75549e-08 -5.18134e-08 -5.6072e-08 -6.03306e-08
+ -6.45891e-08 -6.88477e-08 -8.76373e-06 0.000131607 -0.00021685
+ -0.000433027 0.00047234 0.000211593 -0.000189601 3.2492e-05
+ 0.000575955 7.72235e-05 -0.000285172 -0.000242061 -0.000135112
+ -3.50117e-05 -2.75868e-05 5.48974e-05 1.80604e-07 5.48911e-05
+ 3.97478e-05 0.000192909 0.000297932 0.00402253 -0.0122366
+ -0.047853 -0.0963082 -0.108071 -0.0567275 -0.0239271 -0.0178628
+ -0.0233027 -0.031853 -0.0400843 -0.0482725 -0.0576154 -0.0627218
+ -0.0511236 -0.0279524 -0.0150986 -0.00931091 -0.00652876
+ -0.00479286 -0.00344346 -0.00249578 -0.0019532 -0.00157977
+ -0.00131848 -0.00111251 -0.000939229 -0.000797445 -0.000708384
+ -0.000630452 -0.000539722 -0.000508862 -0.000480596 -0.000439484
+ -0.000407217 -0.000363866 -0.000329506 -0.000318642 -0.000307362
+ -0.000286511 -0.000266253 -0.000242943 -0.000218107 -0.000204661
+ -0.00020241 -0.000194435 -0.000185062 -0.000173042 -0.000160549
+ -0.000151407 -0.000145626 -0.000145976 -0.000147342 -0.000145288
+ -0.000137979 -0.000124481 -0.000123218 -0.000127453 -0.000139006
+ -0.000145486 -0.000129764 -9.82749e-05 -4.72596e-05 -3.08671e-05
+ -3.28834e-05 -4.52254e-05 -6.25389e-05 -6.32516e-05 -6.39643e-05
+ -6.4677e-05 -6.53897e-05 -6.61023e-05 -6.6815e-05 -6.75277e-05
+ -6.61005e-05 -6.45173e-05 -6.29341e-05 -6.13509e-05 -5.97676e-05
+ -5.81844e-05 -5.66012e-05 -5.54231e-05 -5.4455e-05 -5.3487e-05
+ -5.25189e-05 -5.15508e-05 -5.05828e-05 -4.96147e-05 -4.86466e-05
+ -4.76785e-05 -4.67105e-05 -4.57424e-05 -4.47743e-05 -4.38063e-05
+ -4.28382e-05 -4.18821e-05 -4.10211e-05 -4.016e-05 -3.9299e-05
+ -3.8438e-05 4.29885e-05 5.14113e-05 -0.000127986 -0.000611463
+ -0.000149428 0.000882394 0.00297059 -0.00405825 -0.00591067
+ -0.00546997 -0.00158744 0.00190677 0.00298403 0.00268595
+ 0.00196161 0.00130289 0.000783347 0.000520683 0.000565306
+ 0.00053419 -0.00224696 -0.000920818 0.0132755 0.0322504
+ 0.0442808 0.0638615 0.0701007 0.0539356 0.0247771 0.056244
+ 0.294266 0.831368 1.45424 2.02898 2.54559 2.9937 3.35333
+ 3.72609 4.06363 4.32789 4.52413 4.66504 4.7652 4.83637 4.88631
+ 4.92109 4.94464 4.96046 4.97218 4.98079 4.98679 4.99076
+ 4.99361 4.99555 4.99686 4.99783 4.99853 4.99902 4.99936
+ 4.99959 4.99973 4.99983 4.9999 4.99993 4.99996 4.99998 5
+ 5.00001 5 4.99999 4.99997 4.99994 4.99993 4.99994 4.99996
+ 4.99999 5.00004 5.00006 5.00005 5.00003 5.00002 5.00001
+ 5 4.99999 4.99999 4.99999 4.99999 4.99999 4.99999 4.99999
+ 5 5 5 5 5 5 5.00001 5.00001 5.00001 5.00001 5.00001 5.00001
+ 5.00001 5.00001 5.00001 5.00001 5.00001 5.00001 5.00001
+ 5 5 5 5 5 4.99999 4.99999 4.99999 4.99999 4.99999 4.99998
+ EOD
+
+ @v[27].set(<<-'EOD')
+ 5 4.99984 4.99796 4.99478 4.9889 4.98738 4.98896 4.99087
+ 4.99262 4.99419 4.99552 4.99659 4.99743 4.99807 4.99855
+ 4.9989 4.99894 4.99908 4.99935 5.00001 5.0007 5.00132 5.00032
+ 4.99976 5.00134 5.00339 5.00315 5.00157 5.00091 5.00058
+ 5.00012 4.99944 4.99886 4.9994 4.99934 4.99899 4.99876 4.99868
+ 4.99872 4.99883 4.99898 4.99914 4.9993 4.99944 4.99956 4.99967
+ 4.99976 4.99982 4.99986 4.9999 4.99993 4.99997 4.99997 4.99998
+ 4.99998 4.99998 4.99998 4.99998 4.99998 4.99998 4.99998
+ 4.99999 4.99999 4.99999 4.99999 5 5 5 5 5 5 5 5 5 5 5 5
+ 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5
+ 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5.00009 5.00028 5.00015 4.99983
+ 5.00036 4.99996 4.99834 4.99783 5.00383 5.00734 5.00387
+ 5.00058 4.99893 4.99836 4.99832 4.99854 4.99873 4.99905
+ 4.99927 4.99952 4.99969 4.99834 4.99536 4.99163 4.99073
+ 5.0053 5.03631 5.03103 4.9008 4.62503 4.21887 3.70902 3.09967
+ 2.35791 1.41912 0.519675 0.210458 0.131362 0.0980819 0.0708209
+ 0.0471701 0.0323272 0.0253535 0.0199144 0.0152615 0.0117228
+ 0.00917696 0.00738117 0.00609292 0.00512664 0.00436184 0.0037961
+ 0.00331639 0.00289006 0.0025477 0.00226529 0.00202925 0.00182793
+ 0.00165474 0.00150531 0.00137529 0.00125983 0.00115603 0.00106455
+ 0.000982977 0.000911255 0.000846819 0.000790092 0.000738698
+ 0.000692816 0.00065107 0.000613595 0.000579642 0.000548935
+ 0.00052106 0.000495598 0.000472174 0.000450849 0.000431118
+ 0.000412667 0.000395868 0.000381319 0.000368487 0.000357327
+ 0.000344212 0.000330334 0.00031622 0.000303298 0.000295809
+ 0.00028832 0.000280831 0.000273342 0.000265853 0.000258364
+ 0.000250875 0.000245118 0.000239488 0.000233857 0.000228227
+ 0.000222596 0.000216966 0.000211336 0.000207047 0.000203455
+ 0.000199863 0.00019627 0.000192678 0.000189085 0.000185493
+ 0.0001819 0.000178308 0.000174716 0.000171123 0.000167531
+ 0.000163938 0.000160346 0.000156835 0.000153973 0.00015111
+ 0.000148248 0.000145385 0.000296579 -3.96718e-05 -0.000449085
+ 0.000323433 0.000750086 0.000268264 0.000149028 -0.000100249
+ 7.00956e-05 0.00012605 0.00022592 0.000193036 0.000120453
+ 8.07865e-05 7.65771e-05 -3.27828e-05 0.000116759 0.000169498
+ 0.000409804 0.000414965 0.00092323 -0.00590633 -0.0175477
+ -0.032433 -0.0559842 -0.0820373 0.0688484 0.626629 1.32929
+ 2.01657 2.60925 3.12329 3.38952 3.14128 2.38463 1.23802
+ 0.316019 0.107832 0.0694707 0.051837 0.035247 0.0209999
+ 0.0116618 0.00967674 0.00789182 0.00574566 0.00386872 0.00258612
+ 0.00167126 0.00104169 0.000641093 0.000401246 0.000277928
+ 0.000171775 0.000102266 5.89376e-05 3.29258e-05 1.80463e-05
+ 1.0057e-05 6.4571e-06 5.10093e-06 4.06791e-06 3.62716e-06
+ 3.63321e-06 3.99625e-06 4.64368e-06 5.20886e-06 4.77728e-06
+ 3.23919e-06 1.14113e-06 -1.29416e-06 -4.15607e-06 -1.88532e-06
+ 5.24411e-06 1.38678e-05 1.28823e-05 3.6758e-06 -2.52285e-06
+ -3.97133e-06 -4.03071e-06 -3.37154e-06 -2.71238e-06 -2.05321e-06
+ -1.39404e-06 -7.34872e-07 -3.73325e-07 -1.05873e-07 1.61578e-07
+ 4.2903e-07 6.96482e-07 8.18468e-07 7.60065e-07 7.01662e-07
+ 6.43258e-07 5.84855e-07 5.26452e-07 4.68049e-07 4.09646e-07
+ 3.51243e-07 2.9284e-07 2.34437e-07 1.71213e-07 1.06928e-07
+ 4.2644e-08 -2.16403e-08 -8.59247e-08 -1.50209e-07 -2.14493e-07
+ -2.78778e-07 -3.43062e-07 -4.07346e-07 -4.55065e-07 -4.3348e-07
+ -4.11896e-07 -3.90311e-07 -3.68726e-07 -3.47141e-07 -3.25556e-07
+ -3.03971e-07 -2.82386e-07
+ EOD
+
+ @v[28].set(<<-'EOD')
+ 0.368163 0.361756 0.327463 0.269513 0.149476 0.0805716 0.0501146
+ 0.03403 0.0230886 0.0160474 0.0116071 0.00870013 0.00679614
+ 0.00542384 0.00432512 0.00340653 -0.00129719 -0.00399429
+ -0.00318719 0.00443085 0.0150156 0.0334147 0.0132288 -0.0189751
+ -0.0508377 -0.0252174 -0.0142489 -0.00675908 -0.0038653
+ -0.00243423 -0.00168891 -0.00120901 -0.000900426 -0.000685575
+ -0.000557595 -0.000457268 -0.000377427 -0.000315269 -0.000266613
+ -0.000228397 -0.000198283 -0.000174248 -0.000154886 -0.00013892
+ -0.000125864 -0.000115189 -0.000105841 -9.66611e-05 -8.84262e-05
+ -8.23872e-05 -7.74668e-05 -7.25463e-05 -6.79992e-05 -6.35276e-05
+ -5.92413e-05 -5.68994e-05 -5.45574e-05 -5.22154e-05 -4.98735e-05
+ -4.75315e-05 -4.54981e-05 -4.36726e-05 -4.18471e-05 -4.00216e-05
+ -3.81961e-05 -3.64559e-05 -3.54209e-05 -3.43858e-05 -3.33508e-05
+ -3.23157e-05 -3.12807e-05 -3.02456e-05 -2.92105e-05 -2.81755e-05
+ -2.71404e-05 -2.61054e-05 -2.51232e-05 -2.44984e-05 -2.38736e-05
+ -2.32487e-05 -2.26239e-05 -2.19991e-05 -2.13742e-05 -2.07494e-05
+ -2.01246e-05 -1.94998e-05 -1.88749e-05 -1.82865e-05 -1.79044e-05
+ -1.75224e-05 -1.71403e-05 -1.67582e-05 -1.63762e-05 -1.59941e-05
+ -1.56121e-05 -1.523e-05 -1.4848e-05 -1.44659e-05 -1.41138e-05
+ -1.39075e-05 -1.37011e-05 -1.34947e-05 -1.32883e-05 -1.30819e-05
+ -1.28755e-05 -1.26691e-05 -1.24627e-05 -1.22563e-05 -1.205e-05
+ -1.18436e-05 -1.16372e-05 -1.14308e-05 -1.12244e-05 -1.1018e-05
+ -1.08116e-05 -1.06052e-05 -1.03988e-05 -1.01924e-05 -9.98605e-06
+ -9.77966e-06 -2.85319e-05 0.00281092 0.00180106 -0.000981083
+ 0.00551926 -0.00119763 -0.0295069 -0.0367677 0.064749 0.119022
+ 0.0882007 0.0552062 0.03418 0.0223243 0.015545 0.011949
+ 0.00757134 0.00667655 0.00583243 0.00644443 0.00650959 -0.0302575
+ -0.0437806 -0.0355466 0.0381776 0.282109 0.674178 1.07582
+ 1.45189 1.789 2.08649 2.34663 2.57245 2.81211 3.04778 3.2523
+ 3.45877 3.65593 3.83396 3.9923 4.13368 4.25864 4.36719 4.46064
+ 4.54086 4.60962 4.66835 4.71838 4.76094 4.79716 4.82796
+ 4.85413 4.87634 4.89518 4.91116 4.92476 4.93631 4.94608
+ 4.95434 4.9613 4.96715 4.97211 4.97638 4.98001 4.98312 4.98571
+ 4.98795 4.98979 4.99138 4.99269 4.99381 4.99474 4.99551
+ 4.99615 4.99668 4.99713 4.99752 4.99783 4.99811 4.99836
+ 4.99858 4.99873 4.99884 4.99892 4.999 4.99907 4.99912 4.99916
+ 4.99921 4.99926 4.99932 4.99937 4.99942 4.99948 4.99953
+ 4.99956 4.99958 4.99961 4.99963 4.99966 4.99968 4.99971
+ 4.99972 4.99973 4.99974 4.99975 4.99976 4.99977 4.99978
+ 4.99979 4.9998 4.9998 4.99981 4.99982 4.99983 4.99984 4.99985
+ 4.99986 4.99986 4.99987 4.99987 5.00498 5.00354 4.99359
+ 4.98981 5.00498 5.00099 5.00041 5.00022 5.00015 5.00012
+ 5.0001 5.00008 5.00005 5.00003 5 4.99431 4.99459 4.99591
+ 5.00087 5.01029 5.03935 4.92784 4.51643 3.78356 2.68745
+ 1.43417 0.583128 0.205094 0.0777337 0.0391566 0.02723 0.023883
+ 0.018808 0.010165 0.00254623 -0.00377463 -0.0038097 0.00144145
+ 0.00267231 0.00193045 0.00144538 0.00121758 0.00112893 0.00109424
+ 0.0010226 0.000948072 0.000882573 0.000826996 0.000776391
+ 0.000729719 0.000686499 0.000647333 0.000610108 0.000575631
+ 0.000545069 0.000515485 0.000488514 0.000465316 0.000443215
+ 0.000422454 0.00040292 0.00038488 0.000368472 0.000353628
+ 0.000339643 0.000326197 0.000313483 0.000302884 0.000294038
+ 0.000284003 0.000270941 0.000254925 0.000246511 0.000244089
+ 0.000245538 0.000242099 0.000235728 0.000227482 0.000218001
+ 0.000207257 0.000202127 0.000196997 0.000191868 0.000186738
+ 0.000181608 0.00017758 0.000173899 0.000170219 0.000166538
+ 0.000162857 0.000159576 0.00015679 0.000154005 0.000151219
+ 0.000148433 0.000145647 0.000142861 0.000140076 0.00013729
+ 0.000134504 0.000131718 0.000129603 0.000127635 0.000125668
+ 0.0001237 0.000121732 0.000119765 0.000117797 0.000115829
+ 0.000113862 0.000111894 0.000109993 0.000108372 0.000106751
+ 0.00010513 0.000103509 0.000101887 0.000100266 9.86449e-05
+ 9.70237e-05
+ EOD
+
+ @v[29].set(<<-'EOD')
+ 5 4.99899 4.99654 4.99327 4.9863 4.98954 4.99212 4.99378
+ 4.9951 4.99624 4.99715 4.99786 4.99839 4.99879 4.99909 4.99931
+ 4.99922 4.99933 4.99971 5.00064 5.00084 5.00123 4.99865
+ 4.99853 4.99983 5.00457 5.00242 5.00105 5.00062 5.00042
+ 4.99971 4.9994 4.9992 4.9996 4.99955 4.99932 4.99918 4.99915
+ 4.99919 4.99927 4.99937 4.99948 4.99957 4.99966 4.99974
+ 4.9998 4.99985 4.99989 4.99992 4.99993 4.99994 4.99994 4.99996
+ 4.99998 5 5 5.00001 5.00001 5.00001 5.00002 5.00002 5.00001
+ 5.00001 5.00001 5 5 5 5 4.99999 4.99999 4.99999 4.99999
+ 4.99999 4.99999 4.99999 4.99998 4.99998 4.99999 4.99999
+ 4.99999 4.99999 4.99999 4.99999 4.99999 4.99999 5 5 5 5
+ 5 5 5.00001 5.00001 5.00001 5.00001 5.00001 5.00001 5.00001
+ 5.00002 5.00002 5.00001 5.00001 5.00001 5.00001 5.00001
+ 5.00001 5.00001 5.00001 5.00001 5.00001 5.00001 5.00001
+ 5.00001 5.00001 5 5 5 5 5 5 4.9997 4.99998 4.99954 4.99963
+ 5.00059 4.99945 4.99732 4.99957 5.00919 5.00558 5.00033
+ 4.99851 4.9983 4.99854 4.99871 4.99928 4.99914 4.99939 4.99952
+ 4.9998 4.99976 4.99744 4.99598 4.99478 4.99806 5.01911 5.04602
+ 5.05469 5.01317 4.89484 4.69655 4.42036 4.06069 3.60793
+ 3.12531 2.72975 2.45187 2.25081 2.09841 1.98509 1.90211
+ 1.84084 1.79411 1.7574 1.72763 1.70283 1.68188 1.66389 1.64823
+ 1.63438 1.62201 1.61088 1.60081 1.59163 1.58323 1.57549
+ 1.56835 1.56173 1.55558 1.54985 1.54451 1.53951 1.53479
+ 1.53035 1.52615 1.5222 1.51845 1.5149 1.51153 1.50834 1.50529
+ 1.5024 1.49964 1.497 1.49449 1.49208 1.48977 1.48755 1.48542
+ 1.48336 1.48138 1.47948 1.47765 1.4759 1.47419 1.47255 1.47096
+ 1.46949 1.46823 1.46696 1.4657 1.46444 1.46317 1.46191 1.46065
+ 1.45956 1.4585 1.45743 1.45636 1.45529 1.45422 1.45315 1.45226
+ 1.45145 1.45064 1.44983 1.44902 1.44821 1.4474 1.44659 1.44579
+ 1.44498 1.44417 1.44336 1.44255 1.44174 1.44094 1.44019
+ 1.43944 1.43868 1.43793 1.43765 1.43679 1.43515 1.43405
+ 1.43478 1.43387 1.43345 1.43184 1.43086 1.43021 1.43003
+ 1.42988 1.42944 1.42883 1.42818 1.42702 1.42642 1.42595
+ 1.42586 1.42616 1.42783 1.41733 1.38106 1.30738 1.3877 2.09819
+ 3.05285 3.58059 3.77601 3.87609 4.02557 4.24887 4.4608 4.60411
+ 4.72109 4.8255 4.90465 4.97379 5.01253 5.01532 5.01239 5.0092
+ 5.00665 5.00474 5.00333 5.00232 5.00163 5.00117 5.00082
+ 5.00057 5.00039 5.00027 5.00019 5.00013 5.00009 5.00006
+ 5.00004 5.00003 5.00002 5.00001 5.00001 5 5 5 4.99998 4.99995
+ 4.99992 4.99996 5.00005 5.00012 5.00008 4.99996 4.9999 4.99985
+ 4.99986 4.99997 5.00021 5.0003 5.00024 5.00009 5.00007 5.00005
+ 5.00003 5.00001 4.99998 4.99998 4.99998 4.99999 4.99999
+ 5 5 5 5 5 5.00001 5.00001 5.00001 5.00001 5.00001 5.00001
+ 5.00002 5.00002 5.00001 5.00001 5.00001 5.00001 5.00001
+ 5.00001 5 5 5 5 5 4.99999 4.99999 4.99999 4.99999 4.99998
+ 4.99998 4.99998
+ EOD
+
+ @v[30].set(<<-'EOD')
+ 7.10441e-10 5.70385e-05 0.000226143 0.000131916 -0.000887764
+ -8.01837e-05 -3.49653e-05 9.40039e-05 0.000118663 0.000108025
+ 8.6059e-05 6.33268e-05 4.99295e-05 3.16843e-05 3.60692e-05
+ 2.07572e-05 -8.6375e-05 3.44583e-05 8.07397e-05 0.000196296
+ 0.000115615 -7.12768e-05 -0.000129812 -4.18679e-05 7.94364e-05
+ 0.000182034 -5.41226e-05 -0.000451819 -0.000713937 -0.00129863
+ -0.00262186 -0.00213417 -0.00133767 0.000775698 0.000969902
+ 0.000549281 0.000280946 0.000140321 8.6919e-05 7.22446e-05
+ 6.5631e-05 6.45263e-05 6.63087e-05 7.17391e-05 7.59042e-05
+ 7.59172e-05 7.03353e-05 6.33558e-05 5.31136e-05 4.64278e-05
+ 4.40594e-05 4.16909e-05 4.05674e-05 3.96957e-05 3.87875e-05
+ 3.74977e-05 3.62079e-05 3.49181e-05 3.36283e-05 3.23385e-05
+ 3.12427e-05 3.02775e-05 2.93124e-05 2.83472e-05 2.7382e-05
+ 2.64613e-05 2.59077e-05 2.5354e-05 2.48004e-05 2.42468e-05
+ 2.36931e-05 2.31395e-05 2.25859e-05 2.20322e-05 2.14786e-05
+ 2.0925e-05 2.03916e-05 1.9995e-05 1.95984e-05 1.92019e-05
+ 1.88053e-05 1.84087e-05 1.80122e-05 1.76156e-05 1.7219e-05
+ 1.68225e-05 1.64259e-05 1.6051e-05 1.57991e-05 1.55471e-05
+ 1.52952e-05 1.50433e-05 1.47913e-05 1.45394e-05 1.42875e-05
+ 1.40356e-05 1.37836e-05 1.35317e-05 1.32978e-05 1.31513e-05
+ 1.30048e-05 1.28583e-05 1.27118e-05 1.25653e-05 1.24188e-05
+ 1.22724e-05 1.21259e-05 1.19794e-05 1.18329e-05 1.16864e-05
+ 1.15399e-05 1.13934e-05 1.12469e-05 1.11005e-05 1.0954e-05
+ 1.08075e-05 1.0661e-05 1.05145e-05 1.0368e-05 1.02215e-05
+ 1.76447e-05 7.21516e-05 -3.59786e-05 -0.000159618 0.000156236
+ 0.000135106 -0.000336402 -0.000302283 0.000699323 0.000473866
+ -0.000156146 -0.000225625 -0.000123592 -3.78116e-05 8.47472e-06
+ 2.43387e-06 -7.44762e-05 7.80111e-05 9.43608e-05 0.000170159
+ 8.83919e-05 -0.00018802 -0.000373512 -0.000390597 0.000156875
+ 0.0032343 0.00776304 -0.000566905 -0.00760695 -0.0159226
+ -0.0245989 -0.0331402 -0.0100902 0.067837 0.266702 0.910818
+ 1.82282 2.69714 3.43247 3.98325 4.32893 4.51529 4.67087
+ 4.79288 4.87574 4.92797 4.95902 4.97655 4.98622 4.99195
+ 4.99526 4.99735 4.9991 4.99974 4.99982 4.99974 4.99961 4.9995
+ 4.99943 4.9994 4.9994 4.99942 4.99944 4.99948 4.99952 4.99956
+ 4.99961 4.99965 4.9997 4.99974 4.99977 4.99981 4.99983 4.99986
+ 4.99988 4.9999 4.99991 4.99992 4.99993 4.99994 4.99995 4.99995
+ 4.99996 4.99997 4.99997 4.99998 4.99998 4.99999 4.99999
+ 4.99999 5 5 5 5.00001 5.00001 5.00001 5.00001 5.00001 5
+ 5 5 5 5 5 5 4.99999 4.99999 4.99999 4.99999 4.99999 4.99999
+ 4.99999 4.99999 4.99999 4.99999 4.99999 4.99999 4.99999
+ 4.99999 4.99999 5 5.00019 4.99888 4.99663 4.99457 4.99902
+ 5.00229 5.00323 5.00302 5.0023 5.0015 5.00085 5.00041 5.00013
+ 4.99993 4.99979 4.99948 4.99954 4.99983 5.00055 5.00109
+ 5.00009 4.9987 4.998 4.99755 4.99676 4.99618 5.01091 5.05272
+ 5.04156 4.80112 4.27692 3.42343 2.23953 0.967179 0.429813
+ 0.540757 1.32991 2.32147 3.14903 3.78143 4.22325 4.47978
+ 4.59448 4.69875 4.79798 4.87419 4.92339 4.95249 4.97174
+ 4.98408 4.99124 4.99478 4.99729 4.99868 4.9992 4.99941 4.99947
+ 4.99946 4.99943 4.9994 4.99939 4.9994 4.99942 4.99946 4.99951
+ 4.99956 4.99961 4.99967 4.99973 4.99977 4.9998 4.99981 4.99983
+ 4.99984 4.99987 4.99992 5.00001 5.00005 5.00001 4.99994
+ 4.99995 4.99995 4.99996 4.99996 4.99996 4.99997 4.99997
+ 4.99997 4.99998 4.99998 4.99998 4.99998 4.99999 4.99999
+ 4.99999 4.99999 5 5 5 5.00001 5.00001 5.00001 5.00001 5.00001
+ 5.00001 5 5 5 5 5 5 5 5 4.99999 4.99999 4.99999 4.99999
+ 4.99998 4.99998 4.99998
+ EOD
+
+ @v[31].set(<<-'EOD')
+ 1.8179e-09 -5.28841e-06 -1.44913e-05 -3.62932e-05 -9.75719e-05
+ 0.000141781 3.73396e-05 -1.65603e-05 -1.5271e-05 -6.73884e-06
+ 4.40157e-06 -4.85345e-06 -1.02964e-05 2.03126e-05 -1.89457e-05
+ -8.75564e-06 7.67422e-06 4.71103e-06 1.29798e-05 6.13469e-06
+ -1.14363e-05 -0.0394563 -0.0477298 -0.0622012 -0.0519225
+ 0.262499 0.943611 1.67052 2.31017 2.84028 3.28467 3.61582
+ 3.85887 4.13011 4.36511 4.54063 4.67013 4.76408 4.83263
+ 4.8825 4.91837 4.94373 4.96117 4.97318 4.98093 4.98562 4.98906
+ 4.99267 4.99539 4.99666 4.99731 4.99797 4.99844 4.99887
+ 4.99927 4.99933 4.99938 4.99944 4.99949 4.99955 4.9996 4.99965
+ 4.9997 4.99975 4.9998 4.99985 4.99986 4.99987 4.99989 4.9999
+ 4.99991 4.99992 4.99993 4.99995 4.99996 4.99997 4.99998
+ 4.99998 4.99999 4.99999 4.99999 4.99999 5 5 5 5 5.00001
+ 5.00001 5.00001 5 5 5 5 5 5 4.99999 4.99999 4.99999 4.99999
+ 4.99999 4.99999 4.99999 4.99999 4.99999 4.99999 4.99999
+ 4.99999 4.99999 4.99999 4.99999 4.99999 4.99999 4.99999
+ 4.99999 4.99999 4.99999 4.99999 4.99999 4.99999 4.99999
+ 4.99999 4.99997 5.00002 5.00004 5.0001 5.0001 4.99987 5.00009
+ 5.00021 5.00002 5.00004 4.99988 5.00013 4.99993 5.00026
+ 4.99973 5 5.00006 5.00009 5.00004 5.00004 5.04854 4.82711
+ 4.04208 2.64155 0.838902 0.19014 0.0982549 0.0723197 0.0576863
+ 0.0427644 0.0301979 0.020146 0.0135728 0.00980358 0.00774482
+ 0.00586604 0.0036687 0.00211511 0.00121906 0.000647581 0.000828436
+ 0.00190938 0.00224254 0.00199956 0.00165488 0.00135612 0.00113715
+ 0.000984181 0.000877175 0.000789973 0.000741139 0.000689338
+ 0.000625676 0.000586082 0.000550152 0.000529573 0.000505606
+ 0.000482117 0.000460574 0.000441649 0.000424674 0.000408398
+ 0.000391914 0.000376272 0.000361487 0.000348181 0.000336045
+ 0.000324466 0.000313545 0.000303046 0.000293056 0.00028356
+ 0.000274586 0.000266155 0.000258279 0.000250938 0.000243789
+ 0.000236912 0.000230244 0.000224186 0.000219291 0.000215346
+ 0.000212468 0.000207291 0.000200862 0.00019368 0.000186767
+ 0.000183515 0.000180263 0.00017701 0.000173758 0.000170506
+ 0.000167253 0.000164001 0.000161164 0.000158357 0.00015555
+ 0.000152743 0.000149936 0.000147129 0.000144322 0.000142066
+ 0.000140096 0.000138127 0.000136157 0.000134187 0.000132218
+ 0.000130248 0.000128278 0.000126308 0.000124339 0.000122369
+ 0.000120399 0.000118429 0.00011646 0.000114527 0.000112892
+ 0.000111258 0.000109623 0.000107988 0.000103598 6.86052e-05
+ 3.337e-05 7.00783e-05 0.000218764 0.000221318 0.000118593
+ -0.000113962 5.78552e-05 9.42068e-05 0.000237037 0.000171302
+ 0.0001033 6.16066e-05 5.52908e-05 6.30233e-05 7.01897e-05
+ 8.48573e-05 0.000106859 8.37213e-05 -0.0391541 -0.047722
+ -0.0618454 -0.0169804 0.345725 1.03426 1.74825 2.37152 2.88737
+ 3.32173 3.66761 3.9707 4.17762 3.98832 3.30483 2.09737 0.710892
+ 0.148159 0.0707463 0.0555808 0.045618 0.0319116 0.0199589
+ 0.0133357 0.00898528 0.00586075 0.00375478 0.00245443 0.00156038
+ 0.000962344 0.000590953 0.000375107 0.000250243 0.00015882
+ 0.000100203 6.18122e-05 3.7372e-05 2.23009e-05 1.32569e-05
+ 8.29437e-06 5.72457e-06 3.96832e-06 2.98935e-06 2.59699e-06
+ 2.75024e-06 3.38689e-06 4.0453e-06 3.50095e-06 1.64988e-06
+ -3.84371e-07 -2.03828e-06 -3.46401e-06 -1.24301e-06 4.63458e-06
+ 1.14104e-05 1.02619e-05 2.15487e-06 -2.98487e-06 -3.67221e-06
+ -2.94279e-06 -2.58649e-06 -2.23019e-06 -1.87389e-06 -1.5176e-06
+ -1.1613e-06 -7.92127e-07 -4.18889e-07 -4.56502e-08 3.27588e-07
+ 7.00827e-07 8.79539e-07 8.17025e-07 7.5451e-07 6.91996e-07
+ 6.29481e-07 5.66966e-07 5.04452e-07 4.41937e-07 3.79422e-07
+ 3.16908e-07 2.54393e-07 1.90078e-07 1.25366e-07 6.0654e-08
+ -4.05776e-09 -6.87696e-08 -1.33481e-07 -1.98193e-07 -2.62905e-07
+ -3.27617e-07 -3.92329e-07 -4.40392e-07 -4.18802e-07 -3.97213e-07
+ -3.75624e-07 -3.54035e-07 -3.32446e-07 -3.10856e-07 -2.89267e-07
+ -2.67678e-07
+ EOD
+
+ @v[32].set(<<-'EOD')
+ 1.10294 1.10297 1.10291 1.10277 1.10259 1.10294 1.10313
+ 1.10306 1.10299 1.10296 1.10295 1.10295 1.10294 1.10294
+ 1.10294 1.10294 1.10294 1.10294 1.10294 1.10296 1.10296
+ 1.00547 0.998599 1.5201 2.49297 3.31258 3.73162 3.84757
+ 3.92505 4.02965 4.16599 4.30294 4.41541 4.52886 4.64414
+ 4.73865 4.81065 4.86391 4.90315 4.93188 4.95258 4.96726
+ 4.97738 4.98436 4.98888 4.99162 4.99363 4.99573 4.99731
+ 4.99804 4.99843 4.99881 4.99909 4.99934 4.99957 4.9996 4.99964
+ 4.99967 4.9997 4.99973 4.99977 4.9998 4.99983 4.99986 4.99988
+ 4.99991 4.99992 4.99992 4.99993 4.99994 4.99994 4.99995
+ 4.99996 4.99996 4.99997 4.99997 4.99998 4.99998 4.99999
+ 4.99999 4.99999 4.99999 5 5 5 5.00001 5.00001 5.00001 5.00001
+ 5.00001 5.00001 5.00001 5.00001 5.00001 5.00001 5.00001
+ 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 4.99999 4.99999 4.99999
+ 4.99999 4.99999 4.99999 4.99999 5.00028 4.99988 4.99968
+ 5.00019 4.99987 5.00021 4.99973 4.99977 4.99996 4.99997
+ 5.0002 4.99957 5.00026 4.99947 5.00074 5.00003 4.99987 4.99979
+ 5.00008 4.99997 5.08794 5.05993 4.76875 3.99197 3.10174
+ 2.5197 2.21771 2.04 1.92235 1.83874 1.77592 1.72665 1.686
+ 1.65276 1.6286 1.61299 1.60039 1.58934 1.57954 1.57083 1.56306
+ 1.55604 1.54963 1.54375 1.53832 1.53331 1.52865 1.52432
+ 1.52026 1.51645 1.51287 1.50949 1.50629 1.50327 1.50039
+ 1.49766 1.49505 1.49257 1.49019 1.48792 1.48574 1.48365
+ 1.48164 1.47971 1.47784 1.47604 1.47431 1.47264 1.47102
+ 1.46945 1.46794 1.46647 1.46505 1.46367 1.46233 1.46103
+ 1.45976 1.45853 1.45733 1.45616 1.45502 1.45392 1.45284
+ 1.45179 1.45076 1.44975 1.4488 1.44795 1.44711 1.44626 1.44541
+ 1.44457 1.44372 1.44287 1.44212 1.44138 1.44063 1.43989
+ 1.43914 1.4384 1.43766 1.43701 1.43641 1.43581 1.43522 1.43462
+ 1.43402 1.43342 1.43282 1.43223 1.43163 1.43103 1.43043
+ 1.42984 1.42924 1.42865 1.42808 1.42752 1.42695 1.42639
+ 1.42584 1.42529 1.42472 1.42412 1.42365 1.42326 1.42304
+ 1.42162 1.42082 1.42032 1.42029 1.42026 1.41995 1.41947
+ 1.41894 1.41841 1.4179 1.41742 1.41699 1.41656 1.32097 1.30963
+ 1.78765 2.64656 3.35764 3.747 3.86589 3.94217 4.04185 4.18453
+ 4.3561 4.53439 4.68621 4.74905 4.77848 4.84629 4.91261 4.97541
+ 5.01284 5.01548 5.01248 5.00924 5.00666 5.00475 5.00334
+ 5.00234 5.00164 5.00118 5.00083 5.00058 5.0004 5.00028 5.00019
+ 5.00013 5.00009 5.00007 5.00004 5.00003 5.00002 5.00001
+ 5.00001 5.00001 5 5 4.99999 4.99995 4.99992 4.99996 5.00006
+ 5.00012 5.00009 4.99997 4.9999 4.99985 4.99986 4.99997 5.00021
+ 5.00031 5.00024 5.0001 5.00007 5.00005 5.00003 5.00001 4.99998
+ 4.99998 4.99999 4.99999 4.99999 5 5 5 5 5 5.00001 5.00001
+ 5.00001 5.00001 5.00001 5.00001 5.00002 5.00002 5.00001
+ 5.00001 5.00001 5.00001 5.00001 5.00001 5.00001 5 5 5 5
+ 5 4.99999 4.99999 4.99999 4.99998 4.99998 4.99998
+ EOD
+
+ @v[33].set(<<-'EOD')
+ 5 5.00012 5.00023 5.0003 4.99972 4.99988 4.99984 4.99991
+ 4.99996 4.99999 5.00008 5.00009 4.99986 5.00003 5.00007
+ 4.99995 4.9999 4.99997 5.00013 5.00014 5.00013 4.99701 4.99763
+ 4.99742 4.99998 5.02836 5.07262 4.96856 4.57267 3.85637
+ 2.79544 1.45942 0.408016 0.084885 0.0271375 0.0119294 0.00707546
+ 0.0051087 0.00373035 0.00264737 0.00186477 0.00130379 0.000915857
+ 0.000653121 0.000483893 0.000380852 0.000302362 0.000219498
+ 0.000154435 0.000121928 0.000104026 8.61242e-05 7.48526e-05
+ 6.49216e-05 5.56238e-05 5.29689e-05 5.03139e-05 4.7659e-05
+ 4.5004e-05 4.23491e-05 4.00356e-05 3.79522e-05 3.58687e-05
+ 3.37852e-05 3.17018e-05 2.97592e-05 2.89804e-05 2.82016e-05
+ 2.74228e-05 2.66441e-05 2.58653e-05 2.50865e-05 2.43077e-05
+ 2.35289e-05 2.27501e-05 2.19714e-05 2.12346e-05 2.07821e-05
+ 2.03295e-05 1.98769e-05 1.94244e-05 1.89718e-05 1.85192e-05
+ 1.80667e-05 1.76141e-05 1.71615e-05 1.6709e-05 1.62828e-05
+ 1.60061e-05 1.57294e-05 1.54527e-05 1.5176e-05 1.48993e-05
+ 1.46226e-05 1.43459e-05 1.40692e-05 1.37925e-05 1.35158e-05
+ 1.3262e-05 1.31191e-05 1.29761e-05 1.28332e-05 1.26903e-05
+ 1.25474e-05 1.24045e-05 1.22615e-05 1.21186e-05 1.19757e-05
+ 1.18328e-05 1.16898e-05 1.15469e-05 1.1404e-05 1.12611e-05
+ 1.11182e-05 1.09752e-05 1.08323e-05 1.06894e-05 1.05465e-05
+ 1.04036e-05 1.02606e-05 1.00185e-05 3.8343e-05 -3.06781e-05
+ -0.000111758 0.000111673 0.000130815 -0.000210491 -0.000231304
+ 0.000310226 0.000265303 3.0878e-05 -4.48405e-05 -1.2852e-05
+ -7.84469e-06 3.29986e-05 -1.23286e-05 -6.07871e-05 5.35082e-05
+ 7.69194e-05 0.000126221 6.57178e-05 0.00223349 -0.0148854
+ -0.0476636 -0.0491447 0.220125 1.11174 2.03988 2.90209 3.61069
+ 4.13554 4.50679 4.71501 4.83916 4.91027 4.95284 4.98086
+ 4.99151 4.98651 4.97113 4.95075 4.93102 4.93683 4.95457
+ 4.97071 4.98212 4.98948 4.99386 4.99636 4.99785 4.9987 4.99927
+ 4.99989 5.00014 5.00007 4.99988 4.99982 4.99976 4.99973
+ 4.99972 4.99972 4.99973 4.99974 4.99975 4.99977 4.99979
+ 4.99981 4.99984 4.99986 4.99988 4.99989 4.99991 4.99992
+ 4.99993 4.99994 4.99995 4.99996 4.99996 4.99997 4.99997
+ 4.99998 4.99998 4.99998 4.99998 4.99999 4.99999 4.99999
+ 4.99999 5 5 5 5.00001 5.00001 5.00001 5.00002 5.00001 5.00001
+ 5.00001 5.00001 5.00001 5 5 5 5 5 5 5 5 4.99999 4.99999
+ 4.99999 4.99999 4.99999 4.99999 4.99999 4.99999 4.99999
+ 4.99999 4.99999 4.99999 5 5.00012 4.99946 4.99839 4.99733
+ 4.99948 5.00114 5.00158 5.00147 5.00113 5.00073 5.00043
+ 5.0002 5.00006 4.99995 4.99986 4.99973 4.99976 4.9999 5.00029
+ 5.00055 4.99704 4.99734 4.9972 5.00278 5.03354 5.07184 4.94057
+ 4.51936 3.75638 2.60982 1.23803 0.315016 0.0796102 0.0252894
+ 0.0165723 0.0827785 0.491298 1.40686 2.33436 3.1251 3.7691
+ 4.22201 4.49976 4.68115 4.80513 4.88509 4.93208 4.95861
+ 4.97579 4.98655 4.99268 4.99571 4.99771 4.99881 4.99929
+ 4.99954 4.99965 4.9997 4.99971 4.99971 4.99971 4.99971 4.99972
+ 4.99974 4.99976 4.99978 4.99981 4.99984 4.99987 4.99989
+ 4.99991 4.99991 4.99992 4.99992 4.99993 4.99997 5.00003
+ 5.00006 5.00004 5.00001 5 4.99999 4.99998 4.99998 4.99997
+ 4.99997 4.99997 4.99998 4.99998 4.99998 4.99999 4.99999
+ 4.99999 4.99999 5 5 5 5 5.00001 5.00001 5.00001 5.00001
+ 5.00001 5.00001 5.00001 5.00001 5.00001 5 5 5 5 5 5 5 4.99999
+ 4.99999 4.99999 4.99999 4.99998 4.99998
+ EOD
+
+ @v[34].set(<<-'EOD')
+ 5 5.00207 5.00813 5.01486 5.00156 5.0018 4.99861 4.99844
+ 4.99888 4.9993 4.99956 4.99971 4.99979 4.99983 4.99987 4.99989
+ 4.99671 4.9974 4.99864 5.00131 5.00377 5.0021 5.00039 4.99993
+ 5.00004 5.0009 5.00109 4.99636 4.98617 4.96778 4.92047 4.89528
+ 4.91112 4.9559 4.98286 4.99369 4.99812 4.99951 4.99994 5.00014
+ 5.00008 4.99994 4.99984 4.99989 4.99998 5.00004 5.00004
+ 5.00006 5.00005 5.00001 4.99997 4.99992 4.99993 4.99994
+ 4.99996 4.99996 4.99996 4.99996 4.99996 4.99996 4.99996
+ 4.99996 4.99996 4.99996 4.99996 4.99996 4.99996 4.99996
+ 4.99997 4.99997 4.99997 4.99997 4.99997 4.99997 4.99997
+ 4.99997 4.99997 4.99997 4.99997 4.99997 4.99997 4.99997
+ 4.99997 4.99997 4.99997 4.99997 4.99997 4.99997 4.99997
+ 4.99998 4.99998 4.99998 4.99998 4.99998 4.99998 4.99998
+ 4.99998 4.99998 4.99998 4.99998 4.99998 4.99998 4.99998
+ 4.99998 4.99998 4.99998 4.99998 4.99998 4.99998 4.99998
+ 4.99998 4.99998 4.99998 4.99998 4.99998 4.99998 4.99998
+ 4.99998 4.99998 4.99998 4.99998 5.00131 5.00072 4.9977 4.99811
+ 5.00325 4.99647 4.98948 4.99459 5.00262 5.00276 5.00156
+ 5.00072 5.0003 5.00013 4.99995 4.99668 4.99775 4.99917 5.00173
+ 5.00386 5.00188 4.99888 4.99757 4.99951 5.01712 5.0557 5.07088
+ 5.07704 5.07758 5.06958 5.04223 5.03331 5.0279 5.03408 5.07611
+ 5.01911 4.68594 3.99152 2.92195 1.69878 0.809 0.344091 0.154663
+ 0.0788717 0.0467212 0.0336168 0.0280514 0.0254947 0.024173
+ 0.0223567 0.0220555 0.0271514 0.0295872 0.0296052 0.0283971
+ 0.0264726 0.0241813 0.0218244 0.0195349 0.017368 0.0152495
+ 0.013295 0.0115444 0.00996982 0.00857091 0.00733891 0.00627261
+ 0.0053494 0.00456316 0.00388373 0.00331073 0.00282181 0.00240991
+ 0.00206389 0.00177187 0.00152283 0.00131167 0.00112558 0.000954373
+ 0.000805726 0.00069326 0.000600991 0.000525743 0.00047355
+ 0.00044359 0.000434815 0.000436053 0.000402511 0.000368969
+ 0.000335427 0.000301886 0.000268344 0.000234802 0.00020126
+ 0.000184967 0.000169932 0.000154896 0.000139861 0.000124825
+ 0.00010979 9.47546e-05 8.67896e-05 8.24901e-05 7.81906e-05
+ 7.38911e-05 6.95915e-05 6.5292e-05 6.09925e-05 5.66929e-05
+ 5.23934e-05 4.80939e-05 4.37943e-05 3.94948e-05 3.51953e-05
+ 3.08957e-05 2.67968e-05 2.42936e-05 2.17904e-05 1.92872e-05
+ 1.6784e-05 0.00125927 -0.00794344 -0.0305499 -0.0621697
+ -0.0463796 -0.0224608 -0.00538381 0.00546086 0.0108675 0.012883
+ 0.0131787 0.0127271 0.0119702 0.0110398 0.0100635 0.00649617
+ 0.00489388 0.00545863 0.0098351 0.0167428 0.0126563 0.00697542
+ 0.00427027 0.00330002 0.00390774 0.00408999 -0.00259143
+ -0.0160578 -0.0451849 -0.0409651 0.1301 0.597429 1.3848
+ 2.63426 3.81272 4.51373 4.8412 4.98731 4.88165 4.37165 3.40034
+ 2.17681 1.12217 0.505129 0.219703 0.104992 0.0622333 0.0448317
+ 0.0355782 0.0311867 0.0293529 0.0274615 0.0288739 0.0307845
+ 0.0304909 0.029245 0.0273602 0.0251006 0.022697 0.0202765
+ 0.0179357 0.0157106 0.0136562 0.0117951 0.0101273 0.00865784
+ 0.00739394 0.00634364 0.00551356 0.00480538 0.00415747 0.00356084
+ 0.00297585 0.00236711 0.00181853 0.00160713 0.00169822 0.00166542
+ 0.00145504 0.00120252 0.00109259 0.000982658 0.00087273
+ 0.000762802 0.000652874 0.000584068 0.000528263 0.000472458
+ 0.000416653 0.000360848 0.000321155 0.000301442 0.000281729
+ 0.000262016 0.000242303 0.00022259 0.000202877 0.000183164
+ 0.000163451 0.000143738 0.000124025 0.000114582 0.000107399
+ 0.000100216 9.30332e-05 8.58502e-05 7.86672e-05 7.14841e-05
+ 6.43011e-05 5.7118e-05 4.9935e-05 4.35378e-05 4.04281e-05
+ 3.73184e-05 3.42088e-05 3.10991e-05 2.79894e-05 2.48798e-05
+ 2.17701e-05 1.86604e-05
+ EOD
+
+ @v[35].set(<<-'EOD')
+ 7.24585e-12 2.21843e-05 3.20014e-05 1.25076e-05 -2.44947e-05
+ 1.8425e-05 5.50546e-06 3.53025e-05 -1.07551e-05 -3.94383e-06
+ -2.27848e-06 -9.04789e-05 7.44215e-05 -2.7662e-05 0.000200038
+ -2.11998e-05 -2.09011e-05 2.37098e-05 2.18751e-05 -2.28422e-05
+ -6.23659e-05 3.58241e-05 1.76386e-05 -4.28311e-05 0.000355626
+ 0.00156903 0.00100999 -0.0085304 -0.02067 -0.0389485 -0.0651568
+ -0.128475 -0.314362 -0.406837 -0.421558 -0.421277 -0.418176
+ -0.414481 -0.410845 -0.407348 -0.403971 -0.400716 -0.397582
+ -0.394563 -0.391658 -0.388866 -0.386178 -0.383585 -0.381094
+ -0.378789 -0.376569 -0.37435 -0.372256 -0.370188 -0.36815
+ -0.366422 -0.364694 -0.362967 -0.361239 -0.359511 -0.357888
+ -0.356334 -0.354781 -0.353227 -0.351674 -0.350152 -0.348888
+ -0.347625 -0.346361 -0.345098 -0.343834 -0.342571 -0.341307
+ -0.340044 -0.33878 -0.337517 -0.336279 -0.335215 -0.334152
+ -0.333088 -0.332024 -0.330961 -0.329897 -0.328833 -0.32777
+ -0.326706 -0.325642 -0.324601 -0.323683 -0.322766 -0.321849
+ -0.320932 -0.320014 -0.319097 -0.31818 -0.317263 -0.316345
+ -0.315428 -0.314545 -0.313825 -0.313106 -0.312387 -0.311667
+ -0.310948 -0.310228 -0.309509 -0.308789 -0.30807 -0.307351
+ -0.306631 -0.305912 -0.305192 -0.304473 -0.303754 -0.303034
+ -0.302315 -0.301595 -0.300876 -0.300157 -0.299437 -0.298716
+ -0.29798 -0.297329 -0.296691 -0.295837 -0.29516 -0.294725
+ -0.294044 -0.292917 -0.292351 -0.291965 -0.291365 -0.290687
+ -0.290027 -0.289376 -0.288772 -0.288193 -0.287505 -0.286892
+ -0.28626 -0.285714 -0.284545 -0.289246 -0.298717 -0.298492
+ -0.214163 0.181451 0.0749974 0.0454707 0.0292987 0.0196837
+ 0.0124119 0.00884715 0.00527181 0.00585821 0.0296361 0.169856
+ 0.361207 0.538856 0.67469 0.685933 0.392802 0.17772 0.0813085
+ 0.0424601 0.0246654 0.0175258 0.0144256 0.0129859 0.012205
+ 0.0112846 0.010933 0.0134813 0.0147254 0.0147981 0.0142156
+ 0.0132732 0.0121355 0.0109587 0.00981238 0.00872731 0.00767007
+ 0.00669346 0.00581341 0.00502167 0.00431819 0.00369842 0.00316168
+ 0.00269663 0.00230035 0.00195801 0.00166928 0.00142286 0.00121522
+ 0.00104072 0.000893384 0.000767675 0.000661268 0.000567659
+ 0.000481766 0.000407101 0.000350044 0.000302721 0.000263424
+ 0.000236813 0.00022199 0.000218182 0.000219548 0.0002027
+ 0.000185853 0.000169006 0.000152158 0.000135311 0.000118463
+ 0.000101616 9.33782e-05 8.57685e-05 7.81588e-05 7.0549e-05
+ 6.29393e-05 5.53296e-05 4.77199e-05 4.36954e-05 4.15296e-05
+ 3.93637e-05 3.71978e-05 3.50319e-05 3.28661e-05 3.07002e-05
+ 2.85343e-05 2.63685e-05 2.42026e-05 2.20367e-05 1.98709e-05
+ 1.7705e-05 1.55391e-05 1.34772e-05 1.22416e-05 1.10061e-05
+ 9.77055e-06 8.535e-06 0.000631271 -0.00362586 -0.0146235
+ -0.0308486 -0.0237466 -0.0117522 -0.00304171 0.00251033
+ 0.00531986 0.0063897 0.00657351 0.00636494 0.00599705 0.00553442
+ 0.00505994 0.00330925 0.00246671 0.0027006 0.00473161 0.00830333
+ 0.00649147 0.00356815 0.00217448 0.00187579 0.00270447 0.00219543
+ -0.00546118 -0.0179576 -0.0445306 -0.0649309 0.0197935 0.473629
+ 0.87268 0.269542 0.0086094 0.0844602 0.606456 1.04929 0.906014
+ 0.916205 0.919425 0.872867 0.556244 0.262457 0.11838 0.0571226
+ 0.0333451 0.0237133 0.0185096 0.0159617 0.0148663 0.0138683
+ 0.0144081 0.0153797 0.0152551 0.0146487 0.0137192 0.0125973
+ 0.0113996 0.0101903 0.00901851 0.00790495 0.00687502 0.00593994
+ 0.00510092 0.00436111 0.00372439 0.0031945 0.00277537 0.00241888
+ 0.002095 0.00179943 0.00150419 0.00119264 0.00090934 0.000802394
+ 0.000852816 0.000838368 0.000730842 0.000601028 0.000546616
+ 0.000492205 0.000437793 0.000383381 0.000328969 0.00029454
+ 0.000266428 0.000238317 0.000210205 0.000182093 0.000162091
+ 0.000152145 0.000142198 0.000132252 0.000122306 0.000112359
+ 0.000102413 9.24665e-05 8.25201e-05 7.25738e-05 6.26274e-05
+ 5.78553e-05 5.42216e-05 5.05878e-05 4.69541e-05 4.33204e-05
+ 3.96867e-05 3.60529e-05 3.24192e-05 2.87855e-05 2.51518e-05
+ 2.19153e-05 2.03406e-05 1.8766e-05 1.71913e-05 1.56167e-05
+ 1.4042e-05 1.24674e-05 1.08927e-05 9.31806e-06
+ EOD
+
+ @v[36].set(<<-'EOD')
+ 5 5.01426 5.02852 5.01923 4.77685 4.56471 4.52338 4.56813
+ 4.63122 4.693 4.74776 4.79385 4.83258 4.86358 4.88918 4.91021
+ 4.90553 4.89733 4.89554 4.91953 5.00757 5.07101 5.06318
+ 5.05241 5.05535 5.08042 5.07251 4.90973 4.56136 3.98637
+ 3.237 2.67216 2.33678 2.13529 2.00544 1.91429 1.84638 1.79461
+ 1.75338 1.71958 1.69175 1.6686 1.64918 1.63258 1.61836 1.60607
+ 1.59506 1.58483 1.57575 1.56847 1.56193 1.55538 1.54968
+ 1.54416 1.5388 1.53523 1.53165 1.52807 1.52449 1.52091 1.51771
+ 1.51477 1.51182 1.50888 1.50593 1.50309 1.50113 1.49917
+ 1.4972 1.49524 1.49328 1.49132 1.48935 1.48739 1.48543 1.48346
+ 1.48157 1.48012 1.47868 1.47724 1.47579 1.47435 1.47291
+ 1.47146 1.47002 1.46857 1.46713 1.46574 1.46462 1.4635 1.46238
+ 1.46126 1.46014 1.45902 1.4579 1.45678 1.45567 1.45455 1.45349
+ 1.45275 1.45201 1.45127 1.45053 1.44979 1.44905 1.44831
+ 1.44757 1.44683 1.44609 1.44535 1.44461 1.44387 1.44313
+ 1.44239 1.44165 1.44091 1.44017 1.43943 1.43869 1.43795
+ 1.43721 1.43874 1.43976 1.43619 1.43182 1.43726 1.43084
+ 1.42587 1.42383 1.42642 1.42728 1.42736 1.4271 1.42669 1.42621
+ 1.42569 1.41703 1.41244 1.41019 1.41199 1.41833 1.42502
+ 1.41504 1.37535 1.28381 1.44779 2.33713 3.25835 3.67554
+ 3.84975 4.01125 4.2253 4.45433 4.62215 4.74478 4.82998 4.8868
+ 4.92396 4.94768 4.96498 4.98537 5.0128 5.04467 5.06722 5.06535
+ 5.01475 4.91956 4.80647 4.7242 4.7059 4.73552 4.76379 4.81684
+ 4.87376 4.92276 4.96112 4.9884 5.0045 5.00999 5.00933 5.00619
+ 5.00384 5.00342 5.00373 5.00362 5.00309 5.00272 5.00239
+ 5.00204 5.00172 5.00146 5.00124 5.00105 5.00089 5.00076
+ 5.00065 5.00057 5.00048 5.00041 5.00034 5.00028 5.00023
+ 5.00019 5.00015 5.00015 5.00016 5.0002 5.00023 5.00021 5.00019
+ 5.00017 5.00015 5.00012 5.0001 5.00008 5.00007 5.00006 5.00005
+ 5.00004 5.00003 5.00002 5.00001 5.00001 5.00001 5.00001
+ 5.00001 5.00001 5.00001 5.00002 5.00002 5.00002 5.00002
+ 5.00002 5.00002 5.00002 5.00002 5.00002 5.00002 5.00001
+ 5.00001 5.00001 5.00062 4.99506 4.9835 4.96726 4.9728 4.97877
+ 4.98675 4.9966 5.00406 5.00679 5.00629 5.00561 5.00487 5.00429
+ 5.00384 5.002 5.00164 5.00229 5.00484 5.00769 5.00019 5.00242
+ 5.01319 5.0335 5.07265 5.10129 5.11485 5.12551 5.13953 5.16048
+ 5.18862 5.22811 5.25656 5.25627 5.19975 4.9139 4.24745 3.43732
+ 2.8202 2.43224 2.17409 2.01333 1.93951 1.94622 1.98861 2.02217
+ 2.05383 2.08376 2.11184 2.13793 2.16191 2.18267 2.20502
+ 2.22837 2.24958 2.26901 2.28648 2.302 2.31582 2.32802 2.33869
+ 2.34795 2.35596 2.36282 2.3687 2.37371 2.37797 2.38161 2.38476
+ 2.38743 2.3897 2.39168 2.39329 2.39463 2.39575 2.39671 2.39756
+ 2.39835 2.39907 2.39968 2.39999 2.4003 2.40061 2.40091 2.40122
+ 2.40142 2.40159 2.40176 2.40193 2.4021 2.40222 2.40228 2.40234
+ 2.4024 2.40247 2.40253 2.40259 2.40265 2.40271 2.40277 2.40284
+ 2.40287 2.40289 2.40291 2.40294 2.40296 2.40298 2.40301
+ 2.40303 2.40305 2.40308 2.4031 2.40311 2.40312 2.40313 2.40314
+ 2.40315 2.40316 2.40317 2.40318
+ EOD
+
+ @v[37].set(<<-'EOD')
+ 5 5.01732 5.03181 5.05944 5.12686 5.20725 5.28103 5.31254
+ 5.32901 5.33709 5.3408 5.34257 5.34311 5.34347 5.34386 5.34411
+ 5.3406 5.33484 5.32942 5.32904 5.33644 5.34869 5.35001 5.34882
+ 5.34758 5.34672 5.34599 5.34496 5.34364 5.34165 5.33712
+ 5.33502 5.3366 5.34067 5.34306 5.34398 5.34434 5.34442 5.34443
+ 5.34443 5.34441 5.34439 5.34437 5.34437 5.34438 5.34438
+ 5.34438 5.34438 5.34438 5.34437 5.34437 5.34436 5.34436
+ 5.34437 5.34437 5.34437 5.34437 5.34437 5.34437 5.34437
+ 5.34437 5.34437 5.34437 5.34437 5.34437 5.34437 5.34437
+ 5.34437 5.34437 5.34437 5.34437 5.34437 5.34437 5.34437
+ 5.34437 5.34437 5.34437 5.34437 5.34437 5.34437 5.34437
+ 5.34437 5.34437 5.34437 5.34437 5.34437 5.34437 5.34437
+ 5.34437 5.34437 5.34437 5.34437 5.34437 5.34437 5.34437
+ 5.34437 5.34437 5.34437 5.34437 5.34437 5.34437 5.34437
+ 5.34437 5.34437 5.34437 5.34437 5.34437 5.34437 5.34437
+ 5.34437 5.34437 5.34437 5.34437 5.34437 5.34437 5.34437
+ 5.34437 5.34437 5.34437 5.34437 5.34437 5.35377 5.35451
+ 5.34265 5.34488 5.35861 5.28622 4.90033 4.75027 4.89731
+ 4.97098 4.99293 4.99832 4.99909 4.99956 4.99858 4.99829
+ 4.9998 5.00035 5.0038 5.00989 5.00251 4.99438 4.9953 4.99761
+ 4.99985 5.00152 5.0011 5.00046 4.99996 4.99925 4.99862 4.99919
+ 4.99961 5.00048 5.00234 4.99654 4.98235 4.95936 4.83738
+ 4.53021 4.21004 4.00593 3.91207 3.88059 3.87822 3.89117
+ 3.91278 3.94044 3.97376 4.01152 4.05052 4.10679 4.17908
+ 4.25673 4.33414 4.40875 4.47879 4.54342 4.60258 4.65595
+ 4.70291 4.74414 4.78018 4.81185 4.83915 4.86291 4.88301
+ 4.90048 4.91528 4.92802 4.9387 4.94777 4.95539 4.9618 4.96725
+ 4.97195 4.97588 4.97932 4.98247 4.98512 4.98697 4.98831
+ 4.98919 4.99015 4.99101 4.99169 4.99222 4.99282 4.99341
+ 4.994 4.9946 4.99519 4.99578 4.99638 4.99667 4.99693 4.9972
+ 4.99747 4.99773 4.998 4.99827 4.99841 4.99849 4.99856 4.99864
+ 4.99872 4.9988 4.99888 4.99896 4.99904 4.99911 4.99919 4.99927
+ 4.99935 4.99943 4.9995 4.99955 4.9996 4.99965 4.9997 5.00736
+ 4.98252 4.87516 4.66727 4.49142 4.43103 4.4301 4.4571 4.49729
+ 4.5407 4.5835 4.62363 4.66114 4.69577 4.72738 4.74632 4.75971
+ 4.77576 4.80671 4.87073 4.91665 4.93252 4.94418 4.95331
+ 4.96094 4.96727 4.97148 4.97471 4.97612 4.98276 5.00247
+ 5.04086 5.08628 5.10673 5.08887 5.0564 5.02767 5.01336 4.99685
+ 4.97422 4.90866 4.67035 4.33117 4.07888 3.94432 3.89105
+ 3.88174 3.89292 3.91442 3.94564 3.98708 4.0355 4.09134 4.16315
+ 4.24088 4.31918 4.39527 4.46693 4.53337 4.59405 4.6486 4.69693
+ 4.73938 4.77617 4.80809 4.83551 4.85895 4.87894 4.89596
+ 4.91081 4.92417 4.93651 4.94552 4.95198 4.9565 4.96096 4.96523
+ 4.96972 4.97428 4.97868 4.98064 4.9826 4.98455 4.98651 4.98847
+ 4.98967 4.99064 4.9916 4.99257 4.99353 4.99422 4.99457 4.99493
+ 4.99528 4.99563 4.99598 4.99633 4.99668 4.99703 4.99738
+ 4.99773 4.9979 4.99804 4.99817 4.9983 4.99843 4.99856 4.99869
+ 4.99883 4.99896 4.99909 4.99921 4.99926 4.99931 4.99937
+ 4.99942 4.99948 4.99953 4.99959 4.99964
+ EOD
+
+ @v[38].set(<<-'EOD')
+ 4.49849 4.53282 4.58329 4.66625 4.83345 4.97823 5.0207 5.01816
+ 5.01116 5.00595 5.00296 5.00148 5.00073 5.00062 5.00033
+ 5.0003 4.99864 4.99661 4.99652 4.99928 5.00361 5.12573 5.17251
+ 5.22612 5.33479 5.44503 5.44432 5.44379 5.44334 5.443 5.44276
+ 5.44258 5.44246 5.44238 5.44232 5.44228 5.44225 5.44223
+ 5.44221 5.4422 5.44219 5.44219 5.44218 5.44218 5.44218 5.44218
+ 5.44217 5.44217 5.44217 5.44217 5.44217 5.44217 5.44217
+ 5.44217 5.44217 5.44217 5.44217 5.44217 5.44217 5.44217
+ 5.44217 5.44217 5.44217 5.44217 5.44217 5.44217 5.44216
+ 5.44216 5.44216 5.44216 5.44216 5.44216 5.44216 5.44216
+ 5.44216 5.44216 5.44216 5.44216 5.44216 5.44216 5.44216
+ 5.44216 5.44216 5.44216 5.44216 5.44215 5.44215 5.44215
+ 5.44215 5.44215 5.44215 5.44215 5.44215 5.44215 5.44215
+ 5.44215 5.44215 5.44215 5.44215 5.44215 5.44215 5.44215
+ 5.44215 5.44215 5.44215 5.44215 5.44215 5.44215 5.44215
+ 5.44214 5.44214 5.44214 5.44214 5.44214 5.44214 5.44214
+ 5.44214 5.44214 5.44214 5.44214 5.44212 5.45159 5.45236
+ 5.44064 5.44307 5.45616 5.38122 4.77163 3.53297 2.74466
+ 2.34448 2.11802 1.9783 1.88656 1.82001 1.77389 1.72955 1.69632
+ 1.66971 1.6526 1.65236 1.56034 1.53764 1.97139 2.75096 3.39212
+ 3.74042 3.82345 3.85696 3.88547 3.91862 3.9585 4.00467 4.05903
+ 4.1254 4.19533 4.26791 4.34517 4.42112 4.49238 4.55807 4.6179
+ 4.6713 4.71815 4.75889 4.79418 4.82456 4.85062 4.87291 4.89196
+ 4.90823 4.92209 4.93388 4.9439 4.95242 4.95968 4.96585 4.97108
+ 4.9755 4.97923 4.98237 4.98503 4.98732 4.98927 4.99094 4.99233
+ 4.99353 4.99452 4.99538 4.99608 4.99668 4.99718 4.9976 4.99794
+ 4.99822 4.99847 4.99867 4.99884 4.99899 4.99913 4.99924
+ 4.99932 4.99938 4.99943 4.99947 4.99951 4.99953 4.99955
+ 4.99958 4.99961 4.99964 4.99967 4.99969 4.99972 4.99975
+ 4.99977 4.99978 4.99979 4.99981 4.99982 4.99983 4.99985
+ 4.99986 4.99986 4.99987 4.99987 4.99988 4.99988 4.99988
+ 4.99989 4.99989 4.9999 4.9999 4.99991 4.99991 4.99992 4.99992
+ 4.99993 4.99993 4.99993 4.99994 5.00381 5.00064 4.99246
+ 4.99823 5.00349 5.00076 5.00033 5.00015 5.00009 5.00007
+ 5.00005 5.00004 5.00003 5.00002 4.99988 4.99732 4.99728
+ 4.9978 5.00187 5.00927 5.08712 5.07654 4.92855 4.4863 3.76162
+ 3.00049 2.49834 2.20883 2.03492 1.92384 1.84676 1.79021
+ 1.74716 1.7132 1.68576 1.66309 1.64406 1.62785 1.61383 1.60162
+ 1.59081 1.58117 1.57253 1.56473 1.55765 1.55117 1.54527
+ 1.53988 1.53485 1.53012 1.5257 1.5216 1.51773 1.51411 1.51071
+ 1.50746 1.50438 1.50146 1.49868 1.49603 1.4935 1.49109 1.48878
+ 1.48657 1.48445 1.48242 1.48046 1.47858 1.47677 1.47502
+ 1.47333 1.4717 1.47012 1.46859 1.46711 1.46568 1.46428 1.46292
+ 1.4616 1.46034 1.45923 1.45812 1.45701 1.4559 1.45479 1.45378
+ 1.45279 1.45181 1.45082 1.44983 1.44893 1.44813 1.44732
+ 1.44652 1.44571 1.44491 1.4441 1.4433 1.44249 1.44169 1.44089
+ 1.44019 1.43951 1.43883 1.43815 1.43747 1.4368 1.43612 1.43544
+ 1.43476 1.43408 1.43342 1.43283 1.43223 1.43163 1.43104
+ 1.43044 1.42984 1.42924 1.42865
+ EOD
+
+ @v[39].set(<<-'EOD')
+ 5 5.01048 5.01221 4.98887 4.76261 4.54943 4.51564 4.56249
+ 4.62621 4.68843 4.74374 4.79044 4.82972 4.86127 4.88724
+ 4.90862 4.90791 4.89858 4.89589 4.91767 5.00405 5.16956
+ 5.12391 4.7557 3.87953 3.01124 2.48482 2.20424 2.03812 1.92679
+ 1.84956 1.79256 1.74907 1.71487 1.68724 1.6644 1.64513 1.6287
+ 1.61446 1.60197 1.59095 1.58117 1.57245 1.5646 1.55752 1.55109
+ 1.54516 1.53958 1.53444 1.53008 1.52606 1.52205 1.51843
+ 1.5149 1.51146 1.50893 1.50639 1.50387 1.50133 1.4988 1.49651
+ 1.49436 1.49222 1.49007 1.48793 1.48585 1.48433 1.4828 1.48128
+ 1.47975 1.47823 1.4767 1.47518 1.47365 1.47213 1.4706 1.46912
+ 1.46795 1.46678 1.46561 1.46444 1.46327 1.4621 1.46093 1.45976
+ 1.45859 1.45741 1.45628 1.45534 1.45441 1.45347 1.45254
+ 1.4516 1.45067 1.44973 1.4488 1.44786 1.44693 1.44604 1.44539
+ 1.44475 1.4441 1.44345 1.44281 1.44216 1.44151 1.44086 1.44022
+ 1.43957 1.43892 1.43828 1.43763 1.43698 1.43633 1.43569
+ 1.43504 1.43439 1.43375 1.4331 1.43245 1.4318 1.43157 1.43089
+ 1.43001 1.43042 1.42899 1.42439 1.42216 1.43447 1.44048
+ 1.43705 1.43314 1.43039 1.42861 1.42739 1.42651 1.42548
+ 1.42488 1.4243 1.42392 1.4235 1.32443 1.31149 1.78169 2.64844
+ 3.43211 3.95252 4.20231 4.3746 4.49948 4.58929 4.65742 4.71183
+ 4.77057 4.83196 4.88354 4.92894 4.96625 4.99235 5.00651
+ 5.00941 5.00813 5.00689 5.00588 5.00504 5.00431 5.00368
+ 5.00314 5.00268 5.00228 5.00194 5.00165 5.0014 5.00118 5.001
+ 5.00085 5.00072 5.00061 5.00052 5.00044 5.00037 5.00031
+ 5.00027 5.00022 5.00019 5.00016 5.00013 5.00011 5.00009
+ 5.00008 5.00007 5.00006 5.00005 5.00004 5.00003 5.00003
+ 5.00003 5.00002 5.00002 5.00002 5.00001 5.00001 5.00001
+ 5.00001 5.00001 5.00001 5.00001 5.00001 5.00001 5.00001
+ 5.00001 5.00001 5 5 5 5 5 4.99999 4.99999 4.99999 4.99998
+ 4.99998 4.99998 4.99998 4.99998 4.99998 4.99998 4.99999
+ 4.99999 4.99999 4.99999 4.99999 4.99999 5 5 5 5 5.00001
+ 5.00002 5.00003 5.00004 5.00022 4.99974 4.99942 4.99997
+ 5.00063 5.00002 5.00003 4.99994 4.99998 4.99999 5 5 5 5
+ 5 4.99981 4.99998 5.00004 5.00036 5.00049 5.12012 5.16315
+ 5.19712 5.21835 4.87874 4.10151 3.31555 2.74207 2.38075
+ 2.15872 2.01614 1.91886 1.84852 1.79401 1.75052 1.71508
+ 1.68672 1.66467 1.64602 1.62985 1.61576 1.60343 1.59256
+ 1.58287 1.57418 1.56632 1.55922 1.55282 1.54687 1.54132
+ 1.53618 1.53143 1.52698 1.52282 1.51895 1.51527 1.5118 1.50851
+ 1.5054 1.50244 1.49963 1.49695 1.4944 1.49196 1.48963 1.4874
+ 1.48527 1.48322 1.48124 1.47934 1.47751 1.47574 1.47403
+ 1.47239 1.4708 1.46926 1.46777 1.46632 1.46491 1.46355 1.46237
+ 1.4612 1.46002 1.45884 1.45766 1.45659 1.45555 1.45451 1.45346
+ 1.45242 1.45147 1.45062 1.44978 1.44894 1.44809 1.44725
+ 1.4464 1.44556 1.44472 1.44387 1.44303 1.4423 1.44159 1.44088
+ 1.44017 1.43947 1.43876 1.43805 1.43734 1.43664 1.43593
+ 1.43524 1.43462 1.434 1.43338 1.43276 1.43213 1.43151 1.43089
+ 1.43027
+ EOD
+ end
+
+ def highlightTrace(graph)
+ entry = graph.legend_get(:current)
+ active_list = graph.legend_activate
+ if active_list.include?(entry)
+ graph.legend_deactivate(entry)
+ graph.element_deactivate(entry)
+ else
+ graph.legend_activate(entry)
+ graph.element_activate(entry)
+ end
+ end
+
+end
+
+BLT_Graph_Demo.new
+
+Tk.mainloop
diff --git a/jni/ruby/ext/tk/sample/tkextlib/blt/graph7.rb b/jni/ruby/ext/tk/sample/tkextlib/blt/graph7.rb
new file mode 100644
index 0000000..8b31b28
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkextlib/blt/graph7.rb
@@ -0,0 +1,40 @@
+#!/usr/bin/env ruby
+require 'tk'
+require 'tkextlib/blt'
+
+length = 250000
+graph = Tk::BLT::Graph.new(:title=>"Scatter Plot\n#{length} points")
+graph.xaxis_configure(:loose=>false, :title=>'X Axis Label')
+graph.yaxis_configure(:title=>'Y Axis Label')
+graph.legend_configure(:activerelief=>:sunken, :background=>'')
+
+Tk::BLT::Table.add(Tk.root, graph, [0,0], :fill=>:both)
+
+v_x = Tk::BLT::Vector.new(length)
+v_y = Tk::BLT::Vector.new(length)
+v_x.expr("random(#{v_x})")
+v_y.expr("random(#{v_y})")
+v_x.sort(v_y)
+
+plot = Tk::BLT::PlotComponent::Element.new(graph, :symbol=>:square,
+ :color=>'green4', :fill=>'green2',
+ :linewidth=>0, :outlinewidth=>1,
+ :pixels=>4, :label=>'plot',
+ :xdata=>v_x, :ydata=>v_y)
+
+Tk.root.minsize(0, 0)
+
+#graph.zoom_stack
+#graph.crosshairs
+#graph.active_legend
+#graph.closest_point
+Tk::BLT.zoom_stack(graph)
+Tk::BLT.crosshairs(graph)
+Tk::BLT.active_legend(graph)
+Tk::BLT.closest_point(graph)
+
+Tk::BLT::Busy.hold(graph)
+Tk.update
+Tk::BLT::Busy.release(graph)
+
+Tk.mainloop
diff --git a/jni/ruby/ext/tk/sample/tkextlib/blt/graph7a.rb b/jni/ruby/ext/tk/sample/tkextlib/blt/graph7a.rb
new file mode 100644
index 0000000..8def766
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkextlib/blt/graph7a.rb
@@ -0,0 +1,63 @@
+#!/usr/bin/env ruby
+require 'tk'
+require 'tkextlib/blt'
+
+file = File.join(File.dirname(File.expand_path(__FILE__)),
+ 'images', 'buckskin.gif')
+bgTexture = TkPhotoImage.new(:file=>file)
+
+TkOption.add('*Graph.Tile', bgTexture)
+TkOption.add('*Label.Tile', bgTexture)
+TkOption.add('*Frame.Tile', bgTexture)
+TkOption.add('*Htext.Tile', bgTexture)
+TkOption.add('*TileOffset', 0)
+TkOption.add('*HighlightThickness', 0)
+TkOption.add('*Element.ScaleSybols', false)
+TkOption.add('*Element.Smooth', :linear)
+TkOption.add('*activeLine.Color', 'yellow4')
+TkOption.add('*activeLine.Fill', 'yellow')
+TkOption.add('*activeLine.LineWidth', 0)
+TkOption.add('*Element.Pixels', 3)
+TkOption.add('*Graph.halo', '7i')
+
+if Tk.root.winfo_screenvisual != 'staticgray'
+ TkOption.add('*print.background', 'yellow')
+ TkOption.add('*quit.background', 'red')
+end
+
+length = 250000
+graph = Tk::BLT::Graph.new(:title=>"Scatter Plot\n#{length} points")
+graph.xaxis_configure(:loose=>false, :title=>'X Axis Label')
+graph.yaxis_configure(:title=>'Y Axis Label')
+graph.legend_configure(:activerelief=>:sunken, :background=>'')
+
+Tk::BLT::Table.add(Tk.root, graph, [0,0], :fill=>:both)
+
+v_x = Tk::BLT::Vector.new(length)
+v_y = Tk::BLT::Vector.new(length)
+v_x.expr("random(#{v_x})")
+v_y.expr("random(#{v_y})")
+v_x.sort(v_y)
+
+plot = Tk::BLT::PlotComponent::Element.new(graph, :symbol=>:square,
+ :color=>'green4', :fill=>'green2',
+ :linewidth=>0, :outlinewidth=>1,
+ :pixels=>4, :label=>'plot',
+ :xdata=>v_x, :ydata=>v_y)
+
+Tk.root.minsize(0, 0)
+
+#graph.zoom_stack
+#graph.crosshairs
+#graph.active_legend
+#graph.closest_point
+Tk::BLT.zoom_stack(graph)
+Tk::BLT.crosshairs(graph)
+Tk::BLT.active_legend(graph)
+Tk::BLT.closest_point(graph)
+
+Tk::BLT::Busy.hold(graph)
+Tk.update
+Tk::BLT::Busy.release(graph)
+
+Tk.mainloop
diff --git a/jni/ruby/ext/tk/sample/tkextlib/blt/graph7b.rb b/jni/ruby/ext/tk/sample/tkextlib/blt/graph7b.rb
new file mode 100644
index 0000000..8b00f15
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkextlib/blt/graph7b.rb
@@ -0,0 +1,41 @@
+#!/usr/bin/env ruby
+require 'tk'
+require 'tkextlib/blt'
+
+length = 250000
+graph = Tk::BLT::Graph.new(:title=>"Scatter Plot\n#{length} points")
+graph.xaxis_configure(:loose=>false, :title=>'X Axis Label')
+graph.yaxis_configure(:title=>'Y Axis Label')
+graph.legend_configure(:activerelief=>:sunken, :background=>'')
+
+Tk::BLT::Table.add(Tk.root, graph, [0,0], :fill=>:both)
+
+x = Array.new(length)
+y = Array.new(length)
+(0...length).each{|i|
+ x[i] = rand
+ y[i] = rand
+}
+
+plot = Tk::BLT::PlotComponent::Element.new(graph, :symbol=>:square,
+ :color=>'green4', :fill=>'green2',
+ :linewidth=>0, :outlinewidth=>1,
+ :pixels=>4, :label=>'plot',
+ :xdata=>x, :ydata=>y)
+
+Tk.root.minsize(0, 0)
+
+#graph.zoom_stack
+#graph.crosshairs
+#graph.active_legend
+#graph.closest_point
+Tk::BLT.zoom_stack(graph)
+Tk::BLT.crosshairs(graph)
+Tk::BLT.active_legend(graph)
+Tk::BLT.closest_point(graph)
+
+Tk::BLT::Busy.hold(graph)
+Tk.update
+Tk::BLT::Busy.release(graph)
+
+Tk.mainloop
diff --git a/jni/ruby/ext/tk/sample/tkextlib/blt/graph7c.rb b/jni/ruby/ext/tk/sample/tkextlib/blt/graph7c.rb
new file mode 100644
index 0000000..d4ed1a6
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkextlib/blt/graph7c.rb
@@ -0,0 +1,45 @@
+#!/usr/bin/env ruby
+require 'tk'
+require 'tkextlib/blt'
+
+length = 250000
+graph = Tk::BLT::Graph.new(:title=>"Scatter Plot\n#{length} points")
+graph.xaxis_configure(:loose=>false, :title=>'X Axis Label')
+graph.yaxis_configure(:title=>'Y Axis Label')
+graph.legend_configure(:activerelief=>:sunken, :background=>'')
+
+Tk::BLT::Table.add(Tk.root, graph, [0,0], :fill=>:both)
+
+v_x = Tk::BLT::Vector.new(length)
+v_y = Tk::BLT::Vector.new(length)
+x = Array.new(length)
+y = Array.new(length)
+(0...length).each{|i|
+ x[i] = rand
+ y[i] = rand
+}
+v_x.set(x)
+v_y.set(y)
+
+plot = Tk::BLT::PlotComponent::Element.new(graph, :symbol=>:square,
+ :color=>'green4', :fill=>'green2',
+ :linewidth=>0, :outlinewidth=>1,
+ :pixels=>4, :label=>'plot',
+ :xdata=>v_x, :ydata=>v_y)
+
+Tk.root.minsize(0, 0)
+
+#graph.zoom_stack
+#graph.crosshairs
+#graph.active_legend
+#graph.closest_point
+Tk::BLT.zoom_stack(graph)
+Tk::BLT.crosshairs(graph)
+Tk::BLT.active_legend(graph)
+Tk::BLT.closest_point(graph)
+
+Tk::BLT::Busy.hold(graph)
+Tk.update
+Tk::BLT::Busy.release(graph)
+
+Tk.mainloop
diff --git a/jni/ruby/ext/tk/sample/tkextlib/blt/images/buckskin.gif b/jni/ruby/ext/tk/sample/tkextlib/blt/images/buckskin.gif
new file mode 100644
index 0000000..e2d7be9
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkextlib/blt/images/buckskin.gif
Binary files differ
diff --git a/jni/ruby/ext/tk/sample/tkextlib/blt/images/chalk.gif b/jni/ruby/ext/tk/sample/tkextlib/blt/images/chalk.gif
new file mode 100644
index 0000000..30d29a7
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkextlib/blt/images/chalk.gif
Binary files differ
diff --git a/jni/ruby/ext/tk/sample/tkextlib/blt/images/qv100.t.gif b/jni/ruby/ext/tk/sample/tkextlib/blt/images/qv100.t.gif
new file mode 100644
index 0000000..1e738ee
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkextlib/blt/images/qv100.t.gif
Binary files differ
diff --git a/jni/ruby/ext/tk/sample/tkextlib/blt/images/rain.gif b/jni/ruby/ext/tk/sample/tkextlib/blt/images/rain.gif
new file mode 100644
index 0000000..d7bb417
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkextlib/blt/images/rain.gif
Binary files differ
diff --git a/jni/ruby/ext/tk/sample/tkextlib/blt/images/sample.gif b/jni/ruby/ext/tk/sample/tkextlib/blt/images/sample.gif
new file mode 100644
index 0000000..1d8a401
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkextlib/blt/images/sample.gif
Binary files differ
diff --git a/jni/ruby/ext/tk/sample/tkextlib/blt/pareto.rb b/jni/ruby/ext/tk/sample/tkextlib/blt/pareto.rb
new file mode 100644
index 0000000..bf9a1ec
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkextlib/blt/pareto.rb
@@ -0,0 +1,90 @@
+#!/usr/bin/env ruby
+
+require 'tk'
+require 'tkextlib/blt'
+
+# Example of a pareto chart.
+#
+# The pareto chart mixes line and bar elements in the same graph.
+# Each processing operating is represented by a bar element. The
+# total accumulated defects is displayed with a single line element.
+b = Tk::BLT::Barchart.new(:title=>'Defects Found During Inspection',
+ :font=>'Helvetica 12', :plotpady=>[12, 4],
+ :width=>'6i', :height=>'5i')
+Tk::BLT::Table.add(Tk.root, b, :fill=>:both)
+
+data = [
+ ["Spot Weld", 82, 'yellow'],
+ ["Lathe", 49, 'orange'],
+ ["Gear Cut", 38, 'green'],
+ ["Drill", 24, 'blue'],
+ ["Grind", 17, 'red'],
+ ["Lapping", 12, 'brown'],
+ ["Press", 8, 'purple'],
+ ["De-burr", 4, 'pink'],
+ ["Packaging", 3, 'cyan'],
+ ["Other", 12, 'magenta']
+]
+
+# Create an X-Y graph line element to trace the accumulated defects.
+b.line_create('accum', :label=>'', :symbol=>:none, :color=>'red')
+
+# Define a bitmap to be used to stipple the background of each bar.
+pattern1 = Tk::BLT::Bitmap.define([ [4, 4], [1, 2, 4, 8] ])
+
+# For each process, create a bar element to display the magnitude.
+count = 0
+sum = 0
+ydata = [0]
+xdata = [0]
+labels = []
+
+data.each{|label, value, color|
+ count += 1
+ b.element_create(label, :xdata=>count, :ydata=>value, :foreground=>color,
+ :relief=>:solid, :borderwidth=>1, :stipple=>pattern1,
+ :background=>'lightblue')
+ labels[count] = label
+ # Get the total number of defects.
+ sum += value
+ ydata << sum
+ xdata << count
+}
+
+# Configure the coordinates of the accumulated defects,
+# now that we know what they are.
+b.element_configure('accum', :xdata=>xdata, :ydata=>ydata)
+
+# Add text markers to label the percentage of total at each point.
+xdata.zip(ydata){|x, y|
+ percent = (y * 100.0) / sum
+ if x == 0
+ text = ' 0%'
+ else
+ text = '%.1f' % percent
+ end
+ b.marker_create(:text, :coords=>[x, y], :text=>text, :font=>'Helvetica 10',
+ :foreground=>'red4', :anchor=>:center, :yoffset=>-5)
+}
+
+# Display an auxillary y-axis for percentages.
+b.axis_configure('y2', :hide=>false, :min=>0.0, :max=>100.0,
+ :title=>'Percentage')
+
+# Title the y-axis
+b.axis_configure('y', :title=>'Defects')
+
+# Configure the x-axis to display the process names, instead of numbers.
+b.axis_configure('x', :title=>'Process', :rotate=>90, :subdivisions=>0,
+ :command=>proc{|w, val|
+ val = val.round
+ labels[val]? labels[val]: val
+ })
+
+# No legend needed.
+b.legend_configure(:hide=>true)
+
+# Configure the grid lines.
+b.gridline_configure(:mapx=>:x, :color=>'lightblue')
+
+Tk.mainloop
diff --git a/jni/ruby/ext/tk/sample/tkextlib/blt/plot1.rb b/jni/ruby/ext/tk/sample/tkextlib/blt/plot1.rb
new file mode 100644
index 0000000..07dff48
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkextlib/blt/plot1.rb
@@ -0,0 +1,9 @@
+#!/usr/bin/env ruby
+require 'tk'
+require 'tkextlib/blt'
+
+graph = Tk::BLT::Graph.new.pack
+plot = Tk::BLT::PlotComponent::Element.new(graph, :linewidth=>0, :label=>'foo')
+plot.data([[1.0, 3.4], [1.1, 2.8], [1.2, 3.1], [1.4, 2.9]].flatten)
+
+Tk.mainloop
diff --git a/jni/ruby/ext/tk/sample/tkextlib/blt/plot1b.rb b/jni/ruby/ext/tk/sample/tkextlib/blt/plot1b.rb
new file mode 100644
index 0000000..8a3ce82
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkextlib/blt/plot1b.rb
@@ -0,0 +1,10 @@
+#!/usr/bin/env ruby
+require 'tk'
+require 'tkextlib/blt'
+
+graph = Tk::BLT::Graph.new.pack
+plot = graph.element_create
+plot.configure(:linewidth=>0, :label=>'foo',
+ :data=>[[1.0, 3.4], [1.1, 2.8], [1.2, 3.1], [1.4, 2.9]].flatten)
+
+Tk.mainloop
diff --git a/jni/ruby/ext/tk/sample/tkextlib/blt/readme.txt b/jni/ruby/ext/tk/sample/tkextlib/blt/readme.txt
new file mode 100644
index 0000000..8ac1044
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkextlib/blt/readme.txt
@@ -0,0 +1,2 @@
+The scripts and image files in this directory are based on demo files
+of Tcl/Tk's BLT extension.
diff --git a/jni/ruby/ext/tk/sample/tkextlib/blt/scripts/stipples.rb b/jni/ruby/ext/tk/sample/tkextlib/blt/scripts/stipples.rb
new file mode 100644
index 0000000..47f3c4d
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkextlib/blt/scripts/stipples.rb
@@ -0,0 +1,156 @@
+$stipples = {} unless $stipples
+
+$stipples['bdiagonal1'] = Tk::BLT::Bitmap.new(<<EOD)
+#define bdiagonal1_width 8
+#define bdiagonal1_height 8
+static unsigned char bdiagonal1_bits[] = {
+ 0x88, 0x44, 0x22, 0x11, 0x88, 0x44, 0x22, 0x11};
+EOD
+
+$stipples['bdiagonal2'] = Tk::BLT::Bitmap.new(<<EOD)
+#define bdiagonal2_width 8
+#define bdiagonal2_height 8
+static unsigned char bdiagonal2_bits[] = {
+ 0x08, 0x04, 0x02, 0x01, 0x80, 0x40, 0x20, 0x10};
+EOD
+
+$stipples['checker2'] = Tk::BLT::Bitmap.new(<<EOD)
+#define checker2_width 8
+#define checker2_height 8
+static unsigned char checker2_bits[] = {
+ 0x33, 0x33, 0xcc, 0xcc, 0x33, 0x33, 0xcc, 0xcc};
+EOD
+
+
+$stipples['checker3'] = Tk::BLT::Bitmap.new(<<EOD)
+#define checker3_width 8
+#define checker3_height 8
+static unsigned char checker3_bits[] = {
+ 0x0f, 0x0f, 0x0f, 0x0f, 0xf0, 0xf0, 0xf0, 0xf0};
+EOD
+
+$stipples['cross1'] = Tk::BLT::Bitmap.new(<<EOD)
+#define cross1_width 8
+#define cross1_height 8
+static unsigned char cross_bits[] = {
+ 0xff, 0xaa, 0xff, 0xaa, 0xff, 0xaa, 0xff, 0xaa};
+EOD
+
+$stipples['cross2'] = Tk::BLT::Bitmap.new(<<EOD)
+#define cross2_width 8
+#define cross2_height 8
+static unsigned char cross2_bits[] = {
+ 0xff, 0x88, 0x88, 0x88, 0xff, 0x88, 0x88, 0x88};
+EOD
+
+$stipples['cross3'] = Tk::BLT::Bitmap.new(<<EOD)
+#define cross3_width 8
+#define cross3_height 8
+static unsigned char cross3_bits[] = {
+ 0xff, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01};
+EOD
+
+$stipples['crossdiag'] = Tk::BLT::Bitmap.new(<<EOD)
+#define crossdiag_width 8
+#define crossdiag_height 8
+static unsigned char crossdiag2_bits[] = {
+ 0x18, 0x24, 0x42, 0x81, 0x81, 0x42, 0x24, 0x18};
+EOD
+
+$stipples['dot1'] = Tk::BLT::Bitmap.new(<<EOD)
+#define dot1_width 8
+#define dot1_height 8
+static unsigned char dot1_bits[] = {
+ 0x55, 0xaa, 0x55, 0xaa, 0x55, 0xaa, 0x55, 0xaa};
+EOD
+
+$stipples['dot2'] = Tk::BLT::Bitmap.new(<<EOD)
+#define dot2_width 8
+#define dot2_height 8
+static unsigned char dot2_bits[] = {
+ 0x55, 0x00, 0x55, 0x00, 0x55, 0x00, 0x55, 0x00};
+EOD
+
+$stipples['dot3'] = Tk::BLT::Bitmap.new(<<EOD)
+#define dot3_width 8
+#define dot3_height 8
+static unsigned char dot3_bits[] = {
+ 0x11, 0x00, 0x00, 0x00, 0x11, 0x00, 0x00, 0x00};
+EOD
+
+$stipples['dot4'] = Tk::BLT::Bitmap.new(<<EOD)
+#define dot4_width 8
+#define dot4_height 8
+static unsigned char dot4_bits[] = {
+ 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
+EOD
+
+$stipples['fdiagonal1'] = Tk::BLT::Bitmap.new(<<EOD)
+#define fdiagonal1_width 8
+#define fdiagonal1_height 8
+static unsigned char fdiagonal1_bits[] = {
+ 0x11, 0x22, 0x44, 0x88, 0x11, 0x22, 0x44, 0x88};
+EOD
+
+$stipples['fdiagonal2'] = Tk::BLT::Bitmap.new(<<EOD)
+#define fdiagonal2_width 8
+#define fdiagonal2_height 8
+static unsigned char fdiagonal2_bits[] = {
+ 0x10, 0x20, 0x40, 0x80, 0x01, 0x02, 0x04, 0x08};
+EOD
+
+$stipples['hline1'] = Tk::BLT::Bitmap.new(<<EOD)
+#define hline1_width 8
+#define hline1_height 8
+static unsigned char hline1_bits[] = {
+ 0xff, 0x00, 0xff, 0x00, 0xff, 0x00, 0xff, 0x00};
+EOD
+
+$stipples['hline2'] = Tk::BLT::Bitmap.new(<<EOD)
+#define hline2_width 8
+#define hline2_height 8
+static unsigned char hline2_bits[] = {
+ 0xff, 0xff, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00};
+EOD
+
+$stipples['lbottom'] = Tk::BLT::Bitmap.new(<<EOD)
+#define lbottom_width 8
+#define lbottom_height 8
+static unsigned char lbottom_bits[] = {
+ 0x00, 0x11, 0x11, 0x77, 0x00, 0x11, 0x11, 0x77};
+EOD
+
+$stipples['ltop'] = Tk::BLT::Bitmap.new(<<EOD)
+#define ltop_width 8
+#define ltop_height 8
+static unsigned char ltop_bits[] = {
+ 0xee, 0x88, 0x88, 0x00, 0xee, 0x88, 0x88, 0x00};
+EOD
+
+$stipples['rbottom'] = Tk::BLT::Bitmap.new(<<EOD)
+#define rbottom_width 8
+#define rbottom_height 8
+static unsigned char rbottom_bits[] = {
+ 0x00, 0x88, 0x88, 0xee, 0x00, 0x88, 0x88, 0xee};
+EOD
+
+$stipples['rtop'] = Tk::BLT::Bitmap.new(<<EOD)
+#define rtop_width 8
+#define rtop_height 8
+static unsigned char rtop_bits[] = {
+ 0x77, 0x11, 0x11, 0x00, 0x77, 0x11, 0x11, 0x00};
+EOD
+
+$stipples['vline1'] = Tk::BLT::Bitmap.new(<<EOD)
+#define vline1_width 8
+#define vline1_height 8
+static unsigned char vline1_bits[] = {
+ 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55};
+EOD
+
+$stipples['vline2'] = Tk::BLT::Bitmap.new(<<EOD)
+#define vline2_width 8
+#define vline2_height 8
+static unsigned char vline2_bits[] = {
+ 0x33, 0x33, 0x33, 0x33, 0x33, 0x33, 0x33, 0x33};
+EOD
diff --git a/jni/ruby/ext/tk/sample/tkextlib/blt/winop1.rb b/jni/ruby/ext/tk/sample/tkextlib/blt/winop1.rb
new file mode 100644
index 0000000..97c31aa
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkextlib/blt/winop1.rb
@@ -0,0 +1,40 @@
+#!/usr/bin/env ruby
+require 'tk'
+require 'tkextlib/blt'
+
+file = File.join(File.dirname(File.expand_path(__FILE__)),
+ 'images', 'sample.gif')
+if File.exist?(file)
+ src = TkPhotoImage.new(:file=>file)
+else
+ fail RuntimeError, 'no image file'
+end
+
+width = src.width
+height = src.height
+
+TkOption.add('*Label.font', '*helvetica*10*')
+TkOption.add('*Label.background', 'white')
+
+l_img0 = TkLabel.new(:image=>src)
+l_hdr0 = TkLabel.new(:text=>"#{width} x #{height}")
+l_ftr0 = TkLabel.new(:text=>'100%')
+Tk.root.background('white')
+
+(2..10).each{|i|
+ iw = width/i
+ ih = height/i
+ r = '%6g'%(100.0/i)
+ dst = TkPhotoImage.new(:width=>iw, :height=>ih)
+ Tk::BLT::Winop.image_resample(src, dst, :sinc)
+ l_hdr = TkLabel.new(:text=>"#{iw} x #{ih}")
+ l_ftr = TkLabel.new(:text=>"#{r}%")
+ l_img = TkLabel.new(:image=>dst)
+ Tk::BLT::Table.add(Tk.root,
+ [0,i], l_hdr,
+ [1,i], l_img,
+ [2,i], l_ftr)
+ Tk.update
+}
+
+Tk.mainloop
diff --git a/jni/ruby/ext/tk/sample/tkextlib/blt/winop2.rb b/jni/ruby/ext/tk/sample/tkextlib/blt/winop2.rb
new file mode 100644
index 0000000..d59c43b
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkextlib/blt/winop2.rb
@@ -0,0 +1,28 @@
+#!/usr/bin/env ruby
+require 'tk'
+require 'tkextlib/blt'
+
+file = File.join(File.dirname(File.expand_path(__FILE__)),
+ 'images', 'qv100.t.gif')
+if File.exist?(file)
+ src = TkPhotoImage.new(:file=>file)
+else
+ fail RuntimeError, 'no image file'
+end
+
+width = src.width
+height = src.height
+
+TkOption.add('*Label.font', '*helvetica*10*')
+TkOption.add('*Label.background', 'white')
+
+[0, 90, 180, 270, 360, 45].each_with_index{|r, i|
+ dest = TkPhotoImage.new
+ Tk::BLT::Winop.image_rotate(src, dest, r)
+ l_txt = TkLabel.new(:text=>"#{r} degrees")
+ l_img = TkLabel.new(:image=>dest)
+ Tk::BLT::Table.add(Tk.root, [0,i], l_img, [1,i], l_txt)
+ Tk.update
+}
+
+Tk.mainloop
diff --git a/jni/ruby/ext/tk/sample/tkextlib/bwidget/Orig_LICENSE.txt b/jni/ruby/ext/tk/sample/tkextlib/bwidget/Orig_LICENSE.txt
new file mode 100644
index 0000000..16ddca4
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkextlib/bwidget/Orig_LICENSE.txt
@@ -0,0 +1,53 @@
+
+ ######################################################################
+ ### The following text is the original 'LICENSE.txt' of BWidget ###
+ ### extension. ###
+ ### Original Tcl source files are not include in this directory, ###
+ ### because of all of them are rewritten to Ruby files. ###
+ ### However, the bitmap data files ('bwidgtet.xbm' and 'x1.xbm') ###
+ ### included in this directory are quoted from BWidget source ###
+ ### archive. So, those bitmaps are under the following license. ###
+ ######################################################################
+
+
+BWidget ToolKit
+Copyright (c) 1998-1999 UNIFIX.
+Copyright (c) 2001-2002 ActiveState Corp.
+
+The following terms apply to all files associated with the software
+unless explicitly disclaimed in individual files.
+
+The authors hereby grant permission to use, copy, modify, distribute,
+and license this software and its documentation for any purpose, provided
+that existing copyright notices are retained in all copies and that this
+notice is included verbatim in any distributions. No written agreement,
+license, or royalty fee is required for any of the authorized uses.
+Modifications to this software may be copyrighted by their authors
+and need not follow the licensing terms described here, provided that
+the new terms are clearly indicated on the first page of each file where
+they apply.
+
+IN NO EVENT SHALL THE AUTHORS OR DISTRIBUTORS BE LIABLE TO ANY PARTY
+FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
+ARISING OUT OF THE USE OF THIS SOFTWARE, ITS DOCUMENTATION, OR ANY
+DERIVATIVES THEREOF, EVEN IF THE AUTHORS HAVE BEEN ADVISED OF THE
+POSSIBILITY OF SUCH DAMAGE.
+
+THE AUTHORS AND DISTRIBUTORS SPECIFICALLY DISCLAIM ANY WARRANTIES,
+INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE, AND NON-INFRINGEMENT. THIS SOFTWARE
+IS PROVIDED ON AN "AS IS" BASIS, AND THE AUTHORS AND DISTRIBUTORS HAVE
+NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR
+MODIFICATIONS.
+
+GOVERNMENT USE: If you are acquiring this software on behalf of the
+U.S. government, the Government shall have only "Restricted Rights"
+in the software and related documentation as defined in the Federal
+Acquisition Regulations (FARs) in Clause 52.227.19 (c) (2). If you
+are acquiring the software on behalf of the Department of Defense, the
+software shall be classified as "Commercial Computer Software" and the
+Government shall have only "Restricted Rights" as defined in Clause
+252.227-7013 (c) (1) of DFARs. Notwithstanding the foregoing, the
+authors grant the U.S. Government and others acting in its behalf
+permission to use and distribute the software in accordance with the
+terms specified in this license.
diff --git a/jni/ruby/ext/tk/sample/tkextlib/bwidget/basic.rb b/jni/ruby/ext/tk/sample/tkextlib/bwidget/basic.rb
new file mode 100644
index 0000000..060baf8
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkextlib/bwidget/basic.rb
@@ -0,0 +1,198 @@
+#
+# basic demo --- called from demo.rb
+#
+unless Object.const_defined?('DemoVar')
+ fail RuntimeError, "This is NOT a stand alone script. This script is called from 'demo.rb'. "
+end
+
+module DemoBasic
+ @@var = TkVariable.new_hash
+ @@after = nil
+ @@count = 0
+
+ def self.create(nb)
+ frame = nb.insert('end', 'demoBasic', :text=>'Basic')
+ topf = TkFrame.new(frame)
+
+ titf1 = Tk::BWidget::TitleFrame.new(topf, :text=>'Label')
+ titf2 = Tk::BWidget::TitleFrame.new(topf, :text=>'Entry')
+
+ titf3 = Tk::BWidget::TitleFrame.new(frame, :text=>'Button and ArrowButton')
+
+ _label(titf1.get_frame)
+ _entry(titf2.get_frame)
+ _button(titf3.get_frame)
+
+ Tk.pack(titf1, titf2, :side=>:left, :fill=>:both, :padx=>4, :expand=>true)
+ topf.pack(:pady=>2, :fill=>:x)
+ titf3.pack(:pady=>2, :padx=>4, :fill=>:x)
+ end
+
+ def self._label(parent)
+ lab = Tk::BWidget::Label.new(parent, :text=>'This is a Label widget',
+ :helptext=>'Label widget')
+ chk = TkCheckbutton.new(parent, :text=>'Disabled',
+ :variable=>@@var.ref(lab, 'state'),
+ :onvalue=>'disabled', :offvalue=>'normal',
+ :command=>proc{lab[:state] = @@var[lab, 'state']})
+ lab.pack(:anchor=>:w, :pady=>4)
+ chk.pack(:anchor=>:w)
+ end
+
+ def self._entry(parent)
+ ent = Tk::BWidget::Entry.new(parent, :text=>'Press enter',
+ :helptext=>'Entry widtet',
+ :command=>proc{
+ @@var['entcmd'] = 'command called'
+ Tk.after(500, proc{@@var['entcmd'] = ''})
+ })
+
+ chk1 = TkCheckbutton.new(parent, :text=>'Disabled',
+ :variable=>@@var.ref(ent, 'state'),
+ :onvalue=>'disabled', :offvalue=>'normal',
+ :command=>proc{ent.state = @@var[ent, 'state']})
+
+ chk2 = TkCheckbutton.new(parent, :text=>'Non editable',
+ :variable=>@@var.ref(ent, 'editable'),
+ :onvalue=>false, :offvalue=>true,
+ :command=>proc{
+ ent.editable = @@var[ent, 'editable']
+ })
+
+ lab = TkLabel.new(parent, :textvariable=>@@var.ref('entcmd'),
+ :foreground=>'red')
+
+ ent.pack(:pady=>4, :anchor=>:w)
+ Tk.pack(chk1, chk2, :anchor=>:w)
+ lab.pack(:pady=>4)
+ end
+
+ def self._button(parent)
+ frame = TkFrame.new(parent)
+ but = Tk::BWidget::Button.new(frame, :text=>'Press me!',
+ :repeatdelay=>300,
+ :command=>proc{_butcmd('command')},
+ :helptext=>'This is a Button widget')
+
+ sep1 = Tk::BWidget::Separator.new(frame, :orient=>:vertical)
+ arr1 = Tk::BWidget::ArrowButton.new(frame, :type=>:button,
+ :width=>25, :height=>25, :repeatdelay=>300,
+ :command=>proc{_butcmd('command')},
+ :helptext=>"This is an ArrowButton widget\nof type button")
+
+ sep2 = Tk::BWidget::Separator.new(frame, :orient=>:vertical)
+ arr2 = Tk::BWidget::ArrowButton.new(frame, :type=>:arrow,
+ :width=>25, :height=>25, :relief=>:sunken,
+ :ipadx=>0, :ipady=>0, :repeatdelay=>300,
+ :command=>proc{_butcmd('command')},
+ :helptext=>"This is an ArrowButton widget\nof type arrow")
+
+ but.pack(:side=>:left, :padx=>4)
+ sep1.pack(:side=>:left, :padx=>4, :fill=>:y)
+ arr1.pack(:side=>:left, :padx=>4)
+ sep2.pack(:side=>:left, :padx=>4, :fill=>:y)
+ arr2.pack(:side=>:left, :padx=>4)
+ frame.pack
+
+ Tk::BWidget::Separator.new(parent,
+ :orient=>:horizontal).pack(:fill=>:x, :pady=>10)
+
+ labf1 = Tk::BWidget::LabelFrame.new(parent, :text=>'Command',
+ :side=>:top, :anchor=>:w,
+ :relief=>:sunken, :borderwidth=>1)
+ subf = labf1.get_frame
+ chk1 = TkCheckbutton.new(subf, :text=>'Disabled',
+ :variable=>@@var.ref('bstate'),
+ :onvalue=>'disabled', :offvalue=>'normal',
+ :command=>proc{_bstate(@@var['bstate'],
+ but, arr1, arr2)})
+ chk2 = TkCheckbutton.new(subf, :text=>"Use armcommand/\ndisarmcommand",
+ :variable=>@@var.ref('barmcmd'),
+ :command=>proc{_barmcmd(@@var['barmcmd'],
+ but, arr1, arr2)})
+ Tk.pack(chk1, chk2, :anchor=>:w)
+
+ label = TkLabel.new(parent, :textvariable=>@@var.ref('butcmd'),
+ :foreground=>'red').pack(:side=>:bottom, :pady=>4)
+
+ labf2 = Tk::BWidget::LabelFrame.new(parent, :text=>'Direction',
+ :side=>:top, :anchor=>:w,
+ :relief=>:sunken, :borderwidth=>1)
+ subf = labf2.get_frame
+ @@var['bside'] = :top
+ [:top, :left, :bottom, :right].each{|dir|
+ TkRadiobutton.new(subf, :text=>"#{dir} arrow",
+ :variable=>@@var.ref('bside'), :value=>dir,
+ :command=>proc{_bside(@@var['bside'], arr1, arr2)}
+ ).pack(:anchor=>:w)
+ }
+
+ labf3 = Tk::BWidget::LabelFrame.new(parent, :text=>'Relief',
+ :side=>:top, :anchor=>:w,
+ :relief=>:sunken, :borderwidth=>1)
+ subf = labf3.get_frame
+ @@var['brelief'] = :raised
+ [ %w(raised sunken ridge groove), %w(flat solid link)].each{|lrelief|
+ f = TkFrame.new(subf)
+ lrelief.each{|relief|
+ TkRadiobutton.new(f, :text=>relief,
+ :variable=>@@var.ref('brelief'), :value=>relief,
+ :command=>proc{
+ _brelief(@@var['brelief'], but, arr1, arr2)
+ }).pack(:anchor=>:w)
+ }
+ f.pack(:side=>:left, :padx=>2, :anchor=>:n)
+ }
+ Tk.pack(labf1, labf2, labf3, :side=>:left, :fill=>:y, :padx=>4)
+ end
+
+ def self._bstate(state, but, arr1, arr2)
+ [but, arr1, arr2].each{|b| b[:state] = state}
+ end
+
+ def self._brelief(relief, but, arr1, arr2)
+ but[:relief] = relief
+ if relief.to_s != 'link'
+ [arr1, arr2].each{|arr| arr[:relief] = relief}
+ end
+ end
+
+ def self._bside(side, *args)
+ args.each{|arr| arr[:dir] = side}
+ end
+
+ def self._barmcmd(value, but, arr1, arr2)
+ if TkComm.bool(value)
+ but.configure(:armcommand=>proc{_butcmd('arm')},
+ :disarmcommand=>proc{_butcmd('disarm')},
+ :command=>'')
+ [arr1, arr2].each{|arr|
+ arr.configure(:armcommand=>proc{_butcmd('arm')},
+ :disarmcommand=>proc{_butcmd('disarm')},
+ :command=>'')
+ }
+ else
+ but.configure(:armcommand=>'', :disarmcommand=>'',
+ :command=>proc{_butcmd('command')})
+ [arr1, arr2].each{|arr|
+ arr.configure(:armcommand=>'', :disarmcommand=>'',
+ :command=>proc{_butcmd('command')})
+ }
+ end
+ end
+
+ def self._butcmd(reason)
+ unless @@after
+ @@after = TkTimer.new(500, 1, proc{@@var['butcmd'] = ''})
+ end
+ @@after.stop
+ if (reason == 'arm')
+ @@count += 1
+ @@var['butcmd'] = "#{reason} command called (#{@@count})"
+ else
+ @@count = 0
+ @@var['butcmd'] = "#{reason} command called"
+ end
+ @@after.start
+ end
+end
diff --git a/jni/ruby/ext/tk/sample/tkextlib/bwidget/bwidget.xbm b/jni/ruby/ext/tk/sample/tkextlib/bwidget/bwidget.xbm
new file mode 100644
index 0000000..5451ebb
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkextlib/bwidget/bwidget.xbm
@@ -0,0 +1,46 @@
+#define bwidget_width 76
+#define bwidget_height 64
+static char bwidget_bits[] = {
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xf0,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0xf0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xf0,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xf0,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0xf0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xf0,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xf0,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0xf0,0x00,0xb6,0x6d,0xdb,0x16,0x00,0x00,0x00,0x00,0xf0,
+ 0x00,0xdb,0xb6,0x6d,0xab,0x00,0x00,0x00,0x00,0xf0,0x00,0x55,0x55,0x55,0x75,
+ 0x01,0x00,0x00,0x00,0xf0,0x00,0x6d,0xdb,0xb6,0xad,0x02,0x00,0x00,0x00,0xf0,
+ 0x00,0xb6,0x6d,0xdb,0xb6,0x05,0x00,0x00,0x00,0xf0,0x00,0x55,0x55,0x55,0x55,
+ 0x05,0x00,0x00,0x00,0xf0,0x00,0xda,0xb6,0xad,0x6d,0x0b,0x00,0x00,0x00,0xf0,
+ 0x00,0x6b,0x03,0xc0,0xb6,0x05,0x00,0x00,0x00,0xf0,0x00,0x56,0x05,0x00,0x55,
+ 0x0d,0x00,0x00,0x00,0xf0,0x00,0xbb,0x05,0x80,0xdb,0x06,0x00,0x00,0x00,0xf0,
+ 0x00,0xca,0x06,0x00,0x6c,0x0b,0x00,0x00,0x00,0xf0,0x00,0xb6,0x02,0x00,0xaa,
+ 0x0a,0x00,0x00,0x00,0xf0,0x00,0xab,0x05,0x00,0x6c,0x0b,0x00,0x00,0x00,0xf0,
+ 0x00,0xdd,0x06,0x00,0xb6,0x05,0x00,0x00,0x00,0xf0,0x00,0xaa,0x02,0x00,0x55,
+ 0x05,0x00,0x00,0x00,0xf0,0x00,0xb7,0x05,0xc0,0xda,0x02,0x00,0x00,0x00,0xf0,
+ 0x00,0xd9,0x06,0x50,0x6b,0x01,0x00,0x00,0x00,0xf0,0x00,0x56,0xb5,0xad,0xad,
+ 0x00,0x00,0x00,0x00,0xf0,0x00,0xdb,0xd6,0x76,0x15,0x00,0x00,0x00,0x00,0xf0,
+ 0x00,0x6a,0xab,0xaa,0x2d,0x00,0x00,0x00,0x00,0xf0,0x00,0x56,0x75,0xad,0xb6,
+ 0x02,0x00,0x00,0x00,0xf0,0x00,0xbb,0xad,0xd6,0xaa,0x05,0x00,0x00,0x00,0xf0,
+ 0x00,0xca,0xb6,0x6b,0xdb,0x2a,0x00,0x00,0x00,0xf0,0x00,0x77,0xd5,0x5c,0x6d,
+ 0x2d,0x00,0x00,0x00,0xf0,0x00,0x99,0x05,0x00,0xaa,0x56,0x00,0x00,0x00,0xf0,
+ 0x00,0xee,0x06,0x00,0x6c,0xbb,0x00,0x00,0x00,0xf0,0x00,0xaa,0x02,0x00,0xb0,
+ 0x55,0x00,0x00,0x00,0xf0,0x00,0x55,0x05,0x00,0xa8,0xd6,0x00,0x00,0x00,0xf0,
+ 0x00,0xee,0x06,0x00,0xd0,0x6a,0x00,0x00,0x00,0xf0,0x00,0x55,0x03,0x00,0x68,
+ 0xb7,0xfc,0x00,0x7e,0xf0,0x00,0x6d,0x05,0x00,0xa8,0xaa,0xfc,0x80,0x7e,0xf0,
+ 0x00,0xb6,0x05,0x00,0x50,0xbb,0xfe,0x01,0x7e,0xf0,0x00,0x55,0x05,0x00,0x78,
+ 0xad,0xfe,0x81,0x1f,0xf0,0x00,0xb6,0x05,0x00,0xa4,0xb5,0xfe,0x81,0x1f,0xf0,
+ 0x00,0x5b,0x05,0x80,0xba,0x56,0xfe,0x83,0x1f,0xf0,0x00,0xaa,0x6b,0x5b,0xd5,
+ 0x5a,0xff,0x85,0x1f,0xf0,0x00,0xdb,0x5a,0xad,0x57,0x2b,0xff,0xc7,0x0f,0xf0,
+ 0x00,0x6d,0xad,0xd5,0x6a,0x0d,0xff,0xc7,0x0f,0xf0,0x00,0xaa,0xd6,0xb6,0xba,
+ 0x05,0xdf,0xc7,0x0f,0xf0,0x00,0xb7,0xb5,0x5a,0xab,0x8a,0xdf,0xcf,0x0f,0xf0,
+ 0x00,0xd9,0x5a,0xab,0x6d,0x8f,0xcf,0xef,0x07,0xf0,0x00,0x56,0xad,0x75,0xb5,
+ 0xaf,0x8f,0xef,0x07,0xf0,0x00,0xb5,0xeb,0x5a,0x00,0x9f,0xcf,0xef,0x07,0xf0,
+ 0x00,0x00,0x00,0x00,0x00,0xff,0x8f,0xff,0x07,0xf0,0x00,0x00,0x00,0x00,0x00,
+ 0xfe,0x87,0xff,0x03,0xf0,0x00,0x00,0x00,0x00,0x00,0xff,0x03,0xff,0x03,0xf0,
+ 0x00,0x00,0x00,0x00,0x00,0xfe,0x03,0xff,0x03,0xf0,0x00,0x00,0x00,0x00,0x00,
+ 0xfe,0x03,0xff,0x01,0xf0,0x00,0x00,0x00,0x00,0x00,0xfc,0x01,0xff,0x03,0xf0,
+ 0x00,0x00,0x00,0x00,0x00,0xfe,0x01,0xfe,0x01,0xf0,0x00,0x00,0x00,0x00,0x00,
+ 0xfc,0x01,0xfe,0x01,0xf0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xf0,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xf0,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0xf0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xf0,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xf0};
diff --git a/jni/ruby/ext/tk/sample/tkextlib/bwidget/demo.rb b/jni/ruby/ext/tk/sample/tkextlib/bwidget/demo.rb
new file mode 100644
index 0000000..3eb9881
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkextlib/bwidget/demo.rb
@@ -0,0 +1,243 @@
+#!/usr/bin/env ruby
+require 'tk'
+require 'tkextlib/bwidget'
+
+module DemoVar
+ @_wfont = nil
+ @notebook = nil
+ @mainframe = nil
+ @status = TkVariable.new
+ @prgtext = TkVariable.new
+ @prgindic = TkVariable.new
+ @font = nil
+ @font_name = nil
+ @toolbar1 = TkVariable.new(true)
+ @toolbar2 = TkVariable.new(true)
+end
+class << DemoVar
+ attr_accessor :_wfont, :notebook, :mainframe, :font, :font_name
+ attr_reader :status, :prgtext, :prgindic, :toolbar1, :toolbar2
+end
+
+class BWidget_Demo
+ DEMODIR = File.dirname(File.expand_path(__FILE__))
+
+ %w(manager basic select dnd tree tmpldlg).each{|f|
+ require File.join(DEMODIR, f << '.rb')
+ }
+
+ def initialize
+ TkOption.add('*TitleFrame.l.font', 'helvetica 11 bold italic')
+
+ root = TkRoot.new(:title=>'BWidget demo')
+ root.withdraw
+
+ _create
+
+ Tk::BWidget.place(root, 0, 0, :center)
+ root.deiconify
+ root.raise
+ root.focus(true)
+
+ root.geometry(root.geometry)
+ end
+
+ def _create
+ DemoVar.prgtext.value = 'Please wait while loading font...'
+ DemoVar.prgindic.value = -1
+
+ intro = _create_intro
+
+ Tk.update
+
+ Tk::BWidget::SelectFont.load_font
+
+ descmenu = [
+ '&File', 'all', 'file', 0, [
+ ['command', 'E&xit', [], 'Exit BWidget demo', [],
+ {:command=>proc{exit}}]
+ ],
+ '&Options', 'all', 'options', 0, [
+ ['checkbutton', 'Toolbar &1', ['all', 'option'],
+ 'Show/hide toolbar 1', [],
+ { :variable=>DemoVar.toolbar1,
+ :command=>proc{
+ DemoVar.mainframe.show_toolbar(0, DemoVar.toolbar1.value)
+ }
+ }
+ ],
+ ['checkbutton', 'Toolbar &2', ['all', 'option'],
+ 'Show/hide toolbar 2', [],
+ { :variable=>DemoVar.toolbar2,
+ :command=>proc{
+ DemoVar.mainframe.show_toolbar(1, DemoVar.toolbar2.value)
+ }
+ }
+ ]
+ ]
+ ]
+
+ DemoVar.prgtext.value = 'Creating MainFrame...'
+ DemoVar.prgindic.value = 0
+
+ DemoVar.mainframe = Tk::BWidget::MainFrame.new(
+ :menu=>descmenu,
+ :textvariable=>DemoVar.status,
+ :progressvar=>DemoVar.prgindic
+ )
+
+ # toobar 1 creation
+ DemoVar.prgindic.numeric += 1
+
+ DemoVar.mainframe.add_toolbar{|tb1|
+ Tk::BWidget::ButtonBox.new(tb1, :spacing=>0, :padx=>1, :pady=>1){|bbox|
+ add(:image=>Tk::BWidget::Bitmap.new('new'),
+ :highlightthickness=>0, :takefocus=>0, :relief=>:link,
+ :borderwidth=>1, :padx=>1, :pady=>1,
+ :command=>proc{puts 'select "Create a new file" icon'},
+ :helptext=>"Create a new file")
+
+ add(:image=>Tk::BWidget::Bitmap.new('open'),
+ :highlightthickness=>0, :takefocus=>0, :relief=>:link,
+ :borderwidth=>1, :padx=>1, :pady=>1,
+ :command=>proc{puts 'select "Open an existing file" icon'},
+ :helptext=>"Open an existing file")
+
+ add(:image=>Tk::BWidget::Bitmap.new('save'),
+ :highlightthickness=>0, :takefocus=>0, :relief=>:link,
+ :borderwidth=>1, :padx=>1, :pady=>1,
+ :command=>proc{puts 'select "Save file" icon'},
+ :helptext=>"Save file")
+
+ pack(:side=>:left, :anchor=>:w)
+ }
+
+ Tk::BWidget::Separator.new(tb1, :orient=>:vertical){
+ pack(:side=>:left, :fill=>:y, :padx=>4, :anchor=>:w)
+ }
+
+ DemoVar.prgindic.numeric += 1
+
+ Tk::BWidget::ButtonBox.new(tb1, :spacing=>0, :padx=>1, :pady=>1){|bbox|
+ add(:image=>Tk::BWidget::Bitmap.new('cut'),
+ :highlightthickness=>0, :takefocus=>0, :relief=>:link,
+ :borderwidth=>1, :padx=>1, :pady=>1,
+ :command=>proc{puts 'select "Cut selection" icon'},
+ :helptext=>"Cut selection")
+
+ add(:image=>Tk::BWidget::Bitmap.new('copy'),
+ :highlightthickness=>0, :takefocus=>0, :relief=>:link,
+ :borderwidth=>1, :padx=>1, :pady=>1,
+ :command=>proc{puts 'select "Copy selection" icon'},
+ :helptext=>"Copy selection")
+
+ add(:image=>Tk::BWidget::Bitmap.new('paste'),
+ :highlightthickness=>0, :takefocus=>0, :relief=>:link,
+ :borderwidth=>1, :padx=>1, :pady=>1,
+ :command=>proc{puts 'select "Paste selection" icon'},
+ :helptext=>"Paste selection")
+
+ pack(:side=>:left, :anchor=>:w)
+ }
+ }
+
+ # toolbar 2 creation
+ DemoVar.prgindic.numeric += 1
+
+ tb2 = DemoVar.mainframe.add_toolbar
+ DemoVar._wfont = Tk::BWidget::SelectFont::Toolbar.new(tb2,
+ :command=>proc{update_font(DemoVar._wfont[:font])}
+ )
+ DemoVar.font = DemoVar._wfont[:font]
+ DemoVar._wfont.pack(:side=>:left, :anchor=>:w)
+
+ DemoVar.mainframe.add_indicator(
+ :text=>"BWidget #{Tk::BWidget.package_version}"
+ )
+ DemoVar.mainframe.add_indicator(:textvariable=>'tk_patchLevel')
+
+ # NoteBook creation
+ DemoVar.notebook = Tk::BWidget::NoteBook.new(DemoVar.mainframe.get_frame)
+
+ DemoVar.prgtext.value = "Creating Manager..."
+ DemoVar.prgindic.numeric += 1
+ DemoManager.create(DemoVar.notebook)
+
+ DemoVar.prgtext.value = "Creating Basic..."
+ DemoVar.prgindic.numeric += 1
+ DemoBasic.create(DemoVar.notebook)
+
+ DemoVar.prgtext.value = "Creating Select..."
+ DemoVar.prgindic.numeric += 1
+ DemoSelect.create(DemoVar.notebook)
+
+ DemoVar.prgtext.value = "Creating Dialog..."
+ DemoVar.prgindic.numeric += 1
+ DemoDialog.create(DemoVar.notebook)
+
+ DemoVar.prgtext.value = "Creating Drag and Drop..."
+ DemoVar.prgindic.numeric += 1
+ DemoDnD.create(DemoVar.notebook)
+
+ DemoVar.prgtext.value = "Creating Tree..."
+ DemoVar.prgindic.numeric += 1
+ DemoTree.create(DemoVar.notebook)
+
+ DemoVar.prgtext.value = "Done"
+ DemoVar.prgindic.numeric += 1
+
+ DemoVar.notebook.compute_size
+ DemoVar.notebook.pack(:fill=>:both, :expand=>true, :padx=>4, :pady=>4)
+ DemoVar.notebook.raise(DemoVar.notebook.get_page(0))
+
+ DemoVar.mainframe.pack(:fill=>:both, :expand=>true)
+
+ Tk.update_idletasks
+
+ intro.destroy
+ end
+
+ def update_font(newfont)
+ root = Tk.root
+ root[:cursor] = 'watch'
+ if newfont != '' && DemoVar.font != newfont
+ DemoVar._wfont[:font] = newfont
+ DemoVar.notebook[:font] = newfont
+ DemoVar.font = newfont
+ end
+ root[:cursor] = ''
+ end
+
+ def _create_intro
+ top = TkToplevel.new(:relief=>:raised, :borderwidth=>2)
+ top.withdraw
+ top.overrideredirect(true)
+
+ ximg = TkLabel.new(top, :bitmap=>"@#{File.join(DEMODIR,'x1.xbm')}",
+ :foreground=>'grey90', :background=>'white')
+ bwimg = TkLabel.new(ximg, :bitmap=>"@#{File.join(DEMODIR,'bwidget.xbm')}",
+ :foreground=>'grey90', :background=>'white')
+ frame = TkFrame.new(ximg, :background=>'white')
+ TkLabel.new(frame, :text=>'Loading demo',
+ :background=>'white', :font=>'times 8').pack
+ TkLabel.new(frame, :textvariable=>DemoVar.prgtext,
+ :background=>'white', :font=>'times 8', :width=>35).pack
+ Tk::BWidget::ProgressBar.new(frame, :width=>50, :height=>10,
+ :background=>'white',
+ :variable=>DemoVar.prgindic,
+ :maximum=>10).pack
+ frame.place(:x=>0, :y=>0, :anchor=>:nw)
+ bwimg.place(:relx=>1, :rely=>1, :anchor=>:se)
+ ximg.pack
+ Tk::BWidget.place(top, 0, 0, :center)
+ top.deiconify
+
+ top
+ end
+end
+
+module DemoVar
+ Demo = BWidget_Demo.new
+end
+
+Tk.mainloop
diff --git a/jni/ruby/ext/tk/sample/tkextlib/bwidget/dnd.rb b/jni/ruby/ext/tk/sample/tkextlib/bwidget/dnd.rb
new file mode 100644
index 0000000..b1b1cf6
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkextlib/bwidget/dnd.rb
@@ -0,0 +1,46 @@
+#
+# dnd demo --- called from demo.rb
+#
+unless Object.const_defined?('DemoVar')
+ fail RuntimeError, "This is NOT a stand alone script. This script is called from 'demo.rb'. "
+end
+
+module DemoDnD
+ def self.create(nb)
+ frame = nb.insert('end', 'demoDnD', :text=>'Drag and Drop')
+
+ titf1 = Tk::BWidget::TitleFrame.new(frame, :text=>'Drag source')
+ subf = titf1.get_frame
+
+ ent1 = Tk::BWidget::LabelEntry.new(subf, :label=>'Entry',
+ :labelwidth=>14, :dragenabled=>true,
+ :dragevent=>3)
+ labf1 = Tk::BWidget::LabelFrame.new(subf, :text=>'Label (text)',
+ :width=>14)
+ f = labf1.get_frame
+ lab = Tk::BWidget::Label.new(f, :text=>'Drag this text',
+ :dragenabled=>true, :dragevent=>3).pack
+
+ labf2 = Tk::BWidget::LabelFrame.new(subf, :text=>'Label (bitmap)',
+ :width=>14)
+ f = labf2.get_frame
+ lab = Tk::BWidget::Label.new(f, :bitmap=>'info',
+ :dragenabled=>true, :dragevent=>3).pack
+
+ Tk.pack(ent1, labf1, labf2, :side=>:top, :fill=>:x, :pady=>4)
+
+ titf2 = Tk::BWidget::TitleFrame.new(frame, :text=>'Drop targets')
+ subf = titf2.get_frame
+
+ ent1 = Tk::BWidget::LabelEntry.new(subf, :label=>'Entry',
+ :labelwidth=>14, :dropenabled=>true)
+ labf1 = Tk::BWidget::LabelFrame.new(subf, :text=>'Label', :width=>14)
+ f = labf1.get_frame
+ lab = Tk::BWidget::Label.new(f, :dropenabled=>true,
+ :highlightthickness=>1).pack(:fill=>:x)
+ Tk.pack(ent1, labf1, :side=>:top, :fill=>:x, :pady=>4)
+ Tk.pack(titf1, titf2, :pady=>4)
+
+ frame
+ end
+end
diff --git a/jni/ruby/ext/tk/sample/tkextlib/bwidget/manager.rb b/jni/ruby/ext/tk/sample/tkextlib/bwidget/manager.rb
new file mode 100644
index 0000000..a59afb8
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkextlib/bwidget/manager.rb
@@ -0,0 +1,150 @@
+#
+# manager demo --- called from demo.rb
+#
+unless Object.const_defined?('DemoVar')
+ fail RuntimeError, "This is NOT a stand alone script. This script is called from 'demo.rb'. "
+end
+
+module DemoManager
+ @@progress = TkVariable.new(false)
+ @@status = TkVariable.new('Compute in progress...')
+ @@homogeneous = TkVariable.new(false)
+ @@constw = TkVariable.new
+ @@afterobj = nil
+
+ def self.create(nb)
+ frame = nb.insert('end', 'demoManager', :text=>'Manager')
+
+ topf = TkFrame.new(frame)
+ titf1 = Tk::BWidget::TitleFrame.new(topf, :text=>"MainFrame")
+ titf2 = Tk::BWidget::TitleFrame.new(topf, :text=>"NoteBook")
+ titf3 = Tk::BWidget::TitleFrame.new(frame, :text=>"Paned & ScrolledWindow")
+
+ _mainframe(titf1.get_frame)
+ _notebook(titf2.get_frame)
+ _paned(titf3.get_frame)
+
+ Tk.pack(titf1, titf2, :padx=>4, :side=>:left, :fill=>:both, :expand=>true)
+ Tk.pack(topf, :fill=>:x, :pady=>2)
+ Tk.pack(titf3, :pady=>2, :padx=>4, :fill=>:both, :expand=>true)
+
+ frame
+ end
+
+ def self._mainframe(parent)
+ labf1 = Tk::BWidget::LabelFrame.new(parent, :text=>'Toolbar',
+ :side=>:top, :anchor=>:w,
+ :relief=>:sunken, :borderwidth=>2)
+ subf = labf1.get_frame
+ chk1 = TkCheckbutton.new(subf, :text=>'View toolbar 1',
+ :variable=>DemoVar.toolbar1,
+ :command=>proc{
+ DemoVar.mainframe.show_toolbar(
+ 0, DemoVar.toolbar1.value
+ )
+ })
+ chk2 = TkCheckbutton.new(subf, :text=>'View toolbar 2',
+ :variable=>DemoVar.toolbar2,
+ :command=>proc{
+ DemoVar.mainframe.show_toolbar(
+ 1, DemoVar.toolbar2.value
+ )
+ })
+
+ Tk.pack(chk1, chk2, :anchor=>:w, :fill=>:x)
+ labf1.pack(:fill=>:both)
+
+ labf2 = Tk::BWidget::LabelFrame.new(parent, :text=>'Status bar',
+ :side=>:top, :anchor=>:w,
+ :relief=>:sunken, :borderwidth=>2)
+ subf = labf2.get_frame
+ chk1 = TkCheckbutton.new(subf, :text=>"Show Progress\nindicator",
+ :justify=>:left, :variable=>@@progress,
+ :command=>proc{ _show_progress })
+ chk1.pack(:anchor=>:w, :fill=>:x)
+
+ Tk.pack(labf1, labf2, :side=>:left, :padx=>4, :fill=>:both)
+ end
+
+ def self._notebook(parent)
+ TkCheckbutton.new(parent, :text=>'Homogeneous label',
+ :variable=>@@homogeneous,
+ :command=>proc{
+ DemoVar.notebook[:homogeneous] = @@homogeneous.value
+ }).pack(:side=>:left, :anchor=>:n, :fill=>:x)
+ end
+
+ def self._paned(parent)
+ pw1 = Tk::BWidget::PanedWindow.new(parent, :side=>:top)
+ pane = pw1.add(:minsize=>100)
+
+ pw2 = Tk::BWidget::PanedWindow.new(pane, :side=>:left)
+ pane1 = pw2.add(:minsize=>100)
+ pane2 = pw2.add(:minsize=>100)
+
+ pane3 = pw1.add(:minsize=>100)
+
+ [pane1, pane2].each{|pane|
+ sw = Tk::BWidget::ScrolledWindow.new(pane)
+ lb = TkListbox.new(sw, :height=>8, :width=>20, :highlightthickness=>0)
+ (1..8).each{|i| lb.insert('end', "Valur #{i}") }
+ sw.set_widget(lb)
+ sw.pack(:fill=>:both, :expand=>true)
+ }
+
+ sw = Tk::BWidget::ScrolledWindow.new(pane3, :relief=>:sunken,
+ :borderwidth=>2)
+ sf = Tk::BWidget::ScrollableFrame.new(sw)
+ sw.set_widget(sf)
+ subf = sf.get_frame
+ lab = TkLabel.new(subf, :text=>'This is a ScrollableFrame')
+ chk = TkCheckbutton.new(subf, :text=>'Constrained with',
+ :variable=>@@constw, :command=>proc{
+ sf['constrainedwidth'] = @@constw.value
+ })
+ lab.pack
+ chk.pack(:anchor=>:w)
+ chk.bind('FocusIn', proc{sf.see(chk)})
+ (0..20).each{|i|
+ ent = TkEntry.new(subf, :width=>50).pack(:fill=>:x, :pady=>4)
+ ent.bind('FocusIn', proc{sf.see(ent)})
+ ent.insert('end', "Text field #{i}")
+ }
+
+ Tk.pack(sw, pw2, pw1, :fill=>:both, :expand=>true)
+ end
+
+ def self._show_progress
+ unless @@afterobj
+ @@afterobj = TkTimer.new(30, -1, proc{_update_progress})
+ end
+ if @@progress.bool
+ DemoVar.status.value = 'Compute in progress...'
+ DemoVar.prgindic.value = 0
+ DemoVar.mainframe.show_statusbar(:progression)
+ @@afterobj.start unless @@afterobj.running?
+ else
+ DemoVar.status.value = ''
+ DemoVar.mainframe.show_statusbar(:status)
+ @@afterobj.stop
+ end
+ end
+
+ def self._update_progress
+ if @@progress.bool
+ if DemoVar.prgindic.numeric < 100
+ DemoVar.prgindic.numeric += 5
+ else
+ @@progress.value = false
+ DemoVar.mainframe.show_statusbar(:status)
+ DemoVar.status.value = 'Done'
+ @@afterobj.stop
+ Tk.after(500, proc{ DemoVar.status.value = '' })
+ end
+ else
+ @@afterobj.stop
+ end
+ end
+
+end
+
diff --git a/jni/ruby/ext/tk/sample/tkextlib/bwidget/select.rb b/jni/ruby/ext/tk/sample/tkextlib/bwidget/select.rb
new file mode 100644
index 0000000..3a1a810
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkextlib/bwidget/select.rb
@@ -0,0 +1,82 @@
+#
+# select demo --- called from demo.rb
+#
+unless Object.const_defined?('DemoVar')
+ fail RuntimeError, "This is NOT a stand alone script. This script is called from 'demo.rb'. "
+end
+
+module DemoSelect
+ @@var = TkVariable.new_hash
+
+ def self.create(nb)
+ frame = nb.insert('end', 'demoSelect', :text=>'Spin & Combo')
+
+ titf1 = Tk::BWidget::TitleFrame.new(frame, :text=>'SpinBox')
+ subf = titf1.get_frame
+ spin = Tk::BWidget::SpinBox.new(subf, :range=>[1, 100, 1],
+ :textvariable=>@@var.ref('spin', 'var'),
+ :helptext=>'This is the SpinBox')
+ ent = Tk::BWidget::LabelEntry.new(subf, :label=>'Linked var',
+ :labelwidth=>10, :labelanchor=>:w,
+ :textvariable=>@@var.ref('spin', 'var'),
+ :editable=>0,
+ :helptext=>"This is an Entry reflecting\nthe linked var of SpinBox")
+ labf = Tk::BWidget::LabelFrame.new(subf, :text=>'Options',
+ :side=>:top, :anchor=>:w,
+ :relief=>:sunken, :borderwidth=>1,
+ :helptext=>'Modify some options of SpinBox')
+ subf = labf.get_frame
+ chk1 = TkCheckbutton.new(subf, :text=>'Non editable',
+ :variable=>@@var.ref('spin', 'editable'),
+ :onvalue=>false, :offvalue=>true,
+ :command=>proc{
+ spin.editable(@@var['spin', 'editable'])
+ })
+ chk2 = TkCheckbutton.new(subf, :text=>'Disabled',
+ :variable=>@@var.ref('spin', 'state'),
+ :onvalue=>'disabled', :offvalue=>'normal',
+ :command=>proc{
+ spin.state(@@var['spin', 'state'])
+ })
+ Tk.pack(chk1, chk2, :side=>:left, :anchor=>:w)
+ Tk.pack(spin, ent, labf, :pady=>4, :fill=>:x)
+ titf1.pack
+
+ titf2 = Tk::BWidget::TitleFrame.new(frame, :text=>'ComboBox')
+ subf = titf2.get_frame
+ combo = Tk::BWidget::ComboBox.new(subf,
+ :textvariable=>@@var.ref('combo', 'var'),
+ :values=>[
+ 'first value', 'second value',
+ 'third value', 'fourth value',
+ 'fifth value'
+ ],
+ :helptext=>'This is the ComboBox')
+ ent = Tk::BWidget::LabelEntry.new(subf, :label=>'Linked var',
+ :labelwidth=>10, :labelanchor=>:w,
+ :textvariable=>@@var.ref('combo', 'var'),
+ :editable=>0, :helptext=>"This is an Entry reflecting\nthe linked var of ComboBox")
+ labf = Tk::BWidget::LabelFrame.new(subf, :text=>'Options', :side=>:top,
+ :anchor=>:w, :relief=>:sunken,
+ :borderwidth=>1, :helptext=>'Modify some options of ComboBox')
+ subf = labf.get_frame
+ chk1 = TkCheckbutton.new(subf, :text=>'Non editable',
+ :variable=>@@var.ref('combo', 'editable'),
+ :onvalue=>false, :offvalue=>true,
+ :command=>proc{
+ combo.editable(@@var['combo', 'editable'])
+ })
+ chk2 = TkCheckbutton.new(subf, :text=>'Disabled',
+ :variable=>@@var.ref('combo', 'state'),
+ :onvalue=>'disabled', :offvalue=>'normal',
+ :command=>proc{
+ combo.state(@@var['combo', 'state'])
+ })
+
+ Tk.pack(chk1, chk2, :side=>:left, :anchor=>:w)
+ Tk.pack(combo, ent, labf, :pady=>4, :fill=>:x)
+ Tk.pack(titf1, titf2, :pady=>4)
+
+ frame
+ end
+end
diff --git a/jni/ruby/ext/tk/sample/tkextlib/bwidget/tmpldlg.rb b/jni/ruby/ext/tk/sample/tkextlib/bwidget/tmpldlg.rb
new file mode 100644
index 0000000..da2c967
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkextlib/bwidget/tmpldlg.rb
@@ -0,0 +1,221 @@
+#
+# templdlg demo --- called from demo.rb
+#
+unless Object.const_defined?('DemoVar')
+ fail RuntimeError, "This is NOT a stand alone script. This script is called from 'demo.rb'. "
+end
+
+module DemoDialog
+ @@tmpl = TkVariable.new_hash
+ @@msg = TkVariable.new_hash
+ @@msgdlg = nil
+ @@progmsg = TkVariable.new
+ @@progval = TkVariable.new
+ @@progdlg = nil
+ @@resources = TkVariable.new('en')
+
+ def self.create(nb)
+ frame = nb.insert('end', 'demoDlg', :text=>'Dialog')
+
+ titf1 = Tk::BWidget::TitleFrame.new(frame, :text=>'Resources')
+ titf2 = Tk::BWidget::TitleFrame.new(frame, :text=>'Template Dialog')
+ titf3 = Tk::BWidget::TitleFrame.new(frame, :text=>'Message Dialog')
+ titf4 = Tk::BWidget::TitleFrame.new(frame, :text=>'Other dialog')
+
+ subf = titf1.get_frame
+ cmd = proc{ TkOption.read_file(File.join(Tk::BWidget::LIBRARY, 'lang',
+ @@resources.value + '.rc')) }
+ Tk.pack(TkRadiobutton.new(subf, :text=>'English', :value=>'en',
+ :variable=>@@resources, :command=>cmd),
+ TkRadiobutton.new(subf, :text=>'French', :value=>'fr',
+ :variable=>@@resources, :command=>cmd),
+ TkRadiobutton.new(subf, :text=>'German', :value=>'de',
+ :variable=>@@resources, :command=>cmd),
+ :side=>:left)
+
+ _tmpldlg(titf2.get_frame)
+ _msgdlg(titf3.get_frame)
+ _stddlg(titf4.get_frame)
+
+ titf1.pack(:fill=>:x, :pady=>2, :padx=>2)
+ titf4.pack(:side=>:bottom, :fill=>:x, :pady=>2, :padx=>2)
+ Tk.pack(titf2, titf3, :side=>:left, :padx=>2, :fill=>:both, :expand=>true)
+ end
+
+ def self._tmpldlg(parent)
+ @@tmpl['side'] = :bottom
+ @@tmpl['anchor'] = :c
+
+ labf1 = Tk::BWidget::LabelFrame.new(parent, :text=>'Button side',
+ :side=>:top, :anchor=>:w,
+ :relief=>:sunken, :borderwidth=>1)
+ subf = labf1.get_frame
+ Tk.pack(TkRadiobutton.new(subf, :text=>'Bottom', :value=>:bottom,
+ :variable=>@@tmpl.ref('side'), :anchor=>:w),
+ TkRadiobutton.new(subf, :text=>'Left', :value=>:left,
+ :variable=>@@tmpl.ref('side'), :anchor=>:w),
+ TkRadiobutton.new(subf, :text=>'Right', :value=>:right,
+ :variable=>@@tmpl.ref('side'), :anchor=>:w),
+ TkRadiobutton.new(subf, :text=>'Top', :value=>:top,
+ :variable=>@@tmpl.ref('side'), :anchor=>:w),
+ :fill=>:x, :anchor=>:w)
+
+ labf2 = Tk::BWidget::LabelFrame.new(parent, :text=>'Button anchor',
+ :side=>:top, :anchor=>:w,
+ :relief=>:sunken, :borderwidth=>1)
+ subf = labf2.get_frame
+ Tk.pack(TkRadiobutton.new(subf, :text=>'North', :value=>:n,
+ :variable=>@@tmpl.ref('anchor'), :anchor=>:w),
+ TkRadiobutton.new(subf, :text=>'West', :value=>:w,
+ :variable=>@@tmpl.ref('anchor'), :anchor=>:w),
+ TkRadiobutton.new(subf, :text=>'East', :value=>:e,
+ :variable=>@@tmpl.ref('anchor'), :anchor=>:w),
+ TkRadiobutton.new(subf, :text=>'South', :value=>:s,
+ :variable=>@@tmpl.ref('anchor'), :anchor=>:w),
+ TkRadiobutton.new(subf, :text=>'Center', :value=>:c,
+ :variable=>@@tmpl.ref('anchor'), :anchor=>:w),
+ :fill=>:x, :anchor=>:w)
+
+ sep = Tk::BWidget::Separator.new(parent, :orient=>:horizontal)
+ button = TkButton.new(parent, :text=>'Show', :command=>proc{_show_tmpldlg})
+
+ button.pack(:side=>:bottom)
+ sep.pack(:side=>:bottom, :fill=>:x, :pady=>10)
+ Tk.pack(labf1, labf2, :side=>:left, :padx=>4, :anchor=>:n)
+ end
+
+ def self._msgdlg(parent)
+ @@msg['type'] = 'ok'
+ @@msg['icon'] = 'info'
+
+ labf1 = Tk::BWidget::LabelFrame.new(parent, :text=>'Type', :side=>:top,
+ :anchor=>:w, :relief=>:sunken,
+ :borderwidth=>1)
+ subf = labf1.get_frame
+ Tk.pack(TkRadiobutton.new(subf, :text=>'Ok', :value=>'ok',
+ :variable=>@@msg.ref('type'), :anchor=>:w),
+ TkRadiobutton.new(subf, :text=>'Ok, Cancel', :value=>'okcancel',
+ :variable=>@@msg.ref('type'), :anchor=>:w),
+ TkRadiobutton.new(subf, :text=>'Retry, Cancel',
+ :value=>'retrycancel',
+ :variable=>@@msg.ref('type'), :anchor=>:w),
+ TkRadiobutton.new(subf, :text=>'Yes, No', :value=>'yesno',
+ :variable=>@@msg.ref('type'), :anchor=>:w),
+ TkRadiobutton.new(subf, :text=>'Yes, No, Cancel',
+ :value=>'yesnocancel',
+ :variable=>@@msg.ref('type'), :anchor=>:w),
+ TkRadiobutton.new(subf, :text=>'Abort, Retry, Ignore',
+ :value=>'abortretryignore',
+ :variable=>@@msg.ref('type'), :anchor=>:w),
+ :fill=>:x, :anchor=>:w)
+
+ Tk.pack(TkRadiobutton.new(subf, :text=>'User', :value=>'user',
+ :variable=>@@msg.ref('type'), :anchor=>:w),
+ Tk::BWidget::Entry.new(subf, :textvariable=>@@msg.ref('buttons')),
+ :side=>:left)
+
+ labf2 = Tk::BWidget::LabelFrame.new(parent, :text=>'Icon', :side=>:top,
+ :anchor=>:w, :relief=>:sunken,
+ :borderwidth=>1)
+ subf = labf2.get_frame
+ Tk.pack(TkRadiobutton.new(subf, :text=>'Information', :value=>'info',
+ :variable=>@@msg.ref('icon'), :anchor=>:w),
+ TkRadiobutton.new(subf, :text=>'Question', :value=>'question',
+ :variable=>@@msg.ref('icon'), :anchor=>:w),
+ TkRadiobutton.new(subf, :text=>'Warning', :value=>'warning',
+ :variable=>@@msg.ref('icon'), :anchor=>:w),
+ TkRadiobutton.new(subf, :text=>'Error', :value=>'error',
+ :variable=>@@msg.ref('icon'), :anchor=>:w),
+ :fill=>:x, :anchor=>:w)
+
+ sep = Tk::BWidget::Separator.new(parent, :orient=>:horizontal)
+ button = TkButton.new(parent, :text=>'Show', :command=>proc{_show_msgdlg})
+
+ button.pack(:side=>:bottom)
+ sep.pack(:side=>:bottom, :fill=>:x, :pady=>10)
+ Tk.pack(labf1, labf2, :side=>:left, :padx=>4, :anchor=>:n)
+ end
+
+ def self._stddlg(parent)
+ Tk.pack(TkButton.new(parent, :text=>'Select a color '){|w|
+ command(proc{DemoDialog._show_color(w)})
+ },
+ TkButton.new(parent, :text=>'Font selector dialog',
+ :command=>proc{_show_fontdlg}),
+ TkButton.new(parent, :text=>'Progression dialog',
+ :command=>proc{_show_progdlg}),
+ TkButton.new(parent, :text=>'Password dialog',
+ :command=>proc{_show_passdlg}),
+ :side=>:left, :padx=>5, :anchor=>:w)
+ end
+
+ def self._show_color(w)
+ dlg = Tk::BWidget::SelectColor.new(w, :color=>w.background)
+ color = dlg.menu([:below, w])
+ unless color.empty?
+ w.background(color)
+ end
+ end
+
+ def self._show_tmpldlg
+ dlg = Tk::BWidget::Dialog.new(:relative=>Tk.root, :modal=>:local,
+ :separator=>true, :title=>'Template dialog',
+ :side=>@@tmpl['side'],
+ :anchor=>@@tmpl['anchor'],
+ :default=>0, :cancel=>1)
+ dlg.add('name'=>'ok')
+ dlg.add('name'=>'cancel')
+ TkMessage.new(dlg.get_frame, :text=>"Template\nDialog", :justify=>:center,
+ :anchor=>:c, :width=>80).pack(:fill=>:both, :expand=>true,
+ :padx=>100, :pady=>100)
+ dlg.draw
+ dlg.destroy
+ end
+
+ def self._show_msgdlg
+ @@msgdlg.destroy if @@msgdlg
+ @@msgdlg = Tk::BWidget::MessageDlg.new(:relative=>Tk.root,
+ :message=>'Message for MessageBox',
+ :type=>@@msg['type'],
+ :icon=>@@msg['icon'],
+ :buttons=>@@msg['buttons'])
+ @@msgdlg.create
+ end
+
+ def self._show_fontdlg
+ font = Tk::BWidget::SelectFont.new(:relative=>Tk.root,
+ :font=>DemoVar.font).create
+ DemoVar::Demo.update_font(font)
+ end
+
+ def self._show_progdlg
+ @@progmsg.value = "Compute in progress..."
+ @@progval.value = 0
+
+ @@progdlg = Tk::BWidget::ProgressDlg.new(:relative=>Tk.root,
+ :title=>'Wait...',
+ :type=>'infinite', :width=>20,
+ :textvariable=>@@progmsg,
+ :variable=>@@progval,
+ :stop=>'Stop') {
+ command(proc{self.destroy})
+ create
+ }
+ _update_progdlg
+ end
+
+ def self._update_progdlg
+ TkTimer.new(20, -1, proc{
+ if @@progdlg && @@progdlg.winfo_exist?
+ @@progval.value = 2
+ else
+ stop
+ end
+ }).start
+ end
+
+ def self._show_passdlg
+ Tk::BWidget::PasswdDlg.new(:relative=>Tk.root).create
+ end
+end
+
diff --git a/jni/ruby/ext/tk/sample/tkextlib/bwidget/tree.rb b/jni/ruby/ext/tk/sample/tkextlib/bwidget/tree.rb
new file mode 100644
index 0000000..9ef6569
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkextlib/bwidget/tree.rb
@@ -0,0 +1,289 @@
+#
+# templdlg demo --- called from demo.rb
+#
+unless Object.const_defined?('DemoVar')
+ fail RuntimeError, "This is NOT a stand alone script. This script is called from 'demo.rb'. "
+end
+
+module DemoTree
+ @@count = 0
+ @@dblclick = false
+ @@top = nil
+
+ def self.create(nb)
+ frame = nb.insert('end', 'demoTree', :text=>'Tree')
+ pw = Tk::BWidget::PanedWindow.new(frame, :side=>:top)
+
+ pane = pw.add(:weight=>1)
+ title = Tk::BWidget::TitleFrame.new(pane, :text=>'Directory tree')
+ sw = Tk::BWidget::ScrolledWindow.new(title.get_frame,
+ :relief=>:sunken, :borderwidth=>2)
+ tree = Tk::BWidget::Tree.new(sw, :relief=>:flat, :borderwidth=>0,
+ :width=>15, :highlightthickness=>0,
+ :redraw=>false, :dropenabled=>true,
+ :dragenabled=>true, :dragevent=>3,
+ :droptypes=>[
+ 'TREE_NODE', [
+ :copy, [],
+ :move, [],
+ :link, []
+ ],
+ 'LISTBOX_ITEM', [
+ :copy, [],
+ :move, [],
+ :link, []
+ ]
+ ],
+ :opencmd=>proc{|node|
+ moddir(1, tree, node)
+ },
+ :closecmd=>proc{|node|
+ moddir(0, tree, node)
+ })
+ sw.set_widget(tree)
+
+ sw.pack(:side=>:top, :expand=>true, :fill=>:both)
+ title.pack(:fill=>:both, :expand=>true)
+
+ pane = pw.add(:weight=>2)
+ lf = Tk::BWidget::TitleFrame.new(pane, :text=>'Content')
+ sw = Tk::BWidget::ScrolledWindow.new(lf.get_frame,
+ :scrollbar=>:horizontal,
+ :auto=>:none, :relief=>:sunken,
+ :borderwidth=>2)
+
+ list = Tk::BWidget::ListBox.new(sw, :relief=>:flat, :borderwidth=>0,
+ :highlightthickness=>0, :width=>20,
+ :multicolumn=>true, :redraw=>false,
+ :dragevent=>3, :dropenabled=>true,
+ :dragenabled=>true,
+ :droptypes=>[
+ 'TREE_NODE', [
+ :copy, [],
+ :move, [],
+ :link, []
+ ],
+ 'LISTBOX_ITEM', [
+ :copy, [],
+ :move, [],
+ :link, []
+ ]
+ ])
+ sw.set_widget(list)
+
+ Tk.pack(sw, lf, :fill=>:both, :expand=>true)
+
+ pw.pack(:fill=>:both, :expand=>true)
+
+ tree.textbind('ButtonPress-1',
+ proc{|node, ev| select('tree', 1, tree, list, node)})
+ tree.textbind('Double-ButtonPress-1',
+ proc{|node, ev| select('tree', 2, tree, list, node)})
+
+ list.textbind('ButtonPress-1',
+ proc{|node, ev| select('list', 1, tree, list, node)})
+ list.textbind('Double-ButtonPress-1',
+ proc{|node, ev| select('list', 2, tree, list, node)})
+
+ list.imagebind('Double-ButtonPress-1',
+ proc{|node, ev| select('list', 2, tree, list, node)})
+
+ nb.itemconfigure('demoTree',
+ :createcmd=>proc{|*args| init(tree, list, *args)},
+ :raisecmd=>proc{
+ Tk.root.geometry =~
+ /\d+x\d+([+-]{1,2}\d+)([+-]{1,2}\d+)/
+ global_w = ($1 || 0).to_i
+ global_h = ($2 || 0).to_i
+ if @@top
+ Tk::BWidget.place(@@top, 0, 0, :at,
+ global_w - Tk.root.winfo_screenwidth, global_h)
+ @@top.deiconify
+ Tk.root.bind('Unmap', proc{@@top.withdraw})
+ Tk.root.bind('Map', proc{@@top.deiconify})
+ Tk.root.bind('Configure', proc{|w|
+ if w == Tk.root
+ Tk.root.geometry =~
+ /\d+x\d+([+-]{1,2}\d+)([+-]{1,2}\d+)/
+ global_w = ($1 || 0).to_i
+ global_h = ($2 || 0).to_i
+ Tk::BWidget.place(@@top, 0, 0, :at,
+ global_w - Tk.root.winfo_screenwidth,
+ global_h)
+ end
+ }, '%W')
+ end
+ },
+ :leavecmd=>proc{
+ @@top.withdraw if @@top
+ Tk.root.bind_remove('Unmap')
+ Tk.root.bind_remove('Map')
+ Tk.root.bind_remove('Configure')
+ true
+ })
+ end
+
+ def self.init(tree, list, *args)
+ @@count = 0
+ if Tk::PLATFORM['platform'] == 'unix'
+ rootdir = File.expand_path('~')
+ else
+ rootdir = 'c:'
+ end
+
+ tree.insert('end', 'root', 'home',
+ :text=>rootdir, :data=>rootdir, :open=>true,
+ :image=>Tk::BWidget::Bitmap.new('openfold'))
+ getdir(tree, 'home', rootdir)
+ select('tree', 1, tree, list, 'home')
+ tree.redraw(true)
+ list.redraw(true)
+
+ @@top = TkToplevel.new
+ @@top.withdraw
+ @@top.protocol('WM_DELETE_WINDOW'){
+ # don't kill me
+ }
+ @@top.resizable(false, false)
+ @@top.title('Drag rectangle to scroll directory tree')
+ @@top.transient(Tk.root)
+ Tk::BWidget::ScrollView.new(@@top, :window=>tree, :fill=>'white',
+ :width=>300, :height=>300, :relief=>:sunken,
+ :bd=>1).pack(:fill=>:both, :expand=>true)
+ end
+
+ def self.getdir(tree, node, path)
+ lentries = Dir.glob(File.join(path, '*')).sort
+ lfiles = []
+ lentries.each{|f|
+ basename = File.basename(f)
+ if File.directory?(f)
+ Tk::BWidget::Tree::Node.new(tree, node,
+ :index=>'end', :text=>basename,
+ :image=>Tk::BWidget::Bitmap.new('folder'),
+ :drawcross=>:allways, :data=>f)
+ @@count += 1
+ else
+ lfiles << basename
+ end
+ }
+ tree.itemconfigure(node, :drawcross=>:auto, :data=>lfiles)
+ end
+
+ def self.moddir(idx, tree, node)
+ if (idx != 0 && tree.itemcget(node, :drawcross).to_s == 'allways')
+ getdir(tree, node, tree.itemcget(node, :data))
+ if tree.nodes(node).empty?
+ tree.itemconfigure(node, :image=>Tk::BWidget::Bitmap.new('folder'))
+ else
+ tree.itemconfigure(node, :image=>Tk::BWidget::Bitmap.new('openfold'))
+ end
+ else
+ img = %w(folder openfold)[idx] || 'openfold'
+ tree.itemconfigure(node, :image=>Tk::BWidget::Bitmap.new(img))
+ end
+ end
+
+ def self.select(where, num, tree, list, node)
+ @@dblclick = true
+ if num == 1
+ if (where == 'tree' &&
+ tree.selection_get.find{|x|
+ TkUtil._get_eval_string(x) == TkUtil._get_eval_string(node)
+ })
+ @@dblclick = false
+ Tk.after(500, proc{edit('tree', tree, list, node)})
+ return
+ end
+ if (where == 'list' &&
+ list.selection_get.find{|x|
+ TkUtil._get_eval_string(x) == TkUtil._get_eval_string(node)
+ })
+ @@dblclick = false
+ Tk.after(500, proc{edit('list', tree, list, node)})
+ return
+ end
+ if where == 'tree'
+ select_node(tree, list, node)
+ else
+ list.selection_set(node)
+ end
+ elsif (where == 'list' && tree.exist?(node))
+ parent = tree.parent(node)
+ while TkUtil._get_eval_string(parent) != 'root'
+ tree.itemconfigure(parent, :open=>true)
+ parent = tree.parent(parent)
+ end
+ select_node(tree, list, node)
+ end
+ end
+
+ def self.select_node(tree, list, node)
+ tree.selection_set(node)
+ Tk.update
+ list.delete(*(list.items(0, 'end')))
+
+ dir = tree.itemcget(node, :data)
+ if tree.itemcget(node, :drawcross).to_s == 'allways'
+ getdir(tree, node, dir)
+ dir = tree.itemcget(node, :data)
+ end
+
+ tree.nodes(node).each{|subnode|
+ list.insert('end', subnode,
+ :text=>tree.itemcget(subnode, :text),
+ :image=>Tk::BWidget::Bitmap.new('folder'))
+ }
+
+ TkComm.simplelist(dir).each{|f|
+ Tk::BWidget::ListBox::Item.new(list, 'end', :text=>f,
+ :image=>Tk::BWidget::Bitmap.new('file'))
+ }
+ end
+
+ def self.edit(where, tree, list, node)
+ return if @@dblclick
+
+ if (where == 'tree' &&
+ tree.selection_get.find{|x|
+ TkUtil._get_eval_string(x) == TkUtil._get_eval_string(node)
+ })
+ res = tree.edit(node, tree.itemcget(node, :text))
+ if res != ''
+ tree.itemconfigure(node, :text=>res)
+ if list.exist?(node)
+ list.itemconfigure(node, :text=>res)
+ end
+ tree.selection_set(node)
+ end
+ return
+ end
+
+ if (where == 'list')
+ res = list.edit(node, list.igemcget(node, :text))
+ if res != ''
+ list.itemconfigure(node, :text=>res)
+ if tree.exist?(node)
+ tree.itemconfigure(node, :text=>res)
+ else
+ cursel = tree.selection_get[0]
+ index = list.index(node) - tree.nodes(cursel).size
+ data = TkComm.simplelist(tree.itemcget(cursel, :data))
+ data[index] = res
+ tree.itemconfigure(cursel, :date=>data)
+ end
+ list.selection_set(node)
+ end
+ end
+ end
+
+ def self.expand(tree, but)
+ unless (cur = tree.selection_get).empty?
+ if TkComm.bool(but)
+ tree.opentree(cur)
+ else
+ tree.closetree(cur)
+ end
+ end
+ end
+end
diff --git a/jni/ruby/ext/tk/sample/tkextlib/bwidget/x1.xbm b/jni/ruby/ext/tk/sample/tkextlib/bwidget/x1.xbm
new file mode 100644
index 0000000..6137a11
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkextlib/bwidget/x1.xbm
@@ -0,0 +1,2258 @@
+#define x1_width 626
+#define x1_height 428
+static char x1_bits[] = {
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0xff,0xff,0xff,0xff,0xff,0x1f,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0xfc,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0xfe,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfc,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0x0f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfc,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xc0,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x07,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0xfc,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0xfc,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfc,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0xfc,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x1f,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfc,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xf0,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x03,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0xfc,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0x3f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0xfc,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0xfc,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x03,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfc,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0xe0,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x3f,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfc,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfe,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0xfc,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xf0,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0x1f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0xfc,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x01,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfc,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0xf0,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0x0f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfc,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0x7f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0xfc,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xf0,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x03,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfc,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x0f,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfc,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0xe0,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0x7f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0xfc,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0xfe,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0xfc,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xc0,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x0f,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfc,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xf8,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0x7f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfc,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x80,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0xfc,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0xf0,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x07,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0xfc,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfe,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x1f,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfc,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xc0,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfc,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0xf8,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0xfc,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x0f,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0xfc,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xe0,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0x3f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfc,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfc,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0x7f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfc,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x80,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x01,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0xfc,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0xe0,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x07,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfc,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfc,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0x1f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfc,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0x7f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0xfc,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0xe0,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0xfc,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0xfc,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfc,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xff,0x03,0x80,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x1f,0xe0,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0x07,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfc,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x20,0x00,0x00,0x00,
+ 0x00,0xfe,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x1f,0x00,0x00,
+ 0xe0,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x1f,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0xfc,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x80,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0x00,0x00,0x00,0x00,0xfe,0xff,0xff,0xff,0xff,0xff,0xff,0x7f,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0xfc,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xf8,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0x1f,0x00,0x00,0x00,0x00,0xe0,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfc,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xc0,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x03,0x00,0x00,0x00,0x00,0x80,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0xfc,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0xfe,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x7f,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0xfe,0xff,0xff,0xff,0xff,0xff,0xff,0x07,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0xfc,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xf0,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0x1f,0x00,0x00,0x00,0x00,0x00,0x00,0xf8,0xff,0xff,0xff,0xff,0xff,0xff,0x0f,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0xfc,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xc0,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0x07,0x00,0x00,0x00,0x00,0x00,0x00,0xe0,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0x3f,0x00,0x00,0x00,0x00,0x00,0x00,0xfc,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x01,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x80,0xff,0xff,0xff,0xff,0xff,0xff,0x7f,0x00,0x00,0x00,0x00,0x00,0x00,0xfc,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0xfc,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x7f,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0xfc,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xf0,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0x1f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfe,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0x03,0x00,0x00,0x00,0x00,0x00,0xfc,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xc0,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0x07,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xf8,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0x07,0x00,0x00,0x00,0x00,0x00,0xfc,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x80,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x01,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0xf0,0xff,0xff,0xff,0xff,0xff,0xff,0x0f,0x00,0x00,0x00,0x00,0x00,
+ 0xfc,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfe,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0xe0,0xff,0xff,0xff,0xff,0xff,0xff,0x1f,0x00,
+ 0x00,0x00,0x00,0x00,0xfc,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfc,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0x3f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xc0,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0x3f,0x00,0x00,0x00,0x00,0x00,0xfc,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0xf0,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0x0f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x00,0x00,0x00,0x00,0x00,0xfc,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0xe0,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x07,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x01,0x00,0x00,0x00,
+ 0x00,0xfc,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xc0,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x01,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0x03,0x00,0x00,0x00,0x00,0xfc,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfe,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0x07,0x00,0x00,0x00,0x00,0xfc,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0xfe,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0x7f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0xfc,0xff,0xff,0xff,0xff,0xff,0xff,0x0f,0x00,0x00,0x00,0x00,0xfc,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfc,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x1f,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0xf8,0xff,0xff,0xff,0xff,0xff,0xff,0x1f,0x00,0x00,
+ 0x00,0x00,0xfc,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xf8,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x0f,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xf8,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0x3f,0x00,0x00,0x00,0x00,0xfc,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0xf0,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0x07,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xf0,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0x7f,0x00,0x00,0x00,0x00,0xfc,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0xe0,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0xf0,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x00,0x00,0x00,0x00,0xfc,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x08,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xc0,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0xe0,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x01,
+ 0x00,0x00,0x00,0xfc,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x06,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xc0,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x7f,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xe0,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0x03,0x00,0x00,0x00,0xfc,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,
+ 0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x80,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0x3f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xc0,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x07,0x00,0x00,0x00,0xfc,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0xe0,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0x0f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0xc0,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x0f,0x00,0x00,0x00,
+ 0xfc,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xf0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfe,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x07,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0x1f,0x00,0x00,0x00,0xfc,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7c,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfc,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x03,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0x1f,0x00,0x00,0x00,0xfc,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x3f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0xf8,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x80,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x3f,0x00,0x00,0x00,0xfc,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0xc0,0x3f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xf8,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x80,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x7f,0x00,0x00,
+ 0x00,0xfc,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xf0,0x1f,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xf0,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x7f,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0x00,0x00,0x00,0xfc,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xf8,0x0f,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0xe0,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x3f,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0x01,0x00,0x00,0xfc,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0xfe,0x07,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0xe0,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0x1f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x01,0x00,0x00,0xfc,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x80,0xff,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xc0,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0x0f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x03,
+ 0x00,0x00,0xfc,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xc0,0xff,0x03,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x07,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfe,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0x07,0x00,0x00,0xfc,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xf0,0xff,0x01,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x80,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x03,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfe,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x0f,0x00,0x00,0xfc,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0xfc,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0xfe,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x0f,0x00,0x00,0xfc,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0xfe,0x7f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfe,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfe,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0x1f,0x00,0x00,0xfc,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xff,0x7f,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfe,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x7f,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfe,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0x3f,0x00,0x00,0xfc,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xe0,0xff,0x3f,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0xfc,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x3f,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0xfe,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x3f,0x00,0x00,0xfc,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0xf0,0xff,0x1f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfc,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0x1f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0xfe,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x7f,0x00,0x00,
+ 0xfc,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0xfc,0xff,0x1f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xf8,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x0f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfe,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0x00,0x00,0xfc,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfe,0xff,0x0f,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0xf0,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x07,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfe,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0x00,0x00,0xfc,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xff,0xff,0x07,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0xf0,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0xfe,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x01,0x00,0xfc,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0xe0,0xff,0xff,0x07,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xe0,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0xfe,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x03,
+ 0x00,0xfc,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0xf0,0xff,0xff,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xe0,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfe,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0x03,0x00,0xfc,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfc,0xff,0xff,0x03,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0xc0,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x7f,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfe,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x07,0x00,0xfc,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfe,0xff,0xff,
+ 0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0xc0,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0x3f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0xfe,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x07,0x00,0xfc,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x80,0xff,0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0x1f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0xfe,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0x0f,0x00,0xfc,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0xc0,0xff,0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x0f,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfe,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0x0f,0x00,0xfc,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xf0,0xff,0xff,0x7f,0x00,0x00,0x00,
+ 0x00,0xf8,0x3f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x07,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfe,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x1f,0x00,0xfc,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xf8,0xff,0xff,
+ 0x7f,0x00,0x00,0x00,0x00,0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0xfe,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x1f,0x00,0xfc,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0xfe,0xff,0xff,0x3f,0x00,0x00,0x00,0xc0,0xff,0xff,0x03,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfe,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfe,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0x3f,0x00,0xfc,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0xff,0xff,0xff,0x3f,0x00,0x00,0x00,0xe0,0xff,0xff,
+ 0x07,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0xfe,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x01,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfe,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0x3f,0x00,0xfc,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xc0,0xff,0xff,0xff,0x1f,0x00,0x00,
+ 0x00,0xf0,0xff,0xff,0x0f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0xfc,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0xfe,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x7f,0x00,0xfc,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xe0,0xff,0xff,
+ 0xff,0x1f,0x00,0x00,0x00,0xfc,0xff,0xff,0x1f,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfc,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0x7f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x7f,0x00,
+ 0xfc,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0xf0,0xff,0xff,0xff,0x0f,0x00,0x00,0x00,0xfe,0xff,0xff,0x3f,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfc,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0x3f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0x00,0xfc,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0xfc,0xff,0xff,0xff,0x0f,0x00,0x00,0x00,0xfe,0xff,
+ 0xff,0x7f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0xf8,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x1f,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x00,0xfc,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfe,0xff,0xff,0xff,0x0f,0x00,
+ 0x00,0x00,0xff,0xff,0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0xf8,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x0f,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x01,0xfc,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xff,0xff,
+ 0xff,0xff,0x07,0x00,0x00,0x80,0xff,0xff,0xff,0xff,0x01,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xf0,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0x0f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0x01,0xfc,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0xc0,0xff,0xff,0xff,0xff,0x07,0x00,0x00,0xc0,0xff,0xff,0xff,0xff,0x01,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xf0,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0x07,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0x03,0xfc,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0xe0,0xff,0xff,0xff,0xff,0x03,0x00,0x00,0xe0,0xff,
+ 0xff,0xff,0xff,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0xe0,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x03,0x00,0x00,0x00,0x00,
+ 0xf8,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x03,0xfc,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xf8,0xff,0xff,0xff,0xff,0x03,
+ 0x00,0x00,0xe0,0xff,0xff,0xff,0xff,0x07,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0xe0,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x01,
+ 0x00,0x00,0x00,0x00,0xfe,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x80,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x03,0xfc,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfc,0xff,
+ 0xff,0xff,0xff,0x01,0x00,0x00,0xf0,0xff,0xff,0xff,0xff,0x07,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xe0,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0x00,0x00,0x00,0x00,0x80,0xff,0x07,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x80,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0x07,0xfc,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0xfe,0xff,0xff,0xff,0xff,0x01,0x00,0x00,0xf0,0xff,0xff,0xff,0xff,
+ 0x0f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xc0,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x00,0x00,0x00,0x00,0xc0,0xff,0x07,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xc0,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0x07,0xfc,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x80,0xff,0xff,0xff,0xff,0xff,0x01,0x00,0x00,0xf8,
+ 0xff,0xff,0xff,0xff,0x1f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0xc0,0xff,0xff,0xff,0xff,0xff,0xff,0x7f,0x00,0x00,0x00,0x00,
+ 0xe0,0xff,0x0f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xc0,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x0f,0xfc,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xc0,0xff,0xff,0xff,0xff,0xff,
+ 0x00,0x00,0x00,0xf8,0xff,0xff,0xff,0xff,0x1f,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xff,0xff,0xff,0xff,0xff,0xff,0x3f,
+ 0x00,0x00,0x00,0x00,0xf8,0xff,0x0f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0xc0,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x0f,0xfc,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xe0,0xff,
+ 0xff,0xff,0xff,0xff,0x00,0x00,0x00,0xfc,0xff,0xff,0xff,0xff,0x3f,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0x1f,0x00,0x00,0x00,0x00,0xfc,0xff,0x0f,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0xe0,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0x0f,0xfc,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0xf0,0xff,0xff,0xff,0xff,0xff,0x00,0x00,0x00,0xfc,0xff,0xff,0xff,
+ 0xff,0x3f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x80,0xff,0xff,0xff,0xff,0xff,0xff,0x0f,0x00,0x00,0x00,0x00,0xfe,0xff,0x0f,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xe0,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0x1f,0xfc,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0xfc,0xff,0xff,0xff,0xff,0x7f,0x00,0x00,0x00,
+ 0xfe,0xff,0xff,0xff,0xff,0x7f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0xff,0xff,0xff,0xff,0xff,0xff,0x0f,0x00,0x00,0x00,
+ 0x00,0xff,0xff,0x0f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xe0,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x1f,0xfc,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfe,0xff,0xff,0xff,0xff,
+ 0x7f,0x00,0x00,0x00,0xfe,0xff,0xff,0xff,0xff,0x7f,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0x07,0x00,0x00,0x00,0x80,0xff,0xff,0x1f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0xf0,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x1f,
+ 0xfc,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,
+ 0xff,0xff,0xff,0xff,0x7f,0x00,0x00,0x00,0xff,0xff,0xff,0xff,0xff,0xff,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfe,0xff,
+ 0xff,0xff,0xff,0xff,0x03,0x00,0x00,0x00,0xc0,0xff,0xff,0x1f,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xf0,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0x1f,0xfc,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x80,0xff,0xff,0xff,0xff,0xff,0x3f,0x00,0x00,0x00,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0xfe,0xff,0xff,0xff,0xff,0xff,0x01,0x00,0x00,0x00,0xe0,0xff,0xff,
+ 0x1f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xf0,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x3f,0xfc,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0xe0,0xff,0xff,0xff,0xff,0xff,0x3f,0x00,0x00,
+ 0x00,0xff,0xff,0xff,0xff,0xff,0xff,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0xfe,0xff,0xff,0xff,0xff,0xff,0x01,0x00,0x00,
+ 0x00,0xf0,0xff,0xff,0x1f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0xf8,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x3f,0xfc,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xf0,0xff,0xff,0xff,0xff,
+ 0xff,0x3f,0x00,0x00,0x80,0xff,0xff,0xff,0xff,0xff,0xff,0x01,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfc,0xff,0xff,0xff,0xff,
+ 0xff,0x00,0x00,0x00,0x00,0xf8,0xff,0xff,0x1f,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0xf8,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0x3f,0xfc,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xf8,
+ 0xff,0xff,0xff,0xff,0xff,0x1f,0x00,0x00,0x80,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfc,
+ 0xff,0xff,0xff,0xff,0x7f,0x00,0x00,0x00,0x00,0xfc,0xff,0xff,0x1f,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfc,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0x7f,0xfc,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0xfc,0xff,0xff,0xff,0xff,0xff,0x1f,0x00,0x00,0x80,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0xfc,0xff,0xff,0xff,0xff,0x3f,0x00,0x00,0x00,0x00,0xfe,0xff,
+ 0xff,0x1f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfc,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x7f,0xfc,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff,0xff,0xff,0xff,0xff,0x1f,0x00,
+ 0x00,0xc0,0xff,0xff,0xff,0xff,0xff,0xff,0x03,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xf8,0xff,0xff,0xff,0xff,0x3f,0x00,0x00,
+ 0x00,0x00,0xff,0xff,0xff,0x1f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0xfe,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x7f,0xfc,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0x1f,0x00,0x00,0xc0,0xff,0xff,0xff,0xff,0xff,0xff,0x07,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xf8,0xff,0xff,0xff,
+ 0xff,0x1f,0x00,0x00,0x00,0x80,0xff,0xff,0xff,0x1f,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0xfe,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0x7f,0xfc,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xc0,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0x0f,0x00,0x00,0xc0,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0x07,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0xf0,0xff,0xff,0xff,0xff,0x0f,0x00,0x00,0x00,0xc0,0xff,0xff,0xff,0x1f,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xfc,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0xe0,0xff,0xff,0xff,0xff,0xff,0xff,0x0f,0x00,0x00,0xe0,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0x07,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0xf0,0xff,0xff,0xff,0xff,0x07,0x00,0x00,0x00,0xe0,0xff,
+ 0xff,0xff,0x1f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xfc,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xf0,0xff,0xff,0xff,0xff,0xff,0xff,0x0f,
+ 0x00,0x00,0xe0,0xff,0xff,0xff,0xff,0xff,0xff,0x0f,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xf0,0xff,0xff,0xff,0xff,0x07,0x00,
+ 0x00,0x00,0xe0,0xff,0xff,0xff,0x1f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x80,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xfc,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xf8,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0x0f,0x00,0x00,0xe0,0xff,0xff,0xff,0xff,0xff,0xff,0x0f,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xe0,0xff,0xff,
+ 0xff,0xff,0x03,0x00,0x00,0x00,0xf0,0xff,0xff,0xff,0x1f,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x80,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xfc,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0xfe,0xff,0xff,0xff,0xff,0xff,0xff,0x0f,0x00,0x00,0xe0,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0x0f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0xe0,0xff,0xff,0xff,0xff,0x01,0x00,0x00,0x00,0xf8,0xff,0xff,0xff,0x1f,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xc0,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xfc,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x07,0x00,0x00,0xf0,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0x1f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0xe0,0xff,0xff,0xff,0xff,0x00,0x00,0x00,0x00,0xfc,
+ 0xff,0xff,0xff,0x3f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xc0,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xfd,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0x07,0x00,0x00,0xf0,0xff,0xff,0xff,0xff,0xff,0xff,0x1f,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xc0,0xff,0xff,0xff,0xff,0x00,
+ 0x00,0x00,0x00,0xfe,0xff,0xff,0xff,0x3f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0xe0,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xfd,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xc0,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0x07,0x00,0x00,0xf0,0xff,0xff,0xff,0xff,0xff,0xff,0x1f,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xc0,0xff,
+ 0xff,0xff,0x7f,0x00,0x00,0x00,0x00,0xff,0xff,0xff,0xff,0x3f,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0xf0,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xfd,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0xe0,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x07,0x00,0x00,0xf0,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0x3f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x80,0xff,0xff,0xff,0x3f,0x00,0x00,0x00,0x80,0xff,0xff,0xff,0xff,
+ 0x3f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xf0,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xfd,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0xf0,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x07,0x00,0x00,
+ 0xf0,0xff,0xff,0xff,0xff,0xff,0xff,0x3f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xff,0xff,0xff,0x3f,0x00,0x00,0x00,0x80,
+ 0xff,0xff,0xff,0xff,0x3f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xf8,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xfd,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xf8,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0x07,0x00,0x00,0xf8,0xff,0xff,0xff,0xff,0xff,0xff,0x7f,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xff,0xff,0xff,0x1f,
+ 0x00,0x00,0x00,0xc0,0xff,0xff,0xff,0xff,0x3f,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0xfc,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xfd,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfc,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0x03,0x00,0x00,0xf8,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0x7f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0xff,0xff,0xff,0x0f,0x00,0x00,0x00,0xe0,0xff,0xff,0xff,0xff,0x7f,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfc,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0xfe,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x03,0x00,0x00,0xf8,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0x7f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0xff,0xff,0xff,0x0f,0x00,0x00,0x00,0xf0,0xff,0xff,0xff,
+ 0xff,0x7f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfe,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x03,0x00,
+ 0x00,0xf8,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff,0xff,0x07,0x00,0x00,0x00,
+ 0xf8,0xff,0xff,0xff,0xff,0x7f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0x03,0x00,0x00,0xf8,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfe,0xff,0xff,
+ 0x03,0x00,0x00,0x00,0xf8,0xff,0xff,0xff,0xff,0x7f,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x80,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xc0,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0x03,0x00,0x00,0xf8,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0xfe,0xff,0xff,0x01,0x00,0x00,0x00,0xfc,0xff,0xff,0xff,0xff,0xff,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xc0,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0xf0,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x03,0x00,0x00,0xfc,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0xfe,0xff,0xff,0x01,0x00,0x00,0x00,0xfe,0xff,0xff,
+ 0xff,0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xc0,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0xf8,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x03,
+ 0x00,0x00,0xfc,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x01,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfc,0xff,0xff,0x00,0x00,0x00,
+ 0x00,0xff,0xff,0xff,0xff,0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0xe0,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfc,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0x03,0x00,0x00,0xfc,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x01,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfc,0xff,
+ 0x7f,0x00,0x00,0x00,0x00,0xff,0xff,0xff,0xff,0xff,0xff,0x01,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0xf0,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfe,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x03,0x00,0x00,0xfc,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0xfc,0xff,0x7f,0x00,0x00,0x00,0x80,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xf8,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x03,0x00,0x00,0xfc,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0xf8,0xff,0x3f,0x00,0x00,0x00,0xc0,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfc,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x80,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0x03,0x00,0x00,0xfc,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x07,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xf8,0xff,0x1f,0x00,0x00,
+ 0x00,0xe0,0xff,0xff,0xff,0xff,0xff,0xff,0x03,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0xfe,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xc0,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0x03,0x00,0x00,0xfc,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0x07,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xf0,
+ 0xff,0x1f,0x00,0x00,0x00,0xe0,0xff,0xff,0xff,0xff,0xff,0xff,0x07,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x80,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xe0,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x03,0x00,0x00,0xfc,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0x07,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0xf0,0xff,0x0f,0x00,0x00,0x00,0xf0,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0x07,0x00,0x00,0x00,0x00,0x00,0x00,0xc0,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0xf0,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x03,0x00,0x00,
+ 0xfc,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x0f,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xf0,0xff,0x07,0x00,0x00,0x00,0xf8,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0x0f,0x00,0x00,0x00,0x00,0x00,0x00,0xe0,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0xf8,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0x03,0x00,0x00,0xfc,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x0f,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xe0,0xff,0x07,0x00,
+ 0x00,0x00,0xfc,0xff,0xff,0xff,0xff,0xff,0xff,0x1f,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0xf0,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xf8,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0x03,0x00,0x00,0xfc,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0x0f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0xe0,0xff,0x03,0x00,0x00,0x00,0xfc,0xff,0xff,0xff,0xff,0xff,0xff,0x3f,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0xfc,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfc,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x03,0x00,0x00,0xfe,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0x1f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0xe0,0xff,0x01,0x00,0x00,0x00,0xfe,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0x3f,0x00,0x00,0x00,0x00,0x00,0x00,0xfe,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0xfe,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x03,0x00,
+ 0x00,0xfe,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x1f,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xc0,0xff,0x01,0x00,0x00,0x00,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0x7f,0x00,0x00,0x00,0x00,0x00,0x80,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0x07,0x00,0x00,0xfe,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x1f,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xc0,0xff,0x00,
+ 0x00,0x00,0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x01,0x00,0x00,0x00,
+ 0x00,0xe0,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0x07,0x00,0x00,0xfe,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0x3f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x80,0x7f,0x00,0x00,0x00,0x80,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0x03,0x00,0x00,0x00,0x00,0xf8,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xc0,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x07,0x00,0x00,0xfe,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0x3f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x80,0x7f,0x00,0x00,0x00,0xc0,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0x07,0x00,0x00,0x00,0x00,0xfe,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0xe0,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x07,
+ 0x00,0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x7f,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x3f,0x00,0x00,0x00,0xe0,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x1f,0x00,0x00,0x00,0x80,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xf0,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0x0f,0x00,0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x7f,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3f,
+ 0x00,0x00,0x00,0xe0,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x7f,0x00,0x00,
+ 0x00,0xf0,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xf8,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x0f,0x00,0x80,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0x7f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x1f,0x00,0x00,0x00,0xf0,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0x07,0x00,0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0xfc,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x1f,0x00,0x80,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0e,0x00,0x00,0x00,0xf8,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x00,0xfc,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0xfe,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0x1f,0x00,0xc0,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0e,0x00,0x00,0x00,
+ 0xf8,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0x3f,0x00,0xe0,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x06,0x00,0x00,0x00,0xfc,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x7f,0x00,0xf0,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfe,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x80,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x01,0xfc,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x01,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfe,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0xc0,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x01,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0xe0,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x80,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0xf0,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0xf8,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x07,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xc0,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0xfc,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x07,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0xe0,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0xfc,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0x07,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0xe0,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xfd,0x00,0x00,0x00,0x00,0x00,0x00,0xfe,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x0f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xf0,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xfd,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x0f,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xf8,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xfd,
+ 0x00,0x00,0x00,0x00,0x00,0x80,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0x0f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0xf8,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xfd,0x00,0x00,0x00,0x00,0x00,0xc0,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0x1f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0xfc,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xfd,0x00,0x00,0x00,0x00,0x00,0xc0,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x1f,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfe,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xfd,0x00,0x00,0x00,
+ 0x00,0x00,0xe0,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x1f,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfe,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xfd,0x00,0x00,0x00,0x00,0x00,0xf0,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0x3f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xfc,0x00,0x00,0x00,0x00,0x00,0xf8,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0x3f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xfc,0x00,0x00,0x00,0x00,0x00,0xf8,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x7f,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xfc,0x00,0x00,
+ 0x00,0x00,0x00,0xfc,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x7f,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xc0,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xfc,0x00,0x00,0x00,0x00,0x00,0xfe,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0x7f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0xc0,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xfc,0x00,0x00,0x00,0x00,0x00,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xe0,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x7f,0xfc,0x00,0x00,0x00,0x00,0x00,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xf0,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x7f,0xfc,0x00,
+ 0x00,0x00,0x00,0x80,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0xf0,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0x7f,0xfc,0x00,0x00,0x00,0x00,0xc0,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0xf8,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0x7f,0xfc,0x00,0x00,0x00,0x00,0xe0,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x01,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xf8,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x7f,0xfc,0x00,0x00,0x00,0x00,
+ 0xe0,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x01,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfc,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x3f,0xfc,
+ 0x00,0x00,0x00,0x00,0xf0,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0xfe,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0x3f,0xfc,0x00,0x00,0x00,0x00,0xf8,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0xfe,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0x3f,0xfc,0x00,0x00,0x00,0x00,0xf8,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x07,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x3f,0xfc,0x00,0x00,0x00,
+ 0x00,0xfc,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x07,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x1f,
+ 0xfc,0x00,0x00,0x00,0x00,0xfe,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0x07,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x80,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0x1f,0xfc,0x00,0x00,0x00,0x00,0xfe,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0x0f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x80,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x1f,0xfc,0x00,0x00,0x00,0x00,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x0f,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xc0,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x0f,0xfc,0x00,0x00,
+ 0x00,0x80,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x0f,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xc0,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0x0f,0xfc,0x00,0x00,0x00,0x80,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0x1f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x80,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0x0f,0xfc,0x00,0x00,0x00,0xc0,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x1f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x07,0xfc,0x00,0x00,0x00,0xe0,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x1f,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x07,0xfc,0x00,
+ 0x00,0x00,0xe0,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0x3f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0x07,0xfc,0x00,0x00,0x00,0xf0,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0x3f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0x07,0xfc,0x00,0x00,0x00,0xf0,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x7f,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x03,0xfc,0x00,0x00,0x00,0xf8,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x7f,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfe,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x03,0xfc,
+ 0x00,0x00,0x00,0xfc,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0x7f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0xfe,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0x03,0xfc,0x00,0x00,0x00,0xfc,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0xfe,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0x01,0xfc,0x00,0x00,0x00,0xfe,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfc,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x01,0xfc,0x00,0x00,0x00,
+ 0xfe,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfc,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x00,
+ 0xfc,0x00,0x00,0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0xfc,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0x00,0xfc,0x00,0x00,0x80,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0xf8,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x00,0xfc,0x00,0x00,0x80,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x01,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xf8,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x7f,0x00,0xfc,0x00,0x00,
+ 0xc0,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xf8,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x7f,
+ 0x00,0xfc,0x00,0x00,0xc0,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0xf0,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0x3f,0x00,0xfc,0x00,0x00,0xe0,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x03,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xf0,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x3f,0x00,0xfc,0x00,0x00,0xe0,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x07,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xf0,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x3f,0x00,0xfc,0x00,
+ 0x00,0xf0,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0x07,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0xe0,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0x1f,0x00,0xfc,0x00,0x00,0xf0,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0x07,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0xe0,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0x1f,0x00,0xfc,0x00,0x00,0xf8,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x0f,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xe0,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x0f,0x00,0xfc,0x00,0x00,0xf8,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x0f,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xc0,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x0f,0x00,0xfc,
+ 0x00,0x00,0xfc,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0x0f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0xc0,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0x0f,0x00,0xfc,0x00,0x00,0xfc,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0x1f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0xc0,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0x07,0x00,0xfc,0x00,0x00,0xfe,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x1f,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x07,0x00,0xfc,0x00,0x00,0xfe,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x3f,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x03,0x00,
+ 0xfc,0x00,0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0x3f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x80,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0x03,0x00,0xfc,0x00,0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x3f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0x01,0x00,0xfc,0x00,0x80,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x7f,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x01,0x00,0xfc,0x00,0x80,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0x7f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x00,
+ 0x00,0xfc,0x00,0xc0,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0x7f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0xfe,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0x00,0x00,0xfc,0x00,0xc0,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfe,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0x7f,0x00,0x00,0xfc,0x00,0xe0,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfe,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x7f,0x00,0x00,0xfc,0x00,
+ 0xe0,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0xfc,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x3f,
+ 0x00,0x00,0xfc,0x00,0xe0,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0xfc,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0x3f,0x00,0x00,0xfc,0x00,0xf0,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x01,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfc,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x1f,0x00,0x00,0xfc,0x00,0xf0,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x01,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xf8,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x1f,0x00,0x00,0xfc,
+ 0x00,0xf8,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0xf8,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0x0f,0x00,0x00,0xfc,0x00,0xf8,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0xf8,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0x07,0x00,0x00,0xfc,0x00,0xf8,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x03,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xf0,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x07,0x00,0x00,0xfc,0x00,0xfc,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0x07,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xf0,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x03,0x00,0x00,
+ 0xfc,0x00,0xfc,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0x07,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0xf0,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0x03,0x00,0x00,0xfc,0x00,0xfe,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x07,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xe0,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0x01,0x00,0x00,0xfc,0x00,0xfe,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x0f,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xe0,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x01,0x00,0x00,0xfc,0x00,0xfe,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0x0f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0xe0,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x00,0x00,
+ 0x00,0xfc,0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0x0f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0xc0,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0x7f,0x00,0x00,0x00,0xfc,0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x1f,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xc0,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0x7f,0x00,0x00,0x00,0xfc,0x00,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x1f,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xc0,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x3f,0x00,0x00,0x00,0xfc,0x80,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0x1f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x80,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x3f,0x00,
+ 0x00,0x00,0xfc,0x80,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0x3f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x80,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0x1f,0x00,0x00,0x00,0xfc,0x80,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x3f,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0x0f,0x00,0x00,0x00,0xfc,0xc0,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x3f,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x0f,0x00,0x00,0x00,0xfc,
+ 0xc0,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0x7f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x07,
+ 0x00,0x00,0x00,0xfc,0xc0,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x7f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfe,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0x03,0x00,0x00,0x00,0xfc,0xc0,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x7f,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfe,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x03,0x00,0x00,0x00,0xfc,0xe0,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0x7f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0xfe,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x01,0x00,0x00,0x00,
+ 0xfc,0xe0,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0x3f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0xfc,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0x01,0x00,0x00,0x00,0xfc,0xe0,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x3f,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfc,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0x00,0x00,0x00,0x00,0xfc,0xf0,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x1f,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfc,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x7f,0x00,0x00,0x00,0x00,0xfc,0xf0,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0x1f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0xf8,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x3f,0x00,0x00,0x00,
+ 0x00,0xfc,0xf0,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0x0f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0xf8,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0x3f,0x00,0x00,0x00,0x00,0xfc,0xf0,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x07,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xf8,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0x1f,0x00,0x00,0x00,0x00,0xfc,0xf8,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x07,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xf0,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x0f,0x00,0x00,0x00,0x00,0xfc,0xf8,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0xf0,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x0f,0x00,0x00,
+ 0x00,0x00,0xfc,0xf8,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0xf0,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0x07,0x00,0x00,0x00,0x00,0xfc,0xf8,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x01,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xe0,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0x03,0x00,0x00,0x00,0x00,0xfc,0xf8,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xe0,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x01,0x00,0x00,0x00,0x00,0xfc,
+ 0xfc,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0xe0,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x01,0x00,
+ 0x00,0x00,0x00,0xfc,0xfc,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0x7f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xc0,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0x00,0x00,0x00,0x00,0x00,0xfc,0xfc,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x3f,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xc0,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0x7f,0x00,0x00,0x00,0x00,0x00,0xfc,0xfc,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x1f,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0xc0,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x3f,0x00,0x00,0x00,0x00,0x00,
+ 0xfc,0xfc,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0x1f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x80,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x3f,0x00,
+ 0x00,0x00,0x00,0x00,0xfc,0xfe,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x0f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0x1f,0x00,0x00,0x00,0x00,0x00,0xfc,0xfe,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x07,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0x0f,0x00,0x00,0x00,0x00,0x00,0xfc,0xfe,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0x07,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x07,0x00,0x00,0x00,0x00,
+ 0x00,0xfc,0xfe,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x07,
+ 0x00,0x00,0x00,0x00,0x00,0xfc,0xfe,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x01,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0x03,0x00,0x00,0x00,0x00,0x00,0xfc,0xfe,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x01,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfe,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x01,0x00,0x00,0x00,0x00,0x00,0xfc,0xfe,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0xfe,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0xfc,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0x7f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfe,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0x80,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x7f,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0xfc,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x3f,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfc,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0x7f,0x00,0xfe,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0x3f,0x00,0x00,0x00,0x00,0x00,0x00,0xfc,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x3f,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0xfc,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x3f,0x00,0xfc,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x3f,0x00,0x00,0x00,0x00,0x00,0x00,0xfc,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0x7f,0x00,0xc0,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0x1f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0xf8,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x1f,0x00,0xf8,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x1f,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0xfc,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0x03,0x00,0x00,0xfc,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0x0f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xf8,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0x0f,0x00,0xf0,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0x0f,0x00,0x00,0x00,0x00,0x00,0x00,0xfc,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x7f,0x00,0x00,0x00,0xe0,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x07,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xf8,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0x0f,0x00,0xe0,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0x07,0x00,0x00,0x00,0x00,0x00,0x00,0xfc,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x0f,0x00,0x00,0x00,
+ 0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x07,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0xf0,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x07,0x00,0xe0,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x03,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0xfc,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0x01,0x00,0x00,0x00,0x00,0xfc,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0xf0,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x07,0x00,
+ 0xe0,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x01,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0xfc,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0x7f,0x00,0x00,0x00,0x00,0x00,0xf0,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0x01,0x00,0x00,0x00,0x06,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xf0,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0x03,0x00,0xc0,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfc,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x1f,0x00,0x00,0x00,0x00,0x00,0xc0,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x00,0x00,0x00,0x00,0x07,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xe0,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0x03,0x00,0xc0,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfc,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x0f,0x00,0x00,0x00,
+ 0x00,0x00,0x80,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x00,
+ 0x00,0x00,0x80,0x07,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0xe0,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x01,0x00,0xc0,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x7f,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0xfc,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0x03,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0x7f,0x00,0x00,0x00,0xc0,0x0f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0xe0,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x01,
+ 0x00,0xc0,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x3f,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0xfc,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0xfc,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0x3f,0x00,0x00,0x00,0xc0,0x0f,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xc0,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0x01,0x00,0x80,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0x1f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfc,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x7f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0xf8,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x1f,0x00,0x00,0x00,0xe0,
+ 0x1f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xc0,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x01,0x00,0x80,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0x0f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfc,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x3f,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0xf0,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x1f,
+ 0x00,0x00,0x00,0xf0,0x1f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x80,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x00,0x00,0x80,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x07,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0xfc,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0x1f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xe0,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0x0f,0x00,0x00,0x00,0xf8,0x1f,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0x00,0x00,0x80,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x03,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0xfc,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0x0f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xe0,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x07,0x00,0x00,0x00,0xfc,0x3f,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0x00,0x00,0x80,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfc,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x07,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0xc0,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x03,0x00,0x00,0x00,
+ 0xfc,0x3f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x00,0x00,0x80,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfc,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x03,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x80,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0x01,0x00,0x00,0x00,0xfe,0x7f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x00,0x00,0x80,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x7f,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0xfc,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0x01,0x00,0x00,0x00,0xff,0x7f,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfe,0xff,0xff,0xff,0xff,0xff,
+ 0x7f,0x00,0x00,0x80,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x3f,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfc,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x00,0x00,0x00,0x80,0xff,0x7f,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfe,0xff,
+ 0xff,0xff,0xff,0xff,0x7f,0x00,0x00,0x80,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0x1f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfc,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x7f,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0xfe,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x7f,0x00,0x00,0x00,
+ 0x80,0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0xfe,0xff,0xff,0xff,0xff,0xff,0x7f,0x00,0x00,0x80,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0x0f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0xfc,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x3f,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfe,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0x3f,0x00,0x00,0x00,0xc0,0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0xfc,0xff,0xff,0xff,0xff,0xff,0x7f,0x00,0x00,
+ 0x80,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x07,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0xfc,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0x1f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfc,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0x1f,0x00,0x00,0x00,0xe0,0xff,0xff,0x01,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfc,0xff,0xff,0xff,0xff,
+ 0xff,0x7f,0x00,0x00,0x80,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x03,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfc,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0x0f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0xfc,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x0f,0x00,0x00,0x00,0xf0,0xff,0xff,
+ 0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xf8,
+ 0xff,0xff,0xff,0xff,0xff,0x3f,0x00,0x00,0x80,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfc,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x07,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0xfc,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x0f,0x00,0x00,
+ 0x00,0xf8,0xff,0xff,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0xf8,0xff,0xff,0xff,0xff,0xff,0x3f,0x00,0x00,0xc0,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0xfc,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x03,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xf8,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0x07,0x00,0x00,0x00,0xf8,0xff,0xff,0x03,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xf0,0xff,0xff,0xff,0xff,0xff,0x3f,0x00,
+ 0x00,0xc0,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x7f,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0xfc,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xf8,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0x03,0x00,0x00,0x00,0xfc,0xff,0xff,0x03,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xf0,0xff,0xff,0xff,
+ 0xff,0xff,0x3f,0x00,0x00,0xc0,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x3f,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfc,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0xf8,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x01,0x00,0x00,0x00,0xfe,0xff,
+ 0xff,0x07,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0xf0,0xff,0xff,0xff,0xff,0xff,0x3f,0x00,0x00,0xc0,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0x1f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfc,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0xf0,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x00,0x00,
+ 0x00,0x00,0xff,0xff,0xff,0x07,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0xe0,0xff,0xff,0xff,0xff,0xff,0x1f,0x00,0x00,0xc0,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x0f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0xfc,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xf0,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0x7f,0x00,0x00,0x00,0x00,0xff,0xff,0xff,0x07,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xe0,0xff,0xff,0xff,0xff,0xff,0x1f,
+ 0x00,0x00,0xc0,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x07,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0xfc,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0x7f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xf0,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0x3f,0x00,0x00,0x00,0x80,0xff,0xff,0xff,0x0f,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xc0,0xff,0xff,
+ 0xff,0xff,0xff,0x1f,0x00,0x00,0xc0,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfc,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0x3f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0xf0,0xff,0xff,0xff,0xff,0xff,0xff,0x3f,0x00,0x00,0x00,0xc0,0xff,
+ 0xff,0xff,0x0f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0xc0,0xff,0xff,0xff,0xff,0xff,0x1f,0x00,0x00,0xe0,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfc,
+ 0xfe,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x3f,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0xf0,0xff,0xff,0xff,0xff,0xff,0xff,0x1f,0x00,
+ 0x00,0x00,0xe0,0xff,0xff,0xff,0x0f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x80,0xff,0xff,0xff,0xff,0xff,0x0f,0x00,0x00,0xe0,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0xfc,0xfe,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x1f,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xf0,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0x0f,0x00,0x00,0x00,0xf0,0xff,0xff,0xff,0x1f,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff,0xff,0xff,0xff,
+ 0x0f,0x00,0x00,0xe0,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x7f,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfc,0xfe,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0x1f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xf0,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0x07,0x00,0x00,0x00,0xf0,0xff,0xff,0xff,0x1f,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,
+ 0xff,0xff,0xff,0xff,0x0f,0x00,0x00,0xe0,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0x3f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfc,0xfe,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x0f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0xf0,0xff,0xff,0xff,0xff,0xff,0xff,0x03,0x00,0x00,0x00,0xf8,
+ 0xff,0xff,0xff,0x3f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0xfe,0xff,0xff,0xff,0xff,0x0f,0x00,0x00,0xe0,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0x1f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0xfc,0xfe,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x0f,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xf0,0xff,0xff,0xff,0xff,0xff,0xff,0x01,
+ 0x00,0x00,0x00,0xfc,0xff,0xff,0xff,0x3f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfe,0xff,0xff,0xff,0xff,0x07,0x00,0x00,
+ 0xe0,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x0f,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0xfc,0xfe,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0x07,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xf0,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0x00,0x00,0x00,0x00,0xfe,0xff,0xff,0xff,0x3f,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfc,0xff,0xff,0xff,
+ 0xff,0x07,0x00,0x00,0xf0,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x03,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfc,0xfe,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0x07,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0xf0,0xff,0xff,0xff,0xff,0xff,0x7f,0x00,0x00,0x00,0x00,0xfe,0xff,0xff,0xff,
+ 0x7f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0xfc,0xff,0xff,0xff,0xff,0x07,0x00,0x00,0xf0,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfc,0xfc,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x03,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0xf0,0xff,0xff,0xff,0xff,0xff,0x3f,0x00,0x00,0x00,0x00,
+ 0xff,0xff,0xff,0xff,0x7f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0xf8,0xff,0xff,0xff,0xff,0x03,0x00,0x00,0xf0,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0xfc,0xfc,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x03,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xf0,0xff,0xff,0xff,0xff,0xff,0x1f,
+ 0x00,0x00,0x00,0x80,0xff,0xff,0xff,0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xf0,0xff,0xff,0xff,0xff,0x03,0x00,
+ 0x00,0xf0,0xff,0xff,0xff,0xff,0xff,0xff,0x7f,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0xfc,0xfc,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xf0,0xff,0xff,
+ 0xff,0xff,0xff,0x1f,0x00,0x00,0x00,0xc0,0xff,0xff,0xff,0xff,0xff,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xf0,0xff,0xff,
+ 0xff,0xff,0x03,0x00,0x00,0xf8,0xff,0xff,0xff,0xff,0xff,0xff,0x3f,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfc,0xfc,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0xf0,0xff,0xff,0xff,0xff,0xff,0x0f,0x00,0x00,0x00,0xe0,0xff,0xff,0xff,
+ 0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0xe0,0xff,0xff,0xff,0xff,0x01,0x00,0x00,0xf8,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0x1f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfc,0xfc,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0xf0,0xff,0xff,0xff,0xff,0xff,0x07,0x00,0x00,0x00,
+ 0xe0,0xff,0xff,0xff,0xff,0xff,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0xc0,0xff,0xff,0xff,0xff,0x01,0x00,0x00,0xf8,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0x0f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0xfc,0xf8,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xf8,0xff,0xff,0xff,0xff,0xff,
+ 0x03,0x00,0x00,0x00,0xf0,0xff,0xff,0xff,0xff,0xff,0x01,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xff,0xff,0xff,0xff,0x00,
+ 0x00,0x00,0xfc,0xff,0xff,0xff,0xff,0xff,0xff,0x03,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0xfc,0xf8,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xf8,0xff,
+ 0xff,0xff,0xff,0xff,0x01,0x00,0x00,0x00,0xf8,0xff,0xff,0xff,0xff,0xff,0x01,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xff,
+ 0xff,0xff,0xff,0x00,0x00,0x00,0xfc,0xff,0xff,0xff,0xff,0xff,0xff,0x01,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfc,0xf8,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0x7f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0xf8,0xff,0xff,0xff,0xff,0xff,0x00,0x00,0x00,0x00,0xfc,0xff,0xff,
+ 0xff,0xff,0xff,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0xff,0xff,0xff,0x7f,0x00,0x00,0x00,0xfc,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfc,
+ 0xf8,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x7f,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0xf8,0xff,0xff,0xff,0xff,0x7f,0x00,0x00,0x00,
+ 0x00,0xfe,0xff,0xff,0xff,0xff,0xff,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfe,0xff,0xff,0x3f,0x00,0x00,0x00,0xfc,
+ 0xff,0xff,0xff,0xff,0xff,0x7f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0xfc,0xf0,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x7f,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfc,0xff,0xff,0xff,0xff,
+ 0x3f,0x00,0x00,0x00,0x00,0xff,0xff,0xff,0xff,0xff,0xff,0x07,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfc,0xff,0xff,0x3f,
+ 0x00,0x00,0x00,0xfe,0xff,0xff,0xff,0xff,0xff,0x3f,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfc,0xf0,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0x3f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfc,
+ 0xff,0xff,0xff,0xff,0x1f,0x00,0x00,0x00,0x00,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0x07,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0xf8,0xff,0xff,0x1f,0x00,0x00,0x00,0xfe,0xff,0xff,0xff,0xff,0xff,0x0f,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfc,0xf0,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0x3f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0xfc,0xff,0xff,0xff,0xff,0x0f,0x00,0x00,0x00,0x80,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0x0f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0xe0,0xff,0xff,0x0f,0x00,0x00,0x00,0xfe,0xff,0xff,0xff,
+ 0xff,0xff,0x07,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0xfc,0xe0,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x3f,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfe,0xff,0xff,0xff,0xff,0x07,0x00,0x00,
+ 0x00,0xc0,0xff,0xff,0xff,0xff,0xff,0xff,0x0f,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xc0,0xff,0xff,0x07,0x00,0x00,0x00,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0xfc,0xe0,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x1f,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfe,0xff,0xff,0xff,
+ 0xff,0x01,0x00,0x00,0x00,0xe0,0xff,0xff,0xff,0xff,0xff,0xff,0x0f,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xff,0xff,
+ 0x01,0x00,0x00,0x00,0xff,0xff,0xff,0xff,0xff,0xff,0x01,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfc,0xe0,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0x1f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0xff,0xff,0xff,0xff,0xff,0x00,0x00,0x00,0x00,0xf0,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0x1f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0xfe,0x7f,0x00,0x00,0x00,0x80,0xff,0xff,0xff,0xff,0xff,0x7f,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfc,0xc0,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x1f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0xff,0xff,0xff,0xff,0x7f,0x00,0x00,0x00,0x00,0xf8,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0x1f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0xf0,0x1f,0x00,0x00,0x00,0x80,0xff,0xff,0xff,
+ 0xff,0xff,0x3f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0xfc,0xc0,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x1f,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff,0xff,0xff,0x3f,0x00,0x00,
+ 0x00,0x00,0xf8,0xff,0xff,0xff,0xff,0xff,0xff,0x3f,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x80,0xff,0xff,0xff,0xff,0xff,0x1f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0xfc,0xc0,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0x1f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xff,0xff,0xff,
+ 0xff,0x1f,0x00,0x00,0x00,0x00,0xfc,0xff,0xff,0xff,0xff,0xff,0xff,0x3f,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0xc0,0xff,0xff,0xff,0xff,0xff,0x0f,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfc,0x80,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0x0f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x80,0xff,0xff,0xff,0xff,0x0f,0x00,0x00,0x00,0x00,0xfe,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0x3f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xc0,0xff,0xff,0xff,0xff,0xff,0x03,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfc,0x80,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x0f,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x80,0xff,0xff,0xff,0xff,0x07,0x00,0x00,0x00,0x00,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0x7f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xc0,0xff,0xff,
+ 0xff,0xff,0xff,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0xfc,0x80,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x0f,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xc0,0xff,0xff,0xff,0xff,0x03,0x00,
+ 0x00,0x00,0x80,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x7f,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0xe0,0xff,0xff,0xff,0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0xfc,0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0x0f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xc0,0xff,0xff,
+ 0xff,0xff,0x00,0x00,0x00,0x00,0xc0,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0xe0,0xff,0xff,0xff,0xff,0x3f,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfc,0x00,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0x0f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0xc0,0xff,0xff,0xff,0x7f,0x00,0x00,0x00,0x00,0xe0,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xf0,0xff,0xff,0xff,0xff,0x1f,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfc,
+ 0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x0f,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0xe0,0xff,0xff,0xff,0x3f,0x00,0x00,0x00,0x00,0xf0,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x01,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xf0,0xff,
+ 0xff,0xff,0xff,0x0f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0xfc,0x00,0xfe,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x0f,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xe0,0xff,0xff,0xff,0x1f,0x00,
+ 0x00,0x00,0x00,0xf0,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x01,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0xf8,0xff,0xff,0xff,0xff,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfc,0x00,0xfe,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0x0f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xe0,0xff,
+ 0xff,0xff,0x07,0x00,0x00,0x00,0x00,0xf8,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0xf8,0xff,0xff,0xff,0xff,0x01,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfc,0x00,0xfc,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0x07,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0xe0,0xff,0xff,0xff,0x03,0x00,0x00,0x00,0x00,0xfc,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfc,0xff,0xff,0xff,0x7f,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0xfc,0x00,0xfc,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x07,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0xe0,0xff,0xff,0xff,0x00,0x00,0x00,0x00,0x00,
+ 0xfe,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x03,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfc,
+ 0xff,0xff,0xff,0x3f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0xfc,0x00,0xf8,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x07,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xe0,0xff,0xff,0x7f,0x00,
+ 0x00,0x00,0x00,0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x07,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0xfe,0xff,0xff,0xff,0x1f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfc,0x00,0xf8,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0x07,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xc0,
+ 0xff,0xff,0x1f,0x00,0x00,0x00,0x00,0x80,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0x07,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfe,0xff,0xff,0xff,0x07,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfc,0x00,0xf0,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x07,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0xc0,0xff,0xff,0x07,0x00,0x00,0x00,0x00,0xc0,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0x0f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff,0xff,0xff,
+ 0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0xfc,0x00,0xf0,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x07,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xff,0xff,0x01,0x00,0x00,0x00,0x00,
+ 0xe0,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x0f,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0xff,0xff,0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0xfc,0x00,0xe0,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0x07,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0x7f,0x00,
+ 0x00,0x00,0x00,0x00,0xf0,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x1f,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x80,0xff,0xff,0xff,0x7f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfc,0x00,0xe0,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0x07,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0xfe,0x1f,0x00,0x00,0x00,0x00,0x00,0xf8,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0x1f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xff,0xff,0xff,0x1f,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfc,0x00,
+ 0xc0,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x0f,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0xf0,0x01,0x00,0x00,0x00,0x00,0x00,0xfc,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x3f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xc0,0xff,0xff,0xff,
+ 0x0f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0xfc,0x00,0xc0,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x0f,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0xfe,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x7f,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0xc0,0xff,0xff,0xff,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0xfc,0x00,0x80,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0x0f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0x7f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0xe0,0xff,0xff,0xff,0x01,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfc,0x00,0x80,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0x0f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xf0,0xff,0xff,0x7f,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfc,
+ 0x00,0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x0f,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xc0,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xf0,0xff,0xff,
+ 0x3f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0xfc,0x00,0x00,0xfe,0xff,0xff,0xff,0xff,0xff,0xff,0x0f,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0xe0,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x01,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0xf8,0xff,0xff,0x0f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfc,0x00,0x00,0xfe,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0x0f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0xf0,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0xf8,0xff,0xff,0x07,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfc,0x00,0x00,0xfc,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0x0f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xf8,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfc,0xff,0xff,0x01,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0xfc,0x00,0x00,0xfc,0xff,0xff,0xff,0xff,0xff,0xff,0x0f,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfc,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x03,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfe,0xff,
+ 0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0xfc,0x00,0x00,0xf8,0xff,0xff,0xff,0xff,0xff,0xff,0x1f,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0xfe,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x07,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0xfe,0xff,0x3f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfc,0x00,0x00,0xf0,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0x1f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0x0f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff,0x0f,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfc,0x00,0x00,
+ 0xf0,0xff,0xff,0xff,0xff,0xff,0xff,0x1f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x0f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xff,0xff,0x07,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0xfc,0x00,0x00,0xe0,0xff,0xff,0xff,0xff,0xff,0xff,0x1f,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xc0,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x1f,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xc0,0xff,
+ 0xff,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0xfc,0x00,0x00,0xc0,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0x3f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0xe0,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0x3f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0xc0,0xff,0x7f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfc,0x00,0x00,0xc0,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0x3f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0xf0,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0x3f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0xe0,0xff,0x3f,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfc,0x00,
+ 0x00,0x80,0xff,0xff,0xff,0xff,0xff,0xff,0x3f,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfc,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x7f,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xf0,0xff,0x0f,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0xfc,0x00,0x00,0x00,0xff,0xff,0xff,0xff,0xff,0xff,0x7f,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfe,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xf8,
+ 0xff,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0xfc,0x00,0x00,0x00,0xfe,0xff,0xff,0xff,0xff,
+ 0xff,0x7f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0xf8,0xff,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfc,0x00,0x00,0x00,0xfe,
+ 0xff,0xff,0xff,0xff,0xff,0x7f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfc,0x7f,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfc,
+ 0x00,0x00,0x00,0xfc,0xff,0xff,0xff,0xff,0xff,0xff,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xc0,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x03,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfe,0x1f,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0xfc,0x00,0x00,0x00,0xf8,0xff,0xff,0xff,0xff,0xff,0xff,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xf0,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x07,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0xff,0x07,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfc,0x00,0x00,0x00,0xf0,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0xf8,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0x07,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x80,0xff,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfc,0x00,0x00,0x00,
+ 0xe0,0xff,0xff,0xff,0xff,0xff,0xff,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfc,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x0f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xc0,0xff,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0xfc,0x00,0x00,0x00,0xc0,0xff,0xff,0xff,0xff,0xff,0xff,0x03,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x1f,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xe0,0x3f,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0xfc,0x00,0x00,0x00,0x80,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0x3f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0xf0,0x0f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfc,0x00,0x00,0x00,0x80,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0x07,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0xc0,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0x7f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0xf8,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfc,0x00,0x00,
+ 0x00,0x00,0xff,0xff,0xff,0xff,0xff,0xff,0x07,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xf0,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfc,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0xfc,0x00,0x00,0x00,0x00,0xfe,0xff,0xff,0xff,0xff,0xff,0x0f,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xf8,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7e,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0xfc,0x00,0x00,0x00,0x00,0xfc,0xff,0xff,0xff,0xff,
+ 0xff,0x1f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0xfe,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x1f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfc,0x00,0x00,0x00,0x00,0xf8,
+ 0xff,0xff,0xff,0xff,0xff,0x3f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x80,0x07,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfc,0x00,
+ 0x00,0x00,0x00,0xf0,0xff,0xff,0xff,0xff,0xff,0x3f,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xc0,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x07,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xe0,0x01,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0xfc,0x00,0x00,0x00,0x00,0xe0,0xff,0xff,0xff,0xff,0xff,0x7f,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xe0,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x0f,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x70,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0xfc,0x00,0x00,0x00,0x00,0xc0,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0xf8,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0x3f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x18,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfc,0x00,0x00,0x00,0x00,
+ 0x80,0xff,0xff,0xff,0xff,0xff,0xff,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0xfe,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x7f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x06,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfc,
+ 0x00,0x00,0x00,0x00,0x00,0xff,0xff,0xff,0xff,0xff,0xff,0x03,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0xfc,0x00,0x00,0x00,0x00,0x00,0xfc,0xff,0xff,0xff,0xff,0xff,
+ 0x07,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xc0,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x40,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfc,0x00,0x00,0x00,0x00,0x00,0xf8,0xff,
+ 0xff,0xff,0xff,0xff,0x0f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0xf0,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0x07,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfc,0x00,0x00,0x00,
+ 0x00,0x00,0xf0,0xff,0xff,0xff,0xff,0xff,0x1f,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0xfc,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x0f,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0xfc,0x00,0x00,0x00,0x00,0x00,0xe0,0xff,0xff,0xff,0xff,0xff,0x7f,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x1f,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0xfc,0x00,0x00,0x00,0x00,0x00,0xc0,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xc0,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0x7f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfc,0x00,0x00,0x00,0x00,0x00,0x80,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0xf0,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfc,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0xfe,0xff,0xff,0xff,0xff,0xff,0x07,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0xfe,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x03,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0xfc,0x00,0x00,0x00,0x00,0x00,0x00,0xfc,0xff,0xff,0xff,0xff,0xff,0x1f,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0x0f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0xfc,0x00,0x00,0x00,0x00,0x00,0x00,0xf8,0xff,0xff,
+ 0xff,0xff,0xff,0x7f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xf0,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0x7f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfc,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0xe0,0xff,0xff,0xff,0xff,0xff,0xff,0x01,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0xfe,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x01,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfc,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0xc0,0xff,0xff,0xff,0xff,0xff,0xff,0x0f,0x00,0x00,
+ 0x00,0x00,0x00,0xe0,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x0f,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0xfc,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0x7f,0x00,0x00,0x00,0x00,0x00,0xfe,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0x7f,0x00,0x00,0x00,0x00,0x00,0x30,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0xfc,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfe,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0x07,0x00,0x00,0x00,0xe0,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x07,0x00,0x00,0x00,0x80,0x0f,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfc,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0xfc,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x01,0x00,0xc0,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x01,0x00,0x80,
+ 0xff,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfc,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xf0,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0x7f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0xfc,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xe0,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x1f,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfc,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x80,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x03,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfc,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0x7f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0xfc,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfc,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0x1f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0xfc,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xf0,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x03,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfc,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0xc0,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfc,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0x1f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0xfc,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfe,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0xfc,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0xf8,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x7f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfc,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0xe0,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x0f,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfc,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0xfc,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfe,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0x7f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0xfc,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0xf8,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x07,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfc,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0xe0,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfc,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x1f,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0xfc,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0xfc,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfc,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0xf0,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0x7f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfc,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xc0,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x07,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0xfc,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfe,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0xfc,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0xf8,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0x0f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfc,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0xc0,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfc,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfe,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x1f,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0xfc,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0xf0,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x01,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0xfc,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x80,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0x1f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfc,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfc,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfc,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xe0,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x1f,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0xfc,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0xfe,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0xfc,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xe0,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0x0f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfc,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfe,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0x7f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfc,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0xe0,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0xfc,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0xfe,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x0f,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfc,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xc0,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x7f,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfc,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0xf8,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0xfc,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0xfe,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0xfc,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff,0xff,0xff,0xff,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x03,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfc,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x01,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfc,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0xfc,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x3f,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0xfc};
diff --git a/jni/ruby/ext/tk/sample/tkextlib/iwidgets/catalog_demo/Orig_LICENSE.txt b/jni/ruby/ext/tk/sample/tkextlib/iwidgets/catalog_demo/Orig_LICENSE.txt
new file mode 100644
index 0000000..8392da7
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkextlib/iwidgets/catalog_demo/Orig_LICENSE.txt
@@ -0,0 +1,42 @@
+
+ #######################################################################
+ ### The following text is the original 'license.terms' of iwidgets ###
+ ### extension. ###
+ ### Original Tcl source files are not include in this directory, ###
+ ### because of all of them are rewritten to Ruby files. ###
+ ### However, the image data files in the 'images' directory are ###
+ ### quoted from iwidgets source archive. ###
+ #######################################################################
+
+
+This software is copyrighted by DSC Technologies and private individual
+contributors. The copyright holder is specifically listed in the header
+of each file. The following terms apply to all files associated with the
+software unless explicitly disclaimed in individual files by private
+contributors.
+
+Copyright 1997 DSC Technologies Corporation
+
+Permission to use, copy, modify, distribute and license this software and
+its documentation for any purpose, and without fee or written agreement
+with DSC, is hereby granted, provided that the above copyright notice
+appears in all copies and that both the copyright notice and warranty
+disclaimer below appear in supporting documentation, and that the names of
+DSC Technologies Corporation or DSC Communications Corporation not be used
+in advertising or publicity pertaining to the software without specific,
+written prior permission.
+
+DSC DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, AND NON-INFRINGEMENT.
+THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, AND THE AUTHORS AND
+DISTRIBUTORS HAVE NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES,
+ENHANCEMENTS, OR MODIFICATIONS. IN NO EVENT SHALL DSC BE LIABLE FOR ANY
+SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
+RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF
+CONTRACT, NEGLIGENCE OR OTHER TORTUOUS ACTION, ARISING OUT OF OR IN
+CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+
+RESTRICTED RIGHTS: Use, duplication or disclosure by the government
+is subject to the restrictions as set forth in subparagraph (c) (1) (ii)
+of the Rights in Technical Data and Computer Software Clause as DFARS
+252.227-7013 and FAR 52.227-19.
diff --git a/jni/ruby/ext/tk/sample/tkextlib/iwidgets/catalog_demo/images/box.xbm b/jni/ruby/ext/tk/sample/tkextlib/iwidgets/catalog_demo/images/box.xbm
new file mode 100644
index 0000000..7498e15
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkextlib/iwidgets/catalog_demo/images/box.xbm
@@ -0,0 +1,14 @@
+#define Tool_32_box_width 32
+#define Tool_32_box_height 32
+static unsigned char Tool_32_box_bits[] = {
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0xe0, 0xff, 0xff, 0x0f, 0x20, 0x00, 0x00, 0x08,
+ 0x20, 0x00, 0x00, 0x08, 0x20, 0x00, 0x00, 0x08, 0x20, 0x00, 0x00, 0x08,
+ 0x20, 0x00, 0x00, 0x08, 0x20, 0x00, 0x00, 0x08, 0x20, 0x00, 0x00, 0x08,
+ 0x20, 0x00, 0x00, 0x08, 0x20, 0x00, 0x00, 0x08, 0x20, 0x00, 0x00, 0x08,
+ 0x20, 0x00, 0x00, 0x08, 0x20, 0x00, 0x00, 0x08, 0x20, 0x00, 0x00, 0x08,
+ 0x20, 0x00, 0x00, 0x08, 0x20, 0x00, 0x00, 0x08, 0x20, 0x00, 0x00, 0x08,
+ 0xe0, 0xff, 0xff, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, };
diff --git a/jni/ruby/ext/tk/sample/tkextlib/iwidgets/catalog_demo/images/clear.gif b/jni/ruby/ext/tk/sample/tkextlib/iwidgets/catalog_demo/images/clear.gif
new file mode 100644
index 0000000..bd45628
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkextlib/iwidgets/catalog_demo/images/clear.gif
Binary files differ
diff --git a/jni/ruby/ext/tk/sample/tkextlib/iwidgets/catalog_demo/images/close.gif b/jni/ruby/ext/tk/sample/tkextlib/iwidgets/catalog_demo/images/close.gif
new file mode 100644
index 0000000..f91b9e9
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkextlib/iwidgets/catalog_demo/images/close.gif
Binary files differ
diff --git a/jni/ruby/ext/tk/sample/tkextlib/iwidgets/catalog_demo/images/copy.gif b/jni/ruby/ext/tk/sample/tkextlib/iwidgets/catalog_demo/images/copy.gif
new file mode 100644
index 0000000..7319f1d
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkextlib/iwidgets/catalog_demo/images/copy.gif
Binary files differ
diff --git a/jni/ruby/ext/tk/sample/tkextlib/iwidgets/catalog_demo/images/cut.gif b/jni/ruby/ext/tk/sample/tkextlib/iwidgets/catalog_demo/images/cut.gif
new file mode 100644
index 0000000..4258b17
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkextlib/iwidgets/catalog_demo/images/cut.gif
Binary files differ
diff --git a/jni/ruby/ext/tk/sample/tkextlib/iwidgets/catalog_demo/images/exit.gif b/jni/ruby/ext/tk/sample/tkextlib/iwidgets/catalog_demo/images/exit.gif
new file mode 100644
index 0000000..e462be0
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkextlib/iwidgets/catalog_demo/images/exit.gif
Binary files differ
diff --git a/jni/ruby/ext/tk/sample/tkextlib/iwidgets/catalog_demo/images/find.gif b/jni/ruby/ext/tk/sample/tkextlib/iwidgets/catalog_demo/images/find.gif
new file mode 100644
index 0000000..dddcb80
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkextlib/iwidgets/catalog_demo/images/find.gif
Binary files differ
diff --git a/jni/ruby/ext/tk/sample/tkextlib/iwidgets/catalog_demo/images/help.gif b/jni/ruby/ext/tk/sample/tkextlib/iwidgets/catalog_demo/images/help.gif
new file mode 100644
index 0000000..bc8f18c
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkextlib/iwidgets/catalog_demo/images/help.gif
Binary files differ
diff --git a/jni/ruby/ext/tk/sample/tkextlib/iwidgets/catalog_demo/images/line.xbm b/jni/ruby/ext/tk/sample/tkextlib/iwidgets/catalog_demo/images/line.xbm
new file mode 100644
index 0000000..4622ae9
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkextlib/iwidgets/catalog_demo/images/line.xbm
@@ -0,0 +1,14 @@
+#define lineOp_width 32
+#define lineOp_height 32
+static unsigned char lineOp_bits[] = {
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x78, 0x00, 0x00, 0x00,
+ 0xf0, 0x00, 0x00, 0x00, 0xe0, 0x01, 0x00, 0x00, 0xc0, 0x03, 0x00, 0x00,
+ 0x80, 0x07, 0x00, 0x00, 0x00, 0x0f, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x00,
+ 0x00, 0x3c, 0x00, 0x00, 0x00, 0x78, 0x00, 0x00, 0x00, 0xf0, 0x00, 0x00,
+ 0x00, 0xe0, 0x01, 0x00, 0x00, 0xc0, 0x03, 0x00, 0x00, 0x80, 0x07, 0x00,
+ 0x00, 0x00, 0x0f, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x00, 0x00, 0x3c, 0x00,
+ 0x00, 0x00, 0x78, 0x00, 0x00, 0x00, 0xf0, 0x00, 0x00, 0x00, 0xe0, 0x01,
+ 0x00, 0x00, 0xc0, 0x03, 0x00, 0x00, 0x80, 0x07, 0x00, 0x00, 0x00, 0x0f,
+ 0x00, 0x00, 0x00, 0x1e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
diff --git a/jni/ruby/ext/tk/sample/tkextlib/iwidgets/catalog_demo/images/mag.gif b/jni/ruby/ext/tk/sample/tkextlib/iwidgets/catalog_demo/images/mag.gif
new file mode 100644
index 0000000..4a5be66
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkextlib/iwidgets/catalog_demo/images/mag.gif
Binary files differ
diff --git a/jni/ruby/ext/tk/sample/tkextlib/iwidgets/catalog_demo/images/new.gif b/jni/ruby/ext/tk/sample/tkextlib/iwidgets/catalog_demo/images/new.gif
new file mode 100644
index 0000000..9c68ad3
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkextlib/iwidgets/catalog_demo/images/new.gif
Binary files differ
diff --git a/jni/ruby/ext/tk/sample/tkextlib/iwidgets/catalog_demo/images/open.gif b/jni/ruby/ext/tk/sample/tkextlib/iwidgets/catalog_demo/images/open.gif
new file mode 100644
index 0000000..bed862c
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkextlib/iwidgets/catalog_demo/images/open.gif
Binary files differ
diff --git a/jni/ruby/ext/tk/sample/tkextlib/iwidgets/catalog_demo/images/oval.xbm b/jni/ruby/ext/tk/sample/tkextlib/iwidgets/catalog_demo/images/oval.xbm
new file mode 100644
index 0000000..856bd43
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkextlib/iwidgets/catalog_demo/images/oval.xbm
@@ -0,0 +1,14 @@
+#define ovalOp_width 32
+#define ovalOp_height 32
+static unsigned char ovalOp_bits[] = {
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe0, 0x0f, 0x00,
+ 0x00, 0x1c, 0x70, 0x00, 0x00, 0x03, 0x80, 0x01, 0x80, 0x00, 0x00, 0x02,
+ 0x40, 0x00, 0x00, 0x04, 0x20, 0x00, 0x00, 0x08, 0x10, 0x00, 0x00, 0x10,
+ 0x10, 0x00, 0x00, 0x10, 0x08, 0x00, 0x00, 0x20, 0x08, 0x00, 0x00, 0x20,
+ 0x08, 0x00, 0x00, 0x20, 0x08, 0x00, 0x00, 0x20, 0x10, 0x00, 0x00, 0x10,
+ 0x10, 0x00, 0x00, 0x10, 0x20, 0x00, 0x00, 0x08, 0x40, 0x00, 0x00, 0x04,
+ 0x80, 0x00, 0x00, 0x02, 0x00, 0x03, 0x80, 0x01, 0x00, 0x1c, 0x70, 0x00,
+ 0x00, 0xe0, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
diff --git a/jni/ruby/ext/tk/sample/tkextlib/iwidgets/catalog_demo/images/paste.gif b/jni/ruby/ext/tk/sample/tkextlib/iwidgets/catalog_demo/images/paste.gif
new file mode 100644
index 0000000..9974f23
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkextlib/iwidgets/catalog_demo/images/paste.gif
Binary files differ
diff --git a/jni/ruby/ext/tk/sample/tkextlib/iwidgets/catalog_demo/images/points.xbm b/jni/ruby/ext/tk/sample/tkextlib/iwidgets/catalog_demo/images/points.xbm
new file mode 100644
index 0000000..c50aa4c
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkextlib/iwidgets/catalog_demo/images/points.xbm
@@ -0,0 +1,14 @@
+#define dotPencilOp_width 32
+#define dotPencilOp_height 32
+static unsigned char dotPencilOp_bits[] = {
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x00, 0x00, 0x12, 0x00,
+ 0x00, 0x00, 0x09, 0x00, 0x00, 0x00, 0x09, 0x00, 0x00, 0x80, 0x04, 0x00,
+ 0x00, 0x80, 0x04, 0x00, 0x00, 0x40, 0x02, 0x00, 0x00, 0x40, 0x02, 0x00,
+ 0x00, 0x20, 0x01, 0x00, 0x00, 0x20, 0x01, 0x00, 0x00, 0x90, 0x00, 0x00,
+ 0x00, 0x90, 0x00, 0x00, 0x00, 0x48, 0x00, 0x00, 0x00, 0x48, 0x00, 0x00,
+ 0x00, 0x24, 0x00, 0x18, 0x00, 0x24, 0x00, 0x18, 0x00, 0x12, 0x00, 0x00,
+ 0x00, 0x12, 0x00, 0x30, 0x00, 0x0e, 0x00, 0x30, 0x00, 0x06, 0x00, 0x00,
+ 0x00, 0x06, 0x0c, 0x30, 0x00, 0x00, 0x0c, 0x30, 0x00, 0x30, 0xa0, 0x01,
+ 0x00, 0x60, 0xb0, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, };
diff --git a/jni/ruby/ext/tk/sample/tkextlib/iwidgets/catalog_demo/images/poly.gif b/jni/ruby/ext/tk/sample/tkextlib/iwidgets/catalog_demo/images/poly.gif
new file mode 100644
index 0000000..2b595bb
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkextlib/iwidgets/catalog_demo/images/poly.gif
Binary files differ
diff --git a/jni/ruby/ext/tk/sample/tkextlib/iwidgets/catalog_demo/images/print.gif b/jni/ruby/ext/tk/sample/tkextlib/iwidgets/catalog_demo/images/print.gif
new file mode 100644
index 0000000..d321f17
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkextlib/iwidgets/catalog_demo/images/print.gif
Binary files differ
diff --git a/jni/ruby/ext/tk/sample/tkextlib/iwidgets/catalog_demo/images/ruler.gif b/jni/ruby/ext/tk/sample/tkextlib/iwidgets/catalog_demo/images/ruler.gif
new file mode 100644
index 0000000..00d26fe
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkextlib/iwidgets/catalog_demo/images/ruler.gif
Binary files differ
diff --git a/jni/ruby/ext/tk/sample/tkextlib/iwidgets/catalog_demo/images/save.gif b/jni/ruby/ext/tk/sample/tkextlib/iwidgets/catalog_demo/images/save.gif
new file mode 100644
index 0000000..d1ceb1a
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkextlib/iwidgets/catalog_demo/images/save.gif
Binary files differ
diff --git a/jni/ruby/ext/tk/sample/tkextlib/iwidgets/catalog_demo/images/select.gif b/jni/ruby/ext/tk/sample/tkextlib/iwidgets/catalog_demo/images/select.gif
new file mode 100644
index 0000000..f885c9c
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkextlib/iwidgets/catalog_demo/images/select.gif
Binary files differ
diff --git a/jni/ruby/ext/tk/sample/tkextlib/iwidgets/catalog_demo/images/text.xbm b/jni/ruby/ext/tk/sample/tkextlib/iwidgets/catalog_demo/images/text.xbm
new file mode 100644
index 0000000..ffb0686
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkextlib/iwidgets/catalog_demo/images/text.xbm
@@ -0,0 +1,14 @@
+#define font_edit_width 32
+#define font_edit_height 32
+static unsigned char font_edit_bits[] = {
+ 0x00, 0x00, 0x00, 0x30, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x00, 0x1c,
+ 0x00, 0x00, 0x00, 0x6e, 0x00, 0x00, 0x00, 0x77, 0x00, 0x00, 0x80, 0x7b,
+ 0x00, 0x00, 0x80, 0x7e, 0x00, 0x00, 0xc0, 0xfd, 0x00, 0x00, 0x60, 0xfb,
+ 0x00, 0x00, 0xb0, 0xf7, 0x00, 0x00, 0xd0, 0xef, 0x00, 0x00, 0xf8, 0xdf,
+ 0x00, 0x00, 0xd4, 0x7f, 0x00, 0x00, 0xaa, 0x1f, 0x00, 0x00, 0x15, 0x0f,
+ 0x00, 0x80, 0x82, 0x06, 0x03, 0x40, 0x01, 0x01, 0x07, 0xa0, 0x80, 0x00,
+ 0x0f, 0x10, 0x40, 0x00, 0x1f, 0x08, 0x20, 0x00, 0x3b, 0xe4, 0x1f, 0x00,
+ 0x73, 0x1a, 0x00, 0x00, 0xe3, 0x07, 0x00, 0x00, 0xc3, 0x01, 0x00, 0x00,
+ 0xe3, 0x03, 0x00, 0x00, 0x7b, 0x07, 0x00, 0x00, 0x1f, 0x06, 0x00, 0x00,
+ 0x07, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
+ 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, };
diff --git a/jni/ruby/ext/tk/sample/tkextlib/iwidgets/sample/buttonbox.rb b/jni/ruby/ext/tk/sample/tkextlib/iwidgets/sample/buttonbox.rb
new file mode 100644
index 0000000..2b7cd45
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkextlib/iwidgets/sample/buttonbox.rb
@@ -0,0 +1,22 @@
+#!/usr/bin/env ruby
+require 'tk'
+require 'tkextlib/iwidgets'
+
+# sample 1
+p bb1 = Tk::Iwidgets::Buttonbox.new
+p bb1.add('Yes', :text=>'Yes', :command=>proc{puts 'Yes'})
+p bb1.add('No', :text=>'No', :command=>proc{puts 'No'})
+p bb1.add('Maybe', :text=>'Maybe', :command=>proc{puts 'Maybe'})
+bb1.default('Yes')
+bb1.pack(:expand=>true, :fill=>:both, :pady=>5)
+print "\n"
+
+# sample 2
+p bb2 = Tk::Iwidgets::Buttonbox.new
+p btn1 = bb2.add(:text=>'Yes', :command=>proc{puts 'Yes'})
+p btn2 = bb2.add(:text=>'No', :command=>proc{puts 'No'})
+p btn3 = bb2.add(:text=>'Maybe', :command=>proc{puts 'Maybe'})
+bb2.default(btn1)
+bb2.pack(:expand=>true, :fill=>:both, :pady=>5)
+
+Tk.mainloop
diff --git a/jni/ruby/ext/tk/sample/tkextlib/iwidgets/sample/calendar.rb b/jni/ruby/ext/tk/sample/tkextlib/iwidgets/sample/calendar.rb
new file mode 100644
index 0000000..bb09b4d
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkextlib/iwidgets/sample/calendar.rb
@@ -0,0 +1,10 @@
+#!/usr/bin/env ruby
+require 'tk'
+require 'tkextlib/iwidgets'
+
+Tk::Iwidgets::Calendar.new(:command=>proc{|arg| puts(arg.date)},
+ :weekendbackground=>'mistyrose',
+ :weekdaybackground=>'ghostwhite',
+ :outline=>'black', :startday=>'wednesday',
+ :days=>%w(We Th Fr Sa Su Mo Tu)).pack
+Tk.mainloop
diff --git a/jni/ruby/ext/tk/sample/tkextlib/iwidgets/sample/canvasprintbox.rb b/jni/ruby/ext/tk/sample/tkextlib/iwidgets/sample/canvasprintbox.rb
new file mode 100644
index 0000000..c7c0430
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkextlib/iwidgets/sample/canvasprintbox.rb
@@ -0,0 +1,8 @@
+#!/usr/bin/env ruby
+require 'tk'
+require 'tkextlib/iwidgets'
+
+Tk::Iwidgets::Canvasprintbox.new(:orient=>:landscape, :stretch=>1) \
+ .pack(:padx=>10, :pady=>10, :fill=>:both, :expand=>true)
+
+Tk.mainloop
diff --git a/jni/ruby/ext/tk/sample/tkextlib/iwidgets/sample/canvasprintdialog.rb b/jni/ruby/ext/tk/sample/tkextlib/iwidgets/sample/canvasprintdialog.rb
new file mode 100644
index 0000000..ea8d63e
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkextlib/iwidgets/sample/canvasprintdialog.rb
@@ -0,0 +1,8 @@
+#!/usr/bin/env ruby
+require 'tk'
+require 'tkextlib/iwidgets'
+
+Tk::Iwidgets::Canvasprintdialog.new.activate
+
+Tk.mainloop
+
diff --git a/jni/ruby/ext/tk/sample/tkextlib/iwidgets/sample/checkbox.rb b/jni/ruby/ext/tk/sample/tkextlib/iwidgets/sample/checkbox.rb
new file mode 100644
index 0000000..bae0eba
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkextlib/iwidgets/sample/checkbox.rb
@@ -0,0 +1,12 @@
+#!/usr/bin/env ruby
+require 'tk'
+require 'tkextlib/iwidgets'
+
+cb = Tk::Iwidgets::Checkbox.new
+cb.add('bold', :text=>'Bold')
+cb.add('italic', :text=>'Italic')
+cb.add('underline', :text=>'Underline')
+cb.select('underline')
+cb.pack(:expand=>true, :fill=>:both, :padx=>10, :pady=>10)
+
+Tk.mainloop
diff --git a/jni/ruby/ext/tk/sample/tkextlib/iwidgets/sample/combobox.rb b/jni/ruby/ext/tk/sample/tkextlib/iwidgets/sample/combobox.rb
new file mode 100644
index 0000000..3684753
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkextlib/iwidgets/sample/combobox.rb
@@ -0,0 +1,32 @@
+#!/usr/bin/env ruby
+require 'tk'
+require 'tkextlib/iwidgets'
+
+#
+# Non-editable Dropdown Combobox
+#
+cb1 = Tk::Iwidgets::Combobox.new(:labeltext=>'Month:',
+ :selectioncommand=>proc{
+ puts(cb1.get_curselection)
+ },
+ :editable=>false, :listheight=>185,
+ :popupcursor=>'hand1')
+
+cb1.insert_list('end', *%w(Jan Feb Mar Apr May June Jul Aug Sept Oct Nov Dec))
+
+
+#
+# Editable Dropdown Combobox
+#
+cb2 = Tk::Iwidgets::Combobox.new(:labeltext=>'Operating System:',
+ :selectioncommand=>proc{
+ puts(cb2.get_curselection)
+ })
+
+cb2.insert_list('end', *%w(Linux HP-UX SunOS Solaris Irix))
+cb2.insert_entry('end', 'L')
+
+cb1.pack(:padx=>10, :pady=>10, :fill=>:x)
+cb2.pack(:padx=>10, :pady=>10, :fill=>:x)
+
+Tk.mainloop
diff --git a/jni/ruby/ext/tk/sample/tkextlib/iwidgets/sample/dateentry.rb b/jni/ruby/ext/tk/sample/tkextlib/iwidgets/sample/dateentry.rb
new file mode 100644
index 0000000..5727879
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkextlib/iwidgets/sample/dateentry.rb
@@ -0,0 +1,7 @@
+#!/usr/bin/env ruby
+require 'tk'
+require 'tkextlib/iwidgets'
+
+Tk::Iwidgets::Dateentry.new.pack
+
+Tk.mainloop
diff --git a/jni/ruby/ext/tk/sample/tkextlib/iwidgets/sample/datefield.rb b/jni/ruby/ext/tk/sample/tkextlib/iwidgets/sample/datefield.rb
new file mode 100644
index 0000000..12d4982
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkextlib/iwidgets/sample/datefield.rb
@@ -0,0 +1,8 @@
+#!/usr/bin/env ruby
+require 'tk'
+require 'tkextlib/iwidgets'
+
+df = Tk::Iwidgets::Datefield.new(:command=>proc{puts(df.get)})
+df.pack(:fill=>:x, :expand=>true, :padx=>10, :pady=>10)
+
+Tk.mainloop
diff --git a/jni/ruby/ext/tk/sample/tkextlib/iwidgets/sample/dialog.rb b/jni/ruby/ext/tk/sample/tkextlib/iwidgets/sample/dialog.rb
new file mode 100644
index 0000000..3449cd4
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkextlib/iwidgets/sample/dialog.rb
@@ -0,0 +1,20 @@
+#!/usr/bin/env ruby
+require 'tk'
+require 'tkextlib/iwidgets'
+
+Thread.new{Tk.mainloop}
+
+d = Tk::Iwidgets::Dialog.new(:modality=>:application)
+
+d.buttonconfigure('OK', :command=>proc{puts 'OK'; d.deactivate true})
+d.buttonconfigure('Apply', :command=>proc{puts 'Apply'})
+d.buttonconfigure('Cancel', :command=>proc{puts 'Cancel'; d.deactivate false})
+d.buttonconfigure('Help', :command=>proc{puts 'Help'})
+
+TkListbox.new(d.child_site, :relief=>:sunken).pack(:expand=>true, :fill=>:both)
+
+if TkComm.bool(d.activate)
+ puts "Exit via OK button"
+else
+ puts "Exit via Cancel button"
+end
diff --git a/jni/ruby/ext/tk/sample/tkextlib/iwidgets/sample/dialogshell.rb b/jni/ruby/ext/tk/sample/tkextlib/iwidgets/sample/dialogshell.rb
new file mode 100644
index 0000000..00ee997
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkextlib/iwidgets/sample/dialogshell.rb
@@ -0,0 +1,14 @@
+#!/usr/bin/env ruby
+require 'tk'
+require 'tkextlib/iwidgets'
+
+ds = Tk::Iwidgets::Dialogshell.new(:modality=>:none)
+
+ds.add('OK', :text=>'OK', :command=>proc{puts 'OK'; ds.deactivate})
+ds.add('Cancel', :text=>'Cancel', :command=>proc{puts 'Cancel'; ds.deactivate})
+ds.default('OK')
+
+TkButton.new(:text=>'ACTIVATE', :padx=>7, :pady=>7,
+ :command=>proc{puts ds.activate}).pack(:padx=>10, :pady=>10)
+
+Tk.mainloop
diff --git a/jni/ruby/ext/tk/sample/tkextlib/iwidgets/sample/disjointlistbox.rb b/jni/ruby/ext/tk/sample/tkextlib/iwidgets/sample/disjointlistbox.rb
new file mode 100644
index 0000000..682c853
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkextlib/iwidgets/sample/disjointlistbox.rb
@@ -0,0 +1,16 @@
+#!/usr/bin/env ruby
+require 'tk'
+require 'tkextlib/iwidgets'
+
+djl = Tk::Iwidgets::Disjointlistbox.new.pack(:fill=>:both, :expand=>true,
+ :padx=>10, :pady=>10)
+djl.set_lhs(*[0,2,4,5])
+djl.set_rhs(3,6)
+
+djl.insert_lhs(1,7,8)
+djl.insert_rhs(9)
+
+p djl.get_lhs
+p djl.get_rhs
+
+Tk.mainloop
diff --git a/jni/ruby/ext/tk/sample/tkextlib/iwidgets/sample/entryfield-1.rb b/jni/ruby/ext/tk/sample/tkextlib/iwidgets/sample/entryfield-1.rb
new file mode 100644
index 0000000..8563a08
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkextlib/iwidgets/sample/entryfield-1.rb
@@ -0,0 +1,39 @@
+#!/usr/bin/env ruby
+#########################################################
+#
+# use Tk::UTF8_String() for a utf8 charecter
+#
+#########################################################
+require 'tk'
+require 'tkextlib/iwidgets'
+
+TkOption.add('*textBackground', 'white')
+
+ef = Tk::Iwidgets::Entryfield.new(:command=>proc{puts "Return Pressed"})
+
+fef = Tk::Iwidgets::Entryfield.new(:labeltext=>'Fixed:',
+ :fixed=>10, :width=>12)
+
+nef = Tk::Iwidgets::Entryfield.new(:labeltext=>'Numeric:',
+ :validate=>:numeric, :width=>12)
+
+aef = Tk::Iwidgets::Entryfield.new(:labeltext=>'Alphabetic:',
+ :validate=>:alphabetic, :width=>12,
+ :invalid=>proc{
+ puts "Alphabetic contents invalid"
+ })
+
+pef = Tk::Iwidgets::Entryfield.new(:labeltext=>'Password:', :width=>12,
+ :show=>Tk::UTF8_String("\267"),
+ ## <=== utf8 character
+ :command=>proc{puts "Return Pressed"})
+
+Tk::Iwidgets::Labeledwidget.alignlabels(ef, fef, nef, aef, pef)
+
+ef.pack(:fil=>:x, :expand=>true, :padx=>10, :pady=>5)
+fef.pack(:fil=>:x, :expand=>true, :padx=>10, :pady=>5)
+nef.pack(:fil=>:x, :expand=>true, :padx=>10, :pady=>5)
+aef.pack(:fil=>:x, :expand=>true, :padx=>10, :pady=>5)
+pef.pack(:fil=>:x, :expand=>true, :padx=>10, :pady=>5)
+
+Tk.mainloop
diff --git a/jni/ruby/ext/tk/sample/tkextlib/iwidgets/sample/entryfield-2.rb b/jni/ruby/ext/tk/sample/tkextlib/iwidgets/sample/entryfield-2.rb
new file mode 100644
index 0000000..d8ccdf8
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkextlib/iwidgets/sample/entryfield-2.rb
@@ -0,0 +1,44 @@
+#!/usr/bin/env ruby
+#########################################################
+#
+# set $KCODE to 'utf' for a utf8 charecter
+#
+#########################################################
+unless defined?(::Encoding.default_external)
+ $KCODE='utf'
+else
+ DEFAULT_TK_ENCODING = 'UTF-8'
+end
+
+require 'tk'
+require 'tkextlib/iwidgets'
+
+TkOption.add('*textBackground', 'white')
+
+ef = Tk::Iwidgets::Entryfield.new(:command=>proc{puts "Return Pressed"})
+
+fef = Tk::Iwidgets::Entryfield.new(:labeltext=>'Fixed:',
+ :fixed=>10, :width=>12)
+
+nef = Tk::Iwidgets::Entryfield.new(:labeltext=>'Numeric:',
+ :validate=>:numeric, :width=>12)
+
+aef = Tk::Iwidgets::Entryfield.new(:labeltext=>'Alphabetic:',
+ :validate=>:alphabetic, :width=>12,
+ :invalid=>proc{
+ puts "Alphabetic contents invalid"
+ })
+
+pef = Tk::Iwidgets::Entryfield.new(:labeltext=>'Password:', :width=>12,
+ :show=>"\267", ## <=== utf8 character
+ :command=>proc{puts "Return Pressed"})
+
+Tk::Iwidgets::Labeledwidget.alignlabels(ef, fef, nef, aef, pef)
+
+ef.pack(:fil=>:x, :expand=>true, :padx=>10, :pady=>5)
+fef.pack(:fil=>:x, :expand=>true, :padx=>10, :pady=>5)
+nef.pack(:fil=>:x, :expand=>true, :padx=>10, :pady=>5)
+aef.pack(:fil=>:x, :expand=>true, :padx=>10, :pady=>5)
+pef.pack(:fil=>:x, :expand=>true, :padx=>10, :pady=>5)
+
+Tk.mainloop
diff --git a/jni/ruby/ext/tk/sample/tkextlib/iwidgets/sample/entryfield-3.rb b/jni/ruby/ext/tk/sample/tkextlib/iwidgets/sample/entryfield-3.rb
new file mode 100644
index 0000000..327f908
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkextlib/iwidgets/sample/entryfield-3.rb
@@ -0,0 +1,40 @@
+#!/usr/bin/env ruby
+#########################################################
+#
+# set Tk.encoding = 'utf-8' for a utf8 charecter
+#
+#########################################################
+require 'tk'
+require 'tkextlib/iwidgets'
+
+Tk.encoding = 'utf-8'
+
+TkOption.add('*textBackground', 'white')
+
+ef = Tk::Iwidgets::Entryfield.new(:command=>proc{puts "Return Pressed"})
+
+fef = Tk::Iwidgets::Entryfield.new(:labeltext=>'Fixed:',
+ :fixed=>10, :width=>12)
+
+nef = Tk::Iwidgets::Entryfield.new(:labeltext=>'Numeric:',
+ :validate=>:numeric, :width=>12)
+
+aef = Tk::Iwidgets::Entryfield.new(:labeltext=>'Alphabetic:',
+ :validate=>:alphabetic, :width=>12,
+ :invalid=>proc{
+ puts "Alphabetic contents invalid"
+ })
+
+pef = Tk::Iwidgets::Entryfield.new(:labeltext=>'Password:', :width=>12,
+ :show=>"\267", ## <=== utf8 character
+ :command=>proc{puts "Return Pressed"})
+
+Tk::Iwidgets::Labeledwidget.alignlabels(ef, fef, nef, aef, pef)
+
+ef.pack(:fil=>:x, :expand=>true, :padx=>10, :pady=>5)
+fef.pack(:fil=>:x, :expand=>true, :padx=>10, :pady=>5)
+nef.pack(:fil=>:x, :expand=>true, :padx=>10, :pady=>5)
+aef.pack(:fil=>:x, :expand=>true, :padx=>10, :pady=>5)
+pef.pack(:fil=>:x, :expand=>true, :padx=>10, :pady=>5)
+
+Tk.mainloop
diff --git a/jni/ruby/ext/tk/sample/tkextlib/iwidgets/sample/extbutton.rb b/jni/ruby/ext/tk/sample/tkextlib/iwidgets/sample/extbutton.rb
new file mode 100644
index 0000000..4944c72
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkextlib/iwidgets/sample/extbutton.rb
@@ -0,0 +1,20 @@
+#!/usr/bin/env ruby
+require 'tk'
+require 'tkextlib/iwidgets'
+
+Tk::Iwidgets::Extbutton.new(:text=>'Bitmap example', :bitmap=>'info',
+ :background=>'bisque', :activeforeground=>'red',
+ :bitmapforeground=>'blue', :defaultring=>true,
+ :command=>proc{
+ puts "Bisque is beautiful"
+ }).pack(:expand=>true)
+
+#img = TkPhotoImage.new(:file=>File.join(File.dirname(File.expand_path(__FILE__)), '../../../images/earthris.gif'))
+img = TkPhotoImage.new(:file=>File.join(File.dirname(File.expand_path(__FILE__)), '../catalog_demo/images/clear.gif'))
+
+Tk::Iwidgets::Extbutton.new(:text=>'Image example', :relief=>:ridge,
+ :image=>img, :imagepos=>:e, :font=>'9x15bold',
+ :activebackground=>'lightyellow',
+ :background=>'lightgreen').pack(:expand=>true)
+
+Tk.mainloop
diff --git a/jni/ruby/ext/tk/sample/tkextlib/iwidgets/sample/extfileselectionbox.rb b/jni/ruby/ext/tk/sample/tkextlib/iwidgets/sample/extfileselectionbox.rb
new file mode 100644
index 0000000..63e4be2
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkextlib/iwidgets/sample/extfileselectionbox.rb
@@ -0,0 +1,8 @@
+#!/usr/bin/env ruby
+require 'tk'
+require 'tkextlib/iwidgets'
+
+Tk::Iwidgets::Extfileselectionbox.new.pack(:padx=>10, :pady=>10,
+ :fill=>:both, :expand=>true)
+
+Tk.mainloop
diff --git a/jni/ruby/ext/tk/sample/tkextlib/iwidgets/sample/extfileselectiondialog.rb b/jni/ruby/ext/tk/sample/tkextlib/iwidgets/sample/extfileselectiondialog.rb
new file mode 100644
index 0000000..c1a9b3d
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkextlib/iwidgets/sample/extfileselectiondialog.rb
@@ -0,0 +1,29 @@
+#!/usr/bin/env ruby
+require 'tk'
+require 'tkextlib/iwidgets'
+
+mainloop = Thread.new{Tk.mainloop}
+
+#
+# Non-modal example
+#
+nmfsd = Tk::Iwidgets::Extfileselectiondialog.new(:title=>'Non-Modal')
+nmfsd.buttonconfigure('OK', :command=>proc{
+ puts "You selected #{nmfsd.get}"
+ nmfsd.deactivate
+ })
+nmfsd.activate
+
+#
+# Modal example
+#
+mfsd = Tk::Iwidgets::Extfileselectiondialog.new(:modality=>:application)
+mfsd.center
+if TkComm.bool(mfsd.activate)
+ puts "You selected #{mfsd.get}"
+else
+ puts "You cancelled the dialog"
+end
+
+
+mainloop.join
diff --git a/jni/ruby/ext/tk/sample/tkextlib/iwidgets/sample/feedback.rb b/jni/ruby/ext/tk/sample/tkextlib/iwidgets/sample/feedback.rb
new file mode 100644
index 0000000..7b87a02
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkextlib/iwidgets/sample/feedback.rb
@@ -0,0 +1,10 @@
+#!/usr/bin/env ruby
+require 'tk'
+require 'tkextlib/iwidgets'
+
+Tk::Iwidgets::Feedback.new(:labeltext=>'Status', :steps=>20){|fb|
+ pack(:padx=>10, :pady=>10, :fill=>:both, :expand=>true)
+ TkTimer.new(500, 20, proc{fb.step}).start(2500)
+}
+
+Tk.mainloop
diff --git a/jni/ruby/ext/tk/sample/tkextlib/iwidgets/sample/fileselectionbox.rb b/jni/ruby/ext/tk/sample/tkextlib/iwidgets/sample/fileselectionbox.rb
new file mode 100644
index 0000000..3a5b513
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkextlib/iwidgets/sample/fileselectionbox.rb
@@ -0,0 +1,8 @@
+#!/usr/bin/env ruby
+require 'tk'
+require 'tkextlib/iwidgets'
+
+Tk::Iwidgets::Fileselectionbox.new.pack(:padx=>10, :pady=>10,
+ :fill=>:both, :expand=>true)
+
+Tk.mainloop
diff --git a/jni/ruby/ext/tk/sample/tkextlib/iwidgets/sample/fileselectiondialog.rb b/jni/ruby/ext/tk/sample/tkextlib/iwidgets/sample/fileselectiondialog.rb
new file mode 100644
index 0000000..ff22b2f
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkextlib/iwidgets/sample/fileselectiondialog.rb
@@ -0,0 +1,28 @@
+#!/usr/bin/env ruby
+require 'tk'
+require 'tkextlib/iwidgets'
+
+mainloop = Thread.new{Tk.mainloop}
+
+#
+# Non-modal example
+#
+nmfsd = Tk::Iwidgets::Fileselectiondialog.new(:title=>'Non-Modal')
+nmfsd.buttonconfigure('OK', :command=>proc{
+ puts "You selected #{nmfsd.get}"
+ nmfsd.deactivate
+ })
+nmfsd.activate
+
+#
+# Modal example
+#
+mfsd = Tk::Iwidgets::Fileselectiondialog.new(:modality=>:application)
+mfsd.center
+if TkComm.bool(mfsd.activate)
+ puts "You selected #{mfsd.get}"
+else
+ puts "You cancelled the dialog"
+end
+
+mainloop.join
diff --git a/jni/ruby/ext/tk/sample/tkextlib/iwidgets/sample/finddialog.rb b/jni/ruby/ext/tk/sample/tkextlib/iwidgets/sample/finddialog.rb
new file mode 100644
index 0000000..110efb9
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkextlib/iwidgets/sample/finddialog.rb
@@ -0,0 +1,15 @@
+#!/usr/bin/env ruby
+require 'tk'
+require 'tkextlib/iwidgets'
+
+mainloop = Thread.new{Tk.mainloop}
+
+st = Tk::Iwidgets::Scrolledtext.new.pack
+st.insert('end', "Now is the time for all good men\n")
+st.insert('end', "to come to the aid of their country")
+
+fd = Tk::Iwidgets::Finddialog.new(:textwidget=>st)
+fd.center(st)
+fd.activate
+
+mainloop.join
diff --git a/jni/ruby/ext/tk/sample/tkextlib/iwidgets/sample/hierarchy.rb b/jni/ruby/ext/tk/sample/tkextlib/iwidgets/sample/hierarchy.rb
new file mode 100644
index 0000000..085070e
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkextlib/iwidgets/sample/hierarchy.rb
@@ -0,0 +1,25 @@
+#!/usr/bin/env ruby
+require 'tk'
+require 'tkextlib/iwidgets'
+
+def get_files(file)
+ dir = (file.empty?)? ENV['HOME'] : TkComm._fromUTF8(file)
+ Dir.chdir(dir) rescue return ''
+ Dir['*'].sort.collect{|f|
+ [TkComm._toUTF8(File.join(dir, f)), TkComm._toUTF8(f)]
+ }
+end
+
+Tk::Iwidgets::Hierarchy.new(:querycommand=>proc{|arg| get_files(arg.node)},
+ :visibleitems=>'30x15',
+ :labeltext=>ENV['HOME']).pack(:side=>:left,
+ :expand=>true,
+ :fill=>:both)
+
+# Tk::Iwidgets::Hierarchy.new(:querycommand=>[proc{|n| get_files(n)}, '%n'],
+# :visibleitems=>'30x15',
+# :labeltext=>ENV['HOME']).pack(:side=>:left,
+# :expand=>true,
+# :fill=>:both)
+
+Tk.mainloop
diff --git a/jni/ruby/ext/tk/sample/tkextlib/iwidgets/sample/hyperhelp.rb b/jni/ruby/ext/tk/sample/tkextlib/iwidgets/sample/hyperhelp.rb
new file mode 100644
index 0000000..f9c92bf
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkextlib/iwidgets/sample/hyperhelp.rb
@@ -0,0 +1,14 @@
+#!/usr/bin/env ruby
+require 'tk'
+require 'tkextlib/iwidgets'
+
+mainloop = Thread.new{Tk.mainloop}
+
+dir = '/usr/local/ActiveTcl/demos/IWidgets/html/'
+href = [ 'hyperhelp.n', 'buttonbox.n', 'calendar.n' ]
+
+hh = Tk::Iwidgets::Hyperhelp.new(:topics=>href, :helpdir=>dir)
+hh.show_topic('hyperhelp.n')
+hh.activate
+
+mainloop.join
diff --git a/jni/ruby/ext/tk/sample/tkextlib/iwidgets/sample/labeledframe.rb b/jni/ruby/ext/tk/sample/tkextlib/iwidgets/sample/labeledframe.rb
new file mode 100644
index 0000000..4e2e21e
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkextlib/iwidgets/sample/labeledframe.rb
@@ -0,0 +1,14 @@
+#!/usr/bin/env ruby
+require 'tk'
+require 'tkextlib/iwidgets'
+
+lf = Tk::Iwidgets::Labeledframe.new(:labeltext=>'Entry Frame', :labelpos=>:n)
+lf.pack(:fill=>:both, :expand=>true, :padx=>10, :pady=>10)
+
+cs = lf.child_site
+
+Tk::Iwidgets::Entryfield.new(cs, :labeltext=>'Name:').pack(:side=>:top, :fill=>:x)
+Tk::Iwidgets::Spinint.new(cs, :labeltext=>'Number:').pack(:side=>:top, :fill=>:x)
+Tk::Iwidgets::Pushbutton.new(cs, :text=>'Details:').pack(:side=>:top, :fill=>:x)
+
+Tk.mainloop
diff --git a/jni/ruby/ext/tk/sample/tkextlib/iwidgets/sample/labeledwidget.rb b/jni/ruby/ext/tk/sample/tkextlib/iwidgets/sample/labeledwidget.rb
new file mode 100644
index 0000000..577550a
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkextlib/iwidgets/sample/labeledwidget.rb
@@ -0,0 +1,13 @@
+#!/usr/bin/env ruby
+require 'tk'
+require 'tkextlib/iwidgets'
+
+lw = Tk::Iwidgets::Labeledwidget.new(:labeltext=>'Canvas Widget',
+ :labelpos=>:s)
+lw.pack(:fill=>:both, :expand=>true, :padx=>10, :pady=>10)
+
+cw = TkCanvas.new(lw.child_site, :relief=>:raised, :width=>200, :height=>200,
+ :borderwidth=>3, :background=>:white)
+cw.pack(:padx=>10, :pady=>10)
+
+Tk.mainloop
diff --git a/jni/ruby/ext/tk/sample/tkextlib/iwidgets/sample/mainwindow.rb b/jni/ruby/ext/tk/sample/tkextlib/iwidgets/sample/mainwindow.rb
new file mode 100644
index 0000000..c9677f2
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkextlib/iwidgets/sample/mainwindow.rb
@@ -0,0 +1,64 @@
+#!/usr/bin/env ruby
+require 'tk'
+require 'tkextlib/iwidgets'
+
+mw = Tk::Iwidgets::Mainwindow.new
+
+mw.menubar.add(:menubutton, 'file', :text=>'File', :underline=>0,
+ :padx=>8, :pady=>2, :menu=>[
+ [:options, {:tearoff=>false}],
+
+ [:command, 'new', {
+ :label=>'New', :underline=>0,
+ :helpstr=>'Create a new file'
+ }
+ ],
+
+ [:command, 'open', {
+ :label=>'Open ...', :underline=>0,
+ :helpstr=>'Open an existing file'
+ }
+ ],
+
+ [:command, 'save', {
+ :label=>'Save', :underline=>0,
+ :helpstr=>'Save the current file'
+ }
+ ],
+
+ [:command, 'saveas', {
+ :label=>'Save As', :underline=>5,
+ :helpstr=>'Save the file as a different name'
+ }
+ ],
+
+ [:command, 'print', {
+ :label=>'Print', :underline=>0,
+ :helpstr=>'Print the file'
+ }
+ ],
+
+ [:separator, 'sep1'],
+
+ [:command, 'close', {
+ :label=>'Close', :underline=>0,
+ :helpstr=>'Close the file'
+ }
+ ],
+
+ [:separator, 'sep2'],
+
+ [:command, 'exit', {
+ :label=>'Exit', :underline=>1,
+ :helpstr=>'Exit this application'
+ }
+ ],
+
+ nil
+ ])
+
+Tk::Iwidgets::Scrolledtext.new(mw.child_site).pack(:fill=>:both, :expand=>true)
+
+mw.activate
+
+Tk.mainloop
diff --git a/jni/ruby/ext/tk/sample/tkextlib/iwidgets/sample/menubar.rb b/jni/ruby/ext/tk/sample/tkextlib/iwidgets/sample/menubar.rb
new file mode 100644
index 0000000..e012752
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkextlib/iwidgets/sample/menubar.rb
@@ -0,0 +1,124 @@
+#!/usr/bin/env ruby
+require 'tk'
+require 'tkextlib/iwidgets'
+
+helpvar = TkVariable.new
+viewmode = TkVariable.new
+
+menu_spec = [
+ [:menubutton, 'file', {
+ :text=>'File', :menu=>[
+ [:options, {:tearoff=>false}],
+
+ [:command, 'new', {
+ :label=>'New', :helpstr=>'Open new document',
+ :command=>proc{puts 'NEW'}
+ }
+ ],
+
+ [:command, 'close', {
+ :label=>'Close', :helpstr=>'Close current document',
+ :command=>proc{puts 'CLOSE'}
+ }
+ ],
+
+ [:separator, 'sep1'],
+
+ [:command, 'exit', {
+ :label=>'Exit', :helpstr=>'Exit application',
+ :command=>proc{exit}
+ }
+ ]
+ ]
+ }
+ ],
+
+ [:menubutton, 'edit', {
+ :text=>'Edit', :menu=>[
+ [:options, {:tearoff=>false}],
+
+ [:command, 'undo', {
+ :label=>'Undo', :underline=>0,
+ :helpstr=>'Undo last command',
+ :command=>proc{puts 'UNDO'}
+ }
+ ],
+
+ [:separator, 'sep2'],
+
+ [:command, 'cut', {
+ :label=>'Cut', :underline=>1,
+ :helpstr=>'Cut selection to clipboard',
+ :command=>proc{puts 'CUT'}
+ }
+ ],
+
+ [:command, 'copy', {
+ :label=>'Copy', :underline=>1,
+ :helpstr=>'Copy selection to clipboard',
+ :command=>proc{puts 'COPY'}
+ }
+ ],
+
+ [:command, 'paste', {
+ :label=>'Paste', :underline=>0,
+ :helpstr=>'Paste clipboard contents',
+ :command=>proc{puts 'PASTE'}
+ }
+ ]
+ ]
+ }
+ ],
+
+ [:menubutton, 'options', {
+ :text=>'Options', :menu=>[
+ [:options, {:tearoff=>false, :selectcolor=>'blue'}],
+
+ [:radiobutton, 'byName', {
+ :variable=>viewmode, :value=>'NAME',
+ :label=>'by Name', :helpstr=>'View files by name order',
+ :command=>proc{puts 'NAME'}
+ }
+ ],
+
+ [:radiobutton, 'byDate', {
+ :variable=>viewmode, :value=>'DATE',
+ :label=>'by Date', :helpstr=>'View files by date order',
+ :command=>proc{puts 'DATE'}
+ }
+ ],
+
+ [:cascade, 'prefs', {
+ :label=>'Preferences', :menu=>[
+ [:command, 'colors', {
+ :label=>'Colors...', :helpstr=>'Change text colors',
+ :command=>proc{puts 'COLORS'}
+ }
+ ],
+
+ [:command, 'fonts', {
+ :label=>'Fonts...', :helpstr=>'Change text font',
+ :command=>proc{puts 'COLORS'}
+ }
+ ]
+ ]
+ }
+ ]
+ ]
+ }
+ ]
+]
+
+#mb = Tk::Iwidgets::Menubar.new(:helpvariable=>helpvar,
+# :menubuttons=>menu_spec)
+mb = Tk::Iwidgets::Menubar.new(:helpvariable=>helpvar)
+mb.configure(:menubuttons=>menu_spec)
+
+fr = TkFrame.new(:width=>300, :height=>300)
+ef = TkEntry.new(:textvariable=>helpvar)
+
+mb.pack(:anchor=>:nw, :fill=>:x, :expand=>true)
+fr.pack(:fill=>:both, :expand=>true)
+ef.pack(:anchor=>:sw, :fill=>:x, :expand=>true)
+
+Tk.mainloop
diff --git a/jni/ruby/ext/tk/sample/tkextlib/iwidgets/sample/menubar2.rb b/jni/ruby/ext/tk/sample/tkextlib/iwidgets/sample/menubar2.rb
new file mode 100644
index 0000000..477c916
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkextlib/iwidgets/sample/menubar2.rb
@@ -0,0 +1,44 @@
+#!/usr/bin/env ruby
+require 'tk'
+require 'tkextlib/iwidgets'
+
+helpvar = TkVariable.new
+viewmode = TkVariable.new
+
+mb = Tk::Iwidgets::Menubar.new
+mb.menubuttons = [
+ [:menubutton, 'file', {
+ :text=>'File', :menu=>[
+ [:command, 'new', {:label=>'New'}],
+ [:command, 'close', {:label=>'Close'}],
+ [:separator, 'sep1'],
+ [:command, 'quit', {:label=>'Quit'}]
+ ]
+ }
+ ],
+ [:menubutton, 'edit', {:text=>'Edit'}]
+]
+
+mb.add(:command, '.edit.undo', :label=>'Undo', :underline=>0)
+mb.add(:separator, '.edit.sep2')
+mb.add(:command, '.edit.cut', :label=>'Cut', :underline=>1)
+mb.add(:command, '.edit.copy', :label=>'Copy', :underline=>1)
+mb.add(:command, '.edit.paste', :label=>'Paste', :underline=>0)
+
+mb.add(:menubutton, '.options', :text=>'Options', :menu=>[
+ [:radiobutton, 'byName', {
+ :variable=>viewmode, :value=>'NAME', :label=>'by Name'}
+ ],
+ [:radiobutton, 'byDate', {
+ :variable=>viewmode, :value=>'DATE', :label=>'by Date'}
+ ]
+ ])
+
+mb.add(:cascade, '.options.prefs', :label=>'Preferences', :menu=>[
+ [:command, 'colors', {:label=>'Colors...'}],
+ [:command, 'fonts', {:label=>'Fonts...'}]
+ ])
+
+mb.pack(:side=>:left, :anchor=>:nw, :fill=>:x, :expand=>true)
+
+Tk.mainloop
diff --git a/jni/ruby/ext/tk/sample/tkextlib/iwidgets/sample/messagebox1.rb b/jni/ruby/ext/tk/sample/tkextlib/iwidgets/sample/messagebox1.rb
new file mode 100644
index 0000000..87b2d38
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkextlib/iwidgets/sample/messagebox1.rb
@@ -0,0 +1,19 @@
+#!/usr/bin/env ruby
+require 'tk'
+require 'tkextlib/iwidgets'
+
+mb = Tk::Iwidgets::Messagebox.new(:hscrollmode=>:dynamic,
+ :labeltext=>'Messages', :labelpos=>:n,
+ :height=>120, :width=>550,
+ :savedir=>'/tmp', :textbackground=>'#d9d9d9')
+mb.pack(:padx=>5, :pady=>5, :fill=>:both, :expand=>true)
+
+mb.type_add('ERROR', :background=>'red', :foreground=>'white', :bell=>true)
+mb.type_add('WARNING', :background=>'yellow', :foreground=>'black')
+mb.type_add('INFO', :background=>'white', :foreground=>'black')
+
+mb.issue('This is an error message in red with a beep', 'ERROR')
+mb.issue('This warning message in yellow', 'WARNING')
+mb.issue('This is an informational message', 'INFO')
+
+Tk.mainloop
diff --git a/jni/ruby/ext/tk/sample/tkextlib/iwidgets/sample/messagebox2.rb b/jni/ruby/ext/tk/sample/tkextlib/iwidgets/sample/messagebox2.rb
new file mode 100644
index 0000000..5278883
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkextlib/iwidgets/sample/messagebox2.rb
@@ -0,0 +1,19 @@
+#!/usr/bin/env ruby
+require 'tk'
+require 'tkextlib/iwidgets'
+
+mb = Tk::Iwidgets::Messagebox.new(:hscrollmode=>:dynamic,
+ :labeltext=>'Messages', :labelpos=>:n,
+ :height=>120, :width=>550,
+ :savedir=>'/tmp', :textbackground=>'#d9d9d9')
+mb.pack(:padx=>5, :pady=>5, :fill=>:both, :expand=>true)
+
+error = mb.type_add(:background=>'red', :foreground=>'white', :bell=>true)
+warning = mb.type_add(:background=>'yellow', :foreground=>'black')
+info = mb.type_add(:background=>'white', :foreground=>'black')
+
+mb.issue('This is an error message in red with a beep', error)
+mb.issue('This warning message in yellow', warning)
+mb.issue('This is an informational message', info)
+
+Tk.mainloop
diff --git a/jni/ruby/ext/tk/sample/tkextlib/iwidgets/sample/messagedialog.rb b/jni/ruby/ext/tk/sample/tkextlib/iwidgets/sample/messagedialog.rb
new file mode 100644
index 0000000..52799f2
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkextlib/iwidgets/sample/messagedialog.rb
@@ -0,0 +1,44 @@
+#!/usr/bin/env ruby
+require 'tk'
+require 'tkextlib/iwidgets'
+
+mainloop = Thread.new{Tk.mainloop}
+
+#
+# Standard question message dialog used for confirmation.
+#
+md = Tk::Iwidgets::Messagedialog.new(:title=>'Message Dialog',
+ :text=>'Are you sure ? ',
+ :bitmap=>'questhead', :modality=>:global)
+
+md.buttonconfigure('OK', :text=>'Yes')
+md.buttonconfigure('Cancel', :text=>'No')
+
+if TkComm.bool(md.activate)
+ md.text('Are you really sure ? ')
+ if TkComm.bool(md.activate)
+ puts 'Yes'
+ else
+ puts 'No'
+ end
+else
+ puts 'No'
+end
+
+md.destroy
+
+#
+# Copyright notice with automatic deactivation.
+#
+bmp = '@' + File.join(File.dirname(File.expand_path(__FILE__)), '../catalog_demo/images/text.xbm')
+
+cr = Tk::Iwidgets::Messagedialog.new(:title=>'Copyright',
+ :bitmap=>bmp, :imagepos=>:n,
+ :text=>"Copyright 200x XXX Corporation\nAll rights reserved")
+
+cr.hide('Cancel')
+
+cr.activate
+Tk.after(7000, proc{cr.deactivate; Tk.root.destroy})
+
+mainloop.join
diff --git a/jni/ruby/ext/tk/sample/tkextlib/iwidgets/sample/notebook.rb b/jni/ruby/ext/tk/sample/tkextlib/iwidgets/sample/notebook.rb
new file mode 100644
index 0000000..4d460e8
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkextlib/iwidgets/sample/notebook.rb
@@ -0,0 +1,30 @@
+#!/usr/bin/env ruby
+require 'tk'
+require 'tkextlib/iwidgets'
+
+# Create the tabnotebook widget and pack it.
+nb = Tk::Iwidgets::Notebook.new(:width=>100, :height=>100)
+nb.pack(:anchor=>:nw, :fill=>:both, :expand=>true,
+ :side=>:left, :padx=>10, :pady=>10)
+
+# Add two pages to the tabnotebook,
+# labelled "Page One" and "Page Two"
+nb.add(:label=>'Page One')
+nb.add(:label=>'Page Two')
+
+# Get the child site frames of these two pages.
+page1CS = nb.child_site(0)
+page2CS = nb.child_site('Page Two')
+
+# Create buttons on each page of the tabnotebook.
+TkButton.new(page1CS, :text=>'Button One').pack
+TkButton.new(page2CS, :text=>'Button Two').pack
+
+# Select the first page of the tabnotebook.
+nb.select(0)
+
+# Create the scrollbar and associate the scrollbar
+# and the notebook together, then pack the scrollbar
+nb.scrollbar(TkScrollbar.new).pack(:fill=>:y, :expand=>true, :pady=>10)
+
+Tk.mainloop
diff --git a/jni/ruby/ext/tk/sample/tkextlib/iwidgets/sample/notebook2.rb b/jni/ruby/ext/tk/sample/tkextlib/iwidgets/sample/notebook2.rb
new file mode 100644
index 0000000..576a9c1
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkextlib/iwidgets/sample/notebook2.rb
@@ -0,0 +1,30 @@
+#!/usr/bin/env ruby
+require 'tk'
+require 'tkextlib/iwidgets'
+
+# Create the tabnotebook widget and pack it.
+nb = Tk::Iwidgets::Notebook.new(:width=>100, :height=>100)
+nb.pack(:anchor=>:nw, :fill=>:both, :expand=>true,
+ :side=>:top, :padx=>10, :pady=>0)
+
+# Add two pages to the tabnotebook,
+# labelled "Page One" and "Page Two"
+nb.add(:label=>'Page One')
+nb.add(:label=>'Page Two')
+
+# Get the child site frames of these two pages.
+page1CS = nb.child_site(0)
+page2CS = nb.child_site('Page Two')
+
+# Create buttons on each page of the tabnotebook.
+TkButton.new(page1CS, :text=>'Button One').pack
+TkButton.new(page2CS, :text=>'Button Two').pack
+
+# Select the first page of the tabnotebook.
+nb.select(0)
+
+# Create the scrollbar and associate the scrollbar
+# and the notebook together, then pack the scrollbar
+nb.xscrollbar(TkScrollbar.new).pack(:fill=>:x, :expand=>true, :padx=>10)
+
+Tk.mainloop
diff --git a/jni/ruby/ext/tk/sample/tkextlib/iwidgets/sample/optionmenu.rb b/jni/ruby/ext/tk/sample/tkextlib/iwidgets/sample/optionmenu.rb
new file mode 100644
index 0000000..2b921ff
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkextlib/iwidgets/sample/optionmenu.rb
@@ -0,0 +1,14 @@
+#!/usr/bin/env ruby
+require 'tk'
+require 'tkextlib/iwidgets'
+
+om = Tk::Iwidgets::Optionmenu.new(:labelmargin=>5, :labelpos=>:w,
+ :labeltext=>"Operating System :")
+
+om.insert('end', 'Unix', 'VMS', 'Linux', 'OS/2', 'Windows NT', 'DOS')
+om.sort_ascending
+om.select('Linux')
+
+om.pack(:padx=>10, :pady=>10)
+
+Tk.mainloop
diff --git a/jni/ruby/ext/tk/sample/tkextlib/iwidgets/sample/panedwindow.rb b/jni/ruby/ext/tk/sample/tkextlib/iwidgets/sample/panedwindow.rb
new file mode 100644
index 0000000..88fc401
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkextlib/iwidgets/sample/panedwindow.rb
@@ -0,0 +1,22 @@
+#!/usr/bin/env ruby
+require 'tk'
+require 'tkextlib/iwidgets'
+
+pw = Tk::Iwidgets::Panedwindow.new(:width=>300, :height=>300)
+
+pw.add('top')
+pw.add('middle', :margin=>10)
+pw.add('bottom', :margin=>10, :minimum=>10)
+
+pw.pack(:fill=>:both, :expand=>true)
+
+pw.child_site_list.each{|pane|
+ TkButton.new(pane, :text=>pane.path, :relief=>:raised,
+ :borderwidth=>2).pack(:fill=>:both, :expand=>true)
+}
+
+pw.fraction(50,30,20)
+pw.paneconfigure(0, :minimum=>20)
+pw.paneconfigure('bottom', :margin=>15)
+
+Tk.mainloop
diff --git a/jni/ruby/ext/tk/sample/tkextlib/iwidgets/sample/panedwindow2.rb b/jni/ruby/ext/tk/sample/tkextlib/iwidgets/sample/panedwindow2.rb
new file mode 100644
index 0000000..96987d5
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkextlib/iwidgets/sample/panedwindow2.rb
@@ -0,0 +1,22 @@
+#!/usr/bin/env ruby
+require 'tk'
+require 'tkextlib/iwidgets'
+
+pw = Tk::Iwidgets::Panedwindow.new(:width=>300, :height=>300)
+
+top = pw.add
+middle = pw.add(:margin=>10)
+bottom = pw.add(:margin=>10, :minimum=>10)
+
+pw.pack(:fill=>:both, :expand=>true)
+
+pw.child_site_list.each{|pane|
+ TkButton.new(pane, :text=>pane.path, :relief=>:raised,
+ :borderwidth=>2).pack(:fill=>:both, :expand=>true)
+}
+
+pw.fraction(50,30,20)
+pw.paneconfigure(0, :minimum=>20) # 0 == pw.index(top)
+pw.paneconfigure(bottom, :margin=>15)
+
+Tk.mainloop
diff --git a/jni/ruby/ext/tk/sample/tkextlib/iwidgets/sample/promptdialog.rb b/jni/ruby/ext/tk/sample/tkextlib/iwidgets/sample/promptdialog.rb
new file mode 100644
index 0000000..d92a26e
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkextlib/iwidgets/sample/promptdialog.rb
@@ -0,0 +1,17 @@
+#!/usr/bin/env ruby
+require 'tk'
+require 'tkextlib/iwidgets'
+
+mainloop = Thread.new{Tk.mainloop}
+
+TkOption.add('*textBackground', 'white')
+
+pd = Tk::Iwidgets::Promptdialog.new(:modality=>:global, :title=>'Password',
+ :labeltext=>'Password:', :show=>'*')
+pd.hide('Apply')
+
+if TkComm.bool(pd.activate)
+ puts "Password entered: #{pd.get}"
+else
+ puts "Password prompt cancelled"
+end
diff --git a/jni/ruby/ext/tk/sample/tkextlib/iwidgets/sample/pushbutton.rb b/jni/ruby/ext/tk/sample/tkextlib/iwidgets/sample/pushbutton.rb
new file mode 100644
index 0000000..e76dda8
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkextlib/iwidgets/sample/pushbutton.rb
@@ -0,0 +1,9 @@
+#!/usr/bin/env ruby
+require 'tk'
+require 'tkextlib/iwidgets'
+
+Tk::Iwidgets::Pushbutton.new(:text=>'Hello',
+ :command=>proc{puts 'Hello World'},
+ :defaultring=>true).pack(:padx=>10, :pady=>10)
+
+Tk.mainloop
diff --git a/jni/ruby/ext/tk/sample/tkextlib/iwidgets/sample/radiobox.rb b/jni/ruby/ext/tk/sample/tkextlib/iwidgets/sample/radiobox.rb
new file mode 100644
index 0000000..9cd6a00
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkextlib/iwidgets/sample/radiobox.rb
@@ -0,0 +1,13 @@
+#!/usr/bin/env ruby
+require 'tk'
+require 'tkextlib/iwidgets'
+
+rb = Tk::Iwidgets::Radiobox.new(:labeltext=>'Fonts')
+rb.add('times', :text=>'Times')
+rb.add('helvetica', :text=>'Helvetica')
+rb.add('courier', :text=>'Courier')
+rb.add('symbol', :text=>'Symbol')
+rb.select('courier')
+rb.pack(:expand=>true, :fill=>:both, :padx=>10, :pady=>10)
+
+Tk.mainloop
diff --git a/jni/ruby/ext/tk/sample/tkextlib/iwidgets/sample/scrolledcanvas.rb b/jni/ruby/ext/tk/sample/tkextlib/iwidgets/sample/scrolledcanvas.rb
new file mode 100644
index 0000000..92c94b9
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkextlib/iwidgets/sample/scrolledcanvas.rb
@@ -0,0 +1,13 @@
+#!/usr/bin/env ruby
+require 'tk'
+require 'tkextlib/iwidgets'
+
+sc = Tk::Iwidgets::Scrolledcanvas.new
+
+sc.create(TkcRectangle, 100, 100, 400, 400, :fill=>'red')
+TkcRectangle.new(sc, 300, 300, 600, 600, :fill=>'green')
+TkcRectangle.new(sc, [[200, 200], [500, 500]], :fill=>'blue')
+
+sc.pack(:expand=>true, :fill=>:both, :padx=>10, :pady=>10)
+
+Tk.mainloop
diff --git a/jni/ruby/ext/tk/sample/tkextlib/iwidgets/sample/scrolledframe.rb b/jni/ruby/ext/tk/sample/tkextlib/iwidgets/sample/scrolledframe.rb
new file mode 100644
index 0000000..e5bd90a
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkextlib/iwidgets/sample/scrolledframe.rb
@@ -0,0 +1,18 @@
+#!/usr/bin/env ruby
+require 'tk'
+require 'tkextlib/iwidgets'
+
+sf = Tk::Iwidgets::Scrolledframe.new(:width=>150, :height=>180,
+ :labeltext=>'scrolledframe')
+cs = sf.child_site
+
+TkButton.new(cs, :text=>'Hello').pack(:pady=>10)
+TkButton.new(cs, :text=>'World').pack(:pady=>10)
+TkButton.new(cs, :text=>'This is a test').pack(:pady=>10)
+TkButton.new(cs, :text=>'This is a really big button').pack(:pady=>10)
+TkButton.new(cs, :text=>'This is another really big button').pack(:pady=>10)
+TkButton.new(cs, :text=>'This is the last really big button').pack(:pady=>10)
+
+sf.pack(:expand=>true, :fill=>:both, :padx=>10, :pady=>10)
+
+Tk.mainloop
diff --git a/jni/ruby/ext/tk/sample/tkextlib/iwidgets/sample/scrolledhtml.rb b/jni/ruby/ext/tk/sample/tkextlib/iwidgets/sample/scrolledhtml.rb
new file mode 100644
index 0000000..2b675f8
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkextlib/iwidgets/sample/scrolledhtml.rb
@@ -0,0 +1,15 @@
+#!/usr/bin/env ruby
+require 'tk'
+require 'tkextlib/iwidgets'
+
+TkOption.add('*textBackground', 'white')
+
+sh = Tk::Iwidgets::Scrolledhtml.new(:fontname=>'helvetica',
+ :linkcommand=>proc{|href|
+ sh.import_link(href)
+ })
+sh.pack(:expand=>true, :fill=>:both, :padx=>10, :pady=>10)
+
+sh.import(Tk.getOpenFile(:title=>'select HTML document'))
+
+Tk.mainloop
diff --git a/jni/ruby/ext/tk/sample/tkextlib/iwidgets/sample/scrolledlistbox.rb b/jni/ruby/ext/tk/sample/tkextlib/iwidgets/sample/scrolledlistbox.rb
new file mode 100644
index 0000000..bf2c601
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkextlib/iwidgets/sample/scrolledlistbox.rb
@@ -0,0 +1,22 @@
+#!/usr/bin/env ruby
+require 'tk'
+require 'tkextlib/iwidgets'
+
+TkOption.add('*textBackground', 'white')
+
+slb = Tk::Iwidgets::Scrolledlistbox.new(:selectmode=>:single,
+ :vscrollmode=>:static,
+ :hscrollmode=>:dynamic,
+ :labeltext=>'List',
+ :selectioncommand=>proc{
+ puts(slb.get_curselection)
+ },
+ :dblclickcommand=>proc{
+ puts('Double Click')
+ puts(slb.get_curselection)
+ })
+slb.pack(:expand=>true, :fill=>:both, :padx=>10, :pady=>10)
+
+slb.insert('end', *['Hello', 'Out There', 'World'])
+
+Tk.mainloop
diff --git a/jni/ruby/ext/tk/sample/tkextlib/iwidgets/sample/scrolledtext.rb b/jni/ruby/ext/tk/sample/tkextlib/iwidgets/sample/scrolledtext.rb
new file mode 100644
index 0000000..41498e6
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkextlib/iwidgets/sample/scrolledtext.rb
@@ -0,0 +1,11 @@
+#!/usr/bin/env ruby
+require 'tk'
+require 'tkextlib/iwidgets'
+
+st = Tk::Iwidgets::Scrolledtext.new(:hscrollmode=>:dynamic, :wrap=>:none,
+ :labeltext=>'Password File')
+st.pack(:expand=>true, :fill=>:both, :padx=>10, :pady=>10)
+
+st.import('/etc/passwd')
+
+Tk.mainloop
diff --git a/jni/ruby/ext/tk/sample/tkextlib/iwidgets/sample/selectionbox.rb b/jni/ruby/ext/tk/sample/tkextlib/iwidgets/sample/selectionbox.rb
new file mode 100644
index 0000000..7468497
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkextlib/iwidgets/sample/selectionbox.rb
@@ -0,0 +1,19 @@
+#!/usr/bin/env ruby
+require 'tk'
+require 'tkextlib/iwidgets'
+
+TkOption.add('*textBackground', 'white')
+
+sb = Tk::Iwidgets::Selectionbox.new.pack(:padx=>10, :pady=>10,
+ :fill=>:both, :expand=>true)
+
+sb.insert_items('end', *['Hello', 'Out There', 'World'])
+
+TkLabel.new(sb.child_site,
+ :text=>'Child Site is Here').pack(:fill=>:x, :padx=>10, :pady=>10)
+
+sb.insert_items(2, 'Cruel Cruel')
+
+sb.selection_set(1)
+
+Tk.mainloop
diff --git a/jni/ruby/ext/tk/sample/tkextlib/iwidgets/sample/selectiondialog.rb b/jni/ruby/ext/tk/sample/tkextlib/iwidgets/sample/selectiondialog.rb
new file mode 100644
index 0000000..d53391f
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkextlib/iwidgets/sample/selectiondialog.rb
@@ -0,0 +1,12 @@
+#!/usr/bin/env ruby
+require 'tk'
+require 'tkextlib/iwidgets'
+
+mainloop = Thread.new{Tk.mainloop}
+
+TkButton.new(:text=>'QUIT',
+ :command=>proc{Tk.root.destroy}).pack(:padx=>10, :pady=>10)
+
+Tk::Iwidgets::Selectiondialog.new.activate
+
+mainloop.join
diff --git a/jni/ruby/ext/tk/sample/tkextlib/iwidgets/sample/shell.rb b/jni/ruby/ext/tk/sample/tkextlib/iwidgets/sample/shell.rb
new file mode 100644
index 0000000..6d01280
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkextlib/iwidgets/sample/shell.rb
@@ -0,0 +1,17 @@
+#!/usr/bin/env ruby
+require 'tk'
+require 'tkextlib/iwidgets'
+
+sh = Tk::Iwidgets::Shell.new(:modality=>:application,
+ :padx=>20, :pady=>20, :title=>'Shell')
+
+TkButton.new(:text=>'ACTIVATE', :padx=>7, :pady=>7,
+ :command=>proc{puts sh.activate}).pack(:padx=>10, :pady=>10)
+
+TkLabel.new(sh.child_site, :text=>'SHELL').pack
+TkButton.new(sh.child_site, :text=>'YES',
+ :command=>proc{sh.deactivate 'press YES'}).pack(:fill=>:x)
+TkButton.new(sh.child_site, :text=>'NO',
+ :command=>proc{sh.deactivate 'press NO'}).pack(:fill=>:x)
+
+Tk.mainloop
diff --git a/jni/ruby/ext/tk/sample/tkextlib/iwidgets/sample/spindate.rb b/jni/ruby/ext/tk/sample/tkextlib/iwidgets/sample/spindate.rb
new file mode 100644
index 0000000..17197a6
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkextlib/iwidgets/sample/spindate.rb
@@ -0,0 +1,7 @@
+#!/usr/bin/env ruby
+require 'tk'
+require 'tkextlib/iwidgets'
+
+Tk::Iwidgets::Spindate.new.pack(:padx=>10, :pady=>10)
+
+Tk.mainloop
diff --git a/jni/ruby/ext/tk/sample/tkextlib/iwidgets/sample/spinint.rb b/jni/ruby/ext/tk/sample/tkextlib/iwidgets/sample/spinint.rb
new file mode 100644
index 0000000..e2dde01
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkextlib/iwidgets/sample/spinint.rb
@@ -0,0 +1,10 @@
+#!/usr/bin/env ruby
+require 'tk'
+require 'tkextlib/iwidgets'
+
+TkOption.add('*textBackground', 'white')
+
+Tk::Iwidgets::Spinint.new(:labeltext=>'Temperature', :labelpos=>:w, :width=>5,
+ :fixed=>true, :range=>[32, 212]).pack(:pady=>10)
+
+Tk.mainloop
diff --git a/jni/ruby/ext/tk/sample/tkextlib/iwidgets/sample/spinner.rb b/jni/ruby/ext/tk/sample/tkextlib/iwidgets/sample/spinner.rb
new file mode 100644
index 0000000..6a20b0e
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkextlib/iwidgets/sample/spinner.rb
@@ -0,0 +1,33 @@
+#!/usr/bin/env ruby
+require 'tk'
+require 'tkextlib/iwidgets'
+
+class Spinner_demo < TkWindow
+ Months = %w(January February March April May June July August September October November December)
+
+ def block_input(c)
+ false
+ end
+
+ def spin_month(step)
+ index = Months.index(@spinner.get) + step
+ index = 11 if index < 0
+ index = 0 if index > 11
+
+ @spinner.value = Months[index]
+ end
+
+ def initialize(parent=nil)
+ @spinner = Tk::Iwidgets::Spinner.new(parent, :labeltext=>'Month : ',
+ :width=>10, :fixed=>10,
+ :validate=>proc{|c| block_input},
+ :decrement=>proc{spin_month -1},
+ :increment=>proc{spin_month 1})
+ @path = @spinner
+ @spinner.insert(0, Months[0])
+ end
+end
+
+Spinner_demo.new.pack(:padx=>10, :pady=>10)
+
+Tk.mainloop
diff --git a/jni/ruby/ext/tk/sample/tkextlib/iwidgets/sample/spintime.rb b/jni/ruby/ext/tk/sample/tkextlib/iwidgets/sample/spintime.rb
new file mode 100644
index 0000000..2c13884
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkextlib/iwidgets/sample/spintime.rb
@@ -0,0 +1,7 @@
+#!/usr/bin/env ruby
+require 'tk'
+require 'tkextlib/iwidgets'
+
+Tk::Iwidgets::Spintime.new.pack(:padx=>10, :pady=>10)
+
+Tk.mainloop
diff --git a/jni/ruby/ext/tk/sample/tkextlib/iwidgets/sample/tabnotebook.rb b/jni/ruby/ext/tk/sample/tkextlib/iwidgets/sample/tabnotebook.rb
new file mode 100644
index 0000000..382b34d
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkextlib/iwidgets/sample/tabnotebook.rb
@@ -0,0 +1,26 @@
+#!/usr/bin/env ruby
+require 'tk'
+require 'tkextlib/iwidgets'
+
+# Create the tabnotebook widget and pack it.
+tn = Tk::Iwidgets::Tabnotebook.new(:width=>300, :height=>100)
+tn.pack(:anchor=>:nw, :fill=>:both, :expand=>true,
+ :side=>:left, :padx=>10, :pady=>10)
+
+# Add two pages to the tabnotebook,
+# labelled "Page One" and "Page Two"
+tn.add(:label=>'Page One')
+tn.add(:label=>'Page Two')
+
+# Get the child site frames of these two pages.
+page1CS = tn.child_site(0)
+page2CS = tn.child_site('Page Two')
+
+# Create buttons on each page of the tabnotebook.
+TkButton.new(page1CS, :text=>'Button One').pack
+TkButton.new(page2CS, :text=>'Button Two').pack
+
+# Select the first page of the tabnotebook.
+tn.select(0)
+
+Tk.mainloop
diff --git a/jni/ruby/ext/tk/sample/tkextlib/iwidgets/sample/tabnotebook2.rb b/jni/ruby/ext/tk/sample/tkextlib/iwidgets/sample/tabnotebook2.rb
new file mode 100644
index 0000000..2689759
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkextlib/iwidgets/sample/tabnotebook2.rb
@@ -0,0 +1,30 @@
+#!/usr/bin/env ruby
+require 'tk'
+require 'tkextlib/iwidgets'
+
+# Create the tabnotebook widget and pack it.
+tn = Tk::Iwidgets::Tabnotebook.new(:width=>300, :height=>100)
+tn.pack(:anchor=>:nw, :fill=>:both, :expand=>true,
+ :side=>:top, :padx=>10, :pady=>0)
+
+# Add two pages to the tabnotebook,
+# labelled "Page One" and "Page Two"
+tn.add(:label=>'Page One')
+tn.add(:label=>'Page Two')
+
+# Get the child site frames of these two pages.
+page1CS = tn.child_site(0)
+page2CS = tn.child_site('Page Two')
+
+# Create buttons on each page of the tabnotebook.
+TkButton.new(page1CS, :text=>'Button One').pack
+TkButton.new(page2CS, :text=>'Button Two').pack
+
+# Select the first page of the tabnotebook.
+tn.select(0)
+
+# Create the scrollbar
+# and the notebook together, then pack the scrollbar
+tn.xscrollbar(TkScrollbar.new).pack(:fill=>:x, :expand=>true, :padx=>10)
+
+Tk.mainloop
diff --git a/jni/ruby/ext/tk/sample/tkextlib/iwidgets/sample/tabset.rb b/jni/ruby/ext/tk/sample/tkextlib/iwidgets/sample/tabset.rb
new file mode 100644
index 0000000..90be46b
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkextlib/iwidgets/sample/tabset.rb
@@ -0,0 +1,34 @@
+#!/usr/bin/env ruby
+require 'tk'
+require 'tkextlib/iwidgets'
+
+# Create a listbox with two items (one and two)
+l = TkListbox.new(:selectmode=>:single, :exportselection=>false).pack
+l.insert('end', 'one')
+l.insert('end', 'two')
+l.selection_set(0)
+
+# Define a proc that knows how to select an item
+# from a list given an index from the tabset -command callback.
+selectItem = proc{|item|
+ l.selection_clear(l.curselection)
+ l.selection_set(item)
+ l.see(item)
+}
+
+# Create a tabset, set its -command to call selectItem
+# Add two labels to the tabset (one and two).
+ts = Tk::Iwidgets::Tabset.new(:command=>selectItem)
+ts.add(:label=>1)
+ts.add(:label=>2)
+ts.select(0)
+ts.pack(:fill=>:x, :expand=>true)
+
+# Define a proc that knows how to select a tab
+# given a y pixel coordinate from the list..
+selectTab = proc{|y| ts.select(l.nearest(y)) }
+
+# bind button 1 press to the selectTab procedure.
+l.bind('ButtonPress-1', proc{|y| selectTab.call(y) }, '%y')
+
+Tk.mainloop
diff --git a/jni/ruby/ext/tk/sample/tkextlib/iwidgets/sample/timeentry.rb b/jni/ruby/ext/tk/sample/tkextlib/iwidgets/sample/timeentry.rb
new file mode 100644
index 0000000..4659399
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkextlib/iwidgets/sample/timeentry.rb
@@ -0,0 +1,7 @@
+#!/usr/bin/env ruby
+require 'tk'
+require 'tkextlib/iwidgets'
+
+Tk::Iwidgets::Timeentry.new.pack
+
+Tk.mainloop
diff --git a/jni/ruby/ext/tk/sample/tkextlib/iwidgets/sample/timefield.rb b/jni/ruby/ext/tk/sample/tkextlib/iwidgets/sample/timefield.rb
new file mode 100644
index 0000000..bb59450
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkextlib/iwidgets/sample/timefield.rb
@@ -0,0 +1,8 @@
+#!/usr/bin/env ruby
+require 'tk'
+require 'tkextlib/iwidgets'
+
+tf = Tk::Iwidgets::Timefield.new(:command=>proc{puts(tf.get)})
+tf.pack(:fill=>:x, :expand=>true, :padx=>10, :pady=>10)
+
+Tk.mainloop
diff --git a/jni/ruby/ext/tk/sample/tkextlib/iwidgets/sample/toolbar.rb b/jni/ruby/ext/tk/sample/tkextlib/iwidgets/sample/toolbar.rb
new file mode 100644
index 0000000..608efd0
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkextlib/iwidgets/sample/toolbar.rb
@@ -0,0 +1,152 @@
+#!/usr/bin/env ruby
+require 'tk'
+require 'tkextlib/iwidgets'
+
+##########################################
+# icon images
+editcopy22 = TkPhotoImage.new(:data=><<'EOD')
+ R0lGODlhFgAWAIUAAPwCBBQSFPz+/DQyNISChDw6PMzKzMTGxERGRIyKjFxa
+ XMTCvKSmpHR2dPz6/Pz29PTq3MS2rPz69MTCxFxWVHx6dJyWjNzSzPz27Pzy
+ 7Pzu5PTm3NTKvIR+fJyGfHxuZHxqXNTCtPTq5PTi1PTezNS+rExOTFRORMyy
+ lPTaxOzWxOzSvNze3NTOxMy2nMyulMyqjAQCBAAAAAAAAAAAAAAAAAAAAAAA
+ AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAWABYAAAbY
+ QIBwSCwahYGkUnk0BgTQ6IAQaBKfUWhBYKhaAU+CgXAQIAyChLeJzSIQhcH6
+ GFaM0QtGY5kstqEODw8QEQELAhJTc08KBBMEFBUWDRcBE1pca20SGBkaEBsc
+ AY5maFRIAgoLHRQRHh8gIQFlZnByqA8ZGSIQIyQjJQEmYgJ5p2ACrK4gJx4g
+ KIZZAgdeAQ4ZI9kjKSor0AwEjeAs1S0cHAslLi4vMDDRWeRIfEsxMeET4ATy
+ VoYLC5fizXEiAR84BeMG+pEm8EsAFhAjSlR4hR6fLxiF0AkCACH+aENyZWF0
+ ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29yIDE5
+ OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cuZGV2
+ ZWxjb3IuY29tADs=
+EOD
+
+editcut22 = TkPhotoImage.new(:data=><<'EOD')
+ R0lGODlhFgAWAIMAAPwCBAQCBAwCBPz+/OTi5JyanOzq7DQyNGxqbAAAAAAA
+ AAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAWABYAAARbEMhJq704gxBE
+ 0Bf3cZo4kRJqBQNRfBucyudgvJS6VaxLzyMa6/bLiWA9HOg4VIIkL5vzuRkc
+ pkvRIIAorphJLzBW84WEuRZWp6uaT7J2Sh1Hit3OY/ZO7WvsEQAh/mhDcmVh
+ dGVkIGJ5IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAx
+ OTk3LDE5OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRl
+ dmVsY29yLmNvbQA7
+EOD
+
+editpaste22 = TkPhotoImage.new(:data=><<'EOD')
+ R0lGODlhFgAWAIYAAPwCBBQWFDw6FHRuFGRaBFxSBAQCBAQKBCQiBIx6HPz6
+ /NTOfKyiXDQuFOTm5Pz+/Ozu7PTq5Pz63PTyxNTOjKSeRExGLMTGxMzKzNTS
+ 1NTW1Dw2NKSmpKyqrKSipJyanNzWlLy6ZLSuVIx6FISChIyKhJSSlCQiJLS2
+ tDw6NDQyNCQiFCQmHBQSDGRiZHRydGxubHx6dGxqbFxeXGRmZFxaXCwuLOzq
+ 7KyurHx+fDwmFEQuFCweFCQWDBQODBwaHBweHKSinJSWlOTi5JyepHR2dDw6
+ PBQSFNze3ERGRIyKjIyOjISGhPz29Pzy7MS2rMzOzFRWVHx2dHxybDQiFPz2
+ 7Pzu5PTq3PTm1NTCtJyGdHxuZHxqXPzq3PTaxNS6pFxWVFRKRNS2nPTi1PTS
+ tNSulNzOxNSynMymhAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+ AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAA
+ LAAAAAAWABYAAAf/gACCgwABAgMEBYSLggaOjgcICQoLDA2Pj4MGDg8QEZ4F
+ DxITFBUWFxcYGRobjQ8cHR4fCQ8gCyEiFSMWJCUkJieNEB4dKB4pKissK8wr
+ LS4vMDHBAAYQHx8dFx0fJDIzNDU0M+IyHzaNNyg43Ng5Ojs7Ojw9Pj9AMkCN
+ DiZB/h9CSOx4QLCgihItqBkYgqIDESElitAYWJCgkQcXjjRCgi1Ihw4BB5LA
+ QOLCgyQYHihpUU3DBw5ElpAgAYNixSRJjKjQaECDCRPZPDB5IbIGSQwKLnh4
+ wbInLA4kmJB4oaPiAwVNnER40hRK1BIAaVatUZJEFCkmpmjgCeWDCalFe4q4
+ oFKwSRUrEa5gycLzwq8lUnPQ4PEgSpYcUZ5o2cIlS1O/JHLEDdfjQZMIVrpg
+ weLFy5e+M6WSmBGlxYMYYBRzCaOFi5imHWBIfOEiShLTVjaP6eyFTBmN1TA5
+ OvLDjJksWb58OVMGDRqWjAYdmU79SIvpjqJr104nEAAh/mhDcmVhdGVkIGJ5
+ IEJNUFRvR0lGIFBybyB2ZXJzaW9uIDIuNQ0KqSBEZXZlbENvciAxOTk3LDE5
+ OTguIEFsbCByaWdodHMgcmVzZXJ2ZWQuDQpodHRwOi8vd3d3LmRldmVsY29y
+ LmNvbQA7
+EOD
+
+editdelete22 = TkPhotoImage.new(:data=><<'EOD')
+ R0lGODlhFgAWAIYAAASC/FRSVExKTERCRDw6PDQyNCwuLBweHBwaHAwODAwK
+ DAQCBExOTNze3NTW1MTGxLS2tJyanPz+/Ozu7BQSFCwqLDw+POTi5PTu7MzK
+ xIR+fCQmJPz6/Oze1NTGvPz69Pzy7Pz29LyyrPy+vPyupPTm1BQWFIQCBPwC
+ BMS6rPzSzNTOxPTi1NS+rPTezNzOxPTizOzWxMy2pOzaxMy2nPTaxOzOtMyy
+ nOzSvMyqjPx+fOzGpMSihPTq3OzKrOTCpNzKxNTCtAAAAAAAAAAAAAAAAAAA
+ AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+ AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+ AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+ AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAA
+ LAAAAAAWABYAAAf8gACCAQIDBAUGBwgJCgsLgpCRAAwNlZYODxALEY+SkAMN
+ EqKjEw0UD5yegqCjrRMVEqidkgWhraMWF7GptLa3EgEWFRSOnhW+vxgZEBqz
+ kBvItxwdHryRCNGjHyAhHSLOgtgSI60c2yQjJd+eJqEnKK0hJCgnJSngAO0S
+ F+8qEvL0VrBogW+BLX4oVKgIyMIFQU8KfDV4R+8FDBcxZBREthAFiRIsOsyg
+ sVEUh4Un3pGoUcPGjZInK65QicPlxg8oX5RwqNJGjo0hdJwQ6EIkjRM6dvDY
+ CKIHSBc1Ztjw4eOH0oIrsgIJEqSFDBo0cuTgsdSTo7No0xYTZCcQACH+aENy
+ ZWF0ZWQgYnkgQk1QVG9HSUYgUHJvIHZlcnNpb24gMi41DQqpIERldmVsQ29y
+ IDE5OTcsMTk5OC4gQWxsIHJpZ2h0cyByZXNlcnZlZC4NCmh0dHA6Ly93d3cu
+ ZGV2ZWxjb3IuY29tADs=
+EOD
+
+text22 = TkPhotoImage.new(:data=><<'EOD')
+ R0lGODlhFgAWAIQAAPwCBAQCBBwaHAwKDBQSFLy+vLS2tJSWlBQWFKyqrFRS
+ VCwqLDQyNNTS1GxqbFxaXJyanIyOjAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+ AAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAWABYAAAVcICCOZGmK
+ QSoMaZsShBsQBdAapHvgaIDUqUPJlRjSbAoT0fRDKgODRbF0PLUYjZO2F2Bs
+ t9evNix+dsvDlGKK5jraudQb7qbX6a2HEJ+ycyF+LRE8ZTI+fX5oGCEAIf5o
+ Q3JlYXRlZCBieSBCTVBUb0dJRiBQcm8gdmVyc2lvbiAyLjUNCqkgRGV2ZWxD
+ b3IgMTk5NywxOTk4LiBBbGwgcmlnaHRzIHJlc2VydmVkLg0KaHR0cDovL3d3
+ dy5kZXZlbGNvci5jb20AOw==
+EOD
+
+##########################################
+
+bmp_dir = File.join(File.dirname(File.expand_path(__FILE__)),
+ '../catalog_demo/images')
+
+##########################################
+
+status_var = TkVariable.new
+radio_var = TkVariable.new
+check_var1 = TkVariable.new
+check_var2 = TkVariable.new
+
+tb = Tk::Iwidgets::Toolbar.new(:helpvariable=>status_var)
+
+##########################################
+
+tb.add(:button, :helpstr=>'Copy It', :image=>editcopy22,
+ :balloonstr=>'Copy', :command=>proc{puts 'Copy It'})
+
+tb.add(:button, :helpstr=>'Cut It', :image=>editcut22,
+ :balloonstr=>'Cut', :command=>proc{puts 'Cut It'})
+
+tb.add(:button, :helpstr=>'Paste It', :image=>editpaste22,
+ :balloonstr=>'Paste', :command=>proc{puts 'Paste It'})
+
+tb.add(:button, :helpstr=>'Delete It', :image=>editdelete22,
+ :balloonstr=>'Delete', :command=>proc{puts 'Delete It'})
+
+#--------------------------------
+
+tb.add(:frame, :borderwidth=>1, :width=>10, :height=>10)
+
+#--------------------------------
+
+tb.add(:radiobutton, :variable=>radio_var, :value=>'Box',
+ :bitmap=>"@#{bmp_dir}/box.xbm",
+ :helpstr=>'Radio Button #1', :balloonstr=>'Radio',
+ :command=>proc{puts 'Radio Button "Box"'})
+
+tb.add(:radiobutton, :variable=>radio_var, :value=>'Line',
+ :bitmap=>"@#{bmp_dir}/line.xbm",
+ :helpstr=>'Radio Button #2', :balloonstr=>'Radio',
+ :command=>proc{puts 'Radio Button "Line"'})
+
+tb.add(:radiobutton, :variable=>radio_var, :value=>'Oval',
+ :bitmap=>"@#{bmp_dir}/oval.xbm",
+ :helpstr=>'Radio Button #3', :balloonstr=>'Radio',
+ :command=>proc{puts 'Radio Button "Oval"'})
+
+#--------------------------------
+
+tb.add(:frame, :borderwidth=>1, :width=>10, :height=>10)
+
+#--------------------------------
+
+tb.add(:checkbutton, :variable=>check_var1, :onvalue=>'yes', :offvalue=>'no',
+ :image=>text22, :command=>proc{puts 'Checkbutton 1'})
+
+tb.add(:checkbutton, :variable=>check_var2, :onvalue=>'yes', :offvalue=>'no',
+ :bitmap=>"@#{bmp_dir}/points.xbm", :command=>proc{puts 'Checkbutton 2'})
+
+tb.pack(:side=>:top, :anchor=>:nw)
+
+Tk.mainloop
diff --git a/jni/ruby/ext/tk/sample/tkextlib/iwidgets/sample/watch.rb b/jni/ruby/ext/tk/sample/tkextlib/iwidgets/sample/watch.rb
new file mode 100644
index 0000000..2af53ba
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkextlib/iwidgets/sample/watch.rb
@@ -0,0 +1,18 @@
+#!/usr/bin/env ruby
+require 'tk'
+require 'tkextlib/iwidgets'
+
+Thread.new{
+ trap('INT') {puts 'catch SIGINT'}
+ sleep 5
+ trap('INT', 'DEFAULT')
+}
+
+Tk::Iwidgets::Watch.new(:state=>:disabled, :showampm=>:no,
+ :width=>155, :height=>155){|w|
+ w.pack(:padx=>10, :pady=>10, :fill=>:both, :expand=>true)
+ # TkTimer.new(1000, -1, proc{w.show; Tk.update}).start
+ TkTimer.new(25, -1, proc{w.show; Tk.update}).start
+}
+
+Tk.mainloop
diff --git a/jni/ruby/ext/tk/sample/tkextlib/tcllib/Orig_LICENSE.txt b/jni/ruby/ext/tk/sample/tkextlib/tcllib/Orig_LICENSE.txt
new file mode 100644
index 0000000..975f23e
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkextlib/tcllib/Orig_LICENSE.txt
@@ -0,0 +1,46 @@
+
+ >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
+ >>> The following text is the original 'license.term' of tklib <<<
+ >>> extension. <<<
+ >>> Original Tcl files are not include in this directory, because <<<
+ >>> of all of them are rewritten to Ruby files. <<<
+ >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
+
+This software is copyrighted by Ajuba Solutions and other parties.
+The following terms apply to all files associated with the software unless
+explicitly disclaimed in individual files.
+
+The authors hereby grant permission to use, copy, modify, distribute,
+and license this software and its documentation for any purpose, provided
+that existing copyright notices are retained in all copies and that this
+notice is included verbatim in any distributions. No written agreement,
+license, or royalty fee is required for any of the authorized uses.
+Modifications to this software may be copyrighted by their authors
+and need not follow the licensing terms described here, provided that
+the new terms are clearly indicated on the first page of each file where
+they apply.
+
+IN NO EVENT SHALL THE AUTHORS OR DISTRIBUTORS BE LIABLE TO ANY PARTY
+FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
+ARISING OUT OF THE USE OF THIS SOFTWARE, ITS DOCUMENTATION, OR ANY
+DERIVATIVES THEREOF, EVEN IF THE AUTHORS HAVE BEEN ADVISED OF THE
+POSSIBILITY OF SUCH DAMAGE.
+
+THE AUTHORS AND DISTRIBUTORS SPECIFICALLY DISCLAIM ANY WARRANTIES,
+INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE, AND NON-INFRINGEMENT. THIS SOFTWARE
+IS PROVIDED ON AN "AS IS" BASIS, AND THE AUTHORS AND DISTRIBUTORS HAVE
+NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR
+MODIFICATIONS.
+
+GOVERNMENT USE: If you are acquiring this software on behalf of the
+U.S. government, the Government shall have only "Restricted Rights"
+in the software and related documentation as defined in the Federal
+Acquisition Regulations (FARs) in Clause 52.227.19 (c) (2). If you
+are acquiring the software on behalf of the Department of Defense, the
+software shall be classified as "Commercial Computer Software" and the
+Government shall have only "Restricted Rights" as defined in Clause
+252.227-7013 (c) (1) of DFARs. Notwithstanding the foregoing, the
+authors grant the U.S. Government and others acting in its behalf
+permission to use and distribute the software in accordance with the
+terms specified in this license.
diff --git a/jni/ruby/ext/tk/sample/tkextlib/tcllib/datefield.rb b/jni/ruby/ext/tk/sample/tkextlib/tcllib/datefield.rb
new file mode 100644
index 0000000..3550af7
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkextlib/tcllib/datefield.rb
@@ -0,0 +1,29 @@
+#!/usr/bin/ruby
+
+require 'tk'
+require 'tkextlib/tcllib/datefield'
+require 'parsedate'
+
+Tk.root.title('Datefield example')
+
+
+my_date1 = TkVariable.new
+my_date2 = TkVariable.new
+my_date1.trace('w'){
+ begin
+ t = Time.local(*(ParseDate.parsedate(my_date1.value)))
+ my_date2.value = t.strftime('%A')
+ rescue
+ # ignore error
+ end
+}
+
+df = Tk::Tcllib::Datefield.new(:textvariable=>my_date1)
+Tk.grid(TkLabel.new(:text=>'Enter a date:', :anchor=>:e), df, :sticky=>:ew)
+Tk.grid(TkLabel.new(:text=>'That date ia a:', :anchor=>:e),
+ TkLabel.new(:textvariable=>my_date2, :relief=>:sunken, :width=>12),
+ :sticky=>:ew)
+
+df.set_focus
+
+Tk.mainloop
diff --git a/jni/ruby/ext/tk/sample/tkextlib/tcllib/plotdemos1.rb b/jni/ruby/ext/tk/sample/tkextlib/tcllib/plotdemos1.rb
new file mode 100644
index 0000000..7f35a38
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkextlib/tcllib/plotdemos1.rb
@@ -0,0 +1,158 @@
+#!/usr/bin/ruby
+
+require 'tk'
+require 'tkextlib/tcllib/plotchart'
+
+###############################
+
+c1 = TkCanvas.new(:background=>'white', :width=>400, :height=>200)
+c2 = TkCanvas.new(:background=>'white', :width=>400, :height=>200)
+c3 = TkCanvas.new(:background=>'white', :width=>400, :height=>200)
+Tk.pack(c1,c2,c3, :fill=>:both, :side=>:top)
+
+h = TkToplevel.new(:title=>'h')
+hc1 = TkCanvas.new(h, :background=>'white', :width=>400, :height=>200)
+hc2 = TkCanvas.new(h, :background=>'white', :width=>400, :height=>200)
+Tk.pack(hc1,hc2, :fill=>:both, :side=>:top)
+
+v = TkToplevel.new(:title=>'v')
+vc1 = TkCanvas.new(v, :background=>'white', :width=>400, :height=>200)
+vc2 = TkCanvas.new(v, :background=>'white', :width=>400, :height=>200)
+vc3 = TkCanvas.new(v, :background=>'white', :width=>400, :height=>200)
+Tk.pack(vc1,vc2,vc3, :fill=>:both, :side=>:top)
+
+###############################
+
+s = Tk::Tcllib::Plotchart::XYPlot.new(c1, [0.0, 100.0, 10.0],
+ [0.0, 100.0, 20.0])
+
+
+xd = 5.0
+yd = 20.0
+xold = 0.0
+yold = 50.0
+
+s.dataconfig('series1', :color=>'red')
+
+(0..19).each{|i|
+ xnew = xold + xd
+ ynew = yold + (rand() - 0.5) * yd
+ ynew2 = yold + (rand() - 0.5) * 2.0 * yd
+ s.plot('series1', xnew, ynew)
+ s.plot('series2', xnew, ynew2)
+ xold = xnew
+ yold = ynew
+}
+
+s.xtext "X-coordinate"
+s.ytext "Y-data"
+s.title "Aha!"
+
+c1.wait_visibility
+
+s.save_plot "aha.ps"
+
+###############################
+
+s = Tk::Tcllib::Plotchart::Piechart.new(c2)
+
+s.plot([ ["Long names", 10], ["Short names", 30],
+ ["Average", 40], ["Ultra-short names", 5] ])
+
+#
+# Note: title should be shifted up
+# - distinguish a separate title area
+#
+s.title "Okay - this works"
+
+###############################
+
+s = Tk::Tcllib::Plotchart::PolarPlot.new(c3, [3.0, 1.0])
+
+0.step(359, 10){|angle|
+ rad = 1.0+Math.cos(angle*Math::PI/180.0)
+ s.plot('cardioid', rad, angle)
+}
+
+s.title "Cardioid"
+
+###############################
+
+s = Tk::Tcllib::Plotchart::Barchart.new(hc1, %w(A B C D E),
+ [0.0, 10.0, 2.0], 2)
+
+s.plot('series1', [1.0, 4.0, 6.0, 1.0, 7.0], 'red')
+s.plot('series2', [0.0, 3.0, 7.0, 9.3, 2.0], 'green')
+s.title "Arbitrary data"
+
+###############################
+
+s = Tk::Tcllib::Plotchart::Barchart.new(hc2, %w(A B C D E),
+ [0.0, 20.0, 5.0], :stacked)
+
+s.plot('series1', [1.0, 4.0, 6.0, 1.0, 7.0], 'red')
+s.plot('series2', [0.0, 3.0, 7.0, 9.3, 2.0], 'green')
+s.title "Stacked diagram"
+
+###############################
+
+s = Tk::Tcllib::Plotchart::HorizontalBarchart.new(vc1, [0.0, 10.0, 2.0],
+ %w(A B C D E), 2)
+
+s.plot('series1', [1.0, 4.0, 6.0, 1.0, 7.0], 'red')
+s.plot('series2', [0.0, 3.0, 7.0, 9.3, 2.0], 'green')
+s.title "Arbitrary data"
+
+###############################
+
+s = Tk::Tcllib::Plotchart::HorizontalBarchart.new(vc2, [0.0, 20.0, 5.0],
+ %w(A B C D E), :stacked)
+
+s.plot('series1', [1.0, 4.0, 6.0, 1.0, 7.0], 'red')
+s.plot('series2', [0.0, 3.0, 7.0, 9.3, 2.0], 'green')
+s.title "Stacked diagram"
+
+###############################
+
+s = Tk::Tcllib::Plotchart::Timechart.new(vc3, "1 january 2004",
+ "31 december 2004", 4)
+
+s.period("Spring", "1 march 2004", "1 june 2004", 'green')
+s.period("Summer", "1 june 2004", "1 september 2004", 'yellow')
+s.vertline("1 jan", "1 january 2004")
+s.vertline("1 apr", "1 april 2004")
+s.vertline("1 jul", "1 july 2004")
+s.vertline("1 oct", "1 october 2004")
+s.milestone("Longest day", "21 july 2004")
+s.title "Seasons (northern hemisphere)"
+
+###############################
+
+z = TkToplevel.new(:title=>'3D')
+
+zc1 = TkCanvas.new(z, :background=>'white', :width=>400, :height=>300)
+zc2 = TkCanvas.new(z, :background=>'white', :width=>400, :height=>250)
+Tk.pack(zc1,zc2)
+
+s = Tk::Tcllib::Plotchart::Plot3D.new(zc1,
+ [0, 10, 3], [-10, 10, 10], [0, 10, 2.5])
+
+s.title "3D Plot"
+s.plot_function{|x, y|
+ # cowboyhat
+ x1 = x.to_f/9.0
+ y1 = y.to_f/9.0
+ 3.0 * (1.0-(x1*x1+y1*y1))*(1.0-(x1*x1+y1*y1))
+}
+
+s = Tk::Tcllib::Plotchart::Plot3D.new(zc2,
+ [0, 10, 3], [-10, 10, 10], [0, 10, 2.5])
+s.title "3D Plot - data "
+s.colour("green", "black")
+s.plot_data([ [1.0, 2.0, 1.0, 0.0],
+ [1.1, 3.0, 1.1, -0.5],
+ [3.0, 1.0, 4.0, 5.0] ])
+
+###############################
+
+Tk.mainloop
diff --git a/jni/ruby/ext/tk/sample/tkextlib/tcllib/plotdemos2.rb b/jni/ruby/ext/tk/sample/tkextlib/tcllib/plotdemos2.rb
new file mode 100644
index 0000000..cb657a4
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkextlib/tcllib/plotdemos2.rb
@@ -0,0 +1,71 @@
+#!/usr/bin/ruby
+
+require 'tk'
+require 'tkextlib/tcllib/plotchart'
+
+###############################
+
+c1 = TkCanvas.new(:background=>'white', :width=>400, :height=>200)
+c2 = TkCanvas.new(:background=>'white', :width=>400, :height=>200)
+Tk.pack(c1,c2, :fill=>:both, :side=>:top)
+
+###############################
+# Set up a strip chart
+###############################
+slipchart = Tk::Tcllib::Plotchart::Stripchart.new(c1, [0.0, 100.0, 10.0],
+ [0.0, 100.0, 20.0])
+
+TkTimer.new(500, -1, proc{|obj| # obj --> TkTimer object
+ slipchart, xold, xd, yold, yd = obj.return_value
+ xnew = xold + xd
+ ynew = yold + (rand() - 0.5) * yd
+ ynew2 = yold + (rand() - 0.5) * 2.0 * yd
+ slipchart.plot('series1', xnew, ynew)
+ slipchart.plot('series2', xnew, ynew2)
+ obj.stop if xnew >= 200
+ [slipchart, xnew, xd, ynew, yd] # return_value
+ }).start(100, proc{
+ # init return_value
+ [slipchart, 0.0, 15.0, 50.0, 30.0]
+ })
+
+slipchart.title "Aha!"
+
+###############################
+# Set up an isometric plot
+###############################
+s = Tk::Tcllib::Plotchart::IsometricPlot.new(c2, [0.0, 100.0], [0.0, 200.0],
+ :noaxes)
+
+s.set_zoom_pan
+
+s.plot('rectangle', [10.0, 10.0, 50.0, 50.0], 'green')
+s.plot('filled-rectangle', [20.0, 20.0, 40.0, 40.0], 'red')
+s.plot('filled-circle', [70.0, 70.0, 40.0], 'yellow')
+s.plot('circle', [70.0, 70.0, 42.0])
+
+###############################
+# Check the symbols
+###############################
+h = TkToplevel.new(:title=>'h')
+c = TkCanvas.new(h, :bg=>'white', :width=>400, :height=>200).pack(:fill=>:both)
+
+s = Tk::Tcllib::Plotchart::XYPlot.new(c, [0.0, 100.0, 10.0],
+ [0.0, 100.0, 20.0])
+s.dataconfig('series1', :colour=>'red', :type=>:symbol)
+s.dataconfig('series2', :colour=>'green', :type=>:both)
+
+s.yconfig(:format=>"%12.2e")
+
+x = 5.0
+%w(plus cross circle up down dot upfilled downfilled).each{|sym|
+ s.dataconfig('series1', :symbol=>sym)
+ s.dataconfig('series2', :symbol=>sym)
+ s.plot('series1', x, 50.0)
+ s.plot('series2', x, 20)
+ x += 10
+}
+
+##############################
+
+Tk.mainloop
diff --git a/jni/ruby/ext/tk/sample/tkextlib/tcllib/plotdemos3.rb b/jni/ruby/ext/tk/sample/tkextlib/tcllib/plotdemos3.rb
new file mode 100644
index 0000000..66b8fe7
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkextlib/tcllib/plotdemos3.rb
@@ -0,0 +1,83 @@
+#!/usr/bin/ruby
+
+require 'tk'
+require 'tkextlib/tcllib/plotchart'
+
+###############################
+# Set up a strip chart
+###############################
+
+Tk::Tcllib::Plotchart::Stripchart.new([0.0, 100.0, 10.0],
+ [0.0, 100.0, 20.0],
+ :background=>'white',
+ :width=>400, :height=>200){|chart|
+ title "Aha!"
+ pack(:fill=>:both, :side=>:top)
+
+ series1 = Tk::Tcllib::Plotchart::PlotSeries.new(chart)
+ series2 = Tk::Tcllib::Plotchart::PlotSeries.new(chart)
+
+ xd = 15.0
+ yd = 30.0
+
+ TkTimer.new(500, -1, proc{|obj| # obj --> TkTimer object
+ xold, yold = obj.return_value
+ xnew = xold + xd
+ ynew = yold + (rand() - 0.5) * yd
+ ynew2 = yold + (rand() - 0.5) * 2.0 * yd
+
+ series1.plot(xnew, ynew)
+ series2.plot(xnew, ynew2)
+
+ obj.stop if xnew >= 200
+
+ [xnew, ynew] # return_value
+ }).start(100, proc{ [0.0, 50.0] }) # init return_value
+}
+
+###############################
+# Set up an isometric plot
+###############################
+Tk::Tcllib::Plotchart::IsometricPlot.new([0.0, 100.0], [0.0, 200.0], :noaxes,
+ :background=>'white',
+ :width=>400, :height=>200){|chart|
+ pack(:fill=>:both, :side=>:top)
+ set_zoom_pan
+
+ chart.plot('rectangle', [10.0, 10.0, 50.0, 50.0], 'green')
+ chart.plot('filled-rectangle', [20.0, 20.0, 40.0, 40.0], 'red')
+ chart.plot('filled-circle', [70.0, 70.0, 40.0], 'yellow')
+ chart.plot('circle', [70.0, 70.0, 42.0])
+}
+
+###############################
+# Check the symbols
+###############################
+TkToplevel.new(:title=>'h'){|h|
+ Tk::Tcllib::Plotchart::XYPlot.new(h, [0.0, 100.0, 10.0],
+ [0.0, 100.0, 20.0],
+ :bg=>'white',
+ :width=>400, :height=>200){|chart|
+ pack(:fill=>:both)
+
+ yconfig(:format=>"%12.2e")
+
+ series1 = Tk::Tcllib::Plotchart::PlotSeries.new(chart, :colour=>'red',
+ :type=>:symbol)
+ series2 = Tk::Tcllib::Plotchart::PlotSeries.new(chart, :colour=>'green',
+ :type=>:both)
+
+ x = 5.0
+ %w(plus cross circle up down dot upfilled downfilled).each{|sym|
+ series1.dataconfig(:symbol=>sym)
+ series2.dataconfig(:symbol=>sym)
+ series1.plot(x, 50.0)
+ series2.plot(x, 20)
+ x += 10
+ }
+ }
+}
+
+##############################
+
+Tk.mainloop
diff --git a/jni/ruby/ext/tk/sample/tkextlib/tcllib/xyplot.rb b/jni/ruby/ext/tk/sample/tkextlib/tcllib/xyplot.rb
new file mode 100644
index 0000000..2aa101e
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkextlib/tcllib/xyplot.rb
@@ -0,0 +1,17 @@
+#!/usr/bin/ruby
+
+require 'tk'
+require 'tkextlib/tcllib/plotchart'
+
+TkCanvas.new(:background=>'white', :width=>400, :height=>200){|c|
+ pack(:fill=>:both)
+ Tk::Tcllib::Plotchart::XYPlot.new(c, [0.0, 100.0, 10.0],
+ [0.0, 100.0, 20.0]){
+ [ [0.0, 32.0], [10.0, 50.0], [25.0, 60.0], [78.0, 11.0] ].each{|x, y|
+ plot('series1', x, y)
+ }
+ title("Data series")
+ }
+}
+
+Tk.mainloop
diff --git a/jni/ruby/ext/tk/sample/tkextlib/tile/Orig_LICENSE.txt b/jni/ruby/ext/tk/sample/tkextlib/tile/Orig_LICENSE.txt
new file mode 100644
index 0000000..2326ef2
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkextlib/tile/Orig_LICENSE.txt
@@ -0,0 +1,30 @@
+
+ ######################################################################
+ ### The following text is the original 'license.terms' of tile ###
+ ### extension. ###
+ ######################################################################
+
+
+LICENSE ("MIT-style")
+
+This software is Copyright (C) 2003 Joe English and other parties.
+
+The following terms apply to all files associated with this software
+unless explicitly disclaimed in individual files.
+
+The author(s) hereby grant permission to use, copy, modify, distribute,
+and license this software and its documentation for any purpose, provided
+that existing copyright notices are retained in all copies and that this
+notice is included in any distributions. No written agreement,
+license, or royalty fee is required for any of the authorized uses.
+Modifications to this software may be copyrighted by their authors
+and need not follow the licensing terms described here, provided that
+the new terms are clearly indicated on the first page of each file where
+they apply.
+
+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. IN NO EVENT
+shall the AUTHORS of THIS SOFTWARE be LIABLE to ANY PARTY for
+DIRECT, INDIRECT, SPECIAL, INCIDENTAL, or CONSEQUENTIAL DAMAGES
+arising out of the USE of THIS SOFTWARE and its DOCUMENTATION.
diff --git a/jni/ruby/ext/tk/sample/tkextlib/tile/demo.rb b/jni/ruby/ext/tk/sample/tkextlib/tile/demo.rb
new file mode 100644
index 0000000..260ca00
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkextlib/tile/demo.rb
@@ -0,0 +1,983 @@
+#!/usr/bin/env ruby
+#
+# Demo for 'tile' package.
+#
+require 'tk'
+
+demodir = File.dirname($0)
+themesdir = File.join(demodir, 'themes')
+Tk::AUTO_PATH.lappend('.', demodir, themesdir)
+
+Dir.foreach(themesdir){|name|
+ next if name == '.' || name == '..'
+ dir = File.join(themesdir, name)
+ Tk::AUTO_PATH.lappend(dir) if File.directory?(dir)
+}
+
+require 'tkextlib/tile'
+
+def version?(ver)
+ TkPackage.vcompare(Tk::Tile.package_version, ver) >= 0
+end
+
+# define Tcl/Tk procedures for compatibility
+Tk::Tile.__define_LoadImages_proc_for_compatibility__!
+Tk::Tile::Style.__define_wrapper_proc_for_compatibility__!
+
+unless Tk::Tile::Style.theme_names.include?('step')
+ Tk::Tile::Style.theme_create('step')
+end
+
+Tk.load_tclscript(File.join(demodir, 'toolbutton.tcl'))
+Tk.load_tclscript(File.join(demodir, 'repeater.tcl'))
+
+# This forces an update of the available packages list. It's required
+# for package names to find the themes in demos/themes/*.tcl
+## Tk.tk_call(TkPackage.unknown_proc, 'Tcl', TkPackage.provide('Tcl'))
+## --> This doesn't work.
+## Because, unknown_proc may be "command + some arguments".
+Tk.ip_eval("#{TkPackage.unknown_proc} Tcl #{TkPackage.provide('Tcl')}")
+
+TkRoot.new{
+ title 'Tile demo'
+ iconname 'Tile demo'
+}
+
+# The descriptive names of the builtin themes.
+$THEMELIST = [
+ ['default', 'Default'],
+ ['classic', 'Classic'],
+ ['alt', 'Revitalized'],
+ ['winnative', 'Windows native'],
+ ['xpnative', 'XP Native'],
+ ['aqua', 'Aqua'],
+]
+
+$V = TkVariable.new_hash(:THEME => 'default',
+ :COMPOUND => 'top',
+ :CONSOLE => false,
+ :MENURADIO1 => 'One',
+ :MENUCHECK1 => true,
+ :PBMODE => 'determinate',
+ :SELECTED => true,
+ :CHOICE => 2)
+
+# Add in any available loadable themes.
+TkPackage.names.find_all{|n| n =~ /^(tile|ttk)::theme::/}.each{|pkg|
+ name = pkg.split('::')[-1]
+ unless $THEMELIST.assoc(name)
+ $THEMELIST << [name, Tk.tk_call('string', 'totitle', name)]
+ end
+}
+
+# Add theme definition written by ruby
+$RUBY_THEMELIST = []
+begin
+ load(File.join(demodir, 'themes', 'kroc.rb'), true)
+rescue => e
+raise e
+ $RUBY_THEMELIST << ['kroc-rb', 'Kroc (by Ruby)', false]
+else
+ $RUBY_THEMELIST << ['kroc-rb', 'Kroc (by Ruby)', true]
+end
+
+def makeThemeControl(parent)
+ c = Tk::Tile::Labelframe.new(parent, :text=>'Theme')
+ $THEMELIST.each{|theme, name|
+ b = Tk::Tile::Radiobutton.new(c, :text=>name, :value=>theme,
+ :variable=>$V.ref(:THEME),
+ :command=>proc{setTheme(theme)})
+ b.grid(:sticky=>:ew)
+ unless (TkPackage.names.find{|n| n =~ /(tile|ttk)::theme::#{theme}/})
+ b.ttk_state(:disabled)
+ end
+ }
+ $RUBY_THEMELIST.each{|theme, name, available|
+ b = Tk::Tile::Radiobutton.new(c, :text=>name, :value=>theme,
+ :variable=>$V.ref(:THEME),
+ :command=>proc{setTheme(theme)})
+ b.grid(:sticky=>:ew)
+ b.ttk_state(:disabled) unless available
+ }
+ c
+end
+
+def makeThemeMenu(parent)
+ m = TkMenu.new(parent)
+ $THEMELIST.each{|theme, name|
+ m.add(:radiobutton, :label=>name, :variable=>$V.ref(:THEME),
+ :value=>theme, :command=>proc{setTheme(theme)})
+ unless (TkPackage.names.find{|n| n =~ /(tile|ttk)::theme::#{theme}/})
+ m.entryconfigure(:end, :state=>:disabled)
+ end
+ }
+ $RUBY_THEMELIST.each{|theme, name, available|
+ m.add(:radiobutton, :label=>name, :variable=>$V.ref(:THEME),
+ :value=>theme, :command=>proc{setTheme(theme)})
+ m.entryconfigure(:end, :state=>:disabled) unless available
+ }
+ m
+end
+
+def setTheme(theme)
+ if (pkg = TkPackage.names.find{|n| n =~ /(tile|ttk)::theme::#{theme}/})
+ unless Tk::Tile::Style.theme_names.find{|n| n == theme}
+ TkPackage.require(pkg)
+ end
+ end
+ Tk::Tile::Style.theme_use(theme)
+end
+
+#
+# Load icons...
+#
+$BUTTONS = ['open', 'new', 'save']
+$CHECKBOXES = ['bold', 'italic']
+$ICON = {}
+
+def loadIcons(file)
+ Tk.load_tclscript(file)
+ img_data = TkVarAccess.new('ImgData')
+ img_data.keys.each{|icon|
+ $ICON[icon] = TkPhotoImage.new(:data=>img_data[icon])
+ }
+end
+
+loadIcons(File.join(demodir, 'iconlib.tcl'))
+
+#
+# Utilities:
+#
+def foreachWidget(wins, cmd)
+ wins.each{|w|
+ cmd.call(w)
+ foreachWidget(w.winfo_children, cmd)
+ }
+end
+
+# sbstub
+# Used as the :command option for a scrollbar,
+# updates the scrollbar's position.
+#
+def sbstub(sb, cmd, num, units = 'units')
+ num = TkComm.number(num)
+ case cmd.to_s
+ when 'moveto'
+ sb.set(num, num+0.5)
+
+ when 'scroll'
+ if units.to_s == 'pages'
+ delta = 0.2
+ else
+ delta = 0.05
+ end
+ current = sb.get
+ sb.set(current[0] + delta * num, current[1] + delta * num)
+ end
+end
+
+# ... for debugging:
+TkBindTag::ALL.bind('ButtonPress-3', proc{|w| $W = w}, '%W')
+TkBindTag::ALL.bind('Control-ButtonPress-3', proc{|w| w.set_focus}, '%W')
+
+def showHelp()
+ Tk.messageBox(:message=>'No help yet...')
+end
+
+#
+# See toolbutton.tcl.
+TkOption.add('*Toolbar.relief', :groove)
+TkOption.add('*Toolbar.borderWidth', 2)
+
+TkOption.add('*Toolbar.Button.Pad', 2)
+
+$ROOT = Tk.root
+$BASE = $ROOT
+Tk.destroy(*($ROOT.winfo_children))
+
+$TOOLBARS = []
+
+#
+# Toolbar button standard vs. tile comparison:
+#
+def makeToolbars
+ #
+ # Tile toolbar:
+ #
+ tb = Tk::Tile::Frame.new($BASE, :class=>'Toolbar')
+ $TOOLBARS << tb
+ i = 0
+ $BUTTONS.each{|icon|
+ i += 1
+ Tk::Tile::Button.new(tb, :text=>icon, :image=>$ICON[icon],
+ :compound=>$V[:COMPOUND],
+ :style=>:Toolbutton).grid(:row=>0, :column=>i,
+ :sticky=>:news)
+ }
+ $CHECKBOXES.each{|icon|
+ i += 1
+ Tk::Tile::Checkbutton.new(tb, :text=>icon, :image=>$ICON[icon],
+ :variable=>$V.ref(icon),
+ :compound=>$V[:COMPOUND],
+ :style=>:Toolbutton).grid(:row=>0, :column=>i,
+ :sticky=>:news)
+ }
+
+ mb = Tk::Tile::Menubutton.new(tb, :text=>'toolbar', :image=>$ICON['file'],
+ :compound=>$V[:COMPOUND])
+ mb.configure(:menu=>makeCompoundMenu(mb))
+ i += 1
+ mb.grid(:row=>0, :column=>i, :sticky=>:news)
+
+ i += 1
+ tb.grid_columnconfigure(i, :weight=>1)
+
+ #
+ # Standard toolbar:
+ #
+ tb = TkFrame.new($BASE, :class=>'Toolbar')
+ $TOOLBARS << tb
+ i = 0
+ $BUTTONS.each{|icon|
+ i += 1
+ TkButton.new(tb, :text=>icon, :image=>$ICON[icon],
+ :compound=>$V[:COMPOUND], :relief=>:flat,
+ :overrelief=>:raised).grid(:row=>0, :column=>i,
+ :sticky=>:news)
+ }
+ $CHECKBOXES.each{|icon|
+ i += 1
+ TkCheckbutton.new(tb, :text=>icon, :image=>$ICON[icon],
+ :variable=>$V.ref(icon), :compound=>$V[:COMPOUND],
+ :indicatoron=>false, :selectcolor=>'', :relief=>:flat,
+ :overrelief=>:raised).grid(:row=>0, :column=>i,
+ :sticky=>:news)
+ }
+
+ mb = TkMenubutton.new(tb, :text=>'toolbar', :image=>$ICON['file'],
+ :compound=>$V[:COMPOUND])
+ mb.configure(:menu=>makeCompoundMenu(mb))
+ i += 1
+ mb.grid(:row=>0, :column=>i, :sticky=>:news)
+
+ i += 1
+ tb.grid_columnconfigure(i, :weight=>1)
+end
+
+#
+# Toolbar :compound control:
+#
+def makeCompoundMenu(mb)
+ menu = TkMenu.new(mb)
+ %w(text image none top bottom left right center).each{|str|
+ menu.add(:radiobutton, :label=>Tk.tk_call('string', 'totitle', str),
+ :variable=>$V.ref(:COMPOUND), :value=>str,
+ :command=>proc{ changeToolbars() })
+ }
+ menu
+end
+
+makeToolbars()
+
+## CONTROLS
+control = Tk::Tile::Frame.new($BASE)
+
+#
+# Overall theme control:
+#
+makeThemeControl(control).grid(:sticky=>:news, :padx=>6, :ipadx=>6)
+control.grid_rowconfigure(99, :weight=>1)
+
+def changeToolbars
+ foreachWidget($TOOLBARS,
+ proc{|w|
+ begin
+ w.compound($V[:COMPOUND])
+ rescue
+ end
+ })
+end
+
+def scrolledWidget(parent, klass, themed, *args)
+ if themed
+ f = Tk::Tile::Frame.new(parent)
+ t = klass.new(f, *args)
+ vs = Tk::Tile::Scrollbar.new(f)
+ hs = Tk::Tile::Scrollbar.new(f)
+ else
+ f = TkFrame.new(parent)
+ t = klass.new(f, *args)
+ vs = TkScrollbar.new(f)
+ hs = TkScrollbar.new(f)
+ end
+ t.yscrollbar(vs)
+ t.xscrollbar(hs)
+
+ TkGrid.configure(t, vs, :sticky=>:news)
+ TkGrid.configure(hs, 'x', :sticky=>:news)
+ TkGrid.rowconfigure(f, 0, :weight=>1)
+ TkGrid.columnconfigure(f, 0, :weight=>1)
+
+ [f, t]
+end
+
+#
+# Notebook demonstration:
+#
+def makeNotebook
+ nb = Tk::Tile::Notebook.new($BASE, :padding=>6)
+ nb.enable_traversal
+ client = Tk::Tile::Frame.new(nb)
+ nb.add(client, :text=>'Demo', :underline=>0)
+ nb.select(client)
+
+ scales = Tk::Tile::Frame.new(nb)
+ nb.add(scales, :text=>'Scales')
+ combo = Tk::Tile::Frame.new(nb)
+ nb.add(combo, :text=>'Combobox', :underline=>7)
+ tree = Tk::Tile::Frame.new(nb)
+ nb.add(tree, :text=>'Tree')
+ others = Tk::Tile::Frame.new(nb)
+ nb.add(others, :text=>'Others', :underline=>4)
+
+ [nb, client, scales, combo, tree, others]
+end
+
+nb, client, scales, combo, tree, others = makeNotebook()
+
+#
+# Side-by side check, radio, and menu button comparison:
+#
+def fillMenu(menu)
+ %w(above below left right flush).each{|dir|
+ menu.add(:command, :label=>Tk.tk_call('string', 'totitle', dir),
+ :command=>proc{ menu.winfo_parent.direction(dir) })
+ }
+ menu.add(:cascade, :label=>'Submenu', :menu=>(submenu = TkMenu.new(menu)))
+ submenu.add(:command, :label=>'Subcommand 1')
+ submenu.add(:command, :label=>'Subcommand 2')
+ submenu.add(:command, :label=>'Subcommand 3')
+
+ menu.add(:separator)
+ menu.add(:command, :label=>'Quit', :command=>proc{Tk.root.destroy})
+end
+
+l = Tk::Tile::Labelframe.new(client, :text=>'Themed', :padding=>6)
+r = TkLabelframe.new(client, :text=>'Standard', :padx=>6, :pady=>6)
+
+## Styled frame
+cb = Tk::Tile::Checkbutton.new(l, :text=>'Checkbutton',
+ :variable=>$V.ref(:SELECTED), :underline=>2)
+rb1 = Tk::Tile::Radiobutton.new(l, :text=>'One', :variable=>$V.ref(:CHOICE),
+ :value=>1, :underline=>0)
+rb2 = Tk::Tile::Radiobutton.new(l, :text=>'Two', :variable=>$V.ref(:CHOICE),
+ :value=>2)
+rb3 = Tk::Tile::Radiobutton.new(l, :text=>'Three',
+ :variable=>$V.ref(:CHOICE),
+ :value=>3, :underline=>0)
+btn = Tk::Tile::Button.new(l, :text=>'Button', :underline=>0)
+
+mb = Tk::Tile::Menubutton.new(l, :text=>'Menubutton', :underline=>2)
+m = TkMenu.new(mb)
+mb.menu(m)
+fillMenu(m)
+
+$entryText = TkVariable.new('Entry widget')
+e = Tk::Tile::Entry.new(l, :textvariable=>$entryText)
+e.selection_range(6, :end)
+
+ltext_f, ltext = scrolledWidget(l, TkText, true,
+ :width=>12, :height=>5, :wrap=>:none)
+# NOTE TO MAINTAINERS:
+# The checkbuttons are -sticky ew / -expand x on purpose:
+# it demonstrates one of the differences between TCheckbuttons
+# and standard checkbuttons.
+#
+Tk.grid(cb, :sticky=>:ew)
+Tk.grid(rb1, :sticky=>:ew)
+Tk.grid(rb2, :sticky=>:ew)
+Tk.grid(rb3, :sticky=>:ew)
+Tk.grid(btn, :sticky=>:ew, :padx=>2, :pady=>2)
+Tk.grid(mb, :sticky=>:ew, :padx=>2, :pady=>2)
+Tk.grid(e, :sticky=>:ew, :padx=>2, :pady=>2)
+Tk.grid(ltext_f, :sticky=>:news)
+
+TkGrid.columnconfigure(l, 0, :weight=>1)
+TkGrid.rowconfigure(l, 7, :weight=>1) # text widget (grid is a PITA)
+
+## Orig frame
+cb = TkCheckbutton.new(r, :text=>'Checkbutton', :variable=>$V.ref(:SELECTED))
+rb1 = TkRadiobutton.new(r, :text=>'One',
+ :variable=>$V.ref(:CHOICE), :value=>1)
+rb2 = TkRadiobutton.new(r, :text=>'Two', :variable=>$V.ref(:CHOICE),
+ :value=>2, :underline=>1)
+rb3 = TkRadiobutton.new(r, :text=>'Three',
+ :variable=>$V.ref(:CHOICE), :value=>3)
+btn = TkButton.new(r, :text=>'Button')
+
+mb = TkMenubutton.new(r, :text=>'Menubutton', :underline=>3, :takefocus=>true)
+m = TkMenu.new(mb)
+mb.menu(m)
+$V[:rmbIndicatoron] = mb.indicatoron
+m.add(:checkbutton, :label=>'Indicator?', #'
+ :variable=>$V.ref(:rmbIndicatoron),
+ :command=>proc{mb.indicatoron($V[:rmbIndicatoron])})
+m.add(:separator)
+fillMenu(m)
+
+e = TkEntry.new(r, :textvariable=>$entryText)
+
+rtext_f, rtext = scrolledWidget(r, TkText, false,
+ :width=>12, :height=>5, :wrap=>:none)
+
+Tk.grid(cb, :sticky=>:ew)
+Tk.grid(rb1, :sticky=>:ew)
+Tk.grid(rb2, :sticky=>:ew)
+Tk.grid(rb3, :sticky=>:ew)
+Tk.grid(btn, :sticky=>:ew, :padx=>2, :pady=>2)
+Tk.grid(mb, :sticky=>:ew, :padx=>2, :pady=>2)
+Tk.grid(e, :sticky=>:ew, :padx=>2, :pady=>2)
+Tk.grid(rtext_f, :sticky=>:news)
+
+TkGrid.columnconfigure(l, 0, :weight=>1)
+TkGrid.rowconfigure(l, 7, :weight=>1) # text widget (grid is a PITA)
+
+Tk.grid(l, r, :sticky=>:news, :padx=>6, :pady=>6)
+TkGrid.rowconfigure(client, 0, :weight=>1)
+TkGrid.columnconfigure(client, [0, 1], :weight=>1)
+
+#
+# Add some text to the text boxes:
+#
+msgs = [
+"The cat crept into the crypt, crapped and crept out again",
+"Peter Piper picked a peck of pickled peppers",
+"How much wood would a woodchuck chuck if a woodchuck could chuck wood",
+"He thrusts his fists against the posts and still insists he sees the ghosts",
+"Who put the bomb in the bom-b-bom-b-bom,",
+"Is this your sister's sixth zither, sir?",
+"Who put the ram in the ramalamadingdong?",
+"I am not the pheasant plucker, I'm the pheasant plucker's mate."
+]
+
+nmsgs = msgs.size
+(0...50).each{|n|
+ msg = msgs[n % nmsgs]
+ ltext.insert(:end, "#{n}: #{msg}\n")
+ rtext.insert(:end, "#{n}: #{msg}\n")
+}
+#
+# Scales and sliders pane:
+#
+l = Tk::Tile::Labelframe.new(scales, :text=>'Themed', :padding=>6)
+r = TkLabelframe.new(scales, :text=>'Standard', :padx=>6, :pady=>6)
+
+if version?('0.6')
+
+ # thremed frame
+ scale = Tk::Tile::Scale.new(l, :orient=>:horizontal, :from=>0, :to=>100,
+ :variable=>$V.ref(:SCALE))
+ vscale = Tk::Tile::Scale.new(l, :orient=>:vertical, :from=>0, :to=>100,
+ :variable=>$V.ref(:VSCALE))
+ progress = Tk::Tile::Progressbar.new(l, :orient=>:horizontal, :maximum=>100)
+ vprogress = Tk::Tile::Progressbar.new(l, :orient=>:vertical, :maximum=>100)
+
+ if true
+ def progress.inverted(w, value)
+ if w.mode == 'indeterminate'
+ w.value(value)
+ else
+ w.value(w.maximum - value)
+ end
+ end
+ scale.command {|value| progress.value(value)}
+ vscale.command {|value| progress.inverted(vprogress, value) }
+ else
+ # This would also work, but the Tk scale widgets
+ # in the right hand pane cause some interference when
+ # in autoincrement/indeterminate mode.
+ #
+ progress.variable $V.ref(:SCALE)
+ vprogress.variable $V.ref(:VSCALE)
+ end
+
+ scale.set(50)
+ vscale.set(50)
+
+ lmode = Tk::Tile::Label.new(l, :text=>'Progress bar mode')
+ pbmode0 = Tk::Tile::Radiobutton.new(l, :variable=>$V.ref(:PBMODE),
+ :text=>'determinate', :value=>'determinate',
+ :command=>proc{pbMode(progress, vprogress)})
+ pbmode1 = Tk::Tile::Radiobutton.new(l, :variable=>$V.ref(:PBMODE),
+ :text=>'indeterminate', :value=>'indeterminate',
+ :command=>proc{pbMode(progress, vprogress)})
+ def pbMode(progress, vprogress)
+ if vprogress.mode != $V[:PBMODE]
+ vprogress.value(vprogress.maximum - vprogress.value)
+ end
+
+ progress.mode $V[:PBMODE]
+ vprogress.mode $V[:PBMODE]
+ end
+
+ start = Tk::Tile::Button.new(l, :text=>"Start",
+ :command=>proc{pbStart(progress, vprogress)})
+ def pbStart(progress, vprogress)
+ # $V[:PBMODE] = 'indeterminate'
+ pbMode(progress, vprogress)
+ progress.start 10
+ vprogress.start
+ end
+
+ stop = Tk::Tile::Button.new(l, :text=>'Stop',
+ :command=>proc{pbStop(progress, vprogress)})
+ def pbStop(progress, vprogress)
+ progress.stop
+ vprogress.stop
+ end
+
+ Tk.grid(scale, :columnspan=>2, :sticky=>'ew')
+ Tk.grid(progress, :columnspan=>2, :sticky=>'ew')
+ Tk.grid(vscale, vprogress, :sticky=>'nws')
+
+ Tk.grid(lmode, :sticky=>'we', :columnspan=>2)
+ Tk.grid(pbmode0, :sticky=>'we', :columnspan=>2)
+ Tk.grid(pbmode1, :sticky=>'we', :columnspan=>2)
+ Tk.grid(start, :sticky=>'we', :columnspan=>2)
+ Tk.grid(stop, :sticky=>'we', :columnspan=>2)
+
+ l.grid_columnconfigure(0, :weight=>1)
+ l.grid_columnconfigure(1, :weight=>1)
+ l.grid_rowconfigure(99, :weight=>1)
+
+ # standard frame
+ TkScale.new(r, :orient=>:horizontal, :from=>0, :to=>100,
+ :variable=>$V.ref(:SCALE)).grid(:sticky=>'news')
+ TkScale.new(r, :orient=>:vertical, :from=>0, :to=>100,
+ :variable=>$V.ref(:VSCALE)).grid(:sticky=>'nws')
+
+ r.grid_columnconfigure(0, :weight=>1)
+ r.grid_columnconfigure(1, :weight=>1)
+ r.grid_rowconfigure(99, :weight=>1)
+
+else # tile 0.5 or earlier
+
+ # themed frame
+ scale = Tk::Tile::Scale.new(l, :variable=>$V.ref(:SCALE),
+ :orient=>:horizontal, :from=>0, :to=>100)
+ vscale = Tk::Tile::Scale.new(l, :variable=>$V.ref(:VSCALE),
+ :orient=>:vertical, :from=>-25, :to=>25)
+
+ progress = Tk::Tile::Progress.new(l,
+ :orient=>:horizontal, :from=>0, :to=>100)
+ vprogress = Tk::Tile::Progress.new(l,
+ :orient=>:vertical, :from=>-25, :to=>25)
+
+ if true
+ scale.command{|value| progress.set(value)}
+ vscale.command{|value| vprogress.set(value)}
+ else # this would also work. (via TkVariable#trace)
+ v1 = scale.variable
+ v2 = vscale.variable
+ v1.trace('w', proc{ progress.set(v1.value) })
+ v2.trace('w', proc{ vprogress.set(v2.value) })
+ end
+
+ Tk.grid(scale, :columnspan=>2, :sticky=>:ew)
+ Tk.grid(progress, :columnspan=>2, :sticky=>:ew)
+ Tk.grid(vscale, vprogress, :sticky=>:nws)
+ TkGrid.columnconfigure(l, 0, :weight=>1)
+ TkGrid.columnconfigure(l, 1, :weight=>1)
+
+ # standard frame
+ TkScale.new(r, :variable=>$V.ref(:SCALE),
+ :orient=>:horizontal, :from=>0, :to=>100).grid(:sticky=>'news')
+ TkScale.new(r, :variable=>$V.ref(:VSCALE),
+ :orient=>:vertical, :from=>-25, :to=>25).grid(:sticky=>'nws')
+
+ TkGrid.columnconfigure(r, 0, :weight=>1)
+ TkGrid.columnconfigure(r, 1, :weight=>1)
+end
+
+# layout frames
+Tk.grid(l, r, :sticky=>'nwes', :padx=>6, :pady=>6)
+scales.grid_columnconfigure(0, :weight=>1)
+scales.grid_columnconfigure(1, :weight=>1)
+scales.grid_rowconfigure(0, :weight=>1)
+
+#
+# Command box:
+#
+cmd = Tk::Tile::Frame.new($BASE)
+b_close = Tk::Tile::Button.new(cmd, :text=>'Close',
+ :underline=>0, :default=>:normal,
+ :command=>proc{Tk.root.destroy})
+b_help = Tk::Tile::Button.new(cmd, :text=>'Help', :underline=>0,
+ :default=>:normal, :command=>proc{showHelp()})
+Tk.grid('x', b_close, b_help, :pady=>[6, 4], :padx=>4)
+TkGrid.columnconfigure(cmd, 0, :weight=>1)
+
+#
+# Set up accelerators:
+#
+$ROOT.bind('KeyPress-Escape', proc{Tk.event_generate(b_close, '<Invoke>')})
+$ROOT.bind('<Help>', proc{Tk.event_generate(b_help, '<Invoke>')})
+Tk::Tile::KeyNav.enableMnemonics($ROOT)
+Tk::Tile::KeyNav.defaultButton(b_help)
+
+Tk.grid($TOOLBARS[0], '-', :sticky=>:ew)
+Tk.grid($TOOLBARS[1], '-', :sticky=>:ew)
+Tk.grid(control, nb, :sticky=>:news)
+Tk.grid(cmd, '-', :sticky=>:ew)
+TkGrid.columnconfigure($ROOT, 1, :weight=>1)
+TkGrid.rowconfigure($ROOT, 2, :weight=>1)
+
+#
+# Add a menu
+#
+menu = TkMenu.new($BASE)
+$ROOT.menu(menu)
+m_file = TkMenu.new(menu, :tearoff=>0)
+menu.add(:cascade, :label=>'File', :underline=>0, :menu=>m_file)
+m_file.add(:command, :label=>'Open', :underline=>0,
+ :compound=>:left, :image=>$ICON['open'])
+m_file.add(:command, :label=>'Save', :underline=>0,
+ :compound=>:left, :image=>$ICON['save'])
+m_file.add(:separator)
+m_f_test = TkMenu.new(menu, :tearoff=>0)
+m_file.add(:cascade, :label=>'Test submenu', :underline=>0, :menu=>m_f_test)
+m_file.add(:checkbutton, :label=>'Text check', :underline=>5,
+ :variable=>$V.ref(:MENUCHECK1))
+m_file.insert(:end, :separator)
+
+if Tk.windowingsystem != 'x11'
+ TkConsole.create
+ m_file.insert(:end, :checkbutton, :label=>'Console', :underline=>5,
+ :variable=>$V.ref(:CONSOLE), :command=>proc{toggle_console()})
+ def toggle_console
+ if TkComm.bool($V[:CONSOLE])
+ TkConsole.show
+ else
+ TkConsole.hide
+ end
+ end
+end
+
+m_file.add(:command, :label=>'Exit', :underline=>1,
+ :command=>proc{Tk.event_generate(b_close, '<Invoke>')})
+
+%w(One Two Three Four).each{|lbl|
+ m_f_test.add(:radiobutton, :label=>lbl, :variable=>$V.ref(:MENURADIO1))
+}
+
+# Add Theme menu.
+#
+menu.add(:cascade, :label=>'Theme', :underline=>3,
+ :menu=>makeThemeMenu(menu))
+
+setTheme($V[:THEME])
+
+#
+# Combobox demo pane:
+#
+values = %w(list abc def ghi jkl mno pqr stu vwx yz)
+2.times {|i|
+ cb = Tk::Tile::Combobox.new(
+ combo, :values=>values, :textvariable=>$V.ref(:COMBO))
+ cb.pack(:side=>:top, :padx=>2, :pady=>2, :expand=>false, :fill=>:x)
+ if i == 1
+ cb.ttk_state :readonly
+ begin
+ cb.current = 3 # ignore if unsupported (tile0.4)
+ rescue
+ end
+ end
+}
+
+#
+# Treeview widget demo pane:
+#
+if version?('0.5')
+
+ treeview = nil # avoid 'undefined' error
+ scrollbar = Tk::Tile::Scrollbar.new(tree,
+ :command=>proc{|*args| treeview.yview(*args)})
+ treeview = Tk::Tile::Treeview.new(tree, :columns=>%w(Class), :padding=>4,
+ :yscrollcommand=>proc{|*args| scrollbar.set(*args)})
+
+ Tk.grid(treeview, scrollbar, :sticky=>'news')
+ tree.grid_columnconfigure(0, :weight=>1)
+ tree.grid_rowconfigure(0, :weight=>1)
+ tree.grid_propagate(0)
+
+ # Add initial tree node:
+ # Later nodes will be added in <<TreeviewOpen>> binding.
+ treeview.insert('', 0, :id=>'.', :text=>'Main Window', :open=>false,
+ :values=>[TkWinfo.classname('.')])
+ treeview.headingconfigure('#0', :text=>'Widget')
+ treeview.headingconfigure('Class', :text=>'Class')
+ treeview.bind('<TreeviewOpen>', proc{fillTree(treeview)})
+
+ def fillTree(treeview)
+ id = treeview.focus_item
+ unless TkWinfo.exist?(id)
+ treeview.delete(id)
+ end
+ # Replace tree item children with current list of child windows.
+ treeview.delete(treeview.children(id))
+ for child in TkWinfo.children(id)
+ treeview.insert(id, :end, :id=>child, :text=>TkWinfo.appname(child),
+ :open=>false, :values=>[TkWinfo.classname(child)])
+ unless TkWinfo.children(child).empty?
+ # insert dummy child to show [+] indicator
+ treeview.insert(child, :end)
+ end
+ end
+ end
+
+else
+ Tk::Tile::Label.new(tree,
+ :text=>'Treeview is supported on tile 0.5 or later...').pack
+end
+
+#
+# Other demos:
+#
+$Timers = {:StateMonitor=>nil, :FocusMonitor=>nil}
+
+begin
+ msg = Tk::Tile::Label.new(others, :justify=>:left, :wraplength=>300)
+rescue
+ msg = TkMessage.new(others, :aspect=>200)
+end
+
+$Desc = {}
+
+showDescription = TkBindTag.new
+showDescription.bind('Enter', proc{|w| msg.text($Desc[w.path])}, '%W')
+showDescription.bind('Leave', proc{|w| msg.text('')}, '%W')
+
+[
+ [ :trackStates, "Widget states...",
+ "Display/modify widget state bits" ],
+
+ [ :scrollbarResizeDemo, "Scrollbar resize behavior...",
+ "Shows how Tile and standard scrollbars differ when they're sized too large" ],
+
+ [ :trackFocus, "Track keyboard focus..." ,
+ "Display the name of the widget that currently has focus" ],
+
+ [ :repeatDemo, "Repeating buttons...",
+ "Demonstrates custom classes (see demos/repeater.tcl)" ]
+
+].each{|demo_cmd, label, description|
+ b = Tk::Tile::Button.new(others, :text=>label,
+ :command=>proc{ self.__send__(demo_cmd) })
+ $Desc[b.path] = description
+ b.bindtags <<= showDescription
+
+ b.pack(:side=>:top, :expand=>false, :fill=>:x, :padx=>6, :pady=>6)
+}
+
+msg.pack(:side=>:bottom, :expand=>true, :fill=>:both)
+
+
+#
+# Scrollbar resize demo:
+#
+$scrollbars = nil
+
+def scrollbarResizeDemo
+ if $scrollbars
+ begin
+ $scrollbars.destroy
+ rescue
+ end
+ end
+ $scrollbars = TkToplevel.new(:title=>'Scrollbars', :geometry=>'200x200')
+ f = TkFrame.new($scrollbars, :height=>200)
+ tsb = Tk::Tile::Scrollbar.new(f, :command=>proc{|*args| sbstub(tsb, *args)})
+ sb = TkScrollbar.new(f, :command=>proc{|*args| sbstub(sb, *args)})
+ Tk.grid(tsb, sb, :sticky=>:news)
+
+ sb.set(0, 0.5) # prevent backwards-compatibility mode for old SB
+
+ f.grid_columnconfigure(0, :weight=>1)
+ f.grid_columnconfigure(1, :weight=>1)
+ f.grid_rowconfigure(0, :weight=>1)
+
+ f.pack(:expand=>true, :fill=>:both)
+end
+
+#
+# Track focus demo:
+#
+$FocusInf = TkVariable.new_hash
+$focus = nil
+
+def trackFocus
+ if $focus
+ begin
+ $focus.destroy
+ rescue
+ end
+ end
+ $focus = TkToplevel.new(:title=>'Keyboard focus')
+ i = 0
+ [
+ ["Focus widget:", :Widget],
+ ["Class:", :WidgetClass],
+ ["Next:", :WidgetNext],
+ ["Grab:", :Grab],
+ ["Status:", :GrabStatus]
+ ].each{|label, var_index|
+ Tk.grid(Tk::Tile::Label.new($focus, :text=>label, :anchor=>:e),
+ Tk::Tile::Label.new($focus,
+ :textvariable=>$FocusInf.ref(var_index),
+ :width=>40, :anchor=>:w, :relief=>:groove),
+ :sticky=>:ew)
+ i += 1
+ }
+ $focus.grid_columnconfigure(1, :weight=>1)
+ $focus.grid_rowconfigure(i, :weight=>1)
+
+ $focus.bind('Destroy', proc{Tk.after_cancel($Timers[:FocusMonitor])})
+ focusMonitor
+end
+
+def focusMonitor
+ $FocusInf[:Widget] = focus_win = Tk.focus
+ if focus_win
+ $FocusInf[:WidgetClass] = focus_win.winfo_classname
+ $FocusInf[:WidgetNext] = Tk.focus_next(focus_win)
+ else
+ $FocusInf[:WidgetClass] = $FocusInf[:WidgetNext] = ''
+ end
+
+ $FocusInf[:Grab] = grab_wins = Tk.current_grabs
+ unless grab_wins.empty?
+ $FocusInf[:GrabStatus] = grab_wins[0].grab_status
+ else
+ $FocusInf[:GrabStatus] = ''
+ end
+
+ $Timers[:FocusMonitor] = Tk.after(200, proc{ focusMonitor() })
+end
+
+#
+# Widget state demo:
+#
+$Widget = TkVariable.new
+
+TkBindTag::ALL.bind('Control-Shift-ButtonPress-1',
+ proc{|w|
+ $Widget.value = w
+ updateStates()
+ Tk.callback_break
+ }, '%W')
+$states_list = %w(active disabled focus pressed selected
+ background indeterminate invalid default)
+$states_btns = {}
+$states = nil
+
+$State = TkVariable.new_hash
+
+def trackStates
+ if $states
+ begin
+ $state.destroy
+ rescue
+ end
+ end
+ $states = TkToplevel.new(:title=>'Widget states')
+
+ l_inf = Tk::Tile::Label.new($states, :text=>"Press Control-Shift-Button-1 on any widget")
+
+ l_lw = Tk::Tile::Label.new($states, :text=>'Widget:',
+ :anchor=>:e, :relief=>:groove)
+ l_w = Tk::Tile::Label.new($states, :textvariable=>$Widget,
+ :anchor=>:w, :relief=>:groove)
+
+ Tk.grid(l_inf, '-', :sticky=>:ew, :padx=>6, :pady=>6)
+ Tk.grid(l_lw, l_w, :sticky=>:ew)
+
+ $states_list.each{|st|
+ cb = Tk::Tile::Checkbutton.new($states, :text=>st,
+ :variable=>$State.ref(st),
+ :command=>proc{ changeState(st) })
+ $states_btns[st] = cb
+ Tk.grid('x', cb, :sticky=>:nsew)
+ }
+
+ $states.grid_columnconfigure(1, :weight=>1)
+
+ f_cmd = Tk::Tile::Frame.new($states)
+ Tk.grid('x', f_cmd, :sticky=>:nse)
+
+ b_close = Tk::Tile::Button.new(f_cmd, :text=>'Close',
+ :command=>proc{ $states.destroy })
+ Tk.grid('x', b_close, :padx=>4, :pady=>[6,4])
+ f_cmd.grid_columnconfigure(0, :weight=>1)
+
+ $states.bind('KeyPress-Escape', proc{Tk.event_generate(b_close, '<Invoke>')})
+
+ $states.bind('Destroy', proc{Tk.after_cancel($Timers[:StateMonitor])})
+ stateMonitor()
+end
+
+def stateMonitor
+ updateStates() if $Widget.value != ''
+ $Timers[:StateMonitor] = Tk.after(200, proc{ stateMonitor() })
+end
+
+def updateStates
+ $states_list.each{|st|
+ begin
+ $State[st] = $Widget.window.ttk_instate(st)
+ rescue
+ $states_btns[st].ttk_state('disabled')
+ else
+ $states_btns[st].ttk_state('!disabled')
+ end
+ }
+end
+
+def changeState(st)
+ if $Widget.value != ''
+ if $State.bool_element(st)
+ $Widget.window.ttk_state(st)
+ else
+ $Widget.window.ttk_state("!#{st}")
+ end
+ end
+end
+
+#
+# Repeating buttons demo:
+#
+def repeatDemo
+ if defined?($repeatDemo) && $repeatDemo.exist?
+ $repeatDemo.deiconify; return
+ end
+ $repeatDemo = TkToplevel.new(:title=>'Repeating button')
+
+ f = Tk::Tile::Frame.new($repeatDemo)
+ b = Tk::Tile::Button.new(f, :class=>'Repeater', :text=>'Press and hold')
+ if version?('0.6')
+ p = Tk::Tile::Progressbar.new(f, :orient=>:horizontal, :maximum=>10)
+ else # progressbar is not supported
+ p = Tk::Tile::Progress.new(f, :orient=>:horizontal, :from=>0, :to=>10)
+ def p.step
+ i = self.get + 1
+ i = self.from if i > self.to
+ self.set(i)
+ end
+ end
+ b.command {p.step}
+
+ b.pack(:side=>:left, :expand=>false, :fill=>:none, :padx=>6, :pady=>6)
+ p.pack(:side=>:right, :expand=>true, :fill=>:x, :padx=>6, :pady=>6)
+ f.pack(:expand=>true, :fill=>:both)
+end
+
+Tk.mainloop
diff --git a/jni/ruby/ext/tk/sample/tkextlib/tile/iconlib.tcl b/jni/ruby/ext/tk/sample/tkextlib/tile/iconlib.tcl
new file mode 100644
index 0000000..9a93ece
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkextlib/tile/iconlib.tcl
@@ -0,0 +1,110 @@
+array set ImgData {
+bold {R0lGODlhEAAQAJEAANnZ2QAAAP///////yH5BAEAAAAALAAAAAAQABAAAAI6hI+py60U3wj+
+RYQFJYRvEWFBCeFbRFhQQvhG8YPgX0RYUEL4FhEWlBC+RYQFJYQPFN8IPqYut/8hBQA7}
+copy {R0lGODlhEAAQAJEAANnZ2QAAAP///wAAhCH5BAEAAAAALAAAAAAQABAAAAJUhI8JFJ/gY4iI
+UEL4FyIiFIXgW0iEUDgfACBI9pzMAAGRiIghWSMDECR7JEKGtkFIRFBG+TIQKDQxtgzcDcmX
+IfgwQrFlCD4MyZch+EDzj+Bj6mYBADs=}
+cut {R0lGODlhEAAQAJEAANnZ2QAAAAAAhP///yH5BAEAAAAALAAAAAAQABAAAAJFhI+pcUHwEeIi
+E0gACIKPEAFBIXy0gMg8EhM+YmQiKSL4eAIiJMI/EQEhQGYGYiQIQAg+iAkIATIzECMBIgT/
+RBARERlSADs=}
+dragfile {R0lGODlhGAAYAKIAANnZ2TMzM////wAAAJmZmf///////////yH5BAEAAAAALAAAAAAYABgA
+AAPACBi63IqgC4GiyxwogaAbKLrMgSKBoBoousyBogEACIGiyxwoKgGAECI4uiyCExMTOACB
+osuNpDoAGCI4uiyCIkREOACBosutSDoAgSI4usyCIjQAGCi63Iw0ACEoOLrMgiI0ABgoutyM
+NAAhKDi6zIIiNAAYKLrcjDQAISg4usyCIjQAGCi63Iw0AIGiiqPLIyhCA4CBosvNSAMQKKo4
+ujyCIjQAGCi63Iw0AIGiy81IAxCBpMu9GAMAgKPL3QgJADs=}
+dragicon {R0lGODlhGAAYALMAANnZ2TMzM/////8zM8zMzGYAAAAAAJmZmQCZMwAzZgCZzGZmZv//////
+/////////yH5BAEAAAAALAAAAAAYABgAAAT/EMAgJ60SAjlBgEJOSoMIEMgZoJCT0iADBFIG
+KOSkNMwAAABhwiHnIEKIIIQQAQIZhBBwyDmKEMIEE0yABoAghIBDzlGEENDIaQAIQgg45BwF
+CinPOccAECYcUiKEEBFCiHPgMQAEIcQYYyABBUGIQCHlMQCEScZAAhKEEApCECGOARAEIQQp
+BRGIpAyCJCGOASBAISdEcqJAVBLiGABggELOAJGUKyiVhDgGABigkJMEhNAKSqkEhTgGgCCl
+FCQEGIJSSiUhjgEgQCEnJVBJmYQ4BoAAhZyTQCVnEuIYAAIUckoCk5xSiGMACFDISSs9BoBg
+rRXQMQAEKOSklR4DEUAI8MhJ6wwGAACgkZNWCkAEADs=}
+error {R0lGODlhIAAgAKIAANnZ2YQAAP8AAISEhP///////////////yH5BAEAAAAALAAAAAAgACAA
+AAP/CLoMGLqKoMvtGIqiqxEYCLrcioGiyxwIusyBgaLLLRiBoMsQKLrcjYGgu4Giy+2CAkFX
+A0WX2wXFIOgGii7trkCEohsDCACBoktEKLpKhISiGwAIECiqSKooukiqKKoxgACBooukKiIo
+SKooujGDECi6iqQqsopEV2MQAkV3kXQZRXdjEAJFl5F0FUWXY3ACRZcFSRdFlyVwJlB0WZB0
+UXRZAmcCRZeRdBVFl2NwAkV3kXQZRXdjcAJFV5FURVaR6GoMDgSKLpKqiKAgqaLoxgwOBIoq
+kiqKLpIqimrM4ECg6BIRiq4SIaHoxgyCBoou7a5AhKIbMzgAAIGiy+2CTWJmBhAAAkWX2wXF
+zCDoBooud2PMDIKuRqDocgtGzMwg6O4Eii5z4Kgi6DIMhqLoagQGjiqCLvPgYOgqji6CLrfi
+6DIj6HI7jq4i6DIkADs=}
+file {R0lGODlhCwANAJEAANnZ2QAAAP///////yH5BAEAAAAALAAAAAALAA0AAAIyhI9G8Q0AguSH
+AMQdxQgxEyEFQfItICQokYgEBMm3gBCKLRIQJN8CQii2SECQfAug+FgAOw==}
+folder {R0lGODlhEAANAKIAANnZ2YSEhMbGxv//AP///wAAAP///////yH5BAEAAAAALAAAAAAQAA0A
+AANjCIqhiqDLITgyEgi6GoIjIyMYugCBpMsaWBA0giMjIzgyUYBBMjIoIyODEgVBODIygiMj
+E1gQJIMyMjIoI1GAQSMjODIyghMFQSgjI4MyMhJYEDSCIyMjODJRgKHLXAiApcucADs=}
+hourglass {R0lGODlhIAAgAKIAANnZ2YAAAAAAAP8AAP///8DAwICAgP///yH5BAEAAAAALAAAAAAgACAA
+AAPZCLrc/jDKSau9OGcUuqyCoMvNGENVhaMrCLrcjaLLgqDL7WhFVIVVZoKgy+1oRUSFVWaC
+oMvtaEVEhVVmgqDL7WhFRIVVZoKgy+1oVVaCJWaCoMvtgKxISrBMEHS5fZEVSRkKgi63NzIq
+EwRdbndkVCYIutzeyIqqDAVBl9sXWRFJYZkg6HI7ICsiKqwyEwRdbkcrIhKsMhMEXW5HKyIp
+lDITBF1uRysyEiwxEwRdbkcrIyuUEhMEXW5H0WVB0OVujKGqwtEVBF1uRtHlRdDl9odRTlrt
+xRmjBAA7}
+info {R0lGODlhIAAgAKIAANnZ2YSEhMbGxv///wAA/wAAAP///////yH5BAEAAAAALAAAAAAgACAA
+AAP/CLoMGLqKoMvtGCo4uhKBgaDLDRghOLqsghEIuryBgqPLPSiBoMsQOLojhEQkOLpTCLob
+OLqKpIujq4WgC4Gju0i6OLpbCKohOLorhEQkOLorhaAQOLrc3qgCIARHl9sbSQUEji4j6RKO
+Lk9hQODosiKp4ujyFIbi6LIiqeLo8hSG4uiyIqni6PIUhuLosiKp4ujyFIYKji4PkiqOLkth
+BASOLg+SKo4uV2AEhODoMpIqju5KYShA4Ogqku7i6E4FRgAAYOHocvugiohAUC0cXe7GiohA
+0IUSHF3uQamICATdrULB0WUVrIqIQNBlCCwVHF2pwsJQRdDlDYyoKsHRPMLQDQRdbsDQqBmc
+wlBF0OV2jJqZwggEXW5vVDMVgaDL7Y5qKgJBl9sfVUUg6HL7AxSKoMvtr1AEgi5DAgA7}
+italic {R0lGODlhEAAQAJEAANnZ2QAAAP///////yH5BAEAAAAALAAAAAAQABAAAAIrhI+py+1A4hN8
+hIjINBITPlpEZBqJCR8tIjKNxISPFhGZQOITfExdbv9FCgA7}
+new {R0lGODlhEAAQAJEAANnZ2QAAAP///////yH5BAEAAAAALAAAAAAQABAAAAJFhI95FN8IvgXJ
+jyD4ECQ/JAh+kPyICIIdJP+CYAfJvyDYQfIvCHaQ/AuCHST/gmAHyb8g2EHyLwh2kPwLgk3x
+MQg+pu4WADs=}
+open {R0lGODlhEAAQAKIAANnZ2QAAAP//AP///4SEAP///////////yH5BAEAAAAALAAAAAAQABAA
+AANZCLrczigUQZc1EDQgEHSZAwMgIhB0NQIDQkYwdANBNUZwZGQEJxBUQwZlZGRQAkE1RnAE
+Q5dVcCSQdDcAYySQdDcAISSQdDcAASKQdDcAAQBDlwNBl9sfApQAOw==}
+openfold {R0lGODlhEAANAKIAANnZ2YSEhP///8bGxv//AAAAAP///////yH5BAEAAAAALAAAAAAQAA0A
+AANgCIqhiqDLgaIaCLoagkNDIxi6AIFCQ0M4KKpRgCFDQzg0NIQThaHLSxgVKLochRMVMkhD
+Q4M0VBFYEDKEQ0NDOFFRgCE0NEhDQ4MVBRAoNDSEQ0NRWAAYuqyFBQBYurwJADs=}
+overstrike {R0lGODlhEAAQAJEAANnZ2QAAAP///////yH5BAEAAAAALAAAAAAQABAAAAI3hI+py80Uh+Aj
+RFhQCP8iMILgWwRGEHyLwAiCbxEYQfCB4iPBhwiMIPgXYREEHyEiguBj6nI7FQA7}
+palette {R0lGODlhEAAQAKIAANnZ2QAAAP//AP////8A/4QAhP8AAAD//yH5BAEAAAAALAAAAAAQABAA
+AANtCLrcjqGBoMsRKCMTgaALMSgDAYMSCKoxgAFBITgSAIAQEhUIARCAEgAQOBAwghMQEwga
+MoIjIxAIEgCAEBEyKBAgg4GgGxAIYTGCgaALcRgQIIGgCwEYICODgaALITgyEoGguxiqCLrc
+/lChBAA7}
+passwd {R0lGODlhIAAgAMQAANnZ2QAAAICAgICAAP///7CwsMDAwMjIAPjIAOjo6Pj4AODg4HBwcMj4
+ANjY2JiYANDQ0MjIyPj4yKCgoMiYAMjImDAwAMjIMJiYmJCQkP//////////////////////
+/yH5BAEAAAAALAAAAAAgACAAAAX/ICCOIhiIIgiII1maZSCMQnCeJyAIQiAIAiAMwxCcJwkk
+EAQRCIUwGMSBDEEAAuJIlgKRJEEgGAMRBIGiDENQlqNAJAsYCEwgEEEgBAHSIEMAAuJIAgKR
+LEsgGEMgCEJgBMqhHENQlgJILMsSCMRABEFgGAESHMcRgIA4kgKxOIsTBAOhKAITKEGDHMhD
+kqIAEqAjisJAgIooBkpwNMcTgIA4jgLhOBAkEAOhKIoSKEGDIMcTkKQICgQEQQIxEIqiBEpw
+IMdxPAEIiCMJCEQUMUQ0EIqiHIfSIM3xBGUpCiABCUQyEMqhHMiBHMjxBCAgjuQoEAKxRANB
+HMqhHM1x/zxDUJajQIACsUTDQBAEIR3IcQRDAALiSIoCYQiEE03gII7HQR3BEICAOJICYRSC
+QDjRNE1CAAzVQR3WE5AkAAqEUQiFQEARBAUAAAzHQR3BEICAOI4CUQhFIBAREwXjUFUHdQRD
+QJJAABbCFAhEJBgBAADAMAwXdQRDAALiCAhEIRQCYRiCEZDjUFFHMAQkIBAFOAmTQBiFUAQg
+II7AUFXUEQwBCQjEJExBkBRCEZCjMIBD9RxDAALiGEzCFBBYIRTBOI7AQB1DMIoCMQkYGAjL
+JEwBCIgjOVDDEJCAQGACJiTTJEwBSY5BEJAiSCCwTAiCZBKmAATEkSzNQBCCYCDBJgELTNMk
+g0AMEgwTAhAQR7I0zYARgvM8TyAIznMMAQA7}
+paste {R0lGODlhEAAQAKIAANnZ2QAAAP//AISEAISEhP///wAAhP///yH5BAEAAAAALAAAAAAQABAA
+AANwCLrcjqGBoKsYqiKrCDSGBkMiJJCGAgCDKBB0gwYDIKYwdJUIAyBokIaGBmloAhBiaAgH
+TdcCEIKGBsmwVM0AIYaGcAxL1coQgoYGySoisMzMAoeGxrB01QJpaMiwMHTLAEPVsHTVEHTR
+dBlBlxswAQA7}
+print {R0lGODlhEAAQAKIAANnZ2QAAAP///4SEhP//AP///////////yH5BAEAAAAALAAAAAAQABAA
+AANZCLrcjqG7CLqBoquBoBuCoSqBoBsouhoIuiEYqrKBoIGiqwEYEIChyxAIEYGgywEYgKHL
+DAgRCLozgwABARgIukSEABEBGLq8gAEQCLobgAEAgKHLgaDLzZgAOw==}
+question {R0lGODlhIAAgAKIAANnZ2YSEhMbGxv///wAAAAAA/////////yH5BAEAAAAALAAAAAAgACAA
+AAP/CLoMGLqKoMvtGCo4uhKBgaDLDRghOLqsghEIuryBgqPLPSiBoMsQOLrcjYSgu4GjO4Kl
+Kzi6Qwi6EDi6I4UyU1VYgqM7hKAagqM7VTg6VYWFoztCCAqBo6tVWDVThVU4ukqBACE4ulqF
+VSNVWIWjq0IYEDi6K4UlU1VYOLpMgRA4uryCpTi6PIShOLq8hVU4uqyEoTi6vIUlOLqshKE4
+uryFhaPLSxgqOLrc3kgoAgJHl0ewSnB0eQhDIQRHl6uwCkeXhTAUIHB0uQqrcHSZAiMAAJBw
+dFcKS3B0lwIjAkGVcHS5GykiAkEXSHB0uQeFIiIQdJcIBUeXVZAoIgJBT5chkFRwdIUICUMV
+QZc3MIKIBEcJQzcQdLkBQ4NmcAhDFUGX2zFoZggjEHS5vRHNUASCLrc7oqEIBF1uf0QUgaDL
+7Q9QKIIut79CEQi6DAkAOw==}
+redo {R0lGODlhEAAQAJEAANnZ2QAAhP///////yH5BAEAAAAALAAAAAAQABAAAAIvhI+py+1vSByC
+jxAYQXDMwsyAggQAQBB8iwgMgg8REQgUwqbYBDsIPqYutz+MgBQAOw==}
+save {R0lGODlhEAAQAJEAANnZ2QAAAISEAP///yH5BAEAAAAALAAAAAAQABAAAAJWhI9pFB8RIIRC
++BYQFqQQvkWEBSmEbyFhQQrhW0hYkEL4FhIWpBC+hYQFSYxvIgFAoXy0AAiSGP8kAIIkxgcI
+CSBEQvEBQgIIkVB8gJAAAhgfj+BjWgEAOw==}
+underline {R0lGODlhEAAQAJEAANnZ2QAAAP///////yH5BAEAAAAALAAAAAAQABAAAAI3hI+py60UBy4I
+vkVcBMG/iIsg+BdxEQT/Ii6C4F/ERRD8i7gIgn8RF0HwkWITfExFin8EH1OXCwA7}
+undo {R0lGODlhEAAQAJEAANnZ2QAAhP///////yH5BAEAAAAALAAAAAAQABAAAAIuhI+py+2vSByC
+HxdxQCHsCIg7oAAAEUHwLTAiKIQPgRSbYMfd3VEIH1OX2x8mUgA7}
+warning {R0lGODlhIAAgAKIAANnZ2YSEAP//AMbGxgAAAISEhP///////yH5BAEAAAAALAAAAAAgACAA
+AAP/CLq8gREIutz+KESGEHS5vVGIiAxSIehy+6JAUaUqBF1uBxQoukOFhaDL7RgoukKFhaDL
+3RgoujqEVQi63IyBortUWAi63IuBostDWIWgy60YIjKERCMiSFUIutyAISKCpCoiOFSFoMsd
+KCpIqiKCQlUIusyBooqkKiIoQ1UIuryBooqkiqJKVQi6rIGii6SKojpUWAi6DIGiG0RIgaJL
+VQi6HCi6MoREg6I7VFgIuhsoukqEhKKrVFgIuhoouhuEgaKrQ1iFoAuBortDOCi6S4WFoBso
+uiyEostDWIWgGii63K6IqgAAIVB0WQaJBkV3h7AKAAJFl4WQiFB0mQoLRyBQdFkJiQhFl4ew
+CgJFl3WQaFB0WQirIFB0ud0RVVWg6HJ7o6GqAgwUXW5fNFRVhQCBpMvti0oVABCwdLndEehi
+6XI7I4AEADs=}
+}
diff --git a/jni/ruby/ext/tk/sample/tkextlib/tile/readme.txt b/jni/ruby/ext/tk/sample/tkextlib/tile/readme.txt
new file mode 100644
index 0000000..6c4a5cf
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkextlib/tile/readme.txt
@@ -0,0 +1,2 @@
+All of *.tcl and under themes/ directory (except kroc.rb) are
+quoted from Tcl/Tk's Tile extension. Please read Orig_LICENSE.txt.
diff --git a/jni/ruby/ext/tk/sample/tkextlib/tile/repeater.tcl b/jni/ruby/ext/tk/sample/tkextlib/tile/repeater.tcl
new file mode 100644
index 0000000..5a7d82f
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkextlib/tile/repeater.tcl
@@ -0,0 +1,117 @@
+#
+# $Id: repeater.tcl 31689 2011-05-22 09:26:02Z nobu $
+#
+# Demonstration of custom classes.
+#
+# The Tile button doesn't have built-in support for autorepeat.
+# Instead of adding -repeatdelay and -repeatinterval options,
+# and all the extra binding scripts required to deal with them,
+# we create a custom widget class for autorepeating buttons.
+#
+# Usage:
+# ttk::button .b -class Repeater [... other options ...]
+#
+# TODO:
+# Use system settings for repeat interval and initial delay.
+#
+# Notes:
+# Repeater buttons work more like scrollbar arrows than
+# Tk repeating buttons: they fire once immediately when
+# first pressed, and $State(delay) specifies the initial
+# interval before the button starts autorepeating.
+#
+
+namespace eval tile::Repeater {
+ variable State
+ set State(timer) {} ;# [after] id of repeat script
+ set State(interval) 100 ;# interval between repetitions
+ set State(delay) 300 ;# delay after initial invocation
+}
+
+### Class bindings.
+#
+
+bind Repeater <Enter> { %W state active }
+bind Repeater <Leave> { %W state !active }
+
+bind Repeater <Key-space> { tile::Repeater::Activate %W }
+bind Repeater <<Invoke>> { tile::Repeater::Activate %W }
+
+bind Repeater <ButtonPress-1> { tile::Repeater::Press %W }
+bind Repeater <ButtonRelease-1> { tile::Repeater::Release %W }
+bind Repeater <B1-Leave> { tile::Repeater::Pause %W }
+bind Repeater <B1-Enter> { tile::Repeater::Resume %W } ;# @@@ see below
+
+# @@@ Workaround for metacity-induced bug:
+bind Repeater <B1-Enter> \
+ { if {"%d" ne "NotifyUngrab"} { tile::Repeater::Resume %W } }
+
+### Binding procedures.
+#
+
+## Activate -- Keyboard activation binding.
+# Simulate clicking the button, and invoke the command once.
+#
+proc tile::Repeater::Activate {w} {
+ $w instate disabled { return }
+ set oldState [$w state pressed]
+ update idletasks; after 100
+ $w state $oldState
+ after idle [list $w invoke]
+}
+
+## Press -- ButtonPress-1 binding.
+# Invoke the command once and start autorepeating after
+# $State(delay) milliseconds.
+#
+proc tile::Repeater::Press {w} {
+ variable State
+ $w instate disabled { return }
+ $w state pressed
+ $w invoke
+ after cancel $State(timer)
+ set State(timer) [after $State(delay) [list tile::Repeater::Repeat $w]]
+}
+
+## Release -- ButtonRelease binding.
+# Stop repeating.
+#
+proc tile::Repeater::Release {w} {
+ variable State
+ $w state !pressed
+ after cancel $State(timer)
+}
+
+## Pause -- B1-Leave binding
+# Temporarily suspend autorepeat.
+#
+proc tile::Repeater::Pause {w} {
+ variable State
+ $w state !pressed
+ after cancel $State(timer)
+}
+
+## Resume -- B1-Enter binding
+# Resume autorepeat.
+#
+proc tile::Repeater::Resume {w} {
+ variable State
+ $w instate disabled { return }
+ $w state pressed
+ $w invoke
+ after cancel $State(timer)
+ set State(timer) [after $State(interval) [list tile::Repeater::Repeat $w]]
+}
+
+## Repeat -- Timer script
+# Invoke the command and reschedule another repetition
+# after $State(interval) milliseconds.
+#
+proc tile::Repeater::Repeat {w} {
+ variable State
+ $w instate disabled { return }
+ $w invoke
+ set State(timer) [after $State(interval) [list tile::Repeater::Repeat $w]]
+}
+
+#*EOF*
diff --git a/jni/ruby/ext/tk/sample/tkextlib/tile/themes/blue/blue.tcl b/jni/ruby/ext/tk/sample/tkextlib/tile/themes/blue/blue.tcl
new file mode 100644
index 0000000..68733e8
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkextlib/tile/themes/blue/blue.tcl
@@ -0,0 +1,149 @@
+# blue.tcl - Copyright (C) 2004 Pat Thoyts <patthoyts@users.sourceforge.net>
+#
+# blue.tcl,v 1.27 2005/10/08 14:56:57 jenglish Exp
+#
+#
+
+namespace eval tile::theme::blue {
+
+ package provide tile::theme::blue 0.7
+
+ set imgdir [file join [file dirname [info script]] blue]
+ array set I [tile::LoadImages $imgdir *.gif]
+
+ array set colors {
+ -frame "#6699cc"
+ -lighter "#bcd2e8"
+ -window "#e6f3ff"
+ -selectbg "#ffff33"
+ -selectfg "#000000"
+ -disabledfg "#666666"
+ }
+
+ style theme create blue -settings {
+
+ style default . \
+ -borderwidth 1 \
+ -background $colors(-frame) \
+ -fieldbackground $colors(-window) \
+ -troughcolor $colors(-lighter) \
+ -selectbackground $colors(-selectbg) \
+ -selectforeground $colors(-selectfg) \
+ ;
+ style map . -foreground [list disabled $colors(-disabledfg)]
+
+ ## Buttons.
+ #
+ style default TButton -padding "10 0"
+ style layout TButton {
+ Button.button -children {
+ Button.focus -children {
+ Button.padding -children {
+ Button.label
+ }
+ }
+ }
+ }
+
+ style element create button image $I(button-n) \
+ -map [list pressed $I(button-p) active $I(button-h)] \
+ -border 4 -sticky ew
+
+ style element create Checkbutton.indicator image $I(check-nu) \
+ -width 24 -sticky w -map [list \
+ {!disabled active selected} $I(check-hc) \
+ {!disabled active} $I(check-hu) \
+ {!disabled selected} $I(check-nc) ]
+
+ style element create Radiobutton.indicator image $I(radio-nu) \
+ -width 24 -sticky w -map [list \
+ {!disabled active selected} $I(radio-hc) \
+ {!disabled active} $I(radio-hu) \
+ selected $I(radio-nc) ]
+
+ style default TMenubutton -relief raised -padding {10 2}
+
+ ## Toolbar buttons.
+ #
+ style default Toolbutton \
+ -width 0 -relief flat -borderwidth 2 -padding 4 \
+ -background $colors(-frame) -foreground #000000 ;
+ style map Toolbutton -background [list active $colors(-selectbg)]
+ style map Toolbutton -foreground [list active $colors(-selectfg)]
+ style map Toolbutton -relief {
+ disabled flat
+ selected sunken
+ pressed sunken
+ active raised
+ }
+
+ ## Entry widgets.
+ #
+ style default TEntry \
+ -selectborderwidth 1 -padding 2 -insertwidth 2 -font TkTextFont
+ style default TCombobox \
+ -selectborderwidth 1 -padding 2 -insertwidth 2 -font TkTextFont
+
+ ## Notebooks.
+ #
+ style default TNotebook.Tab -padding {4 2 4 2}
+ style map TNotebook.Tab \
+ -background \
+ [list selected $colors(-frame) active $colors(-lighter)] \
+ -padding [list selected {4 4 4 2}]
+
+ ## Labelframes.
+ #
+ style default TLabelframe -borderwidth 2 -relief groove
+
+ ## Scrollbars.
+ #
+ style layout Vertical.TScrollbar {
+ Scrollbar.trough -children {
+ Scrollbar.uparrow -side top
+ Scrollbar.downarrow -side bottom
+ Scrollbar.uparrow -side bottom
+ Vertical.Scrollbar.thumb -side top -expand true -sticky ns
+ }
+ }
+
+ style layout Horizontal.TScrollbar {
+ Scrollbar.trough -children {
+ Scrollbar.leftarrow -side left
+ Scrollbar.rightarrow -side right
+ Scrollbar.leftarrow -side right
+ Horizontal.Scrollbar.thumb -side left -expand true -sticky we
+ }
+ }
+
+ style element create Horizontal.Scrollbar.thumb image $I(sb-thumb) \
+ -map [list {pressed !disabled} $I(sb-thumb-p)] -border 3
+
+ style element create Vertical.Scrollbar.thumb image $I(sb-vthumb) \
+ -map [list {pressed !disabled} $I(sb-vthumb-p)] -border 3
+
+ foreach dir {up down left right} {
+ style element create ${dir}arrow image $I(arrow${dir}) \
+ -map [list \
+ disabled $I(arrow${dir}) \
+ pressed $I(arrow${dir}-p) \
+ active $I(arrow${dir}-h)] \
+ -border 1 -sticky {}
+ }
+
+ ## Scales.
+ #
+ style element create Scale.slider \
+ image $I(slider) -map [list {pressed !disabled} $I(slider-p)]
+
+ style element create Vertical.Scale.slider \
+ image $I(vslider) -map [list {pressed !disabled} $I(vslider-p)]
+
+ style element create Horizontal.Progress.bar \
+ image $I(sb-thumb) -border 2
+ style element create Vertical.Progress.bar \
+ image $I(sb-vthumb) -border 2
+
+ }
+}
+
diff --git a/jni/ruby/ext/tk/sample/tkextlib/tile/themes/blue/blue/arrowdown-h.gif b/jni/ruby/ext/tk/sample/tkextlib/tile/themes/blue/blue/arrowdown-h.gif
new file mode 100644
index 0000000..3c1be9d
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkextlib/tile/themes/blue/blue/arrowdown-h.gif
Binary files differ
diff --git a/jni/ruby/ext/tk/sample/tkextlib/tile/themes/blue/blue/arrowdown-p.gif b/jni/ruby/ext/tk/sample/tkextlib/tile/themes/blue/blue/arrowdown-p.gif
new file mode 100644
index 0000000..1cb36ec
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkextlib/tile/themes/blue/blue/arrowdown-p.gif
Binary files differ
diff --git a/jni/ruby/ext/tk/sample/tkextlib/tile/themes/blue/blue/arrowdown.gif b/jni/ruby/ext/tk/sample/tkextlib/tile/themes/blue/blue/arrowdown.gif
new file mode 100644
index 0000000..e363c36
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkextlib/tile/themes/blue/blue/arrowdown.gif
Binary files differ
diff --git a/jni/ruby/ext/tk/sample/tkextlib/tile/themes/blue/blue/arrowleft-h.gif b/jni/ruby/ext/tk/sample/tkextlib/tile/themes/blue/blue/arrowleft-h.gif
new file mode 100644
index 0000000..cbc3db2
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkextlib/tile/themes/blue/blue/arrowleft-h.gif
Binary files differ
diff --git a/jni/ruby/ext/tk/sample/tkextlib/tile/themes/blue/blue/arrowleft-p.gif b/jni/ruby/ext/tk/sample/tkextlib/tile/themes/blue/blue/arrowleft-p.gif
new file mode 100644
index 0000000..14d541b
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkextlib/tile/themes/blue/blue/arrowleft-p.gif
Binary files differ
diff --git a/jni/ruby/ext/tk/sample/tkextlib/tile/themes/blue/blue/arrowleft.gif b/jni/ruby/ext/tk/sample/tkextlib/tile/themes/blue/blue/arrowleft.gif
new file mode 100644
index 0000000..32584a3
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkextlib/tile/themes/blue/blue/arrowleft.gif
Binary files differ
diff --git a/jni/ruby/ext/tk/sample/tkextlib/tile/themes/blue/blue/arrowright-h.gif b/jni/ruby/ext/tk/sample/tkextlib/tile/themes/blue/blue/arrowright-h.gif
new file mode 100644
index 0000000..913e9da
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkextlib/tile/themes/blue/blue/arrowright-h.gif
Binary files differ
diff --git a/jni/ruby/ext/tk/sample/tkextlib/tile/themes/blue/blue/arrowright-p.gif b/jni/ruby/ext/tk/sample/tkextlib/tile/themes/blue/blue/arrowright-p.gif
new file mode 100644
index 0000000..d02208f
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkextlib/tile/themes/blue/blue/arrowright-p.gif
Binary files differ
diff --git a/jni/ruby/ext/tk/sample/tkextlib/tile/themes/blue/blue/arrowright.gif b/jni/ruby/ext/tk/sample/tkextlib/tile/themes/blue/blue/arrowright.gif
new file mode 100644
index 0000000..2b0f1fd
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkextlib/tile/themes/blue/blue/arrowright.gif
Binary files differ
diff --git a/jni/ruby/ext/tk/sample/tkextlib/tile/themes/blue/blue/arrowup-h.gif b/jni/ruby/ext/tk/sample/tkextlib/tile/themes/blue/blue/arrowup-h.gif
new file mode 100644
index 0000000..6059bae
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkextlib/tile/themes/blue/blue/arrowup-h.gif
Binary files differ
diff --git a/jni/ruby/ext/tk/sample/tkextlib/tile/themes/blue/blue/arrowup-p.gif b/jni/ruby/ext/tk/sample/tkextlib/tile/themes/blue/blue/arrowup-p.gif
new file mode 100644
index 0000000..20b6a82
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkextlib/tile/themes/blue/blue/arrowup-p.gif
Binary files differ
diff --git a/jni/ruby/ext/tk/sample/tkextlib/tile/themes/blue/blue/arrowup.gif b/jni/ruby/ext/tk/sample/tkextlib/tile/themes/blue/blue/arrowup.gif
new file mode 100644
index 0000000..5857616
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkextlib/tile/themes/blue/blue/arrowup.gif
Binary files differ
diff --git a/jni/ruby/ext/tk/sample/tkextlib/tile/themes/blue/blue/button-h.gif b/jni/ruby/ext/tk/sample/tkextlib/tile/themes/blue/blue/button-h.gif
new file mode 100644
index 0000000..0947f43
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkextlib/tile/themes/blue/blue/button-h.gif
Binary files differ
diff --git a/jni/ruby/ext/tk/sample/tkextlib/tile/themes/blue/blue/button-n.gif b/jni/ruby/ext/tk/sample/tkextlib/tile/themes/blue/blue/button-n.gif
new file mode 100644
index 0000000..d984528
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkextlib/tile/themes/blue/blue/button-n.gif
Binary files differ
diff --git a/jni/ruby/ext/tk/sample/tkextlib/tile/themes/blue/blue/button-n.xcf b/jni/ruby/ext/tk/sample/tkextlib/tile/themes/blue/blue/button-n.xcf
new file mode 100644
index 0000000..e38ed19
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkextlib/tile/themes/blue/blue/button-n.xcf
Binary files differ
diff --git a/jni/ruby/ext/tk/sample/tkextlib/tile/themes/blue/blue/button-p.gif b/jni/ruby/ext/tk/sample/tkextlib/tile/themes/blue/blue/button-p.gif
new file mode 100644
index 0000000..e819b1b
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkextlib/tile/themes/blue/blue/button-p.gif
Binary files differ
diff --git a/jni/ruby/ext/tk/sample/tkextlib/tile/themes/blue/blue/check-hc.gif b/jni/ruby/ext/tk/sample/tkextlib/tile/themes/blue/blue/check-hc.gif
new file mode 100644
index 0000000..b753aea
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkextlib/tile/themes/blue/blue/check-hc.gif
Binary files differ
diff --git a/jni/ruby/ext/tk/sample/tkextlib/tile/themes/blue/blue/check-hu.gif b/jni/ruby/ext/tk/sample/tkextlib/tile/themes/blue/blue/check-hu.gif
new file mode 100644
index 0000000..74dbb79
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkextlib/tile/themes/blue/blue/check-hu.gif
Binary files differ
diff --git a/jni/ruby/ext/tk/sample/tkextlib/tile/themes/blue/blue/check-nc.gif b/jni/ruby/ext/tk/sample/tkextlib/tile/themes/blue/blue/check-nc.gif
new file mode 100644
index 0000000..8f3d911
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkextlib/tile/themes/blue/blue/check-nc.gif
Binary files differ
diff --git a/jni/ruby/ext/tk/sample/tkextlib/tile/themes/blue/blue/check-nu.gif b/jni/ruby/ext/tk/sample/tkextlib/tile/themes/blue/blue/check-nu.gif
new file mode 100644
index 0000000..6f360ff
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkextlib/tile/themes/blue/blue/check-nu.gif
Binary files differ
diff --git a/jni/ruby/ext/tk/sample/tkextlib/tile/themes/blue/blue/radio-hc.gif b/jni/ruby/ext/tk/sample/tkextlib/tile/themes/blue/blue/radio-hc.gif
new file mode 100644
index 0000000..f7c21fb
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkextlib/tile/themes/blue/blue/radio-hc.gif
Binary files differ
diff --git a/jni/ruby/ext/tk/sample/tkextlib/tile/themes/blue/blue/radio-hu.gif b/jni/ruby/ext/tk/sample/tkextlib/tile/themes/blue/blue/radio-hu.gif
new file mode 100644
index 0000000..a006630
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkextlib/tile/themes/blue/blue/radio-hu.gif
Binary files differ
diff --git a/jni/ruby/ext/tk/sample/tkextlib/tile/themes/blue/blue/radio-nc.gif b/jni/ruby/ext/tk/sample/tkextlib/tile/themes/blue/blue/radio-nc.gif
new file mode 100644
index 0000000..0281de3
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkextlib/tile/themes/blue/blue/radio-nc.gif
Binary files differ
diff --git a/jni/ruby/ext/tk/sample/tkextlib/tile/themes/blue/blue/radio-nu.gif b/jni/ruby/ext/tk/sample/tkextlib/tile/themes/blue/blue/radio-nu.gif
new file mode 100644
index 0000000..58ec60c
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkextlib/tile/themes/blue/blue/radio-nu.gif
Binary files differ
diff --git a/jni/ruby/ext/tk/sample/tkextlib/tile/themes/blue/blue/sb-thumb-p.gif b/jni/ruby/ext/tk/sample/tkextlib/tile/themes/blue/blue/sb-thumb-p.gif
new file mode 100644
index 0000000..6cfaa41
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkextlib/tile/themes/blue/blue/sb-thumb-p.gif
Binary files differ
diff --git a/jni/ruby/ext/tk/sample/tkextlib/tile/themes/blue/blue/sb-thumb.gif b/jni/ruby/ext/tk/sample/tkextlib/tile/themes/blue/blue/sb-thumb.gif
new file mode 100644
index 0000000..d9bfc0a
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkextlib/tile/themes/blue/blue/sb-thumb.gif
Binary files differ
diff --git a/jni/ruby/ext/tk/sample/tkextlib/tile/themes/blue/blue/sb-vthumb-p.gif b/jni/ruby/ext/tk/sample/tkextlib/tile/themes/blue/blue/sb-vthumb-p.gif
new file mode 100644
index 0000000..930d7fd
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkextlib/tile/themes/blue/blue/sb-vthumb-p.gif
Binary files differ
diff --git a/jni/ruby/ext/tk/sample/tkextlib/tile/themes/blue/blue/sb-vthumb.gif b/jni/ruby/ext/tk/sample/tkextlib/tile/themes/blue/blue/sb-vthumb.gif
new file mode 100644
index 0000000..060be5d
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkextlib/tile/themes/blue/blue/sb-vthumb.gif
Binary files differ
diff --git a/jni/ruby/ext/tk/sample/tkextlib/tile/themes/blue/blue/slider-p.gif b/jni/ruby/ext/tk/sample/tkextlib/tile/themes/blue/blue/slider-p.gif
new file mode 100644
index 0000000..c1c089d
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkextlib/tile/themes/blue/blue/slider-p.gif
Binary files differ
diff --git a/jni/ruby/ext/tk/sample/tkextlib/tile/themes/blue/blue/slider.gif b/jni/ruby/ext/tk/sample/tkextlib/tile/themes/blue/blue/slider.gif
new file mode 100644
index 0000000..1805c2d
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkextlib/tile/themes/blue/blue/slider.gif
Binary files differ
diff --git a/jni/ruby/ext/tk/sample/tkextlib/tile/themes/blue/blue/vslider-p.gif b/jni/ruby/ext/tk/sample/tkextlib/tile/themes/blue/blue/vslider-p.gif
new file mode 100644
index 0000000..bc37b31
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkextlib/tile/themes/blue/blue/vslider-p.gif
Binary files differ
diff --git a/jni/ruby/ext/tk/sample/tkextlib/tile/themes/blue/blue/vslider.gif b/jni/ruby/ext/tk/sample/tkextlib/tile/themes/blue/blue/vslider.gif
new file mode 100644
index 0000000..d3745c7
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkextlib/tile/themes/blue/blue/vslider.gif
Binary files differ
diff --git a/jni/ruby/ext/tk/sample/tkextlib/tile/themes/blue/pkgIndex.tcl b/jni/ruby/ext/tk/sample/tkextlib/tile/themes/blue/pkgIndex.tcl
new file mode 100644
index 0000000..4facac7
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkextlib/tile/themes/blue/pkgIndex.tcl
@@ -0,0 +1,6 @@
+# Package index for tile demo pixmap themes.
+
+if {[file isdirectory [file join $dir blue]]} {
+ package ifneeded tile::theme::blue 0.7 \
+ [list source [file join $dir blue.tcl]]
+}
diff --git a/jni/ruby/ext/tk/sample/tkextlib/tile/themes/keramik/keramik.tcl b/jni/ruby/ext/tk/sample/tkextlib/tile/themes/keramik/keramik.tcl
new file mode 100644
index 0000000..6513a2f
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkextlib/tile/themes/keramik/keramik.tcl
@@ -0,0 +1,194 @@
+# keramik.tcl -
+#
+# A sample pixmap theme for the tile package.
+#
+# Copyright (c) 2004 Googie
+# Copyright (c) 2004 Pat Thoyts <patthoyts@users.sourceforge.net>
+#
+# $Id: keramik.tcl 31689 2011-05-22 09:26:02Z nobu $
+
+package require Tk 8.4; # minimum version for Tile
+package require tile 0.5; # depends upon tile 0.5
+
+namespace eval tile {
+ namespace eval theme {
+ namespace eval keramik {
+ variable version 0.3.2
+ }
+ }
+}
+
+namespace eval tile::theme::keramik {
+
+ variable imgdir [file join [file dirname [info script]] keramik]
+ variable I
+ array set I [tile::LoadImages $imgdir *.gif]
+
+ variable colors
+ array set colors {
+ -frame "#cccccc"
+ -lighter "#cccccc"
+ -window "#ffffff"
+ -selectbg "#eeeeee"
+ -selectfg "#000000"
+ -disabledfg "#aaaaaa"
+ }
+
+ style theme create keramik -parent alt -settings {
+
+
+ # -----------------------------------------------------------------
+ # Theme defaults
+ #
+ style default . \
+ -borderwidth 1 \
+ -background $colors(-frame) \
+ -troughcolor $colors(-lighter) \
+ -font TkDefaultFont \
+ ;
+
+ style map . -foreground [list disabled $colors(-disabledfg)]
+
+ # -----------------------------------------------------------------
+ # Button elements
+ # - the button has a large rounded border and needs a bit of
+ # horizontal padding.
+ # - the checkbutton and radiobutton have the focus drawn around
+ # the whole widget - hence the new layouts.
+ #
+ style layout TButton {
+ Button.background
+ Button.button -children {
+ Button.focus -children {
+ Button.label
+ }
+ }
+ }
+ style layout Toolbutton {
+ Toolbutton.background
+ Toolbutton.button -children {
+ Toolbutton.focus -children {
+ Toolbutton.label
+ }
+ }
+ }
+ style element create button image $I(button-n) \
+ -border {8 6 8 16} -padding {6 6} -sticky news \
+ -map [list {pressed !disabled} $I(button-p) \
+ {active !selected} $I(button-h) \
+ selected $I(button-s) \
+ disabled $I(button-d)]
+ style default TButton -padding {10 6}
+
+ style element create Toolbutton.button image $I(tbar-n) \
+ -border {2 8 2 16} -padding {2 2} -sticky news \
+ -map [list {pressed !disabled} $I(tbar-p) \
+ {active !selected} $I(tbar-a) \
+ selected $I(tbar-p)]
+
+ style element create Checkbutton.indicator image $I(check-u) \
+ -width 20 -sticky w \
+ -map [list selected $I(check-c)]
+
+ style element create Radiobutton.indicator image $I(radio-u) \
+ -width 20 -sticky w \
+ -map [list selected $I(radio-c)]
+
+ # The layout for the menubutton is modified to have a button element
+ # drawn on top of the background. This means we can have transparent
+ # pixels in the button element. Also, the pixmap has a special
+ # region on the right for the arrow. So we draw the indicator as a
+ # sibling element to the button, and draw it after (ie on top of) the
+ # button image.
+ style layout TMenubutton {
+ Menubutton.background
+ Menubutton.button -children {
+ Menubutton.focus -children {
+ Menubutton.padding -children {
+ Menubutton.label -side left -expand true
+ }
+ }
+ }
+ Menubutton.indicator -side right
+ }
+ style element create Menubutton.button image $I(mbut-n) \
+ -map [list {active !disabled} $I(mbut-a) \
+ {pressed !disabled} $I(mbut-a) \
+ {disabled} $I(mbut-d)] \
+ -border {7 10 29 15} -padding {7 4 29 4} -sticky news
+ style element create Menubutton.indicator image $I(mbut-arrow-n) \
+ -width 11 -sticky w -padding {0 0 18 0}
+
+ # -----------------------------------------------------------------
+ # Scrollbars, scale and progress elements
+ # - the scrollbar has three arrow buttons, two at the bottom and
+ # one at the top.
+ #
+ style layout Vertical.TScrollbar {
+ Scrollbar.background
+ Scrollbar.trough -children {
+ Scrollbar.uparrow -side top
+ Scrollbar.downarrow -side bottom
+ Scrollbar.uparrow -side bottom
+ Vertical.Scrollbar.thumb -side top -expand true -sticky ns
+ }
+ }
+
+ style layout Horizontal.TScrollbar {
+ Scrollbar.background
+ Scrollbar.trough -children {
+ Scrollbar.leftarrow -side left
+ Scrollbar.rightarrow -side right
+ Scrollbar.leftarrow -side right
+ Horizontal.Scrollbar.thumb -side left -expand true -sticky we
+ }
+ }
+
+ style default TScrollbar -width 16
+
+ style element create Horizontal.Scrollbar.thumb image $I(hsb-n) \
+ -border {6 4} -width 15 -height 16 -sticky news \
+ -map [list {pressed !disabled} $I(hsb-p)]
+
+ style element create Vertical.Scrollbar.thumb image $I(vsb-n) \
+ -border {4 6} -width 16 -height 15 -sticky news \
+ -map [list {pressed !disabled} $I(vsb-p)]
+
+ style element create Scale.slider image $I(hslider-n) \
+ -border 3
+
+ style element create Vertical.Scale.slider image $I(vslider-n) \
+ -border 3
+
+ style element create Horizontal.Progress.bar image $I(hsb-n) \
+ -border {6 4}
+
+ style element create Vertical.Progress.bar image $I(vsb-n) \
+ -border {4 6}
+
+ style element create uparrow image $I(arrowup-n) \
+ -map [list {pressed !disabled} $I(arrowup-p)]
+
+ style element create downarrow image $I(arrowdown-n) \
+ -map [list {pressed !disabled} $I(arrowdown-p)]
+
+ style element create rightarrow image $I(arrowright-n) \
+ -map [list {pressed !disabled} $I(arrowright-p)]
+
+ style element create leftarrow image $I(arrowleft-n) \
+ -map [list {pressed !disabled} $I(arrowleft-p)]
+
+ # -----------------------------------------------------------------
+ # Notebook elements
+ #
+ style element create tab image $I(tab-n) \
+ -map [list selected $I(tab-p) active $I(tab-p)] \
+ -border {6 6 6 2} -height 12
+
+ ## Labelframes.
+ #
+ style default TLabelframe -borderwidth 2 -relief groove
+ }
+}
+
+package provide tile::theme::keramik $::tile::theme::keramik::version
diff --git a/jni/ruby/ext/tk/sample/tkextlib/tile/themes/keramik/keramik/arrowdown-n.gif b/jni/ruby/ext/tk/sample/tkextlib/tile/themes/keramik/keramik/arrowdown-n.gif
new file mode 100644
index 0000000..2d84f29
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkextlib/tile/themes/keramik/keramik/arrowdown-n.gif
Binary files differ
diff --git a/jni/ruby/ext/tk/sample/tkextlib/tile/themes/keramik/keramik/arrowdown-p.gif b/jni/ruby/ext/tk/sample/tkextlib/tile/themes/keramik/keramik/arrowdown-p.gif
new file mode 100644
index 0000000..52ee752
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkextlib/tile/themes/keramik/keramik/arrowdown-p.gif
Binary files differ
diff --git a/jni/ruby/ext/tk/sample/tkextlib/tile/themes/keramik/keramik/arrowleft-n.gif b/jni/ruby/ext/tk/sample/tkextlib/tile/themes/keramik/keramik/arrowleft-n.gif
new file mode 100644
index 0000000..ff309c5
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkextlib/tile/themes/keramik/keramik/arrowleft-n.gif
Binary files differ
diff --git a/jni/ruby/ext/tk/sample/tkextlib/tile/themes/keramik/keramik/arrowleft-p.gif b/jni/ruby/ext/tk/sample/tkextlib/tile/themes/keramik/keramik/arrowleft-p.gif
new file mode 100644
index 0000000..2159f27
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkextlib/tile/themes/keramik/keramik/arrowleft-p.gif
Binary files differ
diff --git a/jni/ruby/ext/tk/sample/tkextlib/tile/themes/keramik/keramik/arrowright-n.gif b/jni/ruby/ext/tk/sample/tkextlib/tile/themes/keramik/keramik/arrowright-n.gif
new file mode 100644
index 0000000..905fa7e
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkextlib/tile/themes/keramik/keramik/arrowright-n.gif
Binary files differ
diff --git a/jni/ruby/ext/tk/sample/tkextlib/tile/themes/keramik/keramik/arrowright-p.gif b/jni/ruby/ext/tk/sample/tkextlib/tile/themes/keramik/keramik/arrowright-p.gif
new file mode 100644
index 0000000..0323332
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkextlib/tile/themes/keramik/keramik/arrowright-p.gif
Binary files differ
diff --git a/jni/ruby/ext/tk/sample/tkextlib/tile/themes/keramik/keramik/arrowup-n.gif b/jni/ruby/ext/tk/sample/tkextlib/tile/themes/keramik/keramik/arrowup-n.gif
new file mode 100644
index 0000000..20dcadb
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkextlib/tile/themes/keramik/keramik/arrowup-n.gif
Binary files differ
diff --git a/jni/ruby/ext/tk/sample/tkextlib/tile/themes/keramik/keramik/arrowup-p.gif b/jni/ruby/ext/tk/sample/tkextlib/tile/themes/keramik/keramik/arrowup-p.gif
new file mode 100644
index 0000000..129169e
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkextlib/tile/themes/keramik/keramik/arrowup-p.gif
Binary files differ
diff --git a/jni/ruby/ext/tk/sample/tkextlib/tile/themes/keramik/keramik/button-d.gif b/jni/ruby/ext/tk/sample/tkextlib/tile/themes/keramik/keramik/button-d.gif
new file mode 100644
index 0000000..fe9bf98
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkextlib/tile/themes/keramik/keramik/button-d.gif
Binary files differ
diff --git a/jni/ruby/ext/tk/sample/tkextlib/tile/themes/keramik/keramik/button-h.gif b/jni/ruby/ext/tk/sample/tkextlib/tile/themes/keramik/keramik/button-h.gif
new file mode 100644
index 0000000..210734d
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkextlib/tile/themes/keramik/keramik/button-h.gif
Binary files differ
diff --git a/jni/ruby/ext/tk/sample/tkextlib/tile/themes/keramik/keramik/button-n.gif b/jni/ruby/ext/tk/sample/tkextlib/tile/themes/keramik/keramik/button-n.gif
new file mode 100644
index 0000000..5e1eafa
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkextlib/tile/themes/keramik/keramik/button-n.gif
Binary files differ
diff --git a/jni/ruby/ext/tk/sample/tkextlib/tile/themes/keramik/keramik/button-p.gif b/jni/ruby/ext/tk/sample/tkextlib/tile/themes/keramik/keramik/button-p.gif
new file mode 100644
index 0000000..bfd7488
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkextlib/tile/themes/keramik/keramik/button-p.gif
Binary files differ
diff --git a/jni/ruby/ext/tk/sample/tkextlib/tile/themes/keramik/keramik/button-s.gif b/jni/ruby/ext/tk/sample/tkextlib/tile/themes/keramik/keramik/button-s.gif
new file mode 100644
index 0000000..1095ed7
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkextlib/tile/themes/keramik/keramik/button-s.gif
Binary files differ
diff --git a/jni/ruby/ext/tk/sample/tkextlib/tile/themes/keramik/keramik/check-c.gif b/jni/ruby/ext/tk/sample/tkextlib/tile/themes/keramik/keramik/check-c.gif
new file mode 100644
index 0000000..06e8795
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkextlib/tile/themes/keramik/keramik/check-c.gif
Binary files differ
diff --git a/jni/ruby/ext/tk/sample/tkextlib/tile/themes/keramik/keramik/check-u.gif b/jni/ruby/ext/tk/sample/tkextlib/tile/themes/keramik/keramik/check-u.gif
new file mode 100644
index 0000000..3c02fcb
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkextlib/tile/themes/keramik/keramik/check-u.gif
Binary files differ
diff --git a/jni/ruby/ext/tk/sample/tkextlib/tile/themes/keramik/keramik/hsb-n.gif b/jni/ruby/ext/tk/sample/tkextlib/tile/themes/keramik/keramik/hsb-n.gif
new file mode 100644
index 0000000..1d93973
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkextlib/tile/themes/keramik/keramik/hsb-n.gif
Binary files differ
diff --git a/jni/ruby/ext/tk/sample/tkextlib/tile/themes/keramik/keramik/hsb-p.gif b/jni/ruby/ext/tk/sample/tkextlib/tile/themes/keramik/keramik/hsb-p.gif
new file mode 100644
index 0000000..18fbae0
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkextlib/tile/themes/keramik/keramik/hsb-p.gif
Binary files differ
diff --git a/jni/ruby/ext/tk/sample/tkextlib/tile/themes/keramik/keramik/hslider-n.gif b/jni/ruby/ext/tk/sample/tkextlib/tile/themes/keramik/keramik/hslider-n.gif
new file mode 100644
index 0000000..334e8e4
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkextlib/tile/themes/keramik/keramik/hslider-n.gif
Binary files differ
diff --git a/jni/ruby/ext/tk/sample/tkextlib/tile/themes/keramik/keramik/mbut-a.gif b/jni/ruby/ext/tk/sample/tkextlib/tile/themes/keramik/keramik/mbut-a.gif
new file mode 100644
index 0000000..2e2f1c2
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkextlib/tile/themes/keramik/keramik/mbut-a.gif
Binary files differ
diff --git a/jni/ruby/ext/tk/sample/tkextlib/tile/themes/keramik/keramik/mbut-arrow-n.gif b/jni/ruby/ext/tk/sample/tkextlib/tile/themes/keramik/keramik/mbut-arrow-n.gif
new file mode 100644
index 0000000..48197cb
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkextlib/tile/themes/keramik/keramik/mbut-arrow-n.gif
Binary files differ
diff --git a/jni/ruby/ext/tk/sample/tkextlib/tile/themes/keramik/keramik/mbut-d.gif b/jni/ruby/ext/tk/sample/tkextlib/tile/themes/keramik/keramik/mbut-d.gif
new file mode 100644
index 0000000..4a294b4
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkextlib/tile/themes/keramik/keramik/mbut-d.gif
Binary files differ
diff --git a/jni/ruby/ext/tk/sample/tkextlib/tile/themes/keramik/keramik/mbut-n.gif b/jni/ruby/ext/tk/sample/tkextlib/tile/themes/keramik/keramik/mbut-n.gif
new file mode 100644
index 0000000..65c0e4e
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkextlib/tile/themes/keramik/keramik/mbut-n.gif
Binary files differ
diff --git a/jni/ruby/ext/tk/sample/tkextlib/tile/themes/keramik/keramik/radio-c.gif b/jni/ruby/ext/tk/sample/tkextlib/tile/themes/keramik/keramik/radio-c.gif
new file mode 100644
index 0000000..c8257c9
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkextlib/tile/themes/keramik/keramik/radio-c.gif
Binary files differ
diff --git a/jni/ruby/ext/tk/sample/tkextlib/tile/themes/keramik/keramik/radio-u.gif b/jni/ruby/ext/tk/sample/tkextlib/tile/themes/keramik/keramik/radio-u.gif
new file mode 100644
index 0000000..215a738
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkextlib/tile/themes/keramik/keramik/radio-u.gif
Binary files differ
diff --git a/jni/ruby/ext/tk/sample/tkextlib/tile/themes/keramik/keramik/tab-n.gif b/jni/ruby/ext/tk/sample/tkextlib/tile/themes/keramik/keramik/tab-n.gif
new file mode 100644
index 0000000..03099a9
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkextlib/tile/themes/keramik/keramik/tab-n.gif
Binary files differ
diff --git a/jni/ruby/ext/tk/sample/tkextlib/tile/themes/keramik/keramik/tab-p.gif b/jni/ruby/ext/tk/sample/tkextlib/tile/themes/keramik/keramik/tab-p.gif
new file mode 100644
index 0000000..abec6ab
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkextlib/tile/themes/keramik/keramik/tab-p.gif
Binary files differ
diff --git a/jni/ruby/ext/tk/sample/tkextlib/tile/themes/keramik/keramik/tbar-a.gif b/jni/ruby/ext/tk/sample/tkextlib/tile/themes/keramik/keramik/tbar-a.gif
new file mode 100644
index 0000000..2c223ba
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkextlib/tile/themes/keramik/keramik/tbar-a.gif
Binary files differ
diff --git a/jni/ruby/ext/tk/sample/tkextlib/tile/themes/keramik/keramik/tbar-n.gif b/jni/ruby/ext/tk/sample/tkextlib/tile/themes/keramik/keramik/tbar-n.gif
new file mode 100644
index 0000000..77ef8a2
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkextlib/tile/themes/keramik/keramik/tbar-n.gif
Binary files differ
diff --git a/jni/ruby/ext/tk/sample/tkextlib/tile/themes/keramik/keramik/tbar-p.gif b/jni/ruby/ext/tk/sample/tkextlib/tile/themes/keramik/keramik/tbar-p.gif
new file mode 100644
index 0000000..3179b87
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkextlib/tile/themes/keramik/keramik/tbar-p.gif
Binary files differ
diff --git a/jni/ruby/ext/tk/sample/tkextlib/tile/themes/keramik/keramik/vsb-n.gif b/jni/ruby/ext/tk/sample/tkextlib/tile/themes/keramik/keramik/vsb-n.gif
new file mode 100644
index 0000000..be01e4a
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkextlib/tile/themes/keramik/keramik/vsb-n.gif
Binary files differ
diff --git a/jni/ruby/ext/tk/sample/tkextlib/tile/themes/keramik/keramik/vsb-p.gif b/jni/ruby/ext/tk/sample/tkextlib/tile/themes/keramik/keramik/vsb-p.gif
new file mode 100644
index 0000000..0bb39e9
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkextlib/tile/themes/keramik/keramik/vsb-p.gif
Binary files differ
diff --git a/jni/ruby/ext/tk/sample/tkextlib/tile/themes/keramik/keramik/vslider-n.gif b/jni/ruby/ext/tk/sample/tkextlib/tile/themes/keramik/keramik/vslider-n.gif
new file mode 100644
index 0000000..cf03d7f
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkextlib/tile/themes/keramik/keramik/vslider-n.gif
Binary files differ
diff --git a/jni/ruby/ext/tk/sample/tkextlib/tile/themes/keramik/pkgIndex.tcl b/jni/ruby/ext/tk/sample/tkextlib/tile/themes/keramik/pkgIndex.tcl
new file mode 100644
index 0000000..e9e3dc2
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkextlib/tile/themes/keramik/pkgIndex.tcl
@@ -0,0 +1,15 @@
+# pkgIndex.tcl for additional tile pixmap themes.
+#
+# We don't provide the package is the image subdirectory isn't present,
+# or we don't have the right version of Tcl/Tk
+#
+# To use this automatically within tile, the tile-using application should
+# use tile::availableThemes and tile::setTheme
+#
+# $Id: pkgIndex.tcl 31689 2011-05-22 09:26:02Z nobu $
+
+if {![file isdirectory [file join $dir keramik]]} { return }
+if {![package vsatisfies [package provide Tcl] 8.4]} { return }
+
+package ifneeded tile::theme::keramik 0.3.2 \
+ [list source [file join $dir keramik.tcl]]
diff --git a/jni/ruby/ext/tk/sample/tkextlib/tile/themes/kroc.rb b/jni/ruby/ext/tk/sample/tkextlib/tile/themes/kroc.rb
new file mode 100644
index 0000000..72a7c69
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkextlib/tile/themes/kroc.rb
@@ -0,0 +1,226 @@
+#
+# kroc.rb
+#
+# based on:
+# >> kroc.tcl - Copyright (C) 2004 David Zolli <kroc@kroc.tk>
+#
+
+imgdir = File.join(File.dirname(__FILE__), 'kroc', 'kroc')
+$images = Tk::Tile.load_images(imgdir, '*.gif')
+
+if TkPackage.vcompare(Tk::Tile.package_version, '0.5') >= 0
+ $TNotebook_Tab = Tk::Tile::TNotebook.style('Tab')
+else
+ $TNotebook_Tab = 'Tab.TNotebook'
+end
+
+def kroc_rb_settings
+ # Tk::Tile::Style.default(TkRoot, :background=>'#FCB64F',
+ # :troughcolor=>'#F8C278', :borderwidth=>1)
+ # or
+ # Tk::Tile::Style.default(Tk.root, :background=>'#FCB64F',
+ # :troughcolor=>'#F8C278', :borderwidth=>1)
+ # or
+ # Tk::Tile::Style.default('.', :background=>'#FCB64F',
+ # :troughcolor=>'#F8C278', :borderwidth=>1)
+ # or
+ # Tk::Tile::Style.default(nil, :background=>'#FCB64F',
+ # :troughcolor=>'#F8C278', :borderwidth=>1)
+ # or
+ Tk::Tile::Style.default(:background=>'#FCB64F', :troughcolor=>'#F8C278',
+ :borderwidth=>1)
+ # Tk::Tile::Style.default(TkRoot, :font=>Tk::Tile::Font::Default,
+ # :borderwidth=>1)
+ # or
+ # Tk::Tile::Style.default(Tk.root, :font=>Tk::Tile::Font::Default,
+ # :borderwidth=>1)
+ # or
+ # Tk::Tile::Style.default('.', :font=>Tk::Tile::Font::Default,
+ # :borderwidth=>1)
+ # or
+ # Tk::Tile::Style.default(nil, :font=>Tk::Tile::Font::Default,
+ # :borderwidth=>1)
+ # or
+ Tk::Tile::Style.default(:font=>Tk::Tile::Font::Default, :borderwidth=>1)
+
+ # Tk::Tile::Style.map(TkRoot, :background=>[:active, '#694418'])
+ # or
+ # Tk::Tile::Style.map(Tk.root, :background=>[:active, '#694418'])
+ # or
+ # Tk::Tile::Style.map('.', :background=>[:active, '#694418'])
+ # or
+ # Tk::Tile::Style.map(nil, :background=>[:active, '#694418'])
+ # or
+ Tk::Tile::Style.map(:background=>[:active, '#694418'])
+ Tk::Tile::Style.map(:foreground=>[:disabled, '#B2B2B2', :active, '#FFE7CB'])
+
+ # Tk::Tile::Style.default('TButton', :padding=>[10,4])
+ Tk::Tile::Style.default(Tk::Tile::TButton, :padding=>[10,4])
+
+ # Tk::Tile::Style.default('TNotebook.Tab',
+ Tk::Tile::Style.default($TNotebook_Tab,
+ :padding=>[10, 3], :font=>Tk::Tile::Font::Default)
+ # Tk::Tile::Style.map('TNotebook.Tab',
+ Tk::Tile::Style.map($TNotebook_Tab,
+ :background=>[:selected, '#FCB64F', '', '#FFE6BA'],
+ :foreground=>['', 'black'],
+ :padding=>[:selected, [10, 6, 10, 3]])
+
+ # Tk::Tile::Style.map('TScrollbar',
+ Tk::Tile::Style.map(Tk::Tile::TScrollbar,
+ :background=>[:pressed, '#694418'],
+ :arrowcolor=>[:pressed, '#FEF7CB'],
+ :relief=>[:pressed, :sunken])
+
+ # Tk::Tile::Style.layout('Vertical.TScrollbar',
+ Tk::Tile::Style.layout(Tk::Tile.style('Vertical', Tk::Tile::TScrollbar),
+ ['Scrollbar.trough', {:children=>[
+ 'Scrollbar.uparrow', {:side=>:top},
+ 'Scrollbar.downarrow', {:side=>:bottom},
+ 'Scrollbar.uparrow', {:side=>:bottom},
+ 'Scrollbar.thumb', {:side=>:top, :expand=>true}
+ ]}
+ ])
+
+ # Tk::Tile::Style.layout('Horizontal.TScrollbar',
+ Tk::Tile::Style.layout(Tk::Tile.style('Horizontal', Tk::Tile::TScrollbar),
+ ['Scrollbar.trough', {:children=>[
+ 'Scrollbar.leftarrow', {:side=>:left},
+ 'Scrollbar.rightarrow', {:side=>:right},
+ 'Scrollbar.leftarrow', {:side=>:right},
+ 'Scrollbar.thumb', {:side=>:left, :expand=>true}
+ ]}
+ ])
+
+ #
+ # Elements:
+ #
+ if Tk::Tile::TILE_SPEC_VERSION_ID >= 8
+ Tk::Tile::Style.element_create('Button.button',
+ :image,
+ [ $images['button-n'],
+ :pressed, $images['button-p'],
+ :active, $images['button-h'],
+ ], :border=>3, :sticky=>:ew)
+
+ Tk::Tile::Style.element_create('Checkbutton.indicator',
+ :image,
+ [ $images['check-nu'],
+ [:pressed, :selected],$images['check-nc'],
+ :pressed, $images['check-nu'],
+ [:active, :selected], $images['check-hc'],
+ :active, $images['check-hu'],
+ :selected, $images['check-nc'],
+ ], :sticky=>:w)
+
+ Tk::Tile::Style.element_create('Radiobutton.indicator',
+ :image,
+ [ $images['radio-nu'],
+ [:pressed,:selected],$images['radio-nc'],
+ :pressed, $images['radio-nu'],
+ [:active,:selected], $images['radio-hc'],
+ :active, $images['radio-hu'],
+ :selected, $images['radio-nc'],
+ ], :sticky=>:w)
+
+ elsif TkPackage.vcompare(Tk::Tile.package_version, '0.5') >= 0
+ Tk::Tile::Style.element_create('Button.button',
+ :image, $images['button-n'],
+ :map=>[
+ :pressed, $images['button-p'],
+ :active, $images['button-h'],
+ ], :border=>3, :sticky=>:ew)
+
+ Tk::Tile::Style.element_create('Checkbutton.indicator',
+ :image, $images['check-nu'],
+ :map=>[
+ [:pressed, :selected],$images['check-nc'],
+ :pressed, $images['check-nu'],
+ [:active, :selected], $images['check-hc'],
+ :active, $images['check-hu'],
+ :selected, $images['check-nc'],
+ ], :sticky=>:w)
+
+ Tk::Tile::Style.element_create('Radiobutton.indicator',
+ :image, $images['radio-nu'],
+ :map=>[
+ [:pressed, :selected],$images['radio-nc'],
+ :pressed, $images['radio-nu'],
+ [:active, :selected], $images['radio-hc'],
+ :active, $images['radio-hu'],
+ :selected, $images['radio-nc'],
+ ], :sticky=>:w)
+
+ else # tile 0.4 or earlier
+ Tk::Tile::Style.element_create('Button.button', :pixmap,
+ :images=>[
+ :pressed, $images['button-p'],
+ :active, $images['button-h'],
+ '', $images['button-n']
+ ], :border=>3, :tiling=>:tile)
+
+ Tk::Tile::Style.element_create('Checkbutton.indicator', :pixmap,
+ :images=>[
+ [:pressed, :selected],$images['check-nc'],
+ :pressed, $images['check-nu'],
+ [:active, :selected], $images['check-hc'],
+ :active, $images['check-hu'],
+ :selected, $images['check-nc'],
+ '', $images['check-nu'],
+ ], :tiling=>:fixed)
+
+ Tk::Tile::Style.element_create('Radiobutton.indicator', :pixmap,
+ :images=>[
+ [:pressed, :selected],$images['radio-nc'],
+ :pressed, $images['radio-nu'],
+ [:active, :selected], $images['radio-hc'],
+ :active, $images['radio-hu'],
+ :selected, $images['radio-nc'],
+ '', $images['radio-nu'],
+ ], :tiling=>:fixed)
+
+ end
+
+ #
+ # Settings:
+ #
+ # Tk::Tile::Style.layout(Tk::Tile::TButton,
+ Tk::Tile::Style.layout('TButton', [
+ 'Button.button', {:children=>[
+ 'Button.focus', {:children=>[
+ 'Button.padding', {:children=>[
+ 'Button.label', {:expand=>true, :sticky=>''}
+ ]}
+ ]}
+ ]}
+ ])
+
+ # Tk::Tile::Style.layout(Tk::Tile::TCheckbutton,
+ Tk::Tile::Style.layout('TCheckbutton', [
+ 'Checkbutton.background', # this is not needed in tile 0.5 or later
+ 'Checkbutton.border', {:children=>[
+ 'Checkbutton.padding', {:children=>[
+ 'Checkbutton.indicator', {:side=>:left},
+ 'Checkbutton.focus', {:side=>:left, :children=>[
+ 'Checkbutton.label'
+ ]}
+ ]}
+ ]}
+ ])
+
+ # Tk::Tile::Style.layout(Tk::Tile::TRadiobutton,
+ Tk::Tile::Style.layout('TRadiobutton', [
+ 'Radiobutton.background', # this is not needed in tile 0.5 or later
+ 'Radiobutton.border', {:children=>[
+ 'Radiobutton.padding', {:children=>[
+ 'Radiobutton.indicator', {:side=>:left},
+ 'Radiobutton.focus', {:expand=>true, :sticky=>:w, :children=>[
+ 'Radiobutton.label', {:side=>:right, :expand=>true}
+ ]}
+ ]}
+ ]}
+ ])
+end
+
+Tk::Tile::Style.theme_create('kroc-rb', :parent=>'alt',
+ :settings=>proc{ kroc_rb_settings() })
diff --git a/jni/ruby/ext/tk/sample/tkextlib/tile/themes/kroc/kroc.tcl b/jni/ruby/ext/tk/sample/tkextlib/tile/themes/kroc/kroc.tcl
new file mode 100644
index 0000000..b2cd796
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkextlib/tile/themes/kroc/kroc.tcl
@@ -0,0 +1,163 @@
+# kroc.tcl - Copyright (C) 2004 David Zolli <kroc@kroc.tk>
+#
+# A sample pixmap theme for the tile package.
+
+#package require tile::pixmap
+
+namespace eval tile {
+ namespace eval kroc {
+ variable version 0.0.1
+ }
+}
+
+namespace eval tile::kroc {
+
+ set imgdir [file join [file dirname [info script]] kroc]
+ array set Images [tile::LoadImages $imgdir *.gif]
+
+ if {[package vsatisfies [package provide tile] 0.5]} {
+ set TNoteBook_Tab TNotebook.Tab
+ } else {
+ set TNoteBook_Tab Tab.TNotebook
+ }
+
+ style theme create kroc -parent alt -settings {
+
+ style default . -background #FCB64F -troughcolor #F8C278 -borderwidth 1
+ style default . -font TkDefaultFont -borderwidth 1
+ style map . -background [list active #694418]
+ style map . -foreground [list disabled #B2B2B2 active #FFE7CB]
+
+ style default TButton -padding "10 4"
+
+ style default $TNoteBook_Tab -padding {10 3} -font TkDefaultFont
+ style map $TNoteBook_Tab \
+ -background [list selected #FCB64F {} #FFE6BA] \
+ -foreground [list {} black] \
+ -padding [list selected {10 6 10 3}]
+
+ style map TScrollbar \
+ -background { pressed #694418} \
+ -arrowcolor { pressed #FFE7CB } \
+ -relief { pressed sunken } \
+ ;
+
+ style layout Vertical.TScrollbar {
+ Scrollbar.trough -children {
+ Scrollbar.uparrow -side top
+ Scrollbar.downarrow -side bottom
+ Scrollbar.uparrow -side bottom
+ Scrollbar.thumb -side top -expand true
+ }
+ }
+
+ style layout Horizontal.TScrollbar {
+ Scrollbar.trough -children {
+ Scrollbar.leftarrow -side left
+ Scrollbar.rightarrow -side right
+ Scrollbar.leftarrow -side right
+ Scrollbar.thumb -side left -expand true
+ }
+ }
+
+ #
+ # Elements:
+ #
+ if {[package vsatisfies [package provide tile] 0.5]} {
+
+ style element create Button.button image $Images(button-n) \
+ -map [list \
+ pressed $Images(button-p) \
+ active $Images(button-h) \
+ ] -border 3 -sticky ew
+
+ style element create Checkbutton.indicator image $Images(check-nu) \
+ -map [list \
+ {pressed selected} $Images(check-nc) \
+ pressed $Images(check-nu) \
+ {active selected} $Images(check-hc) \
+ active $Images(check-hu) \
+ selected $Images(check-nc) \
+ ] -sticky w
+
+ style element create Radiobutton.indicator image $Images(radio-nu) \
+ -map [list \
+ {pressed selected} $Images(radio-nc) \
+ pressed $Images(radio-nu) \
+ {active selected} $Images(radio-hc) \
+ active $Images(radio-hu) \
+ selected $Images(radio-nc) \
+ ] -sticky w
+
+ } else {
+
+ style element create Button.button pixmap -images [list \
+ pressed $Images(button-p) \
+ active $Images(button-h) \
+ {} $Images(button-n) \
+ ] -border 3 -tiling tile
+
+ style element create Checkbutton.indicator pixmap -images [list \
+ {pressed selected} $Images(check-nc) \
+ pressed $Images(check-nu) \
+ {active selected} $Images(check-hc) \
+ active $Images(check-hu) \
+ selected $Images(check-nc) \
+ {} $Images(check-nu) \
+ ] -tiling fixed
+
+ style element create Radiobutton.indicator pixmap -images [list \
+ {pressed selected} $Images(radio-nc) \
+ pressed $Images(radio-nu) \
+ {active selected} $Images(radio-hc) \
+ active $Images(radio-hu) \
+ selected $Images(radio-nc) \
+ {} $Images(radio-nu) \
+ ] -tiling fixed
+
+ }
+
+ #
+ # Settings: (*button.background is not needed in tile 0.5 or above)
+ #
+ style layout TButton {
+ Button.button -children {
+ Button.focus -children {
+ Button.padding -children {
+ Button.label -expand true -sticky {}
+ }
+ }
+ }
+ }
+
+ style layout TCheckbutton {
+ Checkbutton.border -children {
+ Checkbutton.background
+ Checkbutton.padding -children {
+ Checkbutton.indicator -side left
+ Checkbutton.focus -side left -children {
+ Checkbutton.label
+ }
+ }
+ }
+ }
+
+ style layout TRadiobutton {
+ Radiobutton.border -children {
+ Radiobutton.background
+ Radiobutton.padding -children {
+ Radiobutton.indicator -side left
+ Radiobutton.focus -expand true -sticky w -children {
+ Radiobutton.label -side right -expand true
+ }
+ }
+ }
+ }
+
+ } }
+
+# -------------------------------------------------------------------------
+
+package provide tile::theme::kroc $::tile::kroc::version
+
+# -------------------------------------------------------------------------
diff --git a/jni/ruby/ext/tk/sample/tkextlib/tile/themes/kroc/kroc/button-h.gif b/jni/ruby/ext/tk/sample/tkextlib/tile/themes/kroc/kroc/button-h.gif
new file mode 100644
index 0000000..e7a140d
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkextlib/tile/themes/kroc/kroc/button-h.gif
Binary files differ
diff --git a/jni/ruby/ext/tk/sample/tkextlib/tile/themes/kroc/kroc/button-n.gif b/jni/ruby/ext/tk/sample/tkextlib/tile/themes/kroc/kroc/button-n.gif
new file mode 100644
index 0000000..78b506d
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkextlib/tile/themes/kroc/kroc/button-n.gif
Binary files differ
diff --git a/jni/ruby/ext/tk/sample/tkextlib/tile/themes/kroc/kroc/button-p.gif b/jni/ruby/ext/tk/sample/tkextlib/tile/themes/kroc/kroc/button-p.gif
new file mode 100644
index 0000000..a5a4e90
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkextlib/tile/themes/kroc/kroc/button-p.gif
Binary files differ
diff --git a/jni/ruby/ext/tk/sample/tkextlib/tile/themes/kroc/kroc/check-hc.gif b/jni/ruby/ext/tk/sample/tkextlib/tile/themes/kroc/kroc/check-hc.gif
new file mode 100644
index 0000000..41503c5
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkextlib/tile/themes/kroc/kroc/check-hc.gif
Binary files differ
diff --git a/jni/ruby/ext/tk/sample/tkextlib/tile/themes/kroc/kroc/check-hu.gif b/jni/ruby/ext/tk/sample/tkextlib/tile/themes/kroc/kroc/check-hu.gif
new file mode 100644
index 0000000..b3e512c
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkextlib/tile/themes/kroc/kroc/check-hu.gif
Binary files differ
diff --git a/jni/ruby/ext/tk/sample/tkextlib/tile/themes/kroc/kroc/check-nc.gif b/jni/ruby/ext/tk/sample/tkextlib/tile/themes/kroc/kroc/check-nc.gif
new file mode 100644
index 0000000..a28c288
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkextlib/tile/themes/kroc/kroc/check-nc.gif
Binary files differ
diff --git a/jni/ruby/ext/tk/sample/tkextlib/tile/themes/kroc/kroc/check-nu.gif b/jni/ruby/ext/tk/sample/tkextlib/tile/themes/kroc/kroc/check-nu.gif
new file mode 100644
index 0000000..5c23931
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkextlib/tile/themes/kroc/kroc/check-nu.gif
Binary files differ
diff --git a/jni/ruby/ext/tk/sample/tkextlib/tile/themes/kroc/kroc/radio-hc.gif b/jni/ruby/ext/tk/sample/tkextlib/tile/themes/kroc/kroc/radio-hc.gif
new file mode 100644
index 0000000..359fe1c
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkextlib/tile/themes/kroc/kroc/radio-hc.gif
Binary files differ
diff --git a/jni/ruby/ext/tk/sample/tkextlib/tile/themes/kroc/kroc/radio-hu.gif b/jni/ruby/ext/tk/sample/tkextlib/tile/themes/kroc/kroc/radio-hu.gif
new file mode 100644
index 0000000..9f46b37
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkextlib/tile/themes/kroc/kroc/radio-hu.gif
Binary files differ
diff --git a/jni/ruby/ext/tk/sample/tkextlib/tile/themes/kroc/kroc/radio-nc.gif b/jni/ruby/ext/tk/sample/tkextlib/tile/themes/kroc/kroc/radio-nc.gif
new file mode 100644
index 0000000..6437f33
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkextlib/tile/themes/kroc/kroc/radio-nc.gif
Binary files differ
diff --git a/jni/ruby/ext/tk/sample/tkextlib/tile/themes/kroc/kroc/radio-nu.gif b/jni/ruby/ext/tk/sample/tkextlib/tile/themes/kroc/kroc/radio-nu.gif
new file mode 100644
index 0000000..2d2aac8
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkextlib/tile/themes/kroc/kroc/radio-nu.gif
Binary files differ
diff --git a/jni/ruby/ext/tk/sample/tkextlib/tile/themes/kroc/pkgIndex.tcl b/jni/ruby/ext/tk/sample/tkextlib/tile/themes/kroc/pkgIndex.tcl
new file mode 100644
index 0000000..95c3d57
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkextlib/tile/themes/kroc/pkgIndex.tcl
@@ -0,0 +1,15 @@
+# pkgIndex.tcl for additional tile pixmap themes.
+#
+# We don't provide the package is the image subdirectory isn't present,
+# or we don't have the right version of Tcl/Tk
+#
+# To use this automatically within tile, the tile-using application should
+# use tile::availableThemes and tile::setTheme
+#
+# $Id: pkgIndex.tcl 31689 2011-05-22 09:26:02Z nobu $
+
+if {![file isdirectory [file join $dir kroc]]} { return }
+if {![package vsatisfies [package provide Tcl] 8.4]} { return }
+
+package ifneeded tile::theme::kroc 0.0.1 \
+ [list source [file join $dir kroc.tcl]]
diff --git a/jni/ruby/ext/tk/sample/tkextlib/tile/themes/plastik/pkgIndex.tcl b/jni/ruby/ext/tk/sample/tkextlib/tile/themes/plastik/pkgIndex.tcl
new file mode 100644
index 0000000..4441b79
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkextlib/tile/themes/plastik/pkgIndex.tcl
@@ -0,0 +1,16 @@
+# pkgIndex.tcl for additional tile pixmap themes.
+#
+# We don't provide the package is the image subdirectory isn't present,
+# or we don't have the right version of Tcl/Tk
+#
+# To use this automatically within tile, the tile-using application should
+# use tile::availableThemes and tile::setTheme
+#
+# $Id: pkgIndex.tcl 31689 2011-05-22 09:26:02Z nobu $
+
+if {![file isdirectory [file join $dir plastik]]} { return }
+if {![package vsatisfies [package provide Tcl] 8.4]} { return }
+
+package ifneeded tile::theme::plastik 0.3.1 \
+ [list source [file join $dir plastik.tcl]]
+
diff --git a/jni/ruby/ext/tk/sample/tkextlib/tile/themes/plastik/plastik.tcl b/jni/ruby/ext/tk/sample/tkextlib/tile/themes/plastik/plastik.tcl
new file mode 100644
index 0000000..cba5ebd
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkextlib/tile/themes/plastik/plastik.tcl
@@ -0,0 +1,125 @@
+# plastik.tcl - Copyright (C) 2004 Googie
+#
+# A sample pixmap theme for the tile package.
+#
+# Copyright (c) 2004 Googie
+# Copyright (c) 2005 Pat Thoyts <patthoyts@users.sourceforge.net>
+#
+# $Id: plastik.tcl 25189 2009-10-02 12:04:37Z akr $
+
+package require Tk 8.4
+package require tile 0.5
+
+namespace eval tile::theme::plastik {
+
+ variable version 0.3.1
+ package provide tile::theme::plastik $version
+
+ variable imgdir [file join [file dirname [info script]] plastik]
+ variable Images;
+ array set Images [tile::LoadImages $imgdir *.gif]
+
+ variable colors
+ array set colors {
+ -frame "#cccccc"
+ -disabledfg "#aaaaaa"
+ -selectbg "#657a9e"
+ -selectfg "#ffffff"
+ }
+
+style theme create plastik -parent default -settings {
+ style default . \
+ -background $colors(-frame) \
+ -troughcolor $colors(-frame) \
+ -selectbackground $colors(-selectbg) \
+ -selectforeground $colors(-selectfg) \
+ -font TkDefaultFont \
+ -borderwidth 1 \
+ ;
+
+ style map . -foreground [list disabled $colors(-disabledfg)]
+
+ #
+ # Layouts:
+ #
+ style layout Vertical.TScrollbar {
+ Scrollbar.background
+ Scrollbar.trough -children {
+ Scrollbar.uparrow -side top
+ Scrollbar.downarrow -side bottom
+ Scrollbar.uparrow -side bottom
+ Vertical.Scrollbar.thumb -side top -expand true -sticky ns
+ }
+ }
+
+ style layout Horizontal.TScrollbar {
+ Scrollbar.background
+ Scrollbar.trough -children {
+ Scrollbar.leftarrow -side left
+ Scrollbar.rightarrow -side right
+ Scrollbar.leftarrow -side right
+ Horizontal.Scrollbar.thumb -side left -expand true -sticky we
+ }
+ }
+
+ style layout TButton {
+ Button.button -children {
+ Button.focus -children {
+ Button.padding -children {
+ Button.label -side left -expand true
+ }
+ }
+ }
+ }
+
+ #
+ # Elements:
+ #
+ style element create Button.button image $Images(button-n) \
+ -border 4 -sticky ew \
+ -map [list pressed $Images(button-p) active $Images(button-h)]
+
+ style element create Checkbutton.indicator image $Images(check-nu) \
+ -sticky {} -map [list \
+ {active selected} $Images(check-hc) \
+ {pressed selected} $Images(check-pc) \
+ active $Images(check-hu) \
+ selected $Images(check-nc) \
+ ]
+
+ style element create Radiobutton.indicator image $Images(radio-nu) \
+ -sticky {} -map [list \
+ {active selected} $Images(radio-hc) \
+ {pressed selected} $Images(radio-pc) \
+ active $Images(radio-hu) \
+ selected $Images(radio-nc) \
+ ]
+
+ style element create Horizontal.Scrollbar.thumb \
+ image $Images(hsb-n) -border 3 -sticky ew
+ style element create Vertical.Scrollbar.thumb \
+ image $Images(vsb-n) -border 3 -sticky ns
+
+ style element create Scale.slider \
+ image $Images(hslider-n) -sticky {}
+ style element create Vertical.Scale.slider \
+ image $Images(vslider-n) -sticky {}
+
+ style element create Scrollbar.uparrow image $Images(arrowup-n) \
+ -map [list pressed $Images(arrowup-p)] -sticky {}
+ style element create Scrollbar.downarrow image $Images(arrowdown-n) \
+ -map [list pressed $Images(arrowdown-p)] -sticky {}
+ style element create Scrollbar.leftarrow image $Images(arrowleft-n) \
+ -map [list pressed $Images(arrowleft-p)] -sticky {}
+ style element create Scrollbar.rightarrow image $Images(arrowright-n) \
+ -map [list pressed $Images(arrowright-p)] -sticky {}
+
+ #
+ # Settings:
+ #
+ style default TButton -width -10
+ style default TNotebook.Tab -padding {6 2 6 2}
+ style default TLabelframe -borderwidth 2 -relief groove
+
+} }
+
diff --git a/jni/ruby/ext/tk/sample/tkextlib/tile/themes/plastik/plastik/arrowdown-n.gif b/jni/ruby/ext/tk/sample/tkextlib/tile/themes/plastik/plastik/arrowdown-n.gif
new file mode 100644
index 0000000..d914e7a
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkextlib/tile/themes/plastik/plastik/arrowdown-n.gif
Binary files differ
diff --git a/jni/ruby/ext/tk/sample/tkextlib/tile/themes/plastik/plastik/arrowdown-p.gif b/jni/ruby/ext/tk/sample/tkextlib/tile/themes/plastik/plastik/arrowdown-p.gif
new file mode 100644
index 0000000..abffaa4
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkextlib/tile/themes/plastik/plastik/arrowdown-p.gif
Binary files differ
diff --git a/jni/ruby/ext/tk/sample/tkextlib/tile/themes/plastik/plastik/arrowleft-n.gif b/jni/ruby/ext/tk/sample/tkextlib/tile/themes/plastik/plastik/arrowleft-n.gif
new file mode 100644
index 0000000..9939ae1
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkextlib/tile/themes/plastik/plastik/arrowleft-n.gif
Binary files differ
diff --git a/jni/ruby/ext/tk/sample/tkextlib/tile/themes/plastik/plastik/arrowleft-p.gif b/jni/ruby/ext/tk/sample/tkextlib/tile/themes/plastik/plastik/arrowleft-p.gif
new file mode 100644
index 0000000..1a45ef2
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkextlib/tile/themes/plastik/plastik/arrowleft-p.gif
Binary files differ
diff --git a/jni/ruby/ext/tk/sample/tkextlib/tile/themes/plastik/plastik/arrowright-n.gif b/jni/ruby/ext/tk/sample/tkextlib/tile/themes/plastik/plastik/arrowright-n.gif
new file mode 100644
index 0000000..f4b563f
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkextlib/tile/themes/plastik/plastik/arrowright-n.gif
Binary files differ
diff --git a/jni/ruby/ext/tk/sample/tkextlib/tile/themes/plastik/plastik/arrowright-p.gif b/jni/ruby/ext/tk/sample/tkextlib/tile/themes/plastik/plastik/arrowright-p.gif
new file mode 100644
index 0000000..5459d5e
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkextlib/tile/themes/plastik/plastik/arrowright-p.gif
Binary files differ
diff --git a/jni/ruby/ext/tk/sample/tkextlib/tile/themes/plastik/plastik/arrowup-n.gif b/jni/ruby/ext/tk/sample/tkextlib/tile/themes/plastik/plastik/arrowup-n.gif
new file mode 100644
index 0000000..118290c
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkextlib/tile/themes/plastik/plastik/arrowup-n.gif
Binary files differ
diff --git a/jni/ruby/ext/tk/sample/tkextlib/tile/themes/plastik/plastik/arrowup-p.gif b/jni/ruby/ext/tk/sample/tkextlib/tile/themes/plastik/plastik/arrowup-p.gif
new file mode 100644
index 0000000..89f9b38
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkextlib/tile/themes/plastik/plastik/arrowup-p.gif
Binary files differ
diff --git a/jni/ruby/ext/tk/sample/tkextlib/tile/themes/plastik/plastik/button-h.gif b/jni/ruby/ext/tk/sample/tkextlib/tile/themes/plastik/plastik/button-h.gif
new file mode 100644
index 0000000..548f376
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkextlib/tile/themes/plastik/plastik/button-h.gif
Binary files differ
diff --git a/jni/ruby/ext/tk/sample/tkextlib/tile/themes/plastik/plastik/button-n.gif b/jni/ruby/ext/tk/sample/tkextlib/tile/themes/plastik/plastik/button-n.gif
new file mode 100644
index 0000000..49a2590
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkextlib/tile/themes/plastik/plastik/button-n.gif
Binary files differ
diff --git a/jni/ruby/ext/tk/sample/tkextlib/tile/themes/plastik/plastik/button-p.gif b/jni/ruby/ext/tk/sample/tkextlib/tile/themes/plastik/plastik/button-p.gif
new file mode 100644
index 0000000..e83f7ed
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkextlib/tile/themes/plastik/plastik/button-p.gif
Binary files differ
diff --git a/jni/ruby/ext/tk/sample/tkextlib/tile/themes/plastik/plastik/check-hc.gif b/jni/ruby/ext/tk/sample/tkextlib/tile/themes/plastik/plastik/check-hc.gif
new file mode 100644
index 0000000..b279fa5
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkextlib/tile/themes/plastik/plastik/check-hc.gif
Binary files differ
diff --git a/jni/ruby/ext/tk/sample/tkextlib/tile/themes/plastik/plastik/check-hu.gif b/jni/ruby/ext/tk/sample/tkextlib/tile/themes/plastik/plastik/check-hu.gif
new file mode 100644
index 0000000..5b4fb4f
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkextlib/tile/themes/plastik/plastik/check-hu.gif
Binary files differ
diff --git a/jni/ruby/ext/tk/sample/tkextlib/tile/themes/plastik/plastik/check-nc.gif b/jni/ruby/ext/tk/sample/tkextlib/tile/themes/plastik/plastik/check-nc.gif
new file mode 100644
index 0000000..b139e02
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkextlib/tile/themes/plastik/plastik/check-nc.gif
Binary files differ
diff --git a/jni/ruby/ext/tk/sample/tkextlib/tile/themes/plastik/plastik/check-nu.gif b/jni/ruby/ext/tk/sample/tkextlib/tile/themes/plastik/plastik/check-nu.gif
new file mode 100644
index 0000000..fbe391f
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkextlib/tile/themes/plastik/plastik/check-nu.gif
Binary files differ
diff --git a/jni/ruby/ext/tk/sample/tkextlib/tile/themes/plastik/plastik/check-pc.gif b/jni/ruby/ext/tk/sample/tkextlib/tile/themes/plastik/plastik/check-pc.gif
new file mode 100644
index 0000000..75a3bd6
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkextlib/tile/themes/plastik/plastik/check-pc.gif
Binary files differ
diff --git a/jni/ruby/ext/tk/sample/tkextlib/tile/themes/plastik/plastik/hsb-n.gif b/jni/ruby/ext/tk/sample/tkextlib/tile/themes/plastik/plastik/hsb-n.gif
new file mode 100644
index 0000000..b8ea07e
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkextlib/tile/themes/plastik/plastik/hsb-n.gif
Binary files differ
diff --git a/jni/ruby/ext/tk/sample/tkextlib/tile/themes/plastik/plastik/hslider-n.gif b/jni/ruby/ext/tk/sample/tkextlib/tile/themes/plastik/plastik/hslider-n.gif
new file mode 100644
index 0000000..ce8f284
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkextlib/tile/themes/plastik/plastik/hslider-n.gif
Binary files differ
diff --git a/jni/ruby/ext/tk/sample/tkextlib/tile/themes/plastik/plastik/radio-hc.gif b/jni/ruby/ext/tk/sample/tkextlib/tile/themes/plastik/plastik/radio-hc.gif
new file mode 100644
index 0000000..3391771
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkextlib/tile/themes/plastik/plastik/radio-hc.gif
Binary files differ
diff --git a/jni/ruby/ext/tk/sample/tkextlib/tile/themes/plastik/plastik/radio-hu.gif b/jni/ruby/ext/tk/sample/tkextlib/tile/themes/plastik/plastik/radio-hu.gif
new file mode 100644
index 0000000..88925d0
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkextlib/tile/themes/plastik/plastik/radio-hu.gif
Binary files differ
diff --git a/jni/ruby/ext/tk/sample/tkextlib/tile/themes/plastik/plastik/radio-nc.gif b/jni/ruby/ext/tk/sample/tkextlib/tile/themes/plastik/plastik/radio-nc.gif
new file mode 100644
index 0000000..f8723d3
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkextlib/tile/themes/plastik/plastik/radio-nc.gif
Binary files differ
diff --git a/jni/ruby/ext/tk/sample/tkextlib/tile/themes/plastik/plastik/radio-nu.gif b/jni/ruby/ext/tk/sample/tkextlib/tile/themes/plastik/plastik/radio-nu.gif
new file mode 100644
index 0000000..fb5140e
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkextlib/tile/themes/plastik/plastik/radio-nu.gif
Binary files differ
diff --git a/jni/ruby/ext/tk/sample/tkextlib/tile/themes/plastik/plastik/radio-pc.gif b/jni/ruby/ext/tk/sample/tkextlib/tile/themes/plastik/plastik/radio-pc.gif
new file mode 100644
index 0000000..176225d
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkextlib/tile/themes/plastik/plastik/radio-pc.gif
Binary files differ
diff --git a/jni/ruby/ext/tk/sample/tkextlib/tile/themes/plastik/plastik/vsb-n.gif b/jni/ruby/ext/tk/sample/tkextlib/tile/themes/plastik/plastik/vsb-n.gif
new file mode 100644
index 0000000..85bac45
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkextlib/tile/themes/plastik/plastik/vsb-n.gif
Binary files differ
diff --git a/jni/ruby/ext/tk/sample/tkextlib/tile/themes/plastik/plastik/vslider-n.gif b/jni/ruby/ext/tk/sample/tkextlib/tile/themes/plastik/plastik/vslider-n.gif
new file mode 100644
index 0000000..cf887f9
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkextlib/tile/themes/plastik/plastik/vslider-n.gif
Binary files differ
diff --git a/jni/ruby/ext/tk/sample/tkextlib/tile/toolbutton.tcl b/jni/ruby/ext/tk/sample/tkextlib/tile/toolbutton.tcl
new file mode 100644
index 0000000..a8d9080
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkextlib/tile/toolbutton.tcl
@@ -0,0 +1,152 @@
+#
+# $Id: toolbutton.tcl 31689 2011-05-22 09:26:02Z nobu $
+#
+# Demonstration of custom widget styles.
+#
+
+#
+# ~ BACKGROUND
+#
+# Checkbuttons in toolbars have a very different appearance
+# than regular checkbuttons: there's no indicator, they
+# "pop up" when the mouse is over them, and they appear sunken
+# when selected.
+#
+# Tk added partial support for toolbar-style buttons in 8.4
+# with the "-overrelief" option, and TIP #82 added further
+# support with the "-offrelief" option. So to get a toolbar-style
+# checkbutton, you can configure it with:
+#
+# checkbutton .cb \
+# -indicatoron false -selectcolor {} -relief flat -overrelief raised
+#
+# Behind the scenes, Tk has a lot of rather complicated logic
+# to implement this checkbutton style; see library/button.tcl,
+# generic/tkButton.c, and the platform-specific files unix/tkUnixButton.c
+# et al. for the full details.
+#
+# The tile widget set has a better way: custom styles.
+# Since the appearance is completely controlled by the theme engine,
+# we can define a new "Toolbutton" style and just use:
+#
+# checkbutton .cb -style Toolbutton
+#
+#
+# ~ DEMONSTRATION
+#
+# The tile built-in themes (default, "alt", windows, and XP)
+# already include Toolbutton styles. This script will add
+# them to the "step" and "blue" themes as a demonstration.
+#
+# (Note: Pushbuttons and radiobuttons can also use the "Toolbutton"
+# style; see demo.tcl.)
+#
+
+style theme settings "step" {
+
+#
+# First, we use [style layout] to define what elements to
+# use and how they're arranged. Toolbuttons are pretty
+# simple, consisting of a border, some internal padding,
+# and a label. (See also the TScrollbar layout definition
+# in demos/blue.tcl for a more complicated layout spec.)
+#
+ style layout Toolbutton {
+ Toolbutton.background
+ Toolbutton.border -children {
+ Toolbutton.padding -children {
+ Toolbutton.label
+ }
+ }
+ }
+
+# (Actually the above isn't strictly necessary, since the same layout
+# is defined in the default theme; we could have inherited it
+# instead.)
+#
+# Next, specify default values for element options.
+# For many options (like -background), the defaults
+# inherited from the parent style are sufficient.
+#
+ style default Toolbutton -width 0 -padding 1 -relief flat -borderwidth 2
+
+#
+# Finally, use [style map] to specify state-specific
+# resource values. We want a flat relief if the widget is
+# disabled, sunken if it's selected (on) or pressed,
+# and raised when it's active (the mouse pointer is
+# over the widget). Each state-value pair is checked
+# in order, and the first matching state takes precedence.
+#
+ style map Toolbutton -relief {
+ disabled flat
+ selected sunken
+ pressed sunken
+ active raised
+ }
+}
+
+#
+# Now for the "blue" theme. (Since the purpose of this
+# theme is to show what *can* be done, not necessarily what
+# *should* be done, the following makes some questionable
+# design decisions from an aesthetic standpoint.)
+#
+if {![catch {package require tile::theme::blue}]} {
+style theme settings "blue" {
+
+ #
+ # Default values:
+ #
+ style default Toolbutton \
+ -width 0 -relief flat -borderwidth 2 \
+ -background #6699CC -foreground #000000 ;
+
+ #
+ # Configure state-specific values for -relief, as before:
+ #
+ style map Toolbutton -relief {
+ disabled flat
+ selected sunken
+ pressed sunken
+ active raised
+ }
+
+ #
+ # Adjust the -padding at the same time, to enhance
+ # the raised/sunken illusion:
+ #
+ style default Toolbutton -padding 4
+ style map Toolbutton -padding {
+ disabled {4}
+ selected {6 6 2 2}
+ pressed {6 6 2 2}
+ active {2 2 6 6}
+ }
+
+ #
+ # ... and change the foreground and background colors
+ # when the mouse cursor is over the widget:
+ #
+ style map Toolbutton -background {
+ active #008800
+ } -foreground {
+ active #FFFFFF
+ }
+}
+
+}
+
+#
+# ~ A final note:
+#
+# TIP #82 also says: "When -indicatoron is off and the button itself
+# is on, the relief continues to be hard-coded to sunken. For symmetry,
+# we might consider adding another -onrelief option to cover this
+# case. But it is difficult to imagine ever wanting to change the
+# value of -onrelief so it has been omitted from this TIP.
+# If there as strong desire to have -onrelief, it can be added later."
+# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+#
+# The Tile project aims to make sure that this never needs to happen.
+#
diff --git a/jni/ruby/ext/tk/sample/tkextlib/tkHTML/Orig_COPYRIGHT.txt b/jni/ruby/ext/tk/sample/tkextlib/tkHTML/Orig_COPYRIGHT.txt
new file mode 100644
index 0000000..2b3757b
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkextlib/tkHTML/Orig_COPYRIGHT.txt
@@ -0,0 +1,12 @@
+
+The following text is the original 'COPYRIGHT' file of tkHTML.
+
+-----------------------------------------------------------------------
+Most of the source code for the Tk Html widget has been place in the
+public domain. You can do with it whatever you want. However, some
+files have been copied from other sources and contain copyrights.
+A copyright notice appears separately at the top of each source file.
+-----------------------------------------------------------------------
+
+In this sample, HTML documents are quoted in the 'tests' directory of
+tkHTML source tree. There were no copyright notice in the directory.
diff --git a/jni/ruby/ext/tk/sample/tkextlib/tkHTML/README b/jni/ruby/ext/tk/sample/tkextlib/tkHTML/README
new file mode 100644
index 0000000..0b9f799
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkextlib/tkHTML/README
@@ -0,0 +1,12 @@
+
+ [ TkHtml widget example ]
+
+The directory page1 -- page4 are referd from "test" directory of
+original TkHtml extension's source archive.
+( see http://www.hwaci.com/sw/tkhtml/index.html )
+
+You can see the HTML documents on the 'hv.rb' or 'ss.rb' sample script.
+
+ e.g.
+ LD_LIBRARY_PATH=/usr/local/ActiveTcl/lib:$LD_LIBRARY_PATH /usr/local/bin/ruby ./hv.rb page1/index.html
+
diff --git a/jni/ruby/ext/tk/sample/tkextlib/tkHTML/hv.rb b/jni/ruby/ext/tk/sample/tkextlib/tkHTML/hv.rb
new file mode 100644
index 0000000..920eb15
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkextlib/tkHTML/hv.rb
@@ -0,0 +1,313 @@
+#!/usr/bin/env ruby
+#
+# This script implements the "hv" application. Type "hv FILE" to
+# view FILE as HTML.
+#
+# This application is used for testing the HTML widget. It can
+# also server as an example of how to use the HTML widget.
+#
+require 'tk'
+require 'tkextlib/tkHTML'
+
+root = TkRoot.new(:title=>'HTML File Viewer', :iconname=>'HV')
+
+file = ARGV[0]
+
+#
+# These images are used in place of GIFs or of form elements
+#
+biggray = TkPhotoImage.new(:data=><<'EOD')
+ R0lGODdhPAA+APAAALi4uAAAACwAAAAAPAA+AAACQISPqcvtD6OctNqLs968+w+G4kiW5omm
+ 6sq27gvH8kzX9o3n+s73/g8MCofEovGITCqXzKbzCY1Kp9Sq9YrNFgsAO///
+EOD
+
+smgray = TkPhotoImage.new(:data=><<'EOD')
+ R0lGODdhOAAYAPAAALi4uAAAACwAAAAAOAAYAAACI4SPqcvtD6OctNqLs968+w+G4kiW5omm
+ 6sq27gvH8kzX9m0VADv/
+EOD
+
+nogifbig = TkPhotoImage.new(:data=><<'EOD')
+ R0lGODdhJAAkAPEAAACQkADQ0PgAAAAAACwAAAAAJAAkAAACmISPqcsQD6OcdJqKM71PeK15
+ AsSJH0iZY1CqqKSurfsGsex08XuTuU7L9HywHWZILAaVJssvgoREk5PolFo1XrHZ29IZ8oo0
+ HKEYVDYbyc/jFhz2otvdcyZdF68qeKh2DZd3AtS0QWcDSDgWKJXY+MXS9qY4+JA2+Vho+YPp
+ FzSjiTIEWslDQ1rDhPOY2sXVOgeb2kBbu1AAADv/
+EOD
+
+nogifsm = TkPhotoImage.new(:data=><<'EOD')
+ R0lGODdhEAAQAPEAAACQkADQ0PgAAAAAACwAAAAAEAAQAAACNISPacHtD4IQz80QJ60as25d
+ 3idKZdR0IIOm2ta0Lhw/Lz2S1JqvK8ozbTKlEIVYceWSjwIAO///
+EOD
+
+#
+# define variables
+#
+ul_hyper = TkVariable.new(0)
+show_tbl = TkVariable.new(0)
+show_img = TkVariable.new(1)
+
+#
+# A font chooser routine.
+#
+# html[:fontcommand] = pick_font
+pick_font = proc{|size, attrs|
+ puts "FontCmd: #{size} #{attrs}"
+ [ ((attrs =~ /fixed/)? 'courier': 'charter'),
+ (12 * (1.2**(size.to_f - 4.0))).to_i,
+ ((attrs =~ /italic/)? 'italic': 'roman'),
+ ((attrs =~ /bold/)? 'bold': 'normal') ].join(' ')
+}
+
+#
+# This routine is called for each form element
+#
+form_cmd = proc{|n, cmd, style, *args|
+ # puts "FormCmd: $n $cmd $args"
+ case cmd
+ when 'select', 'textarea', 'input'
+ TkLabel.new(:widgetname=>args[0], :image=>nogifsm)
+ end
+}
+
+#
+# This routine is called for every <IMG> markup
+#
+images = {}
+old_imgs = {}
+big_imgs = {}
+
+hotkey = {}
+
+move_big_image = proc{|b|
+ if big_imgs.key?(b)
+ b.copy(big_imgs[b])
+ big_imgs[b].delete
+ big_imgs.delete(b)
+ Tk.update
+ end
+}
+
+image_cmd = proc{|*args|
+ if show_img.bool
+ smgray
+ else
+ fn = args[0]
+
+ if old_imgs.key?(fn)
+ images[fn] = old_imgs[fn]
+ old_imgs.delete(fn)
+ images[fn]
+
+ else
+ begin
+ img = TkPhotoImage.new(:file=>fn)
+ rescue
+ smgray
+ else
+ if img.width * img.height > 20000
+ b = TkPhotoImage.new(:width=>img.width, :height=>img.height)
+ big_imgs[b] = img
+ img = b
+ Tk.after_idle(proc{ move_big_image.call(b) })
+ end
+
+ images[fn] = img
+ img
+ end
+ end
+ end
+}
+
+#
+# This routine is called for every <SCRIPT> markup
+#
+script_cmd = proc{|*args|
+ # puts "ScriptCmd: #{args.inspect}"
+}
+
+# This routine is called for every <APPLET> markup
+#
+applet_cmd = proc{|w, arglist|
+ # puts "AppletCmd: w=#{w} arglist=#{arglist}"
+ TkLabel.new(w, :text=>"The Applet #{w}", :bd=>2, :relief=>raised)
+}
+
+#
+# Construct the main HTML viewer
+#
+html = Tk::HTML_Widget.new(:padx=>5, :pady=>9,
+ :formcommand=>form_cmd,
+ :imagecommand=>image_cmd,
+ :scriptcommand=>script_cmd,
+ :appletcommand=>applet_cmd,
+ :underlinehyperlinks=>0,
+ :bg=>'white', :tablerelief=>:raised)
+vscr = html.yscrollbar(TkScrollbar.new)
+hscr = html.xscrollbar(TkScrollbar.new)
+
+Tk.grid(html, vscr, :sticky=>:news)
+Tk.grid(hscr, :sticky=>:ew)
+Tk.root.grid_columnconfigure(0, :weight=>1)
+Tk.root.grid_columnconfigure(1, :weight=>0)
+Tk.root.grid_rowconfigure(0, :weight=>1)
+Tk.root.grid_rowconfigure(1, :weight=>0)
+
+#
+# This procedure is called when the user clicks on a hyperlink.
+#
+priv = {}
+last_file = ''
+
+# Read a file
+#
+read_file = proc{|name|
+ begin
+ fp = open(name, 'r')
+ ret = fp.read(File.size(name))
+ rescue
+ ret = nil
+ fp = nil
+ Tk.messageBox(:icon=>'error', :message=>"fail to open '#{name}'",
+ :type=>:ok)
+ ensure
+ fp.close if fp
+ end
+ ret
+}
+
+# Clear the screen.
+#
+clear_screen = proc{
+ html.clear
+ old_imgs.clear
+ big_imgs.clear
+ hotkey.clear
+ images.each{|k, v| old_imgs[k] = v }
+ images.clear
+}
+
+# Load a file into the HTML widget
+#
+load_file = proc{|name|
+ if (doc = read_file.call(name))
+ clear_screen.call
+ last_file = name
+ html.configure(:base=>name)
+ html.parse(doc)
+ old_imgs.clear
+ end
+}
+
+href_binding = proc{|x, y|
+ # koba & dg marking text
+ html.selection_clear
+ priv['mark'] = "@#{x},#{y}"
+ lst = html.href(x, y)
+
+ unless lst.size.zero?
+ lnk, target = lst
+
+ if lnk != ""
+ if lnk =~ /^#{last_file}#(.*)$/
+ html.yview($1)
+ else
+ load_file.call(lnk)
+ end
+ end
+ end
+}
+html.clipping_window.bind('1', href_binding, '%x %y')
+
+# marking text with the mouse and copying to the clipboard just with tkhtml2.0 working
+html.clipping_window.bind('B1-Motion', proc{|w, x, y|
+ w.selection_set(priv['mark'], "@#{x},#{y}")
+ TkClipboard.clear
+ # avoid tkhtml0.0 errors
+ # anyone can fix this for tkhtml0.0
+ begin
+ TkClipboard.append(TkSelection.get)
+ rescue
+ end
+ }, '%W %x %y')
+
+# This procedure is called when the user selects the File/Open
+# menu option.
+#
+last_dir = Dir.pwd
+sel_load = proc{
+ filetypes = [
+ ['Html Files', ['.html', '.htm']],
+ ['All Files', '*']
+ ]
+
+ f = Tk.getOpenFile(:initialdir=>last_dir, :filetypes=>filetypes)
+ if f != ''
+ load_file.call(f)
+ last_dir = File.dirname(f)
+ end
+}
+
+# Refresh the current file.
+#
+refresh = proc{|*args|
+ load_file.call(last_file)
+}
+
+# This binding changes the cursor when the mouse move over
+# top of a hyperlink.
+#
+Tk::HTML_Widget::ClippingWindow.bind('Motion', proc{|w, x, y|
+ parent = w.winfo_parent
+ url = parent.href(x, y)
+ unless url.empty?
+ parent[:cursor] = 'hand2'
+ else
+ parent[:cursor] = ''
+ end
+ }, '%W %x %y')
+#
+# Setup menu
+#
+menu_spec = [
+ [['File', 0],
+ ['Open', sel_load, 0],
+ ['Refresh', refresh, 0],
+ '---',
+ ['Exit', proc{exit}, 1]],
+
+ [['View', 0],
+ ['Underline Hyperlinks', ul_hyper],
+ ['Show Table Structure', show_tbl],
+ ['Show Images', show_img]]
+]
+
+mbar = Tk.root.add_menubar(menu_spec)
+
+#
+# Setup trace
+#
+ul_hyper.trace('w', proc{
+ html[:underlinehyperlinks] = ul_hyper.value
+ refresh.call
+ })
+
+show_tbl.trace('w', proc{
+ if show_tbl.bool
+ html[:tablerelief] = :flat
+ else
+ html[:tablerelief] = :raised
+ end
+ refresh.call
+ })
+
+show_img.trace('w', refresh)
+
+# If an arguent was specified, read it into the HTML widget.
+#
+Tk.update
+if file && file != ""
+ load_file.call(file)
+end
+
+#####################################
+
+Tk.mainloop
diff --git a/jni/ruby/ext/tk/sample/tkextlib/tkHTML/page1/image1 b/jni/ruby/ext/tk/sample/tkextlib/tkHTML/page1/image1
new file mode 100644
index 0000000..31e96b6
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkextlib/tkHTML/page1/image1
Binary files differ
diff --git a/jni/ruby/ext/tk/sample/tkextlib/tkHTML/page1/image10 b/jni/ruby/ext/tk/sample/tkextlib/tkHTML/page1/image10
new file mode 100644
index 0000000..80a8f81
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkextlib/tkHTML/page1/image10
Binary files differ
diff --git a/jni/ruby/ext/tk/sample/tkextlib/tkHTML/page1/image11 b/jni/ruby/ext/tk/sample/tkextlib/tkHTML/page1/image11
new file mode 100644
index 0000000..e8cb01d
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkextlib/tkHTML/page1/image11
Binary files differ
diff --git a/jni/ruby/ext/tk/sample/tkextlib/tkHTML/page1/image12 b/jni/ruby/ext/tk/sample/tkextlib/tkHTML/page1/image12
new file mode 100644
index 0000000..c317bbd
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkextlib/tkHTML/page1/image12
Binary files differ
diff --git a/jni/ruby/ext/tk/sample/tkextlib/tkHTML/page1/image13 b/jni/ruby/ext/tk/sample/tkextlib/tkHTML/page1/image13
new file mode 100644
index 0000000..ac4b3cd
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkextlib/tkHTML/page1/image13
Binary files differ
diff --git a/jni/ruby/ext/tk/sample/tkextlib/tkHTML/page1/image14 b/jni/ruby/ext/tk/sample/tkextlib/tkHTML/page1/image14
new file mode 100644
index 0000000..c3b0255
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkextlib/tkHTML/page1/image14
Binary files differ
diff --git a/jni/ruby/ext/tk/sample/tkextlib/tkHTML/page1/image2 b/jni/ruby/ext/tk/sample/tkextlib/tkHTML/page1/image2
new file mode 100644
index 0000000..da26d70
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkextlib/tkHTML/page1/image2
Binary files differ
diff --git a/jni/ruby/ext/tk/sample/tkextlib/tkHTML/page1/image3 b/jni/ruby/ext/tk/sample/tkextlib/tkHTML/page1/image3
new file mode 100644
index 0000000..d91cdfa
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkextlib/tkHTML/page1/image3
Binary files differ
diff --git a/jni/ruby/ext/tk/sample/tkextlib/tkHTML/page1/image4 b/jni/ruby/ext/tk/sample/tkextlib/tkHTML/page1/image4
new file mode 100644
index 0000000..5fdf70c
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkextlib/tkHTML/page1/image4
Binary files differ
diff --git a/jni/ruby/ext/tk/sample/tkextlib/tkHTML/page1/image5 b/jni/ruby/ext/tk/sample/tkextlib/tkHTML/page1/image5
new file mode 100644
index 0000000..67cd14d
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkextlib/tkHTML/page1/image5
Binary files differ
diff --git a/jni/ruby/ext/tk/sample/tkextlib/tkHTML/page1/image6 b/jni/ruby/ext/tk/sample/tkextlib/tkHTML/page1/image6
new file mode 100644
index 0000000..9e05aa0
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkextlib/tkHTML/page1/image6
Binary files differ
diff --git a/jni/ruby/ext/tk/sample/tkextlib/tkHTML/page1/image7 b/jni/ruby/ext/tk/sample/tkextlib/tkHTML/page1/image7
new file mode 100644
index 0000000..879656d
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkextlib/tkHTML/page1/image7
Binary files differ
diff --git a/jni/ruby/ext/tk/sample/tkextlib/tkHTML/page1/image8 b/jni/ruby/ext/tk/sample/tkextlib/tkHTML/page1/image8
new file mode 100644
index 0000000..8c647c4
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkextlib/tkHTML/page1/image8
Binary files differ
diff --git a/jni/ruby/ext/tk/sample/tkextlib/tkHTML/page1/image9 b/jni/ruby/ext/tk/sample/tkextlib/tkHTML/page1/image9
new file mode 100644
index 0000000..3a77075
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkextlib/tkHTML/page1/image9
Binary files differ
diff --git a/jni/ruby/ext/tk/sample/tkextlib/tkHTML/page1/index.html b/jni/ruby/ext/tk/sample/tkextlib/tkHTML/page1/index.html
new file mode 100644
index 0000000..af87289
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkextlib/tkHTML/page1/index.html
@@ -0,0 +1,115 @@
+<HTML><HEAD><TITLE>Slashdot:News for Nerds. Stuff that Matters.</TITLE> </HEAD>
+<BODY bgcolor="#000000" text="#000000" link="#006666" vlink="#000000">
+<center><a href="http://209.207.224.220/redir.pl?1463" target="_top"><img src="image1" alt="Click Here to enter the Sweepstakes" border="2" width="468" height="60"></a></center> <TABLE BORDER="0" CELLPADDING="0" CELLSPACING="0"><TR><TD WIDTH="1"><SCRIPT LANGUAGE="JAVASCRIPT">
+<!-- now="now" ="" new="new" Date();="Date();" tail="tail" ="" now.getTime();="now.getTime();" document.write("<IMG="document.write("<IMG" SRC="http://209.207.224.245/Slashdot/pc.gif?/slashhead.inc,"+" tail="tail" +="+" "=""" WIDTH="1" HEIGHT="1><BR>");" -->
+</SCRIPT>
+<NOSCRIPT>
+<IMG SRC="image2" WIDTH="1" HEIGHT="1">
+</NOSCRIPT></TD></TR></TABLE><P>
+<TABLE bgcolor="#FFFFFF" cellpadding="0" cellspacing="0" border="0" width="99%" align="center">
+ <TR>
+ <TD valign="top" align="left" valign="top"><A href="http://slashdot.org/"><IMG src="image3" width="275" height="72" border="0" alt="Welcome to Slashdot"></A></TD>
+ <TD><A href="http://slashdot.org/search.pl?topic=linux"><IMG SRC="image4" width="60" height="70" border="0" alt="Linux"></A></TD>
+<TD><A href="http://slashdot.org/search.pl?topic=news"><IMG SRC="image5" width="34" height="44" border="0" alt="News"></A></TD>
+<TD><A href="http://slashdot.org/search.pl?topic=usa"><IMG SRC="image6" width="80" height="61" border="0" alt="United States"></A></TD>
+<TD><A href="http://slashdot.org/search.pl?topic=ed"><IMG SRC="image7" width="87" height="64" border="0" alt="Education"></A></TD>
+<TD><A href="http://slashdot.org/search.pl?topic=space"><IMG SRC="image8" width="73" height="59" border="0" alt="Space"></A></TD>
+
+</TR></TABLE>
+<TABLE width="99%" align="center" cellpadding="0" cellspacing="0" border="0" bgcolor="#FFFFFF"><TR>
+<TD valign="top" rowspan="5"><NOBR><FONT size="2"><B>
+&nbsp;<A href="/faq.shtml">faq</A> <BR>
+&nbsp;<A href="/code.shtml">code</A> <BR>
+&nbsp;<A href="/awards.shtml">awards</A> <BR>
+&nbsp;<A href="http://Andover.Net/privacy.html">privacy</A> <BR>
+&nbsp;<A href="http://slashnet.org">slashNET</A> <BR>
+&nbsp;<A href="/search.pl">older stuff</A> <BR>
+&nbsp;<A href="http://cmdrtaco.net">rob's page</A> <BR>
+&nbsp;<A href="/users.pl?op=preferences">preferences</A> <BR>
+&nbsp;<A href="http://Andover.Net">andover.net</A> <BR>
+&nbsp;<A href="/submit.pl">submit story</A> <BR>
+&nbsp;<A href="/advertising.shtml">advertising</A> <BR>
+&nbsp;<A href="/supporters.shtml">supporters</A> <BR>
+&nbsp;<A href="/pollBooth.pl">past polls</A> <BR>
+&nbsp;<A href="/topics.shtml">topics</A> <BR>
+&nbsp;<A href="/about.shtml">about</A> <BR>
+&nbsp;<A href="/jobs.shtml">jobs</A> <BR>
+&nbsp;<A href="/hof.shtml">hof</A>
+
+</B></FONT></NOBR>
+ <P><TABLE border="0" cellpadding="1" cellspacing="0" align="center" bgcolor="#CCCCCC"><TR>
+ <TD><FONT size="2" color="#000000"><B> Sections</B></FONT></TD></TR>
+ <TR><TD><TABLE border="0" cellspacing="1" cellpadding="1" bgcolor="#FFFFFF" width="100%"><TR><TD><FONT color="#000000" size="2"><NOBR>
+1/23<BR>
+<B><A href="http://slashdot.org/index.pl?section=apache">apache</A></B><BR>
+1/29 (3)<BR>
+<B><A href="http://slashdot.org/index.pl?section=askslashdot">askslashdot</A></B><BR>
+1/27<BR>
+<B><A href="http://slashdot.org/index.pl?section=awards">awards</A></B><BR>
+1/29 (2)<BR>
+<B><A href="http://slashdot.org/index.pl?section=books">books</A></B><BR>
+1/27<BR>
+<B><A href="http://slashdot.org/index.pl?section=bsd">bsd</A></B><BR>
+1/28 (2)<BR>
+<B><A href="http://slashdot.org/index.pl?section=features">features</A></B><BR>
+1/28 (2)<BR>
+<B><A href="http://slashdot.org/index.pl?section=interviews">interviews</A></B><BR>
+1/19<BR>
+<B><A href="http://slashdot.org/index.pl?section=radio">radio</A></B><BR>
+1/27 (2)<BR>
+<B><A href="http://slashdot.org/index.pl?section=science">science</A></B><BR>
+1/28 (3)<BR>
+<B><A href="http://slashdot.org/index.pl?section=yro">yro</A></B><BR> </NOBR></FONT></TD></TR></TABLE><TR>
+ <TD><A href="http://andover.net"><FONT size="2" color="#000000"><B>Andover.Net</B></FONT></A></TD></TR>
+ <TR><TD><TABLE border="0" cellspacing="1" cellpadding="1" bgcolor="#FFFFFF"><TR><TD>
+<FONT color="#000000" size="2"><NOBR><A href="http://www.andovernews.com">AndoverNews</A><BR><A href="http://www.askreggie.com">Ask Reggie</A><BR><A href="http://www.davecentral.com">DaveCentral</A><BR><A href="http://www.freecode.com">FreeCode</A><BR><A href="http://www.mediabuilder.com">MediaBuilder</A><BR> </NOBR></FONT></TD></TR></TABLE></TD></TR></TABLE></P>
+ <P></P>
+</TD><TD valign="top" align="left"><FONT color="#000000"> <TABLE width="99%" cellpadding="0" cellspacing="0" border="0"><TR><TD valign="top" bgcolor="#006666"><IMG src="image9" width="13" height="16" alt="" align="top"><FONT size="4" color="#FFFFFF" face="arial,helvetica"><B>Who Bought Linux.Net?</B></FONT></TD> </TR></TABLE><A href="http://slashdot.org/search.pl?topic=linux"><IMG src="image4" width="60" height="70" border="0" align="right" hspace="20" vspace="10" alt="Linux"></A> <B>Posted by <A href="http://CmdrTaco.net">CmdrTaco</A> on Saturday January 29, @10:52AM</B><BR> <FONT size="2"><B>from the this-game-again dept.</B></FONT><BR> So Fred VanKampen (who has to hold the record for most money made by reselling two domain names) e-mailed us to say that the Domain Name for 'Linux.Net' has been sold. He won't say to whom, but it supposedly will be announced at LinuxWorld next week. Of course we have no idea what he got for the entry, but the rumors were that he made several million when he sold <A href="http://www.linux.com">Linux.com</A> to <A href="http://www.valinux.com">VA Linux</A>. Hopefully he'll take me for a ride in his yacht. ;) <P><B>( </B><A href="http://slashdot.org/articles/00/01/29/0837235.shtml"><B>Read More...</B></A> | <B><A href="http://slashdot.org/article.pl?sid=00/01/29/0837235&mode=thread&threshold=0">58</A> of <A href="http://slashdot.org/article.pl?sid=00/01/29/0837235&mode=thread&threshold=-1">62</A> </B>comments <B>)</B> <P><TABLE width="99%" cellpadding="0" cellspacing="0" border="0"><TR><TD valign="top" bgcolor="#006666"><IMG src="image9" width="13" height="16" alt="" align="top"><FONT size="4" color="#FFFFFF" face="arial,helvetica"><B>Book Reviews: E-Mails from (Over?) The Edge</B></FONT></TD> </TR></TABLE><A href="http://slashdot.org/search.pl?topic=news"><IMG src="image5" width="34" height="44" border="0" align="right" hspace="20" vspace="10" alt="News"></A> <B>Posted by <A href="http://hemos.net">Hemos</A> on Saturday January 29, @10:43AM</B><BR> <FONT size="2"><B>from the touching-story dept.</B></FONT><BR> I'd like to thank the author of this book for sending it to me. Nick's written a book that's touching and endearing, and one that's well worth reading for everyone who's ever had social struggles to deal with. As well, his involvement with the fine folks of <a href="http://www.thevenue.org">TheVenue</a>. I'll warn you - it's not a tech text. But it's still worth reading. Click below to read more. <P><B>( </B><A href="http://slashdot.org/books/00/01/24/1146250.shtml"><B>Read More...</B></A> | <A href="http://slashdot.org/article.pl?sid=00/01/24/1146250&mode=nocomment">6197 bytes in body</A> | <B><A href="http://slashdot.org/article.pl?sid=00/01/24/1146250&mode=thread&threshold=0">6</A> of <A href="http://slashdot.org/article.pl?sid=00/01/24/1146250&mode=thread&threshold=-1">22</A> </B>comments <B>)</B> <P><TABLE width="99%" cellpadding="0" cellspacing="0" border="0"><TR><TD valign="top" bgcolor="#006666"><IMG src="image9" width="13" height="16" alt="" align="top"><FONT size="4" color="#FFFFFF" face="arial,helvetica"><B>Linux Kernel 2.3.41</B></FONT></TD> </TR></TABLE><A href="http://slashdot.org/search.pl?topic=linux"><IMG src="image4" width="60" height="70" border="0" align="right" hspace="20" vspace="10" alt="Linux"></A> <B>Posted by <A href="http://CmdrTaco.net">CmdrTaco</A> on Saturday January 29, @10:21AM</B><BR> <FONT size="2"><B>from the download-compile-reboot-repeat dept.</B></FONT><BR> <A href="mailto:bwhitehead@nospam.acm.org">sdriver</A> writes <I>"For those of us who enjoy *panic*, *oops*, and suddenly seeing their video BIOS... the newest version is out! Be the first on your block to submit a new patch! ;) "</I> If you don't know where to get it, you probably should stick to your warm and cuddly 2.2.x kernel *grin*. Now outta my way, I wanna crash my laptop! <P><B>( </B><A href="http://slashdot.org/articles/00/01/29/0834223.shtml"><B>Read More...</B></A> | <B><A href="http://slashdot.org/article.pl?sid=00/01/29/0834223&mode=thread&threshold=0">52</A> of <A href="http://slashdot.org/article.pl?sid=00/01/29/0834223&mode=thread&threshold=-1">57</A> </B>comments <B>)</B> <P><TABLE width="99%" cellpadding="0" cellspacing="0" border="0"><TR><TD valign="top" bgcolor="#006666"><IMG src="image9" width="13" height="16" alt="" align="top"><FONT size="4" color="#FFFFFF" face="arial,helvetica"><B>Congress Still Figuring Out E-Mail</B></FONT></TD> </TR></TABLE><A href="http://slashdot.org/search.pl?topic=usa"><IMG src="image6" width="80" height="61" border="0" align="right" hspace="20" vspace="10" alt="United States"></A> <B>Posted by <A href="mailto:roblimo@slashdot.org">Roblimo</A> on Saturday January 29, @07:28AM</B><BR> <FONT size="2"><B>from the voice-of-the-people-can-get-awfully-loud dept.</B></FONT><BR> Jett writes <I>" <A href="http://www.vote.com/">Vote.com</A> has <A href="http://www.vote.com/magazine/editorials/editorial1843752.phtml">an interesting article</A> in their Webmag Fifth Estate about how congressmen have responded to the popularity of e-mail in their daily operations. Quote: 'Of the 440 voting and non-voting House of Representatives members, 22 have no e-mail at all. Even House Speaker Dennis Hastert is wired only halfway -- his office receives e-mail, but does not respond to it. And while all U.S. senators have e-mail, they, like their House counterparts, routinely shun non-constituent mail -- even though they chair committees whose decisions affect the entire country.'"</I> <P><B>( </B><A href="http://slashdot.org/articles/00/01/28/2311232.shtml"><B>Read More...</B></A> | <B><A href="http://slashdot.org/article.pl?sid=00/01/28/2311232&mode=thread&threshold=0">66</A> of <A href="http://slashdot.org/article.pl?sid=00/01/28/2311232&mode=thread&threshold=-1">66</A> </B>comments <B>)</B> <P><TABLE width="99%" cellpadding="0" cellspacing="0" border="0"><TR><TD valign="top" bgcolor="#006666"><IMG src="image9" width="13" height="16" alt="" align="top"><FONT size="4" color="#FFFFFF" face="arial,helvetica"><B>Ask Slashdot: Sci Fi Literature 101?</B></FONT></TD> </TR></TABLE><A href="http://slashdot.org/search.pl?topic=ed"><IMG src="image7" width="87" height="64" border="0" align="right" hspace="20" vspace="10" alt="Education"></A> <B>Posted by <A href="http://exit118.com/">Cliff</A> on Saturday January 29, @06:56AM</B><BR> <FONT size="2"><B>from the recommendations-wanted dept.</B></FONT><BR> ohlaadee asks: <I>"My niece (she's 13) wants to start reading science fiction. I do too. I gave us both Asimov's </I>_The Foundation_<I>&nbsp; for Christmas. We'll read it together. I suppose we could spend the rest of our lives just reading Asimov, but I'm wondering what books and movies you folks would come up with? What does the /. recommended Science Fiction 101 list include?"</I> <P><B>( </B><A href="http://slashdot.org/askslashdot/00/01/22/1946244.shtml"><B>Read More...</B></A> | <B><A href="http://slashdot.org/article.pl?sid=00/01/22/1946244&mode=thread&threshold=0">345</A> of <A href="http://slashdot.org/article.pl?sid=00/01/22/1946244&mode=thread&threshold=-1">345</A> </B>comments <B>)</B> <P><TABLE width="99%" cellpadding="0" cellspacing="0" border="0"><TR><TD valign="top" bgcolor="#006666"><IMG src="image9" width="13" height="16" alt="" align="top"><FONT size="4" color="#FFFFFF" face="arial,helvetica"><B>Could Distributed.Net Help the Mars Polar Lander?</B></FONT></TD> </TR></TABLE><A href="http://slashdot.org/search.pl?topic=space"><IMG src="image8" width="73" height="59" border="0" align="right" hspace="20" vspace="10" alt="Space"></A> <B>Posted by <A href="mailto:roblimo@slashdot.org">Roblimo</A> on Saturday January 29, @03:35AM</B><BR> <FONT size="2"><B>from the food-for-thought dept.</B></FONT><BR> Anonymous Coward writes <I>"This official JPL <A href="http://mpfwww.jpl.nasa.gov/msp98/news/mpl000127.html">press release</A> describes the current attempt to listen for faint signals from the Mars Lander. They get three windows a day, and it takes 18 hours to process data because the signal is so weak (if it's really there). Too bad they don't have a deal with <A href="http://www.distributed.net"> distributed.net</A>."</I> Interesting thought. Is anyone at distributed.net or JPL interested in pursuing it? <P><B>( </B><A href="http://slashdot.org/articles/00/01/28/2318246.shtml"><B>Read More...</B></A> | <B><A href="http://slashdot.org/article.pl?sid=00/01/28/2318246&mode=thread&threshold=0">99</A> of <A href="http://slashdot.org/article.pl?sid=00/01/28/2318246&mode=thread&threshold=-1">102</A> </B>comments <B>)</B> <P><TABLE width="99%" cellpadding="0" cellspacing="0" border="0"><TR><TD valign="top" bgcolor="#006666"><IMG src="image9" width="13" height="16" alt="" align="top"><FONT size="4" color="#FFFFFF" face="arial,helvetica"><B>iCrave TV Loses Battle against U.S. Broadcasters</B></FONT></TD> </TR></TABLE><A href="http://slashdot.org/search.pl?topic=tv"><IMG src="image10" width="50" height="50" border="0" align="right" hspace="20" vspace="10" alt="Television"></A> <B>Posted by <A href="mailto:roblimo@slashdot.org">Roblimo</A> on Saturday January 29, @12:21AM</B><BR> <FONT size="2"><B>from the shut-down-just-before-the-super-bowl dept.</B></FONT><BR> <A href="mailto:doran@brandx.net">Doran</A> writes <I>"C|Net has <a href="http://news.cnet.com/news/0-1004-200-1535528.html">this story</a> about how the Canadian company <a href="http://www.icravetv.com">iCraveTV.com</a> has lost its latest battle in U.S. courts over whether it can rebroadcast TV signals over the Web. The broadcasters say it's theft, while iCraveTV sez it's just doing what's legal for other cable TV companies in Canada (ie. rebroadcasting TV). Of course, by framing the streaming video iCraveTV is doing more than just rebroadcasting, they're also adding more commercial content, which the broadcasters feel dilutes their TV commercials. "</I> <P><B>( </B><A href="http://slashdot.org/articles/00/01/29/0010203.shtml"><B>Read More...</B></A> | <B><A href="http://slashdot.org/article.pl?sid=00/01/29/0010203&mode=thread&threshold=0">152</A> of <A href="http://slashdot.org/article.pl?sid=00/01/29/0010203&mode=thread&threshold=-1">170</A> </B>comments <B>)</B> <P><TABLE width="99%" cellpadding="0" cellspacing="0" border="0"><TR><TD valign="top" bgcolor="#006666"><IMG src="image9" width="13" height="16" alt="" align="top"><FONT size="4" color="#FFFFFF" face="arial,helvetica"><B>Win2k Security holes found</B></FONT></TD> </TR></TABLE><A href="http://slashdot.org/search.pl?topic=microsoft"><IMG src="image11" width="75" height="55" border="0" align="right" hspace="20" vspace="10" alt="Microsoft"></A> <B>Posted by <A href="mailto:heunique@slashdot.org">HeUnique</A> on Friday January 28, @04:58PM</B><BR> <FONT size="2"><B>from the and-it's-not-even-out-yet dept.</B></FONT><BR> According to a story posted by <a href="http://www.zdnn.com">ZDNN</a>, <a href="http://www.zdnet.com/zdnn/stories/news/0,4586,2429334,00.html?chkpt=zdnntop">two security holes</a> have been found on Windows 2000, and that's even before the official release of Windows 2000! Administrators who rush to incorporate the patch from MS beware - according to one of the talkback posts on ZDNN, the patch creates a new problem with Windows 2000 news server service. <P><B>( </B><A href="http://slashdot.org/articles/00/01/28/1653228.shtml"><B>Read More...</B></A> | <B><A href="http://slashdot.org/article.pl?sid=00/01/28/1653228&mode=thread&threshold=0">510</A> of <A href="http://slashdot.org/article.pl?sid=00/01/28/1653228&mode=thread&threshold=-1">534</A> </B>comments <B>)</B> <P><TABLE width="99%" cellpadding="0" cellspacing="0" border="0"><TR><TD valign="top" bgcolor="#006666"><IMG src="image9" width="13" height="16" alt="" align="top"><FONT size="4" color="#FFFFFF" face="arial,helvetica"><B>Encryption Debate at Mitnick Trial</B></FONT></TD> </TR></TABLE><A href="http://slashdot.org/search.pl?topic=encryption"><IMG src="image12" width="80" height="70" border="0" align="right" hspace="20" vspace="10" alt="Encryption"></A> <B>Posted by <A href="http://hemos.net">Hemos</A> on Friday January 28, @03:33PM</B><BR> <FONT size="2"><B>from the gimmie-the-data dept.</B></FONT><BR> A number of people have written about <A HREF="http://nytimes.com/library/tech/00/01/cyber/cyberlaw/28law.html">the latest twist</a> in the Mitnick case. Kevin wants to get his data back, but the government is refusing to do so until he gives them the key. Apparently, the government is unable to crack the encryption that he's got on it - you'd think after having the data for five years, they'd be able to brute-force the darn thing. It's a NYT article - free login required. <P><B>( </B><A href="http://slashdot.org/articles/00/01/28/1320253.shtml"><B>Read More...</B></A> | <B><A href="http://slashdot.org/article.pl?sid=00/01/28/1320253&mode=thread&threshold=0">504</A> of <A href="http://slashdot.org/article.pl?sid=00/01/28/1320253&mode=thread&threshold=-1">521</A> </B>comments <B>)</B> <P><TABLE width="99%" cellpadding="0" cellspacing="0" border="0"><TR><TD valign="top" bgcolor="#006666"><IMG src="image9" width="13" height="16" alt="" align="top"><FONT size="4" color="#FFFFFF" face="arial,helvetica"><B>Forum: Future Ports of Games to Linux</B></FONT></TD> </TR></TABLE><A href="http://slashdot.org/search.pl?topic=games"><IMG src="image13" width="80" height="56" border="0" align="right" hspace="20" vspace="10" alt="Games"></A> <B>Posted by <A href="http://CmdrTaco.net">CmdrTaco</A> on Friday January 28, @02:26PM</B><BR> <FONT size="2"><B>from the it's-been-awhile dept.</B></FONT><BR> It's been a long time since I posted an open forum like this, but I'm curious what people think on this one. What games do you most want to see ported to Linux in the next few months? Of course, for me personally it's StarCraft and Diablo 2, but I'm curious what games have come out or are due soon that people would most like to see a port of (and note that WINE doesn't count. ;) <P><B>( </B><A href="http://slashdot.org/articles/00/01/28/1257211.shtml"><B>Read More...</B></A> | <B><A href="http://slashdot.org/article.pl?sid=00/01/28/1257211&mode=thread&threshold=0">648</A> of <A href="http://slashdot.org/article.pl?sid=00/01/28/1257211&mode=thread&threshold=-1">652</A> </B>comments <B>)</B> <P></TD><TD width="210" align="center" valign="top"><TABLE cellpadding="1" cellspacing="0" border="0" width="200" align="center"> <TR bgcolor="#006666"> <TD valign="top"><FONT size="4" color="#FFFFFF" face="arial,helvetica"><B><A HREF="/index.pl?section=features"><FONT COLOR="#FFFFFF">Features</FONT></A></B></FONT></TD> </TR><TR><TD bgcolor="#CCCCCC"><FONT color="#000000" size="2"><A href="/vote.pl">Voting has begun</A> for the $100k <A href="/index.pl?section=awards">Slashdot Beanie Awards</A>. Talk amongst yourselves and choose who deserves the cash. <P>The latest installment of <A href="http://www.thesync.com/geeks">Geeks in Space</A> is up at <A href="http://www.thesync.com">The Sync</A>. Listen to CmdrTaco, Hemos, and Nate talk about the latest events to happen - or not happen in the computer world. <P>Perhaps you are seeking Jon Katz's series of articles related to recent events in Colorado. These articles include <A href="/article.pl?sid=99/04/25/1438249">Voices from the Hellmouth</A>, <A href="/article.pl?sid=99/04/27/0310247">More Stories from the Hellmouth</A> or <A href="/article.pl?sid=99/04/29/0124247">The Price of Being Different</A>, <P>For something different, try reading a little essay <A href="/article.pl?sid=99/03/31/0137221">Thoughts from the Furnace</A> about the internet, and flame. <p> And for a bit of an amusing take on the Open Source world, check out <a href="/article.pl?sid=99/08/24/1327256&mode=thread">Open Source as an Ant Farm</a> <P><B>Update: 01/03 03:10</B> by <B><A href="http://cowboyneal.org">CowboyNeal</a></B>: <P align="right"><B><A href="/features/">Past Features</A></B> <!-- end="end" features="features" block="block" --></FONT></TD> </TR> </TABLE><P> <TABLE cellpadding="1" cellspacing="0" border="0" width="200" align="center"> <TR bgcolor="#006666"> <TD valign="top"><FONT size="4" color="#FFFFFF" face="arial,helvetica"><B><A HREF="http://slashdot.org/index.pl?section=askslashdot"><FONT COLOR="#FFFFFF">Ask Slashdot</FONT></A></B></FONT></TD> </TR><TR><TD bgcolor="#CCCCCC"><FONT color="#000000" size="2"><li><A HREF="http://slashdot.org/article.pl?sid=00/01/22/1946244">Sci Fi Literature 101?</A> <li><A HREF="http://slashdot.org/article.pl?sid=00/01/22/192226">Linux and Satellite Internet Services</A> <li><A HREF="http://slashdot.org/article.pl?sid=00/01/22/1843258">Open Defensive Patents?</A> <li><A HREF="http://slashdot.org/article.pl?sid=00/01/22/1825252">Technologies That Shaped the Last Century?</A> <li><A HREF="http://slashdot.org/article.pl?sid=00/01/22/1958212">Disk Repair Tools for Linux?</A> <li><A HREF="http://slashdot.org/article.pl?sid=00/01/22/1955215">Why Can't the Command-Line be More Standardized?</A> <li><A HREF="http://slashdot.org/article.pl?sid=00/01/22/1928235">Packet Radio Networking with PalmOS?</A> <li><A HREF="http://slashdot.org/article.pl?sid=00/01/22/1817211">Cheap Rackmount Enclosures/Systems?</A> <li><A HREF="http://slashdot.org/article.pl?sid=00/01/22/1950249">Open Source Software and Tax Breaks?</A> <li><A HREF="http://slashdot.org/article.pl?sid=00/01/22/1917207">Building an Upgradable Dual Processor System</A> <P> if you have a question for Ask Slashdot, send it to <A href="mailto:askslashdot@slashdot.org">askslashdot@slashdot.org</A></FONT></TD> </TR> </TABLE><P> <TABLE cellpadding="1" cellspacing="0" border="0" width="200" align="center"> <TR bgcolor="#006666"> <TD valign="top"><FONT size="4" color="#FFFFFF" face="arial,helvetica"><B><A HREF="/users.pl"><FONT COLOR="#FFFFFF">Slashdot Login</FONT></A></B></FONT></TD> </TR><TR><TD bgcolor="#CCCCCC"><FONT color="#000000" size="2"><FORM action="/users.pl" METHOD="POST"> <B>Nickname:</B><BR> <INPUT type="text" name="unickname" size="20" value=""><BR> <B>Password:</B><BR> <INPUT type="hidden" name="returnto" value="index.pl"> <INPUT type="password" name="upasswd" size="20"><BR> <INPUT type="submit" name="op" value="userlogin"> </FORM> Don't have an account yet? <A href="/users.pl">Go Create One</A>. A user account will allow you to customize all these <A href="/cheesyportal.shtml">nutty little boxes</A>, tailor the stories you see, as well as remember your comment viewing preferences.</FONT></TD> </TR> </TABLE><P> <TABLE cellpadding="1" cellspacing="0" border="0" width="200" align="center"> <TR bgcolor="#006666"> <TD valign="top"><FONT size="4" color="#FFFFFF" face="arial,helvetica"><B>Slashdot Poll</B></FONT></TD> </TR><TR><TD bgcolor="#CCCCCC"><FONT color="#000000" size="2"><FORM action="http://slashdot.org/pollBooth.pl"> <INPUT type="hidden" name="qid" value="techadvance"> <B>The Tech Advance I Most Want Is:</B><BR><INPUT type="radio" name="aid" value="1">Nanotechnology<BR><INPUT type="radio" name="aid" value="2">Cold Fusion<BR><INPUT type="radio" name="aid" value="3">Powerful Fuel Cells<BR><INPUT type="radio" name="aid" value="4">Hard Wiring my Body<BR><INPUT type="radio" name="aid" value="5">Universal Strong Crypto<BR><INPUT type="radio" name="aid" value="6">Interstellar Travel<BR><INPUT type="radio" name="aid" value="7">Cybernetic Body Armor<BR><INPUT type="radio" name="aid" value="8">ColecoVision<BR><INPUT type="submit" value="Vote"> [ <A href="http://slashdot.org/pollBooth.pl?qid=techadvance&aid=-1"><B>Results</B></A> | <A href="http://slashdot.org/pollBooth.pl?"><B>Polls</B></A> ] <BR>Comments:<B>656</B> | Votes:<B>29121</B></FORM> </FONT></TD> </TR> </TABLE><P> <TABLE cellpadding="1" cellspacing="0" border="0" width="200" align="center"> <TR bgcolor="#006666"> <TD valign="top"><FONT size="4" color="#FFFFFF" face="arial,helvetica"><B>Older Stuff</B></FONT></TD> </TR><TR><TD bgcolor="#CCCCCC"><FONT color="#000000" size="2"><P><B><A href="http://slashdot.org/index.pl?section=&issue=730512&mode=thread"><FONT size="4">Friday</FONT></A> January 28</B> <LI><A href="http://slashdot.org/articles/00/01/28/1110258.shtml">Abstract Programming and GPL Enforcement</A> (235) <LI><A href="http://slashdot.org/interviews/00/01/28/1225206.shtml">Interview: FreeDOS Leader Jim Hall Answers</A> (86) <LI><A href="http://slashdot.org/articles/00/01/28/116240.shtml">Open Source's Achilles Heel</A> (466) <LI><A href="http://slashdot.org/features/00/01/26/1915230.shtml">The Virtue of Communal Instincts</A> (237) <LI><A href="http://slashdot.org/articles/00/01/28/0723223.shtml">Gartner Group Debunking Open Source Myths</A> (165) <LI><A href="http://slashdot.org/yro/00/01/28/0917229.shtml">DoubleClick Taken to Court</A> (310) <LI><A href="http://slashdot.org/articles/00/01/28/0718209.shtml">Updated Slash & Server 51</A> (81) <LI><A href="http://slashdot.org/articles/00/01/28/089230.shtml">XMMS 1.0.0 Released</A> (128) <LI><A href="http://slashdot.org/askslashdot/00/01/22/192226.shtml">Linux and Satellite Internet Services</A> (138) <LI><A href="http://slashdot.org/articles/00/01/27/1811221.shtml">UN Wants to Combat Online Racism</A> (531) <P><B><A href="http://slashdot.org/index.pl?section=&issue=730511&mode=thread"><FONT size="4">Thursday</FONT></A> January 27</B> <LI><A href="http://slashdot.org/yro/00/01/27/2330205.shtml">Crackdowns, Fools and the MPAA</A> (351) <LI><A href="http://slashdot.org/articles/00/01/27/0832215.shtml">Heroes of Might and Magic III Demo Released</A> (157) <LI><A href="http://slashdot.org/science/00/01/27/1345241.shtml">Sandia Labs Venture Into Nanotechnology</A> (117) <LI><A href="http://slashdot.org/articles/00/01/27/0931237.shtml">CA Announces Program Ports to Linux</A> (195) <LI><A href="http://slashdot.org/interviews/00/01/27/1118251.shtml">Interview: Larry Augustin Finally Answers</A> (210) <LI><A href="http://slashdot.org/awards/00/01/27/0855252.shtml">Final Call for Voting in Slashdot's Beanie Awards</A> (178) <LI><A href="http://slashdot.org/features/00/01/26/197211.shtml">Transmeta Code Morphing != Just In Time</A> (449) <LI><A href="http://slashdot.org/books/00/01/24/1150256.shtml">Intrusion Detection</A> (65) <LI><A href="http://slashdot.org/science/00/01/27/0824239.shtml">Using Enzymes to Help Fight CO2 Build-Up</A> (165) <LI><A href="http://slashdot.org/articles/00/01/27/0712217.shtml">Jon Johansen on ABC World News Tonight</A> (415) <P align="right"><BR><A href="http://slashdot.org/search.pl?section=&min=30"><B>Older Articles</B></A><BR><A href="http://slashdot.org/index.pl?section=&mode=thread&issue=730512"><B>Yesterday's Edition</B></A> </FONT></TD> </TR> </TABLE><P> <TABLE cellpadding="1" cellspacing="0" border="0" width="200" align="center"> <TR bgcolor="#006666"> <TD valign="top"><FONT size="4" color="#FFFFFF" face="arial,helvetica"><B><A HREF="/index.pl?section=books"><FONT COLOR="#FFFFFF">Book Reviews</FONT></A></B></FONT></TD> </TR><TR><TD bgcolor="#CCCCCC"><FONT color="#000000" size="2"><p>Jon Katz, Resident Gasbag, has a new, very appropriate book coming out soon, <a href="http://www.thinkgeek.com">Geeks</a>. Preorder now and receive the book early. <p>For probably the best fiction read around, check out Neal Stephenson's <cite><a href="/article.pl?sid=99/06/23/139229&mode=thread">Cryptonomicon</a></cite>, an engaging read about WWII, cryptography and buried treasure. And data vaults. <p>If you've been doing a lot of work in Perl, you've probably figured out you really need <cite><a href="/article.pl?sid=99/05/10/2238254&mode=thread">Perl in a Nutshell</a></cite> or <cite><a href="/article.pl?sid=99/01/29/1035246&mode=thread">The Perl Cookbook</a></cite>. If you're still learning, grab <cite><a href="/books/older/980526096229.shtml">Programming Perl</a></cite>. <p>And if you want to learn more about how to become a better coder, grab <cite><a href="/article.pl?sid=99/06/28/1417229&mode=thread">The Unified Software Development Process</a></cite> or <cite><a href="/article.pl?sid=99/04/08/1512209&mode=thread">The Practice of Programming</cite></a> Additionally, check out <cite><a href="http://slashdot.org/article.pl?sid=99/09/16/1333202&mode=thread">Refactoring: Improving the Design of Existing Code</a></cite> . <p>Developing a large application? Grab Eric Greenberg's excellent <cite><a href="/article.pl?sid=99/07/13/1943258&mode=thread">Network Application Frameworks</cite></a>. <P>Visit <A href="/index.pl?section=books">Our Book Reviews Section</A> for more. <br> <B>Update: 11/12 05:19</B> by <B><A href="mailto:hemos@slashdot.org">H</A></B>:</FONT></TD> </TR> </TABLE><P> <TABLE cellpadding="1" cellspacing="0" border="0" width="200" align="center"> <TR bgcolor="#006666"> <TD valign="top"><FONT size="4" color="#FFFFFF" face="arial,helvetica"><B>Quick Links</B></FONT></TD> </TR><TR><TD bgcolor="#CCCCCC"><FONT color="#000000" size="2"><B>Cool Sites:</B> <LI><A href="http://www.linux.com">Linux.com</A> (What <B>is</B> Linux?) <LI><A href="http://everything.blockstackers.com">Everything</A> (Blow your Mind) <LI><A href="http://www.geekculture.com/geekycomics/Aftery2k/aftery2kmain.html">After Y2k</A> (<I>This</I> is Post-Apocalyptic?) <LI><A href="http://www.userfriendly.org">User Friendly</A> (Laugh) <LI><A href="http://themes.org">Themes.org</A> (Make X Perty) <P><B>Support Slashdot:</B> <LI><A href="http://www.thinkgeek.com">ThinkGeek</A> (Clothe Yourself in Slashdot) <LI><A href="http://cdnow.com/from=sr-302791">CDnow</A> (Support <A href="http://www.cdnow.com/gift/malda@slashdot.org">Rob's Who Habit</A>) <LI><A href="http://adfu.slashdot.org">Slashdot Advertiser Index</A></FONT></TD> </TR> </TABLE><P> <TABLE cellpadding="1" cellspacing="0" border="0" width="200" align="center"> <TR bgcolor="#006666"> <TD valign="top"><FONT size="4" color="#FFFFFF" face="arial,helvetica"><B><A HREF="http://freshmeat.net"><FONT COLOR="#FFFFFF">Freshmeat</FONT></A></B></FONT></TD> </TR><TR><TD bgcolor="#CCCCCC"><FONT color="#000000" size="2"><P><FONT size="4" color="#006666"><B>January</B></FONT><BR> <LI><A href="http://freshmeat.net/news/2000/01/29/949208399.html">We should get this out of the door now</A> <LI><A href="http://freshmeat.net/news/2000/01/29/949159642.html">Is Linux for Crazies?</A> <LI><A href="http://freshmeat.net/news/2000/01/29/949156343.html">SQN Linux 1.6</A> <LI><A href="http://freshmeat.net/news/2000/01/29/949156277.html">Limo 0.3.2</A> <LI><A href="http://freshmeat.net/news/2000/01/29/949156237.html">Fusion GS 1.3</A> <LI><A href="http://freshmeat.net/news/2000/01/29/949145887.html">MMR 1.5.4</A> <LI><A href="http://freshmeat.net/news/2000/01/29/949142835.html">KUPS 0.3.4</A> <LI><A href="http://freshmeat.net/news/2000/01/29/949142815.html">3DSE patch for XMMS 4</A> <LI><A href="http://freshmeat.net/news/2000/01/29/949139763.html">Linux 2.3.41</A> <LI><A href="http://freshmeat.net/news/2000/01/29/949139751.html">Free Code for Linux S/390</A> <FORM METHOD="post" ACTION="http://core.freshmeat.net/search.php3"> <FONT size="3" color="#006666"><B>Search Freshmeat:</B></FONT><BR> <INPUT TYPE="hidden" NAME="link" VALUE="freshmeat.net"> <INPUT TYPE="text" NAME="query"> </FORM> <P align="right"><A href="http://freshmeat.net"><B>More Meat...</B></A></FONT></TD> </TR> </TABLE><P> </FONT></TD>
+ </TR>
+ </TABLE><TABLE cellpadding="0" cellspacing="0" border="0" width="99%" align="center" bgcolor="ffffff">
+ <TR>
+ <TD colspan="4" align="center"><IMG src="image14" alt="" width="80%" height="1" hspace="10" vspace="30"></TD>
+ </TR><TR>
+ <TD align="center"><FONT size="2" face="arial,helvetica">
+ <FORM method="GET" action="http://slashdot.org/search.pl">
+ <INPUT type="name" name="query" value="" width="20" size="20" length="20">
+ <INPUT type="submit" value="Search">
+ </FORM>
+ </FONT>
+ </TD>
+ <TD bgcolor="#ffffff" width="25"> &nbsp; </TD>
+ <TD align="center">
+ <FONT size="2" face="arial,helvetica"><I>Wasn't there something about a PASCAL programmer knowing the value of
+everything and the Wirth of nothing?
+<TD>&nbsp;</TD></I></FONT>
+ </FONT>
+ </TD></TR>
+ <TR><TD colspan="4" align="center">
+ <FONT size="1" color="#006666" face="arial,helvetica">
+
+ All trademarks and copyrights on this
+ page are owned by their respective owners. Comments
+ are owned by the Poster.
+ The Rest 1997-2000 <A href="http://Andover.Net">Andover.Net</A>.
+</FONT></CENTER>
+ </TD>
+ </TR>
+ </TABLE>
+ <CENTER>
+ <FONT size="2" color="#006666">
+
+ [ <A href="http://slashdot.org/"><Font color="#ffffff">home</FONT></A> |
+ <A href="http://slashdot.org/awards.shtml"><Font color="#ffffff">awards</FONT></A> |
+ <A href="http://slashdot.org/supporters.shtml"><FONT color="#ffffff">supporters</FONT></A> |
+ <A href="http://CmdrTaco.net"><FONT color="#ffffff">rob's homepage</FONT></A> |
+ <A href="http://slashdot.org/submit.pl"><FONT color="#ffffff">contribute story</FONT></A> |
+ <A href="http://slashdot.org/search.pl"><FONT color="#ffffff">older articles</FONT></A> |
+ <A href="http://Andover.Net"><FONT color="#ffffff">Andover.Net</FONT></A> |
+ <A href="http://slashdot.org/advertising.shtml"><FONT color="#ffffff">advertising</FONT></A> |
+ <A href="http://slashdot.org/pollBooth.pl"><FONT color="#ffffff">past polls</FONT></A> |
+ <A href="http://slashdot.org/about.shtml"><FONT color="#ffffff">about</FONT></A> |
+ <A href="http://slashdot.org/faq.shtml"><FONT color="#ffffff">faq</FONT></A> ]
+ </FONT>
+ </CENTER>
+</BODY>
+</HTML>
diff --git a/jni/ruby/ext/tk/sample/tkextlib/tkHTML/page2/image1 b/jni/ruby/ext/tk/sample/tkextlib/tkHTML/page2/image1
new file mode 100644
index 0000000..2ed6ddc
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkextlib/tkHTML/page2/image1
Binary files differ
diff --git a/jni/ruby/ext/tk/sample/tkextlib/tkHTML/page2/image10 b/jni/ruby/ext/tk/sample/tkextlib/tkHTML/page2/image10
new file mode 100644
index 0000000..3021b68
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkextlib/tkHTML/page2/image10
Binary files differ
diff --git a/jni/ruby/ext/tk/sample/tkextlib/tkHTML/page2/image11 b/jni/ruby/ext/tk/sample/tkextlib/tkHTML/page2/image11
new file mode 100644
index 0000000..41d1fe3
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkextlib/tkHTML/page2/image11
Binary files differ
diff --git a/jni/ruby/ext/tk/sample/tkextlib/tkHTML/page2/image12 b/jni/ruby/ext/tk/sample/tkextlib/tkHTML/page2/image12
new file mode 100644
index 0000000..655a686
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkextlib/tkHTML/page2/image12
Binary files differ
diff --git a/jni/ruby/ext/tk/sample/tkextlib/tkHTML/page2/image13 b/jni/ruby/ext/tk/sample/tkextlib/tkHTML/page2/image13
new file mode 100644
index 0000000..97d5950
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkextlib/tkHTML/page2/image13
Binary files differ
diff --git a/jni/ruby/ext/tk/sample/tkextlib/tkHTML/page2/image14 b/jni/ruby/ext/tk/sample/tkextlib/tkHTML/page2/image14
new file mode 100644
index 0000000..6d73ad8
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkextlib/tkHTML/page2/image14
Binary files differ
diff --git a/jni/ruby/ext/tk/sample/tkextlib/tkHTML/page2/image15 b/jni/ruby/ext/tk/sample/tkextlib/tkHTML/page2/image15
new file mode 100644
index 0000000..90cc3b2
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkextlib/tkHTML/page2/image15
Binary files differ
diff --git a/jni/ruby/ext/tk/sample/tkextlib/tkHTML/page2/image16 b/jni/ruby/ext/tk/sample/tkextlib/tkHTML/page2/image16
new file mode 100644
index 0000000..93aa853
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkextlib/tkHTML/page2/image16
Binary files differ
diff --git a/jni/ruby/ext/tk/sample/tkextlib/tkHTML/page2/image17 b/jni/ruby/ext/tk/sample/tkextlib/tkHTML/page2/image17
new file mode 100644
index 0000000..f46f030
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkextlib/tkHTML/page2/image17
Binary files differ
diff --git a/jni/ruby/ext/tk/sample/tkextlib/tkHTML/page2/image18 b/jni/ruby/ext/tk/sample/tkextlib/tkHTML/page2/image18
new file mode 100644
index 0000000..3badd5e
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkextlib/tkHTML/page2/image18
Binary files differ
diff --git a/jni/ruby/ext/tk/sample/tkextlib/tkHTML/page2/image19 b/jni/ruby/ext/tk/sample/tkextlib/tkHTML/page2/image19
new file mode 100644
index 0000000..bd4f6d9
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkextlib/tkHTML/page2/image19
Binary files differ
diff --git a/jni/ruby/ext/tk/sample/tkextlib/tkHTML/page2/image2 b/jni/ruby/ext/tk/sample/tkextlib/tkHTML/page2/image2
new file mode 100644
index 0000000..7566dda
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkextlib/tkHTML/page2/image2
Binary files differ
diff --git a/jni/ruby/ext/tk/sample/tkextlib/tkHTML/page2/image20 b/jni/ruby/ext/tk/sample/tkextlib/tkHTML/page2/image20
new file mode 100644
index 0000000..358fa95
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkextlib/tkHTML/page2/image20
Binary files differ
diff --git a/jni/ruby/ext/tk/sample/tkextlib/tkHTML/page2/image21 b/jni/ruby/ext/tk/sample/tkextlib/tkHTML/page2/image21
new file mode 100644
index 0000000..c81aa52
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkextlib/tkHTML/page2/image21
Binary files differ
diff --git a/jni/ruby/ext/tk/sample/tkextlib/tkHTML/page2/image22 b/jni/ruby/ext/tk/sample/tkextlib/tkHTML/page2/image22
new file mode 100644
index 0000000..6cbd630
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkextlib/tkHTML/page2/image22
Binary files differ
diff --git a/jni/ruby/ext/tk/sample/tkextlib/tkHTML/page2/image23 b/jni/ruby/ext/tk/sample/tkextlib/tkHTML/page2/image23
new file mode 100644
index 0000000..e8173a7
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkextlib/tkHTML/page2/image23
Binary files differ
diff --git a/jni/ruby/ext/tk/sample/tkextlib/tkHTML/page2/image24 b/jni/ruby/ext/tk/sample/tkextlib/tkHTML/page2/image24
new file mode 100644
index 0000000..bffd4b4
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkextlib/tkHTML/page2/image24
Binary files differ
diff --git a/jni/ruby/ext/tk/sample/tkextlib/tkHTML/page2/image25 b/jni/ruby/ext/tk/sample/tkextlib/tkHTML/page2/image25
new file mode 100644
index 0000000..c656fa4
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkextlib/tkHTML/page2/image25
Binary files differ
diff --git a/jni/ruby/ext/tk/sample/tkextlib/tkHTML/page2/image26 b/jni/ruby/ext/tk/sample/tkextlib/tkHTML/page2/image26
new file mode 100644
index 0000000..bc93fdb
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkextlib/tkHTML/page2/image26
Binary files differ
diff --git a/jni/ruby/ext/tk/sample/tkextlib/tkHTML/page2/image27 b/jni/ruby/ext/tk/sample/tkextlib/tkHTML/page2/image27
new file mode 100644
index 0000000..6ad0eff
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkextlib/tkHTML/page2/image27
Binary files differ
diff --git a/jni/ruby/ext/tk/sample/tkextlib/tkHTML/page2/image28 b/jni/ruby/ext/tk/sample/tkextlib/tkHTML/page2/image28
new file mode 100644
index 0000000..88f0d7c
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkextlib/tkHTML/page2/image28
Binary files differ
diff --git a/jni/ruby/ext/tk/sample/tkextlib/tkHTML/page2/image29 b/jni/ruby/ext/tk/sample/tkextlib/tkHTML/page2/image29
new file mode 100644
index 0000000..e070418
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkextlib/tkHTML/page2/image29
Binary files differ
diff --git a/jni/ruby/ext/tk/sample/tkextlib/tkHTML/page2/image3 b/jni/ruby/ext/tk/sample/tkextlib/tkHTML/page2/image3
new file mode 100644
index 0000000..ac3fa33
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkextlib/tkHTML/page2/image3
Binary files differ
diff --git a/jni/ruby/ext/tk/sample/tkextlib/tkHTML/page2/image30 b/jni/ruby/ext/tk/sample/tkextlib/tkHTML/page2/image30
new file mode 100644
index 0000000..4a41950
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkextlib/tkHTML/page2/image30
Binary files differ
diff --git a/jni/ruby/ext/tk/sample/tkextlib/tkHTML/page2/image31 b/jni/ruby/ext/tk/sample/tkextlib/tkHTML/page2/image31
new file mode 100644
index 0000000..60f13ed
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkextlib/tkHTML/page2/image31
Binary files differ
diff --git a/jni/ruby/ext/tk/sample/tkextlib/tkHTML/page2/image32 b/jni/ruby/ext/tk/sample/tkextlib/tkHTML/page2/image32
new file mode 100644
index 0000000..04ddc4e
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkextlib/tkHTML/page2/image32
Binary files differ
diff --git a/jni/ruby/ext/tk/sample/tkextlib/tkHTML/page2/image33 b/jni/ruby/ext/tk/sample/tkextlib/tkHTML/page2/image33
new file mode 100644
index 0000000..c1ecfff
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkextlib/tkHTML/page2/image33
Binary files differ
diff --git a/jni/ruby/ext/tk/sample/tkextlib/tkHTML/page2/image34 b/jni/ruby/ext/tk/sample/tkextlib/tkHTML/page2/image34
new file mode 100644
index 0000000..3dfd5d7
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkextlib/tkHTML/page2/image34
Binary files differ
diff --git a/jni/ruby/ext/tk/sample/tkextlib/tkHTML/page2/image35 b/jni/ruby/ext/tk/sample/tkextlib/tkHTML/page2/image35
new file mode 100644
index 0000000..aea44f3
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkextlib/tkHTML/page2/image35
Binary files differ
diff --git a/jni/ruby/ext/tk/sample/tkextlib/tkHTML/page2/image36 b/jni/ruby/ext/tk/sample/tkextlib/tkHTML/page2/image36
new file mode 100644
index 0000000..baef0e0
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkextlib/tkHTML/page2/image36
Binary files differ
diff --git a/jni/ruby/ext/tk/sample/tkextlib/tkHTML/page2/image37 b/jni/ruby/ext/tk/sample/tkextlib/tkHTML/page2/image37
new file mode 100644
index 0000000..6c6ba52
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkextlib/tkHTML/page2/image37
Binary files differ
diff --git a/jni/ruby/ext/tk/sample/tkextlib/tkHTML/page2/image38 b/jni/ruby/ext/tk/sample/tkextlib/tkHTML/page2/image38
new file mode 100644
index 0000000..e298e04
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkextlib/tkHTML/page2/image38
Binary files differ
diff --git a/jni/ruby/ext/tk/sample/tkextlib/tkHTML/page2/image39 b/jni/ruby/ext/tk/sample/tkextlib/tkHTML/page2/image39
new file mode 100644
index 0000000..e16e2f1
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkextlib/tkHTML/page2/image39
Binary files differ
diff --git a/jni/ruby/ext/tk/sample/tkextlib/tkHTML/page2/image4 b/jni/ruby/ext/tk/sample/tkextlib/tkHTML/page2/image4
new file mode 100644
index 0000000..9e5e46b
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkextlib/tkHTML/page2/image4
Binary files differ
diff --git a/jni/ruby/ext/tk/sample/tkextlib/tkHTML/page2/image5 b/jni/ruby/ext/tk/sample/tkextlib/tkHTML/page2/image5
new file mode 100644
index 0000000..646a6d9
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkextlib/tkHTML/page2/image5
Binary files differ
diff --git a/jni/ruby/ext/tk/sample/tkextlib/tkHTML/page2/image6 b/jni/ruby/ext/tk/sample/tkextlib/tkHTML/page2/image6
new file mode 100644
index 0000000..7df417c
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkextlib/tkHTML/page2/image6
Binary files differ
diff --git a/jni/ruby/ext/tk/sample/tkextlib/tkHTML/page2/image7 b/jni/ruby/ext/tk/sample/tkextlib/tkHTML/page2/image7
new file mode 100644
index 0000000..0e6ac10
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkextlib/tkHTML/page2/image7
Binary files differ
diff --git a/jni/ruby/ext/tk/sample/tkextlib/tkHTML/page2/image8 b/jni/ruby/ext/tk/sample/tkextlib/tkHTML/page2/image8
new file mode 100644
index 0000000..ba7fb47
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkextlib/tkHTML/page2/image8
Binary files differ
diff --git a/jni/ruby/ext/tk/sample/tkextlib/tkHTML/page2/image9 b/jni/ruby/ext/tk/sample/tkextlib/tkHTML/page2/image9
new file mode 100644
index 0000000..b1cad73
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkextlib/tkHTML/page2/image9
Binary files differ
diff --git a/jni/ruby/ext/tk/sample/tkextlib/tkHTML/page2/index.html b/jni/ruby/ext/tk/sample/tkextlib/tkHTML/page2/index.html
new file mode 100644
index 0000000..1c67be6
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkextlib/tkHTML/page2/index.html
@@ -0,0 +1,433 @@
+<html>
+<head>
+ <title>Tcl Resource Center</title>
+</head>
+
+<body bgcolor="white" text="black">
+
+ <!-- MenuTopLevel Resource Software Extensions -->
+ <table border="0" cellpadding="0" cellspacing="0">
+ <tr>
+ <td width="120" valign="TOP"><a href="/"><img src="image1" width="120" height="79" alt="Scriptics" border="0"></a></td>
+ <td valign="top" width="548">
+
+ <!-- Table to hold tabs -->
+ <table cellpadding="0" cellspacing="0" border="0" width="548">
+ <tr>
+ <td valign="top" align="right" colspan="15" width="548"><a name="TOP"><img src="image2" width="548" height="9" alt="Tcl/Tk" border="0"></a></td>
+ </tr>
+ <tr>
+ <td valign="top" align="right" colspan="15" width="548"><img src="image3" width="482" height="34" alt="Scripting Solutions for eBusiness Integration" border="0"></td>
+ </tr>
+ <tr>
+ <td width="18" valign="TOP"><img src="image4" width="18" height="36" alt="" border="0"></td>
+ <td width="58"><a href="/products/" onMouseOver="msover(4, 'http://images.scriptics.com/images/ProductsMouseOff.gif') ; return true ;" onMouseOut="msover(4, 'http://images.scriptics.com/images/ProductsOff.gif') ; return true ;"><img src="image5" width="58" height="36" alt="Products" border="0"></a></td>
+ <td width="14" valign="TOP"><img src="image6" width="14" height="36" alt="" border="0"></td>
+ <td width="69"><a href="/customers/" onMouseOver="msover(6, 'http://images.scriptics.com/images/CustomersMouseOff.gif') ; return true ;" onMouseOut="msover(6, 'http://images.scriptics.com/images/CustomersOff.gif') ; return true ;"><img src="image7" width="69" height="36" alt="Customers" border="0"></a></td>
+ <td width="14" valign="TOP"><img src="image6" width="14" height="36" alt="" border="0"></td>
+ <td width="60"><a href="/partners/" onMouseOver="msover(8, 'http://images.scriptics.com/images/PartnersMouseOff.gif') ; return true ;" onMouseOut="msover(8, 'http://images.scriptics.com/images/PartnersOff.gif') ; return true ;"><img src="image8" width="60" height="36" alt="Partners" border="0"></a></td>
+ <td width="14" valign="TOP"><img src="image6" width="14" height="36" alt="" border="0"></td>
+ <td width="56"><a href="/services/" onMouseOver="msover(10, 'http://images.scriptics.com/images/ServicesMouseOff.gif') ; return true ;" onMouseOut="msover(10, 'http://images.scriptics.com/images/ServicesOff.gif') ; return true ;"><img src="image9" width="56" height="36" alt="Services" border="0"></a></td>
+ <td width="14" valign="TOP"><img src="image10" width="14" height="36" alt="" border="0"></td>
+ <td width="88"><a href="/resource/" onMouseOver="msover(12, 'http://images.scriptics.com/images/ResourceMouseOn.gif') ; return true ;" onMouseOut="msover(12, 'http://images.scriptics.com/images/ResourceOn.gif') ; return true ;"><img src="image11" width="88" height="36" alt="Tcl Resources" border="0"></a></td>
+ <td width="14" valign="TOP"><img src="image12" width="14" height="36" alt="" border="0"></td>
+ <td width="57"><a href="/company/" onMouseOver="msover(14, 'http://images.scriptics.com/images/CompanyMouseOff.gif') ; return true ;" onMouseOut="msover(14, 'http://images.scriptics.com/images/CompanyOff.gif') ; return true ;"><img src="image13" width="57" height="36" alt="Company" border="0"></a></td>
+ <td width="8" valign="TOP"><img src="image14" width="8" height="36" alt="" border="0"></td>
+ <td width="50" valign="TOP"><img src="image15" width="50" height="36" alt="" border="0"></td>
+ <td width="14" valign="TOP"><img src="image16" width="14" height="36" alt="" border="0"></td>
+ </tr>
+ </table>
+ </td>
+ </tr>
+ </table> <script language="Javascript">
+ <!--
+ function msover(num, file )
+ {
+ old = (((navigator.appName=='Netscape') &&
+ (parseInt(navigator.appVersion)<=3.0 )))
+ if ( !old ) {
+ document.images[num].src=file
+ }
+ }
+ //-->
+ </SCRIPT>
+
+<!-- MenuSubLevel Resource Software Extensions Tk -->
+
+<table cellpadding="0" cellspacing="0" border="0">
+
+<!-- Left Hand Column-->
+
+<tr><td valign="top" width="120"><table cellpadding="0" cellspacing="0" border="0" width="120">
+ <tr>
+ <td width="120" valign="TOP"><img src="image17" width="120" height="4" alt="" border="0"></td>
+ </tr>
+ <tr>
+ <td width="120" valign="TOP"><a href="/resource/software/"><img src="image18" width="120" height="11" alt="Software" border="0"></a></td>
+ </tr>
+ <tr>
+ <td width="120" valign="TOP"><img src="image19" width="120" height="4" alt="" border="0"></td>
+ </tr>
+ <tr>
+ <td width="120" valign="TOP"><a href="/resource/software/tcltk/"><img src="image20" width="120" height="11" alt="Tcl/Tk Core" border="0"></a></td>
+ </tr>
+ <tr>
+ <td width="120" valign="TOP"><img src="image19" width="120" height="4" alt="" border="0"></td>
+ </tr>
+ <tr>
+ <td width="120" valign="TOP"><a href="/resource/software/applications/"><img src="image21" width="120" height="11" alt="Applications" border="0"></a></td>
+ </tr>
+ <tr>
+ <td width="120" valign="TOP"><img src="image22" width="120" height="4" alt="" border="0"></td>
+ </tr>
+ <tr>
+ <td width="120" valign="TOP"><a href="/resource/software/extensions/"><img src="image23" width="120" height="11" alt="Extensions" border="0"></a></td>
+ </tr>
+ <tr>
+ <td width="120" valign="TOP"><img src="image24" width="120" height="6" alt="" border="0"></td>
+ </tr>
+ <tr>
+ <td width="120" valign="TOP"><a href="/resource/software/patches/"><img src="image25" width="120" height="11" alt="Patches" border="0"></a></td>
+ </tr>
+ <tr>
+ <td width="120" valign="TOP"><img src="image19" width="120" height="4" alt="" border="0"></td>
+ </tr>
+ <tr>
+ <td width="120" valign="TOP"><a href="/resource/software/java/"><img src="image26" width="120" height="11" alt="Tcl &amp; Java" border="0"></a></td>
+ </tr>
+ <tr>
+ <td width="120" valign="TOP"><img src="image19" width="120" height="4" alt="" border="0"></td>
+ </tr>
+ <tr>
+ <td width="120" valign="TOP"><a href="/resource/software/ports/"><img src="image27" width="120" height="11" alt="Tcl/Tk Ports" border="0"></a></td>
+ </tr>
+ <tr>
+ <td width="120" valign="TOP"><img src="image19" width="120" height="4" alt="" border="0"></td>
+ </tr>
+ <tr>
+ <td width="120" valign="TOP"><a href="/resource/software/tools/"><img src="image28" width="120" height="11" alt="Tools" border="0"></a></td>
+ </tr>
+ <tr>
+ <td width="120" valign="TOP"><img src="image29" width="120" height="6" alt="" border="0"></td>
+ </tr>
+ <tr>
+ <td width="120" valign="TOP"><a href="/resource/doc/"><img src="image30" width="120" height="11" alt="Documentation" border="0"></a></td>
+ </tr>
+ <tr>
+ <td width="120" valign="TOP"><img src="image31" width="120" height="5" alt="" border="0"></td>
+ </tr>
+ <tr>
+ <td width="120" valign="TOP"><a href="/resource/community/"><img src="image32" width="120" height="11" alt="Community" border="0"></a></td>
+ </tr>
+ <tr>
+ <td width="120" valign="TOP"><img src="image31" width="120" height="5" alt="" border="0"></td>
+ </tr>
+ <tr>
+ <td width="120" valign="TOP"><a href="/live/bydate"><img src="image33" width="120" height="11" alt="What's New" border="0"></a></td>
+ </tr>
+ <tr>
+ <td width="120" valign="TOP"><img src="image31" width="120" height="5" alt="" border="0"></td>
+ </tr>
+ <tr>
+ <td width="120" valign="TOP"><a href="/forms/urlnote.html"><img src="image34" width="120" height="11" alt="Add URL" border="0"></a></td>
+ </tr>
+ <tr>
+ <td width="120" valign="TOP"><img src="image31" width="120" height="5" alt="" border="0"></td>
+ </tr>
+ <tr>
+ <td width="120" valign="TOP"><a href="/live/keyword"><img src="image35" width="120" height="11" alt="Keyword Search" border="0"></a></td>
+ </tr>
+ <tr>
+ <td width="120" valign="TOP"><img src="image31" width="120" height="5" alt="" border="0"></td>
+ </tr>
+ <tr>
+ <td width="120" valign="TOP"><a href="/live/sitemap"><img src="image36" width="120" height="11" alt="Index" border="0"></a></td>
+ </tr>
+ <tr>
+ <td width="120" valign="TOP"><img src="image37" width="120" height="6" alt="" border="0"></td>
+ </tr>
+</table><!-- End Left Column --></td><!-- Right Hand Column --><td valign="top" width="548" align="left"><table cellpadding="0" cellspacing="0" border="0" width="548">
+ <tr>
+ <td width="295" valign="TOP"><img src="image38" width="295" height="42" alt="Resource" border="0"></td>
+ <td width="187" valign="bottom" align="right"><FORM action="/live/keyword"><img src="image39" width="46" height="24" alt="" border="0"><INPUT TYPE="TEXT" SIZE="10" MAXLENGTH="35" NAME="keywords"><INPUT type="IMAGE" border="0" img="img" src="http://images.scriptics.com/images/Go.gif" value="submit" width="33" height="24"></FORM>
+ </tr>
+ </table>
+ <!-- 2 Columns for spacer -->
+ <table cellpadding="0" cellspacing="0" border="0" width="548">
+ <tr>
+ <!-- Spacer Column -->
+ <td valign="top" width="10">
+ &nbsp;
+ </td>
+
+
+ <td valign="top" width="548"><font face="Geneva, Helvetica, Arial" size="2"><h1>Tcl Resource Center</h1>
+<font size="+1"><a href="/resource/">Top</a>&gt;<a href="/resource/software/" ="">Software Central</a>&gt;<a href="/resource/software/extensions/" ="">Extensions</a>&gt;Tk Widgets</font><font size="-1"><br>Viewed by name (<a href="/resource/software/extensions/tk/?sortby=date">By date</a>)</font><br>
+<p>Tk is a toolkit for building graphical user interfaces with Tcl.
+ Your Tcl/Tk scripts run on UNIX, Windows, and Macintosh.<p>
+<font face="Geneva, Helvetica, Arial"><ul></ul></font><dl>
+<dt><b><a href="http://marge.phys.washington.edu/%7Ezager/blt80-unoff-exe.zip" ="">BLT 8.0 Unofficial zip and DLL</a></b>
+<dd>This is a compiled version of BLT 8.0 "unofficial" for
+the Windows platform. <a href="/live/annotate?url=http%3a%2f%2fmarge%2ephys%2ewashington%2eedu%2f%257Ezager%2fblt80%2dunoff%2dexe%2ezip">Edit</a>
+ <i><font size="-1">(September 24, 1999 06:31)</font></i><dt><b><a href="ftp://ftp.neosoft.com/languages/tcl/sorted/unknown/blt8.0p2-unoff.tgz" ="">BLT 8.0p2 Unofficial tar file</a><a name="bltunoff"></a></b>
+<dd>This is a contributed patch to make BLT compatible with Tcl/Tk 8.0p2. While still "unofficial", it is widely used.
+ Make sure you get the 8.0p2 version because the 8.0 version does
+ not compile under windows.
+ There is also a <a href="ftp://ftp.neosoft.com/languages/sorted/devel/blt2.3-8.1.tar.gz">2.3-8.1 version</a> that has been patched to work with 8.1.
+ <a href="ftp://ftp.neosoft.com/languages/tcl/sorted/unknown/blt8.0p2-unoff.README">README file</a>. <a href="/live/annotate?url=ftp%3a%2f%2fftp%2eneosoft%2ecom%2flanguages%2ftcl%2fsorted%2funknown%2fblt8%2e0p2%2dunoff%2etgz">Edit</a>
+ <i><font size="-1">(August 30, 1999 06:38)</font></i><dt><b><a href="http://www.tcltk.com/blt/" ="">BLT Home Page</a></b>
+<dd>
+ Author <b>George Howlett</b>, Version <b>2.3</b>,
+ Works with <b>Tk 4.1 through Tk 8.1</b>
+<br><a href="ftp://ftp.tcltk.com/pub/blt/">Download</a>, <a href="ftp://ftp.tcltk.com/pub/blt/BLT2.3.tar.gz">BLT2.3.tar.gz</a>, <a href="ftp://ftp.tcltk.com/pub/blt/BLT2.4h.tar.gz">BLT2.4h.tar.gz</a>, <a href="ftp://ftp.tcltk.com/pub/blt/BLT2.4i.tar.gz">BLT2.4i.tar.gz</a>, <a href="ftp://ftp.tcltk.com/pub/blt/blt2.4i-for-8.0.exe">blt2.4i-for-8.0.exe</a>, <a href="ftp://ftp.tcltk.com/pub/blt/blt2.4i-for-8.1.exe">blt2.4i-for-8.1.exe</a><br>BLT is a set of widgets for Tk, including a graph widget,
+bar chart, drag&drop, a simple command tracer, and much more.
+The 2.4 release, which is still under development, works with 8.0
+or higher.
+There are also an "<a href="#bltunoff">unofficial</a>" release for 8.0p2
+and 8.1a2 that were not done by the author. <a href="/live/annotate?url=http%3a%2f%2fwww%2etcltk%2ecom%2fblt%2f">Edit</a>
+ <i><font size="-1">(October 26, 1999 09:43)</font></i><dt><b><a href="http://www.unifix-online.com/BWidget/index.html" ="">BWidget</a></b>
+<dd>A set of native Tk 8.x Widgets using Tcl8.x namespaces.
+The ToolKit is available under Unix/X11 and Windows.
+The BWidget(s) have a professional look&feel as in other
+well known Toolkits (Tix or Incr Widget) but the concept is
+radically different because everything is native
+so no platform compilation, no compiled extension
+library are needed. The code is 100 Pure Tcl/Tk.
+More 30 components : Notebook, PageManager, Tree, PanedWindow, ButtonBox,
+ScrollView, ComboBox, SpinBox, ListBox, SelectFont, SelectColor,
+ProgressBare ... <a href="/live/annotate?url=http%3a%2f%2fwww%2eunifix%2donline%2ecom%2fBWidget%2findex%2ehtml">Edit</a>
+ <i><font size="-1">(September 06, 1999 09:58)</font></i><dt><b><a href="http://purl.oclc.org/net/nijtmans/dash.html" ="">Dash Patch for Tk</a></b>
+<dd>This patch has many enhancements to the Tk and its canvas
+widget, including dashed lines, smoothed polygons,
+and performance enhancements. <a href="/live/annotate?url=http%3a%2f%2fpurl%2eoclc%2eorg%2fnet%2fnijtmans%2fdash%2ehtml">Edit</a>
+ <i><font size="-1">(November 21, 1999 06:33)</font></i><dt><b><a href="http://www.hwaci.com/sw/et" ="">Embedded Tk (et)</a></b>
+<dd>
+ Author <b><a href="mailto:drh@acm.org" ="">Richard Hipp</a></b>, Version <b>8.0b5</b>,
+ Works with <b>Tk 4.0, 4.1, 4.2, 8.0</b>
+<br>Download: <a href="http://www.hwaci.com/sw/et/et80b5.tar.gz">et80b5.tar.gz</a><br>Embedded Tk or ``ET'' is tool for making stand-alone executables out of a mixture of C or C++ and Tcl/Tk.
+Using ET you can invoke a short Tcl/Tk script in the middle of a C routine, or you can invoke a C routine in the
+middle of a Tcl/Tk script. ET also bundles external Tcl/Tk scripts (including the standard Tcl/Tk startup scripts)
+into the executable so that the executable can be run on another binary-compatible computer that doesn't have
+Tcl/Tk installed. <a href="/live/annotate?url=http%3a%2f%2fwww%2ehwaci%2ecom%2fsw%2fet">Edit</a>
+ <i><font size="-1">(August 19, 1999 15:35)</font></i><dt><b><a href="http://www.purl.org/net/hobbs/tcl/script/tkcon/" ="">Enhanced Tk Console (TkCon)</a></b>
+<dd>
+ Author <b><a href="mailto:jeffrey.hobbs@oen.siemens.de" ="">Jeff Hobbs</a></b>, Version <b>1.3</b>,
+ Works with <b>Tk 4.1 through Tk 8.1</b>
+<br>Download: <a href="http://www.purl.org/net/hobbs/tcl/script/tkcon/tkcon.tar.gz">tkcon.tar.gz</a><br>TkCon is a replacement for the standard console that comes with Tk (on Windows/Mac, but also works on
+
+Unix). The console itself provides many more features than the standard console. <a href="/live/annotate?url=http%3a%2f%2fwww%2epurl%2eorg%2fnet%2fhobbs%2ftcl%2fscript%2ftkcon%2f">Edit</a>
+ <i><font size="-1">(August 23, 1999 12:06)</font></i><dt><b><a href="http://www.scriptmeridian.org/projects/tk/" ="">Frontier-Tk ScriptMeridian project</a></b>
+<dd>This project seeks to integrate the Tk toolkit
+with the Frontier scripting language. <a href="/live/annotate?url=http%3a%2f%2fwww%2escriptmeridian%2eorg%2fprojects%2ftk%2f">Edit</a>
+ <i><font size="-1">(August 19, 1999 15:36)</font></i><dt><b><a href="http://purl.oclc.org/net/nijtmans/img.html" ="">Img image format extension</a></b>
+<dd>This package enhances Tk, adding support for many other Image formats:
+BMP, XBM, XPM, GIF (with transparency), PNG,
+JPEG, TIFF and postscript.
+This is implemented as a shared library that can be dynamically loaded into
+Tcl/Tk.
+ <a href="/live/annotate?url=http%3a%2f%2fpurl%2eoclc%2eorg%2fnet%2fnijtmans%2fimg%2ehtml">Edit</a>
+ <i><font size="-1">(November 21, 1999 06:35)</font></i><dt><b><a href="http://purl.oclc.org/net/oakley/tcl/mclistbox/index.html" ="">mclistbox - a multi-column listbox widget</a></b>
+<dd>mclistbox is a multi-column listbox that is
+written in pure tcl and runs on all platforms
+that support tcl/tk 8.0 or higher. This widget
+requires no other extensions; it is completely
+standalone. <a href="/live/annotate?url=http%3a%2f%2fpurl%2eoclc%2eorg%2fnet%2foakley%2ftcl%2fmclistbox%2findex%2ehtml">Edit</a>
+ <i><font size="-1">(August 19, 1999 15:37)</font></i><dt><b><a href="http://home.t-online.de/home/dshepherd/tkview.htm" ="">MFC views C++ class for embedding Tk</a></b>
+<dd>The idea of embedding Tk in MFC windows always seemed very enticing but information was sparse and contradictory - on a
+ scale between "very easy" and "not yet possible". The only thing for it was to have a go and lo, it wasn't that hard after all.
+ CTkView is a C++ class which can be used in MFC SDI or MDI applications. An instance of CTkView hosts an embedded Tk
+ toplevel widget and performs some management chores for the widget so that it can size, update and react correctly to Windows
+ events. <a href="/live/annotate?url=http%3a%2f%2fhome%2et%2donline%2ede%2fhome%2fdshepherd%2ftkview%2ehtm">Edit</a>
+ <i><font size="-1">(August 19, 1999 15:38)</font></i><dt><b><a href="http://www.cs.umd.edu/hcil/pad++" ="">Pad++</a></b>
+<dd>
+ Author <b><a href="mailto:pad-info@cs.umd.edu" ="">Ben Bederson et al</a></b>, Version <b>0.9p1</b>,
+ Works with <b>8.0</b>
+<br>Download: <a href="http://www.cs.umd.edu/hcil/pad++/download.html">download.html</a><br>Pad++ is a Tk widget that provides a Zoomable User Interface (ZUI) that supports real-time interactive zoomable graphics in a fashion similar to the Tk Canvas widget. Pad++ supports tens of thousands of objects which include text, images, graphics, portals, lenses, simple html (and more), including transparency and rotation. <a href="/live/annotate?url=http%3a%2f%2fwww%2ecs%2eumd%2eedu%2fhcil%2fpad%2b%2b">Edit</a>
+ <i><font size="-1">(August 19, 1999 15:39)</font></i><dt><b><a href="http://home.t-online.de/home/sesam.com/freeware.htm" ="">Progressbar</a></b>
+<dd>Progressbar is a megawidget written in pure tcl (ie: no compiling required - runs on all platforms Macintosh, Unix, Windows).
+Its primary purpose is to show the progress of any action in percent. <a href="/live/annotate?url=http%3a%2f%2fhome%2et%2donline%2ede%2fhome%2fsesam%2ecom%2ffreeware%2ehtm">Edit</a>
+ <i><font size="-1">(January 24, 2000 09:19)</font></i><dt><b><a href="http://jfontain.free.fr/" ="">scwoop (Simple Composite Widget Object Oriented Package)</a></b>
+<dd>Scwoop is a composite widget (also known as mega widget) extension to the great Tk widget library. Scwoop is
+entirely written in Tcl using the stooop (Simple Tcl Only Object Oriented Programming) extension. <a href="/live/annotate?url=http%3a%2f%2fjfontain%2efree%2efr%2f">Edit</a>
+ <i><font size="-1">(January 09, 2000 02:10)</font></i><dt><b><a href="http://www2.clearlight.com/~oakley/tcl/supertext.html" ="">Supertext - tk text widget with unlimited undo</a></b>
+<dd>
+ Author <b><a href="mailto:oakley@channelpoint.com" ="">Bryan Oakley</a></b>, Version <b>1.0b1</b>,
+ Works with <b>Tcl 8.0</b>
+<br>Download: <a href="http://www2.clearlight.com/~oakley/tcl/supertext.tcl">supertext.tcl</a><br>Supertext is a package that provides a tk text widget with full undo and the ability to execute procedures both before and after a text
+widget command has been processed. Supertext may be used as-is, or for the brave it may be used in place of the standard text
+widget. <a href="/live/annotate?url=http%3a%2f%2fwww2%2eclearlight%2ecom%2f%7eoakley%2ftcl%2fsupertext%2ehtml">Edit</a>
+ <i><font size="-1">(August 23, 1999 12:06)</font></i><dt><b><a href="http://www.hwaci.com/sw/tk/nbpi.html" ="">Tabbed Notebook Widget</a></b>
+<dd>
+ Author <b><a href="mailto:drh@acm.org" ="">Richard Hipp</a></b>, Version <b>1.0</b>,
+ Works with <b>Tk 4.1 or later.</b>
+<br>Download: <a href="http://www.hwaci.com/sw/tk/notebook.tcl">notebook.tcl</a><br>This implements a tabbed notebook using
+a canvas widget and embedded frames.
+This is pure Tcl
+code - not a C extension. <a href="/live/annotate?url=http%3a%2f%2fwww%2ehwaci%2ecom%2fsw%2ftk%2fnbpi%2ehtml">Edit</a>
+ <i><font size="-1">(August 23, 1999 12:08)</font></i><dt><b><a href="http://www.tcltk.com/ellson/ftp/Gdtclft2.0.README" ="">Tcl GD - graphics</a></b>
+<dd>
+ Author <b>John Ellson and Spencer Thomas</b>, Version <b>2.0</b>,
+ Works with <b>8.0 and higher</b>
+<br>Download: <a href="http://www.tcltk.com/ellson/ftp/Gdtclft2.0.tar.gz">Gdtclft2.0.tar.gz</a><br>
+ Thomas Boutell's Gd package provides a convenient way to generate
+ PNG images with a C program. If you prefer Tcl for CGI
+ applications, you'll want the TCL GD extension. <a href="/live/annotate?url=http%3a%2f%2fwww%2etcltk%2ecom%2fellson%2fftp%2fGdtclft2%2e0%2eREADME">Edit</a>
+ <i><font size="-1">(August 19, 1999 14:52)</font></i><dt><b><a href="http://www.stratasys.com/software/metagui" ="">The Meta-GUI Tools</a></b>
+<dd>The Meta-GUI tools provide a framework for quickly building full
+GUI applications. The GUI is rendered by a run-time engine
+based on a hierarchical set of definitions you provide. At the bottom
+of the hierarchy are abstract data types such as length, angle,
+string, etc., and these are used to progressively build up frames,
+dialogs, toolbars, menus, and operations. <a href="/live/annotate?url=http%3a%2f%2fwww%2estratasys%2ecom%2fsoftware%2fmetagui">Edit</a>
+ <i><font size="-1">(August 23, 1999 12:10)</font></i><dt><b><a href="http://jfontain.free.fr/" ="">Tkpiechart Home Page</a></b>
+<dd>Tkpiechart is a Tcl-only extension that allows the programmer to create and dynamically update 2D or 3D pie
+charts in a Tcl/Tk application. This uses the stooop package and builds
+pie charts on a Tk canvas. <a href="/live/annotate?url=http%3a%2f%2fjfontain%2efree%2efr%2f">Edit</a>
+ <i><font size="-1">(January 09, 2000 02:12)</font></i><dt><b><a href="http://www.cygnus.com/~irox/tkprint/" ="">TkPrint</a></b>
+<dd>TkPrint is an extension that allows you to print from a
+ Tk widget. <a href="/live/annotate?url=http%3a%2f%2fwww%2ecygnus%2ecom%2f%7eirox%2ftkprint%2f">Edit</a>
+ <i><font size="-1">(October 11, 1999 09:58)</font></i><dt><b><a href="http://www.purl.org/net/hobbs/tcl/capp/" ="">TkTable Home Page</a></b>
+<dd>The TkTable widget. The <code>table</code> command creates a
+2-dimensional grid of cells. The table can use a Tcl array variable or Tcl
+
+command for data storage and retrieval. <a href="/live/annotate?url=http%3a%2f%2fwww%2epurl%2eorg%2fnet%2fhobbs%2ftcl%2fcapp%2f">Edit</a>
+ <i><font size="-1">(November 18, 1999 09:25)</font></i><dt><b><a href="http://ftp.austintx.net/users/jatucker/TkTextmatrix/default.htm" ="">TkTextMatrix (spreadsheet)</a></b>
+<dd>
+ Author <b><a href="mailto:jatucker@austin.dsccc.com" ="">John Arthur Tucker</a></b>, Version <b>4.1</b>,
+ Works with <b>Tk 4.1</b>
+<br>Download: <a href="http://ftp.austintx.net/users/jatucker/TkTextmatrix/download.htm">download.htm</a>, <a href="http://ftp.austintx.net/users/jatucker/TkTextmatrix/textmatrix4.1.tar.gz">textmatrix4.1.tar.gz</a><br>A Tcl/Tk spreadsheet widget, TkTextmatrix, which is implemented in C++ and is
+ basically a Tk Canvas widget plus extra behavior for manipulating rows and columns of cell
+ items many times faster than with a plain Tk Canvas. It actually inserts text nearly as fast
+ as the Tk Text widget. If you work with or are interested in creating your own Tcl/Tk widgets
+ in C++, you might want to take a look at the C++ widget library included with this
+ distribution. <a href="/live/annotate?url=http%3a%2f%2fftp%2eaustintx%2enet%2fusers%2fjatucker%2fTkTextmatrix%2fdefault%2ehtm">Edit</a>
+ <i><font size="-1">(August 23, 1999 12:14)</font></i><dt><b><a href="http://www.cs.umd.edu/~bederson/Togl.html" ="">ToGL - a Tk Open GL widget</a></b>
+<dd>Togl is a Tk widget for OpenGL rendering. Togl is based on OGLTK, originally written by Benjamin Bederson at the
+University of New Mexico (who has since moved to the University of Maryland). Togl adds the new features:
+<ul>
+<li> color-index mode support including color allocation functions
+<li> support for requesting stencil, accumulation, alpha buffers, etc
+<li> multiple OpenGL drawing widgets
+<li> OpenGL extension testing from Tcl
+<li> simple, portable font support
+<li> overlay plane support
+</ul>
+Togl allows one to create and manage a special Tk/OpenGL widget with Tcl and render into it with a C program. That is,
+a typical Togl program will have Tcl code for managing the user interface and a C program for computations and
+OpenGL rendering. <a href="/live/annotate?url=http%3a%2f%2fwww%2ecs%2eumd%2eedu%2f%7ebederson%2fTogl%2ehtml">Edit</a>
+ <i><font size="-1">(August 23, 1999 12:14)</font></i><dt><b><a href="http://www.hwaci.com/sw/tk/treepi.html" ="">Tree Widget</a></b>
+<dd>This implements a tree display in a canvas widget.
+It is similar in layout to that of the
+Windows explorer file viewer. This is pure Tcl
+code - not a C extension. <a href="/live/annotate?url=http%3a%2f%2fwww%2ehwaci%2ecom%2fsw%2ftk%2ftreepi%2ehtml">Edit</a>
+ <i><font size="-1">(September 29, 1999 14:37)</font></i><dt><b><a href="http://www.du.edu/~mschwart/tcl-tk.htm" ="">Windows Extensions for Tcl/Tk (Michael Schwartz)</a></b>
+<dd>This site has pointers to several extensions specific to the
+Windows platform. The extensions provide printing,
+a MAPI interface to send email, and an interface to manipulate
+.INI files, among other things. <a href="/live/annotate?url=http%3a%2f%2fwww%2edu%2eedu%2f%7emschwart%2ftcl%2dtk%2ehtm">Edit</a>
+ <i><font size="-1">(October 07, 1999 10:50)</font></i><dt><b><a href="http://www.tcltk.com/iwidgets/" ="">[incr Widgets] Home Page</a></b>
+<dd>[incr Widgets] is a set of megawidgets (combo boxes, etc.) that are
+upon the [incr Tcl] object system and the [incr Tk] megawidget
+framework. This comes bundled with the
+<a href="http://www.tcltk.com/itcl/">[incr Tcl]</a> distributions. <a href="/live/annotate?url=http%3a%2f%2fwww%2etcltk%2ecom%2fiwidgets%2f">Edit</a>
+ <i><font size="-1">(September 05, 1999 16:08)</font></i><dt><b><a href="http://www1.clearlight.com/~oakley/tcl/combobox/index.html" ="">combobox</a></b>
+<dd>
+ Author <b><a href="mailto:oakley@channelpoint.com" ="">Bryan Oakley</a></b>, Version <b>1.03</b>,
+ Works with <b>8.x</b>
+<br>Download: <a href="http://www1.clearlight.com/~oakley/tcl/combobox/combobox.tcl">combobox.tcl</a><br>combobox is a pure-tcl implementation of a combobox widget. It is
+entirely self contained and does not require any other OO or megawidget
+extension. It supports both editable and non-editable entries, and
+provides the ability to call a procedure anytime the value of the combobox
+changes. <a href="/live/annotate?url=http%3a%2f%2fwww1%2eclearlight%2ecom%2f%7eoakley%2ftcl%2fcombobox%2findex%2ehtml">Edit</a>
+ <i><font size="-1">(August 23, 1999 12:15)</font></i><dt><b><a href="http://www.multimania.com/droche/rnotebook/index.html" ="">Rnotebook</a></b>
+<dd>
+ Author <b><a href="mailto:dan@lectra.com" ="">Daniel Roche</a></b>, Version <b>1.0</b>,
+ Works with <b>8.0 or higher</b>
+<br>Download: <a href="http://www.multimania.com/droche/rnotebook/index.html">index.html</a><br>This implements a resizeable notebook
+widget in pure tcl/tk <a href="/live/annotate?url=http%3a%2f%2fwww%2emultimania%2ecom%2fdroche%2frnotebook%2findex%2ehtml">Edit</a>
+ <i><font size="-1">(August 19, 1999 15:39)</font></i><dt><b><a href="http://www.tregar.com/samdi.html" ="">saMDI v1.0a1 Multi-Document Interface Extension</a></b>
+<dd>A multi-document interface (MDI) extension for TCL/Tk 8.0.
+This is a common interface format in Microsoft Windows that lets a parent window contain multiple child windows.
+In effect you get a window manager inside a window!
+Uses and includes the STOOOP object-oriented extension by
+Jean-Luc Fontaine.
+saMDI v1.0a1 GPL Copyright 1998 Sam Tregar. <a href="/live/annotate?url=http%3a%2f%2fwww%2etregar%2ecom%2fsamdi%2ehtml">Edit</a>
+ <i><font size="-1">(August 23, 1999 12:07)</font></i><dt><b><a href="http://tix.mne.com/htdocs/tix/index.html" ="">Tix Support Site</a></b>
+<dd>
+ Author <b><a href="mailto:tix@mne.com" ="">Ioi Lam, (adopted by Gregg Squires)</a></b>, Version <b>4.1</b>,
+ Works with <b>Tcl 7.4 through Tcl 8.0</b>
+<br><a href="ftp://ftp.tix.mne.com/pub/tix/">Download</a>, <a href="ftp://ftp.tix.mne.com/pub/tix/Tix4.1.0.006.tar.gz">Tix4.1.0.006.tar.gz</a>, <a href="ftp://ftp.tix.mne.com/pub/tix/Tix41p6.zip">Tix41p6.zip</a>, <a href="ftp://ftp.tix.mne.com/pub/tix/win41p6bin.zip">win41p6bin.zip</a><br><b>Tix has found a new home!</b>
+ <br>
+ Tix provides over 40 new Tk including the
+combo box, file selection dialogs, paned widget,
+notebook, hierarchical list, directory tree, and more.
+ <a href="/live/annotate?url=http%3a%2f%2ftix%2emne%2ecom%2fhtdocs%2ftix%2findex%2ehtml">Edit</a>
+ <i><font size="-1">(August 23, 1999 12:11)</font></i><dt><b><a href="ftp://ftp.archive.eso.org/pub/tree" ="">Tk Tree Widget (C++)</a></b>
+<dd>Tk Tree widget for Tcl8.0.3.
+
+This version contains (optional) support for \[incr Tcl\] and \[incr Tk\]
+version 3.0.
+<br>
+With the tree widget, you can display a tree in a Tk canvas. The nodes
+can be made up of any number of canvas items or even other Tk widgets.
+You create the objects that make up a node and the line that connects
+it to its parent and pass them to the tree widget. After this the tree
+widget manages the positions of the nodes and end points of the tree
+lines. Operations are available for inserting, moving and removing
+nodes and subtrees and for querrying the position of a node in the
+tree. The tree can be displayed horizontally or vertically.
+ <a href="/live/annotate?url=ftp%3a%2f%2fftp%2earchive%2eeso%2eorg%2fpub%2ftree">Edit</a>
+ <i><font size="-1">(August 25, 1999 03:14)</font></i><dt><b><a href="http://www.purl.org/net/hobbs/tcl/script/widget/" ="">widget, simple megawidget package</a></b>
+<dd>
+ Author <b><a href="mailto:jeffrey.hobbs@oen.siemens.de" ="">Jeffrey Hobbs</a></b>, Version <b>0.9</b>,
+ Works with <b>Tcl/Tk 8.0 or higher</b>
+<br>Download: <a href="http://www.purl.org/net/hobbs/tcl/script/widget/widget-0.9.tar.gz">widget-0.9.tar.gz</a><br>This is a package of
+ megawidgets (i.e., compound widgets) that work almost exactly like Tk widgets.
+ You can also build your own new megawidgets.
+Includes: combobox, hierarchy, console, progressbar,
+tabnotebook, validating entry, pane geometry manager, baloon help. <a href="/live/annotate?url=http%3a%2f%2fwww%2epurl%2eorg%2fnet%2fhobbs%2ftcl%2fscript%2fwidget%2f">Edit</a>
+ <i><font size="-1">(August 23, 1999 12:16)</font></i></dl>
+<hr><p><center><font size="-1" face="Geneva, Helvetica, Arial"><br><a href="#TOP"><b>Top</b></a><br><!-- key ResourceSoftwareExtensions --><a href="/">Home</a>
+ | <a href="/products/">Products</a>
+ | <a href="/customers/">Customers</a>
+ | <a href="/partners/">Partners</a>
+ | <a href="/services/">Services</a>
+ | <a href="/resource/">Tcl Resources</a>
+ | <a href="/company/">Company</a>
+<br><a href="/live/keyword">Search</a>
+ | <a href="/live/map">Site Map</a>
+ | <a href="/company/feedback.html?url=%2fresource%2fsoftware%2fextensions%2ftk%2f">Feedback</a>
+ | <a href="/company/contact.html">Contact Us</a>
+ | <a href="mailto:info@scriptics.com">info@scriptics.com</a>
+
+ <SCRIPT LANGUAGE="Javascript">
+<!--
+ browser = (((navigator.appName == "Netscape") &&(parseInt(navigator.appVersion) >= 3 )) || ((navigator.appName =="Microsoft Internet Explorer") && (parseInt(navigator.appVersion) >= 4 )))
+
+ if ( browser )
+ {
+ over = new MakeImageArray(10)
+ over[0].src = "http://images.scriptics.com/images/ProductsMouseOff.gif"
+ over[1].src = "http://images.scriptics.com/images/CustomersMouseOff.gif"
+ over[2].src = "http://images.scriptics.com/images/PartnersMouseOff.gif"
+ over[3].src = "http://images.scriptics.com/images/ServicesMouseOff.gif"
+ over[4].src = "http://images.scriptics.com/images/ResourceMouseOff.gif"
+ over[5].src = "http://images.scriptics.com/images/CompanyMouseOff.gif"
+ over[6].src = "http://images.scriptics.com/images/homeMainRollover1.gif"
+ over[7].src = "http://images.scriptics.com/images/homeMainRollover2.gif"
+ over[8].src = "http://images.scriptics.com/images/homeMainRollover3.gif"
+ over[9].src = "http://images.scriptics.com/images/homeMainRollover3.gif"
+
+ }
+
+ function MakeImageArray(n) {
+ this.length = n
+ for (var i = 0; i<=n; i++)="i++)" {="{" this[i]="this[i]" ="" new="new" Image()="Image()" }="}" return="return" this="this" }="}" //="//" --="--">
+ </SCRIPT><br>
+ <font size="2">
+ &copy; 1998-2000 Scriptics Corporation. All rights reserved.
+ <a href="/legal_notice.html">Legal Notice</a> | <A href="" /privacy.html="/privacy.html">
+ Privacy Statement</a>
+ </td></tr></table></td></tr></table>
+</Body>
+</Html>
diff --git a/jni/ruby/ext/tk/sample/tkextlib/tkHTML/page3/image1 b/jni/ruby/ext/tk/sample/tkextlib/tkHTML/page3/image1
new file mode 100644
index 0000000..814d1e8
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkextlib/tkHTML/page3/image1
Binary files differ
diff --git a/jni/ruby/ext/tk/sample/tkextlib/tkHTML/page3/image10 b/jni/ruby/ext/tk/sample/tkextlib/tkHTML/page3/image10
new file mode 100644
index 0000000..45001fa
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkextlib/tkHTML/page3/image10
Binary files differ
diff --git a/jni/ruby/ext/tk/sample/tkextlib/tkHTML/page3/image11 b/jni/ruby/ext/tk/sample/tkextlib/tkHTML/page3/image11
new file mode 100644
index 0000000..7c4c170
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkextlib/tkHTML/page3/image11
Binary files differ
diff --git a/jni/ruby/ext/tk/sample/tkextlib/tkHTML/page3/image12 b/jni/ruby/ext/tk/sample/tkextlib/tkHTML/page3/image12
new file mode 100644
index 0000000..903e734
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkextlib/tkHTML/page3/image12
Binary files differ
diff --git a/jni/ruby/ext/tk/sample/tkextlib/tkHTML/page3/image13 b/jni/ruby/ext/tk/sample/tkextlib/tkHTML/page3/image13
new file mode 100644
index 0000000..226d4f6
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkextlib/tkHTML/page3/image13
Binary files differ
diff --git a/jni/ruby/ext/tk/sample/tkextlib/tkHTML/page3/image14 b/jni/ruby/ext/tk/sample/tkextlib/tkHTML/page3/image14
new file mode 100644
index 0000000..8e8c718
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkextlib/tkHTML/page3/image14
Binary files differ
diff --git a/jni/ruby/ext/tk/sample/tkextlib/tkHTML/page3/image2 b/jni/ruby/ext/tk/sample/tkextlib/tkHTML/page3/image2
new file mode 100644
index 0000000..2ddeb32
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkextlib/tkHTML/page3/image2
Binary files differ
diff --git a/jni/ruby/ext/tk/sample/tkextlib/tkHTML/page3/image3 b/jni/ruby/ext/tk/sample/tkextlib/tkHTML/page3/image3
new file mode 100644
index 0000000..1651ba7
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkextlib/tkHTML/page3/image3
Binary files differ
diff --git a/jni/ruby/ext/tk/sample/tkextlib/tkHTML/page3/image4 b/jni/ruby/ext/tk/sample/tkextlib/tkHTML/page3/image4
new file mode 100644
index 0000000..b565c8d
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkextlib/tkHTML/page3/image4
Binary files differ
diff --git a/jni/ruby/ext/tk/sample/tkextlib/tkHTML/page3/image5 b/jni/ruby/ext/tk/sample/tkextlib/tkHTML/page3/image5
new file mode 100644
index 0000000..e1268b8
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkextlib/tkHTML/page3/image5
Binary files differ
diff --git a/jni/ruby/ext/tk/sample/tkextlib/tkHTML/page3/image6 b/jni/ruby/ext/tk/sample/tkextlib/tkHTML/page3/image6
new file mode 100644
index 0000000..1a6b260
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkextlib/tkHTML/page3/image6
Binary files differ
diff --git a/jni/ruby/ext/tk/sample/tkextlib/tkHTML/page3/image7 b/jni/ruby/ext/tk/sample/tkextlib/tkHTML/page3/image7
new file mode 100644
index 0000000..cec7aa0
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkextlib/tkHTML/page3/image7
Binary files differ
diff --git a/jni/ruby/ext/tk/sample/tkextlib/tkHTML/page3/image8 b/jni/ruby/ext/tk/sample/tkextlib/tkHTML/page3/image8
new file mode 100644
index 0000000..ad0d748
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkextlib/tkHTML/page3/image8
Binary files differ
diff --git a/jni/ruby/ext/tk/sample/tkextlib/tkHTML/page3/image9 b/jni/ruby/ext/tk/sample/tkextlib/tkHTML/page3/image9
new file mode 100644
index 0000000..46ade30
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkextlib/tkHTML/page3/image9
Binary files differ
diff --git a/jni/ruby/ext/tk/sample/tkextlib/tkHTML/page3/index.html b/jni/ruby/ext/tk/sample/tkextlib/tkHTML/page3/index.html
new file mode 100644
index 0000000..f4dc84b
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkextlib/tkHTML/page3/index.html
@@ -0,0 +1,2787 @@
+<html><body bgcolor="white">
+<hr>
+<h1 align="center">Embedding Tcl in C/C++ Applications</h1>
+
+ <table width="100%">
+ <tr><td valign="top" align="left" width="46%">
+ <b>Presented At:</b>
+ <blockquote>
+ The&nbsp;Tcl2K&nbsp;Conference<br>
+ Austin, Texas<br>
+ <nobr>9:00am, February 15, 2000</nobr><br>
+ </blockquote>
+ </td>
+ <td width="5%">&nbsp;</td>
+ <td valign="top" align="left" width="46%">
+ <b>Instructor:</b>
+ <blockquote>
+ D. Richard Hipp<br>
+ drh@hwaci.com<br>
+ http://www.hwaci.com/drh/<br>
+ 704.948.4565
+ </blockquote>
+ </td></tr>
+ </table><p>
+ <center><table border="2">
+ <tr><td>
+ <p align="center">
+ Copies of these notes, example source code,<br>and other
+ resources related to this tutorial<br>are available online at
+ <a href="http://www.hwaci.com/tcl2k/">
+ http://www.hwaci.com/tcl2k/</a></p>
+ <p align="center"><small>$Id: index.html 31689 2011-05-22 09:26:02Z nobu $</small></p></td></tr>
+ </table>
+ </center>
+</p>
+
+<br clear="both"><p><hr></p>
+<h2 align="center">Tutorial Outline</h2>
+<p><ul><li>Introduction</li>
+<li>Building It Yourself</li>
+<ul><li>"Hello, World!" using Tcl</li>
+<li>Tcl scripts as C strings</li>
+<li>Adding new Tcl commands</li>
+<li>A tour of the Tcl API</li>
+<li>Tcl initialization scripts</li>
+<li>Adding Tk</li>
+</ul><li>Tools Survey</li>
+<li>Mktclapp</li>
+<ul><li>"Hello World" using mktclapp</li>
+<li>Adding C code</li>
+<li>Other Features</li>
+<li>Invoking Tcl from C</li>
+<li>Running mktclapp directly</li>
+<li>Real-world examples</li>
+</ul><li>Summary</li>
+</ul></p>
+<br clear="both"><p><hr></p>
+<h2 align="center">Embedding Tcl in C/C++ Applications</h2>
+<p><ul><li>You know how to program in Tcl/Tk</li></ul><ul><li>You know how to program in C/C++</li></ul><ul><li>This tutorial is about how to do both at the same time.</li></ul></p>
+<br clear="both"><p><hr></p>
+<h2 align="center">Why Mix C With Tcl/Tk?</h2>
+<p><ul><li>Use C for the things C is good at and Tcl for the things
+ Tcl is good at.</li></ul><ul><li>Generate standalone executables.
+ <ul><li>Eliminate the need to install Tcl/Tk.</li>
+ <li>Prevent problems when the wrong version of Tcl/Tk is installed.</li>
+ </ul></li></ul><ul><li>Prevent end users from changing the source code.
+ <ul><li>Keeps users from creating new bugs.</li>
+ <li>Protects proprietary code.</li>
+ </ul></li></ul><ul><li>Office politics</li></ul><ul><li>Use Tcl/Tk as a portability layer for a large C program</li></ul><ul><li>Use Tcl as a testing interface</li></ul></p>
+<br clear="both"><p><hr></p>
+<h2 align="center">Why Mix C With Tcl/Tk?</h2>
+<p><blockquote><big><b>
+ "Use C for the things C is good at and use Tcl/Tk for the things
+ Tcl/Tk is good at."
+ </b></blockquote></p><p>
+
+ <table width="100%">
+ <tr><td valign="top" align="left" width="46%">
+ <b>C is good at:</b>
+ <ul>
+ <li>Speed</li>
+ <li>Complex data structures</li>
+ <li>Computation</li>
+ <li>Interacting with hardware</li>
+ <li>Byte-by-byte data analysis</li>
+ </ul>
+ </td>
+ <td width="5%">&nbsp;</td>
+ <td valign="top" align="left" width="46%">
+ <b>Tcl/Tk is good at:</b>
+ <ul>
+ <li>Building a user interface</li>
+ <li>Manipulation of strings</li>
+ <li>Portability</li>
+ <li>Opening sockets</li>
+ <li>Handling events</li>
+ </ul>
+ </td></tr>
+ </table>
+<br clear="both"><p><hr></p>
+<h2 align="center">Programming Models</h2>
+<table width="100%">
+<tr><td valign="top" width="49%">
+
+ <p><b>Mainstream Tcl Programming Model:</b></p>
+</td>
+<td width="2%">&nbsp;</td>
+<td valign="top" width="49%">
+
+ <p><b>Embedded Tcl Programming Model:&nbsp;&nbsp;</b></p>
+</td></tr>
+<tr><td valign="top" width="49%">
+
+ <ul><li>Add bits of C code to a large Tcl program</li></ul>
+</td>
+<td width="2%">&nbsp;</td>
+<td valign="top" width="49%">
+
+ <ul><li>Add bits of Tcl code to a large C program</li></ul>
+</td></tr>
+<tr><td valign="top" width="49%">
+
+ <ul><li>Main Tcl script loads extensions written in C</li></ul>
+</td>
+<td width="2%">&nbsp;</td>
+<td valign="top" width="49%">
+
+ <ul><li>Main C procedure invokes the Tcl interpreter</li></ul>
+</td></tr>
+<tr><td valign="top" width="49%">
+
+ <ul><li>Tcl/Tk is a programming language</li></ul>
+</td>
+<td width="2%">&nbsp;</td>
+<td valign="top" width="49%">
+
+ <ul><li>Tcl/Tk is a C library</li></ul>
+</td></tr>
+<tr><td valign="top" width="49%">
+
+ <center><img src="image1"><br>
+ Most of the Tcl2K conference is about</center>
+</td>
+<td width="2%">&nbsp;</td>
+<td valign="top" width="49%">
+
+ <center><img src="image1"><br>
+ This tutorial is about</center>
+</td></tr>
+</table>
+
+<br clear="both"><p><hr></p>
+<h2 align="center">"Hello, World!" Using The Tcl Library</h2>
+<table cellspacing="0" cellpadding="0" border="0">
+<tr><td valign="center">
+<small><tt>#include&nbsp;&lt;tcl.h></tt></small></td>
+<td>&nbsp;&nbsp;</td>
+<td valign="center"><img src="image2"></td>
+<td>&nbsp;&nbsp;</td>
+<td valign="center">Always include &lt;tcl.h></td>
+</tr>
+<tr><td valign="center">
+<small><tt>int&nbsp;main(int&nbsp;argc,&nbsp;char&nbsp;**argv){<br>
+&nbsp;&nbsp;Tcl_Interp&nbsp;*interp;</tt></small></td>
+<td></td><td></td><td></td><td></td>
+</tr>
+<tr><td valign="center">
+<small><tt>&nbsp;&nbsp;interp&nbsp;=&nbsp;Tcl_CreateInterp();</tt></small></td>
+<td>&nbsp;&nbsp;</td>
+<td valign="center"><img src="image2"></td>
+<td>&nbsp;&nbsp;</td>
+<td valign="center">Create a new Tcl interpreter</td>
+</tr>
+<tr><td valign="center">
+<small><tt>&nbsp;&nbsp;Tcl_Eval(interp,&nbsp;"puts&nbsp;{Hello,&nbsp;World!}");</tt></small></td>
+<td>&nbsp;&nbsp;</td>
+<td valign="center"><img src="image2"></td>
+<td>&nbsp;&nbsp;</td>
+<td valign="center">Execute a Tcl command.</td>
+</tr>
+<tr><td valign="center">
+<small><tt>&nbsp;&nbsp;return&nbsp;0;<br>
+}</tt></small></td>
+<td></td><td></td><td></td><td></td>
+</tr>
+</table>
+
+<br clear="both"><p><hr></p>
+<h2 align="center">Compiling "Hello, World!"</h2>
+<p><p><b>Unix:</b></p>
+ <blockquote><tt>
+ $ gcc hello.c -ltcl -lm -ldl<br>
+ $ ./a.out<br>
+ Hello, World!</tt></blockquote>
+
+ <p><b>Windows using Cygwin:</b></p>
+ <blockquote><tt>
+ C:> gcc hello.c -ltcl80 -lm<br>
+ C:> a.exe<br>
+ Hello, World!</tt></blockquote>
+
+ <p><b>Windows using Mingw32:</b></p>
+ <blockquote><tt>
+ C:> gcc -mno-cygwin hello.c -ltcl82 -lm<br>
+ </tt></blockquote>
+<table><tr><td valign="top"><img src="image3"></td>
+<td valign="top"><b>Also works with VC++</b></td></tr></table></p>
+<br clear="both"><p><hr></p>
+<h2 align="center">Where Does <tt>-ltcl</tt> Come From On Unix?</h2>
+<p><p>Build it yourself using these steps:</p></p><p>
+<p><ul><li>Get tcl8.2.2.tar.gz from Scriptics</li></ul><ul><li><tt>zcat tcl8.2.2.tar.gz | tar vx </tt></li></ul><ul><li><tt>cd tcl8.2.2/unix</tt></li></ul><ul><li><tt>./configure --disable-shared</tt></li></ul><ul><li><tt>make</tt></li></ul><ul><li>Move <b>libtcl8.2.a</b> to your lib directory.</li></ul><ul><li>Copy <b>../generic/tcl.h</b> into /usr/include.</li></ul></p>
+<br clear="both"><p><hr></p>
+<h2 align="center">What Other Libraries Are Required For Unix?</h2>
+<p><ul><li>The sequence of <b>-l</b> options after <b>-ltcl</b>
+ varies from system to system</li></ul><ul><li>Observe what libraries the TCL makefile inserts when
+ it is building <b>tclsh</b></li></ul><ul><li>Examples in this talk are for RedHat Linux 6.0 for Intel</li></ul></p>
+<br clear="both"><p><hr></p>
+<h2 align="center">How To Compile Under Unix Without Installing Tcl</h2>
+<p><p>Specify the *.a file directly:</p>
+ <blockquote><pre>
+ $ gcc -I../tcl8.2.2/generic hello.c \
+ ../tcl8.2.2/unix/libtcl8.2.a -lm -ldl
+ $ strip a.out
+ $ ./a.out
+ Hello, World!</pre></blockquote>
+
+ <p>Or, tell the C compiler where to look for *.a files:</p>
+ <blockquote><pre>
+ $ gcc -I../tcl8.2.2/generic hello.c \
+ -L../tcl8.2.2/unix -ltcl -lm -ldl
+ $ strip a.out
+ $ ./a.out
+ Hello, World!</pre></blockquote>
+<table><tr><td valign="top"><img src="image3"></td>
+<td valign="top"><b>The <tt>-I../tcl8.2.2</tt> argument
+ tells the compiler where to
+ find <tt>&lt;tcl.h&gt;</tt>.</p></b></td></tr></table></p>
+<br clear="both"><p><hr></p>
+<h2 align="center">What's "Cygwin"?</h2>
+<p><ul><li>An implementation of GCC/G++ and all development tools
+ for Windows95/98/NT/2000</li></ul><ul><li>Available for free download at
+ <blockquote>
+ <tt>http://sourceware.cygnus.com/cygwin/</tt>
+ </blockquote></li></ul><ul><li>Also available shrink-wrapped at your local software retailer or
+ online at
+ <blockquote>
+ <tt>http://www.cygnus.com/cygwin/index.html</tt>
+ </blockquote></li></ul><ul><li>Programs compiled using Cygwin require a special
+ DLL (<b>cygwin1.dll</b>) that provides a POSIX system API</li></ul><ul><li>Cygwin1.dll cannot be shipped with proprietary programs
+ without purchasing a license from Cygnus.</li></ul><ul><li>Mingw32 is the same compiler as Cygwin, but generates
+ binaries that do not use cygwin1.dll</li></ul></p>
+<br clear="both"><p><hr></p>
+<h2 align="center">Where Does <tt>-ltcl82</tt> Come From On Windows?</h2>
+<p><p>Build it like this:</p></p><p>
+<p><ul><li>Get <b>tcl82.lib</b> and <b>tcl82.dll</b> from Scriptics.</li></ul><ul><li><tt>echo EXPORTS >tcl82.def</tt></li></ul><ul><li><tt>nm tcl82.lib | grep 'T _' | sed 's/.* T _//' >>tcl82.def</tt></li></ul><ul><li><tt>dlltool --def tcl82.def --dllname tcl82.dll --output-lib libtcl82.a</tt></li></ul><ul><li>Move <b>libtcl82.a</b> to the lib directory and <b>tcl82.dll</b>
+ to the bin directory.</li></ul></p>
+<br clear="both"><p><hr></p>
+<h2 align="center">Where Does Your Code Go?</h2>
+<table cellspacing="0" cellpadding="0" border="0">
+<tr><td valign="center">
+<small><tt>#include&nbsp;&lt;tcl.h><br>
+&nbsp;<br>
+int&nbsp;main(int&nbsp;argc,&nbsp;char&nbsp;**argv){<br>
+&nbsp;&nbsp;Tcl_Interp&nbsp;*interp;<br>
+&nbsp;&nbsp;interp&nbsp;=&nbsp;Tcl_CreateInterp();</tt></small></td>
+<td></td><td></td><td></td><td></td>
+</tr>
+<tr><td valign="center">
+<small><tt>&nbsp;&nbsp;/*&nbsp;Your&nbsp;application&nbsp;code&nbsp;goes&nbsp;here&nbsp;*/</tt></small></td>
+<td>&nbsp;&nbsp;</td>
+<td valign="center"><img src="image2"></td>
+<td>&nbsp;&nbsp;</td>
+<td valign="center">Insert C code here to do whatever it is your program is
+ suppose to do</td>
+</tr>
+<tr><td valign="center">
+<small><tt>&nbsp;&nbsp;return&nbsp;0;<br>
+}</tt></small></td>
+<td></td><td></td><td></td><td></td>
+</tr>
+</table>
+
+<br clear="both"><p><hr></p>
+<h2 align="center">Building A Simple TCLSH</h2>
+<table cellspacing="0" cellpadding="0" border="0">
+<tr><td valign="center">
+<small><tt>#include&nbsp;&lt;tcl.h><br>
+&nbsp;<br>
+int&nbsp;main(int&nbsp;argc,&nbsp;char&nbsp;**argv){<br>
+&nbsp;&nbsp;Tcl_Interp&nbsp;*interp;<br>
+&nbsp;&nbsp;char&nbsp;*z;<br>
+&nbsp;&nbsp;char&nbsp;zLine[2000];<br>
+&nbsp;&nbsp;interp&nbsp;=&nbsp;Tcl_CreateInterp();</tt></small></td>
+<td></td><td></td><td></td><td></td>
+</tr>
+<tr><td valign="center">
+<small><tt>&nbsp;&nbsp;while(&nbsp;fgets(zLine,sizeof(zLine),stdin)&nbsp;){</tt></small></td>
+<td>&nbsp;&nbsp;</td>
+<td valign="center"><img src="image2"></td>
+<td>&nbsp;&nbsp;</td>
+<td valign="center">Get one line of input</td>
+</tr>
+<tr><td valign="center">
+<small><tt>&nbsp;&nbsp;&nbsp;&nbsp;Tcl_Eval(interp,&nbsp;zLine);</tt></small></td>
+<td>&nbsp;&nbsp;</td>
+<td valign="center"><img src="image2"></td>
+<td>&nbsp;&nbsp;</td>
+<td valign="center">Execute the input as Tcl.</td>
+</tr>
+<tr><td valign="center">
+<small><tt>&nbsp;&nbsp;&nbsp;&nbsp;z&nbsp;=&nbsp;Tcl_GetStringResult(interp);<br>
+&nbsp;&nbsp;&nbsp;&nbsp;if(&nbsp;z[0]&nbsp;){<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;printf("¸üÿ¿PX¶\n",&nbsp;z);<br>
+&nbsp;&nbsp;&nbsp;&nbsp;}</tt></small></td>
+<td>&nbsp;&nbsp;</td>
+<td valign="center"><img src="image2"></td>
+<td>&nbsp;&nbsp;</td>
+<td valign="center">Print result if not empty</td>
+</tr>
+<tr><td valign="center">
+<small><tt>&nbsp;&nbsp;}<br>
+&nbsp;&nbsp;return&nbsp;0;<br>
+}</tt></small></td>
+<td></td><td></td><td></td><td></td>
+</tr>
+</table>
+<p><table><tr><td valign="top"><img src="image3"></td>
+<td valign="top"><b>What if user types more than 2000 characters?</b></td></tr></table>
+</p>
+
+<br clear="both"><p><hr></p>
+<h2 align="center">Building A Simple TCLSH</h2>
+<p>Use TCL to handle input. Allows input lines of unlimited length.</p><p>
+<table cellspacing="0" cellpadding="0" border="0">
+<tr><td valign="center">
+<small><tt>#include&nbsp;&lt;tcl.h><br>
+&nbsp;<br>
+/*&nbsp;Tcl&nbsp;code&nbsp;to&nbsp;implement&nbsp;the<br>
+**&nbsp;input&nbsp;loop&nbsp;*/<br>
+static&nbsp;char&nbsp;zLoop[]&nbsp;=&nbsp;<br>
+&nbsp;&nbsp;"while&nbsp;{![eof&nbsp;stdin]}&nbsp;{\n"</tt></small></td>
+<td></td><td></td><td></td><td></td>
+</tr>
+<tr><td valign="center">
+<small><tt>&nbsp;&nbsp;"&nbsp;&nbsp;set&nbsp;line&nbsp;[gets&nbsp;stdin]\n"</tt></small></td>
+<td>&nbsp;&nbsp;</td>
+<td valign="center"><img src="image2"></td>
+<td>&nbsp;&nbsp;</td>
+<td valign="center">Get one line of input</td>
+</tr>
+<tr><td valign="center">
+<small><tt>&nbsp;&nbsp;"&nbsp;&nbsp;set&nbsp;result&nbsp;[eval&nbsp;$line]\n"</tt></small></td>
+<td>&nbsp;&nbsp;</td>
+<td valign="center"><img src="image2"></td>
+<td>&nbsp;&nbsp;</td>
+<td valign="center">Execute input as Tcl</td>
+</tr>
+<tr><td valign="center">
+<small><tt>&nbsp;&nbsp;"&nbsp;&nbsp;if&nbsp;{$result!=\"\"}&nbsp;{puts&nbsp;$result}\n"</tt></small></td>
+<td>&nbsp;&nbsp;</td>
+<td valign="center"><img src="image2"></td>
+<td>&nbsp;&nbsp;</td>
+<td valign="center">Print result</td>
+</tr>
+<tr><td valign="center">
+<small><tt>&nbsp;&nbsp;"}\n"<br>
+;<br>
+&nbsp;<br>
+<br>
+int&nbsp;main(int&nbsp;argc,&nbsp;char&nbsp;**argv){<br>
+&nbsp;&nbsp;Tcl_Interp&nbsp;*interp;<br>
+&nbsp;&nbsp;interp&nbsp;=&nbsp;Tcl_CreateInterp();</tt></small></td>
+<td></td><td></td><td></td><td></td>
+</tr>
+<tr><td valign="center">
+<small><tt>&nbsp;&nbsp;Tcl_Eval(interp,&nbsp;zLoop);</tt></small></td>
+<td>&nbsp;&nbsp;</td>
+<td valign="center"><img src="image2"></td>
+<td>&nbsp;&nbsp;</td>
+<td valign="center">Run the Tcl input loop</td>
+</tr>
+<tr><td valign="center">
+<small><tt>&nbsp;&nbsp;return&nbsp;0;<br>
+}</tt></small></td>
+<td></td><td></td><td></td><td></td>
+</tr>
+</table>
+<p><table><tr><td valign="top"><img src="image3"></td>
+<td valign="top"><b>But what about commands that span multiple lines of input?</b></td></tr></table>
+</p>
+
+<br clear="both"><p><hr></p>
+<h2 align="center">Better Handling Of Command-Line Input</h2>
+<p>The file "input.tcl"</p><p>
+<table cellspacing="0" cellpadding="0" border="0">
+<tr><td valign="center">
+<small><tt>set&nbsp;line&nbsp;{}<br>
+while&nbsp;{![eof&nbsp;stdin]}&nbsp;{</tt></small></td>
+<td></td><td></td><td></td><td></td>
+</tr>
+<tr><td valign="center">
+<small><tt>&nbsp;&nbsp;if&nbsp;{$line!=""}&nbsp;{<br>
+&nbsp;&nbsp;&nbsp;&nbsp;puts&nbsp;-nonewline&nbsp;">&nbsp;"<br>
+&nbsp;&nbsp;}&nbsp;else&nbsp;{<br>
+&nbsp;&nbsp;&nbsp;&nbsp;puts&nbsp;-nonewline&nbsp;"%&nbsp;"<br>
+&nbsp;&nbsp;}<br>
+&nbsp;&nbsp;flush&nbsp;stdout</tt></small></td>
+<td>&nbsp;&nbsp;</td>
+<td valign="center"><img src="image2"></td>
+<td>&nbsp;&nbsp;</td>
+<td valign="center">Prompt for user input. The prompt is normally &quot;%&quot;
+ but changes to &quot;&gt;&quot; if the current line is a continuation.</td>
+</tr>
+<tr><td valign="center">
+<small><tt>&nbsp;&nbsp;append&nbsp;line&nbsp;[gets&nbsp;stdin]<br>
+&nbsp;&nbsp;if&nbsp;{[info&nbsp;complete&nbsp;$line]}&nbsp;{</tt></small></td>
+<td></td><td></td><td></td><td></td>
+</tr>
+<tr><td valign="center">
+<small><tt>&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;{[catch&nbsp;{uplevel&nbsp;#0&nbsp;$line}&nbsp;result]}&nbsp;{</tt></small></td>
+<td>&nbsp;&nbsp;</td>
+<td valign="center"><img src="image2"></td>
+<td>&nbsp;&nbsp;</td>
+<td valign="center">If the command is complete, execute it.</td>
+</tr>
+<tr><td valign="center">
+<small><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;puts&nbsp;stderr&nbsp;"Error:&nbsp;$result"<br>
+&nbsp;&nbsp;&nbsp;&nbsp;}&nbsp;elseif&nbsp;{$result!=""}&nbsp;{<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;puts&nbsp;$result<br>
+&nbsp;&nbsp;&nbsp;&nbsp;}<br>
+&nbsp;&nbsp;&nbsp;&nbsp;set&nbsp;line&nbsp;{}</tt></small></td>
+<td></td><td></td><td></td><td></td>
+</tr>
+<tr><td valign="center">
+<small><tt>&nbsp;&nbsp;}&nbsp;else&nbsp;{<br>
+&nbsp;&nbsp;&nbsp;&nbsp;append&nbsp;line&nbsp;\n<br>
+&nbsp;&nbsp;}</tt></small></td>
+<td>&nbsp;&nbsp;</td>
+<td valign="center"><img src="image2"></td>
+<td>&nbsp;&nbsp;</td>
+<td valign="center">If the command is incomplete, append a newline and get
+ another line of text.</td>
+</tr>
+<tr><td valign="center">
+<small><tt>}</tt></small></td>
+<td></td><td></td><td></td><td></td>
+</tr>
+</table>
+
+<br clear="both"><p><hr></p>
+<h2 align="center">Better Handling Of Command-Line Input</h2>
+<p>The file "input.c"</p><p>
+<table cellspacing="0" cellpadding="0" border="0">
+<tr><td valign="center">
+<small><tt>#include&nbsp;&lt;tcl.h><br>
+&nbsp;<br>
+int&nbsp;main(int&nbsp;argc,&nbsp;char&nbsp;**argv){<br>
+&nbsp;&nbsp;Tcl_Interp&nbsp;*interp;<br>
+&nbsp;&nbsp;interp&nbsp;=&nbsp;Tcl_CreateInterp();</tt></small></td>
+<td></td><td></td><td></td><td></td>
+</tr>
+<tr><td valign="center">
+<small><tt>&nbsp;&nbsp;Tcl_Eval(interp,&nbsp;"source&nbsp;input.tcl");</tt></small></td>
+<td>&nbsp;&nbsp;</td>
+<td valign="center"><img src="image2"></td>
+<td>&nbsp;&nbsp;</td>
+<td valign="center">Read and execute the input loop</td>
+</tr>
+<tr><td valign="center">
+<small><tt>&nbsp;&nbsp;return&nbsp;0;<br>
+}</tt></small></td>
+<td></td><td></td><td></td><td></td>
+</tr>
+</table>
+<p><table><tr><td valign="top"><img src="image3"></td>
+<td valign="top"><b>But now the program is not standalone!</b></td></tr></table>
+</p>
+
+<br clear="both"><p><hr></p>
+<h2 align="center">Converting Scripts Into C Strings</h2>
+<table cellspacing="0" cellpadding="0" border="0">
+<tr><td valign="center">
+<small><tt>static&nbsp;char&nbsp;zInputLoop[]&nbsp;=&nbsp;<br>
+&nbsp;&nbsp;"set&nbsp;line&nbsp;{}\n"<br>
+&nbsp;&nbsp;"while&nbsp;{![eof&nbsp;stdin]}&nbsp;{\n"<br>
+&nbsp;&nbsp;"&nbsp;&nbsp;if&nbsp;{$line!=\"\"}&nbsp;{\n"<br>
+&nbsp;&nbsp;"&nbsp;&nbsp;&nbsp;&nbsp;puts&nbsp;-nonewline&nbsp;\">&nbsp;\"\n"<br>
+&nbsp;&nbsp;"&nbsp;&nbsp;}&nbsp;else&nbsp;{\n"<br>
+&nbsp;&nbsp;"&nbsp;&nbsp;&nbsp;&nbsp;puts&nbsp;-nonewline&nbsp;\"%&nbsp;\"\n"<br>
+&nbsp;&nbsp;"&nbsp;&nbsp;}\n"<br>
+&nbsp;&nbsp;"&nbsp;&nbsp;flush&nbsp;stdout\n"<br>
+&nbsp;&nbsp;"&nbsp;&nbsp;append&nbsp;line&nbsp;[gets&nbsp;stdin]\n"<br>
+&nbsp;&nbsp;"&nbsp;&nbsp;if&nbsp;{[info&nbsp;complete&nbsp;$line]}&nbsp;{\n"<br>
+&nbsp;&nbsp;"&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;{[catch&nbsp;{uplevel&nbsp;#0&nbsp;$line}&nbsp;result]}&nbsp;{\n"<br>
+&nbsp;&nbsp;"&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;puts&nbsp;stderr&nbsp;\"Error:&nbsp;$result\"\n"<br>
+&nbsp;&nbsp;"&nbsp;&nbsp;&nbsp;&nbsp;}&nbsp;elseif&nbsp;{$result!=\"\"}&nbsp;{\n"<br>
+&nbsp;&nbsp;"&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;puts&nbsp;$result\n"<br>
+&nbsp;&nbsp;"&nbsp;&nbsp;&nbsp;&nbsp;}\n"<br>
+&nbsp;&nbsp;"&nbsp;&nbsp;&nbsp;&nbsp;set&nbsp;line&nbsp;{}\n"<br>
+&nbsp;&nbsp;"&nbsp;&nbsp;}&nbsp;else&nbsp;{\n"<br>
+&nbsp;&nbsp;"&nbsp;&nbsp;&nbsp;&nbsp;append&nbsp;line&nbsp;\\n\n"<br>
+&nbsp;&nbsp;"&nbsp;&nbsp;}\n"<br>
+&nbsp;&nbsp;"}\n"<br>
+;</tt></small></td>
+<td></td><td></td><td></td><td></td>
+</tr>
+</table>
+
+<br clear="both"><p><hr></p>
+<h2 align="center">Compile Tcl Scripts Into C Programs</h2>
+<table cellspacing="0" cellpadding="0" border="0">
+<tr><td valign="center">
+<small><tt>#include&nbsp;&lt;tcl.h><br>
+</tt></small></td>
+<td></td><td></td><td></td><td></td>
+</tr>
+<tr><td valign="center">
+<small><tt><br>
+static&nbsp;char&nbsp;zInputLoop[]&nbsp;=&nbsp;<br>
+&nbsp;&nbsp;/*&nbsp;Actual&nbsp;code&nbsp;omitted&nbsp;*/<br>
+;</tt></small></td>
+<td>&nbsp;&nbsp;</td>
+<td valign="center"><img src="image2"></td>
+<td>&nbsp;&nbsp;</td>
+<td valign="center">Copy and paste the converted Tcl script here</td>
+</tr>
+<tr><td valign="center">
+<small><tt><br>
+int&nbsp;main(int&nbsp;argc,&nbsp;char&nbsp;**argv){<br>
+&nbsp;&nbsp;Tcl_Interp&nbsp;*interp;<br>
+&nbsp;&nbsp;interp&nbsp;=&nbsp;Tcl_CreateInterp();</tt></small></td>
+<td></td><td></td><td></td><td></td>
+</tr>
+<tr><td valign="center">
+<small><tt>&nbsp;&nbsp;Tcl_Eval(interp,&nbsp;zInputLoop);</tt></small></td>
+<td>&nbsp;&nbsp;</td>
+<td valign="center"><img src="image2"></td>
+<td>&nbsp;&nbsp;</td>
+<td valign="center">Execute the Tcl code</td>
+</tr>
+<tr><td valign="center">
+<small><tt>&nbsp;&nbsp;return&nbsp;0;<br>
+}</tt></small></td>
+<td></td><td></td><td></td><td></td>
+</tr>
+</table>
+
+<br clear="both"><p><hr></p>
+<h2 align="center">Converting Scripts To Strings<br>Using SED Or TCLSH</h2>
+<table cellspacing="0" cellpadding="0" border="0">
+<tr><td valign="center">
+<small><tt>sed&nbsp;-e&nbsp;'s/\\/\\\\/g'&nbsp;\&nbsp;</tt></small></td>
+<td>&nbsp;&nbsp;</td>
+<td valign="center"><img src="image2"></td>
+<td>&nbsp;&nbsp;</td>
+<td valign="center">Convert <b>\</b> into <b>\\</b></td>
+</tr>
+<tr><td valign="center">
+<small><tt>&nbsp;&nbsp;-e&nbsp;'s/"/\\"/g'&nbsp;\&nbsp;</tt></small></td>
+<td>&nbsp;&nbsp;</td>
+<td valign="center"><img src="image2"></td>
+<td>&nbsp;&nbsp;</td>
+<td valign="center">Convert <b>"</b> into <b>\"</b></td>
+</tr>
+<tr><td valign="center">
+<small><tt>&nbsp;&nbsp;-e&nbsp;'s/^/&nbsp;&nbsp;"/'&nbsp;\&nbsp;</tt></small></td>
+<td>&nbsp;&nbsp;</td>
+<td valign="center"><img src="image2"></td>
+<td>&nbsp;&nbsp;</td>
+<td valign="center">Add <b>"</b> to start of each line</td>
+</tr>
+<tr><td valign="center">
+<small><tt>&nbsp;&nbsp;-e&nbsp;'s/$/\\n"/'&nbsp;input.tcl</tt></small></td>
+<td>&nbsp;&nbsp;</td>
+<td valign="center"><img src="image2"></td>
+<td>&nbsp;&nbsp;</td>
+<td valign="center">Add <b>\n"</b> to end of each line</td>
+</tr>
+<tr><td valign="center">
+<small><tt><br>
+&nbsp;<br>
+<br>
+&nbsp;<br>
+<br>
+while&nbsp;{![eof&nbsp;stdin]}&nbsp;{<br>
+&nbsp;&nbsp;set&nbsp;line&nbsp;[gets&nbsp;stdin]</tt></small></td>
+<td></td><td></td><td></td><td></td>
+</tr>
+<tr><td valign="center">
+<small><tt>&nbsp;&nbsp;regsub&nbsp;-all&nbsp;{\}&nbsp;$line&nbsp;{&amp;&amp;}&nbsp;line</tt></small></td>
+<td>&nbsp;&nbsp;</td>
+<td valign="center"><img src="image2"></td>
+<td>&nbsp;&nbsp;</td>
+<td valign="center">Convert <b>\</b> into <b>\\</b></td>
+</tr>
+<tr><td valign="center">
+<small><tt>&nbsp;&nbsp;regsub&nbsp;-all&nbsp;{"}&nbsp;$line&nbsp;{\"}&nbsp;line</tt></small></td>
+<td>&nbsp;&nbsp;</td>
+<td valign="center"><img src="image2"></td>
+<td>&nbsp;&nbsp;</td>
+<td valign="center">Convert <b>"</b> into <b>\"</b></td>
+</tr>
+<tr><td valign="center">
+<small><tt>&nbsp;&nbsp;puts&nbsp;"\"$line\\n\""</tt></small></td>
+<td>&nbsp;&nbsp;</td>
+<td valign="center"><img src="image2"></td>
+<td>&nbsp;&nbsp;</td>
+<td valign="center">Add <b>"</b> in front and <b>\n"</b> at the end</td>
+</tr>
+<tr><td valign="center">
+<small><tt>}</tt></small></td>
+<td></td><td></td><td></td><td></td>
+</tr>
+</table>
+
+<br clear="both"><p><hr></p>
+<h2 align="center">Converting Scripts Into C Strings</h2>
+<p>You may want to save space by removing comments and extra whitespace
+ from scripts.</p><p>
+<table cellspacing="0" cellpadding="0" border="0">
+<tr><td valign="center">
+<small><tt>static&nbsp;char&nbsp;zInputLoop[]&nbsp;=&nbsp;<br>
+&nbsp;&nbsp;"set&nbsp;line&nbsp;{}\n"<br>
+&nbsp;&nbsp;"while&nbsp;{![eof&nbsp;stdin]}&nbsp;{\n"<br>
+&nbsp;&nbsp;"if&nbsp;{$line!=\"\"}&nbsp;{\n"<br>
+&nbsp;&nbsp;"puts&nbsp;-nonewline&nbsp;\">&nbsp;\"\n"<br>
+&nbsp;&nbsp;"}&nbsp;else&nbsp;{\n"<br>
+&nbsp;&nbsp;"puts&nbsp;-nonewline&nbsp;\"%&nbsp;\"\n"<br>
+&nbsp;&nbsp;"}\n"<br>
+&nbsp;&nbsp;"flush&nbsp;stdout\n"<br>
+&nbsp;&nbsp;"append&nbsp;line&nbsp;[gets&nbsp;stdin]\n"<br>
+&nbsp;&nbsp;"if&nbsp;{[info&nbsp;complete&nbsp;$line]}&nbsp;{\n"<br>
+&nbsp;&nbsp;"if&nbsp;{[catch&nbsp;{uplevel&nbsp;#0&nbsp;$line}&nbsp;result]}&nbsp;{\n"<br>
+&nbsp;&nbsp;"puts&nbsp;stderr&nbsp;\"Error:&nbsp;$result\"\n"<br>
+&nbsp;&nbsp;"}&nbsp;elseif&nbsp;{$result!=\"\"}&nbsp;{\n"<br>
+&nbsp;&nbsp;"puts&nbsp;$result\n"<br>
+&nbsp;&nbsp;"}\n"<br>
+&nbsp;&nbsp;"set&nbsp;line&nbsp;{}\n"<br>
+&nbsp;&nbsp;"}&nbsp;else&nbsp;{\n"<br>
+&nbsp;&nbsp;"append&nbsp;line&nbsp;\\n\n"<br>
+&nbsp;&nbsp;"}\n"<br>
+&nbsp;&nbsp;"}\n"<br>
+;</tt></small></td>
+<td></td><td></td><td></td><td></td>
+</tr>
+</table>
+
+<br clear="both"><p><hr></p>
+<h2 align="center">Converting Scripts To Strings</h2>
+<table cellspacing="0" cellpadding="0" border="0">
+<tr><td valign="center">
+<small><tt>sed&nbsp;-e&nbsp;'s/\\/\\\\/g'&nbsp;\&nbsp;<br>
+&nbsp;&nbsp;-e&nbsp;'s/"/\\"/g'&nbsp;\&nbsp;</tt></small></td>
+<td></td><td></td><td></td><td></td>
+</tr>
+<tr><td valign="center">
+<small><tt>&nbsp;&nbsp;-e&nbsp;'/^&nbsp;*#/d'&nbsp;\&nbsp;</tt></small></td>
+<td>&nbsp;&nbsp;</td>
+<td valign="center"><img src="image2"></td>
+<td>&nbsp;&nbsp;</td>
+<td valign="center">Delete lines that begin with #</td>
+</tr>
+<tr><td valign="center">
+<small><tt>&nbsp;&nbsp;-e&nbsp;'/^&nbsp;*$/d'&nbsp;\&nbsp;</tt></small></td>
+<td>&nbsp;&nbsp;</td>
+<td valign="center"><img src="image2"></td>
+<td>&nbsp;&nbsp;</td>
+<td valign="center">Delete blank lines</td>
+</tr>
+<tr><td valign="center">
+<small><tt>&nbsp;&nbsp;-e&nbsp;'s/^&nbsp;*/&nbsp;&nbsp;"/'&nbsp;\&nbsp;</tt></small></td>
+<td>&nbsp;&nbsp;</td>
+<td valign="center"><img src="image2"></td>
+<td>&nbsp;&nbsp;</td>
+<td valign="center">Delete leading spaces</td>
+</tr>
+<tr><td valign="center">
+<small><tt>&nbsp;&nbsp;-e&nbsp;'s/$/\\n"/'&nbsp;input.tcl<br>
+&nbsp;<br>
+<br>
+&nbsp;<br>
+<br>
+&nbsp;<br>
+while&nbsp;{![eof&nbsp;stdin]}&nbsp;{<br>
+&nbsp;&nbsp;set&nbsp;line&nbsp;[gets&nbsp;stdin]</tt></small></td>
+<td></td><td></td><td></td><td></td>
+</tr>
+<tr><td valign="center">
+<small><tt>&nbsp;&nbsp;set&nbsp;line&nbsp;[string&nbsp;trimleft&nbsp;$line]</tt></small></td>
+<td>&nbsp;&nbsp;</td>
+<td valign="center"><img src="image2"></td>
+<td>&nbsp;&nbsp;</td>
+<td valign="center">Remove leading space</td>
+</tr>
+<tr><td valign="center">
+<small><tt>&nbsp;&nbsp;if&nbsp;{$line==""}&nbsp;continue</tt></small></td>
+<td>&nbsp;&nbsp;</td>
+<td valign="center"><img src="image2"></td>
+<td>&nbsp;&nbsp;</td>
+<td valign="center">Delete blank lines</td>
+</tr>
+<tr><td valign="center">
+<small><tt>&nbsp;&nbsp;if&nbsp;{[string&nbsp;index&nbsp;$line&nbsp;0]=="#"}&nbsp;{<br>
+&nbsp;&nbsp;&nbsp;&nbsp;continue<br>
+&nbsp;&nbsp;}</tt></small></td>
+<td>&nbsp;&nbsp;</td>
+<td valign="center"><img src="image2"></td>
+<td>&nbsp;&nbsp;</td>
+<td valign="center">Delete lines starting with #</td>
+</tr>
+<tr><td valign="center">
+<small><tt>&nbsp;&nbsp;regsub&nbsp;-all&nbsp;{\}&nbsp;$line&nbsp;{&amp;&amp;}&nbsp;line<br>
+&nbsp;&nbsp;regsub&nbsp;-all&nbsp;{"}&nbsp;$line&nbsp;{\"}&nbsp;line<br>
+&nbsp;&nbsp;puts&nbsp;"\"$line\\n\""<br>
+}</tt></small></td>
+<td></td><td></td><td></td><td></td>
+</tr>
+</table>
+
+<br clear="both"><p><hr></p>
+<h2 align="center">Removing Comments Or Leading Space<br>Will Break Some Tcl Scripts!</h2>
+<table cellspacing="0" cellpadding="0" border="0">
+<tr><td valign="center">
+<small><tt>image&nbsp;create&nbsp;bitmap&nbsp;smiley&nbsp;-data&nbsp;{</tt></small></td>
+<td></td><td></td><td></td><td></td>
+</tr>
+<tr><td valign="center">
+<small><tt>#define&nbsp;smile_width&nbsp;15<br>
+#define&nbsp;smile_height&nbsp;15</tt></small></td>
+<td>&nbsp;&nbsp;</td>
+<td valign="center"><img src="image2"></td>
+<td>&nbsp;&nbsp;</td>
+<td valign="center">These lines begin with # but are not comment</td>
+</tr>
+<tr><td valign="center">
+<small><tt>static&nbsp;unsigned&nbsp;char&nbsp;smile_bits[]&nbsp;=&nbsp;{<br>
+&nbsp;&nbsp;&nbsp;0xc0,&nbsp;0x01,&nbsp;0x30,&nbsp;0x06,&nbsp;0x0c,&nbsp;0x18,<br>
+&nbsp;&nbsp;&nbsp;0x04,&nbsp;0x10,&nbsp;0x22,&nbsp;0x22,&nbsp;0x52,&nbsp;0x25,<br>
+&nbsp;&nbsp;&nbsp;0x01,&nbsp;0x40,&nbsp;0x01,&nbsp;0x40,&nbsp;0x01,&nbsp;0x40,<br>
+&nbsp;&nbsp;&nbsp;0x12,&nbsp;0x24,&nbsp;0xe2,&nbsp;0x23,&nbsp;0x04,&nbsp;0x10,<br>
+&nbsp;&nbsp;&nbsp;0x0c,&nbsp;0x18,&nbsp;0x30,&nbsp;0x06,&nbsp;0xc0,&nbsp;0x01};<br>
+}<br>
+&nbsp;<br>
+<br>
+&nbsp;<br>
+text&nbsp;.t<br>
+pack&nbsp;.t<br>
+.t&nbsp;insert&nbsp;end&nbsp;[string&nbsp;trim&nbsp;{</tt></small></td>
+<td></td><td></td><td></td><td></td>
+</tr>
+<tr><td valign="center">
+<small><tt>She&nbsp;walks&nbsp;in&nbsp;beauty,&nbsp;like&nbsp;the&nbsp;night<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Of&nbsp;cloudless&nbsp;climes&nbsp;and&nbsp;starry&nbsp;skies;<br>
+And&nbsp;all&nbsp;that's&nbsp;best&nbsp;of&nbsp;dark&nbsp;and&nbsp;bright<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Meet&nbsp;in&nbsp;her&nbsp;aspect&nbsp;and&nbsp;her&nbsp;eyes;</tt></small></td>
+<td>&nbsp;&nbsp;</td>
+<td valign="center"><img src="image2"></td>
+<td>&nbsp;&nbsp;</td>
+<td valign="center">Indentation is deleted on lines 2
+ and 4</td>
+</tr>
+<tr><td valign="center">
+<small><tt>}]&nbsp;<br>
+&nbsp;<br>
+</tt></small></td>
+<td></td><td></td><td></td><td></td>
+</tr>
+</table>
+<p><table><tr><td valign="top"><img src="image3"></td>
+<td valign="top"><b>Problems like these are rare</b></td></tr></table>
+</p>
+
+<br clear="both"><p><hr></p>
+<h2 align="center">Adding A "continue" Command</h2>
+<table cellspacing="0" cellpadding="0" border="0">
+<tr><td valign="center">
+<small><tt>set&nbsp;line&nbsp;{}<br>
+while&nbsp;{![eof&nbsp;stdin]}&nbsp;{<br>
+&nbsp;&nbsp;if&nbsp;{$line!=""}&nbsp;{<br>
+&nbsp;&nbsp;&nbsp;&nbsp;puts&nbsp;-nonewline&nbsp;">&nbsp;"<br>
+&nbsp;&nbsp;}&nbsp;else&nbsp;{<br>
+&nbsp;&nbsp;&nbsp;&nbsp;puts&nbsp;-nonewline&nbsp;"%&nbsp;"<br>
+&nbsp;&nbsp;}<br>
+&nbsp;&nbsp;flush&nbsp;stdout<br>
+&nbsp;&nbsp;append&nbsp;line&nbsp;[gets&nbsp;stdin]<br>
+&nbsp;&nbsp;if&nbsp;{[info&nbsp;complete&nbsp;$line]}&nbsp;{</tt></small></td>
+<td></td><td></td><td></td><td></td>
+</tr>
+<tr><td valign="center">
+<small><tt>&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;{[lindex&nbsp;$line&nbsp;0]=="continue"}&nbsp;{<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;break;</tt></small></td>
+<td>&nbsp;&nbsp;</td>
+<td valign="center"><img src="image2"></td>
+<td>&nbsp;&nbsp;</td>
+<td valign="center">Break out of the loop if the command
+ is "continue"</td>
+</tr>
+<tr><td valign="center">
+<small><tt>&nbsp;&nbsp;&nbsp;&nbsp;}&nbsp;elseif&nbsp;{[catch&nbsp;{uplevel&nbsp;#0&nbsp;$line}&nbsp;result]}&nbsp;{<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;puts&nbsp;stderr&nbsp;"Error:&nbsp;$result"<br>
+&nbsp;&nbsp;&nbsp;&nbsp;}&nbsp;elseif&nbsp;{$result!=""}&nbsp;{<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;puts&nbsp;$result<br>
+&nbsp;&nbsp;&nbsp;&nbsp;}<br>
+&nbsp;&nbsp;&nbsp;&nbsp;set&nbsp;line&nbsp;{}<br>
+&nbsp;&nbsp;}&nbsp;else&nbsp;{<br>
+&nbsp;&nbsp;&nbsp;&nbsp;append&nbsp;line&nbsp;\n<br>
+&nbsp;&nbsp;}<br>
+}</tt></small></td>
+<td></td><td></td><td></td><td></td>
+</tr>
+</table>
+
+<br clear="both"><p><hr></p>
+<h2 align="center">Stop For Tcl Input At Various Points<br>In A C Program</h2>
+<table cellspacing="0" cellpadding="0" border="0">
+<tr><td valign="center">
+<small><tt>#include&nbsp;&lt;tcl.h><br>
+&nbsp;<br>
+static&nbsp;char&nbsp;zInputLoop[]&nbsp;=&nbsp;<br>
+&nbsp;&nbsp;/*&nbsp;Tcl&nbsp;Input&nbsp;loop&nbsp;as&nbsp;a&nbsp;C&nbsp;string&nbsp;*/<br>
+;<br>
+&nbsp;<br>
+int&nbsp;main(int&nbsp;argc,&nbsp;char&nbsp;**argv){<br>
+&nbsp;&nbsp;Tcl_Interp&nbsp;*interp;<br>
+&nbsp;&nbsp;interp&nbsp;=&nbsp;Tcl_CreateInterp();</tt></small></td>
+<td></td><td></td><td></td><td></td>
+</tr>
+<tr><td valign="center">
+<small><tt>&nbsp;&nbsp;/*&nbsp;Application&nbsp;C&nbsp;code&nbsp;*/</tt></small></td>
+<td>&nbsp;&nbsp;</td>
+<td valign="center"><img src="image2"></td>
+<td>&nbsp;&nbsp;</td>
+<td valign="center">Do some computation</td>
+</tr>
+<tr><td valign="center">
+<small><tt>&nbsp;&nbsp;Tcl_Eval(interp,&nbsp;zInputLoop);</tt></small></td>
+<td>&nbsp;&nbsp;</td>
+<td valign="center"><img src="image2"></td>
+<td>&nbsp;&nbsp;</td>
+<td valign="center">Stop for some Tcl input</td>
+</tr>
+<tr><td valign="center">
+<small><tt>&nbsp;&nbsp;/*&nbsp;More&nbsp;application&nbsp;C&nbsp;code&nbsp;*/</tt></small></td>
+<td>&nbsp;&nbsp;</td>
+<td valign="center"><img src="image2"></td>
+<td>&nbsp;&nbsp;</td>
+<td valign="center">Do more computation</td>
+</tr>
+<tr><td valign="center">
+<small><tt>&nbsp;&nbsp;Tcl_Eval(interp,&nbsp;zInputLoop);</tt></small></td>
+<td>&nbsp;&nbsp;</td>
+<td valign="center"><img src="image2"></td>
+<td>&nbsp;&nbsp;</td>
+<td valign="center">Stop for more Tcl input</td>
+</tr>
+<tr><td valign="center">
+<small><tt>&nbsp;&nbsp;/*&nbsp;Finish&nbsp;up&nbsp;the&nbsp;application&nbsp;*/</tt></small></td>
+<td>&nbsp;&nbsp;</td>
+<td valign="center"><img src="image2"></td>
+<td>&nbsp;&nbsp;</td>
+<td valign="center">Finish the computation</td>
+</tr>
+<tr><td valign="center">
+<small><tt>&nbsp;&nbsp;return&nbsp;0;<br>
+}</tt></small></td>
+<td></td><td></td><td></td><td></td>
+</tr>
+</table>
+
+<br clear="both"><p><hr></p>
+<h2 align="center">Using Tcl For Testing</h2>
+<table cellspacing="0" cellpadding="0" border="0">
+<tr><td valign="center">
+<small><tt>#include&nbsp;&lt;tcl.h><br>
+&nbsp;<br>
+static&nbsp;char&nbsp;zInputLoop[]&nbsp;=&nbsp;<br>
+&nbsp;&nbsp;/*&nbsp;Tcl&nbsp;Input&nbsp;loop&nbsp;as&nbsp;a&nbsp;C&nbsp;string&nbsp;*/<br>
+;<br>
+&nbsp;<br>
+</tt></small></td>
+<td></td><td></td><td></td><td></td>
+</tr>
+<tr><td valign="center">
+<small><tt>int&nbsp;main(int&nbsp;argc,&nbsp;char&nbsp;**argv){<br>
+#ifdef&nbsp;TESTING<br>
+&nbsp;&nbsp;Tcl_Interp&nbsp;*interp;</tt></small></td>
+<td>&nbsp;&nbsp;</td>
+<td valign="center"><img src="image2"></td>
+<td>&nbsp;&nbsp;</td>
+<td valign="center">Create interpreter only if TESTING
+ is defined</td>
+</tr>
+<tr><td valign="center">
+<small><tt>&nbsp;&nbsp;interp&nbsp;=&nbsp;Tcl_CreateInterp();<br>
+#endif<br>
+&nbsp;&nbsp;/*&nbsp;Application&nbsp;C&nbsp;code&nbsp;*/</tt></small></td>
+<td></td><td></td><td></td><td></td>
+</tr>
+<tr><td valign="center">
+<small><tt>#ifdef&nbsp;TESTING<br>
+&nbsp;&nbsp;Tcl_Eval(interp,&nbsp;zInputLoop);<br>
+#endif</tt></small></td>
+<td>&nbsp;&nbsp;</td>
+<td valign="center"><img src="image2"></td>
+<td>&nbsp;&nbsp;</td>
+<td valign="center">Accept command-line input only if TESTING
+ is defined</td>
+</tr>
+<tr><td valign="center">
+<small><tt>&nbsp;&nbsp;/*&nbsp;More&nbsp;application&nbsp;C&nbsp;code&nbsp;*/<br>
+#ifdef&nbsp;TESTING<br>
+&nbsp;&nbsp;Tcl_Eval(interp,&nbsp;zInputLoop);<br>
+#endif<br>
+&nbsp;&nbsp;/*&nbsp;Finish&nbsp;up&nbsp;the&nbsp;application&nbsp;*/<br>
+&nbsp;&nbsp;return&nbsp;0;<br>
+}</tt></small></td>
+<td></td><td></td><td></td><td></td>
+</tr>
+</table>
+
+<br clear="both"><p><hr></p>
+<h2 align="center">Creating A New Tcl Command In C</h2>
+<table cellspacing="0" cellpadding="0" border="0">
+<tr><td valign="center">
+<small><tt>#include&nbsp;&lt;tcl.h><br>
+&nbsp;<br>
+int&nbsp;NewCmd(</tt></small></td>
+<td></td><td></td><td></td><td></td>
+</tr>
+<tr><td valign="center">
+<small><tt>&nbsp;&nbsp;void&nbsp;*clientData,<br>
+&nbsp;&nbsp;Tcl_Interp&nbsp;*interp,<br>
+&nbsp;&nbsp;int&nbsp;argc,<br>
+&nbsp;&nbsp;char&nbsp;**argv</tt></small></td>
+<td>&nbsp;&nbsp;</td>
+<td valign="center"><img src="image2"></td>
+<td>&nbsp;&nbsp;</td>
+<td valign="center">The Tcl command is implemented as
+ a C function with four arguments.</td>
+</tr>
+<tr><td valign="center">
+<small><tt>){<br>
+&nbsp;&nbsp;printf("Hello,&nbsp;World!\n");</tt></small></td>
+<td></td><td></td><td></td><td></td>
+</tr>
+<tr><td valign="center">
+<small><tt>&nbsp;&nbsp;return&nbsp;TCL_OK;</tt></small></td>
+<td>&nbsp;&nbsp;</td>
+<td valign="center"><img src="image2"></td>
+<td>&nbsp;&nbsp;</td>
+<td valign="center">Returns TCL_OK or TCL_ERROR</td>
+</tr>
+<tr><td valign="center">
+<small><tt>}<br>
+&nbsp;<br>
+static&nbsp;char&nbsp;zInputLoop[]&nbsp;=&nbsp;<br>
+&nbsp;&nbsp;/*&nbsp;Tcl&nbsp;code&nbsp;omitted...&nbsp;*/<br>
+;<br>
+&nbsp;<br>
+int&nbsp;main(int&nbsp;argc,&nbsp;char&nbsp;**argv){<br>
+&nbsp;&nbsp;Tcl_Interp&nbsp;*interp;<br>
+&nbsp;&nbsp;interp&nbsp;=&nbsp;Tcl_CreateInterp();</tt></small></td>
+<td></td><td></td><td></td><td></td>
+</tr>
+<tr><td valign="center">
+<small><tt>&nbsp;&nbsp;Tcl_CreateCommand(interp,&nbsp;"helloworld",<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;NewCmd,&nbsp;0,&nbsp;0);</tt></small></td>
+<td>&nbsp;&nbsp;</td>
+<td valign="center"><img src="image2"></td>
+<td>&nbsp;&nbsp;</td>
+<td valign="center">Tell the interpreter which C function to call when the
+ "helloworld" Tcl command is executed</td>
+</tr>
+<tr><td valign="center">
+<small><tt>&nbsp;&nbsp;Tcl_Eval(interp,&nbsp;zInputLoop);<br>
+&nbsp;&nbsp;return&nbsp;0;<br>
+}</tt></small></td>
+<td></td><td></td><td></td><td></td>
+</tr>
+</table>
+
+<br clear="both"><p><hr></p>
+<h2 align="center">Linkage From Tcl To C</h2>
+<p><p align="center"><img src="image4"></p></p><p><ul><li>3rd parameter of Tcl_CreateCommand() is a pointer to the C subroutine
+ that implements the command.</li></ul><ul><li>4th parameter to Tcl_CreateCommand() becomes the 1st parameter to
+ the C routine whenever the Tcl command is executed.</li></ul><ul><li>1st parameter to Tcl_CreateCommand() must be a valid Tcl interpreter.
+ The same pointer appears as the second parameter to the C routine
+ whenever the Tcl command is executed.</li></ul></p>
+
+<br clear="both"><p><hr></p>
+<h2 align="center">Linkage From Tcl To C</h2>
+<p><p align="center"><img src="image5"></p></p><p><ul><li>5th parameter of Tcl_CreateCommand() is a pointer to the C subroutine
+ that is called when the Tcl command is deleted.</li></ul><ul><li>4th parameter to Tcl_CreateCommand() becomes the 1st parameter to
+ the C routine.</li></ul></p>
+
+<br clear="both"><p><hr></p>
+<h2 align="center">When To Use A Delete Proc</h2>
+<p>Examples of where the delete proc is used in standard Tcl/Tk:</p><p>
+<table cellspacing="0" cellpadding="0" border="0">
+<tr><td valign="center">
+<small><tt>button&nbsp;.b&nbsp;-text&nbsp;Hello<br>
+pack&nbsp;.b</tt></small></td>
+<td></td><td></td><td></td><td></td>
+</tr>
+<tr><td valign="center">
+<small><tt>rename&nbsp;.b&nbsp;{}</tt></small></td>
+<td>&nbsp;&nbsp;</td>
+<td valign="center"><img src="image2"></td>
+<td>&nbsp;&nbsp;</td>
+<td valign="center">Deleting the <b>.b</b> command causes the button to be destroyed</td>
+</tr>
+<tr><td valign="center">
+<small><tt><br>
+&nbsp;<br>
+</tt></small></td>
+<td></td><td></td><td></td><td></td>
+</tr>
+<tr><td valign="center">
+<small><tt>image&nbsp;create&nbsp;photo&nbsp;smiley&nbsp;\&nbsp;<br>
+&nbsp;&nbsp;&nbsp;&nbsp;-file&nbsp;smiley.gif</tt></small></td>
+<td></td><td></td><td></td><td></td>
+</tr>
+<tr><td valign="center">
+<small><tt>rename&nbsp;smiley&nbsp;{}</tt></small></td>
+<td>&nbsp;&nbsp;</td>
+<td valign="center"><img src="image2"></td>
+<td>&nbsp;&nbsp;</td>
+<td valign="center">Deleting the <b>smiley</b> command destroys the image and reclaims the
+ memory used to hold the image</td>
+</tr>
+</table>
+<p><ul><li>Always use a delete proc if the clientData is a pointer to
+ malloced memory or some other resource that needs freeing</li></ul><ul><li>Delete procs are never used in the Tcl core but are used
+ extensively in Tk</li></ul></p>
+
+<br clear="both"><p><hr></p>
+<h2 align="center">Linkage From Tcl To C</h2>
+<p>The <tt>argc</tt> and <tt>argv</tt> parameters work just like in
+ <tt>main()</tt></p><p>
+<table cellspacing="0" cellpadding="0" border="0">
+<tr><td valign="center">
+<small><tt>helloworld&nbsp;one&nbsp;{two&nbsp;three}&nbsp;four</tt></small></td>
+<td>&nbsp;&nbsp;</td>
+<td valign="center"><img src="image2"></td>
+<td>&nbsp;&nbsp;</td>
+<td valign="center"><tt>argc = 4<br>
+ argv[0] = "helloworld"<br>
+ argv[1] = "one"<br>
+ argv[2] = "two three"<br>
+ argv[3] = "four"<br>
+ argv[4] = NULL</tt></td>
+</tr>
+</table>
+
+<br clear="both"><p><hr></p>
+<h2 align="center">A Short-Cut</h2>
+<p>In a program with many new Tcl commands implemented in C, it becomes
+ tedious to type the same four parameters over and over again. So
+ we define a short-cut.</p><p>
+<table cellspacing="0" cellpadding="0" border="0">
+<tr><td valign="center">
+<small><tt>#define&nbsp;TCLARGS&nbsp;\&nbsp;<br>
+&nbsp;&nbsp;&nbsp;&nbsp;void&nbsp;*clientData,&nbsp;\&nbsp;<br>
+&nbsp;&nbsp;&nbsp;&nbsp;Tcl_Interp&nbsp;*interp,&nbsp;\&nbsp;<br>
+&nbsp;&nbsp;&nbsp;&nbsp;int&nbsp;argc,&nbsp;\&nbsp;<br>
+&nbsp;&nbsp;&nbsp;&nbsp;char&nbsp;*argv</tt></small></td>
+<td>&nbsp;&nbsp;</td>
+<td valign="center"><img src="image2"></td>
+<td>&nbsp;&nbsp;</td>
+<td valign="center">Define TCLARGS once in a header file</td>
+</tr>
+<tr><td valign="center">
+<small><tt>&nbsp;<br>
+&nbsp;<br>
+&nbsp;</tt></small></td>
+<td></td><td></td><td></td><td></td>
+</tr>
+<tr><td valign="center">
+<small><tt>int&nbsp;NewCmd(TCLARGS){</tt></small></td>
+<td>&nbsp;&nbsp;</td>
+<td valign="center"><img src="image2"></td>
+<td>&nbsp;&nbsp;</td>
+<td valign="center">Use the TCLARGS macro to define new C functions
+ that implement Tcl commands.</td>
+</tr>
+<tr><td valign="center">
+<small><tt>&nbsp;&nbsp;&nbsp;/*&nbsp;implementation...&nbsp;*/<br>
+}</tt></small></td>
+<td></td><td></td><td></td><td></td>
+</tr>
+</table>
+<p><table><tr><td valign="top"><img src="image3"></td>
+<td valign="top"><b>For brevity, we will use the TCLARGS macro during the
+ rest of this talk.</b></td></tr></table>
+</p>
+
+<br clear="both"><p><hr></p>
+<h2 align="center">Returning A Value From C Back To Tcl</h2>
+<table cellspacing="0" cellpadding="0" border="0">
+<tr><td valign="center">
+<small><tt>int&nbsp;NewCmd(TCLARGS){</tt></small></td>
+<td>&nbsp;&nbsp;</td>
+<td valign="center"><img src="image2"></td>
+<td>&nbsp;&nbsp;</td>
+<td valign="center">Note that the C function returns an "int"</td>
+</tr>
+<tr><td valign="center">
+<small><tt>&nbsp;&nbsp;return&nbsp;TCL_OK;</tt></small></td>
+<td>&nbsp;&nbsp;</td>
+<td valign="center"><img src="image2"></td>
+<td>&nbsp;&nbsp;</td>
+<td valign="center">Return value is TCL_OK or TCL_ERROR</td>
+</tr>
+<tr><td valign="center">
+<small><tt>}</tt></small></td>
+<td></td><td></td><td></td><td></td>
+</tr>
+</table>
+<p><ul><li>TCL_OK and TCL_ERROR are defined in &lt;tcl.h&gt;</li></ul><ul><li>Other valid return values TCL_RETURN, TCL_BREAK and TCL_CONTINUE
+ are rarely used</li></ul><ul><li>Common mistake: forgetting to return TCL_OK</li></ul></p>
+
+<br clear="both"><p><hr></p>
+<h2 align="center">Returning A Value From C Back To Tcl</h2>
+<table cellspacing="0" cellpadding="0" border="0">
+<tr><td valign="center">
+<small><tt>int&nbsp;NewCmd(TCLARGS){</tt></small></td>
+<td></td><td></td><td></td><td></td>
+</tr>
+<tr><td valign="center">
+<small><tt>&nbsp;&nbsp;Tcl_SetResult(interp,"Hello!",TCL_STATIC);</tt></small></td>
+<td>&nbsp;&nbsp;</td>
+<td valign="center"><img src="image2"></td>
+<td>&nbsp;&nbsp;</td>
+<td valign="center">Set the result to "Hello!"</td>
+</tr>
+<tr><td valign="center">
+<small><tt>&nbsp;&nbsp;return&nbsp;TCL_OK;<br>
+}</tt></small></td>
+<td></td><td></td><td></td><td></td>
+</tr>
+</table>
+<p><ul><li>Result should be the text of an error message if you
+ return TCL_ERROR.</li></ul><ul><li>3rd argument to Tcl_SetResult() can be TCL_STATIC,
+ TCL_DYNAMIC, TCL_VOLATILE, or a function pointer.</li></ul><ul><li>Also consider using Tcl_AppendResult().</li></ul><ul><li>Direct access to <tt>interp->result</tt> is deprecated.</li></ul><ul><li>See the man pages for details.</li></ul></p>
+
+<br clear="both"><p><hr></p>
+<h2 align="center">The Tcl_Obj Interface</h2>
+<p><ul><li>A new way to write Tcl commands in C code</li></ul><ul><li>First introduced in Tcl8.0</li></ul><ul><li>Can be much faster, especially for lists or numeric values.</li></ul><ul><li>Able to handle arbitrary binary data.</li></ul><ul><li>More difficult to program.</li></ul></p>
+<br clear="both"><p><hr></p>
+<h2 align="center">The Tcl_Obj Interface</h2>
+<table cellspacing="0" cellpadding="0" border="0">
+<tr><td valign="center">
+<small><tt>int&nbsp;NewObjCmd(<br>
+&nbsp;&nbsp;void&nbsp;*clientData,<br>
+&nbsp;&nbsp;Tcl_Interp&nbsp;*interp,<br>
+&nbsp;&nbsp;int&nbsp;objc,</tt></small></td>
+<td></td><td></td><td></td><td></td>
+</tr>
+<tr><td valign="center">
+<small><tt>&nbsp;&nbsp;Tcl_Obj&nbsp;*const*&nbsp;objv</tt></small></td>
+<td>&nbsp;&nbsp;</td>
+<td valign="center"><img src="image2"></td>
+<td>&nbsp;&nbsp;</td>
+<td valign="center">4th parameter is an array Tcl_Objs, not an array of strings</td>
+</tr>
+<tr><td valign="center">
+<small><tt>){<br>
+&nbsp;&nbsp;/*&nbsp;Implementation...&nbsp;*/<br>
+&nbsp;&nbsp;return&nbsp;TCL_OK;<br>
+}<br>
+&nbsp;<br>
+static&nbsp;char&nbsp;zInputLoop[]&nbsp;=&nbsp;<br>
+&nbsp;&nbsp;/*&nbsp;Tcl&nbsp;code&nbsp;omitted...&nbsp;*/<br>
+;<br>
+&nbsp;<br>
+int&nbsp;main(int&nbsp;argc,&nbsp;char&nbsp;**argv){<br>
+&nbsp;&nbsp;Tcl_Interp&nbsp;*interp;<br>
+&nbsp;&nbsp;interp&nbsp;=&nbsp;Tcl_CreateInterp();</tt></small></td>
+<td></td><td></td><td></td><td></td>
+</tr>
+<tr><td valign="center">
+<small><tt>&nbsp;&nbsp;Tcl_CreateObjCommand(interp,&nbsp;"newcmd",<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;NewObjCmd,&nbsp;0,&nbsp;0);</tt></small></td>
+<td>&nbsp;&nbsp;</td>
+<td valign="center"><img src="image2"></td>
+<td>&nbsp;&nbsp;</td>
+<td valign="center">Use a different function to register the command</td>
+</tr>
+<tr><td valign="center">
+<small><tt>&nbsp;&nbsp;Tcl_Eval(interp,&nbsp;zInputLoop);<br>
+&nbsp;&nbsp;return&nbsp;0;<br>
+}</tt></small></td>
+<td></td><td></td><td></td><td></td>
+</tr>
+</table>
+
+<br clear="both"><p><hr></p>
+<h2 align="center">The Tcl_Obj Interface</h2>
+<p><ul><li>There are countless access methods for reading information from and
+ placing information in Tcl_Objs. Always use the access methods.</li></ul><ul><li>Details provided at Lee Bernhard's talk this afternoon.</li></ul><ul><li>Definitely use Tcl_Objs if you are writing a new Tcl extension.</li></ul><ul><li>Tcl_Objs address some of the weaknesses of Tcl relative to C/C++.
+ <ul>
+ <li> Tcl_Objs are faster </li>
+ <li> Tcl_Objs work with binary data </li>
+ </ul>
+ But C/C++ is faster still and better for working with binary data.</li></ul><ul><li>When mixing C/C++ with Tcl/Tk the benefits of Tcl_Objs are
+ less important. Using Tcl_Objs in this context may not be
+ worth the extra trouble.</li></ul><ul><li>This talk will focus on the string interface.</li></ul></p>
+<br clear="both"><p><hr></p>
+<h2 align="center">Nickel Tour Of The Tcl API</h2>
+<p><p><b>Memory allocation functions</b></p>
+<center><table width="90%"><tr>
+<td width="32%" valign="top"><small><tt>
+ Tcl_Alloc<br>
+</tt></small></td>
+<td width="32%" valign="top"><small><tt>
+ Tcl_Free<br>
+</tt></small></td>
+<td width="32%" valign="top"><small><tt>
+ Tcl_Realloc<br>
+</tt></small></td>
+</table></center><p><b>Functions useful in the implementation of new Tcl commands</b></p>
+<center><table width="90%"><tr>
+<td width="32%" valign="top"><small><tt>
+ Tcl_AppendElement<br>
+ Tcl_AppendResult<br>
+ Tcl_GetBoolean<br>
+</tt></small></td>
+<td width="32%" valign="top"><small><tt>
+ Tcl_GetDouble<br>
+ Tcl_GetInt<br>
+ Tcl_GetStringResult<br>
+</tt></small></td>
+<td width="32%" valign="top"><small><tt>
+ Tcl_ResetResult<br>
+ Tcl_SetResult<br>
+</tt></small></td>
+</table></center><p><b>Functions for controlling the Tcl interpreter</b></p>
+<center><table width="90%"><tr>
+<td width="32%" valign="top"><small><tt>
+ Tcl_CreateCommand<br>
+ Tcl_CreateInterp<br>
+</tt></small></td>
+<td width="32%" valign="top"><small><tt>
+ Tcl_CreateObjCommand<br>
+ Tcl_DeleteCommand<br>
+</tt></small></td>
+<td width="32%" valign="top"><small><tt>
+ Tcl_DeleteInterp<br>
+ Tcl_Exit<br>
+</tt></small></td>
+</table></center></p>
+<br clear="both"><p><hr></p>
+<h2 align="center">Nickel Tour Of The Tcl API</h2>
+<p><p><b>I/O functions</b></p>
+<center><table width="90%"><tr>
+<td width="32%" valign="top"><small><tt>
+ Tcl_Close<br>
+ Tcl_Eof<br>
+ Tcl_Flush<br>
+ Tcl_GetChannel<br>
+ Tcl_GetChannelMode<br>
+ Tcl_GetChannelName<br>
+</tt></small></td>
+<td width="32%" valign="top"><small><tt>
+ Tcl_Gets<br>
+ Tcl_OpenCommandChannel<br>
+ Tcl_OpenFileChannel<br>
+ Tcl_OpenTcpClient<br>
+ Tcl_OpenTcpServer<br>
+ Tcl_Read<br>
+</tt></small></td>
+<td width="32%" valign="top"><small><tt>
+ Tcl_Seek<br>
+ Tcl_Tell<br>
+ Tcl_Ungets<br>
+ Tcl_Write<br>
+ Tcl_WriteChars<br>
+</tt></small></td>
+</table></center><p><b>Names and meanings of system error codes</b></p>
+<center><table width="90%"><tr>
+<td width="32%" valign="top"><small><tt>
+ Tcl_ErrnoId<br>
+ Tcl_ErrnoMsg<br>
+</tt></small></td>
+<td width="32%" valign="top"><small><tt>
+ Tcl_GetErrno<br>
+ Tcl_SetErrno<br>
+</tt></small></td>
+<td width="32%" valign="top"><small><tt>
+ Tcl_SignalId<br>
+ Tcl_SignalMsg<br>
+</tt></small></td>
+</table></center></p>
+<br clear="both"><p><hr></p>
+<h2 align="center">Nickel Tour Of The Tcl API</h2>
+<p><p><b>General Operating System Calls</b></p>
+<center><table width="90%"><tr>
+<td width="32%" valign="top"><small><tt>
+ Tcl_Access<br>
+ Tcl_Chdir<br>
+ Tcl_GetCwd<br>
+</tt></small></td>
+<td width="32%" valign="top"><small><tt>
+ Tcl_GetHostName<br>
+ Tcl_GetNameOfExecutable<br>
+ Tcl_Sleep<br>
+</tt></small></td>
+<td width="32%" valign="top"><small><tt>
+ Tcl_Stat<br>
+</tt></small></td>
+</table></center><p><b>String Manipulation And Comparison</b></p>
+<center><table width="90%"><tr>
+<td width="32%" valign="top"><small><tt>
+ Tcl_Concat<br>
+ Tcl_Merge<br>
+</tt></small></td>
+<td width="32%" valign="top"><small><tt>
+ Tcl_SplitList<br>
+ Tcl_StringCaseMatch<br>
+</tt></small></td>
+<td width="32%" valign="top"><small><tt>
+ Tcl_StringMatch<br>
+</tt></small></td>
+</table></center><p><b>Dynamically Resizable Strings</b></p>
+<center><table width="90%"><tr>
+<td width="49%" valign="top"><small><tt>
+ Tcl_DStringAppend<br>
+ Tcl_DStringAppendElement<br>
+ Tcl_DStringEndSublist<br>
+ Tcl_DStringInit<br>
+ Tcl_DStringLength<br>
+</tt></small></td>
+<td width="49%" valign="top"><small><tt>
+ Tcl_DStringResult<br>
+ Tcl_DStringSetLength<br>
+ Tcl_DStringStartSublist<br>
+ Tcl_DStringValue<br>
+</tt></small></td>
+</table></center></p>
+<br clear="both"><p><hr></p>
+<h2 align="center">Nickel Tour Of The Tcl API</h2>
+<p><p><b>Event Handlers</b></p>
+<center><table width="90%"><tr>
+<td width="49%" valign="top"><small><tt>
+ Tcl_CancelIdleCall<br>
+ Tcl_CreateChannelHandler<br>
+ Tcl_CreateTimerHandler<br>
+ Tcl_DeleteChannelHandler<br>
+</tt></small></td>
+<td width="49%" valign="top"><small><tt>
+ Tcl_DeleteTimerHandler<br>
+ Tcl_DoOneEvent<br>
+ Tcl_DoWhenIdle<br>
+</tt></small></td>
+</table></center><p><b>Functions For Reading And Writing Tcl Variables</b></p>
+<center><table width="90%"><tr>
+<td width="32%" valign="top"><small><tt>
+ Tcl_GetVar<br>
+ Tcl_GetVar2<br>
+ Tcl_LinkVar<br>
+ Tcl_SetVar<br>
+ Tcl_SetVar2<br>
+</tt></small></td>
+<td width="32%" valign="top"><small><tt>
+ Tcl_TraceVar<br>
+ Tcl_TraceVar2<br>
+ Tcl_UnlinkVar<br>
+ Tcl_UnsetVar<br>
+ Tcl_UnsetVar2<br>
+</tt></small></td>
+<td width="32%" valign="top"><small><tt>
+ Tcl_UntraceVar<br>
+ Tcl_UntraceVar2<br>
+ Tcl_UpdateLinkedVar<br>
+</tt></small></td>
+</table></center><p><b>Functions For Executing Tcl Code</b></p>
+<center><table width="90%"><tr>
+<td width="32%" valign="top"><small><tt>
+ Tcl_Eval<br>
+ Tcl_EvalFile<br>
+</tt></small></td>
+<td width="32%" valign="top"><small><tt>
+ Tcl_EvalObj<br>
+ Tcl_GlobalEval<br>
+</tt></small></td>
+<td width="32%" valign="top"><small><tt>
+ Tcl_GlobalEvalObj<br>
+ Tcl_VarEval<br>
+</tt></small></td>
+</table></center></p>
+<br clear="both"><p><hr></p>
+<h2 align="center">Nickel Tour Of The Tcl API</h2>
+<p><p><b>Functions For Dealing With Unicode</b></p>
+<center><table width="90%"><tr>
+<td width="49%" valign="top"><small><tt>
+ Tcl_NumUtfChars<br>
+ Tcl_UniCharAtIndex<br>
+ Tcl_UniCharIsAlnum<br>
+ Tcl_UniCharIsAlpha<br>
+ Tcl_UniCharIsControl<br>
+ Tcl_UniCharIsDigit<br>
+ Tcl_UniCharIsGraph<br>
+ Tcl_UniCharIsLower<br>
+ Tcl_UniCharIsPrint<br>
+ Tcl_UniCharIsPunct<br>
+ Tcl_UniCharIsSpace<br>
+ Tcl_UniCharIsUpper<br>
+ Tcl_UniCharIsWordChar<br>
+ Tcl_UniCharLen<br>
+ Tcl_UniCharNcmp<br>
+ Tcl_UniCharToLower<br>
+ Tcl_UniCharToTitle<br>
+</tt></small></td>
+<td width="49%" valign="top"><small><tt>
+ Tcl_UniCharToUpper<br>
+ Tcl_UniCharToUtf<br>
+ Tcl_UniCharToUtfDString<br>
+ Tcl_UtfAtIndex<br>
+ Tcl_UtfBackslash<br>
+ Tcl_UtfCharComplete<br>
+ Tcl_UtfFindFirst<br>
+ Tcl_UtfFindLast<br>
+ Tcl_UtfNcasecmp<br>
+ Tcl_UtfNcmp<br>
+ Tcl_UtfNext<br>
+ Tcl_UtfPrev<br>
+ Tcl_UtfToLower<br>
+ Tcl_UtfToTitle<br>
+ Tcl_UtfToUniChar<br>
+ Tcl_UtfToUniCharDString<br>
+ Tcl_UtfToUpper<br>
+</tt></small></td>
+</table></center>
+ <p><b>Functions For Dealing With Tcl_Objs</b></p>
+ <blockquote><i>Too numerous to list...</i></blockquote></p>
+<br clear="both"><p><hr></p>
+<h2 align="center">Documentation Of The Tcl API</h2>
+<p><ul><li>Tcl comes with excellent man pages</li></ul><ul><li>"Use the source, Luke"</li></ul><ul><li>See <tt>tclDecl.h</tt> for a list of API functions</li></ul><ul><li>The header comments on the implementation of API functions usually
+ gives a good description of what the function does and how it should
+ be used.</li></ul><ul><li>Most API functions are used within Tcl and Tk. Use grep to locate
+ examples.</li></ul></p>
+<br clear="both"><p><hr></p>
+<h2 align="center">Initialization Scripts</h2>
+<p><ul><li>Run the mini TCLSH implemented above and execute the <tt>parray</tt> command</li></ul><ul><li>It doesn't work! What's wrong? </p></li></li></ul><ul><li><tt>parray</tt> is really a Tcl proc that is read in when the
+ interpreter is initialized. </p></li></li></ul><ul><li><tt>parray</tt> (and several other commands) are stored in a
+ handful of &quot;Initialization Scripts&quot; </p></li></li></ul><ul><li>All the initialization scripts are stored in the
+ &quot;Tcl Library&quot; - a directory on the host
+ computer. </p></li></li></ul><table><tr><td valign="top"><img src="image3"></td>
+<td valign="top"><b>Invoke the Tcl_Init() function to locate and read the
+ Tcl initialization scripts.</b></td></tr></table></p>
+<br clear="both"><p><hr></p>
+<h2 align="center">The <tt>Tcl_Init()</tt> Function</h2>
+<table cellspacing="0" cellpadding="0" border="0">
+<tr><td valign="center">
+<small><tt>#include&nbsp;&lt;tcl.h><br>
+&nbsp;<br>
+static&nbsp;char&nbsp;zInputLoop[]&nbsp;=&nbsp;<br>
+&nbsp;&nbsp;/*&nbsp;Tcl&nbsp;code&nbsp;omitted...&nbsp;*/<br>
+;<br>
+&nbsp;<br>
+int&nbsp;main(int&nbsp;argc,&nbsp;char&nbsp;**argv){<br>
+&nbsp;&nbsp;Tcl_Interp&nbsp;*interp;<br>
+&nbsp;&nbsp;interp&nbsp;=&nbsp;Tcl_CreateInterp();</tt></small></td>
+<td></td><td></td><td></td><td></td>
+</tr>
+<tr><td valign="center">
+<small><tt>&nbsp;&nbsp;Tcl_Init(interp);</tt></small></td>
+<td>&nbsp;&nbsp;</td>
+<td valign="center"><img src="image2"></td>
+<td>&nbsp;&nbsp;</td>
+<td valign="center">Locate and read the initialization scripts</td>
+</tr>
+<tr><td valign="center">
+<small><tt>&nbsp;&nbsp;/*&nbsp;Call&nbsp;Tcl_CreateCommand()?&nbsp;*/<br>
+&nbsp;&nbsp;Tcl_Eval(interp,&nbsp;zInputLoop);<br>
+&nbsp;&nbsp;return&nbsp;0;<br>
+}</tt></small></td>
+<td></td><td></td><td></td><td></td>
+</tr>
+</table>
+<p><table><tr><td valign="top"><img src="image3"></td>
+<td valign="top"><b>But Tcl_Init() can fail. We need to check its return value...</b></td></tr></table>
+</p>
+
+<br clear="both"><p><hr></p>
+<h2 align="center">The <tt>Tcl_Init()</tt> Function</h2>
+<table cellspacing="0" cellpadding="0" border="0">
+<tr><td valign="center">
+<small><tt>#include&nbsp;&lt;tcl.h><br>
+&nbsp;<br>
+static&nbsp;char&nbsp;zInputLoop[]&nbsp;=&nbsp;<br>
+&nbsp;&nbsp;/*&nbsp;Tcl&nbsp;code&nbsp;omitted...&nbsp;*/<br>
+;<br>
+&nbsp;<br>
+int&nbsp;main(int&nbsp;argc,&nbsp;char&nbsp;**argv){<br>
+&nbsp;&nbsp;Tcl_Interp&nbsp;*interp;<br>
+&nbsp;&nbsp;interp&nbsp;=&nbsp;Tcl_CreateInterp();</tt></small></td>
+<td></td><td></td><td></td><td></td>
+</tr>
+<tr><td valign="center">
+<small><tt>&nbsp;&nbsp;if(&nbsp;Tcl_Init(interp)!=TCL_OK&nbsp;){<br>
+&nbsp;&nbsp;&nbsp;&nbsp;fprintf(stderr,"Tcl_Init()&nbsp;failed:&nbsp;¸üÿ¿PX¶",<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Tcl_GetStringResult(interp));<br>
+&nbsp;&nbsp;}</tt></small></td>
+<td>&nbsp;&nbsp;</td>
+<td valign="center"><img src="image2"></td>
+<td>&nbsp;&nbsp;</td>
+<td valign="center">Print error message if Tcl_Init() fails</td>
+</tr>
+<tr><td valign="center">
+<small><tt>&nbsp;&nbsp;/*&nbsp;Call&nbsp;Tcl_CreateCommand()?&nbsp;*/<br>
+&nbsp;&nbsp;Tcl_Eval(interp,&nbsp;zInputLoop);<br>
+&nbsp;&nbsp;return&nbsp;0;<br>
+}</tt></small></td>
+<td></td><td></td><td></td><td></td>
+</tr>
+</table>
+<p><table><tr><td valign="top"><img src="image3"></td>
+<td valign="top"><b>But now the program is not standalone.</b></td></tr></table>
+</p>
+
+<br clear="both"><p><hr></p>
+<h2 align="center">How <tt>Tcl_Init()</tt> Works</h2>
+<p><ul><li>Computes the value of variable <tt>tcl_libPath</tt>.</li></ul><ul><li>Invokes the procedure named &quot;<tt>tclInit</tt>&quot;</li></ul><ul><li>A default <tt>tclInit</tt> procedure is built into Tcl.
+ You can define an alternative <tt>tclInit</tt> procedure
+ prior to calling <tt>Tcl_Init()</tt>.</li></ul></p>
+<br clear="both"><p><hr></p>
+<h2 align="center">The Default <tt>initTcl</tt> Procedure</h2>
+<table cellspacing="0" cellpadding="0" border="0">
+<tr><td valign="center">
+<small><tt>set&nbsp;errors&nbsp;{}<br>
+set&nbsp;dirs&nbsp;{}<br>
+if&nbsp;{[info&nbsp;exists&nbsp;tcl_library]}&nbsp;{<br>
+&nbsp;&nbsp;lappend&nbsp;dirs&nbsp;$tcl_library<br>
+}&nbsp;else&nbsp;{<br>
+&nbsp;&nbsp;if&nbsp;{[info&nbsp;exists&nbsp;env(TCL_LIBRARY)]}&nbsp;{<br>
+&nbsp;&nbsp;&nbsp;&nbsp;lappend&nbsp;dirs&nbsp;$env(TCL_LIBRARY)<br>
+&nbsp;&nbsp;}<br>
+&nbsp;&nbsp;lappend&nbsp;dirs&nbsp;$tclDefaultLibrary<br>
+&nbsp;&nbsp;unset&nbsp;tclDefaultLibrary<br>
+&nbsp;&nbsp;set&nbsp;dirs&nbsp;[concat&nbsp;$dirs&nbsp;$tcl_libPath]<br>
+}<br>
+foreach&nbsp;i&nbsp;$dirs&nbsp;{<br>
+&nbsp;&nbsp;set&nbsp;tcl_library&nbsp;$i<br>
+&nbsp;&nbsp;set&nbsp;tclfile&nbsp;[file&nbsp;join&nbsp;$i&nbsp;init.tcl]<br>
+&nbsp;&nbsp;if&nbsp;{[file&nbsp;exists&nbsp;$tclfile]}&nbsp;{<br>
+&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;{![catch&nbsp;{uplevel&nbsp;#0&nbsp;[list&nbsp;source&nbsp;$tclfile]}&nbsp;msg]}&nbsp;{<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return<br>
+&nbsp;&nbsp;&nbsp;&nbsp;}&nbsp;else&nbsp;{<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;append&nbsp;errors&nbsp;"$tclfile:&nbsp;$msg\n$errorInfo\n"<br>
+&nbsp;&nbsp;&nbsp;&nbsp;}<br>
+&nbsp;&nbsp;}<br>
+}<br>
+error&nbsp;"Can't&nbsp;find&nbsp;a&nbsp;usable&nbsp;init.tcl&nbsp;..."</tt></small></td>
+<td></td><td></td><td></td><td></td>
+</tr>
+</table>
+
+<br clear="both"><p><hr></p>
+<h2 align="center">The Default Initialization Sequence</h2>
+<p><ul><li>The <tt>tclInit</tt> procedure locates and sources the <tt>init.tcl</tt>
+ script. The directory that contains <tt>init.tcl</tt> is stored in
+ the <tt>tcl_library</tt> variable.</li></ul><ul><li>The <tt>init.tcl</tt> script creates an <tt>unknown</tt> procedure.
+ The <tt>unknown</tt> procedure will run whenever Tcl encounters an
+ unknown command.</li></ul><ul><li>The <tt>unknown</tt> procedure consults the file <tt>tclIndex</tt> in the
+ <tt>tcl_library</tt> directory to see if the command is defined by one of
+ the initialization scripts.</li></ul><ul><li>The <tt>unknown</tt> procedure sources any needed initialization scripts
+ and retries the command.</li></ul><table><tr><td valign="top"><img src="image3"></td>
+<td valign="top"><b>Commands defined in the initialization scripts are loaded
+ on demand.</b></td></tr></table></p>
+<br clear="both"><p><hr></p>
+<h2 align="center">Standalone Initialization Techniques</h2>
+<p><p><b>Manually execute all initialization scripts</b></p>
+<ul><li>Convert all initialization scripts into C strings and
+ put them in the executable.</li></ul><ul><li>Call <tt>Tcl_Eval()</tt> on each initialization script and omit the
+ call to <tt>Tcl_Init()</tt></li></ul><ul><li>Or, redefine <tt>tclInit</tt> so that it does not attempt to source
+ <tt>init.tcl</tt> then call <tt>Tcl_Eval()</tt> on each initialization
+ script after <tt>Tcl_Init()</tt> returns.</li></ul><table><tr><td valign="top"><img src="image3"></td>
+<td valign="top"><b>This approach is not recommended</b></td></tr></table></p>
+<br clear="both"><p><hr></p>
+<h2 align="center">Standalone Initialization Techniques</h2>
+<p><p><b>Redefining the builtin <tt>source</tt> command</b></p>
+<ul><li>Convert all initialization scripts into C strings and
+ put them in the executable.</li></ul><ul><li>Create a new <tt>source</tt> command that
+ calls <tt>Tcl_Eval()</tt> on the appropriate built-in string
+ instead of reading from the disk.</li></ul><ul><li>Read from disk if the named file is not one that is built in.</li></ul></p>
+<br clear="both"><p><hr></p>
+<h2 align="center">Redefining <tt>source</tt></h2>
+<table cellspacing="0" cellpadding="0" border="0">
+<tr><td valign="center">
+<small><tt>static&nbsp;char&nbsp;zInitTcl[]&nbsp;=&nbsp;"...";<br>
+static&nbsp;char&nbsp;zParrayTcl[]&nbsp;=&nbsp;"...";</tt></small></td>
+<td>&nbsp;&nbsp;</td>
+<td valign="center"><img src="image2"></td>
+<td>&nbsp;&nbsp;</td>
+<td valign="center">Scripts <tt>init.tcl</tt> and <tt>parray.tcl</tt></td>
+</tr>
+<tr><td valign="center">
+<small><tt><br>
+int&nbsp;NewSourceCmd(TCLARGS){</tt></small></td>
+<td></td><td></td><td></td><td></td>
+</tr>
+<tr><td valign="center">
+<small><tt>&nbsp;&nbsp;if(&nbsp;!strcmp(argv[1],"/builtin/init.tcl")&nbsp;)<br>
+&nbsp;&nbsp;&nbsp;&nbsp;return&nbsp;Tcl_Eval(interp,&nbsp;zInitTcl);<br>
+&nbsp;&nbsp;if(&nbsp;!strcmp(argv[1],"/builtin/parray.tcl")&nbsp;)<br>
+&nbsp;&nbsp;&nbsp;&nbsp;return&nbsp;Tcl_Eval(interp,&nbsp;zParrayTcl);</tt></small></td>
+<td>&nbsp;&nbsp;</td>
+<td valign="center"><img src="image2"></td>
+<td>&nbsp;&nbsp;</td>
+<td valign="center">Call <tt>Tcl_Eval()</tt> on builtin strings if the names match</td>
+</tr>
+<tr><td valign="center">
+<small><tt>&nbsp;&nbsp;return&nbsp;Tcl_EvalFile(interp,&nbsp;argv[1]);</tt></small></td>
+<td>&nbsp;&nbsp;</td>
+<td valign="center"><img src="image2"></td>
+<td>&nbsp;&nbsp;</td>
+<td valign="center">Call <tt>Tcl_EvalFile()</tt> if no match</td>
+</tr>
+<tr><td valign="center">
+<small><tt>}<br>
+&nbsp;<br>
+int&nbsp;main(int&nbsp;argc,&nbsp;char&nbsp;**argv){<br>
+&nbsp;&nbsp;Tcl_Interp&nbsp;*interp;</tt></small></td>
+<td></td><td></td><td></td><td></td>
+</tr>
+<tr><td valign="center">
+<small><tt>&nbsp;&nbsp;setenv("TCL_LIBRARY","/builtin");</tt></small></td>
+<td>&nbsp;&nbsp;</td>
+<td valign="center"><img src="image2"></td>
+<td>&nbsp;&nbsp;</td>
+<td valign="center">Causes <tt>tclInit</tt> to look for <tt>init.tcl</tt> in <tt>/builtin</tt></td>
+</tr>
+<tr><td valign="center">
+<small><tt>&nbsp;&nbsp;interp&nbsp;=&nbsp;Tcl_CreateInterp();</tt></small></td>
+<td></td><td></td><td></td><td></td>
+</tr>
+<tr><td valign="center">
+<small><tt>&nbsp;&nbsp;Tcl_CreateCommand(interp,&nbsp;"source",<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;NewSourceCmd,&nbsp;0,&nbsp;0);</tt></small></td>
+<td>&nbsp;&nbsp;</td>
+<td valign="center"><img src="image2"></td>
+<td>&nbsp;&nbsp;</td>
+<td valign="center">Redefine <tt>source</tt></td>
+</tr>
+<tr><td valign="center">
+<small><tt>&nbsp;&nbsp;Tcl_Init(interp);<br>
+&nbsp;&nbsp;Tcl_Eval(interp,&nbsp;zInputLoop);<br>
+&nbsp;&nbsp;return&nbsp;0;<br>
+}</tt></small></td>
+<td></td><td></td><td></td><td></td>
+</tr>
+</table>
+
+<br clear="both"><p><hr></p>
+<h2 align="center">Redefining <tt>source</tt></h2>
+<p><ul><li>This approach works for all versions of Tcl and Tk.</li></ul><ul><li>Also need to redefine the "<tt>file exists</tt>" Tcl command since it
+ too is used by <tt>tclInit</tt>.</li></ul><ul><li>To verify that the program is really standalone, remove the call
+ to <tt>Tcl_EvalFile()</tt>.</li></ul></p>
+<br clear="both"><p><hr></p>
+<h2 align="center">Standalone Initialization Techniques</h2>
+<p><p><b>Use the <tt>Tcl</tt>*<tt>InsertProc()</tt> functions</b></p>
+<ul><li>Three routines that overload basic file I/O operations:
+ <ul>
+ <li> <tt>TclStatInsertProc()</tt> </li>
+ <li> <tt>TclAccessInsertProc()</tt> </li>
+ <li> <tt>TclOpenFileChannelInsertProc()</tt> </li>
+ </ul></li></ul><ul><li>Allows us to implement a virtual filesystem that overlays the
+ real filesystem.</li></ul><ul><li>The virtual filesystem contains all the initialization scripts
+ as compiled-in strings. The initialization scripts look like
+ they are resident on disk even though they are built in.</li></ul><ul><li>These functions first appeared in Tcl8.0.3.
+ Presumably to support TclPro Wrapper.</li></ul><ul><li>The only documentation is comments on the code.
+ See the Tcl source file <tt>generic/tclIOUtil.c</tt></li></ul></p>
+<br clear="both"><p><hr></p>
+<h2 align="center">The <tt>TclStatInsertProc()</tt> Function</h2>
+<p><ul><li>Sole argument is a pointer to a function whose interface is the
+ same as <tt>stat()</tt></li></ul><ul><li>Functions are stacked. Tcl tries each <tt>stat</tt> function on the
+ list, beginning with the most recently inserted, until one succeeds.</li></ul></p>
+<br clear="both"><p><hr></p>
+<h2 align="center">The <tt>TclStatInsertProc()</tt> Function</h2>
+<table cellspacing="0" cellpadding="0" border="0">
+<tr><td valign="center">
+<small><tt>#include&nbsp;&lt;tclInt.h></tt></small></td>
+<td>&nbsp;&nbsp;</td>
+<td valign="center"><img src="image2"></td>
+<td>&nbsp;&nbsp;</td>
+<td valign="center">Rather than <tt>&lt;tcl.h&gt;</tt>!</td>
+</tr>
+<tr><td valign="center">
+<small><tt><br>
+static&nbsp;int<br>
+BltinFileStat(char&nbsp;*path,struct&nbsp;stat&nbsp;*buf){<br>
+&nbsp;&nbsp;char&nbsp;*zData;<br>
+&nbsp;&nbsp;int&nbsp;nData;</tt></small></td>
+<td></td><td></td><td></td><td></td>
+</tr>
+<tr><td valign="center">
+<small><tt>&nbsp;&nbsp;zData&nbsp;=&nbsp;FindBuiltinFile(path,&nbsp;0,&nbsp;&amp;nData);</tt></small></td>
+<td>&nbsp;&nbsp;</td>
+<td valign="center"><img src="image2"></td>
+<td>&nbsp;&nbsp;</td>
+<td valign="center">Check if <tt>path</tt> is a builtin</td>
+</tr>
+<tr><td valign="center">
+<small><tt>&nbsp;&nbsp;if(&nbsp;zData==0&nbsp;){<br>
+&nbsp;&nbsp;&nbsp;&nbsp;return&nbsp;-1;<br>
+&nbsp;&nbsp;}</tt></small></td>
+<td>&nbsp;&nbsp;</td>
+<td valign="center"><img src="image2"></td>
+<td>&nbsp;&nbsp;</td>
+<td valign="center">Fail if <tt>path</tt> is not a builtin</td>
+</tr>
+<tr><td valign="center">
+<small><tt>&nbsp;&nbsp;memset(buf,&nbsp;0,&nbsp;sizeof(*buf));<br>
+&nbsp;&nbsp;buf->st_mode&nbsp;=&nbsp;0400;<br>
+&nbsp;&nbsp;buf->st_size&nbsp;=&nbsp;nData;</tt></small></td>
+<td></td><td></td><td></td><td></td>
+</tr>
+<tr><td valign="center">
+<small><tt>&nbsp;&nbsp;return&nbsp;0;</tt></small></td>
+<td>&nbsp;&nbsp;</td>
+<td valign="center"><img src="image2"></td>
+<td>&nbsp;&nbsp;</td>
+<td valign="center">Success if it is builtin</td>
+</tr>
+<tr><td valign="center">
+<small><tt>}<br>
+&nbsp;<br>
+int&nbsp;main(int&nbsp;argc,&nbsp;char&nbsp;**argv){<br>
+&nbsp;&nbsp;Tcl_Interp&nbsp;*interp;</tt></small></td>
+<td></td><td></td><td></td><td></td>
+</tr>
+<tr><td valign="center">
+<small><tt>&nbsp;&nbsp;TclStatInsertProc(BltinFileStat);</tt></small></td>
+<td>&nbsp;&nbsp;</td>
+<td valign="center"><img src="image2"></td>
+<td>&nbsp;&nbsp;</td>
+<td valign="center">Register new <tt>stat</tt> function</td>
+</tr>
+<tr><td valign="center">
+<small><tt>&nbsp;&nbsp;interp&nbsp;=&nbsp;Tcl_CreateInterp();<br>
+&nbsp;&nbsp;Tcl_Init(interp);<br>
+&nbsp;&nbsp;Tcl_Eval(interp,&nbsp;zInputLoop);<br>
+&nbsp;&nbsp;return&nbsp;0;<br>
+}</tt></small></td>
+<td></td><td></td><td></td><td></td>
+</tr>
+</table>
+
+<br clear="both"><p><hr></p>
+<h2 align="center">The <tt>TclAccessInsertProc()</tt> Function</h2>
+<table cellspacing="0" cellpadding="0" border="0">
+<tr><td valign="center">
+<small><tt>#include&nbsp;&lt;tclInt.h></tt></small></td>
+<td>&nbsp;&nbsp;</td>
+<td valign="center"><img src="image2"></td>
+<td>&nbsp;&nbsp;</td>
+<td valign="center">Rather than <tt>&lt;tcl.h&gt;</tt>!</td>
+</tr>
+<tr><td valign="center">
+<small><tt><br>
+/*&nbsp;BltinFileStat()&nbsp;not&nbsp;shown...&nbsp;*/<br>
+&nbsp;<br>
+static&nbsp;int<br>
+BltinFileAccess(char&nbsp;*path,&nbsp;int&nbsp;mode){<br>
+&nbsp;&nbsp;char&nbsp;*zData;</tt></small></td>
+<td></td><td></td><td></td><td></td>
+</tr>
+<tr><td valign="center">
+<small><tt>&nbsp;&nbsp;if(&nbsp;mode&nbsp;&amp;&nbsp;3&nbsp;)&nbsp;return&nbsp;-1;</tt></small></td>
+<td>&nbsp;&nbsp;</td>
+<td valign="center"><img src="image2"></td>
+<td>&nbsp;&nbsp;</td>
+<td valign="center">All builtins are read-only</td>
+</tr>
+<tr><td valign="center">
+<small><tt>&nbsp;&nbsp;zData&nbsp;=&nbsp;FindBuiltinFile(path,&nbsp;0,&nbsp;&amp;nData);</tt></small></td>
+<td>&nbsp;&nbsp;</td>
+<td valign="center"><img src="image2"></td>
+<td>&nbsp;&nbsp;</td>
+<td valign="center">Check if <tt>path</tt> is a builtin</td>
+</tr>
+<tr><td valign="center">
+<small><tt>&nbsp;&nbsp;if(&nbsp;zData==0&nbsp;)&nbsp;return&nbsp;-1;</tt></small></td>
+<td>&nbsp;&nbsp;</td>
+<td valign="center"><img src="image2"></td>
+<td>&nbsp;&nbsp;</td>
+<td valign="center">Fail if <tt>path</tt> is not a builtin</td>
+</tr>
+<tr><td valign="center">
+<small><tt>&nbsp;&nbsp;return&nbsp;0;</tt></small></td>
+<td>&nbsp;&nbsp;</td>
+<td valign="center"><img src="image2"></td>
+<td>&nbsp;&nbsp;</td>
+<td valign="center">Success if it is builtin</td>
+</tr>
+<tr><td valign="center">
+<small><tt>}<br>
+&nbsp;<br>
+int&nbsp;main(int&nbsp;argc,&nbsp;char&nbsp;**argv){<br>
+&nbsp;&nbsp;Tcl_Interp&nbsp;*interp;</tt></small></td>
+<td></td><td></td><td></td><td></td>
+</tr>
+<tr><td valign="center">
+<small><tt>&nbsp;&nbsp;TclStatInsertProc(BltinFileStat);<br>
+&nbsp;&nbsp;TclAccessInsertProc(BltinFileAccess);</tt></small></td>
+<td>&nbsp;&nbsp;</td>
+<td valign="center"><img src="image2"></td>
+<td>&nbsp;&nbsp;</td>
+<td valign="center">Register new <tt>stat</tt> and <tt>access</tt> functions</td>
+</tr>
+<tr><td valign="center">
+<small><tt>&nbsp;&nbsp;interp&nbsp;=&nbsp;Tcl_CreateInterp();<br>
+&nbsp;&nbsp;Tcl_Init(interp);<br>
+&nbsp;&nbsp;Tcl_Eval(interp,&nbsp;zInputLoop);<br>
+&nbsp;&nbsp;return&nbsp;0;<br>
+}</tt></small></td>
+<td></td><td></td><td></td><td></td>
+</tr>
+</table>
+
+<br clear="both"><p><hr></p>
+<h2 align="center">The <tt>TclOpenFileChannelInsertProc()</tt> Function</h2>
+<table cellspacing="0" cellpadding="0" border="0">
+<tr><td valign="center">
+<small><tt>static&nbsp;Tcl_Channel&nbsp;BuiltinFileOpen(<br>
+&nbsp;&nbsp;Tcl_Interp&nbsp;*interp,&nbsp;&nbsp;&nbsp;/*&nbsp;The&nbsp;TCL&nbsp;interpreter&nbsp;doing&nbsp;the&nbsp;open&nbsp;*/<br>
+&nbsp;&nbsp;char&nbsp;*zFilename,&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;/*&nbsp;Name&nbsp;of&nbsp;the&nbsp;file&nbsp;to&nbsp;open&nbsp;*/<br>
+&nbsp;&nbsp;char&nbsp;*modeString,&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;/*&nbsp;Mode&nbsp;string&nbsp;for&nbsp;the&nbsp;open&nbsp;(ignored)&nbsp;*/<br>
+&nbsp;&nbsp;int&nbsp;permissions&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;/*&nbsp;Permissions&nbsp;for&nbsp;a&nbsp;newly&nbsp;created&nbsp;file&nbsp;(ignored)&nbsp;*/<br>
+){<br>
+&nbsp;&nbsp;char&nbsp;*zData;<br>
+&nbsp;&nbsp;BuiltinFileStruct&nbsp;*p;<br>
+&nbsp;&nbsp;int&nbsp;nData;<br>
+&nbsp;&nbsp;char&nbsp;zName[50];<br>
+&nbsp;&nbsp;Tcl_Channel&nbsp;chan;<br>
+&nbsp;&nbsp;static&nbsp;int&nbsp;count&nbsp;=&nbsp;1;<br>
+&nbsp;<br>
+&nbsp;&nbsp;zData&nbsp;=&nbsp;FindBuiltinFile(zFilename,&nbsp;1,&nbsp;&amp;nData);<br>
+&nbsp;&nbsp;if(&nbsp;zData==0&nbsp;)&nbsp;return&nbsp;NULL;<br>
+&nbsp;&nbsp;p&nbsp;=&nbsp;(BuiltinFileStruct*)Tcl_Alloc(&nbsp;sizeof(BuiltinFileStruct)&nbsp;);<br>
+&nbsp;&nbsp;if(&nbsp;p==0&nbsp;)&nbsp;return&nbsp;NULL;<br>
+&nbsp;&nbsp;p->zData&nbsp;=&nbsp;zData;<br>
+&nbsp;&nbsp;p->nData&nbsp;=&nbsp;nData;<br>
+&nbsp;&nbsp;p->cursor&nbsp;=&nbsp;0;<br>
+&nbsp;&nbsp;sprintf(zName,"etbi_bffffc7c_8049b04",((int)BuiltinFileOpen)>>12,count++);<br>
+&nbsp;&nbsp;chan&nbsp;=&nbsp;Tcl_CreateChannel(&amp;builtinChannelType,&nbsp;zName,&nbsp;<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(ClientData)p,&nbsp;TCL_READABLE);<br>
+&nbsp;&nbsp;return&nbsp;chan;<br>
+}</tt></small></td>
+<td></td><td></td><td></td><td></td>
+</tr>
+</table>
+
+<br clear="both"><p><hr></p>
+<h2 align="center">The <tt>TclOpenFileChannelInsertProc()</tt> Function</h2>
+<table cellspacing="0" cellpadding="0" border="0">
+<tr><td valign="center">
+<small><tt>static&nbsp;Tcl_ChannelType&nbsp;builtinChannelType&nbsp;=&nbsp;{<br>
+&nbsp;&nbsp;"builtin",&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;/*&nbsp;Type&nbsp;name.&nbsp;*/<br>
+&nbsp;&nbsp;NULL,&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;/*&nbsp;Always&nbsp;non-blocking.*/<br>
+&nbsp;&nbsp;BuiltinFileClose,&nbsp;&nbsp;&nbsp;/*&nbsp;Close&nbsp;proc.&nbsp;*/<br>
+&nbsp;&nbsp;BuiltinFileInput,&nbsp;&nbsp;&nbsp;/*&nbsp;Input&nbsp;proc.&nbsp;*/<br>
+&nbsp;&nbsp;BuiltinFileOutput,&nbsp;&nbsp;/*&nbsp;Output&nbsp;proc.&nbsp;*/<br>
+&nbsp;&nbsp;BuiltinFileSeek,&nbsp;&nbsp;&nbsp;&nbsp;/*&nbsp;Seek&nbsp;proc.&nbsp;*/<br>
+&nbsp;&nbsp;NULL,&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;/*&nbsp;Set&nbsp;option&nbsp;proc.&nbsp;*/<br>
+&nbsp;&nbsp;NULL,&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;/*&nbsp;Get&nbsp;option&nbsp;proc.&nbsp;*/<br>
+&nbsp;&nbsp;BuiltinFileWatch,&nbsp;&nbsp;&nbsp;/*&nbsp;Watch&nbsp;for&nbsp;events&nbsp;on&nbsp;console.&nbsp;*/<br>
+&nbsp;&nbsp;BuiltinFileHandle,&nbsp;&nbsp;/*&nbsp;Get&nbsp;a&nbsp;handle&nbsp;from&nbsp;the&nbsp;device.&nbsp;*/<br>
+};</tt></small></td>
+<td></td><td></td><td></td><td></td>
+</tr>
+</table>
+<p>
+ <p>For additional information see:</p>
+ <ul>
+ <li>The man page for <tt>Tcl_CreateChannel()</tt></li>
+ <li>Tk source code file <tt>generic/tkConsole.c</tt></li>
+ </ul>
+</p>
+
+<br clear="both"><p><hr></p>
+<h2 align="center">Initializing Tk</h2>
+<p><ul><li>All the same initialization script issues as Tcl</li></ul><ul><li>Tk initialization scripts are in a different directory
+ than the Tcl initialization scripts - the "Tk Library"</li></ul><ul><li>Call <tt>Tk_Init()</tt> after <tt>Tcl_Init()</tt></li></ul><ul><li>Must have an event loop or Tk will not work!</li></ul></p>
+<br clear="both"><p><hr></p>
+<h2 align="center">Implementing An Event Loop</h2>
+<table cellspacing="0" cellpadding="0" border="0">
+<tr><td valign="center">
+<small><tt>button&nbsp;.b&nbsp;-text&nbsp;Hello&nbsp;-command&nbsp;exit<br>
+pack&nbsp;.b</tt></small></td>
+<td>&nbsp;&nbsp;</td>
+<td valign="center"><img src="image2"></td>
+<td>&nbsp;&nbsp;</td>
+<td valign="center">Create a Tk interface</td>
+</tr>
+<tr><td valign="center">
+<small><tt><br>
+</tt></small></td>
+<td></td><td></td><td></td><td></td>
+</tr>
+<tr><td valign="center">
+<small><tt>bind&nbsp;.&nbsp;&lt;Destroy>&nbsp;{<br>
+&nbsp;&nbsp;if&nbsp;{![winfo&nbsp;exists&nbsp;.]}&nbsp;exit<br>
+}</tt></small></td>
+<td>&nbsp;&nbsp;</td>
+<td valign="center"><img src="image2"></td>
+<td>&nbsp;&nbsp;</td>
+<td valign="center">Close the application when the main window
+ is destroyed</td>
+</tr>
+<tr><td valign="center">
+<small><tt><br>
+</tt></small></td>
+<td></td><td></td><td></td><td></td>
+</tr>
+<tr><td valign="center">
+<small><tt>while&nbsp;1&nbsp;{vwait&nbsp;forever}</tt></small></td>
+<td>&nbsp;&nbsp;</td>
+<td valign="center"><img src="image2"></td>
+<td>&nbsp;&nbsp;</td>
+<td valign="center">The event loop</td>
+</tr>
+</table>
+
+<br clear="both"><p><hr></p>
+<h2 align="center">"Hello, World!" Using Tk</h2>
+<table cellspacing="0" cellpadding="0" border="0">
+<tr><td valign="center">
+<small><tt>#include&nbsp;&lt;tk.h><br>
+&nbsp;<br>
+</tt></small></td>
+<td></td><td></td><td></td><td></td>
+</tr>
+<tr><td valign="center">
+<small><tt>static&nbsp;char&nbsp;zHello[]&nbsp;=&nbsp;</tt></small></td>
+<td>&nbsp;&nbsp;</td>
+<td valign="center"><img src="image2"></td>
+<td>&nbsp;&nbsp;</td>
+<td valign="center">The application code</td>
+</tr>
+<tr><td valign="center">
+<small><tt>&nbsp;&nbsp;"button&nbsp;.b&nbsp;"<br>
+&nbsp;&nbsp;&nbsp;&nbsp;"-text&nbsp;{Hello,&nbsp;World}&nbsp;"<br>
+&nbsp;&nbsp;&nbsp;&nbsp;"-command&nbsp;exit\n"<br>
+&nbsp;&nbsp;"pack&nbsp;.b\n";<br>
+&nbsp;<br>
+</tt></small></td>
+<td></td><td></td><td></td><td></td>
+</tr>
+<tr><td valign="center">
+<small><tt>static&nbsp;char&nbsp;zEventLoop[]&nbsp;=</tt></small></td>
+<td>&nbsp;&nbsp;</td>
+<td valign="center"><img src="image2"></td>
+<td>&nbsp;&nbsp;</td>
+<td valign="center">The event loop</td>
+</tr>
+<tr><td valign="center">
+<small><tt>&nbsp;&nbsp;"bind&nbsp;.&nbsp;&lt;Destroy>&nbsp;{\n"<br>
+&nbsp;&nbsp;"&nbsp;&nbsp;if&nbsp;{![winfo&nbsp;exists&nbsp;.]}&nbsp;exit\n"<br>
+&nbsp;&nbsp;"}\n"<br>
+&nbsp;&nbsp;"while&nbsp;1&nbsp;{vwait&nbsp;forever}\n";<br>
+&nbsp;<br>
+<br>
+int&nbsp;main(int&nbsp;argc,&nbsp;char&nbsp;**argv){<br>
+&nbsp;&nbsp;Tcl_Interp&nbsp;*interp;<br>
+&nbsp;&nbsp;interp&nbsp;=&nbsp;Tcl_CreateInterp();</tt></small></td>
+<td></td><td></td><td></td><td></td>
+</tr>
+<tr><td valign="center">
+<small><tt>&nbsp;&nbsp;Tcl_Init(interp);<br>
+&nbsp;&nbsp;Tk_Init(interp);</tt></small></td>
+<td>&nbsp;&nbsp;</td>
+<td valign="center"><img src="image2"></td>
+<td>&nbsp;&nbsp;</td>
+<td valign="center">We really should check the return values of the init functions...</td>
+</tr>
+<tr><td valign="center">
+<small><tt>&nbsp;&nbsp;Tcl_Eval(interp,&nbsp;zHello);</tt></small></td>
+<td></td><td></td><td></td><td></td>
+</tr>
+<tr><td valign="center">
+<small><tt>&nbsp;&nbsp;Tcl_Eval(interp,&nbsp;zEventLoop);</tt></small></td>
+<td>&nbsp;&nbsp;</td>
+<td valign="center"><img src="image2"></td>
+<td>&nbsp;&nbsp;</td>
+<td valign="center">The event loop never returns</td>
+</tr>
+<tr><td valign="center">
+<small><tt>&nbsp;&nbsp;/*NOTREACHED*/<br>
+}</tt></small></td>
+<td></td><td></td><td></td><td></td>
+</tr>
+</table>
+
+<br clear="both"><p><hr></p>
+<h2 align="center">Compiling "Hello, World!" For Tk</h2>
+<p><p><b>Unix:</b></p>
+ <blockquote><pre>
+ $ gcc hello.c -ltk -L/usr/X11R6/lib \
+ -lX11 -ltcl -lm -ldl
+ $ ./a.out</pre></blockquote>
+
+ <p><b>Windows using Cygwin:</b></p>
+ <blockquote><pre>
+ C:> gcc hello.c -mwindows -ltk80 -ltcl80 -lm
+ C:> a.exe</pre></blockquote>
+
+ <p><b>Windows using Mingw32:</b></p>
+ <blockquote><pre>
+ C:> gcc -mno-cygwin hello.c -mwindows \
+ -ltk82 -ltcl82 -lm
+ C:> a.exe</pre></blockquote></p>
+<br clear="both"><p><hr></p>
+<h2 align="center">Making The Program Standalone</h2>
+<p><p>To make a Tcl application standalone you have to convert the following
+ initialization scripts to C strings and compile them into the
+ executable:</p>
+ <table><tr>
+ <td valign="top"><tt>
+ &nbsp;&nbsp;auto.tcl<br>
+ &nbsp;&nbsp;history.tcl<br>
+ &nbsp;&nbsp;init.tcl
+ </tt></td>
+ <td valign="top"><tt>
+ &nbsp;&nbsp;ldAout.tcl<br>
+ &nbsp;&nbsp;package.tcl
+ </tt></td>
+ <td valign="top"><tt>
+ &nbsp;&nbsp;parray.tcl<br>
+ &nbsp;&nbsp;safe.tcl
+ </tt></td>
+ <td valign="top"><tt>
+ &nbsp;&nbsp;tclIndex<br>
+ &nbsp;&nbsp;word.tcl
+ </tt></td>
+ </tr></table>
+
+ <p>To make a Tk application standalone requires these additional
+ initialization scripts from the Tk Library:</p>
+ <table><tr>
+ <td valign="top"><tt>
+ &nbsp;&nbsp;bgerror.tcl<br>
+ &nbsp;&nbsp;button.tcl<br>
+ &nbsp;&nbsp;clrpick.tcl<br>
+ &nbsp;&nbsp;comdlg.tcl<br>
+ &nbsp;&nbsp;console.tcl<br>
+ &nbsp;&nbsp;dialog.tcl
+ </tt></td>
+ <td valign="top"><tt>
+ &nbsp;&nbsp;entry.tcl<br>
+ &nbsp;&nbsp;focus.tcl<br>
+ &nbsp;&nbsp;listbox.tcl<br>
+ &nbsp;&nbsp;menu.tcl<br>
+ &nbsp;&nbsp;msgbox.tcl<br>
+ &nbsp;&nbsp;optMenu.tcl
+ </tt></td>
+ <td valign="top"><tt>
+ &nbsp;&nbsp;palette.tcl<br>
+ &nbsp;&nbsp;safetk.tcl<br>
+ &nbsp;&nbsp;scale.tcl<br>
+ &nbsp;&nbsp;scrlbar.tcl<br>
+ &nbsp;&nbsp;tclIndex<br>
+ &nbsp;&nbsp;tearoff.tcl
+ </tt></td>
+ <td valign="top"><tt>
+ &nbsp;&nbsp;text.tcl<br>
+ &nbsp;&nbsp;tk.tcl<br>
+ &nbsp;&nbsp;tkfbox.tcl<br>
+ &nbsp;&nbsp;xmfbox.tcl
+ </tt></td>
+ </tr></table>
+
+ <p>Total of about 13K lines and 400K bytes of text or 9K lines and
+ 250K bytes if you strip comments and leading spaces</p></p>
+<br clear="both"><p><hr></p>
+<h2 align="center">A Review Of The Features We Want</h2>
+<p><ol type="A">
+ <li value="1">
+ Combine C/C++ with Tcl/Tk into a single executable.</dd>
+ </li></ol>
+
+ <ol type="A">
+ <li value="2">
+ The executable should be standalone. It must not depend
+ on files not normally found on the system.
+ </li></ol>
+
+ <ol type="A">
+ <li value="3">
+ It should be difficult for end users to alter the program
+ (and introduce bugs).
+ </li></ol></p>
+<br clear="both"><p><hr></p>
+<h2 align="center">Available Programming Aids</h2>
+<p><p>Several tools are available. The chart below shows which tools
+ help achieve which objectives.</p>
+
+ <center><table border="2">
+ <tr>
+ <td></td>
+ <td colspan="3" align="center">
+ <b>Features The Tool Helps To Achieve</b></td>
+ </tr>
+ <tr>
+ <td align="center"><b>Tool Name</b></td>
+ <td align="center">Mix C and Tcl</td>
+ <td align="center">Standalone</td>
+ <td align="center">Hide Source</td>
+ </tr>
+ <tr>
+ <td>SWIG</td>
+ <td align="center"><img src="image6"></td>
+ <td>&nbsp;</td>
+ <td>&nbsp;</td>
+ </tr>
+ <tr>
+ <td>TclPro Wrapper</td>
+ <td>&nbsp;</td>
+ <td align="center"><img src="image6"></td>
+ <td align="center"><img src="image6"></td>
+ </tr>
+ <tr>
+ <td>FreeWrap</td>
+ <td>&nbsp;</td>
+ <td align="center"><img src="image6"></td>
+ <td align="center"><img src="image6"></td>
+ </tr>
+ <tr>
+ <td>Wrap</td>
+ <td>&nbsp;</td>
+ <td align="center"><img src="image6"></td>
+ <td>&nbsp;</td>
+ </tr>
+ <tr>
+ <td>mktclapp</td>
+ <td align="center"><img src="image6"></td>
+ <td align="center"><img src="image6"></td>
+ <td align="center"><img src="image6"></td>
+ </tr>
+ </table></center></p>
+<br clear="both"><p><hr></p>
+<h2 align="center">SWIG</h2>
+<table><tr><td valign="top"><img src="image7"></td>
+<td valign="top"><p><ul><li>Creates an interface between an existing C/C++ library and a high-level
+ programming language. Support for:
+ <ul>
+ <li> Tcl/Tk </li>
+ <li> Perl </li>
+ <li> Python </li>
+ <li> Java </li>
+ <li> Eiffel </li>
+ <li> Guile </li>
+ </ul></li></ul><ul><li>No changes required to C/C++ code. Can be used with legacy libraries.</li></ul><ul><li>Generates an extension, not a standalone binary</li></ul><ul><li>The tutorial on SWIG was yesterday afternoon.</li></ul><ul><li>http://www.swig.org/</li></ul></p></td></tr></table>
+
+<br clear="both"><p><hr></p>
+<h2 align="center">Wrapper Programs</h2>
+<table><tr><td valign="top"><img src="image8"></td>
+<td valign="top"><p><ul><li>Convert a pure Tcl/Tk program into a standalone binary</li></ul><ul><li>Several wrapper programs are available:
+ <ul>
+ <li> TclPro Wrapper - http://www.scriptics.com/ </li>
+ <li> FreeWrap - http://www.albany.net/~dlabelle/freewrap/freewrap.html </li>
+ <li> Wrap - http://members1.chello.nl/~j.nijtmans/wrap.html </li>
+ </ul></li></ul><ul><li>No C compiler required!</li></ul><ul><li>TclPro will convert Tcl script into bytecode so that it cannot be
+ easily read by the end user. FreeWrap encrypts the scripts.</li></ul><ul><li>FreeWrap uses compression on its executable.
+ Wrap uses compression on both the executable and on the bundled script files.</li></ul><ul><li>Usually include extensions like winico and/or BLT</li></ul></p></td></tr></table>
+
+<br clear="both"><p><hr></p>
+<h2 align="center">mktclapp</h2>
+<table><tr><td valign="top"><img src="image9"></td>
+<td valign="top"><p><ul><li>Mix C/C++ with Tcl/Tk into a standalone binary</li></ul>
+<ul><li><tt>mktclapp</tt> generates an application initialization file
+ that contains Tcl scripts as strings and makes all necessary calls
+ to <tt>Tcl_Init</tt>, <tt>Tcl_CreateCommand</tt>,
+ <tt>Tcl</tt>*<tt>InsertProc</tt>, etc.</li></ul><ul><li>Features to make it easier to write new Tcl command in C</li></ul><ul><li><tt>xmktclapp.tcl</tt> provides a GUI interface to <tt>mktclapp</tt></li></ul><ul><li>http://www.hwaci.com/sw/mktclapp/</li></ul></p></td></tr></table>
+
+<br clear="both"><p><hr></p>
+<h2 align="center">"Hello, World!" Using Mktclapp</h2>
+<p><ul><li>Download <tt>mktclapp.c</tt> and <tt>xmktclapp.tcl</tt> from
+ http://www.hwaci.com/sw/mktclapp/</li></ul><ul><li>Compile <tt>mktclapp</tt>:
+ <blockquote><pre>
+ cc -o mktclapp mktclapp.c
+ </pre></blockquote></li></ul><ul><li>Create "Hello, World!" as a Tcl script in file <tt>hw.tcl</tt>:
+ <blockquote><pre>
+ button .b -text {Hello, World!} -command exit
+ pack .b
+ </pre></blockquote></li></ul><ul><li>Launch xmktclapp:
+ <blockquote><pre>
+ wish xmktclapp.tcl
+ </pre></blockquote></li></ul></p>
+<br clear="both"><p><hr></p>
+<h2 align="center">"Hello, World!" Using Mktclapp</h2>
+<table width="100%"><tr><td valign="top"><p><ul><li>Set "Command Line Input?" to "None"</li></ul><ul><li>Set "Standalone?" to "Yes"</li></ul><ul><li>Enter "<tt>hw.mta</tt>" for the Configuration File</li></ul><ul><li>Enter "<tt>hw.c</tt>" for the Output C File</li></ul></p></td>
+<td valign="top" align="right"><img src="image10"></td></tr></table>
+
+<br clear="both"><p><hr></p>
+<h2 align="center">"Hello, World!" Using Mktclapp</h2>
+<table width="100%"><tr><td valign="top"><p><ul><li>Go to the "Tcl Scripts" page</li></ul><ul><li>Press "Insert" and add <tt>hw.tcl</tt> to the list of
+ Tcl scripts</li></ul><ul><li>Change the "Startup Script" to be <tt>hw.tcl</tt>.</li></ul><ul><li>Select File/Build and File/Exit</li></ul></p></td>
+<td valign="top" align="right"><img src="image11"></td></tr></table>
+
+<br clear="both"><p><hr></p>
+<h2 align="center">"Hello, World!" Using Mktclapp</h2>
+<p><ul><li>Mktclapp generates <tt>hw.c</tt>.
+ Compile it something like this:
+ <pre>
+ cc hw.c -ltk -L/usr/X11R6/lib -lX11 -ltcl -lm -ldl
+ </pre></li></ul><ul><li>Or, if using Cygwin:
+ <pre>
+ gcc hw.c -mwindows -ltk80 -ltcl80 -lm
+ </pre></li></ul><ul><li>Or, if using Mingw32:
+ <pre>
+ gcc -mno-cygwin hw.c -mwindows -ltk82 -ltcl82 -lm
+ </pre></li></ul><ul><li>And you're done!</li></ul></p>
+<br clear="both"><p><hr></p>
+<h2 align="center">Adding C Code To Your Program</h2>
+<p>Put the new C code in a new source file named "<tt>add.c</tt>"</p><p>
+<table cellspacing="0" cellpadding="0" border="0">
+<tr><td valign="center">
+<small><tt>#include&nbsp;"hw.h"</tt></small></td>
+<td>&nbsp;&nbsp;</td>
+<td valign="center"><img src="image2"></td>
+<td>&nbsp;&nbsp;</td>
+<td valign="center">Generated by mktclapp</td>
+</tr>
+<tr><td valign="center">
+<small><tt></tt></small></td>
+<td></td><td></td><td></td><td></td>
+</tr>
+<tr><td valign="center">
+<small><tt>int&nbsp;ET_COMMAND_add(ET_TCLARGS){</tt></small></td>
+<td>&nbsp;&nbsp;</td>
+<td valign="center"><img src="image2"></td>
+<td>&nbsp;&nbsp;</td>
+<td valign="center"><tt>ET_TCLARGS</tt> is a macro defined in <tt>hw.h</tt></td>
+</tr>
+<tr><td valign="center">
+<small><tt>&nbsp;&nbsp;int&nbsp;a,&nbsp;b;<br>
+&nbsp;&nbsp;char&nbsp;zResult[30];<br>
+&nbsp;&nbsp;a&nbsp;=&nbsp;atoi(argv[1]);<br>
+&nbsp;&nbsp;b&nbsp;=&nbsp;atoi(argv[2]);<br>
+&nbsp;&nbsp;sprintf(zResult,&nbsp;"-1073742724",&nbsp;a+b);<br>
+&nbsp;&nbsp;Tcl_SetResult(interp,&nbsp;zResult,&nbsp;TCL_VOLATILE);<br>
+&nbsp;&nbsp;return&nbsp;TCL_OK;<br>
+}</tt></small></td>
+<td></td><td></td><td></td><td></td>
+</tr>
+</table>
+
+<br clear="both"><p><hr></p>
+<h2 align="center">Adding C Code To Your Program</h2>
+<table width="100%"><tr><td valign="top"><p><ul><li>Go to the "C/C++ Modules" page of xmktclapp.tcl</li></ul>
+<ul><li>Press "Insert" and add <tt>add.c</tt> to the list of
+ C/C++ modules</p></li></ul></li></ul><ul><li>Select File/Build and File/Exit</li></ul></p></td>
+<td valign="top" align="right"><img src="image12"></td></tr></table>
+
+<br clear="both"><p><hr></p>
+<h2 align="center">Adding C Code To Your Program</h2>
+<p><ul><li>Compile as follows:
+ <pre>
+ cc add.c hw.c -ltk -L/usr/X11R6/lib -ltcl -lm -ldl
+ </pre></li></ul><ul><li>Or construct a Makefile that compiles <tt>add.c</tt> into <tt>add.o</tt>
+ and <tt>hw.c</tt> into <tt>hw.o</tt> and then links them.</li></ul><ul><li>Compile the same way for Windows except use the usual Windows
+ libraries and options...</li></ul><table><tr><td valign="top"><img src="image3"></td>
+<td valign="top"><b>Don't have to worry with <tt>Tcl_CreateCommand()</tt> - Mktclapp takes
+ care of that automatically.</b></td></tr></table></p>
+<br clear="both"><p><hr></p>
+<h2 align="center">Checking Parameters In The <tt>add</tt> Command</h2>
+<p>Modify <tt>add.c</tt> to insure the <tt>add</tt> command
+ is called with exactly two integer arguments</p><p>
+<table cellspacing="0" cellpadding="0" border="0">
+<tr><td valign="center">
+<small><tt>#include&nbsp;"hw.h"<br>
+&nbsp;<br>
+int&nbsp;ET_COMMAND_add(ET_TCLARGS){<br>
+&nbsp;&nbsp;int&nbsp;a,&nbsp;b;<br>
+&nbsp;&nbsp;char&nbsp;zResult[30];</tt></small></td>
+<td></td><td></td><td></td><td></td>
+</tr>
+<tr><td valign="center">
+<small><tt>&nbsp;&nbsp;if(&nbsp;argc!=3&nbsp;){<br>
+&nbsp;&nbsp;&nbsp;&nbsp;Tcl_AppendResult(interp,<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"wrong&nbsp;#&nbsp;args:&nbsp;should&nbsp;be:&nbsp;\"",<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;argv[0],&nbsp;"&nbsp;VALUE&nbsp;VALUE\"",&nbsp;0);<br>
+&nbsp;&nbsp;&nbsp;&nbsp;return&nbsp;TCL_ERROR;<br>
+&nbsp;&nbsp;}</tt></small></td>
+<td>&nbsp;&nbsp;</td>
+<td valign="center"><img src="image2"></td>
+<td>&nbsp;&nbsp;</td>
+<td valign="center">Report an error if there are not exactly
+ 2 arguments</td>
+</tr>
+<tr><td valign="center">
+<small><tt>&nbsp;&nbsp;if(&nbsp;Tcl_GetInt(interp,&nbsp;argv[1],&nbsp;&amp;a)!=TCL_OK&nbsp;){<br>
+&nbsp;&nbsp;&nbsp;&nbsp;return&nbsp;TCL_ERROR;<br>
+&nbsp;&nbsp;}</tt></small></td>
+<td>&nbsp;&nbsp;</td>
+<td valign="center"><img src="image2"></td>
+<td>&nbsp;&nbsp;</td>
+<td valign="center">Report an error if the first argument is
+ not an integer</td>
+</tr>
+<tr><td valign="center">
+<small><tt>&nbsp;&nbsp;if(&nbsp;Tcl_GetInt(interp,&nbsp;argv[2],&nbsp;&amp;b)!=TCL_OK&nbsp;){<br>
+&nbsp;&nbsp;&nbsp;&nbsp;return&nbsp;TCL_ERROR;<br>
+&nbsp;&nbsp;}</tt></small></td>
+<td>&nbsp;&nbsp;</td>
+<td valign="center"><img src="image2"></td>
+<td>&nbsp;&nbsp;</td>
+<td valign="center">Do the same for the second argument</td>
+</tr>
+<tr><td valign="center">
+<small><tt>&nbsp;&nbsp;sprintf(zResult,&nbsp;"-1073742724",&nbsp;a+b);<br>
+&nbsp;&nbsp;Tcl_SetResult(interp,&nbsp;zResult,&nbsp;TCL_VOLATILE);<br>
+&nbsp;&nbsp;return&nbsp;TCL_OK;<br>
+}</tt></small></td>
+<td></td><td></td><td></td><td></td>
+</tr>
+</table>
+
+<br clear="both"><p><hr></p>
+<h2 align="center">Using The Tcl_Obj Interface</h2>
+<p>In the file <tt>objadd.c</tt> put this code:</p><p>
+<table cellspacing="0" cellpadding="0" border="0">
+<tr><td valign="center">
+<small><tt>#include&nbsp;"hw.h"</tt></small></td>
+<td></td><td></td><td></td><td></td>
+</tr>
+<tr><td valign="center">
+<small><tt><br>
+int&nbsp;ET_OBJCOMMAND_add2(ET_OBJARGS){<br>
+&nbsp;&nbsp;int&nbsp;a,&nbsp;b;</tt></small></td>
+<td>&nbsp;&nbsp;</td>
+<td valign="center"><img src="image2"></td>
+<td>&nbsp;&nbsp;</td>
+<td valign="center">Use "<tt>ET_OBJCOMMAND</tt>" instead of "<tt>ET_COMMAND</tt>" and
+ "<tt>ET_OBJARGS</tt>" instead of "<tt>ET_TCLARGS</tt>"</td>
+</tr>
+<tr><td valign="center">
+<small><tt>&nbsp;&nbsp;if(&nbsp;objc!=3&nbsp;){<br>
+&nbsp;&nbsp;&nbsp;&nbsp;Tcl_WrongNumArgs(interp,&nbsp;1,&nbsp;objv,<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"number&nbsp;number");<br>
+&nbsp;&nbsp;&nbsp;&nbsp;return&nbsp;TCL_ERROR;<br>
+&nbsp;&nbsp;}</tt></small></td>
+<td>&nbsp;&nbsp;</td>
+<td valign="center"><img src="image2"></td>
+<td>&nbsp;&nbsp;</td>
+<td valign="center">A special routine for "wrong # args" error</td>
+</tr>
+<tr><td valign="center">
+<small><tt>&nbsp;&nbsp;if(&nbsp;Tcl_GetIntFromObj(interp,&nbsp;objv[1],&nbsp;&amp;a)&nbsp;){</tt></small></td>
+<td>&nbsp;&nbsp;</td>
+<td valign="center"><img src="image2"></td>
+<td>&nbsp;&nbsp;</td>
+<td valign="center">Instead of <tt>Tcl_GetInt</tt></td>
+</tr>
+<tr><td valign="center">
+<small><tt>&nbsp;&nbsp;&nbsp;&nbsp;return&nbsp;TCL_ERROR;<br>
+&nbsp;&nbsp;}<br>
+&nbsp;&nbsp;if(&nbsp;Tcl_GetIntFromObj(interp,&nbsp;objv[2],&nbsp;&amp;b)&nbsp;){<br>
+&nbsp;&nbsp;&nbsp;&nbsp;return&nbsp;TCL_ERROR;<br>
+&nbsp;&nbsp;}</tt></small></td>
+<td></td><td></td><td></td><td></td>
+</tr>
+<tr><td valign="center">
+<small><tt>&nbsp;&nbsp;Tcl_SetIntObj(Tcl_GetObjResult(interp),&nbsp;a+b);</tt></small></td>
+<td>&nbsp;&nbsp;</td>
+<td valign="center"><img src="image2"></td>
+<td>&nbsp;&nbsp;</td>
+<td valign="center">Result stored as integer, not a string</td>
+</tr>
+<tr><td valign="center">
+<small><tt>&nbsp;&nbsp;return&nbsp;TCL_OK;<br>
+}</tt></small></td>
+<td></td><td></td><td></td><td></td>
+</tr>
+</table>
+
+<br clear="both"><p><hr></p>
+<h2 align="center">Speed Of Tcl_Obj Versus "char*" Interfaces</h2>
+<p><ul><li>Compile both <tt>add</tt> and <tt>add2</tt> into the same executable.</li></ul><ul><li>Compare their speeds:
+ <pre>
+ time {add 123456 654321} 10000
+ <font color="blue">26 microseconds per iteration</font>
+ time {add2 123456 654321} 10000
+ <font color="blue">4 microseconds per iteration</font>
+ </pre></li></ul><ul><li>The Tcl_Obj version is 650 faster!</li></ul><ul><li>Replace the addition with a "real" computation that takes
+ 10 milliseconds.</li></ul><ul><li>Now the Tcl_Obj version is only 0.2 faster!</li></ul><table><tr><td valign="top"><img src="image3"></td>
+<td valign="top"><b>In many real-world problems, the Tcl_Obj interface has no noticeable
+ speed advantage over the string interface.</b></td></tr></table></p>
+<br clear="both"><p><hr></p>
+<h2 align="center">More About Built-in Tcl Scripts</h2>
+<table><tr><td valign="top"><img src="image11"></td>
+<td valign="top"><p><ul><li>Comments and leading white-space are removed from the
+ script by default. Use the "Don't Strip Comments"
+ button to change this.</li></ul><ul><li>The file name must exactly match the name that is
+ used by the <tt>source</tt> command.</li></ul></p></td></tr></table>
+
+<br clear="both"><p><hr></p>
+<h2 align="center">Locations Of Libraries</h2>
+<table><tr><td valign="top"><img src="image13"></td>
+<td valign="top"><p><ul><li>Tells mktclapp where to look for script libraries.</li></ul><ul><li>All Tcl scripts in the indicated directories are
+ compiled into the <tt>appinit.c</tt> file.</li></ul><ul><li>Comments and extra white-space are removed.
+ There is no way to turn this off.</li></ul></p></td></tr></table>
+
+<br clear="both"><p><hr></p>
+<h2 align="center">Built-in Binary Data Files</h2>
+<table><tr><td valign="top"><img src="image14"></td>
+<td valign="top"><p><ul><li>Arbitrary files become part of the virtual filesystem</li></ul><ul><li>No comment or white-space removal is attempted</li></ul><ul><li>Useful for images or other binary data</li></ul></p></td></tr></table>
+
+<br clear="both"><p><hr></p>
+<h2 align="center">New Commands In Namespaces</h2>
+<p>Two underscores (__) are replaced by two colons (::) in
+ command names, thus giving the ability to define new commands
+ in a namespace</p><p>
+<table cellspacing="0" cellpadding="0" border="0">
+<tr><td valign="center">
+<small><tt>#include&nbsp;&lt;hw.h></tt></small></td>
+<td></td><td></td><td></td><td></td>
+</tr>
+<tr><td valign="center">
+<small><tt><br>
+int&nbsp;ET_COMMAND_adder__add(ET_TCLARGS){<br>
+&nbsp;&nbsp;int&nbsp;a,&nbsp;b;</tt></small></td>
+<td>&nbsp;&nbsp;</td>
+<td valign="center"><img src="image2"></td>
+<td>&nbsp;&nbsp;</td>
+<td valign="center">Creates the Tcl command called "<tt>adder::add</tt>"</td>
+</tr>
+<tr><td valign="center">
+<small><tt>&nbsp;&nbsp;char&nbsp;*zResult[30];<br>
+&nbsp;&nbsp;if(&nbsp;argc!=3&nbsp;){<br>
+&nbsp;&nbsp;&nbsp;&nbsp;Tcl_AppendResult(interp,<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"wrong&nbsp;#&nbsp;args:&nbsp;should&nbsp;be:&nbsp;\"",<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;argv[0],&nbsp;"&nbsp;VALUE&nbsp;VALUE\"",&nbsp;0);<br>
+&nbsp;&nbsp;&nbsp;&nbsp;return&nbsp;TCL_ERROR;<br>
+&nbsp;&nbsp;}<br>
+&nbsp;&nbsp;if(&nbsp;Tcl_GetInt(interp,&nbsp;argv[1],&nbsp;&amp;a)!=TCL_OK&nbsp;){<br>
+&nbsp;&nbsp;&nbsp;&nbsp;return&nbsp;TCL_ERROR;<br>
+&nbsp;&nbsp;}<br>
+&nbsp;&nbsp;if(&nbsp;Tcl_GetInt(interp,&nbsp;argv[1],&nbsp;&amp;b)!=TCL_OK&nbsp;){<br>
+&nbsp;&nbsp;&nbsp;&nbsp;return&nbsp;TCL_ERROR;<br>
+&nbsp;&nbsp;}<br>
+&nbsp;&nbsp;sprintf(zResult,&nbsp;"-1073742724",&nbsp;a+b);<br>
+&nbsp;&nbsp;Tcl_SetResult(interp,&nbsp;zResult,&nbsp;TCL_VOLATILE);<br>
+&nbsp;&nbsp;return&nbsp;TCL_OK;<br>
+}</tt></small></td>
+<td></td><td></td><td></td><td></td>
+</tr>
+</table>
+
+<br clear="both"><p><hr></p>
+<h2 align="center">Adding Your Own <tt>main()</tt></h2>
+<table cellspacing="0" cellpadding="0" border="0">
+<tr><td valign="center">
+<small><tt>int&nbsp;main(int&nbsp;argc,&nbsp;char&nbsp;**argv){<br>
+&nbsp;&nbsp;/*&nbsp;Application&nbsp;specific&nbsp;initialization&nbsp;*/</tt></small></td>
+<td></td><td></td><td></td><td></td>
+</tr>
+<tr><td valign="center">
+<small><tt>&nbsp;&nbsp;Et_Init(argc,&nbsp;argv);</tt></small></td>
+<td>&nbsp;&nbsp;</td>
+<td valign="center"><img src="image2"></td>
+<td>&nbsp;&nbsp;</td>
+<td valign="center">Never returns!</td>
+</tr>
+<tr><td valign="center">
+<small><tt>&nbsp;&nbsp;/*NOTREACHED*/<br>
+&nbsp;&nbsp;return&nbsp;0;<br>
+}</tt></small></td>
+<td></td><td></td><td></td><td></td>
+</tr>
+</table>
+<p><table><tr><td valign="top"><img src="image3"></td>
+<td valign="top"><b>The "Autofork" feature is disabled if you supply your own <tt>main()</tt></b></td></tr></table>
+</p>
+
+<br clear="both"><p><hr></p>
+<h2 align="center">Initializing The Tcl Interpreter</h2>
+<table cellspacing="0" cellpadding="0" border="0">
+<tr><td valign="center">
+<small><tt>#include&nbsp;&lt;tcl.h><br>
+&nbsp;<br>
+int&nbsp;counter&nbsp;=&nbsp;0;<br>
+&nbsp;<br>
+int&nbsp;main(int&nbsp;argc,&nbsp;char&nbsp;**argv){<br>
+&nbsp;&nbsp;&nbsp;Et_Init(argc,&nbsp;argv);<br>
+&nbsp;&nbsp;&nbsp;/*NOTREACHED*/<br>
+&nbsp;&nbsp;&nbsp;return&nbsp;0;<br>
+}<br>
+&nbsp;<br>
+int&nbsp;Et_AppInit(Tcl_Interp&nbsp;*interp){</tt></small></td>
+<td></td><td></td><td></td><td></td>
+</tr>
+<tr><td valign="center">
+<small><tt>&nbsp;&nbsp;if(&nbsp;Blt_Init(Interp)&nbsp;){<br>
+&nbsp;&nbsp;&nbsp;&nbsp;return&nbsp;TCL_ERROR;<br>
+&nbsp;&nbsp;}</tt></small></td>
+<td>&nbsp;&nbsp;</td>
+<td valign="center"><img src="image2"></td>
+<td>&nbsp;&nbsp;</td>
+<td valign="center">Example: Initialize an extension</td>
+</tr>
+<tr><td valign="center">
+<small><tt>&nbsp;&nbsp;Tcl_LinkVar(interp,&nbsp;"counter",&nbsp;&amp;counter,<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;TCL_LINK_INT);</tt></small></td>
+<td>&nbsp;&nbsp;</td>
+<td valign="center"><img src="image2"></td>
+<td>&nbsp;&nbsp;</td>
+<td valign="center">Or link a C variable to a Tcl variable</td>
+</tr>
+<tr><td valign="center">
+<small><tt>&nbsp;&nbsp;return&nbsp;TCL_OK;</tt></small></td>
+<td>&nbsp;&nbsp;</td>
+<td valign="center"><img src="image2"></td>
+<td>&nbsp;&nbsp;</td>
+<td valign="center">Return TCL_OK if successful</td>
+</tr>
+<tr><td valign="center">
+<small><tt>}</tt></small></td>
+<td></td><td></td><td></td><td></td>
+</tr>
+</table>
+
+<br clear="both"><p><hr></p>
+<h2 align="center">Writing Your Own Event Loop</h2>
+<table cellspacing="0" cellpadding="0" border="0">
+<tr><td valign="center">
+<small><tt>#include&nbsp;&lt;tcl.h><br>
+</tt></small></td>
+<td></td><td></td><td></td><td></td>
+</tr>
+<tr><td valign="center">
+<small><tt>void&nbsp;Et_CustomMainLoop(Tcl_Interp&nbsp;*interp){</tt></small></td>
+<td>&nbsp;&nbsp;</td>
+<td valign="center"><img src="image2"></td>
+<td>&nbsp;&nbsp;</td>
+<td valign="center">Replaces the default event loop</td>
+</tr>
+<tr><td valign="center">
+<small><tt>&nbsp;&nbsp;return;</tt></small></td>
+<td>&nbsp;&nbsp;</td>
+<td valign="center"><img src="image2"></td>
+<td>&nbsp;&nbsp;</td>
+<td valign="center">Ex: Return without handling any events.</td>
+</tr>
+<tr><td valign="center">
+<small><tt>}<br>
+&nbsp;<br>
+int&nbsp;main(int&nbsp;argc,&nbsp;char&nbsp;**argv){</tt></small></td>
+<td></td><td></td><td></td><td></td>
+</tr>
+<tr><td valign="center">
+<small><tt>&nbsp;&nbsp;Et_Init(argc,&nbsp;argv);</tt></small></td>
+<td>&nbsp;&nbsp;</td>
+<td valign="center"><img src="image2"></td>
+<td>&nbsp;&nbsp;</td>
+<td valign="center">This now returns after initializing Tcl</td>
+</tr>
+<tr><td valign="center">
+<small><tt>&nbsp;&nbsp;/*&nbsp;Application&nbsp;code&nbsp;here&nbsp;*/<br>
+&nbsp;&nbsp;return&nbsp;0;<br>
+}</tt></small></td>
+<td></td><td></td><td></td><td></td>
+</tr>
+</table>
+
+<br clear="both"><p><hr></p>
+<h2 align="center">Writing Your Own Event Loop</h2>
+<table cellspacing="0" cellpadding="0" border="0">
+<tr><td valign="center">
+<small><tt>#include&nbsp;&lt;tcl.h><br>
+&nbsp;<br>
+void&nbsp;Et_CustomMainLoop(Tcl_Interp&nbsp;*interp){</tt></small></td>
+<td></td><td></td><td></td><td></td>
+</tr>
+<tr><td valign="center">
+<small><tt>&nbsp;&nbsp;for(;;){<br>
+&nbsp;&nbsp;&nbsp;&nbsp;Tcl_DoOneEvent(TCL_ALL_EVENTS|TCL_DONT_WAIT);<br>
+&nbsp;&nbsp;&nbsp;&nbsp;/*&nbsp;Other&nbsp;processing...&nbsp;*/<br>
+&nbsp;&nbsp;}</tt></small></td>
+<td>&nbsp;&nbsp;</td>
+<td valign="center"><img src="image2"></td>
+<td>&nbsp;&nbsp;</td>
+<td valign="center">Intermix processing and event handling</td>
+</tr>
+<tr><td valign="center">
+<small><tt>}<br>
+&nbsp;<br>
+int&nbsp;main(int&nbsp;argc,&nbsp;char&nbsp;**argv){</tt></small></td>
+<td></td><td></td><td></td><td></td>
+</tr>
+<tr><td valign="center">
+<small><tt>&nbsp;&nbsp;Et_Init(argc,&nbsp;argv);</tt></small></td>
+<td>&nbsp;&nbsp;</td>
+<td valign="center"><img src="image2"></td>
+<td>&nbsp;&nbsp;</td>
+<td valign="center">Never returns</td>
+</tr>
+<tr><td valign="center">
+<small><tt>&nbsp;&nbsp;/*NOTREACHED*/<br>
+&nbsp;&nbsp;return&nbsp;0;<br>
+}</tt></small></td>
+<td></td><td></td><td></td><td></td>
+</tr>
+</table>
+
+<br clear="both"><p><hr></p>
+<h2 align="center">Mktclapp Initialization Sequence</h2>
+<p><ul><li>Initialization starts when the <tt>Et_Init()</tt>
+ function is called either by client code or by
+ the <tt>main()</tt> that mktclapp generates</li></ul><ul><li>Create the main Tcl interpreter</li></ul><ul><li>Construct the virtual filesystem overlay by redefining
+ the <tt>source</tt> command and by using the
+ <tt>Tcl</tt>*<tt>InsertProc()</tt> functions</li></ul><ul><li>Call <tt>Et_PreInit()</tt> if the client defines it</li></ul><ul><li>Call <tt>Tcl_Init()</tt> and <tt>Tk_Init()</tt></li></ul><ul><li>Call <tt>Tcl_CreateCommand()</tt> and <tt>Tcl_CreateObjCommand()</tt>
+ for every <tt>ET_COMMAND_</tt>* and <tt>ET_OBJCOMMAND_</tt>* function
+ in the client code</li></ul><ul><li>Call <tt>Et_AppInit()</tt> if the client defines it</li></ul><ul><li>Run the main Tcl script if there is one</li></ul><ul><li>Call <tt>Et_CustomMainLoop()</tt> if defined by client code or
+ else run the built-in event loop</li></ul></p>
+<br clear="both"><p><hr></p>
+<h2 align="center">Invoking Tcl From C</h2>
+<p><ul><li>Use one of the built-in evaluation functions:
+ <center><table width="80%">
+ <tr><td valign="top" width="50%"><ul>
+ <li> Tcl_Eval() </li>
+ <li> Tcl_VarEval() </li>
+ <li> Tcl_EvalFile() </li>
+ <li> Tcl_GlobalEval() </li>
+ </ul></td>
+ <td valign="top" width="50%"><ul>
+ <li> Tcl_EvalObj() </li>
+ <li> Tcl_GlobalEvalObj() </li>
+ </ul></td></tr>
+ </table></center></li></ul><ul><li>Mktclapp provides evaluation functions with variable argument
+ lists as in <tt>printf()</tt>:
+ <ul>
+ <li> Et_EvalF() </li>
+ <li> Et_GlobalEvalF() </li>
+ </ul></li></ul><ul><li>Mktclapp provides a global variable <tt>Et_Interp</tt> which is
+ a pointer to the main interpreter</li></ul></p>
+<br clear="both"><p><hr></p>
+<h2 align="center">Invoking Tcl From C</h2>
+<p>Example: A C function that pops up an error message dialog box</p><p>
+<table cellspacing="0" cellpadding="0" border="0">
+<tr><td valign="center">
+<small><tt>#include&nbsp;"appinit.h"<br>
+&nbsp;<br>
+void&nbsp;ErrMsg(char&nbsp;*zMsg){<br>
+&nbsp;&nbsp;Tcl_SetVar(Et_Interp,&nbsp;"zMsg",&nbsp;zMsg,&nbsp;TCL_GLOBAL_ONLY);<br>
+&nbsp;&nbsp;Tcl_GlobalEval(Et_Interp,&nbsp;<br>
+&nbsp;&nbsp;&nbsp;&nbsp;"tk_messageBox&nbsp;-icon&nbsp;error&nbsp;-msg&nbsp;$zMsg&nbsp;-type&nbsp;ok");<br>
+&nbsp;&nbsp;Tcl_UnsetVar(Et_Interp,&nbsp;"zMsg",&nbsp;TCL_GLOBAL_ONLY);<br>
+}</tt></small></td>
+<td></td><td></td><td></td><td></td>
+</tr>
+</table>
+
+<br clear="both"><p><hr></p>
+<h2 align="center">Invoking Tcl From C</h2>
+<p>The same C function implemented using <tt>Et_EvalF()</tt> instead
+ of <tt>Tcl_GlobalEval()</tt></p><p>
+<table cellspacing="0" cellpadding="0" border="0">
+<tr><td valign="center">
+<small><tt>#include&nbsp;"appinit.h"<br>
+&nbsp;<br>
+void&nbsp;ErrMsg(char&nbsp;*zMsg){<br>
+&nbsp;&nbsp;Et_EvalF(Et_Interp,&nbsp;<br>
+&nbsp;&nbsp;&nbsp;&nbsp;"tk_messageBox&nbsp;-icon&nbsp;error&nbsp;-msg&nbsp;{¸üÿ¿PX¶}&nbsp;-type&nbsp;ok",<br>
+&nbsp;&nbsp;&nbsp;&nbsp;zMsg);<br>
+}</tt></small></td>
+<td></td><td></td><td></td><td></td>
+</tr>
+</table>
+<p>
+ <ul><li>
+ Suppose the function is called as follows:
+ <blockquote>
+ <tt>ErrMsg("Syntax error near \"}\"");</tt>
+ </blockquote>
+ </li></ul>
+
+ <ul><li>
+ The command that gets executed is:
+ <pre>
+ tk_messageBox -icon error -msg \
+ {Syntax error near "}"} -type ok
+ </pre>
+ </li></ul>
+
+ <ul><li>
+ But this is an ill-formed Tcl command!
+ </li></ul>
+</p>
+
+<br clear="both"><p><hr></p>
+<h2 align="center">Invoking Tcl From C</h2>
+<p>Use the "<tt></tt>" format to generate a quoted string</p><p>
+<table cellspacing="0" cellpadding="0" border="0">
+<tr><td valign="center">
+<small><tt>#include&nbsp;"appinit.h"<br>
+&nbsp;<br>
+void&nbsp;ErrMsg(char&nbsp;*zMsg){<br>
+&nbsp;&nbsp;Et_EvalF(Et_Interp,&nbsp;<br>
+&nbsp;&nbsp;&nbsp;&nbsp;"tk_messageBox&nbsp;-icon&nbsp;error&nbsp;-msg&nbsp;\"%\"&nbsp;-type&nbsp;ok",<br>
+&nbsp;&nbsp;&nbsp;&nbsp;zMsg);<br>
+}</tt></small></td>
+<td></td><td></td><td></td><td></td>
+</tr>
+</table>
+<p><ul><li>The <tt></tt> puts a backslash before all characters that
+ are special to Tcl</li></ul><ul><li>The Tcl command becomes:
+ <pre>
+ tk_messageBox -icon error -msg \
+ "Syntax error near \"\}\"" -type ok
+ </pre></li></ul></p>
+
+<br clear="both"><p><hr></p>
+<h2 align="center">Other Functions Provided By Mktclapp</h2>
+<p><ul><li><tt>void Et_ResultF(Tcl_Interp*, ...);</tt></li></ul><ul><li><tt>char *Et_DStringAppendF(Tcl_DString*, ...);</tt></li></ul><ul><li><tt>int Et_AppendObjF(Tcl_Obj*, ...);</tt></li></ul><ul><li><tt>char *mprintf(const char *format, ...);<br>
+ char *vmprintf(const char *format, va_list);</tt></li></ul><ul><li><tt>void Et_NewBuiltinFile(char *filename, char *data, int amt);</tt></li></ul></p>
+<br clear="both"><p><hr></p>
+<h2 align="center">Operating Mktclapp From The Command Line</h2>
+<p><ul><li>Generate the <tt>appinit.h</tt> header file like this:
+ <blockquote>
+ <tt>mktclapp -header &gt;appinit.h</tt>
+ </blockquote></li></ul><ul><li>Generate the <tt>appinit.c</tt> file like this:
+ <blockquote>
+ <tt>mktclapp -f appinit.mta >appinit.c</tt>
+ </blockquote></li></ul><ul><li>The <tt>*.mta</tt> file is just a list of command-line options</li></ul><ul><li>Enter
+ <blockquote>
+ <tt>mktclapp -help</tt>
+ </blockquote>
+ to get a list of available options</li></ul><ul><li>Look at MTA files generated by xmktclapp.tcl for examples</li></ul></p>
+<br clear="both"><p><hr></p>
+<h2 align="center">Format Of An MTA File</h2>
+<table cellspacing="0" cellpadding="0" border="0">
+<tr><td valign="center">
+<small><tt>#&nbsp;Configuration&nbsp;file&nbsp;generated&nbsp;by&nbsp;xmktclapp<br>
+#&nbsp;Hand&nbsp;editing&nbsp;is&nbsp;not&nbsp;recommended<br>
+#</tt></small></td>
+<td>&nbsp;&nbsp;</td>
+<td valign="center"><img src="image2"></td>
+<td>&nbsp;&nbsp;</td>
+<td valign="center">Comments begin with one #</td>
+</tr>
+<tr><td valign="center">
+<small><tt>##&nbsp;Autofork&nbsp;No<br>
+##&nbsp;CFile:add.c&nbsp;1<br>
+##&nbsp;CFile:objadd.c&nbsp;1<br>
+##&nbsp;CmdLine&nbsp;Console<br>
+##&nbsp;ConfigFile&nbsp;hw.mta<br>
+##&nbsp;Data:check.gif&nbsp;1<br>
+##&nbsp;MainScript&nbsp;hw.tcl<br>
+##&nbsp;Mode&nbsp;Tcl/Tk<br>
+##&nbsp;NoSource&nbsp;No<br>
+##&nbsp;OutputFile&nbsp;hw.c<br>
+##&nbsp;Shroud&nbsp;No<br>
+##&nbsp;Standalone&nbsp;Yes<br>
+##&nbsp;TclFile:hw.tcl&nbsp;1<br>
+##&nbsp;TclLib&nbsp;/usr/lib/tcl8.0<br>
+##&nbsp;TkLib&nbsp;/usr/lib/tk8.0</tt></small></td>
+<td>&nbsp;&nbsp;</td>
+<td valign="center"><img src="image2"></td>
+<td>&nbsp;&nbsp;</td>
+<td valign="center">Lines beginning with two #s are used
+ by xmktclapp.tcl and ignored by mktclapp</td>
+</tr>
+<tr><td valign="center">
+<small><tt>-console<br>
+-main-script&nbsp;"hw.tcl"<br>
+-tcl-library&nbsp;"/usr/lib/tcl8.0"<br>
+-tk-library&nbsp;"/usr/lib/tk8.0"<br>
+"add.c"<br>
+"objadd.c"<br>
+-i&nbsp;"check.gif"<br>
+-strip-tcl&nbsp;"hw.tcl"</tt></small></td>
+<td>&nbsp;&nbsp;</td>
+<td valign="center"><img src="image2"></td>
+<td>&nbsp;&nbsp;</td>
+<td valign="center">All other lines are read by mktclapp and
+ ignored by xmktclapp.tcl</td>
+</tr>
+</table>
+
+<br clear="both"><p><hr></p>
+<h2 align="center">Summary</h2>
+<p><ul><li>Use Tcl for the things Tcl is good at and use C/C++ for the things that
+ C/C++ is good at</li></ul><ul><li>Use wrapper programs to make pure Tcl programs standalone</li></ul><ul><li>Use mktclapp to combine Tcl/Tk with C/C++ into a standalone</li></ul></p>
+<br clear="both"><p><hr></p>
diff --git a/jni/ruby/ext/tk/sample/tkextlib/tkHTML/page4/image1 b/jni/ruby/ext/tk/sample/tkextlib/tkHTML/page4/image1
new file mode 100644
index 0000000..da26d70
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkextlib/tkHTML/page4/image1
Binary files differ
diff --git a/jni/ruby/ext/tk/sample/tkextlib/tkHTML/page4/image2 b/jni/ruby/ext/tk/sample/tkextlib/tkHTML/page4/image2
new file mode 100644
index 0000000..e176a96
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkextlib/tkHTML/page4/image2
Binary files differ
diff --git a/jni/ruby/ext/tk/sample/tkextlib/tkHTML/page4/image3 b/jni/ruby/ext/tk/sample/tkextlib/tkHTML/page4/image3
new file mode 100644
index 0000000..e829d37
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkextlib/tkHTML/page4/image3
Binary files differ
diff --git a/jni/ruby/ext/tk/sample/tkextlib/tkHTML/page4/image4 b/jni/ruby/ext/tk/sample/tkextlib/tkHTML/page4/image4
new file mode 100644
index 0000000..f14ea13
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkextlib/tkHTML/page4/image4
Binary files differ
diff --git a/jni/ruby/ext/tk/sample/tkextlib/tkHTML/page4/image5 b/jni/ruby/ext/tk/sample/tkextlib/tkHTML/page4/image5
new file mode 100644
index 0000000..4ef6277
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkextlib/tkHTML/page4/image5
Binary files differ
diff --git a/jni/ruby/ext/tk/sample/tkextlib/tkHTML/page4/image6 b/jni/ruby/ext/tk/sample/tkextlib/tkHTML/page4/image6
new file mode 100644
index 0000000..1adb261
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkextlib/tkHTML/page4/image6
Binary files differ
diff --git a/jni/ruby/ext/tk/sample/tkextlib/tkHTML/page4/image7 b/jni/ruby/ext/tk/sample/tkextlib/tkHTML/page4/image7
new file mode 100644
index 0000000..ba0d26e
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkextlib/tkHTML/page4/image7
Binary files differ
diff --git a/jni/ruby/ext/tk/sample/tkextlib/tkHTML/page4/image8 b/jni/ruby/ext/tk/sample/tkextlib/tkHTML/page4/image8
new file mode 100644
index 0000000..8b81d58
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkextlib/tkHTML/page4/image8
Binary files differ
diff --git a/jni/ruby/ext/tk/sample/tkextlib/tkHTML/page4/image9 b/jni/ruby/ext/tk/sample/tkextlib/tkHTML/page4/image9
new file mode 100644
index 0000000..f0a352f
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkextlib/tkHTML/page4/image9
Binary files differ
diff --git a/jni/ruby/ext/tk/sample/tkextlib/tkHTML/page4/index.html b/jni/ruby/ext/tk/sample/tkextlib/tkHTML/page4/index.html
new file mode 100644
index 0000000..c7bfde3
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkextlib/tkHTML/page4/index.html
@@ -0,0 +1,768 @@
+<!DOCTYPE HTML="HTML" PUBLIC="PUBLIC" "-//W3C//DTD=""-//W3C//DTD" HTML="HTML" 4.0="4.0" Transitional//EN"="Transitional//EN"">
+<HTML>
+<HEAD>
+<TITLE>[fm] welcome to freshmeat.net</TITLE>
+<STYLE TYPE="text/css"><!-- A:link {text-decoration: none}A:visited{text-decoration:none}A:active{text-decoration:none}--></STYLE>
+</HEAD>
+<BODY MARGINWIDTH="0" MARGINHEIGHT="0" LEFTMARGIN="0" RIGHTMARGIN="0" TOPMARGIN="0" BGCOLOR="#FFFFFF" TEXT="#000000" LINK="#336699" VLINK="#336699" ALINK="#336699">
+<BR><CENTER><TABLE BORDER="0" CELLPADDING="0" CELLSPACING="0"><TR><TD WIDTH="1"><SCRIPT LANGUAGE="JAVASCRIPT">
+<!--
+now = new Date();
+tail = now.getTime();
+document.write("<IMG SRC='http://209.207.224.246/FreshMeat/Core/pc.gif?/index.php3," + tail + "' WIDTH=1 HEIGHT=1><BR>");
+//-->
+</SCRIPT>
+<NOSCRIPT>
+<IMG SRC="image1" WIDTH="1" HEIGHT="1"><BR>
+</NOSCRIPT></TD></TR></TABLE>
+<TABLE BORDER="0" CELLPADDING="0" CELLSPACING="0"><TR><TD WIDTH="468"><SCRIPT LANGUAGE="JAVASCRIPT">
+<!--
+now = new Date();
+tail = now.getTime();
+AltText = "\"Please click here.\"";
+document.write("<A HREF='http://ads.freshmeat.net/cgi-bin/ad_click.pl?index,tsof0001en'>")
+document.write("<IMG SRC='http://ads.freshmeat.net/tsof0001en.gif?" + tail + "' WIDTH=468 HEIGHT=60 ALT=" + AltText + "></A><BR>");
+//-->
+</SCRIPT>
+<NOSCRIPT>
+<A HREF="http://ads.freshmeat.net/cgi-bin/ad_click.pl?index,tsof0001en"><IMG SRC="image2" WIDTH="468" HEIGHT="60" ALT="Please click here."></A><BR>
+</NOSCRIPT></TD></TR></TABLE>
+
+<TABLE CELLSPACING="0" CELLPADDING="2" BORDER="0" WIDTH="97%"><TR>
+<TD ALIGN="left" VALIGN="bottom"><A HREF="/"><IMG SRC="image3" BORDER="0" ALT="freshmeat.net" WIDTH="300" HEIGHT="65"></A></TD>
+<TD VALIGN="bottom" ALIGN="left" ROWSPAN="2"><FONT FACE="Lucida,Verdana,Helvetica,Arial">
+<FORM METHOD="get" ACTION="/search.php3">
+<SMALL>find: <INPUT TYPE="text" SIZE="15" NAME="query"></SMALL></FORM></FONT></TD>
+<TD ALIGN="right" VALIGN="bottom"><FONT FACE="Lucida,Verdana,Helvetica,Arial">
+<A HREF="http://www.linux.com"><FONT COLOR="#000000"><B><SMALL>linux.com partner</SMALL></B></FONT></A><BR>
+<TABLE CELLSPACING="0" CELLPADDING="1" BORDER="0" WIDTH="100%"><TR>
+<TD ALIGN="right"><SMALL><NOBR><FONT FACE="Lucida,Verdana,Helvetica,Arial"><B><A HREF="/">news</A> |<BR>
+<A HREF="/appindex/">appindex</A> |<BR>
+<A HREF="/editorials/">editorials</A> |</B></FONT></NOBR></SMALL></TD>
+<TD ALIGN="right"><SMALL><NOBR><FONT FACE="Lucida,Verdana,Helvetica,Arial"><B><A HREF="/lounge/">lounge</A> |<BR>
+<A HREF="/contrib.php3">contribute</A> |<BR>
+<A HREF="/feedback.php3">feedback</A> |</B></FONT></NOBR></SMALL></TD>
+<TD ALIGN="right"><SMALL><NOBR><FONT FACE="Lucida,Verdana,Helvetica,Arial"><B><A HREF="/about.php3">about</A> |<BR>
+<A HREF="/awards.php3">awards</A> |<BR>
+<A HREF="/faq.php3">FAQ</A> |</B></FONT></NOBR></SMALL></TD>
+</TR></TABLE></TD>
+</TR></TABLE>
+<TABLE WIDTH="100%" CELLPADDING="0" CELLSPACING="0" BORDER="0">
+<TR BGCOLOR="#000000"><TD><IMG SRC="image4" WIDTH="1" HEIGHT="2" ALT=""></TD></TR></TABLE>
+<TABLE CELLSPACING="0" CELLPADDING="3" BORDER="0" WIDTH="100%" BGCOLOR="#BBDDFF">
+<TR><TD ALIGN="center" VALIGN="top">
+<BR>
+<FONT FACE="Lucida,Verdana,Helvetica,Arial">
+
+
+<SMALL><B>sort by: [ <A HREF="/news/2000/01/29/">date</A> | <A HREF="/news/list.php3?day=/2000/01/29/&orderby=name">name</A> | <A HREF="/news/list.php3?day=/2000/01/29/&orderby=urgency">urgency</A> ]</B></SMALL><BR></TD><TD>&nbsp;</TD></TR><TR><TD VALIGN="top" ALIGN="center"><FONT FACE="Lucida,Verdana,Helvetica,Arial"><TABLE CELLSPACING="0" CELLPADDING="2" WIDTH="97%" BORDER="0" BGCOLOR="#000000"><TR><TD COLSPAN="2">
+<TABLE CELLSPACING="0" CELLPADDING="3" WIDTH="100%" BORDER="0" BGCOLOR="#FFFFFF">
+<TR><TD><FONT FACE="Lucida,Verdana,Helvetica,Arial">
+<B><FONT SIZE="+2">We should get this out of the door now</FONT></B><BR>
+<SMALL><B><A HREF="mailto:scoop@freshmeat.net">scoop</A> - January 29th 2000, 23:59 EST</B></SMALL>
+<P>Everyone else is talking about it, so we should announce it ourselves
+before you start to think it's a government hoax. <A HREF="http://server51.freshmeat.net/">Server 51</A> is our new hosting service for Open Source projects, based on Super Cool Space Alien Technology(TM). We hadn't planned to announce it quite so soon, and it's still in the alpha stage as we work day and night at integrating SCSAT with our terrestrial systems, but feel free to take a look around and see what's going on. When we're out of the testing stage and ready to make room for your project, we'll send word via your implants. Be listening.
+
+
+
+<P ALIGN="right"><B>[ <A HREF="/news/2000/01/29/949208399.html">comments (8)</A> ]</B>
+</FONT></TD></TR></TABLE></TD></TR><TR><TD VALIGN="middle">
+&nbsp;<FONT FACE="Lucida,Verdana,Helvetica,Arial"><FONT COLOR="#FFFFFF"><B><SMALL>Category: freshmeat
+</SMALL></B></FONT></FONT></TD><TD ALIGN="right">
+ <A HREF="http://server51.freshmeat.net"><IMG SRC="image5" WIDTH="21" HEIGHT="21" BORDER="0" ALT="homepage"></A> &nbsp;
+</TD></TR></TABLE>
+<HR WIDTH="0" SIZE="0">
+
+
+<TABLE CELLSPACING="0" CELLPADDING="2" WIDTH="97%" BORDER="0" BGCOLOR="#000000"><TR><TD COLSPAN="2">
+<TABLE CELLSPACING="0" CELLPADDING="3" WIDTH="100%" BORDER="0" BGCOLOR="#FFFFFF">
+<TR><TD><FONT FACE="Lucida,Verdana,Helvetica,Arial">
+<B><FONT SIZE="+2">Is Linux for Crazies?</FONT></B><BR>
+<SMALL><B><A HREF="mailto:jeff.covey@pobox.com">jeff covey</A> - January 29th 2000, 23:59 EST</B></SMALL>
+<P>Ray Woodcock writes: "In terms relevant to Linux, this freshmeat
+editorial glances at the tendency of mainstream viewpoints to dismiss
+other viewpoints as 'fringe,' the propensity of dissident movements to
+splinter into factions before they can effectively counter their
+primary adversaries, and the difficulty of creating stability without
+squelching curiosity."
+<P ALIGN="right"><B>[ <A HREF="/news/2000/01/29/949208340.html">comments (2), 2065 words in body</A> ]</B>
+</FONT></TD></TR></TABLE></TD></TR><TR><TD VALIGN="middle">
+&nbsp;<FONT FACE="Lucida,Verdana,Helvetica,Arial"><FONT COLOR="#FFFFFF"><B><SMALL>Category: Editorial
+</SMALL></B></FONT></FONT></TD><TD ALIGN="right">
+ &nbsp;
+</TD></TR></TABLE>
+<HR WIDTH="0" SIZE="0">
+
+
+<TABLE CELLSPACING="0" CELLPADDING="2" WIDTH="97%" BORDER="0" BGCOLOR="#000000"><TR><TD COLSPAN="2">
+<TABLE CELLSPACING="0" CELLPADDING="3" WIDTH="100%" BORDER="0" BGCOLOR="#FFFFFF">
+<TR><TD><FONT FACE="Lucida,Verdana,Helvetica,Arial">
+<B><FONT SIZE="+2">RabbIT 2.0.2</FONT></B><BR>
+<SMALL><B><A HREF="mailto:d94-rol@nada.kth.se">Ernimril</A> - January 29th 2000, 18:29 EST</B></SMALL>
+<DIV ALIGN="justify"><P>RabbIt is the mutating, caching webproxy which is used to speed up surfing over slow links like modems. It does this by removing advertising and background images and scaling down images to low quality JPEGs. RabbIT is written in Java and should be able to run on any platform. It does depend upon an image converter if imagescaleing is on. The recommended image converter is "convert" from the ImageMagick package.</DIV>
+<P><B>Changes:</B> Fixes have been made for a few bugs concerning keep alive and the HTTP response header, a bug with NT and cache directories, a bug concerning requests without a response body, a bug in GZIPHandler that caused it to not gzip already compressed (gzip or compress) streams, a bug in HTTPHeader regarding response phrases that are multiline, and a few bugs in ImageHandler and NCache. GZIPHandler has been built as an intermediate(*) to FilterHandler (this means that it is possible to gzip text/plain, etc., without filtering those streams) uuencoding has been added to the Coder, RabbIT now uses HTTP/1.1, HTMLParser now compiles cleanly with Jikes, and GeneralHeader has been created to allow for HTTPFooter (which is useful when sending chunked data).
+<P><B>Urgency:</B> low
+<P ALIGN="right"><B>[ <A HREF="/news/2000/01/29/949188564.html">comments (0)</A> ]</B>
+</FONT></TD></TR></TABLE></TD></TR><TR><TD VALIGN="middle">
+&nbsp;<FONT FACE="Lucida,Verdana,Helvetica,Arial"><FONT COLOR="#FFFFFF"><B><SMALL>License: freely distributable</SMALL></B><BR>
+<B><SMALL>&nbsp;Category: <A HREF="/appindex/daemons/proxy.html"><FONT COLOR="#FFFFFF">Daemons/Proxy</FONT></A></SMALL></B></FONT></FONT></TD><TD ALIGN="right">
+<A HREF="http://apps.freshmeat.net/download/902659138/"><IMG SRC="image6" WIDTH="21" HEIGHT="21" BORDER="0" ALT="download"></A> <A HREF="http://apps.freshmeat.net/homepage/902659138/"><IMG SRC="image5" WIDTH="21" HEIGHT="21" BORDER="0" ALT="homepage"></A> <A HREF="/appindex/1998/08/09/902659138.html"><IMG SRC="image7" WIDTH="21" HEIGHT="21" BORDER="0" ALT="appindex record"></A> &nbsp;
+</TD></TR></TABLE>
+<HR WIDTH="0" SIZE="0">
+
+
+<TABLE CELLSPACING="0" CELLPADDING="2" WIDTH="97%" BORDER="0" BGCOLOR="#000000"><TR><TD COLSPAN="2">
+<TABLE CELLSPACING="0" CELLPADDING="3" WIDTH="100%" BORDER="0" BGCOLOR="#FFFFFF">
+<TR><TD><FONT FACE="Lucida,Verdana,Helvetica,Arial">
+<B><FONT SIZE="+2">nmpg 1.1.3</FONT></B><BR>
+<SMALL><B><A HREF="mailto:narkos@linuxmail.org">Joel Lindau</A> - January 29th 2000, 18:18 EST</B></SMALL>
+<DIV ALIGN="justify"><P>nmpg is a small command-driven frontend and network-jukebox for mpg123.</DIV>
+<P><B>Changes:</B> Bugfixes, better memory managment, a new .nmpgrc parser, and new options.
+<P><B>Urgency:</B> low
+<P ALIGN="right"><B>[ <A HREF="/news/2000/01/29/949187896.html">comments (0)</A> ]</B>
+</FONT></TD></TR></TABLE></TD></TR><TR><TD VALIGN="middle">
+&nbsp;<FONT FACE="Lucida,Verdana,Helvetica,Arial"><FONT COLOR="#FFFFFF"><B><SMALL>License: OpenSource</SMALL></B><BR>
+<B><SMALL>&nbsp;Category: <A HREF="/appindex/console/sound.html"><FONT COLOR="#FFFFFF">Console/Sound</FONT></A></SMALL></B></FONT></FONT></TD><TD ALIGN="right">
+<A HREF="http://apps.freshmeat.net/download/935430877/"><IMG SRC="image6" WIDTH="21" HEIGHT="21" BORDER="0" ALT="download"></A> <A HREF="http://apps.freshmeat.net/homepage/935430877/"><IMG SRC="image5" WIDTH="21" HEIGHT="21" BORDER="0" ALT="homepage"></A> <A HREF="http://apps.freshmeat.net/changelog/935430877/"><IMG SRC="image8" WIDTH="21" HEIGHT="21" BORDER="0" ALT="changelog"></A> <A HREF="/appindex/1999/08/23/935430877.html"><IMG SRC="image7" WIDTH="21" HEIGHT="21" BORDER="0" ALT="appindex record"></A> &nbsp;
+</TD></TR></TABLE>
+<HR WIDTH="0" SIZE="0">
+
+
+<TABLE CELLSPACING="0" CELLPADDING="2" WIDTH="97%" BORDER="0" BGCOLOR="#000000"><TR><TD COLSPAN="2">
+<TABLE CELLSPACING="0" CELLPADDING="3" WIDTH="100%" BORDER="0" BGCOLOR="#FFFFFF">
+<TR><TD><FONT FACE="Lucida,Verdana,Helvetica,Arial">
+<B><FONT SIZE="+2">mod_dtcl 0.7.3</FONT></B><BR>
+<SMALL><B><A HREF="mailto:davidw@prosa.it">David Welton</A> - January 29th 2000, 18:11 EST</B></SMALL>
+<DIV ALIGN="justify"><P>Mod_dtcl is a free/open source implementation of server-parsed Tcl under Apache. It allows you to tightly integrate HTML with Tcl, a widely-used scripting language with many years of development invested in it. There are also many external Tcl modules that you can load into mod_dtcl, to create images, access databases, etc.</DIV>
+<P><B>Changes:</B> A major overhaul of header handling and internal buffering, and the addition of the ability to handle binary data.
+<P><B>Urgency:</B> low
+<P ALIGN="right"><B>[ <A HREF="/news/2000/01/29/949187471.html">comments (0)</A> ]</B>
+</FONT></TD></TR></TABLE></TD></TR><TR><TD VALIGN="middle">
+&nbsp;<FONT FACE="Lucida,Verdana,Helvetica,Arial"><FONT COLOR="#FFFFFF"><B><SMALL>License: GPL</SMALL></B><BR>
+<B><SMALL>&nbsp;Category: <A HREF="/appindex/web/development.html"><FONT COLOR="#FFFFFF">Web/Development</FONT></A></SMALL></B></FONT></FONT></TD><TD ALIGN="right">
+<A HREF="http://apps.freshmeat.net/download/917925309/"><IMG SRC="image6" WIDTH="21" HEIGHT="21" BORDER="0" ALT="download"></A> <A HREF="http://apps.freshmeat.net/homepage/917925309/"><IMG SRC="image5" WIDTH="21" HEIGHT="21" BORDER="0" ALT="homepage"></A> <A HREF="http://apps.freshmeat.net/changelog/917925309/"><IMG SRC="image8" WIDTH="21" HEIGHT="21" BORDER="0" ALT="changelog"></A> <A HREF="/appindex/1999/02/01/917925309.html"><IMG SRC="image7" WIDTH="21" HEIGHT="21" BORDER="0" ALT="appindex record"></A> &nbsp;
+</TD></TR></TABLE>
+<HR WIDTH="0" SIZE="0">
+
+
+<TABLE CELLSPACING="0" CELLPADDING="2" WIDTH="97%" BORDER="0" BGCOLOR="#000000"><TR><TD COLSPAN="2">
+<TABLE CELLSPACING="0" CELLPADDING="3" WIDTH="100%" BORDER="0" BGCOLOR="#FFFFFF">
+<TR><TD><FONT FACE="Lucida,Verdana,Helvetica,Arial">
+<B><FONT SIZE="+2">CoreLinux++ 0.4.6</FONT></B><BR>
+<SMALL><B><A HREF="mailto:frankc@users.sourceforge.net">Frank V. Castellucci</A> - January 29th 2000, 18:07 EST</B></SMALL>
+<DIV ALIGN="justify"><P>CoreLinux++ is an initiative to normalize methods and conventions for OOA/OOD/C++ development for Linux, materialized in a set of Open Source C++ class libraries (libcorelinux++ and libcoreframework++) to support common patterns and exploit the C++ standards.</DIV>
+<P><B>Changes:</B> This release adds AbstractFactory and AssociativeIterator analysis, design, implementations, test code, a CVS daily tarball, a Patch Submission facility and updated FAQ, Web Pages, and defect reporting guidelines.
+<P><B>Urgency:</B> medium
+<P ALIGN="right"><B>[ <A HREF="/news/2000/01/29/949187233.html">comments (0)</A> ]</B>
+</FONT></TD></TR></TABLE></TD></TR><TR><TD VALIGN="middle">
+&nbsp;<FONT FACE="Lucida,Verdana,Helvetica,Arial"><FONT COLOR="#FFFFFF"><B><SMALL>License: LGPL</SMALL></B><BR>
+<B><SMALL>&nbsp;Category: <A HREF="/appindex/development/libraries.html"><FONT COLOR="#FFFFFF">Development/Libraries</FONT></A></SMALL></B></FONT></FONT></TD><TD ALIGN="right">
+<A HREF="http://apps.freshmeat.net/download/944077775/"><IMG SRC="image6" WIDTH="21" HEIGHT="21" BORDER="0" ALT="download"></A> <A HREF="http://apps.freshmeat.net/homepage/944077775/"><IMG SRC="image5" WIDTH="21" HEIGHT="21" BORDER="0" ALT="homepage"></A> <A HREF="http://apps.freshmeat.net/changelog/944077775/"><IMG SRC="image8" WIDTH="21" HEIGHT="21" BORDER="0" ALT="changelog"></A> <A HREF="/appindex/1999/12/01/944077775.html"><IMG SRC="image7" WIDTH="21" HEIGHT="21" BORDER="0" ALT="appindex record"></A> &nbsp;
+</TD></TR></TABLE>
+<HR WIDTH="0" SIZE="0">
+
+
+<TABLE CELLSPACING="0" CELLPADDING="2" WIDTH="97%" BORDER="0" BGCOLOR="#000000"><TR><TD COLSPAN="2">
+<TABLE CELLSPACING="0" CELLPADDING="3" WIDTH="100%" BORDER="0" BGCOLOR="#FFFFFF">
+<TR><TD><FONT FACE="Lucida,Verdana,Helvetica,Arial">
+<B><FONT SIZE="+2">scribe 0.2</FONT></B><BR>
+<SMALL><B><A HREF="mailto:kahlage@logoncafe.net">ChromeBob</A> - January 29th 2000, 12:12 EST</B></SMALL>
+<DIV ALIGN="justify"><P>scribe writes functions prototypes for your C code, so you don't have to. It also compares unique functions between source code files and will 'extern' when appropriate. C++ methods support is also planned.</DIV>
+<P><B>Changes:</B> A fix for an fflush() bug and better documentation.
+<P><B>Urgency:</B> low
+<P ALIGN="right"><B>[ <A HREF="/news/2000/01/29/949165962.html">comments (0)</A> ]</B>
+</FONT></TD></TR></TABLE></TD></TR><TR><TD VALIGN="middle">
+&nbsp;<FONT FACE="Lucida,Verdana,Helvetica,Arial"><FONT COLOR="#FFFFFF"><B><SMALL>License: GPL</SMALL></B><BR>
+<B><SMALL>&nbsp;Category: <A HREF="/appindex/development/tools.html"><FONT COLOR="#FFFFFF">Development/Tools</FONT></A></SMALL></B></FONT></FONT></TD><TD ALIGN="right">
+<A HREF="http://apps.freshmeat.net/download/946661656/"><IMG SRC="image6" WIDTH="21" HEIGHT="21" BORDER="0" ALT="download"></A> <A HREF="http://apps.freshmeat.net/homepage/946661656/"><IMG SRC="image5" WIDTH="21" HEIGHT="21" BORDER="0" ALT="homepage"></A> <A HREF="/appindex/1999/12/31/946661656.html"><IMG SRC="image7" WIDTH="21" HEIGHT="21" BORDER="0" ALT="appindex record"></A> &nbsp;
+</TD></TR></TABLE>
+<HR WIDTH="0" SIZE="0">
+
+
+<TABLE CELLSPACING="0" CELLPADDING="2" WIDTH="97%" BORDER="0" BGCOLOR="#000000"><TR><TD COLSPAN="2">
+<TABLE CELLSPACING="0" CELLPADDING="3" WIDTH="100%" BORDER="0" BGCOLOR="#FFFFFF">
+<TR><TD><FONT FACE="Lucida,Verdana,Helvetica,Arial">
+<B><FONT SIZE="+2">E theme updater 0.1</FONT></B><BR>
+<SMALL><B><A HREF="mailto:hallvar@ii.uib.no">Hallvar Helleseth</A> - January 29th 2000, 12:04 EST</B></SMALL>
+<DIV ALIGN="justify"><P>E theme Updater is a bash script to automatically update all of your Enlightenment themes from e.themes.org.</DIV>
+<P><B>Changes:</B> Initial release.
+
+<P ALIGN="right"><B>[ <A HREF="/news/2000/01/29/949165472.html">comments (0)</A> ]</B>
+</FONT></TD></TR></TABLE></TD></TR><TR><TD VALIGN="middle">
+&nbsp;<FONT FACE="Lucida,Verdana,Helvetica,Arial"><FONT COLOR="#FFFFFF"><B><SMALL>License: GPL</SMALL></B><BR>
+<B><SMALL>&nbsp;Category: <A HREF="/appindex/console/misc.html"><FONT COLOR="#FFFFFF">Console/Misc</FONT></A></SMALL></B></FONT></FONT></TD><TD ALIGN="right">
+<A HREF="http://apps.freshmeat.net/download/949164501/"><IMG SRC="image6" WIDTH="21" HEIGHT="21" BORDER="0" ALT="download"></A> <A HREF="http://apps.freshmeat.net/homepage/949164501/"><IMG SRC="image5" WIDTH="21" HEIGHT="21" BORDER="0" ALT="homepage"></A> <A HREF="/appindex/2000/01/29/949164501.html"><IMG SRC="image7" WIDTH="21" HEIGHT="21" BORDER="0" ALT="appindex record"></A> &nbsp;
+</TD></TR></TABLE>
+<HR WIDTH="0" SIZE="0">
+
+
+<TABLE CELLSPACING="0" CELLPADDING="2" WIDTH="97%" BORDER="0" BGCOLOR="#000000"><TR><TD COLSPAN="2">
+<TABLE CELLSPACING="0" CELLPADDING="3" WIDTH="100%" BORDER="0" BGCOLOR="#FFFFFF">
+<TR><TD><FONT FACE="Lucida,Verdana,Helvetica,Arial">
+<B><FONT SIZE="+2">Powertweak-Linux 0.1.7</FONT></B><BR>
+<SMALL><B><A HREF="mailto:dave@denial.force9.co.uk">Dave Jones</A> - January 29th 2000, 12:03 EST</B></SMALL>
+<DIV ALIGN="justify"><P>Powertweak-Linux is a port of the Microsoft Windows tool of the same name rewritten from the ground up. Its main function is to tune your system to its optimal performance settings. Currently, it tunes PCI chipsets and can set /proc/sys entries.</DIV>
+<P><B>Changes:</B> A major GUI overhaul, the ability to generate configuration files, extended PCI information tabs, extra information support for the Matrox G200, and numerous other bugfixes & improvements.
+<P><B>Urgency:</B> low
+<P ALIGN="right"><B>[ <A HREF="/news/2000/01/29/949165416.html">comments (2)</A> ]</B>
+</FONT></TD></TR></TABLE></TD></TR><TR><TD VALIGN="middle">
+&nbsp;<FONT FACE="Lucida,Verdana,Helvetica,Arial"><FONT COLOR="#FFFFFF"><B><SMALL>License: GPL</SMALL></B><BR>
+<B><SMALL>&nbsp;Category: <A HREF="/appindex/console/system.html"><FONT COLOR="#FFFFFF">Console/System</FONT></A></SMALL></B></FONT></FONT></TD><TD ALIGN="right">
+<A HREF="http://apps.freshmeat.net/download/930836224/"><IMG SRC="image6" WIDTH="21" HEIGHT="21" BORDER="0" ALT="download"></A> <A HREF="http://apps.freshmeat.net/homepage/930836224/"><IMG SRC="image5" WIDTH="21" HEIGHT="21" BORDER="0" ALT="homepage"></A> <A HREF="http://apps.freshmeat.net/changelog/930836224/"><IMG SRC="image8" WIDTH="21" HEIGHT="21" BORDER="0" ALT="changelog"></A> <A HREF="/appindex/1999/07/01/930836224.html"><IMG SRC="image7" WIDTH="21" HEIGHT="21" BORDER="0" ALT="appindex record"></A> &nbsp;
+</TD></TR></TABLE>
+<HR WIDTH="0" SIZE="0">
+
+
+<TABLE CELLSPACING="0" CELLPADDING="2" WIDTH="97%" BORDER="0" BGCOLOR="#000000"><TR><TD COLSPAN="2">
+<TABLE CELLSPACING="0" CELLPADDING="3" WIDTH="100%" BORDER="0" BGCOLOR="#FFFFFF">
+<TR><TD><FONT FACE="Lucida,Verdana,Helvetica,Arial">
+<B><FONT SIZE="+2">Pexeso Beta</FONT></B><BR>
+<SMALL><B><A HREF="mailto:pavolkrigler@pobox.sk">Pavol Krigler</A> - January 29th 2000, 11:55 EST</B></SMALL>
+<DIV ALIGN="justify"><P>pexeso is a simple graphic card game for one or two players.</DIV>
+<P><B>Changes:</B> Initial public release.
+
+<P ALIGN="right"><B>[ <A HREF="/news/2000/01/29/949164956.html">comments (0)</A> ]</B>
+</FONT></TD></TR></TABLE></TD></TR><TR><TD VALIGN="middle">
+&nbsp;<FONT FACE="Lucida,Verdana,Helvetica,Arial"><FONT COLOR="#FFFFFF"><B><SMALL>License: Freeware</SMALL></B><BR>
+<B><SMALL>&nbsp;Category: <A HREF="/appindex/console/games.html"><FONT COLOR="#FFFFFF">Console/Games</FONT></A></SMALL></B></FONT></FONT></TD><TD ALIGN="right">
+<A HREF="http://apps.freshmeat.net/download/949141436/"><IMG SRC="image6" WIDTH="21" HEIGHT="21" BORDER="0" ALT="download"></A> <A HREF="http://apps.freshmeat.net/homepage/949141436/"><IMG SRC="image5" WIDTH="21" HEIGHT="21" BORDER="0" ALT="homepage"></A> <A HREF="/appindex/2000/01/29/949141436.html"><IMG SRC="image7" WIDTH="21" HEIGHT="21" BORDER="0" ALT="appindex record"></A> &nbsp;
+</TD></TR></TABLE>
+<HR WIDTH="0" SIZE="0">
+
+
+<TABLE CELLSPACING="0" CELLPADDING="2" WIDTH="97%" BORDER="0" BGCOLOR="#000000"><TR><TD COLSPAN="2">
+<TABLE CELLSPACING="0" CELLPADDING="3" WIDTH="100%" BORDER="0" BGCOLOR="#FFFFFF">
+<TR><TD><FONT FACE="Lucida,Verdana,Helvetica,Arial">
+<B><FONT SIZE="+2">XZX 2.9.2</FONT></B><BR>
+<SMALL><B><A HREF="mailto:Erik.Kunze@fantasy.muc.de">E. Kunze</A> - January 29th 2000, 11:54 EST</B></SMALL>
+<DIV ALIGN="justify"><P>XZX is a portable emulator of ZX Spectrum 48K/128K/+3 (8-bit home computers made by Sir Clive Sinclair) and Pentagon/Scorpion (Spectrum clones made in Russia) for machines running UNIX and the X Window system. XZX is completely written in C and emulates Spectrum 48K, 128K, +2 and +3, Pentagon and Scorpion, Interface I with up to 8 microdrives, Multiface 128 and Multiface 3, BetaDisk 128 interface by Technology Research Ltd with 4 disk drives, +D interface by Miles Gordon Technology with 2 disk drives, Kempston mouse, Kempston joystick and built-in machine code monitor.</DIV>
+<P><B>Changes:</B> Lots of feature improvement and bug fixes. Most parts of the audio support has been rewritten for different UNICES.
+<P><B>Urgency:</B> low
+<P ALIGN="right"><B>[ <A HREF="/news/2000/01/29/949164896.html">comments (0)</A> ]</B>
+</FONT></TD></TR></TABLE></TD></TR><TR><TD VALIGN="middle">
+&nbsp;<FONT FACE="Lucida,Verdana,Helvetica,Arial"><FONT COLOR="#FFFFFF"><B><SMALL>License: Shareware</SMALL></B><BR>
+<B><SMALL>&nbsp;Category: <A HREF="/appindex/x11/emulators.html"><FONT COLOR="#FFFFFF">X11/Emulators</FONT></A></SMALL></B></FONT></FONT></TD><TD ALIGN="right">
+<A HREF="http://apps.freshmeat.net/download/936956384/"><IMG SRC="image6" WIDTH="21" HEIGHT="21" BORDER="0" ALT="download"></A> <A HREF="http://apps.freshmeat.net/homepage/936956384/"><IMG SRC="image5" WIDTH="21" HEIGHT="21" BORDER="0" ALT="homepage"></A> <A HREF="http://apps.freshmeat.net/changelog/936956384/"><IMG SRC="image8" WIDTH="21" HEIGHT="21" BORDER="0" ALT="changelog"></A> <A HREF="/appindex/1999/09/10/936956384.html"><IMG SRC="image7" WIDTH="21" HEIGHT="21" BORDER="0" ALT="appindex record"></A> &nbsp;
+</TD></TR></TABLE>
+<HR WIDTH="0" SIZE="0">
+
+
+<TABLE CELLSPACING="0" CELLPADDING="2" WIDTH="97%" BORDER="0" BGCOLOR="#000000"><TR><TD COLSPAN="2">
+<TABLE CELLSPACING="0" CELLPADDING="3" WIDTH="100%" BORDER="0" BGCOLOR="#FFFFFF">
+<TR><TD><FONT FACE="Lucida,Verdana,Helvetica,Arial">
+<B><FONT SIZE="+2">DistroLib 0.4</FONT></B><BR>
+<SMALL><B><A HREF="mailto:phir@gcu-squad.org">PhiR</A> - January 29th 2000, 11:54 EST</B></SMALL>
+<DIV ALIGN="justify"><P>DistroLib is an abstraction library designed to make the development of distributed application easier. Its main target is currently compute-bound tasks based on a one server, many clients model (much like distributed.net), but it is quite generic and could be used for any client/server app. It is lightweight, easy-to-use, and relies heavily on threads.</DIV>
+<P><B>Changes:</B> Important bug fixes and command history support.
+<P><B>Urgency:</B> low
+<P ALIGN="right"><B>[ <A HREF="/news/2000/01/29/949164869.html">comments (0)</A> ]</B>
+</FONT></TD></TR></TABLE></TD></TR><TR><TD VALIGN="middle">
+&nbsp;<FONT FACE="Lucida,Verdana,Helvetica,Arial"><FONT COLOR="#FFFFFF"><B><SMALL>License: GPL</SMALL></B><BR>
+<B><SMALL>&nbsp;Category: <A HREF="/appindex/development/libraries.html"><FONT COLOR="#FFFFFF">Development/Libraries</FONT></A></SMALL></B></FONT></FONT></TD><TD ALIGN="right">
+<A HREF="http://apps.freshmeat.net/download/942588431/"><IMG SRC="image6" WIDTH="21" HEIGHT="21" BORDER="0" ALT="download"></A> <A HREF="http://apps.freshmeat.net/homepage/942588431/"><IMG SRC="image5" WIDTH="21" HEIGHT="21" BORDER="0" ALT="homepage"></A> <A HREF="http://apps.freshmeat.net/changelog/942588431/"><IMG SRC="image8" WIDTH="21" HEIGHT="21" BORDER="0" ALT="changelog"></A> <A HREF="/appindex/1999/11/14/942588431.html"><IMG SRC="image7" WIDTH="21" HEIGHT="21" BORDER="0" ALT="appindex record"></A> &nbsp;
+</TD></TR></TABLE>
+<HR WIDTH="0" SIZE="0">
+
+
+<TABLE CELLSPACING="0" CELLPADDING="2" WIDTH="97%" BORDER="0" BGCOLOR="#000000"><TR><TD COLSPAN="2">
+<TABLE CELLSPACING="0" CELLPADDING="3" WIDTH="100%" BORDER="0" BGCOLOR="#FFFFFF">
+<TR><TD><FONT FACE="Lucida,Verdana,Helvetica,Arial">
+<B><FONT SIZE="+2">ToutDoux 1.1.7</FONT></B><BR>
+<SMALL><B><A HREF="mailto:yeupou@altern.org">yeupou</A> - January 29th 2000, 11:54 EST</B></SMALL>
+<DIV ALIGN="justify"><P>ToutDoux is a project manager which lets you design a plan of action using a tree structure, with translations in French and English.</DIV>
+<P><B>Changes:</B> A new menu and XML standard for save files.
+<P><B>Urgency:</B> low
+<P ALIGN="right"><B>[ <A HREF="/news/2000/01/29/949164843.html">comments (0)</A> ]</B>
+</FONT></TD></TR></TABLE></TD></TR><TR><TD VALIGN="middle">
+&nbsp;<FONT FACE="Lucida,Verdana,Helvetica,Arial"><FONT COLOR="#FFFFFF"><B><SMALL>License: GPL</SMALL></B><BR>
+<B><SMALL>&nbsp;Category: <A HREF="/appindex/gnome/tools.html"><FONT COLOR="#FFFFFF">GNOME/Tools</FONT></A></SMALL></B></FONT></FONT></TD><TD ALIGN="right">
+<A HREF="http://apps.freshmeat.net/download/944433411/"><IMG SRC="image6" WIDTH="21" HEIGHT="21" BORDER="0" ALT="download"></A> <A HREF="http://apps.freshmeat.net/homepage/944433411/"><IMG SRC="image5" WIDTH="21" HEIGHT="21" BORDER="0" ALT="homepage"></A> <A HREF="/appindex/1999/12/05/944433411.html"><IMG SRC="image7" WIDTH="21" HEIGHT="21" BORDER="0" ALT="appindex record"></A> &nbsp;
+</TD></TR></TABLE>
+<HR WIDTH="0" SIZE="0">
+
+
+<TABLE CELLSPACING="0" CELLPADDING="2" WIDTH="97%" BORDER="0" BGCOLOR="#000000"><TR><TD COLSPAN="2">
+<TABLE CELLSPACING="0" CELLPADDING="3" WIDTH="100%" BORDER="0" BGCOLOR="#FFFFFF">
+<TR><TD><FONT FACE="Lucida,Verdana,Helvetica,Arial">
+<B><FONT SIZE="+2">goMP 1.0.3</FONT></B><BR>
+<SMALL><B><A HREF="mailto:dioxine@poulet.org">Gautier</A> - January 29th 2000, 11:52 EST</B></SMALL>
+<DIV ALIGN="justify"><P>goMP is a set of CGI scripts that allows you to remotely control, via a Web browser, a computer acting as an MP3 jukebox. This program is very useful for someone who's got a dedicated computer with a lot of MP3 files but that doesn't have any output and input devices except network and sound card. It's main advantages are built-in cataloging, fast access to music, and no special software needed on the client side.</DIV>
+<P><B>Changes:</B> Bugfixes, a password-protected config page, basic search function, easier installation thanks to an install script, and relocation of HTML docs and CGIs to a subdirectory.
+<P><B>Urgency:</B> medium
+<P ALIGN="right"><B>[ <A HREF="/news/2000/01/29/949164772.html">comments (0)</A> ]</B>
+</FONT></TD></TR></TABLE></TD></TR><TR><TD VALIGN="middle">
+&nbsp;<FONT FACE="Lucida,Verdana,Helvetica,Arial"><FONT COLOR="#FFFFFF"><B><SMALL>License: Artistic</SMALL></B><BR>
+<B><SMALL>&nbsp;Category: <A HREF="/appindex/web/tools.html"><FONT COLOR="#FFFFFF">Web/Tools</FONT></A></SMALL></B></FONT></FONT></TD><TD ALIGN="right">
+<A HREF="http://apps.freshmeat.net/download/948492962/"><IMG SRC="image6" WIDTH="21" HEIGHT="21" BORDER="0" ALT="download"></A> <A HREF="http://apps.freshmeat.net/homepage/948492962/"><IMG SRC="image5" WIDTH="21" HEIGHT="21" BORDER="0" ALT="homepage"></A> <A HREF="http://apps.freshmeat.net/changelog/948492962/"><IMG SRC="image8" WIDTH="21" HEIGHT="21" BORDER="0" ALT="changelog"></A> <A HREF="/appindex/2000/01/21/948492962.html"><IMG SRC="image7" WIDTH="21" HEIGHT="21" BORDER="0" ALT="appindex record"></A> &nbsp;
+</TD></TR></TABLE>
+<HR WIDTH="0" SIZE="0">
+
+
+<TABLE CELLSPACING="0" CELLPADDING="2" WIDTH="97%" BORDER="0" BGCOLOR="#000000"><TR><TD COLSPAN="2">
+<TABLE CELLSPACING="0" CELLPADDING="3" WIDTH="100%" BORDER="0" BGCOLOR="#FFFFFF">
+<TR><TD><FONT FACE="Lucida,Verdana,Helvetica,Arial">
+<B><FONT SIZE="+2">APSEND 1.40</FONT></B><BR>
+<SMALL><B><A HREF="mailto:sventek@gmx.net">M.K.</A> - January 29th 2000, 11:50 EST</B></SMALL>
+<DIV ALIGN="justify"><P>APSEND is a TCP/IP packet sender to test firewalls and other network applications. It also includes a syn flood option, the land DoS attack, and a DoS attack against tcpdump running on a UNIX-based system. Future updates will include support for a scripting language to construct TCP packets and a few more options and protocols like UDP and ICMP. A port of APSEND from Perl to C is planned as well.</DIV>
+<P><B>Changes:</B> The stream attack, bugfixes, and rewrites for parts of the code.
+<P><B>Urgency:</B> low
+<P ALIGN="right"><B>[ <A HREF="/news/2000/01/29/949164633.html">comments (0)</A> ]</B>
+</FONT></TD></TR></TABLE></TD></TR><TR><TD VALIGN="middle">
+&nbsp;<FONT FACE="Lucida,Verdana,Helvetica,Arial"><FONT COLOR="#FFFFFF"><B><SMALL>License: GPL</SMALL></B><BR>
+<B><SMALL>&nbsp;Category: <A HREF="/appindex/console/networking.html"><FONT COLOR="#FFFFFF">Console/Networking</FONT></A></SMALL></B></FONT></FONT></TD><TD ALIGN="right">
+<A HREF="http://apps.freshmeat.net/download/941654429/"><IMG SRC="image6" WIDTH="21" HEIGHT="21" BORDER="0" ALT="download"></A> <A HREF="http://apps.freshmeat.net/homepage/941654429/"><IMG SRC="image5" WIDTH="21" HEIGHT="21" BORDER="0" ALT="homepage"></A> <A HREF="http://apps.freshmeat.net/changelog/941654429/"><IMG SRC="image8" WIDTH="21" HEIGHT="21" BORDER="0" ALT="changelog"></A> <A HREF="/appindex/1999/11/03/941654429.html"><IMG SRC="image7" WIDTH="21" HEIGHT="21" BORDER="0" ALT="appindex record"></A> &nbsp;
+</TD></TR></TABLE>
+<HR WIDTH="0" SIZE="0">
+
+
+<TABLE CELLSPACING="0" CELLPADDING="2" WIDTH="97%" BORDER="0" BGCOLOR="#000000"><TR><TD COLSPAN="2">
+<TABLE CELLSPACING="0" CELLPADDING="3" WIDTH="100%" BORDER="0" BGCOLOR="#FFFFFF">
+<TR><TD><FONT FACE="Lucida,Verdana,Helvetica,Arial">
+<B><FONT SIZE="+2">ecasound 1.6.12r10</FONT></B><BR>
+<SMALL><B><A HREF="mailto:kaiv@wakkanet.fi">Kai Vehmanen</A> - January 29th 2000, 11:48 EST</B></SMALL>
+<DIV ALIGN="justify"><P>Ecasound is a software package designed for multitrack audio processing. It can be used for simple tasks like audio playback, recording and format conversions, as well as for multitrack effect processing, mixing, recording and signal recycling. Ecasound supports a wide range of audio inputs, outputs and effect algorithms. Ecasound has a chain-based design that allows effects to be easily combined both in series and in parallel. Oscillators and MIDI-CCs can be used for controlling effect parameters. Includes a versatile console mode interface, a Qt-based X-interface and various command-line utils suitable for batch processing.</DIV>
+<P><B>Changes:</B> Support for 24- and 32-bit audio formats and for ALSA 0.5, multichannel noisegate, a new 2nd order lowpass filter, some ia-mode commands, and various bugfixes and low-level improvements.
+<P><B>Urgency:</B> low
+<P ALIGN="right"><B>[ <A HREF="/news/2000/01/29/949164529.html">comments (0)</A> ]</B>
+</FONT></TD></TR></TABLE></TD></TR><TR><TD VALIGN="middle">
+&nbsp;<FONT FACE="Lucida,Verdana,Helvetica,Arial"><FONT COLOR="#FFFFFF"><B><SMALL>License: GPL</SMALL></B><BR>
+<B><SMALL>&nbsp;Category: <A HREF="/appindex/console/sound.html"><FONT COLOR="#FFFFFF">Console/Sound</FONT></A></SMALL></B></FONT></FONT></TD><TD ALIGN="right">
+<A HREF="http://apps.freshmeat.net/download/931819147/"><IMG SRC="image6" WIDTH="21" HEIGHT="21" BORDER="0" ALT="download"></A> <A HREF="http://apps.freshmeat.net/homepage/931819147/"><IMG SRC="image5" WIDTH="21" HEIGHT="21" BORDER="0" ALT="homepage"></A> <A HREF="http://apps.freshmeat.net/changelog/931819147/"><IMG SRC="image8" WIDTH="21" HEIGHT="21" BORDER="0" ALT="changelog"></A> <A HREF="/appindex/1999/07/12/931819147.html"><IMG SRC="image7" WIDTH="21" HEIGHT="21" BORDER="0" ALT="appindex record"></A> &nbsp;
+</TD></TR></TABLE>
+<HR WIDTH="0" SIZE="0">
+
+
+<TABLE CELLSPACING="0" CELLPADDING="2" WIDTH="97%" BORDER="0" BGCOLOR="#000000"><TR><TD COLSPAN="2">
+<TABLE CELLSPACING="0" CELLPADDING="3" WIDTH="100%" BORDER="0" BGCOLOR="#FFFFFF">
+<TR><TD><FONT FACE="Lucida,Verdana,Helvetica,Arial">
+<B><FONT SIZE="+2">SCEZ 20000129</FONT></B><BR>
+<SMALL><B><A HREF="mailto:m032@mbsks.franken.de">endergone Zwiebeltuete</A> - January 29th 2000, 11:46 EST</B></SMALL>
+<DIV ALIGN="justify"><P>SCEZ is a library that should make the handling of smart cards (not memory cards) and card readers as simple as possible and be at the same time small and easily portable. Currently supported are Dumb Mouse, CT-API and Towitoko readers and Schlumberger Cryptoflex, Gemplus GPK4000, GSM SIM and Telesec SigG cards. A PKCS#15 implementation is in the design phase. There are ports to PalmOS and MS-Windows available.</DIV>
+<P><B>Changes:</B> More card and reader drivers, and an application to read out GSM SIM card (phone book and SMS) and write it to the card.
+<P><B>Urgency:</B> low
+<P ALIGN="right"><B>[ <A HREF="/news/2000/01/29/949164394.html">comments (0)</A> ]</B>
+</FONT></TD></TR></TABLE></TD></TR><TR><TD VALIGN="middle">
+&nbsp;<FONT FACE="Lucida,Verdana,Helvetica,Arial"><FONT COLOR="#FFFFFF"><B><SMALL>License: BSD type</SMALL></B><BR>
+<B><SMALL>&nbsp;Category: <A HREF="/appindex/development/libraries.html"><FONT COLOR="#FFFFFF">Development/Libraries</FONT></A></SMALL></B></FONT></FONT></TD><TD ALIGN="right">
+<A HREF="http://apps.freshmeat.net/download/939677525/"><IMG SRC="image6" WIDTH="21" HEIGHT="21" BORDER="0" ALT="download"></A> <A HREF="http://apps.freshmeat.net/homepage/939677525/"><IMG SRC="image5" WIDTH="21" HEIGHT="21" BORDER="0" ALT="homepage"></A> <A HREF="/appindex/1999/10/11/939677525.html"><IMG SRC="image7" WIDTH="21" HEIGHT="21" BORDER="0" ALT="appindex record"></A> &nbsp;
+</TD></TR></TABLE>
+<HR WIDTH="0" SIZE="0">
+
+
+<TABLE CELLSPACING="0" CELLPADDING="2" WIDTH="97%" BORDER="0" BGCOLOR="#000000"><TR><TD COLSPAN="2">
+<TABLE CELLSPACING="0" CELLPADDING="3" WIDTH="100%" BORDER="0" BGCOLOR="#FFFFFF">
+<TR><TD><FONT FACE="Lucida,Verdana,Helvetica,Arial">
+<B><FONT SIZE="+2">Comicq 0.2.0</FONT></B><BR>
+<SMALL><B><A HREF="mailto:terminal6@submail.net">Terminal6</A> - January 29th 2000, 11:45 EST</B></SMALL>
+<DIV ALIGN="justify"><P>COMICQ is a command line ICQ messaging tool that allows a user to connect to ICQ using your UIN and password, then sends a message to the destination UIN.</DIV>
+<P><B>Changes:</B> Several bugfixes, icq99a compliance, and a new option --ip that allows you to get any user's IP by their UIN.
+<P><B>Urgency:</B> low
+<P ALIGN="right"><B>[ <A HREF="/news/2000/01/29/949164350.html">comments (0)</A> ]</B>
+</FONT></TD></TR></TABLE></TD></TR><TR><TD VALIGN="middle">
+&nbsp;<FONT FACE="Lucida,Verdana,Helvetica,Arial"><FONT COLOR="#FFFFFF"><B><SMALL>License: GPL</SMALL></B><BR>
+<B><SMALL>&nbsp;Category: <A HREF="/appindex/console/communication.html"><FONT COLOR="#FFFFFF">Console/Communication</FONT></A></SMALL></B></FONT></FONT></TD><TD ALIGN="right">
+<A HREF="http://apps.freshmeat.net/download/948389309/"><IMG SRC="image6" WIDTH="21" HEIGHT="21" BORDER="0" ALT="download"></A> <A HREF="http://apps.freshmeat.net/homepage/948389309/"><IMG SRC="image5" WIDTH="21" HEIGHT="21" BORDER="0" ALT="homepage"></A> <A HREF="/appindex/2000/01/20/948389309.html"><IMG SRC="image7" WIDTH="21" HEIGHT="21" BORDER="0" ALT="appindex record"></A> &nbsp;
+</TD></TR></TABLE>
+<HR WIDTH="0" SIZE="0">
+
+
+<TABLE CELLSPACING="0" CELLPADDING="2" WIDTH="97%" BORDER="0" BGCOLOR="#000000"><TR><TD COLSPAN="2">
+<TABLE CELLSPACING="0" CELLPADDING="3" WIDTH="100%" BORDER="0" BGCOLOR="#FFFFFF">
+<TR><TD><FONT FACE="Lucida,Verdana,Helvetica,Arial">
+<B><FONT SIZE="+2">senv 0.2</FONT></B><BR>
+<SMALL><B><A HREF="mailto:kojak@ids.pl">Zbyszek Sobiecki</A> - January 29th 2000, 11:44 EST</B></SMALL>
+<DIV ALIGN="justify"><P>Senv allows you to run programs with a specified environment. It can set uid, gid, root directory, working directory, limits, and environment variables. It is useful in init scripts and as a shell for users for setting resource limits and environment variables. You can create sets of configurations and specify the one to use from command line.</DIV>
+<P><B>Changes:</B> Login shell limits and environment setting for users, permanent resource limits for specified groups of users and environment variables, and other minor bugfixes.
+<P><B>Urgency:</B> low
+<P ALIGN="right"><B>[ <A HREF="/news/2000/01/29/949164259.html">comments (0)</A> ]</B>
+</FONT></TD></TR></TABLE></TD></TR><TR><TD VALIGN="middle">
+&nbsp;<FONT FACE="Lucida,Verdana,Helvetica,Arial"><FONT COLOR="#FFFFFF"><B><SMALL>License: GPL</SMALL></B><BR>
+<B><SMALL>&nbsp;Category: <A HREF="/appindex/console/administration.html"><FONT COLOR="#FFFFFF">Console/Administration</FONT></A></SMALL></B></FONT></FONT></TD><TD ALIGN="right">
+<A HREF="http://apps.freshmeat.net/download/944953892/"><IMG SRC="image6" WIDTH="21" HEIGHT="21" BORDER="0" ALT="download"></A> <A HREF="http://apps.freshmeat.net/changelog/944953892/"><IMG SRC="image8" WIDTH="21" HEIGHT="21" BORDER="0" ALT="changelog"></A> <A HREF="/appindex/1999/12/11/944953892.html"><IMG SRC="image7" WIDTH="21" HEIGHT="21" BORDER="0" ALT="appindex record"></A> &nbsp;
+</TD></TR></TABLE>
+<HR WIDTH="0" SIZE="0">
+
+
+<TABLE CELLSPACING="0" CELLPADDING="2" WIDTH="97%" BORDER="0" BGCOLOR="#000000"><TR><TD COLSPAN="2">
+<TABLE CELLSPACING="0" CELLPADDING="3" WIDTH="100%" BORDER="0" BGCOLOR="#FFFFFF">
+<TR><TD><FONT FACE="Lucida,Verdana,Helvetica,Arial">
+<B><FONT SIZE="+2">XZX 2.9.2</FONT></B><BR>
+<SMALL><B><A HREF="mailto:Erik.Kunze@fantasy.muc.de">E. Kunze</A> - January 29th 2000, 10:55 EST</B></SMALL>
+<DIV ALIGN="justify"><P>XZX is a portable emulator of ZX Spectrum 48K/128K/+3 (8-bit home computers made by Sir Clive Sinclair) and Pentagon/Scorpion (Spectrum clones made in Russia) for machines running UNIX and the X Window system. XZX is completely written in C and emulates Spectrum 48K, 128K, +2 and +3, Pentagon and Scorpion, Interface I with up to 8 microdrives, Multiface 128 and Multiface 3, BetaDisk 128 interface by Technology Research Ltd with 4 disk drives, +D interface by Miles Gordon Technology with 2 disk drives, Kempston mouse, Kempston joystick and built-in machine code monitor.</DIV>
+<P><B>Changes:</B> Lots of feature improvement and bug fixes. Most parts of the audio support has been rewritten for different UNICES.
+<P><B>Urgency:</B> low
+<P ALIGN="right"><B>[ <A HREF="/news/2000/01/29/949161354.html">comments (0)</A> ]</B>
+</FONT></TD></TR></TABLE></TD></TR><TR><TD VALIGN="middle">
+&nbsp;<FONT FACE="Lucida,Verdana,Helvetica,Arial"><FONT COLOR="#FFFFFF"><B><SMALL>License: Shareware</SMALL></B><BR>
+<B><SMALL>&nbsp;Category: <A HREF="/appindex/x11/emulators.html"><FONT COLOR="#FFFFFF">X11/Emulators</FONT></A></SMALL></B></FONT></FONT></TD><TD ALIGN="right">
+<A HREF="http://apps.freshmeat.net/download/936956384/"><IMG SRC="image6" WIDTH="21" HEIGHT="21" BORDER="0" ALT="download"></A> <A HREF="http://apps.freshmeat.net/homepage/936956384/"><IMG SRC="image5" WIDTH="21" HEIGHT="21" BORDER="0" ALT="homepage"></A> <A HREF="http://apps.freshmeat.net/changelog/936956384/"><IMG SRC="image8" WIDTH="21" HEIGHT="21" BORDER="0" ALT="changelog"></A> <A HREF="/appindex/1999/09/10/936956384.html"><IMG SRC="image7" WIDTH="21" HEIGHT="21" BORDER="0" ALT="appindex record"></A> &nbsp;
+</TD></TR></TABLE>
+<HR WIDTH="0" SIZE="0">
+
+
+<P><SMALL><CENTER><B>[ <A HREF="/news/2000/01/29/">full page for today</A> | <A HREF="/news/2000/01/28/">yesterday's edition</A> ]</SMALL></B></CENTER></FONT></TD><TD WIDTH="27%" VALIGN="top" ALIGN="center"><FONT FACE="Lucida,Verdana,Helvetica,Arial">
+
+<TABLE BORDER="0" CELLPADDING="1" CELLSPACING="0" BGCOLOR="#000000" WIDTH="97%"><TR><TD>
+<TABLE WIDTH="100%" BORDER="0" CELLSPACING="1" CELLPADDING="3">
+<TR><TD ALIGN="center" BGCOLOR="#EEEEEE"><B><FONT FACE="Lucida,Verdana,Helvetica,Arial"><FONT COLOR="#000000">navigator</FONT></FONT></B></TD></TR><TR><TD BGCOLOR="#FFFFFF"><SMALL><FONT FACE="Lucida,Verdana,Helvetica,Arial">
+- <A HREF="/news/2000/01/29/"><FONT COLOR="#000000">full page for today</FONT></A><BR>
+- <A HREF="/news/2000/01/28/"><FONT COLOR="#000000">yesterday's edition</FONT></A><BR>
+- <A HREF="news://news.freshmeat.net/"><FONT COLOR="#000000"><B>new:</B> fm news via NNTP</FONT></A><BR>
+&nbsp;</FONT></SMALL></TD></TR></TABLE></TD></TR></TABLE><P>
+<TABLE BORDER="0" CELLPADDING="1" CELLSPACING="0" BGCOLOR="#000000" WIDTH="97%"><TR><TD>
+<TABLE WIDTH="100%" BORDER="0" CELLSPACING="1" CELLPADDING="3">
+<TR><TD ALIGN="center" BGCOLOR="#EEEEEE"><B><FONT FACE="Lucida,Verdana,Helvetica,Arial"><FONT COLOR="#000000">eye catcher</FONT></FONT></B></TD></TR><TR><TD BGCOLOR="#FFFFFF"><SMALL><FONT FACE="Lucida,Verdana,Helvetica,Arial">
+<B>Free Shirts</B><BR>We give away a free freshmeat t-shirt every week for the best comment added to an application announcement or story posted on freshmeat.
+<P><B>#freshmeat</B><BR>If you want to chat about what's new on freshmeat and hang out with other fm lounge lizards and the fm staff, head over to #freshmeat on irc.freshmeat.net, part of <A HREF="http://openprojects.nu/">The Open Projects Network</A>.
+&nbsp;</FONT></SMALL></TD></TR></TABLE></TD></TR></TABLE><P>
+<TABLE BORDER="0" CELLPADDING="1" CELLSPACING="0" BGCOLOR="#000000" WIDTH="97%"><TR><TD>
+<TABLE WIDTH="100%" BORDER="0" CELLSPACING="1" CELLPADDING="3">
+<TR><TD ALIGN="center" BGCOLOR="#EEEEEE"><B><FONT FACE="Lucida,Verdana,Helvetica,Arial"><FONT COLOR="#000000">site notes</FONT></FONT></B></TD></TR><TR><TD BGCOLOR="#FFFFFF"><SMALL><FONT FACE="Lucida,Verdana,Helvetica,Arial">
+- <A HREF="/news/2000/01/29/949208399.html"><FONT COLOR="#000000">We should get this out of the door now (Jan 29th)</FONT></A><BR>
+- <A HREF="/news/2000/01/01/946704535.html"><FONT COLOR="#000000">freshmeat Y2K report (Jan 01st)</FONT></A><BR>
+- <A HREF="/news/1999/08/16/934862340.html"><FONT COLOR="#000000">Assorted freshmeat notes (Aug 16th)</FONT></A><BR>
+&nbsp;</FONT></SMALL></TD></TR></TABLE></TD></TR></TABLE><P>
+<TABLE BORDER="0" CELLPADDING="1" CELLSPACING="0" BGCOLOR="#000000" WIDTH="97%"><TR><TD>
+<TABLE WIDTH="100%" BORDER="0" CELLSPACING="1" CELLPADDING="3">
+<TR><TD ALIGN="center" BGCOLOR="#EEEEEE"><B><FONT FACE="Lucida,Verdana,Helvetica,Arial"><FONT COLOR="#000000">recent editorials</FONT></FONT></B></TD></TR><TR><TD BGCOLOR="#FFFFFF"><SMALL><FONT FACE="Lucida,Verdana,Helvetica,Arial">
+- <A HREF="/news/2000/01/29/949208340.html"><FONT COLOR="#000000">Is Linux for Crazies? (Jan 29th)</FONT></A><BR>
+- <A HREF="/news/2000/01/22/948603540.html"><FONT COLOR="#000000">A New Business Plan for Free Software (Jan 22nd)</FONT></A><BR>
+- <A HREF="/news/2000/01/15/947998740.html"><FONT COLOR="#000000">Is Linux Going to Reunite the UNIX Market? (Jan 15th)</FONT></A><BR>
+&nbsp;</FONT></SMALL></TD></TR></TABLE></TD></TR></TABLE><P>
+<TABLE BORDER="0" CELLPADDING="1" CELLSPACING="0" BGCOLOR="#000000" WIDTH="97%"><TR><TD>
+<TABLE WIDTH="100%" BORDER="0" CELLSPACING="1" CELLPADDING="3">
+<TR><TD ALIGN="center" BGCOLOR="#EEEEEE"><B><FONT FACE="Lucida,Verdana,Helvetica,Arial"><FONT COLOR="#000000">andover.net</FONT></FONT></B></TD></TR><TR><TD BGCOLOR="#FFFFFF"><SMALL><FONT FACE="Lucida,Verdana,Helvetica,Arial">
+<BR><CENTER><A HREF="http://andover.net"><IMG SRC="image9" BORDER="0" WIDTH="150" HEIGHT="43" ALT="Mirror Logo"></A></CENTER><P>
+- <A HREF="http://www.animfactory.com/"><FONT COLOR="#000000">Animation Factory</FONT></A><BR>
+- <A HREF="http://www.davecentral.com/"><FONT COLOR="#000000">DaveCentral</FONT></A><BR>
+- <A HREF="http://www.freecode.com/"><FONT COLOR="#000000">FreeCode</FONT></A><BR>
+- <A HREF="http://www.InternetTrafficReport.com/"><FONT COLOR="#000000">Internet Traffic Report</FONT></A><BR>
+- <A HREF="http://www.ITManagersJournal.com/"><FONT COLOR="#000000">IT Manager's Journal</FONT></A><BR>
+- <A HREF="http://www.mediabuilder.com/"><FONT COLOR="#000000">MediaBuilder</FONT></A><BR>
+- <A HREF="http://slashdot.org/"><FONT COLOR="#000000">Slashdot</FONT></A><BR>
+- <A HREF="http://www.slaughterhouse.com/"><FONT COLOR="#000000">Slaughterhouse</FONT></A><BR>
+- <A HREF="http://www.techmailings.com/"><FONT COLOR="#000000">TechMailings</FONT></A><BR>
+- <A HREF="http://www.techsightings.com/"><FONT COLOR="#000000">TechSightings</FONT></A><BR>
+<BR><CENTER><B>E-Commerce</B></CENTER><P>
+- <A HREF="http://www.thinkgeek.com"><FONT COLOR="#000000">ThinkGeek (Stuff for smart masses)</FONT></A><BR>
+&nbsp;</FONT></SMALL></TD></TR></TABLE></TD></TR></TABLE><P>
+<TABLE BORDER="0" CELLPADDING="1" CELLSPACING="0" BGCOLOR="#000000" WIDTH="97%"><TR><TD>
+<TABLE WIDTH="100%" BORDER="0" CELLSPACING="1" CELLPADDING="3">
+<TR><TD ALIGN="center" BGCOLOR="#EEEEEE"><B><FONT FACE="Lucida,Verdana,Helvetica,Arial"><FONT COLOR="#000000">supported sites</FONT></FONT></B></TD></TR><TR><TD BGCOLOR="#FFFFFF"><SMALL><FONT FACE="Lucida,Verdana,Helvetica,Arial">
+- <A HREF="http://www.userfriendly.org"><FONT COLOR="#000000">Userfriendly.org</FONT></A><BR>
+- <A HREF="http://www.securityfocus.com"><FONT COLOR="#000000">SecurityFocus</FONT></A><BR>
+- <A HREF="http://copyleft.net"><FONT COLOR="#000000">copyleft</FONT></A><BR>
+- <A HREF="http://filewatcher.org"><FONT COLOR="#000000">Filewatcher</FONT></A><BR>
+- <A HREF="http://www.linux.com"><FONT COLOR="#000000">Linux.com</FONT></A><BR>
+- <A HREF="http://www.linuxtelephony.org"><FONT COLOR="#000000">LinuxTelephony</FONT></A><BR>
+- <A HREF="http://www.linuxtoday.com"><FONT COLOR="#000000">LinuxToday</FONT></A><BR>
+- <A HREF="http://openprojects.nu/services/irc.html"><FONT COLOR="#000000">Openprojects</FONT></A><BR>
+- <A HREF="http://www.32bitsonline.com"><FONT COLOR="#000000">32bitsonline</FONT></A><BR>
+- <A HREF="http://www.gnu.org"><FONT COLOR="#000000">The GNU Project</FONT></A><BR>
+&nbsp;</FONT></SMALL></TD></TR></TABLE></TD></TR></TABLE><P>
+<TABLE BORDER="0" CELLPADDING="1" CELLSPACING="0" BGCOLOR="#000000" WIDTH="97%"><TR><TD>
+<TABLE WIDTH="100%" BORDER="0" CELLSPACING="1" CELLPADDING="3">
+<TR><TD ALIGN="center" BGCOLOR="#EEEEEE"><B><FONT FACE="Lucida,Verdana,Helvetica,Arial"><FONT COLOR="#000000"><a href="/news/2000/01/29/"><font color="#000000">saturday</font></a></FONT></FONT></B></TD></TR><TR><TD BGCOLOR="#FFFFFF"><SMALL><FONT FACE="Lucida,Verdana,Helvetica,Arial">
+- <A HREF="/news/2000/01/29/949208399.html"><FONT COLOR="#000000">We should get this out of the door now</FONT></A><BR>
+- <A HREF="/news/2000/01/29/949208340.html"><FONT COLOR="#000000">Is Linux for Crazies?</FONT></A><BR>
+- <A HREF="/news/2000/01/29/949188564.html"><FONT COLOR="#000000">RabbIT 2.0.2</FONT></A><BR>
+- <A HREF="/news/2000/01/29/949187896.html"><FONT COLOR="#000000">nmpg 1.1.3</FONT></A><BR>
+- <A HREF="/news/2000/01/29/949187471.html"><FONT COLOR="#000000">mod_dtcl 0.7.3</FONT></A><BR>
+- <A HREF="/news/2000/01/29/949187233.html"><FONT COLOR="#000000">CoreLinux++ 0.4.6</FONT></A><BR>
+- <A HREF="/news/2000/01/29/949165962.html"><FONT COLOR="#000000">scribe 0.2</FONT></A><BR>
+- <A HREF="/news/2000/01/29/949165472.html"><FONT COLOR="#000000">E theme updater 0.1</FONT></A><BR>
+- <A HREF="/news/2000/01/29/949165416.html"><FONT COLOR="#000000">Powertweak-Linux 0.1.7</FONT></A><BR>
+- <A HREF="/news/2000/01/29/949164956.html"><FONT COLOR="#000000">Pexeso Beta</FONT></A><BR>
+- <A HREF="/news/2000/01/29/949164896.html"><FONT COLOR="#000000">XZX 2.9.2</FONT></A><BR>
+- <A HREF="/news/2000/01/29/949164869.html"><FONT COLOR="#000000">DistroLib 0.4</FONT></A><BR>
+- <A HREF="/news/2000/01/29/949164843.html"><FONT COLOR="#000000">ToutDoux 1.1.7</FONT></A><BR>
+- <A HREF="/news/2000/01/29/949164772.html"><FONT COLOR="#000000">goMP 1.0.3</FONT></A><BR>
+- <A HREF="/news/2000/01/29/949164633.html"><FONT COLOR="#000000">APSEND 1.40</FONT></A><BR>
+- <A HREF="/news/2000/01/29/949164529.html"><FONT COLOR="#000000">ecasound 1.6.12r10</FONT></A><BR>
+- <A HREF="/news/2000/01/29/949164394.html"><FONT COLOR="#000000">SCEZ 20000129</FONT></A><BR>
+- <A HREF="/news/2000/01/29/949164350.html"><FONT COLOR="#000000">Comicq 0.2.0</FONT></A><BR>
+- <A HREF="/news/2000/01/29/949164259.html"><FONT COLOR="#000000">senv 0.2</FONT></A><BR>
+- <A HREF="/news/2000/01/29/949161354.html"><FONT COLOR="#000000">XZX 2.9.2</FONT></A><BR>
+- <A HREF="/news/2000/01/29/949161036.html"><FONT COLOR="#000000">log4j 0.7.5</FONT></A><BR>
+- <A HREF="/news/2000/01/29/949156343.html"><FONT COLOR="#000000">SQN Linux 1.6</FONT></A><BR>
+- <A HREF="/news/2000/01/29/949156277.html"><FONT COLOR="#000000">Limo 0.3.2</FONT></A><BR>
+- <A HREF="/news/2000/01/29/949156237.html"><FONT COLOR="#000000">Fusion GS 1.3</FONT></A><BR>
+- <A HREF="/news/2000/01/29/949145887.html"><FONT COLOR="#000000">MMR 1.5.4</FONT></A><BR>
+- <A HREF="/news/2000/01/29/949142835.html"><FONT COLOR="#000000">KUPS 0.3.4</FONT></A><BR>
+- <A HREF="/news/2000/01/29/949142815.html"><FONT COLOR="#000000">3DSE patch for XMMS 4</FONT></A><BR>
+- <A HREF="/news/2000/01/29/949139763.html"><FONT COLOR="#000000">Linux 2.3.41</FONT></A><BR>
+- <A HREF="/news/2000/01/29/949139751.html"><FONT COLOR="#000000">Free Code for Linux S/390</FONT></A><BR>
+- <A HREF="/news/2000/01/29/949135979.html"><FONT COLOR="#000000">CircleMUD 3.0 beta patchlevel 17</FONT></A><BR>
+- <A HREF="/news/2000/01/29/949135938.html"><FONT COLOR="#000000">NiL Isn't Liero 000128</FONT></A><BR>
+- <A HREF="/news/2000/01/29/949135913.html"><FONT COLOR="#000000">OpenSSH Unix Port 1.2.2</FONT></A><BR>
+- <A HREF="/news/2000/01/29/949135889.html"><FONT COLOR="#000000">KBoxes! 1.3</FONT></A><BR>
+- <A HREF="/news/2000/01/29/949135867.html"><FONT COLOR="#000000">phpLanParty 0.23</FONT></A><BR>
+- <A HREF="/news/2000/01/29/949135509.html"><FONT COLOR="#000000">DGen/SDL 1.20</FONT></A><BR>
+- <A HREF="/news/2000/01/29/949135482.html"><FONT COLOR="#000000">EdcomLib 1.0 alpha 5</FONT></A><BR>
+- <A HREF="/news/2000/01/29/949135309.html"><FONT COLOR="#000000">Etherboot 4.4.2</FONT></A><BR>
+- <A HREF="/news/2000/01/29/949135205.html"><FONT COLOR="#000000">BLADE 0.18.0</FONT></A><BR>
+- <A HREF="/news/2000/01/29/949135115.html"><FONT COLOR="#000000">Sapphire 0.13.7</FONT></A><BR>
+- <A HREF="/news/2000/01/29/949135070.html"><FONT COLOR="#000000">ippl 1.99.3</FONT></A><BR>
+- <A HREF="/news/2000/01/29/949134977.html"><FONT COLOR="#000000">Saint 1.5patch1</FONT></A><BR>
+- <A HREF="/news/2000/01/29/949134943.html"><FONT COLOR="#000000">Zircon 1.18.232</FONT></A><BR>
+- <A HREF="/news/2000/01/29/949134927.html"><FONT COLOR="#000000">nmap 2.3BETA14</FONT></A><BR>
+- <A HREF="/news/2000/01/29/949134901.html"><FONT COLOR="#000000">xterm patch #124</FONT></A><BR>
+- <A HREF="/news/2000/01/29/949134817.html"><FONT COLOR="#000000">MyThreads-Links v0.5.2</FONT></A><BR>
+- <A HREF="/news/2000/01/29/949134633.html"><FONT COLOR="#000000">sudo 1.6.2p1</FONT></A><BR>
+- <A HREF="/news/2000/01/29/949134552.html"><FONT COLOR="#000000">MIT Photonic-Bands 0.10</FONT></A><BR>
+- <A HREF="/news/2000/01/29/949134246.html"><FONT COLOR="#000000">Launcher 0.86</FONT></A><BR>
+- <A HREF="/news/2000/01/29/949134179.html"><FONT COLOR="#000000">nano 0.8.1</FONT></A><BR>
+- <A HREF="/news/2000/01/29/949134103.html"><FONT COLOR="#000000">Gtk-- 1.1.8</FONT></A><BR>
+- <A HREF="/news/2000/01/29/949134049.html"><FONT COLOR="#000000">tkchooser 0.65</FONT></A><BR>
+- <A HREF="/news/2000/01/29/949133420.html"><FONT COLOR="#000000">XShipWars 1.33a</FONT></A><BR>
+- <A HREF="/news/2000/01/29/949133280.html"><FONT COLOR="#000000">Lamerpad 0.1</FONT></A><BR>
+&nbsp;</FONT></SMALL></TD></TR></TABLE></TD></TR></TABLE><P>
+<TABLE BORDER="0" CELLPADDING="1" CELLSPACING="0" BGCOLOR="#000000" WIDTH="97%"><TR><TD>
+<TABLE WIDTH="100%" BORDER="0" CELLSPACING="1" CELLPADDING="3">
+<TR><TD ALIGN="center" BGCOLOR="#EEEEEE"><B><FONT FACE="Lucida,Verdana,Helvetica,Arial"><FONT COLOR="#000000"><a href="/news/2000/01/28/"><font color="#000000">friday</font></a></FONT></FONT></B></TD></TR><TR><TD BGCOLOR="#FFFFFF"><SMALL><FONT FACE="Lucida,Verdana,Helvetica,Arial">
+- <A HREF="/news/2000/01/28/949117833.html"><FONT COLOR="#000000">fsv 0.9</FONT></A><BR>
+- <A HREF="/news/2000/01/28/949117711.html"><FONT COLOR="#000000">popsneaker 0.1.1</FONT></A><BR>
+- <A HREF="/news/2000/01/28/949114716.html"><FONT COLOR="#000000">eyep-updater.sh 1.0</FONT></A><BR>
+- <A HREF="/news/2000/01/28/949113240.html"><FONT COLOR="#000000">W3Mail 0.5.0</FONT></A><BR>
+- <A HREF="/news/2000/01/28/949113214.html"><FONT COLOR="#000000">The Urgent Decision 0.9.9</FONT></A><BR>
+- <A HREF="/news/2000/01/28/949112269.html"><FONT COLOR="#000000">LTSP 1.02</FONT></A><BR>
+- <A HREF="/news/2000/01/28/949112198.html"><FONT COLOR="#000000">Production BASIC 0.2.12</FONT></A><BR>
+- <A HREF="/news/2000/01/28/949112123.html"><FONT COLOR="#000000">Postfix 19991231-pl03</FONT></A><BR>
+- <A HREF="/news/2000/01/28/949109732.html"><FONT COLOR="#000000">Mp3 Commander 0.7</FONT></A><BR>
+- <A HREF="/news/2000/01/28/949109324.html"><FONT COLOR="#000000">iManager 1.0.1b</FONT></A><BR>
+- <A HREF="/news/2000/01/28/949108399.html"><FONT COLOR="#000000">Eterm 0.9</FONT></A><BR>
+- <A HREF="/news/2000/01/28/949108308.html"><FONT COLOR="#000000">dqd_dirindex 1.0</FONT></A><BR>
+- <A HREF="/news/2000/01/28/949108087.html"><FONT COLOR="#000000">Tidings 1.0.4</FONT></A><BR>
+- <A HREF="/news/2000/01/28/949108026.html"><FONT COLOR="#000000">localscan 2.1</FONT></A><BR>
+- <A HREF="/news/2000/01/28/949107922.html"><FONT COLOR="#000000">WMKeyboard 0.3</FONT></A><BR>
+- <A HREF="/news/2000/01/28/949107834.html"><FONT COLOR="#000000">fcmp 1.0.2</FONT></A><BR>
+- <A HREF="/news/2000/01/28/949107767.html"><FONT COLOR="#000000">Akkord 0.3.1</FONT></A><BR>
+- <A HREF="/news/2000/01/28/949107649.html"><FONT COLOR="#000000">HiM 0.1.1</FONT></A><BR>
+- <A HREF="/news/2000/01/28/949106305.html"><FONT COLOR="#000000">cdrecord 1.8</FONT></A><BR>
+- <A HREF="/news/2000/01/28/949103400.html"><FONT COLOR="#000000">eMixer 0.05.5</FONT></A><BR>
+- <A HREF="/news/2000/01/28/949103187.html"><FONT COLOR="#000000">FreeVSD 1.4.0</FONT></A><BR>
+- <A HREF="/news/2000/01/28/949103096.html"><FONT COLOR="#000000">Common C++ Libraries 0.0</FONT></A><BR>
+- <A HREF="/news/2000/01/28/949095155.html"><FONT COLOR="#000000">Moonshine 1.0beta2</FONT></A><BR>
+- <A HREF="/news/2000/01/28/949095112.html"><FONT COLOR="#000000">swim 0.3.5</FONT></A><BR>
+- <A HREF="/news/2000/01/28/949095009.html"><FONT COLOR="#000000">Xmame/xmess 0.36b15.1</FONT></A><BR>
+- <A HREF="/news/2000/01/28/949094448.html"><FONT COLOR="#000000">pcmcia-cs 3.1.9</FONT></A><BR>
+- <A HREF="/news/2000/01/28/949091509.html"><FONT COLOR="#000000">gPS 0.5.2</FONT></A><BR>
+- <A HREF="/news/2000/01/28/949091415.html"><FONT COLOR="#000000">Snort 1.5.1</FONT></A><BR>
+- <A HREF="/news/2000/01/28/949090436.html"><FONT COLOR="#000000">Pygmy Linux 0.7 beta</FONT></A><BR>
+- <A HREF="/news/2000/01/28/949090237.html"><FONT COLOR="#000000">Intro to Bash Programming HOWTO 0.3</FONT></A><BR>
+- <A HREF="/news/2000/01/28/949084379.html"><FONT COLOR="#000000">GNU Pth 1.3b2</FONT></A><BR>
+- <A HREF="/news/2000/01/28/949084356.html"><FONT COLOR="#000000">Laonux 0.1</FONT></A><BR>
+- <A HREF="/news/2000/01/28/949084304.html"><FONT COLOR="#000000">x-wvdial 0.12</FONT></A><BR>
+- <A HREF="/news/2000/01/28/949084188.html"><FONT COLOR="#000000">Intro to Bash Programming HOWTO 0.3</FONT></A><BR>
+- <A HREF="/news/2000/01/28/949084106.html"><FONT COLOR="#000000">Catalog 1.02</FONT></A><BR>
+- <A HREF="/news/2000/01/28/949084062.html"><FONT COLOR="#000000">harvest 1.5.20-kj-0.9</FONT></A><BR>
+- <A HREF="/news/2000/01/28/949068306.html"><FONT COLOR="#000000">wmseti 0.3.0a</FONT></A><BR>
+- <A HREF="/news/2000/01/28/949057272.html"><FONT COLOR="#000000">RIG 1.02</FONT></A><BR>
+- <A HREF="/news/2000/01/28/949057019.html"><FONT COLOR="#000000">FreeAddr 0.2</FONT></A><BR>
+- <A HREF="/news/2000/01/28/949056939.html"><FONT COLOR="#000000">GtkAda 1.2.5</FONT></A><BR>
+- <A HREF="/news/2000/01/28/949056664.html"><FONT COLOR="#000000">dot.conf 0.6.0</FONT></A><BR>
+- <A HREF="/news/2000/01/28/949055099.html"><FONT COLOR="#000000">dep.pl 1.28.0</FONT></A><BR>
+- <A HREF="/news/2000/01/28/949054980.html"><FONT COLOR="#000000">Prae's Scripts 1.1</FONT></A><BR>
+- <A HREF="/news/2000/01/28/949044301.html"><FONT COLOR="#000000">Project Clock 0.1</FONT></A><BR>
+- <A HREF="/news/2000/01/28/949044285.html"><FONT COLOR="#000000">Xtheater 0.2.1</FONT></A><BR>
+- <A HREF="/news/2000/01/28/949040013.html"><FONT COLOR="#000000">i-no Chart 0.1</FONT></A><BR>
+- <A HREF="/news/2000/01/28/949039945.html"><FONT COLOR="#000000">spliff 0.8.1</FONT></A><BR>
+- <A HREF="/news/2000/01/28/949038953.html"><FONT COLOR="#000000">Regexx 0.95</FONT></A><BR>
+- <A HREF="/news/2000/01/28/949038316.html"><FONT COLOR="#000000">RBook 0.5.0</FONT></A><BR>
+- <A HREF="/news/2000/01/28/949036742.html"><FONT COLOR="#000000">RIG 1.01</FONT></A><BR>
+- <A HREF="/news/2000/01/28/949036714.html"><FONT COLOR="#000000">wchat 1.2.0</FONT></A><BR>
+- <A HREF="/news/2000/01/28/949036428.html"><FONT COLOR="#000000">PCCS MySQLDatabase Admin Tool 1.2.2</FONT></A><BR>
+&nbsp;</FONT></SMALL></TD></TR></TABLE></TD></TR></TABLE><P>
+<TABLE BORDER="0" CELLPADDING="1" CELLSPACING="0" BGCOLOR="#000000" WIDTH="97%"><TR><TD>
+<TABLE WIDTH="100%" BORDER="0" CELLSPACING="1" CELLPADDING="3">
+<TR><TD ALIGN="center" BGCOLOR="#EEEEEE"><B><FONT FACE="Lucida,Verdana,Helvetica,Arial"><FONT COLOR="#000000"><a href="/news/2000/01/27/"><font color="#000000">thursday</font></a></FONT></FONT></B></TD></TR><TR><TD BGCOLOR="#FFFFFF"><SMALL><FONT FACE="Lucida,Verdana,Helvetica,Arial">
+- <A HREF="/news/2000/01/27/949033332.html"><FONT COLOR="#000000">CADUBI 1.1b1</FONT></A><BR>
+- <A HREF="/news/2000/01/27/949032987.html"><FONT COLOR="#000000">Angus' Chess Clock 0.8.1</FONT></A><BR>
+- <A HREF="/news/2000/01/27/949032555.html"><FONT COLOR="#000000">MP3 Report Generator 1.0.0</FONT></A><BR>
+- <A HREF="/news/2000/01/27/949032518.html"><FONT COLOR="#000000">4DOM 0.9.2</FONT></A><BR>
+- <A HREF="/news/2000/01/27/949032386.html"><FONT COLOR="#000000">4XSLT 0.8.2</FONT></A><BR>
+- <A HREF="/news/2000/01/27/949031346.html"><FONT COLOR="#000000">OpenNaken 1.10</FONT></A><BR>
+- <A HREF="/news/2000/01/27/949025747.html"><FONT COLOR="#000000">iManager 1.0b</FONT></A><BR>
+- <A HREF="/news/2000/01/27/949025168.html"><FONT COLOR="#000000">QuakeForge 0.1.0</FONT></A><BR>
+- <A HREF="/news/2000/01/27/949023271.html"><FONT COLOR="#000000">pylice 0.7.0</FONT></A><BR>
+- <A HREF="/news/2000/01/27/949023250.html"><FONT COLOR="#000000">Solfege 0.6.0</FONT></A><BR>
+- <A HREF="/news/2000/01/27/949023151.html"><FONT COLOR="#000000">xinetd 2.1.8.7p1</FONT></A><BR>
+- <A HREF="/news/2000/01/27/949022849.html"><FONT COLOR="#000000">jac 0.13</FONT></A><BR>
+- <A HREF="/news/2000/01/27/949022803.html"><FONT COLOR="#000000">Xmms 1.0.0</FONT></A><BR>
+- <A HREF="/news/2000/01/27/949022319.html"><FONT COLOR="#000000">KSrnd 0.97</FONT></A><BR>
+- <A HREF="/news/2000/01/27/949021877.html"><FONT COLOR="#000000">getpg / UW-IMAP 0.54</FONT></A><BR>
+- <A HREF="/news/2000/01/27/949021849.html"><FONT COLOR="#000000">getpg 0.53</FONT></A><BR>
+- <A HREF="/news/2000/01/27/949021824.html"><FONT COLOR="#000000">setserial 2.17</FONT></A><BR>
+- <A HREF="/news/2000/01/27/949021250.html"><FONT COLOR="#000000">Pan 0.7.3</FONT></A><BR>
+- <A HREF="/news/2000/01/27/949021216.html"><FONT COLOR="#000000">jwhois 2.4.1</FONT></A><BR>
+- <A HREF="/news/2000/01/27/949021126.html"><FONT COLOR="#000000">Kmp3 1.0</FONT></A><BR>
+- <A HREF="/news/2000/01/27/949020964.html"><FONT COLOR="#000000">xPine 0.0.12</FONT></A><BR>
+- <A HREF="/news/2000/01/27/949019905.html"><FONT COLOR="#000000">Avenger's News System 2.1 Alpha</FONT></A><BR>
+- <A HREF="/news/2000/01/27/949019709.html"><FONT COLOR="#000000">RIG 1.0</FONT></A><BR>
+- <A HREF="/news/2000/01/27/949019321.html"><FONT COLOR="#000000">scroller 1.0</FONT></A><BR>
+- <A HREF="/news/2000/01/27/949018347.html"><FONT COLOR="#000000">Perl EyeP Client 0.1</FONT></A><BR>
+- <A HREF="/news/2000/01/27/949017796.html"><FONT COLOR="#000000">sfront 0.54</FONT></A><BR>
+- <A HREF="/news/2000/01/27/949017631.html"><FONT COLOR="#000000">XFrisk 1.2</FONT></A><BR>
+- <A HREF="/news/2000/01/27/949016202.html"><FONT COLOR="#000000">Moffy 0.0.1</FONT></A><BR>
+- <A HREF="/news/2000/01/27/949015348.html"><FONT COLOR="#000000">Solid POP3 0.14</FONT></A><BR>
+- <A HREF="/news/2000/01/27/949014200.html"><FONT COLOR="#000000">php3guest 1.5</FONT></A><BR>
+- <A HREF="/news/2000/01/27/949013630.html"><FONT COLOR="#000000">crUD 01.27.2000</FONT></A><BR>
+- <A HREF="/news/2000/01/27/949013380.html"><FONT COLOR="#000000">crUD 01.27.2000</FONT></A><BR>
+- <A HREF="/news/2000/01/27/949012979.html"><FONT COLOR="#000000">Free Pascal Compiler 0.99.14</FONT></A><BR>
+- <A HREF="/news/2000/01/27/949012771.html"><FONT COLOR="#000000">gtk-font-hack 0.2-gtk-1.2.6</FONT></A><BR>
+- <A HREF="/news/2000/01/27/949009233.html"><FONT COLOR="#000000">Linux 2.2.15pre5</FONT></A><BR>
+- <A HREF="/news/2000/01/27/949005620.html"><FONT COLOR="#000000">krunseti 0.2.1</FONT></A><BR>
+- <A HREF="/news/2000/01/27/948996446.html"><FONT COLOR="#000000">CompuPic 5.0.1036</FONT></A><BR>
+- <A HREF="/news/2000/01/27/948995905.html"><FONT COLOR="#000000">gfontview 0.3.3</FONT></A><BR>
+- <A HREF="/news/2000/01/27/948995819.html"><FONT COLOR="#000000">authlocal 1.0.2</FONT></A><BR>
+- <A HREF="/news/2000/01/27/948995600.html"><FONT COLOR="#000000">bigwig 1.1</FONT></A><BR>
+- <A HREF="/news/2000/01/27/948995501.html"><FONT COLOR="#000000">CAFire 0.0.11</FONT></A><BR>
+- <A HREF="/news/2000/01/27/948995429.html"><FONT COLOR="#000000">ANVLOGIN 2.0</FONT></A><BR>
+- <A HREF="/news/2000/01/27/948994944.html"><FONT COLOR="#000000">sawmill.el 1.9</FONT></A><BR>
+- <A HREF="/news/2000/01/27/948994810.html"><FONT COLOR="#000000">Perlsh 20000127</FONT></A><BR>
+- <A HREF="/news/2000/01/27/948994776.html"><FONT COLOR="#000000">sitescooper 2.1.2</FONT></A><BR>
+- <A HREF="/news/2000/01/27/948994691.html"><FONT COLOR="#000000">MHDns 1.4</FONT></A><BR>
+- <A HREF="/news/2000/01/27/948994419.html"><FONT COLOR="#000000">JChemPaint 0.5</FONT></A><BR>
+- <A HREF="/news/2000/01/27/948994364.html"><FONT COLOR="#000000">Filesystems HOWTO 0.7.3</FONT></A><BR>
+- <A HREF="/news/2000/01/27/948994343.html"><FONT COLOR="#000000">KSnes9x 1.2</FONT></A><BR>
+- <A HREF="/news/2000/01/27/948993513.html"><FONT COLOR="#000000">Mozilla M13</FONT></A><BR>
+- <A HREF="/news/2000/01/27/948993439.html"><FONT COLOR="#000000">edna 0.3</FONT></A><BR>
+- <A HREF="/news/2000/01/27/948993409.html"><FONT COLOR="#000000">GMasqdialer 0.99.8</FONT></A><BR>
+- <A HREF="/news/2000/01/27/948993341.html"><FONT COLOR="#000000">spliff 0.8</FONT></A><BR>
+- <A HREF="/news/2000/01/27/948992808.html"><FONT COLOR="#000000">MultiSeti 0.3</FONT></A><BR>
+- <A HREF="/news/2000/01/27/948970667.html"><FONT COLOR="#000000">rude 0.50</FONT></A><BR>
+- <A HREF="/news/2000/01/27/948970605.html"><FONT COLOR="#000000">cgi-util++ 0.0</FONT></A><BR>
+- <A HREF="/news/2000/01/27/948970479.html"><FONT COLOR="#000000">Cricket 0.72</FONT></A><BR>
+- <A HREF="/news/2000/01/27/948970458.html"><FONT COLOR="#000000">nuni 0.04</FONT></A><BR>
+- <A HREF="/news/2000/01/27/948970379.html"><FONT COLOR="#000000">Ksetiwatch 0.3.0</FONT></A><BR>
+- <A HREF="/news/2000/01/27/948970358.html"><FONT COLOR="#000000">SiteMgrYAP 0.1.2</FONT></A><BR>
+- <A HREF="/news/2000/01/27/948970322.html"><FONT COLOR="#000000">phpLanParty 0.21</FONT></A><BR>
+- <A HREF="/news/2000/01/27/948970285.html"><FONT COLOR="#000000">Glitter Newsreader 0.1</FONT></A><BR>
+- <A HREF="/news/2000/01/27/948970263.html"><FONT COLOR="#000000">Fastresolve 2.4</FONT></A><BR>
+- <A HREF="/news/2000/01/27/948970164.html"><FONT COLOR="#000000">ColdSync 1.1.2</FONT></A><BR>
+- <A HREF="/news/2000/01/27/948970080.html"><FONT COLOR="#000000">DDD 3.2</FONT></A><BR>
+- <A HREF="/news/2000/01/27/948970032.html"><FONT COLOR="#000000">X Northern Captain 4.2.1</FONT></A><BR>
+- <A HREF="/news/2000/01/27/948969919.html"><FONT COLOR="#000000">abcde 1.0.2</FONT></A><BR>
+- <A HREF="/news/2000/01/27/948969659.html"><FONT COLOR="#000000">Gnapster 1.3.2</FONT></A><BR>
+- <A HREF="/news/2000/01/27/948969551.html"><FONT COLOR="#000000">xmix 1.0 Alpha</FONT></A><BR>
+- <A HREF="/news/2000/01/27/948969488.html"><FONT COLOR="#000000">gtktetcolor 0.3</FONT></A><BR>
+- <A HREF="/news/2000/01/27/948969412.html"><FONT COLOR="#000000">muttzilla 0.40</FONT></A><BR>
+- <A HREF="/news/2000/01/27/948969395.html"><FONT COLOR="#000000">muttzilla 0.40</FONT></A><BR>
+- <A HREF="/news/2000/01/27/948969337.html"><FONT COLOR="#000000">asp2php 0.73.6</FONT></A><BR>
+- <A HREF="/news/2000/01/27/948969217.html"><FONT COLOR="#000000">mod_ticket 1.0</FONT></A><BR>
+- <A HREF="/news/2000/01/27/948969078.html"><FONT COLOR="#000000">MegaHAL for Eggdrop .01</FONT></A><BR>
+- <A HREF="/news/2000/01/27/948968456.html"><FONT COLOR="#000000">Jetty 2.3.5</FONT></A><BR>
+- <A HREF="/news/2000/01/27/948968386.html"><FONT COLOR="#000000">xlpotdb 1.0</FONT></A><BR>
+- <A HREF="/news/2000/01/27/948968341.html"><FONT COLOR="#000000">Koala Complete MUD Server 0.1.1a</FONT></A><BR>
+- <A HREF="/news/2000/01/27/948968255.html"><FONT COLOR="#000000">mcountd 0.4</FONT></A><BR>
+- <A HREF="/news/2000/01/27/948967933.html"><FONT COLOR="#000000">cdbackup 0.5.0</FONT></A><BR>
+- <A HREF="/news/2000/01/27/948967908.html"><FONT COLOR="#000000">The Java SSH/Telnet Application/Applet 2.0 RC1</FONT></A><BR>
+&nbsp;</FONT></SMALL></TD></TR></TABLE></TD></TR></TABLE><P>
+<TABLE BORDER="0" CELLPADDING="1" CELLSPACING="0" BGCOLOR="#000000" WIDTH="97%"><TR><TD>
+<TABLE WIDTH="100%" BORDER="0" CELLSPACING="1" CELLPADDING="3">
+<TR><TD ALIGN="center" BGCOLOR="#EEEEEE"><B><FONT FACE="Lucida,Verdana,Helvetica,Arial"><FONT COLOR="#000000"><a href="http://slashdot.org"><font color="#000000">slashdot</font></a></FONT></FONT></B></TD></TR><TR><TD BGCOLOR="#FFFFFF"><SMALL><FONT FACE="Lucida,Verdana,Helvetica,Arial">
+- <A HREF="http://slashdot.org/article.pl?sid=00/01/29/1534255"><FONT COLOR="#000000">Petition Apple for Linux QuickTime</FONT></A><BR>
+- <A HREF="http://slashdot.org/article.pl?sid=00/01/29/1223249"><FONT COLOR="#000000">GNUstep 0.6.5 freeze</FONT></A><BR>
+- <A HREF="http://slashdot.org/article.pl?sid=00/01/28/2324203"><FONT COLOR="#000000">YETI@Home</FONT></A><BR>
+- <A HREF="http://slashdot.org/article.pl?sid=00/01/29/1024215"><FONT COLOR="#000000">Documents Unsealed in Microsoft/Caldera Case</FONT></A><BR>
+- <A HREF="http://slashdot.org/article.pl?sid=00/01/29/0837235"><FONT COLOR="#000000">Who Bought Linux.Net?</FONT></A><BR>
+- <A HREF="http://slashdot.org/article.pl?sid=00/01/24/1146250"><FONT COLOR="#000000">E-Mails from (Over?) The Edge</FONT></A><BR>
+- <A HREF="http://slashdot.org/article.pl?sid=00/01/29/0834223"><FONT COLOR="#000000">Linux Kernel 2.3.41</FONT></A><BR>
+- <A HREF="http://slashdot.org/article.pl?sid=00/01/28/2311232"><FONT COLOR="#000000">Congress Still Figuring Out E-Mail</FONT></A><BR>
+- <A HREF="http://slashdot.org/article.pl?sid=00/01/22/1946244"><FONT COLOR="#000000">Sci Fi Literature 101?</FONT></A><BR>
+- <A HREF="http://slashdot.org/article.pl?sid=00/01/28/2318246"><FONT COLOR="#000000">Could Distributed.Net Help the Mars Polar Lander?</FONT></A><BR>
+&nbsp;</FONT></SMALL></TD></TR></TABLE></TD></TR></TABLE><P>
+<TABLE BORDER="0" CELLPADDING="1" CELLSPACING="0" BGCOLOR="#000000" WIDTH="97%"><TR><TD>
+<TABLE WIDTH="100%" BORDER="0" CELLSPACING="1" CELLPADDING="3">
+<TR><TD ALIGN="center" BGCOLOR="#EEEEEE"><B><FONT FACE="Lucida,Verdana,Helvetica,Arial"><FONT COLOR="#000000"><a href="http://www.securityfocus.com"><font color="#000000">securityfocus</font></a></FONT></FONT></B></TD></TR><TR><TD BGCOLOR="#FFFFFF"><SMALL><FONT FACE="Lucida,Verdana,Helvetica,Arial">
+- <A HREF="http://www.securityfocus.com/level2/?go=news&id=http://www.zdnet.com/zdnn/stories/news/0,4586,2429334,00.html?chkpt=zdnntop"><FONT COLOR="#000000">Win2000 security hole a 'major threat'</FONT></A><BR>
+- <A HREF="http://www.securityfocus.com/level2/?go=news&id=http://www.computerworld.com/home/print.nsf/all/000128e45a"><FONT COLOR="#000000">Visa acknowledges cracker break-ins</FONT></A><BR>
+- <A HREF="http://www.securityfocus.com/level2/?go=news&id=http://www.zdnet.com/sr/stories/column/0,4712,2429536,00.html"><FONT COLOR="#000000">What's Wrong With Microsoft Security?</FONT></A><BR>
+- <A HREF="http://www.securityfocus.com/level2/?go=news&id=http://www.zdnet.com/pcweek/stories/news/0,4153,2429334,00.html"><FONT COLOR="#000000">Microsoft posts first Win2K security patch</FONT></A><BR>
+- <A HREF="http://www.securityfocus.com/level2/?go=tools&id=1018"><FONT COLOR="#000000">Libnids 1.12</FONT></A><BR>
+- <A HREF="http://www.securityfocus.com/level2/?go=news&id=http://www.theregister.co.uk/000127-000005.html"><FONT COLOR="#000000">New hack attack is greater threat than imagined</FONT></A><BR>
+- <A HREF="http://www.securityfocus.com/level2/?go=news&id=http://www.mercurycenter.com/svtech/news/indepth/docs/hacker012700.htm"><FONT COLOR="#000000">Student charged with hacking</FONT></A><BR>
+- <A HREF="http://www.securityfocus.com/level2/?go=library&id=63"><FONT COLOR="#000000">Building and Managing Virtual Private Networks (book)</FONT></A><BR>
+- <A HREF="http://www.securityfocus.com/level2/?go=library&id=111"><FONT COLOR="#000000">Threats, Vulnerabilities and Real-Worl Responses: The Foundations of the TruSecure Process</FONT></A><BR>
+- <A HREF="http://www.securityfocus.com/level2/?go=library&id=1701"><FONT COLOR="#000000">The Hundredth Window : Protecting Your Privacy and Security in the Age of the Internet (boo</FONT></A><BR>
+&nbsp;</FONT></SMALL></TD></TR></TABLE></TD></TR></TABLE><P>
+<TABLE BORDER="0" CELLPADDING="1" CELLSPACING="0" BGCOLOR="#000000" WIDTH="97%"><TR><TD>
+<TABLE WIDTH="100%" BORDER="0" CELLSPACING="1" CELLPADDING="3">
+<TR><TD ALIGN="center" BGCOLOR="#EEEEEE"><B><FONT FACE="Lucida,Verdana,Helvetica,Arial"><FONT COLOR="#000000"><a href="http://www.bebits.com"><font color="#000000">bebits</font></a></FONT></FONT></B></TD></TR><TR><TD BGCOLOR="#FFFFFF"><SMALL><FONT FACE="Lucida,Verdana,Helvetica,Arial">
+- <A HREF="http://www.bebits.com/app/706/"><FONT COLOR="#000000">Pe 3.0a3</FONT></A><BR>
+- <A HREF="http://www.bebits.com/app/757/"><FONT COLOR="#000000">Rarscript 1.5</FONT></A><BR>
+- <A HREF="http://www.bebits.com/app/736/"><FONT COLOR="#000000">CD Manager 0.66a beta</FONT></A><BR>
+- <A HREF="http://www.bebits.com/app/174/"><FONT COLOR="#000000">TraX 1.1</FONT></A><BR>
+- <A HREF="http://www.bebits.com/app/785/"><FONT COLOR="#000000">BeMath 1.2.2</FONT></A><BR>
+- <A HREF="http://www.bebits.com/app/784/"><FONT COLOR="#000000">simple blackjack 1</FONT></A><BR>
+- <A HREF="http://www.bebits.com/app/758/"><FONT COLOR="#000000">HtmlTree 0.5.3</FONT></A><BR>
+- <A HREF="http://www.bebits.com/app/783/"><FONT COLOR="#000000">Yacp 0.1</FONT></A><BR>
+- <A HREF="http://www.bebits.com/app/222/"><FONT COLOR="#000000">TicTacToe 1.5</FONT></A><BR>
+- <A HREF="http://www.bebits.com/app/706/"><FONT COLOR="#000000">Pe 3.0a2</FONT></A><BR>
+&nbsp;</FONT></SMALL></TD></TR></TABLE></TD></TR></TABLE><P>
+<TABLE BORDER="0" CELLPADDING="1" CELLSPACING="0" BGCOLOR="#000000" WIDTH="97%"><TR><TD>
+<TABLE WIDTH="100%" BORDER="0" CELLSPACING="1" CELLPADDING="3">
+<TR><TD ALIGN="center" BGCOLOR="#EEEEEE"><B><FONT FACE="Lucida,Verdana,Helvetica,Arial"><FONT COLOR="#000000"><a href="http://linuxtoday.com"><font color="#000000">linuxtoday</font></a></FONT></FONT></B></TD></TR><TR><TD BGCOLOR="#FFFFFF"><SMALL><FONT FACE="Lucida,Verdana,Helvetica,Arial">
+- <A HREF="http://linuxtoday.com/story.php3?sn=15878"><FONT COLOR="#000000">Linux Journal: KDE--The Next Generation</FONT></A><BR>
+- <A HREF="http://linuxtoday.com/story.php3?sn=15876"><FONT COLOR="#000000">Kernel Cousin gimp-devel #11 Is Out</FONT></A><BR>
+- <A HREF="http://linuxtoday.com/story.php3?sn=15875"><FONT COLOR="#000000">Infoworld: Corel Linux OS ideal for the desktop</FONT></A><BR>
+- <A HREF="http://linuxtoday.com/story.php3?sn=15874"><FONT COLOR="#000000">Technology Evaluation: IBM Jumps on the Linux Bandwagon with Both Feet, Sort Of</FONT></A><BR>
+- <A HREF="http://linuxtoday.com/story.php3?sn=15873"><FONT COLOR="#000000">Tobias Hövekamp: European Union acknowledges</FONT></A><BR>
+- <A HREF=""><FONT COLOR="#000000">&</FONT></A><BR>
+- <A HREF=""><FONT COLOR="#000000">#34;Open Source Software</FONT></A><BR>
+- <A HREF=""><FONT COLOR="#000000">&</FONT></A><BR>
+- <A HREF=""><FONT COLOR="#000000">#34;</FONT></A><BR>
+&nbsp;</FONT></SMALL></TD></TR></TABLE></TD></TR></TABLE><P>
+<TABLE BORDER="0" CELLPADDING="1" CELLSPACING="0" BGCOLOR="#000000" WIDTH="97%"><TR><TD>
+<TABLE WIDTH="100%" BORDER="0" CELLSPACING="1" CELLPADDING="3">
+<TR><TD ALIGN="center" BGCOLOR="#EEEEEE"><B><FONT FACE="Lucida,Verdana,Helvetica,Arial"><FONT COLOR="#000000"><a href="http://www.linuxtelephony.org"><font color="#000000">linuxtelephony</font></a></FONT></FONT></B></TD></TR><TR><TD BGCOLOR="#FFFFFF"><SMALL><FONT FACE="Lucida,Verdana,Helvetica,Arial">
+- <A HREF="http://www.linuxtelephony.org/article.cgi?i=208&r=0"><FONT COLOR="#000000">Traverse Technologies releases NETspider-U in US</FONT></A><BR>
+- <A HREF="http://www.linuxtelephony.org/article.cgi?i=207&r=0"><FONT COLOR="#000000">Quicknet releases new GPL'd Linux Drivers!</FONT></A><BR>
+- <A HREF="http://www.linuxtelephony.org/article.cgi?i=206&r=0"><FONT COLOR="#000000">Natural Microsystems Delivers Carrier-Class Linux</FONT></A><BR>
+- <A HREF="http://www.linuxtelephony.org/article.cgi?i=205&r=0"><FONT COLOR="#000000">Quicknet is hiring programmers of all kinds!</FONT></A><BR>
+- <A HREF="http://www.linuxtelephony.org/article.cgi?i=204&r=0"><FONT COLOR="#000000">Babylon MLPPP Software Released under GPL</FONT></A><BR>
+- <A HREF="http://www.linuxtelephony.org/article.cgi?i=202&r=0"><FONT COLOR="#000000">Linux Telephony Server Project?</FONT></A><BR>
+- <A HREF="http://www.linuxtelephony.org/article.cgi?i=203&r=0"><FONT COLOR="#000000">Vovida Networks to Hire Telephony Software Engineers</FONT></A><BR>
+- <A HREF="http://www.linuxtelephony.org/article.cgi?i=200&r=0"><FONT COLOR="#000000">SPIRO-Linux Introduces Web-Enabled Phone Administration</FONT></A><BR>
+- <A HREF="http://www.linuxtelephony.org/article.cgi?i=199&r=0"><FONT COLOR="#000000">LinuxTelephony sponsors area at LinuxFest 2000</FONT></A><BR>
+- <A HREF="http://www.linuxtelephony.org/article.cgi?i=198&r=0"><FONT COLOR="#000000">GSM-Mobile Switching Center (MSC) with Linux-PC</FONT></A><BR>
+&nbsp;</FONT></SMALL></TD></TR></TABLE></TD></TR></TABLE><P>
+<TABLE BORDER="0" CELLPADDING="1" CELLSPACING="0" BGCOLOR="#000000" WIDTH="97%"><TR><TD>
+<TABLE WIDTH="100%" BORDER="0" CELLSPACING="1" CELLPADDING="3">
+<TR><TD ALIGN="center" BGCOLOR="#EEEEEE"><B><FONT FACE="Lucida,Verdana,Helvetica,Arial"><FONT COLOR="#000000"><a href="http://www.32bitsonline.com"><font color="#000000">32bitsonline</font></a></FONT></FONT></B></TD></TR><TR><TD BGCOLOR="#FFFFFF"><SMALL><FONT FACE="Lucida,Verdana,Helvetica,Arial">
+- <A HREF="http://www.32bitsonline.com/article.php3?file=issues/200001/homeworld&page=1
+"><FONT COLOR="#000000">Game: Homeworld</FONT></A><BR>
+- <A HREF="http://www.32bitsonline.com/news.php3?news=news/200001/nb200001271a&page=1
+"><FONT COLOR="#000000">DVD Lawsuit Spreads Its Own 'Trade Secrets'</FONT></A><BR>
+- <A HREF="http://www.32bitsonline.com/news.php3?news=news/200001/nb200001272&page=1
+"><FONT COLOR="#000000">Register.com Adds 'One-step' Domain Registration</FONT></A><BR>
+- <A HREF="http://www.32bitsonline.com/article.php3?file=issues/200001/webevent&page=1
+"><FONT COLOR="#000000">WebEvent: Keeping you organized</FONT></A><BR>
+- <A HREF="http://www.32bitsonline.com/news.php3?news=news/200001/nb200001273a&page=1
+"><FONT COLOR="#000000">Y2K Officers Defend $100 Bil Investment</FONT></A><BR>
+- <A HREF="http://www.32bitsonline.com/article.php3?file=issues/200001/jan2000_john_berger&page=1
+"><FONT COLOR="#000000">DON'T BE FOOLED</FONT></A><BR>
+- <A HREF="http://www.32bitsonline.com/news.php3?news=news/200001/nb200001274&page=1
+"><FONT COLOR="#000000">Microsoft Scorns Think-Tank's Breakup Idea</FONT></A><BR>
+- <A HREF="http://www.32bitsonline.com/news.php3?news=news/200001/nb200001275a&page=1
+"><FONT COLOR="#000000">Yahoo Accused Of Stalking Internet Users</FONT></A><BR>
+- <A HREF="http://www.32bitsonline.com/news.php3?news=news/200001/nb200001276a&page=1
+"><FONT COLOR="#000000">eToys.com Settles Spat With Swiss Artist Group</FONT></A><BR>
+- <A HREF="http://www.32bitsonline.com/
+"><FONT COLOR="#000000">[more articles/news]</FONT></A><BR>
+&nbsp;</FONT></SMALL></TD></TR></TABLE></TD></TR></TABLE><P>
+<BR><BR></FONT>
+</TD></TR></TABLE>
+<TABLE WIDTH="100%" CELLPADDING="0" CELLSPACING="0" BORDER="0">
+<TR BGCOLOR="#000000"><TD><IMG SRC="image4" WIDTH="1" HEIGHT="2" ALT=""></TD></TR></TABLE>
+</CENTER>
+<TABLE CELLSPACING="0" CELLPADDING="2" WIDTH="100%" BORDER="0"><TR>
+<TD VALIGN="top" ALIGN="center"><FONT FACE="Lucida,Verdana,Helvetica,Arial"><SMALL>copyright © 1997-2000 <A HREF="http://andover.net">Andover.Net</A> -
+icons courtesy of <A HREF="mailto:tigert@gimp.org">tigert@gimp.org</A> -
+code revision <A HREF="http://freshmeat.net/ChangeLog">20000101</A> -
+our <A HREF="http://www.andover.net/privacy.html">privacy policy</A></SMALL></FONT></TD>
+</TR></TABLE>
+</BODY>
+</HTML>
+
+
diff --git a/jni/ruby/ext/tk/sample/tkextlib/tkHTML/ss.rb b/jni/ruby/ext/tk/sample/tkextlib/tkHTML/ss.rb
new file mode 100644
index 0000000..45d4d87
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkextlib/tkHTML/ss.rb
@@ -0,0 +1,436 @@
+#!/usr/bin/env ruby
+#
+# This script implements the "ss" application. "ss" implements
+# a presentation slide-show based on HTML slides.
+#
+require 'tk'
+require 'tkextlib/tkHTML'
+
+file = ARGV[0]
+
+class TkHTML_File_Viewer
+ include TkComm
+
+# These are images to use with the actual image specified in a
+# "<img>" markup can't be found.
+#
+@@biggray = TkPhotoImage.new(:data=><<'EOD')
+ R0lGODdhPAA+APAAALi4uAAAACwAAAAAPAA+AAACQISPqcvtD6OctNqLs968+w+G4kiW5omm
+ 6sq27gvH8kzX9o3n+s73/g8MCofEovGITCqXzKbzCY1Kp9Sq9YrNFgsAO///
+EOD
+
+@@smgray = TkPhotoImage.new(:data=><<'EOD')
+ R0lGODdhOAAYAPAAALi4uAAAACwAAAAAOAAYAAACI4SPqcvtD6OctNqLs968+w+G4kiW5omm
+ 6sq27gvH8kzX9m0VADv/
+EOD
+
+ def initialize(file = nil)
+ @root = TkRoot.new(:title=>'HTML File Viewer', :iconname=>'HV')
+ @fswin = nil
+
+ @html = nil
+ @html_fs = nil
+
+ @hotkey = {}
+
+ @applet_arg = TkVarAccess.new_hash('AppletArg')
+
+ @images = {}
+ @old_imgs = {}
+ @big_imgs = {}
+
+ @last_dir = Dir.pwd
+
+ @last_file = ''
+
+ @key_block = false
+
+ Tk::HTML_Widget::ClippingWindow.bind('1',
+ proc{|w, ksym| key_press(w, ksym)},
+ '%W Down')
+ Tk::HTML_Widget::ClippingWindow.bind('3',
+ proc{|w, ksym| key_press(w, ksym)},
+ '%W Up')
+ Tk::HTML_Widget::ClippingWindow.bind('2',
+ proc{|w, ksym| key_press(w, ksym)},
+ '%W Down')
+
+ Tk::HTML_Widget::ClippingWindow.bind('KeyPress',
+ proc{|w, ksym| key_press(w, ksym)},
+ '%W %K')
+
+ ############################################
+ #
+ # Build the half-size view of the page
+ #
+ menu_spec = [
+ [['File', 0],
+ ['Open', proc{sel_load()}, 0],
+ ['Full Screen', proc{fullscreen()}, 0],
+ ['Refresh', proc{refresh()}, 0],
+ '---',
+ ['Exit', proc{exit}, 1]]
+ ]
+
+ mbar = @root.add_menubar(menu_spec)
+
+ @html = Tk::HTML_Widget.new(:width=>512, :height=>384,
+ :padx=>5, :pady=>9,
+ :formcommand=>proc{|*args| form_cmd(*args)},
+ :imagecommand=>proc{|*args|
+ image_cmd(1, *args)
+ },
+ :scriptcommand=>proc{|*args|
+ script_cmd(*args)
+ },
+ :appletcommand=>proc{|*args|
+ applet_cmd(*args)
+ },
+ :hyperlinkcommand=>proc{|*args|
+ hyper_cmd(*args)
+ },
+ :fontcommand=>proc{|*args|
+ pick_font(*args)
+ },
+ :appletcommand=>proc{|*args|
+ run_applet('small', *args)
+ },
+ :bg=>'white', :tablerelief=>:raised)
+
+ @html.token_handler('meta', proc{|*args| meta(@html, *args)})
+
+ vscr = @html.yscrollbar(TkScrollbar.new)
+ hscr = @html.xscrollbar(TkScrollbar.new)
+
+ Tk.grid(@html, vscr, :sticky=>:news)
+ Tk.grid(hscr, :sticky=>:ew)
+ @root.grid_columnconfigure(0, :weight=>1)
+ @root.grid_columnconfigure(1, :weight=>0)
+ @root.grid_rowconfigure(0, :weight=>1)
+ @root.grid_rowconfigure(1, :weight=>0)
+
+ ############################################
+
+ @html.clipwin.focus
+
+ # If an arguent was specified, read it into the HTML widget.
+ #
+ Tk.update
+ if file && file != ""
+ load_file(file)
+ end
+ end
+
+ #
+ # A font chooser routine.
+ #
+ # html[:fontcommand] = pick_font
+ def pick_font(size, attrs)
+ # puts "FontCmd: #{size} #{attrs}"
+ [ ((attrs =~ /fixed/)? 'courier': 'charter'),
+ (12 * (1.2**(size.to_f - 4.0))).to_i,
+ ((attrs =~ /italic/)? 'italic': 'roman'),
+ ((attrs =~ /bold/)? 'bold': 'normal') ].join(' ')
+ end
+
+ # This routine is called to pick fonts for the fullscreen view.
+ #
+ def pick_font_fs(size, attrs)
+ baseFontSize = 24
+
+ # puts "FontCmd: #{size} #{attrs}"
+ [ ((attrs =~ /fixed/)? 'courier': 'charter'),
+ (baseFontSize * (1.2**(size.to_f - 4.0))).to_i,
+ ((attrs =~ /italic/)? 'italic': 'roman'),
+ ((attrs =~ /bold/)? 'bold': 'normal') ].join(' ')
+ end
+
+ #
+ #
+ def hyper_cmd(*args)
+ puts "HyperlinkCommand: #{args.inspect}"
+ end
+
+ # This routine is called to run an applet
+ #
+ def run_applet(size, w, arglist)
+ applet_arg.value = Hash[*simplelist(arglist)]
+
+ return unless @applet_arg.key?('src')
+
+ src = @html.remove(@applet_arg['src'])
+
+ @applet_arg['window'] = w
+ @applet_arg['fontsize'] = size
+
+ begin
+ Tk.load_tclscript(src)
+ rescue => e
+ puts "Applet error: #{e.message}"
+ end
+ end
+
+ #
+ #
+ def form_cmd(n, cmd, *args)
+ # p [n, cmd, *args]
+ end
+
+ #
+ #
+ def move_big_image(b)
+ return unless @big_imgs.key?(b)
+ b.copy(@big_imgs[b])
+ @big_imgs[b].delete
+ @big_imgs.delete(b)
+ end
+
+ def image_cmd(hs, *args)
+ fn = args[0]
+
+ if @old_imgs.key?(fn)
+ return (@images[fn] = @old_imgs.delete(fn))
+ end
+
+ begin
+ img = TkPhotoImage.new(:file=>fn)
+ rescue
+ return ((hs)? @@smallgray: @@biggray)
+ end
+
+ if hs
+ img2 = TkPhotoImage.new
+ img2.copy(img, :subsample=>[2,2])
+ img.delete
+ img = img2
+ end
+
+ if img.width * img.height > 20000
+ b = TkPhotoImage.new(:width=>img.width, :height=>img.height)
+ @big_imgs[b] = img
+ img = b
+ Tk.after_idle(proc{ move_big_image(b) })
+ end
+
+ @images[fn] = img
+
+ img
+ end
+
+ #
+ # This routine is called for every <SCRIPT> markup
+ #
+ def script_cmd(*args)
+ # puts "ScriptCmd: #{args.inspect}"
+ end
+
+ # This routine is called for every <APPLET> markup
+ #
+ def applet_cmd(w, arglist)
+ # puts "AppletCmd: w=#{w} arglist=#{arglist}"
+ #TkLabel.new(w, :text=>"The Applet #{w}", :bd=>2, :relief=>raised)
+ end
+
+ # This binding fires when there is a click on a hyperlink
+ #
+ def href_binding(w, x, y)
+ lst = w.href(x, y)
+ unless lst.empty?
+ process_url(lst)
+ end
+ end
+
+ #
+ #
+ def sel_load
+ filetypes = [
+ ['Html Files', ['.html', '.htm']],
+ ['All Files', '*']
+ ]
+
+ f = Tk.getOpenFile(:initialdir=>@last_dir, :filetypes=>filetypes)
+ if f != ''
+ load_file(f)
+ @last_dir = File.dirname(f)
+ end
+ end
+
+ # Clear the screen.
+ #
+ def clear_screen
+ if @html_fs && @html_fs.exist?
+ w = @html_fs
+ else
+ w = @html
+ end
+ w.clear
+ @old_imgs.clear
+ @big_imgs.clear
+ @hotkey.clear
+ @images.each{|k, v| @old_imgs[k] = v }
+ @images.clear
+ end
+
+ # Read a file
+ #
+ def read_file(name)
+ begin
+ fp = open(name, 'r')
+ ret = fp.read(File.size(name))
+ rescue
+ ret = nil
+ fp = nil
+ Tk.messageBox(:icon=>'error', :message=>"fail to open '#{name}'",
+ :type=>:ok)
+ ensure
+ fp.close if fp
+ end
+ ret
+ end
+
+ # Process the given URL
+ #
+ def process_url(url)
+ case url[0]
+ when /^file:/
+ load_file(url[0][5..-1])
+ when /^exec:/
+ Tk.ip_eval(url[0][5..-1].tr('\\', ' '))
+ else
+ load_file(url[0])
+ end
+ end
+
+ # Load a file into the HTML widget
+ #
+ def load_file(name)
+ return unless (doc = read_file(name))
+ clear_screen()
+ @last_file = name
+ if @html_fs && @html_fs.exist?
+ w = @html_fs
+ else
+ w = @html
+ end
+ w.configure(:base=>name)
+ w.parse(doc)
+ w.configure(:cursor=>'top_left_arrow')
+ @old_imgs.clear
+ end
+
+ # Refresh the current file.
+ #
+ def refresh(*args)
+ load_file(@last_file) if @last_file
+ end
+
+ # This routine is called whenever a "<meta>" markup is seen.
+ #
+ def meta(w, tag, alist)
+ v = Hash[*simplelist(alist)]
+
+ if v.key?('key') && v.key?('href')
+ @hotkey[v['key']] = w.resolve(v['href'])
+ end
+
+ if v.key?('next')
+ @hotkey['Down'] =v['next']
+ end
+
+ if v.key?('prev')
+ @hotkey['Up'] =v['prev']
+ end
+
+ if v.key?('other')
+ @hotkey['o'] =v['other']
+ end
+ end
+
+ # Go from full-screen mode back to window mode.
+ #
+ def fullscreen_off
+ @fswin.destroy
+ @root.deiconify
+ Tk.update
+ @root.raise
+ @html.clipwin.focus
+ clear_screen()
+ @old_imgs.clear
+ refresh()
+ end
+
+ # Go from window mode to full-screen mode.
+ #
+ def fullscreen
+ if @fswin && @fswin.exist?
+ @fswin.deiconify
+ Tk.update
+ @fswin.raise
+ return
+ end
+
+ width = @root.winfo_screenwidth
+ height = @root.winfo_screenheight
+ @fswin = TkToplevel.new(:overrideredirect=>true,
+ :geometry=>"#{width}x#{height}+0+0")
+
+ @html_fs = Tk::HTML_Widget.new(@fswin, :padx=>5, :pady=>9,
+ :formcommand=>proc{|*args|
+ form_cmd(*args)
+ },
+ :imagecommand=>proc{|*args|
+ image_cmd(0, *args)
+ },
+ :scriptcommand=>proc{|*args|
+ script_cmd(*args)
+ },
+ :appletcommand=>proc{|*args|
+ applet_cmd(*args)
+ },
+ :hyperlinkcommand=>proc{|*args|
+ hyper_cmd(*args)
+ },
+ :appletcommand=>proc{|*args|
+ run_applet('big', *args)
+ },
+ :fontcommand=>proc{|*args|
+ pick_font_fs(*args)
+ },
+ :bg=>'white', :tablerelief=>:raised,
+ :cursor=>:tcross) {
+ pack(:fill=>:both, :expand=>true)
+ token_handler('meta', proc{|*args| meta(self, *args)})
+ }
+
+ clear_screen()
+ @old_imgs.clear
+ refresh()
+ Tk.update
+ @html_fs.clipwin.focus
+ end
+
+ #
+ #
+ def key_press(w, keysym)
+ return if @key_block
+ @key_block = true
+ Tk.after(250, proc{@key_block = false})
+
+ if @hotkey.key?(keysym)
+ process_url(@hotkey[keysym])
+ end
+ case keysym
+ when 'Escape'
+ if @fswin && @fswin.exist?
+ fullscreen_off()
+ else
+ fullscreen()
+ end
+ end
+ end
+end
+############################################
+
+TkHTML_File_Viewer.new(file)
+
+Tk.mainloop
diff --git a/jni/ruby/ext/tk/sample/tkextlib/tkimg/demo.rb b/jni/ruby/ext/tk/sample/tkextlib/tkimg/demo.rb
new file mode 100644
index 0000000..8016c26
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkextlib/tkimg/demo.rb
@@ -0,0 +1,1478 @@
+#!/usr/bin/env ruby
+#
+# Tk::Img demo
+#
+# -- This script is based on demo.tcl of Tcl/Tk's 'Img' extension.
+# Image data in this script is those of demo.tcl.
+# Please read 'license_terms_of_Img_extension' file.
+#
+require 'tk'
+require 'tkextlib/tkimg'
+
+#
+# Make the Image format available.
+#
+class TkImg_demo
+ def initialize
+ img_version = Tk::Img.package_version
+
+ @typeFrame = Hash.new
+ @imgPriv = Hash.new
+
+ root = TkRoot.new(:title=>'Tests for available image formats')
+
+ root.winfo_children.each{|w| w.destroy}
+ TkImage.names{|img| img.delete}
+
+ f = TkFrame.new
+ TkButton.new(f, :text=>'Dismiss', :command=>proc{exit}).pack(:side=>:left)
+ f.pack(:side=>:top, :expand=>:y, :fill=>:both)
+
+ TkMessage.new(:aspect=>900, :text=>format('This page shows the available image formats of the Img extension (Img version %s, using Tcl/Tk %s)', img_version, Tk::TK_PATCHLEVEL)).pack(:side=>:top, :expand=>:y, :fill=>:both)
+ end
+
+##############################
+
+ def update_animated_gif(w, method, num)
+ return unless @imgPriv[w]
+
+ if @imgPriv[w][:args]
+ im = TkPhotoImage.new
+ im.copy(@imgPriv[w][num])
+ num += 1
+ begin
+ im.configure(@imgPriv[w][:args].merge(:format=>[:gif, {:index=>num}]))
+ im.configure(:data=>'', :file=>'') #free storage
+ @imgPriv[w][num] = im
+ rescue
+ @imgPriv[w].delete(:args)
+ if num > 1
+ num = 0
+ im = @imgPriv[w][num]
+ else
+ # this is not an animated GIF; just stop
+ @imgPriv[w].delete(0)
+ return
+ end
+ end
+ else
+ num += 1
+ num = 0 unless @imgPriv[w][num]
+ im = @imgPriv[w][num]
+ end
+ begin
+ w.__send__(method, im)
+ Tk.update_idletasks
+ Tk.after(20, proc{update_animated_gif(w, method, num)})
+ rescue
+ @imgPriv[w].delete(:args)
+ @imgPriv[w].each{|im|
+ @im.delete
+ @imgPriv.delete(im)
+ }
+ end
+ end
+
+ def show_animated_gif(keys)
+ w = TkLabel.new
+ begin
+ im = TkPhotoImage.new(keys.merge(:format=>[:gif, {:index=>0}]))
+ im.configure(:data=>'', :file=>'', :format=>'') #free storage
+ w.image(im)
+ @imgPriv[w] ||= Hash.new
+ @imgPriv[w][0] = im
+ @imgPriv[w][:args] = keys
+ Tk.update_idletasks
+ Tk.after(20, proc{update_animated_gif(w, :image, 0)})
+ rescue => e
+ w.configure(:text=>"error displaying animated gif:\n#{e.message}",
+ :image=>'', :relief=>:ridge)
+ end
+ w.pack
+ end
+
+ def show_image(fmt, type, data)
+ fmt = fmt.to_s.capitalize
+ unless @typeFrame[fmt]
+ @typeFrame[fmt] = TkFrame.new.pack(:side=>:top, :expand=>true, :fill=>:x)
+ TkLabel.new(@typeFrame[fmt], :text=>"#{fmt} : ").pack(:side=>:left)
+ end
+ begin
+ f = TkFrame.new(@typeFrame[fmt],
+ :borderwidth=>2, :relief=>:ridge).pack(:side=>:left)
+ im = TkPhotoImage.new(:data=>data)
+ im['data'] = ''
+ TkLabel.new(f, :image=>im).pack
+ TkLabel.new(f, :text=>type, :borderwidth=>0, :pady=>0, :padx=>2,
+ :font=>'Helvetica 8').pack
+ rescue => e
+ TkMessage.new(f, :text=>"error displaying #{type} image: #{e.message}",
+ :aspect=>250).pack
+ end
+ Tk.update
+ end
+
+end
+
+##############
+
+demo = TkImg_demo.new
+
+##############
+
+demo.show_animated_gif(:data=><<'ENDofIMG')
+R0lGODlhYgIEAIIAAQAAACQAJEkASW0AbZIAkrYAttsA2/8A/yH/C05FVFNDQVBFMi4wAwEA
+AAAh+QQABgD/ACwAAAAAYgIEAAIDuUg63CMwwiCCvQAHwLv/YCiOZGmeaKqubOu+pZXNV03d
+kuAwysLoucjNlpFtYMikcslsOp+ijbRow1EiD12jtyA4INnJZGg8HmfQtHrNbrPP6KqlEgRq
+B17vzi6ukKVmHXBuhIWGh4RTcXJ0QQ8OeVx6XzlWVTRoiJqbnJ0tGmUXdDhgd1uTP2FCo5dT
+g56wsbKaoYBzVlimPJJ7QX9EirPCw8RttTZ1ul29Er81mMXR0tMvxzXJO1wAACH5BAAGAP8A
+LAAAAABiAgQAAgPdCLrc/jDKSau9OOuNAwjgB46kEJjnKazr0A5wTBDDbBc4buz74f/AoHBI
+LBqPSCGPh7M5abQYTOBysVYprAlFCo0+YI9CzCmbz+i0es1uu9/wOFrsqYtE3S73yq9SpTBP
+BDk5PEmHiImKRQYHTISDNjWTMX9UfFuZIFwkY3RhcqGio6SlpqeoqRt2dXmuWyqZV1Z/UjM1
+ToQFS46Lvr/AQUu6BYK4gJe0V7Eprl+sXqrS09TV1tfYbKxhziqxmFOAgYKDOrs9wenqSY07
+uznklFKXmCzN3aB22fv81AAAIfkEAAYA/wAspgAAABgBBAACA+YIEQrNS61Jg1hX6C2GHiBI
+DERpFkShFkZrHHAsz3Rt06/Lrqk5jqFQ58PheI5B0s+HWrFch9dtSp26dDyULwnqeIoay+Qi
+rkAcZ4YDrVY/IOaxGGz0IkPLknN3rfr/MToGTilaJSRcR3RgikF5JyuDfYCUVFeDKj0mSkle
+Q4sYcXFvaA1rDxIScKIZYUVfiUA+PU6Tlbc4US07PJs/nYqLQ4kieZkqki24yzJXe5qziEHD
+dHNloqqpbqfcbquiGK2MH0mzkJG2zLfOhObSQsHC1OVKTLVQUurrWL1biZ9grIFLs2YbNwAh
++QQABgD/ACyHAAAAVwEEAAID/ggQy94uyCloFTgPsYf/AyGOYmGaRnoYR+u+cCzPcZqeJyl6
+xMdhm4zwUgkUJ8iFkqFgKptQCQRJMRqJwqAPtCMVCDhDwcaimc9mslhs0vXeoJ9caL1Q748n
+tMl89PFURURXQx4cH11eYChjKmiPkC5kOGCVIyCYWkN2VoB8fXtOS34RgJybGkCZbosnZJGw
+aCw3bF9tXSFxhqhXnb5JSUt6CsKlxneDqHIdqyEjOI0qZbHUMGq1bs6Yh3NDdb93U1Ki41Hi
+poSEqYZcuYphr9XykjbQrLnbHbwYEkd4xQ2GERvoZxQ6LIUOrWLlKtq8h5Ps6ci0SxknQOVE
+Ddy4HvGPQVMIC1Hk4QZavIfUZq3J8YUEPl0WL3qaIIwjMQAh+QQABgD/ACxlAAAAmwEEAAID
+/ggRCr1qSSlWDVXorYfwQxgSxECSBVGsheEaB3zMdG3feF7DbsumJ5JJJPpwjhnLZMloPp4M
+h3RKrVqv2KxW2nRGmBQlBnP0dD7EYfDne8l08DjcbfgFhaW0cX8ciy9LD05RUREOhQ2GYEoa
+ZGQbIGlDJmsqPy9ymZo0PD11Kyp3anogfX5igamGh1utrq+uhFBQYBm2j5CSIncnLHWYm8Fx
+bj52QZOSSBeNp2BfEIVeU4PUi0mOSJFoaXcpvnTC4TnExiejRdrK2IsSgrKIsPHyr4OJ7GHL
+thxmkSN4vZdauIghriCnF2yAmBOCzoiZPkkAOav3JEs0d+z0ZdPFMgvFJWAGCxL7pPBYHiJ8
+TElcNGuey5cwW97Dp6yDpBK82LgJaXAki47IGqq7xm4WPCoAACH5BAAGAP8ALEYAAADZAQQA
+AgP+GKC7yiHKGYSo1Wo9xPgfMYhEWRZoYaiGcbxwLM90Tbf4ihKFSYqgjnBDjFwuGMoD0Fgy
+n9CodEqtWq/YrHa7hTgaTSXySCZ6PMFQyJdC5Vy2uFz+VqV8pFH6czYfM0pKYF4MYE0OD4ET
+Y4BEfHt6eDt2OAdwc5iZLzhtO3iQIBYdGhgWpYoTYUxOXK2ur7CxrV5fqBR/GWZDaT9sPG4s
+l5rDNi4tdpOfQGlno6SmSEkUiISDT4mJtYpkubq7Qb0mbSuVwsTnmzltPJ96oY9+uNGKiLWy
+9/j5+l3YqrZl3UT12YPnxLg36BLCULdOmbt38bjNC3TISSEqSyRQE1M8yo8QXiMk/XJTSaFC
+hg19gIp4auI0Vhf3yZxJUx8EbP/K6EIDLqSvgy1MJlSno0cPlcsg+gEkTZBGVlMAACH5BAAG
+AP8ALCYAAAAXAgQAAgP+CAHaHQtKKGioV+itRx/gQIBESRTnWRRGexhHLM90bd9127Jrao7A
+kMfDKVommMnisYwwHM+odEqtWq/YrHbL7Xq/YIaTCVEoj5YiZ8gmiX6l1UrnguHu+DvdIEeh
+4EJsAkRqGBoXZxJmEU2NYo9mYoyJFRwZG22Bbz99LHR5oKEydDxyPiUimiCDrIeViK9ni4wP
+kGG3uLm6u7y9tmO1iRKuGZeYmUDJJn18OqLPoKQ9fyZuga2Er4fCioqRTVFlZWTcxJVFQx9u
+yioqPM7Q8TbSptRBI0KthRvF3OLitnwJHEiwoMErk5jMOmMIVqFMIdjFmeMJhh15GF/o6HRK
+qhq+VayyWYLlr5GTcVjAlTS0DyIJOBPlfMqI0WKzeoA+htCnph+3SFAOCh1KtGivk/+EnWs5
+KJDEFMzg0ZS3BydMVSL5aStJ6woAIfkEAAYA/wAsBwAAAFUCBAACA/4ICqEd8MUJRQ0i65GH
+F55HEMM4FkShFgZrHHAsz3Rt10aer6s5lqEQqKPRYI6WI+XBYDYYi+diSq1ar9isdsvter/g
+sHhMLkebUEhziUkai8ROMOQ78Vy6m37Pf+1aPXUlJEJCcG9ubGpOaWlPUowSSxYZbW1FHCBz
+g3V3eC98oaIwfi07KCkmQIQfH4eUsBdLa4tnUma4ubq7vL2+v1mPUGiKE7GVh4V0Pz53pjmj
+0X06LD2oqqxBG4dKiRS0TrdTkcURlBWwmJqaIqsmqDw6oNL0NPKeddnaHJlwl0qKGgkTB6yg
+wYMIEyq8Qm5RsXOW4PCbGIREp3jy5tXbWE4KUCBsm4aI5HYuSUBJDoZZgQTu4aVkm5ZdVCFv
+o01SB/589AFkzshXAE8KXEi0qNGjSMlEajnpJcxN+exUy3OTIzUeUXvue4WsXC0mWAAAIfkE
+AAYA/wAsAAAAAGICBAACA/4YotIuA8JBKxkk60KKN6BxiEdpnmiqrmhoeF6naVXdRI/DBAq/
+8MAAQDgsEgHIpHLJbDqf0Kh0Sq1ar9isdsvterdEIW8IJAfPv0XOEalZZjJYwcWq2++i0Fwu
+m2HcbWs5PWoMgm01F4obci90d5CRJS5yHBw0GX8UEpw6D4RnY0FGYUVfp6ipqqusra6vXKVk
+pqFBhYM5gYkYcJWOIZLBdnovMH2YbjcSOLc+hA2GyoB/cBmWe8DC2ivExpdw05vMn4W1o2Wi
+sOrr7O3u7/BVoujz5mrQhxNuF7zWHTCPtgmcNALEHmPg+NnohOvHs3yILPRjBBAYiYHaXBRD
+6CtnmiBP5mqZGhmvpMmTKFOqbBJGTEgg+D5GlFjt2pyAGIVR4lNNU7JxnhwCACH5BAAGAP8A
+LAAAAABiAgQAAgPtWLZ7/jDKSaU5rOhCuu9DKA5CKJRnGgjB6rJt3AIxDdzBbet87//AoHBI
+LBqPyKRyyWw6n9CodOrL8ay5rFa2YsG8qRNJXAoRRB8CZ6NgYCrweJxhUNjd8rz+QWevPwMg
+ImUoYWEtX1wzNFg2jVSQkZKTlJWWl5iZTo+OW4qIMYZhJKQjgWlqbHQXe61wFwt2bQ2utROw
+sX6oZqYoY4YvLp81WY47msjJysvMzc7PxjPEw2DVKWOmvKceaxurtuB8GLl1Dazhtn0bqGdn
+vb/AXsPE0dD29/j5+vvLVtHzJ7qIKpSNXSpVtNCly1AAACH5BAAGAP8ALAAAAABiAgQAAgPV
+eLq8diYWUwqxJJOx9/iDEIpCaZpBmQZs6wYAC8QwPd94ru987//AoHBILBqPyKRyyWw6n9Ao
+Elaj0l4tlYC1PZVCoHBnnLFUJpF0Y81uOyCTc0Wj4YRBJO9qu8LKqjaAUoOEhYaHiImKi4yN
+TzUxN1STflxZXiZgInccdGZyaQ9uo24PoXFmdHacJCOYKXx8lZRXM5COuLm6u7y9vr+KtJSz
+e1perpwZnRqfaGqk0GunZxd0yh54mq8qxFaRwODh4uPk5eaEVVbdxpibm3fWZXLOotEAADs=
+ENDofIMG
+
+demo.show_image('bmp', '1-bit', <<'ENDofIMG')
+Qk3OAQAAAAAAAD4AAAAoAAAAIgAAADIAAAABAAEAAAAAAJABAABtCwAAbQsAAAIAAAACAAAA
+MzPMAMwzMwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+AAAAAAAAAAAAAAZmTKAAAAAABIRIwAAAAAAEZAigAAAAAAQECIAAAAAAAAAAgAAAAAAAAEAA
+AAAAAAABQAAAAAAAAAPAAAAAAAAAB+AAAAAAAAAC4AAAAAAAAALgAAAAAAAAAsAAAAAAAAAC
+wAAAAAAAAALgAAAAAAAABuAAAAAAAAAG4AAAAAAAAAbgAAAAAAAABuAAAAAAAAAG4AAAAAAA
+AAfgAAAAAAAAA+AAAAAAAAADcAAAAAAAAAPwAAAAAAAAA/AAAAAAAAAD+AAAAAAAAAP4AAAA
+AAAAA/gAAAAAAAAD4AAAAAAAAAHgAAAAAAAAAfAAAAAAAAAA+AAAAAAAAAB8AAAAAAAAADgA
+AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+ENDofIMG
+
+demo.show_image('bmp', '4-bit', <<'ENDofIMG')
+Qk1aBAAAAAAAAHIAAAAoAAAAIgAAADIAAAABAAQAAAAAAOgDAABtCwAAbQsAAA8AAAAPAAAA
+////AAD//wDMzP8AmZn/AGaZ/wAzM8wAmZnMAGaZzAAzZswAzMyZAJmZmQDMZjMAZjNmADMz
+ZgBmMzMABWMgAAAAAAAAAAAAAAAAAAAAAAAFVVVVVVVVVVVVVVVVVVVVUAAAAAVVVVVVVVVV
+VVVVVVVVVVVQAAAABVVVVVVVVVVVVVVVVVVVVVAAAAAFVVVVVVVVVVVVVVVVVVVVUAAAAAVV
+VVVVVVVVVVVVVVVVVVWAAAAABVVVVVVVVVVVVVVVVVVVVVAAAAAFVVBVU3VSVVNVB1UFBVVV
+UAAAAAVVUFU1VVNVVVUFVQBVVVVgAAAABVVQVVUFU1VVVQVVBVVVVTAAAAAIVVBVVVVTVXVV
+BVUFVVVVMAAAAAVVVVVVVVFVFVVVVQVVVVUgAAAABVVVVVVVVVUFVVVVVVVVVSAAAAAHVVVV
+VVVVW5tVVVVVVVVVAAAAAAZVVVVVVVW8u2VVVVVVVVUAAAAAA1VVVVVVW7W7tVVVVVVVVQAA
+AAADVVVVVVWCtbuzVVVVVVVVAAAAAANVVVVVVVW1vrJVVVVVVVUAAAAAAlVVVVVVWLW7UFVV
+VVVVVQAAAAACVVVVVVVatbtVVVVVVVVVAAAAAABVVVVVVVq3u8NVVVVVVVUAAAAAAFVVVVVV
+XrS74VVVVVVVVQAAAAAAVVVVVVWLtbuyVVVVVVVVAAAAAABVVVVVVUu1u7BVVVVVVVUAAAAA
+AFVVVVVVO7W7sFVVVVVVVQAAAAAAVVVVVVUbtbu6VVVVVVVVAAAAAABVVVVVVSu9u1VVVVVV
+VVUAAAAAAFVVVVVVJb67tVVVVVVVVQAAAAAAVVVVVVVVu6u7VVVVVVVVAAAAAABVVVVVVVW7
+u7slVVVVVVUAAAAAAFVVVVVVVbu7u1VVVVVVVQAAAAACVVVVVVVVu7u7wlRVVVVVAAAAAAJV
+VVVVVVW7u7uwV1VVVVUAAAAAA1VVVVVVVbu7u7BVhVVVVSAAAAADVVVVVYVVu7vFAFUVVVVV
+MAAAAAZVVVVVhVUbu7VVVRVXVVVgAAAAB1VVVVVVVVu7u1VVFVFVVVAAAAAFVVVVVVhVVLu7
+xVVVVVVVgAAAAAVVVVVVUVVVK7u1VVVVVVVQAAAACFVVVVhRVVVQq7VVVVVVVVAAAAAFVVVV
+VFV1VVUgBVVVVVVVUAAAAAVVVVVUVRVVVVVVVVVVVVVQAAAABVVVVViFUVVVVVVVVVVVVVAA
+AAAFVVVVVRVUFVVVVVVVVVVVUAAAAAVVVVVVVVVVVVVVVVVVVVVQAAAABVVVVVVVVVVVVVVV
+VVVVVVIAAAAFVVVVVVVVVVVVVVVVVVVVUQAAAAVVVVVVVVVVVVVVVTdVVVVWAAAAAAAhNnWF
+VVVVVVcAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA==}
+ENDofIMG
+
+if false
+demo.show_image('bmp', '4-bit-RLE', <<'ENDofIMG')
+Qk1sAwAAAAAAAHYAAAAoAAAAIgAAADIAAAABAAQAAgAAAPYCAAAAAAAAAAAAABAAAAAQAAAA
+////AMzM/wAA//8AmZn/AJmZzABmmcwAMzPMADNmzABmmf8AmZmZAMxmMwBmM2YAZjMzADMz
+ZgDMzJkAAAAAAAAGBkMQABwAAAACBh5mAmAAAAIGHmYCYAAAAgYeZgJgAAACBh5mAmAAAAIG
+HmYCcAAAAgYeZgJgAAAAIgZmYGZjVmFmY2YFZgYGZmZgAAAAACIGZmBmNmZjZmZmBmYAZmZm
+QAAAAAAiBmZgZmYGY2ZmZgZmBmZmZjAAAAAAIgdmYGZmZmNmVmYGZgZmZmYwAAAAAgYKZgAW
+YmYmZmZmBmZmZhAAAAACBg5mAgYOZgIQAAACBQxmAARq6g5mAgAAAAIEDGYABquqRgAMZgIA
+AAACAwpmAAhqpqqmDGYCAAAAAgMKZgAIcaaqowxmAgAAAAIDDGYABqasoQAMZgIAAAACAQpm
+AAhnpqpgDGYCAAAAAgEKZgAGaaaqAA5mAgAAAAIACmYACGmlqrMMZgIAAAACAApmAAhsqKrC
+DGYCAAAAAgAKZgAIeqaqoQxmAgAAAAIACmYACIqmqqAMZgIAAAACAApmAAg6pqqgDGYCAAAA
+AgAKZgAIKqaqqQxmAgAAAAIACmYABhqtqgAOZgIAAAACAApmAAgWrKqmDGYCAAAAAgAMZgAG
+qpqqAAxmAgAAAAIADGYACKqqqhYKZgIAAAACAAxmAAaqqqoADGYCAAAAAgEMZgAKqqqqsWgA
+CGYCAAAAAgEMZgAKqqqqoGUACGYCAAAAAgMMZgAUqqqqoGZ2ZmZmEAAAAgMIZgAYdmaqqrYA
+ZiZmZmYwAAACBAhmABh2ZiqqpmZmJmVmZkAAAAIFDGYAFGqqqmZmJmJmZmAAAAIGCGYADGdm
+aKqqtgpmAnAAAAIGCGYADGJmZhqqpgpmAmAAAAAWB2ZmZmdiZmZgmqYACmYCYAAAABYGZmZm
+aGZWZmYQBgAKZgJgAAAADgZmZmZoZiYAEmYCYAAAAA4GZmZmZ3ZiABJmAmAAAAIGCGYABiZo
+JgAQZgJgAAACBh5mAmAAAAIGHmYCYQAAAgYeZgJiAAACBhZmAAo1ZmZmZAAAAAAMAAASNFZ2
+CGYCZQwAAAAiAAAB
+ENDofIMG
+end
+
+demo.show_image('bmp', '8-bit', <<'ENDofIMG')
+Qk0CCAAAAAAAAPoAAAAoAAAAIgAAADIAAAABAAgAAAAAAAgHAABtCwAAbQsAADEAAAAxAAAA
+////AMz//wAA//8AzMz/AJnM/wAAzP8AmZn/AGaZ/wAAmf8AZmb/ADNm/wAzM/8A/8zMAMzM
+zACZmcwAZpnMAACZzABmZswAM2bMAABmzAAzM8wAADPMAAAAzAD/zJkAzMyZAMyZmQCZmZkA
+ZmaZAGYzmQAzM5kAzJlmAJlmZgBmZmYAZjNmADMzZgDMmTMAmWYzAJkzMwBmMzMAmWYAAJkz
+AAAAAN0A7u7uAN3d3QC7u7sAqqqqAIiIiAB3d3cAVVVVAAARDgYDKgAAAAAAAAAAAAAAAAAA
+AAAAAAAAAAAAAAAAAAAAAAAVFRUVFRUVFRUVFBQUFBQUFRUVFRUVFRUVFRUVFRUVFQAAAAAV
+FRUVFRUVFRUVFRUVFRUVFRUVFRUVFRUVFRUVFRUVFQAAAAAVFRUVFRUVFRUVFRUVFRUVFRUV
+FRUVFRUVFRUVFRUVFAAAAAAVFRUVFRUVFRUVFRUVFRUVFRUVFRUVFRUVFRUVFRUVFAAAAAAV
+FRUVFRUVFRUVFRUVFRUVFRUVFRUVFRUVFRUVFRUVEgAAAAAVFRUVFhUVFRYVFRUWFRUVERUV
+FhUVFRYVFhUVFRUVEQAAAAAUFRUWABEVFQYPFhUDERUWBhUVKg8VFAAUABQVFRUVEQAAAAAU
+FRUWABYVBhQWFRUGFBUWERUWABYVFgAAFRUVFRUVDgAAAAAUFRUVABUVFBEAFhUGFBUUFRUV
+ABUVFgARFRUVFRUVBgAAAAASFRUWABUVFRUVFRUGFBUPFhUWABYVFgAVFBUVFRUVBgAAAAAR
+FRUVFhUVFRUVFRUEFBUEFhUVFhUVFQAWFRUVFRUVAwAAAAARFRUVFRUVFRUVFRUVFRUrHRUV
+FRUVFRUVFRUVFRUVAwAAAAAPFRUVFRUVFRUVFRUVFCQYKBUVFRUVFRUVFRUVFRUVKgAAAAAO
+FRUVFRUVFRUVFRUUJyEeKA4VFRUVFRUVFRUVFRUVAAAAAAAGFRUVFRUVFRUVFRYeKB0kKCQU
+FRUVFRUVFRUVFRUVAAAAAAAGFRUVFRUVFRUVFRIDKBQnKCgGFRUVFRUVFRUVFRUVAAAAAAAG
+FRUVFRUVFRUVFRUVJxEnJigDFRUVFRUVFRUVFRUVAAAAAAADFRUVFRUVFRUVFRUSKBEnKAkq
+FRUVFRUVFRUVFRUVAAAAAAADFRUVFRUVFRUVFRUuJxEoKBEWFRUVFRUVFRUVFRUVAAAAAAAr
+FRUVFRUVFRUVFRYvKA8oKCEGFRUVFRUVFRUVFRUVAAAAAAAqFRUVFRUVFRUVFRQmKAcoKCYE
+FRUVFRUVFRUVFRUVAAAAAAAAFRUVFRUVFRUVFRIoJwkoKCgDFRUVFRUVFRUVFRUVAAAAAAAA
+FRUVFRUVFRUVFQcoJxEnKCgBFRUVFRUVFRUVFRUUAAAAAAAAFRUVFRUVFRUVFQYoKBQnKCgq
+FhUVFRUVFRUVFRUUAAAAAAAAFRUVFRUVFRUVFQQoKBQkKCgsFhUVFRUVFRUVFRUUAAAAAAAA
+FRUVFRUVFRUVFQMkKCIjKB0RFRUVFRUVFRUVFRUUAAAAAAAAFRUVFRUVFRUVFQMUKCYeKCgV
+FRUVFRUVFRUVFRUVAAAAAAAAFRUVFRUVFRUVFRUVKCgaKCgnFRUVFRUVFRUVFRUVAAAAAAAA
+FRUVFRUVFRUVFRUUKCgkKCgoAxYVFRUVFRUVFRUVAAAAAAArFRUVFRUVFRUVFRURKCgoKCgo
+ERQVFRUVFRUVFRUVAAAAAAADFRUVFRUVFRUVFRURKCgoKCgoIQMWCBUVFRUVFRUVAAAAAAAD
+FRUVFRUVFRUVFRURKCgoKCgoKAAWEBYVFRUVFRUVKgAAAAAGFRUVFRUVFRUVFRUUJygoKCgo
+KAAWFRMVFRUVFRUVAwAAAAAGFRUVFRUVFRUTFhUWHigoKCEUKgAWFgIVFRUVFRUVBgAAAAAO
+FRUVFRUVFRUTFRUVBCgoKCgUFRYVFgIWFRAWFRUVDgAAAAAPFRUVFRUVFRUVFRUVFR4oKCgo
+FRUVFQIVFQUVFRUVEQAAAAARFRUVFRUVFRUVExUVFQckKCgoIRUVFRYVFRUVFRUVEgAAAAAR
+FRUVFRUVFRUWAhYVFRYDJygoKB0VFRUVFRUVFRUVFAAAAAASFRUVFRUVFRMVBRUVFRUWKhko
+KBQVFRUVFRUVFRUVFQAAAAAUFRUVFRUVFQgWFRAVFRUVFgMAKxYVFRUVFRUVFRUVFQAAAAAU
+FRUVFRUVFQgWFQIWFRUVFRUWFhUVFRUVFRUVFRUVFQAAAAAUFRUVFRUVFRMTFRUFFhUVFRUV
+FRUVFRUVFRUVFRUVFQAAAAAVFRUVFRUVFRYFFhUIAhYVFRUVFRUVFRUVFRUVFRUVFQAAAAAV
+FRUVFRUVFRUVFRUVFhUVFRUVFRUVFRUVFRUVFRUVFQAAAAAVFRUVFRUVFRUVFRUVFRUVFRUV
+FRUVFRUVFRUVFRUVFQMAAAAVFRUVFRUVFRUVFRUVFRUVFRUVFRUVFRUVFRUVFRUVFQQAAAAV
+FRUVFRUVFRUVFRUVFRUVFRUVFRUVFAYPEREUFBQVFQ4AAAAAACoDBAYODxESFBQVFRUVFRUV
+FQ8AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA==
+ENDofIMG
+
+if false
+demo.show_image('bmp', '8-bit-RLE', <<'ENDofIMG')
+Qk22CAAAAAAAADYEAAAoAAAAIgAAADIAAAABAAgAAQAAAIAEAAAAAAAAAAAAAAABAAAAAQAA
+////AO7u7gDMzP8Amcz/AJmZ/wCZmcwAZpnMAGZmzAAzZswAMzPMAAAzzAAAAMwAAMz/AACZ
+/wAA//8AAGbMAACZzADd3d0AzJmZAJkzAACZZgAAMzOZAGaZ/wCZZjMAZjNmAMyZZgCZmZkA
+ZjMzADMzZgDMmTMAu7u7AMz//wBmZv8Ad3d3AIiIiADMzJkAAAAAAAAAAAAAAAAAAAAAAAAA
+AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAG
+AAcFBAIBHAAAAAEACgoGCRAKAQAAAAEAIAoBAAAAAQAfCgEJAQAAAAEAHwoBCQEAAAABAB8K
+AQgBAAAAAQAECgAWCwoKCgsKCgoLCgoKBwoKCwoKCgsKCwUKAQcBAAAAABwACQoKCwAHCgoE
+BgsKAgcKCwQKCgEGCgkACQAJBAoBBwEAAAAAGgAJCgoLAAsKBAkLCgoECQoLBwoLAAsKCwAA
+BgoBBQEAAAAAGgAJCgoKAAoKCQcACwoECQoJCgoKAAoKCwAHBgoBBAEAAAAABgAICgoLAAcK
+AA4ECQoGCwoLAAsKCwAKCQUKAQQBAAAAAAYABwoKCgsHCgANAwkKAwsKCgsKCgoACwAGCgEC
+AQAAAAEAAQcOCgERARUOCgECAQAAAAEAAQYMCgAECRcjEw4KAQEBAAAAAQABBQsKAAYJFBgZ
+EwUNCgEAAQAAAAEAAQQKCgAICxkTFRcTFwkMCgEAAQAAAAEAAQQKCgAICAITCRQTEwQMCgEA
+AQAAAAEAAQQMCgAGFAcUGxMCDAoBAAEAAAABAAECCwoABwgTBxQTIAEADAoBAAEAAAABAAEC
+CwoAByIUBxMTBwsADAoBAAEAAAABAAERCgoACAshEwYTExgEDAoBAAEAAAABAAEBCgoACAkb
+ExYTExsDDAoBAAEAAAABAAEACgoACAgTFCATExMCDAoBAAEAAAABAAEACgoACBYTFAcUExMf
+CwoAAwkAAAAAAAEAAQAKCgAJBBMTCRQTEwELAAoKAAMJAAAAAAABAAEACgoACQMTEwkXExMe
+CwAKCgADCQAAAAAAAQABAAoKAAgCFxMcHRMVBwsKAAMJAAAAAAABAAEACgoABwIJExsZExMA
+DQoBAAEAAAABAAEADAoABhMTGhMTFAwKAQABAAAAAQABAAsKAAkJExMXExMTAgsACgoBAAEA
+AAABAAERCwoBBwYTAQcBCQoKAQABAAAAAQABAgsKAQcGEwAEGAILDQgKAQABAAAAAQABAgsK
+AQcHEwAEAAsQCwcKAQEBAAAAAQABBAsKAQkBFAYTAAQACwoPBwoBAgEAAAABAAEECAoADw8L
+CgsZExMTGAkBAAsLDgAHCgEEAQAAAAEAAQUICgAFDwoKCgMABBMADwkKCwoLDgsKEAsKCgoF
+AAAAAAEAAQYNCgEZBBMECgAEDgoKDAQKAQcBAAAAAQABBwkKAA4PCgoKFhcTExMYCgoKCwcK
+AQgBAAAAAQABBwgKAAwLDgsKCgsCFBMTExUKCgEJAQAAAAEAAQgHCgADDwoMAAQKAAYLARIT
+EwkLCgEAAAABAAEJBwoABA0LChAECgAFCwIAEQsACwoBAAAAAQABCQcKAAUNCwoOCwAFCgEL
+AQsMCgEAAAABAAEJBwoABg8PCgoMCxIKAQAAAAEACAoABwsMCwoNDgsAEQoBAAAAAQANCgEL
+EgoBAAAAAQAgCgECAAABACAKAQMAAAEAFgoACwkEBgcHCQkJCgoFAAAAAA0AAAABAgMEBQYH
+CAkJAAgKAQYMAAAAIgAAAQ==
+ENDofIMG
+end
+
+demo.show_image('bmp', '32-bit', <<'ENDofIMG')
+Qk2GFAAAAAAAADYAAAAoAAAAIgAAADIAAAABABgAAAAAAFAUAABtCwAAbQsAAAAAAAAAAAAA
+////ZmbMmZnMmZn/zMz/7u7u////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////AAD///8A
+M8wAM8wAM8wAM8wAM8wAM8wAM8wAM8wAM8wAM8wzM8wzM8wzM8wzM8wzM8wzM8wAM8wAM8wA
+M8wAM8wAM8wAM8wAM8wAM8wAM8wAM8wAM8wAM8wAM8wAM8wAM8wAM8z///8AAP///wAzzAAz
+zAAzzAAzzAAzzAAzzAAzzAAzzAAzzAAzzAAzzAAzzAAzzAAzzAAzzAAzzAAzzAAzzAAzzAAz
+zAAzzAAzzAAzzAAzzAAzzAAzzAAzzAAzzAAzzAAzzAAzzAAzzP///wAA////ADPMADPMADPM
+ADPMADPMADPMADPMADPMADPMADPMADPMADPMADPMADPMADPMADPMADPMADPMADPMADPMADPM
+ADPMADPMADPMADPMADPMADPMADPMADPMADPMADPMMzPM////AAD///8AM8wAM8wAM8wAM8wA
+M8wAM8wAM8wAM8wAM8wAM8wAM8wAM8wAM8wAM8wAM8wAM8wAM8wAM8wAM8wAM8wAM8wAM8wA
+M8wAM8wAM8wAM8wAM8wAM8wAM8wAM8wAM8wzM8z///8AAP///wAzzAAzzAAzzAAzzAAzzAAz
+zAAzzAAzzAAzzAAzzAAzzAAzzAAzzAAzzAAzzAAzzAAzzAAzzAAzzAAzzAAzzAAzzAAzzAAz
+zAAzzAAzzAAzzAAzzAAzzAAzzAAzzDNmzP///wAA////ADPMADPMADPMADPMAADMADPMADPM
+ADPMAADMADPMADPMADPMAADMADPMADPMADPMZmbMADPMADPMAADMADPMADPMADPMAADMADPM
+AADMADPMADPMADPMADPMADPMZmbM////AAD///8zM8wAM8wAM8wAAMz///9mZswAM8wAM8yZ
+mf9mmcwAAMwAM8zMzP9mZswAM8wAAMyZmf8AM8wAM8zu7u5mmcwAM8wzM8z///8zM8z///8z
+M8wAM8wAM8wAM8wAM8xmZsz///8AAP///zMzzAAzzAAzzAAAzP///wAAzAAzzJmZ/zMzzAAA
+zAAzzAAzzJmZ/zMzzAAzzAAAzGZmzAAzzAAAzP///wAAzAAzzAAAzP///////wAzzAAzzAAz
+zAAzzAAzzAAzzJmZzP///wAA////MzPMADPMADPMADPM////ADPMADPMMzPMZmbM////AADM
+ADPMmZn/MzPMADPMMzPMADPMADPMADPM////ADPMADPMAADM////ZmbMADPMADPMADPMADPM
+ADPMADPMmZn/////AAD///8zZswAM8wAM8wAAMz///8AM8wAM8wAM8wAM8wAM8wAM8wAM8yZ
+mf8zM8wAM8xmmcwAAMwAM8wAAMz///8AAMwAM8wAAMz///8AM8wzM8wAM8wAM8wAM8wAM8wA
+M8yZmf////8AAP///2ZmzAAzzAAzzAAzzAAAzAAzzAAzzAAzzAAzzAAzzAAzzAAzzJnM/zMz
+zAAzzJnM/wAAzAAzzAAzzAAAzAAzzAAzzAAzzP///wAAzAAzzAAzzAAzzAAzzAAzzAAzzMzM
+/////wAA////ZmbMADPMADPMADPMADPMADPMADPMADPMADPMADPMADPMADPMADPMADPMADPM
+3d3dMzOZADPMADPMADPMADPMADPMADPMADPMADPMADPMADPMADPMADPMADPMADPMzMz/////
+AAD///9mmcwAM8wAM8wAM8wAM8wAM8wAM8wAM8wAM8wAM8wAM8wAM8wAM8wzM8yZZjPMzJmZ
+MwAAM8wAM8wAM8wAM8wAM8wAM8wAM8wAM8wAM8wAM8wAM8wAM8wAM8wAM8zu7u7///8AAP//
+/5mZzAAzzAAzzAAzzAAzzAAzzAAzzAAzzAAzzAAzzAAzzAAzzDMzzJlmAGYzZsyZZpkzAJmZ
+zAAzzAAzzAAzzAAzzAAzzAAzzAAzzAAzzAAzzAAzzAAzzAAzzAAzzP///////wAA////mZn/
+ADPMADPMADPMADPMADPMADPMADPMADPMADPMADPMAADMzJlmmTMAMzOZmWYzmTMAmWYzMzPM
+ADPMADPMADPMADPMADPMADPMADPMADPMADPMADPMADPMADPM////////AAD///+Zmf8AM8wA
+M8wAM8wAM8wAM8wAM8wAM8wAM8wAM8wAM8wzZszMzP+ZMwAzM8yZZgCZMwCZMwCZmf8AM8wA
+M8wAM8wAM8wAM8wAM8wAM8wAM8wAM8wAM8wAM8wAM8z///////8AAP///5mZ/wAzzAAzzAAz
+zAAzzAAzzAAzzAAzzAAzzAAzzAAzzAAzzAAzzJlmAGZmzJlmAGYzM5kzAMzM/wAzzAAzzAAz
+zAAzzAAzzAAzzAAzzAAzzAAzzAAzzAAzzAAzzP///////wAA////zMz/ADPMADPMADPMADPM
+ADPMADPMADPMADPMADPMADPMADPMM2bMmTMAZmbMmWYAmTMAZmb/7u7uADPMADPMADPMADPM
+ADPMADPMADPMADPMADPMADPMADPMADPM////////AAD////MzP8AM8wAM8wAM8wAM8wAM8wA
+M8wAM8wAM8wAM8wAM8wAM8yIiIiZZgBmZsyZMwCZMwBmZswAAMwAM8wAM8wAM8wAM8wAM8wA
+M8wAM8wAM8wAM8wAM8wAM8wAM8z///////8AAP///93d3QAzzAAzzAAzzAAzzAAzzAAzzAAz
+zAAzzAAzzAAzzAAAzHd3d5kzAGaZzJkzAJkzAGYzZpmZ/wAzzAAzzAAzzAAzzAAzzAAzzAAz
+zAAzzAAzzAAzzAAzzAAzzP///////wAA////7u7uADPMADPMADPMADPMADPMADPMADPMADPM
+ADPMADPMMzPMZjMzmTMAZpn/mTMAmTMAZjMzmcz/ADPMADPMADPMADPMADPMADPMADPMADPM
+ADPMADPMADPMADPM////////AAD///////8AM8wAM8wAM8wAM8wAM8wAM8wAM8wAM8wAM8wA
+M8wzZsyZMwCZZgBmZv+ZMwCZMwCZMwDMzP8AM8wAM8wAM8wAM8wAM8wAM8wAM8wAM8wAM8wA
+M8wAM8wAM8z///////8AAP///////wAzzAAzzAAzzAAzzAAzzAAzzAAzzAAzzAAzzAAzzGaZ
+/5kzAJlmAGZmzJlmAJkzAJkzAMz//wAzzAAzzAAzzAAzzAAzzAAzzAAzzAAzzAAzzAAzzAAz
+zDMzzP///////wAA////////ADPMADPMADPMADPMADPMADPMADPMADPMADPMADPMmZn/mTMA
+mTMAMzPMmWYAmTMAmTMA7u7uAADMADPMADPMADPMADPMADPMADPMADPMADPMADPMADPMMzPM
+////////AAD///////8AM8wAM8wAM8wAM8wAM8wAM8wAM8wAM8wAM8wAM8yZzP+ZMwCZMwAz
+M8yZZjOZMwCZMwC7u7sAAMwAM8wAM8wAM8wAM8wAM8wAM8wAM8wAM8wAM8wAM8wzM8z/////
+//8AAP///////wAzzAAzzAAzzAAzzAAzzAAzzAAzzAAzzAAzzAAzzMzM/5lmM5kzADMzZsyZ
+M5kzADMzmWZmzAAzzAAzzAAzzAAzzAAzzAAzzAAzzAAzzAAzzAAzzAAzzDMzzP///////wAA
+////////ADPMADPMADPMADPMADPMADPMADPMADPMADPMADPMzMz/MzPMmTMAZjMzzJlmmTMA
+mTMAADPMADPMADPMADPMADPMADPMADPMADPMADPMADPMADPMADPMADPM////////AAD/////
+//8AM8wAM8wAM8wAM8wAM8wAM8wAM8wAM8wAM8wAM8wAM8wAM8yZMwCZMwCZmZmZMwCZMwCZ
+ZgAAM8wAM8wAM8wAM8wAM8wAM8wAM8wAM8wAM8wAM8wAM8wAM8z///////8AAP///////wAz
+zAAzzAAzzAAzzAAzzAAzzAAzzAAzzAAzzAAzzAAzzDMzzJkzAJkzAJlmM5kzAJkzAJkzAMzM
+/wAAzAAzzAAzzAAzzAAzzAAzzAAzzAAzzAAzzAAzzAAzzP///////wAA////3d3dADPMADPM
+ADPMADPMADPMADPMADPMADPMADPMADPMADPMZmbMmTMAmTMAmTMAmTMAmTMAmTMAZmbMMzPM
+ADPMADPMADPMADPMADPMADPMADPMADPMADPMADPM////////AAD////MzP8AM8wAM8wAM8wA
+M8wAM8wAM8wAM8wAM8wAM8wAM8wAM8xmZsyZMwCZMwCZMwCZMwCZMwCZMwBmM2bMzP8AAMwA
+mf8AM8wAM8wAM8wAM8wAM8wAM8wAM8wAM8z///////8AAP///8zM/wAzzAAzzAAzzAAzzAAz
+zAAzzAAzzAAzzAAzzAAzzAAzzGZmzJkzAJkzAJkzAJkzAJkzAJkzAJkzAP///wAAzACZzAAA
+zAAzzAAzzAAzzAAzzAAzzAAzzAAzzO7u7v///wAA////mZn/ADPMADPMADPMADPMADPMADPM
+ADPMADPMADPMADPMADPMMzPMmWYAmTMAmTMAmTMAmTMAmTMAmTMA////AADMADPMAGbMADPM
+ADPMADPMADPMADPMADPMADPMzMz/////AAD///+Zmf8AM8wAM8wAM8wAM8wAM8wAM8wAM8wA
+M8wAZswAAMwAM8wAAMzMmWaZMwCZMwCZMwBmM2YzM8zu7u7///8AAMwAAMwA//8AM8wAM8wA
+M8wAM8wAM8wAM8wAM8yZmf////8AAP///5mZzAAzzAAzzAAzzAAzzAAzzAAzzAAzzAAzzABm
+zAAzzAAzzAAzzJnM/5kzAJkzAJkzAJkzADMzzAAzzAAAzAAzzAAAzAD//wAAzAAzzACZzAAA
+zAAzzAAzzAAzzJmZzP///wAA////ZpnMADPMADPMADPMADPMADPMADPMADPMADPMADPMADPM
+ADPMADPMADPMzJlmmTMAmTMAmTMAmTMAADPMADPMADPMADPMAP//ADPMADPMAMz/ADPMADPM
+ADPMADPMZmbM////AAD///9mZswAM8wAM8wAM8wAM8wAM8wAM8wAM8wAM8wAM8wAZswAM8wA
+M8wAM8xmmf+ZZjOZMwCZMwCZMwBmM2YAM8wAM8wAM8wAAMwAM8wAM8wAM8wAM8wAM8wAM8wA
+M8wzZsz///8AAP///2ZmzAAzzAAzzAAzzAAzzAAzzAAzzAAzzAAzzAAAzAD//wAAzAAzzAAz
+zAAAzMzM/5lmAJkzAJkzAJkzADMzmQAzzAAzzAAzzAAzzAAzzAAzzAAzzAAzzAAzzAAzzDMz
+zP///wAA////M2bMADPMADPMADPMADPMADPMADPMADPMAGbMADPMAMz/ADPMADPMADPMADPM
+AADM7u7uzJmZmTMAmTMAMzPMADPMADPMADPMADPMADPMADPMADPMADPMADPMADPMADPM////
+AAD///8zM8wAM8wAM8wAM8wAM8wAM8wAM8wAM8wAmf8AAMwAM8wAmcwAM8wAM8wAM8wAM8wA
+AMzMzP/////d3d0AAMwAM8wAM8wAM8wAM8wAM8wAM8wAM8wAM8wAM8wAM8wAM8z///8AAP//
+/zMzzAAzzAAzzAAzzAAzzAAzzAAzzAAzzACZ/wAAzAAzzAD//wAAzAAzzAAzzAAzzAAzzAAz
+zAAAzAAAzAAzzAAzzAAzzAAzzAAzzAAzzAAzzAAzzAAzzAAzzAAzzAAzzP///wAA////MzPM
+ADPMADPMADPMADPMADPMADPMADPMAGbMAGbMADPMADPMAMz/AADMADPMADPMADPMADPMADPM
+ADPMADPMADPMADPMADPMADPMADPMADPMADPMADPMADPMADPMADPM////AAD///8AM8wAM8wA
+M8wAM8wAM8wAM8wAM8wAM8wAAMwAzP8AAMwAM8wAmf8A//8AAMwAM8wAM8wAM8wAM8wAM8wA
+M8wAM8wAM8wAM8wAM8wAM8wAM8wAM8wAM8wAM8wAM8wAM8z///8AAP///wAzzAAzzAAzzAAz
+zAAzzAAzzAAzzAAzzAAzzAAzzAAzzAAzzAAzzAAAzAAzzAAzzAAzzAAzzAAzzAAzzAAzzAAz
+zAAzzAAzzAAzzAAzzAAzzAAzzAAzzAAzzAAzzAAzzP///wAA////ADPMADPMADPMADPMADPM
+ADPMADPMADPMADPMADPMADPMADPMADPMADPMADPMADPMADPMADPMADPMADPMADPMADPMADPM
+ADPMADPMADPMADPMADPMADPMADPMADPMADPMzMz/AAD///8AM8wAM8wAM8wAM8wAM8wAM8wA
+M8wAM8wAM8wAM8wAM8wAM8wAM8wAM8wAM8wAM8wAM8wAM8wAM8wAM8wAM8wAM8wAM8wAM8wA
+M8wAM8wAM8wAM8wAM8wAM8wAM8wAM8yZzP8AAP///wAzzAAzzAAzzAAzzAAzzAAzzAAzzAAz
+zAAzzAAzzAAzzAAzzAAzzAAzzAAzzAAzzAAzzAAzzAAzzAAzzAAzzAAzzDMzzJmZ/2aZzGZm
+zGZmzDMzzDMzzDMzzAAzzAAzzJmZzAAA////////////7u7uzMz/mcz/mZn/mZnMZpnMZmbM
+M2bMMzPMMzPMADPMADPMADPMADPMADPMADPMADPMADPMZpnM////////////////////////
+////////////////////////AAD/////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////
+//////////////////8AAA==
+ENDofIMG
+
+demo.show_image('gif', 'gif87a', <<'ENDofIMG')
+R0lGODdhQAAoAPcAAAAAADgoOHBgYJiIkIB4iJCAiIB4gGBIUGhggKiYmLCYoLiooHBocMCA
+eJBocLCYmMCooKiQkKCAgGBASIiAiGhYeLiQiIhoaJhwcJh4gMCYkMCgoMCoqKiQiEBAWEg4
+QMiwoMioqMComLCIiFhAWIBgaJhweHBgcLiQkIiAgDg4UIhwgHhgYJh4cMiooFBQcGBYeJiA
+iIBwgIh4iKCAiKB4eHhYYGhIWKiIiEhAWFBIYEhAaEhIaHBYcHBgeFBQeHBogHBQYHBQWGBA
+UFhQaGBYaFhYeKCIkLCQmHhYaGBIWLCYiFBAYEhAYFhQYFBIaFhYcKCIiKCQkKiIkLCIgHBQ
+aIhwcJiAeIBgcJBwcLCQiKiAeKB4gHhwgNCwqMiwqIBoeHBYaJh4eMCYmJBweGhYYNC4qEg4
+UEA4WGBQWEBAYFBQaHBoeFhQcGhgeGhYcMiwsJB4cGBIYNjIwEAwSMCgmHhocFBAWNDAuNDI
+uIBweGBYcHhoeDgwQGhgaKCIgNjQuKiAgNjIuKiIgKCAeKCQiEhIWFBIUGBQaNC4sGBQcGBY
+YMi4sGhYWFhIYFhIaFhQWHhoaLCQkDg4SHBgaJB4gJB4eLiYmLiomGhYaEhIYFhYaIh4gHho
+gGhgcIBoaGBIaHhgcNDAsFBAUGhQYLigoLioqJiIgGhQaFA4SFhIWHhweFBIWJiAgIh4eFhI
+UHBYYIhweEg4WLiYkDg4WGBQYEA4SEA4UMCwqIhocHhgaJB4iJCAgFhASEBAUEhAUIBocFhA
+UKCQmHhgeEgwSNjQwEg4SLCgmDgwUGhQWLCgoEAwUFBASLigmEAwQGhIUFg4SIhoeEgwQKiY
+kFA4UDgwSJiIiIBwcKiQmLCooLCYkDgoQP//////////////////////////////////////
+////////////////////////////////////////////////////////////////////////
+/////////////////////////////////ywAAAAAQAAoAAAI/gABCBxIsKDBggEEDBhAoICB
+AwcjSpxIMSKCBAoWIGDQoIGDBxAURJBAoKLJkwcnUKgQoYEFlxcwdOyYoYGGDRw6eEDJc+IH
+CSBCiHg5YiaJEjM7mjgBAkUKAip6Sh24YqYGmUkbYGDRwoWGlxocvIABI4aMGVN70qiRNSkL
+Gzda4BhhIoeOHTx6+PjxwwcCIGlPouiI4WUDFkFYCLlhYwiLBkU73iBShAgRAkaMHCGAIDBF
+JBpmXkiiZMiQCagzLEFRgi0GDUyaONHx5MkLKFFCSOns+eCUBlRKVIErxIYVG1ewsMiixYSW
+LVxQkIDRpDqRJF1gVPDyhQDg3gSB/mQAwyKMmBJjpoAhU6bKCjMgMGxZAuIMmjRq0KhpsmbN
+EjZtuHEEAgQ4Ad5ACLxRQhkZwBHHGHKMAcccdFxhBgpU1FGDHUzc0QESduDhxRx56DEHHnvs
+4R0ffRzYhREwYOHHH4BUEQgZYYlgoSBfjCHIBh0MAoEdAxBSiCGHIJLIHHCYwEEFQHRhx4Ew
+LLCHIm4sIggjc9RhgQhzgEAIIGSEAAIgjShhwhwN4MGEI4/sAIkjSEQiCRJYuAHEJL0RwMge
+ejzBBiV6VGKJFpcMskUcFyQygoiEbAABJn9kogkaa+RgwCZEMEEEBlNw4gMbiPQ2QyeefAKK
+GpT0cAIk/jjEgQIKggAiiAMgUAFZIkiEIkokozyigyakLFLBGzb8IcUDPXjSGxArlGJKKKcg
+sQAqdojAlQMaCDLGHIlk8EkqiFhQBxJL5BAGE0yo4gQaTBTAQAYc2NGDZ4UAYcoOhfBxwiql
+nFGGDQ3UwMIFGsyBAgs19MBKDg0IQUoroqCRgweO5OCKJjo4osEYBXjySmAE/JBCDHBMUUkT
+T6AxiktgvXTDDbDEUoEsF8ySQxl8LJEGLTugUUQtllBQyyqW8DFyWggY8UYoHPBxxh1O0PDA
+GA0g1ZEQQphQwhus2GJDEGh4cAstbjSBBhF7aEJEEzwYQUQnaQSWHQ+o4BIG/i5gPFIKHl8k
+ZYENGOSiixysqHHGLYbE4IQTt1TQhA6o8KDJGjy8YJkiJPOlCAw7OPKEB7LccYsQoUFWxwSq
+2EFJETo8ogoaThSRwy2y4KEGBaDwUIQfu1DiwyOBNc3DGrzI0cYdnNyRQx+vuCRIAyD0wokS
+aehgSw60+GIILbSoYMstpvwywxM88PAEETwQQTIMCOwBBjAdfMFIFBcEQ4IIDdTaAjAJgMQd
+UnGGJJTtdpMI3yRUAAEP4AUIT9DECRxhN2EoIAZ7IAUkAhECDgwDDLYgxgREgQk8FMNWcxAF
+BwjRhztEQRWtoIQdbHGGHOCBFmqAgRr2kIm6pWUC/p3wwRFAMYM/6IIUR0gAE+Rwh2DIwRgo
+wEMe5jAHQQhCFHFoBAAycYxXxMER27MBMtTACtkU4QyeUYACStGEO8QADA/wRAAEIoMsiOEK
+NxACCEAgiDwIAg+l+EQyAnCKDljAFLbghTHKp4Yi9IBznlEGBxLhiGUsgQOM+EQWAPABKkBC
+DBEIRC/iIApbCQICgxhCMERAiBZYwRLMmIAxFgAK7r3gCb1hAwXwYIUogKIMQSBEHprhDCVc
+4BNVnAMgABEm+hTgGYcoAzQWIAIsTOABaSBEFNIAiSfIAjwIYEQIZIGFMIAhDW/IAy6igYNE
+fEEUiWDEJcRgjBsEgRTM/pDDH5jRAUbgwhQJcIUkaAAEWvziQAjgQCnukIBW6KEWVsDDLFhA
+hQuEwAUjAMEsZnGBPwhBAtI4AAMaEYEOfAIAyjjGNOKgByLM8UADUAYnEmCJLwQBB3jAhRYG
+gTAN4CALWajDEWBxAV1MIBIMcIItjCEQSEShEqoYBTUOJBBbFACAqWjGBl5BhS+gQAs4mEYH
+COHPXmCBEBMYxjQC0IhbVEMglEgDKX5xBgpSVSAEqAAnTtGMB4CBEApAAS6yMIhmlMISlmjG
+IKxxjFnc4AgCsIMqXMEJXujhF7eABFPvKhAEsMENqliAFHpBCRvUAQKm4IAVxBCFBSijFA8Y
+2MQAjDENUrjCClaohB2KAAlWcJYgCLjGABKAjVYsIBsJuEQEmoGJbJjiuNpIQDY4UYAC8EEP
+kegEA9zwBk38tiAIMEB0swGBbGDjGM2QhDIeMItsONe9MrWGMKxhXU8Q4aDfLcgkCpCCCCRA
+G0hQQAKU4d4FGDgbyiBuBAZQAArIAAZ7yEF+IwIER8wAGxherwKOcQllTGMaSJBCBGLAi1Os
+gBJ2nbBEoFCAAUQhCtiIQASEIeMB0IAG1rAsH5ywDRWbJACdmEFDdlGAGMyAxF1gAwzuQNWA
+AAA7
+ENDofIMG
+
+demo.show_image('gif', 'gif89a', <<'ENDofIMG')
+R0lGODlhQAAoAPcAAMnJyTgoOHBgYJiIkIB4iJCAiIB4gGBIUGhggKiYmLCYoLiooHBocMCA
+eJBocLCYmMCooKiQkKCAgGBASIiAiGhYeLiQiIhoaJhwcJh4gMCYkMCgoMCoqKiQiEBAWEg4
+QMiwoMioqMComLCIiFhAWIBgaJhweHBgcLiQkIiAgDg4UIhwgHhgYJh4cMiooFBQcGBYeJiA
+iIBwgIh4iKCAiKB4eHhYYGhIWKiIiEhAWFBIYEhAaEhIaHBYcHBgeFBQeHBogHBQYHBQWGBA
+UFhQaGBYaFhYeKCIkLCQmHhYaGBIWLCYiFBAYEhAYFhQYFBIaFhYcKCIiKCQkKiIkLCIgHBQ
+aIhwcJiAeIBgcJBwcLCQiKiAeKB4gHhwgNCwqMiwqIBoeHBYaJh4eMCYmJBweGhYYNC4qEg4
+UEA4WGBQWEBAYFBQaHBoeFhQcGhgeGhYcMiwsJB4cGBIYNjIwEAwSMCgmHhocFBAWNDAuNDI
+uIBweGBYcHhoeDgwQGhgaKCIgNjQuKiAgNjIuKiIgKCAeKCQiEhIWFBIUGBQaNC4sGBQcGBY
+YMi4sGhYWFhIYFhIaFhQWHhoaLCQkDg4SHBgaJB4gJB4eLiYmLiomGhYaEhIYFhYaIh4gHho
+gGhgcIBoaGBIaHhgcNDAsFBAUGhQYLigoLioqJiIgGhQaFA4SFhIWHhweFBIWJiAgIh4eFhI
+UHBYYIhweEg4WLiYkDg4WGBQYEA4SEA4UMCwqIhocHhgaJB4iJCAgFhASEBAUEhAUIBocFhA
+UKCQmHhgeEgwSNjQwEg4SLCgmDgwUGhQWLCgoEAwUFBASLigmEAwQGhIUFg4SIhoeEgwQKiY
+kFA4UDgwSJiIiIBwcKiQmLCooLCYkDgoQP//////////////////////////////////////
+////////////////////////////////////////////////////////////////////////
+/////////////////////////////////yH5BAEAAAAALAAAAABAACgAAAj+AAEIHEiwoMGC
+AQQMGECggIEDByNKnEgxIoIEChYgYNCggYMHEBREkECgosmTBydQqBChgQWXFzB07JihgYYN
+HDp4QMlz4gcJIEKIeDliJokSMzuaOAECRQoCKnpKHbhipgaZSRtgYNHChYaXGhy8gAEjhowZ
+U3vSqJE1KQsbN1rgGGEih44dPHr4+PHDBwIgaU+i6IjhZQMWQVgIuWFjCIsGRTveIFKECBEC
+RowcIYAgMEUkGmZeSKJkyJAJqDMsQVGCLQYNTJo40fHkyQsoUUJI6ez54JQGVEpUgSvEhhUb
+V7CwyKLFhJYtXFCQgNGkOpEkXWBU8PKFAODeBIH+ZADDIoyYEmOmgCFTpsoKMyAwbFkC4gya
+NGrQqGmyZs0SNm24cQQCBDgB3kAIvFFCGRnAEccYcowBxxx0XGEGClTUUYMdTNzRARJ24OHF
+HHnoMQcee+zhHR99HNiFETBg4ccfgFQRCBlhiWChIF+MIcgGHQwCgR0DEFKIIYcgksgccJjA
+QQVAdGHHgTAssIcibiwiCCNz1GGBCHOAQAggZIQAAiCNKGHCHA3gwYQjj+wAiSNIRCIJEli4
+AcQkvRHAyB56PMEGJXpUYokWlwyyRRwXJDKCiIRsAAEmf2SiCRpr5GDAJkQwQQQGU3DiAxuI
+9DZDJ558AooalPRwAiT+OMSBAgqCACKIAyBQAVkiSIQiSiSjPKKDJqQsUsEbNvwhxQM9eNIb
+ECuUYkoopyCxACp2iMCVAxoIMsYciWTwSSqIWFAHEkvkEAYTTKjiBBpMFMBABhzY0YNnhQBh
+yg6F8HHCKqWcUYYNDdTAwgUazIECCzX0wEoODQhBSiuioJGDB47k4IomOjiiwRgFePJKYAT8
+kEIMcExRSRNPoDGKS2C9dMMNsMRSgSwXzJJDGXwskQYtO6BRRC2WUFDLKpbwMXJaCBjxRigc
+8HHGHU7Q8MAYDSDVkRBCmFDCG6zYYkMQaHhwCy1uNIEGEXtoQkQTPBhBRCdpBJYdD6jgEgb+
+LmA8UgoeXyRlgQ0Y5KKLHKyoccYthsTghBO3VNCEDqjwoMkaPLxgmSIk86UIDDs48oQHstxx
+ixChQVbHBKrYQUkROjyiChpOFJHDLbLgoQYFoPBQhB+7UOLDI4E1zcMavMjRxh2c3JFDH6+4
+JEgDIPTCiRJp6GBLDrT4YggttKhgyy2m/DLDEzzw8AQRPBBBMgwI7AEGMB18wUgUFwRDgggN
+1NoCMAmAxB1ScYYklO12kwjfJFQAAQ/gBQhP0MQJHGE3YSggBnsgBSQCEQIODAMMtiDGBESB
+CTwUw1ZzEAUHCNGHO0RBFa2ghB1scYYc4IEWaoCBGvaQibqlZQL+nfDBEUAxgz/oghRHSAAT
+5HCHYMjBGCjAQx7mMAdBCEIUcWgEADJxjFfEwRHbswEy1MAK2RThDJ5RgAJK0YQ7xAAMD/BE
+AAQigyyI4Qo3EAIIQCCIPAgCD6X4RDICcIoOWMAUtuCFMcqnhiL0gHOeUQYHEuGIZSyBA4z4
+RBYA8AEqQEIMEQhEL+IgClsJAgKDGEIwRECIFljBEsyYgDEWAAruveAJvWEDBfBghSiAogxB
+IEQemuEMJVzgE1WcAyAAESb6FOAZhygDNBYgAixM4AFpIEQU0gCJJ8gCPAhgRAhkgYUwgCEN
+b8gDLqKBg0R8QRSJYMQlxGCMGwSBFMz+kMMfmNEBRuDCFAlwhSRoAARa/OJACOBAKe6QgFbo
+oRZWwMMsWECFC4TABSMAwSxmcYE/CEEC0jgAAxoRgQ58AgDKOMY04qAHIszxQANQBicSYIkv
+BAEHeMCFFgaBMA3gIAtZqMMRYHEBXUwgEgxwgi2MIRBIRKESqhgFNQ4kEFsUAICpaMYGXkGF
+L6BACziYRgcI4c9eYIEQExjGNALQiFtUQyCUSAMpfnEGClJVIASoACdO0YwHgIEQCkABLrIw
+iGaUwhKWaMYgrHGMWdzgCAKwgypcwQle6OEXt4AEU+8qEASwwQ2qWIAUekEJG9QBAqbggBXE
+EIUFKKMUDxjYxACMMQ1SuMIKVqiEHYoACVZwliAIuMYAEoCNViwgGwm4RASagYlsmOK42khA
+NjhRgALwQQ+R6AQD3PAGTfy2IAgwQHSzAYFsYOMYzZCEMh4wi2w4170ytYYwrGFdTxDhoN8t
+yCQKkIIIJEAbSFBAApTh3gUYOBvKIG4EBlAACsgABnvIQX4jAgRHzAAbGF6vAo5xCWVMYxpI
+kEIEYsCLU6yAEnadsESgUIABRCEK2IhABIQh4wHQgAbWsCwfnLANFZskAJ2YQUN2UYAYzIDE
+XWADDO5A1YAAADs=
+ENDofIMG
+
+teapot = <<'ENDofIMG'
+",
+".. c #998074",
+"#. c #84aadc",
+"a. c #c47e55",
+"b. c #4c6ea0",
+"c. c #d48a64",
+"d. c #ecccbc",
+"e. c #8c6252",
+"f. c #b1a094",
+"g. c #714628",
+"h. c #af8a76",
+"i. c #2c5284",
+"j. c #98745f",
+"k. c #8f5124",
+"l. c #844614",
+"m. c #5074a6",
+"n. c #aeb2b9",
+"o. c #3e291c",
+"p. c #44689b",
+"q. c #4c2705",
+"r. c #1b2b43",
+"s. c #e1c8bb",
+"t. c #dd782d",
+"u. c #9c5824",
+"v. c #547aac",
+"w. c #906e5a",
+"x. c #545253",
+"y. c #e07e33",
+"z. c #bcaeac",
+"A. c #aeb6bc",
+"B. c #6f737b",
+"C. c #7e5942",
+"D. c #b55e1a",
+"E. c #7c5134",
+"F. c #8c7a70",
+"G. c #62524d",
+"H. c #bc8a6c",
+"I. c #936754",
+"J. c #6e6d75",
+"K. c #8cb0e2",
+"L. c #d4beb4",
+"M. c #2a201a",
+"N. c #c48664",
+"O. c #412105",
+"P. c #a95a19",
+"Q. c #747a7c",
+"R. c #2a2e33",
+"S. c #484c53",
+"T. c #8690a1",
+"U. c #6c524c",
+"V. c #505967",
+"W. c #040204",
+"X. c #8cb6e4",
+"Y. c #8f4912",
+"Z. c #846e5c",
+"0. c #244a7c",
+"1. c #dcc2b6",
+"2. c #33261b",
+"3. c #81736c",
+"4. c #3c3b46",
+"5. c #735f53",
+"6. c #545e69",
+"7. c #bc7c58",
+"8. c #4c2f1d",
+"9. c #a4806b",
+".# c #604c4c",
+"## c #d4916b",
+"a# c #5c80b2",
+"b# c #e3d3cd",
+"c# c #c8ad9a",
+"d# c #bf6c2e",
+"e# c #08121c",
+"f# c #9c5e34",
+"g# c #9298a1",
+"h# c #8b7f7c",
+"i# c #835f44",
+"j# c #a46e54",
+"k# c #474649",
+"l# c #a65d26",
+"m# c #be6420",
+"n# c #7c9ed2",
+"o# c #ac622c",
+"p# c #726e6c",
+"q# c #e1a684",
+"r# c #a48676",
+"s# c #54464c",
+"t# c #a0a4ac",
+"u# c #b37b5a",
+"v# c #947a70",
+"w# c #543d31",
+"x# c #743e12",
+"y# c #98bcee",
+"z# c #d49e7c",
+"A# c #64320c",
+"B# c #d4cac6",
+"C# c #2c3642",
+"D# c #6e686b",
+"E# c #5c463e",
+"F# c #7f7575",
+"G# c #bcb2b0",
+"H# c #979dac",
+"I# c #a47a61",
+"J# c #8c9094",
+"K# c #1c262c",
+"L# c #d3c3bc",
+"M# c #9cc2f4",
+"N# c #af7455",
+"O# c #fcad5f",
+"P# c #6486b8",
+"Q# c #d4742d",
+"R# c #6d4e3d",
+"S# c #242224",
+"T# c #3b444c",
+"U# c #181515",
+"V# c #6e4024",
+"W# c #749bcc",
+"X# c #afabac",
+"Y# c #7e6a64",
+"Z# c #343634",
+"0# c #e8ac8a",
+"1# c #343a44",
+"2# c #b18f7a",
+"3# c #dda07f",
+"4# c #6f380d",
+"5# c #2f5684",
+"6# c #a08d86",
+"7# c #5f6068",
+"8# c #625751",
+"9# c #16253b",
+".a c #94b6e9",
+"#a c #dfcec8",
+"aa c #3c6194",
+"ba c #ecdad3",
+"ca c #948a89",
+"da c #a4c8fa",
+"ea c #bcb6b8",
+"fa c #604432",
+"ga c #cc6d29",
+"ha c #949ea4",
+"ia c #413024",
+"ja c #a48a7a",
+"ka c #9a867d",
+"la c #1c1a1c",
+"ma c #342116",
+"na c #bc8364",
+"oa c #9c8674",
+"pa c #844e25",
+"qa c #3c4a5c",
+"ra c #582c0d",
+"sa c #c7835a",
+"ta c #613c24",
+"ua c #614b41",
+"va c #adaeb5",
+"wa c #805c4c",
+"xa c #0a0b0f",
+"ya c #c4b2ac",
+"za c #648abc",
+"Aa c #af846a",
+"Ba c #c68a69",
+"Ca c #483c39",
+"Da c #7f400d",
+"Ea c #646e74",
+"Fa c #a85515",
+"Ga c #042244",
+"Ha c #816759",
+"Ia c #95817c",
+"Ja c #9c9aa1",
+"Ka c #9c6b54",
+"La c #7e4924",
+"Ma c #0c1a2c",
+"Na c #5f595f",
+"Oa c #6f615e",
+"Pa c #474149",
+"Qa c #8c9aac",
+"Ra c #cbbeb8",
+"Sa c #806e68",
+"Ta c #82624e",
+"Ua c #949294",
+"Va c #b4652c",
+"Wa c #9c9ea4",
+"Xa c #72574c",
+"Ya c #2a303e",
+"Za c #bc9175",
+"0a c #9c7a64",
+"1a c #261a13",
+"2a c #aca6ac",
+"3a c #341a04",
+"4a c #593520",
+"5a c #d49878",
+"6a c #26282c",
+"7a c #475261",
+"8a c #3f3535",
+"9a c #63676f",
+".b c #a47255",
+"#b c #bc967c",
+"ab c #52433a",
+"bb c #80a4d6",
+"cb c #544c4c",
+"db c #bc723c",
+"eb c #645e54",
+"fb c #a4abb4",
+"gb c #c89070",
+"hb c #8c7469",
+"ib c #c7b8b3",
+" ",
+" ",
+" ",
+" wawae.e.wa ",
+" .#j#N#7.a.db.# ",
+" 8.g.x#C.o. ",
+" N#DaA#raY.Xa4aV#4aPas#q.W.W.6a ",
+" i#O.l.4.4.4.4.4.s#wa7.N#wawaXawawawaA#q.C. ",
+" 3a3a4#wawawae.e.e.I.j#m#d#VaN#KaI.e.e.e.e.waDaO..#j#j#N#N#j#fa ",
+" O.A#wae.e.I.e.I.I.Kal#m#m#D.u.KaKaKaKaI.e.I.e.Da3aXaE#C#W.o.C. ",
+" w#e.k.I.I.Kaf#KaKaKaKal#m#m#D.l#j#Kaj#KaKaKaKaKaFai#u. GaDaI. ",
+" .#waKaI.KaKaj#j#j#j#j#VaD.m#FaVaj#j#j#j#j#j#j#KaKae.U. 9#o.Ka ",
+" .#Xae.Kaj#j#N#N#N#N#N#j#N#j#N#N#N#N#N#dbdbN#N#N#I.waU. e#M.taPa ",
+" .#U.Xawae.Kaj#N#7.dbj#a.a.a.a.a.a.a.j#7.sa##naj#I.e.waXaU.Yama.# ",
+" .#U.Xawae.I.Ka.bna3#0#3###sasaa.sac.##Ba7.u#N#Kaf#f#waXaU.4.s#Pa ",
+" j#N#5aW.Y.u#j#R# 8a.#XaXae.e.I.KaN#naz#0#q#gb7.7.N#N#N#u#nau#N#N#Kaf#f#e.waU.LaU. ",
+" 4.Hahb.bI.j#KaY. s#U.XaXawae.KaKaN#na3#0#3#gbna7.N#u#u#N#7.u#N#.bj#KaI.e.waXa.# ",
+" G.2#e.KaI.E# .#U.Xawae.P.Kaj#N#H.z#q#3#gb7.7.7.7.N#N#u#u#N#.bj#KaI.e.TaXaU.0. ",
+" Ca.#e.j#Va 5#aa0.MaU.Xawak.d#I.j#I#N.5a3#5aBa7.dbN#N#dbN#N#u#I#j#KaKaI.e.waXaU.0.i.p. ",
+" abU.I.KapaaaaaxaGaU.C.wau.VaKaj#I#na5a5agbN.u#N#7.N#N#N#N#N#.bj#KaKaI.e.waXa.#R#m.m.m.p. ",
+" zaW#0.0.s#waKam#0.0.e#GaU.C.k.l#I.KaKa.bnagbgbBa7.u#7.N#N#N#N#N#.bj#j#KaKaI.e.waXa.#.#b.m.m.i.i.0. ",
+" 5#aaW#W#n#aaaa0.U..#e.Kau.ta4aLak.k.u.o#e.KaKa.bu#H.H.nau#N#N#N#N#N#N#j#N#j#KaKaI.I.e.waXa.#fab.m.i.i.i.i.i.0. ",
+"p.p.p.aan#W#0.0.0.0.p.uaU.KaKal#o#d#gal#o#o#e.I.Kaj#N#Aau#u#N#N#N#.bN#N#j#.bj#j#KaKaI.I.e.waXa.#E#m.m.v.m.i.i.m.n#bbn# ",
+"p.p.n#n#n#p.0.0.0.0.0.xa.#waKaKagaQ#t.y.d#dbi#e.I.Ka.bN#I#N#N#N#N#.bN#N#j#N#j#KaKaI.f#e.waXaU.U.w#5#m.m.i.i.i.m.bbbbbbbbaa ",
+"n#n#n#n#n#n#0.aaaap.aaaas#s#waKaj#na##O#dbl#wae.I.I.j.j#j#j#j#j#j#j#.bj#j#j#KaKaKaI.e.e.waXaE.Hai.m.m.i.i.i.i.p.p.bbb.b.p.p.aa ",
+"p.bbn#bbp.p.p.p.p.p.aaaaaaua..#be.Kaj#j#u.XawaTae.I.KaKaKaKaj#j#j#j#j#KaKaKaKaKaI.I.i#waXawaR#uav.m.m.v.v.i.b.bbbbbbbbp.p.b.p.p.",
+"bbp.p.p.p.p.p.n#p.0.0.0.0.p.8#Oa2#ZaZaZak.XaXawae.e.e.I.KaKaKaj#KaKaKaKaI.w.I.I.I.e.waXa0aXa5.5#i.m.m.v.v.p.p.#.#.#.#.#.#.b.bb#.",
+"bbW#p.p.p.n#bbbbp.0.0.0.0.0.0.0.x.D#3.3.w.waU.wawae.e.e.e.f#I.I.I.I.I.I.I.f#e.e.wawaXae.w.ua4.5#5#i.7ai.b.b.b.p.b.#.#.#.p.b.b.#.",
+"p.bbp.bbbbp.p.p.p.0.0.6.p.p.p.0.0.0.0.9#R#wae.9.j.wawae.Tae.e.e.e.I.e.Tai#e.wawaw.Aaw.hbOa6aC#5#m.v.v.#.p.p.b.b.p.#.#.b.b.p.p.b.",
+"0.0.0.p.p.p.p.aa0.0.p.p.p.p.p.p.0.0.p.qaT#s#Z.0a..h.I#I#ZaZaI#gbI#.bH..b.bH.h.j.r#HaU.PaV.V.Na1#v.m.K.K.K.#.b.#.#.#.#.K.p.b.m.p.",
+"0.0.0.0.p.0.0.0.0.0.0.p.p.p.p.0.0.p.p.qaqaqa2.iaR#HaY#ja2#2#I#Za2#0a2#2#h.jaoaF.8#V.6aC#C#C#CaNab.bbbbK.#.b.b.b.#.K.K.#.#.#.X.#.",
+"b.b.p.p.p.0.i.0.0.0.0.p.0.0.0.i.0.0.qaqak#6aR.6a3aiawaY#OaOaOaD#Iah#D#OaF#cbPa6a6aW.V.6.1#C#7ap#b.b.b.b.b.b.b.b.b.K.K.#.b.b.b.b.",
+"bb#.#.#.#.b.b.i.0.p.p.p.0.b.b.0.0.0.qar.YaYaYaR.K#Z#E.xa1a2.S#.#x.x.S.R.laU#1#W.W.9a6.J#J#T.7av#K.K.K.K.b.b.m.m.b.m.K.b.p.m.b.b.",
+"#.#.#.#.#.#.K.#.#.#.#.#.#.b.b.b.#.p.qaqaYaR.YaR.Pa6ak#S#lalaW.W.xaW.W.W.W.U#U#ebT.hag#g#haT.7ac#K.K.K.K.K.K.b.b.#.K.K.K.K.m.b.b.",
+"#.#.#.b.b.b.b.#.#.bb#.#.#.b.K.bbK.#.T.T.J#R.YaS.S.x.ebebR.2.S#S#S#T#S#S#S.9a7aEaEafbhag#6.7aV.m.K.K.K.K.X.K.m.X.K.K..a.aX.K.b.m.",
+"b.b.p.b.p.b.p.K.K.K.b.b.b.b.#.#.#.#.T.T.J#UaJ#J#g#g#haWaWa7#9a2at#fbA.t#9a6.9aJ.EaEafbV.6.V.Nam.b.m..a.am.b.m.m.m.K.X.K..a.a.am.",
+" p.b.p.p.b.p.K.b.b.p.b.b.b.b.K.#.K.7a7aV.9aWat#X#WahaH#ha6.t#n.n.n.n.fbfb9a9an.t#t#fbfb7aV.7#m.m.m..am.m.m.m.m.m.m..a.a.am.m.m.",
+" b.p.b.#.#.#.#.#.b.b.b.b.b.b.K.Pax.V.7aNa7#7#t#vafbB.B.B.B.B.n.A.A.A.fbfb9aA.t#t#fbfbQaH#7#D#m.X..a.a.aX.v.v.v.v.m.m..am.v.m.m.",
+" #.K.K.K.K.K.#.b.b.b.b.K.K.K.T.S.V.9aB.ebNaV.p#9a9aB.D#9a9aB.A.A.A.9aB.B.Eafbn.t#g#hat#X#m..ay#y#y#y#.ay#v.v.v..aX.y#.av.v.v.",
+" #.K.K.#.K.K.K.K.K.K.K.K.K.QaT.V.7#Ea9af.f.2at#OaD#F#Q.J.9aEaB.Ea9a6.Ea9aEaV.H#H#t#2aD#J.v.m.y#y#y#y#X..ay#y#y#y#y#y#.ay#.av.",
+" K.K.K.K.b.b.b.b.K.K.K.K.g#g#t#D#fbWag#c#X#2a2aeb7#D#Q.vaA.2at#p#9a6.V.7#7#9avaSaSaSav.m.v.v.y#.ay#X.v.v.v.v.y#y#y#y#y#y#y#",
+" K.K.b.m.b.b.b.b.K.K.K.K.Ja7#7#6.2az.#ac#z.G#eaG#p#2a2a2at#t#t#t#7#9aD#J.SaL#RaRaF#v.v.v.v.v.v.y#m.v.v.a#a#v.v.M#M#M#y#y# ",
+" b.b.m.b.m.b.b.b.K.X.7#7#7#7#D#3.1.z.yac#yaibh#caB#L#eaz.z.z.z.z.F#h##ab##aL#ibibv.a#m.m.v.y#M#y#a#v.v.v.a#a#a#a#M# ",
+" p.b.m.b.b.m.b.b.m.b.7#9a9aSahb..m..ayayahbhbF.h#Ias.RaRaibibL.L#kab#bab#1.L.L.y#y#a#v.v.M#y#y#M#y#v.a#a#a#v.a#a# ",
+" b.m.b.b.X.K..aK.b.7#D#F#hbv#m.b.m.m.F.F.F.v#v#F.v#L.L.L.L#..ka6#h.s.1.L#1.y#M#y#daM#M#day#y#M#M#M#a#a#a#a# ",
+" p.b.X.X.X.X.X.X.X.9aD#6#..m..aX.y#m.m.F.v#v#v#....1.Ia....kakar#r#r#1.s.M#M#y#a#a#a#M#M#y#y#daM#dadada ",
+" .a.aX..aX..aX..aD#SaF..ay#y#.aX..am.m.........s.s.9.9.r#r#r#r#kakar#M#M#a#a#a#a#a#a#M#M#M#M#dadada ",
+" K.X..a.a.a.a.aH#vab#1.y#X.X.y#y#y#y#v.v...s.d.d.d.s.r#r#h.jajajar#a#M#v.a#a#a#a#a#a#P#dadadaM# "};
+ENDofIMG
+
+demo.show_image('xpm', 'color', "/* XPM */
+static char * teapot[] = {
+\"64 48 204 2\",
+\" c #145ec4#{teapot}")
+
+demo.show_image('xpm', 'transparent', "/* XPM */
+static char * teapot[] = {
+\"64 48 204 2\",
+\" s None c None#{teapot}")
+
+demo.show_image('xbm', 'bitmap', <<'ENDofIMG')
+#define flagup_width 48
+#define flagup_height 48
+static char flagup_bits[] = {
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe0, 0x7f, 0x00,
+ 0x00, 0x00, 0x00, 0xe0, 0x7f, 0x00, 0x00, 0x00, 0x00, 0xef, 0x6a, 0x00,
+ 0x00, 0x00, 0xc0, 0x7b, 0x75, 0x00, 0x00, 0x00, 0xe0, 0xe0, 0x6a, 0x00,
+ 0x00, 0x00, 0x30, 0x60, 0x75, 0x00, 0x00, 0x00, 0x18, 0xe0, 0x7f, 0x00,
+ 0x00, 0x00, 0x0c, 0xe0, 0x7f, 0x00, 0x00, 0x00, 0x06, 0xe0, 0x04, 0x00,
+ 0x00, 0x00, 0x03, 0xe0, 0x04, 0x00, 0x00, 0x80, 0x01, 0xe0, 0x06, 0x00,
+ 0x00, 0xc0, 0x1f, 0xe0, 0x07, 0x00, 0x00, 0xe0, 0x7f, 0xe0, 0x07, 0x00,
+ 0x00, 0x70, 0xe0, 0xe0, 0x05, 0x00, 0x00, 0x38, 0x80, 0xe1, 0x04, 0x00,
+ 0x00, 0x18, 0x80, 0xf1, 0x04, 0x00, 0x00, 0x0c, 0x00, 0xfb, 0x04, 0x00,
+ 0x00, 0x0c, 0x00, 0xff, 0x04, 0x00, 0x00, 0x86, 0x1f, 0xee, 0x04, 0x00,
+ 0x00, 0x06, 0x06, 0xe6, 0x04, 0x00, 0x00, 0x06, 0x00, 0xe6, 0x04, 0x00,
+ 0x00, 0x06, 0x00, 0xe6, 0x04, 0x00, 0x00, 0x06, 0x00, 0x66, 0x04, 0x00,
+ 0x7f, 0x56, 0x52, 0x06, 0xe4, 0xff, 0x00, 0x76, 0x55, 0x06, 0x04, 0x00,
+ 0x00, 0x56, 0x57, 0x06, 0x04, 0x00, 0x00, 0x56, 0x55, 0x06, 0x06, 0x00,
+ 0x00, 0x56, 0xd5, 0x06, 0x03, 0x00, 0x00, 0x06, 0x00, 0x86, 0x01, 0x00,
+ 0x54, 0x06, 0x00, 0xc6, 0x54, 0x55, 0xaa, 0x06, 0x00, 0x66, 0xaa, 0x2a,
+ 0x54, 0x06, 0x00, 0x36, 0x55, 0x55, 0xaa, 0x06, 0x00, 0xbe, 0xaa, 0x2a,
+ 0x54, 0xfe, 0xff, 0x6f, 0x55, 0x55, 0xaa, 0xfc, 0xff, 0xa7, 0xaa, 0x2a,
+ 0x54, 0x01, 0x88, 0x60, 0x55, 0x55, 0xaa, 0xaa, 0x8a, 0xa0, 0xaa, 0x2a,
+ 0x54, 0x55, 0x8d, 0x60, 0x55, 0x55, 0xaa, 0xaa, 0x8a, 0xa0, 0xaa, 0x2a,
+ 0x54, 0x55, 0x8d, 0x60, 0x55, 0x55, 0xaa, 0xaa, 0x8a, 0xa0, 0xaa, 0x2a,
+ 0x54, 0x55, 0x8d, 0x50, 0x55, 0x55, 0xaa, 0xaa, 0x8a, 0xa8, 0xaa, 0x2a,
+ 0x54, 0x55, 0x95, 0x54, 0x55, 0x55, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0x2a,
+ 0x54, 0x55, 0x55, 0x55, 0x55, 0x15, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
+ENDofIMG
+
+demo.show_image('png', 'color', <<'ENDofIMG')
+iVBORw0KGgoAAAANSUhEUgAAAC4AAAAjCAIAAAETQp8oAAAIVklEQVR4nNVXPYgbSRb+xm7B
+K5CgC07QtaCDOvBCDeyAFAxIwQYdbKCBDeTgQBMqtOGCcTYOvXDBODjwHBzsBHcwExzMBAtW
+4GN7YQ1ScKAOBNPBLFcLHugGC7pgBf0WeuGC1vz6h7XZ4O5DIJp69dX3qr969Rp4A3erv69H
+YQn8aasDxh0Aw66JTtPU5ZIIhLsAvIZXw9rLJItfvd74vVzNepPx3Rh2DQAPwPFO3zqenaaO
+GcAdAAdRkuf50TQxyv8Q0gqh0ZWYNQDD0GRpHrbVJHFRYvtGE9H9nr7/dAwg8OkugLldmFaz
+1fDLtXKj1eytt76fv9JKKkkmaE5/yFbMD0IzDA2A3UEbQFsHH6bs7rsGvt0dnC9yu1heRTwZ
+dKPkHMDhTj9OXp0tXpelCBp0F8DXo/DLjp5ni+3uxou5fXT/c5Tl/HwxPcvO3dIDkOXFxGYA
+0tz+5/neNJooRSqVqi1DE3iXqyhJp2n+1dODooBjVpKKAm2t7gAIpCACgHUlD6IkXFfj2HaN
+YnBs3Ur2oK0BHO/030zqDgBmVpIAVPv924AI7cDvt3X16L0/usKzUcjAo4MIwKjftjb1SRAR
+g6/UVjje6T8bhXvDlZ/3Rt3Di/QOJ6fa9wEMu6arJJFwXGSOT6b2NsvEppPTNMnSZ6Owa4I0
+5Ulsn+8OAIABIh34WvuCKIotAN/Hg377293BDRZFBCDNmQABxNbN0vwwig93BrHNJnHS1TLL
+nE/U7xqfJBhp6m5rAdDTSkkaz6xWUitSvhCCRk9Pjnf6StHR1BYFGGwUSYLRgZKUZO4Gi1Ey
+shYAEQE4iJJwPSgKMLD1dEwQAI6myf2n469O4rZWSorxzD48iFAdxcsXEZ1aJfyJtbF1/bYO
+TaCV/ACD+PRrI//3MOzeOC+/yrvX4RM96Lcz50ah8Wm1EXfePwdAaIKvR/1RaKrHve0wSTMA
+RYHMrU7A26vTs2HY39Tj2AJAWdYEDqOkBPaGYbJ4XTKWS14syyRdnF33S1v7Twbdb3cHO/02
+gJP4FMVFCpKIiIFh15Agm7rM5Qykeb5a5pJlFJrT1B1ESdjWD/pmkmRK0ZNRtxpNUzfsmszl
+He0nNo2SbBzbyrWhCa4yapuWcywEqFZblmXLl2se/JpQ0h/HPypJZ855pbeh1d++m5vA37yn
+7in55+3eX17EZXmhRQkBIM/ZprkkAlAwj2d2Z9ADUDBCo9e1ZObK0NUsAno6uMpIXnhX+jSz
+WeZYK+kTJok9ffZA+qKtVV5wASYSBBARAbHNK8YVi80LBjsUbSUlyCcIwDEe7o/jxFa+cK5w
+edEzgZJUERWMauiCJXMdHez2e0+jxLq8ykJJGvXbjw8nWx2tCFGSHU+tUTItWCuSAiDW/jUt
+xxNLwMOjKCDSSkpJWVEUBZjZOpfmeWWvqc2Ysd0zVU49rR4eRVcsjpkgKmICigJ7J7GSlOYM
+4NHR1KZ5Fbm9P54kqSTR0XLromhcnSMGtCQGADqaxv22BiG68FXljgpPx/Etr1+dI1+AiHyi
+/SgGsN0zkogvRg+iBL8Gxzv9qlP4eFye8f8/mOBG87b2rrjfHMc7/cTlKKClJEJi87ZRW1+d
+XAZ8cNV9P9o6eDzojGN73RfPdwdpxvvjWeBLZrbSFQU62mfm63N/GymBTx2tQqOVpP1xEiUr
+u/fbOuxom7loZisjEVFeMDPGcWayj5XSb+vtnk7zQiv55GSyagcBAFW7l2SpL3Wlwye639OD
+rnHMB9GMIHySjlcbQQQi2NT5hIub6EJKtbG54ywviJAzJ9Z1dNA1KrZpynwysePYjmM7Co0v
+5eNBL0rS/atzTbkrtPI7WgEYdo0QSHN2jnPmwgFUZAygmNjs5mu5wg3b+oRHg24BuEoqMwP9
+ts6ZT2ZWCwJB+X7qeNDWmXM508ODVYnqmkAAu6P7+4djx4VPomeCtlbMvPVG79PVwVZXE4TR
+FCf545Mpbl3QXKL/WWtdSbtY4sJULSkWeWE+qb9IUikEL1n9rv7P6Q+b91SNsB1+/v08WXLZ
+8LyG8DbX1XfJebEsG1RrNuvlz7UFMzNMS36mpJLStOQ9JQXVXi+WX2xq55YP//GyWv12r/Dl
+5qcN8uz5AkAJnKZ506/XBVyBl/GP1bfd5sYn38/Ts9R58DqfNj/f3PhjGB6+mJIg5zhc18uC
+Pc9rCmop0fLrLxNb92oM1D14WP0AqIZYlgBwdqtBvY604CRnm7MAfCGUL2c26xrdM0oH0qVF
+1fjHNus9OuA8VUgPdwZEAFj7xMwMntnMpnnmOPBldR0QkZQkJVXI8sIE/uVX6u1dMcpvNRtl
+WTYEbbb8L3t/yF6X4/mZzYqax3WvweBwo5XY5e/qxMuyLPngu6Srm8uyXFcytouWlH+fzL1f
+vB/yZVPWWlK2pHDlUklyy7LRIM/zxFq5VoNjbjUbZVl7MbdvkcI/8eanzWWJhVvOX7lv/n02
+P89Vs9HAWp0aUlKNUfcECSzc8l7L9+u1+bn7JrZfbLSIoJpkAvnXf83P3dItueF5Rknlk1cT
+S8bPv/BPZck/lbJBql43SjouyxKVlLcU/mejkFEcRtYEghlEJASKAlIgL+CYcy62jE7ZEcgx
+XxZWE/ijsFP1G9cJCXgy7PpCAOACKedaSkEAsL1/Ffm2ElfAKGkCJyWBwcWqDhDRUbQqJI/6
+nTRxDEQzezkvydzjk2hvO7xeuAAw8Oho+paFbuItUqQkgACkqVOSSICIolliL+hHoUkd5znW
+FVl3o2Ax4+FB5BMB7yhkHyQFgGPurfs2ZRCc42tVFcPQnNr8/V2Qe1dBfS9ue2Vv2CUhiGia
+2Oczm7mPIf04/BfyDD1tMD0WfgAAAABJRU5ErkJggg==
+ENDofIMG
+
+demo.show_image('png', 'grayscale', <<'ENDofIMG')
+iVBORw0KGgoAAAANSUhEUgAAAC4AAAAjCAAAAAG5S1ejAAAEJElEQVR4nKWTXUwcZRiFH2YG
+ZpiBLsx2wW6ZpU1YC+3axWClf7ZKY5NVozHRxIYaL0xq1YuGeOFVRW40TXthk4aLxsT/xJjG
++tdiGkUl1nQV6rYokuy2IFugy8/irp3dHXYGvFiwBdQ08Vx9+d73Oznfe84LAIjQNv+ELdBy
+aVqTRBSh/8p6aGMZWpDomBwwETg7020sL0NjG0XsTTT9GmlSdreji1xZ555bvzmyVvcNAI/s
+pRX/8lfi4uHoREIEnrnEKwNjcxUibdt+39PX6gwNTEkkB0l+3VPtdgclQI8fs0zd8gvoMkZX
+MBywY3B0Ox0FKoGcTvtKhQuQa5tBuvXmkHOCx4Y1xS7o6Qg29vFi6DvMe79paRjP5sIgAL/1
+jxwKJC4ewS72+kp7WfX4UQRgFUlBjA1/2R7t25DQdpbZiQJPU5V1xVMuqW+9ykc+X37WKJLC
+AmD8gkJX0HIOS3S3f+B3h48jAVNI0Viztbub4wCdC+rUf/3J7eEBOgr6l0Dbr4TUpffBl0Jw
+cARr5qYvL2wPM1d8bv65a3kzPTKKBHU7AuFT53eAS3FaSsdyynQcRGiNxXaVff9wfa+Of/rB
+T66OpgkmRNiYkkssj6CuDusJ6s4YDTUHTjsCuEiNauQu7MNqXJ8LekGoRwAVXNGkV+1/33Wn
+mVdERYx5EWDCttbJqpQ5NqCRSgV0UbE0BBjzP/XpBDn90Te3ll3q8aXXqGIVAvSInau8rrSV
+m5iaY9DaU6TUdyKAKVUhWh/qSU6Owmv9mv9wIQ+OxynqbpZ6IQ6cAgrzURXtc/ZoDnQtGWFH
+6z/OW/t/dhkARbfR2DGer5avbnyZZWleCv/+C13AkYmP3bkxqy73X+y6v9F9NgLNW8Sf7DJs
+yzI+X8ne3DK99r0YoDNSEUHbdb95RiozLWR5TM2ABP79fyRlc8gfiKZ7wuFQ5dOR01CU8vpp
+kZMp05St+UFrga4IQN3npMg7W2/8UCm5k9uT2TcgID7/rqkF/LnDANTvkNYNvlMIZn6L73re
+YfWMEdEynm8bSkIXs3Lppki21G3fsGpr3bU1yvS21InFHO8sjTMfryzNXIxbmyPXhPrm0Bkl
+fXdGKr/DfVl2ZEEQqJhl9O91SF+fFMtWR+8KeKdsogdSxe3ynCdnR0dn3IqmuFyKkqwxFtmN
+alutu2/qx3FRsZuGXFm7a8OsL+r5ikSFx53Vb5RJomBWO30L7WaDNTN8fthTrLrmZHnGVz58
+4Z4ST81nU3/Khl6SnbWy5ZVGxu5btOmQfa7GUmRLzZhmU0oyu8B4SOwEEJ/VsFJVCq/ftCm/
+xnDZOVC+gCd/dnqB+NsH1QzgnLzFxoX2CoGELiu9kxBKpo1JAOv4ygwvhsDcNC6lTgF7h25u
+g7mivaD9QKlyOZxcUVyJvwDv65E2xA9RYAAAAABJRU5ErkJggg==
+ENDofIMG
+
+demo.show_image('png', 'transparent color', <<'ENDofIMG')
+iVBORw0KGgoAAAANSUhEUgAAAC4AAAAjCAYAAAGcIAh/AAAIl0lEQVR4nOWYIXDjyNLHf7p6
+oMU0TIIDtcxhNhT0Mi9LoD+2y7JsF+6xhG3YBSYsYWt2gg6zWcS+gSM2w9RsPiDbiS/Z/e7u
+3b33ql5Xqcoujbp7unv+/+6B70i2//HLskn3G8f8xLJaO34COJ3WqX30+BgwIiCML7oYiKps
+Xcw+362pjDyp+Z6t/19Op3UC+AfA3fk8uahsHj1RFdgZv247QgjcPnRZXRV/3txBmtqmvecZ
+wGlTp94HmknFuou0nWNeW0SEdzPLu8tVBlAWkg4hnE9smtkSFyMAE1tx0z5y1rxh6zzDALcP
+3WE975s6nTbjlj8tJmn8qPwnAvh75NdPi9TUo5Wfnr/4spgeTN+cz5MtJF2u1kDO1JbpH/CU
+4AfnuTht0sfbNrNVxWJW03aOresz2KWwDwNr1wPgg+N/v12kh3ZNVQmVN1QTk5q6HBfvpTLC
+ow/8fHnNMEBUpTLCMIwh/QmgNDmyq7k3leG67bLmTcVq67JpXaEoWxefdryY2ARjVX0vMj8B
+6M4ccEjz3yoipElZpPnOQ+A4IL9Hvi6bpMDH6zYDWM4nyTlPITkigqKHtUdJvzufp6/LJl2c
+Ph3ci+U03TyL0836EVuMB+10WqdpZRDJiTrQR+X+wWWvKl87z/rR0/Wer8smTesyea+st45v
+nxajAR1jYMsiWVuQi9BuHQBFAe/nk/Trbu2R8mqXfx8UAXJg6yIbH7hpt9ycL9LW9ay3HVNr
+6PtIIcJ8WlOIAQXv4+thAZjZisoIq43DVgZbCVWRk+fC8vKeu/M5VSXcPrhsGEBR6kowArUt
+qYzQ9fGl8roytG7coux2MRZwyaiI7O3lKhNyYASNd5er7Of7bTaxFZXJWW0cH3bJPqrRr8sm
+tY+OKi9YO8fWxWw+sampS2xl/nxNF8LfjEz/qXI6fYkdf/iE/lYKkfR+PqGPkWVTp2IPZ7xS
+ij+Spi7TL8t5Wu6YBODirKHzI/AOA/Tx6fj/MPtfT5tEzqG0bCGpObHctB0K2cVpk1wMhKCo
+KlFBBFbbEQIOnk9skb4spunXT4t0Ph+57X77CMOzEBjZgRPZ6bROkgvOR/oYUMCHcFB8pHzZ
+1Dz6yHXb0Uws7+d1Wnc9VSV8WT6xmPeR02md+hg4sQWd87Rdn622Luv6mO3DB88S6nce5jm4
+PiIiLKY1nQ8Uec6ymaTrdpuZWpKPgQLBB8VFzeqySLYyByfPrlbHnlf5eKRDUJzfdVXAoMpq
+4zhfzHb/oaktb6xBVWnq8qAYQICZLY+Vm6cKwhTCxvX0UbGVoRBYd47Hr++TKXImtiIMyoAi
+kiOMWCTA1gX2xg7KXRhQlMjApDIYhEJG2I0KH65WbDvHvo5jHIhhYFaPSLg3MCiHNU/K+8iJ
+Lfk0n3HZdrgYDmGojLCcT/h8s+btiaUSaLs+u3tw1JXBD4qtBJMDotjiN57frR0CfLhtKUWw
+lcEYoR+GEW5VcTFmPoQDSz64PlOFs1kNjGU6sxUfbtvjOo+qmZAfrArjibu431KZsTIAPt4+
+ZM6HQ37OrlbZuvMYyTmxhrfPYPkIWxSwRnaeCbcP22w+sQnhwJPAgWn2crnavnrSj7ClyMek
+FCJcteMHZ7MaszuV+3XXbffHSePufJ72be1fKoXIfycT1WXxYuP/NBH9lXJ3Pk9dDDCANQYR
+6FxgUle8/fn+aO2/zPGJLdPnxQmrrXtRyN8+LZLvlavVhrIYsdaZyDDAiS1Q1Rf6/lbHy0LS
+ia1oaktlhKtVR9u5oyGzObG4PtJu3GEIEhHCoKjCattT93+h4/OJTWcziw8DtjJ8uV+zdfEo
+kvuZqes9hbEHpwuR9G5mWUxroirX7QYhpxBD1NHhcQPj43ykEFJUXgLiPpUhKn0YEIGgSudG
+/pjWFVvn8arcrx2rrctWWzc2WMbweTGj7Xy6OgJHIcQBWxWc2AoYp5w8H2eLGJWgyhABGRgD
+Ow62qj9up168LIT0cTFlAOK+KdNxOptPLEGV+43D5uNtS1UU+KgsJpY+RoIKH66fqGJalykH
+Pi3fcXWzIupAITmzumRiK1T1iFqey9SW6e3UIuTUVth2gc/3D8f8tpeoZAKc7JsQfRopVZUY
+BuZvSjY+oAq+j1SFcLnaIiKYAu4+LVNZjNgdd7yoGoiMTA8j3blecVFpapvmE5sWE5v2v+cT
+m0yRs+l6alsQox6cftVxANl1XTw7zY8+4MKA5BAH6H3k28axcYHC5Pg4cN12PLpAZeDq4xl3
+X86Tj0pQuG87Fic1tjTjEKdgCqjLAhiQ3WaKMZGHB8bgBB3P1Q8d34sflC4oLig5UOQ5VWHY
+uJ5pbZnVFbY0RD8cRv2t65l9vM40eCo8N+eLHVoothBUFUXZuB7nA31UysIc+gERwZjxkd3/
+PgzUZcHza7dXHd+3OnU1Lp7XJeeLE3SAm3WH6weiBoTxbqK2hkrM2BnqOHecXa6yR9fjY+Rs
+9gYfFB+VtfP4fmDrw+GurXlTYQzYaozx3mGT7xr5GMeLpOKph37V8XbjUFVyGSPUdj2fb9fc
+PDwiuWCLEbqMEQyC98pkRxS1LZjWI4L8z3WbqSoi0JyU2FLoo2YPrs9cH7POBQZVqkKoqwoQ
+8nxEsxAUEcEWBVNb4eMxln8XcsZboIGb1lGXOapjJPJ8bEpNDmF3pRZ04G1t8RoRZIfNT+xY
+l0VaNif7zvmFTYH05XRKsTtbOoDXgDWGfFfoZ1fH332fgIbxVqQuI8aMJaDD065FhNv2CbM/
+zk+S7yK6y9hz6fqYfb5v08VZ84JIYLxd+Xj78F1XXpPvOm7M07n2Po6Tzq6pbjcdLurB+LKp
+R/QI8KaSo3cH55Tsw3W7a3FfUvgflR9SflRl9qbAeQUZCenqN2PDaVOnRxd+9wQQ9eWm/oy8
+quTidJokH280HzrHt42jfyWK/075P4AQnUfVTZNLAAAAAElFTkSuQmCC
+ENDofIMG
+
+demo.show_image('png', 'transparent grayscale', <<'ENDofIMG')
+iVBORw0KGgoAAAANSUhEUgAAAC4AAAAjCAQAAAE2KcD0AAAFPElEQVR4nMXWXYicZxUH8N+z
+M3HezCy76axJzJrtR8jWVVc29IMtTTG6hUqqqL1QWlrxQmirXpTihRdSY4pUSws1IIEWBesH
+CAZFapNaSISgpUurJra2i7u2IWs+dpNMnbWzndfM9Hixs5tNmrYJCv7vHvi///ec85z/OQ/L
+kODeeMZ1fq+LsTjolIqixAejx3jqj5EFknfEWFBke5zwkga62O01+9LAO38INsW9QeKmmHG1
+vzrgapkttiWqkWA0hsziSr/1CX+T25fAp+Km4PZg8F2CfCseipGga+HwxYBvxur4hWQoigtp
+T7grHk3rbXHAVKJIzQRq9sZ+a/XpixHFBZGqaQ/LNVTlBnVRVcKAPWnEeBrWMrXw7+uD7WfF
+3EVTFdvSxaaiFJfFaGAxlLfinmj7fuIzcUhFpmUZfXvUND2a+Gr0uT+x1+cxFhsc1zDvQOrE
+CC97wWH3xHDM+JMHg5YV+uNSKz2PHrfEQ2eK24OaLgVTDnnKtpj0Rx8wo+IG3VpmLFNnSNW4
+futUZb7tW9b6Xcq1rFe2QdU/ztAHvIgMe9KIXDvdl4rYl7aln6VBfcbtSEupnkTRpKk0Grkt
+9mHHUsV3nl378kV31f8SH1/qkbe91UVU4hanbI0ylhXybIzE12JrwN0OI/caOqPgDL4SK+xI
+rI5rPK2d7opZdU3zSsYXC7kxNhs2blf6g82gV6adxmKlo5oyp0yf6Zmtpu1xrc/Gi9a6O2DG
+WJyy0SsOpvE0nRiJjvq/UHJUZovDun0ynkyVOKak5kQaiH7c7IFF9V7UHVFB07NuQ26TKzSN
+RH+nJkOL9HIn3kk1/cpe8NPodaWG0zIFmYIp/Yv0WS25y5WUFc172EsqqKsbVlWQyVUW6UcN
+utWvzVow9Kf9wHW6HUz7XWrOOmUFaxbp+xXs1KNfrzm5ptl00puYSLkbJZkhO1OH3khFa1CQ
++7mqGh5LR8AD6QUVg+5Ly3qmbbW2ZF8ajaLnwXTnpnctu/lOz5RlKp5I3KiinWDP2w+k7XH7
+hVuk8v9008DSz9/VTBeG7XHMaWuVvOJDvv7fiA/GHZ5dKvODMeuX+jQdlduoucS7yMVQjUGb
+9Nndmd6jca2C57R0oyWXG/BEuoDIR2PMKe/3E1MdehWHrXIgUYmP+piGJxV1a8hRUnJUOebP
+NONg3OGfakoaXjVo2KQ5+42ncVvjEl9wIH6VFhKt6zeIsSipqWtoKMmFCfk5dVg6luM2bXWc
+1nad1z3jEkV9aq5X84bvJRiOgi/7sYaKYYOaHcssYCg2K7rchMfTslk6nwqu6EjTVHeVQ3Iz
+qnbJ9PhuVIM65v1bjrbjTtoUo3F9bIrRGI1eL9tgzuPL9ymsxGkwbVbJvBnjpqxSs9srqr7h
+kaiZt9cN+mVaeqwXCtrKCgoKOG7ewlPgnC0w57gTCrq916SPGNbvpBYm3ZnqVtim5E2rNbVM
+OuI1fTIVmV69Mpma9RYedcvEj2DAgKvcqmmvY15X1LJBr4qW1XF/+rtTblRTM2HWIbMY0WMd
+Mpmyklnz+s4Vf05TpumgH9ons1q3XiUzNmq6wjAeSU3vcY33qaWJdDS96g1Vl0lKGuoyawyp
+ndstcE+0PG29XKYkVzavoeFqdUWNjicH4maFZW+DQnxJBbm6NTJ853wmOm2dAb1aHQtnfpPg
+c/Fn7c4oZjr9KO5eMgrt9Jjz4yzxVbowo6ok87wTCbZGzZyBzgnytOOCBu859m/4sGOK6ktL
+4qZ49byboHEBU2kZ5c5YKfMX42oX/849L/4D4jD0vGNZ6YMAAAAASUVORK5CYII=
+ENDofIMG
+
+demo.show_image('jpeg', 'color', <<'ENDofIMG')
+/9j/4AAQSkZJRgABAQAAAQABAAD/2wBDAAgGBgcGBQgHBwcJCQgKDBQNDAsLDBkSEw8UHRof
+Hh0aHBwgJC4nICIsIxwcKDcpLDAxNDQ0Hyc5PTgyPC4zNDL/2wBDAQkJCQwLDBgNDRgyIRwh
+MjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjL/wAAR
+CAAmADkDASIAAhEBAxEB/8QAHwAAAQUBAQEBAQEAAAAAAAAAAAECAwQFBgcICQoL/8QAtRAA
+AgEDAwIEAwUFBAQAAAF9AQIDAAQRBRIhMUEGE1FhByJxFDKBkaEII0KxwRVS0fAkM2JyggkK
+FhcYGRolJicoKSo0NTY3ODk6Q0RFRkdISUpTVFVWV1hZWmNkZWZnaGlqc3R1dnd4eXqDhIWG
+h4iJipKTlJWWl5iZmqKjpKWmp6ipqrKztLW2t7i5usLDxMXGx8jJytLT1NXW19jZ2uHi4+Tl
+5ufo6erx8vP09fb3+Pn6/8QAHwEAAwEBAQEBAQEBAQAAAAAAAAECAwQFBgcICQoL/8QAtREA
+AgECBAQDBAcFBAQAAQJ3AAECAxEEBSExBhJBUQdhcRMiMoEIFEKRobHBCSMzUvAVYnLRChYk
+NOEl8RcYGRomJygpKjU2Nzg5OkNERUZHSElKU1RVVldYWVpjZGVmZ2hpanN0dXZ3eHl6goOE
+hYaHiImKkpOUlZaXmJmaoqOkpaanqKmqsrO0tba3uLm6wsPExcbHyMnK0tPU1dbX2Nna4uPk
+5ebn6Onq8vP09fb3+Pn6/9oADAMBAAIRAxEAPwDzLyJSuV5FIsUm4DAzW1Ywpb3sbPhoQ4LA
+jPGea6jWdH0W6EdxYLJA78gICUb169KIq8JTutDWnSnUmqcFds4y2e5jkzGrOVGTt7Ct2aae
+ZFzGSR6cmni1t4RiFWCseRknJHf+f51MsZG4JHwP4hXmVaqctEfVYDLqsKbTla+43S7NZLkr
+dHamMEgg9R6isDVtDu7KdjFGZoOodOcD3rowWIVRkbDuUHI3DFbWnOs1n9pIIMZwwIzyBxwe
+v/16ujWs9iK+VQqfFN3W3Yo6Pp/n6LbXFx9rWeCNifLbjac9T6YxXN+a/wDzy/SvedC13S5/
+DtnZ3ckZmMQSVVTK8cYJ6HI96tfZvC3/AD42/wD35NdfM5dT5Pdtp3PBtEji1CVTtyR1U9vc
+11WpXOnRW9rYwWxB6O+/n2OOgrm40EZyg2n2rTm8M6xp+lrrk1q76bIu4hcMwB74zkD3/TFV
+KcXRcFHXudWGm6deM+axUmCQytGjrIi8Kyg81NFKrxqogVsMWk5OH78j8/YfnQ1hKlrbXU8F
+xCk43ws67d4/L3H5j1rLurqVLhhno2RXlKErn2f1qEIKV7xL77QN21VxwMdqdLdvBpbpDveS
+5cJGiHBzyMj8/wBB61i3OoySJjhR3C0+71FYYfIjncSgbSUOMj0J/mBW1OlJSuzz8fmsY0nG
+kvQ6qO4ubaLyt8fnR/Idh3AEdfyNQeVrH/QQuf8Avv8A+tWd4fu0j0dePnEjIM+vU/zqz/aq
+f8/J/wC/h/xotNSaifEO6bsVo1yy8DmvetkF3HbaW0INuYFMiYwpXA4wKKK7Y7HWtzSvNPs7
+ywezurdJLYrjyyOgx29D6EcivGviF4EtfDlnFqVpeSvFLMsPkSKCVJVjncO3y9MfjRRRUirX
+NKdWcfdi9DhbW3YRS3a7cW+GOepycDA+vWsaS3AcqScjvRRUU9zOcnLVlqx8+Elll43qoH1r
+K2L70UVaerMluf/Z
+ENDofIMG
+
+demo.show_image('jpeg', 'grayscale', <<'ENDofIMG')
+/9j/4AAQSkZJRgABAQAAAQABAAD/2wBDAAgGBgcGBQgHBwcJCQgKDBQNDAsLDBkSEw8UHRof
+Hh0aHBwgJC4nICIsIxwcKDcpLDAxNDQ0Hyc5PTgyPC4zNDL/wAALCAAmADkBAREA/8QAHwAA
+AQUBAQEBAQEAAAAAAAAAAAECAwQFBgcICQoL/8QAtRAAAgEDAwIEAwUFBAQAAAF9AQIDAAQR
+BRIhMUEGE1FhByJxFDKBkaEII0KxwRVS0fAkM2JyggkKFhcYGRolJicoKSo0NTY3ODk6Q0RF
+RkdISUpTVFVWV1hZWmNkZWZnaGlqc3R1dnd4eXqDhIWGh4iJipKTlJWWl5iZmqKjpKWmp6ip
+qrKztLW2t7i5usLDxMXGx8jJytLT1NXW19jZ2uHi4+Tl5ufo6erx8vP09fb3+Pn6/9oACAEB
+AAA/APMvIlK5XkUixSbgMDNX7Z7mOTMas5UZO3sK3Zpp5kXMZJHpyan0uzWS5K3R2pjBIIPU
+eorA1bQ7uynYxRmaDqHTnA966/R9P8/Rba4uPtazwRsT5bcbTnqfTGK5vzX/AOeX6VFYwpb3
+sbPhoQ4LAjPGea6jWdH0W6EdxYLJA78gICUb169KzBa28IxCrBWPIyTkjv8Az/OpljI3BI+B
+/EKcCxCqMjYdyg5G4Yra051ms/tJBBjOGBGeQOOD1/8Ar16PoWu6XP4ds7O7kjMxiCSqqZXj
+jBPQ5HvVr7N4W/58bf8A78mvBtEji1CVTtyR1U9vc11WpXOnRW9rYwWxB6O+/n2OOgrDmCQy
+tGjrIi8Kyg81NFKrxqogVsMWk5OH78j8/YfnUT7QN21VxwMdqdLdvBpbpDveS5cJGiHBzyMj
+8/0HrWnHcXNtF5W+Pzo/kOw7gCOv5GoPK1j/AKCFz/33/wDWrIjQRnKDafatObwzrGn6WuuT
+Wrvpsi7iFwzAHvjOQPf9MVE1hKlrbXU8FxCk43ws67d4/L3H5j1rLurqVLhhno2RVa51GSRM
+cKO4Wn3eorDD5Ec7iUDaShxkehP8wK0vD92kejrx84kZBn16n+dWf7VT/n5P/fw/41WjXLLw
+Oa962QXcdtpbQg25gUyJjClcDjArSvNPs7ywezurdJLYrjyyOgx29D6EcivGviF4EtfDlnFq
+VpeSvFLMsPkSKCVJVjncO3y9MfjXC2tuwilu124t8Mc9Tk4GB9etY0luA5Uk5HerVj58JLLL
+xvVQPrWVsX3r/9k=
+ENDofIMG
+
+demo.show_image('jpeg', 'progressive color', <<'ENDofIMG')
+/9j/4AAQSkZJRgABAQAAAQABAAD/2wBDAAgGBgcGBQgHBwcJCQgKDBQNDAsLDBkSEw8UHRof
+Hh0aHBwgJC4nICIsIxwcKDcpLDAxNDQ0Hyc5PTgyPC4zNDL/2wBDAQkJCQwLDBgNDRgyIRwh
+MjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjL/wgAR
+CAAmADkDASIAAhEBAxEB/8QAGgAAAgMBAQAAAAAAAAAAAAAAAAQDBQYBAv/EABkBAAIDAQAA
+AAAAAAAAAAAAAAECAAMFBP/aAAwDAQACEAMQAAABzA7aRqV/vvl1eIWLrCCt3stuTgrWtaNs
+PsV5dljqXX57XwtLMSLehdazjQjUSQBZVQK//8QAHhAAAgIDAQEBAQAAAAAAAAAAAQIAAwQR
+EiEQBRP/2gAIAQEAAQUC0ZoxegSSZUm2toZDTXuncQcvdTS05UTXyv1KL6jj84spAsNjVhT4
+QfIW1UGZRq6DyHGurq4PLMemsJjWaGO2qf6wTxg9aOn6GCuOir4VibHz/8QAHxEAAgEEAgMA
+AAAAAAAAAAAAAQIAAwQQERIxEyFB/9oACAEDAQE/AVUseIlC3YL3HtQ3ZxTPFwdzygDfyV7o
+BdLlWI9CE7x//8QAGxEAAwEBAAMAAAAAAAAAAAAAAAECESEQEjH/2gAIAQIBAT8BXxsqukWb
+o2vTMMZMvTu8EUifH//EACgQAAEDAwIDCQAAAAAAAAAAAAIAAREQITESUQMiMhMjM0FScYGR
+of/aAAgBAQAGPwKllhcys0shItUs3ksJtkxBLKyxTVsgAnaYuugfqggwqMrHvS2SwotLLxCp
+27j3boSdiacVhnuvldX7QeFHLF1oIZHZNxBN4d4h05emmaf/xAAgEAEAAwACAgIDAAAAAAAA
+AAABABEhMUFRcWGBEJHx/9oACAEBAAE/IcshZFgLXiHkBRkjX2ZMMXcupaDQ7fZRlXxwzq2m
+HKvtNw8afMR+4nAyQDPwUhn1PcOblWCA4SAgq7fyjXNBFYupQJoHCzZ/Qg6ZDC0rzWJF3bSr
+hl7gHj1CvvTIIebEpAaSnHFp1UQioh8wNbjHv6jUa7TSpzzsEon/2gAMAwEAAgADAAAAEIb7
+MuvRaP43Yv/EABoRAQADAQEBAAAAAAAAAAAAAAEAETEhUXH/2gAIAQMBAT8QGjax8NL2bzZn
+k1Ubj8VKe1w5H5Gxahs6xyN0w2f/xAAaEQEBAQEBAQEAAAAAAAAAAAABABEhMUFR/9oACAEC
+AQE/EBu05G8Fg+WvqUj1+xtC02FE8QZt6h63/8QAJBABAAICAgIBBAMAAAAAAAAAAQARITFB
+UWGRcaGx0fCB4fH/2gAIAQEAAT8QvtkSkKLl8RFvQllJTrLEKYaUR2dkTm2mejzMlLHRa9vV
+VP3kopAoS8XmEZJwK929QBQEyWtpz9/cQpiOEFAWXobKVLxEVQS8hjDv+46IjecMUumzzP8A
+cRqyTa48sXGOt/w1ogxTIDmGiosjXPJ78HuVGgwVxK9tt03ks9/Q7nZ8b0E36Z+z/EFWbeJY
+AwKAPNXYefpUHWepPryezuBl6sSs4HJFYsll1Z0v3CYYxDfe37zz/b8yzAZldCmppUMURDFp
+Y0Vx09JklKrxFSl046V/MBjlFe22ij53AGls5lpwah8z5p//2Q==
+ENDofIMG
+
+demo.show_image('jpeg', 'progressive grayscale', <<'ENDofIMG')
+/9j/4AAQSkZJRgABAQAAAQABAAD/2wBDAAgGBgcGBQgHBwcJCQgKDBQNDAsLDBkSEw8UHRof
+Hh0aHBwgJC4nICIsIxwcKDcpLDAxNDQ0Hyc5PTgyPC4zNDL/wgALCAAmADkBAREA/8QAGgAA
+AgMBAQAAAAAAAAAAAAAAAgQDBQYBAP/aAAgBAQAAAAHMenfNC3rRtFT67pJcFaomPWQTaBWP
+rMsW9ZxtElKr/8QAHhAAAgIDAQEBAQAAAAAAAAAAAQIAAwQREiEQBRP/2gAIAQEAAQUC0Zox
+egSSZUm2toZDTXuncQcvdTS05UTXyv1KL6jj84spAsNjVhT4QfIW1UGZRq6DyHGurq4PLMem
+sJjWaGO2qf6wTxg9aOn6GCuOir4VibHz/8QAKBAAAQMDAgMJAAAAAAAAAAAAAgABERAhMRJR
+AyIyEyMzQVJxgZGh/9oACAEBAAY/AqWWFzKzSyEi1SzeSwm2TEEsrLFNWyACdpi66B+qCDCo
+yse9LZLCi0svEKnbuPduhJ2JpxWGe6+V1ftB4UcsXWghkdk3EE3h3iHTl6aZp//EACAQAQAD
+AAICAgMAAAAAAAAAAAEAESExQVFxYYEQkfH/2gAIAQEAAT8hyyFkWAteIeQFGSNfZkwxdy6l
+oNDt9lGVfHDOraYcq+03Dxp8xH7icDJAM/BSGfU9w5uVYIDhICCrt/KNc0EVi6lAmgcLNn9C
+DpkMLSvNYkXdtKuGXuAePUK+9Mgh5sSkBpKccWnVRCKiHzA1uMe/qNRrtNKnPOwSif/aAAgB
+AQAAABCrPPK25v/EACQQAQACAgICAQQDAAAAAAAAAAEAESExQVFhkXGhsdHwgeHx/9oACAEB
+AAE/EL7ZEpCi5fERb0JZSU6yxCmGlEdnZE5tpno8zJSx0Wvb1VT95KKQKEvF5hGScCvdvUAU
+BMlrac/f3EKYjhBQFl6GylS8RFUEvIYw7/uOiI3nDFLps8z/AHEask2uPLFxjrf8NaIMUyA5
+hoqLI1zye/B7lRoMFcSvbbdN5LPf0O52fG9BN+mfs/xBVm3iWAMCgDzV2Hn6VB1nqT68ns7g
+ZerErOByRWLJZdWdL9wmGMQ33t+88/2/MswGZXQpqaVDFEQxaWNFcdPSZJSq8RUpdOOlfzAY
+5RXttoo+dwBpbOZacGofM+af/9k=
+ENDofIMG
+
+demo.show_image('tiff', 'uncompressed', <<'ENDofIMG')
+TU0AKgAAHggAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+AAAAAAAAAAAAAAAAAAAAAAAAAADb///bttu2tv+Sttu2ttvb2/8AJEkAAAAAAAAAAAAAAAAA
+AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD////b//+229u2
+29vb2/+2ttttttu2ttu22//b//8AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+AAAAAAAAAAAAAAAAAAAAAAAAJAC229skbZLb//+2tv8AJEkkbZJtkrbb///b//9tktvb//8A
+AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACSttu2
+29u2ttvb2/8AAAC229skbZIAACSSttu229uSttsAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACQAAAAAAAAAAAAAJCQAJCSSttsAAACS
+ttvb//8AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+AAAAAAAAAAAAAAAASUkAAABJbZIAACQkAACStrYASQDb2/8AAAAAAAAAAAAAAAAAAAAAAAAA
+AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD/////29v//9v/29v///8AAAAAAAAAAAAAAAAA
+AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+AABtJACSbSS2bUnbkm22km3btm22kkn/25L//9ttJAAkAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACSSSSSSSTbkm2SSSSSSSSSJACSSSS2
+bUm2bUm2bUn/27b//9v/////////////27b/tm3btm3//9v/27b//////////////9skAAAA
+AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+AAAAAAAAAAAkAABJAAAAAACSSSRJAABtJABtJACSbSSSSSTbtm22km3btm3btm3btm22km3/
+km22bUn/25L/27b/25Lbtm3btpLbkm3/27bbtpLbtm22km3/25L/27b//7b/27b//////9v/
+/////9v/////tpL/km1tJAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABtAABJAABJAABJAACSJCRJ
+AABtJABtAACSSSRtJACSbSSSSSTbkm222222km22bUm2kknbtpLb25K2km22kknbtpLbtm3b
+tpLbtm22km3btpK2km3btpLb25L//9v/25L/25Lb29v//7b/27b//7b/27b/25Lb29v/27bb
+tpL//9v//////7b///////////////+2bUkAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+AAAAAAAAAAAAAAAAAABJAABJAABJAABJAABJJACSSSSSJABtSQCSSSSSSSSSSSSSJCSSSSS2
+bUmSSSSSJABtJABtAACSSSS2kkm2bUnbkkm2kkn/25K2kknbtm22km3bkm22km3/tm3btm3b
+tm3btpLbkm22km22kkm2kknbtm3bkpL/25L/27b//7b/27b//7b/////tm3btpL/27b/tm3b
+tpLbtm3//7b/25L//9v/////////////////////2/8AAAAAAAAAAAAAAACSSSQkAABtJABJ
+AABtJABJAABJAABJAACSSSRtSQBtJABtSSS2kkmSJCSSJCSSSSSSSSSSSSSSSSSSSSSSSSRt
+JACSSSSSSSS2bUm2km3//9u2bUm2bUm2bUm2SSS2bUm2bUm2km2SSSSSSSTbtm3btpL/25K2
+km3btkm2km3btm22km3bkm3btpL/25K2tm3bkm22km3btm22bUm2bUm2bUm2kkm2bUnbtm22
+tm3bkm3b25L//9v///////////8ADgEAAAMAAAABAEAAAAEBAAMAAAABACgAAAECAAMAAAAD
+AAAetgEDAAMAAAABAAEAAAEGAAMAAAABAAIAAAERAAQAAAABAAAACAESAAMAAAABAAEAAAEV
+AAMAAAABAAMAAAEWAAMAAAABACgAAAEXAAQAAAABAAAeAAEaAAUAAAABAAAevAEbAAUAAAAB
+AAAexAEcAAMAAAABAAEAAAEoAAMAAAABAAIAAAAAAAAACAAIAAgSwAAAAAQAABLAAAAABAAA
+ENDofIMG
+
+demo.show_image('tiff', 'packbits compressed', <<'ENDofIMG')
+TU0AKgAABAqBAMEAgQDBAIEAwQCBAMEAgQDBAIEAwQCBAMEAgQDBAIEAwQCBAMEAgQDBAIEA
+wQCBAMEAgQDBAIEAwQCbAAvb///bttu2tv+Sttv/tv7bA/8AJEm8AKEA/v8G2///ttvbtv3b
+Df+2ttttttu2ttu22//b//+/AKMACCQAttvbJG2S2////7YR/wAkSSRtkm2Sttv//9v//22S
+/9v//8IAoQADkrbbtv/b/7b+2wD//gARttvbJG2SAAAkkrbbttvbkrbbwgCcAAAk9wD/JAUA
+JCSSttv+AAGStv/b///CAJcA/0n+AAJJbZL/AP8k/wAIkra2AEkA29v/wgCBAMEAgQDBAIEA
+wQCBAMEAgQDBAIEAwQCBAMEAgQDBAIEAwQCBAMEAgQDBAIEAwQD9///b//8B2///2/7/gQDQ
+AB5tJACSbSS2bUnbkm22km3btm22kkn/25L//9ttJAAkgQDgACOSSSSSSSTbkm2SSSSSSSSS
+JACSSSS2bUm2bUm2bUn/27b//9v3/w3btv+2bdu2bf//2//btvb/AdskigADJAAASfwAU5JJ
+JEkAAG0kAG0kAJJtJJJJJNu2bbaSbdu2bdu2bdu2bbaSbf+SbbZtSf/bkv/btv/bktu2bdu2
+ktuSbf/bttu2ktu2bbaSbf/bkv/btv//tv/btvz/ANv8/wDb/f8GtpL/km1tJLUAYm0AAEkA
+AEkAAEkAAJIkJEkAAG0kAG0AAJJJJG0kAJJtJJJJJNuSbbbbbbaSbbZtSbaSSdu2ktvbkraS
+bbaSSdu2ktu2bdu2ktu2bbaSbdu2kraSbdu2ktvbkv//2//bkv/bkv7b//8Mtv/btv//tv/b
+tv/bkv7bCP/bttu2kv//2/z/ALb1/wK2bUnXAH9JAABJAABJAABJAABJJACSSSSSJABtSQCS
+SSSSSSSSSSSSJCSSSSS2bUmSSSSSJABtJABtAACSSSS2kkm2bUnbkkm2kkn/25K2kknbtm22
+km3bkm22km3/tm3btm3btm3btpLbkm22km22kkm2kknbtm3bkpL/25L/27b//7b/2wO2//+2
+/f8Ztm3btpL/27b/tm3btpLbtm3//7b/25L//9vx/wHb//UAAZJJ/yT/AH9tJABJAABtJABJ
+AABJAABJAACSSSRtSQBtJABtSSS2kkmSJCSSJCSSSSSSSSSSSSSSSSSSSSSSSSRtJACSSSSS
+SSS2bUm2km3//9u2bUm2bUm2bUm2SSS2bUm2bUm2km2SSSSSSSTbtm3btpL/25K2km3btkm2
+km3btm22km3bkjBt27aS/9uStrZt25JttpJt27Zttm1Jtm1Jtm1JtpJJtm1J27ZttrZt25Jt
+29uS///b+P8ADgEAAAMAAAABAEAAAAEBAAMAAAABACgAAAECAAMAAAADAAAEuAEDAAMAAAAB
+gAUAAAEGAAMAAAABAAIAAAERAAQAAAABAAAACAESAAMAAAABAAEAAAEVAAMAAAABAAMAAAEW
+AAMAAAABACgAAAEXAAQAAAABAAAEAgEaAAUAAAABAAAEvgEbAAUAAAABAAAExgEcAAMAAAAB
+AAEAAAEoAAMAAAABAAIAAAAAAAAACAAIAAgSwAAAAAQAABLAAAAABAAA
+ENDofIMG
+
+if false
+demo.show_image('tiff', 'pixarlog compressed', <<'ENDofIMG')
+TU0AKgAAA3Z4nO2aIWzbUBCGz7HjYyVTNDAp0CgKDRorCauiSGFjRmWRxs0rlQ2FlUWKrLKQ
+sIDK1BoyjFRUjZSF7f13eYnjpZOmdeuU3Wc1se+dn17uf/ee5SuRYRiGYRiGYRiGYRiGYRiG
+YRg/YxVt3EG04IpLJkqocJ8VD6S1746ELsOP8UNMxO1J9MbDPQs2EvOKcV66uOsZoo34lwxb
+JraMfEsif+S06Lrj74/5XNi2iG6jdbCKruMRz3gdfKUbF/OFi/c0vHbzfNvqBDl1giENKHdt
+492dI/7sdIElMRV+i0l0G62igcx3ZMBhnUFc0ebV4fZzeBfDfx2ofyGr1DycOt+3/RXnALIB
+63rTqnYo9SVYBxptVS11+WDz//WZh/MQ8Z5E8/AiwjdmPnTg9qfg1sV+Hn7gabiK3gWbSDPl
+rcdsGIZhGIZhGIZhGIZhnCebXc1IKxeJ2LSGkbija+8G/zAXEd4LDqkTbFuo091T312l8iYd
+79JhK7ngGY+dNSfoklKP38eX4VOMt73NN77Gr4B3tP4NOeLbCWY84qfYt18x4ntPUCd133XG
+zv+RSOp5RD57DlRSiSo5Y59RY1HQV2fH1KRyunbDy/D/0VRjr3HVirQqMuJJxO2UvDY+R4hm
+DKUe3RXywudIHbVrdBe8lNzJJfK08y2kQr5k7RfXS0ZeZaJNIfYl+35S8dF7j1fI8dHV8fmC
+P7P23OO7+Dl8/idVvZCYz7hpz6VyNHKz/6ACxj8kqLNk5MWxIrkoktKhP0Re49uX+qtWxUtn
+1cjP2Nvhi8/h7vyg7FDUXLKe+7o6tEKs/bgrGUEiFfdTeqji6qN1evSaiLYH34X4/piVaOnx
+Qzx1Gr72f03MX9xdEdlcVh5dhZaMLBkS1XJCuZJxo1XXKOwWsOld6nPQbiC9asT70l+5+93Q
+cMFY//rSk1eBaj7IgaoxW3wGlXu710X7QetwpxnRqTxSEHlEupJZk+x3v2xnIRk1VMvk3oJp
+32tz7a2Du7svVNl0tUFdmtt+NiNWOuf1vE6+m/8aUR/5bSuTqBYu06/2UTjeLU7h8+h+r6nf
+ZfAMMKYbUaTH3+Lj+1Tf+n4E/6K2c+kKqS26Py0k7xDTmcz+tPZ04VUmyTLvX4p/wdR4Gsm4
+uV54beCT1Z5edCVNpc/TSn0HoOsh4gAOAQAAAwAAAAEAQAAAAQEAAwAAAAEAKAAAAQIAAwAA
+AAMAAAQkAQMAAwAAAAGAjQAAAQYAAwAAAAEAAgAAAREABAAAAAEAAAAIARIAAwAAAAEAAQAA
+ARUAAwAAAAEAAwAAARYAAwAAAAEAKAAAARcABAAAAAEAAANuARoABQAAAAEAAAQqARsABQAA
+AAEAAAQyARwAAwAAAAEAAQAAASgAAwAAAAEAAgAAAAAAAAAIAAgACBLAAAAABAAAEsAAAAAE
+AAA=
+ENDofIMG
+end
+
+if false
+demo.show_image('tiff', 'logluv compressed', <<'ENDofIMG')
+TU0AKgAAAAgADgEAAAMAAAABAEAAAAEBAAMAAAABACgAAAECAAMAAAADAAAAtgEDAAMAAAAB
+h3QAAAEGAAMAAAABAAIAAAERAAQAAAABAAAAAAESAAMAAAABAAEAAAEVAAMAAAABAAMAAAEW
+AAMAAAABACgAAAEXAAQAAAABAAAAAAEaAAUAAAABAAAAvAEbAAUAAAABAAAAxAEcAAMAAAAB
+AAEAAAEoAAMAAAABAAIAAAAAAAAAEAAQABASwAAAAAQAABLAAAAABAAA
+ENDofIMG
+end
+
+demo.show_image('tiff', 'jpeg compressed', <<'ENDofIMG')
+TU0AKgAABID/2P/AABEIACgAQAMAEQABEQACEQD/2gAMAwAAAQACAAA/APn+vn+vn+iiiiii
+iiiiiiiiiiiiiiiiiiiiiiiiiiitK28O63e28VxaaNqE8ExIilitXZXIODtIGDyCOPStO18O
+a5e28VxaaNqNxBLny5IrV3V8Eg4IGDyCPqDWtZ+FvEOo2kd3Y6Dql1bS/wCrmgs5HR+SOCBg
+8gj6g1m1mkEEgggjqDWUysjFWUqwOCCMEGikpKKKKKKKKKKKKKKUHBB449RRXdXHxU16+nt5
+Ll1j8li5MDOTIxdWJYOzKSMMF3KwG4jHTHo83xl8QXs8U92Y1aJWASAMAxZkO472ZSQA4G5W
+A3YwRjb6mfjj4guZ4pblYYhEr/u7VWHmMzIcszuwyAHC5Vgu7G054x/GPiGDxNqtvqEcLRz/
+AGcR3LFAvmSB3wwwTxsKcEnbjaCQorA8e+J7bxbrdvqcEDRzfZViunaNU82QM3zgAnjaUGCT
+jG0HAFcx8QfFlt4z1221aK18i4+yrFdt5ap50iu+HwCTymzgkkY25IUE87XLVydFFFFFFFFF
+FFFFFFFFFFFFFFFFFFe2vceH9WtktdR8KaRGsEu53hjW2Z8ZH3o1jP8AeG32B6/d7l/E9hqU
+ENvqHhjSkWKUNKUt47Z2IJHDRiM+oK5xx7Db0t34mjvrWK3u9F0vEcoeUxWkdvI2MjAaJUOO
+eV6d/TFlfhp4BvnlmZtYtCHG6G3uUKJk9F3Izce7ZP542IfDXgG5trm4uv7YtJlOfJhnURAs
+TiNMxuxwM43NkgZ61p2lh4Lube5muodVhmDMdlvdII0JJwqgxuxA46tkj8cT23wi+HtwIsat
+raF/veZcQx4PoN0QJ+vA4zV+x8C/Dm6it92rauJJOH33McIVs8gb4cnjvwDjOfS5p+geAZoo
+BcXuqmWRQGYXEcKo2eRhoiTgc54HB554zofgFayMfM8XeSp+ZC2nggr0/wCeo7+38jitB8H9
+OLAXfi9bVXXfG72PyuucZB8z1BH4fXEUHw70/wDdte+IzaxyLvjZrLO5ckZA3jnIx6Z79cNm
++AEUkFwNO8YQXF3EuRFLYtGh/wB5w7bRjnODS3HwYtJYpF0fxfbXlzHgvHNZvEqg9CWVnwMc
+5x0/HEt18NNPc+VpPimG7uVAaRJ7NokQHHJZWf37c44zms4fs++JyCf7Y8P/AC5zi5lOB68R
+9ODVdfgZr7KP+J54fDEkbBcysw9yBGePft3qOH4S6lLGr/2/oCgnH/HxK2PQnbGeD69B3xkZ
+w7z4N+MrW8lgjs7O5RGwJor+FUf3AdlbGeOQOlYM/wAL/E0V08McdhOik7ZV1CGNZAP4gJGV
+sfUDofSsV/Aeti9kt4jYShSdsxvookcDuPNZTjnuAfbg1n6h8MPGumiMy+HbybzM4+x7brGM
+Z3eUW29e+M846GoL34aeMrHZu8P3dxuyM2O26C4x97yi23qOuM0tz8PPFlvs2aLNeb8/8g90
+vNuMfe8ktt68ZxnnHQ1//9kAAA8BAAADAAAAAQBAAAABAQADAAAAAQAoAAABAgADAAAAAwAA
+BToBAwADAAAAAQAHAAABBgADAAAAAQACAAABEQAEAAAAAQAAAAgBEgADAAAAAQABAAABFQAD
+AAAAAQADAAABFgADAAAAAQAoAAABFwAEAAAAAQAABHcBGgAFAAAAAQAABUABGwAFAAAAAQAA
+BUgBHAADAAAAAQABAAABKAADAAAAAQACAAABWwAHAAABIQAABVAAAAAAAAgACAAIEsAAAAAE
+AAASwAAAAAQAAP/Y/9sAQwAIBgYHBgUIBwcHCQkICgwUDQwLCwwZEhMPFB0aHx4dGhwcICQu
+JyAiLCMcHCg3KSwwMTQ0NB8nOT04MjwuMzQy/8QAHwAAAQUBAQEBAQEAAAAAAAAAAAECAwQF
+BgcICQoL/8QAtRAAAgEDAwIEAwUFBAQAAAF9AQIDAAQRBRIhMUEGE1FhByJxFDKBkaEII0Kx
+wRVS0fAkM2JyggkKFhcYGRolJicoKSo0NTY3ODk6Q0RFRkdISUpTVFVWV1hZWmNkZWZnaGlq
+c3R1dnd4eXqDhIWGh4iJipKTlJWWl5iZmqKjpKWmp6ipqrKztLW2t7i5usLDxMXGx8jJytLT
+1NXW19jZ2uHi4+Tl5ufo6erx8vP09fb3+Pn6/9k=
+ENDofIMG
+
+demo.show_image('tiff', 'deflate compressed', <<'ENDofIMG')
+TU0AKgAAAah4nO2Y643EMAiEXQzNUIyboRiaoRh2ADuP+7N70knZkxhZlmNH2fkMRPGO0Wq1
+Wq1Wq9Vqtb5L5m5qqi7Rm5kP4qdNfSSHc3dYDtfmMD8TQS3mn3b3TjRgm6YEgsaeYzwRg4TC
+9PcjRMLYzpmxcABW8+ifNviJ6DIktLKN/vv3/xRHwXJuPoV5HTwqKK1Wq9VqtVqtz+VxwMjv
+8ej/39fUpCGTdLLJVJmm6NlNQIQlev+AhyVMaDBfA6GYAU41nFrzqLSFSw3GjJf6ZeEpUvwu
+bxDOcFREAkpXRKph7IjRzOjAvEnOC9jzcC7rnlp13YB29ip4wvxT1Jn+qwlthMQ5QWDbwlsE
+RTis4uQX+cZl+zCPQfWWGZgsEkfHhaML3KyQN901lIjwL/6a4GvL5EEK4QErneKSKqPW0qaD
++awarnpJlkTIOnI9Aic1o1LsuEHuMdIyHTgrPyVTVKsM/YfuRzY4odxz3v2KBfaf021aDQqi
+E2q3SYs0QxN1cdSOHnW0i8uWyYoR79dFIK95nedr5HhObRRmctXuUC9uNR31AAAOAQAAAwAA
+AAEAQAAAAQEAAwAAAAEAKAAAAQIAAwAAAAMAAAJWAQMAAwAAAAGAsgAAAQYAAwAAAAEAAgAA
+AREABAAAAAEAAAAIARIAAwAAAAEAAQAAARUAAwAAAAEAAwAAARYAAwAAAAEAKAAAARcABAAA
+AAEAAAGfARoABQAAAAEAAAJcARsABQAAAAEAAAJkARwAAwAAAAEAAQAAASgAAwAAAAEAAgAA
+AAAAAAAIAAgACBLAAAAABAAAEsAAAAAEAAA=
+ENDofIMG
+
+if Tk::PLATFORM['platform'] != 'windows'
+demo.show_image('other', 'postscript', <<'ENDofIMG')
+%!PS-Adobe-3
+%%Title: postscript.ps
+%%BoundingBox: 66 648 146 720
+%%Pages: 1
+%%DocumentProcSets: Adobe_distill 0.96
+%%EndComments
+%%BeginProcSet: Adobe_distill 0.96
+/PROLOGUE 30 40 add dict def
+ % 30 procedure entries + room for 40 cached font dictionaries
+ PROLOGUE begin
+ /clip { } def % causes problems. remove if "clip" is needed
+ /bdef { bind def } bind def /ldef { load def } bdef
+ /T { moveto show } bdef /A { moveto ashow } bdef
+ /W { moveto widthshow } bdef /AW { moveto awidthshow } bdef
+ /f /fill ldef /R { { rlineto } repeat } bdef
+ /r /rlineto ldef /L { { lineto } repeat } bdef
+ /m /moveto ldef /l { moveto lineto stroke } bdef
+ /x { 0 rlineto } bdef /y { 0 exch rlineto } bdef
+ /c /curveto ldef /cp /closepath ldef
+ /s /stroke ldef /w /setlinewidth ldef
+ /g /setgray ldef /j /setlinejoin ldef
+ /d /setdash ldef /F /setfont ldef
+ /C /setcmykcolor where { /setcmykcolor get }{ %ifelse
+ { %def
+ 1 sub 3 { 3 index add neg dup 0 lt { pop 0 } if 3 1 roll } repeat
+ setrgbcolor
+ } bind
+ } ifelse def
+ /selectfont where { pop }{ %ifelse
+ /selectfont { exch findfont exch scalefont setfont } bdef
+ } ifelse
+ /MF { exch findfont exch makefont setfont } bdef
+ /FF /selectfont ldef
+ /DF { selectfont currentfont def } bdef
+ /BEGINPAGE { pop /pagesave save def } bdef
+ /ENDPAGE { pop pagesave restore showpage } def
+ /REMAP { %def
+ FontDirectory 2 index known { pop pop pop } { %ifelse
+ findfont dup length dict begin
+ { 1 index /FID ne {def}{pop pop} ifelse } forall
+ exch dup length 0 gt { /Encoding exch def }{ pop } ifelse
+ currentdict end definefont pop
+ } ifelse
+ } bdef
+ /RECODE { %def
+ 3 -1 roll 1 index findfont /Encoding get 256 array copy exch
+ 0 exch { %forall
+ dup type/nametype eq
+ { 3 {2 index} repeat put pop 1 add }{ exch pop }ifelse
+ } forall pop 3 1 roll REMAP
+ } bdef
+ end %PROLOGUE
+%%EndProcSet: Adobe_distill 0.96
+%%EndProlog
+%%BeginSetup
+PROLOGUE begin
+%%EndSetup
+%%Page: 1 1
+1 BEGINPAGE
+1 g
+2 setlinecap
+144 53 m
+390 x
+-19 y
+-390 x
+eofill
+0 g
+1.268 w
+0 setlinecap
+4 setmiterlimit
+[] 0 d
+109.698 714.182 m
+111.525 713.672 112.472 713.234 113.624 712.431 c
+-22.3128 -25.8381 r
+97.4019 682.652 103.794 672.84 100.329 664.844 c
+102.034 675.687 90.7436 683.82 84.1099 684.842 c
+25.588 29.3407 r
+f
+1.0361 w
+f
+f
+91.8805 654.468 m
+96.0255 654.285 100.155 654.188 104.481 654.188 c
+113.804 654.188 122.752 654.636 131.141 655.44 c
+134.222 655.737 136.724 658.133 137.108 661.279 c
+137.79 666.855 138.107 672.696 138.107 678.705 c
+138.107 684.714 137.79 690.555 137.108 696.131 c
+136.724 699.277 134.222 701.674 131.141 701.97 c
+127.476 702.321 123.704 702.604 119.84 702.813 c
+119.84 702.813 103.842 668.373 102.231 664.827 c
+99.8549 659.595 96.601 655.765 91.8805 654.468 c
+f
+0.7851 w
+77.8202 655.44 m
+74.7171 655.948 72.2887 657.716 71.8525 661.279 c
+71.1725 666.855 70.8549 672.696 70.8549 678.705 c
+70.8549 684.714 71.1725 690.555 71.8525 696.131 c
+72.2381 699.277 74.7417 701.674 77.8202 701.97 c
+82.1335 702.383 86.5932 702.702 91.1764 702.916 c
+8.16241 9.07727 r
+99.2863 711.98 101.266 712.345 102.996 711.921 c
+-28.4564 -32.9334 r
+80.6983 681.906 98.7446 677.354 98.7446 666.708 c
+98.7446 655.332 86.3243 654.054 77.8202 655.44 c
+f
+0.0843 w
+139.67 644.154 m
+140.194 644.154 140.619 644.576 140.619 645.098 c
+140.619 645.619 140.194 646.042 139.67 646.042 c
+139.146 646.042 138.721 645.619 138.721 645.098 c
+138.721 644.576 139.146 644.154 139.67 644.154 c
+1 ENDPAGE
+%%Trailer
+end %PROLOGUE
+%%Pages: 1
+%%EOF
+ENDofIMG
+end
+
+if false
+demo.show_image('other', 'pdf', <<'ENDofIMG')
+JVBERi0xLjIKJcfsj6IKNCAwIG9iago8PC9MZW5ndGggNSAwIFIvRmlsdGVyIC9GbGF0ZURl
+Y29kZT4+CnN0cmVhbQp4nF1TSY7cQAy7+xX1AkFbaXlG3jBAgAAzh/z/Esp2uyeDPhhUayEp
+FZMsnt/9/fg6/h6y/hzCHdS1UlyodH0dIrJJNyIWlLpE1OcLrGQOjLg6MOIm6+NoMULWiopN
+bevz6HRiaUQ0aKMHW1L7itQitGA2UvwdDuhoIaw8zSN3UOVqTnILNLAiXQVy3NNvCvQs+M57
+Zv4Gj6LivWK7UxS0dDCknBGl2jNY6MKoKmBkljwYfQUD2d8ZqjkKgINASEyEfCq208nc0Fon
+YSdZIiFy7IldQmbACe4FraKUfVYkzEAgarhgIBJyvIGi+IYrCWqm4I6UJ4mvV4PmfTW4J3TI
+tZCHQzdmDqeLY7Jgpf6IAG7KKVAsLAMBxWIEqrEvuAAc8xXp2Rtgkdhp038B7PfcCyQZ5WDV
+oXIuWGdCI387SO/GjezVgcZyuRaAP1b3gXVmopb1ZfXXkSM/z6Imx+4xpHAsseGHgD2abFzu
+2+qEzjwjl9fJN4vb6zd+ef1Ebq+fDrfZz4zH7GFhc0O32cPSJR+zXzIes0vnMPZlNk73ejWT
+gFNDYs/IOM3tkTXmGUbMsaPF9cAwq8KuyNwxFMc4gJY+d47S0Td/68nSNxkiUNpz159H8Twg
+g1LkcKyGBe6TkQYL3jhwTDwreSJ7gw9eZeBY3GZpPBU/FjY7/HX8A9+h3WJlbmRzdHJlYW0K
+ZW5kb2JqCjUgMCBvYmoKNTE2CmVuZG9iagozIDAgb2JqCjw8Ci9UeXBlIC9QYWdlCi9NZWRp
+YUJveCBbMCAwIDYxMiA3OTJdCi9QYXJlbnQgMiAwIFIKL1Jlc291cmNlcyA8PCAvUHJvY1Nl
+dCBbL1BERl0KPj4KL0NvbnRlbnRzIDQgMCBSCj4+CmVuZG9iagoyIDAgb2JqCjw8IC9UeXBl
+IC9QYWdlcyAvS2lkcyBbCjMgMCBSCl0gL0NvdW50IDEKPj4KZW5kb2JqCjEgMCBvYmoKPDwg
+L1R5cGUgL0NhdGFsb2cgL1BhZ2VzIDIgMCBSCj4+CmVuZG9iago2IDAgb2JqCjw8IC9DcmVh
+dGlvbkRhdGUgKEQ6MTk5NzEyMDUyMjU2MzcpCi9Qcm9kdWNlciAoQWxhZGRpbiBHaG9zdHNj
+cmlwdCA1LjEwKQo+PgplbmRvYmoKeHJlZgowIDcKMDAwMDAwMDAwMCA2NTUzNSBmIAowMDAw
+MDAwNzk5IDAwMDAwIG4gCjAwMDAwMDA3NDAgMDAwMDAgbiAKMDAwMDAwMDYyMCAwMDAwMCBu
+IAowMDAwMDAwMDE1IDAwMDAwIG4gCjAwMDAwMDA2MDEgMDAwMDAgbiAKMDAwMDAwMDg0OCAw
+MDAwMCBuIAp0cmFpbGVyCjw8IC9TaXplIDcgL1Jvb3QgMSAwIFIgL0luZm8gNiAwIFIKPj4K
+c3RhcnR4cmVmCjkzOQolJUVPRgo=
+ENDofIMG
+end
+
+#######################
+
+Tk.mainloop
diff --git a/jni/ruby/ext/tk/sample/tkextlib/tkimg/license_terms_of_Img_extension b/jni/ruby/ext/tk/sample/tkextlib/tkimg/license_terms_of_Img_extension
new file mode 100644
index 0000000..23238e9
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkextlib/tkimg/license_terms_of_Img_extension
@@ -0,0 +1,41 @@
+This software is copyrighted by Jan Nijtmans (the maintainer)
+and a lot of other people who contributed code (most notably
+Andreas Kupries, Thomas G. Lane, Ioi K. Lam, Mario Weilguni
+and Roger E Critchlow Jr).
+The following terms apply to all files associated with the
+software unless explicitly disclaimed in individual files.
+
+The authors hereby grant permission to use, copy, modify, distribute,
+and license this software and its documentation for any purpose, provided
+that existing copyright notices are retained in all copies and that this
+notice is included verbatim in any distributions. No written agreement,
+license, or royalty fee is required for any of the authorized uses.
+Modifications to this software may be copyrighted by their authors
+and need not follow the licensing terms described here, provided that
+the new terms are clearly indicated on the first page of each file where
+they apply.
+
+IN NO EVENT SHALL THE AUTHORS OR DISTRIBUTORS BE LIABLE TO ANY PARTY
+FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
+ARISING OUT OF THE USE OF THIS SOFTWARE, ITS DOCUMENTATION, OR ANY
+DERIVATIVES THEREOF, EVEN IF THE AUTHORS HAVE BEEN ADVISED OF THE
+POSSIBILITY OF SUCH DAMAGE.
+
+THE AUTHORS AND DISTRIBUTORS SPECIFICALLY DISCLAIM ANY WARRANTIES,
+INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE, AND NON-INFRINGEMENT. THIS SOFTWARE
+IS PROVIDED ON AN "AS IS" BASIS, AND THE AUTHORS AND DISTRIBUTORS HAVE
+NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR
+MODIFICATIONS.
+
+GOVERNMENT USE: If you are acquiring this software on behalf of the
+U.S. government, the Government shall have only "Restricted Rights"
+in the software and related documentation as defined in the Federal
+Acquisition Regulations (FARs) in Clause 52.227.19 (c) (2). If you
+are acquiring the software on behalf of the Department of Defense, the
+software shall be classified as "Commercial Computer Software" and the
+Government shall have only "Restricted Rights" as defined in Clause
+252.227-7013 (c) (1) of DFARs. Notwithstanding the foregoing, the
+authors grant the U.S. Government and others acting in its behalf
+permission to use and distribute the software in accordance with the
+terms specified in this license.
diff --git a/jni/ruby/ext/tk/sample/tkextlib/tkimg/readme.txt b/jni/ruby/ext/tk/sample/tkextlib/tkimg/readme.txt
new file mode 100644
index 0000000..8fd1a3e
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkextlib/tkimg/readme.txt
@@ -0,0 +1,3 @@
+The script 'demo.rb' is based on 'demo.tcl' of Tcl/Tk's 'Img' extension.
+Image data in 'demo.rb' is those of 'demo.tcl'.
+Please read 'license_terms_of_Img_extension' file.
diff --git a/jni/ruby/ext/tk/sample/tkextlib/tktable/Orig_LICENSE.txt b/jni/ruby/ext/tk/sample/tkextlib/tktable/Orig_LICENSE.txt
new file mode 100644
index 0000000..b06b0b4
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkextlib/tktable/Orig_LICENSE.txt
@@ -0,0 +1,52 @@
+
+ #######################################################################
+ ### The following text is the original 'license.txt' of tktable ###
+ ### extension. ###
+ ### Original Tcl source files are not include in this directory, ###
+ ### because of all of them are rewritten to Ruby files. ###
+ ### However, the image data file is quoted from iwidgets source ###
+ ### archive. ###
+ #######################################################################
+
+
+ * COPYRIGHT AND LICENSE TERMS *
+
+(This file blatantly stolen from Tcl/Tk license and adapted - thus assume
+it falls under similar license terms).
+
+This software is copyrighted by Jeffrey Hobbs <jeff.hobbs@acm.org>. The
+following terms apply to all files associated with the software unless
+explicitly disclaimed in individual files.
+
+The authors hereby grant permission to use, copy, modify, distribute, and
+license this software and its documentation for any purpose, provided that
+existing copyright notices are retained in all copies and that this notice
+is included verbatim in any distributions. No written agreement, license,
+or royalty fee is required for any of the authorized uses.
+
+IN NO EVENT SHALL THE AUTHORS OR DISTRIBUTORS BE LIABLE TO ANY PARTY FOR
+DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT
+OF THE USE OF THIS SOFTWARE, ITS DOCUMENTATION, OR ANY DERIVATIVES THEREOF,
+EVEN IF THE AUTHORS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+THE AUTHORS AND DISTRIBUTORS SPECIFICALLY DISCLAIM ANY WARRANTIES,
+INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE, AND NON-INFRINGEMENT. THIS SOFTWARE IS
+PROVIDED ON AN "AS IS" BASIS, AND THE AUTHORS AND DISTRIBUTORS HAVE NO
+OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR
+MODIFICATIONS.
+
+RESTRICTED RIGHTS: Use, duplication or disclosure by the U.S. government
+is subject to the restrictions as set forth in subparagraph (c) (1) (ii)
+of the Rights in Technical Data and Computer Software Clause as DFARS
+252.227-7013 and FAR 52.227-19.
+
+SPECIAL NOTES:
+
+This software also falls under the bourbon_ware clause:
+
+ Should you find this software useful in your daily work, you should
+ feel obliged to take the author out for a drink if the opportunity
+ presents itself. The user may feel exempt from this clause if they
+ are under 21 or think the author has already partaken of too many
+ drinks.
diff --git a/jni/ruby/ext/tk/sample/tkextlib/tktable/basic.rb b/jni/ruby/ext/tk/sample/tkextlib/tktable/basic.rb
new file mode 100644
index 0000000..dddbb77
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkextlib/tktable/basic.rb
@@ -0,0 +1,60 @@
+#!/usr/bin/env ruby
+##
+## basic.rb
+##
+## This demo shows the basic use of the table widget
+##
+## ( based on 'basic.tcl' included source archive of tktable extension )
+##
+require 'tk'
+require 'tkextlib/tktable'
+
+ary = TkVariable.new_hash
+rows = 8
+cols = 8
+
+# fill table variable
+((-(rows))..rows).each{|x|
+ ((-(cols))..cols).each{|y|
+ ary[x,y] = "r#{x},c#{y}"
+ }
+}
+
+lbl = TkLabel.new(:text=>"TkTable v1 Example")
+
+table = Tk::TkTable.new(:rows=>rows, :cols=>cols, :variable=>ary,
+ :width=>6, :height=>6,
+ :titlerows=>1, :titlecols=>2,
+ :roworigin=>-1, :colorigin=>-2,
+ :rowstretchmode=>:last, :colstretchmode=>:last,
+ :rowtagcommand=>proc{|row|
+ row = Integer(row)
+ (row>0 && row%2 == 1)? 'OddRow': ''
+ },
+ :coltagcommand=>proc{|col|
+ col = Integer(col)
+ (col>0 && col%2 == 1)? 'OddCol': ''
+ },
+ :selectmode=>:extended, :sparsearray=>false)
+
+sx = table.xscrollbar(TkScrollbar.new)
+sy = table.yscrollbar(TkScrollbar.new)
+
+btn = TkButton.new(:text=>'Exit', :command=>proc{exit})
+
+Tk.grid(lbl, '-', :sticky=>:ew)
+Tk.grid(table, sy, :sticky=>:news)
+Tk.grid(sx, :sticky=>:ew)
+Tk.grid(btn, :sticky=>:ew, :columnspan=>2)
+
+Tk.root.grid_columnconfig(0, :weight=>1)
+Tk.root.grid_rowconfig(1, :weight=>1)
+
+table.tag_configure('OddRow', :bg=>'orange', :fg=>'purple')
+table.tag_configure('OddCol', :bg=>'brown', :fg=>'pink')
+
+table.set_width([-2, 7], [-1, 7], [1, 5], [2, 8], [4, 14])
+
+puts "Table is #{table.path} with array #{(table['variable'])}"
+
+Tk.mainloop
diff --git a/jni/ruby/ext/tk/sample/tkextlib/tktable/buttons.rb b/jni/ruby/ext/tk/sample/tkextlib/tktable/buttons.rb
new file mode 100644
index 0000000..e35c137
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkextlib/tktable/buttons.rb
@@ -0,0 +1,76 @@
+#!/usr/bin/env ruby
+##
+## buttons.rb
+##
+## demonstrates the simulation of a button array
+##
+## ( based on 'buttons.tcl' included source archive of tktable extension )
+##
+require 'tk'
+require 'tkextlib/tktable'
+
+# create the table
+tab = TkVariable.new_hash
+rows = 20
+cols = 20
+
+table = Tk::TkTable.new(:rows=>rows + 1, :cols=>cols + 1,
+ :variable=>tab, :titlerows=>1, :titlecols=>1,
+ :roworigin=>-1, :colorigin=>-1,
+ :colwidth=>4, :width=>8, :height=>8,
+ :cursor=>'top_left_arrow', :borderwidth=>2,
+ :flashmode=>false, :state=>:disabled)
+
+sx = table.xscrollbar(TkScrollbar.new)
+sy = table.yscrollbar(TkScrollbar.new)
+
+Tk.grid(table, sy, :sticky=>:news)
+Tk.grid(sx, :sticky=>:ew)
+
+Tk.root.grid_columnconfig(0, :weight=>1)
+Tk.root.grid_rowconfig(0, :weight=>1)
+
+# set up tags for the various states of the buttons
+table.tag_configure('OFF', :bg=>'red', :relief=>:raised)
+table.tag_configure('ON', :bg=>'green', :relief=>:sunken)
+table.tag_configure('sel', :bg=>'gray75', :relief=>:flat)
+
+# clean up if mouse leaves the widget
+table.bind('Leave', proc{|w| w.selection_clear_all}, '%W')
+
+# highlight the cell under the mouse
+table.bind('Motion', proc{|w, x, y|
+ Tk.callback_break if w.selection_include?(TkComm._at(x,y))
+ w.selection_clear_all
+ w.selection_set(TkComm._at(x,y))
+ Tk.callback_break
+ ## "break" prevents the call to tkTableCheckBorder
+ }, '%W %x %y')
+
+# mousebutton 1 toggles the value of the cell
+# use of "selection includes" would work here
+table.bind('1', proc{|w, x, y|
+ #rc = w.curselection[0]
+ rc = w.index(TkComm._at(x,y))
+ if tab[rc] == 'ON'
+ tab[rc] = 'OFF'
+ w.tag_cell('OFF', rc)
+ else
+ tab[rc] = 'ON'
+ w.tag_cell('ON', rc)
+ end}, '%W %x %y')
+
+
+# inititialize the array, titles, and celltags
+0.step(rows){|i|
+ tab[i,-1] = i
+ 0.step(cols){|j|
+ if i == 0
+ tab[-1,j] = j
+ end
+ tab[i,j] = "OFF"
+ table.tag_cell('OFF', "#{i},#{j}")
+ }
+}
+
+Tk.mainloop
diff --git a/jni/ruby/ext/tk/sample/tkextlib/tktable/command.rb b/jni/ruby/ext/tk/sample/tkextlib/tktable/command.rb
new file mode 100644
index 0000000..e697ccf
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkextlib/tktable/command.rb
@@ -0,0 +1,89 @@
+#!/usr/bin/env ruby
+##
+## command.rb
+##
+## This demo shows the use of the table widget's -command options
+##
+## ( based on 'command.tcl' included source archive of tktable extension )
+##
+require 'tk'
+require 'tkextlib/tktable'
+
+# create the table
+data = TkVariable.new_hash
+rows = 10
+cols = 10
+
+# fill table variable
+((-(rows))..rows).each{|x|
+ ((-(cols))..cols).each{|y|
+ data[x,y] = "#{x} x #{y}"
+ }
+}
+
+lbl = TkLabel.new(:text=>"TkTable :command Example")
+cur_var = TkVariable.new
+current = TkLabel.new(:textvariable=>cur_var, :width=>5)
+ent_var = TkVariable.new
+entry = TkEntry.new(:textvariable=>ent_var)
+
+table = Tk::TkTable.new(:rows=>rows, :cols=>cols,
+ :command=>[proc{|mode, cell, val|
+ if (mode == :w)
+ data[cell] = val
+ else
+ begin
+ data[cell] # exist
+ rescue
+ '' # not exist
+ end
+ end
+ }, '%i %C %s'],
+ :width=>6, :height=>6,
+ :titlerows=>1, :titlecols=>1,
+ :roworigin=>-1, :colorigin=>-1,
+ :rowstretchmode=>:last, :colstretchmode=>:last,
+ :rowtagcommand=>proc{|row|
+ row = Integer(row)
+ (row>0 && row%2 == 1)? 'OddRow': ''
+ },
+ :coltagcommand=>proc{|col|
+ col = Integer(col)
+ (col>0 && col%2 == 1)? 'OddCol': ''
+ },
+ :selectmode=>:extended, :flashmode=>true,
+ :rowstretch=>:unset, :colstretch=>:unset,
+ :browsecommand=>[proc{|w, s|
+ cur_var.value = s
+ ent_var.value = w.get(s)
+ }, '%W %S'],
+ :validate=>true,
+ :validatecommand=>proc{|e|
+ ent_var.value = e.new_value; true
+ })
+=begin
+ :validatecommand=>[
+ proc{|s|
+ ent_var.value = s; true
+ }, '%S'])
+=end
+
+sx = table.xscrollbar(TkScrollbar.new)
+sy = table.yscrollbar(TkScrollbar.new)
+
+entry.bind('Return', proc{|w| table.curvalue = w.value}, '%W')
+
+Tk.grid(lbl, '-', '-', :sticky=>:ew)
+Tk.grid(current, entry, '-', :sticky=>:ew)
+Tk.grid(table, '-', sy, :sticky=>:news)
+Tk.grid(sx, '-', :sticky=>:ew)
+
+Tk.root.grid_columnconfig(1, :weight=>1)
+Tk.root.grid_rowconfig(2, :weight=>1)
+
+table.tag_configure('OddRow', :bg=>'orange', :fg=>'purple')
+table.tag_configure('OddCol', :bg=>'brown', :fg=>'pink')
+
+puts "Table is #{table.path}"
+
+Tk.mainloop
diff --git a/jni/ruby/ext/tk/sample/tkextlib/tktable/debug.rb b/jni/ruby/ext/tk/sample/tkextlib/tktable/debug.rb
new file mode 100644
index 0000000..016d5b3
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkextlib/tktable/debug.rb
@@ -0,0 +1,101 @@
+#!/usr/bin/env ruby
+##
+## debug.rb
+##
+## This demo uses most features of the table widget
+##
+## ( based on 'debug.tcl' included source archive of tktable extension )
+##
+require 'tk'
+require 'tkextlib/tktable'
+
+# create the table
+ary = TkVariable.new_hash
+rows = 25
+cols = 20
+
+# fill table variable
+((-(rows))..rows).each{|x|
+ ((-(cols))..cols).each{|y|
+ ary[x,y] = "r#{x},c#{y}"
+ }
+}
+
+lbl = TkLabel.new(:text=>"TkTable v2 Example")
+
+table = Tk::TkTable.new(:rows=>rows, :cols=>cols, :variable=>ary,
+ :width=>6, :height=>6,
+ :titlerows=>1, :titlecols=>2,
+ :roworigin=>-5, :colorigin=>-2,
+ :coltagcommand=>proc{|col|
+ col = Integer(col)
+ (col>0 && col%2 == 1)? 'OddCol': ''
+ },
+ :selectmode=>:extended, :flashmode=>true,
+ :rowstretch=>:unset, :colstretch=>:unset,
+ :selecttitles=>false, :drawmode=>:single)
+
+sx = table.xscrollbar(TkScrollbar.new)
+sy = table.yscrollbar(TkScrollbar.new)
+
+btn = TkButton.new(:text=>'Exit', :command=>proc{exit})
+
+Tk.grid(lbl, '-', :sticky=>:ew)
+Tk.grid(table, sy, :sticky=>:news)
+Tk.grid(sx, :sticky=>:ew)
+Tk.grid(btn, :sticky=>:ew, :columnspan=>2)
+
+Tk.root.grid_columnconfig(0, :weight=>1)
+Tk.root.grid_rowconfig(1, :weight=>1)
+
+table.tag_configure('OddCol', :bg=>'brown', :fg=>'pink')
+table.tag_configure('title', :bg=>'red', :fg=>'green', :relief=>:sunken)
+table.tag_configure('dis', :state=>:disabled)
+
+first = table[:colorigin]
+%w(n s e w nw ne sw se c).each_with_index{|anchor, idx|
+ table.tag_configure(anchor, :anchor=>anchor)
+ table.tag_row(anchor, idx)
+ table.set([idx,first], anchor)
+}
+courier = TkFont.new(:family=>'Courier', :size=>10)
+table.tag_configure('s', :font=>courier, :justify=>:center)
+
+logo = TkPhotoImage.new(:file=>File.join(File.dirname(File.expand_path(__FILE__)), 'tcllogo.gif'))
+table.tag_configure('logo', :image=>logo, :showtext=>true)
+table.tag_cell('logo', [1,2], [2,3], [4,1])
+table.tag_cell('dis', [2,1], [1,-1], [3,0])
+table.set_width([-2,8], [-1,9], [0, 12], [4, 14])
+
+table.set([1,1], "multi-line\ntext\nmight be\ninteresting",
+ [3,2], "more\nmulti-line\nplaying\n",
+ [2,2], "null\0byte")
+
+# This is in the row span
+l = TkLabel.new(table, :text=>'Window s', :bg=>'yellow')
+table.window_configure([6,0], :sticky=>:s, :window=>l)
+
+# This is in the row titles
+l = TkLabel.new(table, :text=>'Window ne', :bg=>'yellow')
+table.window_configure([4,-1], :sticky=>:ne, :window=>l)
+
+# This will get swallowed by a span
+l = TkLabel.new(table, :text=>'Window ew', :bg=>'yellow')
+table.window_configure([5,3], :sticky=>:ew, :window=>l)
+
+# This is in the col titles
+l = TkLabel.new(table, :text=>'Window news', :bg=>'yellow')
+table.window_configure([-5,1], :sticky=>:news, :window=>l)
+
+l = TkLabel.new(table.winfo_parent, :text=>'Sibling l', :bg=>'orange')
+table.window_configure([5,1], :sticky=>:news, :window=>l)
+
+if table.span_list.empty?
+ table.set_spans([-1,-2], [0,3], [1,2], [0,5], [3,2], [2,2], [6,0], [4,0])
+end
+
+puts "Table is #{table.path} with array #{(table['variable'])}"
+
+# table.postscript(:file=>'out.ps', :first=>:origin, :last=>[2,2])
+
+Tk.mainloop
diff --git a/jni/ruby/ext/tk/sample/tkextlib/tktable/dynarows.rb b/jni/ruby/ext/tk/sample/tkextlib/tktable/dynarows.rb
new file mode 100644
index 0000000..cc72a02
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkextlib/tktable/dynarows.rb
@@ -0,0 +1,99 @@
+#!/usr/bin/env ruby
+##
+## dynarows.rb
+##
+## This demos shows the use of the validation mechanism of the table
+## and uses the table's cache (no -command or -variable) with a cute
+## dynamic row routine.
+##
+## ( based on 'dynarows.tcl' included source archive of tktable extension )
+##
+require 'tk'
+require 'tkextlib/tktable'
+
+def table_validate(w, idx)
+ return unless idx =~ /^(\d+),(\d+)$/
+ row = Integer($1)
+ col = Integer($2)
+ val = w.get(idx)
+
+ [w, idx]
+ nrows = w[:rows]
+ return if row == nrows - 1 && val == ''
+
+ begin
+ time = Tk.tk_call('clock', 'scan', val)
+ date = []
+ Tk.tk_call('clock', 'format', time,
+ :format=>'%m %d %Y').split(' ').each{|item|
+ date << item.sub(/^\s*0*/,'')
+ }
+ w.set(idx, date.join('/'))
+ if row == nrows - 1
+ if w.get([row,1]) != '' && w.get([row,2]) != ''
+ w.tag_row_reset(row)
+ w.set([row,0], row)
+ nrows += 1
+ row += 1
+ w.configure(:rows=>nrows)
+ w.tag_row('unset', row)
+ w.set([row,0], '*')
+ w.see([row,1])
+ w.activate([row,1])
+ end
+ end
+ rescue
+ Tk.bell
+ w.activate(idx)
+ w.selection_clear_all
+ w.selection_set(:active)
+ w.see(:active)
+ end
+end
+
+
+lbl = TkLabel.new(:text=>"Dynamic Date Validated Rows")
+
+table = Tk::TkTable.new(:rows=>2, :cols=>3, :cache=>1, :selecttype=>:row,
+ :titlerows=>1, :titlecols=>1, :height=>5,
+ :colstretch=>:unset, :rowstretch=>:unset,
+ :autoclear=>true,
+ :browsecommand=>[
+ proc{|w,s| table_validate(w, s)},
+ '%W %s'
+ ])
+table.set([0,1], 'Begin', [0,2], 'End', [1,0], '*')
+table.tag_configure('unset', :fg=>'#008811')
+table.tag_configure('title', :fg=>'red')
+table.tag_row('unset', 1)
+table.set_width(0,3)
+
+sx = table.xscrollbar(TkScrollbar.new)
+sy = table.yscrollbar(TkScrollbar.new)
+
+Tk.grid(lbl, '-', :sticky=>:ew)
+Tk.grid(table, sy, :sticky=>:news)
+Tk.grid(sx, :sticky=>:ew)
+
+Tk.root.grid_columnconfig(0, :weight=>1)
+Tk.root.grid_rowconfig(1, :weight=>1)
+
+rtn_proc = proc{|w|
+ r = w.row_index(:active)
+ c = w.col_index(:active)
+
+ if c == 2
+ r += 1
+ w.activate([r,1])
+ else
+ c += 1
+ w.activate([r,c])
+ end
+ w.see(:active)
+ Tk.callback_break
+}
+
+table.bind('Return', rtn_proc, '%W')
+table.bind('KP_Enter', rtn_proc, '%W')
+
+Tk.mainloop
diff --git a/jni/ruby/ext/tk/sample/tkextlib/tktable/maxsize.rb b/jni/ruby/ext/tk/sample/tkextlib/tktable/maxsize.rb
new file mode 100644
index 0000000..74e136c
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkextlib/tktable/maxsize.rb
@@ -0,0 +1,67 @@
+#!/usr/bin/env ruby
+##
+## maxsize.rb
+##
+## This demo uses a really big table. The big startup time is in
+## filling the table's Tcl array var.
+##
+## ( based on 'maxsize.tcl' included source archive of tktable extension )
+##
+require 'tk'
+require 'tkextlib/tktable'
+
+ary = TkVariable.new_hash
+rows = 40000
+cols = 10
+
+# fill table variable
+((-(rows))..rows).each{|x|
+ ((-(cols))..cols).each{|y|
+ ary[x,y] = "#{x},#{y}"
+ }
+}
+
+lbl = TkLabel.new(:text=>"TkTable v2 Example")
+
+table = Tk::TkTable.new(:rows=>rows, :cols=>cols, :variable=>ary,
+ :width=>6, :height=>8,
+ :titlerows=>1, :titlecols=>1,
+ :coltagcommand=>proc{|col|
+ col = Integer(col)
+ (col>0 && col%2 == 1)? 'OddCol': ''
+ },
+ :selectmode=>:extended,
+ :colstretch=>:unset, :rowstretch=>:unset,
+ :selecttitles=>false, :drawmode=>:slow)
+
+sx = table.xscrollbar(TkScrollbar.new)
+sy = table.yscrollbar(TkScrollbar.new)
+
+btn = TkButton.new(:text=>'Exit', :command=>proc{exit})
+
+Tk.grid(lbl, '-', :sticky=>:ew)
+Tk.grid(table, sy, :sticky=>:news)
+Tk.grid(sx, :sticky=>:ew)
+Tk.grid(btn, :sticky=>:ew, :columnspan=>2)
+
+Tk.root.grid_columnconfig(0, :weight=>1)
+Tk.root.grid_rowconfig(1, :weight=>1)
+
+table.tag_configure('OddCol', :bg=>'brown', :fg=>'pink')
+table.tag_configure('title', :bg=>'red', :fg=>'blue', :relief=>:sunken)
+table.tag_configure('dis', :state=>:disabled)
+
+first = table[:colorigin]
+%w(n s e w nw ne sw se c).each_with_index{|anchor, idx|
+ table.tag_configure(anchor, :anchor=>anchor)
+ table.tag_row(anchor, idx)
+ table.set([idx,first], anchor)
+}
+courier = TkFont.new(:family=>'Courier', :size=>10)
+table.tag_configure('s', :font=>courier, :justify=>:center)
+
+table.set_width([-2, 8], [-1, 9], [0, 12], [4, 14])
+
+puts "Table is #{table.path} with array #{(table['variable'])}"
+
+Tk.mainloop
diff --git a/jni/ruby/ext/tk/sample/tkextlib/tktable/spreadsheet.rb b/jni/ruby/ext/tk/sample/tkextlib/tktable/spreadsheet.rb
new file mode 100644
index 0000000..2953b2e
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkextlib/tktable/spreadsheet.rb
@@ -0,0 +1,137 @@
+#!/usr/bin/env ruby
+##
+## spreadsheet.rb
+##
+## This demos shows how you can simulate a 3D table
+## and has other basic features to begin a basic spreadsheet
+##
+## ( based on 'spreadsheet.tcl' included source archive of tktable extension )
+##
+require 'tk'
+require 'tkextlib/tktable'
+
+rows = 10
+cols = 10
+cur_var = TkVariable.new
+table_list = Hash.new{|hash, key| hash[key] = TkVariable.new_hash}
+page = TkVariable.new('AA')
+color = Hash.new('pink')
+color['AA'] = 'orange'
+color['BB'] = 'blue'
+color['CC'] = 'green'
+
+def colorize(num)
+ num = Integer(num)
+ return 'colored' if (num > 0 && num % 2 == 1)
+end
+
+def fill_table(tbl_list, page, r=10, c=10)
+ ary = tbl_list[page]
+
+ (0...r).each{|i|
+ (0...c).each{|j|
+ if i!=0 && j!=0
+ ary[i,j] = "#{page} #{i},#{j}"
+ elsif i!=0
+ ary[i,j] = i.to_s
+ else
+ ary[i,j] = (64+j).chr
+ end
+ }
+ }
+end
+
+def changepage(tbl_list, tbl, ent, col, var, elem, op)
+ if elem != ''
+ page = var[elem]
+ else
+ page = var.value
+ end
+ if tbl[:variable] != tbl_list[page].id
+ tbl.selection_clear_all
+ tbl.variable(tbl_list[page])
+ ent.textvariable(tbl_list[page].ref('active'))
+ tbl.activate('origin')
+ tbl.tag_configure('colored', :bg=>col[page])
+ tbl.see('active')
+ end
+end
+
+lbl = TkLabel.new(:text=>"TkTable v1 Spreadsheet Example")
+
+current = TkLabel.new(:textvariable=>cur_var, :width=>5)
+entry = TkEntry.new(:textvariable=>table_list[page.value].ref('active'))
+lpage = TkLabel.new(:text=>'PAGE:', :width=>6, :anchor=>:e)
+optmenu = TkOptionMenubutton.new(page, *(%w(AA BB CC DD)))
+
+fill_table(table_list, page.value)
+fill_table(table_list, 'BB', Integer(rows/2), Integer(cols/2))
+
+table = Tk::TkTable.new(:rows=>rows, :cols=>cols, :width=>5, :height=>5,
+ :variable=>table_list[page.value],
+ :titlerows=>1, :titlecols=>1,
+ :coltagcommand=>proc{|n| colorize(n)},
+ :flashmode=>true, :selectmode=>:extended,
+ :colstretch=>:unset, :rowstretch=>:unset,
+ :browsecommand=>proc{|e| cur_var.value = e.new_index})
+
+page.trace(:w, proc{|var, elem, op|
+ changepage(table_list, table, entry, color, var, elem, op)
+ })
+
+table.tag_configure('colored', :bg=>color[page.value])
+table.tag_configure('title', :fg=>'red', :relief=>:groove)
+table.tag_configure('blue', :bg=>'blue')
+table.tag_configure('green', :bg=>'green')
+
+table.tag_cell('green', [6,3], [5,7], [4,9])
+table.tag_cell('blue', [8,8])
+table.tag_row('blue', 7)
+table.tag_col('blue', 6, 8)
+table.set_width([0, 3], [2, 7])
+
+sx = table.xscrollbar(TkScrollbar.new)
+sy = table.yscrollbar(TkScrollbar.new)
+
+btn = TkButton.new(:text=>'Exit', :command=>proc{exit})
+
+Tk.grid(lbl, '-', '-', '-', '-', :sticky=>:ew)
+Tk.grid(current, entry, lpage, optmenu, '-', :sticky=>:ew)
+Tk.grid(table, '-', '-', '-', sy, :sticky=>:ns)
+Tk.grid(sx, '-', '-', '-', :sticky=>:ew)
+Tk.grid(btn, '-', '-', '-', '-', :sticky=>:ew)
+
+Tk.root.grid_columnconfig(1, :weight=>1)
+Tk.root.grid_rowconfig(2, :weight=>1)
+
+table.grid_configure(:sticky=>:news)
+
+entry.bind('Return', proc{
+ r = table.row_index(:active)
+ c = table.col_index(:active)
+ rmax = table[:rows]
+ cmax = table[:cols]
+
+ c += 1
+ if c == cmax
+ c = table[:titlecols]
+ r += 1
+ if r == rmax
+ r = table[:titlerows]
+ end
+ end
+ table.activate([r, c])
+ table.see('active')
+ })
+
+menu = TkMenu.new
+m_file = TkMenu.new(menu)
+Tk.root.menu(menu)
+menu.add(:cascade, :label=>'File', :underline=>0, :menu=>m_file)
+m_file.add(:command, :label=>'Fill Array',
+ :command=>proc{ fill_table(table_list, page.value) })
+m_file.add(:command, :label=>'Quit', :command=>proc{exit})
+
+puts "Table is #{table.path} with array #{(table['variable'])}"
+
+Tk.mainloop
diff --git a/jni/ruby/ext/tk/sample/tkextlib/tktable/tcllogo.gif b/jni/ruby/ext/tk/sample/tkextlib/tktable/tcllogo.gif
new file mode 100644
index 0000000..4603d4f
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkextlib/tktable/tcllogo.gif
Binary files differ
diff --git a/jni/ruby/ext/tk/sample/tkextlib/tktable/valid.rb b/jni/ruby/ext/tk/sample/tkextlib/tktable/valid.rb
new file mode 100644
index 0000000..98e9c38
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkextlib/tktable/valid.rb
@@ -0,0 +1,88 @@
+#!/usr/bin/env ruby
+##
+## valid.rb
+##
+## This demos shows the use of the validation mechanism of the table
+## and uses the table's cache (no -command or -variable)
+##
+## ( based on 'valid.tcl' included source archive of tktable extension )
+##
+require 'tk'
+require 'tkextlib/tktable'
+
+rows = 10
+cols = 10
+
+def colorize(num)
+ num = Integer(num)
+ return 'colored' if (num > 0 && num % 2 == 1)
+end
+
+def fill_headers(w, r=10, c=10)
+ (1..(r-1)).each{|i| w.set([i,0], i.to_s)}
+
+ (1..(c-1)).each{|j|
+ if j % 3 == 1
+ w.set([0,j], 'AlphaNum')
+ elsif j % 2 == 1
+ w.set([0,j], 'Alpha')
+ elsif j != 0
+ w.set([0,j], 'Real')
+ end
+ }
+end
+
+def validate_proc(c, val)
+ if c % 3 == 1
+ # AlphaNum
+ regexp = /^[A-Za-z0-9 ]*$/
+ elsif c % 2 == 1
+ # Alpha
+ regexp = /^[A-Za-z ]*$/
+ elsif c != 0
+ # 'Real'
+ regexp = /^[-+]?[0-9]*\.?[0-9]*([0-9]\.?e[-+]?[0-9]*)?$/
+ end
+ if val =~ regexp
+ return true
+ else
+ Tk.bell
+ return false
+ end
+end
+
+lbl = TkLabel.new(:text=>"TkTable v1 Validated Table Example")
+
+table = Tk::TkTable.new(:rows=>rows, :cols=>cols, :cache=>1,
+ :width=>5, :height=>5, :titlerows=>1, :titlecols=>1,
+ :coltagcommand=>proc{|n| colorize(n)},
+ :flashmode=>true, :selectmode=>:extended,
+ :colstretch=>:unset, :rowstretch=>:unset,
+ :validate=>true,
+ :validatecommand=>proc{|e|
+ unless e.widget.tag_include?('title', e.index)
+ validate_proc(e.column, e.new_value)
+ end } )
+
+fill_headers(table)
+
+table.tag_configure('colored', :bg=>'lightblue')
+table.tag_configure('title', :fg=>'red')
+table.set_width(0,3)
+
+sx = table.xscrollbar(TkScrollbar.new)
+sy = table.yscrollbar(TkScrollbar.new)
+
+btn = TkButton.new(:text=>'Exit', :command=>proc{exit})
+
+Tk.grid(lbl, '-', :sticky=>:ew)
+Tk.grid(table, sy, :sticky=>:news)
+Tk.grid(sx, :sticky=>:ew)
+Tk.grid(btn, '-', :sticky=>:ew)
+
+Tk.root.grid_columnconfig(0, :weight=>1)
+Tk.root.grid_rowconfig(1, :weight=>1)
+
+puts "Table is #{table.path}"
+
+Tk.mainloop
diff --git a/jni/ruby/ext/tk/sample/tkextlib/treectrl/bitmaps.rb b/jni/ruby/ext/tk/sample/tkextlib/treectrl/bitmaps.rb
new file mode 100644
index 0000000..0d8b37b
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkextlib/treectrl/bitmaps.rb
@@ -0,0 +1,76 @@
+#
+# Demo: Bitmaps
+#
+def demoBitmaps(t)
+ #if $Version_1_1_OrLater
+ if @has_bgimg
+ t.configure(:showroot=>false, :showbuttons=>false, :showlines=>false,
+ :selectmode=>:browse, :orient=>:horizontal, :wrap=>'5 items',
+ :showheader=>false, :backgroundimage=>@images['sky'])
+ else
+ t.configure(:showroot=>false, :showbuttons=>false, :showlines=>false,
+ :selectmode=>:browse, :orient=>:horizontal, :wrap=>'5 items',
+ :showheader=>false)
+ end
+
+ if $HasColumnCreate
+ t.column_create(:itembackground=>['gray90', []])
+ else
+ t.column_configure(0, :itembackground=>['gray90', []])
+ end
+
+ t.element_create('elemTxt', :text,
+ :fill=>[@SystemHighlightText, ['selected', 'focus']])
+ t.element_create('elemSelTxt', :rect, :showfocus=>true,
+ :fill=>[@SystemHighlight, ['selected', 'focus']])
+ t.element_create('elemSelBmp', :rect, :outlinewidth=>4,
+ :outline=>[@SystemHighlight, ['selected', 'focus']])
+ t.element_create('elemBmp', :bitmap,
+ :foreground=>[@SystemHighlight, ['selected', 'focus']],
+ :background=>'linen',
+ :bitmap=>['question' ['selected']])
+
+ s = t.style_create('STYLE', :orient=>:vertical)
+ t.style_elements(s, ['elemSelBmp', 'elemBmp', 'elemSelTxt', 'elemTxt'])
+ t.style_layout(s, 'elemSelBmp', :union=>'elemBmp', :ipadx=>6, :ipady=>6)
+ t.style_layout(s, 'elemBmp', :pady=>[0, 6], :expand=>:we)
+ t.style_layout(s, 'elemSelTxt', :union=>'elemTxt', :ipadx=>2)
+ t.style_layout(s, 'elemTxt', :expand=>:we)
+
+ # Set default item style
+ if $Version_1_1_OrLater
+ t.defaultstyle = [s]
+ end
+
+ bitmap_names = %w(error gray75 gray50 gray25 gray12
+ hourglass info questhead question warning)
+
+ bitmap_names.each{|name|
+ i = t.item_create
+ unless $Version_1_1_OrLater
+ t.item_style_set(i, 0, s)
+ end
+ t.item_text(i, 0, name)
+ t.item_element_configure(i, 0, 'elemBmp', :bitmap=>name)
+ t.item_lastchild(:root, i)
+ }
+
+ bitmap_names.each{|name|
+ i = t.item_create
+ t.item_style_set(i, 0, s)
+ t.item_text(i, 0, name)
+ if true
+ t.item_element_configure(i, 0, 'elemBmp', :bitmap=>name,
+ :foreground=>['brown', ''],
+ :background=>['', ''])
+ else
+ t.item_element_configure(i, 0, 'elemBmp', :bitmap=>name,
+ :foreground=>[
+ @SystemHighlight, ['selected', 'focus'],
+ 'brown', []
+ ],
+ :background=>['', []])
+ end
+ t.item_lastchild(:root, i)
+ }
+end
diff --git a/jni/ruby/ext/tk/sample/tkextlib/treectrl/demo.rb b/jni/ruby/ext/tk/sample/tkextlib/treectrl/demo.rb
new file mode 100644
index 0000000..564a005
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkextlib/treectrl/demo.rb
@@ -0,0 +1,1305 @@
+#!/usr/bin/env ruby
+
+require 'tk'
+require 'tkextlib/treectrl'
+
+$ScriptDir = File.dirname(File.expand_path(__FILE__))
+
+$HasColumnCreate = Tk::TreeCtrl::HasColumnCreateCommand
+
+$Version_1_1_OrLater = (TkPackage.vcompare(Tk::TreeCtrl.package_version, '1.1') >= 0)
+
+#if Hash.instance_methods.include?(:key)
+if TkCore::WITH_RUBY_VM ### Ruby 1.9 !!!!
+ # ruby 1.9.x --> use Hash#key
+ # Because Hash#index show warning "Hash#index is deprecated; use Hash#key".
+else
+ # ruby 1.8.x --> use Hash#index
+ class Hash
+ alias key index
+ end
+end
+
+class TkTreeCtrl_demo
+ def initialize(dir)
+ @ScriptDir = dir || '.'
+
+ @thisPlatform = Tk::PLATFORM['platform']
+ if @thisPlatform == 'unix' && Tk.windowingsystem == 'aqua'
+ @thisPlatform = 'macosx'
+ end
+
+ @RandomN = [500]
+
+ @images = Hash.new
+ @sel_images = Hash.new
+
+ @popup = Hash.new
+ @mTree = Hash.new
+ @mHeader = Hash.new
+
+ @non_clear_list = []
+
+ @demoCmd = Hash.new
+ @demoFile = Hash.new
+
+ # Get default colors
+ w = TkListbox.new
+ @SystemButtonFace = w[:highlightbackground]
+ @SystemHighlight = w[:selectbackground]
+ @SystemHighlightText = w[:selectforeground]
+ w.destroy
+
+ ####################
+
+ make_source_window()
+ make_menubar()
+ make_main_window()
+
+ if $Version_1_1_OrLater
+ begin
+ @tree2[:backgroundimage]
+ @has_bgimg = true
+ rescue
+ @has_bgimg = false
+ end
+ else
+ @has_bgimg = false
+ end
+
+ ####################
+
+ make_list_popup()
+ make_header_popup()
+
+ init_pics('sky')
+
+ ####################
+
+ @tree2.bind('ButtonPress-3',
+ proc{|w, x, y, rootx, rooty|
+ show_list_popup(w, x, y, rootx, rooty)
+ }, '%W %x %y %X %Y')
+
+ # Allow "scan" bindings
+ if @thisPlatform == 'windows'
+ @tree2.bind_remove('Control-ButtonPress-3')
+ end
+
+ ####################
+
+ init_demo_scripts_module()
+ load_demo_scripts()
+ init_demo_list()
+
+ ####################
+
+ @tree1.notify_bind(@tree1, 'Selection',
+ proc{|c, t|
+ if c == 1
+ item = t.selection_get[0]
+ demo_set(@demoCmd[item], @demoFile[item])
+ end
+ }, '%c %T')
+
+ # When one item is selected in the demo list, display the styles in
+ # that item.
+ # See DemoClear for why the tag "DontDelete" is used
+ @tree2.notify_bind('DontDelete', 'Selection',
+ proc{|c, t|
+ display_styles_in_item(t.selection_get[0]) if c == 1
+ }, '%c %T')
+ end
+
+ ##########################
+
+ def init_pics(*args)
+ args.each{|pat|
+ unless TkImage.names.find{|img| (name = @images.key(img)) && File.fnmatch(pat, name)}
+ Dir.glob(File.join(@ScriptDir, 'pics', "#{pat}.gif")).each{|file|
+ name = File.basename(file, '.gif')
+ img = TkPhotoImage.new(:file=>file)
+ @images[name] = img
+ @sel_images[name] = TkPhotoImage.new
+ @sel_images[name].copy(img)
+ Tk::TreeCtrl.image_tint(@sel_images[name], @SystemHighlight, 128)
+ }
+ end
+ }
+ end
+
+ ##########################
+
+ private
+
+ def make_menubar
+ menuspec = [
+ [['File']]
+ ]
+ if Tk::PLATFORM['platform'] != 'unix'
+ TkConsole.create
+ TkConsole.eval('.console conf -height 8')
+ menuspec[0] << ['Console', proc{
+ if TkComm.bool(TkConsole.eval('winfo ismapped .'))
+ TkConsole.hide
+ else
+ TkConsole.show
+ end
+ }]
+ end
+ menuspec[0] << ['View Source', proc{toggle_source_window()}]
+ menuspec[0] << ['Quit', proc{exit}]
+ Tk.root.add_menubar(menuspec)
+ end
+
+ def make_source_window
+ @src_top = TkToplevel.new
+ f = TkFrame.new(@src_top, :borderwidth=>0)
+ case @thisPlatform
+ when 'unix'
+ font = TkFont.new(['Courier', -12])
+ else
+ font = TkFont.new(['Courier', 9])
+ end
+
+ @src_txt = TkText.new(f, :font=>font, :tabs=>font.measure('1234'),
+ :wrap=>:none)
+ xscr = @src_txt.xscrollbar(TkScrollbar.new(f))
+ yscr = @src_txt.yscrollbar(TkScrollbar.new(f))
+
+ f.pack(:expand=>true, :fill=>:both)
+ f.grid_columnconfigure(0, :weight=>1)
+ f.grid_rowconfigure(0, :weight=>1)
+ @src_txt.grid(:row=>0, :column=>0, :sticky=>:news)
+ xscr.grid(:row=>1, :column=>0, :sticky=>:we)
+ yscr.grid(:row=>0, :column=>1, :sticky=>:ns)
+
+ @src_top.protocol('WM_DELETE_WINDOW', proc{@src_top.withdraw})
+ @src_top.geometry('-0+0')
+ @src_top.withdraw
+ end
+
+ def show_source(file)
+ @src_top.title("Demo Source: #{file}")
+ @src_txt.value = IO.read(File.join(@ScriptDir, file))
+ @src_txt.set_insert('1.0')
+ end
+
+ def toggle_source_window
+ if @src_top.winfo_mapped?
+ @src_top.withdraw
+ else
+ @src_top.deiconify
+ end
+ end
+
+ def tree_plus_scrollbars_in_a_frame(parent, h, v)
+ f = TkFrame.new(parent, :borderwidth=>1, :relief=>:sunken)
+ case @thisPlatform
+ when 'unix'
+ font = TkFont.new(['Helvetica', -12])
+ else
+ # There is a bug on my Win98 box with Tk_MeasureChars() and
+ # MS Sans Serif 8.
+ font = TkFont.new(['MS Sans', 8])
+ end
+
+ tree = Tk::TreeCtrl.new(f, :highlightthickness=>0,
+ :borderwidth=>0, :font=>font)
+ tree[:xscrollincrement] = 20
+ tree.debug_configure(:enable=>false, :display=>false)
+
+ if h
+ h_scr = TkScrollbar.new(f, :orient=>:horizontal,
+ :command=>proc{|*args| tree.xview(*args)})
+ tree.notify_bind(h_scr, 'Scroll-x',
+ proc{|w, l, u| w.set(l, u)}, '%W %l %u')
+ h_scr.bind('ButtonPress-1', proc{tree.set_focus})
+ end
+
+ if v
+ v_scr = TkScrollbar.new(f, :orient=>:vertical,
+ :command=>proc{|*args| tree.yview(*args)})
+ tree.notify_bind(v_scr, 'Scroll-y',
+ proc{|w, l, u| w.set(l, u)}, '%W %l %u')
+ v_scr.bind('ButtonPress-1', proc{tree.set_focus})
+ end
+
+ f.grid_columnconfigure(0, :weight=>1)
+ f.grid_rowconfigure(0, :weight=>1)
+ tree.grid(:row=>0, :column=>0, :sticky=>:news)
+ h_scr.grid(:row=>1, :column=>0, :sticky=>:we) if h
+ v_scr.grid(:row=>0, :column=>1, :sticky=>:ns) if v
+
+ [f, tree]
+ end
+
+ def make_main_window
+ Tk.root.title('Tk::TreeCtrl Demo')
+
+ case @thisPlatform
+ when 'macosx'
+ Tk.root.geometry('+40+40')
+ else
+ Tk.root.geometry('+0+30')
+ end
+
+ pane1 = TkPanedWindow.new(:orient=>:vertical, :borderwidth=>0)
+ pane2 = TkPanedWindow.new(:orient=>:horizontal, :borderwidth=>0)
+
+ # Tree + scrollbar: demos
+ f1, @tree1 = tree_plus_scrollbars_in_a_frame(nil, false, true)
+ @tree1.configure(:showbuttons=>false, :showlines=>:false,
+ :showroot=>false, :height=>100)
+ if $HasColumnCreate
+ @tree1.column_create(:text=>'List of Demos',
+ :expand=>true, :button=>false)
+ else
+ @tree1.column_configure(0, :text=>'List of Demos',
+ :expand=>true, :button=>false)
+ end
+
+ # Tree + scrollbar: styles + elements in list
+ f4, @tree4 = tree_plus_scrollbars_in_a_frame(nil, false, true)
+ @tree4.configure(:showroot=>false, :height=>140)
+ if $HasColumnCreate
+ @tree4.column_create(:text=>'Elements and Styles',
+ :expand=>true, :button=>false)
+ else
+ @tree4.column_configure(0, :text=>'Elements and Styles',
+ :expand=>true, :button=>false)
+ end
+
+ # Tree + scrollbar: styles + elements in selected item
+ f3, @tree3 = tree_plus_scrollbars_in_a_frame(nil, false, true)
+ @tree3.configure(:showroot=>false)
+ if $HasColumnCreate
+ @tree3.column_create(:text=>'Styles in Item',
+ :expand=>true, :button=>false)
+ else
+ @tree3.column_configure(0, :text=>'Styles in Item',
+ :expand=>true, :button=>false)
+ end
+
+ pane1.add(f1, f4, f3, :height=>150)
+ pane1.pack(:expand=>true, :fill=>:both)
+
+ # Frame on right
+ f2_base = TkFrame.new
+
+ # Tree + scrollbars
+ f2, @tree2 = tree_plus_scrollbars_in_a_frame(f2_base, true, true)
+ @tree2.configure(:indent=>19)
+ @tree2.debug_configure(:enable=>false, :display=>true,
+ :erasecolor=>'pink', :displaydelay=>30)
+
+ # Give it a big border to debug drawing
+ @tree2.configure(:borderwidth=>6, :relief=>:ridge, :highlightthickness=>3)
+
+ f2_base.grid_columnconfigure(0, :weight=>1)
+ f2_base.grid_rowconfigure(0, :weight=>1)
+ f2.grid(:row=>0, :column=>0, :sticky=>:news, :pady=>0)
+
+ pane2.add(pane1, :width=>200)
+ pane2.add(f2_base, :width=>450)
+
+ pane2.pack(:expand=>true, :fill=>:both)
+
+ ###
+ # A treectrl widget can generate the following built-in events:
+ # <ActiveItem> called when the active item changes
+ # <Collapse-before> called before an item is closed
+ # <Collapse-after> called after an item is closed
+ # <Expand-before> called before an item is opened
+ # <Expand-after> called after an item is opened
+ # <Selection> called when items are added to or removed from the selection
+ # <Scroll-x> called when horizontal scroll position changes
+ # <Scroll-y> called when vertical scroll position changes
+ #
+ # The application programmer can define custom events to be
+ # generated by the "T notify generate" command. The following events
+ # are generated by the example bindings.
+
+ @tree2.notify_install_event('Header')
+ @tree2.notify_install_detail('Header', 'invoke')
+
+ @tree2.notify_install_event('Drag')
+ @tree2.notify_install_detail('Drag', 'begin')
+ @tree2.notify_install_detail('Drag', 'end')
+ @tree2.notify_install_detail('Drag', 'receive')
+
+ @tree2.notify_install_event('Edit')
+ @tree2.notify_install_detail('Edit', 'accept')
+ end
+
+ def make_list_popup
+ @popup[:bgimg] = TkVariable.new
+ @popup[:bgmode] = TkVariable.new
+ @popup[:debug] = Hash.new{|h, k| h[k] = TkVariable.new}
+ @popup[:doublebuffer] = TkVariable.new
+ @popup[:linestyle] = TkVariable.new
+ @popup[:orient] = TkVariable.new
+ @popup[:selectmode] = TkVariable.new
+ @popup[:show] = Hash.new{|h, k| h[k] = TkVariable.new}
+
+ menuspec = [
+ [ 'Collapse', [], nil, '', {:menu_config=>{:tearoff=>false}} ],
+
+ [ 'Expand', [], nil, '', {:menu_config=>{:tearoff=>false}} ]
+ ]
+
+ # if $Version_1_1_OrLater
+ if @has_bgimg
+ menuspec << \
+ [ 'Background Image',
+ [
+ [ 'none', [@popup[:bgimg], 'none'], nil, '',
+ {:command=>proc{@tree2.backgroundimage = ''}} ],
+ [ 'sky', [@popup[:bgimg], 'sky'], nil, '',
+ {:command=>proc{
+ @tree2.backgroundimage = @images[@popup[:bgimg].value]}} ]
+ ],
+ nil, '', {:menu_config=>{:tearoff=>false}}
+ ]
+ end
+
+ menuspec.concat([
+ [ 'Background Mode',
+ %w(column index row visindex).collect{|val|
+ [ val, [@popup[:bgmode], val] , nil, '',
+ {:command=>proc{@tree2.backgroundmode = @popup[:bgmode].value}} ]
+ },
+ nil, '', {:menu_config=>{:tearoff=>false}}
+ ],
+
+ [ 'Debug',
+ [
+ [ 'Data', @popup[:debug][:data], nil, '',
+ {:command=>proc{
+ @tree2.debug_configure(:data=>@popup[:debug][:data].value)
+ }
+ } ],
+ [ 'Display', @popup[:debug][:display], nil, '',
+ {:command=>proc{
+ @tree2.debug_configure(:display=>@popup[:debug][:display].value)
+ }
+ } ],
+ [ 'Enable', @popup[:debug][:enable], nil, '',
+ {:command=>proc{
+ @tree2.debug_configure(:enable=>@popup[:debug][:enable].value)
+ }
+ } ]
+ ],
+ nil, '', {:menu_config=>{:tearoff=>false}}
+ ],
+
+ [ 'Buffering',
+ [
+ [ 'none', [@popup[:doublebuffer], 'none'], nil, '',
+ {:command=>proc{
+ @tree2.doublebuffer = @popup[:doublebuffer].value
+ }
+ } ],
+ [ 'item', [@popup[:doublebuffer], 'item'], nil, '',
+ {:command=>proc{
+ @tree2.doublebuffer = @popup[:doublebuffer].value
+ }
+ } ],
+ [ 'window', [@popup[:doublebuffer], 'window'], nil, '',
+ {:command=>proc{
+ @tree2.doublebuffer = @popup[:doublebuffer].value
+ }
+ } ]
+ ],
+ nil, '', {:menu_config=>{:tearoff=>false}}
+ ],
+
+ [ 'Line style',
+ [
+ [ 'dot', [@popup[:linestyle], 'dot'], nil, '',
+ {:command=>proc{@tree2.linestyle = @popup[:linestyle].value}} ],
+ [ 'solid', [@popup[:linestyle], 'solid'], nil, '',
+ {:command=>proc{@tree2.linestyle = @popup[:linestyle].value}} ]
+ ],
+ nil, '', {:menu_config=>{:tearoff=>false}}
+ ],
+
+ [ 'Orient',
+ [
+ [ 'Horizontal', [@popup[:orient], 'horizontal'], nil, '',
+ {:command=>proc{@tree2.orient = @popup[:orient].value}} ],
+ [ 'Vertical', [@popup[:orient], 'vertical'], nil, '',
+ {:command=>proc{@tree2.orient = @popup[:orient].value}} ]
+ ],
+ nil, '', {:menu_config=>{:tearoff=>false}}
+ ],
+
+ [ 'Selectmode',
+ %w(list browse extended multiple single).collect{|val|
+ [ val, [@popup[:selectmode], val] , nil, '',
+ {:command=>proc{@tree2.selectmode = @popup[:selectmode].value}} ]
+ },
+ nil, '', {:menu_config=>{:tearoff=>false}}
+ ],
+
+ [ 'Show',
+ [
+ [ 'Buttons', @popup[:show][:buttons], nil, '',
+ {:command=>proc{
+ @tree2.showbuttons = @popup[:show][:buttons].value
+ }
+ } ],
+ [ 'Header', @popup[:show][:header], nil, '',
+ {:command=>proc{
+ @tree2.showheader = @popup[:show][:header].value
+ }
+ } ],
+ [ 'Lines', @popup[:show][:lines], nil, '',
+ {:command=>proc{
+ @tree2.showlines = @popup[:show][:lines].value
+ }
+ } ],
+ [ 'Root', @popup[:show][:root], nil, '',
+ {:command=>proc{
+ @tree2.showroot = @popup[:show][:root].value
+ }
+ } ],
+ [ 'Root Button', @popup[:show][:rootbutton], nil, '',
+ {:command=>proc{
+ @tree2.showrootbutton = @popup[:show][:rootbutton].value
+ }
+ } ]
+ ],
+ nil, '', {:menu_config=>{:tearoff=>false}}
+ ],
+
+ [ 'Visible', [], nil, '', {:menu_config=>{:tearoff=>false}} ]
+ ])
+
+ m = TkMenu.new_menuspec(menuspec, @tree2, false)
+ @non_clear_list << m
+ @mTree[@tree2] = m
+ end
+
+ def show_list_popup(w, x, y, rootx, rooty)
+ id = w.identify(x, y)
+ unless id.empty?
+ if id[0] == 'header'
+ col = id[1]
+ @popup[:column].value = col
+ @popup[:arrow].value = w.column_cget(col, :arrow)
+ @popup[:arrowside].value = w.column_cget(col, :arrowside)
+ @popup[:arrowgravity].value = w.column_cget(col, :arrowgravity)
+ @popup[:expand].value = w.column_cget(col, :expand)
+ @popup[:squeeze].value = w.column_cget(col, :squeeze)
+ @popup[:justify].value = w.column_cget(col, :justify)
+ @mHeader[w].popup(rootx, rooty)
+ return
+ end
+ end
+
+ m = @mTree[w].entrycget('Collapse', :menu)
+ m.delete(0, :end)
+ if $Version_1_1_OrLater
+ m.add_command(:label=>'All', :command=>proc{w.item_collapse(:all)})
+ else
+ m.add_command(:label=>'All', :command=>proc{w.collapse(:all)})
+ end
+ unless id.empty?
+ if id[0] == 'item'
+ item = id[1]
+ if $Version_1_1_OrLater
+ m.add_command(:label=>"Item #{item}",
+ :command=>proc{w.item_collapse(item)})
+ m.add_command(:label=>"Item #{item} (recurse)",
+ :command=>proc{w.item_collapse_recurse(item)})
+ else
+ m.add_command(:label=>"Item #{item}",
+ :command=>proc{w.collapse(item)})
+ m.add_command(:label=>"Item #{item} (recurse)",
+ :command=>proc{w.collapse_recurse(item)})
+ end
+ end
+ end
+
+ m = @mTree[w].entrycget('Expand', :menu)
+ m.delete(0, :end)
+ if $Version_1_1_OrLater
+ m.add_command(:label=>'All', :command=>proc{w.item_expand(:all)})
+ else
+ m.add_command(:label=>'All', :command=>proc{w.expand(:all)})
+ end
+ unless id.empty?
+ if id[0] == 'item'
+ item = id[1]
+ if $Version_1_1_OrLater
+ m.add_command(:label=>"Item #{item}",
+ :command=>proc{w.item_expand(item)})
+ m.add_command(:label=>"Item #{item} (recurse)",
+ :command=>proc{w.item_expand_recurse(item)})
+ else
+ m.add_command(:label=>"Item #{item}",
+ :command=>proc{w.expand(item)})
+ m.add_command(:label=>"Item #{item} (recurse)",
+ :command=>proc{w.expand_recurse(item)})
+ end
+ end
+ end
+
+ [:data, :display, :enable].each{|k|
+ @popup[:debug][k].value = w.debug_cget(k)
+ }
+ # if $Version_1_1_OrLater
+ if @has_bgimg
+ @popup[:bgimg].value = @images.key(w[:backgroundimage])
+ end
+ @popup[:bgmode].value = w[:backgroundmode]
+ @popup[:doublebuffer].value = w[:doublebuffer]
+ @popup[:linestyle].value = w[:linestyle]
+ @popup[:orient].value = w[:orient]
+ @popup[:selectmode].value = w[:selectmode]
+ @popup[:show][:buttons].value = w[:showbuttons]
+ @popup[:show][:header].value = w[:showheader]
+ @popup[:show][:lines].value = w[:showlines]
+ @popup[:show][:root].value = w[:showroot]
+ @popup[:show][:rootbutton].value = w[:showrootbutton]
+
+ m = @mTree[w].entrycget('Visible', :menu)
+ m.delete(0, :end)
+ @popup[:visible] = []
+ (0...(w.numcolumns)).each{|i|
+ @popup[:visible][i] = TkVariable.new(w.column_cget(i, :visible))
+ txt = w.column_cget(i, :text)
+ img_name = w.column_cget(i, :image)
+ img_name = @images.key(img_name) if img_name.kind_of?(TkImage)
+ m.add_checkbutton(:variable=>@popup[:visible][i],
+ :label=>"Column #{i} \"#{txt}\" [#{img_name}]",
+ :command=>proc{w.column_configure(i, :visible=>@popup[:visible][i].value)})
+ }
+
+ @mTree[w].popup(rootx, rooty)
+ end
+
+ def make_header_popup
+ @popup[:column] = TkVariable.new unless @popup[:column]
+ @popup[:arrow] = TkVariable.new
+ @popup[:arrowside] = TkVariable.new
+ @popup[:arrowgravity] = TkVariable.new
+ @popup[:expand] = TkVariable.new
+ @popup[:squeeze] = TkVariable.new
+ @popup[:justify] = TkVariable.new
+
+ menuspec = [
+ [ 'Arrow',
+ [
+ [ 'None', [@popup[:arrow], 'none'], nil, '',
+ {:command=>proc{
+ @tree2.column_configure(@popup[:column].value, :arrow=>:none)
+ }
+ } ],
+ [ 'Up', [@popup[:arrow], 'up'], nil, '',
+ {:command=>proc{
+ @tree2.column_configure(@popup[:column].value, :arrow=>:up)
+ }
+ } ],
+ [ 'Down', [@popup[:arrow], 'down'], nil, '',
+ {:command=>proc{
+ @tree2.column_configure(@popup[:column].value, :arrow=>:down)
+ }
+ } ],
+
+ '---',
+
+ [ 'Side Left', [@popup[:arrowside], 'left'], nil, '',
+ {:command=>proc{
+ @tree2.column_configure(@popup[:column].value,
+ :arrowside=>:left)
+ }
+ } ],
+ [ 'Side Right', [@popup[:arrowside], 'right'], nil, '',
+ {:command=>proc{
+ @tree2.column_configure(@popup[:column].value,
+ :arrowside=>:right)
+ }
+ } ],
+
+ '---',
+
+ [ 'Gravity Left', [@popup[:arrowgravity], 'left'], nil, '',
+ {:command=>proc{
+ @tree2.column_configure(@popup[:column].value,
+ :arrowgravity=>:left)
+ }
+ } ],
+ [ 'Gravity Right', [@popup[:arrowgravity], 'right'], nil, '',
+ {:command=>proc{
+ @tree2.column_configure(@popup[:column].value,
+ :arrowgravity=>:right)
+ }
+ } ],
+ ],
+ nil, '', {:menu_config=>{:tearoff=>false}} ],
+
+ [ 'Expand', @popup[:expand], nil, '',
+ {:command=>proc{
+ @tree2.column_configure(@popup[:column].value,
+ :expand=>@popup[:expand].value)
+ }
+ } ],
+
+ [ 'Squeeze', @popup[:squeeze], nil, '',
+ {:command=>proc{
+ @tree2.column_configure(@popup[:column].value,
+ :squeeze=>@popup[:squeeze].value)
+ }
+ } ],
+
+ [ 'Justify',
+ [
+ [ 'Left', [@popup[:justify], 'left'], nil, '',
+ {:command=>proc{
+ @tree2.column_configure(@popup[:column].value, :justify=>:left)
+ }
+ } ],
+ [ 'Center', [@popup[:justify], 'center'], nil, '',
+ {:command=>proc{
+ @tree2.column_configure(@popup[:column].value,
+ :justify=>:center)
+ }
+ } ],
+ [ 'Right', [@popup[:justify], 'right'], nil, '',
+ {:command=>proc{
+ @tree2.column_configure(@popup[:column].value,
+ :justify=>:right)
+ }
+ } ]
+ ],
+ nil, '', {:menu_config=>{:tearoff=>false}} ]
+ ]
+
+ m = TkMenu.new_menuspec(menuspec, @tree2, false)
+ @non_clear_list << m
+ @mHeader[@tree2] = m
+ end
+
+ ###########################
+
+ def init_demo_scripts_module
+ @demo_scripts = Module.new
+
+ master = self
+
+ has_bgimg = @has_bgimg
+
+ scriptDir = @ScriptDir
+
+ thisPlatform = @thisPlatform
+
+ randomN = @RandomN
+
+ images = @images
+ sel_images = @sel_images
+
+ systemButtonFace = @SystemButtonFace
+ systemHighlight = @SystemHighlight
+ systemHighlightText = @SystemHighlightText
+
+ def master._pub_display_styles_in_item(item)
+ display_styles_in_item(item)
+ end
+ proc_disp_styles_in_item = proc{|item|
+ master._pub_display_styles_in_item(item)
+ }
+
+ @demo_scripts.instance_eval{
+ @master = master
+
+ @has_bgimg = has_bgimg
+
+ @display_styles_in_item = proc_disp_styles_in_item
+
+ @Priv = TkVarAccess.new('::TreeCtrl::Priv')
+
+ @ScriptDir = scriptDir
+
+ @thisPlatform = thisPlatform
+
+ @RandomN = randomN
+
+ @images = images
+ @sel_images = sel_images
+
+ @SystemButtonFace = systemButtonFace
+ @SystemHighlight = systemHighlight
+ @SystemHighlightText = systemHighlightText
+ }
+
+ class << @demo_scripts
+ def _get_binding
+ binding
+ end
+ private :_get_binding
+
+ def load_demo(file)
+ puts "load \"#{file}\"" if $DEBUG
+ begin
+ eval(IO.readlines(file).join, _get_binding())
+ rescue Exception => e
+ bt = e.backtrace
+
+ if bt[0] =~ /^([^:]+):(\d+):/
+ errline = $2.to_i
+ else
+ raise e
+ end
+
+ if bt[1] =~ /^([^:]+):(\d+):/
+ bt.unshift("#{file}:#{errline - $2.to_i + 1}")
+ raise e
+ else
+ raise e
+ end
+ end
+ end
+
+ def init_pics(*args)
+ @master.init_pics(*args)
+ end
+ end
+ end
+
+ def load_demo_scripts
+ # demo sources
+ [
+ 'bitmaps',
+ 'explorer',
+ 'help',
+ 'imovie',
+ 'layout',
+ 'mailwasher',
+ 'outlook-folders',
+ 'outlook-newgroup',
+ 'random',
+ 'www-options'
+ ].each{|f|
+ @demo_scripts.load_demo(File.join(@ScriptDir, "#{f}.rb"))
+ }
+ end
+
+ ###########################
+
+ def init_demo_list
+ @tree1.element_create('e1', :text,
+ :fill=>[@SystemHighlightText, ['selected', 'focus']])
+ @tree1.element_create('e2', :rect, :showfocus=>true,
+ :fill=>[
+ @SystemHighlight, ['selected', 'focus'],
+ 'gray', ['selected', '!focus'],
+ ])
+ @tree1.style_create('s1')
+ @tree1.style_elements('s1', ['e2', 'e1'])
+
+ # Tk listbox has linespace + 1 height
+ @tree1.style_layout('s1', 'e2', :union=>['e1'],
+ :ipadx=>2, :ipady=>[0, 1], :iexpand=>:e)
+
+ if $Version_1_1_OrLater
+ @tree1.defaultstyle = 's1'
+ end
+
+ ###
+ [
+ ["Random #{@RandomN[0]} Items", :demoRandom, 'random.rb'],
+ ["Random #{@RandomN[0]} Items, Button Images", :demoRandom2, 'random.rb'],
+ ["Outlook Express (Folders)", :demoOutlookFolders, 'outlook-folders.rb'],
+ ["Outlook Express (Newsgroup)", :demoOutlookNewsgroup, 'outlook-newgroup.rb'],
+ ["Explorer (Details)", :demoExplorerDetails, 'explorer.rb'],
+ ["Explorer (List)", :demoExplorerList, 'explorer.rb'],
+ ["Explorer (Large icons)", :demoExplorerLargeIcons, 'explorer.rb'],
+ ["Explorer (Small icons)", :demoExplorerSmallIcons, 'explorer.rb'],
+ ["Internet Options", :demoInternetOptions, 'www-options.rb'],
+ ["Help Contents", :demoHelpContents, 'help.rb'],
+ ["Layout", :demoLayout, 'layout.rb'],
+ ["MailWasher", :demoMailWasher, 'mailwasher.rb'],
+ ["Bitmaps", :demoBitmaps, 'bitmaps.rb'],
+ ["iMovie", :demoIMovie, 'imovie.rb']
+ ].each{|label, cmd, file|
+ item = @tree1.item_create
+ @tree1.item_lastchild(:root, item)
+ unless $Version_1_1_OrLater
+ @tree1.item_style_set(item, 0, 's1')
+ end
+ @tree1.item_text(item, 0, label)
+ @demoCmd[item] = cmd
+ @demoFile[item] = file
+ }
+
+ @tree1.yview_moveto(0.0)
+ end
+
+ def demo_set(cmd, file)
+ demo_clear()
+ clicks = Tk::Clock.clicks
+ @demo_scripts.__send__(cmd, @tree2)
+ clicks = Tk::Clock.clicks - clicks
+ puts "set list in #{'%.2g'%(clicks/1000000.0)} seconds (#{clicks} clicks)"
+ @tree2.xview_moveto(0)
+ @tree2.yview_moveto(0)
+ Tk.update
+ display_styles_in_list()
+ show_source(file)
+ end
+
+ def display_styles_in_list
+ # Create elements and styles the first time this is called
+ if @tree4.style_names.empty?
+ @tree4.element_create('e1', :text,
+ :fill=>[@SystemHighlightText,['selected','focus']])
+ @tree4.element_create('e2', :text,
+ :fill=>[
+ @SystemHighlightText, ['selected','focus'],
+ '', ['selected','!focus'],
+ 'blue', []
+ ])
+ @tree4.element_create('e3', :rect, :showfocus=>true,
+ :fill=>[
+ @SystemHighlight, ['selected','focus'],
+ 'gray', ['selected', '!focus']
+ ])
+
+ @tree4.style_create('s1')
+ @tree4.style_elements('s1', ['e3', 'e1'])
+ @tree4.style_layout('s1', 'e3', :union=>['e1'], :ipadx=>1, :ipady=>[0,1])
+
+ @tree4.style_create('s2')
+ @tree4.style_elements('s2', ['e3', 'e1', 'e2'])
+ @tree4.style_layout('s2', 'e1', :padx=>[0,4])
+ @tree4.style_layout('s2', 'e3', :union=>['e1', 'e2'],
+ :ipadx=>1, :ipady=>[0,1])
+ end
+
+ # Clear the list
+ @tree4.item_delete(:all)
+
+ # One item for each element in the demo list
+ @tree2.element_names.sort.each{|elem|
+ if $Version_1_1_OrLater
+ item = @tree4.item_create(:button=>true)
+ @tree4.item_collapse(item)
+ else
+ item = @tree4.item_create
+ @tree4.item_hasbutton(item, true)
+ @tree4.collapse(item)
+ end
+ @tree4.item_style_set(item, 0, 's1')
+ @tree4.item_text(item, 0,
+ "Element #{elem} (#{@tree2.element_type(elem)})")
+
+ # One item for each configuration option for this element
+ @tree2.element_configinfo(elem).each{|name, x, y, default, current|
+ item2 = @tree4.item_create
+
+ if default == current
+ @tree4.item_style_set(item2, 0, 's1')
+ @tree4.item_complex(item2, [
+ ['e1', {:text=>"#{name} #{current.inspect}"}]
+ ])
+ else
+ @tree4.item_style_set(item2, 0, 's2')
+ @tree4.item_complex(item2, [
+ ['e1', {:text=>name}],
+ ['e2', {:text=>current.inspect}]
+ ])
+ end
+
+ @tree4.item_lastchild(item, item2)
+ }
+
+ @tree4.item_lastchild(:root, item)
+ }
+
+ # One item for each style in the demo list
+ @tree2.style_names.sort.each{|sty|
+ if $Version_1_1_OrLater
+ item = @tree4.item_create(:button=>true)
+ @tree4.item_collapse(item)
+ else
+ item = @tree4.item_create
+ @tree4.item_hasbutton(item, true)
+ @tree4.collapse(item)
+ end
+ @tree4.item_style_set(item, 0, 's1')
+ @tree4.item_text(item, 0, "Style #{sty}")
+
+ # One item for each element in the style
+ @tree2.style_elements(sty).each{|elem|
+ if $Version_1_1_OrLater
+ item2 = @tree4.item_create(:button=>true)
+ @tree4.item_collapse(item2)
+ else
+ item2 = @tree4.item_create
+ @tree4.item_hasbutton(item2, true)
+ @tree4.collapse(item2)
+ end
+ @tree4.item_style_set(item2, 0, 's1')
+ @tree4.item_text(item2, 0,
+ "Element #{elem} (#{@tree2.element_type(elem)})")
+
+ # One item for each layout option for this element in this style
+ @tree2.style_layout(sty, elem).each{|k, v|
+ item3 = @tree4.item_create
+ unless $Version_1_1_OrLater
+ @tree4.item_hasbutton(item3, false)
+ end
+ @tree4.item_style_set(item3, 0, 's1')
+ @tree4.item_text(item3, 0, "#{k} #{v.inspect}")
+ @tree4.item_lastchild(item2, item3)
+ }
+
+ @tree4.item_lastchild(item, item2)
+ }
+
+ @tree4.item_lastchild(:root, item)
+ }
+
+ @tree4.xview_moveto(0)
+ @tree4.yview_moveto(0)
+ end
+
+ def display_styles_in_item(item)
+ @tree3.column_configure(0, :text=>"Styles in item #{@tree2.index(item)}")
+
+ # Create elements and styles the first time this is called
+ if @tree3.style_names.empty?
+ @tree3.element_create('e1', :text,
+ :fill=>[@SystemHighlightText,['selected','focus']])
+ @tree3.element_create('e2', :text,
+ :fill=>[
+ @SystemHighlightText, ['selected','focus'],
+ '', ['selected','!focus'],
+ 'blue', []
+ ])
+ @tree3.element_create('e3', :rect, :showfocus=>true,
+ :fill=>[
+ @SystemHighlight, ['selected','focus'],
+ 'gray', ['selected', '!focus']
+ ])
+
+ @tree3.style_create('s1')
+ @tree3.style_elements('s1', ['e3', 'e1'])
+ @tree3.style_layout('s1', 'e3', :union=>['e1'], :ipadx=>1, :ipady=>[0,1])
+
+ @tree3.style_create('s2')
+ @tree3.style_elements('s2', ['e3', 'e1', 'e2'])
+ @tree3.style_layout('s2', 'e1', :padx=>[0,4])
+ @tree3.style_layout('s2', 'e3', :union=>['e1', 'e2'],
+ :ipadx=>1, :ipady=>[0,1])
+ end
+ # Clear the list
+ @tree3.item_delete(:all)
+
+ # One item for each item-column
+ column = 0
+ @tree2.item_style_set(item).each{|sty|
+ item2 = @tree3.item_create
+ if $Version_1_1_OrLater
+ @tree3.item_collapse(item2)
+ else
+ @tree3.collapse(item2)
+ end
+ @tree3.item_style_set(item2, 0, 's1')
+ @tree3.item_element_configure(item2, 0, 'e1',
+ :text=>"Column #{column}: Style #{sty}")
+
+ button = false
+
+ # One item for each element in this style
+ unless sty.to_s.empty?
+ @tree2.item_style_elements(item, column).each{|elem|
+ button = true
+ if $Version_1_1_OrLater
+ item3 = @tree3.item_create(:button=>true)
+ else
+ item3 = @tree3.item_create
+ @tree3.item_hasbutton(item3, true)
+ end
+ if $Version_1_1_OrLater
+ @tree3.item_collapse(item3)
+ else
+ @tree3.collapse(item3)
+ end
+ @tree3.item_style_set(item3, 0, 's1')
+ @tree3.item_element_configure(item3, 0, 'e1',
+ :text=>"Element #{elem} (#{@tree2.element_type(elem)})")
+
+ # One item for each configuration option in this element
+ @tree2.item_element_configinfo(item, column, elem) \
+ .each{|name, x, y, default, current|
+ item4 = @tree3.item_create
+ masterDefault = @tree2.element_cget(elem, name)
+ sameAsMaster = (masterDefault == current)
+ if !sameAsMaster && current == ''
+ sameAsMaster = true
+ current = masterDefault
+ end
+
+ if sameAsMaster
+ @tree3.item_style_set(item4, 0, 's1')
+ @tree3.item_complex(item4, [
+ ['e1',
+ {:text=>"#{name} #{current.inspect}"}]
+ ])
+ else
+ @tree3.item_style_set(item4, 0, 's2')
+ @tree3.item_complex(item4, [
+ ['e1', {:text=>name}],
+ ['e2', {:text=>current.inspect}]
+ ])
+ end
+ @tree3.item_lastchild(item3, item4)
+ }
+ @tree3.item_lastchild(item2, item3)
+ }
+ if $Version_1_1_OrLater
+ @tree3.item_configure(item2, :button=>true) if button
+ else
+ @tree3.item_hasbutton(item2, true) if button
+ end
+ end
+ @tree3.item_lastchild(:root, item2)
+ column += 1
+ }
+
+ @tree3.xview_moveto(0)
+ @tree3.yview_moveto(0)
+ end
+
+ def demo_clear
+ # Clear the demo list
+ @tree2.item_delete(:all)
+
+ # Clear all bindings on the demo list added by the previous demo.
+ # This is why DontDelete is used for the <Selection> binding.
+ @tree2.notify_bindinfo(@tree2).each{|ev|
+ @tree2.notify_bind_remove(@tree2, ev)
+ }
+
+ # Clear all run-time states
+ @tree2.state_names.each{|st| @tree2.state_undefine(st) }
+
+ # Clear the styles-in-item list
+ @tree3.item_delete(:all)
+
+ # Delete columns in demo list
+ while (@tree2.numcolumns > 0)
+ @tree2.column_delete(0)
+ end
+
+ # Delete all styles in demo list
+ @tree2.style_delete(*(@tree2.style_names))
+
+ # Delete all elements in demo list
+ @tree2.element_delete(*(@tree2.element_names))
+
+ if $Version_1_1_OrLater
+ @tree2.item_configure(:root, :button=>false)
+ @tree2.item_expand(:root)
+ else
+ @tree2.item_hasbutton(:root, false)
+ @tree2.expand(:root)
+ end
+
+ # Restore some happy defaults to the demo list
+ # if $Version_1_1_OrLater
+ if @has_bgimg
+ @tree2.configure(:orient=>:vertical, :wrap=>'',
+ :xscrollincrement=>0, :yscrollincrement=>0,
+ :itemheight=>0, :showheader=>true,
+ :background=>'white', :scrollmargin=>0,
+ :xscrolldelay=>50, :yscrolldelay=>50,
+ :openbuttonimage=>'', :closedbuttonimage=>'',
+ :backgroundmode=>:row, :treecolumn=>0, :indent=>19,
+ :defaultstyle=>'', :backgroundimage=>'')
+ else
+ @tree2.configure(:orient=>:vertical, :wrap=>'',
+ :xscrollincrement=>0, :yscrollincrement=>0,
+ :itemheight=>0, :showheader=>true,
+ :background=>'white', :scrollmargin=>0,
+ :xscrolldelay=>50, :yscrolldelay=>50,
+ :openbuttonimage=>'', :closedbuttonimage=>'',
+ :backgroundmode=>:row, :treecolumn=>0, :indent=>19)
+ end
+
+ # Restore default bindings to the demo list
+ @tree2.bindtags = [ @tree2, Tk::TreeCtrl, @tree2.winfo_toplevel, :all ]
+
+ @tree2.winfo_children.each{|w|
+ w.destroy unless @non_clear_list.include?(w)
+ }
+ end
+end
+
+TkTreeCtrl_demo.new($ScriptDir)
+
+##############################################
+
+def cursor_window(top = nil)
+ top.destroy if top.kind_of?(TkWindow) && top.winfo_exist?
+ top = TkToplevel.new(:title=>'Cursor Window')
+
+ c = TkCanvas.new(top, :background=>'white',
+ :width=>50*10, :highlightthickness=>0,
+ :borderwidth=>0).pack(:expand=>true, :fill=>:both)
+ cursors = %w(
+ X_cursor
+ arrow
+ based_arrow_down
+ based_arrow_up
+ boat
+ bogosity
+ bottom_left_corner
+ bottom_right_corner
+ bottom_side
+ bottom_tee
+ box_spiral
+ center_ptr
+ circle
+ clock
+ coffee_mug
+ cross
+ cross_reverse
+ crosshair
+ diamond_cross
+ dot
+ dotbox
+ double_arrow
+ draft_large
+ draft_small
+ draped_box
+ exchange
+ fleur
+ gobbler
+ gumby
+ hand1
+ hand2
+ heart
+ icon
+ iron_cross
+ left_ptr
+ left_side
+ left_tee
+ leftbutton
+ ll_angle
+ lr_angle
+ man
+ middlebutton
+ mouse
+ pencil
+ pirate
+ plus
+ question_arrow
+ right_ptr
+ right_side
+ right_tee
+ rightbutton
+ rtl_logo
+ sailboat
+ sb_down_arrow
+ sb_h_double_arrow
+ sb_left_arrow
+ sb_right_arrow
+ sb_up_arrow
+ sb_v_double_arrow
+ shuttle
+ sizing
+ spider
+ spraycan
+ star
+ target
+ tcross
+ top_left_arrow
+ top_left_corner
+ top_right_corner
+ top_side
+ top_tee
+ trek
+ ul_angle
+ umbrella
+ ur_angle
+ watch
+ xterm
+ )
+
+ orig_cursor = c.cursor
+ col = 0
+ row = 0
+
+ cursors.each{|cur|
+ x = col * 50
+ y = row * 40
+
+ begin
+ c.cursor = cur
+
+ r = TkcRectangle.new(c, x, y, x+50, y+40,
+ :fill=>'gray90', :outline=>'black', :width=>2)
+ t = TkcText.new(c, x+50/2, y+4, :text=>cur, :anchor=>:n, :width=>42)
+
+ col += 1
+ if col >= 10
+ col = 0
+ row += 1
+ end
+
+ r.bind('Enter', proc{c.cursor = cur; r.fill = 'linen'})
+ r.bind('Leave', proc{c.cursor = ''; r.fill = 'gray90'})
+
+ t.bind('Enter', proc{c.cursor = cur})
+ t.bind('Leave', proc{c.cursor = ''})
+ rescue
+ c.cursor = orig_cursor
+ end
+ }
+
+ c.cursor = orig_cursor
+ c.height = (row + 1) * 40
+end
+
+cursor_window()
+
+##############################################
+
+# A little screen magnifier for X11
+if Tk::PLATFORM['platform'] == 'unix' && Tk.windowingsystem != 'aqua'
+ def show_loupe(setting=nil)
+ loupe = (setting.kind_of?(Hash))? setting: {}
+ loupe[:zoom] = 3 unless loupe[:zoom]
+ loupe[:x] = 0 unless loupe[:x]
+ loupe[:y] = 0 unless loupe[:y]
+ loupe[:auto] = true unless loupe[:auto]
+ loupe[:delay] = 500 unless loupe[:delay]
+ loupe[:image] =
+ TkPhotoImage.new(:width=>150, :height=>150) unless loupe[:image]
+
+ top = TkToplevel.new(:geometry=>'-0+30',
+ :title=>'A little screen magnifier for X11')
+ TkLabel.new(top, :image=>loupe[:image]).pack
+
+ TkTimer.new(proc{loupe[:delay]}, -1, proc{
+ x, y = TkWinfo.pointerxy(Tk.root)
+ if loupe[:auto] || loupe[:x] != x || loupe[:y] != y
+ w = loupe[:image].width
+ h = loupe[:image].height
+ Tk::TreeCtrl.loupe(loupe[:image], x, y, w, h, loupe[:zoom])
+ loupe[:x] = x
+ loupe[:y] = y
+ end
+ }).start
+ end
+
+ show_loupe()
+end
+
+##############################################
+
+Tk.mainloop
diff --git a/jni/ruby/ext/tk/sample/tkextlib/treectrl/explorer.rb b/jni/ruby/ext/tk/sample/tkextlib/treectrl/explorer.rb
new file mode 100644
index 0000000..1b8c2a8
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkextlib/treectrl/explorer.rb
@@ -0,0 +1,430 @@
+
+def demoExplorerAux(t, dir_proc, file_proc)
+ base_dir = File.dirname(File.dirname(@ScriptDir))
+
+ clicks = Tk::Clock.clicks
+ globDirs = Dir.glob(File.join(base_dir, '*')).find_all{|file|
+ FileTest.directory?(file)
+ }
+ clickGlobDirs = Tk::Clock.clicks - clicks
+
+ clicks = Tk::Clock.clicks
+ list = globDirs.sort
+ clickSortDirs = Tk::Clock.clicks - clicks
+
+ clicks = Tk::Clock.clicks
+ list.each{|file| dir_proc.call(file)}
+ clickAddDirs = Tk::Clock.clicks - clicks
+
+ clicks = Tk::Clock.clicks
+ globFiles = Dir.glob(File.join(base_dir, '*')).find_all{|file|
+ FileTest.file?(file)
+ }
+ clickGlobFiles = Tk::Clock.clicks - clicks
+
+ clicks = Tk::Clock.clicks
+ list = globFiles.sort
+ clickSortFiles = Tk::Clock.clicks - clicks
+
+ clicks = Tk::Clock.clicks
+ list.each{|file| file_proc.call(file)}
+ clickAddFiles = Tk::Clock.clicks - clicks
+
+ gd = '%.2g' % (clickGlobDirs / 1000000.0)
+ sd = '%.2g' % (clickSortDirs / 1000000.0)
+ ad = '%.2g' % (clickAddDirs / 1000000.0)
+ gf = '%.2g' % (clickGlobFiles / 1000000.0)
+ sf = '%.2g' % (clickSortFiles / 1000000.0)
+ af = '%.2g' % (clickAddFiles / 1000000.0)
+
+ puts "dirs(#{globDirs.length}) glob/sort/add #{gd}/#{sd}/#{ad} files(#{globFiles.length}) glob/sort/add #{gf}/#{sf}/#{af}"
+
+ @Priv[:DirCnt, t] = globDirs.length
+end
+
+#
+# Demo: explorer files
+#
+def demoExplorerDetails(t)
+ height = t.font.metrics(:linespace)
+ height = 18 if height < 18
+
+ t.configure(:showroot=>false, :showbuttons=>false, :showlines=>false,
+ :itemheight=>height, :selectmode=>:extended,
+ :xscrollincrement=>20, :scrollmargin=>16,
+ :xscrolldelay=>[500, 50], :yscrolldelay=>[500, 50])
+
+ init_pics('small-*')
+
+ if $HasColumnCreate
+ t.column_create(:text=>'Name', :tag=>'name',
+ :width=>200, :arrow=>:up, :arrowpad=>6)
+ t.column_create(:text=>'Size', :tag=>'size', :justify=>:right,
+ :width=>60, :arrowside=>:left, :arrowgravity=>:right)
+ t.column_create(:text=>'Type', :tag=>'type', :width=>120)
+ t.column_create(:text=>'Modified', :tag=>'modified', :width=>130)
+ else
+ t.column_configure(0, :text=>'Name', :tag=>'name',
+ :width=>200, :arrow=>:up, :arrowpad=>6)
+ t.column_configure(1, :text=>'Size', :tag=>'size', :justify=>:right,
+ :width=>60, :arrowside=>:left, :arrowgravity=>:right)
+ t.column_configure(2, :text=>'Type', :tag=>'type', :width=>120)
+ t.column_configure(3, :text=>'Modified', :tag=>'modified', :width=>130)
+ end
+
+ t.element_create('e1', :image,
+ :image=>[
+ @sel_images['small-folder'], ['selected'],
+ @images['small-folder'], []
+ ])
+ t.element_create('e2', :text, :lines=>1,
+ :fill=>[@SystemHighlightText, ['selected', 'focus']])
+ t.element_create('txtType', :text, :lines=>1)
+ t.element_create('txtSize', :text, :lines=>1,
+ :datatype=>:integer, :format=>'%dKB')
+ t.element_create('txtDate', :text, :lines=>1,
+ :datatype=>:time, :format=>'%d/%m/%y %I:%M %p')
+ t.element_create('e4', :rect, :showfocus=>true,
+ :fill=>[
+ @SystemHighlight, ['selected', 'focus'],
+ 'gray', ['selected', '!focus']
+ ])
+
+ # image + text
+ s = t.style_create('styName', :orient=>:horizontal)
+ t.style_elements(s, ['e4', 'e1', 'e2'])
+ t.style_layout(s, 'e1', :expand=>:ns)
+ t.style_layout(s, 'e2', :padx=>[2,0], :squeeze=>:x, :expand=>:ns)
+ t.style_layout(s, 'e4', :union=>['e2'], :iexpand=>:ns, :ipadx=>2)
+
+ # column 1: text
+ s = t.style_create('stySize')
+ t.style_elements(s, ['txtSize'])
+ t.style_layout(s, 'txtSize', :padx=>6, :squeeze=>:x, :expand=>:ns)
+
+ # column 2: text
+ s = t.style_create('styType')
+ t.style_elements(s, ['txtType'])
+ t.style_layout(s, 'txtType', :padx=>6, :squeeze=>:x, :expand=>:ns)
+
+ # column 3: text
+ s = t.style_create('styDate')
+ t.style_elements(s, ['txtDate'])
+ t.style_layout(s, 'txtDate', :padx=>6, :squeeze=>:x, :expand=>:ns)
+
+ @Priv[:edit, t] = ['e2']
+ @Priv[:sensitive, t] = [ ['name', 'styName', 'e1', 'e2'] ]
+ @Priv[:dragimage, t] = [ ['name', 'styName', 'e1', 'e2'] ]
+
+ t.notify_bind(t, 'Edit-accept',
+ proc{|w, i, tt| w.item_text(i, 0, tt)}, '%T %I %t')
+
+ dir_proc = proc{|file|
+ item = t.item_create
+ t.item_style_set(item, 0, 'styName', 2, 'styType', 3, 'styDate')
+ t.item_complex(item,
+ [['e2', {:text=>File.basename(file)}]],
+ [],
+ [['txtType', {:text=>'Folder'}]],
+ [['txtDate', {:data=>File.mtime(file).tv_sec}]])
+ t.item_lastchild(:root, item)
+ }
+
+ file_proc = proc{|file|
+ item = t.item_create
+ t.item_style_set(item, 0, 'styName', 1, 'stySize',
+ 2, 'styType', 3, 'styDate')
+
+ ext = File.extname(file)
+ case ext
+ when '.dll'
+ img = 'small-dll'
+ when '.exe'
+ img = 'small-exe'
+ when '.txt'
+ img = 'small-txt'
+ else
+ img = 'small-file'
+ end
+
+ type = ext.upcase
+ type = type[1..-1] << ' ' unless type.empty?
+ type << 'File'
+
+ t.item_complex(item,
+ [
+ ['e1', {:image=>[@sel_images[img], ['selected'],
+ @images[img], []]}],
+ ['e2', {:text=>File.basename(file)}]
+ ],
+ [ ['txtSize', {:data=>File.size(file)/1024 + 1}] ],
+ [ ['txtType', {:text=>type}] ],
+ [ ['txtDate', {:data=>File.mtime(file).tv_sec}] ]
+ )
+ t.item_lastchild(:root, item)
+ }
+
+ demoExplorerAux(t, dir_proc, file_proc)
+
+ @SortColumn = 0
+ t.notify_bind(t, 'Header-invoke',
+ proc{|w, c| explorerHeaderInvoke(t, w, c)}, '%T %C')
+
+ t.bindtags = [ t, 'TreeCtrlFileList', Tk::TreeCtrl, t.winfo_toplevel, :all ]
+end
+
+def explorerHeaderInvoke(t, w, c)
+ if (c == @SortColumn)
+ if t.column_cget(@SortColumn, :arrow) == 'down'
+ order = :increasing
+ arrow = :up
+ else
+ order = :decreasing
+ arrow = :down
+ end
+ else
+ if t.column_cget(@SortColumn, :arrow) == 'down'
+ order = :decreasing
+ arrow = :down
+ else
+ order = :increasing
+ arrow = :up
+ end
+ t.column_configure(@SortColumn, :arrow=>:none)
+ @SortColumn = c
+ end
+
+ t.column_configure(c, :arrow=>arrow)
+ dirCount = TkComm.number(@Priv[:DirCnt, t])
+ lastDir = dirCount - 1
+ case t.column_cget(c, :tag)
+ when 'name'
+ if dirCount > 0
+ t.item_sort(:root, order, {:last=>"root child #{lastDir}"},
+ {:column=>c, :dictionary=>true})
+ end
+ if dirCount < t.numitems - 1
+ t.item_sort(:root, order, {:first=>"root child #{dirCount}"},
+ {:column=>c, :dictionary=>true})
+ end
+
+ when 'size'
+ if dirCount < t.numitems - 1
+ t.item_sort(:root, order, {:first=>"root child #{dirCount}"},
+ {:column=>c, :integer=>true},
+ {:column=>'name', :dictionary=>true})
+ end
+
+ when 'type'
+ if dirCount < t.numitems - 1
+ t.item_sort(:root, order, {:first=>"root child #{dirCount}"},
+ {:column=>c, :dictionary=>true},
+ {:column=>'name', :dictionary=>true})
+ end
+
+ when 'modified'
+ if dirCount > 0
+ t.item_sort(:root, order, {:last=>"root child #{lastDir}"},
+ {:column=>c, :integer=>true},
+ {:column=>'name', :dictionary=>true})
+ end
+ if dirCount < t.numitems - 1
+ t.item_sort(:root, order, {:first=>"root child #{dirCount}"},
+ {:column=>c, :integer=>true},
+ {:column=>'name', :dictionary=>true})
+ end
+
+ end
+end
+
+def demoExplorerLargeIcons(t)
+ # Item height is 32 for icon, 4 padding, 3 lines of text
+ itemHeight = 32 + 4 + t.font.metrics(:linespace) * 3
+
+ t.configure(:showroot=>false, :showbuttons=>false, :showlines=>false,
+ :selectmode=>:extended, :wrap=>:window, :orient=>:horizontal,
+ :itemheight=>itemHeight, :showheader=>false, :scrollmargin=>16,
+ :xscrolldelay=>[500, 50], :yscrolldelay=>[500, 50])
+
+ init_pics('big-*')
+
+ if $HasColumnCreate
+ t.column_create(:width=>75)
+ else
+ t.column_configure(0, :width=>75)
+ end
+
+ t.element_create('elemImg', :image,
+ :image=>[
+ @sel_images['big-folder'], ['selected'],
+ @images['big-folder'], []
+ ])
+ t.element_create('elemTxt', :text, :justify=>:center,
+ :lines=>1, :width=>71, :wrap=>:word,
+ :fill=>[@SystemHighlightText, ['selected', 'focus']])
+ t.element_create('elemSel', :rect, :showfocus=>true,
+ :fill=>[
+ @SystemHighlight, ['selected', 'focus'],
+ 'gray', ['selected']
+ ])
+
+ # image + text
+ s = t.style_create('STYLE', :orient=>:vertical)
+ t.style_elements(s, ['elemSel', 'elemImg', 'elemTxt'])
+ t.style_layout(s, 'elemImg', :expand=>:we)
+ t.style_layout(s, 'elemTxt',
+ :pady=>[4,0], :padx=>2, :squeeze=>:x, :expand=>:we)
+ t.style_layout(s, 'elemSel', :union=>['elemTxt'])
+
+ @Priv[:edit, t] = ['elemTxt']
+ @Priv[:sensitive, t] = [ [0, 'STYLE', 'elemImg', 'elemTxt'] ]
+ @Priv[:dragimage, t] = [ [0, 'STYLE', 'elemImg', 'elemTxt'] ]
+
+ t.notify_bind(t, 'Edit-accept',
+ proc{|w, i, tt| w.item_text(i, 0, tt)}, '%T %I %t')
+
+ dir_proc = proc{|file|
+ item = t.item_create
+ t.item_style_set(item, 0, 'STYLE')
+ t.item_text(item, 0, File.basename(file))
+ t.item_lastchild(:root, item)
+ }
+
+ file_proc = proc{|file|
+ item = t.item_create
+ t.item_style_set(item, 0, 'STYLE')
+
+ ext = File.extname(file)
+ case ext
+ when '.dll'
+ img = 'big-dll'
+ when '.exe'
+ img = 'big-exe'
+ when '.txt'
+ img = 'big-txt'
+ else
+ img = 'big-file'
+ end
+
+ type = ext.upcase
+ type = type[1..-1] << ' ' unless type.empty?
+ type << 'File'
+
+ t.item_complex(item,
+ [
+ ['elemImg', {:image=>[@sel_images[img], ['selected'],
+ @images[img], []]}],
+ ['elemTxt', {:text=>File.basename(file)}]
+ ])
+ t.item_lastchild(:root, item)
+ }
+
+ demoExplorerAux(t, dir_proc, file_proc)
+
+ t.activate(t.index('root firstchild'))
+
+ t.notify_bind(t, 'ActiveItem',
+ proc{|w, a, c|
+ w.item_element_configure(a, 0, 'elemTxt', :lines=>'')
+ w.item_element_configure(c, 0, 'elemTxt', :lines=>3)
+ }, '%T %p %c')
+
+ t.bindtags = [ t, 'TreeCtrlFileList', Tk::TreeCtrl, t.winfo_toplevel, :all ]
+end
+
+# Tree is horizontal, wrapping occurs at right edge of window, each item
+# is as wide as the smallest needed multiple of 110 pixels
+def demoExplorerSmallIcons(t)
+ demoExplorerList(t)
+ t.configure(:orient=>:horizontal, :xscrollincrement=>0)
+ t.column_configure(0, :width=>'', :stepwidth=>110, :widthhack=>false)
+end
+
+# Tree is vertical, wrapping occurs at bottom of window, each range has the
+# same width (as wide as the longest item), xscrollincrement is by range
+def demoExplorerList(t)
+ height = t.font.metrics(:linespace) + 2
+ height = 18 if height < 18
+
+ t.configure(:showroot=>false, :showbuttons=>false, :showlines=>false,
+ :itemheight=>height, :selectmode=>:extended, :wrap=>:window,
+ :showheader=>false, :scrollmargin=>16,
+ :xscrolldelay=>[500, 50], :yscrolldelay=>[500, 50])
+
+ init_pics('small-*')
+
+ if $HasColumnCreate
+ t.column_create(:widthhack=>true)
+ else
+ t.column_configure(0, :widthhack=>true)
+ end
+
+ t.element_create('elemImg', :image,
+ :image=>[
+ @sel_images['small-folder'], ['selected'],
+ @images['small-folder'], []
+ ])
+ t.element_create('elemTxt', :text, :lines=>1,
+ :fill=>[@SystemHighlightText, ['selected', 'focus']])
+ t.element_create('elemSel', :rect, :showfocus=>true,
+ :fill=>[
+ @SystemHighlight, ['selected', 'focus'],
+ 'gray', ['selected', '!focus']
+ ])
+
+ # image + text
+ s = t.style_create('STYLE')
+ t.style_elements(s, ['elemSel', 'elemImg', 'elemTxt'])
+ t.style_layout(s, 'elemImg', :expand=>:ns)
+ t.style_layout(s, 'elemTxt', :squeeze=>:x, :expand=>:ns, :padx=>[2,0])
+ t.style_layout(s, 'elemSel', :union=>['elemTxt'], :iexpand=>:ns, :ipadx=>2)
+
+ @Priv[:edit, t] = ['elemTxt']
+ @Priv[:sensitive, t] = [ [0, 'STYLE', 'elemImg', 'elemTxt'] ]
+ @Priv[:dragimage, t] = [ [0, 'STYLE', 'elemImg', 'elemTxt'] ]
+
+ t.notify_bind(t, 'Edit-accept',
+ proc{|w, i, tt| w.item_text(i, 0, tt)}, '%T %I %t')
+
+ dir_proc = proc{|file|
+ item = t.item_create
+ t.item_style_set(item, 0, 'STYLE')
+ t.item_text(item, 0, File.basename(file))
+ t.item_lastchild(:root, item)
+ }
+
+ file_proc = proc{|file|
+ item = t.item_create
+ t.item_style_set(item, 0, 'STYLE')
+
+ ext = File.extname(file)
+ case ext
+ when '.dll'
+ img = 'small-dll'
+ when '.exe'
+ img = 'small-exe'
+ when '.txt'
+ img = 'small-txt'
+ else
+ img = 'small-file'
+ end
+
+ type = ext.upcase
+ type = type[1..-1] << ' ' unless type.empty?
+ type << 'File'
+
+ t.item_complex(item,
+ [
+ ['elemImg', {:image=>[@sel_images[img], ['selected'],
+ @images[img], []]}],
+ ['elemTxt', {:text=>File.basename(file)}]
+ ])
+ t.item_lastchild(:root, item)
+ }
+
+ demoExplorerAux(t, dir_proc, file_proc)
+
+ t.activate(t.item_firstchild(:root))
+
+ t.bindtags = [ t, 'TreeCtrlFileList', Tk::TreeCtrl, t.winfo_toplevel, :all ]
+end
diff --git a/jni/ruby/ext/tk/sample/tkextlib/treectrl/help.rb b/jni/ruby/ext/tk/sample/tkextlib/treectrl/help.rb
new file mode 100644
index 0000000..31ec9eb
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkextlib/treectrl/help.rb
@@ -0,0 +1,404 @@
+#
+# Demo: Help contents
+#
+def demoHelpContents(t)
+ height = t.font.metrics(:linespace)
+ height = 18 if height < 18
+ t.configure(:showroot=>false, :showbuttons=>false, :showlines=>false,
+ :itemheight=>height, :selectmode=>:browse)
+
+ init_pics('help-*')
+
+ if $Version_1_1_OrLater
+ t.column_create(:text=>'Help Contents')
+ else # TreeCtrl 1.0
+ t.column_configure(0, :text=>'Help Contents')
+ end
+
+ # Define a new item state
+ t.state_define('mouseover')
+
+ t.element_create('e1', :image, :image=>@images['help-page'])
+ t.element_create('e2', :image, :image=>[
+ @images['help-book-open'], ['open'],
+ @images['help-book-closed'], [],
+ ])
+ t.element_create('e3', :text,
+ :font=>[t.font.dup.underline(true), ['mouseover']],
+ :fill=>[
+ @SystemHighlightText, ['selected', 'focus'],
+ 'blue', ['mouseover']
+ ])
+ t.element_create('e4', :rect, :showfocus=>true,
+ :fill=>[@SystemHighlight, ['selected', 'focus']])
+
+ # book
+ s = t.style_create('s1')
+ t.style_elements(s, ['e4', 'e1', 'e3'])
+ t.style_layout(s, 'e1', :padx=>[0,4], :expand=>:ns)
+ t.style_layout(s, 'e3', :expand=>:ns)
+ t.style_layout(s, 'e4', :union=>['e3'], :iexpand=>:ns, :ipadx=>2)
+
+ # page
+ s = t.style_create('s2')
+ t.style_elements(s, ['e4', 'e2', 'e3'])
+ t.style_layout(s, 'e2', :padx=>[0,4], :expand=>:ns)
+ t.style_layout(s, 'e3', :expand=>:ns)
+ t.style_layout(s, 'e4', :union=>['e3'], :iexpand=>:ns, :ipadx=>2)
+
+ parentList = [:root, '', '', '', '', '', '']
+ parent = :root
+ [
+ [0, 's1', "Welcome to Help"],
+ [0, 's2', "Introducing Windows 98"],
+ [1, 's2', "How to Use Help"],
+ [2, 's1', "Find a topic"],
+ [2, 's1', "Get more out of help"],
+ [1, 's2', "Register Your Software"],
+ [2, 's1', "Registering Windows 98 online"],
+ [1, 's2', "What's New in Windows 98"],
+ [2, 's1', "Innovative, easy-to-use features"],
+ [2, 's1', "Improved reliability"],
+ [2, 's1', "A faster operating system"],
+ [2, 's1', "True Web integration"],
+ [2, 's1', "More entertaining and fun"],
+ [1, 's2', "If You're New to Windows 98"],
+ [2, 's2', "Tips for Macintosh Users"],
+ [3, 's1', "Why does the mouse have two buttons?"]
+ ].each{|depth, style, text|
+ item = t.item_create
+ t.item_style_set(item, 0, style)
+ t.item_element_configure(item, 0, 'e3', :text=>text)
+ if $Version_1_1_OrLater
+ t.item_collapse(item)
+ else # TreeCtrl 1.0
+ t.collapse(item)
+ end
+ t.item_lastchild(parentList[depth], item)
+ depth += 1
+ parentList[depth] = item
+ }
+
+ treeCtrlHelp = TkBindTag.new
+
+ treeCtrlHelp.bind('Double-ButtonPress-1',
+ proc{|w, x, y|
+ if w.identify(x, y)[0] == 'header'
+ Tk::TreeCtrl::BindCallback.doubleButton1(w, x, y)
+ else
+ helpButton1(w, x, y)
+ end
+ Tk.callback_break
+ }, '%W %x %y')
+
+ treeCtrlHelp.bind('ButtonPress-1',
+ proc{|w, x, y|
+ helpButton1(w, x, y)
+ Tk.callback_break
+ }, '%W %x %y')
+
+ treeCtrlHelp.bind('Button1-Motion',
+ proc{|w, x, y|
+ helpMotion1(w, x, y)
+ Tk.callback_break
+ }, '%W %x %y')
+
+ treeCtrlHelp.bind('Button1-Leave',
+ proc{|w, x, y|
+ helpLeave1(w, x, y)
+ Tk.callback_break
+ }, '%W %x %y')
+
+ treeCtrlHelp.bind('ButtonRelease-1',
+ proc{|w, x, y|
+ helpRelease1(w, x, y)
+ Tk.callback_break
+ }, '%W %x %y')
+
+ treeCtrlHelp.bind('Motion', proc{|w, x, y| helpMotion(w, x, y) }, '%W %x %y')
+
+ treeCtrlHelp.bind('Leave', proc{|w, x, y| helpMotion(w, x, y) }, '%W %x %y')
+
+ treeCtrlHelp.bind('KeyPress-Return',
+ proc{|w, x, y|
+ if w.selection_get.length == 1
+ if $Version_1_1_OrLater
+ w.item_toggle(w.selection_get[0])
+ else # TreeCtrl 1.0
+ w.toggle(w.selection_get[0])
+ end
+ end
+ Tk.callback_break
+ }, '%W %x %y')
+
+ @Priv[:help, :prev] = ''
+
+ t.bindtags = [ t, treeCtrlHelp, Tk::TreeCtrl, t.winfo_toplevel, :all ]
+end
+
+# This is an alternate implementation that does not define a new item state
+# to change the appearance of the item under the cursor.
+def demoHelpContents2(t)
+ height = t.font.metrics(:linespace)
+ height = 18 if height < 18
+ t.configure(:showroot=>false, :showbuttons=>false, :showlines=>false,
+ :itemheight=>height, :selectmode=>:browse)
+
+ init_pics('help-*')
+
+ if $Version_1_1_OrLater
+ t.column_create(:text=>'Help Contents')
+ else # TreeCtrl 1.0
+ t.column_configure(0, :text=>'Help Contents')
+ end
+
+ t.element_create('e1', :image, :image=>@images['help-page'])
+ t.element_create('e2', :image, :image=>[
+ @images['help-book-open'], ['open'],
+ @images['help-book-closed'], [],
+ ])
+ t.element_create('e3', :text,
+ :fill=>[
+ @SystemHighlightText, ['selected', 'focus'],
+ 'blue', []
+ ])
+ t.element_create('e4', :rect, :showfocus=>true,
+ :fill=>[@SystemHighligh, ['selected', 'focus']])
+ t.element_create('e5', :text, :font=>t.font.dup.underline(true),
+ :fill=>[
+ @SystemHighlightText, ['selected', 'focus'],
+ 'blue', []
+ ])
+
+ # book
+ s = t.style_create('s1')
+ t.style_elements(s, ['e4', 'e1', 'e3'])
+ t.style_layout(s, 'e1', :padx=>[0,4], :expand=>:ns)
+ t.style_layout(s, 'e3', :expand=>:ns)
+ t.style_layout(s, 'e4', :union=>['e3'], :iexpand=>:ns, :ipadx=>2)
+
+ # page
+ s = t.style_create('s2')
+ t.style_elements(s, ['e4', 'e2', 'e3'])
+ t.style_layout(s, 'e2', :padx=>[0,4], :expand=>:ns)
+ t.style_layout(s, 'e3', :expand=>:ns)
+ t.style_layout(s, 'e4', :union=>['e3'], :iexpand=>:ns, :ipadx=>2)
+
+ # book (focus)
+ s = t.style_create('s1.f')
+ t.style_elements(s, ['e4', 'e1', 'e5'])
+ t.style_layout(s, 'e1', :padx=>[0,4], :expand=>:ns)
+ t.style_layout(s, 'e5', :expand=>:ns)
+ t.style_layout(s, 'e4', :union=>['e5'], :iexpand=>:ns, :ipadx=>2)
+
+ # page (focus)
+ s = t.style_create('s2')
+ t.style_elements(s, ['e4', 'e2', 'e5'])
+ t.style_layout(s, 'e2', :padx=>[0,4], :expand=>:ns)
+ t.style_layout(s, 'e5', :expand=>:ns)
+ t.style_layout(s, 'e4', :union=>['e5'], :iexpand=>:ns, :ipadx=>2)
+
+ parentList = [:root, '', '', '', '', '', '']
+ parent = :root
+ [
+ [0, 's1', "Welcome to Help"],
+ [0, 's2', "Introducing Windows 98"],
+ [1, 's2', "How to Use Help"],
+ [2, 's1' "Find a topic"],
+ [2, 's1', "Get more out of help"],
+ [1, 's2', "Register Your Software"],
+ [2, 's1', "Registering Windows 98 online"],
+ [1, 's2', "What's New in Windows 98"],
+ [2, 's1', "Innovative, easy-to-use features"],
+ [2, 's1', "Improved reliability"],
+ [2, 's1', "A faster operating system"],
+ [2, 's1', "True Web integration"],
+ [2, 's1', "More entertaining and fun"],
+ [1, 's2', "If You're New to Windows 98"],
+ [2, 's2', "Tips for Macintosh Users"],
+ [3, 's1', "Why does the mouse have two buttons?"]
+ ].each{|depth, style, text|
+ item = t.item_create
+ t.item_style_set(item, 0, style)
+ t.item_element_configure(item, 0, 'e3', :text=>text)
+ if $Version_1_1_OrLater
+ t.item_collapse(item)
+ else # TreeCtrl 1.0
+ t.collapse(item)
+ end
+ t.item_lastchild(parentList[depth], item)
+ depth += 1
+ parentList[depth] = item
+ }
+
+ treeCtrlHelp = TkBindTag.new
+
+ treeCtrlHelp.bind('Double-ButtonPress-1',
+ proc{|w, x, y|
+ if w.identify(x, y)[0] == 'header'
+ Tk::TreeCtrl::BindCallback.doubleButton1(w, x, y)
+ else
+ helpButton1(w, x, y)
+ end
+ Tk.callback_break
+ }, '%W %x %y')
+
+ treeCtrlHelp.bind('ButtonPress-1',
+ proc{|w, x, y|
+ helpButton1(w, x, y)
+ Tk.callback_break
+ }, '%W %x %y')
+
+ treeCtrlHelp.bind('Button1-Motion',
+ proc{|w, x, y|
+ helpMotion1(w, x, y)
+ Tk.callback_break
+ }, '%W %x %y')
+
+ treeCtrlHelp.bind('Button1-Leave',
+ proc{|w, x, y|
+ helpLeave1(w, x, y)
+ Tk.callback_break
+ }, '%W %x %y')
+
+ treeCtrlHelp.bind('ButtonRelease-1',
+ proc{|w, x, y|
+ helpRelease1(w, x, y)
+ Tk.callback_break
+ }, '%W %x %y')
+
+ treeCtrlHelp.bind('Motion', proc{|w, x, y| helpMotion(w, x, y) }, '%W %x %y')
+
+ treeCtrlHelp.bind('Leave', proc{|w, x, y| helpMotion(w, x, y) }, '%W %x %y')
+
+ treeCtrlHelp.bind('KeyPress-Return',
+ proc{|w, x, y|
+ if w.selection_get.length == 1
+ w.item_toggle(w.selection_get[0])
+ end
+ Tk.callback_break
+ }, '%W %x %y')
+
+ @Priv[:help, :prev] = ''
+
+ t.bindtags = [ t, treeCtrlHelp, Tk::TreeCtrl, t.winfo_toplevel, :all ]
+end
+
+def helpButton1(w, x, y)
+ w.set_focus
+ id = w.identify(x, y)
+ @Priv['buttonMode'] = ''
+ if id[0] == 'header'
+ Tk::TreeCtrl::BindCallback.buttonPress1(w, x, y)
+ elsif id[0] == 'item'
+ item = id[1]
+ # didn't click an element
+ return if id.length != 6
+ if w.selection_includes(item)
+ w.toggle(item)
+ return
+ end
+ if w.selection_get.length > 0
+ item2 = w.selection_get[0]
+ if $Version_1_1_OrLater
+ w.item_collapse(item2)
+ else # TreeCtrl 1.0
+ w.collapse(item2)
+ end
+ w.item_ancestors(item2).each{|i|
+ if $Version_1_1_OrLater
+ w.item_collapse(i) if w.compare(item, '!=', i)
+ else # TreeCtrl 1.0
+ w.collapse(i) if w.compare(item, '!=', i)
+ end
+ }
+ end
+ w.activate(item)
+ if $Version_1_1_OrLater
+ w.item_ancestors(item).each{|i|
+ w.item_expand(i)
+ }
+ w.item_toggle(item)
+ else # TreeCtrl 1.0
+ w.expand(*(w.item_ancestors(item)))
+ w.toggle(item)
+ end
+ w.selection_modify(item, :all)
+ end
+end
+
+def helpMotion1(w, x, y)
+ case @Priv['buttonMode']
+ when 'resize', 'header'
+ Tk::TreeCtrl::BindCallback.motion1(w, x, y)
+ end
+end
+
+def helpLeave1(w, x, y)
+ # This is called when I do ButtonPress-1 on Unix for some reason,
+ # and buttonMode is undefined.
+ return unless @Priv.exist?('buttonMode')
+ case @Priv['buttonMode']
+ when 'header'
+ w.column_configure(@Priv['column'], :sunken=>false)
+ end
+end
+
+def helpRelease1(w, x, y)
+ case @Priv['buttonMode']
+ when 'resize', 'header'
+ Tk::TreeCtrl::BindCallback.release1(w, x, y)
+ end
+ @Priv['buttonMode'] = ''
+end
+
+def helpMotion(w, x, y)
+ id = w.identify(x, y)
+ if id.empty?
+ elsif id[0] == 'header'
+ elsif id[0] == 'item'
+ item = id[1]
+ if id.length == 6
+ if @Priv[:help, :prev] != TkComm._get_eval_string(item)
+ if @Priv[:help, :prev] != ''
+ w.item_state_set(@Priv[:help, :prev], '!mouseover')
+ end
+ w.item_state_set(item, 'mouseover')
+ @Priv[:help, :prev] = item
+ end
+ return
+ end
+ end
+ if @Priv[:help, :prev] != ''
+ w.item_state_set(@Priv[:help, :prev], '!mouseover')
+ @Priv[:help, :prev] = ''
+ end
+end
+
+# Alternate implementation doesn't rely on mouseover state
+def helpMotion2(w, x, y)
+ id = w.identify(x, y)
+ if id[0] == 'header'
+ elsif !id.empty?
+ item = id[1]
+ if id.kength == 6
+ if @Priv[:help, :prev] != TkComm._get_eval_string(item)
+ if @Priv[:help, :prev] != ''
+ style = w.item_style_set(@Priv[:help, :prev], 0)
+ style.sub!(/\.f$/, '')
+ w.item_style_map(@Priv[:help, :prev], 0, style, ['e5', 'e3'])
+ end
+ style = w.item_style_set(item, 0)
+ w.item_style_map(item, 0, style + '.f', ['e3', 'e5'])
+ @Priv[:help, :prev] = item
+ end
+ return
+ end
+ end
+ if @Priv[:help, :prev] != ''
+ style = w.item_style_set(@Priv[:help, :prev], 0)
+ style.sub!(/\.f$/, '')
+ w.item_style_map(@Priv[:help, :prev], 0, style, ['e5', 'e3'])
+ @Priv[:help, :prev] = ''
+ end
+end
diff --git a/jni/ruby/ext/tk/sample/tkextlib/treectrl/imovie.rb b/jni/ruby/ext/tk/sample/tkextlib/treectrl/imovie.rb
new file mode 100644
index 0000000..72134eb
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkextlib/treectrl/imovie.rb
@@ -0,0 +1,130 @@
+#
+# Demo: iMovie
+#
+def demoIMovie(t)
+ t.configure(:showroot=>false, :showbuttons=>false, :showlines=>false,
+ :selectmode=>:browse, :orient=>:horizontal, :wrap=>:window,
+ :showheader=>false, :background=>'#dcdcdc')
+
+ if $HasColumnCreate
+ t.column_create
+ end
+
+ init_pics('imovie-*')
+
+ case @thisPlatform
+ when 'macintosh', 'macosx'
+ font1 = TkFont.new(['Geneva', 9])
+ font2 = TkFont.new(['Geneva', 10])
+ when 'unix'
+ font1 = TkFont.new(['Helvetica', -12])
+ font2 = TkFont.new(['Helvetica', -14])
+ else
+ font1 = TkFont.new(['Helvetica', 8])
+ font2 = TkFont.new(['Helvetica', 10])
+ end
+
+ t.element_create('elemTime', :text, :font=>font1)
+ t.element_create('elemName', :text, :font=>font2, :lines=>1, :width=>80)
+ t.element_create('elemRect', :rect, :outline=>'#827878', :outlinewidth=>1,
+ :fill=>['#ffdc5a', ['selected'], 'white', []])
+ t.element_create('elemImg', :image)
+ t.element_create('elemShadow', :rect, :outline=>'gray', :outlinewidth=>1,
+ :open=>:wn)
+
+ s = t.style_create('STYLE', :orient=>:vertical)
+ t.style_elements(s, [
+ 'elemShadow', 'elemRect', 'elemTime',
+ 'elemImg', 'elemName'
+ ])
+ t.style_layout(s, 'elemShadow', :detach=>true,
+ :padx=>[1,2], :pady=>[1,2], :iexpand=>:es)
+ t.style_layout(s, 'elemTime', :padx=>[2,0])
+ t.style_layout(s, 'elemImg', :pady=>[0,1])
+ t.style_layout(s, 'elemName', :expand=>:we, :ipady=>[0,2], :padx=>[0,3],
+ :squeeze=>:x)
+ t.style_layout(s, 'elemRect', :union=>['elemTime', 'elemImg', 'elemName'],
+ :ipadx=>6, :padx=>[0,3], :pady=>[0,3])
+
+ # Set default item style
+ if $Version_1_1_OrLater
+ t.defaultstyle([s])
+ end
+
+ (0..4).each{|i|
+ [
+ ['15:20', 'Clip 1', @images['imovie-01']],
+ ['19:18', 'Clip 2', @images['imovie-02']],
+ ['07:20', 'Clip 3', @images['imovie-03']],
+ ['07:20', 'Clip 4', @images['imovie-04']],
+ ['07:20', 'Clip 5', @images['imovie-05']],
+ ['07:20', 'Clip 6', @images['imovie-06']],
+ ['07:20', 'Clip 7', @images['imovie-07']]
+ ].each{|time, name, image|
+ item = t.item_create
+ unless $Version_1_1_OrLater
+ t.item_style_set(item, 0, s)
+ end
+ t.item_element_configure(item, 0, 'elemTime', :text=>time)
+ t.item_element_configure(item, 0, 'elemName', :text=>name)
+ t.item_element_configure(item, 0, 'elemImg', :image=>image)
+ t.item_lastchild(:root, item)
+ }
+ }
+
+ t.notify_bind(t, 'Edit-accept', proc{|w, i, c, e, tt|
+ w.item_element_configure(i, c, e, :text=>tt)
+ }, '%T %I %C %E %t')
+
+ iMovie = TkBindTag.new
+ iMovie.bind('ButtonPress-1', proc{|w, x, y|
+ iMovieButton1(w, x, y)
+ }, '%W %x %y')
+
+ t.bindtags = [t, iMovie, Tk::TreeCtrl, t.winfo_toplevel, TkBindTag::ALL]
+end
+
+def iMovieButton1(w, x, y)
+ w.set_focus
+ id = w.identify(x,y)
+
+ if id.empty?
+ # Click outside any item
+
+ elsif id[0] == 'header'
+ # Click in header
+ Tk::TreeCtrl::BindCallback.buttonPress1(w, x, y)
+
+ elsif id[0] == 'item'
+ # Click in item
+ Tk::TreeCtrl::BindCallback.buttonPress1(w, x, y)
+ Tk.update
+ where, item, arg1, arg2, arg3, arg4 = id
+ case arg1
+ when 'column'
+ i = id[1]
+ if id.length == 6
+ e = id[-1]
+ if e == 'elemName'
+ exists = TkWinfo.exist?(w.path + '.entry')
+ Tk::TreeCtrl::BindCallback.entryOpen(w, i, 0, e)
+ ent = TkComm.window(w.path + '.entry')
+ unless exists
+ ent.configure(:borderwidth=>0, :justify=>:center,
+ :background=>'#ffdc5a')
+ x1, y1, x2, y2 = w.item_bbox(i, 0, e)
+ ent.place(:y=>y1 - 1)
+ end
+ ent.selection_clear
+ x1, y1, x2, y2 = w.item_bbox(i)
+ ent.place(:x=>x1 + 1, :width=>x2 - x1 - 5)
+ puts "@#{x - (x1 + 1)}"
+ # ent.icursor = ent.index("@#{x - (x1 + 1)}")
+ ent.icursor = ent.index(TkComm._at(x - (x1 + 1)))
+ end
+ end
+ end
+ end
+
+ Tk.callback_break
+end
diff --git a/jni/ruby/ext/tk/sample/tkextlib/treectrl/layout.rb b/jni/ruby/ext/tk/sample/tkextlib/treectrl/layout.rb
new file mode 100644
index 0000000..488abe2
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkextlib/treectrl/layout.rb
@@ -0,0 +1,159 @@
+#
+# Demo: Layout
+#
+def demoLayout(t)
+ t.configure(:showroot=>false, :showrootbutton=>true, :showbuttons=>true,
+ :showlines=>true, :itemheight=>0, :selectmode=>:browse)
+
+ if $HasColumnCreate
+ t.column_create(:text=>'Layout')
+ else
+ t.column_configure(0, :text=>'Layout')
+ end
+
+ t.element_create('e1', :rect, :width=>30, :height=>30, :fill=>'gray20')
+ t.element_create('e2', :rect, :width=>30, :height=>30, :fill=>'gray40',
+ :outline=>'blue', :outlinewidth=>3)
+ t.element_create('e3', :rect, :fill=>'gray60')
+ t.element_create('e4', :rect, :showfocus=>true,
+ :fill=>[
+ @SystemHighlight, ['selected', 'focus'], 'gray80', []
+ ])
+ t.element_create('e5', :rect, :fill=>'{sky blue}', :width=>20, :height=>20)
+ t.element_create('e6', :rect, :fill=>'{sea green}', :width=>30, :height=>16)
+ t.element_create('e7', :rect, :fill=>'{sky blue}', :width=>30, :height=>16)
+ t.element_create('e8', :rect, :fill=>'gray70', :height=>1)
+
+ s = t.style_create('s1')
+ t.style_elements(s, ['e4', 'e3', 'e1', 'e2', 'e5', 'e6', 'e7'])
+ t.style_layout(s, 'e1', :padx=>[28, 4], :pady=>4)
+ t.style_layout(s, 'e2', :expand=>:es, :padx=>[0, 38])
+ t.style_layout(s, 'e3', :union=>['e1', 'e2'], :ipadx=>4, :ipady=>4, :pady=>2)
+ t.style_layout(s, 'e4', :detach=>true, :iexpand=>:es)
+ t.style_layout(s, 'e5', :detach=>true, :padx=>[2,0], :pady=>2, :iexpand=>:s)
+ t.style_layout(s, 'e6', :detach=>true, :expand=>:ws,
+ :padx=>[0,2], :pady=>[2,0])
+ t.style_layout(s, 'e7', :detach=>true, :expand=>:wn,
+ :padx=>[0,2], :pady=>[0,2])
+
+ if $Version_1_1_OrLater
+ i = t.item_create(:button=>true)
+ else
+ i = t.item_create
+ t.item_hasbutton(i, true)
+ end
+ t.item_style_set(i, 0, s)
+ t.item_lastchild(:root, i)
+ parent = i
+
+ i = t.item_create()
+ unless $Version_1_1_OrLater
+ t.item_hasbutton(i, false)
+ end
+ t.item_style_set(i, 0, s)
+ t.item_lastchild(parent, i)
+
+ ###
+
+ s = t.style_create('s2')
+ t.style_elements(s, ['e4', 'e3', 'e1'])
+ t.style_layout(s, 'e1', :padx=>8, :pady=>8, :iexpand=>:e)
+ t.style_layout(s, 'e3', :union=>['e1'], :ipadx=>[20,4], :ipady=>[4,12])
+ t.style_layout(s, 'e4', :detach=>true, :iexpand=>:es)
+
+ if $Version_1_1_OrLater
+ i = t.item_create(:button=>true)
+ else
+ i = t.item_create
+ t.item_hasbutton(i, true)
+ end
+ t.item_style_set(i, 0, s)
+ t.item_lastchild(:root, i)
+
+ i2 = t.item_create()
+ unless $Version_1_1_OrLater
+ t.item_hasbutton(i2, false)
+ end
+ t.item_style_set(i2, 0, s)
+ t.item_lastchild(i, i2)
+
+ ###
+
+ s = t.style_create('s3')
+ t.style_elements(s, ['e4', 'e3', 'e1', 'e5', 'e6'])
+ t.style_layout(s, 'e4', :union=>['e1', 'e6'], :ipadx=>8, :ipady=>[8,0])
+ t.style_layout(s, 'e3', :union=>['e1', 'e5'], :ipadx=>4, :ipady=>4)
+ t.style_layout(s, 'e5', :ipady=>[0,20])
+
+ if $Version_1_1_OrLater
+ i = t.item_create(:button=>true)
+ else
+ i = t.item_create
+ t.item_hasbutton(i, true)
+ end
+ t.item_style_set(i, 0, s)
+ t.item_lastchild(:root, i)
+
+ i2 = t.item_create()
+ unless $Version_1_1_OrLater
+ t.item_hasbutton(i2, false)
+ end
+ t.item_style_set(i2, 0, s)
+ t.item_lastchild(i, i2)
+
+ ###
+
+ t.element_create('eb', :border, :background=>@SystemButtonFace,
+ :relief=>[:sunken, ['selected'], :raised, []],
+ :thickness=>2, :filled=>true)
+ t.element_create('et', :text)
+
+ text = "Here is a text element surrounded by a border element.\nResize the column to watch me wrap."
+
+ s = t.style_create('e4')
+ t.style_elements(s, ['eb', 'et'])
+ t.style_layout(s, 'eb', :union=>['et'], :ipadx=>2, :ipady=>2)
+ t.style_layout(s, 'et', :squeeze=>:x)
+
+ if $Version_1_1_OrLater
+ i = t.item_create(:button=>true)
+ else
+ i = t.item_create
+ t.item_hasbutton(i, true)
+ end
+ t.item_style_set(i, 0, s)
+ t.item_text(i, 0, text)
+ t.item_lastchild(:root, i)
+ parent = i
+
+ i = t.item_create()
+ unless $Version_1_1_OrLater
+ t.item_hasbutton(i, false)
+ end
+ t.item_style_set(i, 0, s)
+ t.item_text(i, 0, text)
+ t.item_lastchild(parent, i)
+
+ ###
+
+ styleNum = 5
+ [
+ [:horizontal, [:s, :ns, :n]],
+ [:vertical, [:e, :we, :w]]
+ ].each{|orient, expandList|
+ expandList.each{|expand|
+ s = t.style_create("s#{styleNum}", :orient=>orient)
+ t.style_elements(s, ['e4', 'e8', 'e2', 'e5', 'e6'])
+ t.style_layout(s, 'e4', :detach=>true, :iexpand=>:es)
+ t.style_layout(s, 'e8', :detach=>true, :expand=>:n, :iexpand=>:e)
+ t.style_layout(s, 'e2', :expand=>expand)
+ t.style_layout(s, 'e5', :expand=>expand)
+ t.style_layout(s, 'e6', :expand=>expand)
+ styleNum += 1
+
+ i = t.item_create()
+ t.item_style_set(i, 0, s)
+ t.item_lastchild(:root, i)
+ }
+ }
+end
diff --git a/jni/ruby/ext/tk/sample/tkextlib/treectrl/mailwasher.rb b/jni/ruby/ext/tk/sample/tkextlib/treectrl/mailwasher.rb
new file mode 100644
index 0000000..1b51bb9
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkextlib/treectrl/mailwasher.rb
@@ -0,0 +1,269 @@
+#
+# Demo: MailWasher
+#
+def demoMailWasher(t)
+ init_pics('*checked')
+
+ height = t.font.metrics(:linespace) + 2
+ height = 18 if height < 18
+
+ t.configure(:showroot=>false, :showrootbutton=>false, :showbuttons=>false,
+ :showlines=>false, :itemheight=>height, :selectmode=>:browse,
+ :xscrollincrement=>1)
+
+ pad = 4
+
+ if $Version_1_1_OrLater
+ t.column_create(:text=>'Delete', :textpadx=>pad, :tag=>'delete')
+ t.column_create(:text=>'Bounce', :textpadx=>pad, :tag=>'bounce')
+ t.column_create(:text=>'Status', :width=>80, :textpadx=>pad,
+ :tag=>'status')
+ t.column_create(:text=>'Size', :width=>40, :textpadx=>pad,
+ :justify=>:right, :tag=>'size')
+ t.column_create(:text=>'From', :width=>140, :textpadx=>pad, :tag=>'from')
+ t.column_create(:text=>'Subject', :width=>240, :textpadx=>pad,
+ :tag=>'subject')
+ t.column_create(:text=>'Received', :textpadx=>pad, :arrow=>:up,
+ :arrowpad=>[4,0], :tag=>'received')
+ t.column_create(:text=>'Attachments', :textpadx=>pad, :tag=>'attachments')
+
+ t.state_define('CHECK')
+
+ t.element_create('imgCheck', :image, :image=>[
+ @images['checked'], ['CHECK'], @images['unchecked'], []
+ ])
+
+ else # TreeCtrl 1.0
+ t.column_configure(0, :text=>'Delete', :textpadx=>pad, :tag=>'delete')
+ t.column_configure(1, :text=>'Bounce', :textpadx=>pad, :tag=>'bounce')
+ t.column_configure(2, :text=>'Status', :width=>80, :textpadx=>pad,
+ :tag=>'status')
+ t.column_configure(3, :text=>'Size', :width=>40, :textpadx=>pad,
+ :justify=>:right, :tag=>'size')
+ t.column_configure(4, :text=>'From', :width=>140, :textpadx=>pad,
+ :tag=>'from')
+ t.column_configure(5, :text=>'Subject', :width=>240, :textpadx=>pad,
+ :tag=>'subject')
+ t.column_configure(6, :text=>'Received', :textpadx=>pad, :arrow=>:up,
+ :arrowpad=>[4,0], :tag=>'received')
+ t.column_configure(7, :text=>'Attachments', :textpadx=>pad,
+ :tag=>'attachments')
+
+ t.element_create('imgOff', :image, :image=>@images['unchecked'])
+ t.element_create('imgOn', :image, :image=>@images['checked'])
+ end
+
+ t.element_create('border', :rect, :open=>:nw, :outline=>'gray',
+ :outlinewidth=>1, :fill=>[@SystemHighlight, ['selected']])
+ t.element_create('txtAny', :text, :lines=>1,
+ :fill=>[@SystemHighlightText, ['selected']])
+ t.element_create('txtNone', :text, :text=>'none', :lines=>1,
+ :fill=>[@SystemHighlightText, ['selected']])
+ t.element_create('txtYes', :text, :text=>'yes', :lines=>1,
+ :fill=>[@SystemHighlightText, ['selected']])
+ t.element_create('txtNormal', :text, :text=>'Normal', :lines=>1,
+ :fill=>[@SystemHighlightText, ['selected'], '#006800', []])
+ t.element_create('txtPossSpam', :text, :text=>'Possible Spam', :lines=>1,
+ :fill=>[@SystemHighlightText, ['selected'], '#787800', []])
+ t.element_create('txtProbSpam', :text, :text=>'Probably Spam', :lines=>1,
+ :fill=>[@SystemHighlightText, ['selected'], '#FF9000', []])
+ t.element_create('txtBlacklist', :text, :text=>'Blacklisted', :lines=>1,
+ :fill=>[@SystemHighlightText, ['selected'], '#FF5800', []])
+
+ if $Version_1_1_OrLater
+ s = t.style_create('styCheck')
+ t.style_elements(s, ['border', 'imgCheck'])
+ t.style_layout(s, 'border', :detach=>true, :iexpand=>:es)
+ t.style_layout(s, 'imgCheck', :expand=>:news)
+ else
+ ['Off', 'On'].each{|name|
+ s = t.style_create('sty' << name)
+ i = 'img' << name
+ t.style_elements(s, ['border', i])
+ t.style_layout(s, 'border', :detach=>true, :iexpand=>:es)
+ t.style_layout(s, i, :expand=>:news)
+ }
+ end
+
+ pad = 4
+
+ %w(Any None Yes Normal PossSpam ProbSpam Blacklist).each{|name|
+ s = t.style_create('sty' << name)
+ e = 'txt' << name
+ t.style_elements(s, ['border', e])
+ t.style_layout(s, 'border', :detach=>true, :iexpand=>:es)
+ t.style_layout(s, e, :padx=>pad, :squeeze=>:x, :expand=>:ns)
+ }
+
+ [
+ ['baldy@spammer.com', "Your hair is thinning"],
+ ['flat@spammer.com', "Your breasts are too small"],
+ ['tiny@spammer.com', "Your penis is too small"],
+ ['dumbass@spammer.com', "You are not very smart"],
+ ['bankrobber@spammer.com', "You need more money"],
+ ['loser@spammer.com', "You need better friends"],
+ ['gossip@spammer.com', "Find out what your coworkers think about you"],
+ ['whoami@spammer.com', "Find out what you think about yourself"],
+ ['downsized@spammer.com', "You need a better job"],
+ ['poorhouse@spammer.com', "Your mortgage is a joke"],
+ ['spam4ever@spammer.com', "You need more spam"]
+ ].each{|frm, subj|
+ item = t.item_create
+ status = ['styNormal','styPossSpam','styProbSpam','styBlacklist'][rand(4)]
+ attachments = ['styNone','styYes'][rand(2)]
+
+ if $Version_1_1_OrLater
+ delete = [false, true][rand(2)]
+ bounce = [false, true][rand(2)]
+ t.item_style_set(item,
+ 0, 'styCheck', 1, 'styCheck', 2, status, 3, 'styAny',
+ 4, 'styAny', 5, 'styAny', 6, 'styAny', 7, attachments)
+ t.item_state_forcolumn(item, 'delete', 'CHECK') if delete
+ t.item_state_forcolumn(item, 'bounce', 'CHECK') if bounce
+
+ else # TreeCtrl 1.0
+ delete = ['styOn', 'styOff'][rand(2)]
+ bounce = ['styOn', 'styOff'][rand(2)]
+ t.item_style_set(item,
+ 0, delete, 1, bounce, 2, status, 3, 'styAny',
+ 4, 'styAny', 5, 'styAny', 6, 'styAny', 7, attachments)
+ end
+
+ bytes = 512 + rand(1024 * 12)
+ size = "#{bytes / 1024 + 1}KB"
+ seconds = Tk::Clock.seconds - rand(100000)
+ received = Tk::Clock.format(seconds, '%d/%m/%y %I:%M %p')
+ t.item_text(item, 3, size, 4, frm, 5, subj, 6, received)
+ t.item_lastchild(:root, item)
+ }
+
+ sortColumn = 6
+ t.notify_bind(t, 'Header-invoke',
+ proc{|c, w|
+ if c == sortColumn
+ if w.column_cget(sortColumn, :arrow) == 'down'
+ order = :increasing
+ arrow = :up
+ else
+ order = :decreasing
+ arrow = :down
+ end
+ else
+ if w.column_cget(sortColumn, :arrow) == 'down'
+ order = :decreasing
+ arrow = :down
+ else
+ order = :increasing
+ arrow = :up
+ end
+ w.column_configure(sortColumn, :arrow=>:none)
+ sortColumn = c
+ end
+ w.column_configure(c, :arrow=>arrow)
+ case w.column_cget(c, :tag)
+ when 'bounce', 'delete'
+ w.item_sort(:root, order,
+ {
+ :column=>c,
+ :command=>proc{|item1, item2|
+ compareOnOff(w, c, item1, item2)
+ }
+ },
+ { :column=>'subject', :dictionary=>true })
+ when 'status'
+ w.item_sort(:root, order,
+ { :column=>c, :dictionary=>true })
+ when 'from'
+ w.item_sort(:root, order,
+ { :column=>c, :dictionary=>true },
+ { :column=>'subject', :dictionary=>true })
+ when 'subject'
+ w.item_sort(:root, order,
+ { :column=>c, :dictionary=>true })
+ when 'size'
+ w.item_sort(:root, order,
+ { :column=>c, :dictionary=>true },
+ { :column=>'subject', :dictionary=>true })
+ when 'received'
+ w.item_sort(:root, order,
+ { :column=>c, :dictionary=>true },
+ { :column=>'subject', :dictionary=>true })
+ when 'attachments'
+ w.item_sort(:root, order,
+ { :column=>c, :dictionary=>true },
+ { :column=>'subject', :dictionary=>true })
+ end
+ }, '%C %T')
+
+ mailWasher = TkBindTag.new
+
+ if $Version_1_1_OrLater
+ mailWasher.bind('ButtonPress-1',
+ proc{|w, x, y|
+ id = w.identify(x, y)
+ if id.empty?
+ elsif id[0] == 'header'
+ else
+ what, item, where, arg1, arg2, arg3 = id
+ if where == 'column'
+ tag = w.column_cget(arg1, :tag)
+ if tag == 'delete' || tag == 'bounce'
+ w.item_state_forcolumn(item, arg1, '~CHECK')
+ end
+ end
+ end
+ }, '%W %x %y')
+ else # TreeCtrl 1.0
+ mailWasher.bind('ButtonPress-1',
+ proc{|w, x, y|
+ id = w.identify(x, y)
+ if id.empty?
+ elsif id[0] == 'header'
+ else
+ what, item, where, arg1, arg2, arg3 = id
+ if where == 'column'
+ tag = w.column_cget(arg1, :tag)
+ if tag == 'delete' || tag == 'bounce'
+ style = w.item_style_set(item, arg1)
+ if style == 'styOn'
+ style = 'styOff'
+ else
+ style = 'styOn'
+ end
+ w.item_style_set(item, arg1, style)
+ @display_styles_in_item.call(item)
+ end
+ end
+ end
+ }, '%W %x %y')
+ end
+
+ t.bindtags = [t, mailWasher, Tk::TreeCtrl, t.winfo_toplevel, TkBindTag::ALL]
+end
+
+if $Version_1_1_OrLater
+ def compareOnOff(w, c, item1, item2)
+ s1 = w.item_state_forcolumn(item1, c)
+ s2 = w.item_state_forcolumn(item2, c)
+ if (s1 == s2)
+ 0
+ elsif (s1 == 'CHECK')
+ -1
+ else
+ 1
+ end
+ end
+
+else # TreeCtrl 1.0
+ def compareOnOff(w, c, item1, item2)
+ s1 = w.item_style_set(item1, c)
+ s2 = w.item_style_set(item2, c)
+ if (s1 == s2)
+ 0
+ elsif (s1 == 'styOff')
+ -1
+ else
+ 1
+ end
+ end
+end
diff --git a/jni/ruby/ext/tk/sample/tkextlib/treectrl/outlook-folders.rb b/jni/ruby/ext/tk/sample/tkextlib/treectrl/outlook-folders.rb
new file mode 100644
index 0000000..d966807
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkextlib/treectrl/outlook-folders.rb
@@ -0,0 +1,124 @@
+#
+# Demo: Outlook Express folder list
+#
+def demoOutlookFolders(t)
+ init_pics('outlook-*')
+
+ height = t.font.metrics(:linespace) + 2
+ height = 18 if height < 18
+
+ t.configure(:itemheight=>height, :selectmode=>:browse, :showlines=>true,
+ :showroot=>true, :showrootbutton=>false, :showbuttons=>true)
+
+ if $HasColumnCreate
+ t.column_create(:text=>'Folders')
+ else
+ t.column_configure(0, :text=>'Folders')
+ end
+
+ t.element_create('e1', :image)
+ t.element_create('e2', :text, :lines=>1,
+ :fill=>[@SystemHighlightText, ['selected', 'focus']])
+ t.element_create('e3', :text, :lines=>1, :font=>t.font.dup.weight(:bold),
+ :fill=>[@SystemHighlightText, ['selected', 'focus']])
+ t.element_create('e4', :text, :fill=>'blue')
+ t.element_create('e5', :image, :image=>@images['outlook-folder'])
+ t.element_create('e6', :rect, :showfocus=>true,
+ :fill=>[
+ @SystemHighlight, ['selected', 'focus'],
+ 'gray', ['selected', '!focus']
+ ])
+
+ # image + text
+ s = t.style_create('s1')
+ t.style_elements(s, ['e6', 'e1', 'e2'])
+ t.style_layout(s, 'e1', :expand=>:ns)
+ t.style_layout(s, 'e2', :padx=>[4,0], :expand=>:ns, :squeeze=>:x)
+ t.style_layout(s, 'e6', :union=>['e2'], :iexpand=>:ns, :ipadx=>2)
+
+ # image + text + text
+ s = t.style_create('s2')
+ t.style_elements(s, ['e6', 'e1', 'e3', 'e4'])
+ t.style_layout(s, 'e1', :expand=>:ns)
+ t.style_layout(s, 'e3', :padx=>4, :expand=>:ns, :squeeze=>:x)
+ t.style_layout(s, 'e4', :expand=>:ns)
+ t.style_layout(s, 'e6', :union=>['e3'], :iexpand=>:ns, :ipadx=>2)
+
+ # folder + text
+ s = t.style_create('s3')
+ t.style_elements(s, ['e6', 'e5', 'e2'])
+ t.style_layout(s, 'e5', :expand=>:ns)
+ t.style_layout(s, 'e2', :padx=>[4,0], :expand=>:ns, :squeeze=>:x)
+ t.style_layout(s, 'e6', :union=>['e2'], :iexpand=>:ns, :ipadx=>2)
+
+ # folder + text + text
+ s = t.style_create('s4')
+ t.style_elements(s, ['e6', 'e5', 'e3', 'e4'])
+ t.style_layout(s, 'e5', :expand=>:ns)
+ t.style_layout(s, 'e3', :padx=>4, :expand=>:ns, :squeeze=>:x)
+ t.style_layout(s, 'e4', :expand=>:ns)
+ t.style_layout(s, 'e6', :union=>['e3'], :iexpand=>:ns, :ipadx=>2)
+
+ t.item_style_set(:root, 0, 's1')
+ t.item_complex(:root,
+ [
+ ['e1', {:image=>@images['outlook-main']}],
+ ['e2', {:text=>'Outlook Express'}]
+ ])
+
+ parentList = [:root, '', '', '', '', '', '']
+ parent = :root
+ [
+ [0, :local, "Local Folders", true, 0],
+ [1, :inbox, 'Inbox', false, 5],
+ [1, :outbox, 'Outbox', false, 0],
+ [1, :sent, "Sent Items", false, 0],
+ [1, :deleted, "Deleted Items", false, 50],
+ [1, :draft, 'Drafts', false, 0],
+ [1, :folder, "Messages to Dad", false, 0],
+ [1, :folder, "Messages to Sis", false, 0],
+ [1, :folder, "Messages to Me", false, 0],
+ [2, :folder, "2001", false, 0],
+ [2, :folder, "2000", false, 0],
+ [2, :folder, "1999", false, 0],
+ [0, :server, "news.gmane.org", true, 0],
+ [1, :group, "gmane.comp.lang.lua.general", false, 498]
+ ].each{|depth, img, text, button, unread|
+ if $Version_1_1_OrLater
+ item = t.item_create(:button=>button)
+ else
+ item = t.item_create
+ t.item_hasbutton(item, button)
+ end
+ if img == :folder
+ if unread != 0
+ t.item_style_set(item, 0, 's4')
+ t.item_complex(item,
+ [['e3', {:text=>text}], ['e4', {:text=>"(#{unread})"}]])
+ else
+ t.item_style_set(item, 0, 's3')
+ t.item_complex(item, [['e2', {:text=>text}]])
+ end
+ else
+ if unread != 0
+ t.item_style_set(item, 0, 's2')
+ t.item_complex(item,
+ [
+ ['e1', {:image=>@images["outlook-#{img}"]}],
+ ['e3', {:text=>text}],
+ ['e4', {:text=>"(#{unread})"}]
+ ])
+ else
+ t.item_style_set(item, 0, 's1')
+ t.item_complex(item,
+ [
+ ['e1', {:image=>@images["outlook-#{img}"]}],
+ ['e2', {:text=>text}]
+ ])
+ end
+ end
+ t.item_lastchild(parentList[depth], item)
+ depth += 1
+ parentList[depth] = item
+ }
+end
diff --git a/jni/ruby/ext/tk/sample/tkextlib/treectrl/outlook-newgroup.rb b/jni/ruby/ext/tk/sample/tkextlib/treectrl/outlook-newgroup.rb
new file mode 100644
index 0000000..3495522
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkextlib/treectrl/outlook-newgroup.rb
@@ -0,0 +1,448 @@
+#
+# Demo: Outlook Express newsgroup messages
+#
+def demoOutlookNewsgroup(t)
+ init_pics('outlook-*')
+
+ height = t.font.metrics(:linespace)
+ height = 18 if height < 18
+ t.configure(:itemheight=>height, :selectmode=>:browse, :showlines=>false,
+ :showroot=>false, :showrootbutton=>false, :showbuttons=>true)
+
+ if $Version_1_1_OrLater
+ t.column_create(:image=>@images['outlook-clip'], :tag=>'clip')
+ t.column_create(:image=>@images['outlook-arrow'], :tag=>'arrow')
+ t.column_create(:image=>@images['outlook-watch'], :tag=>'watch')
+ t.column_create(:text=>'Subject', :width=>250, :tag=>'subject')
+ t.column_create(:text=>'From', :width=>150, :tag=>'from')
+ t.column_create(:text=>'Sent', :width=>150, :tag=>'sent')
+ t.column_create(:text=>'Size', :width=>60, :justify=>:right, :tag=>'size')
+ else # TreeCtrl 1.0
+ t.column_configure(0, :image=>@images['outlook-clip'], :tag=>'clip')
+ t.column_configure(1, :image=>@images['outlook-arrow'], :tag=>'arrow')
+ t.column_configure(2, :image=>@images['outlook-watch'], :tag=>'watch')
+ t.column_configure(3, :text=>'Subject', :width=>250, :tag=>'subject')
+ t.column_configure(4, :text=>'From', :width=>150, :tag=>'from')
+ t.column_configure(5, :text=>'Sent', :width=>150, :tag=>'sent')
+ t.column_configure(6, :text=>'Size', :width=>60, :justify=>:right,
+ :tag=>'size')
+ end
+
+ # Would be nice if I could specify a column -tag too
+ t.treecolumn = 3
+
+ # State for a read message
+ t.state_define('read')
+
+ # State for a message with unread descendants
+ t.state_define('unread')
+
+ t.element_create('elemImg', :image,
+ :image=>[
+ @sel_images['outlook-read-2'],
+ ['selected', 'read', 'unread', '!open'],
+ @images['outlook-read-2'], ['read', 'unread', '!open'],
+ @sel_images['outlook-read'], ['selected', 'read'],
+ @images['outlook-read'], ['read'],
+ @sel_images['outlook-unread'], ['selected'],
+ @images['outlook-unread'], []
+ ])
+ t.element_create('elemTxt', :text, :lines=>1,
+ :fill=>[@SystemHighlightText, ['selected', 'focus']],
+ :font=>[
+ t.font.dup.weight(:bold), ['read', 'unread', '!open'],
+ t.font.dup.weight(:bold), ['!read']
+ ])
+ t.element_create('sel.e', :rect, :open=>:e, :showfocus=>true,
+ :fill=>[
+ @SystemHighlight, ['selected', 'focus'],
+ 'gray', ['selected', '!focus']
+ ])
+ t.element_create('sel.w', :rect, :open=>:w, :showfocus=>true,
+ :fill=>[
+ @SystemHighlight, ['selected', 'focus'],
+ 'gray', ['selected', '!focus']
+ ])
+ t.element_create('sel.we', :rect, :open=>:we, :showfocus=>true,
+ :fill=>[
+ @SystemHighlight, ['selected', 'focus'],
+ 'gray', ['selected', '!focus']
+ ])
+
+ # Image + text
+ s = t.style_create('s1')
+ t.style_elements(s, ['sel.e', 'elemImg', 'elemTxt'])
+ t.style_layout(s, 'elemImg', :expand=>:ns)
+ t.style_layout(s, 'elemTxt', :padx=>[2,6], :squeeze=>:x, :expand=>:ns)
+ t.style_layout(s, 'sel.e', :union=>['elemTxt'],
+ :iexpand=>:nes, :ipadx=>[2,0])
+
+ # Text
+ s = t.style_create('s2.we')
+ t.style_elements(s, ['sel.we', 'elemTxt'])
+ t.style_layout(s, 'elemTxt', :padx=>6, :squeeze=>:x, :expand=>:ns)
+ t.style_layout(s, 'sel.we', :detach=>true, :iexpand=>:es)
+
+ # Text
+ s = t.style_create('s2.w')
+ t.style_elements(s, ['sel.w', 'elemTxt'])
+ t.style_layout(s, 'elemTxt', :padx=>6, :squeeze=>:x, :expand=>:ns)
+ t.style_layout(s, 'sel.w', :detach=>true, :iexpand=>:es)
+
+ # Set default item style
+ if $Version_1_1_OrLater
+ t.defaultstyle = ['', '', '', 's1', 's2.we', 's2.we', 's2.w']
+ end
+
+ msgCnt = 100
+ thread = 0
+
+ @Message = Hash.new{|k, v| k[v] = Hash.new}
+ @Message[:count][0] = 0
+
+ items = [t.index(:root)]
+
+ (1...(msgCnt)).each{|i|
+ item_i = t.item_create
+ item_j = nil
+ j = nil
+ loop {
+ j = rand(i)
+ item_j = items[j]
+ break if j == 0
+ next if t.depth(item_j) == 5
+ next if @Message[:count][@Message[:thread][item_j]] == 15
+ break
+ }
+ t.item_lastchild(item_j, item_i)
+
+ @Message[:read][item_i] = (rand(2) == 0)
+ if j == 0
+ thread += 1
+ @Message[:thread][item_i] = thread
+ @Message[:seconds][item_i] = (Tk::Clock.seconds - rand(500000))
+ @Message[:seconds2][item_i] = @Message[:seconds][item_i]
+ @Message[:count][thread] = 1
+ else
+ @Message[:thread][item_i] = @Message[:thread][item_j]
+ @Message[:seconds][item_i] = (@Message[:seconds2][item_j] + rand(10000))
+ @Message[:seconds2][item_i] = @Message[:seconds][item_i]
+ @Message[:seconds2][item_j] = @Message[:seconds][item_i]
+ @Message[:count][@Message[:thread][item_j]] += 1
+ end
+ items << item_i
+ }
+
+ (1...(msgCnt)).each{|i|
+ item_i = items[i]
+ subject = "This is thread number #{@Message[:thread][item_i]}"
+ from = 'somebody@somewhere.net'
+ sent = Tk::Clock.format(@Message[:seconds][item_i], "%d/%m/%y %I:%M %p")
+ size = "#{1 + rand(10)}KB"
+
+ # This message has been read
+ t.item_state_set(item_i, 'read') if @Message[:read][item_i]
+
+ # This message has unread descendants
+ t.item_state_set(item_i, 'unread') if anyUnreadDescendants(t, item_i)
+
+ if t.item_numchildren(item_i) > 0
+ if $Version_1_1_OrLater
+ t.item_configure(item_i, :button=>true)
+ else # TreeCtrl 1.0
+ t.item_hasbutton(item_i, true)
+ end
+
+ # Collapse some messages
+ if $Version_1_1_OrLater
+ t.item_collapse(item_i) if rand(2) == 0
+ else # TreeCtrl 1.0
+ t.collapse(item_i) if rand(2) == 0
+ end
+ end
+
+ unless $Version_1_1_OrLater
+ t.item_style_set(item_i, 3, 's1', 4, 's2.we', 5, 's2.we', 6, 's2.w')
+ end
+ t.item_text(item_i, 3, subject, 4, from, 5, sent, 6, size)
+ }
+
+ # Do something when the selection changes
+ t.notify_bind(t, 'Selection',
+ proc{|w|
+ if w.selection_count == 1
+ # One item is selected
+ if @Message[:afterId][:id]
+ Tk.after_cancel(@Message[:afterId][:id])
+ end
+ @Message[:afterId][:item] = w.selection_get[0]
+ @Message[:afterId][:id] = Tk.after(500, proc{
+ messageReadDelayed(w)
+ })
+ end
+ }, '%T')
+end
+
+def messageReadDelayed(t)
+ @Message[:afterId].delete(:id)
+ i = @Message[:afterId][:item]
+ return unless t.selection_includes(i)
+
+ # This message is not read
+ unless @Message[:read][i]
+ # Read the message
+ t.item_state_set(i, 'read')
+ @Message[:read][i] = true
+
+ # Check ancestors (except root)
+ t.item_ancestors(i)[0..-2].each{|i2|
+ # This ancestor has no more unread descendants
+ t.item_state_set(i2, '!unread') unless anyUnreadDescendants(t, i2)
+ }
+ end
+end
+
+# Alternate implementation which does not rely on run-time states
+def demoOutlookNewsgroup2(t)
+ init_pics('outlook-*')
+
+ height = t.font.metrics(:linespace)
+ height = 18 if height < 18
+ t.configure(:itemheight=>height, :selectmode=>:browse, :showlines=>false,
+ :showroot=>false, :showrootbutton=>false, :showbuttons=>true)
+
+ if $Version_1_1_OrLater
+ t.column_create(:image=>@images['outlook-clip'], :tag=>'clip')
+ t.column_create(:image=>@images['outlook-arrow'], :tag=>'arrow')
+ t.column_create(:image=>@images['outlook-watch'], :tag=>'watch')
+ t.column_create(:text=>'Subject', :width=>250, :tag=>'subject')
+ t.column_create(:text=>'From', :width=>150, :tag=>'from')
+ t.column_create(:text=>'Sent', :width=>150, :tag=>'sent')
+ t.column_create(:text=>'Size', :width=>60, :justify=>:right, :tag=>'size')
+ else # TreeCtrl 1.0
+ t.column_configure(0, :image=>@images['outlook-clip'], :tag=>'clip')
+ t.column_configure(1, :image=>@images['outlook-arrow'], :tag=>'arrow')
+ t.column_configure(2, :image=>@images['outlook-watch'], :tag=>'watch')
+ t.column_configure(3, :text=>'Subject', :width=>250, :tag=>'subject')
+ t.column_configure(4, :text=>'From', :width=>150, :tag=>'from')
+ t.column_configure(5, :text=>'Sent', :width=>150, :tag=>'sent')
+ t.column_configure(6, :text=>'Size', :width=>60, :justify=>:right,
+ :tag=>'size')
+ end
+
+ t.treecolumn = 3
+
+ t.element_create('image.unread', :image, :image=>@images['outlook-unread'])
+ t.element_create('image.read', :image, :image=>@images['outlook-read'])
+ t.element_create('image.read2', :image, :image=>@images['outlook-read-2'])
+ t.element_create('text.read', :text, :lines=>1,
+ :fill=>[@SystemHighlightText, ['selected', 'focus']])
+ t.element_create('text.unread', :text, :lines=>1,
+ :fill=>[@SystemHighlightText, ['selected', 'focus']],
+ :font=>t.font.dup.weight(:bold))
+ t.element_create('sel.e', :rect, :open=>:e, :showfocus=>true,
+ :fill=>[
+ @SystemHighlight, ['selected', 'focus'],
+ 'gray', ['selected', '!focus']
+ ])
+ t.element_create('sel.w', :rect, :open=>:w, :showfocus=>true,
+ :fill=>[
+ @SystemHighlight, ['selected', 'focus'],
+ 'gray', ['selected', '!focus']
+ ])
+ t.element_create('sel.we', :rect, :open=>:we, :showfocus=>true,
+ :fill=>[
+ @SystemHighlight, ['selected', 'focus'],
+ 'gray', ['selected', '!focus']
+ ])
+
+ # Image + text
+ s = t.style_create('unread')
+ t.style_elements(s, ['sel.e', 'image.unread', 'text.unread'])
+ t.style_layout(s, 'image.unread', :expand=>:ns)
+ t.style_layout(s, 'text.unread', :padx=>[2,6], :squeeze=>:x, :expand=>:ns)
+ t.style_layout(s, 'sel.e', :union=>['text.unread'],
+ :iexpand=>:nes, :ipadx=>[2,0])
+
+ # Image + text
+ s = t.style_create('read')
+ t.style_elements(s, ['sel.e', 'image.read', 'text.read'])
+ t.style_layout(s, 'image.read', :expand=>:ns)
+ t.style_layout(s, 'text.read', :padx=>[2,6], :squeeze=>:x, :expand=>:ns)
+ t.style_layout(s, 'sel.e', :union=>['text.read'],
+ :iexpand=>:nes, :ipadx=>[2,0])
+
+ # Image + text
+ s = t.style_create('read2')
+ t.style_elements(s, ['sel.e', 'image.read2', 'text.unread'])
+ t.style_layout(s, 'image.read2', :expand=>:ns)
+ t.style_layout(s, 'text.unread', :padx=>[2,6], :squeeze=>:x, :expand=>:ns)
+ t.style_layout(s, 'sel.e', :union=>['text.unread'],
+ :iexpand=>:nes, :ipadx=>[2,0])
+
+ # Text
+ s = t.style_create('unread.we')
+ t.style_elements(s, ['sel.we', 'text.unread'])
+ t.style_layout(s, 'text.unread', :padx=>6, :squeeze=>:x, :expand=>:ns)
+ t.style_layout(s, 'sel.we', :detach=>true, :iexpand=>:es)
+
+ # Text
+ s = t.style_create('read.we')
+ t.style_elements(s, ['sel.we', 'text.read'])
+ t.style_layout(s, 'text.read', :padx=>6, :squeeze=>:x, :expand=>:ns)
+ t.style_layout(s, 'sel.we', :detach=>true, :iexpand=>:es)
+
+ # Text
+ s = t.style_create('unread.w')
+ t.style_elements(s, ['sel.w', 'text.unread'])
+ t.style_layout(s, 'text.unread', :padx=>6, :squeeze=>:x, :expand=>:ns)
+ t.style_layout(s, 'sel.w', :detach=>true, :iexpand=>:es)
+
+ # Text
+ s = t.style_create('read.w')
+ t.style_elements(s, ['sel.w', 'text.read'])
+ t.style_layout(s, 'text.read', :padx=>6, :squeeze=>:x, :expand=>:ns)
+ t.style_layout(s, 'sel.w', :detach=>true, :iexpand=>:es)
+
+ msgCnt = 100
+ thread = 0
+
+ @Message = Hash.new{|k, v| k[v] = Hash.new}
+ @Message[:count][0] = 0
+
+ (1...(msgCnt)).each{|i|
+ t.item_create
+ j = nil
+ loop {
+ j = rand(i)
+ break if j == 0
+ next if t.depth(j) == 5
+ next if @Message[:count][@Message[:thread][j]] == 15
+ break
+ }
+ t.item_lastchild(j, i)
+
+ @Message[:read][i] = (rand(2) == 0)
+ if j == 0
+ thread += 1
+ @Message[:thread][i] = thread
+ @Message[:seconds][i] = (Tk::Clock.seconds - rand(500000))
+ @Message[:seconds2][i] = @Message[:seconds][i]
+ @Message[:count][thread] = 1
+ else
+ @Message[:thread][i] = @Message[:thread][j]
+ @Message[:seconds][i] = (@Message[:seconds2][j] + rand(10000))
+ @Message[:seconds2][i] = @Message[:seconds][i]
+ @Message[:seconds2][j] = @Message[:seconds][i]
+ @Message[:count][@Message[:thread][j]] += 1
+ end
+ }
+
+ (1...(msgCnt)).each{|i|
+ subject = "This is thread number #{@Message[:thread][i]}"
+ from = 'somebody@somewhere.net'
+ sent = Tk::Clock.format(@Message[:seconds][i], "%d/%m/%y %I:%M %p")
+ size = "#{1 + rand(10)}KB"
+ if @Message[:read][i]
+ style = 'read'
+ style2 = 'read2'
+ else
+ style = 'unread'
+ style2 = 'unread2'
+ end
+ t.item_style_set(i, 3, style, 4, "#{style2}.we", 5, "#{style2}.we",
+ 6, "#{style2}.w")
+ t.item_text(i, 3, subject, 4, from, 5, sent, 6, size)
+ if t.item_numchildren(i) > 0
+ t.item_configure(item_i, :button=>true)
+ end
+ }
+
+ # Do something when the selection changes
+ t.notify_bind(t, 'Selection',
+ proc{|w|
+ if w.selection_count == 1
+ i = t.selection_get[0]
+ unless @Message[:read][i]
+ if t.item_isopen(i) || !anyUnreadDescendants(t, i)
+ # unread -> read
+ t.item_style_map(i, 'subject', 'read',
+ ['text.unread', 'text.read'])
+ t.item_style_map(i, 'from', 'read.we',
+ ['text.unread', 'text.read'])
+ t.item_style_map(i, 'sent', 'read.we',
+ ['text.unread', 'text.read'])
+ t.item_style_map(i, 'size', 'read.w',
+ ['text.unread', 'text.read'])
+ else
+ # unread -> read2
+ t.item_style_map(i, 'subject', 'read2',
+ ['text.unread', 'text.unread'])
+ end
+
+ @Message[:read][i] = true
+ @display_styles_in_item.call(i)
+ end
+ end
+ }, '%T')
+
+ t.notify_bind(t, 'Expand-after',
+ proc{|w, i|
+ if @Messge[:read][i] && anyUnreadDescendants(t, i)
+ # read2 -> read
+ t.item_style_map(i, 'subject', 'read',
+ ['text.unread', 'text.read'])
+ # unread -> read
+ t.item_style_map(i, 'from', 'read.we',
+ ['text.unread', 'text.read'])
+ t.item_style_map(i, 'sent', 'read.we',
+ ['text.unread', 'text.read'])
+ t.item_style_map(i, 'size', 'read.w',
+ ['text.unread', 'text.read'])
+ end
+ }, '%T %I')
+
+ t.notify_bind(t, 'Collapse-after',
+ proc{|w, i|
+ if @Messge[:read][i] && anyUnreadDescendants(t, i)
+ # read -> read2
+ t.item_style_map(i, 'subject', 'read2',
+ ['text.read', 'text.unread'])
+ # read -> unread
+ t.item_style_map(i, 'from', 'unread.we',
+ ['text.read', 'text.unread'])
+ t.item_style_map(i, 'sent', 'unread.we',
+ ['text.read', 'text.unread'])
+ t.item_style_map(i, 'size', 'unread.w',
+ ['text.read', 'text.unread'])
+ end
+ }, '%T %I')
+
+ (1...(msgCnt)).each{|i|
+ if rand(2) == 0
+ if t.item_numchildren(i) > 0
+ if $Version_1_1_OrLater
+ t.item_collapse(i)
+ else # TreeCtrl 1.0
+ t.collapse(i)
+ end
+ end
+ end
+ }
+end
+
+def anyUnreadDescendants(t, i)
+ itemList = []
+ item = t.item_firstchild(i)
+ itemList.push(item) if item != ''
+
+ while item = itemList.pop
+ return true unless @Message[:read][item]
+
+ item2 = t.item_nextsibling(item)
+ itemList.push(item2) if item2 != ''
+ item2 = t.item_firstchild(item)
+ itemList.push(item2) if item2 != ''
+ end
+ false
+end
diff --git a/jni/ruby/ext/tk/sample/tkextlib/treectrl/pics/big-dll.gif b/jni/ruby/ext/tk/sample/tkextlib/treectrl/pics/big-dll.gif
new file mode 100644
index 0000000..09170c0
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkextlib/treectrl/pics/big-dll.gif
Binary files differ
diff --git a/jni/ruby/ext/tk/sample/tkextlib/treectrl/pics/big-exe.gif b/jni/ruby/ext/tk/sample/tkextlib/treectrl/pics/big-exe.gif
new file mode 100644
index 0000000..e19aac1
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkextlib/treectrl/pics/big-exe.gif
Binary files differ
diff --git a/jni/ruby/ext/tk/sample/tkextlib/treectrl/pics/big-file.gif b/jni/ruby/ext/tk/sample/tkextlib/treectrl/pics/big-file.gif
new file mode 100644
index 0000000..6c75231
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkextlib/treectrl/pics/big-file.gif
Binary files differ
diff --git a/jni/ruby/ext/tk/sample/tkextlib/treectrl/pics/big-folder.gif b/jni/ruby/ext/tk/sample/tkextlib/treectrl/pics/big-folder.gif
new file mode 100644
index 0000000..186c974
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkextlib/treectrl/pics/big-folder.gif
Binary files differ
diff --git a/jni/ruby/ext/tk/sample/tkextlib/treectrl/pics/big-txt.gif b/jni/ruby/ext/tk/sample/tkextlib/treectrl/pics/big-txt.gif
new file mode 100644
index 0000000..a934925
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkextlib/treectrl/pics/big-txt.gif
Binary files differ
diff --git a/jni/ruby/ext/tk/sample/tkextlib/treectrl/pics/checked.gif b/jni/ruby/ext/tk/sample/tkextlib/treectrl/pics/checked.gif
new file mode 100644
index 0000000..3b9b176
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkextlib/treectrl/pics/checked.gif
Binary files differ
diff --git a/jni/ruby/ext/tk/sample/tkextlib/treectrl/pics/file.gif b/jni/ruby/ext/tk/sample/tkextlib/treectrl/pics/file.gif
new file mode 100644
index 0000000..a64c2a0
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkextlib/treectrl/pics/file.gif
Binary files differ
diff --git a/jni/ruby/ext/tk/sample/tkextlib/treectrl/pics/folder-closed.gif b/jni/ruby/ext/tk/sample/tkextlib/treectrl/pics/folder-closed.gif
new file mode 100644
index 0000000..0a06437
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkextlib/treectrl/pics/folder-closed.gif
Binary files differ
diff --git a/jni/ruby/ext/tk/sample/tkextlib/treectrl/pics/folder-open.gif b/jni/ruby/ext/tk/sample/tkextlib/treectrl/pics/folder-open.gif
new file mode 100644
index 0000000..3fac27f
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkextlib/treectrl/pics/folder-open.gif
Binary files differ
diff --git a/jni/ruby/ext/tk/sample/tkextlib/treectrl/pics/help-book-closed.gif b/jni/ruby/ext/tk/sample/tkextlib/treectrl/pics/help-book-closed.gif
new file mode 100644
index 0000000..0a0497b
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkextlib/treectrl/pics/help-book-closed.gif
Binary files differ
diff --git a/jni/ruby/ext/tk/sample/tkextlib/treectrl/pics/help-book-open.gif b/jni/ruby/ext/tk/sample/tkextlib/treectrl/pics/help-book-open.gif
new file mode 100644
index 0000000..40656c5
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkextlib/treectrl/pics/help-book-open.gif
Binary files differ
diff --git a/jni/ruby/ext/tk/sample/tkextlib/treectrl/pics/help-page.gif b/jni/ruby/ext/tk/sample/tkextlib/treectrl/pics/help-page.gif
new file mode 100644
index 0000000..e1ce1d7
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkextlib/treectrl/pics/help-page.gif
Binary files differ
diff --git a/jni/ruby/ext/tk/sample/tkextlib/treectrl/pics/imovie-01.gif b/jni/ruby/ext/tk/sample/tkextlib/treectrl/pics/imovie-01.gif
new file mode 100644
index 0000000..5fd9215
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkextlib/treectrl/pics/imovie-01.gif
Binary files differ
diff --git a/jni/ruby/ext/tk/sample/tkextlib/treectrl/pics/imovie-02.gif b/jni/ruby/ext/tk/sample/tkextlib/treectrl/pics/imovie-02.gif
new file mode 100644
index 0000000..3d2d1c1
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkextlib/treectrl/pics/imovie-02.gif
Binary files differ
diff --git a/jni/ruby/ext/tk/sample/tkextlib/treectrl/pics/imovie-03.gif b/jni/ruby/ext/tk/sample/tkextlib/treectrl/pics/imovie-03.gif
new file mode 100644
index 0000000..9fccf12
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkextlib/treectrl/pics/imovie-03.gif
Binary files differ
diff --git a/jni/ruby/ext/tk/sample/tkextlib/treectrl/pics/imovie-04.gif b/jni/ruby/ext/tk/sample/tkextlib/treectrl/pics/imovie-04.gif
new file mode 100644
index 0000000..eff851c
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkextlib/treectrl/pics/imovie-04.gif
Binary files differ
diff --git a/jni/ruby/ext/tk/sample/tkextlib/treectrl/pics/imovie-05.gif b/jni/ruby/ext/tk/sample/tkextlib/treectrl/pics/imovie-05.gif
new file mode 100644
index 0000000..ad00c82
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkextlib/treectrl/pics/imovie-05.gif
Binary files differ
diff --git a/jni/ruby/ext/tk/sample/tkextlib/treectrl/pics/imovie-06.gif b/jni/ruby/ext/tk/sample/tkextlib/treectrl/pics/imovie-06.gif
new file mode 100644
index 0000000..238bf16
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkextlib/treectrl/pics/imovie-06.gif
Binary files differ
diff --git a/jni/ruby/ext/tk/sample/tkextlib/treectrl/pics/imovie-07.gif b/jni/ruby/ext/tk/sample/tkextlib/treectrl/pics/imovie-07.gif
new file mode 100644
index 0000000..a9287e1
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkextlib/treectrl/pics/imovie-07.gif
Binary files differ
diff --git a/jni/ruby/ext/tk/sample/tkextlib/treectrl/pics/internet-check-off.gif b/jni/ruby/ext/tk/sample/tkextlib/treectrl/pics/internet-check-off.gif
new file mode 100644
index 0000000..e64866a
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkextlib/treectrl/pics/internet-check-off.gif
Binary files differ
diff --git a/jni/ruby/ext/tk/sample/tkextlib/treectrl/pics/internet-check-on.gif b/jni/ruby/ext/tk/sample/tkextlib/treectrl/pics/internet-check-on.gif
new file mode 100644
index 0000000..cf652be
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkextlib/treectrl/pics/internet-check-on.gif
Binary files differ
diff --git a/jni/ruby/ext/tk/sample/tkextlib/treectrl/pics/internet-print.gif b/jni/ruby/ext/tk/sample/tkextlib/treectrl/pics/internet-print.gif
new file mode 100644
index 0000000..7ac25b1
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkextlib/treectrl/pics/internet-print.gif
Binary files differ
diff --git a/jni/ruby/ext/tk/sample/tkextlib/treectrl/pics/internet-radio-off.gif b/jni/ruby/ext/tk/sample/tkextlib/treectrl/pics/internet-radio-off.gif
new file mode 100644
index 0000000..90ef629
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkextlib/treectrl/pics/internet-radio-off.gif
Binary files differ
diff --git a/jni/ruby/ext/tk/sample/tkextlib/treectrl/pics/internet-radio-on.gif b/jni/ruby/ext/tk/sample/tkextlib/treectrl/pics/internet-radio-on.gif
new file mode 100644
index 0000000..9de742c
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkextlib/treectrl/pics/internet-radio-on.gif
Binary files differ
diff --git a/jni/ruby/ext/tk/sample/tkextlib/treectrl/pics/internet-search.gif b/jni/ruby/ext/tk/sample/tkextlib/treectrl/pics/internet-search.gif
new file mode 100644
index 0000000..1f9a047
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkextlib/treectrl/pics/internet-search.gif
Binary files differ
diff --git a/jni/ruby/ext/tk/sample/tkextlib/treectrl/pics/internet-security.gif b/jni/ruby/ext/tk/sample/tkextlib/treectrl/pics/internet-security.gif
new file mode 100644
index 0000000..86d3943
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkextlib/treectrl/pics/internet-security.gif
Binary files differ
diff --git a/jni/ruby/ext/tk/sample/tkextlib/treectrl/pics/mac-collapse.gif b/jni/ruby/ext/tk/sample/tkextlib/treectrl/pics/mac-collapse.gif
new file mode 100644
index 0000000..81302c8
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkextlib/treectrl/pics/mac-collapse.gif
Binary files differ
diff --git a/jni/ruby/ext/tk/sample/tkextlib/treectrl/pics/mac-expand.gif b/jni/ruby/ext/tk/sample/tkextlib/treectrl/pics/mac-expand.gif
new file mode 100644
index 0000000..0a2cd80
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkextlib/treectrl/pics/mac-expand.gif
Binary files differ
diff --git a/jni/ruby/ext/tk/sample/tkextlib/treectrl/pics/outlook-arrow.gif b/jni/ruby/ext/tk/sample/tkextlib/treectrl/pics/outlook-arrow.gif
new file mode 100644
index 0000000..b1c2afd
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkextlib/treectrl/pics/outlook-arrow.gif
Binary files differ
diff --git a/jni/ruby/ext/tk/sample/tkextlib/treectrl/pics/outlook-clip.gif b/jni/ruby/ext/tk/sample/tkextlib/treectrl/pics/outlook-clip.gif
new file mode 100644
index 0000000..8578132
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkextlib/treectrl/pics/outlook-clip.gif
Binary files differ
diff --git a/jni/ruby/ext/tk/sample/tkextlib/treectrl/pics/outlook-deleted.gif b/jni/ruby/ext/tk/sample/tkextlib/treectrl/pics/outlook-deleted.gif
new file mode 100644
index 0000000..7cc8369
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkextlib/treectrl/pics/outlook-deleted.gif
Binary files differ
diff --git a/jni/ruby/ext/tk/sample/tkextlib/treectrl/pics/outlook-draft.gif b/jni/ruby/ext/tk/sample/tkextlib/treectrl/pics/outlook-draft.gif
new file mode 100644
index 0000000..f195850
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkextlib/treectrl/pics/outlook-draft.gif
Binary files differ
diff --git a/jni/ruby/ext/tk/sample/tkextlib/treectrl/pics/outlook-folder.gif b/jni/ruby/ext/tk/sample/tkextlib/treectrl/pics/outlook-folder.gif
new file mode 100644
index 0000000..b3f7335
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkextlib/treectrl/pics/outlook-folder.gif
Binary files differ
diff --git a/jni/ruby/ext/tk/sample/tkextlib/treectrl/pics/outlook-group.gif b/jni/ruby/ext/tk/sample/tkextlib/treectrl/pics/outlook-group.gif
new file mode 100644
index 0000000..29ad9b4
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkextlib/treectrl/pics/outlook-group.gif
Binary files differ
diff --git a/jni/ruby/ext/tk/sample/tkextlib/treectrl/pics/outlook-inbox.gif b/jni/ruby/ext/tk/sample/tkextlib/treectrl/pics/outlook-inbox.gif
new file mode 100644
index 0000000..f41d804
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkextlib/treectrl/pics/outlook-inbox.gif
Binary files differ
diff --git a/jni/ruby/ext/tk/sample/tkextlib/treectrl/pics/outlook-local.gif b/jni/ruby/ext/tk/sample/tkextlib/treectrl/pics/outlook-local.gif
new file mode 100644
index 0000000..0c74970
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkextlib/treectrl/pics/outlook-local.gif
Binary files differ
diff --git a/jni/ruby/ext/tk/sample/tkextlib/treectrl/pics/outlook-main.gif b/jni/ruby/ext/tk/sample/tkextlib/treectrl/pics/outlook-main.gif
new file mode 100644
index 0000000..92325fa
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkextlib/treectrl/pics/outlook-main.gif
Binary files differ
diff --git a/jni/ruby/ext/tk/sample/tkextlib/treectrl/pics/outlook-outbox.gif b/jni/ruby/ext/tk/sample/tkextlib/treectrl/pics/outlook-outbox.gif
new file mode 100644
index 0000000..c7e8052
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkextlib/treectrl/pics/outlook-outbox.gif
Binary files differ
diff --git a/jni/ruby/ext/tk/sample/tkextlib/treectrl/pics/outlook-read-2.gif b/jni/ruby/ext/tk/sample/tkextlib/treectrl/pics/outlook-read-2.gif
new file mode 100644
index 0000000..2f15a3a
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkextlib/treectrl/pics/outlook-read-2.gif
Binary files differ
diff --git a/jni/ruby/ext/tk/sample/tkextlib/treectrl/pics/outlook-read.gif b/jni/ruby/ext/tk/sample/tkextlib/treectrl/pics/outlook-read.gif
new file mode 100644
index 0000000..a6f9562
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkextlib/treectrl/pics/outlook-read.gif
Binary files differ
diff --git a/jni/ruby/ext/tk/sample/tkextlib/treectrl/pics/outlook-sent.gif b/jni/ruby/ext/tk/sample/tkextlib/treectrl/pics/outlook-sent.gif
new file mode 100644
index 0000000..963b56c
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkextlib/treectrl/pics/outlook-sent.gif
Binary files differ
diff --git a/jni/ruby/ext/tk/sample/tkextlib/treectrl/pics/outlook-server.gif b/jni/ruby/ext/tk/sample/tkextlib/treectrl/pics/outlook-server.gif
new file mode 100644
index 0000000..c950845
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkextlib/treectrl/pics/outlook-server.gif
Binary files differ
diff --git a/jni/ruby/ext/tk/sample/tkextlib/treectrl/pics/outlook-unread.gif b/jni/ruby/ext/tk/sample/tkextlib/treectrl/pics/outlook-unread.gif
new file mode 100644
index 0000000..3df4b99
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkextlib/treectrl/pics/outlook-unread.gif
Binary files differ
diff --git a/jni/ruby/ext/tk/sample/tkextlib/treectrl/pics/outlook-watch.gif b/jni/ruby/ext/tk/sample/tkextlib/treectrl/pics/outlook-watch.gif
new file mode 100644
index 0000000..87ec861
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkextlib/treectrl/pics/outlook-watch.gif
Binary files differ
diff --git a/jni/ruby/ext/tk/sample/tkextlib/treectrl/pics/sky.gif b/jni/ruby/ext/tk/sample/tkextlib/treectrl/pics/sky.gif
new file mode 100644
index 0000000..b7fbf14
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkextlib/treectrl/pics/sky.gif
Binary files differ
diff --git a/jni/ruby/ext/tk/sample/tkextlib/treectrl/pics/small-dll.gif b/jni/ruby/ext/tk/sample/tkextlib/treectrl/pics/small-dll.gif
new file mode 100644
index 0000000..d8875ec
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkextlib/treectrl/pics/small-dll.gif
Binary files differ
diff --git a/jni/ruby/ext/tk/sample/tkextlib/treectrl/pics/small-exe.gif b/jni/ruby/ext/tk/sample/tkextlib/treectrl/pics/small-exe.gif
new file mode 100644
index 0000000..69d30be
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkextlib/treectrl/pics/small-exe.gif
Binary files differ
diff --git a/jni/ruby/ext/tk/sample/tkextlib/treectrl/pics/small-file.gif b/jni/ruby/ext/tk/sample/tkextlib/treectrl/pics/small-file.gif
new file mode 100644
index 0000000..f340662
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkextlib/treectrl/pics/small-file.gif
Binary files differ
diff --git a/jni/ruby/ext/tk/sample/tkextlib/treectrl/pics/small-folder.gif b/jni/ruby/ext/tk/sample/tkextlib/treectrl/pics/small-folder.gif
new file mode 100644
index 0000000..ad1b24d
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkextlib/treectrl/pics/small-folder.gif
Binary files differ
diff --git a/jni/ruby/ext/tk/sample/tkextlib/treectrl/pics/small-txt.gif b/jni/ruby/ext/tk/sample/tkextlib/treectrl/pics/small-txt.gif
new file mode 100644
index 0000000..cdc7cbf
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkextlib/treectrl/pics/small-txt.gif
Binary files differ
diff --git a/jni/ruby/ext/tk/sample/tkextlib/treectrl/pics/unchecked.gif b/jni/ruby/ext/tk/sample/tkextlib/treectrl/pics/unchecked.gif
new file mode 100644
index 0000000..833e482
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkextlib/treectrl/pics/unchecked.gif
Binary files differ
diff --git a/jni/ruby/ext/tk/sample/tkextlib/treectrl/random.rb b/jni/ruby/ext/tk/sample/tkextlib/treectrl/random.rb
new file mode 100644
index 0000000..43aca63
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkextlib/treectrl/random.rb
@@ -0,0 +1,508 @@
+#
+def random_N
+ @RandomN[0] || 500
+end
+
+#
+# Demo: random N items
+#
+def demoRandom(t)
+ init_pics('folder-*', 'small-*')
+
+ height = t.font.metrics(:linespace)
+ height = 18 if height < 18
+ t.configure(:itemheight=>height, :selectmode=>:extended,
+ :showroot=>true, :showrootbutton=>true, :showbuttons=>true,
+ :showlines=>true, :scrollmargin=>16,
+ :xscrolldelay=>[500, 50], :yscrolldelay=>[500, 50])
+
+ if $Version_1_1_OrLater
+ t.column_create(:expand=>true, :text=>'Item',
+ :itembackground=>['#e0e8f0', []], :tag=>'item')
+ t.column_create(:text=>'Parent', :justify=>:center,
+ :itembackground=>['gray90', []], :tag=>'parent')
+ t.column_create(:text=>'Depth', :justify=>:center,
+ :itembackground=>['linen', []], :tag=>'depth')
+ else # TreeCtrl 1.0
+ t.column_configure(0, :expand=>true, :text=>'Item',
+ :itembackground=>['#e0e8f0', []], :tag=>'item')
+ t.column_configure(1, :text=>'Parent', :justify=>:center,
+ :itembackground=>['gray90', []], :tag=>'parent')
+ t.column_configure(2, :text=>'Depth', :justify=>:center,
+ :itembackground=>['linen', []], :tag=>'depth')
+ end
+
+ t.element_create('e1', :image, :image=>[
+ @images['folder-open'], ['open'],
+ @images['folder-closed'], []
+ ])
+ t.element_create('e2', :image, :image=>@images['small-file'])
+ t.element_create('e3', :text,
+ :fill=>[@SystemHighlightText, ['selected', 'focus']])
+ t.element_create('e4', :text, :fill=>'blue')
+ t.element_create('e6', :text)
+ t.element_create('e5', :rect, :showfocus=>true,
+ :fill=>[
+ @SystemHighlight, ['selected', 'focus'],
+ 'gray', ['selected', '!focus']
+ ])
+
+ s = t.style_create('s1')
+ t.style_elements(s, ['e5', 'e1', 'e3', 'e4'])
+ t.style_layout(s, 'e1', :padx=>[0,4], :expand=>:ns)
+ t.style_layout(s, 'e3', :padx=>[0,4], :expand=>:ns)
+ t.style_layout(s, 'e4', :padx=>[0,6], :expand=>:ns)
+ t.style_layout(s, 'e5', :union=>['e3'], :iexpand=>:ns, :ipadx=>2)
+
+ s = t.style_create('s2')
+ t.style_elements(s, ['e5', 'e2', 'e3'])
+ t.style_layout(s, 'e2', :padx=>[0,4], :expand=>:ns)
+ t.style_layout(s, 'e3', :padx=>[0,4], :expand=>:ns)
+ t.style_layout(s, 'e5', :union=>['e3'], :iexpand=>:ns, :ipadx=>2)
+
+ s = t.style_create('s3')
+ t.style_elements(s, ['e6'])
+ t.style_layout(s, 'e6', :padx=>6, :expand=>:ns)
+
+ @Priv[:sensitive, t] = [
+ [:item, 's1', 'e5', 'e1', 'e3'],
+ [:item, 's2', 'e5', 'e2', 'e3']
+ ]
+ @Priv[:dragimage, t] = [
+ [:item, 's1', 'e1', 'e3'],
+ [:item, 's2', 'e2', 'e3']
+ ]
+
+ clicks = Tk::Clock.clicks
+ items = [ t.index(:root) ]
+ (1...(random_N())).each{|i|
+ item_i = t.item_create
+ item_j = nil
+ loop {
+ j = rand(i)
+ item_j = items[j]
+ break if t.depth(item_j) < 5
+ }
+ if $Version_1_1_OrLater
+ t.item_collapse(item_i) if rand(2) == 0
+ else # TreeCtrl 1.0
+ t.collapse(item_i) if rand(2) == 0
+ end
+ if rand(2) == 0
+ t.item_lastchild(item_j, item_i)
+ else
+ t.item_firstchild(item_j, item_i)
+ end
+ items << item_i
+ }
+ puts "created #{random_N() - 1} items in #{Tk::Clock.clicks - clicks} clicks"
+
+ clicks = Tk::Clock.clicks
+ (0...(random_N())).each{|i|
+ item_i = items[i]
+ numChildren = t.item_numchildren(item_i)
+ if numChildren > 0
+ if $Version_1_1_OrLater
+ t.item_configure(item_i, :button=>true)
+ else # TreeCtrl 1.0
+ t.item_hasbutton(item_i, true)
+ end
+ t.item_style_set(item_i, 0, 's1', 1, 's3', 2, 's3')
+ t.item_complex(item_i,
+ [ ['e3', {:text=>"Item #{i}"}],
+ ['e4', {:text=>"(#{numChildren})"}] ],
+ [ ['e6', {:text=>"#{t.item_parent(item_i)}"}] ],
+ [ ['e6', {:text=>"#{t.depth(item_i)}"}] ])
+ else
+ t.item_style_set(item_i, 1, 's3', 2, 's3', 0, 's2')
+ t.item_complex(item_i,
+ [ ['e3', {:text=>"Item #{i}"}] ],
+ [ ['e6', {:text=>"#{t.item_parent(item_i)}"}] ],
+ [ ['e6', {:text=>"#{t.depth(item_i)}"}] ])
+ end
+ }
+ puts "configured #{random_N()} items in #{Tk::Clock.clicks - clicks} clicks"
+
+ treeCtrlRandom = TkBindTag.new
+
+ treeCtrlRandom.bind('Double-ButtonPress-1',
+ proc{|w, x, y|
+ Tk::TreeCtrl::BindCallback.doubleButton1(w, x, y)
+ Tk.callback_break
+ }, '%W %x %y')
+
+ treeCtrlRandom.bind('Control-ButtonPress-1',
+ proc{|w, x, y|
+ @Priv['selectMode'] = :toggle
+ randomButton1(w, x, y)
+ Tk.callback_break
+ }, '%W %x %y')
+
+ treeCtrlRandom.bind('Shift-ButtonPress-1',
+ proc{|w, x, y|
+ @Priv['selectMode'] = :add
+ randomButton1(w, x, y)
+ Tk.callback_break
+ }, '%W %x %y')
+
+ treeCtrlRandom.bind('ButtonPress-1',
+ proc{|w, x, y|
+ @Priv['selectMode'] = :set
+ randomButton1(w, x, y)
+ Tk.callback_break
+ }, '%W %x %y')
+
+ treeCtrlRandom.bind('Button1-Motion',
+ proc{|w, x, y|
+ randomMotion1(w, x, y)
+ Tk.callback_break
+ }, '%W %x %y')
+
+ treeCtrlRandom.bind('Button1-Leave',
+ proc{|w, x, y|
+ randomLeave1(w, x, y)
+ Tk.callback_break
+ }, '%W %x %y')
+
+ treeCtrlRandom.bind('ButtonRelease-1',
+ proc{|w, x, y|
+ randomRelease1(w, x, y)
+ Tk.callback_break
+ }, '%W %x %y')
+
+ t.bindtags = [ t, treeCtrlRandom, Tk::TreeCtrl, t.winfo_toplevel, :all ]
+end
+
+def randomButton1(t, x, y)
+ t.set_focus
+ id = t.identify(x, y)
+ puts id.inspect
+ @Priv['buttonMode'] = ''
+
+ # Click outside any item
+ if id.empty?
+ t.selection_clear
+
+ # Click in header
+ elsif id[0] == 'header'
+ Tk::TreeCtrl::BindCallback.buttonPress1(t, x, y)
+
+ # Click in item
+ else
+ where, item, arg1, arg2, arg3, arg4 = id
+ case arg1
+ when 'button'
+ if $Version_1_1_OrLater
+ t.item_toggle(item)
+ else # TreeCtrl 1.0
+ t.toggle(item)
+ end
+
+ when 'line'
+ if $Version_1_1_OrLater
+ t.item_toggle(arg2)
+ else # TreeCtrl 1.0
+ t.toggle(arg2)
+ end
+
+ when 'column'
+ ok = false
+ # Clicked an element
+ if id.length == 6
+ column = id[3]
+ e = id[5]
+ @Priv.list_element(:sensitive, t).each{|lst|
+ c, s, *eList = TkComm.simplelist(lst)
+ next if column != t.column_index(c)
+ next if t.item_style_set(item, c) != s
+ next if eList.find{|le| le == e} == nil
+ ok = true
+ break
+ }
+ end
+ unless ok
+ t.selection_clear
+ return
+ end
+
+ @Priv[:drag, :motion] = 0
+ @Priv[:drag, :x] = t.canvasx(x)
+ @Priv[:drag, :y] = t.canvasy(y)
+ @Priv[:drop] = ''
+
+ if @Priv['selectMode'] == 'add'
+ Tk::TreeCtrl::BindCallback.beginExtend(t, item)
+ elsif @Priv['selectMode'] == 'toggle'
+ Tk::TreeCtrl::BindCallback.beginToggle(t, item)
+ elsif ! t.selection_includes(item)
+ Tk::TreeCtrl::BindCallback.beginSelect(t, item)
+ end
+ t.activate(item)
+
+ if t.selection_includes(item)
+ @Priv['buttonMode'] = 'drag'
+ end
+ end
+ end
+end
+
+def randomMotion1(t, x, y)
+ case @Priv['buttonMode']
+ when 'resize', 'header'
+ Tk::TreeCtrl::BindCallback.motion1(t, x, y)
+ when 'drag'
+ randomAutoScanCheck(t, x, y)
+ randomMotion(t, x, y)
+ end
+end
+
+def randomMotion(t, x, y)
+ case @Priv['buttonMode']
+ when 'resize', 'header'
+ Tk::TreeCtrl::BindCallback.motion1(t, x, y)
+
+ when 'drag'
+ # Detect initial mouse movement
+ unless @Priv.bool_element(:drag, :motion)
+ @Priv[:selection] = t.selection_get
+ @Priv[:drop] = ''
+ t.dragimage_clear
+ # For each selected item, add 2nd and 3rd elements of
+ # column "item" to the dragimage
+ @Priv.list_element(:selection).each{|i|
+ @Priv.list_element(:dragimage,t).each{|lst|
+ c, s, *eList = TkComm.simplelist(lst)
+ if t.item_style_set(i, c) == s
+ t.dragimage_add(i, c, *eList)
+ end
+ }
+ }
+ @Priv[:drag,:motion] = true
+ end
+
+ # Find the item under the cursor
+ cursor = 'X_cursor'
+ drop = ''
+ id = t.identify(x, y)
+ ok = false
+ if !id.empty? && id[0] == 'item' && id.length == 6
+ item = id[1]
+ column = id[3]
+ e = id[5]
+ @Priv.list_element(:sensitive,t).each{|lst|
+ c, s, *eList = TkComm.simplelist(lst)
+ next if column != t.column_index(c)
+ next if t.item_style_set(item, c) != s
+ next unless eList.find{|val| val.to_s == e.to_s}
+ ok = true
+ break
+ }
+ ok = true if @Priv.list_element(:sensitive,t).find{|val| TkComm.simplelist(val).index(e)}
+ end
+
+ if ok
+ # If the item is not in the pre-drag selection
+ # (i.e. not being dragged) see if we can drop on it
+ unless @Priv.list_element(:selection).find{|val| val.to_s == item.to_s}
+ drop = item
+ # We can drop if dragged item isn't an ancestor
+ @Priv.list_element(:selection).each{|item2|
+ if t.item_isancestor(item2, item)
+ drop = ''
+ break
+ end
+ }
+ if drop != ''
+ x1, y1, x2, y2 = t.item_bbox(drop)
+ if y < y1 + 3
+ cursor = 'top_side'
+ @Priv[:drop,:pos] = 'prevsibling'
+ elsif y >= y2 - 3
+ cursor = 'bottom_side'
+ @Priv[:drop,:pos] = 'nextsibling'
+ else
+ cursor = ''
+ @Priv[:drop,:pos] = 'lastchild'
+ end
+ end
+ end
+ end
+
+ t[:cursor] = cursor if t[:cursor] != cursor
+
+ # Select the item under the cursor (if any) and deselect
+ # the previous drop-item (if any)
+ t.selection_modify(drop, @Priv[:drop])
+ @Priv[:drop] = drop
+
+ # Show the dragimage in its new position
+ x = t.canvasx(x) - @Priv.numeric_element(:drag,:x)
+ y = t.canvasx(y) - @Priv.numeric_element(:drag,:y)
+ t.dragimage_offset(x, y)
+ t.dragimage_configure(:visible=>true)
+ end
+end
+
+def randomLeave1(t, x, y)
+ # This is called when I do ButtonPress-1 on Unix for some reason,
+ # and buttonMode is undefined.
+ return unless @Priv.exist?('buttonMode')
+ case @Priv['buttonMode']
+ when 'header'
+ Tk::TreeCtrl::BindCallback.leave1(t, x, y)
+ end
+end
+
+def randomRelease1(t, x, y)
+ case @Priv['buttonMode']
+ when 'resize', 'header'
+ Tk::TreeCtrl::BindCallback.release1(t, x, y)
+ when 'drag'
+ Tk::TreeCtrl::BindCallback.autoScanCancel(t)
+ t.dragimage_configure(:visible=>false)
+ t.selection_modify('', @Priv[:drop])
+ t[:cursor] = ''
+ if @Priv[:drop] != ''
+ randomDrop(t, @Priv[:drop], @Priv.list_element(:selection),
+ @Priv[:drop, :pos])
+ end
+ end
+ @Priv['buttonMode'] = ''
+end
+
+def randomDrop(t, target, src, pos)
+ parentList = []
+ case pos
+ when 'lastchild'
+ parent = target
+ when 'prevsibling'
+ parent = t.item_parent(target)
+ when 'nextsibling'
+ parent = t.item_parent(target)
+ end
+ src.each{|item|
+ # Ignore any item whose ancestor is also selected
+ ignore = false
+ t.item_ancestors(item).each{|ancestor|
+ if src.find{|val| val.to_s == ancestor.to_s}
+ ignore = true
+ break
+ end
+ }
+ next if ignore
+
+ # Update the old parent of this moved item later
+ unless parentList.find{|val| val.to_s == item.to_s}
+ parentList << t.item_parent(item)
+ end
+
+ # Add to target
+ t.__send__("item_#{pos}", target, item)
+
+ # Update text: parent
+ t.item_element_configure(item, 'parent', 'e6', :text=>parent)
+
+ # Update text: depth
+ t.item_element_configure(item, 'depth', 'e6', :text=>t.depth(item))
+
+ # Recursively update text: depth
+ itemList = []
+ item = t.item_firstchild(item)
+ itemList << item if item != ''
+
+ while item = itemList.pop
+ t.item_element_configure(item, 'depth', 'e6', :text=>t.depth(item))
+
+ item2 = t.item_nextsibling(item)
+ itemList << item2 if item2 != ''
+
+ item2 = t.item_firstchild(item)
+ itemList << item2 if item2 != ''
+ end
+ }
+
+ # Update items that lost some children
+ parentList.each{|item|
+ numChildren = t.item_numchildren(item)
+ if numChildren == 0
+ if $Version_1_1_OrLater
+ t.item_configure(item, :button=>false)
+ else # TreeCtrl 1.0
+ t.item_hasbutton(item, false)
+ end
+ t.item_style_map(item, 'item', 's2', ['e3', 'e3'])
+ else
+ t.item_element_configure(item, 'item', 'e4', :text=>"(#{numChildren})")
+ end
+ }
+
+ # Update the target that gained some children
+ if t.item_style_set(parent, 0) != 's1'
+ if $Version_1_1_OrLater
+ t.item_configure(parent, :button=>true)
+ else # TreeCtrl 1.0
+ t.item_hasbutton(parent, true)
+ end
+ t.item_style_map(parent, 'item', 's1', ['e3', 'e3'])
+ end
+ numChildren = t.item_numchildren(parent)
+ t.item_element_configure(parent, 'item', 'e4', :text=>"(#{numChildren})")
+end
+
+# Same as TreeCtrl::AutoScanCheck, but calls RandomMotion and
+# RandomAutoScanCheckAux
+def randomAutoScanCheck(t, x, y)
+ x1, y1, x2, y2 = t.contentbox
+ margin = t.winfo_pixels(t.scrollmargin)
+ if x < x1 + margin || x >= x2 - margin || y < y1 + margin || y >= y2 - margin
+ if ! @Priv.exist?(:autoscan, :afterId, t)
+ if y >= y2 - margin
+ t.yview(:scroll, 1, :units)
+ delay = t.yscrolldelay
+ elsif y < y1 + margin
+ t.yview(:scroll, -1, :units)
+ delay = t.yscrolldelay
+ elsif x >= x2 - margin
+ t.xview(:scroll, 1, :units)
+ delay = t.xscrolldelay
+ elsif x < x1 + margin
+ t.xview(:scroll, -1, :units)
+ delay = t.xscrolldelay
+ end
+ if @Priv.exist?(:autoscan, :scanning, t)
+ delay = delay[1] if delay.kind_of?(Array)
+ else
+ delay = delay[0] if delay.kind_of?(Array)
+ @Priv[:autoscan, :scanning, t] = true
+ end
+ case @Priv['buttonMode']
+ when 'drag', 'marquee'
+ randomMotion(t, x, y)
+ end
+ @Priv[:autoscan, :afterId, t] =
+ Tk.after(delay, proc{ randomAutoScanCheckAux(t) })
+ end
+ return
+ end
+ Tk::TreeCtrl::BindCallback.autoScanCancel(t)
+end
+
+def randomAutoScanCheckAux(t)
+ @Priv.unset(:autoscan, :afterId, t)
+ x = t.winfo_pointerx - t.winfo_rootx
+ y = t.winfo_pointery - t.winfo_rooty
+ randomAutoScanCheck(t, x, y)
+end
+
+#
+# Demo: random N items, button images
+#
+def demoRandom2(t)
+ demoRandom(t)
+
+ init_pics('mac-*')
+
+ t.configure(:openbuttonimage=>@images['mac-collapse'],
+ :closedbuttonimage=>@images['mac-expand'],
+ :showlines=>false)
+end
diff --git a/jni/ruby/ext/tk/sample/tkextlib/treectrl/readme.txt b/jni/ruby/ext/tk/sample/tkextlib/treectrl/readme.txt
new file mode 100644
index 0000000..81e13b2
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkextlib/treectrl/readme.txt
@@ -0,0 +1,2 @@
+The scripts and image files in this directory are based on demo files
+of Tcl/Tk's TreeCtrl extension.
diff --git a/jni/ruby/ext/tk/sample/tkextlib/treectrl/www-options.rb b/jni/ruby/ext/tk/sample/tkextlib/treectrl/www-options.rb
new file mode 100644
index 0000000..6a3e9c2
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkextlib/treectrl/www-options.rb
@@ -0,0 +1,303 @@
+def demoInternetOptions (t)
+ @Option = TkVarAccess.new_hash('::Option')
+
+ height = t.font.metrics(:linespace) + 2
+ height = 18 if height < 18
+ t.configure(:showroot=>false, :showbuttons=>false, :showlines=>false,
+ :itemheight=>height, :selectmode=>:browse)
+
+ init_pics('internet-*')
+
+ if $HasColumnCreate
+ t.column_create(:text=>'Internet Options')
+ else
+ t.column_configure(0, :text=>'Internet Options')
+ end
+
+ t.state_define('check')
+ t.state_define('radio')
+ t.state_define('on')
+
+ t.element_create('e1', :image, :image=>[
+ @images['internet-check-on'], ['check', 'on'],
+ @images['internet-check-off'], ['check'],
+ @images['internet-radio-on'], ['radio', 'on'],
+ @images['internet-radio-off'], ['radio']
+ ])
+ t.element_create('e2', :text,
+ :fill=>[@SystemHighlightText, ['selected', 'focus']])
+ t.element_create('e3', :rect, :showfocus=>true,
+ :fill=>[@SystemHighlight, ['selected', 'focus']])
+
+ s = t.style_create('s1')
+ t.style_elements(s, ['e3', 'e1', 'e2'])
+ t.style_layout(s, 'e1', :padx=>[0,4], :expand=>:ns)
+ t.style_layout(s, 'e2', :expand=>:ns)
+ t.style_layout(s, 'e3', :union=>['e2'], :iexpand=>:ns, :ipadx=>2)
+
+ parentList = [:root, '', '', '', '', '', '']
+ parent = :root
+ [
+ [0, :print, "Printing", "", ""],
+ [1, :off, "Print background colors and images", "o1", ""],
+ [0, :search, "Search from Address bar", "", ""],
+ [1, :search, "When searching", "", ""],
+ [2, :off, "Display results, and go to the most likely sites",
+ "o2", "r1"],
+ [2, :off, "Do not search from the Address bar", "o3", "r1"],
+ [2, :off, "Just display the results in the main window",
+ "o4", "r1"],
+ [2, :on, "Just go to the most likely site", "o5", "r1"],
+ [0, :security, "Security", "", ""],
+ [1, :on, "Check for publisher's certificate revocation", "o5", ""],
+ [1, :off, "Check for server certificate revocation (requires restart)",
+ "o6", ""]
+ ].each{|depth, setting, text, option, group|
+ item = t.item_create()
+ t.item_style_set(item, 0, 's1')
+ t.item_element_configure(item, 0, 'e2', :text=>text)
+ @Option[:option, item] = option
+ @Option[:group, item] = group
+ if setting == :on || setting == :off
+ @Option[:setting, item] = setting
+ if group == ''
+ t.item_state_set(item, 'check')
+ if setting == :on
+ t.item_state_set(item, 'on')
+ end
+ else
+ if setting == :on
+ @Option[:current, group] = item
+ t.item_state_set(item, 'on')
+ end
+ t.item_state_set(item, 'radio')
+ end
+ else
+ t.item_element_configure(item, 0, 'e1',
+ :image=>@images["internet-#{setting}"])
+ end
+ t.item_lastchild(parentList[depth], item)
+ depth += 1
+ parentList[depth] = item
+ }
+
+ treeCtrlOption = TkBindTag.new
+ treeCtrlOption.bind('Double-ButtonPress-1', proc{|w, x, y|
+ Tk::TreeCtrl::BindCallback.doubleButton1(w, x, y)
+ }, '%W %x %y')
+ treeCtrlOption.bind('ButtonPress-1', proc{|w, x, y|
+ optionButton1(w, x, y)
+ Tk.callback_break
+ }, '%W %x %y')
+ treeCtrlOption.bind('Button1-Motion', proc{|w, x, y|
+ optionMotion1(w, x, y)
+ Tk.callback_break
+ }, '%W %x %y')
+ treeCtrlOption.bind('Button1-Leave', proc{|w, x, y|
+ optionLeave1(w, x, y)
+ Tk.callback_break
+ }, '%W %x %y')
+ treeCtrlOption.bind('ButtonRelease-1', proc{|w, x, y|
+ optionRelease1(w, x, y)
+ Tk.callback_break
+ }, '%W %x %y')
+
+ t.bindtags = [
+ t, treeCtrlOption, Tk::TreeCtrl, t.winfo_toplevel, TkBindTag::ALL
+ ]
+end
+
+def optionButton1(w, x, y)
+ w.set_focus
+ id = w.identify(x, y)
+ if id[0] == 'header'
+ Tk::TreeCtrl::BindCallback.buttonPress1(w, x, y)
+ elsif id.empty?
+ @Priv['buttonMode'] = ''
+ else
+ @Priv['buttonMode'] = ''
+ item = id[1]
+ w.selection_modify(item, :all)
+ w.activate(item)
+ return if @Option[:option, item] == ''
+ group = @Option[:group, item]
+ if group == ''
+ # a checkbutton
+ w.item_state_set(item, '~on')
+ if @Option[:setting, item] == 'on'
+ setting = :off
+ else
+ setting = :on
+ end
+ @Option[:setting, item] = setting
+ else
+ # a radiobutton
+ current = @Option[:current, group]
+ return if current == item.to_s
+ w.item_state_set(current, '!on')
+ w.item_state_set(item, 'on')
+ @Option[:setting, item] = :on
+ @Option[:current, group] = item
+ end
+ end
+end
+
+# Alternate implementation that doesn't rely on run-time styles
+def demoInternetOptions_2(t)
+ height = t.font.metrics(:linespace) + 2
+ height = 18 if height < 18
+ t.configure(:showroot=>false, :showbuttons=>false, :showlines=>false,
+ :itemheight=>height, :selectmode=>:browse)
+
+ init_pics('internet-*')
+
+ t.column_configure(0, :text=>'Internet Options')
+
+ t.element_create('e1', :image)
+ t.element_create('e2', :text,
+ :fill=>[@SystemHighlightText, ['selected', 'focus']])
+ t.element_create('e3', :rect, :showfocus=>true,
+ :fill=>[@SystemHighlight, ['selected', 'focus']])
+
+ s = t.style_create('s1')
+ t.style_elements('s1', ['e3', 'e1', 'e2'])
+ t.style_layout(s, 'e1', :padx=>[0,4], :expand=>:ns)
+ t.style_layout(s, 'e2', :expand=>:ns)
+ t.style_layout(s, 'e3', :union=>['e2'], :iexpand=>:ns, :ipadx=>2)
+
+ parentList = [:root, '', '', '', '', '', '']
+ parent = :root
+ [
+ [0, :print, "Printing", "", ""],
+ [1, :off, "Print background colors and images", "o1", ""],
+ [0, :search, "Search from Address bar", "", ""],
+ [1, :search, "When searching", "", ""],
+ [2, :off, "Display results, and go to the most likely sites",
+ "o2", "r1"],
+ [2, :off, "Do not search from the Address bar", "o3", "r1"],
+ [2, :off, "Just display the results in the main window",
+ "o4", "r1"],
+ [2, :on, "Just go to the most likely site", "o5", "r1"],
+ [0, :security, "Security", "", ""],
+ [1, :on, "Check for publisher's certificate revocation", "o5", ""],
+ [1, :off, "Check for server certificate revocation (requires restart)",
+ "o6", ""]
+ ].each{|depth, setting, text, option, group|
+ item = t.item_create()
+ t.item_style_set(item, 0, 's1')
+ t.item_element_configure(item, 0, 'e2', :text=>text)
+ @Option[:option, item] = option
+ @Option[:group, item] = group
+ if setting == :on || setting == :off
+ @Option[:setting, item] = setting
+ if group == ''
+ img = @images["internet-check-#{setting}"]
+ t.item_element_configure(item, 0, 'e1', :image=>img)
+ else
+ if setting == :on
+ @Option[:current, group] = item
+ end
+ img = @images["internet-radio-#{setting}"]
+ t.item_element_configure(item, 0, 'e1', :image=>img)
+ end
+ else
+ t.item_element_configure(item, 0, 'e1',
+ :image=>@images["internet-#{setting}"])
+ end
+ t.item_lastchild(parentList[depth], item)
+ depth += 1
+ parentList[depth] = item
+ }
+
+ treeCtrlOption = TkBindTag.new
+ treeCtrlOption.bind('Double-ButtonPress-1', proc{|w, x, y|
+ Tk::TreeCtrl::BindCallback.doubleButton1(w, x, y)
+ }, '%W %x %y')
+ treeCtrlOption.bind('ButtonPress-1', proc{|w, x, y|
+ optionButton1(w, x, y)
+ Tk.callback_break
+ }, '%W %x %y')
+ treeCtrlOption.bind('Button1-Motion', proc{|w, x, y|
+ optionMotion1(w, x, y)
+ Tk.callback_break
+ }, '%W %x %y')
+ treeCtrlOption.bind('Button1-Leave', proc{|w, x, y|
+ optionLeave1(w, x, y)
+ Tk.callback_break
+ }, '%W %x %y')
+ treeCtrlOption.bind('ButtonRelease-1', proc{|w, x, y|
+ optionRelease1(w, x, y)
+ Tk.callback_break
+ }, '%W %x %y')
+
+ t.bindtags = [
+ t, treeCtrlOption, Tk::TreeCtrl, t.winfo_toplevel, TkBindTag::ALL
+ ]
+end
+
+def optionButton1_2(w, x, y)
+ w.set_focus
+ id = w.identify(x, y)
+ if id[0] == 'header'
+ Tk::TreeCtrl::BindCallback.buttonPress1(w, x, y)
+ elsif id.empty?
+ @Priv['buttonMode'] = ''
+ else
+ @Priv['buttonMode'] = ''
+ item = id[1]
+ w.selection_modify(item, :all)
+ w.activate(item)
+ return if @Option[:option, item] == ''
+ group = @Option[:group, item]
+ if group == ''
+ # a checkbutton
+ if @Option[:setting, item] == 'on'
+ setting = :off
+ else
+ setting = :on
+ end
+ w.item_element_configure(item, 0, 'e1',
+ :image=>@images["internet-check-#{setting}"])
+ @Option[:setting, item] = setting
+ else
+ # a radiobutton
+ current = @Option[:current, group]
+ return if current == item.to_s
+ w.item_element_configure(current, 0, 'e1',
+ :image=>@images["internet-radio-off"])
+ w.item_element_configure(item, 0, 'e1',
+ :image=>@images["internet-radio-on"])
+ @Option[:setting, item] = :on
+ @Option[:current, group] = item
+ end
+ end
+end
+
+def optionMotion1(w, x, y)
+ case @Priv['buttonMode']
+ when 'resize', 'header'
+ Tk::TreeCtrl::BindCallback.motion1(w, x, y)
+ end
+end
+
+def optionLeave1(w, x, y)
+ # This is called when I do ButtonPress-1 on Unix for some reason,
+ # and buttonMode is undefined.
+ begin
+ mode = @Priv['buttonMode']
+ rescue
+ else
+ case mode
+ when 'header'
+ t.column_configure(@Priv['column'], :sunken=>false)
+ end
+ end
+end
+
+def optionRelease1(w, x, y)
+ case @Priv['buttonMode']
+ when 'resize', 'header'
+ Tk::TreeCtrl::BindCallback.release1(w, x, y)
+ end
+ @Priv['buttonMode'] = ''
+end
diff --git a/jni/ruby/ext/tk/sample/tkextlib/vu/Orig_LICENSE.txt b/jni/ruby/ext/tk/sample/tkextlib/vu/Orig_LICENSE.txt
new file mode 100644
index 0000000..f2e0edc
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkextlib/vu/Orig_LICENSE.txt
@@ -0,0 +1,51 @@
+
+ >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
+ >>> The following text is the original 'license.txt' of vu extension. <<<
+ >>> Original Tcl source files are not include in this directory, <<<
+ >>> because of all of them are rewritten to Ruby files. <<<
+ >>> However, the bitmap data file included in this directory is the <<<
+ >>> same file of vu extension. So, the bitmap data file is under the <<<
+ >>> following license. <<<
+ >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
+
+ * COPYRIGHT AND LICENSE TERMS *
+
+(This file blatantly stolen from Tcl/Tk license and adapted - thus assume
+it falls under similar license terms).
+
+This software is copyrighted by Jeffrey Hobbs <jeff.hobbs@acm.org> and
+others. The following terms apply to all files associated with the
+software unless explicitly disclaimed in individual files.
+
+The authors hereby grant permission to use, copy, modify, distribute, and
+license this software and its documentation for any purpose, provided that
+existing copyright notices are retained in all copies and that this notice
+is included verbatim in any distributions. No written agreement, license,
+or royalty fee is required for any of the authorized uses.
+
+IN NO EVENT SHALL THE AUTHORS OR DISTRIBUTORS BE LIABLE TO ANY PARTY FOR
+DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT
+OF THE USE OF THIS SOFTWARE, ITS DOCUMENTATION, OR ANY DERIVATIVES THEREOF,
+EVEN IF THE AUTHORS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+THE AUTHORS AND DISTRIBUTORS SPECIFICALLY DISCLAIM ANY WARRANTIES,
+INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE, AND NON-INFRINGEMENT. THIS SOFTWARE IS
+PROVIDED ON AN "AS IS" BASIS, AND THE AUTHORS AND DISTRIBUTORS HAVE NO
+OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR
+MODIFICATIONS.
+
+RESTRICTED RIGHTS: Use, duplication or disclosure by the U.S. government
+is subject to the restrictions as set forth in subparagraph (c) (1) (ii)
+of the Rights in Technical Data and Computer Software Clause as DFARS
+252.227-7013 and FAR 52.227-19.
+
+SPECIAL NOTES:
+
+This software also falls under the bourbon_ware clause:
+
+ Should you find this software useful in your daily work, you should
+ feel obliged to take the author out for a drink if the opportunity
+ presents itself. The user may feel exempt from this clause if they
+ are under 21 or think the author has already partaken of too many
+ drinks.
diff --git a/jni/ruby/ext/tk/sample/tkextlib/vu/README.txt b/jni/ruby/ext/tk/sample/tkextlib/vu/README.txt
new file mode 100644
index 0000000..ce5f371
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkextlib/vu/README.txt
@@ -0,0 +1,50 @@
+
+ >>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
+ >>> The following text is the original 'README.txt' of <<<
+ >>> vu extension demos. <<<
+ >>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
+
+##
+## DESCRIPTION OF DEMOS
+##
+
+canvItems.tcl
+ old demo of all canvas chart items, useful to find memory leaks.
+ <1> prints out the additional memory usage (charts.so + script)
+
+canvSticker.tcl
+ Heribert Dahms original "demo.tcl"
+ <p> creates DEMO.ps
+
+canvSticker2.tcl
+ compares "sticker" and "text"; press <1>, <2> or <1> ...
+ <p> creates DEMO.ps
+
+dial.tcl
+ demo of variations of the dial widget.
+
+load.tcl
+ Just a utility file, not a real demo.
+
+m128_000.xbm
+ XBM pic used by sticker and canvItems demos
+
+oscilloscope.tcl
+ the heart of a Realtime Oscilloscope,where the PC´s joystick
+ port gives 4 digtal inputs and 4 analog 8 bit values with an
+ resolution of ~1 millisecond (!!!) running Realtime Linux.
+ <p> creates DEMO.ps
+
+pie.tcl
+ The magic 3D spinning pie chart!
+
+vu.tcl
+ demo fo Vu widgets
+
+canvLabel.tcl
+ 'label' is a canvas item just like 'text', but with -angle
+ rotation of the string. This is not built in by default, as
+ it requires the internal Tk headers.
+ press <1>, <2> or <1> ...
+ <p> creates DEMO.ps
+
diff --git a/jni/ruby/ext/tk/sample/tkextlib/vu/canvItems.rb b/jni/ruby/ext/tk/sample/tkextlib/vu/canvItems.rb
new file mode 100644
index 0000000..364f876
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkextlib/vu/canvItems.rb
@@ -0,0 +1,90 @@
+#!/usr/bin/env ruby
+
+require 'tk'
+require 'tkextlib/vu/charts'
+
+#######################################
+
+xbm = File.join(File.dirname(File.expand_path(__FILE__)), 'm128_000.xbm')
+
+sval = [ 11, 22, 33, 44, 55, 66, 77, 88, 99 ]
+
+l0 = TkLabel.new(:width=>128, :height=>128,
+ :bitmap=>"@#{xbm}", :relief=>:groove).pack(:side=>:left)
+
+c0 = TkCanvas.new(:width=>80, :height=>80,
+ :insertwidth=>0, :highlightthickness=>0,
+ :selectborderwidth=>0, :borderwidth=>2,
+ :relief=>:ridge).place(:in=>l0, :relx=>0.5, :rely=>0.5,
+ :anchor=>:c)
+
+st = Tk::Vu::TkcStripchart.new(c0, 3, 3, 80, 80,
+ :background=>"#b7c0d7", :fill=>'slategray3',
+ :jumpscroll=>1, :outline=>'black',
+ :scaleline=>'blue', :stripline=>'red',
+ :selected=>1, :values=>sval)
+
+TkcText.create(c0, 40, 40,
+ :text=>Tk::TCL_PATCHLEVEL, :fill=>'cyan', :tags=>'text')
+
+
+l1 = TkLabel.new(:width=>128, :height=>128,
+ :bitmap=>"@#{xbm}", :relief=>:groove).pack(:side=>:left)
+
+c1 = TkCanvas.new(:width=>80, :height=>80,
+ :insertwidth=>0, :highlightthickness=>0,
+ :selectborderwidth=>0, :borderwidth=>2,
+ :relief=>:ridge).place(:in=>l1, :relx=>0.5, :rely=>0.5,
+ :anchor=>:c)
+
+bar1 = Tk::Vu::TkcBarchart.new(c1, 3, 3, 80, 80,
+ :background=>"#b7c0d7", :scalevalue=>10.0,
+ :autocolor=>true, :selected=>1,
+ :outline=>'black', :barline=>'yellow',
+ :scalelinestyle=>0)
+
+bar2 = Tk::Vu::TkcBarchart.new(c1, 53, 3, 80, 80,
+ :background=>"#b7c0d7", :scalevalue=>10.0,
+ :autocolor=>true, :selected=>1,
+ :outline=>'black', :fill=>"#b7c0d7",
+ :barline=>'red', :scalelinestyle=>22)
+
+
+l2 = TkLabel.new(:width=>128, :height=>128,
+ :bitmap=>"@#{xbm}", :relief=>:groove).pack(:side=>:left)
+
+c2 = TkCanvas.new(:width=>80, :height=>80,
+ :insertwidth=>0, :highlightthickness=>0,
+ :selectborderwidth=>0, :borderwidth=>2,
+ :relief=>:ridge).place(:in=>l2, :relx=>0.5, :rely=>0.5,
+ :anchor=>:c)
+
+begin
+ stick = Tk::Vu::TkcSticker.new(c2, 3, 3, 80, 80,
+ :text=>"Tcl/Tk", :space=>0, :color=>'red',
+ :outline=>'red', :font=>'Helvetica 14 bold',
+ :fill=>'', :stipple=>'', :bar=>'blue',
+ :orient=>:vertical, :anchor=>:s,
+ :relheight=>1.0, :relwidth=>0.15,
+ :relx=>0.1, :rely=>0.0)
+rescue
+ stick = nil
+ TkcText.new(c2, 40, 10, :text=>"No Sticker Item")
+end
+
+c_do = proc{
+ st[:values] = rand() * 100
+
+ bar1[:values] = rand() * 10
+ bar2[:values] = rand() * 10
+
+ stick[:rely] = rand() * 100 * 0.01 if stick
+}
+
+c0.bind('1', c_do)
+
+TkTimer.new(100, -1, c_do).start
+
+Tk.root.bind('q', proc{exit})
+
+Tk.mainloop
diff --git a/jni/ruby/ext/tk/sample/tkextlib/vu/canvSticker.rb b/jni/ruby/ext/tk/sample/tkextlib/vu/canvSticker.rb
new file mode 100644
index 0000000..85713eb
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkextlib/vu/canvSticker.rb
@@ -0,0 +1,82 @@
+#!/usr/bin/env ruby
+
+require 'tk'
+require 'tkextlib/vu/charts'
+
+#######################################
+
+Tk.root.geometry('+30+30')
+
+delay = 2000
+
+c = TkCanvas.new.pack
+
+begin
+ st = Tk::Vu::TkcSticker.new(c, 0, 0, 10, 10)
+rescue
+ Tk.messageBox(:type=>'ok', :title=>"No sticker Item",
+ :message=>"This build of vu does not include the sticker item")
+ exit
+end
+#st.delete
+
+steps = []
+
+steps << proc{
+ # I used a 75dpi screen for testing, but others should make no difference!
+ puts 'You\'ll see a small upright rectangle with "He" inside.'
+ st = Tk::Vu::TkcSticker.new(c, '6m', '10m', '13m', '27m', :text=>'Hello')
+}
+
+steps << proc{
+ puts 'You\'ll see the whole "Hello" drawn rotated 90 degrees.'
+ st[:orient] = :vertical
+}
+
+steps << proc{
+ puts 'The rectangle shrinks and the text is clipped to "Hell"'
+ #st.coords('6m', '10m', '13m', '20m')
+ st.coords('6m', '10m', '13m', '17m')
+}
+
+steps << proc{
+ puts 'Now you\'ll read "ello"'
+ st[:lefttrunc] = true
+}
+
+steps << proc{
+ puts 'Enlarging the rectangle shows the complete "Hello" again'
+ st.scale(0, 0, 3, 3)
+}
+
+steps << proc{
+ puts 'This time the text is repeated: "Hello", approx. 5mm space, "Hello"'
+ st[:space] = '5m'
+}
+
+steps << proc{
+ puts 'A vertical bar appears in the lower right region and text jumps to the left.'
+ st.configure(:anchor=>:n, :relw=>0.3, :relh=>0.7,
+ :relx=>0.6, :rely=>0.3, :bar=>'red')
+}
+
+steps << proc{
+ puts 'Paint the backgound.'
+ st[:fill] = 'yellow'
+}
+
+steps << proc{
+ puts "Let's test stippling."
+ st[:stipple] = 'gray25'
+}
+
+steps << proc{
+ puts 'Finally a large outline forces a single "Hello" and shrinks the bar.'
+ st[:width] = '6m'
+}
+
+Tk.root.bind('q', proc{exit})
+
+TkTimer.new(delay, 1, *steps).start
+
+Tk.mainloop
diff --git a/jni/ruby/ext/tk/sample/tkextlib/vu/canvSticker2.rb b/jni/ruby/ext/tk/sample/tkextlib/vu/canvSticker2.rb
new file mode 100644
index 0000000..3d9495f
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkextlib/vu/canvSticker2.rb
@@ -0,0 +1,101 @@
+#!/usr/bin/env ruby
+
+require 'tk'
+require 'tkextlib/vu/charts'
+
+#######################################
+
+c = TkCanvas.new.pack
+
+begin
+ st = Tk::Vu::TkcSticker.new(c, 0, 0, 10, 10)
+rescue
+ Tk.messageBox(:type=>'ok', :title=>"No sticker Item",
+ :message=>"This build of vu does not include the sticker item")
+ exit
+end
+
+c.destroy
+
+#---
+#--- set STRING {{x0 y0 x1 y1} {...text...} {resize point: center}
+
+#sti_conf = [ [10, 10, 180, 180], "Sticker äöüß@²³¼½¾", :center ]
+#txt_conf = [ [210, 210], "Text äöüß@²³¼½¾", :center ]
+sti_conf = [ [10, 10, 350, 350],
+ Tk::UTF8_String('Sticker \u00E4\u00F6\u00FC\u00DF\u0040\u00B2\u00B3\u00BC\u00BD\u00BE'),
+ :center ]
+txt_conf = [ [250, 250],
+ Tk::UTF8_String('Text \u00E4\u00F6\u00FC\u00DF\u0040\u00B2\u00B3\u00BC\u00BD\u00BE'),
+ :center ]
+
+#p sti_conf
+
+fnt = TkFont.new('Helvetica 24 bold')
+
+#---GUI
+c = TkCanvas.new(:width=>500, :height=>500, :bg=>'aquamarine3').pack
+
+#---CRRW Use the technique of eval the coord ...
+sti = Tk::Vu::TkcSticker.new(c, sti_conf[0]){
+ anchor sti_conf[2]
+ bar 'black'
+ color 'red'
+ fill ''
+ font fnt
+ lefttrunc 0
+ outline ''
+ relheight 0.0
+ relwidth 0.0
+ relx 0.0
+ rely 0.0
+ space 0
+ stipple ''
+ tags 'sti'
+ text sti_conf[1]
+ width 0
+ orient :vertical
+ minwidth 0
+ minheight 0
+ maxwidth 32767
+ maxheight 32767
+}
+
+txt = TkcText.new(c, txt_conf[0]){
+ activefill ''
+ activestipple ''
+ anchor txt_conf[2]
+ disabledfill ''
+ disabledstipple ''
+ fill 'blue'
+ font fnt
+ justify :left
+ offset '0,0'
+ state ''
+ stipple ''
+ tags ['tex']
+ text txt_conf[1]
+ width 0
+}
+
+#---BINDINGS
+c.bind('2', proc{
+ sti[:orient] = :horizontal
+ txt[:width] = 0 # horizontal
+ })
+
+c.bind('3', proc{
+ sti[:orient] = :vertical
+ txt[:width] = 1 # top down
+ })
+
+Tk.root.bind('p', proc{
+ c.postscript(:file=>'DEMO.ps')
+ puts "DEMO.ps printed"
+ })
+
+Tk.root.bind('q', proc{exit})
+
+#####################
+
+Tk.mainloop
diff --git a/jni/ruby/ext/tk/sample/tkextlib/vu/dial_demo.rb b/jni/ruby/ext/tk/sample/tkextlib/vu/dial_demo.rb
new file mode 100644
index 0000000..f1f2f11
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkextlib/vu/dial_demo.rb
@@ -0,0 +1,113 @@
+#!/usr/bin/env ruby
+
+require 'tk'
+require 'tkextlib/vu/dial'
+
+#######################################
+
+v_volume = TkVariable.new
+v_speed = TkVariable.new
+v_dir = TkVariable.new
+v_rot = TkVariable.new
+v_linked = TkVariable.new
+v_needle = TkVariable.new
+
+volume = Tk::Vu::Dial.new(:label=>"Volume", :from=>-0.1, :to=>0.1,
+ :resolution=>0.001, :minortickinterval=>0.01,
+ :tickinterval=>0.1, :beginangle=>-20,
+ :endangle=>260, :variable=>v_volume)
+
+speed = Tk::Vu::Dial.new(:label=>"Speed", :from=>2000, :to=>100,
+ :resolution=>10, :tickinterval=>100,
+ :minortickinterval=>0, :variable=>v_speed,
+ :showtags=>:label, :showvalue=>false)
+
+speed.set_tag_constrain(100, 'Fast', 2000, 'Slow')
+
+fwd = Tk::Vu::Dial.new(:from=>-10.0, :to=>-20.0, :resolution=>0.1,
+ :tickinterval=>5.0, :minortickinterval=>1.0,
+ :variable=>v_dir)
+
+rev = Tk::Vu::Dial.new(:from=>-20.0, :to=>-10.0, :resolution=>0.1,
+ :tickinterval=>5.0, :minortickinterval=>1.0,
+ :variable=>v_dir)
+
+small = Tk::Vu::Dial.new(:font=>"Helvetica -10", :from=>0, :to=>10,
+ :resolution=>0.05, :tickinterval=>2,
+ :minortickinterval=>0.5, :radius=>20,
+ :dialcolor=>'red2', :activebackground=>'red',
+ :variable=>v_rot)
+
+large = Tk::Vu::Dial.new(:font=>"Helvetica -8", :from=>0, :to=>10,
+ :resolution=>0.05, :tickinterval=>1,
+ :minortickinterval=>0.25, :radius=>40,
+ :dialcolor=>'red2', :activebackground=>'red',
+ :variable=>v_rot)
+
+turn = Tk::Vu::Dial.new(:needlecolor=>'red', :label=>"Linked",
+ :variable=>v_linked)
+
+scale = TkScale.new(:label=>"Linked", :variable=>v_linked)
+
+d1 = Tk::Vu::Dial.new(:resolution=>0.0001, :from=>-0.1, :to=>0.1,
+ :showvalue=>true, :minortickinterval=>0.01,
+ :tickinterval=>0.1, :radius=>30, :label=>"Dial",
+ :beginangle=>-20, :endangle=>260, :variable=>v_needle,
+ :relief=>:raised)
+
+d2 = Tk::Vu::Dial.new(:resolution=>0.01, :from=>-0.1, :to=>0.1,
+ :showvalue=>true, :minortickinterval=>0.01,
+ :tickinterval=>0.1, :radius=>30, :label=>"Dial 2",
+ :beginangle=>-20, :endangle=>260, :variable=>v_needle,
+ :dialrelief=>:flat, :needlecolor=>'red',
+ :needletype=>:triangle, :relief=>:sunken)
+
+d3 = Tk::Vu::Dial.new(:resolution=>0.001, :from=>-0.1, :to=>0.1,
+ :showvalue=>true, :minortickinterval=>0.01,
+ :tickinterval=>0.1, :radius=>30, :label=>"Dial 3",
+ :beginangle=>-20, :endangle=>260, :variable=>v_needle,
+ :dialrelief=>:flat, :needlecolor=>'blue',
+ :needletype=>:arc, :relief=>:ridge)
+
+f_btns = TkFrame.new
+f_sep = TkFrame.new(:height=>2, :relief=>:sunken, :bd=>1)
+
+
+v_volume.value = -0.1
+v_speed.value = 500
+
+update = TkTimer.new(proc{v_speed.numeric}, -1, proc{
+ if v_volume == volume[:to]
+ v_volume.numeric = volume[:from]
+ else
+ v_volume.numeric += volume[:resolution]
+ end
+ })
+
+b_start = TkButton.new(:text=>"Start", :command=>proc{update.start})
+b_stop = TkButton.new(:text=>"Stop", :command=>proc{update.stop})
+b_exit = TkButton.new(:text=>"Exit", :command=>proc{exit})
+
+Tk.grid(b_start, :in=>f_btns, :sticky=>:ew, :padx=>4, :pady=>4)
+Tk.grid(b_stop, :in=>f_btns, :sticky=>:ew, :padx=>4, :pady=>4)
+f_btns.grid_columnconfigure(0, :weight=>1)
+
+Tk.grid(f_btns, speed, volume, :sticky=>:news)
+Tk.grid(f_sep, '-', '-', :sticky=>:news)
+Tk.grid(fwd, rev, d1, :sticky=>:news)
+Tk.grid(small, large, d2, :sticky=>:news)
+Tk.grid(turn, scale, d3, :sticky=>:news)
+
+Tk.grid(b_exit, '-', '-', :sticky=>:ew, :padx=>4, :pady=>4)
+
+Tk.root.grid_columnconfigure(0, :weight=>1)
+Tk.root.grid_columnconfigure(1, :weight=>1)
+Tk.root.grid_columnconfigure(2, :weight=>1)
+
+Tk.root.grid_rowconfigure(0, :weight=>1)
+Tk.root.grid_rowconfigure(2, :weight=>1)
+Tk.root.grid_rowconfigure(3, :weight=>1)
+Tk.root.grid_rowconfigure(4, :weight=>1)
+
+
+Tk.mainloop
diff --git a/jni/ruby/ext/tk/sample/tkextlib/vu/m128_000.xbm b/jni/ruby/ext/tk/sample/tkextlib/vu/m128_000.xbm
new file mode 100644
index 0000000..455e3c5
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkextlib/vu/m128_000.xbm
@@ -0,0 +1,174 @@
+#define m128_000_width 128
+#define m128_000_height 128
+static unsigned char m128_000_bits[] = {
+ 0xc0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0xff, 0xff, 0x00, 0xc0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0xf0, 0xff, 0xff, 0xff,
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x03,
+ 0xf0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0xff, 0xff, 0x03, 0xfc, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
+ 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xea, 0x0f, 0xfc, 0x55, 0x55, 0x55,
+ 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0xd5, 0x0f,
+ 0xbf, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
+ 0xaa, 0xaa, 0xaa, 0x3f, 0x7f, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55,
+ 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x3f, 0xaf, 0xfa, 0xab, 0xaa,
+ 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xfa, 0xab, 0x3e,
+ 0x5f, 0xf5, 0x57, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55,
+ 0x55, 0xf5, 0x57, 0x3d, 0xaf, 0x0e, 0xac, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
+ 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0x0e, 0xac, 0x3e, 0x5f, 0x0d, 0x5c, 0x55,
+ 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x0d, 0x5c, 0x3d,
+ 0xaf, 0x03, 0xb0, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
+ 0xaa, 0x03, 0xb0, 0x3e, 0x5f, 0x03, 0x70, 0x55, 0x55, 0x55, 0x55, 0x55,
+ 0x55, 0x55, 0x55, 0x55, 0x55, 0x03, 0x70, 0x3d, 0xaf, 0x03, 0xb0, 0xaa,
+ 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0x03, 0xb0, 0x3e,
+ 0x5f, 0x03, 0x70, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55,
+ 0x55, 0x03, 0x70, 0x3d, 0xaf, 0x03, 0xb0, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
+ 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0x03, 0xb0, 0x3e, 0x5f, 0x03, 0x70, 0x55,
+ 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x03, 0x70, 0x3d,
+ 0xaf, 0x0e, 0xac, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
+ 0xaa, 0x0e, 0xac, 0x3e, 0x5f, 0x0d, 0x5c, 0x55, 0x55, 0x55, 0x55, 0x55,
+ 0x55, 0x55, 0x55, 0x55, 0x55, 0x0d, 0x5c, 0x3d, 0xaf, 0xfa, 0xab, 0xaa,
+ 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xfa, 0xab, 0x3e,
+ 0x5f, 0xf5, 0x57, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55,
+ 0x55, 0xf5, 0x57, 0x3d, 0xaf, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
+ 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0x3e, 0x5f, 0x55, 0x55, 0x55,
+ 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x3d,
+ 0xaf, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
+ 0xaa, 0xaa, 0xaa, 0x3e, 0x5f, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55,
+ 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x3d, 0xaf, 0xaa, 0xaa, 0xaa,
+ 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0x3e,
+ 0x5f, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55,
+ 0x55, 0x55, 0x55, 0x3d, 0xaf, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
+ 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0x3e, 0x5f, 0x55, 0x55, 0x55,
+ 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x3d,
+ 0xaf, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
+ 0xaa, 0xaa, 0xaa, 0x3e, 0x5f, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55,
+ 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x3d, 0xaf, 0xaa, 0xaa, 0xaa,
+ 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0x3e,
+ 0x5f, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55,
+ 0x55, 0x55, 0x55, 0x3d, 0xaf, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
+ 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0x3e, 0x5f, 0x55, 0x55, 0x55,
+ 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x3d,
+ 0xaf, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
+ 0xaa, 0xaa, 0xaa, 0x3e, 0x5f, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55,
+ 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x3d, 0xaf, 0xaa, 0xaa, 0xaa,
+ 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0x3e,
+ 0x5f, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55,
+ 0x55, 0x55, 0x55, 0x3d, 0xaf, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
+ 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0x3e, 0x5f, 0x55, 0x55, 0x55,
+ 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x3d,
+ 0xaf, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
+ 0xaa, 0xaa, 0xaa, 0x3e, 0x5f, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55,
+ 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x3d, 0xaf, 0xaa, 0xaa, 0xaa,
+ 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0x3e,
+ 0x5f, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55,
+ 0x55, 0x55, 0x55, 0x3d, 0xaf, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
+ 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0x3e, 0x5f, 0x55, 0x55, 0x55,
+ 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x3d,
+ 0xaf, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
+ 0xaa, 0xaa, 0xaa, 0x3e, 0x5f, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55,
+ 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x3d, 0xaf, 0xaa, 0xaa, 0xaa,
+ 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0x3e,
+ 0x5f, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55,
+ 0x55, 0x55, 0x55, 0x3d, 0xaf, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
+ 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0x3e, 0x5f, 0x55, 0x55, 0x55,
+ 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x3d,
+ 0xaf, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
+ 0xaa, 0xaa, 0xaa, 0x3e, 0x5f, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55,
+ 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x3d, 0xaf, 0xaa, 0xaa, 0xaa,
+ 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0x3e,
+ 0x5f, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55,
+ 0x55, 0x55, 0x55, 0x3d, 0xaf, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
+ 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0x3e, 0x5f, 0x55, 0x55, 0x55,
+ 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x3d,
+ 0xaf, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
+ 0xaa, 0xaa, 0xaa, 0x3e, 0x5f, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55,
+ 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x3d, 0xaf, 0xaa, 0xaa, 0xaa,
+ 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0x3e,
+ 0x5f, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55,
+ 0x55, 0x55, 0x55, 0x3d, 0xaf, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
+ 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0x3e, 0x5f, 0x55, 0x55, 0x55,
+ 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x3d,
+ 0xaf, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
+ 0xaa, 0xaa, 0xaa, 0x3e, 0x5f, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55,
+ 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x3d, 0xaf, 0xaa, 0xaa, 0xaa,
+ 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0x3e,
+ 0x5f, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55,
+ 0x55, 0x55, 0x55, 0x3d, 0xaf, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
+ 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0x3e, 0x5f, 0x55, 0x55, 0x55,
+ 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x3d,
+ 0xaf, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
+ 0xaa, 0xaa, 0xaa, 0x3e, 0x5f, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55,
+ 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x3d, 0xaf, 0xaa, 0xaa, 0xaa,
+ 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0x3e,
+ 0x5f, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55,
+ 0x55, 0x55, 0x55, 0x3d, 0xaf, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
+ 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0x3e, 0x5f, 0x55, 0x55, 0x55,
+ 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x3d,
+ 0xaf, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
+ 0xaa, 0xaa, 0xaa, 0x3e, 0x5f, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55,
+ 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x3d, 0xaf, 0xaa, 0xaa, 0xaa,
+ 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0x3e,
+ 0x5f, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55,
+ 0x55, 0x55, 0x55, 0x3d, 0xaf, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
+ 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0x3e, 0x5f, 0x55, 0x55, 0x55,
+ 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x3d,
+ 0xaf, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
+ 0xaa, 0xaa, 0xaa, 0x3e, 0x5f, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55,
+ 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x3d, 0xaf, 0xaa, 0xaa, 0xaa,
+ 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0x3e,
+ 0x5f, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55,
+ 0x55, 0x55, 0x55, 0x3d, 0xaf, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
+ 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0x3e, 0x5f, 0x55, 0x55, 0x55,
+ 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x3d,
+ 0xaf, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
+ 0xaa, 0xaa, 0xaa, 0x3e, 0x5f, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55,
+ 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x3d, 0xaf, 0xaa, 0xaa, 0xaa,
+ 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0x3e,
+ 0x5f, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55,
+ 0x55, 0x55, 0x55, 0x3d, 0xaf, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
+ 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0x3e, 0x5f, 0x55, 0x55, 0x55,
+ 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x3d,
+ 0xaf, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
+ 0xaa, 0xaa, 0xaa, 0x3e, 0x5f, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55,
+ 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x3d, 0xaf, 0xaa, 0xaa, 0xaa,
+ 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0x3e,
+ 0x5f, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55,
+ 0x55, 0x55, 0x55, 0x3d, 0xaf, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
+ 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0x3e, 0x5f, 0x55, 0x55, 0x55,
+ 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x3d,
+ 0xaf, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
+ 0xaa, 0xaa, 0xaa, 0x3e, 0x5f, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55,
+ 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x3d, 0xaf, 0xfa, 0xab, 0xaa,
+ 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xfa, 0xab, 0x3e,
+ 0x5f, 0xf5, 0x57, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55,
+ 0x55, 0xf5, 0x57, 0x3d, 0xaf, 0x0e, 0xac, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
+ 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0x0e, 0xac, 0x3e, 0x5f, 0x0d, 0x5c, 0x55,
+ 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x0d, 0x5c, 0x3d,
+ 0xaf, 0x03, 0xb0, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
+ 0xaa, 0x03, 0xb0, 0x3e, 0x5f, 0x03, 0x70, 0x55, 0x55, 0x55, 0x55, 0x55,
+ 0x55, 0x55, 0x55, 0x55, 0x55, 0x03, 0x70, 0x3d, 0xaf, 0x03, 0xb0, 0xaa,
+ 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0x03, 0xb0, 0x3e,
+ 0x5f, 0x03, 0x70, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55,
+ 0x55, 0x03, 0x70, 0x3d, 0xaf, 0x03, 0xb0, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
+ 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0x03, 0xb0, 0x3e, 0x5f, 0x03, 0x70, 0x55,
+ 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x03, 0x70, 0x3d,
+ 0xaf, 0x0e, 0xac, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
+ 0xaa, 0x0e, 0xac, 0x3e, 0x5f, 0x0d, 0x5c, 0x55, 0x55, 0x55, 0x55, 0x55,
+ 0x55, 0x55, 0x55, 0x55, 0x55, 0x0d, 0x5c, 0x3d, 0xaf, 0xfa, 0xab, 0xaa,
+ 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xfa, 0xab, 0x3e,
+ 0x5f, 0xf5, 0x57, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55,
+ 0x55, 0xf5, 0x57, 0x3d, 0xbf, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
+ 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0x3f, 0x7f, 0x55, 0x55, 0x55,
+ 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x3f,
+ 0xfc, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
+ 0xaa, 0xaa, 0xea, 0x0f, 0xfc, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55,
+ 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0xd5, 0x0f, 0xf0, 0xff, 0xff, 0xff,
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x03,
+ 0xf0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0xff, 0xff, 0x03, 0xc0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0xc0, 0xff, 0xff, 0xff,
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, };
diff --git a/jni/ruby/ext/tk/sample/tkextlib/vu/oscilloscope.rb b/jni/ruby/ext/tk/sample/tkextlib/vu/oscilloscope.rb
new file mode 100644
index 0000000..1efe13c
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkextlib/vu/oscilloscope.rb
@@ -0,0 +1,68 @@
+#!/usr/bin/env ruby
+
+require 'tk'
+require 'tkextlib/vu/charts'
+
+#---USAGE
+info = "...the heart of a Realtime Oscilloscope, where the PCIs
+joystick port gives 4 digtal inputs and 4 analog 8 bit
+values with an resolution of ~1 millisecond (!!!)
+running Realtime Linux.
+<p> creates DEMO.ps
+<B1-Motion> see what happens"
+puts info
+
+#---GEOMETRY
+geo_fr = [10, 10, 210, 180]
+geo_ch0 = [10, 10, 210, 90]
+geo_ch1 = [10, 90, 210, 180]
+geo_t1 = [15, 88]
+
+#---GUI
+c = TkCanvas.new(:width=>220, :height=>190).pack(:fill=>:both, :expand=>true)
+
+#---background
+TkcRectangle.new(c, geo_fr, :width=>4, :fill=>'aquamarine3',
+ :tags=>['osc', 'frbg'])
+
+#---channel 0
+ch0 = Tk::Vu::TkcStripchart.new(c, geo_ch0,
+ :fill=>'', :jumpscroll=>false,
+ :outline=>'', :scaleline=>'',
+ :stripline=>'cyan', :tags=>['osc', 'ch0'])
+
+#---channel 1
+ch1 = Tk::Vu::TkcStripchart.new(c, geo_ch1,
+ :fill=>'', :jumpscroll=>0,
+ :outline=>'', :scaleline=>'',
+ :stripline=>'red', :tags=>['osc', 'ch1'])
+
+#---frame
+TkcRectangle.new(c, geo_fr, :width=>4, :tags=>['osc', 'frfg'])
+
+#---position
+txt1 = TkcText.new(c, geo_t1, :text=>"B1-Motion: X:%X\tY:%Y",
+ :anchor=>:nw, :tags=>['osc', 'txt1'])
+
+#---BINDINGS
+c.bind('B1-Motion', proc{|x, y, xx, yy|
+ ch0[:values] = x
+ ch1[:values] = y
+ txt1[:text] = "B1-Motion: X:#{xx}\tY:#{yy}"
+ }, '%x %y %X %Y')
+
+Tk.root.bind('v', proc{
+ puts ch0[:values].join(' ')
+ puts ch0[:values].size
+ })
+
+Tk.root.bind('p', proc{
+ c.postscript(:file=>'DEMO.ps')
+ puts "DEMO.ps printed"
+ })
+
+Tk.root.bind('q', proc{exit})
+
+#####################
+
+Tk.mainloop
diff --git a/jni/ruby/ext/tk/sample/tkextlib/vu/pie.rb b/jni/ruby/ext/tk/sample/tkextlib/vu/pie.rb
new file mode 100644
index 0000000..c8f9276
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkextlib/vu/pie.rb
@@ -0,0 +1,56 @@
+#!/usr/bin/env ruby
+
+require 'tk'
+require 'tkextlib/vu/pie'
+
+pie = Tk::Vu::Pie.new(:label=>"My Revolving Budget"){
+ itemconfigure('Welfare', :value=>3.004)
+ itemconfigure('Military', :value=>7.006)
+ itemconfigure('Transport', :value=>1.6, :explode=>15)
+ itemconfigure('Parks', :value=>0.9)
+ itemconfigure('Schools', :value=>2)
+ itemconfigure('Debt', :value=>4, :explode=>10)
+
+ configure(:angle=>10, :origin=>90, :shadow=>10)
+}
+
+spin = TkTimer.new(60, -1, proc{|obj|
+ pie.configure(:origin=>pie[:origin] + 1)
+})
+
+f = TkFrame.new
+fast_btn = TkButton.new(f, :text=>"Spin Faster", :command=>proc{spin.start})
+slow_btn = TkButton.new(f, :text=>"Spin Slower", :command=>proc{spin.stop})
+quit_btn = TkButton.new(f, :text=>"Exit", :command=>proc{exit})
+
+Tk.grid(pie, :sticky=>:news)
+Tk.grid(f, :sticky=>:ew)
+
+Tk.pack(fast_btn, slow_btn, quit_btn,
+ :in=>f, :side=>:left, :fill=>:both, :expand=>true, :padx=>6, :pady=>4)
+
+Tk.root.grid_columnconfigure(0, :weight=>1)
+Tk.root.grid_rowconfigure(0, :weight=>1)
+
+priv = {
+ :x=>0, :y=>0, :pie_in=>false, :angle=>pie[:angle], :origin=>pie[:origin]
+}
+
+pie.bind('ButtonPress-1', proc{|w, x, y|
+ priv[:x] = x
+ priv[:y] = y
+ priv[:pie_in] = (w.winfo_width/1.8 > x)
+ priv[:angle] = w[:angle]
+ priv[:origin] = w[:origin]
+ }, '%W %x %y')
+
+pie.bind('B1-Motion', proc{|w, x, y|
+ if priv[:pie_in]
+ w.configure(:angle=>priv[:angle] + (priv[:y] - y)/3,
+ :origin=>(priv[:origin] +
+ ((w.winfo_height/2.2 > y)? -1: 1) *
+ (priv[:x] - x)/3) % 360)
+ end
+ }, '%W %x %y')
+
+Tk.mainloop
diff --git a/jni/ruby/ext/tk/sample/tkextlib/vu/vu_demo.rb b/jni/ruby/ext/tk/sample/tkextlib/vu/vu_demo.rb
new file mode 100644
index 0000000..358d324
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkextlib/vu/vu_demo.rb
@@ -0,0 +1,67 @@
+#!/usr/bin/env ruby
+
+require 'tk'
+require 'tkextlib/vu'
+
+#######################################
+
+puts "Show off barchart and dial widgets"
+
+speed = TkVariable.new(0)
+
+dial = Tk::Vu::Dial.new(:resolution=>0.001, :from=>-0.1, :to=>0.1,
+ :showvalue=>true, :minortickinterval=>0.01,
+ :tickinterval=>0.1, :radius=>50, :label=>"Dial",
+ :beginangle=>-20, :endangle=>260, :dialcolor=>'red3',
+ :active=>'red2', :variable=>speed)
+
+bar = Tk::Vu::Bargraph.new(:from=>0, :to=>100, :relief=>:groove,
+ :border=>2, :label=>"Bar Chart")
+
+#######################################
+
+green = 25
+blue = 50
+purple = 75
+current = 50
+
+def rand_bool
+
+end
+
+update = TkTimer.new(200, -1, proc{
+ if (rand() - 0.5 + speed.numeric * 3) > 0
+ current += 1
+ else
+ current -= 1
+ end
+ bar.set(current)
+ if current < green
+ current = 100 if current <= 0
+ bar[:barcolor] = 'green'
+ elsif current < blue
+ bar[:barcolor] = 'blue'
+ elsif current < purple
+ bar[:barcolor] = 'purple'
+ else
+ bar[:barcolor] = 'red'
+ current = 0 if current >= 100
+ end
+ })
+
+#######################################
+
+gobar = TkButton.new(:text=>"Start", :command=>proc{update.start})
+nobar = TkButton.new(:text=>"Stop", :command=>proc{update.stop})
+quit = TkButton.new(:text=>"Exit", :command=>proc{exit})
+
+Tk.grid('x', gobar, :sticky=>:ew, :padx=>4, :pady=>4)
+Tk.grid(dial, bar, :sticky=>:news)
+Tk.grid('x', nobar, :sticky=>:ew, :padx=>4, :pady=>4)
+Tk.grid(quit, '-', '-', :sticky=>:ew, :padx=>4, :pady=>4)
+Tk.root.grid_columnconfigure(2, :weight=>1)
+Tk.root.grid_rowconfigure(1, :weight=>1)
+
+#######################################
+
+Tk.mainloop
diff --git a/jni/ruby/ext/tk/sample/tkfrom.rb b/jni/ruby/ext/tk/sample/tkfrom.rb
new file mode 100644
index 0000000..f51f7f5
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkfrom.rb
@@ -0,0 +1,132 @@
+#!/usr/bin/env ruby
+
+require "parsedate"
+require "base64"
+
+include ParseDate
+
+class Mail
+ def Mail.new(f)
+ if !f.kind_of?(IO)
+ f = open(f, "r")
+ me = super(f)
+ f.close
+ else
+ me = super
+ end
+ return me
+ end
+
+ def initialize(f)
+ @header = {}
+ @body = []
+ while line = f.gets()
+ $_.chop!
+ next if /^From / =~ line # skip From-line
+ break if /^$/ =~ line # end of header
+ if /^(\S+):\s*(.*)/ =~ line
+ @header[attr = $1.capitalize] = $2
+ elsif attr
+ sub(/^\s*/, '')
+ @header[attr] += "\n" + $_
+ end
+ end
+
+ return unless $_
+
+ while line = f.gets()
+ break if /^From / =~ line
+ @body.push($_)
+ end
+ end
+
+ def header
+ return @header
+ end
+
+ def body
+ return @body
+ end
+
+end
+
+if ARGV.length == 0
+ if ENV['MAIL']
+ ARGV[0] = ENV['MAIL']
+ elsif ENV['USER']
+ ARGV[0] = '/var/spool/mail/' + ENV['USER']
+ elsif ENV['LOGNAME']
+ ARGV[0] = '/var/spool/mail/' + ENV['LOGNAME']
+ end
+end
+
+require "tk"
+list = scroll = nil
+TkFrame.new{|f|
+ list = TkListbox.new(f) {
+ yscroll proc{|*idx|
+ scroll.set *idx
+ }
+ relief 'raised'
+# geometry "80x5"
+ width 80
+ height 5
+ setgrid 'yes'
+ pack('side'=>'left','fill'=>'both','expand'=>'yes')
+ }
+ scroll = TkScrollbar.new(f) {
+ command proc{|idx|
+ list.yview *idx
+ }
+ pack('side'=>'right','fill'=>'y')
+ }
+ pack
+}
+root = Tk.root
+TkButton.new(root) {
+ text 'Dismiss'
+ command proc {exit}
+ pack('fill'=>'both','expand'=>'yes')
+}
+root.bind "Control-c", proc{exit}
+root.bind "Control-q", proc{exit}
+root.bind "space", proc{exit}
+
+$outcount = 0;
+for file in ARGV
+ next unless File.exist?(file)
+ atime = File.atime(file)
+ mtime = File.mtime(file)
+ f = open(file, "r")
+ begin
+ until f.eof
+ mail = Mail.new(f)
+ date = mail.header['Date']
+ next unless date
+ from = mail.header['From']
+ subj = mail.header['Subject']
+ y = m = d = 0
+ y, m, d = parsedate(date) if date
+ from = "sombody@somewhere" unless from
+ subj = "(nil)" unless subj
+ from = decode_b(from)
+ subj = decode_b(subj)
+ list.insert 'end', format('%-02d/%02d/%02d [%-28.28s] %s',y,m,d,from,subj)
+ $outcount += 1
+ end
+ ensure
+ f.close
+ File.utime(atime, mtime, file)
+ list.see 'end'
+ end
+end
+
+limit = 10000
+if $outcount == 0
+ list.insert 'end', "You have no mail."
+ limit = 2000
+end
+Tk.after limit, proc{
+ exit
+}
+Tk.mainloop
diff --git a/jni/ruby/ext/tk/sample/tkhello.rb b/jni/ruby/ext/tk/sample/tkhello.rb
new file mode 100644
index 0000000..597c1f6
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkhello.rb
@@ -0,0 +1,10 @@
+require "tk"
+
+TkButton.new(nil,
+ :text => 'hello',
+ :command => proc{print "hello\n"}).pack(:fill=>'x')
+TkButton.new(nil,
+ :text => 'quit',
+ :command => proc{exit}).pack(:fill=>'x')
+
+Tk.mainloop
diff --git a/jni/ruby/ext/tk/sample/tkline.rb b/jni/ruby/ext/tk/sample/tkline.rb
new file mode 100644
index 0000000..3124c2f
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkline.rb
@@ -0,0 +1,47 @@
+
+require "tkclass"
+
+$tkline_init = FALSE
+def start_random
+ return if $tkline_init
+ $tkline_init = TRUE
+ if defined? Thread
+ Thread.start do
+ loop do
+ sleep 2
+ Line.new($c, rand(400), rand(200), rand(400), rand(200))
+ end
+ end
+ end
+end
+
+Label.new('text'=>'Please press or drag button-1').pack
+
+$c = Canvas.new
+$c.pack
+$start_x = start_y = 0
+
+def do_press(x, y)
+ $start_x = x
+ $start_y = y
+ $current_line = Line.new($c, x, y, x, y)
+ start_random
+end
+def do_motion(x, y)
+ if $current_line
+ $current_line.coords $start_x, $start_y, x, y
+ end
+end
+
+def do_release(x, y)
+ if $current_line
+ $current_line.coords $start_x, $start_y, x, y
+ $current_line.fill 'black'
+ $current_line = nil
+ end
+end
+
+$c.bind("1", proc{|e| do_press e.x, e.y})
+$c.bind("B1-Motion", proc{|x, y| do_motion x, y}, "%x %y")
+$c.bind("ButtonRelease-1", proc{|x, y| do_release x, y}, "%x %y")
+Tk.mainloop
diff --git a/jni/ruby/ext/tk/sample/tkmenubutton.rb b/jni/ruby/ext/tk/sample/tkmenubutton.rb
new file mode 100644
index 0000000..8ae1359
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkmenubutton.rb
@@ -0,0 +1,135 @@
+#!/usr/bin/env ruby
+#
+# menubutton sample : based on sample menubuttons on the Tcl/Tk demo script
+#
+require 'tk'
+
+TkLabel.new(:text=>'Sample of TkMenubutton').pack(:side=>:top)
+
+TkFrame.new{|f|
+ pack(:side=>:top)
+
+
+ TkMenubutton.new(:parent=>f, :text=>'Right', :underline=>0,
+ :direction=>:right, :relief=>:raised){|mb|
+ menu TkMenu.new(:parent=>mb, :tearoff=>0){
+ add(:command, :label=>'Right menu: first item',
+ :command=>proc{print 'You have selected the first item' +
+ " from the Right menu.\n"})
+ add(:command, :label=>'Right menu: second item',
+ :command=>proc{print 'You have selected the second item' +
+ " from the Right menu.\n"})
+ }
+ pack(:side=>:left, :padx=>25, :pady=>25)
+ }
+
+ TkMenubutton.new(:parent=>f, :text=>'Below', :underline=>0,
+ :direction=>:below, :relief=>:raised){|mb|
+ menu(TkMenu.new(:parent=>mb, :tearoff=>0){
+ add(:command, :label=>'Below menu: first item',
+ :command=>proc{print 'You have selected the first item' +
+ " from the Below menu.\n"})
+ add(:command, :label=>'Below menu: second item',
+ :command=>proc{print 'You have selected the second item' +
+ " from the Below menu.\n"})
+ })
+ pack(:side=>:left, :padx=>25, :pady=>25)
+ }
+
+ TkMenubutton.new(:parent=>f, :text=>'Above', :underline=>0,
+ :direction=>:above, :relief=>:raised){|mb|
+ menu TkMenu.new(:parent=>mb, :tearoff=>0){
+ add(:command, :label=>'Above menu: first item',
+ :command=>proc{print 'You have selected the first item' +
+ " from the Above menu.\n"})
+ add(:command, :label=>'Above menu: second item',
+ :command=>proc{print 'You have selected the second item' +
+ " from the Above menu.\n"})
+ }
+ pack(:side=>:left, :padx=>25, :pady=>25)
+ }
+
+ TkMenubutton.new(:parent=>f, :text=>'Left', :underline=>0,
+ :direction=>:left, :relief=>:raised){|mb|
+ menu(TkMenu.new(:parent=>mb, :tearoff=>0){
+ add(:command, :label=>'Left menu: first item',
+ :command=>proc{print 'You have selected the first item' +
+ " from the Left menu.\n"})
+ add(:command, :label=>'Left menu: second item',
+ :command=>proc{print 'You have selected the second item' +
+ " from the Left menu.\n"})
+ })
+ pack(:side=>:left, :padx=>25, :pady=>25)
+ }
+}
+
+############################
+TkFrame.new(:borderwidth=>2, :relief=>:sunken,
+ :height=>5).pack(:side=>:top, :fill=>:x, :padx=>20)
+############################
+
+TkLabel.new(:text=>'Sample of TkOptionMenu').pack(:side=>:top)
+
+colors = %w(Black red4 DarkGreen NavyBlue gray75 Red Green Blue gray50
+ Yellow Cyan Magenta White Brown DarkSeaGreen DarkViolet)
+
+TkFrame.new{|f|
+ pack(:side=>:top)
+
+ b1 = TkOptionMenubutton .
+ new(:parent=>f, :values=>%w(one two three)) .
+ pack(:side=>:left, :padx=>25, :pady=>25)
+
+ b2 = TkOptionMenubutton.new(:parent=>f, :values=>colors) {|optMB|
+ colors.each{|color|
+ no_sel = TkPhotoImage.new(:height=>16, :width=>16){
+ put 'gray50', *[ 0, 0, 16, 1]
+ put 'gray50', *[ 0, 1, 1, 16]
+ put 'gray75', *[ 0, 15, 16, 16]
+ put 'gray75', *[15, 1, 16, 16]
+ put color, *[ 1, 1, 15, 15]
+ }
+ sel = TkPhotoImage.new(:height=>16, :width=>16){
+ put 'Black', *[ 0, 0, 16, 2]
+ put 'Black', *[ 0, 2, 2, 16]
+ put 'Black', *[ 2, 14, 16, 16]
+ put 'Black', *[14, 2, 16, 14]
+ put color, *[ 2, 2, 14, 14]
+ }
+ optMB.entryconfigure(color, :hidemargin=>1,
+ :image=>no_sel, :selectimage=>sel)
+ }
+ optMB.menuconfigure(:tearoff, 1)
+ %w(Black gray75 gray50 White).each{|color|
+ optMB.entryconfigure(color, :columnbreak=>true)
+ }
+ pack(:side=>:left, :padx=>25, :pady=>25)
+ }
+
+ TkButton.new(:parent=>f){
+ text 'show values'
+ command proc{p [b1.value, b2.value]}
+ pack(:side=>:left, :padx=>25, :pady=>5, :anchor=>:s)
+ }
+}
+
+############################
+TkFrame.new(:borderwidth=>2, :relief=>:sunken,
+ :height=>5).pack(:side=>:top, :fill=>:x, :padx=>20)
+############################
+
+root = TkRoot.new(:title=>'menubutton samples')
+
+TkButton.new(root, :text=>'exit', :command=>proc{exit}){
+ pack(:side=>:top, :padx=>25, :pady=>5, :anchor=>:e)
+}
+
+# VirtualEvent <<MenuSelect>> on Tcl/Tk ==> '<MenuSelect>' on Ruby/Tk
+# ( remove the most external <, > for Ruby/Tk notation )
+TkMenu.bind('<MenuSelect>', proc{|widget|
+ p widget.entrycget('active', :label)
+ }, '%W')
+
+############################
+
+Tk.mainloop
diff --git a/jni/ruby/ext/tk/sample/tkmsgcat-load_rb.rb b/jni/ruby/ext/tk/sample/tkmsgcat-load_rb.rb
new file mode 100644
index 0000000..98a91fa
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkmsgcat-load_rb.rb
@@ -0,0 +1,102 @@
+#!/usr/bin/env ruby
+
+require 'tk'
+
+demo_dir = File.dirname($0)
+msgcat_dir = [demo_dir, 'msgs_rb'].join(File::Separator)
+top_win = nil
+#msgcat = TkMsgCatalog.new('::tk')
+msgcat = TkMsgCatalog.new('::tkmsgcat_demo')
+default_locale = msgcat.locale
+#msgcat.load_rb(msgcat_dir)
+msgcat.load(msgcat_dir)
+
+col_proc = TkComm.install_bind(proc{|w, color, frame, label|
+ TkComm.window(frame).background(color)
+ Tk.update
+ TkComm.window(label).text(
+ msgcat["%1$s:: %2$s", 'Color',
+ color.capitalize])
+ w.flash; w.flash
+ Tk.callback_break;
+ }, "%W")
+
+del_proc = TkComm.install_cmd(proc{top_win.destroy; top_win = nil})
+
+err_proc = TkComm.install_cmd(proc{fail(RuntimeError,
+ msgcat['Application Error'])})
+
+show_sample = proc{|loc|
+ top_win = TkToplevel.new(:title=>loc)
+
+ msgcat.locale = loc
+ #msgcat.load_rb(msgcat_dir)
+ msgcat.load(msgcat_dir)
+
+ TkLabel.new(top_win){
+ text "preferences:: #{msgcat.preferences.join(' ')}"
+ pack(:pady=>10, :padx=>10)
+ }
+
+ lbl = TkLabel.new(top_win, :text=>msgcat["%1$s:: %2$s",
+ 'Color', '']).pack(:anchor=>'w')
+
+ bg = TkFrame.new(top_win).pack(:ipadx=>20, :ipady=>10,
+ :expand=>true, :fill=>:both)
+
+ TkFrame.new(bg){|f|
+ ['blue', 'green', 'red'].each{|col|
+ TkButton.new(f, :text=>msgcat[col]){
+ bind('ButtonRelease-1', col_proc, "#{col} #{bg.path} #{lbl.path}")
+ }.pack(:fill=>:x)
+ }
+ }.pack(:anchor=>'center', :pady=>15)
+
+ TkFrame.new(top_win){|f|
+ TkButton.new(f, :text=>msgcat['Delete'],
+ :command=>del_proc).pack(:side=>:right, :padx=>5)
+ TkButton.new(f, :text=>msgcat['Error'],
+ :command=>err_proc).pack(:side=>:left, :padx=>5)
+ }.pack(:side=>:bottom, :fill=>:x)
+
+ top_win
+}
+
+
+# listbox for locale list
+TkLabel.new(:text=>"Please click a locale.").pack(:padx=>5, :pady=>3)
+
+TkFrame.new{|f|
+ TkButton.new(f, :text=>msgcat['Exit'],
+ :command=>proc{exit}).pack(:side=>:right, :padx=>5)
+}.pack(:side=>:bottom, :fill=>:x)
+
+f = TkFrame.new.pack(:side=>:top, :fill=>:both, :expand=>true)
+lbox = TkListbox.new(f).pack(:side=>:left, :fill=>:both, :expand=>true)
+lbox.yscrollbar(TkScrollbar.new(f, :width=>12).pack(:side=>:right, :fill=>:y))
+
+lbox.bind('ButtonRelease-1'){|ev|
+ idx = lbox.index("@#{ev.x},#{ev.y}")
+ if idx == 0
+ loc = default_locale
+ else
+ loc = lbox.get(idx)
+ end
+ if top_win != nil && top_win.exist?
+ top_win.destroy
+ end
+ top_win = show_sample.call(loc)
+}
+
+lbox.insert('end', 'default')
+
+Dir.entries(msgcat_dir).sort.each{|f|
+ if f =~ /^(.*).msg$/
+ lbox.insert('end', $1)
+ end
+}
+
+top_win = show_sample.call(default_locale)
+
+# start eventloop
+Tk.mainloop
diff --git a/jni/ruby/ext/tk/sample/tkmsgcat-load_rb2.rb b/jni/ruby/ext/tk/sample/tkmsgcat-load_rb2.rb
new file mode 100644
index 0000000..05512a3
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkmsgcat-load_rb2.rb
@@ -0,0 +1,102 @@
+#!/usr/bin/env ruby
+
+require 'tk'
+
+demo_dir = File.dirname($0)
+msgcat_dir = [demo_dir, 'msgs_rb2'].join(File::Separator)
+top_win = nil
+#msgcat = TkMsgCatalog.new('::tk')
+msgcat = TkMsgCatalog.new('::tkmsgcat_demo')
+default_locale = msgcat.locale
+#msgcat.load_rb(msgcat_dir)
+msgcat.load(msgcat_dir)
+
+col_proc = TkComm.install_bind(proc{|w, color, frame, label|
+ TkComm.window(frame).background(color)
+ Tk.update
+ TkComm.window(label).text(
+ msgcat["%1$s:: %2$s", 'Color',
+ color.capitalize])
+ w.flash; w.flash
+ Tk.callback_break;
+ }, "%W")
+
+del_proc = TkComm.install_cmd(proc{top_win.destroy; top_win = nil})
+
+err_proc = TkComm.install_cmd(proc{fail(RuntimeError,
+ msgcat['Application Error'])})
+
+show_sample = proc{|loc|
+ top_win = TkToplevel.new(:title=>loc)
+
+ msgcat.locale = loc
+ #msgcat.load_rb(msgcat_dir)
+ msgcat.load(msgcat_dir)
+
+ TkLabel.new(top_win){
+ text "preferences:: #{msgcat.preferences.join(' ')}"
+ pack(:pady=>10, :padx=>10)
+ }
+
+ lbl = TkLabel.new(top_win, :text=>msgcat["%1$s:: %2$s",
+ 'Color', '']).pack(:anchor=>'w')
+
+ bg = TkFrame.new(top_win).pack(:ipadx=>20, :ipady=>10,
+ :expand=>true, :fill=>:both)
+
+ TkFrame.new(bg){|f|
+ ['blue', 'green', 'red'].each{|col|
+ TkButton.new(f, :text=>msgcat[col]){
+ bind('ButtonRelease-1', col_proc, "#{col} #{bg.path} #{lbl.path}")
+ }.pack(:fill=>:x)
+ }
+ }.pack(:anchor=>'center', :pady=>15)
+
+ TkFrame.new(top_win){|f|
+ TkButton.new(f, :text=>msgcat['Delete'],
+ :command=>del_proc).pack(:side=>:right, :padx=>5)
+ TkButton.new(f, :text=>msgcat['Error'],
+ :command=>err_proc).pack(:side=>:left, :padx=>5)
+ }.pack(:side=>:bottom, :fill=>:x)
+
+ top_win
+}
+
+
+# listbox for locale list
+TkLabel.new(:text=>"Please click a locale.").pack(:padx=>5, :pady=>3)
+
+TkFrame.new{|f|
+ TkButton.new(f, :text=>msgcat['Exit'],
+ :command=>proc{exit}).pack(:side=>:right, :padx=>5)
+}.pack(:side=>:bottom, :fill=>:x)
+
+f = TkFrame.new.pack(:side=>:top, :fill=>:both, :expand=>true)
+lbox = TkListbox.new(f).pack(:side=>:left, :fill=>:both, :expand=>true)
+lbox.yscrollbar(TkScrollbar.new(f, :width=>12).pack(:side=>:right, :fill=>:y))
+
+lbox.bind('ButtonRelease-1'){|ev|
+ idx = lbox.index("@#{ev.x},#{ev.y}")
+ if idx == 0
+ loc = default_locale
+ else
+ loc = lbox.get(idx)
+ end
+ if top_win != nil && top_win.exist?
+ top_win.destroy
+ end
+ top_win = show_sample.call(loc)
+}
+
+lbox.insert('end', 'default')
+
+Dir.entries(msgcat_dir).sort.each{|f|
+ if f =~ /^(.*).msg$/
+ lbox.insert('end', $1)
+ end
+}
+
+top_win = show_sample.call(default_locale)
+
+# start eventloop
+Tk.mainloop
diff --git a/jni/ruby/ext/tk/sample/tkmsgcat-load_tk.rb b/jni/ruby/ext/tk/sample/tkmsgcat-load_tk.rb
new file mode 100644
index 0000000..703f471
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkmsgcat-load_tk.rb
@@ -0,0 +1,118 @@
+#!/usr/bin/env ruby
+
+require 'tk'
+
+demo_dir = File.dirname($0)
+msgcat_dir = [demo_dir, 'msgs_tk'].join(File::Separator)
+top_win = nil
+#msgcat = TkMsgCatalog.new('::tk')
+msgcat = TkMsgCatalog.new('::tkmsgcat_demo')
+default_locale = msgcat.locale
+msgcat.load_tk(msgcat_dir)
+
+col_proc = TkComm.install_bind(proc{|w, color, frame, label|
+ TkComm.window(frame).background(color)
+ Tk.update
+ TkComm.window(label).text(
+ msgcat.mc("%1$s:: %2$s", 'Color',
+ color.capitalize))
+ w.flash; w.flash
+ Tk.callback_break;
+ }, "%W")
+
+del_proc = TkComm.install_cmd(proc{top_win.destroy; top_win = nil})
+
+err_proc = TkComm.install_cmd(proc{fail(RuntimeError,
+ msgcat.mc('Application Error'))})
+
+show_sample = proc{|loc|
+ top_win = TkToplevel.new(:title=>loc)
+
+ msgcat.locale = loc
+ msgcat.load_tk(msgcat_dir)
+
+ TkLabel.new(top_win){
+ text "preferences:: #{msgcat.preferences.join(' ')}"
+ pack(:pady=>10, :padx=>10)
+ }
+
+ lbl = TkLabel.new(top_win, :text=>msgcat.mc("%1$s:: %2$s",
+ 'Color', '')).pack(:anchor=>'w')
+
+ bg = TkFrame.new(top_win).pack(:ipadx=>20, :ipady=>10,
+ :expand=>true, :fill=>:both)
+
+ TkFrame.new(bg){|f|
+ ['blue', 'green', 'red'].each{|col|
+ TkButton.new(f, :text=>msgcat.mc(col)){
+ bind('ButtonRelease-1', col_proc, "#{col} #{bg.path} #{lbl.path}")
+ }.pack(:fill=>:x)
+=begin
+ TkButton.new(f, :text=>msgcat.mc(col),
+ :command=>proc{
+ bg.background col
+ lbl.text msgcat.mc("%1$s:: %2$s", 'Color', col.capitalize)
+ }).pack(:fill=>:x)
+=end
+ }
+ }.pack(:anchor=>'center', :pady=>15)
+
+ TkFrame.new(top_win){|f|
+ TkButton.new(f, :text=>msgcat.mc('Delete'),
+ :command=>del_proc).pack(:side=>:right, :padx=>5)
+ TkButton.new(f, :text=>msgcat.mc('Error'),
+ :command=>err_proc).pack(:side=>:left, :padx=>5)
+=begin
+ TkButton.new(f, :text=>msgcat.mc('Delete'),
+ :command=>proc{
+ top_win.destroy
+ top_win = nil
+ }).pack(:side=>:right, :padx=>5)
+ TkButton.new(f, :text=>msgcat.mc('Error'),
+ :command=>proc{
+ fail RuntimeError, msgcat.mc('Application Error')
+ }).pack(:side=>:left, :padx=>5)
+=end
+ }.pack(:side=>:bottom, :fill=>:x)
+
+ top_win
+}
+
+
+# listbox for locale list
+TkLabel.new(:text=>"Please click a locale.").pack(:padx=>5, :pady=>3)
+
+TkFrame.new{|f|
+ TkButton.new(f, :text=>msgcat.mc('Exit'),
+ :command=>proc{exit}).pack(:side=>:right, :padx=>5)
+}.pack(:side=>:bottom, :fill=>:x)
+
+f = TkFrame.new.pack(:side=>:top, :fill=>:both, :expand=>true)
+lbox = TkListbox.new(f).pack(:side=>:left, :fill=>:both, :expand=>true)
+lbox.yscrollbar(TkScrollbar.new(f, :width=>12).pack(:side=>:right, :fill=>:y))
+
+lbox.bind('ButtonRelease-1'){|ev|
+ idx = lbox.index("@#{ev.x},#{ev.y}")
+ if idx == 0
+ loc = default_locale
+ else
+ loc = lbox.get(idx)
+ end
+ if top_win != nil && top_win.exist?
+ top_win.destroy
+ end
+ top_win = show_sample.call(loc)
+}
+
+lbox.insert('end', 'default')
+
+Dir.entries(msgcat_dir).sort.each{|f|
+ if f =~ /^(.*).msg$/
+ lbox.insert('end', $1)
+ end
+}
+
+top_win = show_sample.call(default_locale)
+
+# start eventloop
+Tk.mainloop
diff --git a/jni/ruby/ext/tk/sample/tkmulticolumnlist.rb b/jni/ruby/ext/tk/sample/tkmulticolumnlist.rb
new file mode 100644
index 0000000..a1b3a1a
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkmulticolumnlist.rb
@@ -0,0 +1,743 @@
+#
+# tkmulticolumnlist.rb : multiple column list widget on scrollable frame
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+require 'tk'
+
+class TkMultiColumnList < TkText
+ include TkComposite
+
+ # lbox_height : height of listboxes (pixel)
+ # title_info : array [ [<title_string>,<init_width>], ... ]
+ # keys : hash {<option>=><value>, ... }
+ def initialize_composite(lbox_height, title_info, keys={})
+ # argument check
+ if (! title_info.kind_of? Array) or (title_info.size < 2)
+ raise
+ end
+
+ # mode
+ @keep_minsize = true
+ @show_each_hscr = true
+ @show_win_hscr = true
+
+ # init arrays
+ @base_list = []
+ @rel_list = []
+ @title_list = []
+ @title_cmd = []
+ @lbox_list = []
+ @hscr_list = []
+
+ # decide total width
+ @lbox_total = title_info.size
+ @width_total = 0
+ title_info.each{|title, width, cmd|
+ @width_total += width.to_f
+ @title_cmd << cmd
+ }
+
+ # rel-table of label=>index
+ @name_index = {}
+
+ # size definition
+ @window_width = @width_total
+ @sash = 5
+ @scrbar_width = 15
+ @scrbar_border = 3
+ @lbox_border = 1
+ @title_border = 3
+ @h_l_thick = 0
+
+ # init status
+ @mode = :title
+ @command = nil
+
+ # virtical scrollbar
+ @v_scroll = TkYScrollbar.new(@frame, 'highlightthickness'=>@h_l_thick,
+ 'borderwidth'=>@scrbar_border,
+ 'width'=>@scrbar_width)
+
+ # horizontal scrollbar
+ @h_scroll = TkXScrollbar.new(@frame, 'highlightthickness'=>@h_l_thick,
+ 'borderwidth'=>@scrbar_border,
+ 'width'=>@scrbar_width)
+
+ # create base flames
+ @c_title = TkCanvas.new(@frame, 'highlightthickness'=>@h_l_thick,
+ 'width'=>@window_width)
+ @f_title = TkFrame.new(@c_title, 'width'=>@width_total)
+ @w_title = TkcWindow.new(@c_title, 0, 0,
+ 'window'=>@f_title, 'anchor'=>'nw')
+
+ @c_lbox = TkCanvas.new(@frame, 'highlightthickness'=>@h_l_thick,
+ 'width'=>@window_width)
+ @f_lbox = TkFrame.new(@c_lbox, 'width'=>@width_total)
+ @w_lbox = TkcWindow.new(@c_lbox, 0, 0, 'window'=>@f_lbox, 'anchor'=>'nw')
+
+ @c_hscr = TkCanvas.new(@frame, 'highlightthickness'=>@h_l_thick,
+ 'width'=>@window_width)
+ @f_hscr = TkFrame.new(@c_hscr, 'width'=>@width_total)
+ @w_hscr = TkcWindow.new(@c_hscr, 0, 0, 'window'=>@f_hscr, 'anchor'=>'nw')
+
+ # create each listbox
+ sum = 0.0
+ @rel_list << sum/@width_total
+ title_info.each_with_index{|(label, width), idx|
+ # set relation between label and index
+ if @name_index.include?(label)
+ @name_index[label] << idx
+ else
+ @name_index[label] = [idx]
+ end
+
+ # calculate relative positioning
+ sum += width
+ @rel_list << sum/@width_total
+
+ # title field
+ f = TkFrame.new(@f_title, 'width'=>width)
+ base = [f]
+
+ title = TkLabel.new(f, 'text'=>label, 'borderwidth'=>@title_border,
+ 'relief'=>'raised', 'highlightthickness'=>@h_l_thick)
+ title_binding(title, idx)
+ title.pack('fill'=>'x')
+
+ @title_list << title
+
+ f.place('relx'=>@rel_list[idx], 'y'=>0, 'anchor'=>'nw', 'width'=>1,
+ 'relheight'=>1.0,
+ 'relwidth'=>@rel_list[idx+1] - @rel_list[idx])
+
+ # listbox field
+ f = TkFrame.new(@f_lbox, 'width'=>width)
+ base << f
+ @lbox_list << TkText.new(f, 'highlightthickness'=>@h_l_thick,
+ 'borderwidth'=>@lbox_border,
+ 'takefocus'=>false,
+ 'wrap'=>'none') {
+
+ bindtags(bindtags - [TkText])
+
+ @seltag = TkTextTag.new(self, 'background'=>'#b3b3b3',
+ 'borderwidth'=>1, 'relief'=>'raised')
+ def self.nearest(y)
+ self.index("@1,#{y}").split('.')[0].to_i
+ end
+
+ def self.select_clear(first, last=nil)
+ first = "#{first}.0" if first.kind_of?(Integer)
+ first = self.index(first.to_s + ' linestart')
+ last = first unless last
+ last = "#{last}.0" if first.kind_of?(Integer)
+ last = self.index(last.to_s + ' + 1 lines linestart')
+ @seltag.remove(first, last)
+ end
+
+ def self.select_set(first, last=nil)
+ first = "#{first}.0" if first.kind_of?(Integer)
+ first = self.index(first.to_s + ' linestart')
+ last = first unless last
+ last = "#{last}.0" if first.kind_of?(Integer)
+ last = self.index(last.to_s + ' + 1 lines linestart')
+ @seltag.add(first, last)
+ end
+
+ def self.select_index
+ self.index(@seltag.first).split('.')[0].to_i
+ end
+
+ pack('fill'=>'both', 'expand'=>true)
+ }
+
+ f.place('relx'=>@rel_list[idx], 'y'=>0, 'anchor'=>'nw', 'width'=>1,
+ 'relwidth'=>@rel_list[idx+1] - @rel_list[idx], 'relheight'=>1.0)
+
+ # scrollbar field
+ f = TkFrame.new(@f_hscr, 'width'=>width)
+ base << f
+ @hscr_list << TkXScrollbar.new(f, 'width'=>@scrbar_width,
+ 'borderwidth'=>@scrbar_border,
+ 'highlightthickness'=>@h_l_thick
+ ).pack('fill'=>'x', 'anchor'=>'w')
+ f.place('relx'=>@rel_list[idx], 'y'=>0, 'anchor'=>'nw', 'width'=>1,
+ 'relwidth'=>@rel_list[idx+1] - @rel_list[idx])
+
+ @lbox_list[idx].xscrollbar(@hscr_list[idx])
+
+ # add new base
+ @base_list << base
+ }
+
+ # pad
+ @f_title_pad = TkFrame.new(@frame, 'relief'=>'raised',
+ 'borderwidth'=>@title_border,
+ 'highlightthickness'=>@h_l_thick)
+
+ @f_scr_pad = TkFrame.new(@frame, 'relief'=>'sunken',
+ 'borderwidth'=>1,
+ 'highlightthickness'=>@h_l_thick)
+
+ # height check
+ title_height = 0
+ @title_list.each{|w|
+ h = w.winfo_reqheight
+ title_height = h if title_height < h
+ }
+
+ hscr_height = 0
+ @hscr_list.each{|w|
+ h = w.winfo_reqheight
+ hscr_height = h if hscr_height < h
+ }
+
+ @f_title.height title_height
+ @f_lbox.height lbox_height
+ @f_hscr.height hscr_height
+
+ # set control procedure for virtical scroll
+ @v_scroll.assign(*@lbox_list)
+
+ # set control procedure for horizoncal scroll
+ @h_scroll.assign(@c_title, @c_lbox, @c_hscr)
+
+ # binding for listboxes
+ @lbox_list.each_with_index{|l, idx|
+ l.bind('Button-1', proc{|w, y|
+ @frame.focus
+ select_line(w, w.nearest(y))
+ }, '%W %y')
+ l.bind('B1-Motion', proc{|w, y|
+ select_line(w, w.nearest(y))
+ }, '%W %y')
+ l.bind('Double-Button-1', proc{
+ @command.call(get_select) if @command
+ })
+
+ l.bind('Control-Home', proc{|w| select_line(w, 0)}, '%W')
+ l.bind('Control-End', proc{|w| select_line(w, 'end')}, '%W')
+
+ l.bind('Button-2', proc{|x, y|
+ @lbox_mark_x = x
+ @lbox_list.each{|lbox| lbox.scan_mark(x, y)}
+ }, '%x %y')
+ l.bind('B2-Motion', proc{|x, y|
+ @lbox_list.each{|lbox| lbox.scan_dragto(@lbox_mark_x, y)}
+ l.scan_dragto(x, y)
+ }, '%x %y')
+ }
+
+ bbox = @w_title.bbox
+ @c_title.height(bbox[3])
+ @c_title.scrollregion(bbox)
+
+ bbox = @w_lbox.bbox
+ @c_lbox.height(bbox[3])
+ @c_lbox.scrollregion(bbox)
+
+ if @show_each_hscr
+ bbox = @w_hscr.bbox
+ @c_hscr.height(bbox[3])
+ @c_hscr.scrollregion(bbox)
+ end
+
+ # binding
+ @frame.takefocus(true)
+ @frame.bind('Key-Up', proc{select_shift(@lbox_list[0], -1)})
+ @frame.bind('Key-Down', proc{select_shift(@lbox_list[0], 1)})
+ @frame.bind('Return', proc{@command.call(get_select) if @command})
+
+ # alignment
+ TkGrid.rowconfigure(@frame, 0, 'weight'=>0)
+ TkGrid.rowconfigure(@frame, 1, 'weight'=>1)
+ TkGrid.rowconfigure(@frame, 2, 'weight'=>0)
+ TkGrid.rowconfigure(@frame, 3, 'weight'=>0)
+ TkGrid.columnconfigure(@frame, 0, 'weight'=>1)
+ TkGrid.columnconfigure(@frame, 1, 'weight'=>0)
+ TkGrid.columnconfigure(@frame, 2, 'weight'=>0)
+ @v_scroll.grid('row'=>1, 'column'=>2, 'sticky'=>'ns')
+ @c_title.grid('row'=>0, 'column'=>0, 'sticky'=>'news')
+ @f_title_pad.grid('row'=>0, 'column'=>2, 'sticky'=>'news')
+ @c_lbox.grid('row'=>1, 'column'=>0, 'sticky'=>'news')
+ @c_hscr.grid('row'=>2, 'column'=>0, 'sticky'=>'ew') if @show_each_hscr
+ @h_scroll.grid('row'=>3, 'column'=>0, 'sticky'=>'ew') if @show_win_hscr
+ @f_scr_pad.grid('row'=>2, 'rowspan'=>2, 'column'=>2, 'sticky'=>'news')
+
+ # binding for 'Configure' event
+ @c_lbox.bind('Configure',
+ proc{|height, width| reconstruct(height, width)},
+ '%h %w')
+
+ # set default receiver of method calls
+ @path = @frame.path
+
+ # configure options
+ keys = {} unless keys
+ keys = _symbolkey2str(keys)
+
+ # command
+ cmd = keys.delete('command')
+ command(cmd) if cmd
+
+ # 'scrollbarwidth' option == 'width' option of scrollbars
+ width = keys.delete('scrollbarwidth')
+ scrollbarwidth(width) if width
+
+ # options for listbox titles
+ title_font = keys.delete('titlefont')
+ titlefont(title_font) if title_font
+
+ title_fg = keys.delete('titleforeground')
+ titleforeground(title_fg) if title_fg
+
+ title_bg = keys.delete('titlebackground')
+ titlebackground(title_bg) if title_bg
+
+ # set receivers for configure methods
+ delegate('DEFAULT', *@lbox_list)
+ delegate('activebackground', @v_scroll, @h_scroll, *@hscr_list)
+ delegate('troughcolor', @v_scroll, @h_scroll, *@hscr_list)
+ delegate('repeatdelay', @v_scroll, @h_scroll, *@hscr_list)
+ delegate('repeatinterval', @v_scroll, @h_scroll, *@hscr_list)
+ delegate('borderwidth', @frame)
+ delegate('width', @c_lbox, @c_title, @c_hscr)
+ delegate('relief', @frame)
+
+ # configure
+ configure(keys) if keys.size > 0
+ end
+ private :initialize_composite
+
+ # keep_minsize?
+ def keep_minsize?
+ @keep_minsize
+ end
+ def keep_minsize(bool)
+ @keep_minsize = bool
+ end
+
+ # each hscr
+ def show_each_hscr
+ @show_each_hscr = true
+ @c_hscr.grid('row'=>2, 'column'=>0, 'sticky'=>'ew')
+ end
+ def hide_each_hscr
+ @show_each_hscr = false
+ @c_hscr.ungrid
+ end
+
+ # window hscroll
+ def show_win_hscr
+ @show_win_hscr = true
+ @h_scroll.grid('row'=>3, 'column'=>0, 'sticky'=>'ew')
+ end
+ def hide_win_hscr
+ @show_each_hscr = false
+ @h_scroll.ungrid
+ end
+
+ # set command
+ def command(cmd)
+ @command = cmd
+ self
+ end
+
+ # set scrollbar width
+ def scrollbarwidth(width)
+ @scrbar_width = width
+ @v_scroll['width'] = @scrbar_width
+ @h_scroll['width'] = @scrbar_width
+ @hscr_list.each{|hscr| hscr['width'] = @scrbar_width}
+ self
+ end
+
+ # set scrollbar border
+ def scrollbarborder(width)
+ @scrbar_border = width
+ @v_scroll['border'] = @scrbar_border
+ @h_scroll['border'] = @scrbar_border
+ @hscr_list.each{|hscr| hscr['border'] = @scrbar_border}
+ self
+ end
+
+ # set listbox borders
+ def listboxborder(width)
+ @lbox_border = width
+ @lbox_list.each{|w| w['border'] = @lbox_border}
+ self
+ end
+
+ # set listbox relief
+ def listboxrelief(relief)
+ @lbox_list.each{|w| w['relief'] = relief}
+ self
+ end
+
+ # set title borders
+ def titleborder(width)
+ @title_border = width
+ @f_title_pad['border'] = @title_border
+ @title_list.each{|label| label['border'] = @title_border}
+ self
+ end
+
+ # set title font
+ def titlefont(font)
+ @title_list.each{|label| label['font'] = font}
+ title_height = 0
+ @title_list.each{|w|
+ h = w.winfo_reqheight
+ title_height = h if title_height < h
+ }
+ @f_title.height title_height
+ bbox = @w_title.bbox
+ @c_title.height(bbox[3])
+ @c_title.scrollregion(bbox)
+ self
+ end
+
+ # set title foreground color
+ def titleforeground(fg)
+ @title_list.each{|label| label['foreground'] = fg}
+ self
+ end
+
+ # set title background color
+ def titlebackground(bg)
+ @f_title_pad['background'] = bg
+ @title_list.each{|label| label['background'] = bg}
+ self
+ end
+
+ # set title cmds
+ def titlecommand(idx, cmd=Proc.new)
+ @title_cmd[idx] = cmd
+ end
+
+ # call title cmds
+ def titleinvoke(idx)
+ @title_cmd[idx].call if @title_cmd[idx]
+ end
+
+ # get label widgets of listbox titles
+ def titlelabels(*indices)
+ @title_list[*indices]
+ end
+
+ # get listbox widgets
+ def columns(*indices)
+ @lbox_list[*indices]
+ end
+
+ def delete(*idx)
+ idx = idx.collect{|i|
+ if i.kind_of?(Integer)
+ "#{i}.0"
+ else
+ i.to_s
+ end
+ }
+ @lbox_list.collect{|lbox| lbox.delete(*idx)}
+ end
+
+ def get(idx_s, idx_e=nil)
+ unless idx_e
+ if idx_s.kind_of?(Integer)
+ idx_s = "#{idx_s}.0"
+ idx_e = "#{idx_s} lineend"
+ else
+ idx_s = idx_s.to_s
+ idx_e = "#{idx_s} lineend"
+ end
+ @lbox_list.collect{|lbox|
+ lbox.get(idx_s, idx_e)
+ }
+ else
+ if idx_s.kind_of?(Integer)
+ idx_s = "#{idx_s}.0"
+ else
+ idx_s = idx_s.to_s
+ end
+ if idx_e.kind_of?(Integer)
+ idx_e = "#{idx_e}.end"
+ else
+ idx_e = "#{idx_e} lineend"
+ end
+ list = @lbox_list.collect{|lbox| lbox.get(idx_s, idx_e).split(/\n/)}
+ result = []
+ list[0].each_with_index{|line, index|
+ result << list.collect{|lines| lines[index]}
+ }
+ result
+ end
+ end
+
+ def get_select
+ get(@lbox_list[0].select_index)
+ end
+
+ def _line_array_to_hash(line)
+ result = {}
+ @name_index.each_pair{|label, indices|
+ if indices.size == 1
+ result[label] = line[indices[0]]
+ else
+ result[label] = indices.collect{|index| line[index]}
+ end
+ }
+ result
+ end
+ private :_line_array_to_hash
+
+ def get_by_hash(*idx)
+ get_result = get(*idx)
+ if idx.size == 1
+ _line_array_to_hash(get_result)
+ else
+ get_result.collect{|line| _line_array_to_hash(line)}
+ end
+ end
+
+ def insert(idx, *lines)
+ lbox_ins = []
+ (0..@lbox_list.size).each{lbox_ins << []}
+
+ if idx.kind_of?(Integer)
+ idx = "#{idx}.0"
+ else
+ idx = idx.to_s
+ end
+
+ if @lbox_list[0].index('1.0 + 1 char') == @lbox_list[0].index('end')
+ cr = ""
+ else
+ cr = "\n"
+ end
+
+ lines.each{|line|
+ if line.kind_of? Hash
+ array = []
+ @name_index.each_pair{|label, indices|
+ if indices.size == 1
+ array[indices[0]] = line[label]
+ else
+ if line[label].kind_of? Array
+ indices.each_with_index{|index, num|
+ array[index] = line[label][num]
+ }
+ else
+ array[indices[0]] = line[label]
+ end
+ end
+ }
+ line = array
+ end
+
+ @name_index.each_pair{|label, indices|
+ if indices.size == 1
+ lbox_ins[indices[0]] << line[indices[0]]
+ else
+ indices.each{|index| lbox_ins[index] << line[index]}
+ end
+ }
+ }
+
+ @lbox_list.each_with_index{|lbox, index|
+ lbox.insert(idx, cr + lbox_ins[index].join("\n")) if lbox_ins[index]
+ }
+ end
+
+ def select_clear(first, last=None)
+ @lbox_list.each{|lbox| lbox.sel_clear(first, last=None)}
+ end
+
+ def select_set(first, last=None)
+ @lbox_list.each{|lbox| lbox.sel_set(first, last=None)}
+ end
+
+ ###########################################
+ private
+
+ def reconstruct(height, width)
+ if @keep_minsize && width <= @width_total
+ @f_title.width(@width_total)
+ @f_lbox.width(@width_total)
+ @f_hscr.width(@width_total) if @show_each_hscr
+ @window_width = @width_total
+ else
+ @f_title.width(width)
+ @f_lbox.width(width)
+ @f_hscr.width(width) if @show_each_hscr
+ @window_width = width
+ end
+
+ @f_lbox.height(height)
+
+ @c_title.scrollregion(@w_title.bbox)
+ @c_lbox.scrollregion(@w_lbox.bbox)
+ @c_hscr.scrollregion(@w_hscr.bbox) if @show_each_hscr
+
+ (0..(@rel_list.size - 2)).each{|idx|
+ title, lbox, hscr = @base_list[idx]
+ title.place('relwidth'=>@rel_list[idx+1] - @rel_list[idx])
+ lbox.place('relwidth'=>@rel_list[idx+1] - @rel_list[idx],
+ 'relheight'=>1.0)
+ hscr.place('relwidth'=>@rel_list[idx+1] - @rel_list[idx])
+ }
+ end
+
+ def resize(x)
+ idx = @sel_sash
+ return if idx == 0
+
+ # adjustment of relative positioning
+ delta = (x - @x) / @frame_width
+ if delta < @rel_list[idx-1] - @rel_list[idx] + (2*@sash/@frame_width)
+ delta = @rel_list[idx-1] - @rel_list[idx] + (2*@sash/@frame_width)
+ elsif delta > @rel_list[idx+1] - @rel_list[idx] - (2*@sash/@frame_width)
+ delta = @rel_list[idx+1] - @rel_list[idx] - (2*@sash/@frame_width)
+ end
+ @rel_list[idx] += delta
+
+ # adjustment of leftside widget of the sash
+ title, lbox, hscr = @base_list[idx - 1]
+ title.place('relwidth'=>@rel_list[idx] - @rel_list[idx-1])
+ lbox.place('relwidth'=>@rel_list[idx] - @rel_list[idx-1], 'relheight'=>1.0)
+ hscr.place('relwidth'=>@rel_list[idx] - @rel_list[idx-1])
+
+ # adjustment of rightside widget of the sash
+ title, lbox, hscr = @base_list[idx]
+ title.place('relwidth'=>@rel_list[idx+1] - @rel_list[idx],
+ 'relx'=>@rel_list[idx])
+ lbox.place('relwidth'=>@rel_list[idx+1] - @rel_list[idx],
+ 'relx'=>@rel_list[idx], 'relheight'=>1.0)
+ hscr.place('relwidth'=>@rel_list[idx+1] - @rel_list[idx],
+ 'relx'=>@rel_list[idx])
+
+ # update reference position
+ @x = x
+ end
+
+ def motion_cb(w, x, idx)
+ if x <= @sash && idx > 0
+ w.cursor 'sb_h_double_arrow'
+ @mode = :sash
+ @sel_sash = idx
+ elsif x >= w.winfo_width - @sash && idx < @lbox_total - 1
+ w.cursor 'sb_h_double_arrow'
+ @mode = :sash
+ @sel_sash = idx + 1
+ else
+ w.cursor ""
+ @mode = :title
+ @sel_sash = 0
+ end
+ end
+
+ def title_binding(title, index)
+ title.bind('Motion', proc{|w, x, idx| motion_cb(w, x, idx.to_i)},
+ "%W %x #{index}")
+
+ title.bind('Enter', proc{|w, x, idx| motion_cb(w, x, idx.to_i)},
+ "%W %x #{index}")
+
+ title.bind('Leave', proc{|w| w.cursor ""}, "%W")
+
+ title.bind('Button-1',
+ proc{|w, x|
+ if @mode == :sash
+ @x = x
+ @frame_width = TkWinfo.width(@f_title).to_f
+ else
+ title.relief 'sunken'
+ end
+ },
+ '%W %X')
+
+ title.bind('ButtonRelease-1',
+ proc{|w, x, idx|
+ i = idx.to_i
+ if @mode == :title && @title_cmd[i].kind_of?(Proc)
+ @title_cmd[i].call
+ end
+ title.relief 'raised'
+ motion_cb(w,x,i)
+ },
+ "%W %x #{index}")
+
+ title.bind('B1-Motion', proc{|x| resize(x) if @mode == :sash}, "%X")
+ end
+
+ ########################
+ def select_line(w, idx)
+ @lbox_list.each{|l|
+ l.select_clear(1, 'end')
+ l.select_set(idx)
+ }
+ w.select_set(idx)
+ end
+
+ def select_shift(w, dir)
+ head = w.index('@1,1').split('.')[0].to_i
+ tail = w.index("@1,#{w.winfo_height - 1}").split('.')[0].to_i - 1
+ idx = w.select_index + dir
+ last = w.index('end - 1 char').split('.')[0].to_i
+ if idx < 1
+ idx = 1
+ elsif idx > last
+ idx = last
+ end
+ @lbox_list.each{|l|
+ l.select_clear(1, 'end')
+ l.select_set(idx)
+ }
+ if head > idx
+ @lbox_list.each{|l| l.yview('scroll', -1, 'units')}
+ elsif tail < idx
+ @lbox_list.each{|l| l.yview('scroll', 1, 'units')}
+ end
+ end
+ ########################
+end
+
+################################################
+# test
+################################################
+if __FILE__ == $0
+ l = TkMultiColumnList.new(nil, 200,
+ [ ['L1', 200, proc{p 'click L1'}],
+ ['L2', 100],
+ ['L3', 200] ],
+ 'width'=>350,
+ #'titleforeground'=>'yellow',
+ 'titleforeground'=>'white',
+ #'titlebackground'=>'navy',
+ 'titlebackground'=>'blue',
+ 'titlefont'=>'courier'
+ ).pack('fill'=>'both', 'expand'=>true)
+ l.insert('end', [1,2,3])
+ l.insert('end', [4,5,6])
+ l.insert('end', [4,5,6], [4,5,6])
+ l.insert('end', ['aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa',
+ 'bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb',
+ 'cccccccccccccccccccccccccccccccccccccccccccccccccccc'])
+ l.insert('end', [1,2,3])
+ l.insert('end', [4,5,6], [4,5,6])
+ l.insert('end', ['aaaaaaaaaaaaaaa','bbbbbbbbbbbbbb','ccccccccccccccccc'])
+ l.insert('end', [1,2,3])
+ l.insert('end', [4,5,6], [4,5,6])
+ l.insert('end', ['aaaaaaaaaaaaaaa','bbbbbbbbbbbbbb','ccccccccccccccccc'])
+ l.insert('end', [1,2,3])
+ l.insert('end', [4,5,6], [4,5,6])
+ l.insert('end', ['aaaaaaaaaaaaaaa','bbbbbbbbbbbbbb','ccccccccccccccccc'])
+ l.insert('end', [1,2,3])
+ l.insert('end', [4,5,6], [4,5,6])
+ p l.columns(1)
+ p l.columns(1..3)
+ p l.columns(1,2)
+
+ l.command proc{|line_info| p line_info}
+
+ Tk.mainloop
+end
diff --git a/jni/ruby/ext/tk/sample/tkmultilistbox.rb b/jni/ruby/ext/tk/sample/tkmultilistbox.rb
new file mode 100644
index 0000000..7791649
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkmultilistbox.rb
@@ -0,0 +1,654 @@
+#
+# tkmultilistbox.rb : multiple listbox widget
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+require 'tk'
+
+class TkMultiListbox < TkListbox
+ include TkComposite
+
+ # lbox_height : height of listboxes (pixel)
+ # title_info : array [ [<title_string>,<init_width>], ... ]
+ # keys : hash {<option>=><value>, ... }
+ def initialize_composite(lbox_height, title_info, keys={})
+ # argument check
+ if (! title_info.kind_of? Array) or (title_info.size < 2)
+ raise
+ end
+
+ # decide total width
+ @width_total = 0
+ title_info.each{|title, width| @width_total += width.to_f}
+
+ # virtical scrollbar
+ @v_scroll = TkScrollbar.new(@frame, 'orient'=>'vertical')
+
+ # init arrays
+ @base_list = []
+ @rel_list = []
+ @title_list = []
+ @lbox_list = []
+ @hscr_list = []
+
+ # rel-table of label=>index
+ @name_index = {}
+
+ # create base flames
+ @f_title = TkFrame.new(@frame, 'width'=>@width_total)
+ @f_lbox = TkFrame.new(@frame,
+ 'width'=>@width_total, 'height'=>lbox_height)
+ @f_hscr = TkFrame.new(@frame, 'width'=>@width_total,
+ 'height'=>@v_scroll.cget('width') +
+ 2 * @v_scroll.cget('borderwidth'))
+
+ # dummy label to keep the hight of title space
+ TkLabel.new(@f_title, 'text'=>' ').pack
+
+ # create each listbox
+ sum = 0.0
+ @rel_list << sum/@width_total
+ title_info.each_with_index{|(label, width), idx|
+ # set relation between label and index
+ if @name_index.include?(label)
+ @name_index[label] << idx
+ else
+ @name_index[label] = [idx]
+ end
+
+ # calculate relative positioning
+ sum += width
+ @rel_list << sum/@width_total
+
+ # title field
+ f = TkFrame.new(@f_title, 'width'=>width)
+ base = [f]
+ @title_list << TkLabel.new(f, 'text'=>label).pack('fill'=>'x')
+ f.place('relx'=>@rel_list[idx], 'y'=>0, 'anchor'=>'nw', 'width'=>-6,
+ 'relwidth'=>@rel_list[idx+1] - @rel_list[idx])
+
+ # listbox field
+ f = TkFrame.new(@f_lbox, 'width'=>width)
+ base << f
+ @lbox_list << TkListbox.new(f).pack('fill'=>'both', 'expand'=>true)
+ f.place('relx'=>@rel_list[idx], 'y'=>0, 'anchor'=>'nw', 'width'=>-4,
+ 'relwidth'=>@rel_list[idx+1] - @rel_list[idx], 'relheight'=>1.0)
+
+ # scrollbar field
+ f = TkFrame.new(@f_hscr, 'width'=>width)
+ base << f
+ @hscr_list << TkScrollbar.new(f, 'orient'=>'horizontal') .
+ pack('fill'=>'x', 'anchor'=>'w')
+ f.place('relx'=>@rel_list[idx], 'y'=>0, 'anchor'=>'nw', 'width'=>-4,
+ 'relwidth'=>@rel_list[idx+1] - @rel_list[idx])
+
+ @lbox_list[idx].xscrollcommand proc{|first, last|
+ @hscr_list[idx].set first, last
+ }
+ @hscr_list[idx].command proc{|*args| @lbox_list[idx].xview *args}
+
+ # add new base
+ @base_list << base
+ }
+
+ # create tab
+ @tab_list = [nil]
+ (1..(@rel_list.size - 2)).each{|idx|
+ tab = TkFrame.new(@f_title, 'cursor'=>'sb_h_double_arrow',
+ 'width'=>6, 'borderwidth'=>2, 'relief'=>'raised')
+ @tab_list << tab
+ tab.place('relx'=>@rel_list[idx], 'anchor'=>'ne', 'relheight'=>0.95)
+ tab.bind('Button-1',
+ proc{|x| @x = x; @frame_width = TkWinfo.width(@f_title).to_f},
+ '%X')
+ tab.bind('B1-Motion', proc{|x, idx| resize(x, idx.to_i)}, "%X #{idx}")
+ }
+
+ # set control procedure for virtical scroll
+ @lbox_list.each{|lbox|
+ lbox.yscrollcommand proc{|first, last|
+ @v_scroll.set first, last
+ }
+ }
+ @v_scroll.command proc{|*args| @lbox_list.each{|lbox| lbox.yview *args} }
+
+ # binding for listboxes
+ @mode = {}
+ @mode['browse'] = browse_mode_bindtag
+ @mode['single'] = single_mode_bindtag
+ @mode['extended'] = extended_mode_bindtag
+ @mode['multiple'] = multiple_mode_bindtag
+ @current_mode = 'browse'
+ @lbox_list.each{|l|
+ l.bind('Shift-Key-Left',
+ proc{|w| focus_shift(w, -1); Tk.callback_break}, '%W')
+ l.bind('Shift-Key-Right',
+ proc{|w| focus_shift(w, 1); Tk.callback_break}, '%W')
+
+ l.bind('Button-2', proc{|x, y|
+ @lbox_mark_x = x
+ @lbox_list.each{|lbox| lbox.scan_mark(x, y)}
+ }, '%x %y')
+ l.bind('B2-Motion', proc{|x, y|
+ @lbox_list.each{|lbox| lbox.scan_dragto(@lbox_mark_x, y)}
+ l.scan_dragto(x, y)
+ }, '%x %y')
+
+ l.bindtags(l.bindtags.unshift(@mode[@current_mode]))
+ }
+
+ # alignment
+ TkGrid.rowconfigure(@frame, 0, 'weight'=>0)
+ TkGrid.rowconfigure(@frame, 1, 'weight'=>1)
+ TkGrid.rowconfigure(@frame, 2, 'weight'=>0)
+ TkGrid.columnconfigure(@frame, 0, 'weight'=>1)
+ TkGrid.columnconfigure(@frame, 1, 'weight'=>0)
+ @v_scroll.grid('row'=>1, 'column'=>1, 'sticky'=>'ns')
+ @f_title.grid('row'=>0, 'column'=>0, 'sticky'=>'news')
+ @f_lbox.grid('row'=>1, 'column'=>0, 'sticky'=>'news')
+ @f_hscr.grid('row'=>2, 'column'=>0, 'sticky'=>'ew')
+
+ # binding for 'Configure' event
+ @frame.bind('Configure', proc{reconstruct})
+
+ # set default receiver of method calls
+ @path = @lbox_list[0].path
+
+ # configure options
+ keys = {} unless keys
+ keys = _symbolkey2str(keys)
+
+ # 'mode' option of listboxes
+ sel_mode = keys.delete('mode')
+ mode(sel_mode) if sel_mode
+
+ # 'scrollbarwidth' option == 'width' option of scrollbars
+ width = keys.delete('scrollbarwidth')
+ scrollbarwidth(width) if width
+
+ # options for listbox titles
+ title_font = keys.delete('titlefont')
+ title_fg = keys.delete('titleforeground')
+ title_bg = keys.delete('titlebackground')
+ if title_font or title_fg or title_bg
+ titleconfig(title_font, title_fg, title_bg)
+ end
+
+ # set receivers for configure methods
+ delegate('DEFAULT', *@lbox_list)
+ delegate('activebackground', @v_scroll, *@hscr_list)
+ delegate('troughcolor', @v_scroll, *@hscr_list)
+ delegate('repeatdelay', @v_scroll, *@hscr_list)
+ delegate('repeatinterval', @v_scroll, *@hscr_list)
+ delegate('borderwidth', @frame)
+ delegate('relief', @frame)
+
+ # configure
+ configure(keys) if keys.size > 0
+ end
+ private :initialize_composite
+
+ # set 'mode' option of listboxes
+ def mode(sel_mode)
+ @lbox_list.each{|l|
+ tags = l.bindtags
+ tags = tags - [ @mode[@current_mode] ]
+ l.bindtags(tags.unshift(@mode[sel_mode]))
+ @current_mode = sel_mode
+ }
+ end
+
+ # set scrollbar width
+ def scrollbarwidth(width)
+ @v_scroll['width'] = width
+ @hscr_list.each{|hscr| hscr['width'] = width}
+ @f_hscr['height'] = width + 2 * @v_scroll.cget('borderwidth')
+ end
+
+ # set options of titles
+ def titleconfig(font, fg, bg)
+ keys = {}
+ keys['font'] = font if font
+ keys['foreground'] = fg if fg
+ keys['background'] = bg if bg
+ @title_list.each{|label| label.configure(keys)}
+ end
+
+ # get label widgets of listbox titles
+ def titlelabels(*indices)
+ @title_list[*indices]
+ end
+
+ # get listbox widgets
+ def columns(*indices)
+ @lbox_list[*indices]
+ end
+
+ def activate(idx)
+ @lbox_list.each{|lbox| lbox.activate(idx)}
+ end
+
+ def bbox(idx)
+ @lbox_list.collect{|lbox| lbox.bbox(idx)}
+ end
+
+ def delete(*idx)
+ @lbox_list.collect{|lbox| lbox.delete(*idx)}
+ end
+
+ def get(*idx)
+ if idx.size == 1
+ @lbox_list.collect{|lbox| lbox.get(*idx)}
+ else
+ list = @lbox_list.collect{|lbox| lbox.get(*idx)}
+ result = []
+ list[0].each_with_index{|line, index|
+ result << list.collect{|lines| lines[index]}
+ }
+ result
+ end
+ end
+
+ def _line_array_to_hash(line)
+ result = {}
+ @name_index.each_pair{|label, indices|
+ if indices.size == 1
+ result[label] = line[indices[0]]
+ else
+ result[label] = indices.collect{|index| line[index]}
+ end
+ }
+ result
+ end
+ private :_line_array_to_hash
+
+ def get_by_hash(*idx)
+ get_result = get(*idx)
+ if idx.size == 1
+ _line_array_to_hash(get_result)
+ else
+ get_result.collect{|line| _line_array_to_hash(line)}
+ end
+ end
+
+ def insert(idx, *lines)
+ lbox_ins = []
+ (0..@lbox_list.size).each{lbox_ins << []}
+
+ lines.each{|line|
+ if line.kind_of? Hash
+ array = []
+ @name_index.each_pair{|label, indices|
+ if indices.size == 1
+ array[indices[0]] = line[label]
+ else
+ if line[label].kind_of? Array
+ indices.each_with_index{|index, num|
+ array[index] = line[label][num]
+ }
+ else
+ array[indices[0]] = line[label]
+ end
+ end
+ }
+ line = array
+ end
+
+ @name_index.each_pair{|label, indices|
+ if indices.size == 1
+ lbox_ins[indices[0]] << line[indices[0]]
+ else
+ indices.each{|index| lbox_ins[index] << line[index]}
+ end
+ }
+ }
+
+ @lbox_list.each_with_index{|lbox, index|
+ lbox.insert(idx, *lbox_ins[index]) if lbox_ins[index]
+ }
+ end
+
+ def selection_anchor(index)
+ @lbox_list.each{|lbox| lbox.selection_anchor(index)}
+ end
+
+ def selection_clear(first, last=None)
+ @lbox_list.each{|lbox| lbox.selection_clear(first, last=None)}
+ end
+
+ def selection_set(first, last=None)
+ @lbox_list.each{|lbox| lbox.selection_set(first, last=None)}
+ end
+
+ ###########################################
+ private
+
+ def reconstruct
+ (0..(@rel_list.size - 2)).each{|idx|
+ title, lbox, hscr = @base_list[idx]
+ title.place('relwidth'=>@rel_list[idx+1] - @rel_list[idx])
+ lbox.place('relwidth'=>@rel_list[idx+1] - @rel_list[idx],
+ 'relheight'=>1.0)
+ hscr.place('relwidth'=>@rel_list[idx+1] - @rel_list[idx])
+
+ tab = @tab_list[idx]
+ tab.place('relx'=>@rel_list[idx]) if tab
+ }
+ end
+
+ def resize(x, idx)
+ # adjustment of relative positioning
+ delta = (x - @x) / @frame_width
+ if delta < @rel_list[idx-1] - @rel_list[idx] + 0.02
+ delta = @rel_list[idx-1] - @rel_list[idx] + 0.02
+ elsif delta > @rel_list[idx+1] - @rel_list[idx] - 0.02
+ delta = @rel_list[idx+1] - @rel_list[idx] - 0.02
+ end
+ @rel_list[idx] += delta
+
+ # adjustment of leftside widget of the tab
+ title, lbox, hscr = @base_list[idx - 1]
+ title.place('relwidth'=>@rel_list[idx] - @rel_list[idx-1])
+ lbox.place('relwidth'=>@rel_list[idx] - @rel_list[idx-1], 'relheight'=>1.0)
+ hscr.place('relwidth'=>@rel_list[idx] - @rel_list[idx-1])
+
+ # adjustment of the tab position
+ @tab_list[idx].place('relx'=>@rel_list[idx])
+
+ # adjustment of rightside widget of the tab
+ title, lbox, hscr = @base_list[idx]
+ title.place('relwidth'=>@rel_list[idx+1] - @rel_list[idx],
+ 'relx'=>@rel_list[idx])
+ lbox.place('relwidth'=>@rel_list[idx+1] - @rel_list[idx],
+ 'relx'=>@rel_list[idx], 'relheight'=>1.0)
+ hscr.place('relwidth'=>@rel_list[idx+1] - @rel_list[idx],
+ 'relx'=>@rel_list[idx])
+
+ # update reference position
+ @x = x
+ end
+
+ #################################
+ def browse_mode_bindtag
+ t = TkBindTag.new
+ t.bind('Button-1',
+ proc{|w, y| w.focus; select_line(w, w.nearest(y))}, '%W %y')
+ t.bind('B1-Motion', proc{|w, y| select_line(w, w.nearest(y))}, '%W %y')
+
+ t.bind('Shift-Button-1',
+ proc{|w, y| active_line(w, w.nearest(y))}, '%W %y')
+
+ t.bind('Key-Up', proc{|w| select_shift(w, -1)}, '%W')
+ t.bind('Key-Down', proc{|w| select_shift(w, 1)}, '%W')
+
+ t.bind('Control-Home', proc{|w| select_line(w, 0)}, '%W')
+ t.bind('Control-End', proc{|w| select_line(w, 'end')}, '%W')
+
+ t.bind('space', proc{|w| select_line(w, w.index('active').to_i)}, '%W')
+ t.bind('Select', proc{|w| select_line(w, w.index('active').to_i)}, '%W')
+ t.bind('Control-slash',
+ proc{|w| select_line(w, w.index('active').to_i)}, '%W')
+
+ t
+ end
+
+ ########################
+ def single_mode_bindtag
+ t = TkBindTag.new
+ t.bind('Button-1',
+ proc{|w, y| w.focus; select_only(w, w.nearest(y))}, '%W %y')
+ t.bind('ButtonRelease-1',
+ proc{|w, y| active_line(w, w.nearest(y))}, '%W %y')
+
+ t.bind('Shift-Button-1',
+ proc{|w, y| active_line(w, w.nearest(y))}, '%W %y')
+
+ t.bind('Key-Up', proc{|w| select_shift(w, -1)}, '%W')
+ t.bind('Key-Down', proc{|w| select_shift(w, 1)}, '%W')
+
+ t.bind('Control-Home', proc{|w| select_line(w, 0)}, '%W')
+ t.bind('Control-End', proc{|w| select_line(w, 'end')}, '%W')
+
+ t.bind('space', proc{|w| select_line(w, w.index('active').to_i)}, '%W')
+ t.bind('Select', proc{|w| select_line(w, w.index('active').to_i)}, '%W')
+ t.bind('Control-slash',
+ proc{|w| select_line(w, w.index('active').to_i)}, '%W')
+ t.bind('Control-backslash',
+ proc{@lbox_list.each{|l| l.selection_clear(0, 'end')}})
+
+ t
+ end
+
+ ########################
+ def extended_mode_bindtag
+ t = TkBindTag.new
+ t.bind('Button-1',
+ proc{|w, y| w.focus; select_only(w, w.nearest(y))}, '%W %y')
+ t.bind('B1-Motion', proc{|w, y| select_range(w, w.nearest(y))}, '%W %y')
+
+ t.bind('ButtonRelease-1',
+ proc{|w, y| active_line(w, w.nearest(y))}, '%W %y')
+
+ t.bind('Shift-Button-1',
+ proc{|w, y| select_range(w, w.nearest(y))}, '%W %y')
+ t.bind('Shift-B1-Motion',
+ proc{|w, y| select_range(w, w.nearest(y))}, '%W %y')
+
+ t.bind('Control-Button-1',
+ proc{|w, y| select_toggle(w, w.nearest(y))}, '%W %y')
+
+ t.bind('Control-B1-Motion',
+ proc{|w, y| select_drag(w, w.nearest(y))}, '%W %y')
+
+ t.bind('Key-Up', proc{|w| active_shift(w, -1)}, '%W')
+ t.bind('Key-Down', proc{|w| active_shift(w, 1)}, '%W')
+
+ t.bind('Shift-Up', proc{|w| select_expand(w, -1)}, '%W')
+ t.bind('Shift-Down', proc{|w| select_expand(w, 1)}, '%W')
+
+ t.bind('Control-Home', proc{|w| select_line2(w, 0)}, '%W')
+ t.bind('Control-End', proc{|w| select_line2(w, 'end')}, '%W')
+
+ t.bind('Control-Shift-Home', proc{|w| select_range(w, 0)}, '%W')
+ t.bind('Control-Shift-End', proc{|w| select_range(w, 'end')}, '%W')
+
+ t.bind('space', proc{|w| select_active(w)}, '%W')
+ t.bind('Select', proc{|w| select_active(w)}, '%W')
+ t.bind('Control-slash', proc{|w| select_all}, '%W')
+ t.bind('Control-backslash', proc{|w| clear_all}, '%W')
+
+ t
+ end
+
+ ########################
+ def multiple_mode_bindtag
+ t = TkBindTag.new
+ t.bind('Button-1',
+ proc{|w, y| w.focus; select_line3(w, w.nearest(y))}, '%W %y')
+ t.bind('ButtonRelease-1',
+ proc{|w, y| active_line(w, w.nearest(y))}, '%W %y')
+
+ t.bind('Key-Up', proc{|w| active_shift(w, -1)}, '%W')
+ t.bind('Key-Down', proc{|w| active_shift(w, 1)}, '%W')
+
+ t.bind('Control-Home', proc{|w| select_line2(w, 0)}, '%W')
+ t.bind('Control-End', proc{|w| select_line2(w, 'end')}, '%W')
+
+ t.bind('Control-Shift-Home', proc{|w| active_line(w, 0)}, '%W')
+ t.bind('Control-Shift-End', proc{|w| active_line(w, 'end')}, '%W')
+
+ t.bind('space', proc{|w| select_active(w)}, '%W')
+ t.bind('Select', proc{|w| select_active(w)}, '%W')
+ t.bind('Control-slash', proc{|w| select_all}, '%W')
+ t.bind('Control-backslash', proc{|w| clear_all}, '%W')
+
+ t
+ end
+
+ ########################
+ def active_line(w, idx)
+ @lbox_list.each{|l| l.activate(idx)}
+ end
+
+ def select_only(w, idx)
+ @lbox_list.each{|l|
+ l.selection_clear(0, 'end')
+ l.selection_anchor(idx)
+ l.selection_set('anchor')
+ }
+ end
+
+ def select_range(w, idx)
+ @lbox_list.each{|l|
+ l.selection_clear(0, 'end')
+ l.selection_set('anchor', idx)
+ }
+ end
+
+ def select_toggle(w, idx)
+ st = w.selection_includes(idx)
+ @lbox_list.each{|l|
+ l.selection_anchor(idx)
+ if st == 1
+ l.selection_clear(idx)
+ else
+ l.selection_set(idx)
+ end
+ }
+ end
+
+ def select_drag(w, idx)
+ st = w.selection_includes('anchor')
+ @lbox_list.each{|l|
+ if st == 1
+ l.selection_set('anchor', idx)
+ else
+ l.selection_clear('anchor', idx)
+ end
+ }
+ end
+
+ def select_line(w, idx)
+ @lbox_list.each{|l|
+ l.selection_clear(0, 'end')
+ l.activate(idx)
+ l.selection_anchor(idx)
+ l.selection_set('anchor')
+ }
+ w.selection_set('anchor')
+ end
+
+ def select_line2(w, idx)
+ @lbox_list.each{|l|
+ l.activate(idx)
+ l.selection_anchor(idx)
+ l.selection_set('anchor')
+ }
+ end
+
+ def select_line3(w, idx)
+ @lbox_list.each{|l|
+ l.selection_set(idx)
+ }
+ end
+
+ def select_active(w)
+ idx = l.activate(idx)
+ @lbox_list.each{|l|
+ l.selection_set(idx)
+ }
+ end
+
+ def select_expand(w, dir)
+ idx = w.index('active').to_i + dir
+ if idx < 0
+ idx = 0
+ elsif idx >= w.size
+ idx = w.size - 1
+ end
+ @lbox_list.each{|l|
+ l.activate(idx)
+ l.selection_set(idx)
+ }
+ end
+
+ def active_shift(w, dir)
+ idx = w.index('active').to_i + dir
+ if idx < 0
+ idx = 0
+ elsif idx >= w.size
+ idx = w.size - 1
+ end
+ @lbox_list.each{|l|
+ l.activate(idx)
+ l.selection_anchor(idx)
+ }
+ end
+
+ def select_shift(w, dir)
+ idx = w.index('anchor').to_i + dir
+ if idx < 0
+ idx = 0
+ elsif idx >= w.size
+ idx = w.size - 1
+ end
+ @lbox_list.each{|l|
+ l.selection_clear(0, 'end')
+ l.activate(idx)
+ l.selection_anchor(idx)
+ l.selection_set('anchor')
+ }
+ end
+
+ def select_all
+ @lbox_list.each{|l|
+ l.selection_set(0, 'end')
+ }
+ end
+
+ def clear_all
+ @lbox_list.each{|l|
+ l.selection_clear(0, 'end')
+ }
+ end
+
+ def focus_shift(w, dir)
+ idx = @lbox_list.index(w) + dir
+ return if idx < 0
+ return if idx >= @lbox_list.size
+ @lbox_list[idx].focus
+ end
+ ########################
+end
+
+################################################
+# test
+################################################
+if __FILE__ == $0
+ f = TkFrame.new(nil, 'width'=>300,
+ 'height'=>200).pack('fill'=>'both', 'expand'=>'true')
+ #f = TkFrame.new.pack('fill'=>'both', 'expand'=>'true')
+ l = TkMultiListbox.new(f, 150,
+ [ ['L1', 100],
+ ['L2', 200],
+ ['L3', 50] ],
+ 'titlefont'=>'courier',
+ 'titleforeground'=>'yellow',
+ 'titlebackground'=>'navy'
+ ).pack('fill'=>'both', 'expand'=>true)
+ l.insert('end', [1,2,3])
+ l.insert('end', [4,5,6])
+ l.insert('end', [4,5,6], [4,5,6])
+ l.insert('end', ['aaaaaaaaaaaaaaa','bbbbbbbbbbbbbb','ccccccccccccccccc'])
+ l.insert('end', [1,2,3])
+ l.insert('end', [4,5,6], [4,5,6])
+ l.insert('end', ['aaaaaaaaaaaaaaa','bbbbbbbbbbbbbb','ccccccccccccccccc'])
+ l.insert('end', [1,2,3])
+ l.insert('end', [4,5,6], [4,5,6])
+ l.insert('end', ['aaaaaaaaaaaaaaa','bbbbbbbbbbbbbb','ccccccccccccccccc'])
+ l.insert('end', [1,2,3])
+ l.insert('end', [4,5,6], [4,5,6])
+ p l.columns(1)
+ p l.columns(1..3)
+ p l.columns(1,2)
+ Tk.mainloop
+end
diff --git a/jni/ruby/ext/tk/sample/tkmultilistframe.rb b/jni/ruby/ext/tk/sample/tkmultilistframe.rb
new file mode 100644
index 0000000..7c0aac9
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkmultilistframe.rb
@@ -0,0 +1,940 @@
+#
+# tkmultilistframe.rb : multiple listbox widget on scrollable frame
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+require 'tk'
+
+class TkMultiListFrame < TkListbox
+ include TkComposite
+
+ # lbox_height : height of listboxes (pixel)
+ # title_info : array [ [<title_string>,<init_width>], ... ]
+ # keys : hash {<option>=><value>, ... }
+ def initialize_composite(lbox_height, title_info, keys={})
+ # argument check
+ if (! title_info.kind_of? Array) or (title_info.size < 2)
+ raise
+ end
+
+ # mode
+ @keep_minsize = true
+ @show_each_hscr = true
+ @show_win_hscr = true
+
+ # init arrays
+ @base_list = []
+ @rel_list = []
+ @title_list = []
+ @title_cmd = []
+ @lbox_list = []
+ @hscr_list = []
+
+ # decide total width
+ @lbox_total = title_info.size
+ @width_total = 0
+ title_info.each{|title, width, cmd|
+ @width_total += width.to_f
+ @title_cmd << cmd
+ }
+
+ # rel-table of label=>index
+ @name_index = {}
+
+ # size definition
+ @window_width = @width_total
+ @sash = 5
+ @scrbar_width = 15
+ @scrbar_border = 3
+ @lbox_border = 1
+ @title_border = 3
+ @h_l_thick = 0
+
+ # init status
+ @mode = :title
+
+ # virtical scrollbar
+=begin
+ @v_scroll = TkScrollbar.new(@frame, 'highlightthickness'=>@h_l_thick,
+ 'borderwidth'=>@scrbar_border,
+ 'orient'=>'vertical', 'width'=>@scrbar_width)
+=end
+ @v_scroll = TkYScrollbar.new(@frame, 'highlightthickness'=>@h_l_thick,
+ 'borderwidth'=>@scrbar_border,
+ 'width'=>@scrbar_width)
+
+ # horizontal scrollbar
+=begin
+ @h_scroll = TkScrollbar.new(@frame, 'highlightthickness'=>@h_l_thick,
+ 'borderwidth'=>@scrbar_border,
+ 'orient'=>'horizontal', 'width'=>@scrbar_width)
+=end
+ @h_scroll = TkXScrollbar.new(@frame, 'highlightthickness'=>@h_l_thick,
+ 'borderwidth'=>@scrbar_border,
+ 'width'=>@scrbar_width)
+
+ # create base flames
+ @c_title = TkCanvas.new(@frame, 'highlightthickness'=>@h_l_thick,
+ 'width'=>@window_width)
+ @f_title = TkFrame.new(@c_title, 'width'=>@width_total)
+ @w_title = TkcWindow.new(@c_title, 0, 0,
+ 'window'=>@f_title, 'anchor'=>'nw')
+
+ @c_lbox = TkCanvas.new(@frame, 'highlightthickness'=>@h_l_thick,
+ 'width'=>@window_width)
+ @f_lbox = TkFrame.new(@c_lbox, 'width'=>@width_total)
+ @w_lbox = TkcWindow.new(@c_lbox, 0, 0, 'window'=>@f_lbox, 'anchor'=>'nw')
+
+ @c_hscr = TkCanvas.new(@frame, 'highlightthickness'=>@h_l_thick,
+ 'width'=>@window_width)
+ @f_hscr = TkFrame.new(@c_hscr, 'width'=>@width_total)
+ @w_hscr = TkcWindow.new(@c_hscr, 0, 0, 'window'=>@f_hscr, 'anchor'=>'nw')
+
+ # create each listbox
+ sum = 0.0
+ @rel_list << sum/@width_total
+ title_info.each_with_index{|(label, width), idx|
+ # set relation between label and index
+ if @name_index.include?(label)
+ @name_index[label] << idx
+ else
+ @name_index[label] = [idx]
+ end
+
+ # calculate relative positioning
+ sum += width
+ @rel_list << sum/@width_total
+
+ # title field
+ f = TkFrame.new(@f_title, 'width'=>width)
+ base = [f]
+
+ title = TkLabel.new(f, 'text'=>label, 'borderwidth'=>@title_border,
+ 'relief'=>'raised', 'highlightthickness'=>@h_l_thick)
+ title_binding(title, idx)
+ title.pack('fill'=>'x')
+
+ @title_list << title
+
+ f.place('relx'=>@rel_list[idx], 'y'=>0, 'anchor'=>'nw', 'width'=>1,
+ 'relheight'=>1.0,
+ 'relwidth'=>@rel_list[idx+1] - @rel_list[idx])
+
+ # listbox field
+ f = TkFrame.new(@f_lbox, 'width'=>width)
+ base << f
+ @lbox_list << TkListbox.new(f, 'highlightthickness'=>@h_l_thick,
+ 'borderwidth'=>@lbox_border
+ ).pack('fill'=>'both', 'expand'=>true)
+ f.place('relx'=>@rel_list[idx], 'y'=>0, 'anchor'=>'nw', 'width'=>1,
+ 'relwidth'=>@rel_list[idx+1] - @rel_list[idx], 'relheight'=>1.0)
+
+ # scrollbar field
+ f = TkFrame.new(@f_hscr, 'width'=>width)
+ base << f
+=begin
+ @hscr_list << TkScrollbar.new(f, 'orient'=>'horizontal',
+ 'width'=>@scrbar_width,
+ 'borderwidth'=>@scrbar_border,
+ 'highlightthickness'=>@h_l_thick
+ ).pack('fill'=>'x', 'anchor'=>'w')
+=end
+ @hscr_list << TkXScrollbar.new(f, 'width'=>@scrbar_width,
+ 'borderwidth'=>@scrbar_border,
+ 'highlightthickness'=>@h_l_thick
+ ).pack('fill'=>'x', 'anchor'=>'w')
+ f.place('relx'=>@rel_list[idx], 'y'=>0, 'anchor'=>'nw', 'width'=>1,
+ 'relwidth'=>@rel_list[idx+1] - @rel_list[idx])
+
+=begin
+ @lbox_list[idx].xscrollcommand proc{|first, last|
+ @hscr_list[idx].set first, last
+ }
+ @hscr_list[idx].command proc{|*args| @lbox_list[idx].xview *args}
+=end
+ @lbox_list[idx].xscrollbar(@hscr_list[idx])
+
+ # add new base
+ @base_list << base
+ }
+
+ # pad
+ # @f_title_pad = TkFrame.new(@frame)
+ @f_title_pad = TkFrame.new(@frame, 'relief'=>'raised',
+ 'borderwidth'=>@title_border,
+ 'highlightthickness'=>@h_l_thick)
+
+ @f_scr_pad = TkFrame.new(@frame, 'relief'=>'sunken',
+ 'borderwidth'=>1,
+ 'highlightthickness'=>@h_l_thick)
+
+ # height check
+ title_height = 0
+ @title_list.each{|w|
+ h = w.winfo_reqheight
+ title_height = h if title_height < h
+ }
+
+ hscr_height = 0
+ @hscr_list.each{|w|
+ h = w.winfo_reqheight
+ hscr_height = h if hscr_height < h
+ }
+
+ @f_title.height title_height
+ @f_lbox.height lbox_height
+ @f_hscr.height hscr_height
+
+ # set control procedure for virtical scroll
+=begin
+ @lbox_list.each{|lbox|
+ lbox.yscrollcommand proc{|first, last|
+ @v_scroll.set first, last
+ }
+ }
+ @v_scroll.command proc{|*args| @lbox_list.each{|lbox| lbox.yview *args} }
+=end
+ @v_scroll.assign(*@lbox_list)
+
+ # set control procedure for horizoncal scroll
+=begin
+ @c_title.xscrollcommand proc{|first, last|
+ @h_scroll.set first, last
+ }
+ @c_lbox.xscrollcommand proc{|first, last|
+ @h_scroll.set first, last
+ }
+ @c_hscr.xscrollcommand proc{|first, last|
+ @h_scroll.set first, last
+ }
+ @h_scroll.command proc{|*args|
+ @c_title.xview *args
+ @c_lbox.xview *args
+ @c_hscr.xview *args if @show_each_hscr
+ }
+=end
+ @h_scroll.assign(@c_title, @c_lbox, @c_hscr)
+
+ # binding for listboxes
+ @lbox_mode = {}
+ @lbox_mode['browse'] = browse_mode_bindtag
+ @lbox_mode['single'] = single_mode_bindtag
+ @lbox_mode['extended'] = extended_mode_bindtag
+ @lbox_mode['multiple'] = multiple_mode_bindtag
+ @current_mode = 'browse'
+ @lbox_list.each_with_index{|l, idx|
+ l.bind('Shift-Key-Left',
+ proc{|w| focus_shift(w, -1); Tk.callback_break}, '%W')
+ l.bind('Shift-Key-Right',
+ proc{|w| focus_shift(w, 1); Tk.callback_break}, '%W')
+
+ l.bind('Button-2', proc{|x, y|
+ @lbox_mark_x = x
+ @lbox_list.each{|lbox| lbox.scan_mark(x, y)}
+ }, '%x %y')
+ l.bind('B2-Motion', proc{|x, y|
+ @lbox_list.each{|lbox| lbox.scan_dragto(@lbox_mark_x, y)}
+ l.scan_dragto(x, y)
+ }, '%x %y')
+
+ l.bindtags(l.bindtags.unshift(@lbox_mode[@current_mode]))
+ }
+
+ bbox = @w_title.bbox
+ @c_title.height(bbox[3])
+ @c_title.scrollregion(bbox)
+
+ bbox = @w_lbox.bbox
+ @c_lbox.height(bbox[3])
+ @c_lbox.scrollregion(bbox)
+
+ if @show_each_hscr
+ bbox = @w_hscr.bbox
+ @c_hscr.height(bbox[3])
+ @c_hscr.scrollregion(bbox)
+ end
+
+ # alignment
+ TkGrid.rowconfigure(@frame, 0, 'weight'=>0)
+ TkGrid.rowconfigure(@frame, 1, 'weight'=>1)
+ TkGrid.rowconfigure(@frame, 2, 'weight'=>0)
+ TkGrid.rowconfigure(@frame, 3, 'weight'=>0)
+ TkGrid.columnconfigure(@frame, 0, 'weight'=>1)
+ TkGrid.columnconfigure(@frame, 1, 'weight'=>0)
+ TkGrid.columnconfigure(@frame, 2, 'weight'=>0)
+ @v_scroll.grid('row'=>1, 'column'=>2, 'sticky'=>'ns')
+ @c_title.grid('row'=>0, 'column'=>0, 'sticky'=>'news')
+ @f_title_pad.grid('row'=>0, 'column'=>2, 'sticky'=>'news')
+ @c_lbox.grid('row'=>1, 'column'=>0, 'sticky'=>'news')
+ @c_hscr.grid('row'=>2, 'column'=>0, 'sticky'=>'ew') if @show_each_hscr
+ @h_scroll.grid('row'=>3, 'column'=>0, 'sticky'=>'ew') if @show_win_hscr
+ @f_scr_pad.grid('row'=>2, 'rowspan'=>2, 'column'=>2, 'sticky'=>'news')
+
+ # binding for 'Configure' event
+ @c_lbox.bind('Configure',
+ proc{|height, width| reconstruct(height, width)},
+ '%h %w')
+
+ # set default receiver of method calls
+ @path = @lbox_list[0].path
+
+ # configure options
+ keys = {} unless keys
+ keys = _symbolkey2str(keys)
+
+ # 'mode' option of listboxes
+ sel_mode = keys.delete('mode')
+ mode(sel_mode) if sel_mode
+
+ # 'scrollbarwidth' option == 'width' option of scrollbars
+ width = keys.delete('scrollbarwidth')
+ scrollbarwidth(width) if width
+
+ # options for listbox titles
+ title_font = keys.delete('titlefont')
+ titlefont(title_font) if title_font
+
+ title_fg = keys.delete('titleforeground')
+ titleforeground(title_fg) if title_fg
+
+ title_bg = keys.delete('titlebackground')
+ titlebackground(title_bg) if title_bg
+
+ # set receivers for configure methods
+ delegate('DEFAULT', *@lbox_list)
+ delegate('activebackground', @v_scroll, @h_scroll, *@hscr_list)
+ delegate('troughcolor', @v_scroll, @h_scroll, *@hscr_list)
+ delegate('repeatdelay', @v_scroll, @h_scroll, *@hscr_list)
+ delegate('repeatinterval', @v_scroll, @h_scroll, *@hscr_list)
+ delegate('borderwidth', @frame)
+ delegate('width', @c_lbox, @c_title, @c_hscr)
+ delegate('relief', @frame)
+
+ # configure
+ configure(keys) if keys.size > 0
+ end
+ private :initialize_composite
+
+ # set 'mode' option of listboxes
+ def mode(sel_mode)
+ @lbox_list.each{|l|
+ tags = l.bindtags
+ tags = tags - [ @lbox_mode[@current_mode] ]
+ l.bindtags(tags.unshift(@lbox_mode[sel_mode]))
+ @current_mode = sel_mode
+ }
+ end
+
+ # keep_minsize?
+ def keep_minsize?
+ @keep_minsize
+ end
+ def keep_minsize(bool)
+ @keep_minsize = bool
+ end
+
+ # each hscr
+ def show_each_hscr
+ @show_each_hscr = true
+ @c_hscr.grid('row'=>2, 'column'=>0, 'sticky'=>'ew')
+ end
+ def hide_each_hscr
+ @show_each_hscr = false
+ @c_hscr.ungrid
+ end
+
+ # window hscroll
+ def show_win_hscr
+ @show_win_hscr = true
+ @h_scroll.grid('row'=>3, 'column'=>0, 'sticky'=>'ew')
+ end
+ def hide_win_hscr
+ @show_each_hscr = false
+ @h_scroll.ungrid
+ end
+
+ # set scrollbar width
+ def scrollbarwidth(width)
+ @scrbar_width = width
+ @v_scroll['width'] = @scrbar_width
+ @h_scroll['width'] = @scrbar_width
+ @hscr_list.each{|hscr| hscr['width'] = @scrbar_width}
+ self
+ end
+
+ # set scrollbar border
+ def scrollbarborder(width)
+ @scrbar_border = width
+ @v_scroll['border'] = @scrbar_border
+ @h_scroll['border'] = @scrbar_border
+ @hscr_list.each{|hscr| hscr['border'] = @scrbar_border}
+ self
+ end
+
+ # set listbox borders
+ def listboxborder(width)
+ @lbox_border = width
+ @lbox_list.each{|w| w['border'] = @lbox_border}
+ self
+ end
+
+ # set listbox relief
+ def listboxrelief(relief)
+ @lbox_list.each{|w| w['relief'] = relief}
+ self
+ end
+
+ # set title borders
+ def titleborder(width)
+ @title_border = width
+ @f_title_pad['border'] = @title_border
+ @title_list.each{|label| label['border'] = @title_border}
+ self
+ end
+
+ # set title font
+ def titlefont(font)
+ @title_list.each{|label| label['font'] = font}
+ title_height = 0
+ @title_list.each{|w|
+ h = w.winfo_reqheight
+ title_height = h if title_height < h
+ }
+ @f_title.height title_height
+ bbox = @w_title.bbox
+ @c_title.height(bbox[3])
+ @c_title.scrollregion(bbox)
+ self
+ end
+
+ # set title foreground color
+ def titleforeground(fg)
+ @title_list.each{|label| label['foreground'] = fg}
+ self
+ end
+
+ # set title background color
+ def titlebackground(bg)
+ @f_title_pad['background'] = bg
+ @title_list.each{|label| label['background'] = bg}
+ self
+ end
+
+ # set title cmds
+ def titlecommand(idx, cmd=Proc.new)
+ @title_cmd[idx] = cmd
+ end
+
+ # call title cmds
+ def titleinvoke(idx)
+ @title_cmd[idx].call if @title_cmd[idx]
+ end
+
+ # get label widgets of listbox titles
+ def titlelabels(*indices)
+ @title_list[*indices]
+ end
+
+ # get listbox widgets
+ def columns(*indices)
+ @lbox_list[*indices]
+ end
+
+ def activate(idx)
+ @lbox_list.each{|lbox| lbox.activate(idx)}
+ end
+
+ def bbox(idx)
+ @lbox_list.collect{|lbox| lbox.bbox(idx)}
+ end
+
+ def delete(*idx)
+ @lbox_list.collect{|lbox| lbox.delete(*idx)}
+ end
+
+ def get(*idx)
+ if idx.size == 1
+ @lbox_list.collect{|lbox| lbox.get(*idx)}
+ else
+ list = @lbox_list.collect{|lbox| lbox.get(*idx)}
+ result = []
+ list[0].each_with_index{|line, index|
+ result << list.collect{|lines| lines[index]}
+ }
+ result
+ end
+ end
+
+ def _line_array_to_hash(line)
+ result = {}
+ @name_index.each_pair{|label, indices|
+ if indices.size == 1
+ result[label] = line[indices[0]]
+ else
+ result[label] = indices.collect{|index| line[index]}
+ end
+ }
+ result
+ end
+ private :_line_array_to_hash
+
+ def get_by_hash(*idx)
+ get_result = get(*idx)
+ if idx.size == 1
+ _line_array_to_hash(get_result)
+ else
+ get_result.collect{|line| _line_array_to_hash(line)}
+ end
+ end
+
+ def insert(idx, *lines)
+ lbox_ins = []
+ (0..@lbox_list.size).each{lbox_ins << []}
+
+ lines.each{|line|
+ if line.kind_of? Hash
+ array = []
+ @name_index.each_pair{|label, indices|
+ if indices.size == 1
+ array[indices[0]] = line[label]
+ else
+ if line[label].kind_of? Array
+ indices.each_with_index{|index, num|
+ array[index] = line[label][num]
+ }
+ else
+ array[indices[0]] = line[label]
+ end
+ end
+ }
+ line = array
+ end
+
+ @name_index.each_pair{|label, indices|
+ if indices.size == 1
+ lbox_ins[indices[0]] << line[indices[0]]
+ else
+ indices.each{|index| lbox_ins[index] << line[index]}
+ end
+ }
+ }
+
+ @lbox_list.each_with_index{|lbox, index|
+ lbox.insert(idx, *lbox_ins[index]) if lbox_ins[index]
+ }
+ end
+
+ def selection_anchor(index)
+ @lbox_list.each{|lbox| lbox.selection_anchor(index)}
+ end
+
+ def selection_clear(first, last=None)
+ @lbox_list.each{|lbox| lbox.selection_clear(first, last=None)}
+ end
+
+ def selection_set(first, last=None)
+ @lbox_list.each{|lbox| lbox.selection_set(first, last=None)}
+ end
+
+ ###########################################
+ private
+
+ def reconstruct(height, width)
+ if @keep_minsize && width <= @width_total
+ @f_title.width(@width_total)
+ @f_lbox.width(@width_total)
+ @f_hscr.width(@width_total) if @show_each_hscr
+ @window_width = @width_total
+ else
+ @f_title.width(width)
+ @f_lbox.width(width)
+ @f_hscr.width(width) if @show_each_hscr
+ @window_width = width
+ end
+
+ @f_lbox.height(height)
+
+ @c_title.scrollregion(@w_title.bbox)
+ @c_lbox.scrollregion(@w_lbox.bbox)
+ @c_hscr.scrollregion(@w_hscr.bbox) if @show_each_hscr
+
+ (0..(@rel_list.size - 2)).each{|idx|
+ title, lbox, hscr = @base_list[idx]
+ title.place('relwidth'=>@rel_list[idx+1] - @rel_list[idx])
+ lbox.place('relwidth'=>@rel_list[idx+1] - @rel_list[idx],
+ 'relheight'=>1.0)
+ hscr.place('relwidth'=>@rel_list[idx+1] - @rel_list[idx])
+ }
+ end
+
+ def resize(x)
+ idx = @sel_sash
+ return if idx == 0
+
+ # adjustment of relative positioning
+ delta = (x - @x) / @frame_width
+ if delta < @rel_list[idx-1] - @rel_list[idx] + (2*@sash/@frame_width)
+ delta = @rel_list[idx-1] - @rel_list[idx] + (2*@sash/@frame_width)
+ elsif delta > @rel_list[idx+1] - @rel_list[idx] - (2*@sash/@frame_width)
+ delta = @rel_list[idx+1] - @rel_list[idx] - (2*@sash/@frame_width)
+ end
+ @rel_list[idx] += delta
+
+ # adjustment of leftside widget of the sash
+ title, lbox, hscr = @base_list[idx - 1]
+ title.place('relwidth'=>@rel_list[idx] - @rel_list[idx-1])
+ lbox.place('relwidth'=>@rel_list[idx] - @rel_list[idx-1], 'relheight'=>1.0)
+ hscr.place('relwidth'=>@rel_list[idx] - @rel_list[idx-1])
+
+ # adjustment of rightside widget of the sash
+ title, lbox, hscr = @base_list[idx]
+ title.place('relwidth'=>@rel_list[idx+1] - @rel_list[idx],
+ 'relx'=>@rel_list[idx])
+ lbox.place('relwidth'=>@rel_list[idx+1] - @rel_list[idx],
+ 'relx'=>@rel_list[idx], 'relheight'=>1.0)
+ hscr.place('relwidth'=>@rel_list[idx+1] - @rel_list[idx],
+ 'relx'=>@rel_list[idx])
+
+ # update reference position
+ @x = x
+ end
+
+ def motion_cb(w, x, idx)
+ if x <= @sash && idx > 0
+ w.cursor 'sb_h_double_arrow'
+ @mode = :sash
+ @sel_sash = idx
+ elsif x >= w.winfo_width - @sash && idx < @lbox_total - 1
+ w.cursor 'sb_h_double_arrow'
+ @mode = :sash
+ @sel_sash = idx + 1
+ else
+ w.cursor ""
+ @mode = :title
+ @sel_sash = 0
+ end
+ end
+
+ def title_binding(title, index)
+ title.bind('Motion', proc{|w, x, idx| motion_cb(w, x, idx.to_i)},
+ "%W %x #{index}")
+
+ title.bind('Enter', proc{|w, x, idx| motion_cb(w, x, idx.to_i)},
+ "%W %x #{index}")
+
+ title.bind('Leave', proc{|w| w.cursor ""}, "%W")
+
+ title.bind('Button-1',
+ proc{|w, x|
+ if @mode == :sash
+ @x = x
+ @frame_width = TkWinfo.width(@f_title).to_f
+ else
+ title.relief 'sunken'
+ end
+ },
+ '%W %X')
+
+ title.bind('ButtonRelease-1',
+ proc{|w, x, idx|
+ i = idx.to_i
+ if @mode == :title && @title_cmd[i].kind_of?(Proc)
+ @title_cmd[i].call
+ end
+ title.relief 'raised'
+ motion_cb(w,x,i)
+ },
+ "%W %x #{index}")
+
+ title.bind('B1-Motion', proc{|x| resize(x) if @mode == :sash}, "%X")
+ end
+
+ #################################
+ def browse_mode_bindtag
+ t = TkBindTag.new
+ t.bind('Button-1',
+ proc{|w, y| w.focus; select_line(w, w.nearest(y))}, '%W %y')
+ t.bind('B1-Motion', proc{|w, y| select_line(w, w.nearest(y))}, '%W %y')
+
+ t.bind('Shift-Button-1',
+ proc{|w, y| active_line(w, w.nearest(y))}, '%W %y')
+
+ t.bind('Key-Up', proc{|w| select_shift(w, -1)}, '%W')
+ t.bind('Key-Down', proc{|w| select_shift(w, 1)}, '%W')
+
+ t.bind('Control-Home', proc{|w| select_line(w, 0)}, '%W')
+ t.bind('Control-End', proc{|w| select_line(w, 'end')}, '%W')
+
+ t.bind('space', proc{|w| select_line(w, w.index('active').to_i)}, '%W')
+ t.bind('Select', proc{|w| select_line(w, w.index('active').to_i)}, '%W')
+ t.bind('Control-slash',
+ proc{|w| select_line(w, w.index('active').to_i)}, '%W')
+
+ t
+ end
+
+ ########################
+ def single_mode_bindtag
+ t = TkBindTag.new
+ t.bind('Button-1',
+ proc{|w, y| w.focus; select_only(w, w.nearest(y))}, '%W %y')
+ t.bind('ButtonRelease-1',
+ proc{|w, y| active_line(w, w.nearest(y))}, '%W %y')
+
+ t.bind('Shift-Button-1',
+ proc{|w, y| active_line(w, w.nearest(y))}, '%W %y')
+
+ t.bind('Key-Up', proc{|w| select_shift(w, -1)}, '%W')
+ t.bind('Key-Down', proc{|w| select_shift(w, 1)}, '%W')
+
+ t.bind('Control-Home', proc{|w| select_line(w, 0)}, '%W')
+ t.bind('Control-End', proc{|w| select_line(w, 'end')}, '%W')
+
+ t.bind('space', proc{|w| select_line(w, w.index('active').to_i)}, '%W')
+ t.bind('Select', proc{|w| select_line(w, w.index('active').to_i)}, '%W')
+ t.bind('Control-slash',
+ proc{|w| select_line(w, w.index('active').to_i)}, '%W')
+ t.bind('Control-backslash',
+ proc{@lbox_list.each{|l| l.selection_clear(0, 'end')}})
+
+ t
+ end
+
+ ########################
+ def extended_mode_bindtag
+ t = TkBindTag.new
+ t.bind('Button-1',
+ proc{|w, y| w.focus; select_only(w, w.nearest(y))}, '%W %y')
+ t.bind('B1-Motion', proc{|w, y| select_range(w, w.nearest(y))}, '%W %y')
+
+ t.bind('ButtonRelease-1',
+ proc{|w, y| active_line(w, w.nearest(y))}, '%W %y')
+
+ t.bind('Shift-Button-1',
+ proc{|w, y| select_range(w, w.nearest(y))}, '%W %y')
+ t.bind('Shift-B1-Motion',
+ proc{|w, y| select_range(w, w.nearest(y))}, '%W %y')
+
+ t.bind('Control-Button-1',
+ proc{|w, y| select_toggle(w, w.nearest(y))}, '%W %y')
+
+ t.bind('Control-B1-Motion',
+ proc{|w, y| select_drag(w, w.nearest(y))}, '%W %y')
+
+ t.bind('Key-Up', proc{|w| active_shift(w, -1)}, '%W')
+ t.bind('Key-Down', proc{|w| active_shift(w, 1)}, '%W')
+
+ t.bind('Shift-Up', proc{|w| select_expand(w, -1)}, '%W')
+ t.bind('Shift-Down', proc{|w| select_expand(w, 1)}, '%W')
+
+ t.bind('Control-Home', proc{|w| select_line2(w, 0)}, '%W')
+ t.bind('Control-End', proc{|w| select_line2(w, 'end')}, '%W')
+
+ t.bind('Control-Shift-Home', proc{|w| select_range(w, 0)}, '%W')
+ t.bind('Control-Shift-End', proc{|w| select_range(w, 'end')}, '%W')
+
+ t.bind('space', proc{|w| select_active(w)}, '%W')
+ t.bind('Select', proc{|w| select_active(w)}, '%W')
+ t.bind('Control-slash', proc{|w| select_all}, '%W')
+ t.bind('Control-backslash', proc{|w| clear_all}, '%W')
+
+ t
+ end
+
+ ########################
+ def multiple_mode_bindtag
+ t = TkBindTag.new
+ t.bind('Button-1',
+ proc{|w, y| w.focus; select_line3(w, w.nearest(y))}, '%W %y')
+ t.bind('ButtonRelease-1',
+ proc{|w, y| active_line(w, w.nearest(y))}, '%W %y')
+
+ t.bind('Key-Up', proc{|w| active_shift(w, -1)}, '%W')
+ t.bind('Key-Down', proc{|w| active_shift(w, 1)}, '%W')
+
+ t.bind('Control-Home', proc{|w| select_line2(w, 0)}, '%W')
+ t.bind('Control-End', proc{|w| select_line2(w, 'end')}, '%W')
+
+ t.bind('Control-Shift-Home', proc{|w| active_line(w, 0)}, '%W')
+ t.bind('Control-Shift-End', proc{|w| active_line(w, 'end')}, '%W')
+
+ t.bind('space', proc{|w| select_active(w)}, '%W')
+ t.bind('Select', proc{|w| select_active(w)}, '%W')
+ t.bind('Control-slash', proc{|w| select_all}, '%W')
+ t.bind('Control-backslash', proc{|w| clear_all}, '%W')
+
+ t
+ end
+
+ ########################
+ def active_line(w, idx)
+ @lbox_list.each{|l| l.activate(idx)}
+ end
+
+ def select_only(w, idx)
+ @lbox_list.each{|l|
+ l.selection_clear(0, 'end')
+ l.selection_anchor(idx)
+ l.selection_set('anchor')
+ }
+ end
+
+ def select_range(w, idx)
+ @lbox_list.each{|l|
+ l.selection_clear(0, 'end')
+ l.selection_set('anchor', idx)
+ }
+ end
+
+ def select_toggle(w, idx)
+ st = w.selection_includes(idx)
+ @lbox_list.each{|l|
+ l.selection_anchor(idx)
+ if st == 1
+ l.selection_clear(idx)
+ else
+ l.selection_set(idx)
+ end
+ }
+ end
+
+ def select_drag(w, idx)
+ st = w.selection_includes('anchor')
+ @lbox_list.each{|l|
+ if st == 1
+ l.selection_set('anchor', idx)
+ else
+ l.selection_clear('anchor', idx)
+ end
+ }
+ end
+
+ def select_line(w, idx)
+ @lbox_list.each{|l|
+ l.selection_clear(0, 'end')
+ l.activate(idx)
+ l.selection_anchor(idx)
+ l.selection_set('anchor')
+ }
+ w.selection_set('anchor')
+ end
+
+ def select_line2(w, idx)
+ @lbox_list.each{|l|
+ l.activate(idx)
+ l.selection_anchor(idx)
+ l.selection_set('anchor')
+ }
+ end
+
+ def select_line3(w, idx)
+ @lbox_list.each{|l|
+ l.selection_set(idx)
+ }
+ end
+
+ def select_active(w)
+ idx = l.activate(idx)
+ @lbox_list.each{|l|
+ l.selection_set(idx)
+ }
+ end
+
+ def select_expand(w, dir)
+ idx = w.index('active').to_i + dir
+ if idx < 0
+ idx = 0
+ elsif idx >= w.size
+ idx = w.size - 1
+ end
+ @lbox_list.each{|l|
+ l.activate(idx)
+ l.selection_set(idx)
+ }
+ end
+
+ def active_shift(w, dir)
+ idx = w.index('active').to_i + dir
+ if idx < 0
+ idx = 0
+ elsif idx >= w.size
+ idx = w.size - 1
+ end
+ @lbox_list.each{|l|
+ l.activate(idx)
+ l.selection_anchor(idx)
+ }
+ end
+
+ def select_shift(w, dir)
+ idx = w.index('anchor').to_i + dir
+ if idx < 0
+ idx = 0
+ elsif idx >= w.size
+ idx = w.size - 1
+ end
+ @lbox_list.each{|l|
+ l.selection_clear(0, 'end')
+ l.activate(idx)
+ l.selection_anchor(idx)
+ l.selection_set('anchor')
+ }
+ end
+
+ def select_all
+ @lbox_list.each{|l|
+ l.selection_set(0, 'end')
+ }
+ end
+
+ def clear_all
+ @lbox_list.each{|l|
+ l.selection_clear(0, 'end')
+ }
+ end
+
+ def focus_shift(w, dir)
+ idx = @lbox_list.index(w) + dir
+ return if idx < 0
+ return if idx >= @lbox_list.size
+ @lbox_list[idx].focus
+ end
+ ########################
+end
+
+################################################
+# test
+################################################
+if __FILE__ == $0
+ l = TkMultiListFrame.new(nil, 200,
+ [ ['L1', 200, proc{p 'click L1'}],
+ ['L2', 100],
+ ['L3', 200] ],
+ 'width'=>350,
+ #'titleforeground'=>'yellow',
+ 'titleforeground'=>'white',
+ #'titlebackground'=>'navy',
+ 'titlebackground'=>'blue',
+ 'titlefont'=>'courier'
+ ).pack('fill'=>'both', 'expand'=>true)
+ l.insert('end', [1,2,3])
+ l.insert('end', [4,5,6])
+ l.insert('end', [4,5,6], [4,5,6])
+ l.insert('end', ['aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa',
+ 'bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb',
+ 'cccccccccccccccccccccccccccccccccccccccccccccccccccc'])
+ l.insert('end', [1,2,3])
+ l.insert('end', [4,5,6], [4,5,6])
+ l.insert('end', ['aaaaaaaaaaaaaaa','bbbbbbbbbbbbbb','ccccccccccccccccc'])
+ l.insert('end', [1,2,3])
+ l.insert('end', [4,5,6], [4,5,6])
+ l.insert('end', ['aaaaaaaaaaaaaaa','bbbbbbbbbbbbbb','ccccccccccccccccc'])
+ l.insert('end', [1,2,3])
+ l.insert('end', [4,5,6], [4,5,6])
+ l.insert('end', ['aaaaaaaaaaaaaaa','bbbbbbbbbbbbbb','ccccccccccccccccc'])
+ l.insert('end', [1,2,3])
+ l.insert('end', [4,5,6], [4,5,6])
+ p l.columns(1)
+ p l.columns(1..3)
+ p l.columns(1,2)
+ Tk.mainloop
+end
diff --git a/jni/ruby/ext/tk/sample/tkoptdb-safeTk.rb b/jni/ruby/ext/tk/sample/tkoptdb-safeTk.rb
new file mode 100644
index 0000000..7502e30
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkoptdb-safeTk.rb
@@ -0,0 +1,73 @@
+#!/usr/bin/env ruby
+
+require 'multi-tk'
+
+TkMessage.new(:text => <<EOM).pack
+This is a sample of the safe-Tk slave interpreter. \
+On the slave interpreter, 'tkoptdb.rb' demo is running.
+( NOTE:: a safe-Tk interpreter can't read options \
+from a file. Options are given by the master interpreter \
+in this script. )
+The window shown this message is a root widget of \
+the default master interpreter. The other window \
+is a toplevel widget of the master interpreter, and it \
+has a container frame of the safe-Tk slave interpreter.
+'exit' on the slave interpreter exits the slave only. \
+You can also delete the slave by the button on the toplevel widget.
+EOM
+
+if ENV['LANG'] =~ /^ja/
+ # read Japanese resource
+ ent = TkOptionDB.read_entries(File.expand_path('resource.ja',
+ File.dirname(__FILE__)),
+ 'utf-8')
+else
+ # read English resource
+ ent = TkOptionDB.read_entries(File.expand_path('resource.en',
+ File.dirname(__FILE__)))
+end
+
+file = File.expand_path('tkoptdb.rb', File.dirname(__FILE__))
+
+ip = MultiTkIp.new_safeTk{
+ # When a block is given to 'new_safeTk' method,
+ # the block is evaluated on $SAFE==4.
+ ent.each{|pat, val| Tk.tk_call('option', 'add', pat, val)}
+}
+
+print "ip.eval_proc{$SAFE} ==> ", ip.eval_proc{$SAFE}, "\n"
+
+print "\ncall 'ip.wait_on_mainloop = false'\n"
+print "If 'ip.wait_on_mainloop? == true', ",
+ "when 'mainloop' is called on 'ip.eval_proc', ",
+ "'ip.eval_proc' does't return while the root window exists.\n",
+ "If you want to avoid that, set wait_on_mainloop to false. ",
+ "Then the mainloop in the eval_proc returns soon ",
+ "and the following steps are evaluated. \n",
+ "If you hate the both of them, use 'ip.bg_eval_proc' or ",
+ "wrap 'ip.eval_proc' by a thread.\n"
+
+ip.wait_on_mainloop = false
+
+ret = ip.eval_proc{
+ # When a block is given to 'eval_proc' method,
+ # the block is evaluated on the IP's current safe level.
+ # So, the followings raises an exception.
+ # An Exception object of the exception is returned as a
+ # return value of this method.
+
+ load file
+}
+print "\nip.eval_proc{}, which includes insecure operiation in the given block, returns an exception object: ", ret.inspect, "\n"
+
+print "If a proc object is given, the proc is evaluated on the safe-level which is kept on the proc :: ip.eval_proc( proc{$SAFE} ) ==> ", ip.eval_proc(proc{$SAFE}), "\n"
+
+safe0_cmd = Proc.new{
+ print 'safe0_cmd safe-level == ', $SAFE, "\n"
+ # This proc object keeps current safe-level ($SAFE==0).
+ load file
+}
+ip.eval_proc{safe0_cmd.call}
+
+# Tk.mainloop is ignored on the slave-IP
+Tk.mainloop
diff --git a/jni/ruby/ext/tk/sample/tkoptdb.rb b/jni/ruby/ext/tk/sample/tkoptdb.rb
new file mode 100644
index 0000000..0171e46
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkoptdb.rb
@@ -0,0 +1,106 @@
+#!/usr/bin/env ruby
+#
+# sample script of TkOptionDB
+#
+# If 'LANG' environment variable's value is started by 'ja',
+# then read Japanese resource data and display Japanese button text.
+# In other case, read English resource data and display English text.
+#
+require "tk"
+
+if __FILE__ == $0 || !TkCore::INTERP.safe?
+ if ENV['LANG'] =~ /^ja/
+ # read Japanese resource
+ TkOptionDB.read_with_encoding(File.expand_path('resource.ja',
+ File.dirname(__FILE__)),
+ 'utf-8')
+ else
+ # read English resource
+ TkOptionDB.readfile(File.expand_path('resource.en',
+ File.dirname(__FILE__)))
+ end
+end
+
+# 'show_msg' and 'bye_msg' procedures can be defined on BTN_CMD resource.
+# Those procedures are called under $SAFE==2
+cmd = TkOptionDB.new_proc_class(:BTN_CMD, [:show_msg, :bye_msg], 3) {
+ # If you want to check resource string (str),
+ # please define __check_proc_string__(str) like this.
+ class << self
+ def __check_proc_string__(str)
+ print "($SAFE=#{$SAFE} >>>) check!! str.tainted?::#{str.tainted?}"
+ str.untaint
+ print "==>#{str.tainted?} (<<< $SAFE=#{$SAFE}): "
+ str
+ end
+ private :__check_proc_string__
+ end
+}
+
+# following two frame widgets use same database entry
+TkFrame.new(:class=>'BtnFrame'){|f|
+ pack(:padx=>5, :pady=>5)
+ TkButton.new(:parent=>f, :widgetname=>'hello'){
+ command proc{
+ print "($SAFE=#{$SAFE} >>>) : "
+ cmd.show_msg(TkOptionDB.inspect)
+ print "(<<< $SAFE=#{$SAFE})"
+ }
+ pack(:fill=>:x, :padx=>10, :pady=>10)
+ }
+ TkButton.new(:command=>proc{
+ print "($SAFE=#{$SAFE} >>>) : "
+ cmd.bye_msg
+ print "(<<< $SAFE=#{$SAFE} ) : "
+ exit
+ },
+ :parent=>f, :widgetname=>'quit'){
+ pack(:fill=>:x, :padx=>10, :pady=>10)
+ }
+}
+
+class BtnFrame < TkFrame; end
+BtnFrame.new{|f|
+ pack(:padx=>5, :pady=>5)
+ TkButton.new(:parent=>f, :widgetname=>'hello'){
+ command proc{
+ print "($SAFE=#{$SAFE} >>>) : "
+ cmd.show_msg(TkOptionDB.inspect)
+ print "(<<< $SAFE=#{$SAFE})"
+ }
+ pack(:fill=>:x, :padx=>10, :pady=>10)
+ }
+ TkButton.new(:command=>proc{
+ print "($SAFE=#{$SAFE} >>>) : "
+ cmd.bye_msg
+ print "(<<< $SAFE=#{$SAFE})"
+ exit
+ },
+ :parent=>f, :widgetname=>'quit'){
+ pack(:fill=>:x, :padx=>10, :pady=>10)
+ }
+}
+
+# if unknown class, use default option values
+TkFrame.new(:class=>'BtnFrame2'){|f|
+ pack(:padx=>5, :pady=>5)
+ TkButton.new(:parent=>f, :widgetname=>'hello'){
+ command proc{
+ print "($SAFE=#{$SAFE} >>>) : "
+ cmd.show_msg(TkOptionDB.inspect)
+ print "(<<< $SAFE=#{$SAFE})"
+ }
+ pack(:fill=>:x, :padx=>10, :pady=>10)
+ }
+ TkButton.new(:command=>proc{
+ print "($SAFE=#{$SAFE} >>>) : "
+ cmd.bye_msg
+ print "(<<< $SAFE=#{$SAFE})"
+ exit
+ },
+ :parent=>f, :widgetname=>'quit'){
+ pack(:fill=>:x, :padx=>10, :pady=>10)
+ }
+}
+
+Tk.mainloop
diff --git a/jni/ruby/ext/tk/sample/tkrttimer.rb b/jni/ruby/ext/tk/sample/tkrttimer.rb
new file mode 100644
index 0000000..1f9cbd9
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tkrttimer.rb
@@ -0,0 +1,77 @@
+#!/usr/bin/env ruby
+# This script is a re-implementation of tktimer.rb with TkTimer(TkAfter) class.
+
+require "tk"
+
+root = TkRoot.new(:title=>'realtime timer sample')
+
+f1 = TkFrame.new(:borderwidth=>2, :relief=>:ridge)
+f1.pack(:side=>:bottom, :fill=>:both)
+TkLabel.new(f1, :text=>'use TkTimer (TkAfter) class').pack(:anchor=>:center)
+label1 = TkLabel.new(:parent=>f1, :relief=>:raised,
+ :width=>10).pack(:fill=>:both)
+
+f2 = TkFrame.new(:borderwidth=>2, :relief=>:ridge)
+f2.pack(:side=>:bottom, :fill=>:both)
+TkLabel.new(f2, :text=>'use TkRTTimer class').pack
+label2 = TkLabel.new(:parent=>f2, :relief=>:raised,
+ :width=>10).pack(:fill=>:both)
+
+TkLabel.new(:padx=>10, :pady=>5, :justify=>'left', :text=><<EOT).pack
+Interval setting of each timer object is 10 ms.
+Each timer object counts up the value on each callback
+(the value is not the clock data).
+The count of the TkTimer object is delayed by execution
+time of callbacks and inaccuracy of interval.
+On the other hand, the count of the TkRTTimer object is
+not delayed. Its callback interval is not accurate too.
+But it can compute error correction about the time when
+a callback should start.
+EOT
+
+# define the procedure repeated by the TkTimer object
+tick = proc{|aobj| #<== TkTimer object
+ cnt = aobj.return_value + 1 # return_value keeps a result of the last proc
+ label = aobj.current_args[0]
+ label.text format("%d.%02d", *(cnt.divmod(100)))
+ cnt #==> return value is kept by TkTimer object
+ # (so, can be send to the next repeat-proc)
+}
+
+timer1 = TkTimer.new(10, -1, [tick, label1]) # 10 ms interval
+timer2 = TkRTTimer.new(10, -1, [tick, label2]) # 10 ms interval
+
+timer1.start(0, proc{ label1.text('0.00'); 0 })
+timer2.start(0, proc{ label2.text('0.00'); 0 })
+
+b_start = TkButton.new(:text=>'Start', :state=>:disabled) {
+ pack(:side=>:left, :fill=>:both, :expand=>true)
+}
+
+b_stop = TkButton.new(:text=>'Stop', :state=>:normal) {
+ pack('side'=>'left', 'fill'=>'both', 'expand'=>'yes')
+}
+
+b_start.command {
+ timer1.continue
+ timer2.continue
+ b_stop.state(:normal)
+ b_start.state(:disabled)
+}
+
+b_stop.command {
+ timer1.stop
+ timer2.stop
+ b_start.state(:normal)
+ b_stop.state(:disabled)
+}
+
+TkButton.new(:text=>'Reset', :state=>:normal) {
+ command { timer1.reset; timer2.reset }
+ pack(:side=>:right, :fill=>:both, :expand=>:yes)
+}
+
+ev_quit = TkVirtualEvent.new('Control-c', 'Control-q')
+Tk.root.bind(ev_quit, proc{Tk.exit}).focus
+
+Tk.mainloop
diff --git a/jni/ruby/ext/tk/sample/tksleep_sample.rb b/jni/ruby/ext/tk/sample/tksleep_sample.rb
new file mode 100644
index 0000000..23f6eca
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tksleep_sample.rb
@@ -0,0 +1,29 @@
+require 'tk'
+
+v = TkVariable.new(0)
+l = TkLabel.new(:textvariable=>v).pack(:pady=>[1, 10])
+
+a = TkButton.new(:text=>"button A :: proc{p ['AAA', v.value]}").pack(:fill=>:x, :pady=>[1, 15], :padx=>15)
+a.command{p ['AAA', v.value]}
+
+TkLabel.new(:text=>'Callback of the button B returns LIFO order').pack
+b = TkButton.new(:text=>"button B :: proc{n = v.value; p ['B:start', n]; Tk.sleep(10000); p ['B:end', n]}").pack(:fill=>:x, :pady=>[1, 15], :padx=>15)
+b.command{n = v.value; p ['B:start', n]; Tk.sleep(10000); p ['B:end', n]}
+
+TkLabel.new(:text=>'Callback of the button C returns FIFO order').pack
+c = TkButton.new(:text=>"button C :: proc{n = v.value; Thread.new{p ['C:start', n]; Tk.sleep(10000); p ['C:end', n]}}").pack(:fill=>:x, :pady=>[1, 15], :padx=>15)
+c.command{n = v.value; Thread.new{p ['C:start', n]; Tk.sleep(10000); p ['C:end', n]}}
+
+TkLabel.new(:text=>'Callback of the button D blocks eventloop (no respond to event)').pack
+d = TkButton.new(:text=>"button D :: proc{n = v.value; p ['D:start', n]; sleep(10); p ['D:end', n]}").pack(:fill=>:x, :pady=>[1,15], :padx=>15)
+d.command{n = v.value; p ['D:start', n]; sleep(10); p ['D:end', n]}
+
+TkLabel.new(:text=>'Callback of the button E is another way to avoid eventloop blocking').pack
+e = TkButton.new(:text=>"button E :: proc{n = v.value; Thread.new{p ['D:start', n]; sleep(10); p ['D:end', n]}}").pack(:fill=>:x, :pady=>[1,15], :padx=>15)
+e.command{n = v.value; Thread.new{p ['D:start', n]; sleep(10); p ['D:end', n]}}
+
+TkButton.new(:text=>'QUIT', :command=>proc{exit}).pack
+
+TkTimer.new(500, -1){v.numeric += 1}.start
+
+Tk.mainloop
diff --git a/jni/ruby/ext/tk/sample/tktextframe.rb b/jni/ruby/ext/tk/sample/tktextframe.rb
new file mode 100644
index 0000000..d6584be
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tktextframe.rb
@@ -0,0 +1,281 @@
+#
+# tktextframe.rb : a sample of TkComposite
+#
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+require 'tk'
+
+module Tk::ScrollbarComposite
+ include TkComposite
+
+ def component_construct_keys
+ # If a component requires options for construction,
+ # return an Array of option-keys.
+ []
+ end
+ private :component_construct_keys
+
+ def create_component(keys={})
+ # This method must return the created component widget.
+ end
+ private :create_component
+
+ def component_delegates
+ # if want to override default option-methods or delegates,
+ # please define here.
+ end
+ private :component_delegates
+
+ def define_delegates
+ # option methods for scrollbars
+ option_methods([:scrollbarwidth, :get_scrollbarwidth])
+
+ # set receiver widgets for configure methods (with alias)
+ delegate_alias('scrollbarrelief', 'relief', @h_scroll, @v_scroll)
+ delegate_alias('framebackground', 'background',
+ @frame, @h_scroll, @v_scroll)
+ delegate_alias('activeframebackground', 'activebackground',
+ @h_scroll, @v_scroll)
+
+ # set receiver widgets for configure methods
+ delegate('DEFAULT', @component)
+ delegate('troughcolor', @h_scroll, @v_scroll)
+ delegate('repeatdelay', @h_scroll, @v_scroll)
+ delegate('repeatinterval', @h_scroll, @v_scroll)
+ delegate('borderwidth', @frame)
+ delegate('relief', @frame)
+
+ component_delegates
+ end
+ private :define_delegates
+
+ DEFAULT_VSCROLL = true
+ DEFAULT_HSCROLL = true
+
+ def initialize_composite(keys={})
+ keys = _symbolkey2str(keys)
+
+ # create scrollbars
+ @v_scroll = TkScrollbar.new(@frame, 'orient'=>'vertical')
+ @h_scroll = TkScrollbar.new(@frame, 'orient'=>'horizontal')
+
+ # create a component
+ construct_keys = {}
+ ((component_construct_keys.map{|k| k.to_s}) & keys.keys).each{|k|
+ construct_keys[k] = keys.delete(k)
+ }
+
+ # create a component (the component must be scrollable)
+ @component = create_component(construct_keys)
+
+ # set default receiver of method calls
+ @path = @component.path
+
+ # assign scrollbars
+ @component.xscrollbar(@h_scroll)
+ @component.yscrollbar(@v_scroll)
+
+ # allignment
+ TkGrid.rowconfigure(@frame, 0, 'weight'=>1, 'minsize'=>0)
+ TkGrid.columnconfigure(@frame, 0, 'weight'=>1, 'minsize'=>0)
+ @component.grid('row'=>0, 'column'=>0, 'sticky'=>'news')
+
+ # scrollbars ON
+ vscroll(keys.delete('vscroll'){self.class::DEFAULT_VSCROLL})
+ hscroll(keys.delete('hscroll'){self.class::DEFAULT_HSCROLL})
+
+ # do configure
+ define_delegates
+
+ # do configure
+ configure keys unless keys.empty?
+ end
+ private :initialize_composite
+
+ # get/set width of scrollbar
+ def get_scrollbarwidth
+ @v_scroll.width
+ end
+ def set_scrollbarwidth(width)
+ @v_scroll.width(width)
+ @h_scroll.width(width)
+ end
+ alias :scrollbarwidth :set_scrollbarwidth
+
+ def hook_vscroll_on(*args); end
+ def hook_vscroll_off(*args); end
+ def hook_hscroll_on(*args); end
+ def hook_hscroll_off(*args); end
+ private :hook_vscroll_on,:hook_vscroll_off,:hook_hscroll_on,:hook_hscroll_off
+
+ # vertical scrollbar : ON/OFF
+ def vscroll(mode, *args)
+ st = TkGrid.info(@v_scroll)
+ if mode && st.size == 0 then
+ @v_scroll.grid('row'=>0, 'column'=>1, 'sticky'=>'ns')
+ hook_vscroll_on(*args)
+ elsif !mode && st.size != 0 then
+ @v_scroll.ungrid
+ hook_vscroll_off(*args)
+ end
+ self
+ end
+
+ # horizontal scrollbar : ON/OFF
+ def hscroll(mode, *args)
+ st = TkGrid.info(@h_scroll)
+ if mode && st.size == 0 then
+ @h_scroll.grid('row'=>1, 'column'=>0, 'sticky'=>'ew')
+ hook_hscroll_on(*args)
+ elsif !mode && st.size != 0 then
+ @h_scroll.ungrid
+ hook_hscroll_off(*args)
+ end
+ self
+ end
+end
+
+################################################
+
+class TkTextFrame < TkText
+ include Tk::ScrollbarComposite
+
+ # def component_construct_keys; []; end
+ # private :component_construct_keys
+
+ def create_component(keys={})
+ # keys has options which are listed by component_construct_keys method.
+ @text = TkText.new(@frame, 'wrap'=>'none')
+ @text.configure(keys) unless keys.empty?
+
+ # option methods for component
+ option_methods(
+ [:textbackground, nil, :textbg_info],
+ :textborderwidth,
+ :textrelief
+ )
+
+ # return the created componet
+ @text
+ end
+ private :create_component
+
+ # def component_delegates; end
+ # private :component_delegates
+
+ def hook_hscroll_on(wrap_mode=nil)
+ if wrap_mode
+ wrap wrap_mode
+ else
+ wrap 'none' # => self.wrap('none')
+ end
+ end
+ def hook_hscroll_off(wrap_mode)
+ wrap wrap_mode # => self.wrap(wrap_mode)
+ end
+ def hscroll(mode, wrap_mode="char")
+ super
+ end
+
+ # set background color of text widget
+ def textbackground(color = nil)
+ if color
+ @text.background(color)
+ else
+ @text.background
+ end
+ end
+
+ def textbg_info
+ info = @text.configinfo(:background)
+ if TkComm::GET_CONFIGINFO_AS_ARRAY
+ info[0] = 'textbackground'
+ info
+ else # ! TkComm::GET_CONFIGINFO_AS_ARRAY
+ {'textbackground' => info['background']}
+ end
+ end
+
+ # get/set borderwidth of text widget
+ def set_textborderwidth(width)
+ @text.borderwidth(width)
+ end
+ def get_textborderwidth
+ @text.borderwidth
+ end
+ def textborderwidth(width = nil)
+ if width
+ set_textborderwidth(width)
+ else
+ get_textborderwidth
+ end
+ end
+
+ # set relief of text widget
+ def textrelief(type)
+ @text.relief(type)
+ end
+end
+
+################################################
+# test
+################################################
+if __FILE__ == $0
+ TkLabel.new(:text=>'TkTextFrame is an example of Tk::ScrollbarComposite module.').pack
+ f = TkFrame.new.pack('fill'=>'x')
+ #t = TkTextFrame.new.pack
+ t = TkTextFrame.new(:textborderwidth=>3,
+ :textrelief=>:ridge,
+ :scrollbarrelief=>:ridge).pack
+ p t.configinfo
+ TkButton.new(f, 'text'=>'vscr OFF',
+ 'command'=>proc{t.vscroll(false)}).pack('side'=>'right')
+ TkButton.new(f, 'text'=>'vscr ON',
+ 'command'=>proc{t.vscroll(true)}).pack('side'=>'right')
+ TkButton.new(f, 'text'=>'hscr ON',
+ 'command'=>proc{t.hscroll(true)}).pack('side'=>'left')
+ TkButton.new(f, 'text'=>'hscr OFF',
+ 'command'=>proc{t.hscroll(false)}).pack('side'=>'left')
+
+ ############################################
+
+ # Tk.default_widget_set = :Ttk
+
+ TkFrame.new.pack(:pady=>10)
+ TkLabel.new(:text=>'The following is another example of Tk::ScrollbarComposite module.').pack
+
+ #----------------------------------
+ class ScrListbox < TkListbox
+ include Tk::ScrollbarComposite
+
+ DEFAULT_HSCROLL = false
+
+ def create_component(keys={})
+ TkListbox.new(@frame, keys)
+ end
+ private :create_component
+ end
+ #----------------------------------
+
+ f = TkFrame.new.pack(:pady=>5)
+ lbox = ScrListbox.new(f).pack(:side=>:left)
+ lbox.value = %w(aa bb cc dd eeeeeeeeeeeeeeeeeeeeeeeeee ffffffffff gg hh ii jj kk ll mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm nn oo pp qq)
+ fb = TkFrame.new(f).pack(:expand=>true, :fill=>:y, :padx=>5)
+ TkButton.new(fb, 'text'=>'lbox hscr OFF',
+ 'command'=>proc{lbox.hscroll(false)}).pack(:side=>:bottom,
+ :fill=>:x)
+ TkButton.new(fb, 'text'=>'lbox hscr ON',
+ 'command'=>proc{lbox.hscroll(true)}).pack(:side=>:bottom,
+ :fill=>:x)
+ TkFrame.new(fb).pack(:pady=>5, :side=>:bottom)
+ TkButton.new(fb, 'text'=>'lbox vscr OFF',
+ 'command'=>proc{lbox.vscroll(false)}).pack(:side=>:bottom,
+ :fill=>:x)
+ TkButton.new(fb, 'text'=>'lbox vscr ON',
+ 'command'=>proc{lbox.vscroll(true)}).pack(:side=>:bottom,
+ :fill=>:x)
+
+ ############################################
+
+ Tk.mainloop
+end
diff --git a/jni/ruby/ext/tk/sample/tktextio.rb b/jni/ruby/ext/tk/sample/tktextio.rb
new file mode 100644
index 0000000..679a2b7
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tktextio.rb
@@ -0,0 +1,1060 @@
+#!/usr/bin/env ruby
+#
+# TkTextIO class :: handling I/O stream on a TkText widget
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+# NOTE: TkTextIO supports 'character' (not 'byte') access only.
+# So, for example, TkTextIO#getc returns a character, TkTextIO#pos
+# means the character position, TkTextIO#read(size) counts by
+# characters, and so on.
+# Of course, it is available to make TkTextIO class to suuport
+# 'byte' access. However, it may break multi-byte characters.
+# and then, displayed string on the text widget may be garbled.
+# I think that it is not good on the supposed situation of using
+# TkTextIO.
+#
+require 'tk'
+require 'tk/text'
+require 'tk/textmark'
+require 'thread'
+
+class TkTextIO < TkText
+ # keep safe level
+ @@create_queues = proc{ [Queue.new, Mutex.new, Queue.new, Mutex.new] }
+
+ OPT_DEFAULTS = {
+ 'mode' => nil,
+ 'overwrite' => false,
+ 'text' => nil,
+ 'show' => :pos,
+ 'wrap' => 'char',
+ 'sync' => true,
+ 'prompt' => nil,
+ 'prompt_cmd' => nil,
+ 'hist_size' => 1000,
+ }
+
+ def create_self(keys)
+ opts = _get_io_params((keys.kind_of?(Hash))? keys: {})
+
+ super(keys)
+
+ @count_var = TkVariable.new
+
+ @write_buffer = ''
+ @read_buffer = ''
+ @buf_size = 0
+ @buf_max = 1024
+
+ @write_buf_queue, @write_buf_mutex,
+ @read_buf_queue, @read_buf_mutex = @@create_queues.call
+
+ @idle_flush = TkTimer.new(:idle, 1, proc{ @flusher.run rescue nil })
+ @timer_flush = TkTimer.new(250, -1, proc{ @flusher.run rescue nil })
+
+ @flusher = Thread.new{ loop { Thread.stop; flush() } }
+
+ @receiver = Thread.new{
+ begin
+ loop {
+ str = @write_buf_queue.deq
+ @write_buf_mutex.synchronize { @write_buffer << str }
+ @idle_flush.start
+ }
+ ensure
+ @flusher.kill
+ end
+ }
+
+ @timer_flush.start
+
+ _setup_io(opts)
+ end
+ private :create_self
+
+ def destroy
+ @flusher.kill rescue nil
+
+ @idle_flush.stop rescue nil
+ @timer_flush.stop rescue nil
+
+ @receiver.kill rescue nil
+
+ super()
+ end
+
+ ####################################
+
+ def _get_io_params(keys)
+ opts = {}
+ self.class.const_get(:OPT_DEFAULTS).each{|k, v|
+ if keys.has_key?(k)
+ opts[k] = keys.delete(k)
+ else
+ opts[k] = v
+ end
+ }
+ opts
+ end
+
+ def _setup_io(opts)
+ unless defined? @txtpos
+ @txtpos = TkTextMark.new(self, '1.0')
+ else
+ @txtpos.set('1.0')
+ end
+ @txtpos.gravity = :left
+
+ @lineno = 0
+ @line_offset = 0
+
+ @hist_max = opts['hist_size'].to_i
+ @hist_index = 0
+ @history = Array.new(@hist_max)
+ @history[0] = ''
+
+ self['wrap'] = wrap
+
+ self.show_mode = opts['show']
+
+ self.value = opts['text'] if opts['text']
+
+ @overwrite = (opts['overwrite'])? true: false
+
+ @sync = opts['sync']
+
+ @prompt = opts['prompt']
+ @prompt_cmd = opts['prompt_cmd']
+
+ @open = {:r => true, :w => true} # default is 'r+'
+
+ @console_mode = false
+ @end_of_stream = false
+ @console_buffer = nil
+
+ case opts['mode']
+ when nil
+ # do nothing
+
+ when :console, 'console'
+ @console_mode = true
+ # @console_buffer = TkTextIO.new(:mode=>'r')
+ @console_buffer = self.class.new(:mode=>'r')
+ self.show_mode = :insert
+
+ when 'r', 'rb'
+ @open[:r] = true; @open[:w] = nil
+
+ when 'r+', 'rb+', 'r+b'
+ @open[:r] = true; @open[:w] = true
+
+ when 'w', 'wb'
+ @open[:r] = nil; @open[:w] = true
+ self.value=''
+
+ when 'w+', 'wb+', 'w+b'
+ @open[:r] = true; @open[:w] = true
+ self.value=''
+
+ when 'a', 'ab'
+ @open[:r] = nil; @open[:w] = true
+ @txtpos.set('end - 1 char')
+ @txtpos.gravity = :right
+
+ when 'a+', 'ab+', 'a+b'
+ @open[:r] = true; @open[:w] = true
+ @txtpos.set('end - 1 char')
+ @txtpos.gravity = :right
+
+ else
+ fail ArgumentError, "unknown mode `#{opts['mode']}'"
+ end
+
+ unless defined? @ins_head
+ @ins_head = TkTextMark.new(self, 'insert')
+ @ins_head.gravity = :left
+ end
+
+ unless defined? @ins_tail
+ @ins_tail = TkTextMark.new(self, 'insert')
+ @ins_tail.gravity = :right
+ end
+
+ unless defined? @tmp_mark
+ @tmp_mark = TkTextMark.new(self, 'insert')
+ @tmp_mark.gravity = :left
+ end
+
+ if @console_mode
+ _set_console_line
+ _setup_console_bindings
+ end
+ end
+ private :_get_io_params, :_setup_io
+
+ def _set_console_line
+ @tmp_mark.set(@ins_tail)
+
+ mark_set('insert', 'end')
+
+ prompt = ''
+ prompt << @prompt_cmd.call if @prompt_cmd
+ prompt << @prompt if @prompt
+ insert(@tmp_mark, prompt)
+
+ @ins_head.set(@ins_tail)
+ @ins_tail.set('insert')
+
+ @txtpos.set(@tmp_mark)
+
+ _see_pos
+ end
+
+ def _replace_console_line(str)
+ self.delete(@ins_head, @ins_tail)
+ self.insert(@ins_head, str)
+ end
+
+ def _get_console_line
+ @tmp_mark.set(@ins_tail)
+ s = self.get(@ins_head, @tmp_mark)
+ _set_console_line
+ s
+ end
+ private :_set_console_line, :_replace_console_line, :_get_console_line
+
+ def _cb_up
+ @history[@hist_index].replace(self.get(@ins_head, @ins_tail))
+ @hist_index += 1
+ @hist_index -= 1 if @hist_index >= @hist_max || !@history[@hist_index]
+ _replace_console_line(@history[@hist_index]) if @history[@hist_index]
+ Tk.callback_break
+ end
+ def _cb_down
+ @history[@hist_index].replace(self.get(@ins_head, @ins_tail))
+ @hist_index -= 1
+ @hist_index = 0 if @hist_index < 0
+ _replace_console_line(@history[@hist_index]) if @history[@hist_index]
+ Tk.callback_break
+ end
+ def _cb_left
+ if @console_mode && compare('insert', '<=', @ins_head)
+ mark_set('insert', @ins_head)
+ Tk.callback_break
+ end
+ end
+ def _cb_backspace
+ if @console_mode && compare('insert', '<=', @ins_head)
+ Tk.callback_break
+ end
+ end
+ def _cb_ctrl_a
+ if @console_mode
+ mark_set('insert', @ins_head)
+ Tk.callback_break
+ end
+ end
+ def _cb_ctrl_u
+ if @console_mode
+ mark_set('insert', @ins_head)
+ delete('insert', 'insert lineend')
+ Tk.callback_break
+ end
+ end
+ private :_cb_up, :_cb_down, :_cb_left, :_cb_backspace,
+ :_cb_ctrl_a, :_cb_ctrl_u
+
+ def _setup_console_bindings
+ @bindtag = TkBindTag.new
+
+ tags = self.bindtags
+ tags[tags.index(self)+1, 0] = @bindtag
+ self.bindtags = tags
+
+ @bindtag.bind('Return'){
+ insert('end - 1 char', "\n")
+ if (str = _get_console_line)
+ @read_buf_queue.push(str)
+
+ @history[0].replace(str.chomp)
+ @history.pop
+ @history.unshift('')
+ @hist_index = 0
+ end
+
+ Tk.update
+ Tk.callback_break
+ }
+ @bindtag.bind('Alt-Return'){
+ Tk.callback_continue
+ }
+
+ @bindtag.bind('FocusIn'){
+ if @console_mode
+ mark_set('insert', @ins_tail)
+ Tk.callback_break
+ end
+ }
+
+ ins_mark = TkTextMark.new(self, 'insert')
+
+ @bindtag.bind('ButtonPress'){
+ if @console_mode
+ ins_mark.set('insert')
+ end
+ }
+
+ @bindtag.bind('ButtonRelease-1'){
+ if @console_mode && compare('insert', '<=', @ins_head)
+ mark_set('insert', ins_mark)
+ Tk.callback_break
+ end
+ }
+
+ @bindtag.bind('ButtonRelease-2', '%x %y'){|x, y|
+ if @console_mode
+ # paste a text at 'insert' only
+ x1, y1, x2, y2 = bbox(ins_mark)
+ unless x == x1 && y == y1
+ Tk.event_generate(self, 'ButtonRelease-2', :x=>x1, :y=>y1)
+ Tk.callback_break
+ end
+ end
+ }
+
+ @bindtag.bind('Up'){ _cb_up }
+ @bindtag.bind('Control-p'){ _cb_up }
+
+ @bindtag.bind('Down'){ _cb_down }
+ @bindtag.bind('Control-n'){ _cb_down }
+
+ @bindtag.bind('Left'){ _cb_left }
+ @bindtag.bind('Control-b'){ _cb_left }
+
+ @bindtag.bind('BackSpace'){ _cb_backspace }
+ @bindtag.bind('Control-h'){ _cb_backspace }
+
+ @bindtag.bind('Home'){ _cb_ctrl_a }
+ @bindtag.bind('Control-a'){ _cb_ctrl_a }
+
+ @bindtag.bind('Control-u'){ _cb_ctrl_u }
+ end
+ private :_setup_console_bindings
+
+ def _block_read(size = nil, ret = '', block_mode = true)
+ return '' if size == 0
+ return nil if ! @read_buf_queue && @read_buffer.empty?
+ ret = '' unless ret.kind_of?(String)
+ ret.replace('') unless ret.empty?
+
+ if block_mode == nil # partial
+ if @read_buffer.empty?
+ ret << @read_buffer.slice!(0..-1)
+ return ret
+ end
+ end
+
+ if size.kind_of?(Numeric)
+ loop{
+ @read_buf_mutex.synchronize {
+ buf_len = @read_buffer.length
+ if buf_len >= size
+ ret << @read_buffer.slice!(0, size)
+ return ret
+ else
+ ret << @read_buffer.slice!(0..-1)
+ size -= buf_len
+ return ret unless @read_buf_queue
+ end
+ }
+ @read_buffer << @read_buf_queue.pop
+ }
+ else # readline
+ rs = (size)? size: $/
+ rs = rs.to_s if rs.kind_of?(Regexp)
+ loop{
+ @read_buf_mutex.synchronize {
+ if (str = @read_buffer.slice!(/\A(.*)(#{rs})/m))
+ ret << str
+ return ret
+ else
+ ret << @read_buffer.slice!(0..-1)
+ return ret unless @read_buf_queue
+ end
+ }
+ @read_buffer << @read_buf_queue.pop
+ }
+ end
+ end
+
+ def _block_write
+ ###### currently, not support
+ end
+ private :_block_read, :_block_write
+
+ ####################################
+
+ def <<(obj)
+ _write(obj)
+ self
+ end
+
+ def binmode
+ self
+ end
+
+ def clone
+ fail NotImplementedError, 'cannot clone TkTextIO'
+ end
+ def dup
+ fail NotImplementedError, 'cannot duplicate TkTextIO'
+ end
+
+ def close
+ close_read
+ close_write
+ nil
+ end
+ def close_read
+ @open[:r] = false if @open[:r]
+ nil
+ end
+ def close_write
+ @open[:w] = false if @opne[:w]
+ nil
+ end
+
+ def closed?(dir=nil)
+ case dir
+ when :r, 'r'
+ !@open[:r]
+ when :w, 'w'
+ !@open[:w]
+ else
+ !@open[:r] && !@open[:w]
+ end
+ end
+
+ def _check_readable
+ fail IOError, "not opened for reading" if @open[:r].nil?
+ fail IOError, "closed stream" if !@open[:r]
+ end
+ def _check_writable
+ fail IOError, "not opened for writing" if @open[:w].nil?
+ fail IOError, "closed stream" if !@open[:w]
+ end
+ private :_check_readable, :_check_writable
+
+ def each_line(rs = $/)
+ _check_readable
+ while(s = self.gets(rs))
+ yield(s)
+ end
+ self
+ end
+ alias each each_line
+
+ def each_char
+ _check_readable
+ while(c = self.getc)
+ yield(c)
+ end
+ self
+ end
+ alias each_byte each_char
+
+ def eof?
+ compare(@txtpos, '==', 'end - 1 char')
+ end
+ alias eof eof?
+
+ def fcntl(*args)
+ fail NotImplementedError, "fcntl is not implemented on #{self.class}"
+ end
+
+ def fsync
+ 0
+ end
+
+ def fileno
+ nil
+ end
+
+ def flush
+ Thread.pass
+ if @open[:w] || ! @write_buffer.empty?
+ @write_buf_mutex.synchronize {
+ _sync_write_buf(@write_buffer)
+ @write_buffer[0..-1] = ''
+ }
+ end
+ self
+ end
+
+ def getc
+ return _block_read(1) if @console_mode
+
+ _check_readable
+ return nil if eof?
+ c = get(@txtpos)
+ @txtpos.set(@txtpos + '1 char')
+ _see_pos
+ c
+ end
+
+ def gets(rs = $/)
+ return _block_read(rs) if @console_mode
+
+ _check_readable
+ return nil if eof?
+ _readline(rs)
+ end
+
+ def ioctrl(*args)
+ fail NotImplementedError, 'iocntl is not implemented on TkTextIO'
+ end
+
+ def isatty
+ false
+ end
+ def tty?
+ false
+ end
+
+ def lineno
+ @lineno + @line_offset
+ end
+
+ def lineno=(num)
+ @line_offset = num - @lineno
+ num
+ end
+
+ def overwrite?
+ @overwrite
+ end
+
+ def overwrite=(ovwt)
+ @overwrite = (ovwt)? true: false
+ end
+
+ def pid
+ nil
+ end
+
+ def index_pos
+ index(@txtpos)
+ end
+ alias tell_index index_pos
+
+ def index_pos=(idx)
+ @txtpos.set(idx)
+ @txtpos.set('end - 1 char') if compare(@txtpos, '>=', :end)
+ _see_pos
+ idx
+ end
+
+ def pos
+ s = get('1.0', @txtpos)
+ number(tk_call('string', 'length', s))
+ end
+ alias tell pos
+
+ def pos=(idx)
+ seek(idx, IO::SEEK_SET)
+ idx
+ end
+
+ def pos_gravity
+ @txtpos.gravity
+ end
+
+ def pos_gravity=(side)
+ @txtpos.gravity = side
+ side
+ end
+
+ def print(arg=$_, *args)
+ _check_writable
+ args.unshift(arg)
+ args.map!{|val| (val == nil)? 'nil': val.to_s }
+ str = args.join($,)
+ str << $\ if $\
+ _write(str)
+ nil
+ end
+ def printf(*args)
+ _check_writable
+ _write(sprintf(*args))
+ nil
+ end
+
+ def putc(c)
+ _check_writable
+ c = c.chr if c.kind_of?(Fixnum)
+ _write(c)
+ c
+ end
+
+ def puts(*args)
+ _check_writable
+ if args.empty?
+ _write("\n")
+ return nil
+ end
+ args.each{|arg|
+ if arg == nil
+ _write("nil\n")
+ elsif arg.kind_of?(Array)
+ puts(*arg)
+ elsif arg.kind_of?(String)
+ _write(arg.chomp)
+ _write("\n")
+ else
+ begin
+ arg = arg.to_ary
+ puts(*arg)
+ rescue
+ puts(arg.to_s)
+ end
+ end
+ }
+ nil
+ end
+
+ def _read(len)
+ epos = @txtpos + "#{len} char"
+ s = get(@txtpos, epos)
+ @txtpos.set(epos)
+ @txtpos.set('end - 1 char') if compare(@txtpos, '>=', :end)
+ _see_pos
+ s
+ end
+ private :_read
+
+ def read(len=nil, buf=nil)
+ return _block_read(len, buf) if @console_mode
+
+ _check_readable
+ if len
+ return "" if len == 0
+ return nil if eof?
+ s = _read(len)
+ else
+ s = get(@txtpos, 'end - 1 char')
+ @txtpos.set('end - 1 char')
+ _see_pos
+ end
+ buf.replace(s) if buf.kind_of?(String)
+ s
+ end
+
+ def readchar
+ return _block_read(1) if @console_mode
+
+ _check_readable
+ fail EOFError if eof?
+ c = get(@txtpos)
+ @txtpos.set(@txtpos + '1 char')
+ _see_pos
+ c
+ end
+
+ def _readline(rs = $/)
+ if rs == nil
+ s = get(@txtpos, 'end - 1 char')
+ @txtpos.set('end - 1 char')
+ elsif rs == ''
+ @count_var.value # make it global
+ idx = tksearch_with_count([:regexp], @count_var,
+ "\n(\n)+", @txtpos, 'end - 1 char')
+ if idx
+ s = get(@txtpos, idx) << "\n"
+ @txtpos.set("#{idx} + #{@count_var.value} char")
+ @txtpos.set('end - 1 char') if compare(@txtpos, '>=', :end)
+ else
+ s = get(@txtpos, 'end - 1 char')
+ @txtpos.set('end - 1 char')
+ end
+ else
+ @count_var.value # make it global
+ idx = tksearch_with_count(@count_var, rs, @txtpos, 'end - 1 char')
+ if idx
+ s = get(@txtpos, "#{idx} + #{@count_var.value} char")
+ @txtpos.set("#{idx} + #{@count_var.value} char")
+ @txtpos.set('end - 1 char') if compare(@txtpos, '>=', :end)
+ else
+ s = get(@txtpos, 'end - 1 char')
+ @txtpos.set('end - 1 char')
+ end
+ end
+
+ _see_pos
+ @lineno += 1
+ $_ = s
+ end
+ private :_readline
+
+ def readline(rs = $/)
+ return _block_readline(rs) if @console_mode
+
+ _check_readable
+ fail EOFError if eof?
+ _readline(rs)
+ end
+
+ def readlines(rs = $/)
+ if @console_mode
+ lines = []
+ while (line = _block_readline(rs))
+ lines << line
+ end
+ return lines
+ end
+
+ _check_readable
+ lines = []
+ until(eof?)
+ lines << _readline(rs)
+ end
+ $_ = nil
+ lines
+ end
+
+ def readpartial(maxlen, buf=nil)
+ #return @console_buffer.readpartial(maxlen, buf) if @console_mode
+ return _block_read(maxlen, buf, nil) if @console_mode
+
+ _check_readable
+ fail EOFError if eof?
+ s = _read(maxlen)
+ buf.replace(s) if buf.kind_of?(String)
+ s
+ end
+
+ def reopen(*args)
+ fail NotImplementedError, 'reopen is not implemented on TkTextIO'
+ end
+
+ def rewind
+ @txtpos.set('1.0')
+ _see_pos
+ @lineno = 0
+ @line_offset = 0
+ self
+ end
+
+ def seek(offset, whence=IO::SEEK_SET)
+ case whence
+ when IO::SEEK_SET
+ offset = "1.0 + #{offset} char" if offset.kind_of?(Numeric)
+ @txtpos.set(offset)
+
+ when IO::SEEK_CUR
+ offset = "#{offset} char" if offset.kind_of?(Numeric)
+ @txtpos.set(@txtpos + offset)
+
+ when IO::SEEK_END
+ offset = "#{offset} char" if offset.kind_of?(Numeric)
+ @txtpos.set("end - 1 char + #{offset}")
+
+ else
+ fail Errno::EINVAL, 'invalid whence argument'
+ end
+
+ @txtpos.set('end - 1 char') if compare(@txtpos, '>=', :end)
+ _see_pos
+
+ 0
+ end
+ alias sysseek seek
+
+ def _see_pos
+ see(@show) if @show
+ end
+ private :_see_pos
+
+ def show_mode
+ (@show == @txtpos)? :pos : @show
+ end
+
+ def show_mode=(mode)
+ # define show mode when file position is changed.
+ # mode == :pos or "pos" or true :: see current file position.
+ # mode == :insert or "insert" :: see insert cursor position.
+ # mode == nil or false :: do nothing
+ # else see 'mode' position ('mode' should be text index or mark)
+ case mode
+ when :pos, 'pos', true
+ @show = @txtpos
+ when :insert, 'insert'
+ @show = :insert
+ when nil, false
+ @show = false
+ else
+ begin
+ index(mode)
+ rescue
+ fail ArgumentError, 'invalid show-position'
+ end
+ @show = mode
+ end
+
+ _see_pos
+
+ mode
+ end
+
+ def stat
+ fail NotImplementedError, 'stat is not implemented on TkTextIO'
+ end
+
+ def sync
+ @sync
+ end
+
+ def sync=(mode)
+ @sync = mode
+ end
+
+ def sysread(len, buf=nil)
+ return _block_read(len, buf) if @console_mode
+
+ _check_readable
+ fail EOFError if eof?
+ s = _read(len)
+ buf.replace(s) if buf.kind_of?(String)
+ s
+ end
+
+ def syswrite(obj)
+ _write(obj)
+ end
+
+ def to_io
+ self
+ end
+
+ def trancate(len)
+ delete("1.0 + #{len} char", :end)
+ 0
+ end
+
+ def ungetc(c)
+ if @console_mode
+ @read_buf_mutex.synchronize {
+ @read_buffer[0,0] = c.chr
+ }
+ return nil
+ end
+
+ _check_readable
+ c = c.chr if c.kind_of?(Fixnum)
+ if compare(@txtpos, '>', '1.0')
+ @txtpos.set(@txtpos - '1 char')
+ delete(@txtpos)
+ insert(@txtpos, tk_call('string', 'range', c, 0, 1))
+ @txtpos.set(@txtpos - '1 char') if @txtpos.gravity == 'right'
+ _see_pos
+ else
+ fail IOError, 'cannot ungetc at head of stream'
+ end
+ nil
+ end
+
+=begin
+ def _write(obj)
+ #s = _get_eval_string(obj)
+ s = (obj.kind_of?(String))? obj: obj.to_s
+ n = number(tk_call('string', 'length', s))
+ delete(@txtpos, @txtpos + "#{n} char") if @overwrite
+ self.insert(@txtpos, s)
+ @txtpos.set(@txtpos + "#{n} char")
+ @txtpos.set('end - 1 char') if compare(@txtpos, '>=', :end)
+ _see_pos
+ Tk.update if @sync
+ n
+ end
+ private :_write
+=end
+#=begin
+ def _sync_write_buf(s)
+ if (n = number(tk_call('string', 'length', s))) > 0
+ delete(@txtpos, @txtpos + "#{n} char") if @overwrite
+ self.insert(@txtpos, s)
+ #Tk.update
+
+ @txtpos.set(@txtpos + "#{n} char")
+ @txtpos.set('end - 1 char') if compare(@txtpos, '>=', :end)
+
+ @ins_head.set(@txtpos) if compare(@txtpos, '>', @ins_head)
+
+ _see_pos
+ end
+ self
+ end
+ private :_sync_write_buf
+
+ def _write(obj)
+ s = (obj.kind_of?(String))? obj: obj.to_s
+ n = number(tk_call('string', 'length', s))
+ @write_buf_queue.enq(s)
+ if @sync
+ Thread.pass
+ Tk.update
+ end
+ n
+ end
+ private :_write
+#=end
+
+ def write(obj)
+ _check_writable
+ _write(obj)
+ end
+end
+
+####################
+# TEST
+####################
+if __FILE__ == $0
+ ev_loop = Thread.new{Tk.mainloop}
+
+ f = TkFrame.new.pack
+ #tio = TkTextIO.new(f, :show=>:nil,
+ #tio = TkTextIO.new(f, :show=>:pos,
+ tio = TkTextIO.new(f, :show=>:insert,
+ :text=>">>> This is an initial text line. <<<\n\n"){
+# yscrollbar(TkScrollbar.new(f).pack(:side=>:right, :fill=>:y))
+ pack(:side=>:left, :fill=>:both, :expand=>true)
+ }
+
+ Tk.update
+
+ $stdin = tio
+ $stdout = tio
+ $stderr = tio
+
+ STDOUT.print("\n========= TkTextIO#gets for inital text ========\n\n")
+
+ while(s = gets)
+ STDOUT.print(s)
+ end
+
+ STDOUT.print("\n============ put strings to TkTextIO ===========\n\n")
+
+ puts "On this sample, a text widget works as if it is a I/O stream."
+ puts "Please see the code."
+ puts
+ printf("printf message: %d %X\n", 123456, 255)
+ puts
+ printf("(output by 'p' method) This TkTextIO object is ...\n")
+ p tio
+ print(" [ Current wrap mode of this object is 'char'. ]\n")
+ puts
+ warn("This is a warning message generated by 'warn' method.")
+ puts
+ puts "current show_mode is #{tio.show_mode}."
+ if tio.show_mode == :pos
+ puts "So, you can see the current file position on this text widget."
+ else
+ puts "So, you can see the position '#{tio.show_mode}' on this text widget."
+ end
+ print("Please scroll up this text widget to see the head of lines.\n")
+ print("---------------------------------------------------------\n")
+
+ STDOUT.print("\n=============== TkTextIO#readlines =============\n\n")
+
+ tio.seek(0)
+ lines = readlines
+ STDOUT.puts(lines.inspect)
+
+ STDOUT.print("\n================== TkTextIO#each ===============\n\n")
+
+ tio.rewind
+ tio.each{|line| STDOUT.printf("%2d: %s\n", tio.lineno, line.chomp)}
+
+ STDOUT.print("\n================================================\n\n")
+
+ STDOUT.print("\n========= reverse order (seek by lines) ========\n\n")
+
+ tio.seek(-1, IO::SEEK_END)
+ begin
+ begin
+ tio.seek(:linestart, IO::SEEK_CUR)
+ rescue
+ # maybe use old version of tk/textmark.rb
+ tio.seek('0 char linestart', IO::SEEK_CUR)
+ end
+ STDOUT.print(gets)
+ tio.seek('-1 char linestart -1 char', IO::SEEK_CUR)
+ end while(tio.pos > 0)
+
+ STDOUT.print("\n================================================\n\n")
+
+ tio.seek(0, IO::SEEK_END)
+
+ STDOUT.print("tio.sync == #{tio.sync}\n")
+# tio.sync = false
+# STDOUT.print("tio.sync == #{tio.sync}\n")
+
+ (0..10).each{|i|
+ STDOUT.print("#{i}\n")
+ s = ''
+ (0..1000).each{ s << '*' }
+ print(s)
+ }
+ print("\n")
+ print("\n=========================================================\n\n")
+
+ s = ''
+ timer = TkTimer.new(:idle, -1, proc{
+ #STDOUT.print("idle call\n")
+ unless s.empty?
+ print(s)
+ s = ''
+ end
+ }).start
+ (0..10).each{|i|
+ STDOUT.print("#{i}\n")
+ (0..1000).each{ s << '*' }
+ }
+# timer.stop
+ until s.empty?
+ sleep 0.1
+ end
+ timer.stop
+
+=begin
+ tio.sync = false
+ print("\n")
+ #(0..10000).each{ putc('*') }
+ (0..10).each{|i|
+ STDOUT.print("#{i}\n")
+ (0..1000).each{ putc('*') }
+ }
+
+ (0..10).each{|i|
+ STDOUT.print("#{i}\n")
+ s = ''
+ (0..1000).each{ s << '*' }
+ print(s)
+ }
+=end
+
+ num = 0
+# io = TkTextIO.new(:mode=>:console, :prompt=>'').pack
+#=begin
+ io = TkTextIO.new(:mode=>:console,
+ :prompt_cmd=>proc{
+ s = "[#{num}]"
+ num += 1
+ s
+ },
+ :prompt=>'-> ').pack
+#=end
+ Thread.new{loop{sleep 2; io.puts 'hoge'}}
+ Thread.new{loop{p io.gets}}
+
+ ev_loop.join
+end
diff --git a/jni/ruby/ext/tk/sample/tktimer.rb b/jni/ruby/ext/tk/sample/tktimer.rb
new file mode 100644
index 0000000..b1adb5b
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tktimer.rb
@@ -0,0 +1,50 @@
+#!/usr/bin/env ruby
+# This script generates a counter with start and stop buttons.
+
+require "tk"
+$label = TkLabel.new {
+ text '0.00'
+ relief 'raised'
+ width 10
+ pack('side'=>'bottom', 'fill'=>'both')
+}
+
+TkButton.new {
+ text 'Start'
+ command proc {
+ if $stopped
+ $stopped = FALSE
+ tick
+ end
+ }
+ pack('side'=>'left','fill'=>'both','expand'=>'yes')
+}
+TkButton.new {
+ text 'Stop'
+ command proc{
+ exit if $stopped
+ $stopped = TRUE
+ }
+ pack('side'=>'right','fill'=>'both','expand'=>'yes')
+}
+
+$seconds=0
+$hundredths=0
+$stopped=TRUE
+
+def tick
+ if $stopped then return end
+ Tk.after 50, proc{tick}
+ $hundredths+=5
+ if $hundredths >= 100
+ $hundredths=0
+ $seconds+=1
+ end
+ $label.text format("%d.%02d", $seconds, $hundredths)
+end
+
+root = Tk.root
+root.bind "Control-c", proc{root.destroy}
+root.bind "Control-q", proc{root.destroy}
+Tk.root.focus
+Tk.mainloop
diff --git a/jni/ruby/ext/tk/sample/tktimer2.rb b/jni/ruby/ext/tk/sample/tktimer2.rb
new file mode 100644
index 0000000..125115e
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tktimer2.rb
@@ -0,0 +1,47 @@
+#!/usr/bin/env ruby
+# This script is a re-implementation of tktimer.rb with TkTimer(TkAfter) class.
+
+require "tk"
+
+# new notation :
+# * symbols are acceptable as keys or values of the option hash
+# * the parent widget can be given by :parent key on the option hash
+root = TkRoot.new(:title=>'timer sample')
+label = TkLabel.new(:parent=>root, :relief=>:raised, :width=>10) \
+ .pack(:side=>:bottom, :fill=>:both)
+
+# define the procedure repeated by the TkTimer object
+tick = proc{|aobj| #<== TkTimer object
+ cnt = aobj.return_value + 5 # return_value keeps a result of the last proc
+ label.text format("%d.%02d", *(cnt.divmod(100)))
+ cnt #==> return value is kept by TkTimer object
+ # (so, can be send to the next repeat-proc)
+}
+
+timer = TkTimer.new(50, -1, tick).start(0, proc{ label.text('0.00'); 0 })
+ # ==> repeat-interval : (about) 50 ms,
+ # repeat : infinite (-1) times,
+ # repeat-procedure : tick (only one, in this case)
+ #
+ # ==> wait-before-call-init-proc : 0 ms,
+ # init_proc : proc{ label.text('0.00'); 0 }
+ #
+ # (0ms)-> init_proc ->(50ms)-> tick ->(50ms)-> tick ->....
+
+TkButton.new(:text=>'Start') {
+ command proc{ timer.continue unless timer.running? }
+ pack(:side=>:left, :fill=>:both, :expand=>true)
+}
+TkButton.new(:text=>'Restart') {
+ command proc{ timer.restart(0, proc{ label.text('0.00'); 0 }) }
+ pack(:side=>:left, :fill=>:both, :expand=>true)
+}
+TkButton.new(:text=>'Stop') {
+ command proc{ timer.stop if timer.running? }
+ pack('side'=>'right','fill'=>'both','expand'=>'yes')
+}
+
+ev_quit = TkVirtualEvent.new('Control-c', 'Control-q')
+Tk.root.bind(ev_quit, proc{Tk.exit}).focus
+
+Tk.mainloop
diff --git a/jni/ruby/ext/tk/sample/tktimer3.rb b/jni/ruby/ext/tk/sample/tktimer3.rb
new file mode 100644
index 0000000..08e8a3c
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tktimer3.rb
@@ -0,0 +1,59 @@
+#!/usr/bin/env ruby
+# This script is a re-implementation of tktimer.rb with TkTimer(TkAfter) class.
+
+require "tk"
+
+# new notation :
+# * symbols are acceptable as keys or values of the option hash
+# * the parent widget can be given by :parent key on the option hash
+root = TkRoot.new(:title=>'timer sample')
+label = TkLabel.new(:parent=>root, :relief=>:raised, :width=>10) \
+ .pack(:side=>:bottom, :fill=>:both)
+
+# define the procedure repeated by the TkTimer object
+tick = proc{|aobj| #<== TkTimer object
+ cnt = aobj.return_value + 5 # return_value keeps a result of the last proc
+ label.text format("%d.%02d", *(cnt.divmod(100)))
+ cnt #==> return value is kept by TkTimer object
+ # (so, can be send to the next repeat-proc)
+}
+
+timer = TkTimer.new(50, -1, tick).start(0, proc{ label.text('0.00'); 0 })
+ # ==> repeat-interval : (about) 50 ms,
+ # repeat : infinite (-1) times,
+ # repeat-procedure : tick (only one, in this case)
+ #
+ # ==> wait-before-call-init-proc : 0 ms,
+ # init_proc : proc{ label.text('0.00'); 0 }
+ #
+ # (0ms)-> init_proc ->(50ms)-> tick ->(50ms)-> tick ->....
+
+b_start = TkButton.new(:text=>'Start', :state=>:disabled) {
+ pack(:side=>:left, :fill=>:both, :expand=>true)
+}
+
+b_stop = TkButton.new(:text=>'Stop', :state=>:normal) {
+ pack('side'=>'left', 'fill'=>'both', 'expand'=>'yes')
+}
+
+b_start.command {
+ timer.continue
+ b_stop.state(:normal)
+ b_start.state(:disabled)
+}
+
+b_stop.command {
+ timer.stop
+ b_start.state(:normal)
+ b_stop.state(:disabled)
+}
+
+TkButton.new(:text=>'Reset', :state=>:normal) {
+ command { timer.reset }
+ pack(:side=>:right, :fill=>:both, :expand=>:yes)
+}
+
+ev_quit = TkVirtualEvent.new('Control-c', 'Control-q')
+Tk.root.bind(ev_quit, proc{Tk.exit}).focus
+
+Tk.mainloop
diff --git a/jni/ruby/ext/tk/sample/tktree.rb b/jni/ruby/ext/tk/sample/tktree.rb
new file mode 100644
index 0000000..4eb7f60
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tktree.rb
@@ -0,0 +1,103 @@
+##########################################################################
+# TkTree widget class
+#
+# see <http://wiki.tcl.tk/10615>
+#
+# Note: optional argument '-font' of the Tcl library is changed to
+# 'itemfont' on this Ruby library, because of avoiding font
+# operation trouble in 'initialize' method ( see the following
+# test script ).
+#
+##########################################################################
+require 'tk'
+
+class TkTree < TkCanvas
+ TCL_SCRIPT_PATH = File.join(File.dirname(__FILE__), 'tktree.tcl')
+
+ def create_self(keys)
+ args = [@path]
+ if keys.kind_of?(Hash)
+ font = keys.delete('itemfont')
+# font = hash_kv(font) if font.kind_of?(Hash)
+ keys['font'] = font if font
+# args.concat(hash_kv(keys))
+ args << keys
+ end
+ begin
+ tk_call('::tktree::treecreate', *args)
+ rescue NameError, RuntimeError
+ Tk.load_tclscript(TkTree::TCL_SCRIPT_PATH)
+ tk_call('::tktree::treecreate', *args)
+ end
+ end
+
+ def newitem(itempath, keys = nil)
+ if keys.kind_of?(Hash)
+ keys = _symbolkey2str(keys)
+ font = keys.delete('itemfont')
+# font = hash_kv(font) if font.kind_of?(Hash)
+ keys['font'] = font if font
+# tk_call('::tktree::newitem', @path, itempath, *hash_kv(keys))
+ tk_call('::tktree::newitem', @path, itempath, keys)
+ else
+ tk_call('::tktree::newitem', @path, itempath)
+ end
+ end
+
+ def delitem(itempath)
+ tk_call('::tktree::delitem', @path, itempath)
+ end
+
+ def labelat(xpos, ypos)
+ tk_call('::tktree::delitem', @path, xpos, ypos)
+ end
+
+ def getselection
+ tk_call('::tktree::getselection', @path)
+ end
+
+ def setselection(itempath)
+ tk_call('::tktree::getselection', @path, itempath)
+ end
+end
+
+
+##########################################################################
+# test script
+##########################################################################
+if __FILE__ == $0
+ TkLabel.new(:text=><<EOL, :relief=>:ridge, :justify=>:left).pack
+
+ This is a sample to use a Tcl library script on Ruby/Tk.
+ This sample loads tktree.tcl (see <http://wiki.tcl.tk/10615>)
+ and calls functions of the Tcl script.
+EOL
+
+ items = %w(/group1/item1 /group1/item2 /group1/subgroup/item1 /group2/item1 /item1)
+
+ tr1 = TkTree.new.pack(:expand=>true, :fill=>:both)
+ tr1.focus
+
+ items.each{|item|
+ tr1.newitem(item,
+ :command=>proc{Tk.messageBox(:message=>"#{item} executed")})
+ }
+
+ f = TkFrame.new.pack(:expand=>true, :fill=>:both)
+ tr2 = TkTree.new(f, :bg=>'black', #:itemfont=>{:family=>'Times', :size=>14},
+ :textcolor=>'red', :bd=>4, :relief=>:ridge,
+ :selectbackground=>'darkBlue', :selectforeground=>'yellow',
+ :selectborderwidth=>3, :linecolor=>'yellow') {
+ yscrollbar(TkScrollbar.new(f, :width=>10).pack(:side=>:right, :fill=>:y))
+ xscrollbar(TkScrollbar.new(f, :width=>10).pack(:side=>:bottom, :fill=>:x))
+ pack(:expand=>true, :fill=>:both)
+ }
+
+ items.each{|item|
+ tr2.newitem(item, :textcolor=>'green', :image=>'',
+ :itemfont=>{:family=>'Times', :size=>10},
+ :command=>proc{Tk.messageBox(:message=>"#{item} executed")})
+ }
+
+ Tk.mainloop
+end
diff --git a/jni/ruby/ext/tk/sample/tktree.tcl b/jni/ruby/ext/tk/sample/tktree.tcl
new file mode 100644
index 0000000..a5e47eb
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/tktree.tcl
@@ -0,0 +1,305 @@
+#
+# This Tcl/Tk script is quoted from <http://wiki.tcl.tk/10615>.
+#
+ package require Tk
+ namespace eval ::tktree {
+
+ # Images used for open and close state of subgroups
+ set ::tktree::imgcollapse [image create photo .tktreeopenbm -data {
+ R0lGODdhCQAJAIAAAAEBAf///ywAAAAACQAJAAACEISPoRvG614D80x5ZXyogwIAOw==}]
+ set ::tktree::imgexpand [image create photo .tktreeclosebm -data {
+ R0lGODdhCQAJAIAAAAEBAf///ywAAAAACQAJAAACEYSPoRu28KCSDSJLc44s3lMAADs=}]
+ ###Default images for groups and children
+ set ::tktree::imgsubgroups [image create photo .tktreeimgfolder -data {
+ R0lGODlhEAANAKIAANnZ2Xh4eLi4uPj4APj4+AAAAP///////yH5BAEAAAAA
+ LAAAAAAQAA0AAANkCIChiqDLITgyEgi6GoIjIyMYugCBpMsaWBA0giMjIzgy
+ UYBBMjIoIyODEgVBODIygiMjE1gQJIMyMjIoI1GAQSMjODIyghMFQSgjI4My
+ MhJYEDSCIyMjODJRgKHLXAiApcsMmAA7}]
+ set ::tktree::imgchildren [image create photo .tktreeimgfile -data {
+ R0lGODlhDQAQAKIAANnZ2Xh4ePj4+Li4uAAAAP///////////yH5BAEAAAAA
+ LAAAAAANABAAAANSGLoLgACBoqsRCBAoujqCASGDojtESCEihCREIjgUKLo8
+ hCGCpCsySIGiy0MYIki6IoMUKLo8hCGCpCsySIGiy0MYKLo8hIGiy0MYOLo8
+ SLrMCQA7}]
+
+ #### Swtich all subgroups of a layer to open or close
+ proc ::tktree::switchlayer {win opn {layer /}} {
+ variable cfg
+ foreach child $cfg($win,$layer:subgroups) {
+ set cfg($win,$child:open) $opn
+ switchlayer $win $opn $child
+ }
+ buildwhenidle $win
+ }
+
+ #### will open or close the item given
+ proc ::tktree::switchstate {win item} {
+ set ::tktree::cfg($win,$item:open) [expr ! $::tktree::cfg($win,$item:open)]
+ buildwhenidle $win
+ }
+
+ #### Select the next item up or down
+ proc ::tktree::updown {win down} {
+ variable cfg
+ set index [lsearch -exact $cfg($win,sortlist) $cfg($win,selection)]
+ if {$down} {incr index} {incr index -1}
+ if {$index < 0} {set index end} elseif {$index >= [llength $cfg($win,sortlist)]} {set index 0}
+ setselection $win [lindex $cfg($win,sortlist) $index]
+ }
+
+ #### left-right button binding commands
+ proc ::tktree::leftright {win right} {
+ variable cfg
+ set item $cfg($win,selection)
+ set index [lsearch -exact $cfg($win,sortlist) $item]
+ set parentindex [lsearch -exact $cfg($win,sortlist) [file dirname $item]]
+ if {$parentindex == -1} {set parentindex [expr $index - 1]}
+ if {$cfg($win,$item:group)} {
+ if {$right} {
+ if {$cfg($win,$item:open)} {incr index} {set cfg($win,$item:open) 1}
+ } else {
+ if {$cfg($win,$item:open)} {set cfg($win,$item:open) 0} {set index $parentindex}
+ }
+ } else {
+ if {$right} {incr index} {set index $parentindex}
+ }
+ if {$index < 0} {set index end} elseif {$index >= [llength $cfg($win,sortlist)]} {set index 0}
+ setselection $win [lindex $cfg($win,sortlist) $index]
+ buildwhenidle $win
+ }
+
+ #### will return the pathname of the item at x and y cooridinates
+ proc ::tktree::labelat {win x y} {
+ set x [$win canvasx $x]; set y [$win canvasy $y]
+ foreach m [$win find overlapping $x $y $x $y] {
+ if {[info exists ::tktree::cfg($win,tag:$m)]} {return $::tktree::cfg($win,tag:$m)}
+ }
+ return ""
+ }
+
+ #### will return the path of the current selection in the given tree widget
+ proc ::tktree::getselection {win} {
+ return $::tktree::cfg($win,selection)
+ }
+
+ #### adjust the scrollview to show the selected item as needed
+ proc ::tktree::scrolladjust {win tag} {
+ update
+ set item [$win bbox $tag]
+ set region [$win cget -scrollregion]
+ foreach {axis idx1 idx2} {yview 1 3 xview 0 2} {
+ set range [expr abs([lindex $region $idx2]) - abs([lindex $region $idx1])]
+ set itemtop [lindex $item $idx1]; set itembot [lindex $item $idx2]
+ set viewtop [expr $range * [lindex [$win $axis] 0]]
+ set viewbot [expr $range * [lindex [$win $axis] 1]]
+ if {$itembot > $viewbot} {$win $axis moveto [expr ($itembot. - $viewbot + $viewtop) / $range]}
+ if {$itemtop < $viewtop} {$win $axis moveto [expr $itemtop. / $range]}
+ }
+ }
+
+ #### will set the current selection to the given item on the given tree
+ proc ::tktree::setselection {win item} {
+ variable cfg
+ if {![llength $cfg($win,sortlist)]} {return}
+ if {$item eq ""} {set item [lindex $cfg($win,sortlist) 0]}
+ if {![info exists cfg($win,$item:tag)]} {set item [lindex $cfg($win,sortlist) 0]}
+ if {[$win gettags $cfg($win,$item:tag)] ne ""} {
+ $win select from $cfg($win,$item:tag) 0
+ $win select to $cfg($win,$item:tag) end
+ set cfg($win,selection) $item
+ scrolladjust $win $cfg($win,$item:tag)
+ } {
+ setselection $win "/[lindex $cfg($win,/:sortlist) 0]"
+ }
+ }
+
+ #### will delete the item given from the tree given
+ proc ::tktree::delitem {win item} {
+ variable cfg
+ if {$item eq "/"} {
+ array unset cfg $win,* ; catch {destroy $win}
+ } {
+ set group [file dirname $item]
+ if {$cfg($win,$item:group)} {set type subgroups} {set type children}
+ set index [lsearch -exact $cfg($win,$group:$type) $item]
+ set cfg($win,$group:$type) [lreplace $cfg($win,$group:$type) $index $index]
+ array unset cfg $win,$item*
+ buildwhenidle $win
+ }
+ }
+
+ #### create a new item in the tree and rebuild the widget
+ proc ::tktree::newitem {win item args} {
+ variable cfg
+ if {[string index $item 0] ne "/"} {set item /$item}
+ if {[string index $item end] eq "/"} {
+ set subgroup 1
+ set type subgroups
+ set item [string range $item 0 end-1]
+ set cfg($win,$item:command) [list ::tktree::switchstate $win $item]
+ } {
+ set subgroup 0
+ set type children
+ set cfg($win,$item:command) {}
+ }
+ #Build parent group if needed
+ set group [file dirname $item]
+ if {![info exists cfg($win,$group:open)]} {newitem $win "$group\/"}
+ lappend cfg($win,$group:$type) $item
+ #Configure the new item
+ set cfg($win,$item:group) $subgroup
+ set cfg($win,$item:subgroups) {}
+ set cfg($win,$item:children) {}
+ set cfg($win,$item:sortlist) {}
+ set cfg($win,$item:tags) {}
+ set cfg($win,$item:open) 0
+ set cfg($win,$item:image) {}
+ set cfg($win,$item:textcolor) $cfg($win,textcolor)
+ set cfg($win,$item:font) $cfg($win,font)
+ if {$cfg($win,images)} {set cfg($win,$item:image) [eval list \$::tktree::img$type]}
+ foreach {confitem confval} $args {
+ switch -exact -- $confitem {
+ -textcolor {set cfg($win,$item:textcolor) $confval}
+ -command {set cfg($win,$item:command) $confval}
+ -image {set cfg($win,$item:image) $confval}
+ -font {set cfg($win,$item:font) $confval}
+ }
+ }
+ buildwhenidle $win
+ }
+
+ #### Draw the given layer of the tree on the canvas starting at xposition
+ proc ::tktree::buildlayer {win layer xpos} {
+ variable cfg
+ #Record y positions for vertical line later on
+ set ystart $cfg($win,y); set yend $cfg($win,y)
+ if {$layer eq "/"} {set cfg($win,sortlist) ""}
+ foreach child $cfg($win,$layer:sortlist) {
+ lappend cfg($win,sortlist) $child
+ #Check spacing required for images
+ set imgwidth 0; set imgheight 0
+ if {[string length $cfg($win,$child:image)]} {
+ set imgwidth [expr ([image width $cfg($win,$child:image)] + 2) / 2]
+ set imgheight [expr ([image height $cfg($win,$child:image)] + 2) / 2]
+ }
+ #find X-axis points for image, horiz line, and text
+ if {$imgwidth} {
+ set centerX [expr $imgwidth + $xpos + 7]
+ set rightX [expr $xpos + 7]
+ set textX [expr ($imgwidth * 2) + $xpos + 10]
+ } {
+ set centerX [expr $xpos + 10]
+ set rightX [expr $centerX + 4]
+ set textX [expr $rightX + 1]
+ }
+ #Find the proper amount to increment the y axis
+ set fontheight [lindex [font metrics $cfg($win,$child:font)] 5]
+ set yincr [expr ($fontheight + 1) / 2]
+ if {$imgheight > $yincr} {set yincr $imgheight}
+ incr cfg($win,y) $yincr
+ #Draw the horizonal line
+ $win create line $xpos $cfg($win,y) $rightX $cfg($win,y) -fill $cfg($win,linecolor)
+ set yend $cfg($win,y)
+ #Draw the image, if it exists
+ if {$imgwidth} {
+ set it [$win create image $centerX $cfg($win,y) -image $cfg($win,$child:image)]
+ $win bind $it <1> [list ::tktree::setselection $win $child]
+ }
+ #Draw text and store tags for reference
+ set cfg($win,$child:tag) [$win create text $textX $cfg($win,y) \
+ -text [file tail $child] -font $cfg($win,$child:font) -anchor w -tags x -fill $cfg($win,$child:textcolor)]
+ set cfg($win,tag:$cfg($win,$child:tag)) $child
+ #Command binding
+ $win bind $cfg($win,$child:tag) <1> [list ::tktree::setselection $win $child]
+ $win bind $cfg($win,$child:tag) <Double-1> $cfg($win,$child:command)
+ #next step up on the y axis
+ incr cfg($win,y) $yincr
+ #If its a group, add open-close functionality
+ if {$cfg($win,$child:group)} {
+ if {$cfg($win,$child:open)} {set img collapse} {set img expand}
+ set ocimg [$win create image $xpos [expr $cfg($win,y) - $yincr] -image [eval list \$::tktree::img$img]]
+ $win bind $ocimg <1> [list ::tktree::switchstate $win $child]
+ if {$cfg($win,$child:open)} {buildlayer $win $child $centerX}
+ }
+ }
+ #Vertical line
+ $win lower [$win create line $xpos [expr $ystart - 7] $xpos $yend -fill $cfg($win,linecolor)]
+ }
+
+ #### sort the layer by subgroups then children
+ proc ::tktree::sortlayer {win {layer /}} {
+ variable cfg
+ set cfg($win,$layer:subgroups) [lsort -dictionary $cfg($win,$layer:subgroups)]
+ set cfg($win,$layer:children) [lsort -dictionary $cfg($win,$layer:children)]
+ set cfg($win,$layer:sortlist) [join [list $cfg($win,$layer:subgroups) $cfg($win,$layer:children)]]
+ foreach group $cfg($win,$layer:subgroups) {sortlayer $win $group}
+ }
+
+ #### build the tree at the given path
+ proc ::tktree::buildtree {win} {
+ variable cfg
+ $win delete all
+ sortlayer $win
+ set xpos 5
+ set cfg($win,y) 5
+ #Draw global expand/contract button, if needed
+ if {[string length $cfg($win,/:subgroups)] && $cfg($win,expandall)} {
+ set exp 0
+ foreach subgroup $cfg($win,/:subgroups) {incr exp $cfg($win,$subgroup:open)}
+ if {$exp} {set type collapse} {set type expand}
+ set ocimg [$win create image 1 1 -image [eval list \$::tktree::img$type] -anchor w]
+ $win bind $ocimg <1> [list ::tktree::switchlayer $win [expr ! $exp]]
+ }
+ #Build the layers and set initial selection
+ buildlayer $win / $xpos
+ $win config -scrollregion [$win bbox all]
+ setselection $win $cfg($win,selection)
+ }
+
+ #### internal use - set up a handle to build the tree when everything is idle
+ proc ::tktree::buildwhenidle {win} {
+ catch {after cancel $::tktree::cfg($win,buildHandle)}
+ set ::tktree::cfg($win,buildHandle) [after idle [list ::tktree::buildtree $win]]
+ }
+
+ #### will create a new tree widget at the given path
+ proc ::tktree::treecreate {win args} {
+ variable cfg
+ #Default configuration for new tree
+ set cfg($win,selection) {}
+ set cfg($win,selidx) {}
+ set cfg($win,/:subgroups) {}
+ set cfg($win,/:children) {}
+ set cfg($win,/:open) 1
+ set cfg($win,images) 1
+ set cfg($win,expandall) 1
+ set cfg($win,linecolor) black
+ set cfg($win,textcolor) black
+ set cfg($win,font) {-family Helvetica -size 10}
+ #Parse and setup custom configuration options
+ set canvascfg ""
+ foreach {item val} $args {
+ switch -- $item {
+ -linecolor {set cfg($win,linecolor) $val}
+ -textcolor {set cfg($win,textcolor) $val}
+ -font {set cfg($win,font) $val}
+ -images {set cfg($win,images) $val}
+ -expandall {set cfg($win,expandall) $val}
+ default {lappend canvascfg $item $val}
+ }
+ }
+ #Build the canvas
+ eval {canvas $win -takefocus 1} $canvascfg
+ bind $win <Destroy> [list ::tktree::delitem $win /]
+ bind $win <1> [list focus $win]
+ bind $win <Return> {eval $::tktree::cfg(%W,[::tktree::getselection %W]:command)}
+ bind $win <space> {eval $::tktree::cfg(%W,[::tktree::getselection %W]:command)}
+ bind $win <Up> [list ::tktree::updown $win 0]
+ bind $win <Down> [list ::tktree::updown $win 1]
+ bind $win <Left> [list ::tktree::leftright $win 0]
+ bind $win <Right> [list ::tktree::leftright $win 1]
+
+ #Build the tree when idle
+ buildwhenidle $win
+ }
+ }
+
diff --git a/jni/ruby/ext/tk/sample/ttk_wrapper.rb b/jni/ruby/ext/tk/sample/ttk_wrapper.rb
new file mode 100644
index 0000000..e4eb9c7
--- /dev/null
+++ b/jni/ruby/ext/tk/sample/ttk_wrapper.rb
@@ -0,0 +1,154 @@
+#!/usr/bin/env ruby
+#
+# ttk_wrapper.rb -- use Ttk widgets as default on old Ruby/Tk scripts
+#
+# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
+#
+version = '0.1.3'
+#
+##########################################################################
+# parse commandline arguments
+##########################################################################
+require 'optparse'
+opt = OptionParser.new("Usage: #{$0} [options] rubytk_script" << "\n " <<
+ "Ruby/Tk script wrapper. Use Ttk widgets as default.")
+opt.version = version
+
+OPTS = {}
+OPTS[:themedir] = []
+OPTS[:rb_theme] = []
+OPTS[:theme] = 'default'
+
+opt.on('-l', '--list', 'list available theme names'){|v| OPTS[:list] = true}
+opt.on('-t', '--theme theme', 'theme name'){|v| OPTS[:theme] = v}
+opt.on('-d', '--themedir themes_dir', 'directory of theme definitions'){|v|
+ OPTS[:themedir] << v
+}
+opt.on('-r', '--rubytheme rb_theme', 'theme definition file (ruby script)'){|v|
+ OPTS[:rb_theme] << v
+}
+opt.on('-v', '--verbose', 'print verbose messages'){|v| OPTS[:verbose] = true}
+
+opt.parse!(ARGV)
+
+
+##########################################################################
+# load Ttk (Tile) extension
+##########################################################################
+require 'tk'
+
+begin
+ require 'tkextlib/tile'
+ Tk.default_widget_set = :Ttk
+rescue LoadError
+ if OPTS[:verbose]
+ print "warning: fail to load 'Ttk' extension. use standard widgets.\n"
+ end
+end
+
+if OPTS[:verbose]
+ print "current default widget set is '#{Tk.default_widget_set}'\n"
+end
+
+
+##########################################################################
+# define Tcl/Tk procedures for compatibility.
+# those are required when want to use themes included
+# in "sample/tkextlib/tile/demo.rb".
+##########################################################################
+Tk::Tile.__define_LoadImages_proc_for_compatibility__!
+Tk::Tile::Style.__define_wrapper_proc_for_compatibility__!
+
+
+##########################################################################
+# use themes defined on the demo of Ttk (Tile) extension
+##########################################################################
+demodir = File.dirname(__FILE__)
+demo_themesdir = File.expand_path(File.join(demodir, 'tkextlib', 'tile', 'themes'))
+
+Tk::AUTO_PATH.lappend(*OPTS[:themedir]) unless OPTS[:themedir].empty?
+Tk::AUTO_PATH.lappend('.', demodir, demo_themesdir)
+
+OPTS[:themedir] << demo_themesdir
+print "theme-dirs: #{OPTS[:themedir].inspect}\n" if OPTS[:verbose]
+
+OPTS[:themedir].each{|themesdir|
+ if File.directory?(themesdir)
+ Dir.foreach(themesdir){|name|
+ next if name == '.' || name == '..'
+ path = File.join(themesdir, name)
+ Tk::AUTO_PATH.lappend(path) if File.directory?(path)
+ }
+ end
+}
+
+# This forces an update of the available packages list. It's required
+# for package names to find the themes in demos/themes/*.tcl
+Tk.ip_eval("#{TkPackage.unknown_proc} Tcl #{TkPackage.provide('Tcl')}")
+
+# load themes written in Ruby.
+themes_by_ruby = [File.join(demo_themesdir, 'kroc.rb')]
+themes_by_ruby.concat OPTS[:rb_theme]
+print "ruby-themes: #{themes_by_ruby.inspect}\n" if OPTS[:verbose]
+
+themes_by_ruby.each{|f|
+ begin
+ load(f, true)
+ rescue LoadError
+ print "fail to load \"#{f}\"\n" if OPTS[:verbose]
+ end
+}
+
+
+##########################################################################
+# ignore unsupported options of Ttk widgets
+##########################################################################
+TkConfigMethod.__set_IGNORE_UNKNOWN_CONFIGURE_OPTION__! true
+TkItemConfigMethod.__set_IGNORE_UNKNOWN_CONFIGURE_OPTION__! true
+
+
+##########################################################################
+# set theme of widget style
+##########################################################################
+if OPTS[:list] || OPTS[:verbose]
+ print "supported theme names: #{Tk::Tile.themes.inspect}\n"
+ exit if OPTS[:list] && ARGV.empty?
+end
+print "use theme: \"#{OPTS[:theme]}\"\n" if OPTS[:theme] && OPTS[:verbose]
+#setTheme(OPTS[:theme]) if OPTS[:theme]
+Tk::Tile.set_theme(OPTS[:theme]) if OPTS[:theme]
+
+
+##########################################################################
+# replace $0 and $RPAGRAM_NAME
+##########################################################################
+# When the expand_path of the target script is long, ruby sometimes
+# fails to set the path to $0 (the path string is trimmed).
+# The following replaces $0 and $PROGNAME to avoid such trouble.
+progname_obj = $0.dup
+$program_name = progname_obj
+
+alias $REAL_PROGRAM_NAME $0
+alias $PROGRAM_NAME $program_name
+alias $0 $program_name
+
+trace_var(:$program_name){|val|
+ unless progname_obj.object_id == val.object_id
+ progname_obj.replace(val.to_s)
+ $program_name = progname_obj
+ end
+}
+
+
+##########################################################################
+# load script
+##########################################################################
+if (path = ARGV.shift) && (script = File.expand_path(path))
+ print "load script \"#{script}\"\n" if OPTS[:verbose]
+ $0 = script
+ load(script)
+else
+ print "Error: no script is given.\n"
+ print opt.help
+ exit(1)
+end
diff --git a/jni/ruby/ext/tk/stubs.c b/jni/ruby/ext/tk/stubs.c
new file mode 100644
index 0000000..89da88a
--- /dev/null
+++ b/jni/ruby/ext/tk/stubs.c
@@ -0,0 +1,592 @@
+/************************************************
+
+ stubs.c - Tcl/Tk stubs support
+
+************************************************/
+
+#include "ruby.h"
+#include "stubs.h"
+
+#if !defined(RSTRING_PTR)
+#define RSTRING_PTR(s) (RSTRING(s)->ptr)
+#define RSTRING_LEN(s) (RSTRING(s)->len)
+#endif
+
+#include <tcl.h>
+#include <tk.h>
+
+/*------------------------------*/
+
+#ifdef __MACOS__
+# include <tkMac.h>
+# include <Quickdraw.h>
+
+static int call_macinit = 0;
+
+static void
+_macinit(void)
+{
+ if (!call_macinit) {
+ tcl_macQdPtr = &qd; /* setup QuickDraw globals */
+ Tcl_MacSetEventProc(TkMacConvertEvent); /* setup event handler */
+ call_macinit = 1;
+ }
+}
+#endif
+
+/*------------------------------*/
+
+static int nativethread_checked = 0;
+
+static void
+_nativethread_consistency_check(ip)
+ Tcl_Interp *ip;
+{
+ if (nativethread_checked || ip == (Tcl_Interp *)NULL) {
+ return;
+ }
+
+ /* If the variable "tcl_platform(threaded)" exists,
+ then the Tcl interpreter was compiled with threads enabled. */
+ if (Tcl_GetVar2(ip, "tcl_platform", "threaded", TCL_GLOBAL_ONLY) != (char*)NULL) {
+#ifdef HAVE_NATIVETHREAD
+ /* consistent */
+#else
+ rb_warn("Inconsistency. Loaded Tcl/Tk libraries are enabled nativethread-support. But `tcltklib' is not. The inconsistency causes SEGV or other troubles frequently.");
+#endif
+ } else {
+#ifdef HAVE_NATIVETHREAD
+ rb_warning("Inconsistency.`tcltklib' is enabled nativethread-support. But loaded Tcl/Tk libraries are not. (Probably, the inconsistency doesn't cause any troubles.)");
+#else
+ /* consistent */
+#endif
+ }
+
+ Tcl_ResetResult(ip);
+
+ nativethread_checked = 1;
+}
+
+/*------------------------------*/
+
+#if defined USE_TCL_STUBS && defined USE_TK_STUBS
+
+#if defined _WIN32 || defined __CYGWIN__
+# ifdef HAVE_RUBY_RUBY_H
+# include "ruby/util.h"
+# else
+# include "util.h"
+# endif
+# include <windows.h>
+ typedef HINSTANCE DL_HANDLE;
+# define DL_OPEN LoadLibrary
+# define DL_SYM GetProcAddress
+# define TCL_INDEX 4
+# define TK_INDEX 3
+# define TCL_NAME "tcl89"
+# define TK_NAME "tk89"
+# undef DLEXT
+# define DLEXT ".dll"
+#elif defined HAVE_DLOPEN
+# include <dlfcn.h>
+ typedef void *DL_HANDLE;
+# define DL_OPEN(file) dlopen(file, RTLD_LAZY|RTLD_GLOBAL)
+# define DL_SYM dlsym
+# define TCL_INDEX 8
+# define TK_INDEX 7
+# define TCL_NAME "libtcl8.9"
+# define TK_NAME "libtk8.9"
+# ifdef __APPLE__
+# undef DLEXT
+# define DLEXT ".dylib"
+# endif
+#endif
+
+static DL_HANDLE tcl_dll = (DL_HANDLE)0;
+static DL_HANDLE tk_dll = (DL_HANDLE)0;
+
+int
+#ifdef HAVE_PROTOTYPES
+ruby_open_tcl_dll(char *appname)
+#else
+ruby_open_tcl_dll(appname)
+ char *appname;
+#endif
+{
+ void (*p_Tcl_FindExecutable)(const char *);
+ int n;
+ char *ruby_tcl_dll = 0;
+
+ if (tcl_dll) return TCLTK_STUBS_OK;
+
+ ruby_tcl_dll = getenv("RUBY_TCL_DLL");
+#if defined _WIN32
+ if (ruby_tcl_dll) ruby_tcl_dll = ruby_strdup(ruby_tcl_dll);
+#endif
+ if (ruby_tcl_dll) {
+ tcl_dll = (DL_HANDLE)DL_OPEN(ruby_tcl_dll);
+ } else {
+ char tcl_name[] = TCL_NAME DLEXT;
+ /* examine from 8.9 to 8.1 */
+ for (n = '9'; n > '0'; n--) {
+ tcl_name[TCL_INDEX] = n;
+ tcl_dll = (DL_HANDLE)DL_OPEN(tcl_name);
+ if (tcl_dll)
+ break;
+ }
+ }
+
+#if defined _WIN32
+ if (ruby_tcl_dll) ruby_xfree(ruby_tcl_dll);
+#endif
+
+ if (!tcl_dll)
+ return NO_TCL_DLL;
+
+ p_Tcl_FindExecutable = (void (*)(const char *))DL_SYM(tcl_dll, "Tcl_FindExecutable");
+ if (!p_Tcl_FindExecutable)
+ return NO_FindExecutable;
+
+ if (appname) {
+ p_Tcl_FindExecutable(appname);
+ } else {
+ p_Tcl_FindExecutable("ruby");
+ }
+
+ return TCLTK_STUBS_OK;
+}
+
+int
+ruby_open_tk_dll(void)
+{
+ int n;
+ char *ruby_tk_dll = 0;
+
+ if (!tcl_dll) {
+ /* int ret = ruby_open_tcl_dll(RSTRING_PTR(rb_argv0)); */
+ int ret = ruby_open_tcl_dll(rb_argv0 ? RSTRING_PTR(rb_argv0) : 0);
+ if (ret != TCLTK_STUBS_OK) return ret;
+ }
+
+ if (tk_dll) return TCLTK_STUBS_OK;
+
+ ruby_tk_dll = getenv("RUBY_TK_DLL");
+ if (ruby_tk_dll) {
+ tk_dll = (DL_HANDLE)DL_OPEN(ruby_tk_dll);
+ } else {
+ char tk_name[] = TK_NAME DLEXT;
+ /* examine from 8.9 to 8.1 */
+ for (n = '9'; n > '0'; n--) {
+ tk_name[TK_INDEX] = n;
+ tk_dll = (DL_HANDLE)DL_OPEN(tk_name);
+ if (tk_dll)
+ break;
+ }
+ }
+
+ if (!tk_dll)
+ return NO_TK_DLL;
+
+ return TCLTK_STUBS_OK;
+}
+
+int
+#ifdef HAVE_PROTOTYPES
+ruby_open_tcltk_dll(char *appname)
+#else
+ruby_open_tcltk_dll(appname)
+ char *appname;
+#endif
+{
+ return( ruby_open_tcl_dll(appname) || ruby_open_tk_dll() );
+}
+
+int
+tcl_stubs_init_p(void)
+{
+ return(tclStubsPtr != (TclStubs*)NULL);
+}
+
+int
+tk_stubs_init_p(void)
+{
+ return(tkStubsPtr != (TkStubs*)NULL);
+}
+
+
+Tcl_Interp *
+#ifdef HAVE_PROTOTYPES
+ruby_tcl_create_ip_and_stubs_init(int *st)
+#else
+ruby_tcl_create_ip_and_stubs_init(st)
+ int *st;
+#endif
+{
+ Tcl_Interp *tcl_ip;
+
+ if (st) *st = 0;
+
+ if (tcl_stubs_init_p()) {
+ tcl_ip = Tcl_CreateInterp();
+
+ if (!tcl_ip) {
+ if (st) *st = FAIL_CreateInterp;
+ return (Tcl_Interp*)NULL;
+ }
+
+ _nativethread_consistency_check(tcl_ip);
+
+ return tcl_ip;
+
+ } else {
+ Tcl_Interp *(*p_Tcl_CreateInterp)();
+ Tcl_Interp *(*p_Tcl_DeleteInterp)();
+
+ if (!tcl_dll) {
+ /* int ret = ruby_open_tcl_dll(RSTRING_PTR(rb_argv0)); */
+ int ret = ruby_open_tcl_dll(rb_argv0 ? RSTRING_PTR(rb_argv0) : 0);
+
+ if (ret != TCLTK_STUBS_OK) {
+ if (st) *st = ret;
+ return (Tcl_Interp*)NULL;
+ }
+ }
+
+ p_Tcl_CreateInterp
+ = (Tcl_Interp *(*)())DL_SYM(tcl_dll, "Tcl_CreateInterp");
+ if (!p_Tcl_CreateInterp) {
+ if (st) *st = NO_CreateInterp;
+ return (Tcl_Interp*)NULL;
+ }
+
+ p_Tcl_DeleteInterp
+ = (Tcl_Interp *(*)())DL_SYM(tcl_dll, "Tcl_DeleteInterp");
+ if (!p_Tcl_DeleteInterp) {
+ if (st) *st = NO_DeleteInterp;
+ return (Tcl_Interp*)NULL;
+ }
+
+ tcl_ip = (*p_Tcl_CreateInterp)();
+ if (!tcl_ip) {
+ if (st) *st = FAIL_CreateInterp;
+ return (Tcl_Interp*)NULL;
+ }
+
+ if (!Tcl_InitStubs(tcl_ip, "8.1", 0)) {
+ if (st) *st = FAIL_Tcl_InitStubs;
+ (*p_Tcl_DeleteInterp)(tcl_ip);
+ return (Tcl_Interp*)NULL;
+ }
+
+ _nativethread_consistency_check(tcl_ip);
+
+ return tcl_ip;
+ }
+}
+
+int
+ruby_tcl_stubs_init(void)
+{
+ int st;
+ Tcl_Interp *tcl_ip;
+
+ if (!tcl_stubs_init_p()) {
+ tcl_ip = ruby_tcl_create_ip_and_stubs_init(&st);
+
+ if (!tcl_ip) return st;
+
+ Tcl_DeleteInterp(tcl_ip);
+ }
+
+ return TCLTK_STUBS_OK;
+}
+
+int
+#ifdef HAVE_PROTOTYPES
+ruby_tk_stubs_init(Tcl_Interp *tcl_ip)
+#else
+ruby_tk_stubs_init(tcl_ip)
+ Tcl_Interp *tcl_ip;
+#endif
+{
+ Tcl_ResetResult(tcl_ip);
+
+ if (tk_stubs_init_p()) {
+ if (Tk_Init(tcl_ip) == TCL_ERROR) {
+ return FAIL_Tk_Init;
+ }
+ } else {
+ int (*p_Tk_Init)(Tcl_Interp *);
+
+ if (!tk_dll) {
+ int ret = ruby_open_tk_dll();
+ if (ret != TCLTK_STUBS_OK) return ret;
+ }
+
+ p_Tk_Init = (int (*)(Tcl_Interp *))DL_SYM(tk_dll, "Tk_Init");
+ if (!p_Tk_Init)
+ return NO_Tk_Init;
+
+#if defined USE_TK_STUBS && defined TK_FRAMEWORK && defined(__APPLE__)
+ /*
+ FIX ME : dirty hack for Mac OS X frameworks.
+ With stubs, fails to find Resource/Script directory of Tk.framework.
+ So, teach it to a Tcl interpreter by an environment variable.
+ e.g. when $tcl_library ==
+ /Library/Frameworks/Tcl.framwwork/8.5/Resources/Scripts
+ ==> /Library/Frameworks/Tk.framwwork/8.5/Resources/Scripts
+ */
+ if (Tcl_Eval(tcl_ip,
+ "if {[array get env TK_LIBRARY] == {}} { set env(TK_LIBRARY) [regsub -all -nocase {(t)cl} $tcl_library {\\1k}] }"
+ ) != TCL_OK) {
+ return FAIL_Tk_Init;
+ }
+#endif
+
+ if ((*p_Tk_Init)(tcl_ip) == TCL_ERROR)
+ return FAIL_Tk_Init;
+
+ if (!Tk_InitStubs(tcl_ip, (char *)"8.1", 0))
+ return FAIL_Tk_InitStubs;
+
+#ifdef __MACOS__
+ _macinit();
+#endif
+ }
+
+ return TCLTK_STUBS_OK;
+}
+
+int
+#ifdef HAVE_PROTOTYPES
+ruby_tk_stubs_safeinit(Tcl_Interp *tcl_ip)
+#else
+ruby_tk_stubs_safeinit(tcl_ip)
+ Tcl_Interp *tcl_ip;
+#endif
+{
+ Tcl_ResetResult(tcl_ip);
+
+ if (tk_stubs_init_p()) {
+ if (Tk_SafeInit(tcl_ip) == TCL_ERROR)
+ return FAIL_Tk_Init;
+ } else {
+ int (*p_Tk_SafeInit)(Tcl_Interp *);
+
+ if (!tk_dll) {
+ int ret = ruby_open_tk_dll();
+ if (ret != TCLTK_STUBS_OK) return ret;
+ }
+
+ p_Tk_SafeInit = (int (*)(Tcl_Interp *))DL_SYM(tk_dll, "Tk_SafeInit");
+ if (!p_Tk_SafeInit)
+ return NO_Tk_Init;
+
+ if ((*p_Tk_SafeInit)(tcl_ip) == TCL_ERROR)
+ return FAIL_Tk_Init;
+
+ if (!Tk_InitStubs(tcl_ip, (char *)"8.1", 0))
+ return FAIL_Tk_InitStubs;
+
+#ifdef __MACOS__
+ _macinit();
+#endif
+ }
+
+ return TCLTK_STUBS_OK;
+}
+
+int
+ruby_tcltk_stubs(void)
+{
+ int st;
+ Tcl_Interp *tcl_ip;
+
+ /* st = ruby_open_tcltk_dll(RSTRING_PTR(rb_argv0)); */
+ st = ruby_open_tcltk_dll(rb_argv0 ? RSTRING_PTR(rb_argv0) : 0);
+ switch(st) {
+ case NO_FindExecutable:
+ return -7;
+ case NO_TCL_DLL:
+ case NO_TK_DLL:
+ return -1;
+ }
+
+ tcl_ip = ruby_tcl_create_ip_and_stubs_init(&st);
+ if (!tcl_ip) {
+ switch(st) {
+ case NO_CreateInterp:
+ case NO_DeleteInterp:
+ return -2;
+ case FAIL_CreateInterp:
+ return -3;
+ case FAIL_Tcl_InitStubs:
+ return -5;
+ }
+ }
+
+ st = ruby_tk_stubs_init(tcl_ip);
+ switch(st) {
+ case NO_Tk_Init:
+ Tcl_DeleteInterp(tcl_ip);
+ return -4;
+ case FAIL_Tk_Init:
+ case FAIL_Tk_InitStubs:
+ Tcl_DeleteInterp(tcl_ip);
+ return -6;
+ }
+
+ Tcl_DeleteInterp(tcl_ip);
+
+ return 0;
+}
+
+/*###################################################*/
+#else /* ! USE_TCL_STUBS || ! USE_TK_STUBS) */
+/*###################################################*/
+
+static int open_tcl_dll = 0;
+static int call_tk_stubs_init = 0;
+
+int
+#ifdef HAVE_PROTOTYPES
+ruby_open_tcl_dll(char *appname)
+#else
+ruby_open_tcl_dll(appname)
+ char *appname;
+#endif
+{
+ if (appname) {
+ Tcl_FindExecutable(appname);
+ } else {
+ Tcl_FindExecutable("ruby");
+ }
+ open_tcl_dll = 1;
+
+ return TCLTK_STUBS_OK;
+}
+
+int
+ruby_open_tk_dll(void)
+{
+ if (!open_tcl_dll) {
+ /* ruby_open_tcl_dll(RSTRING_PTR(rb_argv0)); */
+ ruby_open_tcl_dll(rb_argv0 ? RSTRING_PTR(rb_argv0) : 0);
+ }
+
+ return TCLTK_STUBS_OK;
+}
+
+int
+#ifdef HAVE_PROTOTYPES
+ruby_open_tcltk_dll(char *appname)
+#else
+ruby_open_tcltk_dll(appname)
+ char *appname;
+#endif
+{
+ return( ruby_open_tcl_dll(appname) || ruby_open_tk_dll() );
+}
+
+int
+tcl_stubs_init_p(void)
+{
+ return 1;
+}
+
+int
+tk_stubs_init_p(void)
+{
+ return call_tk_stubs_init;
+}
+
+Tcl_Interp *
+#ifdef HAVE_PROTOTYPES
+ruby_tcl_create_ip_and_stubs_init(int *st)
+#else
+ruby_tcl_create_ip_and_stubs_init(st)
+ int *st;
+#endif
+{
+ Tcl_Interp *tcl_ip;
+
+ if (!open_tcl_dll) {
+ /* ruby_open_tcl_dll(RSTRING_PTR(rb_argv0)); */
+ ruby_open_tcl_dll(rb_argv0 ? RSTRING_PTR(rb_argv0) : 0);
+ }
+
+ if (st) *st = 0;
+ tcl_ip = Tcl_CreateInterp();
+ if (!tcl_ip) {
+ if (st) *st = FAIL_CreateInterp;
+ return (Tcl_Interp*)NULL;
+ }
+
+ _nativethread_consistency_check(tcl_ip);
+
+ return tcl_ip;
+}
+
+int
+ruby_tcl_stubs_init(void)
+{
+ return TCLTK_STUBS_OK;
+}
+
+int
+#ifdef HAVE_PROTOTYPES
+ruby_tk_stubs_init(Tcl_Interp *tcl_ip)
+#else
+ruby_tk_stubs_init(tcl_ip)
+ Tcl_Interp *tcl_ip;
+#endif
+{
+ if (Tk_Init(tcl_ip) == TCL_ERROR)
+ return FAIL_Tk_Init;
+
+ if (!call_tk_stubs_init) {
+#ifdef __MACOS__
+ _macinit();
+#endif
+ call_tk_stubs_init = 1;
+ }
+
+ return TCLTK_STUBS_OK;
+}
+
+int
+#ifdef HAVE_PROTOTYPES
+ruby_tk_stubs_safeinit(Tcl_Interp *tcl_ip)
+#else
+ruby_tk_stubs_safeinit(tcl_ip)
+ Tcl_Interp *tcl_ip;
+#endif
+{
+#if TCL_MAJOR_VERSION >= 8
+ if (Tk_SafeInit(tcl_ip) == TCL_ERROR)
+ return FAIL_Tk_Init;
+
+ if (!call_tk_stubs_init) {
+#ifdef __MACOS__
+ _macinit();
+#endif
+ call_tk_stubs_init = 1;
+ }
+
+ return TCLTK_STUBS_OK;
+
+#else /* TCL_MAJOR_VERSION < 8 */
+
+ return FAIL_Tk_Init;
+#endif
+}
+
+int
+ruby_tcltk_stubs(void)
+{
+ /* Tcl_FindExecutable(RSTRING_PTR(rb_argv0)); */
+ Tcl_FindExecutable(rb_argv0 ? RSTRING_PTR(rb_argv0) : 0);
+ return 0;
+}
+
+#endif
diff --git a/jni/ruby/ext/tk/stubs.h b/jni/ruby/ext/tk/stubs.h
new file mode 100644
index 0000000..b4a85db
--- /dev/null
+++ b/jni/ruby/ext/tk/stubs.h
@@ -0,0 +1,33 @@
+#include <tcl.h>
+
+extern int ruby_open_tcl_dll(char *);
+extern int ruby_open_tk_dll(void);
+extern int ruby_open_tcltk_dll(char *);
+extern int tcl_stubs_init_p(void);
+extern int tk_stubs_init_p(void);
+extern Tcl_Interp *ruby_tcl_create_ip_and_stubs_init(int*);
+extern int ruby_tcl_stubs_init(void);
+extern int ruby_tk_stubs_init(Tcl_Interp*);
+extern int ruby_tk_stubs_safeinit(Tcl_Interp*);
+extern int ruby_tcltk_stubs(void);
+
+/* no error */
+#define TCLTK_STUBS_OK (0)
+
+/* return value of ruby_open_tcl_dll() */
+#define NO_TCL_DLL (1)
+#define NO_FindExecutable (2)
+
+/* return value of ruby_open_tk_dll() */
+#define NO_TK_DLL (-1)
+
+/* status value of ruby_tcl_create_ip_and_stubs_init(st) */
+#define NO_CreateInterp (3)
+#define NO_DeleteInterp (4)
+#define FAIL_CreateInterp (5)
+#define FAIL_Tcl_InitStubs (6)
+
+/* return value of ruby_tk_stubs_init() */
+#define NO_Tk_Init (7)
+#define FAIL_Tk_Init (8)
+#define FAIL_Tk_InitStubs (9)
diff --git a/jni/ruby/ext/tk/tcltklib.c b/jni/ruby/ext/tk/tcltklib.c
new file mode 100644
index 0000000..2d45f75
--- /dev/null
+++ b/jni/ruby/ext/tk/tcltklib.c
@@ -0,0 +1,11130 @@
+/*
+ * tcltklib.c
+ * Aug. 27, 1997 Y. Shigehiro
+ * Oct. 24, 1997 Y. Matsumoto
+ */
+
+#define TCLTKLIB_RELEASE_DATE "2010-08-25"
+/* #define CREATE_RUBYTK_KIT */
+
+#include "ruby.h"
+
+#ifdef HAVE_RUBY_ENCODING_H
+#include "ruby/encoding.h"
+#endif
+#ifndef RUBY_VERSION
+#define RUBY_VERSION "(unknown version)"
+#endif
+#ifndef RUBY_RELEASE_DATE
+#define RUBY_RELEASE_DATE "unknown release-date"
+#endif
+
+#undef RUBY_UNTYPED_DATA_WARNING
+#define RUBY_UNTYPED_DATA_WARNING 0
+
+#ifdef HAVE_RB_THREAD_CHECK_TRAP_PENDING
+static int rb_thread_critical; /* dummy */
+int rb_thread_check_trap_pending(void);
+#else
+/* use rb_thread_critical on Ruby 1.8.x */
+#include "rubysig.h"
+#define rb_thread_check_trap_pending() (0+rb_trap_pending)
+#endif
+
+#if !defined(RSTRING_PTR)
+#define RSTRING_PTR(s) (RSTRING(s)->ptr)
+#define RSTRING_LEN(s) (RSTRING(s)->len)
+#endif
+#if !defined(RSTRING_LENINT)
+#define RSTRING_LENINT(s) ((int)RSTRING_LEN(s))
+#endif
+#if !defined(RARRAY_PTR)
+#define RARRAY_PTR(s) (RARRAY(s)->ptr)
+#define RARRAY_LEN(s) (RARRAY(s)->len)
+#endif
+
+#ifdef OBJ_UNTRUST
+#define RbTk_OBJ_UNTRUST(x) do {OBJ_TAINT(x); OBJ_UNTRUST(x);} while (0)
+#else
+#define RbTk_OBJ_UNTRUST(x) OBJ_TAINT(x)
+#endif
+#define RbTk_ALLOC_N(type, n) (type *)ckalloc((int)(sizeof(type) * (n)))
+
+#if defined(HAVE_RB_PROC_NEW) && !defined(RUBY_VM)
+/* Ruby 1.8 :: rb_proc_new() was hidden from intern.h at 2008/04/22 */
+extern VALUE rb_proc_new _((VALUE (*)(ANYARGS/* VALUE yieldarg[, VALUE procarg] */), VALUE));
+#endif
+
+#undef EXTERN /* avoid conflict with tcl.h of tcl8.2 or before */
+#include <stdio.h>
+#ifdef HAVE_STDARG_PROTOTYPES
+#include <stdarg.h>
+#define va_init_list(a,b) va_start(a,b)
+#else
+#include <varargs.h>
+#define va_init_list(a,b) va_start(a)
+#endif
+#include <string.h>
+
+#if !defined HAVE_VSNPRINTF && !defined vsnprintf
+# ifdef WIN32
+ /* In Win32, vsnprintf is available as the "non-ANSI" _vsnprintf. */
+# define vsnprintf _vsnprintf
+# else
+# ifdef HAVE_RUBY_RUBY_H
+# include "ruby/missing.h"
+# else
+# include "missing.h"
+# endif
+# endif
+#endif
+
+#include <tcl.h>
+#include <tk.h>
+
+#ifndef HAVE_RUBY_NATIVE_THREAD_P
+#define ruby_native_thread_p() is_ruby_native_thread()
+#undef RUBY_USE_NATIVE_THREAD
+#else
+#define RUBY_USE_NATIVE_THREAD 1
+#endif
+
+#ifndef HAVE_RB_ERRINFO
+#define rb_errinfo() (ruby_errinfo+0) /* cannot be l-value */
+#else
+VALUE rb_errinfo(void);
+#endif
+#ifndef HAVE_RB_SAFE_LEVEL
+#define rb_safe_level() (ruby_safe_level+0)
+#endif
+#ifndef HAVE_RB_SOURCEFILE
+#define rb_sourcefile() (ruby_sourcefile+0)
+#endif
+
+#include "stubs.h"
+
+#ifndef TCL_ALPHA_RELEASE
+#define TCL_ALPHA_RELEASE 0 /* "alpha" */
+#define TCL_BETA_RELEASE 1 /* "beta" */
+#define TCL_FINAL_RELEASE 2 /* "final" */
+#endif
+
+static struct {
+ int major;
+ int minor;
+ int type; /* ALPHA==0, BETA==1, FINAL==2 */
+ int patchlevel;
+} tcltk_version = {0, 0, 0, 0};
+
+static void
+set_tcltk_version(void)
+{
+ if (tcltk_version.major) return;
+
+ Tcl_GetVersion(&(tcltk_version.major),
+ &(tcltk_version.minor),
+ &(tcltk_version.patchlevel),
+ &(tcltk_version.type));
+}
+
+#if TCL_MAJOR_VERSION >= 8
+# ifndef CONST84
+# if TCL_MAJOR_VERSION == 8 && TCL_MINOR_VERSION <= 4 /* Tcl8.0.x -- 8.4b1 */
+# define CONST84
+# else /* unknown (maybe TCL_VERSION >= 8.5) */
+# ifdef CONST
+# define CONST84 CONST
+# else
+# define CONST84
+# endif
+# endif
+# endif
+#else /* TCL_MAJOR_VERSION < 8 */
+# ifdef CONST
+# define CONST84 CONST
+# else
+# define CONST
+# define CONST84
+# endif
+#endif
+
+#ifndef CONST86
+# if TCL_MAJOR_VERSION == 8 && TCL_MINOR_VERSION <= 5 /* Tcl8.0.x -- 8.5.x */
+# define CONST86
+# else
+# define CONST86 CONST84
+# endif
+#endif
+
+/* copied from eval.c */
+#define TAG_RETURN 0x1
+#define TAG_BREAK 0x2
+#define TAG_NEXT 0x3
+#define TAG_RETRY 0x4
+#define TAG_REDO 0x5
+#define TAG_RAISE 0x6
+#define TAG_THROW 0x7
+#define TAG_FATAL 0x8
+
+/* for ruby_debug */
+#define DUMP1(ARG1) if (ruby_debug) { fprintf(stderr, "tcltklib: %s\n", ARG1); fflush(stderr); }
+#define DUMP2(ARG1, ARG2) if (ruby_debug) { fprintf(stderr, "tcltklib: ");\
+fprintf(stderr, ARG1, ARG2); fprintf(stderr, "\n"); fflush(stderr); }
+#define DUMP3(ARG1, ARG2, ARG3) if (ruby_debug) { fprintf(stderr, "tcltklib: ");\
+fprintf(stderr, ARG1, ARG2, ARG3); fprintf(stderr, "\n"); fflush(stderr); }
+/*
+#define DUMP1(ARG1)
+#define DUMP2(ARG1, ARG2)
+#define DUMP3(ARG1, ARG2, ARG3)
+*/
+
+/* release date */
+static const char tcltklib_release_date[] = TCLTKLIB_RELEASE_DATE;
+
+/* finalize_proc_name */
+static const char finalize_hook_name[] = "INTERP_FINALIZE_HOOK";
+
+static void ip_finalize _((Tcl_Interp*));
+static void ip_free _((void *p));
+
+static int at_exit = 0;
+
+#ifdef HAVE_RUBY_ENCODING_H
+static VALUE cRubyEncoding;
+
+/* encoding */
+static int ENCODING_INDEX_UTF8;
+static int ENCODING_INDEX_BINARY;
+#endif
+static VALUE ENCODING_NAME_UTF8;
+static VALUE ENCODING_NAME_BINARY;
+
+static VALUE create_dummy_encoding_for_tk_core _((VALUE, VALUE, VALUE));
+static VALUE create_dummy_encoding_for_tk _((VALUE, VALUE));
+static int update_encoding_table _((VALUE, VALUE, VALUE));
+static VALUE encoding_table_get_name_core _((VALUE, VALUE, VALUE));
+static VALUE encoding_table_get_obj_core _((VALUE, VALUE, VALUE));
+static VALUE encoding_table_get_name _((VALUE, VALUE));
+static VALUE encoding_table_get_obj _((VALUE, VALUE));
+static VALUE create_encoding_table _((VALUE));
+static VALUE ip_get_encoding_table _((VALUE));
+
+
+/* for callback break & continue */
+static VALUE eTkCallbackReturn;
+static VALUE eTkCallbackBreak;
+static VALUE eTkCallbackContinue;
+
+static VALUE eLocalJumpError;
+
+static VALUE eTkLocalJumpError;
+static VALUE eTkCallbackRetry;
+static VALUE eTkCallbackRedo;
+static VALUE eTkCallbackThrow;
+
+static VALUE tcltkip_class;
+
+static ID ID_at_enc;
+static ID ID_at_interp;
+
+static ID ID_encoding_name;
+static ID ID_encoding_table;
+
+static ID ID_stop_p;
+static ID ID_alive_p;
+static ID ID_kill;
+static ID ID_join;
+static ID ID_value;
+
+static ID ID_call;
+static ID ID_backtrace;
+static ID ID_message;
+
+static ID ID_at_reason;
+static ID ID_return;
+static ID ID_break;
+static ID ID_next;
+
+static ID ID_to_s;
+static ID ID_inspect;
+
+static VALUE ip_invoke_real _((int, VALUE*, VALUE));
+static VALUE ip_invoke _((int, VALUE*, VALUE));
+static VALUE ip_invoke_with_position _((int, VALUE*, VALUE, Tcl_QueuePosition));
+static VALUE tk_funcall _((VALUE(), int, VALUE*, VALUE));
+static VALUE callq_safelevel_handler _((VALUE, VALUE));
+
+/* Tcl's object type */
+#if TCL_MAJOR_VERSION >= 8
+static const char Tcl_ObjTypeName_ByteArray[] = "bytearray";
+static CONST86 Tcl_ObjType *Tcl_ObjType_ByteArray;
+
+static const char Tcl_ObjTypeName_String[] = "string";
+static CONST86 Tcl_ObjType *Tcl_ObjType_String;
+
+#if TCL_MAJOR_VERSION > 8 || (TCL_MAJOR_VERSION == 8 && TCL_MINOR_VERSION >= 1)
+#define IS_TCL_BYTEARRAY(obj) ((obj)->typePtr == Tcl_ObjType_ByteArray)
+#define IS_TCL_STRING(obj) ((obj)->typePtr == Tcl_ObjType_String)
+#define IS_TCL_VALID_STRING(obj) ((obj)->bytes != (char*)NULL)
+#endif
+#endif
+
+#ifndef HAVE_RB_HASH_LOOKUP
+#define rb_hash_lookup rb_hash_aref
+#endif
+
+#ifndef HAVE_RB_THREAD_ALIVE_P
+#define rb_thread_alive_p(thread) rb_funcall2((thread), ID_alive_p, 0, NULL)
+#endif
+
+/* safe Tcl_Eval and Tcl_GlobalEval */
+static int
+#ifdef HAVE_PROTOTYPES
+tcl_eval(Tcl_Interp *interp, const char *cmd)
+#else
+tcl_eval(interp, cmd)
+ Tcl_Interp *interp;
+ const char *cmd; /* don't have to be writable */
+#endif
+{
+ char *buf = strdup(cmd);
+ int ret;
+
+ Tcl_AllowExceptions(interp);
+ ret = Tcl_Eval(interp, buf);
+ free(buf);
+ return ret;
+}
+
+#undef Tcl_Eval
+#define Tcl_Eval tcl_eval
+
+static int
+#ifdef HAVE_PROTOTYPES
+tcl_global_eval(Tcl_Interp *interp, const char *cmd)
+#else
+tcl_global_eval(interp, cmd)
+ Tcl_Interp *interp;
+ const char *cmd; /* don't have to be writable */
+#endif
+{
+ char *buf = strdup(cmd);
+ int ret;
+
+ Tcl_AllowExceptions(interp);
+ ret = Tcl_GlobalEval(interp, buf);
+ free(buf);
+ return ret;
+}
+
+#undef Tcl_GlobalEval
+#define Tcl_GlobalEval tcl_global_eval
+
+/* Tcl_{Incr|Decr}RefCount for tcl7.x or earlier */
+#if TCL_MAJOR_VERSION < 8
+#define Tcl_IncrRefCount(obj) (1)
+#define Tcl_DecrRefCount(obj) (1)
+#endif
+
+/* Tcl_GetStringResult for tcl7.x or earlier */
+#if TCL_MAJOR_VERSION < 8
+#define Tcl_GetStringResult(interp) ((interp)->result)
+#endif
+
+/* Tcl_[GS]etVar2Ex for tcl8.0 */
+#if TCL_MAJOR_VERSION == 8 && TCL_MINOR_VERSION == 0
+static Tcl_Obj *
+Tcl_GetVar2Ex(interp, name1, name2, flags)
+ Tcl_Interp *interp;
+ CONST char *name1;
+ CONST char *name2;
+ int flags;
+{
+ Tcl_Obj *nameObj1, *nameObj2 = NULL, *retObj;
+
+ nameObj1 = Tcl_NewStringObj((char*)name1, -1);
+ Tcl_IncrRefCount(nameObj1);
+
+ if (name2) {
+ nameObj2 = Tcl_NewStringObj((char*)name2, -1);
+ Tcl_IncrRefCount(nameObj2);
+ }
+
+ retObj = Tcl_ObjGetVar2(interp, nameObj1, nameObj2, flags);
+
+ if (name2) {
+ Tcl_DecrRefCount(nameObj2);
+ }
+
+ Tcl_DecrRefCount(nameObj1);
+
+ return retObj;
+}
+
+static Tcl_Obj *
+Tcl_SetVar2Ex(interp, name1, name2, newValObj, flags)
+ Tcl_Interp *interp;
+ CONST char *name1;
+ CONST char *name2;
+ Tcl_Obj *newValObj;
+ int flags;
+{
+ Tcl_Obj *nameObj1, *nameObj2 = NULL, *retObj;
+
+ nameObj1 = Tcl_NewStringObj((char*)name1, -1);
+ Tcl_IncrRefCount(nameObj1);
+
+ if (name2) {
+ nameObj2 = Tcl_NewStringObj((char*)name2, -1);
+ Tcl_IncrRefCount(nameObj2);
+ }
+
+ retObj = Tcl_ObjSetVar2(interp, nameObj1, nameObj2, newValObj, flags);
+
+ if (name2) {
+ Tcl_DecrRefCount(nameObj2);
+ }
+
+ Tcl_DecrRefCount(nameObj1);
+
+ return retObj;
+}
+#endif
+
+/* from tkAppInit.c */
+
+#if TCL_MAJOR_VERSION < 8 || (TCL_MAJOR_VERSION == 8 && TCL_MINOR_VERSION < 4)
+# if !defined __MINGW32__ && !defined __BORLANDC__
+/*
+ * The following variable is a special hack that is needed in order for
+ * Sun shared libraries to be used for Tcl.
+ */
+
+extern int matherr();
+int *tclDummyMathPtr = (int *) matherr;
+# endif
+#endif
+
+/*---- module TclTkLib ----*/
+
+struct invoke_queue {
+ Tcl_Event ev;
+ int argc;
+#if TCL_MAJOR_VERSION >= 8
+ Tcl_Obj **argv;
+#else /* TCL_MAJOR_VERSION < 8 */
+ char **argv;
+#endif
+ VALUE interp;
+ int *done;
+ int safe_level;
+ VALUE result;
+ VALUE thread;
+};
+
+struct eval_queue {
+ Tcl_Event ev;
+ char *str;
+ int len;
+ VALUE interp;
+ int *done;
+ int safe_level;
+ VALUE result;
+ VALUE thread;
+};
+
+struct call_queue {
+ Tcl_Event ev;
+ VALUE (*func)();
+ int argc;
+ VALUE *argv;
+ VALUE interp;
+ int *done;
+ int safe_level;
+ VALUE result;
+ VALUE thread;
+};
+
+void
+invoke_queue_mark(struct invoke_queue *q)
+{
+ rb_gc_mark(q->interp);
+ rb_gc_mark(q->result);
+ rb_gc_mark(q->thread);
+}
+
+void
+eval_queue_mark(struct eval_queue *q)
+{
+ rb_gc_mark(q->interp);
+ rb_gc_mark(q->result);
+ rb_gc_mark(q->thread);
+}
+
+void
+call_queue_mark(struct call_queue *q)
+{
+ int i;
+
+ for(i = 0; i < q->argc; i++) {
+ rb_gc_mark(q->argv[i]);
+ }
+
+ rb_gc_mark(q->interp);
+ rb_gc_mark(q->result);
+ rb_gc_mark(q->thread);
+}
+
+
+static VALUE eventloop_thread;
+static Tcl_Interp *eventloop_interp;
+#ifdef RUBY_USE_NATIVE_THREAD
+Tcl_ThreadId tk_eventloop_thread_id; /* native thread ID of Tcl interpreter */
+#endif
+static VALUE eventloop_stack;
+static int window_event_mode = ~0;
+
+static VALUE watchdog_thread;
+
+Tcl_Interp *current_interp;
+
+/* thread control strategy */
+/* multi-tk works with the following settings only ???
+ : CONTROL_BY_STATUS_OF_RB_THREAD_WAITING_FOR_VALUE 1
+ : USE_TOGGLE_WINDOW_MODE_FOR_IDLE 0
+ : DO_THREAD_SCHEDULE_AT_CALLBACK_DONE 0
+*/
+#ifdef RUBY_USE_NATIVE_THREAD
+#define CONTROL_BY_STATUS_OF_RB_THREAD_WAITING_FOR_VALUE 1
+#define USE_TOGGLE_WINDOW_MODE_FOR_IDLE 0
+#define DO_THREAD_SCHEDULE_AT_CALLBACK_DONE 1
+#else /* ! RUBY_USE_NATIVE_THREAD */
+#define CONTROL_BY_STATUS_OF_RB_THREAD_WAITING_FOR_VALUE 1
+#define USE_TOGGLE_WINDOW_MODE_FOR_IDLE 0
+#define DO_THREAD_SCHEDULE_AT_CALLBACK_DONE 0
+#endif
+
+#if CONTROL_BY_STATUS_OF_RB_THREAD_WAITING_FOR_VALUE
+static int have_rb_thread_waiting_for_value = 0;
+#endif
+
+/*
+ * 'event_loop_max' is a maximum events which the eventloop processes in one
+ * term of thread scheduling. 'no_event_tick' is the count-up value when
+ * there are no event for processing.
+ * 'timer_tick' is a limit of one term of thread scheduling.
+ * If 'timer_tick' == 0, then not use the timer for thread scheduling.
+ */
+#ifdef RUBY_USE_NATIVE_THREAD
+#define DEFAULT_EVENT_LOOP_MAX 800/*counts*/
+#define DEFAULT_NO_EVENT_TICK 10/*counts*/
+#define DEFAULT_NO_EVENT_WAIT 5/*milliseconds ( 1 -- 999 ) */
+#define WATCHDOG_INTERVAL 10/*milliseconds ( 1 -- 999 ) */
+#define DEFAULT_TIMER_TICK 0/*milliseconds ( 0 -- 999 ) */
+#define NO_THREAD_INTERRUPT_TIME 100/*milliseconds ( 1 -- 999 ) */
+#else /* ! RUBY_USE_NATIVE_THREAD */
+#define DEFAULT_EVENT_LOOP_MAX 800/*counts*/
+#define DEFAULT_NO_EVENT_TICK 10/*counts*/
+#define DEFAULT_NO_EVENT_WAIT 20/*milliseconds ( 1 -- 999 ) */
+#define WATCHDOG_INTERVAL 10/*milliseconds ( 1 -- 999 ) */
+#define DEFAULT_TIMER_TICK 0/*milliseconds ( 0 -- 999 ) */
+#define NO_THREAD_INTERRUPT_TIME 100/*milliseconds ( 1 -- 999 ) */
+#endif
+
+#define EVENT_HANDLER_TIMEOUT 100/*milliseconds*/
+
+static int event_loop_max = DEFAULT_EVENT_LOOP_MAX;
+static int no_event_tick = DEFAULT_NO_EVENT_TICK;
+static int no_event_wait = DEFAULT_NO_EVENT_WAIT;
+static int timer_tick = DEFAULT_TIMER_TICK;
+static int req_timer_tick = DEFAULT_TIMER_TICK;
+static int run_timer_flag = 0;
+
+static int event_loop_wait_event = 0;
+static int event_loop_abort_on_exc = 1;
+static int loop_counter = 0;
+
+static int check_rootwidget_flag = 0;
+
+
+/* call ruby interpreter */
+#if TCL_MAJOR_VERSION >= 8
+static int ip_ruby_eval _((ClientData, Tcl_Interp *, int, Tcl_Obj *CONST*));
+static int ip_ruby_cmd _((ClientData, Tcl_Interp *, int, Tcl_Obj *CONST*));
+#else /* TCL_MAJOR_VERSION < 8 */
+static int ip_ruby_eval _((ClientData, Tcl_Interp *, int, char **));
+static int ip_ruby_cmd _((ClientData, Tcl_Interp *, int, char **));
+#endif
+
+struct cmd_body_arg {
+ VALUE receiver;
+ ID method;
+ VALUE args;
+};
+
+/*----------------------------*/
+/* use Tcl internal functions */
+/*----------------------------*/
+#ifndef TCL_NAMESPACE_DEBUG
+#define TCL_NAMESPACE_DEBUG 0
+#endif
+
+#if TCL_NAMESPACE_DEBUG
+
+#if TCL_MAJOR_VERSION >= 8
+EXTERN struct TclIntStubs *tclIntStubsPtr;
+#endif
+
+/*-- Tcl_GetCurrentNamespace --*/
+#if TCL_MAJOR_VERSION == 8 && TCL_MINOR_VERSION < 5
+/* Tcl7.x doesn't have namespace support. */
+/* Tcl8.5+ has definition of Tcl_GetCurrentNamespace() in tclDecls.h */
+# ifndef Tcl_GetCurrentNamespace
+EXTERN Tcl_Namespace * Tcl_GetCurrentNamespace _((Tcl_Interp *));
+# endif
+# if defined(USE_TCL_STUBS) && !defined(USE_TCL_STUB_PROCS)
+# ifndef Tcl_GetCurrentNamespace
+# ifndef FunctionNum_of_GetCurrentNamespace
+#define FunctionNum_of_GetCurrentNamespace 124
+# endif
+struct DummyTclIntStubs_for_GetCurrentNamespace {
+ int magic;
+ struct TclIntStubHooks *hooks;
+ void (*func[FunctionNum_of_GetCurrentNamespace])();
+ Tcl_Namespace * (*tcl_GetCurrentNamespace) _((Tcl_Interp *));
+};
+
+#define Tcl_GetCurrentNamespace \
+ (((struct DummyTclIntStubs_for_GetCurrentNamespace *)tclIntStubsPtr)->tcl_GetCurrentNamespace)
+# endif
+# endif
+#endif
+
+/* namespace check */
+/* ip_null_namespace(Tcl_Interp *interp) */
+#if TCL_MAJOR_VERSION < 8
+#define ip_null_namespace(interp) (0)
+#else /* support namespace */
+#define ip_null_namespace(interp) \
+ (Tcl_GetCurrentNamespace(interp) == (Tcl_Namespace *)NULL)
+#endif
+
+/* rbtk_invalid_namespace(tcltkip *ptr) */
+#if TCL_MAJOR_VERSION < 8
+#define rbtk_invalid_namespace(ptr) (0)
+#else /* support namespace */
+#define rbtk_invalid_namespace(ptr) \
+ ((ptr)->default_ns == (Tcl_Namespace*)NULL || Tcl_GetCurrentNamespace((ptr)->ip) != (ptr)->default_ns)
+#endif
+
+/*-- Tcl_PopCallFrame & Tcl_PushCallFrame --*/
+#if TCL_MAJOR_VERSION >= 8
+# ifndef CallFrame
+typedef struct CallFrame {
+ Tcl_Namespace *nsPtr;
+ int dummy1;
+ int dummy2;
+ char *dummy3;
+ struct CallFrame *callerPtr;
+ struct CallFrame *callerVarPtr;
+ int level;
+ char *dummy7;
+ char *dummy8;
+ int dummy9;
+ char* dummy10;
+} CallFrame;
+# endif
+
+# if !defined(TclGetFrame) && !defined(TclGetFrame_TCL_DECLARED)
+EXTERN int TclGetFrame _((Tcl_Interp *, CONST char *, CallFrame **));
+# endif
+# if defined(USE_TCL_STUBS) && !defined(USE_TCL_STUB_PROCS)
+# ifndef TclGetFrame
+# ifndef FunctionNum_of_GetFrame
+#define FunctionNum_of_GetFrame 32
+# endif
+struct DummyTclIntStubs_for_GetFrame {
+ int magic;
+ struct TclIntStubHooks *hooks;
+ void (*func[FunctionNum_of_GetFrame])();
+ int (*tclGetFrame) _((Tcl_Interp *, CONST char *, CallFrame **));
+};
+#define TclGetFrame \
+ (((struct DummyTclIntStubs_for_GetFrame *)tclIntStubsPtr)->tclGetFrame)
+# endif
+# endif
+
+# if !defined(Tcl_PopCallFrame) && !defined(Tcl_PopCallFrame_TCL_DECLARED)
+EXTERN void Tcl_PopCallFrame _((Tcl_Interp *));
+EXTERN int Tcl_PushCallFrame _((Tcl_Interp *, Tcl_CallFrame *, Tcl_Namespace *, int));
+# endif
+# if defined(USE_TCL_STUBS) && !defined(USE_TCL_STUB_PROCS)
+# ifndef Tcl_PopCallFrame
+# ifndef FunctionNum_of_PopCallFrame
+#define FunctionNum_of_PopCallFrame 128
+# endif
+struct DummyTclIntStubs_for_PopCallFrame {
+ int magic;
+ struct TclIntStubHooks *hooks;
+ void (*func[FunctionNum_of_PopCallFrame])();
+ void (*tcl_PopCallFrame) _((Tcl_Interp *));
+ int (*tcl_PushCallFrame) _((Tcl_Interp *, Tcl_CallFrame *, Tcl_Namespace *, int));
+};
+
+#define Tcl_PopCallFrame \
+ (((struct DummyTclIntStubs_for_PopCallFrame *)tclIntStubsPtr)->tcl_PopCallFrame)
+#define Tcl_PushCallFrame \
+ (((struct DummyTclIntStubs_for_PopCallFrame *)tclIntStubsPtr)->tcl_PushCallFrame)
+# endif
+# endif
+
+#else /* Tcl7.x */
+# ifndef CallFrame
+typedef struct CallFrame {
+ Tcl_HashTable varTable;
+ int level;
+ int argc;
+ char **argv;
+ struct CallFrame *callerPtr;
+ struct CallFrame *callerVarPtr;
+} CallFrame;
+# endif
+# ifndef Tcl_CallFrame
+#define Tcl_CallFrame CallFrame
+# endif
+
+# if !defined(TclGetFrame) && !defined(TclGetFrame_TCL_DECLARED)
+EXTERN int TclGetFrame _((Tcl_Interp *, CONST char *, CallFrame **));
+# endif
+
+# if !defined(Tcl_PopCallFrame) && !defined(Tcl_PopCallFrame_TCL_DECLARED)
+typedef struct DummyInterp {
+ char *dummy1;
+ char *dummy2;
+ int dummy3;
+ Tcl_HashTable dummy4;
+ Tcl_HashTable dummy5;
+ Tcl_HashTable dummy6;
+ int numLevels;
+ int maxNestingDepth;
+ CallFrame *framePtr;
+ CallFrame *varFramePtr;
+} DummyInterp;
+
+static void
+Tcl_PopCallFrame(interp)
+ Tcl_Interp *interp;
+{
+ DummyInterp *iPtr = (DummyInterp*)interp;
+ CallFrame *frame = iPtr->varFramePtr;
+
+ /* **** DUMMY **** */
+ iPtr->framePtr = frame.callerPtr;
+ iPtr->varFramePtr = frame.callerVarPtr;
+
+ return TCL_OK;
+}
+
+/* dummy */
+#define Tcl_Namespace char
+
+static int
+Tcl_PushCallFrame(interp, framePtr, nsPtr, isProcCallFrame)
+ Tcl_Interp *interp;
+ Tcl_CallFrame *framePtr;
+ Tcl_Namespace *nsPtr;
+ int isProcCallFrame;
+{
+ DummyInterp *iPtr = (DummyInterp*)interp;
+ CallFrame *frame = (CallFrame *)framePtr;
+
+ /* **** DUMMY **** */
+ Tcl_InitHashTable(&frame.varTable, TCL_STRING_KEYS);
+ if (iPtr->varFramePtr != NULL) {
+ frame.level = iPtr->varFramePtr->level + 1;
+ } else {
+ frame.level = 1;
+ }
+ frame.callerPtr = iPtr->framePtr;
+ frame.callerVarPtr = iPtr->varFramePtr;
+ iPtr->framePtr = &frame;
+ iPtr->varFramePtr = &frame;
+
+ return TCL_OK;
+}
+# endif
+
+#endif
+
+#endif /* TCL_NAMESPACE_DEBUG */
+
+
+/*---- class TclTkIp ----*/
+struct tcltkip {
+ Tcl_Interp *ip; /* the interpreter */
+#if TCL_NAMESPACE_DEBUG
+ Tcl_Namespace *default_ns; /* default namespace */
+#endif
+#ifdef RUBY_USE_NATIVE_THREAD
+ Tcl_ThreadId tk_thread_id; /* native thread ID of Tcl interpreter */
+#endif
+ int has_orig_exit; /* has original 'exit' command ? */
+ Tcl_CmdInfo orig_exit_info; /* command info of original 'exit' command */
+ int ref_count; /* reference count of rbtk_preserve_ip call */
+ int allow_ruby_exit; /* allow exiting ruby by 'exit' function */
+ int return_value; /* return value */
+};
+
+static const rb_data_type_t tcltkip_type = {
+ "tcltkip",
+ {0, ip_free, 0,},
+};
+
+static struct tcltkip *
+get_ip(self)
+ VALUE self;
+{
+ struct tcltkip *ptr;
+
+ TypedData_Get_Struct(self, struct tcltkip, &tcltkip_type, ptr);
+ if (ptr == 0) {
+ /* rb_raise(rb_eTypeError, "uninitialized TclTkIp"); */
+ return((struct tcltkip *)NULL);
+ }
+ if (ptr->ip == (Tcl_Interp*)NULL) {
+ /* rb_raise(rb_eRuntimeError, "deleted IP"); */
+ return((struct tcltkip *)NULL);
+ }
+ return ptr;
+}
+
+static int
+deleted_ip(ptr)
+ struct tcltkip *ptr;
+{
+ if (!ptr || !ptr->ip || Tcl_InterpDeleted(ptr->ip)
+#if TCL_NAMESPACE_DEBUG
+ || rbtk_invalid_namespace(ptr)
+#endif
+ ) {
+ DUMP1("ip is deleted");
+ return 1;
+ }
+ return 0;
+}
+
+/* increment/decrement reference count of tcltkip */
+static int
+rbtk_preserve_ip(ptr)
+ struct tcltkip *ptr;
+{
+ ptr->ref_count++;
+ if (ptr->ip == (Tcl_Interp*)NULL) {
+ /* deleted IP */
+ ptr->ref_count = 0;
+ } else {
+ Tcl_Preserve((ClientData)ptr->ip);
+ }
+ return(ptr->ref_count);
+}
+
+static int
+rbtk_release_ip(ptr)
+ struct tcltkip *ptr;
+{
+ ptr->ref_count--;
+ if (ptr->ref_count < 0) {
+ ptr->ref_count = 0;
+ } else if (ptr->ip == (Tcl_Interp*)NULL) {
+ /* deleted IP */
+ ptr->ref_count = 0;
+ } else {
+ Tcl_Release((ClientData)ptr->ip);
+ }
+ return(ptr->ref_count);
+}
+
+
+static VALUE
+#ifdef HAVE_STDARG_PROTOTYPES
+create_ip_exc(VALUE interp, VALUE exc, const char *fmt, ...)
+#else
+create_ip_exc(interp, exc, fmt, va_alist)
+ VALUE interp:
+ VALUE exc;
+ const char *fmt;
+ va_dcl
+#endif
+{
+ va_list args;
+ VALUE msg;
+ VALUE einfo;
+ struct tcltkip *ptr = get_ip(interp);
+
+ va_init_list(args,fmt);
+ msg = rb_vsprintf(fmt, args);
+ va_end(args);
+ einfo = rb_exc_new_str(exc, msg);
+ rb_ivar_set(einfo, ID_at_interp, interp);
+ if (ptr) {
+ Tcl_ResetResult(ptr->ip);
+ }
+
+ return einfo;
+}
+
+
+/*####################################################################*/
+#if defined CREATE_RUBYTK_KIT || defined CREATE_RUBYKIT
+
+/*--------------------------------------------------------*/
+
+#if 10 * TCL_MAJOR_VERSION + TCL_MINOR_VERSION < 84
+#error Ruby/Tk-Kit requires Tcl/Tk8.4 or later.
+#endif
+
+/*--------------------------------------------------------*/
+
+/* Many part of code to support Ruby/Tk-Kit is quoted from Tclkit. */
+/* But, never ask Tclkit community about Ruby/Tk-Kit. */
+/* Please ask Ruby (Ruby/Tk) community (e.g. "ruby-dev" mailing list). */
+/*
+----<< license terms of TclKit (from kitgen's "README" file) >>---------------
+The Tclkit-specific sources are license free, they just have a copyright. Hold
+the author(s) harmless and any lawful use is permitted.
+
+This does *not* apply to any of the sources of the other major Open Source
+Software used in Tclkit, which each have very liberal BSD/MIT-like licenses:
+
+ * Tcl/Tk, TclVFS, Thread, Vlerq, Zlib
+------------------------------------------------------------------------------
+ */
+/* Tcl/Tk stubs may work, but probably it is meaningless. */
+#if defined USE_TCL_STUBS || defined USE_TK_STUBS
+# error Not support Tcl/Tk stubs with Ruby/Tk-Kit or Rubykit.
+#endif
+
+#ifndef KIT_INCLUDES_ZLIB
+#if 10 * TCL_MAJOR_VERSION + TCL_MINOR_VERSION < 86
+#define KIT_INCLUDES_ZLIB 1
+#else
+#define KIT_INCLUDES_ZLIB 0
+#endif
+#endif
+
+#ifdef _WIN32
+#define WIN32_LEAN_AND_MEAN
+#include <windows.h>
+#undef WIN32_LEAN_AND_MEAN
+#endif
+
+#if 10 * TCL_MAJOR_VERSION + TCL_MINOR_VERSION < 86
+EXTERN Tcl_Obj* TclGetStartupScriptPath();
+EXTERN void TclSetStartupScriptPath _((Tcl_Obj*));
+#define Tcl_GetStartupScript(encPtr) TclGetStartupScriptPath()
+#define Tcl_SetStartupScript(path,enc) TclSetStartupScriptPath(path)
+#endif
+#if !defined(TclSetPreInitScript) && !defined(TclSetPreInitScript_TCL_DECLARED)
+EXTERN char* TclSetPreInitScript _((char *));
+#endif
+
+#ifndef KIT_INCLUDES_TK
+# define KIT_INCLUDES_TK 1
+#endif
+/* #define KIT_INCLUDES_ITCL 1 */
+/* #define KIT_INCLUDES_THREAD 1 */
+
+Tcl_AppInitProc Vfs_Init, Rechan_Init;
+#if 10 * TCL_MAJOR_VERSION + TCL_MINOR_VERSION < 85
+Tcl_AppInitProc Pwb_Init;
+#endif
+
+#ifdef KIT_LITE
+Tcl_AppInitProc Vlerq_Init, Vlerq_SafeInit;
+#else
+Tcl_AppInitProc Mk4tcl_Init;
+#endif
+
+#if defined TCL_THREADS && defined KIT_INCLUDES_THREAD
+Tcl_AppInitProc Thread_Init;
+#endif
+
+#if KIT_INCLUDES_ZLIB
+Tcl_AppInitProc Zlib_Init;
+#endif
+
+#ifdef KIT_INCLUDES_ITCL
+Tcl_AppInitProc Itcl_Init;
+#endif
+
+#ifdef _WIN32
+Tcl_AppInitProc Dde_Init, Dde_SafeInit, Registry_Init;
+#endif
+
+/*--------------------------------------------------------*/
+
+#define RUBYTK_KITPATH_CONST_NAME "RUBYTK_KITPATH"
+
+static char *rubytk_kitpath = NULL;
+
+static char rubytkkit_preInitCmd[] =
+"proc tclKitPreInit {} {\n"
+ "rename tclKitPreInit {}\n"
+ "load {} rubytk_kitpath\n"
+#if KIT_INCLUDES_ZLIB
+ "catch {load {} zlib}\n"
+#endif
+#ifdef KIT_LITE
+ "load {} vlerq\n"
+ "namespace eval ::vlerq {}\n"
+ "if {[catch { vlerq open $::tcl::kitpath } ::vlerq::starkit_root]} {\n"
+ "set n -1\n"
+ "} else {\n"
+ "set files [vlerq get $::vlerq::starkit_root 0 dirs 0 files]\n"
+ "set n [lsearch [vlerq get $files * name] boot.tcl]\n"
+ "}\n"
+ "if {$n >= 0} {\n"
+ "array set a [vlerq get $files $n]\n"
+#else
+ "load {} Mk4tcl\n"
+#if defined KIT_VFS_WRITABLE && !defined CREATE_RUBYKIT
+ /* running command cannot open itself for writing */
+ "mk::file open exe $::tcl::kitpath\n"
+#else
+ "mk::file open exe $::tcl::kitpath -readonly\n"
+#endif
+ "set n [mk::select exe.dirs!0.files name boot.tcl]\n"
+ "if {[llength $n] == 1} {\n"
+ "array set a [mk::get exe.dirs!0.files!$n]\n"
+#endif
+ "if {![info exists a(contents)]} { error {no boot.tcl file} }\n"
+ "if {$a(size) != [string length $a(contents)]} {\n"
+ "set a(contents) [zlib decompress $a(contents)]\n"
+ "}\n"
+ "if {$a(contents) eq \"\"} { error {empty boot.tcl} }\n"
+ "uplevel #0 $a(contents)\n"
+#if 0
+ "} elseif {[lindex $::argv 0] eq \"-init-\"} {\n"
+ "uplevel #0 { source [lindex $::argv 1] }\n"
+ "exit\n"
+#endif
+ "} else {\n"
+ /* When cannot find VFS data, try to use a real directory */
+ "set vfsdir \"[file rootname $::tcl::kitpath].vfs\"\n"
+ "if {[file isdirectory $vfsdir]} {\n"
+ "set ::tcl_library [file join $vfsdir lib tcl$::tcl_version]\n"
+ "set ::tcl_libPath [list $::tcl_library [file join $vfsdir lib]]\n"
+ "catch {uplevel #0 [list source [file join $vfsdir config.tcl]]}\n"
+ "uplevel #0 [list source [file join $::tcl_library init.tcl]]\n"
+ "set ::auto_path $::tcl_libPath\n"
+ "} else {\n"
+ "error \"\n $::tcl::kitpath has no VFS data to start up\"\n"
+ "}\n"
+ "}\n"
+"}\n"
+"tclKitPreInit"
+;
+
+#if 0
+/* Not use this script.
+ It's a memo to support an initScript for Tcl interpreters in the future. */
+static const char initScript[] =
+"if {[file isfile [file join $::tcl::kitpath main.tcl]]} {\n"
+ "if {[info commands console] != {}} { console hide }\n"
+ "set tcl_interactive 0\n"
+ "incr argc\n"
+ "set argv [linsert $argv 0 $argv0]\n"
+ "set argv0 [file join $::tcl::kitpath main.tcl]\n"
+"} else continue\n"
+;
+#endif
+
+/*--------------------------------------------------------*/
+
+static char*
+set_rubytk_kitpath(const char *kitpath)
+{
+ if (kitpath) {
+ int len = (int)strlen(kitpath);
+ if (rubytk_kitpath) {
+ ckfree(rubytk_kitpath);
+ }
+
+ rubytk_kitpath = (char *)ckalloc(len + 1);
+ memcpy(rubytk_kitpath, kitpath, len);
+ rubytk_kitpath[len] = '\0';
+ }
+ return rubytk_kitpath;
+}
+
+/*--------------------------------------------------------*/
+
+#ifdef WIN32
+#define DEV_NULL "NUL"
+#else
+#define DEV_NULL "/dev/null"
+#endif
+
+static void
+check_tclkit_std_channels(void)
+{
+ Tcl_Channel chan;
+
+ /*
+ * We need to verify if we have the standard channels and create them if
+ * not. Otherwise internals channels may get used as standard channels
+ * (like for encodings) and panic.
+ */
+ chan = Tcl_GetStdChannel(TCL_STDIN);
+ if (chan == NULL) {
+ chan = Tcl_OpenFileChannel(NULL, DEV_NULL, "r", 0);
+ if (chan != NULL) {
+ Tcl_SetChannelOption(NULL, chan, "-encoding", "utf-8");
+ }
+ Tcl_SetStdChannel(chan, TCL_STDIN);
+ }
+ chan = Tcl_GetStdChannel(TCL_STDOUT);
+ if (chan == NULL) {
+ chan = Tcl_OpenFileChannel(NULL, DEV_NULL, "w", 0);
+ if (chan != NULL) {
+ Tcl_SetChannelOption(NULL, chan, "-encoding", "utf-8");
+ }
+ Tcl_SetStdChannel(chan, TCL_STDOUT);
+ }
+ chan = Tcl_GetStdChannel(TCL_STDERR);
+ if (chan == NULL) {
+ chan = Tcl_OpenFileChannel(NULL, DEV_NULL, "w", 0);
+ if (chan != NULL) {
+ Tcl_SetChannelOption(NULL, chan, "-encoding", "utf-8");
+ }
+ Tcl_SetStdChannel(chan, TCL_STDERR);
+ }
+}
+
+/*--------------------------------------------------------*/
+
+static int
+rubytk_kitpathObjCmd(ClientData dummy, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[])
+{
+ const char* str;
+ if (objc == 2) {
+ set_rubytk_kitpath(Tcl_GetString(objv[1]));
+ } else if (objc > 2) {
+ Tcl_WrongNumArgs(interp, 1, objv, "?path?");
+ }
+ str = rubytk_kitpath ? rubytk_kitpath : Tcl_GetNameOfExecutable();
+ Tcl_SetObjResult(interp, Tcl_NewStringObj(str, -1));
+ return TCL_OK;
+}
+
+/*
+ * Public entry point for ::tcl::kitpath.
+ * Creates both link variable name and Tcl command ::tcl::kitpath.
+ */
+static int
+rubytk_kitpath_init(Tcl_Interp *interp)
+{
+ Tcl_CreateObjCommand(interp, "::tcl::kitpath", rubytk_kitpathObjCmd, 0, 0);
+ if (Tcl_LinkVar(interp, "::tcl::kitpath", (char *) &rubytk_kitpath,
+ TCL_LINK_STRING | TCL_LINK_READ_ONLY) != TCL_OK) {
+ Tcl_ResetResult(interp);
+ }
+
+ Tcl_CreateObjCommand(interp, "::tcl::rubytk_kitpath", rubytk_kitpathObjCmd, 0, 0);
+ if (Tcl_LinkVar(interp, "::tcl::rubytk_kitpath", (char *) &rubytk_kitpath,
+ TCL_LINK_STRING | TCL_LINK_READ_ONLY) != TCL_OK) {
+ Tcl_ResetResult(interp);
+ }
+
+ if (rubytk_kitpath == NULL) {
+ /*
+ * XXX: We may want to avoid doing this to allow tcl::kitpath calls
+ * XXX: to obtain changes in nameofexe, if they occur.
+ */
+ set_rubytk_kitpath(Tcl_GetNameOfExecutable());
+ }
+
+ return Tcl_PkgProvide(interp, "rubytk_kitpath", "1.0");
+}
+
+/*--------------------------------------------------------*/
+
+static void
+init_static_tcltk_packages(void)
+{
+ /*
+ * Ensure that std channels exist (creating them if necessary)
+ */
+ check_tclkit_std_channels();
+
+#ifdef KIT_INCLUDES_ITCL
+ Tcl_StaticPackage(0, "Itcl", Itcl_Init, NULL);
+#endif
+#ifdef KIT_LITE
+ Tcl_StaticPackage(0, "Vlerq", Vlerq_Init, Vlerq_SafeInit);
+#else
+ Tcl_StaticPackage(0, "Mk4tcl", Mk4tcl_Init, NULL);
+#endif
+#if 10 * TCL_MAJOR_VERSION + TCL_MINOR_VERSION < 85
+ Tcl_StaticPackage(0, "pwb", Pwb_Init, NULL);
+#endif
+ Tcl_StaticPackage(0, "rubytk_kitpath", rubytk_kitpath_init, NULL);
+ Tcl_StaticPackage(0, "rechan", Rechan_Init, NULL);
+ Tcl_StaticPackage(0, "vfs", Vfs_Init, NULL);
+#if KIT_INCLUDES_ZLIB
+ Tcl_StaticPackage(0, "zlib", Zlib_Init, NULL);
+#endif
+#if defined TCL_THREADS && defined KIT_INCLUDES_THREAD
+ Tcl_StaticPackage(0, "Thread", Thread_Init, Thread_SafeInit);
+#endif
+#ifdef _WIN32
+#if 10 * TCL_MAJOR_VERSION + TCL_MINOR_VERSION > 84
+ Tcl_StaticPackage(0, "dde", Dde_Init, Dde_SafeInit);
+#else
+ Tcl_StaticPackage(0, "dde", Dde_Init, NULL);
+#endif
+ Tcl_StaticPackage(0, "registry", Registry_Init, NULL);
+#endif
+#ifdef KIT_INCLUDES_TK
+ Tcl_StaticPackage(0, "Tk", Tk_Init, Tk_SafeInit);
+#endif
+}
+
+/*--------------------------------------------------------*/
+
+static int
+call_tclkit_init_script(Tcl_Interp *interp)
+{
+#if 0
+ /* Currently, do nothing in this function.
+ It's a memo (quoted from kitInit.c of Tclkit)
+ to support an initScript for Tcl interpreters in the future. */
+ if (Tcl_EvalEx(interp, initScript, -1, TCL_EVAL_GLOBAL) == TCL_OK) {
+ const char *encoding = NULL;
+ Tcl_Obj* path = Tcl_GetStartupScript(&encoding);
+ Tcl_SetStartupScript(Tcl_GetObjResult(interp), encoding);
+ if (path == NULL) {
+ Tcl_Eval(interp, "incr argc -1; set argv [lrange $argv 1 end]");
+ }
+ }
+#endif
+
+ return 1;
+}
+
+/*--------------------------------------------------------*/
+
+#ifdef __WIN32__
+/* #include <tkWinInt.h> *//* conflict definition of struct timezone */
+/* #include <tkIntPlatDecls.h> */
+/* #include <windows.h> */
+EXTERN void TkWinSetHINSTANCE(HINSTANCE hInstance);
+void rbtk_win32_SetHINSTANCE(const char *module_name)
+{
+ /* TCHAR szBuf[256]; */
+ HINSTANCE hInst;
+
+ /* hInst = GetModuleHandle(NULL); */
+ /* hInst = GetModuleHandle("tcltklib.so"); */
+ hInst = GetModuleHandle(module_name);
+ TkWinSetHINSTANCE(hInst);
+
+ /* GetModuleFileName(hInst, szBuf, sizeof(szBuf) / sizeof(TCHAR)); */
+ /* MessageBox(NULL, szBuf, TEXT("OK"), MB_OK); */
+}
+#endif
+
+/*--------------------------------------------------------*/
+
+static void
+setup_rubytkkit(void)
+{
+ init_static_tcltk_packages();
+
+ {
+ ID const_id;
+ const_id = rb_intern(RUBYTK_KITPATH_CONST_NAME);
+
+ if (rb_const_defined(rb_cObject, const_id)) {
+ volatile VALUE pathobj;
+ pathobj = rb_const_get(rb_cObject, const_id);
+
+ if (rb_obj_is_kind_of(pathobj, rb_cString)) {
+#ifdef HAVE_RUBY_ENCODING_H
+ pathobj = rb_str_export_to_enc(pathobj, rb_utf8_encoding());
+#endif
+ set_rubytk_kitpath(RSTRING_PTR(pathobj));
+ }
+ }
+ }
+
+#ifdef CREATE_RUBYTK_KIT
+ if (rubytk_kitpath == NULL) {
+#ifdef __WIN32__
+ /* rbtk_win32_SetHINSTANCE("tcltklib.so"); */
+ {
+ volatile VALUE basename;
+ basename = rb_funcall(rb_cFile, rb_intern("basename"), 1,
+ rb_str_new2(rb_sourcefile()));
+ rbtk_win32_SetHINSTANCE(RSTRING_PTR(basename));
+ }
+#endif
+ set_rubytk_kitpath(rb_sourcefile());
+ }
+#endif
+
+ if (rubytk_kitpath == NULL) {
+ set_rubytk_kitpath(Tcl_GetNameOfExecutable());
+ }
+
+ TclSetPreInitScript(rubytkkit_preInitCmd);
+}
+
+/*--------------------------------------------------------*/
+
+#endif /* defined CREATE_RUBYTK_KIT || defined CREATE_RUBYKIT */
+/*####################################################################*/
+
+
+/**********************************************************************/
+
+/* stub status */
+static void
+tcl_stubs_check(void)
+{
+ if (!tcl_stubs_init_p()) {
+ int st = ruby_tcl_stubs_init();
+ switch(st) {
+ case TCLTK_STUBS_OK:
+ break;
+ case NO_TCL_DLL:
+ rb_raise(rb_eLoadError, "tcltklib: fail to open tcl_dll");
+ case NO_FindExecutable:
+ rb_raise(rb_eLoadError, "tcltklib: can't find Tcl_FindExecutable");
+ case NO_CreateInterp:
+ rb_raise(rb_eLoadError, "tcltklib: can't find Tcl_CreateInterp()");
+ case NO_DeleteInterp:
+ rb_raise(rb_eLoadError, "tcltklib: can't find Tcl_DeleteInterp()");
+ case FAIL_CreateInterp:
+ rb_raise(rb_eRuntimeError, "tcltklib: fail to create a new IP to call Tcl_InitStubs()");
+ case FAIL_Tcl_InitStubs:
+ rb_raise(rb_eRuntimeError, "tcltklib: fail to Tcl_InitStubs()");
+ default:
+ rb_raise(rb_eRuntimeError, "tcltklib: unknown error(%d) on ruby_tcl_stubs_init()", st);
+ }
+ }
+}
+
+
+static VALUE
+tcltkip_init_tk(interp)
+ VALUE interp;
+{
+ struct tcltkip *ptr = get_ip(interp);
+
+#if TCL_MAJOR_VERSION >= 8
+ int st;
+
+ if (Tcl_IsSafe(ptr->ip)) {
+ DUMP1("Tk_SafeInit");
+ st = ruby_tk_stubs_safeinit(ptr->ip);
+ switch(st) {
+ case TCLTK_STUBS_OK:
+ break;
+ case NO_Tk_Init:
+ return rb_exc_new2(rb_eLoadError,
+ "tcltklib: can't find Tk_SafeInit()");
+ case FAIL_Tk_Init:
+ return create_ip_exc(interp, rb_eRuntimeError,
+ "tcltklib: fail to Tk_SafeInit(). %s",
+ Tcl_GetStringResult(ptr->ip));
+ case FAIL_Tk_InitStubs:
+ return create_ip_exc(interp, rb_eRuntimeError,
+ "tcltklib: fail to Tk_InitStubs(). %s",
+ Tcl_GetStringResult(ptr->ip));
+ default:
+ return create_ip_exc(interp, rb_eRuntimeError,
+ "tcltklib: unknown error(%d) on ruby_tk_stubs_safeinit", st);
+ }
+ } else {
+ DUMP1("Tk_Init");
+ st = ruby_tk_stubs_init(ptr->ip);
+ switch(st) {
+ case TCLTK_STUBS_OK:
+ break;
+ case NO_Tk_Init:
+ return rb_exc_new2(rb_eLoadError,
+ "tcltklib: can't find Tk_Init()");
+ case FAIL_Tk_Init:
+ return create_ip_exc(interp, rb_eRuntimeError,
+ "tcltklib: fail to Tk_Init(). %s",
+ Tcl_GetStringResult(ptr->ip));
+ case FAIL_Tk_InitStubs:
+ return create_ip_exc(interp, rb_eRuntimeError,
+ "tcltklib: fail to Tk_InitStubs(). %s",
+ Tcl_GetStringResult(ptr->ip));
+ default:
+ return create_ip_exc(interp, rb_eRuntimeError,
+ "tcltklib: unknown error(%d) on ruby_tk_stubs_init", st);
+ }
+ }
+
+#else /* TCL_MAJOR_VERSION < 8 */
+ DUMP1("Tk_Init");
+ if (ruby_tk_stubs_init(ptr->ip) != TCLTK_STUBS_OK) {
+ return rb_exc_new2(rb_eRuntimeError, ptr->ip->result);
+ }
+#endif
+
+#ifdef RUBY_USE_NATIVE_THREAD
+ ptr->tk_thread_id = Tcl_GetCurrentThread();
+#endif
+
+ return Qnil;
+}
+
+
+/* treat exception on Tcl side */
+static VALUE rbtk_pending_exception;
+static int rbtk_eventloop_depth = 0;
+static int rbtk_internal_eventloop_handler = 0;
+
+
+static int
+pending_exception_check0(void)
+{
+ volatile VALUE exc = rbtk_pending_exception;
+
+ if (!NIL_P(exc) && rb_obj_is_kind_of(exc, rb_eException)) {
+ DUMP1("find a pending exception");
+ if (rbtk_eventloop_depth > 0
+ || rbtk_internal_eventloop_handler > 0
+ ) {
+ return 1; /* pending */
+ } else {
+ rbtk_pending_exception = Qnil;
+
+ if (rb_obj_is_kind_of(exc, eTkCallbackRetry)) {
+ DUMP1("pending_exception_check0: call rb_jump_tag(retry)");
+ rb_jump_tag(TAG_RETRY);
+ } else if (rb_obj_is_kind_of(exc, eTkCallbackRedo)) {
+ DUMP1("pending_exception_check0: call rb_jump_tag(redo)");
+ rb_jump_tag(TAG_REDO);
+ } else if (rb_obj_is_kind_of(exc, eTkCallbackThrow)) {
+ DUMP1("pending_exception_check0: call rb_jump_tag(throw)");
+ rb_jump_tag(TAG_THROW);
+ }
+
+ rb_exc_raise(exc);
+ }
+ } else {
+ return 0;
+ }
+
+ UNREACHABLE;
+}
+
+static int
+pending_exception_check1(thr_crit_bup, ptr)
+ int thr_crit_bup;
+ struct tcltkip *ptr;
+{
+ volatile VALUE exc = rbtk_pending_exception;
+
+ if (!NIL_P(exc) && rb_obj_is_kind_of(exc, rb_eException)) {
+ DUMP1("find a pending exception");
+
+ if (rbtk_eventloop_depth > 0
+ || rbtk_internal_eventloop_handler > 0
+ ) {
+ return 1; /* pending */
+ } else {
+ rbtk_pending_exception = Qnil;
+
+ if (ptr != (struct tcltkip *)NULL) {
+ /* Tcl_Release(ptr->ip); */
+ rbtk_release_ip(ptr);
+ }
+
+ rb_thread_critical = thr_crit_bup;
+
+ if (rb_obj_is_kind_of(exc, eTkCallbackRetry)) {
+ DUMP1("pending_exception_check1: call rb_jump_tag(retry)");
+ rb_jump_tag(TAG_RETRY);
+ } else if (rb_obj_is_kind_of(exc, eTkCallbackRedo)) {
+ DUMP1("pending_exception_check1: call rb_jump_tag(redo)");
+ rb_jump_tag(TAG_REDO);
+ } else if (rb_obj_is_kind_of(exc, eTkCallbackThrow)) {
+ DUMP1("pending_exception_check1: call rb_jump_tag(throw)");
+ rb_jump_tag(TAG_THROW);
+ }
+ rb_exc_raise(exc);
+ }
+ } else {
+ return 0;
+ }
+
+ UNREACHABLE;
+}
+
+
+/* call original 'exit' command */
+static void
+call_original_exit(ptr, state)
+ struct tcltkip *ptr;
+ int state;
+{
+ int thr_crit_bup;
+ Tcl_CmdInfo *info;
+#if TCL_MAJOR_VERSION >= 8
+ Tcl_Obj *cmd_obj;
+ Tcl_Obj *state_obj;
+#endif
+ DUMP1("original_exit is called");
+
+ if (!(ptr->has_orig_exit)) return;
+
+ thr_crit_bup = rb_thread_critical;
+ rb_thread_critical = Qtrue;
+
+ Tcl_ResetResult(ptr->ip);
+
+ info = &(ptr->orig_exit_info);
+
+ /* memory allocation for arguments of this command */
+#if TCL_MAJOR_VERSION >= 8
+ state_obj = Tcl_NewIntObj(state);
+ Tcl_IncrRefCount(state_obj);
+
+ if (info->isNativeObjectProc) {
+ Tcl_Obj **argv;
+#define USE_RUBY_ALLOC 0
+#if USE_RUBY_ALLOC
+ argv = (Tcl_Obj **)ALLOC_N(Tcl_Obj *, 3);
+#else /* not USE_RUBY_ALLOC */
+ argv = RbTk_ALLOC_N(Tcl_Obj *, 3);
+#if 0 /* use Tcl_Preserve/Release */
+ Tcl_Preserve((ClientData)argv); /* XXXXXXXX */
+#endif
+#endif
+ cmd_obj = Tcl_NewStringObj("exit", 4);
+ Tcl_IncrRefCount(cmd_obj);
+
+ argv[0] = cmd_obj;
+ argv[1] = state_obj;
+ argv[2] = (Tcl_Obj *)NULL;
+
+ ptr->return_value
+ = (*(info->objProc))(info->objClientData, ptr->ip, 2, argv);
+
+ Tcl_DecrRefCount(cmd_obj);
+
+#if USE_RUBY_ALLOC
+ xfree(argv);
+#else /* not USE_RUBY_ALLOC */
+#if 0 /* use Tcl_EventuallyFree */
+ Tcl_EventuallyFree((ClientData)argv, TCL_DYNAMIC); /* XXXXXXXX */
+#else
+#if 0 /* use Tcl_Preserve/Release */
+ Tcl_Release((ClientData)argv); /* XXXXXXXX */
+#else
+ /* free(argv); */
+ ckfree((char*)argv);
+#endif
+#endif
+#endif
+#undef USE_RUBY_ALLOC
+
+ } else {
+ /* string interface */
+ CONST84 char **argv;
+#define USE_RUBY_ALLOC 0
+#if USE_RUBY_ALLOC
+ argv = ALLOC_N(char *, 3); /* XXXXXXXXXX */
+#else /* not USE_RUBY_ALLOC */
+ argv = RbTk_ALLOC_N(CONST84 char *, 3);
+#if 0 /* use Tcl_Preserve/Release */
+ Tcl_Preserve((ClientData)argv); /* XXXXXXXX */
+#endif
+#endif
+ argv[0] = (char *)"exit";
+ /* argv[1] = Tcl_GetString(state_obj); */
+ argv[1] = Tcl_GetStringFromObj(state_obj, (int*)NULL);
+ argv[2] = (char *)NULL;
+
+ ptr->return_value = (*(info->proc))(info->clientData, ptr->ip, 2, argv);
+
+#if USE_RUBY_ALLOC
+ xfree(argv);
+#else /* not USE_RUBY_ALLOC */
+#if 0 /* use Tcl_EventuallyFree */
+ Tcl_EventuallyFree((ClientData)argv, TCL_DYNAMIC); /* XXXXXXXX */
+#else
+#if 0 /* use Tcl_Preserve/Release */
+ Tcl_Release((ClientData)argv); /* XXXXXXXX */
+#else
+ /* free(argv); */
+ ckfree((char*)argv);
+#endif
+#endif
+#endif
+#undef USE_RUBY_ALLOC
+ }
+
+ Tcl_DecrRefCount(state_obj);
+
+#else /* TCL_MAJOR_VERSION < 8 */
+ {
+ /* string interface */
+ char **argv;
+#define USE_RUBY_ALLOC 0
+#if USE_RUBY_ALLOC
+ argv = (char **)ALLOC_N(char *, 3);
+#else /* not USE_RUBY_ALLOC */
+ argv = RbTk_ALLOC_N(char *, 3);
+#if 0 /* use Tcl_Preserve/Release */
+ Tcl_Preserve((ClientData)argv); /* XXXXXXXX */
+#endif
+#endif
+ argv[0] = "exit";
+ argv[1] = RSTRING_PTR(rb_fix2str(INT2NUM(state), 10));
+ argv[2] = (char *)NULL;
+
+ ptr->return_value = (*(info->proc))(info->clientData, ptr->ip,
+ 2, argv);
+
+#if USE_RUBY_ALLOC
+ xfree(argv);
+#else /* not USE_RUBY_ALLOC */
+#if 0 /* use Tcl_EventuallyFree */
+ Tcl_EventuallyFree((ClientData)argv, TCL_DYNAMIC); /* XXXXXXXX */
+#else
+#if 0 /* use Tcl_Preserve/Release */
+ Tcl_Release((ClientData)argv); /* XXXXXXXX */
+#else
+ /* free(argv); */
+ ckfree(argv);
+#endif
+#endif
+#endif
+#undef USE_RUBY_ALLOC
+ }
+#endif
+ DUMP1("complete original_exit");
+
+ rb_thread_critical = thr_crit_bup;
+}
+
+/* Tk_ThreadTimer */
+static Tcl_TimerToken timer_token = (Tcl_TimerToken)NULL;
+
+/* timer callback */
+static void _timer_for_tcl _((ClientData));
+static void
+_timer_for_tcl(clientData)
+ ClientData clientData;
+{
+ int thr_crit_bup;
+
+ /* struct invoke_queue *q, *tmp; */
+ /* VALUE thread; */
+
+ DUMP1("call _timer_for_tcl");
+
+ thr_crit_bup = rb_thread_critical;
+ rb_thread_critical = Qtrue;
+
+ Tcl_DeleteTimerHandler(timer_token);
+
+ run_timer_flag = 1;
+
+ if (timer_tick > 0) {
+ timer_token = Tcl_CreateTimerHandler(timer_tick, _timer_for_tcl,
+ (ClientData)0);
+ } else {
+ timer_token = (Tcl_TimerToken)NULL;
+ }
+
+ rb_thread_critical = thr_crit_bup;
+
+ /* rb_thread_schedule(); */
+ /* tick_counter += event_loop_max; */
+}
+
+#ifdef RUBY_USE_NATIVE_THREAD
+#if USE_TOGGLE_WINDOW_MODE_FOR_IDLE
+static int
+toggle_eventloop_window_mode_for_idle(void)
+{
+ if (window_event_mode & TCL_IDLE_EVENTS) {
+ /* idle -> event */
+ window_event_mode |= TCL_WINDOW_EVENTS;
+ window_event_mode &= ~TCL_IDLE_EVENTS;
+ return 1;
+ } else {
+ /* event -> idle */
+ window_event_mode |= TCL_IDLE_EVENTS;
+ window_event_mode &= ~TCL_WINDOW_EVENTS;
+ return 0;
+ }
+}
+#endif
+#endif
+
+static VALUE
+set_eventloop_window_mode(self, mode)
+ VALUE self;
+ VALUE mode;
+{
+
+ if (RTEST(mode)) {
+ window_event_mode = ~0;
+ } else {
+ window_event_mode = ~TCL_WINDOW_EVENTS;
+ }
+
+ return mode;
+}
+
+static VALUE
+get_eventloop_window_mode(self)
+ VALUE self;
+{
+ if ( ~window_event_mode ) {
+ return Qfalse;
+ } else {
+ return Qtrue;
+ }
+}
+
+static VALUE
+set_eventloop_tick(self, tick)
+ VALUE self;
+ VALUE tick;
+{
+ int ttick = NUM2INT(tick);
+ int thr_crit_bup;
+
+
+ if (ttick < 0) {
+ rb_raise(rb_eArgError,
+ "timer-tick parameter must be 0 or positive number");
+ }
+
+ thr_crit_bup = rb_thread_critical;
+ rb_thread_critical = Qtrue;
+
+ /* delete old timer callback */
+ Tcl_DeleteTimerHandler(timer_token);
+
+ timer_tick = req_timer_tick = ttick;
+ if (timer_tick > 0) {
+ /* start timer callback */
+ timer_token = Tcl_CreateTimerHandler(timer_tick, _timer_for_tcl,
+ (ClientData)0);
+ } else {
+ timer_token = (Tcl_TimerToken)NULL;
+ }
+
+ rb_thread_critical = thr_crit_bup;
+
+ return tick;
+}
+
+static VALUE
+get_eventloop_tick(self)
+ VALUE self;
+{
+ return INT2NUM(timer_tick);
+}
+
+static VALUE
+ip_set_eventloop_tick(self, tick)
+ VALUE self;
+ VALUE tick;
+{
+ struct tcltkip *ptr = get_ip(self);
+
+ /* ip is deleted? */
+ if (deleted_ip(ptr)) {
+ return get_eventloop_tick(self);
+ }
+
+ if (Tcl_GetMaster(ptr->ip) != (Tcl_Interp*)NULL) {
+ /* slave IP */
+ return get_eventloop_tick(self);
+ }
+ return set_eventloop_tick(self, tick);
+}
+
+static VALUE
+ip_get_eventloop_tick(self)
+ VALUE self;
+{
+ return get_eventloop_tick(self);
+}
+
+static VALUE
+set_no_event_wait(self, wait)
+ VALUE self;
+ VALUE wait;
+{
+ int t_wait = NUM2INT(wait);
+
+
+ if (t_wait <= 0) {
+ rb_raise(rb_eArgError,
+ "no_event_wait parameter must be positive number");
+ }
+
+ no_event_wait = t_wait;
+
+ return wait;
+}
+
+static VALUE
+get_no_event_wait(self)
+ VALUE self;
+{
+ return INT2NUM(no_event_wait);
+}
+
+static VALUE
+ip_set_no_event_wait(self, wait)
+ VALUE self;
+ VALUE wait;
+{
+ struct tcltkip *ptr = get_ip(self);
+
+ /* ip is deleted? */
+ if (deleted_ip(ptr)) {
+ return get_no_event_wait(self);
+ }
+
+ if (Tcl_GetMaster(ptr->ip) != (Tcl_Interp*)NULL) {
+ /* slave IP */
+ return get_no_event_wait(self);
+ }
+ return set_no_event_wait(self, wait);
+}
+
+static VALUE
+ip_get_no_event_wait(self)
+ VALUE self;
+{
+ return get_no_event_wait(self);
+}
+
+static VALUE
+set_eventloop_weight(self, loop_max, no_event)
+ VALUE self;
+ VALUE loop_max;
+ VALUE no_event;
+{
+ int lpmax = NUM2INT(loop_max);
+ int no_ev = NUM2INT(no_event);
+
+
+ if (lpmax <= 0 || no_ev <= 0) {
+ rb_raise(rb_eArgError, "weight parameters must be positive numbers");
+ }
+
+ event_loop_max = lpmax;
+ no_event_tick = no_ev;
+
+ return rb_ary_new3(2, loop_max, no_event);
+}
+
+static VALUE
+get_eventloop_weight(self)
+ VALUE self;
+{
+ return rb_ary_new3(2, INT2NUM(event_loop_max), INT2NUM(no_event_tick));
+}
+
+static VALUE
+ip_set_eventloop_weight(self, loop_max, no_event)
+ VALUE self;
+ VALUE loop_max;
+ VALUE no_event;
+{
+ struct tcltkip *ptr = get_ip(self);
+
+ /* ip is deleted? */
+ if (deleted_ip(ptr)) {
+ return get_eventloop_weight(self);
+ }
+
+ if (Tcl_GetMaster(ptr->ip) != (Tcl_Interp*)NULL) {
+ /* slave IP */
+ return get_eventloop_weight(self);
+ }
+ return set_eventloop_weight(self, loop_max, no_event);
+}
+
+static VALUE
+ip_get_eventloop_weight(self)
+ VALUE self;
+{
+ return get_eventloop_weight(self);
+}
+
+static VALUE
+set_max_block_time(self, time)
+ VALUE self;
+ VALUE time;
+{
+ struct Tcl_Time tcl_time;
+ VALUE divmod;
+
+ switch(TYPE(time)) {
+ case T_FIXNUM:
+ case T_BIGNUM:
+ /* time is micro-second value */
+ divmod = rb_funcall(time, rb_intern("divmod"), 1, LONG2NUM(1000000));
+ tcl_time.sec = NUM2LONG(RARRAY_PTR(divmod)[0]);
+ tcl_time.usec = NUM2LONG(RARRAY_PTR(divmod)[1]);
+ break;
+
+ case T_FLOAT:
+ /* time is second value */
+ divmod = rb_funcall(time, rb_intern("divmod"), 1, INT2FIX(1));
+ tcl_time.sec = NUM2LONG(RARRAY_PTR(divmod)[0]);
+ tcl_time.usec = (long)(NUM2DBL(RARRAY_PTR(divmod)[1]) * 1000000);
+
+ default:
+ {
+ VALUE tmp = rb_funcall(time, ID_inspect, 0, 0);
+ rb_raise(rb_eArgError, "invalid value for time: '%s'",
+ StringValuePtr(tmp));
+ }
+ }
+
+ Tcl_SetMaxBlockTime(&tcl_time);
+
+ return Qnil;
+}
+
+static VALUE
+lib_evloop_thread_p(self)
+ VALUE self;
+{
+ if (NIL_P(eventloop_thread)) {
+ return Qnil; /* no eventloop */
+ } else if (rb_thread_current() == eventloop_thread) {
+ return Qtrue; /* is eventloop */
+ } else {
+ return Qfalse; /* not eventloop */
+ }
+}
+
+static VALUE
+lib_evloop_abort_on_exc(self)
+ VALUE self;
+{
+ if (event_loop_abort_on_exc > 0) {
+ return Qtrue;
+ } else if (event_loop_abort_on_exc == 0) {
+ return Qfalse;
+ } else {
+ return Qnil;
+ }
+}
+
+static VALUE
+ip_evloop_abort_on_exc(self)
+ VALUE self;
+{
+ return lib_evloop_abort_on_exc(self);
+}
+
+static VALUE
+lib_evloop_abort_on_exc_set(self, val)
+ VALUE self, val;
+{
+ if (RTEST(val)) {
+ event_loop_abort_on_exc = 1;
+ } else if (NIL_P(val)) {
+ event_loop_abort_on_exc = -1;
+ } else {
+ event_loop_abort_on_exc = 0;
+ }
+ return lib_evloop_abort_on_exc(self);
+}
+
+static VALUE
+ip_evloop_abort_on_exc_set(self, val)
+ VALUE self, val;
+{
+ struct tcltkip *ptr = get_ip(self);
+
+
+ /* ip is deleted? */
+ if (deleted_ip(ptr)) {
+ return lib_evloop_abort_on_exc(self);
+ }
+
+ if (Tcl_GetMaster(ptr->ip) != (Tcl_Interp*)NULL) {
+ /* slave IP */
+ return lib_evloop_abort_on_exc(self);
+ }
+ return lib_evloop_abort_on_exc_set(self, val);
+}
+
+static VALUE
+lib_num_of_mainwindows_core(self, argc, argv)
+ VALUE self;
+ int argc; /* dummy */
+ VALUE *argv; /* dummy */
+{
+ if (tk_stubs_init_p()) {
+ return INT2FIX(Tk_GetNumMainWindows());
+ } else {
+ return INT2FIX(0);
+ }
+}
+
+static VALUE
+lib_num_of_mainwindows(self)
+ VALUE self;
+{
+#ifdef RUBY_USE_NATIVE_THREAD /* Ruby 1.9+ !!! */
+ return tk_funcall(lib_num_of_mainwindows_core, 0, (VALUE*)NULL, self);
+#else
+ return lib_num_of_mainwindows_core(self, 0, (VALUE*)NULL);
+#endif
+}
+
+void
+rbtk_EventSetupProc(ClientData clientData, int flag)
+{
+ Tcl_Time tcl_time;
+ tcl_time.sec = 0;
+ tcl_time.usec = 1000L * (long)no_event_tick;
+ Tcl_SetMaxBlockTime(&tcl_time);
+}
+
+void
+rbtk_EventCheckProc(ClientData clientData, int flag)
+{
+ rb_thread_schedule();
+}
+
+
+#ifdef RUBY_USE_NATIVE_THREAD /* Ruby 1.9+ !!! */
+static VALUE
+#ifdef HAVE_PROTOTYPES
+call_DoOneEvent_core(VALUE flag_val)
+#else
+call_DoOneEvent_core(flag_val)
+ VALUE flag_val;
+#endif
+{
+ int flag;
+
+ flag = FIX2INT(flag_val);
+ if (Tcl_DoOneEvent(flag)) {
+ return Qtrue;
+ } else {
+ return Qfalse;
+ }
+}
+
+static VALUE
+#ifdef HAVE_PROTOTYPES
+call_DoOneEvent(VALUE flag_val)
+#else
+call_DoOneEvent(flag_val)
+ VALUE flag_val;
+#endif
+{
+ return tk_funcall(call_DoOneEvent_core, 0, (VALUE*)NULL, flag_val);
+}
+
+#else /* Ruby 1.8- */
+static VALUE
+#ifdef HAVE_PROTOTYPES
+call_DoOneEvent(VALUE flag_val)
+#else
+call_DoOneEvent(flag_val)
+ VALUE flag_val;
+#endif
+{
+ int flag;
+
+ flag = FIX2INT(flag_val);
+ if (Tcl_DoOneEvent(flag)) {
+ return Qtrue;
+ } else {
+ return Qfalse;
+ }
+}
+#endif
+
+
+#if 0
+static VALUE
+#ifdef HAVE_PROTOTYPES
+eventloop_sleep(VALUE dummy)
+#else
+eventloop_sleep(dummy)
+ VALUE dummy;
+#endif
+{
+ struct timeval t;
+
+ if (no_event_wait <= 0) {
+ return Qnil;
+ }
+
+ t.tv_sec = 0;
+ t.tv_usec = (int)(no_event_wait*1000.0);
+
+#ifdef HAVE_NATIVETHREAD
+#ifndef RUBY_USE_NATIVE_THREAD
+ if (!ruby_native_thread_p()) {
+ rb_bug("cross-thread violation on eventloop_sleep()");
+ }
+#endif
+#endif
+
+ DUMP2("eventloop_sleep: rb_thread_wait_for() at thread : %"PRIxVALUE, rb_thread_current());
+ rb_thread_wait_for(t);
+ DUMP2("eventloop_sleep: finish at thread : %"PRIxVALUE, rb_thread_current());
+
+#ifdef HAVE_NATIVETHREAD
+#ifndef RUBY_USE_NATIVE_THREAD
+ if (!ruby_native_thread_p()) {
+ rb_bug("cross-thread violation on eventloop_sleep()");
+ }
+#endif
+#endif
+
+ return Qnil;
+}
+#endif
+
+#define USE_EVLOOP_THREAD_ALONE_CHECK_FLAG 0
+
+#if USE_EVLOOP_THREAD_ALONE_CHECK_FLAG
+static int
+get_thread_alone_check_flag(void)
+{
+#ifdef RUBY_USE_NATIVE_THREAD
+ return 0;
+#else
+ set_tcltk_version();
+
+ if (tcltk_version.major < 8) {
+ /* Tcl/Tk 7.x */
+ return 1;
+ } else if (tcltk_version.major == 8) {
+ if (tcltk_version.minor < 5) {
+ /* Tcl/Tk 8.0 - 8.4 */
+ return 1;
+ } else if (tcltk_version.minor == 5) {
+ if (tcltk_version.type < TCL_FINAL_RELEASE) {
+ /* Tcl/Tk 8.5a? - 8.5b? */
+ return 1;
+ } else {
+ /* Tcl/Tk 8.5.x */
+ return 0;
+ }
+ } else {
+ /* Tcl/Tk 8.6 - 8.9 ?? */
+ return 0;
+ }
+ } else {
+ /* Tcl/Tk 9+ ?? */
+ return 0;
+ }
+#endif
+}
+#endif
+
+#define TRAP_CHECK() do { \
+ if (trap_check(check_var) == 0) return 0; \
+} while (0)
+
+static int
+trap_check(int *check_var)
+{
+ DUMP1("trap check");
+
+#ifdef RUBY_VM
+ if (rb_thread_check_trap_pending()) {
+ if (check_var != (int*)NULL) {
+ /* wait command */
+ return 0;
+ }
+ else {
+ rb_thread_check_ints();
+ }
+ }
+#else
+ if (rb_trap_pending) {
+ run_timer_flag = 0;
+ if (rb_prohibit_interrupt || check_var != (int*)NULL) {
+ /* pending or on wait command */
+ return 0;
+ } else {
+ rb_trap_exec();
+ }
+ }
+#endif
+
+ return 1;
+}
+
+static int
+check_eventloop_interp(void)
+{
+ DUMP1("check eventloop_interp");
+ if (eventloop_interp != (Tcl_Interp*)NULL
+ && Tcl_InterpDeleted(eventloop_interp)) {
+ DUMP2("eventloop_interp(%p) was deleted", eventloop_interp);
+ return 1;
+ }
+
+ return 0;
+}
+
+static int
+lib_eventloop_core(check_root, update_flag, check_var, interp)
+ int check_root;
+ int update_flag;
+ int *check_var;
+ Tcl_Interp *interp;
+{
+ volatile VALUE current = eventloop_thread;
+ int found_event = 1;
+ int event_flag;
+#if 0
+ struct timeval t;
+#endif
+ int thr_crit_bup;
+ int status;
+ int depth = rbtk_eventloop_depth;
+#if USE_EVLOOP_THREAD_ALONE_CHECK_FLAG
+ int thread_alone_check_flag = 1;
+#else
+ enum {thread_alone_check_flag = 1};
+#endif
+
+ if (update_flag) DUMP1("update loop start!!");
+
+#if 0
+ t.tv_sec = 0;
+ t.tv_usec = 1000 * no_event_wait;
+#endif
+
+ Tcl_DeleteTimerHandler(timer_token);
+ run_timer_flag = 0;
+ if (timer_tick > 0) {
+ thr_crit_bup = rb_thread_critical;
+ rb_thread_critical = Qtrue;
+ timer_token = Tcl_CreateTimerHandler(timer_tick, _timer_for_tcl,
+ (ClientData)0);
+ rb_thread_critical = thr_crit_bup;
+ } else {
+ timer_token = (Tcl_TimerToken)NULL;
+ }
+
+#if USE_EVLOOP_THREAD_ALONE_CHECK_FLAG
+ /* version check */
+ thread_alone_check_flag = get_thread_alone_check_flag();
+#endif
+
+ for(;;) {
+ if (check_eventloop_interp()) return 0;
+
+ if (thread_alone_check_flag && rb_thread_alone()) {
+ DUMP1("no other thread");
+ event_loop_wait_event = 0;
+
+ if (update_flag) {
+ event_flag = update_flag;
+ /* event_flag = update_flag | TCL_DONT_WAIT; */ /* for safety */
+ } else {
+ event_flag = TCL_ALL_EVENTS;
+ /* event_flag = TCL_ALL_EVENTS | TCL_DONT_WAIT; */
+ }
+
+ if (timer_tick == 0 && update_flag == 0) {
+ timer_tick = NO_THREAD_INTERRUPT_TIME;
+ timer_token = Tcl_CreateTimerHandler(timer_tick,
+ _timer_for_tcl,
+ (ClientData)0);
+ }
+
+ if (check_var != (int *)NULL) {
+ if (*check_var || !found_event) {
+ return found_event;
+ }
+ if (interp != (Tcl_Interp*)NULL
+ && Tcl_InterpDeleted(interp)) {
+ /* IP for check_var is deleted */
+ return 0;
+ }
+ }
+
+ /* found_event = Tcl_DoOneEvent(event_flag); */
+ found_event = RTEST(rb_protect(call_DoOneEvent,
+ INT2FIX(event_flag), &status));
+ if (status) {
+ switch (status) {
+ case TAG_RAISE:
+ if (NIL_P(rb_errinfo())) {
+ rbtk_pending_exception
+ = rb_exc_new2(rb_eException, "unknown exception");
+ } else {
+ rbtk_pending_exception = rb_errinfo();
+
+ if (!NIL_P(rbtk_pending_exception)) {
+ if (rbtk_eventloop_depth == 0) {
+ VALUE exc = rbtk_pending_exception;
+ rbtk_pending_exception = Qnil;
+ rb_exc_raise(exc);
+ } else {
+ return 0;
+ }
+ }
+ }
+ break;
+
+ case TAG_FATAL:
+ if (NIL_P(rb_errinfo())) {
+ rb_exc_raise(rb_exc_new2(rb_eFatal, "FATAL"));
+ } else {
+ rb_exc_raise(rb_errinfo());
+ }
+ }
+ }
+
+ if (depth != rbtk_eventloop_depth) {
+ DUMP2("DoOneEvent(1) abnormal exit!! %d",
+ rbtk_eventloop_depth);
+ }
+
+ if (check_var != (int*)NULL && !NIL_P(rbtk_pending_exception)) {
+ DUMP1("exception on wait");
+ return 0;
+ }
+
+ if (pending_exception_check0()) {
+ /* pending -> upper level */
+ return 0;
+ }
+
+ if (update_flag != 0) {
+ if (found_event) {
+ DUMP1("next update loop");
+ continue;
+ } else {
+ DUMP1("update complete");
+ return 0;
+ }
+ }
+
+ TRAP_CHECK();
+ if (check_eventloop_interp()) return 0;
+
+ DUMP1("check Root Widget");
+ if (check_root && tk_stubs_init_p() && Tk_GetNumMainWindows() == 0) {
+ run_timer_flag = 0;
+ TRAP_CHECK();
+ return 1;
+ }
+
+ if (loop_counter++ > 30000) {
+ /* fprintf(stderr, "loop_counter > 30000\n"); */
+ loop_counter = 0;
+ }
+
+ } else {
+ int tick_counter;
+
+ DUMP1("there are other threads");
+ event_loop_wait_event = 1;
+
+ found_event = 1;
+
+ if (update_flag) {
+ event_flag = update_flag; /* for safety */
+ /* event_flag = update_flag | TCL_DONT_WAIT; */ /* for safety */
+ } else {
+ event_flag = TCL_ALL_EVENTS;
+ /* event_flag = TCL_ALL_EVENTS | TCL_DONT_WAIT; */
+ }
+
+ timer_tick = req_timer_tick;
+ tick_counter = 0;
+ while(tick_counter < event_loop_max) {
+ if (check_var != (int *)NULL) {
+ if (*check_var || !found_event) {
+ return found_event;
+ }
+ if (interp != (Tcl_Interp*)NULL
+ && Tcl_InterpDeleted(interp)) {
+ /* IP for check_var is deleted */
+ return 0;
+ }
+ }
+
+ if (NIL_P(eventloop_thread) || current == eventloop_thread) {
+ int st;
+ int status;
+
+#ifdef RUBY_USE_NATIVE_THREAD
+ if (update_flag) {
+ st = RTEST(rb_protect(call_DoOneEvent,
+ INT2FIX(event_flag), &status));
+ } else {
+ st = RTEST(rb_protect(call_DoOneEvent,
+ INT2FIX(event_flag & window_event_mode),
+ &status));
+#if USE_TOGGLE_WINDOW_MODE_FOR_IDLE
+ if (!st) {
+ if (toggle_eventloop_window_mode_for_idle()) {
+ /* idle-mode -> event-mode*/
+ tick_counter = event_loop_max;
+ } else {
+ /* event-mode -> idle-mode */
+ tick_counter = 0;
+ }
+ }
+#endif
+ }
+#else
+ /* st = Tcl_DoOneEvent(event_flag); */
+ st = RTEST(rb_protect(call_DoOneEvent,
+ INT2FIX(event_flag), &status));
+#endif
+
+#if CONTROL_BY_STATUS_OF_RB_THREAD_WAITING_FOR_VALUE
+ if (have_rb_thread_waiting_for_value) {
+ have_rb_thread_waiting_for_value = 0;
+ rb_thread_schedule();
+ }
+#endif
+
+ if (status) {
+ switch (status) {
+ case TAG_RAISE:
+ if (NIL_P(rb_errinfo())) {
+ rbtk_pending_exception
+ = rb_exc_new2(rb_eException,
+ "unknown exception");
+ } else {
+ rbtk_pending_exception = rb_errinfo();
+
+ if (!NIL_P(rbtk_pending_exception)) {
+ if (rbtk_eventloop_depth == 0) {
+ VALUE exc = rbtk_pending_exception;
+ rbtk_pending_exception = Qnil;
+ rb_exc_raise(exc);
+ } else {
+ return 0;
+ }
+ }
+ }
+ break;
+
+ case TAG_FATAL:
+ if (NIL_P(rb_errinfo())) {
+ rb_exc_raise(rb_exc_new2(rb_eFatal, "FATAL"));
+ } else {
+ rb_exc_raise(rb_errinfo());
+ }
+ }
+ }
+
+ if (depth != rbtk_eventloop_depth) {
+ DUMP2("DoOneEvent(2) abnormal exit!! %d",
+ rbtk_eventloop_depth);
+ return 0;
+ }
+
+ TRAP_CHECK();
+
+ if (check_var != (int*)NULL
+ && !NIL_P(rbtk_pending_exception)) {
+ DUMP1("exception on wait");
+ return 0;
+ }
+
+ if (pending_exception_check0()) {
+ /* pending -> upper level */
+ return 0;
+ }
+
+ if (st) {
+ tick_counter++;
+ } else {
+ if (update_flag != 0) {
+ DUMP1("update complete");
+ return 0;
+ }
+
+ tick_counter += no_event_tick;
+
+#if 0
+ /* rb_thread_wait_for(t); */
+ rb_protect(eventloop_sleep, Qnil, &status);
+
+ if (status) {
+ switch (status) {
+ case TAG_RAISE:
+ if (NIL_P(rb_errinfo())) {
+ rbtk_pending_exception
+ = rb_exc_new2(rb_eException,
+ "unknown exception");
+ } else {
+ rbtk_pending_exception = rb_errinfo();
+
+ if (!NIL_P(rbtk_pending_exception)) {
+ if (rbtk_eventloop_depth == 0) {
+ VALUE exc = rbtk_pending_exception;
+ rbtk_pending_exception = Qnil;
+ rb_exc_raise(exc);
+ } else {
+ return 0;
+ }
+ }
+ }
+ break;
+
+ case TAG_FATAL:
+ if (NIL_P(rb_errinfo())) {
+ rb_exc_raise(rb_exc_new2(rb_eFatal,
+ "FATAL"));
+ } else {
+ rb_exc_raise(rb_errinfo());
+ }
+ }
+ }
+#endif
+ }
+
+ } else {
+ DUMP2("sleep eventloop %"PRIxVALUE, current);
+ DUMP2("eventloop thread is %"PRIxVALUE, eventloop_thread);
+ /* rb_thread_stop(); */
+ rb_thread_sleep_forever();
+ }
+
+ if (!NIL_P(watchdog_thread) && eventloop_thread != current) {
+ return 1;
+ }
+
+ TRAP_CHECK();
+ if (check_eventloop_interp()) return 0;
+
+ DUMP1("check Root Widget");
+ if (check_root && tk_stubs_init_p() && Tk_GetNumMainWindows() == 0) {
+ run_timer_flag = 0;
+ TRAP_CHECK();
+ return 1;
+ }
+
+ if (loop_counter++ > 30000) {
+ /* fprintf(stderr, "loop_counter > 30000\n"); */
+ loop_counter = 0;
+ }
+
+ if (run_timer_flag) {
+ /*
+ DUMP1("timer interrupt");
+ run_timer_flag = 0;
+ */
+ break; /* switch to other thread */
+ }
+ }
+
+ DUMP1("thread scheduling");
+ rb_thread_schedule();
+ }
+
+ DUMP1("check interrupts");
+#if defined(RUBY_USE_NATIVE_THREAD) || defined(RUBY_VM)
+ if (update_flag == 0) rb_thread_check_ints();
+#else
+ if (update_flag == 0) CHECK_INTS;
+#endif
+
+ }
+ return 1;
+}
+
+
+struct evloop_params {
+ int check_root;
+ int update_flag;
+ int *check_var;
+ Tcl_Interp *interp;
+ int thr_crit_bup;
+};
+
+VALUE
+lib_eventloop_main_core(args)
+ VALUE args;
+{
+ struct evloop_params *params = (struct evloop_params *)args;
+
+ check_rootwidget_flag = params->check_root;
+
+ Tcl_CreateEventSource(rbtk_EventSetupProc, rbtk_EventCheckProc, (ClientData)args);
+
+ if (lib_eventloop_core(params->check_root,
+ params->update_flag,
+ params->check_var,
+ params->interp)) {
+ return Qtrue;
+ } else {
+ return Qfalse;
+ }
+}
+
+VALUE
+lib_eventloop_main(args)
+ VALUE args;
+{
+ return lib_eventloop_main_core(args);
+
+#if 0
+ volatile VALUE ret;
+ int status = 0;
+
+ ret = rb_protect(lib_eventloop_main_core, args, &status);
+
+ switch (status) {
+ case TAG_RAISE:
+ if (NIL_P(rb_errinfo())) {
+ rbtk_pending_exception
+ = rb_exc_new2(rb_eException, "unknown exception");
+ } else {
+ rbtk_pending_exception = rb_errinfo();
+ }
+ return Qnil;
+
+ case TAG_FATAL:
+ if (NIL_P(rb_errinfo())) {
+ rbtk_pending_exception = rb_exc_new2(rb_eFatal, "FATAL");
+ } else {
+ rbtk_pending_exception = rb_errinfo();
+ }
+ return Qnil;
+ }
+
+ return ret;
+#endif
+}
+
+VALUE
+lib_eventloop_ensure(args)
+ VALUE args;
+{
+ struct evloop_params *ptr = (struct evloop_params *)args;
+ volatile VALUE current_evloop = rb_thread_current();
+
+ Tcl_DeleteEventSource(rbtk_EventSetupProc, rbtk_EventCheckProc, (ClientData)args);
+
+ DUMP2("eventloop_ensure: current-thread : %"PRIxVALUE, current_evloop);
+ DUMP2("eventloop_ensure: eventloop-thread : %"PRIxVALUE, eventloop_thread);
+ if (eventloop_thread != current_evloop) {
+ DUMP2("finish eventloop %"PRIxVALUE" (NOT current eventloop)", current_evloop);
+
+ rb_thread_critical = ptr->thr_crit_bup;
+
+ xfree(ptr);
+ /* ckfree((char*)ptr); */
+
+ return Qnil;
+ }
+
+ while((eventloop_thread = rb_ary_pop(eventloop_stack))) {
+ DUMP2("eventloop-ensure: new eventloop-thread -> %"PRIxVALUE,
+ eventloop_thread);
+
+ if (eventloop_thread == current_evloop) {
+ rbtk_eventloop_depth--;
+ DUMP2("eventloop %"PRIxVALUE" : back from recursive call", current_evloop);
+ break;
+ }
+
+ if (NIL_P(eventloop_thread)) {
+ Tcl_DeleteTimerHandler(timer_token);
+ timer_token = (Tcl_TimerToken)NULL;
+
+ break;
+ }
+
+ if (RTEST(rb_thread_alive_p(eventloop_thread))) {
+ DUMP2("eventloop-enshure: wake up parent %"PRIxVALUE, eventloop_thread);
+ rb_thread_wakeup(eventloop_thread);
+
+ break;
+ }
+ }
+
+#ifdef RUBY_USE_NATIVE_THREAD
+ if (NIL_P(eventloop_thread)) {
+ tk_eventloop_thread_id = (Tcl_ThreadId) 0;
+ }
+#endif
+
+ rb_thread_critical = ptr->thr_crit_bup;
+
+ xfree(ptr);
+ /* ckfree((char*)ptr);*/
+
+ DUMP2("finish current eventloop %"PRIxVALUE, current_evloop);
+ return Qnil;
+}
+
+static VALUE
+lib_eventloop_launcher(check_root, update_flag, check_var, interp)
+ int check_root;
+ int update_flag;
+ int *check_var;
+ Tcl_Interp *interp;
+{
+ volatile VALUE parent_evloop = eventloop_thread;
+ struct evloop_params *args = ALLOC(struct evloop_params);
+ /* struct evloop_params *args = RbTk_ALLOC_N(struct evloop_params, 1); */
+
+ tcl_stubs_check();
+
+ eventloop_thread = rb_thread_current();
+#ifdef RUBY_USE_NATIVE_THREAD
+ tk_eventloop_thread_id = Tcl_GetCurrentThread();
+#endif
+
+ if (parent_evloop == eventloop_thread) {
+ DUMP2("eventloop: recursive call on %"PRIxVALUE, parent_evloop);
+ rbtk_eventloop_depth++;
+ }
+
+ if (!NIL_P(parent_evloop) && parent_evloop != eventloop_thread) {
+ DUMP2("wait for stop of parent_evloop %"PRIxVALUE, parent_evloop);
+ while(!RTEST(rb_funcall(parent_evloop, ID_stop_p, 0))) {
+ DUMP2("parent_evloop %"PRIxVALUE" doesn't stop", parent_evloop);
+ rb_thread_run(parent_evloop);
+ }
+ DUMP1("succeed to stop parent");
+ }
+
+ rb_ary_push(eventloop_stack, parent_evloop);
+
+ DUMP3("tcltklib: eventloop-thread : %"PRIxVALUE" -> %"PRIxVALUE"\n",
+ parent_evloop, eventloop_thread);
+
+ args->check_root = check_root;
+ args->update_flag = update_flag;
+ args->check_var = check_var;
+ args->interp = interp;
+ args->thr_crit_bup = rb_thread_critical;
+
+ rb_thread_critical = Qfalse;
+
+#if 0
+ return rb_ensure(lib_eventloop_main, (VALUE)args,
+ lib_eventloop_ensure, (VALUE)args);
+#endif
+ return rb_ensure(lib_eventloop_main_core, (VALUE)args,
+ lib_eventloop_ensure, (VALUE)args);
+}
+
+/* execute Tk_MainLoop */
+static VALUE
+lib_mainloop(argc, argv, self)
+ int argc;
+ VALUE *argv;
+ VALUE self;
+{
+ VALUE check_rootwidget;
+
+ if (rb_scan_args(argc, argv, "01", &check_rootwidget) == 0) {
+ check_rootwidget = Qtrue;
+ } else if (RTEST(check_rootwidget)) {
+ check_rootwidget = Qtrue;
+ } else {
+ check_rootwidget = Qfalse;
+ }
+
+ return lib_eventloop_launcher(RTEST(check_rootwidget), 0,
+ (int*)NULL, (Tcl_Interp*)NULL);
+}
+
+static VALUE
+ip_mainloop(argc, argv, self)
+ int argc;
+ VALUE *argv;
+ VALUE self;
+{
+ volatile VALUE ret;
+ struct tcltkip *ptr = get_ip(self);
+
+ /* ip is deleted? */
+ if (deleted_ip(ptr)) {
+ return Qnil;
+ }
+
+ if (Tcl_GetMaster(ptr->ip) != (Tcl_Interp*)NULL) {
+ /* slave IP */
+ return Qnil;
+ }
+
+ eventloop_interp = ptr->ip;
+ ret = lib_mainloop(argc, argv, self);
+ eventloop_interp = (Tcl_Interp*)NULL;
+ return ret;
+}
+
+
+static VALUE
+watchdog_evloop_launcher(check_rootwidget)
+ VALUE check_rootwidget;
+{
+ return lib_eventloop_launcher(RTEST(check_rootwidget), 0,
+ (int*)NULL, (Tcl_Interp*)NULL);
+}
+
+#define EVLOOP_WAKEUP_CHANCE 3
+
+static VALUE
+lib_watchdog_core(check_rootwidget)
+ VALUE check_rootwidget;
+{
+ VALUE evloop;
+ int prev_val = -1;
+ int chance = 0;
+ int check = RTEST(check_rootwidget);
+ struct timeval t0, t1;
+
+ t0.tv_sec = 0;
+ t0.tv_usec = (long)((NO_THREAD_INTERRUPT_TIME)*1000.0);
+ t1.tv_sec = 0;
+ t1.tv_usec = (long)((WATCHDOG_INTERVAL)*1000.0);
+
+ /* check other watchdog thread */
+ if (!NIL_P(watchdog_thread)) {
+ if (RTEST(rb_funcall(watchdog_thread, ID_stop_p, 0))) {
+ rb_funcall(watchdog_thread, ID_kill, 0);
+ } else {
+ return Qnil;
+ }
+ }
+ watchdog_thread = rb_thread_current();
+
+ /* watchdog start */
+ do {
+ if (NIL_P(eventloop_thread)
+ || (loop_counter == prev_val && chance >= EVLOOP_WAKEUP_CHANCE)) {
+ /* start new eventloop thread */
+ DUMP2("eventloop thread %"PRIxVALUE" is sleeping or dead",
+ eventloop_thread);
+ evloop = rb_thread_create(watchdog_evloop_launcher,
+ (void*)&check_rootwidget);
+ DUMP2("create new eventloop thread %"PRIxVALUE, evloop);
+ loop_counter = -1;
+ chance = 0;
+ rb_thread_run(evloop);
+ } else {
+ prev_val = loop_counter;
+ if (RTEST(rb_funcall(eventloop_thread, ID_stop_p, 0))) {
+ ++chance;
+ } else {
+ chance = 0;
+ }
+ if (event_loop_wait_event) {
+ rb_thread_wait_for(t0);
+ } else {
+ rb_thread_wait_for(t1);
+ }
+ /* rb_thread_schedule(); */
+ }
+ } while(!check || !tk_stubs_init_p() || Tk_GetNumMainWindows() != 0);
+
+ return Qnil;
+}
+
+VALUE
+lib_watchdog_ensure(arg)
+ VALUE arg;
+{
+ eventloop_thread = Qnil; /* stop eventloops */
+#ifdef RUBY_USE_NATIVE_THREAD
+ tk_eventloop_thread_id = (Tcl_ThreadId) 0;
+#endif
+ return Qnil;
+}
+
+static VALUE
+lib_mainloop_watchdog(argc, argv, self)
+ int argc;
+ VALUE *argv;
+ VALUE self;
+{
+ VALUE check_rootwidget;
+
+#ifdef RUBY_VM
+ rb_raise(rb_eNotImpError,
+ "eventloop_watchdog is not implemented on Ruby VM.");
+#endif
+
+ if (rb_scan_args(argc, argv, "01", &check_rootwidget) == 0) {
+ check_rootwidget = Qtrue;
+ } else if (RTEST(check_rootwidget)) {
+ check_rootwidget = Qtrue;
+ } else {
+ check_rootwidget = Qfalse;
+ }
+
+ return rb_ensure(lib_watchdog_core, check_rootwidget,
+ lib_watchdog_ensure, Qnil);
+}
+
+static VALUE
+ip_mainloop_watchdog(argc, argv, self)
+ int argc;
+ VALUE *argv;
+ VALUE self;
+{
+ struct tcltkip *ptr = get_ip(self);
+
+ /* ip is deleted? */
+ if (deleted_ip(ptr)) {
+ return Qnil;
+ }
+
+ if (Tcl_GetMaster(ptr->ip) != (Tcl_Interp*)NULL) {
+ /* slave IP */
+ return Qnil;
+ }
+ return lib_mainloop_watchdog(argc, argv, self);
+}
+
+
+/* thread-safe(?) interaction between Ruby and Tk */
+struct thread_call_proc_arg {
+ VALUE proc;
+ int *done;
+};
+
+void
+_thread_call_proc_arg_mark(struct thread_call_proc_arg *q)
+{
+ rb_gc_mark(q->proc);
+}
+
+static VALUE
+_thread_call_proc_core(arg)
+ VALUE arg;
+{
+ struct thread_call_proc_arg *q = (struct thread_call_proc_arg*)arg;
+ return rb_funcall(q->proc, ID_call, 0);
+}
+
+static VALUE
+_thread_call_proc_ensure(arg)
+ VALUE arg;
+{
+ struct thread_call_proc_arg *q = (struct thread_call_proc_arg*)arg;
+ *(q->done) = 1;
+ return Qnil;
+}
+
+static VALUE
+_thread_call_proc(arg)
+ VALUE arg;
+{
+ struct thread_call_proc_arg *q = (struct thread_call_proc_arg*)arg;
+
+ return rb_ensure(_thread_call_proc_core, (VALUE)q,
+ _thread_call_proc_ensure, (VALUE)q);
+}
+
+static VALUE
+#ifdef HAVE_PROTOTYPES
+_thread_call_proc_value(VALUE th)
+#else
+_thread_call_proc_value(th)
+ VALUE th;
+#endif
+{
+ return rb_funcall(th, ID_value, 0);
+}
+
+static VALUE
+lib_thread_callback(argc, argv, self)
+ int argc;
+ VALUE *argv;
+ VALUE self;
+{
+ struct thread_call_proc_arg *q;
+ VALUE proc, th, ret;
+ int status;
+
+ if (rb_scan_args(argc, argv, "01", &proc) == 0) {
+ proc = rb_block_proc();
+ }
+
+ q = (struct thread_call_proc_arg *)ALLOC(struct thread_call_proc_arg);
+ /* q = RbTk_ALLOC_N(struct thread_call_proc_arg, 1); */
+ q->proc = proc;
+ q->done = (int*)ALLOC(int);
+ /* q->done = RbTk_ALLOC_N(int, 1); */
+ *(q->done) = 0;
+
+ /* create call-proc thread */
+ th = rb_thread_create(_thread_call_proc, (void*)q);
+
+ rb_thread_schedule();
+
+ /* start sub-eventloop */
+ lib_eventloop_launcher(/* not check root-widget */0, 0,
+ q->done, (Tcl_Interp*)NULL);
+
+ if (RTEST(rb_thread_alive_p(th))) {
+ rb_funcall(th, ID_kill, 0);
+ ret = Qnil;
+ } else {
+ ret = rb_protect(_thread_call_proc_value, th, &status);
+ }
+
+ xfree(q->done);
+ xfree(q);
+ /* ckfree((char*)q->done); */
+ /* ckfree((char*)q); */
+
+ if (NIL_P(rbtk_pending_exception)) {
+ /* return rb_errinfo(); */
+ if (status) {
+ rb_exc_raise(rb_errinfo());
+ }
+ } else {
+ VALUE exc = rbtk_pending_exception;
+ rbtk_pending_exception = Qnil;
+ /* return exc; */
+ rb_exc_raise(exc);
+ }
+
+ return ret;
+}
+
+
+/* do_one_event */
+static VALUE
+lib_do_one_event_core(argc, argv, self, is_ip)
+ int argc;
+ VALUE *argv;
+ VALUE self;
+ int is_ip;
+{
+ volatile VALUE vflags;
+ int flags;
+ int found_event;
+
+ if (!NIL_P(eventloop_thread)) {
+ rb_raise(rb_eRuntimeError, "eventloop is already running");
+ }
+
+ tcl_stubs_check();
+
+ if (rb_scan_args(argc, argv, "01", &vflags) == 0) {
+ flags = TCL_ALL_EVENTS | TCL_DONT_WAIT;
+ } else {
+ Check_Type(vflags, T_FIXNUM);
+ flags = FIX2INT(vflags);
+ }
+
+ if (rb_safe_level() >= 4 || (rb_safe_level() >=1 && OBJ_TAINTED(vflags))) {
+ flags |= TCL_DONT_WAIT;
+ }
+
+ if (is_ip) {
+ /* check IP */
+ struct tcltkip *ptr = get_ip(self);
+
+ /* ip is deleted? */
+ if (deleted_ip(ptr)) {
+ return Qfalse;
+ }
+
+ if (Tcl_GetMaster(ptr->ip) != (Tcl_Interp*)NULL) {
+ /* slave IP */
+ flags |= TCL_DONT_WAIT;
+ }
+ }
+
+ /* found_event = Tcl_DoOneEvent(TCL_ALL_EVENTS | TCL_DONT_WAIT); */
+ found_event = Tcl_DoOneEvent(flags);
+
+ if (pending_exception_check0()) {
+ return Qfalse;
+ }
+
+ if (found_event) {
+ return Qtrue;
+ } else {
+ return Qfalse;
+ }
+}
+
+static VALUE
+lib_do_one_event(argc, argv, self)
+ int argc;
+ VALUE *argv;
+ VALUE self;
+{
+ return lib_do_one_event_core(argc, argv, self, 0);
+}
+
+static VALUE
+ip_do_one_event(argc, argv, self)
+ int argc;
+ VALUE *argv;
+ VALUE self;
+{
+ return lib_do_one_event_core(argc, argv, self, 0);
+}
+
+
+static void
+ip_set_exc_message(interp, exc)
+ Tcl_Interp *interp;
+ VALUE exc;
+{
+ char *buf;
+ Tcl_DString dstr;
+ volatile VALUE msg;
+ int thr_crit_bup;
+
+#if TCL_MAJOR_VERSION > 8 || (TCL_MAJOR_VERSION == 8 && TCL_MINOR_VERSION > 0)
+ volatile VALUE enc;
+ Tcl_Encoding encoding;
+#endif
+
+ thr_crit_bup = rb_thread_critical;
+ rb_thread_critical = Qtrue;
+
+ msg = rb_funcall(exc, ID_message, 0, 0);
+ StringValue(msg);
+
+#if TCL_MAJOR_VERSION > 8 || (TCL_MAJOR_VERSION == 8 && TCL_MINOR_VERSION > 0)
+ enc = rb_attr_get(exc, ID_at_enc);
+ if (NIL_P(enc)) {
+ enc = rb_attr_get(msg, ID_at_enc);
+ }
+ if (NIL_P(enc)) {
+ encoding = (Tcl_Encoding)NULL;
+ } else if (RB_TYPE_P(enc, T_STRING)) {
+ /* encoding = Tcl_GetEncoding(interp, RSTRING_PTR(enc)); */
+ encoding = Tcl_GetEncoding((Tcl_Interp*)NULL, RSTRING_PTR(enc));
+ } else {
+ enc = rb_funcall(enc, ID_to_s, 0, 0);
+ /* encoding = Tcl_GetEncoding(interp, RSTRING_PTR(enc)); */
+ encoding = Tcl_GetEncoding((Tcl_Interp*)NULL, RSTRING_PTR(enc));
+ }
+
+ /* to avoid a garbled error message dialog */
+ /* buf = ALLOC_N(char, (RSTRING(msg)->len)+1);*/
+ /* memcpy(buf, RSTRING(msg)->ptr, RSTRING(msg)->len);*/
+ /* buf[RSTRING(msg)->len] = 0; */
+ buf = ALLOC_N(char, RSTRING_LENINT(msg)+1);
+ /* buf = ckalloc(RSTRING_LENINT(msg)+1); */
+ memcpy(buf, RSTRING_PTR(msg), RSTRING_LEN(msg));
+ buf[RSTRING_LEN(msg)] = 0;
+
+ Tcl_DStringInit(&dstr);
+ Tcl_DStringFree(&dstr);
+ Tcl_ExternalToUtfDString(encoding, buf, RSTRING_LENINT(msg), &dstr);
+
+ Tcl_AppendResult(interp, Tcl_DStringValue(&dstr), (char*)NULL);
+ DUMP2("error message:%s", Tcl_DStringValue(&dstr));
+ Tcl_DStringFree(&dstr);
+ xfree(buf);
+ /* ckfree(buf); */
+
+#else /* TCL_VERSION <= 8.0 */
+ Tcl_AppendResult(interp, RSTRING_PTR(msg), (char*)NULL);
+#endif
+
+ rb_thread_critical = thr_crit_bup;
+}
+
+static VALUE
+TkStringValue(obj)
+ VALUE obj;
+{
+ switch(TYPE(obj)) {
+ case T_STRING:
+ return obj;
+
+ case T_NIL:
+ return rb_str_new2("");
+
+ case T_TRUE:
+ return rb_str_new2("1");
+
+ case T_FALSE:
+ return rb_str_new2("0");
+
+ case T_ARRAY:
+ return rb_funcall(obj, ID_join, 1, rb_str_new2(" "));
+
+ default:
+ if (rb_respond_to(obj, ID_to_s)) {
+ return rb_funcall(obj, ID_to_s, 0, 0);
+ }
+ }
+
+ return rb_funcall(obj, ID_inspect, 0, 0);
+}
+
+static int
+#ifdef HAVE_PROTOTYPES
+tcl_protect_core(Tcl_Interp *interp, VALUE (*proc)(VALUE), VALUE data)
+#else
+tcl_protect_core(interp, proc, data) /* should not raise exception */
+ Tcl_Interp *interp;
+ VALUE (*proc)();
+ VALUE data;
+#endif
+{
+ volatile VALUE ret, exc = Qnil;
+ int status = 0;
+ int thr_crit_bup = rb_thread_critical;
+
+ Tcl_ResetResult(interp);
+
+ rb_thread_critical = Qfalse;
+ ret = rb_protect(proc, data, &status);
+ rb_thread_critical = Qtrue;
+ if (status) {
+ char *buf;
+ VALUE old_gc;
+ volatile VALUE type, str;
+
+ old_gc = rb_gc_disable();
+
+ switch(status) {
+ case TAG_RETURN:
+ type = eTkCallbackReturn;
+ goto error;
+ case TAG_BREAK:
+ type = eTkCallbackBreak;
+ goto error;
+ case TAG_NEXT:
+ type = eTkCallbackContinue;
+ goto error;
+ error:
+ str = rb_str_new2("LocalJumpError: ");
+ rb_str_append(str, rb_obj_as_string(rb_errinfo()));
+ exc = rb_exc_new3(type, str);
+ break;
+
+ case TAG_RETRY:
+ if (NIL_P(rb_errinfo())) {
+ DUMP1("rb_protect: retry");
+ exc = rb_exc_new2(eTkCallbackRetry, "retry jump error");
+ } else {
+ exc = rb_errinfo();
+ }
+ break;
+
+ case TAG_REDO:
+ if (NIL_P(rb_errinfo())) {
+ DUMP1("rb_protect: redo");
+ exc = rb_exc_new2(eTkCallbackRedo, "redo jump error");
+ } else {
+ exc = rb_errinfo();
+ }
+ break;
+
+ case TAG_RAISE:
+ if (NIL_P(rb_errinfo())) {
+ exc = rb_exc_new2(rb_eException, "unknown exception");
+ } else {
+ exc = rb_errinfo();
+ }
+ break;
+
+ case TAG_FATAL:
+ if (NIL_P(rb_errinfo())) {
+ exc = rb_exc_new2(rb_eFatal, "FATAL");
+ } else {
+ exc = rb_errinfo();
+ }
+ break;
+
+ case TAG_THROW:
+ if (NIL_P(rb_errinfo())) {
+ DUMP1("rb_protect: throw");
+ exc = rb_exc_new2(eTkCallbackThrow, "throw jump error");
+ } else {
+ exc = rb_errinfo();
+ }
+ break;
+
+ default:
+ buf = ALLOC_N(char, 256);
+ /* buf = ckalloc(sizeof(char) * 256); */
+ sprintf(buf, "unknown loncaljmp status %d", status);
+ exc = rb_exc_new2(rb_eException, buf);
+ xfree(buf);
+ /* ckfree(buf); */
+ break;
+ }
+
+ if (old_gc == Qfalse) rb_gc_enable();
+
+ ret = Qnil;
+ }
+
+ rb_thread_critical = thr_crit_bup;
+
+ Tcl_ResetResult(interp);
+
+ /* status check */
+ if (!NIL_P(exc)) {
+ volatile VALUE eclass = rb_obj_class(exc);
+ volatile VALUE backtrace;
+
+ DUMP1("(failed)");
+
+ thr_crit_bup = rb_thread_critical;
+ rb_thread_critical = Qtrue;
+
+ DUMP1("set backtrace");
+ if (!NIL_P(backtrace = rb_funcall(exc, ID_backtrace, 0, 0))) {
+ backtrace = rb_ary_join(backtrace, rb_str_new2("\n"));
+ Tcl_AddErrorInfo(interp, StringValuePtr(backtrace));
+ }
+
+ rb_thread_critical = thr_crit_bup;
+
+ ip_set_exc_message(interp, exc);
+
+ if (eclass == eTkCallbackReturn)
+ return TCL_RETURN;
+
+ if (eclass == eTkCallbackBreak)
+ return TCL_BREAK;
+
+ if (eclass == eTkCallbackContinue)
+ return TCL_CONTINUE;
+
+ if (eclass == rb_eSystemExit || eclass == rb_eInterrupt) {
+ rbtk_pending_exception = exc;
+ return TCL_RETURN;
+ }
+
+ if (rb_obj_is_kind_of(exc, eTkLocalJumpError)) {
+ rbtk_pending_exception = exc;
+ return TCL_ERROR;
+ }
+
+ if (rb_obj_is_kind_of(exc, eLocalJumpError)) {
+ VALUE reason = rb_ivar_get(exc, ID_at_reason);
+
+ if (RB_TYPE_P(reason, T_SYMBOL)) {
+ if (SYM2ID(reason) == ID_return)
+ return TCL_RETURN;
+
+ if (SYM2ID(reason) == ID_break)
+ return TCL_BREAK;
+
+ if (SYM2ID(reason) == ID_next)
+ return TCL_CONTINUE;
+ }
+ }
+
+ return TCL_ERROR;
+ }
+
+ /* result must be string or nil */
+ if (!NIL_P(ret)) {
+ /* copy result to the tcl interpreter */
+ thr_crit_bup = rb_thread_critical;
+ rb_thread_critical = Qtrue;
+
+ ret = TkStringValue(ret);
+ DUMP1("Tcl_AppendResult");
+ Tcl_AppendResult(interp, RSTRING_PTR(ret), (char *)NULL);
+
+ rb_thread_critical = thr_crit_bup;
+ }
+
+ DUMP2("(result) %s", NIL_P(ret) ? "nil" : RSTRING_PTR(ret));
+
+ return TCL_OK;
+}
+
+static int
+tcl_protect(interp, proc, data)
+ Tcl_Interp *interp;
+ VALUE (*proc)();
+ VALUE data;
+{
+ int code;
+
+#ifdef HAVE_NATIVETHREAD
+#ifndef RUBY_USE_NATIVE_THREAD
+ if (!ruby_native_thread_p()) {
+ rb_bug("cross-thread violation on tcl_protect()");
+ }
+#endif
+#endif
+
+#ifdef RUBY_VM
+ code = tcl_protect_core(interp, proc, data);
+#else
+ do {
+ int old_trapflag = rb_trap_immediate;
+ rb_trap_immediate = 0;
+ code = tcl_protect_core(interp, proc, data);
+ rb_trap_immediate = old_trapflag;
+ } while (0);
+#endif
+
+ return code;
+}
+
+static int
+#if TCL_MAJOR_VERSION >= 8
+ip_ruby_eval(clientData, interp, argc, argv)
+ ClientData clientData;
+ Tcl_Interp *interp;
+ int argc;
+ Tcl_Obj *CONST argv[];
+#else /* TCL_MAJOR_VERSION < 8 */
+ip_ruby_eval(clientData, interp, argc, argv)
+ ClientData clientData;
+ Tcl_Interp *interp;
+ int argc;
+ char *argv[];
+#endif
+{
+ char *arg;
+ int thr_crit_bup;
+ int code;
+
+ if (interp == (Tcl_Interp*)NULL) {
+ rbtk_pending_exception = rb_exc_new2(rb_eRuntimeError,
+ "IP is deleted");
+ return TCL_ERROR;
+ }
+
+ /* ruby command has 1 arg. */
+ if (argc != 2) {
+#if 0
+ rb_raise(rb_eArgError,
+ "wrong number of arguments (%d for 1)", argc - 1);
+#else
+ char buf[sizeof(int)*8 + 1];
+ Tcl_ResetResult(interp);
+ sprintf(buf, "%d", argc-1);
+ Tcl_AppendResult(interp, "wrong number of arguments (",
+ buf, " for 1)", (char *)NULL);
+ rbtk_pending_exception = rb_exc_new2(rb_eArgError,
+ Tcl_GetStringResult(interp));
+ return TCL_ERROR;
+#endif
+ }
+
+ /* get C string from Tcl object */
+#if TCL_MAJOR_VERSION >= 8
+ {
+ char *str;
+ int len;
+
+ thr_crit_bup = rb_thread_critical;
+ rb_thread_critical = Qtrue;
+
+ str = Tcl_GetStringFromObj(argv[1], &len);
+ arg = ALLOC_N(char, len + 1);
+ /* arg = ckalloc(sizeof(char) * (len + 1)); */
+ memcpy(arg, str, len);
+ arg[len] = 0;
+
+ rb_thread_critical = thr_crit_bup;
+
+ }
+#else /* TCL_MAJOR_VERSION < 8 */
+ arg = argv[1];
+#endif
+
+ /* evaluate the argument string by ruby */
+ DUMP2("rb_eval_string(%s)", arg);
+
+ code = tcl_protect(interp, rb_eval_string, (VALUE)arg);
+
+#if TCL_MAJOR_VERSION >= 8
+ xfree(arg);
+ /* ckfree(arg); */
+#endif
+
+ return code;
+}
+
+
+/* Tcl command `ruby_cmd' */
+static VALUE
+ip_ruby_cmd_core(arg)
+ struct cmd_body_arg *arg;
+{
+ volatile VALUE ret;
+ int thr_crit_bup;
+
+ DUMP1("call ip_ruby_cmd_core");
+ thr_crit_bup = rb_thread_critical;
+ rb_thread_critical = Qfalse;
+ ret = rb_apply(arg->receiver, arg->method, arg->args);
+ DUMP2("rb_apply return:%"PRIxVALUE, ret);
+ rb_thread_critical = thr_crit_bup;
+ DUMP1("finish ip_ruby_cmd_core");
+
+ return ret;
+}
+
+#define SUPPORT_NESTED_CONST_AS_IP_RUBY_CMD_RECEIVER 1
+
+static VALUE
+ip_ruby_cmd_receiver_const_get(name)
+ char *name;
+{
+ volatile VALUE klass = rb_cObject;
+#if 0
+ char *head, *tail;
+#endif
+ int state;
+
+#if SUPPORT_NESTED_CONST_AS_IP_RUBY_CMD_RECEIVER
+ klass = rb_eval_string_protect(name, &state);
+ if (state) {
+ return Qnil;
+ } else {
+ return klass;
+ }
+#else
+ return rb_const_get(klass, rb_intern(name));
+#endif
+
+ /* TODO!!!!!! */
+ /* support nest of classes/modules */
+
+ /* return rb_eval_string(name); */
+ /* return rb_eval_string_protect(name, &state); */
+
+#if 0 /* doesn't work!! (fail to autoload?) */
+ /* duplicate */
+ head = name = strdup(name);
+
+ /* has '::' at head ? */
+ if (*head == ':') head += 2;
+ tail = head;
+
+ /* search */
+ while(*tail) {
+ if (*tail == ':') {
+ *tail = '\0';
+ klass = rb_const_get(klass, rb_intern(head));
+ tail += 2;
+ head = tail;
+ } else {
+ tail++;
+ }
+ }
+
+ free(name);
+ return rb_const_get(klass, rb_intern(head));
+#endif
+}
+
+static VALUE
+ip_ruby_cmd_receiver_get(str)
+ char *str;
+{
+ volatile VALUE receiver;
+#if !SUPPORT_NESTED_CONST_AS_IP_RUBY_CMD_RECEIVER
+ int state;
+#endif
+
+ if (str[0] == ':' || ('A' <= str[0] && str[0] <= 'Z')) {
+ /* class | module | constant */
+#if SUPPORT_NESTED_CONST_AS_IP_RUBY_CMD_RECEIVER
+ receiver = ip_ruby_cmd_receiver_const_get(str);
+#else
+ receiver = rb_protect(ip_ruby_cmd_receiver_const_get, (VALUE)str, &state);
+ if (state) return Qnil;
+#endif
+ } else if (str[0] == '$') {
+ /* global variable */
+ receiver = rb_gv_get(str);
+ } else {
+ /* global variable omitted '$' */
+ char *buf;
+ size_t len;
+
+ len = strlen(str);
+ buf = ALLOC_N(char, len + 2);
+ /* buf = ckalloc(sizeof(char) * (len + 2)); */
+ buf[0] = '$';
+ memcpy(buf + 1, str, len);
+ buf[len + 1] = 0;
+ receiver = rb_gv_get(buf);
+ xfree(buf);
+ /* ckfree(buf); */
+ }
+
+ return receiver;
+}
+
+/* ruby_cmd receiver method arg ... */
+static int
+#if TCL_MAJOR_VERSION >= 8
+ip_ruby_cmd(clientData, interp, argc, argv)
+ ClientData clientData;
+ Tcl_Interp *interp;
+ int argc;
+ Tcl_Obj *CONST argv[];
+#else /* TCL_MAJOR_VERSION < 8 */
+ip_ruby_cmd(clientData, interp, argc, argv)
+ ClientData clientData;
+ Tcl_Interp *interp;
+ int argc;
+ char *argv[];
+#endif
+{
+ volatile VALUE receiver;
+ volatile ID method;
+ volatile VALUE args;
+ char *str;
+ int i;
+ int len;
+ struct cmd_body_arg *arg;
+ int thr_crit_bup;
+ VALUE old_gc;
+ int code;
+
+ if (interp == (Tcl_Interp*)NULL) {
+ rbtk_pending_exception = rb_exc_new2(rb_eRuntimeError,
+ "IP is deleted");
+ return TCL_ERROR;
+ }
+
+ if (argc < 3) {
+#if 0
+ rb_raise(rb_eArgError, "too few arguments");
+#else
+ Tcl_ResetResult(interp);
+ Tcl_AppendResult(interp, "too few arguments", (char *)NULL);
+ rbtk_pending_exception = rb_exc_new2(rb_eArgError,
+ Tcl_GetStringResult(interp));
+ return TCL_ERROR;
+#endif
+ }
+
+ /* get arguments from Tcl objects */
+ thr_crit_bup = rb_thread_critical;
+ rb_thread_critical = Qtrue;
+ old_gc = rb_gc_disable();
+
+ /* get receiver */
+#if TCL_MAJOR_VERSION >= 8
+ str = Tcl_GetStringFromObj(argv[1], &len);
+#else /* TCL_MAJOR_VERSION < 8 */
+ str = argv[1];
+#endif
+ DUMP2("receiver:%s",str);
+ /* receiver = rb_protect(ip_ruby_cmd_receiver_get, (VALUE)str, &code); */
+ receiver = ip_ruby_cmd_receiver_get(str);
+ if (NIL_P(receiver)) {
+#if 0
+ rb_raise(rb_eArgError,
+ "unknown class/module/global-variable '%s'", str);
+#else
+ Tcl_ResetResult(interp);
+ Tcl_AppendResult(interp, "unknown class/module/global-variable '",
+ str, "'", (char *)NULL);
+ rbtk_pending_exception = rb_exc_new2(rb_eArgError,
+ Tcl_GetStringResult(interp));
+ if (old_gc == Qfalse) rb_gc_enable();
+ return TCL_ERROR;
+#endif
+ }
+
+ /* get metrhod */
+#if TCL_MAJOR_VERSION >= 8
+ str = Tcl_GetStringFromObj(argv[2], &len);
+#else /* TCL_MAJOR_VERSION < 8 */
+ str = argv[2];
+#endif
+ method = rb_intern(str);
+
+ /* get args */
+ args = rb_ary_new2(argc - 2);
+ for(i = 3; i < argc; i++) {
+ VALUE s;
+#if TCL_MAJOR_VERSION >= 8
+ str = Tcl_GetStringFromObj(argv[i], &len);
+ s = rb_tainted_str_new(str, len);
+#else /* TCL_MAJOR_VERSION < 8 */
+ str = argv[i];
+ s = rb_tainted_str_new2(str);
+#endif
+ DUMP2("arg:%s",str);
+#ifndef HAVE_STRUCT_RARRAY_LEN
+ rb_ary_push(args, s);
+#else
+ RARRAY(args)->ptr[RARRAY(args)->len++] = s;
+#endif
+ }
+
+ if (old_gc == Qfalse) rb_gc_enable();
+ rb_thread_critical = thr_crit_bup;
+
+ /* allocate */
+ arg = ALLOC(struct cmd_body_arg);
+ /* arg = RbTk_ALLOC_N(struct cmd_body_arg, 1); */
+
+ arg->receiver = receiver;
+ arg->method = method;
+ arg->args = args;
+
+ /* evaluate the argument string by ruby */
+ code = tcl_protect(interp, ip_ruby_cmd_core, (VALUE)arg);
+
+ xfree(arg);
+ /* ckfree((char*)arg); */
+
+ return code;
+}
+
+
+/*****************************/
+/* relpace of 'exit' command */
+/*****************************/
+static int
+#if TCL_MAJOR_VERSION >= 8
+#ifdef HAVE_PROTOTYPES
+ip_InterpExitObjCmd(ClientData clientData, Tcl_Interp *interp,
+ int argc, Tcl_Obj *CONST argv[])
+#else
+ip_InterpExitObjCmd(clientData, interp, argc, argv)
+ ClientData clientData;
+ Tcl_Interp *interp;
+ int argc;
+ Tcl_Obj *CONST argv[];
+#endif
+#else /* TCL_MAJOR_VERSION < 8 */
+#ifdef HAVE_PROTOTYPES
+ip_InterpExitCommand(ClientData clientData, Tcl_Interp *interp,
+ int argc, char *argv[])
+#else
+ip_InterpExitCommand(clientData, interp, argc, argv)
+ ClientData clientData;
+ Tcl_Interp *interp;
+ int argc;
+ char *argv[];
+#endif
+#endif
+{
+ DUMP1("start ip_InterpExitCommand");
+ if (interp != (Tcl_Interp*)NULL
+ && !Tcl_InterpDeleted(interp)
+#if TCL_NAMESPACE_DEBUG
+ && !ip_null_namespace(interp)
+#endif
+ ) {
+ Tcl_ResetResult(interp);
+ /* Tcl_Preserve(interp); */
+ /* Tcl_Eval(interp, "interp eval {} {destroy .}; interp delete {}"); */
+ if (!Tcl_InterpDeleted(interp)) {
+ ip_finalize(interp);
+
+ Tcl_DeleteInterp(interp);
+ Tcl_Release(interp);
+ }
+ }
+ return TCL_OK;
+}
+
+static int
+#if TCL_MAJOR_VERSION >= 8
+#ifdef HAVE_PROTOTYPES
+ip_RubyExitObjCmd(ClientData clientData, Tcl_Interp *interp,
+ int argc, Tcl_Obj *CONST argv[])
+#else
+ip_RubyExitObjCmd(clientData, interp, argc, argv)
+ ClientData clientData;
+ Tcl_Interp *interp;
+ int argc;
+ Tcl_Obj *CONST argv[];
+#endif
+#else /* TCL_MAJOR_VERSION < 8 */
+#ifdef HAVE_PROTOTYPES
+ip_RubyExitCommand(ClientData clientData, Tcl_Interp *interp,
+ int argc, char *argv[])
+#else
+ip_RubyExitCommand(clientData, interp, argc, argv)
+ ClientData clientData;
+ Tcl_Interp *interp;
+ int argc;
+ char *argv[];
+#endif
+#endif
+{
+ int state;
+ char *cmd, *param;
+#if TCL_MAJOR_VERSION < 8
+ char *endptr;
+ cmd = argv[0];
+#endif
+
+ DUMP1("start ip_RubyExitCommand");
+
+#if TCL_MAJOR_VERSION >= 8
+ /* cmd = Tcl_GetString(argv[0]); */
+ cmd = Tcl_GetStringFromObj(argv[0], (int*)NULL);
+#endif
+
+ if (argc < 1 || argc > 2) {
+ /* argument error */
+ Tcl_AppendResult(interp,
+ "wrong number of arguments: should be \"",
+ cmd, " ?returnCode?\"", (char *)NULL);
+ return TCL_ERROR;
+ }
+
+ if (interp == (Tcl_Interp*)NULL) return TCL_OK;
+
+ Tcl_ResetResult(interp);
+
+ if (rb_safe_level() >= 4 || Tcl_IsSafe(interp)) {
+ if (!Tcl_InterpDeleted(interp)) {
+ ip_finalize(interp);
+
+ Tcl_DeleteInterp(interp);
+ Tcl_Release(interp);
+ }
+ return TCL_OK;
+ }
+
+ switch(argc) {
+ case 1:
+ /* rb_exit(0); */ /* not return if succeed */
+ Tcl_AppendResult(interp,
+ "fail to call \"", cmd, "\"", (char *)NULL);
+
+ rbtk_pending_exception = rb_exc_new2(rb_eSystemExit,
+ Tcl_GetStringResult(interp));
+ rb_iv_set(rbtk_pending_exception, "status", INT2FIX(0));
+
+ return TCL_RETURN;
+
+ case 2:
+#if TCL_MAJOR_VERSION >= 8
+ if (Tcl_GetIntFromObj(interp, argv[1], &state) == TCL_ERROR) {
+ return TCL_ERROR;
+ }
+ /* param = Tcl_GetString(argv[1]); */
+ param = Tcl_GetStringFromObj(argv[1], (int*)NULL);
+#else /* TCL_MAJOR_VERSION < 8 */
+ state = (int)strtol(argv[1], &endptr, 0);
+ if (*endptr) {
+ Tcl_AppendResult(interp,
+ "expected integer but got \"",
+ argv[1], "\"", (char *)NULL);
+ return TCL_ERROR;
+ }
+ param = argv[1];
+#endif
+ /* rb_exit(state); */ /* not return if succeed */
+
+ Tcl_AppendResult(interp, "fail to call \"", cmd, " ",
+ param, "\"", (char *)NULL);
+
+ rbtk_pending_exception = rb_exc_new2(rb_eSystemExit,
+ Tcl_GetStringResult(interp));
+ rb_iv_set(rbtk_pending_exception, "status", INT2FIX(state));
+
+ return TCL_RETURN;
+
+ default:
+ /* arguemnt error */
+ Tcl_AppendResult(interp,
+ "wrong number of arguments: should be \"",
+ cmd, " ?returnCode?\"", (char *)NULL);
+ return TCL_ERROR;
+ }
+}
+
+
+/**************************/
+/* based on tclEvent.c */
+/**************************/
+
+/*********************/
+/* replace of update */
+/*********************/
+#if TCL_MAJOR_VERSION >= 8
+static int ip_rbUpdateObjCmd _((ClientData, Tcl_Interp *, int,
+ Tcl_Obj *CONST []));
+static int
+ip_rbUpdateObjCmd(clientData, interp, objc, objv)
+ ClientData clientData;
+ Tcl_Interp *interp;
+ int objc;
+ Tcl_Obj *CONST objv[];
+#else /* TCL_MAJOR_VERSION < 8 */
+static int ip_rbUpdateCommand _((ClientData, Tcl_Interp *, int, char *[]));
+static int
+ip_rbUpdateCommand(clientData, interp, objc, objv)
+ ClientData clientData;
+ Tcl_Interp *interp;
+ int objc;
+ char *objv[];
+#endif
+{
+ int flags = 0;
+ static CONST char *updateOptions[] = {"idletasks", (char *) NULL};
+ enum updateOptions {REGEXP_IDLETASKS};
+
+ DUMP1("Ruby's 'update' is called");
+ if (interp == (Tcl_Interp*)NULL) {
+ rbtk_pending_exception = rb_exc_new2(rb_eRuntimeError,
+ "IP is deleted");
+ return TCL_ERROR;
+ }
+#ifdef HAVE_NATIVETHREAD
+#ifndef RUBY_USE_NATIVE_THREAD
+ if (!ruby_native_thread_p()) {
+ rb_bug("cross-thread violation on ip_ruby_eval()");
+ }
+#endif
+#endif
+
+ Tcl_ResetResult(interp);
+
+ if (objc == 1) {
+ flags = TCL_DONT_WAIT;
+
+ } else if (objc == 2) {
+#if TCL_MAJOR_VERSION >= 8
+ int optionIndex;
+ if (Tcl_GetIndexFromObj(interp, objv[1], (CONST84 char **)updateOptions,
+ "option", 0, &optionIndex) != TCL_OK) {
+ return TCL_ERROR;
+ }
+ switch ((enum updateOptions) optionIndex) {
+ case REGEXP_IDLETASKS: {
+ flags = TCL_IDLE_EVENTS;
+ break;
+ }
+ default: {
+ rb_bug("ip_rbUpdateObjCmd: bad option index to UpdateOptions");
+ }
+ }
+#else
+ if (strncmp(objv[1], "idletasks", strlen(objv[1])) != 0) {
+ Tcl_AppendResult(interp, "bad option \"", objv[1],
+ "\": must be idletasks", (char *) NULL);
+ return TCL_ERROR;
+ }
+ flags = TCL_IDLE_EVENTS;
+#endif
+ } else {
+#ifdef Tcl_WrongNumArgs
+ Tcl_WrongNumArgs(interp, 1, objv, "[ idletasks ]");
+#else
+# if TCL_MAJOR_VERSION >= 8
+ int dummy;
+ Tcl_AppendResult(interp, "wrong number of arguments: should be \"",
+ Tcl_GetStringFromObj(objv[0], &dummy),
+ " [ idletasks ]\"",
+ (char *) NULL);
+# else /* TCL_MAJOR_VERSION < 8 */
+ Tcl_AppendResult(interp, "wrong number of arguments: should be \"",
+ objv[0], " [ idletasks ]\"", (char *) NULL);
+# endif
+#endif
+ return TCL_ERROR;
+ }
+
+ Tcl_Preserve(interp);
+
+ /* call eventloop */
+ /* ret = lib_eventloop_core(0, flags, (int *)NULL);*/ /* ignore result */
+ lib_eventloop_launcher(0, flags, (int *)NULL, interp); /* ignore result */
+
+ /* exception check */
+ if (!NIL_P(rbtk_pending_exception)) {
+ Tcl_Release(interp);
+
+ /*
+ if (rb_obj_is_kind_of(rbtk_pending_exception, rb_eSystemExit)) {
+ */
+ if (rb_obj_is_kind_of(rbtk_pending_exception, rb_eSystemExit)
+ || rb_obj_is_kind_of(rbtk_pending_exception, rb_eInterrupt)) {
+ return TCL_RETURN;
+ } else{
+ return TCL_ERROR;
+ }
+ }
+
+ /* trap check */
+ if (rb_thread_check_trap_pending()) {
+ Tcl_Release(interp);
+
+ return TCL_RETURN;
+ }
+
+ /*
+ * Must clear the interpreter's result because event handlers could
+ * have executed commands.
+ */
+
+ DUMP2("last result '%s'", Tcl_GetStringResult(interp));
+ Tcl_ResetResult(interp);
+ Tcl_Release(interp);
+
+ DUMP1("finish Ruby's 'update'");
+ return TCL_OK;
+}
+
+
+/**********************/
+/* update with thread */
+/**********************/
+struct th_update_param {
+ VALUE thread;
+ int done;
+};
+
+static void rb_threadUpdateProc _((ClientData));
+static void
+rb_threadUpdateProc(clientData)
+ ClientData clientData; /* Pointer to integer to set to 1. */
+{
+ struct th_update_param *param = (struct th_update_param *) clientData;
+
+ DUMP1("threadUpdateProc is called");
+ param->done = 1;
+ rb_thread_wakeup(param->thread);
+
+ return;
+}
+
+#if TCL_MAJOR_VERSION >= 8
+static int ip_rb_threadUpdateObjCmd _((ClientData, Tcl_Interp *, int,
+ Tcl_Obj *CONST []));
+static int
+ip_rb_threadUpdateObjCmd(clientData, interp, objc, objv)
+ ClientData clientData;
+ Tcl_Interp *interp;
+ int objc;
+ Tcl_Obj *CONST objv[];
+#else /* TCL_MAJOR_VERSION < 8 */
+static int ip_rb_threadUpdateCommand _((ClientData, Tcl_Interp *, int,
+ char *[]));
+static int
+ip_rb_threadUpdateCommand(clientData, interp, objc, objv)
+ ClientData clientData;
+ Tcl_Interp *interp;
+ int objc;
+ char *objv[];
+#endif
+{
+# if 0
+ int flags = 0;
+# endif
+ struct th_update_param *param;
+ static CONST char *updateOptions[] = {"idletasks", (char *) NULL};
+ enum updateOptions {REGEXP_IDLETASKS};
+ volatile VALUE current_thread = rb_thread_current();
+ struct timeval t;
+
+ DUMP1("Ruby's 'thread_update' is called");
+ if (interp == (Tcl_Interp*)NULL) {
+ rbtk_pending_exception = rb_exc_new2(rb_eRuntimeError,
+ "IP is deleted");
+ return TCL_ERROR;
+ }
+#ifdef HAVE_NATIVETHREAD
+#ifndef RUBY_USE_NATIVE_THREAD
+ if (!ruby_native_thread_p()) {
+ rb_bug("cross-thread violation on ip_rb_threadUpdateCommand()");
+ }
+#endif
+#endif
+
+ if (rb_thread_alone()
+ || NIL_P(eventloop_thread) || eventloop_thread == current_thread) {
+#if TCL_MAJOR_VERSION >= 8
+ DUMP1("call ip_rbUpdateObjCmd");
+ return ip_rbUpdateObjCmd(clientData, interp, objc, objv);
+#else /* TCL_MAJOR_VERSION < 8 */
+ DUMP1("call ip_rbUpdateCommand");
+ return ip_rbUpdateCommand(clientData, interp, objc, objv);
+#endif
+ }
+
+ DUMP1("start Ruby's 'thread_update' body");
+
+ Tcl_ResetResult(interp);
+
+ if (objc == 1) {
+# if 0
+ flags = TCL_DONT_WAIT;
+# endif
+ } else if (objc == 2) {
+#if TCL_MAJOR_VERSION >= 8
+ int optionIndex;
+ if (Tcl_GetIndexFromObj(interp, objv[1], (CONST84 char **)updateOptions,
+ "option", 0, &optionIndex) != TCL_OK) {
+ return TCL_ERROR;
+ }
+ switch ((enum updateOptions) optionIndex) {
+ case REGEXP_IDLETASKS: {
+# if 0
+ flags = TCL_IDLE_EVENTS;
+# endif
+ break;
+ }
+ default: {
+ rb_bug("ip_rb_threadUpdateObjCmd: bad option index to UpdateOptions");
+ }
+ }
+#else
+ if (strncmp(objv[1], "idletasks", strlen(objv[1])) != 0) {
+ Tcl_AppendResult(interp, "bad option \"", objv[1],
+ "\": must be idletasks", (char *) NULL);
+ return TCL_ERROR;
+ }
+# if 0
+ flags = TCL_IDLE_EVENTS;
+# endif
+#endif
+ } else {
+#ifdef Tcl_WrongNumArgs
+ Tcl_WrongNumArgs(interp, 1, objv, "[ idletasks ]");
+#else
+# if TCL_MAJOR_VERSION >= 8
+ int dummy;
+ Tcl_AppendResult(interp, "wrong number of arguments: should be \"",
+ Tcl_GetStringFromObj(objv[0], &dummy),
+ " [ idletasks ]\"",
+ (char *) NULL);
+# else /* TCL_MAJOR_VERSION < 8 */
+ Tcl_AppendResult(interp, "wrong number of arguments: should be \"",
+ objv[0], " [ idletasks ]\"", (char *) NULL);
+# endif
+#endif
+ return TCL_ERROR;
+ }
+
+ DUMP1("pass argument check");
+
+ /* param = (struct th_update_param *)Tcl_Alloc(sizeof(struct th_update_param)); */
+ param = RbTk_ALLOC_N(struct th_update_param, 1);
+#if 0 /* use Tcl_Preserve/Release */
+ Tcl_Preserve((ClientData)param);
+#endif
+ param->thread = current_thread;
+ param->done = 0;
+
+ DUMP1("set idle proc");
+ Tcl_DoWhenIdle(rb_threadUpdateProc, (ClientData) param);
+
+ t.tv_sec = 0;
+ t.tv_usec = (long)((EVENT_HANDLER_TIMEOUT)*1000.0);
+
+ while(!param->done) {
+ DUMP1("wait for complete idle proc");
+ /* rb_thread_stop(); */
+ /* rb_thread_sleep_forever(); */
+ rb_thread_wait_for(t);
+ if (NIL_P(eventloop_thread)) {
+ break;
+ }
+ }
+
+#if 0 /* use Tcl_EventuallyFree */
+ Tcl_EventuallyFree((ClientData)param, TCL_DYNAMIC); /* XXXXXXXX */
+#else
+#if 0 /* use Tcl_Preserve/Release */
+ Tcl_Release((ClientData)param);
+#else
+ /* Tcl_Free((char *)param); */
+ ckfree((char *)param);
+#endif
+#endif
+
+ DUMP1("finish Ruby's 'thread_update'");
+ return TCL_OK;
+}
+
+
+/***************************/
+/* replace of vwait/tkwait */
+/***************************/
+#if TCL_MAJOR_VERSION >= 8
+static int ip_rbVwaitObjCmd _((ClientData, Tcl_Interp *, int,
+ Tcl_Obj *CONST []));
+static int ip_rb_threadVwaitObjCmd _((ClientData, Tcl_Interp *, int,
+ Tcl_Obj *CONST []));
+static int ip_rbTkWaitObjCmd _((ClientData, Tcl_Interp *, int,
+ Tcl_Obj *CONST []));
+static int ip_rb_threadTkWaitObjCmd _((ClientData, Tcl_Interp *, int,
+ Tcl_Obj *CONST []));
+#else
+static int ip_rbVwaitCommand _((ClientData, Tcl_Interp *, int, char *[]));
+static int ip_rb_threadVwaitCommand _((ClientData, Tcl_Interp *, int,
+ char *[]));
+static int ip_rbTkWaitCommand _((ClientData, Tcl_Interp *, int, char *[]));
+static int ip_rb_threadTkWaitCommand _((ClientData, Tcl_Interp *, int,
+ char *[]));
+#endif
+
+#if TCL_MAJOR_VERSION >= 8
+static char *VwaitVarProc _((ClientData, Tcl_Interp *,
+ CONST84 char *,CONST84 char *, int));
+static char *
+VwaitVarProc(clientData, interp, name1, name2, flags)
+ ClientData clientData; /* Pointer to integer to set to 1. */
+ Tcl_Interp *interp; /* Interpreter containing variable. */
+ CONST84 char *name1; /* Name of variable. */
+ CONST84 char *name2; /* Second part of variable name. */
+ int flags; /* Information about what happened. */
+#else /* TCL_MAJOR_VERSION < 8 */
+static char *VwaitVarProc _((ClientData, Tcl_Interp *, char *, char *, int));
+static char *
+VwaitVarProc(clientData, interp, name1, name2, flags)
+ ClientData clientData; /* Pointer to integer to set to 1. */
+ Tcl_Interp *interp; /* Interpreter containing variable. */
+ char *name1; /* Name of variable. */
+ char *name2; /* Second part of variable name. */
+ int flags; /* Information about what happened. */
+#endif
+{
+ int *donePtr = (int *) clientData;
+
+ *donePtr = 1;
+ return (char *) NULL;
+}
+
+#if TCL_MAJOR_VERSION >= 8
+static int
+ip_rbVwaitObjCmd(clientData, interp, objc, objv)
+ ClientData clientData; /* Not used */
+ Tcl_Interp *interp;
+ int objc;
+ Tcl_Obj *CONST objv[];
+#else /* TCL_MAJOR_VERSION < 8 */
+static int
+ip_rbVwaitCommand(clientData, interp, objc, objv)
+ ClientData clientData; /* Not used */
+ Tcl_Interp *interp;
+ int objc;
+ char *objv[];
+#endif
+{
+ int ret, done, foundEvent;
+ char *nameString;
+ int dummy;
+ int thr_crit_bup;
+
+ DUMP1("Ruby's 'vwait' is called");
+ if (interp == (Tcl_Interp*)NULL) {
+ rbtk_pending_exception = rb_exc_new2(rb_eRuntimeError,
+ "IP is deleted");
+ return TCL_ERROR;
+ }
+
+#if 0
+ if (!rb_thread_alone()
+ && eventloop_thread != Qnil
+ && eventloop_thread != rb_thread_current()) {
+#if TCL_MAJOR_VERSION >= 8
+ DUMP1("call ip_rb_threadVwaitObjCmd");
+ return ip_rb_threadVwaitObjCmd(clientData, interp, objc, objv);
+#else /* TCL_MAJOR_VERSION < 8 */
+ DUMP1("call ip_rb_threadVwaitCommand");
+ return ip_rb_threadVwaitCommand(clientData, interp, objc, objv);
+#endif
+ }
+#endif
+
+ Tcl_Preserve(interp);
+#ifdef HAVE_NATIVETHREAD
+#ifndef RUBY_USE_NATIVE_THREAD
+ if (!ruby_native_thread_p()) {
+ rb_bug("cross-thread violation on ip_rbVwaitCommand()");
+ }
+#endif
+#endif
+
+ Tcl_ResetResult(interp);
+
+ if (objc != 2) {
+#ifdef Tcl_WrongNumArgs
+ Tcl_WrongNumArgs(interp, 1, objv, "name");
+#else
+ thr_crit_bup = rb_thread_critical;
+ rb_thread_critical = Qtrue;
+
+#if TCL_MAJOR_VERSION >= 8
+ /* nameString = Tcl_GetString(objv[0]); */
+ nameString = Tcl_GetStringFromObj(objv[0], &dummy);
+#else /* TCL_MAJOR_VERSION < 8 */
+ nameString = objv[0];
+#endif
+ Tcl_AppendResult(interp, "wrong number of arguments: should be \"",
+ nameString, " name\"", (char *) NULL);
+
+ rb_thread_critical = thr_crit_bup;
+#endif
+
+ Tcl_Release(interp);
+ return TCL_ERROR;
+ }
+
+ thr_crit_bup = rb_thread_critical;
+ rb_thread_critical = Qtrue;
+
+#if TCL_MAJOR_VERSION >= 8
+ Tcl_IncrRefCount(objv[1]);
+ /* nameString = Tcl_GetString(objv[1]); */
+ nameString = Tcl_GetStringFromObj(objv[1], &dummy);
+#else /* TCL_MAJOR_VERSION < 8 */
+ nameString = objv[1];
+#endif
+
+ /*
+ if (Tcl_TraceVar(interp, nameString,
+ TCL_GLOBAL_ONLY|TCL_TRACE_WRITES|TCL_TRACE_UNSETS,
+ VwaitVarProc, (ClientData) &done) != TCL_OK) {
+ return TCL_ERROR;
+ }
+ */
+ ret = Tcl_TraceVar(interp, nameString,
+ TCL_GLOBAL_ONLY|TCL_TRACE_WRITES|TCL_TRACE_UNSETS,
+ VwaitVarProc, (ClientData) &done);
+
+ rb_thread_critical = thr_crit_bup;
+
+ if (ret != TCL_OK) {
+#if TCL_MAJOR_VERSION >= 8
+ Tcl_DecrRefCount(objv[1]);
+#endif
+ Tcl_Release(interp);
+ return TCL_ERROR;
+ }
+
+ done = 0;
+
+ foundEvent = RTEST(lib_eventloop_launcher(/* not check root-widget */0,
+ 0, &done, interp));
+
+ thr_crit_bup = rb_thread_critical;
+ rb_thread_critical = Qtrue;
+
+ Tcl_UntraceVar(interp, nameString,
+ TCL_GLOBAL_ONLY|TCL_TRACE_WRITES|TCL_TRACE_UNSETS,
+ VwaitVarProc, (ClientData) &done);
+
+ rb_thread_critical = thr_crit_bup;
+
+ /* exception check */
+ if (!NIL_P(rbtk_pending_exception)) {
+#if TCL_MAJOR_VERSION >= 8
+ Tcl_DecrRefCount(objv[1]);
+#endif
+ Tcl_Release(interp);
+
+/*
+ if (rb_obj_is_kind_of(rbtk_pending_exception, rb_eSystemExit)) {
+*/
+ if (rb_obj_is_kind_of(rbtk_pending_exception, rb_eSystemExit)
+ || rb_obj_is_kind_of(rbtk_pending_exception, rb_eInterrupt)) {
+ return TCL_RETURN;
+ } else{
+ return TCL_ERROR;
+ }
+ }
+
+ /* trap check */
+ if (rb_thread_check_trap_pending()) {
+#if TCL_MAJOR_VERSION >= 8
+ Tcl_DecrRefCount(objv[1]);
+#endif
+ Tcl_Release(interp);
+
+ return TCL_RETURN;
+ }
+
+ /*
+ * Clear out the interpreter's result, since it may have been set
+ * by event handlers.
+ */
+
+ Tcl_ResetResult(interp);
+ if (!foundEvent) {
+ thr_crit_bup = rb_thread_critical;
+ rb_thread_critical = Qtrue;
+
+ Tcl_AppendResult(interp, "can't wait for variable \"", nameString,
+ "\": would wait forever", (char *) NULL);
+
+ rb_thread_critical = thr_crit_bup;
+
+#if TCL_MAJOR_VERSION >= 8
+ Tcl_DecrRefCount(objv[1]);
+#endif
+ Tcl_Release(interp);
+ return TCL_ERROR;
+ }
+
+#if TCL_MAJOR_VERSION >= 8
+ Tcl_DecrRefCount(objv[1]);
+#endif
+ Tcl_Release(interp);
+ return TCL_OK;
+}
+
+
+/**************************/
+/* based on tkCmd.c */
+/**************************/
+#if TCL_MAJOR_VERSION >= 8
+static char *WaitVariableProc _((ClientData, Tcl_Interp *,
+ CONST84 char *,CONST84 char *, int));
+static char *
+WaitVariableProc(clientData, interp, name1, name2, flags)
+ ClientData clientData; /* Pointer to integer to set to 1. */
+ Tcl_Interp *interp; /* Interpreter containing variable. */
+ CONST84 char *name1; /* Name of variable. */
+ CONST84 char *name2; /* Second part of variable name. */
+ int flags; /* Information about what happened. */
+#else /* TCL_MAJOR_VERSION < 8 */
+static char *WaitVariableProc _((ClientData, Tcl_Interp *,
+ char *, char *, int));
+static char *
+WaitVariableProc(clientData, interp, name1, name2, flags)
+ ClientData clientData; /* Pointer to integer to set to 1. */
+ Tcl_Interp *interp; /* Interpreter containing variable. */
+ char *name1; /* Name of variable. */
+ char *name2; /* Second part of variable name. */
+ int flags; /* Information about what happened. */
+#endif
+{
+ int *donePtr = (int *) clientData;
+
+ *donePtr = 1;
+ return (char *) NULL;
+}
+
+static void WaitVisibilityProc _((ClientData, XEvent *));
+static void
+WaitVisibilityProc(clientData, eventPtr)
+ ClientData clientData; /* Pointer to integer to set to 1. */
+ XEvent *eventPtr; /* Information about event (not used). */
+{
+ int *donePtr = (int *) clientData;
+
+ if (eventPtr->type == VisibilityNotify) {
+ *donePtr = 1;
+ }
+ if (eventPtr->type == DestroyNotify) {
+ *donePtr = 2;
+ }
+}
+
+static void WaitWindowProc _((ClientData, XEvent *));
+static void
+WaitWindowProc(clientData, eventPtr)
+ ClientData clientData; /* Pointer to integer to set to 1. */
+ XEvent *eventPtr; /* Information about event. */
+{
+ int *donePtr = (int *) clientData;
+
+ if (eventPtr->type == DestroyNotify) {
+ *donePtr = 1;
+ }
+}
+
+#if TCL_MAJOR_VERSION >= 8
+static int
+ip_rbTkWaitObjCmd(clientData, interp, objc, objv)
+ ClientData clientData;
+ Tcl_Interp *interp;
+ int objc;
+ Tcl_Obj *CONST objv[];
+#else /* TCL_MAJOR_VERSION < 8 */
+static int
+ip_rbTkWaitCommand(clientData, interp, objc, objv)
+ ClientData clientData;
+ Tcl_Interp *interp;
+ int objc;
+ char *objv[];
+#endif
+{
+ Tk_Window tkwin = (Tk_Window) clientData;
+ Tk_Window window;
+ int done, index;
+ static CONST char *optionStrings[] = { "variable", "visibility", "window",
+ (char *) NULL };
+ enum options { TKWAIT_VARIABLE, TKWAIT_VISIBILITY, TKWAIT_WINDOW };
+ char *nameString;
+ int ret, dummy;
+ int thr_crit_bup;
+
+ DUMP1("Ruby's 'tkwait' is called");
+ if (interp == (Tcl_Interp*)NULL) {
+ rbtk_pending_exception = rb_exc_new2(rb_eRuntimeError,
+ "IP is deleted");
+ return TCL_ERROR;
+ }
+
+#if 0
+ if (!rb_thread_alone()
+ && eventloop_thread != Qnil
+ && eventloop_thread != rb_thread_current()) {
+#if TCL_MAJOR_VERSION >= 8
+ DUMP1("call ip_rb_threadTkWaitObjCmd");
+ return ip_rb_threadTkWaitObjCmd((ClientData)tkwin, interp, objc, objv);
+#else /* TCL_MAJOR_VERSION < 8 */
+ DUMP1("call ip_rb_threadTkWaitCommand");
+ return ip_rb_threadTkWwaitCommand((ClientData)tkwin, interp, objc, objv);
+#endif
+ }
+#endif
+
+ Tcl_Preserve(interp);
+ Tcl_ResetResult(interp);
+
+ if (objc != 3) {
+#ifdef Tcl_WrongNumArgs
+ Tcl_WrongNumArgs(interp, 1, objv, "variable|visibility|window name");
+#else
+ thr_crit_bup = rb_thread_critical;
+ rb_thread_critical = Qtrue;
+
+#if TCL_MAJOR_VERSION >= 8
+ Tcl_AppendResult(interp, "wrong number of arguments: should be \"",
+ Tcl_GetStringFromObj(objv[0], &dummy),
+ " variable|visibility|window name\"",
+ (char *) NULL);
+#else /* TCL_MAJOR_VERSION < 8 */
+ Tcl_AppendResult(interp, "wrong number of arguments: should be \"",
+ objv[0], " variable|visibility|window name\"",
+ (char *) NULL);
+#endif
+
+ rb_thread_critical = thr_crit_bup;
+#endif
+
+ Tcl_Release(interp);
+ return TCL_ERROR;
+ }
+
+#if TCL_MAJOR_VERSION >= 8
+ thr_crit_bup = rb_thread_critical;
+ rb_thread_critical = Qtrue;
+
+ /*
+ if (Tcl_GetIndexFromObj(interp, objv[1],
+ (CONST84 char **)optionStrings,
+ "option", 0, &index) != TCL_OK) {
+ return TCL_ERROR;
+ }
+ */
+ ret = Tcl_GetIndexFromObj(interp, objv[1],
+ (CONST84 char **)optionStrings,
+ "option", 0, &index);
+
+ rb_thread_critical = thr_crit_bup;
+
+ if (ret != TCL_OK) {
+ Tcl_Release(interp);
+ return TCL_ERROR;
+ }
+#else /* TCL_MAJOR_VERSION < 8 */
+ {
+ int c = objv[1][0];
+ size_t length = strlen(objv[1]);
+
+ if ((c == 'v') && (strncmp(objv[1], "variable", length) == 0)
+ && (length >= 2)) {
+ index = TKWAIT_VARIABLE;
+ } else if ((c == 'v') && (strncmp(objv[1], "visibility", length) == 0)
+ && (length >= 2)) {
+ index = TKWAIT_VISIBILITY;
+ } else if ((c == 'w') && (strncmp(objv[1], "window", length) == 0)) {
+ index = TKWAIT_WINDOW;
+ } else {
+ Tcl_AppendResult(interp, "bad option \"", objv[1],
+ "\": must be variable, visibility, or window",
+ (char *) NULL);
+ Tcl_Release(interp);
+ return TCL_ERROR;
+ }
+ }
+#endif
+
+ thr_crit_bup = rb_thread_critical;
+ rb_thread_critical = Qtrue;
+
+#if TCL_MAJOR_VERSION >= 8
+ Tcl_IncrRefCount(objv[2]);
+ /* nameString = Tcl_GetString(objv[2]); */
+ nameString = Tcl_GetStringFromObj(objv[2], &dummy);
+#else /* TCL_MAJOR_VERSION < 8 */
+ nameString = objv[2];
+#endif
+
+ rb_thread_critical = thr_crit_bup;
+
+ switch ((enum options) index) {
+ case TKWAIT_VARIABLE:
+ thr_crit_bup = rb_thread_critical;
+ rb_thread_critical = Qtrue;
+ /*
+ if (Tcl_TraceVar(interp, nameString,
+ TCL_GLOBAL_ONLY|TCL_TRACE_WRITES|TCL_TRACE_UNSETS,
+ WaitVariableProc, (ClientData) &done) != TCL_OK) {
+ return TCL_ERROR;
+ }
+ */
+ ret = Tcl_TraceVar(interp, nameString,
+ TCL_GLOBAL_ONLY|TCL_TRACE_WRITES|TCL_TRACE_UNSETS,
+ WaitVariableProc, (ClientData) &done);
+
+ rb_thread_critical = thr_crit_bup;
+
+ if (ret != TCL_OK) {
+#if TCL_MAJOR_VERSION >= 8
+ Tcl_DecrRefCount(objv[2]);
+#endif
+ Tcl_Release(interp);
+ return TCL_ERROR;
+ }
+
+ done = 0;
+ /* lib_eventloop_core(check_rootwidget_flag, 0, &done); */
+ lib_eventloop_launcher(check_rootwidget_flag, 0, &done, interp);
+
+ thr_crit_bup = rb_thread_critical;
+ rb_thread_critical = Qtrue;
+
+ Tcl_UntraceVar(interp, nameString,
+ TCL_GLOBAL_ONLY|TCL_TRACE_WRITES|TCL_TRACE_UNSETS,
+ WaitVariableProc, (ClientData) &done);
+
+#if TCL_MAJOR_VERSION >= 8
+ Tcl_DecrRefCount(objv[2]);
+#endif
+
+ rb_thread_critical = thr_crit_bup;
+
+ /* exception check */
+ if (!NIL_P(rbtk_pending_exception)) {
+ Tcl_Release(interp);
+
+ /*
+ if (rb_obj_is_kind_of(rbtk_pending_exception, rb_eSystemExit)) {
+ */
+ if (rb_obj_is_kind_of(rbtk_pending_exception, rb_eSystemExit)
+ || rb_obj_is_kind_of(rbtk_pending_exception, rb_eInterrupt)) {
+ return TCL_RETURN;
+ } else{
+ return TCL_ERROR;
+ }
+ }
+
+ /* trap check */
+ if (rb_thread_check_trap_pending()) {
+ Tcl_Release(interp);
+
+ return TCL_RETURN;
+ }
+
+ break;
+
+ case TKWAIT_VISIBILITY:
+ thr_crit_bup = rb_thread_critical;
+ rb_thread_critical = Qtrue;
+
+ /* This function works on the Tk eventloop thread only. */
+ if (!tk_stubs_init_p() || Tk_MainWindow(interp) == (Tk_Window)NULL) {
+ window = NULL;
+ } else {
+ window = Tk_NameToWindow(interp, nameString, tkwin);
+ }
+
+ if (window == NULL) {
+ Tcl_AppendResult(interp, ": tkwait: ",
+ "no main-window (not Tk application?)",
+ (char*)NULL);
+ rb_thread_critical = thr_crit_bup;
+#if TCL_MAJOR_VERSION >= 8
+ Tcl_DecrRefCount(objv[2]);
+#endif
+ Tcl_Release(interp);
+ return TCL_ERROR;
+ }
+
+ Tk_CreateEventHandler(window,
+ VisibilityChangeMask|StructureNotifyMask,
+ WaitVisibilityProc, (ClientData) &done);
+
+ rb_thread_critical = thr_crit_bup;
+
+ done = 0;
+ /* lib_eventloop_core(check_rootwidget_flag, 0, &done); */
+ lib_eventloop_launcher(check_rootwidget_flag, 0, &done, interp);
+
+ /* exception check */
+ if (!NIL_P(rbtk_pending_exception)) {
+#if TCL_MAJOR_VERSION >= 8
+ Tcl_DecrRefCount(objv[2]);
+#endif
+ Tcl_Release(interp);
+
+ /*
+ if (rb_obj_is_kind_of(rbtk_pending_exception, rb_eSystemExit)) {
+ */
+ if (rb_obj_is_kind_of(rbtk_pending_exception, rb_eSystemExit)
+ || rb_obj_is_kind_of(rbtk_pending_exception, rb_eInterrupt)) {
+ return TCL_RETURN;
+ } else{
+ return TCL_ERROR;
+ }
+ }
+
+ /* trap check */
+ if (rb_thread_check_trap_pending()) {
+#if TCL_MAJOR_VERSION >= 8
+ Tcl_DecrRefCount(objv[2]);
+#endif
+ Tcl_Release(interp);
+
+ return TCL_RETURN;
+ }
+
+ if (done != 1) {
+ /*
+ * Note that we do not delete the event handler because it
+ * was deleted automatically when the window was destroyed.
+ */
+ thr_crit_bup = rb_thread_critical;
+ rb_thread_critical = Qtrue;
+
+ Tcl_ResetResult(interp);
+ Tcl_AppendResult(interp, "window \"", nameString,
+ "\" was deleted before its visibility changed",
+ (char *) NULL);
+
+ rb_thread_critical = thr_crit_bup;
+
+#if TCL_MAJOR_VERSION >= 8
+ Tcl_DecrRefCount(objv[2]);
+#endif
+ Tcl_Release(interp);
+ return TCL_ERROR;
+ }
+
+ thr_crit_bup = rb_thread_critical;
+ rb_thread_critical = Qtrue;
+
+#if TCL_MAJOR_VERSION >= 8
+ Tcl_DecrRefCount(objv[2]);
+#endif
+
+ Tk_DeleteEventHandler(window,
+ VisibilityChangeMask|StructureNotifyMask,
+ WaitVisibilityProc, (ClientData) &done);
+
+ rb_thread_critical = thr_crit_bup;
+
+ break;
+
+ case TKWAIT_WINDOW:
+ thr_crit_bup = rb_thread_critical;
+ rb_thread_critical = Qtrue;
+
+ /* This function works on the Tk eventloop thread only. */
+ if (!tk_stubs_init_p() || Tk_MainWindow(interp) == (Tk_Window)NULL) {
+ window = NULL;
+ } else {
+ window = Tk_NameToWindow(interp, nameString, tkwin);
+ }
+
+#if TCL_MAJOR_VERSION >= 8
+ Tcl_DecrRefCount(objv[2]);
+#endif
+
+ if (window == NULL) {
+ Tcl_AppendResult(interp, ": tkwait: ",
+ "no main-window (not Tk application?)",
+ (char*)NULL);
+ rb_thread_critical = thr_crit_bup;
+ Tcl_Release(interp);
+ return TCL_ERROR;
+ }
+
+ Tk_CreateEventHandler(window, StructureNotifyMask,
+ WaitWindowProc, (ClientData) &done);
+
+ rb_thread_critical = thr_crit_bup;
+
+ done = 0;
+ /* lib_eventloop_core(check_rootwidget_flag, 0, &done); */
+ lib_eventloop_launcher(check_rootwidget_flag, 0, &done, interp);
+
+ /* exception check */
+ if (!NIL_P(rbtk_pending_exception)) {
+ Tcl_Release(interp);
+
+ /*
+ if (rb_obj_is_kind_of(rbtk_pending_exception, rb_eSystemExit)) {
+ */
+ if (rb_obj_is_kind_of(rbtk_pending_exception, rb_eSystemExit)
+ || rb_obj_is_kind_of(rbtk_pending_exception, rb_eInterrupt)) {
+ return TCL_RETURN;
+ } else{
+ return TCL_ERROR;
+ }
+ }
+
+ /* trap check */
+ if (rb_thread_check_trap_pending()) {
+ Tcl_Release(interp);
+
+ return TCL_RETURN;
+ }
+
+ /*
+ * Note: there's no need to delete the event handler. It was
+ * deleted automatically when the window was destroyed.
+ */
+ break;
+ }
+
+ /*
+ * Clear out the interpreter's result, since it may have been set
+ * by event handlers.
+ */
+
+ Tcl_ResetResult(interp);
+ Tcl_Release(interp);
+ return TCL_OK;
+}
+
+/****************************/
+/* vwait/tkwait with thread */
+/****************************/
+struct th_vwait_param {
+ VALUE thread;
+ int done;
+};
+
+#if TCL_MAJOR_VERSION >= 8
+static char *rb_threadVwaitProc _((ClientData, Tcl_Interp *,
+ CONST84 char *,CONST84 char *, int));
+static char *
+rb_threadVwaitProc(clientData, interp, name1, name2, flags)
+ ClientData clientData; /* Pointer to integer to set to 1. */
+ Tcl_Interp *interp; /* Interpreter containing variable. */
+ CONST84 char *name1; /* Name of variable. */
+ CONST84 char *name2; /* Second part of variable name. */
+ int flags; /* Information about what happened. */
+#else /* TCL_MAJOR_VERSION < 8 */
+static char *rb_threadVwaitProc _((ClientData, Tcl_Interp *,
+ char *, char *, int));
+static char *
+rb_threadVwaitProc(clientData, interp, name1, name2, flags)
+ ClientData clientData; /* Pointer to integer to set to 1. */
+ Tcl_Interp *interp; /* Interpreter containing variable. */
+ char *name1; /* Name of variable. */
+ char *name2; /* Second part of variable name. */
+ int flags; /* Information about what happened. */
+#endif
+{
+ struct th_vwait_param *param = (struct th_vwait_param *) clientData;
+
+ if (flags & (TCL_INTERP_DESTROYED | TCL_TRACE_DESTROYED)) {
+ param->done = -1;
+ } else {
+ param->done = 1;
+ }
+ if (param->done != 0) rb_thread_wakeup(param->thread);
+
+ return (char *)NULL;
+}
+
+#define TKWAIT_MODE_VISIBILITY 1
+#define TKWAIT_MODE_DESTROY 2
+
+static void rb_threadWaitVisibilityProc _((ClientData, XEvent *));
+static void
+rb_threadWaitVisibilityProc(clientData, eventPtr)
+ ClientData clientData; /* Pointer to integer to set to 1. */
+ XEvent *eventPtr; /* Information about event (not used). */
+{
+ struct th_vwait_param *param = (struct th_vwait_param *) clientData;
+
+ if (eventPtr->type == VisibilityNotify) {
+ param->done = TKWAIT_MODE_VISIBILITY;
+ }
+ if (eventPtr->type == DestroyNotify) {
+ param->done = TKWAIT_MODE_DESTROY;
+ }
+ if (param->done != 0) rb_thread_wakeup(param->thread);
+}
+
+static void rb_threadWaitWindowProc _((ClientData, XEvent *));
+static void
+rb_threadWaitWindowProc(clientData, eventPtr)
+ ClientData clientData; /* Pointer to integer to set to 1. */
+ XEvent *eventPtr; /* Information about event. */
+{
+ struct th_vwait_param *param = (struct th_vwait_param *) clientData;
+
+ if (eventPtr->type == DestroyNotify) {
+ param->done = TKWAIT_MODE_DESTROY;
+ }
+ if (param->done != 0) rb_thread_wakeup(param->thread);
+}
+
+#if TCL_MAJOR_VERSION >= 8
+static int
+ip_rb_threadVwaitObjCmd(clientData, interp, objc, objv)
+ ClientData clientData;
+ Tcl_Interp *interp;
+ int objc;
+ Tcl_Obj *CONST objv[];
+#else /* TCL_MAJOR_VERSION < 8 */
+static int
+ip_rb_threadVwaitCommand(clientData, interp, objc, objv)
+ ClientData clientData; /* Not used */
+ Tcl_Interp *interp;
+ int objc;
+ char *objv[];
+#endif
+{
+ struct th_vwait_param *param;
+ char *nameString;
+ int ret, dummy;
+ int thr_crit_bup;
+ volatile VALUE current_thread = rb_thread_current();
+ struct timeval t;
+
+ DUMP1("Ruby's 'thread_vwait' is called");
+ if (interp == (Tcl_Interp*)NULL) {
+ rbtk_pending_exception = rb_exc_new2(rb_eRuntimeError,
+ "IP is deleted");
+ return TCL_ERROR;
+ }
+
+ if (rb_thread_alone() || eventloop_thread == current_thread) {
+#if TCL_MAJOR_VERSION >= 8
+ DUMP1("call ip_rbVwaitObjCmd");
+ return ip_rbVwaitObjCmd(clientData, interp, objc, objv);
+#else /* TCL_MAJOR_VERSION < 8 */
+ DUMP1("call ip_rbVwaitCommand");
+ return ip_rbVwaitCommand(clientData, interp, objc, objv);
+#endif
+ }
+
+ Tcl_Preserve(interp);
+ Tcl_ResetResult(interp);
+
+ if (objc != 2) {
+#ifdef Tcl_WrongNumArgs
+ Tcl_WrongNumArgs(interp, 1, objv, "name");
+#else
+ thr_crit_bup = rb_thread_critical;
+ rb_thread_critical = Qtrue;
+
+#if TCL_MAJOR_VERSION >= 8
+ /* nameString = Tcl_GetString(objv[0]); */
+ nameString = Tcl_GetStringFromObj(objv[0], &dummy);
+#else /* TCL_MAJOR_VERSION < 8 */
+ nameString = objv[0];
+#endif
+ Tcl_AppendResult(interp, "wrong number of arguments: should be \"",
+ nameString, " name\"", (char *) NULL);
+
+ rb_thread_critical = thr_crit_bup;
+#endif
+
+ Tcl_Release(interp);
+ return TCL_ERROR;
+ }
+
+#if TCL_MAJOR_VERSION >= 8
+ Tcl_IncrRefCount(objv[1]);
+ /* nameString = Tcl_GetString(objv[1]); */
+ nameString = Tcl_GetStringFromObj(objv[1], &dummy);
+#else /* TCL_MAJOR_VERSION < 8 */
+ nameString = objv[1];
+#endif
+ thr_crit_bup = rb_thread_critical;
+ rb_thread_critical = Qtrue;
+
+ /* param = (struct th_vwait_param *)Tcl_Alloc(sizeof(struct th_vwait_param)); */
+ param = RbTk_ALLOC_N(struct th_vwait_param, 1);
+#if 1 /* use Tcl_Preserve/Release */
+ Tcl_Preserve((ClientData)param);
+#endif
+ param->thread = current_thread;
+ param->done = 0;
+
+ /*
+ if (Tcl_TraceVar(interp, nameString,
+ TCL_GLOBAL_ONLY|TCL_TRACE_WRITES|TCL_TRACE_UNSETS,
+ rb_threadVwaitProc, (ClientData) param) != TCL_OK) {
+ return TCL_ERROR;
+ }
+ */
+ ret = Tcl_TraceVar(interp, nameString,
+ TCL_GLOBAL_ONLY|TCL_TRACE_WRITES|TCL_TRACE_UNSETS,
+ rb_threadVwaitProc, (ClientData) param);
+
+ rb_thread_critical = thr_crit_bup;
+
+ if (ret != TCL_OK) {
+#if 0 /* use Tcl_EventuallyFree */
+ Tcl_EventuallyFree((ClientData)param, TCL_DYNAMIC); /* XXXXXXXX */
+#else
+#if 1 /* use Tcl_Preserve/Release */
+ Tcl_Release((ClientData)param);
+#else
+ /* Tcl_Free((char *)param); */
+ ckfree((char *)param);
+#endif
+#endif
+
+#if TCL_MAJOR_VERSION >= 8
+ Tcl_DecrRefCount(objv[1]);
+#endif
+ Tcl_Release(interp);
+ return TCL_ERROR;
+ }
+
+ t.tv_sec = 0;
+ t.tv_usec = (long)((EVENT_HANDLER_TIMEOUT)*1000.0);
+
+ while(!param->done) {
+ /* rb_thread_stop(); */
+ /* rb_thread_sleep_forever(); */
+ rb_thread_wait_for(t);
+ if (NIL_P(eventloop_thread)) {
+ break;
+ }
+ }
+
+ thr_crit_bup = rb_thread_critical;
+ rb_thread_critical = Qtrue;
+
+ if (param->done > 0) {
+ Tcl_UntraceVar(interp, nameString,
+ TCL_GLOBAL_ONLY|TCL_TRACE_WRITES|TCL_TRACE_UNSETS,
+ rb_threadVwaitProc, (ClientData) param);
+ }
+
+#if 0 /* use Tcl_EventuallyFree */
+ Tcl_EventuallyFree((ClientData)param, TCL_DYNAMIC); /* XXXXXXXX */
+#else
+#if 1 /* use Tcl_Preserve/Release */
+ Tcl_Release((ClientData)param);
+#else
+ /* Tcl_Free((char *)param); */
+ ckfree((char *)param);
+#endif
+#endif
+
+ rb_thread_critical = thr_crit_bup;
+
+#if TCL_MAJOR_VERSION >= 8
+ Tcl_DecrRefCount(objv[1]);
+#endif
+ Tcl_Release(interp);
+ return TCL_OK;
+}
+
+#if TCL_MAJOR_VERSION >= 8
+static int
+ip_rb_threadTkWaitObjCmd(clientData, interp, objc, objv)
+ ClientData clientData;
+ Tcl_Interp *interp;
+ int objc;
+ Tcl_Obj *CONST objv[];
+#else /* TCL_MAJOR_VERSION < 8 */
+static int
+ip_rb_threadTkWaitCommand(clientData, interp, objc, objv)
+ ClientData clientData;
+ Tcl_Interp *interp;
+ int objc;
+ char *objv[];
+#endif
+{
+ struct th_vwait_param *param;
+ Tk_Window tkwin = (Tk_Window) clientData;
+ Tk_Window window;
+ int index;
+ static CONST char *optionStrings[] = { "variable", "visibility", "window",
+ (char *) NULL };
+ enum options { TKWAIT_VARIABLE, TKWAIT_VISIBILITY, TKWAIT_WINDOW };
+ char *nameString;
+ int ret, dummy;
+ int thr_crit_bup;
+ volatile VALUE current_thread = rb_thread_current();
+ struct timeval t;
+
+ DUMP1("Ruby's 'thread_tkwait' is called");
+ if (interp == (Tcl_Interp*)NULL) {
+ rbtk_pending_exception = rb_exc_new2(rb_eRuntimeError,
+ "IP is deleted");
+ return TCL_ERROR;
+ }
+
+ if (rb_thread_alone() || eventloop_thread == current_thread) {
+#if TCL_MAJOR_VERSION >= 8
+ DUMP1("call ip_rbTkWaitObjCmd");
+ DUMP2("eventloop_thread %"PRIxVALUE, eventloop_thread);
+ DUMP2("current_thread %"PRIxVALUE, current_thread);
+ return ip_rbTkWaitObjCmd(clientData, interp, objc, objv);
+#else /* TCL_MAJOR_VERSION < 8 */
+ DUMP1("call rb_VwaitCommand");
+ return ip_rbTkWaitCommand(clientData, interp, objc, objv);
+#endif
+ }
+
+ Tcl_Preserve(interp);
+ Tcl_Preserve(tkwin);
+
+ Tcl_ResetResult(interp);
+
+ if (objc != 3) {
+#ifdef Tcl_WrongNumArgs
+ Tcl_WrongNumArgs(interp, 1, objv, "variable|visibility|window name");
+#else
+ thr_crit_bup = rb_thread_critical;
+ rb_thread_critical = Qtrue;
+
+#if TCL_MAJOR_VERSION >= 8
+ Tcl_AppendResult(interp, "wrong number of arguments: should be \"",
+ Tcl_GetStringFromObj(objv[0], &dummy),
+ " variable|visibility|window name\"",
+ (char *) NULL);
+#else /* TCL_MAJOR_VERSION < 8 */
+ Tcl_AppendResult(interp, "wrong number of arguments: should be \"",
+ objv[0], " variable|visibility|window name\"",
+ (char *) NULL);
+#endif
+
+ rb_thread_critical = thr_crit_bup;
+#endif
+
+ Tcl_Release(tkwin);
+ Tcl_Release(interp);
+ return TCL_ERROR;
+ }
+
+#if TCL_MAJOR_VERSION >= 8
+ thr_crit_bup = rb_thread_critical;
+ rb_thread_critical = Qtrue;
+ /*
+ if (Tcl_GetIndexFromObj(interp, objv[1],
+ (CONST84 char **)optionStrings,
+ "option", 0, &index) != TCL_OK) {
+ return TCL_ERROR;
+ }
+ */
+ ret = Tcl_GetIndexFromObj(interp, objv[1],
+ (CONST84 char **)optionStrings,
+ "option", 0, &index);
+
+ rb_thread_critical = thr_crit_bup;
+
+ if (ret != TCL_OK) {
+ Tcl_Release(tkwin);
+ Tcl_Release(interp);
+ return TCL_ERROR;
+ }
+#else /* TCL_MAJOR_VERSION < 8 */
+ {
+ int c = objv[1][0];
+ size_t length = strlen(objv[1]);
+
+ if ((c == 'v') && (strncmp(objv[1], "variable", length) == 0)
+ && (length >= 2)) {
+ index = TKWAIT_VARIABLE;
+ } else if ((c == 'v') && (strncmp(objv[1], "visibility", length) == 0)
+ && (length >= 2)) {
+ index = TKWAIT_VISIBILITY;
+ } else if ((c == 'w') && (strncmp(objv[1], "window", length) == 0)) {
+ index = TKWAIT_WINDOW;
+ } else {
+ Tcl_AppendResult(interp, "bad option \"", objv[1],
+ "\": must be variable, visibility, or window",
+ (char *) NULL);
+ Tcl_Release(tkwin);
+ Tcl_Release(interp);
+ return TCL_ERROR;
+ }
+ }
+#endif
+
+ thr_crit_bup = rb_thread_critical;
+ rb_thread_critical = Qtrue;
+
+#if TCL_MAJOR_VERSION >= 8
+ Tcl_IncrRefCount(objv[2]);
+ /* nameString = Tcl_GetString(objv[2]); */
+ nameString = Tcl_GetStringFromObj(objv[2], &dummy);
+#else /* TCL_MAJOR_VERSION < 8 */
+ nameString = objv[2];
+#endif
+
+ /* param = (struct th_vwait_param *)Tcl_Alloc(sizeof(struct th_vwait_param)); */
+ param = RbTk_ALLOC_N(struct th_vwait_param, 1);
+#if 1 /* use Tcl_Preserve/Release */
+ Tcl_Preserve((ClientData)param);
+#endif
+ param->thread = current_thread;
+ param->done = 0;
+
+ rb_thread_critical = thr_crit_bup;
+
+ switch ((enum options) index) {
+ case TKWAIT_VARIABLE:
+ thr_crit_bup = rb_thread_critical;
+ rb_thread_critical = Qtrue;
+ /*
+ if (Tcl_TraceVar(interp, nameString,
+ TCL_GLOBAL_ONLY|TCL_TRACE_WRITES|TCL_TRACE_UNSETS,
+ rb_threadVwaitProc, (ClientData) param) != TCL_OK) {
+ return TCL_ERROR;
+ }
+ */
+ ret = Tcl_TraceVar(interp, nameString,
+ TCL_GLOBAL_ONLY|TCL_TRACE_WRITES|TCL_TRACE_UNSETS,
+ rb_threadVwaitProc, (ClientData) param);
+
+ rb_thread_critical = thr_crit_bup;
+
+ if (ret != TCL_OK) {
+#if 0 /* use Tcl_EventuallyFree */
+ Tcl_EventuallyFree((ClientData)param, TCL_DYNAMIC); /* XXXXXXXX */
+#else
+#if 1 /* use Tcl_Preserve/Release */
+ Tcl_Release(param);
+#else
+ /* Tcl_Free((char *)param); */
+ ckfree((char *)param);
+#endif
+#endif
+
+#if TCL_MAJOR_VERSION >= 8
+ Tcl_DecrRefCount(objv[2]);
+#endif
+
+ Tcl_Release(tkwin);
+ Tcl_Release(interp);
+ return TCL_ERROR;
+ }
+
+ t.tv_sec = 0;
+ t.tv_usec = (long)((EVENT_HANDLER_TIMEOUT)*1000.0);
+
+ while(!param->done) {
+ /* rb_thread_stop(); */
+ /* rb_thread_sleep_forever(); */
+ rb_thread_wait_for(t);
+ if (NIL_P(eventloop_thread)) {
+ break;
+ }
+ }
+
+ thr_crit_bup = rb_thread_critical;
+ rb_thread_critical = Qtrue;
+
+ if (param->done > 0) {
+ Tcl_UntraceVar(interp, nameString,
+ TCL_GLOBAL_ONLY|TCL_TRACE_WRITES|TCL_TRACE_UNSETS,
+ rb_threadVwaitProc, (ClientData) param);
+ }
+
+#if TCL_MAJOR_VERSION >= 8
+ Tcl_DecrRefCount(objv[2]);
+#endif
+
+ rb_thread_critical = thr_crit_bup;
+
+ break;
+
+ case TKWAIT_VISIBILITY:
+ thr_crit_bup = rb_thread_critical;
+ rb_thread_critical = Qtrue;
+
+#if 0 /* variable 'tkwin' must keep the token of MainWindow */
+ if (!tk_stubs_init_p() || Tk_MainWindow(interp) == (Tk_Window)NULL) {
+ window = NULL;
+ } else {
+ window = Tk_NameToWindow(interp, nameString, tkwin);
+ }
+#else
+ if (!tk_stubs_init_p() || tkwin == (Tk_Window)NULL) {
+ window = NULL;
+ } else {
+ /* Tk_NameToWindow() returns right token on non-eventloop thread */
+ Tcl_CmdInfo info;
+ if (Tcl_GetCommandInfo(interp, ".", &info)) { /* check root */
+ window = Tk_NameToWindow(interp, nameString, tkwin);
+ } else {
+ window = NULL;
+ }
+ }
+#endif
+
+ if (window == NULL) {
+ Tcl_AppendResult(interp, ": thread_tkwait: ",
+ "no main-window (not Tk application?)",
+ (char*)NULL);
+
+ rb_thread_critical = thr_crit_bup;
+
+#if 0 /* use Tcl_EventuallyFree */
+ Tcl_EventuallyFree((ClientData)param, TCL_DYNAMIC); /* XXXXXXXX */
+#else
+#if 1 /* use Tcl_Preserve/Release */
+ Tcl_Release(param);
+#else
+ /* Tcl_Free((char *)param); */
+ ckfree((char *)param);
+#endif
+#endif
+
+#if TCL_MAJOR_VERSION >= 8
+ Tcl_DecrRefCount(objv[2]);
+#endif
+ Tcl_Release(tkwin);
+ Tcl_Release(interp);
+ return TCL_ERROR;
+ }
+ Tcl_Preserve(window);
+
+ Tk_CreateEventHandler(window,
+ VisibilityChangeMask|StructureNotifyMask,
+ rb_threadWaitVisibilityProc, (ClientData) param);
+
+ rb_thread_critical = thr_crit_bup;
+
+ t.tv_sec = 0;
+ t.tv_usec = (long)((EVENT_HANDLER_TIMEOUT)*1000.0);
+
+ while(param->done != TKWAIT_MODE_VISIBILITY) {
+ if (param->done == TKWAIT_MODE_DESTROY) break;
+ /* rb_thread_stop(); */
+ /* rb_thread_sleep_forever(); */
+ rb_thread_wait_for(t);
+ if (NIL_P(eventloop_thread)) {
+ break;
+ }
+ }
+
+ thr_crit_bup = rb_thread_critical;
+ rb_thread_critical = Qtrue;
+
+ /* when a window is destroyed, no need to call Tk_DeleteEventHandler */
+ if (param->done != TKWAIT_MODE_DESTROY) {
+ Tk_DeleteEventHandler(window,
+ VisibilityChangeMask|StructureNotifyMask,
+ rb_threadWaitVisibilityProc,
+ (ClientData) param);
+ }
+
+ if (param->done != 1) {
+ Tcl_ResetResult(interp);
+ Tcl_AppendResult(interp, "window \"", nameString,
+ "\" was deleted before its visibility changed",
+ (char *) NULL);
+
+ rb_thread_critical = thr_crit_bup;
+
+ Tcl_Release(window);
+
+#if 0 /* use Tcl_EventuallyFree */
+ Tcl_EventuallyFree((ClientData)param, TCL_DYNAMIC); /* XXXXXXXX */
+#else
+#if 1 /* use Tcl_Preserve/Release */
+ Tcl_Release(param);
+#else
+ /* Tcl_Free((char *)param); */
+ ckfree((char *)param);
+#endif
+#endif
+
+#if TCL_MAJOR_VERSION >= 8
+ Tcl_DecrRefCount(objv[2]);
+#endif
+
+ Tcl_Release(tkwin);
+ Tcl_Release(interp);
+ return TCL_ERROR;
+ }
+
+ Tcl_Release(window);
+
+#if TCL_MAJOR_VERSION >= 8
+ Tcl_DecrRefCount(objv[2]);
+#endif
+
+ rb_thread_critical = thr_crit_bup;
+
+ break;
+
+ case TKWAIT_WINDOW:
+ thr_crit_bup = rb_thread_critical;
+ rb_thread_critical = Qtrue;
+
+#if 0 /* variable 'tkwin' must keep the token of MainWindow */
+ if (!tk_stubs_init_p() || Tk_MainWindow(interp) == (Tk_Window)NULL) {
+ window = NULL;
+ } else {
+ window = Tk_NameToWindow(interp, nameString, tkwin);
+ }
+#else
+ if (!tk_stubs_init_p() || tkwin == (Tk_Window)NULL) {
+ window = NULL;
+ } else {
+ /* Tk_NameToWindow() returns right token on non-eventloop thread */
+ Tcl_CmdInfo info;
+ if (Tcl_GetCommandInfo(interp, ".", &info)) { /* check root */
+ window = Tk_NameToWindow(interp, nameString, tkwin);
+ } else {
+ window = NULL;
+ }
+ }
+#endif
+
+#if TCL_MAJOR_VERSION >= 8
+ Tcl_DecrRefCount(objv[2]);
+#endif
+
+ if (window == NULL) {
+ Tcl_AppendResult(interp, ": thread_tkwait: ",
+ "no main-window (not Tk application?)",
+ (char*)NULL);
+
+ rb_thread_critical = thr_crit_bup;
+
+#if 0 /* use Tcl_EventuallyFree */
+ Tcl_EventuallyFree((ClientData)param, TCL_DYNAMIC); /* XXXXXXXX */
+#else
+#if 1 /* use Tcl_Preserve/Release */
+ Tcl_Release(param);
+#else
+ /* Tcl_Free((char *)param); */
+ ckfree((char *)param);
+#endif
+#endif
+
+ Tcl_Release(tkwin);
+ Tcl_Release(interp);
+ return TCL_ERROR;
+ }
+
+ Tcl_Preserve(window);
+
+ Tk_CreateEventHandler(window, StructureNotifyMask,
+ rb_threadWaitWindowProc, (ClientData) param);
+
+ rb_thread_critical = thr_crit_bup;
+
+ t.tv_sec = 0;
+ t.tv_usec = (long)((EVENT_HANDLER_TIMEOUT)*1000.0);
+
+ while(param->done != TKWAIT_MODE_DESTROY) {
+ /* rb_thread_stop(); */
+ /* rb_thread_sleep_forever(); */
+ rb_thread_wait_for(t);
+ if (NIL_P(eventloop_thread)) {
+ break;
+ }
+ }
+
+ Tcl_Release(window);
+
+ /* when a window is destroyed, no need to call Tk_DeleteEventHandler
+ thr_crit_bup = rb_thread_critical;
+ rb_thread_critical = Qtrue;
+
+ Tk_DeleteEventHandler(window, StructureNotifyMask,
+ rb_threadWaitWindowProc, (ClientData) param);
+
+ rb_thread_critical = thr_crit_bup;
+ */
+
+ break;
+ } /* end of 'switch' statement */
+
+#if 0 /* use Tcl_EventuallyFree */
+ Tcl_EventuallyFree((ClientData)param, TCL_DYNAMIC); /* XXXXXXXX */
+#else
+#if 1 /* use Tcl_Preserve/Release */
+ Tcl_Release((ClientData)param);
+#else
+ /* Tcl_Free((char *)param); */
+ ckfree((char *)param);
+#endif
+#endif
+
+ /*
+ * Clear out the interpreter's result, since it may have been set
+ * by event handlers.
+ */
+
+ Tcl_ResetResult(interp);
+
+ Tcl_Release(tkwin);
+ Tcl_Release(interp);
+ return TCL_OK;
+}
+
+static VALUE
+ip_thread_vwait(self, var)
+ VALUE self;
+ VALUE var;
+{
+ VALUE argv[2];
+ volatile VALUE cmd_str = rb_str_new2("thread_vwait");
+
+ argv[0] = cmd_str;
+ argv[1] = var;
+
+ return ip_invoke_with_position(2, argv, self, TCL_QUEUE_TAIL);
+}
+
+static VALUE
+ip_thread_tkwait(self, mode, target)
+ VALUE self;
+ VALUE mode;
+ VALUE target;
+{
+ VALUE argv[3];
+ volatile VALUE cmd_str = rb_str_new2("thread_tkwait");
+
+ argv[0] = cmd_str;
+ argv[1] = mode;
+ argv[2] = target;
+
+ return ip_invoke_with_position(3, argv, self, TCL_QUEUE_TAIL);
+}
+
+
+/* delete slave interpreters */
+#if TCL_MAJOR_VERSION >= 8
+static void
+delete_slaves(ip)
+ Tcl_Interp *ip;
+{
+ int thr_crit_bup;
+ Tcl_Interp *slave;
+ Tcl_Obj *slave_list, *elem;
+ char *slave_name;
+ int i, len;
+
+ DUMP1("delete slaves");
+ thr_crit_bup = rb_thread_critical;
+ rb_thread_critical = Qtrue;
+
+ if (!Tcl_InterpDeleted(ip) && Tcl_Eval(ip, "interp slaves") == TCL_OK) {
+ slave_list = Tcl_GetObjResult(ip);
+ Tcl_IncrRefCount(slave_list);
+
+ if (Tcl_ListObjLength((Tcl_Interp*)NULL, slave_list, &len) == TCL_OK) {
+ for(i = 0; i < len; i++) {
+ Tcl_ListObjIndex((Tcl_Interp*)NULL, slave_list, i, &elem);
+
+ if (elem == (Tcl_Obj*)NULL) continue;
+
+ Tcl_IncrRefCount(elem);
+
+ /* get slave */
+ /* slave_name = Tcl_GetString(elem); */
+ slave_name = Tcl_GetStringFromObj(elem, (int*)NULL);
+ DUMP2("delete slave:'%s'", slave_name);
+
+ Tcl_DecrRefCount(elem);
+
+ slave = Tcl_GetSlave(ip, slave_name);
+ if (slave == (Tcl_Interp*)NULL) continue;
+
+ if (!Tcl_InterpDeleted(slave)) {
+ /* call ip_finalize */
+ ip_finalize(slave);
+
+ Tcl_DeleteInterp(slave);
+ /* Tcl_Release(slave); */
+ }
+ }
+ }
+
+ Tcl_DecrRefCount(slave_list);
+ }
+
+ rb_thread_critical = thr_crit_bup;
+}
+#else /* TCL_MAJOR_VERSION < 8 */
+static void
+delete_slaves(ip)
+ Tcl_Interp *ip;
+{
+ int thr_crit_bup;
+ Tcl_Interp *slave;
+ int argc;
+ char **argv;
+ char *slave_list;
+ char *slave_name;
+ int i, len;
+
+ DUMP1("delete slaves");
+ thr_crit_bup = rb_thread_critical;
+ rb_thread_critical = Qtrue;
+
+ if (!Tcl_InterpDeleted(ip) && Tcl_Eval(ip, "interp slaves") == TCL_OK) {
+ slave_list = ip->result;
+ if (Tcl_SplitList((Tcl_Interp*)NULL,
+ slave_list, &argc, &argv) == TCL_OK) {
+ for(i = 0; i < argc; i++) {
+ slave_name = argv[i];
+
+ DUMP2("delete slave:'%s'", slave_name);
+
+ slave = Tcl_GetSlave(ip, slave_name);
+ if (slave == (Tcl_Interp*)NULL) continue;
+
+ if (!Tcl_InterpDeleted(slave)) {
+ /* call ip_finalize */
+ ip_finalize(slave);
+
+ Tcl_DeleteInterp(slave);
+ }
+ }
+ }
+ }
+
+ rb_thread_critical = thr_crit_bup;
+}
+#endif
+
+
+/* finalize operation */
+static void
+#ifdef HAVE_PROTOTYPES
+lib_mark_at_exit(VALUE self)
+#else
+lib_mark_at_exit(self)
+ VALUE self;
+#endif
+{
+ at_exit = 1;
+}
+
+static int
+#if TCL_MAJOR_VERSION >= 8
+#ifdef HAVE_PROTOTYPES
+ip_null_proc(ClientData clientData, Tcl_Interp *interp,
+ int argc, Tcl_Obj *CONST argv[])
+#else
+ip_null_proc(clientData, interp, argc, argv)
+ ClientData clientData;
+ Tcl_Interp *interp;
+ int argc;
+ Tcl_Obj *CONST argv[];
+#endif
+#else /* TCL_MAJOR_VERSION < 8 */
+#ifdef HAVE_PROTOTYPES
+ip_null_proc(ClientData clientData, Tcl_Interp *interp, int argc, char *argv[])
+#else
+ip_null_proc(clientData, interp, argc, argv)
+ ClientData clientData;
+ Tcl_Interp *interp;
+ int argc;
+ char *argv[];
+#endif
+#endif
+{
+ Tcl_ResetResult(interp);
+ return TCL_OK;
+}
+
+static void
+ip_finalize(ip)
+ Tcl_Interp *ip;
+{
+ Tcl_CmdInfo info;
+ int thr_crit_bup;
+
+ VALUE rb_debug_bup, rb_verbose_bup;
+ /* When ruby is exiting, printing debug messages in some callback
+ operations from Tcl-IP sometimes cause SEGV. I don't know the
+ reason. But I got SEGV when calling "rb_io_write(rb_stdout, ...)".
+ So, in some part of this function, debug mode and verbose mode
+ are disabled. If you know the reason, please fix it.
+ -- Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp) */
+
+ DUMP1("start ip_finalize");
+
+ if (ip == (Tcl_Interp*)NULL) {
+ DUMP1("ip is NULL");
+ return;
+ }
+
+ if (Tcl_InterpDeleted(ip)) {
+ DUMP2("ip(%p) is already deleted", ip);
+ return;
+ }
+
+#if TCL_NAMESPACE_DEBUG
+ if (ip_null_namespace(ip)) {
+ DUMP2("ip(%p) has null namespace", ip);
+ return;
+ }
+#endif
+
+ thr_crit_bup = rb_thread_critical;
+ rb_thread_critical = Qtrue;
+
+ rb_debug_bup = ruby_debug;
+ rb_verbose_bup = ruby_verbose;
+
+ Tcl_Preserve(ip);
+
+ /* delete slaves */
+ delete_slaves(ip);
+
+ /* shut off some connections from Tcl-proc to Ruby */
+ if (at_exit) {
+ /* NOTE: Only when at exit.
+ Because, ruby removes objects, which depends on the deleted
+ interpreter, on some callback operations.
+ It is important for GC. */
+#if TCL_MAJOR_VERSION >= 8
+ Tcl_CreateObjCommand(ip, "ruby", ip_null_proc,
+ (ClientData)NULL, (Tcl_CmdDeleteProc *)NULL);
+ Tcl_CreateObjCommand(ip, "ruby_eval", ip_null_proc,
+ (ClientData)NULL, (Tcl_CmdDeleteProc *)NULL);
+ Tcl_CreateObjCommand(ip, "ruby_cmd", ip_null_proc,
+ (ClientData)NULL, (Tcl_CmdDeleteProc *)NULL);
+#else /* TCL_MAJOR_VERSION < 8 */
+ Tcl_CreateCommand(ip, "ruby", ip_null_proc,
+ (ClientData)NULL, (Tcl_CmdDeleteProc *)NULL);
+ Tcl_CreateCommand(ip, "ruby_eval", ip_null_proc,
+ (ClientData)NULL, (Tcl_CmdDeleteProc *)NULL);
+ Tcl_CreateCommand(ip, "ruby_cmd", ip_null_proc,
+ (ClientData)NULL, (Tcl_CmdDeleteProc *)NULL);
+#endif
+ /*
+ rb_thread_critical = thr_crit_bup;
+ return;
+ */
+ }
+
+ /* delete root widget */
+#ifdef RUBY_VM
+ /* cause SEGV on Ruby 1.9 */
+#else
+ DUMP1("check `destroy'");
+ if (Tcl_GetCommandInfo(ip, "destroy", &info)) {
+ DUMP1("call `destroy .'");
+ Tcl_GlobalEval(ip, "catch {destroy .}");
+ }
+#endif
+#if 1
+ DUMP1("destroy root widget");
+ if (tk_stubs_init_p() && Tk_MainWindow(ip) != (Tk_Window)NULL) {
+ /*
+ * On Ruby VM, this code piece may be not called, because
+ * Tk_MainWindow() returns NULL on a native thread except
+ * the thread which initialize Tk environment.
+ * Of course, that is a problem. But maybe not so serious.
+ * All widgets are destroyed when the Tcl interp is deleted.
+ * At then, Ruby may raise exceptions on the delete hook
+ * callbacks which registered for the deleted widgets, and
+ * may fail to clear objects which depends on the widgets.
+ * Although it is the problem, it is possibly avoidable by
+ * rescuing exceptions and the finalize hook of the interp.
+ */
+ Tk_Window win = Tk_MainWindow(ip);
+
+ DUMP1("call Tk_DestroyWindow");
+ ruby_debug = Qfalse;
+ ruby_verbose = Qnil;
+ if (! (((Tk_FakeWin*)win)->flags & TK_ALREADY_DEAD)) {
+ Tk_DestroyWindow(win);
+ }
+ ruby_debug = rb_debug_bup;
+ ruby_verbose = rb_verbose_bup;
+ }
+#endif
+
+ /* call finalize-hook-proc */
+ DUMP1("check `finalize-hook-proc'");
+ if ( Tcl_GetCommandInfo(ip, finalize_hook_name, &info)) {
+ DUMP2("call finalize hook proc '%s'", finalize_hook_name);
+ ruby_debug = Qfalse;
+ ruby_verbose = Qnil;
+ Tcl_GlobalEval(ip, finalize_hook_name);
+ ruby_debug = rb_debug_bup;
+ ruby_verbose = rb_verbose_bup;
+ }
+
+ DUMP1("check `foreach' & `after'");
+ if ( Tcl_GetCommandInfo(ip, "foreach", &info)
+ && Tcl_GetCommandInfo(ip, "after", &info) ) {
+ DUMP1("cancel after callbacks");
+ ruby_debug = Qfalse;
+ ruby_verbose = Qnil;
+ Tcl_GlobalEval(ip, "catch {foreach id [after info] {after cancel $id}}");
+ ruby_debug = rb_debug_bup;
+ ruby_verbose = rb_verbose_bup;
+ }
+
+ Tcl_Release(ip);
+
+ DUMP1("finish ip_finalize");
+ ruby_debug = rb_debug_bup;
+ ruby_verbose = rb_verbose_bup;
+ rb_thread_critical = thr_crit_bup;
+}
+
+
+/* destroy interpreter */
+static void
+ip_free(p)
+ void *p;
+{
+ struct tcltkip *ptr = p;
+ int thr_crit_bup;
+
+ DUMP2("free Tcl Interp %p", ptr->ip);
+ if (ptr) {
+ thr_crit_bup = rb_thread_critical;
+ rb_thread_critical = Qtrue;
+
+ if ( ptr->ip != (Tcl_Interp*)NULL
+ && !Tcl_InterpDeleted(ptr->ip)
+ && Tcl_GetMaster(ptr->ip) != (Tcl_Interp*)NULL
+ && !Tcl_InterpDeleted(Tcl_GetMaster(ptr->ip)) ) {
+ DUMP2("parent IP(%p) is not deleted",
+ Tcl_GetMaster(ptr->ip));
+ DUMP2("slave IP(%p) should not be deleted",
+ ptr->ip);
+ xfree(ptr);
+ /* ckfree((char*)ptr); */
+ rb_thread_critical = thr_crit_bup;
+ return;
+ }
+
+ if (ptr->ip == (Tcl_Interp*)NULL) {
+ DUMP1("ip_free is called for deleted IP");
+ xfree(ptr);
+ /* ckfree((char*)ptr); */
+ rb_thread_critical = thr_crit_bup;
+ return;
+ }
+
+ if (!Tcl_InterpDeleted(ptr->ip)) {
+ ip_finalize(ptr->ip);
+
+ Tcl_DeleteInterp(ptr->ip);
+ Tcl_Release(ptr->ip);
+ }
+
+ ptr->ip = (Tcl_Interp*)NULL;
+ xfree(ptr);
+ /* ckfree((char*)ptr); */
+
+ rb_thread_critical = thr_crit_bup;
+ }
+
+ DUMP1("complete freeing Tcl Interp");
+}
+
+
+/* create and initialize interpreter */
+static VALUE ip_alloc _((VALUE));
+static VALUE
+ip_alloc(self)
+ VALUE self;
+{
+ return TypedData_Wrap_Struct(self, &tcltkip_type, 0);
+}
+
+static void
+ip_replace_wait_commands(interp, mainWin)
+ Tcl_Interp *interp;
+ Tk_Window mainWin;
+{
+ /* replace 'vwait' command */
+#if TCL_MAJOR_VERSION >= 8
+ DUMP1("Tcl_CreateObjCommand(\"vwait\")");
+ Tcl_CreateObjCommand(interp, "vwait", ip_rbVwaitObjCmd,
+ (ClientData)NULL, (Tcl_CmdDeleteProc *)NULL);
+#else /* TCL_MAJOR_VERSION < 8 */
+ DUMP1("Tcl_CreateCommand(\"vwait\")");
+ Tcl_CreateCommand(interp, "vwait", ip_rbVwaitCommand,
+ (ClientData)NULL, (Tcl_CmdDeleteProc *)NULL);
+#endif
+
+ /* replace 'tkwait' command */
+#if TCL_MAJOR_VERSION >= 8
+ DUMP1("Tcl_CreateObjCommand(\"tkwait\")");
+ Tcl_CreateObjCommand(interp, "tkwait", ip_rbTkWaitObjCmd,
+ (ClientData)mainWin, (Tcl_CmdDeleteProc *)NULL);
+#else /* TCL_MAJOR_VERSION < 8 */
+ DUMP1("Tcl_CreateCommand(\"tkwait\")");
+ Tcl_CreateCommand(interp, "tkwait", ip_rbTkWaitCommand,
+ (ClientData)mainWin, (Tcl_CmdDeleteProc *)NULL);
+#endif
+
+ /* add 'thread_vwait' command */
+#if TCL_MAJOR_VERSION >= 8
+ DUMP1("Tcl_CreateObjCommand(\"thread_vwait\")");
+ Tcl_CreateObjCommand(interp, "thread_vwait", ip_rb_threadVwaitObjCmd,
+ (ClientData)NULL, (Tcl_CmdDeleteProc *)NULL);
+#else /* TCL_MAJOR_VERSION < 8 */
+ DUMP1("Tcl_CreateCommand(\"thread_vwait\")");
+ Tcl_CreateCommand(interp, "thread_vwait", ip_rb_threadVwaitCommand,
+ (ClientData)NULL, (Tcl_CmdDeleteProc *)NULL);
+#endif
+
+ /* add 'thread_tkwait' command */
+#if TCL_MAJOR_VERSION >= 8
+ DUMP1("Tcl_CreateObjCommand(\"thread_tkwait\")");
+ Tcl_CreateObjCommand(interp, "thread_tkwait", ip_rb_threadTkWaitObjCmd,
+ (ClientData)mainWin, (Tcl_CmdDeleteProc *)NULL);
+#else /* TCL_MAJOR_VERSION < 8 */
+ DUMP1("Tcl_CreateCommand(\"thread_tkwait\")");
+ Tcl_CreateCommand(interp, "thread_tkwait", ip_rb_threadTkWaitCommand,
+ (ClientData)mainWin, (Tcl_CmdDeleteProc *)NULL);
+#endif
+
+ /* replace 'update' command */
+#if TCL_MAJOR_VERSION >= 8
+ DUMP1("Tcl_CreateObjCommand(\"update\")");
+ Tcl_CreateObjCommand(interp, "update", ip_rbUpdateObjCmd,
+ (ClientData)mainWin, (Tcl_CmdDeleteProc *)NULL);
+#else /* TCL_MAJOR_VERSION < 8 */
+ DUMP1("Tcl_CreateCommand(\"update\")");
+ Tcl_CreateCommand(interp, "update", ip_rbUpdateCommand,
+ (ClientData)mainWin, (Tcl_CmdDeleteProc *)NULL);
+#endif
+
+ /* add 'thread_update' command */
+#if TCL_MAJOR_VERSION >= 8
+ DUMP1("Tcl_CreateObjCommand(\"thread_update\")");
+ Tcl_CreateObjCommand(interp, "thread_update", ip_rb_threadUpdateObjCmd,
+ (ClientData)mainWin, (Tcl_CmdDeleteProc *)NULL);
+#else /* TCL_MAJOR_VERSION < 8 */
+ DUMP1("Tcl_CreateCommand(\"thread_update\")");
+ Tcl_CreateCommand(interp, "thread_update", ip_rb_threadUpdateCommand,
+ (ClientData)mainWin, (Tcl_CmdDeleteProc *)NULL);
+#endif
+}
+
+
+#if TCL_MAJOR_VERSION >= 8
+static int
+ip_rb_replaceSlaveTkCmdsObjCmd(clientData, interp, objc, objv)
+ ClientData clientData;
+ Tcl_Interp *interp;
+ int objc;
+ Tcl_Obj *CONST objv[];
+#else /* TCL_MAJOR_VERSION < 8 */
+static int
+ip_rb_replaceSlaveTkCmdsCommand(clientData, interp, objc, objv)
+ ClientData clientData;
+ Tcl_Interp *interp;
+ int objc;
+ char *objv[];
+#endif
+{
+ char *slave_name;
+ Tcl_Interp *slave;
+ Tk_Window mainWin;
+
+ if (objc != 2) {
+#ifdef Tcl_WrongNumArgs
+ Tcl_WrongNumArgs(interp, 1, objv, "slave_name");
+#else
+ char *nameString;
+#if TCL_MAJOR_VERSION >= 8
+ nameString = Tcl_GetStringFromObj(objv[0], (int*)NULL);
+#else /* TCL_MAJOR_VERSION < 8 */
+ nameString = objv[0];
+#endif
+ Tcl_AppendResult(interp, "wrong number of arguments: should be \"",
+ nameString, " slave_name\"", (char *) NULL);
+#endif
+ }
+
+#if TCL_MAJOR_VERSION >= 8
+ slave_name = Tcl_GetStringFromObj(objv[1], (int*)NULL);
+#else
+ slave_name = objv[1];
+#endif
+
+ slave = Tcl_GetSlave(interp, slave_name);
+ if (slave == NULL) {
+ Tcl_AppendResult(interp, "cannot find slave \"",
+ slave_name, "\"", (char *)NULL);
+ return TCL_ERROR;
+ }
+ mainWin = Tk_MainWindow(slave);
+
+ /* replace 'exit' command --> 'interp_exit' command */
+#if TCL_MAJOR_VERSION >= 8
+ DUMP1("Tcl_CreateObjCommand(\"exit\") --> \"interp_exit\"");
+ Tcl_CreateObjCommand(slave, "exit", ip_InterpExitObjCmd,
+ (ClientData)mainWin, (Tcl_CmdDeleteProc *)NULL);
+#else /* TCL_MAJOR_VERSION < 8 */
+ DUMP1("Tcl_CreateCommand(\"exit\") --> \"interp_exit\"");
+ Tcl_CreateCommand(slave, "exit", ip_InterpExitCommand,
+ (ClientData)mainWin, (Tcl_CmdDeleteProc *)NULL);
+#endif
+
+ /* replace vwait and tkwait */
+ ip_replace_wait_commands(slave, mainWin);
+
+ return TCL_OK;
+}
+
+#ifndef ORIG_NAMESPACE_CMD
+#define ORIG_NAMESPACE_CMD "__orig_namespace_command__"
+#endif
+
+#if TCL_MAJOR_VERSION >= 8
+static int ip_rbNamespaceObjCmd _((ClientData, Tcl_Interp *, int,
+ Tcl_Obj *CONST []));
+static int
+ip_rbNamespaceObjCmd(clientData, interp, objc, objv)
+ ClientData clientData;
+ Tcl_Interp *interp;
+ int objc;
+ Tcl_Obj *CONST objv[];
+{
+ Tcl_CmdInfo info;
+ int ret;
+
+ DUMP1("call ip_rbNamespaceObjCmd");
+ DUMP2("objc = %d", objc);
+ DUMP2("objv[0] = '%s'", Tcl_GetString(objv[0]));
+ DUMP2("objv[1] = '%s'", Tcl_GetString(objv[1]));
+ if (!Tcl_GetCommandInfo(interp, ORIG_NAMESPACE_CMD, &(info))) {
+ DUMP1("fail to get "ORIG_NAMESPACE_CMD);
+ Tcl_ResetResult(interp);
+ Tcl_AppendResult(interp,
+ "invalid command name \"namespace\"", (char*)NULL);
+ return TCL_ERROR;
+ }
+
+ rbtk_eventloop_depth++;
+ DUMP2("namespace wrapper enter depth == %d", rbtk_eventloop_depth);
+
+ if (info.isNativeObjectProc) {
+#if TCL_MAJOR_VERSION == 8 && TCL_MINOR_VERSION < 6
+ DUMP1("call a native-object-proc");
+ ret = (*(info.objProc))(info.objClientData, interp, objc, objv);
+#else
+ /* Tcl8.6 or later */
+ int i;
+ Tcl_Obj **cp_objv;
+ char org_ns_cmd_name[] = ORIG_NAMESPACE_CMD;
+
+ DUMP1("call a native-object-proc for tcl8.6 or later");
+ cp_objv = RbTk_ALLOC_N(Tcl_Obj *, (objc + 1));
+
+ cp_objv[0] = Tcl_NewStringObj(org_ns_cmd_name, strlen(org_ns_cmd_name));
+ for(i = 1; i < objc; i++) {
+ cp_objv[i] = objv[i];
+ }
+ cp_objv[objc] = (Tcl_Obj *)NULL;
+
+ /* ret = Tcl_EvalObjv(interp, objc, cp_objv, TCL_EVAL_DIRECT); */
+ ret = Tcl_EvalObjv(interp, objc, cp_objv, 0);
+
+ ckfree((char*)cp_objv);
+#endif
+ } else {
+ /* string interface */
+ int i;
+ char **argv;
+
+ DUMP1("call with the string-interface");
+ /* argv = (char **)Tcl_Alloc(sizeof(char *) * (objc + 1)); */
+ argv = RbTk_ALLOC_N(char *, (objc + 1));
+#if 0 /* use Tcl_Preserve/Release */
+ Tcl_Preserve((ClientData)argv); /* XXXXXXXX */
+#endif
+
+ for(i = 0; i < objc; i++) {
+ /* argv[i] = Tcl_GetString(objv[i]); */
+ argv[i] = Tcl_GetStringFromObj(objv[i], (int*)NULL);
+ }
+ argv[objc] = (char *)NULL;
+
+ ret = (*(info.proc))(info.clientData, interp,
+ objc, (CONST84 char **)argv);
+
+#if 0 /* use Tcl_EventuallyFree */
+ Tcl_EventuallyFree((ClientData)argv, TCL_DYNAMIC); /* XXXXXXXX */
+#else
+#if 0 /* use Tcl_Preserve/Release */
+ Tcl_Release((ClientData)argv); /* XXXXXXXX */
+#else
+ /* Tcl_Free((char*)argv); */
+ ckfree((char*)argv);
+#endif
+#endif
+ }
+
+ DUMP2("namespace wrapper exit depth == %d", rbtk_eventloop_depth);
+ rbtk_eventloop_depth--;
+
+ DUMP1("end of ip_rbNamespaceObjCmd");
+ return ret;
+}
+#endif
+
+static void
+ip_wrap_namespace_command(interp)
+ Tcl_Interp *interp;
+{
+#if TCL_MAJOR_VERSION >= 8
+
+#if TCL_MAJOR_VERSION == 8 && TCL_MINOR_VERSION < 6
+ Tcl_CmdInfo orig_info;
+
+ if (!Tcl_GetCommandInfo(interp, "namespace", &(orig_info))) {
+ return;
+ }
+
+ if (orig_info.isNativeObjectProc) {
+ Tcl_CreateObjCommand(interp, ORIG_NAMESPACE_CMD,
+ orig_info.objProc, orig_info.objClientData,
+ orig_info.deleteProc);
+ } else {
+ Tcl_CreateCommand(interp, ORIG_NAMESPACE_CMD,
+ orig_info.proc, orig_info.clientData,
+ orig_info.deleteProc);
+ }
+
+#else /* tcl8.6 or later */
+ Tcl_Eval(interp, "rename namespace "ORIG_NAMESPACE_CMD);
+
+#endif
+
+ Tcl_CreateObjCommand(interp, "namespace", ip_rbNamespaceObjCmd,
+ (ClientData) 0, (Tcl_CmdDeleteProc *)NULL);
+#endif
+}
+
+
+/* call when interpreter is deleted */
+static void
+#ifdef HAVE_PROTOTYPES
+ip_CallWhenDeleted(ClientData clientData, Tcl_Interp *ip)
+#else
+ip_CallWhenDeleted(clientData, ip)
+ ClientData clientData;
+ Tcl_Interp *ip;
+#endif
+{
+ int thr_crit_bup;
+ /* Tk_Window main_win = (Tk_Window) clientData; */
+
+ DUMP1("start ip_CallWhenDeleted");
+ thr_crit_bup = rb_thread_critical;
+ rb_thread_critical = Qtrue;
+
+ ip_finalize(ip);
+
+ DUMP1("finish ip_CallWhenDeleted");
+ rb_thread_critical = thr_crit_bup;
+}
+
+/*--------------------------------------------------------*/
+
+/* initialize interpreter */
+static VALUE
+ip_init(argc, argv, self)
+ int argc;
+ VALUE *argv;
+ VALUE self;
+{
+ struct tcltkip *ptr; /* tcltkip data struct */
+ VALUE argv0, opts;
+ int cnt;
+ int st;
+ int with_tk = 1;
+ Tk_Window mainWin = (Tk_Window)NULL;
+
+ /* security check */
+ if (rb_safe_level() >= 4) {
+ rb_raise(rb_eSecurityError,
+ "Cannot create a TclTkIp object at level %d",
+ rb_safe_level());
+ }
+
+ /* create object */
+ TypedData_Get_Struct(self, struct tcltkip, &tcltkip_type, ptr);
+ ptr = ALLOC(struct tcltkip);
+ /* ptr = RbTk_ALLOC_N(struct tcltkip, 1); */
+ DATA_PTR(self) = ptr;
+#ifdef RUBY_USE_NATIVE_THREAD
+ ptr->tk_thread_id = 0;
+#endif
+ ptr->ref_count = 0;
+ ptr->allow_ruby_exit = 1;
+ ptr->return_value = 0;
+
+ /* from Tk_Main() */
+ DUMP1("Tcl_CreateInterp");
+ ptr->ip = ruby_tcl_create_ip_and_stubs_init(&st);
+ if (ptr->ip == NULL) {
+ switch(st) {
+ case TCLTK_STUBS_OK:
+ break;
+ case NO_TCL_DLL:
+ rb_raise(rb_eLoadError, "tcltklib: fail to open tcl_dll");
+ case NO_FindExecutable:
+ rb_raise(rb_eLoadError, "tcltklib: can't find Tcl_FindExecutable");
+ case NO_CreateInterp:
+ rb_raise(rb_eLoadError, "tcltklib: can't find Tcl_CreateInterp()");
+ case NO_DeleteInterp:
+ rb_raise(rb_eLoadError, "tcltklib: can't find Tcl_DeleteInterp()");
+ case FAIL_CreateInterp:
+ rb_raise(rb_eRuntimeError, "tcltklib: fail to create a new IP");
+ case FAIL_Tcl_InitStubs:
+ rb_raise(rb_eRuntimeError, "tcltklib: fail to Tcl_InitStubs()");
+ default:
+ rb_raise(rb_eRuntimeError, "tcltklib: unknown error(%d) on ruby_tcl_create_ip_and_stubs_init", st);
+ }
+ }
+
+#if TCL_MAJOR_VERSION >= 8
+#if TCL_NAMESPACE_DEBUG
+ DUMP1("get current namespace");
+ if ((ptr->default_ns = Tcl_GetCurrentNamespace(ptr->ip))
+ == (Tcl_Namespace*)NULL) {
+ rb_raise(rb_eRuntimeError, "a new Tk interpreter has a NULL namespace");
+ }
+#endif
+#endif
+
+ rbtk_preserve_ip(ptr);
+ DUMP2("IP ref_count = %d", ptr->ref_count);
+ current_interp = ptr->ip;
+
+ ptr->has_orig_exit
+ = Tcl_GetCommandInfo(ptr->ip, "exit", &(ptr->orig_exit_info));
+
+#if defined CREATE_RUBYTK_KIT || defined CREATE_RUBYKIT
+ call_tclkit_init_script(current_interp);
+
+# if 10 * TCL_MAJOR_VERSION + TCL_MINOR_VERSION > 84
+ {
+ Tcl_DString encodingName;
+ Tcl_GetEncodingNameFromEnvironment(&encodingName);
+ if (strcmp(Tcl_DStringValue(&encodingName), Tcl_GetEncodingName(NULL))) {
+ /* fails, so we set a variable and do it in the boot.tcl script */
+ Tcl_SetSystemEncoding(NULL, Tcl_DStringValue(&encodingName));
+ }
+ Tcl_SetVar(current_interp, "tclkit_system_encoding", Tcl_DStringValue(&encodingName), 0);
+ Tcl_DStringFree(&encodingName);
+ }
+# endif
+#endif
+
+ /* set variables */
+ Tcl_Eval(ptr->ip, "set argc 0; set argv {}; set argv0 tcltklib.so");
+
+ cnt = rb_scan_args(argc, argv, "02", &argv0, &opts);
+ switch(cnt) {
+ case 2:
+ /* options */
+ if (NIL_P(opts) || opts == Qfalse) {
+ /* without Tk */
+ with_tk = 0;
+ } else {
+ /* Tcl_SetVar(ptr->ip, "argv", StringValuePtr(opts), 0); */
+ Tcl_SetVar(ptr->ip, "argv", StringValuePtr(opts), TCL_GLOBAL_ONLY);
+ Tcl_Eval(ptr->ip, "set argc [llength $argv]");
+ }
+ case 1:
+ /* argv0 */
+ if (!NIL_P(argv0)) {
+ if (strncmp(StringValuePtr(argv0), "-e", 3) == 0
+ || strncmp(StringValuePtr(argv0), "-", 2) == 0) {
+ Tcl_SetVar(ptr->ip, "argv0", "ruby", TCL_GLOBAL_ONLY);
+ } else {
+ /* Tcl_SetVar(ptr->ip, "argv0", StringValuePtr(argv0), 0); */
+ Tcl_SetVar(ptr->ip, "argv0", StringValuePtr(argv0),
+ TCL_GLOBAL_ONLY);
+ }
+ }
+ case 0:
+ /* no args */
+ ;
+ }
+
+ /* from Tcl_AppInit() */
+ DUMP1("Tcl_Init");
+#if (defined CREATE_RUBYTK_KIT || defined CREATE_RUBYKIT) && (!defined KIT_LITE) && (10 * TCL_MAJOR_VERSION + TCL_MINOR_VERSION == 85)
+ /*************************************************************************/
+ /* FIX ME (2010/06/28) */
+ /* Don't use ::chan command for Mk4tcl + tclvfs-1.4 on Tcl8.5. */
+ /* It fails to access VFS files because of vfs::zstream. */
+ /* So, force to use ::rechan by temporarily hiding ::chan. */
+ /*************************************************************************/
+ Tcl_Eval(ptr->ip, "catch {rename ::chan ::_tmp_chan}");
+ if (Tcl_Init(ptr->ip) == TCL_ERROR) {
+ rb_raise(rb_eRuntimeError, "%s", Tcl_GetStringResult(ptr->ip));
+ }
+ Tcl_Eval(ptr->ip, "catch {rename ::_tmp_chan ::chan}");
+#else
+ if (Tcl_Init(ptr->ip) == TCL_ERROR) {
+ rb_raise(rb_eRuntimeError, "%s", Tcl_GetStringResult(ptr->ip));
+ }
+#endif
+
+ st = ruby_tcl_stubs_init();
+ /* from Tcl_AppInit() */
+ if (with_tk) {
+ DUMP1("Tk_Init");
+ st = ruby_tk_stubs_init(ptr->ip);
+ switch(st) {
+ case TCLTK_STUBS_OK:
+ break;
+ case NO_Tk_Init:
+ rb_raise(rb_eLoadError, "tcltklib: can't find Tk_Init()");
+ case FAIL_Tk_Init:
+ rb_raise(rb_eRuntimeError, "tcltklib: fail to Tk_Init(). %s",
+ Tcl_GetStringResult(ptr->ip));
+ case FAIL_Tk_InitStubs:
+ rb_raise(rb_eRuntimeError, "tcltklib: fail to Tk_InitStubs(). %s",
+ Tcl_GetStringResult(ptr->ip));
+ default:
+ rb_raise(rb_eRuntimeError, "tcltklib: unknown error(%d) on ruby_tk_stubs_init", st);
+ }
+
+ DUMP1("Tcl_StaticPackage(\"Tk\")");
+#if TCL_MAJOR_VERSION >= 8
+ Tcl_StaticPackage(ptr->ip, "Tk", Tk_Init, Tk_SafeInit);
+#else /* TCL_MAJOR_VERSION < 8 */
+ Tcl_StaticPackage(ptr->ip, "Tk", Tk_Init,
+ (Tcl_PackageInitProc *) NULL);
+#endif
+
+#ifdef RUBY_USE_NATIVE_THREAD
+ /* set Tk thread ID */
+ ptr->tk_thread_id = Tcl_GetCurrentThread();
+#endif
+ /* get main window */
+ mainWin = Tk_MainWindow(ptr->ip);
+ Tk_Preserve((ClientData)mainWin);
+ }
+
+ /* add ruby command to the interpreter */
+#if TCL_MAJOR_VERSION >= 8
+ DUMP1("Tcl_CreateObjCommand(\"ruby\")");
+ Tcl_CreateObjCommand(ptr->ip, "ruby", ip_ruby_eval, (ClientData)NULL,
+ (Tcl_CmdDeleteProc *)NULL);
+ DUMP1("Tcl_CreateObjCommand(\"ruby_eval\")");
+ Tcl_CreateObjCommand(ptr->ip, "ruby_eval", ip_ruby_eval, (ClientData)NULL,
+ (Tcl_CmdDeleteProc *)NULL);
+ DUMP1("Tcl_CreateObjCommand(\"ruby_cmd\")");
+ Tcl_CreateObjCommand(ptr->ip, "ruby_cmd", ip_ruby_cmd, (ClientData)NULL,
+ (Tcl_CmdDeleteProc *)NULL);
+#else /* TCL_MAJOR_VERSION < 8 */
+ DUMP1("Tcl_CreateCommand(\"ruby\")");
+ Tcl_CreateCommand(ptr->ip, "ruby", ip_ruby_eval, (ClientData)NULL,
+ (Tcl_CmdDeleteProc *)NULL);
+ DUMP1("Tcl_CreateCommand(\"ruby_eval\")");
+ Tcl_CreateCommand(ptr->ip, "ruby_eval", ip_ruby_eval, (ClientData)NULL,
+ (Tcl_CmdDeleteProc *)NULL);
+ DUMP1("Tcl_CreateCommand(\"ruby_cmd\")");
+ Tcl_CreateCommand(ptr->ip, "ruby_cmd", ip_ruby_cmd, (ClientData)NULL,
+ (Tcl_CmdDeleteProc *)NULL);
+#endif
+
+ /* add 'interp_exit', 'ruby_exit' and replace 'exit' command */
+#if TCL_MAJOR_VERSION >= 8
+ DUMP1("Tcl_CreateObjCommand(\"interp_exit\")");
+ Tcl_CreateObjCommand(ptr->ip, "interp_exit", ip_InterpExitObjCmd,
+ (ClientData)mainWin, (Tcl_CmdDeleteProc *)NULL);
+ DUMP1("Tcl_CreateObjCommand(\"ruby_exit\")");
+ Tcl_CreateObjCommand(ptr->ip, "ruby_exit", ip_RubyExitObjCmd,
+ (ClientData)mainWin, (Tcl_CmdDeleteProc *)NULL);
+ DUMP1("Tcl_CreateObjCommand(\"exit\") --> \"ruby_exit\"");
+ Tcl_CreateObjCommand(ptr->ip, "exit", ip_RubyExitObjCmd,
+ (ClientData)mainWin, (Tcl_CmdDeleteProc *)NULL);
+#else /* TCL_MAJOR_VERSION < 8 */
+ DUMP1("Tcl_CreateCommand(\"interp_exit\")");
+ Tcl_CreateCommand(ptr->ip, "interp_exit", ip_InterpExitCommand,
+ (ClientData)mainWin, (Tcl_CmdDeleteProc *)NULL);
+ DUMP1("Tcl_CreateCommand(\"ruby_exit\")");
+ Tcl_CreateCommand(ptr->ip, "ruby_exit", ip_RubyExitCommand,
+ (ClientData)mainWin, (Tcl_CmdDeleteProc *)NULL);
+ DUMP1("Tcl_CreateCommand(\"exit\") --> \"ruby_exit\"");
+ Tcl_CreateCommand(ptr->ip, "exit", ip_RubyExitCommand,
+ (ClientData)mainWin, (Tcl_CmdDeleteProc *)NULL);
+#endif
+
+ /* replace vwait and tkwait */
+ ip_replace_wait_commands(ptr->ip, mainWin);
+
+ /* wrap namespace command */
+ ip_wrap_namespace_command(ptr->ip);
+
+ /* define command to replace commands which depend on slave's MainWindow */
+#if TCL_MAJOR_VERSION >= 8
+ Tcl_CreateObjCommand(ptr->ip, "__replace_slave_tk_commands__",
+ ip_rb_replaceSlaveTkCmdsObjCmd,
+ (ClientData)NULL, (Tcl_CmdDeleteProc *)NULL);
+#else /* TCL_MAJOR_VERSION < 8 */
+ Tcl_CreateCommand(ptr->ip, "__replace_slave_tk_commands__",
+ ip_rb_replaceSlaveTkCmdsCommand,
+ (ClientData)NULL, (Tcl_CmdDeleteProc *)NULL);
+#endif
+
+ /* set finalizer */
+ Tcl_CallWhenDeleted(ptr->ip, ip_CallWhenDeleted, (ClientData)mainWin);
+
+ if (mainWin != (Tk_Window)NULL) {
+ Tk_Release((ClientData)mainWin);
+ }
+
+ return self;
+}
+
+static VALUE
+ip_create_slave_core(interp, argc, argv)
+ VALUE interp;
+ int argc;
+ VALUE *argv;
+{
+ struct tcltkip *master = get_ip(interp);
+ struct tcltkip *slave = ALLOC(struct tcltkip);
+ /* struct tcltkip *slave = RbTk_ALLOC_N(struct tcltkip, 1); */
+ VALUE safemode;
+ VALUE name;
+ int safe;
+ int thr_crit_bup;
+ Tk_Window mainWin;
+
+ /* ip is deleted? */
+ if (deleted_ip(master)) {
+ return rb_exc_new2(rb_eRuntimeError,
+ "deleted master cannot create a new slave");
+ }
+
+ name = argv[0];
+ safemode = argv[1];
+
+ if (Tcl_IsSafe(master->ip) == 1) {
+ safe = 1;
+ } else if (safemode == Qfalse || NIL_P(safemode)) {
+ safe = 0;
+ } else {
+ safe = 1;
+ }
+
+ thr_crit_bup = rb_thread_critical;
+ rb_thread_critical = Qtrue;
+
+#if 0
+ /* init Tk */
+ if (RTEST(with_tk)) {
+ volatile VALUE exc;
+ if (!tk_stubs_init_p()) {
+ exc = tcltkip_init_tk(interp);
+ if (!NIL_P(exc)) {
+ rb_thread_critical = thr_crit_bup;
+ return exc;
+ }
+ }
+ }
+#endif
+
+ /* create slave-ip */
+#ifdef RUBY_USE_NATIVE_THREAD
+ /* slave->tk_thread_id = 0; */
+ slave->tk_thread_id = master->tk_thread_id; /* == current thread */
+#endif
+ slave->ref_count = 0;
+ slave->allow_ruby_exit = 0;
+ slave->return_value = 0;
+
+ slave->ip = Tcl_CreateSlave(master->ip, StringValuePtr(name), safe);
+ if (slave->ip == NULL) {
+ rb_thread_critical = thr_crit_bup;
+ return rb_exc_new2(rb_eRuntimeError,
+ "fail to create the new slave interpreter");
+ }
+#if TCL_MAJOR_VERSION >= 8
+#if TCL_NAMESPACE_DEBUG
+ slave->default_ns = Tcl_GetCurrentNamespace(slave->ip);
+#endif
+#endif
+ rbtk_preserve_ip(slave);
+
+ slave->has_orig_exit
+ = Tcl_GetCommandInfo(slave->ip, "exit", &(slave->orig_exit_info));
+
+ /* replace 'exit' command --> 'interp_exit' command */
+ mainWin = (tk_stubs_init_p())? Tk_MainWindow(slave->ip): (Tk_Window)NULL;
+#if TCL_MAJOR_VERSION >= 8
+ DUMP1("Tcl_CreateObjCommand(\"exit\") --> \"interp_exit\"");
+ Tcl_CreateObjCommand(slave->ip, "exit", ip_InterpExitObjCmd,
+ (ClientData)mainWin, (Tcl_CmdDeleteProc *)NULL);
+#else /* TCL_MAJOR_VERSION < 8 */
+ DUMP1("Tcl_CreateCommand(\"exit\") --> \"interp_exit\"");
+ Tcl_CreateCommand(slave->ip, "exit", ip_InterpExitCommand,
+ (ClientData)mainWin, (Tcl_CmdDeleteProc *)NULL);
+#endif
+
+ /* replace vwait and tkwait */
+ ip_replace_wait_commands(slave->ip, mainWin);
+
+ /* wrap namespace command */
+ ip_wrap_namespace_command(slave->ip);
+
+ /* define command to replace cmds which depend on slave-slave's MainWin */
+#if TCL_MAJOR_VERSION >= 8
+ Tcl_CreateObjCommand(slave->ip, "__replace_slave_tk_commands__",
+ ip_rb_replaceSlaveTkCmdsObjCmd,
+ (ClientData)NULL, (Tcl_CmdDeleteProc *)NULL);
+#else /* TCL_MAJOR_VERSION < 8 */
+ Tcl_CreateCommand(slave->ip, "__replace_slave_tk_commands__",
+ ip_rb_replaceSlaveTkCmdsCommand,
+ (ClientData)NULL, (Tcl_CmdDeleteProc *)NULL);
+#endif
+
+ /* set finalizer */
+ Tcl_CallWhenDeleted(slave->ip, ip_CallWhenDeleted, (ClientData)mainWin);
+
+ rb_thread_critical = thr_crit_bup;
+
+ return TypedData_Wrap_Struct(CLASS_OF(interp), &tcltkip_type, slave);
+}
+
+static VALUE
+ip_create_slave(argc, argv, self)
+ int argc;
+ VALUE *argv;
+ VALUE self;
+{
+ struct tcltkip *master = get_ip(self);
+ VALUE safemode;
+ VALUE name;
+ VALUE callargv[2];
+
+ /* ip is deleted? */
+ if (deleted_ip(master)) {
+ rb_raise(rb_eRuntimeError,
+ "deleted master cannot create a new slave interpreter");
+ }
+
+ /* argument check */
+ if (rb_scan_args(argc, argv, "11", &name, &safemode) == 1) {
+ safemode = Qfalse;
+ }
+ if (Tcl_IsSafe(master->ip) != 1
+ && (safemode == Qfalse || NIL_P(safemode))) {
+ }
+
+ StringValue(name);
+ callargv[0] = name;
+ callargv[1] = safemode;
+
+ return tk_funcall(ip_create_slave_core, 2, callargv, self);
+}
+
+
+/* self is slave of master? */
+static VALUE
+ip_is_slave_of_p(self, master)
+ VALUE self, master;
+{
+ if (!rb_obj_is_kind_of(master, tcltkip_class)) {
+ rb_raise(rb_eArgError, "expected TclTkIp object");
+ }
+
+ if (Tcl_GetMaster(get_ip(self)->ip) == get_ip(master)->ip) {
+ return Qtrue;
+ } else {
+ return Qfalse;
+ }
+}
+
+
+/* create console (if supported) */
+#if defined(MAC_TCL) || defined(__WIN32__)
+#if TCL_MAJOR_VERSION < 8 \
+ || (TCL_MAJOR_VERSION == 8 && TCL_MINOR_VERSION == 0) \
+ || (TCL_MAJOR_VERSION == 8 && TCL_MINOR_VERSION == 1 \
+ && (TCL_RELEASE_LEVEL == TCL_ALPHA_RELEASE \
+ || (TCL_RELEASE_LEVEL == TCL_BETA_RELEASE \
+ && TCL_RELEASE_SERIAL < 2) ) )
+EXTERN void TkConsoleCreate _((void));
+#endif
+#if TCL_MAJOR_VERSION == 8 && TCL_MINOR_VERSION == 1 \
+ && ( (TCL_RELEASE_LEVEL == TCL_FINAL_RELEASE \
+ && TCL_RELEASE_SERIAL == 0) \
+ || (TCL_RELEASE_LEVEL == TCL_BETA_RELEASE \
+ && TCL_RELEASE_SERIAL >= 2) )
+EXTERN void TkConsoleCreate_ _((void));
+#endif
+#endif
+static VALUE
+ip_create_console_core(interp, argc, argv)
+ VALUE interp;
+ int argc; /* dummy */
+ VALUE *argv; /* dummy */
+{
+ struct tcltkip *ptr = get_ip(interp);
+
+ if (!tk_stubs_init_p()) {
+ tcltkip_init_tk(interp);
+ }
+
+ if (Tcl_GetVar(ptr->ip,"tcl_interactive",TCL_GLOBAL_ONLY) == (char*)NULL) {
+ Tcl_SetVar(ptr->ip, "tcl_interactive", "0", TCL_GLOBAL_ONLY);
+ }
+
+#if TCL_MAJOR_VERSION > 8 \
+ || (TCL_MAJOR_VERSION == 8 \
+ && (TCL_MINOR_VERSION > 1 \
+ || (TCL_MINOR_VERSION == 1 \
+ && TCL_RELEASE_LEVEL == TCL_FINAL_RELEASE \
+ && TCL_RELEASE_SERIAL >= 1) ) )
+ Tk_InitConsoleChannels(ptr->ip);
+
+ if (Tk_CreateConsoleWindow(ptr->ip) != TCL_OK) {
+ rb_raise(rb_eRuntimeError, "fail to create console-window");
+ }
+#else
+#if defined(MAC_TCL) || defined(__WIN32__)
+#if TCL_MAJOR_VERSION == 8 && TCL_MINOR_VERSION == 1 \
+ && ( (TCL_RELEASE_LEVEL == TCL_FINAL_RELEASE && TCL_RELEASE_SERIAL == 0) \
+ || (TCL_RELEASE_LEVEL == TCL_BETA_RELEASE && TCL_RELEASE_SERIAL >= 2) )
+ TkConsoleCreate_();
+#else
+ TkConsoleCreate();
+#endif
+
+ if (TkConsoleInit(ptr->ip) != TCL_OK) {
+ rb_raise(rb_eRuntimeError, "fail to create console-window");
+ }
+#else
+ rb_notimplement();
+#endif
+#endif
+
+ return interp;
+}
+
+static VALUE
+ip_create_console(self)
+ VALUE self;
+{
+ struct tcltkip *ptr = get_ip(self);
+
+ /* ip is deleted? */
+ if (deleted_ip(ptr)) {
+ rb_raise(rb_eRuntimeError, "interpreter is deleted");
+ }
+
+ return tk_funcall(ip_create_console_core, 0, (VALUE*)NULL, self);
+}
+
+/* make ip "safe" */
+static VALUE
+ip_make_safe_core(interp, argc, argv)
+ VALUE interp;
+ int argc; /* dummy */
+ VALUE *argv; /* dummy */
+{
+ struct tcltkip *ptr = get_ip(interp);
+ Tk_Window mainWin;
+
+ /* ip is deleted? */
+ if (deleted_ip(ptr)) {
+ return rb_exc_new2(rb_eRuntimeError, "interpreter is deleted");
+ }
+
+ if (Tcl_MakeSafe(ptr->ip) == TCL_ERROR) {
+ /* return rb_exc_new2(rb_eRuntimeError,
+ Tcl_GetStringResult(ptr->ip)); */
+ return create_ip_exc(interp, rb_eRuntimeError, "%s",
+ Tcl_GetStringResult(ptr->ip));
+ }
+
+ ptr->allow_ruby_exit = 0;
+
+ /* replace 'exit' command --> 'interp_exit' command */
+ mainWin = (tk_stubs_init_p())? Tk_MainWindow(ptr->ip): (Tk_Window)NULL;
+#if TCL_MAJOR_VERSION >= 8
+ DUMP1("Tcl_CreateObjCommand(\"exit\") --> \"interp_exit\"");
+ Tcl_CreateObjCommand(ptr->ip, "exit", ip_InterpExitObjCmd,
+ (ClientData)mainWin, (Tcl_CmdDeleteProc *)NULL);
+#else /* TCL_MAJOR_VERSION < 8 */
+ DUMP1("Tcl_CreateCommand(\"exit\") --> \"interp_exit\"");
+ Tcl_CreateCommand(ptr->ip, "exit", ip_InterpExitCommand,
+ (ClientData)mainWin, (Tcl_CmdDeleteProc *)NULL);
+#endif
+
+ return interp;
+}
+
+static VALUE
+ip_make_safe(self)
+ VALUE self;
+{
+ struct tcltkip *ptr = get_ip(self);
+
+ /* ip is deleted? */
+ if (deleted_ip(ptr)) {
+ rb_raise(rb_eRuntimeError, "interpreter is deleted");
+ }
+
+ return tk_funcall(ip_make_safe_core, 0, (VALUE*)NULL, self);
+}
+
+/* is safe? */
+static VALUE
+ip_is_safe_p(self)
+ VALUE self;
+{
+ struct tcltkip *ptr = get_ip(self);
+
+ /* ip is deleted? */
+ if (deleted_ip(ptr)) {
+ rb_raise(rb_eRuntimeError, "interpreter is deleted");
+ }
+
+ if (Tcl_IsSafe(ptr->ip)) {
+ return Qtrue;
+ } else {
+ return Qfalse;
+ }
+}
+
+/* allow_ruby_exit? */
+static VALUE
+ip_allow_ruby_exit_p(self)
+ VALUE self;
+{
+ struct tcltkip *ptr = get_ip(self);
+
+ /* ip is deleted? */
+ if (deleted_ip(ptr)) {
+ rb_raise(rb_eRuntimeError, "interpreter is deleted");
+ }
+
+ if (ptr->allow_ruby_exit) {
+ return Qtrue;
+ } else {
+ return Qfalse;
+ }
+}
+
+/* allow_ruby_exit = mode */
+static VALUE
+ip_allow_ruby_exit_set(self, val)
+ VALUE self, val;
+{
+ struct tcltkip *ptr = get_ip(self);
+ Tk_Window mainWin;
+
+
+ /* ip is deleted? */
+ if (deleted_ip(ptr)) {
+ rb_raise(rb_eRuntimeError, "interpreter is deleted");
+ }
+
+ if (Tcl_IsSafe(ptr->ip)) {
+ rb_raise(rb_eSecurityError,
+ "insecure operation on a safe interpreter");
+ }
+
+ /*
+ * Because of cross-threading, the following line may fail to find
+ * the MainWindow, even if the Tcl/Tk interpreter has one or more.
+ * But it has no problem. Current implementation of both type of
+ * the "exit" command don't need maiinWin token.
+ */
+ mainWin = (tk_stubs_init_p())? Tk_MainWindow(ptr->ip): (Tk_Window)NULL;
+
+ if (RTEST(val)) {
+ ptr->allow_ruby_exit = 1;
+#if TCL_MAJOR_VERSION >= 8
+ DUMP1("Tcl_CreateObjCommand(\"exit\") --> \"ruby_exit\"");
+ Tcl_CreateObjCommand(ptr->ip, "exit", ip_RubyExitObjCmd,
+ (ClientData)mainWin, (Tcl_CmdDeleteProc *)NULL);
+#else /* TCL_MAJOR_VERSION < 8 */
+ DUMP1("Tcl_CreateCommand(\"exit\") --> \"ruby_exit\"");
+ Tcl_CreateCommand(ptr->ip, "exit", ip_RubyExitCommand,
+ (ClientData)mainWin, (Tcl_CmdDeleteProc *)NULL);
+#endif
+ return Qtrue;
+
+ } else {
+ ptr->allow_ruby_exit = 0;
+#if TCL_MAJOR_VERSION >= 8
+ DUMP1("Tcl_CreateObjCommand(\"exit\") --> \"interp_exit\"");
+ Tcl_CreateObjCommand(ptr->ip, "exit", ip_InterpExitObjCmd,
+ (ClientData)mainWin, (Tcl_CmdDeleteProc *)NULL);
+#else /* TCL_MAJOR_VERSION < 8 */
+ DUMP1("Tcl_CreateCommand(\"exit\") --> \"interp_exit\"");
+ Tcl_CreateCommand(ptr->ip, "exit", ip_InterpExitCommand,
+ (ClientData)mainWin, (Tcl_CmdDeleteProc *)NULL);
+#endif
+ return Qfalse;
+ }
+}
+
+/* delete interpreter */
+static VALUE
+ip_delete(self)
+ VALUE self;
+{
+ int thr_crit_bup;
+ struct tcltkip *ptr = get_ip(self);
+
+ /* if (ptr == (struct tcltkip *)NULL || ptr->ip == (Tcl_Interp*)NULL) { */
+ if (deleted_ip(ptr)) {
+ DUMP1("delete deleted IP");
+ return Qnil;
+ }
+
+ thr_crit_bup = rb_thread_critical;
+ rb_thread_critical = Qtrue;
+
+ DUMP1("delete interp");
+ if (!Tcl_InterpDeleted(ptr->ip)) {
+ DUMP1("call ip_finalize");
+ ip_finalize(ptr->ip);
+
+ Tcl_DeleteInterp(ptr->ip);
+ Tcl_Release(ptr->ip);
+ }
+
+ rb_thread_critical = thr_crit_bup;
+
+ return Qnil;
+}
+
+
+/* is deleted? */
+static VALUE
+ip_has_invalid_namespace_p(self)
+ VALUE self;
+{
+ struct tcltkip *ptr = get_ip(self);
+
+ if (ptr == (struct tcltkip *)NULL || ptr->ip == (Tcl_Interp *)NULL) {
+ /* deleted IP */
+ return Qtrue;
+ }
+
+#if TCL_NAMESPACE_DEBUG
+ if (rbtk_invalid_namespace(ptr)) {
+ return Qtrue;
+ } else {
+ return Qfalse;
+ }
+#else
+ return Qfalse;
+#endif
+}
+
+static VALUE
+ip_is_deleted_p(self)
+ VALUE self;
+{
+ struct tcltkip *ptr = get_ip(self);
+
+ if (deleted_ip(ptr)) {
+ return Qtrue;
+ } else {
+ return Qfalse;
+ }
+}
+
+static VALUE
+ip_has_mainwindow_p_core(self, argc, argv)
+ VALUE self;
+ int argc; /* dummy */
+ VALUE *argv; /* dummy */
+{
+ struct tcltkip *ptr = get_ip(self);
+
+ if (deleted_ip(ptr) || !tk_stubs_init_p()) {
+ return Qnil;
+ } else if (Tk_MainWindow(ptr->ip) == (Tk_Window)NULL) {
+ return Qfalse;
+ } else {
+ return Qtrue;
+ }
+}
+
+static VALUE
+ip_has_mainwindow_p(self)
+ VALUE self;
+{
+ return tk_funcall(ip_has_mainwindow_p_core, 0, (VALUE*)NULL, self);
+}
+
+
+/*** ruby string <=> tcl object ***/
+#if TCL_MAJOR_VERSION >= 8
+static VALUE
+get_str_from_obj(obj)
+ Tcl_Obj *obj;
+{
+ int len, binary = 0;
+ const char *s;
+ volatile VALUE str;
+
+#if TCL_MAJOR_VERSION == 8 && TCL_MINOR_VERSION == 0
+ s = Tcl_GetStringFromObj(obj, &len);
+#else
+#if TCL_MAJOR_VERSION == 8 && TCL_MINOR_VERSION <= 3
+ /* TCL_VERSION 8.1 -- 8.3 */
+ if (Tcl_GetCharLength(obj) != Tcl_UniCharLen(Tcl_GetUnicode(obj))) {
+ /* possibly binary string */
+ s = (char *)Tcl_GetByteArrayFromObj(obj, &len);
+ binary = 1;
+ } else {
+ /* possibly text string */
+ s = Tcl_GetStringFromObj(obj, &len);
+ }
+#else /* TCL_VERSION >= 8.4 */
+ if (IS_TCL_BYTEARRAY(obj)) {
+ s = (char *)Tcl_GetByteArrayFromObj(obj, &len);
+ binary = 1;
+ } else {
+ s = Tcl_GetStringFromObj(obj, &len);
+ }
+
+#endif
+#endif
+ str = s ? rb_str_new(s, len) : rb_str_new2("");
+ if (binary) {
+#ifdef HAVE_RUBY_ENCODING_H
+ rb_enc_associate_index(str, ENCODING_INDEX_BINARY);
+#endif
+ rb_ivar_set(str, ID_at_enc, ENCODING_NAME_BINARY);
+#if TCL_MAJOR_VERSION > 8 || (TCL_MAJOR_VERSION == 8 && TCL_MINOR_VERSION >= 1)
+ } else {
+#ifdef HAVE_RUBY_ENCODING_H
+ rb_enc_associate_index(str, ENCODING_INDEX_UTF8);
+#endif
+ rb_ivar_set(str, ID_at_enc, ENCODING_NAME_UTF8);
+#endif
+ }
+ return str;
+}
+
+static Tcl_Obj *
+get_obj_from_str(str)
+ VALUE str;
+{
+ const char *s = StringValuePtr(str);
+
+#if TCL_MAJOR_VERSION == 8 && TCL_MINOR_VERSION == 0
+ return Tcl_NewStringObj((char*)s, RSTRING_LEN(str));
+#else /* TCL_VERSION >= 8.1 */
+ VALUE enc = rb_attr_get(str, ID_at_enc);
+
+ if (!NIL_P(enc)) {
+ StringValue(enc);
+ if (strcmp(RSTRING_PTR(enc), "binary") == 0) {
+ /* binary string */
+ return Tcl_NewByteArrayObj((const unsigned char *)s, RSTRING_LENINT(str));
+ } else {
+ /* text string */
+ return Tcl_NewStringObj(s, RSTRING_LENINT(str));
+ }
+#ifdef HAVE_RUBY_ENCODING_H
+ } else if (rb_enc_get_index(str) == ENCODING_INDEX_BINARY) {
+ /* binary string */
+ return Tcl_NewByteArrayObj((const unsigned char *)s, RSTRING_LENINT(str));
+#endif
+ } else if (memchr(s, 0, RSTRING_LEN(str))) {
+ /* probably binary string */
+ return Tcl_NewByteArrayObj((const unsigned char *)s, RSTRING_LENINT(str));
+ } else {
+ /* probably text string */
+ return Tcl_NewStringObj(s, RSTRING_LENINT(str));
+ }
+#endif
+}
+#endif /* ruby string <=> tcl object */
+
+static VALUE
+ip_get_result_string_obj(interp)
+ Tcl_Interp *interp;
+{
+#if TCL_MAJOR_VERSION >= 8
+ Tcl_Obj *retObj;
+ volatile VALUE strval;
+
+ retObj = Tcl_GetObjResult(interp);
+ Tcl_IncrRefCount(retObj);
+ strval = get_str_from_obj(retObj);
+ RbTk_OBJ_UNTRUST(strval);
+ Tcl_ResetResult(interp);
+ Tcl_DecrRefCount(retObj);
+ return strval;
+#else
+ return rb_tainted_str_new2(interp->result);
+#endif
+}
+
+/* call Tcl/Tk functions on the eventloop thread */
+static VALUE
+callq_safelevel_handler(arg, callq)
+ VALUE arg;
+ VALUE callq;
+{
+ struct call_queue *q;
+
+ Data_Get_Struct(callq, struct call_queue, q);
+ DUMP2("(safe-level handler) $SAFE = %d", q->safe_level);
+ rb_set_safe_level(q->safe_level);
+ return((q->func)(q->interp, q->argc, q->argv));
+}
+
+static int call_queue_handler _((Tcl_Event *, int));
+static int
+call_queue_handler(evPtr, flags)
+ Tcl_Event *evPtr;
+ int flags;
+{
+ struct call_queue *q = (struct call_queue *)evPtr;
+ volatile VALUE ret;
+ volatile VALUE q_dat;
+ volatile VALUE thread = q->thread;
+ struct tcltkip *ptr;
+
+ DUMP2("do_call_queue_handler : evPtr = %p", evPtr);
+ DUMP2("call_queue_handler thread : %"PRIxVALUE, rb_thread_current());
+ DUMP2("added by thread : %"PRIxVALUE, thread);
+
+ if (*(q->done)) {
+ DUMP1("processed by another event-loop");
+ return 0;
+ } else {
+ DUMP1("process it on current event-loop");
+ }
+
+ if (RTEST(rb_thread_alive_p(thread))
+ && ! RTEST(rb_funcall(thread, ID_stop_p, 0))) {
+ DUMP1("caller is not yet ready to receive the result -> pending");
+ return 0;
+ }
+
+ /* process it */
+ *(q->done) = 1;
+
+ /* deleted ipterp ? */
+ ptr = get_ip(q->interp);
+ if (deleted_ip(ptr)) {
+ /* deleted IP --> ignore */
+ return 1;
+ }
+
+ /* incr internal handler mark */
+ rbtk_internal_eventloop_handler++;
+
+ /* check safe-level */
+ if (rb_safe_level() != q->safe_level) {
+ /* q_dat = Data_Wrap_Struct(rb_cData,0,-1,q); */
+ q_dat = Data_Wrap_Struct(0,call_queue_mark,-1,q);
+ ret = rb_funcall(rb_proc_new(callq_safelevel_handler, q_dat),
+ ID_call, 0);
+ rb_gc_force_recycle(q_dat);
+ q_dat = (VALUE)NULL;
+ } else {
+ DUMP2("call function (for caller thread:%"PRIxVALUE")", thread);
+ DUMP2("call function (current thread:%"PRIxVALUE")", rb_thread_current());
+ ret = (q->func)(q->interp, q->argc, q->argv);
+ }
+
+ /* set result */
+ RARRAY_PTR(q->result)[0] = ret;
+ ret = (VALUE)NULL;
+
+ /* decr internal handler mark */
+ rbtk_internal_eventloop_handler--;
+
+ /* complete */
+ *(q->done) = -1;
+
+ /* unlink ruby objects */
+ q->argv = (VALUE*)NULL;
+ q->interp = (VALUE)NULL;
+ q->result = (VALUE)NULL;
+ q->thread = (VALUE)NULL;
+
+ /* back to caller */
+ if (RTEST(rb_thread_alive_p(thread))) {
+ DUMP2("back to caller (caller thread:%"PRIxVALUE")", thread);
+ DUMP2(" (current thread:%"PRIxVALUE")", rb_thread_current());
+#if CONTROL_BY_STATUS_OF_RB_THREAD_WAITING_FOR_VALUE
+ have_rb_thread_waiting_for_value = 1;
+ rb_thread_wakeup(thread);
+#else
+ rb_thread_run(thread);
+#endif
+ DUMP1("finish back to caller");
+#if DO_THREAD_SCHEDULE_AT_CALLBACK_DONE
+ rb_thread_schedule();
+#endif
+ } else {
+ DUMP2("caller is dead (caller thread:%"PRIxVALUE")", thread);
+ DUMP2(" (current thread:%"PRIxVALUE")", rb_thread_current());
+ }
+
+ /* end of handler : remove it */
+ return 1;
+}
+
+static VALUE
+tk_funcall(func, argc, argv, obj)
+ VALUE (*func)();
+ int argc;
+ VALUE *argv;
+ VALUE obj;
+{
+ struct call_queue *callq;
+ struct tcltkip *ptr;
+ int *alloc_done;
+ int thr_crit_bup;
+ int is_tk_evloop_thread;
+ volatile VALUE current = rb_thread_current();
+ volatile VALUE ip_obj = obj;
+ volatile VALUE result;
+ volatile VALUE ret;
+ struct timeval t;
+
+ if (!NIL_P(ip_obj) && rb_obj_is_kind_of(ip_obj, tcltkip_class)) {
+ ptr = get_ip(ip_obj);
+ if (deleted_ip(ptr)) return Qnil;
+ } else {
+ ptr = (struct tcltkip *)NULL;
+ }
+
+#ifdef RUBY_USE_NATIVE_THREAD
+ if (ptr) {
+ /* on Tcl interpreter */
+ is_tk_evloop_thread = (ptr->tk_thread_id == (Tcl_ThreadId) 0
+ || ptr->tk_thread_id == Tcl_GetCurrentThread());
+ } else {
+ /* on Tcl/Tk library */
+ is_tk_evloop_thread = (tk_eventloop_thread_id == (Tcl_ThreadId) 0
+ || tk_eventloop_thread_id == Tcl_GetCurrentThread());
+ }
+#else
+ is_tk_evloop_thread = 1;
+#endif
+
+ if (is_tk_evloop_thread
+ && (NIL_P(eventloop_thread) || current == eventloop_thread)
+ ) {
+ if (NIL_P(eventloop_thread)) {
+ DUMP2("tk_funcall from thread:%"PRIxVALUE" but no eventloop", current);
+ } else {
+ DUMP2("tk_funcall from current eventloop %"PRIxVALUE, current);
+ }
+ result = (func)(ip_obj, argc, argv);
+ if (rb_obj_is_kind_of(result, rb_eException)) {
+ rb_exc_raise(result);
+ }
+ return result;
+ }
+
+ DUMP2("tk_funcall from thread %"PRIxVALUE" (NOT current eventloop)", current);
+
+ thr_crit_bup = rb_thread_critical;
+ rb_thread_critical = Qtrue;
+
+ /* allocate memory (argv cross over thread : must be in heap) */
+ if (argv) {
+ /* VALUE *temp = ALLOC_N(VALUE, argc); */
+ VALUE *temp = RbTk_ALLOC_N(VALUE, argc);
+#if 0 /* use Tcl_Preserve/Release */
+ Tcl_Preserve((ClientData)temp); /* XXXXXXXX */
+#endif
+ MEMCPY(temp, argv, VALUE, argc);
+ argv = temp;
+ }
+
+ /* allocate memory (keep result) */
+ /* alloc_done = (int*)ALLOC(int); */
+ alloc_done = RbTk_ALLOC_N(int, 1);
+#if 0 /* use Tcl_Preserve/Release */
+ Tcl_Preserve((ClientData)alloc_done); /* XXXXXXXX */
+#endif
+ *alloc_done = 0;
+
+ /* allocate memory (freed by Tcl_ServiceEvent) */
+ /* callq = (struct call_queue *)Tcl_Alloc(sizeof(struct call_queue)); */
+ callq = RbTk_ALLOC_N(struct call_queue, 1);
+#if 0 /* use Tcl_Preserve/Release */
+ Tcl_Preserve(callq);
+#endif
+
+ /* allocate result obj */
+ result = rb_ary_new3(1, Qnil);
+
+ /* construct event data */
+ callq->done = alloc_done;
+ callq->func = func;
+ callq->argc = argc;
+ callq->argv = argv;
+ callq->interp = ip_obj;
+ callq->result = result;
+ callq->thread = current;
+ callq->safe_level = rb_safe_level();
+ callq->ev.proc = call_queue_handler;
+
+ /* add the handler to Tcl event queue */
+ DUMP1("add handler");
+#ifdef RUBY_USE_NATIVE_THREAD
+ if (ptr && ptr->tk_thread_id) {
+ /* Tcl_ThreadQueueEvent(ptr->tk_thread_id,
+ &(callq->ev), TCL_QUEUE_HEAD); */
+ Tcl_ThreadQueueEvent(ptr->tk_thread_id,
+ (Tcl_Event*)callq, TCL_QUEUE_HEAD);
+ Tcl_ThreadAlert(ptr->tk_thread_id);
+ } else if (tk_eventloop_thread_id) {
+ /* Tcl_ThreadQueueEvent(tk_eventloop_thread_id,
+ &(callq->ev), TCL_QUEUE_HEAD); */
+ Tcl_ThreadQueueEvent(tk_eventloop_thread_id,
+ (Tcl_Event*)callq, TCL_QUEUE_HEAD);
+ Tcl_ThreadAlert(tk_eventloop_thread_id);
+ } else {
+ /* Tcl_QueueEvent(&(callq->ev), TCL_QUEUE_HEAD); */
+ Tcl_QueueEvent((Tcl_Event*)callq, TCL_QUEUE_HEAD);
+ }
+#else
+ /* Tcl_QueueEvent(&(callq->ev), TCL_QUEUE_HEAD); */
+ Tcl_QueueEvent((Tcl_Event*)callq, TCL_QUEUE_HEAD);
+#endif
+
+ rb_thread_critical = thr_crit_bup;
+
+ /* wait for the handler to be processed */
+ t.tv_sec = 0;
+ t.tv_usec = (long)((EVENT_HANDLER_TIMEOUT)*1000.0);
+
+ DUMP2("callq wait for handler (current thread:%"PRIxVALUE")", current);
+ while(*alloc_done >= 0) {
+ DUMP2("*** callq wait for handler (current thread:%"PRIxVALUE")", current);
+ /* rb_thread_stop(); */
+ /* rb_thread_sleep_forever(); */
+ rb_thread_wait_for(t);
+ DUMP2("*** callq wakeup (current thread:%"PRIxVALUE")", current);
+ DUMP2("*** (eventloop thread:%"PRIxVALUE")", eventloop_thread);
+ if (NIL_P(eventloop_thread)) {
+ DUMP1("*** callq lost eventloop thread");
+ break;
+ }
+ }
+ DUMP2("back from handler (current thread:%"PRIxVALUE")", current);
+
+ /* get result & free allocated memory */
+ ret = RARRAY_PTR(result)[0];
+#if 0 /* use Tcl_EventuallyFree */
+ Tcl_EventuallyFree((ClientData)alloc_done, TCL_DYNAMIC); /* XXXXXXXX */
+#else
+#if 0 /* use Tcl_Preserve/Release */
+ Tcl_Release((ClientData)alloc_done); /* XXXXXXXX */
+#else
+ /* free(alloc_done); */
+ ckfree((char*)alloc_done);
+#endif
+#endif
+ /* if (argv) free(argv); */
+ if (argv) {
+ /* if argv != NULL, alloc as 'temp' */
+ int i;
+ for(i = 0; i < argc; i++) { argv[i] = (VALUE)NULL; }
+
+#if 0 /* use Tcl_EventuallyFree */
+ Tcl_EventuallyFree((ClientData)argv, TCL_DYNAMIC); /* XXXXXXXX */
+#else
+#if 0 /* use Tcl_Preserve/Release */
+ Tcl_Release((ClientData)argv); /* XXXXXXXX */
+#else
+ ckfree((char*)argv);
+#endif
+#endif
+ }
+
+#if 0 /* callq is freed by Tcl_ServiceEvent */
+#if 0 /* use Tcl_Preserve/Release */
+ Tcl_Release(callq);
+#else
+ ckfree((char*)callq);
+#endif
+#endif
+
+ /* exception? */
+ if (rb_obj_is_kind_of(ret, rb_eException)) {
+ DUMP1("raise exception");
+ /* rb_exc_raise(ret); */
+ rb_exc_raise(rb_exc_new3(rb_obj_class(ret),
+ rb_funcall(ret, ID_to_s, 0, 0)));
+ }
+
+ DUMP1("exit tk_funcall");
+ return ret;
+}
+
+
+/* eval string in tcl by Tcl_Eval() */
+#if TCL_MAJOR_VERSION >= 8
+struct call_eval_info {
+ struct tcltkip *ptr;
+ Tcl_Obj *cmd;
+};
+
+static VALUE
+#ifdef HAVE_PROTOTYPES
+call_tcl_eval(VALUE arg)
+#else
+call_tcl_eval(arg)
+ VALUE arg;
+#endif
+{
+ struct call_eval_info *inf = (struct call_eval_info *)arg;
+
+ Tcl_AllowExceptions(inf->ptr->ip);
+ inf->ptr->return_value = Tcl_EvalObj(inf->ptr->ip, inf->cmd);
+
+ return Qnil;
+}
+#endif
+
+static VALUE
+ip_eval_real(self, cmd_str, cmd_len)
+ VALUE self;
+ char *cmd_str;
+ int cmd_len;
+{
+ volatile VALUE ret;
+ struct tcltkip *ptr = get_ip(self);
+ int thr_crit_bup;
+
+#if TCL_MAJOR_VERSION >= 8
+ /* call Tcl_EvalObj() */
+ {
+ Tcl_Obj *cmd;
+
+ thr_crit_bup = rb_thread_critical;
+ rb_thread_critical = Qtrue;
+
+ cmd = Tcl_NewStringObj(cmd_str, cmd_len);
+ Tcl_IncrRefCount(cmd);
+
+ /* ip is deleted? */
+ if (deleted_ip(ptr)) {
+ Tcl_DecrRefCount(cmd);
+ rb_thread_critical = thr_crit_bup;
+ ptr->return_value = TCL_OK;
+ return rb_tainted_str_new2("");
+ } else {
+ int status;
+ struct call_eval_info inf;
+
+ /* Tcl_Preserve(ptr->ip); */
+ rbtk_preserve_ip(ptr);
+
+#if 0
+ ptr->return_value = Tcl_EvalObj(ptr->ip, cmd);
+ /* ptr->return_value = Tcl_GlobalEvalObj(ptr->ip, cmd); */
+#else
+ inf.ptr = ptr;
+ inf.cmd = cmd;
+ ret = rb_protect(call_tcl_eval, (VALUE)&inf, &status);
+ switch(status) {
+ case TAG_RAISE:
+ if (NIL_P(rb_errinfo())) {
+ rbtk_pending_exception = rb_exc_new2(rb_eException,
+ "unknown exception");
+ } else {
+ rbtk_pending_exception = rb_errinfo();
+ }
+ break;
+
+ case TAG_FATAL:
+ if (NIL_P(rb_errinfo())) {
+ rbtk_pending_exception = rb_exc_new2(rb_eFatal, "FATAL");
+ } else {
+ rbtk_pending_exception = rb_errinfo();
+ }
+ }
+#endif
+ }
+
+ Tcl_DecrRefCount(cmd);
+
+ }
+
+ if (pending_exception_check1(thr_crit_bup, ptr)) {
+ rbtk_release_ip(ptr);
+ return rbtk_pending_exception;
+ }
+
+ /* if (ptr->return_value == TCL_ERROR) { */
+ if (ptr->return_value != TCL_OK) {
+ if (event_loop_abort_on_exc > 0 && !Tcl_InterpDeleted(ptr->ip)) {
+ volatile VALUE exc;
+
+ switch (ptr->return_value) {
+ case TCL_RETURN:
+ exc = create_ip_exc(self, eTkCallbackReturn,
+ "ip_eval_real receives TCL_RETURN");
+ case TCL_BREAK:
+ exc = create_ip_exc(self, eTkCallbackBreak,
+ "ip_eval_real receives TCL_BREAK");
+ case TCL_CONTINUE:
+ exc = create_ip_exc(self, eTkCallbackContinue,
+ "ip_eval_real receives TCL_CONTINUE");
+ default:
+ exc = create_ip_exc(self, rb_eRuntimeError, "%s",
+ Tcl_GetStringResult(ptr->ip));
+ }
+
+ rbtk_release_ip(ptr);
+ rb_thread_critical = thr_crit_bup;
+ return exc;
+ } else {
+ if (event_loop_abort_on_exc < 0) {
+ rb_warning("%s (ignore)", Tcl_GetStringResult(ptr->ip));
+ } else {
+ rb_warn("%s (ignore)", Tcl_GetStringResult(ptr->ip));
+ }
+ Tcl_ResetResult(ptr->ip);
+ rbtk_release_ip(ptr);
+ rb_thread_critical = thr_crit_bup;
+ return rb_tainted_str_new2("");
+ }
+ }
+
+ /* pass back the result (as string) */
+ ret = ip_get_result_string_obj(ptr->ip);
+ rbtk_release_ip(ptr);
+ rb_thread_critical = thr_crit_bup;
+ return ret;
+
+#else /* TCL_MAJOR_VERSION < 8 */
+ DUMP2("Tcl_Eval(%s)", cmd_str);
+
+ /* ip is deleted? */
+ if (deleted_ip(ptr)) {
+ ptr->return_value = TCL_OK;
+ return rb_tainted_str_new2("");
+ } else {
+ /* Tcl_Preserve(ptr->ip); */
+ rbtk_preserve_ip(ptr);
+ ptr->return_value = Tcl_Eval(ptr->ip, cmd_str);
+ /* ptr->return_value = Tcl_GlobalEval(ptr->ip, cmd_str); */
+ }
+
+ if (pending_exception_check1(thr_crit_bup, ptr)) {
+ rbtk_release_ip(ptr);
+ return rbtk_pending_exception;
+ }
+
+ /* if (ptr->return_value == TCL_ERROR) { */
+ if (ptr->return_value != TCL_OK) {
+ volatile VALUE exc;
+
+ switch (ptr->return_value) {
+ case TCL_RETURN:
+ exc = create_ip_exc(self, eTkCallbackReturn,
+ "ip_eval_real receives TCL_RETURN");
+ case TCL_BREAK:
+ exc = create_ip_exc(self, eTkCallbackBreak,
+ "ip_eval_real receives TCL_BREAK");
+ case TCL_CONTINUE:
+ exc = create_ip_exc(self, eTkCallbackContinue,
+ "ip_eval_real receives TCL_CONTINUE");
+ default:
+ exc = create_ip_exc(self, rb_eRuntimeError, "%s", ptr->ip->result);
+ }
+
+ rbtk_release_ip(ptr);
+ return exc;
+ }
+ DUMP2("(TCL_Eval result) %d", ptr->return_value);
+
+ /* pass back the result (as string) */
+ ret = ip_get_result_string_obj(ptr->ip);
+ rbtk_release_ip(ptr);
+ return ret;
+#endif
+}
+
+static VALUE
+evq_safelevel_handler(arg, evq)
+ VALUE arg;
+ VALUE evq;
+{
+ struct eval_queue *q;
+
+ Data_Get_Struct(evq, struct eval_queue, q);
+ DUMP2("(safe-level handler) $SAFE = %d", q->safe_level);
+ rb_set_safe_level(q->safe_level);
+ return ip_eval_real(q->interp, q->str, q->len);
+}
+
+int eval_queue_handler _((Tcl_Event *, int));
+int
+eval_queue_handler(evPtr, flags)
+ Tcl_Event *evPtr;
+ int flags;
+{
+ struct eval_queue *q = (struct eval_queue *)evPtr;
+ volatile VALUE ret;
+ volatile VALUE q_dat;
+ volatile VALUE thread = q->thread;
+ struct tcltkip *ptr;
+
+ DUMP2("do_eval_queue_handler : evPtr = %p", evPtr);
+ DUMP2("eval_queue_thread : %"PRIxVALUE, rb_thread_current());
+ DUMP2("added by thread : %"PRIxVALUE, thread);
+
+ if (*(q->done)) {
+ DUMP1("processed by another event-loop");
+ return 0;
+ } else {
+ DUMP1("process it on current event-loop");
+ }
+
+ if (RTEST(rb_thread_alive_p(thread))
+ && ! RTEST(rb_funcall(thread, ID_stop_p, 0))) {
+ DUMP1("caller is not yet ready to receive the result -> pending");
+ return 0;
+ }
+
+ /* process it */
+ *(q->done) = 1;
+
+ /* deleted ipterp ? */
+ ptr = get_ip(q->interp);
+ if (deleted_ip(ptr)) {
+ /* deleted IP --> ignore */
+ return 1;
+ }
+
+ /* incr internal handler mark */
+ rbtk_internal_eventloop_handler++;
+
+ /* check safe-level */
+ if (rb_safe_level() != q->safe_level) {
+#ifdef HAVE_NATIVETHREAD
+#ifndef RUBY_USE_NATIVE_THREAD
+ if (!ruby_native_thread_p()) {
+ rb_bug("cross-thread violation on eval_queue_handler()");
+ }
+#endif
+#endif
+ /* q_dat = Data_Wrap_Struct(rb_cData,0,-1,q); */
+ q_dat = Data_Wrap_Struct(0,eval_queue_mark,-1,q);
+ ret = rb_funcall(rb_proc_new(evq_safelevel_handler, q_dat),
+ ID_call, 0);
+ rb_gc_force_recycle(q_dat);
+ q_dat = (VALUE)NULL;
+ } else {
+ ret = ip_eval_real(q->interp, q->str, q->len);
+ }
+
+ /* set result */
+ RARRAY_PTR(q->result)[0] = ret;
+ ret = (VALUE)NULL;
+
+ /* decr internal handler mark */
+ rbtk_internal_eventloop_handler--;
+
+ /* complete */
+ *(q->done) = -1;
+
+ /* unlink ruby objects */
+ q->interp = (VALUE)NULL;
+ q->result = (VALUE)NULL;
+ q->thread = (VALUE)NULL;
+
+ /* back to caller */
+ if (RTEST(rb_thread_alive_p(thread))) {
+ DUMP2("back to caller (caller thread:%"PRIxVALUE")", thread);
+ DUMP2(" (current thread:%"PRIxVALUE")", rb_thread_current());
+#if CONTROL_BY_STATUS_OF_RB_THREAD_WAITING_FOR_VALUE
+ have_rb_thread_waiting_for_value = 1;
+ rb_thread_wakeup(thread);
+#else
+ rb_thread_run(thread);
+#endif
+ DUMP1("finish back to caller");
+#if DO_THREAD_SCHEDULE_AT_CALLBACK_DONE
+ rb_thread_schedule();
+#endif
+ } else {
+ DUMP2("caller is dead (caller thread:%"PRIxVALUE")", thread);
+ DUMP2(" (current thread:%"PRIxVALUE")", rb_thread_current());
+ }
+
+ /* end of handler : remove it */
+ return 1;
+}
+
+static VALUE
+ip_eval(self, str)
+ VALUE self;
+ VALUE str;
+{
+ struct eval_queue *evq;
+#ifdef RUBY_USE_NATIVE_THREAD
+ struct tcltkip *ptr;
+#endif
+ char *eval_str;
+ int *alloc_done;
+ int thr_crit_bup;
+ volatile VALUE current = rb_thread_current();
+ volatile VALUE ip_obj = self;
+ volatile VALUE result;
+ volatile VALUE ret;
+ Tcl_QueuePosition position;
+ struct timeval t;
+
+ thr_crit_bup = rb_thread_critical;
+ rb_thread_critical = Qtrue;
+ StringValue(str);
+ rb_thread_critical = thr_crit_bup;
+
+#ifdef RUBY_USE_NATIVE_THREAD
+ ptr = get_ip(ip_obj);
+ DUMP2("eval status: ptr->tk_thread_id %p", ptr->tk_thread_id);
+ DUMP2("eval status: Tcl_GetCurrentThread %p", Tcl_GetCurrentThread());
+#else
+ DUMP2("status: Tcl_GetCurrentThread %p", Tcl_GetCurrentThread());
+#endif
+ DUMP2("status: eventloopt_thread %"PRIxVALUE, eventloop_thread);
+
+ if (
+#ifdef RUBY_USE_NATIVE_THREAD
+ (ptr->tk_thread_id == 0 || ptr->tk_thread_id == Tcl_GetCurrentThread())
+ &&
+#endif
+ (NIL_P(eventloop_thread) || current == eventloop_thread)
+ ) {
+ if (NIL_P(eventloop_thread)) {
+ DUMP2("eval from thread:%"PRIxVALUE" but no eventloop", current);
+ } else {
+ DUMP2("eval from current eventloop %"PRIxVALUE, current);
+ }
+ result = ip_eval_real(self, RSTRING_PTR(str), RSTRING_LENINT(str));
+ if (rb_obj_is_kind_of(result, rb_eException)) {
+ rb_exc_raise(result);
+ }
+ return result;
+ }
+
+ DUMP2("eval from thread %"PRIxVALUE" (NOT current eventloop)", current);
+
+ thr_crit_bup = rb_thread_critical;
+ rb_thread_critical = Qtrue;
+
+ /* allocate memory (keep result) */
+ /* alloc_done = (int*)ALLOC(int); */
+ alloc_done = RbTk_ALLOC_N(int, 1);
+#if 0 /* use Tcl_Preserve/Release */
+ Tcl_Preserve((ClientData)alloc_done); /* XXXXXXXX */
+#endif
+ *alloc_done = 0;
+
+ /* eval_str = ALLOC_N(char, RSTRING_LEN(str) + 1); */
+ eval_str = ckalloc(RSTRING_LENINT(str) + 1);
+#if 0 /* use Tcl_Preserve/Release */
+ Tcl_Preserve((ClientData)eval_str); /* XXXXXXXX */
+#endif
+ memcpy(eval_str, RSTRING_PTR(str), RSTRING_LEN(str));
+ eval_str[RSTRING_LEN(str)] = 0;
+
+ /* allocate memory (freed by Tcl_ServiceEvent) */
+ /* evq = (struct eval_queue *)Tcl_Alloc(sizeof(struct eval_queue)); */
+ evq = RbTk_ALLOC_N(struct eval_queue, 1);
+#if 0 /* use Tcl_Preserve/Release */
+ Tcl_Preserve(evq);
+#endif
+
+ /* allocate result obj */
+ result = rb_ary_new3(1, Qnil);
+
+ /* construct event data */
+ evq->done = alloc_done;
+ evq->str = eval_str;
+ evq->len = RSTRING_LENINT(str);
+ evq->interp = ip_obj;
+ evq->result = result;
+ evq->thread = current;
+ evq->safe_level = rb_safe_level();
+ evq->ev.proc = eval_queue_handler;
+
+ position = TCL_QUEUE_TAIL;
+
+ /* add the handler to Tcl event queue */
+ DUMP1("add handler");
+#ifdef RUBY_USE_NATIVE_THREAD
+ if (ptr->tk_thread_id) {
+ /* Tcl_ThreadQueueEvent(ptr->tk_thread_id, &(evq->ev), position); */
+ Tcl_ThreadQueueEvent(ptr->tk_thread_id, (Tcl_Event*)evq, position);
+ Tcl_ThreadAlert(ptr->tk_thread_id);
+ } else if (tk_eventloop_thread_id) {
+ Tcl_ThreadQueueEvent(tk_eventloop_thread_id, (Tcl_Event*)evq, position);
+ /* Tcl_ThreadQueueEvent(tk_eventloop_thread_id,
+ &(evq->ev), position); */
+ Tcl_ThreadAlert(tk_eventloop_thread_id);
+ } else {
+ /* Tcl_QueueEvent(&(evq->ev), position); */
+ Tcl_QueueEvent((Tcl_Event*)evq, position);
+ }
+#else
+ /* Tcl_QueueEvent(&(evq->ev), position); */
+ Tcl_QueueEvent((Tcl_Event*)evq, position);
+#endif
+
+ rb_thread_critical = thr_crit_bup;
+
+ /* wait for the handler to be processed */
+ t.tv_sec = 0;
+ t.tv_usec = (long)((EVENT_HANDLER_TIMEOUT)*1000.0);
+
+ DUMP2("evq wait for handler (current thread:%"PRIxVALUE")", current);
+ while(*alloc_done >= 0) {
+ DUMP2("*** evq wait for handler (current thread:%"PRIxVALUE")", current);
+ /* rb_thread_stop(); */
+ /* rb_thread_sleep_forever(); */
+ rb_thread_wait_for(t);
+ DUMP2("*** evq wakeup (current thread:%"PRIxVALUE")", current);
+ DUMP2("*** (eventloop thread:%"PRIxVALUE")", eventloop_thread);
+ if (NIL_P(eventloop_thread)) {
+ DUMP1("*** evq lost eventloop thread");
+ break;
+ }
+ }
+ DUMP2("back from handler (current thread:%"PRIxVALUE")", current);
+
+ /* get result & free allocated memory */
+ ret = RARRAY_PTR(result)[0];
+
+#if 0 /* use Tcl_EventuallyFree */
+ Tcl_EventuallyFree((ClientData)alloc_done, TCL_DYNAMIC); /* XXXXXXXX */
+#else
+#if 0 /* use Tcl_Preserve/Release */
+ Tcl_Release((ClientData)alloc_done); /* XXXXXXXX */
+#else
+ /* free(alloc_done); */
+ ckfree((char*)alloc_done);
+#endif
+#endif
+#if 0 /* use Tcl_EventuallyFree */
+ Tcl_EventuallyFree((ClientData)eval_str, TCL_DYNAMIC); /* XXXXXXXX */
+#else
+#if 0 /* use Tcl_Preserve/Release */
+ Tcl_Release((ClientData)eval_str); /* XXXXXXXX */
+#else
+ /* free(eval_str); */
+ ckfree(eval_str);
+#endif
+#endif
+#if 0 /* evq is freed by Tcl_ServiceEvent */
+#if 0 /* use Tcl_Preserve/Release */
+ Tcl_Release(evq);
+#else
+ ckfree((char*)evq);
+#endif
+#endif
+
+ if (rb_obj_is_kind_of(ret, rb_eException)) {
+ DUMP1("raise exception");
+ /* rb_exc_raise(ret); */
+ rb_exc_raise(rb_exc_new3(rb_obj_class(ret),
+ rb_funcall(ret, ID_to_s, 0, 0)));
+ }
+
+ return ret;
+}
+
+
+static int
+ip_cancel_eval_core(interp, msg, flag)
+ Tcl_Interp *interp;
+ VALUE msg;
+ int flag;
+{
+#if TCL_MAJOR_VERSION < 8 || (TCL_MAJOR_VERSION == 8 && TCL_MINOR_VERSION < 6)
+ rb_raise(rb_eNotImpError,
+ "cancel_eval is supported Tcl/Tk8.6 or later.");
+
+ UNREACHABLE;
+#else
+ Tcl_Obj *msg_obj;
+
+ if (NIL_P(msg)) {
+ msg_obj = NULL;
+ } else {
+ msg_obj = Tcl_NewStringObj(RSTRING_PTR(msg), RSTRING_LEN(msg));
+ Tcl_IncrRefCount(msg_obj);
+ }
+
+ return Tcl_CancelEval(interp, msg_obj, 0, flag);
+#endif
+}
+
+static VALUE
+ip_cancel_eval(argc, argv, self)
+ int argc;
+ VALUE *argv;
+ VALUE self;
+{
+ VALUE retval;
+
+ if (rb_scan_args(argc, argv, "01", &retval) == 0) {
+ retval = Qnil;
+ }
+ if (ip_cancel_eval_core(get_ip(self)->ip, retval, 0) == TCL_OK) {
+ return Qtrue;
+ } else {
+ return Qfalse;
+ }
+}
+
+#ifndef TCL_CANCEL_UNWIND
+#define TCL_CANCEL_UNWIND 0x100000
+#endif
+static VALUE
+ip_cancel_eval_unwind(argc, argv, self)
+ int argc;
+ VALUE *argv;
+ VALUE self;
+{
+ int flag = 0;
+ VALUE retval;
+
+ if (rb_scan_args(argc, argv, "01", &retval) == 0) {
+ retval = Qnil;
+ }
+
+ flag |= TCL_CANCEL_UNWIND;
+ if (ip_cancel_eval_core(get_ip(self)->ip, retval, flag) == TCL_OK) {
+ return Qtrue;
+ } else {
+ return Qfalse;
+ }
+}
+
+/* restart Tk */
+static VALUE
+lib_restart_core(interp, argc, argv)
+ VALUE interp;
+ int argc; /* dummy */
+ VALUE *argv; /* dummy */
+{
+ volatile VALUE exc;
+ struct tcltkip *ptr = get_ip(interp);
+ int thr_crit_bup;
+
+
+ /* tcl_stubs_check(); */ /* already checked */
+
+ /* ip is deleted? */
+ if (deleted_ip(ptr)) {
+ return rb_exc_new2(rb_eRuntimeError, "interpreter is deleted");
+ }
+
+ thr_crit_bup = rb_thread_critical;
+ rb_thread_critical = Qtrue;
+
+ /* Tcl_Preserve(ptr->ip); */
+ rbtk_preserve_ip(ptr);
+
+ /* destroy the root wdiget */
+ ptr->return_value = Tcl_Eval(ptr->ip, "destroy .");
+ /* ignore ERROR */
+ DUMP2("(TCL_Eval result) %d", ptr->return_value);
+ Tcl_ResetResult(ptr->ip);
+
+#if TCL_MAJOR_VERSION >= 8
+ /* delete namespace ( tested on tk8.4.5 ) */
+ ptr->return_value = Tcl_Eval(ptr->ip, "namespace delete ::tk::msgcat");
+ /* ignore ERROR */
+ DUMP2("(TCL_Eval result) %d", ptr->return_value);
+ Tcl_ResetResult(ptr->ip);
+#endif
+
+ /* delete trace proc ( tested on tk8.4.5 ) */
+ ptr->return_value = Tcl_Eval(ptr->ip, "trace vdelete ::tk_strictMotif w ::tk::EventMotifBindings");
+ /* ignore ERROR */
+ DUMP2("(TCL_Eval result) %d", ptr->return_value);
+ Tcl_ResetResult(ptr->ip);
+
+ /* execute Tk_Init or Tk_SafeInit */
+ exc = tcltkip_init_tk(interp);
+ if (!NIL_P(exc)) {
+ rb_thread_critical = thr_crit_bup;
+ rbtk_release_ip(ptr);
+ return exc;
+ }
+
+ /* Tcl_Release(ptr->ip); */
+ rbtk_release_ip(ptr);
+
+ rb_thread_critical = thr_crit_bup;
+
+ /* return Qnil; */
+ return interp;
+}
+
+static VALUE
+lib_restart(self)
+ VALUE self;
+{
+ struct tcltkip *ptr = get_ip(self);
+
+
+ tcl_stubs_check();
+
+ /* ip is deleted? */
+ if (deleted_ip(ptr)) {
+ rb_raise(rb_eRuntimeError, "interpreter is deleted");
+ }
+
+ return tk_funcall(lib_restart_core, 0, (VALUE*)NULL, self);
+}
+
+
+static VALUE
+ip_restart(self)
+ VALUE self;
+{
+ struct tcltkip *ptr = get_ip(self);
+
+
+ tcl_stubs_check();
+
+ /* ip is deleted? */
+ if (deleted_ip(ptr)) {
+ rb_raise(rb_eRuntimeError, "interpreter is deleted");
+ }
+
+ if (Tcl_GetMaster(ptr->ip) != (Tcl_Interp*)NULL) {
+ /* slave IP */
+ return Qnil;
+ }
+ return lib_restart(self);
+}
+
+static VALUE
+lib_toUTF8_core(ip_obj, src, encodename)
+ VALUE ip_obj;
+ VALUE src;
+ VALUE encodename;
+{
+ volatile VALUE str = src;
+
+#ifdef TCL_UTF_MAX
+# if 0
+ Tcl_Interp *interp;
+# endif
+ Tcl_Encoding encoding;
+ Tcl_DString dstr;
+ int taint_flag = OBJ_TAINTED(str);
+ struct tcltkip *ptr;
+ char *buf;
+ int thr_crit_bup;
+#endif
+
+ tcl_stubs_check();
+
+ if (NIL_P(src)) {
+ return rb_str_new2("");
+ }
+
+#ifdef TCL_UTF_MAX
+ if (NIL_P(ip_obj)) {
+# if 0
+ interp = (Tcl_Interp *)NULL;
+# endif
+ } else {
+ ptr = get_ip(ip_obj);
+
+ /* ip is deleted? */
+ if (deleted_ip(ptr)) {
+# if 0
+ interp = (Tcl_Interp *)NULL;
+ } else {
+ interp = ptr->ip;
+# endif
+ }
+ }
+
+ thr_crit_bup = rb_thread_critical;
+ rb_thread_critical = Qtrue;
+
+ if (NIL_P(encodename)) {
+ if (RB_TYPE_P(str, T_STRING)) {
+ volatile VALUE enc;
+
+#ifdef HAVE_RUBY_ENCODING_H
+ enc = rb_funcall(rb_obj_encoding(str), ID_to_s, 0, 0);
+#else
+ enc = rb_attr_get(str, ID_at_enc);
+#endif
+ if (NIL_P(enc)) {
+ if (NIL_P(ip_obj)) {
+ encoding = (Tcl_Encoding)NULL;
+ } else {
+ enc = rb_attr_get(ip_obj, ID_at_enc);
+ if (NIL_P(enc)) {
+ encoding = (Tcl_Encoding)NULL;
+ } else {
+ /* StringValue(enc); */
+ enc = rb_funcall(enc, ID_to_s, 0, 0);
+ /* encoding = Tcl_GetEncoding(interp, RSTRING_PTR(enc)); */
+ if (!RSTRING_LEN(enc)) {
+ encoding = (Tcl_Encoding)NULL;
+ } else {
+ encoding = Tcl_GetEncoding((Tcl_Interp*)NULL,
+ RSTRING_PTR(enc));
+ if (encoding == (Tcl_Encoding)NULL) {
+ rb_warning("Tk-interp has unknown encoding information (@encoding:'%s')", RSTRING_PTR(enc));
+ }
+ }
+ }
+ }
+ } else {
+ StringValue(enc);
+ if (strcmp(RSTRING_PTR(enc), "binary") == 0) {
+#ifdef HAVE_RUBY_ENCODING_H
+ rb_enc_associate_index(str, ENCODING_INDEX_BINARY);
+#endif
+ rb_ivar_set(str, ID_at_enc, ENCODING_NAME_BINARY);
+ rb_thread_critical = thr_crit_bup;
+ return str;
+ }
+ /* encoding = Tcl_GetEncoding(interp, RSTRING_PTR(enc)); */
+ encoding = Tcl_GetEncoding((Tcl_Interp*)NULL,
+ RSTRING_PTR(enc));
+ if (encoding == (Tcl_Encoding)NULL) {
+ rb_warning("string has unknown encoding information (@encoding:'%s')", RSTRING_PTR(enc));
+ }
+ }
+ } else {
+ encoding = (Tcl_Encoding)NULL;
+ }
+ } else {
+ StringValue(encodename);
+ if (strcmp(RSTRING_PTR(encodename), "binary") == 0) {
+#ifdef HAVE_RUBY_ENCODING_H
+ rb_enc_associate_index(str, ENCODING_INDEX_BINARY);
+#endif
+ rb_ivar_set(str, ID_at_enc, ENCODING_NAME_BINARY);
+ rb_thread_critical = thr_crit_bup;
+ return str;
+ }
+ /* encoding = Tcl_GetEncoding(interp, RSTRING_PTR(encodename)); */
+ encoding = Tcl_GetEncoding((Tcl_Interp*)NULL, RSTRING_PTR(encodename));
+ if (encoding == (Tcl_Encoding)NULL) {
+ /*
+ rb_warning("unknown encoding name '%s'",
+ RSTRING_PTR(encodename));
+ */
+ rb_raise(rb_eArgError, "unknown encoding name '%s'",
+ RSTRING_PTR(encodename));
+ }
+ }
+
+ StringValue(str);
+ if (!RSTRING_LEN(str)) {
+ rb_thread_critical = thr_crit_bup;
+ return str;
+ }
+ buf = ALLOC_N(char, RSTRING_LEN(str)+1);
+ /* buf = ckalloc(sizeof(char) * (RSTRING_LENINT(str)+1)); */
+ memcpy(buf, RSTRING_PTR(str), RSTRING_LEN(str));
+ buf[RSTRING_LEN(str)] = 0;
+
+ Tcl_DStringInit(&dstr);
+ Tcl_DStringFree(&dstr);
+ /* Tcl_ExternalToUtfDString(encoding,buf,strlen(buf),&dstr); */
+ Tcl_ExternalToUtfDString(encoding, buf, RSTRING_LENINT(str), &dstr);
+
+ /* str = rb_tainted_str_new2(Tcl_DStringValue(&dstr)); */
+ /* str = rb_str_new2(Tcl_DStringValue(&dstr)); */
+ str = rb_str_new(Tcl_DStringValue(&dstr), Tcl_DStringLength(&dstr));
+#ifdef HAVE_RUBY_ENCODING_H
+ rb_enc_associate_index(str, ENCODING_INDEX_UTF8);
+#endif
+ if (taint_flag) RbTk_OBJ_UNTRUST(str);
+ rb_ivar_set(str, ID_at_enc, ENCODING_NAME_UTF8);
+
+ /*
+ if (encoding != (Tcl_Encoding)NULL) {
+ Tcl_FreeEncoding(encoding);
+ }
+ */
+ Tcl_DStringFree(&dstr);
+
+ xfree(buf);
+ /* ckfree(buf); */
+
+ rb_thread_critical = thr_crit_bup;
+#endif
+
+ return str;
+}
+
+static VALUE
+lib_toUTF8(argc, argv, self)
+ int argc;
+ VALUE *argv;
+ VALUE self;
+{
+ VALUE str, encodename;
+
+ if (rb_scan_args(argc, argv, "11", &str, &encodename) == 1) {
+ encodename = Qnil;
+ }
+ return lib_toUTF8_core(Qnil, str, encodename);
+}
+
+static VALUE
+ip_toUTF8(argc, argv, self)
+ int argc;
+ VALUE *argv;
+ VALUE self;
+{
+ VALUE str, encodename;
+
+ if (rb_scan_args(argc, argv, "11", &str, &encodename) == 1) {
+ encodename = Qnil;
+ }
+ return lib_toUTF8_core(self, str, encodename);
+}
+
+static VALUE
+lib_fromUTF8_core(ip_obj, src, encodename)
+ VALUE ip_obj;
+ VALUE src;
+ VALUE encodename;
+{
+ volatile VALUE str = src;
+
+#ifdef TCL_UTF_MAX
+ Tcl_Interp *interp;
+ Tcl_Encoding encoding;
+ Tcl_DString dstr;
+ int taint_flag = OBJ_TAINTED(str);
+ char *buf;
+ int thr_crit_bup;
+#endif
+
+ tcl_stubs_check();
+
+ if (NIL_P(src)) {
+ return rb_str_new2("");
+ }
+
+#ifdef TCL_UTF_MAX
+ if (NIL_P(ip_obj)) {
+ interp = (Tcl_Interp *)NULL;
+ } else if (get_ip(ip_obj) == (struct tcltkip *)NULL) {
+ interp = (Tcl_Interp *)NULL;
+ } else {
+ interp = get_ip(ip_obj)->ip;
+ }
+
+ thr_crit_bup = rb_thread_critical;
+ rb_thread_critical = Qtrue;
+
+ if (NIL_P(encodename)) {
+ volatile VALUE enc;
+
+ if (RB_TYPE_P(str, T_STRING)) {
+ enc = rb_attr_get(str, ID_at_enc);
+ if (!NIL_P(enc)) {
+ StringValue(enc);
+ if (strcmp(RSTRING_PTR(enc), "binary") == 0) {
+#ifdef HAVE_RUBY_ENCODING_H
+ rb_enc_associate_index(str, ENCODING_INDEX_BINARY);
+#endif
+ rb_ivar_set(str, ID_at_enc, ENCODING_NAME_BINARY);
+ rb_thread_critical = thr_crit_bup;
+ return str;
+ }
+#ifdef HAVE_RUBY_ENCODING_H
+ } else if (rb_enc_get_index(str) == ENCODING_INDEX_BINARY) {
+ rb_enc_associate_index(str, ENCODING_INDEX_BINARY);
+ rb_ivar_set(str, ID_at_enc, ENCODING_NAME_BINARY);
+ rb_thread_critical = thr_crit_bup;
+ return str;
+#endif
+ }
+ }
+
+ if (NIL_P(ip_obj)) {
+ encoding = (Tcl_Encoding)NULL;
+ } else {
+ enc = rb_attr_get(ip_obj, ID_at_enc);
+ if (NIL_P(enc)) {
+ encoding = (Tcl_Encoding)NULL;
+ } else {
+ /* StringValue(enc); */
+ enc = rb_funcall(enc, ID_to_s, 0, 0);
+ /* encoding = Tcl_GetEncoding(interp, RSTRING_PTR(enc)); */
+ if (!RSTRING_LEN(enc)) {
+ encoding = (Tcl_Encoding)NULL;
+ } else {
+ encoding = Tcl_GetEncoding((Tcl_Interp*)NULL,
+ RSTRING_PTR(enc));
+ if (encoding == (Tcl_Encoding)NULL) {
+ rb_warning("Tk-interp has unknown encoding information (@encoding:'%s')", RSTRING_PTR(enc));
+ } else {
+ encodename = rb_obj_dup(enc);
+ }
+ }
+ }
+ }
+
+ } else {
+ StringValue(encodename);
+
+ if (strcmp(RSTRING_PTR(encodename), "binary") == 0) {
+ Tcl_Obj *tclstr;
+ char *s;
+ int len;
+
+ StringValue(str);
+ tclstr = Tcl_NewStringObj(RSTRING_PTR(str), RSTRING_LENINT(str));
+ Tcl_IncrRefCount(tclstr);
+ s = (char*)Tcl_GetByteArrayFromObj(tclstr, &len);
+ str = rb_tainted_str_new(s, len);
+ s = (char*)NULL;
+ Tcl_DecrRefCount(tclstr);
+#ifdef HAVE_RUBY_ENCODING_H
+ rb_enc_associate_index(str, ENCODING_INDEX_BINARY);
+#endif
+ rb_ivar_set(str, ID_at_enc, ENCODING_NAME_BINARY);
+
+ rb_thread_critical = thr_crit_bup;
+ return str;
+ }
+
+ /* encoding = Tcl_GetEncoding(interp, RSTRING_PTR(encodename)); */
+ encoding = Tcl_GetEncoding((Tcl_Interp*)NULL, RSTRING_PTR(encodename));
+ if (encoding == (Tcl_Encoding)NULL) {
+ /*
+ rb_warning("unknown encoding name '%s'",
+ RSTRING_PTR(encodename));
+ encodename = Qnil;
+ */
+ rb_raise(rb_eArgError, "unknown encoding name '%s'",
+ RSTRING_PTR(encodename));
+ }
+ }
+
+ StringValue(str);
+
+ if (RSTRING_LEN(str) == 0) {
+ rb_thread_critical = thr_crit_bup;
+ return rb_tainted_str_new2("");
+ }
+
+ buf = ALLOC_N(char, RSTRING_LEN(str)+1);
+ /* buf = ckalloc(sizeof(char) * (RSTRING_LENINT(str)+1)); */
+ memcpy(buf, RSTRING_PTR(str), RSTRING_LEN(str));
+ buf[RSTRING_LEN(str)] = 0;
+
+ Tcl_DStringInit(&dstr);
+ Tcl_DStringFree(&dstr);
+ /* Tcl_UtfToExternalDString(encoding,buf,strlen(buf),&dstr); */
+ Tcl_UtfToExternalDString(encoding,buf,RSTRING_LENINT(str),&dstr);
+
+ /* str = rb_tainted_str_new2(Tcl_DStringValue(&dstr)); */
+ /* str = rb_str_new2(Tcl_DStringValue(&dstr)); */
+ str = rb_str_new(Tcl_DStringValue(&dstr), Tcl_DStringLength(&dstr));
+#ifdef HAVE_RUBY_ENCODING_H
+ if (interp) {
+ /* can access encoding_table of TclTkIp */
+ /* -> try to use encoding_table */
+ VALUE tbl = ip_get_encoding_table(ip_obj);
+ VALUE encobj = encoding_table_get_obj(tbl, encodename);
+ rb_enc_associate_index(str, rb_to_encoding_index(encobj));
+ } else {
+ /* cannot access encoding_table of TclTkIp */
+ /* -> try to find on Ruby Encoding */
+ rb_enc_associate_index(str, rb_enc_find_index(RSTRING_PTR(encodename)));
+ }
+#endif
+
+ if (taint_flag) RbTk_OBJ_UNTRUST(str);
+ rb_ivar_set(str, ID_at_enc, encodename);
+
+ /*
+ if (encoding != (Tcl_Encoding)NULL) {
+ Tcl_FreeEncoding(encoding);
+ }
+ */
+ Tcl_DStringFree(&dstr);
+
+ xfree(buf);
+ /* ckfree(buf); */
+
+ rb_thread_critical = thr_crit_bup;
+#endif
+
+ return str;
+}
+
+static VALUE
+lib_fromUTF8(argc, argv, self)
+ int argc;
+ VALUE *argv;
+ VALUE self;
+{
+ VALUE str, encodename;
+
+ if (rb_scan_args(argc, argv, "11", &str, &encodename) == 1) {
+ encodename = Qnil;
+ }
+ return lib_fromUTF8_core(Qnil, str, encodename);
+}
+
+static VALUE
+ip_fromUTF8(argc, argv, self)
+ int argc;
+ VALUE *argv;
+ VALUE self;
+{
+ VALUE str, encodename;
+
+ if (rb_scan_args(argc, argv, "11", &str, &encodename) == 1) {
+ encodename = Qnil;
+ }
+ return lib_fromUTF8_core(self, str, encodename);
+}
+
+static VALUE
+lib_UTF_backslash_core(self, str, all_bs)
+ VALUE self;
+ VALUE str;
+ int all_bs;
+{
+#ifdef TCL_UTF_MAX
+ char *src_buf, *dst_buf, *ptr;
+ int read_len = 0, dst_len = 0;
+ int taint_flag = OBJ_TAINTED(str);
+ int thr_crit_bup;
+
+ tcl_stubs_check();
+
+ StringValue(str);
+ if (!RSTRING_LEN(str)) {
+ return str;
+ }
+
+ thr_crit_bup = rb_thread_critical;
+ rb_thread_critical = Qtrue;
+
+ /* src_buf = ALLOC_N(char, RSTRING_LEN(str)+1); */
+ src_buf = ckalloc(RSTRING_LENINT(str)+1);
+#if 0 /* use Tcl_Preserve/Release */
+ Tcl_Preserve((ClientData)src_buf); /* XXXXXXXX */
+#endif
+ memcpy(src_buf, RSTRING_PTR(str), RSTRING_LEN(str));
+ src_buf[RSTRING_LEN(str)] = 0;
+
+ /* dst_buf = ALLOC_N(char, RSTRING_LEN(str)+1); */
+ dst_buf = ckalloc(RSTRING_LENINT(str)+1);
+#if 0 /* use Tcl_Preserve/Release */
+ Tcl_Preserve((ClientData)dst_buf); /* XXXXXXXX */
+#endif
+
+ ptr = src_buf;
+ while(RSTRING_LEN(str) > ptr - src_buf) {
+ if (*ptr == '\\' && (all_bs || *(ptr + 1) == 'u')) {
+ dst_len += Tcl_UtfBackslash(ptr, &read_len, (dst_buf + dst_len));
+ ptr += read_len;
+ } else {
+ *(dst_buf + (dst_len++)) = *(ptr++);
+ }
+ }
+
+ str = rb_str_new(dst_buf, dst_len);
+ if (taint_flag) RbTk_OBJ_UNTRUST(str);
+#ifdef HAVE_RUBY_ENCODING_H
+ rb_enc_associate_index(str, ENCODING_INDEX_UTF8);
+#endif
+ rb_ivar_set(str, ID_at_enc, ENCODING_NAME_UTF8);
+
+#if 0 /* use Tcl_EventuallyFree */
+ Tcl_EventuallyFree((ClientData)src_buf, TCL_DYNAMIC); /* XXXXXXXX */
+#else
+#if 0 /* use Tcl_Preserve/Release */
+ Tcl_Release((ClientData)src_buf); /* XXXXXXXX */
+#else
+ /* free(src_buf); */
+ ckfree(src_buf);
+#endif
+#endif
+#if 0 /* use Tcl_EventuallyFree */
+ Tcl_EventuallyFree((ClientData)dst_buf, TCL_DYNAMIC); /* XXXXXXXX */
+#else
+#if 0 /* use Tcl_Preserve/Release */
+ Tcl_Release((ClientData)dst_buf); /* XXXXXXXX */
+#else
+ /* free(dst_buf); */
+ ckfree(dst_buf);
+#endif
+#endif
+
+ rb_thread_critical = thr_crit_bup;
+#endif
+
+ return str;
+}
+
+static VALUE
+lib_UTF_backslash(self, str)
+ VALUE self;
+ VALUE str;
+{
+ return lib_UTF_backslash_core(self, str, 0);
+}
+
+static VALUE
+lib_Tcl_backslash(self, str)
+ VALUE self;
+ VALUE str;
+{
+ return lib_UTF_backslash_core(self, str, 1);
+}
+
+static VALUE
+lib_get_system_encoding(self)
+ VALUE self;
+{
+#if TCL_MAJOR_VERSION > 8 || (TCL_MAJOR_VERSION == 8 && TCL_MINOR_VERSION > 0)
+ tcl_stubs_check();
+ return rb_str_new2(Tcl_GetEncodingName((Tcl_Encoding)NULL));
+#else
+ return Qnil;
+#endif
+}
+
+static VALUE
+lib_set_system_encoding(self, enc_name)
+ VALUE self;
+ VALUE enc_name;
+{
+#if TCL_MAJOR_VERSION > 8 || (TCL_MAJOR_VERSION == 8 && TCL_MINOR_VERSION > 0)
+ tcl_stubs_check();
+
+ if (NIL_P(enc_name)) {
+ Tcl_SetSystemEncoding((Tcl_Interp *)NULL, (CONST char *)NULL);
+ return lib_get_system_encoding(self);
+ }
+
+ enc_name = rb_funcall(enc_name, ID_to_s, 0, 0);
+ if (Tcl_SetSystemEncoding((Tcl_Interp *)NULL,
+ StringValuePtr(enc_name)) != TCL_OK) {
+ rb_raise(rb_eArgError, "unknown encoding name '%s'",
+ RSTRING_PTR(enc_name));
+ }
+
+ return enc_name;
+#else
+ return Qnil;
+#endif
+}
+
+
+/* invoke Tcl proc */
+struct invoke_info {
+ struct tcltkip *ptr;
+ Tcl_CmdInfo cmdinfo;
+#if TCL_MAJOR_VERSION >= 8
+ int objc;
+ Tcl_Obj **objv;
+#else
+ int argc;
+ char **argv;
+#endif
+};
+
+static VALUE
+#ifdef HAVE_PROTOTYPES
+invoke_tcl_proc(VALUE arg)
+#else
+invoke_tcl_proc(arg)
+ VALUE arg;
+#endif
+{
+ struct invoke_info *inf = (struct invoke_info *)arg;
+#if TCL_MAJOR_VERSION >= 8 && TCL_MINOR_VERSION < 6
+ int i, len;
+ int argc = inf->objc;
+ char **argv = (char **)NULL;
+#endif
+
+ DUMP1("call invoke_tcl_proc");
+
+#if TCL_MAJOR_VERSION > 8 || (TCL_MAJOR_VERSION == 8 && TCL_MINOR_VERSION >= 6)
+ /* Tcl/Tk 8.6 or later */
+
+ /* eval */
+ inf->ptr->return_value = Tcl_EvalObjv(inf->ptr->ip, inf->objc, inf->objv, TCL_EVAL_DIRECT);
+ /* inf->ptr->return_value = Tcl_EvalObjv(inf->ptr->ip, inf->objc, inf->objv, 0); */
+
+#else /* Tcl/Tk 7.x, 8.0 -- 8.5 */
+
+ /* memory allocation for arguments of this command */
+#if TCL_MAJOR_VERSION == 8
+ /* Tcl/Tk 8.0 -- 8.5 */
+ if (!inf->cmdinfo.isNativeObjectProc) {
+ DUMP1("called proc is not a native-obj-proc");
+ /* string interface */
+ /* argv = (char **)ALLOC_N(char *, argc+1);*/ /* XXXXXXXXXX */
+ argv = RbTk_ALLOC_N(char *, (argc+1));
+#if 0 /* use Tcl_Preserve/Release */
+ Tcl_Preserve((ClientData)argv); /* XXXXXXXX */
+#endif
+ for (i = 0; i < argc; ++i) {
+ argv[i] = Tcl_GetStringFromObj(inf->objv[i], &len);
+ }
+ argv[argc] = (char *)NULL;
+ }
+#endif
+
+ DUMP1("reset result of tcl-interp");
+ Tcl_ResetResult(inf->ptr->ip);
+
+ /* Invoke the C procedure */
+#if TCL_MAJOR_VERSION == 8
+ /* Tcl/Tk 8.0 -- 8.5 */
+ if (inf->cmdinfo.isNativeObjectProc) {
+ DUMP1("call tcl_proc as a native-obj-proc");
+ inf->ptr->return_value
+ = (*(inf->cmdinfo.objProc))(inf->cmdinfo.objClientData,
+ inf->ptr->ip, inf->objc, inf->objv);
+ }
+ else
+#endif
+ {
+#if TCL_MAJOR_VERSION == 8
+ /* Tcl/Tk 8.0 -- 8.5 */
+ DUMP1("call tcl_proc as not a native-obj-proc");
+ inf->ptr->return_value
+ = (*(inf->cmdinfo.proc))(inf->cmdinfo.clientData, inf->ptr->ip,
+ argc, (CONST84 char **)argv);
+
+#if 0 /* use Tcl_EventuallyFree */
+ Tcl_EventuallyFree((ClientData)argv, TCL_DYNAMIC); /* XXXXXXXX */
+#else
+#if 0 /* use Tcl_Preserve/Release */
+ Tcl_Release((ClientData)argv); /* XXXXXXXX */
+#else
+ /* free(argv); */
+ ckfree((char*)argv);
+#endif
+#endif
+
+#else /* TCL_MAJOR_VERSION < 8 */
+ inf->ptr->return_value
+ = (*(inf->cmdinfo.proc))(inf->cmdinfo.clientData, inf->ptr->ip,
+ inf->argc, inf->argv);
+#endif
+ }
+
+#endif /* Tcl/Tk 8.6 or later || Tcl 7.x, 8.0 -- 8.5 */
+
+ DUMP1("end of invoke_tcl_proc");
+ return Qnil;
+}
+
+
+#if TCL_MAJOR_VERSION >= 8
+static VALUE
+ip_invoke_core(interp, objc, objv)
+ VALUE interp;
+ int objc;
+ Tcl_Obj **objv;
+#else
+static VALUE
+ip_invoke_core(interp, argc, argv)
+ VALUE interp;
+ int argc;
+ char **argv;
+#endif
+{
+ struct tcltkip *ptr;
+ Tcl_CmdInfo info;
+ char *cmd;
+ int len;
+ int thr_crit_bup;
+ int unknown_flag = 0;
+
+#if 1 /* wrap tcl-proc call */
+ struct invoke_info inf;
+ int status;
+#else
+#if TCL_MAJOR_VERSION >= 8
+ int argc = objc;
+ char **argv = (char **)NULL;
+ /* Tcl_Obj *resultPtr; */
+#endif
+#endif
+
+ /* get the data struct */
+ ptr = get_ip(interp);
+
+ /* get the command name string */
+#if TCL_MAJOR_VERSION >= 8
+ cmd = Tcl_GetStringFromObj(objv[0], &len);
+#else /* TCL_MAJOR_VERSION < 8 */
+ cmd = argv[0];
+#endif
+
+ /* get the data struct */
+ ptr = get_ip(interp);
+
+ /* ip is deleted? */
+ if (deleted_ip(ptr)) {
+ return rb_tainted_str_new2("");
+ }
+
+ /* Tcl_Preserve(ptr->ip); */
+ rbtk_preserve_ip(ptr);
+
+ /* map from the command name to a C procedure */
+ DUMP2("call Tcl_GetCommandInfo, %s", cmd);
+ if (!Tcl_GetCommandInfo(ptr->ip, cmd, &info)) {
+ DUMP1("error Tcl_GetCommandInfo");
+ DUMP1("try auto_load (call 'unknown' command)");
+ if (!Tcl_GetCommandInfo(ptr->ip,
+#if TCL_MAJOR_VERSION >= 8
+ "::unknown",
+#else
+ "unknown",
+#endif
+ &info)) {
+ DUMP1("fail to get 'unknown' command");
+ /* if (event_loop_abort_on_exc || cmd[0] != '.') { */
+ if (event_loop_abort_on_exc > 0) {
+ /* Tcl_Release(ptr->ip); */
+ rbtk_release_ip(ptr);
+ /*rb_ip_raise(obj,rb_eNameError,"invalid command name `%s'",cmd);*/
+ return create_ip_exc(interp, rb_eNameError,
+ "invalid command name `%s'", cmd);
+ } else {
+ if (event_loop_abort_on_exc < 0) {
+ rb_warning("invalid command name `%s' (ignore)", cmd);
+ } else {
+ rb_warn("invalid command name `%s' (ignore)", cmd);
+ }
+ Tcl_ResetResult(ptr->ip);
+ /* Tcl_Release(ptr->ip); */
+ rbtk_release_ip(ptr);
+ return rb_tainted_str_new2("");
+ }
+ } else {
+#if TCL_MAJOR_VERSION >= 8
+ Tcl_Obj **unknown_objv;
+#else
+ char **unknown_argv;
+#endif
+ DUMP1("find 'unknown' command -> set arguemnts");
+ unknown_flag = 1;
+
+#if TCL_MAJOR_VERSION >= 8
+ /* unknown_objv = (Tcl_Obj **)ALLOC_N(Tcl_Obj *, objc+2); */
+ unknown_objv = RbTk_ALLOC_N(Tcl_Obj *, (objc+2));
+#if 0 /* use Tcl_Preserve/Release */
+ Tcl_Preserve((ClientData)unknown_objv); /* XXXXXXXX */
+#endif
+ unknown_objv[0] = Tcl_NewStringObj("::unknown", 9);
+ Tcl_IncrRefCount(unknown_objv[0]);
+ memcpy(unknown_objv + 1, objv, sizeof(Tcl_Obj *)*objc);
+ unknown_objv[++objc] = (Tcl_Obj*)NULL;
+ objv = unknown_objv;
+#else
+ /* unknown_argv = (char **)ALLOC_N(char *, argc+2); */
+ unknown_argv = RbTk_ALLOC_N(char *, (argc+2));
+#if 0 /* use Tcl_Preserve/Release */
+ Tcl_Preserve((ClientData)unknown_argv); /* XXXXXXXX */
+#endif
+ unknown_argv[0] = strdup("unknown");
+ memcpy(unknown_argv + 1, argv, sizeof(char *)*argc);
+ unknown_argv[++argc] = (char *)NULL;
+ argv = unknown_argv;
+#endif
+ }
+ }
+ DUMP1("end Tcl_GetCommandInfo");
+
+ thr_crit_bup = rb_thread_critical;
+ rb_thread_critical = Qtrue;
+
+#if 1 /* wrap tcl-proc call */
+ /* setup params */
+ inf.ptr = ptr;
+ inf.cmdinfo = info;
+#if TCL_MAJOR_VERSION >= 8
+ inf.objc = objc;
+ inf.objv = objv;
+#else
+ inf.argc = argc;
+ inf.argv = argv;
+#endif
+
+ /* invoke tcl-proc */
+ DUMP1("invoke tcl-proc");
+ rb_protect(invoke_tcl_proc, (VALUE)&inf, &status);
+ DUMP2("status of tcl-proc, %d", status);
+ switch(status) {
+ case TAG_RAISE:
+ if (NIL_P(rb_errinfo())) {
+ rbtk_pending_exception = rb_exc_new2(rb_eException,
+ "unknown exception");
+ } else {
+ rbtk_pending_exception = rb_errinfo();
+ }
+ break;
+
+ case TAG_FATAL:
+ if (NIL_P(rb_errinfo())) {
+ rbtk_pending_exception = rb_exc_new2(rb_eFatal, "FATAL");
+ } else {
+ rbtk_pending_exception = rb_errinfo();
+ }
+ }
+
+#else /* !wrap tcl-proc call */
+
+ /* memory allocation for arguments of this command */
+#if TCL_MAJOR_VERSION >= 8
+ if (!info.isNativeObjectProc) {
+ int i;
+
+ /* string interface */
+ /* argv = (char **)ALLOC_N(char *, argc+1); */
+ argv = RbTk_ALLOC_N(char *, (argc+1));
+#if 0 /* use Tcl_Preserve/Release */
+ Tcl_Preserve((ClientData)argv); /* XXXXXXXX */
+#endif
+ for (i = 0; i < argc; ++i) {
+ argv[i] = Tcl_GetStringFromObj(objv[i], &len);
+ }
+ argv[argc] = (char *)NULL;
+ }
+#endif
+
+ Tcl_ResetResult(ptr->ip);
+
+ /* Invoke the C procedure */
+#if TCL_MAJOR_VERSION >= 8
+ if (info.isNativeObjectProc) {
+ ptr->return_value = (*info.objProc)(info.objClientData, ptr->ip,
+ objc, objv);
+#if 0
+ /* get the string value from the result object */
+ resultPtr = Tcl_GetObjResult(ptr->ip);
+ Tcl_SetResult(ptr->ip, Tcl_GetStringFromObj(resultPtr, &len),
+ TCL_VOLATILE);
+#endif
+ }
+ else
+#endif
+ {
+#if TCL_MAJOR_VERSION >= 8
+ ptr->return_value = (*info.proc)(info.clientData, ptr->ip,
+ argc, (CONST84 char **)argv);
+
+#if 0 /* use Tcl_EventuallyFree */
+ Tcl_EventuallyFree((ClientData)argv, TCL_DYNAMIC); /* XXXXXXXX */
+#else
+#if 0 /* use Tcl_Preserve/Release */
+ Tcl_Release((ClientData)argv); /* XXXXXXXX */
+#else
+ /* free(argv); */
+ ckfree((char*)argv);
+#endif
+#endif
+
+#else /* TCL_MAJOR_VERSION < 8 */
+ ptr->return_value = (*info.proc)(info.clientData, ptr->ip,
+ argc, argv);
+#endif
+ }
+#endif /* ! wrap tcl-proc call */
+
+ /* free allocated memory for calling 'unknown' command */
+ if (unknown_flag) {
+#if TCL_MAJOR_VERSION >= 8
+ Tcl_DecrRefCount(objv[0]);
+#if 0 /* use Tcl_EventuallyFree */
+ Tcl_EventuallyFree((ClientData)objv, TCL_DYNAMIC); /* XXXXXXXX */
+#else
+#if 0 /* use Tcl_Preserve/Release */
+ Tcl_Release((ClientData)objv); /* XXXXXXXX */
+#else
+ /* free(objv); */
+ ckfree((char*)objv);
+#endif
+#endif
+#else /* TCL_MAJOR_VERSION < 8 */
+ free(argv[0]);
+ /* ckfree(argv[0]); */
+#if 0 /* use Tcl_EventuallyFree */
+ Tcl_EventuallyFree((ClientData)argv, TCL_DYNAMIC); /* XXXXXXXX */
+#else
+#if 0 /* use Tcl_Preserve/Release */
+ Tcl_Release((ClientData)argv); /* XXXXXXXX */
+#else
+ /* free(argv); */
+ ckfree((char*)argv);
+#endif
+#endif
+#endif
+ }
+
+ /* exception on mainloop */
+ if (pending_exception_check1(thr_crit_bup, ptr)) {
+ return rbtk_pending_exception;
+ }
+
+ rb_thread_critical = thr_crit_bup;
+
+ /* if (ptr->return_value == TCL_ERROR) { */
+ if (ptr->return_value != TCL_OK) {
+ if (event_loop_abort_on_exc > 0 && !Tcl_InterpDeleted(ptr->ip)) {
+ switch (ptr->return_value) {
+ case TCL_RETURN:
+ return create_ip_exc(interp, eTkCallbackReturn,
+ "ip_invoke_core receives TCL_RETURN");
+ case TCL_BREAK:
+ return create_ip_exc(interp, eTkCallbackBreak,
+ "ip_invoke_core receives TCL_BREAK");
+ case TCL_CONTINUE:
+ return create_ip_exc(interp, eTkCallbackContinue,
+ "ip_invoke_core receives TCL_CONTINUE");
+ default:
+ return create_ip_exc(interp, rb_eRuntimeError, "%s",
+ Tcl_GetStringResult(ptr->ip));
+ }
+
+ } else {
+ if (event_loop_abort_on_exc < 0) {
+ rb_warning("%s (ignore)", Tcl_GetStringResult(ptr->ip));
+ } else {
+ rb_warn("%s (ignore)", Tcl_GetStringResult(ptr->ip));
+ }
+ Tcl_ResetResult(ptr->ip);
+ return rb_tainted_str_new2("");
+ }
+ }
+
+ /* pass back the result (as string) */
+ return ip_get_result_string_obj(ptr->ip);
+}
+
+
+#if TCL_MAJOR_VERSION >= 8
+static Tcl_Obj **
+#else /* TCL_MAJOR_VERSION < 8 */
+static char **
+#endif
+alloc_invoke_arguments(argc, argv)
+ int argc;
+ VALUE *argv;
+{
+ int i;
+ int thr_crit_bup;
+
+#if TCL_MAJOR_VERSION >= 8
+ Tcl_Obj **av;
+#else /* TCL_MAJOR_VERSION < 8 */
+ char **av;
+#endif
+
+ thr_crit_bup = rb_thread_critical;
+ rb_thread_critical = Qtrue;
+
+ /* memory allocation */
+#if TCL_MAJOR_VERSION >= 8
+ /* av = ALLOC_N(Tcl_Obj *, argc+1);*/ /* XXXXXXXXXX */
+ av = RbTk_ALLOC_N(Tcl_Obj *, (argc+1));
+#if 0 /* use Tcl_Preserve/Release */
+ Tcl_Preserve((ClientData)av); /* XXXXXXXX */
+#endif
+ for (i = 0; i < argc; ++i) {
+ av[i] = get_obj_from_str(argv[i]);
+ Tcl_IncrRefCount(av[i]);
+ }
+ av[argc] = NULL;
+
+#else /* TCL_MAJOR_VERSION < 8 */
+ /* string interface */
+ /* av = ALLOC_N(char *, argc+1); */
+ av = RbTk_ALLOC_N(char *, (argc+1));
+#if 0 /* use Tcl_Preserve/Release */
+ Tcl_Preserve((ClientData)av); /* XXXXXXXX */
+#endif
+ for (i = 0; i < argc; ++i) {
+ av[i] = strdup(StringValuePtr(argv[i]));
+ }
+ av[argc] = NULL;
+#endif
+
+ rb_thread_critical = thr_crit_bup;
+
+ return av;
+}
+
+static void
+free_invoke_arguments(argc, av)
+ int argc;
+#if TCL_MAJOR_VERSION >= 8
+ Tcl_Obj **av;
+#else /* TCL_MAJOR_VERSION < 8 */
+ char **av;
+#endif
+{
+ int i;
+
+ for (i = 0; i < argc; ++i) {
+#if TCL_MAJOR_VERSION >= 8
+ Tcl_DecrRefCount(av[i]);
+ av[i] = (Tcl_Obj*)NULL;
+#else /* TCL_MAJOR_VERSION < 8 */
+ free(av[i]);
+ av[i] = (char*)NULL;
+#endif
+ }
+#if TCL_MAJOR_VERSION >= 8
+#if 0 /* use Tcl_EventuallyFree */
+ Tcl_EventuallyFree((ClientData)av, TCL_DYNAMIC); /* XXXXXXXX */
+#else
+#if 0 /* use Tcl_Preserve/Release */
+ Tcl_Release((ClientData)av); /* XXXXXXXX */
+#else
+ ckfree((char*)av);
+#endif
+#endif
+#else /* TCL_MAJOR_VERSION < 8 */
+#if 0 /* use Tcl_EventuallyFree */
+ Tcl_EventuallyFree((ClientData)av, TCL_DYNAMIC); /* XXXXXXXX */
+#else
+#if 0 /* use Tcl_Preserve/Release */
+ Tcl_Release((ClientData)av); /* XXXXXXXX */
+#else
+ /* free(av); */
+ ckfree((char*)av);
+#endif
+#endif
+#endif
+}
+
+static VALUE
+ip_invoke_real(argc, argv, interp)
+ int argc;
+ VALUE *argv;
+ VALUE interp;
+{
+ VALUE v;
+ struct tcltkip *ptr; /* tcltkip data struct */
+
+#if TCL_MAJOR_VERSION >= 8
+ Tcl_Obj **av = (Tcl_Obj **)NULL;
+#else /* TCL_MAJOR_VERSION < 8 */
+ char **av = (char **)NULL;
+#endif
+
+ DUMP2("invoke_real called by thread:%"PRIxVALUE, rb_thread_current());
+
+ /* get the data struct */
+ ptr = get_ip(interp);
+
+ /* ip is deleted? */
+ if (deleted_ip(ptr)) {
+ return rb_tainted_str_new2("");
+ }
+
+ /* allocate memory for arguments */
+ av = alloc_invoke_arguments(argc, argv);
+
+ /* Invoke the C procedure */
+ Tcl_ResetResult(ptr->ip);
+ v = ip_invoke_core(interp, argc, av);
+
+ /* free allocated memory */
+ free_invoke_arguments(argc, av);
+
+ return v;
+}
+
+VALUE
+ivq_safelevel_handler(arg, ivq)
+ VALUE arg;
+ VALUE ivq;
+{
+ struct invoke_queue *q;
+
+ Data_Get_Struct(ivq, struct invoke_queue, q);
+ DUMP2("(safe-level handler) $SAFE = %d", q->safe_level);
+ rb_set_safe_level(q->safe_level);
+ return ip_invoke_core(q->interp, q->argc, q->argv);
+}
+
+int invoke_queue_handler _((Tcl_Event *, int));
+int
+invoke_queue_handler(evPtr, flags)
+ Tcl_Event *evPtr;
+ int flags;
+{
+ struct invoke_queue *q = (struct invoke_queue *)evPtr;
+ volatile VALUE ret;
+ volatile VALUE q_dat;
+ volatile VALUE thread = q->thread;
+ struct tcltkip *ptr;
+
+ DUMP2("do_invoke_queue_handler : evPtr = %p", evPtr);
+ DUMP2("invoke queue_thread : %"PRIxVALUE, rb_thread_current());
+ DUMP2("added by thread : %"PRIxVALUE, thread);
+
+ if (*(q->done)) {
+ DUMP1("processed by another event-loop");
+ return 0;
+ } else {
+ DUMP1("process it on current event-loop");
+ }
+
+ if (RTEST(rb_thread_alive_p(thread))
+ && ! RTEST(rb_funcall(thread, ID_stop_p, 0))) {
+ DUMP1("caller is not yet ready to receive the result -> pending");
+ return 0;
+ }
+
+ /* process it */
+ *(q->done) = 1;
+
+ /* deleted ipterp ? */
+ ptr = get_ip(q->interp);
+ if (deleted_ip(ptr)) {
+ /* deleted IP --> ignore */
+ return 1;
+ }
+
+ /* incr internal handler mark */
+ rbtk_internal_eventloop_handler++;
+
+ /* check safe-level */
+ if (rb_safe_level() != q->safe_level) {
+ /* q_dat = Data_Wrap_Struct(rb_cData,0,0,q); */
+ q_dat = Data_Wrap_Struct(0,invoke_queue_mark,-1,q);
+ ret = rb_funcall(rb_proc_new(ivq_safelevel_handler, q_dat),
+ ID_call, 0);
+ rb_gc_force_recycle(q_dat);
+ q_dat = (VALUE)NULL;
+ } else {
+ DUMP2("call invoke_real (for caller thread:%"PRIxVALUE")", thread);
+ DUMP2("call invoke_real (current thread:%"PRIxVALUE")", rb_thread_current());
+ ret = ip_invoke_core(q->interp, q->argc, q->argv);
+ }
+
+ /* set result */
+ RARRAY_PTR(q->result)[0] = ret;
+ ret = (VALUE)NULL;
+
+ /* decr internal handler mark */
+ rbtk_internal_eventloop_handler--;
+
+ /* complete */
+ *(q->done) = -1;
+
+ /* unlink ruby objects */
+ q->interp = (VALUE)NULL;
+ q->result = (VALUE)NULL;
+ q->thread = (VALUE)NULL;
+
+ /* back to caller */
+ if (RTEST(rb_thread_alive_p(thread))) {
+ DUMP2("back to caller (caller thread:%"PRIxVALUE")", thread);
+ DUMP2(" (current thread:%"PRIxVALUE")", rb_thread_current());
+#if CONTROL_BY_STATUS_OF_RB_THREAD_WAITING_FOR_VALUE
+ have_rb_thread_waiting_for_value = 1;
+ rb_thread_wakeup(thread);
+#else
+ rb_thread_run(thread);
+#endif
+ DUMP1("finish back to caller");
+#if DO_THREAD_SCHEDULE_AT_CALLBACK_DONE
+ rb_thread_schedule();
+#endif
+ } else {
+ DUMP2("caller is dead (caller thread:%"PRIxVALUE")", thread);
+ DUMP2(" (current thread:%"PRIxVALUE")", rb_thread_current());
+ }
+
+ /* end of handler : remove it */
+ return 1;
+}
+
+static VALUE
+ip_invoke_with_position(argc, argv, obj, position)
+ int argc;
+ VALUE *argv;
+ VALUE obj;
+ Tcl_QueuePosition position;
+{
+ struct invoke_queue *ivq;
+#ifdef RUBY_USE_NATIVE_THREAD
+ struct tcltkip *ptr;
+#endif
+ int *alloc_done;
+ int thr_crit_bup;
+ volatile VALUE current = rb_thread_current();
+ volatile VALUE ip_obj = obj;
+ volatile VALUE result;
+ volatile VALUE ret;
+ struct timeval t;
+
+#if TCL_MAJOR_VERSION >= 8
+ Tcl_Obj **av = (Tcl_Obj **)NULL;
+#else /* TCL_MAJOR_VERSION < 8 */
+ char **av = (char **)NULL;
+#endif
+
+ if (argc < 1) {
+ rb_raise(rb_eArgError, "command name missing");
+ }
+
+#ifdef RUBY_USE_NATIVE_THREAD
+ ptr = get_ip(ip_obj);
+ DUMP2("invoke status: ptr->tk_thread_id %p", ptr->tk_thread_id);
+ DUMP2("invoke status: Tcl_GetCurrentThread %p", Tcl_GetCurrentThread());
+#else
+ DUMP2("status: Tcl_GetCurrentThread %p", Tcl_GetCurrentThread());
+#endif
+ DUMP2("status: eventloopt_thread %"PRIxVALUE, eventloop_thread);
+
+ if (
+#ifdef RUBY_USE_NATIVE_THREAD
+ (ptr->tk_thread_id == 0 || ptr->tk_thread_id == Tcl_GetCurrentThread())
+ &&
+#endif
+ (NIL_P(eventloop_thread) || current == eventloop_thread)
+ ) {
+ if (NIL_P(eventloop_thread)) {
+ DUMP2("invoke from thread:%"PRIxVALUE" but no eventloop", current);
+ } else {
+ DUMP2("invoke from current eventloop %"PRIxVALUE, current);
+ }
+ result = ip_invoke_real(argc, argv, ip_obj);
+ if (rb_obj_is_kind_of(result, rb_eException)) {
+ rb_exc_raise(result);
+ }
+ return result;
+ }
+
+ DUMP2("invoke from thread %"PRIxVALUE" (NOT current eventloop)", current);
+
+ thr_crit_bup = rb_thread_critical;
+ rb_thread_critical = Qtrue;
+
+ /* allocate memory (for arguments) */
+ av = alloc_invoke_arguments(argc, argv);
+
+ /* allocate memory (keep result) */
+ /* alloc_done = (int*)ALLOC(int); */
+ alloc_done = RbTk_ALLOC_N(int, 1);
+#if 0 /* use Tcl_Preserve/Release */
+ Tcl_Preserve((ClientData)alloc_done); /* XXXXXXXX */
+#endif
+ *alloc_done = 0;
+
+ /* allocate memory (freed by Tcl_ServiceEvent) */
+ /* ivq = (struct invoke_queue *)Tcl_Alloc(sizeof(struct invoke_queue)); */
+ ivq = RbTk_ALLOC_N(struct invoke_queue, 1);
+#if 0 /* use Tcl_Preserve/Release */
+ Tcl_Preserve((ClientData)ivq); /* XXXXXXXX */
+#endif
+
+ /* allocate result obj */
+ result = rb_ary_new3(1, Qnil);
+
+ /* construct event data */
+ ivq->done = alloc_done;
+ ivq->argc = argc;
+ ivq->argv = av;
+ ivq->interp = ip_obj;
+ ivq->result = result;
+ ivq->thread = current;
+ ivq->safe_level = rb_safe_level();
+ ivq->ev.proc = invoke_queue_handler;
+
+ /* add the handler to Tcl event queue */
+ DUMP1("add handler");
+#ifdef RUBY_USE_NATIVE_THREAD
+ if (ptr->tk_thread_id) {
+ /* Tcl_ThreadQueueEvent(ptr->tk_thread_id, &(ivq->ev), position); */
+ Tcl_ThreadQueueEvent(ptr->tk_thread_id, (Tcl_Event*)ivq, position);
+ Tcl_ThreadAlert(ptr->tk_thread_id);
+ } else if (tk_eventloop_thread_id) {
+ /* Tcl_ThreadQueueEvent(tk_eventloop_thread_id,
+ &(ivq->ev), position); */
+ Tcl_ThreadQueueEvent(tk_eventloop_thread_id,
+ (Tcl_Event*)ivq, position);
+ Tcl_ThreadAlert(tk_eventloop_thread_id);
+ } else {
+ /* Tcl_QueueEvent(&(ivq->ev), position); */
+ Tcl_QueueEvent((Tcl_Event*)ivq, position);
+ }
+#else
+ /* Tcl_QueueEvent(&(ivq->ev), position); */
+ Tcl_QueueEvent((Tcl_Event*)ivq, position);
+#endif
+
+ rb_thread_critical = thr_crit_bup;
+
+ /* wait for the handler to be processed */
+ t.tv_sec = 0;
+ t.tv_usec = (long)((EVENT_HANDLER_TIMEOUT)*1000.0);
+
+ DUMP2("ivq wait for handler (current thread:%"PRIxVALUE")", current);
+ while(*alloc_done >= 0) {
+ /* rb_thread_stop(); */
+ /* rb_thread_sleep_forever(); */
+ rb_thread_wait_for(t);
+ DUMP2("*** ivq wakeup (current thread:%"PRIxVALUE")", current);
+ DUMP2("*** (eventloop thread:%"PRIxVALUE")", eventloop_thread);
+ if (NIL_P(eventloop_thread)) {
+ DUMP1("*** ivq lost eventloop thread");
+ break;
+ }
+ }
+ DUMP2("back from handler (current thread:%"PRIxVALUE")", current);
+
+ /* get result & free allocated memory */
+ ret = RARRAY_PTR(result)[0];
+#if 0 /* use Tcl_EventuallyFree */
+ Tcl_EventuallyFree((ClientData)alloc_done, TCL_DYNAMIC); /* XXXXXXXX */
+#else
+#if 0 /* use Tcl_Preserve/Release */
+ Tcl_Release((ClientData)alloc_done); /* XXXXXXXX */
+#else
+ /* free(alloc_done); */
+ ckfree((char*)alloc_done);
+#endif
+#endif
+
+#if 0 /* ivq is freed by Tcl_ServiceEvent */
+#if 0 /* use Tcl_EventuallyFree */
+ Tcl_EventuallyFree((ClientData)ivq, TCL_DYNAMIC); /* XXXXXXXX */
+#else
+#if 0 /* use Tcl_Preserve/Release */
+ Tcl_Release(ivq);
+#else
+ ckfree((char*)ivq);
+#endif
+#endif
+#endif
+
+ /* free allocated memory */
+ free_invoke_arguments(argc, av);
+
+ /* exception? */
+ if (rb_obj_is_kind_of(ret, rb_eException)) {
+ DUMP1("raise exception");
+ /* rb_exc_raise(ret); */
+ rb_exc_raise(rb_exc_new3(rb_obj_class(ret),
+ rb_funcall(ret, ID_to_s, 0, 0)));
+ }
+
+ DUMP1("exit ip_invoke");
+ return ret;
+}
+
+
+/* get return code from Tcl_Eval() */
+static VALUE
+ip_retval(self)
+ VALUE self;
+{
+ struct tcltkip *ptr; /* tcltkip data struct */
+
+ /* get the data strcut */
+ ptr = get_ip(self);
+
+ /* ip is deleted? */
+ if (deleted_ip(ptr)) {
+ return rb_tainted_str_new2("");
+ }
+
+ return (INT2FIX(ptr->return_value));
+}
+
+static VALUE
+ip_invoke(argc, argv, obj)
+ int argc;
+ VALUE *argv;
+ VALUE obj;
+{
+ return ip_invoke_with_position(argc, argv, obj, TCL_QUEUE_TAIL);
+}
+
+static VALUE
+ip_invoke_immediate(argc, argv, obj)
+ int argc;
+ VALUE *argv;
+ VALUE obj;
+{
+ /* POTENTIALY INSECURE : can create infinite loop */
+ return ip_invoke_with_position(argc, argv, obj, TCL_QUEUE_HEAD);
+}
+
+
+/* access Tcl variables */
+static VALUE
+ip_get_variable2_core(interp, argc, argv)
+ VALUE interp;
+ int argc;
+ VALUE *argv;
+{
+ struct tcltkip *ptr = get_ip(interp);
+ int thr_crit_bup;
+ volatile VALUE varname, index, flag;
+
+ varname = argv[0];
+ index = argv[1];
+ flag = argv[2];
+
+ /*
+ StringValue(varname);
+ if (!NIL_P(index)) StringValue(index);
+ */
+
+#if TCL_MAJOR_VERSION >= 8
+ {
+ Tcl_Obj *ret;
+ volatile VALUE strval;
+
+ thr_crit_bup = rb_thread_critical;
+ rb_thread_critical = Qtrue;
+
+ /* ip is deleted? */
+ if (deleted_ip(ptr)) {
+ rb_thread_critical = thr_crit_bup;
+ return rb_tainted_str_new2("");
+ } else {
+ /* Tcl_Preserve(ptr->ip); */
+ rbtk_preserve_ip(ptr);
+ ret = Tcl_GetVar2Ex(ptr->ip, RSTRING_PTR(varname),
+ NIL_P(index) ? NULL : RSTRING_PTR(index),
+ FIX2INT(flag));
+ }
+
+ if (ret == (Tcl_Obj*)NULL) {
+ volatile VALUE exc;
+ /* exc = rb_exc_new2(rb_eRuntimeError,
+ Tcl_GetStringResult(ptr->ip)); */
+ exc = create_ip_exc(interp, rb_eRuntimeError, "%s",
+ Tcl_GetStringResult(ptr->ip));
+ /* Tcl_Release(ptr->ip); */
+ rbtk_release_ip(ptr);
+ rb_thread_critical = thr_crit_bup;
+ return exc;
+ }
+
+ Tcl_IncrRefCount(ret);
+ strval = get_str_from_obj(ret);
+ RbTk_OBJ_UNTRUST(strval);
+ Tcl_DecrRefCount(ret);
+
+ /* Tcl_Release(ptr->ip); */
+ rbtk_release_ip(ptr);
+ rb_thread_critical = thr_crit_bup;
+ return(strval);
+ }
+#else /* TCL_MAJOR_VERSION < 8 */
+ {
+ char *ret;
+ volatile VALUE strval;
+
+ /* ip is deleted? */
+ if (deleted_ip(ptr)) {
+ return rb_tainted_str_new2("");
+ } else {
+ /* Tcl_Preserve(ptr->ip); */
+ rbtk_preserve_ip(ptr);
+ ret = Tcl_GetVar2(ptr->ip, RSTRING_PTR(varname),
+ NIL_P(index) ? NULL : RSTRING_PTR(index),
+ FIX2INT(flag));
+ }
+
+ if (ret == (char*)NULL) {
+ volatile VALUE exc;
+ exc = rb_exc_new2(rb_eRuntimeError, Tcl_GetStringResult(ptr->ip));
+ /* Tcl_Release(ptr->ip); */
+ rbtk_release_ip(ptr);
+ rb_thread_critical = thr_crit_bup;
+ return exc;
+ }
+
+ strval = rb_tainted_str_new2(ret);
+ /* Tcl_Release(ptr->ip); */
+ rbtk_release_ip(ptr);
+ rb_thread_critical = thr_crit_bup;
+
+ return(strval);
+ }
+#endif
+}
+
+static VALUE
+ip_get_variable2(self, varname, index, flag)
+ VALUE self;
+ VALUE varname;
+ VALUE index;
+ VALUE flag;
+{
+ VALUE argv[3];
+ VALUE retval;
+
+ StringValue(varname);
+ if (!NIL_P(index)) StringValue(index);
+
+ argv[0] = varname;
+ argv[1] = index;
+ argv[2] = flag;
+
+ retval = tk_funcall(ip_get_variable2_core, 3, argv, self);
+
+ if (NIL_P(retval)) {
+ return rb_tainted_str_new2("");
+ } else {
+ return retval;
+ }
+}
+
+static VALUE
+ip_get_variable(self, varname, flag)
+ VALUE self;
+ VALUE varname;
+ VALUE flag;
+{
+ return ip_get_variable2(self, varname, Qnil, flag);
+}
+
+static VALUE
+ip_set_variable2_core(interp, argc, argv)
+ VALUE interp;
+ int argc;
+ VALUE *argv;
+{
+ struct tcltkip *ptr = get_ip(interp);
+ int thr_crit_bup;
+ volatile VALUE varname, index, value, flag;
+
+ varname = argv[0];
+ index = argv[1];
+ value = argv[2];
+ flag = argv[3];
+
+ /*
+ StringValue(varname);
+ if (!NIL_P(index)) StringValue(index);
+ StringValue(value);
+ */
+
+#if TCL_MAJOR_VERSION >= 8
+ {
+ Tcl_Obj *valobj, *ret;
+ volatile VALUE strval;
+
+ thr_crit_bup = rb_thread_critical;
+ rb_thread_critical = Qtrue;
+
+ valobj = get_obj_from_str(value);
+ Tcl_IncrRefCount(valobj);
+
+ /* ip is deleted? */
+ if (deleted_ip(ptr)) {
+ Tcl_DecrRefCount(valobj);
+ rb_thread_critical = thr_crit_bup;
+ return rb_tainted_str_new2("");
+ } else {
+ /* Tcl_Preserve(ptr->ip); */
+ rbtk_preserve_ip(ptr);
+ ret = Tcl_SetVar2Ex(ptr->ip, RSTRING_PTR(varname),
+ NIL_P(index) ? NULL : RSTRING_PTR(index),
+ valobj, FIX2INT(flag));
+ }
+
+ Tcl_DecrRefCount(valobj);
+
+ if (ret == (Tcl_Obj*)NULL) {
+ volatile VALUE exc;
+ /* exc = rb_exc_new2(rb_eRuntimeError,
+ Tcl_GetStringResult(ptr->ip)); */
+ exc = create_ip_exc(interp, rb_eRuntimeError, "%s",
+ Tcl_GetStringResult(ptr->ip));
+ /* Tcl_Release(ptr->ip); */
+ rbtk_release_ip(ptr);
+ rb_thread_critical = thr_crit_bup;
+ return exc;
+ }
+
+ Tcl_IncrRefCount(ret);
+ strval = get_str_from_obj(ret);
+ RbTk_OBJ_UNTRUST(strval);
+ Tcl_DecrRefCount(ret);
+
+ /* Tcl_Release(ptr->ip); */
+ rbtk_release_ip(ptr);
+ rb_thread_critical = thr_crit_bup;
+
+ return(strval);
+ }
+#else /* TCL_MAJOR_VERSION < 8 */
+ {
+ CONST char *ret;
+ volatile VALUE strval;
+
+ /* ip is deleted? */
+ if (deleted_ip(ptr)) {
+ return rb_tainted_str_new2("");
+ } else {
+ /* Tcl_Preserve(ptr->ip); */
+ rbtk_preserve_ip(ptr);
+ ret = Tcl_SetVar2(ptr->ip, RSTRING_PTR(varname),
+ NIL_P(index) ? NULL : RSTRING_PTR(index),
+ RSTRING_PTR(value), FIX2INT(flag));
+ }
+
+ if (ret == (char*)NULL) {
+ return rb_exc_new2(rb_eRuntimeError, ptr->ip->result);
+ }
+
+ strval = rb_tainted_str_new2(ret);
+
+ /* Tcl_Release(ptr->ip); */
+ rbtk_release_ip(ptr);
+ rb_thread_critical = thr_crit_bup;
+
+ return(strval);
+ }
+#endif
+}
+
+static VALUE
+ip_set_variable2(self, varname, index, value, flag)
+ VALUE self;
+ VALUE varname;
+ VALUE index;
+ VALUE value;
+ VALUE flag;
+{
+ VALUE argv[4];
+ VALUE retval;
+
+ StringValue(varname);
+ if (!NIL_P(index)) StringValue(index);
+ StringValue(value);
+
+ argv[0] = varname;
+ argv[1] = index;
+ argv[2] = value;
+ argv[3] = flag;
+
+ retval = tk_funcall(ip_set_variable2_core, 4, argv, self);
+
+ if (NIL_P(retval)) {
+ return rb_tainted_str_new2("");
+ } else {
+ return retval;
+ }
+}
+
+static VALUE
+ip_set_variable(self, varname, value, flag)
+ VALUE self;
+ VALUE varname;
+ VALUE value;
+ VALUE flag;
+{
+ return ip_set_variable2(self, varname, Qnil, value, flag);
+}
+
+static VALUE
+ip_unset_variable2_core(interp, argc, argv)
+ VALUE interp;
+ int argc;
+ VALUE *argv;
+{
+ struct tcltkip *ptr = get_ip(interp);
+ volatile VALUE varname, index, flag;
+
+ varname = argv[0];
+ index = argv[1];
+ flag = argv[2];
+
+ /*
+ StringValue(varname);
+ if (!NIL_P(index)) StringValue(index);
+ */
+
+ /* ip is deleted? */
+ if (deleted_ip(ptr)) {
+ return Qtrue;
+ }
+
+ ptr->return_value = Tcl_UnsetVar2(ptr->ip, RSTRING_PTR(varname),
+ NIL_P(index) ? NULL : RSTRING_PTR(index),
+ FIX2INT(flag));
+
+ if (ptr->return_value == TCL_ERROR) {
+ if (FIX2INT(flag) & TCL_LEAVE_ERR_MSG) {
+ /* return rb_exc_new2(rb_eRuntimeError,
+ Tcl_GetStringResult(ptr->ip)); */
+ return create_ip_exc(interp, rb_eRuntimeError, "%s",
+ Tcl_GetStringResult(ptr->ip));
+ }
+ return Qfalse;
+ }
+ return Qtrue;
+}
+
+static VALUE
+ip_unset_variable2(self, varname, index, flag)
+ VALUE self;
+ VALUE varname;
+ VALUE index;
+ VALUE flag;
+{
+ VALUE argv[3];
+ VALUE retval;
+
+ StringValue(varname);
+ if (!NIL_P(index)) StringValue(index);
+
+ argv[0] = varname;
+ argv[1] = index;
+ argv[2] = flag;
+
+ retval = tk_funcall(ip_unset_variable2_core, 3, argv, self);
+
+ if (NIL_P(retval)) {
+ return rb_tainted_str_new2("");
+ } else {
+ return retval;
+ }
+}
+
+static VALUE
+ip_unset_variable(self, varname, flag)
+ VALUE self;
+ VALUE varname;
+ VALUE flag;
+{
+ return ip_unset_variable2(self, varname, Qnil, flag);
+}
+
+static VALUE
+ip_get_global_var(self, varname)
+ VALUE self;
+ VALUE varname;
+{
+ return ip_get_variable(self, varname,
+ INT2FIX(TCL_GLOBAL_ONLY | TCL_LEAVE_ERR_MSG));
+}
+
+static VALUE
+ip_get_global_var2(self, varname, index)
+ VALUE self;
+ VALUE varname;
+ VALUE index;
+{
+ return ip_get_variable2(self, varname, index,
+ INT2FIX(TCL_GLOBAL_ONLY | TCL_LEAVE_ERR_MSG));
+}
+
+static VALUE
+ip_set_global_var(self, varname, value)
+ VALUE self;
+ VALUE varname;
+ VALUE value;
+{
+ return ip_set_variable(self, varname, value,
+ INT2FIX(TCL_GLOBAL_ONLY | TCL_LEAVE_ERR_MSG));
+}
+
+static VALUE
+ip_set_global_var2(self, varname, index, value)
+ VALUE self;
+ VALUE varname;
+ VALUE index;
+ VALUE value;
+{
+ return ip_set_variable2(self, varname, index, value,
+ INT2FIX(TCL_GLOBAL_ONLY | TCL_LEAVE_ERR_MSG));
+}
+
+static VALUE
+ip_unset_global_var(self, varname)
+ VALUE self;
+ VALUE varname;
+{
+ return ip_unset_variable(self, varname,
+ INT2FIX(TCL_GLOBAL_ONLY | TCL_LEAVE_ERR_MSG));
+}
+
+static VALUE
+ip_unset_global_var2(self, varname, index)
+ VALUE self;
+ VALUE varname;
+ VALUE index;
+{
+ return ip_unset_variable2(self, varname, index,
+ INT2FIX(TCL_GLOBAL_ONLY | TCL_LEAVE_ERR_MSG));
+}
+
+
+/* treat Tcl_List */
+static VALUE
+lib_split_tklist_core(ip_obj, list_str)
+ VALUE ip_obj;
+ VALUE list_str;
+{
+ Tcl_Interp *interp;
+ volatile VALUE ary, elem;
+ int idx;
+ int taint_flag = OBJ_TAINTED(list_str);
+#ifdef HAVE_RUBY_ENCODING_H
+ int list_enc_idx;
+ volatile VALUE list_ivar_enc;
+#endif
+ int result;
+ VALUE old_gc;
+
+ tcl_stubs_check();
+
+ if (NIL_P(ip_obj)) {
+ interp = (Tcl_Interp *)NULL;
+ } else if (get_ip(ip_obj) == (struct tcltkip *)NULL) {
+ interp = (Tcl_Interp *)NULL;
+ } else {
+ interp = get_ip(ip_obj)->ip;
+ }
+
+ StringValue(list_str);
+#ifdef HAVE_RUBY_ENCODING_H
+ list_enc_idx = rb_enc_get_index(list_str);
+ list_ivar_enc = rb_ivar_get(list_str, ID_at_enc);
+#endif
+
+ {
+#if TCL_MAJOR_VERSION >= 8
+ /* object style interface */
+ Tcl_Obj *listobj;
+ int objc;
+ Tcl_Obj **objv;
+ int thr_crit_bup;
+
+ listobj = get_obj_from_str(list_str);
+
+ Tcl_IncrRefCount(listobj);
+
+ result = Tcl_ListObjGetElements(interp, listobj, &objc, &objv);
+
+ if (result == TCL_ERROR) {
+ Tcl_DecrRefCount(listobj);
+ if (interp == (Tcl_Interp*)NULL) {
+ rb_raise(rb_eRuntimeError, "can't get elements from list");
+ } else {
+ rb_raise(rb_eRuntimeError, "%s", Tcl_GetStringResult(interp));
+ }
+ }
+
+ for(idx = 0; idx < objc; idx++) {
+ Tcl_IncrRefCount(objv[idx]);
+ }
+
+ thr_crit_bup = rb_thread_critical;
+ rb_thread_critical = Qtrue;
+
+ ary = rb_ary_new2(objc);
+ if (taint_flag) RbTk_OBJ_UNTRUST(ary);
+
+ old_gc = rb_gc_disable();
+
+ for(idx = 0; idx < objc; idx++) {
+ elem = get_str_from_obj(objv[idx]);
+ if (taint_flag) RbTk_OBJ_UNTRUST(elem);
+
+#ifdef HAVE_RUBY_ENCODING_H
+ if (rb_enc_get_index(elem) == ENCODING_INDEX_BINARY) {
+ rb_enc_associate_index(elem, ENCODING_INDEX_BINARY);
+ rb_ivar_set(elem, ID_at_enc, ENCODING_NAME_BINARY);
+ } else {
+ rb_enc_associate_index(elem, list_enc_idx);
+ rb_ivar_set(elem, ID_at_enc, list_ivar_enc);
+ }
+#endif
+ /* RARRAY(ary)->ptr[idx] = elem; */
+ rb_ary_push(ary, elem);
+ }
+
+ /* RARRAY(ary)->len = objc; */
+
+ if (old_gc == Qfalse) rb_gc_enable();
+
+ rb_thread_critical = thr_crit_bup;
+
+ for(idx = 0; idx < objc; idx++) {
+ Tcl_DecrRefCount(objv[idx]);
+ }
+
+ Tcl_DecrRefCount(listobj);
+
+#else /* TCL_MAJOR_VERSION < 8 */
+ /* string style interface */
+ int argc;
+ char **argv;
+
+ if (Tcl_SplitList(interp, RSTRING_PTR(list_str),
+ &argc, &argv) == TCL_ERROR) {
+ if (interp == (Tcl_Interp*)NULL) {
+ rb_raise(rb_eRuntimeError, "can't get elements from list");
+ } else {
+ rb_raise(rb_eRuntimeError, "%s", interp->result);
+ }
+ }
+
+ ary = rb_ary_new2(argc);
+ if (taint_flag) RbTk_OBJ_UNTRUST(ary);
+
+ old_gc = rb_gc_disable();
+
+ for(idx = 0; idx < argc; idx++) {
+ if (taint_flag) {
+ elem = rb_tainted_str_new2(argv[idx]);
+ } else {
+ elem = rb_str_new2(argv[idx]);
+ }
+ /* rb_ivar_set(elem, ID_at_enc, rb_str_new2("binary")); */
+ /* RARRAY(ary)->ptr[idx] = elem; */
+ rb_ary_push(ary, elem)
+ }
+ /* RARRAY(ary)->len = argc; */
+
+ if (old_gc == Qfalse) rb_gc_enable();
+#endif
+ }
+
+ return ary;
+}
+
+static VALUE
+lib_split_tklist(self, list_str)
+ VALUE self;
+ VALUE list_str;
+{
+ return lib_split_tklist_core(Qnil, list_str);
+}
+
+
+static VALUE
+ip_split_tklist(self, list_str)
+ VALUE self;
+ VALUE list_str;
+{
+ return lib_split_tklist_core(self, list_str);
+}
+
+static VALUE
+lib_merge_tklist(argc, argv, obj)
+ int argc;
+ VALUE *argv;
+ VALUE obj;
+{
+ int num, len;
+ int *flagPtr;
+ char *dst, *result;
+ volatile VALUE str;
+ int taint_flag = 0;
+ int thr_crit_bup;
+ VALUE old_gc;
+
+ if (argc == 0) return rb_str_new2("");
+
+ tcl_stubs_check();
+
+ thr_crit_bup = rb_thread_critical;
+ rb_thread_critical = Qtrue;
+ old_gc = rb_gc_disable();
+
+ /* based on Tcl/Tk's Tcl_Merge() */
+ /* flagPtr = ALLOC_N(int, argc); */
+ flagPtr = RbTk_ALLOC_N(int, argc);
+#if 0 /* use Tcl_Preserve/Release */
+ Tcl_Preserve((ClientData)flagPtr); /* XXXXXXXXXX */
+#endif
+
+ /* pass 1 */
+ len = 1;
+ for(num = 0; num < argc; num++) {
+ if (OBJ_TAINTED(argv[num])) taint_flag = 1;
+ dst = StringValuePtr(argv[num]);
+#if TCL_MAJOR_VERSION >= 8
+ len += Tcl_ScanCountedElement(dst, RSTRING_LENINT(argv[num]),
+ &flagPtr[num]) + 1;
+#else /* TCL_MAJOR_VERSION < 8 */
+ len += Tcl_ScanElement(dst, &flagPtr[num]) + 1;
+#endif
+ }
+
+ /* pass 2 */
+ /* result = (char *)Tcl_Alloc(len); */
+ result = (char *)ckalloc(len);
+#if 0 /* use Tcl_Preserve/Release */
+ Tcl_Preserve((ClientData)result);
+#endif
+ dst = result;
+ for(num = 0; num < argc; num++) {
+#if TCL_MAJOR_VERSION >= 8
+ len = Tcl_ConvertCountedElement(RSTRING_PTR(argv[num]),
+ RSTRING_LENINT(argv[num]),
+ dst, flagPtr[num]);
+#else /* TCL_MAJOR_VERSION < 8 */
+ len = Tcl_ConvertElement(RSTRING_PTR(argv[num]), dst, flagPtr[num]);
+#endif
+ dst += len;
+ *dst = ' ';
+ dst++;
+ }
+ if (dst == result) {
+ *dst = 0;
+ } else {
+ dst[-1] = 0;
+ }
+
+#if 0 /* use Tcl_EventuallyFree */
+ Tcl_EventuallyFree((ClientData)flagPtr, TCL_DYNAMIC); /* XXXXXXXX */
+#else
+#if 0 /* use Tcl_Preserve/Release */
+ Tcl_Release((ClientData)flagPtr);
+#else
+ /* free(flagPtr); */
+ ckfree((char*)flagPtr);
+#endif
+#endif
+
+ /* create object */
+ str = rb_str_new(result, dst - result - 1);
+ if (taint_flag) RbTk_OBJ_UNTRUST(str);
+#if 0 /* use Tcl_EventuallyFree */
+ Tcl_EventuallyFree((ClientData)result, TCL_DYNAMIC); /* XXXXXXXX */
+#else
+#if 0 /* use Tcl_Preserve/Release */
+ Tcl_Release((ClientData)result); /* XXXXXXXXXXX */
+#else
+ /* Tcl_Free(result); */
+ ckfree(result);
+#endif
+#endif
+
+ if (old_gc == Qfalse) rb_gc_enable();
+ rb_thread_critical = thr_crit_bup;
+
+ return str;
+}
+
+static VALUE
+lib_conv_listelement(self, src)
+ VALUE self;
+ VALUE src;
+{
+ int len, scan_flag;
+ volatile VALUE dst;
+ int taint_flag = OBJ_TAINTED(src);
+ int thr_crit_bup;
+
+ tcl_stubs_check();
+
+ thr_crit_bup = rb_thread_critical;
+ rb_thread_critical = Qtrue;
+
+ StringValue(src);
+
+#if TCL_MAJOR_VERSION >= 8
+ len = Tcl_ScanCountedElement(RSTRING_PTR(src), RSTRING_LENINT(src),
+ &scan_flag);
+ dst = rb_str_new(0, len + 1);
+ len = Tcl_ConvertCountedElement(RSTRING_PTR(src), RSTRING_LENINT(src),
+ RSTRING_PTR(dst), scan_flag);
+#else /* TCL_MAJOR_VERSION < 8 */
+ len = Tcl_ScanElement(RSTRING_PTR(src), &scan_flag);
+ dst = rb_str_new(0, len + 1);
+ len = Tcl_ConvertElement(RSTRING_PTR(src), RSTRING_PTR(dst), scan_flag);
+#endif
+
+ rb_str_resize(dst, len);
+ if (taint_flag) RbTk_OBJ_UNTRUST(dst);
+
+ rb_thread_critical = thr_crit_bup;
+
+ return dst;
+}
+
+static VALUE
+lib_getversion(self)
+ VALUE self;
+{
+ set_tcltk_version();
+
+ return rb_ary_new3(4, INT2NUM(tcltk_version.major),
+ INT2NUM(tcltk_version.minor),
+ INT2NUM(tcltk_version.type),
+ INT2NUM(tcltk_version.patchlevel));
+}
+
+static VALUE
+lib_get_reltype_name(self)
+ VALUE self;
+{
+ set_tcltk_version();
+
+ switch(tcltk_version.type) {
+ case TCL_ALPHA_RELEASE:
+ return rb_str_new2("alpha");
+ case TCL_BETA_RELEASE:
+ return rb_str_new2("beta");
+ case TCL_FINAL_RELEASE:
+ return rb_str_new2("final");
+ default:
+ rb_raise(rb_eRuntimeError, "tcltklib has invalid release type number");
+ }
+
+ UNREACHABLE;
+}
+
+
+static VALUE
+tcltklib_compile_info(void)
+{
+ volatile VALUE ret;
+ size_t size;
+ static CONST char form[]
+ = "tcltklib %s :: Ruby%s (%s) %s pthread :: Tcl%s(%s)/Tk%s(%s) %s";
+ char *info;
+
+ size = strlen(form)
+ + strlen(TCLTKLIB_RELEASE_DATE)
+ + strlen(RUBY_VERSION)
+ + strlen(RUBY_RELEASE_DATE)
+ + strlen("without")
+ + strlen(TCL_PATCH_LEVEL)
+ + strlen("without stub")
+ + strlen(TK_PATCH_LEVEL)
+ + strlen("without stub")
+ + strlen("unknown tcl_threads");
+
+ info = ALLOC_N(char, size);
+ /* info = ckalloc(sizeof(char) * size); */ /* SEGV */
+
+ sprintf(info, form,
+ TCLTKLIB_RELEASE_DATE,
+ RUBY_VERSION, RUBY_RELEASE_DATE,
+#ifdef HAVE_NATIVETHREAD
+ "with",
+#else
+ "without",
+#endif
+ TCL_PATCH_LEVEL,
+#ifdef USE_TCL_STUBS
+ "with stub",
+#else
+ "without stub",
+#endif
+ TK_PATCH_LEVEL,
+#ifdef USE_TK_STUBS
+ "with stub",
+#else
+ "without stub",
+#endif
+#ifdef WITH_TCL_ENABLE_THREAD
+# if WITH_TCL_ENABLE_THREAD
+ "with tcl_threads"
+# else
+ "without tcl_threads"
+# endif
+#else
+ "unknown tcl_threads"
+#endif
+ );
+
+ ret = rb_obj_freeze(rb_str_new2(info));
+
+ xfree(info);
+ /* ckfree(info); */
+
+ return ret;
+}
+
+
+/*###############################################*/
+
+static VALUE
+create_dummy_encoding_for_tk_core(interp, name, error_mode)
+ VALUE interp;
+ VALUE name;
+ VALUE error_mode;
+{
+ get_ip(interp);
+
+
+ StringValue(name);
+
+#if TCL_MAJOR_VERSION > 8 || (TCL_MAJOR_VERSION == 8 && TCL_MINOR_VERSION >= 1)
+ if (Tcl_GetEncoding((Tcl_Interp*)NULL, RSTRING_PTR(name)) == (Tcl_Encoding)NULL) {
+ if (RTEST(error_mode)) {
+ rb_raise(rb_eArgError, "invalid Tk encoding name '%s'",
+ RSTRING_PTR(name));
+ } else {
+ return Qnil;
+ }
+ }
+#endif
+
+#ifdef HAVE_RUBY_ENCODING_H
+ if (RTEST(rb_define_dummy_encoding(RSTRING_PTR(name)))) {
+ int idx = rb_enc_find_index(StringValueCStr(name));
+ return rb_enc_from_encoding(rb_enc_from_index(idx));
+ } else {
+ if (RTEST(error_mode)) {
+ rb_raise(rb_eRuntimeError, "fail to create dummy encoding for '%s'",
+ RSTRING_PTR(name));
+ } else {
+ return Qnil;
+ }
+ }
+
+ UNREACHABLE;
+#else
+ return name;
+#endif
+}
+static VALUE
+create_dummy_encoding_for_tk(interp, name)
+ VALUE interp;
+ VALUE name;
+{
+ return create_dummy_encoding_for_tk_core(interp, name, Qtrue);
+}
+
+
+#ifdef HAVE_RUBY_ENCODING_H
+static int
+update_encoding_table(table, interp, error_mode)
+ VALUE table;
+ VALUE interp;
+ VALUE error_mode;
+{
+ struct tcltkip *ptr;
+ int retry = 0;
+ int i, idx, objc;
+ Tcl_Obj **objv;
+ Tcl_Obj *enc_list;
+ volatile VALUE encname = Qnil;
+ volatile VALUE encobj = Qnil;
+
+ /* interpreter check */
+ if (NIL_P(interp)) return 0;
+ ptr = get_ip(interp);
+ if (ptr == (struct tcltkip *) NULL) return 0;
+ if (deleted_ip(ptr)) return 0;
+
+ /* get Tcl's encoding list */
+ Tcl_GetEncodingNames(ptr->ip);
+ enc_list = Tcl_GetObjResult(ptr->ip);
+ Tcl_IncrRefCount(enc_list);
+
+ if (Tcl_ListObjGetElements(ptr->ip, enc_list,
+ &objc, &objv) != TCL_OK) {
+ Tcl_DecrRefCount(enc_list);
+ /* rb_raise(rb_eRuntimeError, "failt to get Tcl's encoding names");*/
+ return 0;
+ }
+
+ /* check each encoding name */
+ for(i = 0; i < objc; i++) {
+ encname = rb_str_new2(Tcl_GetString(objv[i]));
+ if (NIL_P(rb_hash_lookup(table, encname))) {
+ /* new Tk encoding -> add to table */
+ idx = rb_enc_find_index(StringValueCStr(encname));
+ if (idx < 0) {
+ encobj = create_dummy_encoding_for_tk_core(interp,encname,error_mode);
+ } else {
+ encobj = rb_enc_from_encoding(rb_enc_from_index(idx));
+ }
+ encname = rb_obj_freeze(encname);
+ rb_hash_aset(table, encname, encobj);
+ if (!NIL_P(encobj) && NIL_P(rb_hash_lookup(table, encobj))) {
+ rb_hash_aset(table, encobj, encname);
+ }
+ retry = 1;
+ }
+ }
+
+ Tcl_DecrRefCount(enc_list);
+
+ return retry;
+}
+
+static VALUE
+encoding_table_get_name_core(table, enc_arg, error_mode)
+ VALUE table;
+ VALUE enc_arg;
+ VALUE error_mode;
+{
+ volatile VALUE enc = enc_arg;
+ volatile VALUE name = Qnil;
+ volatile VALUE tmp = Qnil;
+ volatile VALUE interp = rb_ivar_get(table, ID_at_interp);
+ struct tcltkip *ptr = (struct tcltkip *) NULL;
+ int idx;
+
+ /* deleted interp ? */
+ if (!NIL_P(interp)) {
+ ptr = get_ip(interp);
+ if (deleted_ip(ptr)) {
+ ptr = (struct tcltkip *) NULL;
+ }
+ }
+
+ /* encoding argument check */
+ /* 1st: default encoding setting of interp */
+ if (ptr && NIL_P(enc)) {
+ if (rb_respond_to(interp, ID_encoding_name)) {
+ enc = rb_funcall(interp, ID_encoding_name, 0, 0);
+ }
+ }
+ /* 2nd: Encoding.default_internal */
+ if (NIL_P(enc)) {
+ enc = rb_enc_default_internal();
+ }
+ /* 3rd: encoding system of Tcl/Tk */
+ if (NIL_P(enc)) {
+ enc = rb_str_new2(Tcl_GetEncodingName((Tcl_Encoding)NULL));
+ }
+ /* 4th: Encoding.default_external */
+ if (NIL_P(enc)) {
+ enc = rb_enc_default_external();
+ }
+ /* 5th: Encoding.locale_charmap */
+ if (NIL_P(enc)) {
+ enc = rb_locale_charmap(rb_cEncoding);
+ }
+
+ if (RTEST(rb_obj_is_kind_of(enc, cRubyEncoding))) {
+ /* Ruby's Encoding object */
+ name = rb_hash_lookup(table, enc);
+ if (!NIL_P(name)) {
+ /* find */
+ return name;
+ }
+
+ /* is it new ? */
+ /* update check of Tk encoding names */
+ if (update_encoding_table(table, interp, error_mode)) {
+ /* add new relations to the table */
+ /* RETRY: registered Ruby encoding? */
+ name = rb_hash_lookup(table, enc);
+ if (!NIL_P(name)) {
+ /* find */
+ return name;
+ }
+ }
+ /* fail to find */
+
+ } else {
+ /* String or Symbol? */
+ name = rb_funcall(enc, ID_to_s, 0, 0);
+
+ if (!NIL_P(rb_hash_lookup(table, name))) {
+ /* find */
+ return name;
+ }
+
+ /* is it new ? */
+ idx = rb_enc_find_index(StringValueCStr(name));
+ if (idx >= 0) {
+ enc = rb_enc_from_encoding(rb_enc_from_index(idx));
+
+ /* registered Ruby encoding? */
+ tmp = rb_hash_lookup(table, enc);
+ if (!NIL_P(tmp)) {
+ /* find */
+ return tmp;
+ }
+
+ /* update check of Tk encoding names */
+ if (update_encoding_table(table, interp, error_mode)) {
+ /* add new relations to the table */
+ /* RETRY: registered Ruby encoding? */
+ tmp = rb_hash_lookup(table, enc);
+ if (!NIL_P(tmp)) {
+ /* find */
+ return tmp;
+ }
+ }
+ }
+ /* fail to find */
+ }
+
+ if (RTEST(error_mode)) {
+ enc = rb_funcall(enc_arg, ID_to_s, 0, 0);
+ rb_raise(rb_eArgError, "unsupported Tk encoding '%s'", RSTRING_PTR(enc));
+ }
+ return Qnil;
+}
+static VALUE
+encoding_table_get_obj_core(table, enc, error_mode)
+ VALUE table;
+ VALUE enc;
+ VALUE error_mode;
+{
+ volatile VALUE obj = Qnil;
+
+ obj = rb_hash_lookup(table,
+ encoding_table_get_name_core(table, enc, error_mode));
+ if (RTEST(rb_obj_is_kind_of(obj, cRubyEncoding))) {
+ return obj;
+ } else {
+ return Qnil;
+ }
+}
+
+#else /* ! HAVE_RUBY_ENCODING_H */
+#if TCL_MAJOR_VERSION > 8 || (TCL_MAJOR_VERSION == 8 && TCL_MINOR_VERSION >= 1)
+static int
+update_encoding_table(table, interp, error_mode)
+ VALUE table;
+ VALUE interp;
+ VALUE error_mode;
+{
+ struct tcltkip *ptr;
+ int retry = 0;
+ int i, objc;
+ Tcl_Obj **objv;
+ Tcl_Obj *enc_list;
+ volatile VALUE encname = Qnil;
+
+ /* interpreter check */
+ if (NIL_P(interp)) return 0;
+ ptr = get_ip(interp);
+ if (ptr == (struct tcltkip *) NULL) return 0;
+ if (deleted_ip(ptr)) return 0;
+
+ /* get Tcl's encoding list */
+ Tcl_GetEncodingNames(ptr->ip);
+ enc_list = Tcl_GetObjResult(ptr->ip);
+ Tcl_IncrRefCount(enc_list);
+
+ if (Tcl_ListObjGetElements(ptr->ip, enc_list, &objc, &objv) != TCL_OK) {
+ Tcl_DecrRefCount(enc_list);
+ /* rb_raise(rb_eRuntimeError, "failt to get Tcl's encoding names"); */
+ return 0;
+ }
+
+ /* get encoding name and set it to table */
+ for(i = 0; i < objc; i++) {
+ encname = rb_str_new2(Tcl_GetString(objv[i]));
+ if (NIL_P(rb_hash_lookup(table, encname))) {
+ /* new Tk encoding -> add to table */
+ encname = rb_obj_freeze(encname);
+ rb_hash_aset(table, encname, encname);
+ retry = 1;
+ }
+ }
+
+ Tcl_DecrRefCount(enc_list);
+
+ return retry;
+}
+
+static VALUE
+encoding_table_get_name_core(table, enc, error_mode)
+ VALUE table;
+ VALUE enc;
+ VALUE error_mode;
+{
+ volatile VALUE name = Qnil;
+
+ enc = rb_funcall(enc, ID_to_s, 0, 0);
+ name = rb_hash_lookup(table, enc);
+
+ if (!NIL_P(name)) {
+ /* find */
+ return name;
+ }
+
+ /* update check */
+ if (update_encoding_table(table, rb_ivar_get(table, ID_at_interp),
+ error_mode)) {
+ /* add new relations to the table */
+ /* RETRY: registered Ruby encoding? */
+ name = rb_hash_lookup(table, enc);
+ if (!NIL_P(name)) {
+ /* find */
+ return name;
+ }
+ }
+
+ if (RTEST(error_mode)) {
+ rb_raise(rb_eArgError, "unsupported Tk encoding '%s'", RSTRING_PTR(enc));
+ }
+ return Qnil;
+}
+static VALUE
+encoding_table_get_obj_core(table, enc, error_mode)
+ VALUE table;
+ VALUE enc;
+ VALUE error_mode;
+{
+ return encoding_table_get_name_core(table, enc, error_mode);
+}
+
+#else /* Tcl/Tk 7.x or 8.0 */
+static VALUE
+encoding_table_get_name_core(table, enc, error_mode)
+ VALUE table;
+ VALUE enc;
+ VALUE error_mode;
+{
+ return Qnil;
+}
+static VALUE
+encoding_table_get_obj_core(table, enc, error_mode)
+ VALUE table;
+ VALUE enc;
+ VALUE error_mode;
+{
+ return Qnil;
+}
+#endif /* end of dependency for the version of Tcl/Tk */
+#endif
+
+static VALUE
+encoding_table_get_name(table, enc)
+ VALUE table;
+ VALUE enc;
+{
+ return encoding_table_get_name_core(table, enc, Qtrue);
+}
+static VALUE
+encoding_table_get_obj(table, enc)
+ VALUE table;
+ VALUE enc;
+{
+ return encoding_table_get_obj_core(table, enc, Qtrue);
+}
+
+#ifdef HAVE_RUBY_ENCODING_H
+static VALUE
+create_encoding_table_core(arg, interp)
+ VALUE arg;
+ VALUE interp;
+{
+ struct tcltkip *ptr = get_ip(interp);
+ volatile VALUE table = rb_hash_new();
+ volatile VALUE encname = Qnil;
+ volatile VALUE encobj = Qnil;
+ int i, idx, objc;
+ Tcl_Obj **objv;
+ Tcl_Obj *enc_list;
+
+#ifdef HAVE_RB_SET_SAFE_LEVEL_FORCE
+ rb_set_safe_level_force(0);
+#else
+ rb_set_safe_level(0);
+#endif
+
+ /* set 'binary' encoding */
+ encobj = rb_enc_from_encoding(rb_enc_from_index(ENCODING_INDEX_BINARY));
+ rb_hash_aset(table, ENCODING_NAME_BINARY, encobj);
+ rb_hash_aset(table, encobj, ENCODING_NAME_BINARY);
+
+
+ /* Tcl stub check */
+ tcl_stubs_check();
+
+ /* get Tcl's encoding list */
+ Tcl_GetEncodingNames(ptr->ip);
+ enc_list = Tcl_GetObjResult(ptr->ip);
+ Tcl_IncrRefCount(enc_list);
+
+ if (Tcl_ListObjGetElements(ptr->ip, enc_list, &objc, &objv) != TCL_OK) {
+ Tcl_DecrRefCount(enc_list);
+ rb_raise(rb_eRuntimeError, "failt to get Tcl's encoding names");
+ }
+
+ /* get encoding name and set it to table */
+ for(i = 0; i < objc; i++) {
+ int name2obj, obj2name;
+
+ name2obj = 1; obj2name = 1;
+ encname = rb_obj_freeze(rb_str_new2(Tcl_GetString(objv[i])));
+ idx = rb_enc_find_index(StringValueCStr(encname));
+ if (idx < 0) {
+ /* fail to find ruby encoding -> check known encoding */
+ if (strcmp(RSTRING_PTR(encname), "identity") == 0) {
+ name2obj = 1; obj2name = 0;
+ idx = ENCODING_INDEX_BINARY;
+
+ } else if (strcmp(RSTRING_PTR(encname), "shiftjis") == 0) {
+ name2obj = 1; obj2name = 0;
+ idx = rb_enc_find_index("Shift_JIS");
+
+ } else if (strcmp(RSTRING_PTR(encname), "unicode") == 0) {
+ name2obj = 1; obj2name = 0;
+ idx = ENCODING_INDEX_UTF8;
+
+ } else if (strcmp(RSTRING_PTR(encname), "symbol") == 0) {
+ name2obj = 1; obj2name = 0;
+ idx = rb_enc_find_index("ASCII-8BIT");
+
+ } else {
+ /* regist dummy encoding */
+ name2obj = 1; obj2name = 1;
+ }
+ }
+
+ if (idx < 0) {
+ /* unknown encoding -> create dummy */
+ encobj = create_dummy_encoding_for_tk(interp, encname);
+ } else {
+ encobj = rb_enc_from_encoding(rb_enc_from_index(idx));
+ }
+
+ if (name2obj) {
+ DUMP2("create_encoding_table: name2obj: %s", RSTRING_PTR(encname));
+ rb_hash_aset(table, encname, encobj);
+ }
+ if (obj2name) {
+ DUMP2("create_encoding_table: obj2name: %s", RSTRING_PTR(encname));
+ rb_hash_aset(table, encobj, encname);
+ }
+ }
+
+ Tcl_DecrRefCount(enc_list);
+
+ rb_ivar_set(table, ID_at_interp, interp);
+ rb_ivar_set(interp, ID_encoding_table, table);
+
+ return table;
+}
+
+#else /* ! HAVE_RUBY_ENCODING_H */
+#if TCL_MAJOR_VERSION > 8 || (TCL_MAJOR_VERSION == 8 && TCL_MINOR_VERSION >= 1)
+static VALUE
+create_encoding_table_core(arg, interp)
+ VALUE arg;
+ VALUE interp;
+{
+ struct tcltkip *ptr = get_ip(interp);
+ volatile VALUE table = rb_hash_new();
+ volatile VALUE encname = Qnil;
+ int i, objc;
+ Tcl_Obj **objv;
+ Tcl_Obj *enc_list;
+
+
+ /* set 'binary' encoding */
+ rb_hash_aset(table, ENCODING_NAME_BINARY, ENCODING_NAME_BINARY);
+
+ /* get Tcl's encoding list */
+ Tcl_GetEncodingNames(ptr->ip);
+ enc_list = Tcl_GetObjResult(ptr->ip);
+ Tcl_IncrRefCount(enc_list);
+
+ if (Tcl_ListObjGetElements(ptr->ip, enc_list, &objc, &objv) != TCL_OK) {
+ Tcl_DecrRefCount(enc_list);
+ rb_raise(rb_eRuntimeError, "failt to get Tcl's encoding names");
+ }
+
+ /* get encoding name and set it to table */
+ for(i = 0; i < objc; i++) {
+ encname = rb_obj_freeze(rb_str_new2(Tcl_GetString(objv[i])));
+ rb_hash_aset(table, encname, encname);
+ }
+
+ Tcl_DecrRefCount(enc_list);
+
+ rb_ivar_set(table, ID_at_interp, interp);
+ rb_ivar_set(interp, ID_encoding_table, table);
+
+ return table;
+}
+
+#else /* Tcl/Tk 7.x or 8.0 */
+static VALUE
+create_encoding_table_core(arg, interp)
+ VALUE arg;
+ VALUE interp;
+{
+ volatile VALUE table = rb_hash_new();
+ rb_ivar_set(interp, ID_encoding_table, table);
+ return table;
+}
+#endif
+#endif
+
+static VALUE
+create_encoding_table(interp)
+ VALUE interp;
+{
+ return rb_funcall(rb_proc_new(create_encoding_table_core, interp),
+ ID_call, 0);
+}
+
+static VALUE
+ip_get_encoding_table(interp)
+ VALUE interp;
+{
+ volatile VALUE table = Qnil;
+
+ table = rb_ivar_get(interp, ID_encoding_table);
+
+ if (NIL_P(table)) {
+ /* initialize encoding_table */
+ table = create_encoding_table(interp);
+ rb_define_singleton_method(table, "get_name", encoding_table_get_name, 1);
+ rb_define_singleton_method(table, "get_obj", encoding_table_get_obj, 1);
+ }
+
+ return table;
+}
+
+
+/*###############################################*/
+
+/*
+ * The following is based on tkMenu.[ch]
+ * of Tcl/Tk (Tk8.0 -- Tk8.5b1) source code.
+ */
+#if TCL_MAJOR_VERSION >= 8
+
+#define MASTER_MENU 0
+#define TEAROFF_MENU 1
+#define MENUBAR 2
+
+struct dummy_TkMenuEntry {
+ int type;
+ struct dummy_TkMenu *menuPtr;
+ /* , and etc. */
+};
+
+struct dummy_TkMenu {
+ Tk_Window tkwin;
+ Display *display;
+ Tcl_Interp *interp;
+ Tcl_Command widgetCmd;
+ struct dummy_TkMenuEntry **entries;
+ int numEntries;
+ int active;
+ int menuType; /* MASTER_MENU, TEAROFF_MENU, or MENUBAR */
+ Tcl_Obj *menuTypePtr;
+ /* , and etc. */
+};
+
+struct dummy_TkMenuRef {
+ struct dummy_TkMenu *menuPtr;
+ char *dummy1;
+ char *dummy2;
+ char *dummy3;
+};
+
+#if 0 /* was available on Tk8.0 -- Tk8.4 */
+EXTERN struct dummy_TkMenuRef *TkFindMenuReferences(Tcl_Interp*, char*);
+#else /* based on Tk8.0 -- Tk8.5.0 */
+#define MENU_HASH_KEY "tkMenus"
+#endif
+
+#endif
+
+static VALUE
+ip_make_menu_embeddable_core(interp, argc, argv)
+ VALUE interp;
+ int argc;
+ VALUE *argv;
+{
+#if TCL_MAJOR_VERSION >= 8
+ volatile VALUE menu_path;
+ struct tcltkip *ptr = get_ip(interp);
+ struct dummy_TkMenuRef *menuRefPtr = NULL;
+ XEvent event;
+ Tcl_HashTable *menuTablePtr;
+ Tcl_HashEntry *hashEntryPtr;
+
+ menu_path = argv[0];
+ StringValue(menu_path);
+
+#if 0 /* was available on Tk8.0 -- Tk8.4 */
+ menuRefPtr = TkFindMenuReferences(ptr->ip, RSTRING_PTR(menu_path));
+#else /* based on Tk8.0 -- Tk8.5b1 */
+ if ((menuTablePtr
+ = (Tcl_HashTable *) Tcl_GetAssocData(ptr->ip, MENU_HASH_KEY, NULL))
+ != NULL) {
+ if ((hashEntryPtr
+ = Tcl_FindHashEntry(menuTablePtr, RSTRING_PTR(menu_path)))
+ != NULL) {
+ menuRefPtr = (struct dummy_TkMenuRef *) Tcl_GetHashValue(hashEntryPtr);
+ }
+ }
+#endif
+
+ if (menuRefPtr == (struct dummy_TkMenuRef *) NULL) {
+ rb_raise(rb_eArgError, "not a menu widget, or invalid widget path");
+ }
+
+ if (menuRefPtr->menuPtr == (struct dummy_TkMenu *) NULL) {
+ rb_raise(rb_eRuntimeError,
+ "invalid menu widget (maybe already destroyed)");
+ }
+
+ if ((menuRefPtr->menuPtr)->menuType != MENUBAR) {
+ rb_raise(rb_eRuntimeError,
+ "target menu widget must be a MENUBAR type");
+ }
+
+ (menuRefPtr->menuPtr)->menuType = TEAROFF_MENU;
+#if 0 /* cause SEGV */
+ {
+ /* char *s = "tearoff"; */
+ char *s = "normal";
+ /* Tcl_SetStringObj((menuRefPtr->menuPtr)->menuTypePtr, s, strlen(s));*/
+ (menuRefPtr->menuPtr)->menuTypePtr = Tcl_NewStringObj(s, strlen(s));
+ /* Tcl_IncrRefCount((menuRefPtr->menuPtr)->menuTypePtr); */
+ /* (menuRefPtr->menuPtr)->menuType = TEAROFF_MENU; */
+ (menuRefPtr->menuPtr)->menuType = MASTER_MENU;
+ }
+#endif
+
+#if 0 /* was available on Tk8.0 -- Tk8.4 */
+ TkEventuallyRecomputeMenu(menuRefPtr->menuPtr);
+ TkEventuallyRedrawMenu(menuRefPtr->menuPtr,
+ (struct dummy_TkMenuEntry *)NULL);
+#else /* based on Tk8.0 -- Tk8.5b1 */
+ memset((void *) &event, 0, sizeof(event));
+ event.xany.type = ConfigureNotify;
+ event.xany.serial = NextRequest(Tk_Display((menuRefPtr->menuPtr)->tkwin));
+ event.xany.send_event = 0; /* FALSE */
+ event.xany.window = Tk_WindowId((menuRefPtr->menuPtr)->tkwin);
+ event.xany.display = Tk_Display((menuRefPtr->menuPtr)->tkwin);
+ event.xconfigure.window = event.xany.window;
+ Tk_HandleEvent(&event);
+#endif
+
+#else /* TCL_MAJOR_VERSION <= 7 */
+ rb_notimplement();
+#endif
+
+ return interp;
+}
+
+static VALUE
+ip_make_menu_embeddable(interp, menu_path)
+ VALUE interp;
+ VALUE menu_path;
+{
+ VALUE argv[1];
+
+ argv[0] = menu_path;
+ return tk_funcall(ip_make_menu_embeddable_core, 1, argv, interp);
+}
+
+
+/*###############################################*/
+
+/*---- initialization ----*/
+void
+Init_tcltklib(void)
+{
+ int ret;
+
+ VALUE lib = rb_define_module("TclTkLib");
+ VALUE ip = rb_define_class("TclTkIp", rb_cObject);
+
+ VALUE ev_flag = rb_define_module_under(lib, "EventFlag");
+ VALUE var_flag = rb_define_module_under(lib, "VarAccessFlag");
+ VALUE release_type = rb_define_module_under(lib, "RELEASE_TYPE");
+
+ /* --------------------------------------------------------------- */
+
+ tcltkip_class = ip;
+
+ /* --------------------------------------------------------------- */
+
+#ifdef HAVE_RUBY_ENCODING_H
+ rb_global_variable(&cRubyEncoding);
+ cRubyEncoding = rb_path2class("Encoding");
+
+ ENCODING_INDEX_UTF8 = rb_enc_to_index(rb_utf8_encoding());
+ ENCODING_INDEX_BINARY = rb_enc_find_index("binary");
+#endif
+
+ rb_global_variable(&ENCODING_NAME_UTF8);
+ rb_global_variable(&ENCODING_NAME_BINARY);
+
+ ENCODING_NAME_UTF8 = rb_obj_freeze(rb_str_new2("utf-8"));
+ ENCODING_NAME_BINARY = rb_obj_freeze(rb_str_new2("binary"));
+
+ /* --------------------------------------------------------------- */
+
+ rb_global_variable(&eTkCallbackReturn);
+ rb_global_variable(&eTkCallbackBreak);
+ rb_global_variable(&eTkCallbackContinue);
+
+ rb_global_variable(&eventloop_thread);
+ rb_global_variable(&eventloop_stack);
+ rb_global_variable(&watchdog_thread);
+
+ rb_global_variable(&rbtk_pending_exception);
+
+ /* --------------------------------------------------------------- */
+
+ rb_define_const(lib, "COMPILE_INFO", tcltklib_compile_info());
+
+ rb_define_const(lib, "RELEASE_DATE",
+ rb_obj_freeze(rb_str_new2(tcltklib_release_date)));
+
+ rb_define_const(lib, "FINALIZE_PROC_NAME",
+ rb_str_new2(finalize_hook_name));
+
+ /* --------------------------------------------------------------- */
+
+#ifdef __WIN32__
+# define TK_WINDOWING_SYSTEM "win32"
+#else
+# ifdef MAC_TCL
+# define TK_WINDOWING_SYSTEM "classic"
+# else
+# ifdef MAC_OSX_TK
+# define TK_WINDOWING_SYSTEM "aqua"
+# else
+# define TK_WINDOWING_SYSTEM "x11"
+# endif
+# endif
+#endif
+ rb_define_const(lib, "WINDOWING_SYSTEM",
+ rb_obj_freeze(rb_str_new2(TK_WINDOWING_SYSTEM)));
+
+ /* --------------------------------------------------------------- */
+
+ rb_define_const(ev_flag, "NONE", INT2FIX(0));
+ rb_define_const(ev_flag, "WINDOW", INT2FIX(TCL_WINDOW_EVENTS));
+ rb_define_const(ev_flag, "FILE", INT2FIX(TCL_FILE_EVENTS));
+ rb_define_const(ev_flag, "TIMER", INT2FIX(TCL_TIMER_EVENTS));
+ rb_define_const(ev_flag, "IDLE", INT2FIX(TCL_IDLE_EVENTS));
+ rb_define_const(ev_flag, "ALL", INT2FIX(TCL_ALL_EVENTS));
+ rb_define_const(ev_flag, "DONT_WAIT", INT2FIX(TCL_DONT_WAIT));
+
+ /* --------------------------------------------------------------- */
+
+ rb_define_const(var_flag, "NONE", INT2FIX(0));
+ rb_define_const(var_flag, "GLOBAL_ONLY", INT2FIX(TCL_GLOBAL_ONLY));
+#ifdef TCL_NAMESPACE_ONLY
+ rb_define_const(var_flag, "NAMESPACE_ONLY", INT2FIX(TCL_NAMESPACE_ONLY));
+#else /* probably Tcl7.6 */
+ rb_define_const(var_flag, "NAMESPACE_ONLY", INT2FIX(0));
+#endif
+ rb_define_const(var_flag, "LEAVE_ERR_MSG", INT2FIX(TCL_LEAVE_ERR_MSG));
+ rb_define_const(var_flag, "APPEND_VALUE", INT2FIX(TCL_APPEND_VALUE));
+ rb_define_const(var_flag, "LIST_ELEMENT", INT2FIX(TCL_LIST_ELEMENT));
+#ifdef TCL_PARSE_PART1
+ rb_define_const(var_flag, "PARSE_VARNAME", INT2FIX(TCL_PARSE_PART1));
+#else /* probably Tcl7.6 */
+ rb_define_const(var_flag, "PARSE_VARNAME", INT2FIX(0));
+#endif
+
+ /* --------------------------------------------------------------- */
+
+ rb_define_module_function(lib, "get_version", lib_getversion, -1);
+ rb_define_module_function(lib, "get_release_type_name",
+ lib_get_reltype_name, -1);
+
+ rb_define_const(release_type, "ALPHA", INT2FIX(TCL_ALPHA_RELEASE));
+ rb_define_const(release_type, "BETA", INT2FIX(TCL_BETA_RELEASE));
+ rb_define_const(release_type, "FINAL", INT2FIX(TCL_FINAL_RELEASE));
+
+ /* --------------------------------------------------------------- */
+
+ eTkCallbackReturn = rb_define_class("TkCallbackReturn", rb_eStandardError);
+ eTkCallbackBreak = rb_define_class("TkCallbackBreak", rb_eStandardError);
+ eTkCallbackContinue = rb_define_class("TkCallbackContinue",
+ rb_eStandardError);
+
+ /* --------------------------------------------------------------- */
+
+ eLocalJumpError = rb_const_get(rb_cObject, rb_intern("LocalJumpError"));
+
+ eTkLocalJumpError = rb_define_class("TkLocalJumpError", eLocalJumpError);
+
+ eTkCallbackRetry = rb_define_class("TkCallbackRetry", eTkLocalJumpError);
+ eTkCallbackRedo = rb_define_class("TkCallbackRedo", eTkLocalJumpError);
+ eTkCallbackThrow = rb_define_class("TkCallbackThrow", eTkLocalJumpError);
+
+ /* --------------------------------------------------------------- */
+
+ ID_at_enc = rb_intern("@encoding");
+ ID_at_interp = rb_intern("@interp");
+ ID_encoding_name = rb_intern("encoding_name");
+ ID_encoding_table = rb_intern("encoding_table");
+
+ ID_stop_p = rb_intern("stop?");
+#ifndef HAVE_RB_THREAD_ALIVE_P
+ ID_alive_p = rb_intern("alive?");
+#endif
+ ID_kill = rb_intern("kill");
+ ID_join = rb_intern("join");
+ ID_value = rb_intern("value");
+
+ ID_call = rb_intern("call");
+ ID_backtrace = rb_intern("backtrace");
+ ID_message = rb_intern("message");
+
+ ID_at_reason = rb_intern("@reason");
+ ID_return = rb_intern("return");
+ ID_break = rb_intern("break");
+ ID_next = rb_intern("next");
+
+ ID_to_s = rb_intern("to_s");
+ ID_inspect = rb_intern("inspect");
+
+ /* --------------------------------------------------------------- */
+
+ rb_define_module_function(lib, "mainloop", lib_mainloop, -1);
+ rb_define_module_function(lib, "mainloop_thread?",
+ lib_evloop_thread_p, 0);
+ rb_define_module_function(lib, "mainloop_watchdog",
+ lib_mainloop_watchdog, -1);
+ rb_define_module_function(lib, "do_thread_callback",
+ lib_thread_callback, -1);
+ rb_define_module_function(lib, "do_one_event", lib_do_one_event, -1);
+ rb_define_module_function(lib, "mainloop_abort_on_exception",
+ lib_evloop_abort_on_exc, 0);
+ rb_define_module_function(lib, "mainloop_abort_on_exception=",
+ lib_evloop_abort_on_exc_set, 1);
+ rb_define_module_function(lib, "set_eventloop_window_mode",
+ set_eventloop_window_mode, 1);
+ rb_define_module_function(lib, "get_eventloop_window_mode",
+ get_eventloop_window_mode, 0);
+ rb_define_module_function(lib, "set_eventloop_tick",set_eventloop_tick,1);
+ rb_define_module_function(lib, "get_eventloop_tick",get_eventloop_tick,0);
+ rb_define_module_function(lib, "set_no_event_wait", set_no_event_wait, 1);
+ rb_define_module_function(lib, "get_no_event_wait", get_no_event_wait, 0);
+ rb_define_module_function(lib, "set_eventloop_weight",
+ set_eventloop_weight, 2);
+ rb_define_module_function(lib, "set_max_block_time", set_max_block_time,1);
+ rb_define_module_function(lib, "get_eventloop_weight",
+ get_eventloop_weight, 0);
+ rb_define_module_function(lib, "num_of_mainwindows",
+ lib_num_of_mainwindows, 0);
+
+ /* --------------------------------------------------------------- */
+
+ rb_define_module_function(lib, "_split_tklist", lib_split_tklist, 1);
+ rb_define_module_function(lib, "_merge_tklist", lib_merge_tklist, -1);
+ rb_define_module_function(lib, "_conv_listelement",
+ lib_conv_listelement, 1);
+ rb_define_module_function(lib, "_toUTF8", lib_toUTF8, -1);
+ rb_define_module_function(lib, "_fromUTF8", lib_fromUTF8, -1);
+ rb_define_module_function(lib, "_subst_UTF_backslash",
+ lib_UTF_backslash, 1);
+ rb_define_module_function(lib, "_subst_Tcl_backslash",
+ lib_Tcl_backslash, 1);
+
+ rb_define_module_function(lib, "encoding_system",
+ lib_get_system_encoding, 0);
+ rb_define_module_function(lib, "encoding_system=",
+ lib_set_system_encoding, 1);
+ rb_define_module_function(lib, "encoding",
+ lib_get_system_encoding, 0);
+ rb_define_module_function(lib, "encoding=",
+ lib_set_system_encoding, 1);
+
+ /* --------------------------------------------------------------- */
+
+ rb_define_alloc_func(ip, ip_alloc);
+ rb_define_method(ip, "initialize", ip_init, -1);
+ rb_define_method(ip, "create_slave", ip_create_slave, -1);
+ rb_define_method(ip, "slave_of?", ip_is_slave_of_p, 1);
+ rb_define_method(ip, "make_safe", ip_make_safe, 0);
+ rb_define_method(ip, "safe?", ip_is_safe_p, 0);
+ rb_define_method(ip, "allow_ruby_exit?", ip_allow_ruby_exit_p, 0);
+ rb_define_method(ip, "allow_ruby_exit=", ip_allow_ruby_exit_set, 1);
+ rb_define_method(ip, "delete", ip_delete, 0);
+ rb_define_method(ip, "deleted?", ip_is_deleted_p, 0);
+ rb_define_method(ip, "has_mainwindow?", ip_has_mainwindow_p, 0);
+ rb_define_method(ip, "invalid_namespace?", ip_has_invalid_namespace_p, 0);
+ rb_define_method(ip, "_eval", ip_eval, 1);
+ rb_define_method(ip, "_cancel_eval", ip_cancel_eval, -1);
+ rb_define_method(ip, "_cancel_eval_unwind", ip_cancel_eval_unwind, -1);
+ rb_define_method(ip, "_toUTF8", ip_toUTF8, -1);
+ rb_define_method(ip, "_fromUTF8", ip_fromUTF8, -1);
+ rb_define_method(ip, "_thread_vwait", ip_thread_vwait, 1);
+ rb_define_method(ip, "_thread_tkwait", ip_thread_tkwait, 2);
+ rb_define_method(ip, "_invoke", ip_invoke, -1);
+ rb_define_method(ip, "_immediate_invoke", ip_invoke_immediate, -1);
+ rb_define_method(ip, "_return_value", ip_retval, 0);
+
+ rb_define_method(ip, "_create_console", ip_create_console, 0);
+
+ /* --------------------------------------------------------------- */
+
+ rb_define_method(ip, "create_dummy_encoding_for_tk",
+ create_dummy_encoding_for_tk, 1);
+ rb_define_method(ip, "encoding_table", ip_get_encoding_table, 0);
+
+ /* --------------------------------------------------------------- */
+
+ rb_define_method(ip, "_get_variable", ip_get_variable, 2);
+ rb_define_method(ip, "_get_variable2", ip_get_variable2, 3);
+ rb_define_method(ip, "_set_variable", ip_set_variable, 3);
+ rb_define_method(ip, "_set_variable2", ip_set_variable2, 4);
+ rb_define_method(ip, "_unset_variable", ip_unset_variable, 2);
+ rb_define_method(ip, "_unset_variable2", ip_unset_variable2, 3);
+ rb_define_method(ip, "_get_global_var", ip_get_global_var, 1);
+ rb_define_method(ip, "_get_global_var2", ip_get_global_var2, 2);
+ rb_define_method(ip, "_set_global_var", ip_set_global_var, 2);
+ rb_define_method(ip, "_set_global_var2", ip_set_global_var2, 3);
+ rb_define_method(ip, "_unset_global_var", ip_unset_global_var, 1);
+ rb_define_method(ip, "_unset_global_var2", ip_unset_global_var2, 2);
+
+ /* --------------------------------------------------------------- */
+
+ rb_define_method(ip, "_make_menu_embeddable", ip_make_menu_embeddable, 1);
+
+ /* --------------------------------------------------------------- */
+
+ rb_define_method(ip, "_split_tklist", ip_split_tklist, 1);
+ rb_define_method(ip, "_merge_tklist", lib_merge_tklist, -1);
+ rb_define_method(ip, "_conv_listelement", lib_conv_listelement, 1);
+
+ /* --------------------------------------------------------------- */
+
+ rb_define_method(ip, "mainloop", ip_mainloop, -1);
+ rb_define_method(ip, "mainloop_watchdog", ip_mainloop_watchdog, -1);
+ rb_define_method(ip, "do_one_event", ip_do_one_event, -1);
+ rb_define_method(ip, "mainloop_abort_on_exception",
+ ip_evloop_abort_on_exc, 0);
+ rb_define_method(ip, "mainloop_abort_on_exception=",
+ ip_evloop_abort_on_exc_set, 1);
+ rb_define_method(ip, "set_eventloop_tick", ip_set_eventloop_tick, 1);
+ rb_define_method(ip, "get_eventloop_tick", ip_get_eventloop_tick, 0);
+ rb_define_method(ip, "set_no_event_wait", ip_set_no_event_wait, 1);
+ rb_define_method(ip, "get_no_event_wait", ip_get_no_event_wait, 0);
+ rb_define_method(ip, "set_eventloop_weight", ip_set_eventloop_weight, 2);
+ rb_define_method(ip, "get_eventloop_weight", ip_get_eventloop_weight, 0);
+ rb_define_method(ip, "set_max_block_time", set_max_block_time, 1);
+ rb_define_method(ip, "restart", ip_restart, 0);
+
+ /* --------------------------------------------------------------- */
+
+ eventloop_thread = Qnil;
+ eventloop_interp = (Tcl_Interp*)NULL;
+
+#ifndef DEFAULT_EVENTLOOP_DEPTH
+#define DEFAULT_EVENTLOOP_DEPTH 7
+#endif
+ eventloop_stack = rb_ary_new2(DEFAULT_EVENTLOOP_DEPTH);
+ RbTk_OBJ_UNTRUST(eventloop_stack);
+
+ watchdog_thread = Qnil;
+
+ rbtk_pending_exception = Qnil;
+
+ /* --------------------------------------------------------------- */
+
+#ifdef HAVE_NATIVETHREAD
+ /* if ruby->nativethread-support and tcltklib->doesn't,
+ the following will cause link-error. */
+ ruby_native_thread_p();
+#endif
+
+ /* --------------------------------------------------------------- */
+
+ rb_set_end_proc(lib_mark_at_exit, 0);
+
+ /* --------------------------------------------------------------- */
+
+ ret = ruby_open_tcl_dll(rb_argv0 ? RSTRING_PTR(rb_argv0) : 0);
+ switch(ret) {
+ case TCLTK_STUBS_OK:
+ break;
+ case NO_TCL_DLL:
+ rb_raise(rb_eLoadError, "tcltklib: fail to open tcl_dll");
+ case NO_FindExecutable:
+ rb_raise(rb_eLoadError, "tcltklib: can't find Tcl_FindExecutable");
+ default:
+ rb_raise(rb_eLoadError, "tcltklib: unknown error(%d) on ruby_open_tcl_dll", ret);
+ }
+
+ /* --------------------------------------------------------------- */
+
+#if defined CREATE_RUBYTK_KIT || defined CREATE_RUBYKIT
+ setup_rubytkkit();
+#endif
+
+ /* --------------------------------------------------------------- */
+
+ /* Tcl stub check */
+ tcl_stubs_check();
+
+ Tcl_ObjType_ByteArray = Tcl_GetObjType(Tcl_ObjTypeName_ByteArray);
+ Tcl_ObjType_String = Tcl_GetObjType(Tcl_ObjTypeName_String);
+
+ /* --------------------------------------------------------------- */
+
+ (void)call_original_exit;
+}
+
+/* eof */
diff --git a/jni/ruby/ext/tk/tkutil/Makefile b/jni/ruby/ext/tk/tkutil/Makefile
new file mode 100644
index 0000000..d292cd2
--- /dev/null
+++ b/jni/ruby/ext/tk/tkutil/Makefile
@@ -0,0 +1,150 @@
+# ***DUMMY MAKEFILE***
+
+SHELL = /bin/sh
+
+# V=0 quiet, V=1 verbose. other values don't work.
+V = 0
+Q1 = $(V:1=)
+Q = $(Q1:0=@)
+ECHO1 = $(V:1=@:)
+ECHO = $(ECHO1:0=@echo)
+NULLCMD = :
+
+#### Start of system configuration section. ####
+top_srcdir = $(topdir)/.
+srcdir = ./ext
+topdir = /home/potato/Documents/android/mkxp/jni/ruby/ruby-2.2.3
+hdrdir = ../../../../.././include
+arch_hdrdir = $(extout)/include/$(arch)
+PATH_SEPARATOR = :
+VPATH = $(srcdir):$(arch_hdrdir)/ruby:$(hdrdir)/ruby
+RUBYLIB =
+RUBYOPT = -
+prefix = $(DESTDIR)/usr/local
+rubysitearchprefix = $(rubylibprefix)/$(sitearch)
+rubyarchprefix = $(rubylibprefix)/$(arch)
+rubylibprefix = $(libdir)/$(RUBY_BASE_NAME)
+exec_prefix = $(prefix)
+vendorarchhdrdir = $(vendorhdrdir)/$(sitearch)
+sitearchhdrdir = $(sitehdrdir)/$(sitearch)
+rubyarchhdrdir = $(rubyhdrdir)/$(arch)
+vendorhdrdir = $(rubyhdrdir)/vendor_ruby
+sitehdrdir = $(rubyhdrdir)/site_ruby
+rubyhdrdir = $(includedir)/$(RUBY_VERSION_NAME)
+vendorarchdir = $(vendorlibdir)/$(sitearch)
+vendorlibdir = $(vendordir)/$(ruby_version)
+vendordir = $(rubylibprefix)/vendor_ruby
+sitearchdir = $(sitelibdir)/$(sitearch)
+sitelibdir = $(sitedir)/$(ruby_version)
+sitedir = $(rubylibprefix)/site_ruby
+rubyarchdir = $(rubylibdir)/$(arch)
+rubylibdir = $(rubylibprefix)/$(ruby_version)
+sitearchincludedir = $(includedir)/$(sitearch)
+archincludedir = $(includedir)/$(arch)
+sitearchlibdir = $(libdir)/$(sitearch)
+archlibdir = $(libdir)/$(arch)
+ridir = $(datarootdir)/$(RI_BASE_NAME)
+mandir = $(datarootdir)/man
+localedir = $(datarootdir)/locale
+libdir = $(exec_prefix)/lib
+psdir = $(docdir)
+pdfdir = $(docdir)
+dvidir = $(docdir)
+htmldir = $(docdir)
+infodir = $(datarootdir)/info
+docdir = $(datarootdir)/doc/$(PACKAGE)
+oldincludedir = $(DESTDIR)/usr/include
+includedir = $(prefix)/include
+localstatedir = $(prefix)/var
+sharedstatedir = $(prefix)/com
+sysconfdir = $(prefix)/etc
+datadir = $(datarootdir)
+datarootdir = $(prefix)/share
+libexecdir = $(exec_prefix)/libexec
+sbindir = $(exec_prefix)/sbin
+bindir = $(exec_prefix)/bin
+archdir = $(rubyarchdir)
+
+
+CC = gcc
+CXX = g++
+LIBRUBY = $(LIBRUBY_SO)
+LIBRUBY_A = lib$(RUBY_SO_NAME)-static.a
+LIBRUBYARG_SHARED = -Wl,-R$(libdir) -L$(libdir) -l$(RUBY_SO_NAME)
+LIBRUBYARG_STATIC = -Wl,-R$(libdir) -L$(libdir) -l$(RUBY_SO_NAME)-static
+empty =
+OUTFLAG = -o $(empty)
+COUTFLAG = -o $(empty)
+
+RUBY_EXTCONF_H =
+cflags = $(optflags) $(debugflags) $(warnflags)
+optflags = -O3 -fno-fast-math
+debugflags = -ggdb3
+warnflags = -Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wunused-variable -Wpointer-arith -Wwrite-strings -Wdeclaration-after-statement -Wimplicit-function-declaration -Wdeprecated-declarations -Wno-packed-bitfield-compat
+CCDLFLAGS = -fPIC
+CFLAGS = $(CCDLFLAGS) $(cflags) -fPIC $(ARCH_FLAG)
+INCFLAGS = -I. -I$(arch_hdrdir) -I$(hdrdir) -I$(srcdir) -I/usr/local/include -I/usr/local/include
+DEFS =
+CPPFLAGS = -DHAVE_RUBY_NATIVE_THREAD_P -DHAVE_RB_ERRINFO -DHAVE_RB_SAFE_LEVEL -DHAVE_RB_HASH_LOOKUP -DHAVE_RB_PROC_NEW -DHAVE_RB_OBJ_UNTRUST -DHAVE_RB_OBJ_TAINT -DHAVE_RB_SET_SAFE_LEVEL_FORCE -DHAVE_RB_SOURCEFILE -DHAVE_RB_THREAD_CHECK_TRAP_PENDING $(DEFS) $(cppflags)
+CXXFLAGS = $(CCDLFLAGS) $(cxxflags) $(ARCH_FLAG)
+ldflags = -L. -fstack-protector -rdynamic -Wl,-export-dynamic
+dldflags =
+ARCH_FLAG =
+DLDFLAGS = $(ldflags) $(dldflags) $(ARCH_FLAG)
+LDSHARED = $(CC) -shared
+LDSHAREDXX = $(CXX) -shared
+AR = ar
+EXEEXT =
+
+RUBY_INSTALL_NAME = $(RUBY_BASE_NAME)
+RUBY_SO_NAME = ruby
+RUBYW_INSTALL_NAME =
+RUBY_VERSION_NAME = $(RUBY_BASE_NAME)-$(ruby_version)
+RUBYW_BASE_NAME = rubyw
+RUBY_BASE_NAME = ruby
+
+arch = x86_64-linux
+sitearch = $(arch)
+ruby_version = 2.2.0
+ruby = $(topdir)/miniruby -I'$(topdir)' -I'$(top_srcdir)/lib' -I'$(extout)/$(arch)' -I'$(extout)/common'
+RUBY = $(ruby)
+ruby_headers = $(hdrdir)/ruby.h $(hdrdir)/ruby/ruby.h $(hdrdir)/ruby/defines.h $(hdrdir)/ruby/missing.h $(hdrdir)/ruby/intern.h $(hdrdir)/ruby/st.h $(hdrdir)/ruby/subst.h $(arch_hdrdir)/ruby/config.h
+
+RM = rm -f
+RM_RF = $(RUBY) -run -e rm -- -rf
+RMDIRS = rmdir --ignore-fail-on-non-empty -p
+MAKEDIRS = /bin/mkdir -p
+INSTALL = /usr/bin/install -c
+INSTALL_PROG = $(INSTALL) -m 0755
+INSTALL_DATA = $(INSTALL) -m 644
+COPY = cp
+TOUCH = exit >
+
+#### End of system configuration section. ####
+
+preload =
+CLEANFILES = mkmf.log config_list
+DISTCLEANFILES =
+
+all install static install-so install-rb: Makefile
+.PHONY: all install static install-so install-rb
+.PHONY: clean clean-so clean-static clean-rb
+
+
+clean-static::
+clean-rb-default::
+clean-rb::
+clean-so::
+clean: clean-so clean-static clean-rb-default clean-rb
+ -$(Q)$(RM) $(CLEANLIBS) $(CLEANOBJS) $(CLEANFILES) .*.time
+
+distclean-rb-default::
+distclean-rb::
+distclean-so::
+distclean-static::
+distclean: clean distclean-so distclean-static distclean-rb-default distclean-rb
+ -$(Q)$(RM) Makefile $(RUBY_EXTCONF_H) conftest.* mkmf.log
+ -$(Q)$(RM) core ruby$(EXEEXT) *~ $(DISTCLEANFILES)
+ -$(Q)$(RMDIRS) $(DISTCLEANDIRS) 2> /dev/null || true
+
+realclean: distclean
diff --git a/jni/ruby/ext/tk/tkutil/depend b/jni/ruby/ext/tk/tkutil/depend
new file mode 100644
index 0000000..fd63e23
--- /dev/null
+++ b/jni/ruby/ext/tk/tkutil/depend
@@ -0,0 +1 @@
+tkutil.o: tkutil.c $(hdrdir)/ruby.h $(topdir)/config.h $(hdrdir)/defines.h
diff --git a/jni/ruby/ext/tk/tkutil/extconf.rb b/jni/ruby/ext/tk/tkutil/extconf.rb
new file mode 100644
index 0000000..9ffde75
--- /dev/null
+++ b/jni/ruby/ext/tk/tkutil/extconf.rb
@@ -0,0 +1,11 @@
+begin
+ require 'mkmf'
+
+ have_func("rb_obj_instance_exec", "ruby.h")
+ have_func("rb_obj_untrust", "ruby.h")
+ have_func("rb_obj_taint", "ruby.h")
+ have_func("rb_sym_to_s", "ruby.h")
+ have_func("strndup", "string.h")
+
+ create_makefile('tkutil')
+end
diff --git a/jni/ruby/ext/tk/tkutil/tkutil.c b/jni/ruby/ext/tk/tkutil/tkutil.c
new file mode 100644
index 0000000..cd8b3cc
--- /dev/null
+++ b/jni/ruby/ext/tk/tkutil/tkutil.c
@@ -0,0 +1,1878 @@
+/************************************************
+
+ tkutil.c -
+
+ $Author: nobu $
+ created at: Fri Nov 3 00:47:54 JST 1995
+
+************************************************/
+
+#define TKUTIL_RELEASE_DATE "2010-03-26"
+
+#include "ruby.h"
+
+#ifdef RUBY_VM
+static int rb_thread_critical; /* dummy */
+#else
+/* On Ruby 1.8.x, use rb_thread_critical (defined at rubysig.h) */
+#include "rubysig.h"
+#endif
+#ifdef HAVE_RUBY_ST_H
+#include "ruby/st.h"
+#else
+#include "st.h"
+#endif
+
+#undef RUBY_UNTYPED_DATA_WARNING
+#define RUBY_UNTYPED_DATA_WARNING 1
+
+#if !defined(RHASH_TBL)
+#define RHASH_TBL(h) (RHASH(h)->tbl)
+#endif
+#if !defined(RSTRING_PTR)
+#define RSTRING_PTR(s) (RSTRING(s)->ptr)
+#define RSTRING_LEN(s) (RSTRING(s)->len)
+#endif
+#if !defined(RARRAY_PTR)
+#define RARRAY_PTR(s) (RARRAY(s)->ptr)
+#define RARRAY_LEN(s) (RARRAY(s)->len)
+#endif
+
+#if defined(HAVE_STRNDUP) && !defined(_GNU_SOURCE)
+extern char *strndup(const char* _ptr, size_t _len);
+#endif
+
+static VALUE cMethod;
+
+static VALUE cTclTkLib;
+
+static VALUE cTkObject;
+static VALUE cTkCallbackEntry;
+
+static VALUE TK_None;
+
+static VALUE cCB_SUBST;
+static VALUE cSUBST_INFO;
+
+static VALUE ENCODING_NAME_UTF8; /* for saving GC cost */
+
+static ID ID_split_tklist;
+static ID ID_toUTF8;
+static ID ID_fromUTF8;
+static ID ID_path;
+static ID ID_at_path;
+static ID ID_at_enc;
+static ID ID_to_eval;
+static ID ID_to_s;
+static ID ID_source;
+static ID ID_downcase;
+static ID ID_install_cmd;
+static ID ID_merge_tklist;
+static ID ID_encoding;
+static ID ID_encoding_system;
+static ID ID_call;
+
+static ID ID_SUBST_INFO;
+
+static VALUE CALLBACK_TABLE;
+static unsigned long CALLBACK_ID_NUM = 0;
+
+/*************************************/
+
+#if defined(HAVE_RB_OBJ_INSTANCE_EXEC) && !defined(RUBY_VM)
+extern VALUE rb_obj_instance_exec _((int, VALUE*, VALUE));
+#endif
+static VALUE
+tk_s_new(argc, argv, klass)
+ int argc;
+ VALUE *argv;
+ VALUE klass;
+{
+ VALUE obj = rb_class_new_instance(argc, argv, klass);
+
+ if (rb_block_given_p()) {
+#ifndef HAVE_RB_OBJ_INSTANCE_EXEC
+ rb_obj_instance_eval(0, 0, obj);
+#else
+ rb_obj_instance_exec(1, &obj, obj);
+#endif
+ }
+ return obj;
+}
+
+/*************************************/
+
+static VALUE
+tkNone_to_s(self)
+ VALUE self;
+{
+ return rb_str_new2("");
+}
+
+static VALUE
+tkNone_inspect(self)
+ VALUE self;
+{
+ return rb_str_new2("None");
+}
+
+/*************************************/
+
+static VALUE
+tk_obj_untrust(self, obj)
+ VALUE self;
+ VALUE obj;
+{
+#ifdef HAVE_RB_OBJ_TAINT
+ rb_obj_taint(obj);
+#endif
+#ifdef HAVE_RB_OBJ_UNTRUST
+ rb_obj_untrust(obj);
+#endif
+
+ return obj;
+}
+
+static VALUE
+tk_eval_cmd(argc, argv, self)
+ int argc;
+ VALUE argv[];
+ VALUE self;
+{
+ volatile VALUE cmd, rest;
+
+ rb_scan_args(argc, argv, "1*", &cmd, &rest);
+ return rb_eval_cmd(cmd, rest, 0);
+}
+
+static VALUE
+tk_do_callback(argc, argv, self)
+ int argc;
+ VALUE *argv;
+ VALUE self;
+{
+#if 0
+ volatile VALUE id;
+ volatile VALUE rest;
+
+ rb_scan_args(argc, argv, "1*", &id, &rest);
+ return rb_apply(rb_hash_aref(CALLBACK_TABLE, id), ID_call, rest);
+#endif
+ return rb_funcall2(rb_hash_aref(CALLBACK_TABLE, argv[0]),
+ ID_call, argc - 1, argv + 1);
+}
+
+static const char cmd_id_head[] = "ruby_cmd TkUtil callback ";
+static const char cmd_id_prefix[] = "cmd";
+
+static VALUE
+tk_install_cmd_core(cmd)
+ VALUE cmd;
+{
+ volatile VALUE id_num;
+
+ id_num = ULONG2NUM(CALLBACK_ID_NUM++);
+ id_num = rb_funcall(id_num, ID_to_s, 0, 0);
+ id_num = rb_str_append(rb_str_new2(cmd_id_prefix), id_num);
+ rb_hash_aset(CALLBACK_TABLE, id_num, cmd);
+ return rb_str_append(rb_str_new2(cmd_id_head), id_num);
+}
+
+static VALUE
+tk_install_cmd(argc, argv, self)
+ int argc;
+ VALUE *argv;
+ VALUE self;
+{
+ volatile VALUE cmd;
+
+#if 0
+ if (rb_scan_args(argc, argv, "01", &cmd) == 0) {
+ cmd = rb_block_proc();
+ }
+ return tk_install_cmd_core(cmd);
+#endif
+ if (argc == 0) {
+ cmd = rb_block_proc();
+ } else {
+ cmd = argv[0];
+ }
+ return tk_install_cmd_core(cmd);
+}
+
+static VALUE
+tk_uninstall_cmd(self, cmd_id)
+ VALUE self;
+ VALUE cmd_id;
+{
+ size_t head_len = strlen(cmd_id_head);
+ size_t prefix_len = strlen(cmd_id_prefix);
+
+ StringValue(cmd_id);
+ if (strncmp(cmd_id_head, RSTRING_PTR(cmd_id), head_len) != 0) {
+ return Qnil;
+ }
+ if (strncmp(cmd_id_prefix,
+ RSTRING_PTR(cmd_id) + head_len, prefix_len) != 0) {
+ return Qnil;
+ }
+
+ return rb_hash_delete(CALLBACK_TABLE,
+ rb_str_new2(RSTRING_PTR(cmd_id) + head_len));
+}
+
+static VALUE
+tk_toUTF8(argc, argv, self)
+ int argc;
+ VALUE *argv;
+ VALUE self;
+{
+ return rb_funcall2(cTclTkLib, ID_toUTF8, argc, argv);
+}
+
+static VALUE
+tk_fromUTF8(argc, argv, self)
+ int argc;
+ VALUE *argv;
+ VALUE self;
+{
+ return rb_funcall2(cTclTkLib, ID_fromUTF8, argc, argv);
+}
+
+static VALUE
+fromDefaultEnc_toUTF8(str, self)
+ VALUE str;
+ VALUE self;
+{
+ VALUE argv[1];
+
+ argv[0] = str;
+ return tk_toUTF8(1, argv, self);
+}
+
+#if 0
+static VALUE
+fromUTF8_toDefaultEnc(str, self)
+ VALUE str;
+ VALUE self;
+{
+ VALUE argv[1];
+
+ argv[0] = str;
+ return tk_fromUTF8(1, argv, self);
+}
+#endif
+
+static int
+to_strkey(key, value, hash)
+ VALUE key;
+ VALUE value;
+ VALUE hash;
+{
+ rb_hash_aset(hash, rb_funcall(key, ID_to_s, 0, 0), value);
+ return ST_CHECK;
+}
+
+static VALUE
+tk_symbolkey2str(self, keys)
+ VALUE self;
+ VALUE keys;
+{
+ volatile VALUE new_keys = rb_hash_new();
+
+ if (NIL_P(keys)) return new_keys;
+ keys = rb_convert_type(keys, T_HASH, "Hash", "to_hash");
+ st_foreach_check(RHASH_TBL(keys), to_strkey, new_keys, Qundef);
+ return new_keys;
+}
+
+static VALUE get_eval_string_core _((VALUE, VALUE, VALUE));
+static VALUE ary2list _((VALUE, VALUE, VALUE));
+static VALUE ary2list2 _((VALUE, VALUE, VALUE));
+static VALUE hash2list _((VALUE, VALUE));
+static VALUE hash2list_enc _((VALUE, VALUE));
+static VALUE hash2kv _((VALUE, VALUE, VALUE));
+static VALUE hash2kv_enc _((VALUE, VALUE, VALUE));
+
+static VALUE
+ary2list(ary, enc_flag, self)
+ VALUE ary;
+ VALUE enc_flag;
+ VALUE self;
+{
+ long idx, idx2, size, size2;
+ int req_chk_flag;
+ volatile VALUE val, val2, str_val;
+ volatile VALUE dst;
+ volatile VALUE sys_enc, dst_enc, str_enc;
+
+ sys_enc = rb_funcall(cTclTkLib, ID_encoding, 0, 0);
+ if (NIL_P(sys_enc)) {
+ sys_enc = rb_funcall(cTclTkLib, ID_encoding_system, 0, 0);
+ sys_enc = rb_funcall(sys_enc, ID_to_s, 0, 0);
+ }
+
+ if (NIL_P(enc_flag)) {
+ dst_enc = sys_enc;
+ req_chk_flag = 1;
+ } else if (enc_flag == Qtrue || enc_flag == Qfalse) {
+ dst_enc = enc_flag;
+ req_chk_flag = 0;
+ } else {
+ dst_enc = rb_funcall(enc_flag, ID_to_s, 0, 0);
+ req_chk_flag = 0;
+ }
+
+ /* size = RARRAY_LEN(ary); */
+ size = 0;
+ for(idx = 0; idx < RARRAY_LEN(ary); idx++) {
+ if (RB_TYPE_P(RARRAY_PTR(ary)[idx], T_HASH)) {
+ size += 2 * RHASH_SIZE(RARRAY_PTR(ary)[idx]);
+ } else {
+ size++;
+ }
+ }
+
+ dst = rb_ary_new2(size);
+ for(idx = 0; idx < RARRAY_LEN(ary); idx++) {
+ val = RARRAY_PTR(ary)[idx];
+ str_val = Qnil;
+ switch(TYPE(val)) {
+ case T_ARRAY:
+ str_val = ary2list(val, enc_flag, self);
+ rb_ary_push(dst, str_val);
+
+ if (req_chk_flag) {
+ str_enc = rb_ivar_get(str_val, ID_at_enc);
+ if (!NIL_P(str_enc)) {
+ str_enc = rb_funcall(str_enc, ID_to_s, 0, 0);
+ } else {
+ str_enc = sys_enc;
+ }
+ if (!rb_str_cmp(str_enc, dst_enc)) {
+ dst_enc = Qtrue;
+ req_chk_flag = 0;
+ }
+ }
+
+ break;
+
+ case T_HASH:
+ /* rb_ary_push(dst, hash2list(val, self)); */
+ if (RTEST(enc_flag)) {
+ val = hash2kv_enc(val, Qnil, self);
+ } else {
+ val = hash2kv(val, Qnil, self);
+ }
+ size2 = RARRAY_LEN(val);
+ for(idx2 = 0; idx2 < size2; idx2++) {
+ val2 = RARRAY_PTR(val)[idx2];
+ switch(TYPE(val2)) {
+ case T_ARRAY:
+ str_val = ary2list(val2, enc_flag, self);
+ rb_ary_push(dst, str_val);
+ break;
+
+ case T_HASH:
+ if (RTEST(enc_flag)) {
+ str_val = hash2list_enc(val2, self);
+ } else {
+ str_val = hash2list(val2, self);
+ }
+ rb_ary_push(dst, str_val);
+ break;
+
+ default:
+ if (val2 != TK_None) {
+ str_val = get_eval_string_core(val2, enc_flag, self);
+ rb_ary_push(dst, str_val);
+ }
+ }
+
+ if (req_chk_flag) {
+ str_enc = rb_ivar_get(str_val, ID_at_enc);
+ if (!NIL_P(str_enc)) {
+ str_enc = rb_funcall(str_enc, ID_to_s, 0, 0);
+ } else {
+ str_enc = sys_enc;
+ }
+ if (!rb_str_cmp(str_enc, dst_enc)) {
+ dst_enc = Qtrue;
+ req_chk_flag = 0;
+ }
+ }
+ }
+ break;
+
+ default:
+ if (val != TK_None) {
+ str_val = get_eval_string_core(val, enc_flag, self);
+ rb_ary_push(dst, str_val);
+
+ if (req_chk_flag) {
+ str_enc = rb_ivar_get(str_val, ID_at_enc);
+ if (!NIL_P(str_enc)) {
+ str_enc = rb_funcall(str_enc, ID_to_s, 0, 0);
+ } else {
+ str_enc = sys_enc;
+ }
+ if (!rb_str_cmp(str_enc, dst_enc)) {
+ dst_enc = Qtrue;
+ req_chk_flag = 0;
+ }
+ }
+ }
+ }
+ }
+
+ if (RTEST(dst_enc) && !NIL_P(sys_enc)) {
+ for(idx = 0; idx < RARRAY_LEN(dst); idx++) {
+ str_val = RARRAY_PTR(dst)[idx];
+ if (rb_obj_respond_to(self, ID_toUTF8, Qtrue)) {
+ str_val = rb_funcall(self, ID_toUTF8, 1, str_val);
+ } else {
+ str_val = rb_funcall(cTclTkLib, ID_toUTF8, 1, str_val);
+ }
+ RARRAY_PTR(dst)[idx] = str_val;
+ }
+ val = rb_apply(cTclTkLib, ID_merge_tklist, dst);
+ if (RB_TYPE_P(dst_enc, T_STRING)) {
+ val = rb_funcall(cTclTkLib, ID_fromUTF8, 2, val, dst_enc);
+ rb_ivar_set(val, ID_at_enc, dst_enc);
+ } else {
+ rb_ivar_set(val, ID_at_enc, ENCODING_NAME_UTF8);
+ }
+ return val;
+ } else {
+ return rb_apply(cTclTkLib, ID_merge_tklist, dst);
+ }
+}
+
+static VALUE
+ary2list2(ary, enc_flag, self)
+ VALUE ary;
+ VALUE enc_flag;
+ VALUE self;
+{
+ long idx, size;
+ int req_chk_flag;
+ volatile VALUE val, str_val;
+ volatile VALUE dst;
+ volatile VALUE sys_enc, dst_enc, str_enc;
+
+ sys_enc = rb_funcall(cTclTkLib, ID_encoding, 0, 0);
+ if (NIL_P(sys_enc)) {
+ sys_enc = rb_funcall(cTclTkLib, ID_encoding_system, 0, 0);
+ sys_enc = rb_funcall(sys_enc, ID_to_s, 0, 0);
+ }
+
+ if (NIL_P(enc_flag)) {
+ dst_enc = sys_enc;
+ req_chk_flag = 1;
+ } else if (enc_flag == Qtrue || enc_flag == Qfalse) {
+ dst_enc = enc_flag;
+ req_chk_flag = 0;
+ } else {
+ dst_enc = rb_funcall(enc_flag, ID_to_s, 0, 0);
+ req_chk_flag = 0;
+ }
+
+ size = RARRAY_LEN(ary);
+ dst = rb_ary_new2(size);
+ for(idx = 0; idx < RARRAY_LEN(ary); idx++) {
+ val = RARRAY_PTR(ary)[idx];
+ str_val = Qnil;
+ switch(TYPE(val)) {
+ case T_ARRAY:
+ str_val = ary2list(val, enc_flag, self);
+ break;
+
+ case T_HASH:
+ if (RTEST(enc_flag)) {
+ str_val = hash2list(val, self);
+ } else {
+ str_val = hash2list_enc(val, self);
+ }
+ break;
+
+ default:
+ if (val != TK_None) {
+ str_val = get_eval_string_core(val, enc_flag, self);
+ }
+ }
+
+ if (!NIL_P(str_val)) {
+ rb_ary_push(dst, str_val);
+
+ if (req_chk_flag) {
+ str_enc = rb_ivar_get(str_val, ID_at_enc);
+ if (!NIL_P(str_enc)) {
+ str_enc = rb_funcall(str_enc, ID_to_s, 0, 0);
+ } else {
+ str_enc = sys_enc;
+ }
+ if (!rb_str_cmp(str_enc, dst_enc)) {
+ dst_enc = Qtrue;
+ req_chk_flag = 0;
+ }
+ }
+ }
+ }
+
+ if (RTEST(dst_enc) && !NIL_P(sys_enc)) {
+ for(idx = 0; idx < RARRAY_LEN(dst); idx++) {
+ str_val = RARRAY_PTR(dst)[idx];
+ if (rb_obj_respond_to(self, ID_toUTF8, Qtrue)) {
+ str_val = rb_funcall(self, ID_toUTF8, 1, str_val);
+ } else {
+ str_val = rb_funcall(cTclTkLib, ID_toUTF8, 1, str_val);
+ }
+ RARRAY_PTR(dst)[idx] = str_val;
+ }
+ val = rb_apply(cTclTkLib, ID_merge_tklist, dst);
+ if (RB_TYPE_P(dst_enc, T_STRING)) {
+ val = rb_funcall(cTclTkLib, ID_fromUTF8, 2, val, dst_enc);
+ rb_ivar_set(val, ID_at_enc, dst_enc);
+ } else {
+ rb_ivar_set(val, ID_at_enc, ENCODING_NAME_UTF8);
+ }
+ return val;
+ } else {
+ return rb_apply(cTclTkLib, ID_merge_tklist, dst);
+ }
+}
+
+static VALUE
+key2keyname(key)
+ VALUE key;
+{
+ return rb_str_append(rb_str_new2("-"), rb_funcall(key, ID_to_s, 0, 0));
+}
+
+static VALUE
+assoc2kv(assoc, ary, self)
+ VALUE assoc;
+ VALUE ary;
+ VALUE self;
+{
+ long i, j, len;
+ volatile VALUE pair;
+ volatile VALUE val;
+ volatile VALUE dst = rb_ary_new2(2 * RARRAY_LEN(assoc));
+
+ len = RARRAY_LEN(assoc);
+
+ for(i = 0; i < len; i++) {
+ pair = RARRAY_PTR(assoc)[i];
+ if (!RB_TYPE_P(pair, T_ARRAY)) {
+ rb_ary_push(dst, key2keyname(pair));
+ continue;
+ }
+ switch(RARRAY_LEN(assoc)) {
+ case 2:
+ rb_ary_push(dst, RARRAY_PTR(pair)[2]);
+
+ case 1:
+ rb_ary_push(dst, key2keyname(RARRAY_PTR(pair)[0]));
+
+ case 0:
+ continue;
+
+ default:
+ rb_ary_push(dst, key2keyname(RARRAY_PTR(pair)[0]));
+
+ val = rb_ary_new2(RARRAY_LEN(pair) - 1);
+ for(j = 1; j < RARRAY_LEN(pair); j++) {
+ rb_ary_push(val, RARRAY_PTR(pair)[j]);
+ }
+
+ rb_ary_push(dst, val);
+ }
+ }
+
+ if (NIL_P(ary)) {
+ return dst;
+ } else {
+ return rb_ary_plus(ary, dst);
+ }
+}
+
+static VALUE
+assoc2kv_enc(assoc, ary, self)
+ VALUE assoc;
+ VALUE ary;
+ VALUE self;
+{
+ long i, j, len;
+ volatile VALUE pair;
+ volatile VALUE val;
+ volatile VALUE dst = rb_ary_new2(2 * RARRAY_LEN(assoc));
+
+ len = RARRAY_LEN(assoc);
+
+ for(i = 0; i < len; i++) {
+ pair = RARRAY_PTR(assoc)[i];
+ if (!RB_TYPE_P(pair, T_ARRAY)) {
+ rb_ary_push(dst, key2keyname(pair));
+ continue;
+ }
+ switch(RARRAY_LEN(assoc)) {
+ case 2:
+ rb_ary_push(dst, get_eval_string_core(RARRAY_PTR(pair)[2], Qtrue, self));
+
+ case 1:
+ rb_ary_push(dst, key2keyname(RARRAY_PTR(pair)[0]));
+
+ case 0:
+ continue;
+
+ default:
+ rb_ary_push(dst, key2keyname(RARRAY_PTR(pair)[0]));
+
+ val = rb_ary_new2(RARRAY_LEN(pair) - 1);
+ for(j = 1; j < RARRAY_LEN(pair); j++) {
+ rb_ary_push(val, RARRAY_PTR(pair)[j]);
+ }
+
+ rb_ary_push(dst, get_eval_string_core(val, Qtrue, self));
+ }
+ }
+
+ if (NIL_P(ary)) {
+ return dst;
+ } else {
+ return rb_ary_plus(ary, dst);
+ }
+}
+
+static int
+push_kv(key, val, args)
+ VALUE key;
+ VALUE val;
+ VALUE args;
+{
+ volatile VALUE ary;
+
+ ary = RARRAY_PTR(args)[0];
+
+#if 0
+ rb_ary_push(ary, key2keyname(key));
+ if (val != TK_None) rb_ary_push(ary, val);
+#endif
+ rb_ary_push(ary, key2keyname(key));
+
+ if (val == TK_None) return ST_CHECK;
+
+ rb_ary_push(ary, get_eval_string_core(val, Qnil, RARRAY_PTR(args)[1]));
+
+ return ST_CHECK;
+}
+
+static VALUE
+hash2kv(hash, ary, self)
+ VALUE hash;
+ VALUE ary;
+ VALUE self;
+{
+ volatile VALUE dst = rb_ary_new2(2 * RHASH_SIZE(hash));
+ volatile VALUE args = rb_ary_new3(2, dst, self);
+
+ st_foreach_check(RHASH_TBL(hash), push_kv, args, Qundef);
+
+ if (NIL_P(ary)) {
+ return dst;
+ } else {
+ return rb_ary_concat(ary, dst);
+ }
+}
+
+static int
+push_kv_enc(key, val, args)
+ VALUE key;
+ VALUE val;
+ VALUE args;
+{
+ volatile VALUE ary;
+
+ ary = RARRAY_PTR(args)[0];
+
+#if 0
+ rb_ary_push(ary, key2keyname(key));
+ if (val != TK_None) {
+ rb_ary_push(ary, get_eval_string_core(val, Qtrue,
+ RARRAY_PTR(args)[1]));
+ }
+#endif
+ rb_ary_push(ary, key2keyname(key));
+
+ if (val == TK_None) return ST_CHECK;
+
+ rb_ary_push(ary, get_eval_string_core(val, Qtrue, RARRAY_PTR(args)[1]));
+
+ return ST_CHECK;
+}
+
+static VALUE
+hash2kv_enc(hash, ary, self)
+ VALUE hash;
+ VALUE ary;
+ VALUE self;
+{
+ volatile VALUE dst = rb_ary_new2(2 * RHASH_SIZE(hash));
+ volatile VALUE args = rb_ary_new3(2, dst, self);
+
+ st_foreach_check(RHASH_TBL(hash), push_kv_enc, args, Qundef);
+
+ if (NIL_P(ary)) {
+ return dst;
+ } else {
+ return rb_ary_concat(ary, dst);
+ }
+}
+
+static VALUE
+hash2list(hash, self)
+ VALUE hash;
+ VALUE self;
+{
+ return ary2list2(hash2kv(hash, Qnil, self), Qfalse, self);
+}
+
+
+static VALUE
+hash2list_enc(hash, self)
+ VALUE hash;
+ VALUE self;
+{
+ return ary2list2(hash2kv_enc(hash, Qnil, self), Qfalse, self);
+}
+
+static VALUE
+tk_hash_kv(argc, argv, self)
+ int argc;
+ VALUE *argv;
+ VALUE self;
+{
+ volatile VALUE hash, enc_flag, ary;
+
+ ary = Qnil;
+ enc_flag = Qnil;
+ switch(argc) {
+ case 3:
+ ary = argv[2];
+ case 2:
+ enc_flag = argv[1];
+ case 1:
+ hash = argv[0];
+ break;
+ case 0:
+ rb_raise(rb_eArgError, "too few arguments");
+ default: /* >= 3 */
+ rb_raise(rb_eArgError, "too many arguments");
+ }
+
+ switch(TYPE(hash)) {
+ case T_ARRAY:
+ if (RTEST(enc_flag)) {
+ return assoc2kv_enc(hash, ary, self);
+ } else {
+ return assoc2kv(hash, ary, self);
+ }
+
+ case T_HASH:
+ if (RTEST(enc_flag)) {
+ return hash2kv_enc(hash, ary, self);
+ } else {
+ return hash2kv(hash, ary, self);
+ }
+
+ case T_NIL:
+ if (NIL_P(ary)) {
+ return rb_ary_new();
+ } else {
+ return ary;
+ }
+
+ default:
+ if (hash == TK_None) {
+ if (NIL_P(ary)) {
+ return rb_ary_new();
+ } else {
+ return ary;
+ }
+ }
+ rb_raise(rb_eArgError, "Hash is expected for 1st argument");
+ }
+
+ UNREACHABLE;
+}
+
+static VALUE
+get_eval_string_core(obj, enc_flag, self)
+ VALUE obj;
+ VALUE enc_flag;
+ VALUE self;
+{
+ switch(TYPE(obj)) {
+ case T_FLOAT:
+ case T_FIXNUM:
+ case T_BIGNUM:
+ return rb_funcall(obj, ID_to_s, 0, 0);
+
+ case T_STRING:
+ if (RTEST(enc_flag)) {
+ if (rb_obj_respond_to(self, ID_toUTF8, Qtrue)) {
+ return rb_funcall(self, ID_toUTF8, 1, obj);
+ } else {
+ return fromDefaultEnc_toUTF8(obj, self);
+ }
+ } else {
+ return obj;
+ }
+
+ case T_SYMBOL:
+ if (RTEST(enc_flag)) {
+ if (rb_obj_respond_to(self, ID_toUTF8, Qtrue)) {
+ return rb_funcall(self, ID_toUTF8, 1,
+ rb_str_dup(rb_sym2str(obj)));
+ } else {
+ return fromDefaultEnc_toUTF8(rb_sym2str(obj), self);
+ }
+ } else {
+#ifdef HAVE_RB_SYM_TO_S
+ return rb_sym_to_s(obj);
+#else
+ return rb_sym2str(obj);
+#endif
+ }
+
+ case T_HASH:
+ if (RTEST(enc_flag)) {
+ return hash2list_enc(obj, self);
+ } else {
+ return hash2list(obj, self);
+ }
+
+ case T_ARRAY:
+ return ary2list(obj, enc_flag, self);
+
+ case T_FALSE:
+ return rb_str_new2("0");
+
+ case T_TRUE:
+ return rb_str_new2("1");
+
+ case T_NIL:
+ return rb_str_new2("");
+
+ case T_REGEXP:
+ return rb_funcall(obj, ID_source, 0, 0);
+
+ default:
+ if (rb_obj_is_kind_of(obj, cTkObject)) {
+ /* return rb_str_new3(rb_funcall(obj, ID_path, 0, 0)); */
+ return get_eval_string_core(rb_funcall(obj, ID_path, 0, 0),
+ enc_flag, self);
+ }
+
+ if (rb_obj_is_kind_of(obj, rb_cProc)
+ || rb_obj_is_kind_of(obj, cMethod)
+ || rb_obj_is_kind_of(obj, cTkCallbackEntry)) {
+ if (rb_obj_respond_to(self, ID_install_cmd, Qtrue)) {
+ return rb_funcall(self, ID_install_cmd, 1, obj);
+ } else {
+ return tk_install_cmd_core(obj);
+ }
+ }
+
+ if (obj == TK_None) return Qnil;
+
+ if (rb_obj_respond_to(obj, ID_to_eval, Qtrue)) {
+ /* return rb_funcall(obj, ID_to_eval, 0, 0); */
+ return get_eval_string_core(rb_funcall(obj, ID_to_eval, 0, 0),
+ enc_flag, self);
+ } else if (rb_obj_respond_to(obj, ID_path, Qtrue)) {
+ /* return rb_funcall(obj, ID_path, 0, 0); */
+ return get_eval_string_core(rb_funcall(obj, ID_path, 0, 0),
+ enc_flag, self);
+ } else if (rb_obj_respond_to(obj, ID_to_s, Qtrue)) {
+ return rb_funcall(obj, ID_to_s, 0, 0);
+ }
+ }
+
+ rb_warning("fail to convert '%+"PRIsVALUE"' to string for Tk", obj);
+
+ return obj;
+}
+
+static VALUE
+tk_get_eval_string(argc, argv, self)
+ int argc;
+ VALUE *argv;
+ VALUE self;
+{
+ volatile VALUE obj, enc_flag;
+
+ if (rb_scan_args(argc, argv, "11", &obj, &enc_flag) == 1) {
+ enc_flag = Qnil;
+ }
+
+ return get_eval_string_core(obj, enc_flag, self);
+}
+
+static VALUE
+tk_get_eval_enc_str(self, obj)
+ VALUE self;
+ VALUE obj;
+{
+ if (obj == TK_None) {
+ return obj;
+ } else {
+ return get_eval_string_core(obj, Qtrue, self);
+ }
+}
+
+static VALUE
+tk_conv_args(argc, argv, self)
+ int argc;
+ VALUE *argv; /* [0]:base_array, [1]:enc_mode, [2]..[n]:args */
+ VALUE self;
+{
+ int idx;
+ long size;
+ volatile VALUE dst;
+ int thr_crit_bup;
+ VALUE old_gc;
+
+ if (argc < 2) {
+ rb_raise(rb_eArgError, "too few arguments");
+ }
+
+ thr_crit_bup = rb_thread_critical;
+ rb_thread_critical = Qtrue;
+ old_gc = rb_gc_disable();
+
+ for(size = 0, idx = 2; idx < argc; idx++) {
+ if (RB_TYPE_P(argv[idx], T_HASH)) {
+ size += 2 * RHASH_SIZE(argv[idx]);
+ } else {
+ size++;
+ }
+ }
+ /* dst = rb_ary_new2(argc - 2); */
+ dst = rb_ary_new2(size);
+ for(idx = 2; idx < argc; idx++) {
+ if (RB_TYPE_P(argv[idx], T_HASH)) {
+ if (RTEST(argv[1])) {
+ hash2kv_enc(argv[idx], dst, self);
+ } else {
+ hash2kv(argv[idx], dst, self);
+ }
+ } else if (argv[idx] != TK_None) {
+ rb_ary_push(dst, get_eval_string_core(argv[idx], argv[1], self));
+ }
+ }
+
+ if (old_gc == Qfalse) rb_gc_enable();
+ rb_thread_critical = thr_crit_bup;
+
+ return rb_ary_plus(argv[0], dst);
+}
+
+
+/*************************************/
+
+static VALUE
+tcl2rb_bool(self, value)
+ VALUE self;
+ VALUE value;
+{
+ if (RB_TYPE_P(value, T_FIXNUM)) {
+ if (NUM2INT(value) == 0) {
+ return Qfalse;
+ } else {
+ return Qtrue;
+ }
+ }
+
+ if (value == Qtrue || value == Qfalse) {
+ return value;
+ }
+
+ rb_check_type(value, T_STRING);
+
+ value = rb_funcall(value, ID_downcase, 0);
+
+ if (RSTRING_PTR(value) == (char*)NULL) return Qnil;
+
+ if (RSTRING_PTR(value)[0] == '\0'
+ || strcmp(RSTRING_PTR(value), "0") == 0
+ || strcmp(RSTRING_PTR(value), "no") == 0
+ || strcmp(RSTRING_PTR(value), "off") == 0
+ || strcmp(RSTRING_PTR(value), "false") == 0) {
+ return Qfalse;
+ } else {
+ return Qtrue;
+ }
+}
+
+#if 0
+static VALUE
+tkstr_to_dec(value)
+ VALUE value;
+{
+ return rb_cstr_to_inum(RSTRING_PTR(value), 10, 1);
+}
+#endif
+
+static VALUE
+tkstr_to_int(value)
+ VALUE value;
+{
+ return rb_cstr_to_inum(RSTRING_PTR(value), 0, 1);
+}
+
+static VALUE
+tkstr_to_float(value)
+ VALUE value;
+{
+ return rb_float_new(rb_cstr_to_dbl(RSTRING_PTR(value), 1));
+}
+
+static VALUE
+tkstr_invalid_numstr(value)
+ VALUE value;
+{
+ rb_raise(rb_eArgError,
+ "invalid value for Number: '%s'", RSTRING_PTR(value));
+ return Qnil; /*dummy*/
+}
+
+static VALUE
+tkstr_rescue_float(value)
+ VALUE value;
+{
+ return rb_rescue2(tkstr_to_float, value,
+ tkstr_invalid_numstr, value,
+ rb_eArgError, 0);
+}
+
+static VALUE
+tkstr_to_number(value)
+ VALUE value;
+{
+ rb_check_type(value, T_STRING);
+
+ if (RSTRING_PTR(value) == (char*)NULL) return INT2FIX(0);
+
+ return rb_rescue2(tkstr_to_int, value,
+ tkstr_rescue_float, value,
+ rb_eArgError, 0);
+}
+
+static VALUE
+tcl2rb_number(self, value)
+ VALUE self;
+ VALUE value;
+{
+ return tkstr_to_number(value);
+}
+
+static VALUE
+tkstr_to_str(value)
+ VALUE value;
+{
+ char * ptr;
+ long len;
+
+ ptr = RSTRING_PTR(value);
+ len = RSTRING_LEN(value);
+
+ if (len > 1 && *ptr == '{' && *(ptr + len - 1) == '}') {
+ return rb_str_new(ptr + 1, len - 2);
+ }
+ return value;
+}
+
+static VALUE
+tcl2rb_string(self, value)
+ VALUE self;
+ VALUE value;
+{
+ rb_check_type(value, T_STRING);
+
+ if (RSTRING_PTR(value) == (char*)NULL) return rb_tainted_str_new2("");
+
+ return tkstr_to_str(value);
+}
+
+static VALUE
+tcl2rb_num_or_str(self, value)
+ VALUE self;
+ VALUE value;
+{
+ rb_check_type(value, T_STRING);
+
+ if (RSTRING_PTR(value) == (char*)NULL) return rb_tainted_str_new2("");
+
+ return rb_rescue2(tkstr_to_number, value,
+ tkstr_to_str, value,
+ rb_eArgError, 0);
+}
+
+static VALUE
+tcl2rb_num_or_nil(self, value)
+ VALUE self;
+ VALUE value;
+{
+ rb_check_type(value, T_STRING);
+
+ if (RSTRING_LEN(value) == 0) return Qnil;
+
+ return tkstr_to_number(value);
+}
+
+
+/*************************************/
+
+#define CBSUBST_TBL_MAX (256)
+struct cbsubst_info {
+ long full_subst_length;
+ long keylen[CBSUBST_TBL_MAX];
+ char *key[CBSUBST_TBL_MAX];
+ char type[CBSUBST_TBL_MAX];
+ ID ivar[CBSUBST_TBL_MAX];
+ VALUE proc;
+ VALUE aliases;
+};
+
+static void
+subst_mark(ptr)
+ struct cbsubst_info *ptr;
+{
+ rb_gc_mark(ptr->proc);
+ rb_gc_mark(ptr->aliases);
+}
+
+static void
+subst_free(ptr)
+ struct cbsubst_info *ptr;
+{
+ int i;
+
+ if (ptr) {
+ for(i = 0; i < CBSUBST_TBL_MAX; i++) {
+ if (ptr->key[i] != NULL) {
+ free(ptr->key[i]); /* allocated by malloc */
+ ptr->key[i] = NULL;
+ }
+ }
+ xfree(ptr); /* allocated by ALLOC */
+ }
+}
+
+static size_t
+subst_memsize(ptr)
+ const struct cbsubst_info *ptr;
+{
+ return sizeof(*ptr);
+}
+
+static const rb_data_type_t cbsubst_info_type = {
+ "TkUtil/CallbackSubst/Info",
+ {
+ subst_mark,
+ subst_free,
+ subst_memsize,
+ },
+ 0, 0, RUBY_TYPED_FREE_IMMEDIATELY,
+};
+
+static VALUE
+allocate_cbsubst_info(struct cbsubst_info **inf_ptr)
+{
+ struct cbsubst_info *inf;
+ volatile VALUE proc, aliases;
+ int idx;
+
+ inf = ALLOC(struct cbsubst_info);
+
+ inf->full_subst_length = 0;
+
+ for(idx = 0; idx < CBSUBST_TBL_MAX; idx++) {
+ inf->keylen[idx] = 0;
+ inf->key[idx] = NULL;
+ inf->type[idx] = '\0';
+ inf->ivar[idx] = (ID) 0;
+ }
+
+ proc = rb_hash_new();
+ inf->proc = proc;
+
+ aliases = rb_hash_new();
+ inf->aliases = aliases;
+
+ if (inf_ptr != (struct cbsubst_info **)NULL) *inf_ptr = inf;
+
+ return TypedData_Wrap_Struct(cSUBST_INFO, &cbsubst_info_type, inf);
+}
+
+static void
+cbsubst_init(void)
+{
+ rb_const_set(cCB_SUBST, ID_SUBST_INFO,
+ allocate_cbsubst_info((struct cbsubst_info **)NULL));
+}
+
+static struct cbsubst_info *
+cbsubst_get_ptr(klass)
+ VALUE klass;
+{
+ return rb_check_typeddata(rb_const_get(klass, ID_SUBST_INFO), &cbsubst_info_type);
+}
+
+static VALUE
+cbsubst_initialize(argc, argv, self)
+ int argc;
+ VALUE *argv;
+ VALUE self;
+{
+ struct cbsubst_info *inf;
+ int idx, iv_idx;
+
+ inf = cbsubst_get_ptr(rb_obj_class(self));
+
+ idx = 0;
+ for(iv_idx = 0; iv_idx < CBSUBST_TBL_MAX; iv_idx++) {
+ if ( inf->ivar[iv_idx] == (ID) 0 ) continue;
+ rb_ivar_set(self, inf->ivar[iv_idx], argv[idx++]);
+ if (idx >= argc) break;
+ }
+
+ return self;
+}
+
+static VALUE
+cbsubst_ret_val(self, val)
+ VALUE self;
+ VALUE val;
+{
+ /* This method may be overwritten on some sub-classes. */
+ /* This method is used for converting from ruby's callback-return-value */
+ /* to tcl's value (e.g. validation procedure of entry widget). */
+ return val;
+}
+
+static int
+each_attr_def(key, value, klass)
+ VALUE key, value, klass;
+{
+ ID key_id, value_id;
+
+ if (key == Qundef) return ST_CONTINUE;
+
+ switch(TYPE(key)) {
+ case T_STRING:
+ key_id = rb_intern_str(key);
+ break;
+ case T_SYMBOL:
+ key_id = SYM2ID(key);
+ break;
+ default:
+ rb_raise(rb_eArgError,
+ "includes invalid key(s). expected a String or a Symbol");
+ }
+
+ switch(TYPE(value)) {
+ case T_STRING:
+ value_id = rb_intern_str(value);
+ break;
+ case T_SYMBOL:
+ value_id = SYM2ID(value);
+ break;
+ default:
+ rb_raise(rb_eArgError,
+ "includes invalid value(s). expected a String or a Symbol");
+ }
+
+ rb_alias(klass, key_id, value_id);
+
+ return ST_CONTINUE;
+}
+
+static VALUE
+cbsubst_def_attr_aliases(self, tbl)
+ VALUE self;
+ VALUE tbl;
+{
+ struct cbsubst_info *inf;
+
+ if (!RB_TYPE_P(tbl, T_HASH)) {
+ rb_raise(rb_eArgError, "expected a Hash");
+ }
+
+ inf = cbsubst_get_ptr(self);
+
+ rb_hash_foreach(tbl, each_attr_def, self);
+
+ return rb_funcall(inf->aliases, rb_intern("update"), 1, tbl);
+}
+
+static VALUE
+cbsubst_sym_to_subst(self, sym)
+ VALUE self;
+ VALUE sym;
+{
+ struct cbsubst_info *inf;
+ VALUE str;
+ char *buf, *ptr;
+ int idx;
+ long len;
+ ID id;
+ volatile VALUE ret;
+
+ if (!RB_TYPE_P(sym, T_SYMBOL)) return sym;
+
+ inf = cbsubst_get_ptr(self);
+
+ if (!NIL_P(ret = rb_hash_aref(inf->aliases, sym))) {
+ str = rb_sym2str(ret);
+ } else {
+ str = rb_sym2str(sym);
+ }
+
+ id = rb_intern_str(rb_sprintf("@%"PRIsVALUE, str));
+
+ for(idx = 0; idx < CBSUBST_TBL_MAX; idx++) {
+ if (inf->ivar[idx] == id) break;
+ }
+ if (idx >= CBSUBST_TBL_MAX) return sym;
+
+ ptr = buf = ALLOC_N(char, inf->full_subst_length + 1);
+
+ *(ptr++) = '%';
+
+ if (len = inf->keylen[idx]) {
+ /* longname */
+ strncpy(ptr, inf->key[idx], len);
+ ptr += len;
+ } else {
+ /* single char */
+ *(ptr++) = (unsigned char)idx;
+ }
+
+ *(ptr++) = ' ';
+ *(ptr++) = '\0';
+
+ ret = rb_str_new2(buf);
+
+ xfree(buf);
+
+ return ret;
+}
+
+static VALUE
+cbsubst_get_subst_arg(argc, argv, self)
+ int argc;
+ VALUE *argv;
+ VALUE self;
+{
+ struct cbsubst_info *inf;
+ VALUE str;
+ char *buf, *ptr;
+ int i, idx;
+ long len;
+ ID id;
+ volatile VALUE arg_sym, ret;
+
+ inf = cbsubst_get_ptr(self);
+
+ ptr = buf = ALLOC_N(char, inf->full_subst_length + 1);
+
+ for(i = 0; i < argc; i++) {
+ switch(TYPE(argv[i])) {
+ case T_STRING:
+ str = argv[i];
+ arg_sym = rb_check_symbol(&str);
+ if (NIL_P(arg_sym)) goto not_found;
+ break;
+ case T_SYMBOL:
+ arg_sym = argv[i];
+ str = rb_sym2str(arg_sym);
+ break;
+ default:
+ rb_raise(rb_eArgError, "arg #%d is not a String or a Symbol", i);
+ }
+
+ if (!NIL_P(ret = rb_hash_aref(inf->aliases, arg_sym))) {
+ str = rb_sym2str(ret);
+ }
+
+ ret = rb_sprintf("@%"PRIsVALUE, str);
+ id = rb_check_id(&ret);
+ if (!id) goto not_found;
+
+ for(idx = 0; idx < CBSUBST_TBL_MAX; idx++) {
+ if (inf->ivar[idx] == id) break;
+ }
+ if (idx >= CBSUBST_TBL_MAX) {
+ not_found:
+ rb_raise(rb_eArgError, "cannot find attribute :%"PRIsVALUE, str);
+ }
+
+ *(ptr++) = '%';
+
+ if (len = inf->keylen[idx]) {
+ /* longname */
+ strncpy(ptr, inf->key[idx], len);
+ ptr += len;
+ } else {
+ /* single char */
+ *(ptr++) = (unsigned char)idx;
+ }
+
+ *(ptr++) = ' ';
+ }
+
+ *ptr = '\0';
+
+ ret = rb_str_new2(buf);
+
+ xfree(buf);
+
+ return ret;
+}
+
+static VALUE
+cbsubst_get_subst_key(self, str)
+ VALUE self;
+ VALUE str;
+{
+ struct cbsubst_info *inf;
+ volatile VALUE list;
+ volatile VALUE ret;
+ VALUE keyval;
+ long i, len, keylen;
+ int idx;
+ char *buf, *ptr, *key;
+
+ list = rb_funcall(cTclTkLib, ID_split_tklist, 1, str);
+ len = RARRAY_LEN(list);
+
+ inf = cbsubst_get_ptr(self);
+
+ ptr = buf = ALLOC_N(char, inf->full_subst_length + len + 1);
+
+ for(i = 0; i < len; i++) {
+ keyval = RARRAY_PTR(list)[i];
+ key = RSTRING_PTR(keyval);
+ if (*key == '%') {
+ if (*(key + 2) == '\0') {
+ /* single char */
+ *(ptr++) = *(key + 1);
+ } else {
+ /* search longname-key */
+ keylen = RSTRING_LEN(keyval) - 1;
+ for(idx = 0; idx < CBSUBST_TBL_MAX; idx++) {
+ if (inf->keylen[idx] != keylen) continue;
+ if ((unsigned char)inf->key[idx][0] != (unsigned char)*(key + 1)) continue;
+ if (strncmp(inf->key[idx], key + 1, keylen)) continue;
+ break;
+ }
+ if (idx < CBSUBST_TBL_MAX) {
+ *(ptr++) = (unsigned char)idx;
+ } else {
+ *(ptr++) = ' ';
+ }
+ }
+ } else {
+ *(ptr++) = ' ';
+ }
+ }
+ *ptr = '\0';
+
+ ret = rb_str_new2(buf);
+ xfree(buf);
+ return ret;
+}
+
+static VALUE
+cbsubst_get_all_subst_keys(self)
+ VALUE self;
+{
+ struct cbsubst_info *inf;
+ char *buf, *ptr;
+ char *keys_buf, *keys_ptr;
+ int idx;
+ long len;
+ volatile VALUE ret;
+
+ inf = cbsubst_get_ptr(self);
+
+ ptr = buf = ALLOC_N(char, inf->full_subst_length + 1);
+ keys_ptr = keys_buf = ALLOC_N(char, CBSUBST_TBL_MAX + 1);
+
+ for(idx = 0; idx < CBSUBST_TBL_MAX; idx++) {
+ if (inf->ivar[idx] == (ID) 0) continue;
+
+ *(keys_ptr++) = (unsigned char)idx;
+
+ *(ptr++) = '%';
+
+ if (len = inf->keylen[idx]) {
+ /* longname */
+ strncpy(ptr, inf->key[idx], len);
+ ptr += len;
+ } else {
+ /* single char */
+ *(ptr++) = (unsigned char)idx;
+ }
+
+ *(ptr++) = ' ';
+ }
+
+ *ptr = '\0';
+ *keys_ptr = '\0';
+
+ ret = rb_ary_new3(2, rb_str_new2(keys_buf), rb_str_new2(buf));
+
+ xfree(buf);
+ xfree(keys_buf);
+
+ return ret;
+}
+
+static VALUE
+cbsubst_table_setup(argc, argv, self)
+ int argc;
+ VALUE *argv;
+ VALUE self;
+{
+ volatile VALUE cbsubst_obj;
+ volatile VALUE key_inf;
+ volatile VALUE longkey_inf;
+ volatile VALUE proc_inf;
+ VALUE inf;
+ ID id;
+ struct cbsubst_info *subst_inf;
+ long idx, len;
+ unsigned char chr;
+
+ /* accept (key_inf, proc_inf) or (key_inf, longkey_inf, procinf) */
+ if (rb_scan_args(argc, argv, "21", &key_inf, &longkey_inf, &proc_inf) == 2) {
+ proc_inf = longkey_inf;
+ longkey_inf = rb_ary_new();
+ }
+
+ /* check the number of longkeys */
+ if (RARRAY_LEN(longkey_inf) > 125 /* from 0x80 to 0xFD */) {
+ rb_raise(rb_eArgError, "too many longname-key definitions");
+ }
+
+ /* init */
+ cbsubst_obj = allocate_cbsubst_info(&subst_inf);
+
+ /*
+ * keys : array of [subst, type, ivar]
+ * subst ==> char code or string
+ * type ==> char code or string
+ * ivar ==> symbol
+ */
+ len = RARRAY_LEN(key_inf);
+ for(idx = 0; idx < len; idx++) {
+ inf = RARRAY_PTR(key_inf)[idx];
+ if (!RB_TYPE_P(inf, T_ARRAY)) continue;
+
+ chr = NUM2CHR(RARRAY_PTR(inf)[0]);
+ subst_inf->type[chr] = NUM2CHR(RARRAY_PTR(inf)[1]);
+
+ subst_inf->full_subst_length += 3;
+
+ id = SYM2ID(RARRAY_PTR(inf)[2]);
+ subst_inf->ivar[chr] = rb_intern_str(rb_sprintf("@%"PRIsVALUE, rb_id2str(id)));
+
+ rb_attr(self, id, 1, 0, Qtrue);
+ }
+
+
+ /*
+ * longkeys : array of [name, type, ivar]
+ * name ==> longname key string
+ * type ==> char code or string
+ * ivar ==> symbol
+ */
+ len = RARRAY_LEN(longkey_inf);
+ for(idx = 0; idx < len; idx++) {
+ inf = RARRAY_PTR(longkey_inf)[idx];
+ if (!RB_TYPE_P(inf, T_ARRAY)) continue;
+
+ chr = (unsigned char)(0x80 + idx);
+ subst_inf->keylen[chr] = RSTRING_LEN(RARRAY_PTR(inf)[0]);
+#if HAVE_STRNDUP
+ subst_inf->key[chr] = strndup(RSTRING_PTR(RARRAY_PTR(inf)[0]),
+ RSTRING_LEN(RARRAY_PTR(inf)[0]));
+#else
+ subst_inf->key[chr] = malloc(RSTRING_LEN(RARRAY_PTR(inf)[0]) + 1);
+ if (subst_inf->key[chr]) {
+ strncpy(subst_inf->key[chr], RSTRING_PTR(RARRAY_PTR(inf)[0]),
+ RSTRING_LEN(RARRAY_PTR(inf)[0]) + 1);
+ subst_inf->key[chr][RSTRING_LEN(RARRAY_PTR(inf)[0])] = '\0';
+ }
+#endif
+ subst_inf->type[chr] = NUM2CHR(RARRAY_PTR(inf)[1]);
+
+ subst_inf->full_subst_length += (subst_inf->keylen[chr] + 2);
+
+ id = SYM2ID(RARRAY_PTR(inf)[2]);
+ subst_inf->ivar[chr] = rb_intern_str(rb_sprintf("@%"PRIsVALUE, rb_id2str(id)));
+
+ rb_attr(self, id, 1, 0, Qtrue);
+ }
+
+ /*
+ * procs : array of [type, proc]
+ * type ==> char code or string
+ * proc ==> proc/method/obj (must respond to 'call')
+ */
+ len = RARRAY_LEN(proc_inf);
+ for(idx = 0; idx < len; idx++) {
+ inf = RARRAY_PTR(proc_inf)[idx];
+ if (!RB_TYPE_P(inf, T_ARRAY)) continue;
+ rb_hash_aset(subst_inf->proc,
+ (RB_TYPE_P(RARRAY_PTR(inf)[0], T_STRING)?
+ INT2FIX(*(RSTRING_PTR(RARRAY_PTR(inf)[0]))) :
+ RARRAY_PTR(inf)[0]),
+ RARRAY_PTR(inf)[1]);
+ }
+
+ rb_const_set(self, ID_SUBST_INFO, cbsubst_obj);
+
+ return self;
+}
+
+static VALUE
+cbsubst_get_extra_args_tbl(self)
+ VALUE self;
+{
+ return rb_ary_new();
+}
+
+static VALUE
+cbsubst_scan_args(self, arg_key, val_ary)
+ VALUE self;
+ VALUE arg_key;
+ VALUE val_ary;
+{
+ struct cbsubst_info *inf;
+ long idx;
+ unsigned char *keyptr = (unsigned char*)RSTRING_PTR(arg_key);
+ long keylen = RSTRING_LEN(arg_key);
+ long vallen = RARRAY_LEN(val_ary);
+ unsigned char type_chr;
+ volatile VALUE dst = rb_ary_new2(vallen);
+ volatile VALUE proc;
+ int thr_crit_bup;
+ VALUE old_gc;
+
+ thr_crit_bup = rb_thread_critical;
+ rb_thread_critical = Qtrue;
+
+ old_gc = rb_gc_disable();
+
+ inf = cbsubst_get_ptr(self);
+
+ for(idx = 0; idx < vallen; idx++) {
+ if (idx >= keylen) {
+ proc = Qnil;
+ } else if (*(keyptr + idx) == ' ') {
+ proc = Qnil;
+ } else {
+ if (type_chr = inf->type[*(keyptr + idx)]) {
+ proc = rb_hash_aref(inf->proc, INT2FIX((int)type_chr));
+ } else {
+ proc = Qnil;
+ }
+ }
+
+ if (NIL_P(proc)) {
+ rb_ary_push(dst, RARRAY_PTR(val_ary)[idx]);
+ } else {
+ rb_ary_push(dst, rb_funcall(proc, ID_call, 1,
+ RARRAY_PTR(val_ary)[idx]));
+ }
+ }
+
+ if (old_gc == Qfalse) rb_gc_enable();
+ rb_thread_critical = thr_crit_bup;
+
+ return dst;
+}
+
+static VALUE
+cbsubst_inspect(self)
+ VALUE self;
+{
+ return rb_str_new2("CallbackSubst");
+}
+
+static VALUE
+substinfo_inspect(self)
+ VALUE self;
+{
+ return rb_str_new2("SubstInfo");
+}
+
+/*************************************/
+
+static VALUE
+tk_cbe_inspect(self)
+ VALUE self;
+{
+ return rb_str_new2("TkCallbackEntry");
+}
+
+/*************************************/
+
+static VALUE
+tkobj_path(self)
+ VALUE self;
+{
+ return rb_ivar_get(self, ID_at_path);
+}
+
+
+/*************************************/
+/* release date */
+const char tkutil_release_date[] = TKUTIL_RELEASE_DATE;
+
+void
+Init_tkutil(void)
+{
+ VALUE cTK = rb_define_class("TkKernel", rb_cObject);
+ VALUE mTK = rb_define_module("TkUtil");
+
+ /* --------------------- */
+
+ rb_define_const(mTK, "RELEASE_DATE",
+ rb_obj_freeze(rb_str_new2(tkutil_release_date)));
+
+ /* --------------------- */
+ rb_global_variable(&cMethod);
+ cMethod = rb_const_get(rb_cObject, rb_intern("Method"));
+
+ ID_path = rb_intern("path");
+ ID_at_path = rb_intern("@path");
+ ID_at_enc = rb_intern("@encoding");
+ ID_to_eval = rb_intern("to_eval");
+ ID_to_s = rb_intern("to_s");
+ ID_source = rb_intern("source");
+ ID_downcase = rb_intern("downcase");
+ ID_install_cmd = rb_intern("install_cmd");
+ ID_merge_tklist = rb_intern("_merge_tklist");
+ ID_encoding = rb_intern("encoding");
+ ID_encoding_system = rb_intern("encoding_system");
+ ID_call = rb_intern("call");
+
+ /* --------------------- */
+ cCB_SUBST = rb_define_class_under(mTK, "CallbackSubst", rb_cData);
+ rb_define_singleton_method(cCB_SUBST, "inspect", cbsubst_inspect, 0);
+
+ cSUBST_INFO = rb_define_class_under(cCB_SUBST, "Info", rb_cData);
+ rb_define_singleton_method(cSUBST_INFO, "inspect", substinfo_inspect, 0);
+
+ ID_SUBST_INFO = rb_intern("SUBST_INFO");
+ rb_define_singleton_method(cCB_SUBST, "ret_val", cbsubst_ret_val, 1);
+ rb_define_singleton_method(cCB_SUBST, "scan_args", cbsubst_scan_args, 2);
+ rb_define_singleton_method(cCB_SUBST, "_sym2subst",
+ cbsubst_sym_to_subst, 1);
+ rb_define_singleton_method(cCB_SUBST, "subst_arg",
+ cbsubst_get_subst_arg, -1);
+ rb_define_singleton_method(cCB_SUBST, "_get_subst_key",
+ cbsubst_get_subst_key, 1);
+ rb_define_singleton_method(cCB_SUBST, "_get_all_subst_keys",
+ cbsubst_get_all_subst_keys, 0);
+ rb_define_singleton_method(cCB_SUBST, "_setup_subst_table",
+ cbsubst_table_setup, -1);
+ rb_define_singleton_method(cCB_SUBST, "_get_extra_args_tbl",
+ cbsubst_get_extra_args_tbl, 0);
+ rb_define_singleton_method(cCB_SUBST, "_define_attribute_aliases",
+ cbsubst_def_attr_aliases, 1);
+
+ rb_define_method(cCB_SUBST, "initialize", cbsubst_initialize, -1);
+
+ cbsubst_init();
+
+ /* --------------------- */
+ rb_global_variable(&cTkCallbackEntry);
+ cTkCallbackEntry = rb_define_class("TkCallbackEntry", cTK);
+ rb_define_singleton_method(cTkCallbackEntry, "inspect", tk_cbe_inspect, 0);
+
+ /* --------------------- */
+ rb_global_variable(&cTkObject);
+ cTkObject = rb_define_class("TkObject", cTK);
+ rb_define_method(cTkObject, "path", tkobj_path, 0);
+
+ /* --------------------- */
+ rb_require("tcltklib");
+ rb_global_variable(&cTclTkLib);
+ cTclTkLib = rb_const_get(rb_cObject, rb_intern("TclTkLib"));
+ ID_split_tklist = rb_intern("_split_tklist");
+ ID_toUTF8 = rb_intern("_toUTF8");
+ ID_fromUTF8 = rb_intern("_fromUTF8");
+
+ /* --------------------- */
+ rb_define_singleton_method(cTK, "new", tk_s_new, -1);
+
+ /* --------------------- */
+ rb_global_variable(&TK_None);
+ TK_None = rb_obj_alloc(rb_cObject);
+ rb_define_const(mTK, "None", TK_None);
+ rb_define_singleton_method(TK_None, "to_s", tkNone_to_s, 0);
+ rb_define_singleton_method(TK_None, "inspect", tkNone_inspect, 0);
+ OBJ_FREEZE(TK_None);
+
+ /* --------------------- */
+ rb_global_variable(&CALLBACK_TABLE);
+ CALLBACK_TABLE = rb_hash_new();
+
+ /* --------------------- */
+ rb_define_singleton_method(mTK, "untrust", tk_obj_untrust, 1);
+
+ rb_define_singleton_method(mTK, "eval_cmd", tk_eval_cmd, -1);
+ rb_define_singleton_method(mTK, "callback", tk_do_callback, -1);
+ rb_define_singleton_method(mTK, "install_cmd", tk_install_cmd, -1);
+ rb_define_singleton_method(mTK, "uninstall_cmd", tk_uninstall_cmd, 1);
+ rb_define_singleton_method(mTK, "_symbolkey2str", tk_symbolkey2str, 1);
+ rb_define_singleton_method(mTK, "hash_kv", tk_hash_kv, -1);
+ rb_define_singleton_method(mTK, "_get_eval_string",
+ tk_get_eval_string, -1);
+ rb_define_singleton_method(mTK, "_get_eval_enc_str",
+ tk_get_eval_enc_str, 1);
+ rb_define_singleton_method(mTK, "_conv_args", tk_conv_args, -1);
+
+ rb_define_singleton_method(mTK, "bool", tcl2rb_bool, 1);
+ rb_define_singleton_method(mTK, "number", tcl2rb_number, 1);
+ rb_define_singleton_method(mTK, "string", tcl2rb_string, 1);
+ rb_define_singleton_method(mTK, "num_or_str", tcl2rb_num_or_str, 1);
+ rb_define_singleton_method(mTK, "num_or_nil", tcl2rb_num_or_nil, 1);
+
+ rb_define_method(mTK, "_toUTF8", tk_toUTF8, -1);
+ rb_define_method(mTK, "_fromUTF8", tk_fromUTF8, -1);
+ rb_define_method(mTK, "_symbolkey2str", tk_symbolkey2str, 1);
+ rb_define_method(mTK, "hash_kv", tk_hash_kv, -1);
+ rb_define_method(mTK, "_get_eval_string", tk_get_eval_string, -1);
+ rb_define_method(mTK, "_get_eval_enc_str", tk_get_eval_enc_str, 1);
+ rb_define_method(mTK, "_conv_args", tk_conv_args, -1);
+
+ rb_define_method(mTK, "bool", tcl2rb_bool, 1);
+ rb_define_method(mTK, "number", tcl2rb_number, 1);
+ rb_define_method(mTK, "string", tcl2rb_string, 1);
+ rb_define_method(mTK, "num_or_str", tcl2rb_num_or_str, 1);
+ rb_define_method(mTK, "num_or_nil", tcl2rb_num_or_nil, 1);
+
+ /* --------------------- */
+ rb_global_variable(&ENCODING_NAME_UTF8);
+ ENCODING_NAME_UTF8 = rb_obj_freeze(rb_str_new2("utf-8"));
+
+ /* --------------------- */
+}
diff --git a/jni/ruby/ext/win32/Makefile b/jni/ruby/ext/win32/Makefile
new file mode 100644
index 0000000..94764f4
--- /dev/null
+++ b/jni/ruby/ext/win32/Makefile
@@ -0,0 +1,150 @@
+# ***DUMMY MAKEFILE***
+
+SHELL = /bin/sh
+
+# V=0 quiet, V=1 verbose. other values don't work.
+V = 0
+Q1 = $(V:1=)
+Q = $(Q1:0=@)
+ECHO1 = $(V:1=@:)
+ECHO = $(ECHO1:0=@echo)
+NULLCMD = :
+
+#### Start of system configuration section. ####
+top_srcdir = $(topdir)/.
+srcdir = $(top_srcdir)/ext/win32
+topdir = ../..
+hdrdir = $(top_srcdir)/include
+arch_hdrdir = $(extout)/include/$(arch)
+PATH_SEPARATOR = :
+VPATH = $(srcdir):$(arch_hdrdir)/ruby:$(hdrdir)/ruby
+RUBYLIB =
+RUBYOPT = -
+prefix = $(DESTDIR)/usr/local
+rubysitearchprefix = $(rubylibprefix)/$(sitearch)
+rubyarchprefix = $(rubylibprefix)/$(arch)
+rubylibprefix = $(libdir)/$(RUBY_BASE_NAME)
+exec_prefix = $(prefix)
+vendorarchhdrdir = $(vendorhdrdir)/$(sitearch)
+sitearchhdrdir = $(sitehdrdir)/$(sitearch)
+rubyarchhdrdir = $(rubyhdrdir)/$(arch)
+vendorhdrdir = $(rubyhdrdir)/vendor_ruby
+sitehdrdir = $(rubyhdrdir)/site_ruby
+rubyhdrdir = $(includedir)/$(RUBY_VERSION_NAME)
+vendorarchdir = $(vendorlibdir)/$(sitearch)
+vendorlibdir = $(vendordir)/$(ruby_version)
+vendordir = $(rubylibprefix)/vendor_ruby
+sitearchdir = $(sitelibdir)/$(sitearch)
+sitelibdir = $(sitedir)/$(ruby_version)
+sitedir = $(rubylibprefix)/site_ruby
+rubyarchdir = $(rubylibdir)/$(arch)
+rubylibdir = $(rubylibprefix)/$(ruby_version)
+sitearchincludedir = $(includedir)/$(sitearch)
+archincludedir = $(includedir)/$(arch)
+sitearchlibdir = $(libdir)/$(sitearch)
+archlibdir = $(libdir)/$(arch)
+ridir = $(datarootdir)/$(RI_BASE_NAME)
+mandir = $(datarootdir)/man
+localedir = $(datarootdir)/locale
+libdir = $(exec_prefix)/lib
+psdir = $(docdir)
+pdfdir = $(docdir)
+dvidir = $(docdir)
+htmldir = $(docdir)
+infodir = $(datarootdir)/info
+docdir = $(datarootdir)/doc/$(PACKAGE)
+oldincludedir = $(DESTDIR)/usr/include
+includedir = $(prefix)/include
+localstatedir = $(prefix)/var
+sharedstatedir = $(prefix)/com
+sysconfdir = $(prefix)/etc
+datadir = $(datarootdir)
+datarootdir = $(prefix)/share
+libexecdir = $(exec_prefix)/libexec
+sbindir = $(exec_prefix)/sbin
+bindir = $(exec_prefix)/bin
+archdir = $(rubyarchdir)
+
+
+CC = gcc
+CXX = g++
+LIBRUBY = $(LIBRUBY_SO)
+LIBRUBY_A = lib$(RUBY_SO_NAME)-static.a
+LIBRUBYARG_SHARED = -Wl,-R$(libdir) -L$(libdir) -l$(RUBY_SO_NAME)
+LIBRUBYARG_STATIC = -Wl,-R$(libdir) -L$(libdir) -l$(RUBY_SO_NAME)-static
+empty =
+OUTFLAG = -o $(empty)
+COUTFLAG = -o $(empty)
+
+RUBY_EXTCONF_H =
+cflags = $(optflags) $(debugflags) $(warnflags)
+optflags = -O3 -fno-fast-math
+debugflags = -ggdb3
+warnflags = -Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wunused-variable -Wpointer-arith -Wwrite-strings -Wdeclaration-after-statement -Wimplicit-function-declaration -Wdeprecated-declarations -Wno-packed-bitfield-compat
+CCDLFLAGS = -fPIC
+CFLAGS = $(CCDLFLAGS) $(cflags) -fPIC $(ARCH_FLAG)
+INCFLAGS = -I. -I$(arch_hdrdir) -I$(hdrdir) -I$(srcdir)
+DEFS =
+CPPFLAGS = $(DEFS) $(cppflags)
+CXXFLAGS = $(CCDLFLAGS) $(cxxflags) $(ARCH_FLAG)
+ldflags = -L. -fstack-protector -rdynamic -Wl,-export-dynamic
+dldflags =
+ARCH_FLAG =
+DLDFLAGS = $(ldflags) $(dldflags) $(ARCH_FLAG)
+LDSHARED = $(CC) -shared
+LDSHAREDXX = $(CXX) -shared
+AR = ar
+EXEEXT =
+
+RUBY_INSTALL_NAME = $(RUBY_BASE_NAME)
+RUBY_SO_NAME = ruby
+RUBYW_INSTALL_NAME =
+RUBY_VERSION_NAME = $(RUBY_BASE_NAME)-$(ruby_version)
+RUBYW_BASE_NAME = rubyw
+RUBY_BASE_NAME = ruby
+
+arch = x86_64-linux
+sitearch = $(arch)
+ruby_version = 2.2.0
+ruby = $(topdir)/miniruby -I'$(topdir)' -I'$(top_srcdir)/lib' -I'$(extout)/$(arch)' -I'$(extout)/common'
+RUBY = $(ruby)
+ruby_headers = $(hdrdir)/ruby.h $(hdrdir)/ruby/ruby.h $(hdrdir)/ruby/defines.h $(hdrdir)/ruby/missing.h $(hdrdir)/ruby/intern.h $(hdrdir)/ruby/st.h $(hdrdir)/ruby/subst.h $(arch_hdrdir)/ruby/config.h
+
+RM = rm -f
+RM_RF = $(RUBY) -run -e rm -- -rf
+RMDIRS = rmdir --ignore-fail-on-non-empty -p
+MAKEDIRS = /bin/mkdir -p
+INSTALL = /usr/bin/install -c
+INSTALL_PROG = $(INSTALL) -m 0755
+INSTALL_DATA = $(INSTALL) -m 644
+COPY = cp
+TOUCH = exit >
+
+#### End of system configuration section. ####
+
+preload =
+CLEANFILES = mkmf.log
+DISTCLEANFILES =
+
+all install static install-so install-rb: Makefile
+.PHONY: all install static install-so install-rb
+.PHONY: clean clean-so clean-static clean-rb
+
+
+clean-static::
+clean-rb-default::
+clean-rb::
+clean-so::
+clean: clean-so clean-static clean-rb-default clean-rb
+ -$(Q)$(RM) $(CLEANLIBS) $(CLEANOBJS) $(CLEANFILES) .*.time
+
+distclean-rb-default::
+distclean-rb::
+distclean-so::
+distclean-static::
+distclean: clean distclean-so distclean-static distclean-rb-default distclean-rb
+ -$(Q)$(RM) Makefile $(RUBY_EXTCONF_H) conftest.* mkmf.log
+ -$(Q)$(RM) core ruby$(EXEEXT) *~ $(DISTCLEANFILES)
+ -$(Q)$(RMDIRS) $(DISTCLEANDIRS) 2> /dev/null || true
+
+realclean: distclean
diff --git a/jni/ruby/ext/win32/extconf.rb b/jni/ruby/ext/win32/extconf.rb
new file mode 100644
index 0000000..c4efee8
--- /dev/null
+++ b/jni/ruby/ext/win32/extconf.rb
@@ -0,0 +1,3 @@
+if compiled?('fiddle') and $mswin||$mingw||$cygwin
+ create_makefile('win32')
+end
diff --git a/jni/ruby/ext/win32/lib/Win32API.rb b/jni/ruby/ext/win32/lib/Win32API.rb
new file mode 100644
index 0000000..71f1d30
--- /dev/null
+++ b/jni/ruby/ext/win32/lib/Win32API.rb
@@ -0,0 +1,37 @@
+# -*- ruby -*-
+# for backward compatibility
+warn "Warning:#{caller[0].sub(/:in `.*'\z/, '')}: Win32API is deprecated after Ruby 1.9.1; use fiddle directly instead" if $VERBOSE
+
+require 'fiddle/import'
+
+class Win32API
+ DLL = {}
+ TYPEMAP = {"0" => Fiddle::TYPE_VOID, "S" => Fiddle::TYPE_VOIDP, "I" => Fiddle::TYPE_LONG}
+ POINTER_TYPE = Fiddle::SIZEOF_VOIDP == Fiddle::SIZEOF_LONG_LONG ? 'q*' : 'l!*'
+
+ def initialize(dllname, func, import, export = "0", calltype = :stdcall)
+ @proto = [import].join.tr("VPpNnLlIi", "0SSI").sub(/^(.)0*$/, '\1')
+ handle = DLL[dllname] ||= Fiddle.dlopen(dllname)
+
+ @func = Fiddle::Function.new(
+ handle[func],
+ @proto.chars.map { |win_type| TYPEMAP[win_type.tr("VPpNnLlIi", "0SSI")] },
+ TYPEMAP[export.tr("VPpNnLlIi", "0SSI")],
+ Fiddle::Importer.const_get(:CALL_TYPE_TO_ABI)[calltype]
+ )
+ rescue Fiddle::DLError => e
+ raise LoadError, e.message, e.backtrace
+ end
+
+ def call(*args)
+ import = @proto.split("")
+ args.each_with_index do |x, i|
+ args[i], = [x == 0 ? nil : x].pack("p").unpack(POINTER_TYPE) if import[i] == "S"
+ args[i], = [x].pack("I").unpack("i") if import[i] == "I"
+ end
+ ret, = @func.call(*args)
+ return ret || 0
+ end
+
+ alias Call call
+end
diff --git a/jni/ruby/ext/win32/lib/win32/importer.rb b/jni/ruby/ext/win32/lib/win32/importer.rb
new file mode 100644
index 0000000..7975cb7
--- /dev/null
+++ b/jni/ruby/ext/win32/lib/win32/importer.rb
@@ -0,0 +1,8 @@
+require 'fiddle/import'
+
+module Win32
+end
+
+Win32.module_eval do
+ Importer = Fiddle::Importer
+end
diff --git a/jni/ruby/ext/win32/lib/win32/registry.rb b/jni/ruby/ext/win32/lib/win32/registry.rb
new file mode 100644
index 0000000..b17c85c
--- /dev/null
+++ b/jni/ruby/ext/win32/lib/win32/registry.rb
@@ -0,0 +1,909 @@
+require 'win32/importer'
+
+module Win32
+
+=begin rdoc
+= Win32 Registry
+
+win32/registry is registry accessor library for Win32 platform.
+It uses importer to call Win32 Registry APIs.
+
+== example
+ Win32::Registry::HKEY_CURRENT_USER.open('SOFTWARE\foo') do |reg|
+ value = reg['foo'] # read a value
+ value = reg['foo', Win32::Registry::REG_SZ] # read a value with type
+ type, value = reg.read('foo') # read a value
+ reg['foo'] = 'bar' # write a value
+ reg['foo', Win32::Registry::REG_SZ] = 'bar' # write a value with type
+ reg.write('foo', Win32::Registry::REG_SZ, 'bar') # write a value
+
+ reg.each_value { |name, type, data| ... } # Enumerate values
+ reg.each_key { |key, wtime| ... } # Enumerate subkeys
+
+ reg.delete_value(name) # Delete a value
+ reg.delete_key(name) # Delete a subkey
+ reg.delete_key(name, true) # Delete a subkey recursively
+ end
+
+= Reference
+
+== Win32::Registry class
+
+--- info
+
+--- num_keys
+
+--- max_key_length
+
+--- num_values
+
+--- max_value_name_length
+
+--- max_value_length
+
+--- descriptor_length
+
+--- wtime
+ Returns an item of key information.
+
+=== constants
+--- HKEY_CLASSES_ROOT
+
+--- HKEY_CURRENT_USER
+
+--- HKEY_LOCAL_MACHINE
+
+--- HKEY_PERFORMANCE_DATA
+
+--- HKEY_CURRENT_CONFIG
+
+--- HKEY_DYN_DATA
+
+ Win32::Registry object whose key is predefined key.
+For detail, see the MSDN[http://msdn.microsoft.com/library/en-us/sysinfo/base/predefined_keys.asp] article.
+
+=end rdoc
+
+ WCHAR = Encoding::UTF_16LE
+ WCHAR_NUL = "\0".encode(WCHAR).freeze
+ WCHAR_CR = "\r".encode(WCHAR).freeze
+ WCHAR_SIZE = WCHAR_NUL.bytesize
+ LOCALE = Encoding.find(Encoding.locale_charmap)
+
+ class Registry
+
+ #
+ # For detail, see the MSDN[http://msdn.microsoft.com/library/en-us/sysinfo/base/registry.asp].
+ #
+ # --- HKEY_*
+ #
+ # Predefined key ((*handle*)).
+ # These are Integer, not Win32::Registry.
+ #
+ # --- REG_*
+ #
+ # Registry value type.
+ #
+ # --- KEY_*
+ #
+ # Security access mask.
+ #
+ # --- KEY_OPTIONS_*
+ #
+ # Key options.
+ #
+ # --- REG_CREATED_NEW_KEY
+ #
+ # --- REG_OPENED_EXISTING_KEY
+ #
+ # If the key is created newly or opened existing key.
+ # See also Registry#disposition method.
+ module Constants
+ HKEY_CLASSES_ROOT = 0x80000000
+ HKEY_CURRENT_USER = 0x80000001
+ HKEY_LOCAL_MACHINE = 0x80000002
+ HKEY_USERS = 0x80000003
+ HKEY_PERFORMANCE_DATA = 0x80000004
+ HKEY_PERFORMANCE_TEXT = 0x80000050
+ HKEY_PERFORMANCE_NLSTEXT = 0x80000060
+ HKEY_CURRENT_CONFIG = 0x80000005
+ HKEY_DYN_DATA = 0x80000006
+
+ REG_NONE = 0
+ REG_SZ = 1
+ REG_EXPAND_SZ = 2
+ REG_BINARY = 3
+ REG_DWORD = 4
+ REG_DWORD_LITTLE_ENDIAN = 4
+ REG_DWORD_BIG_ENDIAN = 5
+ REG_LINK = 6
+ REG_MULTI_SZ = 7
+ REG_RESOURCE_LIST = 8
+ REG_FULL_RESOURCE_DESCRIPTOR = 9
+ REG_RESOURCE_REQUIREMENTS_LIST = 10
+ REG_QWORD = 11
+ REG_QWORD_LITTLE_ENDIAN = 11
+
+ STANDARD_RIGHTS_READ = 0x00020000
+ STANDARD_RIGHTS_WRITE = 0x00020000
+ KEY_QUERY_VALUE = 0x0001
+ KEY_SET_VALUE = 0x0002
+ KEY_CREATE_SUB_KEY = 0x0004
+ KEY_ENUMERATE_SUB_KEYS = 0x0008
+ KEY_NOTIFY = 0x0010
+ KEY_CREATE_LINK = 0x0020
+ KEY_READ = STANDARD_RIGHTS_READ |
+ KEY_QUERY_VALUE | KEY_ENUMERATE_SUB_KEYS | KEY_NOTIFY
+ KEY_WRITE = STANDARD_RIGHTS_WRITE |
+ KEY_SET_VALUE | KEY_CREATE_SUB_KEY
+ KEY_EXECUTE = KEY_READ
+ KEY_ALL_ACCESS = KEY_READ | KEY_WRITE | KEY_CREATE_LINK
+
+ REG_OPTION_RESERVED = 0x0000
+ REG_OPTION_NON_VOLATILE = 0x0000
+ REG_OPTION_VOLATILE = 0x0001
+ REG_OPTION_CREATE_LINK = 0x0002
+ REG_OPTION_BACKUP_RESTORE = 0x0004
+ REG_OPTION_OPEN_LINK = 0x0008
+ REG_LEGAL_OPTION = REG_OPTION_RESERVED |
+ REG_OPTION_NON_VOLATILE | REG_OPTION_CREATE_LINK |
+ REG_OPTION_BACKUP_RESTORE | REG_OPTION_OPEN_LINK
+
+ REG_CREATED_NEW_KEY = 1
+ REG_OPENED_EXISTING_KEY = 2
+
+ REG_WHOLE_HIVE_VOLATILE = 0x0001
+ REG_REFRESH_HIVE = 0x0002
+ REG_NO_LAZY_FLUSH = 0x0004
+ REG_FORCE_RESTORE = 0x0008
+
+ MAX_KEY_LENGTH = 514
+ MAX_VALUE_LENGTH = 32768
+ end
+ include Constants
+ include Enumerable
+
+ #
+ # Error
+ #
+ class Error < ::StandardError
+ module Kernel32
+ extend Importer
+ dlload "kernel32.dll"
+ end
+ FormatMessageW = Kernel32.extern "int FormatMessageW(int, void *, int, int, void *, int, void *)", :stdcall
+ def initialize(code)
+ @code = code
+ buff = WCHAR_NUL * 1024
+ lang = 0
+ begin
+ len = FormatMessageW.call(0x1200, 0, code, lang, buff, 1024, 0)
+ msg = buff.byteslice(0, len * WCHAR_SIZE)
+ msg.delete!(WCHAR_CR)
+ msg.chomp!
+ msg.encode!(LOCALE)
+ rescue EncodingError
+ raise unless lang == 0
+ lang = 0x0409 # en_US
+ retry
+ end
+ super msg
+ end
+ attr_reader :code
+ end
+
+ #
+ # Predefined Keys
+ #
+ class PredefinedKey < Registry
+ def initialize(hkey, keyname)
+ @hkey = hkey
+ @parent = nil
+ @keyname = keyname
+ @disposition = REG_OPENED_EXISTING_KEY
+ end
+
+ # Predefined keys cannot be closed
+ def close
+ raise Error.new(5) ## ERROR_ACCESS_DENIED
+ end
+
+ # Fake #class method for Registry#open, Registry#create
+ def class
+ Registry
+ end
+
+ # Make all
+ Constants.constants.grep(/^HKEY_/) do |c|
+ Registry.const_set c, new(Constants.const_get(c), c.to_s)
+ end
+ end
+
+ #
+ # Win32 APIs
+ #
+ module API
+ include Constants
+ extend Importer
+ dlload "advapi32.dll"
+ [
+ "long RegOpenKeyExW(void *, void *, long, long, void *)",
+ "long RegCreateKeyExW(void *, void *, long, long, long, long, void *, void *, void *)",
+ "long RegEnumValueW(void *, long, void *, void *, void *, void *, void *, void *)",
+ "long RegEnumKeyExW(void *, long, void *, void *, void *, void *, void *, void *)",
+ "long RegQueryValueExW(void *, void *, void *, void *, void *, void *)",
+ "long RegSetValueExW(void *, void *, long, long, void *, long)",
+ "long RegDeleteValueW(void *, void *)",
+ "long RegDeleteKeyW(void *, void *)",
+ "long RegFlushKey(void *)",
+ "long RegCloseKey(void *)",
+ "long RegQueryInfoKey(void *, void *, void *, void *, void *, void *, void *, void *, void *, void *, void *, void *)",
+ ].each do |fn|
+ cfunc = extern fn, :stdcall
+ const_set cfunc.name.intern, cfunc
+ end
+
+ module_function
+
+ def check(result)
+ raise Error, result, caller(1) if result != 0
+ end
+
+ def win64?
+ /^(?:x64|x86_64)/ =~ RUBY_PLATFORM
+ end
+
+ def packhandle(h)
+ win64? ? packqw(h) : packdw(h)
+ end
+
+ def unpackhandle(h)
+ win64? ? unpackqw(h) : unpackdw(h)
+ end
+
+ def packdw(dw)
+ [dw].pack('V')
+ end
+
+ def unpackdw(dw)
+ dw += [0].pack('V')
+ dw.unpack('V')[0]
+ end
+
+ def packqw(qw)
+ [ qw & 0xFFFFFFFF, qw >> 32 ].pack('VV')
+ end
+
+ def unpackqw(qw)
+ qw = qw.unpack('VV')
+ (qw[1] << 32) | qw[0]
+ end
+
+ def make_wstr(str)
+ str.encode(WCHAR)
+ end
+
+ def OpenKey(hkey, name, opt, desired)
+ result = packhandle(0)
+ check RegOpenKeyExW.call(hkey, make_wstr(name), opt, desired, result)
+ unpackhandle(result)
+ end
+
+ def CreateKey(hkey, name, opt, desired)
+ result = packhandle(0)
+ disp = packdw(0)
+ check RegCreateKeyExW.call(hkey, make_wstr(name), 0, 0, opt, desired,
+ 0, result, disp)
+ [ unpackhandle(result), unpackdw(disp) ]
+ end
+
+ def EnumValue(hkey, index)
+ name = WCHAR_NUL * Constants::MAX_KEY_LENGTH
+ size = packdw(Constants::MAX_KEY_LENGTH)
+ check RegEnumValueW.call(hkey, index, name, size, 0, 0, 0, 0)
+ name.byteslice(0, unpackdw(size) * WCHAR_SIZE)
+ end
+
+ def EnumKey(hkey, index)
+ name = WCHAR_NUL * Constants::MAX_KEY_LENGTH
+ size = packdw(Constants::MAX_KEY_LENGTH)
+ wtime = ' ' * 8
+ check RegEnumKeyExW.call(hkey, index, name, size, 0, 0, 0, wtime)
+ [ name.byteslice(0, unpackdw(size) * WCHAR_SIZE), unpackqw(wtime) ]
+ end
+
+ def QueryValue(hkey, name)
+ type = packdw(0)
+ size = packdw(0)
+ name = make_wstr(name)
+ check RegQueryValueExW.call(hkey, name, 0, type, 0, size)
+ data = "\0".force_encoding('ASCII-8BIT') * unpackdw(size)
+ check RegQueryValueExW.call(hkey, name, 0, type, data, size)
+ [ unpackdw(type), data[0, unpackdw(size)] ]
+ end
+
+ def SetValue(hkey, name, type, data, size)
+ case type
+ when REG_SZ, REG_EXPAND_SZ, REG_MULTI_SZ
+ data = data.encode(WCHAR)
+ size ||= data.bytesize + WCHAR_SIZE
+ end
+ check RegSetValueExW.call(hkey, make_wstr(name), 0, type, data, size)
+ end
+
+ def DeleteValue(hkey, name)
+ check RegDeleteValue.call(hkey, make_wstr(name))
+ end
+
+ def DeleteKey(hkey, name)
+ check RegDeleteKey.call(hkey, make_wstr(name))
+ end
+
+ def FlushKey(hkey)
+ check RegFlushKey.call(hkey)
+ end
+
+ def CloseKey(hkey)
+ check RegCloseKey.call(hkey)
+ end
+
+ def QueryInfoKey(hkey)
+ subkeys = packdw(0)
+ maxsubkeylen = packdw(0)
+ values = packdw(0)
+ maxvaluenamelen = packdw(0)
+ maxvaluelen = packdw(0)
+ secdescs = packdw(0)
+ wtime = ' ' * 8
+ check RegQueryInfoKey.call(hkey, 0, 0, 0, subkeys, maxsubkeylen, 0,
+ values, maxvaluenamelen, maxvaluelen, secdescs, wtime)
+ [ unpackdw(subkeys), unpackdw(maxsubkeylen), unpackdw(values),
+ unpackdw(maxvaluenamelen), unpackdw(maxvaluelen),
+ unpackdw(secdescs), unpackqw(wtime) ]
+ end
+ end
+
+ #
+ # Replace %\w+% into the environment value of what is contained between the %'s
+ # This method is used for REG_EXPAND_SZ.
+ #
+ # For detail, see expandEnvironmentStrings[http://msdn.microsoft.com/library/en-us/sysinfo/base/expandenvironmentstrings.asp] \Win32 \API.
+ #
+ def self.expand_environ(str)
+ str.gsub(Regexp.compile("%([^%]+)%".encode(str.encoding))) {
+ v = $1.encode(LOCALE)
+ (e = ENV[v] || ENV[v.upcase]; e.encode(str.encoding) if e) ||
+ $&
+ }
+ end
+
+ @@type2name = { }
+ %w[
+ REG_NONE REG_SZ REG_EXPAND_SZ REG_BINARY REG_DWORD
+ REG_DWORD_BIG_ENDIAN REG_LINK REG_MULTI_SZ
+ REG_RESOURCE_LIST REG_FULL_RESOURCE_DESCRIPTOR
+ REG_RESOURCE_REQUIREMENTS_LIST REG_QWORD
+ ].each do |type|
+ @@type2name[Constants.const_get(type)] = type
+ end
+
+ #
+ # Convert registry type value to readable string.
+ #
+ def self.type2name(type)
+ @@type2name[type] || type.to_s
+ end
+
+ #
+ # Convert 64-bit FILETIME integer into Time object.
+ #
+ def self.wtime2time(wtime)
+ Time.at((wtime - 116444736000000000) / 10000000)
+ end
+
+ #
+ # Convert Time object or Integer object into 64-bit FILETIME.
+ #
+ def self.time2wtime(time)
+ time.to_i * 10000000 + 116444736000000000
+ end
+
+ #
+ # constructor
+ #
+ private_class_method :new
+
+ #
+ # --- Registry.open(key, subkey, desired = KEY_READ, opt = REG_OPTION_RESERVED)
+ #
+ # --- Registry.open(key, subkey, desired = KEY_READ, opt = REG_OPTION_RESERVED) { |reg| ... }
+ #
+ # Open the registry key subkey under key.
+ # key is Win32::Registry object of parent key.
+ # You can use predefined key HKEY_* (see Constants)
+ # desired and opt is access mask and key option.
+ # For detail, see the MSDN[http://msdn.microsoft.com/library/en-us/sysinfo/base/regopenkeyex.asp].
+ # If block is given, the key is closed automatically.
+ def self.open(hkey, subkey, desired = KEY_READ, opt = REG_OPTION_RESERVED)
+ subkey = subkey.chomp('\\')
+ newkey = API.OpenKey(hkey.hkey, subkey, opt, desired)
+ obj = new(newkey, hkey, subkey, REG_OPENED_EXISTING_KEY)
+ if block_given?
+ begin
+ yield obj
+ ensure
+ obj.close
+ end
+ else
+ obj
+ end
+ end
+
+ #
+ # --- Registry.create(key, subkey, desired = KEY_ALL_ACCESS, opt = REG_OPTION_RESERVED)
+ #
+ # --- Registry.create(key, subkey, desired = KEY_ALL_ACCESS, opt = REG_OPTION_RESERVED) { |reg| ... }
+ #
+ # Create or open the registry key subkey under key.
+ # You can use predefined key HKEY_* (see Constants)
+ #
+ # If subkey is already exists, key is opened and Registry#created?
+ # method will return false.
+ #
+ # If block is given, the key is closed automatically.
+ #
+ def self.create(hkey, subkey, desired = KEY_ALL_ACCESS, opt = REG_OPTION_RESERVED)
+ newkey, disp = API.CreateKey(hkey.hkey, subkey, opt, desired)
+ obj = new(newkey, hkey, subkey, disp)
+ if block_given?
+ begin
+ yield obj
+ ensure
+ obj.close
+ end
+ else
+ obj
+ end
+ end
+
+ #
+ # finalizer
+ #
+ @@final = proc { |hkey| proc { API.CloseKey(hkey[0]) if hkey[0] } }
+
+ #
+ # initialize
+ #
+ def initialize(hkey, parent, keyname, disposition)
+ @hkey = hkey
+ @parent = parent
+ @keyname = keyname
+ @disposition = disposition
+ @hkeyfinal = [ hkey ]
+ ObjectSpace.define_finalizer self, @@final.call(@hkeyfinal)
+ end
+
+ # Returns key handle value.
+ attr_reader :hkey
+ # Win32::Registry object of parent key, or nil if predefeined key.
+ attr_reader :parent
+ # Same as subkey value of Registry.open or
+ # Registry.create method.
+ attr_reader :keyname
+ # Disposition value (REG_CREATED_NEW_KEY or REG_OPENED_EXISTING_KEY).
+ attr_reader :disposition
+
+ #
+ # Returns if key is created ((*newly*)).
+ # (see Registry.create) -- basically you call create
+ # then when you call created? on the instance returned
+ # it will tell if it was successful or not
+ #
+ def created?
+ @disposition == REG_CREATED_NEW_KEY
+ end
+
+ #
+ # Returns if key is not closed.
+ #
+ def open?
+ !@hkey.nil?
+ end
+
+ #
+ # Full path of key such as 'HKEY_CURRENT_USER\SOFTWARE\foo\bar'.
+ #
+ def name
+ parent = self
+ name = @keyname
+ while parent = parent.parent
+ name = parent.keyname + '\\' + name
+ end
+ name
+ end
+
+ def inspect
+ "\#<Win32::Registry key=#{name.inspect}>"
+ end
+
+ #
+ # marshalling is not allowed
+ #
+ def _dump(depth)
+ raise TypeError, "can't dump Win32::Registry"
+ end
+
+ #
+ # Same as Win32::Registry.open (self, subkey, desired, opt)
+ #
+ def open(subkey, desired = KEY_READ, opt = REG_OPTION_RESERVED, &blk)
+ self.class.open(self, subkey, desired, opt, &blk)
+ end
+
+ #
+ # Same as Win32::Registry.create (self, subkey, desired, opt)
+ #
+ def create(subkey, desired = KEY_ALL_ACCESS, opt = REG_OPTION_RESERVED, &blk)
+ self.class.create(self, subkey, desired, opt, &blk)
+ end
+
+ #
+ # Close key.
+ #
+ # After close, most method raise an error.
+ #
+ def close
+ API.CloseKey(@hkey)
+ @hkey = @parent = @keyname = nil
+ @hkeyfinal[0] = nil
+ end
+
+ #
+ # Enumerate values.
+ #
+ def each_value
+ index = 0
+ while true
+ begin
+ subkey = API.EnumValue(@hkey, index)
+ rescue Error
+ break
+ end
+ subkey = export_string(subkey)
+ begin
+ type, data = read(subkey)
+ rescue Error
+ next
+ end
+ yield subkey, type, data
+ index += 1
+ end
+ index
+ end
+ alias each each_value
+
+ #
+ # return values as an array
+ #
+ def values
+ vals_ary = []
+ each_value { |*, val| vals_ary << val }
+ vals_ary
+ end
+
+ #
+ # Enumerate subkeys.
+ #
+ # subkey is String which contains name of subkey.
+ # wtime is last write time as FILETIME (64-bit integer).
+ # (see Registry.wtime2time)
+ #
+ def each_key
+ index = 0
+ while true
+ begin
+ subkey, wtime = API.EnumKey(@hkey, index)
+ rescue Error
+ break
+ end
+ subkey = export_string(subkey)
+ yield subkey, wtime
+ index += 1
+ end
+ index
+ end
+
+ #
+ # return keys as an array
+ #
+ def keys
+ keys_ary = []
+ each_key { |key,| keys_ary << key }
+ keys_ary
+ end
+
+ # Read a registry value named name and return array of
+ # [ type, data ].
+ # When name is nil, the `default' value is read.
+ # type is value type. (see Win32::Registry::Constants module)
+ # data is value data, its class is:
+ # :REG_SZ, REG_EXPAND_SZ
+ # String
+ # :REG_MULTI_SZ
+ # Array of String
+ # :REG_DWORD, REG_DWORD_BIG_ENDIAN, REG_QWORD
+ # Integer
+ # :REG_BINARY
+ # String (contains binary data)
+ #
+ # When rtype is specified, the value type must be included by
+ # rtype array, or TypeError is raised.
+ def read(name, *rtype)
+ type, data = API.QueryValue(@hkey, name)
+ unless rtype.empty? or rtype.include?(type)
+ raise TypeError, "Type mismatch (expect #{rtype.inspect} but #{type} present)"
+ end
+ case type
+ when REG_SZ, REG_EXPAND_SZ
+ [ type, data.encode(name.encoding, WCHAR).chop ]
+ when REG_MULTI_SZ
+ [ type, data.encode(name.encoding, WCHAR).split(/\0/) ]
+ when REG_BINARY
+ [ type, data ]
+ when REG_DWORD
+ [ type, API.unpackdw(data) ]
+ when REG_DWORD_BIG_ENDIAN
+ [ type, data.unpack('N')[0] ]
+ when REG_QWORD
+ [ type, API.unpackqw(data) ]
+ else
+ raise TypeError, "Type #{type} is not supported."
+ end
+ end
+
+ #
+ # Read a registry value named name and return its value data.
+ # The class of value is same as #read method returns.
+ #
+ # If the value type is REG_EXPAND_SZ, returns value data whose environment
+ # variables are replaced.
+ # If the value type is neither REG_SZ, REG_MULTI_SZ, REG_DWORD,
+ # REG_DWORD_BIG_ENDIAN, nor REG_QWORD, TypeError is raised.
+ #
+ # The meaning of rtype is same as #read method.
+ #
+ def [](name, *rtype)
+ type, data = read(name, *rtype)
+ case type
+ when REG_SZ, REG_DWORD, REG_QWORD, REG_MULTI_SZ
+ data
+ when REG_EXPAND_SZ
+ Registry.expand_environ(data)
+ else
+ raise TypeError, "Type #{type} is not supported."
+ end
+ end
+
+ # Read a REG_SZ(read_s), REG_DWORD(read_i), or REG_BINARY(read_bin)
+ # registry value named name.
+ #
+ # If the values type does not match, TypeError is raised.
+ def read_s(name)
+ read(name, REG_SZ)[1]
+ end
+
+ #
+ # Read a REG_SZ or REG_EXPAND_SZ registry value named name.
+ #
+ # If the value type is REG_EXPAND_SZ, environment variables are replaced.
+ # Unless the value type is REG_SZ or REG_EXPAND_SZ, TypeError is raised.
+ #
+ def read_s_expand(name)
+ type, data = read(name, REG_SZ, REG_EXPAND_SZ)
+ if type == REG_EXPAND_SZ
+ Registry.expand_environ(data)
+ else
+ data
+ end
+ end
+
+ #
+ # Read a REG_SZ(read_s), REG_DWORD(read_i), or REG_BINARY(read_bin)
+ # registry value named name.
+ #
+ # If the values type does not match, TypeError is raised.
+ #
+ def read_i(name)
+ read(name, REG_DWORD, REG_DWORD_BIG_ENDIAN, REG_QWORD)[1]
+ end
+
+ #
+ # Read a REG_SZ(read_s), REG_DWORD(read_i), or REG_BINARY(read_bin)
+ # registry value named name.
+ #
+ # If the values type does not match, TypeError is raised.
+ #
+ def read_bin(name)
+ read(name, REG_BINARY)[1]
+ end
+
+ #
+ # Write data to a registry value named name.
+ # When name is nil, write to the `default' value.
+ #
+ # type is type value. (see Registry::Constants module)
+ # Class of data must be same as which #read
+ # method returns.
+ #
+ def write(name, type, data)
+ termsize = 0
+ case type
+ when REG_SZ, REG_EXPAND_SZ
+ data = data.encode(WCHAR)
+ termsize = WCHAR_SIZE
+ when REG_MULTI_SZ
+ data = data.to_a.map {|s| s.encode(WCHAR)}.join(WCHAR_NUL) << WCHAR_NUL
+ termsize = WCHAR_SIZE
+ when REG_BINARY
+ data = data.to_s
+ when REG_DWORD
+ data = API.packdw(data.to_i)
+ when REG_DWORD_BIG_ENDIAN
+ data = [data.to_i].pack('N')
+ when REG_QWORD
+ data = API.packqw(data.to_i)
+ else
+ raise TypeError, "Unsupported type #{type}"
+ end
+ API.SetValue(@hkey, name, type, data, data.bytesize + termsize)
+ end
+
+ #
+ # Write value to a registry value named name.
+ #
+ # If wtype is specified, the value type is it.
+ # Otherwise, the value type is depend on class of value:
+ # :Integer
+ # REG_DWORD
+ # :String
+ # REG_SZ
+ # :Array
+ # REG_MULTI_SZ
+ #
+ def []=(name, rtype, value = nil)
+ if value
+ write name, rtype, value
+ else
+ case value = rtype
+ when Integer
+ write name, REG_DWORD, value
+ when String
+ write name, REG_SZ, value
+ when Array
+ write name, REG_MULTI_SZ, value
+ else
+ raise TypeError, "Unexpected type #{value.class}"
+ end
+ end
+ value
+ end
+
+ #
+ # Write value to a registry value named name.
+ #
+ # The value type is REG_SZ(write_s), REG_DWORD(write_i), or
+ # REG_BINARY(write_bin).
+ #
+ def write_s(name, value)
+ write name, REG_SZ, value.to_s
+ end
+
+ #
+ # Write value to a registry value named name.
+ #
+ # The value type is REG_SZ(write_s), REG_DWORD(write_i), or
+ # REG_BINARY(write_bin).
+ #
+ def write_i(name, value)
+ write name, REG_DWORD, value.to_i
+ end
+
+ #
+ # Write value to a registry value named name.
+ #
+ # The value type is REG_SZ(write_s), REG_DWORD(write_i), or
+ # REG_BINARY(write_bin).
+ #
+ def write_bin(name, value)
+ write name, REG_BINARY, value.to_s
+ end
+
+ #
+ # Delete a registry value named name.
+ # We can not delete the `default' value.
+ #
+ def delete_value(name)
+ API.DeleteValue(@hkey, name)
+ end
+ alias delete delete_value
+
+ #
+ # Delete a subkey named name and all its values.
+ #
+ # If recursive is false, the subkey must not have subkeys.
+ # Otherwise, this method deletes all subkeys and values recursively.
+ #
+ def delete_key(name, recursive = false)
+ if recursive
+ open(name, KEY_ALL_ACCESS) do |reg|
+ reg.keys.each do |key|
+ begin
+ reg.delete_key(key, true)
+ rescue Error
+ #
+ end
+ end
+ end
+ API.DeleteKey(@hkey, name)
+ else
+ begin
+ API.EnumKey @hkey, 0
+ rescue Error
+ return API.DeleteKey(@hkey, name)
+ end
+ raise Error.new(5) ## ERROR_ACCESS_DENIED
+ end
+ end
+
+ #
+ # Write all the attributes into the registry file.
+ #
+ def flush
+ API.FlushKey @hkey
+ end
+
+ #
+ # Returns key information as Array of:
+ # :num_keys
+ # The number of subkeys.
+ # :max_key_length
+ # Maximum length of name of subkeys.
+ # :num_values
+ # The number of values.
+ # :max_value_name_length
+ # Maximum length of name of values.
+ # :max_value_length
+ # Maximum length of value of values.
+ # :descriptor_length
+ # Length of security descriptor.
+ # :wtime
+ # Last write time as FILETIME(64-bit integer)
+ #
+ # For detail, see RegQueryInfoKey[http://msdn.microsoft.com/library/en-us/sysinfo/base/regqueryinfokey.asp] Win32 API.
+ #
+ def info
+ API.QueryInfoKey(@hkey)
+ end
+
+ #
+ # Returns an item of key information.
+ #
+ %w[
+ num_keys max_key_length
+ num_values max_value_name_length max_value_length
+ descriptor_length wtime
+ ].each_with_index do |s, i|
+ eval <<-__END__
+ def #{s}
+ info[#{i}]
+ end
+ __END__
+ end
+
+ private
+
+ def export_string(str, enc = Encoding.default_internal || LOCALE) # :nodoc:
+ str.encode(enc)
+ end
+ end
+end
diff --git a/jni/ruby/ext/win32/lib/win32/resolv.rb b/jni/ruby/ext/win32/lib/win32/resolv.rb
new file mode 100644
index 0000000..b5c11bf
--- /dev/null
+++ b/jni/ruby/ext/win32/lib/win32/resolv.rb
@@ -0,0 +1,378 @@
+=begin
+= Win32 DNS and DHCP I/F
+
+=end
+
+require 'win32/registry'
+
+module Win32
+ module Resolv
+ API = Registry::API
+
+ def self.get_hosts_path
+ path = get_hosts_dir
+ path = File.expand_path('hosts', path)
+ File.exist?(path) ? path : nil
+ end
+
+ def self.get_resolv_info
+ search, nameserver = get_info
+ if search.empty?
+ search = nil
+ else
+ search.delete("")
+ search.uniq!
+ end
+ if nameserver.empty?
+ nameserver = nil
+ else
+ nameserver.delete("")
+ nameserver.delete("0.0.0.0")
+ nameserver.uniq!
+ end
+ [ search, nameserver ]
+ end
+
+module Kernel32
+ extend Importer
+ dlload "kernel32"
+end
+getv = Kernel32.extern "int GetVersionExA(void *)", :stdcall
+info = [ 148, 0, 0, 0, 0 ].pack('V5') + "\0" * 128
+getv.call(info)
+if info.unpack('V5')[4] == 2 # VER_PLATFORM_WIN32_NT
+#====================================================================
+# Windows NT
+#====================================================================
+ module_eval <<-'__EOS__', __FILE__, __LINE__+1
+ TCPIP_NT = 'SYSTEM\CurrentControlSet\Services\Tcpip\Parameters'
+
+ class << self
+ private
+ def get_hosts_dir
+ Registry::HKEY_LOCAL_MACHINE.open(TCPIP_NT) do |reg|
+ reg.read_s_expand('DataBasePath')
+ end
+ end
+
+ def get_info
+ search = nil
+ nameserver = []
+ Registry::HKEY_LOCAL_MACHINE.open(TCPIP_NT) do |reg|
+ begin
+ slist = reg.read_s('SearchList')
+ search = slist.split(/,\s*/) unless slist.empty?
+ rescue Registry::Error
+ end
+
+ if add_search = search.nil?
+ search = []
+ begin
+ nvdom = reg.read_s('NV Domain')
+ unless nvdom.empty?
+ @search = [ nvdom ]
+ if reg.read_i('UseDomainNameDevolution') != 0
+ if /^\w+\./ =~ nvdom
+ devo = $'
+ end
+ end
+ end
+ rescue Registry::Error
+ end
+ end
+
+ reg.open('Interfaces') do |h|
+ h.each_key do |iface,|
+ h.open(iface) do |regif|
+ begin
+ [ 'NameServer', 'DhcpNameServer' ].each do |key|
+ begin
+ ns = regif.read_s(key)
+ rescue
+ else
+ unless ns.empty?
+ nameserver.concat(ns.split(/[,\s]\s*/))
+ break
+ end
+ end
+ end
+ rescue Registry::Error
+ end
+
+ if add_search
+ begin
+ [ 'Domain', 'DhcpDomain' ].each do |key|
+ dom = regif.read_s(key)
+ unless dom.empty?
+ search.concat(dom.split(/,\s*/))
+ break
+ end
+ end
+ rescue Registry::Error
+ end
+ end
+ end
+ end
+ end
+ search << devo if add_search and devo
+ end
+ [ search.uniq, nameserver.uniq ]
+ end
+ end
+ __EOS__
+else
+#====================================================================
+# Windows 9x
+#====================================================================
+ module_eval <<-'__EOS__', __FILE__, __LINE__+1
+ TCPIP_9X = 'SYSTEM\CurrentControlSet\Services\VxD\MSTCP'
+ DHCP_9X = 'SYSTEM\CurrentControlSet\Services\VxD\DHCP'
+ WINDOWS = 'Software\Microsoft\Windows\CurrentVersion'
+
+ class << self
+ # private
+
+ def get_hosts_dir
+ Registry::HKEY_LOCAL_MACHINE.open(WINDOWS) do |reg|
+ reg.read_s_expand('SystemRoot')
+ end
+ end
+
+ def get_info
+ search = []
+ nameserver = []
+ begin
+ Registry::HKEY_LOCAL_MACHINE.open(TCPIP_9X) do |reg|
+ if reg.read_s("EnableDNS") == "1"
+ domain = reg.read_s("Domain")
+ ns = reg.read_s("NameServer")
+ slist = reg.read_s("SearchList")
+ search << domain unless domain.empty?
+ search.concat(slist.split(/,\s*/))
+ nameserver.concat(ns.split(/[,\s]\s*/))
+ end
+ end
+ rescue Registry::Error
+ end
+
+ dhcpinfo = get_dhcpinfo
+ search.concat(dhcpinfo[0])
+ nameserver.concat(dhcpinfo[1])
+ [ search, nameserver ]
+ end
+
+ def get_dhcpinfo
+ macaddrs = {}
+ ipaddrs = {}
+ WsControl.get_iflist.each do |index, macaddr, *ipaddr|
+ macaddrs[macaddr] = 1
+ ipaddr.each { |ipaddr| ipaddrs[ipaddr] = 1 }
+ end
+ iflist = [ macaddrs, ipaddrs ]
+
+ search = []
+ nameserver = []
+ version = -1
+ Registry::HKEY_LOCAL_MACHINE.open(DHCP_9X) do |reg|
+ begin
+ version = API.unpackdw(reg.read_bin("Version"))
+ rescue Registry::Error
+ end
+
+ reg.each_key do |key,|
+ catch(:not_used) do
+ reg.open(key) do |regdi|
+ dom, ns = get_dhcpinfo_key(version, regdi, iflist)
+ search << dom if dom
+ nameserver.concat(ns) if ns
+ end
+ end
+ end
+ end
+ [ search, nameserver ]
+ end
+
+ def get_dhcpinfo_95(reg)
+ dhcp = reg.read_bin("DhcpInfo")
+ [
+ API.unpackdw(dhcp[4..7]),
+ API.unpackdw(dhcp[8..11]),
+ 1,
+ dhcp[45..50],
+ reg.read_bin("OptionInfo"),
+ ]
+ end
+
+ def get_dhcpinfo_98(reg)
+ [
+ API.unpackdw(reg.read_bin("DhcpIPAddress")),
+ API.unpackdw(reg.read_bin("DhcpSubnetMask")),
+ API.unpackdw(reg.read_bin("HardwareType")),
+ reg.read_bin("HardwareAddress"),
+ reg.read_bin("OptionInfo"),
+ ]
+ end
+
+ def get_dhcpinfo_key(version, reg, iflist)
+ info = case version
+ when 1
+ get_dhcpinfo_95(reg)
+ when 2
+ get_dhcpinfo_98(reg)
+ else
+ begin
+ get_dhcpinfo_98(reg)
+ rescue Registry::Error
+ get_dhcpinfo_95(reg)
+ end
+ end
+ ipaddr, netmask, hwtype, macaddr, opt = info
+ throw :not_used unless
+ ipaddr and ipaddr != 0 and
+ netmask and netmask != 0 and
+ macaddr and macaddr.size == 6 and
+ hwtype == 1 and
+ iflist[0][macaddr] and iflist[1][ipaddr]
+
+ size = opt.size
+ idx = 0
+ while idx <= size
+ opttype = opt[idx]
+ optsize = opt[idx + 1]
+ optval = opt[idx + 2, optsize]
+ case opttype
+ when 0xFF ## term
+ break
+ when 0x0F ## domain
+ domain = optval.chomp("\0")
+ when 0x06 ## dns
+ nameserver = optval.scan(/..../).collect { |addr|
+ "%d.%d.%d.%d" % addr.unpack('C4')
+ }
+ end
+ idx += optsize + 2
+ end
+ [ domain, nameserver ]
+ rescue Registry::Error
+ throw :not_used
+ end
+ end
+
+ module WsControl
+ module WSock32
+ extend Importer
+ dlload "wsock32.dll"
+ end
+ WsControl = WSock32.extern "int WsControl(int, int, void *, void *, void *, void *", :stdcall
+ WSAGetLastError = WSock32.extern "int WSAGetLastError(void)", :stdcall
+
+ MAX_TDI_ENTITIES = 512
+ IPPROTO_TCP = 6
+ WSCTL_TCP_QUERY_INFORMATION = 0
+ INFO_CLASS_GENERIC = 0x100
+ INFO_CLASS_PROTOCOL = 0x200
+ INFO_TYPE_PROVIDER = 0x100
+ ENTITY_LIST_ID = 0
+ GENERIC_ENTITY = 0
+ CL_NL_ENTITY = 0x301
+ IF_ENTITY = 0x200
+ ENTITY_TYPE_ID = 1
+ CL_NL_IP = 0x303
+ IF_MIB = 0x202
+ IF_MIB_STATS_ID = 1
+ IP_MIB_ADDRTABLE_ENTRY_ID = 0x102
+
+ def self.wsctl(tei_entity, tei_instance,
+ toi_class, toi_type, toi_id,
+ buffsize)
+ reqinfo = [
+ ## TDIEntityID
+ tei_entity, tei_instance,
+ ## TDIObjectID
+ toi_class, toi_type, toi_id,
+ ## TCP_REQUEST_INFORMATION_EX
+ ""
+ ].pack('VVVVVa16')
+ reqsize = API.packdw(reqinfo.size)
+ buff = "\0" * buffsize
+ buffsize = API.packdw(buffsize)
+ result = WsControl.call(
+ IPPROTO_TCP,
+ WSCTL_TCP_QUERY_INFORMATION,
+ reqinfo, reqsize,
+ buff, buffsize)
+ if result != 0
+ raise RuntimeError, "WsControl failed.(#{result})"
+ end
+ [ buff, API.unpackdw(buffsize) ]
+ end
+ private_class_method :wsctl
+
+ def self.get_iflist
+ # Get TDI Entity List
+ entities, size =
+ wsctl(GENERIC_ENTITY, 0,
+ INFO_CLASS_GENERIC,
+ INFO_TYPE_PROVIDER,
+ ENTITY_LIST_ID,
+ MAX_TDI_ENTITIES * 8) # sizeof(TDIEntityID)
+ entities = entities[0, size].
+ scan(/.{8}/).
+ collect { |e| e.unpack('VV') }
+
+ # Get MIB Interface List
+ iflist = []
+ ifcount = 0
+ entities.each do |entity, instance|
+ if( (entity & IF_ENTITY)>0 )
+ ifcount += 1
+ etype, = wsctl(entity, instance,
+ INFO_CLASS_GENERIC,
+ INFO_TYPE_PROVIDER,
+ ENTITY_TYPE_ID,
+ 4)
+ if( (API.unpackdw(etype) & IF_MIB)==IF_MIB )
+ ifentry, = wsctl(entity, instance,
+ INFO_CLASS_PROTOCOL,
+ INFO_TYPE_PROVIDER,
+ IF_MIB_STATS_ID,
+ 21 * 4 + 8 + 130) # sizeof(IFEntry)
+ iflist << [
+ API.unpackdw(ifentry[0,4]),
+ ifentry[20, 6]
+ ]
+ end
+ end
+ end
+
+ # Get IP Addresses
+ entities.each do |entity, instance|
+ if entity == CL_NL_ENTITY
+ etype, = wsctl(entity, instance,
+ INFO_CLASS_GENERIC,
+ INFO_TYPE_PROVIDER,
+ ENTITY_TYPE_ID,
+ 4)
+ if API.unpackdw(etype) == CL_NL_IP
+ ipentries, = wsctl(entity, instance,
+ INFO_CLASS_PROTOCOL,
+ INFO_TYPE_PROVIDER,
+ IP_MIB_ADDRTABLE_ENTRY_ID,
+ 24 * (ifcount+1)) # sizeof(IPAddrEntry)
+ ipentries.scan(/.{24}/) do |ipentry|
+ ipaddr, index = ipentry.unpack('VV')
+ if ifitem = iflist.assoc(index)
+ ifitem << ipaddr
+ end
+ end
+ end
+ end
+ end
+ iflist
+ end
+ end
+ __EOS__
+end
+#====================================================================
+ end
+end
diff --git a/jni/ruby/ext/win32/lib/win32/sspi.rb b/jni/ruby/ext/win32/lib/win32/sspi.rb
new file mode 100644
index 0000000..4645e1b
--- /dev/null
+++ b/jni/ruby/ext/win32/lib/win32/sspi.rb
@@ -0,0 +1,330 @@
+#
+# = win32/sspi.rb
+#
+# Copyright (c) 2006-2007 Justin Bailey
+#
+# Written and maintained by Justin Bailey <jgbailey@gmail.com>.
+#
+# This program is free software. You can re-distribute and/or
+# modify this program under the same terms of ruby itself ---
+# Ruby Distribution License or GNU General Public License.
+#
+
+require 'Win32API'
+
+# Implements bindings to Win32 SSPI functions, focused on authentication to a proxy server over HTTP.
+module Win32
+ module SSPI
+ # Specifies how credential structure requested will be used. Only SECPKG_CRED_OUTBOUND is used
+ # here.
+ SECPKG_CRED_INBOUND = 0x00000001
+ SECPKG_CRED_OUTBOUND = 0x00000002
+ SECPKG_CRED_BOTH = 0x00000003
+
+ # Format of token. NETWORK format is used here.
+ SECURITY_NATIVE_DREP = 0x00000010
+ SECURITY_NETWORK_DREP = 0x00000000
+
+ # InitializeSecurityContext Requirement flags
+ ISC_REQ_REPLAY_DETECT = 0x00000004
+ ISC_REQ_SEQUENCE_DETECT = 0x00000008
+ ISC_REQ_CONFIDENTIALITY = 0x00000010
+ ISC_REQ_USE_SESSION_KEY = 0x00000020
+ ISC_REQ_PROMPT_FOR_CREDS = 0x00000040
+ ISC_REQ_CONNECTION = 0x00000800
+
+ # Win32 API Functions. Uses Win32API to bind methods to constants contained in class.
+ module API
+ # Can be called with AcquireCredentialsHandle.call()
+ AcquireCredentialsHandle = Win32API.new("secur32", "AcquireCredentialsHandle", 'ppLpppppp', 'L')
+ # Can be called with InitializeSecurityContext.call()
+ InitializeSecurityContext = Win32API.new("secur32", "InitializeSecurityContext", 'pppLLLpLpppp', 'L')
+ # Can be called with DeleteSecurityContext.call()
+ DeleteSecurityContext = Win32API.new("secur32", "DeleteSecurityContext", 'P', 'L')
+ # Can be called with FreeCredentialsHandle.call()
+ FreeCredentialsHandle = Win32API.new("secur32", "FreeCredentialsHandle", 'P', 'L')
+ end
+
+ # SecHandle struct
+ class SecurityHandle
+ def upper
+ @struct.unpack("LL")[1]
+ end
+
+ def lower
+ @struct.unpack("LL")[0]
+ end
+
+ def to_p
+ @struct ||= "\0" * 8
+ end
+ end
+
+ # Some familiar aliases for the SecHandle structure
+ CredHandle = CtxtHandle = SecurityHandle
+
+ # TimeStamp struct
+ class TimeStamp
+ attr_reader :struct
+
+ def to_p
+ @struct ||= "\0" * 8
+ end
+ end
+
+ # Creates binary representaiton of a SecBufferDesc structure,
+ # including the SecBuffer contained inside.
+ class SecurityBuffer
+
+ SECBUFFER_TOKEN = 2 # Security token
+
+ TOKENBUFSIZE = 12288
+ SECBUFFER_VERSION = 0
+
+ def initialize(buffer = nil)
+ @buffer = buffer || "\0" * TOKENBUFSIZE
+ @bufferSize = @buffer.length
+ @type = SECBUFFER_TOKEN
+ end
+
+ def bufferSize
+ unpack
+ @bufferSize
+ end
+
+ def bufferType
+ unpack
+ @type
+ end
+
+ def token
+ unpack
+ @buffer
+ end
+
+ def to_p
+ # Assumption is that when to_p is called we are going to get a packed structure. Therefore,
+ # set @unpacked back to nil so we know to unpack when accessors are next accessed.
+ @unpacked = nil
+ # Assignment of inner structure to variable is very important here. Without it,
+ # will not be able to unpack changes to the structure. Alternative, nested unpacks,
+ # does not work (i.e. @struct.unpack("LLP12")[2].unpack("LLP12") results in "no associated pointer")
+ @sec_buffer ||= [@bufferSize, @type, @buffer].pack("LLP")
+ @struct ||= [SECBUFFER_VERSION, 1, @sec_buffer].pack("LLP")
+ end
+
+ private
+
+ # Unpacks the SecurityBufferDesc structure into member variables. We
+ # only want to do this once per struct, so the struct is deleted
+ # after unpacking.
+ def unpack
+ if ! @unpacked && @sec_buffer && @struct
+ @bufferSize, @type = @sec_buffer.unpack("LL")
+ @buffer = @sec_buffer.unpack("LLP#{@bufferSize}")[2]
+ @struct = nil
+ @sec_buffer = nil
+ @unpacked = true
+ end
+ end
+ end
+
+ # SEC_WINNT_AUTH_IDENTITY structure
+ class Identity
+ SEC_WINNT_AUTH_IDENTITY_ANSI = 0x1
+
+ attr_accessor :user, :domain, :password
+
+ def initialize(user = nil, domain = nil, password = nil)
+ @user = user
+ @domain = domain
+ @password = password
+ @flags = SEC_WINNT_AUTH_IDENTITY_ANSI
+ end
+
+ def to_p
+ [@user, @user ? @user.length : 0,
+ @domain, @domain ? @domain.length : 0,
+ @password, @password ? @password.length : 0,
+ @flags].pack("PLPLPLL")
+ end
+ end
+
+ # Takes a return result from an SSPI function and interprets the value.
+ class SSPIResult
+ # Good results
+ SEC_E_OK = 0x00000000
+ SEC_I_CONTINUE_NEEDED = 0x00090312
+
+ # These are generally returned by InitializeSecurityContext
+ SEC_E_INSUFFICIENT_MEMORY = 0x80090300
+ SEC_E_INTERNAL_ERROR = 0x80090304
+ SEC_E_INVALID_HANDLE = 0x80090301
+ SEC_E_INVALID_TOKEN = 0x80090308
+ SEC_E_LOGON_DENIED = 0x8009030C
+ SEC_E_NO_AUTHENTICATING_AUTHORITY = 0x80090311
+ SEC_E_NO_CREDENTIALS = 0x8009030E
+ SEC_E_TARGET_UNKNOWN = 0x80090303
+ SEC_E_UNSUPPORTED_FUNCTION = 0x80090302
+ SEC_E_WRONG_PRINCIPAL = 0x80090322
+
+ # These are generally returned by AcquireCredentialsHandle
+ SEC_E_NOT_OWNER = 0x80090306
+ SEC_E_SECPKG_NOT_FOUND = 0x80090305
+ SEC_E_UNKNOWN_CREDENTIALS = 0x8009030D
+
+ @@map = {}
+ constants.each { |v| @@map[self.const_get(v.to_s)] = v }
+
+ attr_reader :value
+
+ def initialize(value)
+ # convert to unsigned long
+ value = [value].pack("L").unpack("L").first
+ raise "#{value.to_s(16)} is not a recognized result" unless @@map.has_key? value
+ @value = value
+ end
+
+ def to_s
+ @@map[@value].to_s
+ end
+
+ def ok?
+ @value == SEC_I_CONTINUE_NEEDED || @value == SEC_E_OK
+ end
+
+ def ==(other)
+ if other.is_a?(SSPIResult)
+ @value == other.value
+ elsif other.is_a?(Fixnum)
+ @value == @@map[other]
+ else
+ false
+ end
+ end
+ end
+
+ # Handles "Negotiate" type authentication. Geared towards authenticating with a proxy server over HTTP
+ class NegotiateAuth
+ attr_accessor :credentials, :context, :contextAttributes, :user, :domain
+
+ # Default request flags for SSPI functions
+ REQUEST_FLAGS = ISC_REQ_CONFIDENTIALITY | ISC_REQ_REPLAY_DETECT | ISC_REQ_CONNECTION
+
+ # NTLM tokens start with this header always. Encoding alone adds "==" and newline, so remove those
+ B64_TOKEN_PREFIX = ["NTLMSSP"].pack("m").delete("=\n")
+
+ # Given a connection and a request path, performs authentication as the current user and returns
+ # the response from a GET request. The connnection should be a Net::HTTP object, and it should
+ # have been constructed using the Net::HTTP.Proxy method, but anything that responds to "get" will work.
+ # If a user and domain are given, will authenticate as the given user.
+ # Returns the response received from the get method (usually Net::HTTPResponse)
+ def NegotiateAuth.proxy_auth_get(http, path, user = nil, domain = nil)
+ raise "http must respond to :get" unless http.respond_to?(:get)
+ nego_auth = self.new user, domain
+
+ resp = http.get path, { "Proxy-Authorization" => "Negotiate " + nego_auth.get_initial_token }
+ if resp["Proxy-Authenticate"]
+ resp = http.get path, { "Proxy-Authorization" => "Negotiate " + nego_auth.complete_authentication(resp["Proxy-Authenticate"].split(" ").last.strip) }
+ end
+
+ resp
+ end
+
+ # Creates a new instance ready for authentication as the given user in the given domain.
+ # Defaults to current user and domain as defined by ENV["USERDOMAIN"] and ENV["USERNAME"] if
+ # no arguments are supplied.
+ def initialize(user = nil, domain = nil)
+ if user.nil? && domain.nil? && ENV["USERNAME"].nil? && ENV["USERDOMAIN"].nil?
+ raise "A username or domain must be supplied since they cannot be retrieved from the environment"
+ end
+
+ @user = user || ENV["USERNAME"]
+ @domain = domain || ENV["USERDOMAIN"]
+ end
+
+ # Gets the initial Negotiate token. Returns it as a base64 encoded string suitable for use in HTTP. Can
+ # be easily decoded, however.
+ def get_initial_token
+ raise "This object is no longer usable because its resources have been freed." if @cleaned_up
+ get_credentials
+
+ outputBuffer = SecurityBuffer.new
+ @context = CtxtHandle.new
+ @contextAttributes = "\0" * 4
+
+ result = SSPIResult.new(API::InitializeSecurityContext.call(@credentials.to_p, nil, nil,
+ REQUEST_FLAGS,0, SECURITY_NETWORK_DREP, nil, 0, @context.to_p, outputBuffer.to_p, @contextAttributes, TimeStamp.new.to_p))
+
+ if result.ok? then
+ return encode_token(outputBuffer.token)
+ else
+ raise "Error: #{result.to_s}"
+ end
+ end
+
+ # Takes a token and gets the next token in the Negotiate authentication chain. Token can be Base64 encoded or not.
+ # The token can include the "Negotiate" header and it will be stripped.
+ # Does not indicate if SEC_I_CONTINUE or SEC_E_OK was returned.
+ # Token returned is Base64 encoded w/ all new lines removed.
+ def complete_authentication(token)
+ raise "This object is no longer usable because its resources have been freed." if @cleaned_up
+
+ # Nil token OK, just set it to empty string
+ token = "" if token.nil?
+
+ if token.include? "Negotiate"
+ # If the Negotiate prefix is passed in, assume we are seeing "Negotiate <token>" and get the token.
+ token = token.split(" ").last
+ end
+
+ if token.include? B64_TOKEN_PREFIX
+ # indicates base64 encoded token
+ token = token.strip.unpack("m")[0]
+ end
+
+ outputBuffer = SecurityBuffer.new
+ result = SSPIResult.new(API::InitializeSecurityContext.call(@credentials.to_p, @context.to_p, nil,
+ REQUEST_FLAGS, 0, SECURITY_NETWORK_DREP, SecurityBuffer.new(token).to_p, 0,
+ @context.to_p,
+ outputBuffer.to_p, @contextAttributes, TimeStamp.new.to_p))
+
+ if result.ok? then
+ return encode_token(outputBuffer.token)
+ else
+ raise "Error: #{result.to_s}"
+ end
+ ensure
+ # need to make sure we don't clean up if we've already cleaned up.
+ clean_up unless @cleaned_up
+ end
+
+ private
+
+ def clean_up
+ # free structures allocated
+ @cleaned_up = true
+ API::FreeCredentialsHandle.call(@credentials.to_p)
+ API::DeleteSecurityContext.call(@context.to_p)
+ @context = nil
+ @credentials = nil
+ @contextAttributes = nil
+ end
+
+ # Gets credentials based on user, domain or both. If both are nil, an error occurs
+ def get_credentials
+ @credentials = CredHandle.new
+ ts = TimeStamp.new
+ @identity = Identity.new @user, @domain
+ result = SSPIResult.new(API::AcquireCredentialsHandle.call(nil, "Negotiate", SECPKG_CRED_OUTBOUND, nil, @identity.to_p,
+ nil, nil, @credentials.to_p, ts.to_p))
+ raise "Error acquire credentials: #{result}" unless result.ok?
+ end
+
+ def encode_token(t)
+ # encode64 will add newlines every 60 characters so we need to remove those.
+ [t].pack("m").delete("\n")
+ end
+ end
+ end
+end
diff --git a/jni/ruby/ext/win32ole/Makefile b/jni/ruby/ext/win32ole/Makefile
new file mode 100644
index 0000000..e4fe34e
--- /dev/null
+++ b/jni/ruby/ext/win32ole/Makefile
@@ -0,0 +1,150 @@
+# ***DUMMY MAKEFILE***
+
+SHELL = /bin/sh
+
+# V=0 quiet, V=1 verbose. other values don't work.
+V = 0
+Q1 = $(V:1=)
+Q = $(Q1:0=@)
+ECHO1 = $(V:1=@:)
+ECHO = $(ECHO1:0=@echo)
+NULLCMD = :
+
+#### Start of system configuration section. ####
+top_srcdir = $(topdir)/.
+srcdir = $(top_srcdir)/ext/win32ole
+topdir = ../..
+hdrdir = $(top_srcdir)/include
+arch_hdrdir = $(extout)/include/$(arch)
+PATH_SEPARATOR = :
+VPATH = $(srcdir):$(arch_hdrdir)/ruby:$(hdrdir)/ruby
+RUBYLIB =
+RUBYOPT = -
+prefix = $(DESTDIR)/usr/local
+rubysitearchprefix = $(rubylibprefix)/$(sitearch)
+rubyarchprefix = $(rubylibprefix)/$(arch)
+rubylibprefix = $(libdir)/$(RUBY_BASE_NAME)
+exec_prefix = $(prefix)
+vendorarchhdrdir = $(vendorhdrdir)/$(sitearch)
+sitearchhdrdir = $(sitehdrdir)/$(sitearch)
+rubyarchhdrdir = $(rubyhdrdir)/$(arch)
+vendorhdrdir = $(rubyhdrdir)/vendor_ruby
+sitehdrdir = $(rubyhdrdir)/site_ruby
+rubyhdrdir = $(includedir)/$(RUBY_VERSION_NAME)
+vendorarchdir = $(vendorlibdir)/$(sitearch)
+vendorlibdir = $(vendordir)/$(ruby_version)
+vendordir = $(rubylibprefix)/vendor_ruby
+sitearchdir = $(sitelibdir)/$(sitearch)
+sitelibdir = $(sitedir)/$(ruby_version)
+sitedir = $(rubylibprefix)/site_ruby
+rubyarchdir = $(rubylibdir)/$(arch)
+rubylibdir = $(rubylibprefix)/$(ruby_version)
+sitearchincludedir = $(includedir)/$(sitearch)
+archincludedir = $(includedir)/$(arch)
+sitearchlibdir = $(libdir)/$(sitearch)
+archlibdir = $(libdir)/$(arch)
+ridir = $(datarootdir)/$(RI_BASE_NAME)
+mandir = $(datarootdir)/man
+localedir = $(datarootdir)/locale
+libdir = $(exec_prefix)/lib
+psdir = $(docdir)
+pdfdir = $(docdir)
+dvidir = $(docdir)
+htmldir = $(docdir)
+infodir = $(datarootdir)/info
+docdir = $(datarootdir)/doc/$(PACKAGE)
+oldincludedir = $(DESTDIR)/usr/include
+includedir = $(prefix)/include
+localstatedir = $(prefix)/var
+sharedstatedir = $(prefix)/com
+sysconfdir = $(prefix)/etc
+datadir = $(datarootdir)
+datarootdir = $(prefix)/share
+libexecdir = $(exec_prefix)/libexec
+sbindir = $(exec_prefix)/sbin
+bindir = $(exec_prefix)/bin
+archdir = $(rubyarchdir)
+
+
+CC = gcc
+CXX = g++
+LIBRUBY = $(LIBRUBY_SO)
+LIBRUBY_A = lib$(RUBY_SO_NAME)-static.a
+LIBRUBYARG_SHARED = -Wl,-R$(libdir) -L$(libdir) -l$(RUBY_SO_NAME)
+LIBRUBYARG_STATIC = -Wl,-R$(libdir) -L$(libdir) -l$(RUBY_SO_NAME)-static
+empty =
+OUTFLAG = -o $(empty)
+COUTFLAG = -o $(empty)
+
+RUBY_EXTCONF_H =
+cflags = $(optflags) $(debugflags) $(warnflags)
+optflags = -O3 -fno-fast-math
+debugflags = -ggdb3
+warnflags = -Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wunused-variable -Wpointer-arith -Wwrite-strings -Wdeclaration-after-statement -Wimplicit-function-declaration -Wdeprecated-declarations -Wno-packed-bitfield-compat
+CCDLFLAGS = -fPIC
+CFLAGS = $(CCDLFLAGS) $(cflags) -fPIC $(ARCH_FLAG)
+INCFLAGS = -I. -I$(arch_hdrdir) -I$(hdrdir) -I$(srcdir)
+DEFS =
+CPPFLAGS = $(DEFS) $(cppflags)
+CXXFLAGS = $(CCDLFLAGS) $(cxxflags) $(ARCH_FLAG)
+ldflags = -L. -fstack-protector -rdynamic -Wl,-export-dynamic
+dldflags =
+ARCH_FLAG =
+DLDFLAGS = $(ldflags) $(dldflags) $(ARCH_FLAG)
+LDSHARED = $(CC) -shared
+LDSHAREDXX = $(CXX) -shared
+AR = ar
+EXEEXT =
+
+RUBY_INSTALL_NAME = $(RUBY_BASE_NAME)
+RUBY_SO_NAME = ruby
+RUBYW_INSTALL_NAME =
+RUBY_VERSION_NAME = $(RUBY_BASE_NAME)-$(ruby_version)
+RUBYW_BASE_NAME = rubyw
+RUBY_BASE_NAME = ruby
+
+arch = x86_64-linux
+sitearch = $(arch)
+ruby_version = 2.2.0
+ruby = $(topdir)/miniruby -I'$(topdir)' -I'$(top_srcdir)/lib' -I'$(extout)/$(arch)' -I'$(extout)/common'
+RUBY = $(ruby)
+ruby_headers = $(hdrdir)/ruby.h $(hdrdir)/ruby/ruby.h $(hdrdir)/ruby/defines.h $(hdrdir)/ruby/missing.h $(hdrdir)/ruby/intern.h $(hdrdir)/ruby/st.h $(hdrdir)/ruby/subst.h $(arch_hdrdir)/ruby/config.h
+
+RM = rm -f
+RM_RF = $(RUBY) -run -e rm -- -rf
+RMDIRS = rmdir --ignore-fail-on-non-empty -p
+MAKEDIRS = /bin/mkdir -p
+INSTALL = /usr/bin/install -c
+INSTALL_PROG = $(INSTALL) -m 0755
+INSTALL_DATA = $(INSTALL) -m 644
+COPY = cp
+TOUCH = exit >
+
+#### End of system configuration section. ####
+
+preload =
+CLEANFILES = mkmf.log
+DISTCLEANFILES =
+
+all install static install-so install-rb: Makefile
+.PHONY: all install static install-so install-rb
+.PHONY: clean clean-so clean-static clean-rb
+
+
+clean-static::
+clean-rb-default::
+clean-rb::
+clean-so::
+clean: clean-so clean-static clean-rb-default clean-rb
+ -$(Q)$(RM) $(CLEANLIBS) $(CLEANOBJS) $(CLEANFILES) .*.time
+
+distclean-rb-default::
+distclean-rb::
+distclean-so::
+distclean-static::
+distclean: clean distclean-so distclean-static distclean-rb-default distclean-rb
+ -$(Q)$(RM) Makefile $(RUBY_EXTCONF_H) conftest.* mkmf.log
+ -$(Q)$(RM) core ruby$(EXEEXT) *~ $(DISTCLEANFILES)
+ -$(Q)$(RMDIRS) $(DISTCLEANDIRS) 2> /dev/null || true
+
+realclean: distclean
diff --git a/jni/ruby/ext/win32ole/depend b/jni/ruby/ext/win32ole/depend
new file mode 100644
index 0000000..c8445ad
--- /dev/null
+++ b/jni/ruby/ext/win32ole/depend
@@ -0,0 +1,12 @@
+WIN32OLE_HEADERS = $(HDRS) $(ruby_headers)
+win32ole.o : win32ole.c $(WIN32OLE_HEADERS)
+win32ole_variant_m.o : win32ole_variant_m.c $(WIN32OLE_HEADERS)
+win32ole_typelib.o : win32ole_typelib.c $(WIN32OLE_HEADERS)
+win32ole_type.o : win32ole_type.c $(WIN32OLE_HEADERS)
+win32ole_variable.o : win32ole_variable.c $(WIN32OLE_HEADERS)
+win32ole_method.o : win32ole_method.c $(WIN32OLE_HEADERS)
+win32ole_param.o : win32ole_param.c $(WIN32OLE_HEADERS)
+win32ole_variant.o : win32ole_variant.c $(WIN32OLE_HEADERS)
+win32ole_event.o : win32ole_event.c $(WIN32OLE_HEADERS)
+win32ole_record.o : win32ole_record.c $(WIN32OLE_HEADERS)
+win32ole_error.o : win32ole_error.c $(WIN32OLE_HEADERS)
diff --git a/jni/ruby/ext/win32ole/extconf.rb b/jni/ruby/ext/win32ole/extconf.rb
new file mode 100644
index 0000000..59da40b
--- /dev/null
+++ b/jni/ruby/ext/win32ole/extconf.rb
@@ -0,0 +1,44 @@
+#----------------------------------
+# extconf.rb
+# $Revision: 38867 $
+#----------------------------------
+require 'mkmf'
+
+case RUBY_PLATFORM
+when /cygwin/
+ inc = nil
+ lib = '/usr/lib/w32api'
+end
+
+dir_config("win32", inc, lib)
+
+def create_win32ole_makefile
+ if have_library("ole32") and
+ have_library("oleaut32") and
+ have_library("uuid", "&CLSID_CMultiLanguage", "mlang.h") and
+ have_library("user32") and
+ have_library("kernel32") and
+ have_library("advapi32") and
+ have_header("windows.h")
+ unless have_type("IMultiLanguage2", "mlang.h")
+ have_type("IMultiLanguage", "mlang.h")
+ end
+ spec = nil
+ checking_for('thread_specific', '%s') do
+ spec = %w[__declspec(thread) __thread].find {|th|
+ try_compile("#{th} int foo;", "", :werror => true)
+ }
+ spec or 'no'
+ end
+ $defs << "-DRB_THREAD_SPECIFIC=#{spec}" if spec
+ create_makefile("win32ole")
+ end
+end
+
+
+case RUBY_PLATFORM
+when /mswin/
+ $CFLAGS.sub!(/((?:\A|\s)[-\/])W\d(?=\z|\s)/, '\1W3') or
+ $CFLAGS += ' -W3'
+end
+create_win32ole_makefile
diff --git a/jni/ruby/ext/win32ole/lib/win32ole/property.rb b/jni/ruby/ext/win32ole/lib/win32ole/property.rb
new file mode 100644
index 0000000..a68bad9
--- /dev/null
+++ b/jni/ruby/ext/win32ole/lib/win32ole/property.rb
@@ -0,0 +1,16 @@
+# OLEProperty
+# helper class of Property with arguments.
+class OLEProperty
+ def initialize(obj, dispid, gettypes, settypes)
+ @obj = obj
+ @dispid = dispid
+ @gettypes = gettypes
+ @settypes = settypes
+ end
+ def [](*args)
+ @obj._getproperty(@dispid, args, @gettypes)
+ end
+ def []=(*args)
+ @obj._setproperty(@dispid, args, @settypes)
+ end
+end
diff --git a/jni/ruby/ext/win32ole/sample/excel1.rb b/jni/ruby/ext/win32ole/sample/excel1.rb
new file mode 100644
index 0000000..7136c93
--- /dev/null
+++ b/jni/ruby/ext/win32ole/sample/excel1.rb
@@ -0,0 +1,36 @@
+require 'win32ole'
+
+application = WIN32OLE.new('Excel.Application')
+
+application.visible = TRUE
+workbook = application.Workbooks.Add();
+worksheet = workbook.Worksheets(1);
+
+=begin
+worksheet.Range("A1:D1").value = ["North","South","East","West"];
+worksheet.Range("A2:B2").value = [5.2, 10];
+
+worksheet.Range("C2").value = 8;
+worksheet.Range("D2").value = 20;
+=end
+
+worksheet.Range("A1:B2").value = [["North","South"],
+ [5.2, 10]];
+
+vals = WIN32OLE_VARIANT.new([["East","West"],
+ [8, 20]],
+ WIN32OLE::VARIANT::VT_ARRAY)
+worksheet.Range("C1:D2").value = vals
+
+range = worksheet.Range("A1:D2");
+range.Select
+chart = workbook.Charts.Add;
+
+workbook.saved = TRUE;
+
+print "Now quit Excel... Please enter."
+gets
+
+application.ActiveWorkbook.Close(0);
+application.Quit();
+
diff --git a/jni/ruby/ext/win32ole/sample/excel2.rb b/jni/ruby/ext/win32ole/sample/excel2.rb
new file mode 100644
index 0000000..6328826
--- /dev/null
+++ b/jni/ruby/ext/win32ole/sample/excel2.rb
@@ -0,0 +1,30 @@
+require 'win32ole'
+
+# -4100 is the value for the Excel constant xl3DColumn.
+ChartTypeVal = -4100;
+
+# Creates OLE object to Excel
+excel = WIN32OLE.new("excel.application")
+
+# Create and rotate the chart
+excel.visible = TRUE;
+excel.Workbooks.Add();
+excel.Range("a1").value = 3;
+excel.Range("a2").value = 2;
+excel.Range("a3").value = 1;
+excel.Range("a1:a3").Select();
+excelchart = excel.Charts.Add();
+excelchart.type = ChartTypeVal;
+
+i = 0
+i.step(180, 10) do |rot|
+ excelchart.rotation=rot;
+ sleep 0.1
+end
+# Done, bye
+
+print "Now quit Excel... Please enter."
+gets
+
+excel.ActiveWorkbook.Close(0);
+excel.Quit();
diff --git a/jni/ruby/ext/win32ole/sample/excel3.rb b/jni/ruby/ext/win32ole/sample/excel3.rb
new file mode 100644
index 0000000..1ace478
--- /dev/null
+++ b/jni/ruby/ext/win32ole/sample/excel3.rb
@@ -0,0 +1,20 @@
+require 'win32ole'
+
+#application = WIN32OLE.new('Excel.Application.5')
+application = WIN32OLE.new('Excel.Application')
+
+application.visible = TRUE
+workbook = application.Workbooks.Add();
+sheet = workbook.Worksheets(1);
+sheetS = workbook.Worksheets
+puts "The number of sheets is #{sheetS.count}"
+puts "Now add 2 sheets after of `#{sheet.name}`"
+sheetS.add({'count'=>2, 'after'=>sheet})
+puts "The number of sheets is #{sheetS.count}"
+
+print "Now quit Excel... Please enter."
+gets
+
+application.ActiveWorkbook.Close(0);
+application.Quit();
+
diff --git a/jni/ruby/ext/win32ole/sample/ie.rb b/jni/ruby/ext/win32ole/sample/ie.rb
new file mode 100644
index 0000000..11dc861
--- /dev/null
+++ b/jni/ruby/ext/win32ole/sample/ie.rb
@@ -0,0 +1,11 @@
+require 'win32ole'
+url = 'http://www.ruby-lang.org/'
+ie = WIN32OLE.new('InternetExplorer.Application')
+ie.visible = TRUE
+ie.gohome
+print "Now navigate Ruby home page... Please enter."
+gets
+ie.navigate(url)
+print "Now quit Internet Explorer... Please enter."
+gets
+ie.Quit()
diff --git a/jni/ruby/ext/win32ole/sample/ieconst.rb b/jni/ruby/ext/win32ole/sample/ieconst.rb
new file mode 100644
index 0000000..2c6a7a3
--- /dev/null
+++ b/jni/ruby/ext/win32ole/sample/ieconst.rb
@@ -0,0 +1,32 @@
+require 'win32ole'
+
+ie = WIN32OLE.new('InternetExplorer.Application')
+=begin
+WIN32OLE.const_load(ie)
+WIN32OLE.constants.sort.each do |c|
+ puts "#{c} = #{WIN32OLE.const_get(c)}"
+end
+=end
+
+module IE_CONST
+end
+
+WIN32OLE.const_load(ie, IE_CONST)
+IE_CONST.constants.sort.each do |c|
+ puts "#{c} = #{IE_CONST.const_get(c)}"
+end
+
+#------------------------------------------------------------
+# Remark!!! CONSTANTS has not tested enoughly!!!
+# CONSTANTS is alpha release.
+# If there are constants which first letter is not [a-zA-Z],
+# like a '_Foo', then maybe you can access the value by
+# using CONSTANTS['_Foo']
+#------------------------------------------------------------
+IE_CONST::CONSTANTS.each do |k, v|
+ puts "#{k} = #{v}"
+end
+
+puts WIN32OLE::VERSION
+ie.quit
+
diff --git a/jni/ruby/ext/win32ole/sample/ienavi.rb b/jni/ruby/ext/win32ole/sample/ienavi.rb
new file mode 100644
index 0000000..8b279dd
--- /dev/null
+++ b/jni/ruby/ext/win32ole/sample/ienavi.rb
@@ -0,0 +1,40 @@
+require 'win32ole'
+
+$urls = []
+
+def navigate(url)
+ $urls << url
+end
+
+def stop_msg_loop
+ puts "Now Stop IE..."
+ $LOOP = FALSE;
+end
+
+def default_handler(event, *args)
+ case event
+ when "BeforeNavigate"
+ puts "Now Navigate #{args[0]}..."
+ end
+end
+
+ie = WIN32OLE.new('InternetExplorer.Application')
+ie.visible = TRUE
+ie.gohome
+
+ev = WIN32OLE_EVENT.new(ie, 'DWebBrowserEvents')
+
+ev.on_event {|*args| default_handler(*args)}
+ev.on_event("NavigateComplete") {|url| navigate(url)}
+ev.on_event("Quit") {|*args| stop_msg_loop}
+
+$LOOP = TRUE
+while ($LOOP)
+ WIN32OLE_EVENT.message_loop
+end
+
+puts "You Navigated the URLs ..."
+$urls.each_with_index do |url, i|
+ puts "(#{i+1}) #{url}"
+end
+
diff --git a/jni/ruby/ext/win32ole/sample/ienavi2.rb b/jni/ruby/ext/win32ole/sample/ienavi2.rb
new file mode 100644
index 0000000..67977e2
--- /dev/null
+++ b/jni/ruby/ext/win32ole/sample/ienavi2.rb
@@ -0,0 +1,40 @@
+require 'win32ole'
+
+class IEHandler
+ attr_reader :loop
+ def initialize
+ @urls = []
+ @loop = true
+ end
+ def method_missing(event, *args)
+ case event
+ when "BeforeNavigate2"
+ puts "Now Navigate #{args[1]}..."
+ end
+ end
+ def onNavigateComplete2(pdisp, url)
+ @urls << url
+ end
+ def onOnQuit
+ puts "Now Stop IE..."
+ @loop = false
+ end
+ def put_urls
+ puts "You Navigated the URLs ..."
+ @urls.each_with_index do |url, i|
+ puts "(#{i+1}) #{url}"
+ end
+ end
+end
+
+ie = WIN32OLE.new('InternetExplorer.Application')
+ie.visible = true
+ie.gohome
+
+ev = WIN32OLE_EVENT.new(ie)
+ev.handler = IEHandler.new
+
+while (ev.handler.loop)
+ WIN32OLE_EVENT.message_loop
+end
+ev.handler.put_urls
diff --git a/jni/ruby/ext/win32ole/sample/oledirs.rb b/jni/ruby/ext/win32ole/sample/oledirs.rb
new file mode 100644
index 0000000..dbacc21
--- /dev/null
+++ b/jni/ruby/ext/win32ole/sample/oledirs.rb
@@ -0,0 +1,23 @@
+#
+# You need WSH(Windows Scripting Host) to run this script.
+#
+
+require "win32ole"
+
+def listup(items)
+# items.each do |i|
+ for i in items
+ puts i.name
+ end
+end
+
+fs = WIN32OLE.new("Scripting.FileSystemObject")
+
+folder = fs.GetFolder(".")
+
+puts "--- folder of #{folder.path} ---"
+listup(folder.SubFolders)
+
+puts "--- files of #{folder.path} ---"
+listup(folder.Files)
+
diff --git a/jni/ruby/ext/win32ole/sample/olegen.rb b/jni/ruby/ext/win32ole/sample/olegen.rb
new file mode 100644
index 0000000..17653e7
--- /dev/null
+++ b/jni/ruby/ext/win32ole/sample/olegen.rb
@@ -0,0 +1,347 @@
+#-----------------------------
+# olegen.rb
+# $Revision: 44134 $
+#-----------------------------
+
+require 'win32ole'
+
+class WIN32COMGen
+ def initialize(typelib)
+ @typelib = typelib
+ @receiver = ""
+ end
+ attr_reader :typelib
+
+ def ole_classes(typelib)
+ begin
+ @ole = WIN32OLE.new(typelib)
+ [@ole.ole_obj_help]
+ rescue
+ WIN32OLE_TYPE.ole_classes(typelib)
+ end
+ end
+
+ def generate_args(method)
+ args = []
+ if method.size_opt_params >= 0
+ size_required_params = method.size_params - method.size_opt_params
+ else
+ size_required_params = method.size_params - 1
+ end
+ size_required_params.times do |i|
+ if method.params[i] && method.params[i].optional?
+ args.push "arg#{i}=nil"
+ else
+ args.push "arg#{i}"
+ end
+ end
+ if method.size_opt_params >= 0
+ method.size_opt_params.times do |i|
+ args.push "arg#{i + size_required_params}=nil"
+ end
+ else
+ args.push "*arg"
+ end
+ args.join(", ")
+ end
+
+ def generate_argtype(typedetails)
+ ts = ''
+ typedetails.each do |t|
+ case t
+ when 'CARRAY', 'VOID', 'UINT', 'RESULT', 'DECIMAL', 'I8', 'UI8'
+# raise "Sorry type\"" + t + "\" not supported"
+ ts << "\"??? NOT SUPPORTED TYPE:`#{t}'\""
+ when 'USERDEFINED', 'Unknown Type 9'
+ ts << 'VT_DISPATCH'
+ break;
+ when 'SAFEARRAY'
+ ts << 'VT_ARRAY|'
+ when 'PTR'
+ ts << 'VT_BYREF|'
+ when 'INT'
+ ts << 'VT_I4'
+ else
+ if String === t
+ ts << 'VT_' + t
+ end
+ end
+ end
+ if ts.empty?
+ ts = 'VT_VARIANT'
+ elsif ts[-1] == ?|
+ ts += 'VT_VARIANT'
+ end
+ ts
+ end
+
+ def generate_argtypes(method, proptypes)
+ types = method.params.collect{|param|
+ generate_argtype(param.ole_type_detail)
+ }.join(", ")
+ if proptypes
+ types += ", " if types.size > 0
+ types += generate_argtype(proptypes)
+ end
+ types
+ end
+
+ def generate_method_body(method, disptype, types=nil)
+ " ret = #{@receiver}#{disptype}(#{method.dispid}, [" +
+ generate_args(method).gsub("=nil", "") +
+ "], [" +
+ generate_argtypes(method, types) +
+ "])\n" +
+ " @lastargs = WIN32OLE::ARGV\n" +
+ " ret"
+ end
+
+ def generate_method_help(method, type = nil)
+ str = " # "
+ if type
+ str += type
+ else
+ str += method.return_type
+ end
+ str += " #{method.name}"
+ if method.event?
+ str += " EVENT"
+ str += " in #{method.event_interface}"
+ end
+ if method.helpstring && method.helpstring != ""
+ str += "\n # "
+ str += method.helpstring
+ end
+ args_help = generate_method_args_help(method)
+ if args_help
+ str += "\n"
+ str += args_help
+ end
+ str
+ end
+
+ def generate_method_args_help(method)
+ args = []
+ method.params.each_with_index {|param, i|
+ h = " # #{param.ole_type} arg#{i} --- #{param.name}"
+ inout = []
+ inout.push "IN" if param.input?
+ inout.push "OUT" if param.output?
+ h += " [#{inout.join('/')}]"
+ h += " ( = #{param.default})" if param.default
+ args.push h
+ }
+ if args.size > 0
+ args.join("\n")
+ else
+ nil
+ end
+ end
+
+ def generate_method(method, disptype, io = STDOUT, types = nil)
+ io.puts "\n"
+ io.puts generate_method_help(method)
+ if method.invoke_kind == 'PROPERTYPUT'
+ io.print " def #{method.name}=("
+ else
+ io.print " def #{method.name}("
+ end
+ io.print generate_args(method)
+ io.puts ")"
+ io.puts generate_method_body(method, disptype, types)
+ io.puts " end"
+ end
+
+ def generate_propputref_methods(klass, io = STDOUT)
+ klass.ole_methods.select {|method|
+ method.invoke_kind == 'PROPERTYPUTREF' && method.visible?
+ }.each do |method|
+ generate_method(method, io)
+ end
+ end
+
+ def generate_properties_with_args(klass, io = STDOUT)
+ klass.ole_methods.select {|method|
+ method.invoke_kind == 'PROPERTYGET' &&
+ method.visible? &&
+ method.size_params > 0
+ }.each do |method|
+ types = method.return_type_detail
+ io.puts "\n"
+ io.puts generate_method_help(method, types[0])
+ io.puts " def #{method.name}"
+ if klass.ole_type == "Class"
+ io.print " OLEProperty.new(@dispatch, #{method.dispid}, ["
+ else
+ io.print " OLEProperty.new(self, #{method.dispid}, ["
+ end
+ io.print generate_argtypes(method, nil)
+ io.print "], ["
+ io.print generate_argtypes(method, types)
+ io.puts "])"
+ io.puts " end"
+ end
+ end
+
+ def generate_propput_methods(klass, io = STDOUT)
+ klass.ole_methods.select {|method|
+ method.invoke_kind == 'PROPERTYPUT' && method.visible? &&
+ method.size_params == 1
+ }.each do |method|
+ ms = klass.ole_methods.select {|m|
+ m.invoke_kind == 'PROPERTYGET' &&
+ m.dispid == method.dispid
+ }
+ types = []
+ if ms.size == 1
+ types = ms[0].return_type_detail
+ end
+ generate_method(method, '_setproperty', io, types)
+ end
+ end
+
+ def generate_propget_methods(klass, io = STDOUT)
+ klass.ole_methods.select {|method|
+ method.invoke_kind == 'PROPERTYGET' && method.visible? &&
+ method.size_params == 0
+ }.each do |method|
+ generate_method(method, '_getproperty', io)
+ end
+ end
+
+ def generate_func_methods(klass, io = STDOUT)
+ klass.ole_methods.select {|method|
+ method.invoke_kind == "FUNC" && method.visible?
+ }.each do |method|
+ generate_method(method, '_invoke', io)
+ end
+ end
+
+ def generate_methods(klass, io = STDOUT)
+ generate_propget_methods(klass, io)
+ generate_propput_methods(klass, io)
+ generate_properties_with_args(klass, io)
+ generate_func_methods(klass, io)
+# generate_propputref_methods(klass, io)
+ end
+
+ def generate_constants(klass, io = STDOUT)
+ klass.variables.select {|v|
+ v.visible? && v.variable_kind == 'CONSTANT'
+ }.each do |v|
+ io.print " "
+ io.print v.name.sub(/^./){$&.upcase}
+ io.print " = "
+ io.puts v.value
+ end
+ end
+
+ def class_name(klass)
+ klass_name = klass.name
+ if klass.ole_type == "Class" &&
+ klass.guid &&
+ klass.progid
+ klass_name = klass.progid.gsub(/\./, '_')
+ end
+ if /^[A-Z]/ !~ klass_name || Module.constants.include?(klass_name)
+ klass_name = 'OLE' + klass_name
+ end
+ klass_name
+ end
+
+ def define_initialize(klass)
+ <<STR
+
+ def initialize(obj = nil)
+ @clsid = "#{klass.guid}"
+ @progid = "#{klass.progid}"
+ if obj.nil?
+ @dispatch = WIN32OLE.new @progid
+ else
+ @dispatch = obj
+ end
+ end
+STR
+ end
+
+ def define_include
+ " include WIN32OLE::VARIANT"
+ end
+
+ def define_instance_variables
+ " attr_reader :lastargs"
+ end
+
+ def define_method_missing
+ <<STR
+
+ def method_missing(cmd, *arg)
+ @dispatch.method_missing(cmd, *arg)
+ end
+STR
+ end
+
+ def define_class(klass, io = STDOUT)
+ io.puts "class #{class_name(klass)} # #{klass.name}"
+ io.puts define_include
+ io.puts define_instance_variables
+ io.puts " attr_reader :dispatch"
+ io.puts " attr_reader :clsid"
+ io.puts " attr_reader :progid"
+ io.puts define_initialize(klass)
+ io.puts define_method_missing
+ end
+
+ def define_module(klass, io = STDOUT)
+ io.puts "module #{class_name(klass)}"
+ io.puts define_include
+ io.puts define_instance_variables
+ end
+
+ def generate_class(klass, io = STDOUT)
+ io.puts "\n# #{klass.helpstring}"
+ if klass.ole_type == "Class" &&
+ klass.guid &&
+ klass.progid
+ @receiver = "@dispatch."
+ define_class(klass, io)
+ else
+ @receiver = ""
+ define_module(klass, io)
+ end
+ generate_constants(klass, io)
+ generate_methods(klass, io)
+ io.puts "end"
+ end
+
+ def generate(io = STDOUT)
+ io.puts "require 'win32ole'"
+ io.puts "require 'win32ole/property'"
+
+ ole_classes(typelib).select{|klass|
+ klass.visible? &&
+ (klass.ole_type == "Class" ||
+ klass.ole_type == "Interface" ||
+ klass.ole_type == "Dispatch" ||
+ klass.ole_type == "Enum")
+ }.each do |klass|
+ generate_class(klass, io)
+ end
+ begin
+ @ole.quit if @ole
+ rescue
+ end
+ end
+end
+
+require 'win32ole'
+if __FILE__ == $0
+ if ARGV.size == 0
+ $stderr.puts "usage: #{$0} Type Library [...]"
+ exit 1
+ end
+ ARGV.each do |typelib|
+ comgen = WIN32COMGen.new(typelib)
+ comgen.generate
+ end
+end
diff --git a/jni/ruby/ext/win32ole/sample/xml.rb b/jni/ruby/ext/win32ole/sample/xml.rb
new file mode 100644
index 0000000..4b1a54d
--- /dev/null
+++ b/jni/ruby/ext/win32ole/sample/xml.rb
@@ -0,0 +1,7306 @@
+#
+# This file created by olegen.rb as following.
+# ruby olegen.rb 'Microsoft XML, version 2.0' > xml.rb
+#
+require 'win32ole'
+require 'win32ole/property'
+
+#
+module IXMLDOMImplementation
+ include WIN32OLE::VARIANT
+ attr_reader :lastargs
+
+ # BOOL hasFeature
+ # BSTR arg0 --- feature [IN]
+ # BSTR arg1 --- version [IN]
+ def hasFeature(arg0, arg1)
+ ret = _invoke(145, [arg0, arg1], [VT_BSTR, VT_BSTR])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+end
+
+# Core DOM node interface
+module IXMLDOMNode
+ include WIN32OLE::VARIANT
+ attr_reader :lastargs
+
+ # BSTR nodeName
+ # name of the node
+ def nodeName()
+ ret = _getproperty(2, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VARIANT nodeValue
+ # value stored in the node
+ def nodeValue()
+ ret = _getproperty(3, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # DOMNodeType nodeType
+ # the node's type
+ def nodeType()
+ ret = _getproperty(4, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode parentNode
+ # parent of the node
+ def parentNode()
+ ret = _getproperty(6, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNodeList childNodes
+ # the collection of the node's children
+ def childNodes()
+ ret = _getproperty(7, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode firstChild
+ # first child of the node
+ def firstChild()
+ ret = _getproperty(8, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode lastChild
+ # first child of the node
+ def lastChild()
+ ret = _getproperty(9, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode previousSibling
+ # left sibling of the node
+ def previousSibling()
+ ret = _getproperty(10, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode nextSibling
+ # right sibling of the node
+ def nextSibling()
+ ret = _getproperty(11, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNamedNodeMap attributes
+ # the collection of the node's attributes
+ def attributes()
+ ret = _getproperty(12, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMDocument ownerDocument
+ # document that contains the node
+ def ownerDocument()
+ ret = _getproperty(18, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BSTR nodeTypeString
+ # the type of node in string form
+ def nodeTypeString()
+ ret = _getproperty(21, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BSTR text
+ # text content of the node and subtree
+ def text()
+ ret = _getproperty(24, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BOOL specified
+ # indicates whether node is a default value
+ def specified()
+ ret = _getproperty(22, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode definition
+ # pointer to the definition of the node in the DTD or schema
+ def definition()
+ ret = _getproperty(23, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VARIANT nodeTypedValue
+ # get the strongly typed value of the node
+ def nodeTypedValue()
+ ret = _getproperty(25, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VARIANT dataType
+ # the data type of the node
+ def dataType()
+ ret = _getproperty(26, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BSTR xml
+ # return the XML source for the node and each of its descendants
+ def xml()
+ ret = _getproperty(27, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BOOL parsed
+ # has sub-tree been completely parsed
+ def parsed()
+ ret = _getproperty(31, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BSTR namespaceURI
+ # the URI for the namespace applying to the node
+ def namespaceURI()
+ ret = _getproperty(32, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BSTR prefix
+ # the prefix for the namespace applying to the node
+ def prefix()
+ ret = _getproperty(33, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BSTR baseName
+ # the base name of the node (nodename with the prefix stripped off)
+ def baseName()
+ ret = _getproperty(34, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VOID nodeValue
+ # value stored in the node
+ def nodeValue=(arg0)
+ ret = _setproperty(3, [arg0], [VT_VARIANT])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VOID text
+ # text content of the node and subtree
+ def text=(arg0)
+ ret = _setproperty(24, [arg0], [VT_BSTR])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VOID nodeTypedValue
+ # get the strongly typed value of the node
+ def nodeTypedValue=(arg0)
+ ret = _setproperty(25, [arg0], [VT_VARIANT])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VOID dataType
+ # the data type of the node
+ def dataType=(arg0)
+ ret = _setproperty(26, [arg0], [VT_VARIANT])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode insertBefore
+ # insert a child node
+ # IXMLDOMNode arg0 --- newChild [IN]
+ # VARIANT arg1 --- refChild [IN]
+ def insertBefore(arg0, arg1)
+ ret = _invoke(13, [arg0, arg1], [VT_BYREF|VT_DISPATCH, VT_VARIANT])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode replaceChild
+ # replace a child node
+ # IXMLDOMNode arg0 --- newChild [IN]
+ # IXMLDOMNode arg1 --- oldChild [IN]
+ def replaceChild(arg0, arg1)
+ ret = _invoke(14, [arg0, arg1], [VT_BYREF|VT_DISPATCH, VT_BYREF|VT_DISPATCH])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode removeChild
+ # remove a child node
+ # IXMLDOMNode arg0 --- childNode [IN]
+ def removeChild(arg0)
+ ret = _invoke(15, [arg0], [VT_BYREF|VT_DISPATCH])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode appendChild
+ # append a child node
+ # IXMLDOMNode arg0 --- newChild [IN]
+ def appendChild(arg0)
+ ret = _invoke(16, [arg0], [VT_BYREF|VT_DISPATCH])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BOOL hasChildNodes
+ def hasChildNodes()
+ ret = _invoke(17, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode cloneNode
+ # BOOL arg0 --- deep [IN]
+ def cloneNode(arg0)
+ ret = _invoke(19, [arg0], [VT_BOOL])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BSTR transformNode
+ # apply the stylesheet to the subtree
+ # IXMLDOMNode arg0 --- stylesheet [IN]
+ def transformNode(arg0)
+ ret = _invoke(28, [arg0], [VT_BYREF|VT_DISPATCH])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNodeList selectNodes
+ # execute query on the subtree
+ # BSTR arg0 --- queryString [IN]
+ def selectNodes(arg0)
+ ret = _invoke(29, [arg0], [VT_BSTR])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode selectSingleNode
+ # execute query on the subtree
+ # BSTR arg0 --- queryString [IN]
+ def selectSingleNode(arg0)
+ ret = _invoke(30, [arg0], [VT_BSTR])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VOID transformNodeToObject
+ # apply the stylesheet to the subtree, returning the result through a document or a stream
+ # IXMLDOMNode arg0 --- stylesheet [IN]
+ # VARIANT arg1 --- outputObject [IN]
+ def transformNodeToObject(arg0, arg1)
+ ret = _invoke(35, [arg0, arg1], [VT_BYREF|VT_DISPATCH, VT_VARIANT])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+end
+
+# Constants that define a node's type
+module OLEtagDOMNodeType
+ include WIN32OLE::VARIANT
+ attr_reader :lastargs
+ NODE_INVALID = 0
+ NODE_ELEMENT = 1
+ NODE_ATTRIBUTE = 2
+ NODE_TEXT = 3
+ NODE_CDATA_SECTION = 4
+ NODE_ENTITY_REFERENCE = 5
+ NODE_ENTITY = 6
+ NODE_PROCESSING_INSTRUCTION = 7
+ NODE_COMMENT = 8
+ NODE_DOCUMENT = 9
+ NODE_DOCUMENT_TYPE = 10
+ NODE_DOCUMENT_FRAGMENT = 11
+ NODE_NOTATION = 12
+end
+
+#
+module IXMLDOMNodeList
+ include WIN32OLE::VARIANT
+ attr_reader :lastargs
+
+ # I4 length
+ # number of nodes in the collection
+ def length()
+ ret = _getproperty(74, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # PTR item
+ # collection of nodes
+ # I4 arg0 --- index [IN]
+ def item
+ OLEProperty.new(self, 0, [VT_I4], [VT_I4, VT_BYREF|VT_DISPATCH])
+ end
+
+ # IXMLDOMNode nextNode
+ # get next node from iterator
+ def nextNode()
+ ret = _invoke(76, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VOID reset
+ # reset the position of iterator
+ def reset()
+ ret = _invoke(77, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+end
+
+#
+module IXMLDOMNamedNodeMap
+ include WIN32OLE::VARIANT
+ attr_reader :lastargs
+
+ # I4 length
+ # number of nodes in the collection
+ def length()
+ ret = _getproperty(74, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # PTR item
+ # collection of nodes
+ # I4 arg0 --- index [IN]
+ def item
+ OLEProperty.new(self, 0, [VT_I4], [VT_I4, VT_BYREF|VT_DISPATCH])
+ end
+
+ # IXMLDOMNode getNamedItem
+ # lookup item by name
+ # BSTR arg0 --- name [IN]
+ def getNamedItem(arg0)
+ ret = _invoke(83, [arg0], [VT_BSTR])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode setNamedItem
+ # set item by name
+ # IXMLDOMNode arg0 --- newItem [IN]
+ def setNamedItem(arg0)
+ ret = _invoke(84, [arg0], [VT_BYREF|VT_DISPATCH])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode removeNamedItem
+ # remove item by name
+ # BSTR arg0 --- name [IN]
+ def removeNamedItem(arg0)
+ ret = _invoke(85, [arg0], [VT_BSTR])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode getQualifiedItem
+ # lookup the item by name and namespace
+ # BSTR arg0 --- baseName [IN]
+ # BSTR arg1 --- namespaceURI [IN]
+ def getQualifiedItem(arg0, arg1)
+ ret = _invoke(87, [arg0, arg1], [VT_BSTR, VT_BSTR])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode removeQualifiedItem
+ # remove the item by name and namespace
+ # BSTR arg0 --- baseName [IN]
+ # BSTR arg1 --- namespaceURI [IN]
+ def removeQualifiedItem(arg0, arg1)
+ ret = _invoke(88, [arg0, arg1], [VT_BSTR, VT_BSTR])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode nextNode
+ # get next node from iterator
+ def nextNode()
+ ret = _invoke(89, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VOID reset
+ # reset the position of iterator
+ def reset()
+ ret = _invoke(90, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+end
+
+#
+module IXMLDOMDocument
+ include WIN32OLE::VARIANT
+ attr_reader :lastargs
+
+ # BSTR nodeName
+ # name of the node
+ def nodeName()
+ ret = _getproperty(2, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VARIANT nodeValue
+ # value stored in the node
+ def nodeValue()
+ ret = _getproperty(3, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # DOMNodeType nodeType
+ # the node's type
+ def nodeType()
+ ret = _getproperty(4, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode parentNode
+ # parent of the node
+ def parentNode()
+ ret = _getproperty(6, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNodeList childNodes
+ # the collection of the node's children
+ def childNodes()
+ ret = _getproperty(7, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode firstChild
+ # first child of the node
+ def firstChild()
+ ret = _getproperty(8, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode lastChild
+ # first child of the node
+ def lastChild()
+ ret = _getproperty(9, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode previousSibling
+ # left sibling of the node
+ def previousSibling()
+ ret = _getproperty(10, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode nextSibling
+ # right sibling of the node
+ def nextSibling()
+ ret = _getproperty(11, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNamedNodeMap attributes
+ # the collection of the node's attributes
+ def attributes()
+ ret = _getproperty(12, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMDocument ownerDocument
+ # document that contains the node
+ def ownerDocument()
+ ret = _getproperty(18, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BSTR nodeTypeString
+ # the type of node in string form
+ def nodeTypeString()
+ ret = _getproperty(21, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BSTR text
+ # text content of the node and subtree
+ def text()
+ ret = _getproperty(24, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BOOL specified
+ # indicates whether node is a default value
+ def specified()
+ ret = _getproperty(22, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode definition
+ # pointer to the definition of the node in the DTD or schema
+ def definition()
+ ret = _getproperty(23, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VARIANT nodeTypedValue
+ # get the strongly typed value of the node
+ def nodeTypedValue()
+ ret = _getproperty(25, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VARIANT dataType
+ # the data type of the node
+ def dataType()
+ ret = _getproperty(26, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BSTR xml
+ # return the XML source for the node and each of its descendants
+ def xml()
+ ret = _getproperty(27, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BOOL parsed
+ # has sub-tree been completely parsed
+ def parsed()
+ ret = _getproperty(31, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BSTR namespaceURI
+ # the URI for the namespace applying to the node
+ def namespaceURI()
+ ret = _getproperty(32, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BSTR prefix
+ # the prefix for the namespace applying to the node
+ def prefix()
+ ret = _getproperty(33, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BSTR baseName
+ # the base name of the node (nodename with the prefix stripped off)
+ def baseName()
+ ret = _getproperty(34, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMDocumentType doctype
+ # node corresponding to the DOCTYPE
+ def doctype()
+ ret = _getproperty(38, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMImplementation implementation
+ # info on this DOM implementation
+ def implementation()
+ ret = _getproperty(39, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMElement documentElement
+ # the root of the tree
+ def documentElement()
+ ret = _getproperty(40, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # I4 readyState
+ # get the state of the XML document
+ def readyState()
+ ret = _getproperty(-525, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMParseError parseError
+ # get the last parser error
+ def parseError()
+ ret = _getproperty(59, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BSTR url
+ # get the URL for the loaded XML document
+ def url()
+ ret = _getproperty(60, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BOOL async
+ # flag for asynchronous download
+ def async()
+ ret = _getproperty(61, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BOOL validateOnParse
+ # indicates whether the parser performs validation
+ def validateOnParse()
+ ret = _getproperty(65, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BOOL resolveExternals
+ # indicates whether the parser resolves references to external DTD/Entities/Schema
+ def resolveExternals()
+ ret = _getproperty(66, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BOOL preserveWhiteSpace
+ # indicates whether the parser preserves whitespace
+ def preserveWhiteSpace()
+ ret = _getproperty(67, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VOID nodeValue
+ # value stored in the node
+ def nodeValue=(arg0)
+ ret = _setproperty(3, [arg0], [VT_VARIANT])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VOID text
+ # text content of the node and subtree
+ def text=(arg0)
+ ret = _setproperty(24, [arg0], [VT_BSTR])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VOID nodeTypedValue
+ # get the strongly typed value of the node
+ def nodeTypedValue=(arg0)
+ ret = _setproperty(25, [arg0], [VT_VARIANT])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VOID dataType
+ # the data type of the node
+ def dataType=(arg0)
+ ret = _setproperty(26, [arg0], [VT_VARIANT])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VOID async
+ # flag for asynchronous download
+ def async=(arg0)
+ ret = _setproperty(61, [arg0], [VT_BOOL])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VOID validateOnParse
+ # indicates whether the parser performs validation
+ def validateOnParse=(arg0)
+ ret = _setproperty(65, [arg0], [VT_BOOL])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VOID resolveExternals
+ # indicates whether the parser resolves references to external DTD/Entities/Schema
+ def resolveExternals=(arg0)
+ ret = _setproperty(66, [arg0], [VT_BOOL])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VOID preserveWhiteSpace
+ # indicates whether the parser preserves whitespace
+ def preserveWhiteSpace=(arg0)
+ ret = _setproperty(67, [arg0], [VT_BOOL])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VOID onreadystatechange
+ # register a readystatechange event handler
+ def onreadystatechange=(arg0)
+ ret = _setproperty(68, [arg0], [VT_VARIANT])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VOID ondataavailable
+ # register an ondataavailable event handler
+ def ondataavailable=(arg0)
+ ret = _setproperty(69, [arg0], [VT_VARIANT])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VOID ontransformnode
+ # register an ontransformnode event handler
+ def ontransformnode=(arg0)
+ ret = _setproperty(70, [arg0], [VT_VARIANT])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode insertBefore
+ # insert a child node
+ # IXMLDOMNode arg0 --- newChild [IN]
+ # VARIANT arg1 --- refChild [IN]
+ def insertBefore(arg0, arg1)
+ ret = _invoke(13, [arg0, arg1], [VT_BYREF|VT_DISPATCH, VT_VARIANT])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode replaceChild
+ # replace a child node
+ # IXMLDOMNode arg0 --- newChild [IN]
+ # IXMLDOMNode arg1 --- oldChild [IN]
+ def replaceChild(arg0, arg1)
+ ret = _invoke(14, [arg0, arg1], [VT_BYREF|VT_DISPATCH, VT_BYREF|VT_DISPATCH])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode removeChild
+ # remove a child node
+ # IXMLDOMNode arg0 --- childNode [IN]
+ def removeChild(arg0)
+ ret = _invoke(15, [arg0], [VT_BYREF|VT_DISPATCH])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode appendChild
+ # append a child node
+ # IXMLDOMNode arg0 --- newChild [IN]
+ def appendChild(arg0)
+ ret = _invoke(16, [arg0], [VT_BYREF|VT_DISPATCH])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BOOL hasChildNodes
+ def hasChildNodes()
+ ret = _invoke(17, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode cloneNode
+ # BOOL arg0 --- deep [IN]
+ def cloneNode(arg0)
+ ret = _invoke(19, [arg0], [VT_BOOL])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BSTR transformNode
+ # apply the stylesheet to the subtree
+ # IXMLDOMNode arg0 --- stylesheet [IN]
+ def transformNode(arg0)
+ ret = _invoke(28, [arg0], [VT_BYREF|VT_DISPATCH])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNodeList selectNodes
+ # execute query on the subtree
+ # BSTR arg0 --- queryString [IN]
+ def selectNodes(arg0)
+ ret = _invoke(29, [arg0], [VT_BSTR])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode selectSingleNode
+ # execute query on the subtree
+ # BSTR arg0 --- queryString [IN]
+ def selectSingleNode(arg0)
+ ret = _invoke(30, [arg0], [VT_BSTR])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VOID transformNodeToObject
+ # apply the stylesheet to the subtree, returning the result through a document or a stream
+ # IXMLDOMNode arg0 --- stylesheet [IN]
+ # VARIANT arg1 --- outputObject [IN]
+ def transformNodeToObject(arg0, arg1)
+ ret = _invoke(35, [arg0, arg1], [VT_BYREF|VT_DISPATCH, VT_VARIANT])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMElement createElement
+ # create an Element node
+ # BSTR arg0 --- tagName [IN]
+ def createElement(arg0)
+ ret = _invoke(41, [arg0], [VT_BSTR])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMDocumentFragment createDocumentFragment
+ # create a DocumentFragment node
+ def createDocumentFragment()
+ ret = _invoke(42, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMText createTextNode
+ # create a text node
+ # BSTR arg0 --- data [IN]
+ def createTextNode(arg0)
+ ret = _invoke(43, [arg0], [VT_BSTR])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMComment createComment
+ # create a comment node
+ # BSTR arg0 --- data [IN]
+ def createComment(arg0)
+ ret = _invoke(44, [arg0], [VT_BSTR])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMCDATASection createCDATASection
+ # create a CDATA section node
+ # BSTR arg0 --- data [IN]
+ def createCDATASection(arg0)
+ ret = _invoke(45, [arg0], [VT_BSTR])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMProcessingInstruction createProcessingInstruction
+ # create a processing instruction node
+ # BSTR arg0 --- target [IN]
+ # BSTR arg1 --- data [IN]
+ def createProcessingInstruction(arg0, arg1)
+ ret = _invoke(46, [arg0, arg1], [VT_BSTR, VT_BSTR])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMAttribute createAttribute
+ # create an attribute node
+ # BSTR arg0 --- name [IN]
+ def createAttribute(arg0)
+ ret = _invoke(47, [arg0], [VT_BSTR])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMEntityReference createEntityReference
+ # create an entity reference node
+ # BSTR arg0 --- name [IN]
+ def createEntityReference(arg0)
+ ret = _invoke(49, [arg0], [VT_BSTR])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNodeList getElementsByTagName
+ # build a list of elements by name
+ # BSTR arg0 --- tagName [IN]
+ def getElementsByTagName(arg0)
+ ret = _invoke(50, [arg0], [VT_BSTR])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode createNode
+ # create a node of the specified node type and name
+ # VARIANT arg0 --- type [IN]
+ # BSTR arg1 --- name [IN]
+ # BSTR arg2 --- namespaceURI [IN]
+ def createNode(arg0, arg1, arg2)
+ ret = _invoke(54, [arg0, arg1, arg2], [VT_VARIANT, VT_BSTR, VT_BSTR])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode nodeFromID
+ # retrieve node from it's ID
+ # BSTR arg0 --- idString [IN]
+ def nodeFromID(arg0)
+ ret = _invoke(56, [arg0], [VT_BSTR])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BOOL load
+ # load document from the specified XML source
+ # VARIANT arg0 --- xmlSource [IN]
+ def load(arg0)
+ ret = _invoke(58, [arg0], [VT_VARIANT])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VOID abort
+ # abort an asynchronous download
+ def abort()
+ ret = _invoke(62, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BOOL loadXML
+ # load the document from a string
+ # BSTR arg0 --- bstrXML [IN]
+ def loadXML(arg0)
+ ret = _invoke(63, [arg0], [VT_BSTR])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VOID save
+ # save the document to a specified desination
+ # VARIANT arg0 --- desination [IN]
+ def save(arg0)
+ ret = _invoke(64, [arg0], [VT_VARIANT])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+end
+
+#
+module IXMLDOMDocumentType
+ include WIN32OLE::VARIANT
+ attr_reader :lastargs
+
+ # BSTR nodeName
+ # name of the node
+ def nodeName()
+ ret = _getproperty(2, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VARIANT nodeValue
+ # value stored in the node
+ def nodeValue()
+ ret = _getproperty(3, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # DOMNodeType nodeType
+ # the node's type
+ def nodeType()
+ ret = _getproperty(4, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode parentNode
+ # parent of the node
+ def parentNode()
+ ret = _getproperty(6, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNodeList childNodes
+ # the collection of the node's children
+ def childNodes()
+ ret = _getproperty(7, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode firstChild
+ # first child of the node
+ def firstChild()
+ ret = _getproperty(8, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode lastChild
+ # first child of the node
+ def lastChild()
+ ret = _getproperty(9, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode previousSibling
+ # left sibling of the node
+ def previousSibling()
+ ret = _getproperty(10, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode nextSibling
+ # right sibling of the node
+ def nextSibling()
+ ret = _getproperty(11, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNamedNodeMap attributes
+ # the collection of the node's attributes
+ def attributes()
+ ret = _getproperty(12, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMDocument ownerDocument
+ # document that contains the node
+ def ownerDocument()
+ ret = _getproperty(18, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BSTR nodeTypeString
+ # the type of node in string form
+ def nodeTypeString()
+ ret = _getproperty(21, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BSTR text
+ # text content of the node and subtree
+ def text()
+ ret = _getproperty(24, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BOOL specified
+ # indicates whether node is a default value
+ def specified()
+ ret = _getproperty(22, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode definition
+ # pointer to the definition of the node in the DTD or schema
+ def definition()
+ ret = _getproperty(23, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VARIANT nodeTypedValue
+ # get the strongly typed value of the node
+ def nodeTypedValue()
+ ret = _getproperty(25, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VARIANT dataType
+ # the data type of the node
+ def dataType()
+ ret = _getproperty(26, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BSTR xml
+ # return the XML source for the node and each of its descendants
+ def xml()
+ ret = _getproperty(27, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BOOL parsed
+ # has sub-tree been completely parsed
+ def parsed()
+ ret = _getproperty(31, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BSTR namespaceURI
+ # the URI for the namespace applying to the node
+ def namespaceURI()
+ ret = _getproperty(32, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BSTR prefix
+ # the prefix for the namespace applying to the node
+ def prefix()
+ ret = _getproperty(33, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BSTR baseName
+ # the base name of the node (nodename with the prefix stripped off)
+ def baseName()
+ ret = _getproperty(34, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BSTR name
+ # name of the document type (root of the tree)
+ def name()
+ ret = _getproperty(131, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNamedNodeMap entities
+ # a list of entities in the document
+ def entities()
+ ret = _getproperty(132, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNamedNodeMap notations
+ # a list of notations in the document
+ def notations()
+ ret = _getproperty(133, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VOID nodeValue
+ # value stored in the node
+ def nodeValue=(arg0)
+ ret = _setproperty(3, [arg0], [VT_VARIANT])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VOID text
+ # text content of the node and subtree
+ def text=(arg0)
+ ret = _setproperty(24, [arg0], [VT_BSTR])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VOID nodeTypedValue
+ # get the strongly typed value of the node
+ def nodeTypedValue=(arg0)
+ ret = _setproperty(25, [arg0], [VT_VARIANT])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VOID dataType
+ # the data type of the node
+ def dataType=(arg0)
+ ret = _setproperty(26, [arg0], [VT_VARIANT])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode insertBefore
+ # insert a child node
+ # IXMLDOMNode arg0 --- newChild [IN]
+ # VARIANT arg1 --- refChild [IN]
+ def insertBefore(arg0, arg1)
+ ret = _invoke(13, [arg0, arg1], [VT_BYREF|VT_DISPATCH, VT_VARIANT])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode replaceChild
+ # replace a child node
+ # IXMLDOMNode arg0 --- newChild [IN]
+ # IXMLDOMNode arg1 --- oldChild [IN]
+ def replaceChild(arg0, arg1)
+ ret = _invoke(14, [arg0, arg1], [VT_BYREF|VT_DISPATCH, VT_BYREF|VT_DISPATCH])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode removeChild
+ # remove a child node
+ # IXMLDOMNode arg0 --- childNode [IN]
+ def removeChild(arg0)
+ ret = _invoke(15, [arg0], [VT_BYREF|VT_DISPATCH])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode appendChild
+ # append a child node
+ # IXMLDOMNode arg0 --- newChild [IN]
+ def appendChild(arg0)
+ ret = _invoke(16, [arg0], [VT_BYREF|VT_DISPATCH])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BOOL hasChildNodes
+ def hasChildNodes()
+ ret = _invoke(17, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode cloneNode
+ # BOOL arg0 --- deep [IN]
+ def cloneNode(arg0)
+ ret = _invoke(19, [arg0], [VT_BOOL])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BSTR transformNode
+ # apply the stylesheet to the subtree
+ # IXMLDOMNode arg0 --- stylesheet [IN]
+ def transformNode(arg0)
+ ret = _invoke(28, [arg0], [VT_BYREF|VT_DISPATCH])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNodeList selectNodes
+ # execute query on the subtree
+ # BSTR arg0 --- queryString [IN]
+ def selectNodes(arg0)
+ ret = _invoke(29, [arg0], [VT_BSTR])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode selectSingleNode
+ # execute query on the subtree
+ # BSTR arg0 --- queryString [IN]
+ def selectSingleNode(arg0)
+ ret = _invoke(30, [arg0], [VT_BSTR])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VOID transformNodeToObject
+ # apply the stylesheet to the subtree, returning the result through a document or a stream
+ # IXMLDOMNode arg0 --- stylesheet [IN]
+ # VARIANT arg1 --- outputObject [IN]
+ def transformNodeToObject(arg0, arg1)
+ ret = _invoke(35, [arg0, arg1], [VT_BYREF|VT_DISPATCH, VT_VARIANT])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+end
+
+#
+module IXMLDOMElement
+ include WIN32OLE::VARIANT
+ attr_reader :lastargs
+
+ # BSTR nodeName
+ # name of the node
+ def nodeName()
+ ret = _getproperty(2, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VARIANT nodeValue
+ # value stored in the node
+ def nodeValue()
+ ret = _getproperty(3, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # DOMNodeType nodeType
+ # the node's type
+ def nodeType()
+ ret = _getproperty(4, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode parentNode
+ # parent of the node
+ def parentNode()
+ ret = _getproperty(6, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNodeList childNodes
+ # the collection of the node's children
+ def childNodes()
+ ret = _getproperty(7, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode firstChild
+ # first child of the node
+ def firstChild()
+ ret = _getproperty(8, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode lastChild
+ # first child of the node
+ def lastChild()
+ ret = _getproperty(9, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode previousSibling
+ # left sibling of the node
+ def previousSibling()
+ ret = _getproperty(10, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode nextSibling
+ # right sibling of the node
+ def nextSibling()
+ ret = _getproperty(11, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNamedNodeMap attributes
+ # the collection of the node's attributes
+ def attributes()
+ ret = _getproperty(12, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMDocument ownerDocument
+ # document that contains the node
+ def ownerDocument()
+ ret = _getproperty(18, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BSTR nodeTypeString
+ # the type of node in string form
+ def nodeTypeString()
+ ret = _getproperty(21, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BSTR text
+ # text content of the node and subtree
+ def text()
+ ret = _getproperty(24, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BOOL specified
+ # indicates whether node is a default value
+ def specified()
+ ret = _getproperty(22, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode definition
+ # pointer to the definition of the node in the DTD or schema
+ def definition()
+ ret = _getproperty(23, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VARIANT nodeTypedValue
+ # get the strongly typed value of the node
+ def nodeTypedValue()
+ ret = _getproperty(25, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VARIANT dataType
+ # the data type of the node
+ def dataType()
+ ret = _getproperty(26, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BSTR xml
+ # return the XML source for the node and each of its descendants
+ def xml()
+ ret = _getproperty(27, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BOOL parsed
+ # has sub-tree been completely parsed
+ def parsed()
+ ret = _getproperty(31, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BSTR namespaceURI
+ # the URI for the namespace applying to the node
+ def namespaceURI()
+ ret = _getproperty(32, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BSTR prefix
+ # the prefix for the namespace applying to the node
+ def prefix()
+ ret = _getproperty(33, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BSTR baseName
+ # the base name of the node (nodename with the prefix stripped off)
+ def baseName()
+ ret = _getproperty(34, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BSTR tagName
+ # get the tagName of the element
+ def tagName()
+ ret = _getproperty(97, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VOID nodeValue
+ # value stored in the node
+ def nodeValue=(arg0)
+ ret = _setproperty(3, [arg0], [VT_VARIANT])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VOID text
+ # text content of the node and subtree
+ def text=(arg0)
+ ret = _setproperty(24, [arg0], [VT_BSTR])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VOID nodeTypedValue
+ # get the strongly typed value of the node
+ def nodeTypedValue=(arg0)
+ ret = _setproperty(25, [arg0], [VT_VARIANT])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VOID dataType
+ # the data type of the node
+ def dataType=(arg0)
+ ret = _setproperty(26, [arg0], [VT_VARIANT])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode insertBefore
+ # insert a child node
+ # IXMLDOMNode arg0 --- newChild [IN]
+ # VARIANT arg1 --- refChild [IN]
+ def insertBefore(arg0, arg1)
+ ret = _invoke(13, [arg0, arg1], [VT_BYREF|VT_DISPATCH, VT_VARIANT])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode replaceChild
+ # replace a child node
+ # IXMLDOMNode arg0 --- newChild [IN]
+ # IXMLDOMNode arg1 --- oldChild [IN]
+ def replaceChild(arg0, arg1)
+ ret = _invoke(14, [arg0, arg1], [VT_BYREF|VT_DISPATCH, VT_BYREF|VT_DISPATCH])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode removeChild
+ # remove a child node
+ # IXMLDOMNode arg0 --- childNode [IN]
+ def removeChild(arg0)
+ ret = _invoke(15, [arg0], [VT_BYREF|VT_DISPATCH])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode appendChild
+ # append a child node
+ # IXMLDOMNode arg0 --- newChild [IN]
+ def appendChild(arg0)
+ ret = _invoke(16, [arg0], [VT_BYREF|VT_DISPATCH])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BOOL hasChildNodes
+ def hasChildNodes()
+ ret = _invoke(17, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode cloneNode
+ # BOOL arg0 --- deep [IN]
+ def cloneNode(arg0)
+ ret = _invoke(19, [arg0], [VT_BOOL])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BSTR transformNode
+ # apply the stylesheet to the subtree
+ # IXMLDOMNode arg0 --- stylesheet [IN]
+ def transformNode(arg0)
+ ret = _invoke(28, [arg0], [VT_BYREF|VT_DISPATCH])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNodeList selectNodes
+ # execute query on the subtree
+ # BSTR arg0 --- queryString [IN]
+ def selectNodes(arg0)
+ ret = _invoke(29, [arg0], [VT_BSTR])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode selectSingleNode
+ # execute query on the subtree
+ # BSTR arg0 --- queryString [IN]
+ def selectSingleNode(arg0)
+ ret = _invoke(30, [arg0], [VT_BSTR])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VOID transformNodeToObject
+ # apply the stylesheet to the subtree, returning the result through a document or a stream
+ # IXMLDOMNode arg0 --- stylesheet [IN]
+ # VARIANT arg1 --- outputObject [IN]
+ def transformNodeToObject(arg0, arg1)
+ ret = _invoke(35, [arg0, arg1], [VT_BYREF|VT_DISPATCH, VT_VARIANT])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VARIANT getAttribute
+ # look up the string value of an attribute by name
+ # BSTR arg0 --- name [IN]
+ def getAttribute(arg0)
+ ret = _invoke(99, [arg0], [VT_BSTR])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VOID setAttribute
+ # set the string value of an attribute by name
+ # BSTR arg0 --- name [IN]
+ # VARIANT arg1 --- value [IN]
+ def setAttribute(arg0, arg1)
+ ret = _invoke(100, [arg0, arg1], [VT_BSTR, VT_VARIANT])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VOID removeAttribute
+ # remove an attribute by name
+ # BSTR arg0 --- name [IN]
+ def removeAttribute(arg0)
+ ret = _invoke(101, [arg0], [VT_BSTR])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMAttribute getAttributeNode
+ # look up the attribute node by name
+ # BSTR arg0 --- name [IN]
+ def getAttributeNode(arg0)
+ ret = _invoke(102, [arg0], [VT_BSTR])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMAttribute setAttributeNode
+ # set the specified attribute on the element
+ # IXMLDOMAttribute arg0 --- DOMAttribute [IN]
+ def setAttributeNode(arg0)
+ ret = _invoke(103, [arg0], [VT_BYREF|VT_DISPATCH])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMAttribute removeAttributeNode
+ # remove the specified attribute
+ # IXMLDOMAttribute arg0 --- DOMAttribute [IN]
+ def removeAttributeNode(arg0)
+ ret = _invoke(104, [arg0], [VT_BYREF|VT_DISPATCH])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNodeList getElementsByTagName
+ # build a list of elements by name
+ # BSTR arg0 --- tagName [IN]
+ def getElementsByTagName(arg0)
+ ret = _invoke(105, [arg0], [VT_BSTR])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VOID normalize
+ # collapse all adjacent text nodes in sub-tree
+ def normalize()
+ ret = _invoke(106, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+end
+
+#
+module IXMLDOMAttribute
+ include WIN32OLE::VARIANT
+ attr_reader :lastargs
+
+ # BSTR nodeName
+ # name of the node
+ def nodeName()
+ ret = _getproperty(2, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VARIANT nodeValue
+ # value stored in the node
+ def nodeValue()
+ ret = _getproperty(3, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # DOMNodeType nodeType
+ # the node's type
+ def nodeType()
+ ret = _getproperty(4, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode parentNode
+ # parent of the node
+ def parentNode()
+ ret = _getproperty(6, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNodeList childNodes
+ # the collection of the node's children
+ def childNodes()
+ ret = _getproperty(7, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode firstChild
+ # first child of the node
+ def firstChild()
+ ret = _getproperty(8, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode lastChild
+ # first child of the node
+ def lastChild()
+ ret = _getproperty(9, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode previousSibling
+ # left sibling of the node
+ def previousSibling()
+ ret = _getproperty(10, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode nextSibling
+ # right sibling of the node
+ def nextSibling()
+ ret = _getproperty(11, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNamedNodeMap attributes
+ # the collection of the node's attributes
+ def attributes()
+ ret = _getproperty(12, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMDocument ownerDocument
+ # document that contains the node
+ def ownerDocument()
+ ret = _getproperty(18, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BSTR nodeTypeString
+ # the type of node in string form
+ def nodeTypeString()
+ ret = _getproperty(21, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BSTR text
+ # text content of the node and subtree
+ def text()
+ ret = _getproperty(24, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BOOL specified
+ # indicates whether node is a default value
+ def specified()
+ ret = _getproperty(22, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode definition
+ # pointer to the definition of the node in the DTD or schema
+ def definition()
+ ret = _getproperty(23, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VARIANT nodeTypedValue
+ # get the strongly typed value of the node
+ def nodeTypedValue()
+ ret = _getproperty(25, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VARIANT dataType
+ # the data type of the node
+ def dataType()
+ ret = _getproperty(26, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BSTR xml
+ # return the XML source for the node and each of its descendants
+ def xml()
+ ret = _getproperty(27, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BOOL parsed
+ # has sub-tree been completely parsed
+ def parsed()
+ ret = _getproperty(31, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BSTR namespaceURI
+ # the URI for the namespace applying to the node
+ def namespaceURI()
+ ret = _getproperty(32, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BSTR prefix
+ # the prefix for the namespace applying to the node
+ def prefix()
+ ret = _getproperty(33, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BSTR baseName
+ # the base name of the node (nodename with the prefix stripped off)
+ def baseName()
+ ret = _getproperty(34, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BSTR name
+ # get name of the attribute
+ def name()
+ ret = _getproperty(118, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VARIANT value
+ # string value of the attribute
+ def value()
+ ret = _getproperty(120, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VOID nodeValue
+ # value stored in the node
+ def nodeValue=(arg0)
+ ret = _setproperty(3, [arg0], [VT_VARIANT])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VOID text
+ # text content of the node and subtree
+ def text=(arg0)
+ ret = _setproperty(24, [arg0], [VT_BSTR])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VOID nodeTypedValue
+ # get the strongly typed value of the node
+ def nodeTypedValue=(arg0)
+ ret = _setproperty(25, [arg0], [VT_VARIANT])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VOID dataType
+ # the data type of the node
+ def dataType=(arg0)
+ ret = _setproperty(26, [arg0], [VT_VARIANT])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VOID value
+ # string value of the attribute
+ def value=(arg0)
+ ret = _setproperty(120, [arg0], [VT_VARIANT])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode insertBefore
+ # insert a child node
+ # IXMLDOMNode arg0 --- newChild [IN]
+ # VARIANT arg1 --- refChild [IN]
+ def insertBefore(arg0, arg1)
+ ret = _invoke(13, [arg0, arg1], [VT_BYREF|VT_DISPATCH, VT_VARIANT])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode replaceChild
+ # replace a child node
+ # IXMLDOMNode arg0 --- newChild [IN]
+ # IXMLDOMNode arg1 --- oldChild [IN]
+ def replaceChild(arg0, arg1)
+ ret = _invoke(14, [arg0, arg1], [VT_BYREF|VT_DISPATCH, VT_BYREF|VT_DISPATCH])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode removeChild
+ # remove a child node
+ # IXMLDOMNode arg0 --- childNode [IN]
+ def removeChild(arg0)
+ ret = _invoke(15, [arg0], [VT_BYREF|VT_DISPATCH])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode appendChild
+ # append a child node
+ # IXMLDOMNode arg0 --- newChild [IN]
+ def appendChild(arg0)
+ ret = _invoke(16, [arg0], [VT_BYREF|VT_DISPATCH])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BOOL hasChildNodes
+ def hasChildNodes()
+ ret = _invoke(17, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode cloneNode
+ # BOOL arg0 --- deep [IN]
+ def cloneNode(arg0)
+ ret = _invoke(19, [arg0], [VT_BOOL])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BSTR transformNode
+ # apply the stylesheet to the subtree
+ # IXMLDOMNode arg0 --- stylesheet [IN]
+ def transformNode(arg0)
+ ret = _invoke(28, [arg0], [VT_BYREF|VT_DISPATCH])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNodeList selectNodes
+ # execute query on the subtree
+ # BSTR arg0 --- queryString [IN]
+ def selectNodes(arg0)
+ ret = _invoke(29, [arg0], [VT_BSTR])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode selectSingleNode
+ # execute query on the subtree
+ # BSTR arg0 --- queryString [IN]
+ def selectSingleNode(arg0)
+ ret = _invoke(30, [arg0], [VT_BSTR])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VOID transformNodeToObject
+ # apply the stylesheet to the subtree, returning the result through a document or a stream
+ # IXMLDOMNode arg0 --- stylesheet [IN]
+ # VARIANT arg1 --- outputObject [IN]
+ def transformNodeToObject(arg0, arg1)
+ ret = _invoke(35, [arg0, arg1], [VT_BYREF|VT_DISPATCH, VT_VARIANT])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+end
+
+#
+module IXMLDOMDocumentFragment
+ include WIN32OLE::VARIANT
+ attr_reader :lastargs
+
+ # BSTR nodeName
+ # name of the node
+ def nodeName()
+ ret = _getproperty(2, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VARIANT nodeValue
+ # value stored in the node
+ def nodeValue()
+ ret = _getproperty(3, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # DOMNodeType nodeType
+ # the node's type
+ def nodeType()
+ ret = _getproperty(4, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode parentNode
+ # parent of the node
+ def parentNode()
+ ret = _getproperty(6, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNodeList childNodes
+ # the collection of the node's children
+ def childNodes()
+ ret = _getproperty(7, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode firstChild
+ # first child of the node
+ def firstChild()
+ ret = _getproperty(8, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode lastChild
+ # first child of the node
+ def lastChild()
+ ret = _getproperty(9, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode previousSibling
+ # left sibling of the node
+ def previousSibling()
+ ret = _getproperty(10, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode nextSibling
+ # right sibling of the node
+ def nextSibling()
+ ret = _getproperty(11, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNamedNodeMap attributes
+ # the collection of the node's attributes
+ def attributes()
+ ret = _getproperty(12, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMDocument ownerDocument
+ # document that contains the node
+ def ownerDocument()
+ ret = _getproperty(18, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BSTR nodeTypeString
+ # the type of node in string form
+ def nodeTypeString()
+ ret = _getproperty(21, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BSTR text
+ # text content of the node and subtree
+ def text()
+ ret = _getproperty(24, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BOOL specified
+ # indicates whether node is a default value
+ def specified()
+ ret = _getproperty(22, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode definition
+ # pointer to the definition of the node in the DTD or schema
+ def definition()
+ ret = _getproperty(23, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VARIANT nodeTypedValue
+ # get the strongly typed value of the node
+ def nodeTypedValue()
+ ret = _getproperty(25, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VARIANT dataType
+ # the data type of the node
+ def dataType()
+ ret = _getproperty(26, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BSTR xml
+ # return the XML source for the node and each of its descendants
+ def xml()
+ ret = _getproperty(27, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BOOL parsed
+ # has sub-tree been completely parsed
+ def parsed()
+ ret = _getproperty(31, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BSTR namespaceURI
+ # the URI for the namespace applying to the node
+ def namespaceURI()
+ ret = _getproperty(32, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BSTR prefix
+ # the prefix for the namespace applying to the node
+ def prefix()
+ ret = _getproperty(33, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BSTR baseName
+ # the base name of the node (nodename with the prefix stripped off)
+ def baseName()
+ ret = _getproperty(34, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VOID nodeValue
+ # value stored in the node
+ def nodeValue=(arg0)
+ ret = _setproperty(3, [arg0], [VT_VARIANT])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VOID text
+ # text content of the node and subtree
+ def text=(arg0)
+ ret = _setproperty(24, [arg0], [VT_BSTR])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VOID nodeTypedValue
+ # get the strongly typed value of the node
+ def nodeTypedValue=(arg0)
+ ret = _setproperty(25, [arg0], [VT_VARIANT])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VOID dataType
+ # the data type of the node
+ def dataType=(arg0)
+ ret = _setproperty(26, [arg0], [VT_VARIANT])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode insertBefore
+ # insert a child node
+ # IXMLDOMNode arg0 --- newChild [IN]
+ # VARIANT arg1 --- refChild [IN]
+ def insertBefore(arg0, arg1)
+ ret = _invoke(13, [arg0, arg1], [VT_BYREF|VT_DISPATCH, VT_VARIANT])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode replaceChild
+ # replace a child node
+ # IXMLDOMNode arg0 --- newChild [IN]
+ # IXMLDOMNode arg1 --- oldChild [IN]
+ def replaceChild(arg0, arg1)
+ ret = _invoke(14, [arg0, arg1], [VT_BYREF|VT_DISPATCH, VT_BYREF|VT_DISPATCH])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode removeChild
+ # remove a child node
+ # IXMLDOMNode arg0 --- childNode [IN]
+ def removeChild(arg0)
+ ret = _invoke(15, [arg0], [VT_BYREF|VT_DISPATCH])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode appendChild
+ # append a child node
+ # IXMLDOMNode arg0 --- newChild [IN]
+ def appendChild(arg0)
+ ret = _invoke(16, [arg0], [VT_BYREF|VT_DISPATCH])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BOOL hasChildNodes
+ def hasChildNodes()
+ ret = _invoke(17, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode cloneNode
+ # BOOL arg0 --- deep [IN]
+ def cloneNode(arg0)
+ ret = _invoke(19, [arg0], [VT_BOOL])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BSTR transformNode
+ # apply the stylesheet to the subtree
+ # IXMLDOMNode arg0 --- stylesheet [IN]
+ def transformNode(arg0)
+ ret = _invoke(28, [arg0], [VT_BYREF|VT_DISPATCH])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNodeList selectNodes
+ # execute query on the subtree
+ # BSTR arg0 --- queryString [IN]
+ def selectNodes(arg0)
+ ret = _invoke(29, [arg0], [VT_BSTR])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode selectSingleNode
+ # execute query on the subtree
+ # BSTR arg0 --- queryString [IN]
+ def selectSingleNode(arg0)
+ ret = _invoke(30, [arg0], [VT_BSTR])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VOID transformNodeToObject
+ # apply the stylesheet to the subtree, returning the result through a document or a stream
+ # IXMLDOMNode arg0 --- stylesheet [IN]
+ # VARIANT arg1 --- outputObject [IN]
+ def transformNodeToObject(arg0, arg1)
+ ret = _invoke(35, [arg0, arg1], [VT_BYREF|VT_DISPATCH, VT_VARIANT])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+end
+
+#
+module IXMLDOMText
+ include WIN32OLE::VARIANT
+ attr_reader :lastargs
+
+ # BSTR nodeName
+ # name of the node
+ def nodeName()
+ ret = _getproperty(2, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VARIANT nodeValue
+ # value stored in the node
+ def nodeValue()
+ ret = _getproperty(3, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # DOMNodeType nodeType
+ # the node's type
+ def nodeType()
+ ret = _getproperty(4, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode parentNode
+ # parent of the node
+ def parentNode()
+ ret = _getproperty(6, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNodeList childNodes
+ # the collection of the node's children
+ def childNodes()
+ ret = _getproperty(7, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode firstChild
+ # first child of the node
+ def firstChild()
+ ret = _getproperty(8, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode lastChild
+ # first child of the node
+ def lastChild()
+ ret = _getproperty(9, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode previousSibling
+ # left sibling of the node
+ def previousSibling()
+ ret = _getproperty(10, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode nextSibling
+ # right sibling of the node
+ def nextSibling()
+ ret = _getproperty(11, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNamedNodeMap attributes
+ # the collection of the node's attributes
+ def attributes()
+ ret = _getproperty(12, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMDocument ownerDocument
+ # document that contains the node
+ def ownerDocument()
+ ret = _getproperty(18, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BSTR nodeTypeString
+ # the type of node in string form
+ def nodeTypeString()
+ ret = _getproperty(21, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BSTR text
+ # text content of the node and subtree
+ def text()
+ ret = _getproperty(24, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BOOL specified
+ # indicates whether node is a default value
+ def specified()
+ ret = _getproperty(22, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode definition
+ # pointer to the definition of the node in the DTD or schema
+ def definition()
+ ret = _getproperty(23, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VARIANT nodeTypedValue
+ # get the strongly typed value of the node
+ def nodeTypedValue()
+ ret = _getproperty(25, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VARIANT dataType
+ # the data type of the node
+ def dataType()
+ ret = _getproperty(26, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BSTR xml
+ # return the XML source for the node and each of its descendants
+ def xml()
+ ret = _getproperty(27, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BOOL parsed
+ # has sub-tree been completely parsed
+ def parsed()
+ ret = _getproperty(31, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BSTR namespaceURI
+ # the URI for the namespace applying to the node
+ def namespaceURI()
+ ret = _getproperty(32, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BSTR prefix
+ # the prefix for the namespace applying to the node
+ def prefix()
+ ret = _getproperty(33, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BSTR baseName
+ # the base name of the node (nodename with the prefix stripped off)
+ def baseName()
+ ret = _getproperty(34, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BSTR data
+ # value of the node
+ def data()
+ ret = _getproperty(109, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # I4 length
+ # number of characters in value
+ def length()
+ ret = _getproperty(110, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VOID nodeValue
+ # value stored in the node
+ def nodeValue=(arg0)
+ ret = _setproperty(3, [arg0], [VT_VARIANT])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VOID text
+ # text content of the node and subtree
+ def text=(arg0)
+ ret = _setproperty(24, [arg0], [VT_BSTR])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VOID nodeTypedValue
+ # get the strongly typed value of the node
+ def nodeTypedValue=(arg0)
+ ret = _setproperty(25, [arg0], [VT_VARIANT])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VOID dataType
+ # the data type of the node
+ def dataType=(arg0)
+ ret = _setproperty(26, [arg0], [VT_VARIANT])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VOID data
+ # value of the node
+ def data=(arg0)
+ ret = _setproperty(109, [arg0], [VT_BSTR])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode insertBefore
+ # insert a child node
+ # IXMLDOMNode arg0 --- newChild [IN]
+ # VARIANT arg1 --- refChild [IN]
+ def insertBefore(arg0, arg1)
+ ret = _invoke(13, [arg0, arg1], [VT_BYREF|VT_DISPATCH, VT_VARIANT])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode replaceChild
+ # replace a child node
+ # IXMLDOMNode arg0 --- newChild [IN]
+ # IXMLDOMNode arg1 --- oldChild [IN]
+ def replaceChild(arg0, arg1)
+ ret = _invoke(14, [arg0, arg1], [VT_BYREF|VT_DISPATCH, VT_BYREF|VT_DISPATCH])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode removeChild
+ # remove a child node
+ # IXMLDOMNode arg0 --- childNode [IN]
+ def removeChild(arg0)
+ ret = _invoke(15, [arg0], [VT_BYREF|VT_DISPATCH])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode appendChild
+ # append a child node
+ # IXMLDOMNode arg0 --- newChild [IN]
+ def appendChild(arg0)
+ ret = _invoke(16, [arg0], [VT_BYREF|VT_DISPATCH])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BOOL hasChildNodes
+ def hasChildNodes()
+ ret = _invoke(17, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode cloneNode
+ # BOOL arg0 --- deep [IN]
+ def cloneNode(arg0)
+ ret = _invoke(19, [arg0], [VT_BOOL])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BSTR transformNode
+ # apply the stylesheet to the subtree
+ # IXMLDOMNode arg0 --- stylesheet [IN]
+ def transformNode(arg0)
+ ret = _invoke(28, [arg0], [VT_BYREF|VT_DISPATCH])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNodeList selectNodes
+ # execute query on the subtree
+ # BSTR arg0 --- queryString [IN]
+ def selectNodes(arg0)
+ ret = _invoke(29, [arg0], [VT_BSTR])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode selectSingleNode
+ # execute query on the subtree
+ # BSTR arg0 --- queryString [IN]
+ def selectSingleNode(arg0)
+ ret = _invoke(30, [arg0], [VT_BSTR])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VOID transformNodeToObject
+ # apply the stylesheet to the subtree, returning the result through a document or a stream
+ # IXMLDOMNode arg0 --- stylesheet [IN]
+ # VARIANT arg1 --- outputObject [IN]
+ def transformNodeToObject(arg0, arg1)
+ ret = _invoke(35, [arg0, arg1], [VT_BYREF|VT_DISPATCH, VT_VARIANT])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BSTR substringData
+ # retrieve substring of value
+ # I4 arg0 --- offset [IN]
+ # I4 arg1 --- count [IN]
+ def substringData(arg0, arg1)
+ ret = _invoke(111, [arg0, arg1], [VT_I4, VT_I4])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VOID appendData
+ # append string to value
+ # BSTR arg0 --- data [IN]
+ def appendData(arg0)
+ ret = _invoke(112, [arg0], [VT_BSTR])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VOID insertData
+ # insert string into value
+ # I4 arg0 --- offset [IN]
+ # BSTR arg1 --- data [IN]
+ def insertData(arg0, arg1)
+ ret = _invoke(113, [arg0, arg1], [VT_I4, VT_BSTR])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VOID deleteData
+ # delete string within the value
+ # I4 arg0 --- offset [IN]
+ # I4 arg1 --- count [IN]
+ def deleteData(arg0, arg1)
+ ret = _invoke(114, [arg0, arg1], [VT_I4, VT_I4])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VOID replaceData
+ # replace string within the value
+ # I4 arg0 --- offset [IN]
+ # I4 arg1 --- count [IN]
+ # BSTR arg2 --- data [IN]
+ def replaceData(arg0, arg1, arg2)
+ ret = _invoke(115, [arg0, arg1, arg2], [VT_I4, VT_I4, VT_BSTR])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMText splitText
+ # split the text node into two text nodes at the position specified
+ # I4 arg0 --- offset [IN]
+ def splitText(arg0)
+ ret = _invoke(123, [arg0], [VT_I4])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+end
+
+#
+module IXMLDOMCharacterData
+ include WIN32OLE::VARIANT
+ attr_reader :lastargs
+
+ # BSTR nodeName
+ # name of the node
+ def nodeName()
+ ret = _getproperty(2, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VARIANT nodeValue
+ # value stored in the node
+ def nodeValue()
+ ret = _getproperty(3, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # DOMNodeType nodeType
+ # the node's type
+ def nodeType()
+ ret = _getproperty(4, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode parentNode
+ # parent of the node
+ def parentNode()
+ ret = _getproperty(6, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNodeList childNodes
+ # the collection of the node's children
+ def childNodes()
+ ret = _getproperty(7, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode firstChild
+ # first child of the node
+ def firstChild()
+ ret = _getproperty(8, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode lastChild
+ # first child of the node
+ def lastChild()
+ ret = _getproperty(9, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode previousSibling
+ # left sibling of the node
+ def previousSibling()
+ ret = _getproperty(10, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode nextSibling
+ # right sibling of the node
+ def nextSibling()
+ ret = _getproperty(11, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNamedNodeMap attributes
+ # the collection of the node's attributes
+ def attributes()
+ ret = _getproperty(12, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMDocument ownerDocument
+ # document that contains the node
+ def ownerDocument()
+ ret = _getproperty(18, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BSTR nodeTypeString
+ # the type of node in string form
+ def nodeTypeString()
+ ret = _getproperty(21, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BSTR text
+ # text content of the node and subtree
+ def text()
+ ret = _getproperty(24, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BOOL specified
+ # indicates whether node is a default value
+ def specified()
+ ret = _getproperty(22, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode definition
+ # pointer to the definition of the node in the DTD or schema
+ def definition()
+ ret = _getproperty(23, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VARIANT nodeTypedValue
+ # get the strongly typed value of the node
+ def nodeTypedValue()
+ ret = _getproperty(25, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VARIANT dataType
+ # the data type of the node
+ def dataType()
+ ret = _getproperty(26, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BSTR xml
+ # return the XML source for the node and each of its descendants
+ def xml()
+ ret = _getproperty(27, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BOOL parsed
+ # has sub-tree been completely parsed
+ def parsed()
+ ret = _getproperty(31, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BSTR namespaceURI
+ # the URI for the namespace applying to the node
+ def namespaceURI()
+ ret = _getproperty(32, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BSTR prefix
+ # the prefix for the namespace applying to the node
+ def prefix()
+ ret = _getproperty(33, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BSTR baseName
+ # the base name of the node (nodename with the prefix stripped off)
+ def baseName()
+ ret = _getproperty(34, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BSTR data
+ # value of the node
+ def data()
+ ret = _getproperty(109, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # I4 length
+ # number of characters in value
+ def length()
+ ret = _getproperty(110, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VOID nodeValue
+ # value stored in the node
+ def nodeValue=(arg0)
+ ret = _setproperty(3, [arg0], [VT_VARIANT])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VOID text
+ # text content of the node and subtree
+ def text=(arg0)
+ ret = _setproperty(24, [arg0], [VT_BSTR])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VOID nodeTypedValue
+ # get the strongly typed value of the node
+ def nodeTypedValue=(arg0)
+ ret = _setproperty(25, [arg0], [VT_VARIANT])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VOID dataType
+ # the data type of the node
+ def dataType=(arg0)
+ ret = _setproperty(26, [arg0], [VT_VARIANT])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VOID data
+ # value of the node
+ def data=(arg0)
+ ret = _setproperty(109, [arg0], [VT_BSTR])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode insertBefore
+ # insert a child node
+ # IXMLDOMNode arg0 --- newChild [IN]
+ # VARIANT arg1 --- refChild [IN]
+ def insertBefore(arg0, arg1)
+ ret = _invoke(13, [arg0, arg1], [VT_BYREF|VT_DISPATCH, VT_VARIANT])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode replaceChild
+ # replace a child node
+ # IXMLDOMNode arg0 --- newChild [IN]
+ # IXMLDOMNode arg1 --- oldChild [IN]
+ def replaceChild(arg0, arg1)
+ ret = _invoke(14, [arg0, arg1], [VT_BYREF|VT_DISPATCH, VT_BYREF|VT_DISPATCH])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode removeChild
+ # remove a child node
+ # IXMLDOMNode arg0 --- childNode [IN]
+ def removeChild(arg0)
+ ret = _invoke(15, [arg0], [VT_BYREF|VT_DISPATCH])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode appendChild
+ # append a child node
+ # IXMLDOMNode arg0 --- newChild [IN]
+ def appendChild(arg0)
+ ret = _invoke(16, [arg0], [VT_BYREF|VT_DISPATCH])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BOOL hasChildNodes
+ def hasChildNodes()
+ ret = _invoke(17, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode cloneNode
+ # BOOL arg0 --- deep [IN]
+ def cloneNode(arg0)
+ ret = _invoke(19, [arg0], [VT_BOOL])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BSTR transformNode
+ # apply the stylesheet to the subtree
+ # IXMLDOMNode arg0 --- stylesheet [IN]
+ def transformNode(arg0)
+ ret = _invoke(28, [arg0], [VT_BYREF|VT_DISPATCH])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNodeList selectNodes
+ # execute query on the subtree
+ # BSTR arg0 --- queryString [IN]
+ def selectNodes(arg0)
+ ret = _invoke(29, [arg0], [VT_BSTR])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode selectSingleNode
+ # execute query on the subtree
+ # BSTR arg0 --- queryString [IN]
+ def selectSingleNode(arg0)
+ ret = _invoke(30, [arg0], [VT_BSTR])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VOID transformNodeToObject
+ # apply the stylesheet to the subtree, returning the result through a document or a stream
+ # IXMLDOMNode arg0 --- stylesheet [IN]
+ # VARIANT arg1 --- outputObject [IN]
+ def transformNodeToObject(arg0, arg1)
+ ret = _invoke(35, [arg0, arg1], [VT_BYREF|VT_DISPATCH, VT_VARIANT])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BSTR substringData
+ # retrieve substring of value
+ # I4 arg0 --- offset [IN]
+ # I4 arg1 --- count [IN]
+ def substringData(arg0, arg1)
+ ret = _invoke(111, [arg0, arg1], [VT_I4, VT_I4])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VOID appendData
+ # append string to value
+ # BSTR arg0 --- data [IN]
+ def appendData(arg0)
+ ret = _invoke(112, [arg0], [VT_BSTR])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VOID insertData
+ # insert string into value
+ # I4 arg0 --- offset [IN]
+ # BSTR arg1 --- data [IN]
+ def insertData(arg0, arg1)
+ ret = _invoke(113, [arg0, arg1], [VT_I4, VT_BSTR])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VOID deleteData
+ # delete string within the value
+ # I4 arg0 --- offset [IN]
+ # I4 arg1 --- count [IN]
+ def deleteData(arg0, arg1)
+ ret = _invoke(114, [arg0, arg1], [VT_I4, VT_I4])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VOID replaceData
+ # replace string within the value
+ # I4 arg0 --- offset [IN]
+ # I4 arg1 --- count [IN]
+ # BSTR arg2 --- data [IN]
+ def replaceData(arg0, arg1, arg2)
+ ret = _invoke(115, [arg0, arg1, arg2], [VT_I4, VT_I4, VT_BSTR])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+end
+
+#
+module IXMLDOMComment
+ include WIN32OLE::VARIANT
+ attr_reader :lastargs
+
+ # BSTR nodeName
+ # name of the node
+ def nodeName()
+ ret = _getproperty(2, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VARIANT nodeValue
+ # value stored in the node
+ def nodeValue()
+ ret = _getproperty(3, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # DOMNodeType nodeType
+ # the node's type
+ def nodeType()
+ ret = _getproperty(4, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode parentNode
+ # parent of the node
+ def parentNode()
+ ret = _getproperty(6, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNodeList childNodes
+ # the collection of the node's children
+ def childNodes()
+ ret = _getproperty(7, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode firstChild
+ # first child of the node
+ def firstChild()
+ ret = _getproperty(8, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode lastChild
+ # first child of the node
+ def lastChild()
+ ret = _getproperty(9, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode previousSibling
+ # left sibling of the node
+ def previousSibling()
+ ret = _getproperty(10, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode nextSibling
+ # right sibling of the node
+ def nextSibling()
+ ret = _getproperty(11, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNamedNodeMap attributes
+ # the collection of the node's attributes
+ def attributes()
+ ret = _getproperty(12, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMDocument ownerDocument
+ # document that contains the node
+ def ownerDocument()
+ ret = _getproperty(18, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BSTR nodeTypeString
+ # the type of node in string form
+ def nodeTypeString()
+ ret = _getproperty(21, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BSTR text
+ # text content of the node and subtree
+ def text()
+ ret = _getproperty(24, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BOOL specified
+ # indicates whether node is a default value
+ def specified()
+ ret = _getproperty(22, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode definition
+ # pointer to the definition of the node in the DTD or schema
+ def definition()
+ ret = _getproperty(23, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VARIANT nodeTypedValue
+ # get the strongly typed value of the node
+ def nodeTypedValue()
+ ret = _getproperty(25, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VARIANT dataType
+ # the data type of the node
+ def dataType()
+ ret = _getproperty(26, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BSTR xml
+ # return the XML source for the node and each of its descendants
+ def xml()
+ ret = _getproperty(27, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BOOL parsed
+ # has sub-tree been completely parsed
+ def parsed()
+ ret = _getproperty(31, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BSTR namespaceURI
+ # the URI for the namespace applying to the node
+ def namespaceURI()
+ ret = _getproperty(32, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BSTR prefix
+ # the prefix for the namespace applying to the node
+ def prefix()
+ ret = _getproperty(33, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BSTR baseName
+ # the base name of the node (nodename with the prefix stripped off)
+ def baseName()
+ ret = _getproperty(34, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BSTR data
+ # value of the node
+ def data()
+ ret = _getproperty(109, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # I4 length
+ # number of characters in value
+ def length()
+ ret = _getproperty(110, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VOID nodeValue
+ # value stored in the node
+ def nodeValue=(arg0)
+ ret = _setproperty(3, [arg0], [VT_VARIANT])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VOID text
+ # text content of the node and subtree
+ def text=(arg0)
+ ret = _setproperty(24, [arg0], [VT_BSTR])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VOID nodeTypedValue
+ # get the strongly typed value of the node
+ def nodeTypedValue=(arg0)
+ ret = _setproperty(25, [arg0], [VT_VARIANT])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VOID dataType
+ # the data type of the node
+ def dataType=(arg0)
+ ret = _setproperty(26, [arg0], [VT_VARIANT])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VOID data
+ # value of the node
+ def data=(arg0)
+ ret = _setproperty(109, [arg0], [VT_BSTR])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode insertBefore
+ # insert a child node
+ # IXMLDOMNode arg0 --- newChild [IN]
+ # VARIANT arg1 --- refChild [IN]
+ def insertBefore(arg0, arg1)
+ ret = _invoke(13, [arg0, arg1], [VT_BYREF|VT_DISPATCH, VT_VARIANT])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode replaceChild
+ # replace a child node
+ # IXMLDOMNode arg0 --- newChild [IN]
+ # IXMLDOMNode arg1 --- oldChild [IN]
+ def replaceChild(arg0, arg1)
+ ret = _invoke(14, [arg0, arg1], [VT_BYREF|VT_DISPATCH, VT_BYREF|VT_DISPATCH])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode removeChild
+ # remove a child node
+ # IXMLDOMNode arg0 --- childNode [IN]
+ def removeChild(arg0)
+ ret = _invoke(15, [arg0], [VT_BYREF|VT_DISPATCH])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode appendChild
+ # append a child node
+ # IXMLDOMNode arg0 --- newChild [IN]
+ def appendChild(arg0)
+ ret = _invoke(16, [arg0], [VT_BYREF|VT_DISPATCH])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BOOL hasChildNodes
+ def hasChildNodes()
+ ret = _invoke(17, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode cloneNode
+ # BOOL arg0 --- deep [IN]
+ def cloneNode(arg0)
+ ret = _invoke(19, [arg0], [VT_BOOL])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BSTR transformNode
+ # apply the stylesheet to the subtree
+ # IXMLDOMNode arg0 --- stylesheet [IN]
+ def transformNode(arg0)
+ ret = _invoke(28, [arg0], [VT_BYREF|VT_DISPATCH])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNodeList selectNodes
+ # execute query on the subtree
+ # BSTR arg0 --- queryString [IN]
+ def selectNodes(arg0)
+ ret = _invoke(29, [arg0], [VT_BSTR])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode selectSingleNode
+ # execute query on the subtree
+ # BSTR arg0 --- queryString [IN]
+ def selectSingleNode(arg0)
+ ret = _invoke(30, [arg0], [VT_BSTR])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VOID transformNodeToObject
+ # apply the stylesheet to the subtree, returning the result through a document or a stream
+ # IXMLDOMNode arg0 --- stylesheet [IN]
+ # VARIANT arg1 --- outputObject [IN]
+ def transformNodeToObject(arg0, arg1)
+ ret = _invoke(35, [arg0, arg1], [VT_BYREF|VT_DISPATCH, VT_VARIANT])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BSTR substringData
+ # retrieve substring of value
+ # I4 arg0 --- offset [IN]
+ # I4 arg1 --- count [IN]
+ def substringData(arg0, arg1)
+ ret = _invoke(111, [arg0, arg1], [VT_I4, VT_I4])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VOID appendData
+ # append string to value
+ # BSTR arg0 --- data [IN]
+ def appendData(arg0)
+ ret = _invoke(112, [arg0], [VT_BSTR])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VOID insertData
+ # insert string into value
+ # I4 arg0 --- offset [IN]
+ # BSTR arg1 --- data [IN]
+ def insertData(arg0, arg1)
+ ret = _invoke(113, [arg0, arg1], [VT_I4, VT_BSTR])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VOID deleteData
+ # delete string within the value
+ # I4 arg0 --- offset [IN]
+ # I4 arg1 --- count [IN]
+ def deleteData(arg0, arg1)
+ ret = _invoke(114, [arg0, arg1], [VT_I4, VT_I4])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VOID replaceData
+ # replace string within the value
+ # I4 arg0 --- offset [IN]
+ # I4 arg1 --- count [IN]
+ # BSTR arg2 --- data [IN]
+ def replaceData(arg0, arg1, arg2)
+ ret = _invoke(115, [arg0, arg1, arg2], [VT_I4, VT_I4, VT_BSTR])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+end
+
+#
+module IXMLDOMCDATASection
+ include WIN32OLE::VARIANT
+ attr_reader :lastargs
+
+ # BSTR nodeName
+ # name of the node
+ def nodeName()
+ ret = _getproperty(2, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VARIANT nodeValue
+ # value stored in the node
+ def nodeValue()
+ ret = _getproperty(3, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # DOMNodeType nodeType
+ # the node's type
+ def nodeType()
+ ret = _getproperty(4, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode parentNode
+ # parent of the node
+ def parentNode()
+ ret = _getproperty(6, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNodeList childNodes
+ # the collection of the node's children
+ def childNodes()
+ ret = _getproperty(7, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode firstChild
+ # first child of the node
+ def firstChild()
+ ret = _getproperty(8, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode lastChild
+ # first child of the node
+ def lastChild()
+ ret = _getproperty(9, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode previousSibling
+ # left sibling of the node
+ def previousSibling()
+ ret = _getproperty(10, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode nextSibling
+ # right sibling of the node
+ def nextSibling()
+ ret = _getproperty(11, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNamedNodeMap attributes
+ # the collection of the node's attributes
+ def attributes()
+ ret = _getproperty(12, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMDocument ownerDocument
+ # document that contains the node
+ def ownerDocument()
+ ret = _getproperty(18, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BSTR nodeTypeString
+ # the type of node in string form
+ def nodeTypeString()
+ ret = _getproperty(21, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BSTR text
+ # text content of the node and subtree
+ def text()
+ ret = _getproperty(24, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BOOL specified
+ # indicates whether node is a default value
+ def specified()
+ ret = _getproperty(22, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode definition
+ # pointer to the definition of the node in the DTD or schema
+ def definition()
+ ret = _getproperty(23, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VARIANT nodeTypedValue
+ # get the strongly typed value of the node
+ def nodeTypedValue()
+ ret = _getproperty(25, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VARIANT dataType
+ # the data type of the node
+ def dataType()
+ ret = _getproperty(26, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BSTR xml
+ # return the XML source for the node and each of its descendants
+ def xml()
+ ret = _getproperty(27, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BOOL parsed
+ # has sub-tree been completely parsed
+ def parsed()
+ ret = _getproperty(31, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BSTR namespaceURI
+ # the URI for the namespace applying to the node
+ def namespaceURI()
+ ret = _getproperty(32, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BSTR prefix
+ # the prefix for the namespace applying to the node
+ def prefix()
+ ret = _getproperty(33, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BSTR baseName
+ # the base name of the node (nodename with the prefix stripped off)
+ def baseName()
+ ret = _getproperty(34, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BSTR data
+ # value of the node
+ def data()
+ ret = _getproperty(109, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # I4 length
+ # number of characters in value
+ def length()
+ ret = _getproperty(110, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VOID nodeValue
+ # value stored in the node
+ def nodeValue=(arg0)
+ ret = _setproperty(3, [arg0], [VT_VARIANT])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VOID text
+ # text content of the node and subtree
+ def text=(arg0)
+ ret = _setproperty(24, [arg0], [VT_BSTR])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VOID nodeTypedValue
+ # get the strongly typed value of the node
+ def nodeTypedValue=(arg0)
+ ret = _setproperty(25, [arg0], [VT_VARIANT])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VOID dataType
+ # the data type of the node
+ def dataType=(arg0)
+ ret = _setproperty(26, [arg0], [VT_VARIANT])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VOID data
+ # value of the node
+ def data=(arg0)
+ ret = _setproperty(109, [arg0], [VT_BSTR])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode insertBefore
+ # insert a child node
+ # IXMLDOMNode arg0 --- newChild [IN]
+ # VARIANT arg1 --- refChild [IN]
+ def insertBefore(arg0, arg1)
+ ret = _invoke(13, [arg0, arg1], [VT_BYREF|VT_DISPATCH, VT_VARIANT])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode replaceChild
+ # replace a child node
+ # IXMLDOMNode arg0 --- newChild [IN]
+ # IXMLDOMNode arg1 --- oldChild [IN]
+ def replaceChild(arg0, arg1)
+ ret = _invoke(14, [arg0, arg1], [VT_BYREF|VT_DISPATCH, VT_BYREF|VT_DISPATCH])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode removeChild
+ # remove a child node
+ # IXMLDOMNode arg0 --- childNode [IN]
+ def removeChild(arg0)
+ ret = _invoke(15, [arg0], [VT_BYREF|VT_DISPATCH])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode appendChild
+ # append a child node
+ # IXMLDOMNode arg0 --- newChild [IN]
+ def appendChild(arg0)
+ ret = _invoke(16, [arg0], [VT_BYREF|VT_DISPATCH])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BOOL hasChildNodes
+ def hasChildNodes()
+ ret = _invoke(17, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode cloneNode
+ # BOOL arg0 --- deep [IN]
+ def cloneNode(arg0)
+ ret = _invoke(19, [arg0], [VT_BOOL])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BSTR transformNode
+ # apply the stylesheet to the subtree
+ # IXMLDOMNode arg0 --- stylesheet [IN]
+ def transformNode(arg0)
+ ret = _invoke(28, [arg0], [VT_BYREF|VT_DISPATCH])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNodeList selectNodes
+ # execute query on the subtree
+ # BSTR arg0 --- queryString [IN]
+ def selectNodes(arg0)
+ ret = _invoke(29, [arg0], [VT_BSTR])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode selectSingleNode
+ # execute query on the subtree
+ # BSTR arg0 --- queryString [IN]
+ def selectSingleNode(arg0)
+ ret = _invoke(30, [arg0], [VT_BSTR])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VOID transformNodeToObject
+ # apply the stylesheet to the subtree, returning the result through a document or a stream
+ # IXMLDOMNode arg0 --- stylesheet [IN]
+ # VARIANT arg1 --- outputObject [IN]
+ def transformNodeToObject(arg0, arg1)
+ ret = _invoke(35, [arg0, arg1], [VT_BYREF|VT_DISPATCH, VT_VARIANT])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BSTR substringData
+ # retrieve substring of value
+ # I4 arg0 --- offset [IN]
+ # I4 arg1 --- count [IN]
+ def substringData(arg0, arg1)
+ ret = _invoke(111, [arg0, arg1], [VT_I4, VT_I4])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VOID appendData
+ # append string to value
+ # BSTR arg0 --- data [IN]
+ def appendData(arg0)
+ ret = _invoke(112, [arg0], [VT_BSTR])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VOID insertData
+ # insert string into value
+ # I4 arg0 --- offset [IN]
+ # BSTR arg1 --- data [IN]
+ def insertData(arg0, arg1)
+ ret = _invoke(113, [arg0, arg1], [VT_I4, VT_BSTR])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VOID deleteData
+ # delete string within the value
+ # I4 arg0 --- offset [IN]
+ # I4 arg1 --- count [IN]
+ def deleteData(arg0, arg1)
+ ret = _invoke(114, [arg0, arg1], [VT_I4, VT_I4])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VOID replaceData
+ # replace string within the value
+ # I4 arg0 --- offset [IN]
+ # I4 arg1 --- count [IN]
+ # BSTR arg2 --- data [IN]
+ def replaceData(arg0, arg1, arg2)
+ ret = _invoke(115, [arg0, arg1, arg2], [VT_I4, VT_I4, VT_BSTR])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMText splitText
+ # split the text node into two text nodes at the position specified
+ # I4 arg0 --- offset [IN]
+ def splitText(arg0)
+ ret = _invoke(123, [arg0], [VT_I4])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+end
+
+#
+module IXMLDOMProcessingInstruction
+ include WIN32OLE::VARIANT
+ attr_reader :lastargs
+
+ # BSTR nodeName
+ # name of the node
+ def nodeName()
+ ret = _getproperty(2, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VARIANT nodeValue
+ # value stored in the node
+ def nodeValue()
+ ret = _getproperty(3, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # DOMNodeType nodeType
+ # the node's type
+ def nodeType()
+ ret = _getproperty(4, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode parentNode
+ # parent of the node
+ def parentNode()
+ ret = _getproperty(6, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNodeList childNodes
+ # the collection of the node's children
+ def childNodes()
+ ret = _getproperty(7, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode firstChild
+ # first child of the node
+ def firstChild()
+ ret = _getproperty(8, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode lastChild
+ # first child of the node
+ def lastChild()
+ ret = _getproperty(9, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode previousSibling
+ # left sibling of the node
+ def previousSibling()
+ ret = _getproperty(10, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode nextSibling
+ # right sibling of the node
+ def nextSibling()
+ ret = _getproperty(11, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNamedNodeMap attributes
+ # the collection of the node's attributes
+ def attributes()
+ ret = _getproperty(12, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMDocument ownerDocument
+ # document that contains the node
+ def ownerDocument()
+ ret = _getproperty(18, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BSTR nodeTypeString
+ # the type of node in string form
+ def nodeTypeString()
+ ret = _getproperty(21, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BSTR text
+ # text content of the node and subtree
+ def text()
+ ret = _getproperty(24, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BOOL specified
+ # indicates whether node is a default value
+ def specified()
+ ret = _getproperty(22, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode definition
+ # pointer to the definition of the node in the DTD or schema
+ def definition()
+ ret = _getproperty(23, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VARIANT nodeTypedValue
+ # get the strongly typed value of the node
+ def nodeTypedValue()
+ ret = _getproperty(25, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VARIANT dataType
+ # the data type of the node
+ def dataType()
+ ret = _getproperty(26, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BSTR xml
+ # return the XML source for the node and each of its descendants
+ def xml()
+ ret = _getproperty(27, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BOOL parsed
+ # has sub-tree been completely parsed
+ def parsed()
+ ret = _getproperty(31, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BSTR namespaceURI
+ # the URI for the namespace applying to the node
+ def namespaceURI()
+ ret = _getproperty(32, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BSTR prefix
+ # the prefix for the namespace applying to the node
+ def prefix()
+ ret = _getproperty(33, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BSTR baseName
+ # the base name of the node (nodename with the prefix stripped off)
+ def baseName()
+ ret = _getproperty(34, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BSTR target
+ # the target
+ def target()
+ ret = _getproperty(127, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BSTR data
+ # the data
+ def data()
+ ret = _getproperty(128, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VOID nodeValue
+ # value stored in the node
+ def nodeValue=(arg0)
+ ret = _setproperty(3, [arg0], [VT_VARIANT])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VOID text
+ # text content of the node and subtree
+ def text=(arg0)
+ ret = _setproperty(24, [arg0], [VT_BSTR])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VOID nodeTypedValue
+ # get the strongly typed value of the node
+ def nodeTypedValue=(arg0)
+ ret = _setproperty(25, [arg0], [VT_VARIANT])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VOID dataType
+ # the data type of the node
+ def dataType=(arg0)
+ ret = _setproperty(26, [arg0], [VT_VARIANT])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VOID data
+ # the data
+ def data=(arg0)
+ ret = _setproperty(128, [arg0], [VT_BSTR])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode insertBefore
+ # insert a child node
+ # IXMLDOMNode arg0 --- newChild [IN]
+ # VARIANT arg1 --- refChild [IN]
+ def insertBefore(arg0, arg1)
+ ret = _invoke(13, [arg0, arg1], [VT_BYREF|VT_DISPATCH, VT_VARIANT])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode replaceChild
+ # replace a child node
+ # IXMLDOMNode arg0 --- newChild [IN]
+ # IXMLDOMNode arg1 --- oldChild [IN]
+ def replaceChild(arg0, arg1)
+ ret = _invoke(14, [arg0, arg1], [VT_BYREF|VT_DISPATCH, VT_BYREF|VT_DISPATCH])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode removeChild
+ # remove a child node
+ # IXMLDOMNode arg0 --- childNode [IN]
+ def removeChild(arg0)
+ ret = _invoke(15, [arg0], [VT_BYREF|VT_DISPATCH])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode appendChild
+ # append a child node
+ # IXMLDOMNode arg0 --- newChild [IN]
+ def appendChild(arg0)
+ ret = _invoke(16, [arg0], [VT_BYREF|VT_DISPATCH])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BOOL hasChildNodes
+ def hasChildNodes()
+ ret = _invoke(17, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode cloneNode
+ # BOOL arg0 --- deep [IN]
+ def cloneNode(arg0)
+ ret = _invoke(19, [arg0], [VT_BOOL])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BSTR transformNode
+ # apply the stylesheet to the subtree
+ # IXMLDOMNode arg0 --- stylesheet [IN]
+ def transformNode(arg0)
+ ret = _invoke(28, [arg0], [VT_BYREF|VT_DISPATCH])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNodeList selectNodes
+ # execute query on the subtree
+ # BSTR arg0 --- queryString [IN]
+ def selectNodes(arg0)
+ ret = _invoke(29, [arg0], [VT_BSTR])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode selectSingleNode
+ # execute query on the subtree
+ # BSTR arg0 --- queryString [IN]
+ def selectSingleNode(arg0)
+ ret = _invoke(30, [arg0], [VT_BSTR])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VOID transformNodeToObject
+ # apply the stylesheet to the subtree, returning the result through a document or a stream
+ # IXMLDOMNode arg0 --- stylesheet [IN]
+ # VARIANT arg1 --- outputObject [IN]
+ def transformNodeToObject(arg0, arg1)
+ ret = _invoke(35, [arg0, arg1], [VT_BYREF|VT_DISPATCH, VT_VARIANT])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+end
+
+#
+module IXMLDOMEntityReference
+ include WIN32OLE::VARIANT
+ attr_reader :lastargs
+
+ # BSTR nodeName
+ # name of the node
+ def nodeName()
+ ret = _getproperty(2, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VARIANT nodeValue
+ # value stored in the node
+ def nodeValue()
+ ret = _getproperty(3, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # DOMNodeType nodeType
+ # the node's type
+ def nodeType()
+ ret = _getproperty(4, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode parentNode
+ # parent of the node
+ def parentNode()
+ ret = _getproperty(6, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNodeList childNodes
+ # the collection of the node's children
+ def childNodes()
+ ret = _getproperty(7, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode firstChild
+ # first child of the node
+ def firstChild()
+ ret = _getproperty(8, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode lastChild
+ # first child of the node
+ def lastChild()
+ ret = _getproperty(9, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode previousSibling
+ # left sibling of the node
+ def previousSibling()
+ ret = _getproperty(10, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode nextSibling
+ # right sibling of the node
+ def nextSibling()
+ ret = _getproperty(11, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNamedNodeMap attributes
+ # the collection of the node's attributes
+ def attributes()
+ ret = _getproperty(12, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMDocument ownerDocument
+ # document that contains the node
+ def ownerDocument()
+ ret = _getproperty(18, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BSTR nodeTypeString
+ # the type of node in string form
+ def nodeTypeString()
+ ret = _getproperty(21, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BSTR text
+ # text content of the node and subtree
+ def text()
+ ret = _getproperty(24, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BOOL specified
+ # indicates whether node is a default value
+ def specified()
+ ret = _getproperty(22, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode definition
+ # pointer to the definition of the node in the DTD or schema
+ def definition()
+ ret = _getproperty(23, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VARIANT nodeTypedValue
+ # get the strongly typed value of the node
+ def nodeTypedValue()
+ ret = _getproperty(25, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VARIANT dataType
+ # the data type of the node
+ def dataType()
+ ret = _getproperty(26, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BSTR xml
+ # return the XML source for the node and each of its descendants
+ def xml()
+ ret = _getproperty(27, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BOOL parsed
+ # has sub-tree been completely parsed
+ def parsed()
+ ret = _getproperty(31, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BSTR namespaceURI
+ # the URI for the namespace applying to the node
+ def namespaceURI()
+ ret = _getproperty(32, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BSTR prefix
+ # the prefix for the namespace applying to the node
+ def prefix()
+ ret = _getproperty(33, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BSTR baseName
+ # the base name of the node (nodename with the prefix stripped off)
+ def baseName()
+ ret = _getproperty(34, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VOID nodeValue
+ # value stored in the node
+ def nodeValue=(arg0)
+ ret = _setproperty(3, [arg0], [VT_VARIANT])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VOID text
+ # text content of the node and subtree
+ def text=(arg0)
+ ret = _setproperty(24, [arg0], [VT_BSTR])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VOID nodeTypedValue
+ # get the strongly typed value of the node
+ def nodeTypedValue=(arg0)
+ ret = _setproperty(25, [arg0], [VT_VARIANT])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VOID dataType
+ # the data type of the node
+ def dataType=(arg0)
+ ret = _setproperty(26, [arg0], [VT_VARIANT])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode insertBefore
+ # insert a child node
+ # IXMLDOMNode arg0 --- newChild [IN]
+ # VARIANT arg1 --- refChild [IN]
+ def insertBefore(arg0, arg1)
+ ret = _invoke(13, [arg0, arg1], [VT_BYREF|VT_DISPATCH, VT_VARIANT])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode replaceChild
+ # replace a child node
+ # IXMLDOMNode arg0 --- newChild [IN]
+ # IXMLDOMNode arg1 --- oldChild [IN]
+ def replaceChild(arg0, arg1)
+ ret = _invoke(14, [arg0, arg1], [VT_BYREF|VT_DISPATCH, VT_BYREF|VT_DISPATCH])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode removeChild
+ # remove a child node
+ # IXMLDOMNode arg0 --- childNode [IN]
+ def removeChild(arg0)
+ ret = _invoke(15, [arg0], [VT_BYREF|VT_DISPATCH])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode appendChild
+ # append a child node
+ # IXMLDOMNode arg0 --- newChild [IN]
+ def appendChild(arg0)
+ ret = _invoke(16, [arg0], [VT_BYREF|VT_DISPATCH])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BOOL hasChildNodes
+ def hasChildNodes()
+ ret = _invoke(17, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode cloneNode
+ # BOOL arg0 --- deep [IN]
+ def cloneNode(arg0)
+ ret = _invoke(19, [arg0], [VT_BOOL])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BSTR transformNode
+ # apply the stylesheet to the subtree
+ # IXMLDOMNode arg0 --- stylesheet [IN]
+ def transformNode(arg0)
+ ret = _invoke(28, [arg0], [VT_BYREF|VT_DISPATCH])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNodeList selectNodes
+ # execute query on the subtree
+ # BSTR arg0 --- queryString [IN]
+ def selectNodes(arg0)
+ ret = _invoke(29, [arg0], [VT_BSTR])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode selectSingleNode
+ # execute query on the subtree
+ # BSTR arg0 --- queryString [IN]
+ def selectSingleNode(arg0)
+ ret = _invoke(30, [arg0], [VT_BSTR])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VOID transformNodeToObject
+ # apply the stylesheet to the subtree, returning the result through a document or a stream
+ # IXMLDOMNode arg0 --- stylesheet [IN]
+ # VARIANT arg1 --- outputObject [IN]
+ def transformNodeToObject(arg0, arg1)
+ ret = _invoke(35, [arg0, arg1], [VT_BYREF|VT_DISPATCH, VT_VARIANT])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+end
+
+# structure for reporting parser errors
+module IXMLDOMParseError
+ include WIN32OLE::VARIANT
+ attr_reader :lastargs
+
+ # I4 errorCode
+ # the error code
+ def errorCode()
+ ret = _getproperty(0, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BSTR url
+ # the URL of the XML document containing the error
+ def url()
+ ret = _getproperty(179, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BSTR reason
+ # the cause of the error
+ def reason()
+ ret = _getproperty(180, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BSTR srcText
+ # the data where the error occurred
+ def srcText()
+ ret = _getproperty(181, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # I4 line
+ # the line number in the XML document where the error occurred
+ def line()
+ ret = _getproperty(182, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # I4 linepos
+ # the character position in the line containing the error
+ def linepos()
+ ret = _getproperty(183, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # I4 filepos
+ # the absolute file position in the XML document containing the error
+ def filepos()
+ ret = _getproperty(184, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+end
+
+#
+module IXMLDOMNotation
+ include WIN32OLE::VARIANT
+ attr_reader :lastargs
+
+ # BSTR nodeName
+ # name of the node
+ def nodeName()
+ ret = _getproperty(2, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VARIANT nodeValue
+ # value stored in the node
+ def nodeValue()
+ ret = _getproperty(3, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # DOMNodeType nodeType
+ # the node's type
+ def nodeType()
+ ret = _getproperty(4, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode parentNode
+ # parent of the node
+ def parentNode()
+ ret = _getproperty(6, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNodeList childNodes
+ # the collection of the node's children
+ def childNodes()
+ ret = _getproperty(7, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode firstChild
+ # first child of the node
+ def firstChild()
+ ret = _getproperty(8, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode lastChild
+ # first child of the node
+ def lastChild()
+ ret = _getproperty(9, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode previousSibling
+ # left sibling of the node
+ def previousSibling()
+ ret = _getproperty(10, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode nextSibling
+ # right sibling of the node
+ def nextSibling()
+ ret = _getproperty(11, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNamedNodeMap attributes
+ # the collection of the node's attributes
+ def attributes()
+ ret = _getproperty(12, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMDocument ownerDocument
+ # document that contains the node
+ def ownerDocument()
+ ret = _getproperty(18, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BSTR nodeTypeString
+ # the type of node in string form
+ def nodeTypeString()
+ ret = _getproperty(21, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BSTR text
+ # text content of the node and subtree
+ def text()
+ ret = _getproperty(24, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BOOL specified
+ # indicates whether node is a default value
+ def specified()
+ ret = _getproperty(22, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode definition
+ # pointer to the definition of the node in the DTD or schema
+ def definition()
+ ret = _getproperty(23, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VARIANT nodeTypedValue
+ # get the strongly typed value of the node
+ def nodeTypedValue()
+ ret = _getproperty(25, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VARIANT dataType
+ # the data type of the node
+ def dataType()
+ ret = _getproperty(26, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BSTR xml
+ # return the XML source for the node and each of its descendants
+ def xml()
+ ret = _getproperty(27, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BOOL parsed
+ # has sub-tree been completely parsed
+ def parsed()
+ ret = _getproperty(31, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BSTR namespaceURI
+ # the URI for the namespace applying to the node
+ def namespaceURI()
+ ret = _getproperty(32, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BSTR prefix
+ # the prefix for the namespace applying to the node
+ def prefix()
+ ret = _getproperty(33, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BSTR baseName
+ # the base name of the node (nodename with the prefix stripped off)
+ def baseName()
+ ret = _getproperty(34, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VARIANT publicId
+ # the public ID
+ def publicId()
+ ret = _getproperty(136, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VARIANT systemId
+ # the system ID
+ def systemId()
+ ret = _getproperty(137, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VOID nodeValue
+ # value stored in the node
+ def nodeValue=(arg0)
+ ret = _setproperty(3, [arg0], [VT_VARIANT])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VOID text
+ # text content of the node and subtree
+ def text=(arg0)
+ ret = _setproperty(24, [arg0], [VT_BSTR])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VOID nodeTypedValue
+ # get the strongly typed value of the node
+ def nodeTypedValue=(arg0)
+ ret = _setproperty(25, [arg0], [VT_VARIANT])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VOID dataType
+ # the data type of the node
+ def dataType=(arg0)
+ ret = _setproperty(26, [arg0], [VT_VARIANT])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode insertBefore
+ # insert a child node
+ # IXMLDOMNode arg0 --- newChild [IN]
+ # VARIANT arg1 --- refChild [IN]
+ def insertBefore(arg0, arg1)
+ ret = _invoke(13, [arg0, arg1], [VT_BYREF|VT_DISPATCH, VT_VARIANT])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode replaceChild
+ # replace a child node
+ # IXMLDOMNode arg0 --- newChild [IN]
+ # IXMLDOMNode arg1 --- oldChild [IN]
+ def replaceChild(arg0, arg1)
+ ret = _invoke(14, [arg0, arg1], [VT_BYREF|VT_DISPATCH, VT_BYREF|VT_DISPATCH])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode removeChild
+ # remove a child node
+ # IXMLDOMNode arg0 --- childNode [IN]
+ def removeChild(arg0)
+ ret = _invoke(15, [arg0], [VT_BYREF|VT_DISPATCH])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode appendChild
+ # append a child node
+ # IXMLDOMNode arg0 --- newChild [IN]
+ def appendChild(arg0)
+ ret = _invoke(16, [arg0], [VT_BYREF|VT_DISPATCH])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BOOL hasChildNodes
+ def hasChildNodes()
+ ret = _invoke(17, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode cloneNode
+ # BOOL arg0 --- deep [IN]
+ def cloneNode(arg0)
+ ret = _invoke(19, [arg0], [VT_BOOL])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BSTR transformNode
+ # apply the stylesheet to the subtree
+ # IXMLDOMNode arg0 --- stylesheet [IN]
+ def transformNode(arg0)
+ ret = _invoke(28, [arg0], [VT_BYREF|VT_DISPATCH])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNodeList selectNodes
+ # execute query on the subtree
+ # BSTR arg0 --- queryString [IN]
+ def selectNodes(arg0)
+ ret = _invoke(29, [arg0], [VT_BSTR])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode selectSingleNode
+ # execute query on the subtree
+ # BSTR arg0 --- queryString [IN]
+ def selectSingleNode(arg0)
+ ret = _invoke(30, [arg0], [VT_BSTR])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VOID transformNodeToObject
+ # apply the stylesheet to the subtree, returning the result through a document or a stream
+ # IXMLDOMNode arg0 --- stylesheet [IN]
+ # VARIANT arg1 --- outputObject [IN]
+ def transformNodeToObject(arg0, arg1)
+ ret = _invoke(35, [arg0, arg1], [VT_BYREF|VT_DISPATCH, VT_VARIANT])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+end
+
+#
+module IXMLDOMEntity
+ include WIN32OLE::VARIANT
+ attr_reader :lastargs
+
+ # BSTR nodeName
+ # name of the node
+ def nodeName()
+ ret = _getproperty(2, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VARIANT nodeValue
+ # value stored in the node
+ def nodeValue()
+ ret = _getproperty(3, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # DOMNodeType nodeType
+ # the node's type
+ def nodeType()
+ ret = _getproperty(4, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode parentNode
+ # parent of the node
+ def parentNode()
+ ret = _getproperty(6, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNodeList childNodes
+ # the collection of the node's children
+ def childNodes()
+ ret = _getproperty(7, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode firstChild
+ # first child of the node
+ def firstChild()
+ ret = _getproperty(8, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode lastChild
+ # first child of the node
+ def lastChild()
+ ret = _getproperty(9, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode previousSibling
+ # left sibling of the node
+ def previousSibling()
+ ret = _getproperty(10, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode nextSibling
+ # right sibling of the node
+ def nextSibling()
+ ret = _getproperty(11, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNamedNodeMap attributes
+ # the collection of the node's attributes
+ def attributes()
+ ret = _getproperty(12, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMDocument ownerDocument
+ # document that contains the node
+ def ownerDocument()
+ ret = _getproperty(18, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BSTR nodeTypeString
+ # the type of node in string form
+ def nodeTypeString()
+ ret = _getproperty(21, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BSTR text
+ # text content of the node and subtree
+ def text()
+ ret = _getproperty(24, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BOOL specified
+ # indicates whether node is a default value
+ def specified()
+ ret = _getproperty(22, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode definition
+ # pointer to the definition of the node in the DTD or schema
+ def definition()
+ ret = _getproperty(23, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VARIANT nodeTypedValue
+ # get the strongly typed value of the node
+ def nodeTypedValue()
+ ret = _getproperty(25, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VARIANT dataType
+ # the data type of the node
+ def dataType()
+ ret = _getproperty(26, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BSTR xml
+ # return the XML source for the node and each of its descendants
+ def xml()
+ ret = _getproperty(27, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BOOL parsed
+ # has sub-tree been completely parsed
+ def parsed()
+ ret = _getproperty(31, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BSTR namespaceURI
+ # the URI for the namespace applying to the node
+ def namespaceURI()
+ ret = _getproperty(32, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BSTR prefix
+ # the prefix for the namespace applying to the node
+ def prefix()
+ ret = _getproperty(33, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BSTR baseName
+ # the base name of the node (nodename with the prefix stripped off)
+ def baseName()
+ ret = _getproperty(34, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VARIANT publicId
+ # the public ID
+ def publicId()
+ ret = _getproperty(140, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VARIANT systemId
+ # the system ID
+ def systemId()
+ ret = _getproperty(141, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BSTR notationName
+ # the name of the notation
+ def notationName()
+ ret = _getproperty(142, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VOID nodeValue
+ # value stored in the node
+ def nodeValue=(arg0)
+ ret = _setproperty(3, [arg0], [VT_VARIANT])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VOID text
+ # text content of the node and subtree
+ def text=(arg0)
+ ret = _setproperty(24, [arg0], [VT_BSTR])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VOID nodeTypedValue
+ # get the strongly typed value of the node
+ def nodeTypedValue=(arg0)
+ ret = _setproperty(25, [arg0], [VT_VARIANT])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VOID dataType
+ # the data type of the node
+ def dataType=(arg0)
+ ret = _setproperty(26, [arg0], [VT_VARIANT])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode insertBefore
+ # insert a child node
+ # IXMLDOMNode arg0 --- newChild [IN]
+ # VARIANT arg1 --- refChild [IN]
+ def insertBefore(arg0, arg1)
+ ret = _invoke(13, [arg0, arg1], [VT_BYREF|VT_DISPATCH, VT_VARIANT])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode replaceChild
+ # replace a child node
+ # IXMLDOMNode arg0 --- newChild [IN]
+ # IXMLDOMNode arg1 --- oldChild [IN]
+ def replaceChild(arg0, arg1)
+ ret = _invoke(14, [arg0, arg1], [VT_BYREF|VT_DISPATCH, VT_BYREF|VT_DISPATCH])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode removeChild
+ # remove a child node
+ # IXMLDOMNode arg0 --- childNode [IN]
+ def removeChild(arg0)
+ ret = _invoke(15, [arg0], [VT_BYREF|VT_DISPATCH])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode appendChild
+ # append a child node
+ # IXMLDOMNode arg0 --- newChild [IN]
+ def appendChild(arg0)
+ ret = _invoke(16, [arg0], [VT_BYREF|VT_DISPATCH])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BOOL hasChildNodes
+ def hasChildNodes()
+ ret = _invoke(17, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode cloneNode
+ # BOOL arg0 --- deep [IN]
+ def cloneNode(arg0)
+ ret = _invoke(19, [arg0], [VT_BOOL])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BSTR transformNode
+ # apply the stylesheet to the subtree
+ # IXMLDOMNode arg0 --- stylesheet [IN]
+ def transformNode(arg0)
+ ret = _invoke(28, [arg0], [VT_BYREF|VT_DISPATCH])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNodeList selectNodes
+ # execute query on the subtree
+ # BSTR arg0 --- queryString [IN]
+ def selectNodes(arg0)
+ ret = _invoke(29, [arg0], [VT_BSTR])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode selectSingleNode
+ # execute query on the subtree
+ # BSTR arg0 --- queryString [IN]
+ def selectSingleNode(arg0)
+ ret = _invoke(30, [arg0], [VT_BSTR])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VOID transformNodeToObject
+ # apply the stylesheet to the subtree, returning the result through a document or a stream
+ # IXMLDOMNode arg0 --- stylesheet [IN]
+ # VARIANT arg1 --- outputObject [IN]
+ def transformNodeToObject(arg0, arg1)
+ ret = _invoke(35, [arg0, arg1], [VT_BYREF|VT_DISPATCH, VT_VARIANT])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+end
+
+# XTL runtime object
+module IXTLRuntime
+ include WIN32OLE::VARIANT
+ attr_reader :lastargs
+
+ # BSTR nodeName
+ # name of the node
+ def nodeName()
+ ret = _getproperty(2, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VARIANT nodeValue
+ # value stored in the node
+ def nodeValue()
+ ret = _getproperty(3, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # DOMNodeType nodeType
+ # the node's type
+ def nodeType()
+ ret = _getproperty(4, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode parentNode
+ # parent of the node
+ def parentNode()
+ ret = _getproperty(6, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNodeList childNodes
+ # the collection of the node's children
+ def childNodes()
+ ret = _getproperty(7, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode firstChild
+ # first child of the node
+ def firstChild()
+ ret = _getproperty(8, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode lastChild
+ # first child of the node
+ def lastChild()
+ ret = _getproperty(9, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode previousSibling
+ # left sibling of the node
+ def previousSibling()
+ ret = _getproperty(10, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode nextSibling
+ # right sibling of the node
+ def nextSibling()
+ ret = _getproperty(11, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNamedNodeMap attributes
+ # the collection of the node's attributes
+ def attributes()
+ ret = _getproperty(12, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMDocument ownerDocument
+ # document that contains the node
+ def ownerDocument()
+ ret = _getproperty(18, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BSTR nodeTypeString
+ # the type of node in string form
+ def nodeTypeString()
+ ret = _getproperty(21, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BSTR text
+ # text content of the node and subtree
+ def text()
+ ret = _getproperty(24, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BOOL specified
+ # indicates whether node is a default value
+ def specified()
+ ret = _getproperty(22, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode definition
+ # pointer to the definition of the node in the DTD or schema
+ def definition()
+ ret = _getproperty(23, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VARIANT nodeTypedValue
+ # get the strongly typed value of the node
+ def nodeTypedValue()
+ ret = _getproperty(25, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VARIANT dataType
+ # the data type of the node
+ def dataType()
+ ret = _getproperty(26, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BSTR xml
+ # return the XML source for the node and each of its descendants
+ def xml()
+ ret = _getproperty(27, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BOOL parsed
+ # has sub-tree been completely parsed
+ def parsed()
+ ret = _getproperty(31, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BSTR namespaceURI
+ # the URI for the namespace applying to the node
+ def namespaceURI()
+ ret = _getproperty(32, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BSTR prefix
+ # the prefix for the namespace applying to the node
+ def prefix()
+ ret = _getproperty(33, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BSTR baseName
+ # the base name of the node (nodename with the prefix stripped off)
+ def baseName()
+ ret = _getproperty(34, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VOID nodeValue
+ # value stored in the node
+ def nodeValue=(arg0)
+ ret = _setproperty(3, [arg0], [VT_VARIANT])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VOID text
+ # text content of the node and subtree
+ def text=(arg0)
+ ret = _setproperty(24, [arg0], [VT_BSTR])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VOID nodeTypedValue
+ # get the strongly typed value of the node
+ def nodeTypedValue=(arg0)
+ ret = _setproperty(25, [arg0], [VT_VARIANT])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VOID dataType
+ # the data type of the node
+ def dataType=(arg0)
+ ret = _setproperty(26, [arg0], [VT_VARIANT])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode insertBefore
+ # insert a child node
+ # IXMLDOMNode arg0 --- newChild [IN]
+ # VARIANT arg1 --- refChild [IN]
+ def insertBefore(arg0, arg1)
+ ret = _invoke(13, [arg0, arg1], [VT_BYREF|VT_DISPATCH, VT_VARIANT])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode replaceChild
+ # replace a child node
+ # IXMLDOMNode arg0 --- newChild [IN]
+ # IXMLDOMNode arg1 --- oldChild [IN]
+ def replaceChild(arg0, arg1)
+ ret = _invoke(14, [arg0, arg1], [VT_BYREF|VT_DISPATCH, VT_BYREF|VT_DISPATCH])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode removeChild
+ # remove a child node
+ # IXMLDOMNode arg0 --- childNode [IN]
+ def removeChild(arg0)
+ ret = _invoke(15, [arg0], [VT_BYREF|VT_DISPATCH])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode appendChild
+ # append a child node
+ # IXMLDOMNode arg0 --- newChild [IN]
+ def appendChild(arg0)
+ ret = _invoke(16, [arg0], [VT_BYREF|VT_DISPATCH])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BOOL hasChildNodes
+ def hasChildNodes()
+ ret = _invoke(17, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode cloneNode
+ # BOOL arg0 --- deep [IN]
+ def cloneNode(arg0)
+ ret = _invoke(19, [arg0], [VT_BOOL])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BSTR transformNode
+ # apply the stylesheet to the subtree
+ # IXMLDOMNode arg0 --- stylesheet [IN]
+ def transformNode(arg0)
+ ret = _invoke(28, [arg0], [VT_BYREF|VT_DISPATCH])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNodeList selectNodes
+ # execute query on the subtree
+ # BSTR arg0 --- queryString [IN]
+ def selectNodes(arg0)
+ ret = _invoke(29, [arg0], [VT_BSTR])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode selectSingleNode
+ # execute query on the subtree
+ # BSTR arg0 --- queryString [IN]
+ def selectSingleNode(arg0)
+ ret = _invoke(30, [arg0], [VT_BSTR])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VOID transformNodeToObject
+ # apply the stylesheet to the subtree, returning the result through a document or a stream
+ # IXMLDOMNode arg0 --- stylesheet [IN]
+ # VARIANT arg1 --- outputObject [IN]
+ def transformNodeToObject(arg0, arg1)
+ ret = _invoke(35, [arg0, arg1], [VT_BYREF|VT_DISPATCH, VT_VARIANT])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # I4 uniqueID
+ # IXMLDOMNode arg0 --- pNode [IN]
+ def uniqueID(arg0)
+ ret = _invoke(187, [arg0], [VT_BYREF|VT_DISPATCH])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # I4 depth
+ # IXMLDOMNode arg0 --- pNode [IN]
+ def depth(arg0)
+ ret = _invoke(188, [arg0], [VT_BYREF|VT_DISPATCH])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # I4 childNumber
+ # IXMLDOMNode arg0 --- pNode [IN]
+ def childNumber(arg0)
+ ret = _invoke(189, [arg0], [VT_BYREF|VT_DISPATCH])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # I4 ancestorChildNumber
+ # BSTR arg0 --- bstrNodeName [IN]
+ # IXMLDOMNode arg1 --- pNode [IN]
+ def ancestorChildNumber(arg0, arg1)
+ ret = _invoke(190, [arg0, arg1], [VT_BSTR, VT_BYREF|VT_DISPATCH])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # I4 absoluteChildNumber
+ # IXMLDOMNode arg0 --- pNode [IN]
+ def absoluteChildNumber(arg0)
+ ret = _invoke(191, [arg0], [VT_BYREF|VT_DISPATCH])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BSTR formatIndex
+ # I4 arg0 --- lIndex [IN]
+ # BSTR arg1 --- bstrFormat [IN]
+ def formatIndex(arg0, arg1)
+ ret = _invoke(192, [arg0, arg1], [VT_I4, VT_BSTR])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BSTR formatNumber
+ # R8 arg0 --- dblNumber [IN]
+ # BSTR arg1 --- bstrFormat [IN]
+ def formatNumber(arg0, arg1)
+ ret = _invoke(193, [arg0, arg1], [VT_R8, VT_BSTR])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BSTR formatDate
+ # VARIANT arg0 --- varDate [IN]
+ # BSTR arg1 --- bstrFormat [IN]
+ # VARIANT arg2 --- varDestLocale [IN]
+ def formatDate(arg0, arg1, arg2=nil)
+ ret = _invoke(194, [arg0, arg1, arg2], [VT_VARIANT, VT_BSTR, VT_VARIANT])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BSTR formatTime
+ # VARIANT arg0 --- varTime [IN]
+ # BSTR arg1 --- bstrFormat [IN]
+ # VARIANT arg2 --- varDestLocale [IN]
+ def formatTime(arg0, arg1, arg2=nil)
+ ret = _invoke(195, [arg0, arg1, arg2], [VT_VARIANT, VT_BSTR, VT_VARIANT])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+end
+
+# W3C-DOM XML Document
+class Microsoft_XMLDOM_1_0 # DOMDocument
+ include WIN32OLE::VARIANT
+ attr_reader :lastargs
+ attr_reader :dispatch
+ attr_reader :clsid
+ attr_reader :progid
+
+ def initialize(obj = nil)
+ @clsid = "{2933BF90-7B36-11D2-B20E-00C04F983E60}"
+ @progid = "Microsoft.XMLDOM.1.0"
+ if obj.nil?
+ @dispatch = WIN32OLE.new(@progid)
+ else
+ @dispatch = obj
+ end
+ end
+
+ def method_missing(cmd, *arg)
+ @dispatch.method_missing(cmd, *arg)
+ end
+
+ # BSTR nodeName
+ # name of the node
+ def nodeName()
+ ret = @dispatch._getproperty(2, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VARIANT nodeValue
+ # value stored in the node
+ def nodeValue()
+ ret = @dispatch._getproperty(3, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # DOMNodeType nodeType
+ # the node's type
+ def nodeType()
+ ret = @dispatch._getproperty(4, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode parentNode
+ # parent of the node
+ def parentNode()
+ ret = @dispatch._getproperty(6, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNodeList childNodes
+ # the collection of the node's children
+ def childNodes()
+ ret = @dispatch._getproperty(7, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode firstChild
+ # first child of the node
+ def firstChild()
+ ret = @dispatch._getproperty(8, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode lastChild
+ # first child of the node
+ def lastChild()
+ ret = @dispatch._getproperty(9, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode previousSibling
+ # left sibling of the node
+ def previousSibling()
+ ret = @dispatch._getproperty(10, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode nextSibling
+ # right sibling of the node
+ def nextSibling()
+ ret = @dispatch._getproperty(11, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNamedNodeMap attributes
+ # the collection of the node's attributes
+ def attributes()
+ ret = @dispatch._getproperty(12, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMDocument ownerDocument
+ # document that contains the node
+ def ownerDocument()
+ ret = @dispatch._getproperty(18, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BSTR nodeTypeString
+ # the type of node in string form
+ def nodeTypeString()
+ ret = @dispatch._getproperty(21, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BSTR text
+ # text content of the node and subtree
+ def text()
+ ret = @dispatch._getproperty(24, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BOOL specified
+ # indicates whether node is a default value
+ def specified()
+ ret = @dispatch._getproperty(22, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode definition
+ # pointer to the definition of the node in the DTD or schema
+ def definition()
+ ret = @dispatch._getproperty(23, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VARIANT nodeTypedValue
+ # get the strongly typed value of the node
+ def nodeTypedValue()
+ ret = @dispatch._getproperty(25, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VARIANT dataType
+ # the data type of the node
+ def dataType()
+ ret = @dispatch._getproperty(26, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BSTR xml
+ # return the XML source for the node and each of its descendants
+ def xml()
+ ret = @dispatch._getproperty(27, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BOOL parsed
+ # has sub-tree been completely parsed
+ def parsed()
+ ret = @dispatch._getproperty(31, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BSTR namespaceURI
+ # the URI for the namespace applying to the node
+ def namespaceURI()
+ ret = @dispatch._getproperty(32, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BSTR prefix
+ # the prefix for the namespace applying to the node
+ def prefix()
+ ret = @dispatch._getproperty(33, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BSTR baseName
+ # the base name of the node (nodename with the prefix stripped off)
+ def baseName()
+ ret = @dispatch._getproperty(34, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMDocumentType doctype
+ # node corresponding to the DOCTYPE
+ def doctype()
+ ret = @dispatch._getproperty(38, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMImplementation implementation
+ # info on this DOM implementation
+ def implementation()
+ ret = @dispatch._getproperty(39, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMElement documentElement
+ # the root of the tree
+ def documentElement()
+ ret = @dispatch._getproperty(40, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # I4 readyState
+ # get the state of the XML document
+ def readyState()
+ ret = @dispatch._getproperty(-525, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMParseError parseError
+ # get the last parser error
+ def parseError()
+ ret = @dispatch._getproperty(59, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BSTR url
+ # get the URL for the loaded XML document
+ def url()
+ ret = @dispatch._getproperty(60, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BOOL async
+ # flag for asynchronous download
+ def async()
+ ret = @dispatch._getproperty(61, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BOOL validateOnParse
+ # indicates whether the parser performs validation
+ def validateOnParse()
+ ret = @dispatch._getproperty(65, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BOOL resolveExternals
+ # indicates whether the parser resolves references to external DTD/Entities/Schema
+ def resolveExternals()
+ ret = @dispatch._getproperty(66, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BOOL preserveWhiteSpace
+ # indicates whether the parser preserves whitespace
+ def preserveWhiteSpace()
+ ret = @dispatch._getproperty(67, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VOID nodeValue
+ # value stored in the node
+ def nodeValue=(arg0)
+ ret = @dispatch._setproperty(3, [arg0], [VT_VARIANT])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VOID text
+ # text content of the node and subtree
+ def text=(arg0)
+ ret = @dispatch._setproperty(24, [arg0], [VT_BSTR])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VOID nodeTypedValue
+ # get the strongly typed value of the node
+ def nodeTypedValue=(arg0)
+ ret = @dispatch._setproperty(25, [arg0], [VT_VARIANT])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VOID dataType
+ # the data type of the node
+ def dataType=(arg0)
+ ret = @dispatch._setproperty(26, [arg0], [VT_VARIANT])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VOID async
+ # flag for asynchronous download
+ def async=(arg0)
+ ret = @dispatch._setproperty(61, [arg0], [VT_BOOL])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VOID validateOnParse
+ # indicates whether the parser performs validation
+ def validateOnParse=(arg0)
+ ret = @dispatch._setproperty(65, [arg0], [VT_BOOL])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VOID resolveExternals
+ # indicates whether the parser resolves references to external DTD/Entities/Schema
+ def resolveExternals=(arg0)
+ ret = @dispatch._setproperty(66, [arg0], [VT_BOOL])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VOID preserveWhiteSpace
+ # indicates whether the parser preserves whitespace
+ def preserveWhiteSpace=(arg0)
+ ret = @dispatch._setproperty(67, [arg0], [VT_BOOL])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VOID onreadystatechange
+ # register a readystatechange event handler
+ def onreadystatechange=(arg0)
+ ret = @dispatch._setproperty(68, [arg0], [VT_VARIANT])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VOID ondataavailable
+ # register an ondataavailable event handler
+ def ondataavailable=(arg0)
+ ret = @dispatch._setproperty(69, [arg0], [VT_VARIANT])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VOID ontransformnode
+ # register an ontransformnode event handler
+ def ontransformnode=(arg0)
+ ret = @dispatch._setproperty(70, [arg0], [VT_VARIANT])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode insertBefore
+ # insert a child node
+ # IXMLDOMNode arg0 --- newChild [IN]
+ # VARIANT arg1 --- refChild [IN]
+ def insertBefore(arg0, arg1)
+ ret = @dispatch._invoke(13, [arg0, arg1], [VT_BYREF|VT_DISPATCH, VT_VARIANT])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode replaceChild
+ # replace a child node
+ # IXMLDOMNode arg0 --- newChild [IN]
+ # IXMLDOMNode arg1 --- oldChild [IN]
+ def replaceChild(arg0, arg1)
+ ret = @dispatch._invoke(14, [arg0, arg1], [VT_BYREF|VT_DISPATCH, VT_BYREF|VT_DISPATCH])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode removeChild
+ # remove a child node
+ # IXMLDOMNode arg0 --- childNode [IN]
+ def removeChild(arg0)
+ ret = @dispatch._invoke(15, [arg0], [VT_BYREF|VT_DISPATCH])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode appendChild
+ # append a child node
+ # IXMLDOMNode arg0 --- newChild [IN]
+ def appendChild(arg0)
+ ret = @dispatch._invoke(16, [arg0], [VT_BYREF|VT_DISPATCH])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BOOL hasChildNodes
+ def hasChildNodes()
+ ret = @dispatch._invoke(17, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode cloneNode
+ # BOOL arg0 --- deep [IN]
+ def cloneNode(arg0)
+ ret = @dispatch._invoke(19, [arg0], [VT_BOOL])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BSTR transformNode
+ # apply the stylesheet to the subtree
+ # IXMLDOMNode arg0 --- stylesheet [IN]
+ def transformNode(arg0)
+ ret = @dispatch._invoke(28, [arg0], [VT_BYREF|VT_DISPATCH])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNodeList selectNodes
+ # execute query on the subtree
+ # BSTR arg0 --- queryString [IN]
+ def selectNodes(arg0)
+ ret = @dispatch._invoke(29, [arg0], [VT_BSTR])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode selectSingleNode
+ # execute query on the subtree
+ # BSTR arg0 --- queryString [IN]
+ def selectSingleNode(arg0)
+ ret = @dispatch._invoke(30, [arg0], [VT_BSTR])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VOID transformNodeToObject
+ # apply the stylesheet to the subtree, returning the result through a document or a stream
+ # IXMLDOMNode arg0 --- stylesheet [IN]
+ # VARIANT arg1 --- outputObject [IN]
+ def transformNodeToObject(arg0, arg1)
+ ret = @dispatch._invoke(35, [arg0, arg1], [VT_BYREF|VT_DISPATCH, VT_VARIANT])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMElement createElement
+ # create an Element node
+ # BSTR arg0 --- tagName [IN]
+ def createElement(arg0)
+ ret = @dispatch._invoke(41, [arg0], [VT_BSTR])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMDocumentFragment createDocumentFragment
+ # create a DocumentFragment node
+ def createDocumentFragment()
+ ret = @dispatch._invoke(42, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMText createTextNode
+ # create a text node
+ # BSTR arg0 --- data [IN]
+ def createTextNode(arg0)
+ ret = @dispatch._invoke(43, [arg0], [VT_BSTR])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMComment createComment
+ # create a comment node
+ # BSTR arg0 --- data [IN]
+ def createComment(arg0)
+ ret = @dispatch._invoke(44, [arg0], [VT_BSTR])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMCDATASection createCDATASection
+ # create a CDATA section node
+ # BSTR arg0 --- data [IN]
+ def createCDATASection(arg0)
+ ret = @dispatch._invoke(45, [arg0], [VT_BSTR])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMProcessingInstruction createProcessingInstruction
+ # create a processing instruction node
+ # BSTR arg0 --- target [IN]
+ # BSTR arg1 --- data [IN]
+ def createProcessingInstruction(arg0, arg1)
+ ret = @dispatch._invoke(46, [arg0, arg1], [VT_BSTR, VT_BSTR])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMAttribute createAttribute
+ # create an attribute node
+ # BSTR arg0 --- name [IN]
+ def createAttribute(arg0)
+ ret = @dispatch._invoke(47, [arg0], [VT_BSTR])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMEntityReference createEntityReference
+ # create an entity reference node
+ # BSTR arg0 --- name [IN]
+ def createEntityReference(arg0)
+ ret = @dispatch._invoke(49, [arg0], [VT_BSTR])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNodeList getElementsByTagName
+ # build a list of elements by name
+ # BSTR arg0 --- tagName [IN]
+ def getElementsByTagName(arg0)
+ ret = @dispatch._invoke(50, [arg0], [VT_BSTR])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode createNode
+ # create a node of the specified node type and name
+ # VARIANT arg0 --- type [IN]
+ # BSTR arg1 --- name [IN]
+ # BSTR arg2 --- namespaceURI [IN]
+ def createNode(arg0, arg1, arg2)
+ ret = @dispatch._invoke(54, [arg0, arg1, arg2], [VT_VARIANT, VT_BSTR, VT_BSTR])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode nodeFromID
+ # retrieve node from it's ID
+ # BSTR arg0 --- idString [IN]
+ def nodeFromID(arg0)
+ ret = @dispatch._invoke(56, [arg0], [VT_BSTR])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BOOL load
+ # load document from the specified XML source
+ # VARIANT arg0 --- xmlSource [IN]
+ def load(arg0)
+ ret = @dispatch._invoke(58, [arg0], [VT_VARIANT])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VOID abort
+ # abort an asynchronous download
+ def abort()
+ ret = @dispatch._invoke(62, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BOOL loadXML
+ # load the document from a string
+ # BSTR arg0 --- bstrXML [IN]
+ def loadXML(arg0)
+ ret = @dispatch._invoke(63, [arg0], [VT_BSTR])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VOID save
+ # save the document to a specified desination
+ # VARIANT arg0 --- desination [IN]
+ def save(arg0)
+ ret = @dispatch._invoke(64, [arg0], [VT_VARIANT])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # HRESULT ondataavailable EVENT in XMLDOMDocumentEvents
+ def ondataavailable()
+ ret = @dispatch._invoke(198, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # HRESULT onreadystatechange EVENT in XMLDOMDocumentEvents
+ def onreadystatechange()
+ ret = @dispatch._invoke(-609, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+end
+
+# W3C-DOM XML Document (Apartment)
+class Microsoft_FreeThreadedXMLDOM_1_0 # DOMFreeThreadedDocument
+ include WIN32OLE::VARIANT
+ attr_reader :lastargs
+ attr_reader :dispatch
+ attr_reader :clsid
+ attr_reader :progid
+
+ def initialize(obj = nil)
+ @clsid = "{2933BF91-7B36-11D2-B20E-00C04F983E60}"
+ @progid = "Microsoft.FreeThreadedXMLDOM.1.0"
+ if obj.nil?
+ @dispatch = WIN32OLE.new(@progid)
+ else
+ @dispatch = obj
+ end
+ end
+
+ def method_missing(cmd, *arg)
+ @dispatch.method_missing(cmd, *arg)
+ end
+
+ # BSTR nodeName
+ # name of the node
+ def nodeName()
+ ret = @dispatch._getproperty(2, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VARIANT nodeValue
+ # value stored in the node
+ def nodeValue()
+ ret = @dispatch._getproperty(3, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # DOMNodeType nodeType
+ # the node's type
+ def nodeType()
+ ret = @dispatch._getproperty(4, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode parentNode
+ # parent of the node
+ def parentNode()
+ ret = @dispatch._getproperty(6, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNodeList childNodes
+ # the collection of the node's children
+ def childNodes()
+ ret = @dispatch._getproperty(7, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode firstChild
+ # first child of the node
+ def firstChild()
+ ret = @dispatch._getproperty(8, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode lastChild
+ # first child of the node
+ def lastChild()
+ ret = @dispatch._getproperty(9, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode previousSibling
+ # left sibling of the node
+ def previousSibling()
+ ret = @dispatch._getproperty(10, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode nextSibling
+ # right sibling of the node
+ def nextSibling()
+ ret = @dispatch._getproperty(11, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNamedNodeMap attributes
+ # the collection of the node's attributes
+ def attributes()
+ ret = @dispatch._getproperty(12, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMDocument ownerDocument
+ # document that contains the node
+ def ownerDocument()
+ ret = @dispatch._getproperty(18, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BSTR nodeTypeString
+ # the type of node in string form
+ def nodeTypeString()
+ ret = @dispatch._getproperty(21, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BSTR text
+ # text content of the node and subtree
+ def text()
+ ret = @dispatch._getproperty(24, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BOOL specified
+ # indicates whether node is a default value
+ def specified()
+ ret = @dispatch._getproperty(22, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode definition
+ # pointer to the definition of the node in the DTD or schema
+ def definition()
+ ret = @dispatch._getproperty(23, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VARIANT nodeTypedValue
+ # get the strongly typed value of the node
+ def nodeTypedValue()
+ ret = @dispatch._getproperty(25, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VARIANT dataType
+ # the data type of the node
+ def dataType()
+ ret = @dispatch._getproperty(26, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BSTR xml
+ # return the XML source for the node and each of its descendants
+ def xml()
+ ret = @dispatch._getproperty(27, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BOOL parsed
+ # has sub-tree been completely parsed
+ def parsed()
+ ret = @dispatch._getproperty(31, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BSTR namespaceURI
+ # the URI for the namespace applying to the node
+ def namespaceURI()
+ ret = @dispatch._getproperty(32, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BSTR prefix
+ # the prefix for the namespace applying to the node
+ def prefix()
+ ret = @dispatch._getproperty(33, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BSTR baseName
+ # the base name of the node (nodename with the prefix stripped off)
+ def baseName()
+ ret = @dispatch._getproperty(34, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMDocumentType doctype
+ # node corresponding to the DOCTYPE
+ def doctype()
+ ret = @dispatch._getproperty(38, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMImplementation implementation
+ # info on this DOM implementation
+ def implementation()
+ ret = @dispatch._getproperty(39, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMElement documentElement
+ # the root of the tree
+ def documentElement()
+ ret = @dispatch._getproperty(40, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # I4 readyState
+ # get the state of the XML document
+ def readyState()
+ ret = @dispatch._getproperty(-525, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMParseError parseError
+ # get the last parser error
+ def parseError()
+ ret = @dispatch._getproperty(59, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BSTR url
+ # get the URL for the loaded XML document
+ def url()
+ ret = @dispatch._getproperty(60, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BOOL async
+ # flag for asynchronous download
+ def async()
+ ret = @dispatch._getproperty(61, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BOOL validateOnParse
+ # indicates whether the parser performs validation
+ def validateOnParse()
+ ret = @dispatch._getproperty(65, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BOOL resolveExternals
+ # indicates whether the parser resolves references to external DTD/Entities/Schema
+ def resolveExternals()
+ ret = @dispatch._getproperty(66, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BOOL preserveWhiteSpace
+ # indicates whether the parser preserves whitespace
+ def preserveWhiteSpace()
+ ret = @dispatch._getproperty(67, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VOID nodeValue
+ # value stored in the node
+ def nodeValue=(arg0)
+ ret = @dispatch._setproperty(3, [arg0], [VT_VARIANT])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VOID text
+ # text content of the node and subtree
+ def text=(arg0)
+ ret = @dispatch._setproperty(24, [arg0], [VT_BSTR])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VOID nodeTypedValue
+ # get the strongly typed value of the node
+ def nodeTypedValue=(arg0)
+ ret = @dispatch._setproperty(25, [arg0], [VT_VARIANT])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VOID dataType
+ # the data type of the node
+ def dataType=(arg0)
+ ret = @dispatch._setproperty(26, [arg0], [VT_VARIANT])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VOID async
+ # flag for asynchronous download
+ def async=(arg0)
+ ret = @dispatch._setproperty(61, [arg0], [VT_BOOL])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VOID validateOnParse
+ # indicates whether the parser performs validation
+ def validateOnParse=(arg0)
+ ret = @dispatch._setproperty(65, [arg0], [VT_BOOL])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VOID resolveExternals
+ # indicates whether the parser resolves references to external DTD/Entities/Schema
+ def resolveExternals=(arg0)
+ ret = @dispatch._setproperty(66, [arg0], [VT_BOOL])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VOID preserveWhiteSpace
+ # indicates whether the parser preserves whitespace
+ def preserveWhiteSpace=(arg0)
+ ret = @dispatch._setproperty(67, [arg0], [VT_BOOL])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VOID onreadystatechange
+ # register a readystatechange event handler
+ def onreadystatechange=(arg0)
+ ret = @dispatch._setproperty(68, [arg0], [VT_VARIANT])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VOID ondataavailable
+ # register an ondataavailable event handler
+ def ondataavailable=(arg0)
+ ret = @dispatch._setproperty(69, [arg0], [VT_VARIANT])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VOID ontransformnode
+ # register an ontransformnode event handler
+ def ontransformnode=(arg0)
+ ret = @dispatch._setproperty(70, [arg0], [VT_VARIANT])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode insertBefore
+ # insert a child node
+ # IXMLDOMNode arg0 --- newChild [IN]
+ # VARIANT arg1 --- refChild [IN]
+ def insertBefore(arg0, arg1)
+ ret = @dispatch._invoke(13, [arg0, arg1], [VT_BYREF|VT_DISPATCH, VT_VARIANT])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode replaceChild
+ # replace a child node
+ # IXMLDOMNode arg0 --- newChild [IN]
+ # IXMLDOMNode arg1 --- oldChild [IN]
+ def replaceChild(arg0, arg1)
+ ret = @dispatch._invoke(14, [arg0, arg1], [VT_BYREF|VT_DISPATCH, VT_BYREF|VT_DISPATCH])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode removeChild
+ # remove a child node
+ # IXMLDOMNode arg0 --- childNode [IN]
+ def removeChild(arg0)
+ ret = @dispatch._invoke(15, [arg0], [VT_BYREF|VT_DISPATCH])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode appendChild
+ # append a child node
+ # IXMLDOMNode arg0 --- newChild [IN]
+ def appendChild(arg0)
+ ret = @dispatch._invoke(16, [arg0], [VT_BYREF|VT_DISPATCH])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BOOL hasChildNodes
+ def hasChildNodes()
+ ret = @dispatch._invoke(17, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode cloneNode
+ # BOOL arg0 --- deep [IN]
+ def cloneNode(arg0)
+ ret = @dispatch._invoke(19, [arg0], [VT_BOOL])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BSTR transformNode
+ # apply the stylesheet to the subtree
+ # IXMLDOMNode arg0 --- stylesheet [IN]
+ def transformNode(arg0)
+ ret = @dispatch._invoke(28, [arg0], [VT_BYREF|VT_DISPATCH])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNodeList selectNodes
+ # execute query on the subtree
+ # BSTR arg0 --- queryString [IN]
+ def selectNodes(arg0)
+ ret = @dispatch._invoke(29, [arg0], [VT_BSTR])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode selectSingleNode
+ # execute query on the subtree
+ # BSTR arg0 --- queryString [IN]
+ def selectSingleNode(arg0)
+ ret = @dispatch._invoke(30, [arg0], [VT_BSTR])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VOID transformNodeToObject
+ # apply the stylesheet to the subtree, returning the result through a document or a stream
+ # IXMLDOMNode arg0 --- stylesheet [IN]
+ # VARIANT arg1 --- outputObject [IN]
+ def transformNodeToObject(arg0, arg1)
+ ret = @dispatch._invoke(35, [arg0, arg1], [VT_BYREF|VT_DISPATCH, VT_VARIANT])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMElement createElement
+ # create an Element node
+ # BSTR arg0 --- tagName [IN]
+ def createElement(arg0)
+ ret = @dispatch._invoke(41, [arg0], [VT_BSTR])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMDocumentFragment createDocumentFragment
+ # create a DocumentFragment node
+ def createDocumentFragment()
+ ret = @dispatch._invoke(42, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMText createTextNode
+ # create a text node
+ # BSTR arg0 --- data [IN]
+ def createTextNode(arg0)
+ ret = @dispatch._invoke(43, [arg0], [VT_BSTR])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMComment createComment
+ # create a comment node
+ # BSTR arg0 --- data [IN]
+ def createComment(arg0)
+ ret = @dispatch._invoke(44, [arg0], [VT_BSTR])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMCDATASection createCDATASection
+ # create a CDATA section node
+ # BSTR arg0 --- data [IN]
+ def createCDATASection(arg0)
+ ret = @dispatch._invoke(45, [arg0], [VT_BSTR])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMProcessingInstruction createProcessingInstruction
+ # create a processing instruction node
+ # BSTR arg0 --- target [IN]
+ # BSTR arg1 --- data [IN]
+ def createProcessingInstruction(arg0, arg1)
+ ret = @dispatch._invoke(46, [arg0, arg1], [VT_BSTR, VT_BSTR])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMAttribute createAttribute
+ # create an attribute node
+ # BSTR arg0 --- name [IN]
+ def createAttribute(arg0)
+ ret = @dispatch._invoke(47, [arg0], [VT_BSTR])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMEntityReference createEntityReference
+ # create an entity reference node
+ # BSTR arg0 --- name [IN]
+ def createEntityReference(arg0)
+ ret = @dispatch._invoke(49, [arg0], [VT_BSTR])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNodeList getElementsByTagName
+ # build a list of elements by name
+ # BSTR arg0 --- tagName [IN]
+ def getElementsByTagName(arg0)
+ ret = @dispatch._invoke(50, [arg0], [VT_BSTR])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode createNode
+ # create a node of the specified node type and name
+ # VARIANT arg0 --- type [IN]
+ # BSTR arg1 --- name [IN]
+ # BSTR arg2 --- namespaceURI [IN]
+ def createNode(arg0, arg1, arg2)
+ ret = @dispatch._invoke(54, [arg0, arg1, arg2], [VT_VARIANT, VT_BSTR, VT_BSTR])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # IXMLDOMNode nodeFromID
+ # retrieve node from it's ID
+ # BSTR arg0 --- idString [IN]
+ def nodeFromID(arg0)
+ ret = @dispatch._invoke(56, [arg0], [VT_BSTR])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BOOL load
+ # load document from the specified XML source
+ # VARIANT arg0 --- xmlSource [IN]
+ def load(arg0)
+ ret = @dispatch._invoke(58, [arg0], [VT_VARIANT])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VOID abort
+ # abort an asynchronous download
+ def abort()
+ ret = @dispatch._invoke(62, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BOOL loadXML
+ # load the document from a string
+ # BSTR arg0 --- bstrXML [IN]
+ def loadXML(arg0)
+ ret = @dispatch._invoke(63, [arg0], [VT_BSTR])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VOID save
+ # save the document to a specified desination
+ # VARIANT arg0 --- desination [IN]
+ def save(arg0)
+ ret = @dispatch._invoke(64, [arg0], [VT_VARIANT])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # HRESULT ondataavailable EVENT in XMLDOMDocumentEvents
+ def ondataavailable()
+ ret = @dispatch._invoke(198, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # HRESULT onreadystatechange EVENT in XMLDOMDocumentEvents
+ def onreadystatechange()
+ ret = @dispatch._invoke(-609, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+end
+
+# IXMLHttpRequest Interface
+module IXMLHttpRequest
+ include WIN32OLE::VARIANT
+ attr_reader :lastargs
+
+ # I4 status
+ # Get HTTP status code
+ def status()
+ ret = _getproperty(7, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BSTR statusText
+ # Get HTTP status text
+ def statusText()
+ ret = _getproperty(8, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # DISPATCH responseXML
+ # Get response body
+ def responseXML()
+ ret = _getproperty(9, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BSTR responseText
+ # Get response body
+ def responseText()
+ ret = _getproperty(10, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VARIANT responseBody
+ # Get response body
+ def responseBody()
+ ret = _getproperty(11, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VARIANT responseStream
+ # Get response body
+ def responseStream()
+ ret = _getproperty(12, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # I4 readyState
+ # Get ready state
+ def readyState()
+ ret = _getproperty(13, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VOID onreadystatechange
+ # Register a complete event handler
+ def onreadystatechange=(arg0)
+ ret = _setproperty(14, [arg0], [VT_VARIANT])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VOID open
+ # Open HTTP connection
+ # BSTR arg0 --- bstrMethod [IN]
+ # BSTR arg1 --- bstrUrl [IN]
+ # VARIANT arg2 --- varAsync [IN]
+ # VARIANT arg3 --- bstrUser [IN]
+ # VARIANT arg4 --- bstrPassword [IN]
+ def open(arg0, arg1, arg2=nil, arg3=nil, arg4=nil)
+ ret = _invoke(1, [arg0, arg1, arg2, arg3, arg4], [VT_BSTR, VT_BSTR, VT_VARIANT, VT_VARIANT, VT_VARIANT])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VOID setRequestHeader
+ # Add HTTP request header
+ # BSTR arg0 --- bstrHeader [IN]
+ # BSTR arg1 --- bstrValue [IN]
+ def setRequestHeader(arg0, arg1)
+ ret = _invoke(2, [arg0, arg1], [VT_BSTR, VT_BSTR])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BSTR getResponseHeader
+ # Get HTTP response header
+ # BSTR arg0 --- bstrHeader [IN]
+ def getResponseHeader(arg0)
+ ret = _invoke(3, [arg0], [VT_BSTR])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BSTR getAllResponseHeaders
+ # Get all HTTP response headers
+ def getAllResponseHeaders()
+ ret = _invoke(4, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VOID send
+ # Send HTTP request
+ # VARIANT arg0 --- varBody [IN]
+ def send(arg0=nil)
+ ret = _invoke(5, [arg0], [VT_VARIANT])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VOID abort
+ # Abort HTTP request
+ def abort()
+ ret = _invoke(6, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+end
+
+# XML HTTP Request class.
+class Microsoft_XMLHTTP_1 # XMLHTTPRequest
+ include WIN32OLE::VARIANT
+ attr_reader :lastargs
+ attr_reader :dispatch
+ attr_reader :clsid
+ attr_reader :progid
+
+ def initialize(obj = nil)
+ @clsid = "{ED8C108E-4349-11D2-91A4-00C04F7969E8}"
+ @progid = "Microsoft.XMLHTTP.1"
+ if obj.nil?
+ @dispatch = WIN32OLE.new(@progid)
+ else
+ @dispatch = obj
+ end
+ end
+
+ def method_missing(cmd, *arg)
+ @dispatch.method_missing(cmd, *arg)
+ end
+
+ # I4 status
+ # Get HTTP status code
+ def status()
+ ret = @dispatch._getproperty(7, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BSTR statusText
+ # Get HTTP status text
+ def statusText()
+ ret = @dispatch._getproperty(8, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # DISPATCH responseXML
+ # Get response body
+ def responseXML()
+ ret = @dispatch._getproperty(9, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BSTR responseText
+ # Get response body
+ def responseText()
+ ret = @dispatch._getproperty(10, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VARIANT responseBody
+ # Get response body
+ def responseBody()
+ ret = @dispatch._getproperty(11, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VARIANT responseStream
+ # Get response body
+ def responseStream()
+ ret = @dispatch._getproperty(12, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # I4 readyState
+ # Get ready state
+ def readyState()
+ ret = @dispatch._getproperty(13, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VOID onreadystatechange
+ # Register a complete event handler
+ def onreadystatechange=(arg0)
+ ret = @dispatch._setproperty(14, [arg0], [VT_VARIANT])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VOID open
+ # Open HTTP connection
+ # BSTR arg0 --- bstrMethod [IN]
+ # BSTR arg1 --- bstrUrl [IN]
+ # VARIANT arg2 --- varAsync [IN]
+ # VARIANT arg3 --- bstrUser [IN]
+ # VARIANT arg4 --- bstrPassword [IN]
+ def open(arg0, arg1, arg2=nil, arg3=nil, arg4=nil)
+ ret = @dispatch._invoke(1, [arg0, arg1, arg2, arg3, arg4], [VT_BSTR, VT_BSTR, VT_VARIANT, VT_VARIANT, VT_VARIANT])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VOID setRequestHeader
+ # Add HTTP request header
+ # BSTR arg0 --- bstrHeader [IN]
+ # BSTR arg1 --- bstrValue [IN]
+ def setRequestHeader(arg0, arg1)
+ ret = @dispatch._invoke(2, [arg0, arg1], [VT_BSTR, VT_BSTR])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BSTR getResponseHeader
+ # Get HTTP response header
+ # BSTR arg0 --- bstrHeader [IN]
+ def getResponseHeader(arg0)
+ ret = @dispatch._invoke(3, [arg0], [VT_BSTR])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # BSTR getAllResponseHeaders
+ # Get all HTTP response headers
+ def getAllResponseHeaders()
+ ret = @dispatch._invoke(4, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VOID send
+ # Send HTTP request
+ # VARIANT arg0 --- varBody [IN]
+ def send(arg0=nil)
+ ret = @dispatch._invoke(5, [arg0], [VT_VARIANT])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VOID abort
+ # Abort HTTP request
+ def abort()
+ ret = @dispatch._invoke(6, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+end
+
+# XML Data Source Object
+class Microsoft_XMLDSO_1_0 # XMLDSOControl
+ include WIN32OLE::VARIANT
+ attr_reader :lastargs
+ attr_reader :dispatch
+ attr_reader :clsid
+ attr_reader :progid
+
+ def initialize(obj = nil)
+ @clsid = "{550DDA30-0541-11D2-9CA9-0060B0EC3D39}"
+ @progid = "Microsoft.XMLDSO.1.0"
+ if obj.nil?
+ @dispatch = WIN32OLE.new(@progid)
+ else
+ @dispatch = obj
+ end
+ end
+
+ def method_missing(cmd, *arg)
+ @dispatch.method_missing(cmd, *arg)
+ end
+
+ # IXMLDOMDocument XMLDocument
+ def XMLDocument()
+ ret = @dispatch._getproperty(65537, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # I4 JavaDSOCompatible
+ def JavaDSOCompatible()
+ ret = @dispatch._getproperty(65538, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # I4 readyState
+ def readyState()
+ ret = @dispatch._getproperty(-525, [], [])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VOID XMLDocument
+ def XMLDocument=(arg0)
+ ret = @dispatch._setproperty(65537, [arg0], [VT_BYREF|VT_DISPATCH])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # VOID JavaDSOCompatible
+ def JavaDSOCompatible=(arg0)
+ ret = @dispatch._setproperty(65538, [arg0], [VT_I4])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+end
+
+# Constants that define types for IXMLElement.
+module OLEtagXMLEMEM_TYPE
+ include WIN32OLE::VARIANT
+ attr_reader :lastargs
+ XMLELEMTYPE_ELEMENT = 0
+ XMLELEMTYPE_TEXT = 1
+ XMLELEMTYPE_COMMENT = 2
+ XMLELEMTYPE_DOCUMENT = 3
+ XMLELEMTYPE_DTD = 4
+ XMLELEMTYPE_PI = 5
+ XMLELEMTYPE_OTHER = 6
+end
+
+# XMLDocument extends IXML Document. It is obsolete. You should use DOMDocument. This object should not be confused with the XMLDocument property on the XML data island.
+class Msxml # XMLDocument
+ include WIN32OLE::VARIANT
+ attr_reader :lastargs
+ attr_reader :dispatch
+ attr_reader :clsid
+ attr_reader :progid
+
+ def initialize(obj = nil)
+ @clsid = "{CFC399AF-D876-11D0-9C10-00C04FC99C8E}"
+ @progid = "Msxml"
+ if obj.nil?
+ @dispatch = WIN32OLE.new(@progid)
+ else
+ @dispatch = obj
+ end
+ end
+
+ def method_missing(cmd, *arg)
+ @dispatch.method_missing(cmd, *arg)
+ end
+
+ # HRESULT url
+ # set URL to load an XML document from the URL.
+ # BSTR arg0 --- p [IN]
+ def url=(arg0)
+ ret = @dispatch._setproperty(65641, [arg0], [VT_BSTR, VT_HRESULT])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # HRESULT charset
+ # get encoding.
+ # BSTR arg0 --- p [IN]
+ def charset=(arg0)
+ ret = @dispatch._setproperty(65645, [arg0], [VT_BSTR, VT_HRESULT])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # HRESULT async
+ # get asynchronous loading flag.
+ # BOOL arg0 --- pf [IN]
+ def async=(arg0)
+ ret = @dispatch._setproperty(65649, [arg0], [VT_BOOL, VT_HRESULT])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+
+ # HRESULT root
+ # get root IXMLElement of the XML document.
+ # IXMLElement2,IXMLElement2 arg0 --- p [OUT]
+ def root
+ OLEProperty.new(@dispatch, 65637, [VT_BYREF|VT_BYREF|VT_DISPATCH], [VT_BYREF|VT_BYREF|VT_DISPATCH, VT_HRESULT])
+ end
+
+ # HRESULT url
+ # set URL to load an XML document from the URL.
+ # BSTR arg0 --- p [OUT]
+ def url
+ OLEProperty.new(@dispatch, 65641, [VT_BYREF|VT_BSTR], [VT_BYREF|VT_BSTR, VT_HRESULT])
+ end
+
+ # HRESULT readyState
+ # get ready state.
+ # I4 arg0 --- pl [OUT]
+ def readyState
+ OLEProperty.new(@dispatch, 65643, [VT_BYREF|VT_I4], [VT_BYREF|VT_I4, VT_HRESULT])
+ end
+
+ # HRESULT charset
+ # get encoding.
+ # BSTR arg0 --- p [OUT]
+ def charset
+ OLEProperty.new(@dispatch, 65645, [VT_BYREF|VT_BSTR], [VT_BYREF|VT_BSTR, VT_HRESULT])
+ end
+
+ # HRESULT version
+ # get XML version number.
+ # BSTR arg0 --- p [OUT]
+ def version
+ OLEProperty.new(@dispatch, 65646, [VT_BYREF|VT_BSTR], [VT_BYREF|VT_BSTR, VT_HRESULT])
+ end
+
+ # HRESULT doctype
+ # get document type.
+ # BSTR arg0 --- p [OUT]
+ def doctype
+ OLEProperty.new(@dispatch, 65647, [VT_BYREF|VT_BSTR], [VT_BYREF|VT_BSTR, VT_HRESULT])
+ end
+
+ # HRESULT async
+ # get asynchronous loading flag.
+ # BOOL arg0 --- pf [OUT]
+ def async
+ OLEProperty.new(@dispatch, 65649, [VT_BYREF|VT_BOOL], [VT_BYREF|VT_BOOL, VT_HRESULT])
+ end
+
+ # HRESULT createElement
+ # create different types of IXMLElements.
+ # VARIANT arg0 --- vType [IN]
+ # VARIANT arg1 --- var1 [IN]
+ # IXMLElement2,IXMLElement2 arg2 --- ppElem [OUT]
+ def createElement(arg0, arg1=nil, arg2=nil)
+ ret = @dispatch._invoke(65644, [arg0, arg1, arg2], [VT_VARIANT, VT_VARIANT, VT_BYREF|VT_BYREF|VT_DISPATCH])
+ @lastargs = WIN32OLE::ARGV
+ ret
+ end
+end
diff --git a/jni/ruby/ext/win32ole/win32ole.c b/jni/ruby/ext/win32ole/win32ole.c
new file mode 100644
index 0000000..4d664e8
--- /dev/null
+++ b/jni/ruby/ext/win32ole/win32ole.c
@@ -0,0 +1,4073 @@
+/*
+ * (c) 1995 Microsoft Corporation. All rights reserved.
+ * Developed by ActiveWare Internet Corp., http://www.ActiveWare.com
+ *
+ * Other modifications Copyright (c) 1997, 1998 by Gurusamy Sarathy
+ * <gsar@umich.edu> and Jan Dubois <jan.dubois@ibm.net>
+ *
+ * You may distribute under the terms of either the GNU General Public
+ * License or the Artistic License, as specified in the README file
+ * of the Perl distribution.
+ *
+ */
+
+/*
+ modified for win32ole (ruby) by Masaki.Suketa <masaki.suketa@nifty.ne.jp>
+ */
+
+#include "win32ole.h"
+
+/*
+ * unfortunately IID_IMultiLanguage2 is not included in any libXXX.a
+ * in Cygwin(mingw32).
+ */
+#if defined(__CYGWIN__) || defined(__MINGW32__)
+#undef IID_IMultiLanguage2
+const IID IID_IMultiLanguage2 = {0xDCCFC164, 0x2B38, 0x11d2, {0xB7, 0xEC, 0x00, 0xC0, 0x4F, 0x8F, 0x5D, 0x9A}};
+#endif
+
+#define WIN32OLE_VERSION "1.8.3"
+
+typedef HRESULT (STDAPICALLTYPE FNCOCREATEINSTANCEEX)
+ (REFCLSID, IUnknown*, DWORD, COSERVERINFO*, DWORD, MULTI_QI*);
+
+typedef HWND (WINAPI FNHTMLHELP)(HWND hwndCaller, LPCSTR pszFile,
+ UINT uCommand, DWORD dwData);
+typedef BOOL (FNENUMSYSEMCODEPAGES) (CODEPAGE_ENUMPROC, DWORD);
+VALUE cWIN32OLE;
+
+#if defined(RB_THREAD_SPECIFIC) && (defined(__CYGWIN__) || defined(__MINGW32__))
+static RB_THREAD_SPECIFIC BOOL g_ole_initialized;
+# define g_ole_initialized_init() ((void)0)
+# define g_ole_initialized_set(val) (g_ole_initialized = (val))
+#else
+static volatile DWORD g_ole_initialized_key = TLS_OUT_OF_INDEXES;
+# define g_ole_initialized (BOOL)TlsGetValue(g_ole_initialized_key)
+# define g_ole_initialized_init() (g_ole_initialized_key = TlsAlloc())
+# define g_ole_initialized_set(val) TlsSetValue(g_ole_initialized_key, (void*)(val))
+#endif
+
+static BOOL g_uninitialize_hooked = FALSE;
+static BOOL g_cp_installed = FALSE;
+static BOOL g_lcid_installed = FALSE;
+static HINSTANCE ghhctrl = NULL;
+static HINSTANCE gole32 = NULL;
+static FNCOCREATEINSTANCEEX *gCoCreateInstanceEx = NULL;
+static VALUE com_hash;
+static IDispatchVtbl com_vtbl;
+static UINT cWIN32OLE_cp = CP_ACP;
+static rb_encoding *cWIN32OLE_enc;
+static UINT g_cp_to_check = CP_ACP;
+static char g_lcid_to_check[8 + 1];
+static VARTYPE g_nil_to = VT_ERROR;
+static st_table *enc2cp_table;
+static IMessageFilterVtbl message_filter;
+static IMessageFilter imessage_filter = { &message_filter };
+static IMessageFilter* previous_filter;
+
+#if defined(HAVE_TYPE_IMULTILANGUAGE2)
+static IMultiLanguage2 *pIMultiLanguage = NULL;
+#elif defined(HAVE_TYPE_IMULTILANGUAGE)
+static IMultiLanguage *pIMultiLanguage = NULL;
+#else
+#define pIMultiLanguage NULL /* dummy */
+#endif
+
+struct oleparam {
+ DISPPARAMS dp;
+ OLECHAR** pNamedArgs;
+};
+
+static HRESULT ( STDMETHODCALLTYPE QueryInterface )(IDispatch __RPC_FAR *, REFIID riid, void __RPC_FAR *__RPC_FAR *ppvObject);
+static ULONG ( STDMETHODCALLTYPE AddRef )(IDispatch __RPC_FAR * This);
+static ULONG ( STDMETHODCALLTYPE Release )(IDispatch __RPC_FAR * This);
+static HRESULT ( STDMETHODCALLTYPE GetTypeInfoCount )(IDispatch __RPC_FAR * This, UINT __RPC_FAR *pctinfo);
+static HRESULT ( STDMETHODCALLTYPE GetTypeInfo )(IDispatch __RPC_FAR * This, UINT iTInfo, LCID lcid, ITypeInfo __RPC_FAR *__RPC_FAR *ppTInfo);
+static HRESULT ( STDMETHODCALLTYPE GetIDsOfNames )(IDispatch __RPC_FAR * This, REFIID riid, LPOLESTR __RPC_FAR *rgszNames, UINT cNames, LCID lcid, DISPID __RPC_FAR *rgDispId);
+static HRESULT ( STDMETHODCALLTYPE Invoke )( IDispatch __RPC_FAR * This, DISPID dispIdMember, REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS __RPC_FAR *pDispParams, VARIANT __RPC_FAR *pVarResult, EXCEPINFO __RPC_FAR *pExcepInfo, UINT __RPC_FAR *puArgErr);
+static IDispatch* val2dispatch(VALUE val);
+static double rbtime2vtdate(VALUE tmobj);
+static VALUE vtdate2rbtime(double date);
+static rb_encoding *ole_cp2encoding(UINT cp);
+static UINT ole_encoding2cp(rb_encoding *enc);
+NORETURN(static void failed_load_conv51932(void));
+#ifndef pIMultiLanguage
+static void load_conv_function51932(void);
+#endif
+static UINT ole_init_cp(void);
+static void ole_freeexceptinfo(EXCEPINFO *pExInfo);
+static VALUE ole_excepinfo2msg(EXCEPINFO *pExInfo);
+static void ole_free(void *ptr);
+static size_t ole_size(const void *ptr);
+static LPWSTR ole_mb2wc(char *pm, int len);
+static VALUE ole_ary_m_entry(VALUE val, LONG *pid);
+static VALUE is_all_index_under(LONG *pid, long *pub, long dim);
+static void * get_ptr_of_variant(VARIANT *pvar);
+static void ole_set_safe_array(long n, SAFEARRAY *psa, LONG *pid, long *pub, VALUE val, long dim, VARTYPE vt);
+static long dimension(VALUE val);
+static long ary_len_of_dim(VALUE ary, long dim);
+static VALUE ole_set_member(VALUE self, IDispatch *dispatch);
+static VALUE fole_s_allocate(VALUE klass);
+static VALUE create_win32ole_object(VALUE klass, IDispatch *pDispatch, int argc, VALUE *argv);
+static VALUE ary_new_dim(VALUE myary, LONG *pid, LONG *plb, LONG dim);
+static void ary_store_dim(VALUE myary, LONG *pid, LONG *plb, LONG dim, VALUE val);
+static void ole_const_load(ITypeLib *pTypeLib, VALUE klass, VALUE self);
+static HRESULT clsid_from_remote(VALUE host, VALUE com, CLSID *pclsid);
+static VALUE ole_create_dcom(VALUE self, VALUE ole, VALUE host, VALUE others);
+static VALUE ole_bind_obj(VALUE moniker, int argc, VALUE *argv, VALUE self);
+static VALUE fole_s_connect(int argc, VALUE *argv, VALUE self);
+static VALUE fole_s_const_load(int argc, VALUE *argv, VALUE self);
+static ULONG reference_count(struct oledata * pole);
+static VALUE fole_s_reference_count(VALUE self, VALUE obj);
+static VALUE fole_s_free(VALUE self, VALUE obj);
+static HWND ole_show_help(VALUE helpfile, VALUE helpcontext);
+static VALUE fole_s_show_help(int argc, VALUE *argv, VALUE self);
+static VALUE fole_s_get_code_page(VALUE self);
+static BOOL CALLBACK installed_code_page_proc(LPTSTR str);
+static BOOL code_page_installed(UINT cp);
+static VALUE fole_s_set_code_page(VALUE self, VALUE vcp);
+static VALUE fole_s_get_locale(VALUE self);
+static BOOL CALLBACK installed_lcid_proc(LPTSTR str);
+static BOOL lcid_installed(LCID lcid);
+static VALUE fole_s_set_locale(VALUE self, VALUE vlcid);
+static VALUE fole_s_create_guid(VALUE self);
+static VALUE fole_s_ole_initialize(VALUE self);
+static VALUE fole_s_ole_uninitialize(VALUE self);
+static VALUE fole_initialize(int argc, VALUE *argv, VALUE self);
+static int hash2named_arg(VALUE key, VALUE val, VALUE pop);
+static VALUE set_argv(VARIANTARG* realargs, unsigned int beg, unsigned int end);
+static VALUE ole_invoke(int argc, VALUE *argv, VALUE self, USHORT wFlags, BOOL is_bracket);
+static VALUE fole_invoke(int argc, VALUE *argv, VALUE self);
+static VALUE ole_invoke2(VALUE self, VALUE dispid, VALUE args, VALUE types, USHORT dispkind);
+static VALUE fole_invoke2(VALUE self, VALUE dispid, VALUE args, VALUE types);
+static VALUE fole_getproperty2(VALUE self, VALUE dispid, VALUE args, VALUE types);
+static VALUE fole_setproperty2(VALUE self, VALUE dispid, VALUE args, VALUE types);
+static VALUE fole_setproperty_with_bracket(int argc, VALUE *argv, VALUE self);
+static VALUE fole_setproperty(int argc, VALUE *argv, VALUE self);
+static VALUE fole_getproperty_with_bracket(int argc, VALUE *argv, VALUE self);
+static VALUE ole_propertyput(VALUE self, VALUE property, VALUE value);
+static VALUE fole_free(VALUE self);
+static VALUE ole_each_sub(VALUE pEnumV);
+static VALUE ole_ienum_free(VALUE pEnumV);
+static VALUE fole_each(VALUE self);
+static VALUE fole_missing(int argc, VALUE *argv, VALUE self);
+static HRESULT typeinfo_from_ole(struct oledata *pole, ITypeInfo **ppti);
+static VALUE ole_methods(VALUE self, int mask);
+static VALUE fole_methods(VALUE self);
+static VALUE fole_get_methods(VALUE self);
+static VALUE fole_put_methods(VALUE self);
+static VALUE fole_func_methods(VALUE self);
+static VALUE fole_type(VALUE self);
+static VALUE fole_typelib(VALUE self);
+static VALUE fole_query_interface(VALUE self, VALUE str_iid);
+static VALUE fole_respond_to(VALUE self, VALUE method);
+static VALUE ole_usertype2val(ITypeInfo *pTypeInfo, TYPEDESC *pTypeDesc, VALUE typedetails);
+static VALUE ole_ptrtype2val(ITypeInfo *pTypeInfo, TYPEDESC *pTypeDesc, VALUE typedetails);
+static VALUE fole_method_help(VALUE self, VALUE cmdname);
+static VALUE fole_activex_initialize(VALUE self);
+
+static void init_enc2cp(void);
+static void free_enc2cp(void);
+
+static void com_hash_free(void *ptr);
+static void com_hash_mark(void *ptr);
+static size_t com_hash_size(const void *ptr);
+
+static const rb_data_type_t ole_datatype = {
+ "win32ole",
+ {NULL, ole_free, ole_size,},
+ 0, 0, RUBY_TYPED_FREE_IMMEDIATELY
+};
+
+static const rb_data_type_t com_hash_datatype = {
+ "com_hash",
+ {com_hash_mark, com_hash_free, com_hash_size,},
+ 0, 0, RUBY_TYPED_FREE_IMMEDIATELY
+};
+
+static HRESULT (STDMETHODCALLTYPE mf_QueryInterface)(
+ IMessageFilter __RPC_FAR * This,
+ /* [in] */ REFIID riid,
+ /* [iid_is][out] */ void __RPC_FAR *__RPC_FAR *ppvObject)
+{
+ if (MEMCMP(riid, &IID_IUnknown, GUID, 1) == 0
+ || MEMCMP(riid, &IID_IMessageFilter, GUID, 1) == 0)
+ {
+ *ppvObject = &message_filter;
+ return S_OK;
+ }
+ return E_NOINTERFACE;
+}
+
+static ULONG (STDMETHODCALLTYPE mf_AddRef)(
+ IMessageFilter __RPC_FAR * This)
+{
+ return 1;
+}
+
+static ULONG (STDMETHODCALLTYPE mf_Release)(
+ IMessageFilter __RPC_FAR * This)
+{
+ return 1;
+}
+
+static DWORD (STDMETHODCALLTYPE mf_HandleInComingCall)(
+ IMessageFilter __RPC_FAR * pThis,
+ DWORD dwCallType, //Type of incoming call
+ HTASK threadIDCaller, //Task handle calling this task
+ DWORD dwTickCount, //Elapsed tick count
+ LPINTERFACEINFO lpInterfaceInfo //Pointer to INTERFACEINFO structure
+ )
+{
+#ifdef DEBUG_MESSAGEFILTER
+ printf("incoming %08X, %08X, %d\n", dwCallType, threadIDCaller, dwTickCount);
+ fflush(stdout);
+#endif
+ switch (dwCallType)
+ {
+ case CALLTYPE_ASYNC:
+ case CALLTYPE_TOPLEVEL_CALLPENDING:
+ case CALLTYPE_ASYNC_CALLPENDING:
+ if (rb_during_gc()) {
+ return SERVERCALL_RETRYLATER;
+ }
+ break;
+ default:
+ break;
+ }
+ if (previous_filter) {
+ return previous_filter->lpVtbl->HandleInComingCall(previous_filter,
+ dwCallType,
+ threadIDCaller,
+ dwTickCount,
+ lpInterfaceInfo);
+ }
+ return SERVERCALL_ISHANDLED;
+}
+
+static DWORD (STDMETHODCALLTYPE mf_RetryRejectedCall)(
+ IMessageFilter* pThis,
+ HTASK threadIDCallee, //Server task handle
+ DWORD dwTickCount, //Elapsed tick count
+ DWORD dwRejectType //Returned rejection message
+ )
+{
+ if (previous_filter) {
+ return previous_filter->lpVtbl->RetryRejectedCall(previous_filter,
+ threadIDCallee,
+ dwTickCount,
+ dwRejectType);
+ }
+ return 1000;
+}
+
+static DWORD (STDMETHODCALLTYPE mf_MessagePending)(
+ IMessageFilter* pThis,
+ HTASK threadIDCallee, //Called applications task handle
+ DWORD dwTickCount, //Elapsed tick count
+ DWORD dwPendingType //Call type
+ )
+{
+ if (rb_during_gc()) {
+ return PENDINGMSG_WAITNOPROCESS;
+ }
+ if (previous_filter) {
+ return previous_filter->lpVtbl->MessagePending(previous_filter,
+ threadIDCallee,
+ dwTickCount,
+ dwPendingType);
+ }
+ return PENDINGMSG_WAITNOPROCESS;
+}
+
+typedef struct _Win32OLEIDispatch
+{
+ IDispatch dispatch;
+ ULONG refcount;
+ VALUE obj;
+} Win32OLEIDispatch;
+
+static HRESULT ( STDMETHODCALLTYPE QueryInterface )(
+ IDispatch __RPC_FAR * This,
+ /* [in] */ REFIID riid,
+ /* [iid_is][out] */ void __RPC_FAR *__RPC_FAR *ppvObject)
+{
+ if (MEMCMP(riid, &IID_IUnknown, GUID, 1) == 0
+ || MEMCMP(riid, &IID_IDispatch, GUID, 1) == 0)
+ {
+ Win32OLEIDispatch* p = (Win32OLEIDispatch*)This;
+ p->refcount++;
+ *ppvObject = This;
+ return S_OK;
+ }
+ return E_NOINTERFACE;
+}
+
+static ULONG ( STDMETHODCALLTYPE AddRef )(
+ IDispatch __RPC_FAR * This)
+{
+ Win32OLEIDispatch* p = (Win32OLEIDispatch*)This;
+ return ++(p->refcount);
+}
+
+static ULONG ( STDMETHODCALLTYPE Release )(
+ IDispatch __RPC_FAR * This)
+{
+ Win32OLEIDispatch* p = (Win32OLEIDispatch*)This;
+ ULONG u = --(p->refcount);
+ if (u == 0) {
+ st_data_t key = p->obj;
+ st_delete(DATA_PTR(com_hash), &key, 0);
+ free(p);
+ }
+ return u;
+}
+
+static HRESULT ( STDMETHODCALLTYPE GetTypeInfoCount )(
+ IDispatch __RPC_FAR * This,
+ /* [out] */ UINT __RPC_FAR *pctinfo)
+{
+ return E_NOTIMPL;
+}
+
+static HRESULT ( STDMETHODCALLTYPE GetTypeInfo )(
+ IDispatch __RPC_FAR * This,
+ /* [in] */ UINT iTInfo,
+ /* [in] */ LCID lcid,
+ /* [out] */ ITypeInfo __RPC_FAR *__RPC_FAR *ppTInfo)
+{
+ return E_NOTIMPL;
+}
+
+
+static HRESULT ( STDMETHODCALLTYPE GetIDsOfNames )(
+ IDispatch __RPC_FAR * This,
+ /* [in] */ REFIID riid,
+ /* [size_is][in] */ LPOLESTR __RPC_FAR *rgszNames,
+ /* [in] */ UINT cNames,
+ /* [in] */ LCID lcid,
+ /* [size_is][out] */ DISPID __RPC_FAR *rgDispId)
+{
+ /*
+ Win32OLEIDispatch* p = (Win32OLEIDispatch*)This;
+ */
+ char* psz = ole_wc2mb(*rgszNames); // support only one method
+ ID nameid = rb_intern(psz);
+ free(psz);
+ if ((ID)(DISPID)nameid != nameid) return E_NOINTERFACE;
+ *rgDispId = (DISPID)nameid;
+ return S_OK;
+}
+
+static /* [local] */ HRESULT ( STDMETHODCALLTYPE Invoke )(
+ IDispatch __RPC_FAR * This,
+ /* [in] */ DISPID dispIdMember,
+ /* [in] */ REFIID riid,
+ /* [in] */ LCID lcid,
+ /* [in] */ WORD wFlags,
+ /* [out][in] */ DISPPARAMS __RPC_FAR *pDispParams,
+ /* [out] */ VARIANT __RPC_FAR *pVarResult,
+ /* [out] */ EXCEPINFO __RPC_FAR *pExcepInfo,
+ /* [out] */ UINT __RPC_FAR *puArgErr)
+{
+ VALUE v;
+ int i;
+ int args = pDispParams->cArgs;
+ Win32OLEIDispatch* p = (Win32OLEIDispatch*)This;
+ VALUE* parg = ALLOCA_N(VALUE, args);
+ ID mid = (ID)dispIdMember;
+ for (i = 0; i < args; i++) {
+ *(parg + i) = ole_variant2val(&pDispParams->rgvarg[args - i - 1]);
+ }
+ if (dispIdMember == DISPID_VALUE) {
+ if (wFlags == DISPATCH_METHOD) {
+ mid = rb_intern("call");
+ } else if (wFlags & DISPATCH_PROPERTYGET) {
+ mid = rb_intern("value");
+ }
+ }
+ v = rb_funcall2(p->obj, mid, args, parg);
+ ole_val2variant(v, pVarResult);
+ return S_OK;
+}
+
+BOOL
+ole_initialized(void)
+{
+ return g_ole_initialized;
+}
+
+static IDispatch*
+val2dispatch(VALUE val)
+{
+ struct st_table *tbl = DATA_PTR(com_hash);
+ Win32OLEIDispatch* pdisp;
+ st_data_t data;
+ if (st_lookup(tbl, val, &data)) {
+ pdisp = (Win32OLEIDispatch *)(data & ~FIXNUM_FLAG);
+ pdisp->refcount++;
+ }
+ else {
+ pdisp = ALLOC(Win32OLEIDispatch);
+ pdisp->dispatch.lpVtbl = &com_vtbl;
+ pdisp->refcount = 1;
+ pdisp->obj = val;
+ st_insert(tbl, val, (VALUE)pdisp | FIXNUM_FLAG);
+ }
+ return &pdisp->dispatch;
+}
+
+static double
+rbtime2vtdate(VALUE tmobj)
+{
+ SYSTEMTIME st;
+ double t;
+ double nsec;
+
+ st.wYear = FIX2INT(rb_funcall(tmobj, rb_intern("year"), 0));
+ st.wMonth = FIX2INT(rb_funcall(tmobj, rb_intern("month"), 0));
+ st.wDay = FIX2INT(rb_funcall(tmobj, rb_intern("mday"), 0));
+ st.wHour = FIX2INT(rb_funcall(tmobj, rb_intern("hour"), 0));
+ st.wMinute = FIX2INT(rb_funcall(tmobj, rb_intern("min"), 0));
+ st.wSecond = FIX2INT(rb_funcall(tmobj, rb_intern("sec"), 0));
+ st.wMilliseconds = 0;
+ SystemTimeToVariantTime(&st, &t);
+
+ /*
+ * Unfortunately SystemTimeToVariantTime function always ignores the
+ * wMilliseconds of SYSTEMTIME struct.
+ * So, we need to calculate milliseconds by ourselves.
+ */
+ nsec = FIX2INT(rb_funcall(tmobj, rb_intern("nsec"), 0));
+ nsec /= 1000000.0;
+ nsec /= (24.0 * 3600.0);
+ nsec /= 1000;
+ return t + nsec;
+}
+
+static VALUE
+vtdate2rbtime(double date)
+{
+ SYSTEMTIME st;
+ VALUE v;
+ double msec;
+ double sec;
+ VariantTimeToSystemTime(date, &st);
+ v = rb_funcall(rb_cTime, rb_intern("new"), 6,
+ INT2FIX(st.wYear),
+ INT2FIX(st.wMonth),
+ INT2FIX(st.wDay),
+ INT2FIX(st.wHour),
+ INT2FIX(st.wMinute),
+ INT2FIX(st.wSecond));
+ st.wYear = FIX2INT(rb_funcall(v, rb_intern("year"), 0));
+ st.wMonth = FIX2INT(rb_funcall(v, rb_intern("month"), 0));
+ st.wDay = FIX2INT(rb_funcall(v, rb_intern("mday"), 0));
+ st.wHour = FIX2INT(rb_funcall(v, rb_intern("hour"), 0));
+ st.wMinute = FIX2INT(rb_funcall(v, rb_intern("min"), 0));
+ st.wSecond = FIX2INT(rb_funcall(v, rb_intern("sec"), 0));
+ st.wMilliseconds = 0;
+ SystemTimeToVariantTime(&st, &sec);
+ /*
+ * Unfortunately VariantTimeToSystemTime always ignores the
+ * wMilliseconds of SYSTEMTIME struct(The wMilliseconds is 0).
+ * So, we need to calculate milliseconds by ourselves.
+ */
+ msec = date - sec;
+ msec *= 24 * 60;
+ msec -= floor(msec);
+ msec *= 60;
+ if (msec >= 59) {
+ msec -= 60;
+ }
+ if (msec != 0) {
+ return rb_funcall(v, rb_intern("+"), 1, rb_float_new(msec));
+ }
+ return v;
+}
+
+#define ENC_MACHING_CP(enc,encname,cp) if(strcasecmp(rb_enc_name((enc)),(encname)) == 0) return cp
+
+static UINT ole_encoding2cp(rb_encoding *enc)
+{
+ /*
+ * Is there any better solution to convert
+ * Ruby encoding to Windows codepage???
+ */
+ ENC_MACHING_CP(enc, "Big5", 950);
+ ENC_MACHING_CP(enc, "CP51932", 51932);
+ ENC_MACHING_CP(enc, "CP850", 850);
+ ENC_MACHING_CP(enc, "CP852", 852);
+ ENC_MACHING_CP(enc, "CP855", 855);
+ ENC_MACHING_CP(enc, "CP949", 949);
+ ENC_MACHING_CP(enc, "EUC-JP", 20932);
+ ENC_MACHING_CP(enc, "EUC-KR", 51949);
+ ENC_MACHING_CP(enc, "EUC-TW", 51950);
+ ENC_MACHING_CP(enc, "GB18030", 54936);
+ ENC_MACHING_CP(enc, "GB2312", 20936);
+ ENC_MACHING_CP(enc, "GBK", 936);
+ ENC_MACHING_CP(enc, "IBM437", 437);
+ ENC_MACHING_CP(enc, "IBM737", 737);
+ ENC_MACHING_CP(enc, "IBM775", 775);
+ ENC_MACHING_CP(enc, "IBM852", 852);
+ ENC_MACHING_CP(enc, "IBM855", 855);
+ ENC_MACHING_CP(enc, "IBM857", 857);
+ ENC_MACHING_CP(enc, "IBM860", 860);
+ ENC_MACHING_CP(enc, "IBM861", 861);
+ ENC_MACHING_CP(enc, "IBM862", 862);
+ ENC_MACHING_CP(enc, "IBM863", 863);
+ ENC_MACHING_CP(enc, "IBM864", 864);
+ ENC_MACHING_CP(enc, "IBM865", 865);
+ ENC_MACHING_CP(enc, "IBM866", 866);
+ ENC_MACHING_CP(enc, "IBM869", 869);
+ ENC_MACHING_CP(enc, "ISO-2022-JP", 50220);
+ ENC_MACHING_CP(enc, "ISO-8859-1", 28591);
+ ENC_MACHING_CP(enc, "ISO-8859-15", 28605);
+ ENC_MACHING_CP(enc, "ISO-8859-2", 28592);
+ ENC_MACHING_CP(enc, "ISO-8859-3", 28593);
+ ENC_MACHING_CP(enc, "ISO-8859-4", 28594);
+ ENC_MACHING_CP(enc, "ISO-8859-5", 28595);
+ ENC_MACHING_CP(enc, "ISO-8859-6", 28596);
+ ENC_MACHING_CP(enc, "ISO-8859-7", 28597);
+ ENC_MACHING_CP(enc, "ISO-8859-8", 28598);
+ ENC_MACHING_CP(enc, "ISO-8859-9", 28599);
+ ENC_MACHING_CP(enc, "KOI8-R", 20866);
+ ENC_MACHING_CP(enc, "KOI8-U", 21866);
+ ENC_MACHING_CP(enc, "Shift_JIS", 932);
+ ENC_MACHING_CP(enc, "UTF-16BE", 1201);
+ ENC_MACHING_CP(enc, "UTF-16LE", 1200);
+ ENC_MACHING_CP(enc, "UTF-7", 65000);
+ ENC_MACHING_CP(enc, "UTF-8", 65001);
+ ENC_MACHING_CP(enc, "Windows-1250", 1250);
+ ENC_MACHING_CP(enc, "Windows-1251", 1251);
+ ENC_MACHING_CP(enc, "Windows-1252", 1252);
+ ENC_MACHING_CP(enc, "Windows-1253", 1253);
+ ENC_MACHING_CP(enc, "Windows-1254", 1254);
+ ENC_MACHING_CP(enc, "Windows-1255", 1255);
+ ENC_MACHING_CP(enc, "Windows-1256", 1256);
+ ENC_MACHING_CP(enc, "Windows-1257", 1257);
+ ENC_MACHING_CP(enc, "Windows-1258", 1258);
+ ENC_MACHING_CP(enc, "Windows-31J", 932);
+ ENC_MACHING_CP(enc, "Windows-874", 874);
+ ENC_MACHING_CP(enc, "eucJP-ms", 20932);
+ return CP_ACP;
+}
+
+static void
+failed_load_conv51932(void)
+{
+ rb_raise(eWIN32OLERuntimeError, "fail to load convert function for CP51932");
+}
+
+#ifndef pIMultiLanguage
+static void
+load_conv_function51932(void)
+{
+ HRESULT hr = E_NOINTERFACE;
+ void *p;
+ if (!pIMultiLanguage) {
+#if defined(HAVE_TYPE_IMULTILANGUAGE2)
+ hr = CoCreateInstance(&CLSID_CMultiLanguage, NULL, CLSCTX_INPROC_SERVER,
+ &IID_IMultiLanguage2, &p);
+#elif defined(HAVE_TYPE_IMULTILANGUAGE)
+ hr = CoCreateInstance(&CLSID_CMultiLanguage, NULL, CLSCTX_INPROC_SERVER,
+ &IID_IMultiLanguage, &p);
+#endif
+ if (FAILED(hr)) {
+ failed_load_conv51932();
+ }
+ pIMultiLanguage = p;
+ }
+}
+#else
+#define load_conv_function51932() failed_load_conv51932()
+#endif
+
+#define conv_51932(cp) ((cp) == 51932 && (load_conv_function51932(), 1))
+
+static void
+set_ole_codepage(UINT cp)
+{
+ if (code_page_installed(cp)) {
+ cWIN32OLE_cp = cp;
+ } else {
+ switch(cp) {
+ case CP_ACP:
+ case CP_OEMCP:
+ case CP_MACCP:
+ case CP_THREAD_ACP:
+ case CP_SYMBOL:
+ case CP_UTF7:
+ case CP_UTF8:
+ cWIN32OLE_cp = cp;
+ break;
+ case 51932:
+ cWIN32OLE_cp = cp;
+ load_conv_function51932();
+ break;
+ default:
+ rb_raise(eWIN32OLERuntimeError, "codepage should be WIN32OLE::CP_ACP, WIN32OLE::CP_OEMCP, WIN32OLE::CP_MACCP, WIN32OLE::CP_THREAD_ACP, WIN32OLE::CP_SYMBOL, WIN32OLE::CP_UTF7, WIN32OLE::CP_UTF8, or installed codepage.");
+ break;
+ }
+ }
+ cWIN32OLE_enc = ole_cp2encoding(cWIN32OLE_cp);
+}
+
+
+static UINT
+ole_init_cp(void)
+{
+ UINT cp;
+ rb_encoding *encdef;
+ encdef = rb_default_internal_encoding();
+ if (!encdef) {
+ encdef = rb_default_external_encoding();
+ }
+ cp = ole_encoding2cp(encdef);
+ set_ole_codepage(cp);
+ return cp;
+}
+
+struct myCPINFOEX {
+ UINT MaxCharSize;
+ BYTE DefaultChar[2];
+ BYTE LeadByte[12];
+ WCHAR UnicodeDefaultChar;
+ UINT CodePage;
+ char CodePageName[MAX_PATH];
+};
+
+static rb_encoding *
+ole_cp2encoding(UINT cp)
+{
+ static BOOL (*pGetCPInfoEx)(UINT, DWORD, struct myCPINFOEX *) = NULL;
+ struct myCPINFOEX* buf;
+ VALUE enc_name;
+ char *enc_cstr;
+ int idx;
+
+ if (!code_page_installed(cp)) {
+ switch(cp) {
+ case CP_ACP:
+ cp = GetACP();
+ break;
+ case CP_OEMCP:
+ cp = GetOEMCP();
+ break;
+ case CP_MACCP:
+ case CP_THREAD_ACP:
+ if (!pGetCPInfoEx) {
+ pGetCPInfoEx = (BOOL (*)(UINT, DWORD, struct myCPINFOEX *))
+ GetProcAddress(GetModuleHandle("kernel32"), "GetCPInfoEx");
+ if (!pGetCPInfoEx) {
+ pGetCPInfoEx = (void*)-1;
+ }
+ }
+ buf = ALLOCA_N(struct myCPINFOEX, 1);
+ ZeroMemory(buf, sizeof(struct myCPINFOEX));
+ if (pGetCPInfoEx == (void*)-1 || !pGetCPInfoEx(cp, 0, buf)) {
+ rb_raise(eWIN32OLERuntimeError, "cannot map codepage to encoding.");
+ break; /* never reach here */
+ }
+ cp = buf->CodePage;
+ break;
+ case CP_SYMBOL:
+ case CP_UTF7:
+ case CP_UTF8:
+ break;
+ case 51932:
+ load_conv_function51932();
+ break;
+ default:
+ rb_raise(eWIN32OLERuntimeError, "codepage should be WIN32OLE::CP_ACP, WIN32OLE::CP_OEMCP, WIN32OLE::CP_MACCP, WIN32OLE::CP_THREAD_ACP, WIN32OLE::CP_SYMBOL, WIN32OLE::CP_UTF7, WIN32OLE::CP_UTF8, or installed codepage.");
+ break;
+ }
+ }
+
+ enc_name = rb_sprintf("CP%d", cp);
+ idx = rb_enc_find_index(enc_cstr = StringValueCStr(enc_name));
+ if (idx < 0)
+ idx = rb_define_dummy_encoding(enc_cstr);
+ return rb_enc_from_index(idx);
+}
+
+static char *
+ole_wc2mb_alloc(LPWSTR pw, char *(alloc)(UINT size, void *arg), void *arg)
+{
+ LPSTR pm;
+ UINT size = 0;
+ if (conv_51932(cWIN32OLE_cp)) {
+#ifndef pIMultiLanguage
+ DWORD dw = 0;
+ HRESULT hr = pIMultiLanguage->lpVtbl->ConvertStringFromUnicode(pIMultiLanguage,
+ &dw, cWIN32OLE_cp, pw, NULL, NULL, &size);
+ if (FAILED(hr)) {
+ ole_raise(hr, eWIN32OLERuntimeError, "fail to convert Unicode to CP%d", cWIN32OLE_cp);
+ }
+ pm = alloc(size, arg);
+ hr = pIMultiLanguage->lpVtbl->ConvertStringFromUnicode(pIMultiLanguage,
+ &dw, cWIN32OLE_cp, pw, NULL, pm, &size);
+ if (FAILED(hr)) {
+ ole_raise(hr, eWIN32OLERuntimeError, "fail to convert Unicode to CP%d", cWIN32OLE_cp);
+ }
+ pm[size] = '\0';
+#endif
+ return pm;
+ }
+ size = WideCharToMultiByte(cWIN32OLE_cp, 0, pw, -1, NULL, 0, NULL, NULL);
+ if (size) {
+ pm = alloc(size, arg);
+ WideCharToMultiByte(cWIN32OLE_cp, 0, pw, -1, pm, size, NULL, NULL);
+ pm[size] = '\0';
+ }
+ else {
+ pm = alloc(0, arg);
+ *pm = '\0';
+ }
+ return pm;
+}
+
+static char *
+ole_alloc_str(UINT size, void *arg)
+{
+ return ALLOC_N(char, size + 1);
+}
+
+char *
+ole_wc2mb(LPWSTR pw)
+{
+ return ole_wc2mb_alloc(pw, ole_alloc_str, NULL);
+}
+
+static void
+ole_freeexceptinfo(EXCEPINFO *pExInfo)
+{
+ SysFreeString(pExInfo->bstrDescription);
+ SysFreeString(pExInfo->bstrSource);
+ SysFreeString(pExInfo->bstrHelpFile);
+}
+
+static VALUE
+ole_excepinfo2msg(EXCEPINFO *pExInfo)
+{
+ char error_code[40];
+ char *pSource = NULL;
+ char *pDescription = NULL;
+ VALUE error_msg;
+ if(pExInfo->pfnDeferredFillIn != NULL) {
+ (*pExInfo->pfnDeferredFillIn)(pExInfo);
+ }
+ if (pExInfo->bstrSource != NULL) {
+ pSource = ole_wc2mb(pExInfo->bstrSource);
+ }
+ if (pExInfo->bstrDescription != NULL) {
+ pDescription = ole_wc2mb(pExInfo->bstrDescription);
+ }
+ if(pExInfo->wCode == 0) {
+ sprintf(error_code, "\n OLE error code:%lX in ", (unsigned long)pExInfo->scode);
+ }
+ else{
+ sprintf(error_code, "\n OLE error code:%u in ", pExInfo->wCode);
+ }
+ error_msg = rb_str_new2(error_code);
+ if(pSource != NULL) {
+ rb_str_cat2(error_msg, pSource);
+ }
+ else {
+ rb_str_cat(error_msg, "<Unknown>", 9);
+ }
+ rb_str_cat2(error_msg, "\n ");
+ if(pDescription != NULL) {
+ rb_str_cat2(error_msg, pDescription);
+ }
+ else {
+ rb_str_cat2(error_msg, "<No Description>");
+ }
+ if(pSource) free(pSource);
+ if(pDescription) free(pDescription);
+ ole_freeexceptinfo(pExInfo);
+ return error_msg;
+}
+
+void
+ole_uninitialize(void)
+{
+ if (!g_ole_initialized) return;
+ OleUninitialize();
+ g_ole_initialized_set(FALSE);
+}
+
+static void
+ole_uninitialize_hook(rb_event_flag_t evflag, VALUE data, VALUE self, ID mid, VALUE klass)
+{
+ ole_uninitialize();
+}
+
+void
+ole_initialize(void)
+{
+ HRESULT hr;
+
+ if(!g_uninitialize_hooked) {
+ rb_add_event_hook(ole_uninitialize_hook, RUBY_EVENT_THREAD_END, Qnil);
+ g_uninitialize_hooked = TRUE;
+ }
+
+ if(g_ole_initialized == FALSE) {
+ hr = OleInitialize(NULL);
+ if(FAILED(hr)) {
+ ole_raise(hr, rb_eRuntimeError, "fail: OLE initialize");
+ }
+ g_ole_initialized_set(TRUE);
+
+ hr = CoRegisterMessageFilter(&imessage_filter, &previous_filter);
+ if(FAILED(hr)) {
+ previous_filter = NULL;
+ ole_raise(hr, rb_eRuntimeError, "fail: install OLE MessageFilter");
+ }
+ }
+}
+
+static void
+ole_free(void *ptr)
+{
+ struct oledata *pole = ptr;
+ OLE_FREE(pole->pDispatch);
+ free(pole);
+}
+
+static size_t ole_size(const void *ptr)
+{
+ return ptr ? sizeof(struct oledata) : 0;
+}
+
+struct oledata *
+oledata_get_struct(VALUE ole)
+{
+ struct oledata *pole;
+ TypedData_Get_Struct(ole, struct oledata, &ole_datatype, pole);
+ return pole;
+}
+
+LPWSTR
+ole_vstr2wc(VALUE vstr)
+{
+ rb_encoding *enc;
+ int cp;
+ UINT size = 0;
+ LPWSTR pw;
+ st_data_t data;
+ enc = rb_enc_get(vstr);
+
+ if (st_lookup(enc2cp_table, (st_data_t)enc, &data)) {
+ cp = (int)data;
+ } else {
+ cp = ole_encoding2cp(enc);
+ if (code_page_installed(cp) ||
+ cp == CP_ACP ||
+ cp == CP_OEMCP ||
+ cp == CP_MACCP ||
+ cp == CP_THREAD_ACP ||
+ cp == CP_SYMBOL ||
+ cp == CP_UTF7 ||
+ cp == CP_UTF8 ||
+ cp == 51932) {
+ st_insert(enc2cp_table, (st_data_t)enc, (st_data_t)cp);
+ } else {
+ rb_raise(eWIN32OLERuntimeError, "not installed Windows codepage(%d) according to `%s'", cp, rb_enc_name(enc));
+ }
+ }
+ if (conv_51932(cp)) {
+#ifndef pIMultiLanguage
+ DWORD dw = 0;
+ UINT len = RSTRING_LENINT(vstr);
+ HRESULT hr = pIMultiLanguage->lpVtbl->ConvertStringToUnicode(pIMultiLanguage,
+ &dw, cp, RSTRING_PTR(vstr), &len, NULL, &size);
+ if (FAILED(hr)) {
+ ole_raise(hr, eWIN32OLERuntimeError, "fail to convert CP%d to Unicode", cp);
+ }
+ pw = SysAllocStringLen(NULL, size);
+ len = RSTRING_LEN(vstr);
+ hr = pIMultiLanguage->lpVtbl->ConvertStringToUnicode(pIMultiLanguage,
+ &dw, cp, RSTRING_PTR(vstr), &len, pw, &size);
+ if (FAILED(hr)) {
+ ole_raise(hr, eWIN32OLERuntimeError, "fail to convert CP%d to Unicode", cp);
+ }
+#endif
+ return pw;
+ }
+ size = MultiByteToWideChar(cp, 0, RSTRING_PTR(vstr), RSTRING_LEN(vstr), NULL, 0);
+ pw = SysAllocStringLen(NULL, size);
+ MultiByteToWideChar(cp, 0, RSTRING_PTR(vstr), RSTRING_LEN(vstr), pw, size);
+ return pw;
+}
+
+static LPWSTR
+ole_mb2wc(char *pm, int len)
+{
+ UINT size = 0;
+ LPWSTR pw;
+
+ if (conv_51932(cWIN32OLE_cp)) {
+#ifndef pIMultiLanguage
+ DWORD dw = 0;
+ UINT n = len;
+ HRESULT hr = pIMultiLanguage->lpVtbl->ConvertStringToUnicode(pIMultiLanguage,
+ &dw, cWIN32OLE_cp, pm, &n, NULL, &size);
+ if (FAILED(hr)) {
+ ole_raise(hr, eWIN32OLERuntimeError, "fail to convert CP%d to Unicode", cWIN32OLE_cp);
+ }
+ pw = SysAllocStringLen(NULL, size);
+ hr = pIMultiLanguage->lpVtbl->ConvertStringToUnicode(pIMultiLanguage,
+ &dw, cWIN32OLE_cp, pm, &n, pw, &size);
+ if (FAILED(hr)) {
+ ole_raise(hr, eWIN32OLERuntimeError, "fail to convert CP%d to Unicode", cWIN32OLE_cp);
+ }
+#endif
+ return pw;
+ }
+ size = MultiByteToWideChar(cWIN32OLE_cp, 0, pm, len, NULL, 0);
+ pw = SysAllocStringLen(NULL, size - 1);
+ MultiByteToWideChar(cWIN32OLE_cp, 0, pm, len, pw, size);
+ return pw;
+}
+
+static char *
+ole_alloc_vstr(UINT size, void *arg)
+{
+ VALUE str = rb_enc_str_new(NULL, size, cWIN32OLE_enc);
+ *(VALUE *)arg = str;
+ return RSTRING_PTR(str);
+}
+
+VALUE
+ole_wc2vstr(LPWSTR pw, BOOL isfree)
+{
+ VALUE vstr;
+ ole_wc2mb_alloc(pw, ole_alloc_vstr, &vstr);
+ rb_str_set_len(vstr, (long)strlen(RSTRING_PTR(vstr)));
+ if(isfree)
+ SysFreeString(pw);
+ return vstr;
+}
+
+static VALUE
+ole_ary_m_entry(VALUE val, LONG *pid)
+{
+ VALUE obj = Qnil;
+ int i = 0;
+ obj = val;
+ while(RB_TYPE_P(obj, T_ARRAY)) {
+ obj = rb_ary_entry(obj, pid[i]);
+ i++;
+ }
+ return obj;
+}
+
+static VALUE
+is_all_index_under(LONG *pid, long *pub, long dim)
+{
+ long i = 0;
+ for (i = 0; i < dim; i++) {
+ if (pid[i] > pub[i]) {
+ return Qfalse;
+ }
+ }
+ return Qtrue;
+}
+
+void
+ole_val2variant_ex(VALUE val, VARIANT *var, VARTYPE vt)
+{
+ if (val == Qnil) {
+ if (vt == VT_VARIANT) {
+ ole_val2variant2(val, var);
+ } else {
+ V_VT(var) = (vt & ~VT_BYREF);
+ if (V_VT(var) == VT_DISPATCH) {
+ V_DISPATCH(var) = NULL;
+ } else if (V_VT(var) == VT_UNKNOWN) {
+ V_UNKNOWN(var) = NULL;
+ }
+ }
+ return;
+ }
+#if (_MSC_VER >= 1300) || defined(__CYGWIN__) || defined(__MINGW32__)
+ switch(vt & ~VT_BYREF) {
+ case VT_I8:
+ V_VT(var) = VT_I8;
+ V_I8(var) = NUM2I8 (val);
+ break;
+ case VT_UI8:
+ V_VT(var) = VT_UI8;
+ V_UI8(var) = NUM2UI8(val);
+ break;
+ default:
+ ole_val2variant2(val, var);
+ break;
+ }
+#else /* (_MSC_VER >= 1300) || defined(__CYGWIN__) || defined(__MINGW32__) */
+ ole_val2variant2(val, var);
+#endif
+}
+
+VOID *
+val2variant_ptr(VALUE val, VARIANT *var, VARTYPE vt)
+{
+ VOID *p = NULL;
+ HRESULT hr = S_OK;
+ ole_val2variant_ex(val, var, vt);
+ if ((vt & ~VT_BYREF) == VT_VARIANT) {
+ p = var;
+ } else {
+ if ( (vt & ~VT_BYREF) != V_VT(var)) {
+ hr = VariantChangeTypeEx(var, var,
+ cWIN32OLE_lcid, 0, (VARTYPE)(vt & ~VT_BYREF));
+ if (FAILED(hr)) {
+ ole_raise(hr, rb_eRuntimeError, "failed to change type");
+ }
+ }
+ p = get_ptr_of_variant(var);
+ }
+ if (p == NULL) {
+ rb_raise(rb_eRuntimeError, "failed to get pointer of variant");
+ }
+ return p;
+}
+
+static void *
+get_ptr_of_variant(VARIANT *pvar)
+{
+ switch(V_VT(pvar)) {
+ case VT_UI1:
+ return &V_UI1(pvar);
+ break;
+ case VT_I2:
+ return &V_I2(pvar);
+ break;
+ case VT_UI2:
+ return &V_UI2(pvar);
+ break;
+ case VT_I4:
+ return &V_I4(pvar);
+ break;
+ case VT_UI4:
+ return &V_UI4(pvar);
+ break;
+ case VT_R4:
+ return &V_R4(pvar);
+ break;
+ case VT_R8:
+ return &V_R8(pvar);
+ break;
+#if (_MSC_VER >= 1300) || defined(__CYGWIN__) || defined(__MINGW32__)
+ case VT_I8:
+ return &V_I8(pvar);
+ break;
+ case VT_UI8:
+ return &V_UI8(pvar);
+ break;
+#endif
+ case VT_INT:
+ return &V_INT(pvar);
+ break;
+ case VT_UINT:
+ return &V_UINT(pvar);
+ break;
+ case VT_CY:
+ return &V_CY(pvar);
+ break;
+ case VT_DATE:
+ return &V_DATE(pvar);
+ break;
+ case VT_BSTR:
+ return V_BSTR(pvar);
+ break;
+ case VT_DISPATCH:
+ return V_DISPATCH(pvar);
+ break;
+ case VT_ERROR:
+ return &V_ERROR(pvar);
+ break;
+ case VT_BOOL:
+ return &V_BOOL(pvar);
+ break;
+ case VT_UNKNOWN:
+ return V_UNKNOWN(pvar);
+ break;
+ case VT_ARRAY:
+ return &V_ARRAY(pvar);
+ break;
+ default:
+ return NULL;
+ break;
+ }
+}
+
+static void
+ole_set_safe_array(long n, SAFEARRAY *psa, LONG *pid, long *pub, VALUE val, long dim, VARTYPE vt)
+{
+ VALUE val1;
+ HRESULT hr = S_OK;
+ VARIANT var;
+ VOID *p = NULL;
+ long i = n;
+ while(i >= 0) {
+ val1 = ole_ary_m_entry(val, pid);
+ VariantInit(&var);
+ p = val2variant_ptr(val1, &var, vt);
+ if (is_all_index_under(pid, pub, dim) == Qtrue) {
+ if ((V_VT(&var) == VT_DISPATCH && V_DISPATCH(&var) == NULL) ||
+ (V_VT(&var) == VT_UNKNOWN && V_UNKNOWN(&var) == NULL)) {
+ rb_raise(eWIN32OLERuntimeError, "element of array does not have IDispatch or IUnknown Interface");
+ }
+ hr = SafeArrayPutElement(psa, pid, p);
+ }
+ if (FAILED(hr)) {
+ ole_raise(hr, rb_eRuntimeError, "failed to SafeArrayPutElement");
+ }
+ pid[i] += 1;
+ if (pid[i] > pub[i]) {
+ pid[i] = 0;
+ i -= 1;
+ } else {
+ i = dim - 1;
+ }
+ }
+}
+
+static long
+dimension(VALUE val) {
+ long dim = 0;
+ long dim1 = 0;
+ long len = 0;
+ long i = 0;
+ if (RB_TYPE_P(val, T_ARRAY)) {
+ len = RARRAY_LEN(val);
+ for (i = 0; i < len; i++) {
+ dim1 = dimension(rb_ary_entry(val, i));
+ if (dim < dim1) {
+ dim = dim1;
+ }
+ }
+ dim += 1;
+ }
+ return dim;
+}
+
+static long
+ary_len_of_dim(VALUE ary, long dim) {
+ long ary_len = 0;
+ long ary_len1 = 0;
+ long len = 0;
+ long i = 0;
+ VALUE val;
+ if (dim == 0) {
+ if (RB_TYPE_P(ary, T_ARRAY)) {
+ ary_len = RARRAY_LEN(ary);
+ }
+ } else {
+ if (RB_TYPE_P(ary, T_ARRAY)) {
+ len = RARRAY_LEN(ary);
+ for (i = 0; i < len; i++) {
+ val = rb_ary_entry(ary, i);
+ ary_len1 = ary_len_of_dim(val, dim-1);
+ if (ary_len < ary_len1) {
+ ary_len = ary_len1;
+ }
+ }
+ }
+ }
+ return ary_len;
+}
+
+HRESULT
+ole_val_ary2variant_ary(VALUE val, VARIANT *var, VARTYPE vt)
+{
+ long dim = 0;
+ int i = 0;
+ HRESULT hr = S_OK;
+
+ SAFEARRAYBOUND *psab = NULL;
+ SAFEARRAY *psa = NULL;
+ long *pub;
+ LONG *pid;
+
+ Check_Type(val, T_ARRAY);
+
+ dim = dimension(val);
+
+ psab = ALLOC_N(SAFEARRAYBOUND, dim);
+ pub = ALLOC_N(long, dim);
+ pid = ALLOC_N(LONG, dim);
+
+ if(!psab || !pub || !pid) {
+ if(pub) free(pub);
+ if(psab) free(psab);
+ if(pid) free(pid);
+ rb_raise(rb_eRuntimeError, "memory allocation error");
+ }
+
+ for (i = 0; i < dim; i++) {
+ psab[i].cElements = ary_len_of_dim(val, i);
+ psab[i].lLbound = 0;
+ pub[i] = psab[i].cElements - 1;
+ pid[i] = 0;
+ }
+ /* Create and fill VARIANT array */
+ if ((vt & ~VT_BYREF) == VT_ARRAY) {
+ vt = (vt | VT_VARIANT);
+ }
+ psa = SafeArrayCreate((VARTYPE)(vt & VT_TYPEMASK), dim, psab);
+ if (psa == NULL)
+ hr = E_OUTOFMEMORY;
+ else
+ hr = SafeArrayLock(psa);
+ if (SUCCEEDED(hr)) {
+ ole_set_safe_array(dim-1, psa, pid, pub, val, dim, (VARTYPE)(vt & VT_TYPEMASK));
+ hr = SafeArrayUnlock(psa);
+ }
+
+ if(pub) free(pub);
+ if(psab) free(psab);
+ if(pid) free(pid);
+
+ if (SUCCEEDED(hr)) {
+ V_VT(var) = vt;
+ V_ARRAY(var) = psa;
+ }
+ else {
+ if (psa != NULL)
+ SafeArrayDestroy(psa);
+ }
+ return hr;
+}
+
+void
+ole_val2variant(VALUE val, VARIANT *var)
+{
+ struct oledata *pole = NULL;
+ if(rb_obj_is_kind_of(val, cWIN32OLE)) {
+ pole = oledata_get_struct(val);
+ OLE_ADDREF(pole->pDispatch);
+ V_VT(var) = VT_DISPATCH;
+ V_DISPATCH(var) = pole->pDispatch;
+ return;
+ }
+ if (rb_obj_is_kind_of(val, cWIN32OLE_VARIANT)) {
+ ole_variant2variant(val, var);
+ return;
+ }
+ if (rb_obj_is_kind_of(val, cWIN32OLE_RECORD)) {
+ ole_rec2variant(val, var);
+ return;
+ }
+ if (rb_obj_is_kind_of(val, rb_cTime)) {
+ V_VT(var) = VT_DATE;
+ V_DATE(var) = rbtime2vtdate(val);
+ return;
+ }
+ switch (TYPE(val)) {
+ case T_ARRAY:
+ ole_val_ary2variant_ary(val, var, VT_VARIANT|VT_ARRAY);
+ break;
+ case T_STRING:
+ V_VT(var) = VT_BSTR;
+ V_BSTR(var) = ole_vstr2wc(val);
+ break;
+ case T_FIXNUM:
+ V_VT(var) = VT_I4;
+ V_I4(var) = NUM2INT(val);
+ break;
+ case T_BIGNUM:
+ V_VT(var) = VT_R8;
+ V_R8(var) = rb_big2dbl(val);
+ break;
+ case T_FLOAT:
+ V_VT(var) = VT_R8;
+ V_R8(var) = NUM2DBL(val);
+ break;
+ case T_TRUE:
+ V_VT(var) = VT_BOOL;
+ V_BOOL(var) = VARIANT_TRUE;
+ break;
+ case T_FALSE:
+ V_VT(var) = VT_BOOL;
+ V_BOOL(var) = VARIANT_FALSE;
+ break;
+ case T_NIL:
+ if (g_nil_to == VT_ERROR) {
+ V_VT(var) = VT_ERROR;
+ V_ERROR(var) = DISP_E_PARAMNOTFOUND;
+ }else {
+ V_VT(var) = VT_EMPTY;
+ }
+ break;
+ default:
+ V_VT(var) = VT_DISPATCH;
+ V_DISPATCH(var) = val2dispatch(val);
+ break;
+ }
+}
+
+void
+ole_val2variant2(VALUE val, VARIANT *var)
+{
+ g_nil_to = VT_EMPTY;
+ ole_val2variant(val, var);
+ g_nil_to = VT_ERROR;
+}
+
+VALUE
+make_inspect(const char *class_name, VALUE detail)
+{
+ VALUE str;
+ str = rb_str_new2("#<");
+ rb_str_cat2(str, class_name);
+ rb_str_cat2(str, ":");
+ rb_str_concat(str, detail);
+ rb_str_cat2(str, ">");
+ return str;
+}
+
+VALUE
+default_inspect(VALUE self, const char *class_name)
+{
+ VALUE detail = rb_funcall(self, rb_intern("to_s"), 0);
+ return make_inspect(class_name, detail);
+}
+
+static VALUE
+ole_set_member(VALUE self, IDispatch *dispatch)
+{
+ struct oledata *pole = NULL;
+ pole = oledata_get_struct(self);
+ if (pole->pDispatch) {
+ OLE_RELEASE(pole->pDispatch);
+ pole->pDispatch = NULL;
+ }
+ pole->pDispatch = dispatch;
+ return self;
+}
+
+
+static VALUE
+fole_s_allocate(VALUE klass)
+{
+ struct oledata *pole;
+ VALUE obj;
+ ole_initialize();
+ obj = TypedData_Make_Struct(klass, struct oledata, &ole_datatype, pole);
+ pole->pDispatch = NULL;
+ return obj;
+}
+
+static VALUE
+create_win32ole_object(VALUE klass, IDispatch *pDispatch, int argc, VALUE *argv)
+{
+ VALUE obj = fole_s_allocate(klass);
+ ole_set_member(obj, pDispatch);
+ return obj;
+}
+
+static VALUE
+ary_new_dim(VALUE myary, LONG *pid, LONG *plb, LONG dim) {
+ long i;
+ VALUE obj = Qnil;
+ VALUE pobj = Qnil;
+ long *ids = ALLOC_N(long, dim);
+ if (!ids) {
+ rb_raise(rb_eRuntimeError, "memory allocation error");
+ }
+ for(i = 0; i < dim; i++) {
+ ids[i] = pid[i] - plb[i];
+ }
+ obj = myary;
+ pobj = myary;
+ for(i = 0; i < dim-1; i++) {
+ obj = rb_ary_entry(pobj, ids[i]);
+ if (obj == Qnil) {
+ rb_ary_store(pobj, ids[i], rb_ary_new());
+ }
+ obj = rb_ary_entry(pobj, ids[i]);
+ pobj = obj;
+ }
+ if (ids) free(ids);
+ return obj;
+}
+
+static void
+ary_store_dim(VALUE myary, LONG *pid, LONG *plb, LONG dim, VALUE val) {
+ long id = pid[dim - 1] - plb[dim - 1];
+ VALUE obj = ary_new_dim(myary, pid, plb, dim);
+ rb_ary_store(obj, id, val);
+}
+
+VALUE
+ole_variant2val(VARIANT *pvar)
+{
+ VALUE obj = Qnil;
+ VARTYPE vt = V_VT(pvar);
+ HRESULT hr;
+ while ( vt == (VT_BYREF | VT_VARIANT) ) {
+ pvar = V_VARIANTREF(pvar);
+ vt = V_VT(pvar);
+ }
+
+ if(V_ISARRAY(pvar)) {
+ VARTYPE vt_base = vt & VT_TYPEMASK;
+ SAFEARRAY *psa = V_ISBYREF(pvar) ? *V_ARRAYREF(pvar) : V_ARRAY(pvar);
+ UINT i = 0;
+ LONG *pid, *plb, *pub;
+ VARIANT variant;
+ VALUE val;
+ UINT dim = 0;
+ if (!psa) {
+ return obj;
+ }
+ dim = SafeArrayGetDim(psa);
+ pid = ALLOC_N(LONG, dim);
+ plb = ALLOC_N(LONG, dim);
+ pub = ALLOC_N(LONG, dim);
+
+ if(!pid || !plb || !pub) {
+ if(pid) free(pid);
+ if(plb) free(plb);
+ if(pub) free(pub);
+ rb_raise(rb_eRuntimeError, "memory allocation error");
+ }
+
+ for(i = 0; i < dim; ++i) {
+ SafeArrayGetLBound(psa, i+1, &plb[i]);
+ SafeArrayGetLBound(psa, i+1, &pid[i]);
+ SafeArrayGetUBound(psa, i+1, &pub[i]);
+ }
+ hr = SafeArrayLock(psa);
+ if (SUCCEEDED(hr)) {
+ obj = rb_ary_new();
+ i = 0;
+ VariantInit(&variant);
+ V_VT(&variant) = vt_base | VT_BYREF;
+ if (vt_base == VT_RECORD) {
+ hr = SafeArrayGetRecordInfo(psa, &V_RECORDINFO(&variant));
+ if (SUCCEEDED(hr)) {
+ V_VT(&variant) = VT_RECORD;
+ }
+ }
+ while (i < dim) {
+ ary_new_dim(obj, pid, plb, dim);
+ if (vt_base == VT_RECORD)
+ hr = SafeArrayPtrOfIndex(psa, pid, &V_RECORD(&variant));
+ else
+ hr = SafeArrayPtrOfIndex(psa, pid, &V_BYREF(&variant));
+ if (SUCCEEDED(hr)) {
+ val = ole_variant2val(&variant);
+ ary_store_dim(obj, pid, plb, dim, val);
+ }
+ for (i = 0; i < dim; ++i) {
+ if (++pid[i] <= pub[i])
+ break;
+ pid[i] = plb[i];
+ }
+ }
+ SafeArrayUnlock(psa);
+ }
+ if(pid) free(pid);
+ if(plb) free(plb);
+ if(pub) free(pub);
+ return obj;
+ }
+ switch(V_VT(pvar) & ~VT_BYREF){
+ case VT_EMPTY:
+ break;
+ case VT_NULL:
+ break;
+ case VT_I1:
+ if(V_ISBYREF(pvar))
+ obj = INT2NUM((long)*V_I1REF(pvar));
+ else
+ obj = INT2NUM((long)V_I1(pvar));
+ break;
+
+ case VT_UI1:
+ if(V_ISBYREF(pvar))
+ obj = INT2NUM((long)*V_UI1REF(pvar));
+ else
+ obj = INT2NUM((long)V_UI1(pvar));
+ break;
+
+ case VT_I2:
+ if(V_ISBYREF(pvar))
+ obj = INT2NUM((long)*V_I2REF(pvar));
+ else
+ obj = INT2NUM((long)V_I2(pvar));
+ break;
+
+ case VT_UI2:
+ if(V_ISBYREF(pvar))
+ obj = INT2NUM((long)*V_UI2REF(pvar));
+ else
+ obj = INT2NUM((long)V_UI2(pvar));
+ break;
+
+ case VT_I4:
+ if(V_ISBYREF(pvar))
+ obj = INT2NUM((long)*V_I4REF(pvar));
+ else
+ obj = INT2NUM((long)V_I4(pvar));
+ break;
+
+ case VT_UI4:
+ if(V_ISBYREF(pvar))
+ obj = INT2NUM((long)*V_UI4REF(pvar));
+ else
+ obj = INT2NUM((long)V_UI4(pvar));
+ break;
+
+ case VT_INT:
+ if(V_ISBYREF(pvar))
+ obj = INT2NUM((long)*V_INTREF(pvar));
+ else
+ obj = INT2NUM((long)V_INT(pvar));
+ break;
+
+ case VT_UINT:
+ if(V_ISBYREF(pvar))
+ obj = INT2NUM((long)*V_UINTREF(pvar));
+ else
+ obj = INT2NUM((long)V_UINT(pvar));
+ break;
+
+#if (_MSC_VER >= 1300) || defined(__CYGWIN__) || defined(__MINGW32__)
+ case VT_I8:
+ if(V_ISBYREF(pvar))
+#if (_MSC_VER >= 1300) || defined(__CYGWIN__) || defined(__MINGW32__)
+#ifdef V_I8REF
+ obj = I8_2_NUM(*V_I8REF(pvar));
+#endif
+#else
+ obj = Qnil;
+#endif
+ else
+ obj = I8_2_NUM(V_I8(pvar));
+ break;
+ case VT_UI8:
+ if(V_ISBYREF(pvar))
+#if (_MSC_VER >= 1300) || defined(__CYGWIN__) || defined(__MINGW32__)
+#ifdef V_UI8REF
+ obj = UI8_2_NUM(*V_UI8REF(pvar));
+#endif
+#else
+ obj = Qnil;
+#endif
+ else
+ obj = UI8_2_NUM(V_UI8(pvar));
+ break;
+#endif /* (_MSC_VER >= 1300) || defined(__CYGWIN__) || defined(__MINGW32__) */
+
+ case VT_R4:
+ if(V_ISBYREF(pvar))
+ obj = rb_float_new(*V_R4REF(pvar));
+ else
+ obj = rb_float_new(V_R4(pvar));
+ break;
+
+ case VT_R8:
+ if(V_ISBYREF(pvar))
+ obj = rb_float_new(*V_R8REF(pvar));
+ else
+ obj = rb_float_new(V_R8(pvar));
+ break;
+
+ case VT_BSTR:
+ {
+ if(V_ISBYREF(pvar))
+ obj = ole_wc2vstr(*V_BSTRREF(pvar), FALSE);
+ else
+ obj = ole_wc2vstr(V_BSTR(pvar), FALSE);
+ break;
+ }
+
+ case VT_ERROR:
+ if(V_ISBYREF(pvar))
+ obj = INT2NUM(*V_ERRORREF(pvar));
+ else
+ obj = INT2NUM(V_ERROR(pvar));
+ break;
+
+ case VT_BOOL:
+ if (V_ISBYREF(pvar))
+ obj = (*V_BOOLREF(pvar) ? Qtrue : Qfalse);
+ else
+ obj = (V_BOOL(pvar) ? Qtrue : Qfalse);
+ break;
+
+ case VT_DISPATCH:
+ {
+ IDispatch *pDispatch;
+
+ if (V_ISBYREF(pvar))
+ pDispatch = *V_DISPATCHREF(pvar);
+ else
+ pDispatch = V_DISPATCH(pvar);
+
+ if (pDispatch != NULL ) {
+ OLE_ADDREF(pDispatch);
+ obj = create_win32ole_object(cWIN32OLE, pDispatch, 0, 0);
+ }
+ break;
+ }
+
+ case VT_UNKNOWN:
+ {
+ /* get IDispatch interface from IUnknown interface */
+ IUnknown *punk;
+ IDispatch *pDispatch;
+ void *p;
+ HRESULT hr;
+
+ if (V_ISBYREF(pvar))
+ punk = *V_UNKNOWNREF(pvar);
+ else
+ punk = V_UNKNOWN(pvar);
+
+ if(punk != NULL) {
+ hr = punk->lpVtbl->QueryInterface(punk, &IID_IDispatch, &p);
+ if(SUCCEEDED(hr)) {
+ pDispatch = p;
+ obj = create_win32ole_object(cWIN32OLE, pDispatch, 0, 0);
+ }
+ }
+ break;
+ }
+
+ case VT_DATE:
+ {
+ DATE date;
+ if(V_ISBYREF(pvar))
+ date = *V_DATEREF(pvar);
+ else
+ date = V_DATE(pvar);
+
+ obj = vtdate2rbtime(date);
+ break;
+ }
+
+ case VT_RECORD:
+ {
+ IRecordInfo *pri = V_RECORDINFO(pvar);
+ void *prec = V_RECORD(pvar);
+ obj = create_win32ole_record(pri, prec);
+ break;
+ }
+
+ case VT_CY:
+ default:
+ {
+ HRESULT hr;
+ VARIANT variant;
+ VariantInit(&variant);
+ hr = VariantChangeTypeEx(&variant, pvar,
+ cWIN32OLE_lcid, 0, VT_BSTR);
+ if (SUCCEEDED(hr) && V_VT(&variant) == VT_BSTR) {
+ obj = ole_wc2vstr(V_BSTR(&variant), FALSE);
+ }
+ VariantClear(&variant);
+ break;
+ }
+ }
+ return obj;
+}
+
+LONG
+reg_open_key(HKEY hkey, const char *name, HKEY *phkey)
+{
+ return RegOpenKeyEx(hkey, name, 0, KEY_READ, phkey);
+}
+
+LONG
+reg_open_vkey(HKEY hkey, VALUE key, HKEY *phkey)
+{
+ return reg_open_key(hkey, StringValuePtr(key), phkey);
+}
+
+VALUE
+reg_enum_key(HKEY hkey, DWORD i)
+{
+ char buf[BUFSIZ + 1];
+ DWORD size_buf = sizeof(buf);
+ FILETIME ft;
+ LONG err = RegEnumKeyEx(hkey, i, buf, &size_buf,
+ NULL, NULL, NULL, &ft);
+ if(err == ERROR_SUCCESS) {
+ buf[BUFSIZ] = '\0';
+ return rb_str_new2(buf);
+ }
+ return Qnil;
+}
+
+VALUE
+reg_get_val(HKEY hkey, const char *subkey)
+{
+ char *pbuf;
+ DWORD dwtype = 0;
+ DWORD size = 0;
+ VALUE val = Qnil;
+ LONG err = RegQueryValueEx(hkey, subkey, NULL, &dwtype, NULL, &size);
+
+ if (err == ERROR_SUCCESS) {
+ pbuf = ALLOC_N(char, size + 1);
+ err = RegQueryValueEx(hkey, subkey, NULL, &dwtype, (BYTE *)pbuf, &size);
+ if (err == ERROR_SUCCESS) {
+ pbuf[size] = '\0';
+ if (dwtype == REG_EXPAND_SZ) {
+ char* pbuf2 = (char *)pbuf;
+ DWORD len = ExpandEnvironmentStrings(pbuf2, NULL, 0);
+ pbuf = ALLOC_N(char, len + 1);
+ ExpandEnvironmentStrings(pbuf2, pbuf, len + 1);
+ free(pbuf2);
+ }
+ val = rb_str_new2((char *)pbuf);
+ }
+ free(pbuf);
+ }
+ return val;
+}
+
+VALUE
+reg_get_val2(HKEY hkey, const char *subkey)
+{
+ HKEY hsubkey;
+ LONG err;
+ VALUE val = Qnil;
+ err = RegOpenKeyEx(hkey, subkey, 0, KEY_READ, &hsubkey);
+ if (err == ERROR_SUCCESS) {
+ val = reg_get_val(hsubkey, NULL);
+ RegCloseKey(hsubkey);
+ }
+ if (val == Qnil) {
+ val = reg_get_val(hkey, subkey);
+ }
+ return val;
+}
+
+static void
+ole_const_load(ITypeLib *pTypeLib, VALUE klass, VALUE self)
+{
+ unsigned int count;
+ unsigned int index;
+ int iVar;
+ ITypeInfo *pTypeInfo;
+ TYPEATTR *pTypeAttr;
+ VARDESC *pVarDesc;
+ HRESULT hr;
+ unsigned int len;
+ BSTR bstr;
+ char *pName = NULL;
+ VALUE val;
+ VALUE constant;
+ ID id;
+ constant = rb_hash_new();
+ count = pTypeLib->lpVtbl->GetTypeInfoCount(pTypeLib);
+ for (index = 0; index < count; index++) {
+ hr = pTypeLib->lpVtbl->GetTypeInfo(pTypeLib, index, &pTypeInfo);
+ if (FAILED(hr))
+ continue;
+ hr = OLE_GET_TYPEATTR(pTypeInfo, &pTypeAttr);
+ if(FAILED(hr)) {
+ OLE_RELEASE(pTypeInfo);
+ continue;
+ }
+ for(iVar = 0; iVar < pTypeAttr->cVars; iVar++) {
+ hr = pTypeInfo->lpVtbl->GetVarDesc(pTypeInfo, iVar, &pVarDesc);
+ if(FAILED(hr))
+ continue;
+ if(pVarDesc->varkind == VAR_CONST &&
+ !(pVarDesc->wVarFlags & (VARFLAG_FHIDDEN |
+ VARFLAG_FRESTRICTED |
+ VARFLAG_FNONBROWSABLE))) {
+ hr = pTypeInfo->lpVtbl->GetNames(pTypeInfo, pVarDesc->memid, &bstr,
+ 1, &len);
+ if(FAILED(hr) || len == 0 || !bstr)
+ continue;
+ pName = ole_wc2mb(bstr);
+ val = ole_variant2val(V_UNION1(pVarDesc, lpvarValue));
+ *pName = toupper((int)*pName);
+ id = rb_intern(pName);
+ if (rb_is_const_id(id)) {
+ rb_define_const(klass, pName, val);
+ }
+ else {
+ rb_hash_aset(constant, rb_str_new2(pName), val);
+ }
+ SysFreeString(bstr);
+ if(pName) {
+ free(pName);
+ pName = NULL;
+ }
+ }
+ pTypeInfo->lpVtbl->ReleaseVarDesc(pTypeInfo, pVarDesc);
+ }
+ pTypeInfo->lpVtbl->ReleaseTypeAttr(pTypeInfo, pTypeAttr);
+ OLE_RELEASE(pTypeInfo);
+ }
+ rb_define_const(klass, "CONSTANTS", constant);
+}
+
+static HRESULT
+clsid_from_remote(VALUE host, VALUE com, CLSID *pclsid)
+{
+ HKEY hlm;
+ HKEY hpid;
+ VALUE subkey;
+ LONG err;
+ char clsid[100];
+ OLECHAR *pbuf;
+ DWORD len;
+ DWORD dwtype;
+ HRESULT hr = S_OK;
+ err = RegConnectRegistry(StringValuePtr(host), HKEY_LOCAL_MACHINE, &hlm);
+ if (err != ERROR_SUCCESS)
+ return HRESULT_FROM_WIN32(err);
+ subkey = rb_str_new2("SOFTWARE\\Classes\\");
+ rb_str_concat(subkey, com);
+ rb_str_cat2(subkey, "\\CLSID");
+ err = RegOpenKeyEx(hlm, StringValuePtr(subkey), 0, KEY_READ, &hpid);
+ if (err != ERROR_SUCCESS)
+ hr = HRESULT_FROM_WIN32(err);
+ else {
+ len = sizeof(clsid);
+ err = RegQueryValueEx(hpid, "", NULL, &dwtype, (BYTE *)clsid, &len);
+ if (err == ERROR_SUCCESS && dwtype == REG_SZ) {
+ pbuf = ole_mb2wc(clsid, -1);
+ hr = CLSIDFromString(pbuf, pclsid);
+ SysFreeString(pbuf);
+ }
+ else {
+ hr = HRESULT_FROM_WIN32(err);
+ }
+ RegCloseKey(hpid);
+ }
+ RegCloseKey(hlm);
+ return hr;
+}
+
+static VALUE
+ole_create_dcom(VALUE self, VALUE ole, VALUE host, VALUE others)
+{
+ HRESULT hr;
+ CLSID clsid;
+ OLECHAR *pbuf;
+
+ COSERVERINFO serverinfo;
+ MULTI_QI multi_qi;
+ DWORD clsctx = CLSCTX_REMOTE_SERVER;
+
+ if (!gole32)
+ gole32 = LoadLibrary("OLE32");
+ if (!gole32)
+ rb_raise(rb_eRuntimeError, "failed to load OLE32");
+ if (!gCoCreateInstanceEx)
+ gCoCreateInstanceEx = (FNCOCREATEINSTANCEEX*)
+ GetProcAddress(gole32, "CoCreateInstanceEx");
+ if (!gCoCreateInstanceEx)
+ rb_raise(rb_eRuntimeError, "CoCreateInstanceEx is not supported in this environment");
+
+ pbuf = ole_vstr2wc(ole);
+ hr = CLSIDFromProgID(pbuf, &clsid);
+ if (FAILED(hr))
+ hr = clsid_from_remote(host, ole, &clsid);
+ if (FAILED(hr))
+ hr = CLSIDFromString(pbuf, &clsid);
+ SysFreeString(pbuf);
+ if (FAILED(hr))
+ ole_raise(hr, eWIN32OLERuntimeError,
+ "unknown OLE server: `%s'",
+ StringValuePtr(ole));
+ memset(&serverinfo, 0, sizeof(COSERVERINFO));
+ serverinfo.pwszName = ole_vstr2wc(host);
+ memset(&multi_qi, 0, sizeof(MULTI_QI));
+ multi_qi.pIID = &IID_IDispatch;
+ hr = gCoCreateInstanceEx(&clsid, NULL, clsctx, &serverinfo, 1, &multi_qi);
+ SysFreeString(serverinfo.pwszName);
+ if (FAILED(hr))
+ ole_raise(hr, eWIN32OLERuntimeError,
+ "failed to create DCOM server `%s' in `%s'",
+ StringValuePtr(ole),
+ StringValuePtr(host));
+
+ ole_set_member(self, (IDispatch*)multi_qi.pItf);
+ return self;
+}
+
+static VALUE
+ole_bind_obj(VALUE moniker, int argc, VALUE *argv, VALUE self)
+{
+ IBindCtx *pBindCtx;
+ IMoniker *pMoniker;
+ IDispatch *pDispatch;
+ void *p;
+ HRESULT hr;
+ OLECHAR *pbuf;
+ ULONG eaten = 0;
+
+ ole_initialize();
+
+ hr = CreateBindCtx(0, &pBindCtx);
+ if(FAILED(hr)) {
+ ole_raise(hr, eWIN32OLERuntimeError,
+ "failed to create bind context");
+ }
+
+ pbuf = ole_vstr2wc(moniker);
+ hr = MkParseDisplayName(pBindCtx, pbuf, &eaten, &pMoniker);
+ SysFreeString(pbuf);
+ if(FAILED(hr)) {
+ OLE_RELEASE(pBindCtx);
+ ole_raise(hr, eWIN32OLERuntimeError,
+ "failed to parse display name of moniker `%s'",
+ StringValuePtr(moniker));
+ }
+ hr = pMoniker->lpVtbl->BindToObject(pMoniker, pBindCtx, NULL,
+ &IID_IDispatch, &p);
+ pDispatch = p;
+ OLE_RELEASE(pMoniker);
+ OLE_RELEASE(pBindCtx);
+
+ if(FAILED(hr)) {
+ ole_raise(hr, eWIN32OLERuntimeError,
+ "failed to bind moniker `%s'",
+ StringValuePtr(moniker));
+ }
+ return create_win32ole_object(self, pDispatch, argc, argv);
+}
+
+/*
+ * call-seq:
+ * WIN32OLE.connect( ole ) --> aWIN32OLE
+ *
+ * Returns running OLE Automation object or WIN32OLE object from moniker.
+ * 1st argument should be OLE program id or class id or moniker.
+ *
+ * WIN32OLE.connect('Excel.Application') # => WIN32OLE object which represents running Excel.
+ */
+static VALUE
+fole_s_connect(int argc, VALUE *argv, VALUE self)
+{
+ VALUE svr_name;
+ VALUE others;
+ HRESULT hr;
+ CLSID clsid;
+ OLECHAR *pBuf;
+ IDispatch *pDispatch;
+ void *p;
+ IUnknown *pUnknown;
+
+ /* initialize to use OLE */
+ ole_initialize();
+
+ rb_scan_args(argc, argv, "1*", &svr_name, &others);
+ StringValue(svr_name);
+ if (rb_safe_level() > 0 && OBJ_TAINTED(svr_name)) {
+ rb_raise(rb_eSecurityError, "insecure connection - `%s'",
+ StringValuePtr(svr_name));
+ }
+
+ /* get CLSID from OLE server name */
+ pBuf = ole_vstr2wc(svr_name);
+ hr = CLSIDFromProgID(pBuf, &clsid);
+ if(FAILED(hr)) {
+ hr = CLSIDFromString(pBuf, &clsid);
+ }
+ SysFreeString(pBuf);
+ if(FAILED(hr)) {
+ return ole_bind_obj(svr_name, argc, argv, self);
+ }
+
+ hr = GetActiveObject(&clsid, 0, &pUnknown);
+ if (FAILED(hr)) {
+ ole_raise(hr, eWIN32OLERuntimeError,
+ "OLE server `%s' not running", StringValuePtr(svr_name));
+ }
+ hr = pUnknown->lpVtbl->QueryInterface(pUnknown, &IID_IDispatch, &p);
+ pDispatch = p;
+ if(FAILED(hr)) {
+ OLE_RELEASE(pUnknown);
+ ole_raise(hr, eWIN32OLERuntimeError,
+ "failed to create WIN32OLE server `%s'",
+ StringValuePtr(svr_name));
+ }
+
+ OLE_RELEASE(pUnknown);
+
+ return create_win32ole_object(self, pDispatch, argc, argv);
+}
+
+/*
+ * call-seq:
+ * WIN32OLE.const_load( ole, mod = WIN32OLE)
+ *
+ * Defines the constants of OLE Automation server as mod's constants.
+ * The first argument is WIN32OLE object or type library name.
+ * If 2nd argument is omitted, the default is WIN32OLE.
+ * The first letter of Ruby's constant variable name is upper case,
+ * so constant variable name of WIN32OLE object is capitalized.
+ * For example, the 'xlTop' constant of Excel is changed to 'XlTop'
+ * in WIN32OLE.
+ * If the first letter of constant variable is not [A-Z], then
+ * the constant is defined as CONSTANTS hash element.
+ *
+ * module EXCEL_CONST
+ * end
+ * excel = WIN32OLE.new('Excel.Application')
+ * WIN32OLE.const_load(excel, EXCEL_CONST)
+ * puts EXCEL_CONST::XlTop # => -4160
+ * puts EXCEL_CONST::CONSTANTS['_xlDialogChartSourceData'] # => 541
+ *
+ * WIN32OLE.const_load(excel)
+ * puts WIN32OLE::XlTop # => -4160
+ *
+ * module MSO
+ * end
+ * WIN32OLE.const_load('Microsoft Office 9.0 Object Library', MSO)
+ * puts MSO::MsoLineSingle # => 1
+ */
+static VALUE
+fole_s_const_load(int argc, VALUE *argv, VALUE self)
+{
+ VALUE ole;
+ VALUE klass;
+ struct oledata *pole = NULL;
+ ITypeInfo *pTypeInfo;
+ ITypeLib *pTypeLib;
+ unsigned int index;
+ HRESULT hr;
+ OLECHAR *pBuf;
+ VALUE file;
+ LCID lcid = cWIN32OLE_lcid;
+
+ rb_scan_args(argc, argv, "11", &ole, &klass);
+ if (!RB_TYPE_P(klass, T_CLASS) &&
+ !RB_TYPE_P(klass, T_MODULE) &&
+ !RB_TYPE_P(klass, T_NIL)) {
+ rb_raise(rb_eTypeError, "2nd parameter must be Class or Module");
+ }
+ if (rb_obj_is_kind_of(ole, cWIN32OLE)) {
+ pole = oledata_get_struct(ole);
+ hr = pole->pDispatch->lpVtbl->GetTypeInfo(pole->pDispatch,
+ 0, lcid, &pTypeInfo);
+ if(FAILED(hr)) {
+ ole_raise(hr, rb_eRuntimeError, "failed to GetTypeInfo");
+ }
+ hr = pTypeInfo->lpVtbl->GetContainingTypeLib(pTypeInfo, &pTypeLib, &index);
+ if(FAILED(hr)) {
+ OLE_RELEASE(pTypeInfo);
+ ole_raise(hr, rb_eRuntimeError, "failed to GetContainingTypeLib");
+ }
+ OLE_RELEASE(pTypeInfo);
+ if(!RB_TYPE_P(klass, T_NIL)) {
+ ole_const_load(pTypeLib, klass, self);
+ }
+ else {
+ ole_const_load(pTypeLib, cWIN32OLE, self);
+ }
+ OLE_RELEASE(pTypeLib);
+ }
+ else if(RB_TYPE_P(ole, T_STRING)) {
+ file = typelib_file(ole);
+ if (file == Qnil) {
+ file = ole;
+ }
+ pBuf = ole_vstr2wc(file);
+ hr = LoadTypeLibEx(pBuf, REGKIND_NONE, &pTypeLib);
+ SysFreeString(pBuf);
+ if (FAILED(hr))
+ ole_raise(hr, eWIN32OLERuntimeError, "failed to LoadTypeLibEx");
+ if(!RB_TYPE_P(klass, T_NIL)) {
+ ole_const_load(pTypeLib, klass, self);
+ }
+ else {
+ ole_const_load(pTypeLib, cWIN32OLE, self);
+ }
+ OLE_RELEASE(pTypeLib);
+ }
+ else {
+ rb_raise(rb_eTypeError, "1st parameter must be WIN32OLE instance");
+ }
+ return Qnil;
+}
+
+static ULONG
+reference_count(struct oledata * pole)
+{
+ ULONG n = 0;
+ if(pole->pDispatch) {
+ OLE_ADDREF(pole->pDispatch);
+ n = OLE_RELEASE(pole->pDispatch);
+ }
+ return n;
+}
+
+/*
+ * call-seq:
+ * WIN32OLE.ole_reference_count(aWIN32OLE) --> number
+ *
+ * Returns reference counter of Dispatch interface of WIN32OLE object.
+ * You should not use this method because this method
+ * exists only for debugging WIN32OLE.
+ */
+static VALUE
+fole_s_reference_count(VALUE self, VALUE obj)
+{
+ struct oledata * pole = NULL;
+ pole = oledata_get_struct(obj);
+ return INT2NUM(reference_count(pole));
+}
+
+/*
+ * call-seq:
+ * WIN32OLE.ole_free(aWIN32OLE) --> number
+ *
+ * Invokes Release method of Dispatch interface of WIN32OLE object.
+ * You should not use this method because this method
+ * exists only for debugging WIN32OLE.
+ * The return value is reference counter of OLE object.
+ */
+static VALUE
+fole_s_free(VALUE self, VALUE obj)
+{
+ ULONG n = 0;
+ struct oledata * pole = NULL;
+ pole = oledata_get_struct(obj);
+ if(pole->pDispatch) {
+ if (reference_count(pole) > 0) {
+ n = OLE_RELEASE(pole->pDispatch);
+ }
+ }
+ return INT2NUM(n);
+}
+
+static HWND
+ole_show_help(VALUE helpfile, VALUE helpcontext)
+{
+ FNHTMLHELP *pfnHtmlHelp;
+ HWND hwnd = 0;
+
+ if(!ghhctrl)
+ ghhctrl = LoadLibrary("HHCTRL.OCX");
+ if (!ghhctrl)
+ return hwnd;
+ pfnHtmlHelp = (FNHTMLHELP*)GetProcAddress(ghhctrl, "HtmlHelpA");
+ if (!pfnHtmlHelp)
+ return hwnd;
+ hwnd = pfnHtmlHelp(GetDesktopWindow(), StringValuePtr(helpfile),
+ 0x0f, NUM2INT(helpcontext));
+ if (hwnd == 0)
+ hwnd = pfnHtmlHelp(GetDesktopWindow(), StringValuePtr(helpfile),
+ 0, NUM2INT(helpcontext));
+ return hwnd;
+}
+
+/*
+ * call-seq:
+ * WIN32OLE.ole_show_help(obj [,helpcontext])
+ *
+ * Displays helpfile. The 1st argument specifies WIN32OLE_TYPE
+ * object or WIN32OLE_METHOD object or helpfile.
+ *
+ * excel = WIN32OLE.new('Excel.Application')
+ * typeobj = excel.ole_type
+ * WIN32OLE.ole_show_help(typeobj)
+ */
+static VALUE
+fole_s_show_help(int argc, VALUE *argv, VALUE self)
+{
+ VALUE target;
+ VALUE helpcontext;
+ VALUE helpfile;
+ VALUE name;
+ HWND hwnd;
+ rb_scan_args(argc, argv, "11", &target, &helpcontext);
+ if (rb_obj_is_kind_of(target, cWIN32OLE_TYPE) ||
+ rb_obj_is_kind_of(target, cWIN32OLE_METHOD)) {
+ helpfile = rb_funcall(target, rb_intern("helpfile"), 0);
+ if(strlen(StringValuePtr(helpfile)) == 0) {
+ name = rb_ivar_get(target, rb_intern("name"));
+ rb_raise(rb_eRuntimeError, "no helpfile of `%s'",
+ StringValuePtr(name));
+ }
+ helpcontext = rb_funcall(target, rb_intern("helpcontext"), 0);
+ } else {
+ helpfile = target;
+ }
+ if (!RB_TYPE_P(helpfile, T_STRING)) {
+ rb_raise(rb_eTypeError, "1st parameter must be (String|WIN32OLE_TYPE|WIN32OLE_METHOD)");
+ }
+ hwnd = ole_show_help(helpfile, helpcontext);
+ if(hwnd == 0) {
+ rb_raise(rb_eRuntimeError, "failed to open help file `%s'",
+ StringValuePtr(helpfile));
+ }
+ return Qnil;
+}
+
+/*
+ * call-seq:
+ * WIN32OLE.codepage
+ *
+ * Returns current codepage.
+ * WIN32OLE.codepage # => WIN32OLE::CP_ACP
+ */
+static VALUE
+fole_s_get_code_page(VALUE self)
+{
+ return INT2FIX(cWIN32OLE_cp);
+}
+
+static BOOL CALLBACK
+installed_code_page_proc(LPTSTR str) {
+ if (strtoul(str, NULL, 10) == g_cp_to_check) {
+ g_cp_installed = TRUE;
+ return FALSE;
+ }
+ return TRUE;
+}
+
+static BOOL
+code_page_installed(UINT cp)
+{
+ g_cp_installed = FALSE;
+ g_cp_to_check = cp;
+ EnumSystemCodePages(installed_code_page_proc, CP_INSTALLED);
+ return g_cp_installed;
+}
+
+/*
+ * call-seq:
+ * WIN32OLE.codepage = CP
+ *
+ * Sets current codepage.
+ * The WIN32OLE.codepage is initialized according to
+ * Encoding.default_internal.
+ * If Encoding.default_internal is nil then WIN32OLE.codepage
+ * is initialized according to Encoding.default_external.
+ *
+ * WIN32OLE.codepage = WIN32OLE::CP_UTF8
+ * WIN32OLE.codepage = 65001
+ */
+static VALUE
+fole_s_set_code_page(VALUE self, VALUE vcp)
+{
+ UINT cp = FIX2INT(vcp);
+ set_ole_codepage(cp);
+ /*
+ * Should this method return old codepage?
+ */
+ return Qnil;
+}
+
+/*
+ * call-seq:
+ * WIN32OLE.locale -> locale id.
+ *
+ * Returns current locale id (lcid). The default locale is
+ * WIN32OLE::LOCALE_SYSTEM_DEFAULT.
+ *
+ * lcid = WIN32OLE.locale
+ */
+static VALUE
+fole_s_get_locale(VALUE self)
+{
+ return INT2FIX(cWIN32OLE_lcid);
+}
+
+static BOOL
+CALLBACK installed_lcid_proc(LPTSTR str)
+{
+ if (strcmp(str, g_lcid_to_check) == 0) {
+ g_lcid_installed = TRUE;
+ return FALSE;
+ }
+ return TRUE;
+}
+
+static BOOL
+lcid_installed(LCID lcid)
+{
+ g_lcid_installed = FALSE;
+ snprintf(g_lcid_to_check, sizeof(g_lcid_to_check), "%08lx", (unsigned long)lcid);
+ EnumSystemLocales(installed_lcid_proc, LCID_INSTALLED);
+ return g_lcid_installed;
+}
+
+/*
+ * call-seq:
+ * WIN32OLE.locale = lcid
+ *
+ * Sets current locale id (lcid).
+ *
+ * WIN32OLE.locale = 1033 # set locale English(U.S)
+ * obj = WIN32OLE_VARIANT.new("$100,000", WIN32OLE::VARIANT::VT_CY)
+ *
+ */
+static VALUE
+fole_s_set_locale(VALUE self, VALUE vlcid)
+{
+ LCID lcid = FIX2INT(vlcid);
+ if (lcid_installed(lcid)) {
+ cWIN32OLE_lcid = lcid;
+ } else {
+ switch (lcid) {
+ case LOCALE_SYSTEM_DEFAULT:
+ case LOCALE_USER_DEFAULT:
+ cWIN32OLE_lcid = lcid;
+ break;
+ default:
+ rb_raise(eWIN32OLERuntimeError, "not installed locale: %u", (unsigned int)lcid);
+ }
+ }
+ return Qnil;
+}
+
+/*
+ * call-seq:
+ * WIN32OLE.create_guid
+ *
+ * Creates GUID.
+ * WIN32OLE.create_guid # => {1CB530F1-F6B1-404D-BCE6-1959BF91F4A8}
+ */
+static VALUE
+fole_s_create_guid(VALUE self)
+{
+ GUID guid;
+ HRESULT hr;
+ OLECHAR bstr[80];
+ int len = 0;
+ hr = CoCreateGuid(&guid);
+ if (FAILED(hr)) {
+ ole_raise(hr, eWIN32OLERuntimeError, "failed to create GUID");
+ }
+ len = StringFromGUID2(&guid, bstr, sizeof(bstr)/sizeof(OLECHAR));
+ if (len == 0) {
+ rb_raise(rb_eRuntimeError, "failed to create GUID(buffer over)");
+ }
+ return ole_wc2vstr(bstr, FALSE);
+}
+
+/*
+ * WIN32OLE.ole_initialize and WIN32OLE.ole_uninitialize
+ * are used in win32ole.rb to fix the issue bug #2618 (ruby-core:27634).
+ * You must not use these method.
+ */
+
+/* :nodoc: */
+static VALUE
+fole_s_ole_initialize(VALUE self)
+{
+ ole_initialize();
+ return Qnil;
+}
+
+/* :nodoc: */
+static VALUE
+fole_s_ole_uninitialize(VALUE self)
+{
+ ole_uninitialize();
+ return Qnil;
+}
+
+/*
+ * Document-class: WIN32OLE
+ *
+ * <code>WIN32OLE</code> objects represent OLE Automation object in Ruby.
+ *
+ * By using WIN32OLE, you can access OLE server like VBScript.
+ *
+ * Here is sample script.
+ *
+ * require 'win32ole'
+ *
+ * excel = WIN32OLE.new('Excel.Application')
+ * excel.visible = true
+ * workbook = excel.Workbooks.Add();
+ * worksheet = workbook.Worksheets(1);
+ * worksheet.Range("A1:D1").value = ["North","South","East","West"];
+ * worksheet.Range("A2:B2").value = [5.2, 10];
+ * worksheet.Range("C2").value = 8;
+ * worksheet.Range("D2").value = 20;
+ *
+ * range = worksheet.Range("A1:D2");
+ * range.select
+ * chart = workbook.Charts.Add;
+ *
+ * workbook.saved = true;
+ *
+ * excel.ActiveWorkbook.Close(0);
+ * excel.Quit();
+ *
+ * Unfortunately, Win32OLE doesn't support the argument passed by
+ * reference directly.
+ * Instead, Win32OLE provides WIN32OLE::ARGV or WIN32OLE_VARIANT object.
+ * If you want to get the result value of argument passed by reference,
+ * you can use WIN32OLE::ARGV or WIN32OLE_VARIANT.
+ *
+ * oleobj.method(arg1, arg2, refargv3)
+ * puts WIN32OLE::ARGV[2] # the value of refargv3 after called oleobj.method
+ *
+ * or
+ *
+ * refargv3 = WIN32OLE_VARIANT.new(XXX,
+ * WIN32OLE::VARIANT::VT_BYREF|WIN32OLE::VARIANT::VT_XXX)
+ * oleobj.method(arg1, arg2, refargv3)
+ * p refargv3.value # the value of refargv3 after called oleobj.method.
+ *
+ */
+
+/*
+ * call-seq:
+ * WIN32OLE.new(server, [host]) -> WIN32OLE object
+ *
+ * Returns a new WIN32OLE object(OLE Automation object).
+ * The first argument server specifies OLE Automation server.
+ * The first argument should be CLSID or PROGID.
+ * If second argument host specified, then returns OLE Automation
+ * object on host.
+ *
+ * WIN32OLE.new('Excel.Application') # => Excel OLE Automation WIN32OLE object.
+ * WIN32OLE.new('{00024500-0000-0000-C000-000000000046}') # => Excel OLE Automation WIN32OLE object.
+ */
+static VALUE
+fole_initialize(int argc, VALUE *argv, VALUE self)
+{
+ VALUE svr_name;
+ VALUE host;
+ VALUE others;
+ HRESULT hr;
+ CLSID clsid;
+ OLECHAR *pBuf;
+ IDispatch *pDispatch;
+ void *p;
+ rb_call_super(0, 0);
+ rb_scan_args(argc, argv, "11*", &svr_name, &host, &others);
+
+ StringValue(svr_name);
+ if (rb_safe_level() > 0 && OBJ_TAINTED(svr_name)) {
+ rb_raise(rb_eSecurityError, "insecure object creation - `%s'",
+ StringValuePtr(svr_name));
+ }
+ if (!NIL_P(host)) {
+ StringValue(host);
+ if (rb_safe_level() > 0 && OBJ_TAINTED(host)) {
+ rb_raise(rb_eSecurityError, "insecure object creation - `%s'",
+ StringValuePtr(host));
+ }
+ return ole_create_dcom(self, svr_name, host, others);
+ }
+
+ /* get CLSID from OLE server name */
+ pBuf = ole_vstr2wc(svr_name);
+ hr = CLSIDFromProgID(pBuf, &clsid);
+ if(FAILED(hr)) {
+ hr = CLSIDFromString(pBuf, &clsid);
+ }
+ SysFreeString(pBuf);
+ if(FAILED(hr)) {
+ ole_raise(hr, eWIN32OLERuntimeError,
+ "unknown OLE server: `%s'",
+ StringValuePtr(svr_name));
+ }
+
+ /* get IDispatch interface */
+ hr = CoCreateInstance(&clsid, NULL, CLSCTX_INPROC_SERVER | CLSCTX_LOCAL_SERVER,
+ &IID_IDispatch, &p);
+ pDispatch = p;
+ if(FAILED(hr)) {
+ ole_raise(hr, eWIN32OLERuntimeError,
+ "failed to create WIN32OLE object from `%s'",
+ StringValuePtr(svr_name));
+ }
+
+ ole_set_member(self, pDispatch);
+ return self;
+}
+
+static int
+hash2named_arg(VALUE key, VALUE val, VALUE pop)
+{
+ struct oleparam* pOp = (struct oleparam *)pop;
+ unsigned int index, i;
+ index = pOp->dp.cNamedArgs;
+ /*---------------------------------------------
+ the data-type of key must be String or Symbol
+ -----------------------------------------------*/
+ if(!RB_TYPE_P(key, T_STRING) && !RB_TYPE_P(key, T_SYMBOL)) {
+ /* clear name of dispatch parameters */
+ for(i = 1; i < index + 1; i++) {
+ SysFreeString(pOp->pNamedArgs[i]);
+ }
+ /* clear dispatch parameters */
+ for(i = 0; i < index; i++ ) {
+ VariantClear(&(pOp->dp.rgvarg[i]));
+ }
+ /* raise an exception */
+ rb_raise(rb_eTypeError, "wrong argument type (expected String or Symbol)");
+ }
+ if (RB_TYPE_P(key, T_SYMBOL)) {
+ key = rb_sym_to_s(key);
+ }
+
+ /* pNamedArgs[0] is <method name>, so "index + 1" */
+ pOp->pNamedArgs[index + 1] = ole_vstr2wc(key);
+
+ VariantInit(&(pOp->dp.rgvarg[index]));
+ ole_val2variant(val, &(pOp->dp.rgvarg[index]));
+
+ pOp->dp.cNamedArgs += 1;
+ return ST_CONTINUE;
+}
+
+static VALUE
+set_argv(VARIANTARG* realargs, unsigned int beg, unsigned int end)
+{
+ VALUE argv = rb_const_get(cWIN32OLE, rb_intern("ARGV"));
+
+ Check_Type(argv, T_ARRAY);
+ rb_ary_clear(argv);
+ while (end-- > beg) {
+ rb_ary_push(argv, ole_variant2val(&realargs[end]));
+ if (V_VT(&realargs[end]) != VT_RECORD) {
+ VariantClear(&realargs[end]);
+ }
+ }
+ return argv;
+}
+
+static VALUE
+ole_invoke(int argc, VALUE *argv, VALUE self, USHORT wFlags, BOOL is_bracket)
+{
+ LCID lcid = cWIN32OLE_lcid;
+ struct oledata *pole = NULL;
+ HRESULT hr;
+ VALUE cmd;
+ VALUE paramS;
+ VALUE param;
+ VALUE obj;
+ VALUE v;
+
+ BSTR wcmdname;
+
+ DISPID DispID;
+ DISPID* pDispID;
+ EXCEPINFO excepinfo;
+ VARIANT result;
+ VARIANTARG* realargs = NULL;
+ unsigned int argErr = 0;
+ unsigned int i;
+ unsigned int cNamedArgs;
+ int n;
+ struct oleparam op;
+ memset(&excepinfo, 0, sizeof(EXCEPINFO));
+
+ VariantInit(&result);
+
+ op.dp.rgvarg = NULL;
+ op.dp.rgdispidNamedArgs = NULL;
+ op.dp.cNamedArgs = 0;
+ op.dp.cArgs = 0;
+
+ rb_scan_args(argc, argv, "1*", &cmd, &paramS);
+ if(!RB_TYPE_P(cmd, T_STRING) && !RB_TYPE_P(cmd, T_SYMBOL) && !is_bracket) {
+ rb_raise(rb_eTypeError, "method is wrong type (expected String or Symbol)");
+ }
+ if (RB_TYPE_P(cmd, T_SYMBOL)) {
+ cmd = rb_sym_to_s(cmd);
+ }
+ pole = oledata_get_struct(self);
+ if(!pole->pDispatch) {
+ rb_raise(rb_eRuntimeError, "failed to get dispatch interface");
+ }
+ if (is_bracket) {
+ DispID = DISPID_VALUE;
+ argc += 1;
+ rb_ary_unshift(paramS, cmd);
+ } else {
+ wcmdname = ole_vstr2wc(cmd);
+ hr = pole->pDispatch->lpVtbl->GetIDsOfNames( pole->pDispatch, &IID_NULL,
+ &wcmdname, 1, lcid, &DispID);
+ SysFreeString(wcmdname);
+ if(FAILED(hr)) {
+ ole_raise(hr, rb_eNoMethodError,
+ "unknown property or method: `%s'",
+ StringValuePtr(cmd));
+ }
+ }
+
+ /* pick up last argument of method */
+ param = rb_ary_entry(paramS, argc-2);
+
+ op.dp.cNamedArgs = 0;
+
+ /* if last arg is hash object */
+ if(RB_TYPE_P(param, T_HASH)) {
+ /*------------------------------------------
+ hash object ==> named dispatch parameters
+ --------------------------------------------*/
+ cNamedArgs = rb_long2int(RHASH_SIZE(param));
+ op.dp.cArgs = cNamedArgs + argc - 2;
+ op.pNamedArgs = ALLOCA_N(OLECHAR*, cNamedArgs + 1);
+ op.dp.rgvarg = ALLOCA_N(VARIANTARG, op.dp.cArgs);
+
+ rb_hash_foreach(param, hash2named_arg, (VALUE)&op);
+
+ pDispID = ALLOCA_N(DISPID, cNamedArgs + 1);
+ op.pNamedArgs[0] = ole_vstr2wc(cmd);
+ hr = pole->pDispatch->lpVtbl->GetIDsOfNames(pole->pDispatch,
+ &IID_NULL,
+ op.pNamedArgs,
+ op.dp.cNamedArgs + 1,
+ lcid, pDispID);
+ for(i = 0; i < op.dp.cNamedArgs + 1; i++) {
+ SysFreeString(op.pNamedArgs[i]);
+ op.pNamedArgs[i] = NULL;
+ }
+ if(FAILED(hr)) {
+ /* clear dispatch parameters */
+ for(i = 0; i < op.dp.cArgs; i++ ) {
+ VariantClear(&op.dp.rgvarg[i]);
+ }
+ ole_raise(hr, eWIN32OLERuntimeError,
+ "failed to get named argument info: `%s'",
+ StringValuePtr(cmd));
+ }
+ op.dp.rgdispidNamedArgs = &(pDispID[1]);
+ }
+ else {
+ cNamedArgs = 0;
+ op.dp.cArgs = argc - 1;
+ op.pNamedArgs = ALLOCA_N(OLECHAR*, cNamedArgs + 1);
+ if (op.dp.cArgs > 0) {
+ op.dp.rgvarg = ALLOCA_N(VARIANTARG, op.dp.cArgs);
+ }
+ }
+ /*--------------------------------------
+ non hash args ==> dispatch parameters
+ ----------------------------------------*/
+ if(op.dp.cArgs > cNamedArgs) {
+ realargs = ALLOCA_N(VARIANTARG, op.dp.cArgs-cNamedArgs+1);
+ for(i = cNamedArgs; i < op.dp.cArgs; i++) {
+ n = op.dp.cArgs - i + cNamedArgs - 1;
+ VariantInit(&realargs[n]);
+ VariantInit(&op.dp.rgvarg[n]);
+ param = rb_ary_entry(paramS, i-cNamedArgs);
+ if (rb_obj_is_kind_of(param, cWIN32OLE_VARIANT)) {
+ ole_variant2variant(param, &op.dp.rgvarg[n]);
+ } else if (rb_obj_is_kind_of(param, cWIN32OLE_RECORD)) {
+ ole_val2variant(param, &realargs[n]);
+ op.dp.rgvarg[n] = realargs[n];
+ V_VT(&op.dp.rgvarg[n]) = VT_RECORD | VT_BYREF;
+ } else {
+ ole_val2variant(param, &realargs[n]);
+ V_VT(&op.dp.rgvarg[n]) = VT_VARIANT | VT_BYREF;
+ V_VARIANTREF(&op.dp.rgvarg[n]) = &realargs[n];
+ }
+ }
+ }
+ /* apparent you need to call propput, you need this */
+ if (wFlags & DISPATCH_PROPERTYPUT) {
+ if (op.dp.cArgs == 0)
+ ole_raise(ResultFromScode(E_INVALIDARG), eWIN32OLERuntimeError, "argument error");
+
+ op.dp.cNamedArgs = 1;
+ op.dp.rgdispidNamedArgs = ALLOCA_N( DISPID, 1 );
+ op.dp.rgdispidNamedArgs[0] = DISPID_PROPERTYPUT;
+ }
+ hr = pole->pDispatch->lpVtbl->Invoke(pole->pDispatch, DispID,
+ &IID_NULL, lcid, wFlags, &op.dp,
+ &result, &excepinfo, &argErr);
+
+ if (FAILED(hr)) {
+ /* retry to call args by value */
+ if(op.dp.cArgs >= cNamedArgs) {
+ for(i = cNamedArgs; i < op.dp.cArgs; i++) {
+ n = op.dp.cArgs - i + cNamedArgs - 1;
+ param = rb_ary_entry(paramS, i-cNamedArgs);
+ ole_val2variant(param, &op.dp.rgvarg[n]);
+ }
+ if (hr == DISP_E_EXCEPTION) {
+ ole_freeexceptinfo(&excepinfo);
+ }
+ memset(&excepinfo, 0, sizeof(EXCEPINFO));
+ VariantInit(&result);
+ hr = pole->pDispatch->lpVtbl->Invoke(pole->pDispatch, DispID,
+ &IID_NULL, lcid, wFlags,
+ &op.dp, &result,
+ &excepinfo, &argErr);
+
+ /* mega kludge. if a method in WORD is called and we ask
+ * for a result when one is not returned then
+ * hResult == DISP_E_EXCEPTION. this only happens on
+ * functions whose DISPID > 0x8000 */
+ if ((hr == DISP_E_EXCEPTION || hr == DISP_E_MEMBERNOTFOUND) && DispID > 0x8000) {
+ if (hr == DISP_E_EXCEPTION) {
+ ole_freeexceptinfo(&excepinfo);
+ }
+ memset(&excepinfo, 0, sizeof(EXCEPINFO));
+ hr = pole->pDispatch->lpVtbl->Invoke(pole->pDispatch, DispID,
+ &IID_NULL, lcid, wFlags,
+ &op.dp, NULL,
+ &excepinfo, &argErr);
+
+ }
+ for(i = cNamedArgs; i < op.dp.cArgs; i++) {
+ n = op.dp.cArgs - i + cNamedArgs - 1;
+ if (V_VT(&op.dp.rgvarg[n]) != VT_RECORD) {
+ VariantClear(&op.dp.rgvarg[n]);
+ }
+ }
+ }
+
+ if (FAILED(hr)) {
+ /* retry after converting nil to VT_EMPTY */
+ if (op.dp.cArgs > cNamedArgs) {
+ for(i = cNamedArgs; i < op.dp.cArgs; i++) {
+ n = op.dp.cArgs - i + cNamedArgs - 1;
+ param = rb_ary_entry(paramS, i-cNamedArgs);
+ ole_val2variant2(param, &op.dp.rgvarg[n]);
+ }
+ if (hr == DISP_E_EXCEPTION) {
+ ole_freeexceptinfo(&excepinfo);
+ }
+ memset(&excepinfo, 0, sizeof(EXCEPINFO));
+ VariantInit(&result);
+ hr = pole->pDispatch->lpVtbl->Invoke(pole->pDispatch, DispID,
+ &IID_NULL, lcid, wFlags,
+ &op.dp, &result,
+ &excepinfo, &argErr);
+ for(i = cNamedArgs; i < op.dp.cArgs; i++) {
+ n = op.dp.cArgs - i + cNamedArgs - 1;
+ if (V_VT(&op.dp.rgvarg[n]) != VT_RECORD) {
+ VariantClear(&op.dp.rgvarg[n]);
+ }
+ }
+ }
+ }
+
+ }
+ /* clear dispatch parameter */
+ if(op.dp.cArgs > cNamedArgs) {
+ for(i = cNamedArgs; i < op.dp.cArgs; i++) {
+ n = op.dp.cArgs - i + cNamedArgs - 1;
+ param = rb_ary_entry(paramS, i-cNamedArgs);
+ if (rb_obj_is_kind_of(param, cWIN32OLE_VARIANT)) {
+ ole_val2variant(param, &realargs[n]);
+ } else if ( rb_obj_is_kind_of(param, cWIN32OLE_RECORD) &&
+ V_VT(&realargs[n]) == VT_RECORD ) {
+ olerecord_set_ivar(param, V_RECORDINFO(&realargs[n]), V_RECORD(&realargs[n]));
+ }
+ }
+ set_argv(realargs, cNamedArgs, op.dp.cArgs);
+ }
+ else {
+ for(i = 0; i < op.dp.cArgs; i++) {
+ VariantClear(&op.dp.rgvarg[i]);
+ }
+ }
+
+ if (FAILED(hr)) {
+ v = ole_excepinfo2msg(&excepinfo);
+ ole_raise(hr, eWIN32OLERuntimeError, "(in OLE method `%s': )%s",
+ StringValuePtr(cmd),
+ StringValuePtr(v));
+ }
+ obj = ole_variant2val(&result);
+ VariantClear(&result);
+ return obj;
+}
+
+/*
+ * call-seq:
+ * WIN32OLE#invoke(method, [arg1,...]) => return value of method.
+ *
+ * Runs OLE method.
+ * The first argument specifies the method name of OLE Automation object.
+ * The others specify argument of the <i>method</i>.
+ * If you can not execute <i>method</i> directly, then use this method instead.
+ *
+ * excel = WIN32OLE.new('Excel.Application')
+ * excel.invoke('Quit') # => same as excel.Quit
+ *
+ */
+static VALUE
+fole_invoke(int argc, VALUE *argv, VALUE self)
+{
+ return ole_invoke(argc, argv, self, DISPATCH_METHOD|DISPATCH_PROPERTYGET, FALSE);
+}
+
+static VALUE
+ole_invoke2(VALUE self, VALUE dispid, VALUE args, VALUE types, USHORT dispkind)
+{
+ HRESULT hr;
+ struct oledata *pole = NULL;
+ unsigned int argErr = 0;
+ EXCEPINFO excepinfo;
+ VARIANT result;
+ DISPPARAMS dispParams;
+ VARIANTARG* realargs = NULL;
+ int i, j;
+ VALUE obj = Qnil;
+ VALUE tp, param;
+ VALUE v;
+ VARTYPE vt;
+
+ Check_Type(args, T_ARRAY);
+ Check_Type(types, T_ARRAY);
+
+ memset(&excepinfo, 0, sizeof(EXCEPINFO));
+ memset(&dispParams, 0, sizeof(DISPPARAMS));
+ VariantInit(&result);
+ pole = oledata_get_struct(self);
+
+ dispParams.cArgs = RARRAY_LEN(args);
+ dispParams.rgvarg = ALLOCA_N(VARIANTARG, dispParams.cArgs);
+ realargs = ALLOCA_N(VARIANTARG, dispParams.cArgs);
+ for (i = 0, j = dispParams.cArgs - 1; i < (int)dispParams.cArgs; i++, j--)
+ {
+ VariantInit(&realargs[i]);
+ VariantInit(&dispParams.rgvarg[i]);
+ tp = rb_ary_entry(types, j);
+ vt = (VARTYPE)FIX2INT(tp);
+ V_VT(&dispParams.rgvarg[i]) = vt;
+ param = rb_ary_entry(args, j);
+ if (param == Qnil)
+ {
+
+ V_VT(&dispParams.rgvarg[i]) = V_VT(&realargs[i]) = VT_ERROR;
+ V_ERROR(&dispParams.rgvarg[i]) = V_ERROR(&realargs[i]) = DISP_E_PARAMNOTFOUND;
+ }
+ else
+ {
+ if (vt & VT_ARRAY)
+ {
+ int ent;
+ LPBYTE pb;
+ short* ps;
+ LPLONG pl;
+ VARIANT* pv;
+ CY *py;
+ VARTYPE v;
+ SAFEARRAYBOUND rgsabound[1];
+ Check_Type(param, T_ARRAY);
+ rgsabound[0].lLbound = 0;
+ rgsabound[0].cElements = RARRAY_LEN(param);
+ v = vt & ~(VT_ARRAY | VT_BYREF);
+ V_ARRAY(&realargs[i]) = SafeArrayCreate(v, 1, rgsabound);
+ V_VT(&realargs[i]) = VT_ARRAY | v;
+ SafeArrayLock(V_ARRAY(&realargs[i]));
+ pb = V_ARRAY(&realargs[i])->pvData;
+ ps = V_ARRAY(&realargs[i])->pvData;
+ pl = V_ARRAY(&realargs[i])->pvData;
+ py = V_ARRAY(&realargs[i])->pvData;
+ pv = V_ARRAY(&realargs[i])->pvData;
+ for (ent = 0; ent < (int)rgsabound[0].cElements; ent++)
+ {
+ VARIANT velem;
+ VALUE elem = rb_ary_entry(param, ent);
+ ole_val2variant(elem, &velem);
+ if (v != VT_VARIANT)
+ {
+ VariantChangeTypeEx(&velem, &velem,
+ cWIN32OLE_lcid, 0, v);
+ }
+ switch (v)
+ {
+ /* 128 bits */
+ case VT_VARIANT:
+ *pv++ = velem;
+ break;
+ /* 64 bits */
+ case VT_R8:
+ case VT_CY:
+ case VT_DATE:
+ *py++ = V_CY(&velem);
+ break;
+ /* 16 bits */
+ case VT_BOOL:
+ case VT_I2:
+ case VT_UI2:
+ *ps++ = V_I2(&velem);
+ break;
+ /* 8 bites */
+ case VT_UI1:
+ case VT_I1:
+ *pb++ = V_UI1(&velem);
+ break;
+ /* 32 bits */
+ default:
+ *pl++ = V_I4(&velem);
+ break;
+ }
+ }
+ SafeArrayUnlock(V_ARRAY(&realargs[i]));
+ }
+ else
+ {
+ ole_val2variant(param, &realargs[i]);
+ if ((vt & (~VT_BYREF)) != VT_VARIANT)
+ {
+ hr = VariantChangeTypeEx(&realargs[i], &realargs[i],
+ cWIN32OLE_lcid, 0,
+ (VARTYPE)(vt & (~VT_BYREF)));
+ if (hr != S_OK)
+ {
+ rb_raise(rb_eTypeError, "not valid value");
+ }
+ }
+ }
+ if ((vt & VT_BYREF) || vt == VT_VARIANT)
+ {
+ if (vt == VT_VARIANT)
+ V_VT(&dispParams.rgvarg[i]) = VT_VARIANT | VT_BYREF;
+ switch (vt & (~VT_BYREF))
+ {
+ /* 128 bits */
+ case VT_VARIANT:
+ V_VARIANTREF(&dispParams.rgvarg[i]) = &realargs[i];
+ break;
+ /* 64 bits */
+ case VT_R8:
+ case VT_CY:
+ case VT_DATE:
+ V_CYREF(&dispParams.rgvarg[i]) = &V_CY(&realargs[i]);
+ break;
+ /* 16 bits */
+ case VT_BOOL:
+ case VT_I2:
+ case VT_UI2:
+ V_I2REF(&dispParams.rgvarg[i]) = &V_I2(&realargs[i]);
+ break;
+ /* 8 bites */
+ case VT_UI1:
+ case VT_I1:
+ V_UI1REF(&dispParams.rgvarg[i]) = &V_UI1(&realargs[i]);
+ break;
+ /* 32 bits */
+ default:
+ V_I4REF(&dispParams.rgvarg[i]) = &V_I4(&realargs[i]);
+ break;
+ }
+ }
+ else
+ {
+ /* copy 64 bits of data */
+ V_CY(&dispParams.rgvarg[i]) = V_CY(&realargs[i]);
+ }
+ }
+ }
+
+ if (dispkind & DISPATCH_PROPERTYPUT) {
+ dispParams.cNamedArgs = 1;
+ dispParams.rgdispidNamedArgs = ALLOCA_N( DISPID, 1 );
+ dispParams.rgdispidNamedArgs[0] = DISPID_PROPERTYPUT;
+ }
+
+ hr = pole->pDispatch->lpVtbl->Invoke(pole->pDispatch, NUM2INT(dispid),
+ &IID_NULL, cWIN32OLE_lcid,
+ dispkind,
+ &dispParams, &result,
+ &excepinfo, &argErr);
+
+ if (FAILED(hr)) {
+ v = ole_excepinfo2msg(&excepinfo);
+ ole_raise(hr, eWIN32OLERuntimeError, "(in OLE method `<dispatch id:%d>': )%s",
+ NUM2INT(dispid),
+ StringValuePtr(v));
+ }
+
+ /* clear dispatch parameter */
+ if(dispParams.cArgs > 0) {
+ set_argv(realargs, 0, dispParams.cArgs);
+ }
+
+ obj = ole_variant2val(&result);
+ VariantClear(&result);
+ return obj;
+}
+
+/*
+ * call-seq:
+ * WIN32OLE#_invoke(dispid, args, types)
+ *
+ * Runs the early binding method.
+ * The 1st argument specifies dispatch ID,
+ * the 2nd argument specifies the array of arguments,
+ * the 3rd argument specifies the array of the type of arguments.
+ *
+ * excel = WIN32OLE.new('Excel.Application')
+ * excel._invoke(302, [], []) # same effect as excel.Quit
+ */
+static VALUE
+fole_invoke2(VALUE self, VALUE dispid, VALUE args, VALUE types)
+{
+ return ole_invoke2(self, dispid, args, types, DISPATCH_METHOD);
+}
+
+/*
+ * call-seq:
+ * WIN32OLE#_getproperty(dispid, args, types)
+ *
+ * Runs the early binding method to get property.
+ * The 1st argument specifies dispatch ID,
+ * the 2nd argument specifies the array of arguments,
+ * the 3rd argument specifies the array of the type of arguments.
+ *
+ * excel = WIN32OLE.new('Excel.Application')
+ * puts excel._getproperty(558, [], []) # same effect as puts excel.visible
+ */
+static VALUE
+fole_getproperty2(VALUE self, VALUE dispid, VALUE args, VALUE types)
+{
+ return ole_invoke2(self, dispid, args, types, DISPATCH_PROPERTYGET);
+}
+
+/*
+ * call-seq:
+ * WIN32OLE#_setproperty(dispid, args, types)
+ *
+ * Runs the early binding method to set property.
+ * The 1st argument specifies dispatch ID,
+ * the 2nd argument specifies the array of arguments,
+ * the 3rd argument specifies the array of the type of arguments.
+ *
+ * excel = WIN32OLE.new('Excel.Application')
+ * excel._setproperty(558, [true], [WIN32OLE::VARIANT::VT_BOOL]) # same effect as excel.visible = true
+ */
+static VALUE
+fole_setproperty2(VALUE self, VALUE dispid, VALUE args, VALUE types)
+{
+ return ole_invoke2(self, dispid, args, types, DISPATCH_PROPERTYPUT);
+}
+
+/*
+ * call-seq:
+ * WIN32OLE[a1, a2, ...]=val
+ *
+ * Sets the value to WIN32OLE object specified by a1, a2, ...
+ *
+ * dict = WIN32OLE.new('Scripting.Dictionary')
+ * dict.add('ruby', 'RUBY')
+ * dict['ruby'] = 'Ruby'
+ * puts dict['ruby'] # => 'Ruby'
+ *
+ * Remark: You can not use this method to set the property value.
+ *
+ * excel = WIN32OLE.new('Excel.Application')
+ * # excel['Visible'] = true # This is error !!!
+ * excel.Visible = true # You should to use this style to set the property.
+ *
+ */
+static VALUE
+fole_setproperty_with_bracket(int argc, VALUE *argv, VALUE self)
+{
+ return ole_invoke(argc, argv, self, DISPATCH_PROPERTYPUT, TRUE);
+}
+
+/*
+ * call-seq:
+ * WIN32OLE.setproperty('property', [arg1, arg2,...] val)
+ *
+ * Sets property of OLE object.
+ * When you want to set property with argument, you can use this method.
+ *
+ * excel = WIN32OLE.new('Excel.Application')
+ * excel.Visible = true
+ * book = excel.workbooks.add
+ * sheet = book.worksheets(1)
+ * sheet.setproperty('Cells', 1, 2, 10) # => The B1 cell value is 10.
+ */
+static VALUE
+fole_setproperty(int argc, VALUE *argv, VALUE self)
+{
+ return ole_invoke(argc, argv, self, DISPATCH_PROPERTYPUT, FALSE);
+}
+
+/*
+ * call-seq:
+ * WIN32OLE[a1,a2,...]
+ *
+ * Returns the value of Collection specified by a1, a2,....
+ *
+ * dict = WIN32OLE.new('Scripting.Dictionary')
+ * dict.add('ruby', 'Ruby')
+ * puts dict['ruby'] # => 'Ruby' (same as `puts dict.item('ruby')')
+ *
+ * Remark: You can not use this method to get the property.
+ * excel = WIN32OLE.new('Excel.Application')
+ * # puts excel['Visible'] This is error !!!
+ * puts excel.Visible # You should to use this style to get the property.
+ *
+ */
+static VALUE
+fole_getproperty_with_bracket(int argc, VALUE *argv, VALUE self)
+{
+ return ole_invoke(argc, argv, self, DISPATCH_PROPERTYGET, TRUE);
+}
+
+static VALUE
+ole_propertyput(VALUE self, VALUE property, VALUE value)
+{
+ struct oledata *pole = NULL;
+ unsigned argErr;
+ unsigned int index;
+ HRESULT hr;
+ EXCEPINFO excepinfo;
+ DISPID dispID = DISPID_VALUE;
+ DISPID dispIDParam = DISPID_PROPERTYPUT;
+ USHORT wFlags = DISPATCH_PROPERTYPUT|DISPATCH_PROPERTYPUTREF;
+ DISPPARAMS dispParams;
+ VARIANTARG propertyValue[2];
+ OLECHAR* pBuf[1];
+ VALUE v;
+ LCID lcid = cWIN32OLE_lcid;
+ dispParams.rgdispidNamedArgs = &dispIDParam;
+ dispParams.rgvarg = propertyValue;
+ dispParams.cNamedArgs = 1;
+ dispParams.cArgs = 1;
+
+ VariantInit(&propertyValue[0]);
+ VariantInit(&propertyValue[1]);
+ memset(&excepinfo, 0, sizeof(excepinfo));
+
+ pole = oledata_get_struct(self);
+
+ /* get ID from property name */
+ pBuf[0] = ole_vstr2wc(property);
+ hr = pole->pDispatch->lpVtbl->GetIDsOfNames(pole->pDispatch, &IID_NULL,
+ pBuf, 1, lcid, &dispID);
+ SysFreeString(pBuf[0]);
+ pBuf[0] = NULL;
+
+ if(FAILED(hr)) {
+ ole_raise(hr, eWIN32OLERuntimeError,
+ "unknown property or method: `%s'",
+ StringValuePtr(property));
+ }
+ /* set property value */
+ ole_val2variant(value, &propertyValue[0]);
+ hr = pole->pDispatch->lpVtbl->Invoke(pole->pDispatch, dispID, &IID_NULL,
+ lcid, wFlags, &dispParams,
+ NULL, &excepinfo, &argErr);
+
+ for(index = 0; index < dispParams.cArgs; ++index) {
+ VariantClear(&propertyValue[index]);
+ }
+ if (FAILED(hr)) {
+ v = ole_excepinfo2msg(&excepinfo);
+ ole_raise(hr, eWIN32OLERuntimeError, "(in setting property `%s': )%s",
+ StringValuePtr(property),
+ StringValuePtr(v));
+ }
+ return Qnil;
+}
+
+/*
+ * call-seq:
+ * WIN32OLE#ole_free
+ *
+ * invokes Release method of Dispatch interface of WIN32OLE object.
+ * Usually, you do not need to call this method because Release method
+ * called automatically when WIN32OLE object garbaged.
+ *
+ */
+static VALUE
+fole_free(VALUE self)
+{
+ struct oledata *pole = NULL;
+ pole = oledata_get_struct(self);
+ OLE_FREE(pole->pDispatch);
+ pole->pDispatch = NULL;
+ return Qnil;
+}
+
+static VALUE
+ole_each_sub(VALUE pEnumV)
+{
+ VARIANT variant;
+ VALUE obj = Qnil;
+ IEnumVARIANT *pEnum = (IEnumVARIANT *)pEnumV;
+ VariantInit(&variant);
+ while(pEnum->lpVtbl->Next(pEnum, 1, &variant, NULL) == S_OK) {
+ obj = ole_variant2val(&variant);
+ VariantClear(&variant);
+ VariantInit(&variant);
+ rb_yield(obj);
+ }
+ return Qnil;
+}
+
+static VALUE
+ole_ienum_free(VALUE pEnumV)
+{
+ IEnumVARIANT *pEnum = (IEnumVARIANT *)pEnumV;
+ OLE_RELEASE(pEnum);
+ return Qnil;
+}
+
+/*
+ * call-seq:
+ * WIN32OLE#each {|i|...}
+ *
+ * Iterates over each item of OLE collection which has IEnumVARIANT interface.
+ *
+ * excel = WIN32OLE.new('Excel.Application')
+ * book = excel.workbooks.add
+ * sheets = book.worksheets(1)
+ * cells = sheets.cells("A1:A5")
+ * cells.each do |cell|
+ * cell.value = 10
+ * end
+ */
+static VALUE
+fole_each(VALUE self)
+{
+ LCID lcid = cWIN32OLE_lcid;
+
+ struct oledata *pole = NULL;
+
+ unsigned int argErr;
+ EXCEPINFO excepinfo;
+ DISPPARAMS dispParams;
+ VARIANT result;
+ HRESULT hr;
+ IEnumVARIANT *pEnum = NULL;
+ void *p;
+
+ RETURN_ENUMERATOR(self, 0, 0);
+
+ VariantInit(&result);
+ dispParams.rgvarg = NULL;
+ dispParams.rgdispidNamedArgs = NULL;
+ dispParams.cNamedArgs = 0;
+ dispParams.cArgs = 0;
+ memset(&excepinfo, 0, sizeof(excepinfo));
+
+ pole = oledata_get_struct(self);
+ hr = pole->pDispatch->lpVtbl->Invoke(pole->pDispatch, DISPID_NEWENUM,
+ &IID_NULL, lcid,
+ DISPATCH_METHOD | DISPATCH_PROPERTYGET,
+ &dispParams, &result,
+ &excepinfo, &argErr);
+
+ if (FAILED(hr)) {
+ VariantClear(&result);
+ ole_raise(hr, eWIN32OLERuntimeError, "failed to get IEnum Interface");
+ }
+
+ if (V_VT(&result) == VT_UNKNOWN) {
+ hr = V_UNKNOWN(&result)->lpVtbl->QueryInterface(V_UNKNOWN(&result),
+ &IID_IEnumVARIANT,
+ &p);
+ pEnum = p;
+ } else if (V_VT(&result) == VT_DISPATCH) {
+ hr = V_DISPATCH(&result)->lpVtbl->QueryInterface(V_DISPATCH(&result),
+ &IID_IEnumVARIANT,
+ &p);
+ pEnum = p;
+ }
+ if (FAILED(hr) || !pEnum) {
+ VariantClear(&result);
+ ole_raise(hr, rb_eRuntimeError, "failed to get IEnum Interface");
+ }
+
+ VariantClear(&result);
+ rb_ensure(ole_each_sub, (VALUE)pEnum, ole_ienum_free, (VALUE)pEnum);
+ return Qnil;
+}
+
+/*
+ * call-seq:
+ * WIN32OLE#method_missing(id [,arg1, arg2, ...])
+ *
+ * Calls WIN32OLE#invoke method.
+ */
+static VALUE
+fole_missing(int argc, VALUE *argv, VALUE self)
+{
+ ID id;
+ const char* mname;
+ size_t n;
+ rb_check_arity(argc, 1, UNLIMITED_ARGUMENTS);
+ id = rb_to_id(argv[0]);
+ mname = rb_id2name(id);
+ if(!mname) {
+ rb_raise(rb_eRuntimeError, "fail: unknown method or property");
+ }
+ n = strlen(mname);
+#if SIZEOF_SIZE_T > SIZEOF_LONG
+ if (n >= LONG_MAX) {
+ rb_raise(rb_eRuntimeError, "too long method or property name");
+ }
+#endif
+ if(mname[n-1] == '=') {
+ rb_check_arity(argc, 2, 2);
+ argv[0] = rb_enc_str_new(mname, (long)(n-1), cWIN32OLE_enc);
+
+ return ole_propertyput(self, argv[0], argv[1]);
+ }
+ else {
+ argv[0] = rb_enc_str_new(mname, (long)n, cWIN32OLE_enc);
+ return ole_invoke(argc, argv, self, DISPATCH_METHOD|DISPATCH_PROPERTYGET, FALSE);
+ }
+}
+
+static HRESULT
+typeinfo_from_ole(struct oledata *pole, ITypeInfo **ppti)
+{
+ ITypeInfo *pTypeInfo;
+ ITypeLib *pTypeLib;
+ BSTR bstr;
+ VALUE type;
+ UINT i;
+ UINT count;
+ LCID lcid = cWIN32OLE_lcid;
+ HRESULT hr = pole->pDispatch->lpVtbl->GetTypeInfo(pole->pDispatch,
+ 0, lcid, &pTypeInfo);
+ if(FAILED(hr)) {
+ ole_raise(hr, rb_eRuntimeError, "failed to GetTypeInfo");
+ }
+ hr = pTypeInfo->lpVtbl->GetDocumentation(pTypeInfo,
+ -1,
+ &bstr,
+ NULL, NULL, NULL);
+ type = WC2VSTR(bstr);
+ hr = pTypeInfo->lpVtbl->GetContainingTypeLib(pTypeInfo, &pTypeLib, &i);
+ OLE_RELEASE(pTypeInfo);
+ if (FAILED(hr)) {
+ ole_raise(hr, rb_eRuntimeError, "failed to GetContainingTypeLib");
+ }
+ count = pTypeLib->lpVtbl->GetTypeInfoCount(pTypeLib);
+ for (i = 0; i < count; i++) {
+ hr = pTypeLib->lpVtbl->GetDocumentation(pTypeLib, i,
+ &bstr, NULL, NULL, NULL);
+ if (SUCCEEDED(hr) && rb_str_cmp(WC2VSTR(bstr), type) == 0) {
+ hr = pTypeLib->lpVtbl->GetTypeInfo(pTypeLib, i, &pTypeInfo);
+ if (SUCCEEDED(hr)) {
+ *ppti = pTypeInfo;
+ break;
+ }
+ }
+ }
+ OLE_RELEASE(pTypeLib);
+ return hr;
+}
+
+static VALUE
+ole_methods(VALUE self, int mask)
+{
+ ITypeInfo *pTypeInfo;
+ HRESULT hr;
+ VALUE methods;
+ struct oledata *pole = NULL;
+
+ pole = oledata_get_struct(self);
+ methods = rb_ary_new();
+
+ hr = typeinfo_from_ole(pole, &pTypeInfo);
+ if(FAILED(hr))
+ return methods;
+ rb_ary_concat(methods, ole_methods_from_typeinfo(pTypeInfo, mask));
+ OLE_RELEASE(pTypeInfo);
+ return methods;
+}
+
+/*
+ * call-seq:
+ * WIN32OLE#ole_methods
+ *
+ * Returns the array of WIN32OLE_METHOD object.
+ * The element is OLE method of WIN32OLE object.
+ *
+ * excel = WIN32OLE.new('Excel.Application')
+ * methods = excel.ole_methods
+ *
+ */
+static VALUE
+fole_methods(VALUE self)
+{
+ return ole_methods( self, INVOKE_FUNC | INVOKE_PROPERTYGET | INVOKE_PROPERTYPUT | INVOKE_PROPERTYPUTREF);
+}
+
+/*
+ * call-seq:
+ * WIN32OLE#ole_get_methods
+ *
+ * Returns the array of WIN32OLE_METHOD object .
+ * The element of the array is property (gettable) of WIN32OLE object.
+ *
+ * excel = WIN32OLE.new('Excel.Application')
+ * properties = excel.ole_get_methods
+ */
+static VALUE
+fole_get_methods(VALUE self)
+{
+ return ole_methods( self, INVOKE_PROPERTYGET);
+}
+
+/*
+ * call-seq:
+ * WIN32OLE#ole_put_methods
+ *
+ * Returns the array of WIN32OLE_METHOD object .
+ * The element of the array is property (settable) of WIN32OLE object.
+ *
+ * excel = WIN32OLE.new('Excel.Application')
+ * properties = excel.ole_put_methods
+ */
+static VALUE
+fole_put_methods(VALUE self)
+{
+ return ole_methods( self, INVOKE_PROPERTYPUT|INVOKE_PROPERTYPUTREF);
+}
+
+/*
+ * call-seq:
+ * WIN32OLE#ole_func_methods
+ *
+ * Returns the array of WIN32OLE_METHOD object .
+ * The element of the array is property (settable) of WIN32OLE object.
+ *
+ * excel = WIN32OLE.new('Excel.Application')
+ * properties = excel.ole_func_methods
+ *
+ */
+static VALUE
+fole_func_methods(VALUE self)
+{
+ return ole_methods( self, INVOKE_FUNC);
+}
+
+/*
+ * call-seq:
+ * WIN32OLE#ole_type
+ *
+ * Returns WIN32OLE_TYPE object.
+ *
+ * excel = WIN32OLE.new('Excel.Application')
+ * tobj = excel.ole_type
+ */
+static VALUE
+fole_type(VALUE self)
+{
+ ITypeInfo *pTypeInfo;
+ HRESULT hr;
+ struct oledata *pole = NULL;
+ LCID lcid = cWIN32OLE_lcid;
+ VALUE type = Qnil;
+
+ pole = oledata_get_struct(self);
+
+ hr = pole->pDispatch->lpVtbl->GetTypeInfo( pole->pDispatch, 0, lcid, &pTypeInfo );
+ if(FAILED(hr)) {
+ ole_raise(hr, rb_eRuntimeError, "failed to GetTypeInfo");
+ }
+ type = ole_type_from_itypeinfo(pTypeInfo);
+ OLE_RELEASE(pTypeInfo);
+ if (type == Qnil) {
+ rb_raise(rb_eRuntimeError, "failed to create WIN32OLE_TYPE obj from ITypeInfo");
+ }
+ return type;
+}
+
+/*
+ * call-seq:
+ * WIN32OLE#ole_typelib -> The WIN32OLE_TYPELIB object
+ *
+ * Returns the WIN32OLE_TYPELIB object. The object represents the
+ * type library which contains the WIN32OLE object.
+ *
+ * excel = WIN32OLE.new('Excel.Application')
+ * tlib = excel.ole_typelib
+ * puts tlib.name # -> 'Microsoft Excel 9.0 Object Library'
+ */
+static VALUE
+fole_typelib(VALUE self)
+{
+ struct oledata *pole = NULL;
+ HRESULT hr;
+ ITypeInfo *pTypeInfo;
+ LCID lcid = cWIN32OLE_lcid;
+ VALUE vtlib = Qnil;
+
+ pole = oledata_get_struct(self);
+ hr = pole->pDispatch->lpVtbl->GetTypeInfo(pole->pDispatch,
+ 0, lcid, &pTypeInfo);
+ if(FAILED(hr)) {
+ ole_raise(hr, rb_eRuntimeError, "failed to GetTypeInfo");
+ }
+ vtlib = ole_typelib_from_itypeinfo(pTypeInfo);
+ OLE_RELEASE(pTypeInfo);
+ if (vtlib == Qnil) {
+ rb_raise(rb_eRuntimeError, "failed to get type library info.");
+ }
+ return vtlib;
+}
+
+/*
+ * call-seq:
+ * WIN32OLE#ole_query_interface(iid) -> WIN32OLE object
+ *
+ * Returns WIN32OLE object for a specific dispatch or dual
+ * interface specified by iid.
+ *
+ * ie = WIN32OLE.new('InternetExplorer.Application')
+ * ie_web_app = ie.ole_query_interface('{0002DF05-0000-0000-C000-000000000046}') # => WIN32OLE object for dispinterface IWebBrowserApp
+ */
+static VALUE
+fole_query_interface(VALUE self, VALUE str_iid)
+{
+ HRESULT hr;
+ OLECHAR *pBuf;
+ IID iid;
+ struct oledata *pole = NULL;
+ IDispatch *pDispatch;
+ void *p;
+
+ pBuf = ole_vstr2wc(str_iid);
+ hr = CLSIDFromString(pBuf, &iid);
+ SysFreeString(pBuf);
+ if(FAILED(hr)) {
+ ole_raise(hr, eWIN32OLERuntimeError,
+ "invalid iid: `%s'",
+ StringValuePtr(str_iid));
+ }
+
+ pole = oledata_get_struct(self);
+ if(!pole->pDispatch) {
+ rb_raise(rb_eRuntimeError, "failed to get dispatch interface");
+ }
+
+ hr = pole->pDispatch->lpVtbl->QueryInterface(pole->pDispatch, &iid,
+ &p);
+ if(FAILED(hr)) {
+ ole_raise(hr, eWIN32OLERuntimeError,
+ "failed to get interface `%s'",
+ StringValuePtr(str_iid));
+ }
+
+ pDispatch = p;
+ return create_win32ole_object(cWIN32OLE, pDispatch, 0, 0);
+}
+
+/*
+ * call-seq:
+ * WIN32OLE#ole_respond_to?(method) -> true or false
+ *
+ * Returns true when OLE object has OLE method, otherwise returns false.
+ *
+ * ie = WIN32OLE.new('InternetExplorer.Application')
+ * ie.ole_respond_to?("gohome") => true
+ */
+static VALUE
+fole_respond_to(VALUE self, VALUE method)
+{
+ struct oledata *pole = NULL;
+ BSTR wcmdname;
+ DISPID DispID;
+ HRESULT hr;
+ if(!RB_TYPE_P(method, T_STRING) && !RB_TYPE_P(method, T_SYMBOL)) {
+ rb_raise(rb_eTypeError, "wrong argument type (expected String or Symbol)");
+ }
+ if (RB_TYPE_P(method, T_SYMBOL)) {
+ method = rb_sym_to_s(method);
+ }
+ pole = oledata_get_struct(self);
+ wcmdname = ole_vstr2wc(method);
+ hr = pole->pDispatch->lpVtbl->GetIDsOfNames( pole->pDispatch, &IID_NULL,
+ &wcmdname, 1, cWIN32OLE_lcid, &DispID);
+ SysFreeString(wcmdname);
+ return SUCCEEDED(hr) ? Qtrue : Qfalse;
+}
+
+HRESULT
+ole_docinfo_from_type(ITypeInfo *pTypeInfo, BSTR *name, BSTR *helpstr, DWORD *helpcontext, BSTR *helpfile)
+{
+ HRESULT hr;
+ ITypeLib *pTypeLib;
+ UINT i;
+
+ hr = pTypeInfo->lpVtbl->GetContainingTypeLib(pTypeInfo, &pTypeLib, &i);
+ if (FAILED(hr)) {
+ return hr;
+ }
+
+ hr = pTypeLib->lpVtbl->GetDocumentation(pTypeLib, i,
+ name, helpstr,
+ helpcontext, helpfile);
+ if (FAILED(hr)) {
+ OLE_RELEASE(pTypeLib);
+ return hr;
+ }
+ OLE_RELEASE(pTypeLib);
+ return hr;
+}
+
+static VALUE
+ole_usertype2val(ITypeInfo *pTypeInfo, TYPEDESC *pTypeDesc, VALUE typedetails)
+{
+ HRESULT hr;
+ BSTR bstr;
+ ITypeInfo *pRefTypeInfo;
+ VALUE type = Qnil;
+
+ hr = pTypeInfo->lpVtbl->GetRefTypeInfo(pTypeInfo,
+ V_UNION1(pTypeDesc, hreftype),
+ &pRefTypeInfo);
+ if(FAILED(hr))
+ return Qnil;
+ hr = ole_docinfo_from_type(pRefTypeInfo, &bstr, NULL, NULL, NULL);
+ if(FAILED(hr)) {
+ OLE_RELEASE(pRefTypeInfo);
+ return Qnil;
+ }
+ OLE_RELEASE(pRefTypeInfo);
+ type = WC2VSTR(bstr);
+ if(typedetails != Qnil)
+ rb_ary_push(typedetails, type);
+ return type;
+}
+
+static VALUE
+ole_ptrtype2val(ITypeInfo *pTypeInfo, TYPEDESC *pTypeDesc, VALUE typedetails)
+{
+ TYPEDESC *p = pTypeDesc;
+ VALUE type = rb_str_new2("");
+
+ if (p->vt == VT_PTR || p->vt == VT_SAFEARRAY) {
+ p = V_UNION1(p, lptdesc);
+ type = ole_typedesc2val(pTypeInfo, p, typedetails);
+ }
+ return type;
+}
+
+VALUE
+ole_typedesc2val(ITypeInfo *pTypeInfo, TYPEDESC *pTypeDesc, VALUE typedetails)
+{
+ VALUE str;
+ VALUE typestr = Qnil;
+ switch(pTypeDesc->vt) {
+ case VT_I2:
+ typestr = rb_str_new2("I2");
+ break;
+ case VT_I4:
+ typestr = rb_str_new2("I4");
+ break;
+ case VT_R4:
+ typestr = rb_str_new2("R4");
+ break;
+ case VT_R8:
+ typestr = rb_str_new2("R8");
+ break;
+ case VT_CY:
+ typestr = rb_str_new2("CY");
+ break;
+ case VT_DATE:
+ typestr = rb_str_new2("DATE");
+ break;
+ case VT_BSTR:
+ typestr = rb_str_new2("BSTR");
+ break;
+ case VT_BOOL:
+ typestr = rb_str_new2("BOOL");
+ break;
+ case VT_VARIANT:
+ typestr = rb_str_new2("VARIANT");
+ break;
+ case VT_DECIMAL:
+ typestr = rb_str_new2("DECIMAL");
+ break;
+ case VT_I1:
+ typestr = rb_str_new2("I1");
+ break;
+ case VT_UI1:
+ typestr = rb_str_new2("UI1");
+ break;
+ case VT_UI2:
+ typestr = rb_str_new2("UI2");
+ break;
+ case VT_UI4:
+ typestr = rb_str_new2("UI4");
+ break;
+#if (_MSC_VER >= 1300) || defined(__CYGWIN__) || defined(__MINGW32__)
+ case VT_I8:
+ typestr = rb_str_new2("I8");
+ break;
+ case VT_UI8:
+ typestr = rb_str_new2("UI8");
+ break;
+#endif
+ case VT_INT:
+ typestr = rb_str_new2("INT");
+ break;
+ case VT_UINT:
+ typestr = rb_str_new2("UINT");
+ break;
+ case VT_VOID:
+ typestr = rb_str_new2("VOID");
+ break;
+ case VT_HRESULT:
+ typestr = rb_str_new2("HRESULT");
+ break;
+ case VT_PTR:
+ typestr = rb_str_new2("PTR");
+ if(typedetails != Qnil)
+ rb_ary_push(typedetails, typestr);
+ return ole_ptrtype2val(pTypeInfo, pTypeDesc, typedetails);
+ case VT_SAFEARRAY:
+ typestr = rb_str_new2("SAFEARRAY");
+ if(typedetails != Qnil)
+ rb_ary_push(typedetails, typestr);
+ return ole_ptrtype2val(pTypeInfo, pTypeDesc, typedetails);
+ case VT_CARRAY:
+ typestr = rb_str_new2("CARRAY");
+ break;
+ case VT_USERDEFINED:
+ typestr = rb_str_new2("USERDEFINED");
+ if (typedetails != Qnil)
+ rb_ary_push(typedetails, typestr);
+ str = ole_usertype2val(pTypeInfo, pTypeDesc, typedetails);
+ if (str != Qnil) {
+ return str;
+ }
+ return typestr;
+ case VT_UNKNOWN:
+ typestr = rb_str_new2("UNKNOWN");
+ break;
+ case VT_DISPATCH:
+ typestr = rb_str_new2("DISPATCH");
+ break;
+ case VT_ERROR:
+ typestr = rb_str_new2("ERROR");
+ break;
+ case VT_LPWSTR:
+ typestr = rb_str_new2("LPWSTR");
+ break;
+ case VT_LPSTR:
+ typestr = rb_str_new2("LPSTR");
+ break;
+ case VT_RECORD:
+ typestr = rb_str_new2("RECORD");
+ break;
+ default:
+ typestr = rb_str_new2("Unknown Type ");
+ rb_str_concat(typestr, rb_fix2str(INT2FIX(pTypeDesc->vt), 10));
+ break;
+ }
+ if (typedetails != Qnil)
+ rb_ary_push(typedetails, typestr);
+ return typestr;
+}
+
+/*
+ * call-seq:
+ * WIN32OLE#ole_method_help(method)
+ *
+ * Returns WIN32OLE_METHOD object corresponding with method
+ * specified by 1st argument.
+ *
+ * excel = WIN32OLE.new('Excel.Application')
+ * method = excel.ole_method_help('Quit')
+ *
+ */
+static VALUE
+fole_method_help(VALUE self, VALUE cmdname)
+{
+ ITypeInfo *pTypeInfo;
+ HRESULT hr;
+ struct oledata *pole = NULL;
+ VALUE obj;
+
+ SafeStringValue(cmdname);
+ pole = oledata_get_struct(self);
+ hr = typeinfo_from_ole(pole, &pTypeInfo);
+ if(FAILED(hr))
+ ole_raise(hr, rb_eRuntimeError, "failed to get ITypeInfo");
+
+ obj = create_win32ole_method(pTypeInfo, cmdname);
+
+ OLE_RELEASE(pTypeInfo);
+ if (obj == Qnil)
+ rb_raise(eWIN32OLERuntimeError, "not found %s",
+ StringValuePtr(cmdname));
+ return obj;
+}
+
+/*
+ * call-seq:
+ * WIN32OLE#ole_activex_initialize() -> Qnil
+ *
+ * Initialize WIN32OLE object(ActiveX Control) by calling
+ * IPersistMemory::InitNew.
+ *
+ * Before calling OLE method, some kind of the ActiveX controls
+ * created with MFC should be initialized by calling
+ * IPersistXXX::InitNew.
+ *
+ * If and only if you received the exception "HRESULT error code:
+ * 0x8000ffff catastrophic failure", try this method before
+ * invoking any ole_method.
+ *
+ * obj = WIN32OLE.new("ProgID_or_GUID_of_ActiveX_Control")
+ * obj.ole_activex_initialize
+ * obj.method(...)
+ *
+ */
+static VALUE
+fole_activex_initialize(VALUE self)
+{
+ struct oledata *pole = NULL;
+ IPersistMemory *pPersistMemory;
+ void *p;
+
+ HRESULT hr = S_OK;
+
+ pole = oledata_get_struct(self);
+
+ hr = pole->pDispatch->lpVtbl->QueryInterface(pole->pDispatch, &IID_IPersistMemory, &p);
+ pPersistMemory = p;
+ if (SUCCEEDED(hr)) {
+ hr = pPersistMemory->lpVtbl->InitNew(pPersistMemory);
+ OLE_RELEASE(pPersistMemory);
+ if (SUCCEEDED(hr)) {
+ return Qnil;
+ }
+ }
+
+ if (FAILED(hr)) {
+ ole_raise(hr, eWIN32OLERuntimeError, "fail to initialize ActiveX control");
+ }
+
+ return Qnil;
+}
+
+HRESULT
+typelib_from_val(VALUE obj, ITypeLib **pTypeLib)
+{
+ LCID lcid = cWIN32OLE_lcid;
+ HRESULT hr;
+ struct oledata *pole = NULL;
+ unsigned int index;
+ ITypeInfo *pTypeInfo;
+ pole = oledata_get_struct(obj);
+ hr = pole->pDispatch->lpVtbl->GetTypeInfo(pole->pDispatch,
+ 0, lcid, &pTypeInfo);
+ if (FAILED(hr)) {
+ return hr;
+ }
+ hr = pTypeInfo->lpVtbl->GetContainingTypeLib(pTypeInfo, pTypeLib, &index);
+ OLE_RELEASE(pTypeInfo);
+ return hr;
+}
+
+static void
+init_enc2cp(void)
+{
+ enc2cp_table = st_init_numtable();
+}
+
+static void
+free_enc2cp(void)
+{
+ st_free_table(enc2cp_table);
+}
+
+static void
+com_hash_free(void *ptr)
+{
+ st_table *tbl = ptr;
+ st_free_table(tbl);
+}
+
+static void
+com_hash_mark(void *ptr)
+{
+ st_table *tbl = ptr;
+ rb_mark_hash(tbl);
+}
+
+static size_t
+com_hash_size(const void *ptr)
+{
+ const st_table *tbl = ptr;
+ return tbl ? st_memsize(tbl) : 0;
+}
+
+void
+Init_win32ole(void)
+{
+ cWIN32OLE_lcid = LOCALE_SYSTEM_DEFAULT;
+ g_ole_initialized_init();
+
+ com_vtbl.QueryInterface = QueryInterface;
+ com_vtbl.AddRef = AddRef;
+ com_vtbl.Release = Release;
+ com_vtbl.GetTypeInfoCount = GetTypeInfoCount;
+ com_vtbl.GetTypeInfo = GetTypeInfo;
+ com_vtbl.GetIDsOfNames = GetIDsOfNames;
+ com_vtbl.Invoke = Invoke;
+
+ message_filter.QueryInterface = mf_QueryInterface;
+ message_filter.AddRef = mf_AddRef;
+ message_filter.Release = mf_Release;
+ message_filter.HandleInComingCall = mf_HandleInComingCall;
+ message_filter.RetryRejectedCall = mf_RetryRejectedCall;
+ message_filter.MessagePending = mf_MessagePending;
+
+ com_hash = TypedData_Wrap_Struct(rb_cData, &com_hash_datatype, st_init_numtable());
+ rb_gc_register_mark_object(com_hash);
+
+ cWIN32OLE = rb_define_class("WIN32OLE", rb_cObject);
+
+ rb_define_alloc_func(cWIN32OLE, fole_s_allocate);
+
+ rb_define_method(cWIN32OLE, "initialize", fole_initialize, -1);
+
+ rb_define_singleton_method(cWIN32OLE, "connect", fole_s_connect, -1);
+ rb_define_singleton_method(cWIN32OLE, "const_load", fole_s_const_load, -1);
+
+ rb_define_singleton_method(cWIN32OLE, "ole_free", fole_s_free, 1);
+ rb_define_singleton_method(cWIN32OLE, "ole_reference_count", fole_s_reference_count, 1);
+ rb_define_singleton_method(cWIN32OLE, "ole_show_help", fole_s_show_help, -1);
+ rb_define_singleton_method(cWIN32OLE, "codepage", fole_s_get_code_page, 0);
+ rb_define_singleton_method(cWIN32OLE, "codepage=", fole_s_set_code_page, 1);
+ rb_define_singleton_method(cWIN32OLE, "locale", fole_s_get_locale, 0);
+ rb_define_singleton_method(cWIN32OLE, "locale=", fole_s_set_locale, 1);
+ rb_define_singleton_method(cWIN32OLE, "create_guid", fole_s_create_guid, 0);
+ rb_define_singleton_method(cWIN32OLE, "ole_initialize", fole_s_ole_initialize, 0);
+ rb_define_singleton_method(cWIN32OLE, "ole_uninitialize", fole_s_ole_uninitialize, 0);
+
+ rb_define_method(cWIN32OLE, "invoke", fole_invoke, -1);
+ rb_define_method(cWIN32OLE, "[]", fole_getproperty_with_bracket, -1);
+ rb_define_method(cWIN32OLE, "_invoke", fole_invoke2, 3);
+ rb_define_method(cWIN32OLE, "_getproperty", fole_getproperty2, 3);
+ rb_define_method(cWIN32OLE, "_setproperty", fole_setproperty2, 3);
+
+ /* support propput method that takes an argument */
+ rb_define_method(cWIN32OLE, "[]=", fole_setproperty_with_bracket, -1);
+
+ rb_define_method(cWIN32OLE, "ole_free", fole_free, 0);
+
+ rb_define_method(cWIN32OLE, "each", fole_each, 0);
+ rb_define_method(cWIN32OLE, "method_missing", fole_missing, -1);
+
+ /* support setproperty method much like Perl ;-) */
+ rb_define_method(cWIN32OLE, "setproperty", fole_setproperty, -1);
+
+ rb_define_method(cWIN32OLE, "ole_methods", fole_methods, 0);
+ rb_define_method(cWIN32OLE, "ole_get_methods", fole_get_methods, 0);
+ rb_define_method(cWIN32OLE, "ole_put_methods", fole_put_methods, 0);
+ rb_define_method(cWIN32OLE, "ole_func_methods", fole_func_methods, 0);
+
+ rb_define_method(cWIN32OLE, "ole_method", fole_method_help, 1);
+ rb_define_alias(cWIN32OLE, "ole_method_help", "ole_method");
+ rb_define_method(cWIN32OLE, "ole_activex_initialize", fole_activex_initialize, 0);
+ rb_define_method(cWIN32OLE, "ole_type", fole_type, 0);
+ rb_define_alias(cWIN32OLE, "ole_obj_help", "ole_type");
+ rb_define_method(cWIN32OLE, "ole_typelib", fole_typelib, 0);
+ rb_define_method(cWIN32OLE, "ole_query_interface", fole_query_interface, 1);
+ rb_define_method(cWIN32OLE, "ole_respond_to?", fole_respond_to, 1);
+
+ /* Constants definition */
+
+ /*
+ * Version string of WIN32OLE.
+ */
+ rb_define_const(cWIN32OLE, "VERSION", rb_str_new2(WIN32OLE_VERSION));
+
+ /*
+ * After invoking OLE methods with reference arguments, you can access
+ * the value of arguments by using ARGV.
+ *
+ * If the method of OLE(COM) server written by C#.NET is following:
+ *
+ * void calcsum(int a, int b, out int c) {
+ * c = a + b;
+ * }
+ *
+ * then, the Ruby OLE(COM) client script to retrieve the value of
+ * argument c after invoking calcsum method is following:
+ *
+ * a = 10
+ * b = 20
+ * c = 0
+ * comserver.calcsum(a, b, c)
+ * p c # => 0
+ * p WIN32OLE::ARGV # => [10, 20, 30]
+ *
+ * You can use WIN32OLE_VARIANT object to retrieve the value of reference
+ * arguments instead of refering WIN32OLE::ARGV.
+ *
+ */
+ rb_define_const(cWIN32OLE, "ARGV", rb_ary_new());
+
+ /*
+ * 0: ANSI code page. See WIN32OLE.codepage and WIN32OLE.codepage=.
+ */
+ rb_define_const(cWIN32OLE, "CP_ACP", INT2FIX(CP_ACP));
+
+ /*
+ * 1: OEM code page. See WIN32OLE.codepage and WIN32OLE.codepage=.
+ */
+ rb_define_const(cWIN32OLE, "CP_OEMCP", INT2FIX(CP_OEMCP));
+
+ /*
+ * 2
+ */
+ rb_define_const(cWIN32OLE, "CP_MACCP", INT2FIX(CP_MACCP));
+
+ /*
+ * 3: current thread ANSI code page. See WIN32OLE.codepage and
+ * WIN32OLE.codepage=.
+ */
+ rb_define_const(cWIN32OLE, "CP_THREAD_ACP", INT2FIX(CP_THREAD_ACP));
+
+ /*
+ * 42: symbol code page. See WIN32OLE.codepage and WIN32OLE.codepage=.
+ */
+ rb_define_const(cWIN32OLE, "CP_SYMBOL", INT2FIX(CP_SYMBOL));
+
+ /*
+ * 65000: UTF-7 code page. See WIN32OLE.codepage and WIN32OLE.codepage=.
+ */
+ rb_define_const(cWIN32OLE, "CP_UTF7", INT2FIX(CP_UTF7));
+
+ /*
+ * 65001: UTF-8 code page. See WIN32OLE.codepage and WIN32OLE.codepage=.
+ */
+ rb_define_const(cWIN32OLE, "CP_UTF8", INT2FIX(CP_UTF8));
+
+ /*
+ * 0x0800: default locale for the operating system. See WIN32OLE.locale
+ * and WIN32OLE.locale=.
+ */
+ rb_define_const(cWIN32OLE, "LOCALE_SYSTEM_DEFAULT", INT2FIX(LOCALE_SYSTEM_DEFAULT));
+
+ /*
+ * 0x0400: default locale for the user or process. See WIN32OLE.locale
+ * and WIN32OLE.locale=.
+ */
+ rb_define_const(cWIN32OLE, "LOCALE_USER_DEFAULT", INT2FIX(LOCALE_USER_DEFAULT));
+
+ Init_win32ole_variant_m();
+ Init_win32ole_typelib();
+ Init_win32ole_type();
+ Init_win32ole_variable();
+ Init_win32ole_method();
+ Init_win32ole_param();
+ Init_win32ole_event();
+ Init_win32ole_variant();
+ Init_win32ole_record();
+ Init_win32ole_error();
+
+ init_enc2cp();
+ atexit((void (*)(void))free_enc2cp);
+ ole_init_cp();
+}
diff --git a/jni/ruby/ext/win32ole/win32ole.h b/jni/ruby/ext/win32ole/win32ole.h
new file mode 100644
index 0000000..d61f5e2
--- /dev/null
+++ b/jni/ruby/ext/win32ole/win32ole.h
@@ -0,0 +1,155 @@
+#ifndef WIN32OLE_H
+#define WIN32OLE_H 1
+#include "ruby/ruby.h"
+#include "ruby/st.h"
+#include "ruby/encoding.h"
+
+#define GNUC_OLDER_3_4_4 \
+ ((__GNUC__ < 3) || \
+ ((__GNUC__ <= 3) && (__GNUC_MINOR__ < 4)) || \
+ ((__GNUC__ <= 3) && (__GNUC_MINOR__ <= 4) && (__GNUC_PATCHLEVEL__ <= 4)))
+
+#if (defined(__GNUC__)) && (GNUC_OLDER_3_4_4)
+#ifndef NONAMELESSUNION
+#define NONAMELESSUNION 1
+#endif
+#endif
+
+#include <ctype.h>
+
+#include <windows.h>
+#include <ocidl.h>
+#include <olectl.h>
+#include <ole2.h>
+#if defined(HAVE_TYPE_IMULTILANGUAGE2) || defined(HAVE_TYPE_IMULTILANGUAGE)
+#include <mlang.h>
+#endif
+#include <stdlib.h>
+#include <math.h>
+#ifdef HAVE_STDARG_PROTOTYPES
+#include <stdarg.h>
+#define va_init_list(a,b) va_start(a,b)
+#else
+#include <varargs.h>
+#define va_init_list(a,b) va_start(a)
+#endif
+#include <objidl.h>
+
+#define DOUT fprintf(stderr,"%s(%d)\n", __FILE__, __LINE__)
+#define DOUTS(x) fprintf(stderr,"%s(%d):" #x "=%s\n",__FILE__, __LINE__,x)
+#define DOUTMSG(x) fprintf(stderr, "%s(%d):" #x "\n",__FILE__, __LINE__)
+#define DOUTI(x) fprintf(stderr, "%s(%d):" #x "=%d\n",__FILE__, __LINE__,x)
+#define DOUTD(x) fprintf(stderr, "%s(%d):" #x "=%f\n",__FILE__, __LINE__,x)
+
+#if (defined(__GNUC__)) && (GNUC_OLDER_3_4_4)
+#define V_UNION1(X, Y) ((X)->u.Y)
+#else
+#define V_UNION1(X, Y) ((X)->Y)
+#endif
+
+#if (defined(__GNUC__)) && (GNUC_OLDER_3_4_4)
+#undef V_UNION
+#define V_UNION(X,Y) ((X)->n1.n2.n3.Y)
+
+#undef V_VT
+#define V_VT(X) ((X)->n1.n2.vt)
+
+#undef V_BOOL
+#define V_BOOL(X) V_UNION(X,boolVal)
+#endif
+
+#ifndef V_I1REF
+#define V_I1REF(X) V_UNION(X, pcVal)
+#endif
+
+#ifndef V_UI2REF
+#define V_UI2REF(X) V_UNION(X, puiVal)
+#endif
+
+#ifndef V_INT
+#define V_INT(X) V_UNION(X, intVal)
+#endif
+
+#ifndef V_INTREF
+#define V_INTREF(X) V_UNION(X, pintVal)
+#endif
+
+#ifndef V_UINT
+#define V_UINT(X) V_UNION(X, uintVal)
+#endif
+
+#ifndef V_UINTREF
+#define V_UINTREF(X) V_UNION(X, puintVal)
+#endif
+
+#ifdef HAVE_LONG_LONG
+#define I8_2_NUM LL2NUM
+#define UI8_2_NUM ULL2NUM
+#define NUM2I8 NUM2LL
+#define NUM2UI8 NUM2ULL
+#else
+#define I8_2_NUM INT2NUM
+#define UI8_2_NUM UINT2NUM
+#define NUM2I8 NUM2INT
+#define NUM2UI8 NUM2UINT
+#endif
+
+#define OLE_ADDREF(X) (X) ? ((X)->lpVtbl->AddRef(X)) : 0
+#define OLE_RELEASE(X) (X) ? ((X)->lpVtbl->Release(X)) : 0
+#define OLE_FREE(x) {\
+ if(ole_initialized() == TRUE) {\
+ if(x) {\
+ OLE_RELEASE(x);\
+ (x) = 0;\
+ }\
+ }\
+}
+
+#define OLE_GET_TYPEATTR(X, Y) ((X)->lpVtbl->GetTypeAttr((X), (Y)))
+#define OLE_RELEASE_TYPEATTR(X, Y) ((X)->lpVtbl->ReleaseTypeAttr((X), (Y)))
+
+struct oledata {
+ IDispatch *pDispatch;
+};
+
+VALUE cWIN32OLE;
+LCID cWIN32OLE_lcid;
+
+struct oledata *oledata_get_struct(VALUE obj);
+LPWSTR ole_vstr2wc(VALUE vstr);
+LONG reg_open_key(HKEY hkey, const char *name, HKEY *phkey);
+LONG reg_open_vkey(HKEY hkey, VALUE key, HKEY *phkey);
+VALUE reg_enum_key(HKEY hkey, DWORD i);
+VALUE reg_get_val(HKEY hkey, const char *subkey);
+VALUE reg_get_val2(HKEY hkey, const char *subkey);
+void ole_initialize(void);
+VALUE default_inspect(VALUE self, const char *class_name);
+char *ole_wc2mb(LPWSTR pw);
+VALUE ole_wc2vstr(LPWSTR pw, BOOL isfree);
+
+#define WC2VSTR(x) ole_wc2vstr((x), TRUE)
+
+BOOL ole_initialized(void);
+HRESULT ole_docinfo_from_type(ITypeInfo *pTypeInfo, BSTR *name, BSTR *helpstr, DWORD *helpcontext, BSTR *helpfile);
+VALUE ole_typedesc2val(ITypeInfo *pTypeInfo, TYPEDESC *pTypeDesc, VALUE typedetails);
+VALUE make_inspect(const char *class_name, VALUE detail);
+void ole_val2variant(VALUE val, VARIANT *var);
+void ole_val2variant2(VALUE val, VARIANT *var);
+void ole_val2variant_ex(VALUE val, VARIANT *var, VARTYPE vt);
+VALUE ole_variant2val(VARIANT *pvar);
+HRESULT ole_val_ary2variant_ary(VALUE val, VARIANT *var, VARTYPE vt);
+VOID *val2variant_ptr(VALUE val, VARIANT *var, VARTYPE vt);
+HRESULT typelib_from_val(VALUE obj, ITypeLib **pTypeLib);
+
+#include "win32ole_variant_m.h"
+#include "win32ole_typelib.h"
+#include "win32ole_type.h"
+#include "win32ole_variable.h"
+#include "win32ole_method.h"
+#include "win32ole_param.h"
+#include "win32ole_event.h"
+#include "win32ole_variant.h"
+#include "win32ole_record.h"
+#include "win32ole_error.h"
+
+#endif
diff --git a/jni/ruby/ext/win32ole/win32ole_error.c b/jni/ruby/ext/win32ole/win32ole_error.c
new file mode 100644
index 0000000..62e69b1
--- /dev/null
+++ b/jni/ruby/ext/win32ole/win32ole_error.c
@@ -0,0 +1,83 @@
+#include "win32ole.h"
+
+static VALUE ole_hresult2msg(HRESULT hr);
+
+static VALUE
+ole_hresult2msg(HRESULT hr)
+{
+ VALUE msg = Qnil;
+ char *p_msg = NULL;
+ char *term = NULL;
+ DWORD dwCount;
+
+ char strhr[100];
+ sprintf(strhr, " HRESULT error code:0x%08x\n ", (unsigned)hr);
+ msg = rb_str_new2(strhr);
+ dwCount = FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER |
+ FORMAT_MESSAGE_FROM_SYSTEM |
+ FORMAT_MESSAGE_IGNORE_INSERTS,
+ NULL, hr,
+ MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US),
+ (LPTSTR)&p_msg, 0, NULL);
+ if (dwCount == 0) {
+ dwCount = FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER |
+ FORMAT_MESSAGE_FROM_SYSTEM |
+ FORMAT_MESSAGE_IGNORE_INSERTS,
+ NULL, hr, cWIN32OLE_lcid,
+ (LPTSTR)&p_msg, 0, NULL);
+ }
+ if (dwCount > 0) {
+ term = p_msg + strlen(p_msg);
+ while (p_msg < term) {
+ term--;
+ if (*term == '\r' || *term == '\n')
+ *term = '\0';
+ else break;
+ }
+ if (p_msg[0] != '\0') {
+ rb_str_cat2(msg, p_msg);
+ }
+ }
+ LocalFree(p_msg);
+ return msg;
+}
+
+void
+ole_raise(HRESULT hr, VALUE ecs, const char *fmt, ...)
+{
+ va_list args;
+ VALUE msg;
+ VALUE err_msg;
+ va_init_list(args, fmt);
+ msg = rb_vsprintf(fmt, args);
+ va_end(args);
+
+ err_msg = ole_hresult2msg(hr);
+ if(err_msg != Qnil) {
+ rb_str_cat2(msg, "\n");
+ rb_str_append(msg, err_msg);
+ }
+ rb_exc_raise(rb_exc_new_str(ecs, msg));
+}
+
+void
+Init_win32ole_error(void)
+{
+ /*
+ * Document-class: WIN32OLERuntimeError
+ *
+ * Raised when OLE processing failed.
+ *
+ * EX:
+ *
+ * obj = WIN32OLE.new("NonExistProgID")
+ *
+ * raises the exception:
+ *
+ * WIN32OLERuntimeError: unknown OLE server: `NonExistProgID'
+ * HRESULT error code:0x800401f3
+ * Invalid class string
+ *
+ */
+ eWIN32OLERuntimeError = rb_define_class("WIN32OLERuntimeError", rb_eRuntimeError);
+}
diff --git a/jni/ruby/ext/win32ole/win32ole_error.h b/jni/ruby/ext/win32ole/win32ole_error.h
new file mode 100644
index 0000000..5359646
--- /dev/null
+++ b/jni/ruby/ext/win32ole/win32ole_error.h
@@ -0,0 +1,8 @@
+#ifndef WIN32OLE_ERROR_H
+#define WIN32OLE_ERROR_H 1
+
+VALUE eWIN32OLERuntimeError;
+void ole_raise(HRESULT hr, VALUE ecs, const char *fmt, ...);
+void Init_win32ole_error(void);
+
+#endif
diff --git a/jni/ruby/ext/win32ole/win32ole_event.c b/jni/ruby/ext/win32ole/win32ole_event.c
new file mode 100644
index 0000000..105308a
--- /dev/null
+++ b/jni/ruby/ext/win32ole/win32ole_event.c
@@ -0,0 +1,1275 @@
+#include "win32ole.h"
+
+/*
+ * Document-class: WIN32OLE_EVENT
+ *
+ * <code>WIN32OLE_EVENT</code> objects controls OLE event.
+ */
+
+typedef struct {
+ struct IEventSinkVtbl * lpVtbl;
+} IEventSink, *PEVENTSINK;
+
+typedef struct IEventSinkVtbl IEventSinkVtbl;
+
+struct IEventSinkVtbl {
+ STDMETHOD(QueryInterface)(
+ PEVENTSINK,
+ REFIID,
+ LPVOID *);
+ STDMETHOD_(ULONG, AddRef)(PEVENTSINK);
+ STDMETHOD_(ULONG, Release)(PEVENTSINK);
+
+ STDMETHOD(GetTypeInfoCount)(
+ PEVENTSINK,
+ UINT *);
+ STDMETHOD(GetTypeInfo)(
+ PEVENTSINK,
+ UINT,
+ LCID,
+ ITypeInfo **);
+ STDMETHOD(GetIDsOfNames)(
+ PEVENTSINK,
+ REFIID,
+ OLECHAR **,
+ UINT,
+ LCID,
+ DISPID *);
+ STDMETHOD(Invoke)(
+ PEVENTSINK,
+ DISPID,
+ REFIID,
+ LCID,
+ WORD,
+ DISPPARAMS *,
+ VARIANT *,
+ EXCEPINFO *,
+ UINT *);
+};
+
+typedef struct tagIEVENTSINKOBJ {
+ IEventSinkVtbl *lpVtbl;
+ DWORD m_cRef;
+ IID m_iid;
+ long m_event_id;
+ ITypeInfo *pTypeInfo;
+}IEVENTSINKOBJ, *PIEVENTSINKOBJ;
+
+struct oleeventdata {
+ DWORD dwCookie;
+ IConnectionPoint *pConnectionPoint;
+ IDispatch *pDispatch;
+ long event_id;
+};
+
+static VALUE ary_ole_event;
+static ID id_events;
+
+VALUE cWIN32OLE_EVENT;
+
+static BOOL g_IsEventSinkVtblInitialized = FALSE;
+
+static IEventSinkVtbl vtEventSink;
+
+void EVENTSINK_Destructor(PIEVENTSINKOBJ);
+static void ole_val2ptr_variant(VALUE val, VARIANT *var);
+static void hash2ptr_dispparams(VALUE hash, ITypeInfo *pTypeInfo, DISPID dispid, DISPPARAMS *pdispparams);
+static VALUE hash2result(VALUE hash);
+static void ary2ptr_dispparams(VALUE ary, DISPPARAMS *pdispparams);
+static VALUE exec_callback(VALUE arg);
+static VALUE rescue_callback(VALUE arg);
+static HRESULT find_iid(VALUE ole, char *pitf, IID *piid, ITypeInfo **ppTypeInfo);
+static HRESULT find_coclass(ITypeInfo *pTypeInfo, TYPEATTR *pTypeAttr, ITypeInfo **pTypeInfo2, TYPEATTR **pTypeAttr2);
+static HRESULT find_default_source_from_typeinfo(ITypeInfo *pTypeInfo, TYPEATTR *pTypeAttr, ITypeInfo **ppTypeInfo);
+static HRESULT find_default_source(VALUE ole, IID *piid, ITypeInfo **ppTypeInfo);
+static long ole_search_event_at(VALUE ary, VALUE ev);
+static VALUE ole_search_event(VALUE ary, VALUE ev, BOOL *is_default);
+static VALUE ole_search_handler_method(VALUE handler, VALUE ev, BOOL *is_default_handler);
+static void ole_delete_event(VALUE ary, VALUE ev);
+static void oleevent_free(void *ptr);
+static size_t oleevent_size(const void *ptr);
+static VALUE fev_s_allocate(VALUE klass);
+static VALUE ev_advise(int argc, VALUE *argv, VALUE self);
+static VALUE fev_initialize(int argc, VALUE *argv, VALUE self);
+static void ole_msg_loop(void);
+static VALUE fev_s_msg_loop(VALUE klass);
+static void add_event_call_back(VALUE obj, VALUE event, VALUE data);
+static VALUE ev_on_event(int argc, VALUE *argv, VALUE self, VALUE is_ary_arg);
+static VALUE fev_on_event(int argc, VALUE *argv, VALUE self);
+static VALUE fev_on_event_with_outargs(int argc, VALUE *argv, VALUE self);
+static VALUE fev_off_event(int argc, VALUE *argv, VALUE self);
+static VALUE fev_unadvise(VALUE self);
+static VALUE fev_set_handler(VALUE self, VALUE val);
+static VALUE fev_get_handler(VALUE self);
+static VALUE evs_push(VALUE ev);
+static VALUE evs_delete(long i);
+static VALUE evs_entry(long i);
+static long evs_length(void);
+
+
+static const rb_data_type_t oleevent_datatype = {
+ "win32ole_event",
+ {NULL, oleevent_free, oleevent_size,},
+ 0, 0, RUBY_TYPED_FREE_IMMEDIATELY
+};
+
+STDMETHODIMP EVENTSINK_Invoke(
+ PEVENTSINK pEventSink,
+ DISPID dispid,
+ REFIID riid,
+ LCID lcid,
+ WORD wFlags,
+ DISPPARAMS *pdispparams,
+ VARIANT *pvarResult,
+ EXCEPINFO *pexcepinfo,
+ UINT *puArgErr
+ ) {
+
+ HRESULT hr;
+ BSTR bstr;
+ unsigned int count;
+ unsigned int i;
+ ITypeInfo *pTypeInfo;
+ VARIANT *pvar;
+ VALUE ary, obj, event, args, outargv, ev, result;
+ VALUE handler = Qnil;
+ VALUE arg[3];
+ VALUE mid;
+ VALUE is_outarg = Qfalse;
+ BOOL is_default_handler = FALSE;
+ int state;
+
+ PIEVENTSINKOBJ pEV = (PIEVENTSINKOBJ)pEventSink;
+ pTypeInfo = pEV->pTypeInfo;
+ obj = evs_entry(pEV->m_event_id);
+ if (!rb_obj_is_kind_of(obj, cWIN32OLE_EVENT)) {
+ return NOERROR;
+ }
+
+ ary = rb_ivar_get(obj, id_events);
+ if (NIL_P(ary) || !RB_TYPE_P(ary, T_ARRAY)) {
+ return NOERROR;
+ }
+ hr = pTypeInfo->lpVtbl->GetNames(pTypeInfo, dispid,
+ &bstr, 1, &count);
+ if (FAILED(hr)) {
+ return NOERROR;
+ }
+ ev = WC2VSTR(bstr);
+ event = ole_search_event(ary, ev, &is_default_handler);
+ if (RB_TYPE_P(event, T_ARRAY)) {
+ handler = rb_ary_entry(event, 0);
+ mid = rb_intern("call");
+ is_outarg = rb_ary_entry(event, 3);
+ } else {
+ handler = rb_ivar_get(obj, rb_intern("handler"));
+ if (handler == Qnil) {
+ return NOERROR;
+ }
+ mid = ole_search_handler_method(handler, ev, &is_default_handler);
+ }
+ if (handler == Qnil || mid == Qnil) {
+ return NOERROR;
+ }
+
+ args = rb_ary_new();
+ if (is_default_handler) {
+ rb_ary_push(args, ev);
+ }
+
+ /* make argument of event handler */
+ for (i = 0; i < pdispparams->cArgs; ++i) {
+ pvar = &pdispparams->rgvarg[pdispparams->cArgs-i-1];
+ rb_ary_push(args, ole_variant2val(pvar));
+ }
+ outargv = Qnil;
+ if (is_outarg == Qtrue) {
+ outargv = rb_ary_new();
+ rb_ary_push(args, outargv);
+ }
+
+ /*
+ * if exception raised in event callback,
+ * then you receive cfp consistency error.
+ * to avoid this error we use begin rescue end.
+ * and the exception raised then error message print
+ * and exit ruby process by Win32OLE itself.
+ */
+ arg[0] = handler;
+ arg[1] = mid;
+ arg[2] = args;
+ result = rb_protect(exec_callback, (VALUE)arg, &state);
+ if (state != 0) {
+ rescue_callback(Qnil);
+ }
+ if(RB_TYPE_P(result, T_HASH)) {
+ hash2ptr_dispparams(result, pTypeInfo, dispid, pdispparams);
+ result = hash2result(result);
+ }else if (is_outarg == Qtrue && RB_TYPE_P(outargv, T_ARRAY)) {
+ ary2ptr_dispparams(outargv, pdispparams);
+ }
+
+ if (pvarResult) {
+ VariantInit(pvarResult);
+ ole_val2variant(result, pvarResult);
+ }
+
+ return NOERROR;
+}
+
+STDMETHODIMP
+EVENTSINK_QueryInterface(
+ PEVENTSINK pEV,
+ REFIID iid,
+ LPVOID* ppv
+ ) {
+ if (IsEqualIID(iid, &IID_IUnknown) ||
+ IsEqualIID(iid, &IID_IDispatch) ||
+ IsEqualIID(iid, &((PIEVENTSINKOBJ)pEV)->m_iid)) {
+ *ppv = pEV;
+ }
+ else {
+ *ppv = NULL;
+ return E_NOINTERFACE;
+ }
+ ((LPUNKNOWN)*ppv)->lpVtbl->AddRef((LPUNKNOWN)*ppv);
+ return NOERROR;
+}
+
+STDMETHODIMP_(ULONG)
+EVENTSINK_AddRef(
+ PEVENTSINK pEV
+ ){
+ PIEVENTSINKOBJ pEVObj = (PIEVENTSINKOBJ)pEV;
+ return ++pEVObj->m_cRef;
+}
+
+STDMETHODIMP_(ULONG) EVENTSINK_Release(
+ PEVENTSINK pEV
+ ) {
+ PIEVENTSINKOBJ pEVObj = (PIEVENTSINKOBJ)pEV;
+ --pEVObj->m_cRef;
+ if(pEVObj->m_cRef != 0)
+ return pEVObj->m_cRef;
+ EVENTSINK_Destructor(pEVObj);
+ return 0;
+}
+
+STDMETHODIMP EVENTSINK_GetTypeInfoCount(
+ PEVENTSINK pEV,
+ UINT *pct
+ ) {
+ *pct = 0;
+ return NOERROR;
+}
+
+STDMETHODIMP EVENTSINK_GetTypeInfo(
+ PEVENTSINK pEV,
+ UINT info,
+ LCID lcid,
+ ITypeInfo **pInfo
+ ) {
+ *pInfo = NULL;
+ return DISP_E_BADINDEX;
+}
+
+STDMETHODIMP EVENTSINK_GetIDsOfNames(
+ PEVENTSINK pEventSink,
+ REFIID riid,
+ OLECHAR **szNames,
+ UINT cNames,
+ LCID lcid,
+ DISPID *pDispID
+ ) {
+ ITypeInfo *pTypeInfo;
+ PIEVENTSINKOBJ pEV = (PIEVENTSINKOBJ)pEventSink;
+ pTypeInfo = pEV->pTypeInfo;
+ if (pTypeInfo) {
+ return pTypeInfo->lpVtbl->GetIDsOfNames(pTypeInfo, szNames, cNames, pDispID);
+ }
+ return DISP_E_UNKNOWNNAME;
+}
+
+PIEVENTSINKOBJ
+EVENTSINK_Constructor(void)
+{
+ PIEVENTSINKOBJ pEv;
+ if (!g_IsEventSinkVtblInitialized) {
+ vtEventSink.QueryInterface=EVENTSINK_QueryInterface;
+ vtEventSink.AddRef = EVENTSINK_AddRef;
+ vtEventSink.Release = EVENTSINK_Release;
+ vtEventSink.Invoke = EVENTSINK_Invoke;
+ vtEventSink.GetIDsOfNames = EVENTSINK_GetIDsOfNames;
+ vtEventSink.GetTypeInfoCount = EVENTSINK_GetTypeInfoCount;
+ vtEventSink.GetTypeInfo = EVENTSINK_GetTypeInfo;
+
+ g_IsEventSinkVtblInitialized = TRUE;
+ }
+ pEv = ALLOC_N(IEVENTSINKOBJ, 1);
+ if(pEv == NULL) return NULL;
+ pEv->lpVtbl = &vtEventSink;
+ pEv->m_cRef = 0;
+ pEv->m_event_id = 0;
+ pEv->pTypeInfo = NULL;
+ return pEv;
+}
+
+void
+EVENTSINK_Destructor(
+ PIEVENTSINKOBJ pEVObj
+ ) {
+ if(pEVObj != NULL) {
+ OLE_RELEASE(pEVObj->pTypeInfo);
+ free(pEVObj);
+ pEVObj = NULL;
+ }
+}
+
+static void
+ole_val2ptr_variant(VALUE val, VARIANT *var)
+{
+ switch (TYPE(val)) {
+ case T_STRING:
+ if (V_VT(var) == (VT_BSTR | VT_BYREF)) {
+ *V_BSTRREF(var) = ole_vstr2wc(val);
+ }
+ break;
+ case T_FIXNUM:
+ switch(V_VT(var)) {
+ case (VT_UI1 | VT_BYREF) :
+ *V_UI1REF(var) = NUM2CHR(val);
+ break;
+ case (VT_I2 | VT_BYREF) :
+ *V_I2REF(var) = (short)NUM2INT(val);
+ break;
+ case (VT_I4 | VT_BYREF) :
+ *V_I4REF(var) = NUM2INT(val);
+ break;
+ case (VT_R4 | VT_BYREF) :
+ *V_R4REF(var) = (float)NUM2INT(val);
+ break;
+ case (VT_R8 | VT_BYREF) :
+ *V_R8REF(var) = NUM2INT(val);
+ break;
+ default:
+ break;
+ }
+ break;
+ case T_FLOAT:
+ switch(V_VT(var)) {
+ case (VT_I2 | VT_BYREF) :
+ *V_I2REF(var) = (short)NUM2INT(val);
+ break;
+ case (VT_I4 | VT_BYREF) :
+ *V_I4REF(var) = NUM2INT(val);
+ break;
+ case (VT_R4 | VT_BYREF) :
+ *V_R4REF(var) = (float)NUM2DBL(val);
+ break;
+ case (VT_R8 | VT_BYREF) :
+ *V_R8REF(var) = NUM2DBL(val);
+ break;
+ default:
+ break;
+ }
+ break;
+ case T_BIGNUM:
+ if (V_VT(var) == (VT_R8 | VT_BYREF)) {
+ *V_R8REF(var) = rb_big2dbl(val);
+ }
+ break;
+ case T_TRUE:
+ if (V_VT(var) == (VT_BOOL | VT_BYREF)) {
+ *V_BOOLREF(var) = VARIANT_TRUE;
+ }
+ break;
+ case T_FALSE:
+ if (V_VT(var) == (VT_BOOL | VT_BYREF)) {
+ *V_BOOLREF(var) = VARIANT_FALSE;
+ }
+ break;
+ default:
+ break;
+ }
+}
+
+static void
+hash2ptr_dispparams(VALUE hash, ITypeInfo *pTypeInfo, DISPID dispid, DISPPARAMS *pdispparams)
+{
+ BSTR *bstrs;
+ HRESULT hr;
+ UINT len, i;
+ VARIANT *pvar;
+ VALUE val;
+ VALUE key;
+ len = 0;
+ bstrs = ALLOCA_N(BSTR, pdispparams->cArgs + 1);
+ hr = pTypeInfo->lpVtbl->GetNames(pTypeInfo, dispid,
+ bstrs, pdispparams->cArgs + 1,
+ &len);
+ if (FAILED(hr))
+ return;
+
+ for (i = 0; i < len - 1; i++) {
+ key = WC2VSTR(bstrs[i + 1]);
+ val = rb_hash_aref(hash, INT2FIX(i));
+ if (val == Qnil)
+ val = rb_hash_aref(hash, key);
+ if (val == Qnil)
+ val = rb_hash_aref(hash, rb_str_intern(key));
+ pvar = &pdispparams->rgvarg[pdispparams->cArgs-i-1];
+ ole_val2ptr_variant(val, pvar);
+ }
+}
+
+static VALUE
+hash2result(VALUE hash)
+{
+ VALUE ret = Qnil;
+ ret = rb_hash_aref(hash, rb_str_new2("return"));
+ if (ret == Qnil)
+ ret = rb_hash_aref(hash, rb_str_intern(rb_str_new2("return")));
+ return ret;
+}
+
+static void
+ary2ptr_dispparams(VALUE ary, DISPPARAMS *pdispparams)
+{
+ int i;
+ VALUE v;
+ VARIANT *pvar;
+ for(i = 0; i < RARRAY_LEN(ary) && (unsigned int) i < pdispparams->cArgs; i++) {
+ v = rb_ary_entry(ary, i);
+ pvar = &pdispparams->rgvarg[pdispparams->cArgs-i-1];
+ ole_val2ptr_variant(v, pvar);
+ }
+}
+
+static VALUE
+exec_callback(VALUE arg)
+{
+ VALUE *parg = (VALUE *)arg;
+ VALUE handler = parg[0];
+ VALUE mid = parg[1];
+ VALUE args = parg[2];
+ return rb_apply(handler, mid, args);
+}
+
+static VALUE
+rescue_callback(VALUE arg)
+{
+
+ VALUE error;
+ VALUE e = rb_errinfo();
+ VALUE bt = rb_funcall(e, rb_intern("backtrace"), 0);
+ VALUE msg = rb_funcall(e, rb_intern("message"), 0);
+ bt = rb_ary_entry(bt, 0);
+ error = rb_sprintf("%"PRIsVALUE": %"PRIsVALUE" (%s)\n", bt, msg, rb_obj_classname(e));
+ rb_write_error(StringValuePtr(error));
+ rb_backtrace();
+ ruby_finalize();
+ exit(-1);
+
+ return Qnil;
+}
+
+static HRESULT
+find_iid(VALUE ole, char *pitf, IID *piid, ITypeInfo **ppTypeInfo)
+{
+ HRESULT hr;
+ IDispatch *pDispatch;
+ ITypeInfo *pTypeInfo;
+ ITypeLib *pTypeLib;
+ TYPEATTR *pTypeAttr;
+ HREFTYPE RefType;
+ ITypeInfo *pImplTypeInfo;
+ TYPEATTR *pImplTypeAttr;
+
+ struct oledata *pole = NULL;
+ unsigned int index;
+ unsigned int count;
+ int type;
+ BSTR bstr;
+ char *pstr;
+
+ BOOL is_found = FALSE;
+ LCID lcid = cWIN32OLE_lcid;
+
+ pole = oledata_get_struct(ole);
+
+ pDispatch = pole->pDispatch;
+
+ hr = pDispatch->lpVtbl->GetTypeInfo(pDispatch, 0, lcid, &pTypeInfo);
+ if (FAILED(hr))
+ return hr;
+
+ hr = pTypeInfo->lpVtbl->GetContainingTypeLib(pTypeInfo,
+ &pTypeLib,
+ &index);
+ OLE_RELEASE(pTypeInfo);
+ if (FAILED(hr))
+ return hr;
+
+ if (!pitf) {
+ hr = pTypeLib->lpVtbl->GetTypeInfoOfGuid(pTypeLib,
+ piid,
+ ppTypeInfo);
+ OLE_RELEASE(pTypeLib);
+ return hr;
+ }
+ count = pTypeLib->lpVtbl->GetTypeInfoCount(pTypeLib);
+ for (index = 0; index < count; index++) {
+ hr = pTypeLib->lpVtbl->GetTypeInfo(pTypeLib,
+ index,
+ &pTypeInfo);
+ if (FAILED(hr))
+ break;
+ hr = OLE_GET_TYPEATTR(pTypeInfo, &pTypeAttr);
+
+ if(FAILED(hr)) {
+ OLE_RELEASE(pTypeInfo);
+ break;
+ }
+ if(pTypeAttr->typekind == TKIND_COCLASS) {
+ for (type = 0; type < pTypeAttr->cImplTypes; type++) {
+ hr = pTypeInfo->lpVtbl->GetRefTypeOfImplType(pTypeInfo,
+ type,
+ &RefType);
+ if (FAILED(hr))
+ break;
+ hr = pTypeInfo->lpVtbl->GetRefTypeInfo(pTypeInfo,
+ RefType,
+ &pImplTypeInfo);
+ if (FAILED(hr))
+ break;
+
+ hr = pImplTypeInfo->lpVtbl->GetDocumentation(pImplTypeInfo,
+ -1,
+ &bstr,
+ NULL, NULL, NULL);
+ if (FAILED(hr)) {
+ OLE_RELEASE(pImplTypeInfo);
+ break;
+ }
+ pstr = ole_wc2mb(bstr);
+ if (strcmp(pitf, pstr) == 0) {
+ hr = pImplTypeInfo->lpVtbl->GetTypeAttr(pImplTypeInfo,
+ &pImplTypeAttr);
+ if (SUCCEEDED(hr)) {
+ is_found = TRUE;
+ *piid = pImplTypeAttr->guid;
+ if (ppTypeInfo) {
+ *ppTypeInfo = pImplTypeInfo;
+ (*ppTypeInfo)->lpVtbl->AddRef((*ppTypeInfo));
+ }
+ pImplTypeInfo->lpVtbl->ReleaseTypeAttr(pImplTypeInfo,
+ pImplTypeAttr);
+ }
+ }
+ free(pstr);
+ OLE_RELEASE(pImplTypeInfo);
+ if (is_found || FAILED(hr))
+ break;
+ }
+ }
+
+ OLE_RELEASE_TYPEATTR(pTypeInfo, pTypeAttr);
+ OLE_RELEASE(pTypeInfo);
+ if (is_found || FAILED(hr))
+ break;
+ }
+ OLE_RELEASE(pTypeLib);
+ if(!is_found)
+ return E_NOINTERFACE;
+ return hr;
+}
+
+static HRESULT
+find_coclass(
+ ITypeInfo *pTypeInfo,
+ TYPEATTR *pTypeAttr,
+ ITypeInfo **pCOTypeInfo,
+ TYPEATTR **pCOTypeAttr)
+{
+ HRESULT hr = E_NOINTERFACE;
+ ITypeLib *pTypeLib;
+ int count;
+ BOOL found = FALSE;
+ ITypeInfo *pTypeInfo2;
+ TYPEATTR *pTypeAttr2;
+ int flags;
+ int i,j;
+ HREFTYPE href;
+ ITypeInfo *pRefTypeInfo;
+ TYPEATTR *pRefTypeAttr;
+
+ hr = pTypeInfo->lpVtbl->GetContainingTypeLib(pTypeInfo, &pTypeLib, NULL);
+ if (FAILED(hr)) {
+ return hr;
+ }
+ count = pTypeLib->lpVtbl->GetTypeInfoCount(pTypeLib);
+ for (i = 0; i < count && !found; i++) {
+ hr = pTypeLib->lpVtbl->GetTypeInfo(pTypeLib, i, &pTypeInfo2);
+ if (FAILED(hr))
+ continue;
+ hr = OLE_GET_TYPEATTR(pTypeInfo2, &pTypeAttr2);
+ if (FAILED(hr)) {
+ OLE_RELEASE(pTypeInfo2);
+ continue;
+ }
+ if (pTypeAttr2->typekind != TKIND_COCLASS) {
+ OLE_RELEASE_TYPEATTR(pTypeInfo2, pTypeAttr2);
+ OLE_RELEASE(pTypeInfo2);
+ continue;
+ }
+ for (j = 0; j < pTypeAttr2->cImplTypes && !found; j++) {
+ hr = pTypeInfo2->lpVtbl->GetImplTypeFlags(pTypeInfo2, j, &flags);
+ if (FAILED(hr))
+ continue;
+ if (!(flags & IMPLTYPEFLAG_FDEFAULT))
+ continue;
+ hr = pTypeInfo2->lpVtbl->GetRefTypeOfImplType(pTypeInfo2, j, &href);
+ if (FAILED(hr))
+ continue;
+ hr = pTypeInfo2->lpVtbl->GetRefTypeInfo(pTypeInfo2, href, &pRefTypeInfo);
+ if (FAILED(hr))
+ continue;
+ hr = OLE_GET_TYPEATTR(pRefTypeInfo, &pRefTypeAttr);
+ if (FAILED(hr)) {
+ OLE_RELEASE(pRefTypeInfo);
+ continue;
+ }
+ if (IsEqualGUID(&(pTypeAttr->guid), &(pRefTypeAttr->guid))) {
+ found = TRUE;
+ }
+ }
+ if (!found) {
+ OLE_RELEASE_TYPEATTR(pTypeInfo2, pTypeAttr2);
+ OLE_RELEASE(pTypeInfo2);
+ }
+ }
+ OLE_RELEASE(pTypeLib);
+ if (found) {
+ *pCOTypeInfo = pTypeInfo2;
+ *pCOTypeAttr = pTypeAttr2;
+ hr = S_OK;
+ } else {
+ hr = E_NOINTERFACE;
+ }
+ return hr;
+}
+
+static HRESULT
+find_default_source_from_typeinfo(
+ ITypeInfo *pTypeInfo,
+ TYPEATTR *pTypeAttr,
+ ITypeInfo **ppTypeInfo)
+{
+ int i = 0;
+ HRESULT hr = E_NOINTERFACE;
+ int flags;
+ HREFTYPE hRefType;
+ /* Enumerate all implemented types of the COCLASS */
+ for (i = 0; i < pTypeAttr->cImplTypes; i++) {
+ hr = pTypeInfo->lpVtbl->GetImplTypeFlags(pTypeInfo, i, &flags);
+ if (FAILED(hr))
+ continue;
+
+ /*
+ looking for the [default] [source]
+ we just hope that it is a dispinterface :-)
+ */
+ if ((flags & IMPLTYPEFLAG_FDEFAULT) &&
+ (flags & IMPLTYPEFLAG_FSOURCE)) {
+
+ hr = pTypeInfo->lpVtbl->GetRefTypeOfImplType(pTypeInfo,
+ i, &hRefType);
+ if (FAILED(hr))
+ continue;
+ hr = pTypeInfo->lpVtbl->GetRefTypeInfo(pTypeInfo,
+ hRefType, ppTypeInfo);
+ if (SUCCEEDED(hr))
+ break;
+ }
+ }
+ return hr;
+}
+
+static HRESULT
+find_default_source(VALUE ole, IID *piid, ITypeInfo **ppTypeInfo)
+{
+ HRESULT hr;
+ IProvideClassInfo2 *pProvideClassInfo2;
+ IProvideClassInfo *pProvideClassInfo;
+ void *p;
+
+ IDispatch *pDispatch;
+ ITypeInfo *pTypeInfo;
+ ITypeInfo *pTypeInfo2 = NULL;
+ TYPEATTR *pTypeAttr;
+ TYPEATTR *pTypeAttr2 = NULL;
+
+ struct oledata *pole = NULL;
+
+ pole = oledata_get_struct(ole);
+ pDispatch = pole->pDispatch;
+ hr = pDispatch->lpVtbl->QueryInterface(pDispatch,
+ &IID_IProvideClassInfo2,
+ &p);
+ if (SUCCEEDED(hr)) {
+ pProvideClassInfo2 = p;
+ hr = pProvideClassInfo2->lpVtbl->GetGUID(pProvideClassInfo2,
+ GUIDKIND_DEFAULT_SOURCE_DISP_IID,
+ piid);
+ OLE_RELEASE(pProvideClassInfo2);
+ if (SUCCEEDED(hr)) {
+ hr = find_iid(ole, NULL, piid, ppTypeInfo);
+ }
+ }
+ if (SUCCEEDED(hr)) {
+ return hr;
+ }
+ hr = pDispatch->lpVtbl->QueryInterface(pDispatch,
+ &IID_IProvideClassInfo,
+ &p);
+ if (SUCCEEDED(hr)) {
+ pProvideClassInfo = p;
+ hr = pProvideClassInfo->lpVtbl->GetClassInfo(pProvideClassInfo,
+ &pTypeInfo);
+ OLE_RELEASE(pProvideClassInfo);
+ }
+ if (FAILED(hr)) {
+ hr = pDispatch->lpVtbl->GetTypeInfo(pDispatch, 0, cWIN32OLE_lcid, &pTypeInfo );
+ }
+ if (FAILED(hr))
+ return hr;
+ hr = OLE_GET_TYPEATTR(pTypeInfo, &pTypeAttr);
+ if (FAILED(hr)) {
+ OLE_RELEASE(pTypeInfo);
+ return hr;
+ }
+
+ *ppTypeInfo = 0;
+ hr = find_default_source_from_typeinfo(pTypeInfo, pTypeAttr, ppTypeInfo);
+ if (!*ppTypeInfo) {
+ hr = find_coclass(pTypeInfo, pTypeAttr, &pTypeInfo2, &pTypeAttr2);
+ if (SUCCEEDED(hr)) {
+ hr = find_default_source_from_typeinfo(pTypeInfo2, pTypeAttr2, ppTypeInfo);
+ OLE_RELEASE_TYPEATTR(pTypeInfo2, pTypeAttr2);
+ OLE_RELEASE(pTypeInfo2);
+ }
+ }
+ OLE_RELEASE_TYPEATTR(pTypeInfo, pTypeAttr);
+ OLE_RELEASE(pTypeInfo);
+ /* Now that would be a bad surprise, if we didn't find it, wouldn't it? */
+ if (!*ppTypeInfo) {
+ if (SUCCEEDED(hr))
+ hr = E_UNEXPECTED;
+ return hr;
+ }
+
+ /* Determine IID of default source interface */
+ hr = (*ppTypeInfo)->lpVtbl->GetTypeAttr(*ppTypeInfo, &pTypeAttr);
+ if (SUCCEEDED(hr)) {
+ *piid = pTypeAttr->guid;
+ (*ppTypeInfo)->lpVtbl->ReleaseTypeAttr(*ppTypeInfo, pTypeAttr);
+ }
+ else
+ OLE_RELEASE(*ppTypeInfo);
+
+ return hr;
+}
+
+static long
+ole_search_event_at(VALUE ary, VALUE ev)
+{
+ VALUE event;
+ VALUE event_name;
+ long i, len;
+ long ret = -1;
+ len = RARRAY_LEN(ary);
+ for(i = 0; i < len; i++) {
+ event = rb_ary_entry(ary, i);
+ event_name = rb_ary_entry(event, 1);
+ if(NIL_P(event_name) && NIL_P(ev)) {
+ ret = i;
+ break;
+ }
+ else if (RB_TYPE_P(ev, T_STRING) &&
+ RB_TYPE_P(event_name, T_STRING) &&
+ rb_str_cmp(ev, event_name) == 0) {
+ ret = i;
+ break;
+ }
+ }
+ return ret;
+}
+
+static VALUE
+ole_search_event(VALUE ary, VALUE ev, BOOL *is_default)
+{
+ VALUE event;
+ VALUE def_event;
+ VALUE event_name;
+ int i, len;
+ *is_default = FALSE;
+ def_event = Qnil;
+ len = RARRAY_LEN(ary);
+ for(i = 0; i < len; i++) {
+ event = rb_ary_entry(ary, i);
+ event_name = rb_ary_entry(event, 1);
+ if(NIL_P(event_name)) {
+ *is_default = TRUE;
+ def_event = event;
+ }
+ else if (rb_str_cmp(ev, event_name) == 0) {
+ *is_default = FALSE;
+ return event;
+ }
+ }
+ return def_event;
+}
+
+static VALUE
+ole_search_handler_method(VALUE handler, VALUE ev, BOOL *is_default_handler)
+{
+ VALUE mid;
+
+ *is_default_handler = FALSE;
+ mid = rb_to_id(rb_sprintf("on%"PRIsVALUE, ev));
+ if (rb_respond_to(handler, mid)) {
+ return mid;
+ }
+ mid = rb_intern("method_missing");
+ if (rb_respond_to(handler, mid)) {
+ *is_default_handler = TRUE;
+ return mid;
+ }
+ return Qnil;
+}
+
+static void
+ole_delete_event(VALUE ary, VALUE ev)
+{
+ long at = -1;
+ at = ole_search_event_at(ary, ev);
+ if (at >= 0) {
+ rb_ary_delete_at(ary, at);
+ }
+}
+
+
+static void
+oleevent_free(void *ptr)
+{
+ struct oleeventdata *poleev = ptr;
+ if (poleev->pConnectionPoint) {
+ poleev->pConnectionPoint->lpVtbl->Unadvise(poleev->pConnectionPoint, poleev->dwCookie);
+ OLE_RELEASE(poleev->pConnectionPoint);
+ poleev->pConnectionPoint = NULL;
+ }
+ OLE_RELEASE(poleev->pDispatch);
+ free(poleev);
+}
+
+static size_t
+oleevent_size(const void *ptr)
+{
+ return ptr ? sizeof(struct oleeventdata) : 0;
+}
+
+static VALUE
+fev_s_allocate(VALUE klass)
+{
+ VALUE obj;
+ struct oleeventdata *poleev;
+ obj = TypedData_Make_Struct(klass, struct oleeventdata, &oleevent_datatype, poleev);
+ poleev->dwCookie = 0;
+ poleev->pConnectionPoint = NULL;
+ poleev->event_id = 0;
+ poleev->pDispatch = NULL;
+ return obj;
+}
+
+static VALUE
+ev_advise(int argc, VALUE *argv, VALUE self)
+{
+
+ VALUE ole, itf;
+ struct oledata *pole = NULL;
+ char *pitf;
+ HRESULT hr;
+ IID iid;
+ ITypeInfo *pTypeInfo = 0;
+ IDispatch *pDispatch;
+ IConnectionPointContainer *pContainer;
+ IConnectionPoint *pConnectionPoint;
+ IEVENTSINKOBJ *pIEV;
+ DWORD dwCookie;
+ struct oleeventdata *poleev;
+ void *p;
+
+ rb_scan_args(argc, argv, "11", &ole, &itf);
+
+ if (!rb_obj_is_kind_of(ole, cWIN32OLE)) {
+ rb_raise(rb_eTypeError, "1st parameter must be WIN32OLE object");
+ }
+
+ if(!RB_TYPE_P(itf, T_NIL)) {
+ pitf = StringValuePtr(itf);
+ if (rb_safe_level() > 0 && OBJ_TAINTED(itf)) {
+ rb_raise(rb_eSecurityError, "insecure event creation - `%s'",
+ StringValuePtr(itf));
+ }
+ hr = find_iid(ole, pitf, &iid, &pTypeInfo);
+ }
+ else {
+ hr = find_default_source(ole, &iid, &pTypeInfo);
+ }
+ if (FAILED(hr)) {
+ ole_raise(hr, rb_eRuntimeError, "interface not found");
+ }
+
+ pole = oledata_get_struct(ole);
+ pDispatch = pole->pDispatch;
+ hr = pDispatch->lpVtbl->QueryInterface(pDispatch,
+ &IID_IConnectionPointContainer,
+ &p);
+ if (FAILED(hr)) {
+ OLE_RELEASE(pTypeInfo);
+ ole_raise(hr, rb_eRuntimeError,
+ "failed to query IConnectionPointContainer");
+ }
+ pContainer = p;
+
+ hr = pContainer->lpVtbl->FindConnectionPoint(pContainer,
+ &iid,
+ &pConnectionPoint);
+ OLE_RELEASE(pContainer);
+ if (FAILED(hr)) {
+ OLE_RELEASE(pTypeInfo);
+ ole_raise(hr, rb_eRuntimeError, "failed to query IConnectionPoint");
+ }
+ pIEV = EVENTSINK_Constructor();
+ pIEV->m_iid = iid;
+ hr = pConnectionPoint->lpVtbl->Advise(pConnectionPoint,
+ (IUnknown*)pIEV,
+ &dwCookie);
+ if (FAILED(hr)) {
+ ole_raise(hr, rb_eRuntimeError, "Advise Error");
+ }
+
+ TypedData_Get_Struct(self, struct oleeventdata, &oleevent_datatype, poleev);
+ pIEV->m_event_id = evs_length();
+ pIEV->pTypeInfo = pTypeInfo;
+ poleev->dwCookie = dwCookie;
+ poleev->pConnectionPoint = pConnectionPoint;
+ poleev->event_id = pIEV->m_event_id;
+ poleev->pDispatch = pDispatch;
+ OLE_ADDREF(pDispatch);
+
+ return self;
+}
+
+/*
+ * call-seq:
+ * WIN32OLE_EVENT.new(ole, event) #=> WIN32OLE_EVENT object.
+ *
+ * Returns OLE event object.
+ * The first argument specifies WIN32OLE object.
+ * The second argument specifies OLE event name.
+ * ie = WIN32OLE.new('InternetExplorer.Application')
+ * ev = WIN32OLE_EVENT.new(ie, 'DWebBrowserEvents')
+ */
+static VALUE
+fev_initialize(int argc, VALUE *argv, VALUE self)
+{
+ ev_advise(argc, argv, self);
+ evs_push(self);
+ rb_ivar_set(self, id_events, rb_ary_new());
+ fev_set_handler(self, Qnil);
+ return self;
+}
+
+static void
+ole_msg_loop(void)
+{
+ MSG msg;
+ while(PeekMessage(&msg,NULL,0,0,PM_REMOVE)) {
+ TranslateMessage(&msg);
+ DispatchMessage(&msg);
+ }
+}
+
+/*
+ * call-seq:
+ * WIN32OLE_EVENT.message_loop
+ *
+ * Translates and dispatches Windows message.
+ */
+static VALUE
+fev_s_msg_loop(VALUE klass)
+{
+ ole_msg_loop();
+ return Qnil;
+}
+
+static void
+add_event_call_back(VALUE obj, VALUE event, VALUE data)
+{
+ VALUE events = rb_ivar_get(obj, id_events);
+ if (NIL_P(events) || !RB_TYPE_P(events, T_ARRAY)) {
+ events = rb_ary_new();
+ rb_ivar_set(obj, id_events, events);
+ }
+ ole_delete_event(events, event);
+ rb_ary_push(events, data);
+}
+
+static VALUE
+ev_on_event(int argc, VALUE *argv, VALUE self, VALUE is_ary_arg)
+{
+ struct oleeventdata *poleev;
+ VALUE event, args, data;
+ TypedData_Get_Struct(self, struct oleeventdata, &oleevent_datatype, poleev);
+ if (poleev->pConnectionPoint == NULL) {
+ rb_raise(eWIN32OLERuntimeError, "IConnectionPoint not found. You must call advise at first.");
+ }
+ rb_scan_args(argc, argv, "01*", &event, &args);
+ if(!NIL_P(event)) {
+ if(!RB_TYPE_P(event, T_STRING) && !RB_TYPE_P(event, T_SYMBOL)) {
+ rb_raise(rb_eTypeError, "wrong argument type (expected String or Symbol)");
+ }
+ if (RB_TYPE_P(event, T_SYMBOL)) {
+ event = rb_sym_to_s(event);
+ }
+ }
+ data = rb_ary_new3(4, rb_block_proc(), event, args, is_ary_arg);
+ add_event_call_back(self, event, data);
+ return Qnil;
+}
+
+/*
+ * call-seq:
+ * WIN32OLE_EVENT#on_event([event]){...}
+ *
+ * Defines the callback event.
+ * If argument is omitted, this method defines the callback of all events.
+ * If you want to modify reference argument in callback, return hash in
+ * callback. If you want to return value to OLE server as result of callback
+ * use `return' or :return.
+ *
+ * ie = WIN32OLE.new('InternetExplorer.Application')
+ * ev = WIN32OLE_EVENT.new(ie)
+ * ev.on_event("NavigateComplete") {|url| puts url}
+ * ev.on_event() {|ev, *args| puts "#{ev} fired"}
+ *
+ * ev.on_event("BeforeNavigate2") {|*args|
+ * ...
+ * # set true to BeforeNavigate reference argument `Cancel'.
+ * # Cancel is 7-th argument of BeforeNavigate,
+ * # so you can use 6 as key of hash instead of 'Cancel'.
+ * # The argument is counted from 0.
+ * # The hash key of 0 means first argument.)
+ * {:Cancel => true} # or {'Cancel' => true} or {6 => true}
+ * }
+ *
+ * ev.on_event(...) {|*args|
+ * {:return => 1, :xxx => yyy}
+ * }
+ */
+static VALUE
+fev_on_event(int argc, VALUE *argv, VALUE self)
+{
+ return ev_on_event(argc, argv, self, Qfalse);
+}
+
+/*
+ * call-seq:
+ * WIN32OLE_EVENT#on_event_with_outargs([event]){...}
+ *
+ * Defines the callback of event.
+ * If you want modify argument in callback,
+ * you could use this method instead of WIN32OLE_EVENT#on_event.
+ *
+ * ie = WIN32OLE.new('InternetExplorer.Application')
+ * ev = WIN32OLE_EVENT.new(ie)
+ * ev.on_event_with_outargs('BeforeNavigate2') {|*args|
+ * args.last[6] = true
+ * }
+ */
+static VALUE
+fev_on_event_with_outargs(int argc, VALUE *argv, VALUE self)
+{
+ return ev_on_event(argc, argv, self, Qtrue);
+}
+
+/*
+ * call-seq:
+ * WIN32OLE_EVENT#off_event([event])
+ *
+ * removes the callback of event.
+ *
+ * ie = WIN32OLE.new('InternetExplorer.Application')
+ * ev = WIN32OLE_EVENT.new(ie)
+ * ev.on_event('BeforeNavigate2') {|*args|
+ * args.last[6] = true
+ * }
+ * ...
+ * ev.off_event('BeforeNavigate2')
+ * ...
+ */
+static VALUE
+fev_off_event(int argc, VALUE *argv, VALUE self)
+{
+ VALUE event = Qnil;
+ VALUE events;
+
+ rb_scan_args(argc, argv, "01", &event);
+ if(!NIL_P(event)) {
+ if(!RB_TYPE_P(event, T_STRING) && !RB_TYPE_P(event, T_SYMBOL)) {
+ rb_raise(rb_eTypeError, "wrong argument type (expected String or Symbol)");
+ }
+ if (RB_TYPE_P(event, T_SYMBOL)) {
+ event = rb_sym_to_s(event);
+ }
+ }
+ events = rb_ivar_get(self, id_events);
+ if (NIL_P(events)) {
+ return Qnil;
+ }
+ ole_delete_event(events, event);
+ return Qnil;
+}
+
+/*
+ * call-seq:
+ * WIN32OLE_EVENT#unadvise -> nil
+ *
+ * disconnects OLE server. If this method called, then the WIN32OLE_EVENT object
+ * does not receive the OLE server event any more.
+ * This method is trial implementation.
+ *
+ * ie = WIN32OLE.new('InternetExplorer.Application')
+ * ev = WIN32OLE_EVENT.new(ie)
+ * ev.on_event() {...}
+ * ...
+ * ev.unadvise
+ *
+ */
+static VALUE
+fev_unadvise(VALUE self)
+{
+ struct oleeventdata *poleev;
+ TypedData_Get_Struct(self, struct oleeventdata, &oleevent_datatype, poleev);
+ if (poleev->pConnectionPoint) {
+ ole_msg_loop();
+ evs_delete(poleev->event_id);
+ poleev->pConnectionPoint->lpVtbl->Unadvise(poleev->pConnectionPoint, poleev->dwCookie);
+ OLE_RELEASE(poleev->pConnectionPoint);
+ poleev->pConnectionPoint = NULL;
+ }
+ OLE_FREE(poleev->pDispatch);
+ return Qnil;
+}
+
+static VALUE
+evs_push(VALUE ev)
+{
+ return rb_ary_push(ary_ole_event, ev);
+}
+
+static VALUE
+evs_delete(long i)
+{
+ rb_ary_store(ary_ole_event, i, Qnil);
+ return Qnil;
+}
+
+static VALUE
+evs_entry(long i)
+{
+ return rb_ary_entry(ary_ole_event, i);
+}
+
+static long
+evs_length(void)
+{
+ return RARRAY_LEN(ary_ole_event);
+}
+
+/*
+ * call-seq:
+ * WIN32OLE_EVENT#handler=
+ *
+ * sets event handler object. If handler object has onXXX
+ * method according to XXX event, then onXXX method is called
+ * when XXX event occurs.
+ *
+ * If handler object has method_missing and there is no
+ * method according to the event, then method_missing
+ * called and 1-st argument is event name.
+ *
+ * If handler object has onXXX method and there is block
+ * defined by WIN32OLE_EVENT#on_event('XXX'){},
+ * then block is executed but handler object method is not called
+ * when XXX event occurs.
+ *
+ * class Handler
+ * def onStatusTextChange(text)
+ * puts "StatusTextChanged"
+ * end
+ * def onPropertyChange(prop)
+ * puts "PropertyChanged"
+ * end
+ * def method_missing(ev, *arg)
+ * puts "other event #{ev}"
+ * end
+ * end
+ *
+ * handler = Handler.new
+ * ie = WIN32OLE.new('InternetExplorer.Application')
+ * ev = WIN32OLE_EVENT.new(ie)
+ * ev.on_event("StatusTextChange") {|*args|
+ * puts "this block executed."
+ * puts "handler.onStatusTextChange method is not called."
+ * }
+ * ev.handler = handler
+ *
+ */
+static VALUE
+fev_set_handler(VALUE self, VALUE val)
+{
+ return rb_ivar_set(self, rb_intern("handler"), val);
+}
+
+/*
+ * call-seq:
+ * WIN32OLE_EVENT#handler
+ *
+ * returns handler object.
+ *
+ */
+static VALUE
+fev_get_handler(VALUE self)
+{
+ return rb_ivar_get(self, rb_intern("handler"));
+}
+
+void
+Init_win32ole_event(void)
+{
+ ary_ole_event = rb_ary_new();
+ rb_gc_register_mark_object(ary_ole_event);
+ id_events = rb_intern("events");
+ cWIN32OLE_EVENT = rb_define_class("WIN32OLE_EVENT", rb_cObject);
+ rb_define_singleton_method(cWIN32OLE_EVENT, "message_loop", fev_s_msg_loop, 0);
+ rb_define_alloc_func(cWIN32OLE_EVENT, fev_s_allocate);
+ rb_define_method(cWIN32OLE_EVENT, "initialize", fev_initialize, -1);
+ rb_define_method(cWIN32OLE_EVENT, "on_event", fev_on_event, -1);
+ rb_define_method(cWIN32OLE_EVENT, "on_event_with_outargs", fev_on_event_with_outargs, -1);
+ rb_define_method(cWIN32OLE_EVENT, "off_event", fev_off_event, -1);
+ rb_define_method(cWIN32OLE_EVENT, "unadvise", fev_unadvise, 0);
+ rb_define_method(cWIN32OLE_EVENT, "handler=", fev_set_handler, 1);
+ rb_define_method(cWIN32OLE_EVENT, "handler", fev_get_handler, 0);
+}
diff --git a/jni/ruby/ext/win32ole/win32ole_event.h b/jni/ruby/ext/win32ole/win32ole_event.h
new file mode 100644
index 0000000..f1a5aa2
--- /dev/null
+++ b/jni/ruby/ext/win32ole/win32ole_event.h
@@ -0,0 +1,6 @@
+#ifndef WIN32OLE_EVENT_H
+#define WIN32OLE_EVENT_H 1
+
+void Init_win32ole_event(void);
+
+#endif
diff --git a/jni/ruby/ext/win32ole/win32ole_method.c b/jni/ruby/ext/win32ole/win32ole_method.c
new file mode 100644
index 0000000..ba8cf78
--- /dev/null
+++ b/jni/ruby/ext/win32ole/win32ole_method.c
@@ -0,0 +1,950 @@
+#include "win32ole.h"
+
+static void olemethod_free(void *ptr);
+static size_t olemethod_size(const void *ptr);
+static VALUE ole_method_sub(VALUE self, ITypeInfo *pOwnerTypeInfo, ITypeInfo *pTypeInfo, VALUE name);
+static VALUE olemethod_from_typeinfo(VALUE self, ITypeInfo *pTypeInfo, VALUE name);
+static VALUE ole_methods_sub(ITypeInfo *pOwnerTypeInfo, ITypeInfo *pTypeInfo, VALUE methods, int mask);
+static VALUE olemethod_set_member(VALUE self, ITypeInfo *pTypeInfo, ITypeInfo *pOwnerTypeInfo, int index, VALUE name);
+static VALUE folemethod_initialize(VALUE self, VALUE oletype, VALUE method);
+static VALUE folemethod_name(VALUE self);
+static VALUE ole_method_return_type(ITypeInfo *pTypeInfo, UINT method_index);
+static VALUE folemethod_return_type(VALUE self);
+static VALUE ole_method_return_vtype(ITypeInfo *pTypeInfo, UINT method_index);
+static VALUE folemethod_return_vtype(VALUE self);
+static VALUE ole_method_return_type_detail(ITypeInfo *pTypeInfo, UINT method_index);
+static VALUE folemethod_return_type_detail(VALUE self);
+static VALUE ole_method_invkind(ITypeInfo *pTypeInfo, UINT method_index);
+static VALUE ole_method_invoke_kind(ITypeInfo *pTypeInfo, UINT method_index);
+static VALUE folemethod_invkind(VALUE self);
+static VALUE folemethod_invoke_kind(VALUE self);
+static VALUE ole_method_visible(ITypeInfo *pTypeInfo, UINT method_index);
+static VALUE folemethod_visible(VALUE self);
+static VALUE ole_method_event(ITypeInfo *pTypeInfo, UINT method_index, VALUE method_name);
+static VALUE folemethod_event(VALUE self);
+static VALUE folemethod_event_interface(VALUE self);
+static HRESULT ole_method_docinfo_from_type(ITypeInfo *pTypeInfo, UINT method_index, BSTR *name, BSTR *helpstr, DWORD *helpcontext, BSTR *helpfile);
+static VALUE ole_method_helpstring(ITypeInfo *pTypeInfo, UINT method_index);
+static VALUE folemethod_helpstring(VALUE self);
+static VALUE ole_method_helpfile(ITypeInfo *pTypeInfo, UINT method_index);
+static VALUE folemethod_helpfile(VALUE self);
+static VALUE ole_method_helpcontext(ITypeInfo *pTypeInfo, UINT method_index);
+static VALUE folemethod_helpcontext(VALUE self);
+static VALUE ole_method_dispid(ITypeInfo *pTypeInfo, UINT method_index);
+static VALUE folemethod_dispid(VALUE self);
+static VALUE ole_method_offset_vtbl(ITypeInfo *pTypeInfo, UINT method_index);
+static VALUE folemethod_offset_vtbl(VALUE self);
+static VALUE ole_method_size_params(ITypeInfo *pTypeInfo, UINT method_index);
+static VALUE folemethod_size_params(VALUE self);
+static VALUE ole_method_size_opt_params(ITypeInfo *pTypeInfo, UINT method_index);
+static VALUE folemethod_size_opt_params(VALUE self);
+static VALUE ole_method_params(ITypeInfo *pTypeInfo, UINT method_index);
+static VALUE folemethod_params(VALUE self);
+static VALUE folemethod_inspect(VALUE self);
+
+static const rb_data_type_t olemethod_datatype = {
+ "win32ole_method",
+ {NULL, olemethod_free, olemethod_size,},
+ 0, 0, RUBY_TYPED_FREE_IMMEDIATELY
+};
+
+static void
+olemethod_free(void *ptr)
+{
+ struct olemethoddata *polemethod = ptr;
+ OLE_FREE(polemethod->pTypeInfo);
+ OLE_FREE(polemethod->pOwnerTypeInfo);
+ free(polemethod);
+}
+
+static size_t
+olemethod_size(const void *ptr)
+{
+ return ptr ? sizeof(struct olemethoddata) : 0;
+}
+
+struct olemethoddata *
+olemethod_data_get_struct(VALUE obj)
+{
+ struct olemethoddata *pmethod;
+ TypedData_Get_Struct(obj, struct olemethoddata, &olemethod_datatype, pmethod);
+ return pmethod;
+}
+
+static VALUE
+ole_method_sub(VALUE self, ITypeInfo *pOwnerTypeInfo, ITypeInfo *pTypeInfo, VALUE name)
+{
+ HRESULT hr;
+ TYPEATTR *pTypeAttr;
+ BSTR bstr;
+ FUNCDESC *pFuncDesc;
+ WORD i;
+ VALUE fname;
+ VALUE method = Qnil;
+ hr = OLE_GET_TYPEATTR(pTypeInfo, &pTypeAttr);
+ if (FAILED(hr)) {
+ ole_raise(hr, eWIN32OLERuntimeError, "failed to GetTypeAttr");
+ }
+ for(i = 0; i < pTypeAttr->cFuncs && method == Qnil; i++) {
+ hr = pTypeInfo->lpVtbl->GetFuncDesc(pTypeInfo, i, &pFuncDesc);
+ if (FAILED(hr))
+ continue;
+
+ hr = pTypeInfo->lpVtbl->GetDocumentation(pTypeInfo, pFuncDesc->memid,
+ &bstr, NULL, NULL, NULL);
+ if (FAILED(hr)) {
+ pTypeInfo->lpVtbl->ReleaseFuncDesc(pTypeInfo, pFuncDesc);
+ continue;
+ }
+ fname = WC2VSTR(bstr);
+ if (strcasecmp(StringValuePtr(name), StringValuePtr(fname)) == 0) {
+ olemethod_set_member(self, pTypeInfo, pOwnerTypeInfo, i, fname);
+ method = self;
+ }
+ pTypeInfo->lpVtbl->ReleaseFuncDesc(pTypeInfo, pFuncDesc);
+ pFuncDesc=NULL;
+ }
+ OLE_RELEASE_TYPEATTR(pTypeInfo, pTypeAttr);
+ return method;
+}
+
+VALUE
+ole_methods_from_typeinfo(ITypeInfo *pTypeInfo, int mask)
+{
+ HRESULT hr;
+ TYPEATTR *pTypeAttr;
+ WORD i;
+ HREFTYPE href;
+ ITypeInfo *pRefTypeInfo;
+ VALUE methods = rb_ary_new();
+ hr = OLE_GET_TYPEATTR(pTypeInfo, &pTypeAttr);
+ if (FAILED(hr)) {
+ ole_raise(hr, eWIN32OLERuntimeError, "failed to GetTypeAttr");
+ }
+
+ ole_methods_sub(0, pTypeInfo, methods, mask);
+ for(i=0; i < pTypeAttr->cImplTypes; i++){
+ hr = pTypeInfo->lpVtbl->GetRefTypeOfImplType(pTypeInfo, i, &href);
+ if(FAILED(hr))
+ continue;
+ hr = pTypeInfo->lpVtbl->GetRefTypeInfo(pTypeInfo, href, &pRefTypeInfo);
+ if (FAILED(hr))
+ continue;
+ ole_methods_sub(pTypeInfo, pRefTypeInfo, methods, mask);
+ OLE_RELEASE(pRefTypeInfo);
+ }
+ OLE_RELEASE_TYPEATTR(pTypeInfo, pTypeAttr);
+ return methods;
+}
+
+static VALUE
+olemethod_from_typeinfo(VALUE self, ITypeInfo *pTypeInfo, VALUE name)
+{
+ HRESULT hr;
+ TYPEATTR *pTypeAttr;
+ WORD i;
+ HREFTYPE href;
+ ITypeInfo *pRefTypeInfo;
+ VALUE method = Qnil;
+ hr = OLE_GET_TYPEATTR(pTypeInfo, &pTypeAttr);
+ if (FAILED(hr)) {
+ ole_raise(hr, eWIN32OLERuntimeError, "failed to GetTypeAttr");
+ }
+ method = ole_method_sub(self, 0, pTypeInfo, name);
+ if (method != Qnil) {
+ return method;
+ }
+ for(i=0; i < pTypeAttr->cImplTypes && method == Qnil; i++){
+ hr = pTypeInfo->lpVtbl->GetRefTypeOfImplType(pTypeInfo, i, &href);
+ if(FAILED(hr))
+ continue;
+ hr = pTypeInfo->lpVtbl->GetRefTypeInfo(pTypeInfo, href, &pRefTypeInfo);
+ if (FAILED(hr))
+ continue;
+ method = ole_method_sub(self, pTypeInfo, pRefTypeInfo, name);
+ OLE_RELEASE(pRefTypeInfo);
+ }
+ OLE_RELEASE_TYPEATTR(pTypeInfo, pTypeAttr);
+ return method;
+}
+
+static VALUE
+ole_methods_sub(ITypeInfo *pOwnerTypeInfo, ITypeInfo *pTypeInfo, VALUE methods, int mask)
+{
+ HRESULT hr;
+ TYPEATTR *pTypeAttr;
+ BSTR bstr;
+ FUNCDESC *pFuncDesc;
+ VALUE method;
+ WORD i;
+ hr = OLE_GET_TYPEATTR(pTypeInfo, &pTypeAttr);
+ if (FAILED(hr)) {
+ ole_raise(hr, eWIN32OLERuntimeError, "failed to GetTypeAttr");
+ }
+ for(i = 0; i < pTypeAttr->cFuncs; i++) {
+ hr = pTypeInfo->lpVtbl->GetFuncDesc(pTypeInfo, i, &pFuncDesc);
+ if (FAILED(hr))
+ continue;
+
+ hr = pTypeInfo->lpVtbl->GetDocumentation(pTypeInfo, pFuncDesc->memid,
+ &bstr, NULL, NULL, NULL);
+ if (FAILED(hr)) {
+ pTypeInfo->lpVtbl->ReleaseFuncDesc(pTypeInfo, pFuncDesc);
+ continue;
+ }
+ if(pFuncDesc->invkind & mask) {
+ method = folemethod_s_allocate(cWIN32OLE_METHOD);
+ olemethod_set_member(method, pTypeInfo, pOwnerTypeInfo,
+ i, WC2VSTR(bstr));
+ rb_ary_push(methods, method);
+ }
+ pTypeInfo->lpVtbl->ReleaseFuncDesc(pTypeInfo, pFuncDesc);
+ pFuncDesc=NULL;
+ }
+ OLE_RELEASE_TYPEATTR(pTypeInfo, pTypeAttr);
+
+ return methods;
+}
+
+VALUE
+create_win32ole_method(ITypeInfo *pTypeInfo, VALUE name)
+{
+
+ VALUE method = folemethod_s_allocate(cWIN32OLE_METHOD);
+ VALUE obj = olemethod_from_typeinfo(method, pTypeInfo, name);
+ return obj;
+}
+
+/*
+ * Document-class: WIN32OLE_METHOD
+ *
+ * <code>WIN32OLE_METHOD</code> objects represent OLE method information.
+ */
+
+static VALUE
+olemethod_set_member(VALUE self, ITypeInfo *pTypeInfo, ITypeInfo *pOwnerTypeInfo, int index, VALUE name)
+{
+ struct olemethoddata *pmethod;
+ TypedData_Get_Struct(self, struct olemethoddata, &olemethod_datatype, pmethod);
+ pmethod->pTypeInfo = pTypeInfo;
+ OLE_ADDREF(pTypeInfo);
+ pmethod->pOwnerTypeInfo = pOwnerTypeInfo;
+ OLE_ADDREF(pOwnerTypeInfo);
+ pmethod->index = index;
+ rb_ivar_set(self, rb_intern("name"), name);
+ return self;
+}
+
+VALUE
+folemethod_s_allocate(VALUE klass)
+{
+ struct olemethoddata *pmethod;
+ VALUE obj;
+ obj = TypedData_Make_Struct(klass,
+ struct olemethoddata,
+ &olemethod_datatype, pmethod);
+ pmethod->pTypeInfo = NULL;
+ pmethod->pOwnerTypeInfo = NULL;
+ pmethod->index = 0;
+ return obj;
+}
+
+/*
+ * call-seq:
+ * WIN32OLE_METHOD.new(ole_type, method) -> WIN32OLE_METHOD object
+ *
+ * Returns a new WIN32OLE_METHOD object which represents the information
+ * about OLE method.
+ * The first argument <i>ole_type</i> specifies WIN32OLE_TYPE object.
+ * The second argument <i>method</i> specifies OLE method name defined OLE class
+ * which represents WIN32OLE_TYPE object.
+ *
+ * tobj = WIN32OLE_TYPE.new('Microsoft Excel 9.0 Object Library', 'Workbook')
+ * method = WIN32OLE_METHOD.new(tobj, 'SaveAs')
+ */
+static VALUE
+folemethod_initialize(VALUE self, VALUE oletype, VALUE method)
+{
+ VALUE obj = Qnil;
+ ITypeInfo *pTypeInfo;
+ if (rb_obj_is_kind_of(oletype, cWIN32OLE_TYPE)) {
+ SafeStringValue(method);
+ pTypeInfo = itypeinfo(oletype);
+ obj = olemethod_from_typeinfo(self, pTypeInfo, method);
+ if (obj == Qnil) {
+ rb_raise(eWIN32OLERuntimeError, "not found %s",
+ StringValuePtr(method));
+ }
+ }
+ else {
+ rb_raise(rb_eTypeError, "1st argument should be WIN32OLE_TYPE object");
+ }
+ return obj;
+}
+
+/*
+ * call-seq
+ * WIN32OLE_METHOD#name
+ *
+ * Returns the name of the method.
+ *
+ * tobj = WIN32OLE_TYPE.new('Microsoft Excel 9.0 Object Library', 'Workbook')
+ * method = WIN32OLE_METHOD.new(tobj, 'SaveAs')
+ * puts method.name # => SaveAs
+ *
+ */
+static VALUE
+folemethod_name(VALUE self)
+{
+ return rb_ivar_get(self, rb_intern("name"));
+}
+
+static VALUE
+ole_method_return_type(ITypeInfo *pTypeInfo, UINT method_index)
+{
+ FUNCDESC *pFuncDesc;
+ HRESULT hr;
+ VALUE type;
+
+ hr = pTypeInfo->lpVtbl->GetFuncDesc(pTypeInfo, method_index, &pFuncDesc);
+ if (FAILED(hr))
+ ole_raise(hr, eWIN32OLERuntimeError, "failed to GetFuncDesc");
+
+ type = ole_typedesc2val(pTypeInfo, &(pFuncDesc->elemdescFunc.tdesc), Qnil);
+ pTypeInfo->lpVtbl->ReleaseFuncDesc(pTypeInfo, pFuncDesc);
+ return type;
+}
+
+/*
+ * call-seq:
+ * WIN32OLE_METHOD#return_type
+ *
+ * Returns string of return value type of method.
+ * tobj = WIN32OLE_TYPE.new('Microsoft Excel 9.0 Object Library', 'Workbooks')
+ * method = WIN32OLE_METHOD.new(tobj, 'Add')
+ * puts method.return_type # => Workbook
+ *
+ */
+static VALUE
+folemethod_return_type(VALUE self)
+{
+ struct olemethoddata *pmethod;
+ TypedData_Get_Struct(self, struct olemethoddata, &olemethod_datatype, pmethod);
+ return ole_method_return_type(pmethod->pTypeInfo, pmethod->index);
+}
+
+static VALUE
+ole_method_return_vtype(ITypeInfo *pTypeInfo, UINT method_index)
+{
+ FUNCDESC *pFuncDesc;
+ HRESULT hr;
+ VALUE vvt;
+
+ hr = pTypeInfo->lpVtbl->GetFuncDesc(pTypeInfo, method_index, &pFuncDesc);
+ if (FAILED(hr))
+ ole_raise(hr, eWIN32OLERuntimeError, "failed to GetFuncDesc");
+
+ vvt = INT2FIX(pFuncDesc->elemdescFunc.tdesc.vt);
+ pTypeInfo->lpVtbl->ReleaseFuncDesc(pTypeInfo, pFuncDesc);
+ return vvt;
+}
+
+/*
+ * call-seq:
+ * WIN32OLE_METHOD#return_vtype
+ *
+ * Returns number of return value type of method.
+ * tobj = WIN32OLE_TYPE.new('Microsoft Excel 9.0 Object Library', 'Workbooks')
+ * method = WIN32OLE_METHOD.new(tobj, 'Add')
+ * puts method.return_vtype # => 26
+ *
+ */
+static VALUE
+folemethod_return_vtype(VALUE self)
+{
+ struct olemethoddata *pmethod;
+ TypedData_Get_Struct(self, struct olemethoddata, &olemethod_datatype, pmethod);
+ return ole_method_return_vtype(pmethod->pTypeInfo, pmethod->index);
+}
+
+static VALUE
+ole_method_return_type_detail(ITypeInfo *pTypeInfo, UINT method_index)
+{
+ FUNCDESC *pFuncDesc;
+ HRESULT hr;
+ VALUE type = rb_ary_new();
+
+ hr = pTypeInfo->lpVtbl->GetFuncDesc(pTypeInfo, method_index, &pFuncDesc);
+ if (FAILED(hr))
+ return type;
+
+ ole_typedesc2val(pTypeInfo, &(pFuncDesc->elemdescFunc.tdesc), type);
+ pTypeInfo->lpVtbl->ReleaseFuncDesc(pTypeInfo, pFuncDesc);
+ return type;
+}
+
+/*
+ * call-seq:
+ * WIN32OLE_METHOD#return_type_detail
+ *
+ * Returns detail information of return value type of method.
+ * The information is array.
+ * tobj = WIN32OLE_TYPE.new('Microsoft Excel 9.0 Object Library', 'Workbooks')
+ * method = WIN32OLE_METHOD.new(tobj, 'Add')
+ * p method.return_type_detail # => ["PTR", "USERDEFINED", "Workbook"]
+ */
+static VALUE
+folemethod_return_type_detail(VALUE self)
+{
+ struct olemethoddata *pmethod;
+ TypedData_Get_Struct(self, struct olemethoddata, &olemethod_datatype, pmethod);
+ return ole_method_return_type_detail(pmethod->pTypeInfo, pmethod->index);
+}
+
+static VALUE
+ole_method_invkind(ITypeInfo *pTypeInfo, UINT method_index)
+{
+ FUNCDESC *pFuncDesc;
+ HRESULT hr;
+ VALUE invkind;
+ hr = pTypeInfo->lpVtbl->GetFuncDesc(pTypeInfo, method_index, &pFuncDesc);
+ if(FAILED(hr))
+ ole_raise(hr, eWIN32OLERuntimeError, "failed to GetFuncDesc");
+ invkind = INT2FIX(pFuncDesc->invkind);
+ pTypeInfo->lpVtbl->ReleaseFuncDesc(pTypeInfo, pFuncDesc);
+ return invkind;
+}
+
+static VALUE
+ole_method_invoke_kind(ITypeInfo *pTypeInfo, UINT method_index)
+{
+ VALUE type = rb_str_new2("UNKNOWN");
+ VALUE invkind = ole_method_invkind(pTypeInfo, method_index);
+ if((FIX2INT(invkind) & INVOKE_PROPERTYGET) &&
+ (FIX2INT(invkind) & INVOKE_PROPERTYPUT) ) {
+ type = rb_str_new2("PROPERTY");
+ } else if(FIX2INT(invkind) & INVOKE_PROPERTYGET) {
+ type = rb_str_new2("PROPERTYGET");
+ } else if(FIX2INT(invkind) & INVOKE_PROPERTYPUT) {
+ type = rb_str_new2("PROPERTYPUT");
+ } else if(FIX2INT(invkind) & INVOKE_PROPERTYPUTREF) {
+ type = rb_str_new2("PROPERTYPUTREF");
+ } else if(FIX2INT(invkind) & INVOKE_FUNC) {
+ type = rb_str_new2("FUNC");
+ }
+ return type;
+}
+
+/*
+ * call-seq:
+ * WIN32OLE_MTHOD#invkind
+ *
+ * Returns the method invoke kind.
+ * tobj = WIN32OLE_TYPE.new('Microsoft Excel 9.0 Object Library', 'Workbooks')
+ * method = WIN32OLE_METHOD.new(tobj, 'Add')
+ * puts method.invkind # => 1
+ *
+ */
+static VALUE
+folemethod_invkind(VALUE self)
+{
+ struct olemethoddata *pmethod;
+ TypedData_Get_Struct(self, struct olemethoddata, &olemethod_datatype, pmethod);
+ return ole_method_invkind(pmethod->pTypeInfo, pmethod->index);
+}
+
+/*
+ * call-seq:
+ * WIN32OLE_METHOD#invoke_kind
+ *
+ * Returns the method kind string. The string is "UNKNOWN" or "PROPERTY"
+ * or "PROPERTY" or "PROPERTYGET" or "PROPERTYPUT" or "PROPERTYPPUTREF"
+ * or "FUNC".
+ * tobj = WIN32OLE_TYPE.new('Microsoft Excel 9.0 Object Library', 'Workbooks')
+ * method = WIN32OLE_METHOD.new(tobj, 'Add')
+ * puts method.invoke_kind # => "FUNC"
+ */
+static VALUE
+folemethod_invoke_kind(VALUE self)
+{
+ struct olemethoddata *pmethod;
+ TypedData_Get_Struct(self, struct olemethoddata, &olemethod_datatype, pmethod);
+ return ole_method_invoke_kind(pmethod->pTypeInfo, pmethod->index);
+}
+
+static VALUE
+ole_method_visible(ITypeInfo *pTypeInfo, UINT method_index)
+{
+ FUNCDESC *pFuncDesc;
+ HRESULT hr;
+ VALUE visible;
+ hr = pTypeInfo->lpVtbl->GetFuncDesc(pTypeInfo, method_index, &pFuncDesc);
+ if(FAILED(hr))
+ return Qfalse;
+ if (pFuncDesc->wFuncFlags & (FUNCFLAG_FRESTRICTED |
+ FUNCFLAG_FHIDDEN |
+ FUNCFLAG_FNONBROWSABLE)) {
+ visible = Qfalse;
+ } else {
+ visible = Qtrue;
+ }
+ pTypeInfo->lpVtbl->ReleaseFuncDesc(pTypeInfo, pFuncDesc);
+ return visible;
+}
+
+/*
+ * call-seq:
+ * WIN32OLE_METHOD#visible?
+ *
+ * Returns true if the method is public.
+ * tobj = WIN32OLE_TYPE.new('Microsoft Excel 9.0 Object Library', 'Workbooks')
+ * method = WIN32OLE_METHOD.new(tobj, 'Add')
+ * puts method.visible? # => true
+ */
+static VALUE
+folemethod_visible(VALUE self)
+{
+ struct olemethoddata *pmethod;
+ TypedData_Get_Struct(self, struct olemethoddata, &olemethod_datatype, pmethod);
+ return ole_method_visible(pmethod->pTypeInfo, pmethod->index);
+}
+
+static VALUE
+ole_method_event(ITypeInfo *pTypeInfo, UINT method_index, VALUE method_name)
+{
+ TYPEATTR *pTypeAttr;
+ HRESULT hr;
+ WORD i;
+ int flags;
+ HREFTYPE href;
+ ITypeInfo *pRefTypeInfo;
+ FUNCDESC *pFuncDesc;
+ BSTR bstr;
+ VALUE name;
+ VALUE event = Qfalse;
+
+ hr = OLE_GET_TYPEATTR(pTypeInfo, &pTypeAttr);
+ if (FAILED(hr))
+ return event;
+ if(pTypeAttr->typekind != TKIND_COCLASS) {
+ pTypeInfo->lpVtbl->ReleaseTypeAttr(pTypeInfo, pTypeAttr);
+ return event;
+ }
+ for (i = 0; i < pTypeAttr->cImplTypes; i++) {
+ hr = pTypeInfo->lpVtbl->GetImplTypeFlags(pTypeInfo, i, &flags);
+ if (FAILED(hr))
+ continue;
+
+ if (flags & IMPLTYPEFLAG_FSOURCE) {
+ hr = pTypeInfo->lpVtbl->GetRefTypeOfImplType(pTypeInfo,
+ i, &href);
+ if (FAILED(hr))
+ continue;
+ hr = pTypeInfo->lpVtbl->GetRefTypeInfo(pTypeInfo,
+ href, &pRefTypeInfo);
+ if (FAILED(hr))
+ continue;
+ hr = pRefTypeInfo->lpVtbl->GetFuncDesc(pRefTypeInfo, method_index,
+ &pFuncDesc);
+ if (FAILED(hr)) {
+ OLE_RELEASE(pRefTypeInfo);
+ continue;
+ }
+
+ hr = pRefTypeInfo->lpVtbl->GetDocumentation(pRefTypeInfo,
+ pFuncDesc->memid,
+ &bstr, NULL, NULL, NULL);
+ if (FAILED(hr)) {
+ pRefTypeInfo->lpVtbl->ReleaseFuncDesc(pRefTypeInfo, pFuncDesc);
+ OLE_RELEASE(pRefTypeInfo);
+ continue;
+ }
+
+ name = WC2VSTR(bstr);
+ pRefTypeInfo->lpVtbl->ReleaseFuncDesc(pRefTypeInfo, pFuncDesc);
+ OLE_RELEASE(pRefTypeInfo);
+ if (rb_str_cmp(method_name, name) == 0) {
+ event = Qtrue;
+ break;
+ }
+ }
+ }
+ OLE_RELEASE_TYPEATTR(pTypeInfo, pTypeAttr);
+ return event;
+}
+
+/*
+ * call-seq:
+ * WIN32OLE_METHOD#event?
+ *
+ * Returns true if the method is event.
+ * tobj = WIN32OLE_TYPE.new('Microsoft Excel 9.0 Object Library', 'Workbook')
+ * method = WIN32OLE_METHOD.new(tobj, 'SheetActivate')
+ * puts method.event? # => true
+ *
+ */
+static VALUE
+folemethod_event(VALUE self)
+{
+ struct olemethoddata *pmethod;
+ TypedData_Get_Struct(self, struct olemethoddata, &olemethod_datatype, pmethod);
+ if (!pmethod->pOwnerTypeInfo)
+ return Qfalse;
+ return ole_method_event(pmethod->pOwnerTypeInfo,
+ pmethod->index,
+ rb_ivar_get(self, rb_intern("name")));
+}
+
+/*
+ * call-seq:
+ * WIN32OLE_METHOD#event_interface
+ *
+ * Returns event interface name if the method is event.
+ * tobj = WIN32OLE_TYPE.new('Microsoft Excel 9.0 Object Library', 'Workbook')
+ * method = WIN32OLE_METHOD.new(tobj, 'SheetActivate')
+ * puts method.event_interface # => WorkbookEvents
+ */
+static VALUE
+folemethod_event_interface(VALUE self)
+{
+ BSTR name;
+ struct olemethoddata *pmethod;
+ HRESULT hr;
+ TypedData_Get_Struct(self, struct olemethoddata, &olemethod_datatype, pmethod);
+ if(folemethod_event(self) == Qtrue) {
+ hr = ole_docinfo_from_type(pmethod->pTypeInfo, &name, NULL, NULL, NULL);
+ if(SUCCEEDED(hr))
+ return WC2VSTR(name);
+ }
+ return Qnil;
+}
+
+static HRESULT
+ole_method_docinfo_from_type(
+ ITypeInfo *pTypeInfo,
+ UINT method_index,
+ BSTR *name,
+ BSTR *helpstr,
+ DWORD *helpcontext,
+ BSTR *helpfile
+ )
+{
+ FUNCDESC *pFuncDesc;
+ HRESULT hr;
+ hr = pTypeInfo->lpVtbl->GetFuncDesc(pTypeInfo, method_index, &pFuncDesc);
+ if (FAILED(hr))
+ return hr;
+ hr = pTypeInfo->lpVtbl->GetDocumentation(pTypeInfo, pFuncDesc->memid,
+ name, helpstr,
+ helpcontext, helpfile);
+ pTypeInfo->lpVtbl->ReleaseFuncDesc(pTypeInfo, pFuncDesc);
+ return hr;
+}
+
+static VALUE
+ole_method_helpstring(ITypeInfo *pTypeInfo, UINT method_index)
+{
+ HRESULT hr;
+ BSTR bhelpstring;
+ hr = ole_method_docinfo_from_type(pTypeInfo, method_index, NULL, &bhelpstring,
+ NULL, NULL);
+ if (FAILED(hr))
+ return Qnil;
+ return WC2VSTR(bhelpstring);
+}
+
+/*
+ * call-seq:
+ * WIN32OLE_METHOD#helpstring
+ *
+ * Returns help string of OLE method. If the help string is not found,
+ * then the method returns nil.
+ * tobj = WIN32OLE_TYPE.new('Microsoft Internet Controls', 'IWebBrowser')
+ * method = WIN32OLE_METHOD.new(tobj, 'Navigate')
+ * puts method.helpstring # => Navigates to a URL or file.
+ *
+ */
+static VALUE
+folemethod_helpstring(VALUE self)
+{
+ struct olemethoddata *pmethod;
+ TypedData_Get_Struct(self, struct olemethoddata, &olemethod_datatype, pmethod);
+ return ole_method_helpstring(pmethod->pTypeInfo, pmethod->index);
+}
+
+static VALUE
+ole_method_helpfile(ITypeInfo *pTypeInfo, UINT method_index)
+{
+ HRESULT hr;
+ BSTR bhelpfile;
+ hr = ole_method_docinfo_from_type(pTypeInfo, method_index, NULL, NULL,
+ NULL, &bhelpfile);
+ if (FAILED(hr))
+ return Qnil;
+ return WC2VSTR(bhelpfile);
+}
+
+/*
+ * call-seq:
+ * WIN32OLE_METHOD#helpfile
+ *
+ * Returns help file. If help file is not found, then
+ * the method returns nil.
+ * tobj = WIN32OLE_TYPE.new('Microsoft Excel 9.0 Object Library', 'Workbooks')
+ * method = WIN32OLE_METHOD.new(tobj, 'Add')
+ * puts method.helpfile # => C:\...\VBAXL9.CHM
+ */
+static VALUE
+folemethod_helpfile(VALUE self)
+{
+ struct olemethoddata *pmethod;
+ TypedData_Get_Struct(self, struct olemethoddata, &olemethod_datatype, pmethod);
+
+ return ole_method_helpfile(pmethod->pTypeInfo, pmethod->index);
+}
+
+static VALUE
+ole_method_helpcontext(ITypeInfo *pTypeInfo, UINT method_index)
+{
+ HRESULT hr;
+ DWORD helpcontext = 0;
+ hr = ole_method_docinfo_from_type(pTypeInfo, method_index, NULL, NULL,
+ &helpcontext, NULL);
+ if (FAILED(hr))
+ return Qnil;
+ return INT2FIX(helpcontext);
+}
+
+/*
+ * call-seq:
+ * WIN32OLE_METHOD#helpcontext
+ *
+ * Returns help context.
+ * tobj = WIN32OLE_TYPE.new('Microsoft Excel 9.0 Object Library', 'Workbooks')
+ * method = WIN32OLE_METHOD.new(tobj, 'Add')
+ * puts method.helpcontext # => 65717
+ */
+static VALUE
+folemethod_helpcontext(VALUE self)
+{
+ struct olemethoddata *pmethod;
+ TypedData_Get_Struct(self, struct olemethoddata, &olemethod_datatype, pmethod);
+ return ole_method_helpcontext(pmethod->pTypeInfo, pmethod->index);
+}
+
+static VALUE
+ole_method_dispid(ITypeInfo *pTypeInfo, UINT method_index)
+{
+ FUNCDESC *pFuncDesc;
+ HRESULT hr;
+ VALUE dispid = Qnil;
+ hr = pTypeInfo->lpVtbl->GetFuncDesc(pTypeInfo, method_index, &pFuncDesc);
+ if (FAILED(hr))
+ return dispid;
+ dispid = INT2NUM(pFuncDesc->memid);
+ pTypeInfo->lpVtbl->ReleaseFuncDesc(pTypeInfo, pFuncDesc);
+ return dispid;
+}
+
+/*
+ * call-seq:
+ * WIN32OLE_METHOD#dispid
+ *
+ * Returns dispatch ID.
+ * tobj = WIN32OLE_TYPE.new('Microsoft Excel 9.0 Object Library', 'Workbooks')
+ * method = WIN32OLE_METHOD.new(tobj, 'Add')
+ * puts method.dispid # => 181
+ */
+static VALUE
+folemethod_dispid(VALUE self)
+{
+ struct olemethoddata *pmethod;
+ TypedData_Get_Struct(self, struct olemethoddata, &olemethod_datatype, pmethod);
+ return ole_method_dispid(pmethod->pTypeInfo, pmethod->index);
+}
+
+static VALUE
+ole_method_offset_vtbl(ITypeInfo *pTypeInfo, UINT method_index)
+{
+ FUNCDESC *pFuncDesc;
+ HRESULT hr;
+ VALUE offset_vtbl = Qnil;
+ hr = pTypeInfo->lpVtbl->GetFuncDesc(pTypeInfo, method_index, &pFuncDesc);
+ if (FAILED(hr))
+ return offset_vtbl;
+ offset_vtbl = INT2FIX(pFuncDesc->oVft);
+ pTypeInfo->lpVtbl->ReleaseFuncDesc(pTypeInfo, pFuncDesc);
+ return offset_vtbl;
+}
+
+/*
+ * call-seq:
+ * WIN32OLE_METHOD#offset_vtbl
+ *
+ * Returns the offset ov VTBL.
+ * tobj = WIN32OLE_TYPE.new('Microsoft Excel 9.0 Object Library', 'Workbooks')
+ * method = WIN32OLE_METHOD.new(tobj, 'Add')
+ * puts method.offset_vtbl # => 40
+ */
+static VALUE
+folemethod_offset_vtbl(VALUE self)
+{
+ struct olemethoddata *pmethod;
+ TypedData_Get_Struct(self, struct olemethoddata, &olemethod_datatype, pmethod);
+ return ole_method_offset_vtbl(pmethod->pTypeInfo, pmethod->index);
+}
+
+static VALUE
+ole_method_size_params(ITypeInfo *pTypeInfo, UINT method_index)
+{
+ FUNCDESC *pFuncDesc;
+ HRESULT hr;
+ VALUE size_params = Qnil;
+ hr = pTypeInfo->lpVtbl->GetFuncDesc(pTypeInfo, method_index, &pFuncDesc);
+ if (FAILED(hr))
+ return size_params;
+ size_params = INT2FIX(pFuncDesc->cParams);
+ pTypeInfo->lpVtbl->ReleaseFuncDesc(pTypeInfo, pFuncDesc);
+ return size_params;
+}
+
+/*
+ * call-seq:
+ * WIN32OLE_METHOD#size_params
+ *
+ * Returns the size of arguments of the method.
+ * tobj = WIN32OLE_TYPE.new('Microsoft Excel 9.0 Object Library', 'Workbook')
+ * method = WIN32OLE_METHOD.new(tobj, 'SaveAs')
+ * puts method.size_params # => 11
+ *
+ */
+static VALUE
+folemethod_size_params(VALUE self)
+{
+ struct olemethoddata *pmethod;
+ TypedData_Get_Struct(self, struct olemethoddata, &olemethod_datatype, pmethod);
+ return ole_method_size_params(pmethod->pTypeInfo, pmethod->index);
+}
+
+static VALUE
+ole_method_size_opt_params(ITypeInfo *pTypeInfo, UINT method_index)
+{
+ FUNCDESC *pFuncDesc;
+ HRESULT hr;
+ VALUE size_opt_params = Qnil;
+ hr = pTypeInfo->lpVtbl->GetFuncDesc(pTypeInfo, method_index, &pFuncDesc);
+ if (FAILED(hr))
+ return size_opt_params;
+ size_opt_params = INT2FIX(pFuncDesc->cParamsOpt);
+ pTypeInfo->lpVtbl->ReleaseFuncDesc(pTypeInfo, pFuncDesc);
+ return size_opt_params;
+}
+
+/*
+ * call-seq:
+ * WIN32OLE_METHOD#size_opt_params
+ *
+ * Returns the size of optional parameters.
+ * tobj = WIN32OLE_TYPE.new('Microsoft Excel 9.0 Object Library', 'Workbook')
+ * method = WIN32OLE_METHOD.new(tobj, 'SaveAs')
+ * puts method.size_opt_params # => 4
+ */
+static VALUE
+folemethod_size_opt_params(VALUE self)
+{
+ struct olemethoddata *pmethod;
+ TypedData_Get_Struct(self, struct olemethoddata, &olemethod_datatype, pmethod);
+ return ole_method_size_opt_params(pmethod->pTypeInfo, pmethod->index);
+}
+
+static VALUE
+ole_method_params(ITypeInfo *pTypeInfo, UINT method_index)
+{
+ FUNCDESC *pFuncDesc;
+ HRESULT hr;
+ BSTR *bstrs;
+ UINT len, i;
+ VALUE param;
+ VALUE params = rb_ary_new();
+ hr = pTypeInfo->lpVtbl->GetFuncDesc(pTypeInfo, method_index, &pFuncDesc);
+ if (FAILED(hr))
+ return params;
+
+ len = 0;
+ bstrs = ALLOCA_N(BSTR, pFuncDesc->cParams + 1);
+ hr = pTypeInfo->lpVtbl->GetNames(pTypeInfo, pFuncDesc->memid,
+ bstrs, pFuncDesc->cParams + 1,
+ &len);
+ if (FAILED(hr)) {
+ pTypeInfo->lpVtbl->ReleaseFuncDesc(pTypeInfo, pFuncDesc);
+ return params;
+ }
+ SysFreeString(bstrs[0]);
+ if (pFuncDesc->cParams > 0) {
+ for(i = 1; i < len; i++) {
+ param = create_win32ole_param(pTypeInfo, method_index, i-1, WC2VSTR(bstrs[i]));
+ rb_ary_push(params, param);
+ }
+ }
+ pTypeInfo->lpVtbl->ReleaseFuncDesc(pTypeInfo, pFuncDesc);
+ return params;
+}
+
+/*
+ * call-seq:
+ * WIN32OLE_METHOD#params
+ *
+ * returns array of WIN32OLE_PARAM object corresponding with method parameters.
+ * tobj = WIN32OLE_TYPE.new('Microsoft Excel 9.0 Object Library', 'Workbook')
+ * method = WIN32OLE_METHOD.new(tobj, 'SaveAs')
+ * p method.params # => [Filename, FileFormat, Password, WriteResPassword,
+ * ReadOnlyRecommended, CreateBackup, AccessMode,
+ * ConflictResolution, AddToMru, TextCodepage,
+ * TextVisualLayout]
+ */
+static VALUE
+folemethod_params(VALUE self)
+{
+ struct olemethoddata *pmethod;
+ TypedData_Get_Struct(self, struct olemethoddata, &olemethod_datatype, pmethod);
+ return ole_method_params(pmethod->pTypeInfo, pmethod->index);
+}
+
+/*
+ * call-seq:
+ * WIN32OLE_METHOD#inspect -> String
+ *
+ * Returns the method name with class name.
+ *
+ */
+static VALUE
+folemethod_inspect(VALUE self)
+{
+ return default_inspect(self, "WIN32OLE_METHOD");
+}
+
+void Init_win32ole_method(void)
+{
+ cWIN32OLE_METHOD = rb_define_class("WIN32OLE_METHOD", rb_cObject);
+ rb_define_alloc_func(cWIN32OLE_METHOD, folemethod_s_allocate);
+ rb_define_method(cWIN32OLE_METHOD, "initialize", folemethod_initialize, 2);
+ rb_define_method(cWIN32OLE_METHOD, "name", folemethod_name, 0);
+ rb_define_method(cWIN32OLE_METHOD, "return_type", folemethod_return_type, 0);
+ rb_define_method(cWIN32OLE_METHOD, "return_vtype", folemethod_return_vtype, 0);
+ rb_define_method(cWIN32OLE_METHOD, "return_type_detail", folemethod_return_type_detail, 0);
+ rb_define_method(cWIN32OLE_METHOD, "invoke_kind", folemethod_invoke_kind, 0);
+ rb_define_method(cWIN32OLE_METHOD, "invkind", folemethod_invkind, 0);
+ rb_define_method(cWIN32OLE_METHOD, "visible?", folemethod_visible, 0);
+ rb_define_method(cWIN32OLE_METHOD, "event?", folemethod_event, 0);
+ rb_define_method(cWIN32OLE_METHOD, "event_interface", folemethod_event_interface, 0);
+ rb_define_method(cWIN32OLE_METHOD, "helpstring", folemethod_helpstring, 0);
+ rb_define_method(cWIN32OLE_METHOD, "helpfile", folemethod_helpfile, 0);
+ rb_define_method(cWIN32OLE_METHOD, "helpcontext", folemethod_helpcontext, 0);
+ rb_define_method(cWIN32OLE_METHOD, "dispid", folemethod_dispid, 0);
+ rb_define_method(cWIN32OLE_METHOD, "offset_vtbl", folemethod_offset_vtbl, 0);
+ rb_define_method(cWIN32OLE_METHOD, "size_params", folemethod_size_params, 0);
+ rb_define_method(cWIN32OLE_METHOD, "size_opt_params", folemethod_size_opt_params, 0);
+ rb_define_method(cWIN32OLE_METHOD, "params", folemethod_params, 0);
+ rb_define_alias(cWIN32OLE_METHOD, "to_s", "name");
+ rb_define_method(cWIN32OLE_METHOD, "inspect", folemethod_inspect, 0);
+}
diff --git a/jni/ruby/ext/win32ole/win32ole_method.h b/jni/ruby/ext/win32ole/win32ole_method.h
new file mode 100644
index 0000000..ff2898e
--- /dev/null
+++ b/jni/ruby/ext/win32ole/win32ole_method.h
@@ -0,0 +1,16 @@
+#ifndef WIN32OLE_METHOD_H
+#define WIN32OLE_METHOD_H 1
+
+struct olemethoddata {
+ ITypeInfo *pOwnerTypeInfo;
+ ITypeInfo *pTypeInfo;
+ UINT index;
+};
+
+VALUE cWIN32OLE_METHOD;
+VALUE folemethod_s_allocate(VALUE klass);
+VALUE ole_methods_from_typeinfo(ITypeInfo *pTypeInfo, int mask);
+VALUE create_win32ole_method(ITypeInfo *pTypeInfo, VALUE name);
+struct olemethoddata *olemethod_data_get_struct(VALUE obj);
+void Init_win32ole_method(void);
+#endif
diff --git a/jni/ruby/ext/win32ole/win32ole_param.c b/jni/ruby/ext/win32ole/win32ole_param.c
new file mode 100644
index 0000000..31cf853
--- /dev/null
+++ b/jni/ruby/ext/win32ole/win32ole_param.c
@@ -0,0 +1,438 @@
+#include "win32ole.h"
+
+VALUE cWIN32OLE_PARAM;
+
+struct oleparamdata {
+ ITypeInfo *pTypeInfo;
+ UINT method_index;
+ UINT index;
+};
+
+static void oleparam_free(void *ptr);
+static size_t oleparam_size(const void *ptr);
+static VALUE foleparam_s_allocate(VALUE klass);
+static VALUE oleparam_ole_param_from_index(VALUE self, ITypeInfo *pTypeInfo, UINT method_index, int param_index);
+static VALUE oleparam_ole_param(VALUE self, VALUE olemethod, int n);
+static VALUE foleparam_initialize(VALUE self, VALUE olemethod, VALUE n);
+static VALUE foleparam_name(VALUE self);
+static VALUE ole_param_ole_type(ITypeInfo *pTypeInfo, UINT method_index, UINT index);
+static VALUE foleparam_ole_type(VALUE self);
+static VALUE ole_param_ole_type_detail(ITypeInfo *pTypeInfo, UINT method_index, UINT index);
+static VALUE foleparam_ole_type_detail(VALUE self);
+static VALUE ole_param_flag_mask(ITypeInfo *pTypeInfo, UINT method_index, UINT index, USHORT mask);
+static VALUE foleparam_input(VALUE self);
+static VALUE foleparam_output(VALUE self);
+static VALUE foleparam_optional(VALUE self);
+static VALUE foleparam_retval(VALUE self);
+static VALUE ole_param_default(ITypeInfo *pTypeInfo, UINT method_index, UINT index);
+static VALUE foleparam_default(VALUE self);
+static VALUE foleparam_inspect(VALUE self);
+
+static const rb_data_type_t oleparam_datatype = {
+ "win32ole_param",
+ {NULL, oleparam_free, oleparam_size,},
+ 0, 0, RUBY_TYPED_FREE_IMMEDIATELY
+};
+
+static void
+oleparam_free(void *ptr)
+{
+ struct oleparamdata *pole = ptr;
+ OLE_FREE(pole->pTypeInfo);
+ free(pole);
+}
+
+static size_t
+oleparam_size(const void *ptr)
+{
+ return ptr ? sizeof(struct oleparamdata) : 0;
+}
+
+VALUE
+create_win32ole_param(ITypeInfo *pTypeInfo, UINT method_index, UINT index, VALUE name)
+{
+ struct oleparamdata *pparam;
+ VALUE obj = foleparam_s_allocate(cWIN32OLE_PARAM);
+ TypedData_Get_Struct(obj, struct oleparamdata, &oleparam_datatype, pparam);
+
+ pparam->pTypeInfo = pTypeInfo;
+ OLE_ADDREF(pTypeInfo);
+ pparam->method_index = method_index;
+ pparam->index = index;
+ rb_ivar_set(obj, rb_intern("name"), name);
+ return obj;
+}
+
+/*
+ * Document-class: WIN32OLE_PARAM
+ *
+ * <code>WIN32OLE_PARAM</code> objects represent param information of
+ * the OLE method.
+ */
+static VALUE
+foleparam_s_allocate(VALUE klass)
+{
+ struct oleparamdata *pparam;
+ VALUE obj;
+ obj = TypedData_Make_Struct(klass,
+ struct oleparamdata,
+ &oleparam_datatype, pparam);
+ pparam->pTypeInfo = NULL;
+ pparam->method_index = 0;
+ pparam->index = 0;
+ return obj;
+}
+
+static VALUE
+oleparam_ole_param_from_index(VALUE self, ITypeInfo *pTypeInfo, UINT method_index, int param_index)
+{
+ FUNCDESC *pFuncDesc;
+ HRESULT hr;
+ BSTR *bstrs;
+ UINT len;
+ struct oleparamdata *pparam;
+ hr = pTypeInfo->lpVtbl->GetFuncDesc(pTypeInfo, method_index, &pFuncDesc);
+ if (FAILED(hr))
+ ole_raise(hr, rb_eRuntimeError, "fail to ITypeInfo::GetFuncDesc");
+
+ len = 0;
+ bstrs = ALLOCA_N(BSTR, pFuncDesc->cParams + 1);
+ hr = pTypeInfo->lpVtbl->GetNames(pTypeInfo, pFuncDesc->memid,
+ bstrs, pFuncDesc->cParams + 1,
+ &len);
+ if (FAILED(hr)) {
+ pTypeInfo->lpVtbl->ReleaseFuncDesc(pTypeInfo, pFuncDesc);
+ ole_raise(hr, rb_eRuntimeError, "fail to ITypeInfo::GetNames");
+ }
+ SysFreeString(bstrs[0]);
+ if (param_index < 1 || len <= (UINT)param_index)
+ {
+ pTypeInfo->lpVtbl->ReleaseFuncDesc(pTypeInfo, pFuncDesc);
+ rb_raise(rb_eIndexError, "index of param must be in 1..%d", len);
+ }
+
+ TypedData_Get_Struct(self, struct oleparamdata, &oleparam_datatype, pparam);
+ pparam->pTypeInfo = pTypeInfo;
+ OLE_ADDREF(pTypeInfo);
+ pparam->method_index = method_index;
+ pparam->index = param_index - 1;
+ rb_ivar_set(self, rb_intern("name"), WC2VSTR(bstrs[param_index]));
+
+ pTypeInfo->lpVtbl->ReleaseFuncDesc(pTypeInfo, pFuncDesc);
+ return self;
+}
+
+static VALUE
+oleparam_ole_param(VALUE self, VALUE olemethod, int n)
+{
+ struct olemethoddata *pmethod = olemethod_data_get_struct(olemethod);
+ return oleparam_ole_param_from_index(self, pmethod->pTypeInfo, pmethod->index, n);
+}
+
+/*
+ * call-seq:
+ * WIN32OLE_PARAM.new(method, n) -> WIN32OLE_PARAM object
+ *
+ * Returns WIN32OLE_PARAM object which represents OLE parameter information.
+ * 1st argument should be WIN32OLE_METHOD object.
+ * 2nd argument `n' is n-th parameter of the method specified by 1st argument.
+ *
+ * tobj = WIN32OLE_TYPE.new('Microsoft Scripting Runtime', 'IFileSystem')
+ * method = WIN32OLE_METHOD.new(tobj, 'CreateTextFile')
+ * param = WIN32OLE_PARAM.new(method, 2) # => #<WIN32OLE_PARAM:Overwrite=true>
+ *
+ */
+static VALUE
+foleparam_initialize(VALUE self, VALUE olemethod, VALUE n)
+{
+ int idx;
+ if (!rb_obj_is_kind_of(olemethod, cWIN32OLE_METHOD)) {
+ rb_raise(rb_eTypeError, "1st parameter must be WIN32OLE_METHOD object");
+ }
+ idx = FIX2INT(n);
+ return oleparam_ole_param(self, olemethod, idx);
+}
+
+/*
+ * call-seq:
+ * WIN32OLE_PARAM#name
+ *
+ * Returns name.
+ * tobj = WIN32OLE_TYPE.new('Microsoft Excel 9.0 Object Library', 'Workbook')
+ * method = WIN32OLE_METHOD.new(tobj, 'SaveAs')
+ * param1 = method.params[0]
+ * puts param1.name # => Filename
+ */
+static VALUE
+foleparam_name(VALUE self)
+{
+ return rb_ivar_get(self, rb_intern("name"));
+}
+
+static VALUE
+ole_param_ole_type(ITypeInfo *pTypeInfo, UINT method_index, UINT index)
+{
+ FUNCDESC *pFuncDesc;
+ HRESULT hr;
+ VALUE type = rb_str_new2("unknown type");
+ hr = pTypeInfo->lpVtbl->GetFuncDesc(pTypeInfo, method_index, &pFuncDesc);
+ if (FAILED(hr))
+ return type;
+ type = ole_typedesc2val(pTypeInfo,
+ &(pFuncDesc->lprgelemdescParam[index].tdesc), Qnil);
+ pTypeInfo->lpVtbl->ReleaseFuncDesc(pTypeInfo, pFuncDesc);
+ return type;
+}
+
+/*
+ * call-seq:
+ * WIN32OLE_PARAM#ole_type
+ *
+ * Returns OLE type of WIN32OLE_PARAM object(parameter of OLE method).
+ * tobj = WIN32OLE_TYPE.new('Microsoft Excel 9.0 Object Library', 'Workbook')
+ * method = WIN32OLE_METHOD.new(tobj, 'SaveAs')
+ * param1 = method.params[0]
+ * puts param1.ole_type # => VARIANT
+ */
+static VALUE
+foleparam_ole_type(VALUE self)
+{
+ struct oleparamdata *pparam;
+ TypedData_Get_Struct(self, struct oleparamdata, &oleparam_datatype, pparam);
+ return ole_param_ole_type(pparam->pTypeInfo, pparam->method_index,
+ pparam->index);
+}
+
+static VALUE
+ole_param_ole_type_detail(ITypeInfo *pTypeInfo, UINT method_index, UINT index)
+{
+ FUNCDESC *pFuncDesc;
+ HRESULT hr;
+ VALUE typedetail = rb_ary_new();
+ hr = pTypeInfo->lpVtbl->GetFuncDesc(pTypeInfo, method_index, &pFuncDesc);
+ if (FAILED(hr))
+ return typedetail;
+ ole_typedesc2val(pTypeInfo,
+ &(pFuncDesc->lprgelemdescParam[index].tdesc), typedetail);
+ pTypeInfo->lpVtbl->ReleaseFuncDesc(pTypeInfo, pFuncDesc);
+ return typedetail;
+}
+
+/*
+ * call-seq:
+ * WIN32OLE_PARAM#ole_type_detail
+ *
+ * Returns detail information of type of argument.
+ * tobj = WIN32OLE_TYPE.new('Microsoft Excel 9.0 Object Library', 'IWorksheetFunction')
+ * method = WIN32OLE_METHOD.new(tobj, 'SumIf')
+ * param1 = method.params[0]
+ * p param1.ole_type_detail # => ["PTR", "USERDEFINED", "Range"]
+ */
+static VALUE
+foleparam_ole_type_detail(VALUE self)
+{
+ struct oleparamdata *pparam;
+ TypedData_Get_Struct(self, struct oleparamdata, &oleparam_datatype, pparam);
+ return ole_param_ole_type_detail(pparam->pTypeInfo, pparam->method_index,
+ pparam->index);
+}
+
+static VALUE
+ole_param_flag_mask(ITypeInfo *pTypeInfo, UINT method_index, UINT index, USHORT mask)
+{
+ FUNCDESC *pFuncDesc;
+ HRESULT hr;
+ VALUE ret = Qfalse;
+ hr = pTypeInfo->lpVtbl->GetFuncDesc(pTypeInfo, method_index, &pFuncDesc);
+ if(FAILED(hr))
+ return ret;
+ if (V_UNION1((&(pFuncDesc->lprgelemdescParam[index])), paramdesc).wParamFlags &mask)
+ ret = Qtrue;
+ pTypeInfo->lpVtbl->ReleaseFuncDesc(pTypeInfo, pFuncDesc);
+ return ret;
+}
+
+/*
+ * call-seq:
+ * WIN32OLE_PARAM#input?
+ *
+ * Returns true if the parameter is input.
+ * tobj = WIN32OLE_TYPE.new('Microsoft Excel 9.0 Object Library', 'Workbook')
+ * method = WIN32OLE_METHOD.new(tobj, 'SaveAs')
+ * param1 = method.params[0]
+ * puts param1.input? # => true
+ */
+static VALUE
+foleparam_input(VALUE self)
+{
+ struct oleparamdata *pparam;
+ TypedData_Get_Struct(self, struct oleparamdata, &oleparam_datatype, pparam);
+ return ole_param_flag_mask(pparam->pTypeInfo, pparam->method_index,
+ pparam->index, PARAMFLAG_FIN);
+}
+
+/*
+ * call-seq:
+ * WIN32OLE#output?
+ *
+ * Returns true if argument is output.
+ * tobj = WIN32OLE_TYPE.new('Microsoft Internet Controls', 'DWebBrowserEvents')
+ * method = WIN32OLE_METHOD.new(tobj, 'NewWindow')
+ * method.params.each do |param|
+ * puts "#{param.name} #{param.output?}"
+ * end
+ *
+ * The result of above script is following:
+ * URL false
+ * Flags false
+ * TargetFrameName false
+ * PostData false
+ * Headers false
+ * Processed true
+ */
+static VALUE
+foleparam_output(VALUE self)
+{
+ struct oleparamdata *pparam;
+ TypedData_Get_Struct(self, struct oleparamdata, &oleparam_datatype, pparam);
+ return ole_param_flag_mask(pparam->pTypeInfo, pparam->method_index,
+ pparam->index, PARAMFLAG_FOUT);
+}
+
+/*
+ * call-seq:
+ * WIN32OLE_PARAM#optional?
+ *
+ * Returns true if argument is optional.
+ * tobj = WIN32OLE_TYPE.new('Microsoft Excel 9.0 Object Library', 'Workbook')
+ * method = WIN32OLE_METHOD.new(tobj, 'SaveAs')
+ * param1 = method.params[0]
+ * puts "#{param1.name} #{param1.optional?}" # => Filename true
+ */
+static VALUE
+foleparam_optional(VALUE self)
+{
+ struct oleparamdata *pparam;
+ TypedData_Get_Struct(self, struct oleparamdata, &oleparam_datatype, pparam);
+ return ole_param_flag_mask(pparam->pTypeInfo, pparam->method_index,
+ pparam->index, PARAMFLAG_FOPT);
+}
+
+/*
+ * call-seq:
+ * WIN32OLE_PARAM#retval?
+ *
+ * Returns true if argument is return value.
+ * tobj = WIN32OLE_TYPE.new('DirectX 7 for Visual Basic Type Library',
+ * 'DirectPlayLobbyConnection')
+ * method = WIN32OLE_METHOD.new(tobj, 'GetPlayerShortName')
+ * param = method.params[0]
+ * puts "#{param.name} #{param.retval?}" # => name true
+ */
+static VALUE
+foleparam_retval(VALUE self)
+{
+ struct oleparamdata *pparam;
+ TypedData_Get_Struct(self, struct oleparamdata, &oleparam_datatype, pparam);
+ return ole_param_flag_mask(pparam->pTypeInfo, pparam->method_index,
+ pparam->index, PARAMFLAG_FRETVAL);
+}
+
+static VALUE
+ole_param_default(ITypeInfo *pTypeInfo, UINT method_index, UINT index)
+{
+ FUNCDESC *pFuncDesc;
+ ELEMDESC *pElemDesc;
+ PARAMDESCEX * pParamDescEx;
+ HRESULT hr;
+ USHORT wParamFlags;
+ USHORT mask = PARAMFLAG_FOPT|PARAMFLAG_FHASDEFAULT;
+ VALUE defval = Qnil;
+ hr = pTypeInfo->lpVtbl->GetFuncDesc(pTypeInfo, method_index, &pFuncDesc);
+ if (FAILED(hr))
+ return defval;
+ pElemDesc = &pFuncDesc->lprgelemdescParam[index];
+ wParamFlags = V_UNION1(pElemDesc, paramdesc).wParamFlags;
+ if ((wParamFlags & mask) == mask) {
+ pParamDescEx = V_UNION1(pElemDesc, paramdesc).pparamdescex;
+ defval = ole_variant2val(&pParamDescEx->varDefaultValue);
+ }
+ pTypeInfo->lpVtbl->ReleaseFuncDesc(pTypeInfo, pFuncDesc);
+ return defval;
+}
+
+/*
+ * call-seq:
+ * WIN32OLE_PARAM#default
+ *
+ * Returns default value. If the default value does not exist,
+ * this method returns nil.
+ * tobj = WIN32OLE_TYPE.new('Microsoft Excel 9.0 Object Library', 'Workbook')
+ * method = WIN32OLE_METHOD.new(tobj, 'SaveAs')
+ * method.params.each do |param|
+ * if param.default
+ * puts "#{param.name} (= #{param.default})"
+ * else
+ * puts "#{param}"
+ * end
+ * end
+ *
+ * The above script result is following:
+ * Filename
+ * FileFormat
+ * Password
+ * WriteResPassword
+ * ReadOnlyRecommended
+ * CreateBackup
+ * AccessMode (= 1)
+ * ConflictResolution
+ * AddToMru
+ * TextCodepage
+ * TextVisualLayout
+ */
+static VALUE
+foleparam_default(VALUE self)
+{
+ struct oleparamdata *pparam;
+ TypedData_Get_Struct(self, struct oleparamdata, &oleparam_datatype, pparam);
+ return ole_param_default(pparam->pTypeInfo, pparam->method_index,
+ pparam->index);
+}
+
+/*
+ * call-seq:
+ * WIN32OLE_PARAM#inspect -> String
+ *
+ * Returns the parameter name with class name. If the parameter has default value,
+ * then returns name=value string with class name.
+ *
+ */
+static VALUE
+foleparam_inspect(VALUE self)
+{
+ VALUE detail = foleparam_name(self);
+ VALUE defval = foleparam_default(self);
+ if (defval != Qnil) {
+ rb_str_cat2(detail, "=");
+ rb_str_concat(detail, rb_inspect(defval));
+ }
+ return make_inspect("WIN32OLE_PARAM", detail);
+}
+
+void
+Init_win32ole_param(void)
+{
+ cWIN32OLE_PARAM = rb_define_class("WIN32OLE_PARAM", rb_cObject);
+ rb_define_alloc_func(cWIN32OLE_PARAM, foleparam_s_allocate);
+ rb_define_method(cWIN32OLE_PARAM, "initialize", foleparam_initialize, 2);
+ rb_define_method(cWIN32OLE_PARAM, "name", foleparam_name, 0);
+ rb_define_method(cWIN32OLE_PARAM, "ole_type", foleparam_ole_type, 0);
+ rb_define_method(cWIN32OLE_PARAM, "ole_type_detail", foleparam_ole_type_detail, 0);
+ rb_define_method(cWIN32OLE_PARAM, "input?", foleparam_input, 0);
+ rb_define_method(cWIN32OLE_PARAM, "output?", foleparam_output, 0);
+ rb_define_method(cWIN32OLE_PARAM, "optional?", foleparam_optional, 0);
+ rb_define_method(cWIN32OLE_PARAM, "retval?", foleparam_retval, 0);
+ rb_define_method(cWIN32OLE_PARAM, "default", foleparam_default, 0);
+ rb_define_alias(cWIN32OLE_PARAM, "to_s", "name");
+ rb_define_method(cWIN32OLE_PARAM, "inspect", foleparam_inspect, 0);
+}
diff --git a/jni/ruby/ext/win32ole/win32ole_param.h b/jni/ruby/ext/win32ole/win32ole_param.h
new file mode 100644
index 0000000..7e2650c
--- /dev/null
+++ b/jni/ruby/ext/win32ole/win32ole_param.h
@@ -0,0 +1,8 @@
+#ifndef WIN32OLE_PARAM_H
+#define WIN32OLE_PARAM_H
+
+VALUE create_win32ole_param(ITypeInfo *pTypeInfo, UINT method_index, UINT index, VALUE name);
+void Init_win32ole_param(void);
+
+#endif
+
diff --git a/jni/ruby/ext/win32ole/win32ole_record.c b/jni/ruby/ext/win32ole/win32ole_record.c
new file mode 100644
index 0000000..28d6238
--- /dev/null
+++ b/jni/ruby/ext/win32ole/win32ole_record.c
@@ -0,0 +1,604 @@
+#include "win32ole.h"
+
+struct olerecorddata {
+ IRecordInfo *pri;
+ void *pdata;
+};
+
+static HRESULT recordinfo_from_itypelib(ITypeLib *pTypeLib, VALUE name, IRecordInfo **ppri);
+static int hash2olerec(VALUE key, VALUE val, VALUE rec);
+static void olerecord_free(void *pvar);
+static size_t olerecord_size(const void *ptr);
+static VALUE folerecord_s_allocate(VALUE klass);
+static VALUE folerecord_initialize(VALUE self, VALUE typename, VALUE oleobj);
+static VALUE folerecord_to_h(VALUE self);
+static VALUE folerecord_typename(VALUE self);
+static VALUE olerecord_ivar_get(VALUE self, VALUE name);
+static VALUE olerecord_ivar_set(VALUE self, VALUE name, VALUE val);
+static VALUE folerecord_method_missing(int argc, VALUE *argv, VALUE self);
+static VALUE folerecord_ole_instance_variable_get(VALUE self, VALUE name);
+static VALUE folerecord_ole_instance_variable_set(VALUE self, VALUE name, VALUE val);
+static VALUE folerecord_inspect(VALUE self);
+
+static const rb_data_type_t olerecord_datatype = {
+ "win32ole_record",
+ {NULL, olerecord_free, olerecord_size,},
+ 0, 0, RUBY_TYPED_FREE_IMMEDIATELY
+};
+
+static HRESULT
+recordinfo_from_itypelib(ITypeLib *pTypeLib, VALUE name, IRecordInfo **ppri)
+{
+
+ unsigned int count;
+ unsigned int i;
+ ITypeInfo *pTypeInfo;
+ HRESULT hr = OLE_E_LAST;
+ BSTR bstr;
+
+ count = pTypeLib->lpVtbl->GetTypeInfoCount(pTypeLib);
+ for (i = 0; i < count; i++) {
+ hr = pTypeLib->lpVtbl->GetDocumentation(pTypeLib, i,
+ &bstr, NULL, NULL, NULL);
+ if (FAILED(hr))
+ continue;
+
+ hr = pTypeLib->lpVtbl->GetTypeInfo(pTypeLib, i, &pTypeInfo);
+ if (FAILED(hr))
+ continue;
+
+ if (rb_str_cmp(WC2VSTR(bstr), name) == 0) {
+ hr = GetRecordInfoFromTypeInfo(pTypeInfo, ppri);
+ OLE_RELEASE(pTypeInfo);
+ return hr;
+ }
+ OLE_RELEASE(pTypeInfo);
+ }
+ hr = OLE_E_LAST;
+ return hr;
+}
+
+static int
+hash2olerec(VALUE key, VALUE val, VALUE rec)
+{
+ VARIANT var;
+ OLECHAR *pbuf;
+ struct olerecorddata *prec;
+ IRecordInfo *pri;
+ HRESULT hr;
+
+ if (val != Qnil) {
+ TypedData_Get_Struct(rec, struct olerecorddata, &olerecord_datatype, prec);
+ pri = prec->pri;
+ VariantInit(&var);
+ ole_val2variant(val, &var);
+ pbuf = ole_vstr2wc(key);
+ hr = pri->lpVtbl->PutField(pri, INVOKE_PROPERTYPUT, prec->pdata, pbuf, &var);
+ SysFreeString(pbuf);
+ VariantClear(&var);
+ if (FAILED(hr)) {
+ ole_raise(hr, eWIN32OLERuntimeError, "failed to putfield of `%s`", StringValuePtr(key));
+ }
+ }
+ return ST_CONTINUE;
+}
+
+void
+ole_rec2variant(VALUE rec, VARIANT *var)
+{
+ struct olerecorddata *prec;
+ ULONG size = 0;
+ IRecordInfo *pri;
+ HRESULT hr;
+ VALUE fields;
+ TypedData_Get_Struct(rec, struct olerecorddata, &olerecord_datatype, prec);
+ pri = prec->pri;
+ if (pri) {
+ hr = pri->lpVtbl->GetSize(pri, &size);
+ if (FAILED(hr)) {
+ ole_raise(hr, eWIN32OLERuntimeError, "failed to get size for allocation of VT_RECORD object");
+ }
+ if (prec->pdata) {
+ free(prec->pdata);
+ }
+ prec->pdata = ALLOC_N(char, size);
+ if (!prec->pdata) {
+ rb_raise(rb_eRuntimeError, "failed to memory allocation of %lu bytes", (unsigned long)size);
+ }
+ hr = pri->lpVtbl->RecordInit(pri, prec->pdata);
+ if (FAILED(hr)) {
+ ole_raise(hr, eWIN32OLERuntimeError, "failed to initialize VT_RECORD object");
+ }
+ fields = folerecord_to_h(rec);
+ rb_hash_foreach(fields, hash2olerec, rec);
+ V_RECORDINFO(var) = pri;
+ V_RECORD(var) = prec->pdata;
+ V_VT(var) = VT_RECORD;
+ } else {
+ rb_raise(eWIN32OLERuntimeError, "failed to retrieve IRecordInfo interface");
+ }
+}
+
+void
+olerecord_set_ivar(VALUE obj, IRecordInfo *pri, void *prec)
+{
+ HRESULT hr;
+ BSTR bstr;
+ BSTR *bstrs;
+ ULONG count = 0;
+ ULONG i;
+ VALUE fields;
+ VALUE val;
+ VARIANT var;
+ void *pdata = NULL;
+ struct olerecorddata *pvar;
+
+ TypedData_Get_Struct(obj, struct olerecorddata, &olerecord_datatype, pvar);
+ OLE_ADDREF(pri);
+ OLE_RELEASE(pvar->pri);
+ pvar->pri = pri;
+
+ hr = pri->lpVtbl->GetName(pri, &bstr);
+ if (SUCCEEDED(hr)) {
+ rb_ivar_set(obj, rb_intern("typename"), WC2VSTR(bstr));
+ }
+
+ hr = pri->lpVtbl->GetFieldNames(pri, &count, NULL);
+ if (FAILED(hr) || count == 0)
+ return;
+ bstrs = ALLOCA_N(BSTR, count);
+ hr = pri->lpVtbl->GetFieldNames(pri, &count, bstrs);
+ if (FAILED(hr)) {
+ return;
+ }
+
+ fields = rb_hash_new();
+ rb_ivar_set(obj, rb_intern("fields"), fields);
+ for (i = 0; i < count; i++) {
+ pdata = NULL;
+ VariantInit(&var);
+ val = Qnil;
+ if (prec) {
+ hr = pri->lpVtbl->GetFieldNoCopy(pri, prec, bstrs[i], &var, &pdata);
+ if (SUCCEEDED(hr)) {
+ val = ole_variant2val(&var);
+ }
+ }
+ rb_hash_aset(fields, WC2VSTR(bstrs[i]), val);
+ }
+}
+
+VALUE
+create_win32ole_record(IRecordInfo *pri, void *prec)
+{
+ VALUE obj = folerecord_s_allocate(cWIN32OLE_RECORD);
+ olerecord_set_ivar(obj, pri, prec);
+ return obj;
+}
+
+/*
+ * Document-class: WIN32OLE_RECORD
+ *
+ * <code>WIN32OLE_RECORD</code> objects represents VT_RECORD OLE variant.
+ * Win32OLE returns WIN32OLE_RECORD object if the result value of invoking
+ * OLE methods.
+ *
+ * If COM server in VB.NET ComServer project is the following:
+ *
+ * Imports System.Runtime.InteropServices
+ * Public Class ComClass
+ * Public Structure Book
+ * <MarshalAs(UnmanagedType.BStr)> _
+ * Public title As String
+ * Public cost As Integer
+ * End Structure
+ * Public Function getBook() As Book
+ * Dim book As New Book
+ * book.title = "The Ruby Book"
+ * book.cost = 20
+ * Return book
+ * End Function
+ * End Class
+ *
+ * then, you can retrieve getBook return value from the following
+ * Ruby script:
+ *
+ * require 'win32ole'
+ * obj = WIN32OLE.new('ComServer.ComClass')
+ * book = obj.getBook
+ * book.class # => WIN32OLE_RECORD
+ * book.title # => "The Ruby Book"
+ * book.cost # => 20
+ *
+ */
+
+static void
+olerecord_free(void *ptr) {
+ struct olerecorddata *pvar = ptr;
+ OLE_FREE(pvar->pri);
+ if (pvar->pdata) {
+ free(pvar->pdata);
+ }
+ free(pvar);
+}
+
+static size_t
+olerecord_size(const void *ptr)
+{
+ const struct olerecorddata *pvar = ptr;
+ size_t s = 0;
+ ULONG size = 0;
+ HRESULT hr;
+ if (ptr) {
+ s += sizeof(struct olerecorddata);
+ if (pvar->pri) {
+ hr = pvar->pri->lpVtbl->GetSize(pvar->pri, &size);
+ if (SUCCEEDED(hr)) {
+ s += size;
+ }
+ }
+ }
+ return s;
+}
+
+static VALUE
+folerecord_s_allocate(VALUE klass) {
+ VALUE obj = Qnil;
+ struct olerecorddata *pvar;
+ obj = TypedData_Make_Struct(klass, struct olerecorddata, &olerecord_datatype, pvar);
+ pvar->pri = NULL;
+ pvar->pdata = NULL;
+ return obj;
+}
+
+/*
+ * call-seq:
+ * WIN32OLE_RECORD.new(typename, obj) -> WIN32OLE_RECORD object
+ *
+ * Returns WIN32OLE_RECORD object. The first argument is struct name (String
+ * or Symbol).
+ * The second parameter obj should be WIN32OLE object or WIN32OLE_TYPELIB object.
+ * If COM server in VB.NET ComServer project is the following:
+ *
+ * Imports System.Runtime.InteropServices
+ * Public Class ComClass
+ * Public Structure Book
+ * <MarshalAs(UnmanagedType.BStr)> _
+ * Public title As String
+ * Public cost As Integer
+ * End Structure
+ * End Class
+ *
+ * then, you can create WIN32OLE_RECORD object is as following:
+ *
+ * require 'win32ole'
+ * obj = WIN32OLE.new('ComServer.ComClass')
+ * book1 = WIN32OLE_RECORD.new('Book', obj) # => WIN32OLE_RECORD object
+ * tlib = obj.ole_typelib
+ * book2 = WIN32OLE_RECORD.new('Book', tlib) # => WIN32OLE_RECORD object
+ *
+ */
+static VALUE
+folerecord_initialize(VALUE self, VALUE typename, VALUE oleobj) {
+ HRESULT hr;
+ ITypeLib *pTypeLib = NULL;
+ IRecordInfo *pri = NULL;
+
+ if (!RB_TYPE_P(typename, T_STRING) && !RB_TYPE_P(typename, T_SYMBOL)) {
+ rb_raise(rb_eArgError, "1st argument should be String or Symbol");
+ }
+ if (RB_TYPE_P(typename, T_SYMBOL)) {
+ typename = rb_sym_to_s(typename);
+ }
+
+ hr = S_OK;
+ if(rb_obj_is_kind_of(oleobj, cWIN32OLE)) {
+ hr = typelib_from_val(oleobj, &pTypeLib);
+ } else if (rb_obj_is_kind_of(oleobj, cWIN32OLE_TYPELIB)) {
+ pTypeLib = itypelib(oleobj);
+ OLE_ADDREF(pTypeLib);
+ if (pTypeLib) {
+ hr = S_OK;
+ } else {
+ hr = E_FAIL;
+ }
+ } else {
+ rb_raise(rb_eArgError, "2nd argument should be WIN32OLE object or WIN32OLE_TYPELIB object");
+ }
+
+ if (FAILED(hr)) {
+ ole_raise(hr, eWIN32OLERuntimeError, "fail to query ITypeLib interface");
+ }
+
+ hr = recordinfo_from_itypelib(pTypeLib, typename, &pri);
+ OLE_RELEASE(pTypeLib);
+ if (FAILED(hr)) {
+ ole_raise(hr, eWIN32OLERuntimeError, "fail to query IRecordInfo interface for `%s'", StringValuePtr(typename));
+ }
+
+ olerecord_set_ivar(self, pri, NULL);
+
+ return self;
+}
+
+/*
+ * call-seq:
+ * WIN32OLE_RECORD#to_h #=> Ruby Hash object.
+ *
+ * Returns Ruby Hash object which represents VT_RECORD variable.
+ * The keys of Hash object are member names of VT_RECORD OLE variable and
+ * the values of Hash object are values of VT_RECORD OLE variable.
+ *
+ * If COM server in VB.NET ComServer project is the following:
+ *
+ * Imports System.Runtime.InteropServices
+ * Public Class ComClass
+ * Public Structure Book
+ * <MarshalAs(UnmanagedType.BStr)> _
+ * Public title As String
+ * Public cost As Integer
+ * End Structure
+ * Public Function getBook() As Book
+ * Dim book As New Book
+ * book.title = "The Ruby Book"
+ * book.cost = 20
+ * Return book
+ * End Function
+ * End Class
+ *
+ * then, the result of WIN32OLE_RECORD#to_h is the following:
+ *
+ * require 'win32ole'
+ * obj = WIN32OLE.new('ComServer.ComClass')
+ * book = obj.getBook
+ * book.to_h # => {"title"=>"The Ruby Book", "cost"=>20}
+ *
+ */
+static VALUE
+folerecord_to_h(VALUE self)
+{
+ return rb_ivar_get(self, rb_intern("fields"));
+}
+
+/*
+ * call-seq:
+ * WIN32OLE_RECORD#typename #=> String object
+ *
+ * Returns the type name of VT_RECORD OLE variable.
+ *
+ * If COM server in VB.NET ComServer project is the following:
+ *
+ * Imports System.Runtime.InteropServices
+ * Public Class ComClass
+ * Public Structure Book
+ * <MarshalAs(UnmanagedType.BStr)> _
+ * Public title As String
+ * Public cost As Integer
+ * End Structure
+ * Public Function getBook() As Book
+ * Dim book As New Book
+ * book.title = "The Ruby Book"
+ * book.cost = 20
+ * Return book
+ * End Function
+ * End Class
+ *
+ * then, the result of WIN32OLE_RECORD#typename is the following:
+ *
+ * require 'win32ole'
+ * obj = WIN32OLE.new('ComServer.ComClass')
+ * book = obj.getBook
+ * book.typename # => "Book"
+ *
+ */
+static VALUE
+folerecord_typename(VALUE self)
+{
+ return rb_ivar_get(self, rb_intern("typename"));
+}
+
+static VALUE
+olerecord_ivar_get(VALUE self, VALUE name)
+{
+ VALUE fields;
+ fields = rb_ivar_get(self, rb_intern("fields"));
+ return rb_hash_fetch(fields, name);
+}
+
+static VALUE
+olerecord_ivar_set(VALUE self, VALUE name, VALUE val)
+{
+ long len;
+ char *p;
+ VALUE fields;
+ len = RSTRING_LEN(name);
+ p = RSTRING_PTR(name);
+ if (p[len-1] == '=') {
+ name = rb_str_subseq(name, 0, len-1);
+ }
+ fields = rb_ivar_get(self, rb_intern("fields"));
+ rb_hash_fetch(fields, name);
+ return rb_hash_aset(fields, name, val);
+}
+
+/*
+ * call-seq:
+ * WIN32OLE_RECORD#method_missing(name)
+ *
+ * Returns value specified by the member name of VT_RECORD OLE variable.
+ * Or sets value specified by the member name of VT_RECORD OLE variable.
+ * If the member name is not correct, KeyError exception is raised.
+ *
+ * If COM server in VB.NET ComServer project is the following:
+ *
+ * Imports System.Runtime.InteropServices
+ * Public Class ComClass
+ * Public Structure Book
+ * <MarshalAs(UnmanagedType.BStr)> _
+ * Public title As String
+ * Public cost As Integer
+ * End Structure
+ * End Class
+ *
+ * Then getting/setting value from Ruby is as the following:
+ *
+ * obj = WIN32OLE.new('ComServer.ComClass')
+ * book = WIN32OLE_RECORD.new('Book', obj)
+ * book.title # => nil ( book.method_missing(:title) is invoked. )
+ * book.title = "Ruby" # ( book.method_missing(:title=, "Ruby") is invoked. )
+ */
+static VALUE
+folerecord_method_missing(int argc, VALUE *argv, VALUE self)
+{
+ VALUE name;
+ rb_check_arity(argc, 1, 2);
+ name = rb_sym_to_s(argv[0]);
+
+#if SIZEOF_SIZE_T > SIZEOF_LONG
+ {
+ size_t n = strlen(StringValueCStr(name));
+ if (n >= LONG_MAX) {
+ rb_raise(rb_eRuntimeError, "too long member name");
+ }
+ }
+#endif
+
+ if (argc == 1) {
+ return olerecord_ivar_get(self, name);
+ } else if (argc == 2) {
+ return olerecord_ivar_set(self, name, argv[1]);
+ }
+ return Qnil;
+}
+
+/*
+ * call-seq:
+ * WIN32OLE_RECORD#ole_instance_variable_get(name)
+ *
+ * Returns value specified by the member name of VT_RECORD OLE object.
+ * If the member name is not correct, KeyError exception is raised.
+ * If you can't access member variable of VT_RECORD OLE object directly,
+ * use this method.
+ *
+ * If COM server in VB.NET ComServer project is the following:
+ *
+ * Imports System.Runtime.InteropServices
+ * Public Class ComClass
+ * Public Structure ComObject
+ * Public object_id As Ineger
+ * End Structure
+ * End Class
+ *
+ * and Ruby Object class has title attribute:
+ *
+ * then accessing object_id of ComObject from Ruby is as the following:
+ *
+ * srver = WIN32OLE.new('ComServer.ComClass')
+ * obj = WIN32OLE_RECORD.new('ComObject', server)
+ * # obj.object_id returns Ruby Object#object_id
+ * obj.ole_instance_variable_get(:object_id) # => nil
+ *
+ */
+static VALUE
+folerecord_ole_instance_variable_get(VALUE self, VALUE name)
+{
+ VALUE sname;
+ if(!RB_TYPE_P(name, T_STRING) && !RB_TYPE_P(name, T_SYMBOL)) {
+ rb_raise(rb_eTypeError, "wrong argument type (expected String or Symbol)");
+ }
+ sname = name;
+ if (RB_TYPE_P(name, T_SYMBOL)) {
+ sname = rb_sym_to_s(name);
+ }
+ return olerecord_ivar_get(self, sname);
+}
+
+/*
+ * call-seq:
+ * WIN32OLE_RECORD#ole_instance_variable_set(name, val)
+ *
+ * Sets value specified by the member name of VT_RECORD OLE object.
+ * If the member name is not correct, KeyError exception is raised.
+ * If you can't set value of member of VT_RECORD OLE object directly,
+ * use this method.
+ *
+ * If COM server in VB.NET ComServer project is the following:
+ *
+ * Imports System.Runtime.InteropServices
+ * Public Class ComClass
+ * <MarshalAs(UnmanagedType.BStr)> _
+ * Public title As String
+ * Public cost As Integer
+ * End Class
+ *
+ * then setting value of the `title' member is as following:
+ *
+ * srver = WIN32OLE.new('ComServer.ComClass')
+ * obj = WIN32OLE_RECORD.new('Book', server)
+ * obj.ole_instance_variable_set(:title, "The Ruby Book")
+ *
+ */
+static VALUE
+folerecord_ole_instance_variable_set(VALUE self, VALUE name, VALUE val)
+{
+ VALUE sname;
+ if(!RB_TYPE_P(name, T_STRING) && !RB_TYPE_P(name, T_SYMBOL)) {
+ rb_raise(rb_eTypeError, "wrong argument type (expected String or Symbol)");
+ }
+ sname = name;
+ if (RB_TYPE_P(name, T_SYMBOL)) {
+ sname = rb_sym_to_s(name);
+ }
+ return olerecord_ivar_set(self, sname, val);
+}
+
+/*
+ * call-seq:
+ * WIN32OLE_RECORD#inspect -> String
+ *
+ * Returns the OLE struct name and member name and the value of member
+ *
+ * If COM server in VB.NET ComServer project is the following:
+ *
+ * Imports System.Runtime.InteropServices
+ * Public Class ComClass
+ * <MarshalAs(UnmanagedType.BStr)> _
+ * Public title As String
+ * Public cost As Integer
+ * End Class
+ *
+ * then
+ *
+ * srver = WIN32OLE.new('ComServer.ComClass')
+ * obj = WIN32OLE_RECORD.new('Book', server)
+ * obj.inspect # => <WIN32OLE_RECORD(ComClass) {"title" => nil, "cost" => nil}>
+ *
+ */
+static VALUE
+folerecord_inspect(VALUE self)
+{
+ VALUE tname;
+ VALUE field;
+ tname = folerecord_typename(self);
+ if (tname == Qnil) {
+ tname = rb_inspect(tname);
+ }
+ field = rb_inspect(folerecord_to_h(self));
+ return rb_sprintf("#<WIN32OLE_RECORD(%"PRIsVALUE") %"PRIsVALUE">",
+ tname,
+ field);
+}
+
+void
+Init_win32ole_record(void)
+{
+ cWIN32OLE_RECORD = rb_define_class("WIN32OLE_RECORD", rb_cObject);
+ rb_define_alloc_func(cWIN32OLE_RECORD, folerecord_s_allocate);
+ rb_define_method(cWIN32OLE_RECORD, "initialize", folerecord_initialize, 2);
+ rb_define_method(cWIN32OLE_RECORD, "to_h", folerecord_to_h, 0);
+ rb_define_method(cWIN32OLE_RECORD, "typename", folerecord_typename, 0);
+ rb_define_method(cWIN32OLE_RECORD, "method_missing", folerecord_method_missing, -1);
+ rb_define_method(cWIN32OLE_RECORD, "ole_instance_variable_get", folerecord_ole_instance_variable_get, 1);
+ rb_define_method(cWIN32OLE_RECORD, "ole_instance_variable_set", folerecord_ole_instance_variable_set, 2);
+ rb_define_method(cWIN32OLE_RECORD, "inspect", folerecord_inspect, 0);
+}
diff --git a/jni/ruby/ext/win32ole/win32ole_record.h b/jni/ruby/ext/win32ole/win32ole_record.h
new file mode 100644
index 0000000..ea431e9
--- /dev/null
+++ b/jni/ruby/ext/win32ole/win32ole_record.h
@@ -0,0 +1,10 @@
+#ifndef WIN32OLE_RECORD_H
+#define WIN32OLE_RECORD_H 1
+
+VALUE cWIN32OLE_RECORD;
+void ole_rec2variant(VALUE rec, VARIANT *var);
+void olerecord_set_ivar(VALUE obj, IRecordInfo *pri, void *prec);
+VALUE create_win32ole_record(IRecordInfo *pri, void *prec);
+void Init_win32ole_record(void);
+
+#endif
diff --git a/jni/ruby/ext/win32ole/win32ole_type.c b/jni/ruby/ext/win32ole/win32ole_type.c
new file mode 100644
index 0000000..efcac88
--- /dev/null
+++ b/jni/ruby/ext/win32ole/win32ole_type.c
@@ -0,0 +1,915 @@
+#include "win32ole.h"
+
+struct oletypedata {
+ ITypeInfo *pTypeInfo;
+};
+
+static void oletype_free(void *ptr);
+static size_t oletype_size(const void *ptr);
+static VALUE foletype_s_ole_classes(VALUE self, VALUE typelib);
+static VALUE foletype_s_typelibs(VALUE self);
+static VALUE foletype_s_progids(VALUE self);
+static VALUE oletype_set_member(VALUE self, ITypeInfo *pTypeInfo, VALUE name);
+static VALUE foletype_s_allocate(VALUE klass);
+static VALUE oleclass_from_typelib(VALUE self, ITypeLib *pTypeLib, VALUE oleclass);
+static VALUE foletype_initialize(VALUE self, VALUE typelib, VALUE oleclass);
+static VALUE foletype_name(VALUE self);
+static VALUE ole_ole_type(ITypeInfo *pTypeInfo);
+static VALUE foletype_ole_type(VALUE self);
+static VALUE ole_type_guid(ITypeInfo *pTypeInfo);
+static VALUE foletype_guid(VALUE self);
+static VALUE ole_type_progid(ITypeInfo *pTypeInfo);
+static VALUE foletype_progid(VALUE self);
+static VALUE ole_type_visible(ITypeInfo *pTypeInfo);
+static VALUE foletype_visible(VALUE self);
+static VALUE ole_type_major_version(ITypeInfo *pTypeInfo);
+static VALUE foletype_major_version(VALUE self);
+static VALUE ole_type_minor_version(ITypeInfo *pTypeInfo);
+static VALUE foletype_minor_version(VALUE self);
+static VALUE ole_type_typekind(ITypeInfo *pTypeInfo);
+static VALUE foletype_typekind(VALUE self);
+static VALUE ole_type_helpstring(ITypeInfo *pTypeInfo);
+static VALUE foletype_helpstring(VALUE self);
+static VALUE ole_type_src_type(ITypeInfo *pTypeInfo);
+static VALUE foletype_src_type(VALUE self);
+static VALUE ole_type_helpfile(ITypeInfo *pTypeInfo);
+static VALUE foletype_helpfile(VALUE self);
+static VALUE ole_type_helpcontext(ITypeInfo *pTypeInfo);
+static VALUE foletype_helpcontext(VALUE self);
+static VALUE ole_variables(ITypeInfo *pTypeInfo);
+static VALUE foletype_variables(VALUE self);
+static VALUE foletype_methods(VALUE self);
+static VALUE foletype_ole_typelib(VALUE self);
+static VALUE ole_type_impl_ole_types(ITypeInfo *pTypeInfo, int implflags);
+static VALUE foletype_impl_ole_types(VALUE self);
+static VALUE foletype_source_ole_types(VALUE self);
+static VALUE foletype_default_event_sources(VALUE self);
+static VALUE foletype_default_ole_types(VALUE self);
+static VALUE foletype_inspect(VALUE self);
+
+static const rb_data_type_t oletype_datatype = {
+ "win32ole_type",
+ {NULL, oletype_free, oletype_size,},
+ 0, 0, RUBY_TYPED_FREE_IMMEDIATELY
+};
+
+/*
+ * Document-class: WIN32OLE_TYPE
+ *
+ * <code>WIN32OLE_TYPE</code> objects represent OLE type libarary information.
+ */
+
+static void
+oletype_free(void *ptr)
+{
+ struct oletypedata *poletype = ptr;
+ OLE_FREE(poletype->pTypeInfo);
+ free(poletype);
+}
+
+static size_t
+oletype_size(const void *ptr)
+{
+ return ptr ? sizeof(struct oletypedata) : 0;
+}
+
+ITypeInfo *itypeinfo(VALUE self)
+{
+ struct oletypedata *ptype;
+ TypedData_Get_Struct(self, struct oletypedata, &oletype_datatype, ptype);
+ return ptype->pTypeInfo;
+}
+
+VALUE
+ole_type_from_itypeinfo(ITypeInfo *pTypeInfo)
+{
+ ITypeLib *pTypeLib;
+ VALUE type = Qnil;
+ HRESULT hr;
+ unsigned int index;
+ BSTR bstr;
+
+ hr = pTypeInfo->lpVtbl->GetContainingTypeLib( pTypeInfo, &pTypeLib, &index );
+ if(FAILED(hr)) {
+ return Qnil;
+ }
+ hr = pTypeLib->lpVtbl->GetDocumentation( pTypeLib, index,
+ &bstr, NULL, NULL, NULL);
+ OLE_RELEASE(pTypeLib);
+ if (FAILED(hr)) {
+ return Qnil;
+ }
+ type = create_win32ole_type(pTypeInfo, WC2VSTR(bstr));
+ return type;
+}
+
+
+/*
+ * call-seq:
+ * WIN32OLE_TYPE.ole_classes(typelib)
+ *
+ * Returns array of WIN32OLE_TYPE objects defined by the <i>typelib</i> type library.
+ * This method will be OBSOLETE. Use WIN32OLE_TYPELIB.new(typelib).ole_classes instead.
+ */
+static VALUE
+foletype_s_ole_classes(VALUE self, VALUE typelib)
+{
+ VALUE obj;
+
+ /*
+ rb_warn("%s is obsolete; use %s instead.",
+ "WIN32OLE_TYPE.ole_classes",
+ "WIN32OLE_TYPELIB.new(typelib).ole_types");
+ */
+ obj = rb_funcall(cWIN32OLE_TYPELIB, rb_intern("new"), 1, typelib);
+ return rb_funcall(obj, rb_intern("ole_types"), 0);
+}
+
+/*
+ * call-seq:
+ * WIN32OLE_TYPE.typelibs
+ *
+ * Returns array of type libraries.
+ * This method will be OBSOLETE. Use WIN32OLE_TYPELIB.typelibs.collect{|t| t.name} instead.
+ *
+ */
+static VALUE
+foletype_s_typelibs(VALUE self)
+{
+ /*
+ rb_warn("%s is obsolete. use %s instead.",
+ "WIN32OLE_TYPE.typelibs",
+ "WIN32OLE_TYPELIB.typelibs.collect{t|t.name}");
+ */
+ return rb_eval_string("WIN32OLE_TYPELIB.typelibs.collect{|t|t.name}");
+}
+
+/*
+ * call-seq:
+ * WIN32OLE_TYPE.progids
+ *
+ * Returns array of ProgID.
+ */
+static VALUE
+foletype_s_progids(VALUE self)
+{
+ HKEY hclsids, hclsid;
+ DWORD i;
+ LONG err;
+ VALUE clsid;
+ VALUE v = rb_str_new2("");
+ VALUE progids = rb_ary_new();
+
+ err = reg_open_key(HKEY_CLASSES_ROOT, "CLSID", &hclsids);
+ if(err != ERROR_SUCCESS) {
+ return progids;
+ }
+ for(i = 0; ; i++) {
+ clsid = reg_enum_key(hclsids, i);
+ if (clsid == Qnil)
+ break;
+ err = reg_open_vkey(hclsids, clsid, &hclsid);
+ if (err != ERROR_SUCCESS)
+ continue;
+ if ((v = reg_get_val2(hclsid, "ProgID")) != Qnil)
+ rb_ary_push(progids, v);
+ if ((v = reg_get_val2(hclsid, "VersionIndependentProgID")) != Qnil)
+ rb_ary_push(progids, v);
+ RegCloseKey(hclsid);
+ }
+ RegCloseKey(hclsids);
+ return progids;
+}
+
+static VALUE
+oletype_set_member(VALUE self, ITypeInfo *pTypeInfo, VALUE name)
+{
+ struct oletypedata *ptype;
+ TypedData_Get_Struct(self, struct oletypedata, &oletype_datatype, ptype);
+ rb_ivar_set(self, rb_intern("name"), name);
+ ptype->pTypeInfo = pTypeInfo;
+ OLE_ADDREF(pTypeInfo);
+ return self;
+}
+
+static VALUE
+foletype_s_allocate(VALUE klass)
+{
+ struct oletypedata *poletype;
+ VALUE obj;
+ ole_initialize();
+ obj = TypedData_Make_Struct(klass,struct oletypedata, &oletype_datatype, poletype);
+ poletype->pTypeInfo = NULL;
+ return obj;
+}
+
+VALUE
+create_win32ole_type(ITypeInfo *pTypeInfo, VALUE name)
+{
+ VALUE obj = foletype_s_allocate(cWIN32OLE_TYPE);
+ oletype_set_member(obj, pTypeInfo, name);
+ return obj;
+}
+
+static VALUE
+oleclass_from_typelib(VALUE self, ITypeLib *pTypeLib, VALUE oleclass)
+{
+
+ long count;
+ int i;
+ HRESULT hr;
+ BSTR bstr;
+ VALUE typelib;
+ ITypeInfo *pTypeInfo;
+
+ VALUE found = Qfalse;
+
+ count = pTypeLib->lpVtbl->GetTypeInfoCount(pTypeLib);
+ for (i = 0; i < count && found == Qfalse; i++) {
+ hr = pTypeLib->lpVtbl->GetTypeInfo(pTypeLib, i, &pTypeInfo);
+ if (FAILED(hr))
+ continue;
+ hr = pTypeLib->lpVtbl->GetDocumentation(pTypeLib, i,
+ &bstr, NULL, NULL, NULL);
+ if (FAILED(hr))
+ continue;
+ typelib = WC2VSTR(bstr);
+ if (rb_str_cmp(oleclass, typelib) == 0) {
+ oletype_set_member(self, pTypeInfo, typelib);
+ found = Qtrue;
+ }
+ OLE_RELEASE(pTypeInfo);
+ }
+ return found;
+}
+
+/*
+ * call-seq:
+ * WIN32OLE_TYPE.new(typelib, ole_class) -> WIN32OLE_TYPE object
+ *
+ * Returns a new WIN32OLE_TYPE object.
+ * The first argument <i>typelib</i> specifies OLE type library name.
+ * The second argument specifies OLE class name.
+ *
+ * WIN32OLE_TYPE.new('Microsoft Excel 9.0 Object Library', 'Application')
+ * # => WIN32OLE_TYPE object of Application class of Excel.
+ */
+static VALUE
+foletype_initialize(VALUE self, VALUE typelib, VALUE oleclass)
+{
+ VALUE file;
+ OLECHAR * pbuf;
+ ITypeLib *pTypeLib;
+ HRESULT hr;
+
+ SafeStringValue(oleclass);
+ SafeStringValue(typelib);
+ file = typelib_file(typelib);
+ if (file == Qnil) {
+ file = typelib;
+ }
+ pbuf = ole_vstr2wc(file);
+ hr = LoadTypeLibEx(pbuf, REGKIND_NONE, &pTypeLib);
+ if (FAILED(hr))
+ ole_raise(hr, eWIN32OLERuntimeError, "failed to LoadTypeLibEx");
+ SysFreeString(pbuf);
+ if (oleclass_from_typelib(self, pTypeLib, oleclass) == Qfalse) {
+ OLE_RELEASE(pTypeLib);
+ rb_raise(eWIN32OLERuntimeError, "not found `%s` in `%s`",
+ StringValuePtr(oleclass), StringValuePtr(typelib));
+ }
+ OLE_RELEASE(pTypeLib);
+ return self;
+}
+
+/*
+ * call-seq:
+ * WIN32OLE_TYPE#name #=> OLE type name
+ *
+ * Returns OLE type name.
+ * tobj = WIN32OLE_TYPE.new('Microsoft Excel 9.0 Object Library', 'Application')
+ * puts tobj.name # => Application
+ */
+static VALUE
+foletype_name(VALUE self)
+{
+ return rb_ivar_get(self, rb_intern("name"));
+}
+
+static VALUE
+ole_ole_type(ITypeInfo *pTypeInfo)
+{
+ HRESULT hr;
+ TYPEATTR *pTypeAttr;
+ VALUE type = Qnil;
+ hr = OLE_GET_TYPEATTR(pTypeInfo, &pTypeAttr);
+ if(FAILED(hr)){
+ return type;
+ }
+ switch(pTypeAttr->typekind) {
+ case TKIND_ENUM:
+ type = rb_str_new2("Enum");
+ break;
+ case TKIND_RECORD:
+ type = rb_str_new2("Record");
+ break;
+ case TKIND_MODULE:
+ type = rb_str_new2("Module");
+ break;
+ case TKIND_INTERFACE:
+ type = rb_str_new2("Interface");
+ break;
+ case TKIND_DISPATCH:
+ type = rb_str_new2("Dispatch");
+ break;
+ case TKIND_COCLASS:
+ type = rb_str_new2("Class");
+ break;
+ case TKIND_ALIAS:
+ type = rb_str_new2("Alias");
+ break;
+ case TKIND_UNION:
+ type = rb_str_new2("Union");
+ break;
+ case TKIND_MAX:
+ type = rb_str_new2("Max");
+ break;
+ default:
+ type = Qnil;
+ break;
+ }
+ OLE_RELEASE_TYPEATTR(pTypeInfo, pTypeAttr);
+ return type;
+}
+
+/*
+ * call-seq:
+ * WIN32OLE_TYPE#ole_type #=> OLE type string.
+ *
+ * returns type of OLE class.
+ * tobj = WIN32OLE_TYPE.new('Microsoft Excel 9.0 Object Library', 'Application')
+ * puts tobj.ole_type # => Class
+ */
+static VALUE
+foletype_ole_type(VALUE self)
+{
+ ITypeInfo *pTypeInfo = itypeinfo(self);
+ return ole_ole_type(pTypeInfo);
+}
+
+static VALUE
+ole_type_guid(ITypeInfo *pTypeInfo)
+{
+ HRESULT hr;
+ TYPEATTR *pTypeAttr;
+ int len;
+ OLECHAR bstr[80];
+ VALUE guid = Qnil;
+ hr = OLE_GET_TYPEATTR(pTypeInfo, &pTypeAttr);
+ if (FAILED(hr))
+ return guid;
+ len = StringFromGUID2(&pTypeAttr->guid, bstr, sizeof(bstr)/sizeof(OLECHAR));
+ if (len > 3) {
+ guid = ole_wc2vstr(bstr, FALSE);
+ }
+ OLE_RELEASE_TYPEATTR(pTypeInfo, pTypeAttr);
+ return guid;
+}
+
+/*
+ * call-seq:
+ * WIN32OLE_TYPE#guid #=> GUID
+ *
+ * Returns GUID.
+ * tobj = WIN32OLE_TYPE.new('Microsoft Excel 9.0 Object Library', 'Application')
+ * puts tobj.guid # => {00024500-0000-0000-C000-000000000046}
+ */
+static VALUE
+foletype_guid(VALUE self)
+{
+ ITypeInfo *pTypeInfo = itypeinfo(self);
+ return ole_type_guid(pTypeInfo);
+}
+
+static VALUE
+ole_type_progid(ITypeInfo *pTypeInfo)
+{
+ HRESULT hr;
+ TYPEATTR *pTypeAttr;
+ OLECHAR *pbuf;
+ VALUE progid = Qnil;
+ hr = OLE_GET_TYPEATTR(pTypeInfo, &pTypeAttr);
+ if (FAILED(hr))
+ return progid;
+ hr = ProgIDFromCLSID(&pTypeAttr->guid, &pbuf);
+ if (SUCCEEDED(hr)) {
+ progid = ole_wc2vstr(pbuf, FALSE);
+ CoTaskMemFree(pbuf);
+ }
+ OLE_RELEASE_TYPEATTR(pTypeInfo, pTypeAttr);
+ return progid;
+}
+
+/*
+ * call-seq:
+ * WIN32OLE_TYPE#progid #=> ProgID
+ *
+ * Returns ProgID if it exists. If not found, then returns nil.
+ * tobj = WIN32OLE_TYPE.new('Microsoft Excel 9.0 Object Library', 'Application')
+ * puts tobj.progid # => Excel.Application.9
+ */
+static VALUE
+foletype_progid(VALUE self)
+{
+ ITypeInfo *pTypeInfo = itypeinfo(self);
+ return ole_type_progid(pTypeInfo);
+}
+
+
+static VALUE
+ole_type_visible(ITypeInfo *pTypeInfo)
+{
+ HRESULT hr;
+ TYPEATTR *pTypeAttr;
+ VALUE visible;
+ hr = OLE_GET_TYPEATTR(pTypeInfo, &pTypeAttr);
+ if (FAILED(hr))
+ return Qtrue;
+ if (pTypeAttr->wTypeFlags & (TYPEFLAG_FHIDDEN | TYPEFLAG_FRESTRICTED)) {
+ visible = Qfalse;
+ } else {
+ visible = Qtrue;
+ }
+ OLE_RELEASE_TYPEATTR(pTypeInfo, pTypeAttr);
+ return visible;
+}
+
+/*
+ * call-seq:
+ * WIN32OLE_TYPE#visible? #=> true or false
+ *
+ * Returns true if the OLE class is public.
+ * tobj = WIN32OLE_TYPE.new('Microsoft Excel 9.0 Object Library', 'Application')
+ * puts tobj.visible # => true
+ */
+static VALUE
+foletype_visible(VALUE self)
+{
+ ITypeInfo *pTypeInfo = itypeinfo(self);
+ return ole_type_visible(pTypeInfo);
+}
+
+static VALUE
+ole_type_major_version(ITypeInfo *pTypeInfo)
+{
+ VALUE ver;
+ TYPEATTR *pTypeAttr;
+ HRESULT hr;
+ hr = OLE_GET_TYPEATTR(pTypeInfo, &pTypeAttr);
+ if (FAILED(hr))
+ ole_raise(hr, eWIN32OLERuntimeError, "failed to GetTypeAttr");
+ ver = INT2FIX(pTypeAttr->wMajorVerNum);
+ OLE_RELEASE_TYPEATTR(pTypeInfo, pTypeAttr);
+ return ver;
+}
+
+/*
+ * call-seq:
+ * WIN32OLE_TYPE#major_version
+ *
+ * Returns major version.
+ * tobj = WIN32OLE_TYPE.new('Microsoft Word 10.0 Object Library', 'Documents')
+ * puts tobj.major_version # => 8
+ */
+static VALUE
+foletype_major_version(VALUE self)
+{
+ ITypeInfo *pTypeInfo = itypeinfo(self);
+ return ole_type_major_version(pTypeInfo);
+}
+
+static VALUE
+ole_type_minor_version(ITypeInfo *pTypeInfo)
+{
+ VALUE ver;
+ TYPEATTR *pTypeAttr;
+ HRESULT hr;
+ hr = OLE_GET_TYPEATTR(pTypeInfo, &pTypeAttr);
+ if (FAILED(hr))
+ ole_raise(hr, eWIN32OLERuntimeError, "failed to GetTypeAttr");
+ ver = INT2FIX(pTypeAttr->wMinorVerNum);
+ OLE_RELEASE_TYPEATTR(pTypeInfo, pTypeAttr);
+ return ver;
+}
+
+/*
+ * call-seq:
+ * WIN32OLE_TYPE#minor_version #=> OLE minor version
+ *
+ * Returns minor version.
+ * tobj = WIN32OLE_TYPE.new('Microsoft Word 10.0 Object Library', 'Documents')
+ * puts tobj.minor_version # => 2
+ */
+static VALUE
+foletype_minor_version(VALUE self)
+{
+ ITypeInfo *pTypeInfo = itypeinfo(self);
+ return ole_type_minor_version(pTypeInfo);
+}
+
+static VALUE
+ole_type_typekind(ITypeInfo *pTypeInfo)
+{
+ VALUE typekind;
+ TYPEATTR *pTypeAttr;
+ HRESULT hr;
+ hr = OLE_GET_TYPEATTR(pTypeInfo, &pTypeAttr);
+ if (FAILED(hr))
+ ole_raise(hr, eWIN32OLERuntimeError, "failed to GetTypeAttr");
+ typekind = INT2FIX(pTypeAttr->typekind);
+ OLE_RELEASE_TYPEATTR(pTypeInfo, pTypeAttr);
+ return typekind;
+}
+
+/*
+ * call-seq:
+ * WIN32OLE_TYPE#typekind #=> number of type.
+ *
+ * Returns number which represents type.
+ * tobj = WIN32OLE_TYPE.new('Microsoft Word 10.0 Object Library', 'Documents')
+ * puts tobj.typekind # => 4
+ *
+ */
+static VALUE
+foletype_typekind(VALUE self)
+{
+ ITypeInfo *pTypeInfo = itypeinfo(self);
+ return ole_type_typekind(pTypeInfo);
+}
+
+static VALUE
+ole_type_helpstring(ITypeInfo *pTypeInfo)
+{
+ HRESULT hr;
+ BSTR bhelpstr;
+ hr = ole_docinfo_from_type(pTypeInfo, NULL, &bhelpstr, NULL, NULL);
+ if(FAILED(hr)) {
+ return Qnil;
+ }
+ return WC2VSTR(bhelpstr);
+}
+
+/*
+ * call-seq:
+ * WIN32OLE_TYPE#helpstring #=> help string.
+ *
+ * Returns help string.
+ * tobj = WIN32OLE_TYPE.new('Microsoft Internet Controls', 'IWebBrowser')
+ * puts tobj.helpstring # => Web Browser interface
+ */
+static VALUE
+foletype_helpstring(VALUE self)
+{
+ ITypeInfo *pTypeInfo = itypeinfo(self);
+ return ole_type_helpstring(pTypeInfo);
+}
+
+static VALUE
+ole_type_src_type(ITypeInfo *pTypeInfo)
+{
+ HRESULT hr;
+ TYPEATTR *pTypeAttr;
+ VALUE alias = Qnil;
+ hr = OLE_GET_TYPEATTR(pTypeInfo, &pTypeAttr);
+ if (FAILED(hr))
+ return alias;
+ if(pTypeAttr->typekind != TKIND_ALIAS) {
+ OLE_RELEASE_TYPEATTR(pTypeInfo, pTypeAttr);
+ return alias;
+ }
+ alias = ole_typedesc2val(pTypeInfo, &(pTypeAttr->tdescAlias), Qnil);
+ OLE_RELEASE_TYPEATTR(pTypeInfo, pTypeAttr);
+ return alias;
+}
+
+/*
+ * call-seq:
+ * WIN32OLE_TYPE#src_type #=> OLE source class
+ *
+ * Returns source class when the OLE class is 'Alias'.
+ * tobj = WIN32OLE_TYPE.new('Microsoft Office 9.0 Object Library', 'MsoRGBType')
+ * puts tobj.src_type # => I4
+ *
+ */
+static VALUE
+foletype_src_type(VALUE self)
+{
+ ITypeInfo *pTypeInfo = itypeinfo(self);
+ return ole_type_src_type(pTypeInfo);
+}
+
+static VALUE
+ole_type_helpfile(ITypeInfo *pTypeInfo)
+{
+ HRESULT hr;
+ BSTR bhelpfile;
+ hr = ole_docinfo_from_type(pTypeInfo, NULL, NULL, NULL, &bhelpfile);
+ if(FAILED(hr)) {
+ return Qnil;
+ }
+ return WC2VSTR(bhelpfile);
+}
+
+/*
+ * call-seq:
+ * WIN32OLE_TYPE#helpfile
+ *
+ * Returns helpfile path. If helpfile is not found, then returns nil.
+ * tobj = WIN32OLE_TYPE.new('Microsoft Excel 9.0 Object Library', 'Worksheet')
+ * puts tobj.helpfile # => C:\...\VBAXL9.CHM
+ *
+ */
+static VALUE
+foletype_helpfile(VALUE self)
+{
+ ITypeInfo *pTypeInfo = itypeinfo(self);
+ return ole_type_helpfile(pTypeInfo);
+}
+
+static VALUE
+ole_type_helpcontext(ITypeInfo *pTypeInfo)
+{
+ HRESULT hr;
+ DWORD helpcontext;
+ hr = ole_docinfo_from_type(pTypeInfo, NULL, NULL,
+ &helpcontext, NULL);
+ if(FAILED(hr))
+ return Qnil;
+ return INT2FIX(helpcontext);
+}
+
+/*
+ * call-seq:
+ * WIN32OLE_TYPE#helpcontext
+ *
+ * Returns helpcontext. If helpcontext is not found, then returns nil.
+ * tobj = WIN32OLE_TYPE.new('Microsoft Excel 9.0 Object Library', 'Worksheet')
+ * puts tobj.helpfile # => 131185
+ */
+static VALUE
+foletype_helpcontext(VALUE self)
+{
+ ITypeInfo *pTypeInfo = itypeinfo(self);
+ return ole_type_helpcontext(pTypeInfo);
+}
+
+static VALUE
+ole_variables(ITypeInfo *pTypeInfo)
+{
+ HRESULT hr;
+ TYPEATTR *pTypeAttr;
+ WORD i;
+ UINT len;
+ BSTR bstr;
+ VARDESC *pVarDesc;
+ VALUE var;
+ VALUE variables = rb_ary_new();
+ hr = OLE_GET_TYPEATTR(pTypeInfo, &pTypeAttr);
+ if (FAILED(hr)) {
+ ole_raise(hr, eWIN32OLERuntimeError, "failed to GetTypeAttr");
+ }
+
+ for(i = 0; i < pTypeAttr->cVars; i++) {
+ hr = pTypeInfo->lpVtbl->GetVarDesc(pTypeInfo, i, &pVarDesc);
+ if(FAILED(hr))
+ continue;
+ len = 0;
+ hr = pTypeInfo->lpVtbl->GetNames(pTypeInfo, pVarDesc->memid, &bstr,
+ 1, &len);
+ if(FAILED(hr) || len == 0 || !bstr)
+ continue;
+
+ var = create_win32ole_variable(pTypeInfo, i, WC2VSTR(bstr));
+ rb_ary_push(variables, var);
+
+ pTypeInfo->lpVtbl->ReleaseVarDesc(pTypeInfo, pVarDesc);
+ pVarDesc = NULL;
+ }
+ OLE_RELEASE_TYPEATTR(pTypeInfo, pTypeAttr);
+ return variables;
+}
+
+/*
+ * call-seq:
+ * WIN32OLE_TYPE#variables
+ *
+ * Returns array of WIN32OLE_VARIABLE objects which represent variables
+ * defined in OLE class.
+ * tobj = WIN32OLE_TYPE.new('Microsoft Excel 9.0 Object Library', 'XlSheetType')
+ * vars = tobj.variables
+ * vars.each do |v|
+ * puts "#{v.name} = #{v.value}"
+ * end
+ *
+ * The result of above sample script is follows:
+ * xlChart = -4109
+ * xlDialogSheet = -4116
+ * xlExcel4IntlMacroSheet = 4
+ * xlExcel4MacroSheet = 3
+ * xlWorksheet = -4167
+ *
+ */
+static VALUE
+foletype_variables(VALUE self)
+{
+ ITypeInfo *pTypeInfo = itypeinfo(self);
+ return ole_variables(pTypeInfo);
+}
+
+/*
+ * call-seq:
+ * WIN32OLE_TYPE#ole_methods # the array of WIN32OLE_METHOD objects.
+ *
+ * Returns array of WIN32OLE_METHOD objects which represent OLE method defined in
+ * OLE type library.
+ * tobj = WIN32OLE_TYPE.new('Microsoft Excel 9.0 Object Library', 'Worksheet')
+ * methods = tobj.ole_methods.collect{|m|
+ * m.name
+ * }
+ * # => ['Activate', 'Copy', 'Delete',....]
+ */
+static VALUE
+foletype_methods(VALUE self)
+{
+ ITypeInfo *pTypeInfo = itypeinfo(self);
+ return ole_methods_from_typeinfo(pTypeInfo, INVOKE_FUNC | INVOKE_PROPERTYGET | INVOKE_PROPERTYPUT | INVOKE_PROPERTYPUTREF);
+}
+
+/*
+ * call-seq:
+ * WIN32OLE_TYPE#ole_typelib
+ *
+ * Returns the WIN32OLE_TYPELIB object which is including the WIN32OLE_TYPE
+ * object. If it is not found, then returns nil.
+ * tobj = WIN32OLE_TYPE.new('Microsoft Excel 9.0 Object Library', 'Worksheet')
+ * puts tobj.ole_typelib # => 'Microsoft Excel 9.0 Object Library'
+ */
+static VALUE
+foletype_ole_typelib(VALUE self)
+{
+ ITypeInfo *pTypeInfo = itypeinfo(self);
+ return ole_typelib_from_itypeinfo(pTypeInfo);
+}
+
+static VALUE
+ole_type_impl_ole_types(ITypeInfo *pTypeInfo, int implflags)
+{
+ HRESULT hr;
+ ITypeInfo *pRefTypeInfo;
+ HREFTYPE href;
+ WORD i;
+ VALUE type;
+ TYPEATTR *pTypeAttr;
+ int flags;
+
+ VALUE types = rb_ary_new();
+ hr = OLE_GET_TYPEATTR(pTypeInfo, &pTypeAttr);
+ if (FAILED(hr)) {
+ return types;
+ }
+ for (i = 0; i < pTypeAttr->cImplTypes; i++) {
+ hr = pTypeInfo->lpVtbl->GetImplTypeFlags(pTypeInfo, i, &flags);
+ if (FAILED(hr))
+ continue;
+
+ hr = pTypeInfo->lpVtbl->GetRefTypeOfImplType(pTypeInfo, i, &href);
+ if (FAILED(hr))
+ continue;
+ hr = pTypeInfo->lpVtbl->GetRefTypeInfo(pTypeInfo, href, &pRefTypeInfo);
+ if (FAILED(hr))
+ continue;
+
+ if ((flags & implflags) == implflags) {
+ type = ole_type_from_itypeinfo(pRefTypeInfo);
+ if (type != Qnil) {
+ rb_ary_push(types, type);
+ }
+ }
+
+ OLE_RELEASE(pRefTypeInfo);
+ }
+ OLE_RELEASE_TYPEATTR(pTypeInfo, pTypeAttr);
+ return types;
+}
+
+/*
+ * call-seq:
+ * WIN32OLE_TYPE#implemented_ole_types
+ *
+ * Returns the array of WIN32OLE_TYPE object which is implemented by the WIN32OLE_TYPE
+ * object.
+ * tobj = WIN32OLE_TYPE.new('Microsoft Excel 9.0 Object Library', 'Worksheet')
+ * p tobj.implemented_ole_types # => [_Worksheet, DocEvents]
+ */
+static VALUE
+foletype_impl_ole_types(VALUE self)
+{
+ ITypeInfo *pTypeInfo = itypeinfo(self);
+ return ole_type_impl_ole_types(pTypeInfo, 0);
+}
+
+/*
+ * call-seq:
+ * WIN32OLE_TYPE#source_ole_types
+ *
+ * Returns the array of WIN32OLE_TYPE object which is implemented by the WIN32OLE_TYPE
+ * object and having IMPLTYPEFLAG_FSOURCE.
+ * tobj = WIN32OLE_TYPE.new('Microsoft Internet Controls', "InternetExplorer")
+ * p tobj.source_ole_types
+ * # => [#<WIN32OLE_TYPE:DWebBrowserEvents2>, #<WIN32OLE_TYPE:DWebBrowserEvents>]
+ */
+static VALUE
+foletype_source_ole_types(VALUE self)
+{
+ ITypeInfo *pTypeInfo = itypeinfo(self);
+ return ole_type_impl_ole_types(pTypeInfo, IMPLTYPEFLAG_FSOURCE);
+}
+
+/*
+ * call-seq:
+ * WIN32OLE_TYPE#default_event_sources
+ *
+ * Returns the array of WIN32OLE_TYPE object which is implemented by the WIN32OLE_TYPE
+ * object and having IMPLTYPEFLAG_FSOURCE and IMPLTYPEFLAG_FDEFAULT.
+ * tobj = WIN32OLE_TYPE.new('Microsoft Internet Controls', "InternetExplorer")
+ * p tobj.default_event_sources # => [#<WIN32OLE_TYPE:DWebBrowserEvents2>]
+ */
+static VALUE
+foletype_default_event_sources(VALUE self)
+{
+ ITypeInfo *pTypeInfo = itypeinfo(self);
+ return ole_type_impl_ole_types(pTypeInfo, IMPLTYPEFLAG_FSOURCE|IMPLTYPEFLAG_FDEFAULT);
+}
+
+/*
+ * call-seq:
+ * WIN32OLE_TYPE#default_ole_types
+ *
+ * Returns the array of WIN32OLE_TYPE object which is implemented by the WIN32OLE_TYPE
+ * object and having IMPLTYPEFLAG_FDEFAULT.
+ * tobj = WIN32OLE_TYPE.new('Microsoft Internet Controls', "InternetExplorer")
+ * p tobj.default_ole_types
+ * # => [#<WIN32OLE_TYPE:IWebBrowser2>, #<WIN32OLE_TYPE:DWebBrowserEvents2>]
+ */
+static VALUE
+foletype_default_ole_types(VALUE self)
+{
+ ITypeInfo *pTypeInfo = itypeinfo(self);
+ return ole_type_impl_ole_types(pTypeInfo, IMPLTYPEFLAG_FDEFAULT);
+}
+
+/*
+ * call-seq:
+ * WIN32OLE_TYPE#inspect -> String
+ *
+ * Returns the type name with class name.
+ *
+ * ie = WIN32OLE.new('InternetExplorer.Application')
+ * ie.ole_type.inspect => #<WIN32OLE_TYPE:IWebBrowser2>
+ */
+static VALUE
+foletype_inspect(VALUE self)
+{
+ return default_inspect(self, "WIN32OLE_TYPE");
+}
+
+void Init_win32ole_type(void)
+{
+ cWIN32OLE_TYPE = rb_define_class("WIN32OLE_TYPE", rb_cObject);
+ rb_define_singleton_method(cWIN32OLE_TYPE, "ole_classes", foletype_s_ole_classes, 1);
+ rb_define_singleton_method(cWIN32OLE_TYPE, "typelibs", foletype_s_typelibs, 0);
+ rb_define_singleton_method(cWIN32OLE_TYPE, "progids", foletype_s_progids, 0);
+ rb_define_alloc_func(cWIN32OLE_TYPE, foletype_s_allocate);
+ rb_define_method(cWIN32OLE_TYPE, "initialize", foletype_initialize, 2);
+ rb_define_method(cWIN32OLE_TYPE, "name", foletype_name, 0);
+ rb_define_method(cWIN32OLE_TYPE, "ole_type", foletype_ole_type, 0);
+ rb_define_method(cWIN32OLE_TYPE, "guid", foletype_guid, 0);
+ rb_define_method(cWIN32OLE_TYPE, "progid", foletype_progid, 0);
+ rb_define_method(cWIN32OLE_TYPE, "visible?", foletype_visible, 0);
+ rb_define_alias(cWIN32OLE_TYPE, "to_s", "name");
+ rb_define_method(cWIN32OLE_TYPE, "major_version", foletype_major_version, 0);
+ rb_define_method(cWIN32OLE_TYPE, "minor_version", foletype_minor_version, 0);
+ rb_define_method(cWIN32OLE_TYPE, "typekind", foletype_typekind, 0);
+ rb_define_method(cWIN32OLE_TYPE, "helpstring", foletype_helpstring, 0);
+ rb_define_method(cWIN32OLE_TYPE, "src_type", foletype_src_type, 0);
+ rb_define_method(cWIN32OLE_TYPE, "helpfile", foletype_helpfile, 0);
+ rb_define_method(cWIN32OLE_TYPE, "helpcontext", foletype_helpcontext, 0);
+ rb_define_method(cWIN32OLE_TYPE, "variables", foletype_variables, 0);
+ rb_define_method(cWIN32OLE_TYPE, "ole_methods", foletype_methods, 0);
+ rb_define_method(cWIN32OLE_TYPE, "ole_typelib", foletype_ole_typelib, 0);
+ rb_define_method(cWIN32OLE_TYPE, "implemented_ole_types", foletype_impl_ole_types, 0);
+ rb_define_method(cWIN32OLE_TYPE, "source_ole_types", foletype_source_ole_types, 0);
+ rb_define_method(cWIN32OLE_TYPE, "default_event_sources", foletype_default_event_sources, 0);
+ rb_define_method(cWIN32OLE_TYPE, "default_ole_types", foletype_default_ole_types, 0);
+ rb_define_method(cWIN32OLE_TYPE, "inspect", foletype_inspect, 0);
+}
diff --git a/jni/ruby/ext/win32ole/win32ole_type.h b/jni/ruby/ext/win32ole/win32ole_type.h
new file mode 100644
index 0000000..a26bf3e
--- /dev/null
+++ b/jni/ruby/ext/win32ole/win32ole_type.h
@@ -0,0 +1,8 @@
+#ifndef WIN32OLE_TYPE_H
+#define WIN32OLE_TYPE_H 1
+VALUE cWIN32OLE_TYPE;
+VALUE create_win32ole_type(ITypeInfo *pTypeInfo, VALUE name);
+ITypeInfo *itypeinfo(VALUE self);
+VALUE ole_type_from_itypeinfo(ITypeInfo *pTypeInfo);
+void Init_win32ole_type(void);
+#endif
diff --git a/jni/ruby/ext/win32ole/win32ole_typelib.c b/jni/ruby/ext/win32ole/win32ole_typelib.c
new file mode 100644
index 0000000..5a431d8
--- /dev/null
+++ b/jni/ruby/ext/win32ole/win32ole_typelib.c
@@ -0,0 +1,846 @@
+#include "win32ole.h"
+
+struct oletypelibdata {
+ ITypeLib *pTypeLib;
+};
+
+static VALUE reg_get_typelib_file_path(HKEY hkey);
+static VALUE oletypelib_path(VALUE guid, VALUE version);
+static HRESULT oletypelib_from_guid(VALUE guid, VALUE version, ITypeLib **ppTypeLib);
+static VALUE foletypelib_s_typelibs(VALUE self);
+static VALUE oletypelib_set_member(VALUE self, ITypeLib *pTypeLib);
+static void oletypelib_free(void *ptr);
+static size_t oletypelib_size(const void *ptr);
+static VALUE foletypelib_s_allocate(VALUE klass);
+static VALUE oletypelib_search_registry(VALUE self, VALUE typelib);
+static void oletypelib_get_libattr(ITypeLib *pTypeLib, TLIBATTR **ppTLibAttr);
+static VALUE oletypelib_search_registry2(VALUE self, VALUE args);
+static VALUE foletypelib_initialize(VALUE self, VALUE args);
+static VALUE foletypelib_guid(VALUE self);
+static VALUE foletypelib_name(VALUE self);
+static VALUE make_version_str(VALUE major, VALUE minor);
+static VALUE foletypelib_version(VALUE self);
+static VALUE foletypelib_major_version(VALUE self);
+static VALUE foletypelib_minor_version(VALUE self);
+static VALUE foletypelib_path(VALUE self);
+static VALUE foletypelib_visible(VALUE self);
+static VALUE foletypelib_library_name(VALUE self);
+static VALUE ole_types_from_typelib(ITypeLib *pTypeLib, VALUE classes);
+static VALUE typelib_file_from_typelib(VALUE ole);
+static VALUE typelib_file_from_clsid(VALUE ole);
+static VALUE foletypelib_ole_types(VALUE self);
+static VALUE foletypelib_inspect(VALUE self);
+
+static const rb_data_type_t oletypelib_datatype = {
+ "win32ole_typelib",
+ {NULL, oletypelib_free, oletypelib_size,},
+ 0, 0, RUBY_TYPED_FREE_IMMEDIATELY
+};
+
+static VALUE
+reg_get_typelib_file_path(HKEY hkey)
+{
+ VALUE path = Qnil;
+ path = reg_get_val2(hkey, "win64");
+ if (path != Qnil) {
+ return path;
+ }
+ path = reg_get_val2(hkey, "win32");
+ if (path != Qnil) {
+ return path;
+ }
+ path = reg_get_val2(hkey, "win16");
+ return path;
+}
+
+static VALUE
+oletypelib_path(VALUE guid, VALUE version)
+{
+ int k;
+ LONG err;
+ HKEY hkey;
+ HKEY hlang;
+ VALUE lang;
+ VALUE path = Qnil;
+
+ VALUE key = rb_str_new2("TypeLib\\");
+ rb_str_concat(key, guid);
+ rb_str_cat2(key, "\\");
+ rb_str_concat(key, version);
+
+ err = reg_open_vkey(HKEY_CLASSES_ROOT, key, &hkey);
+ if (err != ERROR_SUCCESS) {
+ return Qnil;
+ }
+ for(k = 0; path == Qnil; k++) {
+ lang = reg_enum_key(hkey, k);
+ if (lang == Qnil)
+ break;
+ err = reg_open_vkey(hkey, lang, &hlang);
+ if (err == ERROR_SUCCESS) {
+ path = reg_get_typelib_file_path(hlang);
+ RegCloseKey(hlang);
+ }
+ }
+ RegCloseKey(hkey);
+ return path;
+}
+
+static HRESULT
+oletypelib_from_guid(VALUE guid, VALUE version, ITypeLib **ppTypeLib)
+{
+ VALUE path;
+ OLECHAR *pBuf;
+ HRESULT hr;
+ path = oletypelib_path(guid, version);
+ if (path == Qnil) {
+ return E_UNEXPECTED;
+ }
+ pBuf = ole_vstr2wc(path);
+ hr = LoadTypeLibEx(pBuf, REGKIND_NONE, ppTypeLib);
+ SysFreeString(pBuf);
+ return hr;
+}
+
+ITypeLib *
+itypelib(VALUE self)
+{
+ struct oletypelibdata *ptlib;
+ TypedData_Get_Struct(self, struct oletypelibdata, &oletypelib_datatype, ptlib);
+ return ptlib->pTypeLib;
+}
+
+VALUE
+ole_typelib_from_itypeinfo(ITypeInfo *pTypeInfo)
+{
+ HRESULT hr;
+ ITypeLib *pTypeLib;
+ unsigned int index;
+ VALUE retval = Qnil;
+
+ hr = pTypeInfo->lpVtbl->GetContainingTypeLib(pTypeInfo, &pTypeLib, &index);
+ if(FAILED(hr)) {
+ return Qnil;
+ }
+ retval = create_win32ole_typelib(pTypeLib);
+ return retval;
+}
+
+/*
+ * Document-class: WIN32OLE_TYPELIB
+ *
+ * <code>WIN32OLE_TYPELIB</code> objects represent OLE tyblib information.
+ */
+
+/*
+ * call-seq:
+ *
+ * WIN32OLE_TYPELIB.typelibs
+ *
+ * Returns the array of WIN32OLE_TYPELIB object.
+ *
+ * tlibs = WIN32OLE_TYPELIB.typelibs
+ *
+ */
+static VALUE
+foletypelib_s_typelibs(VALUE self)
+{
+ HKEY htypelib, hguid;
+ DWORD i, j;
+ LONG err;
+ VALUE guid;
+ VALUE version;
+ VALUE name = Qnil;
+ VALUE typelibs = rb_ary_new();
+ VALUE typelib = Qnil;
+ HRESULT hr;
+ ITypeLib *pTypeLib;
+
+ err = reg_open_key(HKEY_CLASSES_ROOT, "TypeLib", &htypelib);
+ if(err != ERROR_SUCCESS) {
+ return typelibs;
+ }
+ for(i = 0; ; i++) {
+ guid = reg_enum_key(htypelib, i);
+ if (guid == Qnil)
+ break;
+ err = reg_open_vkey(htypelib, guid, &hguid);
+ if (err != ERROR_SUCCESS)
+ continue;
+ for(j = 0; ; j++) {
+ version = reg_enum_key(hguid, j);
+ if (version == Qnil)
+ break;
+ if ( (name = reg_get_val2(hguid, StringValuePtr(version))) != Qnil ) {
+ hr = oletypelib_from_guid(guid, version, &pTypeLib);
+ if (SUCCEEDED(hr)) {
+ typelib = create_win32ole_typelib(pTypeLib);
+ rb_ary_push(typelibs, typelib);
+ }
+ }
+ }
+ RegCloseKey(hguid);
+ }
+ RegCloseKey(htypelib);
+ return typelibs;
+}
+
+static VALUE
+oletypelib_set_member(VALUE self, ITypeLib *pTypeLib)
+{
+ struct oletypelibdata *ptlib;
+ TypedData_Get_Struct(self, struct oletypelibdata, &oletypelib_datatype, ptlib);
+ ptlib->pTypeLib = pTypeLib;
+ return self;
+}
+
+static void
+oletypelib_free(void *ptr)
+{
+ struct oletypelibdata *poletypelib = ptr;
+ OLE_FREE(poletypelib->pTypeLib);
+ free(poletypelib);
+}
+
+static size_t
+oletypelib_size(const void *ptr)
+{
+ return ptr ? sizeof(struct oletypelibdata) : 0;
+}
+
+static VALUE
+foletypelib_s_allocate(VALUE klass)
+{
+ struct oletypelibdata *poletypelib;
+ VALUE obj;
+ ole_initialize();
+ obj = TypedData_Make_Struct(klass, struct oletypelibdata, &oletypelib_datatype, poletypelib);
+ poletypelib->pTypeLib = NULL;
+ return obj;
+}
+
+VALUE
+create_win32ole_typelib(ITypeLib *pTypeLib)
+{
+ VALUE obj = foletypelib_s_allocate(cWIN32OLE_TYPELIB);
+ oletypelib_set_member(obj, pTypeLib);
+ return obj;
+}
+
+static VALUE
+oletypelib_search_registry(VALUE self, VALUE typelib)
+{
+ HKEY htypelib, hguid, hversion;
+ DWORD i, j;
+ LONG err;
+ VALUE found = Qfalse;
+ VALUE tlib;
+ VALUE guid;
+ VALUE ver;
+ HRESULT hr;
+ ITypeLib *pTypeLib;
+
+ err = reg_open_key(HKEY_CLASSES_ROOT, "TypeLib", &htypelib);
+ if(err != ERROR_SUCCESS) {
+ return Qfalse;
+ }
+ for(i = 0; !found; i++) {
+ guid = reg_enum_key(htypelib, i);
+ if (guid == Qnil)
+ break;
+ err = reg_open_vkey(htypelib, guid, &hguid);
+ if (err != ERROR_SUCCESS)
+ continue;
+ for(j = 0; found == Qfalse; j++) {
+ ver = reg_enum_key(hguid, j);
+ if (ver == Qnil)
+ break;
+ err = reg_open_vkey(hguid, ver, &hversion);
+ if (err != ERROR_SUCCESS)
+ continue;
+ tlib = reg_get_val(hversion, NULL);
+ if (tlib == Qnil) {
+ RegCloseKey(hversion);
+ continue;
+ }
+ if (rb_str_cmp(typelib, tlib) == 0) {
+ hr = oletypelib_from_guid(guid, ver, &pTypeLib);
+ if (SUCCEEDED(hr)) {
+ oletypelib_set_member(self, pTypeLib);
+ found = Qtrue;
+ }
+ }
+ RegCloseKey(hversion);
+ }
+ RegCloseKey(hguid);
+ }
+ RegCloseKey(htypelib);
+ return found;
+}
+
+static void
+oletypelib_get_libattr(ITypeLib *pTypeLib, TLIBATTR **ppTLibAttr)
+{
+ HRESULT hr;
+ hr = pTypeLib->lpVtbl->GetLibAttr(pTypeLib, ppTLibAttr);
+ if (FAILED(hr)) {
+ ole_raise(hr, eWIN32OLERuntimeError,
+ "failed to get library attribute(TLIBATTR) from ITypeLib");
+ }
+}
+
+static VALUE
+oletypelib_search_registry2(VALUE self, VALUE args)
+{
+ HKEY htypelib, hguid, hversion;
+ double fver;
+ DWORD j;
+ LONG err;
+ VALUE found = Qfalse;
+ VALUE tlib;
+ VALUE ver;
+ VALUE version_str;
+ VALUE version = Qnil;
+ VALUE typelib = Qnil;
+ HRESULT hr;
+ ITypeLib *pTypeLib;
+
+ VALUE guid = rb_ary_entry(args, 0);
+ version_str = make_version_str(rb_ary_entry(args, 1), rb_ary_entry(args, 2));
+
+ err = reg_open_key(HKEY_CLASSES_ROOT, "TypeLib", &htypelib);
+ if(err != ERROR_SUCCESS) {
+ return Qfalse;
+ }
+ err = reg_open_vkey(htypelib, guid, &hguid);
+ if (err != ERROR_SUCCESS) {
+ RegCloseKey(htypelib);
+ return Qfalse;
+ }
+ if (version_str != Qnil) {
+ err = reg_open_vkey(hguid, version_str, &hversion);
+ if (err == ERROR_SUCCESS) {
+ tlib = reg_get_val(hversion, NULL);
+ if (tlib != Qnil) {
+ typelib = tlib;
+ version = version_str;
+ }
+ }
+ RegCloseKey(hversion);
+ } else {
+ fver = 0.0;
+ for(j = 0; ;j++) {
+ ver = reg_enum_key(hguid, j);
+ if (ver == Qnil)
+ break;
+ err = reg_open_vkey(hguid, ver, &hversion);
+ if (err != ERROR_SUCCESS)
+ continue;
+ tlib = reg_get_val(hversion, NULL);
+ if (tlib == Qnil) {
+ RegCloseKey(hversion);
+ continue;
+ }
+ if (fver < atof(StringValuePtr(ver))) {
+ fver = atof(StringValuePtr(ver));
+ version = ver;
+ typelib = tlib;
+ }
+ RegCloseKey(hversion);
+ }
+ }
+ RegCloseKey(hguid);
+ RegCloseKey(htypelib);
+ if (typelib != Qnil) {
+ hr = oletypelib_from_guid(guid, version, &pTypeLib);
+ if (SUCCEEDED(hr)) {
+ found = Qtrue;
+ oletypelib_set_member(self, pTypeLib);
+ }
+ }
+ return found;
+}
+
+
+/*
+ * call-seq:
+ * WIN32OLE_TYPELIB.new(typelib [, version1, version2]) -> WIN32OLE_TYPELIB object
+ *
+ * Returns a new WIN32OLE_TYPELIB object.
+ *
+ * The first argument <i>typelib</i> specifies OLE type library name or GUID or
+ * OLE library file.
+ * The second argument is major version or version of the type library.
+ * The third argument is minor version.
+ * The second argument and third argument are optional.
+ * If the first argument is type library name, then the second and third argument
+ * are ignored.
+ *
+ * tlib1 = WIN32OLE_TYPELIB.new('Microsoft Excel 9.0 Object Library')
+ * tlib2 = WIN32OLE_TYPELIB.new('{00020813-0000-0000-C000-000000000046}')
+ * tlib3 = WIN32OLE_TYPELIB.new('{00020813-0000-0000-C000-000000000046}', 1.3)
+ * tlib4 = WIN32OLE_TYPELIB.new('{00020813-0000-0000-C000-000000000046}', 1, 3)
+ * tlib5 = WIN32OLE_TYPELIB.new("C:\\WINNT\\SYSTEM32\\SHELL32.DLL")
+ * puts tlib1.name # -> 'Microsoft Excel 9.0 Object Library'
+ * puts tlib2.name # -> 'Microsoft Excel 9.0 Object Library'
+ * puts tlib3.name # -> 'Microsoft Excel 9.0 Object Library'
+ * puts tlib4.name # -> 'Microsoft Excel 9.0 Object Library'
+ * puts tlib5.name # -> 'Microsoft Shell Controls And Automation'
+ *
+ */
+static VALUE
+foletypelib_initialize(VALUE self, VALUE args)
+{
+ VALUE found = Qfalse;
+ VALUE typelib = Qnil;
+ int len = 0;
+ OLECHAR * pbuf;
+ ITypeLib *pTypeLib;
+ HRESULT hr = S_OK;
+
+ len = RARRAY_LEN(args);
+ if (len < 1 || len > 3) {
+ rb_raise(rb_eArgError, "wrong number of arguments (%d for 1..3)", len);
+ }
+
+ typelib = rb_ary_entry(args, 0);
+
+ SafeStringValue(typelib);
+
+ found = oletypelib_search_registry(self, typelib);
+ if (found == Qfalse) {
+ found = oletypelib_search_registry2(self, args);
+ }
+ if (found == Qfalse) {
+ pbuf = ole_vstr2wc(typelib);
+ hr = LoadTypeLibEx(pbuf, REGKIND_NONE, &pTypeLib);
+ SysFreeString(pbuf);
+ if (SUCCEEDED(hr)) {
+ found = Qtrue;
+ oletypelib_set_member(self, pTypeLib);
+ }
+ }
+
+ if (found == Qfalse) {
+ rb_raise(eWIN32OLERuntimeError, "not found type library `%s`",
+ StringValuePtr(typelib));
+ }
+ return self;
+}
+
+/*
+ * call-seq:
+ * WIN32OLE_TYPELIB#guid -> The guid string.
+ *
+ * Returns guid string which specifies type library.
+ *
+ * tlib = WIN32OLE_TYPELIB.new('Microsoft Excel 9.0 Object Library')
+ * guid = tlib.guid # -> '{00020813-0000-0000-C000-000000000046}'
+ */
+static VALUE
+foletypelib_guid(VALUE self)
+{
+ ITypeLib *pTypeLib;
+ OLECHAR bstr[80];
+ VALUE guid = Qnil;
+ int len;
+ TLIBATTR *pTLibAttr;
+
+ pTypeLib = itypelib(self);
+ oletypelib_get_libattr(pTypeLib, &pTLibAttr);
+ len = StringFromGUID2(&pTLibAttr->guid, bstr, sizeof(bstr)/sizeof(OLECHAR));
+ if (len > 3) {
+ guid = ole_wc2vstr(bstr, FALSE);
+ }
+ pTypeLib->lpVtbl->ReleaseTLibAttr(pTypeLib, pTLibAttr);
+ return guid;
+}
+
+/*
+ * call-seq:
+ * WIN32OLE_TYPELIB#name -> The type library name
+ *
+ * Returns the type library name.
+ *
+ * tlib = WIN32OLE_TYPELIB.new('Microsoft Excel 9.0 Object Library')
+ * name = tlib.name # -> 'Microsoft Excel 9.0 Object Library'
+ */
+static VALUE
+foletypelib_name(VALUE self)
+{
+ ITypeLib *pTypeLib;
+ HRESULT hr;
+ BSTR bstr;
+ VALUE name;
+ pTypeLib = itypelib(self);
+ hr = pTypeLib->lpVtbl->GetDocumentation(pTypeLib, -1,
+ NULL, &bstr, NULL, NULL);
+
+ if (FAILED(hr)) {
+ ole_raise(hr, eWIN32OLERuntimeError, "failed to get name from ITypeLib");
+ }
+ name = WC2VSTR(bstr);
+ return name;
+}
+
+static VALUE
+make_version_str(VALUE major, VALUE minor)
+{
+ VALUE version_str = Qnil;
+ VALUE minor_str = Qnil;
+ if (major == Qnil) {
+ return Qnil;
+ }
+ version_str = rb_String(major);
+ if (minor != Qnil) {
+ minor_str = rb_String(minor);
+ rb_str_cat2(version_str, ".");
+ rb_str_append(version_str, minor_str);
+ }
+ return version_str;
+}
+
+/*
+ * call-seq:
+ * WIN32OLE_TYPELIB#version -> The type library version String object.
+ *
+ * Returns the type library version.
+ *
+ * tlib = WIN32OLE_TYPELIB.new('Microsoft Excel 9.0 Object Library')
+ * puts tlib.version #-> "1.3"
+ */
+static VALUE
+foletypelib_version(VALUE self)
+{
+ TLIBATTR *pTLibAttr;
+ ITypeLib *pTypeLib;
+ VALUE version;
+
+ pTypeLib = itypelib(self);
+ oletypelib_get_libattr(pTypeLib, &pTLibAttr);
+ version = rb_sprintf("%d.%d", pTLibAttr->wMajorVerNum, pTLibAttr->wMinorVerNum);
+ pTypeLib->lpVtbl->ReleaseTLibAttr(pTypeLib, pTLibAttr);
+ return version;
+}
+
+/*
+ * call-seq:
+ * WIN32OLE_TYPELIB#major_version -> The type library major version.
+ *
+ * Returns the type library major version.
+ *
+ * tlib = WIN32OLE_TYPELIB.new('Microsoft Excel 9.0 Object Library')
+ * puts tlib.major_version # -> 1
+ */
+static VALUE
+foletypelib_major_version(VALUE self)
+{
+ TLIBATTR *pTLibAttr;
+ VALUE major;
+ ITypeLib *pTypeLib;
+ pTypeLib = itypelib(self);
+ oletypelib_get_libattr(pTypeLib, &pTLibAttr);
+
+ major = INT2NUM(pTLibAttr->wMajorVerNum);
+ pTypeLib->lpVtbl->ReleaseTLibAttr(pTypeLib, pTLibAttr);
+ return major;
+}
+
+/*
+ * call-seq:
+ * WIN32OLE_TYPELIB#minor_version -> The type library minor version.
+ *
+ * Returns the type library minor version.
+ *
+ * tlib = WIN32OLE_TYPELIB.new('Microsoft Excel 9.0 Object Library')
+ * puts tlib.minor_version # -> 3
+ */
+static VALUE
+foletypelib_minor_version(VALUE self)
+{
+ TLIBATTR *pTLibAttr;
+ VALUE minor;
+ ITypeLib *pTypeLib;
+ pTypeLib = itypelib(self);
+ oletypelib_get_libattr(pTypeLib, &pTLibAttr);
+ minor = INT2NUM(pTLibAttr->wMinorVerNum);
+ pTypeLib->lpVtbl->ReleaseTLibAttr(pTypeLib, pTLibAttr);
+ return minor;
+}
+
+/*
+ * call-seq:
+ * WIN32OLE_TYPELIB#path -> The type library file path.
+ *
+ * Returns the type library file path.
+ *
+ * tlib = WIN32OLE_TYPELIB.new('Microsoft Excel 9.0 Object Library')
+ * puts tlib.path #-> 'C:\...\EXCEL9.OLB'
+ */
+static VALUE
+foletypelib_path(VALUE self)
+{
+ TLIBATTR *pTLibAttr;
+ HRESULT hr = S_OK;
+ BSTR bstr;
+ LCID lcid = cWIN32OLE_lcid;
+ VALUE path;
+ ITypeLib *pTypeLib;
+
+ pTypeLib = itypelib(self);
+ oletypelib_get_libattr(pTypeLib, &pTLibAttr);
+ hr = QueryPathOfRegTypeLib(&pTLibAttr->guid,
+ pTLibAttr->wMajorVerNum,
+ pTLibAttr->wMinorVerNum,
+ lcid,
+ &bstr);
+ if (FAILED(hr)) {
+ pTypeLib->lpVtbl->ReleaseTLibAttr(pTypeLib, pTLibAttr);
+ ole_raise(hr, eWIN32OLERuntimeError, "failed to QueryPathOfRegTypeTypeLib");
+ }
+
+ pTypeLib->lpVtbl->ReleaseTLibAttr(pTypeLib, pTLibAttr);
+ path = WC2VSTR(bstr);
+ return path;
+}
+
+/*
+ * call-seq:
+ * WIN32OLE_TYPELIB#visible?
+ *
+ * Returns true if the type library information is not hidden.
+ * If wLibFlags of TLIBATTR is 0 or LIBFLAG_FRESTRICTED or LIBFLAG_FHIDDEN,
+ * the method returns false, otherwise, returns true.
+ * If the method fails to access the TLIBATTR information, then
+ * WIN32OLERuntimeError is raised.
+ *
+ * tlib = WIN32OLE_TYPELIB.new('Microsoft Excel 9.0 Object Library')
+ * tlib.visible? # => true
+ */
+static VALUE
+foletypelib_visible(VALUE self)
+{
+ ITypeLib *pTypeLib = NULL;
+ VALUE visible = Qtrue;
+ TLIBATTR *pTLibAttr;
+
+ pTypeLib = itypelib(self);
+ oletypelib_get_libattr(pTypeLib, &pTLibAttr);
+
+ if ((pTLibAttr->wLibFlags == 0) ||
+ (pTLibAttr->wLibFlags & LIBFLAG_FRESTRICTED) ||
+ (pTLibAttr->wLibFlags & LIBFLAG_FHIDDEN)) {
+ visible = Qfalse;
+ }
+ pTypeLib->lpVtbl->ReleaseTLibAttr(pTypeLib, pTLibAttr);
+ return visible;
+}
+
+/*
+ * call-seq:
+ * WIN32OLE_TYPELIB#library_name
+ *
+ * Returns library name.
+ * If the method fails to access library name, WIN32OLERuntimeError is raised.
+ *
+ * tlib = WIN32OLE_TYPELIB.new('Microsoft Excel 9.0 Object Library')
+ * tlib.library_name # => Excel
+ */
+static VALUE
+foletypelib_library_name(VALUE self)
+{
+ HRESULT hr;
+ ITypeLib *pTypeLib = NULL;
+ VALUE libname = Qnil;
+ BSTR bstr;
+
+ pTypeLib = itypelib(self);
+ hr = pTypeLib->lpVtbl->GetDocumentation(pTypeLib, -1,
+ &bstr, NULL, NULL, NULL);
+ if (FAILED(hr)) {
+ ole_raise(hr, eWIN32OLERuntimeError, "failed to get library name");
+ }
+ libname = WC2VSTR(bstr);
+ return libname;
+}
+
+static VALUE
+ole_types_from_typelib(ITypeLib *pTypeLib, VALUE classes)
+{
+ long count;
+ int i;
+ HRESULT hr;
+ BSTR bstr;
+ ITypeInfo *pTypeInfo;
+ VALUE type;
+
+ count = pTypeLib->lpVtbl->GetTypeInfoCount(pTypeLib);
+ for (i = 0; i < count; i++) {
+ hr = pTypeLib->lpVtbl->GetDocumentation(pTypeLib, i,
+ &bstr, NULL, NULL, NULL);
+ if (FAILED(hr))
+ continue;
+
+ hr = pTypeLib->lpVtbl->GetTypeInfo(pTypeLib, i, &pTypeInfo);
+ if (FAILED(hr))
+ continue;
+
+ type = create_win32ole_type(pTypeInfo, WC2VSTR(bstr));
+
+ rb_ary_push(classes, type);
+ OLE_RELEASE(pTypeInfo);
+ }
+ return classes;
+}
+
+static VALUE
+typelib_file_from_typelib(VALUE ole)
+{
+ HKEY htypelib, hclsid, hversion, hlang;
+ double fver;
+ DWORD i, j, k;
+ LONG err;
+ BOOL found = FALSE;
+ VALUE typelib;
+ VALUE file = Qnil;
+ VALUE clsid;
+ VALUE ver;
+ VALUE lang;
+
+ err = reg_open_key(HKEY_CLASSES_ROOT, "TypeLib", &htypelib);
+ if(err != ERROR_SUCCESS) {
+ return Qnil;
+ }
+ for(i = 0; !found; i++) {
+ clsid = reg_enum_key(htypelib, i);
+ if (clsid == Qnil)
+ break;
+ err = reg_open_vkey(htypelib, clsid, &hclsid);
+ if (err != ERROR_SUCCESS)
+ continue;
+ fver = 0;
+ for(j = 0; !found; j++) {
+ ver = reg_enum_key(hclsid, j);
+ if (ver == Qnil)
+ break;
+ err = reg_open_vkey(hclsid, ver, &hversion);
+ if (err != ERROR_SUCCESS || fver > atof(StringValuePtr(ver)))
+ continue;
+ fver = atof(StringValuePtr(ver));
+ typelib = reg_get_val(hversion, NULL);
+ if (typelib == Qnil)
+ continue;
+ if (rb_str_cmp(typelib, ole) == 0) {
+ for(k = 0; !found; k++) {
+ lang = reg_enum_key(hversion, k);
+ if (lang == Qnil)
+ break;
+ err = reg_open_vkey(hversion, lang, &hlang);
+ if (err == ERROR_SUCCESS) {
+ if ((file = reg_get_typelib_file_path(hlang)) != Qnil)
+ found = TRUE;
+ RegCloseKey(hlang);
+ }
+ }
+ }
+ RegCloseKey(hversion);
+ }
+ RegCloseKey(hclsid);
+ }
+ RegCloseKey(htypelib);
+ return file;
+}
+
+static VALUE
+typelib_file_from_clsid(VALUE ole)
+{
+ HKEY hroot, hclsid;
+ LONG err;
+ VALUE typelib;
+ char path[MAX_PATH + 1];
+
+ err = reg_open_key(HKEY_CLASSES_ROOT, "CLSID", &hroot);
+ if (err != ERROR_SUCCESS) {
+ return Qnil;
+ }
+ err = reg_open_key(hroot, StringValuePtr(ole), &hclsid);
+ if (err != ERROR_SUCCESS) {
+ RegCloseKey(hroot);
+ return Qnil;
+ }
+ typelib = reg_get_val2(hclsid, "InprocServer32");
+ RegCloseKey(hroot);
+ RegCloseKey(hclsid);
+ if (typelib != Qnil) {
+ ExpandEnvironmentStrings(StringValuePtr(typelib), path, sizeof(path));
+ path[MAX_PATH] = '\0';
+ typelib = rb_str_new2(path);
+ }
+ return typelib;
+}
+
+VALUE
+typelib_file(VALUE ole)
+{
+ VALUE file = typelib_file_from_clsid(ole);
+ if (file != Qnil) {
+ return file;
+ }
+ return typelib_file_from_typelib(ole);
+}
+
+
+/*
+ * call-seq:
+ * WIN32OLE_TYPELIB#ole_types -> The array of WIN32OLE_TYPE object included the type library.
+ *
+ * Returns the type library file path.
+ *
+ * tlib = WIN32OLE_TYPELIB.new('Microsoft Excel 9.0 Object Library')
+ * classes = tlib.ole_types.collect{|k| k.name} # -> ['AddIn', 'AddIns' ...]
+ */
+static VALUE
+foletypelib_ole_types(VALUE self)
+{
+ ITypeLib *pTypeLib = NULL;
+ VALUE classes = rb_ary_new();
+ pTypeLib = itypelib(self);
+ ole_types_from_typelib(pTypeLib, classes);
+ return classes;
+}
+
+/*
+ * call-seq:
+ * WIN32OLE_TYPELIB#inspect -> String
+ *
+ * Returns the type library name with class name.
+ *
+ * tlib = WIN32OLE_TYPELIB.new('Microsoft Excel 9.0 Object Library')
+ * tlib.inspect # => "<#WIN32OLE_TYPELIB:Microsoft Excel 9.0 Object Library>"
+ */
+static VALUE
+foletypelib_inspect(VALUE self)
+{
+ return default_inspect(self, "WIN32OLE_TYPELIB");
+}
+
+void
+Init_win32ole_typelib(void)
+{
+ cWIN32OLE_TYPELIB = rb_define_class("WIN32OLE_TYPELIB", rb_cObject);
+ rb_define_singleton_method(cWIN32OLE_TYPELIB, "typelibs", foletypelib_s_typelibs, 0);
+ rb_define_alloc_func(cWIN32OLE_TYPELIB, foletypelib_s_allocate);
+ rb_define_method(cWIN32OLE_TYPELIB, "initialize", foletypelib_initialize, -2);
+ rb_define_method(cWIN32OLE_TYPELIB, "guid", foletypelib_guid, 0);
+ rb_define_method(cWIN32OLE_TYPELIB, "name", foletypelib_name, 0);
+ rb_define_method(cWIN32OLE_TYPELIB, "version", foletypelib_version, 0);
+ rb_define_method(cWIN32OLE_TYPELIB, "major_version", foletypelib_major_version, 0);
+ rb_define_method(cWIN32OLE_TYPELIB, "minor_version", foletypelib_minor_version, 0);
+ rb_define_method(cWIN32OLE_TYPELIB, "path", foletypelib_path, 0);
+ rb_define_method(cWIN32OLE_TYPELIB, "ole_types", foletypelib_ole_types, 0);
+ rb_define_alias(cWIN32OLE_TYPELIB, "ole_classes", "ole_types");
+ rb_define_method(cWIN32OLE_TYPELIB, "visible?", foletypelib_visible, 0);
+ rb_define_method(cWIN32OLE_TYPELIB, "library_name", foletypelib_library_name, 0);
+ rb_define_alias(cWIN32OLE_TYPELIB, "to_s", "name");
+ rb_define_method(cWIN32OLE_TYPELIB, "inspect", foletypelib_inspect, 0);
+}
diff --git a/jni/ruby/ext/win32ole/win32ole_typelib.h b/jni/ruby/ext/win32ole/win32ole_typelib.h
new file mode 100644
index 0000000..9fc117f
--- /dev/null
+++ b/jni/ruby/ext/win32ole/win32ole_typelib.h
@@ -0,0 +1,11 @@
+#ifndef WIN32OLE_TYPELIB_H
+#define WIN32OLE_TYPELIB_H 1
+
+VALUE cWIN32OLE_TYPELIB;
+
+void Init_win32ole_typelib(void);
+ITypeLib * itypelib(VALUE self);
+VALUE typelib_file(VALUE ole);
+VALUE create_win32ole_typelib(ITypeLib *pTypeLib);
+VALUE ole_typelib_from_itypeinfo(ITypeInfo *pTypeInfo);
+#endif
diff --git a/jni/ruby/ext/win32ole/win32ole_variable.c b/jni/ruby/ext/win32ole/win32ole_variable.c
new file mode 100644
index 0000000..dd58382
--- /dev/null
+++ b/jni/ruby/ext/win32ole/win32ole_variable.c
@@ -0,0 +1,380 @@
+#include "win32ole.h"
+
+struct olevariabledata {
+ ITypeInfo *pTypeInfo;
+ UINT index;
+};
+
+static void olevariable_free(void *ptr);
+static size_t olevariable_size(const void *ptr);
+static VALUE folevariable_name(VALUE self);
+static VALUE ole_variable_ole_type(ITypeInfo *pTypeInfo, UINT var_index);
+static VALUE folevariable_ole_type(VALUE self);
+static VALUE ole_variable_ole_type_detail(ITypeInfo *pTypeInfo, UINT var_index);
+static VALUE folevariable_ole_type_detail(VALUE self);
+static VALUE ole_variable_value(ITypeInfo *pTypeInfo, UINT var_index);
+static VALUE folevariable_value(VALUE self);
+static VALUE ole_variable_visible(ITypeInfo *pTypeInfo, UINT var_index);
+static VALUE folevariable_visible(VALUE self);
+static VALUE ole_variable_kind(ITypeInfo *pTypeInfo, UINT var_index);
+static VALUE folevariable_variable_kind(VALUE self);
+static VALUE ole_variable_varkind(ITypeInfo *pTypeInfo, UINT var_index);
+static VALUE folevariable_varkind(VALUE self);
+static VALUE folevariable_inspect(VALUE self);
+
+static const rb_data_type_t olevariable_datatype = {
+ "win32ole_variable",
+ {NULL, olevariable_free, olevariable_size,},
+ 0, 0, RUBY_TYPED_FREE_IMMEDIATELY
+};
+
+static void
+olevariable_free(void *ptr)
+{
+ struct olevariabledata *polevar = ptr;
+ OLE_FREE(polevar->pTypeInfo);
+ free(polevar);
+}
+
+static size_t
+olevariable_size(const void *ptr)
+{
+ return ptr ? sizeof(struct olevariabledata) : 0;
+}
+
+/*
+ * Document-class: WIN32OLE_VARIABLE
+ *
+ * <code>WIN32OLE_VARIABLE</code> objects represent OLE variable information.
+ */
+
+VALUE
+create_win32ole_variable(ITypeInfo *pTypeInfo, UINT index, VALUE name)
+{
+ struct olevariabledata *pvar;
+ VALUE obj = TypedData_Make_Struct(cWIN32OLE_VARIABLE, struct olevariabledata,
+ &olevariable_datatype, pvar);
+ pvar->pTypeInfo = pTypeInfo;
+ OLE_ADDREF(pTypeInfo);
+ pvar->index = index;
+ rb_ivar_set(obj, rb_intern("name"), name);
+ return obj;
+}
+
+/*
+ * call-seq:
+ * WIN32OLE_VARIABLE#name
+ *
+ * Returns the name of variable.
+ *
+ * tobj = WIN32OLE_TYPE.new('Microsoft Excel 9.0 Object Library', 'XlSheetType')
+ * variables = tobj.variables
+ * variables.each do |variable|
+ * puts "#{variable.name}"
+ * end
+ *
+ * The result of above script is following:
+ * xlChart
+ * xlDialogSheet
+ * xlExcel4IntlMacroSheet
+ * xlExcel4MacroSheet
+ * xlWorksheet
+ *
+ */
+static VALUE
+folevariable_name(VALUE self)
+{
+ return rb_ivar_get(self, rb_intern("name"));
+}
+
+static VALUE
+ole_variable_ole_type(ITypeInfo *pTypeInfo, UINT var_index)
+{
+ VARDESC *pVarDesc;
+ HRESULT hr;
+ VALUE type;
+ hr = pTypeInfo->lpVtbl->GetVarDesc(pTypeInfo, var_index, &pVarDesc);
+ if (FAILED(hr))
+ ole_raise(hr, eWIN32OLERuntimeError, "failed to GetVarDesc");
+ type = ole_typedesc2val(pTypeInfo, &(pVarDesc->elemdescVar.tdesc), Qnil);
+ pTypeInfo->lpVtbl->ReleaseVarDesc(pTypeInfo, pVarDesc);
+ return type;
+}
+
+/*
+ * call-seq:
+ * WIN32OLE_VARIABLE#ole_type
+ *
+ * Returns OLE type string.
+ *
+ * tobj = WIN32OLE_TYPE.new('Microsoft Excel 9.0 Object Library', 'XlSheetType')
+ * variables = tobj.variables
+ * variables.each do |variable|
+ * puts "#{variable.ole_type} #{variable.name}"
+ * end
+ *
+ * The result of above script is following:
+ * INT xlChart
+ * INT xlDialogSheet
+ * INT xlExcel4IntlMacroSheet
+ * INT xlExcel4MacroSheet
+ * INT xlWorksheet
+ *
+ */
+static VALUE
+folevariable_ole_type(VALUE self)
+{
+ struct olevariabledata *pvar;
+ TypedData_Get_Struct(self, struct olevariabledata, &olevariable_datatype, pvar);
+ return ole_variable_ole_type(pvar->pTypeInfo, pvar->index);
+}
+
+static VALUE
+ole_variable_ole_type_detail(ITypeInfo *pTypeInfo, UINT var_index)
+{
+ VARDESC *pVarDesc;
+ HRESULT hr;
+ VALUE type = rb_ary_new();
+ hr = pTypeInfo->lpVtbl->GetVarDesc(pTypeInfo, var_index, &pVarDesc);
+ if (FAILED(hr))
+ ole_raise(hr, eWIN32OLERuntimeError, "failed to GetVarDesc");
+ ole_typedesc2val(pTypeInfo, &(pVarDesc->elemdescVar.tdesc), type);
+ pTypeInfo->lpVtbl->ReleaseVarDesc(pTypeInfo, pVarDesc);
+ return type;
+}
+
+/*
+ * call-seq:
+ * WIN32OLE_VARIABLE#ole_type_detail
+ *
+ * Returns detail information of type. The information is array of type.
+ *
+ * tobj = WIN32OLE_TYPE.new('DirectX 7 for Visual Basic Type Library', 'D3DCLIPSTATUS')
+ * variable = tobj.variables.find {|variable| variable.name == 'lFlags'}
+ * tdetail = variable.ole_type_detail
+ * p tdetail # => ["USERDEFINED", "CONST_D3DCLIPSTATUSFLAGS"]
+ *
+ */
+static VALUE
+folevariable_ole_type_detail(VALUE self)
+{
+ struct olevariabledata *pvar;
+ TypedData_Get_Struct(self, struct olevariabledata, &olevariable_datatype, pvar);
+ return ole_variable_ole_type_detail(pvar->pTypeInfo, pvar->index);
+}
+
+static VALUE
+ole_variable_value(ITypeInfo *pTypeInfo, UINT var_index)
+{
+ VARDESC *pVarDesc;
+ HRESULT hr;
+ VALUE val = Qnil;
+ hr = pTypeInfo->lpVtbl->GetVarDesc(pTypeInfo, var_index, &pVarDesc);
+ if (FAILED(hr))
+ return Qnil;
+ if(pVarDesc->varkind == VAR_CONST)
+ val = ole_variant2val(V_UNION1(pVarDesc, lpvarValue));
+ pTypeInfo->lpVtbl->ReleaseVarDesc(pTypeInfo, pVarDesc);
+ return val;
+}
+
+/*
+ * call-seq:
+ * WIN32OLE_VARIABLE#value
+ *
+ * Returns value if value is exists. If the value does not exist,
+ * this method returns nil.
+ *
+ * tobj = WIN32OLE_TYPE.new('Microsoft Excel 9.0 Object Library', 'XlSheetType')
+ * variables = tobj.variables
+ * variables.each do |variable|
+ * puts "#{variable.name} #{variable.value}"
+ * end
+ *
+ * The result of above script is following:
+ * xlChart = -4109
+ * xlDialogSheet = -4116
+ * xlExcel4IntlMacroSheet = 4
+ * xlExcel4MacroSheet = 3
+ * xlWorksheet = -4167
+ *
+ */
+static VALUE
+folevariable_value(VALUE self)
+{
+ struct olevariabledata *pvar;
+ TypedData_Get_Struct(self, struct olevariabledata, &olevariable_datatype, pvar);
+ return ole_variable_value(pvar->pTypeInfo, pvar->index);
+}
+
+static VALUE
+ole_variable_visible(ITypeInfo *pTypeInfo, UINT var_index)
+{
+ VARDESC *pVarDesc;
+ HRESULT hr;
+ VALUE visible = Qfalse;
+ hr = pTypeInfo->lpVtbl->GetVarDesc(pTypeInfo, var_index, &pVarDesc);
+ if (FAILED(hr))
+ return visible;
+ if (!(pVarDesc->wVarFlags & (VARFLAG_FHIDDEN |
+ VARFLAG_FRESTRICTED |
+ VARFLAG_FNONBROWSABLE))) {
+ visible = Qtrue;
+ }
+ pTypeInfo->lpVtbl->ReleaseVarDesc(pTypeInfo, pVarDesc);
+ return visible;
+}
+
+/*
+ * call-seq:
+ * WIN32OLE_VARIABLE#visible?
+ *
+ * Returns true if the variable is public.
+ *
+ * tobj = WIN32OLE_TYPE.new('Microsoft Excel 9.0 Object Library', 'XlSheetType')
+ * variables = tobj.variables
+ * variables.each do |variable|
+ * puts "#{variable.name} #{variable.visible?}"
+ * end
+ *
+ * The result of above script is following:
+ * xlChart true
+ * xlDialogSheet true
+ * xlExcel4IntlMacroSheet true
+ * xlExcel4MacroSheet true
+ * xlWorksheet true
+ *
+ */
+static VALUE
+folevariable_visible(VALUE self)
+{
+ struct olevariabledata *pvar;
+ TypedData_Get_Struct(self, struct olevariabledata, &olevariable_datatype, pvar);
+ return ole_variable_visible(pvar->pTypeInfo, pvar->index);
+}
+
+static VALUE
+ole_variable_kind(ITypeInfo *pTypeInfo, UINT var_index)
+{
+ VARDESC *pVarDesc;
+ HRESULT hr;
+ VALUE kind = rb_str_new2("UNKNOWN");
+ hr = pTypeInfo->lpVtbl->GetVarDesc(pTypeInfo, var_index, &pVarDesc);
+ if (FAILED(hr))
+ return kind;
+ switch(pVarDesc->varkind) {
+ case VAR_PERINSTANCE:
+ kind = rb_str_new2("PERINSTANCE");
+ break;
+ case VAR_STATIC:
+ kind = rb_str_new2("STATIC");
+ break;
+ case VAR_CONST:
+ kind = rb_str_new2("CONSTANT");
+ break;
+ case VAR_DISPATCH:
+ kind = rb_str_new2("DISPATCH");
+ break;
+ default:
+ break;
+ }
+ pTypeInfo->lpVtbl->ReleaseVarDesc(pTypeInfo, pVarDesc);
+ return kind;
+}
+
+/*
+ * call-seq:
+ * WIN32OLE_VARIABLE#variable_kind
+ *
+ * Returns variable kind string.
+ *
+ * tobj = WIN32OLE_TYPE.new('Microsoft Excel 9.0 Object Library', 'XlSheetType')
+ * variables = tobj.variables
+ * variables.each do |variable|
+ * puts "#{variable.name} #{variable.variable_kind}"
+ * end
+ *
+ * The result of above script is following:
+ * xlChart CONSTANT
+ * xlDialogSheet CONSTANT
+ * xlExcel4IntlMacroSheet CONSTANT
+ * xlExcel4MacroSheet CONSTANT
+ * xlWorksheet CONSTANT
+ */
+static VALUE
+folevariable_variable_kind(VALUE self)
+{
+ struct olevariabledata *pvar;
+ TypedData_Get_Struct(self, struct olevariabledata, &olevariable_datatype, pvar);
+ return ole_variable_kind(pvar->pTypeInfo, pvar->index);
+}
+
+static VALUE
+ole_variable_varkind(ITypeInfo *pTypeInfo, UINT var_index)
+{
+ VARDESC *pVarDesc;
+ HRESULT hr;
+ VALUE kind = Qnil;
+ hr = pTypeInfo->lpVtbl->GetVarDesc(pTypeInfo, var_index, &pVarDesc);
+ if (FAILED(hr))
+ return kind;
+ pTypeInfo->lpVtbl->ReleaseVarDesc(pTypeInfo, pVarDesc);
+ kind = INT2FIX(pVarDesc->varkind);
+ return kind;
+}
+
+/*
+ * call-seq:
+ * WIN32OLE_VARIABLE#varkind
+ *
+ * Returns the number which represents variable kind.
+ * tobj = WIN32OLE_TYPE.new('Microsoft Excel 9.0 Object Library', 'XlSheetType')
+ * variables = tobj.variables
+ * variables.each do |variable|
+ * puts "#{variable.name} #{variable.varkind}"
+ * end
+ *
+ * The result of above script is following:
+ * xlChart 2
+ * xlDialogSheet 2
+ * xlExcel4IntlMacroSheet 2
+ * xlExcel4MacroSheet 2
+ * xlWorksheet 2
+ */
+static VALUE
+folevariable_varkind(VALUE self)
+{
+ struct olevariabledata *pvar;
+ TypedData_Get_Struct(self, struct olevariabledata, &olevariable_datatype, pvar);
+ return ole_variable_varkind(pvar->pTypeInfo, pvar->index);
+}
+
+/*
+ * call-seq:
+ * WIN32OLE_VARIABLE#inspect -> String
+ *
+ * Returns the OLE variable name and the value with class name.
+ *
+ */
+static VALUE
+folevariable_inspect(VALUE self)
+{
+ VALUE v = rb_inspect(folevariable_value(self));
+ VALUE n = folevariable_name(self);
+ VALUE detail = rb_sprintf("%"PRIsVALUE"=%"PRIsVALUE, n, v);
+ return make_inspect("WIN32OLE_VARIABLE", detail);
+}
+
+void Init_win32ole_variable(void)
+{
+ cWIN32OLE_VARIABLE = rb_define_class("WIN32OLE_VARIABLE", rb_cObject);
+ rb_define_method(cWIN32OLE_VARIABLE, "name", folevariable_name, 0);
+ rb_define_method(cWIN32OLE_VARIABLE, "ole_type", folevariable_ole_type, 0);
+ rb_define_method(cWIN32OLE_VARIABLE, "ole_type_detail", folevariable_ole_type_detail, 0);
+ rb_define_method(cWIN32OLE_VARIABLE, "value", folevariable_value, 0);
+ rb_define_method(cWIN32OLE_VARIABLE, "visible?", folevariable_visible, 0);
+ rb_define_method(cWIN32OLE_VARIABLE, "variable_kind", folevariable_variable_kind, 0);
+ rb_define_method(cWIN32OLE_VARIABLE, "varkind", folevariable_varkind, 0);
+ rb_define_method(cWIN32OLE_VARIABLE, "inspect", folevariable_inspect, 0);
+ rb_define_alias(cWIN32OLE_VARIABLE, "to_s", "name");
+}
diff --git a/jni/ruby/ext/win32ole/win32ole_variable.h b/jni/ruby/ext/win32ole/win32ole_variable.h
new file mode 100644
index 0000000..704dc13
--- /dev/null
+++ b/jni/ruby/ext/win32ole/win32ole_variable.h
@@ -0,0 +1,8 @@
+#ifndef WIN32OLE_VARIABLE_H
+#define WIN32OLE_VARIABLE_H 1
+
+VALUE cWIN32OLE_VARIABLE;
+VALUE create_win32ole_variable(ITypeInfo *pTypeInfo, UINT index, VALUE name);
+void Init_win32ole_variable(void);
+
+#endif
diff --git a/jni/ruby/ext/win32ole/win32ole_variant.c b/jni/ruby/ext/win32ole/win32ole_variant.c
new file mode 100644
index 0000000..1731ab7
--- /dev/null
+++ b/jni/ruby/ext/win32ole/win32ole_variant.c
@@ -0,0 +1,734 @@
+#include "win32ole.h"
+
+struct olevariantdata {
+ VARIANT realvar;
+ VARIANT var;
+};
+
+static void olevariant_free(void *ptr);
+static size_t olevariant_size(const void *ptr);
+static void ole_val2olevariantdata(VALUE val, VARTYPE vt, struct olevariantdata *pvar);
+static void ole_val2variant_err(VALUE val, VARIANT *var);
+static void ole_set_byref(VARIANT *realvar, VARIANT *var, VARTYPE vt);
+static VALUE folevariant_s_allocate(VALUE klass);
+static VALUE folevariant_s_array(VALUE klass, VALUE dims, VALUE vvt);
+static void check_type_val2variant(VALUE val);
+static VALUE folevariant_initialize(VALUE self, VALUE args);
+static LONG *ary2safe_array_index(int ary_size, VALUE *ary, SAFEARRAY *psa);
+static void unlock_safe_array(SAFEARRAY *psa);
+static SAFEARRAY *get_locked_safe_array(VALUE val);
+static VALUE folevariant_ary_aref(int argc, VALUE *argv, VALUE self);
+static VALUE folevariant_ary_aset(int argc, VALUE *argv, VALUE self);
+static VALUE folevariant_value(VALUE self);
+static VALUE folevariant_vartype(VALUE self);
+static VALUE folevariant_set_value(VALUE self, VALUE val);
+
+static const rb_data_type_t olevariant_datatype = {
+ "win32ole_variant",
+ {NULL, olevariant_free, olevariant_size,},
+ 0, 0, RUBY_TYPED_FREE_IMMEDIATELY
+};
+
+static void
+olevariant_free(void *ptr)
+{
+ struct olevariantdata *pvar = ptr;
+ VariantClear(&(pvar->realvar));
+ VariantClear(&(pvar->var));
+ free(pvar);
+}
+
+static size_t
+olevariant_size(const void *ptr)
+{
+ return ptr ? sizeof(struct olevariantdata) : 0;
+}
+
+static void
+ole_val2olevariantdata(VALUE val, VARTYPE vt, struct olevariantdata *pvar)
+{
+ HRESULT hr = S_OK;
+
+ if (((vt & ~VT_BYREF) == (VT_ARRAY | VT_UI1)) && RB_TYPE_P(val, T_STRING)) {
+ long len = RSTRING_LEN(val);
+ void *pdest = NULL;
+ SAFEARRAY *p = NULL;
+ SAFEARRAY *psa = SafeArrayCreateVector(VT_UI1, 0, len);
+ if (!psa) {
+ rb_raise(rb_eRuntimeError, "fail to SafeArrayCreateVector");
+ }
+ hr = SafeArrayAccessData(psa, &pdest);
+ if (SUCCEEDED(hr)) {
+ memcpy(pdest, RSTRING_PTR(val), len);
+ SafeArrayUnaccessData(psa);
+ V_VT(&(pvar->realvar)) = (vt & ~VT_BYREF);
+ p = V_ARRAY(&(pvar->realvar));
+ if (p != NULL) {
+ SafeArrayDestroy(p);
+ }
+ V_ARRAY(&(pvar->realvar)) = psa;
+ if (vt & VT_BYREF) {
+ V_VT(&(pvar->var)) = vt;
+ V_ARRAYREF(&(pvar->var)) = &(V_ARRAY(&(pvar->realvar)));
+ } else {
+ hr = VariantCopy(&(pvar->var), &(pvar->realvar));
+ }
+ } else {
+ if (psa)
+ SafeArrayDestroy(psa);
+ }
+ } else if (vt & VT_ARRAY) {
+ if (val == Qnil) {
+ V_VT(&(pvar->var)) = vt;
+ if (vt & VT_BYREF) {
+ V_ARRAYREF(&(pvar->var)) = &(V_ARRAY(&(pvar->realvar)));
+ }
+ } else {
+ hr = ole_val_ary2variant_ary(val, &(pvar->realvar), (VARTYPE)(vt & ~VT_BYREF));
+ if (SUCCEEDED(hr)) {
+ if (vt & VT_BYREF) {
+ V_VT(&(pvar->var)) = vt;
+ V_ARRAYREF(&(pvar->var)) = &(V_ARRAY(&(pvar->realvar)));
+ } else {
+ hr = VariantCopy(&(pvar->var), &(pvar->realvar));
+ }
+ }
+ }
+#if (_MSC_VER >= 1300) || defined(__CYGWIN__) || defined(__MINGW32__)
+ } else if ( (vt & ~VT_BYREF) == VT_I8 || (vt & ~VT_BYREF) == VT_UI8) {
+ ole_val2variant_ex(val, &(pvar->realvar), (vt & ~VT_BYREF));
+ ole_val2variant_ex(val, &(pvar->var), (vt & ~VT_BYREF));
+ V_VT(&(pvar->var)) = vt;
+ if (vt & VT_BYREF) {
+ ole_set_byref(&(pvar->realvar), &(pvar->var), vt);
+ }
+#endif
+ } else if ( (vt & ~VT_BYREF) == VT_ERROR) {
+ ole_val2variant_err(val, &(pvar->realvar));
+ if (vt & VT_BYREF) {
+ ole_set_byref(&(pvar->realvar), &(pvar->var), vt);
+ } else {
+ hr = VariantCopy(&(pvar->var), &(pvar->realvar));
+ }
+ } else {
+ if (val == Qnil) {
+ V_VT(&(pvar->var)) = vt;
+ if (vt == (VT_BYREF | VT_VARIANT)) {
+ ole_set_byref(&(pvar->realvar), &(pvar->var), vt);
+ } else {
+ V_VT(&(pvar->realvar)) = vt & ~VT_BYREF;
+ if (vt & VT_BYREF) {
+ ole_set_byref(&(pvar->realvar), &(pvar->var), vt);
+ }
+ }
+ } else {
+ ole_val2variant_ex(val, &(pvar->realvar), (VARTYPE)(vt & ~VT_BYREF));
+ if (vt == (VT_BYREF | VT_VARIANT)) {
+ ole_set_byref(&(pvar->realvar), &(pvar->var), vt);
+ } else if (vt & VT_BYREF) {
+ if ( (vt & ~VT_BYREF) != V_VT(&(pvar->realvar))) {
+ hr = VariantChangeTypeEx(&(pvar->realvar), &(pvar->realvar),
+ cWIN32OLE_lcid, 0, (VARTYPE)(vt & ~VT_BYREF));
+ }
+ if (SUCCEEDED(hr)) {
+ ole_set_byref(&(pvar->realvar), &(pvar->var), vt);
+ }
+ } else {
+ if (vt == V_VT(&(pvar->realvar))) {
+ hr = VariantCopy(&(pvar->var), &(pvar->realvar));
+ } else {
+ hr = VariantChangeTypeEx(&(pvar->var), &(pvar->realvar),
+ cWIN32OLE_lcid, 0, vt);
+ }
+ }
+ }
+ }
+ if (FAILED(hr)) {
+ ole_raise(hr, eWIN32OLERuntimeError, "failed to change type");
+ }
+}
+
+static void
+ole_val2variant_err(VALUE val, VARIANT *var)
+{
+ VALUE v = val;
+ if (rb_obj_is_kind_of(v, cWIN32OLE_VARIANT)) {
+ v = folevariant_value(v);
+ }
+ if (TYPE(v) != T_FIXNUM && TYPE(v) != T_BIGNUM && v != Qnil) {
+ rb_raise(eWIN32OLERuntimeError, "failed to convert VT_ERROR VARIANT:`%"PRIsVALUE"'", rb_inspect(v));
+ }
+ V_VT(var) = VT_ERROR;
+ if (v != Qnil) {
+ V_ERROR(var) = NUM2LONG(val);
+ } else {
+ V_ERROR(var) = 0;
+ }
+}
+
+static void
+ole_set_byref(VARIANT *realvar, VARIANT *var, VARTYPE vt)
+{
+ V_VT(var) = vt;
+ if (vt == (VT_VARIANT|VT_BYREF)) {
+ V_VARIANTREF(var) = realvar;
+ } else {
+ if (V_VT(realvar) != (vt & ~VT_BYREF)) {
+ rb_raise(eWIN32OLERuntimeError, "variant type mismatch");
+ }
+ switch(vt & ~VT_BYREF) {
+ case VT_I1:
+ V_I1REF(var) = &V_I1(realvar);
+ break;
+ case VT_UI1:
+ V_UI1REF(var) = &V_UI1(realvar);
+ break;
+ case VT_I2:
+ V_I2REF(var) = &V_I2(realvar);
+ break;
+ case VT_UI2:
+ V_UI2REF(var) = &V_UI2(realvar);
+ break;
+ case VT_I4:
+ V_I4REF(var) = &V_I4(realvar);
+ break;
+ case VT_UI4:
+ V_UI4REF(var) = &V_UI4(realvar);
+ break;
+ case VT_R4:
+ V_R4REF(var) = &V_R4(realvar);
+ break;
+ case VT_R8:
+ V_R8REF(var) = &V_R8(realvar);
+ break;
+
+#if (_MSC_VER >= 1300) || defined(__CYGWIN__) || defined(__MINGW32__)
+#ifdef V_I8REF
+ case VT_I8:
+ V_I8REF(var) = &V_I8(realvar);
+ break;
+#endif
+#ifdef V_UI8REF
+ case VT_UI8:
+ V_UI8REF(var) = &V_UI8(realvar);
+ break;
+#endif
+#endif
+ case VT_INT:
+ V_INTREF(var) = &V_INT(realvar);
+ break;
+
+ case VT_UINT:
+ V_UINTREF(var) = &V_UINT(realvar);
+ break;
+
+ case VT_CY:
+ V_CYREF(var) = &V_CY(realvar);
+ break;
+ case VT_DATE:
+ V_DATEREF(var) = &V_DATE(realvar);
+ break;
+ case VT_BSTR:
+ V_BSTRREF(var) = &V_BSTR(realvar);
+ break;
+ case VT_DISPATCH:
+ V_DISPATCHREF(var) = &V_DISPATCH(realvar);
+ break;
+ case VT_ERROR:
+ V_ERRORREF(var) = &V_ERROR(realvar);
+ break;
+ case VT_BOOL:
+ V_BOOLREF(var) = &V_BOOL(realvar);
+ break;
+ case VT_UNKNOWN:
+ V_UNKNOWNREF(var) = &V_UNKNOWN(realvar);
+ break;
+ case VT_ARRAY:
+ V_ARRAYREF(var) = &V_ARRAY(realvar);
+ break;
+ default:
+ rb_raise(eWIN32OLERuntimeError, "unknown type specified(setting BYREF):%d", vt);
+ break;
+ }
+ }
+}
+
+static VALUE
+folevariant_s_allocate(VALUE klass)
+{
+ struct olevariantdata *pvar;
+ VALUE obj;
+ ole_initialize();
+ obj = TypedData_Make_Struct(klass, struct olevariantdata, &olevariant_datatype, pvar);
+ VariantInit(&(pvar->var));
+ VariantInit(&(pvar->realvar));
+ return obj;
+}
+
+/*
+ * call-seq:
+ * WIN32OLE_VARIANT.array(ary, vt)
+ *
+ * Returns Ruby object wrapping OLE variant whose variant type is VT_ARRAY.
+ * The first argument should be Array object which specifies dimensions
+ * and each size of dimensions of OLE array.
+ * The second argument specifies variant type of the element of OLE array.
+ *
+ * The following create 2 dimensions OLE array. The first dimensions size
+ * is 3, and the second is 4.
+ *
+ * ole_ary = WIN32OLE_VARIANT.array([3,4], VT_I4)
+ * ruby_ary = ole_ary.value # => [[0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0]]
+ *
+ */
+static VALUE
+folevariant_s_array(VALUE klass, VALUE elems, VALUE vvt)
+{
+ VALUE obj = Qnil;
+ VARTYPE vt;
+ struct olevariantdata *pvar;
+ SAFEARRAYBOUND *psab = NULL;
+ SAFEARRAY *psa = NULL;
+ UINT dim = 0;
+ UINT i = 0;
+
+ ole_initialize();
+
+ vt = NUM2UINT(vvt);
+ vt = (vt | VT_ARRAY);
+ Check_Type(elems, T_ARRAY);
+ obj = folevariant_s_allocate(klass);
+
+ TypedData_Get_Struct(obj, struct olevariantdata, &olevariant_datatype, pvar);
+ dim = RARRAY_LEN(elems);
+
+ psab = ALLOC_N(SAFEARRAYBOUND, dim);
+
+ if(!psab) {
+ rb_raise(rb_eRuntimeError, "memory allocation error");
+ }
+
+ for (i = 0; i < dim; i++) {
+ psab[i].cElements = FIX2INT(rb_ary_entry(elems, i));
+ psab[i].lLbound = 0;
+ }
+
+ psa = SafeArrayCreate((VARTYPE)(vt & VT_TYPEMASK), dim, psab);
+ if (psa == NULL) {
+ if (psab) free(psab);
+ rb_raise(rb_eRuntimeError, "memory allocation error(SafeArrayCreate)");
+ }
+
+ V_VT(&(pvar->var)) = vt;
+ if (vt & VT_BYREF) {
+ V_VT(&(pvar->realvar)) = (vt & ~VT_BYREF);
+ V_ARRAY(&(pvar->realvar)) = psa;
+ V_ARRAYREF(&(pvar->var)) = &(V_ARRAY(&(pvar->realvar)));
+ } else {
+ V_ARRAY(&(pvar->var)) = psa;
+ }
+ if (psab) free(psab);
+ return obj;
+}
+
+static void
+check_type_val2variant(VALUE val)
+{
+ VALUE elem;
+ int len = 0;
+ int i = 0;
+ if(!rb_obj_is_kind_of(val, cWIN32OLE) &&
+ !rb_obj_is_kind_of(val, cWIN32OLE_VARIANT) &&
+ !rb_obj_is_kind_of(val, rb_cTime)) {
+ switch (TYPE(val)) {
+ case T_ARRAY:
+ len = RARRAY_LEN(val);
+ for(i = 0; i < len; i++) {
+ elem = rb_ary_entry(val, i);
+ check_type_val2variant(elem);
+ }
+ break;
+ case T_STRING:
+ case T_FIXNUM:
+ case T_BIGNUM:
+ case T_FLOAT:
+ case T_TRUE:
+ case T_FALSE:
+ case T_NIL:
+ break;
+ default:
+ rb_raise(rb_eTypeError, "can not convert WIN32OLE_VARIANT from type %s",
+ rb_obj_classname(val));
+ }
+ }
+}
+
+/*
+ * Document-class: WIN32OLE_VARIANT
+ *
+ * <code>WIN32OLE_VARIANT</code> objects represents OLE variant.
+ *
+ * Win32OLE converts Ruby object into OLE variant automatically when
+ * invoking OLE methods. If OLE method requires the argument which is
+ * different from the variant by automatic conversion of Win32OLE, you
+ * can convert the specfied variant type by using WIN32OLE_VARIANT class.
+ *
+ * param = WIN32OLE_VARIANT.new(10, WIN32OLE::VARIANT::VT_R4)
+ * oleobj.method(param)
+ *
+ * WIN32OLE_VARIANT does not support VT_RECORD variant. Use WIN32OLE_RECORD
+ * class instead of WIN32OLE_VARIANT if the VT_RECORD variant is needed.
+ */
+
+/*
+ * call-seq:
+ * WIN32OLE_VARIANT.new(val, vartype) #=> WIN32OLE_VARIANT object.
+ *
+ * Returns Ruby object wrapping OLE variant.
+ * The first argument specifies Ruby object to convert OLE variant variable.
+ * The second argument specifies VARIANT type.
+ * In some situation, you need the WIN32OLE_VARIANT object to pass OLE method
+ *
+ * shell = WIN32OLE.new("Shell.Application")
+ * folder = shell.NameSpace("C:\\Windows")
+ * item = folder.ParseName("tmp.txt")
+ * # You can't use Ruby String object to call FolderItem.InvokeVerb.
+ * # Instead, you have to use WIN32OLE_VARIANT object to call the method.
+ * shortcut = WIN32OLE_VARIANT.new("Create Shortcut(\&S)")
+ * item.invokeVerb(shortcut)
+ *
+ */
+static VALUE
+folevariant_initialize(VALUE self, VALUE args)
+{
+ int len = 0;
+ VARIANT var;
+ VALUE val;
+ VALUE vvt;
+ VARTYPE vt;
+ struct olevariantdata *pvar;
+
+ len = RARRAY_LEN(args);
+ if (len < 1 || len > 3) {
+ rb_raise(rb_eArgError, "wrong number of arguments (%d for 1..3)", len);
+ }
+ VariantInit(&var);
+ val = rb_ary_entry(args, 0);
+
+ check_type_val2variant(val);
+
+ TypedData_Get_Struct(self, struct olevariantdata, &olevariant_datatype, pvar);
+ if (len == 1) {
+ ole_val2variant(val, &(pvar->var));
+ } else {
+ vvt = rb_ary_entry(args, 1);
+ vt = NUM2INT(vvt);
+ if ((vt & VT_TYPEMASK) == VT_RECORD) {
+ rb_raise(rb_eArgError, "not supported VT_RECORD WIN32OLE_VARIANT object");
+ }
+ ole_val2olevariantdata(val, vt, pvar);
+ }
+ return self;
+}
+
+static SAFEARRAY *
+get_locked_safe_array(VALUE val)
+{
+ struct olevariantdata *pvar;
+ SAFEARRAY *psa = NULL;
+ HRESULT hr;
+ TypedData_Get_Struct(val, struct olevariantdata, &olevariant_datatype, pvar);
+ if (!(V_VT(&(pvar->var)) & VT_ARRAY)) {
+ rb_raise(rb_eTypeError, "variant type is not VT_ARRAY.");
+ }
+ psa = V_ISBYREF(&(pvar->var)) ? *V_ARRAYREF(&(pvar->var)) : V_ARRAY(&(pvar->var));
+ if (psa == NULL) {
+ return psa;
+ }
+ hr = SafeArrayLock(psa);
+ if (FAILED(hr)) {
+ ole_raise(hr, rb_eRuntimeError, "failed to SafeArrayLock");
+ }
+ return psa;
+}
+
+static LONG *
+ary2safe_array_index(int ary_size, VALUE *ary, SAFEARRAY *psa)
+{
+ long dim;
+ LONG *pid;
+ long i;
+ dim = SafeArrayGetDim(psa);
+ if (dim != ary_size) {
+ rb_raise(rb_eArgError, "unmatch number of indices");
+ }
+ pid = ALLOC_N(LONG, dim);
+ if (pid == NULL) {
+ rb_raise(rb_eRuntimeError, "failed to allocate memory for indices");
+ }
+ for (i = 0; i < dim; i++) {
+ pid[i] = NUM2INT(ary[i]);
+ }
+ return pid;
+}
+
+static void
+unlock_safe_array(SAFEARRAY *psa)
+{
+ HRESULT hr;
+ hr = SafeArrayUnlock(psa);
+ if (FAILED(hr)) {
+ ole_raise(hr, rb_eRuntimeError, "failed to SafeArrayUnlock");
+ }
+}
+
+/*
+ * call-seq:
+ * WIN32OLE_VARIANT[i,j,...] #=> element of OLE array.
+ *
+ * Returns the element of WIN32OLE_VARIANT object(OLE array).
+ * This method is available only when the variant type of
+ * WIN32OLE_VARIANT object is VT_ARRAY.
+ *
+ * REMARK:
+ * The all indicies should be 0 or natural number and
+ * lower than or equal to max indicies.
+ * (This point is different with Ruby Array indicies.)
+ *
+ * obj = WIN32OLE_VARIANT.new([[1,2,3],[4,5,6]])
+ * p obj[0,0] # => 1
+ * p obj[1,0] # => 4
+ * p obj[2,0] # => WIN32OLERuntimeError
+ * p obj[0, -1] # => WIN32OLERuntimeError
+ *
+ */
+static VALUE
+folevariant_ary_aref(int argc, VALUE *argv, VALUE self)
+{
+ struct olevariantdata *pvar;
+ SAFEARRAY *psa;
+ VALUE val = Qnil;
+ VARIANT variant;
+ LONG *pid;
+ HRESULT hr;
+
+ TypedData_Get_Struct(self, struct olevariantdata, &olevariant_datatype, pvar);
+ if (!V_ISARRAY(&(pvar->var))) {
+ rb_raise(eWIN32OLERuntimeError,
+ "`[]' is not available for this variant type object");
+ }
+ psa = get_locked_safe_array(self);
+ if (psa == NULL) {
+ return val;
+ }
+
+ pid = ary2safe_array_index(argc, argv, psa);
+
+ VariantInit(&variant);
+ V_VT(&variant) = (V_VT(&(pvar->var)) & ~VT_ARRAY) | VT_BYREF;
+ hr = SafeArrayPtrOfIndex(psa, pid, &V_BYREF(&variant));
+ if (FAILED(hr)) {
+ ole_raise(hr, eWIN32OLERuntimeError, "failed to SafeArrayPtrOfIndex");
+ }
+ val = ole_variant2val(&variant);
+
+ unlock_safe_array(psa);
+ if (pid) free(pid);
+ return val;
+}
+
+/*
+ * call-seq:
+ * WIN32OLE_VARIANT[i,j,...] = val #=> set the element of OLE array
+ *
+ * Set the element of WIN32OLE_VARIANT object(OLE array) to val.
+ * This method is available only when the variant type of
+ * WIN32OLE_VARIANT object is VT_ARRAY.
+ *
+ * REMARK:
+ * The all indicies should be 0 or natural number and
+ * lower than or equal to max indicies.
+ * (This point is different with Ruby Array indicies.)
+ *
+ * obj = WIN32OLE_VARIANT.new([[1,2,3],[4,5,6]])
+ * obj[0,0] = 7
+ * obj[1,0] = 8
+ * p obj.value # => [[7,2,3], [8,5,6]]
+ * obj[2,0] = 9 # => WIN32OLERuntimeError
+ * obj[0, -1] = 9 # => WIN32OLERuntimeError
+ *
+ */
+static VALUE
+folevariant_ary_aset(int argc, VALUE *argv, VALUE self)
+{
+ struct olevariantdata *pvar;
+ SAFEARRAY *psa;
+ VARIANT var;
+ VARTYPE vt;
+ LONG *pid;
+ HRESULT hr;
+ VOID *p = NULL;
+
+ TypedData_Get_Struct(self, struct olevariantdata, &olevariant_datatype, pvar);
+ if (!V_ISARRAY(&(pvar->var))) {
+ rb_raise(eWIN32OLERuntimeError,
+ "`[]' is not available for this variant type object");
+ }
+ psa = get_locked_safe_array(self);
+ if (psa == NULL) {
+ rb_raise(rb_eRuntimeError, "failed to get SafeArray pointer");
+ }
+
+ pid = ary2safe_array_index(argc-1, argv, psa);
+
+ VariantInit(&var);
+ vt = (V_VT(&(pvar->var)) & ~VT_ARRAY);
+ p = val2variant_ptr(argv[argc-1], &var, vt);
+ if ((V_VT(&var) == VT_DISPATCH && V_DISPATCH(&var) == NULL) ||
+ (V_VT(&var) == VT_UNKNOWN && V_UNKNOWN(&var) == NULL)) {
+ rb_raise(eWIN32OLERuntimeError, "argument does not have IDispatch or IUnknown Interface");
+ }
+ hr = SafeArrayPutElement(psa, pid, p);
+ if (FAILED(hr)) {
+ ole_raise(hr, eWIN32OLERuntimeError, "failed to SafeArrayPutElement");
+ }
+
+ unlock_safe_array(psa);
+ if (pid) free(pid);
+ return argv[argc-1];
+}
+
+/*
+ * call-seq:
+ * WIN32OLE_VARIANT.value #=> Ruby object.
+ *
+ * Returns Ruby object value from OLE variant.
+ * obj = WIN32OLE_VARIANT.new(1, WIN32OLE::VARIANT::VT_BSTR)
+ * obj.value # => "1" (not Fixnum object, but String object "1")
+ *
+ */
+static VALUE
+folevariant_value(VALUE self)
+{
+ struct olevariantdata *pvar;
+ VALUE val = Qnil;
+ VARTYPE vt;
+ int dim;
+ SAFEARRAY *psa;
+ TypedData_Get_Struct(self, struct olevariantdata, &olevariant_datatype, pvar);
+
+ val = ole_variant2val(&(pvar->var));
+ vt = V_VT(&(pvar->var));
+
+ if ((vt & ~VT_BYREF) == (VT_UI1|VT_ARRAY)) {
+ if (vt & VT_BYREF) {
+ psa = *V_ARRAYREF(&(pvar->var));
+ } else {
+ psa = V_ARRAY(&(pvar->var));
+ }
+ if (!psa) {
+ return val;
+ }
+ dim = SafeArrayGetDim(psa);
+ if (dim == 1) {
+ val = rb_funcall(val, rb_intern("pack"), 1, rb_str_new2("C*"));
+ }
+ }
+ return val;
+}
+
+/*
+ * call-seq:
+ * WIN32OLE_VARIANT.vartype #=> OLE variant type.
+ *
+ * Returns OLE variant type.
+ * obj = WIN32OLE_VARIANT.new("string")
+ * obj.vartype # => WIN32OLE::VARIANT::VT_BSTR
+ *
+ */
+static VALUE
+folevariant_vartype(VALUE self)
+{
+ struct olevariantdata *pvar;
+ TypedData_Get_Struct(self, struct olevariantdata, &olevariant_datatype, pvar);
+ return INT2FIX(V_VT(&pvar->var));
+}
+
+/*
+ * call-seq:
+ * WIN32OLE_VARIANT.value = val #=> set WIN32OLE_VARIANT value to val.
+ *
+ * Sets variant value to val. If the val type does not match variant value
+ * type(vartype), then val is changed to match variant value type(vartype)
+ * before setting val.
+ * Thie method is not available when vartype is VT_ARRAY(except VT_UI1|VT_ARRAY).
+ * If the vartype is VT_UI1|VT_ARRAY, the val should be String object.
+ *
+ * obj = WIN32OLE_VARIANT.new(1) # obj.vartype is WIN32OLE::VARIANT::VT_I4
+ * obj.value = 3.2 # 3.2 is changed to 3 when setting value.
+ * p obj.value # => 3
+ */
+static VALUE
+folevariant_set_value(VALUE self, VALUE val)
+{
+ struct olevariantdata *pvar;
+ VARTYPE vt;
+ TypedData_Get_Struct(self, struct olevariantdata, &olevariant_datatype, pvar);
+ vt = V_VT(&(pvar->var));
+ if (V_ISARRAY(&(pvar->var)) && ((vt & ~VT_BYREF) != (VT_UI1|VT_ARRAY) || !RB_TYPE_P(val, T_STRING))) {
+ rb_raise(eWIN32OLERuntimeError,
+ "`value=' is not available for this variant type object");
+ }
+ ole_val2olevariantdata(val, vt, pvar);
+ return Qnil;
+}
+
+void
+ole_variant2variant(VALUE val, VARIANT *var)
+{
+ struct olevariantdata *pvar;
+ TypedData_Get_Struct(val, struct olevariantdata, &olevariant_datatype, pvar);
+ VariantCopy(var, &(pvar->var));
+}
+
+void
+Init_win32ole_variant(void)
+{
+ cWIN32OLE_VARIANT = rb_define_class("WIN32OLE_VARIANT", rb_cObject);
+ rb_define_alloc_func(cWIN32OLE_VARIANT, folevariant_s_allocate);
+ rb_define_singleton_method(cWIN32OLE_VARIANT, "array", folevariant_s_array, 2);
+ rb_define_method(cWIN32OLE_VARIANT, "initialize", folevariant_initialize, -2);
+ rb_define_method(cWIN32OLE_VARIANT, "value", folevariant_value, 0);
+ rb_define_method(cWIN32OLE_VARIANT, "value=", folevariant_set_value, 1);
+ rb_define_method(cWIN32OLE_VARIANT, "vartype", folevariant_vartype, 0);
+ rb_define_method(cWIN32OLE_VARIANT, "[]", folevariant_ary_aref, -1);
+ rb_define_method(cWIN32OLE_VARIANT, "[]=", folevariant_ary_aset, -1);
+
+ /*
+ * represents VT_EMPTY OLE object.
+ */
+ rb_define_const(cWIN32OLE_VARIANT, "Empty",
+ rb_funcall(cWIN32OLE_VARIANT, rb_intern("new"), 2, Qnil, INT2FIX(VT_EMPTY)));
+
+ /*
+ * represents VT_NULL OLE object.
+ */
+ rb_define_const(cWIN32OLE_VARIANT, "Null",
+ rb_funcall(cWIN32OLE_VARIANT, rb_intern("new"), 2, Qnil, INT2FIX(VT_NULL)));
+
+ /*
+ * represents Nothing of VB.NET or VB.
+ */
+ rb_define_const(cWIN32OLE_VARIANT, "Nothing",
+ rb_funcall(cWIN32OLE_VARIANT, rb_intern("new"), 2, Qnil, INT2FIX(VT_DISPATCH)));
+
+ /*
+ * represents VT_ERROR variant with DISP_E_PARAMNOTFOUND.
+ * This constants is used for not specified parameter.
+ *
+ * fso = WIN32OLE.new("Scripting.FileSystemObject")
+ * fso.openTextFile(filename, WIN32OLE_VARIANT::NoParam, false)
+ */
+ rb_define_const(cWIN32OLE_VARIANT, "NoParam",
+ rb_funcall(cWIN32OLE_VARIANT, rb_intern("new"), 2, INT2NUM(DISP_E_PARAMNOTFOUND), INT2FIX(VT_ERROR)));
+}
diff --git a/jni/ruby/ext/win32ole/win32ole_variant.h b/jni/ruby/ext/win32ole/win32ole_variant.h
new file mode 100644
index 0000000..efe7ea8
--- /dev/null
+++ b/jni/ruby/ext/win32ole/win32ole_variant.h
@@ -0,0 +1,9 @@
+#ifndef WIN32OLE_VARIANT_H
+#define WIN32OLE_VARIANT_H 1
+
+VALUE cWIN32OLE_VARIANT;
+void ole_variant2variant(VALUE val, VARIANT *var);
+void Init_win32ole_variant(void);
+
+#endif
+
diff --git a/jni/ruby/ext/win32ole/win32ole_variant_m.c b/jni/ruby/ext/win32ole/win32ole_variant_m.c
new file mode 100644
index 0000000..eb3b0b1
--- /dev/null
+++ b/jni/ruby/ext/win32ole/win32ole_variant_m.c
@@ -0,0 +1,149 @@
+#include "win32ole.h"
+
+void Init_win32ole_variant_m(void)
+{
+ /*
+ * Document-module: WIN32OLE::VARIANT
+ *
+ * The WIN32OLE::VARIANT module includes constants of VARIANT type constants.
+ * The constants is used when creating WIN32OLE_VARIANT object.
+ *
+ * obj = WIN32OLE_VARIANT.new("2e3", WIN32OLE::VARIANT::VT_R4)
+ * obj.value # => 2000.0
+ *
+ */
+ mWIN32OLE_VARIANT = rb_define_module_under(cWIN32OLE, "VARIANT");
+
+ /*
+ * represents VT_EMPTY type constant.
+ */
+ rb_define_const(mWIN32OLE_VARIANT, "VT_EMPTY", INT2FIX(VT_EMPTY));
+
+ /*
+ * represents VT_NULL type constant.
+ */
+ rb_define_const(mWIN32OLE_VARIANT, "VT_NULL", INT2FIX(VT_NULL));
+
+ /*
+ * represents VT_I2 type constant.
+ */
+ rb_define_const(mWIN32OLE_VARIANT, "VT_I2", INT2FIX(VT_I2));
+
+ /*
+ * represents VT_I4 type constant.
+ */
+ rb_define_const(mWIN32OLE_VARIANT, "VT_I4", INT2FIX(VT_I4));
+
+ /*
+ * represents VT_R4 type constant.
+ */
+ rb_define_const(mWIN32OLE_VARIANT, "VT_R4", INT2FIX(VT_R4));
+
+ /*
+ * represents VT_R8 type constant.
+ */
+ rb_define_const(mWIN32OLE_VARIANT, "VT_R8", INT2FIX(VT_R8));
+
+ /*
+ * represents VT_CY type constant.
+ */
+ rb_define_const(mWIN32OLE_VARIANT, "VT_CY", INT2FIX(VT_CY));
+
+ /*
+ * represents VT_DATE type constant.
+ */
+ rb_define_const(mWIN32OLE_VARIANT, "VT_DATE", INT2FIX(VT_DATE));
+
+ /*
+ * represents VT_BSTR type constant.
+ */
+ rb_define_const(mWIN32OLE_VARIANT, "VT_BSTR", INT2FIX(VT_BSTR));
+
+ /*
+ * represents VT_USERDEFINED type constant.
+ */
+ rb_define_const(mWIN32OLE_VARIANT, "VT_USERDEFINED", INT2FIX(VT_USERDEFINED));
+
+ /*
+ * represents VT_PTR type constant.
+ */
+ rb_define_const(mWIN32OLE_VARIANT, "VT_PTR", INT2FIX(VT_PTR));
+
+ /*
+ * represents VT_DISPATCH type constant.
+ */
+ rb_define_const(mWIN32OLE_VARIANT, "VT_DISPATCH", INT2FIX(VT_DISPATCH));
+
+ /*
+ * represents VT_ERROR type constant.
+ */
+ rb_define_const(mWIN32OLE_VARIANT, "VT_ERROR", INT2FIX(VT_ERROR));
+
+ /*
+ * represents VT_BOOL type constant.
+ */
+ rb_define_const(mWIN32OLE_VARIANT, "VT_BOOL", INT2FIX(VT_BOOL));
+
+ /*
+ * represents VT_VARIANT type constant.
+ */
+ rb_define_const(mWIN32OLE_VARIANT, "VT_VARIANT", INT2FIX(VT_VARIANT));
+
+ /*
+ * represents VT_UNKNOWN type constant.
+ */
+ rb_define_const(mWIN32OLE_VARIANT, "VT_UNKNOWN", INT2FIX(VT_UNKNOWN));
+
+ /*
+ * represents VT_I1 type constant.
+ */
+ rb_define_const(mWIN32OLE_VARIANT, "VT_I1", INT2FIX(VT_I1));
+
+ /*
+ * represents VT_UI1 type constant.
+ */
+ rb_define_const(mWIN32OLE_VARIANT, "VT_UI1", INT2FIX(VT_UI1));
+
+ /*
+ * represents VT_UI2 type constant.
+ */
+ rb_define_const(mWIN32OLE_VARIANT, "VT_UI2", INT2FIX(VT_UI2));
+
+ /*
+ * represents VT_UI4 type constant.
+ */
+ rb_define_const(mWIN32OLE_VARIANT, "VT_UI4", INT2FIX(VT_UI4));
+
+#if (_MSC_VER >= 1300) || defined(__CYGWIN__) || defined(__MINGW32__)
+ /*
+ * represents VT_I8 type constant.
+ */
+ rb_define_const(mWIN32OLE_VARIANT, "VT_I8", INT2FIX(VT_I8));
+
+ /*
+ * represents VT_UI8 type constant.
+ */
+ rb_define_const(mWIN32OLE_VARIANT, "VT_UI8", INT2FIX(VT_UI8));
+#endif
+
+ /*
+ * represents VT_INT type constant.
+ */
+ rb_define_const(mWIN32OLE_VARIANT, "VT_INT", INT2FIX(VT_INT));
+
+ /*
+ * represents VT_UINT type constant.
+ */
+ rb_define_const(mWIN32OLE_VARIANT, "VT_UINT", INT2FIX(VT_UINT));
+
+ /*
+ * represents VT_ARRAY type constant.
+ */
+ rb_define_const(mWIN32OLE_VARIANT, "VT_ARRAY", INT2FIX(VT_ARRAY));
+
+ /*
+ * represents VT_BYREF type constant.
+ */
+ rb_define_const(mWIN32OLE_VARIANT, "VT_BYREF", INT2FIX(VT_BYREF));
+
+}
diff --git a/jni/ruby/ext/win32ole/win32ole_variant_m.h b/jni/ruby/ext/win32ole/win32ole_variant_m.h
new file mode 100644
index 0000000..afbef30
--- /dev/null
+++ b/jni/ruby/ext/win32ole/win32ole_variant_m.h
@@ -0,0 +1,7 @@
+#ifndef WIN32OLE_VARIANT_M_H
+#define WIN32OLE_VARIANT_M_H 1
+
+VALUE mWIN32OLE_VARIANT;
+void Init_win32ole_variant_m(void);
+
+#endif
diff --git a/jni/ruby/ext/zlib/Makefile b/jni/ruby/ext/zlib/Makefile
new file mode 100644
index 0000000..3139cc6
--- /dev/null
+++ b/jni/ruby/ext/zlib/Makefile
@@ -0,0 +1,274 @@
+
+SHELL = /bin/sh
+
+# V=0 quiet, V=1 verbose. other values don't work.
+V = 0
+Q1 = $(V:1=)
+Q = $(Q1:0=@)
+ECHO1 = $(V:1=@:)
+ECHO = $(ECHO1:0=@echo)
+NULLCMD = :
+
+#### Start of system configuration section. ####
+top_srcdir = $(topdir)/.
+srcdir = $(top_srcdir)/ext/zlib
+topdir = ../..
+hdrdir = $(top_srcdir)/include
+arch_hdrdir = $(extout)/include/$(arch)
+PATH_SEPARATOR = :
+VPATH = $(srcdir):$(arch_hdrdir)/ruby:$(hdrdir)/ruby
+RUBYLIB =
+RUBYOPT = -
+prefix = $(DESTDIR)/usr/local
+rubysitearchprefix = $(rubylibprefix)/$(sitearch)
+rubyarchprefix = $(rubylibprefix)/$(arch)
+rubylibprefix = $(libdir)/$(RUBY_BASE_NAME)
+exec_prefix = $(prefix)
+vendorarchhdrdir = $(vendorhdrdir)/$(sitearch)
+sitearchhdrdir = $(sitehdrdir)/$(sitearch)
+rubyarchhdrdir = $(rubyhdrdir)/$(arch)
+vendorhdrdir = $(rubyhdrdir)/vendor_ruby
+sitehdrdir = $(rubyhdrdir)/site_ruby
+rubyhdrdir = $(includedir)/$(RUBY_VERSION_NAME)
+vendorarchdir = $(vendorlibdir)/$(sitearch)
+vendorlibdir = $(vendordir)/$(ruby_version)
+vendordir = $(rubylibprefix)/vendor_ruby
+sitearchdir = $(sitelibdir)/$(sitearch)
+sitelibdir = $(sitedir)/$(ruby_version)
+sitedir = $(rubylibprefix)/site_ruby
+rubyarchdir = $(rubylibdir)/$(arch)
+rubylibdir = $(rubylibprefix)/$(ruby_version)
+sitearchincludedir = $(includedir)/$(sitearch)
+archincludedir = $(includedir)/$(arch)
+sitearchlibdir = $(libdir)/$(sitearch)
+archlibdir = $(libdir)/$(arch)
+ridir = $(datarootdir)/$(RI_BASE_NAME)
+mandir = $(datarootdir)/man
+localedir = $(datarootdir)/locale
+libdir = $(exec_prefix)/lib
+psdir = $(docdir)
+pdfdir = $(docdir)
+dvidir = $(docdir)
+htmldir = $(docdir)
+infodir = $(datarootdir)/info
+docdir = $(datarootdir)/doc/$(PACKAGE)
+oldincludedir = $(DESTDIR)/usr/include
+includedir = $(prefix)/include
+localstatedir = $(prefix)/var
+sharedstatedir = $(prefix)/com
+sysconfdir = $(prefix)/etc
+datadir = $(datarootdir)
+datarootdir = $(prefix)/share
+libexecdir = $(exec_prefix)/libexec
+sbindir = $(exec_prefix)/sbin
+bindir = $(exec_prefix)/bin
+archdir = $(rubyarchdir)
+
+
+CC = gcc
+CXX = g++
+LIBRUBY = $(LIBRUBY_SO)
+LIBRUBY_A = lib$(RUBY_SO_NAME)-static.a
+LIBRUBYARG_SHARED = -Wl,-R$(libdir) -L$(libdir) -l$(RUBY_SO_NAME)
+LIBRUBYARG_STATIC = -Wl,-R$(libdir) -L$(libdir) -l$(RUBY_SO_NAME)-static
+empty =
+OUTFLAG = -o $(empty)
+COUTFLAG = -o $(empty)
+
+RUBY_EXTCONF_H = extconf.h
+cflags = $(optflags) $(debugflags) $(warnflags)
+optflags = -O3 -fno-fast-math
+debugflags = -ggdb3
+warnflags = -Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wunused-variable -Wpointer-arith -Wwrite-strings -Wdeclaration-after-statement -Wimplicit-function-declaration -Wdeprecated-declarations -Wno-packed-bitfield-compat
+CCDLFLAGS = -fPIC
+CFLAGS = $(CCDLFLAGS) $(cflags) -fPIC $(ARCH_FLAG)
+INCFLAGS = -I. -I$(arch_hdrdir) -I$(hdrdir) -I$(srcdir)
+DEFS =
+CPPFLAGS = -DRUBY_EXTCONF_H=\"$(RUBY_EXTCONF_H)\" $(DEFS) $(cppflags)
+CXXFLAGS = $(CCDLFLAGS) $(cxxflags) $(ARCH_FLAG)
+ldflags = -L. -fstack-protector -rdynamic -Wl,-export-dynamic
+dldflags =
+ARCH_FLAG =
+DLDFLAGS = $(ldflags) $(dldflags) $(ARCH_FLAG)
+LDSHARED = $(CC) -shared
+LDSHAREDXX = $(CXX) -shared
+AR = ar
+EXEEXT =
+
+RUBY_INSTALL_NAME = $(RUBY_BASE_NAME)
+RUBY_SO_NAME = ruby
+RUBYW_INSTALL_NAME =
+RUBY_VERSION_NAME = $(RUBY_BASE_NAME)-$(ruby_version)
+RUBYW_BASE_NAME = rubyw
+RUBY_BASE_NAME = ruby
+
+arch = x86_64-linux
+sitearch = $(arch)
+ruby_version = 2.2.0
+ruby = $(topdir)/miniruby -I'$(topdir)' -I'$(top_srcdir)/lib' -I'$(extout)/$(arch)' -I'$(extout)/common'
+RUBY = $(ruby)
+ruby_headers = $(hdrdir)/ruby.h $(hdrdir)/ruby/ruby.h $(hdrdir)/ruby/defines.h $(hdrdir)/ruby/missing.h $(hdrdir)/ruby/intern.h $(hdrdir)/ruby/st.h $(hdrdir)/ruby/subst.h $(arch_hdrdir)/ruby/config.h $(RUBY_EXTCONF_H)
+
+RM = rm -f
+RM_RF = $(RUBY) -run -e rm -- -rf
+RMDIRS = rmdir --ignore-fail-on-non-empty -p
+MAKEDIRS = /bin/mkdir -p
+INSTALL = /usr/bin/install -c
+INSTALL_PROG = $(INSTALL) -m 0755
+INSTALL_DATA = $(INSTALL) -m 644
+COPY = cp
+TOUCH = exit >
+
+#### End of system configuration section. ####
+
+preload =
+
+libpath = . $(topdir)
+LIBPATH = -L. -L$(topdir)
+DEFFILE =
+
+CLEANFILES = mkmf.log
+DISTCLEANFILES =
+DISTCLEANDIRS =
+
+extout = $(topdir)/.ext
+extout_prefix = $(extout)$(target_prefix)/
+target_prefix =
+LOCAL_LIBS =
+LIBS = $(LIBRUBYARG_SHARED) -lz -lpthread -lgmp -ldl -lcrypt -lm -lc
+ORIG_SRCS = zlib.c
+SRCS = $(ORIG_SRCS)
+OBJS = zlib.o
+HDRS = $(srcdir)/extconf.h
+TARGET = zlib
+TARGET_NAME = zlib
+TARGET_ENTRY = Init_$(TARGET_NAME)
+DLLIB = $(TARGET).so
+EXTSTATIC =
+STATIC_LIB = $(TARGET).a
+
+TIMESTAMP_DIR = $(extout)/.timestamp
+BINDIR = $(extout)/bin
+RUBYCOMMONDIR = $(extout)/common
+RUBYLIBDIR = $(RUBYCOMMONDIR)$(target_prefix)
+RUBYARCHDIR = $(extout)/$(arch)$(target_prefix)
+HDRDIR = $(extout)/include/ruby$(target_prefix)
+ARCHHDRDIR = $(extout)/include/$(arch)/ruby$(target_prefix)
+
+TARGET_SO = $(RUBYARCHDIR)/$(DLLIB)
+CLEANLIBS = $(RUBYARCHDIR)/$(TARGET).so
+CLEANOBJS = *.o *.bak
+
+all: install
+static: all
+.PHONY: all install static install-so install-rb
+.PHONY: clean clean-so clean-static clean-rb
+
+clean-static::
+clean-rb-default::
+clean-rb::
+clean-so::
+clean: clean-so clean-static clean-rb-default clean-rb
+ -$(Q)$(RM) $(CLEANLIBS) $(CLEANOBJS) $(CLEANFILES) .*.time
+
+distclean-rb-default::
+distclean-rb::
+distclean-so::
+distclean-static::
+distclean: clean distclean-so distclean-static distclean-rb-default distclean-rb
+ -$(Q)$(RM) Makefile $(RUBY_EXTCONF_H) conftest.* mkmf.log
+ -$(Q)$(RM) core ruby$(EXEEXT) *~ $(DISTCLEANFILES)
+ -$(Q)$(RMDIRS) $(DISTCLEANDIRS) 2> /dev/null || true
+
+realclean: distclean
+install: install-so install-rb
+
+install-so: $(RUBYARCHDIR)/$(DLLIB)
+clean-so::
+ -$(Q)$(RM) $(RUBYARCHDIR)/$(DLLIB)
+ -$(Q)$(RMDIRS) $(RUBYARCHDIR) 2> /dev/null || true
+clean-static::
+ -$(Q)$(RM) $(STATIC_LIB)
+install-rb: pre-install-rb install-rb-default
+install-rb-default: pre-install-rb-default
+pre-install-rb: Makefile
+pre-install-rb-default: Makefile
+pre-install-rb-default:
+ @$(NULLCMD)
+$(TIMESTAMP_DIR)/.RUBYARCHDIR.time:
+ $(Q) $(MAKEDIRS) $(@D) $(RUBYARCHDIR)
+ $(Q) $(TOUCH) $@
+
+site-install: site-install-so site-install-rb
+site-install-so: install-so
+site-install-rb: install-rb
+
+.SUFFIXES: .c .m .cc .mm .cxx .cpp .o .S
+
+.cc.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<
+
+.cc.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -S $<
+
+.mm.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<
+
+.mm.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -S $<
+
+.cxx.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<
+
+.cxx.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -S $<
+
+.cpp.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<
+
+.cpp.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -S $<
+
+.c.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -c $<
+
+.c.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -S $<
+
+.m.o:
+ $(ECHO) compiling $(<)
+ $(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -c $<
+
+.m.S:
+ $(ECHO) translating $(<)
+ $(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -S $<
+
+$(RUBYARCHDIR)/$(DLLIB): $(OBJS) Makefile $(TIMESTAMP_DIR)/.RUBYARCHDIR.time
+ $(ECHO) linking shared-object $(DLLIB)
+ -$(Q)$(RM) $(@)
+ $(Q) $(LDSHARED) -o $@ $(OBJS) $(LIBPATH) $(DLDFLAGS) $(LOCAL_LIBS) $(LIBS)
+
+$(STATIC_LIB): $(OBJS)
+ -$(Q)$(RM) $(@)
+ $(ECHO) linking static-library $(@)
+ $(Q) $(AR) cru $@ $(OBJS)
+ -$(Q)ranlib $(@) 2> /dev/null || true
+
+###
+$(OBJS): $(RUBY_EXTCONF_H)
+
+$(OBJS): $(HDRS) $(ruby_headers) \
+ $(hdrdir)/ruby/io.h \
+ $(hdrdir)/ruby/encoding.h \
+ $(hdrdir)/ruby/oniguruma.h \
+ $(hdrdir)/ruby/thread.h
diff --git a/jni/ruby/ext/zlib/depend b/jni/ruby/ext/zlib/depend
new file mode 100644
index 0000000..9d47df2
--- /dev/null
+++ b/jni/ruby/ext/zlib/depend
@@ -0,0 +1,5 @@
+$(OBJS): $(HDRS) $(ruby_headers) \
+ $(hdrdir)/ruby/io.h \
+ $(hdrdir)/ruby/encoding.h \
+ $(hdrdir)/ruby/oniguruma.h \
+ $(hdrdir)/ruby/thread.h
diff --git a/jni/ruby/ext/zlib/extconf.h b/jni/ruby/ext/zlib/extconf.h
new file mode 100644
index 0000000..815f4f7
--- /dev/null
+++ b/jni/ruby/ext/zlib/extconf.h
@@ -0,0 +1,7 @@
+#ifndef EXTCONF_H
+#define EXTCONF_H
+#define HAVE_ZLIB_H 1
+#define HAVE_CRC32_COMBINE 1
+#define HAVE_ADLER32_COMBINE 1
+#define HAVE_TYPE_Z_CRC_T 1
+#endif
diff --git a/jni/ruby/ext/zlib/extconf.rb b/jni/ruby/ext/zlib/extconf.rb
new file mode 100644
index 0000000..d3a332b
--- /dev/null
+++ b/jni/ruby/ext/zlib/extconf.rb
@@ -0,0 +1,64 @@
+#
+# extconf.rb
+#
+# $Id: extconf.rb 37527 2012-11-06 18:50:53Z luislavena $
+#
+
+require 'mkmf'
+require 'rbconfig'
+
+dir_config 'zlib'
+
+
+if %w'z libz zlib1 zlib zdll zlibwapi'.find {|z| have_library(z, 'deflateReset')} and
+ have_header('zlib.h') then
+
+ defines = []
+
+ Logging::message 'checking for kind of operating system... '
+ os_code = with_config('os-code') ||
+ case RUBY_PLATFORM.split('-',2)[1]
+ when 'amigaos' then
+ os_code = 'AMIGA'
+ when /\Aos2[\-_]emx\z/ then
+ os_code = 'OS2'
+ when /mswin|mingw|bccwin/ then
+ # NOTE: cygwin should be regarded as Unix.
+ os_code = 'WIN32'
+ else
+ os_code = 'UNIX'
+ end
+ os_code = 'OS_' + os_code.upcase
+
+ OS_NAMES = {
+ 'OS_MSDOS' => 'MS-DOS',
+ 'OS_AMIGA' => 'Amiga',
+ 'OS_VMS' => 'VMS',
+ 'OS_UNIX' => 'Unix',
+ 'OS_ATARI' => 'Atari',
+ 'OS_OS2' => 'OS/2',
+ 'OS_MACOS' => 'MacOS',
+ 'OS_TOPS20' => 'TOPS20',
+ 'OS_WIN32' => 'Win32',
+ 'OS_VMCMS' => 'VM/CMS',
+ 'OS_ZSYSTEM' => 'Z-System',
+ 'OS_CPM' => 'CP/M',
+ 'OS_QDOS' => 'QDOS',
+ 'OS_RISCOS' => 'RISCOS',
+ 'OS_UNKNOWN' => 'Unknown',
+ }
+ unless OS_NAMES.key? os_code then
+ raise "invalid OS_CODE `#{os_code}'"
+ end
+ Logging::message "#{OS_NAMES[os_code]}\n"
+ defines << "OS_CODE=#{os_code}"
+
+ $defs.concat(defines.collect{|d|' -D'+d})
+
+ have_func('crc32_combine', 'zlib.h')
+ have_func('adler32_combine', 'zlib.h')
+ have_type('z_crc_t', 'zlib.h')
+
+ create_makefile('zlib')
+
+end
diff --git a/jni/ruby/ext/zlib/zlib.c b/jni/ruby/ext/zlib/zlib.c
new file mode 100644
index 0000000..84f3cd3
--- /dev/null
+++ b/jni/ruby/ext/zlib/zlib.c
@@ -0,0 +1,4659 @@
+/*
+ * zlib.c - An interface for zlib.
+ *
+ * Copyright (C) UENO Katsuhiro 2000-2003
+ *
+ * $Id: zlib.c 51075 2015-06-30 19:15:53Z nagachika $
+ */
+
+#include <ruby.h>
+#include <zlib.h>
+#include <time.h>
+#include <ruby/io.h>
+#include <ruby/thread.h>
+
+#ifdef HAVE_VALGRIND_MEMCHECK_H
+# include <valgrind/memcheck.h>
+# ifndef VALGRIND_MAKE_MEM_DEFINED
+# define VALGRIND_MAKE_MEM_DEFINED(p, n) VALGRIND_MAKE_READABLE((p), (n))
+# endif
+# ifndef VALGRIND_MAKE_MEM_UNDEFINED
+# define VALGRIND_MAKE_MEM_UNDEFINED(p, n) VALGRIND_MAKE_WRITABLE((p), (n))
+# endif
+#else
+# define VALGRIND_MAKE_MEM_DEFINED(p, n) 0
+# define VALGRIND_MAKE_MEM_UNDEFINED(p, n) 0
+#endif
+
+#define RUBY_ZLIB_VERSION "0.6.0"
+
+#ifndef GZIP_SUPPORT
+#define GZIP_SUPPORT 1
+#endif
+
+/* from zutil.h */
+#ifndef DEF_MEM_LEVEL
+#if MAX_MEM_LEVEL >= 8
+#define DEF_MEM_LEVEL 8
+#else
+#define DEF_MEM_LEVEL MAX_MEM_LEVEL
+#endif
+#endif
+
+#if SIZEOF_LONG > SIZEOF_INT
+static inline uInt
+max_uint(long n)
+{
+ if (n > UINT_MAX) n = UINT_MAX;
+ return (uInt)n;
+}
+#define MAX_UINT(n) max_uint(n)
+#else
+#define MAX_UINT(n) (uInt)(n)
+#endif
+
+#define sizeof(x) ((int)sizeof(x))
+
+static ID id_dictionaries;
+
+/*--------- Prototypes --------*/
+
+static NORETURN(void raise_zlib_error(int, const char*));
+static VALUE rb_zlib_version(VALUE);
+static VALUE do_checksum(int, VALUE*, uLong (*)(uLong, const Bytef*, uInt));
+static VALUE rb_zlib_adler32(int, VALUE*, VALUE);
+static VALUE rb_zlib_crc32(int, VALUE*, VALUE);
+static VALUE rb_zlib_crc_table(VALUE);
+static voidpf zlib_mem_alloc(voidpf, uInt, uInt);
+static void zlib_mem_free(voidpf, voidpf);
+static void finalizer_warn(const char*);
+
+struct zstream;
+struct zstream_funcs;
+struct zstream_run_args;
+static void zstream_init(struct zstream*, const struct zstream_funcs*);
+static void zstream_expand_buffer(struct zstream*);
+static void zstream_expand_buffer_into(struct zstream*, unsigned long);
+static void zstream_append_buffer(struct zstream*, const Bytef*, long);
+static VALUE zstream_detach_buffer(struct zstream*);
+static VALUE zstream_shift_buffer(struct zstream*, long);
+static void zstream_buffer_ungets(struct zstream*, const Bytef*, unsigned long);
+static void zstream_buffer_ungetbyte(struct zstream*, int);
+static void zstream_append_input(struct zstream*, const Bytef*, long);
+static void zstream_discard_input(struct zstream*, long);
+static void zstream_reset_input(struct zstream*);
+static void zstream_passthrough_input(struct zstream*);
+static VALUE zstream_detach_input(struct zstream*);
+static void zstream_reset(struct zstream*);
+static VALUE zstream_end(struct zstream*);
+static void zstream_run(struct zstream*, Bytef*, long, int);
+static VALUE zstream_sync(struct zstream*, Bytef*, long);
+static void zstream_mark(void*);
+static void zstream_free(void*);
+static VALUE zstream_new(VALUE, const struct zstream_funcs*);
+static struct zstream *get_zstream(VALUE);
+static void zstream_finalize(struct zstream*);
+
+static VALUE rb_zstream_end(VALUE);
+static VALUE rb_zstream_reset(VALUE);
+static VALUE rb_zstream_finish(VALUE);
+static VALUE rb_zstream_flush_next_in(VALUE);
+static VALUE rb_zstream_flush_next_out(VALUE);
+static VALUE rb_zstream_avail_out(VALUE);
+static VALUE rb_zstream_set_avail_out(VALUE, VALUE);
+static VALUE rb_zstream_avail_in(VALUE);
+static VALUE rb_zstream_total_in(VALUE);
+static VALUE rb_zstream_total_out(VALUE);
+static VALUE rb_zstream_data_type(VALUE);
+static VALUE rb_zstream_adler(VALUE);
+static VALUE rb_zstream_finished_p(VALUE);
+static VALUE rb_zstream_closed_p(VALUE);
+
+static VALUE rb_deflate_s_allocate(VALUE);
+static VALUE rb_deflate_initialize(int, VALUE*, VALUE);
+static VALUE rb_deflate_init_copy(VALUE, VALUE);
+static VALUE deflate_run(VALUE);
+static VALUE rb_deflate_s_deflate(int, VALUE*, VALUE);
+static void do_deflate(struct zstream*, VALUE, int);
+static VALUE rb_deflate_deflate(int, VALUE*, VALUE);
+static VALUE rb_deflate_addstr(VALUE, VALUE);
+static VALUE rb_deflate_flush(int, VALUE*, VALUE);
+static VALUE rb_deflate_params(VALUE, VALUE, VALUE);
+static VALUE rb_deflate_set_dictionary(VALUE, VALUE);
+
+static VALUE inflate_run(VALUE);
+static VALUE rb_inflate_s_allocate(VALUE);
+static VALUE rb_inflate_initialize(int, VALUE*, VALUE);
+static VALUE rb_inflate_s_inflate(VALUE, VALUE);
+static void do_inflate(struct zstream*, VALUE);
+static VALUE rb_inflate_inflate(VALUE, VALUE);
+static VALUE rb_inflate_addstr(VALUE, VALUE);
+static VALUE rb_inflate_sync(VALUE, VALUE);
+static VALUE rb_inflate_sync_point_p(VALUE);
+static VALUE rb_inflate_set_dictionary(VALUE, VALUE);
+
+#if GZIP_SUPPORT
+struct gzfile;
+static void gzfile_mark(void*);
+static void gzfile_free(void*);
+static VALUE gzfile_new(VALUE, const struct zstream_funcs*, void (*) _((struct gzfile*)));
+static void gzfile_reset(struct gzfile*);
+static void gzfile_close(struct gzfile*, int);
+static void gzfile_write_raw(struct gzfile*);
+static VALUE gzfile_read_raw_partial(VALUE);
+static VALUE gzfile_read_raw_rescue(VALUE);
+static VALUE gzfile_read_raw(struct gzfile*);
+static int gzfile_read_raw_ensure(struct gzfile*, long);
+static char *gzfile_read_raw_until_zero(struct gzfile*, long);
+static unsigned int gzfile_get16(const unsigned char*);
+static unsigned long gzfile_get32(const unsigned char*);
+static void gzfile_set32(unsigned long n, unsigned char*);
+static void gzfile_make_header(struct gzfile*);
+static void gzfile_make_footer(struct gzfile*);
+static void gzfile_read_header(struct gzfile*);
+static void gzfile_check_footer(struct gzfile*);
+static void gzfile_write(struct gzfile*, Bytef*, long);
+static long gzfile_read_more(struct gzfile*);
+static void gzfile_calc_crc(struct gzfile*, VALUE);
+static VALUE gzfile_read(struct gzfile*, long);
+static VALUE gzfile_read_all(struct gzfile*);
+static void gzfile_ungets(struct gzfile*, const Bytef*, long);
+static void gzfile_ungetbyte(struct gzfile*, int);
+static VALUE gzfile_writer_end_run(VALUE);
+static void gzfile_writer_end(struct gzfile*);
+static VALUE gzfile_reader_end_run(VALUE);
+static void gzfile_reader_end(struct gzfile*);
+static void gzfile_reader_rewind(struct gzfile*);
+static VALUE gzfile_reader_get_unused(struct gzfile*);
+static struct gzfile *get_gzfile(VALUE);
+static VALUE gzfile_ensure_close(VALUE);
+static VALUE rb_gzfile_s_wrap(int, VALUE*, VALUE);
+static VALUE gzfile_s_open(int, VALUE*, VALUE, const char*);
+NORETURN(static void gzfile_raise(struct gzfile *, VALUE, const char *));
+static VALUE gzfile_error_inspect(VALUE);
+
+static VALUE rb_gzfile_to_io(VALUE);
+static VALUE rb_gzfile_crc(VALUE);
+static VALUE rb_gzfile_mtime(VALUE);
+static VALUE rb_gzfile_level(VALUE);
+static VALUE rb_gzfile_os_code(VALUE);
+static VALUE rb_gzfile_orig_name(VALUE);
+static VALUE rb_gzfile_comment(VALUE);
+static VALUE rb_gzfile_lineno(VALUE);
+static VALUE rb_gzfile_set_lineno(VALUE, VALUE);
+static VALUE rb_gzfile_set_mtime(VALUE, VALUE);
+static VALUE rb_gzfile_set_orig_name(VALUE, VALUE);
+static VALUE rb_gzfile_set_comment(VALUE, VALUE);
+static VALUE rb_gzfile_close(VALUE);
+static VALUE rb_gzfile_finish(VALUE);
+static VALUE rb_gzfile_closed_p(VALUE);
+static VALUE rb_gzfile_eof_p(VALUE);
+static VALUE rb_gzfile_sync(VALUE);
+static VALUE rb_gzfile_set_sync(VALUE, VALUE);
+static VALUE rb_gzfile_total_in(VALUE);
+static VALUE rb_gzfile_total_out(VALUE);
+static VALUE rb_gzfile_path(VALUE);
+
+static VALUE rb_gzwriter_s_allocate(VALUE);
+static VALUE rb_gzwriter_s_open(int, VALUE*, VALUE);
+static VALUE rb_gzwriter_initialize(int, VALUE*, VALUE);
+static VALUE rb_gzwriter_flush(int, VALUE*, VALUE);
+static VALUE rb_gzwriter_write(VALUE, VALUE);
+static VALUE rb_gzwriter_putc(VALUE, VALUE);
+
+static VALUE rb_gzreader_s_allocate(VALUE);
+static VALUE rb_gzreader_s_open(int, VALUE*, VALUE);
+static VALUE rb_gzreader_initialize(int, VALUE*, VALUE);
+static VALUE rb_gzreader_rewind(VALUE);
+static VALUE rb_gzreader_unused(VALUE);
+static VALUE rb_gzreader_read(int, VALUE*, VALUE);
+static VALUE rb_gzreader_getc(VALUE);
+static VALUE rb_gzreader_readchar(VALUE);
+static VALUE rb_gzreader_each_byte(VALUE);
+static VALUE rb_gzreader_ungetc(VALUE, VALUE);
+static VALUE rb_gzreader_ungetbyte(VALUE, VALUE);
+static void gzreader_skip_linebreaks(struct gzfile*);
+static VALUE gzreader_gets(int, VALUE*, VALUE);
+static VALUE rb_gzreader_gets(int, VALUE*, VALUE);
+static VALUE rb_gzreader_readline(int, VALUE*, VALUE);
+static VALUE rb_gzreader_each(int, VALUE*, VALUE);
+static VALUE rb_gzreader_readlines(int, VALUE*, VALUE);
+#endif /* GZIP_SUPPORT */
+
+/*
+ * Document-module: Zlib
+ *
+ * This module provides access to the {zlib library}[http://zlib.net]. Zlib is
+ * designed to be a portable, free, general-purpose, legally unencumbered --
+ * that is, not covered by any patents -- lossless data-compression library
+ * for use on virtually any computer hardware and operating system.
+ *
+ * The zlib compression library provides in-memory compression and
+ * decompression functions, including integrity checks of the uncompressed
+ * data.
+ *
+ * The zlib compressed data format is described in RFC 1950, which is a
+ * wrapper around a deflate stream which is described in RFC 1951.
+ *
+ * The library also supports reading and writing files in gzip (.gz) format
+ * with an interface similar to that of IO. The gzip format is described in
+ * RFC 1952 which is also a wrapper around a deflate stream.
+ *
+ * The zlib format was designed to be compact and fast for use in memory and on
+ * communications channels. The gzip format was designed for single-file
+ * compression on file systems, has a larger header than zlib to maintain
+ * directory information, and uses a different, slower check method than zlib.
+ *
+ * See your system's zlib.h for further information about zlib
+ *
+ * == Sample usage
+ *
+ * Using the wrapper to compress strings with default parameters is quite
+ * simple:
+ *
+ * require "zlib"
+ *
+ * data_to_compress = File.read("don_quixote.txt")
+ *
+ * puts "Input size: #{data_to_compress.size}"
+ * #=> Input size: 2347740
+ *
+ * data_compressed = Zlib::Deflate.deflate(data_to_compress)
+ *
+ * puts "Compressed size: #{data_compressed.size}"
+ * #=> Compressed size: 887238
+ *
+ * uncompressed_data = Zlib::Inflate.inflate(data_compressed)
+ *
+ * puts "Uncompressed data is: #{uncompressed_data}"
+ * #=> Uncompressed data is: The Project Gutenberg EBook of Don Quixote...
+ *
+ * == Class tree
+ *
+ * - Zlib::Deflate
+ * - Zlib::Inflate
+ * - Zlib::ZStream
+ * - Zlib::Error
+ * - Zlib::StreamEnd
+ * - Zlib::NeedDict
+ * - Zlib::DataError
+ * - Zlib::StreamError
+ * - Zlib::MemError
+ * - Zlib::BufError
+ * - Zlib::VersionError
+ *
+ * (if you have GZIP_SUPPORT)
+ * - Zlib::GzipReader
+ * - Zlib::GzipWriter
+ * - Zlib::GzipFile
+ * - Zlib::GzipFile::Error
+ * - Zlib::GzipFile::LengthError
+ * - Zlib::GzipFile::CRCError
+ * - Zlib::GzipFile::NoFooter
+ *
+ */
+void Init_zlib(void);
+
+/*--------- Exceptions --------*/
+
+static VALUE cZError, cStreamEnd, cNeedDict;
+static VALUE cStreamError, cDataError, cMemError, cBufError, cVersionError;
+
+static void
+raise_zlib_error(int err, const char *msg)
+{
+ VALUE exc;
+
+ if (!msg) {
+ msg = zError(err);
+ }
+
+ switch(err) {
+ case Z_STREAM_END:
+ exc = rb_exc_new2(cStreamEnd, msg);
+ break;
+ case Z_NEED_DICT:
+ exc = rb_exc_new2(cNeedDict, msg);
+ break;
+ case Z_STREAM_ERROR:
+ exc = rb_exc_new2(cStreamError, msg);
+ break;
+ case Z_DATA_ERROR:
+ exc = rb_exc_new2(cDataError, msg);
+ break;
+ case Z_BUF_ERROR:
+ exc = rb_exc_new2(cBufError, msg);
+ break;
+ case Z_VERSION_ERROR:
+ exc = rb_exc_new2(cVersionError, msg);
+ break;
+ case Z_MEM_ERROR:
+ exc = rb_exc_new2(cMemError, msg);
+ break;
+ case Z_ERRNO:
+ rb_sys_fail(msg);
+ /* no return */
+ default:
+ exc = rb_exc_new_str(cZError,
+ rb_sprintf("unknown zlib error %d: %s", err, msg));
+ }
+
+ rb_exc_raise(exc);
+}
+
+
+/*--- Warning (in finalizer) ---*/
+
+static void
+finalizer_warn(const char *msg)
+{
+ fprintf(stderr, "zlib(finalizer): %s\n", msg);
+}
+
+
+/*-------- module Zlib --------*/
+
+/*
+ * Document-method: Zlib.zlib_version
+ *
+ * Returns the string which represents the version of zlib library.
+ */
+static VALUE
+rb_zlib_version(VALUE klass)
+{
+ VALUE str;
+
+ str = rb_str_new2(zlibVersion());
+ OBJ_TAINT(str); /* for safe */
+ return str;
+}
+
+#if SIZEOF_LONG > SIZEOF_INT
+static uLong
+checksum_long(uLong (*func)(uLong, const Bytef*, uInt), uLong sum, const Bytef *ptr, long len)
+{
+ if (len > UINT_MAX) {
+ do {
+ sum = func(sum, ptr, UINT_MAX);
+ ptr += UINT_MAX;
+ len -= UINT_MAX;
+ } while (len >= UINT_MAX);
+ }
+ if (len > 0) sum = func(sum, ptr, (uInt)len);
+ return sum;
+}
+#else
+#define checksum_long(func, sum, ptr, len) (func)((sum), (ptr), (len))
+#endif
+
+static VALUE
+do_checksum(argc, argv, func)
+ int argc;
+ VALUE *argv;
+ uLong (*func)(uLong, const Bytef*, uInt);
+{
+ VALUE str, vsum;
+ unsigned long sum;
+
+ rb_scan_args(argc, argv, "02", &str, &vsum);
+
+ if (!NIL_P(vsum)) {
+ sum = NUM2ULONG(vsum);
+ }
+ else if (NIL_P(str)) {
+ sum = 0;
+ }
+ else {
+ sum = func(0, Z_NULL, 0);
+ }
+
+ if (NIL_P(str)) {
+ sum = func(sum, Z_NULL, 0);
+ }
+ else {
+ StringValue(str);
+ sum = checksum_long(func, sum, (Bytef*)RSTRING_PTR(str), RSTRING_LEN(str));
+ }
+ return rb_uint2inum(sum);
+}
+
+/*
+ * Document-method: Zlib.adler32
+ *
+ * call-seq: Zlib.adler32(string, adler)
+ *
+ * Calculates Adler-32 checksum for +string+, and returns updated value of
+ * +adler+. If +string+ is omitted, it returns the Adler-32 initial value. If
+ * +adler+ is omitted, it assumes that the initial value is given to +adler+.
+ *
+ * Example usage:
+ *
+ * require "zlib"
+ *
+ * data = "foo"
+ * puts "Adler32 checksum: #{Zlib.adler32(data).to_s(16)}"
+ * #=> Adler32 checksum: 2820145
+ *
+ */
+static VALUE
+rb_zlib_adler32(int argc, VALUE *argv, VALUE klass)
+{
+ return do_checksum(argc, argv, adler32);
+}
+
+#ifdef HAVE_ADLER32_COMBINE
+/*
+ * Document-method: Zlib.adler32_combine
+ *
+ * call-seq: Zlib.adler32_combine(adler1, adler2, len2)
+ *
+ * Combine two Adler-32 check values in to one. +alder1+ is the first Adler-32
+ * value, +adler2+ is the second Adler-32 value. +len2+ is the length of the
+ * string used to generate +adler2+.
+ *
+ */
+static VALUE
+rb_zlib_adler32_combine(VALUE klass, VALUE adler1, VALUE adler2, VALUE len2)
+{
+ return ULONG2NUM(
+ adler32_combine(NUM2ULONG(adler1), NUM2ULONG(adler2), NUM2LONG(len2)));
+}
+#else
+#define rb_zlib_adler32_combine rb_f_notimplement
+#endif
+
+/*
+ * Document-method: Zlib.crc32
+ *
+ * call-seq: Zlib.crc32(string, crc)
+ *
+ * Calculates CRC checksum for +string+, and returns updated value of +crc+. If
+ * +string+ is omitted, it returns the CRC initial value. If +crc+ is omitted, it
+ * assumes that the initial value is given to +crc+.
+ *
+ * FIXME: expression.
+ */
+static VALUE
+rb_zlib_crc32(int argc, VALUE *argv, VALUE klass)
+{
+ return do_checksum(argc, argv, crc32);
+}
+
+#ifdef HAVE_CRC32_COMBINE
+/*
+ * Document-method: Zlib.crc32_combine
+ *
+ * call-seq: Zlib.crc32_combine(crc1, crc2, len2)
+ *
+ * Combine two CRC-32 check values in to one. +crc1+ is the first CRC-32
+ * value, +crc2+ is the second CRC-32 value. +len2+ is the length of the
+ * string used to generate +crc2+.
+ *
+ */
+static VALUE
+rb_zlib_crc32_combine(VALUE klass, VALUE crc1, VALUE crc2, VALUE len2)
+{
+ return ULONG2NUM(
+ crc32_combine(NUM2ULONG(crc1), NUM2ULONG(crc2), NUM2LONG(len2)));
+}
+#else
+#define rb_zlib_crc32_combine rb_f_notimplement
+#endif
+
+/*
+ * Document-method: Zlib.crc_table
+ *
+ * Returns the table for calculating CRC checksum as an array.
+ */
+static VALUE
+rb_zlib_crc_table(VALUE obj)
+{
+#if !defined(HAVE_TYPE_Z_CRC_T)
+ /* z_crc_t is defined since zlib-1.2.7. */
+ typedef unsigned long z_crc_t;
+#endif
+ const z_crc_t *crctbl;
+ VALUE dst;
+ int i;
+
+ crctbl = get_crc_table();
+ dst = rb_ary_new2(256);
+
+ for (i = 0; i < 256; i++) {
+ rb_ary_push(dst, rb_uint2inum(crctbl[i]));
+ }
+ return dst;
+}
+
+
+
+/*-------- zstream - internal APIs --------*/
+
+struct zstream {
+ unsigned long flags;
+ VALUE buf;
+ long buf_filled;
+ VALUE input;
+ z_stream stream;
+ const struct zstream_funcs {
+ int (*reset)(z_streamp);
+ int (*end)(z_streamp);
+ int (*run)(z_streamp, int);
+ } *func;
+};
+
+#define ZSTREAM_FLAG_READY 0x1
+#define ZSTREAM_FLAG_IN_STREAM 0x2
+#define ZSTREAM_FLAG_FINISHED 0x4
+#define ZSTREAM_FLAG_CLOSING 0x8
+#define ZSTREAM_FLAG_GZFILE 0x10 /* disallows yield from expand_buffer for
+ gzip*/
+#define ZSTREAM_FLAG_UNUSED 0x20
+
+#define ZSTREAM_READY(z) ((z)->flags |= ZSTREAM_FLAG_READY)
+#define ZSTREAM_IS_READY(z) ((z)->flags & ZSTREAM_FLAG_READY)
+#define ZSTREAM_IS_FINISHED(z) ((z)->flags & ZSTREAM_FLAG_FINISHED)
+#define ZSTREAM_IS_CLOSING(z) ((z)->flags & ZSTREAM_FLAG_CLOSING)
+#define ZSTREAM_IS_GZFILE(z) ((z)->flags & ZSTREAM_FLAG_GZFILE)
+
+#define ZSTREAM_EXPAND_BUFFER_OK 0
+
+/* I think that more better value should be found,
+ but I gave up finding it. B) */
+#define ZSTREAM_INITIAL_BUFSIZE 1024
+/* Allow a quick return when the thread is interrupted */
+#define ZSTREAM_AVAIL_OUT_STEP_MAX 16384
+#define ZSTREAM_AVAIL_OUT_STEP_MIN 2048
+
+static const struct zstream_funcs deflate_funcs = {
+ deflateReset, deflateEnd, deflate,
+};
+
+static const struct zstream_funcs inflate_funcs = {
+ inflateReset, inflateEnd, inflate,
+};
+
+struct zstream_run_args {
+ struct zstream * z;
+ int flush; /* stream flush value for inflate() or deflate() */
+ int interrupt; /* stop processing the stream and return to ruby */
+ int jump_state; /* for buffer expansion block break or exception */
+ int stream_output; /* for streaming zlib processing */
+};
+
+static voidpf
+zlib_mem_alloc(voidpf opaque, uInt items, uInt size)
+{
+ voidpf p = xmalloc2(items, size);
+ /* zlib FAQ: Valgrind (or some similar memory access checker) says that
+ deflate is performing a conditional jump that depends on an
+ uninitialized value. Isn't that a bug?
+ http://www.zlib.net/zlib_faq.html#faq36 */
+ (void)VALGRIND_MAKE_MEM_DEFINED(p, items * size);
+ return p;
+}
+
+static void
+zlib_mem_free(voidpf opaque, voidpf address)
+{
+ xfree(address);
+}
+
+static void
+zstream_init(struct zstream *z, const struct zstream_funcs *func)
+{
+ z->flags = 0;
+ z->buf = Qnil;
+ z->buf_filled = 0;
+ z->input = Qnil;
+ z->stream.zalloc = zlib_mem_alloc;
+ z->stream.zfree = zlib_mem_free;
+ z->stream.opaque = Z_NULL;
+ z->stream.msg = Z_NULL;
+ z->stream.next_in = Z_NULL;
+ z->stream.avail_in = 0;
+ z->stream.next_out = Z_NULL;
+ z->stream.avail_out = 0;
+ z->func = func;
+}
+
+#define zstream_init_deflate(z) zstream_init((z), &deflate_funcs)
+#define zstream_init_inflate(z) zstream_init((z), &inflate_funcs)
+
+static void
+zstream_expand_buffer(struct zstream *z)
+{
+ if (NIL_P(z->buf)) {
+ zstream_expand_buffer_into(z, ZSTREAM_INITIAL_BUFSIZE);
+ return;
+ }
+
+ if (!ZSTREAM_IS_GZFILE(z) && rb_block_given_p()) {
+ if (z->buf_filled >= ZSTREAM_AVAIL_OUT_STEP_MAX) {
+ int state = 0;
+ VALUE self = (VALUE)z->stream.opaque;
+
+ rb_str_resize(z->buf, z->buf_filled);
+ rb_obj_reveal(z->buf, rb_cString);
+ OBJ_INFECT(z->buf, self);
+
+ rb_protect(rb_yield, z->buf, &state);
+
+ z->buf = Qnil;
+ zstream_expand_buffer_into(z, ZSTREAM_AVAIL_OUT_STEP_MAX);
+
+ if (state)
+ rb_jump_tag(state);
+
+ return;
+ }
+ else {
+ zstream_expand_buffer_into(z,
+ ZSTREAM_AVAIL_OUT_STEP_MAX - z->buf_filled);
+ }
+ }
+ else {
+ if (RSTRING_LEN(z->buf) - z->buf_filled >= ZSTREAM_AVAIL_OUT_STEP_MAX) {
+ z->stream.avail_out = ZSTREAM_AVAIL_OUT_STEP_MAX;
+ }
+ else {
+ long inc = z->buf_filled / 2;
+ if (inc < ZSTREAM_AVAIL_OUT_STEP_MIN) {
+ inc = ZSTREAM_AVAIL_OUT_STEP_MIN;
+ }
+ rb_str_resize(z->buf, z->buf_filled + inc);
+ z->stream.avail_out = (inc < ZSTREAM_AVAIL_OUT_STEP_MAX) ?
+ (int)inc : ZSTREAM_AVAIL_OUT_STEP_MAX;
+ }
+ z->stream.next_out = (Bytef*)RSTRING_PTR(z->buf) + z->buf_filled;
+ }
+}
+
+static void
+zstream_expand_buffer_into(struct zstream *z, unsigned long size)
+{
+ if (NIL_P(z->buf)) {
+ /* I uses rb_str_new here not rb_str_buf_new because
+ rb_str_buf_new makes a zero-length string. */
+ z->buf = rb_str_new(0, size);
+ z->buf_filled = 0;
+ z->stream.next_out = (Bytef*)RSTRING_PTR(z->buf);
+ z->stream.avail_out = MAX_UINT(size);
+ rb_obj_hide(z->buf);
+ }
+ else if (z->stream.avail_out != size) {
+ rb_str_resize(z->buf, z->buf_filled + size);
+ z->stream.next_out = (Bytef*)RSTRING_PTR(z->buf) + z->buf_filled;
+ z->stream.avail_out = MAX_UINT(size);
+ }
+}
+
+static void *
+zstream_expand_buffer_protect(void *ptr)
+{
+ struct zstream *z = (struct zstream *)ptr;
+ int state = 0;
+
+ rb_protect((VALUE (*)(VALUE))zstream_expand_buffer, (VALUE)z, &state);
+
+ return (void *)(VALUE)state;
+}
+
+static int
+zstream_expand_buffer_without_gvl(struct zstream *z)
+{
+ char * new_str;
+ long inc, len;
+
+ if (RSTRING_LEN(z->buf) - z->buf_filled >= ZSTREAM_AVAIL_OUT_STEP_MAX) {
+ z->stream.avail_out = ZSTREAM_AVAIL_OUT_STEP_MAX;
+ }
+ else {
+ inc = z->buf_filled / 2;
+ if (inc < ZSTREAM_AVAIL_OUT_STEP_MIN) {
+ inc = ZSTREAM_AVAIL_OUT_STEP_MIN;
+ }
+
+ len = z->buf_filled + inc;
+
+ new_str = ruby_xrealloc(RSTRING(z->buf)->as.heap.ptr, len + 1);
+
+ /* from rb_str_resize */
+ RSTRING(z->buf)->as.heap.ptr = new_str;
+ RSTRING(z->buf)->as.heap.ptr[len] = '\0'; /* sentinel */
+ RSTRING(z->buf)->as.heap.len =
+ RSTRING(z->buf)->as.heap.aux.capa = len;
+
+ z->stream.avail_out = (inc < ZSTREAM_AVAIL_OUT_STEP_MAX) ?
+ (int)inc : ZSTREAM_AVAIL_OUT_STEP_MAX;
+ }
+ z->stream.next_out = (Bytef*)RSTRING_PTR(z->buf) + z->buf_filled;
+
+ return ZSTREAM_EXPAND_BUFFER_OK;
+}
+
+static void
+zstream_append_buffer(struct zstream *z, const Bytef *src, long len)
+{
+ if (NIL_P(z->buf)) {
+ z->buf = rb_str_buf_new(len);
+ rb_str_buf_cat(z->buf, (const char*)src, len);
+ z->buf_filled = len;
+ z->stream.next_out = (Bytef*)RSTRING_PTR(z->buf);
+ z->stream.avail_out = 0;
+ rb_obj_hide(z->buf);
+ return;
+ }
+
+ if (RSTRING_LEN(z->buf) < z->buf_filled + len) {
+ rb_str_resize(z->buf, z->buf_filled + len);
+ z->stream.avail_out = 0;
+ }
+ else {
+ if (z->stream.avail_out >= (uInt)len) {
+ z->stream.avail_out -= (uInt)len;
+ }
+ else {
+ z->stream.avail_out = 0;
+ }
+ }
+ memcpy(RSTRING_PTR(z->buf) + z->buf_filled, src, len);
+ z->buf_filled += len;
+ z->stream.next_out = (Bytef*)RSTRING_PTR(z->buf) + z->buf_filled;
+}
+
+#define zstream_append_buffer2(z,v) \
+ zstream_append_buffer((z),(Bytef*)RSTRING_PTR(v),RSTRING_LEN(v))
+
+static VALUE
+zstream_detach_buffer(struct zstream *z)
+{
+ VALUE dst, self = (VALUE)z->stream.opaque;
+
+ if (!ZSTREAM_IS_FINISHED(z) && !ZSTREAM_IS_GZFILE(z) &&
+ rb_block_given_p()) {
+ /* prevent tiny yields mid-stream, save for next
+ * zstream_expand_buffer() or stream end */
+ return Qnil;
+ }
+
+ if (NIL_P(z->buf)) {
+ dst = rb_str_new(0, 0);
+ }
+ else {
+ dst = z->buf;
+ rb_str_resize(dst, z->buf_filled);
+ rb_obj_reveal(dst, rb_cString);
+ }
+
+ OBJ_INFECT(dst, self);
+
+ z->buf = Qnil;
+ z->buf_filled = 0;
+ z->stream.next_out = 0;
+ z->stream.avail_out = 0;
+
+ if (!ZSTREAM_IS_GZFILE(z) && rb_block_given_p()) {
+ rb_yield(dst);
+ dst = Qnil;
+ }
+
+ return dst;
+}
+
+static VALUE
+zstream_shift_buffer(struct zstream *z, long len)
+{
+ VALUE dst;
+ long buflen;
+
+ if (z->buf_filled <= len) {
+ return zstream_detach_buffer(z);
+ }
+
+ dst = rb_str_new(RSTRING_PTR(z->buf), len);
+ z->buf_filled -= len;
+ memmove(RSTRING_PTR(z->buf), RSTRING_PTR(z->buf) + len,
+ z->buf_filled);
+ z->stream.next_out = (Bytef*)RSTRING_PTR(z->buf) + z->buf_filled;
+ buflen = RSTRING_LEN(z->buf) - z->buf_filled;
+ if (buflen > ZSTREAM_AVAIL_OUT_STEP_MAX) {
+ buflen = ZSTREAM_AVAIL_OUT_STEP_MAX;
+ }
+ z->stream.avail_out = (uInt)buflen;
+
+ return dst;
+}
+
+static void
+zstream_buffer_ungets(struct zstream *z, const Bytef *b, unsigned long len)
+{
+ if (NIL_P(z->buf) || RSTRING_LEN(z->buf) - z->buf_filled == 0) {
+ zstream_expand_buffer_into(z, len);
+ }
+
+ memmove(RSTRING_PTR(z->buf) + len, RSTRING_PTR(z->buf), z->buf_filled);
+ memmove(RSTRING_PTR(z->buf), b, len);
+ z->buf_filled+=len;
+ if (z->stream.avail_out > 0) {
+ if (len > z->stream.avail_out) len = z->stream.avail_out;
+ z->stream.next_out+=len;
+ z->stream.avail_out-=(uInt)len;
+ }
+}
+
+static void
+zstream_buffer_ungetbyte(struct zstream *z, int c)
+{
+ if (NIL_P(z->buf) || RSTRING_LEN(z->buf) - z->buf_filled == 0) {
+ zstream_expand_buffer(z);
+ }
+
+ memmove(RSTRING_PTR(z->buf) + 1, RSTRING_PTR(z->buf), z->buf_filled);
+ RSTRING_PTR(z->buf)[0] = (char)c;
+ z->buf_filled++;
+ if (z->stream.avail_out > 0) {
+ z->stream.next_out++;
+ z->stream.avail_out--;
+ }
+}
+
+static void
+zstream_append_input(struct zstream *z, const Bytef *src, long len)
+{
+ if (len <= 0) return;
+
+ if (NIL_P(z->input)) {
+ z->input = rb_str_buf_new(len);
+ rb_str_buf_cat(z->input, (const char*)src, len);
+ rb_obj_hide(z->input);
+ }
+ else {
+ rb_str_buf_cat(z->input, (const char*)src, len);
+ }
+}
+
+#define zstream_append_input2(z,v)\
+ RB_GC_GUARD(v),\
+ zstream_append_input((z), (Bytef*)RSTRING_PTR(v), RSTRING_LEN(v))
+
+static void
+zstream_discard_input(struct zstream *z, long len)
+{
+ if (NIL_P(z->input) || RSTRING_LEN(z->input) <= len) {
+ z->input = Qnil;
+ }
+ else {
+ memmove(RSTRING_PTR(z->input), RSTRING_PTR(z->input) + len,
+ RSTRING_LEN(z->input) - len);
+ rb_str_resize(z->input, RSTRING_LEN(z->input) - len);
+ }
+}
+
+static void
+zstream_reset_input(struct zstream *z)
+{
+ z->input = Qnil;
+}
+
+static void
+zstream_passthrough_input(struct zstream *z)
+{
+ if (!NIL_P(z->input)) {
+ zstream_append_buffer2(z, z->input);
+ z->input = Qnil;
+ }
+}
+
+static VALUE
+zstream_detach_input(struct zstream *z)
+{
+ VALUE dst;
+
+ if (NIL_P(z->input)) {
+ dst = rb_str_new(0, 0);
+ }
+ else {
+ dst = z->input;
+ rb_obj_reveal(dst, rb_cString);
+ }
+ z->input = Qnil;
+ rb_obj_reveal(dst, rb_cString);
+ return dst;
+}
+
+static void
+zstream_reset(struct zstream *z)
+{
+ int err;
+
+ err = z->func->reset(&z->stream);
+ if (err != Z_OK) {
+ raise_zlib_error(err, z->stream.msg);
+ }
+ z->flags = ZSTREAM_FLAG_READY;
+ z->buf = Qnil;
+ z->buf_filled = 0;
+ z->stream.next_out = 0;
+ z->stream.avail_out = 0;
+ zstream_reset_input(z);
+}
+
+static VALUE
+zstream_end(struct zstream *z)
+{
+ int err;
+
+ if (!ZSTREAM_IS_READY(z)) {
+ rb_warning("attempt to close uninitialized zstream; ignored.");
+ return Qnil;
+ }
+ if (z->flags & ZSTREAM_FLAG_IN_STREAM) {
+ rb_warning("attempt to close unfinished zstream; reset forced.");
+ zstream_reset(z);
+ }
+
+ zstream_reset_input(z);
+ err = z->func->end(&z->stream);
+ if (err != Z_OK) {
+ raise_zlib_error(err, z->stream.msg);
+ }
+ z->flags = 0;
+ return Qnil;
+}
+
+static void *
+zstream_run_func(void *ptr)
+{
+ struct zstream_run_args *args = (struct zstream_run_args *)ptr;
+ int err, state, flush = args->flush;
+ struct zstream *z = args->z;
+ uInt n;
+
+ err = Z_OK;
+ while (!args->interrupt) {
+ n = z->stream.avail_out;
+ err = z->func->run(&z->stream, flush);
+ z->buf_filled += n - z->stream.avail_out;
+
+ if (err == Z_STREAM_END) {
+ z->flags &= ~ZSTREAM_FLAG_IN_STREAM;
+ z->flags |= ZSTREAM_FLAG_FINISHED;
+ break;
+ }
+
+ if (err != Z_OK && err != Z_BUF_ERROR)
+ break;
+
+ if (z->stream.avail_out > 0) {
+ z->flags |= ZSTREAM_FLAG_IN_STREAM;
+ break;
+ }
+
+ if (z->stream.avail_in == 0 && z->func == &inflate_funcs) {
+ /* break here because inflate() return Z_BUF_ERROR when avail_in == 0. */
+ /* but deflate() could be called with avail_in == 0 (there's hidden buffer
+ in zstream->state) */
+ z->flags |= ZSTREAM_FLAG_IN_STREAM;
+ break;
+ }
+
+ if (args->stream_output) {
+ state = (int)(VALUE)rb_thread_call_with_gvl(zstream_expand_buffer_protect,
+ (void *)z);
+ } else {
+ state = zstream_expand_buffer_without_gvl(z);
+ }
+
+ if (state) {
+ err = Z_OK; /* buffer expanded but stream processing was stopped */
+ args->jump_state = state;
+ break;
+ }
+ }
+
+ return (void *)(VALUE)err;
+}
+
+/*
+ * There is no safe way to interrupt z->run->func().
+ */
+static void
+zstream_unblock_func(void *ptr)
+{
+ struct zstream_run_args *args = (struct zstream_run_args *)ptr;
+
+ args->interrupt = 1;
+}
+
+static void
+zstream_run(struct zstream *z, Bytef *src, long len, int flush)
+{
+ struct zstream_run_args args;
+ int err;
+ volatile VALUE guard = Qnil;
+
+ args.z = z;
+ args.flush = flush;
+ args.interrupt = 0;
+ args.jump_state = 0;
+ args.stream_output = !ZSTREAM_IS_GZFILE(z) && rb_block_given_p();
+
+ if (NIL_P(z->input) && len == 0) {
+ z->stream.next_in = (Bytef*)"";
+ z->stream.avail_in = 0;
+ }
+ else {
+ zstream_append_input(z, src, len);
+ z->stream.next_in = (Bytef*)RSTRING_PTR(z->input);
+ z->stream.avail_in = MAX_UINT(RSTRING_LEN(z->input));
+ /* keep reference to `z->input' so as not to be garbage collected
+ after zstream_reset_input() and prevent `z->stream.next_in'
+ from dangling. */
+ guard = z->input;
+ }
+
+ if (z->stream.avail_out == 0) {
+ zstream_expand_buffer(z);
+ }
+
+loop:
+ err = (int)(VALUE)rb_thread_call_without_gvl(zstream_run_func, (void *)&args,
+ zstream_unblock_func, (void *)&args);
+
+ if (flush != Z_FINISH && err == Z_BUF_ERROR
+ && z->stream.avail_out > 0) {
+ z->flags |= ZSTREAM_FLAG_IN_STREAM;
+ }
+
+ zstream_reset_input(z);
+
+ if (err != Z_OK && err != Z_STREAM_END) {
+ if (z->stream.avail_in > 0) {
+ zstream_append_input(z, z->stream.next_in, z->stream.avail_in);
+ }
+ if (err == Z_NEED_DICT) {
+ VALUE self = (VALUE)z->stream.opaque;
+ if (self) {
+ VALUE dicts = rb_ivar_get(self, id_dictionaries);
+ VALUE dict = rb_hash_aref(dicts, rb_uint2inum(z->stream.adler));
+ if (!NIL_P(dict)) {
+ rb_inflate_set_dictionary(self, dict);
+ goto loop;
+ }
+ }
+ }
+ raise_zlib_error(err, z->stream.msg);
+ }
+
+ if (z->stream.avail_in > 0) {
+ zstream_append_input(z, z->stream.next_in, z->stream.avail_in);
+ RB_GC_GUARD(guard) = Qnil; /* prevent tail call to make guard effective */
+ }
+
+ if (args.jump_state)
+ rb_jump_tag(args.jump_state);
+}
+
+static VALUE
+zstream_sync(struct zstream *z, Bytef *src, long len)
+{
+ /* VALUE rest; */
+ int err;
+
+ if (!NIL_P(z->input)) {
+ z->stream.next_in = (Bytef*)RSTRING_PTR(z->input);
+ z->stream.avail_in = MAX_UINT(RSTRING_LEN(z->input));
+ err = inflateSync(&z->stream);
+ if (err == Z_OK) {
+ zstream_discard_input(z,
+ RSTRING_LEN(z->input) - z->stream.avail_in);
+ zstream_append_input(z, src, len);
+ return Qtrue;
+ }
+ zstream_reset_input(z);
+ if (err != Z_DATA_ERROR) {
+ /* rest = rb_str_new((char*)z->stream.next_in, z->stream.avail_in); */
+ raise_zlib_error(err, z->stream.msg);
+ }
+ }
+
+ if (len <= 0) return Qfalse;
+
+ z->stream.next_in = src;
+ z->stream.avail_in = MAX_UINT(len);
+ err = inflateSync(&z->stream);
+ if (err == Z_OK) {
+ zstream_append_input(z, z->stream.next_in, z->stream.avail_in);
+ return Qtrue;
+ }
+ if (err != Z_DATA_ERROR) {
+ /* rest = rb_str_new((char*)z->stream.next_in, z->stream.avail_in); */
+ raise_zlib_error(err, z->stream.msg);
+ }
+ return Qfalse;
+}
+
+static void
+zstream_mark(void *p)
+{
+ struct zstream *z = p;
+ rb_gc_mark(z->buf);
+ rb_gc_mark(z->input);
+}
+
+static void
+zstream_finalize(struct zstream *z)
+{
+ int err = z->func->end(&z->stream);
+ if (err == Z_STREAM_ERROR)
+ finalizer_warn("the stream state was inconsistent.");
+ if (err == Z_DATA_ERROR)
+ finalizer_warn("the stream was freed prematurely.");
+}
+
+static void
+zstream_free(void *p)
+{
+ struct zstream *z = p;
+
+ if (ZSTREAM_IS_READY(z)) {
+ zstream_finalize(z);
+ }
+ xfree(z);
+}
+
+static size_t
+zstream_memsize(const void *p)
+{
+ /* n.b. this does not track memory managed via zalloc/zfree callbacks */
+ return sizeof(struct zstream);
+}
+
+static const rb_data_type_t zstream_data_type = {
+ "zstream",
+ { zstream_mark, zstream_free, zstream_memsize, },
+ 0, 0, RUBY_TYPED_FREE_IMMEDIATELY
+};
+
+static VALUE
+zstream_new(VALUE klass, const struct zstream_funcs *funcs)
+{
+ VALUE obj;
+ struct zstream *z;
+
+ obj = TypedData_Make_Struct(klass, struct zstream, &zstream_data_type, z);
+ zstream_init(z, funcs);
+ z->stream.opaque = (voidpf)obj;
+ return obj;
+}
+
+#define zstream_deflate_new(klass) zstream_new((klass), &deflate_funcs)
+#define zstream_inflate_new(klass) zstream_new((klass), &inflate_funcs)
+
+static struct zstream *
+get_zstream(VALUE obj)
+{
+ struct zstream *z;
+
+ TypedData_Get_Struct(obj, struct zstream, &zstream_data_type, z);
+ if (!ZSTREAM_IS_READY(z)) {
+ rb_raise(cZError, "stream is not ready");
+ }
+ return z;
+}
+
+
+/* ------------------------------------------------------------------------- */
+
+/*
+ * Document-class: Zlib::ZStream
+ *
+ * Zlib::ZStream is the abstract class for the stream which handles the
+ * compressed data. The operations are defined in the subclasses:
+ * Zlib::Deflate for compression, and Zlib::Inflate for decompression.
+ *
+ * An instance of Zlib::ZStream has one stream (struct zstream in the source)
+ * and two variable-length buffers which associated to the input (next_in) of
+ * the stream and the output (next_out) of the stream. In this document,
+ * "input buffer" means the buffer for input, and "output buffer" means the
+ * buffer for output.
+ *
+ * Data input into an instance of Zlib::ZStream are temporally stored into
+ * the end of input buffer, and then data in input buffer are processed from
+ * the beginning of the buffer until no more output from the stream is
+ * produced (i.e. until avail_out > 0 after processing). During processing,
+ * output buffer is allocated and expanded automatically to hold all output
+ * data.
+ *
+ * Some particular instance methods consume the data in output buffer and
+ * return them as a String.
+ *
+ * Here is an ascii art for describing above:
+ *
+ * +================ an instance of Zlib::ZStream ================+
+ * || ||
+ * || +--------+ +-------+ +--------+ ||
+ * || +--| output |<---------|zstream|<---------| input |<--+ ||
+ * || | | buffer | next_out+-------+next_in | buffer | | ||
+ * || | +--------+ +--------+ | ||
+ * || | | ||
+ * +===|======================================================|===+
+ * | |
+ * v |
+ * "output data" "input data"
+ *
+ * If an error occurs during processing input buffer, an exception which is a
+ * subclass of Zlib::Error is raised. At that time, both input and output
+ * buffer keep their conditions at the time when the error occurs.
+ *
+ * == Method Catalogue
+ *
+ * Many of the methods in this class are fairly low-level and unlikely to be
+ * of interest to users. In fact, users are unlikely to use this class
+ * directly; rather they will be interested in Zlib::Inflate and
+ * Zlib::Deflate.
+ *
+ * The higher level methods are listed below.
+ *
+ * - #total_in
+ * - #total_out
+ * - #data_type
+ * - #adler
+ * - #reset
+ * - #finish
+ * - #finished?
+ * - #close
+ * - #closed?
+ */
+
+/*
+ * Closes the stream. All operations on the closed stream will raise an
+ * exception.
+ */
+static VALUE
+rb_zstream_end(VALUE obj)
+{
+ zstream_end(get_zstream(obj));
+ return Qnil;
+}
+
+/*
+ * Resets and initializes the stream. All data in both input and output buffer
+ * are discarded.
+ */
+static VALUE
+rb_zstream_reset(VALUE obj)
+{
+ zstream_reset(get_zstream(obj));
+ return Qnil;
+}
+
+/*
+ * call-seq:
+ * finish -> String
+ * finish { |chunk| ... } -> nil
+ *
+ * Finishes the stream and flushes output buffer. If a block is given each
+ * chunk is yielded to the block until the input buffer has been flushed to
+ * the output buffer.
+ */
+static VALUE
+rb_zstream_finish(VALUE obj)
+{
+ struct zstream *z = get_zstream(obj);
+
+ zstream_run(z, (Bytef*)"", 0, Z_FINISH);
+
+ return zstream_detach_buffer(z);
+}
+
+/*
+ * call-seq:
+ * flush_next_in -> input
+ *
+ */
+static VALUE
+rb_zstream_flush_next_in(VALUE obj)
+{
+ struct zstream *z;
+ VALUE dst;
+
+ TypedData_Get_Struct(obj, struct zstream, &zstream_data_type, z);
+ dst = zstream_detach_input(z);
+ OBJ_INFECT(dst, obj);
+ return dst;
+}
+
+/*
+ * call-seq:
+ * flush_next_out -> String
+ * flush_next_out { |chunk| ... } -> nil
+ *
+ * Flushes output buffer and returns all data in that buffer. If a block is
+ * given each chunk is yielded to the block until the current output buffer
+ * has been flushed.
+ */
+static VALUE
+rb_zstream_flush_next_out(VALUE obj)
+{
+ struct zstream *z;
+
+ TypedData_Get_Struct(obj, struct zstream, &zstream_data_type, z);
+
+ return zstream_detach_buffer(z);
+}
+
+/*
+ * Returns number of bytes of free spaces in output buffer. Because the free
+ * space is allocated automatically, this method returns 0 normally.
+ */
+static VALUE
+rb_zstream_avail_out(VALUE obj)
+{
+ struct zstream *z;
+ TypedData_Get_Struct(obj, struct zstream, &zstream_data_type, z);
+ return rb_uint2inum(z->stream.avail_out);
+}
+
+/*
+ * Allocates +size+ bytes of free space in the output buffer. If there are more
+ * than +size+ bytes already in the buffer, the buffer is truncated. Because
+ * free space is allocated automatically, you usually don't need to use this
+ * method.
+ */
+static VALUE
+rb_zstream_set_avail_out(VALUE obj, VALUE size)
+{
+ struct zstream *z = get_zstream(obj);
+
+ Check_Type(size, T_FIXNUM);
+ zstream_expand_buffer_into(z, FIX2INT(size));
+ return size;
+}
+
+/*
+ * Returns bytes of data in the input buffer. Normally, returns 0.
+ */
+static VALUE
+rb_zstream_avail_in(VALUE obj)
+{
+ struct zstream *z;
+ TypedData_Get_Struct(obj, struct zstream, &zstream_data_type, z);
+ return INT2FIX(NIL_P(z->input) ? 0 : (int)(RSTRING_LEN(z->input)));
+}
+
+/*
+ * Returns the total bytes of the input data to the stream. FIXME
+ */
+static VALUE
+rb_zstream_total_in(VALUE obj)
+{
+ return rb_uint2inum(get_zstream(obj)->stream.total_in);
+}
+
+/*
+ * Returns the total bytes of the output data from the stream. FIXME
+ */
+static VALUE
+rb_zstream_total_out(VALUE obj)
+{
+ return rb_uint2inum(get_zstream(obj)->stream.total_out);
+}
+
+/*
+ * Guesses the type of the data which have been inputed into the stream. The
+ * returned value is either <tt>BINARY</tt>, <tt>ASCII</tt>, or
+ * <tt>UNKNOWN</tt>.
+ */
+static VALUE
+rb_zstream_data_type(VALUE obj)
+{
+ return INT2FIX(get_zstream(obj)->stream.data_type);
+}
+
+/*
+ * Returns the adler-32 checksum.
+ */
+static VALUE
+rb_zstream_adler(VALUE obj)
+{
+ return rb_uint2inum(get_zstream(obj)->stream.adler);
+}
+
+/*
+ * Returns true if the stream is finished.
+ */
+static VALUE
+rb_zstream_finished_p(VALUE obj)
+{
+ return ZSTREAM_IS_FINISHED(get_zstream(obj)) ? Qtrue : Qfalse;
+}
+
+/*
+ * Returns true if the stream is closed.
+ */
+static VALUE
+rb_zstream_closed_p(VALUE obj)
+{
+ struct zstream *z;
+ TypedData_Get_Struct(obj, struct zstream, &zstream_data_type, z);
+ return ZSTREAM_IS_READY(z) ? Qfalse : Qtrue;
+}
+
+
+/* ------------------------------------------------------------------------- */
+
+/*
+ * Document-class: Zlib::Deflate
+ *
+ * Zlib::Deflate is the class for compressing data. See Zlib::ZStream for more
+ * information.
+ */
+
+#define FIXNUMARG(val, ifnil) \
+ (NIL_P((val)) ? (ifnil) \
+ : ((void)Check_Type((val), T_FIXNUM), FIX2INT((val))))
+
+#define ARG_LEVEL(val) FIXNUMARG((val), Z_DEFAULT_COMPRESSION)
+#define ARG_WBITS(val) FIXNUMARG((val), MAX_WBITS)
+#define ARG_MEMLEVEL(val) FIXNUMARG((val), DEF_MEM_LEVEL)
+#define ARG_STRATEGY(val) FIXNUMARG((val), Z_DEFAULT_STRATEGY)
+#define ARG_FLUSH(val) FIXNUMARG((val), Z_NO_FLUSH)
+
+
+static VALUE
+rb_deflate_s_allocate(VALUE klass)
+{
+ return zstream_deflate_new(klass);
+}
+
+/*
+ * Document-method: Zlib::Deflate.new
+ *
+ * call-seq:
+ * Zlib::Deflate.new(level=DEFAULT_COMPRESSION, window_bits=MAX_WBITS, mem_level=DEF_MEM_LEVEL, strategy=DEFAULT_STRATEGY)
+ *
+ * Creates a new deflate stream for compression. If a given argument is nil,
+ * the default value of that argument is used.
+ *
+ * The +level+ sets the compression level for the deflate stream between 0 (no
+ * compression) and 9 (best compression). The following constants have been
+ * defined to make code more readable:
+ *
+ * * Zlib::DEFAULT_COMPRESSION
+ * * Zlib::NO_COMPRESSION
+ * * Zlib::BEST_SPEED
+ * * Zlib::BEST_COMPRESSION
+ *
+ * See http://www.zlib.net/manual.html#Constants for further information.
+ *
+ * The +window_bits+ sets the size of the history buffer and should be between
+ * 8 and 15. Larger values of this parameter result in better compression at
+ * the expense of memory usage.
+ *
+ * The +mem_level+ specifies how much memory should be allocated for the
+ * internal compression state. 1 uses minimum memory but is slow and reduces
+ * compression ratio while 9 uses maximum memory for optimal speed. The
+ * default value is 8. Two constants are defined:
+ *
+ * * Zlib::DEF_MEM_LEVEL
+ * * Zlib::MAX_MEM_LEVEL
+ *
+ * The +strategy+ sets the deflate compression strategy. The following
+ * strategies are available:
+ *
+ * Zlib::DEFAULT_STRATEGY:: For normal data
+ * Zlib::FILTERED:: For data produced by a filter or predictor
+ * Zlib::FIXED:: Prevents dynamic Huffman codes
+ * Zlib::HUFFMAN_ONLY:: Prevents string matching
+ * Zlib::RLE:: Designed for better compression of PNG image data
+ *
+ * See the constants for further description.
+ *
+ * == Examples
+ *
+ * === Basic
+ *
+ * open "compressed.file", "w+" do |io|
+ * io << Zlib::Deflate.new.deflate(File.read("big.file"))
+ * end
+ *
+ * === Custom compression
+ *
+ * open "compressed.file", "w+" do |compressed_io|
+ * deflate = Zlib::Deflate.new(Zlib::BEST_COMPRESSION,
+ * Zlib::MAX_WBITS,
+ * Zlib::MAX_MEM_LEVEL,
+ * Zlib::HUFFMAN_ONLY)
+ *
+ * begin
+ * open "big.file" do |big_io|
+ * until big_io.eof? do
+ * compressed_io << zd.deflate(big_io.read(16384))
+ * end
+ * end
+ * ensure
+ * deflate.close
+ * end
+ * end
+ *
+ * While this example will work, for best optimization review the flags for
+ * your specific time, memory usage and output space requirements.
+ */
+static VALUE
+rb_deflate_initialize(int argc, VALUE *argv, VALUE obj)
+{
+ struct zstream *z;
+ VALUE level, wbits, memlevel, strategy;
+ int err;
+
+ rb_scan_args(argc, argv, "04", &level, &wbits, &memlevel, &strategy);
+ TypedData_Get_Struct(obj, struct zstream, &zstream_data_type, z);
+
+ err = deflateInit2(&z->stream, ARG_LEVEL(level), Z_DEFLATED,
+ ARG_WBITS(wbits), ARG_MEMLEVEL(memlevel),
+ ARG_STRATEGY(strategy));
+ if (err != Z_OK) {
+ raise_zlib_error(err, z->stream.msg);
+ }
+ ZSTREAM_READY(z);
+
+ return obj;
+}
+
+/*
+ * Document-method: Zlib::Deflate#initialize_copy
+ *
+ * Duplicates the deflate stream.
+ */
+static VALUE
+rb_deflate_init_copy(VALUE self, VALUE orig)
+{
+ struct zstream *z1, *z2;
+ int err;
+
+ TypedData_Get_Struct(self, struct zstream, &zstream_data_type, z1);
+ z2 = get_zstream(orig);
+
+ if (z1 == z2) return self;
+ err = deflateCopy(&z1->stream, &z2->stream);
+ if (err != Z_OK) {
+ raise_zlib_error(err, 0);
+ }
+ z1->input = NIL_P(z2->input) ? Qnil : rb_str_dup(z2->input);
+ z1->buf = NIL_P(z2->buf) ? Qnil : rb_str_dup(z2->buf);
+ z1->buf_filled = z2->buf_filled;
+ z1->flags = z2->flags;
+
+ return self;
+}
+
+static VALUE
+deflate_run(VALUE args)
+{
+ struct zstream *z = (struct zstream*)((VALUE*)args)[0];
+ VALUE src = ((VALUE*)args)[1];
+
+ zstream_run(z, (Bytef*)RSTRING_PTR(src), RSTRING_LEN(src), Z_FINISH);
+ return zstream_detach_buffer(z);
+}
+
+/*
+ * Document-method: Zlib::Deflate.deflate
+ *
+ * call-seq:
+ * Zlib.deflate(string[, level])
+ * Zlib::Deflate.deflate(string[, level])
+ *
+ * Compresses the given +string+. Valid values of level are
+ * Zlib::NO_COMPRESSION, Zlib::BEST_SPEED, Zlib::BEST_COMPRESSION,
+ * Zlib::DEFAULT_COMPRESSION, or an integer from 0 to 9.
+ *
+ * This method is almost equivalent to the following code:
+ *
+ * def deflate(string, level)
+ * z = Zlib::Deflate.new(level)
+ * dst = z.deflate(string, Zlib::FINISH)
+ * z.close
+ * dst
+ * end
+ *
+ * See also Zlib.inflate
+ *
+ */
+static VALUE
+rb_deflate_s_deflate(int argc, VALUE *argv, VALUE klass)
+{
+ struct zstream z;
+ VALUE src, level, dst, args[2];
+ int err, lev;
+
+ rb_scan_args(argc, argv, "11", &src, &level);
+
+ lev = ARG_LEVEL(level);
+ StringValue(src);
+ zstream_init_deflate(&z);
+ err = deflateInit(&z.stream, lev);
+ if (err != Z_OK) {
+ raise_zlib_error(err, z.stream.msg);
+ }
+ ZSTREAM_READY(&z);
+
+ args[0] = (VALUE)&z;
+ args[1] = src;
+ dst = rb_ensure(deflate_run, (VALUE)args, zstream_end, (VALUE)&z);
+
+ OBJ_INFECT(dst, src);
+ return dst;
+}
+
+static void
+do_deflate(struct zstream *z, VALUE src, int flush)
+{
+ if (NIL_P(src)) {
+ zstream_run(z, (Bytef*)"", 0, Z_FINISH);
+ return;
+ }
+ StringValue(src);
+ if (flush != Z_NO_FLUSH || RSTRING_LEN(src) > 0) { /* prevent BUF_ERROR */
+ zstream_run(z, (Bytef*)RSTRING_PTR(src), RSTRING_LEN(src), flush);
+ }
+}
+
+/*
+ * Document-method: Zlib::Deflate#deflate
+ *
+ * call-seq:
+ * z.deflate(string, flush = Zlib::NO_FLUSH) -> String
+ * z.deflate(string, flush = Zlib::NO_FLUSH) { |chunk| ... } -> nil
+ *
+ * Inputs +string+ into the deflate stream and returns the output from the
+ * stream. On calling this method, both the input and the output buffers of
+ * the stream are flushed. If +string+ is nil, this method finishes the
+ * stream, just like Zlib::ZStream#finish.
+ *
+ * If a block is given consecutive deflated chunks from the +string+ are
+ * yielded to the block and +nil+ is returned.
+ *
+ * The +flush+ parameter specifies the flush mode. The following constants
+ * may be used:
+ *
+ * Zlib::NO_FLUSH:: The default
+ * Zlib::SYNC_FLUSH:: Flushes the output to a byte boundary
+ * Zlib::FULL_FLUSH:: SYNC_FLUSH + resets the compression state
+ * Zlib::FINISH:: Pending input is processed, pending output is flushed.
+ *
+ * See the constants for further description.
+ *
+ */
+static VALUE
+rb_deflate_deflate(int argc, VALUE *argv, VALUE obj)
+{
+ struct zstream *z = get_zstream(obj);
+ VALUE src, flush;
+
+ rb_scan_args(argc, argv, "11", &src, &flush);
+ OBJ_INFECT(obj, src);
+ do_deflate(z, src, ARG_FLUSH(flush));
+
+ return zstream_detach_buffer(z);
+}
+
+/*
+ * Document-method: Zlib::Deflate#<<
+ *
+ * call-seq: << string
+ *
+ * Inputs +string+ into the deflate stream just like Zlib::Deflate#deflate, but
+ * returns the Zlib::Deflate object itself. The output from the stream is
+ * preserved in output buffer.
+ */
+static VALUE
+rb_deflate_addstr(VALUE obj, VALUE src)
+{
+ OBJ_INFECT(obj, src);
+ do_deflate(get_zstream(obj), src, Z_NO_FLUSH);
+ return obj;
+}
+
+/*
+ * Document-method: Zlib::Deflate#flush
+ *
+ * call-seq:
+ * flush(flush = Zlib::SYNC_FLUSH) -> String
+ * flush(flush = Zlib::SYNC_FLUSH) { |chunk| ... } -> nil
+ *
+ * This method is equivalent to <tt>deflate('', flush)</tt>. This method is
+ * just provided to improve the readability of your Ruby program. If a block
+ * is given chunks of deflate output are yielded to the block until the buffer
+ * is flushed.
+ *
+ * See Zlib::Deflate#deflate for detail on the +flush+ constants NO_FLUSH,
+ * SYNC_FLUSH, FULL_FLUSH and FINISH.
+ */
+static VALUE
+rb_deflate_flush(int argc, VALUE *argv, VALUE obj)
+{
+ struct zstream *z = get_zstream(obj);
+ VALUE v_flush;
+ int flush;
+
+ rb_scan_args(argc, argv, "01", &v_flush);
+ flush = FIXNUMARG(v_flush, Z_SYNC_FLUSH);
+ if (flush != Z_NO_FLUSH) { /* prevent Z_BUF_ERROR */
+ zstream_run(z, (Bytef*)"", 0, flush);
+ }
+
+ return zstream_detach_buffer(z);
+}
+
+/*
+ * Document-method: Zlib::Deflate.params
+ *
+ * call-seq: params(level, strategy)
+ *
+ * Changes the parameters of the deflate stream to allow changes between
+ * different types of data that require different types of compression. Any
+ * unprocessed data is flushed before changing the params.
+ *
+ * See Zlib::Deflate.new for a description of +level+ and +strategy+.
+ *
+ */
+static VALUE
+rb_deflate_params(VALUE obj, VALUE v_level, VALUE v_strategy)
+{
+ struct zstream *z = get_zstream(obj);
+ int level, strategy;
+ int err;
+ uInt n;
+
+ level = ARG_LEVEL(v_level);
+ strategy = ARG_STRATEGY(v_strategy);
+
+ n = z->stream.avail_out;
+ err = deflateParams(&z->stream, level, strategy);
+ z->buf_filled += n - z->stream.avail_out;
+ while (err == Z_BUF_ERROR) {
+ rb_warning("deflateParams() returned Z_BUF_ERROR");
+ zstream_expand_buffer(z);
+ n = z->stream.avail_out;
+ err = deflateParams(&z->stream, level, strategy);
+ z->buf_filled += n - z->stream.avail_out;
+ }
+ if (err != Z_OK) {
+ raise_zlib_error(err, z->stream.msg);
+ }
+
+ return Qnil;
+}
+
+/*
+ * Document-method: Zlib::Deflate.set_dictionary
+ *
+ * call-seq: set_dictionary(string)
+ *
+ * Sets the preset dictionary and returns +string+. This method is available
+ * just only after Zlib::Deflate.new or Zlib::ZStream#reset method was called.
+ * See zlib.h for details.
+ *
+ * Can raise errors of Z_STREAM_ERROR if a parameter is invalid (such as
+ * NULL dictionary) or the stream state is inconsistent, Z_DATA_ERROR if
+ * the given dictionary doesn't match the expected one (incorrect adler32 value)
+ *
+ */
+static VALUE
+rb_deflate_set_dictionary(VALUE obj, VALUE dic)
+{
+ struct zstream *z = get_zstream(obj);
+ VALUE src = dic;
+ int err;
+
+ OBJ_INFECT(obj, dic);
+ StringValue(src);
+ err = deflateSetDictionary(&z->stream,
+ (Bytef*)RSTRING_PTR(src), RSTRING_LENINT(src));
+ if (err != Z_OK) {
+ raise_zlib_error(err, z->stream.msg);
+ }
+
+ return dic;
+}
+
+
+/* ------------------------------------------------------------------------- */
+
+/*
+ * Document-class: Zlib::Inflate
+ *
+ * Zlib:Inflate is the class for decompressing compressed data. Unlike
+ * Zlib::Deflate, an instance of this class is not able to duplicate (clone,
+ * dup) itself.
+ */
+
+static VALUE
+rb_inflate_s_allocate(VALUE klass)
+{
+ VALUE inflate = zstream_inflate_new(klass);
+ rb_ivar_set(inflate, id_dictionaries, rb_hash_new());
+ return inflate;
+}
+
+/*
+ * Document-method: Zlib::Inflate.new
+ *
+ * call-seq:
+ * Zlib::Inflate.new(window_bits = Zlib::MAX_WBITS)
+ *
+ * Creates a new inflate stream for decompression. +window_bits+ sets the
+ * size of the history buffer and can have the following values:
+ *
+ * 0::
+ * Have inflate use the window size from the zlib header of the compressed
+ * stream.
+ *
+ * (8..15)::
+ * Overrides the window size of the inflate header in the compressed stream.
+ * The window size must be greater than or equal to the window size of the
+ * compressed stream.
+ *
+ * Greater than 15::
+ * Add 32 to window_bits to enable zlib and gzip decoding with automatic
+ * header detection, or add 16 to decode only the gzip format (a
+ * Zlib::DataError will be raised for a non-gzip stream).
+ *
+ * (-8..-15)::
+ * Enables raw deflate mode which will not generate a check value, and will
+ * not look for any check values for comparison at the end of the stream.
+ *
+ * This is for use with other formats that use the deflate compressed data
+ * format such as zip which provide their own check values.
+ *
+ * == Example
+ *
+ * open "compressed.file" do |compressed_io|
+ * zi = Zlib::Inflate.new(Zlib::MAX_WBITS + 32)
+ *
+ * begin
+ * open "uncompressed.file", "w+" do |uncompressed_io|
+ * uncompressed_io << zi.inflate(compressed_io.read)
+ * end
+ * ensure
+ * zi.close
+ * end
+ * end
+ *
+ */
+static VALUE
+rb_inflate_initialize(int argc, VALUE *argv, VALUE obj)
+{
+ struct zstream *z;
+ VALUE wbits;
+ int err;
+
+ rb_scan_args(argc, argv, "01", &wbits);
+ TypedData_Get_Struct(obj, struct zstream, &zstream_data_type, z);
+
+ err = inflateInit2(&z->stream, ARG_WBITS(wbits));
+ if (err != Z_OK) {
+ raise_zlib_error(err, z->stream.msg);
+ }
+ ZSTREAM_READY(z);
+
+ return obj;
+}
+
+static VALUE
+inflate_run(VALUE args)
+{
+ struct zstream *z = (struct zstream*)((VALUE*)args)[0];
+ VALUE src = ((VALUE*)args)[1];
+
+ zstream_run(z, (Bytef*)RSTRING_PTR(src), RSTRING_LEN(src), Z_SYNC_FLUSH);
+ zstream_run(z, (Bytef*)"", 0, Z_FINISH); /* for checking errors */
+ return zstream_detach_buffer(z);
+}
+
+/*
+ * Document-method: Zlib::inflate
+ *
+ * call-seq:
+ * Zlib.inflate(string)
+ * Zlib::Inflate.inflate(string)
+ *
+ * Decompresses +string+. Raises a Zlib::NeedDict exception if a preset
+ * dictionary is needed for decompression.
+ *
+ * This method is almost equivalent to the following code:
+ *
+ * def inflate(string)
+ * zstream = Zlib::Inflate.new
+ * buf = zstream.inflate(string)
+ * zstream.finish
+ * zstream.close
+ * buf
+ * end
+ *
+ * See also Zlib.deflate
+ *
+ */
+static VALUE
+rb_inflate_s_inflate(VALUE obj, VALUE src)
+{
+ struct zstream z;
+ VALUE dst, args[2];
+ int err;
+
+ StringValue(src);
+ zstream_init_inflate(&z);
+ err = inflateInit(&z.stream);
+ if (err != Z_OK) {
+ raise_zlib_error(err, z.stream.msg);
+ }
+ ZSTREAM_READY(&z);
+
+ args[0] = (VALUE)&z;
+ args[1] = src;
+ dst = rb_ensure(inflate_run, (VALUE)args, zstream_end, (VALUE)&z);
+
+ OBJ_INFECT(dst, src);
+ return dst;
+}
+
+static void
+do_inflate(struct zstream *z, VALUE src)
+{
+ if (NIL_P(src)) {
+ zstream_run(z, (Bytef*)"", 0, Z_FINISH);
+ return;
+ }
+ StringValue(src);
+ if (RSTRING_LEN(src) > 0 || z->stream.avail_in > 0) { /* prevent Z_BUF_ERROR */
+ zstream_run(z, (Bytef*)RSTRING_PTR(src), RSTRING_LEN(src), Z_SYNC_FLUSH);
+ }
+}
+
+/* Document-method: Zlib::Inflate#add_dictionary
+ *
+ * call-seq: add_dictionary(string)
+ *
+ * Provide the inflate stream with a dictionary that may be required in the
+ * future. Multiple dictionaries may be provided. The inflate stream will
+ * automatically choose the correct user-provided dictionary based on the
+ * stream's required dictionary.
+ */
+static VALUE
+rb_inflate_add_dictionary(VALUE obj, VALUE dictionary) {
+ VALUE dictionaries = rb_ivar_get(obj, id_dictionaries);
+ VALUE checksum = do_checksum(1, &dictionary, adler32);
+
+ rb_hash_aset(dictionaries, checksum, dictionary);
+
+ return obj;
+}
+
+/*
+ * Document-method: Zlib::Inflate#inflate
+ *
+ * call-seq:
+ * inflate(deflate_string) -> String
+ * inflate(deflate_string) { |chunk| ... } -> nil
+ *
+ * Inputs +deflate_string+ into the inflate stream and returns the output from
+ * the stream. Calling this method, both the input and the output buffer of
+ * the stream are flushed. If string is +nil+, this method finishes the
+ * stream, just like Zlib::ZStream#finish.
+ *
+ * If a block is given consecutive inflated chunks from the +deflate_string+
+ * are yielded to the block and +nil+ is returned.
+ *
+ * Raises a Zlib::NeedDict exception if a preset dictionary is needed to
+ * decompress. Set the dictionary by Zlib::Inflate#set_dictionary and then
+ * call this method again with an empty string to flush the stream:
+ *
+ * inflater = Zlib::Inflate.new
+ *
+ * begin
+ * out = inflater.inflate compressed
+ * rescue Zlib::NeedDict
+ * # ensure the dictionary matches the stream's required dictionary
+ * raise unless inflater.adler == Zlib.adler32(dictionary)
+ *
+ * inflater.set_dictionary dictionary
+ * inflater.inflate ''
+ * end
+ *
+ * # ...
+ *
+ * inflater.close
+ *
+ * See also Zlib::Inflate.new
+ */
+static VALUE
+rb_inflate_inflate(VALUE obj, VALUE src)
+{
+ struct zstream *z = get_zstream(obj);
+ VALUE dst;
+
+ OBJ_INFECT(obj, src);
+
+ if (ZSTREAM_IS_FINISHED(z)) {
+ if (NIL_P(src)) {
+ dst = zstream_detach_buffer(z);
+ }
+ else {
+ StringValue(src);
+ zstream_append_buffer2(z, src);
+ dst = rb_str_new(0, 0);
+ OBJ_INFECT(dst, obj);
+ }
+ }
+ else {
+ do_inflate(z, src);
+ dst = zstream_detach_buffer(z);
+ if (ZSTREAM_IS_FINISHED(z)) {
+ zstream_passthrough_input(z);
+ }
+ }
+
+ return dst;
+}
+
+/*
+ * call-seq: << string
+ *
+ * Inputs +string+ into the inflate stream just like Zlib::Inflate#inflate, but
+ * returns the Zlib::Inflate object itself. The output from the stream is
+ * preserved in output buffer.
+ */
+static VALUE
+rb_inflate_addstr(VALUE obj, VALUE src)
+{
+ struct zstream *z = get_zstream(obj);
+
+ OBJ_INFECT(obj, src);
+
+ if (ZSTREAM_IS_FINISHED(z)) {
+ if (!NIL_P(src)) {
+ StringValue(src);
+ zstream_append_buffer2(z, src);
+ }
+ }
+ else {
+ do_inflate(z, src);
+ if (ZSTREAM_IS_FINISHED(z)) {
+ zstream_passthrough_input(z);
+ }
+ }
+
+ return obj;
+}
+
+/*
+ * call-seq: sync(string)
+ *
+ * Inputs +string+ into the end of input buffer and skips data until a full
+ * flush point can be found. If the point is found in the buffer, this method
+ * flushes the buffer and returns false. Otherwise it returns +true+ and the
+ * following data of full flush point is preserved in the buffer.
+ */
+static VALUE
+rb_inflate_sync(VALUE obj, VALUE src)
+{
+ struct zstream *z = get_zstream(obj);
+
+ OBJ_INFECT(obj, src);
+ StringValue(src);
+ return zstream_sync(z, (Bytef*)RSTRING_PTR(src), RSTRING_LEN(src));
+}
+
+/*
+ * Quoted verbatim from original documentation:
+ *
+ * What is this?
+ *
+ * <tt>:)</tt>
+ */
+static VALUE
+rb_inflate_sync_point_p(VALUE obj)
+{
+ struct zstream *z = get_zstream(obj);
+ int err;
+
+ err = inflateSyncPoint(&z->stream);
+ if (err == 1) {
+ return Qtrue;
+ }
+ if (err != Z_OK) {
+ raise_zlib_error(err, z->stream.msg);
+ }
+ return Qfalse;
+}
+
+/*
+ * Document-method: Zlib::Inflate#set_dictionary
+ *
+ * Sets the preset dictionary and returns +string+. This method is available just
+ * only after a Zlib::NeedDict exception was raised. See zlib.h for details.
+ *
+ */
+static VALUE
+rb_inflate_set_dictionary(VALUE obj, VALUE dic)
+{
+ struct zstream *z = get_zstream(obj);
+ VALUE src = dic;
+ int err;
+
+ OBJ_INFECT(obj, dic);
+ StringValue(src);
+ err = inflateSetDictionary(&z->stream,
+ (Bytef*)RSTRING_PTR(src), RSTRING_LENINT(src));
+ if (err != Z_OK) {
+ raise_zlib_error(err, z->stream.msg);
+ }
+
+ return dic;
+}
+
+
+
+#if GZIP_SUPPORT
+
+/* NOTE: Features for gzip files of Ruby/zlib are written from scratch
+ * and using undocumented feature of zlib, negative wbits.
+ * I don't think gzFile APIs of zlib are good for Ruby.
+ */
+
+/*------- .gz file header --------*/
+
+#define GZ_MAGIC1 0x1f
+#define GZ_MAGIC2 0x8b
+#define GZ_METHOD_DEFLATE 8
+#define GZ_FLAG_MULTIPART 0x2
+#define GZ_FLAG_EXTRA 0x4
+#define GZ_FLAG_ORIG_NAME 0x8
+#define GZ_FLAG_COMMENT 0x10
+#define GZ_FLAG_ENCRYPT 0x20
+#define GZ_FLAG_UNKNOWN_MASK 0xc0
+
+#define GZ_EXTRAFLAG_FAST 0x4
+#define GZ_EXTRAFLAG_SLOW 0x2
+
+/* from zutil.h */
+#define OS_MSDOS 0x00
+#define OS_AMIGA 0x01
+#define OS_VMS 0x02
+#define OS_UNIX 0x03
+#define OS_ATARI 0x05
+#define OS_OS2 0x06
+#define OS_MACOS 0x07
+#define OS_TOPS20 0x0a
+#define OS_WIN32 0x0b
+
+#define OS_VMCMS 0x04
+#define OS_ZSYSTEM 0x08
+#define OS_CPM 0x09
+#define OS_QDOS 0x0c
+#define OS_RISCOS 0x0d
+#define OS_UNKNOWN 0xff
+
+#ifndef OS_CODE
+#define OS_CODE OS_UNIX
+#endif
+
+static ID id_write, id_read, id_readpartial, id_flush, id_seek, id_close, id_path, id_input;
+static VALUE cGzError, cNoFooter, cCRCError, cLengthError;
+
+
+
+/*-------- gzfile internal APIs --------*/
+
+struct gzfile {
+ struct zstream z;
+ VALUE io;
+ int level;
+ int os_code; /* for header */
+ time_t mtime; /* for header */
+ VALUE orig_name; /* for header; must be a String */
+ VALUE comment; /* for header; must be a String */
+ unsigned long crc;
+ int ecflags;
+ int lineno;
+ long ungetc;
+ void (*end)(struct gzfile *);
+ rb_encoding *enc;
+ rb_encoding *enc2;
+ rb_econv_t *ec;
+ VALUE ecopts;
+ char *cbuf;
+ VALUE path;
+};
+#define GZFILE_CBUF_CAPA 10
+
+#define GZFILE_FLAG_SYNC ZSTREAM_FLAG_UNUSED
+#define GZFILE_FLAG_HEADER_FINISHED (ZSTREAM_FLAG_UNUSED << 1)
+#define GZFILE_FLAG_FOOTER_FINISHED (ZSTREAM_FLAG_UNUSED << 2)
+
+#define GZFILE_IS_FINISHED(gz) \
+ (ZSTREAM_IS_FINISHED(&(gz)->z) && (gz)->z.buf_filled == 0)
+
+#define GZFILE_READ_SIZE 2048
+
+
+static void
+gzfile_mark(void *p)
+{
+ struct gzfile *gz = p;
+
+ rb_gc_mark(gz->io);
+ rb_gc_mark(gz->orig_name);
+ rb_gc_mark(gz->comment);
+ zstream_mark(&gz->z);
+ rb_gc_mark(gz->ecopts);
+ rb_gc_mark(gz->path);
+}
+
+static void
+gzfile_free(void *p)
+{
+ struct gzfile *gz = p;
+ struct zstream *z = &gz->z;
+
+ if (ZSTREAM_IS_READY(z)) {
+ if (z->func == &deflate_funcs) {
+ finalizer_warn("Zlib::GzipWriter object must be closed explicitly.");
+ }
+ zstream_finalize(z);
+ }
+ if (gz->cbuf) {
+ xfree(gz->cbuf);
+ }
+ xfree(gz);
+}
+
+static size_t
+gzfile_memsize(const void *p)
+{
+ const struct gzfile *gz = p;
+ size_t size = sizeof(struct gzfile);
+
+ if (gz->cbuf)
+ size += GZFILE_CBUF_CAPA;
+
+ return size;
+}
+
+static const rb_data_type_t gzfile_data_type = {
+ "gzfile",
+ { gzfile_mark, gzfile_free, gzfile_memsize, },
+ 0, 0, RUBY_TYPED_FREE_IMMEDIATELY
+};
+
+static VALUE
+gzfile_new(klass, funcs, endfunc)
+ VALUE klass;
+ const struct zstream_funcs *funcs;
+ void (*endfunc)(struct gzfile *);
+{
+ VALUE obj;
+ struct gzfile *gz;
+
+ obj = TypedData_Make_Struct(klass, struct gzfile, &gzfile_data_type, gz);
+ zstream_init(&gz->z, funcs);
+ gz->z.flags |= ZSTREAM_FLAG_GZFILE;
+ gz->io = Qnil;
+ gz->level = 0;
+ gz->mtime = 0;
+ gz->os_code = OS_CODE;
+ gz->orig_name = Qnil;
+ gz->comment = Qnil;
+ gz->crc = crc32(0, Z_NULL, 0);
+ gz->lineno = 0;
+ gz->ungetc = 0;
+ gz->end = endfunc;
+ gz->enc = rb_default_external_encoding();
+ gz->enc2 = 0;
+ gz->ec = NULL;
+ gz->ecflags = 0;
+ gz->ecopts = Qnil;
+ gz->cbuf = 0;
+ gz->path = Qnil;
+
+ return obj;
+}
+
+#define gzfile_writer_new(gz) gzfile_new((gz),&deflate_funcs,gzfile_writer_end)
+#define gzfile_reader_new(gz) gzfile_new((gz),&inflate_funcs,gzfile_reader_end)
+
+static void
+gzfile_reset(struct gzfile *gz)
+{
+ zstream_reset(&gz->z);
+ gz->z.flags |= ZSTREAM_FLAG_GZFILE;
+ gz->crc = crc32(0, Z_NULL, 0);
+ gz->lineno = 0;
+ gz->ungetc = 0;
+ if (gz->ec) {
+ rb_econv_close(gz->ec);
+ gz->ec = rb_econv_open_opts(gz->enc2->name, gz->enc->name,
+ gz->ecflags, gz->ecopts);
+ }
+}
+
+static void
+gzfile_close(struct gzfile *gz, int closeflag)
+{
+ VALUE io = gz->io;
+
+ gz->end(gz);
+ gz->io = Qnil;
+ gz->orig_name = Qnil;
+ gz->comment = Qnil;
+ if (closeflag && rb_respond_to(io, id_close)) {
+ rb_funcall(io, id_close, 0);
+ }
+}
+
+static void
+gzfile_write_raw(struct gzfile *gz)
+{
+ VALUE str;
+
+ if (gz->z.buf_filled > 0) {
+ str = zstream_detach_buffer(&gz->z);
+ OBJ_TAINT(str); /* for safe */
+ rb_funcall(gz->io, id_write, 1, str);
+ if ((gz->z.flags & GZFILE_FLAG_SYNC)
+ && rb_respond_to(gz->io, id_flush))
+ rb_funcall(gz->io, id_flush, 0);
+ }
+}
+
+static VALUE
+gzfile_read_raw_partial(VALUE arg)
+{
+ struct gzfile *gz = (struct gzfile*)arg;
+ VALUE str;
+
+ str = rb_funcall(gz->io, id_readpartial, 1, INT2FIX(GZFILE_READ_SIZE));
+ Check_Type(str, T_STRING);
+ return str;
+}
+
+static VALUE
+gzfile_read_raw_rescue(VALUE arg)
+{
+ struct gzfile *gz = (struct gzfile*)arg;
+ VALUE str = Qnil;
+ if (rb_obj_is_kind_of(rb_errinfo(), rb_eNoMethodError)) {
+ str = rb_funcall(gz->io, id_read, 1, INT2FIX(GZFILE_READ_SIZE));
+ if (!NIL_P(str)) {
+ Check_Type(str, T_STRING);
+ }
+ }
+ return str; /* return nil when EOFError */
+}
+
+static VALUE
+gzfile_read_raw(struct gzfile *gz)
+{
+ return rb_rescue2(gzfile_read_raw_partial, (VALUE)gz,
+ gzfile_read_raw_rescue, (VALUE)gz,
+ rb_eEOFError, rb_eNoMethodError, (VALUE)0);
+}
+
+static int
+gzfile_read_raw_ensure(struct gzfile *gz, long size)
+{
+ VALUE str;
+
+ while (NIL_P(gz->z.input) || RSTRING_LEN(gz->z.input) < size) {
+ str = gzfile_read_raw(gz);
+ if (NIL_P(str)) return 0;
+ zstream_append_input2(&gz->z, str);
+ }
+ return 1;
+}
+
+static char *
+gzfile_read_raw_until_zero(struct gzfile *gz, long offset)
+{
+ VALUE str;
+ char *p;
+
+ for (;;) {
+ p = memchr(RSTRING_PTR(gz->z.input) + offset, '\0',
+ RSTRING_LEN(gz->z.input) - offset);
+ if (p) break;
+ str = gzfile_read_raw(gz);
+ if (NIL_P(str)) {
+ rb_raise(cGzError, "unexpected end of file");
+ }
+ offset = RSTRING_LEN(gz->z.input);
+ zstream_append_input2(&gz->z, str);
+ }
+ return p;
+}
+
+static unsigned int
+gzfile_get16(const unsigned char *src)
+{
+ unsigned int n;
+ n = *(src++) & 0xff;
+ n |= (*(src++) & 0xff) << 8;
+ return n;
+}
+
+static unsigned long
+gzfile_get32(const unsigned char *src)
+{
+ unsigned long n;
+ n = *(src++) & 0xff;
+ n |= (*(src++) & 0xff) << 8;
+ n |= (*(src++) & 0xff) << 16;
+ n |= (*(src++) & 0xffU) << 24;
+ return n;
+}
+
+static void
+gzfile_set32(unsigned long n, unsigned char *dst)
+{
+ *(dst++) = n & 0xff;
+ *(dst++) = (n >> 8) & 0xff;
+ *(dst++) = (n >> 16) & 0xff;
+ *dst = (n >> 24) & 0xff;
+}
+
+static void
+gzfile_raise(struct gzfile *gz, VALUE klass, const char *message)
+{
+ VALUE exc = rb_exc_new2(klass, message);
+ if (!NIL_P(gz->z.input)) {
+ rb_ivar_set(exc, id_input, rb_str_resurrect(gz->z.input));
+ }
+ rb_exc_raise(exc);
+}
+
+/*
+ * Document-method: Zlib::GzipFile::Error#inspect
+ *
+ * Constructs a String of the GzipFile Error
+ */
+static VALUE
+gzfile_error_inspect(VALUE error)
+{
+ VALUE str = rb_call_super(0, 0);
+ VALUE input = rb_attr_get(error, id_input);
+
+ if (!NIL_P(input)) {
+ rb_str_resize(str, RSTRING_LEN(str)-1);
+ rb_str_cat2(str, ", input=");
+ rb_str_append(str, rb_str_inspect(input));
+ rb_str_cat2(str, ">");
+ }
+ return str;
+}
+
+static void
+gzfile_make_header(struct gzfile *gz)
+{
+ Bytef buf[10]; /* the size of gzip header */
+ unsigned char flags = 0, extraflags = 0;
+
+ if (!NIL_P(gz->orig_name)) {
+ flags |= GZ_FLAG_ORIG_NAME;
+ }
+ if (!NIL_P(gz->comment)) {
+ flags |= GZ_FLAG_COMMENT;
+ }
+ if (gz->mtime == 0) {
+ gz->mtime = time(0);
+ }
+
+ if (gz->level == Z_BEST_SPEED) {
+ extraflags |= GZ_EXTRAFLAG_FAST;
+ }
+ else if (gz->level == Z_BEST_COMPRESSION) {
+ extraflags |= GZ_EXTRAFLAG_SLOW;
+ }
+
+ buf[0] = GZ_MAGIC1;
+ buf[1] = GZ_MAGIC2;
+ buf[2] = GZ_METHOD_DEFLATE;
+ buf[3] = flags;
+ gzfile_set32((unsigned long)gz->mtime, &buf[4]);
+ buf[8] = extraflags;
+ buf[9] = gz->os_code;
+ zstream_append_buffer(&gz->z, buf, sizeof(buf));
+
+ if (!NIL_P(gz->orig_name)) {
+ zstream_append_buffer2(&gz->z, gz->orig_name);
+ zstream_append_buffer(&gz->z, (Bytef*)"\0", 1);
+ }
+ if (!NIL_P(gz->comment)) {
+ zstream_append_buffer2(&gz->z, gz->comment);
+ zstream_append_buffer(&gz->z, (Bytef*)"\0", 1);
+ }
+
+ gz->z.flags |= GZFILE_FLAG_HEADER_FINISHED;
+}
+
+static void
+gzfile_make_footer(struct gzfile *gz)
+{
+ Bytef buf[8]; /* 8 is the size of gzip footer */
+
+ gzfile_set32(gz->crc, buf);
+ gzfile_set32(gz->z.stream.total_in, &buf[4]);
+ zstream_append_buffer(&gz->z, buf, sizeof(buf));
+ gz->z.flags |= GZFILE_FLAG_FOOTER_FINISHED;
+}
+
+static void
+gzfile_read_header(struct gzfile *gz)
+{
+ const unsigned char *head;
+ long len;
+ char flags, *p;
+
+ if (!gzfile_read_raw_ensure(gz, 10)) { /* 10 is the size of gzip header */
+ gzfile_raise(gz, cGzError, "not in gzip format");
+ }
+
+ head = (unsigned char*)RSTRING_PTR(gz->z.input);
+
+ if (head[0] != GZ_MAGIC1 || head[1] != GZ_MAGIC2) {
+ gzfile_raise(gz, cGzError, "not in gzip format");
+ }
+ if (head[2] != GZ_METHOD_DEFLATE) {
+ rb_raise(cGzError, "unsupported compression method %d", head[2]);
+ }
+
+ flags = head[3];
+ if (flags & GZ_FLAG_MULTIPART) {
+ rb_raise(cGzError, "multi-part gzip file is not supported");
+ }
+ else if (flags & GZ_FLAG_ENCRYPT) {
+ rb_raise(cGzError, "encrypted gzip file is not supported");
+ }
+ else if (flags & GZ_FLAG_UNKNOWN_MASK) {
+ rb_raise(cGzError, "unknown flags 0x%02x", flags);
+ }
+
+ if (head[8] & GZ_EXTRAFLAG_FAST) {
+ gz->level = Z_BEST_SPEED;
+ }
+ else if (head[8] & GZ_EXTRAFLAG_SLOW) {
+ gz->level = Z_BEST_COMPRESSION;
+ }
+ else {
+ gz->level = Z_DEFAULT_COMPRESSION;
+ }
+
+ gz->mtime = gzfile_get32(&head[4]);
+ gz->os_code = head[9];
+ zstream_discard_input(&gz->z, 10);
+
+ if (flags & GZ_FLAG_EXTRA) {
+ if (!gzfile_read_raw_ensure(gz, 2)) {
+ rb_raise(cGzError, "unexpected end of file");
+ }
+ len = gzfile_get16((Bytef*)RSTRING_PTR(gz->z.input));
+ if (!gzfile_read_raw_ensure(gz, 2 + len)) {
+ rb_raise(cGzError, "unexpected end of file");
+ }
+ zstream_discard_input(&gz->z, 2 + len);
+ }
+ if (flags & GZ_FLAG_ORIG_NAME) {
+ if (!gzfile_read_raw_ensure(gz, 1)) {
+ rb_raise(cGzError, "unexpected end of file");
+ }
+ p = gzfile_read_raw_until_zero(gz, 0);
+ len = p - RSTRING_PTR(gz->z.input);
+ gz->orig_name = rb_str_new(RSTRING_PTR(gz->z.input), len);
+ OBJ_TAINT(gz->orig_name); /* for safe */
+ zstream_discard_input(&gz->z, len + 1);
+ }
+ if (flags & GZ_FLAG_COMMENT) {
+ if (!gzfile_read_raw_ensure(gz, 1)) {
+ rb_raise(cGzError, "unexpected end of file");
+ }
+ p = gzfile_read_raw_until_zero(gz, 0);
+ len = p - RSTRING_PTR(gz->z.input);
+ gz->comment = rb_str_new(RSTRING_PTR(gz->z.input), len);
+ OBJ_TAINT(gz->comment); /* for safe */
+ zstream_discard_input(&gz->z, len + 1);
+ }
+
+ if (gz->z.input != Qnil && RSTRING_LEN(gz->z.input) > 0) {
+ zstream_run(&gz->z, 0, 0, Z_SYNC_FLUSH);
+ }
+}
+
+static void
+gzfile_check_footer(struct gzfile *gz)
+{
+ unsigned long crc, length;
+
+ gz->z.flags |= GZFILE_FLAG_FOOTER_FINISHED;
+
+ if (!gzfile_read_raw_ensure(gz, 8)) { /* 8 is the size of gzip footer */
+ gzfile_raise(gz, cNoFooter, "footer is not found");
+ }
+
+ crc = gzfile_get32((Bytef*)RSTRING_PTR(gz->z.input));
+ length = gzfile_get32((Bytef*)RSTRING_PTR(gz->z.input) + 4);
+
+ gz->z.stream.total_in += 8; /* to rewind correctly */
+ zstream_discard_input(&gz->z, 8);
+
+ if (gz->crc != crc) {
+ rb_raise(cCRCError, "invalid compressed data -- crc error");
+ }
+ if ((uint32_t)gz->z.stream.total_out != length) {
+ rb_raise(cLengthError, "invalid compressed data -- length error");
+ }
+}
+
+static void
+gzfile_write(struct gzfile *gz, Bytef *str, long len)
+{
+ if (!(gz->z.flags & GZFILE_FLAG_HEADER_FINISHED)) {
+ gzfile_make_header(gz);
+ }
+
+ if (len > 0 || (gz->z.flags & GZFILE_FLAG_SYNC)) {
+ gz->crc = checksum_long(crc32, gz->crc, str, len);
+ zstream_run(&gz->z, str, len, (gz->z.flags & GZFILE_FLAG_SYNC)
+ ? Z_SYNC_FLUSH : Z_NO_FLUSH);
+ }
+ gzfile_write_raw(gz);
+}
+
+static long
+gzfile_read_more(struct gzfile *gz)
+{
+ volatile VALUE str;
+
+ while (!ZSTREAM_IS_FINISHED(&gz->z)) {
+ str = gzfile_read_raw(gz);
+ if (NIL_P(str)) {
+ if (!ZSTREAM_IS_FINISHED(&gz->z)) {
+ rb_raise(cGzError, "unexpected end of file");
+ }
+ break;
+ }
+ if (RSTRING_LEN(str) > 0) { /* prevent Z_BUF_ERROR */
+ zstream_run(&gz->z, (Bytef*)RSTRING_PTR(str), RSTRING_LEN(str),
+ Z_SYNC_FLUSH);
+ }
+ if (gz->z.buf_filled > 0) break;
+ }
+ return gz->z.buf_filled;
+}
+
+static void
+gzfile_calc_crc(struct gzfile *gz, VALUE str)
+{
+ if (RSTRING_LEN(str) <= gz->ungetc) {
+ gz->ungetc -= RSTRING_LEN(str);
+ }
+ else {
+ gz->crc = checksum_long(crc32, gz->crc, (Bytef*)RSTRING_PTR(str) + gz->ungetc,
+ RSTRING_LEN(str) - gz->ungetc);
+ gz->ungetc = 0;
+ }
+}
+
+static VALUE
+gzfile_newstr(struct gzfile *gz, VALUE str)
+{
+ if (!gz->enc2) {
+ rb_enc_associate(str, gz->enc);
+ OBJ_TAINT(str); /* for safe */
+ return str;
+ }
+ if (gz->ec && rb_enc_dummy_p(gz->enc2)) {
+ str = rb_econv_str_convert(gz->ec, str, ECONV_PARTIAL_INPUT);
+ rb_enc_associate(str, gz->enc);
+ OBJ_TAINT(str);
+ return str;
+ }
+ return rb_str_conv_enc_opts(str, gz->enc2, gz->enc,
+ gz->ecflags, gz->ecopts);
+}
+
+static long
+gzfile_fill(struct gzfile *gz, long len)
+{
+ if (len < 0)
+ rb_raise(rb_eArgError, "negative length %ld given", len);
+ if (len == 0)
+ return 0;
+ while (!ZSTREAM_IS_FINISHED(&gz->z) && gz->z.buf_filled < len) {
+ gzfile_read_more(gz);
+ }
+ if (GZFILE_IS_FINISHED(gz)) {
+ if (!(gz->z.flags & GZFILE_FLAG_FOOTER_FINISHED)) {
+ gzfile_check_footer(gz);
+ }
+ return -1;
+ }
+ return len < gz->z.buf_filled ? len : gz->z.buf_filled;
+}
+
+static VALUE
+gzfile_read(struct gzfile *gz, long len)
+{
+ VALUE dst;
+
+ len = gzfile_fill(gz, len);
+ if (len == 0) return rb_str_new(0, 0);
+ if (len < 0) return Qnil;
+ dst = zstream_shift_buffer(&gz->z, len);
+ if (!NIL_P(dst)) gzfile_calc_crc(gz, dst);
+ return dst;
+}
+
+static VALUE
+gzfile_readpartial(struct gzfile *gz, long len, VALUE outbuf)
+{
+ VALUE dst;
+
+ if (len < 0)
+ rb_raise(rb_eArgError, "negative length %ld given", len);
+
+ if (!NIL_P(outbuf))
+ OBJ_TAINT(outbuf);
+
+ if (len == 0) {
+ if (NIL_P(outbuf))
+ return rb_str_new(0, 0);
+ else {
+ rb_str_resize(outbuf, 0);
+ return outbuf;
+ }
+ }
+ while (!ZSTREAM_IS_FINISHED(&gz->z) && gz->z.buf_filled == 0) {
+ gzfile_read_more(gz);
+ }
+ if (GZFILE_IS_FINISHED(gz)) {
+ if (!(gz->z.flags & GZFILE_FLAG_FOOTER_FINISHED)) {
+ gzfile_check_footer(gz);
+ }
+ if (!NIL_P(outbuf))
+ rb_str_resize(outbuf, 0);
+ rb_raise(rb_eEOFError, "end of file reached");
+ }
+
+ dst = zstream_shift_buffer(&gz->z, len);
+ gzfile_calc_crc(gz, dst);
+
+ if (!NIL_P(outbuf)) {
+ rb_str_resize(outbuf, RSTRING_LEN(dst));
+ memcpy(RSTRING_PTR(outbuf), RSTRING_PTR(dst), RSTRING_LEN(dst));
+ dst = outbuf;
+ }
+ OBJ_TAINT(dst); /* for safe */
+ return dst;
+}
+
+static VALUE
+gzfile_read_all(struct gzfile *gz)
+{
+ VALUE dst;
+
+ while (!ZSTREAM_IS_FINISHED(&gz->z)) {
+ gzfile_read_more(gz);
+ }
+ if (GZFILE_IS_FINISHED(gz)) {
+ if (!(gz->z.flags & GZFILE_FLAG_FOOTER_FINISHED)) {
+ gzfile_check_footer(gz);
+ }
+ return rb_str_new(0, 0);
+ }
+
+ dst = zstream_detach_buffer(&gz->z);
+ if (NIL_P(dst)) return dst;
+ gzfile_calc_crc(gz, dst);
+ OBJ_TAINT(dst);
+ return gzfile_newstr(gz, dst);
+}
+
+static VALUE
+gzfile_getc(struct gzfile *gz)
+{
+ VALUE buf, dst = 0;
+ int len;
+
+ len = rb_enc_mbmaxlen(gz->enc);
+ while (!ZSTREAM_IS_FINISHED(&gz->z) && gz->z.buf_filled < len) {
+ gzfile_read_more(gz);
+ }
+ if (GZFILE_IS_FINISHED(gz)) {
+ if (!(gz->z.flags & GZFILE_FLAG_FOOTER_FINISHED)) {
+ gzfile_check_footer(gz);
+ }
+ return Qnil;
+ }
+
+ if (gz->ec && rb_enc_dummy_p(gz->enc2)) {
+ const unsigned char *ss, *sp, *se;
+ unsigned char *ds, *dp, *de;
+
+ if (!gz->cbuf) {
+ gz->cbuf = ALLOC_N(char, GZFILE_CBUF_CAPA);
+ }
+ ss = sp = (const unsigned char*)RSTRING_PTR(gz->z.buf);
+ se = sp + gz->z.buf_filled;
+ ds = dp = (unsigned char *)gz->cbuf;
+ de = (unsigned char *)ds + GZFILE_CBUF_CAPA;
+ (void)rb_econv_convert(gz->ec, &sp, se, &dp, de, ECONV_PARTIAL_INPUT|ECONV_AFTER_OUTPUT);
+ rb_econv_check_error(gz->ec);
+ dst = zstream_shift_buffer(&gz->z, sp - ss);
+ gzfile_calc_crc(gz, dst);
+ dst = rb_str_new(gz->cbuf, dp - ds);
+ rb_enc_associate(dst, gz->enc);
+ OBJ_TAINT(dst);
+ return dst;
+ }
+ else {
+ buf = gz->z.buf;
+ len = rb_enc_mbclen(RSTRING_PTR(buf), RSTRING_END(buf), gz->enc);
+ dst = gzfile_read(gz, len);
+ if (NIL_P(dst)) return dst;
+ return gzfile_newstr(gz, dst);
+ }
+}
+
+static void
+gzfile_ungets(struct gzfile *gz, const Bytef *b, long len)
+{
+ zstream_buffer_ungets(&gz->z, b, len);
+ gz->ungetc+=len;
+}
+
+static void
+gzfile_ungetbyte(struct gzfile *gz, int c)
+{
+ zstream_buffer_ungetbyte(&gz->z, c);
+ gz->ungetc++;
+}
+
+static VALUE
+gzfile_writer_end_run(VALUE arg)
+{
+ struct gzfile *gz = (struct gzfile *)arg;
+
+ if (!(gz->z.flags & GZFILE_FLAG_HEADER_FINISHED)) {
+ gzfile_make_header(gz);
+ }
+
+ zstream_run(&gz->z, (Bytef*)"", 0, Z_FINISH);
+ gzfile_make_footer(gz);
+ gzfile_write_raw(gz);
+
+ return Qnil;
+}
+
+static void
+gzfile_writer_end(struct gzfile *gz)
+{
+ if (ZSTREAM_IS_CLOSING(&gz->z)) return;
+ gz->z.flags |= ZSTREAM_FLAG_CLOSING;
+
+ rb_ensure(gzfile_writer_end_run, (VALUE)gz, zstream_end, (VALUE)&gz->z);
+}
+
+static VALUE
+gzfile_reader_end_run(VALUE arg)
+{
+ struct gzfile *gz = (struct gzfile *)arg;
+
+ if (GZFILE_IS_FINISHED(gz)
+ && !(gz->z.flags & GZFILE_FLAG_FOOTER_FINISHED)) {
+ gzfile_check_footer(gz);
+ }
+
+ return Qnil;
+}
+
+static void
+gzfile_reader_end(struct gzfile *gz)
+{
+ if (ZSTREAM_IS_CLOSING(&gz->z)) return;
+ gz->z.flags |= ZSTREAM_FLAG_CLOSING;
+
+ rb_ensure(gzfile_reader_end_run, (VALUE)gz, zstream_end, (VALUE)&gz->z);
+}
+
+static void
+gzfile_reader_rewind(struct gzfile *gz)
+{
+ long n;
+
+ n = gz->z.stream.total_in;
+ if (!NIL_P(gz->z.input)) {
+ n += RSTRING_LEN(gz->z.input);
+ }
+
+ rb_funcall(gz->io, id_seek, 2, rb_int2inum(-n), INT2FIX(1));
+ gzfile_reset(gz);
+}
+
+static VALUE
+gzfile_reader_get_unused(struct gzfile *gz)
+{
+ VALUE str;
+
+ if (!ZSTREAM_IS_READY(&gz->z)) return Qnil;
+ if (!GZFILE_IS_FINISHED(gz)) return Qnil;
+ if (!(gz->z.flags & GZFILE_FLAG_FOOTER_FINISHED)) {
+ gzfile_check_footer(gz);
+ }
+ if (NIL_P(gz->z.input)) return Qnil;
+
+ str = rb_str_resurrect(gz->z.input);
+ OBJ_TAINT(str); /* for safe */
+ return str;
+}
+
+static struct gzfile *
+get_gzfile(VALUE obj)
+{
+ struct gzfile *gz;
+
+ TypedData_Get_Struct(obj, struct gzfile, &gzfile_data_type, gz);
+ if (!ZSTREAM_IS_READY(&gz->z)) {
+ rb_raise(cGzError, "closed gzip stream");
+ }
+ return gz;
+}
+
+
+/* ------------------------------------------------------------------------- */
+
+/*
+ * Document-class: Zlib::GzipFile
+ *
+ * Zlib::GzipFile is an abstract class for handling a gzip formatted
+ * compressed file. The operations are defined in the subclasses,
+ * Zlib::GzipReader for reading, and Zlib::GzipWriter for writing.
+ *
+ * GzipReader should be used by associating an IO, or IO-like, object.
+ *
+ * == Method Catalogue
+ *
+ * - ::wrap
+ * - ::open (Zlib::GzipReader::open and Zlib::GzipWriter::open)
+ * - #close
+ * - #closed?
+ * - #comment
+ * - comment= (Zlib::GzipWriter#comment=)
+ * - #crc
+ * - eof? (Zlib::GzipReader#eof?)
+ * - #finish
+ * - #level
+ * - lineno (Zlib::GzipReader#lineno)
+ * - lineno= (Zlib::GzipReader#lineno=)
+ * - #mtime
+ * - mtime= (Zlib::GzipWriter#mtime=)
+ * - #orig_name
+ * - orig_name (Zlib::GzipWriter#orig_name=)
+ * - #os_code
+ * - path (when the underlying IO supports #path)
+ * - #sync
+ * - #sync=
+ * - #to_io
+ *
+ * (due to internal structure, documentation may appear under Zlib::GzipReader
+ * or Zlib::GzipWriter)
+ */
+
+
+typedef struct {
+ int argc;
+ VALUE *argv;
+ VALUE klass;
+} new_wrap_arg_t;
+
+static VALUE
+new_wrap(VALUE tmp)
+{
+ new_wrap_arg_t *arg = (new_wrap_arg_t *)tmp;
+ return rb_class_new_instance(arg->argc, arg->argv, arg->klass);
+}
+
+static VALUE
+gzfile_ensure_close(VALUE obj)
+{
+ struct gzfile *gz;
+
+ TypedData_Get_Struct(obj, struct gzfile, &gzfile_data_type, gz);
+ if (ZSTREAM_IS_READY(&gz->z)) {
+ gzfile_close(gz, 1);
+ }
+ return Qnil;
+}
+
+static VALUE
+gzfile_wrap(int argc, VALUE *argv, VALUE klass, int close_io_on_error)
+{
+ VALUE obj;
+
+ if (close_io_on_error) {
+ int state = 0;
+ new_wrap_arg_t arg;
+ arg.argc = argc;
+ arg.argv = argv;
+ arg.klass = klass;
+ obj = rb_protect(new_wrap, (VALUE)&arg, &state);
+ if (state) {
+ rb_io_close(argv[0]);
+ rb_jump_tag(state);
+ }
+ }
+ else {
+ obj = rb_class_new_instance(argc, argv, klass);
+ }
+
+ if (rb_block_given_p()) {
+ return rb_ensure(rb_yield, obj, gzfile_ensure_close, obj);
+ }
+ else {
+ return obj;
+ }
+}
+
+/*
+ * Document-method: Zlib::GzipFile.wrap
+ *
+ * call-seq:
+ * Zlib::GzipReader.wrap(io, ...) { |gz| ... }
+ * Zlib::GzipWriter.wrap(io, ...) { |gz| ... }
+ *
+ * Creates a GzipReader or GzipWriter associated with +io+, passing in any
+ * necessary extra options, and executes the block with the newly created
+ * object just like File.open.
+ *
+ * The GzipFile object will be closed automatically after executing the block.
+ * If you want to keep the associated IO object open, you may call
+ * Zlib::GzipFile#finish method in the block.
+ */
+static VALUE
+rb_gzfile_s_wrap(int argc, VALUE *argv, VALUE klass)
+{
+ return gzfile_wrap(argc, argv, klass, 0);
+}
+
+/*
+ * Document-method: Zlib::GzipFile.open
+ *
+ * See Zlib::GzipReader#open and Zlib::GzipWriter#open.
+ */
+static VALUE
+gzfile_s_open(int argc, VALUE *argv, VALUE klass, const char *mode)
+{
+ VALUE io, filename;
+
+ if (argc < 1) {
+ rb_raise(rb_eArgError, "wrong number of arguments (0 for 1)");
+ }
+ filename = argv[0];
+ io = rb_file_open_str(filename, mode);
+ argv[0] = io;
+ return gzfile_wrap(argc, argv, klass, 1);
+}
+
+/*
+ * Document-method: Zlib::GzipFile#to_io
+ *
+ * Same as IO.
+ */
+static VALUE
+rb_gzfile_to_io(VALUE obj)
+{
+ return get_gzfile(obj)->io;
+}
+
+/*
+ * Document-method: Zlib::GzipFile#crc
+ *
+ * Returns CRC value of the uncompressed data.
+ */
+static VALUE
+rb_gzfile_crc(VALUE obj)
+{
+ return rb_uint2inum(get_gzfile(obj)->crc);
+}
+
+/*
+ * Document-method: Zlib::GzipFile#mtime
+ *
+ * Returns last modification time recorded in the gzip file header.
+ */
+static VALUE
+rb_gzfile_mtime(VALUE obj)
+{
+ return rb_time_new(get_gzfile(obj)->mtime, (time_t)0);
+}
+
+/*
+ * Document-method: Zlib::GzipFile#level
+ *
+ * Returns compression level.
+ */
+static VALUE
+rb_gzfile_level(VALUE obj)
+{
+ return INT2FIX(get_gzfile(obj)->level);
+}
+
+/*
+ * Document-method: Zlib::GzipFile#os_code
+ *
+ * Returns OS code number recorded in the gzip file header.
+ */
+static VALUE
+rb_gzfile_os_code(VALUE obj)
+{
+ return INT2FIX(get_gzfile(obj)->os_code);
+}
+
+/*
+ * Document-method: Zlib::GzipFile#orig_name
+ *
+ * Returns original filename recorded in the gzip file header, or +nil+ if
+ * original filename is not present.
+ */
+static VALUE
+rb_gzfile_orig_name(VALUE obj)
+{
+ VALUE str = get_gzfile(obj)->orig_name;
+ if (!NIL_P(str)) {
+ str = rb_str_dup(str);
+ }
+ OBJ_TAINT(str); /* for safe */
+ return str;
+}
+
+/*
+ * Document-method: Zlib::GzipFile#comment
+ *
+ * Returns comments recorded in the gzip file header, or nil if the comments
+ * is not present.
+ */
+static VALUE
+rb_gzfile_comment(VALUE obj)
+{
+ VALUE str = get_gzfile(obj)->comment;
+ if (!NIL_P(str)) {
+ str = rb_str_dup(str);
+ }
+ OBJ_TAINT(str); /* for safe */
+ return str;
+}
+
+/*
+ * Document-method: Zlib::GzipFile#lineno
+ *
+ * The line number of the last row read from this file.
+ */
+static VALUE
+rb_gzfile_lineno(VALUE obj)
+{
+ return INT2NUM(get_gzfile(obj)->lineno);
+}
+
+/*
+ * Document-method: Zlib::GzipReader#lineno=
+ *
+ * Specify line number of the last row read from this file.
+ */
+static VALUE
+rb_gzfile_set_lineno(VALUE obj, VALUE lineno)
+{
+ struct gzfile *gz = get_gzfile(obj);
+ gz->lineno = NUM2INT(lineno);
+ return lineno;
+}
+
+/*
+ * Document-method: Zlib::GzipWriter#mtime=
+ *
+ * Specify the modification time (+mtime+) in the gzip header.
+ * Using a Fixnum or Integer
+ */
+static VALUE
+rb_gzfile_set_mtime(VALUE obj, VALUE mtime)
+{
+ struct gzfile *gz = get_gzfile(obj);
+ VALUE val;
+
+ if (gz->z.flags & GZFILE_FLAG_HEADER_FINISHED) {
+ rb_raise(cGzError, "header is already written");
+ }
+
+ val = rb_Integer(mtime);
+ gz->mtime = NUM2UINT(val);
+
+ return mtime;
+}
+
+/*
+ * Document-method: Zlib::GzipFile#orig_name=
+ *
+ * Specify the original name (+str+) in the gzip header.
+ */
+static VALUE
+rb_gzfile_set_orig_name(VALUE obj, VALUE str)
+{
+ struct gzfile *gz = get_gzfile(obj);
+ VALUE s;
+ char *p;
+
+ if (gz->z.flags & GZFILE_FLAG_HEADER_FINISHED) {
+ rb_raise(cGzError, "header is already written");
+ }
+ s = rb_str_dup(rb_str_to_str(str));
+ p = memchr(RSTRING_PTR(s), '\0', RSTRING_LEN(s));
+ if (p) {
+ rb_str_resize(s, p - RSTRING_PTR(s));
+ }
+ gz->orig_name = s;
+ return str;
+}
+
+/*
+ * Document-method: Zlib::GzipFile#comment=
+ *
+ * Specify the comment (+str+) in the gzip header.
+ */
+static VALUE
+rb_gzfile_set_comment(VALUE obj, VALUE str)
+{
+ struct gzfile *gz = get_gzfile(obj);
+ VALUE s;
+ char *p;
+
+ if (gz->z.flags & GZFILE_FLAG_HEADER_FINISHED) {
+ rb_raise(cGzError, "header is already written");
+ }
+ s = rb_str_dup(rb_str_to_str(str));
+ p = memchr(RSTRING_PTR(s), '\0', RSTRING_LEN(s));
+ if (p) {
+ rb_str_resize(s, p - RSTRING_PTR(s));
+ }
+ gz->comment = s;
+ return str;
+}
+
+/*
+ * Document-method: Zlib::GzipFile#close
+ *
+ * Closes the GzipFile object. This method calls close method of the
+ * associated IO object. Returns the associated IO object.
+ */
+static VALUE
+rb_gzfile_close(VALUE obj)
+{
+ struct gzfile *gz = get_gzfile(obj);
+ VALUE io;
+
+ io = gz->io;
+ gzfile_close(gz, 1);
+ return io;
+}
+
+/*
+ * Document-method: Zlib::GzipFile#finish
+ *
+ * Closes the GzipFile object. Unlike Zlib::GzipFile#close, this method never
+ * calls the close method of the associated IO object. Returns the associated IO
+ * object.
+ */
+static VALUE
+rb_gzfile_finish(VALUE obj)
+{
+ struct gzfile *gz = get_gzfile(obj);
+ VALUE io;
+
+ io = gz->io;
+ gzfile_close(gz, 0);
+ return io;
+}
+
+/*
+ * Document-method: Zlib::GzipFile#closed?
+ *
+ * Same as IO#closed?
+ *
+ */
+static VALUE
+rb_gzfile_closed_p(VALUE obj)
+{
+ struct gzfile *gz;
+ TypedData_Get_Struct(obj, struct gzfile, &gzfile_data_type, gz);
+ return NIL_P(gz->io) ? Qtrue : Qfalse;
+}
+
+/*
+ * Document-method: Zlib::GzipFile#eof?
+ *
+ * Returns +true+ or +false+ whether the stream has reached the end.
+ */
+static VALUE
+rb_gzfile_eof_p(VALUE obj)
+{
+ struct gzfile *gz = get_gzfile(obj);
+ return GZFILE_IS_FINISHED(gz) ? Qtrue : Qfalse;
+}
+
+/*
+ * Document-method: Zlib::GzipFile#sync
+ *
+ * Same as IO#sync
+ *
+ */
+static VALUE
+rb_gzfile_sync(VALUE obj)
+{
+ return (get_gzfile(obj)->z.flags & GZFILE_FLAG_SYNC) ? Qtrue : Qfalse;
+}
+
+/*
+ * Document-method: Zlib::GzipFile#sync=
+ *
+ * call-seq: sync = flag
+ *
+ * Same as IO. If flag is +true+, the associated IO object must respond to the
+ * +flush+ method. While +sync+ mode is +true+, the compression ratio
+ * decreases sharply.
+ */
+static VALUE
+rb_gzfile_set_sync(VALUE obj, VALUE mode)
+{
+ struct gzfile *gz = get_gzfile(obj);
+
+ if (RTEST(mode)) {
+ gz->z.flags |= GZFILE_FLAG_SYNC;
+ }
+ else {
+ gz->z.flags &= ~GZFILE_FLAG_SYNC;
+ }
+ return mode;
+}
+
+/*
+ * Document-method: Zlib::GzipFile#total_in
+ *
+ * Total number of input bytes read so far.
+ */
+static VALUE
+rb_gzfile_total_in(VALUE obj)
+{
+ return rb_uint2inum(get_gzfile(obj)->z.stream.total_in);
+}
+
+/*
+ * Document-method: Zlib::GzipFile#total_out
+ *
+ * Total number of output bytes output so far.
+ */
+static VALUE
+rb_gzfile_total_out(VALUE obj)
+{
+ struct gzfile *gz = get_gzfile(obj);
+ return rb_uint2inum(gz->z.stream.total_out - gz->z.buf_filled);
+}
+
+/*
+ * Document-method: Zlib::GzipFile#path
+ *
+ * call-seq: path
+ *
+ * Returns the path string of the associated IO-like object. This
+ * method is only defined when the IO-like object responds to #path().
+ */
+static VALUE
+rb_gzfile_path(VALUE obj)
+{
+ struct gzfile *gz;
+ TypedData_Get_Struct(obj, struct gzfile, &gzfile_data_type, gz);
+ return gz->path;
+}
+
+static void
+rb_gzfile_ecopts(struct gzfile *gz, VALUE opts)
+{
+ if (!NIL_P(opts)) {
+ rb_io_extract_encoding_option(opts, &gz->enc, &gz->enc2, NULL);
+ }
+ if (gz->enc2) {
+ gz->ecflags = rb_econv_prepare_opts(opts, &opts);
+ gz->ec = rb_econv_open_opts(gz->enc2->name, gz->enc->name,
+ gz->ecflags, opts);
+ gz->ecopts = opts;
+ }
+}
+
+/* ------------------------------------------------------------------------- */
+
+/*
+ * Document-class: Zlib::GzipWriter
+ *
+ * Zlib::GzipWriter is a class for writing gzipped files. GzipWriter should
+ * be used with an instance of IO, or IO-like, object.
+ *
+ * Following two example generate the same result.
+ *
+ * Zlib::GzipWriter.open('hoge.gz') do |gz|
+ * gz.write 'jugemu jugemu gokou no surikire...'
+ * end
+ *
+ * File.open('hoge.gz', 'w') do |f|
+ * gz = Zlib::GzipWriter.new(f)
+ * gz.write 'jugemu jugemu gokou no surikire...'
+ * gz.close
+ * end
+ *
+ * To make like gzip(1) does, run following:
+ *
+ * orig = 'hoge.txt'
+ * Zlib::GzipWriter.open('hoge.gz') do |gz|
+ * gz.mtime = File.mtime(orig)
+ * gz.orig_name = orig
+ * gz.write IO.binread(orig)
+ * end
+ *
+ * NOTE: Due to the limitation of Ruby's finalizer, you must explicitly close
+ * GzipWriter objects by Zlib::GzipWriter#close etc. Otherwise, GzipWriter
+ * will be not able to write the gzip footer and will generate a broken gzip
+ * file.
+ */
+
+static VALUE
+rb_gzwriter_s_allocate(VALUE klass)
+{
+ return gzfile_writer_new(klass);
+}
+
+/*
+ * call-seq: Zlib::GzipWriter.open(filename, level=nil, strategy=nil) { |gz| ... }
+ *
+ * Opens a file specified by +filename+ for writing gzip compressed data, and
+ * returns a GzipWriter object associated with that file. Further details of
+ * this method are found in Zlib::GzipWriter.new and Zlib::GzipFile.wrap.
+ */
+static VALUE
+rb_gzwriter_s_open(int argc, VALUE *argv, VALUE klass)
+{
+ return gzfile_s_open(argc, argv, klass, "wb");
+}
+
+/*
+ * call-seq:
+ * Zlib::GzipWriter.new(io, level = nil, strategy = nil, options = {})
+ *
+ * Creates a GzipWriter object associated with +io+. +level+ and +strategy+
+ * should be the same as the arguments of Zlib::Deflate.new. The GzipWriter
+ * object writes gzipped data to +io+. +io+ must respond to the
+ * +write+ method that behaves the same as IO#write.
+ *
+ * The +options+ hash may be used to set the encoding of the data.
+ * +:external_encoding+, +:internal_encoding+ and +:encoding+ may be set as in
+ * IO::new.
+ */
+static VALUE
+rb_gzwriter_initialize(int argc, VALUE *argv, VALUE obj)
+{
+ struct gzfile *gz;
+ VALUE io, level, strategy, opt = Qnil;
+ int err;
+
+ if (argc > 1) {
+ opt = rb_check_convert_type(argv[argc-1], T_HASH, "Hash", "to_hash");
+ if (!NIL_P(opt)) argc--;
+ }
+
+ rb_scan_args(argc, argv, "12", &io, &level, &strategy);
+ TypedData_Get_Struct(obj, struct gzfile, &gzfile_data_type, gz);
+
+ /* this is undocumented feature of zlib */
+ gz->level = ARG_LEVEL(level);
+ err = deflateInit2(&gz->z.stream, gz->level, Z_DEFLATED,
+ -MAX_WBITS, DEF_MEM_LEVEL, ARG_STRATEGY(strategy));
+ if (err != Z_OK) {
+ raise_zlib_error(err, gz->z.stream.msg);
+ }
+ gz->io = io;
+ ZSTREAM_READY(&gz->z);
+ rb_gzfile_ecopts(gz, opt);
+
+ if (rb_respond_to(io, id_path)) {
+ gz->path = rb_funcall(gz->io, id_path, 0);
+ rb_define_singleton_method(obj, "path", rb_gzfile_path, 0);
+ }
+
+ return obj;
+}
+
+/*
+ * call-seq: flush(flush=nil)
+ *
+ * Flushes all the internal buffers of the GzipWriter object. The meaning of
+ * +flush+ is same as in Zlib::Deflate#deflate. <tt>Zlib::SYNC_FLUSH</tt> is used if
+ * +flush+ is omitted. It is no use giving flush <tt>Zlib::NO_FLUSH</tt>.
+ */
+static VALUE
+rb_gzwriter_flush(int argc, VALUE *argv, VALUE obj)
+{
+ struct gzfile *gz = get_gzfile(obj);
+ VALUE v_flush;
+ int flush;
+
+ rb_scan_args(argc, argv, "01", &v_flush);
+
+ flush = FIXNUMARG(v_flush, Z_SYNC_FLUSH);
+ if (flush != Z_NO_FLUSH) { /* prevent Z_BUF_ERROR */
+ zstream_run(&gz->z, (Bytef*)"", 0, flush);
+ }
+
+ gzfile_write_raw(gz);
+ if (rb_respond_to(gz->io, id_flush)) {
+ rb_funcall(gz->io, id_flush, 0);
+ }
+ return obj;
+}
+
+/*
+ * Same as IO.
+ */
+static VALUE
+rb_gzwriter_write(VALUE obj, VALUE str)
+{
+ struct gzfile *gz = get_gzfile(obj);
+
+ if (!RB_TYPE_P(str, T_STRING))
+ str = rb_obj_as_string(str);
+ if (gz->enc2 && gz->enc2 != rb_ascii8bit_encoding()) {
+ str = rb_str_conv_enc(str, rb_enc_get(str), gz->enc2);
+ }
+ gzfile_write(gz, (Bytef*)RSTRING_PTR(str), RSTRING_LEN(str));
+ return INT2FIX(RSTRING_LEN(str));
+}
+
+/*
+ * Same as IO.
+ */
+static VALUE
+rb_gzwriter_putc(VALUE obj, VALUE ch)
+{
+ struct gzfile *gz = get_gzfile(obj);
+ char c = NUM2CHR(ch);
+
+ gzfile_write(gz, (Bytef*)&c, 1);
+ return ch;
+}
+
+
+
+/*
+ * Document-method: <<
+ * Same as IO.
+ */
+#define rb_gzwriter_addstr rb_io_addstr
+/*
+ * Document-method: printf
+ * Same as IO.
+ */
+#define rb_gzwriter_printf rb_io_printf
+/*
+ * Document-method: print
+ * Same as IO.
+ */
+#define rb_gzwriter_print rb_io_print
+/*
+ * Document-method: puts
+ * Same as IO.
+ */
+#define rb_gzwriter_puts rb_io_puts
+
+
+/* ------------------------------------------------------------------------- */
+
+/*
+ * Document-class: Zlib::GzipReader
+ *
+ * Zlib::GzipReader is the class for reading a gzipped file. GzipReader should
+ * be used an IO, or -IO-like, object.
+ *
+ * Zlib::GzipReader.open('hoge.gz') {|gz|
+ * print gz.read
+ * }
+ *
+ * File.open('hoge.gz') do |f|
+ * gz = Zlib::GzipReader.new(f)
+ * print gz.read
+ * gz.close
+ * end
+ *
+ * == Method Catalogue
+ *
+ * The following methods in Zlib::GzipReader are just like their counterparts
+ * in IO, but they raise Zlib::Error or Zlib::GzipFile::Error exception if an
+ * error was found in the gzip file.
+ * - #each
+ * - #each_line
+ * - #each_byte
+ * - #gets
+ * - #getc
+ * - #lineno
+ * - #lineno=
+ * - #read
+ * - #readchar
+ * - #readline
+ * - #readlines
+ * - #ungetc
+ *
+ * Be careful of the footer of the gzip file. A gzip file has the checksum of
+ * pre-compressed data in its footer. GzipReader checks all uncompressed data
+ * against that checksum at the following cases, and if it fails, raises
+ * <tt>Zlib::GzipFile::NoFooter</tt>, <tt>Zlib::GzipFile::CRCError</tt>, or
+ * <tt>Zlib::GzipFile::LengthError</tt> exception.
+ *
+ * - When an reading request is received beyond the end of file (the end of
+ * compressed data). That is, when Zlib::GzipReader#read,
+ * Zlib::GzipReader#gets, or some other methods for reading returns nil.
+ * - When Zlib::GzipFile#close method is called after the object reaches the
+ * end of file.
+ * - When Zlib::GzipReader#unused method is called after the object reaches
+ * the end of file.
+ *
+ * The rest of the methods are adequately described in their own
+ * documentation.
+ */
+
+static VALUE
+rb_gzreader_s_allocate(VALUE klass)
+{
+ return gzfile_reader_new(klass);
+}
+
+/*
+ * Document-method: Zlib::GzipReader.open
+ *
+ * call-seq: Zlib::GzipReader.open(filename) {|gz| ... }
+ *
+ * Opens a file specified by +filename+ as a gzipped file, and returns a
+ * GzipReader object associated with that file. Further details of this method
+ * are in Zlib::GzipReader.new and ZLib::GzipFile.wrap.
+ */
+static VALUE
+rb_gzreader_s_open(int argc, VALUE *argv, VALUE klass)
+{
+ return gzfile_s_open(argc, argv, klass, "rb");
+}
+
+/*
+ * Document-method: Zlib::GzipReader.new
+ *
+ * call-seq:
+ * Zlib::GzipReader.new(io, options = {})
+ *
+ * Creates a GzipReader object associated with +io+. The GzipReader object reads
+ * gzipped data from +io+, and parses/decompresses it. The +io+ must
+ * have a +read+ method that behaves same as the IO#read.
+ *
+ * The +options+ hash may be used to set the encoding of the data.
+ * +:external_encoding+, +:internal_encoding+ and +:encoding+ may be set as in
+ * IO::new.
+ *
+ * If the gzip file header is incorrect, raises an Zlib::GzipFile::Error
+ * exception.
+ */
+static VALUE
+rb_gzreader_initialize(int argc, VALUE *argv, VALUE obj)
+{
+ VALUE io, opt = Qnil;
+ struct gzfile *gz;
+ int err;
+
+ TypedData_Get_Struct(obj, struct gzfile, &gzfile_data_type, gz);
+ rb_scan_args(argc, argv, "1:", &io, &opt);
+
+ /* this is undocumented feature of zlib */
+ err = inflateInit2(&gz->z.stream, -MAX_WBITS);
+ if (err != Z_OK) {
+ raise_zlib_error(err, gz->z.stream.msg);
+ }
+ gz->io = io;
+ ZSTREAM_READY(&gz->z);
+ gzfile_read_header(gz);
+ rb_gzfile_ecopts(gz, opt);
+
+ if (rb_respond_to(io, id_path)) {
+ gz->path = rb_funcall(gz->io, id_path, 0);
+ rb_define_singleton_method(obj, "path", rb_gzfile_path, 0);
+ }
+
+ return obj;
+}
+
+/*
+ * Document-method: Zlib::GzipReader#rewind
+ *
+ * Resets the position of the file pointer to the point created the GzipReader
+ * object. The associated IO object needs to respond to the +seek+ method.
+ */
+static VALUE
+rb_gzreader_rewind(VALUE obj)
+{
+ struct gzfile *gz = get_gzfile(obj);
+ gzfile_reader_rewind(gz);
+ return INT2FIX(0);
+}
+
+/*
+ * Document-method: Zlib::GzipReader#unused
+ *
+ * Returns the rest of the data which had read for parsing gzip format, or
+ * +nil+ if the whole gzip file is not parsed yet.
+ */
+static VALUE
+rb_gzreader_unused(VALUE obj)
+{
+ struct gzfile *gz;
+ TypedData_Get_Struct(obj, struct gzfile, &gzfile_data_type, gz);
+ return gzfile_reader_get_unused(gz);
+}
+
+/*
+ * Document-method: Zlib::GzipReader#read
+ *
+ * See Zlib::GzipReader documentation for a description.
+ */
+static VALUE
+rb_gzreader_read(int argc, VALUE *argv, VALUE obj)
+{
+ struct gzfile *gz = get_gzfile(obj);
+ VALUE vlen;
+ long len;
+
+ rb_scan_args(argc, argv, "01", &vlen);
+ if (NIL_P(vlen)) {
+ return gzfile_read_all(gz);
+ }
+
+ len = NUM2INT(vlen);
+ if (len < 0) {
+ rb_raise(rb_eArgError, "negative length %ld given", len);
+ }
+ return gzfile_read(gz, len);
+}
+
+/*
+ * Document-method: Zlib::GzipReader#readpartial
+ *
+ * call-seq:
+ * gzipreader.readpartial(maxlen [, outbuf]) => string, outbuf
+ *
+ * Reads at most <i>maxlen</i> bytes from the gziped stream but
+ * it blocks only if <em>gzipreader</em> has no data immediately available.
+ * If the optional <i>outbuf</i> argument is present,
+ * it must reference a String, which will receive the data.
+ * It raises <code>EOFError</code> on end of file.
+ */
+static VALUE
+rb_gzreader_readpartial(int argc, VALUE *argv, VALUE obj)
+{
+ struct gzfile *gz = get_gzfile(obj);
+ VALUE vlen, outbuf;
+ long len;
+
+ rb_scan_args(argc, argv, "11", &vlen, &outbuf);
+
+ len = NUM2INT(vlen);
+ if (len < 0) {
+ rb_raise(rb_eArgError, "negative length %ld given", len);
+ }
+ if (!NIL_P(outbuf))
+ Check_Type(outbuf, T_STRING);
+ return gzfile_readpartial(gz, len, outbuf);
+}
+
+/*
+ * Document-method: Zlib::GzipReader#getc
+ *
+ * See Zlib::GzipReader documentation for a description.
+ */
+static VALUE
+rb_gzreader_getc(VALUE obj)
+{
+ struct gzfile *gz = get_gzfile(obj);
+
+ return gzfile_getc(gz);
+}
+
+/*
+ * Document-method: Zlib::GzipReader#readchar
+ *
+ * See Zlib::GzipReader documentation for a description.
+ */
+static VALUE
+rb_gzreader_readchar(VALUE obj)
+{
+ VALUE dst;
+ dst = rb_gzreader_getc(obj);
+ if (NIL_P(dst)) {
+ rb_raise(rb_eEOFError, "end of file reached");
+ }
+ return dst;
+}
+
+/*
+ * Document-method: Zlib::GzipReader#getbyte
+ *
+ * See Zlib::GzipReader documentation for a description.
+ */
+static VALUE
+rb_gzreader_getbyte(VALUE obj)
+{
+ struct gzfile *gz = get_gzfile(obj);
+ VALUE dst;
+
+ dst = gzfile_read(gz, 1);
+ if (!NIL_P(dst)) {
+ dst = INT2FIX((unsigned int)(RSTRING_PTR(dst)[0]) & 0xff);
+ }
+ return dst;
+}
+
+/*
+ * Document-method: Zlib::GzipReader#readbyte
+ *
+ * See Zlib::GzipReader documentation for a description.
+ */
+static VALUE
+rb_gzreader_readbyte(VALUE obj)
+{
+ VALUE dst;
+ dst = rb_gzreader_getbyte(obj);
+ if (NIL_P(dst)) {
+ rb_raise(rb_eEOFError, "end of file reached");
+ }
+ return dst;
+}
+
+/*
+ * Document-method: Zlib::GzipReader#each_char
+ *
+ * See Zlib::GzipReader documentation for a description.
+ */
+static VALUE
+rb_gzreader_each_char(VALUE obj)
+{
+ VALUE c;
+
+ RETURN_ENUMERATOR(obj, 0, 0);
+
+ while (!NIL_P(c = rb_gzreader_getc(obj))) {
+ rb_yield(c);
+ }
+ return Qnil;
+}
+
+/*
+ * Document-method: Zlib::GzipReader#each_byte
+ *
+ * See Zlib::GzipReader documentation for a description.
+ */
+static VALUE
+rb_gzreader_each_byte(VALUE obj)
+{
+ VALUE c;
+
+ RETURN_ENUMERATOR(obj, 0, 0);
+
+ while (!NIL_P(c = rb_gzreader_getbyte(obj))) {
+ rb_yield(c);
+ }
+ return Qnil;
+}
+
+/*
+ * Document-method: Zlib::GzipReader#bytes
+ *
+ * This is a deprecated alias for <code>each_byte</code>.
+ */
+static VALUE
+rb_gzreader_bytes(VALUE obj)
+{
+ rb_warn("Zlib::GzipReader#bytes is deprecated; use #each_byte instead");
+ if (!rb_block_given_p())
+ return rb_enumeratorize(obj, ID2SYM(rb_intern("each_byte")), 0, 0);
+ return rb_gzreader_each_byte(obj);
+}
+
+/*
+ * Document-method: Zlib::GzipReader#ungetc
+ *
+ * See Zlib::GzipReader documentation for a description.
+ */
+static VALUE
+rb_gzreader_ungetc(VALUE obj, VALUE s)
+{
+ struct gzfile *gz;
+
+ if (FIXNUM_P(s))
+ return rb_gzreader_ungetbyte(obj, s);
+ gz = get_gzfile(obj);
+ StringValue(s);
+ if (gz->enc2 && gz->enc2 != rb_ascii8bit_encoding()) {
+ s = rb_str_conv_enc(s, rb_enc_get(s), gz->enc2);
+ }
+ gzfile_ungets(gz, (const Bytef*)RSTRING_PTR(s), RSTRING_LEN(s));
+ return Qnil;
+}
+
+/*
+ * Document-method: Zlib::GzipReader#ungetbyte
+ *
+ * See Zlib::GzipReader documentation for a description.
+ */
+static VALUE
+rb_gzreader_ungetbyte(VALUE obj, VALUE ch)
+{
+ struct gzfile *gz = get_gzfile(obj);
+ gzfile_ungetbyte(gz, NUM2CHR(ch));
+ return Qnil;
+}
+
+static void
+gzreader_skip_linebreaks(struct gzfile *gz)
+{
+ VALUE str;
+ char *p;
+ int n;
+
+ while (gz->z.buf_filled == 0) {
+ if (GZFILE_IS_FINISHED(gz)) return;
+ gzfile_read_more(gz);
+ }
+ n = 0;
+ p = RSTRING_PTR(gz->z.buf);
+
+ while (n++, *(p++) == '\n') {
+ if (n >= gz->z.buf_filled) {
+ str = zstream_detach_buffer(&gz->z);
+ gzfile_calc_crc(gz, str);
+ while (gz->z.buf_filled == 0) {
+ if (GZFILE_IS_FINISHED(gz)) return;
+ gzfile_read_more(gz);
+ }
+ n = 0;
+ p = RSTRING_PTR(gz->z.buf);
+ }
+ }
+
+ str = zstream_shift_buffer(&gz->z, n - 1);
+ gzfile_calc_crc(gz, str);
+}
+
+static void
+rscheck(const char *rsptr, long rslen, VALUE rs)
+{
+ if (RSTRING_PTR(rs) != rsptr && RSTRING_LEN(rs) != rslen)
+ rb_raise(rb_eRuntimeError, "rs modified");
+}
+
+static long
+gzreader_charboundary(struct gzfile *gz, long n)
+{
+ char *s = RSTRING_PTR(gz->z.buf);
+ char *e = s + gz->z.buf_filled;
+ char *p = rb_enc_left_char_head(s, s + n, e, gz->enc);
+ long l = p - s;
+ if (l < n) {
+ n = rb_enc_precise_mbclen(p, e, gz->enc);
+ if (MBCLEN_NEEDMORE_P(n)) {
+ if ((l = gzfile_fill(gz, l + MBCLEN_NEEDMORE_LEN(n))) > 0) {
+ return l;
+ }
+ }
+ else if (MBCLEN_CHARFOUND_P(n)) {
+ return l + MBCLEN_CHARFOUND_LEN(n);
+ }
+ }
+ return n;
+}
+
+static VALUE
+gzreader_gets(int argc, VALUE *argv, VALUE obj)
+{
+ struct gzfile *gz = get_gzfile(obj);
+ volatile VALUE rs;
+ VALUE dst;
+ const char *rsptr;
+ char *p, *res;
+ long rslen, n, limit = -1;
+ int rspara;
+ rb_encoding *enc = gz->enc;
+ int maxlen = rb_enc_mbmaxlen(enc);
+
+ if (argc == 0) {
+ rs = rb_rs;
+ }
+ else {
+ VALUE lim, tmp;
+
+ rb_scan_args(argc, argv, "11", &rs, &lim);
+ if (!NIL_P(lim)) {
+ if (!NIL_P(rs)) StringValue(rs);
+ }
+ else if (!NIL_P(rs)) {
+ tmp = rb_check_string_type(rs);
+ if (NIL_P(tmp)) {
+ lim = rs;
+ rs = rb_rs;
+ }
+ else {
+ rs = tmp;
+ }
+ }
+ if (!NIL_P(lim)) {
+ limit = NUM2LONG(lim);
+ if (limit == 0) return rb_str_new(0,0);
+ }
+ }
+
+ if (NIL_P(rs)) {
+ if (limit < 0) {
+ dst = gzfile_read_all(gz);
+ if (RSTRING_LEN(dst) == 0) return Qnil;
+ }
+ else if ((n = gzfile_fill(gz, limit)) <= 0) {
+ return Qnil;
+ }
+ else {
+ if (maxlen > 1 && n >= limit && !GZFILE_IS_FINISHED(gz)) {
+ n = gzreader_charboundary(gz, n);
+ }
+ else {
+ n = limit;
+ }
+ dst = zstream_shift_buffer(&gz->z, n);
+ if (NIL_P(dst)) return dst;
+ gzfile_calc_crc(gz, dst);
+ dst = gzfile_newstr(gz, dst);
+ }
+ gz->lineno++;
+ return dst;
+ }
+
+ if (RSTRING_LEN(rs) == 0) {
+ rsptr = "\n\n";
+ rslen = 2;
+ rspara = 1;
+ } else {
+ rsptr = RSTRING_PTR(rs);
+ rslen = RSTRING_LEN(rs);
+ rspara = 0;
+ }
+
+ if (rspara) {
+ gzreader_skip_linebreaks(gz);
+ }
+
+ while (gz->z.buf_filled < rslen) {
+ if (ZSTREAM_IS_FINISHED(&gz->z)) {
+ if (gz->z.buf_filled > 0) gz->lineno++;
+ return gzfile_read(gz, rslen);
+ }
+ gzfile_read_more(gz);
+ }
+
+ p = RSTRING_PTR(gz->z.buf);
+ n = rslen;
+ for (;;) {
+ long filled;
+ if (n > gz->z.buf_filled) {
+ if (ZSTREAM_IS_FINISHED(&gz->z)) break;
+ gzfile_read_more(gz);
+ p = RSTRING_PTR(gz->z.buf) + n - rslen;
+ }
+ if (!rspara) rscheck(rsptr, rslen, rs);
+ filled = gz->z.buf_filled;
+ if (limit > 0 && filled >= limit) {
+ filled = limit;
+ }
+ res = memchr(p, rsptr[0], (filled - n + 1));
+ if (!res) {
+ n = filled;
+ if (limit > 0 && filled >= limit) break;
+ n++;
+ } else {
+ n += (long)(res - p);
+ p = res;
+ if (rslen == 1 || memcmp(p, rsptr, rslen) == 0) break;
+ p++, n++;
+ }
+ }
+ if (maxlen > 1 && n == limit && (gz->z.buf_filled > n || !ZSTREAM_IS_FINISHED(&gz->z))) {
+ n = gzreader_charboundary(gz, n);
+ }
+
+ gz->lineno++;
+ dst = gzfile_read(gz, n);
+ if (NIL_P(dst)) return dst;
+ if (rspara) {
+ gzreader_skip_linebreaks(gz);
+ }
+
+ return gzfile_newstr(gz, dst);
+}
+
+/*
+ * Document-method: Zlib::GzipReader#gets
+ *
+ * See Zlib::GzipReader documentation for a description.
+ */
+static VALUE
+rb_gzreader_gets(int argc, VALUE *argv, VALUE obj)
+{
+ VALUE dst;
+ dst = gzreader_gets(argc, argv, obj);
+ if (!NIL_P(dst)) {
+ rb_lastline_set(dst);
+ }
+ return dst;
+}
+
+/*
+ * Document-method: Zlib::GzipReader#readline
+ *
+ * See Zlib::GzipReader documentation for a description.
+ */
+static VALUE
+rb_gzreader_readline(int argc, VALUE *argv, VALUE obj)
+{
+ VALUE dst;
+ dst = rb_gzreader_gets(argc, argv, obj);
+ if (NIL_P(dst)) {
+ rb_raise(rb_eEOFError, "end of file reached");
+ }
+ return dst;
+}
+
+/*
+ * Document-method: Zlib::GzipReader#each
+ *
+ * See Zlib::GzipReader documentation for a description.
+ */
+static VALUE
+rb_gzreader_each(int argc, VALUE *argv, VALUE obj)
+{
+ VALUE str;
+
+ RETURN_ENUMERATOR(obj, 0, 0);
+
+ while (!NIL_P(str = gzreader_gets(argc, argv, obj))) {
+ rb_yield(str);
+ }
+ return obj;
+}
+
+/*
+ * Document-method: Zlib::GzipReader#lines
+ *
+ * This is a deprecated alias for <code>each_line</code>.
+ */
+static VALUE
+rb_gzreader_lines(int argc, VALUE *argv, VALUE obj)
+{
+ rb_warn("Zlib::GzipReader#lines is deprecated; use #each_line instead");
+ if (!rb_block_given_p())
+ return rb_enumeratorize(obj, ID2SYM(rb_intern("each_line")), argc, argv);
+ return rb_gzreader_each(argc, argv, obj);
+}
+
+/*
+ * Document-method: Zlib::GzipReader#readlines
+ *
+ * See Zlib::GzipReader documentation for a description.
+ */
+static VALUE
+rb_gzreader_readlines(int argc, VALUE *argv, VALUE obj)
+{
+ VALUE str, dst;
+ dst = rb_ary_new();
+ while (!NIL_P(str = gzreader_gets(argc, argv, obj))) {
+ rb_ary_push(dst, str);
+ }
+ return dst;
+}
+
+#endif /* GZIP_SUPPORT */
+
+void
+Init_zlib(void)
+{
+ VALUE mZlib, cZStream, cDeflate, cInflate;
+#if GZIP_SUPPORT
+ VALUE cGzipFile, cGzipWriter, cGzipReader;
+#endif
+
+ mZlib = rb_define_module("Zlib");
+
+ id_dictionaries = rb_intern("@dictionaries");
+
+ cZError = rb_define_class_under(mZlib, "Error", rb_eStandardError);
+ cStreamEnd = rb_define_class_under(mZlib, "StreamEnd", cZError);
+ cNeedDict = rb_define_class_under(mZlib, "NeedDict", cZError);
+ cDataError = rb_define_class_under(mZlib, "DataError", cZError);
+ cStreamError = rb_define_class_under(mZlib, "StreamError", cZError);
+ cMemError = rb_define_class_under(mZlib, "MemError", cZError);
+ cBufError = rb_define_class_under(mZlib, "BufError", cZError);
+ cVersionError = rb_define_class_under(mZlib, "VersionError", cZError);
+
+ rb_define_module_function(mZlib, "zlib_version", rb_zlib_version, 0);
+ rb_define_module_function(mZlib, "adler32", rb_zlib_adler32, -1);
+ rb_define_module_function(mZlib, "adler32_combine", rb_zlib_adler32_combine, 3);
+ rb_define_module_function(mZlib, "crc32", rb_zlib_crc32, -1);
+ rb_define_module_function(mZlib, "crc32_combine", rb_zlib_crc32_combine, 3);
+ rb_define_module_function(mZlib, "crc_table", rb_zlib_crc_table, 0);
+
+ /* The Ruby/zlib version string. */
+ rb_define_const(mZlib, "VERSION", rb_str_new2(RUBY_ZLIB_VERSION));
+ /* The string which represents the version of zlib.h */
+ rb_define_const(mZlib, "ZLIB_VERSION", rb_str_new2(ZLIB_VERSION));
+
+ cZStream = rb_define_class_under(mZlib, "ZStream", rb_cObject);
+ rb_undef_alloc_func(cZStream);
+ rb_define_method(cZStream, "avail_out", rb_zstream_avail_out, 0);
+ rb_define_method(cZStream, "avail_out=", rb_zstream_set_avail_out, 1);
+ rb_define_method(cZStream, "avail_in", rb_zstream_avail_in, 0);
+ rb_define_method(cZStream, "total_in", rb_zstream_total_in, 0);
+ rb_define_method(cZStream, "total_out", rb_zstream_total_out, 0);
+ rb_define_method(cZStream, "data_type", rb_zstream_data_type, 0);
+ rb_define_method(cZStream, "adler", rb_zstream_adler, 0);
+ rb_define_method(cZStream, "finished?", rb_zstream_finished_p, 0);
+ rb_define_method(cZStream, "stream_end?", rb_zstream_finished_p, 0);
+ rb_define_method(cZStream, "closed?", rb_zstream_closed_p, 0);
+ rb_define_method(cZStream, "ended?", rb_zstream_closed_p, 0);
+ rb_define_method(cZStream, "close", rb_zstream_end, 0);
+ rb_define_method(cZStream, "end", rb_zstream_end, 0);
+ rb_define_method(cZStream, "reset", rb_zstream_reset, 0);
+ rb_define_method(cZStream, "finish", rb_zstream_finish, 0);
+ rb_define_method(cZStream, "flush_next_in", rb_zstream_flush_next_in, 0);
+ rb_define_method(cZStream, "flush_next_out", rb_zstream_flush_next_out, 0);
+
+ /* Represents binary data as guessed by deflate.
+ *
+ * See Zlib::Deflate#data_type. */
+ rb_define_const(mZlib, "BINARY", INT2FIX(Z_BINARY));
+
+ /* Represents text data as guessed by deflate.
+ *
+ * NOTE: The underlying constant Z_ASCII was deprecated in favor of Z_TEXT
+ * in zlib 1.2.2. New applications should not use this constant.
+ *
+ * See Zlib::Deflate#data_type. */
+ rb_define_const(mZlib, "ASCII", INT2FIX(Z_ASCII));
+
+#ifdef Z_TEXT
+ /* Represents text data as guessed by deflate.
+ *
+ * See Zlib::Deflate#data_type. */
+ rb_define_const(mZlib, "TEXT", INT2FIX(Z_TEXT));
+#endif
+
+ /* Represents an unknown data type as guessed by deflate.
+ *
+ * See Zlib::Deflate#data_type. */
+ rb_define_const(mZlib, "UNKNOWN", INT2FIX(Z_UNKNOWN));
+
+ cDeflate = rb_define_class_under(mZlib, "Deflate", cZStream);
+ rb_define_singleton_method(cDeflate, "deflate", rb_deflate_s_deflate, -1);
+ rb_define_singleton_method(mZlib, "deflate", rb_deflate_s_deflate, -1);
+ rb_define_alloc_func(cDeflate, rb_deflate_s_allocate);
+ rb_define_method(cDeflate, "initialize", rb_deflate_initialize, -1);
+ rb_define_method(cDeflate, "initialize_copy", rb_deflate_init_copy, 1);
+ rb_define_method(cDeflate, "deflate", rb_deflate_deflate, -1);
+ rb_define_method(cDeflate, "<<", rb_deflate_addstr, 1);
+ rb_define_method(cDeflate, "flush", rb_deflate_flush, -1);
+ rb_define_method(cDeflate, "params", rb_deflate_params, 2);
+ rb_define_method(cDeflate, "set_dictionary", rb_deflate_set_dictionary, 1);
+
+ cInflate = rb_define_class_under(mZlib, "Inflate", cZStream);
+ rb_define_singleton_method(cInflate, "inflate", rb_inflate_s_inflate, 1);
+ rb_define_singleton_method(mZlib, "inflate", rb_inflate_s_inflate, 1);
+ rb_define_alloc_func(cInflate, rb_inflate_s_allocate);
+ rb_define_method(cInflate, "initialize", rb_inflate_initialize, -1);
+ rb_define_method(cInflate, "add_dictionary", rb_inflate_add_dictionary, 1);
+ rb_define_method(cInflate, "inflate", rb_inflate_inflate, 1);
+ rb_define_method(cInflate, "<<", rb_inflate_addstr, 1);
+ rb_define_method(cInflate, "sync", rb_inflate_sync, 1);
+ rb_define_method(cInflate, "sync_point?", rb_inflate_sync_point_p, 0);
+ rb_define_method(cInflate, "set_dictionary", rb_inflate_set_dictionary, 1);
+
+ /* No compression, passes through data untouched. Use this for appending
+ * pre-compressed data to a deflate stream.
+ */
+ rb_define_const(mZlib, "NO_COMPRESSION", INT2FIX(Z_NO_COMPRESSION));
+ /* Fastest compression level, but with with lowest space savings. */
+ rb_define_const(mZlib, "BEST_SPEED", INT2FIX(Z_BEST_SPEED));
+ /* Slowest compression level, but with the best space savings. */
+ rb_define_const(mZlib, "BEST_COMPRESSION", INT2FIX(Z_BEST_COMPRESSION));
+ /* Default compression level which is a good trade-off between space and
+ * time
+ */
+ rb_define_const(mZlib, "DEFAULT_COMPRESSION",
+ INT2FIX(Z_DEFAULT_COMPRESSION));
+
+ /* Deflate strategy for data produced by a filter (or predictor). The
+ * effect of FILTERED is to force more Huffman codes and less string
+ * matching; it is somewhat intermediate between DEFAULT_STRATEGY and
+ * HUFFMAN_ONLY. Filtered data consists mostly of small values with a
+ * somewhat random distribution.
+ */
+ rb_define_const(mZlib, "FILTERED", INT2FIX(Z_FILTERED));
+
+ /* Deflate strategy which uses Huffman codes only (no string matching). */
+ rb_define_const(mZlib, "HUFFMAN_ONLY", INT2FIX(Z_HUFFMAN_ONLY));
+
+#ifdef Z_RLE
+ /* Deflate compression strategy designed to be almost as fast as
+ * HUFFMAN_ONLY, but give better compression for PNG image data.
+ */
+ rb_define_const(mZlib, "RLE", INT2FIX(Z_RLE));
+#endif
+
+#ifdef Z_FIXED
+ /* Deflate strategy which prevents the use of dynamic Huffman codes,
+ * allowing for a simpler decoder for specialized applications.
+ */
+ rb_define_const(mZlib, "FIXED", INT2FIX(Z_FIXED));
+#endif
+
+ /* Default deflate strategy which is used for normal data. */
+ rb_define_const(mZlib, "DEFAULT_STRATEGY", INT2FIX(Z_DEFAULT_STRATEGY));
+
+ /* The maximum size of the zlib history buffer. Note that zlib allows
+ * larger values to enable different inflate modes. See Zlib::Inflate.new
+ * for details.
+ */
+ rb_define_const(mZlib, "MAX_WBITS", INT2FIX(MAX_WBITS));
+
+ /* The default memory level for allocating zlib deflate compression state.
+ */
+ rb_define_const(mZlib, "DEF_MEM_LEVEL", INT2FIX(DEF_MEM_LEVEL));
+
+ /* The maximum memory level for allocating zlib deflate compression state.
+ */
+ rb_define_const(mZlib, "MAX_MEM_LEVEL", INT2FIX(MAX_MEM_LEVEL));
+
+ /* NO_FLUSH is the default flush method and allows deflate to decide how
+ * much data to accumulate before producing output in order to maximize
+ * compression.
+ */
+ rb_define_const(mZlib, "NO_FLUSH", INT2FIX(Z_NO_FLUSH));
+
+ /* The SYNC_FLUSH method flushes all pending output to the output buffer
+ * and the output is aligned on a byte boundary. Flushing may degrade
+ * compression so it should be used only when necessary, such as at a
+ * request or response boundary for a network stream.
+ */
+ rb_define_const(mZlib, "SYNC_FLUSH", INT2FIX(Z_SYNC_FLUSH));
+
+ /* Flushes all output as with SYNC_FLUSH, and the compression state is
+ * reset so that decompression can restart from this point if previous
+ * compressed data has been damaged or if random access is desired. Like
+ * SYNC_FLUSH, using FULL_FLUSH too often can seriously degrade
+ * compression.
+ */
+ rb_define_const(mZlib, "FULL_FLUSH", INT2FIX(Z_FULL_FLUSH));
+
+ /* Processes all pending input and flushes pending output. */
+ rb_define_const(mZlib, "FINISH", INT2FIX(Z_FINISH));
+
+#if GZIP_SUPPORT
+ id_write = rb_intern("write");
+ id_read = rb_intern("read");
+ id_readpartial = rb_intern("readpartial");
+ id_flush = rb_intern("flush");
+ id_seek = rb_intern("seek");
+ id_close = rb_intern("close");
+ id_path = rb_intern("path");
+ id_input = rb_intern("@input");
+
+ cGzipFile = rb_define_class_under(mZlib, "GzipFile", rb_cObject);
+ cGzError = rb_define_class_under(cGzipFile, "Error", cZError);
+
+ /* input gzipped string */
+ rb_define_attr(cGzError, "input", 1, 0);
+ rb_define_method(cGzError, "inspect", gzfile_error_inspect, 0);
+
+ cNoFooter = rb_define_class_under(cGzipFile, "NoFooter", cGzError);
+ cCRCError = rb_define_class_under(cGzipFile, "CRCError", cGzError);
+ cLengthError = rb_define_class_under(cGzipFile,"LengthError",cGzError);
+
+ cGzipWriter = rb_define_class_under(mZlib, "GzipWriter", cGzipFile);
+ cGzipReader = rb_define_class_under(mZlib, "GzipReader", cGzipFile);
+ rb_include_module(cGzipReader, rb_mEnumerable);
+
+ rb_define_singleton_method(cGzipFile, "wrap", rb_gzfile_s_wrap, -1);
+ rb_undef_alloc_func(cGzipFile);
+ rb_define_method(cGzipFile, "to_io", rb_gzfile_to_io, 0);
+ rb_define_method(cGzipFile, "crc", rb_gzfile_crc, 0);
+ rb_define_method(cGzipFile, "mtime", rb_gzfile_mtime, 0);
+ rb_define_method(cGzipFile, "level", rb_gzfile_level, 0);
+ rb_define_method(cGzipFile, "os_code", rb_gzfile_os_code, 0);
+ rb_define_method(cGzipFile, "orig_name", rb_gzfile_orig_name, 0);
+ rb_define_method(cGzipFile, "comment", rb_gzfile_comment, 0);
+ rb_define_method(cGzipReader, "lineno", rb_gzfile_lineno, 0);
+ rb_define_method(cGzipReader, "lineno=", rb_gzfile_set_lineno, 1);
+ rb_define_method(cGzipWriter, "mtime=", rb_gzfile_set_mtime, 1);
+ rb_define_method(cGzipWriter, "orig_name=", rb_gzfile_set_orig_name,1);
+ rb_define_method(cGzipWriter, "comment=", rb_gzfile_set_comment, 1);
+ rb_define_method(cGzipFile, "close", rb_gzfile_close, 0);
+ rb_define_method(cGzipFile, "finish", rb_gzfile_finish, 0);
+ rb_define_method(cGzipFile, "closed?", rb_gzfile_closed_p, 0);
+ rb_define_method(cGzipReader, "eof", rb_gzfile_eof_p, 0);
+ rb_define_method(cGzipReader, "eof?", rb_gzfile_eof_p, 0);
+ rb_define_method(cGzipFile, "sync", rb_gzfile_sync, 0);
+ rb_define_method(cGzipFile, "sync=", rb_gzfile_set_sync, 1);
+ rb_define_method(cGzipReader, "pos", rb_gzfile_total_out, 0);
+ rb_define_method(cGzipWriter, "pos", rb_gzfile_total_in, 0);
+ rb_define_method(cGzipReader, "tell", rb_gzfile_total_out, 0);
+ rb_define_method(cGzipWriter, "tell", rb_gzfile_total_in, 0);
+
+ rb_define_singleton_method(cGzipWriter, "open", rb_gzwriter_s_open,-1);
+ rb_define_alloc_func(cGzipWriter, rb_gzwriter_s_allocate);
+ rb_define_method(cGzipWriter, "initialize", rb_gzwriter_initialize,-1);
+ rb_define_method(cGzipWriter, "flush", rb_gzwriter_flush, -1);
+ rb_define_method(cGzipWriter, "write", rb_gzwriter_write, 1);
+ rb_define_method(cGzipWriter, "putc", rb_gzwriter_putc, 1);
+ rb_define_method(cGzipWriter, "<<", rb_gzwriter_addstr, 1);
+ rb_define_method(cGzipWriter, "printf", rb_gzwriter_printf, -1);
+ rb_define_method(cGzipWriter, "print", rb_gzwriter_print, -1);
+ rb_define_method(cGzipWriter, "puts", rb_gzwriter_puts, -1);
+
+ rb_define_singleton_method(cGzipReader, "open", rb_gzreader_s_open,-1);
+ rb_define_alloc_func(cGzipReader, rb_gzreader_s_allocate);
+ rb_define_method(cGzipReader, "initialize", rb_gzreader_initialize, -1);
+ rb_define_method(cGzipReader, "rewind", rb_gzreader_rewind, 0);
+ rb_define_method(cGzipReader, "unused", rb_gzreader_unused, 0);
+ rb_define_method(cGzipReader, "read", rb_gzreader_read, -1);
+ rb_define_method(cGzipReader, "readpartial", rb_gzreader_readpartial, -1);
+ rb_define_method(cGzipReader, "getc", rb_gzreader_getc, 0);
+ rb_define_method(cGzipReader, "getbyte", rb_gzreader_getbyte, 0);
+ rb_define_method(cGzipReader, "readchar", rb_gzreader_readchar, 0);
+ rb_define_method(cGzipReader, "readbyte", rb_gzreader_readbyte, 0);
+ rb_define_method(cGzipReader, "each_byte", rb_gzreader_each_byte, 0);
+ rb_define_method(cGzipReader, "each_char", rb_gzreader_each_char, 0);
+ rb_define_method(cGzipReader, "bytes", rb_gzreader_bytes, 0);
+ rb_define_method(cGzipReader, "ungetc", rb_gzreader_ungetc, 1);
+ rb_define_method(cGzipReader, "ungetbyte", rb_gzreader_ungetbyte, 1);
+ rb_define_method(cGzipReader, "gets", rb_gzreader_gets, -1);
+ rb_define_method(cGzipReader, "readline", rb_gzreader_readline, -1);
+ rb_define_method(cGzipReader, "each", rb_gzreader_each, -1);
+ rb_define_method(cGzipReader, "each_line", rb_gzreader_each, -1);
+ rb_define_method(cGzipReader, "lines", rb_gzreader_lines, -1);
+ rb_define_method(cGzipReader, "readlines", rb_gzreader_readlines, -1);
+
+ /* The OS code of current host */
+ rb_define_const(mZlib, "OS_CODE", INT2FIX(OS_CODE));
+ /* OS code for MSDOS hosts */
+ rb_define_const(mZlib, "OS_MSDOS", INT2FIX(OS_MSDOS));
+ /* OS code for Amiga hosts */
+ rb_define_const(mZlib, "OS_AMIGA", INT2FIX(OS_AMIGA));
+ /* OS code for VMS hosts */
+ rb_define_const(mZlib, "OS_VMS", INT2FIX(OS_VMS));
+ /* OS code for UNIX hosts */
+ rb_define_const(mZlib, "OS_UNIX", INT2FIX(OS_UNIX));
+ /* OS code for Atari hosts */
+ rb_define_const(mZlib, "OS_ATARI", INT2FIX(OS_ATARI));
+ /* OS code for OS2 hosts */
+ rb_define_const(mZlib, "OS_OS2", INT2FIX(OS_OS2));
+ /* OS code for Mac OS hosts */
+ rb_define_const(mZlib, "OS_MACOS", INT2FIX(OS_MACOS));
+ /* OS code for TOPS-20 hosts */
+ rb_define_const(mZlib, "OS_TOPS20", INT2FIX(OS_TOPS20));
+ /* OS code for Win32 hosts */
+ rb_define_const(mZlib, "OS_WIN32", INT2FIX(OS_WIN32));
+ /* OS code for VM OS hosts */
+ rb_define_const(mZlib, "OS_VMCMS", INT2FIX(OS_VMCMS));
+ /* OS code for Z-System hosts */
+ rb_define_const(mZlib, "OS_ZSYSTEM", INT2FIX(OS_ZSYSTEM));
+ /* OS code for CP/M hosts */
+ rb_define_const(mZlib, "OS_CPM", INT2FIX(OS_CPM));
+ /* OS code for QDOS hosts */
+ rb_define_const(mZlib, "OS_QDOS", INT2FIX(OS_QDOS));
+ /* OS code for RISC OS hosts */
+ rb_define_const(mZlib, "OS_RISCOS", INT2FIX(OS_RISCOS));
+ /* OS code for unknown hosts */
+ rb_define_const(mZlib, "OS_UNKNOWN", INT2FIX(OS_UNKNOWN));
+
+#endif /* GZIP_SUPPORT */
+}
+
+/* Document error classes. */
+
+/*
+ * Document-class: Zlib::Error
+ *
+ * The superclass for all exceptions raised by Ruby/zlib.
+ *
+ * The following exceptions are defined as subclasses of Zlib::Error. These
+ * exceptions are raised when zlib library functions return with an error
+ * status.
+ *
+ * - Zlib::StreamEnd
+ * - Zlib::NeedDict
+ * - Zlib::DataError
+ * - Zlib::StreamError
+ * - Zlib::MemError
+ * - Zlib::BufError
+ * - Zlib::VersionError
+ *
+ */
+
+/*
+ * Document-class: Zlib::StreamEnd
+ *
+ * Subclass of Zlib::Error
+ *
+ * When zlib returns a Z_STREAM_END
+ * is return if the end of the compressed data has been reached
+ * and all uncompressed out put has been produced.
+ *
+ */
+
+/*
+ * Document-class: Zlib::NeedDict
+ *
+ * Subclass of Zlib::Error
+ *
+ * When zlib returns a Z_NEED_DICT
+ * if a preset dictionary is needed at this point.
+ *
+ * Used by Zlib::Inflate.inflate and <tt>Zlib.inflate</tt>
+ */
+
+/*
+ * Document-class: Zlib::VersionError
+ *
+ * Subclass of Zlib::Error
+ *
+ * When zlib returns a Z_VERSION_ERROR,
+ * usually if the zlib library version is incompatible with the
+ * version assumed by the caller.
+ *
+ */
+
+/*
+ * Document-class: Zlib::MemError
+ *
+ * Subclass of Zlib::Error
+ *
+ * When zlib returns a Z_MEM_ERROR,
+ * usually if there was not enough memory.
+ *
+ */
+
+/*
+ * Document-class: Zlib::StreamError
+ *
+ * Subclass of Zlib::Error
+ *
+ * When zlib returns a Z_STREAM_ERROR,
+ * usually if the stream state was inconsistent.
+ *
+ */
+
+/*
+ * Document-class: Zlib::BufError
+ *
+ * Subclass of Zlib::Error when zlib returns a Z_BUF_ERROR.
+ *
+ * Usually if no progress is possible.
+ *
+ */
+
+/*
+ * Document-class: Zlib::DataError
+ *
+ * Subclass of Zlib::Error when zlib returns a Z_DATA_ERROR.
+ *
+ * Usually if a stream was prematurely freed.
+ *
+ */
+
+/*
+ * Document-class: Zlib::GzipFile::Error
+ *
+ * Base class of errors that occur when processing GZIP files.
+ */
+
+/*
+ * Document-class: Zlib::GzipFile::NoFooter
+ *
+ * Raised when gzip file footer is not found.
+ */
+
+/*
+ * Document-class: Zlib::GzipFile::CRCError
+ *
+ * Raised when the CRC checksum recorded in gzip file footer is not equivalent
+ * to the CRC checksum of the actual uncompressed data.
+ */
+
+/*
+ * Document-class: Zlib::GzipFile::LengthError
+ *
+ * Raised when the data length recorded in the gzip file footer is not equivalent
+ * to the length of the actual uncompressed data.
+ */
+
+